diff --git a/runtime/cheats.c b/runtime/cheats.c index 031cd643..caa317fb 100644 --- a/runtime/cheats.c +++ b/runtime/cheats.c @@ -28,6 +28,7 @@ #include "input.h" #include "mods.h" #include "platform/platform.h" +#include "vk.h" #ifdef _WIN32 #define SEP "\\" @@ -505,8 +506,15 @@ static void rebuild_if_needed(const char *dir) { rt_log("cheats: the rebuild did not start; the game starts with the code it has"); return; } - prof_write(); // plat_exit runs no atexit handlers + // The orderly end's steps a start needs before the guest runs (gfx_present.c rt_exit_steps): no save is mounted + // and no menu has run, so the saves and nx2navi.ini have nothing to write. The prewarm builds meanwhile, so its + // crash marker and the boot's journal are put away: left in place, the next start took this end for a driver + // crash in the boot's builds (vk_pipeline.c pm_skipped, skip_init). + if (!rt_exit_begin()) plat_exit(0); rtss_limit_restore(); + vk_pipeline_prewarm_marker_clear(); + vk_pipeline_boot_abandon(); + prof_write(); // plat_exit runs no atexit handlers plat_exit(0); } diff --git a/runtime/vk.h b/runtime/vk.h index 0300d9cb..6121b845 100644 --- a/runtime/vk.h +++ b/runtime/vk.h @@ -1074,6 +1074,7 @@ void vk_pipeline_prewarm(void); // Ends the boot prebuild's crash marker (vk_pipeline.c, "boot prebuild crash marker"): boot_wait calls it when it lets // the game start while the prewarm goes on, so a crash in play is not taken for one in the boot's builds. void vk_pipeline_prewarm_marker_clear(void); +void vk_pipeline_boot_abandon(void); // an end before the guest starts that saves nothing: the boot's journal closed // boot_wait calls it when it lets the game start while the prewarm goes on: the builders of the whole warm after a // driver change (vk_pipeline.c bf_decide) go on as in play, at idle priority and in the background's numbers. void vk_pipeline_prewarm_detach(void); diff --git a/runtime/vk_pipeline.c b/runtime/vk_pipeline.c index 3fe6249f..139190a2 100644 --- a/runtime/vk_pipeline.c +++ b/runtime/vk_pipeline.c @@ -8978,6 +8978,10 @@ void vk_pipeline_save_exit(void) { save_with(SAVE_WAIT_MS, 1); } +// An orderly end before the guest starts that saves no pipelines (cheats.c's rebuild exit): the boot's journal closed +// as vk_pipeline_save_exit closes it, so the next start does not take the end for a driver crash in the library warm. +void vk_pipeline_boot_abandon(void) { journal_close(); } + // The memory report's figure for the pipeline caches the driver keeps in process memory (vk_pipeline_mem): the size of // each cache's data, asked once a minute here on the autosave thread, and by every save (cache_save_one). The size is // asked as the save asks it, at a moment no build runs into either cache (cache_rw, tried once and never waited for), diff --git a/tests/exit_order_check.py b/tests/exit_order_check.py index 434d0a59..53cda22b 100644 --- a/tests/exit_order_check.py +++ b/tests/exit_order_check.py @@ -1,7 +1,8 @@ """The orderly end of the process (runtime/gfx_present.c rt_exit_begin and rt_exit_steps): the steps run in one order, with what a kill of the process must not lose (a save Commit in flight, RivaTuner Statistics Server's profile, the controller's rumble, the settings, the frame-time summary) before the slow pipeline save and the final save flush -last; it runs once, and a second caller on another thread stays where it is. The frame-time summary of the exit +last; it runs once, and a second caller on another thread stays where it is. The cheats rebuild's end, before the +guest runs, puts away the boot prebuild's crash marker and journal (runtime/cheats.c rebuild_if_needed). The frame-time summary of the exit (runtime/perf.c ft_stop) waits for a present thread's update under way and keeps later ones out. Builds those functions into a test program against stand-ins, and checks statically that every orderly end goes through them. No game files. @@ -150,6 +151,16 @@ def static_checks(): print(f'{name}: {"rt_exit_begin, then " + steps + ", then plat_exit" if ok else "FAIL"}' + (f'; calls exit steps of its own: {", ".join(own)}' if own else ''), flush=True) bad += not ok + # the cheats rebuild's end, before the guest runs: the guard, RTSS, the boot's marker and journal, the summary + cheats = (RT / 'cheats.c').read_text(encoding='utf-8') + body = strip_comments(function(cheats, 'static void rebuild_if_needed(const char *dir)')) + tail = body[body.rfind('plat_spawn('):] + want = ['rt_exit_begin', 'rtss_limit_restore', 'vk_pipeline_prewarm_marker_clear', 'vk_pipeline_boot_abandon', + 'prof_write', 'plat_exit'] + pos = calls_in_order(tail, want[:-1]) + [tail.rfind('plat_exit(')] # the last plat_exit is the end's + ok = None not in pos and pos == sorted(pos) + print(f'cheats.c rebuild_if_needed: {", ".join(want)} in that order: {"ok" if ok else "FAIL " + str(pos)}', flush=True) + bad += not ok steps = function(gp, 'void rt_exit_steps(unsigned what)') pos = calls_in_order(steps, ['rtss_limit_restore', 'vk_pipeline_save_exit']) ok = None not in pos and pos[0] < pos[1]