#include #include #ifdef __clang__ #pragma clang diagnostic ignored "-Wall" #endif using namespace metal; struct S { int x; int y; half2x2 m; array a; }; struct Uniforms { half4 colorGreen; half4 colorRed; array testArray; }; struct Inputs { }; struct Outputs { half4 sk_FragColor [[color(0)]]; }; thread bool operator==(const half2x2 left, const half2x2 right); thread bool operator!=(const half2x2 left, const half2x2 right); template bool operator==(const array_ref left, const array_ref right); template bool operator!=(const array_ref left, const array_ref right); thread bool operator==(thread const S& left, thread const S& right); thread bool operator!=(thread const S& left, thread const S& right); thread bool operator==(const half2x2 left, const half2x2 right) { return all(left[0] == right[0]) && all(left[1] == right[1]); } thread bool operator!=(const half2x2 left, const half2x2 right) { return !(left == right); } template bool operator==(const array_ref left, const array_ref right) { if (left.size() != right.size()) { return false; } for (size_t index = 0; index < left.size(); ++index) { if (!all(left[index] == right[index])) { return false; } } return true; } template bool operator!=(const array_ref left, const array_ref right) { return !(left == right); } thread bool operator==(thread const S& left, thread const S& right) { return all(left.x == right.x) && all(left.y == right.y) && all(left.m == right.m) && (make_array_ref(left.a) == make_array_ref(right.a)); } thread bool operator!=(thread const S& left, thread const S& right) { return !(left == right); } fragment Outputs fragmentMain(Inputs _in [[stage_in]], constant Uniforms& _uniforms [[buffer(0)]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) { Outputs _out; (void)_out; array array = array{1.0, 2.0, 3.0, 4.0, 5.0}; S s1 = S{1, 2, half2x2(1.0h), array}; S s2 = S{1, 2, half2x2(1.0h), _uniforms.testArray}; S s3 = S{1, 2, half2x2(2.0h), array{1.0, 2.0, 3.0, 4.0, 5.0}}; _out.sk_FragColor = s1 == s2 && s1 != s3 ? _uniforms.colorGreen : _uniforms.colorRed; return _out; }