GPU: test a queue segment's waits after the segments before it ran #3381

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

@⁠Kolkka on GitHub · 2026-11-26 21:06 UTC · original
Kolkka:fix/hold-wait-order → main · +26 −0 · 1 files · 1 commits · open

Problem

In crates/victory-gpu/src/hold.rs, Held::pump gathers a queue's ready segments into one piece and runs the piece only when it reaches a segment that cannot run yet. A segment with value waits was therefore tested against memory before the segments ahead of it in its own queue had run. A wait could pass on a value one of those segments overwrites with its bottom-of-pipe write, or hold on one it writes.

On the macOS fork (pragyaangaur/VIctory-macOS), GTA VI's Series S intro stopped about two minutes into Prestream. The title's render thread sat in an infinite wait, and then the title's hang checker ended the run. No queue was held and the host GPU was not stuck. With this change the same run reached the world. The pump is the same code here.

Fix

  • Before a segment with waits is tested, the piece gathered so far runs, as it already does before a signal. Consecutive segments without waits are still gathered into one piece.
  • Added regression test hold::tests::a_wait_reads_what_earlier_segments_of_its_queue_wrote: a label starts at 1, segment A sets it to 0, and segment B waits for 1. Before the change, B ran on the stale 1. Now B stays held until the label is 1 again.

Verification

  • cargo test -p victory-gpu --lib --target x86_64-pc-windows-gnullvm under Wine with D3DMetal 4.0 beta 3 on an M5: all 11 hold tests pass. The suite has the same 30 failures on main (tests D3DMetal cannot run), and one more passing test (202 against 201).
  • cargo clippy -p victory-gpu --all-targets --target x86_64-pc-windows-gnullvm -- -D warnings: no warnings.
**@⁠Kolkka** on GitHub · 2026-11-26 21:06 UTC · [original](https://github.com/Marvisak/VIctory/pull/3381) `Kolkka:fix/hold-wait-order` → `main` · +26 −0 · 1 files · 1 commits · open ### Problem In `crates/victory-gpu/src/hold.rs`, `Held::pump` gathers a queue's ready segments into one piece and runs the piece only when it reaches a segment that cannot run yet. A segment with value waits was therefore tested against memory before the segments ahead of it in its own queue had run. A wait could pass on a value one of those segments overwrites with its bottom-of-pipe write, or hold on one it writes. On the macOS fork (pragyaangaur/VIctory-macOS), GTA VI's Series S intro stopped about two minutes into `Prestream`. The title's render thread sat in an infinite wait, and then the title's hang checker ended the run. No queue was held and the host GPU was not stuck. With this change the same run reached the world. The pump is the same code here. ### Fix - Before a segment with waits is tested, the piece gathered so far runs, as it already does before a signal. Consecutive segments without waits are still gathered into one piece. - Added regression test `hold::tests::a_wait_reads_what_earlier_segments_of_its_queue_wrote`: a label starts at 1, segment A sets it to 0, and segment B waits for 1. Before the change, B ran on the stale 1. Now B stays held until the label is 1 again. ### Verification - `cargo test -p victory-gpu --lib --target x86_64-pc-windows-gnullvm` under Wine with D3DMetal 4.0 beta 3 on an M5: all 11 `hold` tests pass. The suite has the same 30 failures on `main` (tests D3DMetal cannot run), and one more passing test (202 against 201). - `cargo clippy -p victory-gpu --all-targets --target x86_64-pc-windows-gnullvm -- -D warnings`: no warnings.
The pump gathered a queue's ready segments into one piece and ran it
only once a segment could not run. A segment with value waits was
tested against memory before the segments ahead of it in its own queue
had run, so a wait could pass on a value one of them overwrites at its
end (or hold on one it writes). The piece gathered so far now runs
before a segment with waits is tested, as before a signal.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017tiHubszVmvo5uoUAc34Br
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 21:13:42 +00:00
github-bot changed title from Queues: test a segment's waits after its queue's earlier segments ran to GPU: test a queue segment's waits after the segments before it ran 2026-11-27 01:10:43 +00:00
github-bot force-pushed github-bot/gh-3381 from 7313afbf98 to df3faef98b 2026-11-27 01:10:44 +00:00 Compare
Author
Owner

@⁠cloph-dsp on GitHub · 2026-11-26 21:26 UTC · original

Independent local verification of PR #3381 (Queues: test a segment's waits after its queue's earlier segments ran), head df3faef98b.

  • Windows, Rust 1.100.0/MSVC, cargo test --locked, CARGO_BUILD_JOBS=2, per-worktree CARGO_TARGET_DIR (D:\Victory-Contrib\target-3381).
  • cargo test --locked -p victory-gpu --lib -- --exact hold::tests::a_wait_reads_what_earlier_segments_of_its_queue_wrote -> 1 passed, 0 failed, 232 filtered, exit 0.
  • git diff --check origin/main HEAD -> clean.
  • Negative control: the new test name is absent from the merge base 63bcca43..., so it is genuinely added by this PR.
  • Pure CPU test using the synthetic Fake memory map; no GPU adapter or game data involved. The Wine/D3DMetal run reported by the author was not independently reproduced.

AI-assisted (Hy4 flash). GPU/driver: N/A for this CPU test. No game data used.

**@⁠cloph-dsp** on GitHub · 2026-11-26 21:26 UTC · [original](https://github.com/Marvisak/VIctory/pull/3381#issuecomment-7203735216) Independent local verification of PR #3381 (`Queues: test a segment's waits after its queue's earlier segments ran`), head df3faef98bbe7deff24e15a464fe73952455f9a2. - Windows, Rust 1.100.0/MSVC, `cargo test --locked`, `CARGO_BUILD_JOBS=2`, per-worktree `CARGO_TARGET_DIR` (`D:\Victory-Contrib\target-3381`). - `cargo test --locked -p victory-gpu --lib -- --exact hold::tests::a_wait_reads_what_earlier_segments_of_its_queue_wrote` -> 1 passed, 0 failed, 232 filtered, exit 0. - `git diff --check origin/main HEAD` -> clean. - Negative control: the new test name is absent from the merge base 63bcca43..., so it is genuinely added by this PR. - Pure CPU test using the synthetic `Fake` memory map; no GPU adapter or game data involved. The Wine/D3DMetal run reported by the author was not independently reproduced. AI-assisted (Hy4 flash). GPU/driver: N/A for this CPU test. No game data used.
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-26 21:30 UTC · original · approved these changes

LGTM — verified on Windows against origin/main (63bcca4).

  • Testing a queue segment's waits after earlier segments run avoids premature holds when an earlier segment in the same submission satisfies the waited value.
  • cargo test -p victory-gpu --lib hold:: -- --test-threads=1: all passed.
  • cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

**@⁠Dukestar69** on GitHub · 2026-11-26 21:30 UTC · [original](https://github.com/Marvisak/VIctory/pull/3381#pullrequestreview-6080663274) · **approved these changes** LGTM — verified on Windows against `origin/main` (`63bcca4`). - Testing a queue segment's waits after earlier segments run avoids premature holds when an earlier segment in the same submission satisfies the waited value. - `cargo test -p victory-gpu --lib hold:: -- --test-threads=1`: all passed. - `cargo clippy -p victory-gpu --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-26 22:44 UTC · original

I checked the complementary queue case on df3faef. Two ready segments are recorded together. The second writes the value needed by the third. When the queue tests the wait, that write should already be visible, including in the wait diagnostics.

On main 63bcca4 the same test reaches the consumer in the end, but reports one stall because the first check sees the old value. On df3faef it runs the same two pieces in order, reports zero stalls, and leaves no held work. The test-only commit passed all 12 hold tests on Windows, along with strict GPU Clippy in both feature configurations and cargo xtask policy.

The fixture uses the synthetic queue executor. The Prestream result remains the one in the PR description. @⁠Kolkka, if you fold in the test, please keep the Git author or add Co-authored-by: andrewpozdnakov7-jpg <[email protected]>.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-26 22:44 UTC · [original](https://github.com/Marvisak/VIctory/pull/3381#issuecomment-7204946072) I checked the complementary queue case on `df3faef`. Two ready segments are recorded together. The second writes the value needed by the third. When the queue tests the wait, that write should already be visible, including in the wait diagnostics. On `main` `63bcca4` the same test reaches the consumer in the end, but reports one stall because the first check sees the old value. On `df3faef` it runs the same two pieces in order, reports zero stalls, and leaves no held work. The [test-only commit](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/bdcb7fd189cc70dd48d6d5f0e8c1977afe9386bc) passed all 12 hold tests on Windows, along with strict GPU Clippy in both feature configurations and `cargo xtask policy`. The fixture uses the synthetic queue executor. The Prestream result remains the one in the PR description. @⁠Kolkka, if you fold in the test, please keep the Git author or add `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>`.
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-27 01:02 UTC · original · approved these changes

Looks good. Flushing accumulated piece segments before evaluating a subsequent segment's waits in Held::pump (crates/victory-gpu/src/hold.rs:144-150) ensures bottom-of-pipe writes from earlier segments on the same queue are visible before wait evaluation, and the new a_wait_reads_what_earlier_segments_of_its_queue_wrote test directly exercises that causal ordering.

Verified:

  • cargo xtask policy passes cleanly.
  • cargo clippy --tests -p victory-gpu (default and --features diagnostics, -D warnings) passes with zero warnings.
  • hold::tests passes (11/11) on both RTX 5090 and WARP with VICTORY_D3D12_DEBUG=1.
**@⁠fuzeofficlal** on GitHub · 2026-11-27 01:02 UTC · [original](https://github.com/Marvisak/VIctory/pull/3381#pullrequestreview-6082138795) · **approved these changes** Looks good. Flushing accumulated `piece` segments before evaluating a subsequent segment's `waits` in `Held::pump` (`crates/victory-gpu/src/hold.rs:144-150`) ensures bottom-of-pipe writes from earlier segments on the same queue are visible before wait evaluation, and the new `a_wait_reads_what_earlier_segments_of_its_queue_wrote` test directly exercises that causal ordering. Verified: - `cargo xtask policy` passes cleanly. - `cargo clippy --tests -p victory-gpu` (default and `--features diagnostics`, `-D warnings`) passes with zero warnings. - `hold::tests` passes (11/11) on both RTX 5090 and WARP with `VICTORY_D3D12_DEBUG=1`.
Author
Owner

@⁠upipibi on GitHub · 2026-11-27 18:12 UTC · original

Overlap with #3141 (fuzeofficlal, opened 11-26 09:57Z, about 11 h before this one): it makes the same fix in Held::pump. The hunk this PR adds before the segment's waits are tested (if !waits.is_empty() && !piece.is_empty() { (w.run)(*queue, std::mem::take(&mut piece)); done.pieces += 1; }) is line for line the first hunk of #3141. #3141 also runs the gathered piece before an Item::FenceWait is tested, which this PR leaves as it is. Its tests add a_wait_runs_the_work_before_it_first and a_wait_for_an_earlier_segment_on_the_same_queue_does_not_stall, the same case as a_wait_reads_what_earlier_segments_of_its_queue_wrote here.

Both merge cleanly into main 63bcca4 on their own. Merged into each other (df3faef onto 469d7a6), they conflict in crates/victory-gpu/src/hold.rs, so only one can go in as is. On main the bug is as both describe: the segment arm tests its waits (hold.rs:143-157) without running the piece gathered before it. #2611 tried the same flush earlier and was closed unmerged.

What this PR adds over #3141 is the title-level evidence from the macOS fork (the intro hang at Prestream).

Checked by reading and a local test merge only, no run. AI-assisted (Claude Code, Claude Opus 5.5 compared the diffs).

**@⁠upipibi** on GitHub · 2026-11-27 18:12 UTC · [original](https://github.com/Marvisak/VIctory/pull/3381#issuecomment-7225247008) Overlap with #3141 (fuzeofficlal, opened 11-26 09:57Z, about 11 h before this one): it makes the same fix in `Held::pump`. The hunk this PR adds before the segment's waits are tested (`if !waits.is_empty() && !piece.is_empty() { (w.run)(*queue, std::mem::take(&mut piece)); done.pieces += 1; }`) is line for line the first hunk of #3141. #3141 also runs the gathered piece before an `Item::FenceWait` is tested, which this PR leaves as it is. Its tests add `a_wait_runs_the_work_before_it_first` and `a_wait_for_an_earlier_segment_on_the_same_queue_does_not_stall`, the same case as `a_wait_reads_what_earlier_segments_of_its_queue_wrote` here. Both merge cleanly into `main` `63bcca4` on their own. Merged into each other (`df3faef` onto `469d7a6`), they conflict in `crates/victory-gpu/src/hold.rs`, so only one can go in as is. On `main` the bug is as both describe: the segment arm tests its waits (`hold.rs:143-157`) without running the piece gathered before it. #2611 tried the same flush earlier and was closed unmerged. What this PR adds over #3141 is the title-level evidence from the macOS fork (the intro hang at `Prestream`). Checked by reading and a local test merge only, no run. AI-assisted (Claude Code, Claude Opus 5.5 compared the diffs).
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

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

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3381'
git switch 'github-bot/gh-3381'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3381'
git switch 'github-bot/gh-3381'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3381'
git switch 'main'
git merge --squash 'github-bot/gh-3381'
git switch 'main'
git merge --ff-only 'github-bot/gh-3381'
git switch 'main'
git merge 'github-bot/gh-3381'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!3381
No description provided.