GPU: strip unsupported UAV/RT format flags and skip redundant pipeline library write #2178

Closed
n-romanovich wants to merge 1 commit from upstream-pr/2180 into main
n-romanovich commented 2026-11-25 07:06:55 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by n-romanovich on 2026-11-25T07:06:55Z.


Summary

  1. resource.rs (host_desc): Query D3D12_FEATURE_FORMAT_SUPPORT (format_support1) and strip or widen ALLOW_UNORDERED_ACCESS / ALLOW_RENDER_TARGET when a format (such as B5G5R5A1_UNORM or B4G4R4A4_UNORM) cannot support or cast to a format supporting those flags, preventing D3D12 GetResourceAllocationInfo / CreateCommittedResource failures. Adds unit test host_desc_strips_unsupported_uav_and_rt_flags.
  2. pipeline/library.rs (save): When l.added == 0 && !l.prebuilt_changed and only early-pipelines.txt changed, skip re-serializing and rewriting the 1+ GiB host-pipelines.bin blob.

Verification

Tested on NVIDIA GeForce RTX 5060 Ti:

  • cargo test --release -p victory-gpu --lib -- resource::tests pipeline::library: 19 passed; 0 failed
<!-- greyfinch-sync:Marvisak/VIctory:issue:6599178270 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2180). Originally posted by [n-romanovich](https://github.com/n-romanovich) on 2026-11-25T07:06:55Z. --- ## Summary 1. **`resource.rs` (`host_desc`):** Query `D3D12_FEATURE_FORMAT_SUPPORT` (`format_support1`) and strip or widen `ALLOW_UNORDERED_ACCESS` / `ALLOW_RENDER_TARGET` when a format (such as `B5G5R5A1_UNORM` or `B4G4R4A4_UNORM`) cannot support or cast to a format supporting those flags, preventing D3D12 `GetResourceAllocationInfo` / `CreateCommittedResource` failures. Adds unit test `host_desc_strips_unsupported_uav_and_rt_flags`. 2. **`pipeline/library.rs` (`save`):** When `l.added == 0 && !l.prebuilt_changed` and only `early-pipelines.txt` changed, skip re-serializing and rewriting the 1+ GiB `host-pipelines.bin` blob. ## Verification Tested on NVIDIA GeForce RTX 5060 Ti: - `cargo test --release -p victory-gpu --lib -- resource::tests pipeline::library`: `19 passed; 0 failed`
catminou4 commented 2026-11-25 08:06:13 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T07:17:38Z.

Review: COMMENTED


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

Unsupported UAV/RT format flags stripped + redundant... skipped — format-flag sanitization for host pipelines.

<!-- greyfinch-sync:Marvisak/VIctory:review:6053351139 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2180#pullrequestreview-6053351139). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T07:17:38Z. **Review:** COMMENTED --- Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff. Unsupported UAV/RT format flags stripped + redundant... skipped — format-flag sanitization for host pipelines.
MamaLeVrai commented 2026-11-25 09:06:22 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by MamaLeVrai on 2026-11-25T08:52:13Z.


Test report on real hardware: AMD RX 6950 XT (RDNA2), Windows 11, Rust 1.98.1, with a GPU present, so the hardware-only shader checks run. I merged this PR's head e1bf6701 into main 940d32f in a throwaway tree (no conflict). cargo clippy --workspace --all-targets --locked -- -D warnings: clean; the same with --all-features: clean. cargo test --workspace --locked: 702 passed, 0 failed, 10 ignored, two runs (main alone on the same machine: 701 passed, 0 failed, 10 ignored). The title was not run, so this says nothing about in-game effect. No game data.

AI-assisted (Claude Code); no game data.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7157574387 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2180#issuecomment-7157574387). Originally posted by [MamaLeVrai](https://github.com/MamaLeVrai) on 2026-11-25T08:52:13Z. --- Test report on real hardware: AMD RX 6950 XT (RDNA2), Windows 11, Rust 1.98.1, with a GPU present, so the hardware-only shader checks run. I merged this PR's head `e1bf6701` into `main` `940d32f` in a throwaway tree (no conflict). `cargo clippy --workspace --all-targets --locked -- -D warnings`: clean; the same with `--all-features`: clean. `cargo test --workspace --locked`: 702 passed, 0 failed, 10 ignored, two runs (`main` alone on the same machine: 701 passed, 0 failed, 10 ignored). The title was not run, so this says nothing about in-game effect. No game data. AI-assisted (Claude Code); no game data.
Marvisak commented 2026-11-25 14:07:19 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T13:28:19Z.


Automated triage for the maintainers.

Merge candidate. The PR now holds only the format-support change. host_desc (crates/victory-gpu/src/resource.rs) queries the host's Support1 bits through the shared cache, descriptor::host::format_support1. typed_store now wraps that cache, so there is no second cache. For a texture asking for UAV or render-target use in a format the host can't serve, it switches to the typeless family when a sibling format supports that use, and otherwise drops the flag with a warning. On main such a texture is not created at all, so the title gets no texture. Here it gets one it can sample. Later UAVs are still refused by fits. Later RTVs are now skipped with a warning in State::set_targets (draw.rs) and clear_rtv (list.rs), the same way set_targets already skips a target with no host texture. The author gives the title's log line for the case (a 2560x1440 B4G4R4A4_UNORM render target refused with 0x80070057). CI (check) passes, and it merges cleanly.

For the maintainer:

  • A skipped target shifts later targets down a slot, as the existing skip in set_targets already does.
  • A tester on #2121 links #1630 and #1832 to the same missing format-115 texture. If those convert the format instead, pick one of the three approaches.
  • The PR title and description still describe the library-save change that was split out. Please update them.

Reply to @n-romanovich: thanks, all three points are addressed (the split, the reused cache, the logged handling of later views), plus the title evidence.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7163825443 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2180#issuecomment-7163825443). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T13:28:19Z. --- <!-- victory-triage v1 head=a4abd0788857ef68581de4372f8442bc8303ea7f verdict=merge-candidate at=2026-11-25T14:50:52Z --> Automated triage for the maintainers. **Merge candidate.** The PR now holds only the format-support change. `host_desc` (`crates/victory-gpu/src/resource.rs`) queries the host's `Support1` bits through the shared cache, `descriptor::host::format_support1`. `typed_store` now wraps that cache, so there is no second cache. For a texture asking for UAV or render-target use in a format the host can't serve, it switches to the typeless family when a sibling format supports that use, and otherwise drops the flag with a warning. On `main` such a texture is not created at all, so the title gets no texture. Here it gets one it can sample. Later UAVs are still refused by `fits`. Later RTVs are now skipped with a warning in `State::set_targets` (`draw.rs`) and `clear_rtv` (`list.rs`), the same way `set_targets` already skips a target with no host texture. The author gives the title's log line for the case (a 2560x1440 `B4G4R4A4_UNORM` render target refused with `0x80070057`). CI (`check`) passes, and it merges cleanly. For the maintainer: - A skipped target shifts later targets down a slot, as the existing skip in `set_targets` already does. - A tester on #2121 links #1630 and #1832 to the same missing format-115 texture. If those convert the format instead, pick one of the three approaches. - The PR title and description still describe the library-save change that was split out. Please update them. Reply to @n-romanovich: thanks, all three points are addressed (the split, the reused cache, the logged handling of later views), plus the title evidence. --- _Generated by [Claude Code](https://claude.ai/code)_
n-romanovich commented 2026-11-25 14:07:32 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by n-romanovich on 2026-11-25T13:57:10Z.


@Marvisak, updated pr/format-support-and-library-save (a4abd07) to address all triage points:

  1. Split unrelated change: moved the pipeline/library.rs save() optimization (with the USED_CHANGED swap moved after Serialize succeeds) to a separate branch perf/skip-redundant-library-save. This PR now contains only the format-support / host_desc change.
  2. Reused CheckFeatureSupport cache: extended descriptor::host::typed_store into pub(crate) fn format_support1(format: u32) -> Option<u32> so resource.rs reuses the single cache instead of adding a second one.
  3. Later UAV / RTV handling & logging:
    • host_desc logs (tracing::warn!) when stripping ALLOW_UNORDERED_ACCESS or ALLOW_RENDER_TARGET.
    • Later UAVs on a stripped texture are already refused and logged by descriptor::host::fits.
    • Later RTVs in draw.rs (OMSetRenderTargets) and list.rs (ClearRenderTargetView) now check resource::allows_render_target(texture) and warn + skip instead of calling CreateRenderTargetView on a non-RT host texture.
  4. Title evidence: GTA VI creates B4G4R4A4_UNORM (format: 115) textures with ALLOW_RENDER_TARGET (flags: 1), which previously failed on the host with 0x80070057:
    WARN victory_gpu::resource: no host texture error=... (0x80070057) desc=ResourceDesc { dimension: 3, alignment: 0, width: 2560, height: 1440, depth_or_array_size: 1, mip_levels: 1, format: 115, sample_count: 1, sample_quality: 0, layout: 0, flags: 1 }
<!-- greyfinch-sync:Marvisak/VIctory:comment:7164530266 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2180#issuecomment-7164530266). Originally posted by [n-romanovich](https://github.com/n-romanovich) on 2026-11-25T13:57:10Z. --- @Marvisak, updated `pr/format-support-and-library-save` (`a4abd07`) to address all triage points: 1. **Split unrelated change**: moved the `pipeline/library.rs` `save()` optimization (with the `USED_CHANGED` swap moved after `Serialize` succeeds) to a separate branch `perf/skip-redundant-library-save`. This PR now contains only the format-support / `host_desc` change. 2. **Reused `CheckFeatureSupport` cache**: extended `descriptor::host::typed_store` into `pub(crate) fn format_support1(format: u32) -> Option<u32>` so `resource.rs` reuses the single cache instead of adding a second one. 3. **Later UAV / RTV handling & logging**: - `host_desc` logs (`tracing::warn!`) when stripping `ALLOW_UNORDERED_ACCESS` or `ALLOW_RENDER_TARGET`. - Later UAVs on a stripped texture are already refused and logged by `descriptor::host::fits`. - Later RTVs in `draw.rs` (`OMSetRenderTargets`) and `list.rs` (`ClearRenderTargetView`) now check `resource::allows_render_target(texture)` and warn + skip instead of calling `CreateRenderTargetView` on a non-RT host texture. 4. **Title evidence**: GTA VI creates `B4G4R4A4_UNORM` (`format: 115`) textures with `ALLOW_RENDER_TARGET` (`flags: 1`), which previously failed on the host with `0x80070057`: `WARN victory_gpu::resource: no host texture error=... (0x80070057) desc=ResourceDesc { dimension: 3, alignment: 0, width: 2560, height: 1440, depth_or_array_size: 1, mip_levels: 1, format: 115, sample_count: 1, sample_quality: 0, layout: 0, flags: 1 }`
Slay326 commented 2026-11-25 15:04:16 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Slay326 on 2026-11-25T14:13:13Z.


Measured on an RTX 3070 with a 3,843 MB library (27,160 pipelines): read whole it is one 3,665 MB private allocation for the run, and save rewrote all of it six times in 130 s with made=0 (only the early list had changed), each time with a second copy in memory: process commit swung between 37.6 and 42.1 GB. With both PRs merged, process commit at start is 10.3 GB instead of 15.6 GB, and no save rewrites the library in a 480 s run.

AI-assisted.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7164940220 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2180#issuecomment-7164940220). Originally posted by [Slay326](https://github.com/Slay326) on 2026-11-25T14:13:13Z. --- Measured on an RTX 3070 with a 3,843 MB library (27,160 pipelines): read whole it is one 3,665 MB private allocation for the run, and `save` rewrote all of it six times in 130 s with `made=0` (only the early list had changed), each time with a second copy in memory: process commit swung between 37.6 and 42.1 GB. With both PRs merged, process commit at start is 10.3 GB instead of 15.6 GB, and no save rewrites the library in a 480 s run. AI-assisted.
KainanP commented 2026-11-25 20:06:19 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by KainanP on 2026-11-25T19:36:11Z.


RTX 4060 Laptop (610.47): merges cleanly onto main 13f91cae but does not build (allows_render_target(texture) at draw.rs:421 and list.rs:1016 needs &texture). With that fix: B5G5R5A1 UAV half fixed (flag dropped), B4G4R4A4 half no longer crashes but the target loses its render-target use, so its draws and clears are skipped; no new failures. Details and the side-by-side table with the other #1753 PRs: https://github.com/Marvisak/VIctory/issues/1753#issuecomment-7172510623. Tested with the help of an AI assistant (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7172523176 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2180#issuecomment-7172523176). Originally posted by [KainanP](https://github.com/KainanP) on 2026-11-25T19:36:11Z. --- RTX 4060 Laptop (610.47): merges cleanly onto main 13f91cae but **does not build** (`allows_render_target(texture)` at draw.rs:421 and list.rs:1016 needs `&texture`). With that fix: B5G5R5A1 UAV half **fixed** (flag dropped), B4G4R4A4 half no longer crashes but the target loses its render-target use, so its draws and clears are skipped; no new failures. Details and the side-by-side table with the other #1753 PRs: https://github.com/Marvisak/VIctory/issues/1753#issuecomment-7172510623. Tested with the help of an AI assistant (Claude Code).
upstream-sync closed this pull request 2026-11-25 23:03:59 +00:00
Marvisak commented 2026-11-25 23:05:57 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T22:06:11Z.


Automated triage for the maintainers, second look (a review against current main, with builds and tests where they could change the verdict).

Closing because it does not build on main and its rule is stricter than the host. host_resource returns an owned ID3D12Resource now, so allows_render_target(texture) fails to compile in draw.rs and list.rs. The format-support query ignores the castable-format lists that make_texture passes, so on an RX 6700 XT and on WARP this strips flags from textures main creates fine (B8G8R8X8 with unordered access, formats 68, 69 and 89 with either flag). The skip messages also warn on every call rather than once. The problem in #1600 is real; dropping a use only after the host has refused the creation, in make_texture's last fallback, would fix it without those side effects.

If this is mistaken, reply here with what was missed and it will be looked at again. Thank you for the contribution.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7175938347 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2180#issuecomment-7175938347). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T22:06:11Z. --- Automated triage for the maintainers, second look (a review against current `main`, with builds and tests where they could change the verdict). Closing because it does not build on `main` and its rule is stricter than the host. `host_resource` returns an owned `ID3D12Resource` now, so `allows_render_target(texture)` fails to compile in `draw.rs` and `list.rs`. The format-support query ignores the castable-format lists that `make_texture` passes, so on an RX 6700 XT and on WARP this strips flags from textures `main` creates fine (B8G8R8X8 with unordered access, formats 68, 69 and 89 with either flag). The skip messages also warn on every call rather than once. The problem in #1600 is real; dropping a use only after the host has refused the creation, in `make_texture`'s last fallback, would fix it without those side effects. If this is mistaken, reply here with what was missed and it will be looked at again. Thank you for the contribution.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
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.

Reference
Marvisak/VIctory!2178
No description provided.