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:
chrg6
2026-11-13 07:48:06 -05:00
parent 71e52159f9
commit 3573a96f46
14 changed files with 411 additions and 134 deletions

View File

@@ -75,9 +75,10 @@ int gfx_shader_guess_refine(const GfxShader *s, int stage, const GfxShaderAnswer
if (!s) return 0;
if (stage == GFX_STAGE_VS) {
uint64_t words = 0;
const uint32_t *w = gfx_shader_spirv(s, &words);
const uint32_t *w = gfx_shader_spirv_pin(s, &words);
GfxShaderIo io[32];
uint32_t ints = w ? int_read_inputs(w, words) & gfx_shader_inputs(s, io) : 0;
gfx_shader_spirv_unpin(s);
for (int l = 0; l < 32; l++)
if (ints >> l & 1 && out->attr_type[l] == GFX_TYPE_FLOAT) out->attr_type[l] = GFX_TYPE_UINT;
} else if (stage == GFX_STAGE_CS) {