1#include <metal_stdlib> 2#include <simd/simd.h> 3using namespace metal; 4struct Inputs { 5 uint3 sk_GlobalInvocationID; 6}; 7struct Globals { 8 texture2d<half, access::read> src; 9 texture2d<half, access::write> dest; 10}; 11void desaturate_vTT(Inputs _in, texture2d<half, access::read> src, texture2d<half, access::write> dest) { 12 half4 color = src.read(_in.sk_GlobalInvocationID.xy); 13 color.xyz = half3(dot(color.xyz, half3(0.22h, 0.67h, 0.11h))); 14 dest.write(color, _in.sk_GlobalInvocationID.xy); 15} 16kernel void computeMain(uint3 sk_GlobalInvocationID [[thread_position_in_grid]], texture2d<half, access::read> src [[texture(0)]], texture2d<half, access::write> dest [[texture(1)]]) { 17 Globals _globals{src, dest}; 18 (void)_globals; 19 Inputs _in = { sk_GlobalInvocationID }; 20 if (_in.sk_GlobalInvocationID.x < _globals.src.get_width() && _in.sk_GlobalInvocationID.y < _globals.src.get_height()) { 21 desaturate_vTT(_in, _globals.src, _globals.dest); 22 } 23 return; 24} 25