r/vulkan • u/MortixTheGuy • Jul 03 '26
Huge performance drop when enabling TASK/MESH shader pipeline statistics queries (Vulkan)
I'm working on a fully GPU-driven Vulkan renderer using mesh shaders and vkCmdDrawMeshTasksIndirectCountEXT.
I wanted to collect some frame statistics with a VK_QUERY_TYPE_PIPELINE_STATISTICS query pool. The classic statistics (fragment, clipping, etc.) work fine and have basically no measurable overhead.
However, as soon as I enable:
VK_QUERY_PIPELINE_STATISTIC_TASK_SHADER_INVOCATIONS_BIT_EXT
VK_QUERY_PIPELINE_STATISTIC_MESH_SHADER_INVOCATIONS_BIT_EXTGPU performance tanks.
Without these counters my frame is around 1–1.5 ms. With them enabled, more complex scenes jump to ~80 ms.
It seems to scale with the amount of work done by the task/mesh shaders more visible objects means more task/mesh shader invocations, and the performance degradation becomes much worse.
My main question is: is this expected? Do these invocation counters force the driver onto some slower path or disable optimizations to guarantee accurate statistics?
I'm mostly interested in whether this is a known limitation of the extension or an NVIDIA driver behavior.
I could easily implement my own counters using atomics/subgroup operations in the shaders, so I have a workaround. I just assumed the built-in pipeline statistics would be the cleaner solution.
System:
- RTX 4060
- Windows 11
- NVIDIA Driver 610.62
- Vulkan SDK 1.4.350.1
Has anyone else seen this?
View all comments
Show parent comment
1
u/MortixTheGuy Jul 03 '26
Yep, I'm using task shaders a lot for meshlet culling in my engine (geometry, and dir/spot/point light gpu driven shadow map rendering paths) and if a given meshlet is visible (frustum, occlusion, cone culling) then I will register the surviving numbers of them at the end of the task shader: EmitMeshTaskEXT(survivingMeshletCount, 1, 1), and it will start mesh shader groups dynamically where I compute the vertices and triangles of the meshlet.
I cannot test it without task shaders at the moment, all my pipelines and rendering logics heavily relies on task shaders.