# `🌋 vk-mem-alloc-rs`
**A very lightweight wrapper around the Vulkan Memory Allocator 🦀**
[![crates][crates-badge]][crates-url]
[![license][license-badge]][license-url]
[![vma][vma-badge]][vma-url]
[![dependency-status][dependency-badge]][dependency-url]
[crates-badge]: https://img.shields.io/crates/v/vk-mem-alloc.svg
[crates-url]: https://crates.io/crates/vk-mem-alloc
[license-badge]: https://img.shields.io/badge/License-MIT/Apache_2.0-blue.svg
[license-url]: LICENSE-MIT
[vma-badge]: https://img.shields.io/badge/Vulkan%20Memory%20Allocator-3.0.1-orange
[vma-url]: https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator
[dependency-badge]: https://deps.rs/repo/github/projectkml/vk-mem-alloc-rs/status.svg
[dependency-url]: https://deps.rs/repo/github/projectkml/vk-mem-alloc-rs
TOML
[dependencies]
vk-mem-alloc = "0.2.0"
Simple Vulkan Memory Allocator example
```Rust
// Create the allocator
let allocator = vkmemalloc::createallocator(&instance, physicaldevice, &device, None).unwrap();
let buffercreateinfo = vk::BufferCreateInfo {
size,
usage: vk::BufferUsageFlags::STORAGE_BUFFER,
..Default::default()
};
let allocationcreateinfo = vkmemalloc::AllocationCreateInfo {
usage: vkmemalloc::MemoryUsage::AUTOPREFERDEVICE,
..Default::default()
};
// Create the buffer
let (buffer, allocation, allocationinfo) = vkmemalloc::createbuffer(allocator, &buffercreateinfo, &allocationcreateinfo).unwrap();
....
// Destroy the buffer
vkmemalloc::destroy_buffer(allocator, buffer, allocation);
// Destroy the allocator
vkmemalloc::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.