Skip to content

GPU: drop ALLOW_UNORDERED_ACCESS when the format cannot be a UAV - #2459

Open
roon9e wants to merge 6 commits into
Marvisak:mainfrom
roon9e:fix/uav-format-without-support
Open

roon9e wants to merge 6 commits into
Marvisak:mainfrom
roon9e:fix/uav-format-without-support

Conversation

@roon9e

@roon9e roon9e commented Nov 25, 2026

Copy link
Copy Markdown

Fixes the world-load device removal on a GTX 1660 SUPER (Turing, driver 610.88) that the #1063 report hit on 940d32f.

The D3D12 debug layer named the invalid call:

ID3D12Device::GetResourceAllocationInfo: A texture that has D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS set in D3D12_RESOURCE_DESC::Flags must be created with a format that either can be used as unordered access, or cast to a format that could be used as unordered access. FeatureLevel is D3D_FEATURE_LEVEL_12_1. D3D12_RESOURCE_DESC::Format is B5G5R5A1_UNORM.

The console allows a texture flagged for unordered access in such a packed format; PC D3D12 does not, so the resource creation is invalid and the next submission device-removes (GetDeviceRemovedReason = 0x887A0001).

host_desc now asks the host device (D3D12_FEATURE_FORMAT_SUPPORT, UAV_TYPED_LOAD|UAV_TYPED_STORE) and drops ALLOW_UNORDERED_ACCESS when the format cannot be a UAV; its unordered views are then refused like any other use the host does not take.

Measured on 940d32f (GTX 1660 SUPER, own 1.0.2.1 copy, Agility 1.620.2 in D3D12\):

  • before: device-removes about 10 s into the world load (crashes.log: host GPU device removed … 0x887A0001);
  • after: the run is stable (25 min, crashes.log clean) and reaches the account-picker screen at 30 fps, then Game Running.

This is independent of the codec stop in #1063 — with this change the run reaches that stop instead of dying earlier — and it is independent of pipelines/contents tried before (a pre-built translate --cache --pipelines library, Series S, and disabling depth twins or large title-buffer copies all still device-removed until this format guard).

Thanks for VIctory.

The D3D12 debug layer named the world-load device removal on a GTX 1660 SUPER (Turing): a texture with D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS must be created with a format that can be used as (or cast to) unordered access, but the layer asks for B5G5R5A1_UNORM. The console allows it; PC D3D12 refuses, so the resource creation is invalid and the next submission device-removes.

host_desc now asks the host device (D3D12_FEATURE_FORMAT_SUPPORT, UAV_TYPED_LOAD|UAV_TYPED_STORE) and drops ALLOW_UNORDERED_ACCESS when the format cannot be a UAV; unordered views of it are then refused like any other use the host does not take.

Measured on 940d32f: without this a run device-removes about 10 s into the world load; with it the run is stable (25 min, no fault) and reaches the account-picker screen.

@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:

  • Dropping ALLOW_UNORDERED_ACCESS when a format lacks typed UAV support cleanly avoids invalid D3D12 resource descriptions on NVIDIA (note: overlaps in scope with #2319 and #2442).
  • cargo test -p victory-gpu resource::tests: 10/10 passed on RTX 5090, 10/10 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.

Drop ALLOW_UNORDERED_ACCESS when the format cannot be a UAV. 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. Overlaps #2462 (same format/UAV theme) — check whether one subsumes the other.

@kotekompotek

Copy link
Copy Markdown

Heads-up for triage: #2442 fixes the same #2258 device removal, with two technical differences worth noting:

@oni-swr

oni-swr commented Nov 25, 2026

Copy link
Copy Markdown

Independent WARP verification of #2459 at 1679fbe

Commands (Rust 1.98.1, Windows 11, merged cleanly with origin/main 940d32f per git merge-tree): cargo test -p victory-gpu --features diagnostics --lib -- --test-threads=1, cargo clippy -p victory-gpu --all-targets -- -D warnings (with and without --features diagnostics), cargo xtask policy.

  • lib tests: 146 passed, 0 failed, 2 ignored; clippy clean both ways; policy OK. No unit tests are added by this PR, so no negative control applies.
  • Not a pass on behaviour: the probe below shows this PR also drops the flag from typeless / sRGB-mapped textures that main keeps it on (27, 29, 88, 90-93 on WARP). The code comment says "(and its castable family)" but uav_format only queries the exact format.

4-way comparison of the UAV-flag PRs (#2459 / #2442 / #2319 / #2432)

#2459 #2442 #2319 #2432
Approach drop ALLOW_UNORDERED_ACCESS in host_desc if CheckFeatureSupport(format) has no UAV typed load/store drop the flag unless typed_store(format) or (Device10 and a castable format has typed_store) drop the flag if family(f)==f && !typed_store(f), warns once no flag change: refuses unordered views the host cannot store typed (fits) and uses the live texture's GetDesc() in shared_texture
Typeless / cast-list textures (e.g. 27, and sRGB 29 which host_desc maps to 27) flag dropped (exact-format probe only) kept (cast-list aware) flag dropped (family(27)==27, typed_store(27) false) n/a
New tests none 1 (host-dependent) 1, but placed after the closing } of mod tests none
Conflicts #2442 and #2319 and #2459 all edit the same host_desc spot in resource.rs: pairwise merge conflicts; #2432 merges cleanly with each touches fits/shared_texture, complements a host_desc fix rather than replacing it

WARP probe of host_desc with flags=RENDER_TARGET|UNORDERED, input format -> UAV flag kept (main keeps it for all of these):

Reading: #2442 is the narrowest fix that still honours the cast-list route main already relies on for sRGB/typeless UAV textures. #2459 and #2319 look like they regress those on a device whose typeless format reports no typed UAV (WARP here; hardware may differ, I could not check). #2432 is a different layer (view refusal + allocation-info query) and could land alongside #2442. Suggest one of the host_desc PRs only.

AI-assisted verification by Claude Code (Claude Sonnet 5.5). Software-only: Microsoft Basic Render Driver (WARP, vendor 0x1414, forced by VICTORY_D3D12_WARP=1 + --features diagnostics; warp_adapter() refuses a non-software adapter), no physical GPU, no game files, dumps or hashes.

@upipibi

upipibi commented Nov 25, 2026 •

Copy link
Copy Markdown

Overlap check: four open PRs drop ALLOW_UNORDERED_ACCESS at resource creation in victory-gpu/src/resource.rs. Each uses a different rule for which formats lose the flag (read from the diffs against main 940d32f, not run):

PR opened the flag goes when
#2180 (n-romanovich) 07:06Z the format isn't typeless and its family lacks TYPED_UNORDERED_ACCESS_VIEW support. It also strips unsupported render-target flags.
#2319 (Calvix2k) 10:33Z the format is its own family head (family(f) == f: a typeless head, or a format with no family) and the host has no typed store for it (typed_store). Corrected: I first had this backwards.
#2442 (kotekompotek) 13:36Z no typed store, unless a castable UAV format exists (not for depth)
#2459 (this) 13:57Z (edited, at 9ff2c1a) no typed store for the format and none for any format it can be cast to (castable(f).any(typed_store)); that's #2442's rule, except that #2442 doesn't allow the castable route for depth resources

Added 20:35Z: two newer PRs for #2725 overlap these (read from the diffs, not run):

PR opened approach
#2773 (kais7654) 20:12Z (updated for c1fcd74) strips only the render-target use at creation, where the device refuses the resource (B4G4R4A4 on NVIDIA), and keeps the unordered-access use; typeless formats keep their description's uses; a typed UAV view whose format the device can't store (B5G5R5A1, B4G4R4A4) is held back (reads null, writes dropped), plus draw.rs / host.rs / list.rs changes
#2767 (narishaa) 20:07Z keeps the flags and instead makes B5G5R5A1 (86) and B4G4R4A4 (115) as R8G8B8A8_UNORM when the host lacks render-target or typed UAV support for them; buffer-to-texture copies into such a texture are expanded on the CPU (list.rs), and descriptor.rs handles the views

Added 21:52Z: two more, read from the diffs (not run):

PR opened approach
#2834 (kais7654) 21:42Z stacked on #2773: host_desc now also drops the unordered-access use when CheckFeatureSupport reports no TYPED_UNORDERED_ACCESS_VIEW for the format (B5G5R5A1, B4G4R4A4 on NVIDIA), as #2773 does for the render-target use; typeless formats keep every use. Rebased on main 61bfc77, whose descriptor::host::fits already holds back unordered views in formats the device doesn't store (the author's 21:46Z comment)
#2832 (legayclightning22) 21:40Z resource.rs only: where the host lacks render-target or typed UAV support, promotes 67 to 26, 115 to 87, and 86 to 87 (render target only), then drops a use the promoted format still lacks; a view now needs its exact format in the castable list rather than the same family

So #2834's unordered-access drop is the same creation-side change as the first four, with the device's own answer as the rule, and #2832 swaps formats like #2767 (87 there instead of 28).

Added 22:21Z: artor410 measured five of these on an RTX 3070 Ti with a synthetic probe (a UAV view of 86/115 and an RTV of 115, one process per case): #735 (comment). In it the RTV of 115 still removes the device with #2442, #2462 and #1946, not with #2767 or #2773. #2459, #2319, #2834 and #2832 are not in that table.

#2462 (lhnizdo) is the view-creation side. kotekompotek noted it complements #2442 rather than overlapping it.

They differ mainly for typeless formats. #2180 leaves typeless formats alone, #2319 applies its rule only to family heads (typeless ones included) and formats with no family, and #2442 keeps the flag when a castable UAV format exists. (Edited: the #2319 row was backwards.) One of the four should be picked; whichever is picked, #2462 still applies.

Edited after 9ff2c1a: #2459 and #2442 now use nearly the same rule. The difference is depth resources (#2442 keeps the castable route off for them).

AI-assisted (Claude Code, Claude Opus 5.5). Read from the diffs only.

Review of Marvisak#2459 (kotekompotek, oni-swr): uav_format probed only the exact format with Support2 UAV_TYPED_LOAD|STORE, an operation-support bit, so the flag was dropped from typeless and sRGB textures (e.g. R8G8B8A8_TYPELESS 27, and 29 which host_desc maps to 27) that the host can legally create unordered through their castable formats.

Use the legality criterion instead: the format, or a format the texture is made castable to (the enhanced-barrier creation make_texture takes), must take a typed unordered view (descriptor::host::typed_store, D3D12_FORMAT_SUPPORT1_TYPED_UNORDERED_ACCESS_VIEW). The B5G5R5A1_UNORM case (no such format in its family on the device) still loses the flag.

Adds a host-derived test (unordered_flag_follows_the_castable_route).
@roon9e

roon9e commented Nov 25, 2026

Copy link
Copy Markdown
Author

Addressed the review feedback in 9ff2c1a (pushed to this branch).

kotekompotek / oni-swr were right: uav_format probed only the exact format with Support2 UAV_TYPED_LOAD | UAV_TYPED_STORE — an operation-support bit — so the flag was dropped from typeless and sRGB textures (R8G8B8A8_TYPELESS 27, and 29 which host_desc maps to 27), plus the B8G8R8X8/B8G8R8A8 families, on any device whose typeless format reports no typed UAV.

What changed:

  • Deleted host::uav_format; host_desc now uses the legality criterion descriptor::host::typed_store (D3D12_FORMAT_SUPPORT1_TYPED_UNORDERED_ACCESS_VIEW, the bit ALLOW_UNORDERED_ACCESS creation enforces), made pub(crate).
  • The flag is dropped only when neither the format itself nor any format the texture is made castable to (castable(d.format), the enhanced-barrier CreateCommittedResource3 list make_texture already passes) takes a typed unordered view. So typeless/sRGB textures that reach a typed-UAV format through the cast list keep the flag; the reported B5G5R5A1_UNORM case, whose family has no such format, still loses it.
  • Added a host-derived test, unordered_flag_follows_the_castable_route, asserting the flag matches typed_store(f) || castable(f).any(typed_store) for 27, 28, 29, 86, 87, 10.

Checks (GTX 1660 SUPER, Turing, Rust 1.98.1): cargo clippy -p victory-gpu --all-targets -- -D warnings clean; the new test passes against the real device. Note: cargo test -p victory-gpu --lib -- --test-threads=1 has 2 pre-existing failures on this machine (dynamic_slots_are_held_until_released, lists_share_a_table_and_copies_keep_their_views) — I reproduced them on 1679fbe with this change stashed, so they are not from this PR.

This brings the rule in line with #2442 (same criterion, cast-list aware). If the maintainers prefer #2442, I'm happy to close this one — the difference now is only surface (where the guard sits, and typed_store exposure).

AI-assisted; verified on the physical Turing device noted above.

host_desc keeps ALLOW_UNORDERED_ACCESS where a format the texture is made castable to takes a typed unordered view. But the cast-list creation (CreateCommittedResource3 / CreatePlacedResource2) can be refused (E_INVALIDARG), and the committed fallback then carried the flag on a format that cannot be a typed UAV itself, removing the device.

The fallback now clears the flag when the format itself cannot take a typed unordered view: with the cast list gone the flag is only legal where it can.

Marvisak commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.

The head is unchanged (41bdc39), and thanks for passing on krcenov's RTX 3070 run. The open point from the last triage still stands: in host_desc (resource.rs), family_formats(90) does not include the linear twin 87, so unordered BGRA sRGB (91) textures lose the flag that main keeps. Verdict unchanged: needs work.


Generated by Claude Code

@roon9e

roon9e commented Nov 25, 2026

Copy link
Copy Markdown
Author

Updated this branch with two things:

  • Merged origin/main (da82e44) so the PR is current (clean merge).
  • 9a47d4a: the committed fallback now clears ALLOW_UNORDERED_ACCESS when the cast-list creation is refused. host_desc keeps the flag where a castable format takes a typed UAV, but if CreateCommittedResource3/CreatePlacedResource2 with that list is refused and the plain fallback then carries the flag on a format that cannot be a typed UAV itself, the device is removed. With the cast list gone the flag is only legal where the format itself can take the view, so the fallback drops it there.

Found while testing on the GTX 1660 SUPER: on da82e44 the world load now device-removes earlier, at a 2560×1440 B4G4R4A4_UNORM (115) render target (no UAV flag) — separate from this PR and reproduced without it; reported on #2258.

…size casts

Triage was right: castable() groups by element size, so castable(B5G5R5A1_UNORM=86) includes 16-bit R16/R8G8 formats that take typed UAVs, and the flag was kept for 86 - the exact texture the report is about (probe on the GTX 1660 SUPER: typed_store(86)=false, yet castable(86)=[49,50,51,52,54,56,57,58,59,68,69,85,115] and all of [49,50,51,52,54,56,57,58,59] take typed UAVs).

Use the format's own family instead (family_formats: the typeless head and its typed/sRGB twins, i.e. every format sharing its family() head), which is what a UAV of the resource can reach without changing what the texels mean. B5G5R5A1 has no such family, so it loses the flag; typeless/sRGB keep it through their typed member. The test now checks 86 loses it.
@roon9e

roon9e commented Nov 25, 2026

Copy link
Copy Markdown
Author

Triage is right — thank you, that was a real bug in the change. Confirmed empirically on the GTX 1660 SUPER:

typed_store(86) = false
castable(86)    = [49,50,51,52,54,56,57,58,59,68,69,85,115]
  of those, typed_store = [49,50,51,52,54,56,57,58,59]   // all 16-bit R16/R8G8 twins

castable groups by element size, so castable(B5G5R5A1_UNORM) reaches typed-UAV 16-bit formats and the flag was kept for 86 — i.e. it did not cover the texture the report is about, and the stable run was 1679fbe, as you say.

Fixed in ce9d6fd: host_desc now uses the format's own family (family_formats, every format that shares its family() head — the typeless head and its typed/sRGB twins), not castable's element-size group. B5G5R5A1_UNORM has no such family, so it loses the flag (the case is covered again); typeless/sRGB keep it through their typed member. The comment no longer claims the B5G5R5A1 case loses it under the old rule, and the test now asserts !family_takes(86) plus the rule for 27/28/29/86/87/10, so a wrong rule fails it. 9a47d4a's creation-fallback guard stays.

On the re-run you suggested: I can't reach that texture on this head, because da82e44 device-removes earlier on this card — a 2560×1440 B4G4R4A4_UNORM (115) render target (no UAV flag), reported on #2258 and reproduced without this change. On 940d32f the new predicate gives the same drop for 86 that was stable there.

This now overlaps #2180/#2319/#2442 as you noted; I'm happy to close this in favour of whichever host_desc fix you pick.

AI-assisted; probe and predicate on the physical Turing device above.

@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. By reading, assert!(!takes(86)) would fail on hosts that store 86 (WARP, AMD). Details and the side-by-side table with the other #1753 PRs: #1753 (comment). Tested with the help of an AI assistant (Claude Code).

…s f itself

Drop the hard-coded !takes(86) from unordered_flag_follows_the_format_family:
the rule (flag kept iff the format's family takes a typed UAV) is what the test
should pin, and a device that stores B5G5R5A1_UNORM typed (WARP, some AMD) keeps
the flag - the old assert panicked there, failing CI.

amily_formats scanned only 1..=115, so a format above 115 with no family
iterated nothing instead of ' alone' as its doc says; chain  itself.
@roon9e

roon9e commented Nov 25, 2026

Copy link
Copy Markdown
Author

Fixed both triage points in 41bdc39.

  • CI / test: dropped the hard-coded assert!(!takes(86)) from unordered_flag_follows_the_format_family. That assert encoded this device's support; WARP (and some AMD) stores B5G5R5A1_UNORM typed and keeps the flag there, so the assert panicked on WARP. The test now pins only the rule, flag_kept == family_takes(format), for 27/28/29/86/87/10.
  • family_formats: it scanned only 1..=115, so a format above 115 with no family iterated nothing rather than "f alone" as its doc says. It now chains f itself for f > 115, and the test asserts family_formats(200) contains 200.

Local: cargo test -p victory-gpu --features diagnostics --lib resource::tests::unordered_flag_follows_the_format_family passes on the GTX 1660 SUPER; cargo clippy -p victory-gpu --all-targets -- -D warnings clean with and without --features diagnostics.

Still overlaps #2180/#2319/#2442; happy to close in favour of whichever host_desc fix is picked.

AI-assisted.

@krcenov

krcenov commented Nov 25, 2026

Copy link
Copy Markdown

Tested this PR at 41bdc39 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).

@roon9e

roon9e commented Nov 26, 2026

Copy link
Copy Markdown
Author

Thanks @krcenov — good to have an Ada confirmation at 41bdc39: no device removal, format 86 created without the unordered flag, and the view refused instead of the device going away. That matches what I see on the GTX 1660 SUPER.

One note for anyone reading this PR: the format-115 / id=817 line you saw is unrelated to the id=817 in #1063 (that one is a streaming codec id, not a resource id) — I chased both and they are different things.

For the record, a separate finding from the same machine (not part of this PR, no code change here): the world-load stop at +0x1330a44 in #1063 loads on the software adapter (VICTORY_D3D12_WARP=1) and is broken on the 1660's D3D12 path — so it is a GPU-path issue, not the runtime's file/decode plumbing. Details in #1063. Nothing here changes this PR.

AI-assisted.

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