Shader cache: six translator switches the key left out are in it, and a test checks every switch #807

Manually merged
github merged 1 commit from github-bot/gh-807 into main 2026-11-29 00:27:57 +00:00 AGit
Owner

@⁠kibagami-nc on GitHub · 2026-11-28 06:31 UTC · original
kibagami-nc:fix/shader-cache-keys-loop-and-lds-switches → main · +100 −28 · 2 files · 1 commits · merged 2026-11-29 00:24 UTC

Found while choosing the tests to ask for in #739, the water light's tile-sized blocks under water.

Rebuilt on main (923e38c). Its new test found three more switches missing from the key, added by today's merges, so six are keyed now. Main's own two new names (VICTORY_WATER_VOLUME_PORTALS, VICTORY_LDS_BOUNDS_EXEMPT) are in KEYED too.

What happens

These switches change how a program is translated, and none of them is in the shader cache's key:

Switch What it changes Since
VICTORY_LOOPS_WAVE whether the branches that close or leave a program's loops are taken by each host wave together 64d4931
VICTORY_LDS_FIRST_INIT whether the first thread sets up the LDS
VICTORY_LDS_INIT_HOIST whether accumulator initialisations are also stored at the start of the program (lds_init_hoist_on in lower.rs) 759f05c
VICTORY_HDR_CLAMP whether pixel float colour outputs are held to the console's HDR range (on; =0 turns it off) 2e855b0
VICTORY_SAMPLED_MARKS whether texture reads through a heap slot mark that slot (=1; off by default) a410fd0
VICTORY_DEFRAG whether CS_DefragHeap_ComputeRelocations is translated (=0 leaves it untranslated, for comparisons) d4d7193

The comment in pipeline/make.rs credits the first two for the water light's open-water fix.

A run that changes one of them is served the translations an earlier run cached without the change, so the switch looks as if it did nothing. For example, VICTORY_SAMPLED_MARKS=1 gets programs that mark no slot, and VICTORY_DEFRAG=0 still runs the defragmentation from the cache. The comment above the list already describes the same trap for VICTORY_WAVE_WIDE.

The change

  • Cache key: the list of switches keyed by name is now a const, KEYED, with the six names added.

  • Translator: victory_shader::emit::SWITCHES gives the list of VICTORY_* switches that the translator's build.rs already gathers from its sources (VICTORY_SHADER_SWITCHES). translation_fingerprint() now reads the same const.

  • Test: a new test checks every switch on that list. Each one must be either:

    • in KEYED;
    • in the key another way: loop limit, group sync, early depth, shader passes, ray-tracing no-hit, or host settings (VICTORY_RDNA_FLOAT through host_rdna);
    • one that changes no translation: what the translator reports, the host it is told of, where its tools are, or the tests' (VICTORY_REQUIRE_HW_GPU).

    A new switch that is none of these fails the test. So does a listed name the translator no longer reads.

The key changes, so every translation is made again once after the update, as after any translator change.

Why not translation_fingerprint()

Main already has victory_shader::emit::translation_fingerprint() (847a0af). It keys every switch the translator names, but nothing calls it: the cache's key is still build() in shader_cache.rs.

Keying on it would also key the switches that change no translation, such as VICTORY_WAVE_WHY, VICTORY_EMIT_DUMP or VICTORY_ADAPTER. A run with one of those set would then translate everything again. So this PR keeps the cache's own list, and the test keeps that list complete.

#550 adds VICTORY_CODE_TABLE_AFTER to the same list. Whichever of the two lands second needs to add one line.

Tests

  • New test shader_cache::tests::every_switch_of_the_translator_is_in_the_key. It passes. It fails without the names it found:
    • on 32ecacf, with ["VICTORY_LDS_FIRST_INIT", "VICTORY_LDS_INIT_HOIST", "VICTORY_LOOPS_WAVE"];
    • on 923e38c, with ["VICTORY_DEFRAG", "VICTORY_HDR_CLAMP", "VICTORY_SAMPLED_MARKS"].
  • cargo test -p victory-gpu --lib --locked: 551 passed, 43 ignored.
  • Clippy (workspace, --all-targets, default and --all-features): nothing in the changed lines. Main 923e38c has findings of its own: 13 in the default build and 11 with --all-features. Among them: an unused colour and a manual_checked_ops in lower.rs, dead code in send.rs, pool.rs and resource.rs, too many arguments, and a drop of a reference in host.rs.
**@⁠kibagami-nc** on GitHub · 2026-11-28 06:31 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/807) `kibagami-nc:fix/shader-cache-keys-loop-and-lds-switches` → `main` · +100 −28 · 2 files · 1 commits · merged 2026-11-29 00:24 UTC Found while choosing the tests to ask for in #739, the water light's tile-sized blocks under water. **Rebuilt on main (923e38c).** Its new test found three more switches missing from the key, added by today's merges, so six are keyed now. Main's own two new names (`VICTORY_WATER_VOLUME_PORTALS`, `VICTORY_LDS_BOUNDS_EXEMPT`) are in `KEYED` too. ## What happens These switches change how a program is translated, and none of them is in the shader cache's key: | Switch | What it changes | Since | |---|---|---| | `VICTORY_LOOPS_WAVE` | whether the branches that close or leave a program's loops are taken by each host wave together | 64d4931 | | `VICTORY_LDS_FIRST_INIT` | whether the first thread sets up the LDS | | | `VICTORY_LDS_INIT_HOIST` | whether accumulator initialisations are also stored at the start of the program (`lds_init_hoist_on` in `lower.rs`) | 759f05c | | `VICTORY_HDR_CLAMP` | whether pixel float colour outputs are held to the console's HDR range (on; `=0` turns it off) | 2e855b0 | | `VICTORY_SAMPLED_MARKS` | whether texture reads through a heap slot mark that slot (`=1`; off by default) | a410fd0 | | `VICTORY_DEFRAG` | whether `CS_DefragHeap_ComputeRelocations` is translated (`=0` leaves it untranslated, for comparisons) | d4d7193 | The comment in `pipeline/make.rs` credits the first two for the water light's open-water fix. A run that changes one of them is served the translations an earlier run cached without the change, so the switch looks as if it did nothing. For example, `VICTORY_SAMPLED_MARKS=1` gets programs that mark no slot, and `VICTORY_DEFRAG=0` still runs the defragmentation from the cache. The comment above the list already describes the same trap for `VICTORY_WAVE_WIDE`. ## The change - **Cache key:** the list of switches keyed by name is now a const, `KEYED`, with the six names added. - **Translator:** `victory_shader::emit::SWITCHES` gives the list of `VICTORY_*` switches that the translator's `build.rs` already gathers from its sources (`VICTORY_SHADER_SWITCHES`). `translation_fingerprint()` now reads the same const. - **Test:** a new test checks every switch on that list. Each one must be either: - in `KEYED`; - in the key another way: loop limit, group sync, early depth, shader passes, ray-tracing no-hit, or host settings (`VICTORY_RDNA_FLOAT` through `host_rdna`); - one that changes no translation: what the translator reports, the host it is told of, where its tools are, or the tests' (`VICTORY_REQUIRE_HW_GPU`). A new switch that is none of these fails the test. So does a listed name the translator no longer reads. The key changes, so every translation is made again once after the update, as after any translator change. ## Why not `translation_fingerprint()` Main already has `victory_shader::emit::translation_fingerprint()` (847a0af). It keys every switch the translator names, but nothing calls it: the cache's key is still `build()` in `shader_cache.rs`. Keying on it would also key the switches that change no translation, such as `VICTORY_WAVE_WHY`, `VICTORY_EMIT_DUMP` or `VICTORY_ADAPTER`. A run with one of those set would then translate everything again. So this PR keeps the cache's own list, and the test keeps that list complete. #550 adds `VICTORY_CODE_TABLE_AFTER` to the same list. Whichever of the two lands second needs to add one line. ## Tests - **New test** `shader_cache::tests::every_switch_of_the_translator_is_in_the_key`. It passes. It fails without the names it found: - on 32ecacf, with `["VICTORY_LDS_FIRST_INIT", "VICTORY_LDS_INIT_HOIST", "VICTORY_LOOPS_WAVE"]`; - on 923e38c, with `["VICTORY_DEFRAG", "VICTORY_HDR_CLAMP", "VICTORY_SAMPLED_MARKS"]`. - **`cargo test -p victory-gpu --lib --locked`**: 551 passed, 43 ignored. - **Clippy** (workspace, `--all-targets`, default and `--all-features`): nothing in the changed lines. Main 923e38c has findings of its own: 13 in the default build and 11 with `--all-features`. Among them: an unused `colour` and a `manual_checked_ops` in `lower.rs`, dead code in `send.rs`, `pool.rs` and `resource.rs`, too many arguments, and a `drop` of a reference in `host.rs`.
Both switches change how a wave64 program is translated for 32-lane
hosts: whether the branches that close or leave its loops are taken by
each host wave together, and whether the first thread sets up its LDS.
Neither was in the shader cache's key. A run with
`VICTORY_LOOPS_WAVE=0` or `VICTORY_LDS_FIRST_INIT=0` was served the
translations an earlier run had cached without them, so the switch
seemed to change nothing. The water-light tests asked for in #739 would
have shown exactly that.

The cache's list of keyed switches is now a const, KEYED, with the two
added. The translator's build script already gathers every `VICTORY_*`
switch its sources name. victory_shader::emit::SWITCHES gives that
list, and a test checks each one: it is in KEYED, in the key another
way (loop limit, group sync, early depth, shader passes, host settings),
or one that changes no translation (what the translator reports, the
host it is told of, where its tools are, the tests'). A new switch that
is none of these fails the test. So does a listed one the translator no
longer reads.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 06:35:09 +00:00
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-28 07:09 UTC · original · approved these changes

Tested locally merged onto main (63b902f).

  • Merge & Policy: Clean merge; cargo xtask policy passed (294 files ok).
  • Tests:
    • cargo test -p victory-gpu --lib shader_cache:: passed (3 passed; 0 failed, including the new every_switch_of_the_translator_is_in_the_key regression test).
    • cargo test -p victory-shader --lib emit::tests:: passed (22 passed; 0 failed; 1 ignored).

Good cache-correctness fix preventing stale cached DXIL across VICTORY_LOOPS_WAVE / VICTORY_LDS_FIRST_INIT toggles. LGTM.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

**@⁠Dukestar69** on GitHub · 2026-11-28 07:09 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/807#pullrequestreview-6096411979) · **approved these changes** Tested locally merged onto `main` (`63b902f`). - **Merge & Policy**: Clean merge; `cargo xtask policy` passed (`294 files ok`). - **Tests**: - `cargo test -p victory-gpu --lib shader_cache::` passed (`3 passed; 0 failed`, including the new `every_switch_of_the_translator_is_in_the_key` regression test). - `cargo test -p victory-shader --lib emit::tests::` passed (`22 passed; 0 failed; 1 ignored`). Good cache-correctness fix preventing stale cached DXIL across `VICTORY_LOOPS_WAVE` / `VICTORY_LDS_FIRST_INIT` toggles. LGTM. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
github-bot changed title from Shader cache: VICTORY_LOOPS_WAVE and VICTORY_LDS_FIRST_INIT are in the key, and a test checks every translator switch to Shader cache: VICTORY_LOOPS_WAVE, VICTORY_LDS_FIRST_INIT and VICTORY_LDS_INIT_HOIST are in the key, and a test checks every translator switch 2026-11-28 19:31:17 +00:00
github-bot force-pushed github-bot/gh-807 from 81622c2777 to cc41119589 2026-11-28 19:31:18 +00:00 Compare
github-bot changed title from Shader cache: VICTORY_LOOPS_WAVE, VICTORY_LDS_FIRST_INIT and VICTORY_LDS_INIT_HOIST are in the key, and a test checks every translator switch to Shader cache: six translator switches the key left out are in it, and a test checks every switch 2026-11-28 19:49:31 +00:00
github-bot force-pushed github-bot/gh-807 from cc41119589 to 3f5ba8cbfb 2026-11-28 19:49:31 +00:00 Compare
github-bot referenced this pull request from a commit 2026-11-29 00:27:22 +00:00
github manually merged commit 89bcee6e74 into main 2026-11-29 00:27:57 +00:00
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

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