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_EXT
GPU 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?