pub struct WebGpuMemoryManager { /* private fields */ }Expand description
Manages a pool of device-resident wgpu::Buffer objects, returning opaque
u64 handles to callers.
All public methods are &self to allow shared references from the backend.
Implementations§
Source§impl WebGpuMemoryManager
impl WebGpuMemoryManager
Sourcepub fn new(device: Arc<WebGpuDevice>) -> Self
pub fn new(device: Arc<WebGpuDevice>) -> Self
Create a new memory manager backed by device.
Sourcepub fn alloc(&self, bytes: usize) -> WebGpuResult<u64>
pub fn alloc(&self, bytes: usize) -> WebGpuResult<u64>
Allocate a new device buffer of bytes bytes.
Returns an opaque handle that identifies the buffer.
Sourcepub fn free(&self, handle: u64) -> WebGpuResult<()>
pub fn free(&self, handle: u64) -> WebGpuResult<()>
Release the buffer associated with handle.
The handle is silently ignored if it is unknown (already freed).
Sourcepub fn copy_to_device(&self, handle: u64, src: &[u8]) -> WebGpuResult<()>
pub fn copy_to_device(&self, handle: u64, src: &[u8]) -> WebGpuResult<()>
Upload src (host bytes) into the device buffer identified by handle.
Sourcepub fn copy_from_device(&self, dst: &mut [u8], handle: u64) -> WebGpuResult<()>
pub fn copy_from_device(&self, dst: &mut [u8], handle: u64) -> WebGpuResult<()>
Download the device buffer identified by handle into dst (host bytes).
Uses a temporary MAP_READ staging buffer and blocks until the GPU
work completes.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for WebGpuMemoryManager
impl !RefUnwindSafe for WebGpuMemoryManager
impl Send for WebGpuMemoryManager
impl Sync for WebGpuMemoryManager
impl Unpin for WebGpuMemoryManager
impl UnsafeUnpin for WebGpuMemoryManager
impl !UnwindSafe for WebGpuMemoryManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more