diff --git a/src/back/wgsl/writer.rs b/src/back/wgsl/writer.rs index 44dd2a97c0..157e4e8db3 100644 --- a/src/back/wgsl/writer.rs +++ b/src/back/wgsl/writer.rs @@ -108,12 +108,8 @@ impl Writer { // Write all structs for (handle, ty) in module.types.iter() { - if let TypeInner::Struct { - ref members, - span: _, - } = ty.inner - { - self.write_struct(module, handle, members)?; + if let TypeInner::Struct { ref members, span } = ty.inner { + self.write_struct(module, handle, members, span)?; writeln!(self.out)?; } } @@ -377,17 +373,28 @@ impl Writer { module: &Module, handle: Handle, members: &[crate::StructMember], + struct_span: u32, ) -> BackendResult { write!(self.out, "struct ")?; self.write_struct_name(module, handle)?; write!(self.out, " {{")?; writeln!(self.out)?; + for (index, member) in members.iter().enumerate() { // The indentation is only for readability write!(self.out, "{}", back::INDENT)?; if let Some(ref binding) = member.binding { self.write_attributes(&map_binding_to_attribute(binding))?; } + + let current_field_size = if index != members.len() - 1 { + let next_member = &members[index + 1]; + next_member.offset - member.offset + } else { + struct_span - member.offset + }; + write!(self.out, "@size({current_field_size}) ")?; + // Write struct member name and type let member_name = &self.names[&NameKey::StructMember(handle, index as u32)]; write!(self.out, "{member_name}: ")?; diff --git a/tests/out/wgsl/210-bevy-2d-shader-frag.wgsl b/tests/out/wgsl/210-bevy-2d-shader-frag.wgsl index a800b0f856..7d7cb49b0d 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, + @size(16) Color: vec4, } struct FragmentOutput { - @location(0) o_Target: vec4, + @location(0) @size(16) 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 365fa3470e..3d1fb14252 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, + @size(64) ViewProj: mat4x4, } struct Transform { - Model: mat4x4, + @size(64) Model: mat4x4, } struct Sprite_size { - size: vec2, + @size(8) size: vec2, } struct VertexOutput { - @location(0) v_Uv: vec2, - @builtin(position) member: vec4, + @location(0) @size(8) v_Uv: vec2, + @builtin(position) @size(16) 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 f7932979b5..98971cb640 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, + @size(64) ViewProj: mat4x4, } struct Transform { - Model: mat4x4, + @size(64) 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) @size(12) v_Position: vec3, + @location(1) @size(12) v_Normal: vec3, + @location(2) @size(8) v_Uv: vec2, + @builtin(position) @size(16) 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 e92cf8127c..34f9e050f9 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, + @size(4) 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 d749d5a1f4..672f9c4cca 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, + @size(64) view_matrix: mat4x4, } struct VertexPushConstants { - world_matrix: mat4x4, + @size(64) world_matrix: mat4x4, } struct VertexOutput { - @location(0) frag_color: vec4, - @builtin(position) member: vec4, + @location(0) @size(16) frag_color: vec4, + @builtin(position) @size(16) member: vec4, } @group(0) @binding(0) diff --git a/tests/out/wgsl/896-push-constant-frag.wgsl b/tests/out/wgsl/896-push-constant-frag.wgsl index 729e35a43f..9c16eccce8 100644 --- a/tests/out/wgsl/896-push-constant-frag.wgsl +++ b/tests/out/wgsl/896-push-constant-frag.wgsl @@ -1,5 +1,5 @@ struct PushConstants { - example: f32, + @size(4) example: f32, } var c: PushConstants; diff --git a/tests/out/wgsl/access.wgsl b/tests/out/wgsl/access.wgsl index 77ebe1ee18..db75795276 100644 --- a/tests/out/wgsl/access.wgsl +++ b/tests/out/wgsl/access.wgsl @@ -1,28 +1,28 @@ struct GlobalConst { - a: u32, - b: vec3, - c: i32, + @size(16) a: u32, + @size(12) b: vec3, + @size(4) c: i32, } struct AlignedWrapper { - value: i32, + @size(8) value: i32, } struct Bar { - _matrix: mat4x3, - matrix_array: array, 2>, - atom: atomic, - atom_arr: array, 10>, - arr: array, 2>, - data: array, + @size(64) _matrix: mat4x3, + @size(32) matrix_array: array, 2>, + @size(4) atom: atomic, + @size(44) atom_arr: array, 10>, + @size(16) arr: array, 2>, + @size(16) data: array, } struct Baz { - m: mat3x2, + @size(24) m: mat3x2, } struct MatCx2InArray { - am: array, 2>, + @size(64) am: array, 2>, } var global_const: GlobalConst = GlobalConst(0u, vec3(0u, 0u, 0u), 0); diff --git a/tests/out/wgsl/array-in-ctor.wgsl b/tests/out/wgsl/array-in-ctor.wgsl index 8c17731f0c..e4c1a6d309 100644 --- a/tests/out/wgsl/array-in-ctor.wgsl +++ b/tests/out/wgsl/array-in-ctor.wgsl @@ -1,5 +1,5 @@ struct Ah { - inner: array, + @size(8) inner: array, } @group(0) @binding(0) diff --git a/tests/out/wgsl/atomicCompareExchange.wgsl b/tests/out/wgsl/atomicCompareExchange.wgsl index 2ff428bd71..7f114afbe2 100644 --- a/tests/out/wgsl/atomicCompareExchange.wgsl +++ b/tests/out/wgsl/atomicCompareExchange.wgsl @@ -1,11 +1,11 @@ struct gen___atomic_compare_exchange_resultSint4_ { - old_value: i32, - exchanged: bool, + @size(4) old_value: i32, + @size(4) exchanged: bool, } struct gen___atomic_compare_exchange_resultUint4_ { - old_value: u32, - exchanged: bool, + @size(4) old_value: u32, + @size(4) exchanged: bool, } const SIZE: u32 = 128u; diff --git a/tests/out/wgsl/atomicOps.wgsl b/tests/out/wgsl/atomicOps.wgsl index 934a7b7952..517e28781d 100644 --- a/tests/out/wgsl/atomicOps.wgsl +++ b/tests/out/wgsl/atomicOps.wgsl @@ -1,6 +1,6 @@ struct Struct { - atomic_scalar: atomic, - atomic_arr: array, 2>, + @size(4) atomic_scalar: atomic, + @size(8) atomic_arr: array, 2>, } @group(0) @binding(0) diff --git a/tests/out/wgsl/bevy-pbr-frag.wgsl b/tests/out/wgsl/bevy-pbr-frag.wgsl index 249298dcc9..e28779d03e 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, + @size(16) pos: vec4, + @size(16) color: vec4, + @size(16) lightParams: vec4, } struct DirectionalLight { - direction: vec4, - color: vec4, + @size(16) direction: vec4, + @size(16) color: vec4, } struct CameraViewProj { - ViewProj: mat4x4, + @size(64) ViewProj: mat4x4, } struct CameraPosition { - CameraPos: vec4, + @size(16) CameraPos: vec4, } struct Lights { - AmbientColor: vec4, - NumLights: vec4, - PointLights: array, - DirectionalLights: array, + @size(16) AmbientColor: vec4, + @size(16) NumLights: vec4, + @size(480) PointLights: array, + @size(32) DirectionalLights: array, } struct StandardMaterial_base_color { - base_color: vec4, + @size(16) base_color: vec4, } struct StandardMaterial_roughness { - perceptual_roughness: f32, + @size(4) perceptual_roughness: f32, } struct StandardMaterial_metallic { - metallic: f32, + @size(4) metallic: f32, } struct StandardMaterial_reflectance { - reflectance: f32, + @size(4) reflectance: f32, } struct StandardMaterial_emissive { - emissive: vec4, + @size(16) emissive: vec4, } struct FragmentOutput { - @location(0) o_Target: vec4, + @location(0) @size(16) o_Target: vec4, } const MAX_POINT_LIGHTS: i32 = 10; diff --git a/tests/out/wgsl/bevy-pbr-vert.wgsl b/tests/out/wgsl/bevy-pbr-vert.wgsl index ac13dcdfdc..b85c24a8d3 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, + @size(64) ViewProj: mat4x4, } struct Transform { - Model: mat4x4, + @size(64) 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) @size(12) v_WorldPosition: vec3, + @location(1) @size(12) v_WorldNormal: vec3, + @location(2) @size(8) v_Uv: vec2, + @location(3) @size(16) v_WorldTangent: vec4, + @builtin(position) @size(16) member: vec4, } var Vertex_Position_1: vec3; diff --git a/tests/out/wgsl/binding-arrays.wgsl b/tests/out/wgsl/binding-arrays.wgsl index 7f181413bb..1ab8fbff2c 100644 --- a/tests/out/wgsl/binding-arrays.wgsl +++ b/tests/out/wgsl/binding-arrays.wgsl @@ -1,9 +1,9 @@ struct UniformIndex { - index: u32, + @size(4) index: u32, } struct FragmentIn { - @location(0) @interpolate(flat) index: u32, + @location(0) @interpolate(flat) @size(4) index: u32, } @group(0) @binding(0) diff --git a/tests/out/wgsl/binding-buffer-arrays.wgsl b/tests/out/wgsl/binding-buffer-arrays.wgsl index 4a36faa399..8b4a77f2ed 100644 --- a/tests/out/wgsl/binding-buffer-arrays.wgsl +++ b/tests/out/wgsl/binding-buffer-arrays.wgsl @@ -1,13 +1,13 @@ struct UniformIndex { - index: u32, + @size(4) index: u32, } struct Foo { - x: u32, + @size(4) x: u32, } struct FragmentIn { - @location(0) @interpolate(flat) index: u32, + @location(0) @interpolate(flat) @size(4) index: u32, } @group(0) @binding(0) diff --git a/tests/out/wgsl/boids.wgsl b/tests/out/wgsl/boids.wgsl index 26502a9e6c..bdf3d80376 100644 --- a/tests/out/wgsl/boids.wgsl +++ b/tests/out/wgsl/boids.wgsl @@ -1,20 +1,20 @@ struct Particle { - pos: vec2, - vel: vec2, + @size(8) pos: vec2, + @size(8) vel: vec2, } struct SimParams { - deltaT: f32, - rule1Distance: f32, - rule2Distance: f32, - rule3Distance: f32, - rule1Scale: f32, - rule2Scale: f32, - rule3Scale: f32, + @size(4) deltaT: f32, + @size(4) rule1Distance: f32, + @size(4) rule2Distance: f32, + @size(4) rule3Distance: f32, + @size(4) rule1Scale: f32, + @size(4) rule2Scale: f32, + @size(4) rule3Scale: f32, } struct Particles { - particles: array, + @size(16) particles: array, } const NUM_PARTICLES: u32 = 1500u; diff --git a/tests/out/wgsl/bool-select-frag.wgsl b/tests/out/wgsl/bool-select-frag.wgsl index 4f0e218ee2..03ebd6ddf2 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) @size(16) o_color: vec4, } var o_color: vec4; diff --git a/tests/out/wgsl/buffer-frag.wgsl b/tests/out/wgsl/buffer-frag.wgsl index 73e543ca76..33004e3315 100644 --- a/tests/out/wgsl/buffer-frag.wgsl +++ b/tests/out/wgsl/buffer-frag.wgsl @@ -1,9 +1,9 @@ struct testBufferBlock { - data: array, + @size(4) data: array, } struct testBufferReadOnlyBlock { - data: array, + @size(4) data: array, } @group(0) @binding(0) diff --git a/tests/out/wgsl/clamp-splat-vert.wgsl b/tests/out/wgsl/clamp-splat-vert.wgsl index deeea02ef1..85a49f26a6 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) @size(16) member: vec4, } var a_pos_1: vec2; diff --git a/tests/out/wgsl/collatz.wgsl b/tests/out/wgsl/collatz.wgsl index a25f795360..0f0526693f 100644 --- a/tests/out/wgsl/collatz.wgsl +++ b/tests/out/wgsl/collatz.wgsl @@ -1,5 +1,5 @@ struct PrimeIndices { - data: array, + @size(4) data: array, } @group(0) @binding(0) diff --git a/tests/out/wgsl/constant-array-size-frag.wgsl b/tests/out/wgsl/constant-array-size-frag.wgsl index fb706acf2a..560b759186 100644 --- a/tests/out/wgsl/constant-array-size-frag.wgsl +++ b/tests/out/wgsl/constant-array-size-frag.wgsl @@ -1,5 +1,5 @@ struct Data { - vecs: array, 42>, + @size(672) vecs: array, 42>, } const NUM_VECS: i32 = 42; diff --git a/tests/out/wgsl/constructors.wgsl b/tests/out/wgsl/constructors.wgsl index 7818e4c39e..10e960121f 100644 --- a/tests/out/wgsl/constructors.wgsl +++ b/tests/out/wgsl/constructors.wgsl @@ -1,6 +1,6 @@ struct Foo { - a: vec4, - b: i32, + @size(16) a: vec4, + @size(16) b: i32, } const const2_: vec3 = vec3(0.0, 1.0, 2.0); diff --git a/tests/out/wgsl/declarations-frag.wgsl b/tests/out/wgsl/declarations-frag.wgsl index 23c697a008..df36598338 100644 --- a/tests/out/wgsl/declarations-frag.wgsl +++ b/tests/out/wgsl/declarations-frag.wgsl @@ -1,33 +1,33 @@ struct VertexData { - position: vec2, - a: vec2, + @size(8) position: vec2, + @size(8) a: vec2, } struct FragmentData { - position: vec2, - a: vec2, + @size(8) position: vec2, + @size(8) a: vec2, } struct TestStruct { - a: f32, - b: f32, + @size(4) a: f32, + @size(4) b: f32, } struct LightScatteringParams { - BetaRay: f32, - BetaMie: array, - HGg: f32, - DistanceMul: array, - BlendCoeff: f32, - SunDirection: vec3, - SunColor: vec3, + @size(16) BetaRay: f32, + @size(48) BetaMie: array, + @size(16) HGg: f32, + @size(64) DistanceMul: array, + @size(16) BlendCoeff: f32, + @size(16) SunDirection: vec3, + @size(16) SunColor: vec3, } struct FragmentOutput { - @location(0) position: vec2, - @location(1) a: vec2, - @location(2) out_array: vec4, - @location(3) out_array_1: vec4, + @location(0) @size(8) position: vec2, + @location(1) @size(8) a: vec2, + @location(2) @size(16) out_array: vec4, + @location(3) @size(16) 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 11aa6b96e8..069d5aa726 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, + @size(4) member: i32, } @group(0) @binding(0) diff --git a/tests/out/wgsl/expressions-frag.wgsl b/tests/out/wgsl/expressions-frag.wgsl index e8e1a9f98a..7aad03e0ba 100644 --- a/tests/out/wgsl/expressions-frag.wgsl +++ b/tests/out/wgsl/expressions-frag.wgsl @@ -1,17 +1,17 @@ struct BST { - data: i32, + @size(4) data: i32, } struct a_buf { - a: array, + @size(4) a: array, } struct TestStruct { - array_: array, 2>, + @size(32) array_: array, 2>, } struct FragmentOutput { - @location(0) o_color: vec4, + @location(0) @size(16) o_color: vec4, } const strct: TestStruct = TestStruct(array, 2>(vec4(0u, 0u, 0u, 0u), vec4(1u, 1u, 1u, 1u))); diff --git a/tests/out/wgsl/extra.wgsl b/tests/out/wgsl/extra.wgsl index 8fc91fa2d9..c14863ae2b 100644 --- a/tests/out/wgsl/extra.wgsl +++ b/tests/out/wgsl/extra.wgsl @@ -1,11 +1,11 @@ struct PushConstants { - index: u32, - double: vec2, + @size(16) index: u32, + @size(16) double: vec2, } struct FragmentIn { - @location(0) color: vec4, - @builtin(primitive_index) primitive_index: u32, + @location(0) @size(16) color: vec4, + @builtin(primitive_index) @size(16) primitive_index: u32, } var pc: PushConstants; diff --git a/tests/out/wgsl/fma-frag.wgsl b/tests/out/wgsl/fma-frag.wgsl index d7c74c2247..8738a60247 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, + @size(16) mx: vec4, + @size(16) my: vec4, + @size(16) mz: vec4, } struct FragmentOutput { - @location(0) o_color: vec4, + @location(0) @size(16) o_color: vec4, } var o_color: vec4; diff --git a/tests/out/wgsl/fragment-output.wgsl b/tests/out/wgsl/fragment-output.wgsl index 45cfdc8e8b..9b7c0e07bd 100644 --- a/tests/out/wgsl/fragment-output.wgsl +++ b/tests/out/wgsl/fragment-output.wgsl @@ -1,19 +1,19 @@ struct FragmentOutputVec4Vec3_ { - @location(0) vec4f: vec4, - @location(1) @interpolate(flat) vec4i: vec4, - @location(2) @interpolate(flat) vec4u: vec4, - @location(3) vec3f: vec3, - @location(4) @interpolate(flat) vec3i: vec3, - @location(5) @interpolate(flat) vec3u: vec3, + @location(0) @size(16) vec4f: vec4, + @location(1) @interpolate(flat) @size(16) vec4i: vec4, + @location(2) @interpolate(flat) @size(16) vec4u: vec4, + @location(3) @size(16) vec3f: vec3, + @location(4) @interpolate(flat) @size(16) vec3i: vec3, + @location(5) @interpolate(flat) @size(16) vec3u: vec3, } struct FragmentOutputVec2Scalar { - @location(0) vec2f: vec2, - @location(1) @interpolate(flat) vec2i: vec2, - @location(2) @interpolate(flat) vec2u: vec2, - @location(3) scalarf: f32, - @location(4) @interpolate(flat) scalari: i32, - @location(5) @interpolate(flat) scalaru: u32, + @location(0) @size(8) vec2f: vec2, + @location(1) @interpolate(flat) @size(8) vec2i: vec2, + @location(2) @interpolate(flat) @size(8) vec2u: vec2, + @location(3) @size(4) scalarf: f32, + @location(4) @interpolate(flat) @size(4) scalari: i32, + @location(5) @interpolate(flat) @size(8) scalaru: u32, } @fragment diff --git a/tests/out/wgsl/globals.wgsl b/tests/out/wgsl/globals.wgsl index b83b43806d..84419dcfc0 100644 --- a/tests/out/wgsl/globals.wgsl +++ b/tests/out/wgsl/globals.wgsl @@ -1,6 +1,6 @@ struct FooStruct { - v3_: vec3, - v1_: f32, + @size(12) v3_: vec3, + @size(4) v1_: f32, } const Foo_1: bool = true; diff --git a/tests/out/wgsl/interface.wgsl b/tests/out/wgsl/interface.wgsl index 68fe28cd4e..c763028c1c 100644 --- a/tests/out/wgsl/interface.wgsl +++ b/tests/out/wgsl/interface.wgsl @@ -1,20 +1,20 @@ struct VertexOutput { - @builtin(position) @invariant position: vec4, - @location(1) _varying: f32, + @builtin(position) @invariant @size(16) position: vec4, + @location(1) @size(16) _varying: f32, } struct FragmentOutput { - @builtin(frag_depth) depth: f32, - @builtin(sample_mask) sample_mask: u32, - @location(0) color: f32, + @builtin(frag_depth) @size(4) depth: f32, + @builtin(sample_mask) @size(4) sample_mask: u32, + @location(0) @size(4) color: f32, } struct Input1_ { - @builtin(vertex_index) index: u32, + @builtin(vertex_index) @size(4) index: u32, } struct Input2_ { - @builtin(instance_index) index: u32, + @builtin(instance_index) @size(4) index: u32, } var output: array; diff --git a/tests/out/wgsl/interpolate.wgsl b/tests/out/wgsl/interpolate.wgsl index e2c4ce28b4..211bdd83b0 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) @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) perspective: vec4, - @location(5) @interpolate(perspective, centroid) perspective_centroid: f32, - @location(6) @interpolate(perspective, sample) perspective_sample: f32, + @builtin(position) @size(16) position: vec4, + @location(0) @interpolate(flat) @size(4) _flat: u32, + @location(1) @interpolate(linear) @size(4) _linear: f32, + @location(2) @interpolate(linear, centroid) @size(8) linear_centroid: vec2, + @location(3) @interpolate(linear, sample) @size(16) linear_sample: vec3, + @location(4) @size(16) perspective: vec4, + @location(5) @interpolate(perspective, centroid) @size(4) perspective_centroid: f32, + @location(6) @interpolate(perspective, sample) @size(12) perspective_sample: f32, } @vertex diff --git a/tests/out/wgsl/module-scope.wgsl b/tests/out/wgsl/module-scope.wgsl index 91a13718dd..000de56fbc 100644 --- a/tests/out/wgsl/module-scope.wgsl +++ b/tests/out/wgsl/module-scope.wgsl @@ -1,5 +1,5 @@ struct S { - x: i32, + @size(4) x: i32, } const Value: i32 = 1; diff --git a/tests/out/wgsl/padding.wgsl b/tests/out/wgsl/padding.wgsl index 7f77c35319..242d845c15 100644 --- a/tests/out/wgsl/padding.wgsl +++ b/tests/out/wgsl/padding.wgsl @@ -1,20 +1,20 @@ struct S { - a: vec3, + @size(16) a: vec3, } struct Test { - a: S, - b: f32, + @size(16) a: S, + @size(16) b: f32, } struct Test2_ { - a: array, 2>, - b: f32, + @size(32) a: array, 2>, + @size(16) b: f32, } struct Test3_ { - a: mat4x3, - b: f32, + @size(64) a: mat4x3, + @size(16) b: f32, } @group(0) @binding(0) diff --git a/tests/out/wgsl/pointers.wgsl b/tests/out/wgsl/pointers.wgsl index 5269e16f7a..db9a860aa7 100644 --- a/tests/out/wgsl/pointers.wgsl +++ b/tests/out/wgsl/pointers.wgsl @@ -1,5 +1,5 @@ struct DynamicArray { - arr: array, + @size(4) arr: array, } @group(0) @binding(0) diff --git a/tests/out/wgsl/quad-vert.wgsl b/tests/out/wgsl/quad-vert.wgsl index 72da615ccb..83c2d7c3a6 100644 --- a/tests/out/wgsl/quad-vert.wgsl +++ b/tests/out/wgsl/quad-vert.wgsl @@ -1,13 +1,13 @@ struct gl_PerVertex { - @builtin(position) gl_Position: vec4, - gl_PointSize: f32, - gl_ClipDistance: array, - gl_CullDistance: array, + @builtin(position) @size(16) gl_Position: vec4, + @size(4) gl_PointSize: f32, + @size(4) gl_ClipDistance: array, + @size(8) gl_CullDistance: array, } struct VertexOutput { - @location(0) member: vec2, - @builtin(position) gl_Position: vec4, + @location(0) @size(0) member: vec2, + @builtin(position) @size(65535) gl_Position: vec4, } var v_uv: vec2; diff --git a/tests/out/wgsl/quad.wgsl b/tests/out/wgsl/quad.wgsl index 3a92981d95..50c59657c6 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) @size(16) uv: vec2, + @builtin(position) @size(16) position: vec4, } const c_scale: f32 = 1.2; diff --git a/tests/out/wgsl/quad_glsl-frag.wgsl b/tests/out/wgsl/quad_glsl-frag.wgsl index e90e5640d3..327cd933c1 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) @size(16) 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 b8d52e04c9..06776bad9c 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) @size(8) v_uv: vec2, + @builtin(position) @size(16) member: vec4, } const c_scale: f32 = 1.2; diff --git a/tests/out/wgsl/shadow.wgsl b/tests/out/wgsl/shadow.wgsl index 8000e785ff..afcb92d08e 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, + @size(64) view_proj: mat4x4, + @size(16) num_lights: vec4, } struct Entity { - world: mat4x4, - color: vec4, + @size(64) world: mat4x4, + @size(16) color: vec4, } struct VertexOutput { - @builtin(position) proj_position: vec4, - @location(0) world_normal: vec3, - @location(1) world_position: vec4, + @builtin(position) @size(16) proj_position: vec4, + @location(0) @size(16) world_normal: vec3, + @location(1) @size(16) world_position: vec4, } struct Light { - proj: mat4x4, - pos: vec4, - color: vec4, + @size(64) proj: mat4x4, + @size(16) pos: vec4, + @size(16) color: vec4, } const c_ambient: vec3 = vec3(0.05, 0.05, 0.05); diff --git a/tests/out/wgsl/skybox.wgsl b/tests/out/wgsl/skybox.wgsl index 73d4da78a4..48008bb16a 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) @size(16) position: vec4, + @location(0) @size(16) uv: vec3, } struct Data { - proj_inv: mat4x4, - view: mat4x4, + @size(64) proj_inv: mat4x4, + @size(64) view: mat4x4, } @group(0) @binding(0) diff --git a/tests/out/wgsl/workgroup-var-init.wgsl b/tests/out/wgsl/workgroup-var-init.wgsl index fdad0477d6..b0fb66dee4 100644 --- a/tests/out/wgsl/workgroup-var-init.wgsl +++ b/tests/out/wgsl/workgroup-var-init.wgsl @@ -1,7 +1,7 @@ struct WStruct { - arr: array, - atom: atomic, - atom_arr: array, 8>, 8>, + @size(2048) arr: array, + @size(4) atom: atomic, + @size(256) atom_arr: array, 8>, 8>, } var w_mem: WStruct;