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_write> tex; 9}; 10kernel void computeMain(uint3 sk_GlobalInvocationID [[thread_position_in_grid]], texture2d<half, access::read_write> tex [[texture(0)]]) { 11 Globals _globals{tex}; 12 (void)_globals; 13 Inputs _in = { sk_GlobalInvocationID }; 14 if (_in.sk_GlobalInvocationID.x < _globals.tex.get_width() && _in.sk_GlobalInvocationID.y < _globals.tex.get_height()) { 15 half4 _0_color = _globals.tex.read(_in.sk_GlobalInvocationID.xy); 16 _0_color.xyz = half3(dot(_0_color.xyz, half3(0.22h, 0.67h, 0.11h))); 17 _globals.tex.write(_0_color, _in.sk_GlobalInvocationID.xy); 18 } 19 return; 20} 21