diff options
| author | skal <pascal.massimino@gmail.com> | 2026-02-17 13:05:11 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-02-17 13:05:11 +0100 |
| commit | bdb1a4e95a545f3f4d88630b8aec6ab771776d99 (patch) | |
| tree | 97a3a15381a7ff9780644ec8876535dd219f23cf /src/effects | |
| parent | a32c7456588abf4f44866d0c055fa94d105e8ef7 (diff) | |
refactor(effects): Streamline uniforms initialization
Centralized uniforms_buffer_ initialization and updates to Effect base class:
- init_uniforms_buffer() now automatic in Effect::Effect()
- uniforms_buffer_.update() now automatic in dispatch_render()
- Removed redundant calls from all effect subclasses
- Updated effect.h comments to reflect automatic behavior
- Updated EFFECT_WORKFLOW.md templates
Benefits:
- 16 lines removed from effect implementations
- Consistent pattern enforced at compile time
- Reduced boilerplate for new effects
Tests: 34/34 passing
handoff(Claude): Effect base class now handles uniforms automatically
Diffstat (limited to 'src/effects')
| -rw-r--r-- | src/effects/flash_effect.cc | 4 | ||||
| -rw-r--r-- | src/effects/gaussian_blur_effect.cc | 4 | ||||
| -rw-r--r-- | src/effects/heptagon_effect.cc | 4 | ||||
| -rw-r--r-- | src/effects/particles_effect.cc | 5 | ||||
| -rw-r--r-- | src/effects/passthrough_effect.cc | 4 | ||||
| -rw-r--r-- | src/effects/peak_meter_effect.cc | 3 | ||||
| -rw-r--r-- | src/effects/placeholder_effect.cc | 3 |
7 files changed, 1 insertions, 26 deletions
diff --git a/src/effects/flash_effect.cc b/src/effects/flash_effect.cc index 93ff4dd..7064e9c 100644 --- a/src/effects/flash_effect.cc +++ b/src/effects/flash_effect.cc @@ -12,7 +12,6 @@ Flash::Flash(const GpuContext& ctx, const std::vector<std::string>& inputs, : Effect(ctx, inputs, outputs, start_time, end_time) { HEADLESS_RETURN_IF_NULL(ctx_.device); - init_uniforms_buffer(); create_nearest_sampler(); create_dummy_scene_texture(); @@ -25,9 +24,6 @@ void Flash::render(WGPUCommandEncoder encoder, // Get output view (scene effects typically write to output, ignore input) WGPUTextureView output_view = nodes.get_view(output_nodes_[0]); - // Update uniforms - uniforms_buffer_.update(ctx_.queue, params); - // Update bind group (use dummy texture for scene effect) pp_update_bind_group(ctx_.device, pipeline_.get(), bind_group_.get_address(), dummy_texture_view_.get(), uniforms_buffer_.get(), diff --git a/src/effects/gaussian_blur_effect.cc b/src/effects/gaussian_blur_effect.cc index 0548b4a..a925dee 100644 --- a/src/effects/gaussian_blur_effect.cc +++ b/src/effects/gaussian_blur_effect.cc @@ -12,7 +12,6 @@ GaussianBlur::GaussianBlur(const GpuContext& ctx, : Effect(ctx, inputs, outputs, start_time, end_time), pipeline_(nullptr), bind_group_(nullptr) { HEADLESS_RETURN_IF_NULL(ctx_.device); - init_uniforms_buffer(); create_linear_sampler(); params_buffer_.init(ctx_.device); @@ -27,8 +26,7 @@ void GaussianBlur::render(WGPUCommandEncoder encoder, WGPUTextureView input_view = nodes.get_view(input_nodes_[0]); WGPUTextureView output_view = nodes.get_view(output_nodes_[0]); - // Update uniforms - uniforms_buffer_.update(ctx_.queue, params); + // Update effect-specific params params_buffer_.update(ctx_.queue, blur_params_); // Update bind group diff --git a/src/effects/heptagon_effect.cc b/src/effects/heptagon_effect.cc index c9ec17c..c02efb3 100644 --- a/src/effects/heptagon_effect.cc +++ b/src/effects/heptagon_effect.cc @@ -13,7 +13,6 @@ Heptagon::Heptagon(const GpuContext& ctx, : Effect(ctx, inputs, outputs, start_time, end_time) { HEADLESS_RETURN_IF_NULL(ctx_.device); - init_uniforms_buffer(); create_nearest_sampler(); create_dummy_scene_texture(); @@ -27,9 +26,6 @@ void Heptagon::render(WGPUCommandEncoder encoder, // Get output view (scene effects typically write to output, ignore input) WGPUTextureView output_view = nodes.get_view(output_nodes_[0]); - // Update uniforms - uniforms_buffer_.update(ctx_.queue, params); - // Create bind group (use dummy texture for scene effect) pp_update_bind_group(ctx_.device, pipeline_.get(), bind_group_.get_address(), dummy_texture_view_.get(), uniforms_buffer_.get(), diff --git a/src/effects/particles_effect.cc b/src/effects/particles_effect.cc index 3c9feb7..d0336f6 100644 --- a/src/effects/particles_effect.cc +++ b/src/effects/particles_effect.cc @@ -14,8 +14,6 @@ Particles::Particles(const GpuContext& ctx, : Effect(ctx, inputs, outputs, start_time, end_time) { HEADLESS_RETURN_IF_NULL(ctx_.device); - init_uniforms_buffer(); - // Initialize particles buffer std::vector<Particle> init_p(NUM_PARTICLES); for (int i = 0; i < NUM_PARTICLES; ++i) { @@ -66,9 +64,6 @@ Particles::Particles(const GpuContext& ctx, void Particles::render(WGPUCommandEncoder encoder, const UniformsSequenceParams& params, NodeRegistry& nodes) { - // Update uniforms - uniforms_buffer_.update(ctx_.queue, params); - // Run compute pass (particle simulation) WGPUComputePassEncoder compute = wgpuCommandEncoderBeginComputePass(encoder, nullptr); diff --git a/src/effects/passthrough_effect.cc b/src/effects/passthrough_effect.cc index 24eefca..217b5d2 100644 --- a/src/effects/passthrough_effect.cc +++ b/src/effects/passthrough_effect.cc @@ -12,7 +12,6 @@ Passthrough::Passthrough(const GpuContext& ctx, : Effect(ctx, inputs, outputs, start_time, end_time) { HEADLESS_RETURN_IF_NULL(ctx_.device); - init_uniforms_buffer(); create_linear_sampler(); pipeline_.set(create_post_process_pipeline_simple( @@ -26,9 +25,6 @@ void Passthrough::render(WGPUCommandEncoder encoder, WGPUTextureView input_view = nodes.get_view(input_nodes_[0]); WGPUTextureView output_view = nodes.get_view(output_nodes_[0]); - // Update uniforms - uniforms_buffer_.update(ctx_.queue, params); - // Manually create bind group with only 3 entries (no effect params needed) WGPUBindGroupEntry entries[3] = {}; entries[0].binding = PP_BINDING_SAMPLER; diff --git a/src/effects/peak_meter_effect.cc b/src/effects/peak_meter_effect.cc index d077302..27adba4 100644 --- a/src/effects/peak_meter_effect.cc +++ b/src/effects/peak_meter_effect.cc @@ -12,8 +12,6 @@ PeakMeter::PeakMeter(const GpuContext& ctx, : Effect(ctx, inputs, outputs, start_time, end_time), pipeline_(nullptr), bind_group_(nullptr) { HEADLESS_RETURN_IF_NULL(ctx_.device); - init_uniforms_buffer(); - const char* shader_main = R"( struct VertexOutput { @builtin(position) position: vec4<f32>, @@ -76,7 +74,6 @@ void PeakMeter::render(WGPUCommandEncoder encoder, WGPUTextureView input_view = nodes.get_view(input_nodes_[0]); WGPUTextureView output_view = nodes.get_view(output_nodes_[0]); - uniforms_buffer_.update(ctx_.queue, params); pp_update_bind_group(ctx_.device, pipeline_, &bind_group_, input_view, uniforms_buffer_.get(), {nullptr, 0}); diff --git a/src/effects/placeholder_effect.cc b/src/effects/placeholder_effect.cc index e024a6b..beb5f33 100644 --- a/src/effects/placeholder_effect.cc +++ b/src/effects/placeholder_effect.cc @@ -17,7 +17,6 @@ Placeholder::Placeholder(const GpuContext& ctx, HEADLESS_RETURN_IF_NULL(ctx_.device); - init_uniforms_buffer(); create_linear_sampler(); pipeline_ = create_post_process_pipeline( @@ -30,8 +29,6 @@ void Placeholder::render(WGPUCommandEncoder encoder, WGPUTextureView input_view = nodes.get_view(input_nodes_[0]); WGPUTextureView output_view = nodes.get_view(output_nodes_[0]); - uniforms_buffer_.update(ctx_.queue, params); - pp_update_bind_group(ctx_.device, pipeline_, &bind_group_, input_view, uniforms_buffer_.get(), {nullptr, 0}); |
