fix(victory-shader): exclude non-translation switches and test files from shader cache key #301

Merged
mauroalvare merged 4 commits from upstream-pr/301 into main 2026-11-27 19:38:44 +00:00
mauroalvare commented 2026-11-26 01:52:20 +00:00 (Migrated from github.com)

Imported from LooperSalty/AnyXboxX. Originally posted by mauroalvare on 2026-11-26T01:52:20Z.


Change

Stops non-translation switches and test/utility files from polluting VICTORY_SHADER_SWITCHES and VICTORY_SHADER_SOURCE_HASH in third_party/victory/crates/victory-shader/build.rs (base c4c93bdc413191a9dc909998d2d53080a3f0c880).

Previously, victory-shader/build.rs walked every .rs file under src/ (including *_tests.rs, the uncompiled orphan emit/desc_data_tests.rs, emit/host.rs, emit/validator.rs, and emit/bitcode/census.rs) and scraped every "VICTORY_*" string literal into VICTORY_SHADER_SWITCHES, which emit::translation_fingerprint() hashes into the on-disk shader cache key. As a result:

  • Toggling VICTORY_D3D12_DEBUG=1 (from emit/host.rs), VICTORY_WAVE_WHY=1, VICTORY_DESC_WHY=1, VICTORY_SHADER_CENSUS=<file>, VICTORY_WARP=1, or VICTORY_DXIL=<path> invalidated 100% of the shader cache even though none of them change the emitted DXIL.
  • Switching between tools/lancer_victory.ps1 (which sets VICTORY_DESC_DATA=1) and -NoTunedSettings (which leaves VICTORY_DESC_DATA unset) also invalidated 100% of the shader cache, even though no compiled code reads VICTORY_DESC_DATA (it only exists in the uncompiled orphan emit/desc_data_tests.rs).
  • Even VICTORY_SHADER_SOURCE_HASH and VICTORY_SHADER_SWITCHES themselves (from env!(...) in emit/mod.rs) were scraped into VICTORY_SHADER_SWITCHES.
  • Editing any *_tests.rs unit-test file invalidated the shader cache via VICTORY_SHADER_SOURCE_HASH.

What changed:

  • Skip *_tests.rs, emit/host.rs, emit/validator.rs, and emit/bitcode/census.rs when computing VICTORY_SHADER_SOURCE_HASH and VICTORY_SHADER_SWITCHES.
  • Skip non-translation literals (*_WHY, VICTORY_SHADER_SOURCE_HASH, VICTORY_SHADER_SWITCHES, VICTORY_REF_VS, VICTORY_REF_PS) from VICTORY_SHADER_SWITCHES.
  • All real translation switches (VICTORY_F16_NEAREST, VICTORY_GROUP_SYNC, VICTORY_SHADER_OPT, VICTORY_SHADER_LOOP_LIMIT, VICTORY_WAVE_*, VICTORY_STRICT_JOINS, etc.) remain in VICTORY_SHADER_SWITCHES and still invalidate the cache as expected.

Linked issue: N/A

Verification

Base reproduction (c4c93bd, before the fix):

cargo test --locked -p victory-shader --test fingerprint_switches
-> FAILED. 0 passed; 1 failed
   non-translation switches changed translation_fingerprint() and would invalidate the shader cache
   (VICTORY_D3D12_DEBUG, VICTORY_DESC_DATA, VICTORY_DESC_WHY, VICTORY_WAVE_WHY, VICTORY_SHADER_CENSUS, VICTORY_WARP, VICTORY_DXIL, plus VICTORY_SHADER_SOURCE_HASH and VICTORY_SHADER_SWITCHES were all in VICTORY_SHADER_SWITCHES)

After the fix (ab7ee46):

cargo test --locked -p victory-shader --test fingerprint_switches -> ok. 1 passed; 0 failed (0.00s)
cargo check --locked -p victory                                   -> Finished `dev` profile in 12.66s
cargo xtask policy                                                -> asset policy: 200 files ok
python -m pytest tests/test_lanceur_victory.py -q                 -> 25 passed in 9.89s

No GPU execution is needed for this build-script / fingerprint test (pure CPU); verified on Windows x64 (Ryzen 7 9700X, RTX 5070 Ti, 32 GB RAM).

Oracle and test data

New integration test third_party/victory/crates/victory-shader/tests/fingerprint_switches.rs toggles 11 non-translation switches and verifies translation_fingerprint() is unchanged, then toggles VICTORY_F16_NEAREST=1 and verifies translation_fingerprint() changes. Fails on base c4c93bd and passes with this change. No game, console, or SDK files were used.

Checklist

  • The PR covers a single reviewable behaviour.
  • A test fails without this change and passes with it.
  • The commands and results of each check are given above.
  • An unimplemented function returns an error (E_NOTIMPL), never a fake success.
  • README: the same change in all 9 languages (test_readme_sync.py checks it).
  • No game, console or SDK file, no key, no dump, no download link.
  • Findings drawn from a title: limited to what rule 2 of AGENTS.md allows (names, slots, argument shapes, flag values, HRESULTs, IIDs, counts), with how they were obtained; no address or RVA.
  • Code taken from another project: compatible licence and credit in THIRD_PARTY.md.

Made with AI assistance (Antigravity).

<!-- greyfinch-sync:LooperSalty/AnyXboxX:issue:5502513486 --> Imported from [LooperSalty/AnyXboxX](https://github.com/LooperSalty/AnyXboxX/pull/301). Originally posted by [mauroalvare](https://github.com/mauroalvare) on 2026-11-26T01:52:20Z. --- ## Change Stops non-translation switches and test/utility files from polluting `VICTORY_SHADER_SWITCHES` and `VICTORY_SHADER_SOURCE_HASH` in `third_party/victory/crates/victory-shader/build.rs` (base `c4c93bdc413191a9dc909998d2d53080a3f0c880`). Previously, `victory-shader/build.rs` walked every `.rs` file under `src/` (including `*_tests.rs`, the uncompiled orphan `emit/desc_data_tests.rs`, `emit/host.rs`, `emit/validator.rs`, and `emit/bitcode/census.rs`) and scraped every `"VICTORY_*"` string literal into `VICTORY_SHADER_SWITCHES`, which `emit::translation_fingerprint()` hashes into the on-disk shader cache key. As a result: - Toggling `VICTORY_D3D12_DEBUG=1` (from `emit/host.rs`), `VICTORY_WAVE_WHY=1`, `VICTORY_DESC_WHY=1`, `VICTORY_SHADER_CENSUS=<file>`, `VICTORY_WARP=1`, or `VICTORY_DXIL=<path>` invalidated 100% of the shader cache even though none of them change the emitted DXIL. - Switching between `tools/lancer_victory.ps1` (which sets `VICTORY_DESC_DATA=1`) and `-NoTunedSettings` (which leaves `VICTORY_DESC_DATA` unset) also invalidated 100% of the shader cache, even though no compiled code reads `VICTORY_DESC_DATA` (it only exists in the uncompiled orphan `emit/desc_data_tests.rs`). - Even `VICTORY_SHADER_SOURCE_HASH` and `VICTORY_SHADER_SWITCHES` themselves (from `env!(...)` in `emit/mod.rs`) were scraped into `VICTORY_SHADER_SWITCHES`. - Editing any `*_tests.rs` unit-test file invalidated the shader cache via `VICTORY_SHADER_SOURCE_HASH`. What changed: - Skip `*_tests.rs`, `emit/host.rs`, `emit/validator.rs`, and `emit/bitcode/census.rs` when computing `VICTORY_SHADER_SOURCE_HASH` and `VICTORY_SHADER_SWITCHES`. - Skip non-translation literals (`*_WHY`, `VICTORY_SHADER_SOURCE_HASH`, `VICTORY_SHADER_SWITCHES`, `VICTORY_REF_VS`, `VICTORY_REF_PS`) from `VICTORY_SHADER_SWITCHES`. - All real translation switches (`VICTORY_F16_NEAREST`, `VICTORY_GROUP_SYNC`, `VICTORY_SHADER_OPT`, `VICTORY_SHADER_LOOP_LIMIT`, `VICTORY_WAVE_*`, `VICTORY_STRICT_JOINS`, etc.) remain in `VICTORY_SHADER_SWITCHES` and still invalidate the cache as expected. Linked issue: N/A ## Verification Base reproduction (`c4c93bd`, before the fix): ``` cargo test --locked -p victory-shader --test fingerprint_switches -> FAILED. 0 passed; 1 failed non-translation switches changed translation_fingerprint() and would invalidate the shader cache (VICTORY_D3D12_DEBUG, VICTORY_DESC_DATA, VICTORY_DESC_WHY, VICTORY_WAVE_WHY, VICTORY_SHADER_CENSUS, VICTORY_WARP, VICTORY_DXIL, plus VICTORY_SHADER_SOURCE_HASH and VICTORY_SHADER_SWITCHES were all in VICTORY_SHADER_SWITCHES) ``` After the fix (`ab7ee46`): ``` cargo test --locked -p victory-shader --test fingerprint_switches -> ok. 1 passed; 0 failed (0.00s) cargo check --locked -p victory -> Finished `dev` profile in 12.66s cargo xtask policy -> asset policy: 200 files ok python -m pytest tests/test_lanceur_victory.py -q -> 25 passed in 9.89s ``` No GPU execution is needed for this build-script / fingerprint test (pure CPU); verified on Windows x64 (Ryzen 7 9700X, RTX 5070 Ti, 32 GB RAM). ## Oracle and test data New integration test `third_party/victory/crates/victory-shader/tests/fingerprint_switches.rs` toggles 11 non-translation switches and verifies `translation_fingerprint()` is unchanged, then toggles `VICTORY_F16_NEAREST=1` and verifies `translation_fingerprint()` changes. Fails on base `c4c93bd` and passes with this change. No game, console, or SDK files were used. ## Checklist - [x] The PR covers a single reviewable behaviour. - [x] A test fails without this change and passes with it. - [x] The commands and results of each check are given above. - [x] An unimplemented function returns an error (`E_NOTIMPL`), never a fake success. - [x] README: the same change in all 9 languages (`test_readme_sync.py` checks it). - [x] No game, console or SDK file, no key, no dump, no download link. - [x] Findings drawn from a title: limited to what rule 2 of `AGENTS.md` allows (names, slots, argument shapes, flag values, HRESULTs, IIDs, counts), with how they were obtained; no address or RVA. - [x] Code taken from another project: compatible licence and credit in `THIRD_PARTY.md`. Made with AI assistance (Antigravity).
LooperSalty commented 2026-11-27 16:24:30 +00:00 (Migrated from github.com)

Imported from LooperSalty/AnyXboxX. Originally posted by LooperSalty on 2026-11-27T16:24:30Z.


Looks good: the skipped files and switches I checked (standalone test host, validator, census, *_WHY logging) do not change the emitted DXIL, and the test fails without the change. One suggestion for build.rs skip_switch: name.ends_with("_WHY") relies on a naming convention, so a future VICTORY_X_WHY that does change translation would silently drop out of the key and serve stale shaders. An explicit list of the diagnostic switches (and a one-line comment at each *_WHY call site saying it must stay diagnostic-only) would make that fail closed.

<!-- greyfinch-sync:LooperSalty/AnyXboxX:comment:7223225276 --> Imported from [LooperSalty/AnyXboxX](https://github.com/LooperSalty/AnyXboxX/pull/301#issuecomment-7223225276). Originally posted by [LooperSalty](https://github.com/LooperSalty) on 2026-11-27T16:24:30Z. --- Looks good: the skipped files and switches I checked (standalone test host, validator, census, `*_WHY` logging) do not change the emitted DXIL, and the test fails without the change. One suggestion for `build.rs` `skip_switch`: `name.ends_with("_WHY")` relies on a naming convention, so a future `VICTORY_X_WHY` that does change translation would silently drop out of the key and serve stale shaders. An explicit list of the diagnostic switches (and a one-line comment at each `*_WHY` call site saying it must stay diagnostic-only) would make that fail closed.
mauroalvare commented 2026-11-27 17:57:26 +00:00 (Migrated from github.com)

Imported from LooperSalty/AnyXboxX. Originally posted by mauroalvare on 2026-11-27T17:57:26Z.


Updated in 7af400d:

  • Replaced name.ends_with("_WHY") in victory-shader/build.rs skip_switch with explicit entries (VICTORY_DESC_WHY, VICTORY_WAVE_WHY) so any future VICTORY_*_WHY fails closed into the cache key.
  • Added a one-line comment at every VICTORY_DESC_WHY and VICTORY_WAVE_WHY call site (emit/lower.rs, emit/mod.rs) noting that it must stay diagnostic-only.

Re-verified fingerprint_switches and cargo xtask policy (286 files ok).

<!-- greyfinch-sync:LooperSalty/AnyXboxX:comment:7224965694 --> Imported from [LooperSalty/AnyXboxX](https://github.com/LooperSalty/AnyXboxX/pull/301#issuecomment-7224965694). Originally posted by [mauroalvare](https://github.com/mauroalvare) on 2026-11-27T17:57:26Z. --- Updated in `7af400d`: - Replaced `name.ends_with("_WHY")` in `victory-shader/build.rs` `skip_switch` with explicit entries (`VICTORY_DESC_WHY`, `VICTORY_WAVE_WHY`) so any future `VICTORY_*_WHY` fails closed into the cache key. - Added a one-line comment at every `VICTORY_DESC_WHY` and `VICTORY_WAVE_WHY` call site (`emit/lower.rs`, `emit/mod.rs`) noting that it must stay diagnostic-only. Re-verified `fingerprint_switches` and `cargo xtask policy` (286 files ok).
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
LooperSalty/AnyXboxX!301
No description provided.