From a2c9a1c6a1e5fe4f58a6db74648cf37635abc6cc Mon Sep 17 00:00:00 2001 From: teoxoy <28601907+teoxoy@users.noreply.github.com> Date: Tue, 5 May 2026 15:55:07 +0200 Subject: [PATCH] [hlsl] handle `matCx2` in the uniform address space properly --- naga/src/back/hlsl/help.rs | 42 +- naga/src/back/hlsl/writer.rs | 43 +- naga/tests/in/wgsl/mat_cx2_f16.toml | 8 + naga/tests/in/wgsl/mat_cx2_f16.wgsl | 242 ++++ naga/tests/out/hlsl/wgsl-access.hlsl | 36 +- naga/tests/out/hlsl/wgsl-globals.hlsl | 20 +- naga/tests/out/hlsl/wgsl-mat_cx2.hlsl | 30 +- naga/tests/out/hlsl/wgsl-mat_cx2_f16.hlsl | 568 ++++++++ naga/tests/out/hlsl/wgsl-mat_cx2_f16.ron | 16 + naga/tests/out/spv/wgsl-mat_cx2_f16.spvasm | 1416 ++++++++++++++++++++ 10 files changed, 2351 insertions(+), 70 deletions(-) create mode 100644 naga/tests/in/wgsl/mat_cx2_f16.toml create mode 100644 naga/tests/in/wgsl/mat_cx2_f16.wgsl create mode 100644 naga/tests/out/hlsl/wgsl-mat_cx2_f16.hlsl create mode 100644 naga/tests/out/hlsl/wgsl-mat_cx2_f16.ron create mode 100644 naga/tests/out/spv/wgsl-mat_cx2_f16.spvasm diff --git a/naga/src/back/hlsl/help.rs b/naga/src/back/hlsl/help.rs index 60e63ebe5..d8e60f1d8 100644 --- a/naga/src/back/hlsl/help.rs +++ b/naga/src/back/hlsl/help.rs @@ -78,6 +78,7 @@ pub(super) struct WrappedStructMatrixAccess { #[derive(Clone, Copy, Debug, Hash, Eq, Ord, PartialEq, PartialOrd)] pub(super) struct WrappedMatCx2 { pub(super) columns: crate::VectorSize, + pub(super) width: u8, } #[derive(Clone, Copy, Debug, Hash, Eq, Ord, PartialEq, PartialOrd)] @@ -838,13 +839,17 @@ impl super::Writer<'_, W> { if let Some(super::writer::MatrixType { columns, rows: crate::VectorSize::Bi, - width: 4, + width, }) = super::writer::get_inner_matrix_data(module, member.ty) { write!( self.out, - "{}{}.{} = (__mat{}x2", - INDENT, RETURN_VARIABLE_NAME, field_name, columns as u8 + "{}{}.{} = (__mat{}x2_f{}", + INDENT, + RETURN_VARIABLE_NAME, + field_name, + columns as u8, + width * 8 )?; if let crate::TypeInner::Array { base, size, .. } = *other { self.write_array_size(module, base, size)?; @@ -2141,35 +2146,42 @@ impl super::Writer<'_, W> { pub(super) fn write_mat_cx2_typedef_and_functions( &mut self, - WrappedMatCx2 { columns }: WrappedMatCx2, + WrappedMatCx2 { columns, width }: WrappedMatCx2, ) -> BackendResult { use crate::back::INDENT; + let bit_width = width * 8; + let type_name = crate::Scalar { + kind: ScalarKind::Float, + width, + } + .to_hlsl_str()?; + // typedef write!(self.out, "typedef struct {{ ")?; for i in 0..columns as u8 { - write!(self.out, "float2 _{i}; ")?; + write!(self.out, "{type_name}2 _{i}; ")?; } - writeln!(self.out, "}} __mat{}x2;", columns as u8)?; + writeln!(self.out, "}} __mat{}x2_f{bit_width};", columns as u8)?; // __get_col_of_mat writeln!( self.out, - "float2 __get_col_of_mat{}x2(__mat{}x2 mat, uint idx) {{", + "{type_name}2 __get_col_of_mat{}x2_f{bit_width}(__mat{}x2_f{bit_width} mat, uint idx) {{", columns as u8, columns as u8 )?; writeln!(self.out, "{INDENT}switch(idx) {{")?; for i in 0..columns as u8 { writeln!(self.out, "{INDENT}case {i}: {{ return mat._{i}; }}")?; } - writeln!(self.out, "{INDENT}default: {{ return (float2)0; }}")?; + writeln!(self.out, "{INDENT}default: {{ return ({type_name}2)0; }}")?; writeln!(self.out, "{INDENT}}}")?; writeln!(self.out, "}}")?; // __set_col_of_mat writeln!( self.out, - "void __set_col_of_mat{}x2(__mat{}x2 mat, uint idx, float2 value) {{", + "void __set_col_of_mat{}x2_f{bit_width}(__mat{}x2_f{bit_width} mat, uint idx, {type_name}2 value) {{", columns as u8, columns as u8 )?; writeln!(self.out, "{INDENT}switch(idx) {{")?; @@ -2182,7 +2194,7 @@ impl super::Writer<'_, W> { // __set_el_of_mat writeln!( self.out, - "void __set_el_of_mat{}x2(__mat{}x2 mat, uint idx, uint vec_idx, float value) {{", + "void __set_el_of_mat{}x2_f{bit_width}(__mat{}x2_f{bit_width} mat, uint idx, uint vec_idx, {type_name} value) {{", columns as u8, columns as u8 )?; writeln!(self.out, "{INDENT}switch(idx) {{")?; @@ -2211,10 +2223,10 @@ impl super::Writer<'_, W> { if let Some(super::writer::MatrixType { columns, rows: crate::VectorSize::Bi, - width: 4, + width, }) = super::writer::get_inner_matrix_data(module, global.ty) { - let entry = WrappedMatCx2 { columns }; + let entry = WrappedMatCx2 { columns, width }; if self.wrapped.insert(WrappedType::MatCx2(entry)) { self.write_mat_cx2_typedef_and_functions(entry)?; } @@ -2229,10 +2241,10 @@ impl super::Writer<'_, W> { if let Some(super::writer::MatrixType { columns, rows: crate::VectorSize::Bi, - width: 4, + width, }) = super::writer::get_inner_matrix_data(module, member.ty) { - let entry = WrappedMatCx2 { columns }; + let entry = WrappedMatCx2 { columns, width }; if self.wrapped.insert(WrappedType::MatCx2(entry)) { self.write_mat_cx2_typedef_and_functions(entry)?; } @@ -2267,7 +2279,7 @@ impl super::Writer<'_, W> { /// /// ```text /// tests\out\hlsl\access.hlsl:183:41: error: cannot compile this l-value expression yet - /// t_1.am = (__mat4x2[2])((float4x2[2])0); + /// t_1.am = (__mat4x2_f32[2])((float4x2[2])0); /// ^ /// ``` fn write_wrapped_zero_value_function( diff --git a/naga/src/back/hlsl/writer.rs b/naga/src/back/hlsl/writer.rs index 3971fb2e7..97a398efa 100644 --- a/naga/src/back/hlsl/writer.rs +++ b/naga/src/back/hlsl/writer.rs @@ -1519,10 +1519,10 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> { if let Some(MatrixType { columns, rows: crate::VectorSize::Bi, - width: 4, + width, }) = matrix_data { - write!(self.out, "__mat{}x2", columns as u8)?; + write!(self.out, "__mat{}x2_f{}", columns as u8, width * 8)?; } else { // Even though Naga IR matrices are column-major, we must describe // matrices passed from the CPU as being in row-major order. @@ -2380,6 +2380,7 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> { }, Struct { columns: crate::VectorSize, + width: u8, base: Handle, }, } @@ -2422,7 +2423,7 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> { if let Some(MatrixType { columns, rows: crate::VectorSize::Bi, - width: 4, + width, }) = get_inner_matrix_of_struct_array_member( module, matrix_expr, @@ -2432,6 +2433,7 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> { Some(( MatrixAccess::Struct { columns, + width, base: matrix_expr, }, vector, @@ -2507,7 +2509,11 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> { } } Some(( - MatrixAccess::Struct { columns, base }, + MatrixAccess::Struct { + columns, + width, + base, + }, Some(Index::Expression(vec_index)), scalar, )) => { @@ -2515,9 +2521,19 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> { // the previously injected functions __set_col_of_matCx2 / __set_el_of_matCx2. if scalar.is_some() { - write!(self.out, "__set_el_of_mat{}x2", columns as u8)?; + write!( + self.out, + "__set_el_of_mat{}x2_f{}", + columns as u8, + width * 8 + )?; } else { - write!(self.out, "__set_col_of_mat{}x2", columns as u8)?; + write!( + self.out, + "__set_col_of_mat{}x2_f{}", + columns as u8, + width * 8 + )?; } write!(self.out, "(")?; self.write_expr(module, base, func_ctx)?; @@ -2547,7 +2563,7 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> { if let Some(MatrixType { columns, rows: crate::VectorSize::Bi, - width: 4, + width, }) = get_inner_matrix_of_struct_array_member( module, pointer, func_ctx, false, ) { @@ -2556,7 +2572,7 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> { resolved = &module.types[base].inner; } - write!(self.out, "(__mat{}x2", columns as u8)?; + write!(self.out, "(__mat{}x2_f{}", columns as u8, width * 8)?; if let TypeInner::Array { base, size, .. } = *resolved { self.write_array_size(module, base, size)?; } @@ -3336,13 +3352,18 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> { if let Some(MatrixType { columns, rows: crate::VectorSize::Bi, - width: 4, + width, }) = get_inner_matrix_of_struct_array_member(module, base, func_ctx, true) .or_else(|| { get_inner_matrix_of_global_uniform(module, base, func_ctx, true) }) { - write!(self.out, "__get_col_of_mat{}x2(", columns as u8)?; + write!( + self.out, + "__get_col_of_mat{}x2_f{}(", + columns as u8, + width * 8 + )?; self.write_expr(module, base, func_ctx)?; write!(self.out, ", ")?; self.write_expr(module, index, func_ctx)?; @@ -3461,7 +3482,6 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> { // __matCx2 struct. if let Some(MatrixType { rows: crate::VectorSize::Bi, - width: 4, .. }) = get_inner_matrix_of_struct_array_member(module, base, func_ctx, true) .or_else(|| { @@ -3810,7 +3830,6 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> { // - a (possibly nested) array of __matCx2's if let Some(MatrixType { rows: crate::VectorSize::Bi, - width: 4, .. }) = get_inner_matrix_of_struct_array_member( module, pointer, func_ctx, false, diff --git a/naga/tests/in/wgsl/mat_cx2_f16.toml b/naga/tests/in/wgsl/mat_cx2_f16.toml new file mode 100644 index 000000000..53fde1547 --- /dev/null +++ b/naga/tests/in/wgsl/mat_cx2_f16.toml @@ -0,0 +1,8 @@ +capabilities = "SHADER_FLOAT16" +targets = "HLSL | SPIRV" + +[hlsl] +shader_model = "V6_2" + +[spv] +debug = true diff --git a/naga/tests/in/wgsl/mat_cx2_f16.wgsl b/naga/tests/in/wgsl/mat_cx2_f16.wgsl new file mode 100644 index 000000000..d9486a5ec --- /dev/null +++ b/naga/tests/in/wgsl/mat_cx2_f16.wgsl @@ -0,0 +1,242 @@ +// Test handling of N-by-2 matrices. +// See the doc comments on `naga::back::hlsl` and `naga::back::spv` for details. +// +// There are additional tests in `access.wgsl`. +// +// Tests that we don't apply this handling to other sizes are in mat_cx3.wgsl. + +// Access type (3rd item in variable names) +// S = Struct +// M = Matrix +// C = Column +// E = Element + +// Index type (4th item in variable names) +// C = Constant +// V = Variable + +enable f16; + +alias Mat = mat4x2; + +@group(0) @binding(0) +var s_m: Mat; + +@group(0) @binding(1) +var u_m: Mat; + +fn access_m() { + var idx = 1; + idx--; + + // loads from storage + let l_s_m = s_m; + let l_s_c_c = s_m[0]; + let l_s_c_v = s_m[idx]; + let l_s_e_cc = s_m[0][0]; + let l_s_e_cv = s_m[0][idx]; + let l_s_e_vc = s_m[idx][0]; + let l_s_e_vv = s_m[idx][idx]; + + // loads from uniform + let l_u_m = u_m; + let l_u_c_c = u_m[0]; + let l_u_c_v = u_m[idx]; + let l_u_e_cc = u_m[0][0]; + let l_u_e_cv = u_m[0][idx]; + let l_u_e_vc = u_m[idx][0]; + let l_u_e_vv = u_m[idx][idx]; + + // stores to storage + s_m = l_u_m; + s_m[0] = l_u_c_c; + s_m[idx] = l_u_c_v; + s_m[0][0] = l_u_e_cc; + s_m[0][idx] = l_u_e_cv; + s_m[idx][0] = l_u_e_vc; + s_m[idx][idx] = l_u_e_vv; +} + +struct StructWithMat { + m: Mat, +} + +@group(1) @binding(0) +var s_sm: StructWithMat; + +@group(1) @binding(1) +var u_sm: StructWithMat; + +fn access_sm() { + var idx = 1; + idx--; + + // loads from storage + let l_s_s = s_sm; + let l_s_m = s_sm.m; + let l_s_c_c = s_sm.m[0]; + let l_s_c_v = s_sm.m[idx]; + let l_s_e_cc = s_sm.m[0][0]; + let l_s_e_cv = s_sm.m[0][idx]; + let l_s_e_vc = s_sm.m[idx][0]; + let l_s_e_vv = s_sm.m[idx][idx]; + + // loads from uniform + let l_u_s = u_sm; + let l_u_m = u_sm.m; + let l_u_c_c = u_sm.m[0]; + let l_u_c_v = u_sm.m[idx]; + let l_u_e_cc = u_sm.m[0][0]; + let l_u_e_cv = u_sm.m[0][idx]; + let l_u_e_vc = u_sm.m[idx][0]; + let l_u_e_vv = u_sm.m[idx][idx]; + + // stores to storage + s_sm = l_u_s; + s_sm.m = l_u_m; + s_sm.m[0] = l_u_c_c; + s_sm.m[idx] = l_u_c_v; + s_sm.m[0][0] = l_u_e_cc; + s_sm.m[0][idx] = l_u_e_cv; + s_sm.m[idx][0] = l_u_e_vc; + s_sm.m[idx][idx] = l_u_e_vv; +} + +@group(2) @binding(0) +var s_am: array; + +@group(2) @binding(1) +var u_am: array; + +fn access_am() { + var idx = 1; + idx--; + + // loads from storage + let l_s_a = s_am; + let l_s_m_c = s_am[0]; + let l_s_m_v = s_am[idx]; + let l_s_c_cc = s_am[0][0]; + let l_s_c_cv = s_am[0][idx]; + let l_s_c_vc = s_am[idx][0]; + let l_s_c_vv = s_am[idx][idx]; + let l_s_e_ccc = s_am[0][0][0]; + let l_s_e_ccv = s_am[0][0][idx]; + let l_s_e_cvc = s_am[0][idx][0]; + let l_s_e_cvv = s_am[0][idx][idx]; + let l_s_e_vcc = s_am[idx][0][0]; + let l_s_e_vcv = s_am[idx][0][idx]; + let l_s_e_vvc = s_am[idx][idx][0]; + let l_s_e_vvv = s_am[idx][idx][idx]; + + // loads from uniform + let l_u_a = u_am; + let l_u_m_c = u_am[0]; + let l_u_m_v = u_am[idx]; + let l_u_c_cc = u_am[0][0]; + let l_u_c_cv = u_am[0][idx]; + let l_u_c_vc = u_am[idx][0]; + let l_u_c_vv = u_am[idx][idx]; + let l_u_e_ccc = u_am[0][0][0]; + let l_u_e_ccv = u_am[0][0][idx]; + let l_u_e_cvc = u_am[0][idx][0]; + let l_u_e_cvv = u_am[0][idx][idx]; + let l_u_e_vcc = u_am[idx][0][0]; + let l_u_e_vcv = u_am[idx][0][idx]; + let l_u_e_vvc = u_am[idx][idx][0]; + let l_u_e_vvv = u_am[idx][idx][idx]; + + // stores to storage + s_am = l_u_a; + s_am[0] = l_u_m_c; + s_am[idx] = l_u_m_v; + s_am[0][0] = l_u_c_cc; + s_am[0][idx] = l_u_c_cv; + s_am[idx][0] = l_u_c_vc; + s_am[idx][idx] = l_u_c_vv; + s_am[0][0][0] = l_u_e_ccc; + s_am[0][0][idx] = l_u_e_ccv; + s_am[0][idx][0] = l_u_e_cvc; + s_am[0][idx][idx] = l_u_e_cvv; + s_am[idx][0][0] = l_u_e_vcc; + s_am[idx][0][idx] = l_u_e_vcv; + s_am[idx][idx][0] = l_u_e_vvc; + s_am[idx][idx][idx] = l_u_e_vvv; +} + +struct StructWithArrayOfStructOfMat { + a: array, +} + +@group(3) @binding(0) +var s_sasm: StructWithArrayOfStructOfMat; + +@group(3) @binding(1) +var u_sasm: StructWithArrayOfStructOfMat; + +fn access_sasm() { + var idx = 1; + idx--; + + // loads from storage + let l_s_s = s_sasm; + let l_s_a = s_sasm.a; + let l_s_m_c = s_sasm.a[0].m; + let l_s_m_v = s_sasm.a[idx].m; + let l_s_c_cc = s_sasm.a[0].m[0]; + let l_s_c_cv = s_sasm.a[0].m[idx]; + let l_s_c_vc = s_sasm.a[idx].m[0]; + let l_s_c_vv = s_sasm.a[idx].m[idx]; + let l_s_e_ccc = s_sasm.a[0].m[0][0]; + let l_s_e_ccv = s_sasm.a[0].m[0][idx]; + let l_s_e_cvc = s_sasm.a[0].m[idx][0]; + let l_s_e_cvv = s_sasm.a[0].m[idx][idx]; + let l_s_e_vcc = s_sasm.a[idx].m[0][0]; + let l_s_e_vcv = s_sasm.a[idx].m[0][idx]; + let l_s_e_vvc = s_sasm.a[idx].m[idx][0]; + let l_s_e_vvv = s_sasm.a[idx].m[idx][idx]; + + // loads from uniform + let l_u_s = u_sasm; + let l_u_a = u_sasm.a; + let l_u_m_c = u_sasm.a[0].m; + let l_u_m_v = u_sasm.a[idx].m; + let l_u_c_cc = u_sasm.a[0].m[0]; + let l_u_c_cv = u_sasm.a[0].m[idx]; + let l_u_c_vc = u_sasm.a[idx].m[0]; + let l_u_c_vv = u_sasm.a[idx].m[idx]; + let l_u_e_ccc = u_sasm.a[0].m[0][0]; + let l_u_e_ccv = u_sasm.a[0].m[0][idx]; + let l_u_e_cvc = u_sasm.a[0].m[idx][0]; + let l_u_e_cvv = u_sasm.a[0].m[idx][idx]; + let l_u_e_vcc = u_sasm.a[idx].m[0][0]; + let l_u_e_vcv = u_sasm.a[idx].m[0][idx]; + let l_u_e_vvc = u_sasm.a[idx].m[idx][0]; + let l_u_e_vvv = u_sasm.a[idx].m[idx][idx]; + + // stores to storage + s_sasm = l_u_s; + s_sasm.a = l_u_a; + s_sasm.a[0].m = l_u_m_c; + s_sasm.a[idx].m = l_u_m_v; + s_sasm.a[0].m[0] = l_u_c_cc; + s_sasm.a[0].m[idx] = l_u_c_cv; + s_sasm.a[idx].m[0] = l_u_c_vc; + s_sasm.a[idx].m[idx] = l_u_c_vv; + s_sasm.a[0].m[0][0] = l_u_e_ccc; + s_sasm.a[0].m[0][idx] = l_u_e_ccv; + s_sasm.a[0].m[idx][0] = l_u_e_cvc; + s_sasm.a[0].m[idx][idx] = l_u_e_cvv; + s_sasm.a[idx].m[0][0] = l_u_e_vcc; + s_sasm.a[idx].m[0][idx] = l_u_e_vcv; + s_sasm.a[idx].m[idx][0] = l_u_e_vvc; + s_sasm.a[idx].m[idx][idx] = l_u_e_vvv; +} + +@compute @workgroup_size(1) +fn main() { + access_m(); + access_sm(); + access_am(); + access_sasm(); +} diff --git a/naga/tests/out/hlsl/wgsl-access.hlsl b/naga/tests/out/hlsl/wgsl-access.hlsl index 9b418b5fa..bfe408356 100644 --- a/naga/tests/out/hlsl/wgsl-access.hlsl +++ b/naga/tests/out/hlsl/wgsl-access.hlsl @@ -1,26 +1,26 @@ -typedef struct { float2 _0; float2 _1; } __mat2x2; -float2 __get_col_of_mat2x2(__mat2x2 mat, uint idx) { +typedef struct { float2 _0; float2 _1; } __mat2x2_f32; +float2 __get_col_of_mat2x2_f32(__mat2x2_f32 mat, uint idx) { switch(idx) { case 0: { return mat._0; } case 1: { return mat._1; } default: { return (float2)0; } } } -void __set_col_of_mat2x2(__mat2x2 mat, uint idx, float2 value) { +void __set_col_of_mat2x2_f32(__mat2x2_f32 mat, uint idx, float2 value) { switch(idx) { case 0: { mat._0 = value; break; } case 1: { mat._1 = value; break; } } } -void __set_el_of_mat2x2(__mat2x2 mat, uint idx, uint vec_idx, float value) { +void __set_el_of_mat2x2_f32(__mat2x2_f32 mat, uint idx, uint vec_idx, float value) { switch(idx) { case 0: { mat._0[vec_idx] = value; break; } case 1: { mat._1[vec_idx] = value; break; } } } -typedef struct { float2 _0; float2 _1; float2 _2; float2 _3; } __mat4x2; -float2 __get_col_of_mat4x2(__mat4x2 mat, uint idx) { +typedef struct { float2 _0; float2 _1; float2 _2; float2 _3; } __mat4x2_f32; +float2 __get_col_of_mat4x2_f32(__mat4x2_f32 mat, uint idx) { switch(idx) { case 0: { return mat._0; } case 1: { return mat._1; } @@ -29,7 +29,7 @@ float2 __get_col_of_mat4x2(__mat4x2 mat, uint idx) { default: { return (float2)0; } } } -void __set_col_of_mat4x2(__mat4x2 mat, uint idx, float2 value) { +void __set_col_of_mat4x2_f32(__mat4x2_f32 mat, uint idx, float2 value) { switch(idx) { case 0: { mat._0 = value; break; } case 1: { mat._1 = value; break; } @@ -37,7 +37,7 @@ void __set_col_of_mat4x2(__mat4x2 mat, uint idx, float2 value) { case 3: { mat._3 = value; break; } } } -void __set_el_of_mat4x2(__mat4x2 mat, uint idx, uint vec_idx, float value) { +void __set_el_of_mat4x2_f32(__mat4x2_f32 mat, uint idx, uint vec_idx, float value) { switch(idx) { case 0: { mat._0[vec_idx] = value; break; } case 1: { mat._1[vec_idx] = value; break; } @@ -65,7 +65,7 @@ struct Baz { }; struct MatCx2InArray { - __mat4x2 am[2]; + __mat4x2_f32 am[2]; }; struct AssignToMember { @@ -171,7 +171,7 @@ void test_matrix_within_struct_accesses() MatCx2InArray ConstructMatCx2InArray(float4x2 arg0[2]) { MatCx2InArray ret = (MatCx2InArray)0; - ret.am = (__mat4x2[2])arg0; + ret.am = (__mat4x2_f32[2])arg0; return ret; } @@ -191,30 +191,30 @@ void test_matrix_within_array_within_struct_accesses() float4x2 l1_1 = ((float4x2)nested_mat_cx2_.am[0]); float2 l2_1 = nested_mat_cx2_.am[0]._0; int _e20 = idx_1; - float2 l3_1 = __get_col_of_mat4x2(nested_mat_cx2_.am[0], _e20); + float2 l3_1 = __get_col_of_mat4x2_f32(nested_mat_cx2_.am[0], _e20); float l4_1 = nested_mat_cx2_.am[0]._0.y; int _e33 = idx_1; float l5_1 = nested_mat_cx2_.am[0]._0[_e33]; int _e39 = idx_1; - float l6_1 = __get_col_of_mat4x2(nested_mat_cx2_.am[0], _e39).y; + float l6_1 = __get_col_of_mat4x2_f32(nested_mat_cx2_.am[0], _e39).y; int _e46 = idx_1; int _e48 = idx_1; - float l7_ = __get_col_of_mat4x2(nested_mat_cx2_.am[0], _e46)[_e48]; + float l7_ = __get_col_of_mat4x2_f32(nested_mat_cx2_.am[0], _e46)[_e48]; int _e55 = idx_1; idx_1 = asint(asuint(_e55) + asuint(int(1))); - t_1.am = (__mat4x2[2])ZeroValuearray2_float4x2_(); - t_1.am[0] = (__mat4x2)float4x2((8.0).xx, (7.0).xx, (6.0).xx, (5.0).xx); + t_1.am = (__mat4x2_f32[2])ZeroValuearray2_float4x2_(); + t_1.am[0] = (__mat4x2_f32)float4x2((8.0).xx, (7.0).xx, (6.0).xx, (5.0).xx); t_1.am[0]._0 = (9.0).xx; int _e77 = idx_1; - __set_col_of_mat4x2(t_1.am[0], _e77, (90.0).xx); + __set_col_of_mat4x2_f32(t_1.am[0], _e77, (90.0).xx); t_1.am[0]._0.y = 10.0; int _e89 = idx_1; t_1.am[0]._0[min(uint(_e89), 1u)] = 20.0; int _e94 = idx_1; - __set_el_of_mat4x2(t_1.am[0], _e94, 1, 30.0); + __set_el_of_mat4x2_f32(t_1.am[0], _e94, 1, 30.0); int _e100 = idx_1; int _e102 = idx_1; - __set_el_of_mat4x2(t_1.am[0], _e100, _e102, 40.0); + __set_el_of_mat4x2_f32(t_1.am[0], _e100, _e102, 40.0); return; } diff --git a/naga/tests/out/hlsl/wgsl-globals.hlsl b/naga/tests/out/hlsl/wgsl-globals.hlsl index 30035fd61..2a5bf9efd 100644 --- a/naga/tests/out/hlsl/wgsl-globals.hlsl +++ b/naga/tests/out/hlsl/wgsl-globals.hlsl @@ -1,5 +1,5 @@ -typedef struct { float2 _0; float2 _1; float2 _2; } __mat3x2; -float2 __get_col_of_mat3x2(__mat3x2 mat, uint idx) { +typedef struct { float2 _0; float2 _1; float2 _2; } __mat3x2_f32; +float2 __get_col_of_mat3x2_f32(__mat3x2_f32 mat, uint idx) { switch(idx) { case 0: { return mat._0; } case 1: { return mat._1; } @@ -7,14 +7,14 @@ float2 __get_col_of_mat3x2(__mat3x2 mat, uint idx) { default: { return (float2)0; } } } -void __set_col_of_mat3x2(__mat3x2 mat, uint idx, float2 value) { +void __set_col_of_mat3x2_f32(__mat3x2_f32 mat, uint idx, float2 value) { switch(idx) { case 0: { mat._0 = value; break; } case 1: { mat._1 = value; break; } case 2: { mat._2 = value; break; } } } -void __set_el_of_mat3x2(__mat3x2 mat, uint idx, uint vec_idx, float value) { +void __set_el_of_mat3x2_f32(__mat3x2_f32 mat, uint idx, uint vec_idx, float value) { switch(idx) { case 0: { mat._0[vec_idx] = value; break; } case 1: { mat._1[vec_idx] = value; break; } @@ -22,8 +22,8 @@ void __set_el_of_mat3x2(__mat3x2 mat, uint idx, uint vec_idx, float value) { } } -typedef struct { float2 _0; float2 _1; float2 _2; float2 _3; } __mat4x2; -float2 __get_col_of_mat4x2(__mat4x2 mat, uint idx) { +typedef struct { float2 _0; float2 _1; float2 _2; float2 _3; } __mat4x2_f32; +float2 __get_col_of_mat4x2_f32(__mat4x2_f32 mat, uint idx) { switch(idx) { case 0: { return mat._0; } case 1: { return mat._1; } @@ -32,7 +32,7 @@ float2 __get_col_of_mat4x2(__mat4x2 mat, uint idx) { default: { return (float2)0; } } } -void __set_col_of_mat4x2(__mat4x2 mat, uint idx, float2 value) { +void __set_col_of_mat4x2_f32(__mat4x2_f32 mat, uint idx, float2 value) { switch(idx) { case 0: { mat._0 = value; break; } case 1: { mat._1 = value; break; } @@ -40,7 +40,7 @@ void __set_col_of_mat4x2(__mat4x2 mat, uint idx, float2 value) { case 3: { mat._3 = value; break; } } } -void __set_el_of_mat4x2(__mat4x2 mat, uint idx, uint vec_idx, float value) { +void __set_el_of_mat4x2_f32(__mat4x2_f32 mat, uint idx, uint vec_idx, float value) { switch(idx) { case 0: { mat._0[vec_idx] = value; break; } case 1: { mat._1[vec_idx] = value; break; } @@ -62,9 +62,9 @@ RWByteAddressBuffer alignment : register(u1); ByteAddressBuffer dummy : register(t2); cbuffer float_vecs : register(b3) { float4 float_vecs[20]; } cbuffer global_vec : register(b4) { float3 global_vec; } -cbuffer global_mat : register(b5) { __mat3x2 global_mat; } +cbuffer global_mat : register(b5) { __mat3x2_f32 global_mat; } cbuffer global_nested_arrays_of_matrices_2x4_ : register(b6) { row_major float2x4 global_nested_arrays_of_matrices_2x4_[2][2]; } -cbuffer global_nested_arrays_of_matrices_4x2_ : register(b7) { __mat4x2 global_nested_arrays_of_matrices_4x2_[2][2]; } +cbuffer global_nested_arrays_of_matrices_4x2_ : register(b7) { __mat4x2_f32 global_nested_arrays_of_matrices_4x2_[2][2]; } void test_msl_packed_vec3_as_arg(float3 arg) { diff --git a/naga/tests/out/hlsl/wgsl-mat_cx2.hlsl b/naga/tests/out/hlsl/wgsl-mat_cx2.hlsl index 30be83d22..6f2284ceb 100644 --- a/naga/tests/out/hlsl/wgsl-mat_cx2.hlsl +++ b/naga/tests/out/hlsl/wgsl-mat_cx2.hlsl @@ -1,18 +1,18 @@ -typedef struct { float2 _0; float2 _1; } __mat2x2; -float2 __get_col_of_mat2x2(__mat2x2 mat, uint idx) { +typedef struct { float2 _0; float2 _1; } __mat2x2_f32; +float2 __get_col_of_mat2x2_f32(__mat2x2_f32 mat, uint idx) { switch(idx) { case 0: { return mat._0; } case 1: { return mat._1; } default: { return (float2)0; } } } -void __set_col_of_mat2x2(__mat2x2 mat, uint idx, float2 value) { +void __set_col_of_mat2x2_f32(__mat2x2_f32 mat, uint idx, float2 value) { switch(idx) { case 0: { mat._0 = value; break; } case 1: { mat._1 = value; break; } } } -void __set_el_of_mat2x2(__mat2x2 mat, uint idx, uint vec_idx, float value) { +void __set_el_of_mat2x2_f32(__mat2x2_f32 mat, uint idx, uint vec_idx, float value) { switch(idx) { case 0: { mat._0[vec_idx] = value; break; } case 1: { mat._1[vec_idx] = value; break; } @@ -28,11 +28,11 @@ struct StructWithArrayOfStructOfMat { }; RWByteAddressBuffer s_m : register(u0); -cbuffer u_m : register(b1) { __mat2x2 u_m; } +cbuffer u_m : register(b1) { __mat2x2_f32 u_m; } RWByteAddressBuffer s_sm : register(u0, space1); cbuffer u_sm : register(b1, space1) { StructWithMat u_sm; } RWByteAddressBuffer s_am : register(u0, space2); -cbuffer u_am : register(b1, space2) { __mat2x2 u_am[4]; } +cbuffer u_am : register(b1, space2) { __mat2x2_f32 u_am[4]; } RWByteAddressBuffer s_sasm : register(u0, space3); cbuffer u_sasm : register(b1, space3) { StructWithArrayOfStructOfMat u_sasm; } @@ -57,15 +57,15 @@ void access_m() float2x2 l_u_m = ((float2x2)u_m); float2 l_u_c_c = u_m._0; int _e40 = idx; - float2 l_u_c_v = __get_col_of_mat2x2(u_m, _e40); + float2 l_u_c_v = __get_col_of_mat2x2_f32(u_m, _e40); float l_u_e_cc = u_m._0.x; int _e49 = idx; float l_u_e_cv = u_m._0[_e49]; int _e53 = idx; - float l_u_e_vc = __get_col_of_mat2x2(u_m, _e53).x; + float l_u_e_vc = __get_col_of_mat2x2_f32(u_m, _e53).x; int _e58 = idx; int _e60 = idx; - float l_u_e_vv = __get_col_of_mat2x2(u_m, _e58)[_e60]; + float l_u_e_vv = __get_col_of_mat2x2_f32(u_m, _e58)[_e60]; { float2x2 _value2 = l_u_m; s_m.Store2(0, asuint(_value2[0])); @@ -223,20 +223,20 @@ void access_am() float2x2 l_u_m_v = ((float2x2)u_am[_e92]); float2 l_u_c_cc = u_am[0]._0; int _e101 = idx_2; - float2 l_u_c_cv = __get_col_of_mat2x2(u_am[0], _e101); + float2 l_u_c_cv = __get_col_of_mat2x2_f32(u_am[0], _e101); int _e105 = idx_2; float2 l_u_c_vc = u_am[_e105]._0; int _e110 = idx_2; int _e112 = idx_2; - float2 l_u_c_vv = __get_col_of_mat2x2(u_am[_e110], _e112); + float2 l_u_c_vv = __get_col_of_mat2x2_f32(u_am[_e110], _e112); float l_u_e_ccc = u_am[0]._0.x; int _e123 = idx_2; float l_u_e_ccv = u_am[0]._0[_e123]; int _e128 = idx_2; - float l_u_e_cvc = __get_col_of_mat2x2(u_am[0], _e128).x; + float l_u_e_cvc = __get_col_of_mat2x2_f32(u_am[0], _e128).x; int _e134 = idx_2; int _e136 = idx_2; - float l_u_e_cvv = __get_col_of_mat2x2(u_am[0], _e134)[_e136]; + float l_u_e_cvv = __get_col_of_mat2x2_f32(u_am[0], _e134)[_e136]; int _e140 = idx_2; float l_u_e_vcc = u_am[_e140]._0.x; int _e146 = idx_2; @@ -244,11 +244,11 @@ void access_am() float l_u_e_vcv = u_am[_e146]._0[_e149]; int _e153 = idx_2; int _e155 = idx_2; - float l_u_e_vvc = __get_col_of_mat2x2(u_am[_e153], _e155).x; + float l_u_e_vvc = __get_col_of_mat2x2_f32(u_am[_e153], _e155).x; int _e160 = idx_2; int _e162 = idx_2; int _e164 = idx_2; - float l_u_e_vvv = __get_col_of_mat2x2(u_am[_e160], _e162)[_e164]; + float l_u_e_vvv = __get_col_of_mat2x2_f32(u_am[_e160], _e162)[_e164]; { float2x2 _value2[4] = l_u_a; { diff --git a/naga/tests/out/hlsl/wgsl-mat_cx2_f16.hlsl b/naga/tests/out/hlsl/wgsl-mat_cx2_f16.hlsl new file mode 100644 index 000000000..a6293def1 --- /dev/null +++ b/naga/tests/out/hlsl/wgsl-mat_cx2_f16.hlsl @@ -0,0 +1,568 @@ +typedef struct { half2 _0; half2 _1; half2 _2; half2 _3; } __mat4x2_f16; +half2 __get_col_of_mat4x2_f16(__mat4x2_f16 mat, uint idx) { + switch(idx) { + case 0: { return mat._0; } + case 1: { return mat._1; } + case 2: { return mat._2; } + case 3: { return mat._3; } + default: { return (half2)0; } + } +} +void __set_col_of_mat4x2_f16(__mat4x2_f16 mat, uint idx, half2 value) { + switch(idx) { + case 0: { mat._0 = value; break; } + case 1: { mat._1 = value; break; } + case 2: { mat._2 = value; break; } + case 3: { mat._3 = value; break; } + } +} +void __set_el_of_mat4x2_f16(__mat4x2_f16 mat, uint idx, uint vec_idx, half value) { + switch(idx) { + case 0: { mat._0[vec_idx] = value; break; } + case 1: { mat._1[vec_idx] = value; break; } + case 2: { mat._2[vec_idx] = value; break; } + case 3: { mat._3[vec_idx] = value; break; } + } +} + +struct StructWithMat { + half2 m_0; half2 m_1; half2 m_2; half2 m_3; +}; + +struct StructWithArrayOfStructOfMat { + StructWithMat a[4]; +}; + +RWByteAddressBuffer s_m : register(u0); +cbuffer u_m : register(b1) { __mat4x2_f16 u_m; } +RWByteAddressBuffer s_sm : register(u0, space1); +cbuffer u_sm : register(b1, space1) { StructWithMat u_sm; } +RWByteAddressBuffer s_am : register(u0, space2); +cbuffer u_am : register(b1, space2) { __mat4x2_f16 u_am[4]; } +RWByteAddressBuffer s_sasm : register(u0, space3); +cbuffer u_sasm : register(b1, space3) { StructWithArrayOfStructOfMat u_sasm; } + +void access_m() +{ + int idx = int(1); + + int _e3 = idx; + idx = asint(asuint(_e3) - asuint(int(1))); + half4x2 l_s_m = half4x2(s_m.Load(0), s_m.Load(4), s_m.Load(8), s_m.Load(12)); + half2 l_s_c_c = s_m.Load(0); + int _e11 = idx; + half2 l_s_c_v = s_m.Load(_e11*4); + half l_s_e_cc = s_m.Load(0+0); + int _e20 = idx; + half l_s_e_cv = s_m.Load(_e20*2+0); + int _e24 = idx; + half l_s_e_vc = s_m.Load(0+_e24*4); + int _e29 = idx; + int _e31 = idx; + half l_s_e_vv = s_m.Load(_e31*2+_e29*4); + half4x2 l_u_m = ((half4x2)u_m); + half2 l_u_c_c = u_m._0; + int _e40 = idx; + half2 l_u_c_v = __get_col_of_mat4x2_f16(u_m, _e40); + half l_u_e_cc = u_m._0.x; + int _e49 = idx; + half l_u_e_cv = u_m._0[_e49]; + int _e53 = idx; + half l_u_e_vc = __get_col_of_mat4x2_f16(u_m, _e53).x; + int _e58 = idx; + int _e60 = idx; + half l_u_e_vv = __get_col_of_mat4x2_f16(u_m, _e58)[_e60]; + { + half4x2 _value2 = l_u_m; + s_m.Store(0, _value2[0]); + s_m.Store(4, _value2[1]); + s_m.Store(8, _value2[2]); + s_m.Store(12, _value2[3]); + } + s_m.Store(0, l_u_c_c); + int _e67 = idx; + s_m.Store(_e67*4, l_u_c_v); + s_m.Store(0+0, l_u_e_cc); + int _e74 = idx; + s_m.Store(_e74*2+0, l_u_e_cv); + int _e77 = idx; + s_m.Store(0+_e77*4, l_u_e_vc); + int _e81 = idx; + int _e83 = idx; + s_m.Store(_e83*2+_e81*4, l_u_e_vv); + return; +} + +StructWithMat ConstructStructWithMat(half4x2 arg0) { + StructWithMat ret = (StructWithMat)0; + ret.m_0 = arg0[0]; + ret.m_1 = arg0[1]; + ret.m_2 = arg0[2]; + ret.m_3 = arg0[3]; + return ret; +} + +half4x2 GetMatmOnStructWithMat(StructWithMat obj) { + return half4x2(obj.m_0, obj.m_1, obj.m_2, obj.m_3); +} + +void SetMatmOnStructWithMat(StructWithMat obj, half4x2 mat) { + obj.m_0 = mat[0]; + obj.m_1 = mat[1]; + obj.m_2 = mat[2]; + obj.m_3 = mat[3]; +} + +void SetMatVecmOnStructWithMat(StructWithMat obj, half2 vec, uint mat_idx) { + switch(mat_idx) { + case 0: { obj.m_0 = vec; break; } + case 1: { obj.m_1 = vec; break; } + case 2: { obj.m_2 = vec; break; } + case 3: { obj.m_3 = vec; break; } + } +} + +void SetMatScalarmOnStructWithMat(StructWithMat obj, half scalar, uint mat_idx, uint vec_idx) { + switch(mat_idx) { + case 0: { obj.m_0[vec_idx] = scalar; break; } + case 1: { obj.m_1[vec_idx] = scalar; break; } + case 2: { obj.m_2[vec_idx] = scalar; break; } + case 3: { obj.m_3[vec_idx] = scalar; break; } + } +} + +void access_sm() +{ + int idx_1 = int(1); + + int _e3 = idx_1; + idx_1 = asint(asuint(_e3) - asuint(int(1))); + StructWithMat l_s_s = ConstructStructWithMat(half4x2(s_sm.Load(0+0), s_sm.Load(0+4), s_sm.Load(0+8), s_sm.Load(0+12))); + half4x2 l_s_m_1 = half4x2(s_sm.Load(0+0), s_sm.Load(0+4), s_sm.Load(0+8), s_sm.Load(0+12)); + half2 l_s_c_c_1 = s_sm.Load(0+0); + int _e16 = idx_1; + half2 l_s_c_v_1 = s_sm.Load(_e16*4+0); + half l_s_e_cc_1 = s_sm.Load(0+0+0); + int _e27 = idx_1; + half l_s_e_cv_1 = s_sm.Load(_e27*2+0+0); + int _e32 = idx_1; + half l_s_e_vc_1 = s_sm.Load(0+_e32*4+0); + int _e38 = idx_1; + int _e40 = idx_1; + half l_s_e_vv_1 = s_sm.Load(_e40*2+_e38*4+0); + StructWithMat l_u_s = u_sm; + half4x2 l_u_m_1 = GetMatmOnStructWithMat(u_sm); + half2 l_u_c_c_1 = GetMatmOnStructWithMat(u_sm)[0]; + int _e54 = idx_1; + half2 l_u_c_v_1 = GetMatmOnStructWithMat(u_sm)[_e54]; + half l_u_e_cc_1 = GetMatmOnStructWithMat(u_sm)[0].x; + int _e65 = idx_1; + half l_u_e_cv_1 = GetMatmOnStructWithMat(u_sm)[0][_e65]; + int _e70 = idx_1; + half l_u_e_vc_1 = GetMatmOnStructWithMat(u_sm)[_e70].x; + int _e76 = idx_1; + int _e78 = idx_1; + half l_u_e_vv_1 = GetMatmOnStructWithMat(u_sm)[_e76][_e78]; + { + StructWithMat _value2 = l_u_s; + { + s_sm.Store(0+0, _value2.m_0); + s_sm.Store(0+4, _value2.m_1); + s_sm.Store(0+8, _value2.m_2); + s_sm.Store(0+12, _value2.m_3); + } + } + { + half4x2 _value2 = l_u_m_1; + s_sm.Store(0+0, _value2[0]); + s_sm.Store(0+4, _value2[1]); + s_sm.Store(0+8, _value2[2]); + s_sm.Store(0+12, _value2[3]); + } + s_sm.Store(0+0, l_u_c_c_1); + int _e89 = idx_1; + s_sm.Store(_e89*4+0, l_u_c_v_1); + s_sm.Store(0+0+0, l_u_e_cc_1); + int _e98 = idx_1; + s_sm.Store(_e98*2+0+0, l_u_e_cv_1); + int _e102 = idx_1; + s_sm.Store(0+_e102*4+0, l_u_e_vc_1); + int _e107 = idx_1; + int _e109 = idx_1; + s_sm.Store(_e109*2+_e107*4+0, l_u_e_vv_1); + return; +} + +typedef half4x2 ret_Constructarray4_half4x2_[4]; +ret_Constructarray4_half4x2_ Constructarray4_half4x2_(half4x2 arg0, half4x2 arg1, half4x2 arg2, half4x2 arg3) { + half4x2 ret[4] = { arg0, arg1, arg2, arg3 }; + return ret; +} + +void access_am() +{ + int idx_2 = int(1); + + int _e3 = idx_2; + idx_2 = asint(asuint(_e3) - asuint(int(1))); + half4x2 l_s_a[4] = Constructarray4_half4x2_(half4x2(s_am.Load(0+0), s_am.Load(0+4), s_am.Load(0+8), s_am.Load(0+12)), half4x2(s_am.Load(16+0), s_am.Load(16+4), s_am.Load(16+8), s_am.Load(16+12)), half4x2(s_am.Load(32+0), s_am.Load(32+4), s_am.Load(32+8), s_am.Load(32+12)), half4x2(s_am.Load(48+0), s_am.Load(48+4), s_am.Load(48+8), s_am.Load(48+12))); + half4x2 l_s_m_c = half4x2(s_am.Load(0+0), s_am.Load(0+4), s_am.Load(0+8), s_am.Load(0+12)); + int _e11 = idx_2; + half4x2 l_s_m_v = half4x2(s_am.Load(_e11*16+0), s_am.Load(_e11*16+4), s_am.Load(_e11*16+8), s_am.Load(_e11*16+12)); + half2 l_s_c_cc = s_am.Load(0+0); + int _e20 = idx_2; + half2 l_s_c_cv = s_am.Load(_e20*4+0); + int _e24 = idx_2; + half2 l_s_c_vc = s_am.Load(0+_e24*16); + int _e29 = idx_2; + int _e31 = idx_2; + half2 l_s_c_vv = s_am.Load(_e31*4+_e29*16); + half l_s_e_ccc = s_am.Load(0+0+0); + int _e42 = idx_2; + half l_s_e_ccv = s_am.Load(_e42*2+0+0); + int _e47 = idx_2; + half l_s_e_cvc = s_am.Load(0+_e47*4+0); + int _e53 = idx_2; + int _e55 = idx_2; + half l_s_e_cvv = s_am.Load(_e55*2+_e53*4+0); + int _e59 = idx_2; + half l_s_e_vcc = s_am.Load(0+0+_e59*16); + int _e65 = idx_2; + int _e68 = idx_2; + half l_s_e_vcv = s_am.Load(_e68*2+0+_e65*16); + int _e72 = idx_2; + int _e74 = idx_2; + half l_s_e_vvc = s_am.Load(0+_e74*4+_e72*16); + int _e79 = idx_2; + int _e81 = idx_2; + int _e83 = idx_2; + half l_s_e_vvv = s_am.Load(_e83*2+_e81*4+_e79*16); + half4x2 l_u_a[4] = ((half4x2[4])u_am); + half4x2 l_u_m_c = ((half4x2)u_am[0]); + int _e92 = idx_2; + half4x2 l_u_m_v = ((half4x2)u_am[_e92]); + half2 l_u_c_cc = u_am[0]._0; + int _e101 = idx_2; + half2 l_u_c_cv = __get_col_of_mat4x2_f16(u_am[0], _e101); + int _e105 = idx_2; + half2 l_u_c_vc = u_am[_e105]._0; + int _e110 = idx_2; + int _e112 = idx_2; + half2 l_u_c_vv = __get_col_of_mat4x2_f16(u_am[_e110], _e112); + half l_u_e_ccc = u_am[0]._0.x; + int _e123 = idx_2; + half l_u_e_ccv = u_am[0]._0[_e123]; + int _e128 = idx_2; + half l_u_e_cvc = __get_col_of_mat4x2_f16(u_am[0], _e128).x; + int _e134 = idx_2; + int _e136 = idx_2; + half l_u_e_cvv = __get_col_of_mat4x2_f16(u_am[0], _e134)[_e136]; + int _e140 = idx_2; + half l_u_e_vcc = u_am[_e140]._0.x; + int _e146 = idx_2; + int _e149 = idx_2; + half l_u_e_vcv = u_am[_e146]._0[_e149]; + int _e153 = idx_2; + int _e155 = idx_2; + half l_u_e_vvc = __get_col_of_mat4x2_f16(u_am[_e153], _e155).x; + int _e160 = idx_2; + int _e162 = idx_2; + int _e164 = idx_2; + half l_u_e_vvv = __get_col_of_mat4x2_f16(u_am[_e160], _e162)[_e164]; + { + half4x2 _value2[4] = l_u_a; + { + half4x2 _value3 = _value2[0]; + s_am.Store(0+0, _value3[0]); + s_am.Store(0+4, _value3[1]); + s_am.Store(0+8, _value3[2]); + s_am.Store(0+12, _value3[3]); + } + { + half4x2 _value3 = _value2[1]; + s_am.Store(16+0, _value3[0]); + s_am.Store(16+4, _value3[1]); + s_am.Store(16+8, _value3[2]); + s_am.Store(16+12, _value3[3]); + } + { + half4x2 _value3 = _value2[2]; + s_am.Store(32+0, _value3[0]); + s_am.Store(32+4, _value3[1]); + s_am.Store(32+8, _value3[2]); + s_am.Store(32+12, _value3[3]); + } + { + half4x2 _value3 = _value2[3]; + s_am.Store(48+0, _value3[0]); + s_am.Store(48+4, _value3[1]); + s_am.Store(48+8, _value3[2]); + s_am.Store(48+12, _value3[3]); + } + } + { + half4x2 _value2 = l_u_m_c; + s_am.Store(0+0, _value2[0]); + s_am.Store(0+4, _value2[1]); + s_am.Store(0+8, _value2[2]); + s_am.Store(0+12, _value2[3]); + } + int _e171 = idx_2; + { + half4x2 _value2 = l_u_m_v; + s_am.Store(_e171*16+0, _value2[0]); + s_am.Store(_e171*16+4, _value2[1]); + s_am.Store(_e171*16+8, _value2[2]); + s_am.Store(_e171*16+12, _value2[3]); + } + s_am.Store(0+0, l_u_c_cc); + int _e178 = idx_2; + s_am.Store(_e178*4+0, l_u_c_cv); + int _e181 = idx_2; + s_am.Store(0+_e181*16, l_u_c_vc); + int _e185 = idx_2; + int _e187 = idx_2; + s_am.Store(_e187*4+_e185*16, l_u_c_vv); + s_am.Store(0+0+0, l_u_e_ccc); + int _e196 = idx_2; + s_am.Store(_e196*2+0+0, l_u_e_ccv); + int _e200 = idx_2; + s_am.Store(0+_e200*4+0, l_u_e_cvc); + int _e205 = idx_2; + int _e207 = idx_2; + s_am.Store(_e207*2+_e205*4+0, l_u_e_cvv); + int _e210 = idx_2; + s_am.Store(0+0+_e210*16, l_u_e_vcc); + int _e215 = idx_2; + int _e218 = idx_2; + s_am.Store(_e218*2+0+_e215*16, l_u_e_vcv); + int _e221 = idx_2; + int _e223 = idx_2; + s_am.Store(0+_e223*4+_e221*16, l_u_e_vvc); + int _e227 = idx_2; + int _e229 = idx_2; + int _e231 = idx_2; + s_am.Store(_e231*2+_e229*4+_e227*16, l_u_e_vvv); + return; +} + +typedef StructWithMat ret_Constructarray4_StructWithMat_[4]; +ret_Constructarray4_StructWithMat_ Constructarray4_StructWithMat_(StructWithMat arg0, StructWithMat arg1, StructWithMat arg2, StructWithMat arg3) { + StructWithMat ret[4] = { arg0, arg1, arg2, arg3 }; + return ret; +} + +StructWithArrayOfStructOfMat ConstructStructWithArrayOfStructOfMat(StructWithMat arg0[4]) { + StructWithArrayOfStructOfMat ret = (StructWithArrayOfStructOfMat)0; + ret.a = arg0; + return ret; +} + +void access_sasm() +{ + int idx_3 = int(1); + + int _e3 = idx_3; + idx_3 = asint(asuint(_e3) - asuint(int(1))); + StructWithArrayOfStructOfMat l_s_s_1 = ConstructStructWithArrayOfStructOfMat(Constructarray4_StructWithMat_(ConstructStructWithMat(half4x2(s_sasm.Load(0+0+0+0), s_sasm.Load(0+0+0+4), s_sasm.Load(0+0+0+8), s_sasm.Load(0+0+0+12))), ConstructStructWithMat(half4x2(s_sasm.Load(0+16+0+0), s_sasm.Load(0+16+0+4), s_sasm.Load(0+16+0+8), s_sasm.Load(0+16+0+12))), ConstructStructWithMat(half4x2(s_sasm.Load(0+32+0+0), s_sasm.Load(0+32+0+4), s_sasm.Load(0+32+0+8), s_sasm.Load(0+32+0+12))), ConstructStructWithMat(half4x2(s_sasm.Load(0+48+0+0), s_sasm.Load(0+48+0+4), s_sasm.Load(0+48+0+8), s_sasm.Load(0+48+0+12))))); + StructWithMat l_s_a_1[4] = Constructarray4_StructWithMat_(ConstructStructWithMat(half4x2(s_sasm.Load(0+0+0+0), s_sasm.Load(0+0+0+4), s_sasm.Load(0+0+0+8), s_sasm.Load(0+0+0+12))), ConstructStructWithMat(half4x2(s_sasm.Load(0+16+0+0), s_sasm.Load(0+16+0+4), s_sasm.Load(0+16+0+8), s_sasm.Load(0+16+0+12))), ConstructStructWithMat(half4x2(s_sasm.Load(0+32+0+0), s_sasm.Load(0+32+0+4), s_sasm.Load(0+32+0+8), s_sasm.Load(0+32+0+12))), ConstructStructWithMat(half4x2(s_sasm.Load(0+48+0+0), s_sasm.Load(0+48+0+4), s_sasm.Load(0+48+0+8), s_sasm.Load(0+48+0+12)))); + half4x2 l_s_m_c_1 = half4x2(s_sasm.Load(0+0+0+0), s_sasm.Load(0+0+0+4), s_sasm.Load(0+0+0+8), s_sasm.Load(0+0+0+12)); + int _e17 = idx_3; + half4x2 l_s_m_v_1 = half4x2(s_sasm.Load(0+_e17*16+0+0), s_sasm.Load(0+_e17*16+0+4), s_sasm.Load(0+_e17*16+0+8), s_sasm.Load(0+_e17*16+0+12)); + half2 l_s_c_cc_1 = s_sasm.Load(0+0+0+0); + int _e31 = idx_3; + half2 l_s_c_cv_1 = s_sasm.Load(_e31*4+0+0+0); + int _e36 = idx_3; + half2 l_s_c_vc_1 = s_sasm.Load(0+0+_e36*16+0); + int _e43 = idx_3; + int _e46 = idx_3; + half2 l_s_c_vv_1 = s_sasm.Load(_e46*4+0+_e43*16+0); + half l_s_e_ccc_1 = s_sasm.Load(0+0+0+0+0); + int _e61 = idx_3; + half l_s_e_ccv_1 = s_sasm.Load(_e61*2+0+0+0+0); + int _e68 = idx_3; + half l_s_e_cvc_1 = s_sasm.Load(0+_e68*4+0+0+0); + int _e76 = idx_3; + int _e78 = idx_3; + half l_s_e_cvv_1 = s_sasm.Load(_e78*2+_e76*4+0+0+0); + int _e83 = idx_3; + half l_s_e_vcc_1 = s_sasm.Load(0+0+0+_e83*16+0); + int _e91 = idx_3; + int _e95 = idx_3; + half l_s_e_vcv_1 = s_sasm.Load(_e95*2+0+0+_e91*16+0); + int _e100 = idx_3; + int _e103 = idx_3; + half l_s_e_vvc_1 = s_sasm.Load(0+_e103*4+0+_e100*16+0); + int _e109 = idx_3; + int _e112 = idx_3; + int _e114 = idx_3; + half l_s_e_vvv_1 = s_sasm.Load(_e114*2+_e112*4+0+_e109*16+0); + StructWithArrayOfStructOfMat l_u_s_1 = u_sasm; + StructWithMat l_u_a_1[4] = u_sasm.a; + half4x2 l_u_m_c_1 = GetMatmOnStructWithMat(u_sasm.a[0]); + int _e129 = idx_3; + half4x2 l_u_m_v_1 = GetMatmOnStructWithMat(u_sasm.a[_e129]); + half2 l_u_c_cc_1 = GetMatmOnStructWithMat(u_sasm.a[0])[0]; + int _e143 = idx_3; + half2 l_u_c_cv_1 = GetMatmOnStructWithMat(u_sasm.a[0])[_e143]; + int _e148 = idx_3; + half2 l_u_c_vc_1 = GetMatmOnStructWithMat(u_sasm.a[_e148])[0]; + int _e155 = idx_3; + int _e158 = idx_3; + half2 l_u_c_vv_1 = GetMatmOnStructWithMat(u_sasm.a[_e155])[_e158]; + half l_u_e_ccc_1 = GetMatmOnStructWithMat(u_sasm.a[0])[0].x; + int _e173 = idx_3; + half l_u_e_ccv_1 = GetMatmOnStructWithMat(u_sasm.a[0])[0][_e173]; + int _e180 = idx_3; + half l_u_e_cvc_1 = GetMatmOnStructWithMat(u_sasm.a[0])[_e180].x; + int _e188 = idx_3; + int _e190 = idx_3; + half l_u_e_cvv_1 = GetMatmOnStructWithMat(u_sasm.a[0])[_e188][_e190]; + int _e195 = idx_3; + half l_u_e_vcc_1 = GetMatmOnStructWithMat(u_sasm.a[_e195])[0].x; + int _e203 = idx_3; + int _e207 = idx_3; + half l_u_e_vcv_1 = GetMatmOnStructWithMat(u_sasm.a[_e203])[0][_e207]; + int _e212 = idx_3; + int _e215 = idx_3; + half l_u_e_vvc_1 = GetMatmOnStructWithMat(u_sasm.a[_e212])[_e215].x; + int _e221 = idx_3; + int _e224 = idx_3; + int _e226 = idx_3; + half l_u_e_vvv_1 = GetMatmOnStructWithMat(u_sasm.a[_e221])[_e224][_e226]; + { + StructWithArrayOfStructOfMat _value2 = l_u_s_1; + { + StructWithMat _value3[4] = _value2.a; + { + StructWithMat _value4 = _value3[0]; + { + s_sasm.Store(0+0+0+0, _value4.m_0); + s_sasm.Store(0+0+0+4, _value4.m_1); + s_sasm.Store(0+0+0+8, _value4.m_2); + s_sasm.Store(0+0+0+12, _value4.m_3); + } + } + { + StructWithMat _value4 = _value3[1]; + { + s_sasm.Store(0+16+0+0, _value4.m_0); + s_sasm.Store(0+16+0+4, _value4.m_1); + s_sasm.Store(0+16+0+8, _value4.m_2); + s_sasm.Store(0+16+0+12, _value4.m_3); + } + } + { + StructWithMat _value4 = _value3[2]; + { + s_sasm.Store(0+32+0+0, _value4.m_0); + s_sasm.Store(0+32+0+4, _value4.m_1); + s_sasm.Store(0+32+0+8, _value4.m_2); + s_sasm.Store(0+32+0+12, _value4.m_3); + } + } + { + StructWithMat _value4 = _value3[3]; + { + s_sasm.Store(0+48+0+0, _value4.m_0); + s_sasm.Store(0+48+0+4, _value4.m_1); + s_sasm.Store(0+48+0+8, _value4.m_2); + s_sasm.Store(0+48+0+12, _value4.m_3); + } + } + } + } + { + StructWithMat _value2[4] = l_u_a_1; + { + StructWithMat _value3 = _value2[0]; + { + s_sasm.Store(0+0+0+0, _value3.m_0); + s_sasm.Store(0+0+0+4, _value3.m_1); + s_sasm.Store(0+0+0+8, _value3.m_2); + s_sasm.Store(0+0+0+12, _value3.m_3); + } + } + { + StructWithMat _value3 = _value2[1]; + { + s_sasm.Store(0+16+0+0, _value3.m_0); + s_sasm.Store(0+16+0+4, _value3.m_1); + s_sasm.Store(0+16+0+8, _value3.m_2); + s_sasm.Store(0+16+0+12, _value3.m_3); + } + } + { + StructWithMat _value3 = _value2[2]; + { + s_sasm.Store(0+32+0+0, _value3.m_0); + s_sasm.Store(0+32+0+4, _value3.m_1); + s_sasm.Store(0+32+0+8, _value3.m_2); + s_sasm.Store(0+32+0+12, _value3.m_3); + } + } + { + StructWithMat _value3 = _value2[3]; + { + s_sasm.Store(0+48+0+0, _value3.m_0); + s_sasm.Store(0+48+0+4, _value3.m_1); + s_sasm.Store(0+48+0+8, _value3.m_2); + s_sasm.Store(0+48+0+12, _value3.m_3); + } + } + } + { + half4x2 _value2 = l_u_m_c_1; + s_sasm.Store(0+0+0+0, _value2[0]); + s_sasm.Store(0+0+0+4, _value2[1]); + s_sasm.Store(0+0+0+8, _value2[2]); + s_sasm.Store(0+0+0+12, _value2[3]); + } + int _e238 = idx_3; + { + half4x2 _value2 = l_u_m_v_1; + s_sasm.Store(0+_e238*16+0+0, _value2[0]); + s_sasm.Store(0+_e238*16+0+4, _value2[1]); + s_sasm.Store(0+_e238*16+0+8, _value2[2]); + s_sasm.Store(0+_e238*16+0+12, _value2[3]); + } + s_sasm.Store(0+0+0+0, l_u_c_cc_1); + int _e250 = idx_3; + s_sasm.Store(_e250*4+0+0+0, l_u_c_cv_1); + int _e254 = idx_3; + s_sasm.Store(0+0+_e254*16+0, l_u_c_vc_1); + int _e260 = idx_3; + int _e263 = idx_3; + s_sasm.Store(_e263*4+0+_e260*16+0, l_u_c_vv_1); + s_sasm.Store(0+0+0+0+0, l_u_e_ccc_1); + int _e276 = idx_3; + s_sasm.Store(_e276*2+0+0+0+0, l_u_e_ccv_1); + int _e282 = idx_3; + s_sasm.Store(0+_e282*4+0+0+0, l_u_e_cvc_1); + int _e289 = idx_3; + int _e291 = idx_3; + s_sasm.Store(_e291*2+_e289*4+0+0+0, l_u_e_cvv_1); + int _e295 = idx_3; + s_sasm.Store(0+0+0+_e295*16+0, l_u_e_vcc_1); + int _e302 = idx_3; + int _e306 = idx_3; + s_sasm.Store(_e306*2+0+0+_e302*16+0, l_u_e_vcv_1); + int _e310 = idx_3; + int _e313 = idx_3; + s_sasm.Store(0+_e313*4+0+_e310*16+0, l_u_e_vvc_1); + int _e318 = idx_3; + int _e321 = idx_3; + int _e323 = idx_3; + s_sasm.Store(_e323*2+_e321*4+0+_e318*16+0, l_u_e_vvv_1); + return; +} + +[numthreads(1, 1, 1)] +void main() +{ + access_m(); + access_sm(); + access_am(); + access_sasm(); + return; +} diff --git a/naga/tests/out/hlsl/wgsl-mat_cx2_f16.ron b/naga/tests/out/hlsl/wgsl-mat_cx2_f16.ron new file mode 100644 index 000000000..ea04bf303 --- /dev/null +++ b/naga/tests/out/hlsl/wgsl-mat_cx2_f16.ron @@ -0,0 +1,16 @@ +( + vertex:[ + ], + fragment:[ + ], + compute:[ + ( + entry_point:"main", + target_profile:"cs_6_2", + ), + ], + task:[ + ], + mesh:[ + ], +) diff --git a/naga/tests/out/spv/wgsl-mat_cx2_f16.spvasm b/naga/tests/out/spv/wgsl-mat_cx2_f16.spvasm new file mode 100644 index 000000000..e7cfd366b --- /dev/null +++ b/naga/tests/out/spv/wgsl-mat_cx2_f16.spvasm @@ -0,0 +1,1416 @@ +; SPIR-V +; Version: 1.1 +; Generator: rspirv +; Bound: 687 +OpCapability Shader +OpCapability Float16 +OpCapability StorageBuffer16BitAccess +OpCapability UniformAndStorageBuffer16BitAccess +OpCapability StorageInputOutput16 +OpExtension "SPV_KHR_storage_buffer_storage_class" +OpExtension "SPV_KHR_16bit_storage" +%1 = OpExtInstImport "GLSL.std.450" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %673 "main" +OpExecutionMode %673 LocalSize 1 1 1 +%3 = OpString "mat_cx2_f16.wgsl" +OpSource Unknown 0 %3 "// Test handling of N-by-2 matrices. +// See the doc comments on `naga::back::hlsl` and `naga::back::spv` for details. +// +// There are additional tests in `access.wgsl`. +// +// Tests that we don't apply this handling to other sizes are in mat_cx3.wgsl. + +// Access type (3rd item in variable names) +// S = Struct +// M = Matrix +// C = Column +// E = Element + +// Index type (4th item in variable names) +// C = Constant +// V = Variable + +enable f16; + +alias Mat = mat4x2; + +@group(0) @binding(0) +var s_m: Mat; + +@group(0) @binding(1) +var u_m: Mat; + +fn access_m() { + var idx = 1; + idx--; + + // loads from storage + let l_s_m = s_m; + let l_s_c_c = s_m[0]; + let l_s_c_v = s_m[idx]; + let l_s_e_cc = s_m[0][0]; + let l_s_e_cv = s_m[0][idx]; + let l_s_e_vc = s_m[idx][0]; + let l_s_e_vv = s_m[idx][idx]; + + // loads from uniform + let l_u_m = u_m; + let l_u_c_c = u_m[0]; + let l_u_c_v = u_m[idx]; + let l_u_e_cc = u_m[0][0]; + let l_u_e_cv = u_m[0][idx]; + let l_u_e_vc = u_m[idx][0]; + let l_u_e_vv = u_m[idx][idx]; + + // stores to storage + s_m = l_u_m; + s_m[0] = l_u_c_c; + s_m[idx] = l_u_c_v; + s_m[0][0] = l_u_e_cc; + s_m[0][idx] = l_u_e_cv; + s_m[idx][0] = l_u_e_vc; + s_m[idx][idx] = l_u_e_vv; +} + +struct StructWithMat { + m: Mat, +} + +@group(1) @binding(0) +var s_sm: StructWithMat; + +@group(1) @binding(1) +var u_sm: StructWithMat; + +fn access_sm() { + var idx = 1; + idx--; + + // loads from storage + let l_s_s = s_sm; + let l_s_m = s_sm.m; + let l_s_c_c = s_sm.m[0]; + let l_s_c_v = s_sm.m[idx]; + let l_s_e_cc = s_sm.m[0][0]; + let l_s_e_cv = s_sm.m[0][idx]; + let l_s_e_vc = s_sm.m[idx][0]; + let l_s_e_vv = s_sm.m[idx][idx]; + + // loads from uniform + let l_u_s = u_sm; + let l_u_m = u_sm.m; + let l_u_c_c = u_sm.m[0]; + let l_u_c_v = u_sm.m[idx]; + let l_u_e_cc = u_sm.m[0][0]; + let l_u_e_cv = u_sm.m[0][idx]; + let l_u_e_vc = u_sm.m[idx][0]; + let l_u_e_vv = u_sm.m[idx][idx]; + + // stores to storage + s_sm = l_u_s; + s_sm.m = l_u_m; + s_sm.m[0] = l_u_c_c; + s_sm.m[idx] = l_u_c_v; + s_sm.m[0][0] = l_u_e_cc; + s_sm.m[0][idx] = l_u_e_cv; + s_sm.m[idx][0] = l_u_e_vc; + s_sm.m[idx][idx] = l_u_e_vv; +} + +@group(2) @binding(0) +var s_am: array; + +@group(2) @binding(1) +var u_am: array; + +fn access_am() { + var idx = 1; + idx--; + + // loads from storage + let l_s_a = s_am; + let l_s_m_c = s_am[0]; + let l_s_m_v = s_am[idx]; + let l_s_c_cc = s_am[0][0]; + let l_s_c_cv = s_am[0][idx]; + let l_s_c_vc = s_am[idx][0]; + let l_s_c_vv = s_am[idx][idx]; + let l_s_e_ccc = s_am[0][0][0]; + let l_s_e_ccv = s_am[0][0][idx]; + let l_s_e_cvc = s_am[0][idx][0]; + let l_s_e_cvv = s_am[0][idx][idx]; + let l_s_e_vcc = s_am[idx][0][0]; + let l_s_e_vcv = s_am[idx][0][idx]; + let l_s_e_vvc = s_am[idx][idx][0]; + let l_s_e_vvv = s_am[idx][idx][idx]; + + // loads from uniform + let l_u_a = u_am; + let l_u_m_c = u_am[0]; + let l_u_m_v = u_am[idx]; + let l_u_c_cc = u_am[0][0]; + let l_u_c_cv = u_am[0][idx]; + let l_u_c_vc = u_am[idx][0]; + let l_u_c_vv = u_am[idx][idx]; + let l_u_e_ccc = u_am[0][0][0]; + let l_u_e_ccv = u_am[0][0][idx]; + let l_u_e_cvc = u_am[0][idx][0]; + let l_u_e_cvv = u_am[0][idx][idx]; + let l_u_e_vcc = u_am[idx][0][0]; + let l_u_e_vcv = u_am[idx][0][idx]; + let l_u_e_vvc = u_am[idx][idx][0]; + let l_u_e_vvv = u_am[idx][idx][idx]; + + // stores to storage + s_am = l_u_a; + s_am[0] = l_u_m_c; + s_am[idx] = l_u_m_v; + s_am[0][0] = l_u_c_cc; + s_am[0][idx] = l_u_c_cv; + s_am[idx][0] = l_u_c_vc; + s_am[idx][idx] = l_u_c_vv; + s_am[0][0][0] = l_u_e_ccc; + s_am[0][0][idx] = l_u_e_ccv; + s_am[0][idx][0] = l_u_e_cvc; + s_am[0][idx][idx] = l_u_e_cvv; + s_am[idx][0][0] = l_u_e_vcc; + s_am[idx][0][idx] = l_u_e_vcv; + s_am[idx][idx][0] = l_u_e_vvc; + s_am[idx][idx][idx] = l_u_e_vvv; +} + +struct StructWithArrayOfStructOfMat { + a: array, +} + +@group(3) @binding(0) +var s_sasm: StructWithArrayOfStructOfMat; + +@group(3) @binding(1) +var u_sasm: StructWithArrayOfStructOfMat; + +fn access_sasm() { + var idx = 1; + idx--; + + // loads from storage + let l_s_s = s_sasm; + let l_s_a = s_sasm.a; + let l_s_m_c = s_sasm.a[0].m; + let l_s_m_v = s_sasm.a[idx].m; + let l_s_c_cc = s_sasm.a[0].m[0]; + let l_s_c_cv = s_sasm.a[0].m[idx]; + let l_s_c_vc = s_sasm.a[idx].m[0]; + let l_s_c_vv = s_sasm.a[idx].m[idx]; + let l_s_e_ccc = s_sasm.a[0].m[0][0]; + let l_s_e_ccv = s_sasm.a[0].m[0][idx]; + let l_s_e_cvc = s_sasm.a[0].m[idx][0]; + let l_s_e_cvv = s_sasm.a[0].m[idx][idx]; + let l_s_e_vcc = s_sasm.a[idx].m[0][0]; + let l_s_e_vcv = s_sasm.a[idx].m[0][idx]; + let l_s_e_vvc = s_sasm.a[idx].m[idx][0]; + let l_s_e_vvv = s_sasm.a[idx].m[idx][idx]; + + // loads from uniform + let l_u_s = u_sasm; + let l_u_a = u_sasm.a; + let l_u_m_c = u_sasm.a[0].m; + let l_u_m_v = u_sasm.a[idx].m; + let l_u_c_cc = u_sasm.a[0].m[0]; + let l_u_c_cv = u_sasm.a[0].m[idx]; + let l_u_c_vc = u_sasm.a[idx].m[0]; + let l_u_c_vv = u_sasm.a[idx].m[idx]; + let l_u_e_ccc = u_sasm.a[0].m[0][0]; + let l_u_e_ccv = u_sasm.a[0].m[0][idx]; + let l_u_e_cvc = u_sasm.a[0].m[idx][0]; + let l_u_e_cvv = u_sasm.a[0].m[idx][idx]; + let l_u_e_vcc = u_sasm.a[idx].m[0][0]; + let l_u_e_vcv = u_sasm.a[idx].m[0][idx]; + let l_u_e_vvc = u_sasm.a[idx].m[idx][0]; + let l_u_e_vvv = u_sasm.a[idx].m[idx][idx]; + + // stores to storage + s_sasm = l_u_s; + s_sasm.a = l_u_a; + s_sasm.a[0].m = l_u_m_c; + s_sasm.a[idx].m = l_u_m_v; + s_sasm.a[0].m[0] = l_u_c_cc; + s_sasm.a[0].m[idx] = l_u_c_cv; + s_sasm.a[idx].m[0] = l_u_c_vc; + s_sasm.a[idx].m[idx] = l_u_c_vv; + s_sasm.a[0].m[0][0] = l_u_e_ccc; + s_sasm.a[0].m[0][idx] = l_u_e_ccv; + s_sasm.a[0].m[idx][0] = l_u_e_cvc; + s_sasm.a[0].m[idx][idx] = l_u_e_cvv; + s_sasm.a[idx].m[0][0] = l_u_e_vcc; + s_sasm.a[idx].m[0][idx] = l_u_e_vcv; + s_sasm.a[idx].m[idx][0] = l_u_e_vvc; + s_sasm.a[idx].m[idx][idx] = l_u_e_vvv; +} + +@compute @workgroup_size(1) +fn main() { + access_m(); + access_sm(); + access_am(); + access_sasm(); +} +" +OpName %4 "Mat" +OpMemberName %8 0 "m" +OpName %8 "StructWithMat" +OpMemberName %13 0 "a" +OpName %13 "StructWithArrayOfStructOfMat" +OpMemberName %14 0 "col0" +OpMemberName %14 1 "col1" +OpMemberName %14 2 "col2" +OpMemberName %14 3 "col3" +OpName %14 "std140_mat4x2" +OpMemberName %15 0 "m_col0" +OpMemberName %15 1 "m_col1" +OpMemberName %15 2 "m_col2" +OpMemberName %15 3 "m_col3" +OpName %15 "std140_StructWithMat" +OpName %16 "std140_array, 4>" +OpName %17 "std140_array" +OpMemberName %18 0 "a" +OpName %18 "std140_StructWithArrayOfStructOfMat" +OpName %19 "s_m" +OpName %22 "u_m" +OpName %25 "s_sm" +OpName %28 "u_sm" +OpName %31 "s_am" +OpName %34 "u_am" +OpName %37 "s_sasm" +OpName %40 "u_sasm" +OpName %43 "mat4x2_from_std140" +OpName %52 "mat4x2_get_column" +OpName %69 "access_m" +OpName %78 "idx" +OpName %143 "StructWithMat_from_std140" +OpName %154 "access_sm" +OpName %160 "idx" +OpName %256 "array, 4>_from_std140" +OpName %270 "access_am" +OpName %276 "idx" +OpName %428 "StructWithArrayOfStructOfMat_from_std140" +OpName %433 "array_from_std140" +OpName %449 "access_sasm" +OpName %455 "idx" +OpName %673 "main" +OpMemberDecorate %8 0 Offset 0 +OpMemberDecorate %8 0 ColMajor +OpMemberDecorate %8 0 MatrixStride 4 +OpDecorate %9 ArrayStride 16 +OpDecorate %12 ArrayStride 16 +OpMemberDecorate %13 0 Offset 0 +OpMemberDecorate %14 0 Offset 0 +OpMemberDecorate %14 1 Offset 4 +OpMemberDecorate %14 2 Offset 8 +OpMemberDecorate %14 3 Offset 12 +OpMemberDecorate %15 0 Offset 0 +OpMemberDecorate %15 1 Offset 4 +OpMemberDecorate %15 2 Offset 8 +OpMemberDecorate %15 3 Offset 12 +OpDecorate %16 ArrayStride 16 +OpDecorate %17 ArrayStride 16 +OpMemberDecorate %18 0 Offset 0 +OpDecorate %19 DescriptorSet 0 +OpDecorate %19 Binding 0 +OpDecorate %20 Block +OpMemberDecorate %20 0 Offset 0 +OpMemberDecorate %20 0 ColMajor +OpMemberDecorate %20 0 MatrixStride 4 +OpDecorate %22 DescriptorSet 0 +OpDecorate %22 Binding 1 +OpDecorate %23 Block +OpMemberDecorate %23 0 Offset 0 +OpDecorate %25 DescriptorSet 1 +OpDecorate %25 Binding 0 +OpDecorate %26 Block +OpMemberDecorate %26 0 Offset 0 +OpDecorate %28 DescriptorSet 1 +OpDecorate %28 Binding 1 +OpDecorate %29 Block +OpMemberDecorate %29 0 Offset 0 +OpDecorate %31 DescriptorSet 2 +OpDecorate %31 Binding 0 +OpDecorate %32 Block +OpMemberDecorate %32 0 Offset 0 +OpMemberDecorate %32 0 ColMajor +OpMemberDecorate %32 0 MatrixStride 4 +OpDecorate %34 DescriptorSet 2 +OpDecorate %34 Binding 1 +OpDecorate %35 Block +OpMemberDecorate %35 0 Offset 0 +OpDecorate %37 DescriptorSet 3 +OpDecorate %37 Binding 0 +OpDecorate %38 Block +OpMemberDecorate %38 0 Offset 0 +OpDecorate %40 DescriptorSet 3 +OpDecorate %40 Binding 1 +OpDecorate %41 Block +OpMemberDecorate %41 0 Offset 0 +%2 = OpTypeVoid +%6 = OpTypeFloat 16 +%5 = OpTypeVector %6 2 +%4 = OpTypeMatrix %5 4 +%7 = OpTypeInt 32 1 +%8 = OpTypeStruct %4 +%11 = OpTypeInt 32 0 +%10 = OpConstant %11 4 +%9 = OpTypeArray %4 %10 +%12 = OpTypeArray %8 %10 +%13 = OpTypeStruct %12 +%14 = OpTypeStruct %5 %5 %5 %5 +%15 = OpTypeStruct %5 %5 %5 %5 +%16 = OpTypeArray %14 %10 +%17 = OpTypeArray %15 %10 +%18 = OpTypeStruct %17 +%20 = OpTypeStruct %4 +%21 = OpTypePointer StorageBuffer %20 +%19 = OpVariable %21 StorageBuffer +%23 = OpTypeStruct %14 +%24 = OpTypePointer Uniform %23 +%22 = OpVariable %24 Uniform +%26 = OpTypeStruct %8 +%27 = OpTypePointer StorageBuffer %26 +%25 = OpVariable %27 StorageBuffer +%29 = OpTypeStruct %15 +%30 = OpTypePointer Uniform %29 +%28 = OpVariable %30 Uniform +%32 = OpTypeStruct %9 +%33 = OpTypePointer StorageBuffer %32 +%31 = OpVariable %33 StorageBuffer +%35 = OpTypeStruct %16 +%36 = OpTypePointer Uniform %35 +%34 = OpVariable %36 Uniform +%38 = OpTypeStruct %13 +%39 = OpTypePointer StorageBuffer %38 +%37 = OpVariable %39 StorageBuffer +%41 = OpTypeStruct %18 +%42 = OpTypePointer Uniform %41 +%40 = OpVariable %42 Uniform +%44 = OpTypeFunction %4 %14 +%55 = OpTypeFunction %5 %4 %11 +%70 = OpTypeFunction %2 +%71 = OpTypePointer StorageBuffer %4 +%72 = OpConstant %11 0 +%74 = OpTypePointer Uniform %14 +%76 = OpConstant %7 1 +%77 = OpTypePointer Uniform %4 +%79 = OpTypePointer Function %7 +%84 = OpTypePointer StorageBuffer %5 +%90 = OpTypePointer StorageBuffer %6 +%105 = OpTypePointer Uniform %5 +%113 = OpTypePointer Uniform %6 +%144 = OpTypeFunction %8 %15 +%155 = OpTypePointer StorageBuffer %8 +%157 = OpTypePointer Uniform %15 +%159 = OpTypePointer Uniform %8 +%186 = OpConstant %11 1 +%187 = OpConstant %11 2 +%188 = OpConstant %11 3 +%257 = OpTypeFunction %9 %16 +%271 = OpTypePointer StorageBuffer %9 +%273 = OpTypePointer Uniform %16 +%275 = OpTypePointer Uniform %9 +%429 = OpTypeFunction %13 %18 +%434 = OpTypeFunction %12 %17 +%450 = OpTypePointer StorageBuffer %13 +%452 = OpTypePointer Uniform %18 +%454 = OpTypePointer Uniform %13 +%460 = OpTypePointer StorageBuffer %12 +%510 = OpTypePointer Uniform %12 +%511 = OpTypePointer Uniform %17 +%43 = OpFunction %4 None %44 +%45 = OpFunctionParameter %14 +%46 = OpLabel +%47 = OpCompositeExtract %5 %45 0 +%48 = OpCompositeExtract %5 %45 1 +%49 = OpCompositeExtract %5 %45 2 +%50 = OpCompositeExtract %5 %45 3 +%51 = OpCompositeConstruct %4 %47 %48 %49 %50 +OpReturnValue %51 +OpFunctionEnd +%52 = OpFunction %5 None %55 +%53 = OpFunctionParameter %4 +%54 = OpFunctionParameter %11 +%56 = OpLabel +OpSelectionMerge %57 None +OpSwitch %54 %62 0 %58 1 %59 2 %60 3 %61 +%58 = OpLabel +%63 = OpCompositeExtract %5 %53 0 +OpBranch %57 +%59 = OpLabel +%64 = OpCompositeExtract %5 %53 1 +OpBranch %57 +%60 = OpLabel +%65 = OpCompositeExtract %5 %53 2 +OpBranch %57 +%61 = OpLabel +%66 = OpCompositeExtract %5 %53 3 +OpBranch %57 +%62 = OpLabel +OpUnreachable +%57 = OpLabel +%67 = OpPhi %5 %63 %58 %64 %59 %65 %60 %66 %61 +OpReturnValue %67 +OpFunctionEnd +%69 = OpFunction %2 None %70 +%68 = OpLabel +%78 = OpVariable %79 Function %76 +%73 = OpAccessChain %71 %19 %72 +%75 = OpAccessChain %74 %22 %72 +OpBranch %80 +%80 = OpLabel +OpLine %3 30 5 +%81 = OpLoad %7 %78 +%82 = OpISub %7 %81 %76 +OpLine %3 30 5 +OpStore %78 %82 +OpLine %3 33 17 +%83 = OpLoad %4 %73 +OpLine %3 34 19 +%85 = OpAccessChain %84 %73 %72 +%86 = OpLoad %5 %85 +OpLine %3 35 19 +%87 = OpLoad %7 %78 +%88 = OpAccessChain %84 %73 %87 +%89 = OpLoad %5 %88 +OpLine %3 36 20 +OpLine %3 36 20 +%91 = OpAccessChain %90 %73 %72 %72 +%92 = OpLoad %6 %91 +OpLine %3 37 20 +%93 = OpLoad %7 %78 +%94 = OpAccessChain %90 %73 %72 %93 +%95 = OpLoad %6 %94 +OpLine %3 38 20 +%96 = OpLoad %7 %78 +OpLine %3 38 20 +%97 = OpAccessChain %90 %73 %96 %72 +%98 = OpLoad %6 %97 +OpLine %3 39 20 +%99 = OpLoad %7 %78 +%100 = OpLoad %7 %78 +%101 = OpAccessChain %90 %73 %99 %100 +%102 = OpLoad %6 %101 +OpLine %3 42 17 +%103 = OpLoad %14 %75 +%104 = OpFunctionCall %4 %43 %103 +OpLine %3 43 19 +%106 = OpAccessChain %105 %75 %72 +%107 = OpLoad %5 %106 +OpLine %3 44 19 +%108 = OpLoad %7 %78 +%109 = OpLoad %14 %75 +%110 = OpFunctionCall %4 %43 %109 +%111 = OpBitcast %11 %108 +%112 = OpFunctionCall %5 %52 %110 %111 +OpLine %3 45 20 +OpLine %3 45 20 +%114 = OpAccessChain %113 %75 %72 %72 +%115 = OpLoad %6 %114 +OpLine %3 46 20 +%116 = OpLoad %7 %78 +%117 = OpAccessChain %113 %75 %72 %116 +%118 = OpLoad %6 %117 +OpLine %3 47 20 +%119 = OpLoad %7 %78 +OpLine %3 47 20 +%120 = OpLoad %14 %75 +%121 = OpFunctionCall %4 %43 %120 +%122 = OpBitcast %11 %119 +%123 = OpFunctionCall %5 %52 %121 %122 +%124 = OpCompositeExtract %6 %123 0 +OpLine %3 48 20 +%125 = OpLoad %7 %78 +%126 = OpLoad %7 %78 +%127 = OpLoad %14 %75 +%128 = OpFunctionCall %4 %43 %127 +%129 = OpBitcast %11 %125 +%130 = OpFunctionCall %5 %52 %128 %129 +%131 = OpVectorExtractDynamic %6 %130 %126 +OpLine %3 51 5 +OpStore %73 %104 +OpLine %3 52 5 +OpLine %3 52 5 +%132 = OpAccessChain %84 %73 %72 +OpStore %132 %107 +OpLine %3 53 5 +%133 = OpLoad %7 %78 +OpLine %3 53 5 +%134 = OpAccessChain %84 %73 %133 +OpStore %134 %112 +OpLine %3 54 5 +OpLine %3 54 5 +OpLine %3 54 5 +%135 = OpAccessChain %90 %73 %72 %72 +OpStore %135 %115 +OpLine %3 55 5 +%136 = OpLoad %7 %78 +OpLine %3 55 5 +%137 = OpAccessChain %90 %73 %72 %136 +OpStore %137 %118 +OpLine %3 56 5 +%138 = OpLoad %7 %78 +OpLine %3 56 5 +OpLine %3 56 5 +%139 = OpAccessChain %90 %73 %138 %72 +OpStore %139 %124 +OpLine %3 57 5 +%140 = OpLoad %7 %78 +%141 = OpLoad %7 %78 +OpLine %3 57 5 +%142 = OpAccessChain %90 %73 %140 %141 +OpStore %142 %131 +OpReturn +OpFunctionEnd +%143 = OpFunction %8 None %144 +%145 = OpFunctionParameter %15 +%146 = OpLabel +%148 = OpCompositeExtract %5 %145 0 +%149 = OpCompositeExtract %5 %145 1 +%150 = OpCompositeExtract %5 %145 2 +%151 = OpCompositeExtract %5 %145 3 +%147 = OpCompositeConstruct %4 %148 %149 %150 %151 +%152 = OpCompositeConstruct %8 %147 +OpReturnValue %152 +OpFunctionEnd +%154 = OpFunction %2 None %70 +%153 = OpLabel +%160 = OpVariable %79 Function %76 +%156 = OpAccessChain %155 %25 %72 +%158 = OpAccessChain %157 %28 %72 +OpBranch %161 +%161 = OpLabel +OpLine %3 72 5 +%162 = OpLoad %7 %160 +%163 = OpISub %7 %162 %76 +OpLine %3 72 5 +OpStore %160 %163 +OpLine %3 75 17 +%164 = OpLoad %8 %156 +OpLine %3 76 17 +%165 = OpAccessChain %71 %156 %72 +%166 = OpLoad %4 %165 +OpLine %3 77 19 +OpLine %3 77 19 +%167 = OpAccessChain %84 %156 %72 %72 +%168 = OpLoad %5 %167 +OpLine %3 78 19 +%169 = OpLoad %7 %160 +%170 = OpAccessChain %84 %156 %72 %169 +%171 = OpLoad %5 %170 +OpLine %3 79 20 +OpLine %3 79 20 +OpLine %3 79 20 +%172 = OpAccessChain %90 %156 %72 %72 %72 +%173 = OpLoad %6 %172 +OpLine %3 80 20 +OpLine %3 80 20 +%174 = OpLoad %7 %160 +%175 = OpAccessChain %90 %156 %72 %72 %174 +%176 = OpLoad %6 %175 +OpLine %3 81 20 +%177 = OpLoad %7 %160 +OpLine %3 81 20 +%178 = OpAccessChain %90 %156 %72 %177 %72 +%179 = OpLoad %6 %178 +OpLine %3 82 20 +%180 = OpLoad %7 %160 +%181 = OpLoad %7 %160 +%182 = OpAccessChain %90 %156 %72 %180 %181 +%183 = OpLoad %6 %182 +OpLine %3 85 17 +%184 = OpLoad %15 %158 +%185 = OpFunctionCall %8 %143 %184 +OpLine %3 86 17 +%189 = OpAccessChain %105 %158 %72 +%190 = OpLoad %5 %189 +%191 = OpAccessChain %105 %158 %186 +%192 = OpLoad %5 %191 +%193 = OpAccessChain %105 %158 %187 +%194 = OpLoad %5 %193 +%195 = OpAccessChain %105 %158 %188 +%196 = OpLoad %5 %195 +%197 = OpCompositeConstruct %4 %190 %192 %194 %196 +OpLine %3 87 19 +OpLine %3 87 19 +%198 = OpAccessChain %105 %158 %72 +%199 = OpLoad %5 %198 +OpLine %3 88 19 +%200 = OpLoad %7 %160 +%201 = OpAccessChain %105 %158 %72 +%202 = OpLoad %5 %201 +%203 = OpAccessChain %105 %158 %186 +%204 = OpLoad %5 %203 +%205 = OpAccessChain %105 %158 %187 +%206 = OpLoad %5 %205 +%207 = OpAccessChain %105 %158 %188 +%208 = OpLoad %5 %207 +%209 = OpCompositeConstruct %4 %202 %204 %206 %208 +%210 = OpBitcast %11 %200 +%211 = OpFunctionCall %5 %52 %209 %210 +OpLine %3 89 20 +OpLine %3 89 20 +OpLine %3 89 20 +%212 = OpAccessChain %113 %158 %72 %72 +%213 = OpLoad %6 %212 +OpLine %3 90 20 +OpLine %3 90 20 +%214 = OpLoad %7 %160 +%215 = OpAccessChain %113 %158 %72 %214 +%216 = OpLoad %6 %215 +OpLine %3 91 20 +%217 = OpLoad %7 %160 +OpLine %3 91 20 +%218 = OpAccessChain %105 %158 %72 +%219 = OpLoad %5 %218 +%220 = OpAccessChain %105 %158 %186 +%221 = OpLoad %5 %220 +%222 = OpAccessChain %105 %158 %187 +%223 = OpLoad %5 %222 +%224 = OpAccessChain %105 %158 %188 +%225 = OpLoad %5 %224 +%226 = OpCompositeConstruct %4 %219 %221 %223 %225 +%227 = OpBitcast %11 %217 +%228 = OpFunctionCall %5 %52 %226 %227 +%229 = OpCompositeExtract %6 %228 0 +OpLine %3 92 20 +%230 = OpLoad %7 %160 +%231 = OpLoad %7 %160 +%232 = OpAccessChain %105 %158 %72 +%233 = OpLoad %5 %232 +%234 = OpAccessChain %105 %158 %186 +%235 = OpLoad %5 %234 +%236 = OpAccessChain %105 %158 %187 +%237 = OpLoad %5 %236 +%238 = OpAccessChain %105 %158 %188 +%239 = OpLoad %5 %238 +%240 = OpCompositeConstruct %4 %233 %235 %237 %239 +%241 = OpBitcast %11 %230 +%242 = OpFunctionCall %5 %52 %240 %241 +%243 = OpVectorExtractDynamic %6 %242 %231 +OpLine %3 95 5 +OpStore %156 %185 +OpLine %3 96 5 +OpLine %3 96 5 +%244 = OpAccessChain %71 %156 %72 +OpStore %244 %197 +OpLine %3 97 5 +OpLine %3 97 5 +OpLine %3 97 5 +%245 = OpAccessChain %84 %156 %72 %72 +OpStore %245 %199 +OpLine %3 98 5 +%246 = OpLoad %7 %160 +OpLine %3 98 5 +%247 = OpAccessChain %84 %156 %72 %246 +OpStore %247 %211 +OpLine %3 99 5 +OpLine %3 99 5 +OpLine %3 99 5 +OpLine %3 99 5 +%248 = OpAccessChain %90 %156 %72 %72 %72 +OpStore %248 %213 +OpLine %3 100 5 +OpLine %3 100 5 +%249 = OpLoad %7 %160 +OpLine %3 100 5 +%250 = OpAccessChain %90 %156 %72 %72 %249 +OpStore %250 %216 +OpLine %3 101 5 +%251 = OpLoad %7 %160 +OpLine %3 101 5 +OpLine %3 101 5 +%252 = OpAccessChain %90 %156 %72 %251 %72 +OpStore %252 %229 +OpLine %3 102 5 +%253 = OpLoad %7 %160 +%254 = OpLoad %7 %160 +OpLine %3 102 5 +%255 = OpAccessChain %90 %156 %72 %253 %254 +OpStore %255 %243 +OpReturn +OpFunctionEnd +%256 = OpFunction %9 None %257 +%258 = OpFunctionParameter %16 +%259 = OpLabel +%260 = OpCompositeExtract %14 %258 0 +%261 = OpFunctionCall %4 %43 %260 +%262 = OpCompositeExtract %14 %258 1 +%263 = OpFunctionCall %4 %43 %262 +%264 = OpCompositeExtract %14 %258 2 +%265 = OpFunctionCall %4 %43 %264 +%266 = OpCompositeExtract %14 %258 3 +%267 = OpFunctionCall %4 %43 %266 +%268 = OpCompositeConstruct %9 %261 %263 %265 %267 +OpReturnValue %268 +OpFunctionEnd +%270 = OpFunction %2 None %70 +%269 = OpLabel +%276 = OpVariable %79 Function %76 +%272 = OpAccessChain %271 %31 %72 +%274 = OpAccessChain %273 %34 %72 +OpBranch %277 +%277 = OpLabel +OpLine %3 113 5 +%278 = OpLoad %7 %276 +%279 = OpISub %7 %278 %76 +OpLine %3 113 5 +OpStore %276 %279 +OpLine %3 116 17 +%280 = OpLoad %9 %272 +OpLine %3 117 19 +%281 = OpAccessChain %71 %272 %72 +%282 = OpLoad %4 %281 +OpLine %3 118 19 +%283 = OpLoad %7 %276 +%284 = OpAccessChain %71 %272 %283 +%285 = OpLoad %4 %284 +OpLine %3 119 20 +OpLine %3 119 20 +%286 = OpAccessChain %84 %272 %72 %72 +%287 = OpLoad %5 %286 +OpLine %3 120 20 +%288 = OpLoad %7 %276 +%289 = OpAccessChain %84 %272 %72 %288 +%290 = OpLoad %5 %289 +OpLine %3 121 20 +%291 = OpLoad %7 %276 +OpLine %3 121 20 +%292 = OpAccessChain %84 %272 %291 %72 +%293 = OpLoad %5 %292 +OpLine %3 122 20 +%294 = OpLoad %7 %276 +%295 = OpLoad %7 %276 +%296 = OpAccessChain %84 %272 %294 %295 +%297 = OpLoad %5 %296 +OpLine %3 123 21 +OpLine %3 123 21 +OpLine %3 123 21 +%298 = OpAccessChain %90 %272 %72 %72 %72 +%299 = OpLoad %6 %298 +OpLine %3 124 21 +OpLine %3 124 21 +%300 = OpLoad %7 %276 +%301 = OpAccessChain %90 %272 %72 %72 %300 +%302 = OpLoad %6 %301 +OpLine %3 125 21 +%303 = OpLoad %7 %276 +OpLine %3 125 21 +%304 = OpAccessChain %90 %272 %72 %303 %72 +%305 = OpLoad %6 %304 +OpLine %3 126 21 +%306 = OpLoad %7 %276 +%307 = OpLoad %7 %276 +%308 = OpAccessChain %90 %272 %72 %306 %307 +%309 = OpLoad %6 %308 +OpLine %3 127 21 +%310 = OpLoad %7 %276 +OpLine %3 127 21 +OpLine %3 127 21 +%311 = OpAccessChain %90 %272 %310 %72 %72 +%312 = OpLoad %6 %311 +OpLine %3 128 21 +%313 = OpLoad %7 %276 +OpLine %3 128 21 +%314 = OpLoad %7 %276 +%315 = OpAccessChain %90 %272 %313 %72 %314 +%316 = OpLoad %6 %315 +OpLine %3 129 21 +%317 = OpLoad %7 %276 +%318 = OpLoad %7 %276 +OpLine %3 129 21 +%319 = OpAccessChain %90 %272 %317 %318 %72 +%320 = OpLoad %6 %319 +OpLine %3 130 21 +%321 = OpLoad %7 %276 +%322 = OpLoad %7 %276 +%323 = OpLoad %7 %276 +%324 = OpAccessChain %90 %272 %321 %322 %323 +%325 = OpLoad %6 %324 +OpLine %3 133 17 +%326 = OpLoad %16 %274 +%327 = OpFunctionCall %9 %256 %326 +OpLine %3 134 19 +%328 = OpAccessChain %74 %274 %72 +%329 = OpLoad %14 %328 +%330 = OpFunctionCall %4 %43 %329 +OpLine %3 135 19 +%331 = OpLoad %7 %276 +%332 = OpAccessChain %74 %274 %331 +%333 = OpLoad %14 %332 +%334 = OpFunctionCall %4 %43 %333 +OpLine %3 136 20 +OpLine %3 136 20 +%335 = OpAccessChain %105 %274 %72 %72 +%336 = OpLoad %5 %335 +OpLine %3 137 20 +%337 = OpLoad %7 %276 +%338 = OpAccessChain %74 %274 %72 +%339 = OpLoad %14 %338 +%340 = OpFunctionCall %4 %43 %339 +%341 = OpBitcast %11 %337 +%342 = OpFunctionCall %5 %52 %340 %341 +OpLine %3 138 20 +%343 = OpLoad %7 %276 +OpLine %3 138 20 +%344 = OpAccessChain %105 %274 %343 %72 +%345 = OpLoad %5 %344 +OpLine %3 139 20 +%346 = OpLoad %7 %276 +%347 = OpLoad %7 %276 +%348 = OpAccessChain %74 %274 %346 +%349 = OpLoad %14 %348 +%350 = OpFunctionCall %4 %43 %349 +%351 = OpBitcast %11 %347 +%352 = OpFunctionCall %5 %52 %350 %351 +OpLine %3 140 21 +OpLine %3 140 21 +OpLine %3 140 21 +%353 = OpAccessChain %113 %274 %72 %72 %72 +%354 = OpLoad %6 %353 +OpLine %3 141 21 +OpLine %3 141 21 +%355 = OpLoad %7 %276 +%356 = OpAccessChain %113 %274 %72 %72 %355 +%357 = OpLoad %6 %356 +OpLine %3 142 21 +%358 = OpLoad %7 %276 +OpLine %3 142 21 +%359 = OpAccessChain %74 %274 %72 +%360 = OpLoad %14 %359 +%361 = OpFunctionCall %4 %43 %360 +%362 = OpBitcast %11 %358 +%363 = OpFunctionCall %5 %52 %361 %362 +%364 = OpCompositeExtract %6 %363 0 +OpLine %3 143 21 +%365 = OpLoad %7 %276 +%366 = OpLoad %7 %276 +%367 = OpAccessChain %74 %274 %72 +%368 = OpLoad %14 %367 +%369 = OpFunctionCall %4 %43 %368 +%370 = OpBitcast %11 %365 +%371 = OpFunctionCall %5 %52 %369 %370 +%372 = OpVectorExtractDynamic %6 %371 %366 +OpLine %3 144 21 +%373 = OpLoad %7 %276 +OpLine %3 144 21 +OpLine %3 144 21 +%374 = OpAccessChain %113 %274 %373 %72 %72 +%375 = OpLoad %6 %374 +OpLine %3 145 21 +%376 = OpLoad %7 %276 +OpLine %3 145 21 +%377 = OpLoad %7 %276 +%378 = OpAccessChain %113 %274 %376 %72 %377 +%379 = OpLoad %6 %378 +OpLine %3 146 21 +%380 = OpLoad %7 %276 +%381 = OpLoad %7 %276 +OpLine %3 146 21 +%382 = OpAccessChain %74 %274 %380 +%383 = OpLoad %14 %382 +%384 = OpFunctionCall %4 %43 %383 +%385 = OpBitcast %11 %381 +%386 = OpFunctionCall %5 %52 %384 %385 +%387 = OpCompositeExtract %6 %386 0 +OpLine %3 147 21 +%388 = OpLoad %7 %276 +%389 = OpLoad %7 %276 +%390 = OpLoad %7 %276 +%391 = OpAccessChain %74 %274 %388 +%392 = OpLoad %14 %391 +%393 = OpFunctionCall %4 %43 %392 +%394 = OpBitcast %11 %389 +%395 = OpFunctionCall %5 %52 %393 %394 +%396 = OpVectorExtractDynamic %6 %395 %390 +OpLine %3 150 5 +OpStore %272 %327 +OpLine %3 151 5 +OpLine %3 151 5 +%397 = OpAccessChain %71 %272 %72 +OpStore %397 %330 +OpLine %3 152 5 +%398 = OpLoad %7 %276 +OpLine %3 152 5 +%399 = OpAccessChain %71 %272 %398 +OpStore %399 %334 +OpLine %3 153 5 +OpLine %3 153 5 +OpLine %3 153 5 +%400 = OpAccessChain %84 %272 %72 %72 +OpStore %400 %336 +OpLine %3 154 5 +%401 = OpLoad %7 %276 +OpLine %3 154 5 +%402 = OpAccessChain %84 %272 %72 %401 +OpStore %402 %342 +OpLine %3 155 5 +%403 = OpLoad %7 %276 +OpLine %3 155 5 +OpLine %3 155 5 +%404 = OpAccessChain %84 %272 %403 %72 +OpStore %404 %345 +OpLine %3 156 5 +%405 = OpLoad %7 %276 +%406 = OpLoad %7 %276 +OpLine %3 156 5 +%407 = OpAccessChain %84 %272 %405 %406 +OpStore %407 %352 +OpLine %3 157 5 +OpLine %3 157 5 +OpLine %3 157 5 +OpLine %3 157 5 +%408 = OpAccessChain %90 %272 %72 %72 %72 +OpStore %408 %354 +OpLine %3 158 5 +OpLine %3 158 5 +%409 = OpLoad %7 %276 +OpLine %3 158 5 +%410 = OpAccessChain %90 %272 %72 %72 %409 +OpStore %410 %357 +OpLine %3 159 5 +%411 = OpLoad %7 %276 +OpLine %3 159 5 +OpLine %3 159 5 +%412 = OpAccessChain %90 %272 %72 %411 %72 +OpStore %412 %364 +OpLine %3 160 5 +%413 = OpLoad %7 %276 +%414 = OpLoad %7 %276 +OpLine %3 160 5 +%415 = OpAccessChain %90 %272 %72 %413 %414 +OpStore %415 %372 +OpLine %3 161 5 +%416 = OpLoad %7 %276 +OpLine %3 161 5 +OpLine %3 161 5 +OpLine %3 161 5 +%417 = OpAccessChain %90 %272 %416 %72 %72 +OpStore %417 %375 +OpLine %3 162 5 +%418 = OpLoad %7 %276 +OpLine %3 162 5 +%419 = OpLoad %7 %276 +OpLine %3 162 5 +%420 = OpAccessChain %90 %272 %418 %72 %419 +OpStore %420 %379 +OpLine %3 163 5 +%421 = OpLoad %7 %276 +%422 = OpLoad %7 %276 +OpLine %3 163 5 +OpLine %3 163 5 +%423 = OpAccessChain %90 %272 %421 %422 %72 +OpStore %423 %387 +OpLine %3 164 5 +%424 = OpLoad %7 %276 +%425 = OpLoad %7 %276 +%426 = OpLoad %7 %276 +OpLine %3 164 5 +%427 = OpAccessChain %90 %272 %424 %425 %426 +OpStore %427 %396 +OpReturn +OpFunctionEnd +%433 = OpFunction %12 None %434 +%435 = OpFunctionParameter %17 +%436 = OpLabel +%437 = OpCompositeExtract %15 %435 0 +%438 = OpFunctionCall %8 %143 %437 +%439 = OpCompositeExtract %15 %435 1 +%440 = OpFunctionCall %8 %143 %439 +%441 = OpCompositeExtract %15 %435 2 +%442 = OpFunctionCall %8 %143 %441 +%443 = OpCompositeExtract %15 %435 3 +%444 = OpFunctionCall %8 %143 %443 +%445 = OpCompositeConstruct %12 %438 %440 %442 %444 +OpReturnValue %445 +OpFunctionEnd +%428 = OpFunction %13 None %429 +%430 = OpFunctionParameter %18 +%431 = OpLabel +%446 = OpCompositeExtract %17 %430 0 +%432 = OpFunctionCall %12 %433 %446 +%447 = OpCompositeConstruct %13 %432 +OpReturnValue %447 +OpFunctionEnd +%449 = OpFunction %2 None %70 +%448 = OpLabel +%455 = OpVariable %79 Function %76 +%451 = OpAccessChain %450 %37 %72 +%453 = OpAccessChain %452 %40 %72 +OpBranch %456 +%456 = OpLabel +OpLine %3 179 5 +%457 = OpLoad %7 %455 +%458 = OpISub %7 %457 %76 +OpLine %3 179 5 +OpStore %455 %458 +OpLine %3 182 17 +%459 = OpLoad %13 %451 +OpLine %3 183 17 +%461 = OpAccessChain %460 %451 %72 +%462 = OpLoad %12 %461 +OpLine %3 184 19 +OpLine %3 184 19 +%463 = OpAccessChain %71 %451 %72 %72 %72 +%464 = OpLoad %4 %463 +OpLine %3 185 19 +%465 = OpLoad %7 %455 +%466 = OpAccessChain %71 %451 %72 %465 %72 +%467 = OpLoad %4 %466 +OpLine %3 186 20 +OpLine %3 186 20 +OpLine %3 186 20 +%468 = OpAccessChain %84 %451 %72 %72 %72 %72 +%469 = OpLoad %5 %468 +OpLine %3 187 20 +OpLine %3 187 20 +%470 = OpLoad %7 %455 +%471 = OpAccessChain %84 %451 %72 %72 %72 %470 +%472 = OpLoad %5 %471 +OpLine %3 188 20 +%473 = OpLoad %7 %455 +OpLine %3 188 20 +%474 = OpAccessChain %84 %451 %72 %473 %72 %72 +%475 = OpLoad %5 %474 +OpLine %3 189 20 +%476 = OpLoad %7 %455 +%477 = OpLoad %7 %455 +%478 = OpAccessChain %84 %451 %72 %476 %72 %477 +%479 = OpLoad %5 %478 +OpLine %3 190 21 +OpLine %3 190 21 +OpLine %3 190 21 +OpLine %3 190 21 +%480 = OpAccessChain %90 %451 %72 %72 %72 %72 %72 +%481 = OpLoad %6 %480 +OpLine %3 191 21 +OpLine %3 191 21 +OpLine %3 191 21 +%482 = OpLoad %7 %455 +%483 = OpAccessChain %90 %451 %72 %72 %72 %72 %482 +%484 = OpLoad %6 %483 +OpLine %3 192 21 +OpLine %3 192 21 +%485 = OpLoad %7 %455 +OpLine %3 192 21 +%486 = OpAccessChain %90 %451 %72 %72 %72 %485 %72 +%487 = OpLoad %6 %486 +OpLine %3 193 21 +OpLine %3 193 21 +%488 = OpLoad %7 %455 +%489 = OpLoad %7 %455 +%490 = OpAccessChain %90 %451 %72 %72 %72 %488 %489 +%491 = OpLoad %6 %490 +OpLine %3 194 21 +%492 = OpLoad %7 %455 +OpLine %3 194 21 +OpLine %3 194 21 +%493 = OpAccessChain %90 %451 %72 %492 %72 %72 %72 +%494 = OpLoad %6 %493 +OpLine %3 195 21 +%495 = OpLoad %7 %455 +OpLine %3 195 21 +%496 = OpLoad %7 %455 +%497 = OpAccessChain %90 %451 %72 %495 %72 %72 %496 +%498 = OpLoad %6 %497 +OpLine %3 196 21 +%499 = OpLoad %7 %455 +%500 = OpLoad %7 %455 +OpLine %3 196 21 +%501 = OpAccessChain %90 %451 %72 %499 %72 %500 %72 +%502 = OpLoad %6 %501 +OpLine %3 197 21 +%503 = OpLoad %7 %455 +%504 = OpLoad %7 %455 +%505 = OpLoad %7 %455 +%506 = OpAccessChain %90 %451 %72 %503 %72 %504 %505 +%507 = OpLoad %6 %506 +OpLine %3 200 17 +%508 = OpLoad %18 %453 +%509 = OpFunctionCall %13 %428 %508 +OpLine %3 201 17 +%512 = OpAccessChain %511 %453 %72 +%513 = OpLoad %17 %512 +%514 = OpFunctionCall %12 %433 %513 +OpLine %3 202 19 +OpLine %3 202 19 +%515 = OpAccessChain %157 %453 %72 %72 +%516 = OpAccessChain %105 %515 %72 +%517 = OpLoad %5 %516 +%518 = OpAccessChain %105 %515 %186 +%519 = OpLoad %5 %518 +%520 = OpAccessChain %105 %515 %187 +%521 = OpLoad %5 %520 +%522 = OpAccessChain %105 %515 %188 +%523 = OpLoad %5 %522 +%524 = OpCompositeConstruct %4 %517 %519 %521 %523 +OpLine %3 203 19 +%525 = OpLoad %7 %455 +%526 = OpAccessChain %157 %453 %72 %525 +%527 = OpAccessChain %105 %526 %72 +%528 = OpLoad %5 %527 +%529 = OpAccessChain %105 %526 %186 +%530 = OpLoad %5 %529 +%531 = OpAccessChain %105 %526 %187 +%532 = OpLoad %5 %531 +%533 = OpAccessChain %105 %526 %188 +%534 = OpLoad %5 %533 +%535 = OpCompositeConstruct %4 %528 %530 %532 %534 +OpLine %3 204 20 +OpLine %3 204 20 +OpLine %3 204 20 +%536 = OpAccessChain %105 %453 %72 %72 %72 +%537 = OpLoad %5 %536 +OpLine %3 205 20 +OpLine %3 205 20 +%538 = OpLoad %7 %455 +%539 = OpAccessChain %157 %453 %72 %72 +%540 = OpAccessChain %105 %539 %72 +%541 = OpLoad %5 %540 +%542 = OpAccessChain %105 %539 %186 +%543 = OpLoad %5 %542 +%544 = OpAccessChain %105 %539 %187 +%545 = OpLoad %5 %544 +%546 = OpAccessChain %105 %539 %188 +%547 = OpLoad %5 %546 +%548 = OpCompositeConstruct %4 %541 %543 %545 %547 +%549 = OpBitcast %11 %538 +%550 = OpFunctionCall %5 %52 %548 %549 +OpLine %3 206 20 +%551 = OpLoad %7 %455 +OpLine %3 206 20 +%552 = OpAccessChain %105 %453 %72 %551 %72 +%553 = OpLoad %5 %552 +OpLine %3 207 20 +%554 = OpLoad %7 %455 +%555 = OpLoad %7 %455 +%556 = OpAccessChain %157 %453 %72 %554 +%557 = OpAccessChain %105 %556 %72 +%558 = OpLoad %5 %557 +%559 = OpAccessChain %105 %556 %186 +%560 = OpLoad %5 %559 +%561 = OpAccessChain %105 %556 %187 +%562 = OpLoad %5 %561 +%563 = OpAccessChain %105 %556 %188 +%564 = OpLoad %5 %563 +%565 = OpCompositeConstruct %4 %558 %560 %562 %564 +%566 = OpBitcast %11 %555 +%567 = OpFunctionCall %5 %52 %565 %566 +OpLine %3 208 21 +OpLine %3 208 21 +OpLine %3 208 21 +OpLine %3 208 21 +%568 = OpAccessChain %113 %453 %72 %72 %72 %72 +%569 = OpLoad %6 %568 +OpLine %3 209 21 +OpLine %3 209 21 +OpLine %3 209 21 +%570 = OpLoad %7 %455 +%571 = OpAccessChain %113 %453 %72 %72 %72 %570 +%572 = OpLoad %6 %571 +OpLine %3 210 21 +OpLine %3 210 21 +%573 = OpLoad %7 %455 +OpLine %3 210 21 +%574 = OpAccessChain %157 %453 %72 %72 +%575 = OpAccessChain %105 %574 %72 +%576 = OpLoad %5 %575 +%577 = OpAccessChain %105 %574 %186 +%578 = OpLoad %5 %577 +%579 = OpAccessChain %105 %574 %187 +%580 = OpLoad %5 %579 +%581 = OpAccessChain %105 %574 %188 +%582 = OpLoad %5 %581 +%583 = OpCompositeConstruct %4 %576 %578 %580 %582 +%584 = OpBitcast %11 %573 +%585 = OpFunctionCall %5 %52 %583 %584 +%586 = OpCompositeExtract %6 %585 0 +OpLine %3 211 21 +OpLine %3 211 21 +%587 = OpLoad %7 %455 +%588 = OpLoad %7 %455 +%589 = OpAccessChain %157 %453 %72 %72 +%590 = OpAccessChain %105 %589 %72 +%591 = OpLoad %5 %590 +%592 = OpAccessChain %105 %589 %186 +%593 = OpLoad %5 %592 +%594 = OpAccessChain %105 %589 %187 +%595 = OpLoad %5 %594 +%596 = OpAccessChain %105 %589 %188 +%597 = OpLoad %5 %596 +%598 = OpCompositeConstruct %4 %591 %593 %595 %597 +%599 = OpBitcast %11 %587 +%600 = OpFunctionCall %5 %52 %598 %599 +%601 = OpVectorExtractDynamic %6 %600 %588 +OpLine %3 212 21 +%602 = OpLoad %7 %455 +OpLine %3 212 21 +OpLine %3 212 21 +%603 = OpAccessChain %113 %453 %72 %602 %72 %72 +%604 = OpLoad %6 %603 +OpLine %3 213 21 +%605 = OpLoad %7 %455 +OpLine %3 213 21 +%606 = OpLoad %7 %455 +%607 = OpAccessChain %113 %453 %72 %605 %72 %606 +%608 = OpLoad %6 %607 +OpLine %3 214 21 +%609 = OpLoad %7 %455 +%610 = OpLoad %7 %455 +OpLine %3 214 21 +%611 = OpAccessChain %157 %453 %72 %609 +%612 = OpAccessChain %105 %611 %72 +%613 = OpLoad %5 %612 +%614 = OpAccessChain %105 %611 %186 +%615 = OpLoad %5 %614 +%616 = OpAccessChain %105 %611 %187 +%617 = OpLoad %5 %616 +%618 = OpAccessChain %105 %611 %188 +%619 = OpLoad %5 %618 +%620 = OpCompositeConstruct %4 %613 %615 %617 %619 +%621 = OpBitcast %11 %610 +%622 = OpFunctionCall %5 %52 %620 %621 +%623 = OpCompositeExtract %6 %622 0 +OpLine %3 215 21 +%624 = OpLoad %7 %455 +%625 = OpLoad %7 %455 +%626 = OpLoad %7 %455 +%627 = OpAccessChain %157 %453 %72 %624 +%628 = OpAccessChain %105 %627 %72 +%629 = OpLoad %5 %628 +%630 = OpAccessChain %105 %627 %186 +%631 = OpLoad %5 %630 +%632 = OpAccessChain %105 %627 %187 +%633 = OpLoad %5 %632 +%634 = OpAccessChain %105 %627 %188 +%635 = OpLoad %5 %634 +%636 = OpCompositeConstruct %4 %629 %631 %633 %635 +%637 = OpBitcast %11 %625 +%638 = OpFunctionCall %5 %52 %636 %637 +%639 = OpVectorExtractDynamic %6 %638 %626 +OpLine %3 218 5 +OpStore %451 %509 +OpLine %3 219 5 +OpLine %3 219 5 +%640 = OpAccessChain %460 %451 %72 +OpStore %640 %514 +OpLine %3 220 5 +OpLine %3 220 5 +OpLine %3 220 5 +%641 = OpAccessChain %71 %451 %72 %72 %72 +OpStore %641 %524 +OpLine %3 221 5 +%642 = OpLoad %7 %455 +OpLine %3 221 5 +%643 = OpAccessChain %71 %451 %72 %642 %72 +OpStore %643 %535 +OpLine %3 222 5 +OpLine %3 222 5 +OpLine %3 222 5 +OpLine %3 222 5 +%644 = OpAccessChain %84 %451 %72 %72 %72 %72 +OpStore %644 %537 +OpLine %3 223 5 +OpLine %3 223 5 +%645 = OpLoad %7 %455 +OpLine %3 223 5 +%646 = OpAccessChain %84 %451 %72 %72 %72 %645 +OpStore %646 %550 +OpLine %3 224 5 +%647 = OpLoad %7 %455 +OpLine %3 224 5 +OpLine %3 224 5 +%648 = OpAccessChain %84 %451 %72 %647 %72 %72 +OpStore %648 %553 +OpLine %3 225 5 +%649 = OpLoad %7 %455 +%650 = OpLoad %7 %455 +OpLine %3 225 5 +%651 = OpAccessChain %84 %451 %72 %649 %72 %650 +OpStore %651 %567 +OpLine %3 226 5 +OpLine %3 226 5 +OpLine %3 226 5 +OpLine %3 226 5 +OpLine %3 226 5 +%652 = OpAccessChain %90 %451 %72 %72 %72 %72 %72 +OpStore %652 %569 +OpLine %3 227 5 +OpLine %3 227 5 +OpLine %3 227 5 +%653 = OpLoad %7 %455 +OpLine %3 227 5 +%654 = OpAccessChain %90 %451 %72 %72 %72 %72 %653 +OpStore %654 %572 +OpLine %3 228 5 +OpLine %3 228 5 +%655 = OpLoad %7 %455 +OpLine %3 228 5 +OpLine %3 228 5 +%656 = OpAccessChain %90 %451 %72 %72 %72 %655 %72 +OpStore %656 %586 +OpLine %3 229 5 +OpLine %3 229 5 +%657 = OpLoad %7 %455 +%658 = OpLoad %7 %455 +OpLine %3 229 5 +%659 = OpAccessChain %90 %451 %72 %72 %72 %657 %658 +OpStore %659 %601 +OpLine %3 230 5 +%660 = OpLoad %7 %455 +OpLine %3 230 5 +OpLine %3 230 5 +OpLine %3 230 5 +%661 = OpAccessChain %90 %451 %72 %660 %72 %72 %72 +OpStore %661 %604 +OpLine %3 231 5 +%662 = OpLoad %7 %455 +OpLine %3 231 5 +%663 = OpLoad %7 %455 +OpLine %3 231 5 +%664 = OpAccessChain %90 %451 %72 %662 %72 %72 %663 +OpStore %664 %608 +OpLine %3 232 5 +%665 = OpLoad %7 %455 +%666 = OpLoad %7 %455 +OpLine %3 232 5 +OpLine %3 232 5 +%667 = OpAccessChain %90 %451 %72 %665 %72 %666 %72 +OpStore %667 %623 +OpLine %3 233 5 +%668 = OpLoad %7 %455 +%669 = OpLoad %7 %455 +%670 = OpLoad %7 %455 +OpLine %3 233 5 +%671 = OpAccessChain %90 %451 %72 %668 %72 %669 %670 +OpStore %671 %639 +OpReturn +OpFunctionEnd +%673 = OpFunction %2 None %70 +%672 = OpLabel +%674 = OpAccessChain %71 %19 %72 +%675 = OpAccessChain %74 %22 %72 +%676 = OpAccessChain %155 %25 %72 +%677 = OpAccessChain %157 %28 %72 +%678 = OpAccessChain %271 %31 %72 +%679 = OpAccessChain %273 %34 %72 +%680 = OpAccessChain %450 %37 %72 +%681 = OpAccessChain %452 %40 %72 +OpBranch %682 +%682 = OpLabel +OpLine %3 238 5 +%683 = OpFunctionCall %2 %69 +OpLine %3 239 5 +%684 = OpFunctionCall %2 %154 +OpLine %3 240 5 +%685 = OpFunctionCall %2 %270 +OpLine %3 241 5 +%686 = OpFunctionCall %2 %449 +OpReturn +OpFunctionEnd \ No newline at end of file