fix(builder): the Windows sandbox's driver cache folders no longer change the drivers' id, so the shaders are not prepared again at the next start #3066

Merged
HumanBean merged 2 commits from HumanBean/Longshot:fix/shader-rebuild into main 2026-12-03 14:46:00 +00:00
Owner

Summary

On Windows, the shaders were prepared again (minutes of "Preparing the shaders") at the start after an update, and again whenever the drivers' shader cache folders were cleaned. A player reported it as "shaders are rebuilding each start".

The cause: the builder's id of the PC's drivers (windows_drivers in builder/crates/build-driver/src/shaders.rs) names the shader cache folder (…\longshot-builder\shaders\<translator>\<driver>\) and keys the record of the last preparation. It included whether %LOCALAPPDATA%\NVIDIA\DXCache, NVIDIA\GLCache and AMD\VkCache exist. The Windows sandbox now makes those folders before every confined start, the preparation's start included (build_core::sandbox_windows::plan::DRIVER_CACHES, make), so AMD's VkCache appears on an NVIDIA PC too. The result:

  1. The preparation's own sandbox makes the folders. The check after it computes another key than the one it started with, so no record of the preparation is written.
  2. The next start's fast check computes the new id. It finds another, empty cache folder (the preparation's journal "entries from 1", the program cache "begun from the shader store's copy", the pipeline cache 0 KB) and prepares everything again.
  3. It does this again each time something removes those folders: Disk Cleanup's shader caches, Storage Sense, a driver reinstall.

To see it on main: on Windows with a GPU that has no AMD VkCache folder (any NVIDIA or Intel PC), start a sandboxed game and then start it again. The second start says fast check: the shaders are to be prepared again, and the path in its vk: program cache … line holds another driver folder than the first start's.

The fix: the id no longer reads whether those folders exist. Its three lines are pinned to what they read once the sandbox has made the folders (true), so a player whose cache folder was already named after the sandbox's first start keeps it. Players who never went through that start prepare once more, and the id is then the same at every start. Linux is unaffected; its id never read these folders.

Read first: windows_drivers and its two tests in builder/crates/build-driver/src/shaders.rs.

Testing

Tested: Linux only, game-free; not run on Windows, and not seen in a game. windows_drivers_are_the_same_once_the_sandbox_made_the_drivers_cache_folders fails on the commit before the fix and passes with it; clippy -D warnings and rustfmt are clean. A Windows-target compile check did not complete. tests/run_all.py on both bug-fix branches together: 868 passed, 12 skipped, 3 failed, none from these changes: test_vk_wb_cpu_words_fast and test_i18n_complete (fails on main; #3065) and test_lifter (fails on main).

Still to test:

  • Windows, NVIDIA (ideally a laptop with an Intel iGPU too), sandbox on: delete %LOCALAPPDATA%\AMD\VkCache, then Play twice. Expecting one preparation at most, then fast check: up to date on the second start, with the same driver folder in the vk: program cache line both times (@Beanstalk on Windows NVIDIA, or by hand)
  • Windows, AMD: Play twice after the update, expecting the second start up to date (@Beanstalk)

Measurements

Nothing to measure: the fix changes which cache folder the builder picks, not the speed of a start. The gain is the skipped preparation (about 2 to 4 minutes a start on the reporting PC).

Risks

  • Windows players whose cache folder was named with one of these folders missing prepare the shaders once more after updating, then no more.
  • A player who deletes the drivers' shader caches no longer gets a new preparation for it. The game's own first start builds what it needs, as it does after any driver cache cleanup.
  • Revert to undo.

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 yet run in the game; Windows-only bug, this PC is Linux)
  • mise run test passes (any failure that also fails on main is named). (tests/run_all.py on both bug-fix branches together: 868 passed, 12 skipped, 3 failed, none from these changes: test_vk_wb_cpu_words_fast and test_i18n_complete (fails on main; #3065) and test_lifter (fails on main).)
  • 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 test commit alone fails it; with the fix both windows_drivers tests pass.)
  • 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.

🤖 Generated with Claude Code

https://claude.ai/code/session_017vw8e2fJhRpDrY7pgVx6oJ

## Summary On Windows, the shaders were prepared again (minutes of "Preparing the shaders") at the start after an update, and again whenever the drivers' shader cache folders were cleaned. A player reported it as "shaders are rebuilding each start". The cause: the builder's id of the PC's drivers (`windows_drivers` in `builder/crates/build-driver/src/shaders.rs`) names the shader cache folder (`…\longshot-builder\shaders\<translator>\<driver>\`) and keys the record of the last preparation. It included whether `%LOCALAPPDATA%\NVIDIA\DXCache`, `NVIDIA\GLCache` and `AMD\VkCache` exist. The Windows sandbox now makes those folders before every confined start, the preparation's start included (`build_core::sandbox_windows::plan::DRIVER_CACHES`, `make`), so AMD's VkCache appears on an NVIDIA PC too. The result: 1. The preparation's own sandbox makes the folders. The check after it computes another key than the one it started with, so no record of the preparation is written. 2. The next start's fast check computes the new id. It finds another, empty cache folder (the preparation's journal "entries from 1", the program cache "begun from the shader store's copy", the pipeline cache 0 KB) and prepares everything again. 3. It does this again each time something removes those folders: Disk Cleanup's shader caches, Storage Sense, a driver reinstall. To see it on `main`: on Windows with a GPU that has no AMD `VkCache` folder (any NVIDIA or Intel PC), start a sandboxed game and then start it again. The second start says `fast check: the shaders are to be prepared again`, and the path in its `vk: program cache …` line holds another driver folder than the first start's. The fix: the id no longer reads whether those folders exist. Its three lines are pinned to what they read once the sandbox has made the folders (`true`), so a player whose cache folder was already named after the sandbox's first start keeps it. Players who never went through that start prepare once more, and the id is then the same at every start. Linux is unaffected; its id never read these folders. Read first: `windows_drivers` and its two tests in `builder/crates/build-driver/src/shaders.rs`. ## Testing **Tested:** Linux only, game-free; **not run on Windows, and not seen in a game**. `windows_drivers_are_the_same_once_the_sandbox_made_the_drivers_cache_folders` fails on the commit before the fix and passes with it; clippy `-D warnings` and rustfmt are clean. A Windows-target compile check did not complete. `tests/run_all.py` on both bug-fix branches together: 868 passed, 12 skipped, 3 failed, none from these changes: `test_vk_wb_cpu_words_fast` and `test_i18n_complete` (fails on `main`; #3065) and `test_lifter` (fails on `main`). **Still to test:** - Windows, NVIDIA (ideally a laptop with an Intel iGPU too), sandbox on: delete `%LOCALAPPDATA%\AMD\VkCache`, then Play twice. Expecting one preparation at most, then `fast check: up to date` on the second start, with the same driver folder in the `vk: program cache` line both times (`@Beanstalk` on Windows NVIDIA, or by hand) - Windows, AMD: Play twice after the update, expecting the second start up to date (`@Beanstalk`) ## Measurements Nothing to measure: the fix changes which cache folder the builder picks, not the speed of a start. The gain is the skipped preparation (about 2 to 4 minutes a start on the reporting PC). ## Risks - Windows players whose cache folder was named with one of these folders missing prepare the shaders once more after updating, then no more. - A player who deletes the drivers' shader caches no longer gets a new preparation for it. The game's own first start builds what it needs, as it does after any driver cache cleanup. - Revert to undo. ## 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 yet run in the game; Windows-only bug, this PC is Linux) - [x] `mise run test` passes (any failure that also fails on `main` is named). *(`tests/run_all.py` on both bug-fix branches together: 868 passed, 12 skipped, 3 failed, none from these changes: `test_vk_wb_cpu_words_fast` and `test_i18n_complete` (fails on `main`; #3065) and `test_lifter` (fails on `main`).)* - [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 - [x] A fix: a game-free test that fails on `main` and passes here. *(The test commit alone fails it; with the fix both `windows_drivers` tests pass.)* - [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. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_017vw8e2fJhRpDrY7pgVx6oJ
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e2fJhRpDrY7pgVx6oJ
fix(builder): the Windows sandbox's driver cache folders no longer change the drivers' id, so the shaders are not prepared again at the next start
Some checks failed
PR description / Title and description (pull_request_target) Has been cancelled
CI / What the change needs (pull_request) Has been cancelled
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Has been cancelled
CI / Third-party parts and guide screenshots (pull_request) Has been cancelled
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
e3d7d2180f
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8e2fJhRpDrY7pgVx6oJ
HumanBean force-pushed fix/shader-rebuild from e3d7d2180f
Some checks failed
PR description / Title and description (pull_request_target) Has been cancelled
CI / What the change needs (pull_request) Has been cancelled
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Has been cancelled
CI / Third-party parts and guide screenshots (pull_request) Has been cancelled
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
to 9d1f8e80ee
Some checks failed
CI / What the change needs (pull_request) Successful in 6s
CI / Third-party parts and guide screenshots (pull_request) Successful in 11s
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Successful in 17s
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Failing after 1m27s
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Failing after 17m23s
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Successful in 13m10s
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Successful in 12m13s
CI / Website build and checks (pull_request) Failing after 40s
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Failing after 51m43s
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Failing after 1h0m5s
PR description / Title and description (pull_request_target) Failing after 6s
2026-12-03 09:36:46 +00:00
Compare
HumanBean changed title from WIP: fix(builder): the Windows sandbox's driver cache folders no longer change the drivers' id, so the shaders are not prepared again at the next start to fix(builder): the Windows sandbox's driver cache folders no longer change the drivers' id, so the shaders are not prepared again at the next start 2026-12-03 14:30:16 +00:00
BeanBot left a comment

Recommendation: Approve. The code is ready: only testing is left. The key change addresses the folder-creation trigger, but the Windows fix has not yet been exercised in a game on either affected Tier 1 vendor. Recommend approval; not approved on the forge.

The builder stops including driver cache folder existence in the Windows driver ID, preventing sandbox folder creation from changing the shader cache key. Players with an older key may prepare shaders once more; clearing a driver cache no longer triggers a separate builder preparation.

Testing before merging (2) (runs on the systems it can change; it doesn't hold the recommendation)

  • L1 builder/crates/build-driver/src/shaders.rs:1231: The fix and cache reuse have not been checked on Windows with NVIDIA drivers. (more on the line) Do: On Windows NVIDIA, remove the AMD VkCache folder, play twice with the sandbox enabled, and record the cache paths and fast-check results; also check startup after clearing the NVIDIA driver cache.
  • L2 builder/crates/build-driver/src/shaders.rs:1231: The changed cache selection has not been checked on Windows with AMD drivers. (more on the line) Do: On Windows AMD, play twice after the update and again after clearing VkCache; record the fast-check results and whether startup and play remain usable.

Checks: Still running: 9 checks.

More: does it help, other systems, switches, what was read

Does it help: Unproven. The author reports 2–4 minutes of preparation on the affected PC, but there is no Windows before-and-after game run; the game-free regression test is reported to fail before the fix and pass afterward.

Other systems: The change affects Windows shader cache selection and preparation receipts for all GPU vendors, with or without the sandbox. Linux and Steam Deck use a separate driver ID implementation. Driver-cache cleanup may shift compilation work to game startup; its effect has not been observed in a game.

Switches: None added, changed or removed.

Reviewed: 9d1f8e80ee against 2ca7d4f741: Read AGENTS.md, CONTRIBUTING.md, the pull request template, the full changed shaders.rs file and the relevant cache, receipt, sandbox and standards code. Skimmed the builder and build reference documentation. docs/review-checklist.md and the neighboring Tooling checkout were absent. No recorded runs, translations or generated files changed.; nothing run (a code review).

Checked and fine:

  • The test creates each sandbox driver cache folder and would detect the previous existence-dependent ID.
  • Both commits record AI assistance, and the diff contains no game-derived outputs or generated files.
  • The pinned true lines preserve the prior ID when all three folders existed.

Testing: No code or tests were run during review. The pull request reports Linux game-free tests; Windows-target compilation did not complete, and CI is still running.

Overlaps and merge order: Not checked; network unavailable.


Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, as HumanBean took it out of WIP. Nothing was run; a maintainer decides.

**Recommendation: Approve.** The code is ready: only testing is left. The key change addresses the folder-creation trigger, but the Windows fix has not yet been exercised in a game on either affected Tier 1 vendor. Recommend approval; not approved on the forge. The builder stops including driver cache folder existence in the Windows driver ID, preventing sandbox folder creation from changing the shader cache key. Players with an older key may prepare shaders once more; clearing a driver cache no longer triggers a separate builder preparation. **Testing before merging (2)** (runs on the systems it can change; it doesn't hold the recommendation) - **L1** `builder/crates/build-driver/src/shaders.rs:1231`: The fix and cache reuse have not been checked on Windows with NVIDIA drivers. (more on the line) **Do:** On Windows NVIDIA, remove the AMD VkCache folder, play twice with the sandbox enabled, and record the cache paths and fast-check results; also check startup after clearing the NVIDIA driver cache. - **L2** `builder/crates/build-driver/src/shaders.rs:1231`: The changed cache selection has not been checked on Windows with AMD drivers. (more on the line) **Do:** On Windows AMD, play twice after the update and again after clearing VkCache; record the fast-check results and whether startup and play remain usable. **Checks:** Still running: 9 checks. <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Unproven. The author reports 2–4 minutes of preparation on the affected PC, but there is no Windows before-and-after game run; the game-free regression test is reported to fail before the fix and pass afterward. **Other systems:** The change affects Windows shader cache selection and preparation receipts for all GPU vendors, with or without the sandbox. Linux and Steam Deck use a separate driver ID implementation. Driver-cache cleanup may shift compilation work to game startup; its effect has not been observed in a game. **Switches:** None added, changed or removed. **Reviewed:** 9d1f8e80ee38 against 2ca7d4f74182: Read AGENTS.md, CONTRIBUTING.md, the pull request template, the full changed shaders.rs file and the relevant cache, receipt, sandbox and standards code. Skimmed the builder and build reference documentation. docs/review-checklist.md and the neighboring Tooling checkout were absent. No recorded runs, translations or generated files changed.; nothing run (a code review). **Checked and fine:** - The test creates each sandbox driver cache folder and would detect the previous existence-dependent ID. - Both commits record AI assistance, and the diff contains no game-derived outputs or generated files. - The pinned true lines preserve the prior ID when all three folders existed. **Testing:** No code or tests were run during review. The pull request reports Linux game-free tests; Windows-target compilation did not complete, and CI is still running. **Overlaps and merge order:** Not checked; network unavailable. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, as HumanBean took it out of WIP. Nothing was run; a maintainer decides.</sub>
@ -1229,0 +1228,4 @@
// confined start (build_core::sandbox_windows::plan::DRIVER_CACHES), so the id changed after the first one and the
// next start prepared every shader again in another, empty cache folder. The lines stay as they read once the
// sandbox made the folders, so a cache folder named after that keeps its name)
if get("LOCALAPPDATA").is_some() {
Member

L1 (should fix): The fix and cache reuse have not been checked on Windows with NVIDIA drivers.

When: With the AMD VkCache folder absent, a sandboxed preparation creates it; the reported failure is another preparation on the following start. The unit test checks the ID but does not exercise the preparation receipt or a real driver.

Do: On Windows NVIDIA, remove the AMD VkCache folder, play twice with the sandbox enabled, and record the cache paths and fast-check results; also check startup after clearing the NVIDIA driver cache.

**L1** (should fix): The fix and cache reuse have not been checked on Windows with NVIDIA drivers. *When:* With the AMD VkCache folder absent, a sandboxed preparation creates it; the reported failure is another preparation on the following start. The unit test checks the ID but does not exercise the preparation receipt or a real driver. **Do:** On Windows NVIDIA, remove the AMD VkCache folder, play twice with the sandbox enabled, and record the cache paths and fast-check results; also check startup after clearing the NVIDIA driver cache.
Member

L2 (should fix): The changed cache selection has not been checked on Windows with AMD drivers.

When: An AMD player can retain the same preparation receipt after VkCache is cleared, so the next game start must rebuild whatever the driver needs without another builder preparation.

Do: On Windows AMD, play twice after the update and again after clearing VkCache; record the fast-check results and whether startup and play remain usable.

**L2** (should fix): The changed cache selection has not been checked on Windows with AMD drivers. *When:* An AMD player can retain the same preparation receipt after VkCache is cleared, so the next game start must rebuild whatever the driver needs without another builder preparation. **Do:** On Windows AMD, play twice after the update and again after clearing VkCache; record the fast-check results and whether startup and play remain usable.
Author
Owner

BeanBot's review, at 9d1f8e80: nothing to change in the code. Both points are Windows runs, which haven't happened (this PC is Linux), so L1 and L2 stay open and so does the unticked box. The Test Farm plays scenes before and after a change; it doesn't cover deleting a folder and playing twice, so this needs someone on Windows, by hand, with a build of this branch:

  1. Delete %LOCALAPPDATA%\AMD\VkCache (NVIDIA or Intel PC; on AMD, skip this the first time).
  2. Play, let the shaders prepare, quit.
  3. Play again.

Pass: the second start says fast check: up to date and does not prepare, and the vk: program cache line holds the same driver folder both times. On AMD, then delete VkCache, play once more and say whether the game starts and plays as usual.

BeanBot's review, at 9d1f8e80: nothing to change in the code. Both points are Windows runs, which haven't happened (this PC is Linux), so **L1** and **L2** stay open and so does the unticked box. The Test Farm plays scenes before and after a change; it doesn't cover deleting a folder and playing twice, so this needs someone on Windows, by hand, with a build of this branch: 1. Delete `%LOCALAPPDATA%\AMD\VkCache` (NVIDIA or Intel PC; on AMD, skip this the first time). 2. Play, let the shaders prepare, quit. 3. Play again. Pass: the second start says `fast check: up to date` and does not prepare, and the `vk: program cache` line holds the same driver folder both times. On AMD, then delete `VkCache`, play once more and say whether the game starts and plays as usual.
HumanBean deleted branch fix/shader-rebuild 2026-12-03 14:46:00 +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!3066
No description provided.