From 46a3b64895270883135d18b54887953149ccf182 Mon Sep 17 00:00:00 2001 From: Valiantsin Dzerakh Date: Tue, 3 Nov 2026 20:31:11 +0300 Subject: [PATCH] Keep the console at start: until the game window opens it shows the shader prewarm d2fbe0a freed the console as soon as the log file was open, but the game window only opens after the shader prewarm. After an update the prewarm translates every shader again (about 5 minutes on a 24-thread CPU), and the player saw neither a console nor a window all that time. The console release and show_console are taken back; the window is still raised at start (#521). Co-Authored-By: Claude Opus 5.5 --- runtime/cfg.c | 6 +++--- runtime/main.c | 4 ---- runtime/platform/linux.c | 2 -- runtime/platform/platform.h | 5 ----- runtime/platform/win32.c | 11 ----------- totk.ini.example | 4 ---- 6 files changed, 3 insertions(+), 29 deletions(-) diff --git a/runtime/cfg.c b/runtime/cfg.c index 1425d1fd..c5ed0d21 100644 --- a/runtime/cfg.c +++ b/runtime/cfg.c @@ -53,7 +53,7 @@ static const char *const known[] = { "REPLAY_CHECK", "RESOLVE_CHECK", "RESTART_WAIT", "ROMFS", "ROMFS_INDEX", "ROMFS_MMAP", "ROMFS_MODS", "ROMFS_PATCHES", "ROMFS_PROOF_DIR", "ROMFS_VERIFY", "RSTICK_DEADZONE", "RUMBLE", "RUMBLE_CURVE", "RUMBLE_STRENGTH", "RUMBLE_TRIGGERS", "SHADER_CACHE", "SHADER_MEMO", "SHADOW_RANGE", "SHADOW_RES", "SHADOW_SCALE", "SHARED_FONTS", "SHARPNESS", "SHOTS", "SHOTS_DIR", - "SHOTS_FULL", "SHOW_CONSOLE", "SPEED_PROBE", "SPIN", "SPIN_HANDOFF_US", "SPLIT_DRAWS", "SPLIT_US", "STICK_DEADZONE", "STICK_SENS", + "SHOTS_FULL", "SPEED_PROBE", "SPIN", "SPIN_HANDOFF_US", "SPLIT_DRAWS", "SPLIT_US", "STICK_DEADZONE", "STICK_SENS", "SWKBD_ANSWER", "SWKBD_TEST", "TEST_PAD", "TEST_PREPARE_SHADERS", "TEX_ALIAS", "TEX_MEMO", "TEX_VRAM_PRESSURE", "TIMER_1MS", "TRACE", "TXD_TRANSPOSE", "UBO_SNAPSHOT", "UPSCALER", "VK_DYN_A2C", "VK_DYN_VERTEX", "VK_NO_FLOAT64", "VK_PRESENT", "VK_RECORDER", "VK_SSBO_ALIGN", "VK_SUBGROUP", "VK_SUBGROUP_PIN", "VK_VALIDATION", "VOLUME", "VRAM_HEADROOM", "VS_OUTS", @@ -99,7 +99,7 @@ static const struct { const char *key, *section; } sections[] = { {"PUSH_SKIP", "performance"}, {"SPLIT_DRAWS", "performance"}, {"SPLIT_US", "performance"}, {"VK_VALIDATION", "performance"}, {"VK_DYN_VERTEX", "performance"}, {"VK_DYN_A2C", "performance"}, {"VK_SUBGROUP_PIN", "performance"}, {"TRACE", "diagnostics"}, {"FLIGHT", "diagnostics"}, {"PASS_CRUMBS", "diagnostics"}, {"FLIGHT_SPIKE_MS", "diagnostics"}, - {"WB_FENCE_LIMIT", "diagnostics"}, {"WB_EXACT", "diagnostics"}, {"SHOW_CONSOLE", "diagnostics"}, + {"WB_FENCE_LIMIT", "diagnostics"}, {"WB_EXACT", "diagnostics"}, {"MV_SURVEY", "diagnostics"}, }; @@ -177,7 +177,7 @@ static const CfgMeta metas[] = { {"VK_DYN_A2C", "", "0|1", RESTART}, {"VK_SUBGROUP_PIN", "1", "0|1", RESTART}, // diagnostics {"TRACE", "", NULL, RESTART}, {"FLIGHT", "0", "0|1", RESTART}, {"FLIGHT_SPIKE_MS", "100", "0..60000", RESTART}, - {"SHOW_CONSOLE", "0", "0|1", RESTART}, {"WB_FENCE_LIMIT", "65536", "0..1073741824", RESTART}, {"WB_EXACT", "1", "0|1", RESTART}, + {"WB_FENCE_LIMIT", "65536", "0..1073741824", RESTART}, {"WB_EXACT", "1", "0|1", RESTART}, {"PASS_CRUMBS", "", "0|1", RESTART}, // vk_crumbs.c pass marks; unset: VK_AMD_buffer_marker only {"INPUT_RECORD", "", NULL, RESTART}, }; diff --git a/runtime/main.c b/runtime/main.c index 3930b770..01b1ffda 100644 --- a/runtime/main.c +++ b/runtime/main.c @@ -547,10 +547,6 @@ int main(int argc, char **argv) { if (cfg.seconds && mode) return usage(argv[0]); log_open(!mode); if (!mode) { - // A game launched by a frontend or a shortcut gets a console of its own that only gets in the way. The log is in - // a file by now; with no log file, or with show_console = 1, the console stays. - if (rt_log_path() && !cfg_bool("TOTK_SHOW_CONSOLE") && plat_console_release_if_owned()) - rt_log("console: owned by the game alone, released (show_console = 1 keeps it)"); cfg.boot = cfg.seconds > 0; // --seconds starts the game like --boot, with its checkpoints discord_init(); // the Rich Presence thread (discord_rpc.c); it reads totk.ini itself and idles while off rt_boot(); diff --git a/runtime/platform/linux.c b/runtime/platform/linux.c index 8d8d1fc8..f32ddd3d 100644 --- a/runtime/platform/linux.c +++ b/runtime/platform/linux.c @@ -1264,8 +1264,6 @@ int plat_os_version(char *out, size_t cap) { int plat_is_wine(void) { return 0; } -int plat_console_release_if_owned(void) { return 0; } - int plat_stderr_path(char *out, size_t cap) { struct stat st; if (fstat(2, &st) || !S_ISREG(st.st_mode)) return 0; diff --git a/runtime/platform/platform.h b/runtime/platform/platform.h index 73ed0a34..af20ec68 100644 --- a/runtime/platform/platform.h +++ b/runtime/platform/platform.h @@ -378,11 +378,6 @@ int plat_is_wine(void); // 1 when the Windows // The file the process's stderr (the log) goes to, as a UTF-8 path; 0 when stderr is not a file (a console, a pipe). int plat_stderr_path(char *out, size_t cap); -// Detaches the process from its console when no other process shares it (a frontend or a shortcut started us and -// Windows made the console for us); a terminal the user started us from keeps its output. Returns 1 when detached. -// Linux: 0. -int plat_console_release_if_owned(void); - // ---- desktop: the in-game menu's "Copy system info" and "Open log folder" int plat_clipboard_set(const char *utf8); // replaces the clipboard's text; 1 on success int plat_open_folder(const char *path); // shows the folder in the file manager; 1 on success diff --git a/runtime/platform/win32.c b/runtime/platform/win32.c index 33d88784..c4aca224 100644 --- a/runtime/platform/win32.c +++ b/runtime/platform/win32.c @@ -1303,17 +1303,6 @@ int plat_stderr_path(char *out, size_t cap) { return WideCharToMultiByte(CP_UTF8, 0, p, -1, out, (int)cap, NULL, NULL) != 0; } -// GetConsoleProcessList counts this process alone only when the console was created for it. The window is hidden first -// and then the console freed: under Windows Terminal as the default terminal, freeing is what closes the terminal -// window that opened beside the game. -int plat_console_release_if_owned(void) { - DWORD pids[2]; - if (!GetConsoleWindow() || GetConsoleProcessList(pids, 2) != 1) return 0; - ShowWindow(GetConsoleWindow(), SW_HIDE); - FreeConsole(); - return 1; -} - // ---- desktop int plat_clipboard_set(const char *utf8) { diff --git a/totk.ini.example b/totk.ini.example index aa936b64..d14ee673 100644 --- a/totk.ini.example +++ b/totk.ini.example @@ -353,10 +353,6 @@ # cheat_0123abcd = 1 [diagnostics] -# Keep the console window of a game started from a frontend (Playnite, RetroBat, ES-DE) or a shortcut. Default 0: the -# console that Windows opened for the game alone is closed once the log is open. A game started from a terminal keeps -# printing there either way; the log is logs\totk.log. -# show_console = 0 # Extra lines in the log, comma separated: svc, host, ipc, fs, gfx, perf, sched, audio, present or all. The menu's # Performance log sets perf (frame timings). Default: none. # trace = perf