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
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/mods
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!3066
Loading…
Reference in a new issue
No description provided.
Delete branch "HumanBean/Longshot:fix/shader-rebuild"
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
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_driversinbuilder/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\GLCacheandAMD\VkCacheexist. 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:To see it on
main: on Windows with a GPU that has no AMDVkCachefolder (any NVIDIA or Intel PC), start a sandboxed game and then start it again. The second start saysfast check: the shaders are to be prepared again, and the path in itsvk: 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_driversand its two tests inbuilder/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_foldersfails on the commit before the fix and passes with it; clippy-D warningsand rustfmt are clean. A Windows-target compile check did not complete.tests/run_all.pyon both bug-fix branches together: 868 passed, 12 skipped, 3 failed, none from these changes:test_vk_wb_cpu_words_fastandtest_i18n_complete(fails onmain; #3065) andtest_lifter(fails onmain).Still to test:
%LOCALAPPDATA%\AMD\VkCache, then Play twice. Expecting one preparation at most, thenfast check: up to dateon the second start, with the same driver folder in thevk: program cacheline both times (@Beanstalkon Windows NVIDIA, or by hand)@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
Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named). (tests/run_all.pyon both bug-fix branches together: 868 passed, 12 skipped, 3 failed, none from these changes:test_vk_wb_cpu_words_fastandtest_i18n_complete(fails onmain; #3065) andtest_lifter(fails onmain).)main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
mainand passes here. (The test commit alone fails it; with the fix bothwindows_driverstests pass.)Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.🤖 Generated with Claude Code
https://claude.ai/code/session_017vw8e2fJhRpDrY7pgVx6oJ
e3d7d2180f9d1f8e80eeWIP: 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 startto 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 startRecommendation: 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)
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.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:
9d1f8e80eeagainst2ca7d4f741: 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:
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.
@ -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() {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.
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.
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:%LOCALAPPDATA%\AMD\VkCache(NVIDIA or Intel PC; on AMD, skip this the first time).Pass: the second start says
fast check: up to dateand does not prepare, and thevk: program cacheline holds the same driver folder both times. On AMD, then deleteVkCache, play once more and say whether the game starts and plays as usual.