WIP: refactor(vk): one retire-later holder for the upscalers' dead queues #978
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!978
Loading…
Reference in a new issue
No description provided.
Delete branch "zeldaootr/Longshot:vk-retire-later"
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?
Type: refactor · Risk: medium · Tested on: Linux, Steam Deck (RADV VANGOGH): runs, but the Deck offers no FSR 3, so the holders held nothing · Needs: any GPU with FSR 3 upscaling and frame generation
Why
Nothing a player would notice: this is a code-structure change. Five files in the Vulkan back end each carried their own copy of "hold this until the GPU can no longer be using it, then free it" (all five wait for the submission timeline's value that followed the thing; three also count frames, with the
4written three times). A fix to the rule had to be made five times. Now it lives in one header with its own check. No issue in the tracker covers it.What changed
One small header owns when a retired thing may be freed; the five files keep what the thing is and how to free it. Same stamps, thresholds and order of frees as before.
gpu/vk/retire_later.h(new):retire_later::Held<Item>withhold(value, item),hold(frame, value, item)and three release rules:free_reached(the timeline has reached the value; a value of 0 is never freed),free_aged(that, and more thankFrameAge= 4 frames past: main's #788 rule for the three frame-counted lists, kept as it is) andfree_all. No Vulkan calls.gpu/vk/vk_reactive.cpp,gpu/vk/vk_fsr3_inputs.cpp,gpu/vk/vk_temporal.cpp:laterandfree_deadare one line each overHeld<std::function<void()>>(vk_temporal'sfree_dead(all)picksfree_allorfree_aged).gpu/vk/vk_fsr3.cpp,gpu/vk/vk_fsr3fi.cpp:drop_imageandfree_deadoverHeld<Image>;destroy_nowis unchanged.tests/test_async_safe_frees.py(main's check of #788's rule, which built the three lists from astruct Deadit found in each file): builds them from the header's holder now, and still from astruct Deadfor a tree before this one (--source). It passes here and still fails all six of its cases on the sources before #788.tests/test_retire_later.py+tests/retire_later_test.cpp(new) check the rule, the boundaries, the order, a free that holds more, and the three frame-stamped holders cut from their sources.tests/test_fsr_image_retirement.py+tests/fsr_image_retirement_test.cppandtests/test_fsr3_release_frees.pycompile the header with the code they cut, instead of a pasted vector of pairs.Not touched, on purpose: the dead queues in
vk_memory.cpp,vk_texture.cpp,vk_imgui.cppandvk_draw.cpp(their release rules have extra conditions); the frame-stamped holders stay frame-stamped; andfree_allis there forvk_temporal.cpp'sfree_dead(all), which main only ever calls withfalse: the flag is main's and is left as it is.Measurements
Verdict: nothing measured: a refactor meant to leave frame time and memory as they are, and the one run in the game (below) could not reach the code that changed, so a number from it would say nothing. It passes its checks.
Flags and settings
None.
Testing
Tested:
a8a30c22(v3.0.0-rc.4-120-gd01328f1: this PR with the options reader and the switch rule), built for x86-64-v3, not this branch alone; that run predates main's #788 and this branch's rework onto it (2026-11-16): the holder now carries a frame and a timeline value for the three frame-counted lists, as #788 made them. Nothing in the game has run since the rework.run_all.py fsr retire reactive temporal) on Linux x86-64 (Ryzen 7 5700U), clang 23.1.5, gcc, glslang, spirv-val, the Vulkan and SPIR-V headers, pass buttests/test_fsr_uniform_ownership.py, which fails the same on main. A fullpython3 -I -B tests/run_all.pyon maine4d035e9and on this branch rebased onto it, the same day and PC (6 at once, the PC busy with other builds): main 609 passed, 28 failed, 26 skipped; this branch 611 / 27 / 26. By name every failure here is one of main's buttests/test_pipeline_cache_file.py, a timed check that passes alone on both;test_oot_state_tapandtest_pipeline_state_sourcesfailed on main's run only (timing). The branch was then rebased onto mainbbe421f5(two files of main's, neither touched here) and pushed; the full run was not repeated for that step..cppfiles whole,-fsyntax-onlywith llvm-mingw 20261104 (Windows), after the rework: clean. (Before the rework also with clang for Linux; not repeated.)free_allnote come from it.Not tested: the holders with anything in them. The Deck's Upscaler row has only the game's own upscalers, so FSR 3, frame generation, the reactive mask and the temporal engines (DLSS, FSR 4, XeSS) never ran, and nothing was retired through
Held. Windows, in the game.Must be tested:
Risks
What could break: an image freed while the GPU still uses it (a device loss on a resolution or upscaler change) or never freed (memory growing), with FSR 3, frame generation or a temporal engine on.
Turning it off: revert the commit.
Compatibility: Nothing changes.
Checklist
Everyone
type(scope): description) of the status line's type.can't be run by hand is in Testing's Not testable by hand, with why.
in Risks. Not ticked yet: Risks names memory growth from a holder never freed, and Measurements says nothing was measured for it.
main(bbe421f5, 2026-11-16; head997e7029; the conflict with #788 in the three frame-counted lists resolved by giving the holder #788's rule).python -I -B tests/run_all.pypasses (any failure that also fails onmainis named).third_party/untouched (a new folder with aPROVENANCE.mdinstead).When it applies
Assisted-by:/Co-Authored-By:trailers.tests/that reads changed source updated in this PR, not weakened.retire_later.h, the frame-stamped dead queues ofvk_reactive,vk_fsr3_inputsandvk_temporaluse it c043e79e86vk_fsr3andvk_fsr3fihold their retired images inretire_later::Held,test_fsr_image_retirementcompiles the headerTested in game: Steam Deck OLED, SteamOS 3.9.5 (20261023.100), AMD Custom GPU 0932 (RADV VANGOGH), Mesa 26.2.0-devel. A build of this branch merged with the two other branches of its set on main
a8a30c22(v3.0.0-rc.4-120-gd01328f1), headless at 1280x720, from empty shader caches: the child save in Kokiri Forest, a teleport to Hyrule Field and 45 s there, four runs, each to its end with no device loss. In one run the Upscaler row (Off, Catmull-Rom, Lanczos) and the Render resolution row were stepped through in play, the game presenting throughout. The Deck offers no FSR 3, frame generation or temporal engine, so the holders this PR changes held nothing in these runs: that still has to be run on a GPU that offers them (Must be tested).Possibly related, for context:
6d08865b29997e7029c3Rebased onto main
bbe421f5; the description names what changed with it.Brought up to the ready-for-review standard (#1454): the checklist's Everyone list has two new boxes, added here from what this PR's description and comments show (please check they match what you know).
997e7029c3aa26c5be26Rebased onto main
430eef4f2(an include-line conflict ingpu/vk/vk_temporal.cpp; both includes kept).tests/run_all.pyon Linux at this head and on main in the same environment: no check fails here that passes on main. Main has since gained a sixth copy of the same retire rule ingpu/vk/vk_framegen.cpp; it is not folded in here.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.