fix(vk): with V-Sync On, frame generation leaves out the made frames the refresh has no room for, so the game keeps its rate #1496
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!1496
Loading…
Reference in a new issue
No description provided.
Delete branch "pmwork-personal/Longshot:fix/fg-fifo-catch-up"
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: fix · Risk: medium · Tested on: Windows 11, RTX 5090 (NVIDIA 621.24) · Needs: a fixed-refresh display with V-Sync On, Windows with an RTX 40, AMD, Linux
TL;DR
With V-Sync On, frame generation at a high multiplier held the game back: at 6x on a 165 Hz display the game ran at 27.5
fps and each of its frames reached the present 138 ms after it was made. This PR leaves out the made frames the display
has no room for, spread evenly over each set, so the screen still gets 165 frames a second and the game keeps its own
rate. On an RTX 5090, 6x went from 27.5 to 54 fps and from 138 to 35 ms, and 3x became 24 to 42 ms faster, in 12
interleaved runs against main.
Breakdown
frame rate times the multiplier passes the display's refresh.
refresh slots they queue and hold the game back.
refresh, spread over the set, so nothing queues.
(its one made frame always stays); saves and settings.
fps, the present 24-103 ms sooner; models of the display loop in the checks.
RX_VK_FG_TIMELINE=0turns thetimeline off.
Why
#1442 put a fixed multiplier's frames on the game's timeline under FIFO (V-Sync On, and V-Sync Auto while DLSS Frame Gen
makes the frames): each frame goes at its own time, no sooner than a refresh after the frame before. When the game's frame
rate times the multiplier passes the refresh, a set's frames cannot all fit: they took the refresh slots one after
another, the sets queued, and the queue held the game back. At 6x on a 165 Hz display the game ran at 27.5 fps (165 / 6)
and the player found it unusable; at 3x the game frame reached the present 53-65 ms after its hand-over. Reviewing #1442,
HumanBean asked for that latency to be measured, and mooki listed it first in what #1442 still owes: it was measured
on #1442's branch before its merge (the rows
2026-11-17-fg-latency-*, here), and this PR is the fix.See #1442, #1362, #315.
How to reproduce
Seen on: Windows 11 Pro build 26300, RTX 5090, NVIDIA 621.24 (32.0.16.2124), 5120x2160 at 165 Hz with G-Sync
Settings and switches: V-Sync On, Frame generation 6x (or 3x uncapped) by Auto (DLSS FG), Frame pacing Off, NVIDIA
DLAA, Reflex On + Boost
Steps: in Hyrule Market, turn the camera; the FPS counter, and
longshot_log.txt's firstvk: frame interpolation:line every 5 s ("the game's frames presented N ms after the game handed them over").
Expected: the game at its own frame rate, the screen at most at the refresh, each game frame shown soon after it is made.
Actual: on main at 6x the game at 27.5 fps and each game frame presented 138 ms after its hand-over; at 3x 53 ms
(uncapped) and 65 ms (V-Sync Auto, a 60 cap, the game held at 55 fps).
What changed
Under FIFO a set on the timeline that would come late leaves made frames out: the most frames are kept that bring its game
frame within a refresh of its own time, and the ones left out are spread over the set so the picture still moves in even
steps. Their copies are not made, so no swapchain image waits for them. Also an opt-in Reflex cap for G-SYNC and FreeSync
displays, and a diagnostic log of each game frame's time from its hand-over to the screen.
gpu/vk/vk_framegen.cpp:fifo_catch_up(new) simulates the set's refresh slots asfifo_slotgives them and returnshow many made frames to leave out, at most all but one;
fifo_pick(new) picks which (6x with 3 shown: the 2nd, 4thand 6th; left out at the front the picture moved 4/6, 1/6 and 1/6 of a game frame).
display_main'stakecalls itonly under FIFO, for a set on the timeline that the swapchain holds whole; the copies and the presents take
fifo_pick's frame; the GPU's delay is still fed back against the set's first frame (against the first one shown, 6xran it down to 0 and a frame more a set was left out); the log's second
frame interpolation:line counts the framesleft out.
gpu/vk/vk_reflex.cpp:fifo_min_interval_us(new),RX_VK_FG_FIFO_CAP=1, opt-in: NVIDIA Reflex's sleep holds thegame to the multiplier's share of refresh - refresh²/3600 while frames are made under FIFO (52.5 fps at 3x and 165 Hz),
as NVIDIA's own Reflex keeps a G-SYNC display under its refresh; the multiplier as it runs (
framegen_now, #1486).apply_modepasses it with the sleep mode, computed before Reflex's lock.gpu/vk/vk_framegen.cpp,vk_main.cpp:RX_VK_FG_LATENCY_LOG=<csv>(diagnostic): each display-thread present'shand-over, call and return on the QueryPerformanceCounter clock, and
<csv>.shown.csvwith each game frame's time onscreen from the driver's present wait (a thread of its own, never beside a present call of the display thread or the
presenter thread, or a remake of the chain:
fg_latency_swapchain_goneinretire_swapchainand beforevkCreateSwapchainKHR).gpu/vk/switches.def,docs/development.md,docs/design.mdsection 13 rule 6: the two switches and the rule.tests/test_framegen_fifo_cap.py(new: the cap's values and the catch-up's answers, compiled from the source);tests/test_framegen_fixed_pace.py's FIFO model with the catch-up: 3x, 4x and 6x at 33 to 60 game frames a second on165 Hz: past the refresh 160 to 165 frames a second shown, each game frame within a refresh of its time, none
waiting, the game at its own rate; under it none left out. Stubs in two other checks, and their text in two more.
docs/tested/: 14 rows for the runs below, and 30 from the latency A/B on #1442's branch before its merge.Measurements
Verdict: better under V-Sync On wherever the frames pass the refresh: 6x 27.5 → 53.8 fps and each game frame's
present 137.7 → 35.1 ms after its hand-over; 3x uncapped 52.6 → 28.5 ms; V-Sync Auto 3x with a 60 cap 55.0 → 60.0 fps and
65.3 → 23.6 ms. The screen gets 160-165 frames a second on both sides, none under 2 ms after the one before; V-Sync Off
is unchanged.
Hardware: Windows 11 Pro build 26300, RTX 5090, NVIDIA 621.24 (32.0.16.2124), AMD Ryzen 7 9800X3D, 64 GB
Scene: Hyrule Market (child), one saved spot; 5120x2160 at 165 Hz with G-Sync, fullscreen; Frame generation by Auto (DLSS
FG), Frame pacing Off, Reflex On + Boost; per row: V-Sync On 6x and 3x uncapped with DLAA, V-Sync Auto 3x with a 60 cap
and DLSS Performance, V-Sync Off 6x with DLAA
Method: main
c7db6c02and this PR at32d570dd, each adev_packs.pypack on one base (nightly-396 @7887c497); a warm-upof each, then main, this PR, this PR, main per case; the control bridge turns the camera with the right stick (60 degrees
a second) for 30 s; PresentMon 2.3.0 on
longshot.exefor those 30 s. Each side's figure is the mean of its 2 runs (thetwo runs a row). From
longshot_log.txt's last six 5-second lines of each run: the game's frame rate (vk: N presents, X fps) and HumanBean's figure from #1442, each game frame's hand-over to its present's call (the firstvk: frame interpolation:line). On screen, PresentMon'sDisplayedTime. Each game frame's hand-over to the screen comes from thisPR's
RX_VK_FG_LATENCY_LOG(the driver's present wait), which main does not have. V-Sync Off: one run a side (the samecode on both).
How to reproduce: the settings above; read the log lines named; for the time on screen
RX_VK_FG_LATENCY_LOG=<csv>andits
.shown.csv. Rows:docs/tested/2026-11-17-fg-fifo-catch-up-*.md.c7db6c0232d570ddBefore #1442 merged, the same A/B with the latency log in both builds (rows
2026-11-17-fg-latency-*, main67efc4d3)measured each game frame on screen 39-40 ms after its hand-over at 3x uncapped (32.8 in a third session) and 45-51 ms
with the 60 cap: this PR's 33.7 is within main's range there, and its 31.0 under it.
RX_VK_FG_FIFO_CAP=1was measured then too (A 39.4 / 39.2 ms, D3 29.0 / 29.2 ms on screen,with the first catch-up, which left out at most one frame a set at its front).
Since the runs (
32d570ddon mainc7db6c02) the PR's head has: main310e7c9dmerged in (#1486, #1487, #1484, #1235,#1209, #280: #1486's DLSS FG cap changes nothing at 3x and 6x on an RTX 50, whose runtime makes up to 5 frames, and
#1235 changes the game's vsync ticker's wait, not run here), the cap taking the multiplier as it runs (opt-in, not
measured on), the latency log's waits kept from the presenter thread's presents (the log only), and the rows.
Flags and settings
Two new switches, both off by default; no menu row.
RX_VK_FG_FIFO_CAP=1RX_VK_FG_LATENCY_LOG=<csv>Testing
Tested: in the game on Windows 11, RTX 5090, NVIDIA 621.24: the 14 runs above (main and this PR in turn); the tester
watched the runs and saw the made frames stop at the refresh while the game kept its frame rate. The made frames left out
show in the log (162 a second at 6x, 10 at 3x uncapped, 16 with the 60 cap); none queued (no frame under 2 ms after the
one before).
python -I -B tests/run_all.py(Windows, llvm-mingw) on7907ae42: 667 passed, 53 failed, 48 skipped; main310e7c9donthis PC: 668 passed, 51 failed. The files that differ between the two runs do the same alone on both (test_fastfp_fma,
test_fpx_sticky and test_spawn_emit fail, test_finish_output passes); the others fail on both alike (
g++,setenv,Linux paths,
test_switch_table).tests/test_framegen_fifo_cap.pyis new and fails on main (nofifo_catch_up).Not testable by hand: a fixed-refresh display: I have only a G-SYNC one. The FIFO model in
tests/test_framegen_fixed_pace.pyis a VRR display; the Steam Deck stands in for it (Must be tested).Not tested: AMD FSR 3.1 FG and the renderer's own frame generation under FIFO (the catch-up runs for any maker; only
DLSS FG was run); 4x and 5x in the game (the model has 4x and 6x); Linux;
RX_VK_FG_FIFO_CAP=1since the catch-up spreads theframes it leaves out.
Must be tested:
against this PR, expecting no more long frames than main and no stall (Test Farm: @Beanstalk steamdeck)
no crash (Test Farm: @Beanstalk windows nvidia gpu-rtx-40xx)
(Test Farm: @Beanstalk windows amd)
(Test Farm: @Beanstalk linux amd radv)
Risks
What could break: where a made frame is left out, the frame before it stays two refreshes on the screen (3x with a 60
cap: DisplayedTime p99 6.2 → 6.8 ms); on a fixed-refresh display a set's frames could round to whole refreshes
differently than the model shows; the latency log is diagnostic only, and off.
Turning it off:
RX_VK_FG_TIMELINE=0gives the frame generation sets as before #1442 (the whole timeline path);reverting the commit gives #1442's queue back.
Compatibility: Nothing changes: no setting, save, cache or ABI.
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.
main. (main310e7c9dmerged in.)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.one a side, the same code.)
docs/tested/for each new measured run (format indocs/tested-configurations.md).mainand passing here.tests/that reads changed source updated in this PR, not weakened.Farm, under Must be tested.)
🤖 Generated with Claude Code
310e7c9dinto fix/fg-fifo-catch-up 9275abf0bdTested in game: Windows 11 Pro build 26300, RTX 5090, NVIDIA 621.24, 5120x2160 at 165 Hz with G-Sync, child Hyrule Market, DLSS FG: 12 runs against main
c7db6c02at V-Sync On 6x and 3x and V-Sync Auto 3x with a 60 cap, and 2 at V-Sync Off 6x (rows docs/tested/2026-11-17-fg-fifo-catch-up-*). At 6x the game ran at 52-55 fps where main held it to 27.5, the screen showed 165 frames a second with none queued, and no crash or lost device.Possibly related, for context: