Fix a DrawElements bug in the Metal backend.

The indexOffset of the draw was not being used. It must be
included in the indexBufferOffset.
Renamed indexBufferOffset -> indexBufferBaseOffset.
Add a DrawElements test which exercises zero and non-zero index offsets.
This commit is contained in:
Stephen White
2018-03-17 13:10:03 -04:00
committed by Corentin Wallez
parent a5aacc9cad
commit 8c231b6990
4 changed files with 146 additions and 7 deletions

View File

@@ -243,7 +243,7 @@ namespace backend { namespace opengl {
PipelineBase* lastPipeline = nullptr;
PipelineGL* lastGLPipeline = nullptr;
RenderPipeline* lastRenderPipeline = nullptr;
uint32_t indexBufferOffset = 0;
uint32_t indexBufferBaseOffset = 0;
PersistentPipelineState persistentPipelineState;
persistentPipelineState.SetDefaultState();
@@ -505,7 +505,7 @@ namespace backend { namespace opengl {
lastRenderPipeline->GetGLPrimitiveTopology(), draw->indexCount,
formatType,
reinterpret_cast<void*>(draw->firstIndex * formatSize +
indexBufferOffset),
indexBufferBaseOffset),
draw->instanceCount, draw->firstInstance);
} else {
// This branch is only needed on OpenGL < 4.2
@@ -513,7 +513,7 @@ namespace backend { namespace opengl {
lastRenderPipeline->GetGLPrimitiveTopology(), draw->indexCount,
formatType,
reinterpret_cast<void*>(draw->firstIndex * formatSize +
indexBufferOffset),
indexBufferBaseOffset),
draw->instanceCount);
}
} break;
@@ -635,7 +635,7 @@ namespace backend { namespace opengl {
case Command::SetIndexBuffer: {
SetIndexBufferCmd* cmd = mCommands.NextCommand<SetIndexBufferCmd>();
indexBufferOffset = cmd->offset;
indexBufferBaseOffset = cmd->offset;
inputBuffers.OnSetIndexBuffer(cmd->buffer.Get());
} break;