fix(vk): with NVIDIA's driver on Linux each frame is presented before the next frame's work runs (RX_VK_PRESENT_GATE=0 to disable) #3298
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
4 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!3298
Loading…
Reference in a new issue
No description provided.
Delete branch "HumanBean/Longshot:fix/present-gate"
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 NVIDIA's driver on Linux each game frame is now presented before the next frame's work runs on the GPU: the 1 %
low goes from 80 to 100 fps in Kokiri at 4K DLSS (from 1080p), with the same fps, and every frame reaches the screen on an
even rhythm. This is the proper fix for the DLSS 1 % low drop that #3287 tries to fix by turning Skip Upscaler Wait off.
What was wrong: NVIDIA's Linux driver does a present's own GPU work on the queue it is given and waits for it on the CPU.
With Skip Upscaler Wait (#3135) the game is a frame ahead, so by the time the presenter presented frame N, 0–9 ms of frame
N+1's work was already queued on the replay's queue in front of it. Frame N went out late by a different amount every
frame (real present intervals: 33–37 % over 1.25x the median, p99 18 ms at a 9 ms median), and the render thread waited
for the presenter as long. Not V-Sync, not Reflex: the same with V-Sync off (immediate) and with Reflex Off.
What this changes (
device_policy.hpresent_gate, on with NVIDIA's driver on Linux;RX_VK_PRESENT_GATE=0turns itoff,
=1on elsewhere):vk_main.cppcreate_device). The Presentqueue row's compute queue could not present to the Wayland window here, so every earlier "own queue" try silently
presented on the replay's queue.
submit_or_retry),which the presenter signals on its queue right after
vkQueuePresentKHRreturns, before any wait for the frame to beshown (
presenter_loop). No CPU thread waits: the next frame's work is submitted as before and starts on the GPU about0.15 ms after the copy. The copy is submitted before the hand-over, so it is never behind the gate, and every hand-over's
value is signalled whatever its present did.
Read first: the present gate's comment above
submit_or_retryingpu/vk/vk_replay.cpp, thengate_signalinpresenter_loopand the gate block inpresent_hand_off.How it was found (for #3287): the frame trace's
msis the render thread's present-to-present time, not the game'sframe time. A probe (not in this PR) timed the presenter's copy wait, present call and shown wait, the render thread's
drain, fence, acquire and Reflex sleep, and the game's limiter and room waits. Under FIFO at 240 Hz the skip showed no
alternation on this PC; the 1 % low drop came from the present call blocking 8–11 ms (p95) with the skip on, against 1 ms
off. Presenting right after the copy's submit on the replay's queue made presents even but cost 10 % fps (the call held
the queue's lock ~6.5 ms, stalling the recorder's submits and with them the game's captures); a high-priority present
queue is not offered (the family lists medium only). The gate keeps the order without holding any CPU thread.
Testing
Tested: Linux (CachyOS, sway 1.13, Wayland), RTX 3090, NVIDIA 620.70.06, windowed on a 240 Hz display, the game's
4K output with DLSS from 1080p, Reflex On, V-Sync Off, uncapped (the settings of the v3.2.0 against nightly 1179 benchmark
that showed the drop). Kokiri Forest, Hyrule Field and the Market standing still, 45 s each, gate on (default) against
RX_VK_PRESENT_GATE=0, interleaved: the log saysvk: presents on a queue of their own, the second of the replay's family 0 (the present gate)andvk: the present gate: on, ...; with the gate the present call takes 0.15 ms (median) andunder 2 % of real present intervals are over 1.25x the median, against 8–40 % off. A run of the first test version
showed the same in Kokiri twice more (1 % low 99.7 and 100.6 against 80.0 and 79.4).
tests/test_device_policy.pycovers the rule and the switch (not run yet here: the PC's queue was busy with the runsbelow).
Also on this PC, one run a side, gate on against off (Kokiri, the same settings unless said): V-Sync On (FIFO) 127.1
against 128.6 fps, 1 % low 83.3 against 86.4; a 60 fps cap 60.0 against 60.0, 1 % low 56.6 against 53.2; Skip Upscaler
Wait off 94.5 against 94.6, 1 % low 64.0 (a pipeline built mid-run) against 68.2; frame generation 2x 72.0 against 70.6,
1 % low 50.9 against 45.2. No loss past the noise.
A cold review by a second agent found a deadlock, fixed in the third commit:
device_wait_idle_lockedholds the presents'queue's lock the presenter signals under, so a submit held for a present not yet made never ran and the idle-wait never
ended (a resize, an effect or frame generation toggled). The values handed over are now signalled from the CPU first.
Rebased on
main0b284cc7(#3299): it compiles on Linux, and a windowed smoke run passed with the gate on (in play fromkokiri-start, 900 frames, the menu opened; the log names the gate's queue).
Still to test:
RX_VK_PRESENT_GATE=1against unset at 4K DLSS from 1080p, V-Sync off, Kokiri, expecting a better1 % low with the same fps (the #3287 numbers suggest the same block there) (@Beanstalk)
RX_VK_PRESENT_GATE=1against unset, to decide whether to turn it on there(@Beanstalk)
Measurements
Verdict: the same fps or better, and a much better 1 % low, in all three areas.
Setup: Linux, RTX 3090, NVIDIA 620.70.06, Ryzen (24 threads); 4K output, DLSS from 1080p, Reflex On, V-Sync Off,
uncapped, windowed (kept visible), standing 45 s after a warm-up;
dev.py ab --env RX_VK_PRESENT_GATE=0, twointerleaved pairs, one build. "1 % low" is
dev.py ab's (the frame trace).de091ae2(this PR's build withRX_VK_PRESENT_GATE=0, main's path)04c298ce(the gate on, the default)Real present intervals (a probe around
vkQueuePresentKHR, Kokiri): p99 18.1 ms off, 9.7 ms on; over 1.25x the median33–37 % off, 0.0 % on.
Risks
The second commit moves Skip Upscaler Wait to the Debug tab's developer page (after Present queue), still on by
default and changing at once: with the gate it has no downside here, so it is best left on. Its key and saved value are
unchanged.
A second queue of the graphics family on NVIDIA Linux only. A driver that misbehaves with it:
RX_VK_PRESENT_GATE=0restores main's path exactly. A revert is enough.
A gated submit that is never signalled would stall the GPU: every hand-over's value is signalled on every path of the
presenter's iteration (made, failed, not made), and the copy is always ahead of the gate.
The Present queue row (Debug tab, compute queue) is not made while the gate is on with NVIDIA on Linux: the gate's own
queue takes its place (logged).
Nothing changes in saves or settings.
Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named):dev.py test-changedand, on the rebased head,test_device_policy,test_menu_ini_keys,test_upscaler_rows,test_recorder_parts,test_vk_recorder_fastpass;test_i18n_completefails onmaintoo ("Fill title screen" untranslated).main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
mainand passes here:test_device_policy(the rule andRX_VK_PRESENT_GATE); the gate's GPU ordering itself needs a GPU (the windowed smoke run below).gpu/vk/switches.def.tests/that reads changed source is updated, not weakened.Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.🤖 Generated with Claude Code
Tested in game: Linux (CachyOS, sway, Wayland), RTX 3090, NVIDIA 620.70.06, 4K DLSS from 1080p, Reflex On, V-Sync Off, uncapped: Kokiri Forest, Hyrule Field and the Market, gate on against RX_VK_PRESENT_GATE=0, two interleaved pairs each. Log shows the gate on its own queue; present call 0.15 ms; 1% low up in all three areas (Kokiri 80 -> 92-98), same fps.
Possibly related, for context:
324933d2749ea318cccd9ea318cccd48476edc40@review
Recommendation: Request changes. The gate can miss next-frame submissions and can leave the GPU waiting forever when its signal submission fails. Its idle-wait release also permits timeline signals to execute out of order.
The change presents game frames on a second queue and holds subsequent replay work until presentation, improving reported frame pacing on the tested NVIDIA Linux system. It also moves Skip Upscaler Wait to the developer page; the synchronization and other supported configurations need further work.
Blocking (4): must change before merging.
gpu/vk/vk_replay.cpp:7747: The replay queue is unlocked before the gate value is published, so another submitting thread can enqueue next-frame work without the gate. When: After the frame copy is submitted, present_out unlocks present_mu before present_hand_off stores present_gate_pending. A recorder or replay submit that acquires the lock in that interval sees no pending value and runs ahead of the present, restoring the variable presentation delay this change is intended to prevent. Do: Publish the hand-off's gate value while holding the replay queue lock, after the copy submit and before any later submit can acquire that lock.gpu/vk/vk_replay.cpp:175: The gate records a signal as completed before checking whether Vulkan accepted it, and a refused signal leaves its waiting replay submission blocked. (more on the line) Do: Handle signal submission failure with a safe retry or release/fatal path, and advance the bookkeeping only after a signal is successfully arranged.gpu/vk/vk_replay.cpp:179: A CPU release can overtake an earlier signal already queued on the presenter queue, violating timeline semaphore signal ordering. (more on the line) Do: Coordinate CPU release with outstanding queue signals so every timeline signal executes in increasing order, without waiting while holding a lock needed by the presenter.gpu/vk/vk_replay.cpp:8137: The semaphore handle is initialized without the lock used by the idle-wait path that reads it. (more on the line) Do: Create and publish the semaphore under the same synchronization used by readers, or initialize it before concurrent idle waits and submissions can begin.Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)
gpu/vk/device_policy.h:839: The default covers all NVIDIA proprietary Linux systems, while the repeated measurements cover one GPU, driver and Wayland configuration. (more on the line) Do: Run interleaved gate-on and gate-off comparisons on representative NVIDIA Linux tier-1 systems and window/present modes, including frame times and 1% lows.@fixcan do L1, L2, L3 and L4.Questions (3) (not confirmed from the code; they don't hold the recommendation)
tests/test_device_policy.py:439: Is there a game-free behavioral test elsewhere that exercises the gate’s ordering and idle release?Checks: Still running: 11 checks.
More: does it help, other systems, switches, what was read
Does it help: Yes, on the reported RTX 3090 Linux setup: two interleaved runs show Kokiri 1% lows of 80.1/79.1 fps with the gate off and 91.8/97.6 with it on, with average fps roughly unchanged. The reported present-interval p99 falls from 18.1 to 9.7 ms. The comparison uses the same head with the switch off, rather than a separate base build, and does not establish the effect across the default's other NVIDIA Linux configurations.
Other systems: The default affects NVIDIA proprietary drivers on Linux, including different GPUs, window systems, present modes, caps and upscalers. The override can enable it on Windows, AMD and Intel. Frame generation's synchronous presents use the replay queue when the gate queue replaces the developer Present queue. The reported frame-generation, FIFO and capped runs are single runs on one system; other tier-1 coverage remains outstanding.
Switches: RX_VK_PRESENT_GATE is added, defaulting on for NVIDIA proprietary drivers on Linux and off elsewhere; 0 disables it and 1 forces it on. Its table row is present, but broader default-on coverage is outstanding. HOS_FRAME_SKIP_TAIL retains its default of on and its saved key; its menu row moves to the developer page.
Reviewed:
48476edc40againsta2b7abf9ee: Read AGENTS.md, CONTRIBUTING.md, the pull request template, relevant standards, commit messages, the complete diff and the queue, hand-off, signal, idle-wait and device-creation code around the changes. Skimmed the changed policy test and related setting and frame-generation callers. The large changed source files and menu test were not read in full; no recorded runs or generated files were included in the diff. docs/review-checklist.md and the adjacent Tooling checkout were absent.; nothing run (a code review).Checked and fine:
Testing: No commands that build, execute project code or run tests were used. The author reports Linux game runs; CI is still running.
Overlaps and merge order: The description identifies #3287 as another approach to the same DLSS 1% low problem; its current status and merge order could not be checked offline.
Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
@ -828,6 +836,7 @@ inline DevicePolicy device_policy(const DeviceFacts& f) {p.gpu_clock_peak = f.amd() && f.deck_apu();p.readback_late_newest = f.handheld();p.acquire_ahead = true; // (every driver; not under frame generation or FIFO: vk_replay.cpp acquire_ahead_wanted)p.present_gate = !f.windows && f.driver_id == VK_DRIVER_ID_NVIDIA_PROPRIETARY;L5 (should fix): The default covers all NVIDIA proprietary Linux systems, while the repeated measurements cover one GPU, driver and Wayland configuration.
When: A player using another supported NVIDIA generation, driver, window system or pacing mode receives the gate by default, but the reported runs do not show its frame pacing or cost there.
Do: Run interleaved gate-on and gate-off comparisons on representative NVIDIA Linux tier-1 systems and window/present modes, including frame times and 1% lows.
@ -155,0 +172,4 @@/// an idle-wait for every value handed over (present_gate_release_locked). A timeline's values only go upvoid present_gate_signal_locked(uint64_t v, bool from_cpu) {if (!present_gate || v <= present_gate_upto) return;present_gate_upto = v;L2 (blocking): The gate records a signal as completed before checking whether Vulkan accepted it, and a refused signal leaves its waiting replay submission blocked.
When: If vkQueueSubmit2 for the presenter's signal returns an out-of-memory error, the code logs the error but leaves present_gate_upto at that value. The replay queue waits for a value that was never signalled, and the idle-wait release skips that value, so the game can freeze permanently.
Do: Handle signal submission failure with a safe retry or release/fatal path, and advance the bookkeeping only after a signal is successfully arranged.
@ -155,0 +176,4 @@VkResult r;if (from_cpu) {VkSemaphoreSignalInfo si{VK_STRUCTURE_TYPE_SEMAPHORE_SIGNAL_INFO};si.semaphore = present_gate, si.value = v;L3 (blocking): A CPU release can overtake an earlier signal already queued on the presenter queue, violating timeline semaphore signal ordering.
When: The presenter submits a signal for frame N, then frame N+1 is handed over before that signal executes. An effect or frame-generation change enters device_wait_idle_locked and signals N+1 from the CPU; the still-pending GPU signal for N can then execute against a semaphore already at N+1.
Do: Coordinate CPU release with outstanding queue signals so every timeline signal executes in increasing order, without waiting while holding a lock needed by the presenter.
@ -8053,0 +8134,4 @@ti.semaphoreType = VK_SEMAPHORE_TYPE_TIMELINE;VkSemaphoreCreateInfo ci{VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO};ci.pNext = &ti;if (vkCreateSemaphore(dev.device, &ci, nullptr, &present_gate) != VK_SUCCESS) present_gate = VK_NULL_HANDLE;L4 (blocking): The semaphore handle is initialized without the lock used by the idle-wait path that reads it.
When: On the first hand-off, vkCreateSemaphore writes present_gate while another thread enters device_wait_idle_locked and present_gate_release_locked reads that plain handle under present_queue_mu. The writer does not hold that mutex, so these accesses race even when no value has yet been handed over.
Do: Create and publish the semaphore under the same synchronization used by readers, or initialize it before concurrent idle waits and submissions can begin.
WIP: fix(vk): with NVIDIA's driver on Linux each frame is presented before the next frame's work runs (RX_VK_PRESENT_GATE=0 to disable)to fix(vk): with NVIDIA's driver on Linux each frame is presented before the next frame's work runs (RX_VK_PRESENT_GATE=0 to disable)Rebased from main
de091ae2onto0b284cc7: the numbers still hold. The commits in between (#3299, #3297, #3289, #3294, #3280, #3288) change the website, input, the menu, UI, content and the fog rows: none touches gpu/vk's present path, the presenter or the queues. The rebased head compiles on Linux, test_device_policy, test_menu_ini_keys and test_upscaler_rows pass, and a windowed smoke run passed with the gate on.Recommendation: Request changes. The gate can miss a replay submission, leave a submission blocked after a refused signal, and violate timeline semaphore ordering. Its handle also has an unsynchronized initialization and read.
The change aims to smooth NVIDIA Linux presentation by gating the next frame’s GPU work until the current present is made. It adds a second queue and cross-thread semaphore coordination, whose correctness issues currently outweigh the measured gain.
Blocking (4): must change before merging.
gpu/vk/vk_replay.cpp:7747: The replay queue is unlocked before the gate value is published, so another submitting thread can enqueue next-frame work without the gate. When: After the frame copy is submitted, present_out unlocks present_mu before present_hand_off stores present_gate_pending. A recorder or replay submit that acquires the lock in that interval sees no pending value and runs ahead of the present, restoring the variable presentation delay this change is intended to prevent. Do: Publish the hand-off's gate value while holding the replay queue lock, after the copy submit and before any later submit can acquire that lock.gpu/vk/vk_replay.cpp:175: The gate records a signal as completed before checking whether Vulkan accepted it, and a refused signal leaves its waiting replay submission blocked. When: If vkQueueSubmit2 for the presenter's signal returns an out-of-memory error, the code logs the error but leaves present_gate_upto at that value. The replay queue waits for a value that was never signalled, and the idle-wait release skips that value, so the game can freeze permanently. Do: Handle signal submission failure with a safe retry or release/fatal path, and advance the bookkeeping only after a signal is successfully arranged.gpu/vk/vk_replay.cpp:179: A CPU release can overtake an earlier signal already queued on the presenter queue, violating timeline semaphore signal ordering. When: The presenter submits a signal for frame N, then frame N+1 is handed over before that signal executes. An effect or frame-generation change enters device_wait_idle_locked and signals N+1 from the CPU; the still-pending GPU signal for N can then execute against a semaphore already at N+1. Do: Coordinate CPU release with outstanding queue signals so every timeline signal executes in increasing order, without waiting while holding a lock needed by the presenter.gpu/vk/vk_replay.cpp:8137: The semaphore handle is initialized without the lock used by the idle-wait path that reads it. When: On the first hand-off, vkCreateSemaphore writes present_gate while another thread enters device_wait_idle_locked and present_gate_release_locked reads that plain handle under present_queue_mu. The writer does not hold that mutex, so these accesses race even when no value has yet been handed over. Do: Create and publish the semaphore under the same synchronization used by readers, or initialize it before concurrent idle waits and submissions can begin.Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)
gpu/vk/device_policy.h:839: The default covers all NVIDIA proprietary Linux systems, while the repeated measurements cover one GPU, driver and Wayland configuration. When: A player using another supported NVIDIA generation, driver, window system or pacing mode receives the gate by default, but the reported runs do not show its frame pacing or cost there. Do: Run interleaved gate-on and gate-off comparisons on representative NVIDIA Linux tier-1 systems and window/present modes, including frame times and 1% lows.@fixcan do L1, L2, L3 and L4.Since the last review (on
48476edc40)Still open: L1 (The replay queue is unlocked before the gate value is published, so another submitting thr…); L2 (The gate records a signal as completed before checking whether Vulkan accepted it, and a r…); L3 (A CPU release can overtake an earlier signal already queued on the presenter queue, violat…); L4 (The semaphore handle is initialized without the lock used by the idle-wait path that reads…); L5 (The default covers all NVIDIA proprietary Linux systems, while the repeated measurements c…)
Checks: Still running: 11 checks.
More: does it help, other systems, switches, what was read
Does it help: Yes, on the tested RTX 3090 Linux Wayland setup: two interleaved pairs report Kokiri 1% lows of 79.1–80.1 fps off versus 91.8–97.6 fps on, with average fps approximately unchanged; measured present-interval p99 fell from 18.1 to 9.7 ms. Other NVIDIA Linux configurations remain unmeasured.
Other systems: The gate defaults on for NVIDIA Linux and can be forced on elsewhere; queue availability, drivers, window systems, frame generation and idle waits can affect its behavior. The reported smoke run covers one Linux NVIDIA configuration; Windows and other hardware runs remain outstanding.
Switches: RX_VK_PRESENT_GATE is added: it defaults on for NVIDIA Linux and off elsewhere, with 0 disabling and 1 enabling it. The tested default helps on one configuration, but its effect across the default-on population remains unproven. Skip Upscaler Wait moves to the developer page; its default remains on and its saved key is unchanged.
Reviewed:
48476edc40againsta2b7abf9ee: Read the repository rules, PR template, standards, replay gate diff and surrounding hand-off and signal paths; skimmed the remaining diff and reported measurements. Did not read every changed code file in full. Tooling’s AGENTS.md was unavailable locally; docs/review-checklist.md is absent.; nothing run (a code review).Checked and fine:
Testing: No commands that build, run tests or execute project code were run. The supplied CI checks are still running; the PR reports a Linux build, game-free checks and an in-game smoke run.
Overlaps and merge order: Not determined from the supplied information.
Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, as HumanBean took it out of WIP. Nothing was run; a maintainer decides.
@Beanstalk Measure RX_VK_PRESENT_GATE=1 against it unset on Windows NVIDIA (an RTX 40 or 50 card), AMD on Windows and on Linux, and Intel Arc on Windows: Kokiri Forest and the Market standing still, 4K output with DLSS (or FSR 4 / XeSS on AMD and Intel) from 1080p, V-Sync off, uncapped, two interleaved pairs each. Report fps, 1% low and p99, and the log's 'vk: the present gate: on' line on the =1 side. We want to know where it raises the 1% low without lowering fps, to choose where it is on by default.
Beanstalk test farm · an earlier run: commit
48476ed(the newer results are in a comment below)Commit
48476ed· approved by HumanBean (reviewed) · dashboard⚠️ Note: The requested AMD and Intel upscaler runs cannot share the NVIDIA SDK build in this plan; FSR 4 and XeSS each require their own build configuration.
⚠️ Note: Linux presentation cannot be measured because window scenarios are Windows-only; the plan also cannot measure actual present intervals or prove the synchronization race and signal-failure paths safe.
Started.
Estimate: done in about 1 h, from the queue and the testers online now; some jobs can't start yet.
windows+nvidia+window+dlss+gpu-rtx-40xx_rtx-50xx(GPU "rtx 40xx" or "rtx 50xx")What was tested
What will be tested · AI plan (
gpt-6.1-terra)On Windows RTX 40- and 50-series PCs, compare the present gate enabled against its default-off state in Kokiri Forest and the Market, standing still for 45 seconds per place. Two interleaved pairs use 4K DLSS from 1080p, V-Sync off and an uncapped frame rate, reporting FPS, 1% low and p99 frame time. The test fails for a crash, a missing gate-on log line, or a frame-time or FPS regression beyond 15%.
RX_VK_PRESENT_GATE) and off; main is not built or run.1(PR only).kokiri-start(settings dlss=1, vsync=2, resolution=4, frame_rate_cap=6, quality_preset=0; switchesHOS_OUTPUT_RES=3840x2160,RX_VK_AUTO_TUNE=0; in a hidden window (the present path runs)), then teleport to Kokiri Forest, measure kokiri for 45 s (after 10 s warm-up), teleport to Market, measure market for 45 s (after 10 s warm-up); 2 runs on each side.Beanstalk test farm
Commit
b806067· approved by nobody yet · dashboardA member of
BigBeanscan review this commit and comment@Beanstalkto test it.Thanks: L1 to L4 were real, all fixed in
b8060677(compiled on Linux,test_device_policypasses, a windowed smoke run passed with the gate on).present_gate_armpublishes the gate's value whiledev.present_muis still held after the copy's submit, beforeqk.unlock();present_hand_offtakes the value as an argument. No submit can come between the copy and the gate.present_gate_uptomoves only once the signal is queued or made. A refused queue signal waits for the presents' queue to go idle (its earlier signals done) and signals from the CPU; refused again,device_lostwith the reason.present_gate_armunderdev.present_queue_mu, the lockpresent_gate_release_lockedreads it under; the replay's submits read it only after the seq_cst store of a pending value made after it.L5: agreed it needs more NVIDIA Linux systems. This PC is the only one here, and the Test Farm's window scenarios are Windows-only, so it stays in Still to test;
RX_VK_PRESENT_GATE=0is the way back.Questions:
@review
Recommendation: Approve. The code is ready: only testing is left. The gate improves frame pacing on the tested NVIDIA Linux system, and the four code fixes address their ledger cases. Broader testing is still needed for a default that covers NVIDIA Linux systems generally. Recommend approval; not approved on the forge.
The change presents game frames on a separate queue and gates subsequent GPU work to reduce uneven present intervals. It adds queue and semaphore synchronization, plus a developer override.
Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)
gpu/vk/device_policy.h:839: The default covers all NVIDIA proprietary Linux systems, while the repeated measurements cover one GPU, driver and Wayland configuration. When: A player using another supported NVIDIA generation, driver, window system or pacing mode receives the gate by default, but the reported runs do not show its frame pacing or cost there. Do: Run interleaved gate-on and gate-off comparisons on representative NVIDIA Linux tier-1 systems and window/present modes, including frame times and 1% lows.Since the last review (on
48476edc40)Resolved: L1 (The replay queue is unlocked before the gate value is published, so another submitting thr…); L2 (The gate records a signal as completed before checking whether Vulkan accepted it, and a r…); L3 (A CPU release can overtake an earlier signal already queued on the presenter queue, violat…); L4 (The semaphore handle is initialized without the lock used by the idle-wait path that reads…)
Still open: L5 (The default covers all NVIDIA proprietary Linux systems, while the repeated measurements c…)
Checks: Still running: 11 checks.
More: does it help, other systems, switches, what was read
Does it help: Yes, on the tested RTX 3090 Linux Wayland setup: two interleaved pairs showed Kokiri 1% lows rising from 79.1–80.1 to 91.8–97.6 fps, with similar average fps. The comparison used the PR build with the gate disabled as the baseline; broader default-on results are missing.
Other systems: The gate defaults off on Windows and non-NVIDIA drivers, but can be forced on there. Frame generation, FIFO, a frame cap and Skip Upscaler Wait off each have one run per side on the tested Linux PC; broader coverage remains outstanding.
Switches: RX_VK_PRESENT_GATE is added: on by default with NVIDIA's proprietary Linux driver and off elsewhere; 0 disables it and 1 enables it. The default helped on the tested system, but its broader NVIDIA Linux coverage remains unverified. Skip Upscaler Wait moves to the developer page and keeps its existing default and saved key.
Reviewed:
b80606776cagainsta2b7abf9ee: Read AGENTS.md, CONTRIBUTING.md, the fix diff, the gate and presenter paths, the idle-wait and submission references, and the supplied runs and comments. Skimmed the overall diff; the large changed code files and all repository review rules were not read in full.; nothing run (a code review).Checked and fine:
Testing: The author reports a Linux compile, policy test and windowed smoke run on the fixed head. CI is still running; no commands from the project were executed for this review.
Overlaps and merge order: Not checked; network access is unavailable.
Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
Tested on Windows 11, RTX 5080, NVIDIA 621.47: this PR's head
48476edc, one build,RX_VK_PRESENT_GATE=1against unset,dev.py abinterleaved, 45 s each after warm-up. 4K output, DLSS from 1080p, Reflex On, V-Sync Off, uncapped, windowed. Every=1run loggedvk: the present gate: onand the second-queue line. No errors, no device lost.p99: Kokiri 8.27 → 8.63 ms, Market 13.01 → 12.72 ms.
For Windows + NVIDIA: no 1% low gain, and 3–4% fewer fps in Kokiri (
=1lower in 5 of 6 pairs and in both V-Sync pairs). The Market difference is within the spread. With=1the Kokiri 1% low varied less between runs but stayed below unset's. From this PC, I'd keep it off on Windows NVIDIA.A note on the runs above: another task's builds and one game run on this PC went through the job queue between my timed runs (9 times, never during one). The queue's load check (CPU, memory, disk) only works on Linux, so these runs have no record of how busy the PC was, and anything outside the queue would not show. The widest swing was on the unset side in Kokiri (1% low 94.6 to 133.4); its lowest run started 5 s after one of those builds ended. Nothing else ran between the two V-Sync pairs. I'd read the 1% low result (no gain) as solid and the 3–4% fps drop as less certain.