Skip to content

Commit

Permalink
backend documents mirrors examples crates
Browse files Browse the repository at this point in the history
sections was added was added to the examples crate to show the
usage of new api (6a8bb87), but the examples crate is not
published on `crates.io` and `docs.rs`, this commit updates
brings the same example code to the documents of the backend
crates `gpu-alloc-ash` and `gpu-alloc-erupt`.
  • Loading branch information
nerditation authored and zakarumych committed Mar 28, 2024
1 parent fd2986a commit 35640d1
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
24 changes: 24 additions & 0 deletions ash/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
//! }
//! ```
Expand Down
24 changes: 24 additions & 0 deletions erupt/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
//! }
//! ```
Expand Down

0 comments on commit 35640d1

Please sign in to comment.