pub struct StagingRing<B = Buffer> { /* private fields */ }Expand description
The slots, their capacities and fences: one frame’s staging memory at a time, reused once the GPU is done with it.
Generic over the buffer type for the reason the module header gives; the
engine uses the default StagingRing<wgpu::Buffer>.
Implementations§
Source§impl<B> StagingRing<B>
impl<B> StagingRing<B>
Sourcepub fn new() -> Self
pub fn new() -> Self
An empty ring of STAGING_SLOTS slots of at most
MAX_SLOT_BYTES each. No buffer exists until the first frame.
Sourcepub fn with_limits(max_slots: usize, max_slot_bytes: u64) -> Self
pub fn with_limits(max_slots: usize, max_slot_bytes: u64) -> Self
An empty ring with its slot count and per-slot ceiling stated.
Sourcepub fn stats(&self) -> StagingStats
pub fn stats(&self) -> StagingStats
What this ring has done so far.
Sourcepub fn slot_count(&self) -> usize
pub fn slot_count(&self) -> usize
How many slots exist.
Source§impl<B: Clone> StagingRing<B>
impl<B: Clone> StagingRing<B>
Sourcepub fn acquire<A>(&mut self, allocator: &A, bytes: u64) -> Option<SlotLease<B>>where
A: StagingAllocator<Buffer = B>,
pub fn acquire<A>(&mut self, allocator: &A, bytes: u64) -> Option<SlotLease<B>>where
A: StagingAllocator<Buffer = B>,
Hands out a slot holding at least bytes, or None when the frame
needs more than a slot may hold or every slot is still in flight.
In order of preference: a ready slot already large enough (no
allocation), a ready slot too small or an abandoned/failed one
replaced at slot_capacity(bytes), a new slot while the ring has
fewer than its limit. A slot in flight is never handed out.
Source§impl StagingRing<Buffer>
impl StagingRing<Buffer>
Sourcepub fn begin(&mut self, device: &Device, bytes: u64) -> Option<StagingFrame>
pub fn begin(&mut self, device: &Device, bytes: u64) -> Option<StagingFrame>
Opens one frame’s staging: a mapped slot of at least bytes, or None
when the caller should fall back to queue writes this frame (see
Self::acquire).
When every slot is still in flight the device is polled once, without waiting, so a slot whose submission has already finished is re-mapped rather than skipped.