diff --git a/ash/src/lib.rs b/ash/src/lib.rs index ec49aee..e75c9b3 100644 --- a/ash/src/lib.rs +++ b/ash/src/lib.rs @@ -74,6 +74,30 @@ //! //! unsafe { allocator.dealloc(AshMemoryDevice::wrap(&device), block) } //! +//! // the `ash::Device` also implements `AsRef<AshMemoryDevice>` +//! // you can pass a reference of `ash::Device` directly as argument +//! let mut block = unsafe { +//! allocator.alloc( +//! &device, +//! Request { +//! size: 10, +//! align_mask: 1, +//! usage: UsageFlags::HOST_ACCESS, +//! memory_types: !0, +//! }, +//! ) +//! }?; +//! +//! unsafe { +//! block.write_bytes( +//! &device, +//! 0, +//! &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], +//! ) +//! }?; +//! +//! unsafe { allocator.dealloc(&device, block) } +//! //! Ok(()) //! } //! ``` diff --git a/erupt/src/lib.rs b/erupt/src/lib.rs index a1b7c4b..427d30d 100644 --- a/erupt/src/lib.rs +++ b/erupt/src/lib.rs @@ -78,6 +78,30 @@ //! //! unsafe { allocator.dealloc(EruptMemoryDevice::wrap(&device), block) } //! +//! // the `erupt::DeviceLoader` also implements `AsRef<EruptMemoryDevice>` +//! // you can pass a reference of `erupt::DeviceLoader` directly as argument +//! let mut block = unsafe { +//! allocator.alloc( +//! &device, +//! Request { +//! size: 10, +//! align_mask: 1, +//! usage: UsageFlags::HOST_ACCESS, +//! memory_types: !0, +//! }, +//! ) +//! }?; +//! +//! unsafe { +//! block.write_bytes( +//! &device, +//! 0, +//! &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], +//! ) +//! }?; +//! +//! unsafe { allocator.dealloc(&device, block) } +//! //! Ok(()) //! } //! ```