Skip to main content

UnpremultiplyPass

Struct UnpremultiplyPass 

Source
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

Source

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.

Source

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.

Source

pub fn format(&self) -> TextureFormat

The target format this pass was built for — the surface’s own, since it writes the swapchain directly.

Source

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

Source

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.

Trait Implementations§

Source§

impl Debug for UnpremultiplyPass

Source§

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

Formats the value using the given formatter. Read more

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,