GPU: wait for queued presentation before resizing the swap chain #3082

Open
passerbyyhx wants to merge 1 commit from upstream-pr/3084 into main
passerbyyhx commented 2026-11-26 07:02:16 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by passerbyyhx on 2026-11-26T07:02:16Z.


The existing compositor fallback test can exit with code 2173 when the D3D12 debug layer is enabled. After the primary-only fallback presents a 32×32 frame, the two-plane retry needs a 64×64 swap chain. The copy-list fence has already completed at that point, but Present queued work after it. The debug layer reports #921 when DXGI releases an old back buffer in ResizeBuffers.

This signals the presentation queue and waits for the fence immediately before resizing. It uses the existing submission lock to assign the fence value. A failed signal or wait goes through the existing resize retry. Frames of unchanged size and format take the existing path.

On WARP with the debug layer, the original test exited 2173 on 63bcca43 and passed on the patch in each of three alternating runs. The same test passed on the RTX 4090 Laptop with the debug layer. Both devices produced the expected primary fallback (32×32, RGBA 255/0/0/255) and subsequent composite (64×64, RGBA 127/0/128/255). The full WARP diagnostics library suite passed with the debug layer enabled (246 passed, 1 ignored). Strict workspace Clippy passed with default and all features, and the asset check passed. Debug message #1419 appeared on both revisions. The patched run completed without #921.

Coordination claim · Earlier report on clean main

<!-- greyfinch-sync:Marvisak/VIctory:issue:6621356721 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3084). Originally posted by [passerbyyhx](https://github.com/passerbyyhx) on 2026-11-26T07:02:16Z. --- The existing compositor fallback test can exit with code 2173 when the D3D12 debug layer is enabled. After the primary-only fallback presents a 32×32 frame, the two-plane retry needs a 64×64 swap chain. The copy-list fence has already completed at that point, but `Present` queued work after it. The debug layer reports #921 when DXGI releases an old back buffer in `ResizeBuffers`. This signals the presentation queue and waits for the fence immediately before resizing. It uses the existing submission lock to assign the fence value. A failed signal or wait goes through the existing resize retry. Frames of unchanged size and format take the existing path. On WARP with the debug layer, the original test exited 2173 on `63bcca43` and passed on the patch in each of three alternating runs. The same test passed on the RTX 4090 Laptop with the debug layer. Both devices produced the expected primary fallback (32×32, RGBA 255/0/0/255) and subsequent composite (64×64, RGBA 127/0/128/255). The full WARP diagnostics library suite passed with the debug layer enabled (246 passed, 1 ignored). Strict workspace Clippy passed with default and all features, and the asset check passed. Debug message #1419 appeared on both revisions. The patched run completed without #921. [Coordination claim](https://github.com/Marvisak/VIctory/issues/1633#issuecomment-7184801678) · [Earlier report on clean main](https://github.com/Marvisak/VIctory/pull/2929)
Dukestar69 commented 2026-11-26 08:03:04 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T07:08:10Z.

Review: APPROVED


Tested locally merged onto origin/main (63bcca4) on Windows 11 x64 (NVIDIA GeForce RTX 5090):

  • cargo test -p victory-gpu host::tests -- --test-threads=1 --skip dynamic_slots_are_held_until_released: 30 passed, 0 failed.
  • 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:6069850523 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3084#pullrequestreview-6069850523). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-26T07:08:10Z. **Review:** APPROVED --- Tested locally merged onto `origin/main` (`63bcca4`) on Windows 11 x64 (NVIDIA GeForce RTX 5090): - `cargo test -p victory-gpu host::tests -- --test-threads=1 --skip dynamic_slots_are_held_until_released`: 30 passed, 0 failed. - `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).
fuzeofficlal commented 2026-11-26 09:05:43 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T08:39:56Z.

Review: APPROVED


Reproduced the Debug Layer failure on origin/main (63bcca43) and verified the fix on 76ee198d on Windows 11 (RTX 5090 + WARP):

  • origin/main with VICTORY_D3D12_DEBUG=1: host::present_plane_tests::compositor_failure_presents_primary_in_the_same_frame exited 2173 on 3/3 WARP runs and 1/1 RTX 5090 run.
  • #3084 (76ee198d) with VICTORY_D3D12_DEBUG=1: passed 3/3 on WARP and 3/3 on RTX 5090.
  • cargo clippy -p victory-gpu --all-targets -- -D warnings (default and --all-features): clean; host::tests + present_plane_tests passed on RTX 5090 (30/30, skipping the pre-existing NVIDIA dynamic_slots_are_held_until_released cap failure) and WARP (32/32); cargo xtask policy: 191 files ok.

Lock ordering and error handling look sound:

  • present_with_compositor already acquires self.presenter then self.submitted (via self.execute), and no code path acquires self.presenter under self.submitted, so there is no lock-order inversion.
  • Waiting synchronously with HANDLE::default() under self.submitted avoids touching self.event and releases the lock before ResizeBuffers, while any Signal/SetEventOnCompletion error routes through the existing retry.attempt path.

LGTM.

<!-- greyfinch-sync:Marvisak/VIctory:review:6070844000 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3084#pullrequestreview-6070844000). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T08:39:56Z. **Review:** APPROVED --- Reproduced the Debug Layer failure on `origin/main` (`63bcca43`) and verified the fix on `76ee198d` on Windows 11 (RTX 5090 + WARP): - `origin/main` with `VICTORY_D3D12_DEBUG=1`: `host::present_plane_tests::compositor_failure_presents_primary_in_the_same_frame` exited `2173` on 3/3 WARP runs and 1/1 RTX 5090 run. - `#3084` (`76ee198d`) with `VICTORY_D3D12_DEBUG=1`: passed 3/3 on WARP and 3/3 on RTX 5090. - `cargo clippy -p victory-gpu --all-targets -- -D warnings` (default and `--all-features`): clean; `host::tests` + `present_plane_tests` passed on RTX 5090 (30/30, skipping the pre-existing NVIDIA `dynamic_slots_are_held_until_released` cap failure) and WARP (32/32); `cargo xtask policy`: 191 files ok. Lock ordering and error handling look sound: - `present_with_compositor` already acquires `self.presenter` then `self.submitted` (via `self.execute`), and no code path acquires `self.presenter` under `self.submitted`, so there is no lock-order inversion. - Waiting synchronously with `HANDLE::default()` under `self.submitted` avoids touching `self.event` and releases the lock before `ResizeBuffers`, while any `Signal`/`SetEventOnCompletion` error routes through the existing `retry.attempt` path. LGTM.
Marvisak commented 2026-11-26 09:06:05 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-26T08:21:01Z.


Automated triage for the maintainers.

Merge candidate. In Host::present_with_compositor (victory-gpu/src/host.rs), the resize path now signals the queue and waits on the host fence before ResizeBuffers. In origin/main the copy list is waited for in execute, but Present queues work after that, so the old back buffers could still be in use when DXGI releases them. D3D12 requires the queue to be idle before ResizeBuffers, so the wait is correct. It takes submitted the same way Host::execute does, with the same lock order (presenter, then submitted), and SetEventOnCompletion with a null event blocks until the value is reached. Frames that keep their size are unchanged.

CI: passing (check).


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7186486900 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3084#issuecomment-7186486900). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-26T08:21:01Z. --- <!-- victory-triage v1 head=76ee198d6fc9d78418b02c74301df10032d961bf verdict=merge-candidate at=2026-11-26T08:17:59Z --> Automated triage for the maintainers. **Merge candidate.** In `Host::present_with_compositor` (`victory-gpu/src/host.rs`), the resize path now signals the queue and waits on the host fence before `ResizeBuffers`. In `origin/main` the copy list is waited for in `execute`, but `Present` queues work after that, so the old back buffers could still be in use when DXGI releases them. D3D12 requires the queue to be idle before `ResizeBuffers`, so the wait is correct. It takes `submitted` the same way `Host::execute` does, with the same lock order (presenter, then submitted), and `SetEventOnCompletion` with a null event blocks until the value is reached. Frames that keep their size are unchanged. CI: passing (check). --- _Generated by [Claude Code](https://claude.ai/code)_
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/3084:upstream-pr/3084'
git switch 'upstream-pr/3084'

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