Log RivaTuner Statistics Server's own settings for the game while it lists the game.

rtss_limit.c writes and reads back only FramerateLimit and FramerateLimitDenominator, but RTSS's [Framerate] section
holds more that limits or paces the frames: a frame time limit (LimitTime over LimitTimeDenominator), scanline sync
(SyncScanline0/1), display sync, its own Reflex sleep and passive waiting. A player with any of them set in Global gets
an RTSS that holds the game to more than the game's limit, and no log said so.

While RTSS lists the game, the worker's reader (read_settings, the system's ini reader on Profiles\<exe>.cfg, else
Profiles\Global, read again only when either file's write time changes) now also takes SyncDisplay, ReflexSleep and
PassiveWait, and watch logs "RivaTuner Statistics Server's settings for the game (<file>): limit L/D, frame time limit
T/TD, scanline sync S0/S1, display sync X, Reflex sleep R, passive wait P" once per change, 40 lines at most. It reads
only, makes no call into RTSS's hooks library and changes nothing RTSS or the game does; whether the game should keep
RTSS out when one of these is set is left for approval.

Not reproduced before the change: it needs RTSS's settings in a play-test. tests/rtss_limit_check.c checks the text
with and without the modes and that a short buffer cuts it; tests/rtss_worker_check.c gains settings_logged (nothing
read while the game is not listed, then one line for the game's profile with what it took from Global, and one more
after the limit changes). Both pass, with a compile of every runtime file; -Wall adds no warning.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
chrg6
2026-11-13 17:19:31 -05:00
parent 6be25cc978
commit ecbd49441b
4 changed files with 80 additions and 24 deletions

View File

@@ -30,16 +30,22 @@ static inline const char *rtss_out_limiter(int64_t want) {
// RTSS's own [Framerate] settings for the game, as its profile file holds them (rtss_limit.c read_settings): a frame
// rate limit (Limit over LimitDenominator), a frame time limit (LimitTime over LimitTimeDenominator) and scanline sync
// (SyncScanline0 and SyncScanline1); 0 is off for each.
// (SyncScanline0 and SyncScanline1), 0 off for each; and the modes beside them, for the log: SyncDisplay, ReflexSleep
// and PassiveWait.
typedef struct {
int limit, limit_den, time, time_den, scan0, scan1;
int sync_display, reflex_sleep, passive_wait;
} RtssSettings;
// RTSS holds the game's frames by a setting of its own.
static inline int rtss_settings_limit(const RtssSettings *s) { return s->limit || s->time || s->scan0 || s->scan1; }
// "limit L/D, frame time limit T/TD, scanline sync S0/S1", the values as the file holds them.
static inline void rtss_settings_text(char *out, size_t n, const RtssSettings *s) {
snprintf(out, n, "limit %d/%d, frame time limit %d/%d, scanline sync %d/%d", s->limit, s->limit_den, s->time,
s->time_den, s->scan0, s->scan1);
// "limit L/D, frame time limit T/TD, scanline sync S0/S1", and with modes ", display sync X, Reflex sleep R, passive
// wait P": the values as the file holds them.
static inline void rtss_settings_text(char *out, size_t n, const RtssSettings *s, int modes) {
int k = snprintf(out, n, "limit %d/%d, frame time limit %d/%d, scanline sync %d/%d", s->limit, s->limit_den, s->time,
s->time_den, s->scan0, s->scan1);
if (modes && k >= 0 && (size_t)k < n)
snprintf(out + k, n - (size_t)k, ", display sync %d, Reflex sleep %d, passive wait %d", s->sync_display,
s->reflex_sleep, s->passive_wait);
}

View File

@@ -255,7 +255,7 @@ static const char *fail_reason(int f) {
// RTSS's own settings for the game, read from its profile file as RTSS keeps it: Profiles\<exe>.cfg, else
// Profiles\Global, and a key the game's profile lacks from Global. The system's ini reader does it, so no call goes into
// RTSS's hooks library, which a run that keeps RTSS out never loads. The files are read again only when the time
// either was written changes. Worker thread only.
// either was written changes. Worker thread only, while RTSS lists the game (watch).
static RtssSettings settings;
static char settings_file[MAX_PATH + 16]; // which file they came from, as Profiles\<name>
@@ -283,23 +283,35 @@ static void read_settings(void) {
const char *p = a ? own : NULL;
settings = (RtssSettings){cfg_int(p, global, "Limit"), cfg_int(p, global, "LimitDenominator"),
cfg_int(p, global, "LimitTime"), cfg_int(p, global, "LimitTimeDenominator"),
cfg_int(p, global, "SyncScanline0"), cfg_int(p, global, "SyncScanline1")};
cfg_int(p, global, "SyncScanline0"), cfg_int(p, global, "SyncScanline1"),
cfg_int(p, global, "SyncDisplay"), cfg_int(p, global, "ReflexSleep"),
cfg_int(p, global, "PassiveWait")};
if (a) snprintf(settings_file, sizeof settings_file, "Profiles\\%s.cfg", profile);
else snprintf(settings_file, sizeof settings_file, "Profiles\\Global");
}
// While RTSS is kept out (w < 0) the game's own limiter, the driver's low latency or frame generation holds the frames,
// and a limit the player set in RTSS itself for the game (its global profile or the game's own, a frame time limit or
// scanline sync) still holds them a second time. Logged once per change and shown in the menu (rtss_limit_state 4).
// While RTSS lists the game, the settings it holds for it are logged once per change: what RTSS applies may be more than
// the FramerateLimit the game writes (a frame time limit, scanline sync, its own Reflex). While RTSS is kept out
// (w < 0) the game's own limiter, the driver's low latency or frame generation holds the frames, and a limit the player
// set in RTSS itself for the game (its global profile or the game's own, a frame time limit or scanline sync) still
// holds them a second time. Logged once per change and shown in the menu (rtss_limit_state 4).
static void watch(int64_t w, int listed) {
static int said, lines;
static char said_text[128];
static int said, lines, settings_lines;
static char said_text[128], said_settings[MAX_PATH + 256];
int on = 0;
char text[128] = "";
if (w < 0 && listed) {
if (listed) {
read_settings();
char all[MAX_PATH + 256], modes[192];
rtss_settings_text(modes, sizeof modes, &settings, 1);
snprintf(all, sizeof all, "(%s): %s", settings_file, modes);
if (strcmp(all, said_settings) && settings_lines++ < 40)
rt_log("frame rate: RivaTuner Statistics Server's settings for the game %s", all);
snprintf(said_settings, sizeof said_settings, "%s", all);
}
if (w < 0 && listed) {
on = rtss_settings_limit(&settings);
rtss_settings_text(text, sizeof text, &settings);
rtss_settings_text(text, sizeof text, &settings, 0);
}
if (w >= 0) said = 0; // a later kept-out want logs afresh
else if (on != said || (on && strcmp(text, said_text))) {