1cb93a386Sopenharmony_ci#include <metal_stdlib> 2cb93a386Sopenharmony_ci#include <simd/simd.h> 3cb93a386Sopenharmony_ciusing namespace metal; 4cb93a386Sopenharmony_cistruct S { 5cb93a386Sopenharmony_ci int x; 6cb93a386Sopenharmony_ci int y; 7cb93a386Sopenharmony_ci}; 8cb93a386Sopenharmony_cistruct Uniforms { 9cb93a386Sopenharmony_ci half4 colorGreen; 10cb93a386Sopenharmony_ci half4 colorRed; 11cb93a386Sopenharmony_ci}; 12cb93a386Sopenharmony_cistruct Inputs { 13cb93a386Sopenharmony_ci}; 14cb93a386Sopenharmony_cistruct Outputs { 15cb93a386Sopenharmony_ci half4 sk_FragColor [[color(0)]]; 16cb93a386Sopenharmony_ci}; 17cb93a386Sopenharmony_ci 18cb93a386Sopenharmony_citemplate <typename T1, typename T2, size_t N> 19cb93a386Sopenharmony_cibool operator==(thread const array<T1, N>& left, thread const array<T2, N>& right); 20cb93a386Sopenharmony_citemplate <typename T1, typename T2, size_t N> 21cb93a386Sopenharmony_cibool operator!=(thread const array<T1, N>& left, thread const array<T2, N>& right); 22cb93a386Sopenharmony_ci 23cb93a386Sopenharmony_cithread bool operator==(const half2x2 left, const half2x2 right); 24cb93a386Sopenharmony_cithread bool operator!=(const half2x2 left, const half2x2 right); 25cb93a386Sopenharmony_ci 26cb93a386Sopenharmony_cithread bool operator==(thread const S& left, thread const S& right); 27cb93a386Sopenharmony_cithread bool operator!=(thread const S& left, thread const S& right); 28cb93a386Sopenharmony_ci 29cb93a386Sopenharmony_citemplate <typename T1, typename T2, size_t N> 30cb93a386Sopenharmony_cibool operator==(thread const array<T1, N>& left, thread const array<T2, N>& right) { 31cb93a386Sopenharmony_ci for (size_t index = 0; index < N; ++index) { 32cb93a386Sopenharmony_ci if (!all(left[index] == right[index])) { 33cb93a386Sopenharmony_ci return false; 34cb93a386Sopenharmony_ci } 35cb93a386Sopenharmony_ci } 36cb93a386Sopenharmony_ci return true; 37cb93a386Sopenharmony_ci} 38cb93a386Sopenharmony_ci 39cb93a386Sopenharmony_citemplate <typename T1, typename T2, size_t N> 40cb93a386Sopenharmony_cibool operator!=(thread const array<T1, N>& left, thread const array<T2, N>& right) { 41cb93a386Sopenharmony_ci return !(left == right); 42cb93a386Sopenharmony_ci} 43cb93a386Sopenharmony_cithread bool operator==(const half2x2 left, const half2x2 right) { 44cb93a386Sopenharmony_ci return all(left[0] == right[0]) && 45cb93a386Sopenharmony_ci all(left[1] == right[1]); 46cb93a386Sopenharmony_ci} 47cb93a386Sopenharmony_cithread bool operator!=(const half2x2 left, const half2x2 right) { 48cb93a386Sopenharmony_ci return !(left == right); 49cb93a386Sopenharmony_ci} 50cb93a386Sopenharmony_cithread bool operator==(thread const S& left, thread const S& right) { 51cb93a386Sopenharmony_ci return all(left.x == right.x) && 52cb93a386Sopenharmony_ci all(left.y == right.y); 53cb93a386Sopenharmony_ci} 54cb93a386Sopenharmony_cithread bool operator!=(thread const S& left, thread const S& right) { 55cb93a386Sopenharmony_ci return !(left == right); 56cb93a386Sopenharmony_ci} 57cb93a386Sopenharmony_cifragment Outputs fragmentMain(Inputs _in [[stage_in]], constant Uniforms& _uniforms [[buffer(0)]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) { 58cb93a386Sopenharmony_ci Outputs _out; 59cb93a386Sopenharmony_ci (void)_out; 60cb93a386Sopenharmony_ci array<float, 4> f1 = array<float, 4>{1.0, 2.0, 3.0, 4.0}; 61cb93a386Sopenharmony_ci array<float, 4> f2 = array<float, 4>{1.0, 2.0, 3.0, 4.0}; 62cb93a386Sopenharmony_ci array<float, 4> f3 = array<float, 4>{1.0, 2.0, 3.0, -4.0}; 63cb93a386Sopenharmony_ci array<int3, 2> v1 = array<int3, 2>{int3(1, 2, 3), int3(4, 5, 6)}; 64cb93a386Sopenharmony_ci array<int3, 2> v2 = array<int3, 2>{int3(1, 2, 3), int3(4, 5, 6)}; 65cb93a386Sopenharmony_ci array<int3, 2> v3 = array<int3, 2>{int3(1, 2, 3), int3(4, 5, -6)}; 66cb93a386Sopenharmony_ci array<half2x2, 3> m1 = array<half2x2, 3>{half2x2(1.0h), half2x2(2.0h), half2x2(half2(3.0h, 4.0h), half2(5.0h, 6.0h))}; 67cb93a386Sopenharmony_ci array<half2x2, 3> m2 = array<half2x2, 3>{half2x2(1.0h), half2x2(2.0h), half2x2(half2(3.0h, 4.0h), half2(5.0h, 6.0h))}; 68cb93a386Sopenharmony_ci array<half2x2, 3> m3 = array<half2x2, 3>{half2x2(1.0h), half2x2(half2(2.0h, 3.0h), half2(4.0h, 5.0h)), half2x2(6.0h)}; 69cb93a386Sopenharmony_ci array<S, 3> s1 = array<S, 3>{S{1, 2}, S{3, 4}, S{5, 6}}; 70cb93a386Sopenharmony_ci array<S, 3> s2 = array<S, 3>{S{1, 2}, S{0, 0}, S{5, 6}}; 71cb93a386Sopenharmony_ci array<S, 3> s3 = array<S, 3>{S{1, 2}, S{3, 4}, S{5, 6}}; 72cb93a386Sopenharmony_ci _out.sk_FragColor = ((((((f1 == f2 && f1 != f3) && v1 == v2) && v1 != v3) && m1 == m2) && m1 != m3) && s1 != s2) && s3 == s1 ? _uniforms.colorGreen : _uniforms.colorRed; 73cb93a386Sopenharmony_ci return _out; 74cb93a386Sopenharmony_ci} 75