Protocol

MTLCommandQueue

A queue that organizes the order in which command buffers are executed by the GPU.

Declaration

@protocol MTLCommandQueue

Overview

The MTLCommandQueue protocol defines the interface for an object that can queue an ordered list of command buffers for a Metal device to execute. In general, command queues are thread-safe and allow multiple outstanding command buffers to be encoded simultaneously.

Your app does not 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 actually perform rendering, 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.

Topics

Creating Command Buffers

commandBuffer

Creates a command buffer.

Required.

commandBufferWithUnretainedReferences

Creates a command buffer that does not hold strong references to any objects (such as buffers, textures, samplers, and state objects) referenced by command encoders that are created from this command buffer.

Required.

Debugging with Xcode

insertDebugCaptureBoundary

Inform Xcode about when GPU Frame Capture starts and stops.

Required.

Deprecated

Identifying Properties

device

The device from which this command queue was created.

Required.

label

A string that identifies this object.

Required.

Relationships

Inherits From

See Also

Command Setup

Setting Up a Command Structure

Discover how Metal executes commands on a GPU.

Devices and Commands

Demonstrates how to access and interact with the GPU.

Labeling Metal Objects and Commands

Assign meaningful labels to your Metal objects and commands so you can easily identify them in the call list of a captured frame.

MTLCommandBuffer

A container that stores encoded commands that are committed to and executed by the GPU.

MTLCommandEncoder

An encoder that writes GPU commands into a command buffer.

Advanced Command Setup

Organize your commands for maximum concurrency and minimal dependencies.