Repository navigation
Shaders: cache normalized DXIL cache dir and passthrough DXIL in RAM - #2915
real-alponzo wants to merge 1 commit into
Conversation
|
Rerun on the new head
The test checks the hit count through its own First run, on Tested:
Not tested: a title run (no time saved was measured), AMD / Intel on this run. AI use: Claude Code (Claude Opus 5.5) ran the tests and the scratch checks and wrote this report. |
|
Tested: Not tested: Same-process cache-root switching, GPU execution, performance, full suite, and retail smoke. AI use: T3 Code / Codex ( |
KOLESNiii
left a comment
There was a problem hiding this comment.
Thanks for this. Requesting changes for two points, marked blocking inline:
- The passthrough RAM cache (
pso.rs) short-circuitsdxc::compile_cached, so it ignores the DXIL cache directory and its counters. - The normalized-dir cache (
dxc.rs) is keyed on the path as given, so relative paths and re-pointed links can return a stale canonical path.
The other inline comments are non-blocking.
Scope: this PR has three changes: the passthrough DXIL RAM cache (pso.rs), the canonical-path cache for the DXIL cache dir (dxc.rs), and the console_geometry refactor onto finish_two_pass_compiled. CONTRIBUTING.md asks for one logical change per PR. Please split the dxc.rs path cache into its own PR. The console_geometry dedup can go with the pso.rs cache or stand alone.
This review was written from the diff at 6f7f998. I did not build this PR or run its tests.
Review assisted by Claude Code (Claude Opus 5.5); I checked each point before posting.
| ) -> Result<Vec<u8>, String> { | ||
| let key = (crate::gpu::shader::fnv64(hlsl.as_bytes()), hlsl.len(), profile); | ||
| if let Some(hit) = cache.lock().unwrap_or_else(|e| e.into_inner()).get(&key).cloned() { | ||
| return Ok(hit); |
There was a problem hiding this comment.
Blocking. A RAM hit returns before dxc::compile_cached runs, so after the first compile of a passthrough MS/GS shader:
- the DXIL cache counters (
cache_counters()hits/compilations, which feedXCL_ACTIVITYand the report stats) stop counting these shaders; - the key doesn't include
cache_dir(). IfXCL_DXIL_CACHEchanges inside the process, the new directory never gets thems_6_6/gs_6_6passthrough.dxil.gpu_compute_e2e.rsandgpu_pso_e2e.rsboth pointXCL_DXIL_CACHEat a cold dir in-process, so a cold-cache test can miss shaders it expects to find written.
Please either key the RAM cache on the resolved cache dir as well (and count a RAM hit as a DXIL cache hit), or move this cache under compile_cached so the disk-cache bookkeeping still runs.
| profile: &'static str, | ||
| compile: impl FnOnce() -> Result<Vec<u8>, String>, | ||
| ) -> Result<Vec<u8>, String> { | ||
| let key = (crate::gpu::shader::fnv64(hlsl.as_bytes()), hlsl.len(), profile); |
There was a problem hiding this comment.
Non-blocking: the key is only (fnv64(hlsl), len, profile), and a hit is returned without comparing the source. If two passthrough sources of the same length collide on FNV-64, the wrong DXIL comes back with no check, and you get mismatched output signatures and garbage geometry. The disk cache also mixes in the toolchain identity and entry point. The passthrough sources are small, so storing the HLSL in the entry (or using it as the key) and comparing it on a hit costs little.
| ) -> PathBuf { | ||
| if let Some(hit) = cache.lock().unwrap_or_else(|e| e.into_inner()).get(dir).cloned() { | ||
| return hit; | ||
| } |
There was a problem hiding this comment.
Blocking. The cache is keyed on dir as given, so a stale result can come back in two cases:
- a relative
XCL_DXIL_CACHE(e.g..\dxil) keeps its first canonical result after the current directory changes; - a directory later replaced by a junction/symlink keeps its old target, while an alias of it canonicalizes to the new one.
In both cases cache_mutex_name and the flight key no longer match where the files are actually written. Unifying those is the reason normalized_cache_dir exists. At least key the cache on std::path::absolute(dir) (and only cache absolute inputs), and document that links swapped mid-process are not handled.
| let calls = std::sync::atomic::AtomicUsize::new(0); | ||
| let first = normalized_cache_dir_in(&cache, &dir, |p| { | ||
| calls.fetch_add(1, Ordering::Relaxed); | ||
| Ok(PathBuf::from(r"\\?\C:\fake\cache").join(p.file_name().unwrap_or_default())) |
There was a problem hiding this comment.
Non-blocking, test: the fake canonicalize joins the file name onto \\?\C:\fake\cache, so the cached value is ...\cache\cache. It works, but it isn't a plausible canonical path and hides what the test means. Returning the fixed path would be clearer. Also, the missing-dir half asserts >= 1 calls and never calls a second time, so it doesn't test the "retries" in the name: a regression that caches the ancestor fallback for a missing dir would still pass. Call normalized_cache_dir_in twice for missing and assert that canonicalize runs again.
|
Confirmed the relative-directory concern with a Windows public-API probe using the same relative cache path
The PR reused the old directory for both a cache hit and a new write. The stale canonical path constructs the target filename upstream of locking, so this affects file placement even without concurrent writers. Both revisions used the identical test-only overlay and were explicitly rebuilt from their respective checkouts. Junction retargeting and retail performance were not tested. AI use: OpenAI Codex with GPT-6.2 Astra wrote and ran the synthetic probe and checked the build roots; Codex coordinated and prepared this report. |
|
Tested (AMD): clean
Review (by reading, no bugs found): the passthrough RAM key Not tested: retail smoke. The AI use: Claude Code (Claude Sonnet 5.5) ran the checks and wrote this. |
dxc::compile_cached_in_observed previously called std::fs::canonicalize via normalized_cache_dir on every shader lookup, and finish_two_pass_compiled / rect_list_gs re-read and re-validated passthrough DXIL from disk on every two-pass MS/GS or rect-list PSO build. Cache canonicalized existing cache directories in dxc.rs and cache compiled passthrough DXIL (ms_6_6 / gs_6_6) in RAM in pso.rs. Fixes xcl-dev#2885. Assisted-by: Antigravity (Gemini 4 Neon)
6f7f998 to
dd43765
Compare
|
Thanks @KOLESNiii and @andrewDoing! Addressed all points in dd43765: |
|
Tested: The relative DXIL cache path regression is fixed on
All three probes exited 0 with their expected results. Windows 11 build 26200, Rust 1.97.1 MSVC, DXC 1.8.2502.11. Not tested: Passthrough RAM cache, junction retargeting, GPU execution, retail smoke, and the full workspace suite. AI use: OpenAI Codex (GPT-6) wrote and ran the probe and prepared this report. |
|
NVIDIA and AMD full-suite run, to go with the reports above by ettehn, fromthemoonx, since none of them covers AMD. Tested exact head Tested
Not tested
AI use
|
Cache canonicalized DXIL cache directories in
dxc::normalized_cache_dirand cache compiled passthrough DXIL (ms_6_6/gs_6_6) in RAM forfinish_two_pass_compiled,console_geometry, andrect_list_gs.Fixes #2885.
What is in it
crates/xcl/src/gpu/recomp/dxc.rs(normalized_cache_dir_in/normalized_cache_dir, capped at 64 entries), keyed bystd::path::absolute(dir)so relativeXCL_DXIL_CACHEpaths still resolve cleanly across working directory changes (mid-process symlink/junction re-pointing is documented as not handled; non-existent paths are not cached until they exist).compile_passthrough_cached_in/compile_passthrough_cached, capped at 256 entries, keyed by(normalized_cache_dir, profile, hlsl), never caching errors or deferred misses, and recording DXIL cache hits viadxc::record_cache_hit()) incrates/xcl/src/gpu/recomp/pso.rsand wired it intofinish_two_pass_compiled,console_geometry, andrect_list_gs.normalized_cache_dir_caches_existing_dir_and_retries_missingandpassthrough_ram_cache_reuses_compiled_dxil_and_does_not_cache_errors.Regression run
Base (
main):PR head (
dd437650):Tested
rustc 1.100.0, DXC 1.9.2602.17.cargo test -p xcl --lib normalized_cache_dir_caches_existing_dir -- --nocapture:1 passed; 0 failed; 0 ignored; 1346 filtered out.cargo test -p xcl --lib passthrough_ram_cache_reuses_compiled_dxil -- --nocapture:1 passed; 0 failed; 0 ignored; 1346 filtered out..\scripts\smoke.ps1 -Game "C:\VIctory-SSD-test\game" -Seconds 60on8b957becanddd437650(blocks above).Not tested
AI use
normalized_cache_dirand passthrough DXIL RAM caches, addressed review feedback, wrote the unit tests, ran the tests and paired smoke runs, and drafted this PR description.