D3D12.X: size two-pass indirect buffers from GPU feedback and finer buckets #2816

Open
github-bot wants to merge 2 commits from github-bot/gh-2816 into nvidia-dev AGit
Owner

@⁠coolpersonnn on GitHub · 2026-11-26 14:22 UTC · original
coolpersonnn:ws2/two-pass-feedback-sizing → nvidia-dev · +1038 −83 · 2 files · 2 commits · open

Stacked on #2815; only the top commit belongs here.

Size two-pass indirect DispatchMesh record buffers from observed GPU feedback and tighten bucket rounding so indirect mesh draws do not reserve worst-case multi-MiB buffers on every cold recording.

Part of #2688

What is in it

  • Extend SCALE_ARGS_HLSL with an uncapped RawBufferLoad feedback UAV (encoded as raw_n + 1) and add per-device async readback/clear in IndirectFeedback, committed on submit in two_pass_submitted and polled with cross-queue waits in alloc_pool::executed.
  • Start cold indirect PSOs at a 4 MiB cap (INDIRECT_COLD_CAP), grow immediately when GPU feedback shows clamping over the 250 ms history window, decay slowly downward when bursts subside, and round record/scratch allocations in 256 KiB half-steps (bucket_bytes).
  • Unit tests on WARP/SM 6.6 covering uncapped SCALE_ARGS_HLSL feedback, clamp growth/decay across windows, and submit-before-copyback ordering.

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,748 passed, 10 failed, 48 ignored across 41 test binaries; 27 explicit SKIPPED GPU tests (hle::d3d12x::bind: 41 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: f163cdc0290ff3079e8a507f74ee11f24a4edad2
gpu: NVIDIA GeForce RTX 5090
title: a93b40d7
seconds: 60
exit: 0x0
frames shown: 1680 (PresentX 1680)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16301 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 GPU feedback copyback, indirect sizing policy, and WARP/SM 6.6 tests; 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/2816) `coolpersonnn:ws2/two-pass-feedback-sizing` → `nvidia-dev` · +1038 −83 · 2 files · 2 commits · open Stacked on #2815; only the top commit belongs here. Size two-pass indirect `DispatchMesh` record buffers from observed GPU feedback and tighten bucket rounding so indirect mesh draws do not reserve worst-case multi-MiB buffers on every cold recording. Part of #2688 **What is in it** - Extend `SCALE_ARGS_HLSL` with an uncapped `RawBufferLoad` feedback UAV (encoded as `raw_n + 1`) and add per-device async readback/clear in `IndirectFeedback`, committed on submit in `two_pass_submitted` and polled with cross-queue waits in `alloc_pool::executed`. - Start cold indirect PSOs at a `4 MiB` cap (`INDIRECT_COLD_CAP`), grow immediately when GPU feedback shows clamping over the 250 ms history window, decay slowly downward when bursts subside, and round record/scratch allocations in `256 KiB` half-steps (`bucket_bytes`). - Unit tests on WARP/SM 6.6 covering uncapped `SCALE_ARGS_HLSL` feedback, clamp growth/decay across windows, and submit-before-copyback ordering. **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,748 passed, 10 failed, 48 ignored across 41 test binaries; 27 explicit `SKIPPED` GPU tests (`hle::d3d12x::bind`: 41 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: f163cdc0290ff3079e8a507f74ee11f24a4edad2 gpu: NVIDIA GeForce RTX 5090 title: a93b40d7 seconds: 60 exit: 0x0 frames shown: 1680 (PresentX 1680) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 16301 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 GPU feedback copyback, indirect sizing policy, and WARP/SM 6.6 tests; 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)
Record uncapped indirect DispatchMesh group counts in SCALE_ARGS_HLSL
via an async per-device readback/clear path committed on queue submit,
start cold indirect PSOs at 4 MiB with automatic clamp-driven growth,
and tighten record/scratch buckets to 256 KiB half-steps.

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:09 +00:00
Author
Owner

@⁠jeremiahmvze on GitHub · 2026-11-26 14:54 UTC · original

Test note from porting this onto another nvidia-dev-based branch (the code applied cleanly after #2815): the new feedback tests are not safe to run in parallel.

  • cargo test -p xcl --lib bind:: -- --test-threads=1: 40 passed.
  • With 4 test threads, 1 to 3 of these fail on each run:
    • indirect_feedback_waits_for_submit_before_copyback
    • indirect_feedback_copyback_grows_on_clamp_and_decays_over_windows
    • gpu_scale_args_reports_uncapped_group_count_feedback (a panic on the FEEDBACK lock)

They all use the process-wide FEEDBACK / FEEDBACK_ACTIVE statics, so one test's entries and on/off state leak into another's. Holding one shared test mutex (or resetting FEEDBACK under a guard) in each of these tests should fix it.

Caveat: this was on our port, not on f163cdc0 itself, and on an RTX 4090. The runtime path isn't affected; it's only the tests.

**@⁠jeremiahmvze** on GitHub · 2026-11-26 14:54 UTC · [original](https://github.com/xcl-dev/xcl/pull/2816#issuecomment-7195507003) Test note from porting this onto another `nvidia-dev`-based branch (the code applied cleanly after #2815): the new feedback tests are not safe to run in parallel. - `cargo test -p xcl --lib bind:: -- --test-threads=1`: 40 passed. - With 4 test threads, 1 to 3 of these fail on each run: - `indirect_feedback_waits_for_submit_before_copyback` - `indirect_feedback_copyback_grows_on_clamp_and_decays_over_windows` - `gpu_scale_args_reports_uncapped_group_count_feedback` (a panic on the `FEEDBACK` lock) They all use the process-wide `FEEDBACK` / `FEEDBACK_ACTIVE` statics, so one test's entries and on/off state leak into another's. Holding one shared test mutex (or resetting `FEEDBACK` under a guard) in each of these tests should fix it. Caveat: this was on our port, not on `f163cdc0` itself, and on an RTX 4090. The runtime path isn't affected; it's only the tests.
Author
Owner

@⁠DarkPanda69 on GitHub · 2026-11-26 14:56 UTC · original

AMD run (listed as untested), with an RTX 3060 in the same PC. Two of the new tests fail now and then on both cards when the tests run in parallel.

Tested: head f163cdc applied on its base nvidia-dev af2cecc, debug, Rust 1.100.0, Windows 11 Pro 26200, Ryzen 7 5800X, card picked with XCL_ADAPTER.
cargo test -p xcl --lib -- hle::d3d12x::bind hle::d3d12x::alloc_pool --test-threads=4, repeated:

  • AMD RX 9070 XT (RDNA4), driver 32.0.32029.2010: 1 of 6 runs failed (47 passed, 2 failed); the others 49 passed, 0 failed.
  • NVIDIA RTX 3060, driver 32.0.16.1088: 1 of 4 runs failed, same two tests.
  • gpu_scale_args_reports_uncapped_group_count_feedback and gpu_two_pass_pooled_scratch_respects_remaining_budget pass by name on both cards.

The two are indirect_feedback_waits_for_submit_before_copyback (bind.rs, assertion failed: !fb.dirty && !fb.copy_in_flight) and indirect_feedback_copyback_grows_on_clamp_and_decays_over_windows, which then panics on the poisoned FEEDBACK mutex. They fail more often on #2817, and the details are in my comment there. On one thread, #2817 passed 10 of 10 runs.

As on #2817, XCL_ADAPTER=radeon (lowercase) skips gpu_scale_args_reports_uncapped_group_count_feedback on this card with no D3D12 hardware adapter, because the name match is case-sensitive; Radeon runs it.

Not tested: a title run, release, XCL_HEAP_WINDOWS=1, Intel.

AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.

**@⁠DarkPanda69** on GitHub · 2026-11-26 14:56 UTC · [original](https://github.com/xcl-dev/xcl/pull/2816#issuecomment-7195558596) AMD run (listed as untested), with an RTX 3060 in the same PC. Two of the new tests fail now and then on both cards when the tests run in parallel. **Tested:** head `f163cdc` applied on its base `nvidia-dev` `af2cecc`, debug, Rust 1.100.0, Windows 11 Pro 26200, Ryzen 7 5800X, card picked with `XCL_ADAPTER`. `cargo test -p xcl --lib -- hle::d3d12x::bind hle::d3d12x::alloc_pool --test-threads=4`, repeated: - AMD RX 9070 XT (RDNA4), driver 32.0.32029.2010: 1 of 6 runs failed (47 passed, 2 failed); the others 49 passed, 0 failed. - NVIDIA RTX 3060, driver 32.0.16.1088: 1 of 4 runs failed, same two tests. - `gpu_scale_args_reports_uncapped_group_count_feedback` and `gpu_two_pass_pooled_scratch_respects_remaining_budget` pass by name on both cards. The two are `indirect_feedback_waits_for_submit_before_copyback` (`bind.rs`, `assertion failed: !fb.dirty && !fb.copy_in_flight`) and `indirect_feedback_copyback_grows_on_clamp_and_decays_over_windows`, which then panics on the poisoned `FEEDBACK` mutex. They fail more often on #2817, and the details are in my comment there. On one thread, #2817 passed 10 of 10 runs. As on #2817, `XCL_ADAPTER=radeon` (lowercase) skips `gpu_scale_args_reports_uncapped_group_count_feedback` on this card with `no D3D12 hardware adapter`, because the name match is case-sensitive; `Radeon` runs it. **Not tested:** a title run, release, `XCL_HEAP_WINDOWS=1`, Intel. AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.
Author
Owner

@⁠ettehn on GitHub · 2026-11-26 14:58 UTC · original

Confirmed the parallel test failure on the exact head f163cdc0290ff3079e8a507f74ee11f24a4edad2 and checked a test-only fix. RTX 5070 Ti Laptop (12 GB, 621.24), Windows 11 x64 build 26200, Rust 1.97.1 MSVC, DXC 1.8.2502.11.

  • Stock bind::tests: 41 reported passed on one thread, including the default heap-window capability skip. In eight fresh runs at four threads, 3 aborted: indirect_feedback_waits_for_submit_before_copyback first asserted !fb.dirty && !fb.copy_in_flight, then the other feedback tests hit the poisoned mutex.
  • Local test-only change: take the existing lock_warp_tests() at the start of indirect_feedback_copyback_grows_on_clamp_and_decays_over_windows and gpu_scale_args_reports_uncapped_group_count_feedback; the submit-order test already takes it. With those two guards plus the separate fixture below, the four-thread bind suite passed 16/16 fresh runs (42 reported passed, 0 failed, 0 ignored each, including one default capability skip). The skipped two_pass_binds_set_the_shared_view_heap also passed separately with XCL_HEAP_WINDOWS=1, with no skip.
  • Native two-queue fixture: a gate held the producer queue while poll_two_pass_feedback scheduled the readback on a second DIRECT queue. Its copy fence stayed pending until the producer was released. After release, the existing clamped, zero-count and disabled cases read back encoded values 501, 1, and 0. The focused run passed 1/0/0 with no capability skips.

Base command: cargo test --locked --offline -p xcl --lib -j 2 hle::d3d12x::bind::tests -- --test-threads=1 --nocapture; repeats used the same harness with --test-threads=4. Synthetic tests only. OpenAI Codex (6.2sol) assisted with verification.

**@⁠ettehn** on GitHub · 2026-11-26 14:58 UTC · [original](https://github.com/xcl-dev/xcl/pull/2816#issuecomment-7195611203) Confirmed the parallel test failure on the exact head `f163cdc0290ff3079e8a507f74ee11f24a4edad2` and checked a test-only fix. RTX 5070 Ti Laptop (12 GB, 621.24), Windows 11 x64 build 26200, Rust 1.97.1 MSVC, DXC 1.8.2502.11. - Stock `bind::tests`: 41 reported passed on one thread, including the default heap-window capability skip. In eight fresh runs at four threads, 3 aborted: `indirect_feedback_waits_for_submit_before_copyback` first asserted `!fb.dirty && !fb.copy_in_flight`, then the other feedback tests hit the poisoned mutex. - Local test-only change: take the existing `lock_warp_tests()` at the start of `indirect_feedback_copyback_grows_on_clamp_and_decays_over_windows` and `gpu_scale_args_reports_uncapped_group_count_feedback`; the submit-order test already takes it. With those two guards plus the separate fixture below, the four-thread bind suite passed **16/16** fresh runs (42 reported passed, 0 failed, 0 ignored each, including one default capability skip). The skipped `two_pass_binds_set_the_shared_view_heap` also passed separately with `XCL_HEAP_WINDOWS=1`, with no skip. - Native two-queue fixture: a gate held the producer queue while `poll_two_pass_feedback` scheduled the readback on a second `DIRECT` queue. Its copy fence stayed pending until the producer was released. After release, the existing clamped, zero-count and disabled cases read back encoded values `501`, `1`, and `0`. The focused run passed 1/0/0 with no capability skips. Base command: `cargo test --locked --offline -p xcl --lib -j 2 hle::d3d12x::bind::tests -- --test-threads=1 --nocapture`; repeats used the same harness with `--test-threads=4`. Synthetic tests only. OpenAI Codex (6.2sol) assisted with verification.
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/2816/head:github-bot/gh-2816'
git switch 'github-bot/gh-2816'

Merge

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