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

# setKernelBuffer(_:offset:at:)

Sets a buffer for the compute function.

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

## Parameters

`buffer`

The buffer to set in the buffer argument table.

`offset`

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

`index`

An index in the buffer argument table.

## Discussion

If you created the indirect command buffer with [`inheritBuffers`](/documentation/Metal/MTLIndirectCommandBufferDescriptor/inheritBuffers) set to <doc://com.apple.documentation/documentation/Swift/true>, don’t call this method. The command gets the arguments from the parent encoder when you execute the command.

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)