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}; 9struct Outputs { 10 float4 sk_Position [[position]]; 11 float2 vcoord_Stage0 [[user(locn1) center_no_perspective]]; 12 float sk_PointSize [[point_size]]; 13}; 14vertex Outputs vertexMain(Inputs _in [[stage_in]], uint sk_VertexID [[vertex_id]], uint sk_InstanceID [[instance_id]]) { 15 Outputs _out; 16 (void)_out; 17 int x = sk_InstanceID % 200; 18 int y = sk_InstanceID / 200; 19 int ileft = (sk_InstanceID * 929) % 17; 20 int iright = (ileft + 1) + (sk_InstanceID * 1637) % (17 - ileft); 21 int itop = (sk_InstanceID * 313) % 17; 22 int ibot = (itop + 1) + (sk_InstanceID * 1901) % (17 - itop); 23 float outset = 0.03125; 24 outset = 0 == (x + y) % 2 ? -outset : outset; 25 float l = float(ileft) * 0.0625 - outset; 26 float r = float(iright) * 0.0625 + outset; 27 float t = float(itop) * 0.0625 - outset; 28 float b = float(ibot) * 0.0625 + outset; 29 float2 vertexpos; 30 vertexpos.x = float(x) + (0 == sk_VertexID % 2 ? l : r); 31 vertexpos.y = float(y) + (0 == sk_VertexID / 2 ? t : b); 32 _out.vcoord_Stage0.x = float(0 == sk_VertexID % 2 ? -1 : 1); 33 _out.vcoord_Stage0.y = float(0 == sk_VertexID / 2 ? -1 : 1); 34 _out.sk_Position = float4(vertexpos.x, vertexpos.y, 0.0, 1.0); 35 return _out; 36} 37