D3D12.X: flush pending tile mappings before submit and fix VRAM unmap/retire races #2981
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!2981
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2981"
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?
@Saksukella on GitHub · 2026-11-27 07:06 UTC · original
Saksukella:fix/vram-tile-map-sync-0x887a→amd-dev· +495 −22 · 3 files · 2 commits · openFixes four tile-mapping synchronization and VRAM retirement races that caused deterministic
DXGI_ERROR_DEVICE_HUNG(0x887A0006) GPU page faults during world streaming on AMD RDNA 4 (RX 9070 XT).Root causes & fixes (
real.rs,sparse.rs,vram.rs)record_deferredtile-mapping flush & wait (real.rs,sparse.rs,vram.rs):q_execute_command_listsflushedsparseandvramtile mappings viatitle_textures::refreshbeforelist_x::record_deferred, which can block for several milliseconds while compiling pipelines.UpdateTileMappingsor recycled-tile zero-fills queued on another thread during thatrecord_deferredwindow were never flushed or waited on beforeexecute_with_waits_on, letting active dispatches read pages whose tile mappings or GPU zero-fills were still in flight.sparse::wait_pending_mappings(q)andvram::wait_pending_mappings(q)right beforeexecute_with_waits_on(returns immediately with 0 signals / 0 waits when no concurrent thread dirtied mappings duringrecord_deferred).seal_and_drain_unmapsTOCTOU & missingflush_signal(vram.rs):seal_and_drain_unmapspreviously droppedPAGES.lock(), calledsignal_device_queues, re-acquired the lock, and only then calledstd::mem::take(&mut pages.unsealed_unmaps)— attaching concurrent unmaps pushed after the signal to stale fence marks soUpdateTileMappings(NULL)could unmap tiles while a newer title submit was still reading them.unsealed_unmapsbefore releasingPAGES.lock()(seal_snapshot_ops) and flushespages.flush_signal()wheneverpages.dirty_signalis true (coveringPendingUnmapOp::Tiles).recycle_readyunsignaled unmap (vram.rs):pages.flush_signal()immediately afterpages.unmap(res, info.total)before pushing the recycled resource back intoreserved_pool.zero_buflifetime (vram.rs):PoolHeaps::take_heapnow returns(ID3D12Heap, Option<ID3D12Resource>)and retires both insideRetiringHeap { _zero_buf, _heap }inRetireQueue(dropping_zero_bufbefore its backing_heap) instead of dropping the placed alias buffer underPAGES.lock()while still in flight.Tested
amd-dev(bf7c82ee+ebef6042,--test-threads=1, 0 new warnings):cargo test -p xcl --lib hle::d3d12x::vram -- --test-threads=1:36 passed; 0 failed; 1 ignored, including 3 new pure-CPU regression tests:seal_and_drain_unmaps_does_not_attach_stale_marks_to_concurrent_unmapswait_pending_mappings_flushes_post_refresh_dirty_signalretire_queue_keeps_zero_buf_alive_until_marks_completecargo test -p xcl --lib hle::d3d12x::sparse -- --test-threads=1:37 passed; 0 failed; 1 ignored73 passed; 0 failed; 2 ignored.XCL_DIRECT_DXIL=1 XCL_PER_LANE=1 XCL_RT_GATE=miss XCL_DRED=1 XCL_GPU_CULPRIT=1):71b8e6e0base): deterministic0x887A0006DRED page fault (VA 0x1c7103000) att=100.7swithvram pages queuework pending during arecord_deferredwindow.amd-dev(bf7c82ee+ebef6042): survived full 240.04 s (1,464frames,00x887A0006,00x887A0005,0DRED page faults,0crashes,0exceptions).Not tested
Regression run
Baseline (
main,b49be183):This PR (
ebef6042onamd-devbf7c82ee):AI use
@luckyteagirl on GitHub · 2026-11-27 07:16 UTC · original
Tested on unmodified PR head
ebef6042703497bf3ab66486bda939158c5850e0on Windows 11 Home 26200.9711, Ryzen 9 5980HX, integrated AMD Radeon Graphics and Radeon RX 6800M (driver 30.0.13002.13003), Rust 1.100.0 MSVC, debug. Both commands ran withXCL_ADAPTER=AMD Radeon RX 6800MandXCL_REQUIRE_GPU=1.cargo +1.100.0 test --offline --locked -p xcl --lib hle::d3d12x::vram -- --nocapture --test-threads=1— 36 passed, 0 failed, 1 ignored, 0 reported skips. All three new CPU regression tests passed. The small-texture fixture uses the named RX 6800M and verified pixel preservation across 512 BC1 textures, with 2 MiB of incremental allocation.cargo +1.100.0 test --offline --locked -p xcl --lib hle::d3d12x::sparse:: -- --nocapture --test-threads=1— 37 passed, 0 failed, 1 ignored, 0 reported skips.The blocked-queue retirement and sparse fixtures use the D3D12 default adapter, which I checked is the integrated Radeon on this machine.
Not tested — The full workspace suite, retail-title smoke, the streaming race on RX 6800M, or a comparison with upstream main.
AI use — Codex (GPT-6, exact variant unavailable) selected and ran the tests and wrote this report.
@bobosneefdev on GitHub · 2026-11-27 07:48 UTC · original
Tested (retail title, RX 6800): not the clean PR tree. This PR's three files (
ebef6042) merged over amd-devbf7c82eewith local changes: reverts of00fe5aecand287a931b, logging, and a local switch that compiles compute HLSL over 256 KB with-O0. Windows 11 Pro 26200, Radeon RX 6800 16 GB (driver 32.0.21045.29003), Ryzen 5 5600X3D, 64 GB, Rust 1.98.1 MSVC, release.xcl runof GTA 6 withXCL_PREPARE=0 XCL_RT_GATE=miss XCL_PSO_MAX_KB=1100 XCL_DRED=1 XCL_INDIRECT_PRELUDE=0, one run with the PR and four without, same build otherwise. "Tiles in sealed unmap batches" is the highest value of a local log line printed every 10 s.-O0over 1 MB)0x887a0007at 509 s0x887a0007at 301 sNone)0x887a0007at 287 s0x887a0007at 254 s0x887a0007at 264 spage fault at GPU VA 0x0; allocations there: []; recently freed: [], and every queue had moved within 500 ms. Runs 263 and 266 ended the same way without the PR, so it is a different cause from the tile backlog.Not tested: the clean PR head, the test suite on this tree,
scripts/smoke.ps1, more than one run with the PR, any other GPU.AI use: Claude Code with Claude Fable 5.2 ran the title, read the logs and wrote this report.
@SzczepanGrela on GitHub · 2026-11-27 07:50 UTC · original · edited 2026-11-27 09:16 UTC
Updated RX 9070 / Wine check on
ecbbf96a041089ce086d654d8b8502d29989f0cc, including the new shipped-helper tests. The comparison for this update is its actual parent/previous headebef6042703497bf3ab66486bda939158c5850e0; PR branch base remainsamd-devbf7c82ee1b2685bb40417e09c4128177aa68d719.RX 9070 16 GB (RADV GFX1201), Ryzen 7 7700, CachyOS kernel 7.3.6-1-cachyos, Mesa 26.3.1-5, GE-Proton11-12 / Wine 11.0 Staging, ntsync. Native vkd3d-proton
8293130ebe370b1+, local asserts-disabled build; Rust 1.97.1, Windows-GNU release. Private enabled caches per process.XCL_SPARSE_CPU_WAIT_MS=0,XCL_ZERO_TARGET_PAGES=1.Tested
The four new tests each passed in a separate fresh process (1 passed / 0 failed), then together at both
--test-threads=1and4(4 passed / 0 failed each), 0 ignored/skipped. Passive observations confirmed RX 9070 vendor/device1002:7550, LUID[0,1007]for every new test rather than relying on the default adapter selection.Under
hle::d3d12x::vram::tests:::seal_and_drain_unmaps_leaves_concurrent_unmap_unsealed: the production helper seals only the old0x1111entry, leaving the callback's new0x2222entry unsealed. This is the test's synchronous injected interleaving, not a CPU-thread stress run.vram_wait_pending_mappings_and_recycle_ready_flush_and_wait: the wait records fence value 1; recycling succeeds, advances the page fence from 1 to 2, clearsdirty_signaland parks one resource.pool_heaps_take_heap_keeps_zero_buf_alive_in_retire_queue: the actual placed zero-buffer COM refcount remains 2 while the retirement fence is 0, then falls to 1 after CPU-signaling fence 1 and dropping the retired item. This checks native COM retention; it does not submit GPU work using that alias.Also
hle::d3d12x::sparse::tests::sparse_wait_pending_mappings_flushes_queued_mapping:mapping_queuedclears, sparse fence value becomes 1 and the recorded queue wait matches it. This checks the queued flag/wait bookkeeping, not copied data in that test.--test-threads=1and4: 7 passed / 0 failed per invocation.18 processes total. Copied source trees, original assertions unchanged; only passive test observations and the local native fixture added.
The last filter is a local fixture using actual
Pagesmapping/zero-fill/signal operations and the VRAM late-wait helper, with native buffers and queues. It is not an upstream test.Earlier result retained: my original
ebef6042versusbf7c82eenative data comparison found 19 stale first readbacks on the pre-fix parent (311,296 wrong words), versus none onebef6042. That archived comparison remains separate; the current update compares two heads that already contain the fix.Not tested: full
q_execute_command_lists/record_deferredcaller, default CPU-wait route, real concurrent unmap stress, GPU use of the retiring zero-buffer alias, whole suite, title/smoke or performance. The new tests were run as shipped, with no reverse-mutation check here. Integration into main623d02e4conflicts in all three runtime files and was not built. No retail data used.AI use: OpenAI Codex (GPT-6; exact serving variant not exposed) reviewed both public revisions, added passive adapter/state observations, ran the new tests and native controls, independently checked the results, and updated this report. Publication authorized by the account owner.
@fromthemoonx on GitHub · 2026-11-27 08:25 UTC · original · edited 2026-11-27 10:13 UTC
Rerun on the new head
ecbbf96(adds tests only): the new tests now catch M1, but still not M2 (theRetiringHeapfield order) or M3 (thewait_pending_mappingscalls removed from submit).Same machine.
ecbbf96merges into currentamd-dev5fbd90fwithout conflicts. I did not rerun the full suite: the new commit changes tests only.hle::d3d12x::vram::(36 tests) andhle::d3d12x::sparse::(38),--test-threads=8, 30 runs eachseal_and_drain_unmaps_leaves_concurrent_unmap_unsealedfails 3 of 3 (concurrent unmap must stay unsealed for a fresh fence mark, left0, right1)_heapdeclared before_zero_buf)pool_heaps_take_heap_keeps_zero_buf_alive_in_retire_queuechecks thatzero_bufstays alive, not which field drops first. thehollowedone's generic-RetiringHeapdiff above does catch thiswait_pending_mappings(q)calls removed fromq_execute_command_lists)wait_pending_mappingsdirectly, so nothing checks that submit calls itNVIDIA run (listed under Not tested): no new failure compared with
amd-devitself (all 18 failures also fail there), and the e2e debug-layer messages are the same. But none of the three new tests covers the shipped code: each of the three fixes can be put back as it was and all tests still pass.Tested:
ebef604(its base is currentamd-devbf7c82e, so head = merged), andbf7c82eitself for comparison. RTX 3060 12 GB (driver 610.88), Ryzen 7 5700X, Windows 11 Pro 26300, Rust 1.100.0 MSVC, debug, Graphics Tools (D3D12 debug layer) installed.cargo test --workspace --no-fail-fast -- --test-threads=4,ebef604SKIPPEDlinesamd-devbf7c82eamd-devbf7c82e's runs, e.g. the 3e2etitle tests ([FAIL] … Write64BitValueTopOfPipeX: 0x0, on both),giant_driver_compiles_have_their_own_lane,title_bytes_are_used_in_place_when_all_are_readable,physical_home_without_sparse_windows_uses_coherent_window(3 of 3 alone on both). The 18th,compositor_releases_root_sig_and_rejects_invalid_planes(psos_for leaked root_sig COM refs, left2, right1), failed once on the PR, in that suite run, and passed in 3 more lib runs. It is flaky onbf7c82etoo: it failed 1 of 7 lib runs there with the same assertion (left3), and passes 3 of 3 alone on both.--test-threads=4: 1 suite run + 3 more runs eachthread 'xcl-pso-0' panicked at windows-core-0.62.2\src\interface.rs:41:18: null reference produced/non-unwinding panic. aborting.: 2 of 4 onbf7c82e(one more later run crashed with a segfault), 3 of 4 on the PR, so fromamd-dev, not this PRvramtests alone, 40 runs each;hle::d3d12x::vram::(33 tests) andhle::d3d12x::sparse::(37),--test-threads=8, 30 runs eachseal_and_drain_unmapsalso seals the unmaps pushed after the snapshot (as before the fix)vram::/sparse::passRetiringHeapdeclares_heapbefore_zero_buf(the heap drops first)wait_pending_mappings(q)calls removed fromq_execute_command_listse2etest_title_draws_with_a_root_signature_under_the_debug_layer, PR vsbf7c82eThe new tests run a copy of each fix rather than the code that ships:
seal_and_drain_unmaps_does_not_attach_stale_marks_to_concurrent_unmapsreplays the snapshot sequence by hand and callsseal_snapshot_ops, notseal_and_drain_unmaps.wait_pending_mappings_flushes_post_refresh_dirty_signalchecks theneeds_mapping_waitpredicate only.retire_queue_keeps_zero_buf_alive_until_marks_completeuses a test-onlyFakeRetiringHeap, so the drop order of the realRetiringHeapis not checked.If you want the field order guarded, a test on
RetiringHeapitself with stand-in fields would catch M2. Callingseal_and_drain_unmaps's two locked halves from a test would cover M1.Not tested: a title on NVIDIA with this branch, a release build, Intel, a long run.
AI use: Claude Code (Claude Opus 5.5) ran the tests and the scratch mutations and wrote this report.
@SlopTart on GitHub · 2026-11-27 08:28 UTC · original
Linux (Wine) run of #2981 on the NVIDIA+Wine lane: your fixes do not change this branch's behavior there - the suite still dies at the same place.
Boxb (i5-10600K, 16 GB DDR4, GTX 1070 8 GB, 550.163.01, Debian 13, wine-10.0, xvfb),
pr/2981headebef6042(amd-dev-based): the full suite died with the same red prefix and the same hard crash as plain amd-dev tipbf7c82eerun the same evening on the same machine:sm5_ambient_hlsl_shaders_compile_cleanly,gpu_two_pass_indirect_commands_keep_their_own_records,gpu_promoted_uav_clear_values_pass_create_committed_resource,a_put_off_dispatch_runs_at_the_submit_when_its_build_outlasts_the_wait_budget,bitset_runs_emit_exact_contiguous_page_ranges,write_buffer_immediate_on_open_existing_heap_visible_to_cpu,compositor_releases_root_sig_and_rejects_invalid_planes,a_dispatch_with_a_pipeline_still_building_waits_at_the_submitwine: Unhandled page fault on execute access to 00007FFFFE8A0428- suite does not complete (the older tipb5c0275fstill completed at 770/22 on this box, so the branch regressed on the NVIDIA+Wine lane independently of your change).Solo deadlock test at tip
bf7c82ee: FAILED 3/3 (~9.92 sdispatch 17 waited for the build,list_x.rs:8508:17) - your tile-flush work does not touch it. Details on the standing thread #2764.AMD+Wine lane (rig, RX 7900 XT, wine-11.0 Proton) cannot complete any recent amd-dev suite (dies partway), so no rig numbers for this one.
AI use: Hermes agent (local Qwen-class) ran the tests and drafted this; I checked it before posting.
@thehollowedone on GitHub · 2026-11-27 08:40 UTC · original
Follow-up to the independent NVIDIA mutation check: I verified a small way for the existing retirement test to guard the production type's field order, rather than a separate
FakeRetiringHeap.On #2981 head
ebef6042, I madeRetiringHeapgeneric with its current COM types as defaults, then instantiated that same type with drop trackers inretire_queue_keeps_zero_buf_alive_until_marks_complete. The production instantiations and drop order remain as shipped. On Windows 11 build 26300, RTX 3080 Ti (621.35), Ryzen 7 9800X3D, Rust 1.99.1 MSVC:cargo test --offline --locked -j 4 -p xcl --lib hle::d3d12x::vram:: -- --test-threads=1: 33 passed, 0 failed, 1 ignored with the candidate diff.RetiringHeapdefinition then runningcargo test --offline --locked -j 4 -p xcl --lib retire_queue_keeps_zero_buf_alive_until_marks_complete -- --nocapture --test-threads=1: 0 passed, 1 failed, 0 ignored. The failure wasleft: ["heap", "zero_buf"],right: ["zero_buf", "heap"]. I restored the correct order afterward.Candidate test-only diff (production behavior unchanged)
This covers the field-order regression only. It does not establish the native COM lifetime, the late mapping wait, or the unmap snapshot race; those still need their own production-path evidence. No title executable or full workspace suite was run for this candidate. AI use: Codex (GPT-6.2 Sol) reviewed the code, wrote the local diff, and ran the passing and mutation checks.
@Saksukella on GitHub · 2026-11-27 09:03 UTC · original
Thanks @fromthemoonx and @thehollowedone! Pushed shipped-code tests directly exercising \seal_and_drain_unmaps_with, \ram::wait_pending_mappings, \ram::recycle_ready, \sparse::wait_pending_mappings, and \PoolHeaps::take_heap\ + \RetiringHeap\ COM refcount retention (\39/39\ \ram, \38/38\ \sparse\ passed on RX 9070 XT).
@vibryxcx on GitHub · 2026-11-27 09:21 UTC · original · edited 2026-11-27 10:50 UTC
Clean-tree title A/B on an RX 6800 (RDNA2): with
ebef6042, 2 of 2 300 s runs ended cleanly; on its basebf7c82ee, 0 of 2. That is a small sample, but it is the first title run of the unmodified PR tree on RDNA2 here (bobosneefdev's run above merged local reverts and switches).Setup: RX 6800 16 GB, driver 32.0.21045.5002, i5-10600KF, 32 GB, Windows 11 Pro 26200, release builds of
bf7c82eeandebef6042(clean worktrees), the same retail title with warm caches. Each run:xcl runwithXCL_RUN_SECONDS=300, A pressed every 10 s, interleaved base / head / base / head, with 2 min between runs.int3(game_scarlett_master.exe+0x3bf4) near the endXCL_RUN_SECONDS0x887a0006at 229 sXCL_RUN_SECONDSbf7c82eelost the device in 3 of 3 600 s soak runs earlier (#2874), so the two clean head runs fit "fewer unmap/retire races", but two runs cannot prove it.ebef6042. The current headecbbf96aadds tests (+266 lines insparse.rs/vram.rs) and changes one runtime line (signal_device_queues(dev, dev_key, extra_queue)). I have not rerun the title on it.ecbbf96aon this card aborts inpso_async::used_tests::a_pipeline_an_earlier_run_used_is_built_ahead_of_its_first_use(0xc0000409), but so does basebf7c82eein the same run order (the test passes alone on both), so that is not this PR.Not tested:
ecbbf96aon the title; more runs; runs longer than 300 s; NVIDIA.AI use: Claude Code (Claude Opus 5.5) ran the A/B through a local test runner, read the logs and wrote this comment.
Update, on the current
amd-dev(5fbd90f9, which has #2947): with this PR the device reset is not gone. I made a local merge of5fbd90f9and the current headecbbf96a(2fc8305d, no conflict) and tested it against5fbd90f9itself, same card and settings as above, 600 s runs, interleaved:5fbd90f90x887a0007at 341 s0x887a0007at 329 s5fbd90f90x887a0007at 353 s0xc0000005atgame_scarlett_master.exe+0x2215c35(the null write of #232 / #159) at about 180 sSo on this card the two clean 300 s runs above came from runs that were simply shorter than the reset, which happens at 330-350 s here. With 600 s runs the PR did not remove the reset. Please read the earlier table as "no reset within 300 s", not as a fix.
@oni-swr on GitHub · 2026-11-27 10:09 UTC · original
RDNA3 / Windows data for #2981 at the new head: 0 of 3 600 s runs hung with it; on the same setup the amd-dev tree hung in 1 of 3. That is "no hang seen in 3 runs", not a fix claim. RDNA2 counterpart: vibryxcx's run above (7214590553).
Setup: RX 7800 XT 16 GB (RDNA3), driver 32.0.31035.1003, Ryzen 7 5700X3D, 64 GB, Windows 11 build 26200, DXC 1.8.2502.11, release builds, the same retail title.
amd-dev5fbd90f9(has #2947), unmodified (built frombfb40311, whose tree is identical).ecbbf96amerged onto5fbd90f9(clean merge, 3 files; the merge commit is local and only used for this test, since the PR branch is still based onbf7c82ee).XCL_PREPARE=0 XCL_NETWORK=0 XCL_ACTIVITY=1, A pressed every 8 s, 600 s runs. Each arm: 3 consecutive runs on one isolated copy of the same warm shader cache and profile, each run starting from what the previous one wrote. NoXCL_DRED. The arms ran one after the other, not interleaved.5fbd90f9ecbbf96aon5fbd90f90x887a0006(device hung) at 153 sNot tested: more than 3 runs per arm (1 vs 0 hangs is not a difference), DRED, a cold cache, other GPUs.
AI use: Claude Code (Claude Sonnet 5.5) built the trees, ran the title, read the logs and wrote this comment. Every number comes from those runs.
@spicbully-star on GitHub · 2026-11-27 10:51 UTC · original
Second RX 9070 XT data point, matching @bobosneefdev's RX 6800 run above: with this PR the device removal and
DRED page fault at GPU VA 0x0; allocations there: []; recently freed: []remain here too. What changes is which queue stops first.Setup: RX 9070 XT 16 GB, Windows 10 22H2 (19045), i7-9700K, 32 GB RAM. Release build of
ecbbf96plusbfb4031(amd-dev, cherry-picked) plus the #662 XG fix.Env:
XCL_NETWORK=0 XCL_DIRECT_DXIL=1 XCL_RT_GATE=miss XCL_DRED=1 XCL_PREPARE=0 XCL_PSO_IMAGE_SKIP=1 XCL_HUGE_PSO_CONCURRENCY=3plus Agility SDK, warm cache, noXCL_PER_LANE.texture page mappings did not reachlines5fbd90f(without)gpu-awakeecbbf96+bfb4031(with)texture uploads(1924/1925),vram pages(13719/13721),sparse(39683/39685), all stalled for ~16 s; title queues idleSo on this machine, with the PR the title queues go idle, and the stuck work is on XCL's own upload, page and sparse queues. One run only, so the order may vary. Next I'm testing
XCL_VRAM_ARENAS=1(no tiled pages) to see whether the VA 0x0 fault needs the page path, and I'll add that result in #2996.Tested with Claude Code (Claude Opus 5.5). The lines are from the run logs.
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.