D3D12.X: guard disk_stores removal on ShaderCacheSession SetDeleteOnDestroy #1591
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1601"
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 b3IKK on 2026-11-24T18:07:50Z.
In
shader_cache_session::release, whendelete_on_destroywas set on a disk-mode session,disk_stores().lock().unwrap().remove(&k)removed keykunconditionally. If two sessionsS1andS2shared the same storeArc1withSetDeleteOnDestroy(), releasingS1removedk,S3opened a fresh storeArc2forkand cached shaders in it, and releasingS2later evictedS3's newerArc2fromdisk_stores().This removes
kfromdisk_stores()only when the currently storedArcis stillArc::ptr_eqtoboxed.store.What is in it
crates/xcl/src/hle/d3d12x/shader_cache_session.rs: checkArc::ptr_eq(cur, &boxed.store)before removingkfromdisk_stores(); add unit teststale_delete_on_destroy_does_not_evict_newer_disk_store(verified failing withDXGI_ERROR_NOT_FOUNDbefore the fix).Tested
stable-x86_64-pc-windows-msvc), DXC 1.9.2609.5, debug (scripts/test.ps1) and release (scripts/smoke.ps1).\scripts\test.ps1(cargo build --workspace+cargo test --workspace -- --test-threads=4): 777 passed, 0 failed, 41 ignored (SKIPPED GPU tests: 2no wave64—gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask,gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware; 1no heap windows—heap_window_out_of_memory_falls_back_to_the_switch_form)cargo test -p xcl --lib shader_cache_session: 2 passed, 0 failed (stale_delete_on_destroy_does_not_evict_newer_disk_storefailed before the fix)Regression run
main:
PR:
Not tested
AI use
shader_cache_session.rs, wrote the fix and unit test, ran the test suite andscripts/smoke.ps1regression runs, and drafted this PR description.Imported from ivall/xcl. Originally posted by Aniseto on 2026-11-24T18:14:48Z.
Ran the
shader_cache_sessionmodule at0003178. The PR adds no test of its own, so this is a regression check:Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, wave32 only, 16 GB) driver 32.0.16.2124, Intel Core i5-12400F, 64 GB RAM, rustc 1.100.0 (0ef1bc386 2026-11-09) MSVC 14.44.35207, DXC 1.9.2609.5, debug build.
Both tests pass, and this machine takes the path the PR guards: the run logs
CreateShaderCacheSession failed on the PC runtime (0x80070057) - using an in-memory session, so the in-memory session whosedisk_storesregistration the PR touches is the one in use here. That makes it a real path rather than a mocked one, though by itself it does not prove the set-delete-on-destroy ordering; that needs a driver that accepts the session.Not tested: the destroy path on a driver that accepts the session (this one refuses it), RDNA2/RDNA4 and Intel GPUs, Wine, release profile.
AI-assisted (OpenCode), model: DeepSeek V4.1 Flash 1017 - built the PR's head commit from a clean tree and ran the tests on this machine; no local changes were made.
Imported from ivall/xcl. Originally posted by b3IKK on 2026-11-24T18:44:22Z.
Thanks for testing @Aniseto! Quick note: one of those 2 tests (\stale_delete_on_destroy_does_not_evict_newer_disk_store) is the regression test added by this PR — it directly exercises the fallback \SetDeleteOnDestroy\ / \disk_stores()\ ABA eviction path (which is only used by the fallback session itself) and fails without the \Arc::ptr_eq\ check.
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T20:21:58Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~22 ignored. (Intermittent 0xc0000005 abort under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodifiedmain.)Thanks!
upstream-sync referenced this pull request2026-11-25 07:04:28 +00:00
Imported from ivall/xcl. Originally posted by upipibi on 2026-11-26T16:08:23Z.
NVIDIA test report for
0003178: RTX 3070 8 GB (Ampere, driver 616.56), Windows 11 26100, Rust 1.100.0, debug. Head tested as-is on its base9e3831e.cargo test -p xcl --lib -- --skip hle::xaudio2 --test-threads=4: 719 passed, 0 failed, 21 ignored; 2 SKIPPED (no wave64: gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware), neither in a file this PR changes.hle::d3d12x::shader_cache_session::tests::stale_delete_on_destroy_does_not_evict_newer_disk_storewith--exact --test-threads=1 --nocapture, 3 runs: 3/3 passed, 0 SKIPPED.Lib tests only; no title run.
AI-assisted (Claude Code, Claude Opus 5.5).
Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-30T12:57:02Z.
merge-check
base:
9dfbe3ea66head:
0003178b8cmerge: clean (local merge tree 16667840d8df2e49d4476d7626c7272873ec7fa0)
build: cargo build --workspace --offline --locked -> ok
tests: cargo test --workspace --offline --locked --no-fail-fast -- --test-threads=4 -> 2885 passed, 2 failed, 51 ignored; SKIPPED: 24 (22 no wave64; 2 no heap windows, one requires XCL_HEAP_WINDOWS=1); failing: gpu::dxil::msaa_tests::gpu_direct_image_get_resinfo_d16 and gpu::recomp::pso::shader_cache_tests::console_mesh_caches_hlsl_compute_pass_in_memory_and_on_disk; both also fail in exact-base filtered runs.
review: The one-file change removes the shared key only when its current Arc still matches the releasing session’s store. The regression recreates the replacement-store sequence and confirms the newer value remains readable. The store lock is released before taking the registry lock. No default frame-path work added.
performance: Reasoned cost is limited to session release. Matched 60-second RTX 3080 Ti smokes held 60 presents per 2-second interval with zero device removals or crashes. Base/merge tree: 1662/1692 frames; peak commit 16288/16341 MB (single-run delta, not attributed to this change).
verdict: safe to merge — clean merge, successful build, no new test failures, and matched smoke runs passed.
hardware / tool and model: RTX 3080 Ti, driver 32.0.16.2140; Ryzen 7 9800X3D; Windows 11 Pro build 26300; rustc 1.99.1 / Codex GPT-6.2 Sol.
Regression run
main:
merged PR tree:
Imported from ivall/xcl. Originally posted by SzczepanGrela on 2026-11-30T13:15:33Z.
merge-check
base:
9dfbe3ea66head:
0003178b8cmerge: clean; staged merge tree 8df2ff5de0244d00548123970d13cc7d5156c6a1, no local production edits.
build: cargo build --workspace --release --target x86_64-pc-windows-gnu --offline --locked -j 3 --message-format=json-render-diagnostics -> ok on base and merge.
tests: cargo test --workspace --release --target x86_64-pc-windows-gnu --offline --locked -j 3 --no-fail-fast -- --test-threads=4 --nocapture -> exit 101 on both. On each, 41 of 42 harnesses completed with 136 passed, 12 failed, 20 ignored; the library harness exited 5 without a summary. These are completed-harness counts, not full-suite totals. Four SKIPPED notices on each: three missing D3D12 debug layer and one disabled heap-window path.
review: Read the complete one-file diff and current module. Registry lookup, Arc::ptr_eq and removal share one lock; the store-clear guard is released before that lock. Targeted stale-store regression is red on base and green on merge, as below. No blocking finding in this change itself.
performance: One pointer comparison on delete-on-destroy session release; no added draw/dispatch work. Reasoned, not timed.
verdict: not yet: this Wine run cannot establish full-suite non-regression because both library harnesses abort. Targeted fix verified; no PR-specific failure observed among the completed harnesses. A complete independent merge check remains needed.
hardware / tool and model: RX 9070 16 GB, RADV GFX1201 / Mesa 26.3.1-arch3.5; Ryzen 7 7700, 30 GiB RAM; CachyOS 7.3.6-3-cachyos; GE-Proton11-12 / Wine 11.0 Staging, vkd3d-proton 8293130ebe370b1+; Rust 1.97.1, Windows GNU release executables. Codex, GPT-6 (exact serving variant not exposed).
Tested
Targeted runner: Wine
<unit.exe> hle::d3d12x::shader_cache_session::tests:: --nocapture --test-threads=1, then--test-threads=4.--exactZero targeted skips. Negative controls fail at
FindValuewith0x887A0002; the unchanged base production code loses the replacement store. The device/session test also exercises XCL's actual fallback after vkd3d-proton returns0x80004001.The same 12 completed-harness failures occur on both sides in
d3d12_resource_and_sync,e2e,gpu_compute_e2e(six),gpu_two_pass_cache_e2e,pls_quota,predication_e2eandsparse_reinit. Both library runs reportgpu::dxil::fuzz_tests::fuzz_validate_and_gpu_2failed before exiting 5; neither produces library totals. No cause or PR attribution claimed for those interruptions.Separate source worktrees and final target directories; source hashes, test inventories and distinct executable hashes verified. An initial shared-target attempt reused the base executable; it was rejected and excluded from all PR results above.
Not tested
Native Windows/MSVC, retail titles,
scripts/smoke.ps1, timing/FPS, or the library tests left unexecuted after the abort.XCL_SAMPLE_*unset;XCL_NETWORK=0.AI use
Codex (GPT-6, exact serving variant not exposed) reviewed the diff, prepared the verbatim-test negative control, ran the comparisons, verified source/binary provenance and drafted this report. Publication authorized by the account owner.
Imported from ivall/xcl. Originally posted by Pipodi on 2026-11-30T14:20:22Z.
merge-check claim
head:
0003178b8cImported from ivall/xcl. Originally posted by Pipodi on 2026-11-30T14:37:38Z.
merge-check
base:
9dfbe3ea66head:
0003178b8cmerge: clean (local merge tree 5dcb48bc75218a0a547cceb1b9823963b1b8be8b)
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> first run: the library harness aborted (0xc0000409, STATUS_STACK_BUFFER_OVERRUN, no summary), the other harnesses 148 passed, 0 failed, 20 ignored. The library harness alone rerun: 2738 passed, 1 failed, 31 ignored, so 2886 passed, 1 failed, 51 ignored in all; failing: gpu::dxil::msaa_tests::gpu_direct_image_get_resinfo_d16 (also fails on main
9dfbe3ea, fixed by #3513). New test shader_cache_session::tests::stale_delete_on_destroy_does_not_evict_newer_disk_store passes on the merge and fails with the production hunk reverted (uncommitted; FindValue returns 0x887A0002). 24 SKIPPED: 22 "no wave64", two_pass_binds_set_the_shared_view_heap (no heap windows) and pso_measurement_compiles_an_exact_synthetic_record (cannot disable the driver cache).disagreement of the two earlier checks: thehollowedone lists console_mesh_caches_hlsl_compute_pass_in_memory_and_on_disk as failing on the merge and on base; SzczepanGrela (Wine, RADV) could not get library totals because the library harness aborts. Here console_mesh_caches_hlsl_compute_pass_in_memory_and_on_disk passes (in the library rerun, and also on the merge for #1781), so it is not caused by this PR and is not a failure on this setup. The library-harness abort is not specific to this PR: it did not repeat on the rerun of the same binary and was reported on unmodified main by DavidM1911 on this PR (0xc0000005 under parallel scheduling); the PR changes only the release path of a fallback shader cache session. The Wine run therefore does not block: its targeted result (test red on base, green on merge) matches mine.
review: read the whole diff (crates/xcl/src/hle/d3d12x/shader_cache_session.rs, +50 -1). release() now removes the shared disk_stores key only when the entry is still this session store (Arc::ptr_eq), under one lock held for the get and the remove; the store lock is dropped before it. This closes the sequence where an older session, released late, evicts a newer store of the same (id, version). No blocker.
performance: one pointer comparison when a delete-on-destroy session is released; nothing in the frame path.
verdict: safe to merge
hardware / tool and model: NVIDIA RTX 4090, driver 621.40; i9-13900K; Windows 11 Pro 10.0.26300; rustc 1.100.0; debug. Claude Code, Claude Opus 5.5.
Imported from ivall/xcl. Originally posted by brainhay5 on 2026-11-30T23:55:12Z.
merge-check claim
head:
0003178b8cClaiming for a tie-break: the three checks on this head disagree because one was run under Wine (x86_64-pc-windows-gnu), where both library harnesses abort. A native Windows run on the same head should settle whether that verdict reflects the PR or the environment.
Imported from ivall/xcl. Originally posted by brainhay5 on 2026-12-01T00:12:32Z.
merge-check
base:
d0832e614fhead:
0003178b8cmerge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2890 passed, 1 failed, 51 ignored; 29 SKIPPED lines; failing: test_title_runs_and_game_folder_is_untouched — also fails on the base alone with the same command, verified by running it there
review: one file (+50), and the change is the right shape:
releasenow removes the disk store only when the entry is still the sameArc(Arc::ptr_eq), so a session that is stale (its store already replaced by a newer session for the same identifier/version) can no longer evict the newer one. The lock is taken once and the check and removal happen under it, so there is no window between them. The added test builds exactly that ordering — s1 and s2 delete-on-destroy, s1 dropped, s3 opens a fresh store and writes, s2 dropped — and asserts s3's value survives; that test fails without the change. Contained, no unrelated edits, no new dependency.performance: none in a hot path — the guard runs once per session release, and
ptr_eqis a pointer comparison. No per-frame or per-draw cost.verdict: safe to merge
comment on the disagreement above: this head has three checks and two verdicts. The
not yetcame from a run under Wine with--target x86_64-pc-windows-gnu, where the check itself reports that both library harnesses abort — so it could not establish non-regression, which is a statement about that environment rather than this PR. On native Windows the full suite completes (2,774 lib tests present, 2,890 passed overall) and the only failure is the one that fails on base regardless. That matches the twosafe to mergeverdicts above.hardware / tool and model: RTX 5070 Ti 16 GB, driver 610.88 (32.0.16.1088); Ryzen 7 5800X3D, 64 GB; Windows 11 22631; OpenCode agent, DeepSeek V4.1 Flash 1017
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T06:14:22Z.
Triage (#1607) – head
0003178No open or merged PR makes the same change: main's
releaseinshader_cache_session.rsstill removes thedisk_stores()entry by key alone. #2878 and #2332 edit the same file (shared memory-mode sessions, StoreValue capacity) but keep that removal as it is. The new test fails without theArc::ptr_eqguard (stale s2 evicts s3's store).No problems found in the diff.
Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
Imported from ivall/xcl. Originally posted by Decodere on 2026-12-02T08:33:34Z.
merge-check
base:
1c8b551475head:
0003178b8cmerge: clean trial merge into
1c8b551475e1e7bfe48f94448492a4c3544a2e0f(trial-merge commitc3a132c75e5c7bae7bd7c41b907b50273757c6a7;git diff --checkclean).build:
cargo build --workspace-> ok.tests:
cargo test --workspace --no-fail-fast -- --test-threads=4 --nocapture(43 targets) -> 2910 passed, 0 failed, 51 ignored (+1 new test vsmain1c8b5514; all 43 targets green includinggpu_two_pass_cache_e2e). Bothhle::d3d12x::shader_cache_session::testspassed with 0 skips:stale_delete_on_destroy_does_not_evict_newer_disk_storeandrejected_create_shader_cache_session_falls_back_to_working_in_memory_session. 28SKIPPEDlines — all hardware/environment-expected on RTX 4060 (22no wave64, 2no d3d12SDKLayers.dll, 1no D3D12 debug layer, 2no heap windows, 1cannot disable the driver cache (Windows Developer Mode required)).review: read the full merged diff (1 file:
crates/xcl/src/hle/d3d12x/shader_cache_session.rs, +50/-1). Production change is 4 lines inrelease(shader_cache_session.rs:157-160): before removingkfromdisk_stores()onSetDeleteOnDestroy, it checksArc::ptr_eq(cur, &boxed.store)under thedisk_stores()lock so a stale session handle holding an olderArccannot evict a newer session's store opened under the same(id, version). Clean, race-free, properly mutex-scoped, and covered by the new regression test. No UB, lock-ordering, or correctness issues found. Note on the prior disagreement: the earliernot yetwas an unrelated Wine lib-test-harness abort (0x40000015) with no defect attributed to this PR, and the entire native Windows workspace suite passed 2910/0 here.performance: Tier 1 — cold teardown path (
releaseof fallbackID3D12ShaderCacheSessionwithSetDeleteOnDestroy); adds a singleArc::ptr_eqcheck while already holding thedisk_stores()mutex. No runtime or hot-path impact (retail smoke not required perTESTING.md).verdict: safe to merge
hardware / tool and model: NVIDIA GeForce RTX 4060 8 GB (driver 621.40), Intel Core i5-11400F, 32 GB RAM, Windows 11 Build 26200, Rust 1.100.1 MSVC, DXC 1.9.2602.17 / Antigravity (Gemini 4 Neon)
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.