GPU: pipelines that write depth only go first among early starts #2895

Open
0xkn0wh3r3 wants to merge 2 commits from upstream-pr/2897 into main
0xkn0wh3r3 commented 2026-11-25 23:21:30 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by 0xkn0wh3r3 on 2026-11-25T23:21:30Z.


What

Pipelines an earlier run drew with are started while the title loads (early starts), in the order the title creates them, after the pipelines draws are waiting for. A shadow map's or depth prepass's pipeline feeds several later draws in a frame, and those draws wait for it too.

Early starts that write depth and no colour now get a queue of their own. That means no render target, a depth format, and depth writes on (GraphicsState::writes_depth_only). Workers take from it after the queue draws wait for and before the other early starts (queue_index). Draws that are waiting still come first.

Where it came from

From DexNom's fork, DexNom/VIctory@921d8d3 (Queue.early_depth, GraphicsState::writes_depth_only and its queue test), built on this tree's QUEUES. Credited with Co-authored-by: DexNom.

Tested

  • New test pipeline::make::tests::depth_only_pipelines_go_ahead_of_other_early_starts: an early start that writes depth only goes in queue 1, another early start in queue 2, and either one, when a draw waits for it, in queue 0.
  • The same test checks VICTORY_DEPTH_ONLY_FIRST=0: a depth-only early start then goes in queue 2 with the others.
  • cargo test -p victory-gpu (Windows 11, RTX 5070 Ti): 230 passed. The 2 known NVIDIA failures are fixed by #2121.
  • cargo clippy -p victory-gpu --all-targets -- -D warnings, with and without --features diagnostics: clean.

Measuring it

Draw waits for pipelines are counted from the start and logged with each batch of pipelines made, on the host pipelines all made line:

  • draw_waits: draws that waited for their pipeline;
  • draw_waited_ms: the time they waited in all;
  • draws_without: draws whose frame budget ran out first, so they were drawn without the pipeline.

VICTORY_DEPTH_ONLY_FIRST=0 turns the depth-only queue off. To compare on one build:

  1. Clear the pipeline library, start the title, and note the counts on the last host pipelines all made line once the world is reached.
  2. Clear the library again and repeat with VICTORY_DEPTH_ONLY_FIRST=0.

Not tested

  • This is a scheduling heuristic and I haven't measured whether it helps. I can't run the title here, so the comparison above is for a tester.
<!-- greyfinch-sync:Marvisak/VIctory:issue:6615797091 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2897). Originally posted by [0xkn0wh3r3](https://github.com/0xkn0wh3r3) on 2026-11-25T23:21:30Z. --- ## What Pipelines an earlier run drew with are started while the title loads (early starts), in the order the title creates them, after the pipelines draws are waiting for. A shadow map's or depth prepass's pipeline feeds several later draws in a frame, and those draws wait for it too. Early starts that write depth and no colour now get a queue of their own. That means no render target, a depth format, and depth writes on (`GraphicsState::writes_depth_only`). Workers take from it after the queue draws wait for and before the other early starts (`queue_index`). Draws that are waiting still come first. ## Where it came from From DexNom's fork, [DexNom/VIctory@921d8d3](https://github.com/DexNom/VIctory/commit/921d8d3b43b44f3a6ca4b44095edd3c4baf10a87) (`Queue.early_depth`, `GraphicsState::writes_depth_only` and its queue test), built on this tree's `QUEUES`. Credited with `Co-authored-by: DexNom`. ## Tested - New test `pipeline::make::tests::depth_only_pipelines_go_ahead_of_other_early_starts`: an early start that writes depth only goes in queue 1, another early start in queue 2, and either one, when a draw waits for it, in queue 0. - The same test checks `VICTORY_DEPTH_ONLY_FIRST=0`: a depth-only early start then goes in queue 2 with the others. - `cargo test -p victory-gpu` (Windows 11, RTX 5070 Ti): 230 passed. The 2 known NVIDIA failures are fixed by #2121. - `cargo clippy -p victory-gpu --all-targets -- -D warnings`, with and without `--features diagnostics`: clean. ## Measuring it Draw waits for pipelines are counted from the start and logged with each batch of pipelines made, on the `host pipelines all made` line: - `draw_waits`: draws that waited for their pipeline; - `draw_waited_ms`: the time they waited in all; - `draws_without`: draws whose frame budget ran out first, so they were drawn without the pipeline. `VICTORY_DEPTH_ONLY_FIRST=0` turns the depth-only queue off. To compare on one build: 1. Clear the pipeline library, start the title, and note the counts on the last `host pipelines all made` line once the world is reached. 2. Clear the library again and repeat with `VICTORY_DEPTH_ONLY_FIRST=0`. ## Not tested - This is a scheduling heuristic and I haven't measured whether it helps. I can't run the title here, so the comparison above is for a tester.
fuzeofficlal commented 2026-11-26 00:03:07 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T23:32:25Z.

Review: COMMENTED


Verified head a3ea016e cleanly on top of origin/main (842b0cb7) on Windows 11 x64 (NVIDIA GeForce RTX 5090).

Code Review

  • The 3-tier priority queue (0: draw-awaited, 1: depth-only early starts, 2: other early starts) dequeues deterministically via queues.iter_mut().find_map(VecDeque::pop_front) with FIFO within each tier. Promoting an already-queued early start when a draw waits (enqueue(p, true)) cleanly skips the stale lower-tier entry via p.taken without duplicate compilation.
  • GraphicsState::writes_depth_only accurately checks NumRenderTargets == 0 && depth_format != DXGI_FORMAT_UNKNOWN && DepthEnable && DepthWriteMask == ALL, while non-stream graphics pipelines (graphics = None) fall into tier 2.

Local Verification

  • cargo test --locked -p victory-gpu pipeline: 26/26 passed (including pipeline::make::tests::depth_only_pipelines_go_ahead_of_other_early_starts).
  • cargo clippy --locked -p victory-gpu --tests -- -D warnings (default and --features diagnostics): clean.
  • cargo xtask policy: 191 files ok.

Looks clean and ready to merge.

<!-- greyfinch-sync:Marvisak/VIctory:review:6066454233 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2897#pullrequestreview-6066454233). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-25T23:32:25Z. **Review:** COMMENTED --- Verified head `a3ea016e` cleanly on top of `origin/main` (`842b0cb7`) on Windows 11 x64 (NVIDIA GeForce RTX 5090). ### Code Review - The 3-tier priority queue (`0`: draw-awaited, `1`: depth-only early starts, `2`: other early starts) dequeues deterministically via `queues.iter_mut().find_map(VecDeque::pop_front)` with FIFO within each tier. Promoting an already-queued early start when a draw waits (`enqueue(p, true)`) cleanly skips the stale lower-tier entry via `p.taken` without duplicate compilation. - `GraphicsState::writes_depth_only` accurately checks `NumRenderTargets == 0 && depth_format != DXGI_FORMAT_UNKNOWN && DepthEnable && DepthWriteMask == ALL`, while non-stream graphics pipelines (`graphics = None`) fall into tier 2. ### Local Verification - `cargo test --locked -p victory-gpu pipeline`: **26/26 passed** (including `pipeline::make::tests::depth_only_pipelines_go_ahead_of_other_early_starts`). - `cargo clippy --locked -p victory-gpu --tests -- -D warnings` (default and `--features diagnostics`): clean. - `cargo xtask policy`: `191 files ok`. Looks clean and ready to merge.
kotekompotek commented 2026-11-26 00:03:07 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T23:35:04Z.

Review: COMMENTED


Sound prioritization: writes_depth_only correctly identifies shadow-map/depth-prepass pipelines (no RTs, depth enabled, full write mask), and queueing them ahead of other early starts shortens the critical path for dependent draws without changing wait-for ordering. LGTM.

<!-- greyfinch-sync:Marvisak/VIctory:review:6066478372 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2897#pullrequestreview-6066478372). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-25T23:35:04Z. **Review:** COMMENTED --- Sound prioritization: writes_depth_only correctly identifies shadow-map/depth-prepass pipelines (no RTs, depth enabled, full write mask), and queueing them ahead of other early starts shortens the critical path for dependent draws without changing wait-for ordering. LGTM.
Marvisak commented 2026-11-26 05:04:13 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-26T04:30:44Z.


Automated triage for the maintainers.

Needs work (unchanged). The new commit 5f82c56 in pipeline/make.rs adds DRAW_WAITS, DRAW_WAITED_US and DRAWS_WITHOUT, counted in wait. They are logged on the host pipelines all made line in drained. VICTORY_DEPTH_ONLY_FIRST=0 turns the depth-only queue off through the new queue_for. The counters read correctly: every wait is counted, and a draw that leaves without its pipeline is counted in draws_without.

Thank you for making it measurable. The verdict still depends on the measurement, though: a cold-library run each way with the three counts from the last line. Once those numbers are posted here, this can be judged on the result. If the depth-only queue is kept, the comparison switch could be dropped then.

CI: passing.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7182658749 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2897#issuecomment-7182658749). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-26T04:30:44Z. --- <!-- victory-triage v1 head=5f82c5628daa4ec62b97288a3d27b01a840f8da9 verdict=needs-work at=2026-11-26T07:23:30Z --> Automated triage for the maintainers. **Needs work (unchanged).** The new commit `5f82c56` in `pipeline/make.rs` adds `DRAW_WAITS`, `DRAW_WAITED_US` and `DRAWS_WITHOUT`, counted in `wait`. They are logged on the `host pipelines all made` line in `drained`. `VICTORY_DEPTH_ONLY_FIRST=0` turns the depth-only queue off through the new `queue_for`. The counters read correctly: every wait is counted, and a draw that leaves without its pipeline is counted in `draws_without`. Thank you for making it measurable. The verdict still depends on the measurement, though: a cold-library run each way with the three counts from the last line. Once those numbers are posted here, this can be judged on the result. If the depth-only queue is kept, the comparison switch could be dropped then. CI: passing. --- _Generated by [Claude Code](https://claude.ai/code)_
0xkn0wh3r3 commented 2026-11-26 08:03:11 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by 0xkn0wh3r3 on 2026-11-26T07:05:57Z.


Agreed, it's unmeasured. I can't run the title, so 5f82c56 makes it measurable instead:

  • Draw waits are counted from the start and logged with each batch of pipelines made, on the host pipelines all made line: draw_waits, draw_waited_ms, and draws_without (frame budget ran out, drawn without the pipeline).
  • VICTORY_DEPTH_ONLY_FIRST=0 turns the depth-only queue off, so one build can be compared both ways.

A tester could clear the pipeline library, reach the world, and note the last line's counts. Then clear it again and repeat with VICTORY_DEPTH_ONLY_FIRST=0. If anyone can run that, the numbers would settle it. Until then I'm not claiming a gain, and I understand if this stays open.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7185094344 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2897#issuecomment-7185094344). Originally posted by [0xkn0wh3r3](https://github.com/0xkn0wh3r3) on 2026-11-26T07:05:57Z. --- Agreed, it's unmeasured. I can't run the title, so 5f82c56 makes it measurable instead: - Draw waits are counted from the start and logged with each batch of pipelines made, on the `host pipelines all made` line: `draw_waits`, `draw_waited_ms`, and `draws_without` (frame budget ran out, drawn without the pipeline). - `VICTORY_DEPTH_ONLY_FIRST=0` turns the depth-only queue off, so one build can be compared both ways. A tester could clear the pipeline library, reach the world, and note the last line's counts. Then clear it again and repeat with `VICTORY_DEPTH_ONLY_FIRST=0`. If anyone can run that, the numbers would settle it. Until then I'm not claiming a gain, and I understand if this stays open.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2897:upstream-pr/2897'
git switch 'upstream-pr/2897'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/2897'
git switch 'upstream-pr/2897'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2897'
git switch 'upstream-pr/2897'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2897'
git switch 'main'
git merge --squash 'upstream-pr/2897'
git switch 'main'
git merge --ff-only 'upstream-pr/2897'
git switch 'main'
git merge 'upstream-pr/2897'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
Marvisak/VIctory!2895
No description provided.