1#include <metal_stdlib> 2#include <simd/simd.h> 3#ifdef __clang__ 4#pragma clang diagnostic ignored "-Wall" 5#endif 6using namespace metal; 7constant const array<half, 5> globalArray = array<half, 5>{1.0h, 1.0h, 1.0h, 1.0h, 1.0h}; 8constant const half2 globalVector = half2(1.0h); 9constant const half2x2 globalMatrix = half2x2(half2(1.0h, 1.0h), half2(1.0h, 1.0h)); 10struct Uniforms { 11 half4 colorRed; 12 half2x2 testMatrix2x2; 13 array<half, 5> testArray; 14}; 15struct Inputs { 16}; 17struct Outputs { 18 half4 sk_FragColor [[color(0)]]; 19}; 20 21template <typename T1, typename T2> 22bool operator==(const array_ref<T1> left, const array_ref<T2> right); 23template <typename T1, typename T2> 24bool operator!=(const array_ref<T1> left, const array_ref<T2> right); 25 26thread bool operator==(const half2x2 left, const half2x2 right); 27thread bool operator!=(const half2x2 left, const half2x2 right); 28 29template <typename T1, typename T2> 30bool operator==(const array_ref<T1> left, const array_ref<T2> right) { 31 if (left.size() != right.size()) { 32 return false; 33 } 34 for (size_t index = 0; index < left.size(); ++index) { 35 if (!all(left[index] == right[index])) { 36 return false; 37 } 38 } 39 return true; 40} 41 42template <typename T1, typename T2> 43bool operator!=(const array_ref<T1> left, const array_ref<T2> right) { 44 return !(left == right); 45} 46thread bool operator==(const half2x2 left, const half2x2 right) { 47 return all(left[0] == right[0]) && 48 all(left[1] == right[1]); 49} 50thread bool operator!=(const half2x2 left, const half2x2 right) { 51 return !(left == right); 52} 53fragment Outputs fragmentMain(Inputs _in [[stage_in]], constant Uniforms& _uniforms [[buffer(0)]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) { 54 Outputs _out; 55 (void)_out; 56 const array<half, 5> localArray = array<half, 5>{0.0h, 1.0h, 2.0h, 3.0h, 4.0h}; 57 const half2 localVector = half2(1.0h); 58 const half2x2 localMatrix = half2x2(half2(0.0h, 1.0h), half2(2.0h, 3.0h)); 59 if (((((make_array_ref(globalArray) == make_array_ref(_uniforms.testArray) || all(globalVector == _uniforms.colorRed.xy)) || globalMatrix == _uniforms.testMatrix2x2) || make_array_ref(localArray) == make_array_ref(_uniforms.testArray)) || all(localVector == _uniforms.colorRed.xy)) || localMatrix == _uniforms.testMatrix2x2) { 60 _out.sk_FragColor = _uniforms.colorRed; 61 return _out; 62 } 63 _out.sk_FragColor = half4(0.0h, 1.0h, 0.0h, 1.0h); 64 return _out; 65} 66