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

Open
Kolkka wants to merge 1 commit from upstream-pr/3381 into main
Kolkka commented 2026-11-26 21:06:04 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Kolkka on 2026-11-26T21:06:04Z.


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.
<!-- greyfinch-sync:Marvisak/VIctory:issue:5517138621 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3381). Originally posted by [Kolkka](https://github.com/Kolkka) on 2026-11-26T21:06:04Z. --- ### 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.
cloph-dsp commented 2026-11-26 21:26:51 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by cloph-dsp on 2026-11-26T21:26:51Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7203735216 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3381#issuecomment-7203735216). Originally posted by [cloph-dsp](https://github.com/cloph-dsp) on 2026-11-26T21:26:51Z. --- 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.
Dukestar69 commented 2026-11-26 21:30:45 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T21:30:45Z.

Review: APPROVED


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).

<!-- greyfinch-sync:Marvisak/VIctory:review:6080663274 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3381#pullrequestreview-6080663274). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-26T21:30:45Z. **Review:** APPROVED --- 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).
andrewpozdnakov7-jpg commented 2026-11-26 22:44:35 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-26T22:44:35Z.


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]>.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7204946072 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3381#issuecomment-7204946072). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-26T22:44:35Z. --- 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]>`.
fuzeofficlal commented 2026-11-27 01:02:16 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-27T01:02:16Z.

Review: APPROVED


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.
<!-- greyfinch-sync:Marvisak/VIctory:review:6082138795 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3381#pullrequestreview-6082138795). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-27T01:02:16Z. **Review:** APPROVED --- 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`.
upipibi commented 2026-11-27 18:12:43 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by upipibi on 2026-11-27T18:12:43Z.


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).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7225247008 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3381#issuecomment-7225247008). Originally posted by [upipibi](https://github.com/upipibi) on 2026-11-27T18:12:43Z. --- 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 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/3381:upstream-pr/3381'
git switch 'upstream-pr/3381'

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/3381'
git switch 'upstream-pr/3381'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3381'
git switch 'upstream-pr/3381'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3381'
git switch 'main'
git merge --squash 'upstream-pr/3381'
git switch 'main'
git merge --ff-only 'upstream-pr/3381'
git switch 'main'
git merge 'upstream-pr/3381'
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!3381
No description provided.