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

Merged
kibagami-nc merged 1 commit from upstream-pr/807 into main 2026-11-29 00:24:47 +00:00
kibagami-nc commented 2026-11-28 06:31:41 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by kibagami-nc on 2026-11-28T06:31:41Z.


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.
<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5537476054 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/807). Originally posted by [kibagami-nc](https://github.com/kibagami-nc) on 2026-11-28T06:31:41Z. --- 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`.
Dukestar69 commented 2026-11-28 07:09:21 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Dukestar69 on 2026-11-28T07:09:21Z.

Review: APPROVED


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).

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:review:6096411979 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/807#pullrequestreview-6096411979). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-28T07:09:21Z. **Review:** APPROVED --- 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).
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!807
No description provided.