From b3eded8d56219fa19029a1b9bb7e7e7584f093d9 Mon Sep 17 00:00:00 2001 From: skal Date: Tue, 17 Feb 2026 12:35:59 +0100 Subject: refactor(effects): Factor shared initialization into Effect base class Eliminate ~100 lines of duplicated code across effect subclasses by moving common resource initialization to the base Effect class. Most effects repeatedly created uniforms buffers, samplers, and dummy textures with identical configurations. Changes: - Add shared members to Effect: uniforms_buffer_, sampler_, dummy_texture_* - Add helpers: init_uniforms_buffer(), create_*_sampler(), create_dummy_scene_texture() - Add gpu_create_*_sampler() and gpu_create_dummy_scene_texture() to gpu.h - Move HEADLESS_RETURN_IF_NULL to Effect constructor - Update 7 effects to use base class helpers (Flash, Heptagon, Passthrough, Placeholder, GaussianBlur, Particles, PeakMeter) Benefits: Improved consistency, easier maintenance, reduced binary size. Co-Authored-By: Claude Sonnet 4.5 --- src/effects/peak_meter_effect.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/effects/peak_meter_effect.cc') diff --git a/src/effects/peak_meter_effect.cc b/src/effects/peak_meter_effect.cc index d823e20..d077302 100644 --- a/src/effects/peak_meter_effect.cc +++ b/src/effects/peak_meter_effect.cc @@ -12,7 +12,7 @@ PeakMeter::PeakMeter(const GpuContext& ctx, : Effect(ctx, inputs, outputs, start_time, end_time), pipeline_(nullptr), bind_group_(nullptr) { HEADLESS_RETURN_IF_NULL(ctx_.device); - uniforms_buffer_.init(ctx_.device); + init_uniforms_buffer(); const char* shader_main = R"( struct VertexOutput { -- cgit v1.2.3