From 7d3185fca6bbb5cf57dce047e73013fef9c22b18 Mon Sep 17 00:00:00 2001 From: chrg6 Date: Tue, 10 Nov 2026 06:38:45 -0500 Subject: [PATCH] Let an AppImage without NVIDIA's DLSS library download it beside the game on machines with NVIDIA's driver. An AppImage made with --no-dlss carries no NVIDIA file, and its builds had no DLSS. After a build its AppRun now downloads the pinned libnvidia-ngx-dlss.so. from NVIDIA's DLSS SDK repository when /proc/driver/nvidia exists and the game folder holds no such library, checks its SHA-256 and writes the notice that names its licence. NX2NAVI_NO_DLSS=1 skips it, and a failed download is a warning. Pull request #290 by loteran, written again on top of the pin that came with the bundled library: - the version, file name, checksum and address come from tools/dlss_pin.py when the AppImage is made, instead of a second copy in the script, and the notice is dlss_pin's own text, carried in the kit; - it runs only when no library is beside the game, so it adds nothing to a build that placed the kit's and leaves a player's own version alone; - the download goes to a name that does not start like the library's: the game takes any file with that prefix, and an interrupted download would have been one. The generated AppRun passes bash -n; nothing was run on Linux here. Co-Authored-By: Claude Fable 5.2 --- docs/README-BuildKit.md | 4 +++- tools/make_appimage.py | 37 +++++++++++++++++++++++++++++++++++-- 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/docs/README-BuildKit.md b/docs/README-BuildKit.md index 4a46042c..5ce23971 100644 --- a/docs/README-BuildKit.md +++ b/docs/README-BuildKit.md @@ -117,7 +117,9 @@ game's own scaling and swapchain as they are (the log says so). NVIDIA DLSS (RTX cards) needs the driver's own `libnvidia-ngx.so.1` on the library path (the proprietary driver's utilities package, `nvidia-utils` on Arch) and NVIDIA's DLSS library `libnvidia-ngx-dlss.so.` beside `ocarina`. The AppImage's kit has the library in `bin/` with `libnvidia-ngx-dlss-NOTICE.txt`, which names its licence, -and the build copies both beside `ocarina` (`tools/make_appimage.py --no-dlss` leaves it out). From a source checkout, +and the build copies both beside `ocarina` (`tools/make_appimage.py --no-dlss` leaves it out; such an AppImage +downloads the same pinned library from NVIDIA's repository after a build on a machine with NVIDIA's driver, checks its +SHA-256 and writes the notice, unless `NX2NAVI_NO_DLSS=1` is set or a library is already there). From a source checkout, or to use another DLSS version, put the library there yourself: NVIDIA publishes it as `lib/Linux_x86_64/rel/libnvidia-ngx-dlss.so.` in [its DLSS repository](https://github.com/NVIDIA/DLSS), tagged `v`, and `tools/dlss_pin.py` names the version the kit carries. Later builds keep a library they did not diff --git a/tools/make_appimage.py b/tools/make_appimage.py index 0debe26c..d64b3890 100644 --- a/tools/make_appimage.py +++ b/tools/make_appimage.py @@ -7,7 +7,8 @@ player's PC from their own dump with tools/make_game.py, as NX2navi-Setup.exe do The AppImage holds no game files: the kit's tools/, recomp/, runtime/ and docs, the shader translator built by tools/build_xlate.py (bin/nx2navi_xlate), NVIDIA's DLSS library with its notice (bin/, tools/dlss_pin.py: downloaded from NVIDIA's DLSS SDK repository and checked, or --dlss; not with --no-dlss), the pinned Vulkan Memory Allocator -header, and a relocatable CPython 3.14 (python-build-standalone, as `uv python install 3.14` puts in +header (an AppImage made without the library downloads it after a build on machines with NVIDIA's driver: AppRun's +get_dlss), and a relocatable CPython 3.14 (python-build-standalone, as `uv python install 3.14` puts in ~/.local/share/uv/python) with numpy, lz4, zstandard, fonttools and pillow, and with --prompt-art the button art make_game.py's prompts step draws from (as make_kit.py --prompt-art: the pictures tools/prompt_art.py art_files names, into the kit's prompt-art folder; without it that step is skipped and the game keeps the Switch prompts). zbic, the GPL @@ -98,8 +99,34 @@ esac NUP="$1" OUT="${2:-$HOME/Games/Ocarina}" [ -f "$NUP" ] || { echo "error: $NUP is not a file" >&2; usage; exit 1; } +# NVIDIA's DLSS for Linux, which the game's DLSS modes need beside it (runtime/resolution.c finds +# libnvidia-ngx-dlss.so. there). The build places the kit's when this file carries it; when it does not +# (made with --no-dlss) and the game folder holds none, the version tools/dlss_pin.py pins is downloaded from +# NVIDIA's DLSS SDK repository, on machines with NVIDIA's driver only, checked against its SHA-256 and kept +# unmodified with the notice that names its licence. NX2NAVI_NO_DLSS=1 skips it. +DLSS_VERSION=@DLSS_VERSION@ +DLSS_SO=@DLSS_SO@ +DLSS_SHA256=@DLSS_SHA256@ +DLSS_URL=@DLSS_URL@ +get_dlss() { + [ -e /proc/driver/nvidia/version ] && [ -z "${NX2NAVI_NO_DLSS:-}" ] || return 0 + compgen -G "$OUT/libnvidia-ngx-dlss.so.*" >/dev/null && return 0 # the kit's, or one the player put there + echo "Downloading NVIDIA DLSS $DLSS_VERSION for Linux (NVIDIA RTX SDKs License) ..." + # not under the library's name: the game takes any file whose name starts like it + local tmp="$OUT/.dlss-download.part" + rm -f "$tmp" + if curl -fsSL -o "$tmp" "$DLSS_URL" && echo "$DLSS_SHA256 $tmp" | sha256sum -c --status; then + mv -f "$tmp" "$OUT/$DLSS_SO" + cp -f "$KIT/docs/libnvidia-ngx-dlss-NOTICE.txt" "$OUT/libnvidia-ngx-dlss-NOTICE.txt" + else + rm -f "$tmp" + echo "warning: DLSS could not be downloaded or did not match its checksum; the game runs without it" >&2 + fi +} + echo "Building into $OUT with $jobs compiles at a time (${mem_gb} GB of RAM); this takes 10 to 25 minutes." run_make_game --nup "$NUP" --out "$OUT" --jobs "$jobs" || exit $? +get_dlss # play.sh: the environment the game wants on this machine, then the game { @@ -168,6 +195,9 @@ def main(): shutil.copy2(ROOT / f, kit / f) (kit / 'docs').mkdir() shutil.copy2(ROOT / 'docs' / 'README-BuildKit.md', kit / 'docs' / 'README-BuildKit.md') + # the notice AppRun's get_dlss writes beside a library it downloads; its sha256 line is the one make_game.py reads + pin = dlss_pin.pin(linux=True) + (kit / 'docs' / pin.notice).write_text(dlss_pin.notice_text(linux=True), encoding='utf-8') (kit / 'bin').mkdir() for f in ('nx2navi_xlate', 'nx2navi_xlate.id'): shutil.copy2(xlate / f, kit / 'bin' / f) @@ -189,7 +219,10 @@ def main(): for cache in py.rglob('__pycache__'): shutil.rmtree(cache, ignore_errors=True) - (app / 'AppRun').write_text(APPRUN, encoding='utf-8') + apprun = APPRUN + for key, value in (('VERSION', dlss_pin.VERSION), ('SO', pin.name), ('SHA256', pin.sha256), ('URL', pin.url)): + apprun = apprun.replace(f'@DLSS_{key}@', value) + (app / 'AppRun').write_text(apprun, encoding='utf-8') (app / 'AppRun').chmod(0o755) (app / 'nx2navi.desktop').write_text(DESKTOP, encoding='utf-8') from PIL import Image # the window icon of runtime/nx2navi.ico, as PNG