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 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 |
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)
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. |
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
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(this PR):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.