mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-17 07:09:57 -04:00
Record the game's time step at every present in the flight recorder: the patch page's step, the time manager's and the game's present count.
frames.tsv gains step_frames, game_step_frames and guest_presents. The game writes its step at its own present, a frame or two before the replay presents that frame, so the present count is there to line the two up. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// NX2NAVI_FLIGHT=1 flight recorder: a ring of the last NX2NAVI_FLIGHT_FRAMES (600) presents, one record each (interval,
|
||||
// render-thread blocked time per perf kind, event counts) and a 320x180 thumbnail each (gfx_present.c, blitted on the
|
||||
// render-thread blocked time per perf kind, event counts, the game's time step) and a 320x180 thumbnail each (gfx_present.c, blitted on the
|
||||
// GPU by the present thread). A dump goes to <dir>/<YYYYMMDD-HHMMSS>-f<frame>/: events.tsv (the texture events of its
|
||||
// frames, flight_tex), f<frame>.png per thumbnail and frames.tsv, written in that order by a background thread. Triggers: F8 while the game window has focus, a frame interval over
|
||||
// NX2NAVI_FLIGHT_SPIKE_MS (100; 0 off; at most one dump per 10 s), NX2NAVI_FLIGHT_AT=<frame>[,<frame>...] and
|
||||
@@ -38,6 +38,8 @@ _Static_assert(PERF_CNT_N == 12, "count_names follows the PERF_CNT_* list");
|
||||
typedef struct {
|
||||
uint64_t frame, t_ns;
|
||||
uint32_t interval_us, blocked_us[PERF_N], n[C_N];
|
||||
float step_page, step_game; // frame_step_flight: the step in 60 Hz frames on the patch page and in the game
|
||||
uint64_t guest_presents; // the game's presents so far, which the two steps belong to
|
||||
} Rec;
|
||||
|
||||
// A texture event (flight_tex). seq is the event's index + 1 once it is written, 0 while a writer fills the slot, so
|
||||
@@ -365,12 +367,13 @@ static void dump_main(void *arg) {
|
||||
fprintf(f, "frame\tt_ms\tinterval_ms");
|
||||
for (int k = 0; k < PERF_N; k++) fprintf(f, "\t%s", blocked_names[k]);
|
||||
for (int k = 0; k < C_N; k++) fprintf(f, "\t%s", count_names[k]);
|
||||
fprintf(f, "\tthumb\n");
|
||||
fprintf(f, "\tstep_frames\tgame_step_frames\tguest_presents\tthumb\n");
|
||||
for (int i = 0; i < j->n; i++) {
|
||||
const Rec *r = &j->r[i];
|
||||
fprintf(f, "%llu\t%.1f\t%.2f", (unsigned long long)r->frame, r->t_ns / 1e6, r->interval_us / 1000.0);
|
||||
for (int k = 0; k < PERF_N; k++) fprintf(f, "\t%.2f", r->blocked_us[k] / 1000.0);
|
||||
for (int k = 0; k < C_N; k++) fprintf(f, "\t%u", r->n[k]);
|
||||
fprintf(f, "\t%.4f\t%.4f\t%llu", r->step_page, r->step_game, (unsigned long long)r->guest_presents);
|
||||
fprintf(f, "\t%d\n", have ? have[i] : 0);
|
||||
}
|
||||
fclose(f);
|
||||
@@ -440,6 +443,7 @@ void flight_frame(uint64_t frame, uint64_t now_ns, uint64_t interval_ns, const u
|
||||
r->n[C_PERF0 + k] = (uint32_t)(v - prev_cnt[k]);
|
||||
prev_cnt[k] = v;
|
||||
}
|
||||
frame_step_flight(&r->step_page, &r->step_game, &r->guest_presents);
|
||||
recorded++;
|
||||
|
||||
static int key_was;
|
||||
|
||||
@@ -361,6 +361,18 @@ static double ocarina_step_s(void) {
|
||||
return base * speed / 60.0;
|
||||
}
|
||||
|
||||
static _Atomic uint64_t guest_presents; // frame_step_present calls so far (frame_step_flight)
|
||||
|
||||
// The flight recorder's view of the step at a host present (flight.c, render thread): the newest step the patch page
|
||||
// holds in 60 Hz frames per update (set ostep; -1 without), the game's own step from its time manager in 60 Hz frames
|
||||
// (-1 unknown or not free-running), and the game's presents so far, which name the update those two belong to.
|
||||
void frame_step_flight(float *page, float *game, uint64_t *presents) {
|
||||
*page = ostep_page ? frame_step_frames() : -1.0f;
|
||||
double s = frame_free_running() ? ocarina_step_s() : -1;
|
||||
*game = s > 0 ? (float)(s * 60.0) : -1.0f;
|
||||
*presents = atomic_load_explicit(&guest_presents, memory_order_relaxed);
|
||||
}
|
||||
|
||||
// Free-running builds (Ocarina): the game's step follows the display interval (ocarina_step, in 60 Hz frames), written
|
||||
// at each present: frames per update on the patch page with the set ostep, else the time manager's base step. The
|
||||
// game left it at one 60 Hz frame whatever the frame rate, so at 144 fps it ran 2.4 times too fast.
|
||||
@@ -605,6 +617,7 @@ static void world_clock(double dt, double step) {
|
||||
}
|
||||
|
||||
void frame_step_present(uint64_t display_ns, int interval) {
|
||||
atomic_fetch_add_explicit(&guest_presents, 1, memory_order_relaxed);
|
||||
game_interval = interval > 0 ? interval : 1;
|
||||
frame_limit_live();
|
||||
double step = 0, dt = last_ns ? (double)(display_ns - last_ns) * 1e-9 : 0;
|
||||
|
||||
@@ -394,6 +394,7 @@ int frame_free_running(void); // no fps60/realtime p
|
||||
double frame_step_limit_hz(void); // the frame rate the limit gives (overlay); 0 unknown
|
||||
double frame_step_game_hz(void); // the rate the game draws at under the limit; 0 unknown
|
||||
float frame_step_frames(void); // the 60 Hz frames the game steps per update (set ostep), else 1
|
||||
void frame_step_flight(float *page, float *game, uint64_t *presents); // flight.c: the step at a host present
|
||||
// rtss_limit.c: RivaTuner Statistics Server takes the frame limit where it runs
|
||||
void rtss_limit_want(int64_t mhz); // the pacer's limit in millihertz: >0, 0 none, -1 keep RTSS out
|
||||
int rtss_limit_active(void); // RTSS limits to the wanted rate: the pacer holds no frames
|
||||
|
||||
Reference in New Issue
Block a user