Instance Method

drawIndexedPrimitives(type:indexType:indexBuffer:indexBufferOffset:indirectBuffer:indirectBufferOffset:)

Encodes a command to render a number of instances of primitives using index data in contiguous array elements, starting from the base vertex of a base instance.

Required.

Declaration

func drawIndexedPrimitives(type primitiveType: MTLPrimitiveType, indexType: MTLIndexType, indexBuffer: MTLBuffer, indexBufferOffset: Int, indirectBuffer: MTLBuffer, indirectBufferOffset: Int)

Parameters

primitiveType

The type of primitive that the vertices are assembled into.

indexType

The data type of the indices.

indexBuffer

A buffer that contains indices to vertices.

indexBufferOffset

Byte offset within indexBuffer to start reading indices from.

indirectBuffer

A MTLBuffer object from which the device reads draw call arguments, as laid out in the MTLDrawIndexedPrimitivesIndirectArguments structure.

indirectBufferOffset

Byte offset within indirectBuffer to start reading arguments from. Must be a multiple of 4 bytes.

Discussion

The draw call arguments are read from a GPU buffer instead of being directly passed as method parameters via the CPU. Your app may avoid expensive latency costs by using indirect drawing.

When a draw command is encoded, any necessary references to rendering state or resources previously set on the encoder are recorded as part of the command. After encoding a command, you can safely change the encoding state to set up parameters needed to encode other commands.

See Also

Drawing Geometric Primitives and Tessellated Patches Indirectly

Specifying Drawing and Dispatch Arguments Indirectly

Use indirect commands if you don't know your draw or dispatch call arguments when you encode the command.

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

Encodes a command to render a number of instances of primitives using vertex data in contiguous array elements, starting from a base instance.

Required.

func drawPatches(numberOfPatchControlPoints: Int, patchIndexBuffer: MTLBuffer?, patchIndexBufferOffset: Int, indirectBuffer: MTLBuffer, indirectBufferOffset: Int)

Encodes a command to render a number of instances of tessellated patches, using an indirect buffer.

Required.

struct MTLDrawIndexedPrimitivesIndirectArguments

The data layout required for drawing indexed primitives via indirect buffer calls.

struct MTLDrawPrimitivesIndirectArguments

The data layout required for drawing primitives via indirect buffer calls.

struct MTLDrawPatchIndirectArguments

The data layout required for drawing patches via indirect buffer calls.