Hi,
please point how to get an access to tasks count in a mesh shader?
The receipt from GLSL/extensions/ext/GLSL_EXT_mesh_shader.txt at main · KhronosGroup/GLSL · GitHub
sounds incomplete and brakes flexibility:
(8) Should the gl_NumWorkGroups built-in be supported in task or mesh
shaders, as with compute shaders?RESOLVED: No, this isn't worth the trouble. If required, an application can pass a workgroup count manually via a uniform. If we were to support such a thing, it would be necessary to figure out how this built-in would interact with gl_NumWorkGroups. For compute shaders, if you dispatched five workgroups with DispatchCompute, they would always be numbered 0..4 and have values less than gl_NumWorkGroups. If you called glDrawMeshTasksNV with <first> set to 3 and <count> set to 5, the work groups would be numbered 3..7 and it would be necessary to decide if gl_NumWorkGroups should be 5 or 8.
Scenarios are following:
- A task shader is generating tasks count dynamically, so it is not possible to pass exact number of tasks as an uniform without implementing same algorithm on CPU side;
- Ok, vkCmdDrawMeshTasksNV accepts (first, count) and a program stages are task+mesh+frag then the task can receive initial “first” and “count” via manually passes uniforms, but why the task shader is not able to generate own “first” and pass it further?
Proposal is following:
- a task shader out is uint gl_TaskFirstNV, 0 by default;
- a task shader out is uint gl_TaskCountNV, same rules as now;
- a mesh shader in uint gl_TaskFirstNV - new input, it is or out from staged task shader or vkCmdDrawMeshTasksNV(first…);
- a mesh shader in uint gl_TaskCountNV - new input, it is or out from staged task shader or vkCmdDrawMeshTasksNV(…count);
- new input gl_NumWorkGroups.x = gl_TaskCountNV - gl_TaskFirstNV or vkCmdDrawMeshTasksNV(count - first).
Regards,
Valentine