ValveSoftware / Proton

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

Decouple OpenVR and OpenXR from Steam #8256

Open Tuupertunut opened 2 days ago

Tuupertunut commented 2 days ago

Currently both Proton's wineopenxr and vrclient modules depend on a Windows registry key HKEY_CURRENT_USER\Software\Wine\VR. This key seems to be used to store VR-related Vulkan extensions for use in those modules. The key must be present for wineopenxr or vrclient to work, otherwise they will crash when opening an OpenXR or OpenVR application. https://github.com/ValveSoftware/Proton/blob/efbcf967a1d3354a0a92bcf978a981b3a56b61b4/wineopenxr/openxr.c#L333-L337 https://github.com/ValveSoftware/Proton/blob/3c3d468971353a5302f401a1e017730970ab8921/vrclient_x64/vrclient_main.c#L134-L138

The only code where this registry key is initialized is steam.cpp in steam_helper module, which means that Steam must always be run before any VR application is opened. Therefore Proton's VR support has a de-facto dependency on Steam. https://github.com/ValveSoftware/Proton/blob/3c3d468971353a5302f401a1e017730970ab8921/steam_helper/steam.cpp#L702-L1024

From an architecture standpoint it would make more sense to decouple the VR initialization code from steam_helper, so that the wineopenxr and vrclient modules could be used independently and not require Steam. Currently they are already independent modules in every other way. This would allow using them in regular Wine as well as not having to ensure Steam runs before any VR app. I see two different approaches:

  1. Move the VR registry initialization code to the wineopenxr and vrclient modules so they could initialize themselves. I have an example patch for Proton 8.26 where I copy pasted the init code from steam_helper to vrclient and now I'm able to run non-Steam VR games with Wine-GE without having Steam. proton-vrfix.patch.txt

  2. As suggested in #6038, don't use the registry key at all and instead query Vulkan extensions directly from wineopenxr and vrclient modules when needed.

Another note:

The registry key also seems to have a state value that different modules like wineopenxr and vrclient, as well as dxvk and vkd3d use to check if steam_helper has finished initializing VR. As far as I've understood, this would not be needed if the wineopenxr and vrclient modules were in charge of initializing themselves. https://github.com/doitsujin/dxvk/blob/dd15328ccf87f709235fc320edb04172d15fdea2/src/dxvk/dxvk_openvr.cpp#L62-L63 https://github.com/HansKristian-Work/vkd3d-proton/blob/657f81b0f6da25f6f991faa6a92fac2a09fcce08/libs/d3d12core/main.c#L129