Skip to content

D3D12.X: retain reserved backing through the final tile mapping - #3734

Open
jeroenhaentjens wants to merge 1 commit into
xcl-dev:mainfrom
jeroenhaentjens:fix/reserved-backing-mapping-lifetime
Open

jeroenhaentjens wants to merge 1 commit into
xcl-dev:mainfrom
jeroenhaentjens:fix/reserved-backing-mapping-lifetime

Conversation

@jeroenhaentjens

@jeroenhaentjens jeroenhaentjens commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

What & Why

Part 4 of the review split of Draft #3682. Keep the tiles and heaps of every mapped reserved texture alive through active and retiring submit queues and the separate tile-mapping queue's final NULL mapping. This applies with XCL_LATE_RELEASE=0 as well. A texture that cannot return to the pool still receives a final NULL mapping and fence before native release.

What is in it

  • Keep the tile backing in RecycleInfo::backing until the mapping fence completes. make_spares uses the same pending recycle path.
  • Include active and retiring queue completion in release batches. Retry failed queue markers per queue without reopening submissions. Keep parked backing associated with an unmarked device until its retirement dependency is recovered.
  • Cover installed and recovered retirement marks in late_release.rs, the failed-signal spare case in an isolated WARP process, and the final upload and NULL-mapping gates in the GPU regression.
  • Queue completion is included here because it must be established before the final mapping retires the backing.

Tested

  • Commit ec06277. Intel Core i7-9750H, NVIDIA Quadro RTX 3000 (driver 597.06 / 32.0.15.9706), Windows 11 25H2 build 26200.9974, Rust MSVC 1.100.0 and DXC 1.9.2609.5.
  • git diff --check passed. cargo test --locked --workspace -- --test-threads=4 completed with 3,010 passed, 0 failed, 52 ignored and 26 SKIPPED diagnostics. The reserved-backing GPU regression recorded 0 D3D12 Debug Layer messages.
  • The failed-signal spare test passed three consecutive isolated WARP runs. The two late-release marker tests and the registry recovery test also passed.
  • cargo build --locked --release succeeded for the candidate. Both 60-second runs used the same shader cache and input schedule.

Regression run

Baseline (main)

xcl-smoke v1
commit: 5ad98adbc360225ac8a57ad9661e16fe8df9d8dd
gpu: NVIDIA Quadro RTX 3000
title: 0ba91dcb
seconds: 60
exit: 0x0
frames shown: 1520 (PresentX 1520)
presents per 2 s (last 3): 59 62 61
device removals: 0
crashes: 0
peak commit: 13865 MB

PR head

xcl-smoke v1
commit: ec06277bd366db39b2861941cceb0bc529a59d84
gpu: NVIDIA Quadro RTX 3000
title: 0ba91dcb
seconds: 60
exit: 0x0
frames shown: 1539 (PresentX 1539)
presents per 2 s (last 3): 60 61 61
device removals: 0
crashes: 0
peak commit: 13945 MB

Not tested

AMD, Linux, and scenes with sustained bursts of mapped texture release. The GPU regression covers the ordering directly.

AI use

OpenAI Codex (GPT-6, specific revision unavailable) assisted with the implementation, tests and PR update.

@github-actions github-actions Bot added area:d3d12 D3D12.X runtime, command lists, resources, sparse memory area:docs-ci Documentation, scripts, workflows, repo governance area:memory Virtual/physical memory, arenas, VRAM budget, UMA gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks) labels Dec 2, 2026
@Foniass

Foniass commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator

Review of d9ca1779 (code reading only, not a merge-check) · 4 medium

In short: This PR keeps a released reserved texture's tiles, and so their pool heaps, until the title's queues are done with it and the NULL tile mapping has completed. It also changes late_release to wait for the marks of retiring queues, ignore the device-removed u64::MAX value, and hold back parked backing while a queue on the same device has no retirement mark. It is #3682's fd938727 with the texture-budget gates removed, and it builds against main on its own. The mechanism holds up, and the GPU test would fail without it. It is now on by default, though; a failed queue retirement keeps backing forever, and the new sealing rules are untested.

Medium

  1. A failed queue retirement holds reserved backing forever.

    • queue_completion_snapshot_for_release (present.rs ~496) reports a Retiring::Failed queue as unmarked. A Failed entry never leaves the registry (sweep removes only Retiring::Mark), and nothing retries its mark.
    • After one failure, Dead::blocked_backing (late_release.rs ~40, ~132) holds back every mapped reserved texture released later on that device, with its tiles and heaps, for the rest of the run.
    • Held::is_empty then never becomes true, so every pinned hold waits its full IDLE_WAIT.

    Fix: retry the retirement mark, as D3D12.X: add an opt-in two-tier texture budget #3682's later commits do, or put a bound on the hold.

  2. The default path changes, where in D3D12.X: add an opt-in two-tier texture budget #3682 this was behind the budget.

    • Here it applies to every mapped reserved texture (real.rs ~2518, vram.rs ~3136). Each release of one that does not go back to the pool (render targets, depth, textures with private data) now queues a NULL UpdateTileMappings and a Signal on the mapping queue. Before, its tiles went idle at release.
    • With XCL_LATE_RELEASE=0, mapped reserved textures are now held and recycled through the reserved pool, because forget_pages gets held = true.
    • The description should say both paths change. The one 60 s smoke run does not measure the cost in a scene with many releases.
  3. The new sealing rules have no tests.

    • unmarked_retirement_does_not_hold_unrelated_releases (late_release.rs ~501) only shows that entries that are not parked pass.
    • No test parks backing on an unmarked device and checks that it stays in open, keeps its order, and goes once the mark is installed.
    • No test checks that a batch waits for a retiring mark: every test passes &[] for retiring.
  4. Two changes in one PR, over the size target. The late_release / present.rs rework (retiring marks in the batch, open_prefix revisions, unmarked-device blocking, the u64::MAX check in take_gone) stands apart from keeping the tile backing through the NULL mapping. Together they are about 540 changed lines. The u64::MAX handling also overlaps D3D12.X: retain resources when retirement fences fail #3125. Splitting the queue-snapshot part out would make each half reviewable on its own.

Checked and fine
  • Builds on main alone: no texture-budget symbol from D3D12.X: add an opt-in two-tier texture budget #3682 is used. Compared with fd938727, the texture_budget_enabled() gates and the L0 test setup are gone, and a simpler unmarked-device rule stands in for D3D12.X: add an opt-in two-tier texture budget #3682's later failed-retirement handling. If both stay open, D3D12.X: add an opt-in two-tier texture budget #3682 will need reworking onto this one.
  • The NULL mapping is covered: unmap_range signals after UpdateTileMappings, recycle_ready takes pages.mark() after it, and tiles are released only in collect_released once that value has completed.
  • Textures with private data lose their pool key but still park their backing, and are released natively after the NULL mapping. Spares from make_spares keep backing: None.
  • open[..count] cannot go out of bounds: only begin_seal and a failed end_seal remove from open, and both bump open_revision.
  • Lock order is HELD then PARKING, with no reverse path.
  • PAGES keys and GetDevice both give the raw pointer of the hooked device, so blocked_backing compares like with like.
  • The GPU test runs in a child process with XCL_LATE_RELEASE=0, skips without tiled-resources tier 2, and on main would fail at the tile-users assertion. README updated.

Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.

Keep the native resource and its tile users through the submit-queue
marks and the fence after the NULL mapping. Keep spares on the existing
pool path. Hold backing on devices with an unmarked retired queue while
letting unrelated releases continue.

Adapt the upload and mapping regression to the existing texture pools
and runtime adapter selection.

(cherry picked and adapted from fd93872)
Assisted-by: OpenAI Codex (GPT-6, specific revision unavailable)
@jeroenhaentjens
jeroenhaentjens force-pushed the fix/reserved-backing-mapping-lifetime branch from d9ca177 to ec06277 Compare December 2, 2026 22:28
@jeroenhaentjens

Copy link
Copy Markdown
Contributor Author

@Foniass I isolated the failed-signal spare test in a WARP process and verified it three times. Failed retirement markers now retry per queue. The new tests cover waiting on an installed marker and keeping parked backing in order until the recovered marker completes. The description includes the scope with XCL_LATE_RELEASE=0 and the updated 60-second head run.

@Foniass

Foniass commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator

Follow-up review of ec06277b, since d9ca1779 (code reading only, not a merge-check) · 1 medium

In short: Since d9ca1779 a failed queue retirement is retried: the retirement worker re-signals the queue every 250 ms and turns the failed entry into a mark. New tests cover retiring marks and parked backing on an unmarked device. The spare test that failed CI now runs in its own WARP process. The description now says the change also applies with XCL_LATE_RELEASE=0. Three of the four earlier points are fixed and nothing new turned up. The PR is still two changes in one.

Medium

  1. Two changes in one PR, over the size target (still open).

    • It is now 555+/167-, about 720 changed lines. Roughly half is the queue-completion rework, which this push made bigger:
      • retiring marks in the batch, open_prefix / open_revision and unmarked-device blocking (late_release.rs ~40-160);
      • queue_completion_snapshot_for_release and the retry worker (present.rs ~505-700).
    • The other half keeps the tile backing through the NULL mapping (vram.rs, real.rs).
    • The description says queue completion "must be established before the final mapping retires the backing". That is an order, and two stacked PRs give the same order.
    • The u64::MAX handling and checked_add(1).filter(|&next| next != u64::MAX) in late_release.rs still repeat D3D12.X: retain resources when retirement fences fail #3125.

    Fix: make the queue-completion part its own PR and stack this one on it.

Checked and fine
  • Earlier finding fixed: a failed retirement held backing forever. retry_failed_retirements (present.rs ~645) re-signals each Retiring::Failed queue outside the registry lock, and recover_retiring (~424) turns it into Retiring::Mark. sweep can then remove it, Dead::blocked_backing lets go, and Held::is_empty can become true. A queue on a removed device is skipped.
  • Earlier finding fixed: the description now says the change applies with XCL_LATE_RELEASE=0, and that a texture that cannot return to the pool still gets a final NULL mapping and fence. Scenes with bursts of releases are under Not tested.
  • Earlier finding fixed: the sealing rules have tests.
    • release_waits_for_a_retiring_queue_mark (late_release.rs ~520): a batch waits for a retiring mark.
    • parked_backing_waits_in_order_for_the_recovered_queue_mark (~536): parked backing on an unmarked device stays in open, in order, while other entries go, and goes once the mark completes.
    • failed_retirement_stays_pinned_until_its_recovered_mark: the registry goes from failed to marked to swept.
  • spares_without_their_signal_are_released runs in a child process on WARP. On d9ca1779 it saw another test's mapping value on a reused device and poisoned PAGES for two later tests.
  • retire_released_queue now uses the same retirement_device / signal_retirement helpers as the retry.
  • queue_completion_snapshot_for_release does not wait on Preparing, so a release during a retirement cannot block on its own queue.
  • A seal that fails part-way takes nothing from open. Blocked entries go back to the front in order.
  • Lock order is still HELD then PARKING. drain_recycled reads fence values outside PAGES and checks that the fence is still the same one.

Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:d3d12 D3D12.X runtime, command lists, resources, sparse memory area:docs-ci Documentation, scripts, workflows, repo governance area:memory Virtual/physical memory, arenas, VRAM budget, UMA gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks) needs-1st-check Passes gates; needs first independent merge-check (#3041)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants