proton: Populate NVIDIA_WINE_DLL_DIR when available

NVIDIA-software may check the environment variable `NVIDIA_WINE_DLL_DIR`
for a path where DLLs provided by the NVIDIA Linux driver can be found.
This is done as a fallback for when the "DriverStore" cannot be detected
via the D3DDDI functions for querying an adapter-specific registry key.

Tested with an application that reads `NVIDIA_WINE_DLL_DIR` from the
environment and tries to load a known DLL from it. As expected manually
setting the environment variable to the on-disk location did not work,
as the path is not accurate within the pressure-vessel environment.

Link: https://github.com/ValveSoftware/Proton/pull/8087
This commit is contained in:
Liam Middlebrook 2024-09-09 17:12:05 -07:00 committed by Arkadiusz Hiler
parent 7e9c7a09a3
commit 5e0dfbdb34

22
proton
View File

@ -1062,11 +1062,14 @@ class CompatData:
# Try to detect known DLLs that ship with the NVIDIA Linux Driver # Try to detect known DLLs that ship with the NVIDIA Linux Driver
# and add them into the prefix # and add them into the prefix
nvidia_wine_dll_dir = find_nvidia_wine_dll_dir() if g_session.nvidia_wine_dll_dir:
if nvidia_wine_dll_dir:
for dll in ["_nvngx.dll", "nvngx.dll"]: for dll in ["_nvngx.dll", "nvngx.dll"]:
try_copy(nvidia_wine_dll_dir + "/" + dll, "drive_c/windows/system32", optional=True, try_copy(g_session.nvidia_wine_dll_dir + "/" + dll,
prefix=self.prefix_dir, track_file=tracked_files, link_debug=True) "drive_c/windows/system32",
optional=True,
prefix=self.prefix_dir,
track_file=tracked_files,
link_debug=True)
setup_game_dir_drive() setup_game_dir_drive()
setup_steam_dir_drive() setup_steam_dir_drive()
@ -1543,6 +1546,17 @@ class Session:
if "PROTON_CRASH_REPORT_DIR" in self.env: if "PROTON_CRASH_REPORT_DIR" in self.env:
self.env["WINE_CRASH_REPORT_DIR"] = self.env["PROTON_CRASH_REPORT_DIR"] self.env["WINE_CRASH_REPORT_DIR"] = self.env["PROTON_CRASH_REPORT_DIR"]
# NVIDIA software may check for the "DriverStore" by querying the
# NGXCore\NGXPath registry key via `D3DDDI_QUERYREGISTRY_SERVICEKEY` for
# a given adapter. In the case where this path cannot be found, the
# `NVIDIA_WINE_DLL_DIR` environment variable is read as a fallback.
#
# TODO: Add support for populating NGXCore\NGXPath so we can remove the
# NGX copies done in setup_prefix(), and this environment variable.
self.nvidia_wine_dll_dir = find_nvidia_wine_dll_dir()
if self.nvidia_wine_dll_dir:
self.env["NVIDIA_WINE_DLL_DIR"] = self.nvidia_wine_dll_dir
if "PROTON_LOG" in self.env and nonzero(self.env["PROTON_LOG"]): if "PROTON_LOG" in self.env and nonzero(self.env["PROTON_LOG"]):
if self.setup_logging(append_forever=False): if self.setup_logging(append_forever=False):
self.log_file.write("======================\n") self.log_file.write("======================\n")