executeCommands(buffer:indirectBuffer:)
Encodes a command that runs an indirect range of commands from an indirect command buffer.
Declaration
func executeCommands(buffer indirectCommandBuffer: any MTLIndirectCommandBuffer, indirectBuffer indirectRangeBuffer: MTLGPUAddress)Parameters
- indirectCommandBuffer:
A Mtlindirectcommandbuffer instance that contains other commands the current command runs.
- indirectRangeBuffer:
GPUAddress of a Mtlbuffer instance with data that matches the layout of the Mtlindirectcommandbufferexecutionrange structure. This address requires 4-byte alignment.
Discussion
Use this method to indicate to Metal the span of indices in the command buffer to execute indirectly via an MTLBuffer instance you provide in the indirectRangeBuffer parameter. This allows you to calculate the span of commands Metal executes in the GPU timeline, enabling GPU-driven workflows.
Metal requires that the contents of this buffer match the layout of struct MTLIndirectCommandBufferExecutionRange, which specifies a location and a length within the indirect command buffer. You are responsible for ensuring the address of this buffer has 4-byte alignment.
Use an instance of MTLResidencySet to mark residency of the indirect buffer that the indirectRangeBuffer parameter references.