• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#version 450
2
3#define MAX_VER  81
4#define MAX_PRIM 32
5#define MAX_VIEWS gl_MaxMeshViewCountNV
6
7#define BARRIER() \
8    memoryBarrierShared(); \
9    barrier();
10
11#extension GL_NV_mesh_shader : enable
12
13layout(local_size_x = 32) in;
14
15layout(max_vertices=MAX_VER) out;
16layout(max_primitives=MAX_PRIM) out;
17layout(triangles) out;
18
19// test use of redeclared per-view builtin attributes
20
21out gl_MeshPerVertexNV {
22    perviewNV vec4 gl_PositionPerViewNV[MAX_VIEWS];         // explicitly sized view dim
23    perviewNV float gl_ClipDistancePerViewNV[MAX_VIEWS][4]; // explicitly sized view dim
24    perviewNV float gl_CullDistancePerViewNV[MAX_VIEWS][4]; // explicitly sized view dim
25} gl_MeshVerticesNV[];
26
27perprimitiveNV out gl_MeshPerPrimitiveNV {
28    perviewNV int gl_LayerPerViewNV[];                      // implicitly sized view dim
29    perviewNV int gl_ViewportMaskPerViewNV[][1];            // implicitly sized view dim
30} gl_MeshPrimitivesNV[];
31
32void main()
33{
34    uint iid = gl_LocalInvocationID.x;
35    uint viewID = gl_MeshViewIndicesNV[gl_MeshViewCountNV%MAX_VIEWS];
36
37    gl_MeshVerticesNV[iid].gl_PositionPerViewNV[viewID]          = vec4(1.0, 2.0, 3.0, 4.0);
38    gl_MeshVerticesNV[iid].gl_ClipDistancePerViewNV[viewID][2]   = 5.0;
39    gl_MeshVerticesNV[iid].gl_CullDistancePerViewNV[viewID][3]   = 6.0;
40    gl_MeshPrimitivesNV[iid].gl_LayerPerViewNV[viewID]           = 7;
41    gl_MeshPrimitivesNV[iid].gl_ViewportMaskPerViewNV[viewID][0] = 8;
42
43    BARRIER();
44
45    gl_MeshVerticesNV[iid+1].gl_PositionPerViewNV[viewID]          = gl_MeshVerticesNV[iid].gl_PositionPerViewNV[viewID];
46    gl_MeshVerticesNV[iid+1].gl_ClipDistancePerViewNV[viewID][2]   = gl_MeshVerticesNV[iid].gl_ClipDistancePerViewNV[viewID][2];
47    gl_MeshVerticesNV[iid+1].gl_CullDistancePerViewNV[viewID][3]   = gl_MeshVerticesNV[iid].gl_CullDistancePerViewNV[viewID][3];
48    gl_MeshPrimitivesNV[iid+1].gl_LayerPerViewNV[viewID]           = gl_MeshPrimitivesNV[iid].gl_LayerPerViewNV[viewID];
49    gl_MeshPrimitivesNV[iid+1].gl_ViewportMaskPerViewNV[viewID][0] = gl_MeshPrimitivesNV[iid].gl_ViewportMaskPerViewNV[viewID][0];
50
51    BARRIER();
52}
53
54