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[MAX_VER]; // explicitly sized to MAX_VER 26 27perprimitiveNV out gl_MeshPerPrimitiveNV { 28 int gl_PrimitiveID; 29 int gl_Layer; 30 int gl_ViewportIndex; 31 int gl_ViewportMask[]; 32} gl_MeshPrimitivesNV[]; // implicitly sized to MAX_PRIM 33 34out uint gl_PrimitiveIndicesNV[MAX_PRIM*3]; // explicitly sized to MAX_PRIM * 3 35 36void main() 37{ 38 uint iid = gl_LocalInvocationID.x; 39 uint gid = gl_WorkGroupID.x; 40 41 gl_MeshVerticesNV[iid].gl_Position = vec4(1.0); 42 gl_MeshVerticesNV[iid].gl_PointSize = 2.0; 43 gl_MeshVerticesNV[iid].gl_ClipDistance[3] = 3.0; 44 gl_MeshVerticesNV[iid].gl_CullDistance[2] = 4.0; 45 46 BARRIER(); 47 48 gl_MeshVerticesNV[iid+1].gl_Position = gl_MeshVerticesNV[iid].gl_Position; 49 gl_MeshVerticesNV[iid+1].gl_PointSize = gl_MeshVerticesNV[iid].gl_PointSize; 50 gl_MeshVerticesNV[iid+1].gl_ClipDistance[3] = gl_MeshVerticesNV[iid].gl_ClipDistance[3]; 51 gl_MeshVerticesNV[iid+1].gl_CullDistance[2] = gl_MeshVerticesNV[iid].gl_CullDistance[2]; 52 53 BARRIER(); 54 55 gl_MeshPrimitivesNV[iid].gl_PrimitiveID = 6; 56 gl_MeshPrimitivesNV[iid].gl_Layer = 7; 57 gl_MeshPrimitivesNV[iid].gl_ViewportIndex = 8; 58 gl_MeshPrimitivesNV[iid].gl_ViewportMask[0] = 9; 59 60 BARRIER(); 61 62 gl_MeshPrimitivesNV[iid+1].gl_PrimitiveID = gl_MeshPrimitivesNV[iid].gl_PrimitiveID; 63 gl_MeshPrimitivesNV[iid+1].gl_Layer = gl_MeshPrimitivesNV[iid].gl_Layer; 64 gl_MeshPrimitivesNV[iid+1].gl_ViewportIndex = gl_MeshPrimitivesNV[iid].gl_ViewportIndex; 65 gl_MeshPrimitivesNV[iid+1].gl_ViewportMask[0] = gl_MeshPrimitivesNV[iid].gl_ViewportMask[0]; 66 67 BARRIER(); 68 69 // check bound limits 70 gl_PrimitiveIndicesNV[0] = 1; 71 gl_PrimitiveIndicesNV[(MAX_PRIM * 3) - 1] = 2; 72 gl_PrimitiveCountNV = MAX_PRIM * 3; 73} 74