Shaders: the DXC cache key leaves out whole-line HLSL comments #3373
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3373"
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?
Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-29T11:01:08Z.
The DXC cache key hashed the full HLSL text, including the translator's per-instruction comments. Each console program starts with two
v_nopwhose 32-bit literal differs between programs with the same code, and the translator writes them as// 0000: v_nop ; lit 0x…. Those comment lines alone gave identical code a new key, so DXC compiled it again. The key now leaves out whole-line//comments; the source DXC compiles is unchanged. Part of #2088.Measured on a retail game's DXIL cache from a full preparation (25,797 DXC sources, dumped with a throwaway hook under their cache keys):
XCL_LINK_MEM,dxc.rs).dxc.exeon 150 random kept + 150 random redundant sources (one thread): 2.14 s vs 0.71 s mean, so the copies are about 17 % of a cold DXC pass. The driver blob store already dedups identical DXIL, so this saves DXC time only.What is in it
crates/xcl/src/gpu/recomp/dxc.rs:cache_key_for_toolchainhashes the source without whole-line//comments, plus the optimisation level the source length selects (-O3 / -O1 / -O0), so sources whose comments push them over a length threshold do not share an entry. A comment line ending in\, or following a line that does, stays in the key (line splicing makes it code). The key has a new domain tag.warm_pack), which checks<key>.dxil, finds them.Tested
cargo test -p xcl --lib gpu::recomp::dxc::: 37 passed, 0 failed, 0 ignoredcargo test --workspace --no-fail-fast -- --test-threads=4: 2621 passed, 0 failed, 49 ignoredRegression run
Retail game, 60 s,
XCL_PREPARE=0andXCL_PRESS_AT=25:Aon both sides, same DXIL cache.main (
d8bd9a38):this PR (
39d97735):DXIL cache in
report.json: main 107,906 hits / 7 misses, this PR 106,238 hits / 12 misses from the same cache (entries under the old key are adopted, nothing went cold).Not tested
dxc.exe, not from an XCL run.XCL_PREPARE=0).AI use
🤖 Generated with Claude Code
Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-29T11:03:55Z.
Duplicate of #3241 (same cause, opened earlier), which this should be closed in favour of. The measurements and the old-key adoption from this PR are offered there: https://github.com/xcl-dev/xcl/pull/3241
Written with Claude Code (Claude Opus 5.5).
Pull request closed