From 5ceb0256792053ee80841f2b5ac0dfae1fd4c6f8 Mon Sep 17 00:00:00 2001 From: skal Date: Wed, 11 Feb 2026 11:58:24 +0100 Subject: fix: Complete auxiliary texture initialization fix Root cause: After swapping init/resize order, effects with Renderer3D crashed because resize() called before init() tried to use uninitialized GPU resources. Changes: - Add guards in FlashCubeEffect::resize() and Hybrid3DEffect::resize() to check ctx_.device before calling renderer_.resize() - Remove lazy initialization remnants from CircleMaskEffect and CNNEffect - Register auxiliary textures directly in init() (width_/height_ already set) - Remove ensure_texture() methods and texture_initialized_ flags All 36 tests passing. Demo runs without crashes. Co-Authored-By: Claude Sonnet 4.5 --- src/gpu/effects/circle_mask_effect.cc | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'src/gpu/effects/circle_mask_effect.cc') diff --git a/src/gpu/effects/circle_mask_effect.cc b/src/gpu/effects/circle_mask_effect.cc index 08a9e33..f34ffb7 100644 --- a/src/gpu/effects/circle_mask_effect.cc +++ b/src/gpu/effects/circle_mask_effect.cc @@ -26,6 +26,9 @@ CircleMaskEffect::~CircleMaskEffect() { void CircleMaskEffect::init(MainSequence* demo) { demo_ = demo; + // Register auxiliary texture (width_/height_ set by resize() before init()) + demo_->register_auxiliary_texture("circle_mask", width_, height_); + compute_params_.init(ctx_.device); // Initialize uniforms BEFORE bind group creation @@ -152,20 +155,13 @@ void CircleMaskEffect::init(MainSequence* demo) { render_bind_group_ = wgpuDeviceCreateBindGroup(ctx_.device, &render_bg_desc); } -void CircleMaskEffect::ensure_texture() { - if (!texture_initialized_ && demo_) { - demo_->register_auxiliary_texture("circle_mask", width_, height_); - texture_initialized_ = true; - } -} - void CircleMaskEffect::resize(int width, int height) { if (width == width_ && height == height_) return; Effect::resize(width, height); - if (!demo_ || !texture_initialized_) + if (!demo_) return; // Resize auxiliary texture @@ -193,8 +189,6 @@ void CircleMaskEffect::resize(int width, int height) { void CircleMaskEffect::compute(WGPUCommandEncoder encoder, const CommonPostProcessUniforms& uniforms) { - ensure_texture(); - uniforms_.update(ctx_.queue, uniforms); const CircleMaskParams params = { -- cgit v1.2.3