fix(vk): a fixed frame generation multiplier's sets follow the game's presents, not the render thread's hand-over #2184

Open
Jiro113 wants to merge 7 commits from Jiro113/Longshot:fix/fg-fixed-sets-game-clock into main
Contributor

Summary

With a fixed frame generation multiplier (2x to 8x) the generated frames are paced on the game's timeline (#1362, and under FIFO #1442), and that
timeline was the render thread's hand-over: framegen_record put each set at its own call, which comes after the main
thread's signal and the frame's replay. On an RTX 4090 (DLSS Frame Gen 2x at a 60 fps cap, FIFO, a 240 Hz VRR display)
the hand-over came about 4.4 ms after the game's present, its intervals' standard deviation 0.94 ms where the
presents' was 0.28 ms, and the game frames' intervals on screen followed the hand-overs' (r 0.81; against the presents',
r 0.23): the game's frames reached the screen as unevenly as the replay ran.

To see it on main: frame generation 2x at a 60 fps cap, V-Sync on, a VRR display; pan the camera in Hyrule Field and
record the presents with PresentMon: the game frames' intervals on screen have a standard deviation of 2.36 ms (six runs
here: 2.27 to 2.44), 28 % of them within 0.5 ms of 16.67 ms.

At the game's cap, the sets now follow the game's presents:

  • present takes the game's thread's time just after the FPS counter's stamp; the present's job carries it to both
    framegen_record calls (present_game_at);
  • fixed_clock puts the set at that present, the render thread's lag after the presents later, smoothed over 16
    sets: the presents give the intervals and the lag the phase, so the GPU's delay (pace_delay) takes up only how much
    the lag varies;
  • a present not known (not after the last one, after the hand-over, or over 100 ms before it) puts the set at its
    hand-over, the lag kept, and the next set is on the presents again; a hitch takes the lag again;
  • pace_feeds keeps a set that came after a long game frame from feeding the GPU's delay back, on either timeline.

Below its cap the game's thread waits in its present (for the main thread's signal, then for room in the render
thread's queue), so its presents carry the game's own work too, and sets on them would take in how both vary. enqueue
now takes how long the thread waited (game_wait); fixed_clock smooths it, and over 1 ms the sets are at their
hand-over as on main, under 0.5 ms on the presents again. At the cap here, 4 to 47 presents of 600 waited 0.1 to
0.2 ms.

RX_VK_FG_GAME_CLOCK=0 puts every set at its hand-over again (a kill switch, its row in gpu/vk/switches.def). Auto is
unchanged. The log's frame interpolation line counts the sets on the presents, their lag (mean, most), those at their
hand-over because the game ran below its cap, and the times the delay was fed back at a game frame.
docs/dev/reference/architecture.md (frame generation's rule 2) says when the presents hold.

This and #2183 (the replay's queue at global priority low) change some of the same files (vk_framegen.cpp/.h,
vk_replay.cpp, switches.def, the guide images' README) but merge with no conflict in either order; the "both" column
below is the two merged.

Possibly related: #1568 (frame generation 2x paced unevenly in
Jabu-Jabu's Belly, Linux, RTX 5080) and #2105 (stutter in busy
areas with frame generation, the game's frames down to 51 to 55 fps, RTX 4070 SUPER, Windows): below the cap this keeps
main's pacing when the replay has its own thread (Risks), so it should not change those drops (inferred). Neither
was tried there.

Read first: gpu/vk/vk_framegen.cpp (fixed_clock, pace_feeds, framegen_record), gpu/vk/vk_replay.cpp
(present, enqueue: present_game_at, game_wait).

Testing

Tested: Windows 11, RTX 4090, NVIDIA 621.24, a 240 Hz VRR display, full screen. Four runs of this PR and four with #2183 too, against six of main (Measurements). In every run
the log's line put each 5 s window's sets on the game's presents (a run's first set aside), but in the window of the
teleport's load, where 17 to 57 were at their hand-over with the game below its cap. Over the pan the hand-over came 4.0
to 5.3 ms after the game's present, as on main (Summary); a window of the pan:

vk: frame interpolation: 301 of the sets on the game's timeline placed on the game's presents, the others at their hand-over (0 with the game below its cap; RX_VK_FG_GAME_CLOCK=0: all); handed over 4.5 ms after their present (at most 8.7); the GPU's delay at its most, a game frame, 0 times

No device was lost. This PR's head, on main a2dc53859, ran again 30 s in a window (in the Market: the run's
teleport to Hyrule Field didn't take): past its first log window, each 5 s window put 299 to 301 sets on the game's
presents, 0 with the game below its cap; no device lost.

On earlier builds of this work, on the same PC (with the replay's queue at global priority low too, before the work was
split in three), below the cap under a GPU load, three runs of two series: past the first log windows every window put
its sets at their hand-over, and the game frames' calls followed the hand-overs (their intervals' slope against them
1.06, 1.07 and 1.04, r 0.99) as with RX_VK_FG_GAME_CLOCK=0 (1.05, 1.06, 1.04, and 1.11 in another scene, r 0.98 to
0.99), where without the last commit they followed the presents (1.03 and 1.06); at the cap, unloaded,
300 or 301 sets a log window on the presents.

mise run test (tests/run_all.py --strict) on this PC, Windows with llvm-mingw's clang++: 37 checks fail on main
a2dc53859 here (listed below), and the same 37 fail here, on the same lines, and no other (test_sampler_admission's
concurrent cases fail a varying number of times from run to run on main: 2 of 147 in its full run, 3 in this PR's). The renderer builds on Linux (RX_VK_ONLY=1).

tests/test_framegen_fixed_pace.py fails at each test commit for the bug's reason and passes at its fix (clang++): on
main's code, the screen moves with the hand-over (sd 1.04 ms); below the cap on the first fix's, the GPU's delay ran
to 11.4 ms on the presents against 7.2 at the hand-over. It passes here with g++ (11.4, Linux) and clang++; it catches
the 13 mutations of the last fix its commit lists, and the 3 a cold review tried on the first.
tests/present_source_crop_test.cpp follows framegen_record's new arguments; it passes on main and here, with
clang++ and with g++.

The 37 checks that fail on main a2dc53859 on this PC

nx2/test_import_windows, test_auto_handheld, test_bug_report, test_close_waits_for_save, test_compile_zero_byte, test_crash_dialog, test_damaged_rom_files, test_dev_ab, test_dev_build, test_dev_migrate, test_dev_packs, test_draw_stream_visibility, test_fs_save_commit, test_fsr3fi_hud_layer, test_fsr3fi_hudless_colour, test_fsr_uniform_ownership, test_game_menu_mouse_buttons, test_guest_copies, test_hold_toggle, test_input_movie, test_linux_preflight, test_lower_atomg_cas, test_menu_i18n, test_menu_keys, test_menu_slider_ends, test_pads_after_menu, test_perf_report, test_portable_builder_home, test_portable_builder_startup, test_recording_admission, test_sampler_admission, test_sdiv_overflow, test_sim_turf_pools, test_switch_table, test_tls_objects, test_vibration_menu, test_work_lock

Still to test:

  • AMD and Intel on Windows, FSR 3.1 or Built-in frame generation 2x at a 60 fps cap, V-Sync on, VRR: PresentMon over a
    camera pan, main against this PR, expecting the game frames at least as even on screen and the log's line counting
    the sets on the presents (Test Farm)
  • Linux (Mesa or NVIDIA), the same (Test Farm)
  • A GPU-bound scene below the cap on another PC: the log's line saying the sets were at their hand-over (by hand)

Measurements

Verdict: a fix for the game frames' pacing: at the cap their intervals on screen have a standard deviation of
1.49 ms (1.48 to 1.52, four runs) against 2.36 on main (2.27 to 2.44, six runs), and no longer follow the render
thread's hand-overs (r 0.35 against 0.81). The intervals between a game frame and a generated frame do not change
beyond the runs' spread (9.5 % within 0.5 ms of 8.33 ms against 10.0 %): where the generated frame lands is
#2183's part. With both, 30.4 % within 0.5 ms (20.1 to 35.4) against 29.8 % (26.5 to 33.6) for that PR alone,
the game frames' standard deviation 1.29 ms against 2.24, and a game frame's two halves (game to generated frame,
generated to game frame) within 0.2 ms of each other on average in three runs of four (+0.04 to +0.36 ms), against
none of four without this PR.

Setup: Windows 11, RTX 4090, NVIDIA 621.24, 240 Hz VRR display; DLSS Frame Gen 2x, 60 fps cap, FIFO, full screen,
Hyrule Field with the camera panning for 60 s after a teleport, PresentMon over the pan; every run with the same logging
switches on (HOS_PRESENT_TRACE, RX_VK_FG_LATENCY_LOG, RX_VK_REFLEX_LOG), RX_VK_PRESENT_QUEUE=0. Runs interleaved
with the other heads of this work, after one warm-up run each; the mean of each head's runs, (lowest-highest). One more
run of main was left out: PresentMon saw 5309 of its 13240 frames composed by the desktop (Composed: Flip), not
flipped straight to the display.

Before: main @ 8aa749834 After: this PR @ 38e673852 After: this PR and the queue's priority PR @ 451bc026c
Game frames on screen, their intervals' standard deviation, ms 2.36 (2.27-2.44) 1.49 (1.48-1.52) 1.29 (1.24-1.33)
Game frames on screen within 0.5 ms of 16.67 ms, % 28.4 (26.5-29.3) 37.4 (35.9-39.2) 57.5 (55.8-59.0)
Screen against the hand-overs (game frames' intervals): slope, r 2.04, 0.81 0.57, 0.35 0.36, 0.26
Intervals on screen within 0.5 ms of 8.33 ms, % 10.0 (7.3-12.3) 9.5 (6.8-12.2) 30.4 (20.1-35.4)
Intervals on screen, standard deviation, ms 2.43 (2.27-2.94) 2.50 (2.18-2.94) 1.44 (1.39-1.49)
Game frame to generated frame, minus generated to game frame, mean, ms -3.46 (-4.56 to -2.97) -3.85 (-4.78 to -3.16) +0.15 (+0.04 to +0.36)
Game frame on screen after its present, median, ms 22.68 (22.58-23.01) 22.89 (22.65-23.25) 21.17 (21.09-21.21)
Runs 6 4 4

Baseline: main 8aa749834 for both After columns. 38e673852 is this PR's commits (760888e08) and one diagnosis commit
on top, RX_VK_FG_MADE_SHIFT_US, left unset (it shifts nothing unset, and it is not in this PR); 451bc026c is the same
on top of #2183's commits.

Measured on main 8aa749834. This PR is now on main a2dc53859, its commits' changes the same (checked with
git range-diff) and, since, a line in the guide images' README. main's commits since change neither the presents'
timing, the queues nor the fixed sets' pacing; in the renderer, one keeps the HUD's colours with FSR 3.1 frame
generation in Native HDR (DLSS here), one starts the replay's threads through a guard that reports their C++
exceptions, one logs fewer memory imports, #2171 moves two includes, spells
rx_nvn.h's static assertions so g++ builds them, changes menu texts and mends present_source_crop_test.cpp's
hud_source stand-in, and #2174 keeps the simulated-turf lists at the game's own size in areas without turf, so that Hyrule
Field, the scene measured, no longer stalls 250 ms at a time on the way in: that changes frame times there, and both
sides above ran without it. #1722 adds a save.

Risks

  • Every fixed multiplier at its cap is paced on the game's presents now, on every GPU and maker; measured here on an
    RTX 4090 with DLSS only (Still to test). RX_VK_FG_GAME_CLOCK=0 puts it back as on main.
  • Below the cap the sets go back to the hand-over only once the thread's smoothed wait passes 1 ms: a burst of 11 or
    more waits of 2 ms or more at the cap puts them at their hand-over for about 22 presents.
  • Without the replay's own thread (async off) no wait is taken: the game's thread replays and presents itself there, and
    its sets stay on its presents.
  • fixed_clock's state is not reset when the device or the swapchain is made again, or frame generation is turned off
    and on; a hitch takes the lag again.
  • Nothing changes in longshot_options.ini, the saves or the caches. A revert is enough.

Checklist

Ready for review

  • One topic, on current main; the title is a Conventional Commit.
  • Tested on my own PC, in the game for a change the game runs, as Testing says.
  • mise run test passes (any failure that also fails on main is named).
  • Measured against main, or Measurements says why there is nothing to measure.
  • No game files, build output or hand-edited generated files; third_party/ untouched; nothing GPL-incompatible.

When it applies

  • A fix: a game-free test that fails on main and passes here.
  • A switch added or changed: it ships at the default the measurements chose, with its row in gpu/vk/switches.def.
  • A check under tests/ that reads changed source is updated, not weakened.
  • Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths.
  • Docs updated.
  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.

No screenshots: the change is in the frames' timing, which a still picture does not show; nothing in the menus changes.
The guide's Graphics capture reviews gpu/vk/vk_framegen.h, which this changes (framegen_record's arguments): the
image is retained and docs/user/images/guide/README.md records the review. That check
(scripts/check_guide_screenshots.py --review-sources) fails on main already (ten files changed since the
capture's reviewed revision); this adds that one to its list.

Ready to merge

  • Everything in Still to test has run, its results in Tested.
  • Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers").
  • Approved in review, every comment answered.
  • CI passes on the head; on current main, measured again or a comment says why the numbers still hold.

🤖 Generated with Claude Code

## Summary With a fixed frame generation multiplier (2x to 8x) the generated frames are paced on the game's timeline (https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1362, and under FIFO https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1442), and that timeline was the render thread's hand-over: `framegen_record` put each set at its own call, which comes after the main thread's signal and the frame's replay. On an RTX 4090 (DLSS Frame Gen 2x at a 60 fps cap, FIFO, a 240 Hz VRR display) the hand-over came about 4.4 ms after the game's present, its intervals' standard deviation 0.94 ms where the presents' was 0.28 ms, and the game frames' intervals on screen followed the hand-overs' (r 0.81; against the presents', r 0.23): the game's frames reached the screen as unevenly as the replay ran. To see it on `main`: frame generation 2x at a 60 fps cap, V-Sync on, a VRR display; pan the camera in Hyrule Field and record the presents with PresentMon: the game frames' intervals on screen have a standard deviation of 2.36 ms (six runs here: 2.27 to 2.44), 28 % of them within 0.5 ms of 16.67 ms. At the game's cap, the sets now follow the game's presents: - `present` takes the game's thread's time just after the FPS counter's stamp; the present's job carries it to both `framegen_record` calls (`present_game_at`); - `fixed_clock` puts the set at that present, the render thread's lag after the presents later, smoothed over 16 sets: the presents give the intervals and the lag the phase, so the GPU's delay (`pace_delay`) takes up only how much the lag varies; - a present not known (not after the last one, after the hand-over, or over 100 ms before it) puts the set at its hand-over, the lag kept, and the next set is on the presents again; a hitch takes the lag again; - `pace_feeds` keeps a set that came after a long game frame from feeding the GPU's delay back, on either timeline. Below its cap the game's thread waits in its present (for the main thread's signal, then for room in the render thread's queue), so its presents carry the game's own work too, and sets on them would take in how both vary. `enqueue` now takes how long the thread waited (`game_wait`); `fixed_clock` smooths it, and over 1 ms the sets are at their hand-over as on `main`, under 0.5 ms on the presents again. At the cap here, 4 to 47 presents of 600 waited 0.1 to 0.2 ms. `RX_VK_FG_GAME_CLOCK=0` puts every set at its hand-over again (a kill switch, its row in `gpu/vk/switches.def`). Auto is unchanged. The log's frame interpolation line counts the sets on the presents, their lag (mean, most), those at their hand-over because the game ran below its cap, and the times the delay was fed back at a game frame. `docs/dev/reference/architecture.md` (frame generation's rule 2) says when the presents hold. This and https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2183 (the replay's queue at global priority low) change some of the same files (`vk_framegen.cpp`/`.h`, `vk_replay.cpp`, `switches.def`, the guide images' README) but merge with no conflict in either order; the "both" column below is the two merged. Possibly related: https://git.magicbean.dev/MagicBeanDev/Longshot/issues/1568 (frame generation 2x paced unevenly in Jabu-Jabu's Belly, Linux, RTX 5080) and https://git.magicbean.dev/MagicBeanDev/Longshot/issues/2105 (stutter in busy areas with frame generation, the game's frames down to 51 to 55 fps, RTX 4070 SUPER, Windows): below the cap this keeps `main`'s pacing when the replay has its own thread (Risks), so it should not change those drops (inferred). Neither was tried there. Read first: `gpu/vk/vk_framegen.cpp` (`fixed_clock`, `pace_feeds`, `framegen_record`), `gpu/vk/vk_replay.cpp` (`present`, `enqueue`: `present_game_at`, `game_wait`). ## Testing **Tested:** Windows 11, RTX 4090, NVIDIA 621.24, a 240 Hz VRR display, full screen. Four runs of this PR and four with https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2183 too, against six of `main` (Measurements). In every run the log's line put each 5 s window's sets on the game's presents (a run's first set aside), but in the window of the teleport's load, where 17 to 57 were at their hand-over with the game below its cap. Over the pan the hand-over came 4.0 to 5.3 ms after the game's present, as on `main` (Summary); a window of the pan: ``` vk: frame interpolation: 301 of the sets on the game's timeline placed on the game's presents, the others at their hand-over (0 with the game below its cap; RX_VK_FG_GAME_CLOCK=0: all); handed over 4.5 ms after their present (at most 8.7); the GPU's delay at its most, a game frame, 0 times ``` No device was lost. This PR's head, on `main` a2dc53859, ran again 30 s in a window (in the Market: the run's teleport to Hyrule Field didn't take): past its first log window, each 5 s window put 299 to 301 sets on the game's presents, 0 with the game below its cap; no device lost. On earlier builds of this work, on the same PC (with the replay's queue at global priority low too, before the work was split in three), below the cap under a GPU load, three runs of two series: past the first log windows every window put its sets at their hand-over, and the game frames' calls followed the hand-overs (their intervals' slope against them 1.06, 1.07 and 1.04, r 0.99) as with `RX_VK_FG_GAME_CLOCK=0` (1.05, 1.06, 1.04, and 1.11 in another scene, r 0.98 to 0.99), where without the last commit they followed the presents (1.03 and 1.06); at the cap, unloaded, 300 or 301 sets a log window on the presents. `mise run test` (`tests/run_all.py --strict`) on this PC, Windows with llvm-mingw's clang++: 37 checks fail on `main` a2dc53859 here (listed below), and the same 37 fail here, on the same lines, and no other (`test_sampler_admission`'s concurrent cases fail a varying number of times from run to run on `main`: 2 of 147 in its full run, 3 in this PR's). The renderer builds on Linux (`RX_VK_ONLY=1`). `tests/test_framegen_fixed_pace.py` fails at each test commit for the bug's reason and passes at its fix (clang++): on `main`'s code, the screen moves with the hand-over (sd 1.04 ms); below the cap on the first fix's, the GPU's delay ran to 11.4 ms on the presents against 7.2 at the hand-over. It passes here with g++ (11.4, Linux) and clang++; it catches the 13 mutations of the last fix its commit lists, and the 3 a cold review tried on the first. `tests/present_source_crop_test.cpp` follows `framegen_record`'s new arguments; it passes on `main` and here, with clang++ and with g++. <details><summary>The 37 checks that fail on <code>main</code> a2dc53859 on this PC</summary> `nx2/test_import_windows`, `test_auto_handheld`, `test_bug_report`, `test_close_waits_for_save`, `test_compile_zero_byte`, `test_crash_dialog`, `test_damaged_rom_files`, `test_dev_ab`, `test_dev_build`, `test_dev_migrate`, `test_dev_packs`, `test_draw_stream_visibility`, `test_fs_save_commit`, `test_fsr3fi_hud_layer`, `test_fsr3fi_hudless_colour`, `test_fsr_uniform_ownership`, `test_game_menu_mouse_buttons`, `test_guest_copies`, `test_hold_toggle`, `test_input_movie`, `test_linux_preflight`, `test_lower_atomg_cas`, `test_menu_i18n`, `test_menu_keys`, `test_menu_slider_ends`, `test_pads_after_menu`, `test_perf_report`, `test_portable_builder_home`, `test_portable_builder_startup`, `test_recording_admission`, `test_sampler_admission`, `test_sdiv_overflow`, `test_sim_turf_pools`, `test_switch_table`, `test_tls_objects`, `test_vibration_menu`, `test_work_lock` </details> **Still to test:** - AMD and Intel on Windows, FSR 3.1 or Built-in frame generation 2x at a 60 fps cap, V-Sync on, VRR: PresentMon over a camera pan, `main` against this PR, expecting the game frames at least as even on screen and the log's line counting the sets on the presents (Test Farm) - Linux (Mesa or NVIDIA), the same (Test Farm) - A GPU-bound scene below the cap on another PC: the log's line saying the sets were at their hand-over (by hand) ## Measurements **Verdict:** a fix for the game frames' pacing: at the cap their intervals on screen have a standard deviation of 1.49 ms (1.48 to 1.52, four runs) against 2.36 on `main` (2.27 to 2.44, six runs), and no longer follow the render thread's hand-overs (r 0.35 against 0.81). The intervals between a game frame and a generated frame do not change beyond the runs' spread (9.5 % within 0.5 ms of 8.33 ms against 10.0 %): where the generated frame lands is https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2183's part. With both, 30.4 % within 0.5 ms (20.1 to 35.4) against 29.8 % (26.5 to 33.6) for that PR alone, the game frames' standard deviation 1.29 ms against 2.24, and a game frame's two halves (game to generated frame, generated to game frame) within 0.2 ms of each other on average in three runs of four (+0.04 to +0.36 ms), against none of four without this PR. Setup: Windows 11, RTX 4090, NVIDIA 621.24, 240 Hz VRR display; DLSS Frame Gen 2x, 60 fps cap, FIFO, full screen, Hyrule Field with the camera panning for 60 s after a teleport, PresentMon over the pan; every run with the same logging switches on (`HOS_PRESENT_TRACE`, `RX_VK_FG_LATENCY_LOG`, `RX_VK_REFLEX_LOG`), `RX_VK_PRESENT_QUEUE=0`. Runs interleaved with the other heads of this work, after one warm-up run each; the mean of each head's runs, (lowest-highest). One more run of `main` was left out: PresentMon saw 5309 of its 13240 frames composed by the desktop (Composed: Flip), not flipped straight to the display. | | Before: main @ 8aa749834 | After: this PR @ 38e673852 | After: this PR and the queue's priority PR @ 451bc026c | |---|---|---|---| | Game frames on screen, their intervals' standard deviation, ms | 2.36 (2.27-2.44) | 1.49 (1.48-1.52) | 1.29 (1.24-1.33) | | Game frames on screen within 0.5 ms of 16.67 ms, % | 28.4 (26.5-29.3) | 37.4 (35.9-39.2) | 57.5 (55.8-59.0) | | Screen against the hand-overs (game frames' intervals): slope, r | 2.04, 0.81 | 0.57, 0.35 | 0.36, 0.26 | | Intervals on screen within 0.5 ms of 8.33 ms, % | 10.0 (7.3-12.3) | 9.5 (6.8-12.2) | 30.4 (20.1-35.4) | | Intervals on screen, standard deviation, ms | 2.43 (2.27-2.94) | 2.50 (2.18-2.94) | 1.44 (1.39-1.49) | | Game frame to generated frame, minus generated to game frame, mean, ms | -3.46 (-4.56 to -2.97) | -3.85 (-4.78 to -3.16) | +0.15 (+0.04 to +0.36) | | Game frame on screen after its present, median, ms | 22.68 (22.58-23.01) | 22.89 (22.65-23.25) | 21.17 (21.09-21.21) | | Runs | 6 | 4 | 4 | Baseline: `main` 8aa749834 for both After columns. 38e673852 is this PR's commits (760888e08) and one diagnosis commit on top, `RX_VK_FG_MADE_SHIFT_US`, left unset (it shifts nothing unset, and it is not in this PR); 451bc026c is the same on top of https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2183's commits. Measured on `main` 8aa749834. This PR is now on `main` a2dc53859, its commits' changes the same (checked with `git range-diff`) and, since, a line in the guide images' README. `main`'s commits since change neither the presents' timing, the queues nor the fixed sets' pacing; in the renderer, one keeps the HUD's colours with FSR 3.1 frame generation in Native HDR (DLSS here), one starts the replay's threads through a guard that reports their C++ exceptions, one logs fewer memory imports, https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2171 moves two includes, spells `rx_nvn.h`'s static assertions so g++ builds them, changes menu texts and mends `present_source_crop_test.cpp`'s `hud_source` stand-in, and https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2174 keeps the simulated-turf lists at the game's own size in areas without turf, so that Hyrule Field, the scene measured, no longer stalls 250 ms at a time on the way in: that changes frame times there, and both sides above ran without it. https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1722 adds a save. ## Risks - Every fixed multiplier at its cap is paced on the game's presents now, on every GPU and maker; measured here on an RTX 4090 with DLSS only (Still to test). `RX_VK_FG_GAME_CLOCK=0` puts it back as on `main`. - Below the cap the sets go back to the hand-over only once the thread's smoothed wait passes 1 ms: a burst of 11 or more waits of 2 ms or more at the cap puts them at their hand-over for about 22 presents. - Without the replay's own thread (async off) no wait is taken: the game's thread replays and presents itself there, and its sets stay on its presents. - `fixed_clock`'s state is not reset when the device or the swapchain is made again, or frame generation is turned off and on; a hitch takes the lag again. - Nothing changes in `longshot_options.ini`, the saves or the caches. A revert is enough. ## Checklist ### Ready for review - [x] One topic, on current `main`; the title is a Conventional Commit. - [x] Tested on my own PC, in the game for a change the game runs, as Testing says. - [x] `mise run test` passes (any failure that also fails on `main` is named). - [x] Measured against `main`, or Measurements says why there is nothing to measure. - [x] No game files, build output or hand-edited generated files; `third_party/` untouched; nothing GPL-incompatible. ### When it applies - [x] A fix: a game-free test that fails on `main` and passes here. - [x] A switch added or changed: it ships at the default the measurements chose, with its row in `gpu/vk/switches.def`. - [x] A check under `tests/` that reads changed source is updated, not weakened. - [x] Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths. - [x] Docs updated. - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. No screenshots: the change is in the frames' timing, which a still picture does not show; nothing in the menus changes. The guide's Graphics capture reviews `gpu/vk/vk_framegen.h`, which this changes (`framegen_record`'s arguments): the image is retained and `docs/user/images/guide/README.md` records the review. That check (`scripts/check_guide_screenshots.py --review-sources`) fails on `main` already (ten files changed since the capture's reviewed revision); this adds that one to its list. ### Ready to merge - [ ] Everything in Still to test has run, its results in Tested. - [ ] Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers"). - [ ] Approved in review, every comment answered. - [ ] CI passes on the head; on current `main`, measured again or a comment says why the numbers still hold. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
tests/test_framegen_fixed_pace.py models 2x at about 60 fps under FIFO on a
240 Hz VRR display, each game frame handed over 2.6 to 6.4 ms after the
game's thread presented it (measured on an RTX 4090: 4.5 ms at the median,
sd about 1.1 ms, the presents themselves 0.27 ms apart at most). Every frame
should be shown as long after its picture as the others (sd under 0.5 ms),
no more than a millisecond later than at the hand-over, none waiting, the
GPU's delay never at its most (a game frame). So too handed over 12 to
16 ms after (near a game frame), at 90 to 110 fps, and 17 to 19 ms after
with one present not known, after which the next set is on the presents
again; a set handed over 18 ms after its present once a second must not
feed the GPU's delay back.

On main, which puts the set where the render thread hands it over (the
stand-in fixed_clock and pace_feeds), the screen moves with the hand-over
(sd 1.04 ms) and the first case fails. The text checks then look for the
game's thread's time, taken in present, reaching both framegen_record calls
through the present that job makes, and for display_main feeding the delay
back through pace_feeds.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
With DLSS Frame Gen 2x at 60 fps under FIFO on a 240 Hz VRR display the
frames reached the screen unevenly. framegen_record put each set on the
game's timeline at its own call, the render thread's hand-over, which comes
after the main thread's signal and the frame's replay: 4.5 ms after the
game's present at the median, its intervals sd 1.1 to 1.2 ms where the
presents' were 0.27 ms (RTX 4090), and the screen followed the hand-overs
(r 0.92 to 0.94; against the presents, r 0.24).

present now takes the game's thread's time just after the FPS counter's
stamp. The present's job carries it (present_game_at for a present made on
the game's thread) to both framegen_record calls. fixed_clock puts the set
at that present, the render thread's lag after the presents later, smoothed
over 16 sets: the presents give the intervals and the lag the phase, so the
GPU's delay (pace_delay) takes up only how much the lag varies. Placed at
the presents themselves, a lag near a game frame (a GPU-bound replay, or
near 100 fps) held the delay at a game frame and the frames went out as they
came. A present not known (not after the last one, after the hand-over or
over 100 ms before it) puts the set at its hand-over, the lag kept, so the
next set is on the presents again; a hitch takes the lag again. The set's
frame time and span follow that timeline; Auto is unchanged. pace_feeds
keeps a set that came after a long game frame on either timeline (the
presents or the hand-overs) from feeding the delay back.

RX_VK_FG_GAME_CLOCK=0 puts the sets at the hand-over again (a kill switch,
its row in switches.def). display_main's log line counts the sets placed on
the presents, their lag (mean, most) and the times the delay was fed back at
a game frame. In the test's model the frames' spread after their pictures
goes from 1.04 to 0.39 ms, 0.34 ms later on average; with the lag 12 to
16 ms, at 100 fps, and after a present not known the delay never reaches a
game frame.

tests/present_source_crop_test.cpp and tests/test_present_source_crop.py
follow framegen_record's new argument and cut fixed_clock out too;
tests/test_framegen_fixed_pace.py loses main's stand-in.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The cold review of the fixed sets on the game's timeline found cases the FIFO model did not run, and a time the
text checks did not hold:

- 30 fps, handed over 25 to 40 ms after the presents: every set on its present, sd 1.80 ms against 4.42 at the
  hand-over, 1.3 ms later.
- A step in the lag (2.6-6.4 ms, then 12.1-15.9 from set 350, back from 470): one jump each way on either timeline,
  then the frames glide to the new lag; from frame to frame 0.50 ms against 0.88.
- A hitch (150 ms at set 400, the lag longer after it): the set after it untimed, the lag taken again, the sets after
  it on their presents at once; from frame to frame 0.45 ms against 0.83, game frames at most 0.3 ms late.
- The report adds how far a frame's time after its picture moves from one frame to the next (root mean square and
  most); both() checks it is no worse than at the hand-over.
- The text checks hold the time on both presents made on the game's thread (the one that waits for the GPU and the
  other), and one clock for bh_now and now_ns.

Mutations, each against this test: a 20 ms window instead of 100 (caught by the 30 fps case), the present's time
only on the present that waits (caught by the text check), the smoothed lag kept through a hitch (caught by
fixed_clock's own check; on the model both look alike).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
With RX_VK_FG_GAME_CLOCK=0, or no present's time known, the line said "0 of the sets ... handed over 0.0 ms after
their present"; it now says none were, and why it can be. The comment on a present not known says what 0 is today:
a present made without its time, which vk_replay.cpp's present gives every one it makes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Below its cap the game's thread waits in its present: for the main thread's signal that the frame's data is written,
then for room in the render thread's queue. Measured on an RTX 4090 under a GPU load at 33 to 50 fps, 436 to 599 of 600
presents waited 7 to 21 ms each for the signal; at the cap 4 to 47 waited for it, 0.1 to 0.2 ms. Each present then comes
the game's own work after the present before let it go, so a fixed set placed on the presents takes in how both the
game's work and the replay's vary: on one scene at about 50 fps the GPU's delay reached a game frame 10.6 times a log
window on the presents, against 0.5 at the hand-over (RX_VK_FG_GAME_CLOCK=0), that run first.

run_fifo gets a closed loop: the game's present its work after the last hand-over, the hand-over the replay's work after
it, the world moving as the hand-overs did. Its work 6 to 14 ms and the replay's 17 to 23 ms (50 fps, each present held
10 ms), 2x on 240 Hz: on the presents the GPU's delay ran to 11.4 ms against 7.2 at the hand-over, from frame to frame
the frames jumped 2.16 ms against 0.96, a made frame and the game frame after it a refresh apart. The check asks the
screen of the hand-over there, and with the thread freed from set 400 on the presents again once. fixed_clock's unit
checks: how long the thread waited, smoothed over 16 presents, over 1 ms the sets at their hand-over, under 0.5 ms on
the presents again; a present not known and RX_VK_FG_GAME_CLOCK=0 take no wait; a 30 ms wait once a second never moves
them. The text checks follow the wait from enqueue to fixed_clock, and pin that it counts the signal: the present's
time taken before the wait for it, the wait taken in enqueue after the room's block, so a present that found room at
once has its wait too.

Not modelled: what the wait is made of in the game (the model holds the present as a whole); the game going from its
cap to below it, as the model never runs at the cap; bursts of waits of 2 ms or more at the cap, and waits near the
thresholds; the render thread held on a free set, which lengthens the wait. On this commit the closed loop below the
cap fails (fixed_clock takes no wait: a stand-in places every set on the presents, as it does).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Below its cap the game's thread waits in its present, for the main thread's signal that the frame's data is written,
then for room in the render thread's queue, so each present comes the game's own work after the present before let it
go, and sets placed on them (fixed_clock) took in how both vary: on one scene at about 50 fps the GPU's delay reached a
game frame 10.6 times a log window on the presents, against 0.5 at the hand-over, that run first.

enqueue now takes how long the game's thread waited in a present: game_wait, from its game_at, taken before the wait
for the CPU's signal, to its job in the queue, after the room there. The job carries it through do_present to
framegen_record and fixed_clock, which smooths it over the known presents, each taken to 2 ms at most: over 1 ms the
sets are at their hand-over, under 0.5 ms they are on the presents again, the lag taken again. At the cap (4 to 47
presents of 600 waited 0.1 to 0.2 ms for the signal on an RTX 4090) nothing changes, and a 30 ms wait once a second
raises it to 0.13 ms. RX_VK_FG_GAME_CLOCK=0 takes no wait, as before. The log's line of the sets on the game's timeline
counts those at their hand-over because the game ran below its cap; architecture.md's rule 2 and the switch's text say
when the presents hold. tests/present_source_crop_test.cpp passes the new game_wait (0). That test fails on main
already: its hud_source stand-in takes a parameter fewer than the code passes since d664e3428; with the stand-in mended
in a copy it passes here.

tests/test_framegen_fixed_pace.py: the stand-in for a fixed_clock without the wait is gone. On the test commit the
closed loop below the cap fails at its behaviour check (on the presents the GPU's delay ran to 11.4 ms against 7.2 at
the hand-over); here it passes with g++ and clang++, the screen the same as RX_VK_FG_GAME_CLOCK=0's, and with the thread
freed from set 400 the sets go back on the presents once. Thirteen mutations of the fix are caught, six by the model
(the hold, its two thresholds, the clamp twice, the lag taken again) and seven by the text checks (the wait not taken,
not passed on twice, not cleared after a present, taken before the room, only the room's wait counted, the present's
time taken after the CPU's signal).

In the game (RTX 4090, 621.24, 2x, FIFO, VRR 240 Hz; builds of the branch before it was split in three, so with the
replay's queue at global priority low too), below the cap under a GPU load, in three runs of two series (a fourth was
left out, the game's window brought to the front during it): in each, past the first windows, every window put its sets
at their hand-over, and the game frames' calls followed the hand-overs (their intervals' slope against them 1.06, 1.07
and 1.04, r 0.99) as with RX_VK_FG_GAME_CLOCK=0 (1.05, 1.06, 1.04 and 1.11, the last in another scene, r 0.98 to 0.99),
where before this commit they followed the presents (1.03 and 1.06 against those, r 0.99). The GPU's delay reached a
game frame in bursts with either, more often in the first run of each round: 6.6 to 9.9 times a log window (two here,
two with RX_VK_FG_GAME_CLOCK=0), against 1.4 to 2.1 in the second (one here, two with it); before this commit the runs
on the presents had it more in each of four pairs whichever went first (19.9, 7.2, 10.6 and 10.1 times a window against
2.5, 2.7, 0.5 and 4.7). At the cap, unloaded, 300 or 301 sets a window on the presents and none below the cap past the
start; during it one window each counted 27 and 35, the presents then waiting 1.8 to 2.4 ms for the signal.

Not covered: without the replay's own thread (async off) no wait is taken (game_wait 0): the game's thread replays and
presents its frame itself there, so its sets stay on its presents. A burst of 11 or more waits of 2 ms or more at the
cap puts the sets at their hand-over for about 22 presents. fixed_clock's state is not reset when the device or the
swapchain is made again, or frame generation turned off and on. The log's count of the sets below the cap is not
checked.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
docs(guide): framegen_record's new arguments leave the Graphics capture as it is
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
CI / Website build and checks (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
Website / Website on Cloudflare (pull_request_target) Has been skipped
PR description / Description follows the template (pull_request_target) Successful in 10s
dd4be442c3
The guide's Graphics capture reviews gpu/vk/vk_framegen.h, whose framegen_record now takes the
game's present time and wait (scripts/check_guide_screenshots.py --review-sources). No menu row
changes, so the image is retained. The README records the review, as earlier source reviews there do.

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

Tested in game: Windows 11, RTX 4090, NVIDIA 621.24, a 240 Hz VRR display, full screen; DLSS Frame Gen 2x at a 60 fps cap, V-Sync on, Hyrule Field with the camera panning, PresentMon recording, four runs of this PR and four with the queue priority PR too, against six of main: the log put 300 or 301 sets a 5 s window on the game's presents, and the game frames' intervals on screen had a standard deviation of 1.49 ms against 2.36 on main. No device was lost. The final head, on main a2dc53859, ran again 30 s in a window: past its first log window, 299 to 301 sets a 5 s window on the game's presents, none below the cap, no device lost.

Tested in game: Windows 11, RTX 4090, NVIDIA 621.24, a 240 Hz VRR display, full screen; DLSS Frame Gen 2x at a 60 fps cap, V-Sync on, Hyrule Field with the camera panning, PresentMon recording, four runs of this PR and four with the queue priority PR too, against six of main: the log put 300 or 301 sets a 5 s window on the game's presents, and the game frames' intervals on screen had a standard deviation of 1.49 ms against 2.36 on main. No device was lost. The final head, on main a2dc53859, ran again 30 s in a window: past its first log window, 299 to 301 sets a 5 s window on the game's presents, none below the cap, no device lost.
Member

Possibly related, for context:

  • PR #2183 WIP: fix(vk): the replay's queue at global priority low with fixed frame generation on NVIDIA's Windows driver — Overlapping frame-generation Vulkan pacing work and shared files; PR descriptions say they compose cleanly.
  • issue #1568 Game: Frame pacing becomes uneven with frame generation in Jabu-Jabu's Belly — Open report of uneven frame-generation pacing on Linux/NVIDIA; candidate symptom this may address.
  • issue #2105 Game: Stutter in heavy areas despite steady 60 fps base: replay thread near 16.7 ms and texture-streaming hitches (RTX 4070 SUPER, Windows 11, 4K) — Open frame-generation stutter report; description says below-cap behavior is retained, so impact is uncertain.
Possibly related, for context: - PR #2183 WIP: fix(vk): the replay's queue at global priority low with fixed frame generation on NVIDIA's Windows driver — Overlapping frame-generation Vulkan pacing work and shared files; PR descriptions say they compose cleanly. - issue #1568 Game: Frame pacing becomes uneven with frame generation in Jabu-Jabu's Belly — Open report of uneven frame-generation pacing on Linux/NVIDIA; candidate symptom this may address. - issue #2105 Game: Stutter in heavy areas despite steady 60 fps base: replay thread near 16.7 ms and texture-streaming hitches (RTX 4070 SUPER, Windows 11, 4K) — Open frame-generation stutter report; description says below-cap behavior is retained, so impact is uncertain.
Jiro113 changed title from WIP: fix(vk): a fixed frame generation multiplier's sets follow the game's presents, not the render thread's hand-over to fix(vk): a fixed frame generation multiplier's sets follow the game's presents, not the render thread's hand-over 2026-11-22 02:07:44 +00:00
dazemc left a comment

Read of dd4be442 (code = 0546b296 test + 4a273d61 fix + docs) on main a2dc5385. The hand-off change is only the set's place — fixed_dues(place.before, place.at, …) from the presents + the smoothed lag instead of (before, now) — and the rest of the set's life is untouched. The off path is main exactly and the test is real. One concrete gap at 3x and up, under FIFO.

1. At 3x+, a lag step or a held present can make fifo_catch_up drop the set's made frames. The game frame's due is now place.at + pace_lead(frame, made) + extra (vk_framegen.cpp:1844-1856), with place.at = game_at + c.lag (:263) — the smoothed lag. When the actual hand-over is later than the smoothed lag by more than the lead, due[made] falls before the set is taken. fifo_catch_up then still measures from due[made]: its next is clamped to now and its loop wants shown frames a refresh apart ending within a refresh of due[made] (:346-354); with the game frame already late it cannot fit even three, and returns made - 1 (:354), leaving out all but one made frame — and the game frame goes late anyway, so this drops generated frames for nothing. Its own doc says the premise is "so that the set's game frame … is shown no more than a refresh after its own time" — true on main's hand-over timeline, not once the place is behind the hand-over. Reachable at made >= 2 (3x to 8x, which DLSS FG runs at 6x):

  • a present held in the replay loop up to hold_ms() = 50 ms (cpu_wait_unmet, vk_replay.cpp:7592-7593), whose own game_wait does not see the hold (it is taken at enqueue after the signal/room, :7752, not when the held present runs, :7557) — so it is accepted as an at-cap present and placed with a 4.5 ms lag while it was handed over 50 ms late;
  • the lag step the PR itself measures (4.5 → 12–16 ms): at 3x/60 the lead is frame·2/3 ≈ 11 ms (12.5 at 4x), so a step of that size is right at the cushion, and a larger one is not absorbed.

The tests cannot see it: every case with a non-zero lag uses made = 1 (tests/test_framegen_fixed_pace.py:510,513,568,570,584,587,604,608,617,620), and fifo_catch_up returns 0 at made < 2 (vk_framegen.cpp:346); the 3x/4x/6x cases (:425,438,454,472,486) pass no lag, so fixed_clock's place there is the hand-over and the new path is not exercised. Please add one 3x case with the measured lag and a held present; the fix is to measure the catch-up against the hand-over when the game frame is already late (e.g. max(due[made], now)), or to skip it then.

2. The other questions.

  • Waits/reordering: no part-style split here — the change is the due times only. due[] is strictly increasing whenever timed (fixed_clock requires at > before, :267), and a place not after the one before, a hitch, or a present not known/stale (>100 ms, :253) leaves the set at its hand-over or with no times at all — main's path. set->made, the frames' order and the slots are untouched, so nothing is duplicated or reordered; the only drop path I found is the catch-up above.
  • Off path: =0 reduces to main exactly: c.at tracks now and p.at = now, so place.before/at are main's before/now; c.frame equals fg.game_ns (same sequence, same guards), and pace_feeds(span, frame, hand_span, hand_frame) then has span == hand_span and frame == hand_frame, i.e. the old single check. Frame generation off never calls framegen_record; Auto is structurally untouched because the auto_rate branch returns before the by_time block (:1747-1800) — that claim holds.
  • The test fails on main — the fixture extracts fixed_clock, and check_game_at asserts the time's path from present_tagged to both framegen_record calls, neither of which exists on main — and it covers the measured lag distribution, a lag step, a hitch, a present not known and one >100 ms stale, the below-cap loop with both hysteresis ends, and =0. Its held-present coverage is plumbing only (:849-853), which is the gap in 1.
  • #2083: that is the swapchain image hold in present_image_with_trial, not the present job's game_at; nothing here makes it worse. A held image makes the display thread's presents late, and the sets go out at their times when it ends, as on main (FIFO's catch-up may still leave made frames out there, which is the existing rule).
  • Pins for the A/B: #2183's RX_VK_QUEUE_PRIORITY and #2182's RX_VK_PRESENT_PROBE/RX_VK_QUEUE_PRIORITY must be on the same side in both arms (and #2182 is diagnostic anyway); RX_VK_FG_GAME_CLOCK on the same side in both arms is the whole comparison; keep RX_VK_PRESENT_QUEUE=0 as the measured runs did, plus the FG logs. For our #1988 present/texture-stall A/B, pin RX_VK_FG_GAME_CLOCK and RX_VK_ASYNC_PARTS/RX_VK_ASYNC_FENCES on both arms — this changes the game frames' pacing, so it moves present stalls for a reason that is not #1988. #2184 and our #1988 fix both edit do_present within a few lines (the framegen_record call at :5508 vs the SlowWatch/texture_frame note) — rebase, no semantic overlap.
  • Claims: "Every fixed multiplier at its cap is paced on the game's presents now, on every GPU and maker" (Risks) is conditional on the smoothed present wait staying under 1 ms at the cap (:254-256) — measured only on the RTX 4090. On a PC whose present thread waits more at the cap, held stays false? no: it goes true, the sets return to the hand-over, and the fix does nothing (not worse, but not the claim). Say "where the thread does not wait in its present"; the Still-to-test's log line is the acceptance. The screen table's Before/After are main 8aa749834 / 38e673852 (pre-split + a diagnosis commit), both without #2174, which the body itself says changes Hyrule Field's frame times — the measured scene; the head has a 30 s log window only. One row on the head (or a re-measure on current main) closes the status warning.

No approval, and no claim on it.

**Read of `dd4be442` (code = `0546b296` test + `4a273d61` fix + docs) on main `a2dc5385`.** The hand-off change is only the set's *place* — `fixed_dues(place.before, place.at, …)` from the presents + the smoothed lag instead of `(before, now)` — and the rest of the set's life is untouched. The off path is main exactly and the test is real. One concrete gap at 3x and up, under FIFO. **1. At 3x+, a lag step or a held present can make `fifo_catch_up` drop the set's made frames.** The game frame's due is now `place.at + pace_lead(frame, made) + extra` (`vk_framegen.cpp:1844-1856`), with `place.at = game_at + c.lag` (`:263`) — the *smoothed* lag. When the actual hand-over is later than the smoothed lag by more than the lead, `due[made]` falls **before** the set is taken. `fifo_catch_up` then still measures from `due[made]`: its `next` is clamped to `now` and its loop wants `shown` frames a refresh apart ending within a refresh of `due[made]` (`:346-354`); with the game frame already late it cannot fit even three, and returns `made - 1` (`:354`), leaving out all but one made frame — and the game frame goes late anyway, so this drops generated frames for nothing. Its own doc says the premise is "so that the set's game frame … is shown no more than a refresh after its own time" — true on main's hand-over timeline, not once the place is behind the hand-over. Reachable at `made >= 2` (3x to 8x, which DLSS FG runs at 6x): - a present held in the replay loop up to `hold_ms()` = 50 ms (`cpu_wait_unmet`, `vk_replay.cpp:7592-7593`), whose own `game_wait` does not see the hold (it is taken at `enqueue` after the signal/room, `:7752`, not when the held present runs, `:7557`) — so it is accepted as an at-cap present and placed with a 4.5 ms lag while it was handed over 50 ms late; - the lag step the PR itself measures (4.5 → 12–16 ms): at 3x/60 the lead is frame·2/3 ≈ 11 ms (12.5 at 4x), so a step of that size is right at the cushion, and a larger one is not absorbed. **The tests cannot see it**: every case with a non-zero lag uses `made = 1` (`tests/test_framegen_fixed_pace.py:510,513,568,570,584,587,604,608,617,620`), and `fifo_catch_up` returns 0 at `made < 2` (`vk_framegen.cpp:346`); the 3x/4x/6x cases (`:425,438,454,472,486`) pass no lag, so `fixed_clock`'s place there is the hand-over and the new path is not exercised. Please add one 3x case with the measured lag and a held present; the fix is to measure the catch-up against the hand-over when the game frame is already late (e.g. `max(due[made], now)`), or to skip it then. **2. The other questions.** - **Waits/reordering:** no part-style split here — the change is the due times only. `due[]` is strictly increasing whenever `timed` (`fixed_clock` requires `at > before`, `:267`), and a place not after the one before, a hitch, or a present not known/stale (>100 ms, `:253`) leaves the set at its hand-over or with no times at all — main's path. `set->made`, the frames' order and the slots are untouched, so nothing is duplicated or reordered; the only drop path I found is the catch-up above. - **Off path:** `=0` reduces to main exactly: `c.at` tracks `now` and `p.at = now`, so `place.before/at` are main's `before/now`; `c.frame` equals `fg.game_ns` (same sequence, same guards), and `pace_feeds(span, frame, hand_span, hand_frame)` then has `span == hand_span` and `frame == hand_frame`, i.e. the old single check. Frame generation off never calls `framegen_record`; **Auto is structurally untouched** because the `auto_rate` branch returns before the `by_time` block (`:1747-1800`) — that claim holds. - **The test fails on main** — the fixture extracts `fixed_clock`, and `check_game_at` asserts the time's path from `present_tagged` to both `framegen_record` calls, neither of which exists on main — and it covers the measured lag distribution, a lag step, a hitch, a present not known and one >100 ms stale, the below-cap loop with both hysteresis ends, and `=0`. Its held-present coverage is plumbing only (`:849-853`), which is the gap in 1. - **#2083:** that is the swapchain image hold in `present_image_with_trial`, not the present job's `game_at`; nothing here makes it worse. A held image makes the display thread's presents late, and the sets go out at their times when it ends, as on main (FIFO's catch-up may still leave made frames out there, which is the existing rule). - **Pins for the A/B:** #2183's `RX_VK_QUEUE_PRIORITY` and #2182's `RX_VK_PRESENT_PROBE`/`RX_VK_QUEUE_PRIORITY` must be on the same side in both arms (and #2182 is diagnostic anyway); `RX_VK_FG_GAME_CLOCK` on the same side in both arms is the whole comparison; keep `RX_VK_PRESENT_QUEUE=0` as the measured runs did, plus the FG logs. For our #1988 present/texture-stall A/B, pin `RX_VK_FG_GAME_CLOCK` and `RX_VK_ASYNC_PARTS`/`RX_VK_ASYNC_FENCES` on both arms — this changes the game frames' pacing, so it moves present stalls for a reason that is not #1988. #2184 and our #1988 fix both edit `do_present` within a few lines (the `framegen_record` call at `:5508` vs the `SlowWatch`/`texture_frame` note) — rebase, no semantic overlap. - **Claims:** "Every fixed multiplier at its cap is paced on the game's presents now, on every GPU and maker" (Risks) is conditional on the smoothed present wait staying under 1 ms at the cap (`:254-256`) — measured only on the RTX 4090. On a PC whose present thread waits more at the cap, `held` stays false? no: it goes true, the sets return to the hand-over, and the fix does nothing (not worse, but not the claim). Say "where the thread does not wait in its present"; the Still-to-test's log line is the acceptance. The screen table's Before/After are `main 8aa749834` / `38e673852` (pre-split + a diagnosis commit), both without #2174, which the body itself says changes Hyrule Field's frame times — the measured scene; the head has a 30 s log window only. One row on the head (or a re-measure on current main) closes the status warning. No approval, and no claim on it.
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
CI / Website build and checks (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
Website / Website on Cloudflare (pull_request_target) Has been skipped
PR description / Description follows the template (pull_request_target) Successful in 10s
This pull request doesn't have enough approvals yet. 0 of 1 approvals granted.
Some workflows are waiting to be reviewed.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'fix/fg-fixed-sets-game-clock:Jiro113-fix/fg-fixed-sets-game-clock'
git switch 'Jiro113-fix/fg-fixed-sets-game-clock'
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/Longshot!2184
No description provided.