---
title: "drawIndexedPrimitives(type:indexType:indexBuffer:indexBufferOffset:indirectBuffer:indirectBufferOffset:)"
framework: metal
role: symbol
role_heading: Instance Method
path: "metal/mtlrendercommandencoder/drawindexedprimitives(type:indextype:indexbuffer:indexbufferoffset:indirectbuffer:indirectbufferoffset:)"
---

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

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

## Declaration

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

## Parameters

- `primitiveType`: An doc://com.apple.metal/documentation/Metal/MTLPrimitiveType instance that represents how the command interprets vertex argument data. See the doc://com.apple.metal/documentation/Metal/MTLRenderCommandEncoder/setVertexBuffer(_:offset:index:) method and its siblings for more information about setting an entry in the vertex shader argument table for buffers.
- `indexType`: An doc://com.apple.metal/documentation/Metal/MTLIndexType instance that represents the index’s format, including doc://com.apple.metal/documentation/Metal/MTLIndexType/uint16 and doc://com.apple.metal/documentation/Metal/MTLIndexType/uint32.
- `indexBuffer`: An doc://com.apple.metal/documentation/Metal/MTLBuffer instance that contains the vertex indices of the indexType format.
- `indexBufferOffset`: An integer that represents the location that’s a multiple of the index size from the start of indexBuffer where the vertex indices begin.
- `indirectBuffer`: An doc://com.apple.metal/documentation/Metal/MTLBuffer instance with data that matches the layout of the doc://com.apple.metal/documentation/Metal/MTLDrawIndexedPrimitivesIndirectArguments structure.
- `indirectBufferOffset`: An integer that represents the location, in bytes, from the start of indirectBuffer where the indirect arguments structure begins. See the https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf to check for offset alignment requirements for buffers in device and constant address space.

## Discussion

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. You can complete a primitive and start a new one by passing a sentinel index value that’s the largest unsigned integer possible for indexType. For example, the largest unsigned integer for MTLIndexType.uint16 and MTLIndexType.uint32 is 0xFFFF and 0xFFFFFFFF, respectively. The command finishes the current primitive and begins drawing a new one each time the command reads a sentinel index value. 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 indexed vertices

- [drawIndexedPrimitives(type:indexCount:indexType:indexBuffer:indexBufferOffset:)](metal/mtlrendercommandencoder/drawindexedprimitives(type:indexcount:indextype:indexbuffer:indexbufferoffset:).md)
- [drawIndexedPrimitives(type:indexCount:indexType:indexBuffer:indexBufferOffset:instanceCount:)](metal/mtlrendercommandencoder/drawindexedprimitives(type:indexcount:indextype:indexbuffer:indexbufferoffset:instancecount:).md)
- [drawIndexedPrimitives(type:indexCount:indexType:indexBuffer:indexBufferOffset:instanceCount:baseVertex:baseInstance:)](metal/mtlrendercommandencoder/drawindexedprimitives(type:indexcount:indextype:indexbuffer:indexbufferoffset:instancecount:basevertex:baseinstance:).md)
