feat(settings): add your own DLSS 5 files on Windows #328
Labels
No labels
area/build
area/install
area/mods
area/saves
area/tooling
area/ui
area/updates
ci: approved
good first issue
gpu/amd
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
platform/linux
platform/steam-deck
platform/windows
priority
critical
priority
high
priority
low
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/LongshotLauncher!328
Loading…
Reference in a new issue
No description provided.
Delete branch "pmwork-personal/LongshotLauncher:feat/dlss5-files-rust"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Longshot runs NVIDIA's DLSS 5 since Longshot #2503, and on RTX 20, 30 and 40 the community FP16 file since Longshot #2513, but it never ships or downloads either file: today players copy
nvngx_dlssnr.dllinto a folder by hand. With this, they add the files they already have in Settings, and the launcher copies each one once to the folder every version's game looks in.This is #282 (the same feature for the C# launcher) ported to the Rust launcher, which replaced it in #284, with the fix from #282's review for a replace that is stopped half way (L6). #282 is closed in favour of this one.
What changed
ngxfolder comes first.%LOCALAPPDATA%\Longshot\ngx\nvngx_dlssnr.dlland%LOCALAPPDATA%\Longshot\ngx\fp16\nvngx_dlssnr.dll, whatever the file was called. Longshot'sgpu/vk/vk_dlss.cpplooks there afterRX_VK_DLSS_DIRand the game folder'sngx.RX_VK_DLSS_DIRand not a link: an environment variable works only when the launcher starts the game and would override a player's own; with a copy the player can move or delete the original.ngxfolder, work as before.src/dlss5.rs): a record beside the copies,.longshot-launcher-placed.txt(its name starts with a dot, nevernvngx_). Each line holds a copy's bytes, last write time, file identity (volume and file index on Windows, device and inode elsewhere) and SHA-256. A file the record does not match is the player's: put there by hand (Longshot's guide has players do that), or changed since. Its row says "Put here by hand", it has no Remove, and Storage and Remove everything leave it out.pending., then the copy is moved over the old one in one step, then the record takes it as placed. Whichever copy is in place after a crash or power loss between the steps still matches the record, so it stays the launcher's. The next Settings check settles a pending line (in place: placed; not in place: dropped), never while an Add or Remove runs. If the record cannot be written, the Add stops and the old copy stays.Local\LongshotLauncher.Dlss5Files) besides the launcher's own lock. Settling skips while another launcher works.MZ) and has a DLSS 5 model's size..longshot-launcher-*.tmp: NGX never takes it).gpu/vk/dlss_nr_model.hkFp16Known(size and SHA-256CDFA6C1E…FEABF3ED) is the FP16 file. Any other file must carry a valid embedded signature whose signer's organisation (the certificate subject's O attribute alone) is NVIDIA Corporation (WinVerifyTrust, offline: NGX loads only NVIDIA-signed files), and its description must say DLSSNR: then it is NVIDIA's file. Anything else is refused, another NVIDIA DLL with its own reason.%LOCALAPPDATA%\Longshotdown may be a junction or a symbolic link: the launcher never writes or deletes through one, and never removes a linkedfp16folder. A link above it (an AppData or profile folder moved to another drive) is the system's, and allowed.fp16andngxfolders when they are empty. It never touches a file in a game folder, a file put there by hand, or the file it was copied from.src/dlss5/tests.rs: the places, when the section shows, the RTX series by name, how one Add sorts the two files (the FP16 file without asking NVIDIA's check, NVIDIA's check on the copy), files refused before and after the copy, replace, remove and the empty folders, a file put there by hand, a replacement with the same size and time, an edit in place caught before a delete, a damaged record, a record that cannot be written, an Add stopped before and after the move and the record settled after it, a junction (Windows) or symbolic link (Linux) at the ancestor,ngxandfp16, a file held by the game (Windows), the file in place picked again by another path, a linkedfp16folder left alone, a link above the Longshot folder, a stale temporary copy cleaned up (and a fresh one and another file kept), an Add that settles a stopped one, a record that cannot be read, an Add that asks before replacing a file put there by hand (and asks again when that file changed before the answer), the same file already in place (taken over, or already the launcher's: nothing copied), one launcher at a time through the named mutex (Windows), and on Windows the real check (an unsigned file, Microsoft's own DLLs, NVIDIA'snvapi64.dllwhen present, also under the temporary name). The test files are a few MB and made in the test; no NVIDIA file is in the repository. An ignored test,real_dlss5_files, runs the real files whenLONGSHOT_DLSS5_NVIDIA/LONGSHOT_DLSS5_FP16name them.src/storage/cleanup.rs: Remove everything takes the launcher's copy and leaves one put there by hand.tests/test_launcher_core.py --longshot: the launcher's FP16 list is the pinned Longshot'skFp16Known. CI's sparse checkout getsgpu/vk/dlss_nr_model.hfor it.Cargo.toml: the windows-sys features for WinTrust and CryptoAPI (no new crate;Cargo.lockunchanged).docs/ci.mdnames the new comparison.Testing
Tested (Windows 11, RTX 5090; this branch on main
ae619e2):cargo clippy --locked --workspace --all-targets -- -D warnings: clean.cargo fmt --all -- --check: clean.python -I tests/test_launcher_core.py --longshot <pinned 7015105c>: the contract check (with the new FP16 comparison) and the 15 catalogs pass.cargo teston this Windows PC: 178 pass, 11 fail. Mainae619e2on the same PC: 154 pass, the same 11 fail (folders, game recovery, registry, Steam library, versions, home, storage: mostly paths that mix/and\). The 24 new tests pass.test_release.pyat the pinned8f6f6c97: 46 tests pass.real_dlss5_filestest, into a temporary folder; the files are not in the repository): NVIDIA'snvngx_dlssnr.dll310.9.16 (266,424,944 bytes, signed by NVIDIA Corporation) is sorted as NVIDIA's file; the FP16 file (276,162,560 bytes, the known hash) as the FP16 file; Remove deletes both copies, the record and the empty folders; the originals stay.fp16folder that Remove could delete and a settle that did not check for links, a pending line a second stopped Add could overwrite, a record read that hid errors and dropped lines, and a link check that also refused links above the Longshot folder. All are fixed, with tests.LOCALAPPDATA, so nothing of the player's was changed; the real files were only read):ngxby hand: both rows say "Put here by hand (254.1 MiB / 263.4 MiB). The launcher leaves it alone." with no Remove; the RTX 50 line and the hint show.fp16.nvapi64.dll(560 KB) is refused before any copy ("This is not a DLSS 5 file"); NVIDIA's DLSS upscalernvngx_dlss.dll(59 MB, signed by NVIDIA) is refused after the check ("This NVIDIA file is not the DLSS 5 model"). Both rows stay as they were.fp16folder go; NVIDIA's copy and the record stay; no temporary file is left.Still to test
Risks
Screenshots
In the first comment: the section with the files put there by hand, after both Adds, Storage's Your data, and Remove everything's review (this branch's debug build, scratch folders).
Co-Authored-By: Claude Opus 5.5 [email protected]
🤖 Generated with Claude Code
Screenshots of this branch's debug build on Windows 11 with an RTX 5090, in a scratch launcher home and a scratch
LOCALAPPDATA(so the paths are test folders).Settings › Game, with both files put in
ngxby hand: the player's files, no Remove.After Add DLSS 5 file… with each real file: each sorted to its place, now the launcher's copy with Remove.
Storage › Your data (after the FP16 copy was removed in Settings): the launcher's copy of NVIDIA's file, not removable here.
Remove everything's review lists the launcher's copy.
@review
Recommendation: Request changes. Adding a file can silently overwrite the player's only copy of a file they placed by hand, despite the UI saying the launcher leaves it alone. The ownership record can also lose entries when two launcher instances operate concurrently.
The feature lets Windows players copy their existing DLSS 5 files into the shared game folder and manage launcher-owned copies in Settings and Storage. The reported Windows checks show that both real files can be classified and copied, but replacing an existing player-owned file needs an explicit safeguard.
Blocking (1): must change before merging.
src/dlss5.rs:473: Adding a file replaces an existing player-owned file without warning or confirmation, although its row says the launcher leaves it alone. (more on the line) Do: Before replacing a destination that is not launcher-owned, show which file will be replaced and require explicit confirmation, or refuse the replacement until the player moves it.Should fix (2): not blocking, but worth doing before merging.
src/dlss5.rs:140: The lock serializes record updates only within one launcher process. (more on the line) Do: Use a cross-process lock for the shared folder around reconciliation and the complete record update and file operation.ui/main.slint:172: The new navigation lock does not prevent switching Settings categories while a DLSS operation runs. (more on the line) Do: Apply the DLSS busy state to Settings category navigation as well, or keep the operation's progress and result visible across categories.Testing before merging (1) (the change behaves the same on every system: one run of the change itself is enough; it doesn't hold the recommendation)
@fixcan do L1, L2 and L3.Checks: Still running:
CI / Rust formatting, lint and tests (pull_request),CI / Release packages and stable upgrades (pull_request).More: does it help, other systems, switches, what was read
Does it help: Unproven end to end: the author reports successful classification and copying of both real files on Windows 11 with an RTX 5090, but does not report launching Longshot with either copied file. This is not a performance change.
Other systems: The section is hidden on Linux; the ownership and cleanup code is also exercised by synthetic cross-platform tests. Windows file identity, signatures, junctions, Storage and Remove everything are affected. RTX 20–40 gameplay with the shared FP16 copy remains untested in the supplied runs.
Switches: No production switches added, changed or removed. The ignored real-file test accepts LONGSHOT_DLSS5_NVIDIA and LONGSHOT_DLSS5_FP16; neither is set by default.
Reviewed:
507e57972cagainstae619e2dbc: Read AGENTS.md and CONTRIBUTING.md; no review checklist or pull request template was present at the named paths. Read the commit, full new DLSS code and tests, the storage cleanup code, and the UI changes; traced filesystem helpers, navigation and callers. Reviewed the remaining diffs and skimmed translations and reported runs. The rest of the existing UI and storage files were read around the affected paths rather than in full.; nothing run (a code review).Checked and fine:
Testing: Read-only review; no project code, tests or builds were run. Both CI jobs are still running.
Overlaps and merge order: #282 is closed in favour of this Rust implementation; no merge ordering is needed.
Automated code review by BeanBot (gpt-6.1-terra), asked for by llun. Nothing was run; a maintainer decides.
@ -0,0 +137,4 @@#[cfg(not(windows))]{let _ = path;NvidiaCheck::NotNvidiaL2 (should fix): The lock serializes record updates only within one launcher process.
When: An installed and a portable launcher add different models at the same time. Both can read the same record and then write their own version, so one placed file loses its ownership entry and appears as put there by hand; Remove and Remove everything cannot remove it.
Do: Use a cross-process lock for the shared folder around reconciliation and the complete record update and file operation.
@ -0,0 +470,4 @@let mut record = Record::read(folder)?;record.pending.insert(kind, entry.clone());record.write(folder)?;if let Err(error) = copy.persist(&destination) {L1 (blocking): Adding a file replaces an existing player-owned file without warning or confirmation, although its row says the launcher leaves it alone.
When: A player has their only copy of a model in the shared ngx folder and selects another model of the same kind. The temporary copy is persisted over the existing file, destroying the player's file without a chance to keep it.
Do: Before replacing a destination that is not launcher-owned, show which file will be replaced and require explicit confirmation, or refuse the replacement until the player moves it.
@ -166,3 +170,3 @@out property <bool> editing-text: Ink.editing-text;changed page => { Ink.editing-text = false; }out property <bool> navigation-locked: (root.page == Page.launch && Game.show-log) || (root.page == Page.build && Game.folders-open) || Game.busy || Players.busy || Mods.busy || Preferences.cleaning || Preferences.changing-folder || Preferences.romfs-running || Updates.applying;out property <bool> navigation-locked: (root.page == Page.launch && Game.show-log) || (root.page == Page.build && Game.folders-open) || Game.busy || Players.busy || Mods.busy || Preferences.cleaning || Preferences.changing-folder || Preferences.romfs-running || Preferences.dlss5-busy || Updates.applying;L3 (should fix): The new navigation lock does not prevent switching Settings categories while a DLSS operation runs.
When: During a long copy, the category buttons can switch to Storage or another Settings page because their handler checks only Players.busy and Preferences.cleaning. The progress and result disappear from view even though the operation is still running.
Do: Apply the DLSS busy state to Settings category navigation as well, or keep the operation's progress and result visible across categories.
L4 (a game run with a file added in Settings): the launcher's part ends at the file in the folder, and that part is covered. Each copy is byte for byte the file picked (
one_add_tells_the_two_files_apart_by_their_content, and the real-file run), at%LOCALAPPDATA%\Longshot\ngx\nvngx_dlssnr.dllandngx\fp16\nvngx_dlssnr.dll: the folder Longshot'sgpu/vk/vk_dlss.cppsearches afterRX_VK_DLSS_DIRand the game's ownngx.The game side already ran with these very files in that folder, for #282 (RTX 5090, Longshot #2513's build
pr-2513-76252ff9): its log found NVIDIA's file and the known FP16 file in%LOCALAPPDATA%\Longshot\ngxandngx\fp16, and DLSS 5 ran with the FP16 file ("the community FP16 file, direct"). This launcher writes the same bytes to the same paths, so nothing the game reads changes.An RTX 20, 30 or 40 run of the FP16 file tests Longshot #2513's path more than this PR; it needs a card that isn't here (a tester or the Test Farm).
L1 to L3 are being fixed in the next push.
Fixed in
1c3ad76(tests first in the same commit; clippy, rustfmt and the catalogs clean, 178 tests pass here, the same 11 Windows-only failures asmain):L1 (a file put there by hand replaced without asking): an Add now reads the file already in the place before anything moves.
L2 (one launcher at a time): Add, Remove and the settling of the record also hold a mutex named for the folder,
Local\LongshotLauncher.Dlss5Files, shared by every launcher of the user, so a portable and an installed launcher take turns; settling skips while another one works.one_launcher_at_a_time_across_processeschecks it from two threads (the mutex belongs to its thread).L3 (Settings' categories during a copy): the categories and Manage storage wait while an Add or Remove runs, as the top bar already did.
Checked by hand on this branch's debug build (scratch folders): NVIDIA's file put there by hand, added again: taken over, the file not rewritten; a wrong file put in
fp16by hand, the FP16 file added: the dialog below, Cancel kept it, Replace replaced it; a click on Storage during that copy stayed on Game with the progress.@review
Recommendation: Approve. The replacement prompt and navigation lock address the player-facing issues, and the supplied game run shows the shared-folder integration working. Cross-process locking works when the Windows mutex is acquired, though acquisition failure still leaves a minor gap. Recommend approval; not approved on the forge.
Players can add their own DLSS 5 files through Settings and share the copies across game versions. The change adds file validation and ownership tracking, at the cost of additional filesystem and UI logic.
Should fix (1): not blocking, but worth doing before merging.
src/dlss5.rs:140: An operation proceeds without the cross-process lock when mutex acquisition fails. When: If Windows cannot create or wait for the named mutex, exclusive stores None and an Add or Remove can update the record concurrently with another launcher. Do: Return an error when the shared mutex cannot be acquired and stop the operation before accessing the record.@fixcan do L2.Since the last review (on
507e57972c)Resolved: L1 (Adding a file replaces an existing player-owned file without warning or confirmation, alth…); L3 (The new navigation lock does not prevent switching Settings categories while a DLSS operat…); L4 (The supplied runs do not show a game loading a file from the shared folder.)
Still open: L2 (An operation proceeds without the cross-process lock when mutex acquisition fails.)
Checks: Still running:
CI / Rust formatting, lint and tests (pull_request),CI / Release packages and stable upgrades (pull_request).Also noticed (2; not asked for, not blocking)
More: does it help, other systems, switches, what was read
Does it help: Yes. The author reports that both real files were sorted into the expected shared paths on Windows 11, and that Longshot previously loaded those same files from those paths on an RTX 5090. This is not a performance change.
Other systems: The feature is Windows-only; Linux hides the section. Storage and Remove everything use the ownership record, while the named mutex coordinates launcher instances in the same Windows session. An RTX 20–40 game run remains unreported.
Switches: No player-facing switches added or changed. The ignored real-file test uses LONGSHOT_DLSS5_NVIDIA and LONGSHOT_DLSS5_FP16; neither affects normal launcher operation.
Reviewed:
1c3ad768d3againstae619e2dbc: Read AGENTS.md, CONTRIBUTING.md, src/preferences/dlss5.rs and src/dlss5/windows.rs in full; reviewed the fix diff, relevant portions of src/dlss5.rs, its tests, Settings and storage callers. Skimmed translations and the remaining pull-request diff; the other changed code files were not read in full.; nothing run (a code review).Checked and fine:
Testing: No commands from the project or tests were run. The author reports Windows checks and manual tests; both CI jobs are still running.
Overlaps and merge order: LongshotLauncher #282 is closed in favour of this pull request.
Automated code review by BeanBot (gpt-6.1-terra), asked for by llun. Nothing was run; a maintainer decides.
@fix
Recommendation: Approve. The mutex failure path now stops Add, Remove and bulk DLSS file cleanup before they can change the shared record. The fix preserves the feature and the normal wait and nonblocking settle behavior. Recommend approval; not approved on the forge.
What
@fixchangedI changed this pull request: the new head is
4486b37fdb.Changed
Nothing was built or run: the checks run again on the new head.
Players can add their own DLSS 5 files through Settings and share the copies across game versions. The fix adds error handling around the shared mutex at a small complexity cost.
Checks: they run again on this head; a failure shows on the pull request.
Also noticed (3; not asked for, not blocking)
More: does it help, other systems, switches, what was read
Does it help: Yes. The reported Windows tests and manual checks show that the launcher sorts, copies and removes the real files; the author also reports a game run using the same files at the same paths. Mutex failure handling has been checked in code but has not been run on this head.
Other systems: The shared mutex applies on Windows; Linux retains the local lock and does not offer the feature. Remove everything now reports a mutex error instead of removing DLSS files without the lock.
Switches: No switches added or changed by the fix. The feature adds no player setting; the ignored real-file test uses LONGSHOT_DLSS5_NVIDIA and LONGSHOT_DLSS5_FP16 to locate test files.
Reviewed:
4486b37fdbagainstae619e2dbc: Read AGENTS.md, CONTRIBUTING.md, the fix diff, src/preferences/dlss5.rs and src/storage/cleanup.rs in full; inspected the mutex implementation, its callers and the relevant record operations in src/dlss5.rs. The original feature diff, tests, translations, UI and other changed files were not read in full for this re-check.; nothing run (a code review).Checked and fine:
Testing: No commands that run the project or tests were executed. The fix report says tests were not run; CI has not yet run on this head. The PR reports Windows tests and manual feature checks on the preceding head.
Overlaps and merge order: None found in the supplied context; #282 is closed in favor of this pull request.
Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, after its fix. Nothing was run; a maintainer decides.