1cb93a386Sopenharmony_ciuniform half4 colorRed, colorGreen;
2cb93a386Sopenharmony_ciuniform half  unknownInput;
3cb93a386Sopenharmony_ci
4cb93a386Sopenharmony_cibool test_half() {
5cb93a386Sopenharmony_ci    bool ok = true;
6cb93a386Sopenharmony_ci    half4 inputRed   = colorRed;
7cb93a386Sopenharmony_ci    half4 inputGreen = colorGreen;
8cb93a386Sopenharmony_ci
9cb93a386Sopenharmony_ci    // Vector op scalar
10cb93a386Sopenharmony_ci    half4 x = inputRed + 2;
11cb93a386Sopenharmony_ci    ok = ok && (x == half4(3, 2, 2, 3));
12cb93a386Sopenharmony_ci    x = inputGreen.garb - 2;
13cb93a386Sopenharmony_ci    ok = ok && (x == half4(-1, -1, -2, -2));
14cb93a386Sopenharmony_ci    x = inputRed + inputGreen.g;
15cb93a386Sopenharmony_ci    ok = ok && (x == half4(2, 1, 1, 2));
16cb93a386Sopenharmony_ci    x.xyz = inputGreen.aga * 9;
17cb93a386Sopenharmony_ci    ok = ok && (x == half4(9, 9, 9, 2));
18cb93a386Sopenharmony_ci    x.xy = x.zw / 0.5;
19cb93a386Sopenharmony_ci    ok = ok && (x == half4(18, 4, 9, 2));
20cb93a386Sopenharmony_ci
21cb93a386Sopenharmony_ci    // (Vector op scalar).swizzle
22cb93a386Sopenharmony_ci    x = (inputRed * 5).yxwz;
23cb93a386Sopenharmony_ci    ok = ok && (x == half4(0, 5, 5, 0));
24cb93a386Sopenharmony_ci
25cb93a386Sopenharmony_ci    // Scalar op vector
26cb93a386Sopenharmony_ci    x = 2 + inputRed;
27cb93a386Sopenharmony_ci    ok = ok && (x == half4(3, 2, 2, 3));
28cb93a386Sopenharmony_ci    x = 10 - inputGreen.garb;
29cb93a386Sopenharmony_ci    ok = ok && (x == half4(9, 9, 10, 10));
30cb93a386Sopenharmony_ci    x = inputRed.r + inputGreen;
31cb93a386Sopenharmony_ci    ok = ok && (x == half4(1, 2, 1, 2));
32cb93a386Sopenharmony_ci    x.xyz = 9 * inputGreen.aga;
33cb93a386Sopenharmony_ci    ok = ok && (x == half4(9, 9, 9, 2));
34cb93a386Sopenharmony_ci    x.xy = 36 / x.zw;
35cb93a386Sopenharmony_ci    ok = ok && (x == half4(4, 18, 9, 2));
36cb93a386Sopenharmony_ci
37cb93a386Sopenharmony_ci    // (Scalar op vector).swizzle
38cb93a386Sopenharmony_ci    x = (36 / x).yxwz;
39cb93a386Sopenharmony_ci    ok = ok && (x == half4(2, 9, 18, 4));
40cb93a386Sopenharmony_ci
41cb93a386Sopenharmony_ci    // X op= scalar.
42cb93a386Sopenharmony_ci    x += 2;
43cb93a386Sopenharmony_ci    x *= 2;
44cb93a386Sopenharmony_ci    x -= 4;
45cb93a386Sopenharmony_ci    x /= 2;
46cb93a386Sopenharmony_ci    ok = ok && (x == half4(2, 9, 18, 4));
47cb93a386Sopenharmony_ci
48cb93a386Sopenharmony_ci    // X = X op scalar.
49cb93a386Sopenharmony_ci    x  = x + 2;
50cb93a386Sopenharmony_ci    x  = x * 2;
51cb93a386Sopenharmony_ci    x  = x - 4;
52cb93a386Sopenharmony_ci    x  = x / 2;
53cb93a386Sopenharmony_ci    ok = ok && (x == half4(2, 9, 18, 4));
54cb93a386Sopenharmony_ci
55cb93a386Sopenharmony_ci    return ok;
56cb93a386Sopenharmony_ci}
57cb93a386Sopenharmony_ci
58cb93a386Sopenharmony_cibool test_int() {
59cb93a386Sopenharmony_ci    bool ok = true;
60cb93a386Sopenharmony_ci    int4 inputRed   = int4(colorRed);
61cb93a386Sopenharmony_ci    int4 inputGreen = int4(colorGreen);
62cb93a386Sopenharmony_ci
63cb93a386Sopenharmony_ci    // Vector op scalar
64cb93a386Sopenharmony_ci    int4 x = inputRed + 2;
65cb93a386Sopenharmony_ci    ok = ok && (x == int4(3, 2, 2, 3));
66cb93a386Sopenharmony_ci    x = inputGreen.garb - 2;
67cb93a386Sopenharmony_ci    ok = ok && (x == int4(-1, -1, -2, -2));
68cb93a386Sopenharmony_ci    x = inputRed + inputGreen.g;
69cb93a386Sopenharmony_ci    ok = ok && (x == int4(2, 1, 1, 2));
70cb93a386Sopenharmony_ci    x.xyz = inputGreen.aga * 9;
71cb93a386Sopenharmony_ci    ok = ok && (x == int4(9, 9, 9, 2));
72cb93a386Sopenharmony_ci    x.xy = x.zw / 3;
73cb93a386Sopenharmony_ci    ok = ok && (x == int4(3, 0, 9, 2));
74cb93a386Sopenharmony_ci
75cb93a386Sopenharmony_ci    // (Vector op scalar).swizzle
76cb93a386Sopenharmony_ci    x = (inputRed * 5).yxwz;
77cb93a386Sopenharmony_ci    ok = ok && (x == int4(0, 5, 5, 0));
78cb93a386Sopenharmony_ci
79cb93a386Sopenharmony_ci    // Scalar op vector
80cb93a386Sopenharmony_ci    x = 2 + inputRed;
81cb93a386Sopenharmony_ci    ok = ok && (x == int4(3, 2, 2, 3));
82cb93a386Sopenharmony_ci    x = 10 - inputGreen.garb;
83cb93a386Sopenharmony_ci    ok = ok && (x == int4(9, 9, 10, 10));
84cb93a386Sopenharmony_ci    x = inputRed.r + inputGreen;
85cb93a386Sopenharmony_ci    ok = ok && (x == int4(1, 2, 1, 2));
86cb93a386Sopenharmony_ci    x.xyz = 9 * inputGreen.aga;
87cb93a386Sopenharmony_ci    ok = ok && (x == int4(9, 9, 9, 2));
88cb93a386Sopenharmony_ci    x.xy = 36 / x.zw;
89cb93a386Sopenharmony_ci    ok = ok && (x == int4(4, 18, 9, 2));
90cb93a386Sopenharmony_ci
91cb93a386Sopenharmony_ci    // (Scalar op vector).swizzle
92cb93a386Sopenharmony_ci    x = (36 / x).yxwz;
93cb93a386Sopenharmony_ci    ok = ok && (x == int4(2, 9, 18, 4));
94cb93a386Sopenharmony_ci
95cb93a386Sopenharmony_ci    // X op= scalar.
96cb93a386Sopenharmony_ci    x += 2;
97cb93a386Sopenharmony_ci    x *= 2;
98cb93a386Sopenharmony_ci    x -= 4;
99cb93a386Sopenharmony_ci    x /= 2;
100cb93a386Sopenharmony_ci    ok = ok && (x == int4(2, 9, 18, 4));
101cb93a386Sopenharmony_ci
102cb93a386Sopenharmony_ci    // X = X op scalar.
103cb93a386Sopenharmony_ci    x  = x + 2;
104cb93a386Sopenharmony_ci    x  = x * 2;
105cb93a386Sopenharmony_ci    x  = x - 4;
106cb93a386Sopenharmony_ci    x  = x / 2;
107cb93a386Sopenharmony_ci    ok = ok && (x == int4(2, 9, 18, 4));
108cb93a386Sopenharmony_ci
109cb93a386Sopenharmony_ci    return ok;
110cb93a386Sopenharmony_ci}
111cb93a386Sopenharmony_ci
112cb93a386Sopenharmony_cihalf4 main(float2 coords) {
113cb93a386Sopenharmony_ci    return test_half() && test_int() ? colorGreen : colorRed;
114cb93a386Sopenharmony_ci}
115