From 76cec1b1fd533dda37aa53c40ef7665ed3b406b6 Mon Sep 17 00:00:00 2001 From: David Huculak Date: Sun, 3 Sep 2023 19:32:38 -0400 Subject: [PATCH 1/2] use @interpolate(flat) attribute as per the WebGPU spec: User-defined vertex outputs and fragment inputs of scalar or vector integer type must always be specified as @interpolate(flat) https://www.w3.org/TR/WGSL/#interpolation --- wgpu/src/shader/quad.wgsl | 22 +++++++++++----------- wgpu/src/shader/triangle.wgsl | 20 ++++++++++---------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/wgpu/src/shader/quad.wgsl b/wgpu/src/shader/quad.wgsl index fb402158c7..87055339f8 100644 --- a/wgpu/src/shader/quad.wgsl +++ b/wgpu/src/shader/quad.wgsl @@ -147,12 +147,12 @@ fn solid_fs_main( struct GradientVertexInput { @location(0) v_pos: vec2, - @location(1) colors_1: vec4, - @location(2) colors_2: vec4, - @location(3) colors_3: vec4, - @location(4) colors_4: vec4, - @location(5) offsets: vec4, - @location(6) direction: vec4, + @location(1) @interpolate(flat) colors_1: vec4, + @location(2) @interpolate(flat) colors_2: vec4, + @location(3) @interpolate(flat) colors_3: vec4, + @location(4) @interpolate(flat) colors_4: vec4, + @location(5) @interpolate(flat) offsets: vec4, + @location(6) @interpolate(flat) direction: vec4, @location(7) position_and_scale: vec4, @location(8) border_color: vec4, @location(9) border_radius: vec4, @@ -161,11 +161,11 @@ struct GradientVertexInput { struct GradientVertexOutput { @builtin(position) position: vec4, - @location(1) colors_1: vec4, - @location(2) colors_2: vec4, - @location(3) colors_3: vec4, - @location(4) colors_4: vec4, - @location(5) offsets: vec4, + @location(1) @interpolate(flat) colors_1: vec4, + @location(2) @interpolate(flat) colors_2: vec4, + @location(3) @interpolate(flat) colors_3: vec4, + @location(4) @interpolate(flat) colors_4: vec4, + @location(5) @interpolate(flat) offsets: vec4, @location(6) direction: vec4, @location(7) position_and_scale: vec4, @location(8) border_color: vec4, diff --git a/wgpu/src/shader/triangle.wgsl b/wgpu/src/shader/triangle.wgsl index 9f512d1489..3a2b984555 100644 --- a/wgpu/src/shader/triangle.wgsl +++ b/wgpu/src/shader/triangle.wgsl @@ -38,22 +38,22 @@ fn solid_fs_main(input: SolidVertexOutput) -> @location(0) vec4 { struct GradientVertexInput { @location(0) v_pos: vec2, - @location(1) colors_1: vec4, - @location(2) colors_2: vec4, - @location(3) colors_3: vec4, - @location(4) colors_4: vec4, - @location(5) offsets: vec4, + @location(1) @interpolate(flat) colors_1: vec4, + @location(2) @interpolate(flat) colors_2: vec4, + @location(3) @interpolate(flat) colors_3: vec4, + @location(4) @interpolate(flat) colors_4: vec4, + @location(5) @interpolate(flat) offsets: vec4, @location(6) direction: vec4, } struct GradientVertexOutput { @builtin(position) position: vec4, @location(0) raw_position: vec2, - @location(1) colors_1: vec4, - @location(2) colors_2: vec4, - @location(3) colors_3: vec4, - @location(4) colors_4: vec4, - @location(5) offsets: vec4, + @location(1) @interpolate(flat) colors_1: vec4, + @location(2) @interpolate(flat) colors_2: vec4, + @location(3) @interpolate(flat) colors_3: vec4, + @location(4) @interpolate(flat) colors_4: vec4, + @location(5) @interpolate(flat) offsets: vec4, @location(6) direction: vec4, } From 87800095e27353557adb39ef42ee6f82a0075bc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Thu, 7 Sep 2023 05:43:03 +0200 Subject: [PATCH 2/2] Remove unnecessary `interpolate(flat)` in `quad.wgsl` --- wgpu/src/shader/quad.wgsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wgpu/src/shader/quad.wgsl b/wgpu/src/shader/quad.wgsl index 87055339f8..023b5a6d1c 100644 --- a/wgpu/src/shader/quad.wgsl +++ b/wgpu/src/shader/quad.wgsl @@ -152,7 +152,7 @@ struct GradientVertexInput { @location(3) @interpolate(flat) colors_3: vec4, @location(4) @interpolate(flat) colors_4: vec4, @location(5) @interpolate(flat) offsets: vec4, - @location(6) @interpolate(flat) direction: vec4, + @location(6) direction: vec4, @location(7) position_and_scale: vec4, @location(8) border_color: vec4, @location(9) border_radius: vec4,