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

# executeCommandsInBuffer:withRange:

Encodes a command that runs a range of commands from an indirect command buffer.

## Declaration

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

## Parameters

- `indirectCommandBuffer`: A doc://com.apple.metal/documentation/Metal/MTLIndirectCommandBuffer instance containing other commands that the current command runs.
- `executionRange`: A span of integers that represent the command entries in the buffer that the current command runs.

## Discussion

Discussion Use this method to encode the execution of a range of Metal render 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 render command references a pipeline state when you pass it as an argument to the command’s setRenderPipelineState(_:) method during CPU encoding, or set_render_pipeline_state() during GPU encoding.

## See Also

### Running commands from indirect command buffers

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