GPU: handle DXGI Present failures and occlusion #1461

Closed
github-bot wants to merge 1 commit from gh-pr/1461/head into gh-pr/1461/base
Owner

@⁠Luizbc2 on GitHub · 2026-11-24 18:12 UTC · original
Luizbc2:fix/dxgi-present-status → main · +42 −3 · 1 files · 1 commits · closed without merging

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

**@⁠Luizbc2** on GitHub · 2026-11-24 18:12 UTC · [original](https://github.com/Marvisak/VIctory/pull/1461) `Luizbc2:fix/dxgi-present-status` → `main` · +42 −3 · 1 files · 1 commits · closed without merging ## 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)
Check the DXGI HRESULT before recording a presented frame.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:32:44 +00:00
github-bot closed this pull request 2026-11-26 04:32:44 +00:00
Author
Owner

@⁠acetonahard-code on GitHub · 2026-11-24 20:58 UTC · original

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.

**@⁠acetonahard-code** on GitHub · 2026-11-24 20:58 UTC · [original](https://github.com/Marvisak/VIctory/pull/1461#issuecomment-7144313123) 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>
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 01:28 UTC · original · edited 2026-11-25 15:52 UTC

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

**@⁠Marvisak** on GitHub · 2026-11-25 01:28 UTC · [original](https://github.com/Marvisak/VIctory/pull/1461#issuecomment-7149592803) · edited 2026-11-25 15:52 UTC <!-- 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)_
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 22:01 UTC · original

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.

**@⁠Marvisak** on GitHub · 2026-11-25 22:01 UTC · [original](https://github.com/Marvisak/VIctory/pull/1461#issuecomment-7175836301) 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

This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!1461
No description provided.