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
impl StagingFrame
Sourcepub fn copy_to_buffer(
&mut self,
encoder: &mut CommandEncoder,
bytes: &[u8],
dst: &Buffer,
dst_offset: u64,
) -> bool
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.
Sourcepub fn copy_parts_to_buffer(
&mut self,
encoder: &mut CommandEncoder,
parts: &[&[u8]],
dst: &Buffer,
dst_offset: u64,
) -> bool
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.
Sourcepub 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
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).
Sourcepub fn finish(self, encoder: &CommandEncoder)
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.