drawPrimitives(primitiveType:indirectBuffer:)
Encodes a draw command that renders multiple instances of a geometric primitive with indirect arguments.
Declaration
func drawPrimitives(primitiveType: MTLPrimitiveType, indirectBuffer: MTLGPUAddress)Parameters
- primitiveType:
A Mtlprimitivetype representing how the command interprets vertex argument data.
- indirectBuffer:
GPUAddress of a Mtlbuffer instance with data that matches the layout of the Mtldrawprimitivesindirectarguments structure. You are responsible for ensuring that the alignment of this address is 4 bytes.
Discussion
When you use this function, Metal reads the parameters to the draw command from an MTLBuffer instance, allowing you to implement a GPU-driven workflow where a compute pipeline state determines the draw arguments.
You are responsible for ensuring that the address of the indirect buffer you provide to this method has 4-byte alignment.
Because this is a non-indexed draw call, Metal interprets the contents of the indirect buffer to match the layout of struct MTLDrawPrimitivesIndirectArguments.
Use an instance of MTLResidencySet to mark residency of the indirect buffer that the indirectBuffer parameter references.