Chapter 6. Synchronization and Cache Control

Synchronization of access to resources is primarily the responsibility of the application. In Vulkan, there are four forms of concurrency during execution: between the host and device, between the queues, between queue submissions, and between commands within a command buffer. Vulkan provides the application with a set of synchronization primitives for these purposes. Further, memory caches and other optimizations mean that the normal flow of command execution does not guarantee that all memory transactions from a command are immediately visible to other agents with views into a given range of memory. Vulkan also provides barrier operations to ensure this type of synchronization.

Four synchronization primitive types are exposed by Vulkan. These are:

Each is covered in detail in its own subsection of this chapter. Fences are used to communicate completion of execution of command buffer submissions to queues back to the application. Fences can therefore be used as a coarse-grained synchronization mechanism. Semaphores are generally associated with resources or groups of resources and can be used to marshal ownership of shared data. Their status is not visible to the host. Events provide a finer-grained synchronization primitive which can be signaled at command level granularity by both device and host, and can be waited upon by either. Barriers provide execution and memory synchronization between sets of commands.