RenderChain

Struct RenderChain 

Source
pub struct RenderChain {
    textures: ChainTextures,
    warp: WarpPipeline,
    blur: BlurPipeline,
    comp: CompPipeline,
    waveform: WaveformRenderer,
    custom_wave: CustomWaveRenderer,
    custom_shape: CustomShapeRenderer,
    border: BorderRenderer,
    motion_vector: MotionVectorRenderer,
    wave_samples: Vec<f32>,
    wave_volume: f32,
    last_warp_field: Option<(u32, u32, Vec<WarpVertex>)>,
}
Expand description

The eight per-frame pipelines plus the small per-chain caches and the per-chain feedback textures (render / prev / final / blur1-3 / scratch).

Fields§

§textures: ChainTextures

Resolution-dependent feedback textures owned by this chain. Secondary chains during transitions get a fresh ChainTextures so the two preset states don’t collide on the warp / prev / blur targets.

§warp: WarpPipeline§blur: BlurPipeline§comp: CompPipeline§waveform: WaveformRenderer§custom_wave: CustomWaveRenderer§custom_shape: CustomShapeRenderer§border: BorderRenderer§motion_vector: MotionVectorRenderer§wave_samples: Vec<f32>

Mono-mixed audio for the waveform pass, smoothed CPU-side per WaveParams::smoothing before upload.

§wave_volume: f32

Instantaneous frame-mean volume used by b_mod_wave_alpha_by_volume.

§last_warp_field: Option<(u32, u32, Vec<WarpVertex>)>

Latest (cols, rows, WarpVertex[]) snapshot from the most recent update_warp_vertices call. Read by the motion-vector pass to build anisotropic segments aligned with the local warp displacement.

Implementations§

Source§

impl RenderChain

Source

pub fn new(gpu: &GpuContext, mesh: &WarpMesh) -> Result<Self>

Build a chain against the supplied GPU context and warp mesh. The chain’s pipelines bind the context’s render/prev/blur texture views directly; callers must call [Self::rebind_after_resize] if the context is later resized.

The mesh stays owned by the renderer (the engine evaluates per-vertex equations against it, so it has a single-owner constraint above the renderer level); the chain only needs it at construction time to size the vertex buffer.

Source

pub fn with_textures( gpu: &GpuContext, mesh: &WarpMesh, textures: ChainTextures, ) -> Result<Self>

Same as Self::new but uses a caller-provided ChainTextures. Useful when reclaiming textures from a previous chain (e.g. swapping the secondary into the primary slot at the end of a transition) to avoid an unnecessary GPU allocation.

Source

pub fn textures(&self) -> &ChainTextures

Borrow the chain’s feedback textures — needed by the renderer to read the final comp output (for blend / display) and to drive the copy_to_prev step that closes the per-frame feedback loop.

Source

pub fn update_warp_vertices( &mut self, queue: &Queue, cols: u32, rows: u32, vertices: &[WarpVertex], )

Push freshly computed warp UVs to the GPU. Also caches the vertex array on the CPU so the motion-vector pass can sample the per-cell warp displacement (anisotropic segments) when it runs later in the same frame.

Source

pub fn rebuild_warp_mesh(&mut self, device: &Device, mesh: &WarpMesh)

Reallocate the warp pipeline’s vertex/index buffers for a different-sized mesh. Driven by [MilkRenderer::set_mesh_size].

Source

pub fn update_waveform_samples( &mut self, queue: &Queue, samples: &[f32], instantaneous_volume: f32, wave_params: WaveParams, )

Push a fresh mono audio sample window for the waveform pass.

Applies the IIR smoothing dictated by wave_params.smoothing on the CPU side before upload; the buffer is clamped to NUM_WAVE_SAMPLES and shorter inputs are zero-padded.

Source

pub fn update_waveform_samples_lr( &mut self, queue: &Queue, left: &[f32], right: &[f32], instantaneous_volume: f32, wave_params: WaveParams, )

Stereo variant of Self::update_waveform_samples. Uploads both channels into the 2N-wide sample buffer so the waveform pass can read L from offset 0 and R from offset N in two dispatches.

instantaneous_volume is computed from the perceptual downmix (engine-side) so it represents the listener’s loudness, not one channel’s. Smoothing is applied to each channel independently.

Source

pub fn wave_samples(&self) -> &[f32]

Source

pub fn wave_volume(&self) -> f32

Source

pub fn update_custom_waves( &mut self, queue: &Queue, vertices: &[CustomWaveVertex], batches: &[CustomWaveBatch], )

Upload the per-frame custom-wave vertex stream.

Source

pub fn custom_wave_vertex_count(&self) -> u32

Source

pub fn custom_wave_batch_count(&self) -> usize

Source

pub fn update_custom_shapes( &mut self, queue: &Queue, instances: &[CustomShapeInstance], batches: &[CustomShapeBatch], aspect: f32, )

Upload the per-frame custom-shape instance stream.

Source

pub fn custom_shape_instance_count(&self) -> u32

Source

pub fn custom_shape_batch_count(&self) -> usize

Source

pub fn border_batch_count(&self) -> usize

Source

pub fn motion_vector_segment_count(&self) -> u32

Source

pub fn comp_pipeline(&self) -> &CompPipeline

Borrow the comp pipeline — needed by the renderer to swap in user shaders (the user-shader pipeline owns the texture binding plan and stays attached to MilkRenderer for now).

Source

pub fn comp_pipeline_mut(&mut self) -> &mut CompPipeline

Source

pub fn warp_pipeline(&self) -> &WarpPipeline

Borrow the warp pipeline. Mirrors Self::comp_pipeline; needed by the renderer’s set_user_warp_shader path.

Source

pub fn warp_pipeline_mut(&mut self) -> &mut WarpPipeline

Source

pub fn record_passes( &mut self, gpu: &GpuContext, encoder: &mut CommandEncoder, state: &RenderState, comp_uniforms: &ShaderUniforms, sprite_pipeline: &SpritePipeline, sprite_pool: &SpritePool, sprite_frames: &[SpriteFrame], )

Record the eight per-frame passes into the supplied encoder, in MD2 order: warp → waveform (+ optional mirrored second pass for double_line) → custom waves → custom shapes → borders → motion vectors → blur pyramid → comp.

Does not submit; the renderer is responsible for the submit and for the copy_to_prev step that closes the feedback loop.

Source

pub fn copy_to_prev(&self, encoder: &mut CommandEncoder, gpu: &GpuContext)

Copy this chain’s render_texture into its prev_texture so the next frame’s warp pass sees the current frame’s output as feedback. Caller drives this via the renderer’s encoder after record_passes.

Source

pub fn resize(&mut self, gpu: &GpuContext)

Re-allocate per-chain textures at the new resolution and rebind every pass. Replaces both the renderer-level resize plumbing and the per- chain rebind that V.0 left in place.

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
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<T> WasmNotSend for T
where T: Send,

§

impl<T> WasmNotSendSync for T
where T: WasmNotSend + WasmNotSync,

§

impl<T> WasmNotSync for T
where T: Sync,