Skip to content

GPU: create a texture without a host UAV format without the flag - #2319

Open
Calvix2k wants to merge 2 commits into
Marvisak:mainfrom
Calvix2k:codex/gpu-uav-format-fallback-2307
Open

Calvix2k wants to merge 2 commits into
Marvisak:mainfrom
Calvix2k:codex/gpu-uav-format-fallback-2307

Conversation

@Calvix2k

Copy link
Copy Markdown
Contributor

A texture the title creates with D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS in a format the host has no typed UAV for, and with no typeless family to stand in (B5G5R5A1_UNORM, and the console's two-byte formats that pass through as DXGI numbers), removes the device: on a strict driver GetResourceAllocationInfo fails with

D3D12_RESOURCE_DESC::Format is B5G5R5A1_UNORM; a texture that has ALLOW_UNORDERED_ACCESS must be created with a format that ... can be used as unordered access

as reported in #2307 on an RTX 3070 / Windows 10. The title then runs at 30 fps with a black screen.

What the fix does

host_desc drops ALLOW_UNORDERED_ACCESS for exactly those textures — no family to map to, and typed_store says the device cannot make a typed unordered view of the format — and logs a one-time warning naming the format. The texture is created, the title keeps running, and its unordered views are refused later by fits (the view half, #1763). Formats with a family are untouched: the sRGB mapping and the case where the device does store to the type keep the flag.

Verification

  • cargo test -p victory-gpu --features diagnostics --lib on Windows 10 19045 / RX 7800 XT: 146 passed, 1 failed — the known placed-view test on a runtime without ID3D12Device10 (GPU tests: placed R32_UINT -> R9G9B9E5 view does not share its host texture (Windows 10, RX 7800 XT) #1999), identical on main; clippy -D warnings clean.
  • New test a_format_without_unordered_access_loses_the_flag covers the drop and the "keeps the flag" arm. On the AMD driver here typed_store reports true for 85/86/115, so the drop arm skips; that is why the device removal is NVIDIA-only in the report. It needs an NVIDIA or WARP run to be exercised for real.

@DenRakEiw DenRakEiw left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified against origin/main (940d32f) on Windows 11 + NVIDIA GeForce RTX 5090 and WARP:

  • Stripping UNORDERED in host_desc when a format has no typeless family and !descriptor::host::typed_store(d.format) (e.g. B5G5R5A1 / 86 on NVIDIA) cleanly avoids device removal while preserving UNORDERED for UAV-capable formats. (Minor nit: a_format_without_unordered_access_loses_the_flag is placed just outside mod tests { ... } at the bottom of resource.rs, though it compiles and runs cleanly.)
  • cargo test -p victory-gpu a_format_without_unordered_access_loses_the_flag: 1/1 passed on RTX 5090, 1/1 passed on WARP.
  • cargo clippy -p victory-gpu --all-targets -- -D warnings: 0 warnings.
  • cargo xtask policy: 183 files ok.

AI-assisted (Gemini 4 Neon).

@catminou4 catminou4 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A texture without a host UAV format is created without the unordered flag instead of removing the device (typed_store probe). Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1. Ties to #2305/#2332 vendor workaround cluster for #1952-adjacent device removals.

@qtLkz

qtLkz commented Nov 25, 2026

Copy link
Copy Markdown

Ran the drop arm on NVIDIA, with the output visible: RTX 4070 Ti (Ada), driver 621.01, Windows 11 Pro build 26300, Rust 1.98.1 pinned, this PR on top of main 940d32f.

cargo test -p victory-gpu --lib --locked a_format_without_unordered_access_loses_the_flag -- --nocapture
running 1 test
test resource::a_format_without_unordered_access_loses_the_flag ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 145 filtered out

No this device stores to 86 as a typed UAV; skipped line was printed, so on this card typed_store(86) is false and the test really took the drop arm: format 86 with ALLOW_UNORDERED_ACCESS comes back from host_desc without the flag and still as 86. The "28 keeps the flag" arm ran as well (no assertion failed).

This matters because the test returns early as a pass when the device does report a typed UAV for 86 (as on the RX 7800 XT above), so a bare "1/1 passed" does not by itself show the new arm ran. With --nocapture, the missing skip line does show it.

Same nit as above: the test sits just outside mod tests (its path is resource::a_format_without_unordered_access_loses_the_flag), harmless.

AI-assisted (Claude).

Marvisak commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.

Merge candidate (worth a look; small). resource.rs host_desc now drops ALLOW_UNORDERED_ACCESS only for a format with no family at all (family(f) == f && family(f + 1) != f, the same test descriptor::host::fits uses) that the host cannot use for typed unordered views (typed_store). This stops the device removal from #2307 for formats such as B5G5R5A1. Typeless heads (sRGB UAV textures turned typeless, R32_TYPELESS) keep the flag, so the gap from the previous review is closed. Their unordered views behave as on main. A refused view on a dropped format is then refused in fits, as the comment says. The test is inside mod tests now, and its sRGB assertion (29 keeps the flag and becomes 27) runs before the device-dependent early return, so it runs on every host. An RTX 4070 Ti run in this thread shows the drop arm executing. CI check: passing. Nit: resource.rs now ends with an extra blank line.

On your reply: confirmed. The condition and the test match what was asked.


Generated by Claude Code

Part of Marvisak#2307 (the allocation half; Marvisak#1763 covers the view half).

A texture the title creates with `D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS` in a format the host has no typed UAV for, and that has no typeless family to stand in (`B5G5R5A1_UNORM`, and the console's two-byte formats that pass through as DXGI numbers), removes the device at `GetResourceAllocationInfo` on a strict driver: "a texture that has ALLOW_UNORDERED_ACCESS must be created with a format that ... can be used as unordered access". `host_desc` now drops the flag for exactly those formats with a one-time warning, so the texture is created and the title keeps running; its unordered views are refused later by `fits` (Marvisak#1763), instead of the device disappearing.

Formats with a family are untouched: the sRGB case keeps its existing mapping, and a format whose type the device stores to keeps the flag.

## Verification

- `cargo test -p victory-gpu --features diagnostics --lib` on Windows 10 19045 / RX 7800 XT: 146 passed, 1 failed — the known placed-view test on a runtime without `ID3D12Device10` (Marvisak#1999), identical on `main`; clippy `-D warnings` clean.
- `a_format_without_unordered_access_loses_the_flag` checks the new arm and the "keeps the flag" arm. It skips where the device does report a typed UAV for those formats — this AMD driver does (85, 86, 115 all true here), which is why the removal is NVIDIA-only in the reports; the drop needs an NVIDIA/WARP run to be exercised.
Review feedback on Marvisak#2319: `family(f) == f` is also true for every typeless
format, so the new drop would have taken `ALLOW_UNORDERED_ACCESS` from sRGB
textures the block above just made typeless (29 -> 27, 91 -> 90, 93 -> 92)
and from typeless UAV textures of the title's own (R32_TYPELESS). Their
unordered views would then be refused by `descriptor::host::fits`, a
regression from `main`.

Use the test `fits` uses for "no family at all": `family(f) == f &&
family(f + 1) != f`. The test now also checks that an sRGB UAV texture (29)
keeps the flag and comes out as its typeless family 27; that assertion runs
before the device-dependent early return, so it is checked on AMD too. Move
the test inside `mod tests` (it sat after the module's closing brace).
@Calvix2k
Calvix2k force-pushed the codex/gpu-uav-format-fallback-2307 branch from f908b04 to 3558858 Compare November 25, 2026 16:15
@Calvix2k

Copy link
Copy Markdown
Contributor Author

The gap is fixed in 3558858 (rebased onto main 67e8ae1): the drop now needs family(f) == f && family(f + 1) != f, the same "no family at all" test fits uses, so typeless formats (sRGB UAVs turned typeless, R32_TYPELESS) keep ALLOW_UNORDERED_ACCESS and their unordered views stay as on main.

The test also covers that: an sRGB UAV texture (29) keeps the flag and comes out as its typeless family 27. I put that assertion before the device-dependent typed_store(86) early return so it runs on AMD too (here 86 answers true and the B5G5R5A1 half skips). The test is now inside mod tests.

Local: cargo test -p victory-gpu --features diagnostics --lib 146 passed / 2 ignored, plus the known placed-view failure (#1999); clippy -D warnings clean.

@fyernald fyernald left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked on a host that's a little different from the ones in this thread: RTX 3080 (Ampere), driver 617.42, Windows 10 (19045), main 67e8ae1.

On this driver the UAV-flagged B5G5R5A1_UNORM texture doesn't remove the device. It fails differently. I placed one through create_placed and read it back with host_copy (local probe test):

host texture flags device
main not made (host_copy → None) – not removed
this PR made 0x0 (no ALLOW_UNORDERED_ACCESS) not removed

So on older drivers the same bug means the texture is simply missing, and this PR fixes that case too.

Negative control: with the host_desc change taken out and the new test kept, a_format_without_unordered_access_loses_the_flag fails here with 86 has no typed UAV (left: 4, right: 0). With the PR the test passes, and the full cargo test -p victory-gpu --lib --locked gives 193 passed, 3 failed. Those 3 also fail on main here: the heap cap (FIND-9) and the Windows 10 castable test (#1999). With #2462 merged on top, the results are the same.

This host has no ID3D12Device10. I also checked that sRGB UAV textures keep the flag, as on main (29 → 27 and 91 → 90, both still unordered). The PR's own sRGB assertion passes here too.

@davesousa

Copy link
Copy Markdown

In-game result on NVIDIA: RTX 3070 Ti (Ampere, 8 GB), driver 621.40, Windows 11 26200, 32 GB RAM. Title Series 1.0.2.1. diag build (--features diagnostics), after translate --cache --pipelines. This PR (3558858) merged onto main 13f91ca. On this card, a_format_without_unordered_access_loses_the_flag passes without its skip line, so the drop arm runs.

Build Result
main 13f91ca Host device removed about 35 s after start, during the first-boot screens, in 2 of 2 runs. With VICTORY_D3D12_DEBUG=1, the last messages before RemoveDevice (DXGI_ERROR_INVALID_CALL) are id=599 at GetResourceAllocationInfo (B5G5R5A1_UNORM with ALLOW_UNORDERED_ACCESS) and id=342 (typed UAV of B5G5R5A1_UNORM). This is the same as #2563 on an RTX 3070.
main + #2319 (3558858) No removal at that point. The log shows the PR's warning once (format=86). First-boot, legal and start screens run at 30 fps (33.3 ms/frame) for 6 minutes.

After the start screen, while loading into the world, the + #2319 run ended with a GPU hang: 0x887A0006, after a 10.5 s submission of 34 lists (TDR delay 8 s). The log shows 42 compute pipelines refused by the host before it. That looks like the known NVIDIA world hang (#1968, #2220), not this PR.

Also seen on both builds, unchanged by this PR: view heap capped at 1,000,000 (the title asks for 1,245,184; #1760), and the 2560x1440 format 115 render target refused (#797).

AI-assisted (Claude Code); the runs are on my machine.

@KainanP

KainanP commented Nov 25, 2026

Copy link
Copy Markdown

RTX 4060 Laptop (610.47), merged onto main 13f91ca: B5G5R5A1 UAV half fixed (flag dropped, UAVs null), B4G4R4A4 target half still removes the device; no new failures in cargo test -p victory-gpu. Details and the side-by-side table with the other #1753 PRs: #1753 (comment). Tested with the help of an AI assistant (Claude Code).

@qtLkz

qtLkz commented Nov 25, 2026

Copy link
Copy Markdown

Re-ran the updated head (3558858) on the same NVIDIA setup: RTX 4070 Ti, driver 621.01, Windows 11 Pro build 26300, merged onto main 13f91ca (clean merge).

cargo test -p victory-gpu --lib --locked a_format_without_unordered_access_loses_the_flag -- --nocapture
test resource::tests::a_format_without_unordered_access_loses_the_flag ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 196 filtered out

Again no "skipped" line, so the drop arm for 86 ran. The new sRGB case (29 keeps the flag as typeless 27) passes too, and the test now sits inside mod tests (path resource::tests::...). Thanks for moving it.

AI-assisted (Claude).

@krcenov

krcenov commented Nov 25, 2026

Copy link
Copy Markdown

Tested this PR at 3558858 on an RTX 3070 (driver 32.0.16.1714), Windows 10 22H2 (19045). The only local change is an Agility SDK 1.620.2 export (D3D12SDKVersion/D3D12SDKPath), which Windows 10 needs; see #2563. It was a diag build with VICTORY_D3D12_DEBUG=1 VICTORY_D3D12_DRED=1.

  • Fixed: No device removal in a 5-minute run. On 940d32f without a fix, the device was removed at 40–66 s. It held a steady 30 fps on menus and loading screens.
  • Format 86 handled: The B5G5R5A1 texture is created without the unordered flag. The view is then refused instead of removing the device: view the host does not allow unordered=true format=86 flags=1.
  • Still reported, not fatal: The format-115 render target (id=817 / id=599, B4G4R4A4_UNORM) and NumDescriptors 2097152 (id=645).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants