Keep the 240 ceiling while RivaTuner Statistics Server holds the limit, and take the limit back after 200 ms with no host present.

frame_step_cap_ns returned 0 once RTSS held the limit, so pace() set each slot to now and the acquire never waited.
RTSS holds frames inside the host present, and a minimised window (gfx_present.c present_image skips the present) or
a frame hold gives it none to hold: the game then ran with no limiter but pace_smooth's floor, which follows the
intervals down, and the quick menu is where 640-700 fps read address 0 (frame_rate.c LIMIT_FREE_MAX_HZ).
gfx_present.c flip_locked now stores the time of each host present that took its picture (gfx_window_hosted_ns), and
rtss_decide.h rtss_pace_period gives the pacer the limit's period before the first host present and once none went
out for 200 ms (as vk_lowlat.c HOLD_IDLE_NS), and the 240 ceiling's period, never 0, while RTSS holds. The frames RTSS
lets through come further apart than the ceiling, so pace() waits for none of them; no new wait site.

Not reproduced before the change. frame_step_check (new cases: holding with a host present 10 and 199 ms ago, 250 ms
ago, none yet, not holding, 144 minimised, unlimited) and rtss_limit_check (rtss_pace_period) pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
chrg6
2026-11-13 18:55:40 -05:00
parent 1f547853e3
commit 27a034e946
6 changed files with 73 additions and 6 deletions

View File

@@ -39,7 +39,10 @@ int vk_dlssg_multiplier(void) { return fg_mult; }
int vk_dlssg_active(void) { return fg_mult > 1; }
int vk_lowlat_on(void) { return 0; }
void rtss_limit_want(int64_t millihz) { (void)millihz; }
int rtss_limit_active(void) { return 0; }
static int rtss_holds; // RivaTuner Statistics Server holds the game to the want (rtss_limit.c)
static uint64_t kern_ns, hosted; // kern_now_ns, and its time at the newest host present (0: none yet)
int rtss_limit_active(void) { return rtss_holds; }
uint64_t gfx_window_hosted_ns(void) { return hosted; }
// The time manager the sound job's gate reads its step from (frame_rate.c sound_job_step), while the sound checks run:
// [main+0x4c7e890] holds the slot, the slot the manager, the manager +0x10 the step. Nothing else reads.
static int fake_manager;
@@ -67,7 +70,7 @@ int mem_copy_readable(uint8_t *const *dst, const uint64_t (*src)[2], int n, uint
(void)dst, (void)src, (void)n, (void)ok;
return 0;
}
uint64_t kern_now_ns(void) { return 0; }
uint64_t kern_now_ns(void) { return kern_ns; }
// the floor watch (off here)
int floor_watch_wanted(void) { return 0; }
int floor_watch_found(const uint64_t *addr, const float *val, const int *unit, int n, const float link[3]) {
@@ -280,6 +283,29 @@ int main(int argc, char **argv) {
}
fg_mult = 1;
// RivaTuner Statistics Server holds the limit: the pacer keeps the 240 ceiling while host presents go out, and the
// limit's own period before the first host present and once none went out for 200 ms (a minimised window, a frame
// hold), when RTSS has nothing to hold.
{
static const struct { const char *l; int holds; uint64_t hosted_ago; double hz; const char *what; } cases[] = {
{"60", 1, 10000000, 240, "RTSS holds, a host present 10 ms ago: the ceiling alone"},
{"60", 1, 199000000, 240, "199 ms ago: still RTSS's"},
{"60", 1, 250000000, 60, "250 ms ago: the limit back"},
{"60", 1, 0, 60, "no host present yet: the limit"},
{"60", 0, 10000000, 60, "RTSS does not hold: the limit"},
{"144", 1, 250000000, 144, "144, minimised: 144"},
{"unlimited", 1, 10000000, 240, "unlimited, RTSS holds: the ceiling is the limit"}};
kern_ns = 50000000000ull;
for (unsigned i = 0; i < sizeof cases / sizeof *cases; i++) {
set_limit(cases[i].l);
rtss_holds = cases[i].holds;
hosted = cases[i].hosted_ago ? kern_ns - cases[i].hosted_ago : 0;
double hz = 1e9 / (double)frame_step_cap_ns();
CHECK(fabs(hz - cases[i].hz) < 0.01, "%s: paces at %.3f fps, not %.0f", cases[i].what, hz, cases[i].hz);
}
rtss_holds = 0, hosted = kern_ns = 0;
}
// The water's ripples at 144 fps, a step of 60/144 frame: 64 water objects asked once a frame each run 600 steps
// in 1440 frames (the cut gave none), and the day's seconds asked between them keep their own fraction.
{