From d378da77eec4d506bc01e4c08c38644d72969cc7 Mon Sep 17 00:00:00 2001 From: skal Date: Wed, 11 Feb 2026 11:34:08 +0100 Subject: refactor: Simplify effect render API and fix uniform initialization MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Root cause: Uniform buffers created but not initialized before bind group creation, causing undefined UV coordinates in circle_mask_compute.wgsl. Changes: - Add get_common_uniforms() helper to Effect base class - Refactor render()/compute() signatures: 5 params → CommonPostProcessUniforms& - Fix uninitialized uniforms in CircleMaskEffect and CNNEffect - Update all 19 effect implementations and headers - Fix WGSL syntax error in FlashEffect (u.audio_intensity → audio_intensity) - Update test files (test_sequence.cc) Benefits: - Cleaner API: construct uniforms once per frame, reuse across effects - More maintainable: CommonPostProcessUniforms changes need no call site updates - Fixes UV coordinate bug in circle_mask_compute.wgsl All 36 tests passing (100%) handoff(Claude): Effect API refactor complete --- src/gpu/effects/moving_ellipse_effect.cc | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'src/gpu/effects/moving_ellipse_effect.cc') diff --git a/src/gpu/effects/moving_ellipse_effect.cc b/src/gpu/effects/moving_ellipse_effect.cc index 9866f20..bbd3c08 100644 --- a/src/gpu/effects/moving_ellipse_effect.cc +++ b/src/gpu/effects/moving_ellipse_effect.cc @@ -13,17 +13,9 @@ MovingEllipseEffect::MovingEllipseEffect(const GpuContext& ctx) : Effect(ctx) { bindings, 1); pass_.vertex_count = 3; } -void MovingEllipseEffect::render(WGPURenderPassEncoder pass, float t, float b, - float i, float a) { - const CommonPostProcessUniforms u = { - .resolution = {(float)width_, (float)height_}, - ._pad = {0.0f, 0.0f}, - .aspect_ratio = a, - .time = t, - .beat = b, - .audio_intensity = i, - }; - uniforms_.update(ctx_.queue, u); +void MovingEllipseEffect::render(WGPURenderPassEncoder pass, + const CommonPostProcessUniforms& uniforms) { + uniforms_.update(ctx_.queue, uniforms); wgpuRenderPassEncoderSetPipeline(pass, pass_.pipeline); wgpuRenderPassEncoderSetBindGroup(pass, 0, pass_.bind_group, 0, nullptr); wgpuRenderPassEncoderDraw(pass, 3, 1, 0, 0); -- cgit v1.2.3