1#include <metal_stdlib> 2#include <simd/simd.h> 3using namespace metal; 4struct Uniforms { 5 half4 colorGreen; 6 half4 colorRed; 7}; 8struct Inputs { 9}; 10struct Outputs { 11 half4 sk_FragColor [[color(0)]]; 12}; 13half4 unpremul_h4h4(half4 color) { 14 return half4(color.xyz / max(color.w, 9.9999997473787516e-05h), color.w); 15} 16half4 live_fn_h4h4h4(half4 a, half4 b) { 17 return a + b; 18} 19fragment Outputs fragmentMain(Inputs _in [[stage_in]], constant Uniforms& _uniforms [[buffer(0)]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) { 20 Outputs _out; 21 (void)_out; 22 half4 a; 23 half4 b; 24 { 25 a = live_fn_h4h4h4(half4(3.0h), half4(-5.0h)); 26 } 27 { 28 b = unpremul_h4h4(half4(1.0h)); 29 } 30 _out.sk_FragColor = any(a != half4(0.0h)) && any(b != half4(0.0h)) ? _uniforms.colorGreen : _uniforms.colorRed; 31 return _out; 32} 33