Reusing command buffers
Command buffers can be recorded once and submitted multiple times. They can also be used once and reset before the next use or just recorded, submitted, and discarded.
In this recipe, you will learn how to reuse a command buffer without creating a race condition between your application and the GPU.
Getting ready
The code provided in VulkanCore::CommandQueueManager
doesn’t synchronize command buffers but provides functions to help you do so, such as goToNextCmdBuffer
, waitUntilSubmitIsComplete
, and waitUntilAllSubmitsAreComplete
.
How to do it…
Using command buffers can be accomplished in two ways:
- Create a command buffer and reuse it indefinitely. In this case, once the command buffer is submitted, you must wait for it to be processed before starting to record new commands. One way to guarantee that the buffer has finished being processed is by checking the status of the fences associated with it. If the fence is to be reused...