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: ChainTexturesResolution-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: f32Instantaneous 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
impl RenderChain
Sourcepub fn new(gpu: &GpuContext, mesh: &WarpMesh) -> Result<Self>
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.
Sourcepub fn with_textures(
gpu: &GpuContext,
mesh: &WarpMesh,
textures: ChainTextures,
) -> Result<Self>
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.
Sourcepub fn textures(&self) -> &ChainTextures
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.
Sourcepub fn update_warp_vertices(
&mut self,
queue: &Queue,
cols: u32,
rows: u32,
vertices: &[WarpVertex],
)
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.
Sourcepub fn rebuild_warp_mesh(&mut self, device: &Device, mesh: &WarpMesh)
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].
Sourcepub fn update_waveform_samples(
&mut self,
queue: &Queue,
samples: &[f32],
instantaneous_volume: f32,
wave_params: WaveParams,
)
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.
Sourcepub fn update_waveform_samples_lr(
&mut self,
queue: &Queue,
left: &[f32],
right: &[f32],
instantaneous_volume: f32,
wave_params: WaveParams,
)
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.
pub fn wave_samples(&self) -> &[f32]
pub fn wave_volume(&self) -> f32
Sourcepub fn update_custom_waves(
&mut self,
queue: &Queue,
vertices: &[CustomWaveVertex],
batches: &[CustomWaveBatch],
)
pub fn update_custom_waves( &mut self, queue: &Queue, vertices: &[CustomWaveVertex], batches: &[CustomWaveBatch], )
Upload the per-frame custom-wave vertex stream.
pub fn custom_wave_vertex_count(&self) -> u32
pub fn custom_wave_batch_count(&self) -> usize
Sourcepub fn update_custom_shapes(
&mut self,
queue: &Queue,
instances: &[CustomShapeInstance],
batches: &[CustomShapeBatch],
aspect: f32,
)
pub fn update_custom_shapes( &mut self, queue: &Queue, instances: &[CustomShapeInstance], batches: &[CustomShapeBatch], aspect: f32, )
Upload the per-frame custom-shape instance stream.
pub fn custom_shape_instance_count(&self) -> u32
pub fn custom_shape_batch_count(&self) -> usize
pub fn border_batch_count(&self) -> usize
pub fn motion_vector_segment_count(&self) -> u32
Sourcepub fn comp_pipeline(&self) -> &CompPipeline
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).
pub fn comp_pipeline_mut(&mut self) -> &mut CompPipeline
Sourcepub fn warp_pipeline(&self) -> &WarpPipeline
pub fn warp_pipeline(&self) -> &WarpPipeline
Borrow the warp pipeline. Mirrors Self::comp_pipeline; needed
by the renderer’s set_user_warp_shader path.
pub fn warp_pipeline_mut(&mut self) -> &mut WarpPipeline
Sourcepub fn record_passes(
&mut self,
gpu: &GpuContext,
encoder: &mut CommandEncoder,
state: &RenderState,
comp_uniforms: &ShaderUniforms,
sprite_pipeline: &SpritePipeline,
sprite_pool: &SpritePool,
sprite_frames: &[SpriteFrame],
)
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.
Sourcepub fn copy_to_prev(&self, encoder: &mut CommandEncoder, gpu: &GpuContext)
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.
Sourcepub fn resize(&mut self, gpu: &GpuContext)
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§
impl Freeze for RenderChain
impl !RefUnwindSafe for RenderChain
impl Send for RenderChain
impl Sync for RenderChain
impl Unpin for RenderChain
impl !UnwindSafe for RenderChain
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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