---
title: "executeCommandsInBuffer:withRange:"
framework: metal
role: symbol
role_heading: Instance Method
path: "metal/mtl4computecommandencoder/executecommandsinbuffer:withrange:"
---

# executeCommandsInBuffer:withRange:

Encodes a command to execute a series of commands from an indirect command buffer.

## Declaration

```occ
- (void) executeCommandsInBuffer:(id<MTLIndirectCommandBuffer>) indirectCommandBuffer withRange:(NSRange) executionRange;
```

## Parameters

- `indirectCommandBuffer`: doc://com.apple.metal/documentation/Metal/MTLIndirectCommandBuffer instance containing the commands to execute.
- `executionRange`: The range of commands to execute.

## Discussion

Discussion Use this method to encode the execution of a range of Metal compute commands in the GPU timeline. note: If the indirectCommandBuffer parameter references any pipeline state objects, you are responsible for adding them to a MTLResidencySet instance in use when you commit the command buffer. An indirect compute command references a pipeline state when you pass it as an argument to the command’s setComputePipelineState(_:) method during CPU encoding, or set_compute_pipeline_state() during GPU encoding.

## See Also

### Encoding indirect command buffers

- [executeCommands(buffer:indirectBuffer:)](metal/mtl4computecommandencoder/executecommands(buffer:indirectbuffer:).md)
