diff --git a/CHANGELOG.md b/CHANGELOG.md index df475b0c14..3406481f31 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## v0.9 (TBD) - WGSL: + - commas are used to separate struct members intead of semicolons - attributes are declared with `@attrib` instead of `[[attrib]]` - `stride` attribute is removed - block comments are supported diff --git a/src/back/wgsl/writer.rs b/src/back/wgsl/writer.rs index 2d4b0150bf..9315e63757 100644 --- a/src/back/wgsl/writer.rs +++ b/src/back/wgsl/writer.rs @@ -419,7 +419,7 @@ impl Writer { let member_name = &self.names[&NameKey::StructMember(handle, index as u32)]; write!(self.out, "{}: ", member_name)?; self.write_type(module, member.ty)?; - write!(self.out, ";")?; + write!(self.out, ",")?; writeln!(self.out)?; } diff --git a/src/front/wgsl/mod.rs b/src/front/wgsl/mod.rs index 2271a915d2..3f2348b98b 100644 --- a/src/front/wgsl/mod.rs +++ b/src/front/wgsl/mod.rs @@ -2811,7 +2811,14 @@ impl Parser { let mut members = Vec::new(); lexer.expect(Token::Paren('{'))?; - loop { + let mut ready = true; + while !lexer.skip(Token::Paren('}')) { + if !ready { + return Err(Error::Unexpected( + lexer.next(), + ExpectedToken::Token(Token::Separator(',')), + )); + } let (mut size, mut align) = (None, None); self.push_scope(Scope::Attribute, lexer); let mut bind_parser = BindingParser::default(); @@ -2838,10 +2845,6 @@ impl Parser { let bind_span = self.pop_scope(lexer); let (name, span) = match lexer.next() { (Token::Word(word), span) => (word, span), - (Token::Paren('}'), _) => { - let span = Layouter::round_up(alignment, offset); - return Ok((members, span)); - } other => return Err(Error::Unexpected(other, ExpectedToken::FieldName)), }; if crate::keywords::wgsl::RESERVED.contains(&name) { @@ -2849,7 +2852,7 @@ impl Parser { } lexer.expect(Token::Separator(':'))?; let (ty, _access) = self.parse_type_decl(lexer, None, type_arena, const_arena)?; - lexer.expect(Token::Separator(';'))?; + ready = lexer.skip(Token::Separator(',')); self.layouter.update(type_arena, const_arena).unwrap(); @@ -2868,6 +2871,9 @@ impl Parser { offset: range.start, }); } + + let span = Layouter::round_up(alignment, offset); + Ok((members, span)) } fn parse_type_decl_impl<'a>( diff --git a/src/front/wgsl/tests.rs b/src/front/wgsl/tests.rs index a439eff4b9..906311248f 100644 --- a/src/front/wgsl/tests.rs +++ b/src/front/wgsl/tests.rs @@ -157,11 +157,11 @@ fn parse_type_cast() { fn parse_struct() { parse_str( " - struct Foo { x: i32; }; + struct Foo { x: i32 }; struct Bar { - @size(16) x: vec2; - @align(16) y: f32; - @size(32) @align(8) z: vec3; + @size(16) x: vec2, + @align(16) y: f32, + @size(32) @align(8) z: vec3, }; struct Empty {}; var s: Foo; @@ -415,8 +415,8 @@ fn parse_struct_instantiation() { parse_str( " struct Foo { - a: f32; - b: vec3; + a: f32, + b: vec3, }; @stage(fragment) @@ -433,7 +433,7 @@ fn parse_array_length() { parse_str( " struct Foo { - data: array; + data: array }; // this is used as both input and output for convenience @group(0) @binding(0) diff --git a/tests/in/access.wgsl b/tests/in/access.wgsl index d68a74ca0e..390a018b11 100644 --- a/tests/in/access.wgsl +++ b/tests/in/access.wgsl @@ -1,15 +1,15 @@ // This snapshot tests accessing various containers, dereferencing pointers. struct AlignedWrapper { - @align(8) value: i32; + @align(8) value: i32 }; struct Bar { - matrix: mat4x4; - matrix_array: array, 2>; - atom: atomic; - arr: array, 2>; - data: array; + matrix: mat4x4, + matrix_array: array, 2>, + atom: atomic, + arr: array, 2>, + data: array, }; @group(0) @binding(0) diff --git a/tests/in/boids.wgsl b/tests/in/boids.wgsl index c3106f1c64..2655f2783a 100644 --- a/tests/in/boids.wgsl +++ b/tests/in/boids.wgsl @@ -1,22 +1,22 @@ let NUM_PARTICLES: u32 = 1500u; struct Particle { - pos : vec2; - vel : vec2; + pos : vec2, + vel : vec2, }; struct SimParams { - deltaT : f32; - rule1Distance : f32; - rule2Distance : f32; - rule3Distance : f32; - rule1Scale : f32; - rule2Scale : f32; - rule3Scale : f32; + deltaT : f32, + rule1Distance : f32, + rule2Distance : f32, + rule3Distance : f32, + rule1Scale : f32, + rule2Scale : f32, + rule3Scale : f32, }; struct Particles { - particles : array; + particles : array }; @group(0) @binding(0) var params : SimParams; diff --git a/tests/in/bounds-check-restrict.wgsl b/tests/in/bounds-check-restrict.wgsl index fefcdec0cd..d88be39fb4 100644 --- a/tests/in/bounds-check-restrict.wgsl +++ b/tests/in/bounds-check-restrict.wgsl @@ -1,10 +1,10 @@ // Tests for `naga::back::BoundsCheckPolicy::Restrict`. struct Globals { - a: array; - v: vec4; - m: mat3x4; - d: array; + a: array, + v: vec4, + m: mat3x4, + d: array, }; @group(0) @binding(0) var globals: Globals; diff --git a/tests/in/bounds-check-zero-atomic.wgsl b/tests/in/bounds-check-zero-atomic.wgsl index ad4012dbf1..c64cc8bd0a 100644 --- a/tests/in/bounds-check-zero-atomic.wgsl +++ b/tests/in/bounds-check-zero-atomic.wgsl @@ -5,9 +5,9 @@ // be combined. struct Globals { - a: atomic; - b: array, 10>; - c: array>; + a: atomic, + b: array, 10>, + c: array>, }; @group(0) @binding(0) var globals: Globals; diff --git a/tests/in/bounds-check-zero.wgsl b/tests/in/bounds-check-zero.wgsl index e1a05ac927..1dbfd9cb5e 100644 --- a/tests/in/bounds-check-zero.wgsl +++ b/tests/in/bounds-check-zero.wgsl @@ -1,10 +1,10 @@ // Tests for `naga::back::BoundsCheckPolicy::ReadZeroSkipWrite`. struct Globals { - a: array; - v: vec4; - m: mat3x4; - d: array; + a: array, + v: vec4, + m: mat3x4, + d: array, }; @group(0) @binding(0) var globals: Globals; diff --git a/tests/in/collatz.wgsl b/tests/in/collatz.wgsl index 7e2b135434..15a9d46056 100644 --- a/tests/in/collatz.wgsl +++ b/tests/in/collatz.wgsl @@ -1,5 +1,5 @@ struct PrimeIndices { - data: array; + data: array }; // this is used as both input and output for convenience @group(0) @binding(0) diff --git a/tests/in/extra.wgsl b/tests/in/extra.wgsl index e8a858cc19..6dcecd5535 100644 --- a/tests/in/extra.wgsl +++ b/tests/in/extra.wgsl @@ -1,12 +1,12 @@ struct PushConstants { - index: u32; - double: vec2; + index: u32, + double: vec2, }; var pc: PushConstants; struct FragmentIn { - @location(0) color: vec4; - @builtin(primitive_index) primitive_index: u32; + @location(0) color: vec4, + @builtin(primitive_index) primitive_index: u32, }; @stage(fragment) diff --git a/tests/in/globals.wgsl b/tests/in/globals.wgsl index 7e5b725016..ed8c40a70d 100644 --- a/tests/in/globals.wgsl +++ b/tests/in/globals.wgsl @@ -6,9 +6,9 @@ var wg : array; var at: atomic; struct Foo { - v3: vec3; + v3: vec3, // test packed vec3 - v1: f32; + v1: f32, }; @group(0) @binding(1) var alignment: Foo; diff --git a/tests/in/interface.wgsl b/tests/in/interface.wgsl index 7375295521..d2cf84023c 100644 --- a/tests/in/interface.wgsl +++ b/tests/in/interface.wgsl @@ -1,8 +1,8 @@ // Testing various parts of the pipeline interface: locations, built-ins, and entry points struct VertexOutput { - @builtin(position) position: vec4; - @location(1) varying: f32; + @builtin(position) position: vec4, + @location(1) varying: f32, }; @stage(vertex) @@ -16,9 +16,9 @@ fn vertex( } struct FragmentOutput { - @builtin(frag_depth) depth: f32; - @builtin(sample_mask) sample_mask: u32; - @location(0) color: f32; + @builtin(frag_depth) depth: f32, + @builtin(sample_mask) sample_mask: u32, + @location(0) color: f32, }; @stage(fragment) @@ -47,11 +47,11 @@ fn compute( } struct Input1 { - @builtin(vertex_index) index: u32; + @builtin(vertex_index) index: u32, }; struct Input2 { - @builtin(instance_index) index: u32; + @builtin(instance_index) index: u32, }; @stage(vertex) diff --git a/tests/in/interpolate.wgsl b/tests/in/interpolate.wgsl index a3dea61e50..1cb7239458 100644 --- a/tests/in/interpolate.wgsl +++ b/tests/in/interpolate.wgsl @@ -1,14 +1,14 @@ //TODO: merge with "interface"? struct FragmentInput { - @builtin(position) position: vec4; - @location(0) @interpolate(flat) flat : u32; - @location(1) @interpolate(linear) linear : f32; - @location(2) @interpolate(linear, centroid) linear_centroid : vec2; - @location(3) @interpolate(linear, sample) linear_sample : vec3; - @location(4) @interpolate(perspective) perspective : vec4; - @location(5) @interpolate(perspective, centroid) perspective_centroid : f32; - @location(6) @interpolate(perspective, sample) perspective_sample : f32; + @builtin(position) position: vec4, + @location(0) @interpolate(flat) flat : u32, + @location(1) @interpolate(linear) linear : f32, + @location(2) @interpolate(linear, centroid) linear_centroid : vec2, + @location(3) @interpolate(linear, sample) linear_sample : vec3, + @location(4) @interpolate(perspective) perspective : vec4, + @location(5) @interpolate(perspective, centroid) perspective_centroid : f32, + @location(6) @interpolate(perspective, sample) perspective_sample : f32, }; @stage(vertex) diff --git a/tests/in/operators.wgsl b/tests/in/operators.wgsl index 9d472294f1..23dbf734c2 100644 --- a/tests/in/operators.wgsl +++ b/tests/in/operators.wgsl @@ -39,8 +39,8 @@ fn bool_cast(x: vec3) -> vec3 { } struct Foo { - a: vec4; - b: i32; + a: vec4, + b: i32, }; fn constructors() -> f32 { diff --git a/tests/in/pointers.wgsl b/tests/in/pointers.wgsl index 6eddb77953..cf07d5dbf1 100644 --- a/tests/in/pointers.wgsl +++ b/tests/in/pointers.wgsl @@ -5,7 +5,7 @@ fn f() { } struct DynamicArray { - arr: array; + arr: array }; @group(0) @binding(0) diff --git a/tests/in/policy-mix.wgsl b/tests/in/policy-mix.wgsl index fe05a3232a..a29556a5b3 100644 --- a/tests/in/policy-mix.wgsl +++ b/tests/in/policy-mix.wgsl @@ -3,12 +3,12 @@ // Storage and Uniform storage classes struct InStorage { - a: array, 10>; + a: array, 10> }; @group(0) @binding(0) var in_storage: InStorage; struct InUniform { - a: array, 20>; + a: array, 20> }; @group(0) @binding(1) var in_uniform: InUniform; diff --git a/tests/in/push-constants.wgsl b/tests/in/push-constants.wgsl index d5b4cf99dd..4a55ed20a8 100644 --- a/tests/in/push-constants.wgsl +++ b/tests/in/push-constants.wgsl @@ -1,10 +1,10 @@ struct PushConstants { - multiplier: f32; + multiplier: f32 }; var pc: PushConstants; struct FragmentIn { - @location(0) color: vec4; + @location(0) color: vec4 }; @stage(fragment) diff --git a/tests/in/quad.wgsl b/tests/in/quad.wgsl index 847de8630f..37b543397b 100644 --- a/tests/in/quad.wgsl +++ b/tests/in/quad.wgsl @@ -2,8 +2,8 @@ let c_scale: f32 = 1.2; struct VertexOutput { - @location(0) uv : vec2; - @builtin(position) position : vec4; + @location(0) uv : vec2, + @builtin(position) position : vec4, }; @stage(vertex) diff --git a/tests/in/shadow.wgsl b/tests/in/shadow.wgsl index 0b64b2f8d0..37e17877c9 100644 --- a/tests/in/shadow.wgsl +++ b/tests/in/shadow.wgsl @@ -1,6 +1,6 @@ struct Globals { - view_proj: mat4x4; - num_lights: vec4; + view_proj: mat4x4, + num_lights: vec4, }; @group(0) @@ -8,8 +8,8 @@ struct Globals { var u_globals: Globals; struct Entity { - world: mat4x4; - color: vec4; + world: mat4x4, + color: vec4, }; @group(1) @@ -24,9 +24,9 @@ fn vs_bake(@location(0) position: vec4) -> @builtin(position) vec4 { */ struct VertexOutput { - @builtin(position) proj_position: vec4; - @location(0) world_normal: vec3; - @location(1) world_position: vec4; + @builtin(position) proj_position: vec4, + @location(0) world_normal: vec3, + @location(1) world_position: vec4, }; @stage(vertex) @@ -46,9 +46,9 @@ fn vs_main( // fragment shader struct Light { - proj: mat4x4; - pos: vec4; - color: vec4; + proj: mat4x4, + pos: vec4, + color: vec4, }; @group(0) diff --git a/tests/in/skybox.wgsl b/tests/in/skybox.wgsl index afbc38718e..06e5a07aa0 100644 --- a/tests/in/skybox.wgsl +++ b/tests/in/skybox.wgsl @@ -1,11 +1,11 @@ struct VertexOutput { - @builtin(position) position: vec4; - @location(0) uv: vec3; + @builtin(position) position: vec4, + @location(0) uv: vec3, }; struct Data { - proj_inv: mat4x4; - view: mat4x4; + proj_inv: mat4x4, + view: mat4x4, }; @group(0) @binding(0) var r_data: Data; diff --git a/tests/out/wgsl/210-bevy-2d-shader-frag.wgsl b/tests/out/wgsl/210-bevy-2d-shader-frag.wgsl index cfb3ce6ce0..3c7aaf1d14 100644 --- a/tests/out/wgsl/210-bevy-2d-shader-frag.wgsl +++ b/tests/out/wgsl/210-bevy-2d-shader-frag.wgsl @@ -1,9 +1,9 @@ struct ColorMaterial_color { - Color: vec4; + Color: vec4, }; struct FragmentOutput { - @location(0) o_Target: vec4; + @location(0) o_Target: vec4, }; var v_Uv_1: vec2; diff --git a/tests/out/wgsl/210-bevy-2d-shader-vert.wgsl b/tests/out/wgsl/210-bevy-2d-shader-vert.wgsl index 18a6630f8d..b6e70957cb 100644 --- a/tests/out/wgsl/210-bevy-2d-shader-vert.wgsl +++ b/tests/out/wgsl/210-bevy-2d-shader-vert.wgsl @@ -1,18 +1,18 @@ struct Camera { - ViewProj: mat4x4; + ViewProj: mat4x4, }; struct Transform { - Model: mat4x4; + Model: mat4x4, }; struct Sprite_size { - size: vec2; + size: vec2, }; struct VertexOutput { - @location(0) v_Uv: vec2; - @builtin(position) member: vec4; + @location(0) v_Uv: vec2, + @builtin(position) member: vec4, }; var Vertex_Position_1: vec3; diff --git a/tests/out/wgsl/210-bevy-shader-vert.wgsl b/tests/out/wgsl/210-bevy-shader-vert.wgsl index a2ac6ba10c..d7a177cb3c 100644 --- a/tests/out/wgsl/210-bevy-shader-vert.wgsl +++ b/tests/out/wgsl/210-bevy-shader-vert.wgsl @@ -1,16 +1,16 @@ struct Camera { - ViewProj: mat4x4; + ViewProj: mat4x4, }; struct Transform { - Model: mat4x4; + Model: mat4x4, }; struct VertexOutput { - @location(0) v_Position: vec3; - @location(1) v_Normal: vec3; - @location(2) v_Uv: vec2; - @builtin(position) member: vec4; + @location(0) v_Position: vec3, + @location(1) v_Normal: vec3, + @location(2) v_Uv: vec2, + @builtin(position) member: vec4, }; var Vertex_Position_1: vec3; diff --git a/tests/out/wgsl/246-collatz-comp.wgsl b/tests/out/wgsl/246-collatz-comp.wgsl index a990dd31ba..994c028d12 100644 --- a/tests/out/wgsl/246-collatz-comp.wgsl +++ b/tests/out/wgsl/246-collatz-comp.wgsl @@ -1,5 +1,5 @@ struct PrimeIndices { - indices: array; + indices: array, }; @group(0) @binding(0) diff --git a/tests/out/wgsl/800-out-of-bounds-panic-vert.wgsl b/tests/out/wgsl/800-out-of-bounds-panic-vert.wgsl index b57fa3e0b4..a3aca90828 100644 --- a/tests/out/wgsl/800-out-of-bounds-panic-vert.wgsl +++ b/tests/out/wgsl/800-out-of-bounds-panic-vert.wgsl @@ -1,14 +1,14 @@ struct Globals { - view_matrix: mat4x4; + view_matrix: mat4x4, }; struct VertexPushConstants { - world_matrix: mat4x4; + world_matrix: mat4x4, }; struct VertexOutput { - @location(0) frag_color: vec4; - @builtin(position) member: vec4; + @location(0) frag_color: vec4, + @builtin(position) member: vec4, }; @group(0) @binding(0) diff --git a/tests/out/wgsl/896-push-constant-vert.wgsl b/tests/out/wgsl/896-push-constant-vert.wgsl index f7f2dcfb31..89e7cee2be 100644 --- a/tests/out/wgsl/896-push-constant-vert.wgsl +++ b/tests/out/wgsl/896-push-constant-vert.wgsl @@ -1,5 +1,5 @@ struct PushConstants { - example: f32; + example: f32, }; var c: PushConstants; diff --git a/tests/out/wgsl/access.wgsl b/tests/out/wgsl/access.wgsl index 1080002efc..cab0428e9d 100644 --- a/tests/out/wgsl/access.wgsl +++ b/tests/out/wgsl/access.wgsl @@ -1,13 +1,13 @@ struct AlignedWrapper { - value: i32; + value: i32, }; struct Bar { - matrix: mat4x4; - matrix_array: array,2>; - atom: atomic; - arr: array,2>; - data: array; + matrix: mat4x4, + matrix_array: array,2>, + atom: atomic, + arr: array,2>, + data: array, }; @group(0) @binding(0) diff --git a/tests/out/wgsl/bevy-pbr-frag.wgsl b/tests/out/wgsl/bevy-pbr-frag.wgsl index bf12b515da..d8ef7b2dd0 100644 --- a/tests/out/wgsl/bevy-pbr-frag.wgsl +++ b/tests/out/wgsl/bevy-pbr-frag.wgsl @@ -1,51 +1,51 @@ struct PointLight { - pos: vec4; - color: vec4; - lightParams: vec4; + pos: vec4, + color: vec4, + lightParams: vec4, }; struct DirectionalLight { - direction: vec4; - color: vec4; + direction: vec4, + color: vec4, }; struct CameraViewProj { - ViewProj: mat4x4; + ViewProj: mat4x4, }; struct CameraPosition { - CameraPos: vec4; + CameraPos: vec4, }; struct Lights { - AmbientColor: vec4; - NumLights: vec4; - PointLights: array; - DirectionalLights: array; + AmbientColor: vec4, + NumLights: vec4, + PointLights: array, + DirectionalLights: array, }; struct StandardMaterial_base_color { - base_color: vec4; + base_color: vec4, }; struct StandardMaterial_roughness { - perceptual_roughness: f32; + perceptual_roughness: f32, }; struct StandardMaterial_metallic { - metallic: f32; + metallic: f32, }; struct StandardMaterial_reflectance { - reflectance: f32; + reflectance: f32, }; struct StandardMaterial_emissive { - emissive: vec4; + emissive: vec4, }; struct FragmentOutput { - @location(0) o_Target: vec4; + @location(0) o_Target: vec4, }; var v_WorldPosition_1: vec3; diff --git a/tests/out/wgsl/bevy-pbr-vert.wgsl b/tests/out/wgsl/bevy-pbr-vert.wgsl index 617537fad5..13c7cb9358 100644 --- a/tests/out/wgsl/bevy-pbr-vert.wgsl +++ b/tests/out/wgsl/bevy-pbr-vert.wgsl @@ -1,17 +1,17 @@ struct CameraViewProj { - ViewProj: mat4x4; + ViewProj: mat4x4, }; struct Transform { - Model: mat4x4; + Model: mat4x4, }; struct VertexOutput { - @location(0) v_WorldPosition: vec3; - @location(1) v_WorldNormal: vec3; - @location(2) v_Uv: vec2; - @location(3) v_WorldTangent: vec4; - @builtin(position) member: vec4; + @location(0) v_WorldPosition: vec3, + @location(1) v_WorldNormal: vec3, + @location(2) v_Uv: vec2, + @location(3) v_WorldTangent: vec4, + @builtin(position) member: vec4, }; var Vertex_Position_1: vec3; diff --git a/tests/out/wgsl/boids.wgsl b/tests/out/wgsl/boids.wgsl index 1910535abc..bc908aa675 100644 --- a/tests/out/wgsl/boids.wgsl +++ b/tests/out/wgsl/boids.wgsl @@ -1,20 +1,20 @@ struct Particle { - pos: vec2; - vel: vec2; + pos: vec2, + vel: vec2, }; struct SimParams { - deltaT: f32; - rule1Distance: f32; - rule2Distance: f32; - rule3Distance: f32; - rule1Scale: f32; - rule2Scale: f32; - rule3Scale: f32; + deltaT: f32, + rule1Distance: f32, + rule2Distance: f32, + rule3Distance: f32, + rule1Scale: f32, + rule2Scale: f32, + rule3Scale: f32, }; struct Particles { - particles: array; + particles: array, }; let NUM_PARTICLES: u32 = 1500u; diff --git a/tests/out/wgsl/bool-select-frag.wgsl b/tests/out/wgsl/bool-select-frag.wgsl index c1d5502cf1..f44a4416e8 100644 --- a/tests/out/wgsl/bool-select-frag.wgsl +++ b/tests/out/wgsl/bool-select-frag.wgsl @@ -1,5 +1,5 @@ struct FragmentOutput { - @location(0) o_color: vec4; + @location(0) o_color: vec4, }; var o_color: vec4; diff --git a/tests/out/wgsl/clamp-splat-vert.wgsl b/tests/out/wgsl/clamp-splat-vert.wgsl index 953ea71ccd..fd0b8eaf6d 100644 --- a/tests/out/wgsl/clamp-splat-vert.wgsl +++ b/tests/out/wgsl/clamp-splat-vert.wgsl @@ -1,5 +1,5 @@ struct VertexOutput { - @builtin(position) member: vec4; + @builtin(position) member: vec4, }; var a_pos_1: vec2; diff --git a/tests/out/wgsl/collatz.wgsl b/tests/out/wgsl/collatz.wgsl index 334a779e6f..37e530c0ce 100644 --- a/tests/out/wgsl/collatz.wgsl +++ b/tests/out/wgsl/collatz.wgsl @@ -1,5 +1,5 @@ struct PrimeIndices { - data: array; + data: array, }; @group(0) @binding(0) diff --git a/tests/out/wgsl/constant-array-size-vert.wgsl b/tests/out/wgsl/constant-array-size-vert.wgsl index f0d5474a20..bf4830dc9e 100644 --- a/tests/out/wgsl/constant-array-size-vert.wgsl +++ b/tests/out/wgsl/constant-array-size-vert.wgsl @@ -1,5 +1,5 @@ struct Data { - vecs: array,42u>; + vecs: array,42u>, }; @group(1) @binding(0) diff --git a/tests/out/wgsl/declarations-vert.wgsl b/tests/out/wgsl/declarations-vert.wgsl index cc5d9c932e..ba1cdd58d6 100644 --- a/tests/out/wgsl/declarations-vert.wgsl +++ b/tests/out/wgsl/declarations-vert.wgsl @@ -1,23 +1,23 @@ struct VertexData { - position: vec2; - a: vec2; + position: vec2, + a: vec2, }; struct FragmentData { - position: vec2; - a: vec2; + position: vec2, + a: vec2, }; struct TestStruct { - a: f32; - b: f32; + a: f32, + b: f32, }; struct VertexOutput { - @location(0) position: vec2; - @location(1) a: vec2; - @location(2) out_array: vec4; - @location(3) out_array_1: vec4; + @location(0) position: vec2, + @location(1) a: vec2, + @location(2) out_array: vec4, + @location(3) out_array_1: vec4, }; var vert: VertexData; diff --git a/tests/out/wgsl/empty-global-name.wgsl b/tests/out/wgsl/empty-global-name.wgsl index 1baaf03e29..81334fc8f6 100644 --- a/tests/out/wgsl/empty-global-name.wgsl +++ b/tests/out/wgsl/empty-global-name.wgsl @@ -1,5 +1,5 @@ struct type_1 { - member: i32; + member: i32, }; @group(0) @binding(0) diff --git a/tests/out/wgsl/expressions-frag.wgsl b/tests/out/wgsl/expressions-frag.wgsl index 434d24b6a1..f487aae834 100644 --- a/tests/out/wgsl/expressions-frag.wgsl +++ b/tests/out/wgsl/expressions-frag.wgsl @@ -1,9 +1,9 @@ struct BST { - data: i32; + data: i32, }; struct FragmentOutput { - @location(0) o_color: vec4; + @location(0) o_color: vec4, }; var global: f32; diff --git a/tests/out/wgsl/extra.wgsl b/tests/out/wgsl/extra.wgsl index e1aaa9c018..98b6bc883b 100644 --- a/tests/out/wgsl/extra.wgsl +++ b/tests/out/wgsl/extra.wgsl @@ -1,11 +1,11 @@ struct PushConstants { - index: u32; - double: vec2; + index: u32, + double: vec2, }; struct FragmentIn { - @location(0) color: vec4; - @builtin(primitive_index) primitive_index: u32; + @location(0) color: vec4, + @builtin(primitive_index) primitive_index: u32, }; var pc: PushConstants; diff --git a/tests/out/wgsl/fma-frag.wgsl b/tests/out/wgsl/fma-frag.wgsl index 8bd6686745..3d094d41ce 100644 --- a/tests/out/wgsl/fma-frag.wgsl +++ b/tests/out/wgsl/fma-frag.wgsl @@ -1,11 +1,11 @@ struct Mat4x3_ { - mx: vec4; - my: vec4; - mz: vec4; + mx: vec4, + my: vec4, + mz: vec4, }; struct FragmentOutput { - @location(0) o_color: vec4; + @location(0) o_color: vec4, }; var o_color: vec4; diff --git a/tests/out/wgsl/globals.wgsl b/tests/out/wgsl/globals.wgsl index d1ab5cbf11..4d60fe89b4 100644 --- a/tests/out/wgsl/globals.wgsl +++ b/tests/out/wgsl/globals.wgsl @@ -1,6 +1,6 @@ struct Foo { - v3_: vec3; - v1_: f32; + v3_: vec3, + v1_: f32, }; let Foo_2: bool = true; diff --git a/tests/out/wgsl/interface.wgsl b/tests/out/wgsl/interface.wgsl index ad24717f36..9da63f6318 100644 --- a/tests/out/wgsl/interface.wgsl +++ b/tests/out/wgsl/interface.wgsl @@ -1,20 +1,20 @@ struct VertexOutput { - @builtin(position) position: vec4; - @location(1) varying: f32; + @builtin(position) position: vec4, + @location(1) varying: f32, }; struct FragmentOutput { - @builtin(frag_depth) depth: f32; - @builtin(sample_mask) sample_mask: u32; - @location(0) color: f32; + @builtin(frag_depth) depth: f32, + @builtin(sample_mask) sample_mask: u32, + @location(0) color: f32, }; struct Input1_ { - @builtin(vertex_index) index: u32; + @builtin(vertex_index) index: u32, }; struct Input2_ { - @builtin(instance_index) index: u32; + @builtin(instance_index) index: u32, }; var output: array; diff --git a/tests/out/wgsl/interpolate.wgsl b/tests/out/wgsl/interpolate.wgsl index 69ccd9630b..a74b65741f 100644 --- a/tests/out/wgsl/interpolate.wgsl +++ b/tests/out/wgsl/interpolate.wgsl @@ -1,12 +1,12 @@ struct FragmentInput { - @builtin(position) position: vec4; - @location(0) flat: u32; - @location(1) @interpolate(linear) linear: f32; - @location(2) @interpolate(linear, centroid) linear_centroid: vec2; - @location(3) @interpolate(linear, sample) linear_sample: vec3; - @location(4) perspective: vec4; - @location(5) @interpolate(perspective, centroid) perspective_centroid: f32; - @location(6) @interpolate(perspective, sample) perspective_sample: f32; + @builtin(position) position: vec4, + @location(0) flat: u32, + @location(1) @interpolate(linear) linear: f32, + @location(2) @interpolate(linear, centroid) linear_centroid: vec2, + @location(3) @interpolate(linear, sample) linear_sample: vec3, + @location(4) perspective: vec4, + @location(5) @interpolate(perspective, centroid) perspective_centroid: f32, + @location(6) @interpolate(perspective, sample) perspective_sample: f32, }; @stage(vertex) diff --git a/tests/out/wgsl/operators.wgsl b/tests/out/wgsl/operators.wgsl index eac31fec00..5beefb4d4d 100644 --- a/tests/out/wgsl/operators.wgsl +++ b/tests/out/wgsl/operators.wgsl @@ -1,6 +1,6 @@ struct Foo { - a: vec4; - b: i32; + a: vec4, + b: i32, }; let v_f32_one: vec4 = vec4(1.0, 1.0, 1.0, 1.0); diff --git a/tests/out/wgsl/pointers.wgsl b/tests/out/wgsl/pointers.wgsl index e06ecb0b15..035e05292d 100644 --- a/tests/out/wgsl/pointers.wgsl +++ b/tests/out/wgsl/pointers.wgsl @@ -1,5 +1,5 @@ struct DynamicArray { - arr: array; + arr: array, }; @group(0) @binding(0) diff --git a/tests/out/wgsl/quad-vert.wgsl b/tests/out/wgsl/quad-vert.wgsl index eaec429139..7f598d03f1 100644 --- a/tests/out/wgsl/quad-vert.wgsl +++ b/tests/out/wgsl/quad-vert.wgsl @@ -1,10 +1,10 @@ struct gl_PerVertex { - @builtin(position) gl_Position: vec4; + @builtin(position) gl_Position: vec4, }; struct VertexOutput { - @location(0) member: vec2; - @builtin(position) gl_Position: vec4; + @location(0) member: vec2, + @builtin(position) gl_Position: vec4, }; var v_uv: vec2; diff --git a/tests/out/wgsl/quad.wgsl b/tests/out/wgsl/quad.wgsl index 641f2fd289..01c21bf157 100644 --- a/tests/out/wgsl/quad.wgsl +++ b/tests/out/wgsl/quad.wgsl @@ -1,6 +1,6 @@ struct VertexOutput { - @location(0) uv: vec2; - @builtin(position) position: vec4; + @location(0) uv: vec2, + @builtin(position) position: vec4, }; let c_scale: f32 = 1.2000000476837158; diff --git a/tests/out/wgsl/quad_glsl-frag.wgsl b/tests/out/wgsl/quad_glsl-frag.wgsl index 74276c9d62..49dbe92423 100644 --- a/tests/out/wgsl/quad_glsl-frag.wgsl +++ b/tests/out/wgsl/quad_glsl-frag.wgsl @@ -1,5 +1,5 @@ struct FragmentOutput { - @location(0) o_color: vec4; + @location(0) o_color: vec4, }; var v_uv_1: vec2; diff --git a/tests/out/wgsl/quad_glsl-vert.wgsl b/tests/out/wgsl/quad_glsl-vert.wgsl index 470286a3ca..a029b3d434 100644 --- a/tests/out/wgsl/quad_glsl-vert.wgsl +++ b/tests/out/wgsl/quad_glsl-vert.wgsl @@ -1,6 +1,6 @@ struct VertexOutput { - @location(0) v_uv: vec2; - @builtin(position) member: vec4; + @location(0) v_uv: vec2, + @builtin(position) member: vec4, }; var a_pos_1: vec2; diff --git a/tests/out/wgsl/shadow.wgsl b/tests/out/wgsl/shadow.wgsl index a5dbb554ef..41fc7eba2d 100644 --- a/tests/out/wgsl/shadow.wgsl +++ b/tests/out/wgsl/shadow.wgsl @@ -1,23 +1,23 @@ struct Globals { - view_proj: mat4x4; - num_lights: vec4; + view_proj: mat4x4, + num_lights: vec4, }; struct Entity { - world: mat4x4; - color: vec4; + world: mat4x4, + color: vec4, }; struct VertexOutput { - @builtin(position) proj_position: vec4; - @location(0) world_normal: vec3; - @location(1) world_position: vec4; + @builtin(position) proj_position: vec4, + @location(0) world_normal: vec3, + @location(1) world_position: vec4, }; struct Light { - proj: mat4x4; - pos: vec4; - color: vec4; + proj: mat4x4, + pos: vec4, + color: vec4, }; let c_ambient: vec3 = vec3(0.05000000074505806, 0.05000000074505806, 0.05000000074505806); diff --git a/tests/out/wgsl/skybox.wgsl b/tests/out/wgsl/skybox.wgsl index 93b5f06e58..32c2c52d25 100644 --- a/tests/out/wgsl/skybox.wgsl +++ b/tests/out/wgsl/skybox.wgsl @@ -1,11 +1,11 @@ struct VertexOutput { - @builtin(position) position: vec4; - @location(0) uv: vec3; + @builtin(position) position: vec4, + @location(0) uv: vec3, }; struct Data { - proj_inv: mat4x4; - view: mat4x4; + proj_inv: mat4x4, + view: mat4x4, }; @group(0) @binding(0) diff --git a/tests/wgsl-errors.rs b/tests/wgsl-errors.rs index a5a0a5fc11..bde6da336b 100644 --- a/tests/wgsl-errors.rs +++ b/tests/wgsl-errors.rs @@ -376,13 +376,13 @@ fn struct_member_zero_size() { check( r#" struct Bar { - @size(0) data: array; + @size(0) data: array }; "#, r#"error: struct member size or alignment must not be 0 ┌─ wgsl:3:23 │ -3 │ @size(0) data: array; +3 │ @size(0) data: array │ ^ struct member size or alignment must not be 0 "#, @@ -394,13 +394,13 @@ fn struct_member_zero_align() { check( r#" struct Bar { - @align(0) data: array; + @align(0) data: array }; "#, r#"error: struct member size or alignment must not be 0 ┌─ wgsl:3:24 │ -3 │ @align(0) data: array; +3 │ @align(0) data: array │ ^ struct member size or alignment must not be 0 "#, @@ -542,7 +542,7 @@ fn postfix_pointers() { check( r#" - struct S { m: i32; }; + struct S { m: i32 }; fn main() { var s: S = S(42); let ps = &s; @@ -655,12 +655,12 @@ fn reserved_keyword() { // struct member check( r#" - struct Foo { sampler: f32; }; + struct Foo { sampler: f32 }; "#, r###"error: name `sampler` is a reserved keyword ┌─ wgsl:2:26 │ -2 │ struct Foo { sampler: f32; }; +2 │ struct Foo { sampler: f32 }; │ ^^^^^^^ definition of `sampler` "###, @@ -843,8 +843,8 @@ fn invalid_arrays() { #[test] fn invalid_structs() { check_validation_error! { - "struct Bad { data: sampler; };", - "struct Bad { data: texture_2d; };": + "struct Bad { data: sampler };", + "struct Bad { data: texture_2d };": Err(naga::valid::ValidationError::Type { error: naga::valid::TypeError::InvalidData(_), .. @@ -852,7 +852,7 @@ fn invalid_structs() { } check_validation_error! { - "struct Bad { data: array; other: f32; };": + "struct Bad { data: array, other: f32, };": Err(naga::valid::ValidationError::Type { error: naga::valid::TypeError::InvalidDynamicArray(_, _), .. @@ -865,7 +865,7 @@ fn invalid_functions() { check_validation_error! { "fn unacceptable_unsized(arg: array) { }", " - struct Unsized { data: array; }; + struct Unsized { data: array }; fn unacceptable_unsized(arg: Unsized) { } ": Err(naga::valid::ValidationError::Function { @@ -883,7 +883,7 @@ fn invalid_functions() { check_validation_error! { "fn unacceptable_unsized(arg: ptr>) { }", " - struct Unsized { data: array; }; + struct Unsized { data: array }; fn unacceptable_unsized(arg: ptr) { } ": Err(naga::valid::ValidationError::Type { @@ -998,8 +998,8 @@ fn missing_bindings() { check_validation_error! { " struct VertexIn { - @location(0) pos: vec4; - uv: vec2; + @location(0) pos: vec4, + uv: vec2 }; @stage(vertex) @@ -1088,7 +1088,7 @@ fn valid_access() { fn invalid_local_vars() { check_validation_error! { " - struct Unsized { data: array; }; + struct Unsized { data: array }; fn local_ptr_dynamic_array(okay: ptr) { var not_okay: ptr> = &(*okay).data; } @@ -1144,12 +1144,12 @@ fn invalid_runtime_sized_arrays() { check_validation_error! { " struct Unsized { - arr: array; + arr: array }; struct Outer { - legit: i32; - unsized: Unsized; + legit: i32, + unsized: Unsized }; @group(0) @binding(0) var outer: Outer; @@ -1187,7 +1187,7 @@ fn select() { } ", " - struct S { member: i32; }; + struct S { member: i32 }; fn select_structs(which: bool) -> S { var x: S = S(1); var y: S = S(2); @@ -1257,7 +1257,7 @@ fn wrong_access_mode() { check_validation_error! { " struct Globals { - i: i32; + i: i32 }; @group(0) @binding(0) @@ -1269,7 +1269,7 @@ fn wrong_access_mode() { ", " struct Globals { - i: i32; + i: i32 }; @group(0) @binding(0)