---
title: "executeCommandsInBuffer(_:range:)"
framework: metal
role: symbol
role_heading: Instance Method
path: "metal/mtlcomputecommandencoder/executecommandsinbuffer(_:range:)"
---

# executeCommandsInBuffer(_:range:)

Encodes an instruction to run commands from an indirect buffer.

## Declaration

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

## Parameters

- `buffer`: The doc://com.apple.metal/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 doc://com.apple.metal/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 doc://com.apple.metal/documentation/Metal/MTLGPUFamily/apple10, don’t have this limitation.

## See Also

### Dispatching from indirect command buffers

- [dispatchThreadgroups(indirectBuffer:indirectBufferOffset:threadsPerThreadgroup:)](metal/mtlcomputecommandencoder/dispatchthreadgroups(indirectbuffer:indirectbufferoffset:threadsperthreadgroup:).md)
- [executeCommandsInBuffer(_:indirectBuffer:offset:)](metal/mtlcomputecommandencoder/executecommandsinbuffer(_:indirectbuffer:offset:).md)
- [executeCommands(in:indirectBuffer:indirectBufferOffset:)](metal/mtlcomputecommandencoder/executecommands(in:indirectbuffer:indirectbufferoffset:).md)
- [executeCommands(in:with:)](metal/mtlcomputecommandencoder/executecommands(in:with:).md)
