protonscr

RTX Reflections (Elevator) Demo - Almost there!

vkd3dclosed
HansKristian-Work/vkd3d-proton#886 · opened 2021-11-01 by SveSop · updated 2023-03-17 · 13 comments · github
SSveSop 2021-11-01 github

So i have been experimenting with the Reflections (Elevator) demo from nVidia, and made some progress with dxvk-nvapi towards getting stuff to happen - other than the "Need nVidia RTX adapter with driver 416.25 or newer" message. This is my progress so far.

Setup:
wine-staging-6.19 (There is some sound issues when running under wine-staging-6.20)
vkd3d-proton 35d2f1e87faf697378efb2a88ffe43ddb3e24e62
dxvk(for dxgi)
dxvk-nvapi - Custom experimental branch: https://github.com/SveSop/dxvk-nvapi/tree/experimental

System:
Ubuntu20.04
GPU: RTX 2070 (8GB)
Driver: nVidia 470.82

Need to disable the winecfg option Allow the window manager to control the windows, or else it seems to bug out and not show LOADING on screen. (Crashes all the same tho).

The crash reads: \Engine\Source\Runtime\D3D12RHI\Private\D3D12Raytracing.cpp:702 E_INVALIDARG I assume the demo is compiled with UnrealEngine 4.22 given the releasedate of the demo - and the fact that this was when UE4 seemed to introduce RTX features.
Looking at the file in question, it may (or may not depending on me viewing the source right) fail on this function:

                  Buffer = Adapter->CreateRHIBuffer<FD3D12MemBuffer>(
                        nullptr, BufferDesc, BufferDesc.Alignment,
                        0, BufferDesc.Width, BUF_Static, CreateInfo,
                        FRHIGPUMask::FromIndex(Device->GetGPUIndex()));

I am attaching a logfile from my test, aswell as attaching nvapi.dll and nvapi64.dll from the experimental branch.

Reflections.log.gz
dxvk-nvapi.tar.gz
.
Worth looking into?

Ooscarbg 2021-11-02 github

Good news! thanks for the work.. seems this work will make Atomic Heart demo also work.. seems they are based on same UE4 RTX branch/release tag..

Ooscarbg 2021-11-13 github

@SveSop have you retested with current Nvidia Vulkan dev drivers (Linux 470.62.07) released a day after your initial post?
I say because they come with some Vulkan RT fix:
"Fixed a compiler bug with Ray Tracing shaders which could cause shader execution timeouts, resulting in device loss"

SSveSop 2021-11-14 github

@SveSop have you retested with current Nvidia Vulkan dev drivers (Linux 470.62.07) released a day after your initial post? I say because they come with some Vulkan RT fix: "Fixed a compiler bug with Ray Tracing shaders which could cause shader execution timeouts, resulting in device loss"

Yeah. No change for this issue sadly.

SSveSop 2021-12-03 github

Looking a bit closer on the UE source, i am not sure what version i used, but picking the 4.22 branch from Unreal git source, the line and error message seems to point to:

			if (It.Type == D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV)
				{
					DEC_DWORD_STAT(STAT_D3D12RayTracingViewDescriptorHeaps);
					DEC_DWORD_STAT_BY(STAT_D3D12RayTracingViewDescriptors, It.NumDescriptors);
				}
				else

This breaks vkd3d with:
fixme:d3d12_state_object_parse_subobjects: Unrecognized subobject type: 3 and returns a E_INVALIDARG

I this may indicate that vkd3d needs D3D12_STATE_SUBOBJECT_TYPE_NODE_MASK possibly someplace in the structure of the https://github.com/HansKristian-Work/vkd3d-proton/blob/master/libs/vkd3d/raytracing_pipeline.c#L426 function.

Just passing this without doing anything like this:

--- a/libs/vkd3d/raytracing_pipeline.c
+++ b/libs/vkd3d/raytracing_pipeline.c
@@ -603,6 +603,11 @@ static HRESULT d3d12_state_object_parse_subobjects(struct d3d12_state_object *ob
                 data->vk_libraries_count += 1;
                 break;
             }
+            case D3D12_STATE_SUBOBJECT_TYPE_NODE_MASK:
+            {
+                FIXME("NODE_MASK not implemented!\n");
+                break;
+            }
 
             default:
                 FIXME("Unrecognized subobject type: %u.\n", obj->Type);
-- 

will result in:

fixme:d3d12_state_object_parse_subobjects: NODE_MASK not implemented!
err:d3d12_state_object_compile_pipeline: Failed to convert DXIL export: __CHS_from_Main_MainPS

So i guess this needs some sort of implementation?

EDIT: I am not completely sure that this missing NODE_MASK actually "breaks" vkd3d, but i kinda thought D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV was somewhat implemented... Meh :unamused:

SSveSop 2021-12-06 github

Stubbing out and just let this D3D12_STATE_SUBOBJECT_TYPE_NODE_MASK pass like i did above, results in this:

01b0:err:vkd3d_dxil_log_callback: dxil-spirv: Unimplemented DXIL opcode 58
01b0:err:vkd3d_dxil_log_callback: dxil-spirv: Failed to emit instruction.
01b0:err:vkd3d_dxil_log_callback: dxil-spirv: Failed to convert function.
01b0:err:d3d12_state_object_compile_pipeline: Failed to convert DXIL export: __CHS_from_Main_MainPS

Seemingly "opcode 58" is:
https://github.com/HansKristian-Work/dxil-spirv/blob/master/dxil.hpp#L266

Maybe dxil-spirv opcode CBufferLoad needs some sort of implementation?

Ooscarbg 2022-02-07 github

would be nice if @HansKristian-Work could give a look at "dxil-spirv: Unimplemented DXIL opcode 58" and if fixing that completely fixes running "original" UE4 RTX demos released by Nvidia (based on old 4.22/4.23 branches)

Ooscarbg 2022-04-02 github

seems CBufferLoad support (for "Unimplemented DXIL opcode 58" ) has been implemented! ( https://github.com/HansKristian-Work/dxil-spirv/commit/670d48838b4fcc236c6997f51aaec1334bc8c8e9 )
@SveSop can you test if latest VKD3D with your "D3D12_STATE_SUBOBJECT_TYPE_NODE_MASK" patch fixes the demo completely?

SSveSop 2022-04-02 github

It did not fail on the same as before tho, so there is some movement :smile:

028c:err:d3d12_state_object_parse_subobjects: Must have shader config.

The error message both for Reflections Demo and the pre-alpha version of Atomic Heart points to what i believe is this struct in the UE4 source:

			Entry.StateObject = CreateRayTracingStateObject(
				RayTracingDevice,
				MakeArrayView(&LibraryPtr, 1),
				RenamedEntryPoints,
				MaxPayloadSizeInBytes,
				MakeArrayView(&HitGroupDesc, NumHitGroups),
				GlobalRootSignature,
				MakeArrayView(&LocalRootSignature, 1),
				LocalRootSignatureAssociations,
				{},
				D3D12_STATE_OBJECT_TYPE_COLLECTION);

Then again, i have not looked into this in a while, and i did clean out some of the patches i experimented with, so i can't really tell if it should be a quick-fix or not. Something to do with RTPSO collection whatever that is :smirk:

Ooscarbg 2022-04-05 github

Hi, demo works with little added work:
basically handling missing shader config and setting to sensible values found in UE4 code..
perhaps setting maxPipelineRayHitAttributeSize = 32; instead of maxPipelineRayHitAttributeSize = 16; is better for all projects as
http://vulkan.gpuinfo.org/displayextensionproperty.php?extensionname=VK_KHR_ray_tracing_pipeline&extensionproperty=maxRayHitAttributeSize&platform=all
shows all vendors support max attrib size of 32 altough to run this demo 16 is ok..
for interface_create_info.maxPipelineRayPayloadSize = 64; vulkan has no upper limit but more hurts perf.. because is like shared local mem which limits threads dispatched per SM in CUDA parlance..
also allows Atomic Heart to load but altough runs and music sounds screen is black at all times.. but may due to other issues:
6318:warn:d3d12_resource_validate_create_info: Ignoring optimized clear value.
6318:warn:d3d12_command_list_OMSetRenderTargets: RTV descriptor 1 is not initialized.
etc..

here is the patch:
reflectionsvkd3dpatch.txt

maybe I suspect early DXR spec didn't required settings this values and allowed running with some defaults set like I'm doing here(?)..

diff --git a/libs/vkd3d/raytracing_pipeline.c b/libs/vkd3d/raytracing_pipeline.c
index a963350f..cd7b3e1d 100644
--- a/libs/vkd3d/raytracing_pipeline.c
+++ b/libs/vkd3d/raytracing_pipeline.c
@@ -604,6 +604,11 @@ static HRESULT d3d12_state_object_parse_subobjects(struct d3d12_state_object *ob
                 data->vk_libraries_count += 1;
                 break;
             }
+            case D3D12_STATE_SUBOBJECT_TYPE_NODE_MASK:
+            {
+                FIXME("NODE_MASK not implemented!\n");
+                break;
+            }
 
             default:
                 FIXME("Unrecognized subobject type: %u.\n", obj->Type);
@@ -619,8 +624,8 @@ static HRESULT d3d12_state_object_parse_subobjects(struct d3d12_state_object *ob
 
     if (!data->shader_config)
     {
-        ERR("Must have shader config.\n");
-        return E_INVALIDARG;
+        /*ERR*/FIXME("Must have shader config.\n");
+        //return E_INVALIDARG;
     }
 
     return S_OK;
@@ -1342,8 +1347,17 @@ static HRESULT d3d12_state_object_compile_pipeline(struct d3d12_state_object *ob
 
     interface_create_info.sType = VK_STRUCTURE_TYPE_RAY_TRACING_PIPELINE_INTERFACE_CREATE_INFO_KHR;
     interface_create_info.pNext = NULL;
-    interface_create_info.maxPipelineRayPayloadSize = data->shader_config->MaxPayloadSizeInBytes;
-    interface_create_info.maxPipelineRayHitAttributeSize = data->shader_config->MaxAttributeSizeInBytes;
+    if (data->shader_config)
+    {
+        interface_create_info.maxPipelineRayPayloadSize = data->shader_config->MaxPayloadSizeInBytes;
+        interface_create_info.maxPipelineRayHitAttributeSize = data->shader_config->MaxAttributeSizeInBytes;
+    }
+    else
+    {
+        FIXME("assigning maxPipelineRayPayloadSize = 64 maxPipelineRayHitAttributeSize = 16");
+        interface_create_info.maxPipelineRayPayloadSize = 64;
+        interface_create_info.maxPipelineRayHitAttributeSize = 16;
+    }
 
     if (data->pipeline_config.MaxTraceRecursionDepth >
             object->device->device_info.ray_tracing_pipeline_properties.maxRayRecursionDepth)
@@ -1365,7 +1379,12 @@ static HRESULT d3d12_state_object_compile_pipeline(struct d3d12_state_object *ob
     vr = VK_CALL(vkCreateRayTracingPipelinesKHR(object->device->vk_device, VK_NULL_HANDLE,
             VK_NULL_HANDLE, 1, &pipeline_create_info, NULL, &object->pipeline));
     if (vr)
-        return hresult_from_vk_result(vr);
+    {
+        FIXME("vkCreateRayTracingPipelinesKHR error");
+            return 
+        hresult_from_vk_result(vr);
+        
+    }
 
     if (object->type == D3D12_STATE_OBJECT_TYPE_RAYTRACING_PIPELINE)
     {
SSveSop 2022-04-05 github

Right.. i assume the reason i cant get it to work is because i am not using the vulkan beta driver then. I'm on 510 driver branch due to other issues atm, so unless they updated optix/cuda for the 470 branch im not going back to that atm.

SSveSop 2022-05-10 github

NVIDIA driver 510.60.02 +
vkd3d @ 71940797d1722384df1d520807e6e83746de1414

  • (branch) origin further-rt-tests

And this demo is working.

BBlisto91 2023-02-03 github

@SveSop Friendly ping 👀
Is it correctly understood of me that this is working now?

Jjp7677 2023-03-17 github

Yes, this demo indeed works with the nvapi modification @SveSop did ( https://github.com/SveSop/dxvk-nvapi/tree/elevatordemo ). I had to set a Wine Virtual Desktop with one of the resolutions mentioned in README of that demo to avoid flickering and black screen on my non 16:9 monitor.

(The demo looks quite impressive when it works ..)

DLLs