• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#include <metal_stdlib>
2#include <simd/simd.h>
3#ifdef __clang__
4#pragma clang diagnostic ignored "-Wall"
5#endif
6using namespace metal;
7struct Uniforms {
8    half4 colorRed;
9    half4 colorGreen;
10};
11struct Inputs {
12};
13struct Outputs {
14    half4 sk_FragColor [[color(0)]];
15};
16thread bool operator==(const half3x3 left, const half3x3 right);thread bool operator!=(const half3x3 left, const half3x3 right);thread bool operator==(const half4x4 left, const half4x4 right);thread bool operator!=(const half4x4 left, const half4x4 right);thread bool operator==(const half2x2 left, const half2x2 right);thread bool operator!=(const half2x2 left, const half2x2 right);thread bool operator==(const float3x3 left, const float3x3 right);thread bool operator!=(const float3x3 left, const float3x3 right);thread bool operator==(const float4x4 left, const float4x4 right);thread bool operator!=(const float4x4 left, const float4x4 right);thread bool operator==(const float2x2 left, const float2x2 right);thread bool operator!=(const float2x2 left, const float2x2 right);thread bool operator==(const half3x3 left, const half3x3 right) {return all(left[0] == right[0]) && all(left[1] == right[1]) && all(left[2] == right[2]);}thread bool operator!=(const half3x3 left, const half3x3 right) {return !(left == right);}thread half3x3 operator/(const half3x3 left, const half3x3 right) {
17    return half3x3(left[0] / right[0], left[1] / right[1], left[2] / right[2]);
18}
19thread half3x3& operator/=(thread half3x3& left, thread const half3x3& right) {
20    left = left / right;
21    return left;
22}
23thread bool operator==(const half4x4 left, const half4x4 right) {return all(left[0] == right[0]) && all(left[1] == right[1]) && all(left[2] == right[2]) && all(left[3] == right[3]);}thread bool operator!=(const half4x4 left, const half4x4 right) {return !(left == 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);}thread half2x2 operator/(const half2x2 left, const half2x2 right) {
24    return half2x2(left[0] / right[0], left[1] / right[1]);
25}
26thread half2x2& operator/=(thread half2x2& left, thread const half2x2& right) {
27    left = left / right;
28    return left;
29}
30thread half2x2& operator*=(thread half2x2& left, thread const half2x2& right) {
31    left = left * right;
32    return left;
33}
34thread half3x3& operator*=(thread half3x3& left, thread const half3x3& right) {
35    left = left * right;
36    return left;
37}
38thread bool operator==(const float3x3 left, const float3x3 right) {return all(left[0] == right[0]) && all(left[1] == right[1]) && all(left[2] == right[2]);}thread bool operator!=(const float3x3 left, const float3x3 right) {return !(left == right);}thread float3x3 operator/(const float3x3 left, const float3x3 right) {
39    return float3x3(left[0] / right[0], left[1] / right[1], left[2] / right[2]);
40}
41thread float3x3& operator/=(thread float3x3& left, thread const float3x3& right) {
42    left = left / right;
43    return left;
44}
45thread bool operator==(const float4x4 left, const float4x4 right) {return all(left[0] == right[0]) && all(left[1] == right[1]) && all(left[2] == right[2]) && all(left[3] == right[3]);}thread bool operator!=(const float4x4 left, const float4x4 right) {return !(left == right);}thread bool operator==(const float2x2 left, const float2x2 right) {return all(left[0] == right[0]) && all(left[1] == right[1]);}thread bool operator!=(const float2x2 left, const float2x2 right) {return !(left == right);}thread float2x2 operator/(const float2x2 left, const float2x2 right) {
46    return float2x2(left[0] / right[0], left[1] / right[1]);
47}
48thread float2x2& operator/=(thread float2x2& left, thread const float2x2& right) {
49    left = left / right;
50    return left;
51}
52thread float2x2& operator*=(thread float2x2& left, thread const float2x2& right) {
53    left = left * right;
54    return left;
55}
56thread float3x3& operator*=(thread float3x3& left, thread const float3x3& right) {
57    left = left * right;
58    return left;
59}
60bool test_matrix_op_matrix_half_b() {
61    bool ok = true;
62    {
63        const half3x3 splat_4 = half3x3(half3(4.0h, 4.0h, 4.0h), half3(4.0h, 4.0h, 4.0h), half3(4.0h, 4.0h, 4.0h));
64        const half3x3 splat_2 = half3x3(half3(2.0h, 2.0h, 2.0h), half3(2.0h, 2.0h, 2.0h), half3(2.0h, 2.0h, 2.0h));
65        half3x3 m = half3x3(2.0h);
66        m += splat_4;
67        ok = ok && m == half3x3(half3(6.0h, 4.0h, 4.0h), half3(4.0h, 6.0h, 4.0h), half3(4.0h, 4.0h, 6.0h));
68        m = half3x3(2.0h);
69        m -= splat_4;
70        ok = ok && m == half3x3(half3(-2.0h, -4.0h, -4.0h), half3(-4.0h, -2.0h, -4.0h), half3(-4.0h, -4.0h, -2.0h));
71        m = half3x3(2.0h);
72        m /= splat_4;
73        ok = ok && m == half3x3(0.5h);
74        m = splat_4;
75        m += half3x3(2.0h);
76        ok = ok && m == half3x3(half3(6.0h, 4.0h, 4.0h), half3(4.0h, 6.0h, 4.0h), half3(4.0h, 4.0h, 6.0h));
77        m = splat_4;
78        m -= half3x3(2.0h);
79        ok = ok && m == half3x3(half3(2.0h, 4.0h, 4.0h), half3(4.0h, 2.0h, 4.0h), half3(4.0h, 4.0h, 2.0h));
80        m = splat_4;
81        m /= splat_2;
82        ok = ok && m == half3x3(half3(2.0h, 2.0h, 2.0h), half3(2.0h, 2.0h, 2.0h), half3(2.0h, 2.0h, 2.0h));
83    }
84    {
85        half4x4 m = half4x4(half4(1.0h, 2.0h, 3.0h, 4.0h), half4(5.0h, 6.0h, 7.0h, 8.0h), half4(9.0h, 10.0h, 11.0h, 12.0h), half4(13.0h, 14.0h, 15.0h, 16.0h));
86        m += half4x4(half4(16.0h, 15.0h, 14.0h, 13.0h), half4(12.0h, 11.0h, 10.0h, 9.0h), half4(8.0h, 7.0h, 6.0h, 5.0h), half4(4.0h, 3.0h, 2.0h, 1.0h));
87        ok = ok && m == half4x4(half4(17.0h, 17.0h, 17.0h, 17.0h), half4(17.0h, 17.0h, 17.0h, 17.0h), half4(17.0h, 17.0h, 17.0h, 17.0h), half4(17.0h, 17.0h, 17.0h, 17.0h));
88    }
89    {
90        half2x2 m = half2x2(half2(10.0h, 20.0h), half2(30.0h, 40.0h));
91        m -= half2x2(half2(1.0h, 2.0h), half2(3.0h, 4.0h));
92        ok = ok && m == half2x2(half2(9.0h, 18.0h), half2(27.0h, 36.0h));
93    }
94    {
95        half2x2 m = half2x2(half2(2.0h, 4.0h), half2(6.0h, 8.0h));
96        m /= half2x2(half2(2.0h, 2.0h), half2(2.0h, 4.0h));
97        ok = ok && m == half2x2(half2(1.0h, 2.0h), half2(3.0h, 2.0h));
98    }
99    {
100        half2x2 m = half2x2(half2(1.0h, 2.0h), half2(7.0h, 4.0h));
101        m *= half2x2(half2(3.0h, 5.0h), half2(3.0h, 2.0h));
102        ok = ok && m == half2x2(half2(38.0h, 26.0h), half2(17.0h, 14.0h));
103    }
104    {
105        half3x3 m = half3x3(half3(10.0h, 4.0h, 2.0h), half3(20.0h, 5.0h, 3.0h), half3(10.0h, 6.0h, 5.0h));
106        m *= half3x3(half3(3.0h, 3.0h, 4.0h), half3(2.0h, 3.0h, 4.0h), half3(4.0h, 9.0h, 2.0h));
107        ok = ok && m == half3x3(half3(130.0h, 51.0h, 35.0h), half3(120.0h, 47.0h, 33.0h), half3(240.0h, 73.0h, 45.0h));
108    }
109    return ok;
110}
111fragment Outputs fragmentMain(Inputs _in [[stage_in]], constant Uniforms& _uniforms [[buffer(0)]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) {
112    Outputs _out;
113    (void)_out;
114    bool _0_ok = true;
115    {
116        const float3x3 _1_splat_4 = float3x3(float3(4.0, 4.0, 4.0), float3(4.0, 4.0, 4.0), float3(4.0, 4.0, 4.0));
117        const float3x3 _2_splat_2 = float3x3(float3(2.0, 2.0, 2.0), float3(2.0, 2.0, 2.0), float3(2.0, 2.0, 2.0));
118        float3x3 _3_m = float3x3(2.0);
119        _3_m += _1_splat_4;
120        _0_ok = _0_ok && _3_m == float3x3(float3(6.0, 4.0, 4.0), float3(4.0, 6.0, 4.0), float3(4.0, 4.0, 6.0));
121        _3_m = float3x3(2.0);
122        _3_m -= _1_splat_4;
123        _0_ok = _0_ok && _3_m == float3x3(float3(-2.0, -4.0, -4.0), float3(-4.0, -2.0, -4.0), float3(-4.0, -4.0, -2.0));
124        _3_m = float3x3(2.0);
125        _3_m /= _1_splat_4;
126        _0_ok = _0_ok && _3_m == float3x3(0.5);
127        _3_m = _1_splat_4;
128        _3_m += float3x3(2.0);
129        _0_ok = _0_ok && _3_m == float3x3(float3(6.0, 4.0, 4.0), float3(4.0, 6.0, 4.0), float3(4.0, 4.0, 6.0));
130        _3_m = _1_splat_4;
131        _3_m -= float3x3(2.0);
132        _0_ok = _0_ok && _3_m == float3x3(float3(2.0, 4.0, 4.0), float3(4.0, 2.0, 4.0), float3(4.0, 4.0, 2.0));
133        _3_m = _1_splat_4;
134        _3_m /= _2_splat_2;
135        _0_ok = _0_ok && _3_m == float3x3(float3(2.0, 2.0, 2.0), float3(2.0, 2.0, 2.0), float3(2.0, 2.0, 2.0));
136    }
137    {
138        float4x4 _4_m = float4x4(float4(1.0, 2.0, 3.0, 4.0), float4(5.0, 6.0, 7.0, 8.0), float4(9.0, 10.0, 11.0, 12.0), float4(13.0, 14.0, 15.0, 16.0));
139        _4_m += float4x4(float4(16.0, 15.0, 14.0, 13.0), float4(12.0, 11.0, 10.0, 9.0), float4(8.0, 7.0, 6.0, 5.0), float4(4.0, 3.0, 2.0, 1.0));
140        _0_ok = _0_ok && _4_m == float4x4(float4(17.0, 17.0, 17.0, 17.0), float4(17.0, 17.0, 17.0, 17.0), float4(17.0, 17.0, 17.0, 17.0), float4(17.0, 17.0, 17.0, 17.0));
141    }
142    {
143        float2x2 _5_m = float2x2(float2(10.0, 20.0), float2(30.0, 40.0));
144        _5_m -= float2x2(float2(1.0, 2.0), float2(3.0, 4.0));
145        _0_ok = _0_ok && _5_m == float2x2(float2(9.0, 18.0), float2(27.0, 36.0));
146    }
147    {
148        float2x2 _6_m = float2x2(float2(2.0, 4.0), float2(6.0, 8.0));
149        _6_m /= float2x2(float2(2.0, 2.0), float2(2.0, 4.0));
150        _0_ok = _0_ok && _6_m == float2x2(float2(1.0, 2.0), float2(3.0, 2.0));
151    }
152    {
153        float2x2 _7_m = float2x2(float2(1.0, 2.0), float2(7.0, 4.0));
154        _7_m *= float2x2(float2(3.0, 5.0), float2(3.0, 2.0));
155        _0_ok = _0_ok && _7_m == float2x2(float2(38.0, 26.0), float2(17.0, 14.0));
156    }
157    {
158        float3x3 _8_m = float3x3(float3(10.0, 4.0, 2.0), float3(20.0, 5.0, 3.0), float3(10.0, 6.0, 5.0));
159        _8_m *= float3x3(float3(3.0, 3.0, 4.0), float3(2.0, 3.0, 4.0), float3(4.0, 9.0, 2.0));
160        _0_ok = _0_ok && _8_m == float3x3(float3(130.0, 51.0, 35.0), float3(120.0, 47.0, 33.0), float3(240.0, 73.0, 45.0));
161    }
162    _out.sk_FragColor = _0_ok && test_matrix_op_matrix_half_b() ? _uniforms.colorGreen : _uniforms.colorRed;
163    return _out;
164}
165