Mesh shader glMultiDrawMeshTasksIndirectNV

Hello,

When using DrawMeshTasksIndirectNV, I’ve expanded

typedef struct 
{
    uint count;
    uint first;
} DrawMeshTasksIndirectCommandNV;

to include a meshID so that my struct is now

typedef struct 
{
    uint count;
    uint first;
    uint meshID;
} DrawMeshTasksIndirectCommandNV;

which indexes into an array of meshes. So, if a terrain model has 16 tiles (meshes), the gl_DrawID will be used to index into an array of terrain meshes in my task shader which will then compute an LOD, do an early cull, etc.

I have verified that the data in the buffers is correct, via NSight Graphics.

count = 16 because of 16 terrain tile meshes (each tile has a command)
offset = 0
stride = 12 sizeof(DrawMeshTasksIndrectCommandNV)

my mesh shader draw call is

glMultiDrawMeshTasksIndirectNV(0, 16, 12);

My task shader has DrawMeshTasksIndirectCommandNV bound as an SSBO

struct DrawCommand
{
    uint taskCount;
    uint firstTask;
    uint meshID;
};

layout(std430, binding = 5) readonly buffer drawCommand
{
    DrawCommand commands[];
};

...
uint idx = gl_DrawID;
uint meshID = commands[idx].meshID;
// Use meshID to index into mesh array

When I run, I see one tile, as if gl_DrawID is stuck at 0.
However, if I force stride to be 0, I see 5 tiles, but ill-defined.

I’m doing something wrong here. Any help is greatly appreciated.

Thanks,
DC

To simplify the question, gl_DrawIDARB (and gl_DrawID) are stuck at 0 when using glMultiDrawMeshTasksIndirectNV. Is anyone aware if this is a driver bug?

I am not aware of the issue you are describing. I dont have a NV GPU to test on right now, but the last times gl_DrawID was not stuck at 0. I use glMultiDrawMeshTasksIndirectCountNV but I doubt that matters.

Try making a minimum reproducible or run other peoples program and see if the issue persists.

I didn’t have any luck finding other peoples program that uses the MultiDrawMeshTasks* functions. Do you know of any programs that you can point me to which uses these mesh shader functions?

You can run mine (although I havent tested it on NV for a while): https://github.com/BoyBaykiller/IDKEngine/tree/master

In the top right check “UseMeshShaders”. Then the entire scene will be rendered using glMultiDrawMeshTasksIndirectCountNV. Here I use gl_DrawID in the task shader.

Thanks!

I’ll take a look. I appreciate the example.

I’ve modified my code to use glMultiDrawMeshTasksIndirectCountNV with the same results. gl_DrawID appears to be stuck at 0, same when using glMultiDrawMeshTasksIndirectNV.

I’m on Rocky 8 using RTX 2080 GPU and running driver version 565.57.01.