• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#include <metal_stdlib>
2#include <simd/simd.h>
3using namespace metal;
4struct Uniforms {
5    float4 testInputs;
6    float4 colorGreen;
7    float4 colorRed;
8};
9struct Inputs {
10};
11struct Outputs {
12    float4 sk_FragColor [[color(0)]];
13};
14
15fragment Outputs fragmentMain(Inputs _in [[stage_in]], constant Uniforms& _uniforms [[buffer(0)]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) {
16    Outputs _out;
17    (void)_out;
18    int4 expectedA = int4(-100, 0, 75, 100);
19    int4 intValues = int4(_uniforms.testInputs * 100.0);
20    int4 clampLow = int4(-100, -200, -200, 100);
21    int4 expectedB = int4(-100, 0, 50, 225);
22    int4 clampHigh = int4(100, 200, 50, 300);
23    _out.sk_FragColor = ((((((clamp(intValues.x, -100, 100) == expectedA.x && all(clamp(intValues.xy, -100, 100) == expectedA.xy)) && all(clamp(intValues.xyz, -100, 100) == expectedA.xyz)) && all(clamp(intValues, -100, 100) == expectedA)) && clamp(intValues.x, clampLow.x, clampHigh.x) == expectedB.x) && all(clamp(intValues.xy, clampLow.xy, clampHigh.xy) == expectedB.xy)) && all(clamp(intValues.xyz, clampLow.xyz, clampHigh.xyz) == expectedB.xyz)) && all(clamp(intValues, clampLow, clampHigh) == expectedB) ? _uniforms.colorGreen : _uniforms.colorRed;
24    return _out;
25}
26