|
1 | | -//! This crate provides a fully written in Rust memory allocator for Vulkan and DirectX 12. |
| 1 | +//! This crate provides a fully written in Rust memory allocator for Vulkan, DirectX 12 and Metal. |
2 | 2 | //! |
3 | 3 | //! # [Windows-rs] and [winapi] |
4 | 4 | //! |
|
155 | 155 | //! # #[cfg(not(feature = "d3d12"))] |
156 | 156 | //! # fn main() {} |
157 | 157 | //! ``` |
| 158 | +//! |
| 159 | +//! # Setting up the Metal memory allocator |
| 160 | +//! |
| 161 | +//! ```no_run |
| 162 | +//! # #[cfg(feature = "metal")] |
| 163 | +//! # fn main() { |
| 164 | +//! use gpu_allocator::metal::*; |
| 165 | +//! |
| 166 | +//! # let device = Arc::new(metal::Device::system_default().unwrap()); |
| 167 | +//! let mut allocator = Allocator::new(&AllocatorCreateDesc { |
| 168 | +//! device: device.clone(), |
| 169 | +//! debug_settings: Default::default(), |
| 170 | +//! allocation_sizes: Default::default(), |
| 171 | +//! }); |
| 172 | +//! # } |
| 173 | +//! # #[cfg(not(feature = "metal"))] |
| 174 | +//! # fn main() {} |
| 175 | +//! ``` |
| 176 | +//! |
| 177 | +//! # Simple Metal allocation example |
| 178 | +//! ```no_run |
| 179 | +//! # #[cfg(feature = "metal")] |
| 180 | +//! # fn main() { |
| 181 | +//! use gpu_allocator::metal::*; |
| 182 | +//! use gpu_allocator::MemoryLocation; |
| 183 | +//! # let device = Arc::new(metal::Device::system_default().unwrap()); |
| 184 | +//! # let mut allocator = Allocator::new(&AllocatorCreateDesc { |
| 185 | +//! # device: device.clone(), |
| 186 | +//! # debug_settings: Default::default(), |
| 187 | +//! # allocation_sizes: Default::default(), |
| 188 | +//! # }) |
| 189 | +//! # .unwrap(); |
| 190 | +//! |
| 191 | +//! let allocation_desc = AllocationCreateDesc::buffer( |
| 192 | +//! &device, |
| 193 | +//! "Example allocation", |
| 194 | +//! 512, // size in bytes |
| 195 | +//! gpu_allocator::MemoryLocation::GpuOnly, |
| 196 | +//! ); |
| 197 | +//! let allocation = allocator.allocate(&allocation_desc).unwrap(); |
| 198 | +//! let resource = allocation.make_buffer().unwrap(); |
| 199 | +//! |
| 200 | +//! // Cleanup |
| 201 | +//! drop(resource); |
| 202 | +//! allocator.free(&allocation).unwrap(); |
| 203 | +//! # } |
| 204 | +//! # #[cfg(not(feature = "metal"))] |
| 205 | +//! # fn main() {} |
| 206 | +//! ``` |
158 | 207 |
|
159 | 208 | mod result; |
160 | 209 | pub use result::*; |
|
0 commit comments