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