<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "macOS: 27.0.0 -",
    "tvOS: 27.0.0 -",
    "visionOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "RealityKit",
  "identifier" : "/documentation/RealityKit/ComputeGraphComponent/setBuffer(_:bufferOffset:elementCount:at:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "RealityKit",
      "ComputeGraph",
      "_RealityKit_ComputeGraph"
    ],
    "preciseIdentifier" : "s:24_RealityKit_ComputeGraph0cD9ComponentV9setBuffer_12bufferOffset12elementCount2atySo9MTLBuffer_pSg_S2iSgSitF"
  },
  "title" : "setBuffer(_:bufferOffset:elementCount:at:)"
}
-->

# setBuffer(_:bufferOffset:elementCount:at:)

Binds a Metal buffer to a parameter.

```
mutating func setBuffer(_ buffer: (any MTLBuffer)?, bufferOffset: Int = 0, elementCount: Int? = nil, at index: Int)
```

## Parameters

`buffer`

The `MTLBuffer` to bind.

`bufferOffset`

Byte offset into `buffer`. Defaults to `0`.

`elementCount`

Number of elements in the buffer, for buffers with variable capacity.

`at`

Index into the device buffers table.

---

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)