play: keep VICTORY_KEEP_OLD_SHADERS from environment across prepare #4387

Open
nidea1 wants to merge 2 commits from upstream-pr/4387 into main
nidea1 commented 2026-11-30 19:35:10 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by nidea1 on 2026-11-30T19:35:10Z.


Follow-up to #4231 (reported by @Kwaarckmoon).

What it changes

play::clear_stale_shaders checks VICTORY_KEEP_OLD_SHADERS=1 from the environment, and play::preload spawns a child victory preload process that runs the same check. However, on victory play, clear_stale_shaders runs inside play::prepare(..).and_then(..), after prepare clears every inherited VICTORY_* variable not listed in KEPT. Because VICTORY_KEEP_OLD_SHADERS was not in KEPT, setting VICTORY_KEEP_OLD_SHADERS=1 in the caller's environment was silently stripped and the old shader cache was still deleted (only --set VICTORY_KEEP_OLD_SHADERS=1 or a line in victory-settings.txt worked).

  • Add "VICTORY_KEEP_OLD_SHADERS" to KEPT in apps/victory/src/play.rs so the environment variable survives play::prepare (and any child victory preload spawned by play), while an explicit --set VICTORY_KEEP_OLD_SHADERS=... or victory-settings.txt line still overrides it.
  • Extend play::tests::play_keeps_the_storage_paths_when_resetting_switches to cover VICTORY_KEEP_OLD_SHADERS case-insensitively.

How it was tested

  • GPU and profile (Series X or S, resolution, DLSS, frame generation, ray tracing): Windows 11 x64 unit/integration tests (apps/victory); launcher env-handling fix (no runtime GPU change).
  • Before: stale_switch("VICTORY_KEEP_OLD_SHADERS") returned true, so play::prepare stripped inherited VICTORY_KEEP_OLD_SHADERS=1 before clear_stale_shaders ran.
  • After: stale_switch("VICTORY_KEEP_OLD_SHADERS") and stale_switch("victory_keep_old_shaders") return false, keeping the env var intact for clear_stale_shaders and child preload.
  • For shader changes, the wave sizes tested (32 and/or 64 lanes): N/A.
  • cargo test passed for the crates it touches: yes (cargo test -j 4 -p victory --locked: 91/91 unit + 3/3 integration tests passed; cargo clippy -j 4 -p victory --all-targets --locked --no-deps -- -D warnings: 0 warnings; cargo run -p xtask -- policy --staged: 1 files ok).

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. Related: #4231, #4014 (adds VRAM/room knobs to KEPT, does not include VICTORY_KEEP_OLD_SHADERS).
<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5572371897 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4387). Originally posted by [nidea1](https://github.com/nidea1) on 2026-11-30T19:35:10Z. --- Follow-up to #4231 (reported by @Kwaarckmoon). ## What it changes `play::clear_stale_shaders` checks `VICTORY_KEEP_OLD_SHADERS=1` from the environment, and `play::preload` spawns a child `victory preload` process that runs the same check. However, on `victory play`, `clear_stale_shaders` runs inside `play::prepare(..).and_then(..)`, after `prepare` clears every inherited `VICTORY_*` variable not listed in `KEPT`. Because `VICTORY_KEEP_OLD_SHADERS` was not in `KEPT`, setting `VICTORY_KEEP_OLD_SHADERS=1` in the caller's environment was silently stripped and the old shader cache was still deleted (only `--set VICTORY_KEEP_OLD_SHADERS=1` or a line in `victory-settings.txt` worked). - Add `"VICTORY_KEEP_OLD_SHADERS"` to `KEPT` in `apps/victory/src/play.rs` so the environment variable survives `play::prepare` (and any child `victory preload` spawned by `play`), while an explicit `--set VICTORY_KEEP_OLD_SHADERS=...` or `victory-settings.txt` line still overrides it. - Extend `play::tests::play_keeps_the_storage_paths_when_resetting_switches` to cover `VICTORY_KEEP_OLD_SHADERS` case-insensitively. ## How it was tested - GPU and profile (Series X or S, resolution, DLSS, frame generation, ray tracing): Windows 11 x64 unit/integration tests (`apps/victory`); launcher env-handling fix (no runtime GPU change). - Before: `stale_switch("VICTORY_KEEP_OLD_SHADERS")` returned `true`, so `play::prepare` stripped inherited `VICTORY_KEEP_OLD_SHADERS=1` before `clear_stale_shaders` ran. - After: `stale_switch("VICTORY_KEEP_OLD_SHADERS")` and `stale_switch("victory_keep_old_shaders")` return `false`, keeping the env var intact for `clear_stale_shaders` and child `preload`. - For shader changes, the wave sizes tested (32 and/or 64 lanes): N/A. - `cargo test` passed for the crates it touches: yes (`cargo test -j 4 -p victory --locked`: 91/91 unit + 3/3 integration tests passed; `cargo clippy -j 4 -p victory --all-targets --locked --no-deps -- -D warnings`: 0 warnings; `cargo run -p xtask -- policy --staged`: 1 files ok). ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. Related: #4231, #4014 (adds VRAM/room knobs to `KEPT`, does not include `VICTORY_KEEP_OLD_SHADERS`).
babuakhil commented 2026-11-30 19:55:05 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by babuakhil on 2026-11-30T19:55:05Z.


Checked on Windows 11 (Rust 1.98.1, pinned), on main (e1251c31), which this is based on. cargo test -p victory passes (91 unit, 1 + 2 integration), and cargo clippy -p victory --all-targets --no-deps -- -D warnings is clean. Not tested in the game.

The order is as described. In main.rs's Command::Play arm, play::prepare runs first and removes every name leftovers() returns, which is stale_switch over the environment, and only then does play::clear_stale_shaders(named_cache) read VICTORY_KEEP_OLD_SHADERS. The other switches that arm needs (VICTORY_PRELOAD, VICTORY_CLEAR_SHADERS, VICTORY_CACHE_DIR) are read before prepare for that reason, and this one was missed. With the KEPT line taken back out, the extended test fails (stale_switch("victory_keep_old_shaders") is true), and with it the test passes.

Keeping it in KEPT, rather than reading it before prepare like the other three, also carries it into the victory preload child, whose own clear_stale_shaders (the Shaders | Warm | Preload arm) reads the same variable. So this is the better of the two ways to fix it.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7290131272 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4387#issuecomment-7290131272). Originally posted by [babuakhil](https://github.com/babuakhil) on 2026-11-30T19:55:05Z. --- Checked on Windows 11 (Rust 1.98.1, pinned), on `main` (`e1251c31`), which this is based on. `cargo test -p victory` passes (91 unit, 1 + 2 integration), and `cargo clippy -p victory --all-targets --no-deps -- -D warnings` is clean. Not tested in the game. The order is as described. In `main.rs`'s `Command::Play` arm, `play::prepare` runs first and removes every name `leftovers()` returns, which is `stale_switch` over the environment, and only then does `play::clear_stale_shaders(named_cache)` read `VICTORY_KEEP_OLD_SHADERS`. The other switches that arm needs (`VICTORY_PRELOAD`, `VICTORY_CLEAR_SHADERS`, `VICTORY_CACHE_DIR`) are read before `prepare` for that reason, and this one was missed. With the `KEPT` line taken back out, the extended test fails (`stale_switch("victory_keep_old_shaders")` is true), and with it the test passes. Keeping it in `KEPT`, rather than reading it before `prepare` like the other three, also carries it into the `victory preload` child, whose own `clear_stale_shaders` (the `Shaders | Warm | Preload` arm) reads the same variable. So this is the better of the two ways to fix it.
andrewpozdnakov7-jpg commented 2026-12-01 10:10:23 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by andrewpozdnakov7-jpg on 2026-12-01T10:10:23Z.


The PowerShell launcher has the same gap as the native launcher. play-nvidia.ps1 removes VICTORY_KEEP_OLD_SHADERS before either warm --used or preload enters clear_stale_shaders. I added the setting to the script's existing preserved environment entries in 41de5c1588b861b59c4cc6b23b859d3c8018129f, directly on your 2afbf6da head. Review commit

In Windows PowerShell 5.1, I ran the exact environment filter with synthetic entries. Your head selected both uppercase and lowercase spellings of the setting for removal. The updated filter kept both and still selected an unrelated flag for removal. The script parsed and the one-file staged policy check passed.

The commit is ready to include here if you want both launchers to honor the setting. Please preserve the Git author on cherry-pick or rebase, or add Co-authored-by: andrewpozdnakov7-jpg <[email protected]> if folding it in.

AI-assisted with OpenAI Codex.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7307781048 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4387#issuecomment-7307781048). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-12-01T10:10:23Z. --- The PowerShell launcher has the same gap as the native launcher. `play-nvidia.ps1` removes `VICTORY_KEEP_OLD_SHADERS` before either `warm --used` or `preload` enters `clear_stale_shaders`. I added the setting to the script's existing preserved environment entries in 41de5c1588b861b59c4cc6b23b859d3c8018129f, directly on your `2afbf6da` head. [Review commit](https://github.com/andrewpozdnakov7-jpg/VIctory-NVIDIA/commit/41de5c1588b861b59c4cc6b23b859d3c8018129f) In Windows PowerShell 5.1, I ran the exact environment filter with synthetic entries. Your head selected both uppercase and lowercase spellings of the setting for removal. The updated filter kept both and still selected an unrelated flag for removal. The script parsed and the one-file staged policy check passed. The commit is ready to include here if you want both launchers to honor the setting. Please preserve the Git author on cherry-pick or rebase, or add `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>` if folding it in. AI-assisted with OpenAI Codex.
nidea1 commented 2026-12-01 10:55:10 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by nidea1 on 2026-12-01T10:55:10Z.


Thanks @andrewpozdnakov7-jpg! Cherry-picked onto this branch as 9eceadf7b2 (from 41de5c1588) with your original Git author preserved. Verified scripts/play-nvidia.ps1 parses cleanly with CRLF preserved, along with cargo test --locked -p victory, cargo clippy --locked -p victory --all-targets -- -D warnings, and cargo xtask policy.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7308912996 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4387#issuecomment-7308912996). Originally posted by [nidea1](https://github.com/nidea1) on 2026-12-01T10:55:10Z. --- Thanks @andrewpozdnakov7-jpg! Cherry-picked onto this branch as 9eceadf7b20b4267dda1b4569bc3bbc006caf171 (from `41de5c1588`) with your original Git author preserved. Verified `scripts/play-nvidia.ps1` parses cleanly with CRLF preserved, along with `cargo test --locked -p victory`, `cargo clippy --locked -p victory --all-targets -- -D warnings`, and `cargo xtask policy`.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/4387:upstream-pr/4387'
git switch 'upstream-pr/4387'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/4387'
git switch 'upstream-pr/4387'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/4387'
git switch 'upstream-pr/4387'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/4387'
git switch 'main'
git merge --squash 'upstream-pr/4387'
git switch 'main'
git merge --ff-only 'upstream-pr/4387'
git switch 'main'
git merge 'upstream-pr/4387'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
trustno1-coder/VIctory-NVIDIA!4387
No description provided.