<!--
{
  "availability" : [
    "iOS: 12.0.0 -",
    "iPadOS: 12.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.14.0 -",
    "tvOS: 12.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Metal",
  "identifier" : "/documentation/Metal/MTLIndirectRenderCommand/setVertexBuffer(_:offset:at:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Metal"
    ],
    "preciseIdentifier" : "c:objc(pl)MTLIndirectRenderCommand(im)setVertexBuffer:offset:atIndex:"
  },
  "title" : "setVertexBuffer(_:offset:at:)"
}
-->

# setVertexBuffer(_:offset:at:)

Sets a vertex buffer argument for the command.

```
func setVertexBuffer(_ buffer: any MTLBuffer, offset: Int, at index: Int)
```

## Parameters

`buffer`

The buffer to set in the buffer argument table.

`offset`

The location, in bytes relative to start of `buffer`,
of the first byte of data for the vertex shader.

`index`

An index in the buffer argument table. The maximum index is determined when you created the indirect command buffer.

## Discussion

You don’t need to call this method if you create an indirect command buffer with its
[`inheritBuffers`](/documentation/Metal/MTLIndirectCommandBufferDescriptor/inheritBuffers) property equal to
<doc://com.apple.documentation/documentation/Swift/true>.
The command gets the arguments from the parent encoder when it runs.

If you need to pass other kinds of parameters to your shader, such as textures and samplers, create an argument buffer and pass it to the shader using this method.

---

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)