Skip to content

Commit

Permalink
[Metal] Simplified condition to choose drawPrimitives/drawIndexedPrim…
Browse files Browse the repository at this point in the history
…itives versions.
  • Loading branch information
LukasBanana committed Aug 16, 2024
1 parent 5bb7ffe commit 031db6f
Showing 1 changed file with 43 additions and 51 deletions.
94 changes: 43 additions & 51 deletions sources/Renderer/Metal/Command/MTCommandExecutor.mm
Original file line number Diff line number Diff line change
Expand Up @@ -304,30 +304,26 @@
else
{
id<MTLRenderCommandEncoder> renderEncoder = context.FlushAndGetRenderEncoder();
const bool hasBaseInstance = (cmd->baseInstance != 0);
if (cmd->instanceCount != 1 || hasBaseInstance)
if (cmd->baseInstance != 0)
{
if (hasBaseInstance)
{
/* Suppored since iOS 9.0 */
[renderEncoder
drawPrimitives: context.GetPrimitiveType()
vertexStart: cmd->vertexStart
vertexCount: cmd->vertexCount
instanceCount: cmd->instanceCount
baseInstance: cmd->baseInstance
];
}
else
{
/* Suppored since iOS 8.0 */
[renderEncoder
drawPrimitives: context.GetPrimitiveType()
vertexStart: cmd->vertexStart
vertexCount: cmd->vertexCount
instanceCount: cmd->instanceCount
];
}
/* Suppored since iOS 9.0 */
[renderEncoder
drawPrimitives: context.GetPrimitiveType()
vertexStart: cmd->vertexStart
vertexCount: cmd->vertexCount
instanceCount: cmd->instanceCount
baseInstance: cmd->baseInstance
];
}
else if (cmd->instanceCount != 1)
{
/* Suppored since iOS 8.0 */
[renderEncoder
drawPrimitives: context.GetPrimitiveType()
vertexStart: cmd->vertexStart
vertexCount: cmd->vertexCount
instanceCount: cmd->instanceCount
];
}
else
{
Expand Down Expand Up @@ -366,35 +362,31 @@
else
{
id<MTLRenderCommandEncoder> renderEncoder = context.FlushAndGetRenderEncoder();
const bool hasBaseVertexOrInstance = (cmd->baseVertex != 0 || cmd->baseInstance != 0);
if (cmd->instanceCount != 1 || hasBaseVertexOrInstance)
if (cmd->baseVertex != 0 || cmd->baseInstance != 0)
{
/* Suppored since iOS 9.0 */
[renderEncoder
drawIndexedPrimitives: context.GetPrimitiveType()
indexCount: cmd->indexCount
indexType: context.GetIndexType()
indexBuffer: context.GetIndexBuffer()
indexBufferOffset: context.GetIndexBufferOffset(cmd->firstIndex)
instanceCount: cmd->instanceCount
baseVertex: cmd->baseVertex
baseInstance: cmd->baseInstance
];
}
else if (cmd->instanceCount != 1)
{
if (hasBaseVertexOrInstance)
{
/* Suppored since iOS 9.0 */
[renderEncoder
drawIndexedPrimitives: context.GetPrimitiveType()
indexCount: cmd->indexCount
indexType: context.GetIndexType()
indexBuffer: context.GetIndexBuffer()
indexBufferOffset: context.GetIndexBufferOffset(cmd->firstIndex)
instanceCount: cmd->instanceCount
baseVertex: cmd->baseVertex
baseInstance: cmd->baseInstance
];
}
else
{
/* Suppored since iOS 8.0 */
[renderEncoder
drawIndexedPrimitives: context.GetPrimitiveType()
indexCount: cmd->indexCount
indexType: context.GetIndexType()
indexBuffer: context.GetIndexBuffer()
indexBufferOffset: context.GetIndexBufferOffset(cmd->firstIndex)
instanceCount: cmd->instanceCount
];
}
/* Suppored since iOS 8.0 */
[renderEncoder
drawIndexedPrimitives: context.GetPrimitiveType()
indexCount: cmd->indexCount
indexType: context.GetIndexType()
indexBuffer: context.GetIndexBuffer()
indexBufferOffset: context.GetIndexBufferOffset(cmd->firstIndex)
instanceCount: cmd->instanceCount
];
}
else
{
Expand Down

0 comments on commit 031db6f

Please sign in to comment.