diff options
| author | skal <pascal.massimino@gmail.com> | 2026-02-11 11:42:46 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-02-11 11:42:46 +0100 |
| commit | 5fb1bcc25fef7388a2d68be6c1f062bcf996fd85 (patch) | |
| tree | 47ccf3b23eb3f947f7cc3fb0dc5b4e504c95c2e3 /src/gpu/effects/circle_mask_effect.cc | |
| parent | d378da77eec4d506bc01e4c08c38644d72969cc7 (diff) | |
fix: Resolve auxiliary texture resolution mismatch bug
Auxiliary textures were created during init() using default dimensions
(1280x720) before resize() was called with actual window size. This
caused compute shaders to receive uniforms with correct resolution but
render to wrong-sized textures.
Changes:
- Add MainSequence::resize_auxiliary_texture() to recreate textures
- Override resize() in CircleMaskEffect to resize circle_mask texture
- Override resize() in CNNEffect to resize captured_frame texture
- Bind groups are recreated with new texture views after resize
Tests: All 36 tests passing
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Diffstat (limited to 'src/gpu/effects/circle_mask_effect.cc')
| -rw-r--r-- | src/gpu/effects/circle_mask_effect.cc | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/gpu/effects/circle_mask_effect.cc b/src/gpu/effects/circle_mask_effect.cc index d2645d6..aa9f324 100644 --- a/src/gpu/effects/circle_mask_effect.cc +++ b/src/gpu/effects/circle_mask_effect.cc @@ -157,6 +157,35 @@ void CircleMaskEffect::init(MainSequence* demo) { render_bind_group_ = wgpuDeviceCreateBindGroup(ctx_.device, &render_bg_desc); } +void CircleMaskEffect::resize(int width, int height) { + Effect::resize(width, height); + + if (!demo_) + return; + + // Resize auxiliary texture + demo_->resize_auxiliary_texture("circle_mask", width, height); + + // Recreate render bind group with new texture view + if (render_bind_group_) + wgpuBindGroupRelease(render_bind_group_); + + WGPUTextureView mask_view = demo_->get_auxiliary_view("circle_mask"); + const WGPUBindGroupEntry render_entries[] = { + {.binding = 0, .textureView = mask_view}, + {.binding = 1, .sampler = mask_sampler_}, + {.binding = 2, + .buffer = uniforms_.get().buffer, + .size = sizeof(CommonPostProcessUniforms)}, + }; + const WGPUBindGroupDescriptor render_bg_desc = { + .layout = wgpuRenderPipelineGetBindGroupLayout(render_pipeline_, 0), + .entryCount = 3, + .entries = render_entries, + }; + render_bind_group_ = wgpuDeviceCreateBindGroup(ctx_.device, &render_bg_desc); +} + void CircleMaskEffect::compute(WGPUCommandEncoder encoder, const CommonPostProcessUniforms& uniforms) { uniforms_.update(ctx_.queue, uniforms); |
