<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 14.0.0 -",
    "macOS: 11.0.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "Metal",
  "identifier" : "/documentation/Metal/MTLComputeCommandEncoder/executeCommandsInBuffer(_:indirectBuffer:offset:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Metal"
    ],
    "preciseIdentifier" : "s:So24MTLComputeCommandEncoderP5MetalE23executeCommandsInBuffer_08indirectH06offsetySo011MTLIndirectbH0_p_So9MTLBuffer_pSitF"
  },
  "title" : "executeCommandsInBuffer(_:indirectBuffer:offset:)"
}
-->

# executeCommandsInBuffer(_:indirectBuffer:offset:)

Encodes an instruction to run commands from an indirect buffer, using another buffer to provide the command range.

```
func executeCommandsInBuffer(_ buffer: any MTLIndirectCommandBuffer, indirectBuffer indirectRangeBuffer: any MTLBuffer, offset: Int)
```

## Parameters

`buffer`

The [`MTLIndirectCommandBuffer`](/documentation/Metal/MTLIndirectCommandBuffer) instance containing the commands to execute.

`indirectRangeBuffer`

An [`MTLBuffer`](/documentation/Metal/MTLBuffer) instance with data that matches the layout of the [`MTLIndirectCommandBufferExecutionRange`](/documentation/Metal/MTLIndirectCommandBufferExecutionRange) structure.

    When running on Metal devices that belong to the [`MTLGPUFamily.mac2`](/documentation/Metal/MTLGPUFamily/mac2)     GPU family, the maximum value for the [`length`](/documentation/Metal/MTLIndirectCommandBufferExecutionRange/length)     property of that structure is 0x4000 (16,384).
    Metal devices that belong to an Apple silicon family, such as [`MTLGPUFamily.apple10`](/documentation/Metal/MTLGPUFamily/apple10)    , don’t have this limitation.

`offset`

The number of bytes from the start of `indirectRangeBuffer` containing the execution range to use. Align the offset on a multiple of `4`.

---

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)