pub struct UnpremultiplyPass { /* private fields */ }Expand description
The straight-alpha present pass for one surface: a pipeline built for that surface’s own format plus the bind-group layout its program derived.
Built once per surface configure (a rare event) — a pipeline object, a bind-group layout and nothing per frame but one bind group.
Implementations§
Source§impl UnpremultiplyPass
impl UnpremultiplyPass
Sourcepub fn selected_by(output: OutputAlpha) -> bool
pub fn selected_by(output: OutputAlpha) -> bool
Whether a swapchain interpreting its alpha as output needs this pass.
The whole routing rule, in one place: Straight does, Premultiplied
does not — the engine already writes the latter’s convention, and a
conversion there would divide every partial-alpha pixel by its own alpha
for nothing.
Sourcepub fn new(
device: &Device,
format: TextureFormat,
driver_cache: Option<&PipelineCache>,
) -> Self
pub fn new( device: &Device, format: TextureFormat, driver_cache: Option<&PipelineCache>, ) -> Self
Builds the pass for a format target.
driver_cache is the host’s persisted wgpu::PipelineCache when it has
one — None on every backend but Vulkan, which is every backend this
arm actually runs on today (it exists for iOS/Metal), so the parameter
is about keeping the seam honest rather than about a cache hit.
The pipeline is built through a frust_gpu::PipelineCache of this
pass’s own, over a one-module library: the substrate’s rule is that a
frame is never the first place a pipeline is compiled, and a surface
configure is not a frame. The cache is not kept — the compiled pipeline
is a reference-counted handle that outlives it, and there is exactly one
variant to ask for.
Sourcepub fn format(&self) -> TextureFormat
pub fn format(&self) -> TextureFormat
The target format this pass was built for — the surface’s own, since it writes the swapchain directly.
Sourcepub fn record(
&self,
device: &Device,
encoder: &mut CommandEncoder,
source_view: &TextureView,
target_view: &TextureView,
timestamp_writes: Option<RenderPassTimestampWrites<'_>>,
)
pub fn record( &self, device: &Device, encoder: &mut CommandEncoder, source_view: &TextureView, target_view: &TextureView, timestamp_writes: Option<RenderPassTimestampWrites<'_>>, )
Records the conversion into encoder: reads source_view (the
premultiplied intermediate the frame was rendered into) and writes
straight-alpha pixels into target_view (the acquired swapchain
texture). The caller submits encoder.
No extent is taken: the triangle covers the whole destination whatever its size, and the fragment stage reads the source at its own position, so the two views only have to agree with each other — which the surface that owns both guarantees by recreating them together.
The attachment is CLEARED rather than loaded even though every pixel of it is then written: the destination is a fresh swapchain image whose prior contents mean nothing, and a load would cost a tile read per tile on exactly the mobile GPUs this tier targets.
The bind group is built per call rather than cached, mirroring
frust-render’s own premultiply pass: it names the source view, which a
resize replaces, so caching it would need an invalidation seam to buy one
allocation a frame.
timestamp_writes is the pass’s own timestamp_writes, verbatim — the
host asks its frust_gpu::diag::TimestampRing (via
frust_engine::FrameTimestamps) for one fresh pair charged to
crate::diag::EngineSpan::Blit and hands it straight through, None
on every arm that does not time this pass (an inert ring, a tier build
with no perf-trace, or the EngineDirect arm this pass never runs on
at all).
Sourcepub fn layout_desc() -> PipelineLayoutDesc
pub fn layout_desc() -> PipelineLayoutDesc
This pass’s shape as the downlevel lint reads it, so the bind-group,
vertex-topology and sample-count ceilings
(frust_gpu::lint::lint_pipeline_layout) are checked against the real
description rather than restated in prose.