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 int x; 9 int y; 10 half2x2 m; 11 array<float, 5> a; 12}; 13struct Uniforms { 14 half4 colorGreen; 15 half4 colorRed; 16 array<float, 5> testArray; 17}; 18struct Inputs { 19}; 20struct Outputs { 21 half4 sk_FragColor [[color(0)]]; 22}; 23thread bool operator==(const half2x2 left, const half2x2 right);thread bool operator!=(const half2x2 left, const half2x2 right);template <typename T1, typename T2>bool operator==(const array_ref<T1> left, const array_ref<T2> right);template <typename T1, typename T2>bool operator!=(const array_ref<T1> left, const array_ref<T2> 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 <typename T1, typename T2>bool operator==(const array_ref<T1> left, const array_ref<T2> 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 <typename T1, typename T2>bool operator!=(const array_ref<T1> left, const array_ref<T2> 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]]) { 24 Outputs _out; 25 (void)_out; 26 array<float, 5> array = array<float, 5>{1.0, 2.0, 3.0, 4.0, 5.0}; 27 S s1 = S{1, 2, half2x2(1.0h), array}; 28 S s2 = S{1, 2, half2x2(1.0h), _uniforms.testArray}; 29 S s3 = S{1, 2, half2x2(2.0h), array<float, 5>{1.0, 2.0, 3.0, 4.0, 5.0}}; 30 _out.sk_FragColor = s1 == s2 && s1 != s3 ? _uniforms.colorGreen : _uniforms.colorRed; 31 return _out; 32} 33