1cb93a386Sopenharmony_ci#include <metal_stdlib>
2cb93a386Sopenharmony_ci#include <simd/simd.h>
3cb93a386Sopenharmony_ciusing namespace metal;
4cb93a386Sopenharmony_cistruct Inputs {
5cb93a386Sopenharmony_ci};
6cb93a386Sopenharmony_cistruct Outputs {
7cb93a386Sopenharmony_ci    float4 sk_Position [[position]];
8cb93a386Sopenharmony_ci    float2 vcoord_Stage0 [[user(locn1)]];
9cb93a386Sopenharmony_ci    float sk_PointSize [[point_size]];
10cb93a386Sopenharmony_ci};
11cb93a386Sopenharmony_civertex Outputs vertexMain(Inputs _in [[stage_in]], uint sk_VertexID [[vertex_id]], uint sk_InstanceID [[instance_id]]) {
12cb93a386Sopenharmony_ci    Outputs _out;
13cb93a386Sopenharmony_ci    (void)_out;
14cb93a386Sopenharmony_ci    int x = sk_InstanceID % 200;
15cb93a386Sopenharmony_ci    int y = sk_InstanceID / 200;
16cb93a386Sopenharmony_ci    int ileft = (sk_InstanceID * 929) % 17;
17cb93a386Sopenharmony_ci    int iright = (ileft + 1) + (sk_InstanceID * 1637) % (17 - ileft);
18cb93a386Sopenharmony_ci    int itop = (sk_InstanceID * 313) % 17;
19cb93a386Sopenharmony_ci    int ibot = (itop + 1) + (sk_InstanceID * 1901) % (17 - itop);
20cb93a386Sopenharmony_ci    float outset = 0.03125;
21cb93a386Sopenharmony_ci    outset = 0 == (x + y) % 2 ? -outset : outset;
22cb93a386Sopenharmony_ci    float l = float(ileft) / 16.0 - outset;
23cb93a386Sopenharmony_ci    float r = float(iright) / 16.0 + outset;
24cb93a386Sopenharmony_ci    float t = float(itop) / 16.0 - outset;
25cb93a386Sopenharmony_ci    float b = float(ibot) / 16.0 + outset;
26cb93a386Sopenharmony_ci    float2 vertexpos;
27cb93a386Sopenharmony_ci    vertexpos.x = float(x) + (0 == sk_VertexID % 2 ? l : r);
28cb93a386Sopenharmony_ci    vertexpos.y = float(y) + (0 == sk_VertexID / 2 ? t : b);
29cb93a386Sopenharmony_ci    _out.vcoord_Stage0.x = float(0 == sk_VertexID % 2 ? -1 : 1);
30cb93a386Sopenharmony_ci    _out.vcoord_Stage0.y = float(0 == sk_VertexID / 2 ? -1 : 1);
31cb93a386Sopenharmony_ci    _out.sk_Position = float4(vertexpos.x, vertexpos.y, 0.0, 1.0);
32cb93a386Sopenharmony_ci    return _out;
33cb93a386Sopenharmony_ci}
34