It's a very simple format on a surface level. The file starts with a 12-byte header:
struct DxvkStateCacheHeader {
char magic[4] = { 'D', 'X', 'V', 'K' };
uint32_t version = 10; /* incremented any time something changes */
uint32_t entrySize = 0; /* no longer meaningful, always 0 */
};
Followed by an array of entries until the end of the file, so the design allows us to just append data to the file when compiling new pipelines without rewriting the whole thing.
Each entry has the following layout, note that the header contains a bit field:
struct {
uint32_t stageMask : 8; /* VkShaderStageFlags */
uint32_t entrySize : 24; /* size of the data array, in bytes, not including header */
uint8_t sha1Hash[20]; /* data hash, not including header */
char data[];
};
The data array contains a compact serialization of the pipeline state data, but I'd highly discourage trying to parse that, especially since the exact contents may change with future releases. If your intention is to merge caches, just use the SHA1 hash for deduplication purposes.
BTW, according to this data it should be "unbreakable", but sometimes it breaks. For example when changing nvidia drivers versions forth and back. Like recently I played Borderlands Pre-Sequel with 495.44, then updated drivers to 510.54 played a bit more (w/o issues, or just didn't noticed any), then realized this driver version has some issues in other applications and reverted back to 495.44. After that Borderlands started crashing after first few frames, I had to remove DXVK cache file to fix this.
Not the first time it happened, sometimes it just small artifacts I prefer to ignore when I almost done with a game. The question is how to properly deal with this, is it possible to "repair" DXVK cache file? Or maybe it's driver's cache problem?
We don't really do a huge amount of validation at compile time.
I don't think it's the file that breaks, it's more likely just that we're trying to compile a pipeline that's not supported on the given driver. Which, yes, is a problem that needs to be addressed.
I found that "bad" cache file not removed but renamed, so uploading both caches just in case:
BorderlandsPreSequel.dxvk-cache.mixed.zip
BorderlandsPreSequel.dxvk-cache.495.44.zip
Nothing extracted yet.
Are there any documentations regarding the fileformat of the DXVK shadercache files?
Cheers.