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
impl ShaderQuadPass
Sourcepub fn new(pipeline_cache: Option<PipelineCache>) -> Self
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.
Sourcepub fn registered_len(&self) -> usize
pub fn registered_len(&self) -> usize
How many programs currently have a target registered with a renderer.
Sourcepub fn set_frame_target_extent(&mut self, extent: Option<(u32, u32)>)
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.
Sourcepub fn prepare(
&mut self,
device: &Device,
queue: &Queue,
encoder: &mut CommandEncoder,
scene: &Scene,
root: Affine,
engine: &mut EngineRenderer,
)
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.