Skip to content

D3D12.X: fence sparse tile reuse after the last placed-buffer pin - #2531

Open
razormontana wants to merge 1 commit into
xcl-dev:mainfrom
razormontana:d3d12x/retire-sparse-tiles-after-final-pin
Open

razormontana wants to merge 1 commit into
xcl-dev:mainfrom
razormontana:d3d12x/retire-sparse-tiles-after-final-pin

Conversation

@razormontana

Copy link
Copy Markdown
Contributor

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.rs queues 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.
  • A CPU regression checks both mock queue completion orders and exactly-once return. The README documents when a pinned sparse tile returns to the pool.

Tested

  • Windows 11 Pro 22631, Intel Core i7-10700K, GeForce RTX 3070 8 GB (driver 617.42), Rust 1.100.0 MSVC and Windows SDK DXC.
  • Clean 6d7f8b9269a1a83f0b1e23805fd3388cdc0c2c44. cargo test -p xcl --lib -j 2 hle::d3d12x::sparse::tests::unpinned_sparse_tiles_wait_for_every_queue_before_reuse -- --exact passed 1 test with 0 failures, ignored tests or GPU skips.
  • A standalone, CPU-only control using the previous immediate free-list return failed the assertion that the last unpin keeps the tile unavailable.
  • cargo build --offline --locked --workspace and cargo build --offline --locked --release --workspace succeeded. The debug cargo test --offline --locked --workspace --no-fail-fast -- --test-threads=4 --show-output run with XCL_ADAPTER=3070 reported 1,424 passed, 0 failed and 46 ignored across 37 targets. The pass count includes 26 SKIPPED notices (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 60 on the same retail title in the Series S profile on the RTX 3070. They used XCL_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

xcl-smoke v1
commit: 6d12f58a229bc73889878a448c64dc3af25eeba0
gpu: NVIDIA GeForce RTX 3070
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 651 (PresentX 651)
presents per 2 s (last 3): 8 0 15
device removals: 0
crashes: 0
peak commit: 14469 MB

Candidate

xcl-smoke v1
commit: 6d7f8b9269a1a83f0b1e23805fd3388cdc0c2c44
gpu: NVIDIA GeForce RTX 3070
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 808 (PresentX 808)
presents per 2 s (last 3): 0 18 23
device removals: 0
crashes: 0
peak commit: 14692 MB

Not tested

  • The focused regression uses simulated fence completion. The retail smoke checks startup but does not establish that the last-pin retirement case occurred. AMD and Intel GPU coverage is pending.

AI use

  • OpenAI Codex (GPT-6.2 Sol) traced the sparse tile lifetime, implemented the fix, wrote and ran the focused regression, independently reviewed the diff and evidence, and drafted this description. The lead agent ran the workspace suite and retail smoke using OpenAI Codex (GPT-6.2).

A decommitted sparse tile can stay pinned after the window unmap is queued. Queue its eventual last unpin for the existing fence retirement path before the tile can enter the free list. Mark the sparse queue and title queues from an allocation or submission, outside the Release callback.

Part of xcl-dev#2457 (item 1) and xcl-dev#1773.
@razormontana
razormontana marked this pull request as ready for review November 25, 2026 22:00
@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

Thanks!

@xpatfussy69x

Copy link
Copy Markdown

Test run on exact head 6d7f8b9 (6d7f8b9269a1a83f0b1e23805fd3388cdc0c2c44, on its base 6d12f58), clean tree.

Tested

Regression run (60 s, default settings, a retail title)

main:

xcl-smoke v1
commit: e1d84b7d9153f86a97d2ec5d209d196046fc0bea
gpu: NVIDIA GeForce RTX 3060
title: c3f791f3
seconds: 60
exit: 0x0
frames shown: 1091 (PresentX 1091)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14814 MB

this PR:

xcl-smoke v1
commit: 6d7f8b9269a1a83f0b1e23805fd3388cdc0c2c44
gpu: NVIDIA GeForce RTX 3060
title: c3f791f3
seconds: 60
exit: 0x0
frames shown: 1140 (PresentX 1140)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14787 MB

No crash or device removal; frames 104 % of main's, peak commit 100 %.

Not tested

  • Whether a placed buffer unpins a parked tile while a queue still uses it in this run: a regression check only
  • The PR merged into current main (tested on its own base; it merges into e1d84b7 without conflicts)
  • AMD / native wave64

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and both smoke runs on the machine above and wrote this report.

@emirduran707

Copy link
Copy Markdown
Contributor

Independent AMD RDNA4 (native wave64) verification of exact PR head 6d7f8b9269a1a83f0b1e23805fd3388cdc0c2c44 on Windows 11 Pro 26300 (AMD Radeon RX 9060 XT 16 GB, driver 32.0.31044.16, Ryzen 5 5600, Rust 1.100.0 MSVC, DXC 1.9.2602.17).

Tested

  • cargo build --workspace (debug): passed (0 errors).
  • 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, 1 heap_window_out_of_memory_falls_back_to_the_switch_form no heap windows, 1 pso_measurement_compiles_an_exact_synthetic_record Windows Developer Mode off).
    • The new test hle::d3d12x::sparse::tests::unpinned_sparse_tiles_wait_for_every_queue_before_reuse passed.
    • The 2 failures (gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 and fuzz_validate_and_gpu_3) are pre-existing on unmodified main on this RX 9060 XT / driver 32.0.31044.16.
  • cargo build --release -p xcl + 60 s retail-title smoke test (scripts/smoke.ps1, offline):
xcl-smoke v1
commit: 6d7f8b9269a1a83f0b1e23805fd3388cdc0c2c44
gpu: AMD Radeon RX 9060 XT
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1600 (PresentX 1600)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 13934 MB

(Compare against main 68a284a on this machine: 1573 frames, 14420 MB peak, 0 device removals, 0 crashes.)

Not tested

  • NVIDIA / Intel GPUs, Linux / Wine.

AI use

  • Verification run and report prepared with Antigravity (Gemini 4 Neon); all build, test, and smoke results are from live runs on this machine.

@SlopTart

Copy link
Copy Markdown

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 target x86_64-pc-windows-gnu run 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.

@KOLESNiii KOLESNiii mentioned this pull request Nov 25, 2026
rootw0rm pushed a commit to rootw0rm/xcl that referenced this pull request Nov 26, 2026
…cl-dev#2531 + xcl-dev#2638)

(cherry picked from commit fa5b533156ecdf632edcb1b703c54a16948928bf)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants