pub struct WaveformRenderer {
pipelines: [RenderPipeline; 4],
bind_group: BindGroup,
uniform_buffer: Buffer,
sample_buffer: Buffer,
last_uniforms: WaveUniforms,
}Expand description
GPU waveform pass — owns its pipelines, uniforms, and a sample
storage buffer of fixed length NUM_WAVE_SAMPLES.
Fields§
§pipelines: [RenderPipeline; 4]4 pipelines: (alpha lines, additive lines, alpha dots, additive
dots). Indexed by pipeline_index(is_dots, is_additive).
bind_group: BindGroup§uniform_buffer: Buffer§sample_buffer: Buffer§last_uniforms: WaveUniformsLast uniforms uploaded, kept for flip_y double-pass dispatch.
Implementations§
Source§impl WaveformRenderer
impl WaveformRenderer
Sourcepub fn new(device: &Device, format: TextureFormat) -> Self
pub fn new(device: &Device, format: TextureFormat) -> Self
Create a new renderer targeting format. format must match the
texture the host will dispatch into (typically render_texture).
Sourcepub fn update_wave_samples(&self, queue: &Queue, samples: &[f32])
pub fn update_wave_samples(&self, queue: &Queue, samples: &[f32])
Push a fresh sample buffer (mono, length capped at
NUM_WAVE_SAMPLES; shorter buffers are zero-padded). Apply CPU
IIR smoothing first with apply_smoothing if you want
wave_smoothing to actually attenuate spikes.
Mono path: the same data is written into both halves of the
2N-wide buffer so a shader pass at either sample_offset sees
coherent samples. Stereo callers use
Self::update_wave_samples_lr instead.
Sourcepub fn update_wave_samples_lr(&self, queue: &Queue, left: &[f32], right: &[f32])
pub fn update_wave_samples_lr(&self, queue: &Queue, left: &[f32], right: &[f32])
Push split L/R sample buffers. Left lands at offset 0 (the
default sample_offset of 0 reads it); right lands at offset
NUM_WAVE_SAMPLES. Used by the top-vs-bottom split path —
RenderChain::record_passes dispatches two waveform passes with
distinct sample_offset + wave_y so the listener sees L on
the upper half and R on the lower half.
Sourcepub fn update_uniforms(&mut self, queue: &Queue, u: &WaveUniforms)
pub fn update_uniforms(&mut self, queue: &Queue, u: &WaveUniforms)
Push fresh uniforms. Keeps a CPU-side copy for double-pass mode 6.
Sourcepub fn render(&self, encoder: &mut CommandEncoder, view: &TextureView)
pub fn render(&self, encoder: &mut CommandEncoder, view: &TextureView)
Render the waveform into view using the previously uploaded
uniforms + samples. Loads existing contents (no clear) — meant
to draw on top of the warp pass output.
Sourcepub fn render_with_blend(
&self,
encoder: &mut CommandEncoder,
view: &TextureView,
is_dots: bool,
is_additive: bool,
)
pub fn render_with_blend( &self, encoder: &mut CommandEncoder, view: &TextureView, is_dots: bool, is_additive: bool, )
Same as Self::render but with explicit blend selection. Used
by the host to honour b_additive_waves without round-tripping a
flag through the uniforms.
Auto Trait Implementations§
impl Freeze for WaveformRenderer
impl !RefUnwindSafe for WaveformRenderer
impl Send for WaveformRenderer
impl Sync for WaveformRenderer
impl Unpin for WaveformRenderer
impl !UnwindSafe for WaveformRenderer
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