diff options
| author | skal <pascal.massimino@gmail.com> | 2026-02-09 12:20:36 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-02-09 12:20:36 +0100 |
| commit | 9f470ce9c629b8756a3b1b8b9d30e8cf643dbcbd (patch) | |
| tree | da138cb6225c84f8a857d80f3249b8c9412ab307 | |
| parent | a09d43fcddf4b61b2bd7c2d4dc687fc8834a0a08 (diff) | |
try to fix test_demo
| -rw-r--r-- | TODO.md | 97 | ||||
| -rw-r--r-- | src/test_demo.cc | 8 |
2 files changed, 14 insertions, 91 deletions
@@ -6,6 +6,11 @@ This file tracks prioritized tasks with detailed attack plans. ## Recently Completed (February 9, 2026) +- [x] **Fix test_demo Black Screen**: + - **Issue**: `test_demo` showed black screen because it failed to load its timeline sequence (`assets/test_demo.seq`). + - **Fix**: Added missing `LoadTimeline` call in `src/test_demo.cc`. + - **Result**: `FlashEffect` and `PeakMeterEffect` should now render correctly. + - [x] **WGSL Uniform Buffer Validation & Consolidation (Task #75)**: - **Standardization**: Refactored `DistortEffect` and others to use `CommonPostProcessUniforms` (binding 2) + `EffectParams` (binding 3). - **Validation Tool**: Created `tools/validate_uniforms.py` to parse C++ and WGSL (including embedded strings) and verify size/alignment. @@ -29,93 +34,6 @@ This file tracks prioritized tasks with detailed attack plans. --- -## Priority 1: Uniform Buffer Alignment (Task #74) [COMPLETED - February 9, 2026] - -**Goal**: Fix WebGPU uniform buffer size/padding/alignment mismatches between C++ structs and WGSL shaders. - -**Root Cause**: WGSL `vec3<f32>` has 16-byte alignment (not 12), causing struct padding mismatches. Using `vec3<f32>` for padding fields created unpredictable struct sizes. - -**Fixes Applied**: -- `circle_mask_compute.wgsl`: Changed `_pad: vec3<f32>` to three separate `f32` fields - - Before: 24+ bytes in WGSL, 16 bytes in C++ - - After: 16 bytes in both -- Verified all shaders use individual `f32` fields for padding (no `vec3` in padding) - -**Results**: -- ✅ demo64k: Runs with **0 WebGPU validation errors** -- ✅ Test suite: **32/33 tests passing (97%)** -- ❌ DemoEffectsTest: SEGFAULT in wgpu_native library (unrelated to alignment fixes) - -**Key Lesson**: Never use `vec3<f32>` for padding in WGSL uniform structs. Always use individual `f32` fields to ensure predictable alignment. - ---- - -## Priority 1: WGSL Uniform Buffer Validation & Consolidation (Task #75) - -**Goal**: Prevent alignment bugs by consolidating uniform buffer patterns and creating automated validation. - -**Background**: Recent bugs (Task #74) revealed WGSL `vec3<f32>` alignment issues causing 16-byte padding where 12 bytes expected. Need systematic approach to prevent recurrence. - -**Attack Plan**: - -### Phase 1: Audit & Document (1-2 hours) -- [ ] **1.1**: Audit all WGSL shaders for uniform struct definitions - - List all uniform structs, their sizes, and padding strategies - - Identify inconsistencies (vec3 padding vs individual f32 fields) - - Document in `doc/UNIFORM_BUFFER_GUIDELINES.md` -- [ ] **1.2**: Audit C++ struct definitions (CommonPostProcessUniforms, etc.) - - Verify static_assert size checks exist for all uniform structs - - Check for missing size validation - -### Phase 2: Consolidation (2-3 hours) -- [ ] **2.1**: Standardize on CommonUniforms pattern - - All post-process effects should use CommonPostProcessUniforms for binding 2 - - Effect-specific params at binding 3 (16 or 32 bytes, properly padded) -- [ ] **2.2**: Eliminate `vec3<f32>` in padding fields - - Replace all `_pad: vec3<f32>` with `_pad0/1/2: f32` - - Apply to: FadeEffect, ThemeModulationEffect, any other effects -- [ ] **2.3**: Add C++ wrapper structs with static_assert - - Every WGSL uniform struct should have matching C++ struct - - All structs require `static_assert(sizeof(...) == EXPECTED_SIZE)` - -### Phase 3: Validation Tool (3-4 hours) -- [ ] **3.1**: Create `tools/validate_uniforms.py` - - Parse WGSL shader files for uniform struct definitions - - Calculate expected size using WGSL alignment rules: - - `f32`: 4-byte aligned - - `vec2<f32>`: 8-byte aligned - - `vec3<f32>`: **16-byte aligned** (not 12!) - - `vec4<f32>`: 16-byte aligned - - Struct size: rounded to largest member alignment -- [ ] **3.2**: Parse C++ headers for matching structs - - Extract `sizeof()` from static_assert statements - - Match WGSL struct names to C++ struct names -- [ ] **3.3**: Report mismatches - - Exit non-zero if C++ size != WGSL size - - Print detailed alignment breakdown for debugging -- [ ] **3.4**: Integrate into CI/build system - - Add CMake custom command to run validation - - Fail build if validation fails (development builds only) - - Add to `scripts/check_all.sh` - -### Phase 4: Documentation (1 hour) -- [ ] **4.1**: Write `doc/UNIFORM_BUFFER_GUIDELINES.md` - - Explain WGSL alignment rules (with examples) - - Document standard patterns (CommonUniforms, effect params) - - Show correct padding techniques - - Add examples of common mistakes -- [ ] **4.2**: Update CONTRIBUTING.md - - Add "Uniform Buffer Checklist" section - - Require validation tool passes before commit - -**Size Impact**: Negligible (consolidation may save 50-100 bytes) - -**Priority**: High (prevents entire class of subtle bugs) - -**Dependencies**: None - ---- - ## Priority 1: Spectral Brush Editor (Task #5) [IN PROGRESS] **Goal:** Create a web-based tool for procedurally tracing audio spectrograms. Replaces large `.spec` binary assets with tiny procedural C++ code (50-100× compression). @@ -189,13 +107,10 @@ This file tracks prioritized tasks with detailed attack plans. ## Priority 2: 3D System Enhancements (Task #18) **Goal:** Establish a pipeline for importing complex 3D scenes to replace hardcoded geometry. **Progress:** C++ pipeline for loading and processing object-specific data (like plane_distance) is now in place. Shader integration for SDFs is pending. - ## Priority 3: WGSL Modularization (Task #50) [RECURRENT] **Goal**: Refactor `ShaderComposer` and WGSL assets to support granular, reusable snippets and `#include` directives. This is an ongoing task to maintain shader code hygiene as new features are added. - - ## Phase 2: Size Optimization (Final Goal) - [ ] **Task #34: Full STL Removal**: Replace all remaining `std::vector`, `std::map`, and `std::string` usage with custom minimal containers or C-style arrays to allow for CRT replacement. (Minimal Priority - deferred to end). @@ -345,4 +260,4 @@ This file tracks prioritized tasks with detailed attack plans. --- -## Future Goals
\ No newline at end of file +## Future Goals diff --git a/src/test_demo.cc b/src/test_demo.cc index d116f85..749ef01 100644 --- a/src/test_demo.cc +++ b/src/test_demo.cc @@ -41,9 +41,14 @@ class PeakMeterEffect : public PostProcessEffect { audio_intensity: f32, }; + struct EffectParams { + unused: f32, + }; + @group(0) @binding(0) var inputSampler: sampler; @group(0) @binding(1) var inputTexture: texture_2d<f32>; @group(0) @binding(2) var<uniform> uniforms: Uniforms; + @group(0) @binding(3) var<uniform> params: EffectParams; @vertex fn vs_main(@builtin(vertex_index) vertexIndex: u32) -> VertexOutput { @@ -214,6 +219,9 @@ int main(int argc, char** argv) { platform_state = platform_init(fullscreen_enabled, width, height); gpu_init(&platform_state); + // Load timeline from test_demo.seq + LoadTimeline(*gpu_get_main_sequence(), *gpu_get_context()); + // Add peak meter visualization effect (renders as final post-process) #if !defined(STRIP_ALL) const GpuContext* gpu_ctx = gpu_get_context(); |
