Shaders: cache normalized DXIL cache dir and passthrough DXIL in RAM #2915
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2915"
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 real-alponzo on 2026-11-26T23:06:30Z.
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.Imported from ivall/xcl. Originally posted by fromthemoonx on 2026-11-27T00:09:36Z.
Rerun on the new head
dd43765: still passes on NVIDIA, both RAM caches are still hit by the suite's real calls, and both tests still fail with the lookups disabled.cargo test --workspace --no-fail-fast -- --test-threads=4,dd43765(base =main8b957be, so head = merged)SKIPPEDlineseprintln!in the shippednormalized_cache_dir/compile_passthrough_cached(unit tests' own_incalls left out),cargo test -p xcl --libnormalized_cache_dir: 84 calls, 38 hits; passthrough: 4 hits, 1 miss (ms_6_6)--test d3d12_mesh_stream --test gpu_compute_e2enormalized_cache_dir: 5 calls, 2 hits; no passthrough callsget(...)lookups replaced byNone, each test alonenormalized_cache_dir_caches_existing_dir_and_retries_missingandpassthrough_ram_cache_reuses_compiled_dxil_and_does_not_cache_errorsfail 3 of 3The test checks the hit count through its own
on_hitclosure, so droppingdxc::record_cache_hitfromcompile_passthrough_cachedwould not fail any test.First run, on
6f7f998: Full suite on NVIDIA (listed under Not tested): passes. Both RAM caches are hit by the suite's real calls, and both new tests fail with the lookups disabled.Tested:
6f7f998(its base is currentmain8b957be, so head = merged). RTX 3060 12 GB (driver 610.88), Ryzen 7 5700X, Windows 11 Pro 26300, Rust 1.100.0 MSVC, debug, DXC 1.9.2602.17.cargo test --workspace --no-fail-fast -- --test-threads=4SKIPPEDlines (no wave64, refused per-lane forms)eprintln!on each hit / miss,cargo test -p xcl --lib+--test d3d12_mesh_stream --test gpu_compute_e2e(the new unit tests' own calls subtracted)ms_6_6);normalized_cache_dir: 34 hits, 50 misses; all tests passget(...)lookups replaced byNonepassthrough_ram_cache_reuses_compiled_dxil_and_does_not_cache_errorsandnormalized_cache_dir_caches_existing_dir_and_retries_missingfail 3 of 3; unchanged they pass 3 of 3compile_passthrough_cachedandnormalized_cache_dircall the tested_inhelpers directly, so the tests cover the shipped path.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.
Imported from ivall/xcl. Originally posted by JJAutoCompare on 2026-11-27T00:21:55Z.
Tested:
6f7f998963b1339a1d8282ae9e92211e2c93d635on Windows 11 build 26200, Ryzen 7 3800X, Rust 1.100.0 MSVC, debug, DXC 1.9.2602.17. Ran the built library test executable with--test-threads=1 --nocapturefor normalization, alias deduplication, cache statistics, passthrough RAM reuse, key context and mesh compute caching. Six passed, 0 failed, ignored or skipped. Repeated the mesh test in a separate process with a second fresh cache root: 1 passed, 0 failed, ignored or skipped. Each root held four files, and their SHA-256 inventories matched.Not tested: Same-process cache-root switching, GPU execution, performance, full suite, and retail smoke.
AI use: T3 Code / Codex (
gpt-6.2-sol) ran and reran the checks and wrote this report.Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-27T00:27:20Z.
Code review location:
crates/xcl/src/gpu/recomp/pso.rs; line 1082Blocking. A RAM hit returns before
dxc::compile_cachedruns, so after the first compile of a passthrough MS/GS shader:cache_counters()hits/compilations, which feedXCL_ACTIVITYand the report stats) stop counting these shaders;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_cachedso the disk-cache bookkeeping still runs.Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-27T00:27:20Z.
Code review location:
crates/xcl/src/gpu/recomp/pso.rs; line 1080Non-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.Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-27T00:27:20Z.
Code review location:
crates/xcl/src/gpu/recomp/dxc.rs; line 826Blocking. The cache is keyed on
diras given, so a stale result can come back in two cases:XCL_DXIL_CACHE(e.g..\dxil) keeps its first canonical result after the current directory changes;In both cases
cache_mutex_nameand the flight key no longer match where the files are actually written. Unifying those is the reasonnormalized_cache_direxists. At least key the cache onstd::path::absolute(dir)(and only cache absolute inputs), and document that links swapped mid-process are not handled.Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-27T00:27:20Z.
Code review location:
crates/xcl/src/gpu/recomp/dxc.rs; line 1646Non-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>= 1calls 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. Callnormalized_cache_dir_intwice formissingand assert that canonicalize runs again.Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-27T00:27:20Z.
Review: CHANGES_REQUESTED
Thanks for this. Requesting changes for two points, marked blocking inline:
pso.rs) short-circuitsdxc::compile_cached, so it ignores the DXIL cache directory and its counters.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 theconsole_geometryrefactor ontofinish_two_pass_compiled. CONTRIBUTING.md asks for one logical change per PR. Please split thedxc.rspath cache into its own PR. Theconsole_geometrydedup can go with thepso.rscache 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.
Imported from ivall/xcl. Originally posted by andrewDoing on 2026-11-27T00:37:39Z.
Confirmed the relative-directory concern with a Windows public-API probe using the same relative cache path
dxilthroughout. Botha/dxilandb/dxilexisted and started empty. The test compiled source 1 under working directorya, changed tob, then compiled source 1, source 2, and source 2 again; the sources had distinct keys.8b957bec6f7f9989The 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.
Imported from ivall/xcl. Originally posted by oni-swr on 2026-11-27T02:06:20Z.
Tested (AMD): clean
6f7f998963b1339a1d8282ae9e92211e2c93d635(base = main8b957bec). Windows 11 26200, Ryzen 7 5700X3D, AMD Radeon RX 7800 XT (driver 32.0.31035.1003), Rust 1.100.0 MSVC, DXC 1.8.2502.11 (Windows SDK 10.0.26100), debug.cargo test -j 4 -p xcl --no-fail-fast -- --test-threads=4thencargo build --workspace+cargo test -p xcl --test e2e: thee2etests need the workspace-built test title, so the first run failed 3 of them for lack of it and the rerun passed 4 of 4. Lib/other targets: 1 failed, 7SKIPPEDlines (no heap windows, refused V_CVT_F16_F32 / V_MUL_F16 / VOP3-modifier forms), 47 ignored. The one failure,gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1(seed 722:res[30] = 0x1, CPU 0x7fffffff), also fails onmain8b957becwith the same seed on this GPU, so it is not from the PR.normalized_cache_dir_caches_existing_dir_and_retries_missingandpassthrough_ram_cache_reuses_compiled_dxil_and_does_not_cache_errorspass.Review (by reading, no bugs found): the passthrough RAM key
(fnv64(hlsl), len, profile)matches what the disk key hashes for these fixed-entry (main), toolchain-process-static compiles; errors and cached-only deferrals are not cached (pso.rs:1074-1090). Both caches stop inserting at 64 / 256 entries (dxc.rs:829,pso.rs:1086) with no eviction, so overflow only costs the old behaviour. Concurrent workers can at worst compile the same HLSL twice; DXC compiles stay coalesced by the disk-cache flight. Minor: the key is a 64-bit hash + length with no source comparison.Not tested: retail smoke. The
scripts/smoke.ps1run starts with a cold-cache precompile of about 26k shaders, which did not fit this session's time budget, so I did not produce a base/headxcl-smokepair. No runtime hit-rate or timing was measured either.AI use: Claude Code (Claude Sonnet 5.5) ran the checks and wrote this.
Imported from ivall/xcl. Originally posted by real-alponzo on 2026-11-27T03:30:48Z.
Thanks @KOLESNiii and @andrewDoing! Addressed all points in
dd437650:ormalized_cache_dir_in\ now keys on \std::path::absolute(dir)\ (documenting mid-process link swaps and testing missing-dir retries twice), and \compile_passthrough_cached\ keys on (normalized_cache_dir, profile, hlsl)\ while recording DXIL cache hits via \dxc::record_cache_hit(). Re-ran unit tests and 60 s smoke.
Imported from ivall/xcl. Originally posted by ettehn on 2026-11-27T04:39:19Z.
Tested: The relative DXIL cache path regression is fixed on
dd43765097194ab84e82b811de3990bd70241387. A Windows CPU-only Rust probe built each revision’s unchangeddxc.rsand calleddxc::compile_cachedwith two syntheticps_6_6shaders. Each revision ran once in a fresh process with two empty cache directories. WithXCL_DXIL_CACHE=dxilthroughout, the process compiled red in A, changed to B, compiled red and then green twice, and returned to A to compile red again.8b957bec6f7f9989dd437650All 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.
Imported from ivall/xcl. Originally posted by futurepro62 on 2026-11-27T06:20:55Z.
NVIDIA and AMD full-suite run, to go with the reports above by ettehn, fromthemoonx, since none of them covers AMD. Tested exact head
dd437650(on its base8b957be).Tested
cargo build --workspace, thenXCL_REQUIRE_GPU=mesh cargo test --workspace --no-fail-fast -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form --skip gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::const_and_null_mask_operands_agree_with_hlsl_on_the_gpu --skip gpu::recomp::lower_dxil::tests::mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu --skip gpu::dxil::fuzz_tests: 1436 passed, 0 failed, 45 ignored. SKIPPED (no wave64):a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu,a_per_lane_2d_or_3d_group_runs_on_the_gpu,coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu,cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu,dispatch_chain_native_wave64_builds_whole,gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware,the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu.normalized_cache_dir_caches_existing_dir_and_retries_missing,passthrough_ram_cache_reuses_compiled_dxil_and_does_not_cache_errors.XCL_ADAPTER=radeon),cargo test --workspace --no-fail-fast -- --test-threads=4 --skip gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1: 1447 passed, 0 failed, 47 ignored. SKIPPED:f16_programs_on_the_gpu(f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))),f16_programs_on_the_gpu(f16 arithmetic, wave64, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))),f16_programs_on_the_gpu(f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))),f16_programs_on_the_gpu(f16 packed, wave64, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))),f32_programs_on_the_gpu(f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))),f32_programs_on_the_gpu(f32 conversions, wave64, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))),heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).--skipleaves out tests that fail on mainc2ee10e4too, not because of this PR. On NVIDIA:heap_window_out_of_memory_falls_back_to_the_switch_form(#1651), the fourgpu::recomp::lower_dxil::tests::*_programs_on_the_gputests,const_and_null_mask_operands_agree_with_hlsl_on_the_gpuandmask_ff0_and_flbit_agree_with_hlsl_on_the_gpu(follow-up on #1651) fail becauserunner::skip_testturns their skips into failures underXCL_REQUIRE_GPU=mesh, andgpu::dxil::fuzz_testsseeds 70, 545, 1019 and 1507 failCreateComputePipelineStatewithE_OUTOFMEMORYon this card (drivers 616.64 and 621.40). On AMD:fuzz_validate_and_gpu_1fails on seed 540 (res[833]0x7 vs CPU 0x6). The AMD run does not setXCL_REQUIRE_GPU.Not tested
AI use
Imported from ivall/xcl. Originally posted by LocranKing on 2026-11-27T10:00:57Z.
Tested PR #2915 (
dd437650) againstmain(8b957bec) on Windows 11 (26300), Ryzen 5 5500 (6C/12T), RTX 3060 Ti 8 GiB (driver621.40),rustc 1.100.0, DXC1.9.2602.17.Unit Tests (
cargo test --locked -p xcl --lib)gpu::recomp::pso::shader_cache_tests::passthrough_ram_cache_reuses_compiled_dxil_and_does_not_cache_errors: ok (1 passed, 0 failed)gpu::recomp::dxc::accessor_library_tests::normalized_cache_dir_caches_existing_dir_and_retries_missing: ok (1 passed, 0 failed)Paired 180 s Retail Smoke (
9cc6a39e, Series Slockhart,XCL_HEAP_WINDOWS=1,XCL_DIRECT_DXIL=all,XCL_DIRECT_SPLIT_INSTRUCTIONS=0,XCL_PSO_WAIT_MS=50)Both runs started from identical pre-warmed DXIL/driver cache snapshots and reached the 3D world (
~60 sin-world):main(8b957bec)67.2 s/188.4 s124014(28windows)29,411 MB14,281 / 2,241 MB9,178draws,34,068dispatches0 / 0(exit: 0x0)dd437650)105.4 s/225.7 s125315(27windows)30,216 MB14,491 / 2,340 MB11,843draws,34,222dispatches0 / 0(exit: 0x0)Clean
180 sretail run (exit: 0x0,0crashes,0device removals).Not tested: Instrumented call/time counters for
finish_two_pass_compiled,rect_list_gs, andnormalized_cache_dirduring a retail world load (requested in #2885), or full workspace test suite ondd437650.Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T09:10:30Z.
Triage (#1607) – head
dd43765No merged PR does this. main still calls
std::fs::canonicalizeon everynormalized_cache_dircall, andfinish_two_pass_compiled/rect_list_gsstill go todxc::compile_cachedfor the passthrough every time.#2928 overlaps in part: it also adds a RAM cache to
normalized_cache_dir, alongside many unrelated changes. It does not add the passthrough DXIL cache.No problems found in the diff. Failed compiles and
cached_onlymisses are not cached, and the cache key includes the normalized cache dir and the profile.Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.