D3D12.X: fence-quarantine released shared descriptor ranges #2782
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!2782
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2782"
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?
@itsSio on GitHub · 2026-11-26 12:23 UTC · original
itsSio:d3d12x/nvidia-dev-console-heap-quarantine→nvidia-dev· +520 −34 · 1 files · 1 commits · openOn
nvidia-dev,release_globalimmediately overwrote freed shared view ranges withfill_nulls, clearedNAMES, and returned them toGLOBAL.free, whilerelease_global_samplerreturned freed sampler ranges straight toGLOBAL_SAMPLER.freewithout coalescing or waiting for the GPU. Any in-flight command list still reading those shader-visible descriptor slots could observe nulled or overwritten descriptors.This change quarantines released shared view and sampler ranges behind per-queue completion fences across all live device queues (signaled outside
SLOT_WRITES,HEAPS,GLOBAL, andGLOBAL_SAMPLERlocks, preserving lock order). ForGLOBAL,fill_nullsandNAMES.clearare deferred until every signaled queue passes its fence mark when draining completed ranges back intofree.drain_global_retiredis serialized underGLOBAL_DRAIN(GLOBAL_DRAIN -> SLOT_WRITES -> GLOBAL, never held alongsideHEAPS), keepsGLOBAL_RETIREDset untilmerge_releasefinishes, and bumpsGLOBAL_DRAIN_SEQunderGLOBALon each merge (checked afterGLOBAL_RETIREDinslot()) so a concurrentslot()or second drainer cannot miss descriptors mid-drain and return an unmapped index. Zero-queue unit tests release immediately, and failed fence signals keep ranges safely quarantined without blocking later healthy ranges.What is in it
D3D12.X: fence-quarantine released shared descriptor ranges(9ddd2feb):crates/xcl/src/hle/d3d12x/console_heap.rs(per-queue fence quarantine forGLOBALandGLOBAL_SAMPLER, batched release on heap unregister, serialized deferredfill_nulls+NAMES.cleardrain underGLOBAL_DRAINwithGLOBAL_DRAIN_SEQsynchronization forslot(), coalesced sampler free list, and unit tests for multi-queue quarantine, coalescing, deferred view null-fill, mid-drain concurrentslot()and second-drainer waiting, zero-queue immediate release, and failed fence signals)Tested
Commit
9ddd2feb57a2e1bee79d387c5a3cf057798eed47(based onnvidia-devaf2cecc40886a8682ecf3267f5328c6dc4b66ad7, clean worktree).32.0.16.1088), AMD Ryzen 7 9800X3D, 32 GB RAM, Windows 11 Pro build 26200,rustc 1.97.0(stable-x86_64-pc-windows-msvc), DXC1.9.2609.5,XCL_ADAPTER=NVIDIA.9ddd2feb:cargo test -p xcl --lib console_heap -- --test-threads=4(debug): 22 passed, 0 failed (slot_waits_for_in_flight_drain_before_returning_unmappedpassed);cargo test --release -p xcl --lib console_heap -- --test-threads=4: 22 passed, 0 failed.9ddd2feb:cargo build --release -p xcl(exit 0) + 60 s retailscripts/smoke.ps1(XCL_PREPARE=0, RTX 5080):1640frames,15757MB peak commit,0removals,0crashes.b7552237(debug,cargo test --workspace --no-fail-fast -- --test-threads=4): 1749 passed, 7 failed, 48 ignored,27 SKIPPED(6 failures reproduce on unmodifiednvidia-devaf2cecc4:texture_upload::tests×2,d3d12_mesh_stream,gpu_compute_e2e,gpu_two_pass_cache_e2e×2; the 7th was intermittente2eNVIDIAumdlogs, which passed4/0/0×3 standalone on bothaf2cecc4andb7552237).32.0.16.1088), AMD Ryzen 5 5600X, 16 GB RAM, Windows 11 Pro build 26200,rustc 1.99.1(stable-x86_64-pc-windows-msvc), Windows SDK 10.0.26100 DXC1.8.2502.11,XCL_ADAPTER=NVIDIA.console_heap.rsdiff immediately before squashing to9ddd2feb:cargo test -p xcl --lib console_heap -- --test-threads=4(debug): 22 passed, 0 failed;cargo test --release -p xcl --lib console_heap -- --test-threads=4: 22 passed, 0 failed.b7552237(debug,cargo test --workspace --no-fail-fast -- --test-threads=4 --nocapture): 1749 passed, 7 failed, 48 ignored,30 SKIPPED(same 6 pre-existingaf2cecc4failures plus unrelated parallel flakegamesave::tests::atomic_writes_preserve_xcltmp_blobs_and_skip_leftover_temps, which passed3/3standalone on bothb7552237andaf2cecc4).Regression run
main(b49be183, RTX 5080, release):PR (
9ddd2feb, RTX 5080, release,XCL_PREPARE=0):Not tested
9ddd2febafter theconsole_heap.rs-only concurrency fix (covered by debug + releaseconsole_heaptests on both PCs and the fresh RTX 5080 smoke on9ddd2feb).scripts/smoke.ps1on the RTX 2080 SUPER.nvidia-dev(the 60 s smoke verifies stability and memory parity).AI use
Ran via Samaritan:
b7552237, and performed the independent read-only concurrency audit of thedrain_global_retiredfix (catching a check-order race inslot()and confirming PASS after the fix).b7552237.GLOBAL_DRAIN/GLOBAL_DRAIN_SEQfix and deterministic concurrency test for@KDenKC's review, ran the dual-PCconsole_heapdebug/release checks and fresh RTX 5080 smoke on9ddd2feb, ranscripts/pr_check.py --local, updated this description, and pushed9ddd2feb.@KDenKC on GitHub · 2026-11-26 12:37 UTC · original
Source review of
b7552237, no run. One window indrain_global_retired(console_heap.rs~584-617):The ready ranges are popped from
s.retiredandGLOBAL_RETIREDis stored as!s.retired.is_empty()underGLOBAL. ThenGLOBALis dropped whilefill_nullsruns underSLOT_WRITES, and only afterwards are the ranges merged intos.free. In between, those ranges are neither retired nor free, and the flag can already readfalse. A concurrentslot()on a hosted heap with no page (~852) checksGLOBAL_RETIRED, seesfalse, skips the drain, and returnsfinish_view_slot(h, k, None): the unmapped index. The same happens to a second caller that entersdrain_global_retiredduring the first one'sfill_nulls. So when the shared heap is exhausted, a view can get the null slot even though descriptors are about to be free.Keeping the flag (or a small "draining" count) set until the merge is done, or having a caller that sees the flag drop wait on the drain in progress, would close it.
Not tested: no build or run on our side.
AI use: Gemini (Antigravity) found it in a review. Claude Code (Claude Opus 5.5) checked it against the source at
b7552237and wrote this.@DarkPanda69 on GitHub · 2026-11-26 13:36 UTC · original · edited 2026-11-26 14:55 UTC
Update for head
9ddd2fe: same result. Onnvidia-devaf2cecc,console_heapgives 22 passed, 0 failed, 0 SKIPPED with this PR (19 without),slot_waits_for_in_flight_drain_before_returning_unmappedamong them. As below, these tests run on the default adapter, the RX 9070 XT.AMD run (listed as untested): the new tests pass on an RX 9070 XT.
Base
nvidia-devaf2cecc, then headb755223applied, debug, Windows 11 Pro 26200,cargo test -p xcl --lib -- console_heap --nocapture --test-threads=4:nvidia-dev: 19 passed, 0 failed.released_shared_ranges_stay_quarantined_until_queue_completesandretired_descriptor_ranges_stay_quarantined_until_all_queues_completeare among them.The new tests make their device with
create_device(None, ..), so they ran on the default adapter, which is the RX 9070 XT (RDNA4, driver 32.0.32029.2010) on this machine. A run withXCL_ADAPTER=3060gave the same counts, but it does not move these tests to the RTX 3060, so it is not an NVIDIA result for them.Not tested: native wave64 GPU tests (this change is in
console_heap.rs), Intel, Linux / Wine, a title.AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.
b755223752to9ddd2feb57@itsSio on GitHub · 2026-11-26 14:39 UTC · original
Thanks for catching that window, @KDenKC — squashed the fix into
9ddd2feb(crates/xcl/src/hle/d3d12x/console_heap.rs) and refreshed the PR description and smoke run:drain_global_retiredunderGLOBAL_DRAIN(GLOBAL_DRAIN -> SLOT_WRITES -> GLOBAL, never held alongsideHEAPS) and keptGLOBAL_RETIREDset acrossfill_nullsuntilmerge_releasefinishes.GLOBAL_DRAIN_SEQ(incremented underGLOBALon everymerge_release, read in reverseAcquireorder afterGLOBAL_RETIREDinslot()) so neither a concurrentslot()nor a second drainer can observeGLOBAL_RETIRED == falsewhile descriptors are still mid-drain and return an unmapped slot.slot_waits_for_in_flight_drain_before_returning_unmappedcovering both a concurrentslot()and a seconddrain_global_retiredentering mid-fill_nulls.Tested
32.0.16.1088, Ryzen 7 9800X3D, Win11 26200,rustc 1.97.0, DXC1.9.2609.5,9ddd2feb):cargo test -p xcl --lib console_heap -- --test-threads=422 passed, 0 failed (debug and release); fresh 60 s RTX 5080 release smoke (XCL_PREPARE=0):1640frames,15757MB peak commit,0removals,0crashes.32.0.16.1088, Ryzen 5 5600X, Win11 26200,rustc 1.99.1, DXC1.8.2502.11, identicalconsole_heap.rsbytes prior to squash):cargo test -p xcl --lib console_heap -- --test-threads=422 passed, 0 failed (debug and release).Not tested
9ddd2feb.AI use
Ran via Samaritan:
console_heapchecks and RTX 5080 smoke, pushed9ddd2feb, and wrote this reply.slot()and verifying PASS after the fix).@Prime1997 on GitHub · 2026-11-26 15:20 UTC · original · reviewed
Updated source status: retain; validation pending. Rechecked current head
9ddd2feb57a2e1bee79d387c5a3cf057798eed47against the previously reviewedb755223752d79186a0aca209a3c86641c18a7eed, targetingnvidia-devataf2cecc40886a8682ecf3267f5328c6dc4b66ad7.The new revision directly addresses the earlier retired/free publication gap:
GLOBAL_DRAINserializes draining through null-fill and free-range publication,GLOBAL_RETIREDstays set during that interval, andGLOBAL_DRAIN_SEQlets an exhausted allocation observe a completed concurrent drain and retry. The fallback dropsHEAPSbefore waiting on the drain and reacquires/re-finds the heap afterward. The previous exact-head finding should not be treated as an unchanged defect or a reason to close this revision.I inspected the full175-line delta and the surrounding allocation path. The added child-isolated fixture exercises an in-flight drain and the sequence-observation helper with owned fake COM objects. I have not built or run this new head, the new fixture, or a GPU lifetime workload. Its80ms sleep also should not be presented as proof of every scheduling interleaving. The earlier native results for other PRs do not transfer to this revision.
Disposition is blocked on current-head validation and the remaining integration checks, rather than rejection. No merge or closure is made by this report.
AI use: Codex (GPT-6) inspected the revision and relevant call path; no new execution is claimed. Optional temporary Discord for coordinating contributor work, testing and comparing results.
@SlopTart on GitHub · 2026-11-26 15:26 UTC · original
Two Linux/Wine lanes on head
9ddd2feb(basenvidia-devaf2cecc4), both lanes have same-day base numbers from the exact base commit, so the diffs below are head-vs-base on identical machines.Lanes
xvfbBoth:
cargo test --release --locked -p xcl --lib --target x86_64-pc-windows-gnu -- --test-threads=2 --skip gpu::, full wine env per lane (runner: Proton wine //usr/bin/wine,WINEDLLOVERRIDES="d3d12,d3d12core,dxgi,d3d11,d3d10core=n,b",VKD3D_CONFIG=ignore_shared_fence,XCL_DXC_DIRset).af2cecc49ddd2febconsole_heaptests), red set identicalAll 22
console_heaptests green on both lanes, includingslot_waits_for_in_flight_drain_before_returning_unmapped, matching @DarkPanda69's 22 on RDNA4. Contention probe for the window @KDenKC raised (drain vs concurrentslot()): the whole module re-run 3 times with--test-threads=8per lane, 6 of 6 runs 22 passed, 0 failed on both vendors.Not cleared by this PR (expected, different code path): the two
real::descriptor_heap_testsreds on the Pascal lane (a_copy_of_a_destroyed_resources_view_is_the_null_view,zero_sampler...) are unchanged by head9ddd2feb. The first of those is Wine-specific (red on both Wine lanes, green on Windows per #2688 thread); the second is only red on this Pascal/wine-10 box.Tested: head + base full lib suite and
console_heapstress on both Linux/Wine lanes, release. Not tested: Windows, native Linux, in-game.AI use: Hermes agent (local Qwen-class) ran the tests and drafted this; I checked it before posting.
@throny on GitHub · 2026-11-26 15:35 UTC · original
Test report: in the world on an RTX 4080 16 GB. No harm seen; it does not change this card's device losses.
Tested
git apply, both as they are) onnvidia-devaf2cecc4+ #684 + #2697 + #2749 + #2729 + #2794 + the two-pass stack #2817. The retail title of #505, Series X profile, world from about 170 s; the card is 2.5 GB over its video memory budget there.0x887a0005, nonvlddmkmevent)0xc0000005in title code) after 297 s and 226 s, 1 ended by my guardNot tested
AI use: Claude Code (Claude Fable 5.2) ran this on the owner's machine and wrote the report.
@nnonno91 on GitHub · 2026-11-26 15:44 UTC · original
Two real D3D12 queues on RTX 5090 and Radeon RDNA2 iGPU. On PR head
9ddd2feb57a2e1bee79d387c5a3cf057798eed47(nvidia-devparentaf2cecc40886a8682ecf3267f5328c6dc4b66ad7), the stockhle::d3d12x::console_heap::testssuite passed 21/21 in a debug build with four test threads andXCL_HEAP_WINDOWS=1.I then extended
released_shared_ranges_stay_quarantined_until_queue_completeslocally with test-only changes. The fixture selects and prints the DXGI adapter and registers a real DIRECT queue and a real COMPUTE queue on that device. Both wait on independently controlled D3D12 fences. I verified two retirement marks on each released range, then let the DIRECT queue finish and waited for its completion fence. The COMPUTE queue was still gated at that point.Windows 11 build 26200, Ryzen 7 9800X3D, 32 GB RAM, Rust 1.100.0. The extended fixture ran in fresh test processes with
XCL_HEAP_WINDOWS=1,XCL_TEST_SHARED_QUARANTINE_CHILD=1, and an explicit adapter. It checks fence ordering and descriptor reuse using real queues. Retail gameplay and runtime performance were outside this test.AI use — Codex ran the stock tests, extended the local fixture, and verified the adapter and fence checkpoints.
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.