summaryrefslogtreecommitdiff
path: root/src/gpu/effects/fade_effect.cc
diff options
context:
space:
mode:
authorskal <pascal.massimino@gmail.com>2026-02-11 11:34:08 +0100
committerskal <pascal.massimino@gmail.com>2026-02-11 11:34:08 +0100
commitd378da77eec4d506bc01e4c08c38644d72969cc7 (patch)
tree5cc38517320ba3aefb46a2f9c939c9fdc8ed5fae /src/gpu/effects/fade_effect.cc
parent4da0a3a5369142078fd7c681e3f0f1817bd6e2f3 (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/fade_effect.cc')
-rw-r--r--src/gpu/effects/fade_effect.cc21
1 files changed, 7 insertions, 14 deletions
diff --git a/src/gpu/effects/fade_effect.cc b/src/gpu/effects/fade_effect.cc
index 39b54e0..93684d8 100644
--- a/src/gpu/effects/fade_effect.cc
+++ b/src/gpu/effects/fade_effect.cc
@@ -72,26 +72,19 @@ void FadeEffect::update_bind_group(WGPUTextureView input_view) {
uniforms_.get(), params_buffer_);
}
-void FadeEffect::render(WGPURenderPassEncoder pass, float time, float beat,
- float intensity, float aspect_ratio) {
- const CommonPostProcessUniforms u = {
- .resolution = {(float)width_, (float)height_},
- .aspect_ratio = aspect_ratio,
- .time = time,
- .beat = beat,
- .audio_intensity = intensity,
- };
- uniforms_.update(ctx_.queue, u);
+void FadeEffect::render(WGPURenderPassEncoder pass,
+ const CommonPostProcessUniforms& uniforms) {
+ uniforms_.update(ctx_.queue, uniforms);
// Example fade pattern: fade in at start, fade out at end
// Customize this based on your needs
float fade_amount = 1.0f;
- if (time < 2.0f) {
+ if (uniforms.time < 2.0f) {
// Fade in from black over first 2 seconds
- fade_amount = time / 2.0f;
- } else if (time > 36.0f) {
+ fade_amount = uniforms.time / 2.0f;
+ } else if (uniforms.time > 36.0f) {
// Fade out to black after 36 seconds
- fade_amount = 1.0f - ((time - 36.0f) / 4.0f);
+ fade_amount = 1.0f - ((uniforms.time - 36.0f) / 4.0f);
fade_amount = fmaxf(fade_amount, 0.0f);
}