<!--
{
  "availability" : [
    "iOS: 17.0.0 -",
    "iPadOS: 17.0.0 -",
    "macCatalyst: 17.0.0 -",
    "macOS: 14.0.0 -",
    "tvOS: 17.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Metal",
  "identifier" : "/documentation/Metal/MTLComputeCommandEncoder/setBufferOffset(offset:attributeStride:index:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Metal"
    ],
    "preciseIdentifier" : "c:objc(pl)MTLComputeCommandEncoder(im)setBufferOffset:attributeStride:atIndex:"
  },
  "title" : "setBufferOffset(offset:attributeStride:index:)"
}
-->

# setBufferOffset(offset:attributeStride:index:)

Changes where the data begins and the distance between adjacent elements in a buffer already bound to the buffer argument table.

```
func setBufferOffset(offset: Int, attributeStride stride: Int, index: Int)
```

## Parameters

`offset`

Where the data to bind begins, in bytes, from the start of the bound buffer.

`stride`

The number of bytes between the start of one element and the start of the next.

`index`

The index of the buffer to change in the argument table.

## Discussion> Important:
> Only call this method when the buffer is part of ``doc://com.apple.metal/documentation/Metal/MTLComputePipelineDescriptor/stageInputDescriptor`` and has its stride set to ``doc://com.apple.metal/documentation/Metal/MTLBufferLayoutStrideDynamic``.

_ _Prefer calling this method to unbinding and then rebinding data.

For buffers binding to an argument using the `device` address space, align the offset to the data type’s size. The maximum size for an offset is `16` bytes.

For buffers in the `constant` address space, the minimum alignment depends on the hardware running your app. See the [Metal feature set tables (PDF)](https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf) for information on each Apple GPU family.

---

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)