xref: /aosp_15_r20/external/skia/tests/sksl/shared/DeadStripFunctions.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};
16half4 unpremul_h4h4(half4 color);
17half4 unpremul_h4h4(half4 color) {
18    return half4(color.xyz / max(color.w, 0.0001h), color.w);
19}
20half4 live_fn_h4h4h4(half4 a, half4 b) {
21    return a + b;
22}
23fragment Outputs fragmentMain(Inputs _in [[stage_in]], constant Uniforms& _uniforms [[buffer(0)]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) {
24    Outputs _out;
25    (void)_out;
26    half4 a;
27    half4 b;
28    {
29        a = live_fn_h4h4h4(half4(3.0h), half4(-5.0h));
30    }
31    {
32        b = unpremul_h4h4(half4(1.0h));
33    }
34    _out.sk_FragColor = any(a != half4(0.0h)) && any(b != half4(0.0h)) ? _uniforms.colorGreen : _uniforms.colorRed;
35    return _out;
36}
37