Shader cache key misses four translator switches (WATER_TILE_SLOTS, WAVE_LOOP_SKIPS, MEMORY_NEAR, LDS_START): with a warm cache, =0 is served the default translations #1504

Open
opened 2026-11-28 03:25:02 +00:00 by MrEjecutor · 0 comments
MrEjecutor commented 2026-11-28 03:25:02 +00:00 (Migrated from github.com)
Contributor

Imported from fxceless/victory-fork. Originally posted by MrEjecutor on 2026-11-28T03:25:02Z.


Read in the code at 9e90746; not reproduced in a run.

crates/victory-gpu/src/shader_cache.rs, build(): the cache's key is made of the translator's fingerprint, the loop limit, group_sync(), a list of switches by name, VICTORY_EARLY_DEPTH, shader_opt() and host_settings(). Four switches that the translator reads are in none of those:

switch read in what =0 gives
VICTORY_WATER_TILE_SLOTS emit/water_tile_slots.rs on(), through host_form in translate_plain the water light's tile program as it is
VICTORY_WAVE_LOOP_SKIPS emit/mod.rs, where the wave-wide forms are tried only the form of before
VICTORY_MEMORY_NEAR emit/mod.rs memory_near() every load by address looks in the directory
VICTORY_LDS_START emit/lower.rs lds_start_on() a group's LDS starts as the host's memory is

All four are on unless set to 0, and 0 is there to get the code of before (the README names the first and the third that way). With none of them in the key, a run with one of them at 0 on a cache that a default run filled is served the default translations, and the other way round: comparing the switch on and off then compares a translation with itself. It is the case the comment above the list describes for VICTORY_WAVE_WIDE=0. The doc comment of memory_near() already says "Part of the translation: the shader cache keys on it."

A change that would close it:

             "VICTORY_THREAD_TICKET",
+            "VICTORY_WATER_TILE_SLOTS",
+            "VICTORY_WAVE_LOOP_SKIPS",
+            "VICTORY_MEMORY_NEAR",
+            "VICTORY_LDS_START",
         ] {

Every key changes once with it, as with any change to that file (build.rs takes shader_cache.rs into the translator's fingerprint). With it, cargo check -p victory-gpu --all-targets --locked passes here. cargo clippy -p victory-gpu --all-targets --locked -- -D warnings does not get as far as victory-gpu on 9e90746: it stops in victory-shader at emit/water_tile_slots.rs:87 (manual_is_multiple_of), a line this change does not touch.

Not tested: any of this in the game: I have not run this fork's current main, so I have not seen a cached translation served under the wrong switch, only read that nothing tells them apart. I looked only at the switches crates/victory-shader/src reads from the environment; VICTORY_RDNA_FLOAT, VICTORY_GROUP_SYNC, VICTORY_SHADER_OPT and VICTORY_SHADER_LOOP_LIMIT reach the key by its other parts, and the rest looked like diagnostics or test inputs by their names, which I did not read one by one.

AI-assisted (Claude Code): the reading of the code and this text. No game files attached.

<!-- greyfinch-sync:fxceless/victory-fork:issue:6658489699 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/issues/1504). Originally posted by [MrEjecutor](https://github.com/MrEjecutor) on 2026-11-28T03:25:02Z. --- Read in the code at `9e90746`; not reproduced in a run. `crates/victory-gpu/src/shader_cache.rs`, `build()`: the cache's key is made of the translator's fingerprint, the loop limit, `group_sync()`, a list of switches by name, `VICTORY_EARLY_DEPTH`, `shader_opt()` and `host_settings()`. Four switches that the translator reads are in none of those: | switch | read in | what `=0` gives | |---|---|---| | `VICTORY_WATER_TILE_SLOTS` | `emit/water_tile_slots.rs` `on()`, through `host_form` in `translate_plain` | the water light's tile program as it is | | `VICTORY_WAVE_LOOP_SKIPS` | `emit/mod.rs`, where the wave-wide forms are tried | only the form of before | | `VICTORY_MEMORY_NEAR` | `emit/mod.rs` `memory_near()` | every load by address looks in the directory | | `VICTORY_LDS_START` | `emit/lower.rs` `lds_start_on()` | a group's LDS starts as the host's memory is | All four are on unless set to 0, and 0 is there to get the code of before (the README names the first and the third that way). With none of them in the key, a run with one of them at 0 on a cache that a default run filled is served the default translations, and the other way round: comparing the switch on and off then compares a translation with itself. It is the case the comment above the list describes for `VICTORY_WAVE_WIDE=0`. The doc comment of `memory_near()` already says "Part of the translation: the shader cache keys on it." A change that would close it: ```diff "VICTORY_THREAD_TICKET", + "VICTORY_WATER_TILE_SLOTS", + "VICTORY_WAVE_LOOP_SKIPS", + "VICTORY_MEMORY_NEAR", + "VICTORY_LDS_START", ] { ``` Every key changes once with it, as with any change to that file (`build.rs` takes `shader_cache.rs` into the translator's fingerprint). With it, `cargo check -p victory-gpu --all-targets --locked` passes here. `cargo clippy -p victory-gpu --all-targets --locked -- -D warnings` does not get as far as `victory-gpu` on `9e90746`: it stops in `victory-shader` at `emit/water_tile_slots.rs:87` (`manual_is_multiple_of`), a line this change does not touch. **Not tested:** any of this in the game: I have not run this fork's current `main`, so I have not seen a cached translation served under the wrong switch, only read that nothing tells them apart. I looked only at the switches `crates/victory-shader/src` reads from the environment; `VICTORY_RDNA_FLOAT`, `VICTORY_GROUP_SYNC`, `VICTORY_SHADER_OPT` and `VICTORY_SHADER_LOOP_LIMIT` reach the key by its other parts, and the rest looked like diagnostics or test inputs by their names, which I did not read one by one. AI-assisted (Claude Code): the reading of the code and this text. No game files attached.
Sign in to join this conversation.
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
fxceless/victory-fork#1504
No description provided.