Skip to content

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

Closed
n-romanovich wants to merge 1 commit into
Marvisak:mainfrom
n-romanovich:pr/format-support-and-library-save
Closed

n-romanovich wants to merge 1 commit into
Marvisak:mainfrom
n-romanovich:pr/format-support-and-library-save

Conversation

@n-romanovich

Copy link
Copy Markdown

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

@n-romanovich
n-romanovich force-pushed the pr/format-support-and-library-save branch from a633e0c to e408cd8 Compare November 25, 2026 07:11

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

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

@n-romanovich
n-romanovich force-pushed the pr/format-support-and-library-save branch from e408cd8 to e1bf670 Compare November 25, 2026 07:19
RecompLive added a commit to RecompLive/victory-fork that referenced this pull request Nov 25, 2026
… (victory #2180)

Port of Marvisak/VIctory#2180 by n-romanovich (GPL-3.0-or-later).
host_desc queries D3D12_FEATURE_FORMAT_SUPPORT and widens a format to a
family member that supports UAV/render-target, or drops the flag, so
CreateCommittedResource stops refusing textures like B5G5R5A1_UNORM.
save() no longer re-serialises the (1+ GiB) library when only the early
list changed.

Adapted to ours: kept the streaming write_library save (no in-memory
blob) and its 0 byte count on the early-list-only path; the new test
uses our texture()/make_texture helpers; dropped the duplicate
RENDER_TARGET const.
@MamaLeVrai

Copy link
Copy Markdown

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.

r4tedx added a commit to r4tedx/VIctory that referenced this pull request Nov 25, 2026
…nd skip redundant pipeline library write, head e1bf670)

Merged cleanly. Both touched files match integration/play merge 1a232a8.
r4tedx added a commit to r4tedx/VIctory that referenced this pull request Nov 25, 2026

Marvisak commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

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:

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

@n-romanovich
n-romanovich force-pushed the pr/format-support-and-library-save branch from e1bf670 to a4abd07 Compare November 25, 2026 13:55
@n-romanovich

Copy link
Copy Markdown
Author

@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

Slay326 commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

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

KainanP commented Nov 25, 2026

Copy link
Copy Markdown

RTX 4060 Laptop (610.47): merges cleanly onto main 13f91ca 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: #1753 (comment). Tested with the help of an AI assistant (Claude Code).

@Marvisak

Copy link
Copy Markdown
Owner

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.

@Marvisak Marvisak closed this Nov 25, 2026
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.

6 participants