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/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/effect.cc')
| -rw-r--r-- | src/gpu/effect.cc | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/gpu/effect.cc b/src/gpu/effect.cc index 528d7fc..42e623a 100644 --- a/src/gpu/effect.cc +++ b/src/gpu/effect.cc @@ -508,6 +508,55 @@ WGPUTextureView MainSequence::get_auxiliary_view(const char* name) { return it->second.view; } +// Resize existing auxiliary texture +void MainSequence::resize_auxiliary_texture(const char* name, int width, + int height) { + const std::string key(name); + auto it = auxiliary_textures_.find(key); + FATAL_CHECK(it == auxiliary_textures_.end(), + "Auxiliary texture not found for resize: %s\n", name); + + // Release old resources + if (it->second.view) + wgpuTextureViewRelease(it->second.view); + if (it->second.texture) + wgpuTextureRelease(it->second.texture); + + // Create new texture with new dimensions + const WGPUTextureDescriptor desc = { + .usage = + WGPUTextureUsage_RenderAttachment | WGPUTextureUsage_TextureBinding, + .dimension = WGPUTextureDimension_2D, + .size = {(uint32_t)width, (uint32_t)height, 1}, + .format = gpu_ctx.format, + .mipLevelCount = 1, + .sampleCount = 1, + }; + + WGPUTexture texture = wgpuDeviceCreateTexture(gpu_ctx.device, &desc); + FATAL_CHECK(!texture, "Failed to resize auxiliary texture: %s\n", name); + + // Create view + const WGPUTextureViewDescriptor view_desc = { + .format = gpu_ctx.format, + .dimension = WGPUTextureViewDimension_2D, + .mipLevelCount = 1, + .arrayLayerCount = 1, + }; + + WGPUTextureView view = wgpuTextureCreateView(texture, &view_desc); + FATAL_CHECK(!view, "Failed to create resized auxiliary texture view: %s\n", + name); + + // Update registry + it->second = {texture, view, width, height}; + +#if !defined(STRIP_ALL) + printf("[MainSequence] Resized auxiliary texture '%s' to %dx%d\n", name, + width, height); +#endif /* !defined(STRIP_ALL) */ +} + #if !defined(STRIP_ALL) void MainSequence::simulate_until(float target_time, float step_rate, float bpm) { |
