Update rive-cpp to 2.0 version
[platform/core/uifw/rive-tizen.git] / submodule / skia / tests / sksl / shared / MatricesNonsquare.metal
1 #include <metal_stdlib>
2 #include <simd/simd.h>
3 using namespace metal;
4 struct Uniforms {
5     half4 colorGreen;
6     half4 colorRed;
7 };
8 struct Inputs {
9 };
10 struct Outputs {
11     half4 sk_FragColor [[color(0)]];
12 };
13
14 thread bool operator==(const half2x3 left, const half2x3 right);
15 thread bool operator!=(const half2x3 left, const half2x3 right);
16
17 thread bool operator==(const half2x4 left, const half2x4 right);
18 thread bool operator!=(const half2x4 left, const half2x4 right);
19
20 thread bool operator==(const half3x2 left, const half3x2 right);
21 thread bool operator!=(const half3x2 left, const half3x2 right);
22
23 thread bool operator==(const half3x4 left, const half3x4 right);
24 thread bool operator!=(const half3x4 left, const half3x4 right);
25
26 thread bool operator==(const half4x2 left, const half4x2 right);
27 thread bool operator!=(const half4x2 left, const half4x2 right);
28
29 thread bool operator==(const half4x3 left, const half4x3 right);
30 thread bool operator!=(const half4x3 left, const half4x3 right);
31
32 thread bool operator==(const half2x2 left, const half2x2 right);
33 thread bool operator!=(const half2x2 left, const half2x2 right);
34
35 thread bool operator==(const half3x3 left, const half3x3 right);
36 thread bool operator!=(const half3x3 left, const half3x3 right);
37
38 thread bool operator==(const float2x3 left, const float2x3 right);
39 thread bool operator!=(const float2x3 left, const float2x3 right);
40
41 thread bool operator==(const float2x4 left, const float2x4 right);
42 thread bool operator!=(const float2x4 left, const float2x4 right);
43
44 thread bool operator==(const float3x2 left, const float3x2 right);
45 thread bool operator!=(const float3x2 left, const float3x2 right);
46
47 thread bool operator==(const float3x4 left, const float3x4 right);
48 thread bool operator!=(const float3x4 left, const float3x4 right);
49
50 thread bool operator==(const float4x2 left, const float4x2 right);
51 thread bool operator!=(const float4x2 left, const float4x2 right);
52
53 thread bool operator==(const float4x3 left, const float4x3 right);
54 thread bool operator!=(const float4x3 left, const float4x3 right);
55
56 thread bool operator==(const float2x2 left, const float2x2 right);
57 thread bool operator!=(const float2x2 left, const float2x2 right);
58
59 thread bool operator==(const float3x3 left, const float3x3 right);
60 thread bool operator!=(const float3x3 left, const float3x3 right);
61 thread bool operator==(const half2x3 left, const half2x3 right) {
62     return all(left[0] == right[0]) &&
63            all(left[1] == right[1]);
64 }
65 thread bool operator!=(const half2x3 left, const half2x3 right) {
66     return !(left == right);
67 }
68 thread bool operator==(const half2x4 left, const half2x4 right) {
69     return all(left[0] == right[0]) &&
70            all(left[1] == right[1]);
71 }
72 thread bool operator!=(const half2x4 left, const half2x4 right) {
73     return !(left == right);
74 }
75 thread bool operator==(const half3x2 left, const half3x2 right) {
76     return all(left[0] == right[0]) &&
77            all(left[1] == right[1]) &&
78            all(left[2] == right[2]);
79 }
80 thread bool operator!=(const half3x2 left, const half3x2 right) {
81     return !(left == right);
82 }
83 thread bool operator==(const half3x4 left, const half3x4 right) {
84     return all(left[0] == right[0]) &&
85            all(left[1] == right[1]) &&
86            all(left[2] == right[2]);
87 }
88 thread bool operator!=(const half3x4 left, const half3x4 right) {
89     return !(left == right);
90 }
91 thread bool operator==(const half4x2 left, const half4x2 right) {
92     return all(left[0] == right[0]) &&
93            all(left[1] == right[1]) &&
94            all(left[2] == right[2]) &&
95            all(left[3] == right[3]);
96 }
97 thread bool operator!=(const half4x2 left, const half4x2 right) {
98     return !(left == right);
99 }
100 thread bool operator==(const half4x3 left, const half4x3 right) {
101     return all(left[0] == right[0]) &&
102            all(left[1] == right[1]) &&
103            all(left[2] == right[2]) &&
104            all(left[3] == right[3]);
105 }
106 thread bool operator!=(const half4x3 left, const half4x3 right) {
107     return !(left == right);
108 }
109 thread bool operator==(const half2x2 left, const half2x2 right) {
110     return all(left[0] == right[0]) &&
111            all(left[1] == right[1]);
112 }
113 thread bool operator!=(const half2x2 left, const half2x2 right) {
114     return !(left == right);
115 }
116 thread bool operator==(const half3x3 left, const half3x3 right) {
117     return all(left[0] == right[0]) &&
118            all(left[1] == right[1]) &&
119            all(left[2] == right[2]);
120 }
121 thread bool operator!=(const half3x3 left, const half3x3 right) {
122     return !(left == right);
123 }
124 thread half2x4 operator/(const half2x4 left, const half2x4 right) {
125     return half2x4(left[0] / right[0], left[1] / right[1]);
126 }
127 thread half2x4& operator/=(thread half2x4& left, thread const half2x4& right) {
128     left = left / right;
129     return left;
130 }
131 thread bool operator==(const float2x3 left, const float2x3 right) {
132     return all(left[0] == right[0]) &&
133            all(left[1] == right[1]);
134 }
135 thread bool operator!=(const float2x3 left, const float2x3 right) {
136     return !(left == right);
137 }
138 thread bool operator==(const float2x4 left, const float2x4 right) {
139     return all(left[0] == right[0]) &&
140            all(left[1] == right[1]);
141 }
142 thread bool operator!=(const float2x4 left, const float2x4 right) {
143     return !(left == right);
144 }
145 thread bool operator==(const float3x2 left, const float3x2 right) {
146     return all(left[0] == right[0]) &&
147            all(left[1] == right[1]) &&
148            all(left[2] == right[2]);
149 }
150 thread bool operator!=(const float3x2 left, const float3x2 right) {
151     return !(left == right);
152 }
153 thread bool operator==(const float3x4 left, const float3x4 right) {
154     return all(left[0] == right[0]) &&
155            all(left[1] == right[1]) &&
156            all(left[2] == right[2]);
157 }
158 thread bool operator!=(const float3x4 left, const float3x4 right) {
159     return !(left == right);
160 }
161 thread bool operator==(const float4x2 left, const float4x2 right) {
162     return all(left[0] == right[0]) &&
163            all(left[1] == right[1]) &&
164            all(left[2] == right[2]) &&
165            all(left[3] == right[3]);
166 }
167 thread bool operator!=(const float4x2 left, const float4x2 right) {
168     return !(left == right);
169 }
170 thread bool operator==(const float4x3 left, const float4x3 right) {
171     return all(left[0] == right[0]) &&
172            all(left[1] == right[1]) &&
173            all(left[2] == right[2]) &&
174            all(left[3] == right[3]);
175 }
176 thread bool operator!=(const float4x3 left, const float4x3 right) {
177     return !(left == right);
178 }
179 thread bool operator==(const float2x2 left, const float2x2 right) {
180     return all(left[0] == right[0]) &&
181            all(left[1] == right[1]);
182 }
183 thread bool operator!=(const float2x2 left, const float2x2 right) {
184     return !(left == right);
185 }
186 thread bool operator==(const float3x3 left, const float3x3 right) {
187     return all(left[0] == right[0]) &&
188            all(left[1] == right[1]) &&
189            all(left[2] == right[2]);
190 }
191 thread bool operator!=(const float3x3 left, const float3x3 right) {
192     return !(left == right);
193 }
194 thread float2x4 operator/(const float2x4 left, const float2x4 right) {
195     return float2x4(left[0] / right[0], left[1] / right[1]);
196 }
197 thread float2x4& operator/=(thread float2x4& left, thread const float2x4& right) {
198     left = left / right;
199     return left;
200 }
201 bool test_half_b() {
202     bool ok = true;
203     half2x3 m23 = half2x3(2.0h);
204     ok = ok && m23 == half2x3(half3(2.0h, 0.0h, 0.0h), half3(0.0h, 2.0h, 0.0h));
205     half2x4 m24 = half2x4(3.0h);
206     ok = ok && m24 == half2x4(half4(3.0h, 0.0h, 0.0h, 0.0h), half4(0.0h, 3.0h, 0.0h, 0.0h));
207     half3x2 m32 = half3x2(4.0h);
208     ok = ok && m32 == half3x2(half2(4.0h, 0.0h), half2(0.0h, 4.0h), half2(0.0h, 0.0h));
209     half3x4 m34 = half3x4(5.0h);
210     ok = ok && m34 == half3x4(half4(5.0h, 0.0h, 0.0h, 0.0h), half4(0.0h, 5.0h, 0.0h, 0.0h), half4(0.0h, 0.0h, 5.0h, 0.0h));
211     half4x2 m42 = half4x2(6.0h);
212     ok = ok && m42 == half4x2(half2(6.0h, 0.0h), half2(0.0h, 6.0h), half2(0.0h, 0.0h), half2(0.0h, 0.0h));
213     half4x3 m43 = half4x3(7.0h);
214     ok = ok && m43 == half4x3(half3(7.0h, 0.0h, 0.0h), half3(0.0h, 7.0h, 0.0h), half3(0.0h, 0.0h, 7.0h), half3(0.0h, 0.0h, 0.0h));
215     half2x2 m22 = m32 * m23;
216     ok = ok && m22 == half2x2(8.0h);
217     half3x3 m33 = m43 * m34;
218     ok = ok && m33 == half3x3(35.0h);
219     m23 += (half2x3(1.0, 1.0, 1.0, 1.0, 1.0, 1.0) * 1.0h);
220     ok = ok && m23 == half2x3(half3(3.0h, 1.0h, 1.0h), half3(1.0h, 3.0h, 1.0h));
221     m32 -= (half3x2(1.0, 1.0, 1.0, 1.0, 1.0, 1.0) * 2.0h);
222     ok = ok && m32 == half3x2(half2(2.0h, -2.0h), half2(-2.0h, 2.0h), half2(-2.0h, -2.0h));
223     m24 /= (half2x4(1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0) * 4.0h);
224     ok = ok && m24 == half2x4(half4(0.75h, 0.0h, 0.0h, 0.0h), half4(0.0h, 0.75h, 0.0h, 0.0h));
225     return ok;
226 }
227 fragment Outputs fragmentMain(Inputs _in [[stage_in]], constant Uniforms& _uniforms [[buffer(0)]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) {
228     Outputs _out;
229     (void)_out;
230     bool _0_ok = true;
231     float2x3 _1_m23 = float2x3(2.0);
232     _0_ok = _0_ok && _1_m23 == float2x3(float3(2.0, 0.0, 0.0), float3(0.0, 2.0, 0.0));
233     float2x4 _2_m24 = float2x4(3.0);
234     _0_ok = _0_ok && _2_m24 == float2x4(float4(3.0, 0.0, 0.0, 0.0), float4(0.0, 3.0, 0.0, 0.0));
235     float3x2 _3_m32 = float3x2(4.0);
236     _0_ok = _0_ok && _3_m32 == float3x2(float2(4.0, 0.0), float2(0.0, 4.0), float2(0.0, 0.0));
237     float3x4 _4_m34 = float3x4(5.0);
238     _0_ok = _0_ok && _4_m34 == float3x4(float4(5.0, 0.0, 0.0, 0.0), float4(0.0, 5.0, 0.0, 0.0), float4(0.0, 0.0, 5.0, 0.0));
239     float4x2 _5_m42 = float4x2(6.0);
240     _0_ok = _0_ok && _5_m42 == float4x2(float2(6.0, 0.0), float2(0.0, 6.0), float2(0.0, 0.0), float2(0.0, 0.0));
241     float4x3 _6_m43 = float4x3(7.0);
242     _0_ok = _0_ok && _6_m43 == float4x3(float3(7.0, 0.0, 0.0), float3(0.0, 7.0, 0.0), float3(0.0, 0.0, 7.0), float3(0.0, 0.0, 0.0));
243     float2x2 _7_m22 = _3_m32 * _1_m23;
244     _0_ok = _0_ok && _7_m22 == float2x2(8.0);
245     float3x3 _8_m33 = _6_m43 * _4_m34;
246     _0_ok = _0_ok && _8_m33 == float3x3(35.0);
247     _1_m23 += (float2x3(1.0, 1.0, 1.0, 1.0, 1.0, 1.0) * 1.0);
248     _0_ok = _0_ok && _1_m23 == float2x3(float3(3.0, 1.0, 1.0), float3(1.0, 3.0, 1.0));
249     _3_m32 -= (float3x2(1.0, 1.0, 1.0, 1.0, 1.0, 1.0) * 2.0);
250     _0_ok = _0_ok && _3_m32 == float3x2(float2(2.0, -2.0), float2(-2.0, 2.0), float2(-2.0, -2.0));
251     _2_m24 /= (float2x4(1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0) * 4.0);
252     _0_ok = _0_ok && _2_m24 == float2x4(float4(0.75, 0.0, 0.0, 0.0), float4(0.0, 0.75, 0.0, 0.0));
253     _out.sk_FragColor = _0_ok && test_half_b() ? _uniforms.colorGreen : _uniforms.colorRed;
254     return _out;
255 }