GPU: throttle failed swap-chain creation and resize #1625

Merged
AwsAli05 merged 1 commit from upstream-pr/1626 into main 2026-11-25 00:23:20 +00:00
AwsAli05 commented 2026-11-24 19:56:01 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by AwsAli05 on 2026-11-24T19:56:01Z.


Fixes #1591. Thanks to @fiestorra for identifying the per-frame DXGI calls and documenting the failure.

When DXGI refuses swap-chain creation or resize, wait one second before repeating the operation. The retry state lives beside the presenter under the existing lock. Frames that match an already working swap chain can still present during a failed resize's cooldown. Creation failures identify the failing step and log the requested dimensions and format.

The regression test simulates two seconds of frames at 60 Hz during a desktop outage. Only two calls reach the failing operation. It also verifies that a successful attempt immediately clears the cooldown.

On Windows, the GPU diagnostics suite passed 54 tests with one ignored benchmark. Clippy passed for the GPU crate with all targets and features. The regression used synthetic inputs.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6590202593 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1626). Originally posted by [AwsAli05](https://github.com/AwsAli05) on 2026-11-24T19:56:01Z. --- Fixes #1591. Thanks to @fiestorra for identifying the per-frame DXGI calls and documenting the failure. When DXGI refuses swap-chain creation or resize, wait one second before repeating the operation. The retry state lives beside the presenter under the existing lock. Frames that match an already working swap chain can still present during a failed resize's cooldown. Creation failures identify the failing step and log the requested dimensions and format. The regression test simulates two seconds of frames at 60 Hz during a desktop outage. Only two calls reach the failing operation. It also verifies that a successful attempt immediately clears the cooldown. On Windows, the GPU diagnostics suite passed 54 tests with one ignored benchmark. Clippy passed for the GPU crate with all targets and features. The regression used synthetic inputs.
catminou4 commented 2026-11-24 21:02:51 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T20:06:15Z.

Review: COMMENTED


Static review only: victory-gpu/victory-hle/apps are Windows-only (D3D12/windows_sys), so nothing here compiles or runs on macOS — please rely on the Windows CI leg.

Swap-chain creation/resize failures are throttled to one attempt per second via SwapChainRetry (next_attempt set only on Err, cleared on success), so a desktop that is temporarily unavailable no longer spams DXGI calls and warnings every frame. Presentation bundles presenter+retry under the same mutex; the ? on attempt returns None (skip present) during backoff, which is the right frame-level behavior. Failure steps are now tagged ("window", "DXGI factory", "swap chain", "copy list") — good for diagnosis. The unit test covers the 1s window and recovery; it is #[cfg(test)] in a Windows-only crate, so it runs on Windows only.

<!-- greyfinch-sync:Marvisak/VIctory:review:6046506245 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1626#pullrequestreview-6046506245). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-24T20:06:15Z. **Review:** COMMENTED --- Static review only: victory-gpu/victory-hle/apps are Windows-only (D3D12/windows_sys), so nothing here compiles or runs on macOS — please rely on the Windows CI leg. Swap-chain creation/resize failures are throttled to one attempt per second via `SwapChainRetry` (`next_attempt` set only on `Err`, cleared on success), so a desktop that is temporarily unavailable no longer spams DXGI calls and warnings every frame. `Presentation` bundles presenter+retry under the same mutex; the `?` on `attempt` returns `None` (skip present) during backoff, which is the right frame-level behavior. Failure steps are now tagged (`"window"`, `"DXGI factory"`, `"swap chain"`, `"copy list"`) — good for diagnosis. The unit test covers the 1s window and recovery; it is `#[cfg(test)]` in a Windows-only crate, so it runs on Windows only.
acetonahard-code commented 2026-11-24 23:05:49 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by acetonahard-code on 2026-11-24T22:14:44Z.


Tested on Windows 11, RTX 4070 SUPER (driver 621.14), with the repo toolchain, merged into current main (70564ae):

cargo test -p victory-gpu passed failed ignored
main 76 2 1
main + this PR 77 2 1
main, --all-features 79 2 -
main + this PR, --all-features 80 2 -
  • The new test passes.
  • No GPU test skipped for lack of a device.
  • cargo clippy --all-targets -- -D warnings, with and without --all-features: clean.
  • Two victory-gpu tests fail on current main on this NVIDIA card: dynamic_slots_are_held_until_released, lists_share_a_table_and_copies_keep_their_views. That's the 1,000,000-view heap cap, see #1744. They fail the same way with this PR, and no other test does.

I didn't test with game data.


Tested locally with an AI-assisted script (Claude Code); I checked the results before posting.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7145988415 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1626#issuecomment-7145988415). Originally posted by [acetonahard-code](https://github.com/acetonahard-code) on 2026-11-24T22:14:44Z. --- Tested on Windows 11, RTX 4070 SUPER (driver 621.14), with the repo toolchain, merged into current `main` (70564ae): | `cargo test -p victory-gpu` | passed | failed | ignored | |---|---|---|---| | `main` | 76 | 2 | 1 | | `main` + this PR | 77 | 2 | 1 | | `main`, `--all-features` | 79 | 2 | - | | `main` + this PR, `--all-features` | 80 | 2 | - | - The new test passes. - No GPU test skipped for lack of a device. - `cargo clippy --all-targets -- -D warnings`, with and without `--all-features`: clean. - Two `victory-gpu` tests fail on current `main` on this NVIDIA card: `dynamic_slots_are_held_until_released`, `lists_share_a_table_and_copies_keep_their_views`. That's the 1,000,000-view heap cap, see #1744. They fail the same way with this PR, and no other test does. I didn't test with game data. --- <sub>Tested locally with an AI-assisted script (Claude Code); I checked the results before posting.</sub>
upstream-sync closed this pull request 2026-11-25 01:06:57 +00:00
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!1625
No description provided.