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.
  • While the two-pass cap wait polls a pending fence, rescan completed batches on other queues at 1 ms intervals and retry acquisition when a batch is reclaimed. The WARP regression completes the later queue after polling switches from yielding to sleeping. Review report

Tested

  • RTX 5090, updated head a2c10b4a. cargo build --offline --locked -j 6 --workspace succeeded. cargo test --offline --locked -j 6 --workspace --no-fail-fast -- --test-threads=4 --nocapture reported 1839 passed, 13 failed, 48 ignored, and 27 GPU skip notices. The new regression passed. The failure names and counts match the previous head and the earlier nvidia-dev baseline.
  • The targeted WARP regression failed on bc82371e with the test harness alone (0 passed, 1 failed). With the fix, cargo test --offline --locked -j 4 -p xcl --lib -- wait_oldest_fenced later_queue_completion_during_sleep_reclaims_before_wait_deadline fence_wait_timeout --test-threads=1 --nocapture reported 5 passed, 0 failed. Both invocations had zero skips.
  • Earlier head bc82371e, RTX 5090: cargo build --offline --locked -j 8 --workspace succeeded. cargo test --offline --locked -j 8 --workspace --no-fail-fast -- --test-threads=4 --nocapture reported 1838 passed, 13 failed, 48 ignored, and 27 GPU skip notices. The failure names and counts match the earlier nvidia-dev baseline. The idle-pool regression passed.
  • Earlier head 9afb55e8, RTX 5090: cargo build --offline --locked -j 6 --workspace succeeded. cargo test --offline --locked -j 6 --workspace --no-fail-fast -- --test-threads=4 --nocapture reported 1836 passed, 14 failed, 48 ignored, and 27 GPU skip notices (excluded from coverage). Additional reported failures compared with that earlier release baseline: hle::d3d12x::sparse::tests::a_tile_decommitted_and_committed_again_keeps_its_video_memory. The sparse tile test passed 5/5 standalone reruns on the same head.
  • Full workspace repeat on 9afb55e8, same RTX 5090 and command: 1837 passed, 13 failed, 48 ignored, 27 GPU skip notices. The sparse tile test passed; the 13 failure names and counts match the earlier nvidia-dev baseline.
  • 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: a2c10b4a6d5f0463b69d10e8edde21a85dcaa3cb
gpu: NVIDIA GeForce RTX 5090
title: a93b40d7
seconds: 60
exit: 0x0
frames shown: 1632 (PresentX 1632)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 17223 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.
  • T3 Code, Codex (gpt-6.2-sol) reproduced and fixed the fence-accounting race, added the regression test, and reran validation on the revised stack.
  • T3 Code, Codex (gpt-6.2-sol) reproduced the idle-pool regression, applied the suggested fix and reran validation on the revised stack.
  • T3 Code, Codex (gpt-6.2-sol) adapted the review's fence rescan to elapsed time, reproduced the late completion, and reran the workspace suite and retail smoke.

@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 a2c10b4: clean. On the newer nvidia-dev eff3bca, bind + alloc_pool at --test-threads=4: RX 9070 XT 6 of 6 runs and RTX 3060 4 of 4 runs 85 passed, 0 failed (neither of the two rare failures below showed up).

Update for head bc82371: two rare single failures at --test-threads=4, neither reproducible on demand. On nvidia-dev eae0150, bind + alloc_pool, 24 runs on this head (14 RX 9070 XT, 10 RTX 3060), 84 passed each except:

  • the new records_for_falls_back_to_whole_before_shrinking_halves failed once (RX 9070 XT);
  • dispatch_x_with_thread_dimensions_launches_whole_groups failed once (RTX 3060). That is its second failure with this PR (once on e70a708 above). nvidia-dev alone: 0 failures in 22 runs.

I didn't catch the panic text for either (14 more runs, all clean, while trying). I didn't run single-threaded on this head.

Update for head 9afb55e: clean. On nvidia-dev eae0150, bind + alloc_pool at --test-threads=4: RX 9070 XT 6 of 6 runs and RTX 3060 4 of 4 runs 83 passed, 0 failed.

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
Contributor

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
Contributor

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.

@thehollowedone

Copy link
Copy Markdown
Contributor

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

MatyEjsr commented Nov 26, 2026 •

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.

@coolpersonnn
coolpersonnn force-pushed the ws2/two-pass-budget-fallback branch from e70a708 to 9afb55e Compare November 26, 2026 21:26
Sweep expired reusable buffers even when an allocator releases no
buffers of its own. The WARP regression seeds the free pool, then
checks it directly after an unrelated allocator release.

Suggested-by: thehollowedone (xcl-dev#2815 (comment))

Publish the retired batch and its byte charge under the same lock. Otherwise reclamation can subtract a batch before the publisher adds its bytes.

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)
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)
@coolpersonnn
coolpersonnn force-pushed the ws2/two-pass-budget-fallback branch from 9afb55e to bc82371 Compare November 26, 2026 22:12
pedrocalazans05 added a commit to pedrocalazans05/xcl that referenced this pull request Nov 26, 2026
…port PR xcl-dev#2817)

Port upstream PR xcl-dev#2817 (bc82371 / Part of xcl-dev#2688) onto rx580-mesh-vs-fallback:
- Add real::video_memory_info() exposing DXGI local VRAM budget alongside usage.
- Dynamically cap two-pass pool at 25% of remaining DXGI local headroom with floor (local_budget / 32).clamp(256 MiB, 512 MiB) and ceiling min(local_budget / 4, 2048 MiB) cached for 250 ms (overridable via XCL_TWO_PASS_MB).
- Update put_free_bufs to retain up to two_pass_cap().min(FREE_RES_CAP) without halving churn.
- Add bounded submit-fence wait (10 ms limit, 250 ms timeout backoff cleared on reclaim, device-removal short-circuit) and half-step bucket shrinking down to a single record before refusing, counting direct DispatchMesh cuts/drops for both uses_vs and hardware MS pass-through.
@thehollowedone

Copy link
Copy Markdown
Contributor

I found a wait-path stall on exact #2817 head bc82371ee25fa81577173a05c1b255ed2a4ffebf, relative to its #2816 parent 9ae803e. Under the two-pass cap, wait_oldest_fenced_until polls only the oldest batch's marks. If a later batch on another queue finishes while that fence remains pending, its reusable buffer is not reclaimed until the full wait deadline. The end-of-wait reclaim then reports progress, so timeout backoff does not engage; subsequent recordings can repeat the stall. The production wait limit is 10 ms per attempt.

I reproduced this with a test-only WARP schedule: queue A keeps a small buffer pending; queue B holds the requested 64 MiB buffer and completes after the eighth poll of A. A stays pending. With the PR logic unchanged, cargo test --offline --locked -p xcl --lib later_completed_queue_reclaims_without_waiting_for_oldest -- --test-threads=1 --nocapture failed (0 passed, 1 failed, 0 ignored, 0 skipped) after 249 polls of A. The test uses a 100 ms deadline so the distinction is deterministic; it does not claim a measured 10 ms retail stall.

The local candidate rechecks all fenced batches at bounded intervals while polling A, then retries acquisition when a batch is reclaimed. The same test passed (1/0/0/0). cargo test --offline --locked -p xcl --lib hle::d3d12x::bind::tests -- --test-threads=4 then reported 77 passed, 0 failed, 0 ignored, with one explicit SKIPPED opt-in heap-window test (so 76 executed). This is a focused candidate, not a merge or retail verdict; the full workspace suite and paired smoke runs have not been run for it.

Windows 11 build 26300, Ryzen 7 9800X3D, rustc 1.99.1 MSVC. WARP executed the new fixture; the RTX 3080 Ti was present but was not used by that fixture. Synthetic inputs only.

Candidate fix and regression diff
diff --git a/crates/xcl/src/hle/d3d12x/bind.rs b/crates/xcl/src/hle/d3d12x/bind.rs
index 12e3c5ea..8716ac85 100644
--- a/crates/xcl/src/hle/d3d12x/bind.rs
+++ b/crates/xcl/src/hle/d3d12x/bind.rs
@@ -474,6 +474,12 @@ fn wait_oldest_fenced_until(deadline: std::time::Instant) -> WaitStep {
                     if matches!(unsafe { fence_state(fence, *value) }, FenceState::Removed) {
                         return WaitStep::Stopped;
                     }
+                    // A later batch on another queue may have completed while this oldest
+                    // fence remains pending; do not spend the entire wait budget on it.
+                    if polls % 64 == 0 && reclaim_fenced() > 0 {
+                        note_two_pass(TP_WAITED);
+                        return WaitStep::Progressed;
+                    }
                     if std::time::Instant::now() >= deadline {
                         timed_out = true;
                         break 'wait;
@@ -7289,9 +7295,15 @@ void ms(uint3 g : SV_GroupID) { o.Store((v * 16u + g.x) * 4u, rec.Load(g.x * 4u)
         // Complete only the fences this test has registered, once allocation actually waits.
         static FENCES_TO_SIGNAL_ON_WAIT: std::cell::RefCell<Vec<(ID3D12Fence, Arc<AtomicU64>)>> =
             const { std::cell::RefCell::new(Vec::new()) };
+        static FENCE_WAIT_POLLS: std::cell::Cell<u32> = const { std::cell::Cell::new(0) };
+        static FENCE_SIGNAL_AFTER_POLLS: std::cell::Cell<u32> = const { std::cell::Cell::new(1) };
     }
 
     pub(super) fn signal_fence_on_wait(fence: &ID3D12Fence) {
+        let poll = FENCE_WAIT_POLLS.with(|n| { let poll = n.get() + 1; n.set(poll); poll });
+        if poll < FENCE_SIGNAL_AFTER_POLLS.with(|n| n.get()) {
+            return;
+        }
         FENCES_TO_SIGNAL_ON_WAIT.with_borrow_mut(|signals| {
             if let Some(index) = signals.iter().position(|(test, _)| test.as_raw() == fence.as_raw()) {
                 let (_, value) = signals.swap_remove(index);
@@ -7411,6 +7423,58 @@ void ms(uint3 g : SV_GroupID) { o.Store((v * 16u + g.x) * 4u, rec.Load(g.x * 4u)
         assert_eq!(got_raw, Some(large_raw));
     }
 
+    #[test]
+    fn later_completed_queue_reclaims_without_waiting_for_oldest() {
+        let _warp_guard = lock_warp_tests();
+        WAIT_BACKOFF_UNTIL_MS.store(0, Ordering::Release);
+        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 ids = Box::new([0u8; 8]);
+        let (l1, l2) = (ids.as_ptr() as *mut c_void, (ids.as_ptr() as usize + 1) as *mut c_void);
+        let (a1, a2, a3) = (ids.as_ptr() as usize + 2, ids.as_ptr() as usize + 3, ids.as_ptr() as usize + 4);
+        let (q1, q2) = ((ids.as_ptr() as usize + 5) as *mut c_void, (ids.as_ptr() as usize + 6) as *mut c_void);
+
+        reset(l1, a1, 0);
+        let old = unsafe { TwoPassBuf::make(&dev, RECORD_MIN, "old queue") }.unwrap();
+        with(l1, |s| s.res_buf = Some(old));
+        track_two_pass_list(l1 as usize);
+        let (f1, v1) = make_test_fence(0);
+        unsafe { two_pass_submitted(q1, Some(&f1), 1, &[l1]) };
+        reset(l1, a3, 0);
+
+        reset(l2, a2, 0);
+        let size = 64 << 20;
+        let needed = unsafe { TwoPassBuf::make(&dev, size, "needed queue") }.unwrap();
+        let needed_raw = needed.res.as_raw() as usize;
+        with(l2, |s| s.res_buf = Some(needed));
+        track_two_pass_list(l2 as usize);
+        let (f2, v2) = make_test_fence(0);
+        unsafe { two_pass_submitted(q2, Some(&f2), 1, &[l2]) };
+        reset(l2, a3, 0);
+
+        let cap = TWO_PASS[TP_ALIVE].load(Ordering::Relaxed) + (8 << 20);
+        FENCE_WAIT_POLLS.with(|n| n.set(0));
+        FENCE_SIGNAL_AFTER_POLLS.with(|n| n.set(8));
+        // B completes after polling A begins; A remains pending throughout acquisition.
+        FENCES_TO_SIGNAL_ON_WAIT.with_borrow_mut(|signals| signals.push((f1, v2)));
+        let got = unsafe { acquire_two_pass_buf_with_cap(&dev, size, size * 2, u64::MAX, "needed queue", cap, std::time::Duration::from_millis(100)) }.unwrap();
+        let polls = FENCE_WAIT_POLLS.with(|n| n.get());
+        let got_raw = got.as_ref().map(|b| b.res.as_raw() as usize);
+
+        v1.store(1, Ordering::Release);
+        drop(got);
+        reclaim_fenced();
+        while FREE_RES.lock().unwrap().take(key, 0, u64::MAX).is_some() {}
+        forget(l1);
+        forget(l2);
+        WAIT_BACKOFF_UNTIL_MS.store(0, Ordering::Release);
+        FENCE_SIGNAL_AFTER_POLLS.with(|n| n.set(1));
+        FENCES_TO_SIGNAL_ON_WAIT.with_borrow_mut(|signals| signals.clear());
+        assert_eq!(got_raw, Some(needed_raw));
+        assert!(polls <= 65, "completed later queue must be noticed promptly, not after {polls} polls of the older pending fence");
+    }
+
     #[test]
     fn acquire_res_buf_shrinks_under_tight_cap_instead_of_skipping() {
         let _warp_guard = lock_warp_tests();

AI use: Codex (GPT-6.2 Sol) wrote the candidate and regression, ran the tests, and drafted this report. Codex (GPT-6.2 Astra) reviewed the fence and reclamation schedule.

@Decodere

Copy link
Copy Markdown
Contributor

Follow-up independent desktop NVIDIA (natural 8 GB VRAM) verification of PR #2817 at updated head bc82371ee25fa81577173a05c1b255ed2a4ffebf (3 stacked commits 42ae6051 -> 9ae803e3 -> bc82371e on nvidia-dev merge-base eae015021c639866ab061cdff2e9daf8ba9daac5; parent 9ae803e3952b4e2f68c206ae34950e59b6b5fadd). This supersedes our earlier check at e70a708b after the stacked update adding timeout backoff, non-churn free-buffer retention, and whole-before-shrink fallback (bc82371e).

Environment

  • GPU: NVIDIA GeForce RTX 4060 (8 GB / 7956 MiB reported by D3D12, 7012 MB DXGI local video memory budget observed in this run), driver 32.0.16.2114 (NVIDIA 621.14, WDDM 3.2)
  • CPU / RAM / OS: Intel Core i5-11400F (6C / 12T), 32 GB RAM (31.9 GiB usable), Windows 11 Home 26200 (Developer Mode off)
  • Toolchain: rustc 1.100.0 (0ef1bc386 2026-11-09) MSVC, DXC 1.9.2609.5, --release

Targeted release tests & build (bc82371e)

Command Result
cargo test --release -p xcl --lib fence_wait_timeout_backs_off_subsequent_waits_until_reclaim -- --nocapture 1 passed; 0 failed; 0 ignored; 1742 filtered out (0.02s)
cargo test --release -p xcl --lib put_free_bufs_retains_buffers_up_to_cap_without_halving_churn -- --nocapture 1 passed; 0 failed; 0 ignored; 1742 filtered out (0.01s)
cargo test --release -p xcl --lib records_for_falls_back_to_whole_before_shrinking_halves -- --nocapture 1 passed; 0 failed; 0 ignored; 1742 filtered out (0.01s)
cargo test --release -p xcl --lib hle::d3d12x::alloc_pool:: -- --test-threads=4 (3 consecutive runs) 8 passed; 0 failed; 0 ignored; 1735 filtered out × 3 (0.20s, 0.20s, 0.21s)
cargo test --release -p xcl --lib hle::d3d12x::bind:: -- --test-threads=4 (3 consecutive runs) 76 passed; 0 failed; 0 ignored; 1667 filtered out × 3 (0.33s, 0.33s, 0.33s; two_pass_binds_set_the_shared_view_heap self-skipped because XCL_HEAP_WINDOWS is opt-in)
cargo build --release -p xcl --bin xcl Clean build (1m 28s, exit 0)

Paired quiet 60 s retail smoke (title: 29640639)

Merge-base on nvidia-dev (eae015021c639866ab061cdff2e9daf8ba9daac5, cached baseline on the same machine):

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

PR #2817 (bc82371ee25fa81577173a05c1b255ed2a4ffebf):

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

Runtime log observations (xcl.log)

  • 9387 log lines, 0 [ERROR] / device-removal / panic lines.
  • Final draw/memory telemetry in log: 19303 draws with translated pipelines (0 skipped, 0 with PC pipelines), 1024 dispatches (0 skipped); last memory sample 14759 MB committed by the process; video memory 6117 MB local, 4748 MB non-local; video memory budget 7012 MB.

Limits of coverage

  • DXGI headroom capping, wait-oldest-fenced reclamation, timeout backoff, non-churn free-buffer retention, and whole-before-shrink fallback all passed 3/3 under parallel --test-threads=4 runs of alloc_pool:: and bind:: (76/0/0 in bind::; two_pass_binds_set_the_shared_view_heap self-skipped because XCL_HEAP_WINDOWS is opt-in).
  • The 60 s menu capture on title: 29640639 logged 0 live two-pass allocations and stayed below the 7012 MB local VRAM budget (6117 MB local used), confirming clean 8 GB runtime behavior on nvidia-dev without exercising live in-world VRAM-pressure shrinking; frame-count and peak-commit deltas vs. the cached eae01502 baseline reflect normal single-run startup/worker variance and are not attributed to this PR.

AI disclosure: test execution and report drafting assisted by Google Antigravity (Gemini 4 Neon).

Reclaim completed batches on other queues at elapsed-time intervals
during the cap wait. One pending fence must not hide a reusable
record buffer until the wait deadline. The WARP regression completes
the later batch after polling changes from yields to sleeps.

Reported-by: thehollowedone (xcl-dev#2817 (comment))
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)
@coolpersonnn
coolpersonnn force-pushed the ws2/two-pass-budget-fallback branch from bc82371 to a2c10b4 Compare November 26, 2026 23:14
@andrewDoing

Copy link
Copy Markdown

PR #2817 — late completion on a second queue

The proposed 64-poll rescan can miss a reusable buffer until the next 64-poll boundary. In a WARP fixture, queue A stayed pending and queue B's 64 MiB buffer became reusable on poll 70. The published candidate returned the correct buffer on poll 129. After the initial yields, each unsuccessful poll requests a 200 µs sleep, so 64 such sleeps alone span at least 12.8 ms. Production uses a 10 ms wait budget. The observed defect concerns when a ready buffer is noticed. Both fixtures check that the acquired buffer is the expected one. Original report and candidate

Revision under test B completes on poll 8 B completes on poll 70
Unchanged production head Failed, 253 polls Failed, 254 polls
Published 64-poll candidate Passed within 65 polls Failed, 129 polls
Elapsed-time refinement Passed within 65 polls, 5/5 Passed within 90 polls, 5/5

The refinement checks all fenced batches once at the yield-to-sleep transition and again after 1 ms has elapsed since the previous scan. A successful reclaim retries acquisition. The existing fence-completion predicates still govern reuse, including multi-queue marks. The scan runs before the deadline check, so scan time and scheduler delays can still extend the wait. The 1 ms interval has not been benchmarked for CPU cost or lock contention with large queues.

The fixtures use WARP allocations and deterministically advanced test fences, a 100 ms deadline and serial execution. No retail workload, physical GPU scheduling, or production wall-clock latency was measured. The refinement's bind module run reported 78 passed, zero failed and zero ignored, including one explicit heap-window skip. The full suite and retail smoke pair remain untested. Baseline log · Published candidate log · Refinement log · Bind module log

Reproduce on Windows

Use a separate checkout of bc82371ee25fa81577173a05c1b255ed2a4ffebf for each arm. Apply exactly one complete patch to each clean checkout. All three patches were verified with git apply --check, applied to the exact upstream source, and compared with the source that produced these results.

Arm Complete patch
Unchanged production code plus both fixtures Baseline patch
Published change plus both fixtures Published candidate patch
Timed refinement plus both fixtures Refinement patch
git apply <path-to-one-complete-patch>
cargo test --locked -p xcl --lib later_completed_queue -- --test-threads=1 --nocapture

At review time on November 26, the live PR remained at this head. The original report's early schedule was the latest of 14 conversation comments. No public follow-up covering the poll-70 case or formal review was visible. PR discussion

@andrewDoing

Copy link
Copy Markdown

Independent budget-pressure check on RTX 5070, NVIDIA driver 616.92; Ryzen 7 5700X3D; Windows build 26300.10075; Rust 1.100.0 MSVC, debug. The test-only fixture supplied a native device and queried the real DXGI budget, with no guest or rendering.

On the same adapter (LUID confirmed), allocated 3,520 MiB of non-pool local heaps and then released them; sampled after 350 ms to cross the 250 ms refresh period. Reported process usage rose from 9,371,648 to 3,700,359,168 bytes and returned to 9,371,648 bytes. The reported local budget was 11,717,836,800 bytes.

  • Parent 9ae803e3: automatic cap stayed at 1,024 MiB.
  • PR head bc82371ee25fa81577173a05c1b255ed2a4ffebf: automatic cap went from 2,048 MiB to 2,004,369,408 bytes (about 1,911.5 MiB) under pressure, then back to 2,048 MiB after release.
  • Head with XCL_TWO_PASS_MB=256: cap stayed at 256 MiB throughout.

Each arm passed its fixture with 0 failures, 0 ignored and no reported skips. This tests cap calculation on a 12 GB adapter; it does not measure GTA VI's actual VRAM use, performance or stability.

AI use: OpenAI Codex with GPT-6.2 Astra built the test-only fixture and ran the comparison; Codex coordinated and prepared this report.

@andrewDoing

Copy link
Copy Markdown

Retested the late-fence case from my earlier review on updated head a2c10b4a6d5f0463b69d10e8edde21a85dcaa3cb. The exact upstream WARP regression passed in five fresh runs (5 passed, 0 failed, 0 ignored, no reported skips). It exercises a later queue completing after the wait enters its sleep phase and checks reclamation before the modeled 10 ms deadline.

The bind module reported 77 passed, 0 failed and 0 ignored, including one explicit opt-in heap-window skip. This validates the synthetic schedule, not retail frame-time impact or queue-scan overhead.

AI use: OpenAI Codex with GPT-6.2 Astra inspected the updated code and ran the tests; Codex coordinated and prepared this report.

@JJAutoCompare

Copy link
Copy Markdown

Tested: Clean a2c10b4a6d5f0463b69d10e8edde21a85dcaa3cb, Windows 11 build 26200, Ryzen 7 3800X, Intel Arc A770 driver 32.0.101.9175, Rust 1.100.0 MSVC, debug. cargo test --offline --locked -j 2 -p xcl --lib --no-run, then focused hle::d3d12x::bind::tests filters in the built binary. Six CPU capacity/record-sizing tests and five WARP allocation tests passed. WARP covered 64→48 MiB and 48→32 MiB shrinking, the existing-buffer cutoff, pool retention and whole-buffer fallback. On Arc, gpu_two_pass_pooled_scratch_respects_remaining_budget passed and reported 512 KiB taken against a 16 MiB cap. All three groups had zero failures, ignores and skips.

Not tested: Live DXGI pressure, retail behavior or full suite.

AI use: T3 Code / Codex (gpt-6.2-sol) ran and reran the checks and wrote this report.

@Decodere

Copy link
Copy Markdown
Contributor

Follow-up independent desktop NVIDIA (natural 8 GB VRAM) verification of PR #2817 at updated head a2c10b4a6d5f0463b69d10e8edde21a85dcaa3cb (3 stacked commits 42ae6051 -> 9ae803e3 -> a2c10b4a on nvidia-dev merge-base eae015021c639866ab061cdff2e9daf8ba9daac5, MERGEABLE against live nvidia-dev ecc0bb57), superseding our earlier bc82371e check.

Environment

  • GPU: NVIDIA GeForce RTX 4060 (8 GB / 7956 MiB reported by D3D12), driver 32.0.16.2114 (NVIDIA 621.14, WDDM 3.2)
  • CPU / RAM / OS: Intel Core i5-11400F (6C / 12T), 32 GB RAM (31.9 GiB usable), Windows 11 Home 26200 (Developer Mode off)
  • Toolchain: rustc 1.100.0 (0ef1bc386 2026-11-09) MSVC, DXC 1.9.2609.5, --release

Targeted release tests & build (a2c10b4a)

Command Result
cargo test --release -p xcl --lib later_queue_completion_during_sleep_reclaims_before_wait_deadline -- --nocapture (3 consecutive runs) 1 passed; 0 failed; 0 ignored; 1743 filtered out × 3 (0.02s × 3, 0 skipped)
cargo test --release -p xcl --lib hle::d3d12x::bind:: -- --test-threads=1 (3 consecutive runs) 77 passed; 0 failed; 0 ignored; 1667 filtered out × 3 (0.66s, 0.65s, 0.66s; 76 executed + 1 self-skipped two_pass_binds_set_the_shared_view_heap: no heap windows (opt-in: XCL_HEAP_WINDOWS=1))
cargo test --release -p xcl --lib hle::d3d12x::alloc_pool:: -- --test-threads=1 (3 consecutive runs) 8 passed; 0 failed; 0 ignored; 1736 filtered out × 3 (0.28s, 0.30s, 0.28s, 0 skipped)
cargo build --release -p xcl Clean build (1m 37s, exit 0, 0 new warnings in bind.rs/alloc_pool.rs)

Paired quiet 60 s retail smoke (title: 29640639)

Exact nvidia-dev merge-base (eae015021c639866ab061cdff2e9daf8ba9daac5, cached baseline on the same machine):

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

PR #2817 (a2c10b4a6d5f0463b69d10e8edde21a85dcaa3cb, XCL_TWO_PASS_MB unset):

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

Runtime log observations (xcl.log)

  • 9390 log lines, 0 [ERROR] / device-removal / panic lines.
  • Final draw/memory telemetry in log: 19303 draws with translated pipelines (0 skipped, 0 with PC pipelines), 1024 dispatches (0 skipped); last memory sample 14651 MB committed by the process; video memory 6119 MB local, 4811 MB non-local.
  • 0 two-pass cap-refusal / wait / shrink warnings triggered during the 60 s run on title: 29640639.

Limits of coverage

  • The new periodic cross-queue fence-reclaim rescan (FENCE_WAIT_RESCAN_INTERVAL in wait_oldest_fenced_until) and the full stacked #2815–#2817 headroom-cap / wait / shrink logic were verified via later_queue_completion_during_sleep_reclaims_before_wait_deadline (3/3), hle::d3d12x::bind:: (76 executed + 1 opt-in XCL_HEAP_WINDOWS=1 skip × 3), and hle::d3d12x::alloc_pool:: (8/8 × 3).
  • This 60 s startup smoke on title: 29640639 does not enter heavy two-pass VRAM pressure (0 two-pass wait/shrink log lines), so it confirms zero runtime regression on a natural 8 GB RTX 4060 rather than reproducing over-budget world-load two-pass contention (frame-count and peak-commit deltas vs. cached eae01502 reflect single-run startup variance, not this PR). Full CI workspace coverage (note: GitHub Build and test (Windows, no GPU) is currently failing on a2c10b4a) was not run here.

AI disclosure: test execution and report drafting assisted by Google Antigravity (Gemini 4 Neon).

@3L1A5-1

3L1A5-1 commented Nov 27, 2026

Copy link
Copy Markdown

8 GB NVIDIA under real world-load pressure (the case the RTX 4060 smoke above didn't reach): the cap holds two-pass buffers at ≤256 MiB with nothing left waiting, the run lasts longer, but local video memory as a whole is not lower. One run, so the timing is indicative.

Tested

Results

without this PR (3 runs) with this PR (1 run)
Two-pass buffers alive ~1,021 MiB (+ ~724 MiB waiting for fences / allocator resets) 224–256 MiB at every sample, 0 MiB waiting
End device removed 0x887a0005 at title 262–272 s (2 runs); the third stopped presenting at 241 s Close failed with E_OUTOFMEMORY (0x8007000e) at title 339.6 s, no device-removed line
Local video memory peak 11.5–11.7 GB, +4.3 to +4.5 GB over a ~7.2 GB budget 11.5 GB, +4.3 GB over budget
Free physical RAM, minimum 91–169 MB 86 MB
  • What the cap cost in this run (from its own log lines): 59,730 buffers not made, 120 indirect commands clamped (4,724 groups dropped), 163 direct dispatches cut (4,952 groups dropped), 13,767 buffers shrunk, 1 wait timed out. I couldn't judge the picture: the screenshots in that phase were blank.
  • So on this card the ~1.5 GB the cap saves is taken by other allocations, and the overall overcommit stays. The end moved from a device removal to a host-side E_OUTOFMEMORY at Close, with free RAM near zero. The later end is within what I'd call noise for one run (the base alone ranged 241–300+ s).

Not tested: repeats, the picture under the clamps, AMD.

AI use: runs and log analysis by Claude Code agents (Claude Sonnet 5.5), report written and checked against the run logs by Claude Code (Claude Opus 5.5).

@LocranKing

Copy link
Copy Markdown

Independent paired measurements of the #2815 → #2816 → #2817 two-pass mesh stack on an 8 GB RTX 3060 Ti (7,256 MB DXGI local VRAM budget).

Setup

  • Machine: Windows 11 Home build 26300, AMD Ryzen 5 5500 (6C/12T), 31.8 GB RAM, NVIDIA GeForce RTX 3060 Ti (8 GB, driver 621.40, nvprofile shader heap 2048 MB), DXC 1.9.2602.17.
  • Title & cache: Retail title 9cc6a39e, release builds, each PR head merged cleanly with origin/nvidia-dev (ecc0bb57), 180 s each, all starting from identical copies of a warm lockhart cache snapshot (1,296 used pipelines, 3,206 driver blobs).
  • Env: XCL_DEVICE_TYPE=lockhart XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_TEXTURE_LEVEL_PAGES=1 XCL_PSO_WAIT_MS=50 XCL_GFX_PSO_WAIT_MS=200 XCL_CS_PSO_WAIT_MS=50 XCL_PREPARE_GRAPHICS=0 XCL_DRED=1 + XCL_PRESS_AT (18:A..74:A).

Summary (180 s paired runs)

tree frames (PresentX) peak commit local / non-local VRAM peak two-pass alive two-pass skipped past cap indirect clamped
nvidia-dev (ecc0bb57) 1,825 27,125 MB 9,773 / 4,914 MB 92 (1,023 MiB; 414 MiB reset wait) 42,663 (1024 MiB cap) –
#2815 (42ae6051 + ecc0bb57) 1,805 25,765 MB (-1,360) 9,524 / 4,758 MB 41 (631 MiB; 0 MiB fence/reset wait) 2,554 (1024 MiB cap, -94%) –
#2816 (9ae803e3 + ecc0bb57) 1,775 25,178 MB (-1,947) 8,565 / 4,904 MB 42 (13 MiB; 5 MiB reuse) 0 (1024 MiB cap) 0 (0 groups)
#2817 (a2c10b4a + ecc0bb57) 1,789 24,516 MB (-2,609) 8,429 / 4,653 MB 33 (18 MiB) 0 (256 MiB DXGI-scaled cap) 4 (184 groups dropped)

All four runs exited 0x0 with 0 device removals and 0 crashes, and all entered the 3D world (first_2pass_mesh_t = 112.9–133.0 s). On an 8 GB card, #2816 + #2817 cut two-pass live allocations from 1,023 MiB → 13–18 MiB, eliminated all 42,663 skipped two-pass draws, and reduced peak commit by 2.61 GB and peak local VRAM by 1.34 GB.

xcl-smoke v1 blocks (180 s each)
xcl-smoke v1
commit: ecc0bb57976b1bc94854199ddf4f915fd00e0a59
gpu: NVIDIA GeForce RTX 3060 Ti
title: 9cc6a39e
seconds: 180
exit: 0x0
frames shown: 1825 (PresentX 1825)
presents per 2 s (last 3): 1 1 1
device removals: 0
crashes: 0
peak commit: 27125 MB
xcl-smoke v1
commit: 42ae60514ad2b3aaad5e940e2ad3b7bcc595d9b9
gpu: NVIDIA GeForce RTX 3060 Ti
title: 9cc6a39e
seconds: 180
exit: 0x0
frames shown: 1805 (PresentX 1806)
presents per 2 s (last 3): 0 2 1
device removals: 0
crashes: 0
peak commit: 25765 MB
xcl-smoke v1
commit: 9ae803e3952b4e2f68c206ae34950e59b6b5fadd
gpu: NVIDIA GeForce RTX 3060 Ti
title: 9cc6a39e
seconds: 180
exit: 0x0
frames shown: 1775 (PresentX 1775)
presents per 2 s (last 3): 1 0 2
device removals: 0
crashes: 0
peak commit: 25178 MB
xcl-smoke v1
commit: a2c10b4a6d5f0463b69d10e8edde21a85dcaa3cb
gpu: NVIDIA GeForce RTX 3060 Ti
title: 9cc6a39e
seconds: 180
exit: 0x0
frames shown: 1789 (PresentX 1790)
presents per 2 s (last 3): 1 1 1
device removals: 0
crashes: 0
peak commit: 24516 MB

Not tested: longer runs past 180 s on #2815–#2817, Series X (anaconda), AMD GPUs.

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.