Multiple command-queues

Does anyone know what the expected behaviour is when you're running multiple command-queues at the same time? Does one take priority, or are they somehow scheduled?


Or is this unspecified and not to be relied on?


If it helps, the context is that I want one queue rendering my scene from a gyro-driven POV. This render-loop may dip below 60fps.

A second queue would run at a strict 60fps, using the latest gyro data to warp the last rendered frame and display the result.

Answered by wcm in 182028022

There's no need to create multiple command queues to support this use case. It's safe to use a single command queue to create command buffers on multiple threads, and as long as you don't attempt to encode commands into a single command buffer from multiple threads. Command buffers will (appear to) be executed in the order they are enqueued, and a buffer is implicitly enqueued when it is committed if you have not previously explicitly enqueued it. If you do use multiple command queues, there is no such ordering guarantee, and the queues will be serviced in an order determined by the driver.

a MTLCommandQueue is a non-transient object so it is strongly adviced to only use one queue per program/app since you can easily reuse it. see more about this here

Accepted Answer

There's no need to create multiple command queues to support this use case. It's safe to use a single command queue to create command buffers on multiple threads, and as long as you don't attempt to encode commands into a single command buffer from multiple threads. Command buffers will (appear to) be executed in the order they are enqueued, and a buffer is implicitly enqueued when it is committed if you have not previously explicitly enqueued it. If you do use multiple command queues, there is no such ordering guarantee, and the queues will be serviced in an order determined by the driver.

Multiple command-queues
 
 
Q