Contents

drawPrimitives(type:indirectBuffer:indirectBufferOffset:)

Encodes a draw command that renders multiple instances of a geometric primitive with indirect arguments.

Declaration

func drawPrimitives(type primitiveType: MTLPrimitiveType, indirectBuffer: any MTLBuffer, indirectBufferOffset: Int)

Parameters

  • primitiveType:

    An Mtlprimitivetype instance that represents how the command interprets vertex argument data.

    See the Setvertexbuffer(_:offset:index:) method and its siblings for more information about setting an entry in the vertex shader argument table for buffers.

  • indirectBuffer:

    An Mtlbuffer instance with data that matches the layout of the Mtldrawprimitivesindirectarguments structure.

  • indirectBufferOffset:

    An integer that represents the location, in bytes, from the start of indirectBuffer where the indirect arguments structure begins.

    See the Metal Feature Set Tables to check for offset alignment requirements for buffers in device and constant address space.

Discussion

Indirect drawing methods may help your app avoid expensive latency costs. This is because the command reads arguments from an MTLBuffer instance instead of using the CPU to pass parameters to the command.

The method records the encoder’s current rendering state and resources the command needs as it runs. You can safely change the encoder’s render pipeline state to encode other commands after calling this method. Subsequent changes to the state don’t affect the commands already in the encoder’s MTLCommandBuffer.

See Also

Drawing with vertices