• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1uniform half4 colorGreen, colorRed;
2
3bool test_float() {
4    bool ok = true;
5
6    float2x3 m23 = float2x3(2);
7    ok = ok && (m23 == float2x3(2, 0, 0,
8                                0, 2, 0));
9    float2x4 m24 = float2x4(3);
10    ok = ok && (m24 == float2x4(3, 0, 0, 0,
11                                0, 3, 0, 0));
12    float3x2 m32 = float3x2(4);
13    ok = ok && (m32 == float3x2(4, 0,
14                                0, 4,
15                                0, 0));
16    float3x4 m34 = float3x4(5);
17    ok = ok && (m34 == float3x4(5, 0, 0, 0,
18                                0, 5, 0, 0,
19                                0, 0, 5, 0));
20    float4x2 m42 = float4x2(6);
21    ok = ok && (m42 == float4x2(6, 0,
22                                0, 6,
23                                0, 0,
24                                0, 0));
25    float4x3 m43 = float4x3(7);
26    ok = ok && (m43 == float4x3(7, 0, 0,
27                                0, 7, 0,
28                                0, 0, 7,
29                                0, 0, 0));
30    float2x2 m22 = m32 * m23;
31    ok = ok && (m22 == float2x2(2 * 4));
32    float3x3 m33 = m43 * m34;
33    ok = ok && (m33 == float3x3(7 * 5));
34    float4x4 m44 = m24 * m42;
35
36    m23 += 1;
37    ok = ok && (m23 == float2x3(3, 1, 1,
38                                1, 3, 1));
39    m32 -= 2;
40    ok = ok && (m32 == float3x2(2, -2,
41                                -2, 2,
42                                -2, -2));
43    m24 /= 4;
44    ok = ok && (m24 == float2x4(0.75, 0, 0, 0,
45                                0, 0.75, 0, 0));
46    return ok;
47}
48
49bool test_half() {
50    bool ok = true;
51
52    half2x3 m23 = half2x3(2);
53    ok = ok && (m23 == half2x3(2, 0, 0,
54                               0, 2, 0));
55    half2x4 m24 = half2x4(3);
56    ok = ok && (m24 == half2x4(3, 0, 0, 0,
57                               0, 3, 0, 0));
58    half3x2 m32 = half3x2(4);
59    ok = ok && (m32 == half3x2(4, 0,
60                               0, 4,
61                               0, 0));
62    half3x4 m34 = half3x4(5);
63    ok = ok && (m34 == half3x4(5, 0, 0, 0,
64                               0, 5, 0, 0,
65                               0, 0, 5, 0));
66    half4x2 m42 = half4x2(6);
67    ok = ok && (m42 == half4x2(6, 0,
68                               0, 6,
69                               0, 0,
70                               0, 0));
71    half4x3 m43 = half4x3(7);
72    ok = ok && (m43 == half4x3(7, 0, 0,
73                               0, 7, 0,
74                               0, 0, 7,
75                               0, 0, 0));
76    half2x2 m22 = m32 * m23;
77    ok = ok && (m22 == half2x2(2 * 4));
78    half3x3 m33 = m43 * m34;
79    ok = ok && (m33 == half3x3(7 * 5));
80    half4x4 m44 = m24 * m42;
81
82    m23 += 1;
83    ok = ok && (m23 == half2x3(3, 1, 1,
84                               1, 3, 1));
85    m32 -= 2;
86    ok = ok && (m32 == half3x2(2, -2,
87                               -2, 2,
88                               -2, -2));
89    m24 /= 4;
90    ok = ok && (m24 == half2x4(0.75, 0, 0, 0,
91                               0, 0.75, 0, 0));
92    return ok;
93}
94
95half4 main(float2 coords) {
96    return test_float() && test_half() ? colorGreen : colorRed;
97}
98