1uniform half4 colorGreen, colorRed; 2 3bool test_float() { 4 bool ok = true; 5 6 float2x2 m1 = float2x2(float4(1, 2, 3, 4)); 7 ok = ok && (m1 == float2x2(1, 2, 3, 4)); 8 9 // This generates {5, 0, 0, 5} on some Radeon GPUs. 10// float2x2 m2 = float2x2(float4(5)); 11// ok = ok && (m2 == float2x2(5, 5, 5, 5)); 12 13 float2x2 m3 = float2x2(m1); 14 ok = ok && (m3 == float2x2(1, 2, 3, 4)); 15 16 float2x2 m4 = float2x2(6); 17 ok = ok && (m4 == float2x2(6, 0, 0, 6)); 18 19 m3 *= m4; 20 ok = ok && (m3 == float2x2(6, 12, 18, 24)); 21 22 float2x2 m5 = float2x2(m1[1][1]); 23 ok = ok && (m5 == float2x2(4, 0, 0, 4)); 24 25 m1 += m5; 26 ok = ok && (m1 == float2x2(5, 2, 3, 8)); 27 28 float2x2 m7 = float2x2(5, float3(6, 7, 8)); 29 ok = ok && (m7 == float2x2(5, 6, 7, 8)); 30 31 float3x3 m9 = float3x3(9); 32 ok = ok && (m9 == float3x3(9, 0, 0, 0, 9, 0, 0, 0, 9)); 33 34 float4x4 m10 = float4x4(11); 35 ok = ok && (m10 == float4x4(11, 0, 0, 0, 0, 11, 0, 0, 0, 0, 11, 0, 0, 0, 0, 11)); 36 37 float4x4 m11 = float4x4(20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20); 38 m11 -= m10; 39 ok = ok && (m11 == float4x4(9, 20, 20, 20, 20, 9, 20, 20, 20, 20, 9, 20, 20, 20, 20, 9)); 40 41 return ok; 42} 43 44bool test_half() { 45 bool ok = true; 46 47 half2x2 m1 = half2x2(half4(1, 2, 3, 4)); 48 ok = ok && (m1 == half2x2(1, 2, 3, 4)); 49 50 // This generates {5, 0, 0, 5} on some Radeon GPUs. 51// half2x2 m2 = half2x2(half4(5)); 52// ok = ok && (m2 == half2x2(5, 5, 5, 5)); 53 54 half2x2 m3 = half2x2(m1); 55 ok = ok && (m3 == half2x2(1, 2, 3, 4)); 56 57 half2x2 m4 = half2x2(6); 58 ok = ok && (m4 == half2x2(6, 0, 0, 6)); 59 60 m3 *= m4; 61 ok = ok && (m3 == half2x2(6, 12, 18, 24)); 62 63 half2x2 m5 = half2x2(m1[1][1]); 64 ok = ok && (m5 == half2x2(4, 0, 0, 4)); 65 66 m1 += m5; 67 ok = ok && (m1 == half2x2(5, 2, 3, 8)); 68 69 half2x2 m7 = half2x2(5, half3(6, 7, 8)); 70 ok = ok && (m7 == half2x2(5, 6, 7, 8)); 71 72 half3x3 m9 = half3x3(9); 73 ok = ok && (m9 == half3x3(9, 0, 0, 0, 9, 0, 0, 0, 9)); 74 75 half4x4 m10 = half4x4(11); 76 ok = ok && (m10 == half4x4(11, 0, 0, 0, 0, 11, 0, 0, 0, 0, 11, 0, 0, 0, 0, 11)); 77 78 half4x4 m11 = half4x4(20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20); 79 m11 -= m10; 80 ok = ok && (m11 == half4x4(9, 20, 20, 20, 20, 9, 20, 20, 20, 20, 9, 20, 20, 20, 20, 9)); 81 82 return ok; 83} 84 85bool test_comma() { 86 float2x2 x, y; 87 return (x = float2x2(1, 2, 3, 4), 88 y = 0.5 * float2x2(2, 4, 6, 8), 89 x == y); 90} 91 92half4 main(float2 coords) { 93 return test_float() && test_half() && test_comma() ? colorGreen : colorRed; 94} 95