vkgen 0.1.0

Generates Rust source code from vk.xml
vkgen-0.1.0 is not a library.
Visit the last successful build: vkgen-2.2.1

vkgen

Generates Rust source code from vk.xml

Usage

$ vkgen <input file> <output file>

  • input file should be the Vulkan registry (vk.xml)
  • output file will be created if it does not exist

To use the generated file one has to add libloading to cargo.toml:

[dependencies]
libloading = "0.5.0"

This is required to load vkGetInstanceProcAddr from a shared library. All other functions are loaded dynamically via vkGetInstanceProcAddr and vkGetDeviceProcAddr to avoid additional overhead.

Examples

This example demonstrates how to load libvulkan on linux and output the instance version (1.1.0), where vk.rs is a file containing the generated rust source code.

mod vk;

fn main() {
	unsafe {
		vk::load("/usr/lib/x86_64-linux-gnu/libvulkan.so.1.1.92");
		let mut v: u32 = 0;
		vk::vkEnumerateInstanceVersion(&mut i as *mut u32);
		println!("instance version is {}", v);
	}
}

Known Issues

  • type aliases are generated for uint32_t, uint64_t, ...
  • macros are not generated
  • some type aliases are not generated
  • constant 'VK_QUEUE_FAMILY_EXTERNAL_KHR' has wrong type
  • enum aliases are not generated properly