<!--
{
  "availability" : [
    "iOS: 26.0.0 -",
    "iPadOS: 26.0.0 -",
    "macCatalyst: 26.0.0 -",
    "macOS: 26.0.0 -",
    "tvOS: 26.0.0 -",
    "visionOS: 26.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Metal",
  "identifier" : "/documentation/Metal/MTL4RenderCommandEncoder/drawPrimitives(primitiveType:vertexStart:vertexCount:instanceCount:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Metal"
    ],
    "preciseIdentifier" : "c:objc(pl)MTL4RenderCommandEncoder(im)drawPrimitives:vertexStart:vertexCount:instanceCount:"
  },
  "title" : "drawPrimitives(primitiveType:vertexStart:vertexCount:instanceCount:)"
}
-->

# drawPrimitives(primitiveType:vertexStart:vertexCount:instanceCount:)

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

```
func drawPrimitives(primitiveType: MTLPrimitiveType, vertexStart: Int, vertexCount: Int, instanceCount: Int)
```

## Parameters

`primitiveType`

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

`vertexStart`

The lowest value the command passes to your vertex shader function’s parameter with
the `vertex_id` attribute.

`vertexCount`

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

`instanceCount`

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

## Discussion

The command assigns each vertex a unique `vertex_id` value within its drawing instance
that increases from `vertexStart` through `(vertexStart + vertexCount - 1)`.

Additionally, the command assigns each drawing instance a unique `instance_id` value that increases
from `0` through `(instanceCount - 1)`.

Your vertex shader can use the `vertex_id` value to uniquely identify each vertex in each drawing instance, and the
`instance_id` value to identify which instance that vertex belongs to.

---

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)