fix(vk): the replay's queue at global priority low with fixed frame generation on NVIDIA's Windows driver #2183
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!2183
Loadingβ¦
Reference in a new issue
No description provided.
Delete branch "Jiro113/Longshot:fix/fg-replay-queue-priority"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
With a fixed frame generation multiplier on NVIDIA's Windows driver, the game frame and the generated frame do not
share the screen evenly: at 2x and 60 fps each should stay 8.33 ms, but the game frame's present waits for the replay's
GPU work and the generated frame's does not, so the intervals swing by a few milliseconds and the motion judders.
To see it on
main: Windows, an NVIDIA card (measured on an RTX 4090, 621.24), a VRR display, frame generation 2x(DLSS, FSR 3.1 or Built-in), the frame rate capped at 60, V-Sync on; pan the camera in Hyrule Field and record the
presents with PresentMon. About 10 % of the intervals on screen are within 0.5 ms of 8.33 ms (six runs here: 7.3 to 12.3 %).
This makes the replay's queue at the global priority low (
VK_KHR_global_priority, elseVK_EXT_global_priority)where frame generation starts at a fixed multiplier (2x to 8x) with NVIDIA's driver on Windows, and where the queue's
family lists that level. The game frame's work then no longer waits behind the replay's: 29.8 % of the intervals within 0.5 ms here (four
runs: 26.5 to 33.6 %), and the game frame on screen 1.5 ms sooner after its present. The aim, 95 % within 0.5 ms,
is not reached: the game frame still waits on the replay's queue behind the next
frame's work, which a queue-wide priority cannot reorder (inferred), and #2184 deals with the sets' own timing.
The level is set when the device is made and kept, so:
(a fixed multiplier against Off or Auto) says After restart and Restart needed, as the menu's other such rows do, and
the frames keep the start's kind until then (
framegen_hold,framegen_running). Off to Auto, and 2x to 8x, applyat once;
HOS_HEADLESS, as the control bridge's test runs anddev.py ab --headlessset) starts withframe generation off and asks no priority; so does
RX_VK_FRAMEGEN=0(frame generation kept off);RX_VK_QUEUE_PRIORITY(added as a diagnosis switch by #2182) becomes ahwswitch:low,medium,highor
realtimeasks that level whatever frame generation is,0oroffnone;On the way,
menu_row_takes_restartsaid a row takes a restart even with no slot left to follow its value (15 of themenu's 16 slots are now taken); it now takes one only with its slot, and
tests/test_menu_restart_slots.pycounts themodules' rows again.
This pull request carries #2182's two commits (the switches it is built on); the one merged first brings them.
Read first:
gpu/vk/device_policy.h(policy_rule::replay_queue_priority,framegen_at_start,replay_priority_follows_framegen,queue_priority_look/_chained/_restart),gpu/vk/vk_main.cpp(create_device),gpu/vk/vk_framegen.cpp(framegen_hold,framegen_running),gpu/vk/vk_menu.cpp(menu_row_takes_restart).Testing
Tested: Windows 11, RTX 4090, NVIDIA 621.24, a 240 Hz VRR display, full screen. Four runs of this PR against six of
main(Measurements). The log said:No device was lost. This PR's head, on
maina2dc53859, ran again 30 s in a window (in the Market: the run'steleport to Hyrule Field didn't take): the same two lines, frame interpolation ready at 2x, no device lost.
On earlier builds of this work, the same PC:
RX_VK_QUEUE_PRIORITY=lowagainst without, one full-screen capture each: within 0.5 ms of 8.33 ms,DLSS 5.1 β 34.9 %, FSR 3.1 5.2 β 35.3 %, Built-in 4.5 β 41.7 %;
option set, thenoption get), in windowed runs started twice,the presents' geometry lines read before and after the set: with DLSS, FSR 3.1 and Built-in, 2x to Off and Off to 2x
said Restart needed, the frames kept the start's kind and the next start took the new value; DLSS 2x to Auto the
same, Off to Auto at once; with
RX_VK_QUEUE_PRIORITY=0, 2x to Off at once with no priority asked; with no window,frame generation started off and no priority was asked (9 of 9 as expected).
mise run test(tests/run_all.py --strict) on this PC, Windows with llvm-mingw's clang++: 37 checks fail onmaina2dc53859here (listed below), and the same 37 fail here, on the same lines, and no other (test_sampler_admission'sconcurrent 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;run alone three times, it failed twice on
mainand passed each time here). Every check this PR changes passes here with clang++ and with g++ (11.4,Linux), and the renderer builds on Linux (
RX_VK_ONLY=1).Each fix's check fails at its test commit for the bug's reason and passes at the fix (clang++):
test_device_policy(noreplay_queue_priority, the switch's levels and its log block),test_menu_modules(Framegeneration's row and its
restart_value),test_menu_row_takes_restart(a row said to take a restart with no slot tofollow it),
test_framegen_hold(frame generation turned off at once where its row takes a restart) andtest_framegen_windowless_start(3 of its 7 cases).test_menu_restart_slotsis a check made right, not a failingone: on
mainit counted onlyvk_menu.cpp's own table (0 rows) and passed; it now counts 14 rows there and 15 here,of 16 slots.
The 37 checks that fail on
maina2dc53859on this PCnx2/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_lockStill to test:
V-Sync on, PresentMon over a camera pan,
mainagainst this PR, expecting more frames within 0.5 ms of 8.33 ms andthe log's line of the low priority (Test Farm)
and the Frame generation row without a restart (Test Farm)
so, and the row without a restart (by hand)
Measurements
Verdict: a fix, measured: 29.8 % of the intervals on screen within 0.5 ms of 8.33 ms (26.5 to 33.6, four runs)
against 10.0 % on
main(7.3 to 12.3, six runs), their standard deviation 1.64 ms against 2.43, and the game frame onscreen 1.5 ms sooner after its present (median 21.16 against 22.68 ms). Not reached: 95 % within 0.5 ms, and a game
frame's two halves (game to generated frame, generated to game frame) within 0.2 ms of each other on average: -1.36
to +0.34 ms here, none of four runs; with #2184 too, three of four.
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(the default).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
mainwas left out: PresentMon saw 5309 of its 13240 frames composed by the desktop (Composed: Flip),not flipped straight to the display.
8aa749834What the low priority costs the game alone on the GPU, by
dev.py ab(this PR's pack andmain's on the same base,three interleaved pairs, 60 s of the frame trace each, in a window, DLSS Frame Gen 2x, uncapped with
HOS_FPS_MAX=1000, V-Sync off, Render resolution 67 %): no difference shown, 98.3 against 98.9 fps (the median ofthree runs;
main98.2 to 98.9, this PR 97.4 to 98.4), within the runs' spread. The logs said the replay's queue was atglobal priority low in this PR's three runs and in none of
main's. (dev.py abrefuses its write-up when the controlbridge's pipe name,
HOS_CONTROL, differs from run to run, as it does; these runs left it out with--allow HOS_CONTROL.)8aa74983Measured on
main8aa749834with this PR's commits on it (ccdeb469e). This PR is now onmaina2dc53859, its commits'changes the same (checked with
git range-diff) but intest_present_device_loss(the diagnosis commits: it now takesmain's list of the present routine's calls and adds the probe's to it), and, since, a line in the guide images'README.
main's commits since change neither the presents' timing, the queues nor the menu's restart rows; in therenderer, 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 and changes menu texts, 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.
RX_VK_QUEUE_PRIORITYships unset: the rule above decides, and the numbers above are that rule's.RX_VK_PRESENT_PROBEandRX_VK_PRESENT_QUEUE_PRIORITYcome with #2182's commits: diagnosis switches thatship unset (off).
Risks
60 fps cap and a synthetic compute load at 8 of 10 beside it, 42.7 β 25.0 fps (one pair, earlier build). A player who
streams or records on the same GPU may see it.
RX_VK_QUEUE_PRIORITY=0turns it off.rule (Still to test).
longshot_options.ini(no new key), the saves or the caches. A revert is enough.Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named).main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
mainand passes here.gpu/vk/switches.def.tests/that reads changed source is updated, not weakened.Assisted-by:/Co-Authored-By:trailers.No screenshots: the change is in the frames' timing, which a still picture does not show, and the Frame generation row
uses the menu's existing After restart / Restart needed lines. The guide's Graphics capture reviews six files this
changes (
scripts/check_guide_screenshots.py --review-sources): the capture makes no device and shows the compileddefaults, so the image is retained, and
docs/user/images/guide/README.mdrecords the review. That check fails onmainalready (ten files changed since the capture's reviewed revision); this adds three to its list(
gpu/vk/menu/framegen.cpp,gpu/vk/menu_restart.h,gpu/vk/vk_framegen.h).Ready to merge
main, measured again or a comment says why the numbers still hold.π€ Generated with Claude Code
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 against six of main: the log said the replay's queue was at global priority low, and 29.8 % of the intervals on screen were within 0.5 ms of 8.33 ms against 10.0 % on main. On earlier builds of this work, same PC: FSR 3.1 and Built-in frame generation, and the Frame generation row's restart through the control bridge (on to off and off to on said Restart needed and applied at the next start). No device was lost. The final head, on main
a2dc53859, ran again 30 s in a window: the replay's queue at global priority low, frame interpolation ready at 2x, no device lost.Possibly related, for context:
WIP: fix(vk): the replay's queue at global priority low with fixed frame generation on NVIDIA's Windows driverto fix(vk): the replay's queue at global priority low with fixed frame generation on NVIDIA's Windows driverView command line instructions
Checkout
From your project repository, check out a new branch and test the changes.