Repository navigation
D3D12.X: cap two-pass buffers by DXGI headroom with wait and shrink - #2817
coolpersonnn wants to merge 3 commits into
Conversation
|
Independent Windows check on the clean stacked head
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. |
|
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.
One run with the stack. (Claude Code, Claude Opus 5.5) |
|
Update for head Update for head 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
The failures:
#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 Not tested: a title run, AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report. |
|
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
Not tested
AI use: Claude Code (Claude Fable 5.2) ran this on the owner's machine and wrote the report. |
|
Two Linux/Wine lanes on the full stack, both vendors, release profile. Nobody here has posted Linux numbers for this stack yet. Lanes
Suite verdicts (clean stack
Flake, matches @DarkPanda69's parallel-only observation. On lane A, Vendor-split, predates the stack. Not tested: Windows, native Linux, the in-game evidence items. |
c1bf0e8 to
4eea0ac
Compare
|
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 With
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. |
|
Independent Windows/NVIDIA check of the current #2817 head With
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. |
|
By reading only, not run, at
AI use: Claude Code (Claude Opus 5.5) wrote this; Claude Fable 5.2 rechecked it; checked by a person before posting. |
|
Follow-up to the partial-draw review on current head 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. 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)
4eea0ac to
e70a708
Compare
|
Independent Windows/NVIDIA check of #2817 head
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. |
|
Independent Windows/NVIDIA verification and source audit of PR #2817 at head System
Tested
Regression run Not tested
AI use
|
|
Independent RTX 4060 (8 GB) / Windows 11 release verification of PR #2817 updated head Setup
Targeted RTX 4060 release unit & GPU tests (
|
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:(local_budget / 32).clamp(256 MiB, 512 MiB).min(ceiling)and amin(local_budget / 4, 2048 MiB)ceiling cached for 250 ms (XCL_TWO_PASS_MBstill overrides), and remove the/ 2reuse-pool clamp input_free_bufsthat caused buffer churn.wait_oldest_fenced_until,FENCE_WAIT_LIMIT = 10 ms) with250 mstimeout backoff andFenceState::Removedshort-circuiting (WaitStep::Stopped), and retry oversized reuse candidates before waiting.DispatchMesh/ExecuteIndirectrecord 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 directDispatchMeshfallback cuts/drops (TP_DIRECT_CUT,TP_DIRECT_GROUPS_DROPPED).XCL_TWO_PASS_BATCHhalves (Halves->Whole) and batch-buffer allocations (batch_region/try_make_with_cap) to fall back cleanly without pollutingTP_REFUSEDor prematurely skipping draws, plus 10 unit/GPU tests covering budget scaling, wait backoff, device removal, half-step shrink selection, and batch fallback.Tested
32.0.16.2101,32187 MiBVRAM, wave32 / split wave64), WARP (software renderer), AMD Ryzen 9 9950X3D, Windows 11 Pro (10.0.26300),rustc 1.100.0(0ef1bc386 2026-11-09), DXC1.8.2502.11.e70a708b:cargo test --offline --locked -p xcl --lib -- hle::d3d12x::bind hle::d3d12x::alloc_pool --test-threads=4(NVIDIA + WARP):82 passed; 0 failed(1opt-inSKIPPED:hle::d3d12x::bind::tests::two_pass_binds_set_the_shared_view_heap: no heap windows (opt-in: XCL_HEAP_WINDOWS=1)).XCL_HEAP_WINDOWS=1:two_pass_binds_set_the_shared_view_heap1 passed; 0 failed.cargo build --offline --locked --release --workspace && cargo test --offline --locked --release --workspace --no-fail-fast -- --test-threads=4):e70a708bon RTX 5090:total_passed=1833, total_failed=13, total_ignored=48, skips=27(xcllib:1706 passed; 7 failed; 28 ignored) vsnvidia-dev(eae01502):total_passed=1812, total_failed=13, total_ignored=48, skips=27.e70a708bon WARP (XCL_ADAPTER=warp):total_passed=1838, total_failed=6, total_ignored=48, skips=363(xcllib:1711 passed; 2 failed; 28 ignored) vsnvidia-dev(eae01502):total_passed=1817, total_failed=6, total_ignored=48, skips=364.nvidia-devbaseline (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_pipelinex2,two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobsx2); WARP's 6 failures match pre-existing baseline (texture_uploadx2,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).SKIPPEDGPU 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-inXCL_HEAP_WINDOWS=1skip above (1).scripts/smoke.ps1,title: a93b40d7, RTX 5090,XCL_PREPARE=0):e70a708bproduced1675frames (PresentX 1675),0device removals,0crashes,16201 MBpeak commit vsnvidia-deveae01502(1628frames,15793 MBpeak commit) andmainb49be183(1654frames,16446 MBpeak commit).title: a93b40d7(RTX 5090,XCL_PREPARE=0, syntheticAinputs entering live world loading withtwo-pass DispatchMeshandtwo-pass ExecuteIndirect(DispatchMesh),0device removals and0crashes across all 5 runs):nvidia-dev(eae01502, default1024 MiBcap):1426frames (PresentX 1426),83made /3taken again /0let go,83alive (1013 MiB),37 MiBwaiting for allocator resets,2420draws refused/skipped past1024 MiB, peak commit36712 MB, peak local VRAM15647 MB.e70a708b(default DXGI headroom ->2048 MiBcap):1432frames (PresentX 1432),105made /6taken again /3let go,102alive (1550 MiB),0 MiBwaiting for fences/resets,0refused/skipped draws,0warnings,0waits/timeouts,0clamped/cut/shrunk, peak commit39579 MB, peak local VRAM16221 MB.e70a708b(XCL_TWO_PASS_MB=1024):1428frames (PresentX 1428),71made /5taken again /2let go (69alive,1023 MiB),489shrunk,2317refused past1024 MiB,0waiting for fences/resets,0waits/timeouts, peak commit37568 MB.e70a708b(XCL_TWO_PASS_MB=256):1432frames (PresentX 1432),24made /3taken again /3let go (21alive,255 MiB),271shrunk,1direct cut (24groups dropped),10164refused past256 MiB,0waits/timeouts, peak commit35055 MB.e70a708b(XCL_TWO_PASS_BATCH=2):1415frames (PresentX 1415),60made /13taken again /3let go (57alive,2022 MiB,7kept for reuse385 MiB),478shrunk,3560refused past2048 MiB,0waits/timeouts, peak commit36466 MB.Regression run
Not tested
XCL_TWO_PASS_MB=1024and256overrides.presentspause after ~60–64 s on bothnvidia-devand 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-loadingDispatchMeshandExecuteIndirect(DispatchMesh)draws and DirectStorage streaming executed across all five runs.AI use
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.