D3D12.X: preserve replaced driver blobs after stale rejection #2604
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2614"
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 luckyteagirl on 2026-11-26T02:03:27Z.
Fixes #2601. A driver can reject a cached blob after another process replaces the same path. A pathname delete then removes the replacement, even if both generations have identical bytes. Keep the handle that supplied the old blob through PSO creation and invalidate that file object on refusal.
What is in it
crates/xcl/src/hle/d3d12x/real.rs: retain the exact opened file generation and dispose that handle on runtime refusal; a cross-process regression directly replaces a still-open blob with identical bytes. On the current main's two-pass mesh path, retain the loaded disk generation through the driver call and invalidate it before a refused cold retry; a RAM hit evicts only the matching RAM entry.crates/xcl/src/shaders.rs: retain and invalidate the same file generation for an offline over-cap refusal; on a refused under-cap blob, release and invalidate that generation before an uncached retry so Wine can publish a replacement.Tested
d50210a8on main83b00818:cargo build --locked -p xcl -j 1passed.cargo test --locked -p xcl --lib -j 1 hle::d3d12x::real:: -- --nocapturepassed 65 tests, 0 failed, 0 ignored, 0 explicit SKIPPED (1,293 filtered). This includes the exact-file cache tests, graphics rejection/retry, five two-pass identity tests and a real RX 6800M mesh passthrough test. The corresponding unpatched GitHub merge failed to compile at the graphics cache call sites.git diff --checkand the worktree are clean. This is focused validation, not a full GPU workspace suite or retail title run.8927d18f: a cap-disabled stale-blob regression failed with the test-only addition on previous headcd7be10fand passed with the fix.cargo test -p xcl --lib driver_cache::tests -- --nocapture: 6 passed, 0 failed;cargo test -p xcl --lib pipeline_cap_tests -- --nocapture --test-threads=1: 3 passed, 0 failed. The pipeline-cap group also passed five parallel reruns after one initial split-cache reuse failure; the split test passed in isolation. These are focused Windows tests, not a Wine run or completed GPU suite.8927d18ftests and oldercd7be10fbuild, workspace, and retail results below are historical; they do not validate current headd50210a8.cargo build --locked --workspace -j 1: passed.943947c: a new identical-byte replacement regression failed 0 passed, 1 failed, showing that the replacement was deleted. This draft revision uses the exact file handle instead.cargo test --locked -p xcl --lib -j 1 hle::d3d12x::real::driver_cache::tests -- --test-threads=1 --show-output: 6 passed, 0 failed, 0 ignored, 1332 filtered. The direct cross-process, identical-byte replacement test passed separately (1 passed, 0 failed).cargo test --locked -p xcl --test gpu_compute_e2e -j 1 -- --test-threads=1 --show-output: 7 passed, 0 failed, 0 ignored; one test reportedSKIPPEDfor unavailable heap windows.XCL_ADAPTER=nomatchwithcargo test --locked --workspace --no-fail-fast -j 1 -- --test-threads=1 --show-output: 37 target summaries, 1437 passed, 0 failed, 47 ignored. The log contains 138 standaloneSKIPPEDnotices, many repeated subcases, and more inline skip notices; adapter-dependent GPU cases are not coverage. No complete RX 6800M suite is claimed.cbc165f, which has the same source tree as the previous headcd7be10,XCL_ADAPTER=6800M XCL_REQUIRE_GPU=1with the same workspace command stopped in the library test process atgpu::dxil::core_tests::raw_loads_in_root_windows_respect_exec_and_boundswith0xc0000005(STATUS_ACCESS_VIOLATION), before a library summary. The--no-fail-fastintegration targets continued, includinggpu_compute_e2eat 7 passed / 0 failed. A prior clean-main control on this RX 6800M crashed in the same focused raw-load test; I have not rerun that control onb49be18.cd7be10on an RTX 5070 Ti and an AMD Ryzen 7 9800X3D iGPU. With explicitly listed exclusions for tests that also fail on main on those systems, the NVIDIA workspace run reported 1,425 passed, 0 failed, 45 ignored; the AMD iGPU run reported 1,436 passed, 0 failed, 47 ignored. The new blob-replacement tests passed. These were debug test runs, not game runs. Independent report with hardware, exclusions and SKIPPED notices.cargo test --workspace --no-fail-fast -- --test-threads=4: 1,437 passed, 0 failed, 47 ignored, 25 explicit GPU skips (native wave64 and refused per-lane forms). All sixdriver_cachetests passed, and the six-test group passed 30 of 30 parallel reruns at eight test threads. These are the independent reporter's results, not runs on our RX 6800M.Regression run
A paired main/current-head retail run is pending for
d50210a8; the pluggable SSD containing the owned title is not mounted. The blocks below were collected on the previous headcd7be10fand do not validate the current code.Guarded 30-second debug builds on the owned title, same RX 6800M and fresh per-run cache/data. The previous head showed 315/385 frames (81.8% of main) and 8267/8284 MB peak commit (99.8% of main). Both exited normally with no device removal or crash.
main:
PR:
Not tested
AI use
bb54f23; my follow-up commitcd7be10strengthens the child-process replacement test. OpenAI Codex (GPT-6; exact serving variant unavailable), with Luna subagents, adapted that test, reviewed the code, ran the stated checks, and prepared this description.8927d18f. The same model rebased the PR ontomain83b00818, fixed the two-pass graphics cache integration, and ran the current-head focused build and tests; Codex reviewed the diff and updated this description.Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-26T02:32:01Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, 26 ignored.Thanks!
— Devin
Imported from ivall/xcl. Originally posted by mokkamokacaffe on 2026-11-26T02:38:17Z.
I independently prepared a fix for #2601 before noticing this PR had opened concurrently, so I will not open a competing PR.
One generation-identity edge remains in
invalidate_if_unchanged: byte equality does not prove that the pathname still names the generation that was read. If replacement B is byte-for-byte identical to A, rejection of A still deletes B. The protection also depends on every writer using the new.lockprotocol, which mixed XCL versions do not guarantee.An alternative is to retain the exact file handle used to read A through PSO creation, opened with delete access and
FILE_SHARE_DELETE, then invalidate that file object withFileDispositionInfoExand POSIX delete semantics. This remains correct for identical replacements and non-cooperating writers and does not add persistent lock files.I have an unsubmitted reference implementation and an identical-byte cross-process regression here:
github.com/mokkamokacaffe/xcl@06d08685e6That branch has only passed Windows-target compilation from Linux, whereas this PR has real Windows/AMD execution, so I am offering it as a design/test contribution rather than claiming it is better validated.
AI-assisted review: OpenAI Codex (GPT-6.2 Astra, Ultra reasoning).
Imported from ivall/xcl. Originally posted by mokkamokacaffe on 2026-11-26T03:01:18Z.
Interesting
Imported from ivall/xcl. Originally posted by luckyteagirl on 2026-11-26T03:03:38Z.
Thanks for catching the generation-identity gap and offering the reference implementation. I reproduced the identical-byte failure on the previous
943947chead: the replacement was deleted (0 passed, 1 failed in the focused regression). I adapted your retained-handle approach on draft headcbc165f, credited your commit in the commit message and PR description, and changed the cross-process test so the child publishes B directly over the still-open A before the delayed parent invalidates A.On Windows, the new cross-process test passes; all six
driver_cache::testspass,gpu_compute_e2epasses 7/7 on the RX 6800M, and the full workspace run with adapter selection disabled reports 1,437 passed / 0 failed / 47 ignored. Windows no-GPU CI is green. The full GPU run still stops at the same raw-load access violation previously observed on clean main; the revised head's paired title smoke is pending. This response was prepared with OpenAI Codex (GPT-6; exact serving variant unavailable).Imported from ivall/xcl. Originally posted by mokkamokacaffe on 2026-11-26T03:06:40Z.
Thanks for the clear provenance, the failing-first reproduction, and the Windows/AMD validation.
I compared revised head
cbc165fwith my reference commit06d08685e60b37a38728c6caf9b1f103995bf468; the resulting trees differ only in the three-line strengthening of the child-process regression. Since the retained-handle implementation and the rest of the tests were adopted substantially intact, could the Git history preserve authorship as well?Either approach would work:
06d08685e60b37a38728c6caf9b1f103995bf468and put the direct-replacement test adjustment in a follow-up commit; orCo-authored-by: mokkamokacaffe <[email protected]>The existing commit-message and PR-body attribution is appreciated; this request is only so the authorship survives in Git/GitHub history.
AI-assisted comment: OpenAI Codex (GPT-6.2 Astra, Ultra reasoning).
Imported from ivall/xcl. Originally posted by luckyteagirl on 2026-11-26T03:10:59Z.
Done. I rewrote the draft PR as two commits:
bb54f23is a cherry-pick of your06d0868, retaining you as the Git author, andcd7be10is my three-line test adjustment. I verified the final source tree is identical to the previously testedcbc165ftree. Thanks for asking for the durable credit; the PR commit list now shows your authorship directly.The paired title smoke remains pending. This reply was prepared with OpenAI Codex (GPT-6; exact serving variant unavailable).
Imported from ivall/xcl. Originally posted by mokkamokacaffe on 2026-11-26T03:15:41Z.
Thank you, @luckyteagirl — I really appreciate you restructuring the history to preserve my original Git authorship and keeping your test adjustment as a separate commit.
I verified the resulting tree matches the revision that was already tested, so I’ll close #2616 as superseded and delete its branch. Thanks again for handling this so thoughtfully.
AI-assisted comment: OpenAI Codex (GPT-6.2 Astra, Ultra reasoning).
Imported from ivall/xcl. Originally posted by fromthemoonx on 2026-11-26T03:25:36Z.
A complete GPU workspace suite on NVIDIA (both listed under Not tested): passes, and the
driver_cachetests are stable in parallel.Tested:
cd7be10(its base is currentmainb49be18, so head = merged). RTX 3060 12 GB (driver 610.88), Ryzen 7 5700X, Windows 11 Pro 26300 (NTFS), Rust 1.100.0 MSVC, debug.cargo test --workspace --no-fail-fast -- --test-threads=4SKIPPEDlines (no wave64, refused per-lane forms); all 6driver_cache::testsran and passed, includingan_older_process_cannot_remove_a_replacement_blobanda_cache_symlink_never_disposes_its_targethle::d3d12x::real::driver_cache::tests::(6 tests),--test-threads=8, 30 runsThe library process ran to the end here (no
0xc0000005), so this is the full GPU run the RX 6800M log could not give.Not tested: a refusal in a real title (no stale blob was produced), a release build, AMD (covered above).
AI use: Claude Code (Claude Opus 5.5) ran the suite and the repeats, and wrote this report.
Imported from ivall/xcl. Originally posted by upipibi on 2026-11-26T05:30:31Z.
NVIDIA test report for
cd7be10: RTX 3070 8 GB (Ampere, driver 616.56), Windows 11 26100, Rust 1.100.0, debug.cargo test -p xcl --lib -- --skip hle::xaudio2 --test-threads=4(thehle::xaudio2tests hang on this machine, onmaintoo):driver_cachetests (an_older_process_cannot_remove_a_replacement_blob,a_cache_symlink_never_disposes_its_target) ran in it and passed.Lib tests only; no title run.
AI-assisted (Claude Code, Claude Opus 5.5).
Imported from ivall/xcl. Originally posted by futurepro62 on 2026-11-26T05:34:19Z.
NVIDIA and AMD full-suite run, to go with the reports above by fromthemoonx, upipibi, since none of them covers AMD. Tested exact head
cd7be10f(on its baseb49be18).Tested
cargo build --workspace, thenXCL_REQUIRE_GPU=mesh cargo test --workspace -- --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: 1425 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.an_older_process_cannot_remove_a_replacement_blob,a_cache_symlink_never_disposes_its_target.XCL_ADAPTER=radeon),cargo test --workspace -- --test-threads=4 --skip gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1: 1436 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 mainb49be183too, 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 DavidM1911 on 2026-11-26T08:29:18Z.
Re-verification on RTX 3060 Ti (Windows 11), new head merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.Thanks!
— Devin
Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-26T11:45:43Z.
Wine/Proton concern with the open
LoadedBlobhandle (checked againstcd7be10f).Under Wine, renaming over a file that has any open handle fails. In
server/fd.c,set_fd_namereturnsSTATUS_ACCESS_DENIEDwhen the destination inode has open fds ("can't replace an opened file"). It does not look at share modes, and it ignoresFILE_RENAME_POSIX_SEMANTICS. This happens on ext4 or any other Linux filesystem.FileDispositionInfoExwith POSIX semantics is accepted, and the file is unlinked when its handle closes, soinvalidate()itself works.Where it breaks: the refused, not-over-cap branch of
Pipelinesincrates/xcl/src/shaders.rs.loadedis still open when the uncached compile finishes anddriver_cache::write(path, ..)renames the new blob over the same path. Under Wine that rename always fails, and the stale file is not invalidated in this branch. Every later--pipelinespass loads the same stale blob, gets it refused, compiles again and fails to save. Before this PR,remove_filecleared the stale file. On NTFS the POSIX rename succeeds, so this only shows up under Wine (and on Windows volumes without POSIX rename).Suggested change: once the driver has refused the blob, invalidate it (which closes the handle) before the uncached compile, as the over-cap branch above already does:
The runtime call sites in
real.rsalready callnote(false, loaded.take())before the retry andkeep, so they don't hit this within one process. They do keep the handle open through the first driver compile, though. While a cache file is open there, a second XCL process sharing the cache dir cannotkeepa replacement for it under Wine. Dropping the handle earlier would avoid that, for example by keeping the bytes and reopening for deletion only on refusal, at the cost of the generation check. That is a smaller issue.Not tested: this comes from reading Wine master's source on the GitHub mirror. The
server/fd.cbehaviour was read in the source itself; the ntdll and kernelbase handling is from a summary of those files. Nothing was run under Wine or Proton. The same lifetime affectsan_older_process_cannot_remove_a_replacement_blob: its child'swriteover a file the parent still has open would be refused under Wine.AI use: found and written with Claude Code (Claude Opus 5.5) and checked by me.
Imported from ivall/xcl. Originally posted by luckyteagirl on 2026-11-27T07:03:47Z.
I moved this PR back to draft while I address the Wine open-handle concern. On the current head
cd7be10f, the under-cap refused-blob path keepsLoadedBlobopen through the uncached retry and the same-name cache write. Wine's server rejects replacing a destination with an open handle, so the stale cache file may survive and be refused again on the next pass. I checked the current XCL and Wine source; I have not run this path under Wine.The existing Windows GPU suite and paired title smoke remain valid results for
cd7be10f, but they do not cover this case. A fix needs to close/invalidate the refused blob before the retry, followed by fresh validation on the new head. The owned-title SSD is offline at present, so I cannot produce the required new paired smoke blocks yet.AI-assisted source review: OpenAI Codex, including a GPT-6.2 Sol agent.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T08:28:45Z.
Triage (#1607) – head
d50210aMain commit
e72351f(merged with #2959) is adapted from this PR. It adds the samedriver_cache::LoadedBlob, which keeps the handle of the file generation it read and disposes that object on refusal (FILE_DISPOSITION_FLAG_POSIX_SEMANTICS,FILE_FLAG_OPEN_REPARSE_POINT).It also adds the cross-process replacement and symlink tests.
compute_container,translated_graphics_pso_once, the two-pass mesh/compute paths and the offlinePipelinesretry inshaders.rsall passloaded.take()/invalidate()on main.Recommendation: close (superseded by main commit
e72351f).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 throny on 2026-12-01T12:55:22Z.
Closing as superseded: this change is already on
main(e72351f8). main real.rs driver_cache::LoadedBlob with handle-based invalidate used at the runtime and the shaders.rs offline refusal sites, tests included; commit says Adapted from #2614Two independent checks found this: Foniass's close list on #1607 and ours against current
main. If something here is still missing onmain, say so and reopen it, or ask and I will.AI use: Claude Code (Claude Opus 5.5); the per-PR comparison was done by Claude Sonnet 5.5 sub-agents.
Pull request closed