Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Vulkane
Vulkan for Rust: complete bindings generated from the official vk.xml
specification, plus a safe RAII wrapper that covers compute and graphics
end-to-end — from instance creation through shadow mapping and deferred
shading.
What is Vulkane?
Vulkane generates complete Vulkan API bindings from vk.xml, the
official machine-readable specification maintained by Khronos. Every
type, constant, struct, enum, function pointer, and dispatch table is
derived at build time. Nothing is hardcoded.
To target a different Vulkan version, swap vk.xml and rebuild.
Vulkane exposes Vulkan through two complementary APIs:
-
vulkane::raw— direct FFI bindings, exactly as the spec defines them. Maximum control, zero overhead. -
vulkane::safe— RAII wrappers with automatic cleanup,Result-based error handling, typed flags, and convenience helpers. Covers compute and graphics:- Instance / Device —
Instance,PhysicalDevice,PhysicalDeviceGroup,Device,Queue,DeviceFeaturesbuilder (1.0 / 1.1 / 1.2 / 1.3 features). - Memory —
Buffer,Image,ImageView,Sampler,DeviceMemory, plus a VMA-style sub-allocator (Allocator) with TLSF + linear pools, custom pools, dedicated allocations, persistent mapping, defragmentation, and budget queries. - Convenience helpers —
Buffer::new_bound,Image::new_2d_bound,Queue::upload_buffer<T>,Queue::upload_image_rgba,Queue::one_shot— collapse the 5-step allocate-bind pattern into one call. - Compute —
ComputePipeline,PipelineLayout,DescriptorSet,ShaderModule, specialization constants, pipeline cache, push constants. - Graphics —
RenderPass(withsimple_colorshortcut),Framebuffer,GraphicsPipelineBuilder(depth bias,CompareOp,InputRate, multi-attachment blend, dynamic viewport/scissor),Surface(Win32 / Wayland / Xlib / Xcb / Metal),Swapchain. - Synchronization — typed
PipelineStage/AccessFlags(plus 64-bitPipelineStage2/AccessFlags2for Sync2),Fence,Semaphore(binary + timeline),ImageBarrier::color/::depth,ClearValue,QueryPool. - Derive macros —
#[derive(Vertex)]auto-generates vertex input layouts from#[repr(C)]structs (optionalderivefeature). - Raw escape hatch —
Device::dispatch()/Instance::dispatch()expose the full dispatch tables so you can drop to raw Vulkan for anything the safe wrapper doesn't cover yet.
- Instance / Device —
Quick Start
[]
= { = "0.4", = ["fetch-spec"] }
use ;
Bundled Examples
15 examples ship with the crate, from basic compute through advanced
graphics techniques. All are headless (runnable in CI) except
windowed_triangle.
| Example | Technique |
|---|---|
device_info |
Raw API: instance, physical device enumeration, queue families |
fill_buffer |
Safe API: vkCmdFillBuffer round trip |
compute_square |
Compute: SPIR-V, descriptor set, pipeline, dispatch, verify |
compute_image_invert |
Compute: 2D storage image, layout transitions, per-pixel verify |
compile_shader |
Compile GLSL/WGSL → SPIR-V via naga (--features naga) |
headless_triangle |
Graphics: render pass, pipeline, draw, readback |
textured_quad |
Graphics: texture upload, sampler, WGSL fragment shader |
windowed_triangle |
Windowed: winit + surface + swapchain + present loop |
buffer_upload |
Queue::one_shot staging upload pattern |
allocator_compute |
Allocator::create_buffer — 2 lines vs 5 |
raw_interop |
Device::dispatch() + .raw() escape hatch |
depth_prepass |
Depth-only pass + color EQUAL — early-Z prepass |
instanced_mesh |
100 triangles via InputRate::INSTANCE |
shadow_map |
Two-pass shadow mapping: depth bias, comparison sampler, uniform buffers |
deferred_shading |
G-buffer (3 MRT) + fullscreen Phong lighting pass |
derive_vertex |
#[derive(Vertex)] auto-generated vertex layouts (--features derive) |
#[derive(Vertex)]
Enable the derive feature to auto-generate vertex input layouts:
= { = "0.4", = ["fetch-spec", "derive"] }
use Vertex;
// In pipeline setup:
let bindings = ;
let attributes = attributes;
builder.vertex_input
Strides, offsets, and Vulkan format enums are computed at compile time.
Supports f32, [f32; 2..4], u32, [u32; 2..4], i32,
[i32; 2..3], [u8; 4], u16, i16. For per-instance data, use
MyStruct::instance_binding(n) instead of ::binding(n).
Why Vulkane over ash?
| Aspect | Vulkane | ash |
|---|---|---|
| Source of truth | vk.xml at build time |
Hand-curated bindings |
| New Vulkan version | Swap vk.xml, rebuild | Wait for crate update |
| Safe wrapper | Built-in: compute + graphics + allocator + sync | Raw FFI only |
| Sub-allocator | TLSF + linear pools + defrag built in | BYO (gpu-allocator) |
| Vertex layout | #[derive(Vertex)] |
Manual |
| Pipeline builder | Depth bias, CompareOp, multi-attach, dynamic viewport | N/A (raw structs) |
| Allocation helpers | Buffer::new_bound, Queue::upload_buffer<T> |
N/A |
| GLSL/WGSL→SPIR-V | Optional naga feature |
N/A |
| Raw escape hatch | device.dispatch() + .raw() |
N/A (always raw) |
| Maturity | New (0.4) | Battle-tested |
Features
| Feature | Description |
|---|---|
build-support (default) |
XML parsing and code generation during build |
fetch-spec |
Auto-download vk.xml from Khronos GitHub |
naga |
compile_glsl + compile_wgsl → SPIR-V at runtime |
derive |
#[derive(Vertex)] proc macro for vertex layouts |
Providing vk.xml
VK_XML_PATHenv var — point to any localvk.xml- Local copy at
spec/registry/Vulkan-Docs/xml/vk.xml - Auto-download (
--features fetch-spec), optionally pinned withVK_VERSION=1.3.250
Supported Vulkan Versions
1.2.175 through the latest release. The minimum is set by the
VK_MAKE_API_VERSION macros introduced in that version.
Architecture
vk.xml → vulkan_gen (roxmltree parser + codegen) → vulkane crate
├── raw/ (generated FFI bindings)
├── safe/ (RAII wrapper)
└── vulkane_derive (proc macros)
License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE)
- MIT License (LICENSE-MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in vulkane by you, as defined in the Apache-2.0 license, shall be dual-licensed as above, without any additional terms or conditions.