xref: /aosp_15_r20/external/skia/tests/sksl/shared/LogicalAndShortCircuit.metal (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
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 colorGreen;
9    half4 colorRed;
10};
11struct Inputs {
12};
13struct Outputs {
14    half4 sk_FragColor [[color(0)]];
15};
16bool TrueFalse_b() {
17    int x = 1;
18    int y = 1;
19    if (x == 1 && (y += 1) == 3) {
20        return false;
21    } else {
22        return x == 1 && y == 2;
23    }
24}
25bool FalseTrue_b() {
26    int x = 1;
27    int y = 1;
28    if (x == 2 && (y += 1) == 2) {
29        return false;
30    } else {
31        return x == 1 && y == 1;
32    }
33}
34bool FalseFalse_b() {
35    int x = 1;
36    int y = 1;
37    if (x == 2 && (y += 1) == 3) {
38        return false;
39    } else {
40        return x == 1 && y == 1;
41    }
42}
43fragment Outputs fragmentMain(Inputs _in [[stage_in]], constant Uniforms& _uniforms [[buffer(0)]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) {
44    Outputs _out;
45    (void)_out;
46    bool _0_TrueTrue;
47    int _2_y = 1;
48    if ((_2_y += 1) == 2) {
49        _0_TrueTrue = _2_y == 2;
50    } else {
51        _0_TrueTrue = false;
52    }
53    _out.sk_FragColor = ((_0_TrueTrue && TrueFalse_b()) && FalseTrue_b()) && FalseFalse_b() ? _uniforms.colorGreen : _uniforms.colorRed;
54    return _out;
55}
56