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