Top Related Projects
Safe and rich Rust wrapper around the Vulkan API
Vulkan bindings for Rust
C++ examples for the Vulkan graphics API
Awesome Vulkan ecosystem
Quick Overview
Vulkan-Hpp is a C++ wrapper for the Vulkan graphics and compute API. It provides a modern C++ interface to Vulkan, offering type safety, error handling, and improved usability while maintaining full compatibility with the C API.
Pros
- Improved type safety and compile-time checks
- Automatic resource management through RAII principles
- Reduced boilerplate code compared to the C API
- Better integration with modern C++ features and standard library
Cons
- Slight performance overhead due to abstraction layer
- Learning curve for developers familiar with the C API
- May not cover all edge cases or advanced features of Vulkan
- Potential for version mismatches between Vulkan-Hpp and Vulkan SDK
Code Examples
- Creating a Vulkan instance:
#include <vulkan/vulkan.hpp>
vk::Instance createInstance() {
vk::ApplicationInfo appInfo("MyApp", VK_MAKE_VERSION(1, 0, 0));
vk::InstanceCreateInfo createInfo({}, &appInfo);
return vk::createInstance(createInfo);
}
- Creating a device and queue:
vk::Device createDevice(vk::PhysicalDevice physicalDevice) {
auto queueFamilyProperties = physicalDevice.getQueueFamilyProperties();
uint32_t queueFamilyIndex = 0;
for (const auto& prop : queueFamilyProperties) {
if (prop.queueFlags & vk::QueueFlagBits::eGraphics) break;
++queueFamilyIndex;
}
float queuePriority = 1.0f;
vk::DeviceQueueCreateInfo queueCreateInfo({}, queueFamilyIndex, 1, &queuePriority);
vk::DeviceCreateInfo deviceCreateInfo({}, 1, &queueCreateInfo);
return physicalDevice.createDevice(deviceCreateInfo);
}
- Creating and using a command buffer:
void recordAndSubmitCommands(vk::Device device, vk::Queue queue) {
vk::CommandPoolCreateInfo poolInfo({}, queue.getFamilyIndex());
vk::CommandPool commandPool = device.createCommandPool(poolInfo);
vk::CommandBufferAllocateInfo allocInfo(commandPool, vk::CommandBufferLevel::ePrimary, 1);
auto commandBuffers = device.allocateCommandBuffers(allocInfo);
vk::CommandBuffer commandBuffer = commandBuffers[0];
vk::CommandBufferBeginInfo beginInfo(vk::CommandBufferUsageFlagBits::eOneTimeSubmit);
commandBuffer.begin(beginInfo);
// Record commands here
commandBuffer.end();
vk::SubmitInfo submitInfo({}, {}, commandBuffer, {});
queue.submit(submitInfo, nullptr);
queue.waitIdle();
}
Getting Started
To use Vulkan-Hpp in your project:
- Install the Vulkan SDK from the official LunarG website.
- Include the Vulkan-Hpp header in your project:
#include <vulkan/vulkan.hpp> - Link against the Vulkan library in your build system.
- Start using Vulkan-Hpp classes and functions in your code, as shown in the examples above.
Note: Ensure that your compiler supports C++11 or later, as Vulkan-Hpp relies on modern C++ features.
Competitor Comparisons
Safe and rich Rust wrapper around the Vulkan API
Pros of Vulkano
- Written in Rust, providing memory safety and zero-cost abstractions
- Higher-level abstractions that simplify Vulkan development
- Built-in synchronization primitives and automatic resource management
Cons of Vulkano
- May have performance overhead due to higher-level abstractions
- Less direct control over Vulkan API compared to Vulkan-Hpp
- Smaller community and ecosystem compared to C++ Vulkan libraries
Code Comparison
Vulkano:
let device = Device::new(physical, &Features::none(), &DeviceExtensions::none(), None)?;
let queue = queues.next().unwrap();
let command_buffer = AutoCommandBufferBuilder::primary(device.clone(), queue.family(), CommandBufferUsage::OneTimeSubmit)?;
Vulkan-Hpp:
vk::DeviceCreateInfo createInfo({}, queueCreateInfos, {}, deviceExtensions);
vk::Device device = physicalDevice.createDevice(createInfo);
vk::Queue queue = device.getQueue(queueFamilyIndex, 0);
vk::CommandBufferAllocateInfo allocInfo(commandPool, vk::CommandBufferLevel::ePrimary, 1);
vk::CommandBuffer commandBuffer = device.allocateCommandBuffers(allocInfo)[0];
Vulkan bindings for Rust
Pros of ash
- Written in Rust, providing memory safety and zero-cost abstractions
- Lightweight and close to the metal, offering fine-grained control
- Actively maintained with frequent updates
Cons of ash
- Steeper learning curve for developers new to Rust
- Less abstraction, requiring more boilerplate code
- Smaller community compared to C++ Vulkan libraries
Code comparison
ash:
let instance = ash::Instance::new(&create_info, None)?;
let device = instance.create_device(physical_device, &device_create_info, None)?;
Vulkan-Hpp:
vk::Instance instance = vk::createInstance(createInfo);
vk::Device device = physicalDevice.createDevice(deviceCreateInfo);
Summary
ash is a Rust-based Vulkan wrapper that offers memory safety and performance benefits, but may require more effort to use compared to Vulkan-Hpp. Vulkan-Hpp provides a more familiar C++ interface with higher-level abstractions, potentially making it easier for developers transitioning from other C++ graphics APIs. The choice between the two depends on the project's language preferences, performance requirements, and developer expertise.
C++ examples for the Vulkan graphics API
Pros of Vulkan
- Extensive collection of Vulkan examples covering various techniques and features
- Well-documented code with detailed explanations for each example
- Includes additional utilities and helper functions for common Vulkan tasks
Cons of Vulkan
- Primarily focused on C++ examples, may not be ideal for developers using other languages
- Larger repository size due to the inclusion of assets and multiple examples
Code Comparison
Vulkan (C++ with raw Vulkan API):
VkCommandBufferBeginInfo cmdBufInfo = {};
cmdBufInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
vkBeginCommandBuffer(commandBuffer, &cmdBufInfo);
Vulkan-Hpp (C++ with Vulkan-Hpp wrapper):
vk::CommandBufferBeginInfo cmdBufInfo;
commandBuffer.begin(cmdBufInfo);
Summary
Vulkan provides a comprehensive set of examples and utilities for learning and working with the Vulkan API, while Vulkan-Hpp offers a more modern C++ wrapper for the API. Vulkan is better suited for those wanting to understand the raw Vulkan implementation, while Vulkan-Hpp simplifies usage for C++ developers. The choice between them depends on the developer's preferences and project requirements.
Awesome Vulkan ecosystem
Pros of awesome-vulkan
- Comprehensive collection of Vulkan resources, including tutorials, tools, and libraries
- Regularly updated with community contributions
- Covers a wide range of Vulkan-related topics and applications
Cons of awesome-vulkan
- Not a direct implementation or wrapper for Vulkan
- May contain outdated or deprecated resources if not actively maintained
- Requires additional effort to integrate resources into projects
Code comparison
While a direct code comparison is not relevant due to the nature of these repositories, here's an example of how they might be used:
awesome-vulkan:
## Vulkan Tutorials
- [Vulkan Tutorial](https://vulkan-tutorial.com/)
- [Intel Vulkan Tutorials](https://github.com/GameTechDev/IntroductionToVulkan)
Vulkan-Hpp:
#include <vulkan/vulkan.hpp>
vk::Instance instance = vk::createInstance(vk::InstanceCreateInfo());
vk::PhysicalDevice physicalDevice = instance.enumeratePhysicalDevices().front();
awesome-vulkan serves as a curated list of Vulkan resources, while Vulkan-Hpp provides a C++ wrapper for the Vulkan API, offering different functionalities for developers working with Vulkan.
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Vulkan-Hpp: C++ bindings for Vulkan
Overview
Vulkan-Hpp provides header-only C++ bindings for the Vulkan C API to improve the developer experience with Vulkan without introducing run-time CPU costs. It adds features like type safety for enumerations and bit-fields, STL container support, exception support, and several varieties of RAII-capable types.
This repository contains the generators for Vulkan-Hpp, which accept the XML specification of Vulkan and emit C++ bindings, which are documented further below.
CI/CD status
We test a wide range of compilers across Windows, Linux and MacOS (via MoltenVK). Below is a matrix representing all of the runner permutations used for automated testing. For more details, check out the workflow that governs these runners.
| GCC | Clang | MSVC | |
|---|---|---|---|
| Windows 2022 Windows 2025 | - - | 17 17 | VS 17 2022 VS 17 2022 |
| Ubuntu 22.04 Ubuntu 24.04 | 10, 11 12, 13, 14 | 13, 14, 15 16, 17, 18 | - - |
| MacOS 14 MacOS 15 MacOS 26 | - - - | 15 17 17 | - - - |
Documentation
All other documentation is in docs:
- Building describes how to configure, build, and generate new headers.
- Usage explains how to use the various features of Vulkan-Hpp with detailed examples.
- Configuration lists all the options available to configure the behaviour and features of Vulkan-Hpp.
- Handles is an overview of the three different families of handles provided by Vulkan-Hpp. These allow semantics similar to
std::unique_ptr,std::shared_ptr, and alsovk::raiitypes, which are RAII (resource acquisition is initialisation) handles that offer object-oriented semantics for Vulkan handles.
[!NOTE]
All macro configuration options available in the C API are also available and used in Vulkan-Hpp.
Installation and usage
Vulkan SDK
Vulkan-Hpp has been part of the LunarG Vulkan SDK since version 1.0.24; this remains the recommended installation method. If you need a more recent version than the SDK supports, then Vulkan-Hpp is also distributed as part of the Khronos Group Vulkan-Headers repository.
vcpkg
As above, Vulkan-Hpp is provided in the vulkan-headers port in vcpkg.
Otherwise, you can also install the vulkan-sdk-components port, which is a vcpkg equivalent to the LunarG-distributed Vulkan SDK.
git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
./bootstrap-vcpkg.sh
./vcpkg integrate install
./vcpkg install vulkan-headers
For support, create an issue or pull request on the vcpkg repository.
Conan
Similar to vcpkg, Vulkan-Hpp can be installed as part of the vulkan-headers recipe.
The vcpkg and Conan packages are kept up to date by Microsoft and members of the community. Requests for updates and issues with these packages should be directed to their respective repositories rather than here.
Breaking Changes
We try to keep the API for all flavours of Vulkan-Hpp constant or backwards compatible. However, we may introduce unavoidable breaking changes, usually to fix bugs. Following is a list of those changes, arranged by version.
v1.4.351
In order to improve argument safety, the interface of functions taking a C-array of values has changed to take a std::array, instead.
The affected functions are:
vk::CommandBuffer::setFragmentShadingRateKHRvk::raii::CommandBuffer::setBlendConstantsvk::raii::CommandBuffer::setFragmentShadingRateKHRvk::raii::CommandBuffer::setFragmentShadingRateEnumNV
v1.4.334
The vulkan_hpp C++ named module has been renamed to vulkan.
v1.4.324
With PR #2226, the return type of vk::raii::Device::acquireNextImage2KHR and vk::raii::SwapchainKHR::acquireNextImage has changed from std::pair<vk::Result,uint32_t> to the equivalent vk::ResultValue<uint32_t>
v1.4.329
With PR #2303, import std was made mandatory when using the C++ named module.
Contributing
Feel free to submit a PR to add to this list. You should use clang-format version 22.1.1 to format the generated files.
- Examples A port of Sascha Willems examples to Vulkan-Hpp
- Vookoo Stateful helper classes for Vulkan-Hpp, Introduction Article.
License
Copyright 2015-2026 The Khronos Group Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Top Related Projects
Safe and rich Rust wrapper around the Vulkan API
Vulkan bindings for Rust
C++ examples for the Vulkan graphics API
Awesome Vulkan ecosystem
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot