pub struct StagingBufferPool { /* private fields */ }Expand description
Device-local staging buffer pool keyed by (size, usage).
Hot dispatch paths (e.g. GpuBufferHandle::readback_until) acquire
readback staging buffers from this pool instead of creating a fresh
wgpu::Buffer on every call. Each (size, usage) class is capped at
[STAGING_BUFFER_POOL_CLASS_CAP] entries; evictions drop the
least-recently-used buffer.
Implementations§
Source§impl StagingBufferPool
impl StagingBufferPool
Sourcepub fn stats(&self) -> StagingBufferPoolStats
pub fn stats(&self) -> StagingBufferPoolStats
Return allocation and hit counters.
Sourcepub fn acquire(&self, device: &Device, size: u64, usage: BufferUsages) -> Buffer
pub fn acquire(&self, device: &Device, size: u64, usage: BufferUsages) -> Buffer
Acquire a staging buffer with exactly size bytes and usage.
Reuses a free buffer when one is available; otherwise creates a fresh GPU allocation and increments the allocation counter.
Sourcepub fn release(&self, buffer: Buffer, size: u64, usage: BufferUsages)
pub fn release(&self, buffer: Buffer, size: u64, usage: BufferUsages)
Release a staging buffer back to the pool.
The buffer is pushed to the MRU position of its (size, usage) class.
If the class already holds 16 buffers, the LRU entry is dropped.
Trait Implementations§
Source§impl Clone for StagingBufferPool
impl Clone for StagingBufferPool
Source§fn clone(&self) -> StagingBufferPool
fn clone(&self) -> StagingBufferPool
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for StagingBufferPool
impl Debug for StagingBufferPool
Source§impl Default for StagingBufferPool
impl Default for StagingBufferPool
Source§fn default() -> StagingBufferPool
fn default() -> StagingBufferPool
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for StagingBufferPool
impl RefUnwindSafe for StagingBufferPool
impl Send for StagingBufferPool
impl Sync for StagingBufferPool
impl Unpin for StagingBufferPool
impl UnsafeUnpin for StagingBufferPool
impl UnwindSafe for StagingBufferPool
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