D3D12.X: remove tracked textures before final COM release #1517
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1527"
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 OtavioTadeu on 2026-11-24T17:17:17Z.
Synchronizes
real::res_releasewithtitle_textures::TEXTURESso tracked resources are removed before their COM refcount can drop to 0 (underXCL_LATE_RELEASE=0or a concurrent refcount-2 race), preventingrefresh_onceandclone_resourcesfrom callingAddRefon freed memory. Fixes #1359.What is in it
crates/xcl/src/hle/d3d12x/title_textures.rs: addTRACKED_COUNT,ReleaseOutcome,release_tracked, and unit + concurrent refcount-2 race testscrates/xcl/src/hle/d3d12x/real.rs: routeres_releasethroughtitle_textures::release_trackedbefore final release and cleanupTested
stable-x86_64-pc-windows-msvc), debug buildcargo test --workspace -- --test-threads=4: 777 passed, 0 failed, 41 ignored (SKIPPED GPU tests:gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask[no wave64],gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware[no wave64],heap_window_out_of_memory_falls_back_to_the_switch_form[no heap windows])cargo test -p xcl --lib title_textures: 14 passed, 0 failedcargo test -p xcl --lib d3d12x: 144 passed, 0 failed, 1 ignoredRegression run
scripts/smoke.ps1 -Game retail_title -Seconds 60(mainbaseline vs PR head on NVIDIA GeForce GTX 1660 SUPER):Not tested
AI use
Imported from ivall/xcl. Originally posted by upipibi on 2026-11-24T17:47:55Z.
Duplicate note: #1404 (opened earlier, not a draft, 3 comments) also fixes #1359 in
real::res_release. The approaches differ:real.rs. It callstitle_textures::forgetfrom the reference countReleasereturns, and around an extraAddRef.title_textures::release_tracked(+202 intitle_textures.rs), with unit tests and a concurrent refcount-2 race test.Both edit
res_release, so only one can land. Comparison only: I haven't run either.AI use: Claude Code (Claude Opus 5.5) compared the diffs and wrote this.
Imported from ivall/xcl. Originally posted by Belox17 on 2026-11-24T18:48:49Z.
Test report for
0789e88b/7c748c8bon NVIDIA (RTX 3060 Ti): the whole suite passes, but the new test is flaky and takes two other tests down with itTested
0789e88bas is, clean tree. The current head7c748c8bis the same patch rebased onto9e3831e(git range-diff); its tree is identical to my merge of0789e88binto9e3831e, and the test is unchanged.cargo test --workspace -- --test-threads=4: 771 passed, 0 failed, 41 ignored (baseb7aa9f3: 770). Merged into9e3831e: 777 passed, 0 failed, 41 ignored.cargo test -p xcl --lib tracked_release_removes_entry, alone, 20 runs: 13 passed, 7 failed, alwaysobject not freed on iteration N(title_textures.rs:2181; N = 2, 14, 70, 85, 115, 208, 460).cargo test -p xcl --lib title_textures -- --test-threads=4, 10 runs: 5 passed, 5 failed. Each failed run has 3 failures: this test, plusplaced_title_textures_share_vram_and_preserve_pixelsandtransitions_apply_when_their_list_is_submittedwithPoisonError, because the panic happens whileTEST_LOCKis held.Likely cause, from reading the test (I did not instrument it): the
readerthread AddRefs every tracked key under theTEXTURESlock and releases it later throughrelease_tracked. When the reader holds the last reference in an iteration, the finalmock_releaseruns on the reader thread, possibly aftert2.join(), soobj.freedcan still be false at the assertion. Waiting until the reader has dropped its references to the current object (or keeping the reader away from the object under test) before asserting would make the check deterministic.Not tested
res_releasewith a title (late release on andXCL_LATE_RELEASE=0); AMD; any retail title (no smoke run).AI use: Claude Code (Claude Opus 5.5) ran the commands and wrote this report; I checked it before posting.
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T18:58:39Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~21 ignored.Thanks!
Imported from ivall/xcl. Originally posted by throny on 2026-11-24T20:29:58Z.
Two contributors checked independently and found that #801 #1404 solves the same problem (for #1359) in a different way: #1607, group D38. You may want to compare them with the other author and agree on one, or say in the PR why both are needed.
This is a hint, not a request from the maintainers; nobody from the project has adopted #1607 so far.
AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.
upstream-sync referenced this pull request2026-11-25 06:04:27 +00:00
Imported from ivall/xcl. Originally posted by JJAutoCompare on 2026-11-25T05:20:21Z.
Empirical test report (
25fe0672)PR #1527, tested at
25fe06723d867defb80671d309a002f30a17475f.Hardware / environment
rustc 1.100.0 (0ef1bc386 2026-11-09)dxcompiler.dll: 1.9(5512-01b62ad4)(1.9.2609.5) - 1.9.2609.5 (01b62ad47)Commands and results
cargo test --workspace --no-runexited 0. This compiled the workspace test binaries.cargo test -p xcl --lib tracked_release_removes_entry_before_final_drop_and_survives_refcount_2_raceran outsideInvoke-ArcTest.ps1withXCL_ADAPTER=NONE_CPU_ONLYandRUST_TEST_NOCAPTURE=1. It exited 0 with 1 passed, 0 failed, 0 ignored, 0 skipped, and 748 filtered out.Observed behavior
The mock COM fixture confirmed that the single-reference resource left the texture table while the final reference was still held. Its concurrent case ran 500 iterations with two releasing threads and a reader that attempted to retain the resource under the table lock. Every iteration reached mock destruction, removed the table entry, and completed without the mock recording an AddRef after destruction.
Not tested
The full GPU workspace suite and game smoke runs were omitted. This fixture exercises the release helper with mock reference counts. It provides no coverage of the real D3D12 release hook, GPU queue behavior, or a title running with
XCL_LATE_RELEASE=0.AI use
Verified with T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high). Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against
pr1527-focused.logand published.Imported from ivall/xcl. Originally posted by ettehn on 2026-11-25T07:01:19Z.
I repeated the mock COM test after the earlier flaky result. I applied the
25fe067diff by itself tomainat568e7dband verified that the added and removed lines match the upstream diff.On Windows 11 25H2 (
26200.9974), Ryzen 9 8945HX, Rust 1.97.1 MSVC (debug), I rancargo test --locked --offline -j 2 -p xcl --lib hle::d3d12x::title_textures::tests::tracked_release_removes_entry_before_final_drop_and_survives_refcount_2_race -- --exact --test-threads=1withXCL_ADAPTER=NONE_CPU_ONLY. 20 of 20 invocations passed, with 500 concurrent iterations per invocation and zero failures or ignored tests. I tested the updated fixture on this machine. This run did not exercise the actual D3D12 release hook, the GPU, or a retail title.Verification assisted by OpenAI Codex (GPT-6).
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-26T05:40:35Z.
Re-verification on RTX 3060 Ti (Windows 11): still a merge conflict with current
mainon the new head — needs another rebase before it can be tested.Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T06:00:14Z.
Triage (#1607) – head
25fe067Same problem (#1359) as #1404 and #801 (#1607 D4 / D38), solved differently: this PR serializes a tracked resource's last Release under the
TEXTURESlock and keeps late_release; #1404 forgets on unlocked AddRef probes; #801 runs Release under the lock on an older base without late_release.Main commit
6a7e44ehas since rewrittenres_release(real.rs): it now tells the last reference by an AddRef/Release probe on every path and callstitle_textures::forgetwhile the object is still alive, which closes most of the window this PR targets. What is left is two releases of the last two references at once, whichrelease_trackedstill covers for tracked textures. The PR conflicts with that rewrite and needs rebasing onto it; in itsLast { hold_ref: false }path the object is already freed before the address-keyed cleanup inres_release, which is what6a7e44emoved away from.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.