Repository navigation
D3D12.X: size two-pass indirect buffers from GPU feedback and finer buckets - #2816
coolpersonnn wants to merge 2 commits into
Conversation
|
Test note from porting this onto another
They all use the process-wide Caveat: this was on our port, not on |
|
Update for head Update for head 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. Tested: head
The two are As on #2817, Not tested: a title run, release, AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report. |
|
Confirmed the parallel test failure on the exact head
Base command: |
|
Ran the two-pass indirect feedback tests at System
Results
What this adds Not tested AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used. |
|
@coolpersonnn I reproduced a second fence-ordering case on exact The focused fixture delivers q0=15, q1=2, then delayed q0=10 through Results on Windows 10 19045, RTX 3090 Ti host, driver 621.40, rustc 1.98.1 MSVC. The test uses a WARP allocation and synthetic fence values. It inspects the actual scheduled wait list, without executing the copy.
The result establishes the stale readback dependency. Its effects on observed clamp counts, scene completeness, and device removal remain unmeasured. Codex (OpenAI GPT-6 family) wrote and executed the fixture and minimal correction. Focused patchdiff --git a/crates/xcl/src/hle/d3d12x/bind.rs b/crates/xcl/src/hle/d3d12x/bind.rs
index 7f2a8e8d..4e46301d 100644
--- a/crates/xcl/src/hle/d3d12x/bind.rs
+++ b/crates/xcl/src/hle/d3d12x/bind.rs
@@ -1268,8 +1268,11 @@ fn mark_indirect_feedback_used(dev_key: usize, fb_slot: u32, cap: u32, queue: us
fb.dirty = true;
if let Some((f, v)) = fence {
if let Some(m) = fb.pending_fences.iter_mut().find(|(q, ..)| *q == queue) {
- m.1 = f.clone();
- m.2 = v;
+ // The submit bookkeeping lock is released before these notifications.
+ if v > m.2 {
+ m.1 = f.clone();
+ m.2 = v;
+ }
} else {
fb.pending_fences.push((queue, f.clone(), v));
}
@@ -4949,6 +4952,41 @@ void ms(uint3 g : SV_GroupID) { o.Store((v * 16u + g.x) * 4u, rec.Load(g.x * 4u)
}
}
+ #[test]
+ fn feedback_copy_waits_for_the_newest_submit_on_each_other_queue() {
+ let _warp_guard = lock_warp_tests();
+ let Some(dev) = warp_device_for_test() else { return };
+ let dev_key = dev.as_raw() as usize;
+ let ids = Box::new([0u8; 4]);
+ let list = ids.as_ptr() as *mut c_void;
+ let q0 = (ids.as_ptr() as usize + 1) as *mut c_void;
+ let q1 = (ids.as_ptr() as usize + 2) as *mut c_void;
+ let copy_queue = ids.as_ptr() as usize + 3;
+ let (f0, _) = make_test_fence(13);
+ let (f1, _) = make_test_fence(1);
+
+ let (target0, target1) = unsafe {
+ reset(list, 0, 0);
+ let (_, slot, _) = prepare_indirect_feedback(&dev, 0x7700_0003).unwrap();
+ with(list, |s| s.fb_uses.push((dev_key, slot, 64)));
+ track_two_pass_list(list as usize);
+ two_pass_submitted(q0, Some(&f0), 15, &[list]);
+ two_pass_submitted(q1, Some(&f1), 2, &[list]);
+ two_pass_submitted(q0, Some(&f0), 10, &[list]);
+
+ let mut feedback = FEEDBACK.lock().unwrap().as_mut().unwrap().remove(&dev_key).unwrap();
+ let (_, _, _, waits) = feedback.schedule_copy(copy_queue).unwrap();
+ let target = |fence: &ID3D12Fence| {
+ waits.iter().find(|(f, _)| f.as_raw() == fence.as_raw()).map(|(_, value)| *value)
+ };
+ untrack_two_pass_list(list as usize);
+ forget(list);
+ (target(&f0), target(&f1))
+ };
+ assert_eq!(target1, Some(2));
+ assert_eq!(target0, Some(15), "copy and clear must wait for the newer producer");
+ }
+
#[test]
fn indirect_feedback_waits_for_submit_before_copyback() {
let _warp_guard = lock_warp_tests(); |
f163cdc to
ebd9a37
Compare
|
Re-ran the two-pass feedback tests at System
Results
What this adds Not tested AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used. |
|
By reading only, not run, at A two-pass AI use: Claude Code; Claude Opus 5.5 wrote it, Claude Fable 5.2 rechecked it |
ebd9a37 to
862b1ed
Compare
|
Independent RTX 4060 (8 GB) / Windows 11 release verification of PR #2816 updated head Setup
Targeted RTX 4060 release unit & GPU tests (
|
|
Follow-up, by reading only, not run, at AI use: Claude Code; Claude Opus 5.5 wrote it, Claude Fable 5.2 rechecked it; checked by a person before posting. |
|
Re-ran the two-pass feedback tests at System
Results
What this adds Not tested AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used. |
862b1ed to
4345fc8
Compare
|
Re-ran the two-pass feedback tests at System
Results
What this adds Not tested AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used. |
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)
4345fc8 to
9ae803e
Compare
|
Re-ran the two-pass feedback tests at System
Results
What this adds Not tested AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used. |
…uckets (port PR xcl-dev#2816) Port upstream PR xcl-dev#2816 (9ae803e / Part of xcl-dev#2688) onto rx580-mesh-vs-fallback: - Add 256 KiB half-step record buffer buckets (1.5x midpoints from 256 KiB to 128 MiB) in record_buffer_bytes, cutting worst-case rounding waste from 2x to 1.5x for all two-pass draws including VS pass-through uses_vs. - Bound reuse growth in ensure_res_buffer (prefer <= 2x need from FREE_RES before allocating, fall back to oversized free buffer on cap pressure). - Add async GPU group-count feedback infrastructure (IndirectFeedback, IndirectFeedbackSlot 16-window history, poll_two_pass_feedback from alloc_pool::executed) with device-removal guards (u64::MAX / q.Signal) and exact clamp/drop counters.
|
Follow-up independent desktop NVIDIA verification of PR #2816 at updated head Environment
Targeted release tests & build (
|
| Command | Result |
|---|---|
cargo test --release -p xcl --lib gpu_scale_args_reports_uncapped_group_count_feedback -- --nocapture |
1 passed; 0 failed; 0 ignored; 1732 filtered out (0.21s, on-GPU RTX 4060) |
cargo test --release -p xcl --lib indirect_feedback_ignores_readback_after_device_removal -- --nocapture |
1 passed; 0 failed; 0 ignored; 1732 filtered out (0.02s) |
cargo test --release -p xcl --lib hle::d3d12x::alloc_pool:: -- --test-threads=4 (3 consecutive runs) |
8 passed; 0 failed; 0 ignored; 1725 filtered out × 3 (0.20s, 0.20s, 0.20s) |
cargo test --release -p xcl --lib hle::d3d12x::bind:: -- --test-threads=4 (3 consecutive runs) |
66 passed; 0 failed; 0 ignored; 1667 filtered out × 3 (0.30s, 0.30s, 0.30s; 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 27s, 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 #2816 (9ae803e3952b4e2f68c206ae34950e59b6b5fadd):
xcl-smoke v1
commit: 9ae803e3952b4e2f68c206ae34950e59b6b5fadd
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1611 (PresentX 1611)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14944 MB
Runtime log observations (xcl.log)
9385log lines,0[ERROR]/ device-removal / panic lines.- Final draw/memory telemetry in log:
19219 draws with translated pipelines (0 skipped, 0 with PC pipelines), 1024 dispatches (0 skipped); last memory sample14776 MB committed by the process; video memory 6119 MB local, 4746 MB non-local; video memory budget 7022 MB.
Limits of coverage
- GPU indirect-feedback group-count reporting (
gpu_scale_args_reports_uncapped_group_count_feedback), device-removal readback guard (indirect_feedback_ignores_readback_after_device_removal), and finer bucket sizing passed 3/3 under parallel--test-threads=4runs ofalloc_pool::andbind::(two_pass_binds_set_the_shared_view_heapself-skipped becauseXCL_HEAP_WINDOWSis opt-in). - The 60 s menu capture on
title: 29640639logged0live two-pass indirect-feedback events and confirms clean runtime stability onnvidia-devrather than in-world two-pass VRAM savings; frame-count and peak-commit deltas vs. the cachedeae01502baseline 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).
|
Tested: Clean Not tested: Retail, workspace suite, retirement behavior from #2815 and DXGI headroom from #2817. AI use: T3 Code / Codex ( |
Size two-pass indirect mesh record buffers from async GPU group-count feedback and 256 KiB half-step buckets instead of worst-case static over-allocation.
Stacked on #2815; only the top commit belongs here.
Part of #2688
What is in it
crates/xcl/src/hle/d3d12x/alloc_pool.rs: pollpoll_two_pass_feedback()during allocator reclaim/trim so completed GPU feedback counters update before new indirect draws size their buffers.crates/xcl/src/hle/d3d12x/bind.rs:SCRATCH_BLOCKandRECORD_MINto256 << 10(256 KiB) with finer half-steprecord_buffer_bytesbuckets.indirect_record_need_hintso first-seen indirect PSOs keep full worst-case capacity rather than dropping initial geometry.FEEDBACK_HISTORY(ever_nonzero) inIndirectFeedbackSlotso active frustum-culled PSOs stay warm while truly unused PSOs decay down to 256 KiB (RECORD_MIN), and stop readback/feedback polling cleanly onFenceState::Removed(u64::MAX/q.Signalfailure).FEEDBACK_HEADER_U32S = 2) reporting exactTP_INDIRECT_CLAMPEDandTP_INDIRECT_GROUPS_DROPPEDdiagnostics, wire feedback intodefer_execute_indirect, bound oversized buffer reuse to[need .. need * 2]inensure_res_buffer, and add 4 unit/GPU tests (including matchinggpu_two_pass_pooled_scratch_respects_remaining_budgetWARP adapter expectations).+757/-79across the commit:514runtime lines viaalloc_pool.rs+2andbind.rs+465/-47, plus322test lines+290/-32): kept in one commit because the 256 KiB half-step buckets,IndirectFeedbackreadback/header clamp counters, HLSL scaling wiring, and removal/fence guards form one cohesive feedback-sizing change that would otherwise breakgit bisectacross partial states.Tested
9ae803e3, RTX 5090:cargo build --offline --locked -j 8 --workspacesucceeded.cargo test --offline --locked -j 8 --workspace --no-fail-fast -- --test-threads=4 --nocapturereported 1828 passed, 13 failed, 48 ignored, and 27 GPU skip notices. The failure names and counts match the earliernvidia-devbaseline. The idle-pool regression passed.4345fc85, RTX 5090:cargo build --offline --locked -j 6 --workspacesucceeded.cargo test --offline --locked -j 6 --workspace --no-fail-fast -- --test-threads=4 --nocapturereported 1827 passed, 13 failed, 48 ignored, and 27 GPU skip notices (excluded from coverage). All failures match the test names and counts in the earliernvidia-devrelease baseline below.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.862b1ed1:cargo test --offline --locked -p xcl --lib -- hle::d3d12x::bind hle::d3d12x::alloc_pool --test-threads=4(NVIDIA + WARP):72 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) on RTX 5090:862b1ed1(previous head):total_passed=1823, total_failed=13, total_ignored=48, skips=27(xcllib:1696 passed; 7 failed; 28 ignored).nvidia-dev(eae01502):total_passed=1812, total_failed=13, total_ignored=48, skips=27(xcllib:1685 passed; 7 failed; 28 ignored).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).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):862b1ed1produced1666frames (PresentX 1666),0device removals,0crashes,16149 MBpeak commit vsnvidia-deveae01502(1628frames,15793 MBpeak commit) andmainb49be183(1654frames,16446 MBpeak commit).Regression run
Not tested
nvidia-dev(eae01502) and the top of the stack (D3D12.X: cap two-pass buffers by DXGI headroom with wait and shrink #2817), not separately on this intermediate commit (targetedbind+alloc_pooltests ran on both NVIDIA and WARP here).0two-pass draws); world loading andExecuteIndirect(DispatchMesh)paths were verified in 120 s runs on top of the stack (D3D12.X: cap two-pass buffers by DXGI headroom with wait and shrink #2817) using synthetic menu-advance inputs.AI use
gemini-pro-orchestrator-neon) and Codex (GPT-6.2 Sol) wrote and reviewed the feedback-sizing fixes, tests, and PR description; all builds, tests, and smoke runs were executed directly on local hardware.gpt-6.2-sol) reproduced and fixed the fence-accounting race, added the regression test, and reran validation on the revised stack.gpt-6.2-sol) reproduced the idle-pool regression, applied the suggested fix and reran validation on the revised stack.