Skip to main content

StagingRing

Struct StagingRing 

Source
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>

Source

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.

Source

pub fn with_limits(max_slots: usize, max_slot_bytes: u64) -> Self

An empty ring with its slot count and per-slot ceiling stated.

Source

pub fn stats(&self) -> StagingStats

What this ring has done so far.

Source

pub fn slot_count(&self) -> usize

How many slots exist.

Source

pub fn slot(&self, index: usize) -> Option<(u64, SlotState)>

Slot index’s capacity and state, if it exists.

Source§

impl<B: Clone> StagingRing<B>

Source

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>

Source

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.

Trait Implementations§

Source§

impl<B: Debug> Debug for StagingRing<B>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<B> Default for StagingRing<B>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<B> Freeze for StagingRing<B>
where Vec<Slot<B>>: Freeze,

§

impl<B> RefUnwindSafe for StagingRing<B>
where Vec<Slot<B>>: RefUnwindSafe,

§

impl<B> Send for StagingRing<B>
where Vec<Slot<B>>: Send,

§

impl<B> Sync for StagingRing<B>
where Vec<Slot<B>>: Sync,

§

impl<B> Unpin for StagingRing<B>
where Vec<Slot<B>>: Unpin,

§

impl<B> UnsafeUnpin for StagingRing<B>
where Vec<Slot<B>>: UnsafeUnpin,

§

impl<B> UnwindSafe for StagingRing<B>
where Vec<Slot<B>>: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,