D3D12.X: reclaim two-pass buffers on submit fence completion #2815

Open
github-bot wants to merge 1 commit from github-bot/gh-2815 into nvidia-dev AGit
Owner

@⁠coolpersonnn on GitHub · 2026-11-26 14:22 UTC · original
coolpersonnn:ws2/two-pass-fence-reuse → nvidia-dev · +412 −39 · 2 files · 1 commits · open

Reclaim retired two-pass mesh record and scratch buffers as soon as their GPU command queue fence completes, instead of waiting for the title to reset the command allocator or hitting the 10 s UNKNOWN_RES fallback timeout.

Part of #2688

What is in it

  • Track two-pass buffer bindings on open command lists in bind and hand them over to per-queue FencedBatch entries inside two_pass_submitted called from alloc_pool::executed on real ExecuteCommandLists submission (keeping split segments linked across splits and retiring untracked/bundled recordings back through ALLOC_RES).
  • Reclaim all signaled FencedBatch buffers on acquisition before checking the cap, and report live fence-held MiB in the periodic two-pass buffers: summary (waiting for GPU fences).
  • Unit tests covering fence reclamation without allocator reset, split-segment fence reclamation, multi-queue resubmission waiting for all fences, and untracked submit fallback to ALLOC_RES.

Tested

  • Hardware & toolchain: Windows 11 x64 (26200/26300), Ryzen 9 9950X3D, 95,800 MB RAM, NVIDIA GeForce RTX 5090 (32 GB, driver 621.01, DXC 1.8.2502.11), rustc 1.100.0, release + test builds.
  • cargo test --workspace --no-fail-fast -- --test-threads=4: 1,745 passed, 10 failed, 48 ignored across 41 test binaries; 27 explicit SKIPPED GPU tests (hle::d3d12x::bind: 38 passed incl. 1 SKIPPED two_pass_binds_set_the_shared_view_heap: no heap windows; hle::d3d12x::alloc_pool: 8 passed). All 10 failures are pre-existing failures also present on unmodified nvidia-dev (af2cecc4).
  • cargo build --release -p xcl --bin xcl: exited 0.
  • Full stacked series (#2688 WS2, measured through PR 3 on title: a93b40d7 over warm-cache 120 s runs): drops world-entry two-pass alive memory from 998 MiB (598 MiB waiting for allocator resets) to 129 MiB (0 MiB waiting), eliminating 73 past-cap skips with 0 device removals and 0 crashes.

Regression run

xcl-smoke v1
commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7
gpu: NVIDIA GeForce RTX 5090
title: a93b40d7
seconds: 60
exit: 0x0
frames shown: 1670 (PresentX 1670)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16641 MB
xcl-smoke v1
commit: af2cecc40886a8682ecf3267f5328c6dc4b66ad7
gpu: NVIDIA GeForce RTX 5090
title: a93b40d7
seconds: 60
exit: 0x0
frames shown: 1682 (PresentX 1682)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 18586 MB
xcl-smoke v1
commit: 71b1a93201456a655a5b23fe45348257c0658018
gpu: NVIDIA GeForce RTX 5090
title: a93b40d7
seconds: 60
exit: 0x0
frames shown: 1683 (PresentX 1683)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 17062 MB

Not tested

  • AMD RDNA2/3/4 and 8–16 GB NVIDIA GPUs.
  • Sustained 2–10 min in-world play (blocked on unmodified nvidia-dev af2cecc4 by pre-existing multi-minute compute-PSO driver compiles at world entry when the full world shader cache is absent).
  • Optional XCL_HEAP_WINDOWS=1 heap-window test (two_pass_binds_set_the_shared_view_heap skipped by default).

AI use

  • T3 Code / Antigravity, Gemini Pro (Orchestrator Neon): implemented the submit-fence tracking path, unit tests, and verification scripts; ran all builds, test suites, and smoke benchmarks.
**@⁠coolpersonnn** on GitHub · 2026-11-26 14:22 UTC · [original](https://github.com/xcl-dev/xcl/pull/2815) `coolpersonnn:ws2/two-pass-fence-reuse` → `nvidia-dev` · +412 −39 · 2 files · 1 commits · open Reclaim retired two-pass mesh record and scratch buffers as soon as their GPU command queue fence completes, instead of waiting for the title to reset the command allocator or hitting the 10 s `UNKNOWN_RES` fallback timeout. Part of #2688 **What is in it** - Track two-pass buffer bindings on open command lists in `bind` and hand them over to per-queue `FencedBatch` entries inside `two_pass_submitted` called from `alloc_pool::executed` on real `ExecuteCommandLists` submission (keeping split segments linked across splits and retiring untracked/bundled recordings back through `ALLOC_RES`). - Reclaim all signaled `FencedBatch` buffers on acquisition before checking the cap, and report live fence-held MiB in the periodic `two-pass buffers:` summary (`waiting for GPU fences`). - Unit tests covering fence reclamation without allocator reset, split-segment fence reclamation, multi-queue resubmission waiting for all fences, and untracked submit fallback to `ALLOC_RES`. **Tested** - Hardware & toolchain: Windows 11 x64 (`26200/26300`), Ryzen 9 9950X3D, 95,800 MB RAM, NVIDIA GeForce RTX 5090 (32 GB, driver `621.01`, DXC `1.8.2502.11`), `rustc 1.100.0`, release + test builds. - `cargo test --workspace --no-fail-fast -- --test-threads=4`: 1,745 passed, 10 failed, 48 ignored across 41 test binaries; 27 explicit `SKIPPED` GPU tests (`hle::d3d12x::bind`: 38 passed incl. 1 `SKIPPED two_pass_binds_set_the_shared_view_heap: no heap windows`; `hle::d3d12x::alloc_pool`: 8 passed). All 10 failures are pre-existing failures also present on unmodified `nvidia-dev` (`af2cecc4`). - `cargo build --release -p xcl --bin xcl`: exited 0. - Full stacked series (`#2688` WS2, measured through PR 3 on `title: a93b40d7` over warm-cache 120 s runs): drops world-entry two-pass alive memory from `998 MiB` (`598 MiB` waiting for allocator resets) to `129 MiB` (`0 MiB` waiting), eliminating `73` past-cap skips with `0` device removals and `0` crashes. **Regression run** ``` xcl-smoke v1 commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7 gpu: NVIDIA GeForce RTX 5090 title: a93b40d7 seconds: 60 exit: 0x0 frames shown: 1670 (PresentX 1670) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 16641 MB ``` ``` xcl-smoke v1 commit: af2cecc40886a8682ecf3267f5328c6dc4b66ad7 gpu: NVIDIA GeForce RTX 5090 title: a93b40d7 seconds: 60 exit: 0x0 frames shown: 1682 (PresentX 1682) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 18586 MB ``` ``` xcl-smoke v1 commit: 71b1a93201456a655a5b23fe45348257c0658018 gpu: NVIDIA GeForce RTX 5090 title: a93b40d7 seconds: 60 exit: 0x0 frames shown: 1683 (PresentX 1683) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 17062 MB ``` **Not tested** - AMD RDNA2/3/4 and 8–16 GB NVIDIA GPUs. - Sustained 2–10 min in-world play (blocked on unmodified `nvidia-dev` `af2cecc4` by pre-existing multi-minute compute-PSO driver compiles at world entry when the full world shader cache is absent). - Optional `XCL_HEAP_WINDOWS=1` heap-window test (`two_pass_binds_set_the_shared_view_heap` skipped by default). **AI use** - T3 Code / Antigravity, Gemini Pro (Orchestrator Neon): implemented the submit-fence tracking path, unit tests, and verification scripts; ran all builds, test suites, and smoke benchmarks.
Track per-queue fence marks on recordings that use two-pass mesh buffers
so retired buffers return to FREE_RES once their GPU submits finish
instead of waiting for allocator resets or the 10 s unknown-allocator
timeout. Untracked submits and bundles fall back safely to allocator
holding.

Part of #2688
Assisted-by: T3 Code / Antigravity (Gemini Pro Orchestrator Neon)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 14:25:07 +00:00
Author
Owner

@⁠thehollowedone on GitHub · 2026-11-26 14:45 UTC · original

Independent Windows/NVIDIA check of #2815 head 71b1a932 against its clean nvidia-dev base af2cecc4. I ran cargo build --offline --locked --workspace, then cargo test --offline --locked --workspace --no-fail-fast -- --test-threads=4 with XCL_ADAPTER=3080 and a persistent local DXIL test cache. Windows 11 build 26300, RTX 3080 Ti / driver 621.35, Ryzen 7 9800X3D, rustc 1.99.1 MSVC, DXC 1.8.2502.11.

Clean revision Passed Failed Ignored GPU SKIPPED notices
Base af2cecc4 1,745 6 48 26
Head 71b1a932 1,749 6 48 26

The same six named tests failed in both runs: two texture_upload tests, console_ms_in_as_slot_and_ms_with_as_are_refused_cleanly, async_compute_pso_registers_real_pso_and_not_standin, and two two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs instances. The head adds four passing tests. Of the 26 skip notices, 21 require wave64, three per-lane forms were refused, and two heap-window cases were disabled in the default run; I do not count skips as coverage.

I also ran the opt-in two_pass_binds_set_the_shared_view_heap fixture separately on both revisions with XCL_HEAP_WINDOWS=1: cargo test --offline --locked -p xcl --lib two_pass_binds_set_the_shared_view_heap -- --nocapture --test-threads=1. Each passed 1/1 with no skip. This synthetic check exercises the opt-in descriptor-heap binding path; it does not measure an in-world memory saving.

Not tested: paired retail-title smoke, sustained world load, AMD/Intel, or the full workspace suite with heap windows enabled. These results alone do not establish merge readiness.

AI use: Codex (GPT-6.2 Sol) ran the builds and tests, compared the exact base and head results, and drafted this report.

**@⁠thehollowedone** on GitHub · 2026-11-26 14:45 UTC · [original](https://github.com/xcl-dev/xcl/pull/2815#issuecomment-7195286547) Independent Windows/NVIDIA check of [#2815 head `71b1a932`](https://github.com/xcl-dev/xcl/commit/71b1a93201456a655a5b23fe45348257c0658018) against its clean [`nvidia-dev` base `af2cecc4`](https://github.com/xcl-dev/xcl/commit/af2cecc40886a8682ecf3267f5328c6dc4b66ad7). I ran `cargo build --offline --locked --workspace`, then `cargo test --offline --locked --workspace --no-fail-fast -- --test-threads=4` with `XCL_ADAPTER=3080` and a persistent local DXIL test cache. Windows 11 build 26300, RTX 3080 Ti / driver 621.35, Ryzen 7 9800X3D, rustc 1.99.1 MSVC, DXC 1.8.2502.11. | Clean revision | Passed | Failed | Ignored | GPU `SKIPPED` notices | | --- | ---: | ---: | ---: | ---: | | Base `af2cecc4` | 1,745 | 6 | 48 | 26 | | Head `71b1a932` | 1,749 | 6 | 48 | 26 | The same six named tests failed in both runs: two `texture_upload` tests, `console_ms_in_as_slot_and_ms_with_as_are_refused_cleanly`, `async_compute_pso_registers_real_pso_and_not_standin`, and two `two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs` instances. The head adds four passing tests. Of the 26 skip notices, 21 require wave64, three per-lane forms were refused, and two heap-window cases were disabled in the default run; I do not count skips as coverage. I also ran the opt-in `two_pass_binds_set_the_shared_view_heap` fixture separately on **both** revisions with `XCL_HEAP_WINDOWS=1`: `cargo test --offline --locked -p xcl --lib two_pass_binds_set_the_shared_view_heap -- --nocapture --test-threads=1`. Each passed 1/1 with no skip. This synthetic check exercises the opt-in descriptor-heap binding path; it does not measure an in-world memory saving. **Not tested:** paired retail-title smoke, sustained world load, AMD/Intel, or the full workspace suite with heap windows enabled. These results alone do not establish merge readiness. AI use: Codex (GPT-6.2 Sol) ran the builds and tests, compared the exact base and head results, and drafted this report.
Author
Owner

@⁠nnonno91 on GitHub · 2026-11-26 15:21 UTC · original

Independent RTX 5090 world-load check of #2815. I ran the clean nvidia-dev base af2cecc40886a8682ecf3267f5328c6dc4b66ad7 and the clean PR head 71b1a93201456a655a5b23fe45348257c0658018 on Windows 11 26200, RTX 5090 32 GB (driver 617.42), Ryzen 7 9800X3D, and 32 GB RAM.

Measured during loading Base PR head
Two-pass buffers made 6 6
Two-pass buffers reused 0 4
Largest sampled live two-pass pool 68 MiB 33 MiB
MiB waiting for allocator reset at that sample 3 0
Two-pass allocations refused at the cap 0 0
Peak process commit (XCL log) 36,609 MB 36,875 MB
Peak sampled local VRAM (31,419 MB DXGI budget) 20,168 MB 20,557 MB
Device removals / crashes 0 / 0 0 / 0

One 115 s release smoke run per revision, base first, using workload 9cc6a39e, identical copies of the offline profile, and shared shader and driver caches. Both reached world loading and stopped presenting before playable gameplay. Both timed runs exited 0x0. This shows the reuse path firing during loading. Sustained in-world memory and FPS remain unmeasured.

Ran scripts/smoke.ps1 -Game <workload> -Xcl <release exe> -Seconds 115 with XCL_ADAPTER=RTX 5090, XCL_NETWORK=0, XCL_ACTIVITY=1, XCL_PREPARE=0, XCL_DIRECT_DXIL=1, XCL_HEAP_WINDOWS=1, XCL_UMA_SHADOW=1, XCL_COHERENT_HEAPS=sparse:16, XCL_LOOK_SKIP=1, XCL_LOOK_STATS=2, XCL_TWO_PASS_MB=1024, XCL_GFX_PSO_WAIT_MS=150, and XCL_PRESS_AT=16:A,23:A,30:A.

AI use — Codex built the exact revisions, ran the smoke tests, and summarized the logs.

**@⁠nnonno91** on GitHub · 2026-11-26 15:21 UTC · [original](https://github.com/xcl-dev/xcl/pull/2815#issuecomment-7196148231) **Independent RTX 5090 world-load check of #2815.** I ran the clean `nvidia-dev` base `af2cecc40886a8682ecf3267f5328c6dc4b66ad7` and the clean PR head `71b1a93201456a655a5b23fe45348257c0658018` on Windows 11 26200, RTX 5090 32 GB (driver 617.42), Ryzen 7 9800X3D, and 32 GB RAM. | Measured during loading | Base | PR head | | --- | ---: | ---: | | Two-pass buffers made | 6 | 6 | | Two-pass buffers reused | 0 | 4 | | Largest sampled live two-pass pool | 68 MiB | 33 MiB | | MiB waiting for allocator reset at that sample | 3 | 0 | | Two-pass allocations refused at the cap | 0 | 0 | | Peak process commit (XCL log) | 36,609 MB | 36,875 MB | | Peak sampled local VRAM (31,419 MB DXGI budget) | 20,168 MB | 20,557 MB | | Device removals / crashes | 0 / 0 | 0 / 0 | One 115 s release smoke run per revision, base first, using workload `9cc6a39e`, identical copies of the offline profile, and shared shader and driver caches. Both reached world loading and stopped presenting before playable gameplay. Both timed runs exited `0x0`. This shows the reuse path firing during loading. Sustained in-world memory and FPS remain unmeasured. Ran `scripts/smoke.ps1 -Game <workload> -Xcl <release exe> -Seconds 115` with `XCL_ADAPTER=RTX 5090`, `XCL_NETWORK=0`, `XCL_ACTIVITY=1`, `XCL_PREPARE=0`, `XCL_DIRECT_DXIL=1`, `XCL_HEAP_WINDOWS=1`, `XCL_UMA_SHADOW=1`, `XCL_COHERENT_HEAPS=sparse:16`, `XCL_LOOK_SKIP=1`, `XCL_LOOK_STATS=2`, `XCL_TWO_PASS_MB=1024`, `XCL_GFX_PSO_WAIT_MS=150`, and `XCL_PRESS_AT=16:A,23:A,30:A`. AI use — Codex built the exact revisions, ran the smoke tests, and summarized the logs.
Author
Owner

@⁠KDenKC on GitHub · 2026-11-26 15:34 UTC · original

Source review of 71b1a932, no run. One ordering gap:

alloc_pool's submit path (around alloc_pool.rs:322-340) increments and signals the queue's fence under STATE, then drop(g) and calls bind::two_pass_submitted(queue, Some(&fence), value, lists). There, an existing entry for the queue is overwritten unconditionally (bind.rs:~132: m.1 = f.clone(); m.2 = value;). Two threads submitting to the same queue can reach two_pass_submitted in the opposite order to their Signals. The list then keeps the older value, and its two-pass buffers can be reclaimed once that older value completes while the newer submit still runs. Keeping the larger value (m.2 = m.2.max(value) when it is the same fence) closes it. #2816 and #2817 carry the same code, and #2816's mark_indirect_feedback_used has the same overwrite on pending_fences.

Not tested: no build or run on our side.

AI use: Gemini (Antigravity) flagged it in a review. Claude Code (Claude Opus 5.5) checked it against the source at 71b1a932 and wrote this.

**@⁠KDenKC** on GitHub · 2026-11-26 15:34 UTC · [original](https://github.com/xcl-dev/xcl/pull/2815#issuecomment-7196447610) Source review of `71b1a932`, no run. One ordering gap: `alloc_pool`'s submit path (around `alloc_pool.rs:322-340`) increments and signals the queue's fence under `STATE`, then `drop(g)` and calls `bind::two_pass_submitted(queue, Some(&fence), value, lists)`. There, an existing entry for the queue is overwritten unconditionally (`bind.rs:~132`: `m.1 = f.clone(); m.2 = value;`). Two threads submitting to the same queue can reach `two_pass_submitted` in the opposite order to their `Signal`s. The list then keeps the older value, and its two-pass buffers can be reclaimed once that older value completes while the newer submit still runs. Keeping the larger value (`m.2 = m.2.max(value)` when it is the same fence) closes it. #2816 and #2817 carry the same code, and #2816's `mark_indirect_feedback_used` has the same overwrite on `pending_fences`. Not tested: no build or run on our side. AI use: Gemini (Antigravity) flagged it in a review. Claude Code (Claude Opus 5.5) checked it against the source at `71b1a932` and wrote this.
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2815/head:github-bot/gh-2815'
git switch 'github-bot/gh-2815'

Merge

Merge the changes and update on Forgejo.
git switch 'nvidia-dev'
git merge --no-ff 'github-bot/gh-2815'
git switch 'github-bot/gh-2815'
git rebase 'nvidia-dev'
git switch 'nvidia-dev'
git merge --ff-only 'github-bot/gh-2815'
git switch 'github-bot/gh-2815'
git rebase 'nvidia-dev'
git switch 'nvidia-dev'
git merge --no-ff 'github-bot/gh-2815'
git switch 'nvidia-dev'
git merge --squash 'github-bot/gh-2815'
git switch 'nvidia-dev'
git merge --ff-only 'github-bot/gh-2815'
git switch 'nvidia-dev'
git merge 'github-bot/gh-2815'
git push origin 'nvidia-dev'
This discussion has been locked. Commenting is limited to contributors.
No description provided.