D3D12.X: forget released command queues from vram::Pages::waited #1889
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1899"
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 emirduran707 on 2026-11-24T22:46:05Z.
vram::Pages::waitedcaches the last tile-mapping fence value each command queue waited on, keyed by the rawID3D12CommandQueueCOM pointer.real::q_releasenotifiedlist_x::on_queue_releasewhen a queue's refcount reached zero, but left its entry invram::Pages::waited.If a newly created command queue reuses a freed queue's COM pointer while
pages.valuehas not advanced,vram::before_executesees the stale entry and skipsqueue.Wait(&pages.fence, pages.value), allowing the new queue to execute against tiled resources before pendingUpdateTileMappingscomplete (and leaking a map entry for every destroyed queue).What is in it
crates/xcl/src/hle/d3d12x/vram.rs: extract the wait tracker intoFenceWaits, addvram::forget_queue, and add unit testreleased_queue_address_rewaits_on_reuse.crates/xcl/src/hle/d3d12x/real.rs: callsuper::vram::forget_queue(this as usize)inq_releasewhen the queue's refcount reaches zero.Tested
cargo build --workspace, thencargo test --workspace --no-fail-fast -- --test-threads=4on11fea40(rebased ontomain1a0bbe3): 1249 passed, 2 failed, 46 ignored; 8 SKIPPED (6 inlower_dxil::tests::{f16,f32}_programs_on_the_gpu;heap_window_out_of_memory_falls_back_to_the_switch_form;pso_measurement_compiles_an_exact_synthetic_record)gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1,gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_3) fail identically on unmodifiedmain1a0bbe3on this GPU (seeds 722 and 1599).cargo test -p xcl --lib released_queue_address_rewaits_on_reuse: 1 passed, 0 failedRegression run
main:
this PR:
Not tested
AI use
main1a0bbe3(a conflict incrates/xcl/src/hle/d3d12x/vram.rs: main rewrotebefore_execute; this PR'srecord_waitnow sits in main's version, andforget_queuefollows it) and reran the suite and smoke runs above.Imported from ivall/xcl. Originally posted by upipibi on 2026-11-24T22:51:42Z.
An interaction to watch, from reading the diffs (not run). This PR, #1819 (
cpu_writes::on_queue_release) and #1691 all changeq_releaseinreal.rs.On
main, a queue the title submitted to rarely reachesn == 0:presentkeeps a reference to every such queue (#1668). #1691 (head81f6397) fixes that with a second path,n == 1 && present::forget_queue(this). That path drops the tracking reference and, when the count then reaches 0, callslist_x::on_queue_releaseagain. With #1691 in, that second path is how a released queue normally goes.This PR adds
vram::forget_queueonly in the firstif n == 0branch, and #1819 does the same for its hook. Whichever of them merges after #1691 would leave the stalevram::Pages::waitedentry (or theFENCESworker) in place on that normal path. One way to keep the three independent: a singleon_queue_gone(this)that calls every per-queue cleanup, used in both placesnreaches 0.AI-assisted (Claude Code).
Imported from ivall/xcl. Originally posted by Melow-code on 2026-11-24T23:10:36Z.
Review: COMMENTED
The stale waited entry is a real bug — a reused COM pointer skipping a tile-mapping wait could corrupt GPU memory. Check how this interacts with #1691 and #1819 in q_release, since both touch the same cleanup path.
Imported from ivall/xcl. Originally posted by frenziedcoder on 2026-11-24T23:21:13Z.
NVIDIA test report for
7b493f3: no new test failures (the 4 that fail also fail on689f2db), its own testreleased_queue_address_rewaits_on_reusepasses, and a clean smoke pair on the retail title (1654 vs 1657 frames).Tested
stable-x86_64-pc-windows-msvc, DXC 1.8.2502.11 (SDK 10.0.26100.0). Exact head7b493f354667e57b5cd765f7dda4795d48118b34, no local changes.cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4(debug): 972 passed, 4 failed, 45 ignored; the PR's own testreleased_queue_address_rewaits_on_reusepasses. SKIPPED:gpu::recomp::lower::tests::a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu(no wave64),gpu::recomp::lower::tests::coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu(no wave64),gpu::recomp::lower::tests::cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu(no wave64),gpu::recomp::lower::tests::the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu(no wave64),gpu::recomp::lower_dxil::tests::a_per_lane_2d_or_3d_group_runs_on_the_gpu(no wave64),gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu(f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))),gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu(f16 arithmetic, wave64: no wave64),gpu::recomp::lower_dxil::tests::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))),gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu(f16 packed, wave64: no wave64),gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu(f32 arithmetic, wave64: no wave64),gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu(f32 compares, wave64: no wave64),gpu::recomp::lower_dxil::tests::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))),gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu(f32 conversions, wave64: no wave64),gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu(f32 rounding, wave64: no wave64),gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu(f32 three-source, wave64: no wave64),gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu(f32 transcendentals, wave64: no wave64),gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu(f64, wave64: no wave64),gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu(integer arithmetic, wave64: no wave64),gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu(integer carries, wave64: no wave64),gpu_geometry_wave32_prefix_count_over_a_mask(no wave64),gpu_wave32_program_in_wave64_hardware(no wave64),heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).fuzz_validate_and_gpu_0,fuzz_validate_and_gpu_1,fuzz_validate_and_gpu_2,fuzz_validate_and_gpu_3ingpu::dxil::fuzz_tests. They fail the same way on the base689f2dbhere (0x8007000EfromCreateComputePipelineStateon seeds 70, 545, 1019 and 1507, the NVIDIA refusal @PHeitor1 reported on #1679), so this PR adds no failure.test_title_draws_with_a_root_signature_under_the_debug_layerreports ok, but this machine has no D3D12 debug layer (debug layer requested but unavailable … (0x887A002D)), so it ran without the layer and is no evidence either way.Regression run (
scripts/smoke.ps1 -Seconds 60, release, the retail title of #505 at its start screen;XCL_PSO_PRELOAD=0for both builds, because this machine's preload list holds the program of #1307)base (
689f2db, this PR's merge base withmain):this PR:
Not tested: the world load (the smoke runs stop at the start screen, so code that only runs later is not exercised there); AMD.
AI use: Claude Code (Claude Opus 5.5) built and ran the tests and smoke runs on my machine and wrote this report; I checked it.
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T02:07:15Z.
Verification on RTX 3060 Ti (Windows 11): merge conflict with current
mainincrates/xcl/src/hle/d3d12x/vram.rs— needs a rebase before it can be tested.Imported from ivall/xcl. Originally posted by JJAutoCompare on 2026-11-25T04:14:56Z.
XCL PR #1899 verification
Clean head
9c336500ee42c43197d6c7ec86cdeddaf169539don STOR-WINLAB. Windows 11 Enterprise Evaluation x64 (build 26200), Ryzen 7 3800X, Intel Arc A770 (driver 32.0.101.9175), DXC 1.9.2609.5, rustc 1.100.0 (0ef1bc386, x86_64-pc-windows-msvc). Debug/test profiles with debug info and incremental compilation disabled.Tested
cargo build --workspaceandcargo test --workspace --no-runboth succeeded outside the GPU mutex. Cargo built 19 test binaries.cargo test -p xcl --lib hle::d3d12x::vram::tests::released_queue_address_rewaits_on_reuse -- --exactwithXCL_ADAPTER=NONE_CPU_ONLYoutside the mutex yielded 1 passed, 0 failed, 0 ignored, 0 skips. The unit test verifies that a duplicate fence wait is suppressed, forgetting a released queue lets the same address request that wait again, and an advancing fence requests a new wait. The diff touches onlycrates/xcl/src/hle/d3d12x/{real,vram}.rs.cargo test --workspace --no-fail-fast -- --test-threads=4ran once underInvoke-ArcTest.ps1withXCL_ADAPTER=A770andRUST_TEST_NOCAPTURE=1. Cargo exited 101. Summing all 20test result:lines inpr1899-suite.log(19 binaries and one doc-test harness) yielded 1,110 reported passed, 28 failed and 46 ignored. The queue regression also passed in this run.Workspace failures and skips
xcllibrary had 27 GPU shader failures, includingCreateComputePipelineStateerrors (0x80070057) and shader result mismatches. Thee2etarget had one failure intest_title_runs_and_game_folder_is_untouched. ItsRSSetDepthBiasXcheck observed a blue pixel where it expected green.SKIPPED. They give no coverage for the skipped cases. Reasons include missing wave64 and D3D12 debug-layer support, per-lane forms refused by the recompiler, tiled-resource tier limits, unavailable heap windows, and inability to disable the driver cache.Not tested
Matched
mainbaseline, retail-title smoke run, other GPUs, sample-dependent paths (XCL_SAMPLE_*unset), and actual D3D12 queue address reuse.AI use
T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high) ran the build and verification. Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against
pr1899-suite.logand published.Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-25T09:38:14Z.
Recheck on the rebased 11fea40
Same Windows 11 build 26300, RTX 3080 Ti (621.35), Ryzen 7 9800X3D and Rust 1.99.1 MSVC. The clean
cargo build --offline --locked --workspacepassed.cargo test --offline --locked --workspace --no-fail-fast -- --test-threads=4 --nocapturereported 1251 passed, 0 failed, 46 ignored. Cargo's passed count includes 25 runtime skips. The stock address-reuse test passed.I reran the same synthetic two-queue fixture separately with the D3D12 debug layer enabled. It passed with zero skips. Nonfinal release kept both records, and final release cleared only the releasing queue's record. Removing only the hook left both records and failed the same assertion. The debug layer printed live-object warnings at process exit. This fixture covers queue release and cache cleanup. It does not test a recycled native pointer with tile mappings still in flight or a retail run.
AI-assisted. Codex (GPT-6, exact variant unavailable) ran the recheck and drafted this update.
Earlier verification
Independent Windows run on 9c33650. Windows 11 build 26300, Ryzen 7 9800X3D, RTX 3080 Ti (621.35), Rust 1.99.1 MSVC, DXC 1.8.2502.11.
The clean
cargo build --workspace --offline --locked -j 4passed.cargo test --workspace --offline --locked --no-fail-fast -j 4 -- --nocapture --test-threads=4finished with 1138 passed, 0 failed, 46 ignored. Cargo’s pass count includes 25 runtime skips (20 native wave64, three unsupported per-lane forms, one unavailable driver-cache control and one no heap windows). The stock address-reuse test passed.A scratch test used two real D3D12 queues on the same device. Both completed native waits on the mapping fence. Dropping a nonfinal reference preserved both wait records. Final release removed only the matching record, leaving the other queue’s record intact until its own final release. Omitting only the new cleanup call left the first queue’s stale record and failed the test. The focused filter
local_native_queue_final_release_forgets_only_its_own_waitpassed with the D3D12 debug layer enabled and no skips.The fixture covers native release without submission tracking. I also checked the exact #1691 and #1819 heads separately with
git merge-tree. Each conflicts with this head inreal.rs.I combined the three exact heads locally on 568e7db by sending both final-release paths through the same cleanup block. The same workspace build and test commands passed on the integration with 1159 passed, 0 failed, 46 ignored, including 25 runtime skips in Cargo’s pass count.
With the D3D12 debug layer enabled,
cargo test --offline --locked -j 4 -p xcl --lib local_combined_queue_cleanup_covers_both_final_release_paths -- --nocapture --test-threads=1passed 1 of 1 without skips. Using three native queues, the fixture verified that both final-release paths remove the tile-mapping wait record and CPU write worker. Intermediate releases preserved both records, and the third queue kept its records until its own final release. When cleanup was omitted only on the path where the tracking reference is the last one, both records remained and the test failed at that assertion. The fixture registered the queue with submission tracking directly. Coverage was sequential and synthetic.AI use: Codex (GPT-6, exact variant unspecified) prepared the scratch test, ran the checks and drafted this report.
Imported from ivall/xcl. Originally posted by emirduran707 on 2026-11-25T13:20:35Z.
Thanks for pointing this out. Agreed: with #1691 in, the
n == 1 && present::forget_queue(this)path is how a released queue normally reaches 0, sovram::forget_queuehas to run there too. Whichever of this PR and #1691 merges second, I will rebase this one so both places where the count reaches 0 go through the same cleanup (a single per-queue "gone" helper, as you suggest), and add a test for the second path. Until one of them merges I am leaving the head as it is, so the reports above stay valid for it.AI use: Antigravity with Claude Opus 5.5 drafted this reply.
Imported from ivall/xcl. Originally posted by oni-swr on 2026-11-25T19:44:33Z.
AMD RX 7800 XT test report
Tested locally by merging PR head
11fea400cd87edf8f562e359e1451d221f08183conto basemain3f2777019544c0ada2cd294aa792d3c378ff0df8(no push). The base is an ancestor of currentmainand both trees merge cleanly.Hardware and tools: AMD Radeon RX 7800 XT, driver 32.0.31035.1003; Windows 10 Pro; Rust 1.100.0 / Cargo 1.100.0; DXC 1.8.2502.11 (DXIL 1.8.2502.11). Debug test build.
cargo test --workspace --no-fail-fast -- --test-threads=4: 1,356 passed, 2 failed, 46 ignored. There were 7SKIPPEDreports: six GPU cases (wave32/wave64 variants for three unsupported instruction forms) and one heap-window case. The two failures and all 7SKIPPEDreports match the baseline (1,355 passed, 2 failed, 46 ignored).Not tested
AI use
Codex (gpt-6-luna) ran Phase 2 tests and wrote this report (Phase 1 pre-compile / initial baseline run used Claude Code (Claude Sonnet 5.5)).
Imported from ivall/xcl. Originally posted by bmjask on 2026-11-25T21:25:48Z.
Review: COMMENTED
No concrete source defect found. q_release forgets queue only at refcount zero, and per-device clearing prevents reused raw queue address from suppressing required tile-mapping waits; current CI/smoke are green. Nonblocking gap: test covers FenceWaits directly rather than hooked q_release -> forget_queue -> before_execute with an address-reused queue. An integration seam would strengthen it, but I found no blocker.
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-26T00:34:53Z.
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 ClosetPie107 on 2026-11-26T06:49:01Z.
AMD RDNA4 / Linux (Proton Experimental) test report on head
11fea400(merged cleanly ontomainb49be183):Hardware & environment
experimental-11.0-20261112),vkd3d-protonmasterec207194(3.2.0) +dxil-spirvb540c8a2+ relaxed-vtable patch (-Db_ndebug=true), DXVKv3.1.1-209, DXC1.9.2609.5, Rustx86_64-pc-windows-gnuIsolated unit tests (
mainb49be183+ #189911fea400, debug,--test-threads=1,WINEDLLOVERRIDES="d3d12,d3d12core=n"):xcl.exe hle::d3d12x::vram:: -- --test-threads=1: 20 passed, 0 failed, 1 ignored (0 skipped).Combined 300 s retail sanity run (release,
mainb49be183+ #1540 + #1675 + #1844 + #1899 + #2123 + #2369 + #2422, retail 1.0.2.1 pressingApast menus):exit=0), 0 crashes, 0 device removals,2,014PresentXframes,131,072translated draws,660,943dispatches (44,546chained split-compute dispatches),102,631Opus packets (0 errors).Not tested
AI use
main, ran the Proton unit tests and combined retail run on this machine, and drafted this report.Imported from ivall/xcl. Originally posted by throny on 2026-11-27T20:32:27Z.
merge-check claim
head:
11fea400cdImported from ivall/xcl. Originally posted by throny on 2026-11-27T20:52:30Z.
merge-check
base:
6089122ahead:
11fea400cdmerge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 1466 passed, 0 failed, 47 ignored (26 SKIPPED lines); base alone: 1465 passed, 0 failed, 47 ignored
review: no blocker. Rare, for a follow-up: Pages::new runs under the PAGES lock, and if its fence creation fails the queue it just made is released on the same thread, which now reaches forget_queue and the same lock (needs device removal or out of memory). The test covers the wait table only and stays green without the forget_queue call. From the thread: the fix rarely triggers until #1691 lands, because the presenter keeps a reference to submitted queues (not verified here).
performance: one lock per final queue release (reasoned).
verdict: safe to merge
hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300, Rust 1.100.0, debug. Claude Code; merge, build and suite run by Claude Fable 5.2, diff review by Claude Opus 5.5 (every hunk read; nothing run on the GPU beyond the suite).
Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-28T00:18:52Z.
merge-check claim
head:
11fea400cdImported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-28T01:10:55Z.
merge-check
base:
2c717a043chead:
11fea400cdmerge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 1467 passed, 0 failed, 47 ignored, 25 SKIPPED: 21 no wave64, 3 per-lane f16/f32 forms refused (#1426 semantics), 1 no heap windows; failing: none. The suite ran on this PC at the same time as 5 other PRs' suites, in one queued job.
review: none. Whole diff read (real.rs q_release, vram.rs FenceWaits / before_execute / forget_queue + 1 test). A released queue's last waited tile-mapping fence value is forgotten, so a new queue at the same address waits for the mappings again; before_execute waits exactly as before.
performance: reasoned, not measured: same work in before_execute; one PAGES lock per final queue release.
verdict: safe to merge
hardware / tool and model: Windows 11 build 26300.9974, NVIDIA GeForce RTX 2070 SUPER 8 GB (driver 621.40, wave32 only), AMD Ryzen 5 3600XT; rustc 1.100.1 (20ddd0171 2026-11-25) x86_64-pc-windows-msvc, debug test profile; trial merge ff89dcef073f6702b8d9a02150245215b348655d (local, not pushed). Claude Code: Claude Opus 5.5 (coordination, full-diff review, draft).
Imported from ivall/xcl. Originally posted by Melow-code on 2026-11-28T14:06:50Z.
I found a possible address-reuse window in
11fea400. Inq_release, nativeReleasecan return zero beforelist_x::on_queue_releaseandvram::forget_queuerun. A new queue at that address can then reachbefore_executewhileFenceWaitsstill has the old entry.Tested on an RTX 3070, NVIDIA driver 610.88, Windows build 26100. I created a DIRECT queue, enqueued
Wait(fence, 1)on a fence at zero, and released the queue's sole COM reference.Releasereturned zero. The next queue on the same device reused the exact COM address in all three runs whileGetCompletedValue()was still zero. A watchdog signaled the fence for cleanup. The probe did not load a title or XCL hooks.In a separate test of the unchanged
FenceWaits,record(5),forget, thenrecord(5)returnsSome(5)for the new queue. If the secondrecord(5)runs beforeforget, it returnsNone. This covers the tracker interleaving and confirms the hardware premise separately. I did not observe an end-to-end XCL tile-mapping failure.Could the wait cache be keyed by a queue identity assigned before the queue is exposed, with cleanup removing only that identity?
AI use: Codex (GPT-6.2 Sol) reviewed the source, ran both probes, and drafted this comment.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T07:04:08Z.
Triage (#1607) – head
11fea40Main already does this:
vram::forget_queue(commit4a4c5f7b, "D3D12.X: invalidate retired queue address caches", merged with #2959) callspages.waited.remove(&queue)for every device, andpresent::invalidate_queue_cachesruns it when the queue-retirement worker retires a released queue (q_release->retire_released_queue). This PR'sforget_queueand theFenceWaitswrapper would duplicate it, and the branch no longer merges.Recommendation: close (superseded by main commit
4a4c5f7b).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:49:45Z.
Closing as superseded: this change is already on
main(4a4c5f7b). main4a4c5f7bvram::forget_queue (called from present.rs retire) does pages.waited.remove(&queue); same fix as this PR's forget_queue/FenceWaits.forgetTwo 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