Waiting until all commands submitted to a queue are finished
When we want to synchronize the application with work submitted to a selected queue, we don't always have to use fences. It is possible for the application to wait until all tasks submitted to a selected queue are finished.
How to do it...
- Take the handle of the queue into which tasks were submitted. Store it in a variable of type
VkQueue
namedqueue
. - Call
vkQueueWaitIdle( queue )
and provide thequeue
variable. - We can make sure that no errors occurred by checking if the value returned by the call is equal to a
VK_SUCCESS
.
How it works...
The vkQueueWaitIdle()
function pauses the application until all work (processing of all command buffers) submitted to the given queue is finished. This way, we don't need to create fences.
But such synchronization should be performed only on very rare occasions. Graphics hardware (GPU) is usually much faster than the general processor (CPU), and may require work to be constantly submitted for the application...