fix(vk): another image is shown in place of one the window does not give back, so the picture no longer freezes after Alt+Tab #2214

Closed
llun wants to merge 3 commits from llun/Longshot:fix/held-image-fresh-swapchain into main
Member

Summary

With frame generation on, on an RX 9070 XT under Windows in fullscreen, the picture freezes after Alt+Tab while the game and its sound go on, until F11. The system keeps the image it shows until another one is shown on the window. Since #1458 an image not given back in 250 ms is held, and nothing else is presented, so nothing ever lets it go. #2083's remake didn't help: the reporter's nightly-745 log shows the new swapchain's first image held again at once. This PR's first version (a fresh swapchain, the one before destroyed first) made it worse: its destroy waited 12 s for the system, and the whole game stalled until F11 (log in a comment below). Both logs also show the hold can begin as the game comes back in front.

Now, while an image is held, present_image asks for one more (a timeout of 0, with a fence of its own) and shows it in the held one's place if it is free within 2 ms. The system then lets the held one go, and it's shown at a later present. One that isn't free is kept and looked at again at the next present, without waiting; at most two are held. #2083's remake stays, for when no image could be shown for its wait. New log line: vk: another of the window's images shown in place of the one not given back.

Read first: other_image, fence_free and held_other beside held_image_drop in gpu/vk/vk_replay.cpp, then the hold in present_image_with_trial (after image_free).

See #1482 (to close once an AMD run shows the picture coming back). See #2083, #1458, #1376.

Testing

Tested: not in the game yet. The person I work for tests this head on AMD. The first version's in-game runs (RTX 5080, Windows 11) no longer apply.

Checks (not run on this PC for this head; CI runs them): tests/test_present_held_image.py's engine keeps the image it shows until another is shown on the window, and a remake with the swapchain before handed over takes the held image over, as the logs show. It expects a frame within 100 ms of the window being seen again with an image held, and no remake. Broken variants: no remake, and no other image shown (main's behaviour).

Still to test:

  • Windows, AMD RX 9000 or 7000, a build of this head: by hand.

    1. In the Insert menu's Graphics tab, set Frame generation to Auto (or 2x) and Frame generation by to FSR 3.1 FG, Fullscreen on (F11), V-Sync Auto.
    2. Walk in Hyrule Field for a minute.
    3. Alt+Tab to another window, wait 10 to 15 s, Alt+Tab back, without F11. Five times.
    4. Play 10 minutes in fullscreen, then repeat with Frame generation by set to Built-in FG.

    Expecting the picture moving within about a second each time, never frozen until F11. In logs/longshot_log.txt: not given back in 250 ms followed by another of the window's images shown in place of the one not given back, then the window's image was given back: frames are shown again, and no 12 s stall (the game read no controller).

  • Windows, NVIDIA, the same steps: by hand. Expecting no change (no image is held there).

  • Linux: by hand. The held path is shared; with a driver that waits in its acquire nothing is held.

Measurements

Verdict: not measured yet: the new code runs only while an image is held, which this PC (NVIDIA) never reaches.

Before: main @ a2dc5385 After: this PR @ 5ddd9b45
reporter's freeze (RX 9070 XT, FSR 3.1 FG) frozen until F11 to test on AMD

Risks

  • While an image is held, one more image is out (at most two). With frame generation's sets ahead, an acquire with a timeout of 0 gives none when the driver has none to give, and the frame isn't shown, as before.
  • If the system doesn't let the held image go after another is shown, it stays held, and frames go on through the other images. #2083's remake comes only when none could be shown for 1 s, then 2 s and 4 s.
  • No switch. A revert is enough.

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. (Not yet: the person I work for tests it on AMD.)
  • mise run test passes (any failure that also fails on main is named). (Not run on this PC for this head; CI.)
  • 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.
  • Docs updated.
  • 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 frame generation on, on an RX 9070 XT under Windows in fullscreen, the picture freezes after Alt+Tab while the game and its sound go on, until F11. The system keeps the image it shows until another one is shown on the window. Since #1458 an image not given back in 250 ms is held, and nothing else is presented, so nothing ever lets it go. [#2083](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2083)'s remake didn't help: the reporter's nightly-745 log shows the new swapchain's first image held again at once. This PR's first version (a fresh swapchain, the one before destroyed first) made it worse: its destroy waited 12 s for the system, and the whole game stalled until F11 (log in a comment below). Both logs also show the hold can begin as the game comes back in front. Now, while an image is held, `present_image` asks for one more (a timeout of 0, with a fence of its own) and shows it in the held one's place if it is free within 2 ms. The system then lets the held one go, and it's shown at a later present. One that isn't free is kept and looked at again at the next present, without waiting; at most two are held. #2083's remake stays, for when no image could be shown for its wait. New log line: `vk: another of the window's images shown in place of the one not given back`. Read first: `other_image`, `fence_free` and `held_other` beside `held_image_drop` in `gpu/vk/vk_replay.cpp`, then the hold in `present_image_with_trial` (after `image_free`). See #1482 (to close once an AMD run shows the picture coming back). See #2083, #1458, #1376. ## Testing **Tested:** not in the game yet. The person I work for tests this head on AMD. The first version's in-game runs (RTX 5080, Windows 11) no longer apply. Checks (not run on this PC for this head; CI runs them): `tests/test_present_held_image.py`'s engine keeps the image it shows until another is shown on the window, and a remake with the swapchain before handed over takes the held image over, as the logs show. It expects a frame within 100 ms of the window being seen again with an image held, and no remake. Broken variants: no remake, and no other image shown (main's behaviour). **Still to test:** - Windows, AMD RX 9000 or 7000, a build of this head: by hand. 1. In the Insert menu's Graphics tab, set Frame generation to Auto (or 2x) and Frame generation by to FSR 3.1 FG, Fullscreen on (F11), V-Sync Auto. 2. Walk in Hyrule Field for a minute. 3. Alt+Tab to another window, wait 10 to 15 s, Alt+Tab back, without F11. Five times. 4. Play 10 minutes in fullscreen, then repeat with Frame generation by set to Built-in FG. Expecting the picture moving within about a second each time, never frozen until F11. In `logs/longshot_log.txt`: `not given back in 250 ms` followed by `another of the window's images shown in place of the one not given back`, then `the window's image was given back: frames are shown again`, and no 12 s stall (`the game read no controller`). - Windows, NVIDIA, the same steps: by hand. Expecting no change (no image is held there). - Linux: by hand. The held path is shared; with a driver that waits in its acquire nothing is held. ## Measurements **Verdict:** not measured yet: the new code runs only while an image is held, which this PC (NVIDIA) never reaches. | | Before: main @ a2dc5385 | After: this PR @ 5ddd9b45 | |---|---|---| | reporter's freeze (RX 9070 XT, FSR 3.1 FG) | frozen until F11 | to test on AMD | ## Risks - While an image is held, one more image is out (at most two). With frame generation's sets ahead, an acquire with a timeout of 0 gives none when the driver has none to give, and the frame isn't shown, as before. - If the system doesn't let the held image go after another is shown, it stays held, and frames go on through the other images. #2083's remake comes only when none could be shown for 1 s, then 2 s and 4 s. - No switch. A revert is enough. ## Checklist ### Ready for review - [x] 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. (Not yet: the person I work for tests it on AMD.) - [ ] `mise run test` passes (any failure that also fails on `main` is named). (Not run on this PC for this head; CI.) - [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] Docs updated. - [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 model engine now carries a held image, never let go, into a swapchain made with the one before handed over
(oldSwapchain, the same image count). That is the reporter's nightly-745 log after #2083: the remake's new
swapchain held its first image again at once with the game in front, and only F11, through a 1280x720 swapchain,
brought the picture back. A fresh swapchain (create_swapchain_fresh) takes none.

Checked: back in front after Alt+Tab, a frame within 100 ms on Windows and within 1.5 s of the hold on Linux; a hold
with the game in front all along (a hitch, an overlay) recovers within 1.5 s. Fails on main: no frame in 3 s.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
fix(vk): the held image's remake makes the swapchain fresh, and at once when the game is back in front (#1482)
Some checks failed
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
CI / Python source checks (ubuntu-24.04, part 1/2) (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 10s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 15s
CI / Workflow lint (actionlint) (pull_request) Successful in 19s
Website / Website on Cloudflare (pull_request_target) Has been skipped
Third-party parts / As their notes say (pull_request) Successful in 22s
CI / Website build and checks (pull_request) Failing after 1m17s
beanstalk/approval can't be tested as asked: see the farm's comment
PR description / Description follows the template (pull_request_target) Successful in 6s
74dd812e97
#2083's remake for a window's image never given back was made with the swapchain before handed over (oldSwapchain)
at the same size and image count. On the reporter's RX 9070 XT (AMD 26.10.1, Windows 11, FSR 3.1 frame generation,
nightly-745) the new swapchain's first image was held again at once, with the game in front, and the picture stayed
frozen until F11, whose 1280x720 swapchain can't take the old images over.

The remake is now fresh (create_swapchain_fresh): the swapchain before is let go first (the GPU idle, it destroyed),
the new one is made with no oldSwapchain and asks for another image count than the one before had
(gpu/vk/swapchain_fresh.h). On Windows, the game window coming back in front during a hold it spent behind another
window (Alt+Tab) makes it fresh at once instead of after the rest of the 1 s wait. Each is logged.

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

Tested in game: Windows 11 (build 26300), NVIDIA GeForce RTX 5080, NVIDIA 621.24, 1920x1080 at 360 Hz. This PR @ 74dd812e as a pack over main eee3e1d5's base, through the job queue with the control bridge: the castle-gate save (Hyrule Field, child Link), frame generation Auto (AMD FSR 3.1, 3 to 4 made frames a game frame), a 1280x720 window, then full screen through the Fullscreen row (F11's path), then a window again, walking. Presents went on at each stage (425, 510, 344), none stalled, shots show the scene moving, clean close. No image is held on NVIDIA, so the new remake did not run on its own; a local-only hook calling create_swapchain_fresh every 4 s made the swapchain fresh 16 times over the same steps (4 and 5 images in turn, window and full screen, across both Fullscreen changes) with presents going on and frame interpolation at 0 late frames. The AMD Windows path itself needs the Test Farm.

Tested in game: Windows 11 (build 26300), NVIDIA GeForce RTX 5080, NVIDIA 621.24, 1920x1080 at 360 Hz. This PR @ 74dd812e as a pack over main eee3e1d5's base, through the job queue with the control bridge: the castle-gate save (Hyrule Field, child Link), frame generation Auto (AMD FSR 3.1, 3 to 4 made frames a game frame), a 1280x720 window, then full screen through the Fullscreen row (F11's path), then a window again, walking. Presents went on at each stage (425, 510, 344), none stalled, shots show the scene moving, clean close. No image is held on NVIDIA, so the new remake did not run on its own; a local-only hook calling create_swapchain_fresh every 4 s made the swapchain fresh 16 times over the same steps (4 and 5 images in turn, window and full screen, across both Fullscreen changes) with presents going on and frame interpolation at 0 late frames. The AMD Windows path itself needs the Test Farm.
Author
Member

@Beanstalk Windows with an AMD RX 9000 or 7000 card, and one NVIDIA RTX card: set frame generation on (FSR 3.1 frame generation first, then the built-in one), full screen, in Hyrule Field. Alt+Tab to another window for about 10 seconds and back, 5 times; then play 10 minutes in full screen without Alt+Tab. Check that the picture is moving again within about a second of coming back each time (on main the picture can stay frozen until F11 while the sound goes on). Post the log lines with "not given back", "the swapchain made again" and "a fresh swapchain", and say whether the picture ever froze, and for how long.

@Beanstalk Windows with an AMD RX 9000 or 7000 card, and one NVIDIA RTX card: set frame generation on (FSR 3.1 frame generation first, then the built-in one), full screen, in Hyrule Field. Alt+Tab to another window for about 10 seconds and back, 5 times; then play 10 minutes in full screen without Alt+Tab. Check that the picture is moving again within about a second of coming back each time (on main the picture can stay frozen until F11 while the sound goes on). Post the log lines with "not given back", "the swapchain made again" and "a fresh swapchain", and say whether the picture ever froze, and for how long.
Member

Beanstalk test farm

Commit 5ddd9b4 · approved by nobody yet · dashboard

A member of BigBeans can review this commit and comment @Beanstalk to test it.

<!-- beanstalk:sticky --> ### Beanstalk test farm Commit `5ddd9b4` · approved by nobody yet · [dashboard](https://beanstalk.magicbean.dev/prs/2214) A member of `BigBeans` can review this commit and comment `@Beanstalk` to test it.
llun changed title from fix(vk): the held image's remake makes the swapchain fresh, and at once when the game is back in front to WIP: fix(vk): the held image's remake makes the swapchain fresh, and at once when the game is back in front 2026-11-22 05:10:10 +00:00
Author
Member
@review
BeanBot requested changes 2026-11-22 05:12:51 +00:00
Dismissed
BeanBot left a comment

Recommendation: Request changes. The fresh remake works in the model and in forced NVIDIA remakes, but it has not yet been shown to recover the reported AMD freeze. The shared recovery path and the changed swapchain image count also need testing on the affected systems. (It stands on L3: The check Guide screenshots / Guide images and local UI source review (pull_request) fails on this head and passes on the base branch: Failing after 15s.)

The change destroys and recreates a swapchain when an acquired image remains held, and attempts recovery immediately when a Windows window returns to the foreground. It may restore a frozen picture without F11, at the cost of a device-idle wait and a potentially different swapchain image count.

@fix will do (3)

  1. L2 (its part an edit can do) gpu/vk/vk_main.cpp:1179: Restore the usual image count after recovery if the fresh count is not needed for the remainder of the session.
  2. L3: The check Guide screenshots / Guide images and local UI source review (pull_request) fails on this head and passes on the base branch: Failing after 15s.
  3. L4: The check CI / Website build and checks (pull_request) fails on this head and passes on the base branch: Failing after 1m17s.

Before merging: testing (2) (runs on the systems it can change; it doesn't hold the recommendation)

  • L1 (minor) gpu/vk/vk_main.cpp:1234: The model assumes that a fresh swapchain releases the stuck image, but the reported AMD driver behavior has not been tested with this change. (more on the line)
  • L2 (minor) gpu/vk/vk_main.cpp:1179: A recovered swapchain can retain a different image count for the rest of a session; one fewer image can reduce frame-generation presentation capacity, while one more consumes VRAM. (more on the line)
More: does it help, other systems, switches, what was read

Does it help: Unproven for the reported bug. The model fails on main and passes here; on Windows with an RTX 5080, 16 forced fresh remakes continued presenting, but the driver did not reproduce the held image. No AMD run has established that the picture recovers.

Other systems: The held-image remake also runs on Linux and on other GPU vendors. NVIDIA Windows was exercised with forced remakes, but Linux, Steam Deck, and AMD Windows recovery remain untested. A changed image count can also affect frame-generation presentation capacity and VRAM after recovery.

Switches: None added, changed, or removed.

Reviewed: 74dd812e97 against a2dc538590: Read the repository rules, PR template, standards, commit messages, full diff, new header and test, changed test logic, and the swapchain and presentation code surrounding the changes. Skimmed the remaining portions of the large changed source and test files; the full changed files were not all read in full. docs/review-checklist.md and the adjacent Tooling checkout were absent. No generated files or translations changed.; nothing run (a code review).

Checked and fine:

  • Both commits record AI assistance.
  • No renderer API version, shader, generated file, game-derived file, or switch-table change is indicated by the diff.
  • The fresh path drains the presenter before taking the queue lock and retires the old swapchain before creating its replacement.

Testing: Read-only review; no builds, tests, or project scripts were run. The PR reports a model test and Windows NVIDIA in-game runs; its AMD and Linux runs remain outstanding.

Overlaps and merge order: None found in the supplied review context.


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

**Recommendation: Request changes.** The fresh remake works in the model and in forced NVIDIA remakes, but it has not yet been shown to recover the reported AMD freeze. The shared recovery path and the changed swapchain image count also need testing on the affected systems. (It stands on L3: The check `Guide screenshots / Guide images and local UI source review (pull_request)` fails on this head and passes on the base branch: Failing after 15s.) The change destroys and recreates a swapchain when an acquired image remains held, and attempts recovery immediately when a Windows window returns to the foreground. It may restore a frozen picture without F11, at the cost of a device-idle wait and a potentially different swapchain image count. **`@fix` will do (3)** 1. **L2** (its part an edit can do) `gpu/vk/vk_main.cpp:1179`: Restore the usual image count after recovery if the fresh count is not needed for the remainder of the session. 2. **L3**: The check `Guide screenshots / Guide images and local UI source review (pull_request)` fails on this head and passes on the base branch: Failing after 15s. 3. **L4**: The check `CI / Website build and checks (pull_request)` fails on this head and passes on the base branch: Failing after 1m17s. **Before merging: testing (2)** (runs on the systems it can change; it doesn't hold the recommendation) - **L1** (minor) `gpu/vk/vk_main.cpp:1234`: The model assumes that a fresh swapchain releases the stuck image, but the reported AMD driver behavior has not been tested with this change. (more on the line) - **L2** (minor) `gpu/vk/vk_main.cpp:1179`: A recovered swapchain can retain a different image count for the rest of a session; one fewer image can reduce frame-generation presentation capacity, while one more consumes VRAM. (more on the line) <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Unproven for the reported bug. The model fails on main and passes here; on Windows with an RTX 5080, 16 forced fresh remakes continued presenting, but the driver did not reproduce the held image. No AMD run has established that the picture recovers. **Other systems:** The held-image remake also runs on Linux and on other GPU vendors. NVIDIA Windows was exercised with forced remakes, but Linux, Steam Deck, and AMD Windows recovery remain untested. A changed image count can also affect frame-generation presentation capacity and VRAM after recovery. **Switches:** None added, changed, or removed. **Reviewed:** 74dd812e9712 against a2dc53859018: Read the repository rules, PR template, standards, commit messages, full diff, new header and test, changed test logic, and the swapchain and presentation code surrounding the changes. Skimmed the remaining portions of the large changed source and test files; the full changed files were not all read in full. docs/review-checklist.md and the adjacent Tooling checkout were absent. No generated files or translations changed.; nothing run (a code review). **Checked and fine:** - Both commits record AI assistance. - No renderer API version, shader, generated file, game-derived file, or switch-table change is indicated by the diff. - The fresh path drains the presenter before taking the queue lock and retires the old swapchain before creating its replacement. **Testing:** Read-only review; no builds, tests, or project scripts were run. The PR reports a model test and Windows NVIDIA in-game runs; its AMD and Linux runs remain outstanding. **Overlaps and merge order:** None found in the supplied review context. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by llun. Nothing was run; a maintainer decides.</sub>
@ -1166,6 +1176,10 @@ bool create_swapchain(uint32_t width, uint32_t height) {
const uint32_t slots_made = (uint32_t)present_slots_for(swapchain_framegen(), fg_sets == 2);
if (caps.maxImageCount) ci.minImageCount = std::min(ci.minImageCount, caps.maxImageCount);
ci.imageFormat = fmt.format;
// (#1482) fresh: another image count than the one before had, so the driver cannot hand its images on (swapchain_fresh.h)
Member

L2 (minor): A recovered swapchain can retain a different image count for the rest of a session; one fewer image can reduce frame-generation presentation capacity, while one more consumes VRAM. Measure frame pacing and VRAM after recovery against main on representative Tier 1 hardware, including Linux and Steam Deck, and verify ordinary presentation and recovery there.

**L2** (minor): A recovered swapchain can retain a different image count for the rest of a session; one fewer image can reduce frame-generation presentation capacity, while one more consumes VRAM. Measure frame pacing and VRAM after recovery against main on representative Tier 1 hardware, including Linux and Steam Deck, and verify ordinary presentation and recovery there.
@ -1217,1 +1231,4 @@
VkSwapchainKHR sc;
// (#1482) fresh: the one before let go first, the GPU idle and it destroyed, so nothing of it is handed over; the image
// it held goes with it (present_image lets its fence go at the next present)
if (swapchain_fresh && dev.swapchain) {
Member

L1 (minor): The model assumes that a fresh swapchain releases the stuck image, but the reported AMD driver behavior has not been tested with this change. Run the reported Alt+Tab reproduction on AMD Windows with both frame-generation methods and verify repeated recovery and subsequent play.

**L1** (minor): The model assumes that a fresh swapchain releases the stuck image, but the reported AMD driver behavior has not been tested with this change. Run the reported Alt+Tab reproduction on AMD Windows with both frame-generation methods and verify repeated recovery and subsequent play.
llun changed title from WIP: fix(vk): the held image's remake makes the swapchain fresh, and at once when the game is back in front to fix(vk): the held image's remake makes the swapchain fresh, and at once when the game is back in front 2026-11-22 05:13:21 +00:00
Author
Member

On the review:

  • L3, Guide screenshots: this isn't from this PR. scripts/check_guide_screenshots.py --review-sources compares the whole tree with the recorded review hashes, not the PR's diff. On main @ a2dc5385, run here, it fails with the same 10 files, gpu/vk/vk_internal.h among them (main changed it since settings-graphics.png was reviewed). This PR changes no UI, so it doesn't update the hashes; that needs a look at the settings screen.
  • L4, Website build: table/menu graphics coverage mismatch at Simulated turf comes from main's Simulated turf row (#2093, #2174). #2213 fixes it. This PR touches neither the website nor the graphics settings.
  • L2, the image count after recovery: kept as it is, on purpose. fresh_image_count asks for one image more than the swapchain before had. It asks for one fewer only when that count is already the surface's most (16 on the reported RX 9070 XT; 4 to 8 asked for here), so frame generation doesn't lose a spare image in practice. The extra image costs one image of video memory (about 8 MB at 1080p) until the next ordinary remake (F11, a resize, a V-Sync or frame generation change) asks for the usual count again. Putting the usual count back right after recovery would mean a second device-idle remake just as the picture comes back: a hitch the player sees, to save 8 MB. If a maintainer prefers that, it's a small change.
  • L1, testing on AMD: agreed; it's the first item of Still to test. Beanstalk answered that the farm can't change focus or see whether the picture comes back, so it can't run the Alt+Tab steps. That needs a person with an RX 9000 or 7000 on Windows, ideally the reporter of #1482 on a build with this change.
On the review: - **L3, Guide screenshots:** this isn't from this PR. `scripts/check_guide_screenshots.py --review-sources` compares the whole tree with the recorded review hashes, not the PR's diff. On main @ a2dc5385, run here, it fails with the same 10 files, `gpu/vk/vk_internal.h` among them (main changed it since `settings-graphics.png` was reviewed). This PR changes no UI, so it doesn't update the hashes; that needs a look at the settings screen. - **L4, Website build:** `table/menu graphics coverage mismatch at Simulated turf` comes from main's Simulated turf row ([#2093](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2093), [#2174](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2174)). [#2213](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2213) fixes it. This PR touches neither the website nor the graphics settings. - **L2, the image count after recovery:** kept as it is, on purpose. `fresh_image_count` asks for one image **more** than the swapchain before had. It asks for one fewer only when that count is already the surface's most (16 on the reported RX 9070 XT; 4 to 8 asked for here), so frame generation doesn't lose a spare image in practice. The extra image costs one image of video memory (about 8 MB at 1080p) until the next ordinary remake (F11, a resize, a V-Sync or frame generation change) asks for the usual count again. Putting the usual count back right after recovery would mean a second device-idle remake just as the picture comes back: a hitch the player sees, to save 8 MB. If a maintainer prefers that, it's a small change. - **L1, testing on AMD:** agreed; it's the first item of Still to test. Beanstalk answered that the farm can't change focus or see whether the picture comes back, so it can't run the Alt+Tab steps. That needs a person with an RX 9000 or 7000 on Windows, ideally the reporter of #1482 on a build with this change.
llun changed title from fix(vk): the held image's remake makes the swapchain fresh, and at once when the game is back in front to WIP: fix(vk): the held image's remake makes the swapchain fresh, and at once when the game is back in front 2026-11-22 05:44:29 +00:00
Author
Member

Not fixed, and worse: back to WIP. Please don't merge.

A log from this PR's own build (pr-2214-74dd812e) on the reporter's setup (RX 9070 XT, AMD 26.10.1, Windows 11, FSR 3.1 frame generation at 2x, fullscreen) shows:

  1. The first Alt+Tab and back: no image held, the picture fine.
  2. The second Alt+Tab: the image was held the moment the game came back in front, not while it was behind. the window's image was not given back in 250 ms follows hid: game window in front directly. So the new "back in front" remake never ran: it only fires for a hold that began while the window was behind.
  3. 1 s later the fresh remake ran (... not given back in 1 s: the swapchain made again, fresh), and letting the swapchain before go blocked for about 12 s, with the queue's lock held. The recorder was blocked on that lock for 12113.94 ms, hid: the game read no controller for 12.1 s, the game presented 16 fps over 16.8 s, and the next frame was shown 12145.5 ms after the game handed it over.
  4. It came back only with F11: display: windowed is logged before vk: a fresh swapchain: the one before (6 images) let go first, 7 images asked for. That line is written after retire_swapchain returns, so the destroy finished only once the window changed.

On main the picture freezes while the game and its sound go on. With this PR the whole game stops until F11. That's a regression.

What it says about the cause: the idea behind this PR, that the driver hands the held image on to a remade swapchain of the same size, is wrong, or not what matters. The system keeps the image until something new is shown on the window, or the window itself changes (F11). No swapchain remake frees it, and destroying the swapchain only waits for the system to let it go. What's left, from this evidence:

  • Present another image instead of holding the one not given back (acquire another, show it), so the system lets the held one go. Unproven.
  • F11's own window change, done by the game when a hold doesn't end. This log and the earlier ones prove it works, but the window leaves fullscreen and comes back.

Also seen: the hold can begin as the game comes back in front. A fix has to cover that case, not only a hold that began while the window was hidden.

The rest of BeanBot's review (the image count) and the Still to test steps are on hold until there's a direction that holds up against this log.

**Not fixed, and worse: back to WIP. Please don't merge.** A log from this PR's own build (`pr-2214-74dd812e`) on the reporter's setup (RX 9070 XT, AMD 26.10.1, Windows 11, FSR 3.1 frame generation at 2x, fullscreen) shows: 1. The first Alt+Tab and back: no image held, the picture fine. 2. The second Alt+Tab: the image was held the moment the game came **back in front**, not while it was behind. `the window's image was not given back in 250 ms` follows `hid: game window in front` directly. So the new "back in front" remake never ran: it only fires for a hold that began while the window was behind. 3. 1 s later the fresh remake ran (`... not given back in 1 s: the swapchain made again, fresh`), and **letting the swapchain before go blocked for about 12 s**, with the queue's lock held. The recorder was blocked on that lock for 12113.94 ms, `hid: the game read no controller for 12.1 s`, the game presented 16 fps over 16.8 s, and the next frame was shown 12145.5 ms after the game handed it over. 4. It came back only with F11: `display: windowed` is logged **before** `vk: a fresh swapchain: the one before (6 images) let go first, 7 images asked for`. That line is written after `retire_swapchain` returns, so the destroy finished only once the window changed. On main the picture freezes while the game and its sound go on. With this PR the whole game stops until F11. That's a regression. What it says about the cause: the idea behind this PR, that the driver hands the held image on to a remade swapchain of the same size, is wrong, or not what matters. The system keeps the image until something new is shown on the window, or the window itself changes (F11). No swapchain remake frees it, and destroying the swapchain only waits for the system to let it go. What's left, from this evidence: - Present another image instead of holding the one not given back (acquire another, show it), so the system lets the held one go. Unproven. - F11's own window change, done by the game when a hold doesn't end. This log and the earlier ones prove it works, but the window leaves fullscreen and comes back. Also seen: the hold can begin as the game comes back in front. A fix has to cover that case, not only a hold that began while the window was hidden. The rest of BeanBot's review (the image count) and the Still to test steps are on hold until there's a direction that holds up against this log.
fix(vk): show another image in place of one the window does not give back, instead of a fresh swapchain (#1482)
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 9s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 13s
CI / Workflow lint (actionlint) (pull_request) Successful in 14s
Third-party parts / As their notes say (pull_request) Successful in 15s
CI / Website build and checks (pull_request) Failing after 37s
PR description / Description follows the template (pull_request_target) Failing after 4s
beanstalk/approval not approved yet
5ddd9b4501
The fresh swapchain didn't fix it, and made it worse: on the reporter's RX 9070 XT the image was held as the game came
back in front, and destroying the swapchain first waited 12 s for the system, the whole game stalled until F11.

The system keeps the image it shows until another one is shown on the window. So the fresh remake is gone (the
held-image remake is #2083's again), and while an image is held one more is asked for with a timeout of 0 and a fence
of its own, and shown in its place if it is free within 2 ms; the system then lets the held one go, and it is shown at
a later present. One not free is kept and looked at again at the next present; at most two are held. The held-image
test's engine now keeps the shown image until another is shown, and a remake with the swapchain before handed over
takes it over, as the reporter's logs show.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
llun changed title from WIP: fix(vk): the held image's remake makes the swapchain fresh, and at once when the game is back in front to WIP: fix(vk): another image is shown in place of one the window does not give back, so the picture no longer freezes after Alt+Tab 2026-11-22 05:49:26 +00:00
Author
Member

Reworked after the AMD log above: the fresh swapchain is gone (it stalled the game 12 s). Now, while an image is held, another is asked for (timeout 0, its own fence) and shown in its place if free within 2 ms, so the system lets the held one go; #2083's remake stays for when none can be shown. The test's engine now keeps the shown image until another is shown. Not run in game yet: an AMD test of this head is next (steps in Still to test). BeanBot's points on the first version (image count, fresh remake) no longer apply: there is no fresh swapchain or changed image count now.

Reworked after the AMD log above: the fresh swapchain is gone (it stalled the game 12 s). Now, while an image is held, another is asked for (timeout 0, its own fence) and shown in its place if free within 2 ms, so the system lets the held one go; #2083's remake stays for when none can be shown. The test's engine now keeps the shown image until another is shown. Not run in game yet: an AMD test of this head is next (steps in Still to test). BeanBot's points on the first version (image count, fresh remake) no longer apply: there is no fresh swapchain or changed image count now.
Author
Member
@review
BeanBot left a comment

Recommendation: Request changes. The fresh-swapchain approach and its lasting image-count change are gone. The replacement recovery still needs to be demonstrated on the affected AMD Windows setup. (It stands on L3: The check Guide screenshots / Guide images and local UI source review (pull_request) fails on this head and passes on the base branch: Failing after 15s.)

While a swapchain image is held, the change tries to present another image so the held one can be released. It avoids the former fresh-swapchain approach and its reported 12-second stall, at the cost of holding up to one additional image during recovery.

@fix will do (2)

  1. L3: The check Guide screenshots / Guide images and local UI source review (pull_request) fails on this head and passes on the base branch: Failing after 15s.
  2. L4: The check CI / Website build and checks (pull_request) fails on this head and passes on the base branch: Failing after 1m17s.

Before merging: testing (1) (runs on the systems it can change; it doesn't hold the recommendation)

  • L1 (minor) gpu/vk/vk_main.cpp:1234: The model assumes that a fresh swapchain releases the stuck image, but the reported AMD driver behavior has not been tested with this change. Run the reported Alt+Tab reproduction on AMD Windows with both frame-generation methods and verify repeated recovery and subsequent play.

Since the last review (on 74dd812e97)
Resolved: L2 (A recovered swapchain can retain a different image count for the rest of a session; one fe…)
Still open: L1 (The model assumes that a fresh swapchain releases the stuck image, but the reported AMD dr…); L3 (The check Guide screenshots / Guide images and local UI source review (pull_request) fai…); L4 (The check CI / Website build and checks (pull_request) fails on this head and passes on…)

Also noticed (1; not asked for, not blocking)
  • The held-image test still contains messages describing a fresh remake, although the implementation now presents another image.
More: does it help, other systems, switches, what was read

Does it help: Unproven. The reporter reproduced the freeze on an RX 9070 XT, but this head has not been tested in the game; the test models the proposed recovery.

Other systems: The held-image path is shared across Windows and Linux and can affect other GPU drivers and presentation modes. The earlier NVIDIA run tested a different implementation; this head has no reported in-game runs.

Switches: None added, changed or removed.

Reviewed: 5ddd9b4501 against a2dc538590: Read AGENTS.md, CONTRIBUTING.md, the pull request template, standards, the diff, and the changed test and thread documentation. Reviewed the presentation code around the changed helpers and their callers; the rest of the large replay file was skimmed.; nothing run (a code review).

Checked and fine:

  • The replacement image uses a separate acquire fence and is retained when it is not yet free.
  • Acquire-ahead is suppressed while either image is held.
  • The fresh-swapchain image-count change is absent from the final diff.

Testing: No commands that build or run tests were executed. The reported test model covers recovery by presenting another image; the affected AMD driver and this head remain untested in game.

Overlaps and merge order: None identified.


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

**Recommendation: Request changes.** The fresh-swapchain approach and its lasting image-count change are gone. The replacement recovery still needs to be demonstrated on the affected AMD Windows setup. (It stands on L3: The check `Guide screenshots / Guide images and local UI source review (pull_request)` fails on this head and passes on the base branch: Failing after 15s.) While a swapchain image is held, the change tries to present another image so the held one can be released. It avoids the former fresh-swapchain approach and its reported 12-second stall, at the cost of holding up to one additional image during recovery. **`@fix` will do (2)** 1. **L3**: The check `Guide screenshots / Guide images and local UI source review (pull_request)` fails on this head and passes on the base branch: Failing after 15s. 2. **L4**: The check `CI / Website build and checks (pull_request)` fails on this head and passes on the base branch: Failing after 1m17s. **Before merging: testing (1)** (runs on the systems it can change; it doesn't hold the recommendation) - **L1** (minor) `gpu/vk/vk_main.cpp:1234`: The model assumes that a fresh swapchain releases the stuck image, but the reported AMD driver behavior has not been tested with this change. Run the reported Alt+Tab reproduction on AMD Windows with both frame-generation methods and verify repeated recovery and subsequent play. **Since the last review** (on 74dd812e9712) Resolved: L2 (A recovered swapchain can retain a different image count for the rest of a session; one fe…) Still open: L1 (The model assumes that a fresh swapchain releases the stuck image, but the reported AMD dr…); L3 (The check `Guide screenshots / Guide images and local UI source review (pull_request)` fai…); L4 (The check `CI / Website build and checks (pull_request)` fails on this head and passes on…) <details> <summary>Also noticed (1; not asked for, not blocking)</summary> - The held-image test still contains messages describing a fresh remake, although the implementation now presents another image. </details> <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Unproven. The reporter reproduced the freeze on an RX 9070 XT, but this head has not been tested in the game; the test models the proposed recovery. **Other systems:** The held-image path is shared across Windows and Linux and can affect other GPU drivers and presentation modes. The earlier NVIDIA run tested a different implementation; this head has no reported in-game runs. **Switches:** None added, changed or removed. **Reviewed:** 5ddd9b450136 against a2dc53859018: Read AGENTS.md, CONTRIBUTING.md, the pull request template, standards, the diff, and the changed test and thread documentation. Reviewed the presentation code around the changed helpers and their callers; the rest of the large replay file was skimmed.; nothing run (a code review). **Checked and fine:** - The replacement image uses a separate acquire fence and is retained when it is not yet free. - Acquire-ahead is suppressed while either image is held. - The fresh-swapchain image-count change is absent from the final diff. **Testing:** No commands that build or run tests were executed. The reported test model covers recovery by presenting another image; the affected AMD driver and this head remain untested in game. **Overlaps and merge order:** None identified. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by llun. Nothing was run; a maintainer decides.</sub>
llun changed title from WIP: fix(vk): another image is shown in place of one the window does not give back, so the picture no longer freezes after Alt+Tab to fix(vk): another image is shown in place of one the window does not give back, so the picture no longer freezes after Alt+Tab 2026-11-22 05:52:44 +00:00
Author
Member

Closing as it didn't work for the user at all. Will have to continue another time.

Closing as it didn't work for the user at all. Will have to continue another time.
llun closed this pull request 2026-11-22 06:15:23 +00:00
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 9s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 13s
CI / Workflow lint (actionlint) (pull_request) Successful in 14s
Third-party parts / As their notes say (pull_request) Successful in 15s
CI / Website build and checks (pull_request) Failing after 37s
PR description / Description follows the template (pull_request_target) Failing after 4s
beanstalk/approval not approved yet

Pull request closed

Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
3 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!2214
No description provided.