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 user-defined per-view attributes 20 21// mix of single-view and per-view attributes 22layout(location=0) out block { 23 perprimitiveNV perviewNV vec4 color1[][3]; // Implicitly sized 24 perprimitiveNV vec4 color2[3]; 25 perviewNV vec4 color3[MAX_VIEWS][3]; // Explicitly sized 26 vec4 color4; 27} b[]; 28 29// per-view block attributes 30perviewNV layout(location=10) out perviewBlock { 31 perprimitiveNV vec4 color5[]; // Implicitly sized 32 perprimitiveNV vec4 color6[MAX_VIEWS][3]; // Explicitly sized 33 vec4 color7[][3]; // Implicitly sized 34 vec4 color8[MAX_VIEWS]; // Explicitly sized 35} b2[]; 36 37// per-view non-block attributes 38perviewNV layout(location=18) out vec4 nonBlk1[MAX_VER][MAX_VIEWS]; // Explicit+Explicit 39perviewNV perprimitiveNV layout(location=19) out vec4 nonBlk2[MAX_PRIM][]; // Explicit+Implicit 40perviewNV layout(location=20) out vec4 nonBlk3[][MAX_VIEWS]; // Implicit+Explicit 41perviewNV perprimitiveNV layout(location=21) out vec4 nonBlk4[][]; // Implicit+Implicit 42 43// per-view non-block array attributes 44perviewNV layout(location=22) out vec4 nonBlkArr1[MAX_VER][MAX_VIEWS][2]; // Explicit+Explicit 45perviewNV perprimitiveNV layout(location=24) out vec4 nonBlkArr2[MAX_PRIM][][2]; // Explicit+Implicit 46perviewNV layout(location=26) out vec4 nonBlkArr3[][MAX_VIEWS][2]; // Implicit+Explicit 47perviewNV perprimitiveNV layout(location=28) out vec4 nonBlkArr4[][][2]; // Implicit+Implicit 48 49void main() 50{ 51 uint iid = gl_LocalInvocationID.x; 52 uint viewID = gl_MeshViewIndicesNV[gl_MeshViewCountNV%MAX_VIEWS]; 53 54 b[iid].color1[viewID][2] = vec4(1.0); 55 b[iid].color2[1] = vec4(2.0); 56 b[iid].color3[viewID][2] = vec4(3.0); 57 b[iid].color4 = vec4(4.0); 58 59 BARRIER(); 60 61 b2[iid].color5[viewID] = vec4(5.0); 62 b2[iid].color6[viewID][1] = vec4(6.0); 63 b2[iid].color7[viewID][2] = vec4(7.0); 64 b2[iid].color8[viewID] = vec4(8.0); 65 66 BARRIER(); 67} 68 69