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/gaussian_blur.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/gaussian_blur.wgsl')
| -rw-r--r-- | assets/final/shaders/gaussian_blur.wgsl | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/assets/final/shaders/gaussian_blur.wgsl b/assets/final/shaders/gaussian_blur.wgsl index 39cbf54..3b87b10 100644 --- a/assets/final/shaders/gaussian_blur.wgsl +++ b/assets/final/shaders/gaussian_blur.wgsl @@ -3,6 +3,8 @@ struct CommonUniforms { resolution: vec2<f32>, + _pad0: f32, + _pad1: f32, aspect_ratio: f32, time: f32, beat: f32, @@ -13,7 +15,7 @@ struct EffectParams { _pad: f32, }; -@group(0) @binding(2) var<uniform> common: CommonUniforms; +@group(0) @binding(2) var<uniform> uniforms: CommonUniforms; @group(0) @binding(3) var<uniform> params: EffectParams; @vertex fn vs_main(@builtin(vertex_index) i: u32) -> @builtin(position) vec4<f32> { @@ -26,16 +28,16 @@ struct EffectParams { } @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; var res = vec4<f32>(0.0); // Parameterized strength + dramatic beat pulsation - let pulse = 0.5 + common.audio_intensity * 2.0; // Pulsate between 0.5x and 2.5x with beat + let pulse = 0.5 + uniforms.audio_intensity * 2.0; // Pulsate between 0.5x and 2.5x with beat let size = params.strength * pulse; for (var x: f32 = -2.0; x <= 2.0; x += 1.0) { for (var y: f32 = -2.0; y <= 2.0; y += 1.0) { - res += textureSample(txt, smplr, uv + vec2<f32>(x, y) * size / common.resolution.x); + res += textureSample(txt, smplr, uv + vec2<f32>(x, y) * size / uniforms.resolution.x); } } return res / 25.0; |
