d3d12: keep pipeline wait budgets from moving backward #2601
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2601"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ubiquitarianism/leonida. Originally posted by louisdibiasi on 2026-11-29T02:25:17Z.
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.Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-11-29T02:31:34Z.
Reviewed head
2336020880, merged with mainc8bf0e7b65. 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).
Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-29T03:01:00Z.
#2601 | head
2336020880(merged cleanly onto origin/mainc8bf0e7b65) | Windows 11 (10.0.26200.9974), rustc 1.96.0 (ac68faa20 2026-05-25), MSVC 19.44.35228 (x64) | AI-assisted: yesSummary — PASS
Verified
233602088041c9c2c75f724dbad187474e2cb286merged cleanly ontoorigin/main(c8bf0e7b6568f471b42540010e335ca6413d4c58,git merge-tree --write-treeexit0) on native Windows 11 (x64).Verification Details
d3d12/crates/leonida-gpu/src/pipeline/make.rs):origin/main,SPENTinitialized to(u64::MAX, Duration::ZERO)and reset wheneverspent.0 != frame, so a recording thread that sampledframe = N - 1before acquiringspent_ofafter another thread already advancedspent.0toNreset*spent = (N - 1, Duration::ZERO)(and the nextNwaiter reset it back to(N, Duration::ZERO)), reopening the full per-frame pipeline wait budget.CARGO_BUILD_JOBS=4,--test-threads=4):cargo test -p leonida-gpu --lib pipeline::make::tests -- --test-threads=4:test result: ok. 7 passed; 0 failed; 0 ignored; 0 measured; 564 filtered out; finished in 0.51sonorigin/main->test result: ok. 8 passed; 0 failed; 0 ignored; 0 measured; 564 filtered out; finished in 0.51s(13.75s) with#2601, includingpipeline::make::tests::older_frames_cannot_reopen_a_pipeline_wait_budget ... okacross bothshared = trueandshared = false.cargo check -p leonida-gpu --tests->0errors,0warnings.Imported from ubiquitarianism/leonida. Originally posted by timbot103 on 2026-11-29T04:29:16Z.
Review: COMMENTED
Reviewed head
233602088. The guard ind3d12/crates/leonida-gpu/src/pipeline/make.rs:443gives 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 ind3d12/crates/leonida-gpu/src/frame.rs:76andd3d12/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:757covers 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.
Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-29T05:47:24Z.
Verified by OreoFR — READY
c8bf0e7b6+ this PR (head233602088) merged with --no-ffreserve_frame_waitso the PR's test can call it:older_frames_cannot_reopen_a_pipeline_wait_budgetfails (left: (500ms, 500ms),right: (0ns, 0ns)), so an older frame reopens the budget. The other 7pipeline::maketests pass.cargo test -p leonida-gpu --lib pipeline::makeind3d12/: 8 passed, 0 failedSPENThas to start at 0 now thatframe < spent.0returns zero, and the end-of-wait accounting is unchanged.AI-assisted (Claude Code, Claude Opus 5.5), run for OreoFR.
Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-11-29T10:38:11Z.
Linux game-run follow-up for
233602088. I compared5844b6481with the same base plus this PR on a desktop RTX 4070 SUPER 12 GiB (NVIDIA 620.73.04, CachyOS, Wine 11.22, VKD3D-Proton71cae091, DXVK DXGI). Both runs were offline in Series S with frame generation off, the same input, copies of the same warm caches, and 500 ms for ordinary pipelines / 10 s for screen passes.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
54b2a81e9with the launcher's 10 s ordinary budget still showed waits around 10 s on both builds.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).
Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-11-29T11:27:49Z.
Follow-up with a visually matched opening marker on Linux. I tested
b589e0fe0+ the existing DXC compiler branch9075a5e419against the same build plus #2601 at233602088. Both used app-local DXC v1.9.2609, the same launcher and input, copies of the same warm caches and the 500 ms ordinary pipeline wait budget. Series S, Wine 11.22, VKD3D-Proton71cae091, DXVK DXGI, RTX 4070 SUPER, NVIDIA 620.73.04, CachyOS.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).
Imported from ubiquitarianism/leonida. Originally posted by enlight3d on 2026-11-29T18:35:28Z.
RUN: PR #2601 (pipeline wait budgets cannot move backward)
Heads: PR
233602088, maineedd72e30(current origin/main at the time; main had moved from4364a4fa6during the job). Merged locally withgit merge --no-ff(clean,make.rsauto-merged, nothing pushed). No conflict with #2566.Command (d3d12/, MSVC target, vcvars64):
cargo test -j 6 -p leonida-gpu --lib(andolder_framesalone for the red),cargo check -j 6 -p leonida-gpu --tests.reserve_frame_waitput back to the old rule, any frame different from the stored one resets the budget):older_frames_cannot_reopen_a_pipeline_wait_budgetFAILED atmake.rs:805(left: (500ms, 500ms), right: (0ns, 0ns)): a delayed older frame got a fresh budget. Restored afterwards. (Reverting only the non-test code is a build failure: the test calls the new function.)--libsuite 545 passed, 0 failed, 47 ignored. Plain main: 544 passed, 0 failed, 47 ignored (the difference is the new test).cargo check -p leonida-gpu --testson the merged tree: clean.Machine: RTX 3090 24 GB, NVIDIA 621.40, Windows 11 (native D3D12 target).
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-29T18:59:52Z.
Merging. Head
233602088has red/green verdicts from reviewers other than the author (above), merges cleanly withmain7c66bc52e, does not force a rebase of #2566, and carries a claim ID. Remaining main CI reds (translator-testsmesh,semantic-testsf16) are pre-existing. Merged by MoonEyes.AI-assisted (Claude Code).