From c6aa7f1be2d52d9b12507fd0d5381513f5c0b9b6 Mon Sep 17 00:00:00 2001 From: skal Date: Thu, 12 Feb 2026 00:41:46 +0100 Subject: fix: PeakMeterEffect render() now properly overrides base class The custom render() signature didn't match PostProcessEffect::render(), so it was never called. The base class method was used instead, which didn't update uniforms with the peak value. Fixed by: - Using correct override signature: render(pass, uniforms) - Calling PostProcessEffect::render() to handle standard rendering - Removed unused custom parameters (time, beat, peak_value, aspect_ratio) - Added override keyword to update_bind_group() Peak meter bar now displays correctly with audio_intensity. Co-Authored-By: Claude Sonnet 4.5 --- src/test_demo.cc | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/src/test_demo.cc b/src/test_demo.cc index b564b9b..9cbeae2 100644 --- a/src/test_demo.cc +++ b/src/test_demo.cc @@ -86,30 +86,15 @@ class PeakMeterEffect : public PostProcessEffect { create_post_process_pipeline(ctx_.device, ctx_.format, shader_code.c_str()); } - void update_bind_group(WGPUTextureView input_view) { + void update_bind_group(WGPUTextureView input_view) override { pp_update_bind_group(ctx_.device, pipeline_, &bind_group_, input_view, uniforms_.get(), {}); } - void render(WGPURenderPassEncoder pass, float time, float beat, - float peak_value, float aspect_ratio) { - (void)time; - (void)beat; - - CommonPostProcessUniforms u = { - .resolution = {(float)width_, (float)height_}, - .aspect_ratio = aspect_ratio, - .time = time, - .beat_time = beat, - .beat_phase = beat, - .audio_intensity = peak_value, - ._pad = 0.0f, - }; - uniforms_.update(ctx_.queue, u); - - wgpuRenderPassEncoderSetPipeline(pass, pipeline_); - wgpuRenderPassEncoderSetBindGroup(pass, 0, bind_group_, 0, nullptr); - wgpuRenderPassEncoderDraw(pass, 3, 1, 0, 0); // Full-screen triangle + void render(WGPURenderPassEncoder pass, + const CommonPostProcessUniforms& uniforms) override { + uniforms_.update(ctx_.queue, uniforms); + PostProcessEffect::render(pass, uniforms); } }; -- cgit v1.2.3