fix(dlss): DLSS 5 is let go before the process exits, so its exit no longer faults the GPU #2807

Open
bulldogsajr22 wants to merge 2 commits from bulldogsajr22/Longshot:fix/dlss5-exit-release into main
Contributor

Summary

With DLSS 5 (Neural Rendering) On, about one exit in ten ended in an NVIDIA GPU fault at the second the game closed: Windows' event log shows nvlddmkm event 13, "Graphics SM Warp Exception ... MMU Fault", then event 153, a GPU reset (the screens go black for a moment). Once, the reset never came back and the PC froze. With DLSS 5 Off, it never happened. It started with DLSS 5 (#2503, #2513, in nightly-835); nothing like it came before on the same PC and driver.

The cause: DLSS 5's feature was never let go at the exit. Every exit goes through mkwvk_close_asked and then ends the process (ExitProcess, or TerminateProcess for Windows' stop requests). That close lets DLSS Frame Generation go (dlss_fg_close) but not DLSS 5. So the process ended with frames that used DLSS 5 still on the GPU, while the model's library (nvngx_dlssnr) freed its own memory as it was unloaded.

To see it on main: DLSS 5 On, at 5120x2160 on an RTX 5090, load a save, play a minute, quit (the window's close, the Insert menu's Quit or Restart now, or the control bridge's quit), and repeat. About one exit in ten logs the fault and the reset (Event Viewer, Windows Logs, System, source nvlddmkm).

What changes:

  • mkwvk_close_asked calls dlss_nr_close first, before Streamline's shutdown returns early. Every exit goes through it: the window's close, the Insert menu's Quit and Restart now, the control bridge's quit and relaunch, and Windows' stop requests (Ctrl+C, log-off, shut down). On Linux, the SDL window's close goes through it too.
  • dlss_nr_close marks the exit, and the recording thread lets DLSS 5 go the way it does in play (drop_nr, under the locks it takes in play). This happens from the chain, or from each present (temporal_idle) when no frame is upscaled (a menu, the title). Nothing of DLSS 5's is made again after that. The release itself (temporal_later) runs once the GPU is done with every frame that used the model.
  • The close waits for the release, as dlss_fg_close waits for the queue: about 20 to 90 ms in the game. It stops waiting after 0.5 s with no frame presented (a hung renderer), and after 2 s at most; the model is then left to the process's end, as on main, and the log says why. DLSS 5's lock is tried, never waited for, so a recording thread stalled inside NGX with it held (in the model's making or its run) can't hold the close past those limits. A minimised window keeps presenting, so it is let go as in play.
  • A game held by Pause in background (#2786) goes on when the close is asked. Held (minimised or behind another window), it presents no frame, so DLSS 5 would be left made to the process's end. rx_close_asked, which every exit goes through, now ends the hold (hos_background_close_asked) before the renderer's close, and the game is never held again while it closes: its frames come and DLSS 5 is let go as in play.
  • Both DLSS 5 files are let go the same way (nr_release_feature): NVIDIA's file through NGX, and the community FP16 file through the direct path. In play, nothing changes but one relaxed atomic load in the chain and at each present.

Read first: dlss_nr_close and the closing branches of dlss_nr_idle and dlss_nr_chain in gpu/vk/vk_dlss.cpp, then temporal_idle in gpu/vk/vk_temporal.cpp, hos_background_close_asked in host/background_pause.c, and tests/test_dlss_nr_exit.py.

See #2503, #2513 (DLSS 5), #2786 (Pause in background).

Testing

Tested: Windows 11 Pro (26H2, build 26300), Ryzen 9 9950X3D, RTX 5090, NVIDIA 621.40, 5120x2160 (21:9), ultrawide, DLSS 5 On: NVIDIA's file through NGX, and the community FP16 file through the direct path (RX_VK_DLSS_NR_MODEL=fp16, the known file by its SHA-256).

In the game, driven through the game's control bridge (HOS_CONTROL): launch, load the save, play 30 to 60 s, exit, then check Windows' event log for nvlddmkm faults and resets. 172 exits with DLSS 5 On, no GPU fault (no nvlddmkm event of any kind in that time). Every exit that had DLSS 5 made logs vk: DLSS 5 Neural Rendering: let go for the exit (N ms, its frames done on the GPU), then DLSS Frame Gen's own line, except the 4 held runs below, which ran before the hold change.

  • The head, 6011e3f3f (the review's change: the close tries DLSS 5's lock, never waits for it), on main @ 01d6878b3, headless: NVIDIA's file, 6 exits, 4 quits in play and 2 with the pause menu open, let go in 18 to 51 ms.
  • This PR's code before the review (built at 388b97c29, on main @ 01d6878b3; b6ac561c6 after it changed only tests/), headless:
    • NVIDIA's file: 6 exits, 4 quits in play and 2 with the pause menu open, let go in 18 to 49 ms.
    • The community FP16 file, the direct path (each log: DLSS 5 runs the community FP16 file, direct): 6 exits, 4 in play and 2 in the pause menu, let go in 19 to 53 ms.
  • With Pause in background On (ab5b52f74, the same change as this head, before the clean-up below), windowed:
    • 6 exits minimised, held (pause: the game is held), then closed: each logs pause: the game goes on after 7.8 s held (the game is closing), then the release (50 to 54 ms).
    • 10 more: 4 quits in play, 3 window closes, and 3 minimised and closed without a hold (the window never in front first, so the hold did not start). Released in 51 to 88 ms.
    • Before the hold change (on main @ 01d6878b3 with the rest of this PR): 4 exits held and closed, DLSS 5 left after 0.5 s (no frame presented for 0.5 s), no fault.
  • On main @ 22d0d200 (where the fault was measured), with this PR's DLSS 5 part (dd122933a): 130 exits, mixed:
    • 60 quits in play (the bridge's quit);
    • 30 with the pause menu open (no frame upscaled: DLSS 5 let go through the presents alone);
    • 30 by the window's close, as a player closes it (WM_CLOSE);
    • 10 minimised, then closed (ShowWindow, then WM_CLOSE). The game keeps presenting while minimised (about 90 fps by the bridge's status, IsIconic true), so DLSS 5 is let go as in play; 3 more such exits checked that (let go in about 50 ms).
    • 80 of these ran on an earlier version whose wait stopped only after 2 s; the other 50 on this logic.
  • The bridge's relaunch (the same close as the Insert menu's Restart now): DLSS 5 let go (49 ms), no fault. The game started again did not come back in this headless test setup, the same on main. On main @ 22d0d200 with DLSS 5 On, that restart's exit faulted the GPU (nvlddmkm 13, then 153).
  • Before: on main @ 22d0d200, the same loop with DLSS 5 Off: 60 exits, no fault (DLSS 5 never loads). With it On, the day's exits: 7 faults in 62, the last at exit 11 of the loop (p = 0.013 against Off, Fisher's exact test, two-sided).
  • Since ab5b52f74, a clean-up, the behaviour the same:
    • nr_resources alone decides whether anything of DLSS 5's is made (the feature and its parameters are only made with it set);
    • dlss_nr_chain takes its lock once;
    • the closing temporal_idle no longer rewrites holding.

Checks:

  • tests/test_dlss_nr_exit.py (new) fails on main and passes here, with g++ and clang++ on Linux, and built by llvm-mingw's clang++ and run on Windows. It compiles the real dlss_nr_close, dlss_nr_idle, the start of dlss_nr_chain, drop_nr's DLSS 5 part, and vk_temporal.cpp's later, free_dead and the start of temporal_idle, with a fake renderer whose GPU runs two submissions behind. It checks:

    • in play, from a frame with no upscale, and Off within its grace: let go before the close returns, only after the GPU is done with every frame that used it, and not made again;
    • never made: no wait;
    • no frame presented: left after 0.5 s;
    • the GPU never done: left after 2 s;
    • the recording thread stalled with DLSS 5's lock held: left 0.5 s after the last frame, without waiting for the lock (a watchdog fails a close that waits); never made, the lock only busy at the close's first look: no line;
    • mkwvk_close_asked calls it before Streamline's shutdown returns.
  • Undoing each part of the fix makes it fail:

    • the chain's or the idle's closing branch, or the drop in either;
    • the free at closing, or temporal_idle woken at closing;
    • the wait for the release;
    • the 0.5 s stop, the 2 s stop, or the present count;
    • the lock waited for instead of tried, or the silent return when nothing was made;
    • the call in mkwvk_close_asked, or that call moved after Streamline's shutdown.

    A close with no time limit fails at 10 s of the test's clock rather than hanging the check.

  • tests/test_pause_background.py gains a check that fails on main (the game is still held 100 looks after a close was asked) and passes here, with gcc and clang on Linux, and built by llvm-mingw's clang and run on Windows.

    • It compiles background_pause.c from its state on and rx_close_asked, with stand-ins for Windows' window and event calls.
    • A game held while minimised and then closed goes on, is woken before the renderer's close, and is never held again.
    • Undoing any of these makes it fail: the closing check, the flag, the wake, the call in rx_close_asked, or the call moved after the renderer's close.
  • tests/test_dlss_nr_chain.py gains a check, failing on main, that at the exit the chain makes and runs nothing and lets go what was made. tests/test_dlss_nr_actions.py's stand-ins now know the exit flag. Both pass with g++ and clang++.

  • Builds of this PR's code:

    • The game's Windows build (llvm-mingw, with NGX and Streamline) compiles every changed file with no warning.
    • The Linux renderer (longshot-builder dev compile --only renderer, system clang, without NGX: the stubs) builds longshot_vk.so, 271 units, no warning in them.
    • host/background_pause.c and host/rx_backend.c with -fsyntax-only -Wall -Wextra on Linux, gcc and clang: the same warnings as main.
  • mise run test on the head: 853 passed, 33 failed, 10 skipped. The same 33 fail on main @ 01d6878b3 (852 passed there). Each fails on main the same way, none for this PR's code: several on fixtures behind main's own code (pause_background_now and movie_now undeclared, among them test_crt_options.py and test_upscaler_round_trip.py, which read vk_dlss.cpp), and test_screensaver.py, which stubs rx_close_asked, on display.c's show_game_window. mise run lint passes.

    The 37 checks that fail on main too

    test_bug_report.py, test_cloth_kernels.py, test_control_picture.py, test_crash_record.py, test_crt_options.py, test_dav1d_av1.py, test_dev_update.py, test_framegen_hdr.py, test_framegen_resources.py, test_fsr3_shaders.py, test_fsr3fi_hud_layer.py, test_fsr3fi_hudless_colour.py, test_guest_holes.py, test_host_shaders.py, test_input_background.py, test_lifter.py, test_linux_pressure.py, test_loaded_modules_drop.py, test_log_levels.py, test_menu_keys.py, test_oot_cloth.py, test_option_ids.py, test_perf_send.py, test_pipeline_tour.py, test_present_source_crop.py, test_program_cache_cleanup.py, test_program_cache_one_variant.py, test_screensaver.py, test_switch_table.py, test_temporal_present_bandwidth.py, test_upscaler_round_trip.py, test_vcore_video_acquire.py, test_video_catchup.py, test_video_hold_early.py, test_video_input_limit.py, test_windows_on_linux.py, test_xinput_thread.py

Still to test:

  • Linux, NVIDIA, DLSS 5 On (RX_VK_DLSS_NR_LINUX=1, the experiment): quit in play and with the pause menu open, expecting the "let go for the exit" line and no NVRM: Xid fault in dmesg (@Beanstalk DLSS 5 exit on Linux NVIDIA with RX_VK_DLSS_NR_LINUX=1: quit in play and in the pause menu, check the log line and dmesg)
  • Windows, RTX 20/30/40, DLSS 5 with the community FP16 file (the direct path, run here on an RTX 50 only): quit in play, expecting the "let go for the exit" line and no nvlddmkm event (@Beanstalk DLSS 5 FP16 file exit on RTX 20-40: quit in play, check the log line and the event log)

Measurements

Verdict: the exit's GPU fault with DLSS 5 On is gone: 0 in 172 exits here, against 7 in 62 on main (p < 0.0001, Fisher's exact test, two-sided). The exit takes 17 to 88 ms more for the release; play is unchanged.

Setup: Windows 11, RTX 5090, NVIDIA 621.40, 5120x2160 ultrawide, DLSS 5 On. Launch, load the save (Shadow Temple), play 30 to 60 s, exit, then check Windows' event log. The exit's time is from the game's log line. After: the head 6011e3f3f (6 exits), 388b97c29, this PR's code before the review (12; b6ac561c6 after it changed only tests/), ab5b52f74 (16, Pause in background On; 4 more before its hold change) and this PR's DLSS 5 part on main @ 22d0d200 (134: the 130, the 3 minimised checks and the relaunch), as Testing says.

Before: main @ 22d0d200 After: this PR @ 6011e3f3f
Exits with an nvlddmkm MMU fault, DLSS 5 On 7 of 62 (11%) 0 of 172
Exits with DLSS 5 Off 0 of 60 (unchanged: nothing is made)
DLSS 5 let go before the process ends never every exit that made it, but the 4 held before the hold change
The community FP16 file (the direct path) not run 6 of 6 let go, no fault
Held by Pause in background, then closed (no #2786 then) the hold ends, then let go: 6 of 6
Time the close waits for it (median: in play / pause menu / window's close / minimised) 0 47 / 19 / 69 / 51.5 ms (17 to 88), before the head; the head's: 46 to 51 / 18 to 19 ms
test_dlss_nr_exit.py fails passes
test_pause_background.py fails (held after the close), on main @ 01d6878b3 passes

In play, the cost is one relaxed atomic load per chain and per present; there is nothing to measure there.

Risks

  • A slower exit: the close waits for DLSS 5's release, about 20 to 90 ms. It waits for nothing when DLSS 5 was never made, and at most 0.5 s with no frame presented or 2 s in all. The fault came at the last moment of the exit, so a stuck release leaves things as on main.
  • A renderer that presents nothing at the close (hung) leaves DLSS 5 to the process's end after 0.5 s, as on main. By then no frame of it is on the GPU; that case (Pause in background's hold, before this PR ended it at the close) ran 4 times with no fault.
  • A held game goes on while it closes: for the close's few frames, the game runs behind a minimised or covered window, as it does without Pause in background. Its sound stays off (Mute in background is on while Pause in background is).
  • The picture at the exit: for the last few frames, the upscaler's picture is shown without DLSS 5. They are drawn after the quit, while the window closes.
  • The order of the close: DLSS 5 is let go on the recording thread under the locks it already takes in play (the chain's, then DLSS's), so no lock order is new. The close thread only tries DLSS's lock, between its 2 ms sleeps, and holds no lock while it waits.
  • Another DLSS 5 file: a newer NVIDIA file goes through the same NGX release call it uses in play; another community file is not loaded until its hash is added (gpu/vk/dlss_nr_model.h).
  • Turned off by a revert. Nothing changes for players after updating (no setting, save or cache).

Checklist

Ready for review

  • One topic, on current main; the title is a Conventional Commit.
  • Tested on my own PC, in the game for a change the game runs, as Testing says.
  • mise run test passes (any failure that also fails on main is named).
  • Measured against main, or Measurements says why there is nothing to measure.
  • No game files, build output or hand-edited generated files; third_party/ untouched; nothing GPL-incompatible.

When it applies

  • A fix: a game-free test that fails on main and passes here.
  • A check under tests/ that reads changed source is updated, not weakened.
  • Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths.
  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.

Ready to merge

  • Everything in Still to test has run, its results in Tested.
  • Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers").
  • Approved in review, every comment answered.
  • CI passes on the head; on current main, measured again or a comment says why the numbers still hold.

🤖 Generated with Claude Code

## Summary With **DLSS 5** (Neural Rendering) On, about one exit in ten ended in an NVIDIA GPU fault at the second the game closed: Windows' event log shows `nvlddmkm` event 13, "Graphics SM Warp Exception ... MMU Fault", then event 153, a GPU reset (the screens go black for a moment). Once, the reset never came back and the PC froze. With DLSS 5 Off, it never happened. It started with DLSS 5 (#2503, #2513, in nightly-835); nothing like it came before on the same PC and driver. The cause: DLSS 5's feature was never let go at the exit. Every exit goes through `mkwvk_close_asked` and then ends the process (`ExitProcess`, or `TerminateProcess` for Windows' stop requests). That close lets DLSS Frame Generation go (`dlss_fg_close`) but not DLSS 5. So the process ended with frames that used DLSS 5 still on the GPU, while the model's library (`nvngx_dlssnr`) freed its own memory as it was unloaded. To see it on `main`: DLSS 5 On, at 5120x2160 on an RTX 5090, load a save, play a minute, quit (the window's close, the Insert menu's Quit or Restart now, or the control bridge's `quit`), and repeat. About one exit in ten logs the fault and the reset (Event Viewer, Windows Logs, System, source `nvlddmkm`). What changes: - **`mkwvk_close_asked` calls `dlss_nr_close` first**, before Streamline's shutdown returns early. Every exit goes through it: the window's close, the Insert menu's Quit and Restart now, the control bridge's quit and relaunch, and Windows' stop requests (Ctrl+C, log-off, shut down). On Linux, the SDL window's close goes through it too. - **`dlss_nr_close` marks the exit**, and the recording thread lets DLSS 5 go the way it does in play (`drop_nr`, under the locks it takes in play). This happens from the chain, or from each present (`temporal_idle`) when no frame is upscaled (a menu, the title). Nothing of DLSS 5's is made again after that. The release itself (`temporal_later`) runs once the GPU is done with every frame that used the model. - **The close waits for the release**, as `dlss_fg_close` waits for the queue: about 20 to 90 ms in the game. It stops waiting after 0.5 s with no frame presented (a hung renderer), and after 2 s at most; the model is then left to the process's end, as on `main`, and the log says why. DLSS 5's lock is tried, never waited for, so a recording thread stalled inside NGX with it held (in the model's making or its run) can't hold the close past those limits. A minimised window keeps presenting, so it is let go as in play. - **A game held by Pause in background (#2786) goes on when the close is asked.** Held (minimised or behind another window), it presents no frame, so DLSS 5 would be left made to the process's end. `rx_close_asked`, which every exit goes through, now ends the hold (`hos_background_close_asked`) before the renderer's close, and the game is never held again while it closes: its frames come and DLSS 5 is let go as in play. - **Both DLSS 5 files** are let go the same way (`nr_release_feature`): NVIDIA's file through NGX, and the community FP16 file through the direct path. In play, nothing changes but one relaxed atomic load in the chain and at each present. Read first: `dlss_nr_close` and the closing branches of `dlss_nr_idle` and `dlss_nr_chain` in `gpu/vk/vk_dlss.cpp`, then `temporal_idle` in `gpu/vk/vk_temporal.cpp`, `hos_background_close_asked` in `host/background_pause.c`, and `tests/test_dlss_nr_exit.py`. See #2503, #2513 (DLSS 5), #2786 (Pause in background). ## Testing **Tested:** Windows 11 Pro (26H2, build 26300), Ryzen 9 9950X3D, RTX 5090, NVIDIA 621.40, 5120x2160 (21:9), ultrawide, DLSS 5 On: NVIDIA's file through NGX, and the community FP16 file through the direct path (`RX_VK_DLSS_NR_MODEL=fp16`, the known file by its SHA-256). In the game, driven through the game's control bridge (`HOS_CONTROL`): launch, load the save, play 30 to 60 s, exit, then check Windows' event log for `nvlddmkm` faults and resets. **172 exits with DLSS 5 On, no GPU fault** (no `nvlddmkm` event of any kind in that time). Every exit that had DLSS 5 made logs `vk: DLSS 5 Neural Rendering: let go for the exit (N ms, its frames done on the GPU)`, then DLSS Frame Gen's own line, except the 4 held runs below, which ran before the hold change. - **The head, `6011e3f3f`** (the review's change: the close tries DLSS 5's lock, never waits for it), on `main` @ 01d6878b3, headless: NVIDIA's file, 6 exits, 4 quits in play and 2 with the pause menu open, let go in 18 to 51 ms. - **This PR's code before the review** (built at `388b97c29`, on `main` @ 01d6878b3; `b6ac561c6` after it changed only `tests/`), headless: - NVIDIA's file: 6 exits, 4 quits in play and 2 with the pause menu open, let go in 18 to 49 ms. - The community FP16 file, the direct path (each log: `DLSS 5 runs the community FP16 file, direct`): 6 exits, 4 in play and 2 in the pause menu, let go in 19 to 53 ms. - **With Pause in background On** (`ab5b52f74`, the same change as this head, before the clean-up below), windowed: - 6 exits minimised, held (`pause: the game is held`), then closed: each logs `pause: the game goes on after 7.8 s held (the game is closing)`, then the release (50 to 54 ms). - 10 more: 4 quits in play, 3 window closes, and 3 minimised and closed without a hold (the window never in front first, so the hold did not start). Released in 51 to 88 ms. - Before the hold change (on `main` @ 01d6878b3 with the rest of this PR): 4 exits held and closed, DLSS 5 left after 0.5 s (`no frame presented for 0.5 s`), no fault. - **On `main` @ 22d0d200** (where the fault was measured), with this PR's DLSS 5 part (`dd122933a`): 130 exits, mixed: - 60 quits in play (the bridge's `quit`); - 30 with the pause menu open (no frame upscaled: DLSS 5 let go through the presents alone); - 30 by the window's close, as a player closes it (`WM_CLOSE`); - 10 minimised, then closed (`ShowWindow`, then `WM_CLOSE`). The game keeps presenting while minimised (about 90 fps by the bridge's status, `IsIconic` true), so DLSS 5 is let go as in play; 3 more such exits checked that (let go in about 50 ms). - 80 of these ran on an earlier version whose wait stopped only after 2 s; the other 50 on this logic. - **The bridge's `relaunch`** (the same close as the Insert menu's Restart now): DLSS 5 let go (49 ms), no fault. The game started again did not come back in this headless test setup, the same on `main`. On `main` @ 22d0d200 with DLSS 5 On, that restart's exit faulted the GPU (`nvlddmkm` 13, then 153). - **Before:** on `main` @ 22d0d200, the same loop with DLSS 5 Off: 60 exits, no fault (DLSS 5 never loads). With it On, the day's exits: 7 faults in 62, the last at exit 11 of the loop (p = 0.013 against Off, Fisher's exact test, two-sided). - **Since `ab5b52f74`**, a clean-up, the behaviour the same: - `nr_resources` alone decides whether anything of DLSS 5's is made (the feature and its parameters are only made with it set); - `dlss_nr_chain` takes its lock once; - the closing `temporal_idle` no longer rewrites `holding`. Checks: - `tests/test_dlss_nr_exit.py` (new) fails on `main` and passes here, with g++ and clang++ on Linux, and built by llvm-mingw's clang++ and run on Windows. It compiles the real `dlss_nr_close`, `dlss_nr_idle`, the start of `dlss_nr_chain`, `drop_nr`'s DLSS 5 part, and vk_temporal.cpp's `later`, `free_dead` and the start of `temporal_idle`, with a fake renderer whose GPU runs two submissions behind. It checks: - in play, from a frame with no upscale, and Off within its grace: let go before the close returns, only after the GPU is done with every frame that used it, and not made again; - never made: no wait; - no frame presented: left after 0.5 s; - the GPU never done: left after 2 s; - the recording thread stalled with DLSS 5's lock held: left 0.5 s after the last frame, without waiting for the lock (a watchdog fails a close that waits); never made, the lock only busy at the close's first look: no line; - `mkwvk_close_asked` calls it before Streamline's shutdown returns. - Undoing each part of the fix makes it fail: - the chain's or the idle's closing branch, or the drop in either; - the free at closing, or `temporal_idle` woken at closing; - the wait for the release; - the 0.5 s stop, the 2 s stop, or the present count; - the lock waited for instead of tried, or the silent return when nothing was made; - the call in `mkwvk_close_asked`, or that call moved after Streamline's shutdown. A close with no time limit fails at 10 s of the test's clock rather than hanging the check. - `tests/test_pause_background.py` gains a check that fails on `main` (`the game is still held 100 looks after a close was asked`) and passes here, with gcc and clang on Linux, and built by llvm-mingw's clang and run on Windows. - It compiles `background_pause.c` from its state on and `rx_close_asked`, with stand-ins for Windows' window and event calls. - A game held while minimised and then closed goes on, is woken before the renderer's close, and is never held again. - Undoing any of these makes it fail: the closing check, the flag, the wake, the call in `rx_close_asked`, or the call moved after the renderer's close. - `tests/test_dlss_nr_chain.py` gains a check, failing on `main`, that at the exit the chain makes and runs nothing and lets go what was made. `tests/test_dlss_nr_actions.py`'s stand-ins now know the exit flag. Both pass with g++ and clang++. - Builds of this PR's code: - The game's Windows build (llvm-mingw, with NGX and Streamline) compiles every changed file with no warning. - The Linux renderer (`longshot-builder dev compile --only renderer`, system clang, without NGX: the stubs) builds `longshot_vk.so`, 271 units, no warning in them. - `host/background_pause.c` and `host/rx_backend.c` with `-fsyntax-only -Wall -Wextra` on Linux, gcc and clang: the same warnings as `main`. - `mise run test` on the head: 853 passed, 33 failed, 10 skipped. The same 33 fail on `main` @ 01d6878b3 (852 passed there). Each fails on `main` the same way, none for this PR's code: several on fixtures behind `main`'s own code (`pause_background_now` and `movie_now` undeclared, among them `test_crt_options.py` and `test_upscaler_round_trip.py`, which read `vk_dlss.cpp`), and `test_screensaver.py`, which stubs `rx_close_asked`, on `display.c`'s `show_game_window`. `mise run lint` passes. <details><summary>The 37 checks that fail on main too</summary> `test_bug_report.py`, `test_cloth_kernels.py`, `test_control_picture.py`, `test_crash_record.py`, `test_crt_options.py`, `test_dav1d_av1.py`, `test_dev_update.py`, `test_framegen_hdr.py`, `test_framegen_resources.py`, `test_fsr3_shaders.py`, `test_fsr3fi_hud_layer.py`, `test_fsr3fi_hudless_colour.py`, `test_guest_holes.py`, `test_host_shaders.py`, `test_input_background.py`, `test_lifter.py`, `test_linux_pressure.py`, `test_loaded_modules_drop.py`, `test_log_levels.py`, `test_menu_keys.py`, `test_oot_cloth.py`, `test_option_ids.py`, `test_perf_send.py`, `test_pipeline_tour.py`, `test_present_source_crop.py`, `test_program_cache_cleanup.py`, `test_program_cache_one_variant.py`, `test_screensaver.py`, `test_switch_table.py`, `test_temporal_present_bandwidth.py`, `test_upscaler_round_trip.py`, `test_vcore_video_acquire.py`, `test_video_catchup.py`, `test_video_hold_early.py`, `test_video_input_limit.py`, `test_windows_on_linux.py`, `test_xinput_thread.py` </details> **Still to test:** - Linux, NVIDIA, DLSS 5 On (`RX_VK_DLSS_NR_LINUX=1`, the experiment): quit in play and with the pause menu open, expecting the "let go for the exit" line and no `NVRM: Xid` fault in `dmesg` (@Beanstalk DLSS 5 exit on Linux NVIDIA with RX_VK_DLSS_NR_LINUX=1: quit in play and in the pause menu, check the log line and dmesg) - Windows, RTX 20/30/40, DLSS 5 with the community FP16 file (the direct path, run here on an RTX 50 only): quit in play, expecting the "let go for the exit" line and no `nvlddmkm` event (@Beanstalk DLSS 5 FP16 file exit on RTX 20-40: quit in play, check the log line and the event log) ## Measurements **Verdict:** the exit's GPU fault with DLSS 5 On is gone: 0 in 172 exits here, against 7 in 62 on `main` (p < 0.0001, Fisher's exact test, two-sided). The exit takes 17 to 88 ms more for the release; play is unchanged. Setup: Windows 11, RTX 5090, NVIDIA 621.40, 5120x2160 ultrawide, DLSS 5 On. Launch, load the save (Shadow Temple), play 30 to 60 s, exit, then check Windows' event log. The exit's time is from the game's log line. After: the head `6011e3f3f` (6 exits), `388b97c29`, this PR's code before the review (12; `b6ac561c6` after it changed only `tests/`), `ab5b52f74` (16, Pause in background On; 4 more before its hold change) and this PR's DLSS 5 part on `main` @ 22d0d200 (134: the 130, the 3 minimised checks and the relaunch), as Testing says. | | Before: main @ 22d0d200 | After: this PR @ 6011e3f3f | |---|---|---| | Exits with an `nvlddmkm` MMU fault, DLSS 5 On | 7 of 62 (11%) | 0 of 172 | | Exits with DLSS 5 Off | 0 of 60 | (unchanged: nothing is made) | | DLSS 5 let go before the process ends | never | every exit that made it, but the 4 held before the hold change | | The community FP16 file (the direct path) | not run | 6 of 6 let go, no fault | | Held by Pause in background, then closed | (no #2786 then) | the hold ends, then let go: 6 of 6 | | Time the close waits for it (median: in play / pause menu / window's close / minimised) | 0 | 47 / 19 / 69 / 51.5 ms (17 to 88), before the head; the head's: 46 to 51 / 18 to 19 ms | | `test_dlss_nr_exit.py` | fails | passes | | `test_pause_background.py` | fails (held after the close), on main @ 01d6878b3 | passes | In play, the cost is one relaxed atomic load per chain and per present; there is nothing to measure there. ## Risks - **A slower exit:** the close waits for DLSS 5's release, about 20 to 90 ms. It waits for nothing when DLSS 5 was never made, and at most 0.5 s with no frame presented or 2 s in all. The fault came at the last moment of the exit, so a stuck release leaves things as on `main`. - **A renderer that presents nothing at the close** (hung) leaves DLSS 5 to the process's end after 0.5 s, as on `main`. By then no frame of it is on the GPU; that case (Pause in background's hold, before this PR ended it at the close) ran 4 times with no fault. - **A held game goes on while it closes:** for the close's few frames, the game runs behind a minimised or covered window, as it does without Pause in background. Its sound stays off (Mute in background is on while Pause in background is). - **The picture at the exit:** for the last few frames, the upscaler's picture is shown without DLSS 5. They are drawn after the quit, while the window closes. - **The order of the close:** DLSS 5 is let go on the recording thread under the locks it already takes in play (the chain's, then DLSS's), so no lock order is new. The close thread only tries DLSS's lock, between its 2 ms sleeps, and holds no lock while it waits. - **Another DLSS 5 file:** a newer NVIDIA file goes through the same NGX release call it uses in play; another community file is not loaded until its hash is added (`gpu/vk/dlss_nr_model.h`). - Turned off by a revert. Nothing changes for players after updating (no setting, save or cache). ## Checklist ### Ready for review - [x] One topic, on current `main`; the title is a Conventional Commit. - [x] Tested on my own PC, in the game for a change the game runs, as Testing says. - [x] `mise run test` passes (any failure that also fails on `main` is named). - [x] Measured against `main`, or Measurements says why there is nothing to measure. - [x] No game files, build output or hand-edited generated files; `third_party/` untouched; nothing GPL-incompatible. ### When it applies - [x] A fix: a game-free test that fails on `main` and passes here. - [x] A check under `tests/` that reads changed source is updated, not weakened. - [x] Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths. - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. ### Ready to merge - [ ] Everything in Still to test has run, its results in Tested. - [ ] Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers"). - [ ] Approved in review, every comment answered. - [ ] CI passes on the head; on current `main`, measured again or a comment says why the numbers still hold. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The check for the exit-time GPU fault with DLSS 5 On, before its fix: on
main it fails for the bug.

- The real dlss_nr_close, dlss_nr_idle, dlss_nr_chain's start and
  drop_nr's DLSS 5 part, with vk_temporal.cpp's later, free_dead and
  temporal_idle's start, compiled with a fake renderer whose GPU is two
  submissions behind.
- At the exit in play, from a frame with no upscale (a menu, the title),
  and while Off within its grace: the feature is let go before the close
  returns, only once the GPU is done with every frame that used it, and
  is not made again.
- Never made: no wait. A renderer that stopped presenting: left 0.5 s
  after its last frame, as before; frames presented but never done on
  the GPU: left after 2 s.
- mkwvk_close_asked lets DLSS 5 go before Streamline's shutdown returns.
- test_dlss_nr_chain.py: at the exit the chain runs and makes nothing
  and lets go what was made; test_dlss_nr_actions.py's stand-ins know the
  exit flag.
- test_pause_background.py: a game held by Pause in background (#2786)
  and closed goes on, woken before the renderer's close waits for its
  frames, and is never held again; background_pause.c from its state on
  and rx_close_asked, compiled with stand-ins for Windows' calls. On main
  it stays held, and DLSS 5 is left made as the process ends.

main has no dlss_nr_close: a stand-in that does nothing, as main does at
the exit, so the check fails on the feature still made.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012w3Td4tpZNoc9ZWbbfNyrH
fix(dlss): DLSS 5 is let go before the process exits, so its exit no longer faults the GPU
Some checks failed
PR description / Title and description (pull_request_target) Successful in 6s
CI / What the change needs (pull_request) Has been cancelled
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Has been cancelled
CI / Third-party parts and guide screenshots (pull_request) Has been cancelled
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
beanstalk/approval waiting for a BigBean's 👍 on the request
388b97c29c
With DLSS 5 On, about one exit in ten ended in an NVIDIA "MMU Fault" and a
GPU reset at the second the process ended, and once in a reset that never
came back (the PC froze). Its feature was never let go at the exit: the
process ended (ExitProcess) with frames that used it still on the GPU,
while the model's library let its own memory go as it was unloaded. DLSS
Frame Generation is let go at the exit (dlss_fg_close); DLSS 5 was not.

- mkwvk_close_asked, which every exit goes through (the window's close,
  the Insert menu's Quit and Restart now, the control bridge's quit,
  Windows' stop requests), calls dlss_nr_close first, before Streamline's
  shutdown returns.
- dlss_nr_close marks the exit: DLSS 5 is made no more, and the recording
  thread lets it go as it does in play (drop_nr, under the chain's lock),
  from the chain or from each present (temporal_idle), so also with no
  upscale. Its release (temporal_later) runs once the frames that used it
  are done on the GPU. The close waits for that while frames come, 2 s
  at most; a renderer that stopped presenting (0.5 s with no frame: hung,
  or Windows ending the session within its 4 s) leaves it to the
  process's end, as before. A minimised window keeps presenting.
- A game held by Pause in background (#2786: minimised or behind
  another window, no frame presented) goes on when a close is asked:
  rx_close_asked ends the hold (hos_background_close_asked) before the
  renderer's close, and it is never held again, so its frames come and
  DLSS 5 is let go as in play rather than left to the process's end.
- Both DLSS 5 paths (NVIDIA's file through NGX, the community FP16 file
  direct) are let go the same way (nr_release_feature). Nothing changes
  in play: one relaxed load in the chain and at each present.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012w3Td4tpZNoc9ZWbbfNyrH
Author
Contributor

Tested in game: Windows 11, RTX 5090, NVIDIA 621.40, 5120x2160, DLSS 5 On, Shadow Temple save: 165 exits (quit in play, pause menu, window close, minimised then closed, Pause in background held then closed, the bridge's relaunch; NVIDIA's file and the community FP16 file), no nvlddmkm fault, each logging DLSS 5 let go for the exit in 17 to 86 ms. main @ 22d0d200: 7 faults in 62 exits.

Tested in game: Windows 11, RTX 5090, NVIDIA 621.40, 5120x2160, DLSS 5 On, Shadow Temple save: 165 exits (quit in play, pause menu, window close, minimised then closed, Pause in background held then closed, the bridge's relaunch; NVIDIA's file and the community FP16 file), no nvlddmkm fault, each logging DLSS 5 let go for the exit in 17 to 86 ms. main @ 22d0d200: 7 faults in 62 exits.
Member

Possibly related, for context:

  • PR #620 WIP: feat(dlss): compose neural rendering over native HDR — Earlier DLSS 5 lifecycle and HDR implementation; this PR addresses teardown of its feature.
  • PR #2293 WIP: fix(vk): a temporal upscaler's passes have device-lost checkpoints of their own — Separate open temporal-renderer device-loss diagnostics; not the same shutdown fault.
Possibly related, for context: - PR #620 WIP: feat(dlss): compose neural rendering over native HDR — Earlier DLSS 5 lifecycle and HDR implementation; this PR addresses teardown of its feature. - PR #2293 WIP: fix(vk): a temporal upscaler's passes have device-lost checkpoints of their own — Separate open temporal-renderer device-loss diagnostics; not the same shutdown fault.
bulldogsajr22 force-pushed fix/dlss5-exit-release from 388b97c29c
Some checks failed
PR description / Title and description (pull_request_target) Successful in 6s
CI / What the change needs (pull_request) Has been cancelled
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Has been cancelled
CI / Third-party parts and guide screenshots (pull_request) Has been cancelled
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
beanstalk/approval waiting for a BigBean's 👍 on the request
to b6ac561c62
Some checks failed
PR description / Title and description (pull_request_target) Successful in 6s
CI / What the change needs (pull_request) Has been cancelled
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Has been cancelled
CI / Third-party parts and guide screenshots (pull_request) Has been cancelled
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
2026-11-29 15:19:44 +00:00
Compare
Author
Contributor

Pushed b6ac561c6 (the test commit amended, the fix replayed on it; gpu/ and host/ unchanged from 388b97c29):

  • tests/test_pause_background.py: the close fixture's rx_end_claim stand-in is declared off Windows only, as in rx_backend.c. On Windows it was unused, and -Werror stopped the check from compiling. Both new checks now also build with llvm-mingw and run on Windows, and pass.
  • tests/test_dlss_nr_exit.py: an unused field and include path removed; the docstring rewrapped.
  • Description: the counts recounted from every run's log (166 exits, 0 faults; 16 on ab5b52f74, a window close there released in 88 ms), the medians recomputed, and both Fisher's p-values two-sided. mise run test: 849 passed, the same 37 failing as on main.
Pushed `b6ac561c6` (the test commit amended, the fix replayed on it; `gpu/` and `host/` unchanged from `388b97c29`): - `tests/test_pause_background.py`: the close fixture's `rx_end_claim` stand-in is declared off Windows only, as in `rx_backend.c`. On Windows it was unused, and `-Werror` stopped the check from compiling. Both new checks now also build with llvm-mingw and run on Windows, and pass. - `tests/test_dlss_nr_exit.py`: an unused field and include path removed; the docstring rewrapped. - Description: the counts recounted from every run's log (166 exits, 0 faults; 16 on `ab5b52f74`, a window close there released in 88 ms), the medians recomputed, and both Fisher's p-values two-sided. `mise run test`: 849 passed, the same 37 failing as on `main`.
bulldogsajr22 changed title from WIP: fix(dlss): DLSS 5 is let go before the process exits, so its exit no longer faults the GPU to fix(dlss): DLSS 5 is let go before the process exits, so its exit no longer faults the GPU 2026-11-29 15:20:09 +00:00
Author
Contributor

On the Measurements' main (22d0d200 against the base, 01d6878b3): the numbers still hold.

  • Of the 25 commits between them, two touch the exit's path: #2786 (Pause in background), which this PR handles (Testing, the held closes), and #2741, where the game's log file is written. mkwvk_close_asked is the same in both, and nothing of DLSS 5's, Streamline's or the temporal chain's changed.
  • The After side was run on 01d6878b3 too: this PR's code at 388b97c29 (12 exits, NVIDIA's file and the community FP16 file) and on ab5b52f74 (20, Pause in background On). No fault, and every release logged.
  • Before, on 01d6878b3 itself: the same DLSS 5 On exits are not run again on purpose, since about one in ten resets the GPU, and once a reset never came back.
On the Measurements' `main` (22d0d200 against the base, 01d6878b3): the numbers still hold. - Of the 25 commits between them, two touch the exit's path: #2786 (Pause in background), which this PR handles (Testing, the held closes), and #2741, where the game's log file is written. `mkwvk_close_asked` is the same in both, and nothing of DLSS 5's, Streamline's or the temporal chain's changed. - The After side was run on 01d6878b3 too: this PR's code at `388b97c29` (12 exits, NVIDIA's file and the community FP16 file) and on `ab5b52f74` (20, Pause in background On). No fault, and every release logged. - Before, on 01d6878b3 itself: the same DLSS 5 On exits are not run again on purpose, since about one in ten resets the GPU, and once a reset never came back.
Author
Contributor

@Beanstalk linux nvidia, and an RTX 20, 30 or 40 on Windows: this head (b6ac561c), the two items of Still to test. Each needs a DLSS 5 file the farm PC has itself (Longshot doesn't download one, docs/user/dlss5.md); without it, say so, and that item stays open.

  1. Linux, NVIDIA: start with RX_VK_DLSS_NR_LINUX=1. The native NGX must offer neural rendering: if the Graphics tab shows no DLSS 5 row, stop there and say so.
    Windows, RTX 20, 30 or 40: the community FP16 file as nvngx_dlssnr.dll in %LOCALAPPDATA%\Longshot\ngx\fp16\. The game's log says DLSS 5 runs the community FP16 file, direct.
  2. Graphics: DLSS 5 On. Load the repo save kokiri-start and play about 30 s.
  3. Quit with the Insert menu's Quit. Then start again and quit with the pause menu open, and once more by closing the window: three exits, five times each if there's time.

Expected at every exit: the game's log has vk: DLSS 5 Neural Rendering: let go for the exit (N ms, its frames done on the GPU), and no GPU fault (Linux: no NVRM: Xid line in dmesg from that time; Windows: no nvlddmkm event in Event Viewer, Windows Logs, System).

@Beanstalk linux nvidia, and an RTX 20, 30 or 40 on Windows: this head (`b6ac561c`), the two items of Still to test. Each needs a DLSS 5 file the farm PC has itself (Longshot doesn't download one, docs/user/dlss5.md); without it, say so, and that item stays open. 1. **Linux, NVIDIA:** start with `RX_VK_DLSS_NR_LINUX=1`. The native NGX must offer neural rendering: if the Graphics tab shows no DLSS 5 row, stop there and say so. **Windows, RTX 20, 30 or 40:** the community FP16 file as `nvngx_dlssnr.dll` in `%LOCALAPPDATA%\Longshot\ngx\fp16\`. The game's log says `DLSS 5 runs the community FP16 file, direct`. 2. Graphics: DLSS 5 **On**. Load the repo save `kokiri-start` and play about 30 s. 3. Quit with the Insert menu's Quit. Then start again and quit with the pause menu open, and once more by closing the window: three exits, five times each if there's time. Expected at every exit: the game's log has `vk: DLSS 5 Neural Rendering: let go for the exit (N ms, its frames done on the GPU)`, and no GPU fault (Linux: no `NVRM: Xid` line in `dmesg` from that time; Windows: no `nvlddmkm` event in Event Viewer, Windows Logs, System).
Member

@bulldogsajr22 only members of BigBeans can start the farm.

One of them can approve this request by reacting 👍 to it or to this comment. This request was for 388b97c, and the PR has changed since (6011e3f), so a 👍 no longer approves it. Comment @Beanstalk again to ask for the new commit.

@bulldogsajr22 only members of `BigBeans` can start the farm. ~~One of them can approve this request by reacting 👍 to it or to this comment.~~ This request was for `388b97c`, and the PR has changed since (`6011e3f`), so a 👍 no longer approves it. Comment `@Beanstalk` again to ask for the new commit.
Member
@review
BeanBot left a comment

Recommendation: Approve. The release substantially reduced exit faults in the reported RTX 5090 runs, but shutdown can wait indefinitely on the DLSS state lock before reaching its timeout. The Linux and older RTX paths also still need their requested game runs. Nothing blocking is left: what remains is for the author before merging (below). Recommend approval; not approved on the forge.

The change retires DLSS 5 before process exit and wakes a game held in the background so it can present the frames needed for retirement. It adds a bounded intended wait to exit, but the lock acquisition itself is unbounded.

Should fix (1): not blocking, but worth doing before merging.

  • L1 gpu/vk/vk_dlss.cpp:1643: The close takes the DLSS state mutex without a timeout before starting, and during, its timed wait. (more on the line) Do: Make observing retirement bounded without waiting indefinitely for s.mu, for example by publishing the retirement state separately and using a timed or nonblocking lock with the same close deadline.

Testing before merging (2) (runs on the systems it can change; it doesn't hold the recommendation)

  • L2: The experimental Linux NVIDIA release path has not yet been exercised in game. When: With RX_VK_DLSS_NR_LINUX=1, quitting in play or from the pause menu uses the new retirement and present path without a reported Linux run showing that it completes safely. Do: Run the requested Linux NVIDIA exits in play and from the pause menu, checking the release log and kernel GPU fault log.
  • L3: The community FP16 direct path has only been run on RTX 50 hardware. When: RTX 20–40 users with the community model take the direct release path, but no reported exit run covers those GPUs. Do: Run the requested Windows RTX 20, 30 or 40 exits with the community FP16 model and check the release and driver event logs.

@fix can do L1.

Checks: Still running: 10 checks.

More: does it help, other systems, switches, what was read

Does it help: Yes on the tested RTX 5090 setup: the author reports 0 faults in 166 exits with variants of the fix versus 7 in 62 on an earlier main commit; 32 after-side exits used the current base. Linux and RTX 20–40 remain untested.

Other systems: The DLSS release path affects NVIDIA on Windows and experimental Linux; the background-pause change affects close behavior independently of GPU. The reported runs cover Windows on RTX 5090, including both model paths and held closes; the requested Linux and older RTX runs remain outstanding.

Switches: None added, changed, or removed.

Reviewed: b6ac561c62 against 01d6878b3f: Read the repository rules, contribution guide, PR template, standards, full production diff, commit messages, shutdown and retirement paths, background-pause implementation, and the new exit and pause test changes. Skimmed the remaining changed test fixtures and surrounding renderer code; the full changed renderer and host files were not read in full. docs/review-checklist.md and the adjacent Tooling checkout were absent.; nothing run (a code review).

Checked and fine:

  • Both commits record AI assistance in trailers.
  • The change adds no game-derived files, generated files, API version changes, or switches.
  • The reported tests include mutation checks for the exit and background-hold branches.
  • CI has no reported head-only failures; checks are still running.

Testing: Read-only review; no builds, tests, or project scripts were run. The author reports 166 fault-free Windows exits and game-free checks against the base.

Overlaps and merge order: Not checked; the network is closed.


Automated code review by BeanBot (gpt-6.1-terra), asked for by llun. Nothing was run; a maintainer decides.

**Recommendation: Approve.** The release substantially reduced exit faults in the reported RTX 5090 runs, but shutdown can wait indefinitely on the DLSS state lock before reaching its timeout. The Linux and older RTX paths also still need their requested game runs. Nothing blocking is left: what remains is for the author before merging (below). Recommend approval; not approved on the forge. The change retires DLSS 5 before process exit and wakes a game held in the background so it can present the frames needed for retirement. It adds a bounded intended wait to exit, but the lock acquisition itself is unbounded. **Should fix (1)**: not blocking, but worth doing before merging. - **L1** `gpu/vk/vk_dlss.cpp:1643`: The close takes the DLSS state mutex without a timeout before starting, and during, its timed wait. (more on the line) **Do:** Make observing retirement bounded without waiting indefinitely for s.mu, for example by publishing the retirement state separately and using a timed or nonblocking lock with the same close deadline. **Testing before merging (2)** (runs on the systems it can change; it doesn't hold the recommendation) - **L2**: The experimental Linux NVIDIA release path has not yet been exercised in game. *When:* With RX_VK_DLSS_NR_LINUX=1, quitting in play or from the pause menu uses the new retirement and present path without a reported Linux run showing that it completes safely. **Do:** Run the requested Linux NVIDIA exits in play and from the pause menu, checking the release log and kernel GPU fault log. - **L3**: The community FP16 direct path has only been run on RTX 50 hardware. *When:* RTX 20–40 users with the community model take the direct release path, but no reported exit run covers those GPUs. **Do:** Run the requested Windows RTX 20, 30 or 40 exits with the community FP16 model and check the release and driver event logs. `@fix` can do L1. **Checks:** Still running: 10 checks. <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Yes on the tested RTX 5090 setup: the author reports 0 faults in 166 exits with variants of the fix versus 7 in 62 on an earlier main commit; 32 after-side exits used the current base. Linux and RTX 20–40 remain untested. **Other systems:** The DLSS release path affects NVIDIA on Windows and experimental Linux; the background-pause change affects close behavior independently of GPU. The reported runs cover Windows on RTX 5090, including both model paths and held closes; the requested Linux and older RTX runs remain outstanding. **Switches:** None added, changed, or removed. **Reviewed:** b6ac561c6255 against 01d6878b3f14: Read the repository rules, contribution guide, PR template, standards, full production diff, commit messages, shutdown and retirement paths, background-pause implementation, and the new exit and pause test changes. Skimmed the remaining changed test fixtures and surrounding renderer code; the full changed renderer and host files were not read in full. docs/review-checklist.md and the adjacent Tooling checkout were absent.; nothing run (a code review). **Checked and fine:** - Both commits record AI assistance in trailers. - The change adds no game-derived files, generated files, API version changes, or switches. - The reported tests include mutation checks for the exit and background-hold branches. - CI has no reported head-only failures; checks are still running. **Testing:** Read-only review; no builds, tests, or project scripts were run. The author reports 166 fault-free Windows exits and game-free checks against the base. **Overlaps and merge order:** Not checked; the network is closed. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by llun. Nothing was run; a maintainer decides.</sub>
@ -1615,0 +1640,4 @@
nr_closing.store(true, std::memory_order_release);
State& s = st();
const auto settled = [&s] {
std::lock_guard lock(s.mu);
Member

L1 (should fix): The close takes the DLSS state mutex without a timeout before starting, and during, its timed wait. A stalled recording thread can therefore prevent the process from closing indefinitely.

When: If the driver or model stalls in feature creation or evaluation while dlss_nr_chain holds s.mu, settled() blocks on that mutex. Neither the 0.5-second no-present timeout nor the two-second limit can run, and the window close cannot reach the existing bounded renderer shutdown.

Do: Make observing retirement bounded without waiting indefinitely for s.mu, for example by publishing the retirement state separately and using a timed or nonblocking lock with the same close deadline.

**L1** (should fix): The close takes the DLSS state mutex without a timeout before starting, and during, its timed wait. A stalled recording thread can therefore prevent the process from closing indefinitely. *When:* If the driver or model stalls in feature creation or evaluation while dlss_nr_chain holds s.mu, settled() blocks on that mutex. Neither the 0.5-second no-present timeout nor the two-second limit can run, and the window close cannot reach the existing bounded renderer shutdown. **Do:** Make observing retirement bounded without waiting indefinitely for s.mu, for example by publishing the retirement state separately and using a timed or nonblocking lock with the same close deadline.
bulldogsajr22 force-pushed fix/dlss5-exit-release from b6ac561c62
Some checks failed
PR description / Title and description (pull_request_target) Successful in 6s
CI / What the change needs (pull_request) Has been cancelled
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Has been cancelled
CI / Third-party parts and guide screenshots (pull_request) Has been cancelled
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
to 6011e3f3f6
Some checks failed
CI / What the change needs (pull_request) Blocked by required conditions
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Blocked by required conditions
CI / Third-party parts and guide screenshots (pull_request) Blocked by required conditions
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Blocked by required conditions
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Blocked by required conditions
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Blocked by required conditions
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Blocked by required conditions
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Blocked by required conditions
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Blocked by required conditions
CI / Website build and checks (pull_request) Blocked by required conditions
beanstalk/approval waiting for a BigBean's 👍 on the request
PR description / Title and description (pull_request_target) Has been cancelled
2026-11-29 19:01:18 +00:00
Compare
Author
Contributor

Pushed 6011e3f3f (beb650823 the test, then the fix), answering BeanBot's review (#2807 (comment)), asked for by @llun:

  • L1, the close waited for DLSS 5's lock (inline): right, and new with this PR, since main's exit never takes that lock. dlss_nr_close now tries it (try_to_lock) at each look, between its 2 ms sleeps, and never waits for it: a recording thread stalled inside NGX with the lock held leaves the exit to the same 0.5 s and 2 s limits. When the lock is only busy at the first look (DLSS's upscale takes it each frame) and nothing of DLSS 5's was made, the close says nothing, as before.
    • tests/test_dlss_nr_exit.py: a thread holds the lock with no frame presented; the close ends 0.5 s after the last frame and says why (a watchdog fails a close that waits, rather than hanging the check). And never made, the lock busy at the first look: no line.
    • With the lock waited for again, the first check fails (the close waits for DLSS 5's lock, held by a stalled recording thread); without the quiet return, the second. Both pass with gcc and clang on Linux, and built by llvm-mingw and run on Windows.
    • vk_dlss.cpp built for Windows with the build's own flags and -Wall -Wextra: the same warnings as before the change, none new. Every test that reads vk_dlss.cpp gives the same result as before it.
  • L2 and L3 (Linux NVIDIA, and an RTX 20, 30 or 40 with the community FP16 file) are the two items of Still to test. The farm request for them (#2807 (comment)) was for b6ac561c, so it is asked again for this head in the next comment.

In the game, this head: 6 exits with DLSS 5 On (4 quits in play, 2 with the pause menu open), each let go in 18 to 51 ms, no GPU fault; the description's Testing and Measurements include them. mise run test: 853 passed, the same 33 failing as on main @ 01d6878b3; mise run lint passes.

Pushed `6011e3f3f` (`beb650823` the test, then the fix), answering BeanBot's review (https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2807#issuecomment-90814), asked for by @llun: - **L1, the close waited for DLSS 5's lock** ([inline](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2807#issuecomment-90813)): right, and new with this PR, since `main`'s exit never takes that lock. `dlss_nr_close` now tries it (`try_to_lock`) at each look, between its 2 ms sleeps, and never waits for it: a recording thread stalled inside NGX with the lock held leaves the exit to the same 0.5 s and 2 s limits. When the lock is only busy at the first look (DLSS's upscale takes it each frame) and nothing of DLSS 5's was made, the close says nothing, as before. - `tests/test_dlss_nr_exit.py`: a thread holds the lock with no frame presented; the close ends 0.5 s after the last frame and says why (a watchdog fails a close that waits, rather than hanging the check). And never made, the lock busy at the first look: no line. - With the lock waited for again, the first check fails (`the close waits for DLSS 5's lock, held by a stalled recording thread`); without the quiet return, the second. Both pass with gcc and clang on Linux, and built by llvm-mingw and run on Windows. - `vk_dlss.cpp` built for Windows with the build's own flags and `-Wall -Wextra`: the same warnings as before the change, none new. Every test that reads `vk_dlss.cpp` gives the same result as before it. - **L2 and L3** (Linux NVIDIA, and an RTX 20, 30 or 40 with the community FP16 file) are the two items of Still to test. The farm request for them (https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2807#issuecomment-90304) was for `b6ac561c`, so it is asked again for this head in the next comment. In the game, this head: 6 exits with DLSS 5 On (4 quits in play, 2 with the pause menu open), each let go in 18 to 51 ms, no GPU fault; the description's Testing and Measurements include them. `mise run test`: 853 passed, the same 33 failing as on `main` @ 01d6878b3; `mise run lint` passes.
Author
Contributor

@Beanstalk linux nvidia, and an RTX 20, 30 or 40 on Windows: this head (6011e3f, after the review), the two items of Still to test. (Asked again: the earlier request was for b6ac561.) Each needs a DLSS 5 file the farm PC has itself (Longshot doesn't download one, docs/user/dlss5.md); without it, say so, and that item stays open.

  1. Linux, NVIDIA: start with RX_VK_DLSS_NR_LINUX=1. The native NGX must offer neural rendering: if the Graphics tab shows no DLSS 5 row, stop there and say so.
    Windows, RTX 20, 30 or 40: the community FP16 file as nvngx_dlssnr.dll in %LOCALAPPDATA%\Longshot\ngx\fp16\. The game's log says DLSS 5 runs the community FP16 file, direct.
  2. Graphics: DLSS 5 On. Load the repo save kokiri-start and play about 30 s.
  3. Quit with the Insert menu's Quit. Then start again and quit with the pause menu open, and once more by closing the window: three exits, five times each if there's time.

Expected at every exit: the game's log has vk: DLSS 5 Neural Rendering: let go for the exit (N ms, its frames done on the GPU), and no GPU fault (Linux: no NVRM: Xid line in dmesg from that time; Windows: no nvlddmkm event in Event Viewer, Windows Logs, System).

@Beanstalk linux nvidia, and an RTX 20, 30 or 40 on Windows: this head (`6011e3f`, after the review), the two items of Still to test. (Asked again: the earlier request was for `b6ac561`.) Each needs a DLSS 5 file the farm PC has itself (Longshot doesn't download one, docs/user/dlss5.md); without it, say so, and that item stays open. 1. **Linux, NVIDIA:** start with `RX_VK_DLSS_NR_LINUX=1`. The native NGX must offer neural rendering: if the Graphics tab shows no DLSS 5 row, stop there and say so. **Windows, RTX 20, 30 or 40:** the community FP16 file as `nvngx_dlssnr.dll` in `%LOCALAPPDATA%\Longshot\ngx\fp16\`. The game's log says `DLSS 5 runs the community FP16 file, direct`. 2. Graphics: DLSS 5 **On**. Load the repo save `kokiri-start` and play about 30 s. 3. Quit with the Insert menu's Quit. Then start again and quit with the pause menu open, and once more by closing the window: three exits, five times each if there's time. Expected at every exit: the game's log has `vk: DLSS 5 Neural Rendering: let go for the exit (N ms, its frames done on the GPU)`, and no GPU fault (Linux: no `NVRM: Xid` line in `dmesg` from that time; Windows: no `nvlddmkm` event in Event Viewer, Windows Logs, System).
Member

@bulldogsajr22 only members of BigBeans can start the farm. One of them can approve this request by reacting 👍 to it or to this comment.

@bulldogsajr22 only members of `BigBeans` can start the farm. One of them can approve this request by reacting 👍 to it or to this comment.
Member
@review
BeanBot left a comment

Recommendation: Approve. The code is ready: only testing is left. The close no longer waits on the DLSS mutex, and the reported Windows runs show the exit fault substantially reduced. Linux NVIDIA and RTX 20–40 FP16 exit runs are still outstanding. Recommend approval; not approved on the forge.

The change releases DLSS 5 after its GPU work finishes before exit, and resumes a background-held game so it can present the frames needed for release. It adds a bounded exit wait and close-path coordination.

Testing before merging (2) (runs on the systems it can change; it doesn't hold the recommendation)

  • L2: The experimental Linux NVIDIA release path has not yet been exercised in game. When: With RX_VK_DLSS_NR_LINUX=1, quitting in play or from the pause menu uses the new retirement and present path without a reported Linux run showing that it completes safely. Do: Run the requested Linux NVIDIA exits in play and from the pause menu, checking the release log and kernel GPU fault log.
  • L3: The community FP16 direct path has only been run on RTX 50 hardware. When: RTX 20–40 users with the community model take the direct release path, but no reported exit run covers those GPUs. Do: Run the requested Windows RTX 20, 30 or 40 exits with the community FP16 model and check the release and driver event logs.

Since the last review (on b6ac561c62)
Resolved: L1 (The close takes the DLSS state mutex without a timeout before starting, and during, its ti…)
Still open: L2 (The experimental Linux NVIDIA release path has not yet been exercised in game.); L3 (The community FP16 direct path has only been run on RTX 50 hardware.)

Checks: Cancelled on this head (no result): PR description / Title and description (pull_request_target). Still running: 10 checks.

More: does it help, other systems, switches, what was read

Does it help: Yes: the author reports 0 faults in 172 exits after the change versus 7 in 62 on main, on an RTX 5090. Reported release waits were 17–88 ms before the latest fix and 18–51 ms for six exits on the latest head.

Other systems: The release path also affects experimental Linux NVIDIA and the community FP16 model on older RTX cards; both still need the requested game runs. The no-NGX build has no-op stubs, and background pause is resumed before renderer shutdown.

Switches: None added, changed or removed.

Reviewed: 6011e3f3f6 against 01d6878b3f: Read AGENTS.md, CONTRIBUTING.md, the pull request template, the full diff since the ledger, the main diff and relevant close-path references; skimmed the longer test fixtures and pull request diff. The changed code files were not all read in full. Tooling's adjacent AGENTS.md and docs/review-checklist.md were not present.; nothing run (a code review).

Checked and fine:

  • The close still requests release and waits for its completion when the mutex is available.
  • The reported latest-head Windows runs released DLSS 5 without a GPU fault.
  • The new test covers a stalled mutex holder and the initially busy, never-made case.

Testing: No commands that run project code or tests were executed. The author reports game-free checks and Windows and Linux builds; CI is still running.

Overlaps and merge order: None identified from the supplied information.


Automated code review by BeanBot (gpt-6.1-terra), asked for by llun. Nothing was run; a maintainer decides.

**Recommendation: Approve.** The code is ready: only testing is left. The close no longer waits on the DLSS mutex, and the reported Windows runs show the exit fault substantially reduced. Linux NVIDIA and RTX 20–40 FP16 exit runs are still outstanding. Recommend approval; not approved on the forge. The change releases DLSS 5 after its GPU work finishes before exit, and resumes a background-held game so it can present the frames needed for release. It adds a bounded exit wait and close-path coordination. **Testing before merging (2)** (runs on the systems it can change; it doesn't hold the recommendation) - **L2**: The experimental Linux NVIDIA release path has not yet been exercised in game. *When:* With RX_VK_DLSS_NR_LINUX=1, quitting in play or from the pause menu uses the new retirement and present path without a reported Linux run showing that it completes safely. **Do:** Run the requested Linux NVIDIA exits in play and from the pause menu, checking the release log and kernel GPU fault log. - **L3**: The community FP16 direct path has only been run on RTX 50 hardware. *When:* RTX 20–40 users with the community model take the direct release path, but no reported exit run covers those GPUs. **Do:** Run the requested Windows RTX 20, 30 or 40 exits with the community FP16 model and check the release and driver event logs. **Since the last review** (on b6ac561c6255) Resolved: L1 (The close takes the DLSS state mutex without a timeout before starting, and during, its ti…) Still open: L2 (The experimental Linux NVIDIA release path has not yet been exercised in game.); L3 (The community FP16 direct path has only been run on RTX 50 hardware.) **Checks:** Cancelled on this head (no result): `PR description / Title and description (pull_request_target)`. Still running: 10 checks. <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Yes: the author reports 0 faults in 172 exits after the change versus 7 in 62 on main, on an RTX 5090. Reported release waits were 17–88 ms before the latest fix and 18–51 ms for six exits on the latest head. **Other systems:** The release path also affects experimental Linux NVIDIA and the community FP16 model on older RTX cards; both still need the requested game runs. The no-NGX build has no-op stubs, and background pause is resumed before renderer shutdown. **Switches:** None added, changed or removed. **Reviewed:** 6011e3f3f614 against 01d6878b3f14: Read AGENTS.md, CONTRIBUTING.md, the pull request template, the full diff since the ledger, the main diff and relevant close-path references; skimmed the longer test fixtures and pull request diff. The changed code files were not all read in full. Tooling's adjacent AGENTS.md and docs/review-checklist.md were not present.; nothing run (a code review). **Checked and fine:** - The close still requests release and waits for its completion when the mutex is available. - The reported latest-head Windows runs released DLSS 5 without a GPU fault. - The new test covers a stalled mutex holder and the initially busy, never-made case. **Testing:** No commands that run project code or tests were executed. The author reports game-free checks and Windows and Linux builds; CI is still running. **Overlaps and merge order:** None identified from the supplied information. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by llun. Nothing was run; a maintainer decides.</sub>
Some checks failed
CI / What the change needs (pull_request) Blocked by required conditions
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Blocked by required conditions
CI / Third-party parts and guide screenshots (pull_request) Blocked by required conditions
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Blocked by required conditions
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Blocked by required conditions
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Blocked by required conditions
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Blocked by required conditions
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Blocked by required conditions
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Blocked by required conditions
CI / Website build and checks (pull_request) Blocked by required conditions
beanstalk/approval waiting for a BigBean's 👍 on the request
PR description / Title and description (pull_request_target) Has been cancelled
This pull request doesn't have enough approvals yet. 0 of 1 approvals granted.
Some workflows are waiting to be reviewed.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'fix/dlss5-exit-release:bulldogsajr22-fix/dlss5-exit-release'
git switch 'bulldogsajr22-fix/dlss5-exit-release'
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
4 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/Longshot!2807
No description provided.