vk_dxgi
vk_dxgi is a small, single-header C++ library that lets a Vulkan application take full control of its DXGI swap chain.
Single-header C++ library that gives Vulkan applications on Windows direct control over DXGI presentation, unlocking frame-latency waitable objects, variable refresh rate, and HDR output without the standard compatibility layer.
This is a small C++ library for Windows application developers who are building graphics programs using Vulkan, a low-level graphics programming interface. The specific problem it solves involves how those programs display their rendered images on screen. Windows has its own system for managing display output called DXGI (DirectX Graphics Infrastructure), and by default Vulkan programs use a compatibility layer to work with it. This library replaces that layer and gives the Vulkan application direct control over the DXGI side of presentation.
The main reason to use direct DXGI control is access to features that the compatibility layer does not expose. These include frame-latency waitable objects (a way to precisely control how many frames ahead the GPU works, which reduces input lag), support for variable refresh rate displays, and control over tearing behavior. Programs that need to interact with other code expecting a standard DXGI interface also benefit from this approach.
The library is distributed as a single header file, which means there is no separate build step. Developers add one file to their project and enable the implementation in exactly one source file. The setup involves creating a Vulkan device with specific extension support enabled, then calling the library's functions to create a swap chain (the structure that manages the frames being shown on screen), acquire each frame's image for rendering, and present the finished frame to the display.
The library supports two modes. In the default mode, the application renders directly into the DXGI backbuffer images, which avoids an extra copy step. In the alternative blit mode, the application renders into a single shared image and the library copies it into the appropriate backbuffer, which is more compatible with different driver configurations. Synchronization between Vulkan and the D3D12 side is handled through a shared fence object imported as a Vulkan timeline semaphore. Supported color formats include standard 8-bit formats, 16-bit float, and 10-bit HDR.
Where it fits
- Reduce input lag in a Vulkan game on Windows by using DXGI frame-latency waitable objects directly instead of the default compatibility layer.
- Enable variable refresh rate support for a Vulkan renderer on G-Sync or FreeSync displays.
- Integrate a Vulkan swap chain into a larger Windows application that already expects a standard DXGI interface.
- Add 10-bit HDR or 16-bit float output to an existing Vulkan-based graphics engine on Windows.