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