D3D12.X: unmap sparse tiles after the work the title's queues were given #496
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!496
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/496/head"
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?
@notdxbi on GitHub · 2026-11-24 01:02 UTC · original
notdxbi:pr-unmap-after-title-work→main· +96 −0 · 1 files · 1 commits · closed without mergingWhen the title unmaps physical pages in a sparse window,
sparse::decommittedunmapped their tiles (UpdateTileMappingsto NULL) on the sparse queue at once, ahead of work still in flight on the title's queues that reads or writes those tiles. While a retail game streamed its world (Linux, RTX 5060), NVIDIA's MMU faulted in a copy engine (NVRM Xid 31 … ENGINE CE0 … FAULT_PTE, a GPU VA with nothing mapped) and the device was lost. Now each known title queue signals a fence of its own and the sparse queue waits for it before unmapping; nothing waits on the CPU. Part of #175 / #248.What is in it
hle/d3d12x/sparse.rs:after_work_on(state, queues), called bydecommittedwithpresent::known_queues()beforeunmap_tiles; one fence per title queue (a fence shared by several queues could go backwards).unmapping_waits_for_work_on_title_queues(GPU): with a title queue held on a gate fence, the sparse queue's next signal does not complete until the gate opens. Without the change it fails ("the unmap queue went ahead of the title's work in flight").Tested
from_ifacechecks relaxed and-Db_ndebug=true, as in #257; DXVK 3.1.1 dxgi), Rust stablex86_64-pc-windows-gnu(cross-built), releasemain2997c9a+ this commit): CPU tests--skip gpu:: --test-threads=4: 364 passed, 0 failed, 3 ignored; GPU testsgpu:: --test-threads=1: 271 passed, 0 failed, 18 ignored (run serially: with 4 threads this card sometimes loses the device, NVRM Xid 109, in tests this change does not touch).mesh_dispatch::tests::gpu_*/paired_*were excluded: they hang this GPU onmaintoo.SKIPPEDon this adapter:gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware(no wave64)Regression run
scripts/smoke.ps1needs Windows (see Not tested).Not tested
scripts/smoke.ps1blocks and no MSVC build; this PR needs someone to run the regression on Windows before it can be merged.AI use
🤖 Generated with Claude Code
mainreaches on Windows; the obstacle is replaced vtables — proposal: proxies #175@ghost on GitHub · 2026-11-24 01:32 UTC · original
Windows / MSVC run, since Not tested asks for one:
409f40fmerged ontomain508a0c7(clean merge) builds and passes.Tested
x86_64-pc-windows-msvc; DXC 1.9.2602.17; debug build..\scripts\test.ps1: 681 passed, 0 failed, 41 ignored; noSKIPPEDGPU tests.cargo test -p xcl --lib unmapping_waits_for_work:unmapping_waits_for_work_on_title_queuespasses on the hardware adapter.Not tested
smoke.ps1(no retail title here yet).AI use
@vibryxcx on GitHub · 2026-11-24 01:48 UTC · original
Windows regression run with a retail title, which Not tested asks for (the comment above ran the suite only).
Tested
cargo clean --release -p xclbefore each build.409f40fas it is, against its base,main2997c9a. No uncommitted changes.scripts/smoke.ps1 -Game <folder> -Seconds 60, no input. Blocks below.XCL_PRESS_A_AT=14,17,21,40,60,66,72,-Seconds 180(the presses #532 uses):2997c9a409f40fRegression run
main2997c9a:This PR
409f40f:Not tested
AI use
@xstraok on GitHub · 2026-11-24 01:56 UTC · original
Tested
maina6f5f7a+ #257 + #458 + this PR (gh pr diff 496applied) on RX 9060 XT (RDNA4, RADV Mesa26.2.6), Linux, Proton Experimental Wine. The retail title still lost the device 67 s into world loading,
but with an AMD SQC (scalar data) page fault at an address no BO ever covered – past the end of the shared view
heap, not a sparse tile (
RADV_DEBUG=bo_history; details in <issue from draft 1>). So on AMD the device losscomes from a different cause, and these runs neither confirm nor rule out this PR's fix. No regression seen from
it (2 runs to 129 s and 145 s).
AI-assisted report (Claude Code, Claude Opus 5.5); runs made by me on the hardware above.
@notdxbi on GitHub · 2026-11-24 01:59 UTC · original
Thanks @nullmarsh and @vibryxcx for the runs.
A note for review: #532 changes the same function (
sparse::decommitted). It parks a fully decommitted tile until the next submit instead of unmapping it at once, which is about the driver cost of the calls. This PR is about ordering: the NULL mapping goes on the sparse queue only after the work already given to the title's queues (each queue signals a fence of its own; the sparse queue waits on the GPU). They should compose. When a parked tile is finally unmapped, it still needs to be ordered after work in flight that may use it. If #532 goes in first, I'll rebase this onto it and put the wait where the parked tiles are actually unmapped.@Kalmarv on GitHub · 2026-11-24 02:10 UTC · original · edited 2026-11-24 02:50 UTC
Tested
409f40f(this PR's head) and its base2997c9awith one added integration test, on an RTX 5070 Ti (NVIDIA 610.74), Ryzen 9 9950X, Windows 11 Pro 25H2 (26200.9711), rustc 1.99.0, debug.What the test does. A title's queue may GPU-wait for a fence that another of its queues signals only in a later submit; async compute does this.
sparse::before_executeandpresent::note_execute, as theExecuteCommandListshook does, so both are known queues.doneafter it.sparse::free→decommitted).before_executeand only then signals F.donehasn't completed after 5 s, the test signals F from the CPU so that everything can finish, then fails.Results (
sparse_decommit_waits, 3 runs each, one at a time):2997c9a: passes 3 of 3;409f40f: fails 3 of 3 with "queue A did not finish in 5 s".Why, by reading
409f40f. This part is not measured beyond the result above.decommittedcallsafter_work_on, so the sparse queue waits for a fence that every known queue signals, A included. A has that signal queued behind its wait for F.s.signal()follows the unmap.before_executethen waits fors.fenceat that value, so B'sSignal(F)never runs, and A never gets past its wait.unmapping_waits_for_work_on_title_queuesholds the title queue on a gate the CPU opens, so it doesn't reach this case.Not tested: AMD, Linux/vkd3d-proton (your setup), and any retail title. I haven't tried a fix. The test takes about 5 s even when it passes: its watchdog sleeps the full 5 s before checking.
The test, as a patch on
409f40f(git apply; built and run there and on2997c9a):crates/xcl/tests/sparse_decommit_waits.rs(Test and report by Claude Code, Claude Opus 5.5; the runs are ours, on the hardware above.)
Title smoke run
cargo build --release -p xcl) from clean checkouts2997c9aca6ebf4577fed34ebdb3cb0a77dd9ec21(this PR's base); PR head:409f40f85227fc3be5cdf43da7ea006ca89913fc, no uncommitted changesscripts/smoke.ps1 -Game <title folder> -Seconds 60on a retail title, main first, after one 60 s warm-up run of main; both sides start from the same learned coherent-window sizemain:
PR:
Not tested: whether the title unmapped sparse tiles in these 60 s (the log has no count of unmaps), so the run does not show the fault this PR fixes; it ran on native Windows on an RTX 5070 Ti, not under Wine on an RTX 5060 as in the PR; AMD GPUs.
🤖 Claude Opus 5.5
mainreaches on Windows; the obstacle is replaced vtables — proposal: proxies #175@ghost on GitHub · 2026-11-24 09:51 UTC · original
@Kalmarv's
sparse_decommit_waitstest reproduces on AMD. My earlier pass here was the whole suite on the head merged ontomain; the suite has no case like this one.Tested
create_device(None, …)uses), driver 32.0.32029.2010; Ryzen 7 5800X3D; Windows 11 Pro 26200; Rust 1.100.0 MSVC; debug.git applyto the PR head409f40fas it is and to its parent2997c9a, not merged ontomain;cargo test -p xcl --test sparse_decommit_waits -- --test-threads=1, 3 runs each:409f40f: fails 3 of 3, "queue A did not finish in 5 s: the unmap waits for A, which waits for B, which waits for the unmap";2997c9a: passes 3 of 3.Not tested
main(it conflicts).AI use
mainreaches on Windows; the obstacle is replaced vtables — proposal: proxies #175@raylitebull on GitHub · 2026-11-24 10:42 UTC · original
Closing as superseded by #532, which has already been merged into
main.mainreaches on Windows; the obstacle is replaced vtables — proposal: proxies #175Pull request closed