vkgen

Generates Rust source code from vk.xml

This crate offers

General information

Usage

Step 1

Download vk.xml from the official Vulkan-Headers repository (https://github.com/KhronosGroup/Vulkan-Headers/blob/master/registry/vk.xml)

Step 2

Generate Rust source code from vk.xml

$ vkgen <input file> <output file>

Step 3

Add libloading to cargo.toml [dependencies] libloading = "0.5.0" This is required to load vkGetInstanceProcAddr from the Vulkan shared library.

Step 4

Load libvulkan in order to use the generated functions rust unsafe { vkLoad("path/to/libvulkan"); } Note: vkLoad() only loads vkGetInstanceProcAddr from the shared library, all other functions are loaded dynamically via vkGetInstanceProcAddr and vkGetDeviceProcAddr to avoid additional dispatch overhead.

Examples

This simple example demonstrates how to load libvulkan on linux and output the instance version (1.1.0). vk.rs is the file containing the generated Rust source code. The location of libvulkan.so/vulkan.dll may vary depending on the OS. ```rust mod vk;

use self::vk::*;

fn main() { unsafe { vkLoad("/usr/lib/x86_64-linux-gnu/libvulkan.so.1.1.92"); }

let mut v: u32 = 0;
vkEnumerateInstanceVersion(&mut v as *mut u32);
println!("vulkan instance version is {}.{}.{}", VK_VERSION_MAJOR(v), VK_VERSION_MINOR(v), VK_VERSION_PATCH(v));

}

```

Known Issues