Skip to main content

StagingFrame

Struct StagingFrame 

Source
pub struct StagingFrame { /* private fields */ }
Expand description

One frame’s open slot: a mapped view to write uploads into and the copy commands that move them to their destinations.

Every copy is recorded into the encoder the caller passes, at the point the caller calls — so a renderer records its copies ahead of the passes that read their destinations. Self::finish must run before that encoder is submitted: it unmaps the slot (a mapped buffer cannot be submitted) and attaches the slot’s fence to the encoder. A frame dropped without it unmaps the slot and leaves it abandoned, which is still safe to submit.

Implementations§

Source§

impl StagingFrame

Source

pub fn used(&self) -> u64

Bytes placed so far, alignment padding included.

Source

pub fn slot(&self) -> Option<usize>

The slot this frame writes into.

Source

pub fn copy_to_buffer( &mut self, encoder: &mut CommandEncoder, bytes: &[u8], dst: &Buffer, dst_offset: u64, ) -> bool

Writes bytes into the slot and records their copy to dst at dst_offset, answering whether it did; false (nothing written, nothing recorded) means the caller writes them by queue instead.

Refused when they do not fit the slot or are not a whole number of wgpu::COPY_BUFFER_ALIGNMENT units, which a copy command cannot move.

Source

pub fn copy_parts_to_buffer( &mut self, encoder: &mut CommandEncoder, parts: &[&[u8]], dst: &Buffer, dst_offset: u64, ) -> bool

Self::copy_to_buffer over parts laid back to back: one copy command for data the caller holds in pieces, landing in dst exactly as the pieces’ concatenation. Only the whole is held to the copy alignment, not each piece.

Source

pub fn copy_to_texture( &mut self, encoder: &mut CommandEncoder, dst: TexelCopyTextureInfo<'_>, bytes_per_row: u32, rows: u32, extent: Extent3d, fill: impl FnOnce(WriteOnly<'_, [u8]>), ) -> bool

Writes one texture upload of rows rows of bytes_per_row bytes into the slot — fill is handed exactly that many bytes of the mapping and must write every one of them — and records its copy to dst over extent, answering whether it did. false (nothing written, nothing recorded) means the caller writes the texture by queue instead.

Refused when the upload does not fit the slot, or when bytes_per_row is not a multiple of wgpu::COPY_BYTES_PER_ROW_ALIGNMENT, which a buffer-to-texture copy requires (a queue write does not).

Source

pub fn finish(self, encoder: &CommandEncoder)

Ends the frame: unmaps the slot and attaches its fence to encoder, so the slot is re-mapped — and handed out again — only once the submission carrying encoder has finished on the GPU.

Trait Implementations§

Source§

impl Debug for StagingFrame

Source§

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

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

impl Drop for StagingFrame

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

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,