📒 gpu-allocator
[]
= "0.25.0"
This crate provides a fully written in Rust memory allocator for Vulkan and DirectX 12.
Windows-rs and winapi
gpu-allocator
recently migrated from winapi to windows-rs but still provides convenient helpers to convert to and from winapi types, enabled when compiling with the public-winapi
crate feature.
Setting up the Vulkan memory allocator
use *;
let mut allocator = new;
Simple Vulkan allocation example
use *;
use MemoryLocation;
// Setup vulkan info
let vk_info = builder
.size
.usage;
let buffer = unsafe .unwrap;
let requirements = unsafe ;
let allocation = allocator
.allocate.unwrap;
// Bind memory to the buffer
unsafe ;
// Cleanup
allocator.free.unwrap;
unsafe ;
Setting up the D3D12 memory allocator
use *;
let mut allocator = new;
Simple d3d12 allocation example
use *;
use MemoryLocation;
let buffer_desc = D3D12_RESOURCE_DESC ;
let allocation_desc = from_d3d12_resource_desc;
let allocation = allocator.allocate.unwrap;
let mut resource: = None;
let hr = unsafe ?;
// Cleanup
drop;
allocator.free.unwrap;
Minimum Supported Rust Version
The MSRV for this crate and the vulkan
and d3d12
features is Rust 1.65. Any other features such as the visualizer
(with all the egui
dependencies) may have a higher requirement and are not tested in our CI.
License
Licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Alternative libraries
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.