• 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_NV_mesh_shader : enable
11
12layout(local_size_x = 32) in;
13
14layout(max_vertices=MAX_VER) out;
15layout(max_primitives=MAX_PRIM) out;
16layout(triangles) out;
17
18// test use of redeclared single-view builtins in mesh shaders:
19
20out gl_MeshPerVertexNV {
21    vec4 gl_Position;
22    float gl_PointSize;
23    float gl_ClipDistance[4];
24    float gl_CullDistance[4];
25} gl_MeshVerticesNV[];
26
27perprimitiveNV out gl_MeshPerPrimitiveNV {
28    int gl_PrimitiveID;
29    int gl_Layer;
30    int gl_ViewportIndex;
31    int gl_ViewportMask[];
32} gl_MeshPrimitivesNV[];
33
34void main()
35{
36    uint iid = gl_LocalInvocationID.x;
37    uint gid = gl_WorkGroupID.x;
38
39    gl_MeshVerticesNV[iid].gl_Position = vec4(1.0);
40    gl_MeshVerticesNV[iid].gl_PointSize = 2.0;
41    gl_MeshVerticesNV[iid].gl_ClipDistance[3] = 3.0;
42    gl_MeshVerticesNV[iid].gl_CullDistance[2] = 4.0;
43
44    BARRIER();
45
46    gl_MeshVerticesNV[iid+1].gl_Position = gl_MeshVerticesNV[iid].gl_Position;
47    gl_MeshVerticesNV[iid+1].gl_PointSize = gl_MeshVerticesNV[iid].gl_PointSize;
48    gl_MeshVerticesNV[iid+1].gl_ClipDistance[3] = gl_MeshVerticesNV[iid].gl_ClipDistance[3];
49    gl_MeshVerticesNV[iid+1].gl_CullDistance[2] = gl_MeshVerticesNV[iid].gl_CullDistance[2];
50
51    BARRIER();
52
53    gl_MeshPrimitivesNV[iid].gl_PrimitiveID = 6;
54    gl_MeshPrimitivesNV[iid].gl_Layer = 7;
55    gl_MeshPrimitivesNV[iid].gl_ViewportIndex = 8;
56    gl_MeshPrimitivesNV[iid].gl_ViewportMask[0] = 9;
57
58    BARRIER();
59
60    gl_MeshPrimitivesNV[iid+1].gl_PrimitiveID = gl_MeshPrimitivesNV[iid].gl_PrimitiveID;
61    gl_MeshPrimitivesNV[iid+1].gl_Layer = gl_MeshPrimitivesNV[iid].gl_Layer;
62    gl_MeshPrimitivesNV[iid+1].gl_ViewportIndex = gl_MeshPrimitivesNV[iid].gl_ViewportIndex;
63    gl_MeshPrimitivesNV[iid+1].gl_ViewportMask[0] = gl_MeshPrimitivesNV[iid].gl_ViewportMask[0];
64
65    BARRIER();
66}
67