Shaders: precompile answers for its own shader, not by the shared miss count (#291) #441
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/Belobug--VIctory-Belobug-AMD!441
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-441"
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?
@hussainmussa on GitHub · 2026-11-27 01:55 UTC · original
hussainmussa:fix/precompile-own-answer→a-publier· +70 −5 · 1 files · 1 commits · openRefs #291.
What was wrong
On the dispute in #291 first: the comment there is right about reachability. On
a-publier(4eb6cfd) theNonearm ofprecompilecannot run fromvictory shadersortranslate --warm, because both callcfg.cache_subdir("shaders")?first, andCache::openthen makes the same two calls on the same path (ensure_outside_repo,create_dir_all). WithVICTORY_CACHE_DIRpointing at a file, both commands stop withcreating ...\shadersbefore a shader is read.But the issue is right that the answer is wrong by construction, and one case of that is reachable.
precompilereturnedOk(MISSES == misses), andMISSESis every thread's count.translate --warmruns on all cores and turns that answer into "translated now" against "in the cache already" (warm_shader,d3d12x.rs:74). So a shader found in the cache is counted as "translated now" whenever another thread stores one during the call.What this does
precompilenow answers by whether this call reached the translator. The body moves toprecompiled(cache, build, container, translate), which takes the cache and the translator so that tests need no graphics device. One file, no signature of anything public changes.Nonearm of the issue, unreachable today, now answers correctly too).MISSESmoves exactly when the translator ran (cached_by), so on one thread the answer is the same as before.Testing
Windows 11, Rust 1.98.1, no graphics device used.
cargo test -p victory-gpu --locked --lib shader_cache: 5 passed, the two new ones among them.precompiled, both new tests fail:precompiling_without_a_cache_is_not_theregetsOk(true)forOk(false), andprecompiling_answers_for_its_own_shaderreports16 of 500 shaders found in the cache were said translated now.cargo clippy -p victory-gpu --no-deps --all-targets --locked -- -D warnings: clean.cargo test -p xtask --locked: 9 passed.The second test is a race between two threads, so with the old code the number of wrong answers varies from run to run (16 and 21 of 500 in two runs here); with the new code it is 0 by construction, since the answer no longer reads shared state.
Not tested:
precompileitself, which opens the graphics device, and a realtranslate --warmover the title's shaders (I have no game files). The tests driveprecompiledwith a stand-in translator.Note
#436 also refers to #291 and changes how
--warmreports failures intranslate.rs. This touches onlyshader_cache.rsand the two do not overlap.Written with help from Claude; everything above was built and run on my machine.
@Yoshi-233 on GitHub · 2026-11-27 02:16 UTC · original
I checked the public
shader_cache::precompileentry point ona-publier@4eb6cfdand PR head9c38609. I compiled the unmodified cache module on x86-64 Linux with the real GFX10-to-DXIL translator and on-disk cache. The fixture supplies the two Windows host probes. The inputs are synthetic compute shaders with distinct thread-group widths.For each of 32 runs I paused the thread reading an already-cached shader at the host-capability probe inside
build(), let a second thread finish precompiling a distinct cold shader, then resumed the first. The wait uses channels, so no sleeps or timing thresholds are involved.Ok(false)Ok(false)Ok(true)The actual cache counters ended at 65 hits and 33 misses on both builds before restart. That isolates the change to the per-call answer used by the warmer. The old result could report a fresh translation even though the reader's shader was already on disk. This was CPU-side testing with fixed host capabilities; no game or GPU run. AI-assisted verification.
@MamaLeVrai on GitHub · 2026-11-27 03:55 UTC · original
Tested on an RX 6950 XT (RDNA 2), driver 32.0.21045.29003, Windows 11 build 26300, Rust 1.98.1, release. At
9c38609:cargo test --release -p victory-gpu --lib398 passed, 0 failed, 34 ignored.AI-assisted (Claude Code); no game data.
@hussainmussa on GitHub · 2026-11-27 17:10 UTC · original
Ran this on the title's real shaders. RTX 4070, Windows 11, 20 threads, diag build,
translate --warmovershaders.rpf(25,889 hashes) with a freshVICTORY_CACHE_DIRper build. Step 1 warms every other hash; step 2 warms all of them, so 12,853 are in the cache when it starts.4eb6cfd9c38609Step 1 is the same on both (12,853 translated now, 92 do not translate). A third pass on
9c38609: 0 translated now, 25,694 in the cache already, 0.9 s. Both caches end with 25,694 files, so only the report differed. One run of each step per build.Written with help from Claude; everything above was run on my machine.
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.