Skip to content

GPU: textures drop unordered access in formats the host cannot write (NVIDIA B5G5R5A1) - #1787

Open
Danigamer05 wants to merge 2 commits into
Marvisak:mainfrom
Danigamer05:fix/nvidia-unordered-formats
Open

Danigamer05 wants to merge 2 commits into
Marvisak:mainfrom
Danigamer05:fix/nvidia-unordered-formats

Conversation

@Danigamer05

Copy link
Copy Markdown

What

host_desc keeps the title's unordered-access flag for a texture whose format the host GPU cannot write from shaders. NVIDIA has no typed unordered access for B5G5R5A1_UNORM (format 86); AMD has. On an NVIDIA card the host description is then invalid, and the size query that shared_texture makes with it (GetResourceAllocationInfo) removes the device.

  • host_desc drops UNORDERED when host_unordered_format says the host has no typed unordered access views for the format.
  • host_unordered_format asks CheckFeatureSupport(D3D12_FEATURE_FORMAT_SUPPORT) once per format and logs the formats it turns down. Typeless formats keep the use, since their views decide later. Without a host it answers yes.
  • New test unordered_access_only_in_formats_the_host_writes: render-target + UAV textures in formats 86, 28, 87, 2 and 10 keep their render-target use, keep UAV exactly when the host has it, and are created by the host.

Why

On main 70564ae, on an RTX 2080 SUPER (driver 621.01, Windows 11), every run ended in the menus about 50 s after start with DXGI_ERROR_INVALID_CALL (0x887A0001). With VICTORY_D3D12_DEBUG=1 the debug layer names it:

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. [...] D3D12_RESOURCE_DESC::Format is B5G5R5A1_UNORM.

With this change the log shows the host has no unordered access for this format: its textures are made without it format=86, the run passes the menus and loads into the world, where it later stops on a GPU hang. That hang is the known wave64-on-32-lane class (main refuses no wave64 programs on NVIDIA) and is not touched here.

Tests

  • cargo test -p victory-gpu --lib: the new test passes. Two tests fail on this machine both with and without this change, so they are not caused by it: descriptor::host::tests::dynamic_slots_are_held_until_released and memory::tests::lists_share_a_table_and_copies_keep_their_views.
  • cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.
  • rustfmt --check: clean for the lines this changes (other files on main have unrelated differences).
  • Asset policy hook: passes.

No game data in the diff or the description. AI-assisted (Claude Code); runs on my machine with my own copy.

🤖 Generated with Claude Code

Hosts differ in which formats take unordered access: NVIDIA has none
for B5G5R5A1_UNORM, AMD has. host_desc kept the title's UAV flag for
such a texture, so on an NVIDIA card the host description was invalid,
and the size query shared_texture makes with it removed the device
(DXGI_ERROR_INVALID_CALL) in the menus, about 50 s after start.

A texture in a format the host cannot write from shaders (asked once
per format with CheckFeatureSupport, typed unordered access views) is
now made without that use; typeless formats keep it, their views decide.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@DesertGamer

Copy link
Copy Markdown

VIctory V2: community PRs, merged and tested

Open PRs sitting in the queue? V2 pulls them into one build, screens each one (binaries, build scripts, hooks, new deps) and runs tests after every batch.

Where it stands today: launches, runs the menu at 30 fps, plays the intro video, reaches the start screen and loads the world (~50 s). Entering the world is the current blocker: rendering fails with a GPU "device removed" error (tracked in issue #1).

⚠️ Entering the world on a real GPU can hang it and make Windows reset the driver. Try it at your own risk.

Not playable yet, but every batch of merged fixes moves it closer. If you have a PR that's stuck, or a GPU to test on, I'd love your help:
https://DesertGamer/VIctory-V2

Unofficial community fork of Marvisak/VIctory, GPL-3.0.

@upipibi

upipibi commented Nov 24, 2026

Copy link
Copy Markdown

Related, for the reviewers: #1763, #1775 and #1780 (one change three times) fix the other half of the same NVIDIA B5G5R5A1_UNORM problem. They refuse the unordered view in descriptor::host::fits, where this PR drops UNORDERED from the texture's host description in resource.rs. The two look complementary rather than duplicates: once this drops the flag, an unordered view of such a texture still has to be refused, which is what fits does in those PRs. From reading the descriptions and file lists; nothing built.

AI-assisted (Claude Code).

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

Textures drop unordered access in formats the host cannot write: same host-capability policy as #1775/#1801 at texture creation. Consistent trio — review together.

Marvisak commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.

Needs work. Thanks for the update (e0e5096). The main point is fixed: host_desc in crates/victory-gpu/src/resource.rs now keeps UNORDERED when the format or any format in castable(format) takes typed UAVs, so B5G5R5A1_UNORM keeps its 16-bit alias writes on NVIDIA. That makes this more accurate than #1832, which drops the flag based on the format alone. One real problem remains in the new fallback in make_texture:

  • Initial state in the fallback. initial is computed before creation as legal_for(d.flags, texture_state(state)) with the original flags. The fallback removes UNORDERED from plain, but it still passes that initial to CreateCommittedResource. A texture the title creates in the unordered-access state (0x8) is then created in a state its flags do not allow, and creation fails again. Recompute initial from plain.flags there, and make the test create one texture with an unordered-access starting state (it currently passes 0).
  • Minor: shared_texture's takes reads the host texture's actual flags, so later title textures of the same memory that ask for unordered access will replace the fallback texture again and again. Worth a note or a check.
  • Nit: the new test's doc comment sits right below the existing /// A 4x4 texture filled from a title buffer… lines, so that text now documents the new test, and buffer_data_reaches_the_host_texture loses its doc comment.

With the initial-state fix, this looks mergeable as the resource-side complement to #1763's view refusal.

CI: passing (check).


Generated by Claude Code

Review on Marvisak#1787: host textures are made with their castable formats, and
D3D12 allows ALLOW_UNORDERED_ACCESS when a format the texture can be cast
to takes typed unordered access (B5G5R5A1_UNORM's 16-bit aliases such as
R16_UINT on NVIDIA). Dropping the use whenever the texture's own format
lacks it lost writes through those aliases.

host_desc now drops it only when neither the format nor any castable
format takes typed unordered access. make_texture's fallback without
castable formats (CreateCommittedResource3 refused or no Device10) drops
it when the format alone lacks it, since there the alias is gone and the
flag is illegal. The test makes the textures through make_texture.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Danigamer05

Copy link
Copy Markdown
Author

Thanks for the review, both points are right. Pushed e0e5096:

  • Castable formats. host_desc now drops UNORDERED only when neither the texture's format nor any format in castable(format) takes typed unordered access. For B5G5R5A1_UNORM on NVIDIA the flag stays, since R16_UINT / R16_FLOAT take it, and make_texture creates the texture with those formats through CreateCommittedResource3.
  • Fallback without castable formats. If CreateCommittedResource3 is refused (or there is no ID3D12Device10), make_texture falls back to CreateCommittedResource with no cast list. There the alias is gone and the flag on format 86 is illegal, so the fallback now drops UNORDERED when the format alone lacks it. Before, that path just failed with "no host texture".
  • The test (unordered_access_only_where_the_format_or_an_alias_takes_it) creates formats 86, 28, 87, 2, 10 and 85 through make_texture and checks the flag against the format plus its castable list. It passes on an RTX 2080 SUPER (32..32 lanes, driver 621.01). Clippy -D warnings is clean for victory-gpu.

On the removal itself: agreed, the GetResourceAllocationInfo line is a warning. With #1763's refusal of the unordered view of format 86, this PR is only needed for the no-castable fallback and for the flag to match what the host can do. If #1832 is the one carried forward, I'm fine closing this one.

AI-assisted (Claude Code).

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