1#include <metal_stdlib> 2#include <simd/simd.h> 3using namespace metal; 4struct Uniforms { 5 half4 colorGreen; 6 half4 colorRed; 7}; 8struct Inputs { 9}; 10struct Outputs { 11 half4 sk_FragColor [[color(0)]]; 12}; 13 14thread bool operator==(const half2x3 left, const half2x3 right); 15thread bool operator!=(const half2x3 left, const half2x3 right); 16 17thread bool operator==(const half2x4 left, const half2x4 right); 18thread bool operator!=(const half2x4 left, const half2x4 right); 19 20thread bool operator==(const half3x2 left, const half3x2 right); 21thread bool operator!=(const half3x2 left, const half3x2 right); 22 23thread bool operator==(const half3x4 left, const half3x4 right); 24thread bool operator!=(const half3x4 left, const half3x4 right); 25 26thread bool operator==(const half4x2 left, const half4x2 right); 27thread bool operator!=(const half4x2 left, const half4x2 right); 28 29thread bool operator==(const half4x3 left, const half4x3 right); 30thread bool operator!=(const half4x3 left, const half4x3 right); 31 32thread bool operator==(const half2x2 left, const half2x2 right); 33thread bool operator!=(const half2x2 left, const half2x2 right); 34 35thread bool operator==(const half3x3 left, const half3x3 right); 36thread bool operator!=(const half3x3 left, const half3x3 right); 37 38thread bool operator==(const float2x3 left, const float2x3 right); 39thread bool operator!=(const float2x3 left, const float2x3 right); 40 41thread bool operator==(const float2x4 left, const float2x4 right); 42thread bool operator!=(const float2x4 left, const float2x4 right); 43 44thread bool operator==(const float3x2 left, const float3x2 right); 45thread bool operator!=(const float3x2 left, const float3x2 right); 46 47thread bool operator==(const float2x2 left, const float2x2 right); 48thread bool operator!=(const float2x2 left, const float2x2 right); 49thread bool operator==(const half2x3 left, const half2x3 right) { 50 return all(left[0] == right[0]) && 51 all(left[1] == right[1]); 52} 53thread bool operator!=(const half2x3 left, const half2x3 right) { 54 return !(left == right); 55} 56thread bool operator==(const half2x4 left, const half2x4 right) { 57 return all(left[0] == right[0]) && 58 all(left[1] == right[1]); 59} 60thread bool operator!=(const half2x4 left, const half2x4 right) { 61 return !(left == right); 62} 63thread bool operator==(const half3x2 left, const half3x2 right) { 64 return all(left[0] == right[0]) && 65 all(left[1] == right[1]) && 66 all(left[2] == right[2]); 67} 68thread bool operator!=(const half3x2 left, const half3x2 right) { 69 return !(left == right); 70} 71thread bool operator==(const half3x4 left, const half3x4 right) { 72 return all(left[0] == right[0]) && 73 all(left[1] == right[1]) && 74 all(left[2] == right[2]); 75} 76thread bool operator!=(const half3x4 left, const half3x4 right) { 77 return !(left == right); 78} 79thread bool operator==(const half4x2 left, const half4x2 right) { 80 return all(left[0] == right[0]) && 81 all(left[1] == right[1]) && 82 all(left[2] == right[2]) && 83 all(left[3] == right[3]); 84} 85thread bool operator!=(const half4x2 left, const half4x2 right) { 86 return !(left == right); 87} 88thread bool operator==(const half4x3 left, const half4x3 right) { 89 return all(left[0] == right[0]) && 90 all(left[1] == right[1]) && 91 all(left[2] == right[2]) && 92 all(left[3] == right[3]); 93} 94thread bool operator!=(const half4x3 left, const half4x3 right) { 95 return !(left == right); 96} 97thread bool operator==(const half2x2 left, const half2x2 right) { 98 return all(left[0] == right[0]) && 99 all(left[1] == right[1]); 100} 101thread bool operator!=(const half2x2 left, const half2x2 right) { 102 return !(left == right); 103} 104thread bool operator==(const half3x3 left, const half3x3 right) { 105 return all(left[0] == right[0]) && 106 all(left[1] == right[1]) && 107 all(left[2] == right[2]); 108} 109thread bool operator!=(const half3x3 left, const half3x3 right) { 110 return !(left == right); 111} 112thread bool operator==(const float2x3 left, const float2x3 right) { 113 return all(left[0] == right[0]) && 114 all(left[1] == right[1]); 115} 116thread bool operator!=(const float2x3 left, const float2x3 right) { 117 return !(left == right); 118} 119thread bool operator==(const float2x4 left, const float2x4 right) { 120 return all(left[0] == right[0]) && 121 all(left[1] == right[1]); 122} 123thread bool operator!=(const float2x4 left, const float2x4 right) { 124 return !(left == right); 125} 126thread bool operator==(const float3x2 left, const float3x2 right) { 127 return all(left[0] == right[0]) && 128 all(left[1] == right[1]) && 129 all(left[2] == right[2]); 130} 131thread bool operator!=(const float3x2 left, const float3x2 right) { 132 return !(left == right); 133} 134thread bool operator==(const float2x2 left, const float2x2 right) { 135 return all(left[0] == right[0]) && 136 all(left[1] == right[1]); 137} 138thread bool operator!=(const float2x2 left, const float2x2 right) { 139 return !(left == right); 140} 141bool test_half_b() { 142 bool ok = true; 143 half2x3 m23 = half2x3(2.0h); 144 ok = ok && m23 == half2x3(half3(2.0h, 0.0h, 0.0h), half3(0.0h, 2.0h, 0.0h)); 145 half2x4 m24 = half2x4(3.0h); 146 ok = ok && m24 == half2x4(half4(3.0h, 0.0h, 0.0h, 0.0h), half4(0.0h, 3.0h, 0.0h, 0.0h)); 147 half3x2 m32 = half3x2(4.0h); 148 ok = ok && m32 == half3x2(half2(4.0h, 0.0h), half2(0.0h, 4.0h), half2(0.0h, 0.0h)); 149 half3x4 m34 = half3x4(5.0h); 150 ok = ok && m34 == half3x4(half4(5.0h, 0.0h, 0.0h, 0.0h), half4(0.0h, 5.0h, 0.0h, 0.0h), half4(0.0h, 0.0h, 5.0h, 0.0h)); 151 half4x2 m42 = half4x2(6.0h); 152 ok = ok && m42 == half4x2(half2(6.0h, 0.0h), half2(0.0h, 6.0h), half2(0.0h, 0.0h), half2(0.0h, 0.0h)); 153 half4x3 m43 = half4x3(7.0h); 154 ok = ok && m43 == half4x3(half3(7.0h, 0.0h, 0.0h), half3(0.0h, 7.0h, 0.0h), half3(0.0h, 0.0h, 7.0h), half3(0.0h, 0.0h, 0.0h)); 155 half2x2 m22 = m32 * m23; 156 ok = ok && m22 == half2x2(8.0h); 157 half3x3 m33 = m43 * m34; 158 ok = ok && m33 == half3x3(35.0h); 159 m23 += (half2x3(1.0, 1.0, 1.0, 1.0, 1.0, 1.0) * 1.0h); 160 ok = ok && m23 == half2x3(half3(3.0h, 1.0h, 1.0h), half3(1.0h, 3.0h, 1.0h)); 161 m32 -= (half3x2(1.0, 1.0, 1.0, 1.0, 1.0, 1.0) * 2.0h); 162 ok = ok && m32 == half3x2(half2(2.0h, -2.0h), half2(-2.0h, 2.0h), half2(-2.0h, -2.0h)); 163 m24 *= 0.25h; 164 ok = ok && m24 == half2x4(half4(0.75h, 0.0h, 0.0h, 0.0h), half4(0.0h, 0.75h, 0.0h, 0.0h)); 165 return ok; 166} 167fragment Outputs fragmentMain(Inputs _in [[stage_in]], constant Uniforms& _uniforms [[buffer(0)]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) { 168 Outputs _out; 169 (void)_out; 170 bool _0_ok = true; 171 float2x3 _1_m23 = float2x3(2.0); 172 _0_ok = _0_ok && _1_m23 == float2x3(float3(2.0, 0.0, 0.0), float3(0.0, 2.0, 0.0)); 173 float2x4 _2_m24 = float2x4(3.0); 174 _0_ok = _0_ok && _2_m24 == float2x4(float4(3.0, 0.0, 0.0, 0.0), float4(0.0, 3.0, 0.0, 0.0)); 175 float3x2 _3_m32 = float3x2(4.0); 176 _0_ok = _0_ok && _3_m32 == float3x2(float2(4.0, 0.0), float2(0.0, 4.0), float2(0.0, 0.0)); 177 float2x2 _7_m22 = _3_m32 * _1_m23; 178 _0_ok = _0_ok && _7_m22 == float2x2(8.0); 179 _1_m23 += (float2x3(1.0, 1.0, 1.0, 1.0, 1.0, 1.0) * 1.0); 180 _0_ok = _0_ok && _1_m23 == float2x3(float3(3.0, 1.0, 1.0), float3(1.0, 3.0, 1.0)); 181 _3_m32 -= (float3x2(1.0, 1.0, 1.0, 1.0, 1.0, 1.0) * 2.0); 182 _0_ok = _0_ok && _3_m32 == float3x2(float2(2.0, -2.0), float2(-2.0, 2.0), float2(-2.0, -2.0)); 183 _2_m24 *= 0.25; 184 _0_ok = _0_ok && _2_m24 == float2x4(float4(0.75, 0.0, 0.0, 0.0), float4(0.0, 0.75, 0.0, 0.0)); 185 _out.sk_FragColor = _0_ok && test_half_b() ? _uniforms.colorGreen : _uniforms.colorRed; 186 return _out; 187} 188