diff --git a/README.md b/README.md index c401049a..4be87aa3 100644 --- a/README.md +++ b/README.md @@ -38,10 +38,10 @@ Report problems as issues, following [CONTRIBUTING.md](CONTRIBUTING.md). display; in a window of another shape than the picture, frames are generated inside the picture only, so the black bars stay clean. The frame limit counts the frames the game draws, and frame generation adds its frames on top of it. The frame limit can also be - handed to RivaTuner Statistics Server, which then limits the game in its place: one limiter at a time, and the - game takes the limit back while a movie plays, while it is minimised and whenever RivaTuner is not seen holding it; - where frame generation or low latency keeps it out, the game says when a limit set in RivaTuner itself holds the - game as well + handed to RivaTuner Statistics Server, which then limits the game in its place once it is seen holding the game; + the game paces movies itself, and takes the limit back while it is minimised and whenever RivaTuner is not seen + holding it; where frame generation or low latency keeps it out, the game says when a limit set in RivaTuner itself + holds the game as well - HDR on HDR displays, two kinds: the game's scene tone mapped to the display's peak, matched to the game's mid grey and tone, with true blacks, or the game's own native HDR; peak, game and HUD brightness in the menu - The game's known shaders prepared when the game is built, and the pipelines met in play built again in the background at each start, so play rarely stops to compile them; a shader or pipeline met for the first time can diff --git a/docs/architecture.md b/docs/architecture.md index bc8b3214..c52680ee 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -264,8 +264,9 @@ keeps per-core data without locks and relies on that, so the host models it (`ru the game's code needs (`rtss_decide.h` `rtss_pace_period`). Frame generation keeps RTSS out (it would count the generated frames), and the game's pacer holds the drawn frames beside it. The exceptions as they stand: `pace_smooth` still waits on the present thread while RTSS holds the limit; DLSS Frame Generation's Reflex sleeps where the frame - starts while the pacer holds the limit; and a limit set in RTSS itself still holds the game where the game keeps RTSS - out, which the log ("two limiters") and the + starts while the pacer holds the limit; at a play limit equal to a movie's rate (60, the default, for the game's 60 + fps movies) RTSS's profile keeps that limit and RTSS holds the movie beside the pacer; and a limit set in RTSS itself + still holds the game where the game keeps RTSS out, which the log ("two limiters") and the frame rate row of the menu point out, and the same where RTSS is out of it for the run because its profile cannot be written or its hooks library does not load, which the log points out the same way (the menu shows the administrator note for the first and nothing for the second). @@ -276,8 +277,10 @@ keeps per-core data without locks and relies on that, so the host models it (`ru from the saved file; a fractional rate over a denominator where RTSS knows one, else rounded down to whole frames) once the first picture went out and the limit stayed the same for two polls, so a want that flips (low latency at a swapchain rebuild) writes nothing. A movie leaves the play limit in the profile; only a play limit below the movie's - rate gives the profile no limit for the movie's length, so that RTSS does not space out the frames the pacer sends at - once to catch up. The pacer stands aside (`rtss_limit_active`) only once RTSS is seen holding the game: it lists the + rate gives the profile no limit for the movie's length, so that RTSS does not hold the movie below its rate. Above + the movie's rate RTSS lets the frames the pacer sends at once after a late frame through faster than the movie runs; + at the movie's own rate (a limit of 60) whether RTSS spaces them out, and the picture falls behind the sound, is not + measured. The pacer stands aside (`rtss_limit_active`) only once RTSS is seen holding the game: it lists the process with its Vulkan presents, has read the profile (its update flag clear) and measured a period of the game's frames lately, no movie plays and a picture went out within 200 ms. The pacer keeps the limit while RTSS does not run or has not hooked the game, for a limit RTSS refuses, and for the rest of the run when the profile cannot be written diff --git a/runtime/rtss_decide.h b/runtime/rtss_decide.h index 6e43f608..97c6bbf5 100644 --- a/runtime/rtss_decide.h +++ b/runtime/rtss_decide.h @@ -138,9 +138,13 @@ typedef struct { // What the profile gets for a want w >= 0 (the play limit: frame_rate.c frame_step_cap_ns wants it through a movie // too) while a movie plays at movie_mhz: w, so that a movie no longer rewrites the profile at its start and end; but no -// limit (0) while the movie runs faster than w (a limit of 30, 40 or 45). The game's pacer holds every movie at its -// rate and keeps its slots through a late frame (nvn_api_obj.c pace); RTSS at the movie's rate or below would space out -// the frames that catch up, and the picture would fall behind the sound at each late frame for good. +// limit (0) while the movie runs faster than w (a limit of 30, 40 or 45), where RTSS would hold the movie below its +// rate. The game's pacer holds every movie at its rate and keeps its slots through a late frame (nvn_api_obj.c pace), +// sending the frames that catch up at once. Above the movie's rate RTSS lets them through faster than the movie runs. +// At the movie's own rate (a limit of 60 for the game's 60 fps movies, the default) the profile keeps that rate, and +// RTSS holds the movie beside the pacer for its length: whether RTSS's limiter then spaces out the frames that catch +// up, so that the picture falls behind the sound at each late frame, is not measured. Giving the profile no limit there +// too would cost two profile writes per movie at the default limit. static inline int64_t rtss_target(int64_t w, int64_t movie_mhz) { return w > 0 && movie_mhz > w ? 0 : w; } // The profile's FramerateLimit and FramerateLimitDenominator for mhz (>= 0): a whole rate over 1, a fraction over 1000 @@ -298,8 +302,8 @@ static inline void rtss_why_text(char *out, size_t n, const RtssOut *o, int fail // ---- the game's pacer beside RTSS (frame_rate.c frame_step_cap_ns) // The period the pacer keeps (now_ns and hosted_ns are kern_now_ns times; hosted_ns of the newest host present, // gfx_present.c gfx_window_hosted_ns, 0 before the first). The limit's own period while RTSS does not hold the game, -// while a movie plays (from its first frame: the pacer keeps the movie's slots, which RTSS does not know, and the -// worker's next poll gives the movie to the pacer for its length, rtss_target), before the first host present, and +// while a movie plays (from its first frame: the pacer keeps the movie's slots, which RTSS does not know; rtss_target +// says what RTSS's profile holds meanwhile), before the first host present, and // once no host present went out for RTSS_HOLD_IDLE_NS: a minimised window or a frame hold (vk_backend.c frame_hold) // gives RTSS nothing to hold, and a pacer that held nothing then let the quick menu run at the 640-700 fps that read // address 0 (frame_rate.c LIMIT_FREE_MAX_HZ). While RTSS holds, the ceiling's period and never 0: the frames RTSS lets diff --git a/tests/rtss_limit_check.c b/tests/rtss_limit_check.c index 3f74fec5..29ce53cb 100644 --- a/tests/rtss_limit_check.c +++ b/tests/rtss_limit_check.c @@ -428,7 +428,7 @@ static void churn(void) { // A movie under RTSS: the want stays the play limit and the game's pacer holds the movie. At a limit of 144 the profile // keeps 144 through it, with no write; under the movie's rate (40) the profile has no limit for the movie's length, so -// RTSS cannot space out the frames that catch up after a late one, and gets 40 back at its end. +// RTSS does not hold the movie below its rate, and gets 40 back at its end; at the movie's own rate (60) it keeps 60. static void movie(void) { Run r; run_init(&r); @@ -458,6 +458,18 @@ static void movie(void) { "40 back at its end"); o = step(&r, 40000); CHECK(o.holds, "held from the next poll"); + // at the movie's own rate (60, the default limit) the profile keeps 60 through the movie, with no write: RTSS holds + // the movie beside the pacer, as rtss_target says + run_init(&r); + step(&r, 60000); + step(&r, 60000); + r.movie_mhz = 60000; + for (int i = 0; i < 5; i++) o = step(&r, 60000); + CHECK(o.act == RTSS_DO_NOTHING && !o.holds && o.why == RTSS_WHY_MOVIE && r.st.applies == 1 && r.st.holds == 60000, + "a movie at 60: no write, the profile keeps 60"); + r.movie_mhz = 0; + o = step(&r, 60000); + CHECK(o.holds && r.st.applies == 1, "held again after it, no write"); CHECK(rtss_target(60000, 60000) == 60000 && rtss_target(59940, 60000) == 0 && rtss_target(0, 60000) == 0 && rtss_target(144000, 0) == 144000 && rtss_target(RTSS_OUT_LOWLAT, 60000) == RTSS_OUT_LOWLAT, "rtss_target");