• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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};
13float _skOutParamHelper0_modf(float _var0, thread float4& whole) {
14    float _var1;
15    float _skResult = modf(_var0, _var1);
16    whole.x = _var1;
17    return _skResult;
18}
19float2 _skOutParamHelper1_modf(float2 _var0, thread float4& whole) {
20    float2 _var1;
21    float2 _skResult = modf(_var0, _var1);
22    whole.xy = _var1;
23    return _skResult;
24}
25float3 _skOutParamHelper2_modf(float3 _var0, thread float4& whole) {
26    float3 _var1;
27    float3 _skResult = modf(_var0, _var1);
28    whole.xyz = _var1;
29    return _skResult;
30}
31float4 _skOutParamHelper3_modf(float4 _var0, thread float4& whole) {
32    float4 _var1;
33    float4 _skResult = modf(_var0, _var1);
34    whole = _var1;
35    return _skResult;
36}
37fragment Outputs fragmentMain(Inputs _in [[stage_in]], constant Uniforms& _uniforms [[buffer(0)]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) {
38    Outputs _out;
39    (void)_out;
40    float4 value = float4(2.5, -2.5, 8.0, -0.125);
41    const float4 expectedWhole = float4(2.0, -2.0, 8.0, 0.0);
42    const float4 expectedFraction = float4(0.5, -0.5, 0.0, -0.125);
43    bool4 ok = bool4(false);
44    float4 whole;
45    float4 fraction;
46    fraction.x =     _skOutParamHelper0_modf(value.x, whole);
47    ok.x = whole.x == 2.0 && fraction.x == 0.5;
48    fraction.xy =     _skOutParamHelper1_modf(value.xy, whole);
49    ok.y = all(whole.xy == float2(2.0, -2.0)) && all(fraction.xy == float2(0.5, -0.5));
50    fraction.xyz =     _skOutParamHelper2_modf(value.xyz, whole);
51    ok.z = all(whole.xyz == float3(2.0, -2.0, 8.0)) && all(fraction.xyz == float3(0.5, -0.5, 0.0));
52    fraction =     _skOutParamHelper3_modf(value, whole);
53    ok.w = all(whole == expectedWhole) && all(fraction == expectedFraction);
54    _out.sk_FragColor = all(ok) ? _uniforms.colorGreen : _uniforms.colorRed;
55    return _out;
56}
57