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