mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-20 06:09:58 -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:
@@ -5485,6 +5485,17 @@ static void system_log(uint64_t frame, const ReportFig *f, const VkPipeMem *pm,
|
||||
flight_mem(&frec, &fthumb);
|
||||
uint64_t lq = logq_bytes();
|
||||
uint64_t shaders = sr.cache + sr.use + sr.pack + sr.records;
|
||||
// The shaders' SPIR-V as held (gfx_shader.c "SPIR-V at rest"): against what it would be uncompressed, how many
|
||||
// shaders hold it compressed alone, and the decodes readers' pins made, those on the drawing threads apart.
|
||||
char spv[400];
|
||||
if (sr.compress > 0)
|
||||
snprintf(spv, sizeof spv, " (their SPIR-V %.0f, uncompressed %.0f; %llu shaders compressed; %llu decompressions "
|
||||
"in %.0f ms, %llu of them on the drawing threads in %.1f ms, the longest %.2f ms)", sr.spv_held / M,
|
||||
sr.spv_full / M, (unsigned long long)sr.spv_packed, (unsigned long long)sr.decodes, sr.decode_ns / 1e6,
|
||||
(unsigned long long)sr.draw_decodes, sr.draw_decode_ns / 1e6, sr.draw_decode_max_ns / 1e6);
|
||||
else
|
||||
snprintf(spv, sizeof spv, " (their SPIR-V %.0f, uncompressed%s)", sr.spv_held / M,
|
||||
sr.compress < 0 ? ": shader_compress = 0" : "");
|
||||
uint64_t pipes = pm->ram_pipes + pm->ram_keys + pm->ram_seed + pm->ram_binaries;
|
||||
uint64_t texhost = th.bytes + th.tmp, known = shaders + pipes + texhost + lq + frec;
|
||||
uint64_t pcache = pm->cache[0] + pm->cache[1];
|
||||
@@ -5503,15 +5514,15 @@ static void system_log(uint64_t frame, const ReportFig *f, const VkPipeMem *pm,
|
||||
f->hblocks / M, fthumb / M);
|
||||
if (hi.committed)
|
||||
mg_put(line, sizeof line, &k, " + the C runtime heap %.0f (%.0f of it handed out; of it known: shader caches %.0f in "
|
||||
"%llu shaders, pipeline tables %.0f, the texture cache %.0f with decode temporaries %.0f now and %.0f at most "
|
||||
"%llu shaders%s, pipeline tables %.0f, the texture cache %.0f with decode temporaries %.0f now and %.0f at most "
|
||||
"since the last report, the log queue %.0f, the flight recorder's records %.0f; the rest %.0f)",
|
||||
hi.committed / M, hi.used / M, shaders / M, (unsigned long long)sr.shaders, pipes / M, texhost / M,
|
||||
hi.committed / M, hi.used / M, shaders / M, (unsigned long long)sr.shaders, spv, pipes / M, texhost / M,
|
||||
th.tmp / M, th.tmp_peak / M, lq / M, frec / M, ((double)hi.committed - (double)known) / M);
|
||||
else
|
||||
mg_put(line, sizeof line, &k, " + what the runtime knows it allocated %.0f (the C runtime heap's size is not "
|
||||
"known: shader caches %.0f in %llu shaders, pipeline tables %.0f, the texture cache %.0f with decode "
|
||||
"known: shader caches %.0f in %llu shaders%s, pipeline tables %.0f, the texture cache %.0f with decode "
|
||||
"temporaries %.0f now and %.0f at most since the last report, the log queue %.0f, the flight recorder's "
|
||||
"records %.0f)", known / M, shaders / M, (unsigned long long)sr.shaders, pipes / M, texhost / M,
|
||||
"records %.0f)", known / M, shaders / M, (unsigned long long)sr.shaders, spv, pipes / M, texhost / M,
|
||||
th.tmp / M, th.tmp_peak / M, lq / M, frec / M);
|
||||
mg_put(line, sizeof line, &k, " + the driver's pipeline cache data %.0f (pipeline-cache.bin's %.0f, the play cache's "
|
||||
"%.0f, %s) + other %.0f (the driver's own memory, thread stacks, the program's data; %u other heaps)",
|
||||
|
||||
Reference in New Issue
Block a user