vulkan_present: keep continuous readback valid on OUT_OF_DATE present #2507
Closed
github-bot
wants to merge 2 commits from
github-bot/gh-2507 into main
AGit
pull from: github-bot/gh-2507
merge into: github:main
github:main
github:perf/darner-title-priority-ceiling
github:gh-readonly-queue/main/pr-3311-b5c45b663dbc5a9c3532bb3f307e5f81b32faefa
github:gh-readonly-queue/main/pr-3088-af22e7847ff5808f72d1a1881c24be2fafd20b54
github:gh-readonly-queue/main/pr-3123-7f3fa026a94c6646e89244f28e1ce22290361867
github:gh-readonly-queue/main/pr-3354-637baa0b77ba47222e7280b17c1a59c6a1781d57
github:gh-readonly-queue/main/pr-3365-d7a0e0196a43834813014b4bd3aa5502a8263b14
github:gh-readonly-queue/main/pr-3361-5dfe8bbd05ed12fb2f2e1718d9af77a7c5f46fd8
github:gh-readonly-queue/main/pr-3366-8da9148204e9d12c585efa9ac2b7cc1ab08c7682
github:fix/runtime-test-conservative-fixtures
github:ci/shard-semantic-linux
github:docs/fg-limit-fps-switch
github:fix/runtime-test-fixture-paths
github:fix/runtime-test-fixture-readers
github:fix/read-file-hard-link
github:fix/book-slot-heap-never-read
github:fix/depth-resolve-spv-path
github:fix/indirect-unused-batched
github:gh-pr/3358/base
github:fix/xmem-refusal-diagnostics
github:gh-pr/3357/base
github:ci/shorten-ci-time
github:fix/alias-later-queued-submissions
github:claude/gallant-sagan-aamatr
github:gh-pr/3342/base
github:gh-pr/3341/base
github:d3d12/agility-sdk-621
github:gh-pr/3293/base
github:gh-pr/3319/base
github:gh-pr/3318/base
github:gh-pr/3315/base
github:gh-pr/3313/base
github:gh-pr/3314/base
github:claude/fervent-curie-m19lnr
github:gh-pr/3216/base
github:gh-pr/3272/base
github:gh-pr/3276/base
github:gh-pr/3279/base
github:gh-pr/3257/base
github:gh-pr/3258/base
github:gh-pr/3271/base
github:codex/skip-no-hit-ray-passes
github:gh-pr/3230/base
github:gh-pr/3266/base
github:gh-pr/3247/base
github:gh-pr/3246/base
github:gh-pr/3244/base
github:claude/sharp-sagan-1jqnp3
github:t3/preserve-fsr-sdk-restart-path
github:t3/propagate-host-failure-hresult
github:t3/launcher-custom-parameters
github:t3/series-x-2160-startup
github:codex/d3d12-uncapped-simulation
github:ci/less-to-run
github:perf/native-compute-shader-forms
github:claude/blissful-franklin-ukp7ag
github:codex/full-precompile-default
github:gh-pr/3166/base
github:gh-pr/3148/base
github:gh-pr/3138/base
github:gh-pr/3106/base
github:gh-pr/3057/base
github:gh-pr/2756/base
github:gh-pr/2812/base
github:gh-pr/3032/base
github:gh-pr/2992/base
github:notes/card-time-and-plant-flicker
github:gh-pr/2986/base
github:gh-pr/3000/base
github:gh-pr/2966/base
github:gh-pr/2924/base
github:gh-pr/726/base
github:gh-pr/2761/base
github:gh-pr/2663/base
github:gh-pr/2861/base
github:gh-pr/2862/base
github:gh-pr/2820/base
github:gh-pr/2811/base
github:gh-pr/2803/base
github:rt-call-trace
github:gh-pr/2802/base
github:gh-pr/2766/base
github:perf/ahead-split
github:gh-pr/2589/base
github:gh-pr/2699/base
github:gh-pr/2696/base
github:docs/readme-runtime-proposal
github:gh-pr/1346/base
github:codex/coord-claim-check-20261124-7e48
No reviewers
Labels
Clear labels
accessibility
Barrier affecting people with disabilities
area: ci
.github/ workflows and settings
area: d3d12
The D3D12 runtime in d3d12/ (Rust: leonida.exe and its crates)
area: docs
Documentation
area: launcher
The launcher (launcher/)
area: runtime (legacy)
The earlier Vulkan runtime in runtime/
area: shader translator
The shader translator (leonida-shader, tools/rdna2spirv) and its tests
area: tools
tools/ and scripts/
area: viewer
The map viewer (viewer/)
bug
Something isn't working
dependencies
Pull requests that update a dependency file
documentation
Improvements or additions to documentation
duplicate
This issue or pull request already exists
enhancement
New feature or request
good first issue
Good for newcomers
help wanted
Extra attention is needed
invalid
This doesn't seem right
missing claim
Needs a claim in #14
needs in-game run
Changes the code a frame runs through: needs the 300 s in-game gate (docs/game_gate.md)
needs rebase
Conflicts with the base branch: rebase it on main
needs-triage
Needs maintainer evaluation before the next triage state
question
Further information is requested
ready-for-agent
Fully specified and ready for an AFK agent
submodules
Pull requests that update submodules code
wontfix
This will not be worked on
No labels
accessibility
area: ci
area: d3d12
area: docs
area: launcher
area: runtime (legacy)
area: shader translator
area: tools
area: viewer
bug
dependencies
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs in-game run
needs rebase
needs-triage
question
ready-for-agent
submodules
wontfix
Milestone
Clear milestone
No items
No milestone
Assignees
Clear assignees
No assignees
1 participant
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
github/ubiquitarianism--leonida!2507
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2507"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@lixonik on GitHub · 2026-11-27 21:29 UTC · original
lixonik:rt-present-resize-readback→main· +9 −6 · 1 files · 2 commits · closed without mergingSummary
Fixes a regression from
9f98dcc61(RT-POST-LOAD-GPU-MEMORY) inVulkanPresenter::submit_now()(runtime/src/vulkan_present.h) that brokexbox_presentcase F (xbox_present_test.cpp:1226) on NVIDIA RTX 5070 during window resize.When the window is resized between presents,
vkQueuePresentKHRon Windows/NVIDIA can returnVK_ERROR_OUT_OF_DATE_KHRafter the command buffer -- including thevkCmdCopyImageToBuffertransfer intocapture_buffer_-- has already been submitted (submitted == VK_SUCCESS).submit_now()still returnsVK_SUCCESS, andxbox_present_test.cpp:1224explicitly expects the composed frame to remain readable throughread_back().Commit
9f98dcc61clearedcaptured_ = falsebefore submission and moved thecaptured_ = trueassignment insideif (result == VK_SUCCESS || result == VK_SUBOPTIMAL_KHR). As a result, anyVK_ERROR_OUT_OF_DATE_KHRfromvkQueuePresentKHRleftcaptured_ == falseand causedread_back()to fail.This change:
pending_capture_ = frame.done) gated onVK_SUCCESS || VK_SUBOPTIMAL_KHRso only shown frames are written to disk.captured_,captured_extent_, andcaptured_format_whenevercopy_frame && capture_ptr_ran andresultisVK_SUCCESS,VK_SUBOPTIMAL_KHR, orVK_ERROR_OUT_OF_DATE_KHR(leavingVK_ERROR_SURFACE_LOST_KHRand other failures uncaptured).Verification
main39f52f39c):ctest --output-on-failure -R ^xbox_present$failed deterministically atxbox_present_test.cpp:1226(line 1226: present_planes(&one, 1)) during case F window resize (320x240 -> 400x300).ctest --output-on-failure -R ^(xbox_present|d3d12_present)$: 2/2 passed (d3d12_present1.45 s,xbox_present2.76 s).python -I scripts/check_no_game_data.py runtime/src/vulkan_present.h: pass.python -I tests/test_ctest_registration.py -v: pass.git diff --check: clean;git merge-treeclean against open PRs #2001 and #2014.Claimed in #1608 (
RT-PRESENT-RESIZE-READBACK). No game files used.GPUs tested: NVIDIA GeForce RTX 5070 12 GB (Windows 11, driver 610.88, Vulkan 1.4.341;
VK_LAYER_KHRONOS_validationnot installed locally).AI-assisted.
Independent follow-up
Three independent reports tested this head on RTX 5070 Ti and RTX 3080 on native Windows, and RTX 4070 SUPER and AMD Raphael under Wine. The window-resize test failed on their baseline and passed with the patch. The Wine report also forced WSI result codes after a real present and checked continuous readback and disk capture separately. RTX 5070 Ti report · RTX 3080 report · Wine and controlled WSI report
A later independent Wine run reproduced the first-resize failure on both main and the #2566 integration tree. Applying this PR alone made all six tested configurations pass 3/3, including desktop RTX 4070 SUPER and headless RTX 4070 SUPER / AMD Raphael configurations. The diagnostic RADV run traced the failure to missing continuous readback after PresentX succeeded. Desktop and headless follow-up
@Tyrannys on GitHub · 2026-11-27 21:39 UTC · original · approved these changes
Independent verification of head
b8486b4a5on profile M: RTX 4070 SUPER 12 GB, NVIDIA 621.01, Windows 11, Ryzen 7 9800X3D. MSVC RelWithDebInfo.main39f52f39c:ctest -C RelWithDebInfo --output-on-failure -R "^xbox_present$"failed 2 of 2 runs, atline 1226: present_planes(&one, 1)(case F, window resize). So this is not just an RTX 5070 issue: the 4070 SUPER on 621.01 hits it too.39f52f39ctogether with #2505, which only touches a compile-pool test):ctest -C RelWithDebInfo --output-on-failure -R "^(xbox_present|d3d12_present)$"passed 3 of 3 runs (xbox_present2.95-4.06 s,d3d12_present1.62-1.97 s). The resize case is part ofxbox_present, and it ran on the card.pending_capture_(disk capture) is still set only for a shown present.captured_is now also set forVK_ERROR_OUT_OF_DATE_KHR, but only aftervkQueueSubmitsucceeded, so the copy intocapture_buffer_was really queued.VK_ERROR_SURFACE_LOST_KHRstill clears it.Clean. Approving. No game files used.
AI-assisted (Claude Code).
@timbot103 on GitHub · 2026-11-28 02:01 UTC · original
Reviewed at head
b8486b4a5on Windows 11 (MSVC 202219.44) with dual-GPU Vulkan validation (LEONIDA_VK_VALIDATION=1, Vulkan SDK1.4.363.0).Verification
xbox_present_readback_size_testandxbox_present_test.xbox_present_readback_size_test: passed.xbox_present_test(LEONIDA_PRESENT_PLANE1=0,LEONIDA_VK_VALIDATION=1): all cases passed with 0 validation errors on both NVIDIA GeForce RTX 5080 (616.64) and AMD Radeon(TM) Graphics (25.10.30.02) — notably fixing the resizeOUT_OF_DATEfailure previously reproduced on RTX 5080 (window resized 320x240 -> 400x300 -> 200x150 -> 320x240 between composed presents: ok).Notes (non-blocking)
frame_index_after submit and publishing capture extent/format onVK_ERROR_OUT_OF_DATE_KHR(vulkan_present.h:364-374,650-717,1336-1412) is sound because the capture copy and transfer-to-host barrier were already submitted and fenced beforevkQueuePresentKHR, while surface-loss clears capture and minimize skips it.vulkan_present.h:360-363): Consider updating the contract comment stating a skipped present stays unreadable until a frame is shown so it mentions theOUT_OF_DATEsubmitted-capture case as well.Approve.
AI-assisted review + local MSVC/dual-GPU verification.
@zmasi on GitHub · 2026-11-29 00:59 UTC · original
#2507 | head
b8486b4a58(merged cleanly with main48bae6cade— no conflicts on currentmain) |ctest --test-dir runtime/build -C RelWithDebInfo -R "^(xbox_present_readback_size|vk_presenter_sync|d3d12_present|xbox_present)$" --output-on-failure(LEONIDA_VK_VALIDATION=1) | red on main:xbox_presentfails deterministically on RTX 3090 atline 1226: present_planes(&one, 1)during case F window resize (VK_ERROR_OUT_OF_DATE_KHRafter frame copy submission) | green on PR+main:4/4CTests (xbox_present_readback_size,vk_presenter_sync,d3d12_present,xbox_present—compose: window resized 320x240 -> 400x300 -> 200x150 -> 320x240 between composed presents: okandxbox_present_test: all cases pass, including HDR10 ST.2084 + tearing/non-tearing modes) pass in8.19 son RTX 3090 with0Khronos validation errors;check_no_game_data.py0violations | Windows 11, MSVC 19.44, RTX 3090, Vulkan SDK 1.4.363.1 | AI-assisted: yes@timbot103 on GitHub · 2026-11-29 01:08 UTC · original · reviewed
Reviewed head
b8486b4a5by static inspection only, with no builds or GPU runs.In
runtime/src/vulkan_present.h:650, the copy submission succeeds beforevkQueuePresentKHRruns. The capture path orders staging writes, makes them visible to the host, and transitions the image toPRESENT_SRC_KHRinruntime/src/vulkan_present.h:1336. The patch records the copied extent and format forVK_ERROR_OUT_OF_DATE_KHR, andread_back()still waits for that submission's fence before reading the bytes inruntime/src/vulkan_present.h:364.VK_SUCCESSandVK_SUBOPTIMAL_KHRstill qualify for disk sampling. An out-of-date or suboptimal present marks the swapchain stale, and recreation waits for the queue to idle before replacing its image semaphores and capture storage. Surface loss follows its existing recovery path and clears capture validity. Other present errors leave the new capture unpublished.Case F in
runtime/test/xbox_present_test.cpp:1212already verifies readback and pixel contents across resizes, including the settled extent. The exact WSI result during resize depends on the driver. No findings.AI-assisted.
@Diegobecker07 on GitHub · 2026-11-29 14:10 UTC · original
Verified on another setup: an RTX 5070 Ti with a newer driver (621.40), a display that exposes HDR10, and today's
main51d343b86. Thatmainalready has #2508, which moved the failing check from line 1226 to 1320.main51d343b86, thenmain+ PR headb8486b4a5(git merge --no-ff, local only, clean). Targets built:xbox_present_test,xbox_present_readback_size_test,vk_presenter_sync_test,d3d12_present_test,vk_present_dump_testandxs_present_lazy_test(Ninja, RelWithDebInfo, MSVC 19.44,LEONIDA_REQUIRE_VULKAN=ON).main,xbox_presentfails 3 of 3 atline 1320: present_planes(&one, 1), the first resize round of case F.xbox_presentpasses 3 of 3 (window resized 320x240 -> 400x300 -> 200x150 -> 320x240 between composed presents: ok,all cases pass). It also passes withLEONIDA_VK_VALIDATION=1 VK_VALIDATE_SYNC=1(the device line readsvalidation on), with 0 VUID lines. This surface has HDR10, so the runs includeHDR10 plane to an HDR10 (ST.2084) swapchain ... ok; as the test notes, the forced-encoding checks are skipped on such a surface.xbox_present_readback_size,vk_presenter_sync,vk_present_dump(plus_defaultand_invalid),d3d12_presentandxs_present_lazy.present failed (VkResult -11)lines appear in every run, red and green, so they are not the symptom (as noted in #1608).GPUs tested: NVIDIA GeForce RTX 5070 Ti 16 GB (desktop, profile M), driver 621.40, HDR10 display; Windows 11 Pro 26300; Vulkan SDK 1.4.363.0.
AI-assisted.
@merzleckeier on GitHub · 2026-11-29 14:19 UTC · original
AGENT-MSG | 2026-11-29 14:19 UTC | merzleckeier | AI-assisted: Codex
BASE:
9bb67cb53versus the same base +b8486b4a5, clean. The PR also merges cleanly withddfe24fba.MACHINE: RTX 4070 SUPER (NVIDIA 620.73.04) and AMD Raphael iGPU (1002:164e, RADV Mesa 26.3.1) | CachyOS, Wine 11.22, headless Gamescope.
EVIDENCE: MEASURED, 12 stock resize runs and 16 controlled result checks.
Stock
xbox_presentwithLEONIDA_PRESENT_PLANE1=0:mainfailed at the first resizedpresent_planes(&one, 1)in 3/3 runs on each GPU. The PR passed 3/3 on each GPU, including the320×240 → 400×300 → 200×150 → 320×240sequence.The extra fixture composes red, then blue, with continuous readback and disk capture. It performs the real GPU copy and present and overrides only a successful WSI return after the second frame. Both GPUs gave the same results:
VK_SUCCESSorVK_SUBOPTIMAL_KHRVK_ERROR_OUT_OF_DATE_KHRVK_ERROR_SURFACE_LOST_KHRThe fixture checks the full pixel contents, capture extent, Vulkan format and PPM bytes. Run
vk_presenter_sync_testwith--reply-ok,--reply-suboptimal,--reply-out-of-date, or--reply-surface-lost. The last two pass on the PR, and only--reply-out-of-datefails on main. Host validation reported only the baseline Wine device-creation VUID01387. Gamescope itself returned 139 during NVIDIA teardown on both builds after the Wine child had exited. The Wine child exit and assertions were recorded separately.@TheGeogeo on GitHub · 2026-11-29 14:34 UTC · original
Tested
b8486b4a5merged (no commit) with main8fb974878: MSVC 19.52, Windows 11 10.0.26300.GPUs tested: NVIDIA GeForce RTX 3080, driver 621.40.
xbox_presentpasses with this PR.runtime/src/vulkan_present.hback to main,xbox_presentfails as it does on main: "present failed (VkResult -11)", then "line 1319: present_planes(&one, 1)".gta6rtlinks with nothing new over main: no new unresolved symbol, same imports.xs_proxy_mock, which failed once on a timing check (line 4846, the 40 ms idle-timeout case). This is unrelated to the PR: that test binary does not depend onvulkan_present.h(it was not rebuilt when the file went back to main), and the same binary then passed 5 of 5 reruns.91bab934dtoo.AI-assisted (Claude Code).
@ammonium231 on GitHub · 2026-11-30 15:59 UTC · original
RTX 3090 / 621.40, validation on,
b8486b4a5merged onto main20fe0c754, CTest env: xbox_present all cases pass incl. the 320x240 -> 400x300 -> 200x150 resize (main fails at xbox_present_test.cpp:1320 on the first resize); d3d12_present passes as on main. No validation errors.@imShangLi on GitHub · 2026-12-01 16:26 UTC · original
VERIFY-2507 — Linux, Fedora 45, GCC, no GPU device, no game files
Verdict: PASS on the reading, and I could not build or run it. The change does exactly what the pull request says, and its placement relative to the two neighbouring blocks is the part that matters — I checked that it is right. But
runtime/src/vulkan_present.his not compiled on Linux at all (I probed it), so there is no test I can run and no compile check either.Head
e2bce1a3, base the currentmain88a9f133, merge baseed867d7b, 1 commit, 1 file, +9/−6:runtime/src/vulkan_present.h.1. What it changes
VulkanPresenter::submit_now()used to set the "a frame was captured" flag only for a present that succeeded:read_back()hands the frame out only whencaptured_is set (runtime/src/vulkan_present.h:366). After9f98dcc61moved that assignment inside the "shown" branch, a present that reportedVK_ERROR_OUT_OF_DATE_KHR— which on Windows/NVIDIA happens on a resize, after the command buffer with thevkCmdCopyImageToBufferintocapture_buffer_has already been submitted — leftcaptured_false, andread_back()failed even though the frame was there.The pull request splits the two:
2. The placement is the whole change, and it is right
The new block sits between two others, and both orderings matter:
SURFACE_LOSTreset, so a lost surface still clearscaptured_— and the new block's condition does not includeVK_ERROR_SURFACE_LOST_KHRanyway, so the two agree.OUT_OF_DATE → VK_SUCCESSconversion, so the comparison still sees the originalVK_ERROR_OUT_OF_DATE_KHRrather than the converted success. Had the conversion come first, the new clause would have been dead.And
pending_capture_ = frame.done— the disk sample — stays inside the "shown" branch, so only frames that were actually shown are written to disk; the pull request's own summary says that is deliberate, and the code keeps it.3. Why I could not run it
runtime/src/vulkan_present.his included byruntime/shims/d3d12_vulkan_device.cpp,runtime/shims/xbox_present.cpp,runtime/src/vulkan_present_splash.hand three tests — and all of the ones that reach it are behind the Windows shim (if(WIN32 AND LEONIDA_BUILD_WINDOWS_RUNTIME)) or include<windows.h>. I probed it: putting#errorat the end of the header and rebuilding the Linux runtime produced no error, so the header is not compiled here at all.The test the pull request uses is
xbox_present_test.cppcase F, which resizes a window during a present — that needs a Win32 window and a real Vulkan swapchain, and the pull request's own measurement is on an NVIDIA RTX 5070. The negative control it quotes (case F failing deterministically onmain) is the right experiment and I have no way to run it.4. What I did not check
9f98dcc61) and thexbox_presentcase F behaviour.d3d12_presenttest the pull request also lists.VK_ERROR_OUT_OF_DATE_KHRis the only present result that can arrive with the frame already copied — the new condition coversVK_SUCCESS,VK_SUBOPTIMAL_KHRandVK_ERROR_OUT_OF_DATE_KHRand nothing else, and I did not enumerate what other resultsvkQueuePresentKHRcan return on the platforms in question.AI-assisted: MiniMax M3.1 Flash.
@aslan2142 on GitHub · 2026-12-01 16:45 UTC · original
Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (
d3d12/) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools,d3d12/, or general docs), please feel free to reopen it.Pull request closed