---
title: Indirect command encoding
framework: metal
role: collectionGroup
role_heading: API Collection
path: metal/indirect-command-encoding
---

# Indirect command encoding

Store draw commands in Metal buffers and run them at a later time on the GPU, either once or repeatedly.

## Overview

Overview You can use an MTLIndirectCommandBuffer instance to store draw commands and invoke them at a later time. Metal executes all the draw commands in an indirect command buffer each time you submit it. This means you can use indirect command buffers multiple times, unlike MTLCommandBuffer instances, which are all single-use. You can encode an indirect command buffer to run on either the CPU or the GPU. However, the GPU gives you the ability to immediately use the output of one pass as the input of a subsequent pass. For example, you can create an indirect command buffer with commands that conditionally draw visible items by running: A compute kernel that identifies visible geometry and saves it to a result buffer An indirect command buffer that uses the result buffer as its input to make decisions on what to draw

## Topics

### Indirect command buffers

- [Creating an indirect command buffer](metal/creating-an-indirect-command-buffer.md)
- [Specifying drawing and dispatch arguments indirectly](metal/specifying-drawing-and-dispatch-arguments-indirectly.md)
- [Encoding indirect command buffers on the CPU](metal/encoding-indirect-command-buffers-on-the-cpu.md)
- [Encoding indirect command buffers on the GPU](metal/encoding-indirect-command-buffers-on-the-gpu.md)
- [MTLIndirectCommandBuffer](metal/mtlindirectcommandbuffer.md)
- [MTLIndirectCommandBufferDescriptor](metal/mtlindirectcommandbufferdescriptor.md)
- [MTLIndirectCommandType](metal/mtlindirectcommandtype.md)
- [MTLIndirectCommandBufferExecutionRange](metal/mtlindirectcommandbufferexecutionrange.md)
- [MTLIndirectCommandBufferExecutionRangeMake(_:_:)](metal/mtlindirectcommandbufferexecutionrangemake(_:_:).md)

### Indirect compute commands

- [MTLIndirectComputeCommand](metal/mtlindirectcomputecommand.md)
- [MTLRegion](metal/mtlregion.md)
- [MTLSize](metal/mtlsize.md)
- [MTLOrigin](metal/mtlorigin.md)
- [MTLStageInRegionIndirectArguments](metal/mtlstageinregionindirectarguments.md)
- [MTLDispatchThreadgroupsIndirectArguments](metal/mtldispatchthreadgroupsindirectarguments.md)

### Render compute commands

- [MTLIndirectRenderCommand](metal/mtlindirectrendercommand.md)
- [MTLDrawPatchIndirectArguments](metal/mtldrawpatchindirectarguments.md)
- [MTLDrawPrimitivesIndirectArguments](metal/mtldrawprimitivesindirectarguments.md)
- [MTLDrawIndexedPrimitivesIndirectArguments](metal/mtldrawindexedprimitivesindirectarguments.md)

## See Also

### Command encoders

- [Render passes](metal/render-passes.md)
- [Compute passes](metal/compute-passes.md)
- [Machine learning passes](metal/machine-learning-passes.md)
- [Blit passes](metal/blit-passes.md)
- [Ray tracing with acceleration structures](metal/ray-tracing-with-acceleration-structures.md)
