fix(vk): NVIDIA's shader cache limit read and logged, and the pipeline cache file read where that cache is kept under 4 GB #2125

Merged
HumanBean merged 1 commit from HumanBean/Longshot:fix/nvidia-shader-cache-limit into main 2026-11-21 21:23:07 +00:00
Owner

Summary

Players on NVIDIA report every pipeline compiling again for no reason, with no driver update, and a player who raised the NVIDIA Control Panel's Shader Cache Size from its default to 10 GB saw it stop. Logs on the forge show NVIDIA's GLCache sitting at 1025 MB (#2079), the 1 GB limit, while a start builds about 2 GB into it. The driver throws pipelines out as it fills, including the predicted ones the preparation puts there alone, and those are compiled again in play.

#1845's rule makes it worse on Windows PCs with 20 GB of RAM or less. It leaves longshot_vk_pipelines.bin unread once the GLCache folder holds 512 MB, and a 1 GB-capped cache passes that check while unable to keep what it is given.

This PR:

  • gpu/vk/nvidia_cache_limit.h (new): reads NVIDIA's limit. On Windows that is the Shader Cache Size, read only through nvapi64.dll's driver settings (NvAPI_DRS_GetSetting on the current global profile, PS_SHADERDISKCACHE_MAX_SIZE, MB). On Linux it is __GL_SHADER_DISK_CACHE_SIZE, which hos_main.c already sets to 10 GiB unless the player chose a value.
  • pcache_load.h: the rule reads the file where that limit is known and under 4 GB (Why::kDriverCacheSmall). An unknown limit behaves as before.
  • vk_draw.cpp: the start logs the limit (vk: driver shader cache: NVIDIA's holds at most N MB (...)) and warns under 4 GB. That puts the cause in every bug report's log.
  • The other half is the launcher, which raises a Windows limit under 4 GB to 10 GB before a build and before Play: LongshotLauncher#243. This PR covers players who don't use the launcher, or decline its admin prompt.

How to see it on main: on Windows with NVIDIA, set Shader Cache Size to 1 GB, start, play through a few areas, and restart. Shaders compile again in places already seen, and on a 16 GB PC the log says pipeline cache file not read: Windows with NVIDIA's own driver ....

Read first: gpu/vk/nvidia_cache_limit.h, pcache_load::choose, and pcache_load_off / driver_cache_log in vk_draw.cpp.

Testing

Tested: not in the game: opened without a run at the request of the person I work for. Built as a pack over the shared base on Linux (dev.py pack: longshot, longshot_vk.so). nvidia_cache_limit.h was compiled with -Wall -Wextra -Werror -fsyntax-only, its Windows half against stub windows.h declarations; there is no Windows build here. tests/test_pcache_load.py gains the rule's cases (1 GB read, just under 4 GB read, 4 GB / 10 GB / Unlimited / unknown not read, the switch winning). It also gains Linux folder cases with __GL_SHADER_DISK_CACHE_SIZE at 10 GiB and 1 GiB, and Windows cases with the limit stood in (FAKE_LIMIT_MB). Not run on this PC (no tests run here); CI runs it.

Still to test:

  • Windows, NVIDIA, 16 GB of RAM, Shader Cache Size 1 GB: the log has NVIDIA's holds at most 1024 MB (Shader Cache Size in the NVIDIA Control Panel) as a warning, and pipeline cache file read: NVIDIA's own shader cache is kept under 4 GB (@Beanstalk).
  • Windows, NVIDIA, Shader Cache Size 10 GB or Unlimited: the log has the size or has no limit, and the file rule behaves as on main (@Beanstalk).
  • Windows, AMD or Intel: no NVIDIA line, nothing else changes (@Beanstalk).
  • Linux, NVIDIA: NVIDIA's holds at most 10240 MB (__GL_SHADER_DISK_CACHE_SIZE) (by hand).

Measurements

Nothing new to measure on main's own path: the change only acts where NVIDIA's limit is under 4 GB. There it reads the pipeline cache file, which costs what #1845 measured for reading it (about 1 GB of private memory on an RTX 4070 SUPER), and in exchange the pipelines the capped cache dropped are not compiled again in play. Reading the limit is one NVAPI settings load at the start, once a run, only with NVIDIA's own driver; it is not timed here.

Risks

  • Windows NVIDIA PCs with 20 GB of RAM or less and a limit under 4 GB read the file again: about 1 GB more memory there, in exchange for no recompiling. RX_VK_PCACHE_LOAD=0 still leaves it unread.
  • If the NVAPI read fails (no nvapi64.dll, a refusal, a driver without the setting), the limit is unknown and everything behaves as on main.
  • Nothing changes in saves, longshot_options.ini or the caches after updating.

Checklist

Ready for review

  • One topic, on current main; the title is a Conventional Commit.
  • Tested on my own PC, in the game for a change the game runs, as Testing says. (not run, as asked; Windows to the Test Farm)
  • mise run test passes (any failure that also fails on main is named). (no tests run on this PC; CI)
  • Measured against main, or Measurements says why there is nothing to measure.
  • No game files, build output or hand-edited generated files; third_party/ untouched; nothing GPL-incompatible.

When it applies

  • A fix: a game-free test that fails on main and passes here. (the rule gains an input, the limit, so the new cases don't compile on main; not run here)
  • A check under tests/ that reads changed source is updated, not weakened.
  • Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths. (Linux built; Windows only syntax-checked: CI)
  • Docs updated.
  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.

Ready to merge

  • Everything in Still to test has run, its results in Tested.
  • Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers").
  • Approved in review, every comment answered.
  • CI passes on the head; on current main, measured again or a comment says why the numbers still hold.

Before: main @ c5e1421d2 · After: this PR @ d88ad916c

🤖 Generated with Claude Code

## Summary Players on NVIDIA report every pipeline compiling again for no reason, with no driver update, and a player who raised the NVIDIA Control Panel's **Shader Cache Size** from its default to 10 GB saw it stop. Logs on the forge show NVIDIA's GLCache sitting at 1025 MB ([#2079](https://git.magicbean.dev/MagicBeanDev/Longshot/issues/2079)), the 1 GB limit, while a start builds about 2 GB into it. The driver throws pipelines out as it fills, including the predicted ones the preparation puts there alone, and those are compiled again in play. [#1845](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1845)'s rule makes it worse on Windows PCs with 20 GB of RAM or less. It leaves `longshot_vk_pipelines.bin` unread once the GLCache folder holds 512 MB, and a 1 GB-capped cache passes that check while unable to keep what it is given. This PR: - `gpu/vk/nvidia_cache_limit.h` (new): reads NVIDIA's limit. On Windows that is the Shader Cache Size, read only through `nvapi64.dll`'s driver settings (`NvAPI_DRS_GetSetting` on the current global profile, `PS_SHADERDISKCACHE_MAX_SIZE`, MB). On Linux it is `__GL_SHADER_DISK_CACHE_SIZE`, which `hos_main.c` already sets to 10 GiB unless the player chose a value. - `pcache_load.h`: the rule reads the file where that limit is known and under 4 GB (`Why::kDriverCacheSmall`). An unknown limit behaves as before. - `vk_draw.cpp`: the start logs the limit (`vk: driver shader cache: NVIDIA's holds at most N MB (...)`) and warns under 4 GB. That puts the cause in every bug report's log. - The other half is the launcher, which raises a Windows limit under 4 GB to 10 GB before a build and before Play: [LongshotLauncher#243](https://git.magicbean.dev/MagicBeanDev/LongshotLauncher/pulls/243). This PR covers players who don't use the launcher, or decline its admin prompt. How to see it on main: on Windows with NVIDIA, set Shader Cache Size to 1 GB, start, play through a few areas, and restart. Shaders compile again in places already seen, and on a 16 GB PC the log says `pipeline cache file not read: Windows with NVIDIA's own driver ...`. Read first: `gpu/vk/nvidia_cache_limit.h`, `pcache_load::choose`, and `pcache_load_off` / `driver_cache_log` in `vk_draw.cpp`. ## Testing **Tested:** not in the game: opened without a run at the request of the person I work for. Built as a pack over the shared base on Linux (`dev.py pack`: `longshot`, `longshot_vk.so`). `nvidia_cache_limit.h` was compiled with `-Wall -Wextra -Werror -fsyntax-only`, its Windows half against stub `windows.h` declarations; there is no Windows build here. `tests/test_pcache_load.py` gains the rule's cases (1 GB read, just under 4 GB read, 4 GB / 10 GB / Unlimited / unknown not read, the switch winning). It also gains Linux folder cases with `__GL_SHADER_DISK_CACHE_SIZE` at 10 GiB and 1 GiB, and Windows cases with the limit stood in (`FAKE_LIMIT_MB`). Not run on this PC (no tests run here); CI runs it. **Still to test:** - Windows, NVIDIA, 16 GB of RAM, Shader Cache Size 1 GB: the log has `NVIDIA's holds at most 1024 MB (Shader Cache Size in the NVIDIA Control Panel)` as a warning, and `pipeline cache file read: NVIDIA's own shader cache is kept under 4 GB` (@Beanstalk). - Windows, NVIDIA, Shader Cache Size 10 GB or Unlimited: the log has the size or `has no limit`, and the file rule behaves as on main (@Beanstalk). - Windows, AMD or Intel: no NVIDIA line, nothing else changes (@Beanstalk). - Linux, NVIDIA: `NVIDIA's holds at most 10240 MB (__GL_SHADER_DISK_CACHE_SIZE)` (by hand). ## Measurements Nothing new to measure on main's own path: the change only acts where NVIDIA's limit is under 4 GB. There it reads the pipeline cache file, which costs what #1845 measured for reading it (about 1 GB of private memory on an RTX 4070 SUPER), and in exchange the pipelines the capped cache dropped are not compiled again in play. Reading the limit is one NVAPI settings load at the start, once a run, only with NVIDIA's own driver; it is not timed here. ## Risks - Windows NVIDIA PCs with 20 GB of RAM or less and a limit under 4 GB read the file again: about 1 GB more memory there, in exchange for no recompiling. `RX_VK_PCACHE_LOAD=0` still leaves it unread. - If the NVAPI read fails (no `nvapi64.dll`, a refusal, a driver without the setting), the limit is unknown and everything behaves as on main. - Nothing changes in saves, `longshot_options.ini` or the caches after updating. ## Checklist ### Ready for review - [x] One topic, on current `main`; the title is a Conventional Commit. - [ ] Tested on my own PC, in the game for a change the game runs, as Testing says. (not run, as asked; Windows to the Test Farm) - [ ] `mise run test` passes (any failure that also fails on `main` is named). (no tests run on this PC; CI) - [x] Measured against `main`, or Measurements says why there is nothing to measure. - [x] No game files, build output or hand-edited generated files; `third_party/` untouched; nothing GPL-incompatible. ### When it applies - [ ] A fix: a game-free test that fails on `main` and passes here. (the rule gains an input, the limit, so the new cases don't compile on main; not run here) - [x] A check under `tests/` that reads changed source is updated, not weakened. - [ ] Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths. (Linux built; Windows only syntax-checked: CI) - [x] Docs updated. - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. ### Ready to merge - [ ] Everything in Still to test has run, its results in Tested. - [ ] Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers"). - [ ] Approved in review, every comment answered. - [ ] CI passes on the head; on current `main`, measured again or a comment says why the numbers still hold. Before: main @ c5e1421d2 · After: this PR @ d88ad916c 🤖 Generated with [Claude Code](https://claude.com/claude-code)
fix(vk): NVIDIA's shader cache limit read and logged, and the pipeline cache file read where that cache is kept under 4 GB
Some checks failed
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
Website / Website on Cloudflare (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 8s
Website / Website on Cloudflare (pull_request_target) Has been skipped
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 12s
CI / Workflow lint (actionlint) (pull_request) Successful in 12s
Third-party parts / As their notes say (pull_request) Successful in 14s
CI / Website build and checks (pull_request) Failing after 19s
beanstalk/approval can't be tested as asked: see the farm's comment
PR description / Description follows the template (pull_request_target) Failing after 9s
d88ad916c4
Players report every pipeline compiling again with no driver update, and their
logs show NVIDIA's GLCache sitting at 1025 MB: the control panel's Shader Cache
Size held at 1 GB, while a start builds about 2 GB into it, so the driver drops
pipelines as it fills. On Windows with 20 GB of RAM or less, #1845 leaves the
pipeline cache file unread once that folder holds 512 MB, counting on a cache
that cannot keep what it is handed.

gpu/vk/nvidia_cache_limit.h reads the limit: Windows' Shader Cache Size through
nvapi64.dll's driver settings (read only), Linux's __GL_SHADER_DISK_CACHE_SIZE.
pcache_load's rule reads the file where the limit is known and under 4 GB, and
the start logs the limit, warning when it is under 4 GB. The launcher raises
Windows' limit to 10 GB (LongshotLauncher's DriverSettings.RaiseShaderCache).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Owner

@Beanstalk On Windows with an NVIDIA GPU: set the NVIDIA Control Panel's Shader Cache Size to 1 GB, start the game to the title, and check the log has the warning 'vk: driver shader cache: NVIDIA's holds at most 1024 MB (Shader Cache Size in the NVIDIA Control Panel)'. On a PC with 20 GB of RAM or less, also check for 'pipeline cache file read: NVIDIA's own shader cache is kept under 4 GB'. Then set it to Unlimited, start again, and check for 'NVIDIA's has no limit'. On an AMD or Intel Windows PC: one start to the title, with no NVIDIA line in the log.

@Beanstalk On Windows with an NVIDIA GPU: set the NVIDIA Control Panel's Shader Cache Size to 1 GB, start the game to the title, and check the log has the warning 'vk: driver shader cache: NVIDIA's holds at most 1024 MB (Shader Cache Size in the NVIDIA Control Panel)'. On a PC with 20 GB of RAM or less, also check for 'pipeline cache file read: NVIDIA's own shader cache is kept under 4 GB'. Then set it to Unlimited, start again, and check for 'NVIDIA's has no limit'. On an AMD or Intel Windows PC: one start to the title, with no NVIDIA line in the log.
Member

Beanstalk test farm · ⛔ can't be tested as asked

Commit d88ad91 · approved by HumanBean (untrusted) · dashboard

Not run: the farm can't test this as asked, so nothing is built or run:

The requested NVIDIA checks require changing the global NVIDIA Control Panel Shader Cache Size to 1 GB and Unlimited, which the unattended farm cannot set. The alternative can check the Windows AMD and Intel log behavior, but cannot verify those NVIDIA limits or the low-RAM cache-file decision.

⚠️ Note: The under-4-GB cache-file reason also depends on the driver cache being measurable and already holding at least 512 MB; a title start alone does not guarantee that condition.

What it could test instead: The alternative plan starts the title screen on Windows AMD and Intel PCs and checks that no NVIDIA shader-cache limit line appears. It takes roughly 10 minutes per tester and fails on a crash or an NVIDIA limit line.

A member of BigBeans can comment @Beanstalk <new words> to ask for something else, or @Beanstalk test it anyway to run the plan regardless.

<!-- beanstalk:sticky --> ### Beanstalk test farm · ⛔ can't be tested as asked Commit `d88ad91` · approved by HumanBean (untrusted) · [dashboard](https://beanstalk.magicbean.dev/prs/2125) **Not run: the farm can't test this as asked**, so nothing is built or run: > The requested NVIDIA checks require changing the global NVIDIA Control Panel Shader Cache Size to 1 GB and Unlimited, which the unattended farm cannot set. The alternative can check the Windows AMD and Intel log behavior, but cannot verify those NVIDIA limits or the low-RAM cache-file decision. ⚠️ **Note:** The under-4-GB cache-file reason also depends on the driver cache being measurable and already holding at least 512 MB; a title start alone does not guarantee that condition. What it could test instead: The alternative plan starts the title screen on Windows AMD and Intel PCs and checks that no NVIDIA shader-cache limit line appears. It takes roughly 10 minutes per tester and fails on a crash or an NVIDIA limit line. A member of `BigBeans` can comment `@Beanstalk <new words>` to ask for something else, or `@Beanstalk test it anyway` to run the plan regardless.
HumanBean changed title from WIP: fix(vk): NVIDIA's shader cache limit read and logged, and the pipeline cache file read where that cache is kept under 4 GB to fix(vk): NVIDIA's shader cache limit read and logged, and the pipeline cache file read where that cache is kept under 4 GB 2026-11-21 21:22:59 +00:00
HumanBean deleted branch fix/nvidia-shader-cache-limit 2026-11-21 21:23:07 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/Longshot!2125
No description provided.