1cb93a386Sopenharmony_ciuniform half4 colorRed, colorGreen;
2cb93a386Sopenharmony_ciuniform half  unknownInput;
3cb93a386Sopenharmony_ci
4cb93a386Sopenharmony_cibool test_half() {
5cb93a386Sopenharmony_ci    bool ok = true;
6cb93a386Sopenharmony_ci
7cb93a386Sopenharmony_ci    // Vector op scalar
8cb93a386Sopenharmony_ci    half4 x = half4(half2(1), half2(2, 3)) + 5;
9cb93a386Sopenharmony_ci    ok = ok && (x == half4(6, 6, 7, 8));
10cb93a386Sopenharmony_ci    x = half4(8, half3(10)) - 1;
11cb93a386Sopenharmony_ci    ok = ok && (x == half4(7, 9, 9, 9));
12cb93a386Sopenharmony_ci    x = half4(half2(8), half2(9)) + 1;
13cb93a386Sopenharmony_ci    ok = ok && (x == half4(9, 9, 10, 10));
14cb93a386Sopenharmony_ci    x.xyz = half3(2) * 3;
15cb93a386Sopenharmony_ci    ok = ok && (x == half4(6, 6, 6, 10));
16cb93a386Sopenharmony_ci    x.xy = half2(12) / 4;
17cb93a386Sopenharmony_ci    ok = ok && (x == half4(3, 3, 6, 10));
18cb93a386Sopenharmony_ci
19cb93a386Sopenharmony_ci    // (Vector op scalar).swizzle
20cb93a386Sopenharmony_ci    x = (half4(12) / 2).yxwz;
21cb93a386Sopenharmony_ci    ok = ok && (x == half4(6));
22cb93a386Sopenharmony_ci
23cb93a386Sopenharmony_ci    // Scalar op vector
24cb93a386Sopenharmony_ci    x = 5 + half4(half2(1), half2(2, 3));
25cb93a386Sopenharmony_ci    ok = ok && (x == half4(6, 6, 7, 8));
26cb93a386Sopenharmony_ci    x = 1 - half4(8, half3(10));
27cb93a386Sopenharmony_ci    ok = ok && (x == half4(-7, -9, -9, -9));
28cb93a386Sopenharmony_ci    x = 1 + half4(half2(8), half2(9));
29cb93a386Sopenharmony_ci    ok = ok && (x == half4(9, 9, 10, 10));
30cb93a386Sopenharmony_ci    x.xyz = 3 * half3(2);
31cb93a386Sopenharmony_ci    ok = ok && (x == half4(6, 6, 6, 10));
32cb93a386Sopenharmony_ci    x.xy = 4 / half2(0.5);
33cb93a386Sopenharmony_ci    ok = ok && (x == half4(8, 8, 6, 10));
34cb93a386Sopenharmony_ci    x = 20 / half4(10, 20, 40, 80);
35cb93a386Sopenharmony_ci    ok = ok && (x == half4(2, 1, 0.5, 0.25));
36cb93a386Sopenharmony_ci
37cb93a386Sopenharmony_ci    // (Scalar op vector).swizzle
38cb93a386Sopenharmony_ci    x = (12 / half4(2)).yxwz;
39cb93a386Sopenharmony_ci    ok = ok && (x == half4(6));
40cb93a386Sopenharmony_ci
41cb93a386Sopenharmony_ci    // Vector op unknown scalar
42cb93a386Sopenharmony_ci    half  unknown = unknownInput;
43cb93a386Sopenharmony_ci    x = half4(0) + unknown;
44cb93a386Sopenharmony_ci    ok = ok && (x == half4(unknown));
45cb93a386Sopenharmony_ci    x = half4(0) * unknown;
46cb93a386Sopenharmony_ci    ok = ok && (x == half4(0));
47cb93a386Sopenharmony_ci    x = half4(0) / unknown;
48cb93a386Sopenharmony_ci    ok = ok && (x == half4(0));
49cb93a386Sopenharmony_ci    x = half4(1) * unknown;
50cb93a386Sopenharmony_ci    ok = ok && (x == half4(unknown));
51cb93a386Sopenharmony_ci
52cb93a386Sopenharmony_ci    // Unknown scalar op vector
53cb93a386Sopenharmony_ci    x = unknown * half4(1);
54cb93a386Sopenharmony_ci    ok = ok && (x == half4(unknown));
55cb93a386Sopenharmony_ci    x = unknown + half4(0);
56cb93a386Sopenharmony_ci    ok = ok && (x == half4(unknown));
57cb93a386Sopenharmony_ci    x = unknown - half4(0);
58cb93a386Sopenharmony_ci    ok = ok && (x == half4(unknown));
59cb93a386Sopenharmony_ci    x = unknown / half4(1);
60cb93a386Sopenharmony_ci    ok = ok && (x == half4(unknown));
61cb93a386Sopenharmony_ci
62cb93a386Sopenharmony_ci    // Scalar op unknown vector
63cb93a386Sopenharmony_ci    x = 0 + half4(unknown);
64cb93a386Sopenharmony_ci    ok = ok && (x == half4(unknown));
65cb93a386Sopenharmony_ci    x = 0 * half4(unknown);
66cb93a386Sopenharmony_ci    ok = ok && (x == half4(0));
67cb93a386Sopenharmony_ci    x = 0 / half4(unknown);  // this should NOT optimize away
68cb93a386Sopenharmony_ci    ok = ok && (x == half4(0));
69cb93a386Sopenharmony_ci    x = 1 * half4(unknown);
70cb93a386Sopenharmony_ci    ok = ok && (x == half4(unknown));
71cb93a386Sopenharmony_ci
72cb93a386Sopenharmony_ci    // X = Unknown op scalar
73cb93a386Sopenharmony_ci    x = half4(unknown) + 0;
74cb93a386Sopenharmony_ci    ok = ok && (x == half4(unknown));
75cb93a386Sopenharmony_ci    x = half4(unknown) * 0;
76cb93a386Sopenharmony_ci    ok = ok && (x == half4(0));
77cb93a386Sopenharmony_ci    x = half4(unknown) * 1;
78cb93a386Sopenharmony_ci    ok = ok && (x == half4(unknown));
79cb93a386Sopenharmony_ci    x = half4(unknown) - 0;
80cb93a386Sopenharmony_ci    ok = ok && (x == half4(unknown));
81cb93a386Sopenharmony_ci
82cb93a386Sopenharmony_ci    // X op= scalar.
83cb93a386Sopenharmony_ci    x = half4(unknown);
84cb93a386Sopenharmony_ci    x += 1;
85cb93a386Sopenharmony_ci    x += 0;
86cb93a386Sopenharmony_ci    x -= 1;
87cb93a386Sopenharmony_ci    x -= 0;
88cb93a386Sopenharmony_ci    x *= 1;
89cb93a386Sopenharmony_ci    x /= 1;
90cb93a386Sopenharmony_ci    ok = ok && (x == half4(unknown));
91cb93a386Sopenharmony_ci
92cb93a386Sopenharmony_ci    // X = X op scalar.
93cb93a386Sopenharmony_ci    x = half4(unknown);
94cb93a386Sopenharmony_ci    x = x + 1;
95cb93a386Sopenharmony_ci    x = x + 0;
96cb93a386Sopenharmony_ci    x = x - 1;
97cb93a386Sopenharmony_ci    x = x - 0;
98cb93a386Sopenharmony_ci    x = x * 1;
99cb93a386Sopenharmony_ci    x = x / 1;
100cb93a386Sopenharmony_ci    ok = ok && (x == half4(unknown));
101cb93a386Sopenharmony_ci
102cb93a386Sopenharmony_ci    return ok;
103cb93a386Sopenharmony_ci}
104cb93a386Sopenharmony_ci
105cb93a386Sopenharmony_cibool test_int() {
106cb93a386Sopenharmony_ci    bool ok = true;
107cb93a386Sopenharmony_ci
108cb93a386Sopenharmony_ci    // Vector op scalar
109cb93a386Sopenharmony_ci    int4 x = int4(int2(1), int2(2, 3)) + 5;
110cb93a386Sopenharmony_ci    ok = ok && (x == int4(6, 6, 7, 8));
111cb93a386Sopenharmony_ci    x = int4(8, int3(10)) - 1;
112cb93a386Sopenharmony_ci    ok = ok && (x == int4(7, 9, 9, 9));
113cb93a386Sopenharmony_ci    x = int4(int2(8), int2(9)) + 1;
114cb93a386Sopenharmony_ci    ok = ok && (x == int4(9, 9, 10, 10));
115cb93a386Sopenharmony_ci    x.xyz = int3(2) * 3;
116cb93a386Sopenharmony_ci    ok = ok && (x == int4(6, 6, 6, 10));
117cb93a386Sopenharmony_ci    x.xy = int2(12) / 4;
118cb93a386Sopenharmony_ci    ok = ok && (x == int4(3, 3, 6, 10));
119cb93a386Sopenharmony_ci
120cb93a386Sopenharmony_ci    // (Vector op scalar).swizzle
121cb93a386Sopenharmony_ci    x = (int4(12) / 2).yxwz;
122cb93a386Sopenharmony_ci    ok = ok && (x == int4(6));
123cb93a386Sopenharmony_ci
124cb93a386Sopenharmony_ci    // Scalar op vector
125cb93a386Sopenharmony_ci    x = 5 + int4(int2(1), int2(2, 3));
126cb93a386Sopenharmony_ci    ok = ok && (x == int4(6, 6, 7, 8));
127cb93a386Sopenharmony_ci    x = 1 - int4(8, int3(10));
128cb93a386Sopenharmony_ci    ok = ok && (x == int4(-7, -9, -9, -9));
129cb93a386Sopenharmony_ci    x = 1 + int4(int2(8), int2(9));
130cb93a386Sopenharmony_ci    ok = ok && (x == int4(9, 9, 10, 10));
131cb93a386Sopenharmony_ci    x.xyz = 3 * int3(2);
132cb93a386Sopenharmony_ci    ok = ok && (x == int4(6, 6, 6, 10));
133cb93a386Sopenharmony_ci    x.xy = 16 / int2(2);
134cb93a386Sopenharmony_ci    ok = ok && (x == int4(8, 8, 6, 10));
135cb93a386Sopenharmony_ci    x = 2000 / int4(10, 20, 40, 80);
136cb93a386Sopenharmony_ci    ok = ok && (x == int4(200, 100, 50, 25));
137cb93a386Sopenharmony_ci
138cb93a386Sopenharmony_ci    // (Scalar op vector).swizzle
139cb93a386Sopenharmony_ci    x = (12 / int4(2)).yxwz;
140cb93a386Sopenharmony_ci    ok = ok && (x == int4(6));
141cb93a386Sopenharmony_ci
142cb93a386Sopenharmony_ci    // Vector op unknown scalar
143cb93a386Sopenharmony_ci    int  unknown = int(unknownInput);
144cb93a386Sopenharmony_ci    x = int4(0) + unknown;
145cb93a386Sopenharmony_ci    ok = ok && (x == int4(unknown));
146cb93a386Sopenharmony_ci    x = int4(0) * unknown;
147cb93a386Sopenharmony_ci    ok = ok && (x == int4(0));
148cb93a386Sopenharmony_ci    x = int4(0) / unknown;
149cb93a386Sopenharmony_ci    ok = ok && (x == int4(0));
150cb93a386Sopenharmony_ci    x = int4(1) * unknown;
151cb93a386Sopenharmony_ci    ok = ok && (x == int4(unknown));
152cb93a386Sopenharmony_ci
153cb93a386Sopenharmony_ci    // Unknown scalar op vector
154cb93a386Sopenharmony_ci    x = unknown * int4(1);
155cb93a386Sopenharmony_ci    ok = ok && (x == int4(unknown));
156cb93a386Sopenharmony_ci    x = unknown + int4(0);
157cb93a386Sopenharmony_ci    ok = ok && (x == int4(unknown));
158cb93a386Sopenharmony_ci    x = unknown - int4(0);
159cb93a386Sopenharmony_ci    ok = ok && (x == int4(unknown));
160cb93a386Sopenharmony_ci    x = unknown / int4(1);
161cb93a386Sopenharmony_ci    ok = ok && (x == int4(unknown));
162cb93a386Sopenharmony_ci
163cb93a386Sopenharmony_ci    // Scalar op unknown vector
164cb93a386Sopenharmony_ci    x = 0 + int4(unknown);
165cb93a386Sopenharmony_ci    ok = ok && (x == int4(unknown));
166cb93a386Sopenharmony_ci    x = 0 * int4(unknown);
167cb93a386Sopenharmony_ci    ok = ok && (x == int4(0));
168cb93a386Sopenharmony_ci    x = 0 / int4(unknown);
169cb93a386Sopenharmony_ci    ok = ok && (x == int4(0));
170cb93a386Sopenharmony_ci    x = 1 * int4(unknown);
171cb93a386Sopenharmony_ci    ok = ok && (x == int4(unknown));
172cb93a386Sopenharmony_ci
173cb93a386Sopenharmony_ci    // Unknown vector op scalar
174cb93a386Sopenharmony_ci    x = int4(unknown) + 0;
175cb93a386Sopenharmony_ci    ok = ok && (x == int4(unknown));
176cb93a386Sopenharmony_ci    x = int4(unknown) * 0;
177cb93a386Sopenharmony_ci    ok = ok && (x == int4(0));
178cb93a386Sopenharmony_ci    x = int4(unknown) * 1;
179cb93a386Sopenharmony_ci    ok = ok && (x == int4(unknown));
180cb93a386Sopenharmony_ci    x = int4(unknown) - 0;
181cb93a386Sopenharmony_ci    ok = ok && (x == int4(unknown));
182cb93a386Sopenharmony_ci
183cb93a386Sopenharmony_ci    // X op= scalar.
184cb93a386Sopenharmony_ci    x = int4(unknown);
185cb93a386Sopenharmony_ci    x += 1;
186cb93a386Sopenharmony_ci    x += 0;
187cb93a386Sopenharmony_ci    x -= 1;
188cb93a386Sopenharmony_ci    x -= 0;
189cb93a386Sopenharmony_ci    x *= 1;
190cb93a386Sopenharmony_ci    x /= 1;
191cb93a386Sopenharmony_ci    ok = ok && (x == int4(unknown));
192cb93a386Sopenharmony_ci
193cb93a386Sopenharmony_ci    // X = X op scalar.
194cb93a386Sopenharmony_ci    x = int4(unknown);
195cb93a386Sopenharmony_ci    x = x + 1;
196cb93a386Sopenharmony_ci    x = x + 0;
197cb93a386Sopenharmony_ci    x = x - 1;
198cb93a386Sopenharmony_ci    x = x - 0;
199cb93a386Sopenharmony_ci    x = x * 1;
200cb93a386Sopenharmony_ci    x = x / 1;
201cb93a386Sopenharmony_ci    ok = ok && (x == int4(unknown));
202cb93a386Sopenharmony_ci
203cb93a386Sopenharmony_ci    return ok;
204cb93a386Sopenharmony_ci}
205cb93a386Sopenharmony_ci
206cb93a386Sopenharmony_cihalf4 main(float2 coords) {
207cb93a386Sopenharmony_ci    return test_half() && test_int() ? colorGreen : colorRed;
208cb93a386Sopenharmony_ci}
209