GPU: use native root type codes in the shader cache #415
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!415
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/415/head"
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?
@enzoduarte1 on GitHub · 2026-11-24 03:08 UTC · original
enzoduarte1:gpu/shader-cache-root-codes→main· +33 −10 · 1 files · 1 commits · closed without mergingWhat
shader_cache.rsencodedRootTypewith its own numbering that disagreed with the one the console shader uses (RootType::from_rawinvictory-shader/src/native.rs):2isOther(2)in the native parser, but the cache decoded it asTable;Other(x)was written as6 + x, which overflows in debug builds and wraps into a known code in release builds for anyx >= u32::MAX - 5. The native parser reads that value straight from shader bytes, so it is reachable.The cache now stores the native raw values directly, making encode/decode bijective for every value the parser can produce. The cache key already includes the executable's BLAKE3, so entries written by an older build are not reused. A round-trip test covers all native codes plus
Other(u32::MAX).Tested
x86_64-pc-windows-gnu(no MSVC linker on this machine).cargo test -p victory-gpu --lib shader_cache::: 3 passed.cargo test --workspace --exclude victory-loader -- --test-threads=1: all suites passed.cargo clippy -p victory-gpu --all-targets -- -A clippy::undocumented_unsafe_blocks -D warnings: clean. The allowed lint is the pre-existing warning fixed by PR #355.rustfmt --edition 2024 --check crates/victory-gpu/src/shader_cache.rsandgit diff --check: clean.cargo xtask policy: 151 files ok. No game files or data taken from them were added.cargo test -p victory-loader --test load_probe. Its fixture passes MSVC's/DELAYLOADflag, which MinGW rejects here; the same failure occurs on unmodifiedmain.cargo fmt --all --checkalso has unrelated pre-existing diffs, so no other files were reformatted.Checklist
cargo fmt,cargo clippy --workspace --all-targetsandcargo test --workspacepass — see the toolchain limitations above; the changed crate is clean.cargo xtask policypasses. The change adds no game files or data taken from them (docs/asset-policy.md).@jeremygold02 on GitHub · 2026-11-24 04:36 UTC · original
Thanks @enzoduarte1 for aligning cached root types with their native codes. I tested head
6924b095e3bfc128a3c85b3edc3332cd94274f5awith:Result: 3 passed, 0 failed (42 filtered out). The tests check native root-type code round trips, cache entry encoding/decoding with damaged-entry rejection, and reuse of cached translations. These are cache-format unit tests; they do not exercise a title’s shader workload.
@Marvisak on GitHub · 2026-11-25 00:28 UTC · original
Automated triage for the maintainers.
Merge candidate.
root_codeincrates/victory-gpu/src/shader_cache.rscomputed6 + xforRootType::Other(x), whilenative.rsbuildsRootType::from_raw(le32(e, 0))from a full u32, sox >= u32::MAX - 5panics in debug builds and wraps to the wrong variant in release. Writing the raw codes directly fixes it, and the round-trip test covers it. One correction to the description: the old mapping did not decode raw2asTable(Other(2)was written as 8 and read back asOther(2)); only the overflow was wrong.CI: no check runs on the head commit.
Generated by Claude Code
@Marvisak on GitHub · 2026-11-25 21:58 UTC · original
Automated triage for the maintainers, second look (a review against current
main, with builds and tests where they could change the verdict).Closing because the overflow it guards against cannot occur, and the change has a cost.
root_codeis applied only toHostShader::user_dataentries, which the translator builds with rootsConstants,TableorDescriptoronly, soRootType::Othernever reaches the cache and the current encoding round-trips every value that does. Editingshader_cache.rschanges the shader-cache key, so merging this would retranslate every shader for no change in output. It also collides with #1931's use of code 6.If this is mistaken, reply here with what was missed and it will be looked at again. Thank you for the contribution.
Pull request closed