fix(vk): frame generation's fixed multipliers on the game's timeline under V-Sync On (FIFO) too #1442
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
6 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!1442
Loading…
Reference in a new issue
No description provided.
Delete branch "pmwork-personal/Longshot:fix/fg-fifo-paced"
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: Windows with another NVIDIA card (RTX 40), AMD and Intel, a fixed-refresh display with V-Sync On, Linux
On main since #1362 merged: rebased onto main
e8e92f97, this PR's own commits only (b168de50the code,c50d1993the hintand docs,
024e7432the tested rows,42252930the review's fixes), plus09e3e113from HumanBean's review: one set's imagesunder FIFO when the display's refresh is unknown, and the game frame's handover-to-present time in the log, for the latency A/B.
Why
With V-Sync On (and V-Sync Auto, which is FIFO while DLSS Frame Gen makes the frames), a fixed multiplier's set still
went out as it came: FIFO showed its frames one a refresh, and the set's last frame stayed on the screen until the next
set came. The motion is uneven (3x at 60 fps on a 240 Hz G-Sync display: 4.2, 4.2 and 8.3 ms a frame), and at the
display's limit main loses frames: at 3x with a 60 cap on 165 Hz it ran at 51-53 fps, with frames on the screen up to
15-17 ms (p99) instead of one refresh.
#1362 shows a set's frames at their own times where the swapchain does not wait for a refresh. This PR does the same
under FIFO, where at most one frame can go out each refresh.
See #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 (or Auto with DLSS Frame Gen), Frame generation 3x (Frame generation by: Auto,
DLSS FG), Frame pacing Off (its default)
Steps: in play, turn the camera at an even speed; for numbers, run PresentMon on
longshot.exe.Expected: each frame on the screen for about the same time (one or a few refreshes, as the frame rate asks).
Actual: on main the frames' times on the screen vary (sd 2.3-2.5 ms at 3x, V-Sync On), and at the refresh limit
the game drops to 51-53 fps with frames shown up to 15-17 ms.
What changed
A fixed multiplier's set is now shown on the game's timeline in every present mode. Under FIFO each frame goes at its
due time but no sooner than a refresh after the frame before was given, so the frames never queue up in the swapchain
and the next set's copies never wait behind them.
RX_VK_FG_TIMELINE=0still gives main's behaviour back.gpu/vk/vk_framegen.cpp:fixed_on_timelineno longer leaves FIFO out;fifo_slot(new) gives a frame its timeunder FIFO: its due time, but not sooner than a refresh after the slot the frame before was given, the slots a refresh
apart from the last one given (as Auto's), and again from now when more than half a refresh behind (the display thread
held up). In
display_main: the display's refresh per set (Taken.refresh), a present late by over 1 ms past its slotis the next one's slot, a present that is not shown gives its slot back, a frame under FIFO is late against its slot,
and the log's second
frame interpolation:line counts the frames held to a slot.gpu/vk/vk_main.cppcreate_swapchain: two sets' images under FIFO too (with #1362's slot per frame of both sets,and at most
kPresentSlotsMaxover the least), so the next set is taken early there as well: with one set's, itscopies went once the set before was shown, behind the game's next frame. Under FIFO a set too big for the chain (an
NVIDIA surface: 7x and 8x) keeps one set's, as main: more images there only deepen FIFO's queue.
RX_VK_FG_TIMELINE=0: one set's and 3 slots, as main.create_device's comment says the presentqueue is off by default, and what it did under FIFO.
docs/development.md,gpu/vk/switches.def: the fixedmultipliers keep their own times in every mode ("With V-Sync Off" goes); as on #1362, the hint does not send players
to
RX_VK_PRESENT_QUEUE, which the README anddocs/development.mdkeep.docs/design.mdsection 13 is now "Framegeneration's presents, as rules" (rule 2: FIFO and
fifo_slot); its anchor's new name is in the five// doc:lines,tests/test_doc_anchors.pyand the measure skill.tests/test_framegen_fixed_pace.py: a model of a VRR display under FIFO (one present a refresh, three sets, a late wake)next to #1362's V-Sync Off model: 3x at 60 fps on 240 Hz shows each frame as far after the one before as its picture; a
late set goes out a refresh apart, never two presents waiting; game frames 10 and 20 ms apart at 3x on 165 Hz are
shown each when presented, the game held at 55 fps.
This joins the FIFO work of an earlier branch onto #1362: that branch also left late made frames out (a drop), which #1362
removed. With the drop, the refresh limit failed (the game ran at its 60 cap and threw away 80-120 made frames per 5 s:
two-refresh gaps); without it the game is held at the limit, as below.
Measurements
Verdict: better than main in all three cases. At the refresh limit (3x, cap 60) the frames' times on the screen
went from sd 1.6-2.2 ms to 0.1-0.3 ms and the game from 51-53 to 55 fps; with V-Sync On at 3x (the tester's settings),
sd 2.3-2.5 to 0.7 ms, p99 18 to 8-9 ms, and the game from 50 to 54 fps; at 2x with a 60 cap, the animation error from
3.9-4.1 to 2.3-2.5 ms and the latency from 14.2 to 11.2 ms.
Hardware: Windows 11 Pro build 26300, RTX 5090, NVIDIA 621.24, AMD Ryzen 7 9800X3D, 64 GB
Scene: Hyrule Market (child), a saved spot where the camera can turn; 5120x2160 at 165 Hz with G-Sync, fullscreen, DLSS
frame generation (DLSS-G made every frame in play), Reflex On + Boost. D3: V-Sync Auto, 3x, cap 60, DLSS Performance
(180 frames a second asked of 165 Hz: the refresh limit). A: V-Sync On, 3x, uncapped, DLAA (the tester's own). D2: V-Sync
Auto, 2x, cap 60, DLSS Performance (120 a second).
Method: main at #1362's base and this PR, each a
dev_packs.pypack on one base (nightly-396 @7887c497), a warm-up ofeach, then main and this PR in turn: D3 three runs a side, A and D2 two a side (2026-11-17 10:34 to 10:52). The control
bridge turns the camera with the right stick (60 degrees a second) for 30 s; PresentMon 2.3.0 on
longshot.exefor 26 sof it. Columns from PresentMon's CSV: frames shown a second, the game's fps (that over the multiplier),
DisplayedTime'ssd and p99, far = frames more than 35% off the mean, the sd of
AnimationError,DisplayLatency's median. Each run'snumber is shown. The head,
2d3bc77b, adds the review's fixes after the measured 1a854a3e (=80186012), not run on the screen: the late count underFIFO (the log only), one set's images under FIFO for 7x and 8x (not measured here), the display's refresh asked after a
set's copies instead of before (once a second, a call to Windows no longer in the first copy's time), the test model and
comments; at 2x and 3x what is shown does not change. Since the runs, #1362 took main
67efc4d3in (a merge) and this PRis rebased onto it: main's #1309 deleted RX_VK_PRESENT_AHEAD, whose default (a set's copies together) the runs used, and
is otherwise a refactor its own runs measured as no change in fps.
How to reproduce: the settings above, a save at a spot to turn the camera, PresentMon 2.x
--process_name longshot.exe --timed 26 --terminate_after_timed --output_file <csv>. Rows:docs/tested/2026-11-17-fg-fifo-*.md.544229a2DisplayedTimesd, msDisplayedTimesd, msDisplayedTimesd, msDisplayLatencymedian), msFlags and settings
No new switch.
RX_VK_FG_TIMELINE(from #1362) now also covers FIFO; its row and docs say so.RX_VK_FG_TIMELINE=0off=0: the sets, images and slots as main in every mode=0for an A/BTesting
Tested:
Game-free:
python -I -B tests/run_all.pyon0c552c97(Windows, llvm-mingw): 630 passed, 46 failed, 47 skipped. All 46fail on main on this PC too: they call
g++orsetenv, read Linux paths, or check things this PC lacks(
test_tested_configurations: a Windows pipe's line ends). Four (fastfp_fma,fpx_sticky,spawn_emit,finish_output) pass or fail from run to run on this PC, on main as here.tests/test_framegen_fixed_pace.py(new)and the checks that cut the changed sources pass; so do
test_switch_tableandtest_vk_swapchain_compatsincemain
67efc4d3.The 46, each failing on main too
auto_handheld bug_report bug_report_defaults cpu_report crash_dialog crash_groups crt_options damage_debug_menu
display_startup_failure dlss_feature_size failed_compile_keeps_objects finish_output framegen_preset
fsr_uniform_ownership guest_imported hardware_report hud_layout_row import_reach invalidate_vcore job_queue
linux_preflight linux_pressure mirror_budget missing_nup pads_after_menu parallel_init_order pending_guest_import
perf_report pipeline_play_cache portable_builder_startup present_thread profiling_mode readback_timeout_source
recorder_sync replay_write_order rumble_menu run_all_changed slow_frames staging_burst target_image_pool
tested_configurations upscaler_round_trip upscaler_rows vcore_escape vk_occlusion_queries walk_key
A cold review of this PR's commits by a second agent: nothing that can wait forever or hold the game more than main,
no overflow, no fault at a mode change or a failed present,
RX_VK_FG_TIMELINE=0as main. Its findings, fixed in2d3bc77b: the late count under FIFO missed late frames; 7x and 8x under FIFO got two sets' images, which only deepenedFIFO's queue (two refreshes more delay); the refresh query counted in the first copy's time; the test's FIFO model fed
back every set where the code feeds back none at the refresh limit (the case now runs both ways); two stale comments.
In the game, Windows 11, RTX 5090, NVIDIA 621.24, 5120x2160 at 165 Hz with G-Sync: the runs above.
Not tested: the head's fixes on the screen (
2d3bc77b, above); a fixed-refresh display with V-Sync On (frames round towhole refreshes there;
fifo_slotkeeps them a refresh apart at least); a display whose refresh Windows does not report(no
fifo_slotspacing then: the frames go as on main); 4x and up under FIFO; FSR 3.1 frame generation and the built-in maker under FIFO; AMD, Intel andRTX 40 cards; Linux; the present queue under FIFO in this branch (the earlier branch measured it: animation error 2.98 ->
1.65 ms at V-Sync On 3x).
Must be tested:
the log's second
frame interpolation:line counting frames held to a refresh (Test Farm: @Beanstalk windows nvidia,V-Sync On with DLSS frame generation at 3x, the camera turning; PresentMon against main)
linux)
more often than on main (by hand: a tester with such a display)
Risks
What could break: frame generation under FIFO (V-Sync On, and Auto with DLSS Frame Gen) with a fixed multiplier: each
frame now waits for its time and its refresh slot, so the game's frame is shown about made / (made + 1) of a game frame
later than on main (in these runs the latency stayed the same or went down: 11.8 ms at 3x, 14.2 -> 11.2 ms at 2x); the
swapchain asks for two sets' images under FIFO (an NVIDIA surface: 8 from 3x up, 6 at 2x); a display whose refresh the
system reports wrong would get its slots too far apart or too close.
Turning it off:
RX_VK_FG_TIMELINE=0(the sets, images and slots as on main in every mode).Compatibility: Nothing changes: no save,
longshot_options.inikey, cache or vk ABI change.Issues
See #315
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 extra swapchain images under FIFO, a memory cost with no measurement.
main.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.docs/tested/for each new measured run (format indocs/tested-configurations.md).tests/that reads changed source updated in this PR, not weakened.🤖 Generated with Claude Code
With V-Sync Off, a fixed frame generation multiplier's frames are shown at their own times on the game's timeline whether Frame pacing is On or Off (where the swapchain holds a set's frames at once: up to 6x on an NVIDIA card). The hint for Off ("As soon as it is ready.") and README's Frame pacing text did not say so. Both hints now add it, in the 13 languages of menu_i18n.h (machine-made, as the file says). tests/test_menu_i18n.py fails on main on this PC too (pt-BR's count). Co-Authored-By: Claude Opus 5.5 <[email protected]>544229a2, the PR, the PR with the present queue) d68011f26867efc4d3) into fix/fg-paced-without-vsync544229a2against this branch (round 6) f7d5523dcdTested in game: Windows 11 Pro build 26300, RTX 5090, NVIDIA 621.24, 5120x2160 at 165 Hz with G-Sync, Hyrule Market (child), DLSS frame generation (DLSS-G made every frame in play). Scripted 30 s camera turns with PresentMon, main @
544229a2against this PR @ 1a854a3e (stacked on #1362), packs on one base, in turn: at the refresh limit (V-Sync Auto, 3x, cap 60) three runs a side, the game 50.8-52.6 -> 54.9-55.0 fps and the frames' time on screen sd 1.6-2.2 -> 0.1-0.3 ms, p99 15-17 -> 6.2 ms; V-Sync On 3x (the tester's settings) two a side, 50 -> 54.4 fps, sd 2.3-2.5 -> 0.7 ms, p99 18 -> 8.3-8.7 ms; V-Sync Auto 2x cap 60 two a side, animation error sd 3.9-4.1 -> 2.3-2.5 ms, latency 14.2 -> 11.2 ms. The head2d3bc77b(the review's fixes, rebased onto main67efc4d3through #1362) builds and passes the checks; it was not run on the screen (the description says why the numbers hold).@Beanstalk please run this branch against main with V-Sync On and Frame generation at 2x and at 3x (and V-Sync Auto with a 60 frame rate cap at 3x, which asks more frames than a 165 Hz display shows), turning the camera in play for about 30 s each, on: Windows with an RTX 40 card (DLSS frame generation), and AMD on Windows and on Linux (FSR 3.1 frame generation). What to look at: the two
vk: frame interpolation:lines in longshot_log.txt (frames shown on time and late; sets on the game's timeline, taken early, frames held to a refresh), and where PresentMon runs, the spread of DisplayedTime and the game's fps. Expected: the frames more evenly on the screen than on main, the game's fps the same or higher at the display's limit, and no new stutter, errors or device loss. RX_VK_FG_TIMELINE=0 gives main's behaviour on the same build, for an A/B.@pmwork-personal only members of
BigBeanscan start the farm.One of them can approve this request by reacting 👍 to it or to this comment.This request was for2d3bc77, and the PR has changed since (0c552c9), so a 👍 no longer approves it. Comment@Beanstalkagain to ask for the new commit.e3420742into fix/fg-fifo-paced: the hint without the present queue, the image cap0c552c97: #1362's answer to HumanBean's review merged in (a merge, no force push): the Frame pacing hint (13 languages) no longer sends players to RX_VK_PRESENT_QUEUE (README and development.md keep it, with its risk), and create_swapchain's image request stays at most kPresentSlotsMax over the least, next to this PR's one-set rule for 7x and 8x under FIFO. Builds (dev_packs.py pack); suite 630 passed, 46 failed, 47 skipped, all 46 failing on main too.@Beanstalk please run this branch at
0c552c97against main with V-Sync On and Frame generation at 2x and at 3x (and V-Sync Auto with a 60 frame rate cap at 3x, which asks more frames than a 165 Hz display shows), turning the camera in play for about 30 s each, on: Windows with an RTX 40 card (DLSS frame generation), and AMD on Windows and on Linux (FSR 3.1 frame generation). What to look at: the twovk: frame interpolation:lines in longshot_log.txt (frames shown on time and late; sets on the game's timeline, taken early, frames held to a refresh), and where PresentMon runs, the spread of DisplayedTime and the game's fps. Expected: the frames more evenly on the screen than on main, the game's fps the same or higher at the display's limit, and no new stutter, errors or device loss. RX_VK_FG_TIMELINE=0 gives main's behaviour on the same build, for an A/B. (The request on2d3bc77bexpired with the new commit.)@pmwork-personal only members of
BigBeanscan start the farm. One of them can approve this request by reacting 👍 to it or to this comment.@Beanstalk please run this branch at
0c552c97against main with V-Sync On and Frame generation at 2x and at 3x (and V-Sync Auto with a 60 frame rate cap at 3x, which asks more frames than a 165 Hz display shows), turning the camera in play for about 30 s each, on: Windows with an RTX 40 card (DLSS frame generation), and AMD on Windows and on Linux (FSR 3.1 frame generation). What to look at: the two vk: frame interpolation: lines in longshot_log.txt (frames shown on time and late; sets on the game's timeline, taken early, frames held to a refresh), and where PresentMon runs, the spread of DisplayedTime and the game's fps. Expected: the frames more evenly on the screen than on main, the game's fps the same or higher at the display's limit, and no new stutter, errors or device loss. RX_VK_FG_TIMELINE=0 gives main's behaviour on the same build, for an A/B. (The request on2d3bc77bexpired with the new commit.)Beanstalk test farm · an earlier run: commit
0c552c9(the newer results are in a comment below)Commit
0c552c9· tier reviewed · approved by llun · dashboardWhat will be tested · AI plan (
gpt-6.1-terra)Compare the PR with main in child Hyrule Market on Windows RTX 40, Windows AMD, and Linux AMD, using 2x and 3x frame generation with V-Sync On and Auto. Each run turns the camera for approximately 30 seconds at 60 frames per second, then measures frame time and FPS; the four setting combinations take roughly 15–20 minutes per tester. Crashes, device loss, substantial FPS drops, or worse p99 frame times fail the plan. The farm cannot measure during the camera turn or collect PresentMon DisplayedTime, so this does not establish on-screen pacing or reproduce a 165 Hz display limit.
1or0; frame_generation2or3.Started at 18:43 UTC.
NVIDIA GeForce RTX 4070, 621.1.0AMD Radeon RX 9070 XT, 2.0.416AMD Radeon RX 7900 XTX (RADV NAVI31), 26.2.7; 2: linux+amd+radv+dgpuAMD Radeon RX 7900 XT (RADV NAVI31), 26.2.6vsync=1, frame_generation=2vsync=1, frame_generation=2vsync=1, frame_generation=2vsync=1, frame_generation=3vsync=1, frame_generation=3vsync=1, frame_generation=3vsync=0, frame_generation=2vsync=0, frame_generation=2vsync=0, frame_generation=2vsync=0, frame_generation=3vsync=0, frame_generation=3vsync=0, frame_generation=3Measurements · windows+nvidia+gpu-rtx-40xx
Verdict: fail on windows+nvidia+gpu-rtx-40xx (1/1 report):
market-framegen screenshot.max_difffailed.Hardware: 1: windows+nvidia+nvidia-proprietary+dgpu
NVIDIA GeForce RTX 4070, 621.1.013th Gen Intel(R) Core(TM) i7-13700F, 32 GB RAMScene: market-framegen, from a new save (frame_pacing=0, frame_rate_cap=0); each cell's settings and switches as the table names them
Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); market-framegen: 1 game start a side, market 30 s after 5 s warm-up; each number the median of the runs, then of 1 report
How to reproduce: the farm's plan above (
@Beanstalkon this PR runs it again)67efc4d0c552c9vsync=1, frame_generation=2· market · frame ratevsync=1, frame_generation=2· market · frame time (p99) (ms)vsync=1, frame_generation=2· forbidden log linesvsync=1, frame_generation=3· market · frame ratevsync=1, frame_generation=3· market · frame time (p99) (ms)vsync=1, frame_generation=3· forbidden log linesvsync=0, frame_generation=2· market · frame ratevsync=0, frame_generation=2· market · frame time (p99) (ms)vsync=0, frame_generation=2· forbidden log linesvsync=0, frame_generation=3· market · frame ratevsync=0, frame_generation=3· market · frame time (p99) (ms)vsync=0, frame_generation=3· forbidden log linesFlags and settings
vsync1,0frame_generation2,3Markdown for the PR description
Measurements · windows+amd
Verdict: fail on windows+amd (1/1 report):
market-framegen screenshot.max_difffailed.Hardware: 1: windows+amd+amd-proprietary+dgpu
AMD Radeon RX 9070 XT, 2.0.416AMD Ryzen 7 5800X3D 8-Core Processor, 32 GB RAMScene: market-framegen, from a new save (frame_pacing=0, frame_rate_cap=0); each cell's settings and switches as the table names them
Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); market-framegen: 1 game start a side, market 30 s after 5 s warm-up; each number the median of the runs, then of 1 report
How to reproduce: the farm's plan above (
@Beanstalkon this PR runs it again)67efc4d0c552c9vsync=1, frame_generation=2· market · frame ratevsync=1, frame_generation=2· market · frame time (p99) (ms)vsync=1, frame_generation=2· forbidden log linesvsync=1, frame_generation=3· market · frame ratevsync=1, frame_generation=3· market · frame time (p99) (ms)vsync=1, frame_generation=3· forbidden log linesvsync=0, frame_generation=2· market · frame ratevsync=0, frame_generation=2· market · frame time (p99) (ms)vsync=0, frame_generation=2· forbidden log linesvsync=0, frame_generation=3· market · frame ratevsync=0, frame_generation=3· market · frame time (p99) (ms)vsync=0, frame_generation=3· forbidden log linesFlags and settings
vsync1,0frame_generation2,3Markdown for the PR description
Measurements · linux+amd
Verdict: fail on linux+amd (2/1 report):
market-framegen screenshot.max_diff;market-framegen market.frametime_p99_ms.max_delta_pct (+18.2%);market-framegen market.fps_mean.min_delta_pct (-12.7%)failed.Hardware: 1: linux+amd+radv+dgpu
AMD Radeon RX 7900 XTX (RADV NAVI31), 26.2.7AMD Ryzen 7 5800X3D 8-Core Processor, 64 GB RAM; 2: linux+amd+radv+dgpuAMD Radeon RX 7900 XT (RADV NAVI31), 26.2.6AMD Ryzen 7 5700X3D 8-Core Processor, 32 GB RAMScene: market-framegen, from a new save (frame_pacing=0, frame_rate_cap=0); each cell's settings and switches as the table names them
Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); market-framegen: 1 game start a side, market 30 s after 5 s warm-up; each number the median of the runs, then of 2 reports
How to reproduce: the farm's plan above (
@Beanstalkon this PR runs it again)67efc4d0c552c9vsync=1, frame_generation=2· market · frame ratevsync=1, frame_generation=2· market · frame time (p99) (ms)vsync=1, frame_generation=2· forbidden log linesvsync=1, frame_generation=3· market · frame ratevsync=1, frame_generation=3· market · frame time (p99) (ms)vsync=1, frame_generation=3· forbidden log linesvsync=0, frame_generation=2· market · frame ratevsync=0, frame_generation=2· market · frame time (p99) (ms)vsync=0, frame_generation=2· forbidden log linesvsync=0, frame_generation=3· market · frame ratevsync=0, frame_generation=3· market · frame time (p99) (ms)vsync=0, frame_generation=3· forbidden log linesFlags and settings
vsync1,0frame_generation2,3Markdown for the PR description
Verdict: Request changes. The smoothness gain is real and well measured. But this turns the timeline on for the most common frame generation setup (V-Sync Auto with DLSS Frame Gen is FIFO), and the latency evidence it gives,
DisplayLatency, can't see the cost the change adds. A likely cost nobody has measured has to be measured before this merges.What it does: under V-Sync On and Auto, a fixed multiplier's frames go out at their own times, no sooner than a refresh apart, instead of queueing in FIFO. The game holds 55 fps at the display's limit instead of 51-53, and frames on the screen go from sd 2.3 ms to 0.7 ms. It makes the code better if it doesn't cost latency.
Reviewed:
0c552c97against #1362's heade3420742(this PR's own commits; #1362 itself is reviewed there). Read in full: the changes tovk_framegen.cpp(fixed_on_timeline,fifo_slot,display_main's slot handling),vk_main.cpp(create_swapchain'sset_too_bigandfg_sets,create_device's comment),vk_replay.cpp(present_slots_for's comment,present_image's remake key),display_refresh_mhzon both platforms,switches.defand the hint. Skimmed: the test model,docs/design.mdsection 13, the README, development.md, the measure skill, the 14docs/tested/rows, the 13 languages. Nothing run (a code review).Fixed in this review: nothing.
Checked and fine:
fifo_slotand its use: a present that isn't shown gives its slot back, and a late one moves the next slot.vsync_now's new term can't collide with the others:swapchain_framegen()*2+1stays under 16, and Auto isopts.framegen == 1.set_too_biguses the surface's own spare count, so 7x and 8x on an NVIDIA surface keep one set's images, as on main.kPresentSlotsMaxover the least (#1362'se3420742).refresh_mhz.RX_VK_PRESENT_QUEUE.RX_VK_FG_TIMELINE=0gives main's images, slots and path in every mode.Blocking
Latency under FIFO is not measured. Risks says it "stayed the same or went down: 11.8 ms at 3x, 14.2 -> 11.2 ms at 2x", from
DisplayLatency. PresentMon measures that from the frame'sCPUStartTime, which, for an app that gives it no markers, is the end of the present call before. It covers the last few ms before each present, not the time since the game handed the frame over. It can't see what this PR adds: the game's frame held for its lead (made / (made + 1) of a game frame, ~12 ms at 3x and 55 fps) pluslate_ns(14.9 ms in the r6A-pr1 log). That every 3x run reads 11.8 ms on both sides fits that. (My #1362 review asked forDisplayLatencytoo; that was wrong for this.) Main's FIFO queue also delayed the game's frame behind its made ones, so the real difference may be small. But it has to be shown, since this reaches most RTX 40 and 50 players with V-Sync Auto. Two ways that measure it:MsPCLatency(the runs had Reflex On, so the markers are there);framegen_queueto itspresent_commit, main against this PR.Put the result in Measurements and Risks. If it is worse than main, that is a regression to fix, not a trade-off to state.
Suggestions
vk_main.cpp:1075, inline: under FIFO with the refresh unknown (display_refresh_mhz()0),fifo_slotdoesn't space the frames. With two sets' images, FIFO can then queue more presents than on main, so latency is deeper than main's, not "as on main" as Not tested says. Taking one set's images there (fg_sets = 1when FIFO and the refresh is 0) would keep that case as main.Testing: one PC (RTX 5090, Windows, 165 Hz G-Sync), and its numbers are good. The Test Farm run llun approved (RTX 40, AMD Windows and Linux) is running, but it says itself that it can't measure on-screen pacing, only fps and frame times. The run that holds this merge is a fixed-refresh display with V-Sync On, already in Must be tested. A present timed between vblanks behaves differently there than on VRR, and FIFO's queue no longer covers a frame that misses one. That setup is common: TVs, and the Steam Deck's own panel. A Steam Deck run would cover it and Linux at once.
Overlaps and merge order: stacked on #1362, which merges first. The latency point stands there too, for V-Sync Off.
@ -1056,0 +1072,4 @@const bool timeline = !(timeline_env && env_value_off(timeline_env));const bool set_too_big = mode == VK_PRESENT_MODE_FIFO_KHR && caps.maxImageCount &&(uint32_t)std::max(opts.framegen, 0) > caps.maxImageCount - std::min(caps.maxImageCount, caps.minImageCount);const uint32_t fg_sets = timeline && !set_too_big ? 2 : 1;Under FIFO with the refresh unknown (
display_refresh_mhz()returns 0),fifo_slotdoesn't space the frames, so with two sets' images FIFO can queue more presents than on main: more latency than main, not "as on main" as Not tested says. Suggest one set's images there:fg_sets = 1when the mode is FIFO and the refresh is 0.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).
0c552c977109e3e11330Beanstalk test farm
Commit
09e3e11· tier untrusted · approved by nobody yet · dashboardA member of
BigBeanscan review this commit and comment@Beanstalkto test it.Rebased onto main
e8e92f97(#1362 has merged), and two fixes from my review on top, as the person I work for asked:create_swapchainkeeps both #1362's image cap and this PR'sset_too_big; the check's text follows. Checked: in every file this PR changes, its own changes are line for line what they were at0c552c97.09e3e113: under FIFO with the display's refresh unknown (display_refresh_mhz()0), one set's images, as on main. My inline point atvk_main.cpp:1075.09e3e113, for the latency question: the firstvk: frame interpolation:line now ends "the game's frames presented N ms after the game handed them over".RX_VK_FG_TIMELINE=0runs main's path in the same build, so one build gives both sides. It's the present call, not the screen: under FIFO main's path queues more in the swapchain, so it reads main's side low, never this PR's high.Not built or run here: the checks run on CI. The latency A/B itself still has to be run in the game.
Verdict: Request changes. The smoothness gain under V-Sync On stands, and the farm shows no frame-rate or frame-time cost on RTX 40, AMD Windows or Linux. But the latency question that blocked it is still open. Under V-Sync Auto with DLSS Frame Gen, the most common frame generation setup, nobody has shown that the game's frame reaches the screen no later than on main. The new log line makes that one game run; it hasn't been run yet.
What it does for players: under V-Sync On and Auto, a fixed multiplier's frames go out at their own times, a refresh apart at least, instead of queueing in FIFO. At the display's limit the game holds 55 fps instead of 51-53, and frame times on screen go from sd 2.3 to 0.7 ms (RTX 5090). It makes the code better if the latency holds.
Reviewed: a re-review:
09e3e113against my review's0c552c97. The branch is rebased onto maine8e92f97with the PR's four commits only. In every file it changes, its own changes match0c552c97line for line. Plus09e3e113, which I wrote:create_swapchain'sfifo_unpaced, and the log's handover-to-present mean indisplay_main. I also read the Test Farm's four reports for0c552c97. Nothing built or run (a code review).09e3e113is my own code, so another reviewer should read it before this merges.Fixed in this review: the rebase (described in the comment above), and
09e3e113: one set's images under FIFO when the display's refresh is unknown, which was my inline point. Pushed to the PR's branch.Checked and fine:
create_swapchainkeeps #1362's cap besideset_too_big.display_refresh_mhzis declared beforecreate_swapchain, and both platforms answer it (Windows from the window's monitor, Linux from the host window).game[k]on the timeline,k == madeon main's path), after a present that was shown, and its reset list grew with the struct.0c552c97:67efc4d, before #1362, and took the picture while the camera turned. The pictures aren't published, so I can't tell a different moment from a wrong picture.Blocking
The latency A/B, in the game. One build is enough now:
RX_VK_FG_TIMELINE=0, interleaved;vk: frame interpolation:line, "the game's frames presented N ms after the game handed them over", median per run.It reads main's side low (FIFO's queue behind the present isn't counted), so this PR at or below
=0settles it. Above=0needs the screen (Reflex's PC latency) to decide. Put the numbers in Measurements and Risks. A run on this PR's RTX 5090 is ideal; an RTX 3090 with FSR 3.1 FG would do too. I can run that here if you want.A fixed-refresh display with V-Sync On (already in Must be tested). A frame that misses a vblank is no longer covered by FIFO's queue there, so it holds the merge. A TV or a Steam Deck (Linux, gamescope) would cover it.
Suggestions
Testing:
0c552c97: no crash, no frame-time or fps cost; screenshots inconclusive.09e3e113or the rebased head. CI will run the checks.Overlaps and merge order: #1362 is merged; this PR is now on its own.
WIP: fix(vk): frame generation's fixed multipliers on the game's timeline under V-Sync On (FIFO) tooto fix(vk): frame generation's fixed multipliers on the game's timeline under V-Sync On (FIFO) tooVerdict: comment, after the merge. I found no bug in the diff, and I read
09e3e113(HumanBean's own commit, which he asked another reader for): it is fine. This merged at 21:48 UTC while his request for changes (review 1695) was open, so what it asks for is owed: the latency A/B in the game and a fixed-refresh display with V-Sync On. Ranked by risk, what is left on current main:What it does for players. With V-Sync On (and Auto with DLSS Frame Gen), a fixed multiplier's frames now go out at their own times on the game's timeline, but never sooner than a refresh after the frame before. On main they came back to back and the last frame of a set stayed on the screen until the next set. The author's numbers (RTX 5090, 165 Hz G-Sync): frame time on screen sd 2.3 ms to 0.7 ms at V-Sync On 3x, and the game at the refresh limit from 51-53 to 55 fps.
What I checked and found fine (line numbers on current main)
fixed_on_timeline(vk_framegen.cpp:225) lost its FIFO argument and both callers follow (on_line, 633; the test).fifo_slot(235): no slot or no refresh gives the due time; otherwise the later of the due time and a refresh after the last slot; a slot more than half a refresh behind starts again from now. I broke it two ways (below) and the new test fails each.display_main(783-820): the slot is taken before the wait, moves to the real present time when that is over 1 ms late (816), is given back whenpresent_commitsays nothing was shown (820), and the late count is against the slot (786-791). The mode is read at each present (788), so a chain made again for another mode is honoured.create_swapchain(vk_main.cpp:1084-1100):set_too_biguses the surface's own spare count, so 7x and 8x on an NVIDIA surface keep one set's images;fifo_unpaced(09e3e113) answers the inline point of review 1681: with no known refresh, one set's images as main. The slot count is stored with the chain (1100).vsync_now(vk_replay.cpp:5667): the multiplier and DLSS-G terms stay under 16, so they cannot collide with the V-Sync term (a multiple of 16); the new term is a multiple of 256, 1280 or more, so no two states share a key.display_mainandcreate_swapchainis gated on FIFO (s.refresh && dev.swap_mode == FIFO,set_too_big,fifo_unpaced), so V-Sync Off and mailbox behave as main with #1362 does. The exceptions are adisplay_refresh_mhz()call per set (cached for a second) and the longer first log line.RX_VK_FG_TIMELINE=0gives main's path in every mode: no timeline, one set's images, 3 slots. So one build gives both sides of an A/B.test_doc_anchorsfollows the new anchor.1. The latency A/B (owed). What I add on how to measure it
late_nsafter it is handed over:fixed_dues(before, now, made, pace_lead(game_ns, made) + extra, ...)(vk_framegen.cpp:1439). With the numbers of the author's own run A (3x, 54.4 fps so an 18.4 ms frame, lead 2/3 of it = 12.3 ms,late_ns14.9 ms from the log) that is about 27 ms after hand-over, before FIFO's own wait. What main's figure is, only the A/B can say.DisplayLatency, which HumanBean explained cannot see this. So run both: under the limit (for example 3x with a cap so that 3 x fps is well under the refresh, the game's rate equal on both sides) and at it.RX_VK_FG_TIMELINE=0against default, alternating, at least three runs a side, medians and the worst run shown, and say whetherRX_VK_PRESENT_QUEUEis on (#1476 would change it):(a) the new number in the first
frame interpolation:line (vk_framegen.cpp:672, 831), on any GPU. It stops at the present call, so it reads main's side low under FIFO (as the comment says): a PR value at or under main's is a pass, a higher one is not a verdict;(b) for a higher one,
RX_VK_REFLEX_LOG=1on NVIDIA: its line already prints "simulation start to present end" next to "to the GPU's end" (vk_reflex.cpp:31, 130). #1362's answer quoted only the second; the first is the one this hold moves, because the Reflex present markers bracket the real present call (vk_reflex.cpp:277 and 287), whichpresent_commitmakes late (vk_replay.cpp:5925-5934). Neither number includes the time the frame then waits for its refresh, so a screen figure is still needed if (b) is higher;(c) HumanBean's "Reflex's PC latency" may not exist in PresentMon: the author said on #1362 that PresentMon 2.3 wrote no PC-latency column in those runs. Say so if it is not there.
RX_VK_FG_TIMELINE=0is the stopgap until then.2. A fixed-refresh display with V-Sync On (owed). The model in the test (tests/test_framegen_fixed_pace.py:155) is a VRR display: each present is shown at its present or a refresh after the one before, with no vblank grid. On a fixed refresh, main's queue is never empty, so its frames land on consecutive vblanks. This PR leaves the queue empty on purpose and spaces presents by the reported refresh, so a present's place against the vblank is not controlled, and near the edge a little jitter turns a one-refresh gap into two. The PR says as much ("frames round to whole refreshes there") but has no number. What the run should show, main against PR on the same display at 2x and 3x: the share of frames shown for 1, 2 and 3 refreshes (PresentMon
DisplayedTimein refresh units), the longest gap, and the latency figures above. Windows reports whole Hz and the code guesses the /1.001 rate for a value one under a multiple of 6 (vk_main.cpp:1946-1948), so also say the display's exact refresh.3. The Test Farm's red, and what it points to. HumanBean's review 1695 already says the main things: the picture rule fails everywhere, the V-Sync Off cells are #1362's, the baseline (main
67efc4d3) is before #1362, the camera turns while the picture is taken, and the second Linux PC is broken. I agree, and add what I found in the four reports (all on0c552c9, whose changes are line for line those of the merged head except09e3e113; each had V-Sync On and V-Sync Off cells at 2x and 3x):screenshot.max_diff, limit 0.1) fails in all 12 cells on all four reports (0.28 to 0.87), and every report's "main against itself" field is empty, so there is no noise floor. The PR changes no draw or shader code (vk_framegen.cpp's display thread, vk_main.cpp's image count, vk_replay.cpp's slot count and remake key, texts and docs), so only which frame is captured can differ: [INFERENCE] from the diff, not tested. The same rule failed on #1362 (Linux AMD, 3x 0.52 and 4x 0.02; HumanBean asked there, and I found no answer before it merged) and on #1458 (the swapchain image waited for on the CPU; field-pacing, Windows AMD). To settle it: one main against main pair (orRX_VK_FG_TIMELINE=0against default on one build) on one machine. If identical code is over 0.1, the threshold is the problem.09e3e11is "untrusted, approved by nobody"), so the next run has to be asked for with a BigBeans member's approval, with the twoframe interpolation:lines of the V-Sync On cells attached (the reports show only the end of the log), and with the picture taken with the camera still (HumanBean's suggestion) and a noise floor.4. Main's Guide screenshots check is one issue redder. It passes on main
93bc8a7f, fails onc392df3a(5 issues from #1388 and #426) and on the merge with 6:gpu/vk/menu_i18n.hchanged since the reviewed revision ofsettings-graphics.png(vk_menu.cppandvk_internal.hare changed here too but were already flagged). On current main it is 10 issues with other merges since. The picture shows the Quality preset row and the Frame generation and frame rate cap rows, not the Frame pacing hint this PR rewords (that row is on the Debug tab, as the note on #1466 says for #1362's wording), so it should be retained with a new reviewed revision and a dated note, as #1466 did. The PR was merged with that status red.5. Smaller follow-ups
vk: swapchain WxH, N imageslog lines (main and this PR) at 2x and 3x and the idle VRAM from the driver into Risks. On a card under 8 GB that cost is not nothing (HumanBean raised the same on #1362).present_ahead_wanted(pace || line, ...)ands.timed = s.auto_timed || s.line(vk_framegen.cpp:700-704) put those sets on the timeline instead, so "At an even interval" no longer holds for fixed multipliers. The hint and the docs say so, but every measured row is Frame pacing Off. One A/B at V-Sync On, 3x, Frame pacing On would show whether anyone who turned it on to calm FIFO loses something.late_ns(the GPU delay added to every frame's time) stale at the refresh limit? It is fed only from a set whose first copy went as it came (vk_framegen.cpp:770,as_cameat 649), and the new test's own comment says that at the refresh limit under FIFO "every set is left out and the delay keeps its value" (tests/test_framegen_fixed_pace.py:313-315). Then the value from before the limit stays, and one learned during a hitch (it can go up to a whole game frame) stays until the game leaves the limit. The slots hide it while the limit holds, but it comes back in the first frames under the limit. Could the author paste the D3 log's two lines and say whatlate_nswas before and after the limit was reached? The latency runs in 1 would show it too.vsync_nowremakes the swapchain in modes where nothing changes (vk_replay.cpp:5667-5668). The termopts.framegen * 256is added for any multiplier above 4x in every present mode, but only FIFO uses it (set_too_big). Stepping 5x to 6x in the menu at V-Sync Off or mailbox remakes the chain to an identical one. Suggestion:544229a2. The Must-be-tested list is the record of what is owed (latency A/B, fixed-refresh display, Intel, an RTX 40 card on a screen, AMD on a screen), so it is worth fixing even now.Conflict with main: it was mechanical, and is gone.
0c552c97against main (93bc8a7f) conflicted in 13 files (the measure skill, README, design.md, development.md, menu_i18n.h, switches.def, vk_framegen.cpp, vk_internal.h, vk_main.cpp, vk_menu.cpp, vk_replay.cpp, test_doc_anchors.py, test_framegen_fixed_pace.py) because #1362 was squashed into main while the PR carried its commits. HumanBean's force-push at 21:22 rebased the PR ontoe8e92f97(main with #1362). I compared the net changed lines of the old head over #1362's head (e3420742) with the new head's four earlier commits over their base: 437 changed lines each, and no line differs in either direction; the file lists are the same. The new head adds only09e3e113.git merge-treeof the new head with main93bc8a7f: no conflicts, and it merged. The API's "mergeable: false" was the WIP title.Overlaps. Before the merge I took the 332 other open pull requests, 178 of which share a file name (README.md and docs/development.md are in most), fetched their heads and merged each against a scratch commit of main plus this head: none conflicted where it did not already conflict with main. I also searched their diffs for
display_main,create_swapchain,present_slots_for,swap_spare,vsync_now,fg_setsandFG_TIMELINE: matches were #1390 (merged since), #1354, #1339 and #1334 (their diffs show the removal ofpresent_ahead_wanted's environment parameter, which main already has from #1309), #1105 (callers ofcreate_swapchain), #1043 (a drain condition onswap_spare, behindRX_VK_PRESENT_THREAD, off by default), #966 (one thread-start line) and #424 (a comment). I read those matching lines only, not the whole PRs; I saw no interaction. #1476 came after the scan (above).What I ran
display_main,framegen_record,create_swapchain,display_refresh_mhz,present_commit, the Reflex log); compared the squash with the head (same 453 changed lines); checked that the FIFO functions are unchanged on current main.python -I -B tests/test_framegen_fixed_pace.py, on the head: passes. The same test file against main's source (an archive of main93bc8a7f): fails at its first source check (display_main'sfixed_on_timeline(set->by_time, timeline_off)line). So red on main, green on the head.fifo_slotin a copy of the head: always returning the due time failsfifo_slot(10 * ms, 10 * ms, hz240, 10 * ms) == 10 * ms + hz240; moving the "slot far behind" limit to 1000 refreshes failsfifo_slot(10 * ms, 10 * ms, hz240, 30 * ms) == 30 * ms. (My first mutant died of an unused-variable compile error, which proves nothing; I redid it keeping the variables used.) The text checks pindisplay_main's slot code; its loop is modelled by a copy in the test (run_fifo), so a change of the real loop that keeps the pinned text is not caught.--exact --strict, on the head and on main93bc8a7f: 11 passed, 0 failed on both.python -I -B tests/run_all.py --jobs 6 --strict) on the head (before the merge) and on main93bc8a7f, in two worktrees, compared by failing name: head 674 passed, 38 failed, 17 skipped; main 675 passed, 38 failed, 17 skipped. The same 38 test files fail on both (this Linux PC's own failures, not looked into one by one); the one test more on main istests/test_target_retention.pyfrom #1462, which the head's older base lacks (it passes on main). So the head adds no failure. I did not rerun it on the merge or on current main.e8e92f97(the changed drivers: test_framegen_fixed_pace.py, test_doc_anchors.py, test_present_semaphores.py): test_framegen_fixed_pace.py compiles for the Windows target (PASS, syntax only; execution not tested). test_present_semaphores.py FAILS the checker's CRT policy: its fixture includes longshot_env.h without defining_CRT_SECURE_NO_WARNINGSfirst. That is not this change: the PR's only edit in that file is theoptsstruct line, and the include is there in the base (read from the diff, not run on the base). Windows execution of both fixtures: not tested.scripts/check_guide_screenshots.py --review-sources) on the head, on main93bc8a7f, onc392df3a, on the merge and on current main: passes only on93bc8a7f; 7, 5, 6 and 10 issues on the others (the head's 7 include files from #1362 and #1464 that its older base had not retained yet).What I did not run: the game, any GPU, PresentMon or Reflex logs (this PC runs the game windowless: no swapchain, no FIFO, no vblank), Windows execution of the new C++ fixture (the syntax check is not a Windows run, and it compiles against llvm-mingw's library, not Microsoft's), Linux or AMD or Intel runtime, a fixed-refresh display. So I cannot confirm or refute the author's screen numbers or the latency. The two things that would settle the top two items are the latency A/B and the fixed-refresh run, both on a real display.
Inline-comment candidates (the PR is merged, so fold them into one comment)
RX_VK_REFLEX_LOG=1) or a screen measurement. Please put both sides in Measurements, under the limit and at it, and say whether the present queue is on.late_nsis fed only here, and at the refresh limit the test's own comment says every set is left out. Can you show the D3 log's second line and whatlate_nswas before and after the limit was reached?dev.swap_mode == VK_PRESENT_MODE_FIFO_KHR.Picking up the outstanding Windows RTX 4070 displayed-cadence check. I’ll start with a same-build control pair, then compare the FIFO timeline switch on a fixed-refresh display where available, keeping base and generated frames separate and using display-confirmed timing.