Warm the GPU driver's cache again when build_game relinks a prepared build: the cache is keyed to the exe, and after a relink every new stage library took 40-220 ms in play instead of about 2 ms; totk.exe --warm-shaders builds the prepared variants from the shader cache without translating

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Valiantsin DzerakhandClaude Opus 5.5 committed 2026-10-27 09:00:54 +03:00
1 parent 138a7d3a99
commit 7daeffdc08
5 files changed
+53 -2

No files matched your search

+1
View File
@@ -260,4 +260,5 @@ int probe_shader(void); // M4 T4
int probe_vkmem(void), probe_vkexec(void), probe_astc(void); // M4 T5, T6
int probe_movie(void); // movie_probe.c: host VP9 movie::Decoder on one RomFS movie
int vk_pipeline_prepare_shaders(void); // vk_pipeline.c: --prepare-shaders (tools/prepare_shaders.py)
int vk_pipeline_warm_shaders(void); // vk_pipeline.c: --warm-shaders (tools/build_game.py)
// gfx_stubs.c defines each of these weakly: prints "probe-x: not built yet", returns 2.
+2 -1
View File
@@ -388,7 +388,7 @@ static int usage(const char *argv0) {
fprintf(stderr, "usage: %s [--exefs DIR] [--romfs DIR] [--profile DIR] [--selftest | --probe-loader | "
"--probe-cfg | --probe-kernel | --probe-ipc | --probe-services | --probe-fs | --probe-gfx-abi | "
"--probe-nvn | --probe-nvn-tex | --probe-window | --probe-shader | --probe-vkmem | "
"--probe-vkexec | --probe-astc | --probe-movie | --prepare-shaders | --boot |--frames N [--shot PNG]]\n", argv0);
"--probe-vkexec | --probe-astc | --probe-movie | --prepare-shaders | --warm-shaders | --boot |--frames N [--shot PNG]]\n", argv0);
return 2;
}
@@ -488,6 +488,7 @@ int main(int argc, char **argv) {
if (!strcmp(mode, "--probe-vkdevice")) return probe_vkdevice();
if (!strcmp(mode, "--probe-movie")) return probe_movie();
if (!strcmp(mode, "--prepare-shaders")) return vk_pipeline_prepare_shaders();
if (!strcmp(mode, "--warm-shaders")) return vk_pipeline_warm_shaders();
if (!strcmp(mode, "--boot")) { cfg.boot = 1; rt_boot(); return 0; }
return usage(argv[0]);
}
+23
View File
@@ -2926,6 +2926,29 @@ int vk_pipeline_prepare_shaders(void) {
return rc;
}
// totk.exe --warm-shaders (tools/build_game.py after it relinked a prepared build): the driver's disk cache is keyed to
// the exe, so a rebuilt totk.exe finds it cold and a new library costs 40-220 ms in play instead of about 2 ms. This
// builds every variant of shader-prepared.bin into it again from the shader cache, without translating the seed.
int vk_pipeline_warm_shaders(void) {
if (!ensure_init()) {
fprintf(stderr, "warm-shaders: no Vulkan device\n");
return 1;
}
char dir[MAX_PATH * 2];
snprintf(dir, sizeof dir, "%s", P.cache_path);
char *cut = strrchr(dir, '\\');
if (!cut) return 1;
*cut = 0;
char prp[MAX_PATH * 2 + 32];
snprintf(prp, sizeof prp, "%s\\shader-prepared.bin", dir);
if (GetFileAttributesA(prp) == INVALID_FILE_ATTRIBUTES) {
fprintf(stderr, "warm-shaders: no %s (tools/prepare_shaders.py writes it)\n", prp);
return 1;
}
lb_warm_prepared(dir);
return 0;
}
// ---- dynamic state
void vk_pipeline_set_dynamic(VkCommandBuffer cb, const VkPipeState *s) {