Add proper support for IndexType and uint32 indices

This commit is contained in:
SirLynix
2022-04-04 09:02:00 +02:00
parent 66ff6cfa81
commit 9d526741b9
34 changed files with 188 additions and 57 deletions

View File

@@ -105,9 +105,17 @@ namespace Nz
else if constexpr (std::is_same_v<T, DrawIndexedData>)
{
const UInt8* origin = 0; //< For an easy way to cast an integer to a pointer
origin += command.states.indexBufferOffset;
switch (command.states.indexBufferType)
{
case IndexType::U8: origin += command.firstIndex * sizeof(UInt8); break;
case IndexType::U16: origin += command.firstIndex * sizeof(UInt16); break;
case IndexType::U32: origin += command.firstIndex * sizeof(UInt32); break;
}
ApplyStates(*context, command.states);
context->glDrawElementsInstanced(ToOpenGL(command.states.pipeline->GetPipelineInfo().primitiveMode), command.indexCount, GL_UNSIGNED_SHORT, origin + command.firstIndex * sizeof(UInt16), command.instanceCount);
context->glDrawElementsInstanced(ToOpenGL(command.states.pipeline->GetPipelineInfo().primitiveMode), command.indexCount, ToOpenGL(command.states.indexBufferType), origin, command.instanceCount);
}
else if constexpr (std::is_same_v<T, EndDebugRegionData>)
{