Skip to main content

ShaderQuadPass

Struct ShaderQuadPass 

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

Renders a frame’s Command::ShaderQuads into pooled offscreen targets and registers each with the renderer that will draw it.

Owned by whoever owns the frame’s EngineRenderer and the encoder it records into — the two have to be the same frame’s — and driven once per frame through Self::prepare, including frames drawing no quad at all: that is the call on which a program the scene has stopped drawing ages towards its reap.

Implementations§

Source§

impl ShaderQuadPass

Source

pub fn new(pipeline_cache: Option<PipelineCache>) -> Self

An empty pass seeded with an optional clone of the surface’s wgpu::PipelineCache, so a persisted cache speeds a user program’s first compilation exactly as it speeds the engine’s own pipelines.

Source

pub fn registered_len(&self) -> usize

How many programs currently have a target registered with a renderer.

Source

pub fn set_frame_target_extent(&mut self, extent: Option<(u32, u32)>)

Sets the frame’s own render-target extent, in device pixels, so the next Self::prepare call can cull a quad whose device-space rectangle does not intersect it at all (see [frame_demands]’s doc comment for the exact rule). None (the default a fresh Self::new starts with) applies no culling.

The extent passed here MUST be the frame’s own real render target — the same size the surface (or headless target) EngineRenderer::encode is about to be called with — never an approximation or a stale value from an earlier resize: a wrong extent culls a quad that would in fact have landed on the real target, which is a visible miss, not merely a missed optimization.

Opt-in rather than inferred: prepare’s own signature is fixed by its external caller (frust-render’s SurfaceRenderer, which records the pre-pass ahead of EngineRenderer::encode — see the module header), and nothing reachable from prepare’s existing parameters names the frame’s target extent today (EngineRenderer learns it only when encode itself is called, afterward). Adding a required parameter to prepare to carry it through would break that caller — out of scope here — so a caller that knows its target extent ahead of time calls this setter first instead. Wiring frust-render’s own call site to do so is a follow-up outside this module.

Source

pub fn prepare( &mut self, device: &Device, queue: &Queue, encoder: &mut CommandEncoder, scene: &Scene, root: Affine, engine: &mut EngineRenderer, )

Renders every fragment program scene draws into its own pooled target, recording each pass into encoder, and registers the results with engine so the frame compiled after this call draws them.

Call once per frame, before engine’s own encode and with that frame’s encoder, scene and root. Nothing is submitted: the passes recorded here precede the frame’s in the same command buffer, which is the whole ordering guarantee the effect needs.

A program that fails to compile, or whose target could not be built, is unregistered rather than left pointing at a stale texture — its quads draw nothing, and the compiler says so once. When the kill switch is set the same unregistration happens for every program and no GPU work is done at all.

Trait Implementations§

Source§

impl Debug for ShaderQuadPass

Source§

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

ShaderEffects owns wgpu handles that do not print usefully, so the pass reports the only state a reader can act on: how many programs are registered.

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