Build a large compute shader ahead only when a run has dispatched it, and release the shaders of pipelines the boot does not keep.

The 2 GiB of device memory a filled cache cost was not the thousands of compute pipelines but twenty of them: the compute shaders of 0.9 to 2.0 million SPIR-V words, the game's tensor-core upscaler programs, which nothing dispatches. A pipeline of one holds about 100 MiB of device memory from the moment it exists, and the driver keeps that memory when the pipeline is destroyed, so keeping only the recently dispatched pipelines did not help: the boot pass still created the twenty from pipeline-cache.bin at every start. Measured with --probe-prewarm on a copy of an installed copy's caches (RTX 5090, NVIDIA 621.01): the pass over all 4,066 compute shaders took the device memory from 386 to 2,398 MiB and the process's commit up by 2.5 GB; the same pass before the twenty were in the cache left the device memory at 386 MiB, and all 4,046 other pipelines kept at once cost 2 MiB.

A compute shader over NX2NAVI_LIB_PREBUILD_BIG is now built ahead, from the caches or by the background builder, only when the usage record says a run dispatched it. None of the twenty is among the 138 shaders eleven runs dispatched. Should the game dispatch one for the first time, that dispatch compiles it once and later boots build it ahead.

The boot also reads the shader of a pipeline it does not keep as a copy and releases it after the build, instead of leaving 3,900 shaders loaded (240 MB of commit); a first dispatch then reads its shader from the disk, 0.04 to 0.10 ms in the probe.

With both, the same pass on the same caches leaves the device memory at 386 MiB and raises the commit by 47 MB; 256 first dispatches after it took 0.13 ms on average, 1.8 ms at most, all read from the cache file. With compute_keep = all, which builds everything as before, the pass ends at 2,528 MiB. Not yet run in the game.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
chrg6
2026-11-10 04:52:28 -05:00
parent 1b9016896a
commit f9f0505ed1
5 changed files with 84 additions and 43 deletions

View File

@@ -106,8 +106,9 @@
# lib_prebuild_threads = 2
# How many compute pipelines the start builds and keeps: those of the compute shaders the game used most recently.
# Every other known one is built into the pipeline cache and released again, and made from the cache when the game
# first uses it (well under a millisecond). all: the start keeps the pipeline of every known compute shader, as
# versions up to 0.6.1 did, which held more than 2 GB of video memory. 0: none are kept.
# first uses it (well under a millisecond). Very large compute shaders the game has never used are not built at all.
# all: the start builds and keeps the pipeline of every known compute shader, as versions up to 0.6.1 did, which held
# more than 2 GB of video memory. 0: none are kept.
# compute_keep = 512
# 1: very large compute shaders that no cache holds are built on one background thread after the start. 0: each is
# built when the game first uses it, which can hold that frame for a second or two.