summaryrefslogtreecommitdiff
path: root/src/gpu/effects/circle_mask_effect.h
AgeCommit message (Collapse)Author
26 hoursfix: Complete auxiliary texture initialization fixskal
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 <noreply@anthropic.com>
26 hoursrefactor: Use lazy initialization for auxiliary texturesskal
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 <noreply@anthropic.com>
26 hoursfix: Resolve auxiliary texture resolution mismatch bugskal
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>
26 hoursrefactor: Simplify effect render API and fix uniform initializationskal
Root cause: Uniform buffers created but not initialized before bind group creation, causing undefined UV coordinates in circle_mask_compute.wgsl. Changes: - Add get_common_uniforms() helper to Effect base class - Refactor render()/compute() signatures: 5 params → CommonPostProcessUniforms& - Fix uninitialized uniforms in CircleMaskEffect and CNNEffect - Update all 19 effect implementations and headers - Fix WGSL syntax error in FlashEffect (u.audio_intensity → audio_intensity) - Update test files (test_sequence.cc) Benefits: - Cleaner API: construct uniforms once per frame, reuse across effects - More maintainable: CommonPostProcessUniforms changes need no call site updates - Fixes UV coordinate bug in circle_mask_compute.wgsl All 36 tests passing (100%) handoff(Claude): Effect API refactor complete
3 daysRefactor Effect class to centralize common uniforms managementskal
Moved to Effect base class. Updated all subclasses to use the base member, removing redundant declarations and initializations. Cleaned up by removing redundant class definitions and including specific headers. Fixed a typo in DistortEffect constructor.
3 daysfeat: WGSL Uniform Buffer Validation & Consolidation (Task #75)skal
- Added to validate WGSL/C++ struct alignment. - Integrated validation into . - Standardized uniform usage in , , , . - Renamed generic to specific names in WGSL and C++ to avoid collisions. - Added and updated . - handoff(Gemini): Completed Task #75.
3 daysfix: Resolve WebGPU uniform buffer alignment issues (Task #74)skal
Fixed critical validation errors caused by WGSL vec3<f32> alignment mismatches. Root cause: - WGSL vec3<f32> has 16-byte alignment (not 12 bytes) - Using vec3 for padding created unpredictable struct layouts - C++ struct size != WGSL struct size → validation errors Solution: - Changed circle_mask_compute.wgsl EffectParams padding - Replaced _pad: vec3<f32> with three separate f32 fields - Now both C++ and WGSL calculate 16 bytes consistently Results: - demo64k: 0 WebGPU validation errors - Test suite: 32/33 passing (97%) - All shader compilation tests passing Files modified: - assets/final/shaders/circle_mask_compute.wgsl - TODO.md (updated task status) - PROJECT_CONTEXT.md (updated test results) - HANDOFF_2026-02-09_UniformAlignment.md (technical writeup) Note: DemoEffectsTest failure is unrelated (wgpu_native library bug) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
4 daysfeat: Add CircleMaskEffect and RotatingCubeEffect with auxiliary texture maskingskal
Implements demonstration of auxiliary texture masking system with: - CircleMaskEffect: Generates circular mask, renders green outside circle - RotatingCubeEffect: Renders SDF cube inside circle using mask Architecture: - Mask generation in compute phase (1.0 inside, 0.0 outside) - CircleMask renders green where mask < 0.5 (outside circle) - RotatingCube samples mask and discards where mask < 0.5 Files added: - src/gpu/effects/circle_mask_effect.{h,cc} - src/gpu/effects/rotating_cube_effect.{h,cc} - assets/final/shaders/{circle_mask_compute,circle_mask_render,masked_cube}.wgsl Build system: - Updated CMakeLists.txt with new effect sources - Registered shaders in demo_assets.txt - Updated test_demo_effects.cc (8 scene effects total) Status: Effects temporarily disabled in demo.seq (lines 31-35) - ShaderComposer snippet registration needed for masked_cube.wgsl - All 33 tests pass, demo runs without crashes Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>