D3D12.X: drop CopyScratch resources outside COPY_SCRATCH lock and skip own-work reset hooks #3111
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3111"
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 iggyvilla on 2026-11-28T08:44:11Z.
Fixes #3069.
Updated for
amd-devf33df5a7(the first version was against7c795f5e; the old head6f37174cis replaced by a rebased commit).CopyScratchCachestill droppedID3D12Resourcewrappers (incollect_releasedandacquire) while holding the globalCOPY_SCRATCHmutex.ID3D12Resource::Releaseentersreal::res_release->vram::PAGES, so this inverts the lock order against threads that holdPAGESand wait forCOPY_SCRATCH.list_x.rs:collect_released,releaseandacquirehand evicted scratch to the caller in aVec<CopyScratch>; every caller (on_queue_release,release_copy_scratchand its reaper thread,copy_scratch,acquire_scratch_for_copy,copy_scratch_submitted, the two tests) drops it after releasingCOPY_SCRATCH.real.rs:cl_resetskipslist_x::on_pc_reset,dred::resetanddred::mark_pipelinewhentitle_textures::is_own_work(), so XCL's own list resets never enterCOPY_SCRATCH.Tested
32.0.21045.29003), Ryzen 7 5700X, Windows 11,rustc 1.100.0, debug test build onorigin/amd-devf33df5a7+ this commit.cargo test --lib copy_scratch: 2 passed, 0 failed.cargo test --lib hle::d3d12x:: -- --test-threads=1: the same 8 tests fail with and without this commit (insparse,title_texturesandreal::release_tests); no new failures.7c795f5e) 4 runs of 254-600 s on this card without a hang. Onf33df5a7only the 60 s smoke below was run.Regression run
Both 60 s runs with
scripts/smoke.ps1 -Seconds 60,XCL_PREPARE=0, on the same retail title and RX 6650 XT, afterxcl pso-precompile --usedhad warmed the compute pipeline cache (with a build that has all three ports of this series). Firstmaind8bd9a38, then this PR's head.Peak commit is 1.56x main's, past the 1.25x rule, but that is
amd-dev's, not this change's: the same 60 s run onamd-devf33df5a7without this commit peaks at 25,028 MB (1,429 frames). So everyamd-devPR will fail that one line of the check untilamd-devitself comes down.Not tested
cargo test --workspace, so the PR description check stays red), NVIDIA, RDNA3/RDNA4.AI use
amd-dev7c795f5e) was written and tested by Antigravity with Gemini 4 Neon (High). Its port tof33df5a7(the old patch no longer applied: the code moved) was done by Claude Code (Claude Sonnet 5.5, effort high), which also ran the tests below and wrote this text. The account owner did not write the code or this text.Imported from ivall/xcl. Originally posted by JJAutoCompare on 2026-11-28T10:37:58Z.
Tested
Exact
6f37174c9d1c14ef914c716855e2346e4438a434on theamd-devPR, Windows 11 x64 build 26200.9974, Ryzen 7 3800X, and Rust 1.100.1 MSVC. I reran the pinned standalone CPU harness withcopy_scratch.exe --test-threads=1 --nocapture. ItsCopyScratchCache::collect_releasedandreleasemethods matched the Git source byte-for-byte. The harness supplied stand-in owners, synthetic completion inputs, and a fixture mutex.The busy entry stayed counted until completion. The sweep also visited the idle entry swapped into a vacated slot. Retained bytes went 238 → 149 → 82 → 59 → 0. Owners dropped exactly once in order
1, 3, 4, 6, 2, 5, andtry_locksucceeded in each destructor.1 passed, 0 failed, 0 ignored, 0 runtime skips. Native exit was 0, with no tests filtered out.
Not tested
Native COM or D3D12 behavior, GPU, acquire paths, production call sites, runtime reset hooks, the reported stall, retail soak, CI, and the workspace suite.
AI use
T3 Code through the Codex harness (
gpt-6.2-sol) verified the source and executable, reran the standalone test, and wrote this report.Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T09:31:45Z.
Triage (#1607) – head
e2f500dThis PR's commit is already on
amd-devase46947d("cherry picked from commite2f500d1"), with the same changes tolist_x.rs(CopyScratchCachehands evicted scratch back to drop outsideCOPY_SCRATCH) andreal.rs(cl_resetskips own-work lists). Nothing in this PR is missing from the base branch.Recommendation: close (superseded by amd-dev commit
e46947d).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-01T16:01:24Z.
Closing as superseded: this change is already on
amd-dev(e46947d0). From Foniass's rechecked close list on #1607, checked again by script just now. If something here is still missing, say so and reopen it, or ask and I will.AI use: Claude Code (Claude Opus 5.5).
Pull request closed