optimizeIndirectCommandBuffer(_:range:)
Encodes a command that can improve the performance of a range of commands within an indirect command buffer.
Declaration
func optimizeIndirectCommandBuffer(_ buffer: any MTLIndirectCommandBuffer, range: Range<Int>)Parameters
- buffer:
An indirect command buffer the command optimizes.
- range:
A range of commands within
indirectCommandBuffer.
Discussion
This command can reduce the time it takes the GPU to run the commands within an indirect command buffer by removing its redundancies. For example, an indirect command buffer may have empty commands or commands that duplicate identical state. Redundancies like these can come from multiple compute functions that encode commands in parallel, which can sometimes reset commands or configure identical states multiple times.
You can’t run any commands that start or end at an index within that range, or that cross into another optimized range. However, you can reuse the range you optimize by resetting it and then encoding new commands to it.