D3D12.X: fence sparse tile reuse after the last placed-buffer pin #2521
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2531"
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 razormontana on 2026-11-25T21:47:28Z.
D3D12.X: fence sparse tile reuse after the last placed-buffer pin
When a sparse window unmaps a tile still pinned by a placed buffer, the last unpin can put the tile back in the pool before outstanding queue work completes. Defer that return to the existing sparse tile quarantine and take fence marks after the last pin drops. Part of #2457 (item 1), #1773 and #1833.
What is in it
sparse.rsqueues unused tiles at the last unpin. Allocation and submission fence the queued tiles on the sparse and title queues. Pool reuse and retirement continue to use the free list.Tested
6d7f8b9269a1a83f0b1e23805fd3388cdc0c2c44.cargo test -p xcl --lib -j 2 hle::d3d12x::sparse::tests::unpinned_sparse_tiles_wait_for_every_queue_before_reuse -- --exactpassed 1 test with 0 failures, ignored tests or GPU skips.cargo build --offline --locked --workspaceandcargo build --offline --locked --release --workspacesucceeded. The debugcargo test --offline --locked --workspace --no-fail-fast -- --test-threads=4 --show-outputrun withXCL_ADAPTER=3070reported 1,424 passed, 0 failed and 46 ignored across 37 targets. The pass count includes 26SKIPPEDnotices (21 native-wave64 checks, 3 unsupported per-lane forms, 1 reserved cube with mips and 1 heap-window check).Regression run
Both clean release builds ran
scripts/smoke.ps1 -Game <folder> -Seconds 60on the same retail title in the Series S profile on the RTX 3070. They usedXCL_DIRECT_DXIL=1, networking off and identical starting copies of XCL's warmed cache. NVIDIA's driver cache settings were left at their defaults.Main
Candidate
Not tested
AI use
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T22:08:27Z.
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!
Imported from ivall/xcl. Originally posted by xpatfussy69x on 2026-11-25T22:40:52Z.
Test run on exact head
6d7f8b9(6d7f8b9269a1a83f0b1e23805fd3388cdc0c2c44, on its base6d12f58), clean tree.Tested
cargo test --workspace -- --test-threads=4: 1424 passed, 0 failed, 46 ignoredV_MUL_F16/V_PK_MUL_F16/V_CVT_F16_F32(onmaintoo)cargo test -p xcl --lib unpinned_sparse_tiles: 1 passed, 0 failedunpinned_sparse_tiles_wait_for_every_queue_before_reuse: oksparse.rs) without conflicts (git merge-tree); the two were not run togetherRegression run (60 s, default settings, a retail title)
main:
this PR:
No crash or device removal; frames 104 % of
main's, peak commit 100 %.Not tested
main(tested on its own base; it merges intoe1d84b7without conflicts)AI use
Imported from ivall/xcl. Originally posted by emirduran707 on 2026-11-25T22:52:05Z.
Independent AMD RDNA4 (native wave64) verification of exact PR head
6d7f8b9269a1a83f0b1e23805fd3388cdc0c2c44on Windows 11 Pro 26300 (AMD Radeon RX 9060 XT 16 GB, driver32.0.31044.16, Ryzen 5 5600, Rust 1.100.0 MSVC, DXC1.9.2602.17).Tested
cargo build --workspace(debug): passed (0errors).cargo test --workspace --no-fail-fast -- --test-threads=4:1422 passed, 2 failed, 46 ignored(8 SKIPPED: 6 per-lane DXIL forms refused by host adapter/driver, 1heap_window_out_of_memory_falls_back_to_the_switch_formno heap windows, 1pso_measurement_compiles_an_exact_synthetic_recordWindows Developer Mode off).hle::d3d12x::sparse::tests::unpinned_sparse_tiles_wait_for_every_queue_before_reusepassed.gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1andfuzz_validate_and_gpu_3) are pre-existing on unmodifiedmainon this RX 9060 XT / driver32.0.31044.16.cargo build --release -p xcl+ 60 s retail-title smoke test (scripts/smoke.ps1, offline):(Compare against
main68a284aon this machine:1573 frames, 14420 MB peak, 0 device removals, 0 crashes.)Not tested
AI use
Imported from ivall/xcl. Originally posted by SlopTart on 2026-11-25T23:07:55Z.
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): 164 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
unpinned_sparse_tiles_wait_for_every_queue_before_reuse: passed. Sparse tiling on RADV executes for real 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.
Imported from ivall/xcl. Originally posted by Decodere on 2026-11-27T03:15:39Z.
Independent desktop NVIDIA verification of PR #2531 at head
6d7f8b9269a1a83f0b1e23805fd3388cdc0c2c44(1commit; exact parent & merge-base:6d12f58a229bc73889878a448c64dc3af25eeba0, pre-#2555ancestor ofmain).Environment
7956 MiBreported by D3D12), driver32.0.16.2114(NVIDIA621.14, WDDM 3.2)31.9 GiBusable), Windows 11 Home26200(Developer Mode off)rustc 1.100.0 (0ef1bc386 2026-11-09)MSVC, DXC1.9.2609.5,--releaseTargeted release tests & build (
6d7f8b92)cargo test --release -p xcl --lib unpinned_sparse_tiles_wait_for_every_queue_before_reuse -- --nocapture(3 consecutive runs)1 passed; 0 failed; 0 ignored; 1324 filtered out× 3 (0.00s× 3,0skipped)cargo test --release -p xcl --lib hle::d3d12x::sparse:: -- --test-threads=1(3 consecutive runs)18 passed; 0 failed; 1 ignored; 1306 filtered out× 3 (1.21s,1.22s,1.18s,0skipped)cargo build --release -p xcl1m 10s, exit0,0new warnings)Paired quiet 60 s retail smoke (
title: 29640639)Exact parent & merge-base (
6d12f58a229bc73889878a448c64dc3af25eeba0, cached baseline on the same machine):PR #2531 (
6d7f8b9269a1a83f0b1e23805fd3388cdc0c2c44):Runtime log observations (
xcl.log)9221log lines,0[ERROR]/ device-removal / panic lines.19525 draws with translated pipelines (0 skipped, 0 with PC pipelines), 1024 dispatches (0 skipped); last memory sample14023 MB committed by the process; video memory 6114 MB local, 4686 MB non-local.Limits of coverage
unpinned_sparse_tiles_wait_for_every_queue_before_reuse(3/3) andhle::d3d12x::sparse::(18/0/1× 3).title: 29640639exercises live sparse VRAM allocation (7445 MBsparse) with zero device removals or crashes (frame-count and commit deltas vs. cached parent reflect single-run startup variance, not this PR); heavy multi-minute placed-buffer churn under tight 8 GB VRAM eviction was not separately stressed here.AI disclosure: test execution and report drafting assisted by Google Antigravity (Gemini 4 Neon).
Imported from ivall/xcl. Originally posted by andrewDoing on 2026-11-27T03:34:49Z.
I tested the last-pin retirement case on NVIDIA GeForce RTX 5070 12 GB, driver 616.92, Windows 11, at PR head
6d7f8b9269a1a83f0b1e23805fd3388cdc0c2c44with one local test added tosparse.rs. Production code was unchanged.The fixture mapped a native reserved buffer and a sparse window to the same 64 KiB tile. It registered one placed-buffer pin, removed the sparse window mapping, and waited for the sparse queue to finish the unmap. It then gated a separate D3D12 direct queue on a native fence and queued a four-byte
CopyBufferRegionfrom the still-mapped alias. At that point it invokedforget_in, the production last-release bookkeeping, and requested a tile throughtake_tile.(0,0)stayed out of the free list. Allocation returned(0,1).(0,0)once, another drain added nothing, and the next allocation returned(0,0).cargo test --locked -p xcl --lib hle::d3d12x::sparse::tests::native_last_pin_fence_probe -- --exact --nocapturepassed in 0.45 s, with 1 passed, 0 failed, and no capability skip. This is a test-only fixture using isolated sparse state. It seeded the pin and buffer records and calledforget_indirectly. It kept a native COM reference alive for the queued copy. The guest COMReleasehook, memory pressure, and title gameplay remain outside this test's coverage.AI use: OpenAI Codex with GPT-6.2 Astra prepared the fixture and ran the test; Codex coordinated and prepared this report.
Imported from ivall/xcl. Originally posted by throny on 2026-11-27T21:49:26Z.
merge-check claim
head:
6d7f8b9269Imported from ivall/xcl. Originally posted by throny on 2026-11-27T22:11:32Z.
merge-check
base:
2c717a04head:
6d7f8b9269merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 1467 passed, 0 failed, 47 ignored (26 SKIPPED lines); base alone: 1466 passed, 0 failed, 47 ignored
review: none blocking. Every user of the removed field and function on main is updated; quarantine_tiles returns at once with no tiles; flush_parked never quarantines pinned tiles, so the early return in unpin cannot leave stale marks. The test covers the retirement table alone, not the wiring into take_tile and before_execute. Nit: the README row now describes internals.
performance: the same scans as main plus one Signal per known queue for each batch of unpinned tiles (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-28T02:46:21Z.
merge-check claim
head:
6d7f8b9269Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-28T03:52:54Z.
merge-check
base:
e429936c10head:
6d7f8b9269merge: conflicts (crates/xcl/src/hle/d3d12x/sparse.rs)
build: not run (the PR does not merge into this base)
tests: not run on this base. On the previous base
753e8b1athe trial merge was clean, built, and its suite gave 1513 passed, 0 failed, 47 ignored, 24 SKIPPED.review: not repeated on this base. On
753e8b1a: none. Whole diff read (sparse.rs TileRetirement: unpin / drain, quarantine_unpinned in take_tile and before_execute, forget_in, 1 unit test + updated tests; README). A pool tile whose last placed-buffer pin drops is no longer freed at once: it waits for new fence marks on the sparse queue and every known title queue, taken after that drop (a buffer could be used after the window's unmap marks). A tile cannot be pinned again while quarantined, so it cannot reach the free list twice; quarantine_tiles returns early with no tiles, so submits with nothing unpinned signal nothing.performance: not assessed on this base.
verdict: not yet: conflicts with main (crates/xcl/src/hle/d3d12x/sparse.rs); rebase onto main
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. Claude Code: Claude Opus 5.5 (coordination, full-diff review, draft).
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T08:17:46Z.
Triage (#1607) – head
6d7f8b9This fixes item 1 of #2457 (a tile unpinned by a released placed buffer skips the fence quarantine). #2539 and the closed #2528 fix item 2 of the same issue (
place_bufferholdingSTATEacrossCreateReservedResource), a different bug, so this is not a duplicate.main has changed this path since:
forget_in->release_if_unused(t, tile)now pushes the tile ontocoolingfor a 2 s timer (9554f33e) and has akeptpath, so reuse is delayed by time but still not fenced on the title queues. The fence-based retirement here still adds something, butsparse.rson main was reworked heavily and the branch conflicts; it needs a rebase onto thecooling/keptcode.Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.