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 testInputs; 9 half4 colorGreen; 10 half4 colorRed; 11}; 12struct Inputs { 13}; 14struct Outputs { 15 half4 sk_FragColor [[color(0)]]; 16}; 17fragment Outputs fragmentMain(Inputs _in [[stage_in]], constant Uniforms& _uniforms [[buffer(0)]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) { 18 Outputs _out; 19 (void)_out; 20 uint4 uintValues = uint4(_uniforms.testInputs * 100.0h + 200.0h); 21 uint4 expectedA = uint4(100u, 200u, 275u, 300u); 22 const uint4 clampLow = uint4(100u, 0u, 0u, 300u); 23 uint4 expectedB = uint4(100u, 200u, 250u, 425u); 24 const uint4 clampHigh = uint4(300u, 400u, 250u, 500u); 25 _out.sk_FragColor = ((((((((((((((clamp(uintValues.x, 100u, 300u) == expectedA.x && all(clamp(uintValues.xy, 100u, 300u) == expectedA.xy)) && all(clamp(uintValues.xyz, 100u, 300u) == expectedA.xyz)) && all(clamp(uintValues, 100u, 300u) == expectedA)) && 100u == expectedA.x) && all(uint2(100u, 200u) == expectedA.xy)) && all(uint3(100u, 200u, 275u) == expectedA.xyz)) && all(uint4(100u, 200u, 275u, 300u) == expectedA)) && clamp(uintValues.x, 100u, 300u) == expectedB.x) && all(clamp(uintValues.xy, uint2(100u, 0u), uint2(300u, 400u)) == expectedB.xy)) && all(clamp(uintValues.xyz, uint3(100u, 0u, 0u), uint3(300u, 400u, 250u)) == expectedB.xyz)) && all(clamp(uintValues, clampLow, clampHigh) == expectedB)) && 100u == expectedB.x) && all(uint2(100u, 200u) == expectedB.xy)) && all(uint3(100u, 200u, 250u) == expectedB.xyz)) && all(uint4(100u, 200u, 250u, 425u) == expectedB) ? _uniforms.colorGreen : _uniforms.colorRed; 26 return _out; 27} 28