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