GPU: skip prewarming after the predecessor fence completes #232

Open
github-bot wants to merge 2 commits from github-bot/gh-232 into main AGit
Owner

@⁠loyodea on GitHub · 2026-11-26 07:37 UTC · original
loyodea:victory-submit-fence-overhead → main · +148 −18 · 1 files · 2 commits · open

Related to #163. When the previous GPU submission's fence has already completed, skip the early refresh pass and retire the completed submission using the observed fence value. Normal preparation still runs. When the preceding submission is busy, the early refresh remains available and the event wait is followed by a fence query.

An already-complete predecessor uses one fence query instead of two. If work remains after the early refresh, the quick check adds one fence query. This change has no measured gameplay frame-rate result.

Tested

  • Windows 11 26300, Radeon RX 9060 XT driver 32.0.32029.2010, and Rust 1.100.0 GNU x64.
  • The focused host regression exercised finished and unfinished predecessors, checked deferred writes and retained resources, and passed on hardware. Making prewarm unconditional caused it to fail as expected.
  • cargo test --locked -p victory-gpu -j 4 --lib -- --test-threads=1 --nocapture reported 113 passed, one failed, and four ignored. Clean upstream 4f62c2a reported 112 passed, one failed, and four ignored. Both failed the same assertion in watch::tests::written_pages_are_reported_to_every_asker.

The run used original synthetic fixtures. Codex helped implement, review, and test the patch.

**@⁠loyodea** on GitHub · 2026-11-26 07:37 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/232) `loyodea:victory-submit-fence-overhead` → `main` · +148 −18 · 1 files · 2 commits · open Related to #163. When the previous GPU submission's fence has already completed, skip the early refresh pass and retire the completed submission using the observed fence value. Normal preparation still runs. When the preceding submission is busy, the early refresh remains available and the event wait is followed by a fence query. An already-complete predecessor uses one fence query instead of two. If work remains after the early refresh, the quick check adds one fence query. This change has no measured gameplay frame-rate result. **Tested** - Windows 11 26300, Radeon RX 9060 XT driver 32.0.32029.2010, and Rust 1.100.0 GNU x64. - The focused host regression exercised finished and unfinished predecessors, checked deferred writes and retained resources, and passed on hardware. Making prewarm unconditional caused it to fail as expected. - `cargo test --locked -p victory-gpu -j 4 --lib -- --test-threads=1 --nocapture` reported 113 passed, one failed, and four ignored. Clean upstream `4f62c2a` reported 112 passed, one failed, and four ignored. Both failed the same assertion in `watch::tests::written_pages_are_reported_to_every_asker`. The run used original synthetic fixtures. Codex helped implement, review, and test the patch.
Sample the pending fence before scanning the next submission for refresh work. When already complete, retire it with that sample and prepare the new submission normally. Preserve the event wait and confirmed completion path. Related to #163.

Co-authored-by: Codex <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 07:43:19 +00:00
Author
Owner

@⁠gut0to on GitHub · 2026-11-26 16:20 UTC · original · reviewed

AI-assisted review. I inspected the prewarm/drain branches and the new focused test statically; I did not run tests or the game. This review suggests a case for the remaining-wait path.

**@⁠gut0to** on GitHub · 2026-11-26 16:20 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/232#pullrequestreview-6077452269) · **reviewed** AI-assisted review. I inspected the prewarm/drain branches and the new focused test statically; I did not run tests or the game. This review suggests a case for the remaining-wait path.
@ -1223,4 +1275,4 @@
if let Err(e) = self.fence.SetEventOnCompletion(target, self.event) {
tracing::warn!(error = %e, "host async drain failed");
} else {
WaitForSingleObject(self.event, INFINITE);
Author
Owner

@⁠gut0to on GitHub · 2026-11-26 16:20 UTC · original

AI-assisted review; I did not run tests. Could the regression include a case where prewarm runs but does not signal target, then another thread signals it after SetEventOnCompletion? The current test callback always completes the fence, so it verifies reaping after prewarm but never exercises the event wait and post-wait fence query that this change also modifies.

**@⁠gut0to** on GitHub · 2026-11-26 16:20 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/232#discussion_r4711026012) AI-assisted review; I did not run tests. Could the regression include a case where `prewarm` runs but does not signal `target`, then another thread signals it after `SetEventOnCompletion`? The current test callback always completes the fence, so it verifies reaping after prewarm but never exercises the event wait and post-wait fence query that this change also modifies.
@ -1223,4 +1275,4 @@
if let Err(e) = self.fence.SetEventOnCompletion(target, self.event) {
tracing::warn!(error = %e, "host async drain failed");
} else {
WaitForSingleObject(self.event, INFINITE);
Author
Owner

@⁠loyodea on GitHub · 2026-11-26 18:53 UTC · original

Agreed. The current test completes the fence inside prewarm, so it exercises the second fence sample and skips the event wait. A separate thread signaled only after SetEventOnCompletion succeeds would cover that branch without relying on timing. A bounded wait can then verify that the submission retires and its deferred write is applied.

**@⁠loyodea** on GitHub · 2026-11-26 18:53 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/232#discussion_r4712404612) Agreed. The current test completes the fence inside `prewarm`, so it exercises the second fence sample and skips the event wait. A separate thread signaled only after `SetEventOnCompletion` succeeds would cover that branch without relying on timing. A bounded wait can then verify that the submission retires and its deferred write is applied.
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/232/head:github-bot/gh-232'
git switch 'github-bot/gh-232'

Merge

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