#vulkan #vk #ash #memory #allocator

vk-mem-alloc

A very lightweight wrapper around the Vulkan Memory Allocator

2 releases

Uses new Rust 2021

0.1.1 Aug 12, 2022
0.1.0 Aug 12, 2022

#135 in Graphics APIs

MIT/Apache

265KB
3K SLoC

🌋 vk-mem-alloc-rs

A very lightweight wrapper around the Vulkan Memory Allocator 🦀

crates license vma dependency-status

[dependencies]
vk-mem-alloc = "0.1.1"

Simple Vulkan Memory Allocator example

// Create the allocator
let allocator = vk_mem_alloc::create_allocator(&instance, physical_device, &device).unwrap();

let buffer_create_info = vk::BufferCreateInfo {
    size,
    usage: vk::BufferUsageFlags::STORAGE_BUFFER,
    ..Default::default()
};

let allocation_create_info = vk_mem_alloc::AllocationCreateInfo {
    usage: vk_mem_alloc::MemoryUsage::AUTO_PREFER_DEVICE,
    ..Default::default()
};

// Create the buffer
let (buffer, allocation, allocation_info) = vk_mem_alloc::create_buffer(allocator, &buffer_create_info, &allocation_create_info, None).unwrap();

....

// Destroy the buffer
vk_mem_alloc::destroy_buffer(allocator, buffer, allocation);

// Destroy the allocator
vk_mem_alloc::destroy_allocator(allocator);

Credits

  • AMD for creating the Vulkan Memory Allocator.
  • The Ash community for creating such an awesome rust wrapper around Vulkan.
  • Graham Wihlidal for creating vk-mem, my buildscript is based on its build script.

Dependencies

~4.5MB
~117K SLoC