ValveSoftware / Proton

Compatibility tool for Steam Play based on Wine and additional components
Other
23.9k stars 1.04k forks source link

wineopenxr: xrGetVulkanDeviceExtensionsKHR and Vulkan-native games #7737

Open gotzl opened 3 months ago

gotzl commented 3 months ago

wineopenxr always returns just VK_WINE_openxr_device_extensions when asked for required vulkan extensions (wine_xrGetVulkanDeviceExtensionsKHR). This extension is not part of the spec and no driver provides it. But in case of D3D11/D3D12, it ends up in "Enabled device extensions" by extension providers implemented in dxvk/vkd3d by using a wineopenxr specific API.

However, when a Vulkan-native game checks if all required vulkan extensions are available, it will not be able to find VK_WINE_openxr_device_extensions enabled on the device. As an example, BeamNG is not able to activate OpenXR (see also my post on the BeamNG forum)

 26.43237|D|engine::OpenXrHelper::OpenXr::initVulkan| These Vulkan device extensions are required by the OpenXR runtime:
 26.43246|D|engine::OpenXrHelper::OpenXr::initVulkan|  - VK_WINE_openxr_device_extensions
 26.43251|E|engine::OpenXrHelper::OpenXr::initVulkan| The 'VK_WINE_openxr_device_extensions' Vulkan device extension, required by the OpenXR runtime, has not been loaded for the current Vulkan device
 26.43255|E|engine::OpenXrHelper::OpenXr::initVulkan| Some Vulkan device extensions required by the OpenXR runtime were not found. Unable to initialize Vulkan bindings for OpenXR
 26.43260|E|engine::OpenXrHelper::OpenXr::setEnable| Unable to enable OpenXR

I'm not completely sure why this is done in this way, but it feels to me that returning VK_WINE_openxr_device_extensions should be a D3D11/D3D12 specific code path. When a Vulkan-native game checks for required vulkan extensions, the function should just return the actual VK_* extensions that are reported by the XrInstance, however substituting _fd for _win32 extensions.

I've implemented this in a local patch to wineopenxr (proton_9.0 branch) and it allows BeamNG to activate OpenXR

 52.39755|D|engine::OpenXrHelper::OpenXr::initVulkan| These Vulkan device extensions are required by the OpenXR runtime:
 52.39765|D|engine::OpenXrHelper::OpenXr::initVulkan|  - VK_KHR_external_memory
 52.39774|D|engine::OpenXrHelper::OpenXr::initVulkan|  - VK_KHR_external_semaphore
 52.39784|D|engine::OpenXrHelper::OpenXr::initVulkan|  - VK_KHR_dedicated_allocation
 52.39790|D|engine::OpenXrHelper::OpenXr::initVulkan|  - VK_KHR_get_memory_requirements2
 52.39795|D|engine::OpenXrHelper::OpenXr::initVulkan|  - VK_KHR_external_memory_win32
 52.39802|D|engine::OpenXrHelper::OpenXr::initVulkan|  - VK_KHR_external_semaphore_win32
 52.39807|D|engine::OpenXrHelper::OpenXr::initVulkan|  - VK_EXT_debug_marker
 52.39813|W|engine::OpenXrHelper::OpenXr::initVulkan| The 'VK_EXT_debug_marker' Vulkan device extension, required by the OpenXR runtime, has not been loaded for the current Vulkan device. We'll do an exception and allow OpenXR to continue loading, since it's whitelisted in exceptionExtensions
 52.39818|D|engine::OpenXrHelper::OpenXr::initVulkan| All Vulkan device extensions required by the OpenXR runtime appear to have been correctly loaded
 52.39835|D|engine::OpenXrHelper::OpenXr::initSession| OpenXR is about to create xrSession

I'm not sure if what I'm saying/doing makes sense. If it does make sense, I'm willing to cleanup and share the patch in a PR if required.

jurassicjordan commented 1 month ago

having same issue specifically occurring on S&box. devs confirmed this is a proton related issue