Files
DroidDeck/tools/upscale/bridges
The412Banner 491106ac3c feat(upscale): build the DLSS / FSR / XeSS bridge DLLs from source and ship them as the upscale pack
Ports the Windows x64 bridge DLLs of michaelisomer-cyber/Winlator-NeuralScale (a0ab6b0f,
GPL-3.0) to tools/upscale/bridges. They replace a game's nvngx, nvapi64, FidelityFX,
FSR 2/3 and XeSS DLLs inside Wine and hand each frame to the Android Vulkan layer
through the unchanged fsr4_seam_proto.h buffers.

- build.sh builds the 12 DLLs with MinGW-w64 GCC, deterministically, checks each
  export table against its .def and stamps them as Wine builtins (winebuild --builtin
  signature at 0x40), into x86_64-windows/ and aarch64-windows/.
- CI: recipe upscale-bridges into linuxfs/usr/local/lib/droiddeck-upscale/bridges,
  kept out of the APK and shipped as the upscale add-on pack, like dirt.
- D3D11 NGX now reports DLSS unavailable instead of succeeding and rendering nothing.
- The nvapi64 signature hooks run only with DROIDDECK_UPSCALE_SIGFIX=1, logging only
  with DROIDDECK_UPSCALE_LOG=1; DROIDDECK_UPSCALE_* variables are read before the
  fork's WINLATOR_FSR4_* names.
2026-11-29 22:51:53 -05:00
..

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

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_0_npu Backend the bridges assume until the layer writes its live control word: fsr3_gpu, xess3_gpu, fsr4_0_npu, fsr4_1_lite_npu, fsr4_1_full_npu, fsr4_1_lite_gpu, fsr4_1_full_gpu
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_LOG=1 off Hook messages appended to C:\windows\temp\wl_fsr4_bridge.log

Changes from the fork

  • D3D11 NGX reports DLSS unavailable (SuperSampling.Available 0, feature requirements AdapterUnsupported, CreateFeature/EvaluateFeature return NVSDK_NGX_Result_FAIL_FeatureNotSupported). The fork returned success and rendered nothing, because D3D11 has no route to the Vulkan layer.
  • The nvapi64.dll hooks are off unless DROIDDECK_UPSCALE_SIGFIX=1; the fork always installed them.
  • 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 at a0ab6b0f770e1a6786b4e68def46b4edb8baafd0 (app/src/main/cpp/fsr4npu_win/), GPL-3.0. That fork builds on 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.