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}; 18bool test3x3_b(Uniforms _uniforms) { 19 float3 expected = float3(3.0, 2.0, 1.0); 20 float3 vec; 21 for (int c = 0;c < 3; ++c) { 22 for (int r = 0;r < 3; ++r) { 23 vec[uint3(2, 1, 0)[r]] = _uniforms.testMatrix3x3[c][r]; 24 } 25 if (any(vec != expected)) { 26 return false; 27 } 28 expected += 3.0; 29 } 30 return true; 31} 32bool test4x4_b(Uniforms _uniforms) { 33 float4 expected = float4(4.0, 3.0, 2.0, 1.0); 34 float4 vec; 35 for (int c = 0;c < 4; ++c) { 36 for (int r = 0;r < 4; ++r) { 37 vec[uint4(3, 2, 1, 0)[r]] = _uniforms.testMatrix4x4[c][r]; 38 } 39 if (any(vec != expected)) { 40 return false; 41 } 42 expected += 4.0; 43 } 44 return true; 45} 46fragment Outputs fragmentMain(Inputs _in [[stage_in]], constant Uniforms& _uniforms [[buffer(0)]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) { 47 Outputs _out; 48 (void)_out; 49 _out.sk_FragColor = test3x3_b(_uniforms) && test4x4_b(_uniforms) ? _uniforms.colorGreen : _uniforms.colorRed; 50 return _out; 51} 52