Skip to content

GPU: drop the unordered-access permission a format cannot carry, before any call names it - #1832

Open
fiestorra wants to merge 1 commit into
Marvisak:mainfrom
fiestorra:gpu/drop-uav-on-formats-that-cannot
Open

fiestorra wants to merge 1 commit into
Marvisak:mainfrom
fiestorra:gpu/drop-uav-on-formats-that-cannot

Conversation

@fiestorra

Copy link
Copy Markdown
Contributor

The device removal comes from a description we hand the host, and it is measured: with this, three runs in a row do not remove the device

After installing the debug layer on a machine that has the failure, the message that ends the device is this one and only this one:

D3D12: 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_2. D3D12_RESOURCE_DESC::Format is
B5G5R5A1_UNORM. id=599 severity=1
→ host GPU device removed (0x887A0001)

Two things make it fatal where a creation ladder would not help:

The change

host_desc — the one place a title description becomes a host description — now asks the host whether the format can be a typed unordered access view (CheckFeatureSupport(D3D12_FEATURE_FORMAT_SUPPORT), Support2 & (UAV_TYPED_LOAD | UAV_TYPED_STORE)), caches the answer per format, and drops ALLOW_UNORDERED_ACCESS when the answer is no, once per format, with a warning naming the format:

    if d.flags & UNORDERED != 0 && typed_uav(d.format) == Some(false) {
        d.flags &= !UNORDERED;
        ... "dropping unordered access: the host cannot use this format as a typed UAV"
    }

The answer is tri-state on purpose: when the host cannot be asked, the description is left exactly as the title wrote it. Dropping a permission that was legal would lose a texture's writes silently, which is worse than the bug.

Verification, on the machine that removes the device

Same setup each time: main at 70564ae plus this change, release, empty cache, real window (3840×2160), debug layer on or off as noted, default adapter (AMD Radeon(TM) Graphics, driver 32.0.21045.29003), session 1.

id=599 device removed frames
main 1 yes, frame 128 128
main + this, run 1 0 no 128 (cut by the time limit)
main + this, run 2 0 no 256
main + this, run 3 0 no kept presenting

The rule fires twice per run (format=27 and format=86), and the run continues past the point it used to die.

What I am not claiming

No game data is involved: a description, a format number, warnings and counts only.

Written with an AI assistant.

@upipibi

upipibi commented Nov 24, 2026

Copy link
Copy Markdown

Overlap for the reviewers: #1787 (22:33) also drops UNORDERED from a texture's host description in resource.rs when the host can't store the format (host_unordered_format), for the same B5G5R5A1_UNORM device removal. #1763, #1775, #1780 and #1801 handle the view side in descriptor/host.rs. This PR and #1787 edit the same resource.rs path, so one of the two is enough. From reading the file lists and descriptions; nothing built.

AI-assisted (Claude Code).

@fiestorra

Copy link
Copy Markdown
Contributor Author

Tested against the real failure, and against the other two candidates: it is one of three causes

With the debug layer installed on a machine that reproduces the removal, the same scenario (session 1, window 3840×2160, empty cache, default adapter AMD Radeon(TM) Graphics, driver 32.0.21045.29003):

build id=599 id=1419 device removed
main 70564ae 1 0 yes, frame 128
+ this pull request 0 0 no
+ this and #1630 (texture ladder) 0 2 yes
+ this and #1778 (sampler heap) 0 0 no
+ all three 0 0 no, keeps presenting

So on this machine this change alone is enough to stop the removal, while the texture ladder alone is not — it removes the no host texture line and then uncovers a second rule violation (id 1419, the sampler heap) that was previously invisible because the run died at 599 first.

That is worth saying in the pull request rather than in a later comment: a reviewer testing only this change on an NVIDIA card may see the removal go away and a different one appear later, and it is the id 1419 of #1778 in that case.

Full write-up with the chain: #1754 (comment)

Still in the log with all three, and a different problem: host view heap capped at 1000000 and 310,720 title slot past the host heap (#1760). No removal on this machine, still costing frames.

No game data is involved.

Written with an AI assistant.

@fiestorra

Copy link
Copy Markdown
Contributor Author

Correction to my own measurements: those runs were on the RTX 4090, not on the integrated GPU

I have been writing "default adapter, integrated AMD Radeon(TM) Graphics, driver 32.0.21045.29003" on the runs I made in session 1. That attribution is wrong, and the cause is worth knowing because it is the exact trap this repository keeps warning about.

DXGI enumerates the adapters in a different order in the two sessions. Measured on this machine, same binary, same moment, with cargo test --release -p victory-gpu -- --ignored adapters:

session 0 (the agent's, services):
  adapter 0: "AMD Radeon(TM) Graphics"      vendor=0x1002  485 MiB
  adapter 1: "NVIDIA GeForce RTX 4090"      vendor=0x10de  24,138 MiB
  adapter 2: "Microsoft Basic Render Driver"

session 1 (the interactive desktop, where the title actually runs):
  adapter 0: "NVIDIA GeForce RTX 4090"      vendor=0x10de  24,138 MiB
  adapter 1: "AMD Radeon(TM) Graphics"      vendor=0x1002  485 MiB
  adapter 2: "Microsoft Basic Render Driver"

So the default adapter is the integrated AMD in the agent's session and the RTX 4090 in the session where the title runs, which is precisely where every number I published in the last few rounds came from. With my selector in place the run says it plainly:

INFO victory_gpu::host: host GPU adapter="AMD Radeon(TM) Graphics" index=1 vendor=0x1002 …

— index=1 is the AMD in session 1, the reverse of session 0, which is what made me notice.

What this changes, and what it does not:

No game data is involved: adapter descriptions, vendor ids and memory sizes only.

Written with an AI assistant.

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

Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff.

Drop the unordered-access permission a format cannot carry: fourth leg of the host-capability gating (#1775/#1787/#1801/#1843) — keep them consistent.

@fiestorra

Copy link
Copy Markdown
Contributor Author

On the card that refuses it: main dies at frame 64 with id 599, this branch reaches frame 256 with none

Re-ran the comparison on the RTX 4090 (driver 32.0.16.2124) with the D3D12 debug layer on, since that is the adapter where the rule fires — the integrated AMD here accepts the same description, which is why an AMD-only test cannot judge this. Session 1, real window 3840×2160, empty cache, diag build with VICTORY_D3D12_DEBUG=1 VICTORY_D3D12_DRED=1:

main 70564ae this branch
id=599 (ALLOW_UNORDERED_ACCESS on a B5G5R5A1_UNORM texture, in GetResourceAllocationInfo) yes, severity 1 0
id=1419 0 0
device removed yes no
last frame before the run ended 64 (draws= line) 256, draws=1636, still presenting
dropping unordered access — 2 (formats 27 and 86)

So on the NVIDIA card the change does exactly what it claims: the description is made without a permission the format cannot carry, before any device call names it, and the device survives.

The log line from main for the record, with the driver's own wording:

D3D12: 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_2. … B5G5R5A1_UNORM. id=599 severity=1
→ host GPU device removed …: ID3D12Device::GetResourceAllocationInfo: …

Why this cannot be fixed where the rest of the texture work happens: the message is raised by a query (GetResourceAllocationInfo), three calls before anything is created, so a retry ladder around CreateCommittedResource — including the one in #1630 — never gets to run. And severity=1 means it is not returned as an HRESULT.

Also worth saying plainly, because it decides how the fix should be judged: on this machine's integrated AMD the same main build shows no id 599, no cap and no removal, and ran 1,024 frames / 6,656 draws in the same 40 s (#1754 (comment)). The failure is the NVIDIA driver's answer, so a reviewer with only an AMD card will see nothing here — the card to test this on is the one that refuses.

Still in the log after this change, and deliberately not touched: the capped view heap (host view heap capped at 1000000, 310,720 slots past it — #1760/#1779) and one no host texture (#1630). They no longer remove the device; they still cost the frame.

Verification of the branch: cargo test -p victory-gpu --locked 78 passed / 2 ignored, the ignored GPU test typed_uav_follows_the_format_not_the_request passing, clippy --workspace --all-targets --all-features -D warnings clean, rustfmt --check on resource.rs at the same 15 hunks as main.

No game data is involved: a format number, debug-layer ids, warnings and counts only.

Written with an AI assistant.

@fiestorra

Copy link
Copy Markdown
Contributor Author

The 120-second run: frame 2,048, draws=13312, dispatches=1024, still no removal

Short follow-up to the table above, because 40 seconds does not prove the device stays: same card (RTX 4090, driver 32.0.16.2124), same diag build with the debug layer and DRED on, session 1, empty cache, but for 120 s:

id=599             0
id=1419            0
device removed     0
frame=2048 draws=13312 drawn=13312 dispatches=1024 dispatched=1024

versus main on the same card, which ends at frame 64 with id 599 and a removed device. So the skip is not a postponement: nothing else trips the layer in two minutes, and the draw and dispatch counters keep climbing.

That also fixes what the frame does to the card's load: 2,048 frames and 13,312 draws in two minutes means it is not sitting in a corner avoiding the texture that used to kill it.

Nothing else changed in the branch; the verification in the comment above still holds.

Written with an AI assistant.

…re any call names it

The description the title gives its 2560x1440 B5G5R5A1_UNORM targets (render
target and unordered access) cannot be named to the host as it stands, and
the debug layer says exactly what happens: 'A texture that has
D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS set ... 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' — id 599, severity 1, which removes the
device (Marvisak#1754).

It is raised in GetResourceAllocationInfo, a query made before anything is
created, so a ladder of descriptions around CreateCommittedResource cannot
help: the device is already going. host_desc now asks the host, once per
format, whether the format can be a typed unordered access view, and drops
the permission when it says no, so no device call ever names such a
description. An answer the host does not give leaves the description alone.

Measured on the machine that reports the removal: with it, three runs in a
row show no id 599, no device removal, and the boot keeps presenting frames;
before it, the same run removed the device at frame 128.
@fiestorra

Copy link
Copy Markdown
Contributor Author

Measured both bit choices on the cards where this matters: they agree, so the queue has two pull requests for one fix

I ran the two format-support tests side by side on the RTX 4090 (driver 32.0.16.2124, session 1 — the adapter that refuses this format) and on the integrated AMD of the same machine (32.0.21045.29003, session 0):

format Support1 TYPED_UAV (0x100000) Support2 typed load/store (0xc0) this PR's answer
86 B5G5R5A1_UNORM 0xe4d3f0 clear 0x200 clear no
28 R8G8B8A8_UNORM 0x33fcd3f3 set 0x102c0 set yes
41 R32_FLOAT 0x6f4d7fb set 0x2c8 set yes
27 B8G8R8A8_UNORM_SRGB 0x1010f0 set 0x200 clear n/a — mapped to its UNORM family first

So for the format this is about, Support1 & TYPED_UNORDERED_ACCESS_VIEW (#1926) and Support2 & (UAV_TYPED_LOAD | UAV_TYPED_STORE) (#1832, mine) give the same answer, and the one format where they differ — the sRGB one — never reaches the check: host_desc maps sRGB with the unordered-access permission to its UNORM family before it, which is why the pair disagrees there harmlessly.

Two consequences, and the second is the one worth acting on:

  1. Nobody should "fix" one bit into the other later without re-measuring. Support1 is the flag the D3D12 documentation points at; Support2's typed load/store is what a shader actually does. On these two drivers they agree on the formats the title uses, and the sRGB case shows they will not always.
  2. There are two pull requests for one fix: GPU: drop the unordered-access permission a format cannot carry, before any call names it #1832 (mine: one file, +116, host_desc drops the permission, tri-state when the host cannot be asked, measured on the 4090 — no GetResourceAllocationInfo refusal, no removal, 2,048 frames in 120 s) and GPU: boot on NVIDIA when a format cannot be a typed UAV #1926 (+214/−34 across nine files, which also carries CPU, pipeline and manifest changes). A maintainer should only have to review one of them.

I am not precious about which. Mine is smaller and was measured on the card that fails; yours is the one that reads the documented flag and additionally refuses the unsupported view at creation, which is a real improvement over dropping the permission alone. If you want yours in, say so and I close mine — I would only ask that the tri-state behaviour be kept: when the host cannot be asked, the description should stay as the title wrote it, because dropping a permission that was legal loses a texture's writes silently.

If it is easier the other way round, mine is MERGEABLE/CLEAN with a green check today and yours is too, so it is a choice and not a queue problem.

No game data is involved: formats, support masks and counts.

Written with an AI assistant.

@SamuelGDMG

Copy link
Copy Markdown

Tested this fix locally and it's working — it resolves the 0x887A0001 (DXGI_ERROR_INVALID_CALL) device removal on B5G5R5A1_UNORM and gets past the crash cleanly.

Specs: Windows 11 (10.0.26200), Ryzen 5 5500, RTX 3050 8 GB, driver 610.88. Running diag build on 940d32f with VICTORY_D3D12_DEBUG=1, and VICTORY_D3D12_DRED=1 (Series 1.0.2.1, 0 missing imports).

Written with an AI assistant.

@fiestorra

Copy link
Copy Markdown
Contributor Author

Merge check: the three GPU fixes together keep the suites where main has them

Nobody can run this from CI, so I did it here: main 940d32f with #1630, #1832 and #1778 merged into one tree (they touch resource.rs, the descriptor heap and the shader cache, and they do not conflict), then the tests and a boot.

main alone the three merged
cargo test --workspace --locked 26 suites ok, 1 failure 26 ok, 1 failure — the same one
cargo test -p victory-shader --locked --lib 247 passed, 3 ignored 247 passed, 3 ignored
cargo test -p victory-gpu --features diagnostics --lib 146 passed, 2 ignored 148 passed, 6 ignored
boot, 120 s, RTX 4090 32.0.16.2124, session 1 device removed ×2, dies at frame 64 0 removals, 2,048 frames, 13,312 draws

The one failure in both columns is victory-hle::modules::lifecycle::tests::showing_a_title_window_shows_its_stand_in, which fails on main too in a session without a desktop — it is the agent's environment, not the change.

The GPU suite gained two tests and four skips because those are the tests the three pull requests add (the ladder's attempts, the typed-UAV rule, the sampler fallback), and some of them skip without a host. That is why the counts differ and why they are written out instead of "all green".

So, for a reviewer deciding whether these can go in together: they do not regress the suites, and together they change what a boot does — which is the only reason to merge them as a set rather than one at a time.

What this check does not cover: it says nothing about the title beyond those 120 seconds, and the run still stops at the terms-of-service screen, which is not a GPU matter. It also does not cover other people's fixes: the cap (#1779) is untouched here and still logs host view heap capped at 1000000 once per run.

No game data is involved: test counts and frame numbers.

Written with an AI assistant.

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.

Needs work. host_desc in crates/victory-gpu/src/resource.rs drops ALLOW_UNORDERED_ACCESS when typed_uav(d.format) (Support2 typed load/store) is false for the texture's own format. Issues:

#1787 overlaps this change. One of the two should carry it forward.

CI: check passing.


Generated by Claude Code

0xkn0wh3r3 added a commit to 0xkn0wh3r3/VIctory that referenced this pull request Nov 25, 2026
…mmit

Marvisak#2130 was rewritten on top of Marvisak#2120's update, so layering it on the old
merges kept two versions of it. This tree is upstream main (940d32f) with
all 32 open PRs of 0xkn0wh3r3 at their current commits, the upstream
fixes Marvisak#1887, Marvisak#1717, Marvisak#1832, Marvisak#1630, Marvisak#1763 and Marvisak#1613, and the demo-only
conformance list; the old history stays as this merge's first parent.
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.

5 participants