<!--
{
  "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(_:range:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Metal"
    ],
    "preciseIdentifier" : "s:So24MTLComputeCommandEncoderP5MetalE23executeCommandsInBuffer_5rangeySo011MTLIndirectbH0_p_SnySiGtF"
  },
  "title" : "executeCommandsInBuffer(_:range:)"
}
-->

# executeCommandsInBuffer(_:range:)

Encodes an instruction to run commands from an indirect buffer.

```
func executeCommandsInBuffer(_ buffer: any MTLIndirectCommandBuffer, range: Range<Int>)
```

## Parameters

`buffer`

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

`range`

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

---

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)