1#include <metal_stdlib> 2#include <simd/simd.h> 3using namespace metal; 4struct Uniforms { 5 half4 colorGreen; 6 half4 colorRed; 7 half4 testInputs; 8}; 9struct Inputs { 10}; 11struct Outputs { 12 half4 sk_FragColor [[color(0)]]; 13}; 14 15thread bool operator==(const half2x2 left, const half2x2 right); 16thread bool operator!=(const half2x2 left, const half2x2 right); 17 18thread bool operator==(const float2x2 left, const float2x2 right); 19thread bool operator!=(const float2x2 left, const float2x2 right); 20thread bool operator==(const half2x2 left, const half2x2 right) { 21 return all(left[0] == right[0]) && 22 all(left[1] == right[1]); 23} 24thread bool operator!=(const half2x2 left, const half2x2 right) { 25 return !(left == right); 26} 27half2x2 half2x2_from_half4(half4 x0) { 28 return half2x2(half2(x0.xy), half2(x0.zw)); 29} 30thread bool operator==(const float2x2 left, const float2x2 right) { 31 return all(left[0] == right[0]) && 32 all(left[1] == right[1]); 33} 34thread bool operator!=(const float2x2 left, const float2x2 right) { 35 return !(left == right); 36} 37float2x2 float2x2_from_float4(float4 x0) { 38 return float2x2(float2(x0.xy), float2(x0.zw)); 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 bool ok = true; 44 ok = ok && half2x2_from_half4(_uniforms.testInputs) == half2x2(half2(-1.25h, 0.0h), half2(0.75h, 2.25h)); 45 ok = ok && float2x2_from_float4(float4(_uniforms.testInputs)) == float2x2(float2(-1.25, 0.0), float2(0.75, 2.25)); 46 ok = ok && half2x2_from_half4(_uniforms.colorGreen) == half2x2(half2(0.0h, 1.0h), half2(0.0h, 1.0h)); 47 ok = ok && half2x2_from_half4(_uniforms.colorGreen) == half2x2(half2(0.0h, 1.0h), half2(0.0h, 1.0h)); 48 ok = ok && half2x2_from_half4(half4(int4(_uniforms.colorGreen))) == half2x2(half2(0.0h, 1.0h), half2(0.0h, 1.0h)); 49 ok = ok && half2x2_from_half4(_uniforms.colorGreen) == half2x2(half2(0.0h, 1.0h), half2(0.0h, 1.0h)); 50 ok = ok && half2x2_from_half4(_uniforms.colorGreen) == half2x2(half2(0.0h, 1.0h), half2(0.0h, 1.0h)); 51 ok = ok && half2x2_from_half4(half4(bool4(_uniforms.colorGreen))) == half2x2(half2(0.0h, 1.0h), half2(0.0h, 1.0h)); 52 _out.sk_FragColor = ok ? _uniforms.colorGreen : _uniforms.colorRed; 53 return _out; 54} 55