Skip to content

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

Merged
trustno1-coder merged 1 commit into
trustno1-coder:mainfrom
kibagami-nc:fix/shader-cache-keys-loop-and-lds-switches
Nov 29, 2026
Merged

trustno1-coder merged 1 commit into
trustno1-coder:mainfrom
kibagami-nc:fix/shader-cache-keys-loop-and-lds-switches

Conversation

@kibagami-nc

@kibagami-nc kibagami-nc commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

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 Dukestar69 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

MystifiedSky added a commit to MystifiedSky/VIctory-NVIDIA-Improved that referenced this pull request Nov 28, 2026
Shaun-Fong added a commit to Shaun-Fong/VIctory-NVIDIA that referenced this pull request Nov 28, 2026
…TORY_LDS_FIRST_INIT are in the key, and a test checks every translator switch
@kibagami-nc
kibagami-nc force-pushed the fix/shader-cache-keys-loop-and-lds-switches branch from 81622c2 to cc41119 Compare November 28, 2026 19:24
@kibagami-nc kibagami-nc changed the title Shader cache: VICTORY_LOOPS_WAVE and VICTORY_LDS_FIRST_INIT are in the key, and a test checks every translator switch 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 Nov 28, 2026
… a test checks every switch

VICTORY_LOOPS_WAVE, VICTORY_LDS_FIRST_INIT, VICTORY_LDS_INIT_HOIST,
VICTORY_HDR_CLAMP, VICTORY_SAMPLED_MARKS and VICTORY_DEFRAG change how a
program is translated, but the cache's key left them out: a run with one of
them changed was served the translations an earlier run had cached without
the change.

The keyed names are now a const, KEYED. victory_shader::emit::SWITCHES gives
the switches the translator's build.rs gathers from its sources, and a test
checks that each one is in KEYED, in the key another way, or changes no
translation. translation_fingerprint() reads the same const.
@kibagami-nc
kibagami-nc force-pushed the fix/shader-cache-keys-loop-and-lds-switches branch from cc41119 to 3f5ba8c Compare November 28, 2026 19:48
@kibagami-nc kibagami-nc changed the title 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 Shader cache: six translator switches the key left out are in it, and a test checks every switch Nov 28, 2026
@trustno1-coder
trustno1-coder merged commit 89bcee6 into trustno1-coder:main Nov 29, 2026
1 check failed
trustno1-coder added a commit that referenced this pull request Nov 29, 2026
…R are in the key

#807's test of every translator switch found them left out.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X5CFykxe6G44cMPrmExrcw
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants