WIP: fix(vk): frame generation's made frames at their own times with V-Sync Off #1362

Draft
pmwork-personal wants to merge 16 commits from pmwork-personal/Longshot:fix/fg-paced-without-vsync into main
Contributor

Type: fix · Risk: medium · Tested on: Windows 11, RTX 5090 (NVIDIA 621.24) · Needs: Windows with another NVIDIA card (RTX 40), AMD and Intel (FSR 3.1 FG and the built-in maker), a fixed-refresh display, Linux

Why

With V-Sync Off, frame generation made its frames but the screen hardly showed them: DLSS Frame Gen at 3x looked like the
game's own frame rate. The display thread presented each set (the made frames and the game's frame) as soon as it came,
all within a millisecond, and a swapchain that does not wait for a refresh shows each present at once, so the game's
frame covered the made ones. The FPS counter and the log said the frames were made and shown on time. V-Sync On looked
smooth only because FIFO shows one present a refresh (which also holds the game at the refresh rate over the multiplier).

This PR shows each frame of a set at its own time. One more wait, after the present call, is not this PR's to turn on
for everyone (the present queue, Hookshot issue 1161 from before the fork): the hint and docs say how players turn it on.

See #315 (its "the log shows frames being presented on time, but the motion doesn't match": the log counts the present
calls, and both waits are after them).

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 Off, Frame generation 3x (Frame generation by: Auto, DLSS FG), Frame pacing Off (its
default), NVIDIA Reflex On + Boost, NVIDIA DLAA
Steps: in play, turn the camera at an even speed. For numbers, run PresentMon on longshot.exe meanwhile.
Expected: the motion of three times the game's frame rate: each frame on the screen about a third of a game frame
(~6 ms at ~55 fps).
Actual: the motion of the game's frame rate: on main 66% of the frames are on the screen under 2 ms, and about 55 a
second for 2 ms or more (the game's own).

What changed

Where the swapchain does not wait for a refresh (V-Sync Off: immediate; mailbox), a fixed multiplier's set is now shown on
the game's timeline: each frame at its place between the game's two frames, after the GPU's delay, its copies submitted
ahead together, whatever Frame pacing says. The next set is taken while the current one is shown, so its copies reach the
GPU when it comes. FIFO (V-Sync On, and Auto with DLSS Frame Gen) keeps its path. RX_VK_FG_TIMELINE=0 gives the old
behaviour back.

  • pacing, gpu/vk/vk_framegen.cpp: fixed_dues (frame k of a set at (k + 1) / (made + 1) of the way from the game frame
    before, so each frame moves as far as its time), pace_lead (made / (made + 1) of a game frame: no frame shown before its
    game frame came), pace_delay (the GPU's delay: up by half, down by a sixteenth, at most a game frame),
    fixed_on_timeline (immediate and mailbox only, RX_VK_FG_TIMELINE).
  • the display loop, display_main: take / copy_up_to (a set's copies presented ahead, as many as swapchain images
    are free), take_early (the next set taken during the current set's waits, not within 3 ms of a present), the first
    copy's fence polled every 2 ms of a wait (ready_at), and the delay fed back only from sets whose first copy went within
    3 ms of their coming (as_came, set in copy once that copy's present_image returned): a set late for other reasons
    raised the delay by its own lateness before.
  • frame slots, gpu/vk/vk_replay.cpp present_slots_for: where the swapchain is made for two sets, a slot per frame of
    both while frame generation runs (2 x the multiplier: 4, 6 and 8 at 2x, 3x and 4x, at most kPresentSlotsMax, 8,
    vk_internal.h; ImGui keeps one more vertex buffer, vk_imgui.cpp). Each present waits for the copy last made in its
    slot: with 3 slots a set's 4th copy waited for its own first copy, and with a slot per frame of one set the next set's
    copy k for the shown set's copy k, each behind the game's work queued before it. The count is the swapchain's
    (dev.swap_slots, set by create_swapchain); FIFO, RX_VK_FG_TIMELINE=0 and frame generation off keep 3.
  • swapchain images, gpu/vk/vk_main.cpp create_swapchain: two sets' spare images where the swapchain does not wait for
    a refresh (an NVIDIA surface: 6 at 2x, its most, 8, from 3x up); FIFO and RX_VK_FG_TIMELINE=0 one set's.
  • log: the frame interpolation: line has a <2 ms bucket and counts a frame late against its own time; a second line
    gives the sets on the timeline, taken early, left out of the delay, and the copies' end and the delay.
  • menu and docs: the Frame pacing hint (Off and On, 13 languages) and the README say a fixed multiplier keeps its own
    times at V-Sync Off and that RX_VK_PRESENT_QUEUE=1 makes them the most even; docs/development.md has
    RX_VK_FG_TIMELINE and RX_VK_PRESENT_QUEUE; gpu/vk/switches.def has RX_VK_FG_TIMELINE (#1300).
  • for agents and the next change here: docs/design.md section 13 writes the five rules down (pacing measured on the
    screen; sets on the game's timeline; the delay only from sets taken as they came; a slot per frame of both sets and two
    sets' images; a present waits on its queue), with // doc: anchors on the functions that keep them (held by
    tests/test_doc_anchors.py). The measure skill measures a change to how frames are shown with PresentMon's on-screen
    times, and counts which engine made the frames in the measured stretch only.
  • tests: tests/test_framegen_fixed_pace.py (new) runs the real timing functions through a model of the display loop:
    game frames 15.5 to 22 ms apart, a 60 ms frame, a GPU slower than a frame, 4x with 6 spare images (the delay settles at
    14.6 ms, as with images to spare; before the image fix it ran to 17.9 of the 18.5 ms game frame), and checks the slot
    counts and where they come from; tests/test_present_semaphores.py checks that a retired swapchain counts 3 slots.

Measurements

Verdict: it helps a lot. At 3x the frames on the screen under 2 ms went from 66% to 33% and the frames with their own
time on the screen from 55 to 111 a second; at 4x from 70% to 45%, and 60 to 111 a second. With RX_VK_PRESENT_QUEUE=1
too, 0.0 to 0.1% at both: every frame on the screen for its own time (3x: 4.8 to 7.2 ms, p10 to p90). The tester,
watching the runs: main "not super smooth", this PR with the present queue "this is the best"; a 14-minute play test of
the PR's first version with the present queue: "a lot better now".

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, V-Sync
Off, NVIDIA DLAA, Frame generation 3x and 4x by Auto (DLSS FG), Frame pacing Off, Reflex On + Boost, frame rate cap
Uncapped
Method: main at this PR's merge base and this PR, each a dev_packs.py pack on one base (nightly-396 @ 7887c497), a
warm-up run of each, then main, this PR and this PR with RX_VK_PRESENT_QUEUE=1 in turn, two rounds at 3x and two at
4x (2026-11-17 00:48 to 01:01). The control bridge turns the camera with the right stick (60 degrees a second) for 30 s,
the pad, keys and mouse left out; PresentMon 2.3.0 on longshot.exe for 26 s of it. Each run's number is shown (two
runs: their median is their mean). In play DLSS-G made 600 of each 600 presents in every run (DLSS Frame Gen (NGX): of the last 600 presents 600 made by DLSS-G; the title screen before it, the built-in maker). A first A/B of this PR's
earlier version (fac3ec4c, before the review fixes) on nightly-396 gave the same numbers within a point.
The head, 311d9d8d, adds the second review's two fixes after a44ef0fb, not run on the screen: the slot count is stored
after the old chain's retire_swapchain (each run above made one swapchain, logged, so it ran with the head's count),
and as_came leaves the first copy's own submit out (between the first A/B's version, timed at take, and a44ef0fb's,
timed after the copy, which gave the same numbers within a point).
How to reproduce: a save at a spot to turn the camera; the settings above; PresentMon 2.x --process_name longshot.exe --timed 26 --terminate_after_timed --output_file <csv> while the camera turns; from the CSV the share of DisplayedTime
under 2 ms. Rows: docs/tested/2026-11-17-fg-pacing-pmwork-personal-*.md (and the first A/B's,
docs/tested/2026-11-16-fg-pacing-pmwork-personal-*.md).

Before: main @ 544229a2 After: this PR @ a44ef0fb After, RX_VK_PRESENT_QUEUE=1: this PR @ a44ef0fb
3x: presents a second 159.5 / 160.3 164.1 / 164.8 169.5 / 170.5
3x: frames on the screen under 2 ms 65.8% / 65.7% 32.7% / 32.5% 0.0% / 0.1%
3x: frames on the screen 2 ms or more, a second 54.6 / 55.0 110.5 / 111.2 169.4 / 170.3
3x: DisplayedTime median (p10 to p90), stdev, ms 1.22 (1.08-16.54), 7.27 / 1.20 (0.58-16.64), 7.28 5.28 (1.05-13.31), 4.76 / 5.50 (1.03-13.11), 4.67 5.73 (4.82-7.18), 1.18 / 5.72 (4.90-7.04), 1.03
4x: presents a second 197.1 / 195.9 203.1 / 203.4 212.8 / 212.4
4x: frames on the screen under 2 ms 69.9% / 69.6% 45.3% / 45.6% 0.0% / 0.1%
4x: frames on the screen 2 ms or more, a second 59.4 / 59.6 111.1 / 110.6 212.7 / 212.3
4x: DisplayedTime median (p10 to p90), stdev, ms 1.21 (0.63-16.39), 6.66 / 1.21 (0.57-16.59), 6.75 2.64 (1.02-12.27), 4.48 / 2.63 (1.02-12.19), 4.46 4.62 (3.87-5.59), 0.84 / 4.61 (3.90-5.59), 0.87

Where the rest waits (from the same CSVs: the call at CPUStartTime + CPUBusy, the screen at CPUStartTime +
DisplayLatency): main presents a set's frames 0.37 ms apart (median), so they reach the screen together. This PR calls
them at their times (3x: 5.96 ms apart, p10 5.12, p90 7.11; 4x: 4.82 ms), but each present then waits 3 to 12 ms on the
replay's queue behind the game's next frame and reaches the screen the moment that GPU work ends (0.01 ms after it):
every one of the 1610 pairs under 2 ms apart on the screen at 3x was called ~5.9 ms apart. With the present queue the
call reaches the screen 1.1 to 1.8 ms later (p10 to p90), and the screen's gaps are the calls' (3x: 5.71 ms, 4x: 4.61).

a7m3-1.presentmon.csv   4140 presents in 25.9 s = 159.5/s; shown under 1 ms 397 (9.6%), under 2 ms 2723 (65.8%); shown 2 ms or more: 54.6/s   DisplayedTime ms: median 1.22, p10 1.08, p90 16.54, stdev 7.27
a7p3-1.presentmon.csv   4260 presents in 26.0 s = 164.1/s; shown under 1 ms 366 (8.6%), under 2 ms 1393 (32.7%); shown 2 ms or more: 110.5/s   DisplayedTime ms: median 5.28, p10 1.05, p90 13.31, stdev 4.76
a7q3-1.presentmon.csv   4403 presents in 26.0 s = 169.5/s; shown under 1 ms 1 (0.0%), under 2 ms 2 (0.0%); shown 2 ms or more: 169.4/s   DisplayedTime ms: median 5.73, p10 4.82, p90 7.18, stdev 1.18
a7m3-2.presentmon.csv   4162 presents in 26.0 s = 160.3/s; shown under 1 ms 594 (14.3%), under 2 ms 2734 (65.7%); shown 2 ms or more: 55.0/s   DisplayedTime ms: median 1.20, p10 0.58, p90 16.64, stdev 7.28
a7p3-2.presentmon.csv   4278 presents in 26.0 s = 164.8/s; shown under 1 ms 367 (8.6%), under 2 ms 1390 (32.5%); shown 2 ms or more: 111.2/s   DisplayedTime ms: median 5.50, p10 1.03, p90 13.11, stdev 4.67
a7q3-2.presentmon.csv   4426 presents in 26.0 s = 170.5/s; shown under 1 ms 2 (0.0%), under 2 ms 4 (0.1%); shown 2 ms or more: 170.3/s   DisplayedTime ms: median 5.72, p10 4.90, p90 7.04, stdev 1.03
a7m4-1.presentmon.csv   5116 presents in 26.0 s = 197.1/s; shown under 1 ms 551 (10.8%), under 2 ms 3574 (69.9%); shown 2 ms or more: 59.4/s   DisplayedTime ms: median 1.21, p10 0.63, p90 16.39, stdev 6.66
a7p4-1.presentmon.csv   5268 presents in 25.9 s = 203.1/s; shown under 1 ms 482 (9.1%), under 2 ms 2385 (45.3%); shown 2 ms or more: 111.1/s   DisplayedTime ms: median 2.64, p10 1.02, p90 12.27, stdev 4.48
a7q4-1.presentmon.csv   5527 presents in 26.0 s = 212.8/s; shown under 1 ms 0 (0.0%), under 2 ms 1 (0.0%); shown 2 ms or more: 212.7/s   DisplayedTime ms: median 4.62, p10 3.87, p90 5.59, stdev 0.84
a7m4-2.presentmon.csv   5088 presents in 26.0 s = 195.9/s; shown under 1 ms 789 (15.5%), under 2 ms 3540 (69.6%); shown 2 ms or more: 59.6/s   DisplayedTime ms: median 1.21, p10 0.57, p90 16.59, stdev 6.75
a7p4-2.presentmon.csv   5284 presents in 26.0 s = 203.4/s; shown under 1 ms 466 (8.8%), under 2 ms 2410 (45.6%); shown 2 ms or more: 110.6/s   DisplayedTime ms: median 2.63, p10 1.02, p90 12.19, stdev 4.46
a7q4-2.presentmon.csv   5518 presents in 26.0 s = 212.4/s; shown under 1 ms 0 (0.0%), under 2 ms 3 (0.1%); shown 2 ms or more: 212.3/s   DisplayedTime ms: median 4.61, p10 3.90, p90 5.59, stdev 0.87

(this PR, 3x, a7p3-2's log: the present calls on time, the screen above not)
vk: frame interpolation: 826 frames shown on time, 0 late (over 2 ms); shown apart: <2 ms 0, 2-7 743, 7-9 71, 9-12 12, 12-17 0, 17-25 0, over 25 0
vk: frame interpolation: 275 sets on the game's timeline (the swapchain does not wait for a refresh), 263 taken early, 98 with copies later than they came (left out of the GPU's delay); first copies done 12.7 ms after their game frame (seen within 2 ms), 14.5 ms past their lead for the GPU (RX_VK_FG_TIMELINE=0: off)
(this PR with the present queue, 4x, a7q4-1's log)
vk: presents on a queue of their own, of compute family 2 (RX_VK_PRESENT_QUEUE=0: off)
vk: frame interpolation: 1064 frames shown on time, 0 late (over 2 ms); shown apart: <2 ms 0, 2-7 1058, 7-9 6, 9-12 0, 12-17 0, 17-25 0, over 25 0

Flags and settings

One new switch, RX_VK_FG_TIMELINE (a kill switch, on as it ships); RX_VK_PRESENT_QUEUE is unchanged and now documented.
No menu row or ini key changes; the Frame pacing row's hint is longer.

Flag What it is Before this PR After this PR Effect Helps / doesn't help / untested Recommendation
RX_VK_FG_TIMELINE env, renderer did not exist on (unset); =0 off on: a fixed multiplier's sets on the game's timeline at V-Sync Off and mailbox, two sets' images and slots; =0: as main helps: the table (RTX 5090, 3x and 4x); untested elsewhere on for everyone; =0 for an A/B or if a GPU shows a regression
RX_VK_PRESENT_QUEUE env, renderer off off =1: presents on a compute family's queue of their own helps here: the table's last column; Hookshot issue 1161 (black screen, RTX 4090, NVIDIA 621) off by default until that fault is found; players with V-Sync Off frame generation may set it (the hint says so)

Testing

Tested:

  • Game-free: python -I -B tests/run_all.py on a44ef0fb (Windows, llvm-mingw): 627 passed, 48 failed, 47 skipped. All 48
    fail on main on this PC too (an export of 544229a2): they call g++ or setenv, read Linux paths, or check main's own
    sources (test_switch_table: RX_VK_PGO_FILE; test_vk_swapchain_compat: the Linux start, after its
    create_swapchain checks pass; test_tested_configurations: 2026-11-16-shadow-map-slots-gumminaomi-on.md). 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.

    The 48 of the last run, 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 switch_table target_image_pool
    tested_configurations upscaler_round_trip upscaler_rows vcore_escape vk_occlusion_queries vk_swapchain_compat walk_key

  • A cold review of the whole diff by a second agent: no high-severity finding (no image lost or presented twice, no
    acquire past the swapchain's limit, no hang); its four findings (the slots across two sets, FIFO's slot count, the count
    following the menu live, as_came before the first copy) are fixed in a44ef0fb, and measured above. Its read of those
    fixes found that retire_swapchain set the new count back to 3 on every chain made over an old one, and that
    as_came counted the copy's own submit: both fixed in 311d9d8d, with test checks that fail on the old order.

  • In the game, Windows 11, RTX 5090, NVIDIA 621.24, 5120x2160 at 165 Hz with G-Sync: the runs above (V-Sync Off, 3x and
    4x, DLSS-G making the frames in play), the first A/B of fac3ec4c, and a 14-minute play test of fac3ec4c at 3x with
    RX_VK_PRESENT_QUEUE=1 by the tester (no present error, no device lost; DLSS-G made 597 to 600 of each 600 presents
    in play).

Not tested: the head's two fixes on the screen (311d9d8d, above), and a swapchain made again in play (a multiplier or
V-Sync change, a resize) with this PR; V-Sync On (FIFO) and Auto, whose path is unchanged (and now keeps main's 3 slots); 2x and 5x to 8x (5x and
6x are presented ahead where the surface holds them, 7x and 8x not); a mailbox swapchain; FSR 3.1 frame generation; AMD,
Intel and RTX 40 cards; a fixed-refresh display; Linux. Latency was not measured: the game's frame is shown later than on
main, after the made frames before it (made / (made + 1) of a game frame: ~12 ms at 3x and ~55 fps), as interpolation's
pacing needs.

Must be tested:

  • Windows, an RTX 40 card (DLSS FG at 3x and 4x): V-Sync Off, turn the camera, expecting even motion and the log's
    second frame interpolation: line with most sets taken early (Test Farm: @Beanstalk windows nvidia, V-Sync Off with
    DLSS frame generation at 3x and 4x, the camera turning; the frame interpolation log lines and PresentMon's on-screen
    times against main)
  • AMD on Windows and on Linux (FSR 3.1 FG and the built-in maker): the same, expecting the same lines and no new stutter
    (Test Farm: @Beanstalk amd windows and amd linux, the same)
  • Intel (the built-in maker): the same (Test Farm: @Beanstalk intel, the same)
  • A fixed-refresh display without G-Sync or FreeSync, V-Sync Off at 3x: tearing as before, the motion even (by hand: a
    tester with such a display)

Risks

What could break: frame generation at V-Sync Off and mailbox with a fixed multiplier: each frame now waits for its
time, so the game's frame is shown made / (made + 1) of a game frame later than on main (~12 ms at 3x and ~55 fps); the
swapchain asks for two sets' images at V-Sync Off (an NVIDIA surface: 8 from 3x up, was 5 at 3x and 6 at 4x; 6 at 2x,
was 4: 88 to 133 MB more at 5120x2160); present_image keeps up to 8 frame slots there while frame generation runs, so up
to 8 presents can be on the GPU at once (3 before).

Turning it off: RX_VK_FG_TIMELINE=0 (the sets, the swapchain's images and the frame slots as on main).

Compatibility: Nothing changes: no save, longshot_options.ini key, cache or vk ABI change.

Issues

See #315

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).
  • Measurements has a verdict, or one line saying why there is nothing to measure.
  • Testing names what was tested, what wasn't, and what must still be tested, where and how.
  • Rebased on current main.
  • 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.
  • 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.
  • Docs updated.

🤖 Generated with Claude Code

**Type:** fix · **Risk:** medium · **Tested on:** Windows 11, RTX 5090 (NVIDIA 621.24) · **Needs:** Windows with another NVIDIA card (RTX 40), AMD and Intel (FSR 3.1 FG and the built-in maker), a fixed-refresh display, Linux ## Why With V-Sync Off, frame generation made its frames but the screen hardly showed them: DLSS Frame Gen at 3x looked like the game's own frame rate. The display thread presented each set (the made frames and the game's frame) as soon as it came, all within a millisecond, and a swapchain that does not wait for a refresh shows each present at once, so the game's frame covered the made ones. The FPS counter and the log said the frames were made and shown on time. V-Sync On looked smooth only because FIFO shows one present a refresh (which also holds the game at the refresh rate over the multiplier). This PR shows each frame of a set at its own time. One more wait, after the present call, is not this PR's to turn on for everyone (the present queue, Hookshot issue 1161 from before the fork): the hint and docs say how players turn it on. See #315 (its "the log shows frames being presented on time, but the motion doesn't match": the log counts the present calls, and both waits are after them). ## 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 Off, Frame generation 3x (Frame generation by: Auto, DLSS FG), Frame pacing Off (its default), NVIDIA Reflex On + Boost, NVIDIA DLAA **Steps:** in play, turn the camera at an even speed. For numbers, run PresentMon on `longshot.exe` meanwhile. **Expected:** the motion of three times the game's frame rate: each frame on the screen about a third of a game frame (~6 ms at ~55 fps). **Actual:** the motion of the game's frame rate: on main 66% of the frames are on the screen under 2 ms, and about 55 a second for 2 ms or more (the game's own). ## What changed Where the swapchain does not wait for a refresh (V-Sync Off: immediate; mailbox), a fixed multiplier's set is now shown on the game's timeline: each frame at its place between the game's two frames, after the GPU's delay, its copies submitted ahead together, whatever Frame pacing says. The next set is taken while the current one is shown, so its copies reach the GPU when it comes. FIFO (V-Sync On, and Auto with DLSS Frame Gen) keeps its path. `RX_VK_FG_TIMELINE=0` gives the old behaviour back. - pacing, `gpu/vk/vk_framegen.cpp`: `fixed_dues` (frame k of a set at (k + 1) / (made + 1) of the way from the game frame before, so each frame moves as far as its time), `pace_lead` (made / (made + 1) of a game frame: no frame shown before its game frame came), `pace_delay` (the GPU's delay: up by half, down by a sixteenth, at most a game frame), `fixed_on_timeline` (immediate and mailbox only, `RX_VK_FG_TIMELINE`). - the display loop, `display_main`: `take` / `copy_up_to` (a set's copies presented ahead, as many as swapchain images are free), `take_early` (the next set taken during the current set's waits, not within 3 ms of a present), the first copy's fence polled every 2 ms of a wait (`ready_at`), and the delay fed back only from sets whose first copy went within 3 ms of their coming (`as_came`, set in `copy` once that copy's `present_image` returned): a set late for other reasons raised the delay by its own lateness before. - frame slots, `gpu/vk/vk_replay.cpp` `present_slots_for`: where the swapchain is made for two sets, a slot per frame of both while frame generation runs (2 x the multiplier: 4, 6 and 8 at 2x, 3x and 4x, at most `kPresentSlotsMax`, 8, `vk_internal.h`; ImGui keeps one more vertex buffer, `vk_imgui.cpp`). Each present waits for the copy last made in its slot: with 3 slots a set's 4th copy waited for its own first copy, and with a slot per frame of one set the next set's copy k for the shown set's copy k, each behind the game's work queued before it. The count is the swapchain's (`dev.swap_slots`, set by `create_swapchain`); FIFO, `RX_VK_FG_TIMELINE=0` and frame generation off keep 3. - swapchain images, `gpu/vk/vk_main.cpp` `create_swapchain`: two sets' spare images where the swapchain does not wait for a refresh (an NVIDIA surface: 6 at 2x, its most, 8, from 3x up); FIFO and `RX_VK_FG_TIMELINE=0` one set's. - log: the `frame interpolation:` line has a `<2 ms` bucket and counts a frame late against its own time; a second line gives the sets on the timeline, taken early, left out of the delay, and the copies' end and the delay. - menu and docs: the Frame pacing hint (Off and On, 13 languages) and the README say a fixed multiplier keeps its own times at V-Sync Off and that `RX_VK_PRESENT_QUEUE=1` makes them the most even; `docs/development.md` has `RX_VK_FG_TIMELINE` and `RX_VK_PRESENT_QUEUE`; `gpu/vk/switches.def` has `RX_VK_FG_TIMELINE` (#1300). - for agents and the next change here: `docs/design.md` section 13 writes the five rules down (pacing measured on the screen; sets on the game's timeline; the delay only from sets taken as they came; a slot per frame of both sets and two sets' images; a present waits on its queue), with `// doc:` anchors on the functions that keep them (held by `tests/test_doc_anchors.py`). The measure skill measures a change to how frames are shown with PresentMon's on-screen times, and counts which engine made the frames in the measured stretch only. - tests: `tests/test_framegen_fixed_pace.py` (new) runs the real timing functions through a model of the display loop: game frames 15.5 to 22 ms apart, a 60 ms frame, a GPU slower than a frame, 4x with 6 spare images (the delay settles at 14.6 ms, as with images to spare; before the image fix it ran to 17.9 of the 18.5 ms game frame), and checks the slot counts and where they come from; `tests/test_present_semaphores.py` checks that a retired swapchain counts 3 slots. ## Measurements **Verdict:** it helps a lot. At 3x the frames on the screen under 2 ms went from 66% to 33% and the frames with their own time on the screen from 55 to 111 a second; at 4x from 70% to 45%, and 60 to 111 a second. With `RX_VK_PRESENT_QUEUE=1` too, 0.0 to 0.1% at both: every frame on the screen for its own time (3x: 4.8 to 7.2 ms, p10 to p90). The tester, watching the runs: main "not super smooth", this PR with the present queue "this is the best"; a 14-minute play test of the PR's first version with the present queue: "a lot better now". 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, V-Sync Off, NVIDIA DLAA, Frame generation 3x and 4x by Auto (DLSS FG), Frame pacing Off, Reflex On + Boost, frame rate cap Uncapped Method: main at this PR's merge base and this PR, each a `dev_packs.py` pack on one base (nightly-396 @ 7887c497), a warm-up run of each, then main, this PR and this PR with `RX_VK_PRESENT_QUEUE=1` in turn, two rounds at 3x and two at 4x (2026-11-17 00:48 to 01:01). The control bridge turns the camera with the right stick (60 degrees a second) for 30 s, the pad, keys and mouse left out; PresentMon 2.3.0 on `longshot.exe` for 26 s of it. Each run's number is shown (two runs: their median is their mean). In play DLSS-G made 600 of each 600 presents in every run (`DLSS Frame Gen (NGX): of the last 600 presents 600 made by DLSS-G`; the title screen before it, the built-in maker). A first A/B of this PR's earlier version (fac3ec4c, before the review fixes) on nightly-396 gave the same numbers within a point. The head, 311d9d8d, adds the second review's two fixes after a44ef0fb, not run on the screen: the slot count is stored after the old chain's `retire_swapchain` (each run above made one swapchain, logged, so it ran with the head's count), and `as_came` leaves the first copy's own submit out (between the first A/B's version, timed at take, and a44ef0fb's, timed after the copy, which gave the same numbers within a point). How to reproduce: a save at a spot to turn the camera; the settings above; PresentMon 2.x `--process_name longshot.exe --timed 26 --terminate_after_timed --output_file <csv>` while the camera turns; from the CSV the share of `DisplayedTime` under 2 ms. Rows: `docs/tested/2026-11-17-fg-pacing-pmwork-personal-*.md` (and the first A/B's, `docs/tested/2026-11-16-fg-pacing-pmwork-personal-*.md`). | | Before: main @ 544229a2 | After: this PR @ a44ef0fb | After, `RX_VK_PRESENT_QUEUE=1`: this PR @ a44ef0fb | |---|---|---|---| | 3x: presents a second | 159.5 / 160.3 | 164.1 / 164.8 | 169.5 / 170.5 | | 3x: frames on the screen under 2 ms | 65.8% / 65.7% | 32.7% / 32.5% | 0.0% / 0.1% | | 3x: frames on the screen 2 ms or more, a second | 54.6 / 55.0 | 110.5 / 111.2 | 169.4 / 170.3 | | 3x: `DisplayedTime` median (p10 to p90), stdev, ms | 1.22 (1.08-16.54), 7.27 / 1.20 (0.58-16.64), 7.28 | 5.28 (1.05-13.31), 4.76 / 5.50 (1.03-13.11), 4.67 | 5.73 (4.82-7.18), 1.18 / 5.72 (4.90-7.04), 1.03 | | 4x: presents a second | 197.1 / 195.9 | 203.1 / 203.4 | 212.8 / 212.4 | | 4x: frames on the screen under 2 ms | 69.9% / 69.6% | 45.3% / 45.6% | 0.0% / 0.1% | | 4x: frames on the screen 2 ms or more, a second | 59.4 / 59.6 | 111.1 / 110.6 | 212.7 / 212.3 | | 4x: `DisplayedTime` median (p10 to p90), stdev, ms | 1.21 (0.63-16.39), 6.66 / 1.21 (0.57-16.59), 6.75 | 2.64 (1.02-12.27), 4.48 / 2.63 (1.02-12.19), 4.46 | 4.62 (3.87-5.59), 0.84 / 4.61 (3.90-5.59), 0.87 | Where the rest waits (from the same CSVs: the call at `CPUStartTime` + `CPUBusy`, the screen at `CPUStartTime` + `DisplayLatency`): main presents a set's frames 0.37 ms apart (median), so they reach the screen together. This PR calls them at their times (3x: 5.96 ms apart, p10 5.12, p90 7.11; 4x: 4.82 ms), but each present then waits 3 to 12 ms on the replay's queue behind the game's next frame and reaches the screen the moment that GPU work ends (0.01 ms after it): every one of the 1610 pairs under 2 ms apart on the screen at 3x was called ~5.9 ms apart. With the present queue the call reaches the screen 1.1 to 1.8 ms later (p10 to p90), and the screen's gaps are the calls' (3x: 5.71 ms, 4x: 4.61). ``` a7m3-1.presentmon.csv 4140 presents in 25.9 s = 159.5/s; shown under 1 ms 397 (9.6%), under 2 ms 2723 (65.8%); shown 2 ms or more: 54.6/s DisplayedTime ms: median 1.22, p10 1.08, p90 16.54, stdev 7.27 a7p3-1.presentmon.csv 4260 presents in 26.0 s = 164.1/s; shown under 1 ms 366 (8.6%), under 2 ms 1393 (32.7%); shown 2 ms or more: 110.5/s DisplayedTime ms: median 5.28, p10 1.05, p90 13.31, stdev 4.76 a7q3-1.presentmon.csv 4403 presents in 26.0 s = 169.5/s; shown under 1 ms 1 (0.0%), under 2 ms 2 (0.0%); shown 2 ms or more: 169.4/s DisplayedTime ms: median 5.73, p10 4.82, p90 7.18, stdev 1.18 a7m3-2.presentmon.csv 4162 presents in 26.0 s = 160.3/s; shown under 1 ms 594 (14.3%), under 2 ms 2734 (65.7%); shown 2 ms or more: 55.0/s DisplayedTime ms: median 1.20, p10 0.58, p90 16.64, stdev 7.28 a7p3-2.presentmon.csv 4278 presents in 26.0 s = 164.8/s; shown under 1 ms 367 (8.6%), under 2 ms 1390 (32.5%); shown 2 ms or more: 111.2/s DisplayedTime ms: median 5.50, p10 1.03, p90 13.11, stdev 4.67 a7q3-2.presentmon.csv 4426 presents in 26.0 s = 170.5/s; shown under 1 ms 2 (0.0%), under 2 ms 4 (0.1%); shown 2 ms or more: 170.3/s DisplayedTime ms: median 5.72, p10 4.90, p90 7.04, stdev 1.03 a7m4-1.presentmon.csv 5116 presents in 26.0 s = 197.1/s; shown under 1 ms 551 (10.8%), under 2 ms 3574 (69.9%); shown 2 ms or more: 59.4/s DisplayedTime ms: median 1.21, p10 0.63, p90 16.39, stdev 6.66 a7p4-1.presentmon.csv 5268 presents in 25.9 s = 203.1/s; shown under 1 ms 482 (9.1%), under 2 ms 2385 (45.3%); shown 2 ms or more: 111.1/s DisplayedTime ms: median 2.64, p10 1.02, p90 12.27, stdev 4.48 a7q4-1.presentmon.csv 5527 presents in 26.0 s = 212.8/s; shown under 1 ms 0 (0.0%), under 2 ms 1 (0.0%); shown 2 ms or more: 212.7/s DisplayedTime ms: median 4.62, p10 3.87, p90 5.59, stdev 0.84 a7m4-2.presentmon.csv 5088 presents in 26.0 s = 195.9/s; shown under 1 ms 789 (15.5%), under 2 ms 3540 (69.6%); shown 2 ms or more: 59.6/s DisplayedTime ms: median 1.21, p10 0.57, p90 16.59, stdev 6.75 a7p4-2.presentmon.csv 5284 presents in 26.0 s = 203.4/s; shown under 1 ms 466 (8.8%), under 2 ms 2410 (45.6%); shown 2 ms or more: 110.6/s DisplayedTime ms: median 2.63, p10 1.02, p90 12.19, stdev 4.46 a7q4-2.presentmon.csv 5518 presents in 26.0 s = 212.4/s; shown under 1 ms 0 (0.0%), under 2 ms 3 (0.1%); shown 2 ms or more: 212.3/s DisplayedTime ms: median 4.61, p10 3.90, p90 5.59, stdev 0.87 (this PR, 3x, a7p3-2's log: the present calls on time, the screen above not) vk: frame interpolation: 826 frames shown on time, 0 late (over 2 ms); shown apart: <2 ms 0, 2-7 743, 7-9 71, 9-12 12, 12-17 0, 17-25 0, over 25 0 vk: frame interpolation: 275 sets on the game's timeline (the swapchain does not wait for a refresh), 263 taken early, 98 with copies later than they came (left out of the GPU's delay); first copies done 12.7 ms after their game frame (seen within 2 ms), 14.5 ms past their lead for the GPU (RX_VK_FG_TIMELINE=0: off) (this PR with the present queue, 4x, a7q4-1's log) vk: presents on a queue of their own, of compute family 2 (RX_VK_PRESENT_QUEUE=0: off) vk: frame interpolation: 1064 frames shown on time, 0 late (over 2 ms); shown apart: <2 ms 0, 2-7 1058, 7-9 6, 9-12 0, 12-17 0, 17-25 0, over 25 0 ``` ### Flags and settings One new switch, `RX_VK_FG_TIMELINE` (a kill switch, on as it ships); `RX_VK_PRESENT_QUEUE` is unchanged and now documented. No menu row or ini key changes; the Frame pacing row's hint is longer. | Flag | What it is | Before this PR | After this PR | Effect | Helps / doesn't help / untested | Recommendation | |---|---|---|---|---|---|---| | `RX_VK_FG_TIMELINE` | env, renderer | did not exist | on (unset); `=0` off | on: a fixed multiplier's sets on the game's timeline at V-Sync Off and mailbox, two sets' images and slots; `=0`: as main | helps: the table (RTX 5090, 3x and 4x); untested elsewhere | on for everyone; `=0` for an A/B or if a GPU shows a regression | | `RX_VK_PRESENT_QUEUE` | env, renderer | off | off | `=1`: presents on a compute family's queue of their own | helps here: the table's last column; Hookshot issue 1161 (black screen, RTX 4090, NVIDIA 621) | off by default until that fault is found; players with V-Sync Off frame generation may set it (the hint says so) | ## Testing **Tested:** - Game-free: `python -I -B tests/run_all.py` on a44ef0fb (Windows, llvm-mingw): 627 passed, 48 failed, 47 skipped. All 48 fail on main on this PC too (an export of 544229a2): they call `g++` or `setenv`, read Linux paths, or check main's own sources (`test_switch_table`: `RX_VK_PGO_FILE`; `test_vk_swapchain_compat`: the Linux start, after its `create_swapchain` checks pass; `test_tested_configurations`: `2026-11-16-shadow-map-slots-gumminaomi-on.md`). 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. <details><summary>The 48 of the last run, each failing on main too</summary> 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 switch_table target_image_pool tested_configurations upscaler_round_trip upscaler_rows vcore_escape vk_occlusion_queries vk_swapchain_compat walk_key </details> - A cold review of the whole diff by a second agent: no high-severity finding (no image lost or presented twice, no acquire past the swapchain's limit, no hang); its four findings (the slots across two sets, FIFO's slot count, the count following the menu live, `as_came` before the first copy) are fixed in a44ef0fb, and measured above. Its read of those fixes found that `retire_swapchain` set the new count back to 3 on every chain made over an old one, and that `as_came` counted the copy's own submit: both fixed in 311d9d8d, with test checks that fail on the old order. - In the game, Windows 11, RTX 5090, NVIDIA 621.24, 5120x2160 at 165 Hz with G-Sync: the runs above (V-Sync Off, 3x and 4x, DLSS-G making the frames in play), the first A/B of fac3ec4c, and a 14-minute play test of fac3ec4c at 3x with `RX_VK_PRESENT_QUEUE=1` by the tester (no present error, no device lost; DLSS-G made 597 to 600 of each 600 presents in play). **Not tested:** the head's two fixes on the screen (311d9d8d, above), and a swapchain made again in play (a multiplier or V-Sync change, a resize) with this PR; V-Sync On (FIFO) and Auto, whose path is unchanged (and now keeps main's 3 slots); 2x and 5x to 8x (5x and 6x are presented ahead where the surface holds them, 7x and 8x not); a mailbox swapchain; FSR 3.1 frame generation; AMD, Intel and RTX 40 cards; a fixed-refresh display; Linux. Latency was not measured: the game's frame is shown later than on main, after the made frames before it (made / (made + 1) of a game frame: ~12 ms at 3x and ~55 fps), as interpolation's pacing needs. **Must be tested:** - Windows, an RTX 40 card (DLSS FG at 3x and 4x): V-Sync Off, turn the camera, expecting even motion and the log's second `frame interpolation:` line with most sets taken early (Test Farm: @Beanstalk windows nvidia, V-Sync Off with DLSS frame generation at 3x and 4x, the camera turning; the frame interpolation log lines and PresentMon's on-screen times against main) - AMD on Windows and on Linux (FSR 3.1 FG and the built-in maker): the same, expecting the same lines and no new stutter (Test Farm: @Beanstalk amd windows and amd linux, the same) - Intel (the built-in maker): the same (Test Farm: @Beanstalk intel, the same) - A fixed-refresh display without G-Sync or FreeSync, V-Sync Off at 3x: tearing as before, the motion even (by hand: a tester with such a display) ## Risks **What could break:** frame generation at V-Sync Off and mailbox with a fixed multiplier: each frame now waits for its time, so the game's frame is shown made / (made + 1) of a game frame later than on main (~12 ms at 3x and ~55 fps); the swapchain asks for two sets' images at V-Sync Off (an NVIDIA surface: 8 from 3x up, was 5 at 3x and 6 at 4x; 6 at 2x, was 4: 88 to 133 MB more at 5120x2160); present_image keeps up to 8 frame slots there while frame generation runs, so up to 8 presents can be on the GPU at once (3 before). **Turning it off:** `RX_VK_FG_TIMELINE=0` (the sets, the swapchain's images and the frame slots as on main). **Compatibility:** Nothing changes: no save, `longshot_options.ini` key, cache or vk ABI change. ## Issues See #315 ## 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] Measurements has a verdict, or one line saying why there is nothing to measure. - [x] Testing names what was tested, what wasn't, and what must still be tested, where and how. - [x] Rebased on current `main`. - [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. - [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] Docs updated. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
With V-Sync Off and Frame pacing Off (its default), the display thread presented a fixed multiplier's set as it came:
its two made frames and the game's within a millisecond of each other. An immediate swapchain shows each present at
once, so the screen showed the game's frame and hardly the made ones: DLSS Frame Gen 3x at V-Sync Off looked like the
game's own frame rate (RTX 5090, 5120x2160 at 165 Hz with G-Sync, DLAA, Reflex On + Boost). The display thread's own
counts in a player's log: per set, two presents under 7 ms after the one before and one 17-25 ms after. V-Sync On
looked smooth only because FIFO shows one present a refresh, which also holds the game at 165 / 3 = 55 fps.

Now every fixed multiplier's set with a made frame gets its times on the game's own timeline (fixed_dues): frame k at its
place between the two game frames, (k + 1) / (made + 1) of the way, so each frame moves as far as its time. Where the
swapchain does not wait for a refresh (immediate, mailbox: fixed_on_timeline), display_main shows the set at those times
and presents it ahead (its copies at once, before the game's next frame), whatever Frame pacing says. FIFO (V-Sync On,
and Auto with DLSS Frame Gen) is as before.

The set's first frame is due when its game frame came (pace_lead: made / (made + 1) of a game frame), plus the GPU's
delay (pace_delay): the set's frames are done with the game frame's GPU work, and shown at times that did not wait for
it they would go out at once. The delay follows what each set needed (its own delay and its lateness, a millisecond to
spare: no double count for the sets in flight), up by half, down by a sixteenth, at most two game frames.

The frame interpolation log line has a <2 ms bucket (presents the screen hardly tells apart), and a second line gives
the sets on the timeline and the GPU's delay. RX_VK_FG_TIMELINE=0 turns it off (as before), for an A/B.

This takes the idea of an unpushed fix of 2026-11-13 (the times on the game's timeline, a delay that follows the GPU),
which needed Frame pacing On. The Bloodborne PC port's NGX frame generation path paces the same way (a slot per made
frame from the source frame's cadence and the GPU's ready time); its default Streamline path leaves the pacing to
Streamline, which Longshot does not use.

tests/test_framegen_fixed_pace.py is new; test_present_source_crop cuts fixed_dues and pace_lead too.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Review of the change before: a set's copies went to the GPU only once the set before had been shown, behind the parts of
the game's next frame submitted meanwhile. Its first copy was done that much later, the set came past its times, and
the GPU's delay (pace_delay) grew with that lateness, which made the next set's copies later still: with the GPU busy
(12.4 ms of GPU work a frame at ~55 fps, DLAA at 5120x2160) it could run up to its limit.

- display_main takes the next set as soon as it comes, while the set before waits for its frames' times (take_early),
  where the swapchain holds the images of both: that set's frames still to present and all of the next one's. Not within
  3 ms of the shown set's next frame. vk_main.cpp asks for two sets' images where the swapchain does not wait for a
  refresh (an NVIDIA surface: 6 at 2x, its most, 8, at 3x and 4x); FIFO keeps one set's.
- The GPU's delay is fed back only from a set whose first copy was waited for (presented ahead: 5x to 8x and
  RX_VK_PRESENT_AHEAD=0 are not), and not from a set after a long game frame (over 1.5 smoothed ones).
- At most a game frame (was two): three sets in all, one shown, the next taken, one being made.
- The second log line also gives the sets taken early and when their first copies were done after their game frame.
- docs/development.md has RX_VK_FG_TIMELINE.

tests/test_framegen_fixed_pace.py runs the real timing functions through a model of the display loop: game frames 15.5
to 22 ms apart, frames done 12 ms after their game frame, a 60 ms frame, a GPU slower than a frame, then one with room.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
take_early looked for the next set only right before each frame's wait. At 2x the next set comes while the set's game
frame waits, so none was taken early (0 of 300 sets in a run; at 3x 236 to 276 of 300 were). The wait now goes in steps
of 2 ms at most while the next set may still be taken early (one shown, presented ahead, on the timeline), and looks
for it at each step; otherwise it waits as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A set taken early (its copies to the GPU when it came) was fed back from when the display thread came to it, after the set
before it was shown: often well after its copies were done, so the GPU's delay (pace_delay) and the log's "copies done"
counted the display thread's own wait (review). Now its first copy's fence is read every 2 ms of the wait for the shown
set's frames (no wait: a zero timeout), and the time it was seen done (ready_at) is used; a set not taken early still
counts from when its fence wait ended. The log's second line says the copies' end is seen within 2 ms.

tests/test_framegen_fixed_pace.py: the display loop's model feeds back each set's own copy end; a check that a set taken
early has its copy end seen.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The review of this branch found two faults at 4x and up at V-Sync Off.

present_image kept 3 frame slots and waits for the copy last made in a slot. A set of 4 frames presented ahead reused its
own first copy's slot for its 4th copy, so taking the next set early held the display thread until the GPU had done that
set's first copy (and the game's work queued before it): the frames of the set still shown went out late, together. Now
present_slots_for gives a fixed multiplier its own count of slots from 4x up while frame generation runs (at most
kPresentSlotsMax, 8; ImGui's vertex buffers one more). Off, Auto, 2x and 3x keep 3, which is also how many presents can
be on the GPU at once.

Two sets of 4 need 8 spare swapchain images; an NVIDIA surface has 6. The next set waited until all of its copies fit,
which happened only after the set before showed 2 frames once the GPU's delay passed 3/4 of a game frame. Its copies then
went later, behind more of the game's work, and fed back, the delay rose with its own lateness (the 4x logs: 20-22 ms, a
whole game frame). Now the next set's copies go for the images free, its first ones at once, the rest as the presents of
the set before give images back; and only a set whose first copy went within 3 ms of its coming (as_came) feeds the delay
back. The test's display-loop model shows both: as before the 4x delay runs to 17.9 ms of the 18.5 ms game frame, now it
settles at 14.6 ms, as with images to spare, and no frame is late.

Also from the review: a set is on the game's timeline only where it is presented ahead (one shown a frame at a time had
no first copy to learn the GPU's delay from: RX_VK_PRESENT_AHEAD=0, 7x and 8x on 6 spare images keep the old flow);
RX_VK_FG_TIMELINE=0 now also asks for the swapchain images as before; a frame on the timeline counts as late against its
own time in the log; the log counts the sets left out of the delay. 5x and 6x are presented ahead where the surface
holds them (the 4x image count: 6 spare on NVIDIA), and 7x and 8x are not.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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]>
With V-Sync Off and a fixed multiplier the pacer now calls each present at its own time (3x: median 5.9 ms apart), but
on the replay's queue a present waits there behind the game's next frame (3-12 ms) and some made frames still reach the
screen together: on an RTX 5090 at 165 Hz, 32% (3x) and 45% (4x) were shown under 2 ms. With the presents on a queue of
their own, 0.1% at both, the time on screen within 4.9-6.9 ms at 3x (p10-p90). The present queue stays opt-in (issue
1161: an RTX 4090 on NVIDIA's 621 driver got a black screen), so the hint (13 languages), the README and
development.md's switch table say how to turn it on.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Thirteen rows of 2026-11-16: main and the fix at 3x and 4x, two interleaved 30 s camera pans each at one spot, then the
fix with RX_VK_PRESENT_QUEUE=1 (two pans each at 3x and 4x, and a 14-minute play test), PresentMon's on-screen times.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
#1300 put every RX_ switch the renderer reads in gpu/vk/switches.def; the timeline switch this branch adds was read in
vk_framegen.cpp and vk_main.cpp without a row. A kill switch, as RX_VK_PRESENT_AHEAD: on for every PC, =0 the old way.
(tests/test_switch_table.py still names RX_VK_PGO_FILE, as it does on main: its reader is nx2/build.py's -DPGO_ENV.)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Many changes here are made with agents, and each fault this branch fixes looked like frame generation off while the FPS
counter and the display thread's counts said all was well. docs/design.md section 13 writes the five rules down: pacing
is measured on the screen (the log counts present calls), a fixed multiplier's set on the game's timeline where the
swapchain does not wait for a refresh, the GPU's delay fed back only from sets taken as they came, a frame slot per frame
and two sets' spare images for a set presented ahead, and a present waits on the queue it is made on (RX_VK_PRESENT_QUEUE,
issue 1161). `// doc:` anchors above fixed_on_timeline, pace_delay, present_ahead_wanted, present_slots_for and
create_swapchain's image count point there, and tests/test_doc_anchors.py keeps them (REQUIRED).

The measure skill: a change to how frames are shown is measured with frame generation on, with PresentMon's on-screen
times (DisplayedTime under 2 ms, its spread; DisplayLatency against the call and the GPU work for where a frame waited),
and the run says which engine made the frames (DLSS-G makes only the frames with DLSS inputs).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The rows of 2026-11-16, design.md section 13 and the measure skill said DLSS-G made about a third of the presents at the
spot and the built-in maker the rest. That was a count over each whole log: the title screen, file select and load draw
no scene, so DLSS-G has no inputs there and the built-in maker makes those frames (`without new inputs`). In play DLSS-G
made 600 of each 600 presents in every run (597 to 600 in the play test). The rows now give the counts after the load,
and the skill says to count the measured stretch only.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A cold review of this branch found:

- At 4x present_image had 4 slots and two sets in flight, so the next set's copy k (taken early, during the shown set's
  waits) waited in the slot of the shown set's copy k. A copy of the shown set that went late (in parts, as images
  freed) sat behind the game's next frame on the GPU, and the display thread waited for it while that set's frames were
  due: the stall 70dae803 removed inside one set, across two. present_slots_for now gives a slot per frame of both sets
  (2 x the multiplier: 4, 6 and 8 at 2x, 3x and 4x, at most kPresentSlotsMax) where the swapchain is made for two sets.
- The slot count did not look at the present mode or RX_VK_FG_TIMELINE: FIFO and RX_VK_FG_TIMELINE=0 got 4 to 8 slots
  from 4x up, main's 3. They keep 3 now.
- The count followed the menu live, so sets in flight after a multiplier change were copied with another count. It is
  the swapchain's now (dev.swap_slots, set by create_swapchain for the sets it makes the chain for); the chain is made
  again when the multiplier, V-Sync or RX_VK_FG_TIMELINE change. Off (and frame generation not running): 3.
- as_came was set when a set was taken, before its first copy's present_image, which can wait for a slot, an image or
  a new swapchain: a set whose first copy went late could still feed the GPU's delay. It is set once that copy returned.
- The frame log's pictures in slots past a count that went down were read only once it came back up, late and out of
  order; they are dropped (RX_VK_FRAMELOG only, at most 5).

docs/design.md rule 4 says it; tests/test_framegen_fixed_pace.py checks the new counts and where they come from,
test_present_semaphores.py that a retired chain counts 3 slots, test_doc_anchors.py the anchor's new line.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Twelve rows of 2026-11-17 on an RTX 5090: main at the branch's merge base and the branch at a44ef0fb, both packs on
nightly-396, and the branch with RX_VK_PRESENT_QUEUE=1, in turn, two rounds each at 3x and 4x, 30 s camera pans at one
spot, PresentMon's on-screen times; the tester's words where he watched.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
fix(vk): the frame slots survive a remade swapchain; as_came does not count the copy's own submit
Some checks failed
PR description / Description follows the template (pull_request_target) Successful in 4s
Website / Website on Cloudflare (pull_request_target) Has been skipped
CI / Conventional Commit title (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been cancelled
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been cancelled
CI / Workflow lint (actionlint) (pull_request) Has been cancelled
Guide screenshots / Guide images and local UI source review (pull_request) Has been cancelled
Third-party parts / As their notes say (pull_request) Has been cancelled
Third-party parts / The same as upstream (pull_request) Has been cancelled
Website / Website on Cloudflare (pull_request) Has been cancelled
311d9d8d5b
The review of a44ef0fb:

- create_swapchain stored dev.swap_slots before vkCreateSwapchainKHR, and retire_swapchain, called right after it for
  the old chain, set 3 again: every chain made over an old one (a multiplier change, V-Sync, HDR, Reflex, a resize,
  out of date) ran with 3 slots, at 4x worse than before a44ef0fb. Only a chain with none before (the first, or after a
  lost surface) kept its count, as each run of the 2026-11-17 A/B did (one swapchain each, logged). The count is now
  computed beside fg_sets and stored with the chain, after the retire. test_present_semaphores checks that a chain made
  over an old one keeps it; test_framegen_fixed_pace that the store follows retire_swapchain().
- as_came, timed after the first copy's present_image, also counted that copy's own submit (the game's held submits, the
  queue's lock): a CPU that takes 3 ms to submit would leave every set out of the GPU's delay, which then stays at 0 and
  shows the frames together again (on the RTX 5090, 36% of the sets left out against 27%). Now: taken within 3 ms of its
  coming, and its first copy not held in present_image over 3 ms (a wait for a slot, an image or a new swapchain).

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

Tested in game: Windows 11 Pro build 26300, RTX 5090, NVIDIA 621.24, 5120x2160 at 165 Hz with G-Sync, Hyrule Market (child): V-Sync Off, DLSS frame generation at 3x and 4x (DLSS-G made every frame in play), Reflex On + Boost, DLAA. Scripted 30 s camera turns with PresentMon, main @ 544229a2 against this PR @ a44ef0fb as packs on one base, interleaved, two runs each: frames on the screen under 2 ms 66% -> 33% at 3x and 70% -> 45% at 4x; with RX_VK_PRESENT_QUEUE=1 as well, 0.0-0.1% at both (on screen 4.8-7.2 ms apart at 3x). The tester watched the runs: main 'not super smooth', this PR with the present queue 'this is the best'; a 14-minute play test of an earlier version (fac3ec4c) with the present queue: 'a lot better now', no present error or device lost. The head 311d9d8d (the second review's fixes) builds and passes the checks; it was not run on the screen (the description says why the numbers hold).

Tested in game: Windows 11 Pro build 26300, RTX 5090, NVIDIA 621.24, 5120x2160 at 165 Hz with G-Sync, Hyrule Market (child): V-Sync Off, DLSS frame generation at 3x and 4x (DLSS-G made every frame in play), Reflex On + Boost, DLAA. Scripted 30 s camera turns with PresentMon, main @ 544229a2 against this PR @ a44ef0fb as packs on one base, interleaved, two runs each: frames on the screen under 2 ms 66% -> 33% at 3x and 70% -> 45% at 4x; with RX_VK_PRESENT_QUEUE=1 as well, 0.0-0.1% at both (on screen 4.8-7.2 ms apart at 3x). The tester watched the runs: main 'not super smooth', this PR with the present queue 'this is the best'; a 14-minute play test of an earlier version (fac3ec4c) with the present queue: 'a lot better now', no present error or device lost. The head 311d9d8d (the second review's fixes) builds and passes the checks; it was not run on the screen (the description says why the numbers hold).
docs: the present queue's black screen was Hookshot issue 1161, before the fork
Some checks are pending
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Blocked by required conditions
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Blocked by required conditions
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
Guide screenshots / Guide images and local UI source review (pull_request) Blocked by required conditions
Third-party parts / As their notes say (pull_request) Blocked by required conditions
Third-party parts / The same as upstream (pull_request) Blocked by required conditions
Website / Website on Cloudflare (pull_request) Blocked by required conditions
PR description / Description follows the template (pull_request_target) Successful in 4s
beanstalk/approval waiting for a BigBean's 👍 on the request
Website / Website on Cloudflare (pull_request_target) Has been skipped
2e530f467b
Longshot's #1161 is another pull request; the README, design.md section 13 and development.md's RX_VK_PRESENT_QUEUE row
now say whose issue it was.

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

2e530f46 (docs only): the present queue's black screen is Hookshot issue 1161, from before the fork, not Longshot's #1161 (another pull request). The README, docs/design.md section 13, docs/development.md and this description now say so. No code change.

2e530f46 (docs only): the present queue's black screen is Hookshot issue 1161, from before the fork, not Longshot's #1161 (another pull request). The README, docs/design.md section 13, docs/development.md and this description now say so. No code change.
Author
Contributor

@Beanstalk please run this branch against main with V-Sync Off and Frame generation at 3x and at 4x, turning the camera in play for about 30 s each, on: Windows with an RTX 40 card (DLSS frame generation), AMD on Windows and on Linux (FSR 3.1 frame generation), and Intel (the built-in 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), and where PresentMon runs, the share of frames whose DisplayedTime is under 2 ms. Expected: far fewer frames under 2 ms than on main, 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.

@Beanstalk please run this branch against main with V-Sync Off and Frame generation at 3x and at 4x, turning the camera in play for about 30 s each, on: Windows with an RTX 40 card (DLSS frame generation), AMD on Windows and on Linux (FSR 3.1 frame generation), and Intel (the built-in 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), and where PresentMon runs, the share of frames whose DisplayedTime is under 2 ms. Expected: far fewer frames under 2 ms than on main, 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.
Member

@pmwork-personal only members of BigBeans can start the farm. One of them can approve this request by reacting 👍 to it or to this comment.

@pmwork-personal only members of `BigBeans` can start the farm. One of them can approve this request by reacting 👍 to it or to this comment.
Some checks are pending
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Blocked by required conditions
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Blocked by required conditions
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
Guide screenshots / Guide images and local UI source review (pull_request) Blocked by required conditions
Third-party parts / As their notes say (pull_request) Blocked by required conditions
Third-party parts / The same as upstream (pull_request) Blocked by required conditions
Website / Website on Cloudflare (pull_request) Blocked by required conditions
PR description / Description follows the template (pull_request_target) Successful in 4s
beanstalk/approval waiting for a BigBean's 👍 on the request
Website / Website on Cloudflare (pull_request_target) Has been skipped
This pull request has changes conflicting with the target branch.
  • docs/development.md
  • gpu/vk/vk_framegen.cpp
Some workflows are waiting to be reviewed.
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'fix/fg-paced-without-vsync:pmwork-personal-fix/fg-paced-without-vsync'
git switch 'pmwork-personal-fix/fg-paced-without-vsync'
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 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!1362
No description provided.