mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-17 07:09:57 -04:00
Stop a second copy of the game before the shader prewarm, not after it.
The one-game-per-profile lock was taken at the first storage use, after the boot prewarm. A second copy started while the game ran (a second Play, a shortcut) spent 14 to 30 s translating and building on every core and committed about 10.9 GB before it ended with "another copy of the game is running", enough to bring a 48 GB machine to its commit limit and stall the copy being played. rt_boot now takes the lock first; storage_init takes it again, which plat_lock_file answers from the handle it already holds. A restart from the settings menu is unaffected: main waits for the previous process to exit before rt_boot.
This commit is contained in:
committed by
chrg6
parent
9bba578e58
commit
59069502f3
@@ -395,6 +395,7 @@ static void boot_wait(PlatThread *warm, uint64_t cap_ms) {
|
||||
|
||||
void rt_boot(void) {
|
||||
check_npdm();
|
||||
fs_host_lock_profile(); // a second copy of the game stops here, before the prewarm below
|
||||
if (!rt_config()->shot) vk_pipeline_async_enable(); // a --shot image must not depend on build timing
|
||||
// Shaders and pipelines recorded in earlier runs are made ready while the modules load; the guest waits for them.
|
||||
PlatThread *warm = plat_thread_new(prewarm_main, NULL, "prewarm");
|
||||
|
||||
@@ -57,6 +57,8 @@ void fs_trace(const char *what, const char *path); // NX2NAVI_TRACE=fs:
|
||||
// ---- fs_host.c
|
||||
void fs_host_set_profile(const char *dir); // profile directory; before the first storage mount only
|
||||
// (default rt_config()->profile)
|
||||
void fs_host_lock_profile(void); // the one-game-per-profile lock; fatal when another copy
|
||||
// holds it (rt_boot, before the prewarm; storage_init)
|
||||
int fs_save_busy(void); // a save is being written: a save file open for writing,
|
||||
// or save data changed in the last 3 s and not committed
|
||||
void fs_save_flush(void); // wait for a save Commit still running in the background;
|
||||
|
||||
@@ -619,19 +619,27 @@ static uint32_t save_commit(void) {
|
||||
}
|
||||
|
||||
// ---- storage roots
|
||||
static void storage_init(void *param) {
|
||||
(void)param;
|
||||
// One game per profile: a second one's start would take the first one's commit in progress for an interrupted one
|
||||
// and delete it, and both would write into one working copy (save-tx/work), losing or mixing their saves. rt_boot
|
||||
// takes the lock before the shader prewarm, so a second copy ends at once instead of after the prewarm's seconds of
|
||||
// work on every core and the gigabytes of memory it commits; storage_init takes it again (plat_lock_file keeps one
|
||||
// handle per path, so the second call holds it already).
|
||||
void fs_host_lock_profile(void) {
|
||||
if (!*profile)
|
||||
need(snprintf(profile, sizeof profile, "%s", rt_config()->profile) < (int)sizeof profile, "profile path");
|
||||
uint64_t uid[2];
|
||||
char p[PATH_CAP];
|
||||
make_dirs(profile);
|
||||
// One game per profile: a second one's start would take the first one's commit in progress for an interrupted
|
||||
// one and delete it, and both would write into one working copy (save-tx/work), losing or mixing their saves.
|
||||
snprintf(p, sizeof p, "%s/instance.lock", profile);
|
||||
int held = plat_lock_file(p);
|
||||
if (!held) rt_fatal("fs: another copy of the game is running with the profile %s; close it first", profile);
|
||||
if (held < 0) rt_log("fs: cannot make %s; a second copy of the game would not be stopped", p);
|
||||
}
|
||||
|
||||
static void storage_init(void *param) {
|
||||
(void)param;
|
||||
uint64_t uid[2];
|
||||
char p[PATH_CAP];
|
||||
fs_host_lock_profile();
|
||||
account_uid(uid);
|
||||
snprintf(p, sizeof p, "%s/save", profile);
|
||||
make_dirs(p);
|
||||
|
||||
Reference in New Issue
Block a user