gpu: widen unsupported 16-bit render targets and UAVs to R8G8B8A8_UNORM #2767
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2767
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2767"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@narishaa on GitHub · 2026-11-25 20:07 UTC · original
narishaa:fix/nvidia-packed-16bit-targets→main· +327 −17 · 5 files · 1 commits · openSummary
Rebased adaptation onto
main(13f91ca) of #89 (by @HenriqueSBueno, currently markedtriage: needs rebase), addressing theDXGI_ERROR_INVALID_CALL(0x887A0001) device removal on NVIDIA GPUs reported in #2725 and #1753.On NVIDIA (tested on RTX 3050, driver
32.0.16.2101),B4G4R4A4_UNORM(115) fails render-target creation andB5G5R5A1_UNORM(86) fails typed UAV creation/allocation queries:CreateCommittedResource3/CreateCommittedResource:D3D12_CLEAR_VALUE::Format/D3D12_RESOURCE_DESC::Format is B4G4R4A4_UNORM(id=817,id=599)GetResourceAllocationInfo/CreateUnorderedAccessView:B5G5R5A1_UNORM(0x56) does not support typed UAVs (id=599,id=342)Changes
CheckFeatureSupport(D3D12_FEATURE_FORMAT_SUPPORT)once per packed 16-bit format (86,115) viaresource::target_format, widening render-target and unordered-access textures (and their clear values, RTVs, pipeline RT formats, andResolveSubresourceformats) toR8G8B8A8_UNORM(28) when unsupported. Sampled-only textures keep their native format.target_formatinshared_textureafter merging flags from aliased title textures at the same address so a sampled texture promoted toRENDER_TARGET/UNORDEREDdoes not keep format115/86.descriptor::host::fitsandresource::view_formatso views of widened targets resolve toR8G8B8A8_UNORM.CopyTextureRegionuploads inprepare_footprint_upload(while preservinglist.defer_fillfor unchanged footprints) and skip mixed packed/widened GPU-to-GPU copies/resolves.B5G5R5A1_UNORM/B4G4R4A4_UNORMrow expansion.Verification
Tested on Windows 10 (build 26200), Intel Core i7-9700KF, NVIDIA GeForce RTX 3050 (driver
32.0.16.2101), diagnostics build withVICTORY_D3D12_DEBUG=1:13f91ca):host GPU device removed(0x887A0001) ~12 s after the heap loop at frame ~52 with the 4 D3D12 errors above.packed 16-bit render targets are R8G8B8A8_UNORM on this GPU; title boots and runs past frame 1,024 at ~30 fps with zerono host textureorRemoveDeviceerrors.cargo clippy --workspace --all-targets --locked -- -D warnings: passcargo clippy --workspace --all-targets --all-features --locked -- -D warnings: passcargo xtask policy: pass (184 files ok)cargo test -p victory-gpu --locked: 194 passed, 2 failed (the pre-existing NVIDIA 1,000,000-view heap-cap assertionsdynamic_slots_are_held_until_releasedandlists_share_a_table_and_copies_keep_their_viewsfrom #1835), 1 ignored.Related: #2725, #1753, #89.
@fuzeofficlal on GitHub · 2026-11-25 20:27 UTC · original
Reviewed and tested
f307c7fcon Windows 11 + NVIDIA GeForce RTX 5090 + WARP againstmain(13f91ca).Hardware check & code review
On RTX 5090,
B5G5R5A1_UNORM (86)reportsRT = true, UAV = falseandB4G4R4A4_UNORM (115)reportsRT = false, UAV = false, so both hit the widening path toR8G8B8A8_UNORM (28)whenRENDER_TARGET | UNORDEREDis set (prepare_footprint_upload,expand_packed16_rows,descriptor::host::fits,RtvRecord, PSORTFormats, clear values, andResolveSubresourceformat all line up cleanly).Three remaining gaps worth noting on mixed widened/native paths:
read_back(list.rs:941-980): copying from a widenedR8G8B8A8_UNORMtarget back to a115/86(2-byte/texel)FOOTPRINTbuffer still issues a directCopyTextureRegionwith mismatched texture/footprint formats (28vs115/86), which D3D12 rejects.alias_copy(texture.rs:253-332):alias_source(resource.rs:1974) compares guestr.descelement sizes (both(2, 1)), so copying between a widened target (28, 4B/texel) and a native 16-bit sampled alias (115/86, 2B/texel) copies through a 2B/texel footprint and corrupts data/dimensions.skip_mixed_packed_copy) &B5G5R5A1RT-only:CopyResource/CopyTextureRegion/ResolveSubresourcebetween a native 16-bit sampled texture and a widened28target are silently dropped; and becausehost_lacks_targetrequires bothRENDER_TARGETandTYPED_UNORDERED_ACCESS_VIEW, even RT-onlyB5G5R5A1textures are widened on RTX 5090 despite native RT support (compare#89for companion/compute conversion on mixed copies).Verification (Windows 11, RTX 5090 + WARP)
--features diagnostics):resource::tests18/18 passed (includingpacked_16_expansion_matches_dxgi_layout); full--test-threads=1197 passed, 2 failed (only the 2 pre-existing RTX 5090 >1M heap-cap baselines).VICTORY_D3D12_WARP=1,--features diagnostics --test-threads=1): 199 passed, 0 failed, 1 ignored.cargo clippy(default &diagnostics): 0 warnings;cargo xtask policy: 184 files ok.13f91caand#2773(semantically mutually exclusive); conflicts with#89and#2679.@kotekompotek on GitHub · 2026-11-25 20:38 UTC · original
Correct bit-replication expansion (5->8 as v<<3|v>>2, 4->8 as v<<4|v, A1 -> 0/255) and the widening is applied at every seam that names a format: RTV record, view fits(), resolve formats, and both copy entry points guarded by skip_mixed_packed_copy for cross-element cases. Relates to #2442 (which drops UNORDERED on unviewable formats): this widens 86/115 to RGBA8 so the views become legal - complementary, and once both land the flag survives where it can.
@oni-swr on GitHub · 2026-11-25 20:58 UTC · original
Independent WARP/CPU verification of
f307c7fc(#2767).Review: Packed 16-bit render targets and UAVs become R8G8B8A8_UNORM only where the host lacks support (
host_lacks_target, queried once per format). The change is applied consistently inhost_desc,shared_texture, clear values, RTVs, pipeline RT formats, view-format checks, and resolve. Copies mixing a native packed texture with a widened one are skipped with a once-only warning. Buffer-to-texture footprint copies expand texels on the CPU into a widened upload buffer with a 256-byte pitch. The bit replication for B5G5R5A1 and B4G4R4A4 is right (hand-checked 0xffff and the mixed value). Two notes, neither blocking:resource.rsnames the specific title. #1633 rule 7 is about files, dumps, shader names and hashes, so this is probably fine, but you may prefer a generic wording.host_lacks_targetever returns true, so the GPU-side behaviour is unverified here and needs a GPU that lacks the formats.Results (WARP/CPU):
origin/main:cargo test -p victory-gpu --lib: 195 passed, 0 failed.cargo clippy --locked -p victory-gpu --all-targets [--all-features] -- -D warnings: clean.cargo test -p xtask(policy): 6 passed.Negative control (mutating the PR head): removing the bit replication for the 5-bit channels, or the alpha replication in the 4-bit format, makes
packed_16_expansion_matches_dxgi_layoutfail. The expansion test catches those.Method: no physical GPU.
VICTORY_WARP=1,VICTORY_D3D12_WARP=1, Windows SDK 10.0.26100dxil.dllonPATH, Windows 11, rustc 1.98.1 MSVC,--locked. Comparedorigin/main(13f91ca) with the PR head. The PR merges cleanly onto that main. No game files, dumps, shader names or retail hashes were used or are needed.AI disclosure: this verification was done by Claude Code / Claude Sonnet 5.5.
@artor410 on GitHub · 2026-11-25 21:53 UTC · original
Tested on RTX 3070 Ti, driver 610.88, Windows 11 26300, rustc 1.98.1. main
13f91ca. Headf307c7f(fast-forward on main).cargo test -p victory-gpu(main: 193 passed, 2 failed: the known heap-cap pairdynamic_slots_are_held_until_released,lists_share_a_table_and_copies_keep_their_views). With this PR: 194 passed, same 2 failed. Newpacked_16_expansion_matches_dxgi_layoutpasses.create_placedwith the UAV and/or RT flag, thendescriptor::host::make_view(View::Unordered(..))andHost::rtv(texture, None), thenGetDeviceRemovedReason, one process per case. On main: UAV view of 86 or 115 crashes the test process (0xc0000005 inside the driver); RTV of 115 removes the device (0x887A0001); 115 with RT|UAV gets no host texture.CheckFeatureSupporthere: 86 RT yes, typed UAV no; 115 RT no, typed UAV no.Covers both formats and both uses, and keeps the writes. Same approach as #89 and as the VItoriaBr fork, which reaches the world on an RTX 5060 Ti. Probe calls
Host::rtvdirectly, notset_targets; untested in-game here.(Claude Code, Claude Opus 5.5.)
@Marvisak on GitHub · 2026-11-25 23:21 UTC · original
Automated triage for the maintainers.
The approach is sound and well evidenced (debug-layer errors and
CheckFeatureSupportresults on NVIDIA, plus hardware reports in the thread):resource::target_formatwidens B5G5R5A1/B4G4R4A4 render-target and UAV textures to R8G8B8A8_UNORM where the GPU lacks the support, and the format is applied consistently inhost_desc,shared_texture, clear values,RtvRecord::host_desc, pipeline RT formats,descriptor::host::fitsand resolve. Buffer-to-texture copies are expanded inlist.rsprepare_footprint_upload, and the bit replication inunpack_16is right. Some paths that now reach a widened texture still assume 2 bytes per texel:list.rsread_back: a texture-to-footprint copy from a widened texture into a B5G5R5A1/B4G4R4A4 footprint callsCopyTextureRegionwith a 4-byte texture and a 2-byte footprint format. D3D12 rejects that, so it needs packing on the way back or a refusal.texture.rsstaging/upload: footprints come from the host description (RGBA8) while the detiled title memory is 2 bytes per texel, so a title-written widened texture would be uploaded with the wrong layout.texture.rsalias_copy(viaresource::alias_source) compares the guest element sizes, which are equal, so a widened target and a native sampled alias of the same memory are copied as if they had the same layout.host_lacks_targetwidens when either support bit is missing, so on NVIDIA a B5G5R5A1 texture that is only a render target is widened even though the GPU renders to it natively. Checking only the support each texture's flags need would keep more textures native.This also overlaps #89 (the original of this change, credited in the description) and takes a different approach from #2773 (drop the uses the device refuses). A maintainer should choose one direction. Minor: the
host_lacks_targetdoc comment could describe the targets generically. CI (check) passes. Handling or explicitly refusing the three copy paths above would make this a merge candidate.Generated by Claude Code
@potatoe0100 on GitHub · 2026-11-26 14:45 UTC · original
RTX 4060 8 GB (Ada), driver 621.14, Windows 11 Pro 26300. Head
f307c7fmerged ontomain63bcca4(clean).cargo test -p victory-gpu --lib --locked -- --test-threads=1: 230 passed, 2 failed. The 2 failures are the heap-cap pair that also fails onmainhere (fixed by #2461). Nothing new fails.The triage's first copy path (
read_back) is a crash, not just a bad copy. I used a scratch test (below) that writes a 4x4 texture from a title buffer through our list, reads it back into a footprint of the texture's own format, then submits.main0xc0000409)0xc0000409)0xc0000409)The upload half alone (
prepare_footprint_upload) records, closes and runs fine with this PR. Adding the texture-to-footprint copy makes the process abort when the list is closed. That's becauseread_backrecordsCopyTextureRegionfrom the widened R8G8B8A8 texture into a footprint that still names 86 or 115. A title that reads one of these targets back would then crash the process, where it used to work.So
read_backneeds one of two things: a widened read (an R8G8B8A8 footprint, then packing the texels back into 2 bytes on the CPU when the readback is copied to the title), or a refusal with a warning, like the mixed GPU copies. The last row also shows the triage's fourth point. On this card 86 is widened even when it's only a render target, becausehost_lacks_targetasks for both supports at once.Scratch test (in
resource.rstests, next toa_texture_read_back_reaches_the_title_buffer)I didn't check the other two paths the triage names (
texture.rsupload of title-written data, andalias_copy).AI-assisted (Claude). Unit tests only, no game data.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.