GPU: drop unsupported UAV/RT flags on typed host textures and guard RTV creation #1040

Closed
github-bot wants to merge 3 commits from gh-pr/1040/head into gh-pr/1040/base
Owner

@⁠gabrielcruzg3 on GitHub · 2026-11-24 15:15 UTC · original
gabrielcruzg3:fix/host-texture-uav-support → main · +107 −8 · 4 files · 3 commits · closed without merging

Addresses #264 (Finding #4) and related D3D12 validation errors on formats that PC GPUs do not support as typed UAVs or render targets (such as B5G5R5A1_UNORM and B4G4R4A4_UNORM).

Changes

  • \crates/victory-gpu/src/resource.rs: Query \D3D12_FEATURE_FORMAT_SUPPORT\ for non-typeless host textures and drop \ALLOW_UNORDERED_ACCESS\ / \ALLOW_RENDER_TARGET\ when unsupported (preserving UAV on typeless formats). Omit \pOptimizedClearValue\ when neither render-target nor depth-stencil flags remain (avoids D3D12 id=815).
  • \crates/victory-gpu/src/host.rs, \draw.rs, \list.rs: Return \Option<D3D12_CPU_DESCRIPTOR_HANDLE>\ from \Host::rtv()\ and skip RTV creation when the host resource lacks \ALLOW_RENDER_TARGET\ (avoids id=36 / id=42 / \DXGI_ERROR_INVALID_CALL).

Verification

  • Added synthetic GPU test \host_texture_drops_unsupported_uav_flag_for_b5g5r5a1\ covering \B5G5R5A1_UNORM, \B4G4R4A4_UNORM\ with clear value, and \R8G8B8A8_TYPELESS.
  • Passed \cargo clippy -- -D warnings, \cargo test -p victory-gpu, and \cargo xtask policy.
**@⁠gabrielcruzg3** on GitHub · 2026-11-24 15:15 UTC · [original](https://github.com/Marvisak/VIctory/pull/1040) `gabrielcruzg3:fix/host-texture-uav-support` → `main` · +107 −8 · 4 files · 3 commits · closed without merging Addresses #264 (Finding #4) and related D3D12 validation errors on formats that PC GPUs do not support as typed UAVs or render targets (such as B5G5R5A1_UNORM and B4G4R4A4_UNORM). ### Changes - \crates/victory-gpu/src/resource.rs\: Query \D3D12_FEATURE_FORMAT_SUPPORT\ for non-typeless host textures and drop \ALLOW_UNORDERED_ACCESS\ / \ALLOW_RENDER_TARGET\ when unsupported (preserving UAV on typeless formats). Omit \pOptimizedClearValue\ when neither render-target nor depth-stencil flags remain (avoids D3D12 id=815). - \crates/victory-gpu/src/host.rs\, \draw.rs\, \list.rs\: Return \Option<D3D12_CPU_DESCRIPTOR_HANDLE>\ from \Host::rtv()\ and skip RTV creation when the host resource lacks \ALLOW_RENDER_TARGET\ (avoids id=36 / id=42 / \DXGI_ERROR_INVALID_CALL\). ### Verification - Added synthetic GPU test \host_texture_drops_unsupported_uav_flag_for_b5g5r5a1\ covering \B5G5R5A1_UNORM\, \B4G4R4A4_UNORM\ with clear value, and \R8G8B8A8_TYPELESS\. - Passed \cargo clippy -- -D warnings\, \cargo test -p victory-gpu\, and \cargo xtask policy\.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:18:00 +00:00
github-bot closed this pull request 2026-11-26 04:18:00 +00:00
Author
Owner

@⁠shortselow-byte on GitHub · 2026-11-24 15:51 UTC · original

This PR has no CI run yet, so I ran the CI's checks at head 08e4c89: Windows 11, Rust 1.98.1 MSVC, AMD Radeon RX 6900 XT (RDNA2). The new test fails on AMD and on WARP, so it would fail CI too.

  • host_texture_drops_unsupported_uav_flag_for_b5g5r5a1 fails at resource.rs:1904: the B5G5R5A1_UNORM texture keeps ALLOW_UNORDERED_ACCESS. Same failure on WARP (--features diagnostics, VICTORY_D3D12_WARP=1).
  • The code is doing the right thing: a temporary D3D12_FEATURE_FORMAT_SUPPORT query on both devices gives TYPED_UNORDERED_ACCESS_VIEW and RENDER_TARGET for both B5G5R5A1_UNORM (86) and B4G4R4A4_UNORM (115). So nothing is dropped there, as intended. The test hard-codes one driver's answer.
  • Suggestion: have the test query the format support and assert against it, or use a format no device allows as a typed UAV or render target.

Other checks:

  • The branch is based on d2a4bae, and cargo clippy -- -D warnings fails on that base (in victory-hle and victory-gpu code that isn't from this PR). Merged locally onto main ffe310e, both clippy runs (default and --all-features) are clean. The workspace tests still stop at the failing test above.
  • cargo xtask policy: ok.
**@⁠shortselow-byte** on GitHub · 2026-11-24 15:51 UTC · [original](https://github.com/Marvisak/VIctory/pull/1040#issuecomment-7136735221) This PR has no CI run yet, so I ran the CI's checks at head `08e4c89`: Windows 11, Rust 1.98.1 MSVC, AMD Radeon RX 6900 XT (RDNA2). The new test fails on AMD and on WARP, so it would fail CI too. - `host_texture_drops_unsupported_uav_flag_for_b5g5r5a1` fails at `resource.rs:1904`: the `B5G5R5A1_UNORM` texture keeps `ALLOW_UNORDERED_ACCESS`. Same failure on WARP (`--features diagnostics`, `VICTORY_D3D12_WARP=1`). - The code is doing the right thing: a temporary `D3D12_FEATURE_FORMAT_SUPPORT` query on both devices gives `TYPED_UNORDERED_ACCESS_VIEW` and `RENDER_TARGET` for both `B5G5R5A1_UNORM` (86) and `B4G4R4A4_UNORM` (115). So nothing is dropped there, as intended. The test hard-codes one driver's answer. - Suggestion: have the test query the format support and assert against it, or use a format no device allows as a typed UAV or render target. Other checks: - The branch is based on `d2a4bae`, and `cargo clippy -- -D warnings` fails on that base (in `victory-hle` and `victory-gpu` code that isn't from this PR). Merged locally onto `main` `ffe310e`, both clippy runs (default and `--all-features`) are clean. The workspace tests still stop at the failing test above. - `cargo xtask policy`: ok.
Author
Owner

@⁠NuraadGit on GitHub · 2026-11-24 16:17 UTC · original

This is the same problem as #55 and #89. Two things from an RTX 2080 (native Windows, driver 616.56) that apply to this version:

1. The continue in set_targets moves later targets into the wrong slots. When host.rtv returns None, the target is left out of rtvs. Every render target after it then binds one slot lower, so the pixel shader's later outputs go to the wrong textures. A null RTV in that slot keeps the order. @⁠EduAzevedo made this point on #55 and posted a patch. Mine does it in Host::rtv: a typed null view (R8G8B8A8_UNORM, TEXTURE2D) when the resource lacks ALLOW_RENDER_TARGET. The early return in clear_rtv is right as it is. (This one is from reading the diff; I haven't run this branch.)

2. The guard is needed, but dropping the use loses the title's writes. In the world the host refuses exactly two textures here: 2560x1440 format 115 (flags RT, loses RT) and 2560x1440 format 86 (flags RT|UAV, loses the UAV). Without a guard, the device was removed with DXGI_ERROR_INVALID_CALL at world entry, 2 of 2 runs. With one, the run stayed up for 8 minutes, but the first texture's draws and the second's compute writes go nowhere.

Merging the efforts: the RTV guard and the null clear value (which #55 doesn't have) are useful on their own, for any format. For 86 and 115, #89 keeps the writes by making them R8G8B8A8_UNORM. With a substitution like it on this card, no use is dropped, and the world ran 12 minutes at ~2,810 draws per frame. So I'd combine: the guard with a null RTV from here, the substitution from #89, and the use-dropping as the last resort for other formats.

AI-assisted (Claude Code): the runs and log analysis were automated. The hardware, title copy and runs are the user's.

**@⁠NuraadGit** on GitHub · 2026-11-24 16:17 UTC · [original](https://github.com/Marvisak/VIctory/pull/1040#issuecomment-7137436612) This is the same problem as #55 and #89. Two things from an RTX 2080 (native Windows, driver 616.56) that apply to this version: **1. The `continue` in `set_targets` moves later targets into the wrong slots.** When `host.rtv` returns `None`, the target is left out of `rtvs`. Every render target after it then binds one slot lower, so the pixel shader's later outputs go to the wrong textures. A null RTV in that slot keeps the order. @⁠EduAzevedo made this point on #55 and posted a patch. Mine does it in `Host::rtv`: a typed null view (`R8G8B8A8_UNORM`, `TEXTURE2D`) when the resource lacks `ALLOW_RENDER_TARGET`. The early return in `clear_rtv` is right as it is. (This one is from reading the diff; I haven't run this branch.) **2. The guard is needed, but dropping the use loses the title's writes.** In the world the host refuses exactly two textures here: 2560x1440 format 115 (flags RT, loses RT) and 2560x1440 format 86 (flags RT|UAV, loses the UAV). Without a guard, the device was removed with `DXGI_ERROR_INVALID_CALL` at world entry, 2 of 2 runs. With one, the run stayed up for 8 minutes, but the first texture's draws and the second's compute writes go nowhere. **Merging the efforts:** the RTV guard and the null clear value (which #55 doesn't have) are useful on their own, for any format. For 86 and 115, #89 keeps the writes by making them `R8G8B8A8_UNORM`. With a substitution like it on this card, no use is dropped, and the world ran 12 minutes at ~2,810 draws per frame. So I'd combine: the guard with a null RTV from here, the substitution from #89, and the use-dropping as the last resort for other formats. *AI-assisted (Claude Code): the runs and log analysis were automated. The hardware, title copy and runs are the user's.*
Author
Owner

@⁠Zipettte on GitHub · 2026-11-24 16:30 UTC · original

Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at 08e4c89: the new test resource::tests::host_texture_drops_unsupported_uav_flag_for_b5g5r5a1 fails every time (3/3):

panicked at crates\victory-gpu\src\resource.rs:1904:9:
assertion `left == right` failed
  left: 4
 right: 0

4 is D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS, so the UAV flag is kept on this machine. Maybe this RDNA3 driver reports typed UAV support for B5G5R5A1 and the flag is (correctly) not dropped. If so, the test may need to check the format support first instead of always expecting the flag to be removed. The other 43 victory-gpu tests pass.

Tested with AI assistance (Claude).

**@⁠Zipettte** on GitHub · 2026-11-24 16:30 UTC · [original](https://github.com/Marvisak/VIctory/pull/1040#issuecomment-7137777472) Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at 08e4c89: the new test `resource::tests::host_texture_drops_unsupported_uav_flag_for_b5g5r5a1` fails every time (3/3): ``` panicked at crates\victory-gpu\src\resource.rs:1904:9: assertion `left == right` failed left: 4 right: 0 ``` 4 is `D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS`, so the UAV flag is kept on this machine. Maybe this RDNA3 driver reports typed UAV support for B5G5R5A1 and the flag is (correctly) not dropped. If so, the test may need to check the format support first instead of always expecting the flag to be removed. The other 43 victory-gpu tests pass. _Tested with AI assistance (Claude)._
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-24 17:02 UTC · original

Tested across NVIDIA GeForce RTX 5090, AMD Radeon(TM) Graphics (1002:13c0), and D3D12 WARP with VICTORY_D3D12_DEBUG=1, and put together a rebased branch fixing the two issues noted above:

  1. Adapter-aware capability assertions in resource.rs: Queries CheckFeatureSupport(D3D12_FEATURE_FORMAT_SUPPORT) dynamically for B5G5R5A1_UNORM / B4G4R4A4_UNORM (stripping on NVIDIA while preserving supported flags on AMD and WARP), and tests unconditional RT+UAV flag stripping + pOptimizedClearValue omission on BC1_UNORM (71, flags = 5) and UAV stripping on B8G8R8X8_UNORM (88).
  2. Preserve MRT output slot indices when ALLOW_RENDER_TARGET was stripped (host.rs + draw.rs): Instead of continue shifting subsequent targets down by one slot, pushes a typed null RTV (Host::null_rtv, falling back to R8G8B8A8_UNORM TEXTURE2D when the texture's own format cannot back a host RTV) while keeping the non-RT texture out of self.targets so no invalid RENDER_TARGET barrier is emitted. Verified with a synthetic MRT draw (SV_Target0 bound to BC1_UNORM, SV_Target1 bound to R8G8B8A8_UNORM reading back [0, 255, 0, 255]) with zero D3D12 debug errors on all three adapters.

Branch ready to cherry-pick from (author attribution preserved): https://github.com/fuzeofficlal/VIctory/tree/fix/host-texture-uav-support-1040 (1bdeeb4c)

**@⁠fuzeofficlal** on GitHub · 2026-11-24 17:02 UTC · [original](https://github.com/Marvisak/VIctory/pull/1040#issuecomment-7138584070) Tested across **NVIDIA GeForce RTX 5090**, **AMD Radeon(TM) Graphics (`1002:13c0`)**, and **D3D12 WARP** with `VICTORY_D3D12_DEBUG=1`, and put together a rebased branch fixing the two issues noted above: 1. **Adapter-aware capability assertions in `resource.rs`**: Queries `CheckFeatureSupport(D3D12_FEATURE_FORMAT_SUPPORT)` dynamically for `B5G5R5A1_UNORM` / `B4G4R4A4_UNORM` (stripping on NVIDIA while preserving supported flags on AMD and WARP), and tests unconditional RT+UAV flag stripping + `pOptimizedClearValue` omission on `BC1_UNORM` (`71`, `flags = 5`) and UAV stripping on `B8G8R8X8_UNORM` (`88`). 2. **Preserve MRT output slot indices when `ALLOW_RENDER_TARGET` was stripped (`host.rs` + `draw.rs`)**: Instead of `continue` shifting subsequent targets down by one slot, pushes a typed null RTV (`Host::null_rtv`, falling back to `R8G8B8A8_UNORM` `TEXTURE2D` when the texture's own format cannot back a host RTV) while keeping the non-RT texture out of `self.targets` so no invalid `RENDER_TARGET` barrier is emitted. Verified with a synthetic MRT draw (`SV_Target0` bound to `BC1_UNORM`, `SV_Target1` bound to `R8G8B8A8_UNORM` reading back `[0, 255, 0, 255]`) with zero D3D12 debug errors on all three adapters. Branch ready to cherry-pick from (author attribution preserved): https://github.com/fuzeofficlal/VIctory/tree/fix/host-texture-uav-support-1040 (`1bdeeb4c`)
Author
Owner

@⁠MamaLeVrai on GitHub · 2026-11-24 20:08 UTC · original

Heads-up on this PR's test host_texture_drops_unsupported_uav_flag_for_b5g5r5a1: on main plus this PR alone it fails on an RX 6950 XT (left: 4, right: 0 at the first assert). host_texture only drops what the adapter refuses, via CheckFeatureSupport, and that adapter accepts a typed UAV on B5G5R5A1_UNORM, so the flag stays; the test assumes every adapter refuses it. The CI runner has no GPU there (host() is None, the test returns early), so CI would not show it. The code is right; the test can ask the adapter the same way and expect the flag kept or dropped accordingly. That is what the commit 9b2e665 of #1632 does (for B5G5R5A1 UAV and render target and for B4G4R4A4 render target). AI-assisted (Claude Code); no game data.

**@⁠MamaLeVrai** on GitHub · 2026-11-24 20:08 UTC · [original](https://github.com/Marvisak/VIctory/pull/1040#issuecomment-7143089395) Heads-up on this PR's test `host_texture_drops_unsupported_uav_flag_for_b5g5r5a1`: on `main` plus this PR alone it fails on an RX 6950 XT (`left: 4, right: 0` at the first assert). `host_texture` only drops what the adapter refuses, via `CheckFeatureSupport`, and that adapter accepts a typed UAV on B5G5R5A1_UNORM, so the flag stays; the test assumes every adapter refuses it. The CI runner has no GPU there (`host()` is `None`, the test returns early), so CI would not show it. The code is right; the test can ask the adapter the same way and expect the flag kept or dropped accordingly. That is what the commit `9b2e665` of #1632 does (for B5G5R5A1 UAV and render target and for B4G4R4A4 render target). AI-assisted (Claude Code); no game data.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 00:30 UTC · original

Automated triage for the maintainers. Closing because another open pull request covers the same change.

See #55. same change as before (drop UAV/RT flags by a format-support query, skip UAV barriers by a hard-coded flag test, guard RTVs) and still conflicts; #55 fixes the same NVIDIA packed 16-bit refusals in 47 lines by retrying creation. Also carried by bundles #1632/#1638.

If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

**@⁠Marvisak** on GitHub · 2026-11-25 00:30 UTC · [original](https://github.com/Marvisak/VIctory/pull/1040#issuecomment-7148584637) Automated triage for the maintainers. Closing because another open pull request covers the same change. See #55. same change as before (drop UAV/RT flags by a format-support query, skip UAV barriers by a hard-coded flag test, guard RTVs) and still conflicts; #55 fixes the same NVIDIA packed 16-bit refusals in 47 lines by retrying creation. Also carried by bundles #1632/#1638. If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!1040
No description provided.