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 colorRed; 9 half4 colorGreen; 10 half unknownInput; 11}; 12struct Inputs { 13}; 14struct Outputs { 15 half4 sk_FragColor [[color(0)]]; 16}; 17bool test_int_b(Uniforms _uniforms) { 18 bool ok = true; 19 int4 inputRed = int4(_uniforms.colorRed); 20 int4 inputGreen = int4(_uniforms.colorGreen); 21 int4 x = inputRed + 2; 22 ok = ok && all(x == int4(3, 2, 2, 3)); 23 x = inputGreen.ywxz - 2; 24 ok = ok && all(x == int4(-1, -1, -2, -2)); 25 x = inputRed + inputGreen.y; 26 ok = ok && all(x == int4(2, 1, 1, 2)); 27 x.xyz = inputGreen.wyw * 9; 28 ok = ok && all(x == int4(9, 9, 9, 2)); 29 x.xy = x.zw / 4; 30 ok = ok && all(x == int4(2, 0, 9, 2)); 31 x = (inputRed * 5).yxwz; 32 ok = ok && all(x == int4(0, 5, 5, 0)); 33 x = 2 + inputRed; 34 ok = ok && all(x == int4(3, 2, 2, 3)); 35 x = 10 - inputGreen.ywxz; 36 ok = ok && all(x == int4(9, 9, 10, 10)); 37 x = inputRed.x + inputGreen; 38 ok = ok && all(x == int4(1, 2, 1, 2)); 39 x.xyz = 8 * inputGreen.wyw; 40 ok = ok && all(x == int4(8, 8, 8, 2)); 41 x.xy = 36 / x.zw; 42 ok = ok && all(x == int4(4, 18, 8, 2)); 43 x = (37 / x).yxwz; 44 ok = ok && all(x == int4(2, 9, 18, 4)); 45 x += 2; 46 x *= 2; 47 x -= 4; 48 x /= 2; 49 ok = ok && all(x == int4(2, 9, 18, 4)); 50 x = x + 2; 51 x = x * 2; 52 x = x - 4; 53 x = x / 2; 54 ok = ok && all(x == int4(2, 9, 18, 4)); 55 return ok; 56} 57fragment Outputs fragmentMain(Inputs _in [[stage_in]], constant Uniforms& _uniforms [[buffer(0)]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) { 58 Outputs _out; 59 (void)_out; 60 bool _0_ok = true; 61 half4 _1_inputRed = _uniforms.colorRed; 62 half4 _2_inputGreen = _uniforms.colorGreen; 63 half4 _3_x = _1_inputRed + 2.0h; 64 _0_ok = _0_ok && all(_3_x == half4(3.0h, 2.0h, 2.0h, 3.0h)); 65 _3_x = _2_inputGreen.ywxz - 2.0h; 66 _0_ok = _0_ok && all(_3_x == half4(-1.0h, -1.0h, -2.0h, -2.0h)); 67 _3_x = _1_inputRed + _2_inputGreen.y; 68 _0_ok = _0_ok && all(_3_x == half4(2.0h, 1.0h, 1.0h, 2.0h)); 69 _3_x.xyz = _2_inputGreen.wyw * 9.0h; 70 _0_ok = _0_ok && all(_3_x == half4(9.0h, 9.0h, 9.0h, 2.0h)); 71 _3_x.xy = _3_x.zw * 2.0h; 72 _0_ok = _0_ok && all(_3_x == half4(18.0h, 4.0h, 9.0h, 2.0h)); 73 _3_x = (_1_inputRed * 5.0h).yxwz; 74 _0_ok = _0_ok && all(_3_x == half4(0.0h, 5.0h, 5.0h, 0.0h)); 75 _3_x = 2.0h + _1_inputRed; 76 _0_ok = _0_ok && all(_3_x == half4(3.0h, 2.0h, 2.0h, 3.0h)); 77 _3_x = 10.0h - _2_inputGreen.ywxz; 78 _0_ok = _0_ok && all(_3_x == half4(9.0h, 9.0h, 10.0h, 10.0h)); 79 _3_x = _1_inputRed.x + _2_inputGreen; 80 _0_ok = _0_ok && all(_3_x == half4(1.0h, 2.0h, 1.0h, 2.0h)); 81 _3_x.xyz = 8.0h * _2_inputGreen.wyw; 82 _0_ok = _0_ok && all(_3_x == half4(8.0h, 8.0h, 8.0h, 2.0h)); 83 _3_x.xy = 32.0h / _3_x.zw; 84 _0_ok = _0_ok && all(_3_x == half4(4.0h, 16.0h, 8.0h, 2.0h)); 85 _3_x = (32.0h / _3_x).yxwz; 86 _0_ok = _0_ok && all(_3_x == half4(2.0h, 8.0h, 16.0h, 4.0h)); 87 _3_x += 2.0h; 88 _3_x *= 2.0h; 89 _3_x -= 4.0h; 90 _3_x *= 0.5h; 91 _0_ok = _0_ok && all(_3_x == half4(2.0h, 8.0h, 16.0h, 4.0h)); 92 _3_x = _3_x + 2.0h; 93 _3_x = _3_x * 2.0h; 94 _3_x = _3_x - 4.0h; 95 _3_x = _3_x * 0.5h; 96 _0_ok = _0_ok && all(_3_x == half4(2.0h, 8.0h, 16.0h, 4.0h)); 97 _out.sk_FragColor = _0_ok && test_int_b(_uniforms) ? _uniforms.colorGreen : _uniforms.colorRed; 98 return _out; 99} 100