GPU: a 4444 render target gets a BGRA8 stand-in #3877

Open
kotekompotek wants to merge 1 commit from upstream-pr/3877 into main
kotekompotek commented 2026-11-30 08:32:39 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-30T08:32:39Z.


For #1952 (see also #2723 for the same NVIDIA run's earlier blocker).

NVIDIA has no renderable DXGI_FORMAT_B4G4R4A4_UNORM (console format 115) at all: CheckFeatureSupport reports no RENDER_TARGET (on the GTX 1050 not even TEXTURE2D), so CreateCommittedResource fails E_INVALIDARG. The issue's 2560x1440 4444 target then has no host texture (no host texture ... format 115 flags 1), and the device is removed soon after.

A texture whose format the host cannot give the description's uses (render target, unordered access, or even a plain sampled texture) is now made in B8G8R8A8 instead: same channel order, and every 4-bit value is exact in 8 bits (n*17). Views (RTV/DSV/SRV/UAV, described or default), pipeline RTVFormats, resolves and clear values all name the host texture's real format; copies between title memory and the texture expand packed 4444 rows to the host's texels and pack them back down on read backs and detiled uploads. Stand-in clears quantize to 4444 first, so a channel reads back as the console's exact nibble. Footprint/texture element mismatches that are not this stand-in are refused with a one-time warning instead of copying garbage.

Testing

GTX 1050 4GB, driver 32.0.15.8228, Windows 10 19045, debug build of this branch.

  • cargo test -p victory-gpu --lib: 231 passed, 5 failed — the same 5 that fail on main on this machine (descriptor heap size, placed texture, compute pipeline, dynamic slots, depth-bounds pipeline); all driver limits this PR does not touch.
  • New tests: a_4444_copy_round_trips_through_the_stand_in and a_4444_render_target_clears_and_reads_back create real 4444 render targets and expand, clear and pack on the live device, reading back exact nibble patterns; a_4444_host_desc_follows_host_support and a_4444_stands_in_where_the_host_cannot_use_it cover the capability gate without needing the host to lack the format.
  • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings clean.

On this machine creation_format(115, ...) resolves to B8G8R8A8, so the new tests exercise the stand-in for real; on a host with a renderable 4444 they take the native path instead.

AI-assisted. No game data is included.

<!-- greyfinch-sync:Marvisak/VIctory:issue:5561769551 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3877). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-30T08:32:39Z. --- For #1952 (see also #2723 for the same NVIDIA run's earlier blocker). NVIDIA has no renderable `DXGI_FORMAT_B4G4R4A4_UNORM` (console format 115) at all: `CheckFeatureSupport` reports no `RENDER_TARGET` (on the GTX 1050 not even `TEXTURE2D`), so `CreateCommittedResource` fails `E_INVALIDARG`. The issue's 2560x1440 4444 target then has no host texture (`no host texture ... format 115 flags 1`), and the device is removed soon after. A texture whose format the host cannot give the description's uses (render target, unordered access, or even a plain sampled texture) is now made in `B8G8R8A8` instead: same channel order, and every 4-bit value is exact in 8 bits (n*17). Views (RTV/DSV/SRV/UAV, described or default), pipeline `RTVFormats`, resolves and clear values all name the host texture's real format; copies between title memory and the texture expand packed 4444 rows to the host's texels and pack them back down on read backs and detiled uploads. Stand-in clears quantize to 4444 first, so a channel reads back as the console's exact nibble. Footprint/texture element mismatches that are not this stand-in are refused with a one-time warning instead of copying garbage. ## Testing GTX 1050 4GB, driver 32.0.15.8228, Windows 10 19045, debug build of this branch. - `cargo test -p victory-gpu --lib`: 231 passed, 5 failed — the same 5 that fail on `main` on this machine (descriptor heap size, placed texture, compute pipeline, dynamic slots, depth-bounds pipeline); all driver limits this PR does not touch. - New tests: `a_4444_copy_round_trips_through_the_stand_in` and `a_4444_render_target_clears_and_reads_back` create real 4444 render targets and expand, clear and pack on the live device, reading back exact nibble patterns; `a_4444_host_desc_follows_host_support` and `a_4444_stands_in_where_the_host_cannot_use_it` cover the capability gate without needing the host to lack the format. - `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings` clean. On this machine `creation_format(115, ...)` resolves to `B8G8R8A8`, so the new tests exercise the stand-in for real; on a host with a renderable 4444 they take the native path instead. AI-assisted. No game data is included.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3877:upstream-pr/3877'
git switch 'upstream-pr/3877'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3877'
git switch 'upstream-pr/3877'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3877'
git switch 'upstream-pr/3877'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3877'
git switch 'main'
git merge --squash 'upstream-pr/3877'
git switch 'main'
git merge --ff-only 'upstream-pr/3877'
git switch 'main'
git merge 'upstream-pr/3877'
git push origin 'main'
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!3877
No description provided.