<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.11.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Metal",
  "identifier" : "/documentation/Metal/MTLRenderCommandEncoder/drawIndexedPrimitives(type:indexCount:indexType:indexBuffer:indexBufferOffset:instanceCount:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Metal"
    ],
    "preciseIdentifier" : "c:objc(pl)MTLRenderCommandEncoder(im)drawIndexedPrimitives:indexCount:indexType:indexBuffer:indexBufferOffset:instanceCount:"
  },
  "title" : "drawIndexedPrimitives(type:indexCount:indexType:indexBuffer:indexBufferOffset:instanceCount:)"
}
-->

# drawIndexedPrimitives(type:indexCount:indexType:indexBuffer:indexBufferOffset:instanceCount:)

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

```
func drawIndexedPrimitives(type primitiveType: MTLPrimitiveType, indexCount: Int, indexType: MTLIndexType, indexBuffer: any MTLBuffer, indexBufferOffset: Int, instanceCount: Int)
```

## Parameters

`primitiveType`

An [`MTLPrimitiveType`](/documentation/Metal/MTLPrimitiveType) instance that represents how the command interprets vertex argument data.

    See the [`setVertexBuffer(_:offset:index:)`](/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.

`indexCount`

An integer that represents the number of vertices the command reads from `indexBuffer` for each instance.

`indexType`

An [`MTLIndexType`](/documentation/Metal/MTLIndexType) instance that represents the index’s format, including [`MTLIndexType.uint16`](/documentation/Metal/MTLIndexType/uint16) and [`MTLIndexType.uint32`](/documentation/Metal/MTLIndexType/uint32).

`indexBuffer`

An [`MTLBuffer`](/documentation/Metal/MTLBuffer) instance that contains the `indexCount` 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.

`instanceCount`

An integer that represents the number of times the command draws `primitiveType` with `indexCount` vertices.

## Discussion

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`](/documentation/Metal/MTLIndexType/uint16) and [`MTLIndexType.uint32`](/documentation/Metal/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`](/documentation/Metal/MTLCommandBuffer).

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)