A queue that organizes command buffers to be executed by a GPU.


@protocol MTLCommandQueue


A MTLCommandQueue object is used to queue an ordered list of command buffers for a MTLDevice to execute. Command queues are thread-safe and allow multiple outstanding command buffers to be encoded simultaneously.

You don't define classes that implement this protocol. To create a command queue, call the newCommandQueue or newCommandQueueWithMaxCommandBufferCount: method of a MTLDevice object. The queue returned by newCommandQueueWithMaxCommandBufferCount: method restricts the number of uncompleted command buffers. Typically, you create one or more command queues when your app is initialized and then keep those queues around throughout the lifetime of your app.

To render images or execute compute operations, use the command queue to create one or more command buffer objects, then encode commands into those objects and commit them to the queue. There are two methods to create MTLCommandBuffer objects: commandBuffer and commandBufferWithUnretainedReferences. In most cases, you use the commandBuffer method, because it creates a command buffer that holds a strong reference to any objects that are needed to finish executing the commands encoded in the command buffer. In very rare situations, you use the commandBufferWithUnretainedReferences method to create a command buffer that does not keep strong references to these objects. In this case, you are responsible for keeping these objects alive until the commands encoded in the command buffer have finished executing.


Creating Command Buffers

- commandBuffer

Creates a command buffer.


- commandBufferWithUnretainedReferences

Creates a command buffer that doesn't hold strong references to any objects required to execute the command buffer.


Identifying the Command Queue


The device from which the command queue was created.



A string that identifies the command queue.



- insertDebugCaptureBoundary

Informs Xcode about when GPU Frame Capture starts and stops.




Inherits From

See Also

Command Setup

Setting Up a Command Structure

Discover how Metal executes commands on a GPU.


A container that stores encoded commands for the GPU to execute.


An encoder that writes GPU commands into a command buffer.

Counter Sampling

Retrieve information about how the GPU executed your commands.