protonscr

Raytracing test hangs because RayClosest is not in the stages

vkd3dclosed
HansKristian-Work/vkd3d-proton#817 · opened 2021-09-27 by Flakebi · updated 2021-10-05 · 2 comments · github
FFlakebi 2021-09-27 github

Hi,
I’m not that familiar with the dxr and vulkan raytracing APIs, so I’m not sure if this is an issue in the raytracing test, vkd3d or the driver, but my guess is this is a problem in vkd3d.
Anyway, running VKD3D_CONFIG=dxr VKD3D_TEST_FILTER=raytracing vkd3d-proton/build/tests/d3d12 hangs, because a shader – probably XRayClosest – is not bound correctly.

When I add XRayClosest to the dxil_exports, some tests still fail, but at least it doesn’t hang:

diff --git a/tests/d3d12_raytracing.c b/tests/d3d12_raytracing.c
index 80599629..e30d4434 100644
--- a/tests/d3d12_raytracing.c
+++ b/tests/d3d12_raytracing.c
@@ -1011,9 +1013,10 @@ void test_raytracing(void)
     if (rt_object_library)
     {
         const WCHAR *table_export[] = { u"XRayMiss" };
-        D3D12_EXPORT_DESC dxil_exports[2] = {
+        D3D12_EXPORT_DESC dxil_exports[3] = {
             { u"XRayMiss", u"RayMiss", 0 },
             { u"XRayGen", u"RayGen", 0 },
+            { u"XRayClosest", u"RayClosest", 0 },
         };
         unsigned int local_rs_table_index;
         D3D12_HIT_GROUP_DESC hit_group;

Without this change, only two stages (RayMiss and RayGen) are passed to vkCreateRayTracingPipelinesKHR, but the groupinfo refers to shader stage 0, 1 and 2, 2 for the closest hit shader.

Running with Vulkan validation layers (VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation) prints a note:

VUID-VkRayTracingShaderGroupCreateInfoKHR-closestHitShader-03478(ERROR / SPEC): msgNum: -1489437352 - Validation Error: [ VUID-VkRayTracingShaderGroupCreateInfoKHR-closestHitShader-03478 ] Object 0: handle = 0x190d340, type = VK_OBJECT_TYPE_DEVICE; | MessageID = 0xa738fd58 | : pGroups[2] The Vulkan spec states: closestHitShader must be either VK_SHADER_UNUSED_KHR or a valid index into VkRayTracingPipelineCreateInfoKHR::pStages referring to a shader of VK_SHADER_STAGE_CLOSEST_HIT_BIT_KHR (https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VUID-VkRayTracingShaderGroupCreateInfoKHR-closestHitShader-03478)
    Objects: 1
        [0] 0x190d340, type: 3, name: NULL

What I think is happening:
XRayClosest is exported in an extra rt object library that is added in a collection where exports is null, which in dxr means everything will be exported. But translating this to the vulkan api misses adding these implicit exports to the stages, ending up with a reference to a non-existing stage.

HHansKristian-Work maintainer 2021-09-29 github

The validation error is bogus I think. The spec says that pStages[] arrays are implicitly added to by using pipeline libraries, and that additional shader is referenced by a pGroup entry.

FFlakebi 2021-10-04 github

Thanks, that makes sense. The spec doesn’t exactly make it obvious. I opened a PR on the validation layers.

Launch options