pub struct ExternalFrame<'a> { /* private fields */ }Expand description
The live frame handed to ExternalPass::record: the device and queue
behind it, the encoder every pass of this frame is recorded into, and the
engine’s texture registry to bind results into.
Borrowed for the duration of one record call and never longer — nothing
here can be stashed across frames, which is what keeps a pass from
out-living the surface whose device it was handed. wgpu::Device and
wgpu::Queue are cheaply Clone (both Arc-backed underneath), so
Self::device/Self::queue returning a borrow does not itself stop a
pass from cloning one and stashing the owned handle past this call —
doing that is a contract violation regardless of whether the borrow
checker catches it: the shell that owns the real device may drop and
recreate it (surface loss, a GPU reset), and a clone a pass kept past
that point references a device that looks alive but is not the one
backing any future frame, so GPU work built against it fails or panics
rather than silently rebinding to the shell’s current one.
Built fresh for each pass a drain runs, scoped to that one pass’s own
registered id (Self::id) — a pass never sees another pass’s id, and
Self::bind_texture/Self::unbind_texture act only on its own.
Implementations§
Source§impl<'a> ExternalFrame<'a>
impl<'a> ExternalFrame<'a>
Sourcepub fn device(&self) -> &Device
pub fn device(&self) -> &Device
The device this frame is being recorded on — the shell’s own live device, not a second one.
Sourcepub fn queue(&self) -> &Queue
pub fn queue(&self) -> &Queue
The queue the frame will be submitted on, for staged writes
(write_texture, write_buffer) a pass needs committed before the
frame reads them.
Sourcepub fn encoder(&mut self) -> &mut CommandEncoder
pub fn encoder(&mut self) -> &mut CommandEncoder
The frame’s own encoder — the one the scene pass is recorded into after every pass has run, and the one the renderer submits once.
Sourcepub fn id(&self) -> SceneTextureId
pub fn id(&self) -> SceneTextureId
The id the pass being recorded this call is registered under —
what Self::bind_texture/Self::unbind_texture act on.
Sourcepub fn frame_index(&self) -> u64
pub fn frame_index(&self) -> u64
How many frames this process has drained passes in, counting from zero.
Advances once per drain that has at least one pass to run, so a pass animating off it sees a dense sequence rather than one with the pass-free frames of other surfaces punched out of it. It is a frame counter, not a clock: a pass needing wall-clock time reads one.
Sourcepub fn bind_texture(
&mut self,
size: (u32, u32),
view: TextureView,
) -> Option<TextureView>
pub fn bind_texture( &mut self, size: (u32, u32), view: TextureView, ) -> Option<TextureView>
Registers view under this pass’s own id (Self::id) so this
frame’s Command::SceneTexture naming that id composites it,
returning whatever was bound under it before.
size is the view’s extent in texels — the rectangle the display
list’s destination is mapped onto. It is a pass’s own choice, read
however its owner reads layout (a widget’s own size, typically); this
type carries no target extent of its own to hand back. view must be
a non-array 2D view of a float-sampleable texture carrying
wgpu::TextureUsages::TEXTURE_BINDING. A zero extent, or one past
u16::MAX on either axis, registers nothing and leaves scenes naming
the id drawing nothing; so does an id nothing ever bound. Re-binding
replaces the previous view.
Sourcepub fn unbind_texture(&mut self) -> Option<TextureView>
pub fn unbind_texture(&mut self) -> Option<TextureView>
Removes the view bound under this pass’s own id (Self::id),
returning it. A pass tearing its own target down mid-run does this
itself; a pass that simply stops being registered has it done for it
(see the module docs).