mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-15 19:19:58 -04:00
Give Mesa's shader cache beside the game a limit of 8 GB instead of its default 1 GB.
On Linux with RADV (and the Steam Deck) the game points MESA_SHADER_CACHE_DIR at mesa-cache beside the exe, a folder nothing else writes, but left Mesa's limit of 1 GB. The stage libraries the library warm builds in play are kept only in the driver's cache, and a preparation of every shader variant is larger than that limit, so what did not fit was compiled again in play. The limit is now 8 GB in that folder unless MESA_SHADER_CACHE_MAX_SIZE is set, as NVIDIA's cache beside the game already has. Checked: all runtime files compile. Not run on Linux. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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__
|
||||
|
||||
Reference in New Issue
Block a user