Skip to content

D3D12.X: cap two-pass buffers by DXGI headroom with wait and shrink - #2817

Open
coolpersonnn wants to merge 3 commits into
xcl-dev:nvidia-devfrom
coolpersonnn:ws2/two-pass-budget-fallback
Open

coolpersonnn wants to merge 3 commits into
xcl-dev:nvidia-devfrom
coolpersonnn:ws2/two-pass-budget-fallback

Conversation

@coolpersonnn

@coolpersonnn coolpersonnn commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Cap the two-pass mesh buffer pool dynamically from DXGI local VRAM headroom, reclaim busy memory via bounded fence waits, and shrink/fallback gracefully before dropping draws.

Stacked on #2816; only the top commit belongs here.
Part of #2688

What is in it

  • crates/xcl/src/hle/d3d12x/bind.rs:
    • Cap the two-pass pool at 25% of remaining DXGI local VRAM headroom with a card-scaled floor (local_budget / 32).clamp(256 MiB, 512 MiB).min(ceiling) and a min(local_budget / 4, 2048 MiB) ceiling cached for 250 ms (XCL_TWO_PASS_MB still overrides), and remove the / 2 reuse-pool clamp in put_free_bufs that caused buffer churn.
    • Bound submit-fence waits (wait_oldest_fenced_until, FENCE_WAIT_LIMIT = 10 ms) with 250 ms timeout backoff and FenceState::Removed short-circuiting (WaitStep::Stopped), and retry oversized reuse candidates before waiting.
    • Shrink oversized DispatchMesh / ExecuteIndirect record buffers across every 256 KiB half-step bucket down to a single record (records_for_with_cap + try_ensure_res_buffer_exact_with_cap) rather than jumping straight past 1.5x steps, and track exact direct DispatchMesh fallback cuts/drops (TP_DIRECT_CUT, TP_DIRECT_GROUPS_DROPPED).
    • Allow XCL_TWO_PASS_BATCH halves (Halves -> Whole) and batch-buffer allocations (batch_region / try_make_with_cap) to fall back cleanly without polluting TP_REFUSED or prematurely skipping draws, plus 10 unit/GPU tests covering budget scaling, wait backoff, device removal, half-step shrink selection, and batch fallback.

Tested

  • Hardware / toolchain: NVIDIA GeForce RTX 5090 (driver 32.0.16.2101, 32187 MiB VRAM, wave32 / split wave64), WARP (software renderer), AMD Ryzen 9 9950X3D, Windows 11 Pro (10.0.26300), rustc 1.100.0 (0ef1bc386 2026-11-09), DXC 1.8.2502.11.
  • Targeted suite on clean e70a708b:
    • cargo test --offline --locked -p xcl --lib -- hle::d3d12x::bind hle::d3d12x::alloc_pool --test-threads=4 (NVIDIA + WARP): 82 passed; 0 failed (1 opt-in SKIPPED: hle::d3d12x::bind::tests::two_pass_binds_set_the_shared_view_heap: no heap windows (opt-in: XCL_HEAP_WINDOWS=1)).
    • With XCL_HEAP_WINDOWS=1: two_pass_binds_set_the_shared_view_heap 1 passed; 0 failed.
  • Clean workspace release build + test suite (cargo build --offline --locked --release --workspace && cargo test --offline --locked --release --workspace --no-fail-fast -- --test-threads=4):
    • e70a708b on RTX 5090: total_passed=1833, total_failed=13, total_ignored=48, skips=27 (xcl lib: 1706 passed; 7 failed; 28 ignored) vs nvidia-dev (eae01502): total_passed=1812, total_failed=13, total_ignored=48, skips=27.
    • e70a708b on WARP (XCL_ADAPTER=warp): total_passed=1838, total_failed=6, total_ignored=48, skips=363 (xcl lib: 1711 passed; 2 failed; 28 ignored) vs nvidia-dev (eae01502): total_passed=1817, total_failed=6, total_ignored=48, skips=364.
    • Zero new failures on either backend: RTX 5090's 13 failures match pre-existing nvidia-dev baseline (fuzz_validate_and_gpu_{0,1,2,3}, gpu_compute_thread_limits_leave_the_lanes_past_them_out, texture_upload::{pieces_hold_the_texels_of_their_levels, gpu_parts_of_a_texture_go_up_and_the_rest_stays}, console_ms_in_as_slot_and_ms_with_as_are_refused_cleanly, async_compute_pso_registers_real_pso_and_not_standin, split_compute_prefers_the_offline_whole_pipeline x2, two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs x2); WARP's 6 failures match pre-existing baseline (texture_upload x2, console_ms_in_as_slot_and_ms_with_as_are_refused_cleanly, test_title_draws_with_a_root_signature_under_the_debug_layer, test_title_runs_under_the_debug_layer_with_dred, test_title_runs_and_game_folder_is_untouched).
    • 27 SKIPPED GPU tests on RTX 5090: no wave64 (20), wave32, per-lane form: refused (3), no heap windows (2), cannot disable the driver cache (1), plus opt-in XCL_HEAP_WINDOWS=1 skip above (1).
  • 60 s retail startup smoke (scripts/smoke.ps1, title: a93b40d7, RTX 5090, XCL_PREPARE=0): e70a708b produced 1675 frames (PresentX 1675), 0 device removals, 0 crashes, 16201 MB peak commit vs nvidia-dev eae01502 (1628 frames, 15793 MB peak commit) and main b49be183 (1654 frames, 16446 MB peak commit).
  • Matched 120 s world-loading A/B runs on title: a93b40d7 (RTX 5090, XCL_PREPARE=0, synthetic A inputs entering live world loading with two-pass DispatchMesh and two-pass ExecuteIndirect(DispatchMesh), 0 device removals and 0 crashes across all 5 runs):
    • nvidia-dev (eae01502, default 1024 MiB cap): 1426 frames (PresentX 1426), 83 made / 3 taken again / 0 let go, 83 alive (1013 MiB), 37 MiB waiting for allocator resets, 2420 draws refused/skipped past 1024 MiB, peak commit 36712 MB, peak local VRAM 15647 MB.
    • e70a708b (default DXGI headroom -> 2048 MiB cap): 1432 frames (PresentX 1432), 105 made / 6 taken again / 3 let go, 102 alive (1550 MiB), 0 MiB waiting for fences/resets, 0 refused/skipped draws, 0 warnings, 0 waits/timeouts, 0 clamped/cut/shrunk, peak commit 39579 MB, peak local VRAM 16221 MB.
    • e70a708b (XCL_TWO_PASS_MB=1024): 1428 frames (PresentX 1428), 71 made / 5 taken again / 2 let go (69 alive, 1023 MiB), 489 shrunk, 2317 refused past 1024 MiB, 0 waiting for fences/resets, 0 waits/timeouts, peak commit 37568 MB.
    • e70a708b (XCL_TWO_PASS_MB=256): 1432 frames (PresentX 1432), 24 made / 3 taken again / 3 let go (21 alive, 255 MiB), 271 shrunk, 1 direct cut (24 groups dropped), 10164 refused past 256 MiB, 0 waits/timeouts, peak commit 35055 MB.
    • e70a708b (XCL_TWO_PASS_BATCH=2): 1415 frames (PresentX 1415), 60 made / 13 taken again / 3 let go (57 alive, 2022 MiB, 7 kept for reuse 385 MiB), 478 shrunk, 3560 refused past 2048 MiB, 0 waits/timeouts, peak commit 36466 MB.

Regression run

xcl-smoke v1
commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7
gpu: NVIDIA GeForce RTX 5090
title: a93b40d7
seconds: 60
exit: 0x0
frames shown: 1654 (PresentX 1654)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16446 MB
xcl-smoke v1
commit: e70a708bfcab1e806a8e81517124cb2f890479b2
gpu: NVIDIA GeForce RTX 5090
title: a93b40d7
seconds: 60
exit: 0x0
frames shown: 1675 (PresentX 1675)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16201 MB

Not tested

  • Not tested on AMD GPUs (RDNA2/RDNA3/RDNA4); NVIDIA wave32 (split wave64) and WARP only.
  • Natural low-VRAM hardware pressure (< 8 GiB local budget) could not be reproduced on the 32 GiB RTX 5090 directly; pool-cap starvation and shrink/cut fallbacks were exercised instead via XCL_TWO_PASS_MB=1024 and 256 overrides.
  • Steady-state post-load rendered gameplay frames past the upstream cold NVIDIA huge-PSO compilation stretch (presents pause after ~60–64 s on both nvidia-dev and this PR while 650 KB–1.5 MB compute/graphics PSOs compile) were not reached within the 120 s scripted world-loading runs, though live world-loading DispatchMesh and ExecuteIndirect(DispatchMesh) draws and DirectStorage streaming executed across all five runs.

AI use

  • T3 Code / Antigravity (gemini-pro-orchestrator-neon) and Codex (GPT-6.2 Sol) wrote and reviewed the budget-capping/fallback fixes, tests, and PR description; all builds, tests, smoke runs, and world-loading runs were executed directly on local hardware.

@ettehn

ettehn commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Independent Windows check on the clean stacked head c1bf0e82183fd477e9f4dbed24773e8097782cee (nvidia-dev base af2cecc40886a8682ecf3267f5328c6dc4b66ad7). Windows 11 build 26200, Ryzen 9 8945HX, RTX 5070 Ti Laptop 12 GB (driver 621.24), Rust 1.97.1 MSVC debug, XCL_ADAPTER=NVIDIA, XCL_TWO_PASS_MB unset.

  • Default heap setting: cargo test --locked --offline -p xcl --lib -j 2 -- hle::d3d12x::bind::tests:: hle::d3d12x::alloc_pool::tests:: --skip two_pass_binds_set_the_shared_view_heap --test-threads=1 --nocapture reported 53 passed, 0 failed, 0 ignored, no reported skips. This includes the fence reclaim and multi-queue tests, uncapped GPU feedback, and the scripted budget/wait/shrink cases. The ExecuteIndirect case logged the RTX 5070 Ti Laptop as its adapter.
  • Fresh process with XCL_HEAP_WINDOWS=1 XCL_REQUIRE_GPU=wave64: cargo test --locked --offline -p xcl --lib -j 2 -- hle::d3d12x::bind::tests::two_pass_binds_set_the_shared_view_heap --exact --test-threads=1 --nocapture reported 1 passed, 0 failed, 0 ignored, no reported skips. Both passes set the shared shader-visible heap in the binding fixture.

This covers the targeted synthetic tests on the 12 GB host. In-game tight-budget waits/shrinks, end-to-end rendering with heap windows, and the full workspace suite were outside this run.

OpenAI Codex assisted with verification.

@joeypercia

Copy link
Copy Markdown
Contributor

In the world on a 12 GB card, over its budget: this stack frees about 1 GB and makes about 98 % of the two-pass draws that were skipped. One run with the stack, against two without.

Setup: RTX 4070 Ti 12 GB (621.40), Ryzen 7 7800X3D, 32 GB RAM, Windows 11 26200, release.

without (05-37-51, 05-49-01) with #2815–#2817 (06-39-11)
two-pass draws not made 66,728 / 65,539 (past 1024 MiB) 1,395 (past 256 MiB, the headroom cap)
two-pass buffers alive at the end 81 (1,011 MiB) 93 (78 MiB)
waiting for allocator resets 568 / 641 MiB 0 MiB
buffers made / taken again / let go 370–377 / 1,937–2,013 / 289–296 3,735 / 1,566 / 3,642
peak video memory / budget (#2776's table) 15,928–16,006 / ~10,530 MB 14,971 / 10,547 MB
presents in the last ~240 s 58–59 57
device removed no no
  • On a card past its budget the headroom cap matters most. It shrank to 256 MiB (85 wait/shrink lines) instead of skipping 65k draws at a fixed 1 GiB.
  • Buffers are made ten times as often (3,735 against ~370), since fewer are kept. I didn't measure what that costs per frame.
  • The frame rate doesn't move: the title is still 4.4 GB past the budget, mostly target pages and sparse tiles ([OFFICIAL] Swarm: RAM and VRAM use down, towards stable 30 FPS on AMD and NVIDIA #2688), and that's what limits it here.

One run with the stack. (Claude Code, Claude Opus 5.5)

@DarkPanda69

DarkPanda69 commented Nov 26, 2026 •

Copy link
Copy Markdown

Update for head e70a708 (with the lock_warp_tests change): applies on nvidia-dev eae0150 again. bind + alloc_pool at --test-threads=4: no indirect_feedback_* failure in 14 runs on the RX 9070 XT or 4 on the RTX 3060 (82 passed each). One RX 9070 XT run had a single failure in dispatch_x_with_thread_dimensions_launches_whole_groups, which is an existing nvidia-dev test outside this diff. It didn't come back in 8 more runs, and nvidia-dev alone passed 8 of 8, so I can't say whether it is related; I didn't keep its panic message.

Update for head 4eea0ac: the flake didn't show up. Tested at the PR head (its base is still af2cecc, and the diff no longer applies on the newer nvidia-dev). hle::d3d12x::bind + alloc_pool at --test-threads=4: RX 9070 XT (XCL_ADAPTER=Radeon, so the hardware test runs) 6 of 6 runs 54 passed, 0 failed; RTX 3060 4 of 4 the same; one thread on the RX 9070 XT 3 of 3. At c1bf0e8 the same command failed in 4 of 6 runs on the RX 9070 XT, so this is a real change, but 10 clean runs don't prove the race is gone.


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. They pass every time on one thread.

Tested: head c1bf0e8 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: 4 of 6 runs failed (52 passed, 2 failed); the others 54 passed, 0 failed. With --skip gpu_scale_args_reports_uncapped_group_count_feedback, 4 of 6 still failed, so it is not that test.
  • NVIDIA RTX 3060, driver 32.0.16.1088: 1 of 4 runs failed, same two tests.
  • --test-threads=1 on the RX 9070 XT: 10 of 10 runs 54 passed, 0 failed.
  • Each of the two passes on its own by name. nvidia-dev without the PR: 42 passed, 0 failed.

The failures:

  • indirect_feedback_waits_for_submit_before_copyback panics at bind.rs:5127: assertion failed: !fb.dirty && !fb.copy_in_flight.
  • indirect_feedback_copyback_grows_on_clamp_and_decays_over_windows then panics at bind.rs:1442:37, the FEEDBACK.lock().unwrap() in poll_two_pass_feedback. In one run gpu_scale_args_reports_uncapped_group_count_feedback panicked at the same line with PoisonError, so after the first panic the FEEDBACK mutex is poisoned and the later feedback tests fail with it.

#2816 has the same two tests and the same failures: 1 of 6 runs on the RX 9070 XT, 1 of 4 on the RTX 3060. #2815 alone passed (46 passed, 0 failed).

One more thing I saw: the new gpu_scale_args_reports_uncapped_group_count_feedback matches XCL_ADAPTER against the adapter name with a case-sensitive contains, so XCL_ADAPTER=radeon skips it with no D3D12 hardware adapter on this AMD Radeon card. With XCL_ADAPTER=Radeon it runs and passes, on both cards. The existing gpu_two_pass_pooled_scratch_respects_remaining_budget on nvidia-dev skips the same way with radeon.

Not tested: a title run, TP_WAITED / TP_SHRUNK in play, release, XCL_HEAP_WINDOWS=1 (two_pass_binds_set_the_shared_view_heap SKIPPED), Intel.

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

@throny

throny commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator

Test report for the stack (#2815 + #2816 + this PR) in the world on an RTX 4080 16 GB: the buffers no longer wait for allocator resets and far fewer draws are skipped, but on a card that is over its budget the derived cap is 256 MiB and refusals come back as the run goes on.

Tested

without (run 14, 98 s of world) without (run 16, 435 s) with (run 18, 165 s) with (run 19, 297 s)
draws with translated pipelines 77,424 203,918 131,072 189,554
of them skipped 18,805 (24 %) 131,072 (64 %) 2,991 (2.3 %) 37,301 (19.7 %)
two-pass buffers alive 85 / 987 MiB 86 / 992 MiB 152 / 255 MiB 108 / 255 MiB
waiting for allocator resets 442 MiB 378 MiB 0 0
waiting for GPU fences – – 0 0
"not made past" the cap 18,805 past 1,024 MiB 136,784 past 1,024 MiB 3,354 past 256 MiB 58,193 past 256 MiB
waited / shrunk / indirect clamped – – 5 / 377 / 53 51 / 9,052 / 189
video memory at the end (budget 15.2 GB) 18.8 GB 19.5 GB 17.9 GB 18.7 GB
  • D3D12.X: reclaim two-pass buffers on submit fence completion #2815 does what it says here: nothing is left waiting for an allocator reset (378–442 MiB before), and the pool turns over (968 made, 896 taken again, 816 let go in run 18).
  • The cap: this card is 3 GB over its DXGI budget in the world, so the headroom is negative and the derived cap sits at its floor of 256 MiB, a quarter of the old default. The first 30 s of the world are almost free of refusals (2,991 skipped of 65,536 by 205 s in run 18, then none for two minutes), then they grow again: in run 19 from 2,145 at 272 s to 37,301 at 405 s. So on a card in this state the stack trades "1 GiB that is half idle" for "256 MiB that is all in use", which is better (20 % against 24–64 % skipped), but not yet "no draw skipped for lack of memory". A floor that depends on the card rather than on the headroom, or counting the freed 400 MiB against it, may be worth a look.
  • Two things that appeared in the runs with the stack and in none of the six earlier world runs of this card on the same branch; I can't say from two runs that the stack causes them:
    • GPU wait timeouts (GPU queue.Wait … did not complete within 5000 ms): 9 within 30 s around 303–333 s in run 18 (my run guard ended that run there), 14 around 360–390 s in run 19.
    • recorded last (a call into the driver stands still) twice in run 19 (265 s, 282 s).
      Both could be the "wait briefly on pending submit fences" path meeting a GPU that is seconds behind (this card spends 93 % of the submitting thread's time inside PresentX in the world, see D3D12.X: instrument submitting-thread call breakdown under XCL_LOOK_STATS=2 #2729's report), so they may be specific to an over-budget card.
  • Run 19 ended at 467 s with 0xc0000005 in the title's own code, no device removal; run 18 by my guard. Neither run lost the device (4 of 6 earlier runs did).
  • Frame rate unchanged: 0.21 presents/s in both.

Not tested

  • The three PRs one by one (only the whole stack), their unit tests and the suite, AMD, a card that is under its budget in the world (where the cap would be larger), and the picture: frame dumps time out in the world here (frame dump copy: not finished after 2000 ms), so I can't say whether the draws that are no longer skipped fill in the ground.

AI use: Claude Code (Claude Fable 5.2) ran this on the owner's machine and wrote the report.

@SlopTart

Copy link
Copy Markdown

Two Linux/Wine lanes on the full stack, both vendors, release profile. Nobody here has posted Linux numbers for this stack yet.

Lanes

  • A (AMD): Ryzen 9 9900X, 96 GB DDR5, RX 7900 XT 20 GB (Navi 31), Arch, kernel 7.2.15, Mesa 26.2.5 RADV, wine-11.0 (Proton), rustc 1.94.0
  • B (NVIDIA): i5-10600K, 16 GB DDR4, GTX 1070 8 GB, driver 550.163.01, Debian 13, stock wine-10.0, xvfb
    Both: cargo test --release --locked -p xcl --lib --target x86_64-pc-windows-gnu -- --test-threads=2 --skip gpu::, full env per lane (runner: Proton wine on A, /usr/bin/wine on B, WINEDLLOVERRIDES="d3d12,d3d12core,dxgi,d3d11,d3d10core=n,b", VKD3D_CONFIG=ignore_shared_fence, XCL_DXC_DIR set).

Suite verdicts (clean stack c1bf0e82 on base af2cecc4)

Lane Base af2cecc4 Stack c1bf0e82 Stack-introduced reds
A RDNA3/wine-11 869 pass / 6 fail 880 pass / 7 fail (4 ignored, 769 filtered) bind::wait_oldest_fenced_reclaims_in_flight_buffer_before_refusing (in-suite only)
B Pascal/wine-10 865 pass / 10 fail 877 pass / 10 fail none, identical red set

Flake, matches @DarkPanda69's parallel-only observation. On lane A, wait_oldest_fenced... (bind.rs:5192) is the only stack-added red: red in-suite 2 of 2 runs, green alone 3 of 3 (--exact). On lane B it is green in-suite and 2 of 2 alone. First run on A additionally aborted the test host: the bind.rs panic poisoned a mutex, then list_x::a_reset_while_the_last_submit_runs_records_on_another_pc_list hit PoisonError unwrapping at bind.rs:1442 inside a non-unwinding scope, thread caused non-unwinding panic. aborting., exit status: 9 (test binary, not the assertion). The rerun with --nocapture completed 880/7 instead. So on this stack the parallel flake can escalate to a host abort on the wine-11/Proton lane; the wine-10 lane never showed it.

Vendor-split, predates the stack. bind::gpu_two_pass_indirect_commands_keep_their_own_records is consistently red on the Pascal lane (red alone 3/3, at base and at stack), green everywhere on RDNA3. It is in the base's 10-red set on that box, so it is not caused by #2815-#2817, but it does mean two-pass-adjacent coverage is already dead on Pascal/wine-10 before this stack lands. Its sibling in-suite reds on that box (write_buffer_immediate_on_open_existing_heap_visible_to_cpu, descriptor_heap zero_sampler, texture_upload gpu_parts...) likewise vanish when the stack lands on the AMD lane.

Not tested: Windows, native Linux, the in-game evidence items.
AI use: Hermes agent (local Qwen-class) ran the tests and drafted this; I checked it before posting.

@Smokeyqdqd

Copy link
Copy Markdown

Independent RTX 3060 retest of the intermittent feedback failures on #2817. With four test threads, the original revision failed in 3 of 10 runs. The current PR head completed all 10 runs successfully.

Tested

Windows 11 build 26200, Ryzen 7 5800X, 32 GB RAM, RTX 3060 12 GB, NVIDIA 610.88, rustc 1.100.0 MSVC, debug. No tracked edits. Original PR revision c1bf0e82183fd477e9f4dbed24773e8097782cee, updated PR head 4eea0ac2c2ac18790ab624ddbbd9e301562088c7.

With XCL_ADAPTER=NVIDIA, XCL_TWO_PASS_MB and XCL_HEAP_WINDOWS unset, I ran:

cargo test --offline --locked -p xcl --lib -- hle::d3d12x::bind hle::d3d12x::alloc_pool --test-threads=4 --nocapture
  • Original, four threads: seven runs reported 54 passed, 0 failed, 0 ignored. Run 8 reported 52 passed, 2 failed, 0 ignored. Runs 7 and 10 aborted before the harness printed totals. All three failures hit the same assertion in indirect_feedback_waits_for_submit_before_copyback at bind.rs:5127 (!fb.dirty && !fb.copy_in_flight), followed by a poisoned mutex. In the two aborted runs the log also reports a non-unwinding panic and exit status 0xc0000409.
  • Updated head, four threads: 10/10 runs reported 54 passed, 0 failed, 0 ignored.
  • Same command with --test-threads=1: 3/3 runs on each revision reported 54 passed, 0 failed, 0 ignored.
  • All 26 runs above printed one explicit GPU skip: two_pass_binds_set_the_shared_view_heap (heap windows disabled). One additional four-thread run on the updated head with XCL_HEAP_WINDOWS=1 reported 54 passed, 0 failed, 0 ignored and zero SKIPPED lines.

Not tested

Retail gameplay, FPS, VRAM savings, full workspace suite or other adapters. These results cover the filtered tests on this machine.

AI use

Codex (GPT-6.2 Astra) ran the tests, checked the revision and logs, and drafted this report.

@thehollowedone

Copy link
Copy Markdown

Independent Windows/NVIDIA check of the current #2817 head 4eea0ac2 against its exact #2816 parent ebd9a37b. Clean tracked tree for each run. RTX 3080 Ti 12 GB (driver 621.35), Ryzen 7 9800X3D, Windows 11 build 26300, rustc 1.99.1 MSVC, DXC 1.8.2502.11.

With XCL_ADAPTER=NVIDIA, XCL_TWO_PASS_MB and XCL_HEAP_WINDOWS unset:

  • Head: cargo test --offline --locked -p xcl --lib hle::d3d12x::bind::tests -- --test-threads=4 — 46 passed, 0 failed, 0 ignored. One GPU SKIPPED notice for the opt-in heap-window case; that notice is not counted as coverage.
  • Head and parent, separately: cargo test --offline --locked --workspace --no-fail-fast -- --test-threads=4. Head: 1,756 passed, 7 failed, 48 ignored across 41 test targets, with 26 GPU SKIPPED notices. Parent: 1,751 passed, 7 failed, 48 ignored across 41 test targets, also with 26 GPU SKIPPED notices. The seven failed test names are identical on both revisions: one shader-cache test, two texture-upload tests, one mesh-stream test, one async-compute test, and two runs of the two-pass driver-cache test. This comparison found no new failing test on the top commit in this setup; it does not establish the cause of those seven failures.
  • In a fresh process with XCL_HEAP_WINDOWS=1, cargo test --offline --locked -p xcl --lib hle::d3d12x::bind::tests::two_pass_binds_set_the_shared_view_heap -- --exact --test-threads=1 --nocapture — 1 passed, 0 failed, 0 ignored, without a skip notice.

Not tested: a matched retail world-load run, sustained frame time, AMD/Intel, or Linux/Wine. These synthetic results do not establish the stack's in-world memory or draw-skip improvement on this card.

AI use: Codex (GPT-6.2 Sol) ran the tests, checked the current head and parent, compared failures, and drafted this report.

@throny throny mentioned this pull request Nov 26, 2026
@pvfreis

pvfreis commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

By reading only, not run, at 4eea0ac2 (base af2cecc4):

  1. A shrunk DispatchMesh draws part of its groups and is counted as run. Under cap pressure ensure_res_buffer now returns a buffer smaller than the need (bind.rs:1481-1489, acquire_res_buf_with_cap :453-470). dispatch_mesh then draws n = groups.min(record_groups(cap, ..)) (:1811-1812), warns for the first 8 only (:1819) and counts DRAWS (:1834). At af2cecc4 the same refusal counted DRAWS_SKIPPED; only needs above RECORD_MAX were cut this way. So "skipped" falls partly because draws become partial. The "shrunk" counter (:328) also counts ExecuteIndirect acquisitions (:1945) and no groups; throny's report above has 377 and 9,052 of them. A count of the groups dropped (or of cut draws) in the summary line would let [OFFICIAL] Swarm: RAM and VRAM use down, towards stable 30 FPS on AMD and NVIDIA #2688's evidence item 7 be judged.

AI use: Claude Code (Claude Opus 5.5) wrote this; Claude Fable 5.2 rechecked it; checked by a person before posting.

@thehollowedone

Copy link
Copy Markdown

Follow-up to the partial-draw review on current head 4eea0ac2: the shrink loop also skips a supported record-buffer size. record_buffer_bytes uses power-of-two and 1.5× half-step buckets, but acquire_res_buf_with_cap halves a 64 MiB request straight to 32 MiB. With 48 MiB of room, it could use the 48 MiB bucket. For 64 KiB records, record_groups then permits 768 rather than 512 of 1,024 requested groups. This improves the amount recorded under the same cap; it does not address the remaining partial draw or prove pixel correctness.

I added a focused D3D12 WARP allocation regression at this exact head. On the untouched code it failed, 0 passed / 1 failed: expected 48 MiB, got 32 MiB. Walking each bucket in order made it pass, 1 passed / 0 failed; the test also checked 48→32 MiB. cargo test --offline --locked -p xcl --lib acquire_res_buf -- --test-threads=1 then passed 3/3, with no skips. On Windows 11 build 26300, Ryzen 7 9800X3D, RTX 3080 Ti driver 621.35, rustc 1.99.1 MSVC, XCL_ADAPTER=NVIDIA, the candidate's cargo test --offline --locked --workspace --no-fail-fast -- --test-threads=4 reported 1,757 passed, 7 failed, 48 ignored across 41 targets, with 26 explicit GPU skip notices. Those are the same seven failing test names as my untouched-head run (1,756/7/48); the added pass is the new regression.

Candidate diff against `4eea0ac2`
diff --git a/crates/xcl/src/hle/d3d12x/bind.rs b/crates/xcl/src/hle/d3d12x/bind.rs
@@ -453,9 +453,15 @@ unsafe fn acquire_res_buf_with_cap(
     let dev_key = dev.as_raw() as usize;
     let mut cand = need;
     while cand > floor {
-        let next = record_buffer_bytes((cand / 2).max(floor));
+        // The buckets alternate between powers of two and 1.5× their half. Halving a power
+        // skips its 1.5× bucket, which may fit the cap and preserve more mesh groups.
+        let next = if cand.is_power_of_two() {
+            cand - (cand >> 2)
+        } else {
+            cand.next_power_of_two() >> 1
+        }.max(floor);
         if next >= cand || (existing_cap >= floor && next <= existing_cap) {
             break;
         }
@@ -5250,8 +5256,26 @@ void ms(uint3 g : SV_GroupID) { o.Store((v * 16u + g.x) * 4u, rec.Load(g.x * 4u)
         assert!(TWO_PASS[TP_SHRUNK].load(Ordering::Relaxed) > shrunk_before);
     }

+    #[test]
+    fn acquire_res_buf_uses_finer_bucket_when_it_fits_the_cap() {
+        let _warp_guard = lock_warp_tests();
+        let Some(dev) = warp_device_for_test() else { return };
+        let key = dev.as_raw() as usize;
+        while FREE_RES.lock().unwrap().take(key, 0, u64::MAX).is_some() {}
+        let tight_cap = TWO_PASS[TP_ALIVE].load(Ordering::Relaxed) + (48 << 20);
+        let buf = unsafe { acquire_res_buf_with_cap(&dev, 64 << 20, 64 << 10, 0, tight_cap, std::time::Duration::ZERO) }.unwrap().unwrap();
+        assert_eq!(buf.bytes, 48 << 20, "the next smaller bucket fits the available headroom");
+        assert_eq!(record_groups(buf.bytes, 64 << 10, 1), 768);
+        drop(buf);

+        let tight_cap = TWO_PASS[TP_ALIVE].load(Ordering::Relaxed) + (32 << 20);
+        let buf = unsafe { acquire_res_buf_with_cap(&dev, 48 << 20, 64 << 10, 0, tight_cap, std::time::Duration::ZERO) }.unwrap().unwrap();
+        assert_eq!(buf.bytes, 32 << 20, "the bucket below 48 MiB also fits");
+        drop(buf);
+    }

     #[test]
     fn acquire_res_buf_stops_shrinking_at_existing_buffer_size() {

Not tested: a retail title or GPU readback of the resulting mesh. AI use: Codex (GPT-6.2 Sol; GPT-6.2 Astra assisted source review) traced the bucket path, wrote and ran the local candidate and regression, and drafted this comment. I checked the diff and results before posting.

Reclaim retired and reset two-pass record, batch, and argument scratch
buffers when their recording's submit queue fences pass, without waiting
for the owning command allocator to reset. Guard fence polling against
device removal (`u64::MAX` / `FenceState::Removed`) so in-flight buffers
are never returned to the reuse pool on a lost device, keep closed command
lists' buffers intact across idle trims for Reset-less replay, and track
upstream `batch_buf` allocations through the same submit fences.

Part of xcl-dev#2688

Assisted-by: T3 Code / Antigravity (Gemini Pro Orchestrator Neon)
Assisted-by: Codex (GPT-6.2 Sol)
…uckets

Add 256 KiB half-step record buffer buckets and async GPU group-count
feedback for two-pass ExecuteIndirect draws (including deferred batch
mode), eliminate cold-start clamping so initial indirect draws keep
full capacity, keep active frustum-culled PSOs warm over a 16-window
history while dropping unused PSOs to 256 KiB, report exact clamped
command and dropped group counts, guard feedback readback against
device removal (`u64::MAX` / `q.Signal`), and bound reuse growth in
`ensure_res_buffer`.

Part of xcl-dev#2688

Assisted-by: T3 Code / Antigravity (Gemini Pro Orchestrator Neon)
Assisted-by: Codex (GPT-6.2 Sol)
Cap the two-pass pool dynamically at 25% of remaining DXGI local VRAM
headroom with a card-scaled floor `(local_budget / 32).clamp(256 MiB, 512 MiB)`
and a `min(local_budget / 4, 2048 MiB)` ceiling cached for 250 ms, remove
the `/ 2` reuse pool clamp in `put_free_bufs` that caused buffer churn,
retry oversized reuse candidates before waiting, bound submit-fence waits
at 10 ms with 250 ms timeout backoff and device-removal short-circuiting,
walk every 256 KiB half-step bucket while shrinking record buffers down
to a single record (avoiding unnecessary jumps past 1.5x steps) while
counting direct `DispatchMesh` cuts/drops, and let `XCL_TWO_PASS_BATCH`
halves and batch-buffer allocations fall back without polluting `TP_REFUSED`.

Part of xcl-dev#2688

Assisted-by: T3 Code / Antigravity (Gemini Pro Orchestrator Neon)
Assisted-by: Codex (GPT-6.2 Sol)
@thehollowedone

Copy link
Copy Markdown

Independent Windows/NVIDIA check of #2817 head e70a708b against its exact #2816 parent 862b1ed1. Clean tracked tree on each revision; RTX 3080 Ti 12 GB (driver 621.35), Ryzen 7 9800X3D, Windows 11 build 26300, rustc 1.99.1 MSVC, DXC 1.8.2502.11. XCL_ADAPTER=NVIDIA; XCL_TWO_PASS_MB and XCL_HEAP_WINDOWS unset for the matched suite. Each revision used its own writable scratch XCL_DXIL_CACHE.

  • Head: cargo build --offline --locked --workspace passed. cargo test --offline --locked -p xcl --lib hle::d3d12x::bind::tests -- --test-threads=4 --nocapture passed 74/0/0, with one explicit GPU skip for the opt-in heap-window case. In a fresh process with XCL_HEAP_WINDOWS=1, that exact test passed 1/0/0, with no skip.
  • Head and parent, separately: cargo test --offline --locked --workspace --no-fail-fast -- --test-threads=4 --nocapture. Head: 1,840 passed, 9 failed, 48 ignored across 45 test targets; parent: 1,830 passed, 9 failed, 48 ignored across 45 targets. Both logs have 26 GPU SKIPPED notices (21 no wave64, 3 refused per-lane forms, 2 no heap windows). Skips are not coverage.
  • The nine failing test instances have the same names on both revisions: gpu_compute_thread_limits_leave_the_lanes_past_them_out; 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; split_compute_prefers_the_offline_whole_pipeline in two targets; and two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs in two targets. This comparison found no new failing test on D3D12.X: cap two-pass buffers by DXGI headroom with wait and shrink #2817's top commit in this setup; it does not identify the causes of the existing failures.

Not tested: a retail title or matched world-load run on this card, in-game VRAM savings, draw completeness, frame content, AMD/Intel or Wine. The passing synthetic tests do not establish those outcomes.

AI use: Codex (GPT-6.2 Sol) ran the exact-head and parent tests, compared their outputs, and drafted this report. I checked each result and the revisions before posting.

@MatyEjsr

Copy link
Copy Markdown

Independent Windows/NVIDIA verification and source audit of PR #2817 at head e70a708bfcab1e806a8e81517124cb2f890479b2 (stacked on #2816 862b1ed1 / #2815 42532264, MERGEABLE onto current origin/nvidia-dev eae015021c639866ab061cdff2e9daf8ba9daac5).

System

  • OS: Windows 11 Pro for Workstations (build 26200, Developer Mode ON)
  • CPU / RAM: AMD Ryzen 7 7800X3D, 32 GB RAM (31 GiB usable)
  • GPU: NVIDIA GeForce RTX 3090 24 GB (driver 32.0.16.1742 / 617.42)
  • Toolchain: rustc 1.100.0 (0ef1bc386 2026-11-09), DXC 1.9.2602.17 (21d28f72)

Tested

  • cargo build --workspace -j 8 (debug): passed (18.71s).
  • cargo test -p xcl --lib -j 8 -- hle::d3d12x::bind hle::d3d12x::alloc_pool --test-threads=8 --nocapture: 82 passed; 0 failed; 0 ignored (including 1 SKIPPED: two_pass_binds_set_the_shared_view_heap: no heap windows (opt-in: XCL_HEAP_WINDOWS=1) -> 81 executed, 1 skipped). Identical result at --test-threads=4.
  • XCL_HEAP_WINDOWS=1 cargo test -p xcl --lib -- hle::d3d12x::bind::tests::two_pass_binds_set_the_shared_view_heap --exact --nocapture: 1 passed; 0 failed; 0 ignored.
  • cargo test --workspace -j 8 --no-fail-fast -- --test-threads=8 --nocapture (45 test binaries): 1840 passed; 9 failed; 48 ignored, with 29 explicit SKIPPED notices separated from passing coverage (21 no wave64, 3 wave32, per-lane form: refused, 2 no heap windows, 3 no d3d12SDKLayers.dll / no D3D12 debug layer).
  • Baseline check on origin/nvidia-dev (eae015021c639866ab061cdff2e9daf8ba9daac5) for those exact 9 failing tests: 0 passed; 9 failed; 0 ignored (all 9 are pre-existing on nvidia-dev: gpu_compute_thread_limits_leave_the_lanes_past_them_out, pieces_hold_the_texels_of_their_levels, gpu_parts_of_a_texture_go_up_and_the_rest_stays, console_ms_in_as_slot_and_ms_with_as_are_refused_cleanly, async_compute_pso_registers_real_pso_and_not_standin, split_compute_prefers_the_offline_whole_pipeline x2, two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs x2).
  • Source audit (crates/xcl/src/hle/d3d12x/bind.rs): confirmed prior review fixes on e70a708bfcab (TP_DIRECT_CUT / TP_DIRECT_GROUPS_DROPPED separation, full 1.5x half-step bucket walk down to floor, FenceState::Removed short-circuiting without timeout/backoff inflation, and batch_region / Halves -> Whole fallback without TP_REFUSED pollution). No duplicate open/merged PRs found.

Regression run
60s scripts/smoke.ps1 pair (origin/nvidia-dev eae01502 vs PR #2817 e70a708b, release, Developer Mode ON): 1576 vs 1599 frames shown (98.6%), 0 device removals, 0 crashes, 15284 MB vs 14760 MB peak commit (103.6%), local VRAM peak 6128 MB vs 6188 MB, non-local VRAM peak 4835 MB vs 4885 MB.

xcl-smoke v1
commit: eae015021c639866ab061cdff2e9daf8ba9daac5
gpu: NVIDIA GeForce RTX 3090
title: c1cc91a4
seconds: 60
exit: 0x0
frames shown: 1599 (PresentX 1599)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14760 MB
xcl-smoke v1
commit: e70a708bfcab1e806a8e81517124cb2f890479b2
gpu: NVIDIA GeForce RTX 3090
title: c1cc91a4
seconds: 60
exit: 0x0
frames shown: 1576 (PresentX 1576)
presents per 2 s (last 3): 61 60 60
device removals: 0
crashes: 0
peak commit: 15284 MB

Not tested

  • AMD GPUs / native wave64, Linux / Wine, natural < 12 GB DXGI VRAM budget pressure, and live two-pass mesh draws on the retail title (the 60s smoke window did not reach recomp_programs > 0 or emit D3D12.X: two-pass buffers: lines, so it verifies zero startup/memory/frame regression while the cap/wait/shrink paths are covered by the targeted D3D12/WARP tests and source audit).

AI use

  • Antigravity (agy) with gemini-pro-orchestrator-argon (audited by gemini-pro-orchestrator-argon) ran the local builds, test suites, retail smoke run, baseline failure check, and source audit, and drafted and audited this report.

@Decodere

Copy link
Copy Markdown
Contributor

Independent RTX 4060 (8 GB) / Windows 11 release verification of PR #2817 updated head e70a708bfcab1e806a8e81517124cb2f890479b2 (3 commits on merge-base nvidia-dev eae015021c639866ab061cdff2e9daf8ba9daac5; stacked on exact parent PR #2816 862b1ed1e7993ee0cab3ef19e33796a97b18c569). Natural 8 GB VRAM hardware data point; measurements and targeted test results only (not a full source review).

Setup

  • GPU: NVIDIA GeForce RTX 4060 (8 GB / 7956 MiB reported by D3D12, 6945 MB DXGI local video memory budget), driver 32.0.16.2114 (NVIDIA 621.14, WDDM 3.2)
  • CPU / RAM / OS: Intel Core i5-11400F (6 cores / 12 threads), 32 GB RAM (31.9 GiB usable), Windows 11 Home 26200
  • Toolchain / caches: rustc 1.100.0 (0ef1bc386 2026-11-09), DXC 1.9.2609.5, release builds, warm DXIL/pipeline caches, quiet machine (zero concurrent builds/tests during timed runs)
  • Workload: Retail workload title: 29640639 via scripts/smoke.ps1 -Seconds 60 (XCL_NETWORK=0, default flags, no input)

Targeted RTX 4060 release unit & GPU tests (e70a708b)

  • cargo test --release -p xcl --lib budget_two_pass_cap_scales_with_headroom_and_stays_bounded -- --nocapture: 1 passed, 0 failed, 0 ignored (0.00 s, 0 SKIPPED).
  • cargo test --release -p xcl --lib wait_oldest_fenced_reclaims_in_flight_buffer_before_refusing -- --nocapture: 1 passed, 0 failed, 0 ignored (0.01 s, 0 SKIPPED).
  • cargo test --release -p xcl --lib wait_oldest_fenced_advances_past_small_batch_to_reclaim_large_batch -- --nocapture: 1 passed, 0 failed, 0 ignored (0.01 s, 0 SKIPPED).
  • cargo test --release -p xcl --lib acquire_res_buf_shrinks_under_tight_cap_instead_of_skipping -- --nocapture: 1 passed, 0 failed, 0 ignored (0.02 s, 0 SKIPPED).
  • cargo test --release -p xcl --lib acquire_res_buf_uses_finer_bucket_when_it_fits_the_cap -- --nocapture: 1 passed, 0 failed, 0 ignored (0.02 s, 0 SKIPPED).
  • cargo test --release -p xcl --lib acquire_res_buf_stops_shrinking_at_existing_buffer_size -- --nocapture: 1 passed, 0 failed, 0 ignored (0.01 s, 0 SKIPPED).
  • cargo test --release -p xcl --lib hle::d3d12x::bind:: -- --test-threads=4 (3 consecutive parallel passes): 74 passed, 0 failed, 0 ignored on all 3 passes (0.33 s / 0.34 s / 0.35 s; 1 opt-in SKIPPED notice per run: two_pass_binds_set_the_shared_view_heap skipped without XCL_HEAP_WINDOWS=1).
  • cargo test --release -p xcl --lib hle::d3d12x::alloc_pool:: -- --test-threads=4 (3 consecutive parallel passes): 8 passed, 0 failed, 0 ignored on all 3 passes (0.20 s / 0.21 s / 0.21 s, 0 SKIPPED).

Paired 60 s RTX 4060 smoke (eae01502 / #2816 862b1ed1 vs #2817 e70a708b)

All three runs completed cleanly at steady 60/2 s pacing with 0 device removals and 0 crashes (e70a708b xcl.log: 6,179 / 6,118 MB peak/end local VRAM, 4,763 MB end non-local VRAM, 14,748 MB end commit, 19,294 translated draws / 1,024 dispatches with 0 skipped; note 0 two-pass buffer/draw log lines fired during this 60 s menu smoke, so the lower single-run peak commit 14912 vs 15926 MB on eae01502 should not be attributed to live headroom capping).

Merge-base nvidia-dev (eae01502):

xcl-smoke v1
commit: eae015021c639866ab061cdff2e9daf8ba9daac5
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1551 (PresentX 1551)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15926 MB

Exact parent PR #2816 (862b1ed1):

xcl-smoke v1
commit: 862b1ed1e7993ee0cab3ef19e33796a97b18c569
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1591 (PresentX 1591)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14994 MB

PR #2817 head (e70a708b):

xcl-smoke v1
commit: e70a708bfcab1e806a8e81517124cb2f890479b2
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1639 (PresentX 1639)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14912 MB

Limits of coverage

  • Full workspace test suite was not run on e70a708b (only the 6 targeted tests individually, 3 parallel --test-threads=4 passes each of bind:: and alloc_pool::, release build, and stacked 60 s smokes); two_pass_binds_set_the_shared_view_heap skipped without opt-in XCL_HEAP_WINDOWS=1.
  • Although this host is a natural 8 GB VRAM GPU (6945 MB DXGI budget, 6118 MB steady-state local VRAM during the menu smoke), the 60 s no-input menu/intro smoke did not enter the world or trigger live two-pass buffer pressure (0 two-pass log lines), so live in-world DXGI headroom wait/shrink/refuse transitions were exercised only by the 6 targeted release unit tests above rather than extended world play.
  • Single discrete NVIDIA 8 GB GPU (RTX 4060) on native Windows 11; no AMD, Intel, or Wine/Linux run on this host.

AI use

Ran the targeted release tests (including 3× --test-threads=4 concurrency passes), release build, and stacked quiet 60 s smoke runs with assistance from Google Antigravity (Gemini 4 Neon); all test counts, timings, memory figures, and smoke blocks were extracted directly from cargo test, xcl.log, and scripts/smoke.ps1 outputs.

@pvfreis

pvfreis commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Follow-up, by reading only at e70a708b: addressed. A DispatchMesh that draws fewer groups than asked because its record buffer is short now counts direct cut and the groups it dropped (bind.rs:2902-2904), and both are in the two-pass summary line (:377) next to the indirect counts, so #2688's item 7 can be judged from a run log.

AI use: Claude Code (Claude Opus 5.5) checked the new head and wrote this; Claude Fable 5.2 rechecked it; checked by a person before posting.

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.