GPU: handle DXGI Present failures and occlusion #1460

Closed
Luizbc2 wants to merge 1 commit from upstream-pr/1461 into main
Luizbc2 commented 2026-11-24 18:12:48 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Luizbc2 on 2026-11-24T18:12:48Z.


What changed

Host::present now checks DXGI’s HRESULT before recording a frame. An occluded window skips that frame, transient failures are logged once per consecutive status, and a failed Present on a removed device goes through the existing device-removal diagnostic path.

Reproduction

On the base revision, inspect Host::present: the return from IDXGISwapChain::Present is discarded and the frame counter is incremented unconditionally. The regression exercises the three return paths with S_OK, DXGI_STATUS_OCCLUDED, and DXGI_ERROR_DEVICE_REMOVED.

Verification

  • cargo test --workspace --lib --locked --offline present_result_distinguishes_occlusion_from_success_and_failure passed on Windows.
  • git diff --check passed.
  • The regression uses simulated HRESULTs. No physical device removal was triggered.

DXGI Present return values

<!-- greyfinch-sync:Marvisak/VIctory:issue:6588394837 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1461). Originally posted by [Luizbc2](https://github.com/Luizbc2) on 2026-11-24T18:12:48Z. --- ## What changed `Host::present` now checks DXGI’s HRESULT before recording a frame. An occluded window skips that frame, transient failures are logged once per consecutive status, and a failed Present on a removed device goes through the existing device-removal diagnostic path. ## Reproduction On the base revision, inspect `Host::present`: the return from `IDXGISwapChain::Present` is discarded and the frame counter is incremented unconditionally. The regression exercises the three return paths with `S_OK`, `DXGI_STATUS_OCCLUDED`, and `DXGI_ERROR_DEVICE_REMOVED`. ## Verification - `cargo test --workspace --lib --locked --offline present_result_distinguishes_occlusion_from_success_and_failure` passed on Windows. - `git diff --check` passed. - The regression uses simulated HRESULTs. No physical device removal was triggered. [DXGI Present return values](https://learn.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgiswapchain-present)
acetonahard-code commented 2026-11-24 21:03:48 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by acetonahard-code on 2026-11-24T20:58:48Z.


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

cargo test -p victory-gpu passed failed ignored
main 50 0 1
main + this PR 51 0 1
main, --all-features 53 0 -
main + this PR, --all-features 54 0 -
  • 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.
  • Minor: cargo fmt --check would rewrap 2 blocks this PR adds (host.rs). main isn't rustfmt-clean either, so take it or leave it.

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:7144313123 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1461#issuecomment-7144313123). Originally posted by [acetonahard-code](https://github.com/acetonahard-code) on 2026-11-24T20:58:48Z. --- Tested on Windows 11, RTX 4070 SUPER (driver 621.14), with the repo toolchain, merged into current `main` (ffe310e): | `cargo test -p victory-gpu` | passed | failed | ignored | |---|---|---|---| | `main` | 50 | 0 | 1 | | `main` + this PR | 51 | 0 | 1 | | `main`, `--all-features` | 53 | 0 | - | | `main` + this PR, `--all-features` | 54 | 0 | - | - 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. - Minor: `cargo fmt --check` would rewrap 2 blocks this PR adds (`host.rs`). `main` isn't rustfmt-clean either, so take it or leave it. I didn't test with game data. --- <sub>Tested locally with an AI-assisted script (Claude Code); I checked the results before posting.</sub>
mercuryVM commented 2026-11-24 21:28:04 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T21:21:33Z.

Review: APPROVED


Tested f9822de on Windows 11, RTX 5070, MSVC: builds, cargo test --workspace --no-fail-fast 638 passed, 0 failed (on our fork main). present_result_distinguishes_occlusion_from_success_and_failure passes.

  • Checking the Present HRESULT is right. DXGI_STATUS_OCCLUDED is a success code, so ok() alone would count an occluded frame as shown, and the explicit comparison handles that.
  • A failed Present on a removed device now reaches the existing removal report instead of being silently discarded.
  • The early return None paths skip only the frame meter. The one caller (queue.rs, PresentX) uses the return value only for the diagnostics black-frame log, so the title's present path is unchanged and can't stall on an occluded or minimized window.
  • The warning is rate-limited per consecutive status, so a minimized window doesn't flood the log.
  • Nit: while occluded, DXGI suggests polling with DXGI_PRESENT_TEST instead of presenting. Calling Present(0) every frame is harmless, but it's an option if occlusion costs time.

Merged into our fork's main.

AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:review:6047612539 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1461#pullrequestreview-6047612539). Originally posted by [mercuryVM](https://github.com/mercuryVM) on 2026-11-24T21:21:33Z. **Review:** APPROVED --- Tested f9822de on Windows 11, RTX 5070, MSVC: builds, `cargo test --workspace --no-fail-fast` 638 passed, 0 failed (on our fork main). `present_result_distinguishes_occlusion_from_success_and_failure` passes. - Checking the `Present` HRESULT is right. `DXGI_STATUS_OCCLUDED` is a success code, so `ok()` alone would count an occluded frame as shown, and the explicit comparison handles that. - A failed `Present` on a removed device now reaches the existing removal report instead of being silently discarded. - The early `return None` paths skip only the frame meter. The one caller (`queue.rs`, `PresentX`) uses the return value only for the diagnostics black-frame log, so the title's present path is unchanged and can't stall on an occluded or minimized window. - The warning is rate-limited per consecutive status, so a minimized window doesn't flood the log. - Nit: while occluded, DXGI suggests polling with `DXGI_PRESENT_TEST` instead of presenting. Calling `Present(0)` every frame is harmless, but it's an option if occlusion costs time. Merged into our fork's main. AI-assisted (Claude Code).
Marvisak commented 2026-11-25 02:06:06 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T01:28:48Z.


Automated triage for the maintainers.

Merge candidate. This now merges cleanly onto current main. Host::present in crates/victory-gpu/src/host.rs stopped discarding the Present HRESULT: an occluded window (DXGI_STATUS_OCCLUDED, a success code) skips the frame meter and returns None, a removed device goes through the existing fail path with removal_data/last_notes, and other failures are logged once per consecutive status. I checked the merged present and its caller in queue.rs (a None only affects the diagnostics blink check), and the behaviour matches the linked DXGI documentation. CI: no check runs on this head. A contributor reported in this thread that the build, tests and clippy pass on Windows with this PR merged into main. This is a recommendation to look, not an approval.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7149592803 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1461#issuecomment-7149592803). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T01:28:48Z. --- <!-- victory-triage v1 head=f9822de8b349509db3c7489d82870bde2df325ab verdict=merge-candidate at=2026-11-25T15:52:39Z --> Automated triage for the maintainers. **Merge candidate.** This now merges cleanly onto current `main`. `Host::present` in `crates/victory-gpu/src/host.rs` stopped discarding the `Present` HRESULT: an occluded window (`DXGI_STATUS_OCCLUDED`, a success code) skips the frame meter and returns `None`, a removed device goes through the existing `fail` path with `removal_data`/`last_notes`, and other failures are logged once per consecutive status. I checked the merged `present` and its caller in `queue.rs` (a `None` only affects the diagnostics blink check), and the behaviour matches the linked DXGI documentation. CI: no check runs on this head. A contributor reported in this thread that the build, tests and clippy pass on Windows with this PR merged into `main`. This is a recommendation to look, not an approval. --- _Generated by [Claude Code](https://claude.ai/code)_
upstream-sync closed this pull request 2026-11-25 22:03:01 +00:00
Marvisak commented 2026-11-25 22:04:40 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T22:01:22Z.


Automated triage for the maintainers, second look (a review against current main, with builds and tests where they could change the verdict).

Closing because, on current main, skipping the frame meter on an occluded present would break bookkeeping. This was written when Meter::frame was only the fps counter. It now also advances the frame count that title-memory withholding compares against and runs the frame-end drop of withheld writes, so returning before it while the window is minimised would keep every title-memory list's writes withheld until the window is restored. What remains without the occlusion branch is a warning line and an earlier failure on device removal, which Host::execute already reports at the next submission.

If this is mistaken, reply here with what was missed and it will be looked at again. Thank you for the contribution.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7175836301 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1461#issuecomment-7175836301). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T22:01:22Z. --- Automated triage for the maintainers, second look (a review against current `main`, with builds and tests where they could change the verdict). Closing because, on current `main`, skipping the frame meter on an occluded present would break bookkeeping. This was written when `Meter::frame` was only the fps counter. It now also advances the frame count that title-memory withholding compares against and runs the frame-end drop of withheld writes, so returning before it while the window is minimised would keep every title-memory list's writes withheld until the window is restored. What remains without the occlusion branch is a warning line and an earlier failure on device removal, which `Host::execute` already reports at the next submission. If this is mistaken, reply here with what was missed and it will be looked at again. Thank you for the contribution.

Pull request closed

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!1460
No description provided.