Keep only the compute pipelines of recently dispatched shaders from the boot, and build the others into the pipeline cache without keeping them.

The boot prebuild built the pipeline of every compute shader play ever recorded and kept all of them for the process. A pipeline that exists holds driver memory whether or not anything dispatches it: with a history of 4,066 compute shaders they held 2.3 GiB of device memory, and its share of the process's commit, from the title screen on (RTX 5090, NVIDIA 621.01), while a boot into the first village dispatched 95 of them.

The boot now keeps the pipelines of the 512 compute shaders dispatched most recently (compute-used.bin next to pipeline-keys.bin records which run last dispatched each; the setting is compute_keep, with "all" for the earlier behaviour). Every other one is still built at boot, so that the pipeline cache holds it after an update or a driver update, but destroyed at once, and created from the cache at its first dispatch. A dispatch that comes while such a build runs gets that build's pipeline.

Each boot stage now logs the device memory and the process commit it leaves ("mem: boot stage"), and the log says what the first dispatches cost. nx2navi.exe --probe-prewarm runs these stages without the game from the caches next to the executable and times first dispatches of pipelines the boot did not keep: 256 of them took 0.19 ms on average and 3 ms at most, all read from the pipeline cache file, and 372 pipelines built and destroyed at boot left the device memory where it was.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
(cherry picked from commit 16a796d623686bca5304eaf1b29981247453a413)
This commit is contained in:
chrg6
2026-11-10 03:23:52 -05:00
parent 9a22bea0f0
commit 61a13c62b9
9 changed files with 440 additions and 33 deletions

View File

@@ -20,6 +20,8 @@
// --probe-dpi the process DPI awareness (per-monitor v2) and the primary monitor's size; no game files
// --probe-gfx-abi NVN object layouts against nvn.h's reserved sizes; needs no game files
// --probe-nvn, --probe-nvn-tex, --probe-window, --probe-shader, --probe-vkmem, --probe-vkexec graphics probes
// --probe-prewarm the boot's pipeline stages from the caches next to the executable, the memory each leaves and
// what a compute pipeline's first dispatch costs; skips without recorded shaders, runs no game
// --probe-astc the compute ASTC decoder against astc_decode_ldr; needs no game files
// --probe-zstd host zstd streams (ov_zstd.c) on frames made here; needs no game files
// --probe-input gamepad polls on a virtual gamepad, also while SDL's update takes long; needs no game files
@@ -495,7 +497,7 @@ static int usage(const char *argv0) {
"--probe-cfg | --probe-dpi | --probe-mods | --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-zstd | --probe-input | --probe-movie | --probe-crash-call | --probe-crash-null | --probe-discord | "
"--prepare-shaders | --warm-shaders | --boot |--seconds S [--shot PNG]]\n", argv0);
"--prepare-shaders | --warm-shaders | --probe-prewarm | --boot |--seconds S [--shot PNG]]\n", argv0);
return 2;
}
@@ -643,6 +645,7 @@ int main(int argc, char **argv) {
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, "--probe-prewarm")) return vk_pipeline_probe_prewarm();
if (!strcmp(mode, "--boot")) { cfg.boot = 1; rt_boot(); return 0; }
return usage(argv[0]);
}