• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#include <metal_stdlib>
2#include <simd/simd.h>
3using namespace metal;
4struct Uniforms {
5    float4 testMatrix2x2;
6    half4 colorGreen;
7    half4 colorRed;
8};
9struct Inputs {
10};
11struct Outputs {
12    half4 sk_FragColor [[color(0)]];
13};
14fragment Outputs fragmentMain(Inputs _in [[stage_in]], constant Uniforms& _uniforms [[buffer(0)]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) {
15    Outputs _out;
16    (void)_out;
17    float4 inputVal = _uniforms.testMatrix2x2 + float4(2.0, -2.0, 1.0, 8.0);
18    float4 expected = float4(3.0, 3.0, 5.0, 13.0);
19    const float allowedDelta = 0.05;
20    _out.sk_FragColor = ((((((abs(abs(inputVal.x) - expected.x) < allowedDelta && abs(length(inputVal.xy) - expected.y) < allowedDelta) && abs(length(inputVal.xyz) - expected.z) < allowedDelta) && abs(length(inputVal) - expected.w) < allowedDelta) && abs(3.0 - expected.x) < allowedDelta) && abs(3.0 - expected.y) < allowedDelta) && abs(5.0 - expected.z) < allowedDelta) && abs(13.0 - expected.w) < allowedDelta ? _uniforms.colorGreen : _uniforms.colorRed;
21    return _out;
22}
23