WIP: perf(vk): with the render thread, a fence of one queue waits for that queue's work, not for other queues' stopped work #2648
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/mods
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
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!2648
Loading…
Reference in a new issue
No description provided.
Delete branch "Veix/Longshot:perf/render-thread-queue-fences"
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?
Summary
With the render thread, a fence of one queue waits for that queue's work, as it does without the render thread since
8c28ed70, instead of for every queue's work up to it, which another queue's stopped submission held back. (The result line is to be written from the measurements of this head.)NVN's fences are per queue (
nvnQueueFenceSynccovers the work submitted to that queue). Without the render thread the replay keeps that since8c28ed70:fence_qgives the queue's last submission, and a wait for it waits for the recording that submission was finished in (wait_recorded). With the render thread, the default since #588,fence_qgave the newest submission of any queue, and the wait went to the shared timeline, which signals a value only once no older submission of any queue is stopped at an event wait. OoT's main thread waits every frame for a fence of one of its queues, while the presentation queues' submissions stop at an event wait until the main thread's CPU signal: its wait then included their stopped work.What this changes (render thread only; without it nothing changes):
fence_q: the queue's own last submission, asenqueuenumbers it (q_own, a leaf lock), or the last present's value if that is newer. A present carries no queue, and a fence taken after it covers it, as onmain.wait_inner:wait_own_recordingwaits for the recording the value was finished in (value_rec, woken byrec_map_cv), or until the shared timeline passes the value, within the wait's time. Neither within it: the shared timeline, as before.RX_VK_PER_QUEUE_FENCES=0(the existing switch) gives the old behaviour in both modes.Prior work: #2212 (siantm, closed on 2026-11-24) made the same change behind
RX_VK_ASYNC_FENCES, built on #2211's wait for a queue; it was closed with #2211, which was withdrawn. Its review (dazemc) found that a fence taken after a present must cover the present; this pull request does that. Its measurements showed no gain on the Test Farm and a worse tail in one CPU-paced sitting on an RTX 4060 (p99 17.7 -> 21.3 ms, cause not found). This one waits on the existing recording map instead of #2211's wait. Related: #2523 (neotoxic, WIP) changes the fence poll without the render thread; no overlap in behaviour, its hunk is next to this one.Read first:
fence_qandwait_own_recordingingpu/vk/vk_replay.cpp, thentests/test_render_thread_queue_fences.py.Testing
Tested: Windows 11, Ryzen 9 9900X, RTX 4070 SUPER 12 GB, driver 621.24, on
main@9eabf8bc.tests/test_render_thread_queue_fences.py(new) cutsfence_q,wait_own_recordingandenqueue's notes out ofgpu/vk/vk_replay.cppand runs them against stand-ins for the queues and both timelines: it fails onmain(a fence of the scene queue is the newest submission of any queue, and its wait waits for the shared timeline) and passes here, with clang++ and g++; undoing either the queue's own value or the own wait makes it fail. The checks that read the changed files (python -I -B tests/run_all.py --changed origin/main): the 2 that fail (test_dev_ab, test_input_movie) fail the same way onmain@9eabf8bcon this PC. The renderer builds.What this head is, against what was measured before it: the change was first measured as a proof of concept, together with other changes. This head differs from that proof of concept in more than one way, so a result that differs from it has more than one candidate:
value_rec, filled when the recording is submitted) and polls the shared timeline each 1 ms, within the wait's time.enqueuein both; the proof of concept also kept it whenRX_VK_PER_QUEUE_FENCES=0.Still to test:
main, alone (no other change): the recorded routes, frame pacing and the host's GPU-wait line, CPU-bound and GPU-bound (by hand)main(by hand)main, no hang (@Beanstalk or by hand)Measurements
(To be measured at this head against
main@9eabf8bc.)Risks
RX_VK_PER_QUEUE_FENCES=0givesmain's behaviour.longshot_options.inior the caches.Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named).main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
mainand passes here.gpu/vk/switches.def.Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.This pull request was written with the help of Claude (an AI assistant).
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.