• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#version 460
2
3#define MAX_VER  81
4#define MAX_PRIM 32
5
6#define BARRIER() \
7    memoryBarrierShared(); \
8    barrier();
9
10#extension GL_EXT_mesh_shader : enable
11
12layout(local_size_x = 32, local_size_y = 1, local_size_z = 1) in;
13
14layout(max_vertices=MAX_VER) out;
15layout(max_primitives=MAX_PRIM) out;
16layout(points) out;
17
18// test use of redeclared single-view builtins in mesh shaders:
19
20out gl_MeshPerVertexEXT {
21    vec4 gl_Position;
22    float gl_PointSize;
23    float gl_ClipDistance[4];
24    float gl_CullDistance[4];
25} gl_MeshVerticesEXT[MAX_VER];                   // explicitly sized to MAX_VER
26
27perprimitiveEXT out gl_MeshPerPrimitiveEXT {
28    int gl_PrimitiveID;
29    int gl_Layer;
30    int gl_ViewportIndex;
31    bool gl_CullPrimitiveEXT;
32    int  gl_PrimitiveShadingRateEXT;
33} gl_MeshPrimitivesEXT[];                        // implicitly sized to MAX_PRIM
34
35out uint gl_PrimitivePointIndicesEXT[MAX_PRIM];     // explicitly sized to MAX_PRIM
36
37void main()
38{
39    uint iid = gl_LocalInvocationID.x;
40    uint gid = gl_WorkGroupID.x;
41
42    SetMeshOutputsEXT(MAX_VER, MAX_PRIM);
43
44    gl_MeshVerticesEXT[iid].gl_Position = vec4(1.0);
45    gl_MeshVerticesEXT[iid].gl_PointSize = 2.0;
46    gl_MeshVerticesEXT[iid].gl_ClipDistance[3] = 3.0;
47    gl_MeshVerticesEXT[iid].gl_CullDistance[2] = 4.0;
48
49    BARRIER();
50
51    gl_MeshVerticesEXT[iid+1].gl_Position = gl_MeshVerticesEXT[iid].gl_Position;
52    gl_MeshVerticesEXT[iid+1].gl_PointSize = gl_MeshVerticesEXT[iid].gl_PointSize;
53    gl_MeshVerticesEXT[iid+1].gl_ClipDistance[3] = gl_MeshVerticesEXT[iid].gl_ClipDistance[3];
54    gl_MeshVerticesEXT[iid+1].gl_CullDistance[2] = gl_MeshVerticesEXT[iid].gl_CullDistance[2];
55
56    BARRIER();
57
58    gl_MeshPrimitivesEXT[iid].gl_PrimitiveID = 6;
59    gl_MeshPrimitivesEXT[iid].gl_Layer = 7;
60    gl_MeshPrimitivesEXT[iid].gl_ViewportIndex = 8;
61    gl_MeshPrimitivesEXT[iid].gl_CullPrimitiveEXT = false;
62
63    BARRIER();
64
65    gl_MeshPrimitivesEXT[iid+1].gl_PrimitiveID = gl_MeshPrimitivesEXT[iid].gl_PrimitiveID;
66    gl_MeshPrimitivesEXT[iid+1].gl_Layer = gl_MeshPrimitivesEXT[iid].gl_Layer;
67    gl_MeshPrimitivesEXT[iid+1].gl_ViewportIndex = gl_MeshPrimitivesEXT[iid].gl_ViewportIndex;
68    gl_MeshPrimitivesEXT[iid+1].gl_CullPrimitiveEXT = gl_MeshPrimitivesEXT[iid].gl_CullPrimitiveEXT;
69
70    BARRIER();
71
72    // check bound limits
73    gl_PrimitivePointIndicesEXT[0] = 1;
74    gl_PrimitivePointIndicesEXT[MAX_PRIM - 1] = 2;
75}
76