diff options
| author | skal <pascal.massimino@gmail.com> | 2026-02-11 11:34:08 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-02-11 11:34:08 +0100 |
| commit | d378da77eec4d506bc01e4c08c38644d72969cc7 (patch) | |
| tree | 5cc38517320ba3aefb46a2f9c939c9fdc8ed5fae /src/gpu/effects/particles_effect.cc | |
| parent | 4da0a3a5369142078fd7c681e3f0f1817bd6e2f3 (diff) | |
refactor: Simplify effect render API and fix uniform initialization
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
Diffstat (limited to 'src/gpu/effects/particles_effect.cc')
| -rw-r--r-- | src/gpu/effects/particles_effect.cc | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/src/gpu/effects/particles_effect.cc b/src/gpu/effects/particles_effect.cc index cd0df74..f8c18f0 100644 --- a/src/gpu/effects/particles_effect.cc +++ b/src/gpu/effects/particles_effect.cc @@ -25,16 +25,9 @@ ParticlesEffect::ParticlesEffect(const GpuContext& ctx) : Effect(ctx) { render_pass_.vertex_count = 6; render_pass_.instance_count = NUM_PARTICLES; } -void ParticlesEffect::compute(WGPUCommandEncoder e, float t, float b, float i, - float a) { - const CommonPostProcessUniforms u = { - .resolution = {(float)width_, (float)height_}, - .aspect_ratio = a, - .time = t, - .beat = b, - .audio_intensity = i, - }; - uniforms_.update(ctx_.queue, u); +void ParticlesEffect::compute(WGPUCommandEncoder e, + const CommonPostProcessUniforms& uniforms) { + uniforms_.update(ctx_.queue, uniforms); WGPUComputePassEncoder pass = wgpuCommandEncoderBeginComputePass(e, nullptr); wgpuComputePassEncoderSetPipeline(pass, compute_pass_.pipeline); wgpuComputePassEncoderSetBindGroup(pass, 0, compute_pass_.bind_group, 0, @@ -43,8 +36,9 @@ void ParticlesEffect::compute(WGPUCommandEncoder e, float t, float b, float i, 1, 1); wgpuComputePassEncoderEnd(pass); } -void ParticlesEffect::render(WGPURenderPassEncoder pass, float t, float b, - float i, float a) { +void ParticlesEffect::render(WGPURenderPassEncoder pass, + const CommonPostProcessUniforms& uniforms) { + (void)uniforms; wgpuRenderPassEncoderSetPipeline(pass, render_pass_.pipeline); wgpuRenderPassEncoderSetBindGroup(pass, 0, render_pass_.bind_group, 0, nullptr); |
