diff options
| author | skal <pascal.massimino@gmail.com> | 2026-02-09 09:49:51 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-02-09 09:49:51 +0100 |
| commit | df39c7e3efa70376fac579b178c803eb319d517f (patch) | |
| tree | 35ef2f2b1b0faa210186cd54c3796d4753aa8710 /assets/final/shaders/circle_mask_compute.wgsl | |
| parent | 538767bcf85c0d269b090434383f7499167af566 (diff) | |
fix: Resolve WebGPU uniform buffer alignment issues (Task #74)
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>
Diffstat (limited to 'assets/final/shaders/circle_mask_compute.wgsl')
| -rw-r--r-- | assets/final/shaders/circle_mask_compute.wgsl | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/assets/final/shaders/circle_mask_compute.wgsl b/assets/final/shaders/circle_mask_compute.wgsl index 9bb03ff..1ed6c1e 100644 --- a/assets/final/shaders/circle_mask_compute.wgsl +++ b/assets/final/shaders/circle_mask_compute.wgsl @@ -3,6 +3,8 @@ struct CommonUniforms { resolution: vec2<f32>, + _pad0: f32, + _pad1: f32, aspect_ratio: f32, time: f32, beat: f32, @@ -10,10 +12,12 @@ struct CommonUniforms { }; struct EffectParams { radius: f32, - _pad: vec3<f32>, + _pad0: f32, + _pad1: f32, + _pad2: f32, }; -@group(0) @binding(0) var<uniform> common: CommonUniforms; +@group(0) @binding(0) var<uniform> uniforms: CommonUniforms; @group(0) @binding(1) var<uniform> params: EffectParams; struct VSOutput { @@ -27,9 +31,9 @@ struct VSOutput { } @fragment fn fs_main(@builtin(position) p: vec4<f32>) -> @location(0) vec4<f32> { - let uv = p.xy / common.resolution; + let uv = p.xy / uniforms.resolution; let center = vec2<f32>(0.5, 0.5); - let aspect_corrected_uv = (uv - center) * vec2<f32>(common.aspect_ratio, 1.0); + let aspect_corrected_uv = (uv - center) * vec2<f32>(uniforms.aspect_ratio, 1.0); let dist = length(aspect_corrected_uv); let edge_width = 0.01; |
