diff --git a/docs/installer.md b/docs/installer.md index fe0d8f1e..cf8f0903 100644 --- a/docs/installer.md +++ b/docs/installer.md @@ -203,7 +203,9 @@ bin/ nx2navi_xlate, hactool, ninja, libSDL3.so.0 - The setup's temp folder is `.setup-temp` inside the install folder (`--temp` changes it): the AppImage is mounted read-only, and a Steam Deck's `/home` is often too full for the generated C while the game goes to the SD card. - The game keeps Mesa's shader cache in `mesa-cache` beside `nx2navi` unless `MESA_SHADER_CACHE_DIR` is set, for the - same reason: RADV fills its default folder in `~/.cache` up to 1 GB. With NVIDIA's driver, its cache goes to + same reason: RADV fills its default folder in `~/.cache` up to 1 GB. In that folder the limit is 8 GB unless + `MESA_SHADER_CACHE_MAX_SIZE` is set, since the shader preparation and the stage libraries built in play do not fit + in 1 GB. With NVIDIA's driver, its cache goes to `nvidia-cache` beside it unless `__GL_SHADER_DISK_CACHE_PATH` is set, with a limit of 8 GiB unless `__GL_SHADER_DISK_CACHE_SIZE` is set: the default limit of 1 GiB is smaller than what the shader preparation builds. When that folder cannot be made or written, the driver keeps its own folder and limit. diff --git a/runtime/vk_device.c b/runtime/vk_device.c index 5a76c791..29101c32 100644 --- a/runtime/vk_device.c +++ b/runtime/vk_device.c @@ -70,14 +70,19 @@ static int instance_ext_present(const char *name) { // Mesa's drivers (RADV on Linux and the Steam Deck) keep a shader cache of their own beside our pipeline cache, by // default in ~/.cache and up to 1 GB: about 35 MB in a minute of the title screen. A Deck's /home is small and the game // usually sits on the SD card, so unless MESA_SHADER_CACHE_DIR names a folder, it goes to mesa-cache beside the exe. +// That folder is ours alone, so its limit is raised to MESA_CACHE_SIZE unless MESA_SHADER_CACHE_MAX_SIZE is set: the +// stage libraries the library warm builds in play live only in the driver's cache (vk_pipeline.c, "the play cache"), +// and a preparation of every shader variant does not fit in 1 GB, so the rest would be compiled again in play. +#define MESA_CACHE_SIZE "8G" static void mesa_cache_beside_exe(void) { - char dir[PLAT_PATH_MAX * 2]; + char dir[PLAT_PATH_MAX * 2], size[32]; if (plat_getenv("MESA_SHADER_CACHE_DIR", dir, sizeof dir)) return; int len = plat_exe_path(dir, sizeof dir - 16); char *cut = len ? plat_last_sep(dir) : NULL; if (!cut) return; strcpy(cut + 1, "mesa-cache"); plat_setenv("MESA_SHADER_CACHE_DIR", dir); + if (!plat_getenv("MESA_SHADER_CACHE_MAX_SIZE", size, sizeof size)) plat_setenv("MESA_SHADER_CACHE_MAX_SIZE", MESA_CACHE_SIZE); } #ifdef __linux__