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 builtins in mesh shaders: 19 20void main() 21{ 22 uint iid = gl_LocalInvocationID.x; 23 uint gid = gl_WorkGroupID.x; 24 25 gl_MeshVerticesNV[iid].gl_Position = vec4(1.0); 26 gl_MeshVerticesNV[iid].gl_PointSize = 2.0; 27 gl_MeshVerticesNV[iid].gl_ClipDistance[3] = 3.0; 28 gl_MeshVerticesNV[iid].gl_CullDistance[2] = 4.0; 29 30 BARRIER(); 31 32 gl_MeshVerticesNV[iid+1].gl_Position = gl_MeshVerticesNV[iid].gl_Position; 33 gl_MeshVerticesNV[iid+1].gl_PointSize = gl_MeshVerticesNV[iid].gl_PointSize; 34 gl_MeshVerticesNV[iid+1].gl_ClipDistance[3] = gl_MeshVerticesNV[iid].gl_ClipDistance[3]; 35 gl_MeshVerticesNV[iid+1].gl_CullDistance[2] = gl_MeshVerticesNV[iid].gl_CullDistance[2]; 36 37 BARRIER(); 38 39 gl_MeshPrimitivesNV[iid].gl_PrimitiveID = 6; 40 gl_MeshPrimitivesNV[iid].gl_Layer = 7; 41 gl_MeshPrimitivesNV[iid].gl_ViewportIndex = 8; 42 gl_MeshPrimitivesNV[iid].gl_ViewportMask[0] = 9; 43 44 BARRIER(); 45 46 gl_MeshPrimitivesNV[iid+1].gl_PrimitiveID = gl_MeshPrimitivesNV[iid].gl_PrimitiveID; 47 gl_MeshPrimitivesNV[iid+1].gl_Layer = gl_MeshPrimitivesNV[iid].gl_Layer; 48 gl_MeshPrimitivesNV[iid+1].gl_ViewportIndex = gl_MeshPrimitivesNV[iid].gl_ViewportIndex; 49 gl_MeshPrimitivesNV[iid+1].gl_ViewportMask[0] = gl_MeshPrimitivesNV[iid].gl_ViewportMask[0]; 50 51 BARRIER(); 52 53 // should truncate 257 -> 1 54 gl_PrimitiveIndicesNV[0] = 257; 55 gl_PrimitiveIndicesNV[gid] = gl_PrimitiveIndicesNV[gid-1]; 56 57 // writes 4 indices at offset gl_DrawID 58 writePackedPrimitiveIndices4x8NV(gl_DrawID, 0x01020304); 59 60 gl_PrimitiveCountNV = MAX_PRIM * 3; 61 62 BARRIER(); 63} 64