mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-16 18:09:58 -04:00
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>
63 lines
3.3 KiB
C
63 lines
3.3 KiB
C
// runtime/rtss_decide.h: the parts of RivaTuner Statistics Server's frame limiting (rtss_limit.c) that make no system
|
|
// call. Built and run by tests/rtss_limit_check.py on any system; prints each failed check and exits 1 on any.
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
|
|
#include "rtss_decide.h"
|
|
|
|
static int fails;
|
|
#define CHECK(c, ...) do { if (!(c)) { fails++; printf("FAIL line %d: ", __LINE__); printf(__VA_ARGS__); printf("\n"); } } while (0)
|
|
|
|
// RTSS's own settings: which of them hold the game's frames, and the log's text of them.
|
|
static void settings(void) {
|
|
RtssSettings none = {0, 1, 0, 0, 0, 0, 1, 1, 1};
|
|
CHECK(!rtss_settings_limit(&none), "no limit, no frame time limit, no scanline sync: RTSS holds nothing");
|
|
RtssSettings s = none;
|
|
s.limit = 50;
|
|
CHECK(rtss_settings_limit(&s), "a frame rate limit holds the frames");
|
|
s = none, s.time = 16667, s.time_den = 1;
|
|
CHECK(rtss_settings_limit(&s), "a frame time limit holds the frames");
|
|
s = none, s.scan0 = -40;
|
|
CHECK(rtss_settings_limit(&s), "scanline sync from the bottom holds the frames");
|
|
s = none, s.scan1 = 1;
|
|
CHECK(rtss_settings_limit(&s), "the second scanline sync holds the frames");
|
|
s = none, s.limit_den = 1000, s.time_den = 7;
|
|
CHECK(!rtss_settings_limit(&s), "denominators alone hold nothing");
|
|
CHECK(!rtss_settings_limit(&none), "display sync, Reflex sleep and passive wait alone hold nothing");
|
|
char text[192];
|
|
s = (RtssSettings){59940, 1000, 16667, 1, -40, 0, 1, 2, 0};
|
|
rtss_settings_text(text, sizeof text, &s, 0);
|
|
CHECK(!strcmp(text, "limit 59940/1000, frame time limit 16667/1, scanline sync -40/0"), "text: %s", text);
|
|
rtss_settings_text(text, sizeof text, &s, 1);
|
|
CHECK(!strcmp(text, "limit 59940/1000, frame time limit 16667/1, scanline sync -40/0, display sync 1, Reflex sleep 2, "
|
|
"passive wait 0"),
|
|
"text with the modes: %s", text);
|
|
char small[16], mid[70];
|
|
rtss_settings_text(small, sizeof small, &s, 1);
|
|
CHECK(strlen(small) == sizeof small - 1, "a short buffer is cut, not overrun");
|
|
rtss_settings_text(mid, sizeof mid, &s, 1);
|
|
CHECK(strlen(mid) == sizeof mid - 1 && !strncmp(mid, text, sizeof mid - 1), "the modes cut at the buffer's end");
|
|
}
|
|
|
|
// The kept-out reasons, for the log.
|
|
static void reasons(void) {
|
|
CHECK(!strcmp(rtss_out_text(RTSS_OUT_SETTING), "NX2NAVI_RTSS=0"), "the setting");
|
|
CHECK(!strcmp(rtss_out_text(RTSS_OUT_FRAMEGEN), "frame generation"), "frame generation");
|
|
CHECK(!strcmp(rtss_out_text(RTSS_OUT_LOWLAT), "the driver's low latency"), "low latency");
|
|
CHECK(!strcmp(rtss_out_limiter(RTSS_OUT_SETTING), "the game's limiter"), "the setting leaves the game's limiter");
|
|
CHECK(!strcmp(rtss_out_limiter(RTSS_OUT_LOWLAT), "the driver's low latency"), "low latency holds the frames");
|
|
CHECK(RTSS_UNSET < 0 && RTSS_OUT_SETTING < 0 && RTSS_OUT_FRAMEGEN < 0 && RTSS_OUT_LOWLAT < 0,
|
|
"every reason is below 0, where a limit never is");
|
|
CHECK(RTSS_UNSET != RTSS_OUT_SETTING && RTSS_UNSET != RTSS_OUT_FRAMEGEN && RTSS_UNSET != RTSS_OUT_LOWLAT &&
|
|
RTSS_OUT_SETTING != RTSS_OUT_FRAMEGEN && RTSS_OUT_FRAMEGEN != RTSS_OUT_LOWLAT &&
|
|
RTSS_OUT_SETTING != RTSS_OUT_LOWLAT,
|
|
"the reasons differ");
|
|
}
|
|
|
|
int main(void) {
|
|
settings();
|
|
reasons();
|
|
printf("rtss_limit_check: %s\n", fails ? "FAIL" : "ok");
|
|
return fails != 0;
|
|
}
|