Expand description
§vulkanic - Vulkan API adapter
Ultra-thin wrapper sitting on top of vk-sys.
§Examples
GLFW:
let ep: EntryPoints = vk::EntryPoints::load(|procname| {
glfw_window.get_instance_proc_address(0, procname.to_str().unwrap())
}).into();
// let instance_info = ...
let instance = unsafe { ep.create_instance(&instance_info) }?;
let ip: InstancePointers = vk::InstancePointers::load(|procname| {
glfw_window.get_instance_proc_address(instance, procname.to_str().unwrap())
}).into();
let dp: DevicePointers = vk::DevicePointers::load(|procname| {
glfw_window.get_instance_proc_address(instance, procname.to_str().unwrap())
}).into();
for physical_device in ip.enumerate_physical_devices(instance)? {
// ...
}
// ...
// use pointers directly, if wrapper implementation is missing
// unsafe { dp.InvalidateMappedMemoryRanges(..) }
§Crate conventions
- same partitioning like
vk-syswithEntryPoints,InstancePointersandDevicePointers - Rust naming conventions are met
- function names e.g.
CreateDevicerenamed tocreate_device - parameter names e.g.
physicalDevicerenamed tophysical_device - C type prefixes are omitted e.g.
pCreateInfotocreate_info
- function names e.g.
- type mapping
vk::Bool32tobool- pointers
pCreateInfo: *const DeviceCreateInfoto borrowscreate_info: &DeviceCreateInfo - API calls having array parameters e.g.
fenceCount: u32, pFences: *const Fencewill be presented as Rust slices e.g.fences: &[vk::Fence].
- return values
std::result::Result<T, vk::Result>if API call has a resultTif API call has no result- API calls with a result, will return
Ok(..)only forvk::SUCCESS
§Missing parts
- many Vulkan API calls are still not yet implemented
- API calls like
vkAcquireNextImageKHRcan return non-error results which are currently handled as error. It’s not clear (even from the specs) if out-parameter are valid in this case.
§Safety
- many Vulkan API calls are safe Rust regarding they may fail, but will not have undefined behaviour
- all Vulkan API calls with structs containing pointers like
pNext: *const c_voidhave to be considered unsafe, because caller has to make sure they are valid. - using
Vecor slices as ffi pointers is safe, because all vk-sys structs are#[repr(C)], which ensures correct alignment without padding.
Structs§
- Device
Pointers - Wrapper for
vk::DevicePointers. - Entry
Points - Wrapper for
vk::EntryPoints. - Instance
Pointers - Wrapper for
vk::InstancePointers.
Type Aliases§
- Result
- Result type for most Vulkan API calls, if they support them.
Currently non-error return values are handled as
Err(..)(also see Missing parts on top).