mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-19 04:19:57 -04:00
Keep NVIDIA's shader disk cache beside the exe with a limit that holds the prepared set.
NVIDIA's Linux driver compiles into a disk cache in ~/.cache/nvidia, shared with every program, and a process adds at most 1 GiB to it (__GL_SHADER_DISK_CACHE_SIZE); a start that finds more than that in several files deletes the later ones. nx2navi.exe --prepare-shaders builds the 42,142 variants of game 1.1.1 in one process, about 1.5 GB: on the default limit it stored about 30,700 of them, and the first start after the preparation compiled the rest (and the pipelines built from them) again. Unless the environment sets them, the game now points __GL_SHADER_DISK_CACHE_PATH at nvidia-cache beside the exe (made here, the driver only makes GLCache inside it) and __GL_SHADER_DISK_CACHE_SIZE at 8 GiB before its first Vulkan call, as it does for Mesa's cache. The docs name both. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
committed by
chrg6
parent
03cb703e8f
commit
c9942578e1
@@ -72,9 +72,37 @@ static void mesa_cache_beside_exe(void) {
|
||||
plat_setenv("MESA_SHADER_CACHE_DIR", dir);
|
||||
}
|
||||
|
||||
#ifdef __linux__
|
||||
// NVIDIA's Linux driver keeps the pipelines it compiles in a disk cache of its own, by default in ~/.cache/nvidia,
|
||||
// shared with every program. One process adds at most __GL_SHADER_DISK_CACHE_SIZE to it (1 GiB unless set), and a start
|
||||
// that finds more than that in several files deletes the later ones. nx2navi.exe --prepare-shaders builds the 42,142
|
||||
// variants of game 1.1.1 into it in one process: with the default limit it stored about 30,700 of them and the rest
|
||||
// were compiled again by the first start after it. So unless the environment sets them, the cache goes to nvidia-cache
|
||||
// beside the exe, which nothing else writes, with a limit of NV_CACHE_BYTES. The driver makes GLCache inside that
|
||||
// folder but not the folder, so it is made here.
|
||||
#define NV_CACHE_BYTES "8589934592" // 8 GiB
|
||||
static void nvidia_cache_beside_exe(void) {
|
||||
char dir[PLAT_PATH_MAX * 2], size[32];
|
||||
if (!plat_getenv("__GL_SHADER_DISK_CACHE_PATH", dir, sizeof dir)) {
|
||||
int len = plat_exe_path(dir, sizeof dir - 16);
|
||||
char *cut = len ? plat_last_sep(dir) : NULL;
|
||||
if (cut) {
|
||||
strcpy(cut + 1, "nvidia-cache");
|
||||
plat_fs_mkdir(dir); // already there is fine
|
||||
plat_setenv("__GL_SHADER_DISK_CACHE_PATH", dir);
|
||||
}
|
||||
}
|
||||
if (!plat_getenv("__GL_SHADER_DISK_CACHE_SIZE", size, sizeof size))
|
||||
plat_setenv("__GL_SHADER_DISK_CACHE_SIZE", NV_CACHE_BYTES);
|
||||
}
|
||||
#endif
|
||||
|
||||
static int create_instance(void) {
|
||||
vk_dlssg_early(); // DLSS Frame Generation: Streamline before any Vulkan call of the process (its slInit asks so)
|
||||
mesa_cache_beside_exe();
|
||||
#ifdef __linux__
|
||||
nvidia_cache_beside_exe();
|
||||
#endif
|
||||
const char *ext[12];
|
||||
uint32_t n_ext = (uint32_t)gfx_window_vk_extensions(ext, 7);
|
||||
const char *layers[] = {"VK_LAYER_KHRONOS_validation"};
|
||||
|
||||
Reference in New Issue
Block a user