1#include <metal_stdlib> 2#include <simd/simd.h> 3using namespace metal; 4struct Uniforms { 5 float4x4 colorXform; 6}; 7struct Inputs { 8}; 9struct Outputs { 10 half4 sk_FragColor [[color(0)]]; 11}; 12struct Globals { 13 texture2d<half> s; 14 sampler sSmplr; 15}; 16 17thread bool operator==(const float4x4 left, const float4x4 right); 18thread bool operator!=(const float4x4 left, const float4x4 right); 19thread bool operator==(const float4x4 left, const float4x4 right) { 20 return all(left[0] == right[0]) && 21 all(left[1] == right[1]) && 22 all(left[2] == right[2]) && 23 all(left[3] == right[3]); 24} 25thread bool operator!=(const float4x4 left, const float4x4 right) { 26 return !(left == right); 27} 28fragment Outputs fragmentMain(Inputs _in [[stage_in]], constant Uniforms& _uniforms [[buffer(0)]], texture2d<half> s[[texture(0)]], sampler sSmplr[[sampler(0)]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) { 29 Globals _globals{s, sSmplr}; 30 (void)_globals; 31 Outputs _out; 32 (void)_out; 33 float4 tmpColor; 34 _out.sk_FragColor = (tmpColor = float4(_globals.s.sample(_globals.sSmplr, float2(1.0))) , half4(_uniforms.colorXform != float4x4(1.0) ? float4(clamp((_uniforms.colorXform * float4(tmpColor.xyz, 1.0)).xyz, 0.0, tmpColor.w), tmpColor.w) : tmpColor)); 35 return _out; 36} 37