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}; 16fragment Outputs fragmentMain(Inputs _in [[stage_in]], constant Uniforms& _uniforms [[buffer(0)]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) { 17 Outputs _out; 18 (void)_out; 19 half sumA = 0.0h; 20 half sumB = 0.0h; 21 { 22 half a = 0.0h; 23 half b = 10.0h; 24 for (; a < 10.0h && b > 0.0h; (++a, --b)) { 25 sumA += a; 26 sumB += b; 27 } 28 } 29 if (sumA != 45.0h || sumB != 55.0h) { 30 _out.sk_FragColor = _uniforms.colorRed; 31 return _out; 32 } 33 int sumC = 0; 34 { 35 int c = 0; 36 for (; c < 10; ++c) { 37 sumC += c; 38 } 39 } 40 if (sumC != 45) { 41 _out.sk_FragColor = _uniforms.colorRed; 42 return _out; 43 } 44 float sumE = 0.0; 45 { 46 array<float, 2> d = array<float, 2>{0.0, 10.0}; 47 array<float, 4> e = array<float, 4>{1.0, 2.0, 3.0, 4.0}; 48 for (; d[0] < d[1]; ++d[0]) { 49 sumE += float(half(e[0])); 50 } 51 } 52 if (sumE != 10.0) { 53 _out.sk_FragColor = _uniforms.colorRed; 54 return _out; 55 } 56 { 57 for (; ; ) break; 58 } 59 for (; ; ) _out.sk_FragColor = _uniforms.colorGreen; 60 return _out; 61 return _out; 62} 63