d3d12: B4G4R4A4 render targets are RGBA8 images where no 4444 format is a colour attachment (RT-4444-TARGET) #517
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs rebase
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/ubiquitarianism--leonida!517
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/517/head"
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?
@VibeClauding on GitHub · 2026-11-24 06:50 UTC · original
VibeClauding:cont-4444-target→main· +262 −1 · 3 files · 1 commits · merged 2026-11-24 20:43 UTCClaimed in #14 as
RT-4444-TARGET.What and why
DXGI_FORMAT_B4G4R4A4_UNORMmaps toVK_FORMAT_A4R4G4B4_UNORM_PACK16, which NVIDIA does not offer as a colour attachment, and neither areR4G4B4A4/B4G4R4A4(all sampled only; RTX 3070, driver 610.88,vulkaninfo --show-formats). So a B4G4R4A4 texture withALLOW_RENDER_TARGETwas refused:GetResourceAllocationInfoansweredUINT64_MAXand creation failed. The retail title asks for one during boot and asserts on the answer (seen on a forge-based branch on Windows; this is the same fix ontomain).Now, only where no 4444 format renders:
DeviceState's texture format choice, next to the B5G5R5A1 and sRGB UAV cases). Every 4-bit value is exact in 8 bits.RTVFormatsentry getR8G8B8A8_UNORMas the attachment format.4_4_4_4(136), as the console's do.bind_imageviews a 4444 T# on an RGBA8 image as RGBA8 withA4R4G4B4's channels (the lookup would otherwise pickA4B4G4R4by channel order, a 16-bit view of a 32-bit image, which Vulkan validation rejects).Not covered, and said in the code:
CopyTextureRegionbetween such a texture and a buffer footprint moves 4-byte RGBA8 texels, not packed 16-bit ones. Replay's footprint bounds checks still hold, so nothing is written outside the buffer. Converting would need the footprint's format inCopyLocation, which is not recorded today.Tests
d3d12_b4g4r4a4_target(modelled ond3d12_b5g5r5a1_uav, exits 77 where A4R4G4B4 renders): a size and a committed resource for a 1920x1080 target; whole and rectangle RTV clears with 4-bit-exact colours read back as RGBA8; the SRV T# format is 4_4_4_4; a non-render-target B4G4R4A4 texture still gets a size. Passes on RTX 3070 withLEONIDA_VK_VALIDATION=1, 0 validation errors.ctest(Windows 11, MSVC, RTX 3070): 302/304.d3d12_execute_indirect_validationfails the same way on unchangedmainhere;xmemfailed once under-j 4and passes alone (3 of 3).scripts/check_no_game_data.pyon the changed files: clean.AI-assisted (Claude Code); built and tested on the machine above.
@sodove on GitHub · 2026-11-24 07:16 UTC · original
Independent Windows test on RTX 5070 Ti (610.74), Windows 11 26100.7623, MSVC 19.44.35220 Release. I applied
28052acd70to maind42773d073. The PR's stock target test fails the allocation-size check with the main implementation and passes on this head with Vulkan validation enabled.I also compared full and rectangle clears with colors that need 4-bit quantization. I normalized WARP's packed 4444 readback into RGBA8 values for the comparison.
The fallback stored the colors at 8-bit precision. The default native hardware D3D12 adapter reported no 4444 render-target support, so WARP was the native reference here. This is a clear precision difference in addition to the documented footprint difference. Draw and sample precision were outside this test.
Synthetic fixtures only. AI-assisted verification.
@SweatierKey on GitHub · 2026-11-24 16:52 UTC · original · approved these changes
Independently verified on Windows 11 + NVIDIA GeForce RTX 5070 Ti (driver 616.92, clean
origin/mainat3ed8e50b7, no game files,VK_LAYER_KHRONOS_validationnot installed on host).python3 -I scripts/check_no_game_data.py: PASSd3d12_b4g4r4a4_target_test.exe:d3d12_b4g4r4a4_target_test: OK (RGBA8 image, render-target clears 64x32 matched, SRV T# format 136, 0 validation errors)VK_FORMAT_R8G8B8A8_UNORMwhenVK_FORMAT_A4R4G4B4_UNORM_PACK16lacks color-attachment support (NVIDIA), while preserving GFX104_4_4_4T# format codes and channel mapping inbind_image.AI-assisted: yes
@QemmHD on GitHub · 2026-11-24 20:43 UTC · original
Merging.
Why merged: RT-4444-TARGET: where the device can't use a 4444 format as a colour attachment (NVIDIA), a B4G4R4A4 render target becomes an RGBA8 image. Its T#s keep the 4_4_4_4 format, and PSO RTV formats follow the image. Before this, the render target couldn't be created at all (size UINT64_MAX). sodove (5070 Ti) and SweatierKey approved.
Why it's good: The new d3d12_b4g4r4a4_target really runs here (not skipped): "B4G4R4A4_UNORM ... using RGBA8", OK, 0 validation errors. b5g5r5a1_uav, srgb_uav and vulkan_device also pass. Follow-up, not a blocker: sodove measured that the RGBA8 fallback stores clears at 8-bit precision instead of quantising to 4 bits (0/1920 texels matched WARP's 4-bit result), and buffer-footprint copies from it move 4-byte texels (documented in the code). Quantising on clear and store would close that gap.
Tested on Windows 11 / RTX 4070 SUPER (NVIDIA 621.24), VS 2022 + Ninja RelWithDebInfo, Vulkan SDK 1.4.363.0. Merged alone onto main, its ctests pass both plain and with LEONIDA_VK_VALIDATION=1. Cumulative: #517, #907, #927, #954 and #1074 merged onto main
32a5d9698(after aslan2142's runtime merges). There the repo-consistency set gives 573 passed / 5 skipped / 0 failed, compileall is clean, and full ctest is 314/316 with the same 11 skips. The 2 failures are d3d12_depth_resolve (pre-existing) and d3d12_close_parity, which fails on plain32a5d9698too: a regression from #510, reported there, not from these PRs. git merge-tree against current main: no conflicts. Security read of the three-dot diff: no binaries, game data, downloads, network calls or CI changes.AI-assisted (Claude Code, Claude Opus 5.5).