mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-05 12:35:42 +00:00
game-env: put the NGX core DLLs into system32 in DLSS mode
NGX loads its core by full path from the registry's NGXCore FullPath (C:\windows\system32); the bridge folder on WINEDLLPATH does not answer that, so DLSS games without the signature-fix hooks failed with "failed to load C:\windows\system32\_nvngx.dll" (Bright Memory: Infinite on the Red Magic 12 Pro). DLSS mode now links (or copies) the bridge's _nvngx.dll and nvngx.dll into the prefix's system32 and refreshes them when their contents change. The XeSS runtime uses the same helper, which now compares contents instead of sizes.
This commit is contained in:
1 parent
bba89b7c11
commit
73442ad3e0
2 files changed
+55
-8
No files matched your search
@@ -1190,15 +1190,12 @@ def time_now():
|
||||
return time.time()
|
||||
|
||||
|
||||
def upscale_xess(prefix, data):
|
||||
"""Intel's XeSS runtime beside the bridge: libxess.dll loads wl_xess_official.dll from system32. A hard link
|
||||
when the prefix is on the same file system as the data, else a copy."""
|
||||
source = os.path.join(data, "xess", UPSCALE_XESS)
|
||||
if not os.path.isfile(source):
|
||||
return "XeSS runtime not downloaded"
|
||||
target = os.path.join(prefix, "pfx", "drive_c", "windows", "system32", UPSCALE_XESS)
|
||||
def upscale_link(source, target):
|
||||
"""target = source's bytes: a hard link when both are on one file system, else a copy. Kept when equal."""
|
||||
if os.path.isfile(target) and os.path.getsize(target) == os.path.getsize(source):
|
||||
return None
|
||||
with open(source, "rb") as a, open(target, "rb") as b:
|
||||
if a.read() == b.read():
|
||||
return
|
||||
staged = target + ".droiddeck-tmp"
|
||||
if os.path.lexists(staged):
|
||||
os.unlink(staged)
|
||||
@@ -1212,6 +1209,32 @@ def upscale_xess(prefix, data):
|
||||
break
|
||||
dst.write(chunk)
|
||||
os.replace(staged, target)
|
||||
|
||||
|
||||
# NGX loads its core by full path from the registry's NGXCore FullPath (C:\windows\system32), which the bridge
|
||||
# folder on WINEDLLPATH does not answer (Bright Memory: Infinite, "failed to load C:\windows\system32\_nvngx.dll").
|
||||
UPSCALE_NGX_CORE = ("_nvngx.dll", "nvngx.dll")
|
||||
|
||||
|
||||
def upscale_ngx_core(prefix, bridges):
|
||||
"""The bridge's NGX core DLLs as files in the prefix's system32 (DLSS mode)."""
|
||||
system32 = os.path.join(prefix, "pfx", "drive_c", "windows", "system32")
|
||||
if not os.path.isdir(system32):
|
||||
return False
|
||||
for name in UPSCALE_NGX_CORE:
|
||||
source = os.path.join(bridges, "x86_64-windows", name)
|
||||
if os.path.isfile(source):
|
||||
upscale_link(source, os.path.join(system32, name))
|
||||
return True
|
||||
|
||||
|
||||
def upscale_xess(prefix, data):
|
||||
"""Intel's XeSS runtime beside the bridge: libxess.dll loads wl_xess_official.dll from system32. A hard link
|
||||
when the prefix is on the same file system as the data, else a copy."""
|
||||
source = os.path.join(data, "xess", UPSCALE_XESS)
|
||||
if not os.path.isfile(source):
|
||||
return "XeSS runtime not downloaded"
|
||||
upscale_link(source, os.path.join(prefix, "pfx", "drive_c", "windows", "system32", UPSCALE_XESS))
|
||||
return None
|
||||
|
||||
|
||||
@@ -1280,6 +1303,11 @@ def upscale_settings(env, prefix):
|
||||
notes.append("NVIDIA NGX registry entries added to the prefix (DLSS mode)")
|
||||
except OSError as error:
|
||||
notes.append("NGX registry entries not written (%s)" % error)
|
||||
try:
|
||||
if prefix:
|
||||
upscale_ngx_core(prefix, bridges)
|
||||
except OSError as error:
|
||||
notes.append("NGX core DLLs not placed in system32 (%s)" % error)
|
||||
elif mode == "native":
|
||||
result["DROIDDECK_UPSCALE_SPOOF_DLSS"] = "0"
|
||||
result["DROIDDECK_UPSCALE_GPU_SPOOF"] = "rdna4"
|
||||
|
||||
@@ -101,6 +101,25 @@ class UpscalerSettingsTest(unittest.TestCase):
|
||||
self.assertEqual(b"MZ-xess", target.read_bytes())
|
||||
self.assertEqual(source.stat().st_ino, target.stat().st_ino)
|
||||
|
||||
def test_dlss_mode_puts_the_ngx_core_in_system32_and_refreshes_it(self):
|
||||
prefix = tempfile.mkdtemp()
|
||||
self.addCleanup(shutil.rmtree, prefix, True)
|
||||
Path(prefix, "pfx/drive_c/windows/system32").mkdir(parents=True)
|
||||
for name in ("_nvngx.dll", "nvngx.dll"):
|
||||
Path(self.root, "bridges/x86_64-windows", name).write_bytes(b"MZ-v1")
|
||||
MODULE["upscale_settings"]({"DROIDDECK_UPSCALE_MODE": "dlss"}, prefix)
|
||||
core = Path(prefix, "pfx/drive_c/windows/system32/_nvngx.dll")
|
||||
self.assertEqual(b"MZ-v1", core.read_bytes())
|
||||
Path(self.root, "bridges/x86_64-windows/_nvngx.dll").unlink()
|
||||
Path(self.root, "bridges/x86_64-windows/_nvngx.dll").write_bytes(b"MZ-v2")
|
||||
MODULE["upscale_settings"]({"DROIDDECK_UPSCALE_MODE": "dlss"}, prefix)
|
||||
self.assertEqual(b"MZ-v2", core.read_bytes())
|
||||
other = tempfile.mkdtemp()
|
||||
self.addCleanup(shutil.rmtree, other, True)
|
||||
Path(other, "pfx/drive_c/windows/system32").mkdir(parents=True)
|
||||
MODULE["upscale_settings"]({"DROIDDECK_UPSCALE_MODE": "fsr"}, other)
|
||||
self.assertFalse(Path(other, "pfx/drive_c/windows/system32/_nvngx.dll").exists())
|
||||
|
||||
def test_a_game_started_on_xess_without_the_runtime_says_so(self):
|
||||
prefix = tempfile.mkdtemp()
|
||||
self.addCleanup(shutil.rmtree, prefix, True)
|
||||
|
||||
Reference in new issue
Block a user