You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 gpu_allocator::vulkan::*;letmut allocator = Allocator::new(&AllocatorCreateDesc{
instance,
device,
physical_device,debug_settings:Default::default(),buffer_device_address:true,// Ideally, check the BufferDeviceAddressFeatures struct.allocation_sizes:Default::default(),});
Simple Vulkan allocation example
use gpu_allocator::vulkan::*;use gpu_allocator::MemoryLocation;// Setup vulkan infolet vk_info = vk::BufferCreateInfo::default().size(512).usage(vk::BufferUsageFlags::STORAGE_BUFFER);let buffer = unsafe{ device.create_buffer(&vk_info,None)}.unwrap();let requirements = unsafe{ device.get_buffer_memory_requirements(buffer)};let allocation = allocator
.allocate(&AllocationCreateDesc{name:"Example allocation",
requirements,location:MemoryLocation::CpuToGpu,linear:true,// Buffers are always linearallocation_scheme:AllocationScheme::GpuAllocatorManaged,}).unwrap();// Bind memory to the bufferunsafe{ device.bind_buffer_memory(buffer, allocation.memory(), allocation.offset()).unwrap()};// Cleanup
allocator.free(allocation).unwrap();unsafe{ device.destroy_buffer(buffer,None)};
Setting up the D3D12 memory allocator
use gpu_allocator::d3d12::*;letmut allocator = Allocator::new(&AllocatorCreateDesc{device:ID3D12DeviceVersion::Device(device),debug_settings:Default::default(),allocation_sizes:Default::default(),});
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:
[dependencies]
gpu-allocator = { version = "0.27.0", default-features = false, features = ["hashbrown", "other features"] }
gpu-allocator = { version = "0.27", default-features = false, features = ["hashbrown", "other features"] }
To support both std and no_std builds in project, you can use the following in your Cargo.toml:
The MSRV for this crate and the vulkan, d3d12 and metal features is Rust 1.71.
The no_std support requires version aboveRust 1.81beacuaseor higher because no_std support of dependency thiserror requires core::error::Error which is stabalizedstabilized 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.
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.
gpu-allocator = { version = "0.27", default-features = false}
45
+
gpu-allocator = { version = "0.27.0", default-features = false}
46
46
```
47
47
48
48
## Minimum Supported Rust Version
49
49
50
50
The MSRV for this crate and the `vulkan`, `d3d12` and `metal` features is Rust **1.71**.
51
51
52
-
The `no_std` support requires version above **1.81** beacuase `no_std` support of dependency `thiserror` requires `core::error::Error` which is stabalized in **1.81**.
52
+
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**.
53
53
54
54
Any other features such as the `visualizer` (with all the `egui` dependencies) may have a higher requirement and are not tested in our CI.
0 commit comments