Skip to content

fix(gpu): prioritize and bound-wait cold compute pipelines before dropping dispatches - #420

Merged
pragyaangaur merged 1 commit into
pragyaangaur:mainfrom
gdemontalivet:fix/macos-sync-cold-compute-pso
Nov 27, 2026
Merged

pragyaangaur merged 1 commit into
pragyaangaur:mainfrom
gdemontalivet:fix/macos-sync-cold-compute-pso

Conversation

@gdemontalivet

Copy link
Copy Markdown
Contributor

Summary

  • Replaces the 2-lane pipeline queue ([now, early]) in pipeline/make.rs with a 3-lane PriorityQueue (Compute → Graphics → Early) in crates/victory-gpu/src/pipeline/schedule.rs so cold compute dispatches jump ahead of queued graphics pipelines and pre-warms.
  • Gives requested cold compute pipelines an independent bounded wait budget (10 s per-frame wall-clock window and 10 s per-pipeline compilation cap, gated by VICTORY_SYNC_COMPUTE_PSO, default ON, 0 disables) so one-time initialization/skinning/bake compute dispatches are not dropped on cold launches once graphics compilation exhausts the shared 500 ms frame wait budget.

Verification

  • cargo xtask policy: pass
  • cargo test -p victory-gpu: 107 passed (including 6 new pipeline::schedule::tests::* tests)
  • cargo clippy --target x86_64-pc-windows-gnullvm --workspace --all-targets -- -D warnings (default & --features diagnostics): 0 warnings

…pping dispatches

Give cold compute dispatches a dedicated priority worker lane ahead of
queued graphics pipelines and an independent bounded wall-clock wait
window (VICTORY_SYNC_COMPUTE_PSO, on by default; 0 disables) so one-time
compute passes are not dropped when a cold frame exhausts the shorter
graphics compilation budget:

- pipeline/schedule.rs: add a three-lane PriorityQueue (Compute,
  Graphics, Early) and WaitBudgets tracking the 500 ms per-frame
  graphics wait budget separately from a 10 s per-frame wall-clock and
  per-pipeline compute compilation cap, plus unit tests runnable on
  both macOS and Windows.
- pipeline/make.rs: classify compute pipelines in Pending, record when
  a worker begins compiling each pipeline, promote requested compute
  pipelines to Lane::Compute ahead of Lane::Graphics and Lane::Early,
  and log once if a compute dispatch or pipeline exceeds its cap.
@evan-kolberg

Copy link
Copy Markdown
Contributor

Physical M4 Pro A/B for gdemontalivet’s exact #420 revision. I used one Windows test binary on CrossOver 26.3 / D3DMetal 4.0 beta 3. After exhausting the same frame’s 500 ms graphics allowance, a generated compute shader went through the normal guest dispatch. The same test gate held publication of the real worker-created PSO for 40 ms after compilation and the first wait request.

  • Off, two trials: zero additional wait, zero cold dispatches, and output remained 0x00000000.
  • On, two trials: 50.045 and 49.625 ms of additional wait. One cold dispatch per trial wrote the exact 0x420c0de1 marker.
  • The warmed dispatch wrote the marker in all four trials.

This exercises preservation of the first dispatch under controlled PSO readiness. The added wait includes the test hold. Production compile and frame times need separate measurement.

Prepared and tested with Codex.

@pragyaangaur
pragyaangaur merged commit fc1fbd4 into pragyaangaur:main Nov 27, 2026
1 check passed
@earpjonathan

Copy link
Copy Markdown
Contributor

In-game check on an M5 Pro (macOS 27.0.1, CrossOver 26.3 Wine with the repo's current patches, D3DMetal 4.0 beta 3, Series X). Base: main at bf99e72 plus #401, #435, #433, #439 and #419. Same opening and scripted input, about 7 minutes per run. Every run started with a cold cache: the host pipeline library was replaced at start (stale=32).

That matches the description: one-time setup work dropped on a cold start leaves the scene wrong for good, and #420 keeps it. In steady state, runs with and without #420 drop about the same, roughly 40 per frame, so #420 doesn't change that part.

Only a few runs, so take the totals as rough. I can run more if that helps.

Prepared with Claude Code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants