Expand description
Ergonomic Vulkan wrapper built on generated FFI bindings.
vulkan-rust provides safe-ish wrappers around the raw Vulkan API exposed by
vulkan-rust-sys. The raw types live in the re-exported vk module; this
crate adds ergonomic methods on Entry, Instance, and Device that
handle output parameters, two-call enumeration, and error checking.
§Quick start
use vulkan_rust::{Entry, LibloadingLoader};
let loader = unsafe { LibloadingLoader::new() }?;
let entry = unsafe { Entry::new(loader) }?;
// entry is now ready to create instances, enumerate layers, etc.§Panics
Wrapper methods on Instance and Device panic if the underlying
Vulkan function pointer was not loaded. This happens when calling a
command from an extension or Vulkan version that was not enabled at
instance or device creation time. The panic message names the missing
command (e.g., "vkCmdDrawMeshTasksEXT not loaded").
Core Vulkan 1.0 commands are always loaded and will not panic.
§Crate structure
| Module | Purpose |
|---|---|
vk | Re-export of vulkan-rust-sys,raw #[repr(C)] types, handles, enums |
Entry | Vulkan entry point,loads the library, enumerates layers/extensions |
Instance | Vulkan instance,physical device queries, instance-level commands |
Device | Vulkan logical device,all device-level commands |
bytecode | SPIR-V byte alignment helpers |
Version | Decoded Vulkan version (major.minor.patch) from a packed u32 |
§Guide
The companion vulkan_rust Guide covers Vulkan concepts in depth:
| Topic | Guide chapter |
|---|---|
| First steps | Hello Triangle tutorial |
| Handles, lifetimes, parent-child | The Vulkan Object Model |
| Heaps, allocation, mapping | Memory Management |
| Fences, semaphores, barriers | Synchronization |
| Attachments, subpasses | Render Passes & Framebuffers |
| Graphics & compute pipelines | Pipelines |
| Layouts, pools, sets | Descriptor Sets & Resource Binding |
| Recording & submission | Command Buffers |
| Extension struct chains | The pNext Extension Chain |
| Debug messenger, layers | Validation Layers & Debugging |
| Safety model, two-crate design | Design Decisions |
| Error types, Result pattern | Error Handling Philosophy |
| Porting from ash | Migration Guide |
| C API to Rust mapping | C-to-Rust Reference |
§Feature flags
| Flag | Default | Description |
|---|---|---|
surface | yes | Enables required_extensions and SurfaceError for window surface creation via raw-window-handle. Disable with default-features = false for headless use. |
Re-exports§
pub use bytecode::BytecodeError;pub use bytecode::cast_to_u32;
Modules§
Structs§
- Device
- Wrapper around a
VkDevicehandle and its loaded command table. - Entry
- Entry point into the Vulkan API.
- Instance
- Wrapper around a
VkInstancehandle and its loaded command table. - Libloading
Loader - Default
Loaderimplementation backed bylibloading. - Version
- Decoded Vulkan API version (major.minor.patch).
- VkError
- Wrapper around
vk::Resultthat implementsstd::error::Error.
Enums§
- Load
Error - Error returned when the Vulkan shared library cannot be loaded.
- Surface
Error - Error returned by surface creation.
Traits§
- Loader
- Abstraction over loading symbols from the Vulkan shared library.
Functions§
- required_
extensions - Instance extensions required for surface creation on this platform.
Type Aliases§
- VkResult
- Vulkan API result type.