GPU: a present waits for its copy before reading the probe and capture #197

Open
github-bot wants to merge 1 commit from github-bot/gh-197 into main AGit
Owner

@⁠WHOISJARDAS on GitHub · 2026-11-25 21:11 UTC · original
WHOISJARDAS:gpu/async-present-wait → main · +13 −0 · 1 files · 1 commits · open

With VICTORY_ASYNC_SUBMIT=1 the presenter's copy list can still be queued when execute returns. In diagnostics builds (the build this README runs), present then reads the black-frame probe, and a wanted capture, before the copy has run, and drops them when it returns. The D3D12 debug layer stops at EXECUTION ERROR #921: OBJECT_DELETED_WHILE_STILL_IN_USE in Host::present; without the debug layer the device is removed reading the freed probe (DRED: page fault at 0x20005a000; inside freed [8 × unnamed (type 34)], the same address every run, a buffer made and freed on each present).

present and present_over now wait for the in-flight work when they have a probe or a capture to read. Release builds have neither, so nothing changes there.

Tested

RX 9070 XT 16 GB (driver 32.0.32029.2010), Ryzen 7 9800X3D, Windows 11 26200, Series X profile, this README's settings, VICTORY_ASYNC_SUBMIT=1:

result
4cbe9d7 (+ #39 so that it starts here) device removed 4-5 s in, 3 of 3 runs (VICTORY_D3D12_DRED=1, VICTORY_KEEP_RETIRED=1 and VICTORY_D3D12_DEBUG=1 runs)
with this 127 s and a 6-minute run with no exception or device removal

For what it's worth, on the same save and camera async submission did not raise the frame rate here: median 4.6 fps with it, 5.4 without (most world submissions copy back, which makes them wait anyway). So this only makes the switch usable for experiments; it keeps its default.

AI use: Claude Code (Claude Opus 5.5) found the freed object with DRED and the debug layer and wrote the change; the hardware and runs are mine.

🤖 Generated with Claude Code

**@⁠WHOISJARDAS** on GitHub · 2026-11-25 21:11 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/197) `WHOISJARDAS:gpu/async-present-wait` → `main` · +13 −0 · 1 files · 1 commits · open With `VICTORY_ASYNC_SUBMIT=1` the presenter's copy list can still be queued when `execute` returns. In diagnostics builds (the build this README runs), `present` then reads the black-frame probe, and a wanted capture, before the copy has run, and drops them when it returns. The D3D12 debug layer stops at `EXECUTION ERROR #921: OBJECT_DELETED_WHILE_STILL_IN_USE` in `Host::present`; without the debug layer the device is removed reading the freed probe (DRED: `page fault at 0x20005a000; inside freed [8 × unnamed (type 34)]`, the same address every run, a buffer made and freed on each present). `present` and `present_over` now wait for the in-flight work when they have a probe or a capture to read. Release builds have neither, so nothing changes there. ## Tested RX 9070 XT 16 GB (driver 32.0.32029.2010), Ryzen 7 9800X3D, Windows 11 26200, Series X profile, this README's settings, `VICTORY_ASYNC_SUBMIT=1`: | | result | |---|---| | `4cbe9d7` (+ #39 so that it starts here) | device removed 4-5 s in, 3 of 3 runs (`VICTORY_D3D12_DRED=1`, `VICTORY_KEEP_RETIRED=1` and `VICTORY_D3D12_DEBUG=1` runs) | | with this | 127 s and a 6-minute run with no exception or device removal | For what it's worth, on the same save and camera async submission did not raise the frame rate here: median 4.6 fps with it, 5.4 without (most world submissions copy back, which makes them wait anyway). So this only makes the switch usable for experiments; it keeps its default. AI use: Claude Code (Claude Opus 5.5) found the freed object with DRED and the debug layer and wrote the change; the hardware and runs are mine. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
With VICTORY_ASYNC_SUBMIT=1 the presenter's copy list can run after
`execute` returns. In diagnostics builds `present` then read the
black-frame probe (and a wanted capture) before the copy had run, and
dropped them when it returned: the D3D12 debug layer stops at #921
OBJECT_DELETED_WHILE_STILL_IN_USE in `Host::present`, and without it the
device is removed reading the freed probe (DRED: page fault inside a
freed resource, the same address each time), 4 s into the run.

`present` and `present_over` now wait for in-flight work when they have
something to read back. Release builds have no probe or capture.

RX 9070 XT, driver 32.0.32029.2010: with async submissions the run was
removed 4 s in (3 of 3); with this, 127 s and a 6-minute run held with no
exception.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:37:45 +00:00
Author
Owner

@⁠adrianmjim on GitHub · 2026-11-26 19:46 UTC · original

Tested natively on Windows 11 (build 26300) with an RX 7900 XT (driver 32.0.32029.2010), at head 48821bf, its base 4cbe9d7, and current main 4f62c2a.

Main has had a fix for the same crash since 9b89ec2 (2026-11-25), which is after this PR's base:

  • 9b89ec2 adds Host::execute_title. Only the title's submissions (queue.rs) may now return before the GPU is done.
  • present and present_over still call Host::execute, which passes no keep. That makes can_async false, so the call waits on its fence before it returns.
  • So on main, the probe and capture copy has already finished when present reads them. With this PR applied to 4f62c2a, the two new wait_in_flight() calls have nothing of the present's own left to wait for.

Also, a59f3e5 on main makes async submission the default (VICTORY_ASYNC_SUBMIT=0 turns it off). So the line about the switch keeping its default is out of date on main.

What I ran:

  • cargo test -p victory-gpu --lib, debug build, with and without --features diagnostics.
  • Base 4cbe9d7 and the PR head: 3 runs each, interleaved.
  • Main 4f62c2a and main + this PR (merges cleanly): 2 runs each, interleaved.
  • No new failures and no new warnings. Every failure also happens without the PR and looks like a timing flake: frame::tests::waits_end_on_ticks_and_count_frames (most runs), depth_bounds_control_a_title_draw and two watch::tests failures. Other heavy jobs were running on the machine at the same time.

Not tested:

  • No game run. I did not reproduce the device removal at 4cbe9d7, and I did not run the game on main with diagnostics and async submission.
  • The unit tests can't cover this path, because can_async is off under cfg(test).

Unless there is a path on main where a present's copy can still return early, this PR looks superseded by 9b89ec2.

**@⁠adrianmjim** on GitHub · 2026-11-26 19:46 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/197#issuecomment-7201947264) Tested natively on Windows 11 (build 26300) with an RX 7900 XT (driver 32.0.32029.2010), at head 48821bf, its base 4cbe9d7, and current main 4f62c2a. Main has had a fix for the same crash since 9b89ec2 (2026-11-25), which is after this PR's base: - 9b89ec2 adds `Host::execute_title`. Only the title's submissions (queue.rs) may now return before the GPU is done. - `present` and `present_over` still call `Host::execute`, which passes no `keep`. That makes `can_async` false, so the call waits on its fence before it returns. - So on main, the probe and capture copy has already finished when `present` reads them. With this PR applied to 4f62c2a, the two new `wait_in_flight()` calls have nothing of the present's own left to wait for. Also, a59f3e5 on main makes async submission the default (`VICTORY_ASYNC_SUBMIT=0` turns it off). So the line about the switch keeping its default is out of date on main. What I ran: - `cargo test -p victory-gpu --lib`, debug build, with and without `--features diagnostics`. - Base 4cbe9d7 and the PR head: 3 runs each, interleaved. - Main 4f62c2a and main + this PR (merges cleanly): 2 runs each, interleaved. - No new failures and no new warnings. Every failure also happens without the PR and looks like a timing flake: `frame::tests::waits_end_on_ticks_and_count_frames` (most runs), `depth_bounds_control_a_title_draw` and two `watch::tests` failures. Other heavy jobs were running on the machine at the same time. Not tested: - No game run. I did not reproduce the device removal at 4cbe9d7, and I did not run the game on main with diagnostics and async submission. - The unit tests can't cover this path, because `can_async` is off under `cfg(test)`. Unless there is a path on main where a present's copy can still return early, this PR looks superseded by 9b89ec2.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
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/197/head:github-bot/gh-197'
git switch 'github-bot/gh-197'

Merge

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