fix(vk): the overlays let go what a present's copy read only after every present still on the GPU #1536

Merged
llun merged 3 commits from pmwork-personal/Longshot:fix/ui-frees-after-presents-in-flight into main 2026-11-18 02:42:17 +00:00
Member

Type: fix · Risk: low · Tested on: Windows 11, RTX 5090 (NVIDIA 621.24) · Needs: the tester's RTX 5080 at 360 Hz (the report's PC), Linux and AMD (any frame generation at 3x or more)

TL;DR

With frame generation at 3x or more, Longshot's overlay (the Insert menu, the FPS counter) let go of its upload buffers
and old font textures 4 frames after their last use, but since #1362 up to 6 frames (8 from 4x) can still be on the GPU,
so the GPU could read memory already let go. A test-only log shows it on an RTX 5090; it is the likely cause of a
tester's lost GPU ("device lost") on an RTX 5080 seconds after choosing 3x, and at every start with 3x saved. The overlay
now waits as long as the most frames that can be in flight.

Breakdown

  • Who it helps: players with frame generation at 3x or more, any maker (Built-in, FSR 3.1, DLSS FG), any GPU.
  • What was wrong: gpu/vk/vk_imgui.cpp let go of what a present's copy read 4 presents later ("present_image keeps
    three frames in flight"); #1362 gave present_image up to kPresentSlotsMax (8) frame slots and sends a set's copies to
    the GPU together, behind the game's next frame, so at 3x and up a copy could read a buffer or a texture already gone.
  • What changes: the overlay waits kPresentSlotsMax + 1 presents (as Dear ImGui's own vertex buffers, ImageCount).
  • What does not change: the frames, their times, the swapchain, the present queue; saves, settings and caches.
  • How it was checked: a game-free test that fails on main; in the game on an RTX 5090, a test-only log of each let-go
    while the copy that read it was still on the GPU: main 10 of 44 in each of 3 runs, this PR 0 of 44 in 2 runs.
  • What is still open: the tester's PC (RTX 5080, 360 Hz) with the fix: the 5090 never lost the device, with or without.
    A second RTX 5080 report (#1491, DLSS FG at 2x) is not this bug: 2x keeps 4 frame slots, which the old wait covered.
  • Risk: low: the staging buffers and old textures live ~5 frames longer (a few MB at most, only while glyphs are added).

Why

A tester (RTX 5080, NVIDIA 621.24, 1920x1080 at 360 Hz, V-Sync Auto, Reflex On) stepped Frame generation from Auto to 2x
to 3x by Built-in FG in the Insert menu: 8 s after 3x the device was lost (submit 81189 failed (-4), 0 checkpoints).
With 3x saved, every start lost the device 5 s in, at the start-up screen. Auto (3 frame slots) and 2x (4) were safe: the
overlay's 4 presents covered them. 3x takes 6 slots, 4x and up 8 (present_slots_for, docs/design.md section 13 rule 4).
Since #1442 the same slots apply under FIFO too (V-Sync On, and Auto with DLSS FG), so every present mode is
exposed at 3x and up, not only mailbox and immediate. The checkpoints are on the replay's recordings, not the present's
copies: hence 0. The crash message named RX_VK_PRESENT_QUEUE=0; the presents' own queue (#1476) does not make these
let-gos (the same 10 of 44 with it off, below). #1491 (another RTX 5080 on 621.24, DLSS FG at 2x, a lost device at the
start-up logo since nightly-458) cannot be this bug and may be the queue's: not this PR's, and asked there separately.

Reported by null (nullifyshot) on Discord, with the log and both crash records.

See #1362, #1442, #1476, #1491.

How to reproduce

Seen on: Windows 11 build 26300, RTX 5080, NVIDIA 621.24, 1920x1080 at 360 Hz (the tester's report); on an RTX 5090
(NVIDIA 621.24) the let-gos show in the test-only log below, without a lost device
Settings and switches: Frame generation 3x (or more), Frame generation by Built-in FG, V-Sync Auto, Frame pacing Off,
NVIDIA Reflex On; main 310e7c9d
Steps: save Frame generation at 3x and start the game; or in play, open the Insert menu and step Frame generation to
3x, then change rows that add glyphs (Menu size, the FPS counter).
Expected: the game runs.
Actual: the device is lost seconds later (vk: FATAL: the GPU device was lost).

What changed

The overlay now keeps what a present's copy read until every copy that can still be on the GPU is done:
kPresentSlotsMax + 1 presents instead of 4. A game-free test models present_image's frame slots, and the design notes
say what the slots bound.

  • gpu/vk/vk_imgui.cpp: kFramesLater (how many presents the overlay keeps what it let go) is kPresentSlotsMax + 1,
    not 4; the comment says why.
  • tests/test_ui_texture_upload.py, tests/ui_texture_upload_test.cpp: the windowed cases and a new ring-destroy model
    present_image's ring (present_slots_for, kPresentSlotsMax, cut from the sources): nothing let go while a copy that
    read it can still be on the GPU, and let go after. Fails on main: "an upload's staging buffer, let go 4 presents after
    the copy that used it, while present_image keeps 8 copies in flight".
  • docs/design.md section 13 rule 4: the slots also bound what a copy reads; kFramesLater carries that rule's doc:
    anchor, and tests/test_doc_anchors.py keeps it there. gpu/vk/vk_internal.h: kPresentSlotsMax's comment names both
    of its followers.
  • docs/tested/2026-11-17-overlay-frees-*.md: the seven runs below.

Measurements

Verdict: fixed. On main at 3x the overlay let go 10 of 44 staging buffers while the present copy that read them was
still on the GPU, in each of 3 runs; with this PR 0 of 44 in 2 runs. The RTX 5090 here did not lose the device either way
(the freed memory stays mapped in its block, and the GPU reads stale bytes): the counts are the evidence, not a crash.

Hardware: Windows 11 Pro build 26300, RTX 5090, NVIDIA 621.24, AMD Ryzen 7 9800X3D, 64 GB, 5120x2160 at 165 Hz (G-Sync)
Scene: the start-up screen and the title (the tester's second crash: 5 s after each start); then a save in play in Hyrule
Market (child), the tester's map
Method: main 310e7c9d and this branch as measured (60911109; since rebased onto 4b68c42b as 50bc545c, the same code with reworded comments, its doc: anchor and that anchor's row), each with one test-only DIAGNOSTIC commit that is not in this PR (present
copies numbered by frame slot in vk_replay.cpp; vk_imgui.cpp reap asks whether the copy that read what it lets go is
done, and logs each that is not); dev_packs.py packs on one base (nightly-396 @ 7887c497). Settings: the Launcher's, with
Frame generation 3x, Frame generation by Built-in FG, V-Sync Auto (mailbox), Frame pacing Off. Each run: 75 s from the start
with 3x saved, then the control bridge changes Menu size, the FPS counter and Frame generation (2x, 3x, 4x) every 4 s for
75 s (each needs new glyphs: uploads, and lets go of old ones), then quits. Runs in turn: main, this PR, main with
RX_VK_FG_TIMELINE=0, main with RX_VK_PRESENT_QUEUE=0, main, this PR.
How to reproduce: the DIAGNOSTIC commit's two hunks below on the build to check, the settings above, longshot_ctl.py option set for the rows.

// vk_replay.cpp, before present_image: each copy numbered, and each frame slot's last
static uint64_t diag_copy_seq = 0, diag_slot_seq[kPresentSlotsMax] = {};
uint64_t diag_copy_next() { return diag_copy_seq + 1; }
bool diag_copy_done(uint64_t seq) {   // (its slot's fence; a slot used again since was waited for first)
    for (uint32_t s = 0; s < (uint32_t)kPresentSlotsMax; s++)
        if (seq && diag_slot_seq[s] == seq)
            return (::vkx::vkWaitForFences)(dev.device, 1, &frames[s].done, VK_TRUE, 0) == VK_SUCCESS;
    return true;
}
// in present_image, after vkQueueSubmit2(dev.queue, 1, &si, f.done):
diag_slot_seq[slot] = ++diag_copy_seq;
// vk_imgui.cpp: Dead gets `uint64_t seq = diag_copy_next();` (a given-up texture: seq - 1, last read by the copy before);
// reap, in a window, before it lets one go: if (!diag_copy_done(d.seq)) count it and log
// "ui diag: let go <a staging buffer | a texture> that copy N read, still on the GPU"; every 600 presents the totals
at the start-up screen and title, 3x Before: main @ 310e7c9d After: this PR @ 60911109 Before, RX_VK_FG_TIMELINE=0: main @ 310e7c9d Before, RX_VK_PRESENT_QUEUE=0: main @ 310e7c9d
let-gos (first run / second run) 44 / 44 44 / 44 44 44
of them while their copy was still on the GPU 10 / 10 0 / 0 0 10
device lost no / no no / no no no
(run 1, main)
vk: ui diag: let go a staging buffer that copy 45069 read, still on the GPU (copy 45073 next; 4 presents after it)
vk: ui diag: 44 let go in all, 10 of them while the copy that read them was still on the GPU (kFramesLater 4)
(run 2, this PR)
vk: ui diag: 44 let go in all, 0 of them while the copy that read them was still on the GPU (kFramesLater 9)

The numbers still hold on main 4b68c42b: of the 4 commits since 310e7c9d (#1496, #1497, #1500, #1473), none touches
vk_imgui.cpp, present_slots_for or kPresentSlotsMax, and #1496's changes in vk_framegen.cpp act under FIFO
only (these runs were mailbox) or add a log that is off by default.

Flags and settings

None: this PR adds or changes no switch, menu row or ini key. RX_VK_FG_TIMELINE=0 and RX_VK_PRESENT_QUEUE=0
were run above only to tell the causes apart.

A replay of the tester's own session (his settings from the report over the Launcher's; in play in Hyrule Market, the Insert
menu driven by its keys: Upscaler DLSS to FSR 3.1 and back, Render resolution down to Ultra Performance and back to DLAA,
Frame generation Off, Auto, 2x, 3x, Frame generation by through its three makers, then Menu size and the FPS counter
changed with the menu open) on main: the swapchain made again as in his log (mailbox, 6 then 8 images), 46 let go, 0 while
their copy was on the GPU, no device lost: in play this GPU kept up within 4 presents.

Testing

Tested:

  • In the game on Windows 11, RTX 5090, NVIDIA 621.24: the six runs above (Built-in FG 2x, 3x and 4x, V-Sync Auto) and the
    tester's session on main (also FSR 3.1 FG and DLSS FG); no device lost or crash, with main or with this PR.
  • python -I -B tests/run_all.py on 60911109 (before the rebase; the 4 commits since touch none of these files) (Windows, llvm-mingw clang 23): 666 passed, 53 failed, 48 skipped; the 53
    fail on main 310e7c9d too (the 44 of main 415a8944 on this PC, and 9 newer ones run on main here: test_compute_warm_apart,
    test_dev_packs, test_draw_stream_visibility, test_fsr_image_retirement, test_invalidate_quick, test_libc_hooks,
    test_psychov35_fsr3_fg, test_sdiv_overflow, test_switch_table). tests/test_ui_texture_upload.py passes here and fails
    on main; with kFramesLater = kPresentSlotsMax - 1 it fails again.

Not testable by hand: the tester's 360 Hz display and RTX 5080.

Not tested: Linux, AMD, Intel (the same code; no other path), and a Linux build (the new line uses kPresentSlotsMax
as the same file's Dear ImGui ImageCount already does).

Must be tested:

  • The tester's PC (RTX 5080, 360 Hz): Frame generation 3x by Built-in FG, V-Sync Auto, a start and a few minutes in the
    Insert menu, expecting no device lost (by hand: the reporter; asked to try RX_VK_FG_TIMELINE=0 and
    RX_VK_PRESENT_QUEUE=0 meanwhile, one at a time, which tells this bug from the queue).

Risks

What could break: nothing that I know of. What the overlay lets go now lives 9 presents instead of 4: a few MB to
tens of MB for a moment when the font atlas grows several times at the start-up screen; a given-up texture keeps its
descriptor set longer (Dear ImGui's pool has 16; if it ran out, the overlays skip a frame, as before); headless
(RX_VK_SHOT_MENU) it takes 9 menu shots before anything is let go; and up to 9 presents' worth instead of 4 is still
held at exit.

Turning it off: none needed; RX_VK_FG_TIMELINE=0 (3 frame slots) or Frame generation 2x avoided it before.

Compatibility: Nothing changes: saves, longshot_options.ini, caches and the vk ABI as before.

Issues

See #1362, #1442, #1476

Checklist

Everyone

  • One topic.
  • The title is a Conventional Commit (type(scope): description) of the status line's type.
  • Why gives the reason plainly and links the issues that fit (the tracker searched).
  • Tested on my own PC where it runs (in the game, for a change the game runs), as Testing's Tested says; what
    can't be run by hand is in Testing's Not testable by hand, with why.
  • Measurements has a verdict, or one line saying why there is nothing to measure.
  • Nothing gets worse that I know of: any cost (speed, latency, memory, a setup that worked before) is measured and
    in Risks.
  • Testing names what was tested, what wasn't, and what must still be tested, where and how.
  • Rebased on current main.
  • python -I -B tests/run_all.py passes (any failure that also fails on main is named).
  • No game files, dumps, build output or generated files.
  • third_party/ untouched (a new folder with a PROVENANCE.md instead).
  • The license is OK: GPL-3.0-or-later, nothing incompatible and nothing decompiled.

When it applies

  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.
  • Numbers from the same PC, scene and settings, at least 2 interleaved runs each, the median reported.
  • A file in docs/tested/ for each new measured run (format in docs/tested-configurations.md).
  • A game-free test added for the fix, failing on main and passing here.
  • A check under tests/ that reads changed source updated in this PR, not weakened.
  • Docs updated.

🤖 Generated with Claude Code

Assisted-by: Claude Code
Co-Authored-By: Claude Opus 5.5 [email protected]

**Type:** fix · **Risk:** low · **Tested on:** Windows 11, RTX 5090 (NVIDIA 621.24) · **Needs:** the tester's RTX 5080 at 360 Hz (the report's PC), Linux and AMD (any frame generation at 3x or more) ## TL;DR With frame generation at 3x or more, Longshot's overlay (the Insert menu, the FPS counter) let go of its upload buffers and old font textures 4 frames after their last use, but since #1362 up to 6 frames (8 from 4x) can still be on the GPU, so the GPU could read memory already let go. A test-only log shows it on an RTX 5090; it is the likely cause of a tester's lost GPU ("device lost") on an RTX 5080 seconds after choosing 3x, and at every start with 3x saved. The overlay now waits as long as the most frames that can be in flight. ## Breakdown - **Who it helps:** players with frame generation at 3x or more, any maker (Built-in, FSR 3.1, DLSS FG), any GPU. - **What was wrong:** `gpu/vk/vk_imgui.cpp` let go of what a present's copy read 4 presents later ("present_image keeps three frames in flight"); #1362 gave present_image up to `kPresentSlotsMax` (8) frame slots and sends a set's copies to the GPU together, behind the game's next frame, so at 3x and up a copy could read a buffer or a texture already gone. - **What changes:** the overlay waits `kPresentSlotsMax + 1` presents (as Dear ImGui's own vertex buffers, `ImageCount`). - **What does not change:** the frames, their times, the swapchain, the present queue; saves, settings and caches. - **How it was checked:** a game-free test that fails on main; in the game on an RTX 5090, a test-only log of each let-go while the copy that read it was still on the GPU: main 10 of 44 in each of 3 runs, this PR 0 of 44 in 2 runs. - **What is still open:** the tester's PC (RTX 5080, 360 Hz) with the fix: the 5090 never lost the device, with or without. A second RTX 5080 report (#1491, DLSS FG at 2x) is not this bug: 2x keeps 4 frame slots, which the old wait covered. - **Risk:** low: the staging buffers and old textures live ~5 frames longer (a few MB at most, only while glyphs are added). ## Why A tester (RTX 5080, NVIDIA 621.24, 1920x1080 at 360 Hz, V-Sync Auto, Reflex On) stepped Frame generation from Auto to 2x to 3x by Built-in FG in the Insert menu: 8 s after 3x the device was lost (`submit 81189 failed (-4)`, `0 checkpoints`). With 3x saved, every start lost the device 5 s in, at the start-up screen. Auto (3 frame slots) and 2x (4) were safe: the overlay's 4 presents covered them. 3x takes 6 slots, 4x and up 8 (`present_slots_for`, docs/design.md section 13 rule 4). Since #1442 the same slots apply under FIFO too (V-Sync On, and Auto with DLSS FG), so every present mode is exposed at 3x and up, not only mailbox and immediate. The checkpoints are on the replay's recordings, not the present's copies: hence 0. The crash message named `RX_VK_PRESENT_QUEUE=0`; the presents' own queue (#1476) does not make these let-gos (the same 10 of 44 with it off, below). #1491 (another RTX 5080 on 621.24, DLSS FG at 2x, a lost device at the start-up logo since nightly-458) cannot be this bug and may be the queue's: not this PR's, and asked there separately. Reported by null (nullifyshot) on Discord, with the log and both crash records. See #1362, #1442, #1476, #1491. ## How to reproduce **Seen on:** Windows 11 build 26300, RTX 5080, NVIDIA 621.24, 1920x1080 at 360 Hz (the tester's report); on an RTX 5090 (NVIDIA 621.24) the let-gos show in the test-only log below, without a lost device **Settings and switches:** Frame generation 3x (or more), Frame generation by Built-in FG, V-Sync Auto, Frame pacing Off, NVIDIA Reflex On; main 310e7c9d **Steps:** save Frame generation at 3x and start the game; or in play, open the Insert menu and step Frame generation to 3x, then change rows that add glyphs (Menu size, the FPS counter). **Expected:** the game runs. **Actual:** the device is lost seconds later (`vk: FATAL: the GPU device was lost`). ## What changed The overlay now keeps what a present's copy read until every copy that can still be on the GPU is done: `kPresentSlotsMax + 1` presents instead of 4. A game-free test models present_image's frame slots, and the design notes say what the slots bound. - `gpu/vk/vk_imgui.cpp`: `kFramesLater` (how many presents the overlay keeps what it let go) is `kPresentSlotsMax + 1`, not 4; the comment says why. - `tests/test_ui_texture_upload.py`, `tests/ui_texture_upload_test.cpp`: the windowed cases and a new `ring-destroy` model present_image's ring (`present_slots_for`, `kPresentSlotsMax`, cut from the sources): nothing let go while a copy that read it can still be on the GPU, and let go after. Fails on main: "an upload's staging buffer, let go 4 presents after the copy that used it, while present_image keeps 8 copies in flight". - `docs/design.md` section 13 rule 4: the slots also bound what a copy reads; `kFramesLater` carries that rule's `doc:` anchor, and `tests/test_doc_anchors.py` keeps it there. `gpu/vk/vk_internal.h`: `kPresentSlotsMax`'s comment names both of its followers. - `docs/tested/2026-11-17-overlay-frees-*.md`: the seven runs below. ## Measurements **Verdict:** fixed. On main at 3x the overlay let go 10 of 44 staging buffers while the present copy that read them was still on the GPU, in each of 3 runs; with this PR 0 of 44 in 2 runs. The RTX 5090 here did not lose the device either way (the freed memory stays mapped in its block, and the GPU reads stale bytes): the counts are the evidence, not a crash. Hardware: Windows 11 Pro build 26300, RTX 5090, NVIDIA 621.24, AMD Ryzen 7 9800X3D, 64 GB, 5120x2160 at 165 Hz (G-Sync) Scene: the start-up screen and the title (the tester's second crash: 5 s after each start); then a save in play in Hyrule Market (child), the tester's map Method: main 310e7c9d and this branch as measured (60911109; since rebased onto 4b68c42b as 50bc545c, the same code with reworded comments, its `doc:` anchor and that anchor's row), each with one test-only DIAGNOSTIC commit that is not in this PR (present copies numbered by frame slot in `vk_replay.cpp`; `vk_imgui.cpp` `reap` asks whether the copy that read what it lets go is done, and logs each that is not); `dev_packs.py` packs on one base (nightly-396 @ 7887c497). Settings: the Launcher's, with Frame generation 3x, Frame generation by Built-in FG, V-Sync Auto (mailbox), Frame pacing Off. Each run: 75 s from the start with 3x saved, then the control bridge changes Menu size, the FPS counter and Frame generation (2x, 3x, 4x) every 4 s for 75 s (each needs new glyphs: uploads, and lets go of old ones), then quits. Runs in turn: main, this PR, main with `RX_VK_FG_TIMELINE=0`, main with `RX_VK_PRESENT_QUEUE=0`, main, this PR. How to reproduce: the DIAGNOSTIC commit's two hunks below on the build to check, the settings above, `longshot_ctl.py option set` for the rows. ```cpp // vk_replay.cpp, before present_image: each copy numbered, and each frame slot's last static uint64_t diag_copy_seq = 0, diag_slot_seq[kPresentSlotsMax] = {}; uint64_t diag_copy_next() { return diag_copy_seq + 1; } bool diag_copy_done(uint64_t seq) { // (its slot's fence; a slot used again since was waited for first) for (uint32_t s = 0; s < (uint32_t)kPresentSlotsMax; s++) if (seq && diag_slot_seq[s] == seq) return (::vkx::vkWaitForFences)(dev.device, 1, &frames[s].done, VK_TRUE, 0) == VK_SUCCESS; return true; } // in present_image, after vkQueueSubmit2(dev.queue, 1, &si, f.done): diag_slot_seq[slot] = ++diag_copy_seq; // vk_imgui.cpp: Dead gets `uint64_t seq = diag_copy_next();` (a given-up texture: seq - 1, last read by the copy before); // reap, in a window, before it lets one go: if (!diag_copy_done(d.seq)) count it and log // "ui diag: let go <a staging buffer | a texture> that copy N read, still on the GPU"; every 600 presents the totals ``` | at the start-up screen and title, 3x | Before: main @ 310e7c9d | After: this PR @ 60911109 | Before, RX_VK_FG_TIMELINE=0: main @ 310e7c9d | Before, RX_VK_PRESENT_QUEUE=0: main @ 310e7c9d | |---|---|---|---|---| | let-gos (first run / second run) | 44 / 44 | 44 / 44 | 44 | 44 | | of them while their copy was still on the GPU | 10 / 10 | 0 / 0 | 0 | 10 | | device lost | no / no | no / no | no | no | ``` (run 1, main) vk: ui diag: let go a staging buffer that copy 45069 read, still on the GPU (copy 45073 next; 4 presents after it) vk: ui diag: 44 let go in all, 10 of them while the copy that read them was still on the GPU (kFramesLater 4) (run 2, this PR) vk: ui diag: 44 let go in all, 0 of them while the copy that read them was still on the GPU (kFramesLater 9) ``` The numbers still hold on main 4b68c42b: of the 4 commits since 310e7c9d (#1496, #1497, #1500, #1473), none touches `vk_imgui.cpp`, `present_slots_for` or `kPresentSlotsMax`, and #1496's changes in `vk_framegen.cpp` act under FIFO only (these runs were mailbox) or add a log that is off by default. ### Flags and settings None: this PR adds or changes no switch, menu row or ini key. `RX_VK_FG_TIMELINE=0` and `RX_VK_PRESENT_QUEUE=0` were run above only to tell the causes apart. A replay of the tester's own session (his settings from the report over the Launcher's; in play in Hyrule Market, the Insert menu driven by its keys: Upscaler DLSS to FSR 3.1 and back, Render resolution down to Ultra Performance and back to DLAA, Frame generation Off, Auto, 2x, 3x, Frame generation by through its three makers, then Menu size and the FPS counter changed with the menu open) on main: the swapchain made again as in his log (mailbox, 6 then 8 images), 46 let go, 0 while their copy was on the GPU, no device lost: in play this GPU kept up within 4 presents. ## Testing **Tested:** - In the game on Windows 11, RTX 5090, NVIDIA 621.24: the six runs above (Built-in FG 2x, 3x and 4x, V-Sync Auto) and the tester's session on main (also FSR 3.1 FG and DLSS FG); no device lost or crash, with main or with this PR. - `python -I -B tests/run_all.py` on 60911109 (before the rebase; the 4 commits since touch none of these files) (Windows, llvm-mingw clang 23): 666 passed, 53 failed, 48 skipped; the 53 fail on main 310e7c9d too (the 44 of main 415a8944 on this PC, and 9 newer ones run on main here: test_compute_warm_apart, test_dev_packs, test_draw_stream_visibility, test_fsr_image_retirement, test_invalidate_quick, test_libc_hooks, test_psychov35_fsr3_fg, test_sdiv_overflow, test_switch_table). `tests/test_ui_texture_upload.py` passes here and fails on main; with `kFramesLater = kPresentSlotsMax - 1` it fails again. **Not testable by hand:** the tester's 360 Hz display and RTX 5080. **Not tested:** Linux, AMD, Intel (the same code; no other path), and a Linux build (the new line uses `kPresentSlotsMax` as the same file's Dear ImGui `ImageCount` already does). **Must be tested:** - The tester's PC (RTX 5080, 360 Hz): Frame generation 3x by Built-in FG, V-Sync Auto, a start and a few minutes in the Insert menu, expecting no device lost (by hand: the reporter; asked to try `RX_VK_FG_TIMELINE=0` and `RX_VK_PRESENT_QUEUE=0` meanwhile, one at a time, which tells this bug from the queue). ## Risks **What could break:** nothing that I know of. What the overlay lets go now lives 9 presents instead of 4: a few MB to tens of MB for a moment when the font atlas grows several times at the start-up screen; a given-up texture keeps its descriptor set longer (Dear ImGui's pool has 16; if it ran out, the overlays skip a frame, as before); headless (`RX_VK_SHOT_MENU`) it takes 9 menu shots before anything is let go; and up to 9 presents' worth instead of 4 is still held at exit. **Turning it off:** none needed; `RX_VK_FG_TIMELINE=0` (3 frame slots) or Frame generation 2x avoided it before. **Compatibility:** Nothing changes: saves, longshot_options.ini, caches and the vk ABI as before. ## Issues See #1362, #1442, #1476 ## Checklist ### Everyone - [x] One topic. - [x] The title is a Conventional Commit (`type(scope): description`) of the status line's type. - [x] Why gives the reason plainly and links the issues that fit (the tracker searched). - [x] Tested on my own PC where it runs (in the game, for a change the game runs), as Testing's Tested says; what can't be run by hand is in Testing's Not testable by hand, with why. - [x] Measurements has a verdict, or one line saying why there is nothing to measure. - [x] Nothing gets worse that I know of: any cost (speed, latency, memory, a setup that worked before) is measured and in Risks. - [x] Testing names what was tested, what wasn't, and what must still be tested, where and how. - [x] Rebased on current `main`. - [x] `python -I -B tests/run_all.py` passes (any failure that also fails on `main` is named). - [x] No game files, dumps, build output or generated files. - [x] `third_party/` untouched (a new folder with a `PROVENANCE.md` instead). - [x] The license is OK: GPL-3.0-or-later, nothing incompatible and nothing decompiled. ### When it applies - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. - [x] Numbers from the same PC, scene and settings, at least 2 interleaved runs each, the median reported. - [x] A file in `docs/tested/` for each new measured run (format in `docs/tested-configurations.md`). - [x] A game-free test added for the fix, failing on `main` and passing here. - [x] A check under `tests/` that reads changed source updated in this PR, not weakened. - [x] Docs updated. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Assisted-by: Claude Code Co-Authored-By: Claude Opus 5.5 <[email protected]>
test_ui_texture_upload now models present_image's ring of frame slots (vk_replay.cpp present_slots_for, up to
kPresentSlotsMax): in a window, the wait for a frame slot is all that tells the CPU a present's copy is done, so what the
overlays recorded into the copy of present P may still be read until present P + the ring's slots. The windowed cases
and the new ring-destroy (a texture Dear ImGui gives up when its atlas grows) check that nothing is let go before that,
and that it is let go after.

Fails on main: vk_imgui.cpp lets them go 4 presents later ("present_image keeps three frames in flight"), while frame
generation on the game's timeline keeps up to 8 copies in flight since #1362.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Assisted-by: Claude Code
vk_imgui.cpp let go of its staging buffers and the textures Dear ImGui gives up 4 presents after their last use
("present_image keeps three frames in flight"). Since #1362, frame generation on the game's timeline keeps a frame slot
per frame of two sets (present_slots_for: 6 at 3x, 8 from 4x up; under FIFO too since #1442) and sends a set's copies to
the GPU together, behind the game's next frame, so at 3x and up a copy could still read a buffer or a texture already let
go. A test-only log showed it on an RTX 5090 (10 of 44 let-gos at 3x, no lost device there); it is a likely cause of a
tester's lost device on an RTX 5080 (NVIDIA 621.24, Built-in FG, 8 s after 3x was chosen, and 5 s after every start with
3x saved), not reproduced.

kFramesLater is now kPresentSlotsMax + 1, one spare as Dear ImGui's own vertex buffers (ImageCount), with its docs/design.md
anchor (section 13 rule 4, which now says what the slots also bound) and its row in tests/test_doc_anchors.py.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Assisted-by: Claude Code
docs(tested): the overlays' let-go A/B at frame generation 3x, and a replay of the tester's session
Some checks failed
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
Website / Website on Cloudflare (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 7s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 11s
CI / Workflow lint (actionlint) (pull_request) Successful in 13s
Third-party parts / As their notes say (pull_request) Successful in 14s
Website / Website on Cloudflare (pull_request_target) Has been skipped
PR description / Description follows the template (pull_request_target) Successful in 4s
1b14c9ac97
Seven runs on an RTX 5090 (NVIDIA 621.24): main and this branch in turn at the start-up screen and the title (main 10 of 44
let-gos while their present copy was still on the GPU in each run, this branch 0), main with RX_VK_FG_TIMELINE=0 (0) and
with RX_VK_PRESENT_QUEUE=0 (10), and the tester's own session replayed in play (0, no device lost).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Assisted-by: Claude Code
Author
Member

Tested in game: Windows 11 Pro 26300, RTX 5090, NVIDIA 621.24, 5120x2160 at 165 Hz: frame generation 2x, 3x and 4x by Built-in FG at V-Sync Auto (mailbox), at the start-up screen and the title with Menu size, the FPS counter and Frame generation changed every 4 s, main and this branch in turn, two runs each, with a test-only log of each overlay let-go while its present copy was still on the GPU: main 10 of 44 in each run, this branch 0 of 44; no device lost, crash or missing overlay either way. A replay of the tester's own session in play (Hyrule Market, the Insert menu driven by its keys, FSR 3.1 FG and DLSS FG too) on main: no device lost.

Tested in game: Windows 11 Pro 26300, RTX 5090, NVIDIA 621.24, 5120x2160 at 165 Hz: frame generation 2x, 3x and 4x by Built-in FG at V-Sync Auto (mailbox), at the start-up screen and the title with Menu size, the FPS counter and Frame generation changed every 4 s, main and this branch in turn, two runs each, with a test-only log of each overlay let-go while its present copy was still on the GPU: main 10 of 44 in each run, this branch 0 of 44; no device lost, crash or missing overlay either way. A replay of the tester's own session in play (Hyrule Market, the Insert menu driven by its keys, FSR 3.1 FG and DLSS FG too) on main: no device lost.
llun approved these changes 2026-11-18 02:42:13 +00:00
llun merged commit 9af4808f8b into main 2026-11-18 02:42:17 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 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!1536
No description provided.