GPU: a pipeline is waited for in one frame only (#1181) #1234

Open
github-bot wants to merge 1 commit from github-bot/gh-1234 into main AGit
Owner

@⁠milesah3ad on GitHub · 2026-11-26 01:02 UTC · original
milesah3ad:pipeline-wait-once → main · +62 −3 · 1 files · 1 commits · open

@⁠fxceless — requesting your review and merge.

Fixes the steady-state stall in #1181: a pipeline the worker has not made within a frame's wait budget was waited for again in every frame that drew with it, each time for the whole VICTORY_PIPELINE_WAIT_MS (500 ms). In play this reads as the game freezing while you move, and un-freezing after opening the pause menu (no world draws there, so the worker catches up).

Change

crates/victory-gpu/src/pipeline/make.rs only (+60/−3):

  • Pending gets waited_frame: the first title frame that waited for it. A pipeline is waited for in one frame; later frames drop its draws until it is made, exactly as draws past the budget are dropped today.
  • The claim is taken under the existing budget lock and only when the frame has budget left, so a pipeline first bound after another one spent the frame's budget keeps its wait for a later frame (the issue BradRoland found in #867).
  • VICTORY_PIPELINE_WAIT_EVERY_FRAME=1 restores the old behaviour.
  • Two unit tests: a pipeline already waited for in an earlier frame returns at once; the claim belongs to the first frame (same frame may wait again, a later one may not).

Credit: the one-frame cap is powplusplus' (#867 — which also carries unrelated changes that removed the device for HrHd); claiming only with budget left is BradRoland's correction posted on #867. This PR is just that piece, on its own.

Tests

  • cargo test -p victory-gpu --locked: 195 passed, 1 failed — watch::tests::written_pages_are_reported_to_every_asker, which fails the same way on main (a183ea2) here, without this change.
  • The new test fails on the old behaviour: with VICTORY_PIPELINE_WAIT_EVERY_FRAME=1 it waits 510 ms and fails; with the fix it returns immediately.
  • cargo clippy --all-targets --all-features: nothing in make.rs (the existing errors on main remain; #841).

In the game

RTX 5080 16 GB (wave32), driver 621.24, Ryzen 7 9800X3D, 64 GB, Windows 11 26300, Series X profile, release build of this branch (on 006c353) + VICTORY_RELAY=1 VICTORY_TEXTURE_BACK=1 VICTORY_FRAME_LOG=1, cold pipeline cache.

stretch pipelines being made waited in the usual frame world fps
first world frames 745 → 86 500 → 120 ms (each new pipeline's one wait) 1.1–1.9
after that, ~4 min moving around 0 0.0 ms in 27 of 30 frame-log lines (others 0.3, 2.2, 18.2 ms) median 4.0 (1.8–4.9, 38 samples ≥1,000 draws)

The tester reported play as "very smooth and steady" where the previous build froze whenever the character moved. I did not run an A/B on this exact tree without the change, so the before side is #1181's measurement (500 ms waited every world frame with 4 stuck pipelines) plus the tester's experience on an earlier build.

Note on the cold start: with hundreds of first-time pipelines every frame still finds a new one to wait for, so the budget is spent until they are made (first row). That is the existing design and unchanged here.


AI-assisted (Claude Code, Claude Opus 5.5): the change, tests and measurements were prepared with it; a person ran the game, judged the result and asked for this PR to be opened.

🤖 Generated with Claude Code

**@⁠milesah3ad** on GitHub · 2026-11-26 01:02 UTC · [original](https://github.com/fxceless/victory-fork/pull/1234) `milesah3ad:pipeline-wait-once` → `main` · +62 −3 · 1 files · 1 commits · open @⁠fxceless — requesting your review and merge. Fixes the steady-state stall in #1181: a pipeline the worker has not made within a frame's wait budget was waited for again in **every** frame that drew with it, each time for the whole `VICTORY_PIPELINE_WAIT_MS` (500 ms). In play this reads as the game freezing while you move, and un-freezing after opening the pause menu (no world draws there, so the worker catches up). ## Change `crates/victory-gpu/src/pipeline/make.rs` only (+60/−3): - `Pending` gets `waited_frame`: the first title frame that waited for it. A pipeline is waited for in **one** frame; later frames drop its draws until it is made, exactly as draws past the budget are dropped today. - The claim is taken under the existing budget lock and **only when the frame has budget left**, so a pipeline first bound after another one spent the frame's budget keeps its wait for a later frame (the issue BradRoland found in #867). - `VICTORY_PIPELINE_WAIT_EVERY_FRAME=1` restores the old behaviour. - Two unit tests: a pipeline already waited for in an earlier frame returns at once; the claim belongs to the first frame (same frame may wait again, a later one may not). Credit: the one-frame cap is powplusplus' (#867 — which also carries unrelated changes that removed the device for HrHd); claiming only with budget left is BradRoland's correction posted on #867. This PR is just that piece, on its own. ## Tests - `cargo test -p victory-gpu --locked`: 195 passed, 1 failed — `watch::tests::written_pages_are_reported_to_every_asker`, which fails the same way on `main` (`a183ea2`) here, without this change. - The new test **fails on the old behaviour**: with `VICTORY_PIPELINE_WAIT_EVERY_FRAME=1` it waits 510 ms and fails; with the fix it returns immediately. - `cargo clippy --all-targets --all-features`: nothing in `make.rs` (the existing errors on `main` remain; #841). ## In the game RTX 5080 16 GB (wave32), driver 621.24, Ryzen 7 9800X3D, 64 GB, Windows 11 26300, Series X profile, release build of this branch (on `006c353`) + `VICTORY_RELAY=1 VICTORY_TEXTURE_BACK=1 VICTORY_FRAME_LOG=1`, cold pipeline cache. | stretch | pipelines being made | `waited` in the usual frame | world fps | |---|---|---|---| | first world frames | 745 → 86 | 500 → 120 ms (each new pipeline's one wait) | 1.1–1.9 | | after that, ~4 min moving around | 0 | **0.0 ms** in 27 of 30 frame-log lines (others 0.3, 2.2, 18.2 ms) | **median 4.0** (1.8–4.9, 38 samples ≥1,000 draws) | The tester reported play as "very smooth and steady" where the previous build froze whenever the character moved. I did not run an A/B on this exact tree without the change, so the before side is #1181's measurement (500 ms waited every world frame with 4 stuck pipelines) plus the tester's experience on an earlier build. Note on the cold start: with hundreds of first-time pipelines every frame still finds a new one to wait for, so the budget is spent until they are made (first row). That is the existing design and unchanged here. --- AI-assisted (Claude Code, Claude Opus 5.5): the change, tests and measurements were prepared with it; a person ran the game, judged the result and asked for this PR to be opened. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
A pipeline the worker has not made within a frame's wait budget (a slow or
stuck driver compile) was waited for again in every frame that drew with it,
each taking the whole budget (VICTORY_PIPELINE_WAIT_MS, 500 ms): world frames
waited 500 ms each while four pipelines stayed MAKING (#1181), felt in play as
a freeze while moving that the pause menu (no world draws) let go.

Now the first frame with budget left claims the pipeline's one wait; later
frames drop its draws until it is made, as past the budget before. The claim
is taken under the budget lock and only with time left, so a pipeline first
bound after another spent the frame's budget keeps its wait for a later
frame. VICTORY_PIPELINE_WAIT_EVERY_FRAME=1 restores the old behaviour.

The one-frame cap is from powplusplus' #867; claiming only with budget left
is BradRoland's correction posted there.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:00:05 +00:00
Author
Owner

@⁠milesah3ad on GitHub · 2026-11-26 02:10 UTC · original

Rebased onto fc63ce1. a35c557 added formats and variant to Pending, next to this PR's waited_frame; the conflict was only that. Both are kept, and each format variant is its own Pending, so it gets its own single wait like any other pipeline.

One fix to the test, too: it marked the pipeline as waited "in the frame before" with frame.wrapping_sub(1), which at frame 0 (the test run alone) is u64::MAX, the "not waited yet" sentinel, so the run alone waited and failed. It now uses frame.wrapping_add(1). Run alone: 6/6 in pipeline::make; with VICTORY_PIPELINE_WAIT_EVERY_FRAME=1 the test still fails after a 500 ms wait, as it should.

Full cargo test -p victory-gpu: passes, apart from watch::tests::written_pages_are_reported_to_every_asker, which fails intermittently here on main too (one run 200/200, the next 199/200).

AI-assisted (Claude Code).

**@⁠milesah3ad** on GitHub · 2026-11-26 02:10 UTC · [original](https://github.com/fxceless/victory-fork/pull/1234#issuecomment-7180527463) Rebased onto `fc63ce1`. `a35c557` added `formats` and `variant` to `Pending`, next to this PR's `waited_frame`; the conflict was only that. Both are kept, and each format variant is its own `Pending`, so it gets its own single wait like any other pipeline. One fix to the test, too: it marked the pipeline as waited "in the frame before" with `frame.wrapping_sub(1)`, which at frame 0 (the test run alone) is `u64::MAX`, the "not waited yet" sentinel, so the run alone waited and failed. It now uses `frame.wrapping_add(1)`. Run alone: 6/6 in `pipeline::make`; with `VICTORY_PIPELINE_WAIT_EVERY_FRAME=1` the test still fails after a 500 ms wait, as it should. Full `cargo test -p victory-gpu`: passes, apart from `watch::tests::written_pages_are_reported_to_every_asker`, which fails intermittently here on `main` too (one run 200/200, the next 199/200). *AI-assisted (Claude Code).*
Author
Owner

@⁠ArturoWolff on GitHub · 2026-11-26 07:21 UTC · original

Independent, game-free scheduler comparison on the receiving fxceless tree. This supports the one-frame wait cap, but also gives a reason to keep the policy for a once-only compute dispatch separate from that for an ordinary draw.

Setup and provenance: receiver 46bf5351707b1697c04e5d871c30973ebaa3e973, native Linux Rust 1.98.1, separate source trees and Cargo targets. I exercised the actual pipeline/make.rs worker queue, condition variable and ready() implementation in a small Rust adapter. Only host pipeline construction, the frame counter, library bookkeeping and the Windows/Wine-specific environment interfaces are replaced by synthetic fixtures; no D3D12, title data, shader conversion, driver cache or GPU. Each scenario starts in a fresh process. VICTORY_PIPELINE_WAIT_MS=80, shared budget on, with explicit compute-policy selection. The shorter render budget makes the test cheap, not a proposed in-game setting.

The four arms are clean receiver; the exact change from this PR at 7195775ba6f09a797b7523c749c7d8b558255a7f; the compute-wait policy only from Beqren's #129, c0fdca08d3446294336cfb6d59c2dbaa2cced69a with the concurrent-caller follow-up da4cee66b2a7d2fe1339c08f5b1a6732082f7de5; and the combination. Credit for the one-frame cap and budget-claim correction also goes to powplusplus and BradRoland (#867), as noted in the PR. The compute change on this receiver keeps its existing graphics wait, worker queue and logging style. I am testing the readiness policy, not the other #129 changes or the reworked branch now in draft.

Measured:

Controlled case Receiver #1234 only Compute wait only Both
Waits for one still-pending graphics pipeline across four frames 4 1 4 1
Sum of recorded graphics waits, ms 320.26 80.06 320.26 80.07
Once-only compute request admitted after the graphics budget is spent 0/1 0/1 1/1 1/1
Two concurrent once-only callers, same compute pipeline 0/2 0/2 2/2 2/2
Explicit host refusal incorrectly admitted 0 0 0 0

Each controlled job builds exactly once; after eventual publication its ready result remains usable. To reproduce the compute case, hold one synthetic graphics job until the shared budget expires. Have a worker claim a second, compute job but hold its result. Call ready() once from each of one or two recording threads. Release the synthetic builder only when each caller has entered the real condition-variable wait or returned without it. Count returned host IDs, not just queued jobs. The baseline and #1234 lose those simulated one-shot calls even though the worker soon publishes successfully. The compute-wait variant returns the same successfully built host object to both callers. This models readiness only, not the subsequent command recording, binding or dispatch effect.

Controls: a pipeline that did not get any wait in one frame can still use the next frame's budget; a second graphics pipeline does not get extra budget in the spent frame. With VICTORY_PIPELINE_WAIT_EVERY_FRAME=1 the combined arm returns to four graphics waits; with VICTORY_COMPUTE_WAIT=0 it returns to the baseline one-shot behavior. With a compute job deliberately held, the real 20-second allowance expires at 20,000 ms, the next call skips waiting, and the later published result is accepted. The two new tests in #1234 and the inherited scheduler tests pass in the combined arm. Totals across four arms: 50 passing focused test invocations, four intentional assertion failures that reproduce the old/missing behavior. All four isolated builds/runners exited successfully; no OOM, game launch or GPU workload.

Implication: the repeated-wait fix and the once-only correctness concern are complementary, not substitutes. I would keep the cap for draws and investigate an explicitly selected bounded compute policy rather than globally setting the wait budget to zero. The 20 s limit here is per wait call before the give-up flag skips later waits, not a guaranteed total frame time; multiple delayed jobs can still accumulate long waits. The delay before a worker starts building matters too, and a real application-level dispatch/consumer witness is still needed before attributing missing geometry to this mechanism.

Beqren's corrected report is consistent with our earlier RTX 4060 runs with vkd3d-proton 71cae091, where five of the six named programs reached host completion (the sixth remained unresolved within our observation window). The converter fix is a separate matter from the remaining cold-cache readiness race. Thanks for checking that on both runtime versions. My test does not establish a native Windows/AMD/NVIDIA gameplay result, any particular head/skin repair, or a safe final choice of wait duration. No title launch or change to the installed runtime was made for this comparison.

AI assistance: Hermes Agent, working on behalf of ArturoWolff. (GPT 6.2 Sol High).

**@⁠ArturoWolff** on GitHub · 2026-11-26 07:21 UTC · [original](https://github.com/fxceless/victory-fork/pull/1234#issuecomment-7185366462) Independent, game-free scheduler comparison on the receiving fxceless tree. This supports the one-frame wait cap, but also gives a reason to keep the policy for a once-only compute dispatch separate from that for an ordinary draw. **Setup and provenance:** receiver `46bf5351707b1697c04e5d871c30973ebaa3e973`, native Linux Rust 1.98.1, separate source trees and Cargo targets. I exercised the actual `pipeline/make.rs` worker queue, condition variable and `ready()` implementation in a small Rust adapter. Only host pipeline construction, the frame counter, library bookkeeping and the Windows/Wine-specific environment interfaces are replaced by synthetic fixtures; no D3D12, title data, shader conversion, driver cache or GPU. Each scenario starts in a fresh process. `VICTORY_PIPELINE_WAIT_MS=80`, shared budget on, with explicit compute-policy selection. The shorter render budget makes the test cheap, not a proposed in-game setting. The four arms are clean receiver; the exact change from this PR at `7195775ba6f09a797b7523c749c7d8b558255a7f`; the compute-wait policy only from Beqren's [#129](https://github.com/avatarmanz/VIctory-7900XTX/pull/129), `c0fdca08d3446294336cfb6d59c2dbaa2cced69a` with the concurrent-caller follow-up `da4cee66b2a7d2fe1339c08f5b1a6732082f7de5`; and the combination. Credit for the one-frame cap and budget-claim correction also goes to powplusplus and BradRoland (#867), as noted in the PR. The compute change on this receiver keeps its existing graphics wait, worker queue and logging style. I am testing the readiness policy, not the other #129 changes or the reworked branch now in draft. **Measured:** | Controlled case | Receiver | #1234 only | Compute wait only | Both | | --- | ---: | ---: | ---: | ---: | | Waits for one still-pending graphics pipeline across four frames | 4 | 1 | 4 | 1 | | Sum of recorded graphics waits, ms | 320.26 | 80.06 | 320.26 | 80.07 | | Once-only compute request admitted after the graphics budget is spent | 0/1 | 0/1 | 1/1 | 1/1 | | Two concurrent once-only callers, same compute pipeline | 0/2 | 0/2 | 2/2 | 2/2 | | Explicit host refusal incorrectly admitted | 0 | 0 | 0 | 0 | Each controlled job builds exactly once; after eventual publication its ready result remains usable. To reproduce the compute case, hold one synthetic graphics job until the shared budget expires. Have a worker claim a second, compute job but hold its result. Call `ready()` once from each of one or two recording threads. Release the synthetic builder only when each caller has entered the real condition-variable wait or returned without it. Count returned host IDs, not just queued jobs. The baseline and #1234 lose those simulated one-shot calls even though the worker soon publishes successfully. The compute-wait variant returns the same successfully built host object to both callers. This models readiness only, not the subsequent command recording, binding or dispatch effect. Controls: a pipeline that did not get any wait in one frame can still use the next frame's budget; a second graphics pipeline does not get extra budget in the spent frame. With `VICTORY_PIPELINE_WAIT_EVERY_FRAME=1` the combined arm returns to four graphics waits; with `VICTORY_COMPUTE_WAIT=0` it returns to the baseline one-shot behavior. With a compute job deliberately held, the real 20-second allowance expires at 20,000 ms, the next call skips waiting, and the later published result is accepted. The two new tests in #1234 and the inherited scheduler tests pass in the combined arm. Totals across four arms: 50 passing focused test invocations, four intentional assertion failures that reproduce the old/missing behavior. All four isolated builds/runners exited successfully; no OOM, game launch or GPU workload. **Implication:** the repeated-wait fix and the once-only correctness concern are complementary, not substitutes. I would keep the cap for draws and investigate an explicitly selected bounded compute policy rather than globally setting the wait budget to zero. The 20 s limit here is per wait call before the give-up flag skips later waits, not a guaranteed total frame time; multiple delayed jobs can still accumulate long waits. The delay before a worker starts building matters too, and a real application-level dispatch/consumer witness is still needed before attributing missing geometry to this mechanism. Beqren's [corrected report](https://github.com/avatarmanz/VIctory-7900XTX/issues/111#issuecomment-7184231609) is consistent with our earlier RTX 4060 runs with vkd3d-proton `71cae091`, where five of the six named programs reached host completion (the sixth remained unresolved within our observation window). The converter fix is a separate matter from the remaining cold-cache readiness race. Thanks for checking that on both runtime versions. My test does not establish a native Windows/AMD/NVIDIA gameplay result, any particular head/skin repair, or a safe final choice of wait duration. No title launch or change to the installed runtime was made for this comparison. AI assistance: Hermes Agent, working on behalf of ArturoWolff. (GPT 6.2 Sol High).
Author
Owner

@⁠slauko on GitHub · 2026-11-26 07:30 UTC · original

Confirmed from Linux/Wine (RTX 3080 Ti, vkd3d-proton ec20719, uiliannn's line with this patch taken as it is).

Before it, every world frame stood at the wait budget, whatever the build or the preset: 507–519 ms in one run and 622–627 ms in another on the next build, and 512–514 ms in three earlier ones, all at about 4,800 draws. Each frame's first draw with one of 40 compute pipelines the workers never finished took the 500 ms again, and 340 draws were dropped a frame (dropped 340 without a host pipeline (4 being made)).

With it, the same scene (about 4,790 draws a frame): 395–413 ms, and the frame log says pipelines: 0.0 ms waited. What is left of a 403 ms frame: 112 ms preparing, 268 ms waiting for the card, the card idle 65 ms — so it is the card's time now.

For whoever worked around the old behaviour with VICTORY_PIPELINE_WAIT_MS=0: that drops a pipeline's draw in the frame that first asks for it, every time. With the one-frame claim the default budget is right again.

**@⁠slauko** on GitHub · 2026-11-26 07:30 UTC · [original](https://github.com/fxceless/victory-fork/pull/1234#issuecomment-7185530215) Confirmed from Linux/Wine (RTX 3080 Ti, vkd3d-proton `ec20719`, uiliannn's line with this patch taken as it is). **Before it**, every world frame stood at the wait budget, whatever the build or the preset: 507–519 ms in one run and 622–627 ms in another on the next build, and 512–514 ms in three earlier ones, all at about 4,800 draws. Each frame's first draw with one of 40 compute pipelines the workers never finished took the 500 ms again, and 340 draws were dropped a frame (`dropped 340 without a host pipeline (4 being made)`). **With it**, the same scene (about 4,790 draws a frame): 395–413 ms, and the frame log says `pipelines: 0.0 ms waited`. What is left of a 403 ms frame: 112 ms preparing, 268 ms waiting for the card, the card idle 65 ms — so it is the card's time now. For whoever worked around the old behaviour with `VICTORY_PIPELINE_WAIT_MS=0`: that drops a pipeline's draw in the frame that first asks for it, every time. With the one-frame claim the default budget is right again.
Author
Owner

@⁠Filip722 on GitHub · 2026-11-26 17:39 UTC · original

I reproduced the repeated-wait behavior from #1181 on Bazzite 44, RTX 5060 Laptop 8 GB, NVIDIA 615.78.08, GE-Proton11-14, and vkd3d-proton 3.2.0 (cae8353ed7959c4+). All three Series S replays used the same offline checkpoint, initial caches and 54-second stationary camera window before input. The compatibility baseline was main e4245f3c1b with the same Linux bring-up changes in each arm.

Pipeline wait Unique Presents FPS Median / p95 interval Median pipeline wait per frame
500 ms every frame 96 1.77 555 / 725 ms 500.1 ms
24 ms every frame 200 3.71 210 / 500 ms 24.1 ms
#1234 with the initial 500 ms budget 201 3.79 220 / 441 ms 0.0 ms

Four to six pipelines were still pending in all three windows. The #1234 arm retained working camera input after the measurement. All six focused pipeline tests passed under Proton on the compatibility build.

I rebased the scheduler change onto e4245f3, preserving the original authorship and current main's first-use tracker. The scheduler file matches the tested port byte for byte and the staged asset-policy check passed. Clean rebase c988e0f.

Assisted by Codex (GPT-6.2-Sol High).

**@⁠Filip722** on GitHub · 2026-11-26 17:39 UTC · [original](https://github.com/fxceless/victory-fork/pull/1234#issuecomment-7199416985) I reproduced the repeated-wait behavior from #1181 on Bazzite 44, RTX 5060 Laptop 8 GB, NVIDIA 615.78.08, GE-Proton11-14, and vkd3d-proton 3.2.0 (cae8353ed7959c4+). All three Series S replays used the same offline checkpoint, initial caches and 54-second stationary camera window before input. The compatibility baseline was main e4245f3c1b0490250d9cf0946a2113000be98687 with the same Linux bring-up changes in each arm. | Pipeline wait | Unique Presents | FPS | Median / p95 interval | Median pipeline wait per frame | | --- | ---: | ---: | ---: | ---: | | 500 ms every frame | 96 | 1.77 | 555 / 725 ms | 500.1 ms | | 24 ms every frame | 200 | 3.71 | 210 / 500 ms | 24.1 ms | | #1234 with the initial 500 ms budget | 201 | 3.79 | 220 / 441 ms | 0.0 ms | Four to six pipelines were still pending in all three windows. The #1234 arm retained working camera input after the measurement. All six focused pipeline tests passed under Proton on the compatibility build. I rebased the scheduler change onto e4245f3, preserving the original authorship and current main's first-use tracker. The scheduler file matches the tested port byte for byte and the staged asset-policy check passed. [Clean rebase c988e0f](https://github.com/Filip722/victory-fork/commit/c988e0f4cbc575200c65c7665e59b95b4b2af8ac). Assisted by Codex (GPT-6.2-Sol High).
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/src/pipeline/make.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1234/head:github-bot/gh-1234'
git switch 'github-bot/gh-1234'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1234'
git switch 'github-bot/gh-1234'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1234'
git switch 'github-bot/gh-1234'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1234'
git switch 'main'
git merge --squash 'github-bot/gh-1234'
git switch 'main'
git merge --ff-only 'github-bot/gh-1234'
git switch 'main'
git merge 'github-bot/gh-1234'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.