Vulkan SDK Offers Developers a Smooth Transition Path to Synchronization2

The newly released VK_KHR_synchronization2 extension brings extensive improvements to Vulkan queue submission, events, and pipeline barriers resulting in API significant usability enhancements for developers.

Synchronization2 highlights include:

  • Data for semaphores and command buffers is passed in arrays of structures, rather than in separate arrays spread across multiple structures, to streamline queue submissions.
  • Barrier pipeline stage masks are now stored in the barrier structure rather than passed as separate parameters to vkCmdPipelineBarrier() to simplify resource state tracking.
  • VkPipelineStageFlags2KHR and VkAccessFlags2KHR are expanded to 64-bits to allow for future extensibility with new extensions.
  • vkCmdSetEvent2KHR() requires pipeline barriers, enhancing driver efficiency by scheduling work at event ‘set’ time, rather than the ‘wait’ for barrier information to become available.
  • New image layout types now ‘do the right thing’ for both color and depth/stencil images. Also, image layout transitions do not happen if a barrier’s oldLayout and newLayout field are equal, even if the layout provided doesn’t match the current layout of the image.

More details on this significant extension have been added to the Vulkan Guide.

The new Vulkan SDK version 1.2.170 adds immediate support for Synchronization2, and here we highlight how developers can leverage the SDK to immediately use this new functionality, even before the extension ships in their Vulkan drivers.

Upgrading to Synchronization2

The Synchronization2 extension has been designed to be largely backward compatible with the previous Synchronization extension, enabling new Synchronization2 functions to be adopted incrementally into an existing application. For example, Synchronization2 queue submissions can be used with the original pipeline barriers or vice versa.

The one exception is that setting events and matching waiting for events must use calls from the same version of the extension, i.e., SetEvent must be used with WaitEvents, and SetEvent2 must be used with WaitEvents2.

There are code examples in the Vulkan Guide that show how to convert code to use the new VK_KHR_synchronization2 extension, together with Synchronization2 example code in the Vulkan Wiki and new Synchronization2 samples in the Vulkan-Samples repository.

The Synchronization2 SDK Layer

In order to promote rapid adoption of the new Synchronization2 extension and provide a smooth transition for developers, a new software layer is now available with the Vulkan SDK which efficiently implements Synchronization2 over the original synchronization APIs. This enables applications to use the new extension even if target devices do not have Synchronization2 support in their native drivers.

This new layer, called VK_LAYER_KHRONOS_synchronization2, is designed to be a transparent helper by intercepting calls to vkGetPhysicalDeviceFeatures2() and reporting support for the extension if the underlying device says it doesn’t support it. Then if vkCreateDevice() is called with Synchronization2 enabled and the device doesn’t implement it, the layer will intercept the new Synchronization2 functions, translating new extension calls into equivalent calls to original functions. The layer also intercepts many of the original synchronization functions to translate VK_PIPELINE_STAGE_NONE_KHR and the new image layouts (VK_IMAGE_LAYOUT_ATTACHMENT_OPTIMAL_KH and VK_IMAGE_LAYOUT_READ_ONLY_OPTIMAL_KHR) into values that an older driver implementation would support.

Getting Started with Synchronization2 in the Vulkan SDK

The Vulkan SDK includes functionality to help you get started with this new extension. First of all, the Vulkan Configurator (vkconfig) has a new “Synchronization” configuration, which enables Synchronization Validation, and VK_LAYER_KHRONOS_synchronization2.

Enabling the Synchronization2 layer in the Vulkan Configurator

To always use the layer’s Synchronization2 implementation, the “Force Enable” setting causes it to be active even when the underlying device also implements the extension. For more information, please see the Synchronization2 documentation for this layer in the SDK and the source code in the Vulkan-ExtensionLayer repo.

Improved Synchronization Validation

Synchronization Validation was first released in 2020 and has been substantially evolved to fully support Synchronization2. Even when the Synchronization2 extension isn’t in use, Validation now uses the new pipeline stages and access masks, as well as tracking pipeline stages on a per barrier basis, enabling improved error messages. For example, because Synchronization2 has separate pipeline stages for the different types of transfer operations, Synchronization Validation can report a hazard from a vkCmdCopyBuffer() call with SYNC_COPY_TRANSFER_READ in the access info, rather than SYNC_TRANSFER_TRANSFER_READ.

Core Validation also adds support for Synchronization2 and also takes advantage of the extension’s backward compatibility.

Where to Get Help

Synchronization2 brings big changes to Vulkan to improve developer productivity and application performance. Updates to the Vulkan SDK and vkconfig will improve API usability for developers. The extensive improvements to queue submission, events, and pipeline barriers will allow for more efficient driver implementations and provide for future extensibility. The implementation available in the new Synchronization2 layer enables developers to immediately start development using this significant new extension.

If you have questions or find problems with the SDK, you should report issues on To offer suggestions for future releases, provide comments, or report issues about the Synchronization2 layer or Synchronization Validation, please contact the development team via the GitHub repositories using the links shown below:

Authored by