mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-21 03:39:57 -04:00
Keep the SPIR-V of shaders nobody read for 30 seconds compressed in memory.
The shader memory cache held 777 MiB of SPIR-V for 7115 shaders for the whole session. A background thread now compresses the SPIR-V of each shader no reader pinned for shader_compress_idle_s seconds (zstd level 1, 26% of the bytes on the test install's 44,151 modules) and frees the plain copy; readers pin it through gfx_shader_spirv_pin and get it decoded back. What the drawing thread compares at pipeline misses and draws, the module's FNV-1a and its Binding decorations, is kept with the shader, so module_binding_missing, the water corrections and the DLSS, crumbs and skip lists decode nothing. A compute pipeline created at a dispatch and a mesh shader's first pipeline key still decode on that thread, and the memory report counts those decodes apart, with the SPIR-V as held against uncompressed and the shaders held compressed. shader_compress = 0 keeps it plain. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -171,8 +171,10 @@ int probe_shader(void) {
|
||||
first[i] = translate(&entries[i], &err);
|
||||
FAIL_IF(!first[i], "shader %s did not translate", entries[i].key);
|
||||
uint64_t words;
|
||||
const uint32_t *w = gfx_shader_spirv(first[i], &words);
|
||||
FAIL_IF(words < 5 || w[0] != 0x07230203, "shader %s: bad SPIR-V magic", entries[i].key);
|
||||
const uint32_t *w = gfx_shader_spirv_pin(first[i], &words);
|
||||
uint32_t magic = w[0];
|
||||
gfx_shader_spirv_unpin(first[i]);
|
||||
FAIL_IF(words < 5 || magic != 0x07230203, "shader %s: bad SPIR-V magic", entries[i].key);
|
||||
}
|
||||
FAIL_IF(gfx_shader_requests() - req0 != WANT, "pass 1 sent %llu requests, expected %d",
|
||||
(unsigned long long)(gfx_shader_requests() - req0), WANT);
|
||||
@@ -187,8 +189,10 @@ int probe_shader(void) {
|
||||
second[i] = translate(&entries[i], &err);
|
||||
FAIL_IF(!second[i], "shader %s missing from the disk cache", entries[i].key);
|
||||
uint64_t words;
|
||||
const uint32_t *w = gfx_shader_spirv(second[i], &words);
|
||||
FAIL_IF(words < 5 || w[0] != 0x07230203, "shader %s: bad SPIR-V magic from disk", entries[i].key);
|
||||
const uint32_t *w = gfx_shader_spirv_pin(second[i], &words);
|
||||
uint32_t magic = w[0];
|
||||
gfx_shader_spirv_unpin(second[i]);
|
||||
FAIL_IF(words < 5 || magic != 0x07230203, "shader %s: bad SPIR-V magic from disk", entries[i].key);
|
||||
}
|
||||
int hits = (int)(gfx_shader_cache_hits() - hits0);
|
||||
FAIL_IF(gfx_shader_requests() != req0, "pass 2 contacted the service");
|
||||
|
||||
Reference in New Issue
Block a user