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/gpu/gpu.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/gpu/gpu.h') diff --git a/src/gpu/gpu.h b/src/gpu/gpu.h index 9a3fd38..d6c0255 100644 --- a/src/gpu/gpu.h +++ b/src/gpu/gpu.h @@ -97,4 +97,11 @@ RenderPass gpu_create_render_pass(WGPUDevice device, WGPUTextureFormat format, // Needed for render pipeline const char* shader_code, ResourceBinding* bindings, - int num_bindings); \ No newline at end of file + int num_bindings); + +// Common sampler configurations +WGPUSampler gpu_create_linear_sampler(WGPUDevice device); +WGPUSampler gpu_create_nearest_sampler(WGPUDevice device); + +// Dummy 1x1 texture for scene effects (don't need texture input) +TextureWithView gpu_create_dummy_scene_texture(WGPUDevice device); \ No newline at end of file -- cgit v1.2.3