• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 colorGreen;
9    half4 colorRed;
10    float3x3 testMatrix3x3;
11    float4x4 testMatrix4x4;
12};
13struct Inputs {
14};
15struct Outputs {
16    half4 sk_FragColor [[color(0)]];
17};
18thread bool operator==(const float3x3 left, const float3x3 right);thread bool operator!=(const float3x3 left, const float3x3 right);thread bool operator==(const float4x4 left, const float4x4 right);thread bool operator!=(const float4x4 left, const float4x4 right);thread bool operator==(const float3x3 left, const float3x3 right) {return all(left[0] == right[0]) && all(left[1] == right[1]) && all(left[2] == right[2]);}thread bool operator!=(const float3x3 left, const float3x3 right) {return !(left == right);}thread bool operator==(const float4x4 left, const float4x4 right) {return all(left[0] == right[0]) && all(left[1] == right[1]) && all(left[2] == right[2]) && all(left[3] == right[3]);}thread bool operator!=(const float4x4 left, const float4x4 right) {return !(left == right);}bool test3x3_b(Uniforms _uniforms) {
19    float3x3 matrix;
20    float3 values = float3(1.0, 2.0, 3.0);
21    for (int index = 0;index < 3; ++index) {
22        matrix[index] = values;
23        values += 3.0;
24    }
25    return matrix == _uniforms.testMatrix3x3;
26}
27bool test4x4_b(Uniforms _uniforms) {
28    float4x4 matrix;
29    float4 values = float4(1.0, 2.0, 3.0, 4.0);
30    for (int index = 0;index < 4; ++index) {
31        matrix[index] = values;
32        values += 4.0;
33    }
34    return matrix == _uniforms.testMatrix4x4;
35}
36fragment Outputs fragmentMain(Inputs _in [[stage_in]], constant Uniforms& _uniforms [[buffer(0)]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) {
37    Outputs _out;
38    (void)_out;
39    _out.sk_FragColor = test3x3_b(_uniforms) && test4x4_b(_uniforms) ? _uniforms.colorGreen : _uniforms.colorRed;
40    return _out;
41}
42