diff options
| author | skal <pascal.massimino@gmail.com> | 2026-02-08 16:33:24 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-02-08 16:33:24 +0100 |
| commit | 775c0ea61faeaa8a09638d94b2399117f8b8cea3 (patch) | |
| tree | eebe2e59f3a8f50d97585bdbf334cebd15651e4d /log.txt | |
| parent | c7d1dd7ecb23d79cb00bc81ea8ec5ef61192f22a (diff) | |
fix(gpu): Correct FlashUniforms struct alignment for WGSL
Critical bugfix: Buffer size mismatch causing validation error
**Problem:**
Demo crashed with WebGPU validation error:
"Buffer is bound with size 24 where the shader expects 32"
**Root Cause:**
WGSL struct alignment rules:
- vec3<f32> has 16-byte alignment (not 12-byte)
- C++ struct was 24 bytes, WGSL expected 32 bytes
**Incorrect Layout (24 bytes):**
```cpp
struct FlashUniforms {
float flash_intensity; // 0-3
float intensity; // 4-7
float color[3]; // 8-19 (WRONG: no padding)
float _pad; // 20-23
};
```
**Correct Layout (32 bytes):**
```cpp
struct FlashUniforms {
float flash_intensity; // 0-3
float intensity; // 4-7
float _pad1[2]; // 8-15 (padding for vec3 alignment)
float color[3]; // 16-27 (vec3 aligned to 16 bytes)
float _pad2; // 28-31
};
```
**WGSL Alignment Rules:**
- vec3<f32> has size=12 bytes but alignment=16 bytes
- Must pad before vec3 to maintain 16-byte boundary
**Files Modified:**
- src/gpu/effects/flash_effect.h (struct layout + static_assert)
- src/gpu/effects/flash_effect.cc (field names: _pad → _pad1, _pad2)
**Verification:**
✅ Demo runs without validation errors
✅ All 32 tests pass (100%)
✅ static_assert enforces correct size at compile time
handoff(Claude): Critical alignment bug fixed, demo stable
Diffstat (limited to 'log.txt')
| -rw-r--r-- | log.txt | 23 |
1 files changed, 23 insertions, 0 deletions
@@ -0,0 +1,23 @@ + +thread '<unnamed>' (15208210) panicked at src/lib.rs:606:5: +Error in wgpuQueueSubmit: Validation Error + +Caused by: + In a draw command, kind: Draw + Buffer is bound with size 24 where the shader expects 32 in group[0] compact index 0 + +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace +fatal runtime error: failed to initiate panic, error 5, aborting +[GraphicsT=0.23, AudioT=0.13, Beat=0, Frac=0.26, Peak=1.00] +[SEQUENCE START] priority=0, start_time=0.00 + [EFFECT START] 15FlashCubeEffect (priority=-1, time=0.20-1.50) + [EFFECT START] 11FlashEffect (priority=0, time=0.00-1.00) + [EFFECT START] 10FadeEffect (priority=1, time=0.10-1.00) + [EFFECT START] 14SolarizeEffect (priority=2, time=0.00-2.00) +WebGPU Error: Validation Error + +Caused by: + In wgpuCommandEncoderFinish + In a draw command, kind: Draw + Buffer is bound with size 24 where the shader expects 32 in group[0] compact index 0 + |
