From c148557cabf1fb9127b00b248479de2eb1d1d477 Mon Sep 17 00:00:00 2001 From: Cupnfish Date: Sat, 2 Jul 2022 15:39:42 +0800 Subject: update `wgpu` to `0.13` --- wgpu/src/shader/blit.wgsl | 16 ++++++++-------- wgpu/src/shader/image.wgsl | 30 ++++++++++++++--------------- wgpu/src/shader/quad.wgsl | 44 +++++++++++++++++++++---------------------- wgpu/src/shader/triangle.wgsl | 18 +++++++++--------- 4 files changed, 54 insertions(+), 54 deletions(-) (limited to 'wgpu/src/shader') diff --git a/wgpu/src/shader/blit.wgsl b/wgpu/src/shader/blit.wgsl index f8f6e2d4..5ff86f0a 100644 --- a/wgpu/src/shader/blit.wgsl +++ b/wgpu/src/shader/blit.wgsl @@ -16,19 +16,19 @@ var uvs: array, 6> = array, 6>( vec2(1.0, 1.0) ); -[[group(0), binding(0)]] var u_sampler: sampler; -[[group(1), binding(0)]] var u_texture: texture_2d; +@group(0) @binding(0) var u_sampler: sampler; +@group(1) @binding(0) var u_texture: texture_2d; struct VertexInput { - [[builtin(vertex_index)]] vertex_index: u32; + @builtin(vertex_index) vertex_index: u32, }; struct VertexOutput { - [[builtin(position)]] position: vec4; - [[location(0)]] uv: vec2; + @builtin(position) position: vec4, + @location(0) uv: vec2, }; -[[stage(vertex)]] +@vertex fn vs_main(input: VertexInput) -> VertexOutput { var out: VertexOutput; out.uv = uvs[input.vertex_index]; @@ -37,7 +37,7 @@ fn vs_main(input: VertexInput) -> VertexOutput { return out; } -[[stage(fragment)]] -fn fs_main(input: VertexOutput) -> [[location(0)]] vec4 { +@fragment +fn fs_main(input: VertexOutput) -> @location(0) vec4 { return textureSample(u_texture, u_sampler, input.uv); } diff --git a/wgpu/src/shader/image.wgsl b/wgpu/src/shader/image.wgsl index ff304422..bb1c6b9d 100644 --- a/wgpu/src/shader/image.wgsl +++ b/wgpu/src/shader/image.wgsl @@ -2,26 +2,26 @@ struct Globals { transform: mat4x4; }; -[[group(0), binding(0)]] var globals: Globals; -[[group(0), binding(1)]] var u_sampler: sampler; -[[group(1), binding(0)]] var u_texture: texture_2d_array; +@group(0) @binding(0) var globals: Globals; +@group(0) @binding(1) var u_sampler: sampler; +@group(1) @binding(0) var u_texture: texture_2d_array; struct VertexInput { - [[location(0)]] v_pos: vec2; - [[location(1)]] pos: vec2; - [[location(2)]] scale: vec2; - [[location(3)]] atlas_pos: vec2; - [[location(4)]] atlas_scale: vec2; - [[location(5)]] layer: i32; + @location(0) v_pos: vec2, + @location(1) pos: vec2, + @location(2) scale: vec2, + @location(3) atlas_pos: vec2, + @location(4) atlas_scale: vec2, + @location(5) layer: i32, }; struct VertexOutput { - [[builtin(position)]] position: vec4; - [[location(0)]] uv: vec2; - [[location(1)]] layer: f32; // this should be an i32, but naga currently reads that as requiring interpolation. + @builtin(position) position: vec4, + @location(0) uv: vec2, + @location(1) layer: f32, // this should be an i32, but naga currently reads that as requiring interpolation. }; -[[stage(vertex)]] +@vertex fn vs_main(input: VertexInput) -> VertexOutput { var out: VertexOutput; @@ -40,7 +40,7 @@ fn vs_main(input: VertexInput) -> VertexOutput { return out; } -[[stage(fragment)]] -fn fs_main(input: VertexOutput) -> [[location(0)]] vec4 { +@fragment +fn fs_main(input: VertexOutput) -> @location(0) vec4 { return textureSample(u_texture, u_sampler, input.uv, i32(input.layer)); } diff --git a/wgpu/src/shader/quad.wgsl b/wgpu/src/shader/quad.wgsl index 73f5d597..2e31cde3 100644 --- a/wgpu/src/shader/quad.wgsl +++ b/wgpu/src/shader/quad.wgsl @@ -1,31 +1,31 @@ struct Globals { - transform: mat4x4; - scale: f32; + transform: mat4x4, + scale: f32, }; -[[group(0), binding(0)]] var globals: Globals; +@group(0) @binding(0) var globals: Globals; struct VertexInput { - [[location(0)]] v_pos: vec2; - [[location(1)]] pos: vec2; - [[location(2)]] scale: vec2; - [[location(3)]] color: vec4; - [[location(4)]] border_color: vec4; - [[location(5)]] border_radius: f32; - [[location(6)]] border_width: f32; + @location(0) v_pos: vec2, + @location(1) pos: vec2, + @location(2) scale: vec2, + @location(3) color: vec4, + @location(4) border_color: vec4, + @location(5) border_radius: f32, + @location(6) border_width: f32, }; struct VertexOutput { - [[builtin(position)]] position: vec4; - [[location(0)]] color: vec4; - [[location(1)]] border_color: vec4; - [[location(2)]] pos: vec2; - [[location(3)]] scale: vec2; - [[location(4)]] border_radius: f32; - [[location(5)]] border_width: f32; + @builtin(position) position: vec4, + @location(0) color: vec4, + @location(1) border_color: vec4, + @location(2) pos: vec2, + @location(3) scale: vec2, + @location(4) border_radius: f32, + @location(5) border_width: f32, }; -[[stage(vertex)]] +@vertex fn vs_main(input: VertexInput) -> VertexOutput { var out: VertexOutput; @@ -77,10 +77,10 @@ fn distance_alg( } -[[stage(fragment)]] +@fragment fn fs_main( input: VertexOutput -) -> [[location(0)]] vec4 { +) -> @location(0) vec4 { var mixed_color: vec4 = input.color; if (input.border_width > 0.0) { @@ -96,7 +96,7 @@ fn fs_main( internal_border ); - var border_mix: f32 = smoothStep( + var border_mix: f32 = smoothstep( max(internal_border - 0.5, 0.0), internal_border + 0.5, internal_distance @@ -112,7 +112,7 @@ fn fs_main( input.border_radius ); - var radius_alpha: f32 = 1.0 - smoothStep( + var radius_alpha: f32 = 1.0 - smoothstep( max(input.border_radius - 0.5, 0.0), input.border_radius + 0.5, dist); diff --git a/wgpu/src/shader/triangle.wgsl b/wgpu/src/shader/triangle.wgsl index 61d9c5a4..4348cffd 100644 --- a/wgpu/src/shader/triangle.wgsl +++ b/wgpu/src/shader/triangle.wgsl @@ -1,20 +1,20 @@ struct Globals { - transform: mat4x4; + transform: mat4x4, }; -[[group(0), binding(0)]] var globals: Globals; +@group(0) @binding(0) var globals: Globals; struct VertexInput { - [[location(0)]] position: vec2; - [[location(1)]] color: vec4; + @location(0) position: vec2, + @location(1) color: vec4, }; struct VertexOutput { - [[builtin(position)]] position: vec4; - [[location(0)]] color: vec4; + @builtin(position) position: vec4, + @location(0) color: vec4, }; -[[stage(vertex)]] +@vertex fn vs_main(input: VertexInput) -> VertexOutput { var out: VertexOutput; @@ -24,7 +24,7 @@ fn vs_main(input: VertexInput) -> VertexOutput { return out; } -[[stage(fragment)]] -fn fs_main(input: VertexOutput) -> [[location(0)]] vec4 { +@fragment +fn fs_main(input: VertexOutput) -> @location(0) vec4 { return input.color; } -- cgit From a88155b2a28bfcbe39c7b87d7e9befb73a7dc8d7 Mon Sep 17 00:00:00 2001 From: Cupnfish Date: Sat, 2 Jul 2022 22:29:49 +0800 Subject: fix `wgsl` syntax --- wgpu/src/shader/image.wgsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'wgpu/src/shader') diff --git a/wgpu/src/shader/image.wgsl b/wgpu/src/shader/image.wgsl index bb1c6b9d..773ef90a 100644 --- a/wgpu/src/shader/image.wgsl +++ b/wgpu/src/shader/image.wgsl @@ -1,5 +1,5 @@ struct Globals { - transform: mat4x4; + transform: mat4x4, }; @group(0) @binding(0) var globals: Globals; -- cgit From 390e2a2d34d610dec057a3b6679b795e8c2a5c94 Mon Sep 17 00:00:00 2001 From: Cupnfish Date: Sat, 2 Jul 2022 22:51:51 +0800 Subject: better `wgsl` code style --- wgpu/src/shader/blit.wgsl | 4 ++-- wgpu/src/shader/image.wgsl | 6 +++--- wgpu/src/shader/quad.wgsl | 6 +++--- wgpu/src/shader/triangle.wgsl | 6 +++--- 4 files changed, 11 insertions(+), 11 deletions(-) (limited to 'wgpu/src/shader') diff --git a/wgpu/src/shader/blit.wgsl b/wgpu/src/shader/blit.wgsl index 5ff86f0a..c2ea223f 100644 --- a/wgpu/src/shader/blit.wgsl +++ b/wgpu/src/shader/blit.wgsl @@ -21,12 +21,12 @@ var uvs: array, 6> = array, 6>( struct VertexInput { @builtin(vertex_index) vertex_index: u32, -}; +} struct VertexOutput { @builtin(position) position: vec4, @location(0) uv: vec2, -}; +} @vertex fn vs_main(input: VertexInput) -> VertexOutput { diff --git a/wgpu/src/shader/image.wgsl b/wgpu/src/shader/image.wgsl index 773ef90a..5e22cdf4 100644 --- a/wgpu/src/shader/image.wgsl +++ b/wgpu/src/shader/image.wgsl @@ -1,6 +1,6 @@ struct Globals { transform: mat4x4, -}; +} @group(0) @binding(0) var globals: Globals; @group(0) @binding(1) var u_sampler: sampler; @@ -13,13 +13,13 @@ struct VertexInput { @location(3) atlas_pos: vec2, @location(4) atlas_scale: vec2, @location(5) layer: i32, -}; +} struct VertexOutput { @builtin(position) position: vec4, @location(0) uv: vec2, @location(1) layer: f32, // this should be an i32, but naga currently reads that as requiring interpolation. -}; +} @vertex fn vs_main(input: VertexInput) -> VertexOutput { diff --git a/wgpu/src/shader/quad.wgsl b/wgpu/src/shader/quad.wgsl index 2e31cde3..73edd97c 100644 --- a/wgpu/src/shader/quad.wgsl +++ b/wgpu/src/shader/quad.wgsl @@ -1,7 +1,7 @@ struct Globals { transform: mat4x4, scale: f32, -}; +} @group(0) @binding(0) var globals: Globals; @@ -13,7 +13,7 @@ struct VertexInput { @location(4) border_color: vec4, @location(5) border_radius: f32, @location(6) border_width: f32, -}; +} struct VertexOutput { @builtin(position) position: vec4, @@ -23,7 +23,7 @@ struct VertexOutput { @location(3) scale: vec2, @location(4) border_radius: f32, @location(5) border_width: f32, -}; +} @vertex fn vs_main(input: VertexInput) -> VertexOutput { diff --git a/wgpu/src/shader/triangle.wgsl b/wgpu/src/shader/triangle.wgsl index 4348cffd..b24402f8 100644 --- a/wgpu/src/shader/triangle.wgsl +++ b/wgpu/src/shader/triangle.wgsl @@ -1,18 +1,18 @@ struct Globals { transform: mat4x4, -}; +} @group(0) @binding(0) var globals: Globals; struct VertexInput { @location(0) position: vec2, @location(1) color: vec4, -}; +} struct VertexOutput { @builtin(position) position: vec4, @location(0) color: vec4, -}; +} @vertex fn vs_main(input: VertexInput) -> VertexOutput { -- cgit