I use VKD3D_SHADER_CACHE_PATH to set a fixed path for the shader cache because I don't want the shaders in the program directories all over.
However it's such a hassle to do this for each game, since sharing shader cache file isn't really a great idea.
I made a Proof of concept patch here so the cache name is the same as the program/app-name, it seems to work for me, but I am by no means a C programmer, but you get the idea.
--- a/libs/vkd3d/cache.c 2024-03-13 10:32:06.481920565 +0100
+++ b/libs/vkd3d/cache.c 2024-03-13 10:31:57.489923606 +0100
@@ -3147,6 +3147,9 @@
struct d3d12_device *device)
{
char path_buf[VKD3D_PATH_MAX];
+ char app[VKD3D_PATH_MAX];
+ char *cachename;
+
VKD3D_UNUSED size_t i, n;
const char *separator;
const char *path;
@@ -3178,13 +3181,17 @@
* Seems to be related to drive detection (Rename fails with drive mismatch in some cases for example).
* Manually remap Unix style paths to conservative Win32.
* Normally Wine accepts Unix style paths, but not here for whatever reason. */
+ if (!vkd3d_get_program_name(app))
+ cachename = "vkd3d-proton-cache";
+ else
+ cachename = strcat(app, "-cache");
if (path && path[0] == '/')
- snprintf(cache->read_path, sizeof(cache->read_path), "Z:\\%s%svkd3d-proton.cache", path + 1, separator);
+ snprintf(cache->read_path, sizeof(cache->read_path), "Z:\\%s%s%s", path + 1, separator, cachename);
else if (path)
- snprintf(cache->read_path, sizeof(cache->read_path), "%s%svkd3d-proton.cache", path, separator);
+ snprintf(cache->read_path, sizeof(cache->read_path), "%s%s%s", path, separator, cachename);
else
- strcpy(cache->read_path, "vkd3d-proton.cache");
+ strcpy(cache->read_path, cachename);
for (i = 0, n = strlen(cache->read_path); i < n; i++)
if (cache->read_path[i] == '/')
@@ -3192,9 +3199,9 @@
INFO("Remapping VKD3D_SHADER_CACHE to: %s.\n", cache->read_path);
#else
if (path)
- snprintf(cache->read_path, sizeof(cache->read_path), "%s%svkd3d-proton.cache", path, separator);
+ snprintf(cache->read_path, sizeof(cache->read_path), "%s%s%s", path, separator, cachename);
else
- strcpy(cache->read_path, "vkd3d-proton.cache");
+ strcpy(cache->read_path, cachename);
#endif
INFO("Attempting to load disk cache from: %s.\n", cache->read_path);
I use VKD3D_SHADER_CACHE_PATH to set a fixed path for the shader cache because I don't want the shaders in the program directories all over. However it's such a hassle to do this for each game, since sharing shader cache file isn't really a great idea.
I made a Proof of concept patch here so the cache name is the same as the program/app-name, it seems to work for me, but I am by no means a C programmer, but you get the idea.