cg-tuwien/Auto-Vk-Toolkit

Validation error in ray tracing examples

johannesugb opened this issue · 1 comments

Beginning with Vulkan SDK X(?), the ray tracing examples show multiple of the following validation errors:

 [ VUID-VkMemoryBarrier2-dstAccessMask-07454 ] Object 0: handle = 0x2100c143b10, type = VK_OBJECT_TYPE_COMMAND_BUFFER; | MessageID = 0xade1a5bb | vkCmdPipelineBarrier2(): pDependencyInfo.pMemoryBarriers[0].dstAccessMask bit VK_ACCESS_SHADER_READ_BIT is not supported by stage mask (VK_PIPELINE_STAGE_ACCELERATION_STRUCTURE_BUILD_BIT_KHR). The Vulkan spec states: If pname:dstAccessMask includes VK_ACCESS_2_SHADER_READ_BIT, pname:dstStageMask must include VK_PIPELINE_STAGE_2_ALL_GRAPHICS_BIT, VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_2_ACCELERATION_STRUCTURE_BUILD_BIT_KHR, VK_PIPELINE_STAGE_2_MICROMAP_BUILD_BIT_EXT, or one of the VK_PIPELINE_STAGE_*_SHADER_BIT stages (https://vulkan.lunarg.com/doc/view/1.3.261.1/windows/1.3-extensions/vkspec.html#VUID-VkMemoryBarrier2-dstAccessMask-07454)

Why? And how to fix?

I did reproduce this issue after updating to the newest version of SDK ( so update from 1.3.250.1 to 1.3.261.1 ) on both ray_tracing_custom_intersection and ray_tracing_with_shadows_and_ao. I unfortunately cannot test the ray_query_in_ray_tracing_shaders as I only have GTX 1080 which does not support RT queries.

The validation error mentions VK_PIPELINE_STAGE_ACCELERATION_STRUCTURE_BUILD_BIT_KHR and VK_ACCESS_SHADER_READ_BIT which I've confirmed to be wrong after checking the API dump (probably the validation layers being confused). According to the message as well as online docs (Table 1. Supported access types) this combination of Stage and Access should be valid. I have opened an issue in the Vulkan Validation Layers repo.

That being said when replacing the access::shader_read with access::acceleration_structure_read in avk.cpp on lines 1664 & 1665, 1789 and 2051 the validation errors are gone for ray_tracing_custom_intersection. Doing the same fix in triangle_mesh_geometry_manager.hpp on line 64 removes the validation layer errors for ray_tracing_with_shadows_and_ao.