Skip to main content

Crate vulkan_rust

Crate vulkan_rust 

Source
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

ModulePurpose
vkRe-export of vulkan-rust-sys,raw #[repr(C)] types, handles, enums
EntryVulkan entry point,loads the library, enumerates layers/extensions
InstanceVulkan instance,physical device queries, instance-level commands
DeviceVulkan logical device,all device-level commands
bytecodeSPIR-V byte alignment helpers
VersionDecoded Vulkan version (major.minor.patch) from a packed u32

§Guide

The companion vulkan_rust Guide covers Vulkan concepts in depth:

TopicGuide chapter
First stepsHello Triangle tutorial
Handles, lifetimes, parent-childThe Vulkan Object Model
Heaps, allocation, mappingMemory Management
Fences, semaphores, barriersSynchronization
Attachments, subpassesRender Passes & Framebuffers
Graphics & compute pipelinesPipelines
Layouts, pools, setsDescriptor Sets & Resource Binding
Recording & submissionCommand Buffers
Extension struct chainsThe pNext Extension Chain
Debug messenger, layersValidation Layers & Debugging
Safety model, two-crate designDesign Decisions
Error types, Result patternError Handling Philosophy
Porting from ashMigration Guide
C API to Rust mappingC-to-Rust Reference

§Feature flags

FlagDefaultDescription
surfaceyesEnables 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§

bytecode
SPIR-V bytecode alignment helper.
vk
Raw Vulkan FFI types generated from vk.xml.

Structs§

Device
Wrapper around a VkDevice handle and its loaded command table.
Entry
Entry point into the Vulkan API.
Instance
Wrapper around a VkInstance handle and its loaded command table.
LibloadingLoader
Default Loader implementation backed by libloading.
Version
Decoded Vulkan API version (major.minor.patch).
VkError
Wrapper around vk::Result that implements std::error::Error.

Enums§

LoadError
Error returned when the Vulkan shared library cannot be loaded.
SurfaceError
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.