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