1cb93a386Sopenharmony_ci#include <metal_stdlib> 2cb93a386Sopenharmony_ci#include <simd/simd.h> 3cb93a386Sopenharmony_ciusing namespace metal; 4cb93a386Sopenharmony_cistruct Uniforms { 5cb93a386Sopenharmony_ci half4 colorGreen; 6cb93a386Sopenharmony_ci half4 colorRed; 7cb93a386Sopenharmony_ci}; 8cb93a386Sopenharmony_cistruct Inputs { 9cb93a386Sopenharmony_ci}; 10cb93a386Sopenharmony_cistruct Outputs { 11cb93a386Sopenharmony_ci half4 sk_FragColor [[color(0)]]; 12cb93a386Sopenharmony_ci}; 13cb93a386Sopenharmony_cifloat _skOutParamHelper0_modf(float _var0, thread float4& whole) { 14cb93a386Sopenharmony_ci float _var1; 15cb93a386Sopenharmony_ci float _skResult = modf(_var0, _var1); 16cb93a386Sopenharmony_ci whole.x = _var1; 17cb93a386Sopenharmony_ci return _skResult; 18cb93a386Sopenharmony_ci} 19cb93a386Sopenharmony_cifloat2 _skOutParamHelper1_modf(float2 _var0, thread float4& whole) { 20cb93a386Sopenharmony_ci float2 _var1; 21cb93a386Sopenharmony_ci float2 _skResult = modf(_var0, _var1); 22cb93a386Sopenharmony_ci whole.xy = _var1; 23cb93a386Sopenharmony_ci return _skResult; 24cb93a386Sopenharmony_ci} 25cb93a386Sopenharmony_cifloat3 _skOutParamHelper2_modf(float3 _var0, thread float4& whole) { 26cb93a386Sopenharmony_ci float3 _var1; 27cb93a386Sopenharmony_ci float3 _skResult = modf(_var0, _var1); 28cb93a386Sopenharmony_ci whole.xyz = _var1; 29cb93a386Sopenharmony_ci return _skResult; 30cb93a386Sopenharmony_ci} 31cb93a386Sopenharmony_cifloat4 _skOutParamHelper3_modf(float4 _var0, thread float4& whole) { 32cb93a386Sopenharmony_ci float4 _var1; 33cb93a386Sopenharmony_ci float4 _skResult = modf(_var0, _var1); 34cb93a386Sopenharmony_ci whole = _var1; 35cb93a386Sopenharmony_ci return _skResult; 36cb93a386Sopenharmony_ci} 37cb93a386Sopenharmony_cifragment Outputs fragmentMain(Inputs _in [[stage_in]], constant Uniforms& _uniforms [[buffer(0)]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) { 38cb93a386Sopenharmony_ci Outputs _out; 39cb93a386Sopenharmony_ci (void)_out; 40cb93a386Sopenharmony_ci float4 value = float4(2.5, -2.5, 8.0, -0.125); 41cb93a386Sopenharmony_ci const float4 expectedWhole = float4(2.0, -2.0, 8.0, 0.0); 42cb93a386Sopenharmony_ci const float4 expectedFraction = float4(0.5, -0.5, 0.0, -0.125); 43cb93a386Sopenharmony_ci bool4 ok = bool4(false); 44cb93a386Sopenharmony_ci float4 whole; 45cb93a386Sopenharmony_ci float4 fraction; 46cb93a386Sopenharmony_ci fraction.x = _skOutParamHelper0_modf(value.x, whole); 47cb93a386Sopenharmony_ci ok.x = whole.x == 2.0 && fraction.x == 0.5; 48cb93a386Sopenharmony_ci fraction.xy = _skOutParamHelper1_modf(value.xy, whole); 49cb93a386Sopenharmony_ci ok.y = all(whole.xy == float2(2.0, -2.0)) && all(fraction.xy == float2(0.5, -0.5)); 50cb93a386Sopenharmony_ci fraction.xyz = _skOutParamHelper2_modf(value.xyz, whole); 51cb93a386Sopenharmony_ci ok.z = all(whole.xyz == float3(2.0, -2.0, 8.0)) && all(fraction.xyz == float3(0.5, -0.5, 0.0)); 52cb93a386Sopenharmony_ci fraction = _skOutParamHelper3_modf(value, whole); 53cb93a386Sopenharmony_ci ok.w = all(whole == expectedWhole) && all(fraction == expectedFraction); 54cb93a386Sopenharmony_ci _out.sk_FragColor = all(ok) ? _uniforms.colorGreen : _uniforms.colorRed; 55cb93a386Sopenharmony_ci return _out; 56cb93a386Sopenharmony_ci} 57