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 Compound { 13 float4 f4; 14 int3 i3; 15}; 16struct Uniforms { 17 half4 colorRed; 18 half4 colorGreen; 19}; 20struct Inputs { 21}; 22struct Outputs { 23 half4 sk_FragColor [[color(0)]]; 24}; 25 26thread bool operator==(thread const S& left, thread const S& right); 27thread bool operator!=(thread const S& left, thread const S& right); 28 29thread bool operator==(thread const Nested& left, thread const Nested& right); 30thread bool operator!=(thread const Nested& left, thread const Nested& right); 31 32thread bool operator==(thread const Compound& left, thread const Compound& right); 33thread bool operator!=(thread const Compound& left, thread const Compound& right); 34void modifies_a_struct_vS(thread S& s); 35void _skOutParamHelper0_modifies_a_struct_vS(thread S& s) { 36 S _var0 = s; 37 modifies_a_struct_vS(_var0); 38 s = _var0; 39} 40void modifies_a_struct_vS(thread S& s); 41void _skOutParamHelper1_modifies_a_struct_vS(thread Nested& n3) { 42 S _var0 = n3.b; 43 modifies_a_struct_vS(_var0); 44 n3.b = _var0; 45} 46thread bool operator==(thread const S& left, thread const S& right) { 47 return all(left.x == right.x) && 48 all(left.y == right.y); 49} 50thread bool operator!=(thread const S& left, thread const S& right) { 51 return !(left == right); 52} 53thread bool operator==(thread const Nested& left, thread const Nested& right) { 54 return all(left.a == right.a) && 55 all(left.b == right.b); 56} 57thread bool operator!=(thread const Nested& left, thread const Nested& right) { 58 return !(left == right); 59} 60thread bool operator==(thread const Compound& left, thread const Compound& right) { 61 return all(left.f4 == right.f4) && 62 all(left.i3 == right.i3); 63} 64thread bool operator!=(thread const Compound& left, thread const Compound& right) { 65 return !(left == right); 66} 67S returns_a_struct_S() { 68 S s; 69 s.x = 1.0; 70 s.y = 2; 71 return s; 72} 73S constructs_a_struct_S() { 74 return S{2.0, 3}; 75} 76float accepts_a_struct_fS(S s) { 77 return s.x + float(s.y); 78} 79void modifies_a_struct_vS(thread S& s) { 80 s.x++; 81 s.y++; 82} 83fragment Outputs fragmentMain(Inputs _in [[stage_in]], constant Uniforms& _uniforms [[buffer(0)]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) { 84 Outputs _out; 85 (void)_out; 86 S s = returns_a_struct_S(); 87 float x = accepts_a_struct_fS(s); 88 _skOutParamHelper0_modifies_a_struct_vS(s); 89 S expected = constructs_a_struct_S(); 90 Nested n1; 91 Nested n2; 92 Nested n3; 93 n1.a = returns_a_struct_S(); 94 n1.b = n1.a; 95 n2 = n1; 96 n3 = n2; 97 _skOutParamHelper1_modifies_a_struct_vS(n3); 98 Compound c1 = Compound{float4(1.0, 2.0, 3.0, 4.0), int3(5, 6, 7)}; 99 Compound c2 = Compound{float4(float(_uniforms.colorGreen.y), 2.0, 3.0, 4.0), int3(5, 6, 7)}; 100 Compound c3 = Compound{float4(float(_uniforms.colorGreen.x), 2.0, 3.0, 4.0), int3(5, 6, 7)}; 101 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}}) && c1 == c2) && c2 != c3; 102 _out.sk_FragColor = valid ? _uniforms.colorGreen : _uniforms.colorRed; 103 return _out; 104} 105