1cb93a386Sopenharmony_ci#include <metal_stdlib>
2cb93a386Sopenharmony_ci#include <simd/simd.h>
3cb93a386Sopenharmony_ciusing namespace metal;
4cb93a386Sopenharmony_cistruct Uniforms {
5cb93a386Sopenharmony_ci    half4 colorGreen;
6cb93a386Sopenharmony_ci    half4 colorRed;
7cb93a386Sopenharmony_ci};
8cb93a386Sopenharmony_cistruct Inputs {
9cb93a386Sopenharmony_ci};
10cb93a386Sopenharmony_cistruct Outputs {
11cb93a386Sopenharmony_ci    half4 sk_FragColor [[color(0)]];
12cb93a386Sopenharmony_ci};
13cb93a386Sopenharmony_ci
14cb93a386Sopenharmony_cithread bool operator==(const half3x3 left, const half3x3 right);
15cb93a386Sopenharmony_cithread bool operator!=(const half3x3 left, const half3x3 right);
16cb93a386Sopenharmony_ci
17cb93a386Sopenharmony_cithread bool operator==(const half2x2 left, const half2x2 right);
18cb93a386Sopenharmony_cithread bool operator!=(const half2x2 left, const half2x2 right);
19cb93a386Sopenharmony_ci
20cb93a386Sopenharmony_cithread bool operator==(const float3x3 left, const float3x3 right);
21cb93a386Sopenharmony_cithread bool operator!=(const float3x3 left, const float3x3 right);
22cb93a386Sopenharmony_ci
23cb93a386Sopenharmony_cithread bool operator==(const float2x2 left, const float2x2 right);
24cb93a386Sopenharmony_cithread bool operator!=(const float2x2 left, const float2x2 right);
25cb93a386Sopenharmony_cithread bool operator==(const half3x3 left, const half3x3 right) {
26cb93a386Sopenharmony_ci    return all(left[0] == right[0]) &&
27cb93a386Sopenharmony_ci           all(left[1] == right[1]) &&
28cb93a386Sopenharmony_ci           all(left[2] == right[2]);
29cb93a386Sopenharmony_ci}
30cb93a386Sopenharmony_cithread bool operator!=(const half3x3 left, const half3x3 right) {
31cb93a386Sopenharmony_ci    return !(left == right);
32cb93a386Sopenharmony_ci}
33cb93a386Sopenharmony_cithread half3x3 operator/(const half3x3 left, const half3x3 right) {
34cb93a386Sopenharmony_ci    return half3x3(left[0] / right[0], left[1] / right[1], left[2] / right[2]);
35cb93a386Sopenharmony_ci}
36cb93a386Sopenharmony_cithread half3x3& operator/=(thread half3x3& left, thread const half3x3& right) {
37cb93a386Sopenharmony_ci    left = left / right;
38cb93a386Sopenharmony_ci    return left;
39cb93a386Sopenharmony_ci}
40cb93a386Sopenharmony_cithread bool operator==(const half2x2 left, const half2x2 right) {
41cb93a386Sopenharmony_ci    return all(left[0] == right[0]) &&
42cb93a386Sopenharmony_ci           all(left[1] == right[1]);
43cb93a386Sopenharmony_ci}
44cb93a386Sopenharmony_cithread bool operator!=(const half2x2 left, const half2x2 right) {
45cb93a386Sopenharmony_ci    return !(left == right);
46cb93a386Sopenharmony_ci}
47cb93a386Sopenharmony_cithread half2x2 operator/(const half2x2 left, const half2x2 right) {
48cb93a386Sopenharmony_ci    return half2x2(left[0] / right[0], left[1] / right[1]);
49cb93a386Sopenharmony_ci}
50cb93a386Sopenharmony_cithread half2x2& operator/=(thread half2x2& left, thread const half2x2& right) {
51cb93a386Sopenharmony_ci    left = left / right;
52cb93a386Sopenharmony_ci    return left;
53cb93a386Sopenharmony_ci}
54cb93a386Sopenharmony_cithread bool operator==(const float3x3 left, const float3x3 right) {
55cb93a386Sopenharmony_ci    return all(left[0] == right[0]) &&
56cb93a386Sopenharmony_ci           all(left[1] == right[1]) &&
57cb93a386Sopenharmony_ci           all(left[2] == right[2]);
58cb93a386Sopenharmony_ci}
59cb93a386Sopenharmony_cithread bool operator!=(const float3x3 left, const float3x3 right) {
60cb93a386Sopenharmony_ci    return !(left == right);
61cb93a386Sopenharmony_ci}
62cb93a386Sopenharmony_cithread float3x3 operator/(const float3x3 left, const float3x3 right) {
63cb93a386Sopenharmony_ci    return float3x3(left[0] / right[0], left[1] / right[1], left[2] / right[2]);
64cb93a386Sopenharmony_ci}
65cb93a386Sopenharmony_cithread float3x3& operator/=(thread float3x3& left, thread const float3x3& right) {
66cb93a386Sopenharmony_ci    left = left / right;
67cb93a386Sopenharmony_ci    return left;
68cb93a386Sopenharmony_ci}
69cb93a386Sopenharmony_cithread bool operator==(const float2x2 left, const float2x2 right) {
70cb93a386Sopenharmony_ci    return all(left[0] == right[0]) &&
71cb93a386Sopenharmony_ci           all(left[1] == right[1]);
72cb93a386Sopenharmony_ci}
73cb93a386Sopenharmony_cithread bool operator!=(const float2x2 left, const float2x2 right) {
74cb93a386Sopenharmony_ci    return !(left == right);
75cb93a386Sopenharmony_ci}
76cb93a386Sopenharmony_cithread float2x2 operator/(const float2x2 left, const float2x2 right) {
77cb93a386Sopenharmony_ci    return float2x2(left[0] / right[0], left[1] / right[1]);
78cb93a386Sopenharmony_ci}
79cb93a386Sopenharmony_cithread float2x2& operator/=(thread float2x2& left, thread const float2x2& right) {
80cb93a386Sopenharmony_ci    left = left / right;
81cb93a386Sopenharmony_ci    return left;
82cb93a386Sopenharmony_ci}
83cb93a386Sopenharmony_cibool test_half_b() {
84cb93a386Sopenharmony_ci    bool ok = true;
85cb93a386Sopenharmony_ci    ok = ok && half3x3(2.0h) + (half3x3(1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0) * 4.0h) == half3x3(half3(6.0h, 4.0h, 4.0h), half3(4.0h, 6.0h, 4.0h), half3(4.0h, 4.0h, 6.0h));
86cb93a386Sopenharmony_ci    ok = ok && half3x3(2.0h) - (half3x3(1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0) * 4.0h) == half3x3(half3(-2.0h, -4.0h, -4.0h), half3(-4.0h, -2.0h, -4.0h), half3(-4.0h, -4.0h, -2.0h));
87cb93a386Sopenharmony_ci    ok = ok && half3x3(2.0h) * 4.0h == half3x3(8.0h);
88cb93a386Sopenharmony_ci    ok = ok && half3x3(2.0h) / (half3x3(1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0) * 4.0h) == half3x3(0.5h);
89cb93a386Sopenharmony_ci    ok = ok && (half3x3(1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0) * 4.0h) + half3x3(2.0h) == half3x3(half3(6.0h, 4.0h, 4.0h), half3(4.0h, 6.0h, 4.0h), half3(4.0h, 4.0h, 6.0h));
90cb93a386Sopenharmony_ci    ok = ok && (half3x3(1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0) * 4.0h) - half3x3(2.0h) == half3x3(half3(2.0h, 4.0h, 4.0h), half3(4.0h, 2.0h, 4.0h), half3(4.0h, 4.0h, 2.0h));
91cb93a386Sopenharmony_ci    ok = ok && 4.0h * half3x3(2.0h) == half3x3(8.0h);
92cb93a386Sopenharmony_ci    ok = ok && (half2x2(1.0, 1.0, 1.0, 1.0) * 4.0h) / half2x2(half2(2.0h, 2.0h), half2(2.0h, 2.0h)) == half2x2(half2(2.0h, 2.0h), half2(2.0h, 2.0h));
93cb93a386Sopenharmony_ci    return ok;
94cb93a386Sopenharmony_ci}
95cb93a386Sopenharmony_cifragment Outputs fragmentMain(Inputs _in [[stage_in]], constant Uniforms& _uniforms [[buffer(0)]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) {
96cb93a386Sopenharmony_ci    Outputs _out;
97cb93a386Sopenharmony_ci    (void)_out;
98cb93a386Sopenharmony_ci    bool _0_ok = true;
99cb93a386Sopenharmony_ci    _0_ok = _0_ok && float3x3(2.0) + (float3x3(1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0) * 4.0) == float3x3(float3(6.0, 4.0, 4.0), float3(4.0, 6.0, 4.0), float3(4.0, 4.0, 6.0));
100cb93a386Sopenharmony_ci    _0_ok = _0_ok && float3x3(2.0) - (float3x3(1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0) * 4.0) == float3x3(float3(-2.0, -4.0, -4.0), float3(-4.0, -2.0, -4.0), float3(-4.0, -4.0, -2.0));
101cb93a386Sopenharmony_ci    _0_ok = _0_ok && float3x3(2.0) * 4.0 == float3x3(8.0);
102cb93a386Sopenharmony_ci    _0_ok = _0_ok && float3x3(2.0) / (float3x3(1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0) * 4.0) == float3x3(0.5);
103cb93a386Sopenharmony_ci    _0_ok = _0_ok && (float3x3(1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0) * 4.0) + float3x3(2.0) == float3x3(float3(6.0, 4.0, 4.0), float3(4.0, 6.0, 4.0), float3(4.0, 4.0, 6.0));
104cb93a386Sopenharmony_ci    _0_ok = _0_ok && (float3x3(1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0) * 4.0) - float3x3(2.0) == float3x3(float3(2.0, 4.0, 4.0), float3(4.0, 2.0, 4.0), float3(4.0, 4.0, 2.0));
105cb93a386Sopenharmony_ci    _0_ok = _0_ok && 4.0 * float3x3(2.0) == float3x3(8.0);
106cb93a386Sopenharmony_ci    _0_ok = _0_ok && (float2x2(1.0, 1.0, 1.0, 1.0) * 4.0) / float2x2(float2(2.0, 2.0), float2(2.0, 2.0)) == float2x2(float2(2.0, 2.0), float2(2.0, 2.0));
107cb93a386Sopenharmony_ci    _out.sk_FragColor = _0_ok && test_half_b() ? _uniforms.colorGreen : _uniforms.colorRed;
108cb93a386Sopenharmony_ci    return _out;
109cb93a386Sopenharmony_ci}
110