A queue that organizes the order in which command buffers are executed by the GPU.
- iOS 8.0+
- macOS 10.11+
- tvOS 9.0+
MTLCommand 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
new method of a
MTLDevice object. The queue returned by
new 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
command. In most cases, you use the
command 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
command 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.