📒 gpu-allocator
[]
= "0.28.0"
This crate provides a fully written in Rust memory allocator for Vulkan, DirectX 12 and Metal.
Setting up the Vulkan memory allocator
use *;
let mut allocator = new;
Simple Vulkan allocation example
use *;
use MemoryLocation;
// Setup vulkan info
let vk_info = default
.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;
Setting up the Metal memory allocator
use *;
let mut allocator = new;
Simple Metal allocation example
use *;
use MemoryLocation;
let allocation_desc = buffer;
let allocation = allocator.allocate.unwrap;
let heap = unsafe ;
let resource = unsafe
.unwrap;
// Cleanup
drop;
allocator.free.unwrap;
no_std
support
no_std
support can be enabled by compiling with --no-default-features
to disable std
support and --features hashbrown
for Hash
collections that are only defined in std
for internal usages in crate. For example:
[]
= { = "0.28.0", = false, = ["hashbrown", "other features"] }
To support both std
and no_std
builds in your project, use the following in your Cargo.toml
:
[]
= ["std", "other features"]
= ["gpu-allocator/std"]
= ["gpu-allocator/hashbrown"]
= []
[]
= { = "0.28.0", = false }
Minimum Supported Rust Version
The MSRV for this crate and the vulkan
, d3d12
and metal
features is Rust 1.71.
The no_std
support requires Rust 1.81 or higher because no_std
support of dependency thiserror
requires core::error::Error
which is stabilized in 1.81.
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.