Repository navigation
d3d12: keep pipeline wait budgets from moving backward - #2601
Conversation
Skip waiting when a recording thread arrives with an older frame number. Otherwise the older request can reset the budget and let the newer frame spend it again.
|
Reviewed head 2336020, merged with main c8bf0e7. All 8 pipeline::make unit tests passed in leonida-gpu (Windows 10, Rust 1.100.1). I also compared the reservation logic in isolation with a partly spent budget, in both shared and non-shared modes. With 60 ms already charged against a 100 ms limit for frame 42, the old main logic granted frame 41 another 100 ms. The updated logic granted frame 41 0 ms and left frame 42 with 40 ms. The next frame got the full 100 ms. CPU-only, no game files. AI-assisted. Codex (GPT-6). |
|
#2601 | head 2336020 (merged cleanly onto origin/main c8bf0e7) | Windows 11 (10.0.26200.9974), rustc 1.96.0 (ac68faa20 2026-05-25), MSVC 19.44.35228 (x64) | AI-assisted: yes Summary — PASSVerified Verification Details
|
timbot103
left a comment
There was a problem hiding this comment.
Reviewed head 233602088. The guard in d3d12/crates/leonida-gpu/src/pipeline/make.rs:443 gives older frame requests zero wait before changing the recorded frame or spend. The mutex serializes comparison, reset, and reservation for each budget. Saturating subtraction and the per-pipeline cap keep shared reservations within the remaining allowance, and completion accounts for the wait only if its frame still owns the budget.
The waiting path samples the process-wide unsigned frame counter in d3d12/crates/leonida-gpu/src/pipeline/make.rs:379. The counter starts at zero and advances independently of the pacing clock in d3d12/crates/leonida-gpu/src/frame.rs:76 and d3d12/crates/leonida-gpu/src/frame.rs:217. The relaxed atomic is sufficient for the frame number because the mutex protects the budget state. The patch reuses the existing Rust types and standard-library operations.
The regression at d3d12/crates/leonida-gpu/src/pipeline/make.rs:757 covers frame zero, a stale request after spending the current frame's budget, a repeat current-frame request, and the next frame in both wait modes.
Static audit only. No builds, tests, or GPU runs performed.
AI-assisted.
|
Verified by OreoFR — READY
AI-assisted (Claude Code, Claude Opus 5.5), run for OreoFR. |
|
Linux game-run follow-up for
The opening-sequence title card was sampled on main only. The sampled images and draw counts differ, so the numbers do not establish a same-scene performance effect. The PR test harness ended early after 163 s and stopped the runtime. A previous cold A/B on A separate test on newer main found a Series S presentation fallback in this Wine setup. I verified the compositor portion of #2577 separately and posted that result there. A visible open-world scene is still unverified. AI-assisted with OpenAI Codex (GPT-6). |
|
Follow-up with a visually matched opening marker on Linux. I tested
Both runs reached the visible 3D opening sequence and exited normally. The title card was first captured at 125 s and 130 s with a five-second capture cadence. One run per arm and differing draw loads leave the effect on FPS unresolved. This run did not show a reduction in the largest logged pipeline wait interval mean. The app-local compiler was needed to get comparable visible scenes. In a separate same-binary control on this base, adding only the official DXC DLL pair changed the max logged indirect clamp counter from 0 to 268 per frame and eliminated the two clamp creation failures. Compiler-side reproduction and GPU tests. AI-assisted with OpenAI Codex (GPT-6). |
|
RUN: PR #2601 (pipeline wait budgets cannot move backward) Heads: PR 2336020, main eedd72e (current origin/main at the time; main had moved from 4364a4f during the job). Merged locally with Command (d3d12/, MSVC target, vcvars64):
Machine: RTX 3090 24 GB, NVIDIA 621.40, Windows 11 (native D3D12 target). |
|
Merging. Head AI-assisted (Claude Code). |
… is left with nothing (D3D12-COLD-START-SKIPS) The shared frame budget was a reservation: the first recording thread to wait in a frame took all that was left of it, and every other thread of that frame (and any thread still on an older frame) got nothing, so its draw went out without a wait and was dropped as not made. On first starts (no pipeline book) 400 to 3,600 draws, dispatches and indirect executions a frame were dropped at the arrival in the world, and the character's head, drawn by a pass the title runs once, stayed missing for the run. - The frame's waits are counted once over the threads that wait at the same time: what passed while at least one thread waited. A thread that begins to wait while others do is left what is left at that count, so waits that overlap still cost the frame its budget once; the time a thread records between two waits is not counted; a thread on an older frame joins the current frame's waits and opens no budget of its own (ProjectLeonida#2601). On by default; LEONIDA_PIPELINE_WAIT_DEADLINE=0 reserves the frame's budget as before (no effect with LEONIDA_PIPELINE_WAIT_SHARED=0); LEONIDA_AB can turn it while the title runs. - A pipeline's own budget (LEONIDA_PIPELINE_WAIT_ONCE) is charged the same way, the real time once, not the threads' times added up, whatever the sharing of the frame's budget (LEONIDA_PIPELINE_WAIT_ONCE=0 turns that budget off). - The queue a wait moves its pipeline forward in and the budget a pipeline's waits count against are passed in, so that tests cover them; one line tells the rules in use at the first wait. AI-assisted: Claude Code (Claude Opus 5.5) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claimed in the coordination issue as: Keep an older frame request from resetting the Rust D3D12 pipeline wait budget
What and why
A recording thread can sample the frame number and reach the pipeline wait lock after a newer frame has already spent its budget. Resetting the budget on every frame-number change lets a delayed request for frame 41 reopen a spent budget for frame 42. Give stale requests zero wait time and keep the currently tracked frame's accounting intact.
Tested
pipeline::make::testsand the frame counter test passed on Windows 11 with Rust 1.98.1.cargo check --locked --offline --profile diag -p leonida --features diagnosticsand the changed-file game-data scan passed.GPUs tested: n/a (CPU-only regression and application check).
AI-assisted: Yes, with OpenAI Codex (GPT-6).
Checklist
mainand merges cleanly.