From c809790015b4ddc354c6b1993a633eddd042930f Mon Sep 17 00:00:00 2001 From: skal Date: Wed, 11 Feb 2026 11:46:53 +0100 Subject: refactor: Use lazy initialization for auxiliary textures Prevents init/resize ordering bug and avoids unnecessary reallocation. Changes: - Auxiliary textures created on first use (compute/update_bind_group) - Added ensure_texture() methods to defer registration until resize() - Added early return in resize() if dimensions unchanged - Removed texture registration from init() methods Benefits: - No reallocation on window resize if dimensions match - Texture created with correct dimensions from start - Memory saved if effect never renders Tests: All 36 tests passing Co-Authored-By: Claude Sonnet 4.5 --- src/gpu/effects/circle_mask_effect.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/gpu/effects/circle_mask_effect.h') diff --git a/src/gpu/effects/circle_mask_effect.h b/src/gpu/effects/circle_mask_effect.h index 6ebaca1..91443d8 100644 --- a/src/gpu/effects/circle_mask_effect.h +++ b/src/gpu/effects/circle_mask_effect.h @@ -29,8 +29,11 @@ class CircleMaskEffect : public Effect { static_assert(sizeof(CircleMaskParams) == 16, "CircleMaskParams must be 16 bytes for WGSL alignment"); + void ensure_texture(); + MainSequence* demo_ = nullptr; float radius_; + bool texture_initialized_ = false; WGPURenderPipeline compute_pipeline_ = nullptr; WGPUBindGroup compute_bind_group_ = nullptr; -- cgit v1.2.3