Skip to main content

FilterResources

Struct FilterResources 

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

The GPU resources a frame’s filter rounds are executed with, beyond the two pooled pages they ping-pong between.

Three of them, and each is the engine’s only one of its kind: the filter-data texture holding every filter in the frame’s 48-byte parameter block, the bilinear sampler (filter_sampler) the blur kernels read their source page through, and the instance buffer one quad per pass is drawn from.

Public because this is executing a filter pass — the renderer holds one and drives it over the pages the scheduler named, and tests/filters.rs drives the same type over pages of its own on real hardware. That second caller is not a convenience: frust_scene carries no filter command yet (the scene seam is a later plan), so a filter layer cannot reach EngineRenderer::encode through a Scene at all, and driving this type directly is the only way the ported WGSL is exercised on a device.

Implementations§

Source§

impl FilterResources

Source

pub fn new(device: &Device) -> Self

A renderer’s filter resources, with nothing uploaded yet.

Source

pub fn prepare( &mut self, device: &Device, queue: &Queue, pipeline: &RenderPipeline, blocks: &[GpuFilterData], passes: u32, )

Uploads this frame’s parameter blocks and reserves room for passes pass instances, growing either resource if the frame outgrew it.

pipeline is the one EnginePipeline::Filter describes; it is needed because wgpu derives a pipeline’s bind-group layouts from its shader module, so the group naming the filter-data texture can only be built against the pipeline that will bind it.

A block count no filter-data texture could hold (see filter_data_texture_height) leaves the group unbuilt, which leaves every filter pass of the frame issuing no draw — the page is still cleared, so the layer composites as transparent rather than as whatever its page last held. Unreachable in practice, and “draw less, never wrong” when it is not.

Source

pub fn write_instance( &self, queue: &Queue, index: u32, instance: &FilterInstanceData, )

Writes one pass’s instance into slot index of the instance buffer.

Separate from Self::prepare because a pass’s dest_texture_size is the extent the texture pool quantized its destination page up to, and NDC is computed against the attachment’s real extent — only the round that acquires the page knows it. A queue write issued while the frame is being recorded still lands ahead of the command buffers it is submitted with, which is the same ordering a page’s viewport uniform already relies on.

A slot past the reserved capacity is dropped rather than written, which leaves that pass drawing whatever the slot last held; unreachable, since prepare reserved one slot per pass of this very frame.

Source

pub fn record_pass( &self, device: &Device, encoder: &mut CommandEncoder, plan: &FilterPassPlan<'_>, )

Records one filter pass into encoder: clear the destination page, then draw the one instanced quad that filters plan’s source into it.

The clear is unconditional and the draw is not. A filter pass writes only the region its step names — a decimated one a quarter of the texels the pass before it did — and the kernels sample past that region without bounds checks, so whatever surrounds it has to be transparent rather than a previous holder’s pixels. That has to hold even on the path where the pass itself cannot be issued, or the layer’s composite would sample the page’s previous tenant instead of nothing.

The pass is opened and closed here, on the caller’s own encoder: a filter round is not an exception to EngineRenderer::encode’s contract.

Source

pub fn record_pass_timed( &self, device: &Device, encoder: &mut CommandEncoder, plan: &FilterPassPlan<'_>, timestamps: Option<RenderPassTimestampWrites<'_>>, )

Self::record_pass, stamping the pass’s GPU time into timestamps.

A separate method rather than a field on FilterPassPlan: the plan is public and built by struct literal outside this crate, so a new required field would break every one of those call sites to serve a diagnostic they do not use. None records exactly what Self::record_pass does.

Trait Implementations§

Source§

impl Debug for FilterResources

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,