1cb93a386Sopenharmony_ci#include <metal_stdlib> 2cb93a386Sopenharmony_ci#include <simd/simd.h> 3cb93a386Sopenharmony_ciusing namespace metal; 4cb93a386Sopenharmony_cistruct Uniforms { 5cb93a386Sopenharmony_ci half4 colorGreen; 6cb93a386Sopenharmony_ci half4 colorRed; 7cb93a386Sopenharmony_ci}; 8cb93a386Sopenharmony_cistruct Inputs { 9cb93a386Sopenharmony_ci}; 10cb93a386Sopenharmony_cistruct Outputs { 11cb93a386Sopenharmony_ci half4 sk_FragColor [[color(0)]]; 12cb93a386Sopenharmony_ci}; 13cb93a386Sopenharmony_cifloat2x2 float2x2_from_float3x3(float3x3 x0) { 14cb93a386Sopenharmony_ci return float2x2(float2(x0[0].xy), float2(x0[1].xy)); 15cb93a386Sopenharmony_ci} 16cb93a386Sopenharmony_cifloat2x2 float2x2_from_float4x4(float4x4 x0) { 17cb93a386Sopenharmony_ci return float2x2(float2(x0[0].xy), float2(x0[1].xy)); 18cb93a386Sopenharmony_ci} 19cb93a386Sopenharmony_cifloat3x3 float3x3_from_float4x4(float4x4 x0) { 20cb93a386Sopenharmony_ci return float3x3(float3(x0[0].xyz), float3(x0[1].xyz), float3(x0[2].xyz)); 21cb93a386Sopenharmony_ci} 22cb93a386Sopenharmony_cifloat3x3 float3x3_from_float2x2(float2x2 x0) { 23cb93a386Sopenharmony_ci return float3x3(float3(x0[0].xy, 0.0), float3(x0[1].xy, 0.0), float3(0.0, 0.0, 1.0)); 24cb93a386Sopenharmony_ci} 25cb93a386Sopenharmony_cifloat4x4 float4x4_from_float3x3(float3x3 x0) { 26cb93a386Sopenharmony_ci return float4x4(float4(x0[0].xyz, 0.0), float4(x0[1].xyz, 0.0), float4(x0[2].xyz, 0.0), float4(0.0, 0.0, 0.0, 1.0)); 27cb93a386Sopenharmony_ci} 28cb93a386Sopenharmony_cifragment Outputs fragmentMain(Inputs _in [[stage_in]], constant Uniforms& _uniforms [[buffer(0)]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) { 29cb93a386Sopenharmony_ci Outputs _out; 30cb93a386Sopenharmony_ci (void)_out; 31cb93a386Sopenharmony_ci float result = 0.0; 32cb93a386Sopenharmony_ci float2x2 a = float2x2_from_float3x3(float3x3(1.0)); 33cb93a386Sopenharmony_ci result += a[0].x; 34cb93a386Sopenharmony_ci float2x2 b = float2x2_from_float4x4(float4x4(1.0)); 35cb93a386Sopenharmony_ci result += b[0].x; 36cb93a386Sopenharmony_ci float3x3 c = float3x3_from_float4x4(float4x4(1.0)); 37cb93a386Sopenharmony_ci result += c[0].x; 38cb93a386Sopenharmony_ci float3x3 d = float3x3_from_float2x2(float2x2(1.0)); 39cb93a386Sopenharmony_ci result += d[0].x; 40cb93a386Sopenharmony_ci float4x4 e = float4x4_from_float3x3(float3x3_from_float2x2(float2x2(1.0))); 41cb93a386Sopenharmony_ci result += e[0].x; 42cb93a386Sopenharmony_ci float2x2 f = float2x2_from_float3x3(float3x3_from_float4x4(float4x4(1.0))); 43cb93a386Sopenharmony_ci result += f[0].x; 44cb93a386Sopenharmony_ci _out.sk_FragColor = result == 6.0 ? _uniforms.colorGreen : _uniforms.colorRed; 45cb93a386Sopenharmony_ci return _out; 46cb93a386Sopenharmony_ci} 47