diff options
| author | skal <pascal.massimino@gmail.com> | 2026-02-14 12:40:57 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-02-14 12:40:57 +0100 |
| commit | 48beb6b1c10d7ca42205000a5bb420a1e3282d92 (patch) | |
| tree | 20cacc57d733b1e996b0d6d3df0719338d1a7a6b | |
| parent | c4cfc8459dbc6fde74d5553519dc3fcb1afccad0 (diff) | |
Fix: CNN v2 compute shader validation error
Replace textureSample() with textureSampleLevel() in compute shader.
textureSample() requires derivative calculations only available in fragment
shaders. Compute shaders must explicitly specify mip level.
Fixes: DemoEffectsTest CNNv2Effect initialization
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
| -rw-r--r-- | workspaces/main/shaders/cnn_v2/cnn_v2_static.wgsl | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/workspaces/main/shaders/cnn_v2/cnn_v2_static.wgsl b/workspaces/main/shaders/cnn_v2/cnn_v2_static.wgsl index 63fafa8..309e832 100644 --- a/workspaces/main/shaders/cnn_v2/cnn_v2_static.wgsl +++ b/workspaces/main/shaders/cnn_v2/cnn_v2_static.wgsl @@ -33,17 +33,18 @@ fn main(@builtin(global_invocation_id) id: vec3<u32>) { // Parametric features (p0-p3) - bilinear sample from specified mip level // Use UV coordinates for bilinear interpolation + // Note: Use textureSampleLevel (not textureSample) in compute shaders let uv = (vec2<f32>(coord) + 0.5) / vec2<f32>(dims); var rgba: vec4<f32>; if (params.mip_level == 0u) { - rgba = textureSample(input_tex, linear_sampler, uv); + rgba = textureSampleLevel(input_tex, linear_sampler, uv, 0.0); } else if (params.mip_level == 1u) { - rgba = textureSample(input_tex_mip1, linear_sampler, uv); + rgba = textureSampleLevel(input_tex_mip1, linear_sampler, uv, 0.0); } else if (params.mip_level == 2u) { - rgba = textureSample(input_tex_mip2, linear_sampler, uv); + rgba = textureSampleLevel(input_tex_mip2, linear_sampler, uv, 0.0); } else { // Mip 3 or higher: use mip 2 as fallback - rgba = textureSample(input_tex_mip2, linear_sampler, uv); + rgba = textureSampleLevel(input_tex_mip2, linear_sampler, uv, 0.0); } let p0 = rgba.r; |
