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
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!2125
Loading…
Reference in a new issue
No description provided.
Delete branch "HumanBean/Longshot:fix/nvidia-shader-cache-limit"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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.binunread 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 throughnvapi64.dll's driver settings (NvAPI_DRS_GetSettingon the current global profile,PS_SHADERDISKCACHE_MAX_SIZE, MB). On Linux it is__GL_SHADER_DISK_CACHE_SIZE, whichhos_main.calready 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.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, andpcache_load_off/driver_cache_loginvk_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.hwas compiled with-Wall -Wextra -Werror -fsyntax-only, its Windows half against stubwindows.hdeclarations; there is no Windows build here.tests/test_pcache_load.pygains 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_SIZEat 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:
NVIDIA's holds at most 1024 MB (Shader Cache Size in the NVIDIA Control Panel)as a warning, andpipeline cache file read: NVIDIA's own shader cache is kept under 4 GB(@Beanstalk).has no limit, and the file rule behaves as on main (@Beanstalk).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
RX_VK_PCACHE_LOAD=0still leaves it unread.nvapi64.dll, a refusal, a driver without the setting), the limit is unknown and everything behaves as on main.longshot_options.inior the caches after updating.Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named). (no tests run on this PC; CI)main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
mainand passes here. (the rule gains an input, the limit, so the new cases don't compile on main; not run here)tests/that reads changed source is updated, not weakened.Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.Before: main @
c5e1421d2· After: this PR @d88ad916c🤖 Generated with Claude Code
@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 test farm · ⛔ can't be tested as asked
Commit
d88ad91· approved by HumanBean (untrusted) · dashboardNot run: the farm can't test this as asked, so nothing is built or run:
⚠️ 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
BigBeanscan comment@Beanstalk <new words>to ask for something else, or@Beanstalk test it anywayto run the plan regardless.WIP: fix(vk): NVIDIA's shader cache limit read and logged, and the pipeline cache file read where that cache is kept under 4 GBto fix(vk): NVIDIA's shader cache limit read and logged, and the pipeline cache file read where that cache is kept under 4 GB