Kazan
Vulkan bindings for Rust, generated from the official Vulkan-Headers vk.xml registry.
Why Kazan?
- Supports all Vulkan versions and extensions
- Fully generated wrappers
- Per-extension dispatch tables
Modules
kazan::*-- helper types and traits (ArrayCStr,InstanceExtensionSet,DeviceExtensionSet,EnumerateInto,RawPtr,SliceOrLen, etc.)vk-- all Vulkan types, constants, function pointer types, and Vulkan-specific traits (Handle,ApiVersion,TaggedStructure,Extends, etc.), re-exported flatvk::vk1_0,vk::vk1_1, ... - items grouped by API versionvk::khr,vk::ext,vk::nv, ... - items grouped by vendorvk::khr::swapchain,vk::ext::debug_utils, ... - individual extensionsvk::video::*- video extensions
window-- platform surface creation viaraw-window-handle(requireswindowfeature)ffi-- raw C FFI function types (requiresffifeature)
Function tables
Each API version and extension defines its own EntryFn, InstanceFn, and/or DeviceFn struct containing the commands it introduces.
EntryFn-- global commands, no instance requiredvk::vk1_0::EntryFn--create_instance,enumerate_instance_extension_properties, ...vk::vk1_1::EntryFn--enumerate_instance_version
InstanceFn-- loaded viavk::vk1_0::EntryFnvk::vk1_0::InstanceFn--enumerate_physical_devices,create_device,get_device_proc_addr, ...vk::khr::surface::InstanceFn--get_physical_device_surface_support,destroy_surface, ...vk::ext::debug_utils::InstanceFn--create_debug_utils_messenger, ...
DeviceFn-- loaded viavk::vk1_0::InstanceFnvk::vk1_0::DeviceFn--create_image,cmd_draw,queue_submit, ...vk::khr::swapchain::DeviceFn--create_swapchain,acquire_next_image, ...
Entry bootstraps the loading chain: it holds StaticFn (vkGetInstanceProcAddr), vk1_0::EntryFn, and optionally vk1_1::EntryFn.
Example
use ;
// Load the Vulkan library and entry points.
let entry = unsafe ;
// Create an instance with surface extensions for the current platform.
let display_handle = window.display_handle?.as_raw;
let required = required_extensions?;
let extension_names: = required.names.map.collect;
let app_info = default
.application_name
.api_version;
let create_info = default
.application_info
.enabled_extension_names;
let instance = entry.vk1_0.create_instance?;
// Load instance function tables.
let instance_fn = unsafe ;
// Create a surface via the platform-agnostic window module.
let window_fn = load;
let window_handle = window.window_handle?.as_raw;
let surface = unsafe ;
// Create a device and load device function tables.
let device = unsafe ;
let device_fn = unsafe ;
let swapchain_fn = unsafe ;
Features
| Feature | Description |
|---|---|
loaded |
Runtime loading of the Vulkan library via libloading |
linked |
Link to the system Vulkan library at build time |
std |
Standard library support (read_spv, Error impls) |
debug |
Debug trait implementations for generated types |
window |
Platform surface creation via raw-window-handle |
ffi |
Expose raw C FFI types in vk::ffi |
provisional |
Include provisional/beta extensions |
Running the generator
Parses vk.xml and video.xml from the vendored Vulkan-Headers submodule and writes generated source to crates/kazan/src/generated/.
Acknowledgements
Kazan is heavily based on ash.
License
Licensed under either of
at your option.