D3D12.X: fail closed on heap retirement fences and sweep idle arenas without PAGES #2538
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!2538
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2538"
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?
@Decodere on GitHub · 2026-11-25 22:06 UTC · original
Decodere:fix-vram-retire-fail-closed-arenas→main· +162 −26 · 1 files · 1 commits · openPart of #1773
Part of #1585
Part of #1833
What is in it
Fixes three VRAM heap retirement and idle arena reclamation bugs in
crates/xcl/src/hle/d3d12x/vram.rs(without touchingArenas::take_for):CreateFence/Signalfailure inRetireQueue::retire_with: Previously, under VRAM/commit pressure, ifmake_fenceorsignalfailed on all live queues (withunmap_mark == None),retire_withsawmarks.is_empty()and returnedheapsimmediately to drop while live queues were still using them; if it failed on 1 of N live queues, that queue was omitted sosweep_withdropped the heaps as soon as the remaining queues finished.RetiringBatch::marksis nowOption<Vec<(F, u64)>>(None= unarmed),RetireQueue::capture_marksreturnsNoneif ANY queue failsmake_fenceorsignal(preserving monotonic*v += 1on any already-signaled queue), andretire_withreturnsheapsimmediately ONLY whenqueues.is_empty() && unmap_mark.is_none(). AddedRetireQueue::retry_unarmed_with(invoked inretire_heaps_and_sweepbeforeretire_with/sweep_with) so transiently-unarmed batches capture one shared set of fresh marks across all live queues and recover without head-of-line blocking armed ready batches.u64::MAXdevice-removed sentinel inRetireQueue::sweep_with: Added pure helperfence_reached(completed, target)(completed != u64::MAX && completed >= target) and applied it tounmap_mark,b.marks, and dead-queue fence pruning soID3D12Fence::GetCompletedValue() == u64::MAXon device removal never falsely reaps pending batches or prunes fences.before_executewhenPAGEShas no activeSome(Pages)entry for the device: Added per-devicelast_sweep: Vec<(usize, Instant)>,record_sweep, andsweep_dropped_for_if_due(1 s interval, pruninglast_sweepwhen no arenas remain fordev) toArenas<H>, plusstatic ARENA_COUNT: AtomicUsizesynchronized toarenas.list.len()on everyARENASlist mutation (place,before_execute). Whendo_reclaimis false andARENA_COUNT > 0(e.g.XCL_VRAM_ARENAS=1or devices with only non-tiled D32S8/MSAA arenas),before_executerunssweep_dropped_for_if_dueand retires reclaimed heaps throughretire_heaps_and_sweep, keeping a zero-lock fast path whenARENA_COUNT == 0.hle::d3d12x::vram::tests, pure CPU,0skips):retire_queue_fails_closed_on_fence_or_signal_failure_and_recoversretire_queue_rejects_device_removed_sentinelarenas_sweep_dropped_for_if_due_reclaims_without_pagesTested
origin/main(e1d84b7d9153f86a97d2ec5d209d196046fc0bea) with theRetireQueuetests:retire_queue_fails_closed_on_fence_or_signal_failure_and_recoverspanicked atvram.rs:1703:all-fail must hold heaps.retire_queue_rejects_device_removed_sentinelpanicked atvram.rs:1719:u64::MAX sentinel must neither reap nor prune.0compiler warnings invram.rs):cargo test --release -p xcl --lib hle::d3d12x::vram::tests -- --test-threads=1 --nocapture:22 passed; 0 failed; 1 ignored(churn_update_tile_mappings_timing),0skipped (all 3 new pure-CPU tests plusgpu_retire_queue_holds_heap_until_blocked_queue_passes_mark,d32s8_targets_take_their_own_size_of_video_memory, andreservable_agrees_with_the_driverpassed).XCL_ADAPTER=warp):cargo test --release -p xcl --lib hle::d3d12x::vram::tests -- --test-threads=1 --nocapture:22 passed; 0 failed; 1 ignored,0skipped.cargo test --release --workspace --no-fail-fast -- --test-threads=4 --nocapture):37test binaries:1426 passed; 0 failed; 46 ignored.29pre-existing runtimeSKIPPEDmessages (21no wave64on wave32-only RTX 4060,3per-lane form: refused,3no D3D12 debug layer/no d3d12SDKLayers.dll,1cannot disable the driver cache,1no heap windows).Regression run
Before (
origin/maine1d84b7d9153f86a97d2ec5d209d196046fc0bea):After (
fix-vram-retire-fail-closed-arenas73ff10e9ba8c4e7d45362bb8637536b52aba1686):Both 60 s runs reach steady
60 60 60presents per 2 s with0device removals,0crashes,1542vs1508frames shown (102.3%), and14007 MBvs14016 MBpeak commit.Not tested
CreateFenceOOM orDXGI_ERROR_DEVICE_REMOVEDinjection on hardware (both failure paths are exercised deterministically in the pure-CPURetireQueueunit tests).d3d12SDKLayers.dllis not installed on this machine) and native wave64 GPU tests (RTX 4060 is wave32-only).AI use
Written and verified with Google Antigravity (Gemini 4 Neon). All code changes, failing-first reproductions, targeted RTX 4060 and WARP test runs, the full release workspace suite, and both paired 60 s GPU smoke runs were executed and checked locally.
@DavidM1911 on GitHub · 2026-11-25 22:17 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!
@emirduran707 on GitHub · 2026-11-25 22:24 UTC · original
Independent AMD RDNA4 (native wave64) test report on exact head
73ff10e9ba8c4e7d45362bb8637536b52aba1686(clean detached checkout, no local changes).Tested
stable-x86_64-pc-windows-msvc), DXC 1.9.2602.17; tests debug, smoke release.cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4: 1424 passed, 2 failed, 46 ignored; 8 SKIPPED (6 inlower_dxil::tests::{f16,f32}_programs_on_the_gpurefused by per-lane form;heap_window_out_of_memory_falls_back_to_the_switch_form;pso_measurement_compiles_an_exact_synthetic_record). All native wave64 GPU tests ran and passed.hle::d3d12x::vram::tests::retire_queue_fails_closed_on_fence_or_signal_failure_and_recoversandretire_queue_rejects_device_removed_sentinel.gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1seed 722 andfuzz_validate_and_gpu_3seed 1599) are pre-existing on unmodifiedmainon this GPU.Regression run (60 s retail-title smoke,
XCL_NETWORK=0, release)(Matched
main68a284abaseline on the same machine today: 1573 frames, 14420 MB peak, 0 device removals, 0 crashes.)Not tested
AI use
@SlopTart on GitHub · 2026-11-25 23:24 UTC · original
Tested: current PR head merged onto current
origin/main(clean), Linux (Arch, kernel 7.2.15), Mesa 26.2.5 RADV, Radeon RX 7900 XT (NAVI31), cargo targetx86_64-pc-windows-gnurun under wine-11.0 (Proton), rustc 1.94.0, vkd3d-proton 3.1 with the XCL patch, official MS DXC (binaries 2026-09-29).gpu_suite (cold cache): 165 passed / 3 failed, no crashes. The three are the known baseline on this lane (seed-1003 fuzz, mad/mac contraction, promoted-UAV-clear driver gap, PR #2490); none caused by this PR.Targeted run of
retire_queue_fails_closed_on_fence_or_signal_failure_and_recoversandretire_queue_rejects_device_removed_sentinel: 2 passed. The sentinel test is a failure-path unit test; it does not exercise a real device-lost event on this lane.Not tested: retail titles (no title data on this lane, counts only).
AI use: Hermes agent (local Qwen-class) ran both machines and drafted this; I checked it before posting.
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.