Skip to main content

ExternalFrame

Struct ExternalFrame 

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

Source

pub fn device(&self) -> &Device

The device this frame is being recorded on — the shell’s own live device, not a second one.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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).

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for ExternalFrame<'a>

§

impl<'a> !UnwindSafe for ExternalFrame<'a>

§

impl<'a> Freeze for ExternalFrame<'a>

§

impl<'a> Send for ExternalFrame<'a>

§

impl<'a> Sync for ExternalFrame<'a>

§

impl<'a> Unpin for ExternalFrame<'a>

§

impl<'a> UnsafeUnpin for ExternalFrame<'a>

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, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(_simd: S, value: T) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

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,