Hold each frame's start in the driver while low latency is on, and let that keep the frame limit.

The driver's sleep sits where the game's frame starts: at its first pad read or window image acquire after a present,
whichever comes first, before the input is sampled. The frame's number, the count of the game's presents, goes with
its work: the guest thread marks the simulation and the first submission, the replaying thread tags its queue
submissions and marks their end, and the present thread marks the host present, which carries the number too. The
window's swapchain is made with the latency mode while NVIDIA's path is on, and remade when the setting changes.

While the mode is in effect the pacer holds nothing, so a picture goes out as soon as it is drawn and the limit is
kept by the driver before the pad is read; RivaTuner Statistics Server is kept out as with frame generation. The pacer
takes the limit back while a movie plays, while no host present goes out, and for the rest of the run when the frames
show the driver does not hold it. With the mode off every hook returns at its first check.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
chrg6
2026-11-12 22:28:32 -05:00
parent 2f30f1a2e5
commit c37fb7dc40
8 changed files with 86 additions and 5 deletions

View File

@@ -893,6 +893,11 @@ NVN_API(nvnQueuePresentTexture) {
}
if (hitch_every && o->presents % (uint64_t)hitch_every == 0) plat_wait_ns((uint64_t)hitch_ms * 1000000);
uint64_t period = present_period(o), now = kern_now_ns();
// A driver's low-latency sleep (vk_lowlat.c) holds the next frame to the period where the frame starts, before
// its pad read, so this pacer holds nothing: the present goes out as soon as it is drawn and the image is free at
// once. A wait here as well would be a second one, after the picture is drawn. Not while a movie plays: its slots
// are kept through a late frame (pace), which only this pacer does, so the back end is told there is no period.
if (gfx_backend()->frame_paced && gfx_backend()->frame_paced(frame_step_movie_hz() > 0 ? 0 : period)) period = 0;
uint64_t slot = now + pace(&o->pace, now, period);
gfx_backend()->present(t, o->crop, slot);
o->ticket[idx] = o->presents;