mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-06 04:55:44 +00:00
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.
87 lines
6.6 KiB
Markdown
87 lines
6.6 KiB
Markdown
# Upscale bridge DLLs
|
|
|
|
Windows x86-64 DLLs that stand in for a game's DLSS, FidelityFX (FSR 2, FSR 3, FidelityFX API) and
|
|
XeSS libraries inside Wine. They do not upscale anything themselves: each frame's colour, depth,
|
|
motion-vector and output images are written into a host-visible Vulkan mailbox buffer, and a
|
|
`vkCmdUpdateBuffer` "doorbell" on a marker buffer tells the Android Vulkan layer to record the
|
|
upscaler into the game's command buffer. The layer finds both buffers by their sizes and magic
|
|
numbers. `fsr4_seam_proto.h` is that contract and is a verbatim copy of the fork's
|
|
`app/src/main/cpp/fsr4npu/fsr4_seam_proto.h` (sha256 `a9f614c53ae9209edf0fa9c5acb0a27fdf923c08026362b23f60e1bcb39acd15`).
|
|
It must stay byte-identical to the layer's copy. If the layer does not acknowledge a frame,
|
|
the bridge blits the render-resolution image to the output (bilinear) so the game never shows
|
|
stale memory. D3D12 games reach Vulkan through vkd3d-proton's `ID3D12DXVKInteropDevice1`.
|
|
|
|
| DLL | Source | Export list | Replaces |
|
|
| --- | --- | --- | --- |
|
|
| `amd_fidelityfx_vk.dll` | `wl_ffx_bridge.c` | `wl_ffx_bridge.def` | FidelityFX API (`ffxCreateContext`, `ffxDispatch`, ...) |
|
|
| `amd_fidelityfx_dx12.dll`, `amd_fidelityfx_upscaler_vk.dll`, `amd_fidelityfx_upscaler_dx12.dll`, `amd_fidelityfx_loader_dx12.dll` | copies of `amd_fidelityfx_vk.dll` | | the same API under the other SDK file names |
|
|
| `ffx_fsr3upscaler_x64.dll` | `wl_fsr23_bridge.c` | `ffx_fsr3upscaler_x64.def` | FSR 3.0 / 3.1 upscaler |
|
|
| `ffx_fsr2_api_x64.dll` | `wl_fsr23_bridge.c` | `ffx_fsr2_api_x64.def` | FSR 2.0 / 2.1 / 2.2 |
|
|
| `libxess.dll` | `wl_xess_bridge.c` | `libxess.def` | Intel XeSS 1.3 / 2.0 (D3D12 + Vulkan) |
|
|
| `nvngx.dll` | `wl_ngx_bridge.c` | `nvngx.def` | NVIDIA NGX / DLSS Super Resolution (Vulkan + D3D12) |
|
|
| `_nvngx.dll`, `nvngx_dlss.dll` | copies of `nvngx.dll` | | the names games and Streamline load NGX by |
|
|
| `nvapi64.dll` | `wl_nvapi_shim.c` (+ `wl_ngx_hooks.h`) | `nvapi64.def` | NVAPI, reporting an RTX 2060 so games offer DLSS |
|
|
|
|
`wl_fsr23_bridge.c` exports both the FSR 2 and FSR 3 entry points, so both DLLs carry all 21.
|
|
`nvngx.dll` exports the 88 `.def` names plus 9 that only its source marks `__declspec(dllexport)`. `build.sh`
|
|
fails when a DLL's exports (from `x86_64-w64-mingw32-objdump -p`) differ from its `.def` plus
|
|
its source's `dllexport` names.
|
|
|
|
When the XeSS 3.0 backend is selected, `wl_xess3_direct.h` loads Intel's XeSS SDK runtime as
|
|
`wl_xess_official.dll` (from the DLL search path, then `C:\windows\system32`). When it is missing or
|
|
fails, the frame goes to the layer flagged `WLFSR4_FLAG_XESS_FALLBACK` (FSR 3.1 on the GPU). That DLL is Intel's prebuilt binary and is not built here.
|
|
|
|
## Build
|
|
|
|
```sh
|
|
bash tools/upscale/bridges/build.sh OUT
|
|
```
|
|
|
|
Needs `x86_64-w64-mingw32-gcc` (Ubuntu `gcc-mingw-w64-x86-64`) and `python3`. The output is
|
|
deterministic (`-s`, `-Wl,--no-insert-timestamp`, linked under the bare DLL name because `ld`
|
|
derives the image base from the output path). Every DLL is stamped as a Wine builtin the way
|
|
`winebuild --builtin` does it: the 32-byte `"Wine builtin DLL"` signature, zero-padded, at file
|
|
offset 0x40 (`pe.py stamp`). Wine then loads them from `WINEDLLPATH` when the override is
|
|
`builtin`. The same x86-64 files are installed to `OUT/x86_64-windows/` and
|
|
`OUT/aarch64-windows/`, because the ARM64EC Wine loads x86-64 builtins from the latter.
|
|
|
|
CI builds them with the `upscale-bridges` component recipe into
|
|
`app/src/main/assets/linuxfs/usr/local/lib/droiddeck-upscale/bridges/`. The APK may not carry
|
|
Windows executables (`tools/release/runtime_inputs.py`), so they ship in the `upscale` add-on
|
|
pack (`tools/packs/build.sh`), whose entries are `bridges/{x86_64,aarch64}-windows/<dll>`.
|
|
|
|
## Environment
|
|
|
|
| Variable | Default | Effect |
|
|
| --- | --- | --- |
|
|
| `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` | 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
|
|
|
|
- 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 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/`.
|
|
- Built with Ubuntu's MinGW-w64 GCC (msvcrt) instead of the fork's PowerShell script; flags as in
|
|
its `build_win_dlls.ps1` plus `-s` and `-Wl,--no-insert-timestamp`. The fork stamped the
|
|
signature at install time; here it is stamped at build time.
|
|
|
|
Seam protocol, struct layouts, magics and backend IDs are unchanged.
|
|
|
|
## Credits and licence
|
|
|
|
Ported from [michaelisomer-cyber/Winlator-NeuralScale](https://github.com/michaelisomer-cyber/Winlator-NeuralScale)
|
|
at `a0ab6b0f770e1a6786b4e68def46b4edb8baafd0`, updated to `71c140d9e5586f659251c3ebc602f2d21923655c` (r5: D3D11
|
|
DLSS through DXVK's interop, `wl_dxvk_interop.h`) (`app/src/main/cpp/fsr4npu_win/`), GPL-3.0. That fork
|
|
builds on [StevenMXZ/Winlator-Ludashi](https://github.com/StevenMXZ/Winlator-Ludashi). The NGX
|
|
and NVAPI shims follow OptiScaler's approach (and fakenvapi's NVAPI interface). These files stay
|
|
under the GPL-3.0, the licence of this repository (`LICENSE`); modified files say so in their
|
|
first line.
|