From d47ed325fd3e8ac3a3cf9d26cb8c6c87347bffa6 Mon Sep 17 00:00:00 2001 From: The412Banner Date: Sat, 5 Dec 2026 02:16:18 -0500 Subject: [PATCH] upscale: DLSS signature fix on by default DLSS games only work with the nvapi64.dll hooks that let NGX accept the bridge DLLs (without them the DLSS sample stops at GetFeatureRequirements with PlatformError; with them it runs Full FSR 4.1 on the NPU in D3D11 and D3D12, Red Magic 12 Pro). DLSS mode now has the fix on unless the player switches it off: the app stores "1" or "0" for DLSS games and reads a missing entry as on, and droiddeck-game-env passes 1 unless the game stores 0. Upstream always installs the hooks. --- .../java/com/droiddeck/launcher/core/GameUpscaler.kt | 7 ++++--- .../com/droiddeck/launcher/core/GameUpscalerTest.kt | 10 ++++++++++ tools/linuxfs/overlay/usr/local/bin/droiddeck-game-env | 4 ++-- tools/tests/test_game_environment.py | 8 ++++++++ tools/upscale/bridges/README.md | 5 +++-- 5 files changed, 27 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/com/droiddeck/launcher/core/GameUpscaler.kt b/app/src/main/java/com/droiddeck/launcher/core/GameUpscaler.kt index f628d8509b..c0ff2664ca 100644 --- a/app/src/main/java/com/droiddeck/launcher/core/GameUpscaler.kt +++ b/app/src/main/java/com/droiddeck/launcher/core/GameUpscaler.kt @@ -62,7 +62,7 @@ object GameUpscaler { val engine: Engine = DEFAULT_ENGINE, val sharpness: Int = DEFAULT_SHARPNESS, val npuSync: Boolean = false, - val signatureFix: Boolean = false, + val signatureFix: Boolean = true, ) fun choice(config: GameEnvironment.Config, scope: String): Choice? { @@ -74,7 +74,7 @@ object GameUpscaler { engine = Engine.byId(entries[ENGINE]) ?: DEFAULT_ENGINE, sharpness = entries[SHARPNESS]?.toIntOrNull()?.coerceIn(0, 100) ?: DEFAULT_SHARPNESS, npuSync = entries[NPU_SYNC] == "1", - signatureFix = entries[SIGFIX] == "1", + signatureFix = entries[SIGFIX] != "0", ) } @@ -83,7 +83,8 @@ object GameUpscaler { put(ENGINE, choice.engine.id) put(SHARPNESS, choice.sharpness.coerceIn(0, 100).toString()) if (choice.npuSync) put(NPU_SYNC, "1") - if (choice.signatureFix && choice.mode == Mode.DLSS) put(SIGFIX, "1") + // DLSS games need NGX to accept the bridge DLLs; on unless the player switched it off (stored as "0"). + if (choice.mode == Mode.DLSS) put(SIGFIX, if (choice.signatureFix) "1" else "0") } fun withChoice(config: GameEnvironment.Config, scope: String, choice: Choice?): GameEnvironment.Config { diff --git a/app/src/test/java/com/droiddeck/launcher/core/GameUpscalerTest.kt b/app/src/test/java/com/droiddeck/launcher/core/GameUpscalerTest.kt index 6b43ae3b1f..b571c5f901 100644 --- a/app/src/test/java/com/droiddeck/launcher/core/GameUpscalerTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/core/GameUpscalerTest.kt @@ -49,6 +49,16 @@ class GameUpscalerTest { assertEquals(GameUpscaler.Engine.SGSR2, GameUpscaler.Engine.byId("sgsr2_gpu")) } + @Test fun dlssGamesHaveTheSignatureFixOnUnlessSwitchedOff() { + val saved = GameEnvironment.Config().withEntries("7", mapOf(GameUpscaler.MODE to "dlss")) + assertTrue(GameUpscaler.choice(saved, "7")!!.signatureFix) + assertEquals("1", GameUpscaler.entries(GameUpscaler.Choice(GameUpscaler.Mode.DLSS))[GameUpscaler.SIGFIX]) + val off = GameUpscaler.entries(GameUpscaler.Choice(GameUpscaler.Mode.DLSS, signatureFix = false)) + assertEquals("0", off[GameUpscaler.SIGFIX]) + val reread = GameUpscaler.choice(GameEnvironment.Config().withEntries("7", off), "7")!! + assertFalse(reread.signatureFix) + } + @Test fun theControlFileUsesTheLayersKeys() { assertEquals("enabled=1\nbackend=fsr4_1_lite_gpu\nsharpness=0.55\nnpu_sync=0\n", GameUpscaler.controlText(GameUpscaler.Engine.FSR4_LITE_GPU, 55, npuSync = false, enabled = true)) diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-game-env b/tools/linuxfs/overlay/usr/local/bin/droiddeck-game-env index 780a5c075d..f7877601c6 100755 --- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-game-env +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-game-env @@ -1273,8 +1273,8 @@ def upscale_settings(env, prefix): result["DXVK_ENABLE_NVAPI"] = "1" result["WINE_HIDE_NVIDIA_GPU"] = "0" dxvk = 'dxgi.hideNvidiaGpu = False; dxgi.customVendorId = 10de; dxgi.customDeviceId = 1f08; dxgi.customDeviceDesc = "NVIDIA GeForce RTX 2060"' - if env.get("DROIDDECK_UPSCALE_SIGFIX") == "1": - result["DROIDDECK_UPSCALE_SIGFIX"] = "1" + # NGX rejects the bridge DLLs without the signature fix; on unless this game switched it off ("0"). + result["DROIDDECK_UPSCALE_SIGFIX"] = "0" if env.get("DROIDDECK_UPSCALE_SIGFIX") == "0" else "1" try: if prefix and upscale_registry(prefix): notes.append("NVIDIA NGX registry entries added to the prefix (DLSS mode)") diff --git a/tools/tests/test_game_environment.py b/tools/tests/test_game_environment.py index dc593c8aaf..a1328b50bd 100644 --- a/tools/tests/test_game_environment.py +++ b/tools/tests/test_game_environment.py @@ -101,6 +101,14 @@ 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_turns_the_signature_fix_on_unless_switched_off(self): + env, _ = MODULE["upscale_settings"]({"DROIDDECK_UPSCALE_MODE": "dlss"}, None) + self.assertEqual("1", env["DROIDDECK_UPSCALE_SIGFIX"]) + env, _ = MODULE["upscale_settings"]({"DROIDDECK_UPSCALE_MODE": "dlss", "DROIDDECK_UPSCALE_SIGFIX": "0"}, None) + self.assertEqual("0", env["DROIDDECK_UPSCALE_SIGFIX"]) + env, _ = MODULE["upscale_settings"]({"DROIDDECK_UPSCALE_MODE": "fsr"}, None) + self.assertNotIn("DROIDDECK_UPSCALE_SIGFIX", env) + def test_a_game_started_on_xess_without_the_runtime_says_so(self): prefix = tempfile.mkdtemp() self.addCleanup(shutil.rmtree, prefix, True) diff --git a/tools/upscale/bridges/README.md b/tools/upscale/bridges/README.md index a600b1463a..8e68421ac5 100644 --- a/tools/upscale/bridges/README.md +++ b/tools/upscale/bridges/README.md @@ -56,7 +56,7 @@ pack (`tools/packs/build.sh`), whose entries are `bridges/{x86_64,aarch64}-windo | --- | --- | --- | | `DROIDDECK_UPSCALE_BACKEND` (then `DROIDDECK_UPSCALE_ENGINE`, `WINLATOR_FSR4_BACKEND`, `WINLATOR_FSR4_ENGINE`) | `fsr4_1_full_npu` | Backend the bridges assume until the layer writes its live control word: `fsr3_gpu`, `xess3_gpu`, `sgsr2_gpu`, `fsr4_1_lite_npu`, `fsr4_1_full_npu`, `fsr4_1_lite_gpu`, `fsr4_1_full_gpu` (`fsr4_0_npu` = `fsr4_1_full_npu`) | | `DROIDDECK_UPSCALE_VRAM_MB` (then `WINLATOR_FSR4_VRAM_MB`, `WRAPPER_VMEM_MAX_SIZE`) | DXGI adapter 0, else 12 GB | VRAM `nvapi64.dll` reports (512-65536 MB) | -| `DROIDDECK_UPSCALE_SIGFIX=1` | off | `nvapi64.dll` patches the import tables of loaded modules (LoadLibrary*, GetProcAddress, GetFileAttributes*, CreateFileW, Reg*), redirects `nvngx`/`_nvngx` loads to `C:\windows\system32\_nvngx.dll`, fakes the NVIDIA signature-override registry keys, forces `WinVerifyTrust` success and redirects `CryptQueryObject` for `nvngx`/`amd_fidelityfx*`, so games that signature-check NGX load the bridge. Never applied to rdr2.exe, playrdr2.exe or gta5.exe | +| `DROIDDECK_UPSCALE_SIGFIX=1` | on in DLSS mode (`droiddeck-game-env` sets `1` unless the game stores `0`) | `nvapi64.dll` patches the import tables of loaded modules (LoadLibrary*, GetProcAddress, GetFileAttributes*, CreateFileW, Reg*), redirects `nvngx`/`_nvngx` loads to `C:\windows\system32\_nvngx.dll`, fakes the NVIDIA signature-override registry keys, forces `WinVerifyTrust` success and redirects `CryptQueryObject` for `nvngx`/`amd_fidelityfx*`, so games that signature-check NGX load the bridge. Never applied to rdr2.exe, playrdr2.exe or gta5.exe | | `DROIDDECK_UPSCALE_LOG=1` | off | Hook messages appended to `C:\windows\temp\wl_fsr4_bridge.log` | ## Changes from the fork @@ -64,7 +64,8 @@ pack (`tools/packs/build.sh`), whose entries are `bridges/{x86_64,aarch64}-windo - Until upstream r5, D3D11 NGX reported DLSS unavailable here (the fork returned success and rendered nothing). Since r5 the D3D11 entry points reach the Vulkan layer through DXVK's interop (`wl_dxvk_interop.h`), as upstream does. -- The `nvapi64.dll` hooks are off unless `DROIDDECK_UPSCALE_SIGFIX=1`; the fork always installed them. +- The `nvapi64.dll` hooks follow `DROIDDECK_UPSCALE_SIGFIX`, which DLSS games get as `1` unless switched off (the fork + always installed them). Without them NGX rejects the bridges (DLSS sample: `GetFeatureRequirements` PlatformError). - Logging is off unless `DROIDDECK_UPSCALE_LOG=1`; the fork always wrote the log. - `DROIDDECK_UPSCALE_*` variables are read first, the fork's names after them (`dd_env.h`). - `fsr4_seam_proto.h` is included from this folder instead of `../fsr4npu/`.