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

# executeCommandsInBuffer(_:indirectBuffer:offset:)

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

## Declaration

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

## Parameters

- `buffer`: The doc://com.apple.metal/documentation/Metal/MTLIndirectCommandBuffer instance containing the commands to execute.
- `indirectRangeBuffer`: An doc://com.apple.metal/documentation/Metal/MTLBuffer instance with data that matches the layout of the doc://com.apple.metal/documentation/Metal/MTLIndirectCommandBufferExecutionRange structure. When running on Metal devices that belong to the doc://com.apple.metal/documentation/Metal/MTLGPUFamily/mac2 GPU family, the maximum value for the doc://com.apple.metal/documentation/Metal/MTLIndirectCommandBufferExecutionRange/length property of that structure is 0x4000 (16,384). Metal devices that belong to an Apple silicon family, such as doc://com.apple.metal/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.

## See Also

### Dispatching from indirect command buffers

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