feat(play): NVIDIA's shader cache raised to 10 GB when it holds under 4 GB, so Longshot's shaders stop compiling again #243

Merged
HumanBean merged 3 commits from HumanBean/LongshotLauncher:feat/nvidia-shader-cache-room into main 2026-11-21 21:35:47 +00:00
Owner

Players on NVIDIA report every pipeline compiling again with no driver update. Their shader cache is held at 1 GB (the NVIDIA Control Panel's Shader Cache Size), while a start of Longshot builds about 2 GB into it, so the driver throws pipelines out as it fills. A player who raised it to 10 GB saw no more rebuilds, and logs on the forge show caches sitting at 1025 MB (Longshot#2079).

Summary

On Windows, before a build (which prepares the shaders) and before Play, the launcher reads NVIDIA's Shader Cache Size through NVAPI. A size under 4 GB is raised to 10 GB, the same 10 GiB the game gives NVIDIA's cache on Linux (hos_main.c driver_cache_room), and Home says so in its notice.

  • Core/DriverSettings.cs: RaiseShaderCache / ShaderCacheShort decide, behind INvidiaShaderCache. NvApiProfiles reads and writes the current global profile's PS_SHADERDISKCACHE_MAX_SIZE (0x00AC8497, MB; NVDRS_SETTING_V1 handled as bytes, 12320 long at pack 4). This is the setting the control panel's Global Settings changes.
  • Never lowered. Off (0), Unlimited (0xFFFFFFFF), any size of 4 GB or more, and PS_SHADERDISKCACHE turned off are all left alone, and so is a driver that doesn't know the setting.
  • If the driver saves only for an administrator (NVAPI -137, NVAPI_INVALID_USER_PRIVILEGE), Home shows a card once per launcher start: Stop shaders compiling again at every start, then "NVIDIA's shader cache holds 1 GB, and Longshot needs about 2 GB." and a quieter note ("For every game on this PC. Windows asks for permission first."). Raise to 10 GB is the primary button and Not now a quiet link. The button starts the launcher again elevated with --raise-nvidia-shader-cache, which does only that (Program.Main), and reads Waiting for Windows… while UAC asks. Success is a toast. A refusal turns the card into the steps to do it by hand, with Try again.
  • The values come from NVIDIA's open headers (nvapi_interface.h, NvApiDriverSettings.h, nvapi.h), and the MB unit from NVIDIA Profile Inspector's reference (1 GB = 0x400, 10 GB = 0x2800).

Read first: Core/DriverSettings.cs (RaiseShaderCache, NvApiProfiles.ShaderCache / SetShaderCacheMb), then LauncherService.RoomInNvidiaCache.

The game side, which logs the limit and stops counting on a cache under 4 GB, is a Longshot pull request of its own (linked in a comment).

Testing

Tested: the app and tests/launcher_core compile (dotnet build, Linux). The screenshot scene home-nvidia-cache renders the card (screenshot in the latest comment). The policy has checks in tests/launcher_core/DriverSettingsChecks.cs (NvidiaCacheChecks): 1 GB raised, not raised twice, 4 GB / 100 GB / Unlimited / Off / cache off / setting unknown left alone. Those checks have not run on this PC (no tests are run here); CI runs them.

Still to test (none of it can run on Linux):

  • Windows, NVIDIA, Shader Cache Size at 1 GB: Play shows the "now holds 10 GB" notice, and the NVIDIA Control Panel then reads 10 GB (by hand).
  • Windows, NVIDIA, a standard (non-admin) account, or wherever saving returns -137: Raise it to 10 GB shows UAC; yes raises it, no leaves the "raise it yourself" notice (by hand).
  • Windows, NVIDIA, Unlimited or 10 GB already: nothing said, nothing changed (by hand).
  • Windows, AMD or Intel: nothing said (no nvapi64.dll) (by hand).

Risks

  • It changes a global driver setting, for every game on the PC, and only upward (more disk for the driver's cache, at most 10 GB). The player can set it back in the control panel; the launcher only raises it again if they choose under 4 GB.
  • If the struct layout or ids were wrong, NVAPI returns an error status, which is caught (NvidiaProblem). The game then starts as before.
  • The UAC prompt appears only after the player clicks the button.

🤖 Generated with Claude Code

Players on NVIDIA report every pipeline compiling again with no driver update. Their shader cache is held at 1 GB (the NVIDIA Control Panel's Shader Cache Size), while a start of Longshot builds about 2 GB into it, so the driver throws pipelines out as it fills. A player who raised it to 10 GB saw no more rebuilds, and logs on the forge show caches sitting at 1025 MB ([Longshot#2079](https://git.magicbean.dev/MagicBeanDev/Longshot/issues/2079)). ## Summary On Windows, before a build (which prepares the shaders) and before Play, the launcher reads NVIDIA's Shader Cache Size through NVAPI. A size under 4 GB is raised to 10 GB, the same 10 GiB the game gives NVIDIA's cache on Linux (`hos_main.c` `driver_cache_room`), and Home says so in its notice. - `Core/DriverSettings.cs`: `RaiseShaderCache` / `ShaderCacheShort` decide, behind `INvidiaShaderCache`. `NvApiProfiles` reads and writes the current global profile's `PS_SHADERDISKCACHE_MAX_SIZE` (`0x00AC8497`, MB; `NVDRS_SETTING_V1` handled as bytes, 12320 long at pack 4). This is the setting the control panel's Global Settings changes. - Never lowered. Off (0), Unlimited (`0xFFFFFFFF`), any size of 4 GB or more, and `PS_SHADERDISKCACHE` turned off are all left alone, and so is a driver that doesn't know the setting. - If the driver saves only for an administrator (NVAPI -137, `NVAPI_INVALID_USER_PRIVILEGE`), Home shows a card once per launcher start: **Stop shaders compiling again at every start**, then "NVIDIA's shader cache holds 1 GB, and Longshot needs about 2 GB." and a quieter note ("For every game on this PC. Windows asks for permission first."). **Raise to 10 GB** is the primary button and **Not now** a quiet link. The button starts the launcher again elevated with `--raise-nvidia-shader-cache`, which does only that (`Program.Main`), and reads *Waiting for Windows…* while UAC asks. Success is a toast. A refusal turns the card into the steps to do it by hand, with **Try again**. - The values come from NVIDIA's open headers (`nvapi_interface.h`, `NvApiDriverSettings.h`, `nvapi.h`), and the MB unit from NVIDIA Profile Inspector's reference (1 GB = `0x400`, 10 GB = `0x2800`). Read first: `Core/DriverSettings.cs` (`RaiseShaderCache`, `NvApiProfiles.ShaderCache` / `SetShaderCacheMb`), then `LauncherService.RoomInNvidiaCache`. The game side, which logs the limit and stops counting on a cache under 4 GB, is a Longshot pull request of its own (linked in a comment). ## Testing **Tested:** the app and `tests/launcher_core` compile (`dotnet build`, Linux). The screenshot scene `home-nvidia-cache` renders the card (screenshot in the latest comment). The policy has checks in `tests/launcher_core/DriverSettingsChecks.cs` (`NvidiaCacheChecks`): 1 GB raised, not raised twice, 4 GB / 100 GB / Unlimited / Off / cache off / setting unknown left alone. Those checks have not run on this PC (no tests are run here); CI runs them. **Still to test** (none of it can run on Linux): - Windows, NVIDIA, Shader Cache Size at 1 GB: Play shows the "now holds 10 GB" notice, and the NVIDIA Control Panel then reads 10 GB (by hand). - Windows, NVIDIA, a standard (non-admin) account, or wherever saving returns -137: **Raise it to 10 GB** shows UAC; yes raises it, no leaves the "raise it yourself" notice (by hand). - Windows, NVIDIA, Unlimited or 10 GB already: nothing said, nothing changed (by hand). - Windows, AMD or Intel: nothing said (no nvapi64.dll) (by hand). ## Risks - It changes a global driver setting, for every game on the PC, and only upward (more disk for the driver's cache, at most 10 GB). The player can set it back in the control panel; the launcher only raises it again if they choose under 4 GB. - If the struct layout or ids were wrong, NVAPI returns an error status, which is caught (`NvidiaProblem`). The game then starts as before. - The UAC prompt appears only after the player clicks the button. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
feat(play): NVIDIA's shader cache raised to 10 GB when it holds under 4 GB, so Longshot's shaders stop compiling again
All checks were successful
CI / Compile and test (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 5s
95409fc0a4
Many players' NVIDIA shader caches are held at 1 GB (the control panel's Shader
Cache Size), while a start of Longshot builds about 2 GB of pipelines into it:
the driver throws the oldest out as it fills and they are compiled again in
play, the "everything rebuilds with no driver update" players report.

Before a build and before Play (Windows), a size under 4 GB is raised to 10 GB
through NVAPI (the current global profile's PS_SHADERDISKCACHE_MAX_SIZE, as the
control panel sets it), and Home says so. Never lowered; Off, Unlimited and a
cache turned off are left alone. Where the driver saves only for an
administrator (NVAPI -137), Home offers Raise it to 10 GB, which starts the
launcher again elevated with --raise-nvidia-shader-cache for that alone.

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

The new notice on Home (screenshot scene home-nvidia-cache), when the driver wants an administrator: Raise it to 10 GB beside it.

home-nvidia-cache.png

The new notice on Home (screenshot scene `home-nvidia-cache`), when the driver wants an administrator: **Raise it to 10 GB** beside it. ![home-nvidia-cache.png](https://git.magicbean.dev/attachments/a46c8540-3836-4c88-9870-061728cc2b98)
Member

Possibly related, for context:

  • issue MagicBeanDev/Longshot#1522 Install: Slow shader build on original Steam Deck; resumability unclear — Reports recurring shader preparation; related symptom, though not established as NVIDIA cache eviction.
Possibly related, for context: - issue MagicBeanDev/Longshot#1522 Install: Slow shader build on original Steam Deck; resumability unclear — Reports recurring shader preparation; related symptom, though not established as NVIDIA cache eviction.
Author
Owner

The game side: Longshot#2125 reads the limit, logs it, and stops counting on a cache under 4 GB.

The game side: [Longshot#2125](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2125) reads the limit, logs it, and stops counting on a cache under 4 GB.
feat(play): the NVIDIA shader cache offer as a card of its own, like the other offers
All checks were successful
CI / Compile and test (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 5s
381df7c6c6
A titled card with Not now and Raise to 10 GB (Waiting for Windows… while UAC
asks), in place of a button beside the warning notice; a refusal turns it into
the steps to do it by hand, with Try again; success is a toast.

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

The offer is now a card of its own, like the Hookshot-saves and launcher-update offers, in place of a button squeezed beside the warning notice: a title, one line with Details, Not now and Raise to 10 GB (Waiting for Windows… while UAC asks). Success is a toast; a refusal turns the card into the steps to do it by hand, with Try again.

home-nvidia-cache.png

The offer is now a card of its own, like the Hookshot-saves and launcher-update offers, in place of a button squeezed beside the warning notice: a title, one line with Details, **Not now** and **Raise to 10 GB** (*Waiting for Windows…* while UAC asks). Success is a toast; a refusal turns the card into the steps to do it by hand, with **Try again**. ![home-nvidia-cache.png](https://git.magicbean.dev/attachments/409192ea-3ec3-4f20-9432-1406d72f67be)
feat(play): the NVIDIA shader cache card redone: its whole text, one strong button
All checks were successful
CI / Compile and test (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 6s
46947bf8ea
A blue card titled Stop shaders compiling again at every start: what is wrong,
then a quieter note (every game, Windows asks), no Details; Raise to 10 GB as
the primary button, Not now as a quiet link.

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

The card redone: its whole text with no Details, Raise to 10 GB as the one strong button, Not now as a quiet link.

home-nvidia-cache.png

The card redone: its whole text with no Details, **Raise to 10 GB** as the one strong button, **Not now** as a quiet link. ![home-nvidia-cache.png](https://git.magicbean.dev/attachments/ff47977e-096a-46c0-a2ff-a7b26f70f0be)
HumanBean changed title from WIP: feat(play): NVIDIA's shader cache raised to 10 GB when it holds under 4 GB, so Longshot's shaders stop compiling again to feat(play): NVIDIA's shader cache raised to 10 GB when it holds under 4 GB, so Longshot's shaders stop compiling again 2026-11-21 21:35:31 +00:00
HumanBean deleted branch feat/nvidia-shader-cache-room 2026-11-21 21:35:49 +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/LongshotLauncher!243
No description provided.