VkLayer_vsync: A Vulkan Layer for Overwriting the Vulkan VSync Mode
When programming applications using graphics APIs like OpenGL, Vulkan1 or Direct3D, one has to think about how rendered framebuffers are displayed on the monitor. Vertical synchronization (VSync) is a mode where copying to the display area of the monitor is synchronized with the vertical blanking interval, thus avoiding artifacts like screen tearing.
Due to this, VSync is often turned on by default for many applications. I was recently involved in implementing an option in Blender for turning off VSync for being able to reliably measure viewport rendering performance above the display refresh rate.
However, applications utilizing graphics APIs which are not games often do not implement (or publicly advertise) options for turning off VSync. While driver options were available to end users widely for overwriting VSync behavior for OpenGL and Direct3D 11, the situation is not as clear for Vulkan. I implemented a Vulkan layer for overwriting the VSync choices of Vulkan apps at https://github.com/chrismile/VkLayerVsync.
The Vulkan documentation describes the concept of layers as follows.
"Vulkan supports intercepting or hooking API entry points via a layer framework. A layer can intercept all or any subset of Vulkan API entry points. Multiple layers can be chained together to cascade their functionality in the appearance of a single, larger layer."
– https://github.com/KhronosGroup/Vulkan-Utility-Libraries/blob/main/docs/layer_configuration.md
VkLayer_vsync intercepts vkCreateSwapchainKHR and overwrites the VkPresentModeKHR state depending on configuration options specified by the user. An example for how the layer can be used to force-disable the usage of VSync can be found below.
1export VK_ADD_LAYER_PATH=<Path to VkLayer_vsync>
2export VK_LOADER_LAYERS_ENABLE=*vsync
3export VK_VSYNC=off
An overview and prebuilt binaries for Windows and Linux can be found at the project page.
-
Vulkan and the Vulkan logo are registered trademarks of the Khronos Group Inc. ↩︎