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    half4 testInputs;
8cb93a386Sopenharmony_ci};
9cb93a386Sopenharmony_cistruct Inputs {
10cb93a386Sopenharmony_ci};
11cb93a386Sopenharmony_cistruct Outputs {
12cb93a386Sopenharmony_ci    half4 sk_FragColor [[color(0)]];
13cb93a386Sopenharmony_ci};
14cb93a386Sopenharmony_ci
15cb93a386Sopenharmony_cithread bool operator==(const half2x2 left, const half2x2 right);
16cb93a386Sopenharmony_cithread bool operator!=(const half2x2 left, const half2x2 right);
17cb93a386Sopenharmony_ci
18cb93a386Sopenharmony_cithread bool operator==(const float2x2 left, const float2x2 right);
19cb93a386Sopenharmony_cithread bool operator!=(const float2x2 left, const float2x2 right);
20cb93a386Sopenharmony_cithread bool operator==(const half2x2 left, const half2x2 right) {
21cb93a386Sopenharmony_ci    return all(left[0] == right[0]) &&
22cb93a386Sopenharmony_ci           all(left[1] == right[1]);
23cb93a386Sopenharmony_ci}
24cb93a386Sopenharmony_cithread bool operator!=(const half2x2 left, const half2x2 right) {
25cb93a386Sopenharmony_ci    return !(left == right);
26cb93a386Sopenharmony_ci}
27cb93a386Sopenharmony_cihalf2x2 half2x2_from_half4(half4 x0) {
28cb93a386Sopenharmony_ci    return half2x2(half2(x0.xy), half2(x0.zw));
29cb93a386Sopenharmony_ci}
30cb93a386Sopenharmony_cithread bool operator==(const float2x2 left, const float2x2 right) {
31cb93a386Sopenharmony_ci    return all(left[0] == right[0]) &&
32cb93a386Sopenharmony_ci           all(left[1] == right[1]);
33cb93a386Sopenharmony_ci}
34cb93a386Sopenharmony_cithread bool operator!=(const float2x2 left, const float2x2 right) {
35cb93a386Sopenharmony_ci    return !(left == right);
36cb93a386Sopenharmony_ci}
37cb93a386Sopenharmony_cifloat2x2 float2x2_from_float4(float4 x0) {
38cb93a386Sopenharmony_ci    return float2x2(float2(x0.xy), float2(x0.zw));
39cb93a386Sopenharmony_ci}
40cb93a386Sopenharmony_cifragment Outputs fragmentMain(Inputs _in [[stage_in]], constant Uniforms& _uniforms [[buffer(0)]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) {
41cb93a386Sopenharmony_ci    Outputs _out;
42cb93a386Sopenharmony_ci    (void)_out;
43cb93a386Sopenharmony_ci    bool ok = true;
44cb93a386Sopenharmony_ci    ok = ok && half2x2_from_half4(_uniforms.testInputs) == half2x2(half2(-1.25h, 0.0h), half2(0.75h, 2.25h));
45cb93a386Sopenharmony_ci    ok = ok && float2x2_from_float4(float4(_uniforms.testInputs)) == float2x2(float2(-1.25, 0.0), float2(0.75, 2.25));
46cb93a386Sopenharmony_ci    ok = ok && half2x2_from_half4(_uniforms.colorGreen) == half2x2(half2(0.0h, 1.0h), half2(0.0h, 1.0h));
47cb93a386Sopenharmony_ci    ok = ok && half2x2_from_half4(_uniforms.colorGreen) == half2x2(half2(0.0h, 1.0h), half2(0.0h, 1.0h));
48cb93a386Sopenharmony_ci    ok = ok && half2x2_from_half4(half4(int4(_uniforms.colorGreen))) == half2x2(half2(0.0h, 1.0h), half2(0.0h, 1.0h));
49cb93a386Sopenharmony_ci    ok = ok && half2x2_from_half4(_uniforms.colorGreen) == half2x2(half2(0.0h, 1.0h), half2(0.0h, 1.0h));
50cb93a386Sopenharmony_ci    ok = ok && half2x2_from_half4(_uniforms.colorGreen) == half2x2(half2(0.0h, 1.0h), half2(0.0h, 1.0h));
51cb93a386Sopenharmony_ci    ok = ok && half2x2_from_half4(half4(bool4(_uniforms.colorGreen))) == half2x2(half2(0.0h, 1.0h), half2(0.0h, 1.0h));
52cb93a386Sopenharmony_ci    _out.sk_FragColor = ok ? _uniforms.colorGreen : _uniforms.colorRed;
53cb93a386Sopenharmony_ci    return _out;
54cb93a386Sopenharmony_ci}
55