KhronosGroup / Vulkan-ValidationLayers

Vulkan Validation Layers (VVL)
https://vulkan.lunarg.com/doc/sdk/latest/linux/khronos_validation_layer.html
Other
752 stars 402 forks source link

GPU-AV Debug printf with VK_EXT_shader_object generates false positive "VUID-vkCmdDispatch-None-08600" vaildation error. #7178

Open codecnotsupported opened 9 months ago

codecnotsupported commented 9 months ago

Environment:

Describe the Issue

Use of Debug printf, or GPU-assisted validation, causes validation error (see additional context below). This validation false positive only happens when both synchronization and core are active, when synchronization validation is disabled, it behaves as expected. I also tested if it still checks for a correct descriptor set layout without synchronization enabled, which it does.

Expected behavior Expected no validation error. Debug printf works fine, and gives the expected output.

Valid Usage ID N/A

Additional context

code or terminal output ```sh VUID-vkCmdDispatch-None-08600(ERROR / SPEC): msgNum: 877702099 - Validation Error: [ VUID-vkCmdDispatch-None-08600 ] Object 0: handle = 0x56430c123e50, type = VK_OBJECT_TYPE_COMMAND_BUFFER; Object 1: handle = 0x27d60e0000000019, type = VK_OBJECT_TYPE_SHADER_EXT; | MessageID = 0x3450abd3 | vkCmdDispatch(): The VkShaderEXT 0x27d60e0000000019[] statically uses descriptor set (index #31) which is not compatible with the currently bound descriptor set's layout. The Vulkan spec states: For each set n that is statically used by a bound shader, a descriptor set must have been bound to n at the same pipeline bind point, with a VkPipelineLayout that is compatible for set n, with the VkPipelineLayout or VkDescriptorSetLayout array that was used to create the current VkPipeline or VkShaderEXT, as described in Pipeline Layout Compatibility (https://vulkan.lunarg.com/doc/view/1.3.268.0/linux/1.3-extensions/vkspec.html#VUID-vkCmdDispatch-None-08600) Objects: 2 [0] 0x56430c123e50, type: 6, name: NULL [1] 0x27d60e0000000019, type: 1000482000, name: NULL ```
codecnotsupported commented 9 months ago

I just tested with the VK_EXT_shader_object sample from Vulkan-Samples which has too many descriptor sets for GPU-AV (Debug printf and GPU-assisted) to work.

[info] (Swapchain) Surface format selected: VK_FORMAT_B8G8R8A8_SRGB, VK_COLORSPACE_SRGB_NONLINEAR_KHR

[info] Depth format selected: VK_FORMAT_D32_SFLOAT

[info] Depth format selected: VK_FORMAT_D32_SFLOAT
[info] Depth format selected: VK_FORMAT_D32_SFLOAT
[info] Depth format selected: VK_FORMAT_D32_SFLOAT

[info] Compiling skybox Shader

UNASSIGNED-DEBUG-PRINTF(ERROR / SPEC): msgNum: -1841738615 - Validation Error: [ UNASSIGNED-DEBUG-PRINTF ] | MessageID = 0x92394c89 | Setup Error. Detail: (Descriptor Set Layout conflict with validation's descriptor set at slot 31. Application has too many descriptor sets in the pipeline layout to continue with gpu validation. Validation is not modifying the pipeline layout. Instrumented shaders are replaced with non-instrumented shaders.)
    Objects: 0

It gives a warning for each shader module(?). After which it crashes. Note that this is with all validation disabled, and GPU-AV (Debug printf) enabled.

codecnotsupported commented 9 months ago

It gets more interesting, though slightly off-topic. The Vulkan sample does not crash when both Core and Handle Wrapping are enabled, it does when only Core is enabled. Meaning that the crash is unrelated to GPU-AV, when debug printf is enabled it gives additionally the same error as before.

VUID-vkCmdDrawIndexed-None-08879(ERROR / SPEC): msgNum: 295873134 - Validation Error: [ VUID-vkCmdDrawIndexed-None-08879 ] Object 0: handle = 0x55ba4ae010a0, type = VK_OBJECT_TYPE_COMMAND_BUFFER; | MessageID = 0x11a2aa6e | vkCmdDrawIndexed():  Shaders VK_SHADER_STAGE_VERTEX_BIT and VK_SHADER_STAGE_FRAGMENT_BIT have different descriptor set layouts. The Vulkan spec states: All bound graphics shader objects must have been created with identical or identically defined arrays of descriptor set layouts (https://vulkan.lunarg.com/doc/view/1.3.268.0/linux/1.3-extensions/vkspec.html#VUID-vkCmdDrawIndexed-None-08879)
    Objects: 1
        [0] 0x55ba4ae010a0, type: 6, name: NULL
spencer-lunarg commented 4 months ago

Sorry for the delay on this, looking at the error (and testing) seems a big issue is we don't have enough tests for GPU-AV and DebugPrintf that use Shader Object yet

The above error messages seems to be related to how we have to instrument the debug buffer to write to in the GPU to an unused descriptor set (which will be 31 for a machine with 32 slots), seems we have issues there making sure it lines up to the rules Shader Object has

For your comment in https://github.com/KhronosGroup/Vulkan-ValidationLayers/issues/7178#issuecomment-1865855713 it seems we are not gracefully handling the case where all slots are taken