Understanding synchronization in the swapchain – fences and semaphores
The application and the GPU processes run in parallel; unless specified otherwise, the command buffers and their commands also run in parallel on the GPU. To enforce an order between the CPU and the GPU, and between command buffers being processed in the GPU, Vulkan provides two mechanisms: fences and semaphores. Fences are used to synchronize work between the GPU and the CPU, while semaphores are used to synchronize workloads executed in the GPU.
In this recipe, you will learn about fences and semaphores: why they are necessary, how they are used (and when), and how to use semaphores with a swapchain.
Getting ready
Examples of semaphores can be found in the VulkanCore::Swapchain
class, while examples of fences can be found in the VulkanCore::CommandQueueManager
class.
How to do it…
Fences and semaphores have different uses. Let’s explore each one of those elements and how to...