1617a3babSopenharmony_ciuniform int idx; 2617a3babSopenharmony_ciuniform float3x2 um; 3617a3babSopenharmony_ci 4617a3babSopenharmony_cistruct PS_OUTPUT 5617a3babSopenharmony_ci{ 6617a3babSopenharmony_ci float4 Color : SV_Target0; 7617a3babSopenharmony_ci}; 8617a3babSopenharmony_ci 9617a3babSopenharmony_ciPS_OUTPUT main() 10617a3babSopenharmony_ci{ 11617a3babSopenharmony_ci // matrices of 3 rows, 2 columns (regardless of row vs col major storage) 12617a3babSopenharmony_ci const float3x2 m1 = { { 10, 11 }, // row-wise initialization 13617a3babSopenharmony_ci { 12, 13 }, 14617a3babSopenharmony_ci { 14, 15 } }; 15617a3babSopenharmony_ci 16617a3babSopenharmony_ci const float3x2 m2 = { 20, 21, 22, 23, 24, 25 }; // component-wise matrix initialization is allowed 17617a3babSopenharmony_ci const float3x2 m3 = { 30, 31, 33, 33, 34, 35 }; // component-wise matrix initialization is allowed 18617a3babSopenharmony_ci 19617a3babSopenharmony_ci // These can be observed in the AST post-const folding to ensure we obtain the right value, 20617a3babSopenharmony_ci // as given in comments to the right of each line. Note that the first indirection into a 21617a3babSopenharmony_ci // matrix returns a row vector. 22617a3babSopenharmony_ci float e1_00 = m1[0][0]; // 10 23617a3babSopenharmony_ci float e1_01 = m1[0][1]; // 11 24617a3babSopenharmony_ci float e1_10 = m1[1][0]; // 12 25617a3babSopenharmony_ci float e1_11 = m1[1][1]; // 13 26617a3babSopenharmony_ci float e1_20 = m1[2][0]; // 14 27617a3babSopenharmony_ci float e1_21 = m1[2][1]; // 15 28617a3babSopenharmony_ci 29617a3babSopenharmony_ci float e2_00 = m2[0][0]; // 20 30617a3babSopenharmony_ci float e2_01 = m2[0][1]; // 21 31617a3babSopenharmony_ci float e2_10 = m2[1][0]; // 22 32617a3babSopenharmony_ci float e2_11 = m2[1][1]; // 23 33617a3babSopenharmony_ci float e2_20 = m2[2][0]; // 24 34617a3babSopenharmony_ci float e2_21 = m2[2][1]; // 25 35617a3babSopenharmony_ci 36617a3babSopenharmony_ci // float e3a_00 = m3._m00; // TODO... also as an lvalue for a non-const matrix 37617a3babSopenharmony_ci // float e3b_00 = m3._11; // TODO... also as an lvalue for a non-const matrix 38617a3babSopenharmony_ci 39617a3babSopenharmony_ci float2 r0a = m1[0]; // row0: 10,11: types must match: constant index into constant 40617a3babSopenharmony_ci float2 r1a = m1[1]; // row1: 12,13: ... 41617a3babSopenharmony_ci float2 r2a = m1[2]; // row2: 14,15: ... 42617a3babSopenharmony_ci 43617a3babSopenharmony_ci float2 r0b = m2[idx]; // types should match: variable index into constant 44617a3babSopenharmony_ci float2 r0c = um[idx]; // types should match: variable index into variable 45617a3babSopenharmony_ci 46617a3babSopenharmony_ci PS_OUTPUT psout; 47617a3babSopenharmony_ci psout.Color = e2_11; // 23 48617a3babSopenharmony_ci return psout; 49617a3babSopenharmony_ci} 50