| Age | Commit message (Collapse) | Author |
|
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>
|
|
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>
|
|
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>
|
|
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
|
|
CircleMaskEffect was creating shader modules directly without using
ShaderComposer, causing #include directives to fail at runtime.
Changes:
- Add ShaderComposer.Compose() for compute and render shaders
- Include shader_composer.h header
Fixes demo64k crash on CircleMaskEffect initialization.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
|
|
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.
|
|
- 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.
|
|
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>
|
|
Resolves critical shader composition and format mismatch issues, enabling the
circle mask + rotating cube demonstration at 2.0s-4.0s in the timeline.
**Key Fixes:**
1. **Shader Function Name** (masked_cube.wgsl):
- Fixed call to `ray_box_intersection()` (was incorrectly `ray_box()`)
- Updated return value handling to use `RayBounds` struct (`.hit`, `.t_entry`, `.t_exit`)
- Removed unused `sky_tex` binding to match pipeline layout expectations (5 bindings → 4)
2. **Shader Lifetime Issue** (rotating_cube_effect.h/cc):
- Added `std::string composed_shader_` member to persist shader source
- Prevents use-after-free when WebGPU asynchronously parses shader code
3. **Format Mismatch** (circle_mask_effect.cc):
- Changed compute pipeline format from hardcoded `RGBA8Unorm` to `ctx_.format` (Bgra8UnormSrgb)
- Matches auxiliary texture format created by `MainSequence::register_auxiliary_texture()`
- Added depth stencil state to render pipeline to match scene pass requirements:
* Format: Depth24Plus
* depthWriteEnabled: False (no depth writes needed)
* depthCompare: Always (always pass depth test)
4. **WebGPU Descriptor Initialization** (circle_mask_effect.cc):
- Added `depthSlice = WGPU_DEPTH_SLICE_UNDEFINED` for non-Windows builds
- Ensures proper initialization of render pass color attachments
5. **Test Coverage** (test_demo_effects.cc):
- Updated EXPECTED_SCENE_COUNT: 6 → 8 (added CircleMaskEffect, RotatingCubeEffect)
- Marked both effects as requiring 3D pipeline setup (skipped in basic tests)
**Technical Details:**
- **Auxiliary Texture Flow**: CircleMaskEffect generates mask (1.0 inside, 0.0 outside) →
RotatingCubeEffect samples mask to render only inside circle → GaussianBlurEffect post-processes
- **Pipeline Format Matching**: All pipelines targeting same render pass must use matching formats:
* Color: Bgra8UnormSrgb (system framebuffer format)
* Depth: Depth24Plus (scene pass depth buffer)
- **ShaderComposer Integration**: Relies on `InitShaderComposer()` (called in `gpu.cc:372`)
registering snippets: `common_uniforms`, `math/sdf_utils`, `ray_box`, etc.
**Effect Behavior:**
- Runs from 2.0s to 4.0s in demo timeline
- CircleMaskEffect (priority 0): Draws green outside circle, transparent inside
- RotatingCubeEffect (priority 1): Renders bump-mapped cube inside circle
- GaussianBlurEffect (priority 2): Post-process blur on entire composition
**Test Results:**
- All 33 tests pass (100%)
- No WebGPU validation errors
- Demo runs cleanly with `--seek 2.0`
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
|
|
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>
|