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 /doc/ANALYSIS_VARIABLE_TEMPO.md | |
| 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 'doc/ANALYSIS_VARIABLE_TEMPO.md')
0 files changed, 0 insertions, 0 deletions
