Keep HUD staging and display buffers alive until the GPU finishes #359

Open
github-bot wants to merge 1 commit from github-bot/gh-359 into a-publier AGit
Owner

@⁠ANDREANIADS on GitHub · 2026-11-26 21:51 UTC · original
ANDREANIADS:fix-hud-submission-lifetime → a-publier · +30 −38 · 1 files · 1 commits · open

Resizing the optional HUD or changing its swap-chain format abandons its previous card buffer and four upload buffers via mem::forget. Repeated format or scale changes retain every set. The four upload slots also rotate by time. If more than four refreshes are recorded before execution, a later refresh can overwrite bytes that an earlier command still needs.

The patch stages each new picture at an offset in the recording command list’s upload storage and keeps the display buffer on that list through submission. A scale or format change can then release the panel’s reference. No wait is added to the drawing path. Failed staging reuses an existing picture when available and retries at the next sample. At 4K with an FP16 swap chain the surface exceeds the 4 MiB scratch page, so that refresh can require a dedicated scratch allocation.

Before and after on two physical adapters

I recorded nine synthetic HUD updates before submitting their command lists together. The sequence included two scales, RGBA8 and FP16, and a nonzero upload offset. The panel stayed alive through execution. After waiting on the queue’s fence, I compared the card-buffer readbacks to the expected packed pixels and reset the completed lists.

Observation Original cd8dfc0 This change
Matching update images 7/9 (updates 0 and 1 were wrong) 9/9, byte for byte
References to the first retired card buffer after fence and reset 2 including the test observer 1, the observer alone

I ran the attached regression separately on a GeForce RTX 3070 and on Intel UHD Graphics 630. Both reproduced the same two mismatches in the original and all nine byte-exact readbacks with the patch. On both adapters the first retired buffer had two references after completion on the original and only the observer on the fixed build. The Intel run exercises D3D12 copies and resource lifetime independently of the game’s shader requirements.

All three existing HUD unit tests passed. I checked that the patch applies independently to the default branch and on top of #348. Validation used Rust 1.98.0 MSVC and locally available dependencies. The experiment measures resource lifetime and pixel correctness under a delayed submission. It does not measure gameplay frame rate.

Implemented and tested with Codex.

Reproduce the queued readback

The attached test patch applies to the base and the proposed change. Extract it, then run from the repository root on Windows with a D3D12 adapter. Substitute the adapter name if needed.

git apply hud-delayed-regression.patch
$env:VICTORY_PANEL = "1"
$env:VICTORY_D3D12_ADAPTER = "RTX 3070"
cargo test --locked -p victory-gpu --features diagnostics --lib host::panel::queued_lifetime_qa::delayed_refresh_and_resize -- --ignored --exact --nocapture --test-threads=1

hud-delayed-regression.zip

**@⁠ANDREANIADS** on GitHub · 2026-11-26 21:51 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/359) `ANDREANIADS:fix-hud-submission-lifetime` → `a-publier` · +30 −38 · 1 files · 1 commits · open Resizing the optional HUD or changing its swap-chain format abandons its previous card buffer and four upload buffers via `mem::forget`. Repeated format or scale changes retain every set. The four upload slots also rotate by time. If more than four refreshes are recorded before execution, a later refresh can overwrite bytes that an earlier command still needs. The patch stages each new picture at an offset in the recording command list’s upload storage and keeps the display buffer on that list through submission. A scale or format change can then release the panel’s reference. No wait is added to the drawing path. Failed staging reuses an existing picture when available and retries at the next sample. At 4K with an FP16 swap chain the surface exceeds the 4 MiB scratch page, so that refresh can require a dedicated scratch allocation. ### Before and after on two physical adapters I recorded nine synthetic HUD updates before submitting their command lists together. The sequence included two scales, RGBA8 and FP16, and a nonzero upload offset. The panel stayed alive through execution. After waiting on the queue’s fence, I compared the card-buffer readbacks to the expected packed pixels and reset the completed lists. | Observation | Original `cd8dfc0` | This change | |---|---|---| | Matching update images | 7/9 (updates 0 and 1 were wrong) | **9/9**, byte for byte | | References to the first retired card buffer after fence and reset | 2 including the test observer | **1**, the observer alone | I ran the attached regression separately on a **GeForce RTX 3070** and on **Intel UHD Graphics 630**. Both reproduced the same two mismatches in the original and all nine byte-exact readbacks with the patch. On both adapters the first retired buffer had two references after completion on the original and only the observer on the fixed build. The Intel run exercises D3D12 copies and resource lifetime independently of the game’s shader requirements. All three existing HUD unit tests passed. I checked that the patch applies independently to the default branch and on top of #348. Validation used Rust 1.98.0 MSVC and locally available dependencies. The experiment measures resource lifetime and pixel correctness under a delayed submission. It does not measure gameplay frame rate. Implemented and tested with Codex. ### Reproduce the queued readback The attached test patch applies to the base and the proposed change. Extract it, then run from the repository root on Windows with a D3D12 adapter. Substitute the adapter name if needed. ```powershell git apply hud-delayed-regression.patch $env:VICTORY_PANEL = "1" $env:VICTORY_D3D12_ADAPTER = "RTX 3070" cargo test --locked -p victory-gpu --features diagnostics --lib host::panel::queued_lifetime_qa::delayed_refresh_and_resize -- --ignored --exact --nocapture --test-threads=1 ``` [hud-delayed-regression.zip](https://github.com/user-attachments/files/35484904/hud-delayed-regression.zip)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 00:58:28 +00:00
Author
Owner

@⁠lvndrpup on GitHub · 2026-11-27 05:30 UTC · original · reviewed

A check of how this sits on the current a-publier, since it was cut from cd8dfc0. Your RTX 3070 and UHD 630 runs already cover the behaviour, so this is only about the merge.

cf46420 merges into 4eb6cfd with no conflict; git merges its panel.rs with the changes made there since cd8dfc0. On the merged tree (RTX 3060 Ti 8 GB, Windows 11 build 26300, Rust 1.98.1, debug):

victory-gpu cargo test --lib cargo clippy --all-targets -- -D warnings
default features 396 passed, 0 failed, 34 ignored clean
--all-features 445 passed, 0 failed, 34 ignored clean

I did not run your attached regression or the HUD in a game.

**@⁠lvndrpup** on GitHub · 2026-11-27 05:30 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/359#pullrequestreview-6083877931) · **reviewed** A check of how this sits on the current `a-publier`, since it was cut from `cd8dfc0`. Your RTX 3070 and UHD 630 runs already cover the behaviour, so this is only about the merge. `cf46420` merges into `4eb6cfd` with no conflict; git merges its `panel.rs` with the changes made there since `cd8dfc0`. On the merged tree (RTX 3060 Ti 8 GB, Windows 11 build 26300, Rust 1.98.1, debug): | `victory-gpu` | `cargo test --lib` | `cargo clippy --all-targets -- -D warnings` | |---|---|---| | default features | 396 passed, 0 failed, 34 ignored | clean | | `--all-features` | 445 passed, 0 failed, 34 ignored | clean | I did not run your attached regression or the HUD in a game.
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/359/head:github-bot/gh-359'
git switch 'github-bot/gh-359'

Merge

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