OpenXR-SDK-Source icon indicating copy to clipboard operation
OpenXR-SDK-Source copied to clipboard

Crash running Hello-XR on DirectX12

Open Ravbug opened this issue 2 years ago • 5 comments

I'm trying to use Hello-XR as an example for my own DirectX12 implementation for OpenXR, and when running the Hello-XR example on a Vive Pro with SteamVR, the sample crashes trying to render a frame.

Steps to reproduce:

  1. Checkout latest of this repo
  2. mkdir build ; cd build ; cmake ..
  3. Go to hello_xr->main.cpp and remove the try-catch to prevent it from catching the exception where the crash is
  4. Go to hello_xr->properties->Debugging and add -g D3D12 to Command Arguments
  5. Build and run

Stack trace at crash: image

Output:

[16:38:17.680][Info   ] Press any key to shutdown...
[16:38:17.705][Info   ] Available Layers: (0)
[16:38:17.750][Info   ] Instance RuntimeName=SteamVR/OpenXR RuntimeVersion=0.1.0
[16:38:17.750][Info   ] Available View Configuration Types: (1)
[16:38:17.750][Info   ] Available Environment Blend Mode count : (1)
[16:38:17.750][Info   ] Environment Blend Mode (XR_ENVIRONMENT_BLEND_MODE_OPAQUE) : (Selected)
[16:38:18.414][Info   ] Available reference spaces: 3
[16:38:18.424][Info   ] System Properties: Name=SteamVR/OpenXR : lighthouse VendorId=10462
[16:38:18.424][Info   ] System Graphics Properties: MaxWidth=2016 MaxHeight=2240 MaxLayers=16
[16:38:18.424][Info   ] System Tracking Properties: OrientationTracking=True PositionTracking=True
[16:38:18.424][Info   ] Creating swapchain for view 0 with dimensions Width=2016 Height=2240 SampleCount=1
[16:38:18.427][Info   ] Creating swapchain for view 1 with dimensions Width=2016 Height=2240 SampleCount=1
[16:38:18.430][Info   ] XrEventDataSessionStateChanged: state XR_SESSION_STATE_UNKNOWN->XR_SESSION_STATE_IDLE session=1995166640864 time=332621467785300
[16:38:18.430][Info   ] XrEventDataSessionStateChanged: state XR_SESSION_STATE_IDLE->XR_SESSION_STATE_READY session=1995166640864 time=332621467796000
[16:38:18.475][Error  ] HRESULT failure [80070057]
    Origin: d3d12Device->CreateCommittedResource(&heapProp, D3D12_HEAP_FLAG_NONE, &buffDesc, d3d12ResourceState, nullptr, __uuidof(ID3D12Resource), reinterpret_cast<void**>(buffer.ReleaseAndGetAddressOf()))
    Source: OpenXR-SDK-Source-main\src\tests\hello_xr\graphicsplugin_d3d12.cpp:69

The DirectX11 and OpenGL backends appear to work correctly. I could not test Vulkan2, Vulkan, or OpenGLES because it reported those backends were not supported.

GPU: NVIDIA RTX 2070 Super with driver 512.59 OS: Windows 10 21H1 19043.1706

Ravbug avatar May 30 '22 23:05 Ravbug

Hmm, so that shouldn't crash, but also, Vulkan and vulkan_enable2 should both be supported by steamvr.

rpavlik avatar Jun 13 '22 18:06 rpavlik

An issue (number 1734) has been filed to correspond to this issue in the internal Khronos GitLab (Khronos members only: KHR:openxr/openxr#1734 ), to facilitate working group processes.

This GitHub issue will continue to be the main site of discussion.

rpavlik-bot avatar Jun 15 '22 15:06 rpavlik-bot

Hi - Sorry for the delay, I just tried to repro this on dx11, vulkan and vulkan2 with the latest SteamvVR stable release and am not getting any crashes:

image

We do have performance validation warnings in vulkan if validation layers are enabled but this shouldn't affect rendering/functionality.

can you send a SteamVR system report?

image

1runeberg avatar Aug 03 '22 23:08 1runeberg

As of today the DirectX12 backend is working and after manually telling CMake where Vulkan was installed (it was not picking that up automatically), the Vulkan backends also work, though they logged many peformance warnings: [Warning] PERF: (COMMAND_BUFFER 0x1342964d480) [Validation] Validation Performance Warning: [ UNASSIGNED-CoreValidation-DrawState-InvalidImageLayout ] Object 0: handle = 0x1342964d480, type = VK_OBJECT_TYPE_COMMAND_BUFFER; | MessageID = 0x4dae5635 | vkCmdBlitImage: For optimal performance VkImage 0x359e9300000000cb[] layout should be VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL instead of GENERAL.

I haven't updated my copy of hello-xr since filing the original issue.

Here is my system report if it's still useful @1runeberg: steamvr_system_report.zip

Ravbug avatar Aug 04 '22 05:08 Ravbug

As of today the DirectX12 backend is working and after manually telling CMake where Vulkan was installed (it was not picking that up automatically), the Vulkan backends also work, though they logged many peformance warnings: [Warning] PERF: (COMMAND_BUFFER 0x1342964d480) [Validation] Validation Performance Warning: [ UNASSIGNED-CoreValidation-DrawState-InvalidImageLayout ] Object 0: handle = 0x1342964d480, type = VK_OBJECT_TYPE_COMMAND_BUFFER; | MessageID = 0x4dae5635 | vkCmdBlitImage: For optimal performance VkImage 0x359e9300000000cb[] layout should be VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL instead of GENERAL.

I haven't updated my copy of hello-xr since filing the original issue.

Here is my system report if it's still useful @1runeberg: steamvr_system_report.zip

Thanks for the update. We're aware of the warnings.

My understanding is that this is a deficiency in the way Vulkan shares images at the moment.

If the image is in VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, there's a likelihood that specialized memory layouts would be used and Vulkan currently doesn't have a way to properly communicate this between two apps. It depends on the driver and a number of other reasons whether the images ends up in an optimized layout or not.

We're working within the Vulkan working group to help address this. However, this shouldn't result in a significant perf loss.

1runeberg avatar Aug 05 '22 19:08 1runeberg