runtime/test: xbox_present presents again after a resize when the first present was out of date (RT-XBOX-PRESENT-RESIZE-UNSHOWN) #3513

Code

Clone this repository

Checkout

From your project repository, check out a new branch and test the changes.

git fetch -u  "rt/xbox-present-resize-unshown:jirehcwe-rt/xbox-present-resize-unshown"
git switch "jirehcwe-rt/xbox-present-resize-unshown"
Open
leonida/mandy
jirehcwe wants to merge 1 commit from jirehcwe/mandy:rt/xbox-present-resize-unshown into main

This branch is out-of-date with the base branch

Conversation
Reviewers 0 approvals
  • No reviewers
Details
This pull request is blocked because it's outdated.
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 'rt/xbox-present-resize-unshown:jirehcwe-rt/xbox-present-resize-unshown'
git switch 'jirehcwe-rt/xbox-present-resize-unshown'
First-time contributor

Claimed in the coordination issue as: RT-XBOX-PRESENT-RESIZE-UNSHOWN (claim)

What and why

xbox_present fails on every run on an RTX 3060 Ti, in the resize case of runtime/test/xbox_present_test.cpp
("F: the window changes size between composed presents"), at its first EXPECT(present_planes(&one, 1)).

Right after SetWindowPos, vkQueuePresentKHR returns VK_ERROR_OUT_OF_DATE_KHR for the first present; the acquire
before it succeeds. PresentX returns S_OK. Since b03482aeb (RT-POST-LOAD-GPU-MEMORY), VulkanPresenter marks a
frame as captured only when the present was shown ("never expose a stale sample after an unsampled or unshown frame",
runtime/src/vulkan_present.h). So read_back() has no frame until the next shown one, as its doc comment says. The
resize loop was written before that commit, when any submitted frame could be read back, and its comment still said
"the frame is still composed and read back".

The change is test-only:

  • The resize loop presents once more, once a size, when all three hold: PresentX was accepted, nothing could be read
    back, and the count of composed presents did not move. That is how an unshown present looks. The next present
    recreates the swapchain and is shown.
  • Any other failure still fails the test: a PresentX error, a second unshown present for the same size, a read back
    that fails after a shown present, or a mismatch with the model. Every frame that is compared is a shown one, checked
    at its real extent, and round == 2 still requires the new size.
  • present_planes gets an optional accepted out-parameter. Its other callers are unchanged.
  • The comments are corrected.

The minimised case later in the same file already retries after unshown presents, so this follows its precedent.

Tested

  • Before the change, on main f4b0404e9: xbox_present fails 3 of 3 runs. Measured with temporary prints:
    result=-1000001004 acquired=0 copy_frame=1 captured=0 ext=320x240, then read_back=0.
  • After the change: xbox_present and xbox_present_readback_size pass 8 of 8 runs (5 before the review's comment
    edits, 3 after). No new compiler warning in the test file.
  • python -I scripts/check_no_game_data.py: clean, on the whole tree.
  • An independent read-only reviewer agent traced VulkanPresenter::submit, read_back and xbox_present.cpp and
    approved:
    • The runtime behaviour is intended and consistent with the other unshown paths (minimised, surface lost).
    • A runtime-side retry, or exposing an unshown frame, would break the "read back is what the window shows" contract.
    • The retry can't mask a stale or mis-sized compose target.
    • Its three comment-wording nits are applied.
  • Not tested: other GPUs or drivers. Where the first present after a resize is shown, the retry never runs and the
    loop behaves as before.

GPUs tested: NVIDIA GeForce RTX 3060 Ti, driver 610.88, Windows 11 Pro (build 26200)

AI-assisted: yes. Claude Code with Claude Fable 5.2 wrote the change. A separate read-only reviewer agent on Claude
Opus 5.5 reviewed it.

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: no translator change)

🤖 Generated with Claude Code

Claimed in the coordination issue as: RT-XBOX-PRESENT-RESIZE-UNSHOWN ([claim](https://clearfieldswimming.com/leonida/mandy/issues/3312#issuecomment-26777)) ### What and why `xbox_present` fails on every run on an RTX 3060 Ti, in the resize case of `runtime/test/xbox_present_test.cpp` ("F: the window changes size between composed presents"), at its first `EXPECT(present_planes(&one, 1))`. Right after `SetWindowPos`, `vkQueuePresentKHR` returns `VK_ERROR_OUT_OF_DATE_KHR` for the first present; the acquire before it succeeds. `PresentX` returns `S_OK`. Since `b03482aeb` (RT-POST-LOAD-GPU-MEMORY), `VulkanPresenter` marks a frame as captured only when the present was shown ("never expose a stale sample after an unsampled or unshown frame", `runtime/src/vulkan_present.h`). So `read_back()` has no frame until the next shown one, as its doc comment says. The resize loop was written before that commit, when any submitted frame could be read back, and its comment still said "the frame is still composed and read back". The change is test-only: - The resize loop presents once more, once a size, when all three hold: `PresentX` was accepted, nothing could be read back, and the count of composed presents did not move. That is how an unshown present looks. The next present recreates the swapchain and is shown. - Any other failure still fails the test: a `PresentX` error, a second unshown present for the same size, a read back that fails after a shown present, or a mismatch with the model. Every frame that is compared is a shown one, checked at its real extent, and `round == 2` still requires the new size. - `present_planes` gets an optional `accepted` out-parameter. Its other callers are unchanged. - The comments are corrected. The minimised case later in the same file already retries after unshown presents, so this follows its precedent. ### Tested - **Before the change**, on `main` `f4b0404e9`: `xbox_present` fails 3 of 3 runs. Measured with temporary prints: `result=-1000001004 acquired=0 copy_frame=1 captured=0 ext=320x240`, then `read_back=0`. - **After the change:** `xbox_present` and `xbox_present_readback_size` pass 8 of 8 runs (5 before the review's comment edits, 3 after). No new compiler warning in the test file. - `python -I scripts/check_no_game_data.py`: clean, on the whole tree. - An independent read-only reviewer agent traced `VulkanPresenter::submit`, `read_back` and `xbox_present.cpp` and approved: - The runtime behaviour is intended and consistent with the other unshown paths (minimised, surface lost). - A runtime-side retry, or exposing an unshown frame, would break the "read back is what the window shows" contract. - The retry can't mask a stale or mis-sized compose target. - Its three comment-wording nits are applied. - Not tested: other GPUs or drivers. Where the first present after a resize is shown, the retry never runs and the loop behaves as before. GPUs tested: NVIDIA GeForce RTX 3060 Ti, driver 610.88, Windows 11 Pro (build 26200) AI-assisted: yes. Claude Code with Claude Fable 5.2 wrote the change. A separate read-only reviewer agent on Claude Opus 5.5 reviewed it. ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [x] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a: no translator change) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Right after the window is resized, vkQueuePresentKHR can return VK_ERROR_OUT_OF_DATE_KHR
for the first present (RTX 3060 Ti, driver 610.88: every run). PresentX returns S_OK, but
since b03482aeb the presenter marks a frame as captured only when the present was shown,
so read_back() has no frame until the next shown one. The resize case still expected the
unshown frame to be read back and failed at its first present.

The resize loop now presents once more, once a size, when PresentX was accepted, nothing
could be read back and the count of composed presents did not move. Any other failure
still fails the test. Test-only; the comment that said the frame is still read back is
corrected.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Sign in to join this conversation.
No description provided.