1cb93a386Sopenharmony_ci#include <metal_stdlib>
2cb93a386Sopenharmony_ci#include <simd/simd.h>
3cb93a386Sopenharmony_ciusing namespace metal;
4cb93a386Sopenharmony_cistruct Uniforms {
5cb93a386Sopenharmony_ci    half4 colorRed;
6cb93a386Sopenharmony_ci    half4 colorGreen;
7cb93a386Sopenharmony_ci    half unknownInput;
8cb93a386Sopenharmony_ci};
9cb93a386Sopenharmony_cistruct Inputs {
10cb93a386Sopenharmony_ci};
11cb93a386Sopenharmony_cistruct Outputs {
12cb93a386Sopenharmony_ci    half4 sk_FragColor [[color(0)]];
13cb93a386Sopenharmony_ci};
14cb93a386Sopenharmony_cibool test_int_b(Uniforms _uniforms) {
15cb93a386Sopenharmony_ci    bool ok = true;
16cb93a386Sopenharmony_ci    int4 inputRed = int4(_uniforms.colorRed);
17cb93a386Sopenharmony_ci    int4 inputGreen = int4(_uniforms.colorGreen);
18cb93a386Sopenharmony_ci    int4 x = inputRed + 2;
19cb93a386Sopenharmony_ci    ok = ok && all(x == int4(3, 2, 2, 3));
20cb93a386Sopenharmony_ci    x = inputGreen.ywxz - 2;
21cb93a386Sopenharmony_ci    ok = ok && all(x == int4(-1, -1, -2, -2));
22cb93a386Sopenharmony_ci    x = inputRed + inputGreen.y;
23cb93a386Sopenharmony_ci    ok = ok && all(x == int4(2, 1, 1, 2));
24cb93a386Sopenharmony_ci    x.xyz = inputGreen.wyw * 9;
25cb93a386Sopenharmony_ci    ok = ok && all(x == int4(9, 9, 9, 2));
26cb93a386Sopenharmony_ci    x.xy = x.zw / 3;
27cb93a386Sopenharmony_ci    ok = ok && all(x == int4(3, 0, 9, 2));
28cb93a386Sopenharmony_ci    x = (inputRed * 5).yxwz;
29cb93a386Sopenharmony_ci    ok = ok && all(x == int4(0, 5, 5, 0));
30cb93a386Sopenharmony_ci    x = 2 + inputRed;
31cb93a386Sopenharmony_ci    ok = ok && all(x == int4(3, 2, 2, 3));
32cb93a386Sopenharmony_ci    x = 10 - inputGreen.ywxz;
33cb93a386Sopenharmony_ci    ok = ok && all(x == int4(9, 9, 10, 10));
34cb93a386Sopenharmony_ci    x = inputRed.x + inputGreen;
35cb93a386Sopenharmony_ci    ok = ok && all(x == int4(1, 2, 1, 2));
36cb93a386Sopenharmony_ci    x.xyz = 9 * inputGreen.wyw;
37cb93a386Sopenharmony_ci    ok = ok && all(x == int4(9, 9, 9, 2));
38cb93a386Sopenharmony_ci    x.xy = 36 / x.zw;
39cb93a386Sopenharmony_ci    ok = ok && all(x == int4(4, 18, 9, 2));
40cb93a386Sopenharmony_ci    x = (36 / x).yxwz;
41cb93a386Sopenharmony_ci    ok = ok && all(x == int4(2, 9, 18, 4));
42cb93a386Sopenharmony_ci    x += 2;
43cb93a386Sopenharmony_ci    x *= 2;
44cb93a386Sopenharmony_ci    x -= 4;
45cb93a386Sopenharmony_ci    x /= 2;
46cb93a386Sopenharmony_ci    ok = ok && all(x == int4(2, 9, 18, 4));
47cb93a386Sopenharmony_ci    x = x + 2;
48cb93a386Sopenharmony_ci    x = x * 2;
49cb93a386Sopenharmony_ci    x = x - 4;
50cb93a386Sopenharmony_ci    x = x / 2;
51cb93a386Sopenharmony_ci    ok = ok && all(x == int4(2, 9, 18, 4));
52cb93a386Sopenharmony_ci    return ok;
53cb93a386Sopenharmony_ci}
54cb93a386Sopenharmony_cifragment Outputs fragmentMain(Inputs _in [[stage_in]], constant Uniforms& _uniforms [[buffer(0)]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) {
55cb93a386Sopenharmony_ci    Outputs _out;
56cb93a386Sopenharmony_ci    (void)_out;
57cb93a386Sopenharmony_ci    bool _0_ok = true;
58cb93a386Sopenharmony_ci    half4 _1_inputRed = _uniforms.colorRed;
59cb93a386Sopenharmony_ci    half4 _2_inputGreen = _uniforms.colorGreen;
60cb93a386Sopenharmony_ci    half4 _3_x = _1_inputRed + 2.0h;
61cb93a386Sopenharmony_ci    _0_ok = _0_ok && all(_3_x == half4(3.0h, 2.0h, 2.0h, 3.0h));
62cb93a386Sopenharmony_ci    _3_x = _2_inputGreen.ywxz - 2.0h;
63cb93a386Sopenharmony_ci    _0_ok = _0_ok && all(_3_x == half4(-1.0h, -1.0h, -2.0h, -2.0h));
64cb93a386Sopenharmony_ci    _3_x = _1_inputRed + _2_inputGreen.y;
65cb93a386Sopenharmony_ci    _0_ok = _0_ok && all(_3_x == half4(2.0h, 1.0h, 1.0h, 2.0h));
66cb93a386Sopenharmony_ci    _3_x.xyz = _2_inputGreen.wyw * 9.0h;
67cb93a386Sopenharmony_ci    _0_ok = _0_ok && all(_3_x == half4(9.0h, 9.0h, 9.0h, 2.0h));
68cb93a386Sopenharmony_ci    _3_x.xy = _3_x.zw / 0.5h;
69cb93a386Sopenharmony_ci    _0_ok = _0_ok && all(_3_x == half4(18.0h, 4.0h, 9.0h, 2.0h));
70cb93a386Sopenharmony_ci    _3_x = (_1_inputRed * 5.0h).yxwz;
71cb93a386Sopenharmony_ci    _0_ok = _0_ok && all(_3_x == half4(0.0h, 5.0h, 5.0h, 0.0h));
72cb93a386Sopenharmony_ci    _3_x = 2.0h + _1_inputRed;
73cb93a386Sopenharmony_ci    _0_ok = _0_ok && all(_3_x == half4(3.0h, 2.0h, 2.0h, 3.0h));
74cb93a386Sopenharmony_ci    _3_x = 10.0h - _2_inputGreen.ywxz;
75cb93a386Sopenharmony_ci    _0_ok = _0_ok && all(_3_x == half4(9.0h, 9.0h, 10.0h, 10.0h));
76cb93a386Sopenharmony_ci    _3_x = _1_inputRed.x + _2_inputGreen;
77cb93a386Sopenharmony_ci    _0_ok = _0_ok && all(_3_x == half4(1.0h, 2.0h, 1.0h, 2.0h));
78cb93a386Sopenharmony_ci    _3_x.xyz = 9.0h * _2_inputGreen.wyw;
79cb93a386Sopenharmony_ci    _0_ok = _0_ok && all(_3_x == half4(9.0h, 9.0h, 9.0h, 2.0h));
80cb93a386Sopenharmony_ci    _3_x.xy = 36.0h / _3_x.zw;
81cb93a386Sopenharmony_ci    _0_ok = _0_ok && all(_3_x == half4(4.0h, 18.0h, 9.0h, 2.0h));
82cb93a386Sopenharmony_ci    _3_x = (36.0h / _3_x).yxwz;
83cb93a386Sopenharmony_ci    _0_ok = _0_ok && all(_3_x == half4(2.0h, 9.0h, 18.0h, 4.0h));
84cb93a386Sopenharmony_ci    _3_x += 2.0h;
85cb93a386Sopenharmony_ci    _3_x *= 2.0h;
86cb93a386Sopenharmony_ci    _3_x -= 4.0h;
87cb93a386Sopenharmony_ci    _3_x /= 2.0h;
88cb93a386Sopenharmony_ci    _0_ok = _0_ok && all(_3_x == half4(2.0h, 9.0h, 18.0h, 4.0h));
89cb93a386Sopenharmony_ci    _3_x = _3_x + 2.0h;
90cb93a386Sopenharmony_ci    _3_x = _3_x * 2.0h;
91cb93a386Sopenharmony_ci    _3_x = _3_x - 4.0h;
92cb93a386Sopenharmony_ci    _3_x = _3_x / 2.0h;
93cb93a386Sopenharmony_ci    _0_ok = _0_ok && all(_3_x == half4(2.0h, 9.0h, 18.0h, 4.0h));
94cb93a386Sopenharmony_ci    _out.sk_FragColor = _0_ok && test_int_b(_uniforms) ? _uniforms.colorGreen : _uniforms.colorRed;
95cb93a386Sopenharmony_ci    return _out;
96cb93a386Sopenharmony_ci}
97