Recompiler: canonicalize generated HLSL cache keys #3450
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3450"
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 bmjask on 2026-11-29T18:08:22Z.
Canonicalizes generated HLSL before looking up DXIL cache entries, removing duplicate DXC work caused only by comments or outer indentation while preserving exact identity for line-sensitive or debug-edited sources.
Stacked on #3449; only commit
db569c7dbelongs here.What is in it
Tested
cargo test -p xcl --lib generated_cache -- --test-threads=4: 3 passed, 0 failed..\scripts\test.ps1atdb569c7d: 2,748 passed, 0 failed, 49 ignored; 29 GPU tests explicitly skipped for unsupported/opt-in hardware paths.Regression run
Not tested
XCL_PREPARE=0, so the run exercised the runtime/JIT path only.dxil.dllpaths.AI use
Imported from ivall/xcl. Originally posted by andrewDoing on 2026-11-29T19:03:44Z.
I reproduced a wrong cache hit at
db569c7d35615e3a785597211fb5208ac6107586on an RTX 5070. These two valid HLSL inputs differ only in how the preprocessor sees the newline after3:#define VALUE 3 /*\n*/ ;#define VALUE 3\n;Both shaders store
value()in a UAV, wherevalue()containsreturn VALUE + 5;. DXC treats the multiline comment as one space, so its first semicolon remains inside the macro. The bare newline ends the second directive. The PR's canonicalizer instead flushes a line at the newline inside the comment, producing the same key for both sources. I ran both population orders with fresh cache directories. In each order the second source hit the first one's cache entry and fenced readback returned the first source's value. The independent compiler runs and the native readbacks agreed on the correct values above.The companion fix on my fork keeps block-comment newlines out of directive boundaries and versions the canonical key to avoid reusing entries written under the ambiguous key. With that old key seeded, both orders missed on each distinct input, produced 3 and 8 as expected, and hit correctly on a repeat. All 15 DXC cache tests passed on the fix with zero skips. The regression assertion against the unchanged PR head failed on the wrong GPU value, with the other 14 tests passing.
XCL_ADAPTER=5070 cargo test --offline --locked -p xcl --lib gpu::recomp::dxc::cache_tests -- --test-threads=1 --nocaptureon RTX 5070 12 GB (616.92), Ryzen 7 5700X3D, Windows 11 26300.10075, Rust 1.100.0, DXC 1.8.2502.11, debug. This is a synthetic shader/cache regression test. Codex with GPT-6.2 Sol built the fixture, ran the controls and wrote the companion fix.