steve-lunarg | 297ae21 | 2016-08-24 14:36:13 -0600 | [diff] [blame] | 1 | uniform int idx; |
| 2 | uniform float3x2 um; |
| 3 | |
| 4 | struct PS_OUTPUT |
| 5 | { |
| 6 | float4 Color : SV_Target0; |
| 7 | }; |
| 8 | |
| 9 | PS_OUTPUT main() |
| 10 | { |
| 11 | // matrices of 3 rows, 2 columns (regardless of row vs col major storage) |
| 12 | const float3x2 m1 = { { 10, 11 }, // row-wise initialization |
| 13 | { 12, 13 }, |
| 14 | { 14, 15 } }; |
| 15 | |
| 16 | const float3x2 m2 = { 20, 21, 22, 23, 24, 25 }; // component-wise matrix initialization is allowed |
| 17 | const float3x2 m3 = { 30, 31, 33, 33, 34, 35 }; // component-wise matrix initialization is allowed |
| 18 | |
| 19 | // These can be observed in the AST post-const folding to ensure we obtain the right value, |
| 20 | // as given in comments to the right of each line. Note that the first indirection into a |
| 21 | // matrix returns a row vector. |
| 22 | float e1_00 = m1[0][0]; // 10 |
| 23 | float e1_01 = m1[0][1]; // 11 |
| 24 | float e1_10 = m1[1][0]; // 12 |
| 25 | float e1_11 = m1[1][1]; // 13 |
| 26 | float e1_20 = m1[2][0]; // 14 |
| 27 | float e1_21 = m1[2][1]; // 15 |
| 28 | |
| 29 | float e2_00 = m2[0][0]; // 20 |
| 30 | float e2_01 = m2[0][1]; // 21 |
| 31 | float e2_10 = m2[1][0]; // 22 |
| 32 | float e2_11 = m2[1][1]; // 23 |
| 33 | float e2_20 = m2[2][0]; // 24 |
| 34 | float e2_21 = m2[2][1]; // 25 |
| 35 | |
| 36 | // float e3a_00 = m3._m00; // TODO... also as an lvalue for a non-const matrix |
| 37 | // float e3b_00 = m3._11; // TODO... also as an lvalue for a non-const matrix |
| 38 | |
| 39 | float2 r0a = m1[0]; // row0: 10,11: types must match: constant index into constant |
| 40 | float2 r1a = m1[1]; // row1: 12,13: ... |
| 41 | float2 r2a = m1[2]; // row2: 14,15: ... |
| 42 | |
| 43 | float2 r0b = m2[idx]; // types should match: variable index into constant |
| 44 | float2 r0c = um[idx]; // types should match: variable index into variable |
| 45 | |
| 46 | PS_OUTPUT psout; |
| 47 | psout.Color = e2_11; // 23 |
| 48 | return psout; |
| 49 | } |