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