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

Merged
llun merged 7 commits from pmwork-personal/Longshot:fix/fg-fifo-catch-up into main 2026-11-18 01:37:40 +00:00
Member

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

  • Who it helps: players with a fixed frame generation multiplier and V-Sync On (or Auto with DLSS Frame Gen) whose
    frame rate times the multiplier passes the display's refresh.
  • What was wrong: since #1442 each made frame waits for its own refresh, and when a set's frames do not fit the
    refresh slots they queue and hold the game back.
  • What changes: a set that would be late leaves out the fewest made frames that bring its game frame within a
    refresh, spread over the set, so nothing queues.
  • What does not change: V-Sync Off, mailbox, Auto (the display's own multiplier), Off; sets under the refresh; 2x
    (its one made frame always stays); saves and settings.
  • How it was checked: 12 runs on an RTX 5090 at 165 Hz, main and this PR in turn: 6x 27.5 → 54 fps, 3x 55 → 56-60
    fps, the present 24-103 ms sooner; models of the display loop in the checks.
  • What is still open: a fixed-refresh display with V-Sync On, an RTX 40, AMD and Linux.
  • Risk: medium: a frame left out leaves the one before it two refreshes on screen; RX_VK_FG_TIMELINE=0 turns the
    timeline 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 first vk: 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 as fifo_slot gives them and returns
    how many made frames to leave out, at most all but one; fifo_pick (new) picks which (6x with 3 shown: the 2nd, 4th
    and 6th; left out at the front the picture moved 4/6, 1/6 and 1/6 of a game frame). display_main's take calls it
    only 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, 6x
    ran it down to 0 and a frame more a set was left out); the log's second frame interpolation: line counts the frames
    left out.
  • gpu/vk/vk_reflex.cpp: fifo_min_interval_us (new), RX_VK_FG_FIFO_CAP=1, opt-in: NVIDIA Reflex's sleep holds the
    game 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_mode passes 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's
    hand-over, call and return on the QueryPerformanceCounter clock, and <csv>.shown.csv with each game frame's time on
    screen 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_gone in retire_swapchain and before vkCreateSwapchainKHR).
  • gpu/vk/switches.def, docs/development.md, docs/design.md section 13 rule 6: the two switches and the rule.
  • Tests: 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 on
    165 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 c7db6c02 and this PR at 32d570dd, each a dev_packs.py pack on one base (nightly-396 @ 7887c497); a warm-up
of 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.exe for those 30 s. Each side's figure is the mean of its 2 runs (the
two 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 first vk: frame interpolation: line). On screen, PresentMon's DisplayedTime. Each game frame's hand-over to the screen comes from this
PR's RX_VK_FG_LATENCY_LOG (the driver's present wait), which main does not have. V-Sync Off: one run a side (the same
code on both).
How to reproduce: the settings above; read the log lines named; for the time on screen RX_VK_FG_LATENCY_LOG=<csv> and
its .shown.csv. Rows: docs/tested/2026-11-17-fg-fifo-catch-up-*.md.

Before: main @ c7db6c02 After: this PR @ 32d570dd
6x V-Sync On: game fps 27.5 / 27.5 55.5 / 52.0
6x: game frame's present after its hand-over, ms 137.6 / 137.8 35.1 / 35.1
6x: game frame on screen after its hand-over, mean (p99), ms not logged on main 45.7 (63.9) / 51.9 (68.5)
6x: frames on screen a second (PresentMon); made frames left out a second 164.9 / 164.9; 0 164.6 / 164.3; 162
3x V-Sync On uncapped: game fps 54.8 / 54.5 57.3 / 55.5
3x: present after hand-over, ms 53.6 / 51.6 28.4 / 28.6
3x: on screen after hand-over, mean (p99), ms not logged on main 32.9 (49.8) / 34.5 (59.7)
3x: DisplayedTime p99 (sd), ms 8.5 (0.8) / 12.1 (1.4) 9.6 (0.7) / 12.1 (1.1)
3x V-Sync Auto, 60 cap: game fps 55.0 / 55.0 60.0 / 60.0
3x, 60 cap: present after hand-over, ms 65.1 / 65.6 23.5 / 23.7
3x, 60 cap: on screen after hand-over, mean (p99), ms not logged on main 28.2 (41.8) / 33.9 (59.2)
3x, 60 cap: DisplayedTime p99 (sd), ms 6.1 (0.5) / 6.2 (0.0) 7.0 (0.3) / 6.6 (0.5)
6x V-Sync Off: game fps; frames on screen a second; under 2 ms 45.7; 271.8; 0.5% 47.7; 282.5; 0.7%

Before #1442 merged, the same A/B with the latency log in both builds (rows 2026-11-17-fg-latency-*, main 67efc4d3)
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=1 was 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).

main, 6x:    vk: frame interpolation: ... the game's frames presented 137.8 ms after the game handed them over
             vk: 4080 presents, 27.5 fps
this PR, 6x: vk: frame interpolation: 824 frames shown on time, 0 late (over 2 ms); shown apart: <2 ms 0, 2-7 822, 7-9 2,
             9-12 0, 12-17 0, 17-25 0, over 25 0; the game's frames presented 35.1 ms after the game handed them over
             vk: frame interpolation: 276 sets on the game's timeline, 276 taken early, 70 with copies later than they
             came (left out of the GPU's delay), 814 frames held to a refresh after the one before (FIFO), 831 made
             frames left out to catch up (FIFO); ...
             vk: 4080 presents, 55.9 fps

Since the runs (32d570dd on main c7db6c02) the PR's head has: main 310e7c9d merged 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.

Flag What it is Before this PR After this PR Effect Helps / doesn't help / untested Recommendation
RX_VK_FG_FIFO_CAP=1 switch (attempt) none off NVIDIA Reflex holds the game to the multiplier's share of refresh - refresh²/3600 under FIFO while frames are made with the first catch-up, 3x on 165 Hz: helps with a 60 cap (29 ms on screen against main's 45-51), about main's uncapped (39 against 33-40); not run with this catch-up; would leave refreshes without a new frame on a fixed-refresh display (untested) off: by hand, for a VRR display with a frame rate cap
RX_VK_FG_LATENCY_LOG=<csv> switch (diag) none unset a CSV of each display-thread present's times, and each game frame's time on screen the measurements above unset: for latency A/B runs

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) on 7907ae42: 667 passed, 53 failed, 48 skipped; main 310e7c9d on
this 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.py is new and fails on main (no fifo_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.py is 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=1 since the catch-up spreads the
frames it leaves out.

Must be tested:

  • steamdeck (its own panel, a fixed refresh): Frame generation 2x and 3x with V-Sync On, 30 s of camera turning, main
    against this PR, expecting no more long frames than main and no stall (Test Farm: @Beanstalk steamdeck)
  • windows, nvidia, gpu-rtx-40xx: Frame generation 2x with V-Sync On, expecting fps and frame time p99 within 10% of main,
    no crash (Test Farm: @Beanstalk windows nvidia gpu-rtx-40xx)
  • windows, amd: Frame generation 3x with V-Sync On by FSR 3.1 FG, expecting the game's fps at or over main's and no crash
    (Test Farm: @Beanstalk windows amd)
  • linux, amd, radv: builds, and Frame generation 3x with V-Sync On runs, expecting no crash and fps at or over main's
    (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=0 gives 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

  • One topic.
  • The title is a Conventional Commit (type(scope): description) of the status line's type.
  • Why gives the reason plainly and links the issues that fit (the tracker searched).
  • Tested on my own PC where it runs (in the game, for a change the game runs), as Testing's Tested says; what
    can't be run by hand is in Testing's Not testable by hand, with why.
  • Measurements has a verdict, or one line saying why there is nothing to measure.
  • Nothing gets worse that I know of: any cost (speed, latency, memory, a setup that worked before) is measured and
    in Risks.
  • Testing names what was tested, what wasn't, and what must still be tested, where and how.
  • Rebased on current main. (main 310e7c9d merged in.)
  • python -I -B tests/run_all.py passes (any failure that also fails on main is named).
  • No game files, dumps, build output or generated files.
  • third_party/ untouched (a new folder with a PROVENANCE.md instead).
  • The license is OK: GPL-3.0-or-later, nothing incompatible and nothing decompiled.

When it applies

  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.
  • Numbers from the same PC, scene and settings, at least 2 interleaved runs each, the median reported. (V-Sync Off:
    one a side, the same code.)
  • Switches documented (docs/development.md; the README for a menu row) and shipped at their recommended value.
  • A file in docs/tested/ for each new measured run (format in docs/tested-configurations.md).
  • A game-free test added for the fix, failing on main and passing here.
  • A check under tests/ that reads changed source updated in this PR, not weakened.
  • Host code builds on both Windows (llvm-mingw) and Linux, with UTF-8 paths. (Windows built and run; Linux: Test
    Farm, under Must be tested.)
  • Docs updated.

🤖 Generated with Claude Code

**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 - **Who it helps:** players with a fixed frame generation multiplier and V-Sync On (or Auto with DLSS Frame Gen) whose frame rate times the multiplier passes the display's refresh. - **What was wrong:** since #1442 each made frame waits for its own refresh, and when a set's frames do not fit the refresh slots they queue and hold the game back. - **What changes:** a set that would be late leaves out the fewest made frames that bring its game frame within a refresh, spread over the set, so nothing queues. - **What does not change:** V-Sync Off, mailbox, Auto (the display's own multiplier), Off; sets under the refresh; 2x (its one made frame always stays); saves and settings. - **How it was checked:** 12 runs on an RTX 5090 at 165 Hz, main and this PR in turn: 6x 27.5 → 54 fps, 3x 55 → 56-60 fps, the present 24-103 ms sooner; models of the display loop in the checks. - **What is still open:** a fixed-refresh display with V-Sync On, an RTX 40, AMD and Linux. - **Risk:** medium: a frame left out leaves the one before it two refreshes on screen; `RX_VK_FG_TIMELINE=0` turns the timeline 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 first `vk: 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 as `fifo_slot` gives them and returns how many made frames to leave out, at most all but one; `fifo_pick` (new) picks which (6x with 3 shown: the 2nd, 4th and 6th; left out at the front the picture moved 4/6, 1/6 and 1/6 of a game frame). `display_main`'s `take` calls it only 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, 6x ran it down to 0 and a frame more a set was left out); the log's second `frame interpolation:` line counts the frames left out. - `gpu/vk/vk_reflex.cpp`: `fifo_min_interval_us` (new), `RX_VK_FG_FIFO_CAP=1`, opt-in: NVIDIA Reflex's sleep holds the game 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_mode` passes 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's hand-over, call and return on the QueryPerformanceCounter clock, and `<csv>.shown.csv` with each game frame's time on screen 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_gone` in `retire_swapchain` and before `vkCreateSwapchainKHR`). - `gpu/vk/switches.def`, `docs/development.md`, `docs/design.md` section 13 rule 6: the two switches and the rule. - Tests: `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 on 165 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 c7db6c02 and this PR at 32d570dd, each a `dev_packs.py` pack on one base (nightly-396 @ 7887c497); a warm-up of 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.exe` for those 30 s. Each side's figure is the mean of its 2 runs (the two 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 first `vk: frame interpolation:` line). On screen, PresentMon's `DisplayedTime`. Each game frame's hand-over to the screen comes from this PR's `RX_VK_FG_LATENCY_LOG` (the driver's present wait), which main does not have. V-Sync Off: one run a side (the same code on both). How to reproduce: the settings above; read the log lines named; for the time on screen `RX_VK_FG_LATENCY_LOG=<csv>` and its `.shown.csv`. Rows: `docs/tested/2026-11-17-fg-fifo-catch-up-*.md`. | | Before: main @ c7db6c02 | After: this PR @ 32d570dd | |---|---|---| | 6x V-Sync On: game fps | 27.5 / 27.5 | 55.5 / 52.0 | | 6x: game frame's present after its hand-over, ms | 137.6 / 137.8 | 35.1 / 35.1 | | 6x: game frame on screen after its hand-over, mean (p99), ms | not logged on main | 45.7 (63.9) / 51.9 (68.5) | | 6x: frames on screen a second (PresentMon); made frames left out a second | 164.9 / 164.9; 0 | 164.6 / 164.3; 162 | | 3x V-Sync On uncapped: game fps | 54.8 / 54.5 | 57.3 / 55.5 | | 3x: present after hand-over, ms | 53.6 / 51.6 | 28.4 / 28.6 | | 3x: on screen after hand-over, mean (p99), ms | not logged on main | 32.9 (49.8) / 34.5 (59.7) | | 3x: DisplayedTime p99 (sd), ms | 8.5 (0.8) / 12.1 (1.4) | 9.6 (0.7) / 12.1 (1.1) | | 3x V-Sync Auto, 60 cap: game fps | 55.0 / 55.0 | 60.0 / 60.0 | | 3x, 60 cap: present after hand-over, ms | 65.1 / 65.6 | 23.5 / 23.7 | | 3x, 60 cap: on screen after hand-over, mean (p99), ms | not logged on main | 28.2 (41.8) / 33.9 (59.2) | | 3x, 60 cap: DisplayedTime p99 (sd), ms | 6.1 (0.5) / 6.2 (0.0) | 7.0 (0.3) / 6.6 (0.5) | | 6x V-Sync Off: game fps; frames on screen a second; under 2 ms | 45.7; 271.8; 0.5% | 47.7; 282.5; 0.7% | Before #1442 merged, the same A/B with the latency log in both builds (rows `2026-11-17-fg-latency-*`, main 67efc4d3) 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=1` was 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). ``` main, 6x: vk: frame interpolation: ... the game's frames presented 137.8 ms after the game handed them over vk: 4080 presents, 27.5 fps this PR, 6x: vk: frame interpolation: 824 frames shown on time, 0 late (over 2 ms); shown apart: <2 ms 0, 2-7 822, 7-9 2, 9-12 0, 12-17 0, 17-25 0, over 25 0; the game's frames presented 35.1 ms after the game handed them over vk: frame interpolation: 276 sets on the game's timeline, 276 taken early, 70 with copies later than they came (left out of the GPU's delay), 814 frames held to a refresh after the one before (FIFO), 831 made frames left out to catch up (FIFO); ... vk: 4080 presents, 55.9 fps ``` Since the runs (32d570dd on main c7db6c02) the PR's head has: main 310e7c9d merged 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. | Flag | What it is | Before this PR | After this PR | Effect | Helps / doesn't help / untested | Recommendation | |---|---|---|---|---|---|---| | `RX_VK_FG_FIFO_CAP=1` | switch (attempt) | none | off | NVIDIA Reflex holds the game to the multiplier's share of refresh - refresh²/3600 under FIFO while frames are made | with the first catch-up, 3x on 165 Hz: helps with a 60 cap (29 ms on screen against main's 45-51), about main's uncapped (39 against 33-40); not run with this catch-up; would leave refreshes without a new frame on a fixed-refresh display (untested) | off: by hand, for a VRR display with a frame rate cap | | `RX_VK_FG_LATENCY_LOG=<csv>` | switch (diag) | none | unset | a CSV of each display-thread present's times, and each game frame's time on screen | the measurements above | unset: for latency A/B runs | ## 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) on 7907ae42: 667 passed, 53 failed, 48 skipped; main 310e7c9d on this 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.py` is new and fails on main (no `fifo_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.py` is 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=1` since the catch-up spreads the frames it leaves out. **Must be tested:** - steamdeck (its own panel, a fixed refresh): Frame generation 2x and 3x with V-Sync On, 30 s of camera turning, main against this PR, expecting no more long frames than main and no stall (Test Farm: @Beanstalk steamdeck) - windows, nvidia, gpu-rtx-40xx: Frame generation 2x with V-Sync On, expecting fps and frame time p99 within 10% of main, no crash (Test Farm: @Beanstalk windows nvidia gpu-rtx-40xx) - windows, amd: Frame generation 3x with V-Sync On by FSR 3.1 FG, expecting the game's fps at or over main's and no crash (Test Farm: @Beanstalk windows amd) - linux, amd, radv: builds, and Frame generation 3x with V-Sync On runs, expecting no crash and fps at or over main's (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=0` gives 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 - [x] One topic. - [x] The title is a Conventional Commit (`type(scope): description`) of the status line's type. - [x] Why gives the reason plainly and links the issues that fit (the tracker searched). - [x] Tested on my own PC where it runs (in the game, for a change the game runs), as Testing's Tested says; what can't be run by hand is in Testing's Not testable by hand, with why. - [x] Measurements has a verdict, or one line saying why there is nothing to measure. - [x] Nothing gets worse that I know of: any cost (speed, latency, memory, a setup that worked before) is measured and in Risks. - [x] Testing names what was tested, what wasn't, and what must still be tested, where and how. - [x] Rebased on current `main`. (main 310e7c9d merged in.) - [x] `python -I -B tests/run_all.py` passes (any failure that also fails on `main` is named). - [x] No game files, dumps, build output or generated files. - [x] `third_party/` untouched (a new folder with a `PROVENANCE.md` instead). - [x] The license is OK: GPL-3.0-or-later, nothing incompatible and nothing decompiled. ### When it applies - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. - [x] Numbers from the same PC, scene and settings, at least 2 interleaved runs each, the median reported. (V-Sync Off: one a side, the same code.) - [x] Switches documented (docs/development.md; the README for a menu row) and shipped at their recommended value. - [x] A file in `docs/tested/` for each new measured run (format in `docs/tested-configurations.md`). - [x] A game-free test added for the fix, failing on `main` and passing here. - [x] A check under `tests/` that reads changed source updated in this PR, not weakened. - [x] Host code builds on both Windows (llvm-mingw) and Linux, with UTF-8 paths. (Windows built and run; Linux: Test Farm, under Must be tested.) - [x] Docs updated. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Ported from #1442's branch after its merge (its local commits 9b1ea9e9, cb8936fb, 3652a37b, 4af37570, 9ea95fcb, 00d9bcf8,
fdb59b96, 54e10f04 and the second review's work in progress), onto main c7db6c02 in one 3-way step: main's own later
changes win where both touched a line (HumanBean's 09e3e113 for the refresh not known, #1476's present-queue rule).

- FIFO's catch-up (fifo_catch_up): a set on the timeline whose first frame would come over a refresh late leaves its
  first made frame out, from 3x; only a set the swapchain holds whole.
- RX_VK_FG_FIFO_CAP=1 (opt-in): NVIDIA Reflex's minimum interval holds the game to the multiplier's share of
  refresh - refresh^2/3600 under FIFO while frames are made.
- RX_VK_FG_LATENCY_LOG=<csv>: each display-thread present's hand-over, call and return; <csv>.shown.csv each game
  frame's time on screen from the driver's present wait.
- docs/tested: the latency A/B's 30 runs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
At 6x on a 165 Hz display the catch-up's one frame a set was not enough: the game was held to 27.5 frames a second
and each game frame shown 138 ms after its hand-over. fifo_catch_up now keeps the most frames that bring the set's
game frame within a refresh of its own time, at most all made frames but one out; fifo_pick spreads the ones left
out over the set (6x with 3 shown: the 2nd, 4th and 6th), so the picture moves in even steps. The GPU's delay is fed
back against the set's first frame again: against the first one shown, 6x ran it down to 0 and a frame more a set
was left out.

The FIFO model (tests/test_framegen_fixed_pace.py) checks 3x, 4x and 6x at 33 to 60 game frames a second on 165 Hz:
past the refresh 160 to 165 shown a second, each game frame within a refresh of its time, none waiting, the game at
its own rate; under it none left out. Also from the second review of #1442: the latency log's comment says when the
shown file is made; docs/development.md's RX_VK_FG_TIMELINE=0 row names FIFO's one-set cases; design.md rule 5's tail
was doubled by the port.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
From a cold review of the branch: fg_latency_swapchain_gone noted nothing before the log's thread started, so a chain
retired just after the first present's id was queued could be waited on after it was destroyed; it now notes every
time. vkWaitForPresentKHR's VK_SUBOPTIMAL_KHR is a present shown too. The shown file has the game frames of sets
presented ahead only (docs/development.md, switches.def). In tests/test_framegen_fixed_pace.py the GPU's delay limit
is 10 ms with its reason (the game no longer held to 55 a second, the 10 and 20 ms gaps reach the pacing: 8.75 ms),
not a placeholder, and two comments say what the catch-up now does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
vk_framegen.h: both declarations kept (fg_latency_swapchain_gone; #1486's framegen_capped and framegen_now).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Since #1486 a fixed multiplier past DLSS FG's runtime's most runs at that most (a saved 8x at 6x on an RTX 50): with
RX_VK_FG_FIFO_CAP=1 the cap held the game to 8x's share of the refresh. The check has 8x saved and 6x running.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
fix(vk): the latency log's waits kept from the presenter thread's presents; the cap's and 7x/8x texts as measured
Some checks failed
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
Website / Website on Cloudflare (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 8s
PR description / Description follows the template (pull_request_target) Successful in 10s
CI / Workflow lint (actionlint) (pull_request) Successful in 12s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 12s
Third-party parts / As their notes say (pull_request) Successful in 14s
Website / Website on Cloudflare (pull_request_target) Has been skipped
7907ae42fb
From a second cold review: the presenter thread (RX_VK_PRESENT_THREAD) presents a handed-over made frame under
dev.presenter_queue_mu, not present_image_mu, so the log's thread now waits only when both are free. The docs said the
opt-in cap gave the least latency; measured with the first catch-up it was 29 ms against 45-51 with a 60 cap, and about
main's uncapped: they say that now. Since #1486 DLSS FG runs a saved 7x or 8x at 6x, so only the renderer's own or FSR
3.1 frame generation goes out as it comes there. design.md's 6x figures are the measured ones. A text check holds the
catch-up's condition.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Member

Tested 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 c7db6c02 at 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.

Tested 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 c7db6c02 at 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.
Collaborator

Possibly related, for context:

  • issue #1381 Game: Linux Reflex/DLSS Frame Generation does not cap base frames below V-Sync refresh — Related Linux Reflex/frame-generation refresh cap behavior
Possibly related, for context: - issue #1381 Game: Linux Reflex/DLSS Frame Generation does not cap base frames below V-Sync refresh — Related Linux Reflex/frame-generation refresh cap behavior
llun approved these changes 2026-11-18 01:37:31 +00:00
llun merged commit 02a2e4f0b1 into main 2026-11-18 01:37:40 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
3 participants
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
MagicBeanDev/Longshot!1496
No description provided.