gpu: avoid three AMD device removals (alias default, aside flight, enhanced barriers) #176

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

@⁠scarlett7023 on GitHub · 2026-12-05 21:06 UTC · original
scarlett7023:fix/amd-device-removals → main · +41 −2 · 3 files · 1 commits · open

Three small fixes for the device removals we hit on an RX 7900 XT (Windows 11 23H2, driver 32.0.32015.16001). All three were reproduced on a self-compiled --features diagnostics build with VICTORY_D3D12_DEBUG=1, and each one alone is enough to kill a session.

1. Zero-copy alias kills a plain double-clicked launch

crates/victory-gpu/src/resource.rs - relaxed_format_casting(). With the alias enabled the first frames already fail, before any of the fence problems show up:

CreateShaderResourceView: The Format (0x43, R9G9B9E5_SHAREDEXP) is invalid when creating a View;
it is not a fully qualified format within the same family as the Format of the Resource (0x2a, R32_UINT).
... device removed (0x887A0005)

The fix flips the default: the alias is now opt-in (VICTORY_DIRECT_ALIAS=1), instead of opt-out. This is the one that makes a launcher-started run die instantly, so it is the difference between "crashes on launch" and "runs".

2. The resident copy list is re-executed before its previous flight lands

crates/victory-gpu/src/host.rs, mapped_at(). The single recorded Aside.list is executed on the copy queue every time card memory is made, and nothing waits for the previous execution. Two threads making memory at once re-execute it while the old flight is pending, which D3D12 rejects:

ID3D12CommandQueue::ExecuteCommandLists: Failed to execute a command list 0x...:'Unnamed ID3D12GraphicsCommandList Object'
because the command queue fence has not advanced past previous executions of the command list. id=553

Adding a wait before the submission (a.fence.GetCompletedValue() < a.value -> SetEventOnCompletion(a.value, None), which blocks) makes id 553 disappear. @YamoriCou tested this on RDNA 2 with the JOIN defaults left on (VICTORY_JOIN_SEND=1 VICTORY_JOIN_PARTS=8), which used to crash within seconds, and got 34+ minutes with no errors at ~27.6 fps in v0.6.0.

3. ID3D12GraphicsCommandList7 is QI'd on devices without enhanced barriers

crates/victory-gpu/src/host/rec.rs. The QI succeeds even when D3D12_OPTIONS12::EnhancedBarriersSupported is false, and the first barrier recorded through it then fails:

ID3D12CommandList::Barrier: Enhanced barriers are not supported on the current device (id=1343)

The fix asks the device first (CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS12)) and keeps list7 as None when it is not supported, falling back to legacy barriers.

Testing

With the three changes, a plain double-clicked launch with no environment variables at all runs with 0 ERROR lines and no device removal. 3840x2160 native is GPU-bound at ~12 fps on the 7900 XT, both with this build and with the official binary once the pipeline warm-up is done, so the changes do not regress performance. cargo check -p victory is clean (no warnings).

Happy to adjust naming/comments to match the project's conventions.

**@⁠scarlett7023** on GitHub · 2026-12-05 21:06 UTC · [original](https://github.com/ReTerryDavis/ReVIctory/pull/175) `scarlett7023:fix/amd-device-removals` → `main` · +41 −2 · 3 files · 1 commits · open Three small fixes for the device removals we hit on an RX 7900 XT (Windows 11 23H2, driver 32.0.32015.16001). All three were reproduced on a self-compiled `--features diagnostics` build with `VICTORY_D3D12_DEBUG=1`, and each one alone is enough to kill a session. **1. Zero-copy alias kills a plain double-clicked launch** `crates/victory-gpu/src/resource.rs` - `relaxed_format_casting()`. With the alias enabled the first frames already fail, before any of the fence problems show up: ``` CreateShaderResourceView: The Format (0x43, R9G9B9E5_SHAREDEXP) is invalid when creating a View; it is not a fully qualified format within the same family as the Format of the Resource (0x2a, R32_UINT). ... device removed (0x887A0005) ``` The fix flips the default: the alias is now opt-in (`VICTORY_DIRECT_ALIAS=1`), instead of opt-out. This is the one that makes a launcher-started run die instantly, so it is the difference between "crashes on launch" and "runs". **2. The resident copy list is re-executed before its previous flight lands** `crates/victory-gpu/src/host.rs`, `mapped_at()`. The single recorded `Aside.list` is executed on the copy queue every time card memory is made, and nothing waits for the previous execution. Two threads making memory at once re-execute it while the old flight is pending, which D3D12 rejects: ``` ID3D12CommandQueue::ExecuteCommandLists: Failed to execute a command list 0x...:'Unnamed ID3D12GraphicsCommandList Object' because the command queue fence has not advanced past previous executions of the command list. id=553 ``` Adding a wait before the submission (`a.fence.GetCompletedValue() < a.value` -> `SetEventOnCompletion(a.value, None)`, which blocks) makes id 553 disappear. `@YamoriCou` tested this on RDNA 2 with the JOIN defaults left on (`VICTORY_JOIN_SEND=1 VICTORY_JOIN_PARTS=8`), which used to crash within seconds, and got 34+ minutes with no errors at ~27.6 fps in v0.6.0. **3. `ID3D12GraphicsCommandList7` is QI'd on devices without enhanced barriers** `crates/victory-gpu/src/host/rec.rs`. The QI succeeds even when `D3D12_OPTIONS12::EnhancedBarriersSupported` is false, and the first barrier recorded through it then fails: ``` ID3D12CommandList::Barrier: Enhanced barriers are not supported on the current device (id=1343) ``` The fix asks the device first (`CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS12)`) and keeps `list7` as `None` when it is not supported, falling back to legacy barriers. **Testing** With the three changes, a plain double-clicked launch with no environment variables at all runs with 0 ERROR lines and no device removal. 3840x2160 native is GPU-bound at ~12 fps on the 7900 XT, both with this build and with the official binary once the pipeline warm-up is done, so the changes do not regress performance. `cargo check -p victory` is clean (no warnings). Happy to adjust naming/comments to match the project's conventions.
- resource: default the zero-copy R32_UINT -> R9G9B9E5 alias off; on some
  drivers CreateShaderResourceView rejects the view format (0x43 vs 0x2a)
  and the device is removed on the first frame. Opt in with
  VICTORY_DIRECT_ALIAS=1.
- host: before re-submitting the resident copy list in mapped_at(), wait for
  its previous flight to land. Re-executing it on the copy queue while the
  fence is behind is what the debug layer reports as a command list whose
  fence has not advanced (id 553).
- host/rec: only QI ID3D12GraphicsCommandList7 when the device reports
  D3D12_OPTIONS12::EnhancedBarriersSupported; the QI alone succeeds on
  devices without enhanced barriers and the first Barrier() then fails
  (id 1343).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-05 21:10:21 +00:00
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/176/head:github-bot/gh-175'
git switch 'github-bot/gh-175'

Merge

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