Shader cache key: a switch set to nothing keys apart from an unset one #1132
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/fxceless--victory-fork!1132
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1132"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@KainanP on GitHub · 2026-11-25 21:09 UTC · original
KainanP:fix/fingerprint-unset-vs-empty→main· +55 −8 · 1 files · 1 commits · openRefs #848 (section 3, "Bugs noticed in diffs", item 10).
The bug
emit::translation_fingerprint(the shader cache key, used byvictory-gpu'sshader_cache::build) wroteNAME=followed by the value for every switch the translator reads. An unset switch and a switch set to an empty value produced the same bytes.Two switches that change the translation count as on when they are merely set:
VICTORY_STRICT_JOINS(lower.rs,var_os(..).is_some()): joins read only by another join are checked, and about 40 programs stop by name.VICTORY_MESH_OUTPUT_STRICT(lower.rs,var_os(..).is_some()): mesh shaders past the 32 KiB output cap are refused.So a run with
VICTORY_STRICT_JOINS=(empty, e.g.VICTORY_STRICT_JOINS= wine victory.exe ...orSetEnvironmentVariable(name, "")from a launcher) translates with strict joins. But it gets the cache key of a run without the switch, and reads translations made without it. The reverse also happens.The fix
An unset switch now writes
NAME\0and a set one writesNAME=value\0, so the two can't collide. Environment values can't contain NUL, so a value can't run into the next name. The loop moves intoswitch_values(out, names, value), which takes the lookup as a closure so a test can drive it with synthetic values. Every existing key changes once, but so does every edit to the translator source (VICTORY_SHADER_SOURCE_HASH), so a stale entry is just a cache miss.Tested
emit::tests::a_switch_set_to_nothing_keys_apart_from_an_unset_one. It fails with the old encoding (assertion left != right failed: the unset and empty keys were byte-identical) and passes with the fix. It also checks that both switches are in the realVICTORY_SHADER_SWITCHESlist.cargo test -p victory-shader --lib: 216 passed, 0 failed, 3 ignored. Windows 11, RTX 4060 Laptop + Intel UHD hybrid laptop, default adapter, Rust 1.98.1 MSVC.cargo test -p victory-gpu --lib shader_cache: 2 passed.cargo clippy -p victory-shader --all-targets --locked: nothing new.rustfmt --checkreports nothing in the changed lines.Not tested
AI use: Claude Code (Claude Opus 5.5) found the affected switches, wrote the change and the test, and ran the commands above on my machine. No game files were used.
🤖 Generated with Claude Code
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.