Task shader reads the mesh descriptor set when layouts are stage-exclusive and UPDATE_AFTER_BIND is enabled

Summary

In a task + mesh + fragment graphics pipeline, the task shader reads the descriptors of the mesh shader’s descriptor set instead of its own set when all of the following are true:

  • The task set layout uses stageFlags = VK_SHADER_STAGE_TASK_BIT_EXT only.
  • The mesh set layout uses stageFlags = VK_SHADER_STAGE_MESH_BIT_EXT only.
  • The set layouts and the descriptor pool use UPDATE_AFTER_BIND (VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT, VK_DESCRIPTOR_BINDING_UPDATE_AFTER_BIND_BIT, VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT).

Validation layers (core, GPU-AV, synchronization) report no errors. Giving both layouts VK_SHADER_STAGE_TASK_BIT_EXT | VK_SHADER_STAGE_MESH_BIT_EXT, or leaving UPDATE_AFTER_BIND off, makes every binding read the correct buffer.

The same misread also happens in our renderer with VK_EXT_descriptor_buffer. The attached repro covers classic descriptor sets only.

Environment

  • NVIDIA GeForce RTX 4080 Laptop GPU, driver 616.56
  • Also reproduced by a colleague on the latest driver
  • Driver Version 595.79 didn’t have the bug
  • Windows 11
  • Vulkan 1.4.351, Vulkan SDK 1.4.363
  • The repro requests Vulkan 1.3 and VK_EXT_mesh_shader

Repro

Pipeline layout:

  • Set 0: mesh shader, 9 storage-buffer bindings
  • Set 1: task shader, 11 storage-buffer bindings

Each binding points at its own buffer range. The range is filled with a unique marker 0x5E70RRBB (RR = 1 for the mesh set, 2 for the task set, BB = binding) and has a unique size. The task shader writes .length() and the first element of each of its bindings into a result buffer addressed by a buffer device address in the push constants, so the recorded output does not go through a descriptor. The host then checks that each task binding saw its own marker and length.

Four variants are run:

stage flags on the two layouts UpdateAfterBind result
TASK / MESH yes FAIL
TASK | MESH on both yes PASS
TASK / MESH no PASS
TASK | MESH on both no PASS

Build and run (Vulkan SDK with VULKAN_SDK set, CMake >= 3.24, C++20):

NvidiaRepro.zip (11.8 KB)

I seem to be running into the same issue, but setting stage flags to more than just TASK (even setting MESH/VERTEX/FRAGMENT/COMPUTE) does not help. I’m not using UPDATE_AFTER_BIND in the first place, so this does not help either. This is solely using descriptor buffers and no descriptor pools at all.

Reading any SSBO or Uniform/IUB data from a descriptor set/buffer in the task shader just returns apparent garbage when the descriptor set index is only used by the task shader. Reading from the same underlying descriptor buffer but different descriptor set index in the mesh shader returns all data correctly. If I use the same underlying descriptor buffer at the same descriptor set index for both task/mesh, then the task shader also reads correct data.

Environment:

  • RTX 3090
  • occurs on both 615.71.09 and 615.78.08
  • Linux

This was working correctly in 610.57.04 and prior drivers, so it seems like the R615 branch introduced this descriptor set index mapping mismatch.