• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#include <metal_stdlib>
2#include <simd/simd.h>
3using namespace metal;
4struct S {
5    float x;
6    int y;
7};
8struct Nested {
9    S a;
10    S b;
11};
12struct Uniforms {
13    float4 colorRed;
14    float4 colorGreen;
15};
16struct Inputs {
17};
18struct Outputs {
19    float4 sk_FragColor [[color(0)]];
20};
21void modifies_a_struct_vS(thread S& s);
22void _skOutParamHelper0_modifies_a_struct_vS(thread S& s) {
23    S _var0 = s;
24    modifies_a_struct_vS(_var0);
25    s = _var0;
26}
27void modifies_a_struct_vS(thread S& s);
28void _skOutParamHelper1_modifies_a_struct_vS(thread Nested& n3) {
29    S _var0 = n3.b;
30    modifies_a_struct_vS(_var0);
31    n3.b = _var0;
32}
33thread bool operator==(thread const S& left, thread const S& right) {
34    return (left.x == right.x) &&
35           (left.y == right.y);
36}
37thread bool operator!=(thread const S& left, thread const S& right) {
38    return !(left == right);
39}
40thread bool operator==(thread const Nested& left, thread const Nested& right) {
41    return (left.a == right.a) &&
42           (left.b == right.b);
43}
44thread bool operator!=(thread const Nested& left, thread const Nested& right) {
45    return !(left == right);
46}
47
48S returns_a_struct_S() {
49    S s;
50    s.x = 1.0;
51    s.y = 2;
52    return s;
53}
54S constructs_a_struct_S() {
55    return S{2.0, 3};
56}
57float accepts_a_struct_fS(S s) {
58    return s.x + float(s.y);
59}
60void modifies_a_struct_vS(thread S& s) {
61    s.x++;
62    s.y++;
63}
64fragment Outputs fragmentMain(Inputs _in [[stage_in]], constant Uniforms& _uniforms [[buffer(0)]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) {
65    Outputs _out;
66    (void)_out;
67    S s = returns_a_struct_S();
68    float x = accepts_a_struct_fS(s);
69    _skOutParamHelper0_modifies_a_struct_vS(s);
70    S expected = constructs_a_struct_S();
71    Nested n1;
72    Nested n2;
73    Nested n3;
74    n1.a = returns_a_struct_S();
75    n1.b = n1.a;
76    n2 = n1;
77    n3 = n2;
78    _skOutParamHelper1_modifies_a_struct_vS(n3);
79    bool valid = (((((((x == 3.0 && s.x == 2.0) && s.y == 3) && s == expected) && s == S{2.0, 3}) && s != returns_a_struct_S()) && n1 == n2) && n1 != n3) && n3 == Nested{S{1.0, 2}, S{2.0, 3}};
80    _out.sk_FragColor = valid ? _uniforms.colorGreen : _uniforms.colorRed;
81    return _out;
82}
83