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}; 28thread bool operator==(thread const S& left, thread const S& right);thread bool operator!=(thread const S& left, thread const S& right);thread bool operator==(thread const Nested& left, thread const Nested& right);thread bool operator!=(thread const Nested& left, thread const Nested& right);thread bool operator==(thread const Compound& left, thread const Compound& right);thread bool operator!=(thread const Compound& left, thread const Compound& right);thread bool operator==(thread const S& left, thread const S& right) {return all(left.x == right.x) && all(left.y == right.y);}thread bool operator!=(thread const S& left, thread const S& right) {return !(left == right);}thread bool operator==(thread const Nested& left, thread const Nested& right) {return all(left.a == right.a) && all(left.b == right.b);}thread bool operator!=(thread const Nested& left, thread const Nested& right) {return !(left == right);}thread bool operator==(thread const Compound& left, thread const Compound& right) {return all(left.f4 == right.f4) && all(left.i3 == right.i3);}thread bool operator!=(thread const Compound& left, thread const Compound& right) {return !(left == right);}S returns_a_struct_S() { 29 S s; 30 s.x = 1.0; 31 s.y = 2; 32 return s; 33} 34S constructs_a_struct_S() { 35 return S{2.0, 3}; 36} 37float accepts_a_struct_fS(S s) { 38 return s.x + float(s.y); 39} 40void modifies_a_struct_vS(thread S& s) { 41 s.x++; 42 s.y++; 43} 44fragment Outputs fragmentMain(Inputs _in [[stage_in]], constant Uniforms& _uniforms [[buffer(0)]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) { 45 Outputs _out; 46 (void)_out; 47 S _skTemp0; 48 S _skTemp1; 49 S s = returns_a_struct_S(); 50 float x = accepts_a_struct_fS(s); 51 ((modifies_a_struct_vS((_skTemp0 = s))), (s = _skTemp0)); 52 S expected = constructs_a_struct_S(); 53 Nested n1; 54 Nested n2; 55 Nested n3; 56 n1.a = returns_a_struct_S(); 57 n1.b = n1.a; 58 n2 = n1; 59 n3 = n2; 60 ((modifies_a_struct_vS((_skTemp1 = n3.b))), (n3.b = _skTemp1)); 61 Compound c1 = Compound{float4(1.0, 2.0, 3.0, 4.0), int3(5, 6, 7)}; 62 Compound c2 = Compound{float4(float(_uniforms.colorGreen.y), 2.0, 3.0, 4.0), int3(5, 6, 7)}; 63 Compound c3 = Compound{float4(float(_uniforms.colorGreen.x), 2.0, 3.0, 4.0), int3(5, 6, 7)}; 64 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; 65 _out.sk_FragColor = valid ? _uniforms.colorGreen : _uniforms.colorRed; 66 return _out; 67} 68