• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1uniform half  unknownInput;
2uniform half4 colorRed, colorGreen;
3
4bool test_half() {
5    half unknown = unknownInput;
6
7    bool ok = true;
8    ok = ok &&  (half4(half2(1), half2(2, 3)) + half4(5, 6, 7, 8)) == half4(6, 7, 9, 11);
9    ok = ok &&  (half4(8, half3(10)) - half4(1))                   == half4(7, 9, 9, 9);
10    ok = ok &&  (half4(2) * half4(1, 2, 3, 4))                     == half4(2, 4, 6, 8);
11    ok = ok &&  (half4(12) / half4(1, 2, 3, 4))                    == half4(12, 6, 4, 3);
12    ok = ok && !(half4(1) == half4(2));
13    ok = ok &&  (half2(1) == half2(1, 1));
14    ok = ok &&  (half2(1, 1) == half2(1, 1));
15    ok = ok && !(half2(1) == half2(1, 0));
16    ok = ok &&  (half4(1) == half4(half2(1), half2(1)));
17    ok = ok &&  (half4(half3(1), 1) == half4(half2(1), half2(1)));
18    ok = ok && !(half4(half3(1), 1) == half4(half2(1), 1, 0));
19    ok = ok &&  (half2(1) != half2(1, 0));
20    ok = ok && !(half4(1) != half4(half2(1), half2(1)));
21    ok = ok &&  ( half4(1) ==  half4(1));
22    ok = ok &&  (-half4(1) == -half4(1));
23    ok = ok &&  ( half4(1) != -half4(1));
24    ok = ok &&  (-half4(1) !=  half4(1));
25    ok = ok &&  ( half4(0) != -half4(1));
26    ok = ok &&  (-half4(0) !=  half4(1));
27    ok = ok &&  (-half4(0) != -half4(1));
28    ok = ok && !(-half4(1) ==  half4(1));
29    ok = ok && !( half4(1) == -half4(1));
30    ok = ok && !( half4(0) ==  half4(1));
31    ok = ok && !( half4(0) == -half4(1));
32    ok = ok && !(-half4(0) ==  half4(1));
33    ok = ok && !(-half4(0) == -half4(1));
34    ok = ok && !(-half4(1) != -half4(1));
35    ok = ok &&  (half4(unknown) * half4(1) == half4(unknown));
36    ok = ok &&  (half4(1) * half4(unknown) == half4(unknown));
37    ok = ok &&  (half4(unknown) * half4(0) == half4(0));
38    ok = ok &&  (half4(0) * half4(unknown) == half4(0));
39    ok = ok &&  (half4(0) / half4(unknown) == half4(0));  // this should NOT optimize away
40    ok = ok &&  (half4(unknown) + half4(0) == half4(unknown));
41    ok = ok &&  (half4(0) + half4(unknown) == half4(unknown));
42    ok = ok &&  (half4(unknown) - half4(0) == half4(unknown));
43
44    half4 val = half4(unknown);
45    val += half4(1);
46    val += half4(0);
47    val -= half4(1);
48    val -= half4(0);
49    val = val + half4(1);
50    val = val + half4(0);
51    val = val - half4(1);
52    val = val - half4(0);
53    ok = ok && (val == half4(unknown));
54    val *= half4(1);
55    val *= half4(2);
56    val /= half4(1);
57    val /= half4(2);
58    val = val * half4(1);
59    val = val * half4(2);
60    val = val / half4(1);
61    val = val / half4(2);
62    ok = ok && (val == half4(unknown));
63
64    return ok;
65}
66
67bool test_int() {
68    int unknown = int(unknownInput);
69
70    bool ok = true;
71    ok = ok &&  (int4(int2(1), int2(2, 3)) + int4(5, 6, 7, 8)) == int4(6, 7, 9, 11);
72    ok = ok &&  (int4(8, int3(10)) - int4(1))                  == int4(7, 9, 9, 9);
73    ok = ok &&  (int4(2) * int4(1, 2, 3, 4))                   == int4(2, 4, 6, 8);
74    ok = ok &&  (int4(12) / int4(1, 2, 3, 4))                  == int4(12, 6, 4, 3);
75    ok = ok && !(int4(1) == int4(2));
76    ok = ok &&  (int2(1) == int2(1, 1));
77    ok = ok &&  (int2(1, 1) == int2(1, 1));
78    ok = ok && !(int2(1) == int2(1, 0));
79    ok = ok &&  (int4(1) == int4(int2(1), int2(1)));
80    ok = ok &&  (int4(int3(1), 1) == int4(int2(1), int2(1)));
81    ok = ok && !(int4(int3(1), 1) == int4(int2(1), 1, 0));
82    ok = ok &&  (int2(1) != int2(1, 0));
83    ok = ok && !(int4(1) != int4(int2(1), int2(1)));
84    ok = ok &&  ( int4(1) ==  int4(1));
85    ok = ok &&  (-int4(1) == -int4(1));
86    ok = ok &&  ( int4(1) != -int4(1));
87    ok = ok &&  (-int4(1) !=  int4(1));
88    ok = ok &&  ( int4(0) != -int4(1));
89    ok = ok &&  (-int4(0) !=  int4(1));
90    ok = ok &&  (-int4(0) != -int4(1));
91    ok = ok && !(-int4(1) ==  int4(1));
92    ok = ok && !( int4(1) == -int4(1));
93    ok = ok && !( int4(0) ==  int4(1));
94    ok = ok && !( int4(0) == -int4(1));
95    ok = ok && !(-int4(0) ==  int4(1));
96    ok = ok && !(-int4(0) == -int4(1));
97    ok = ok && !(-int4(1) != -int4(1));
98    ok = ok &&  (int4(unknown) * int4(1) == int4(unknown));
99    ok = ok &&  (int4(1) * int4(unknown) == int4(unknown));
100    ok = ok &&  (int4(unknown) * int4(0) == int4(0));
101    ok = ok &&  (int4(0) * int4(unknown) == int4(0));
102    ok = ok &&  (int4(0) / int4(unknown) == int4(0));
103    ok = ok &&  (int4(unknown) + int4(0) == int4(unknown));
104    ok = ok &&  (int4(0) + int4(unknown) == int4(unknown));
105    ok = ok &&  (int4(unknown) - int4(0) == int4(unknown));
106
107    int4 val = int4(unknown);
108    val += int4(1);
109    val += int4(0);
110    val -= int4(1);
111    val -= int4(0);
112    val = val + int4(1);
113    val = val + int4(0);
114    val = val - int4(1);
115    val = val - int4(0);
116    ok = ok && (val == int4(unknown));
117    val *= int4(1);
118    val *= int4(2);
119    val /= int4(1);
120    val /= int4(2);
121    val = val * int4(1);
122    val = val * int4(2);
123    val = val / int4(1);
124    val = val / int4(2);
125    ok = ok && (val == int4(unknown));
126
127    return ok;
128}
129
130half4 main(float2 coords) {
131    return test_half() && test_int() ? colorGreen : colorRed;
132}
133