xref: /aosp_15_r20/external/skia/tests/sksl/shared/IntegerDivisionES3.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};
10struct Inputs {
11};
12struct Outputs {
13    half4 sk_FragColor [[color(0)]];
14};
15fragment Outputs fragmentMain(Inputs _in [[stage_in]], constant Uniforms& _uniforms [[buffer(0)]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) {
16    Outputs _out;
17    (void)_out;
18    int zero = int(_uniforms.colorGreen.x);
19    int one = int(_uniforms.colorGreen.y);
20    for (int x = zero;x < 100; ++x) {
21        for (int y = one;y < 100; ++y) {
22            int _0_x = x;
23            int _1_result = 0;
24            while (_0_x >= y) {
25                ++_1_result;
26                _0_x -= y;
27            }
28            if (x / y != _1_result) {
29                _out.sk_FragColor = half4(1.0h, half(float(x) * 0.003921569), half(float(y) * 0.003921569), 1.0h);
30                return _out;
31            }
32        }
33    }
34    _out.sk_FragColor = _uniforms.colorGreen;
35    return _out;
36}
37