Skip to content

D3D-87: B8G8R8X8 textures (BGRA8 images, views read alpha 1, no typed UAV) - #759

Merged
ItsNotRexed merged 2 commits into
ItsNotRexed:mainfrom
SpositoDouglas:d3d-87-b8g8r8x8
Nov 22, 2026
Merged

ItsNotRexed merged 2 commits into
ItsNotRexed:mainfrom
SpositoDouglas:d3d-87-b8g8r8x8

Conversation

@SpositoDouglas

@SpositoDouglas SpositoDouglas commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

What: DXGI_FORMAT_B8G8R8X8_UNORM, _UNORM_SRGB and _TYPELESS were refused by CreateCommittedResource. They now map to the B8G8R8A8 Vulkan formats, so creation, copies, footprints and clears work as for BGRA8. Shader views of the family read alpha as 1 (the T# selects one for alpha), and views between the B8G8R8X8 and B8G8R8A8 typeless families give a null descriptor. As the host runtime answers, the family has no typed UAV: CheckFeatureSupport leaves the typed UAV bits out (the BGRA8 image would have advertised them), typed B8G8R8X8 textures with ALLOW_UNORDERED_ACCESS are refused (the typeless format is accepted, as on the host), CreateUnorderedAccessView gives a null descriptor, and these images get no storage usage.
Why: D3D-87 in #313 (split from D3D-61); claim: #634 (comment)

Measured on the host runtime before deciding (RX 9060 XT, AMD's Windows D3D12 driver, and WARP):

  • ClearRenderTargetView on B8G8R8X8_UNORM: WARP writes the clear's alpha into the X byte, as Vulkan does in a BGRA8 image, so clears need no change.
  • CheckFeatureSupport: B8G8R8X8_UNORM, _UNORM_SRGB and _TYPELESS report no TYPED_UNORDERED_ACCESS_VIEW and no UAV_TYPED_LOAD/STORE; B8G8R8A8_UNORM reports all three.
  • CreateCommittedResource with ALLOW_UNORDERED_ACCESS: E_INVALIDARG for B8G8R8X8_UNORM and _UNORM_SRGB, S_OK for _TYPELESS; with ALLOW_RENDER_TARGET, S_OK for all three.

Tests:

  • d3d12_clear_test: B8G8R8A8_UNORM (control) and B8G8R8X8_UNORM clears, full and rectangle, byte-exact against WARP.
  • d3d12_vulkan_device_test: B8G8R8X8 footprints (mips, array, SRGB, typeless) against the host runtime; the three formats in the D3D-60 creation check; typed UAV bits and UAV/RTV resource creation compared with the host runtime. main's FORMAT_SUPPORT comparison with the host now covers the three formats as well.
  • d3d12_descriptor_test: a B8G8R8X8_UNORM and a B8G8R8A8_UNORM texture uploaded with the same bytes (fourth byte never 255), sampled through the bindless set: same red, green, blue; alpha 1 against the stored byte. T# formats and swizzles, a typed SRGB view of the typeless resource, refused views across the two families and refused UAVs. Since D3D-81: sample A8_UNORM textures through the alpha channel #674 took the upload offsets the earlier revision used, the two textures are now uploaded past the cube array's footprints, and their views sit at the end of the slot enum.
  • Negative control: with the shim change reverted and the tests kept, all three fail (B8G8R8X8 creation and format support are refused).

Tested:

  • Windows 11 Pro 26H2 (10.0.26300.9974), AMD Radeon RX 9060 XT (RDNA4), AMD Software 26.11.2 (32.0.32029.2010, Vulkan driver 2.0.416), Vulkan 1.4.359; MSVC 19.44 (VS 2022 Build Tools), Vulkan SDK 1.4.363.0, llvm-mc 21.1.8 (conda-forge), Python 3.13.9; on 41f4482 + this PR
  • d3d12_clear_test: 197/197 readbacks matched WARP (189 on 41f4482; the 8 new are B8G8R8A8 and B8G8R8X8)
  • d3d12_descriptor_test: pass, the B8G8R8X8 checks included (64 texels each). With Runtime: depth-plane SRVs only on their own depth family (#678 follow-up) #767 in main, D3D-75's depth-plane check passes on this GPU too, so no local change was needed this time
  • d3d12_vulkan_device_test: pass; FORMAT_SUPPORT against the host: 83 formats compared (80 on 41f4482), 0 mismatches. d3d12_uav_clear_test: pass
  • with LEONIDA_VK_VALIDATION=1 (implicit layers off): all four tests above pass with 0 validation errors
  • ctest --test-dir runtime\build -C RelWithDebInfo: 89/89 (the same on 41f4482)
  • python -I scripts\run_gpu_tests.py: 150 translated, 150 pass spirv-val; 145/145 native wave64, 145/145 with LEONIDA_W64_EMULATE=1
  • python -m compileall -q make_game.py tools tests, python -I make_game.py --help: pass; tests/semantic: 1338 OK; python -I tests/test_*.py: 161/161; pytest-based tests: 1184 passed, 9 skipped

The checks posted on 55e7760 were on the previous base. This rebase changes no behavior, only where the descriptor test uploads its two textures and numbers their slots.

Not in this PR:

  • Draws into a B8G8R8X8 render target, now that Runtime: compute path and graphics draws on Vulkan (D3D-3, D3D-4, milestone M1) #291 is in main: blend factors that read destination alpha should see 1 on these formats, and what WARP leaves in the X byte after a draw isn't measured yet.
  • A castable-format list that names the other family (relaxed casting) isn't consulted: views across B8G8R8X8 and B8G8R8A8 stay refused even then.

AI-assisted: written with Claude Code; reviewed and tested by me.
No game data, keys or decryption involved.

🤖 Generated with Claude Code

Copilot AI balanced review requested due to automatic review settings November 22, 2026 02:36

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

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

Tested 55e7760 on NVIDIA GeForce RTX 5070, driver 621.24, Windows 11 Pro (26300), VS 2022 Build Tools, Vulkan SDK 1.4.363.0, with LEONIDA_VK_VALIDATION=1 and LEONIDA_D3D12=vulkan: pass

  • ctest -C RelWithDebInfo: 97% tests passed, 1 tests failed out of 31
  • d3d12_clear_test (changed here): exit=1 validation=0 | format 28 case 0 byte 2: Vulkan 7f, WARP 80
  • d3d12_descriptor_test (changed here): exit=0 validation=0 | [rt] d3d12_xs: device slot 36 (forwarded) first call
  • d3d12_vulkan_device_test (changed here): exit=1 validation=0 | 10 validation errors
  • 30 test programs in the build pass with 0 validation errors
  • d3d12_clear_test fails (format 28 case 0 byte 2: Vulkan 7f, WARP 80) exactly as on main 67204bf, so not from this PR: NVIDIA rounds a 0.5 UNORM clear to 0x7f, which #521 addresses
  • d3d12_vulkan_device_test reports 10 synchronization-validation WRITE_AFTER_WRITE hazards on back-to-back copies (so ctest's d3d12_vulkan_device fails). main 8df277f shows the same 10 here, so not from this PR: it's @guimsolutions's finding in #634, which #782 addresses

Implicit Vulkan layers (overlays) were off through an empty VK_IMPLICIT_LAYER_PATH.

@JavierBlanco23

Copy link
Copy Markdown
Contributor

Tested #759 at 55e7760 on Windows 11, RTX 5080 (Blackwell), driver 616.56, Vulkan 1.4.x, MSVC 19.44.

d3d12_vulkan_device_test: All host comparisons match

  • Copy comparison: 0/69 cases differ (known BC mip differences documented)
  • MSAA quality: 12 compared, 8 skipped, 0 mismatches
  • Resolve: 60/60 matched, 10 skipped
  • WriteToSubresource/ReadFromSubresource: both paths matched

ctest: 31/31 PASS with LEONIDA_VK_VALIDATION=1

Note: Exit code 1 from d3d12_vulkan_device_test with validation due to 1 pre-existing ReShade layer load error, not from this PR.

AI-assisted.

@evilclanker9000

Copy link
Copy Markdown
Contributor

I checked the sRGB view of B8G8R8X8_TYPELESS on 55e776026d7058a2d53938181ce7433d92d1a222. The checked-in test inspects its descriptor. This probe sampled that view and a UNORM view of the same uploaded texture, with the component mapping (A, B, force-zero, R) for both. This puts the logical X8 alpha constant in the output’s red channel and an sRGB-decoded source channel in output alpha.

The 8×8 texture stored bytes in B,G,R,X order: (128+i, 32*y, 32*x, 3*i), where i=8*y+x. I used the runtime’s normal SRV/sampler creation and bindless lookup, and a test compute pipeline. A separate native Windows D3D12 program sampled the same bytes through the same two views and mapping. Both paths point-sampled the centers and packed to RGBA8.

RTX 5080 readback Matches native D3D12 on the RTX Matches analytic sRGB/UNORM reference Example at (4,4)
sRGB 64/64 56/64 exact, maximum 1 byte level (255,95,0,55)
UNORM 64/64 64/64 exact (255,164,0,128)

All 64 sRGB texels distinguish conversion from an unconverted UNORM read, and all 64 distinguish the required alpha constant from the stored X byte. The eight one-level differences from the ideal transfer function occur identically in Vulkan and native D3D12 on this GPU. WARP matches the analytic reference on all 64 sRGB texels. The augmented runtime test passed on the RTX with core/sync validation (Windows 11 build 26200, NVIDIA 32.0.16.1692).

SpositoDouglas and others added 2 commits November 22, 2026 10:03
Map B8G8R8X8_UNORM, _UNORM_SRGB and _TYPELESS to the B8G8R8A8 Vulkan formats, so
creation, copies, footprints and clears work as for BGRA8. Shader views of the family
read alpha as 1 (the T# selects one for the alpha channel), and views between the
B8G8R8X8 and B8G8R8A8 typeless families are refused, although both land on the same
VkFormat.

Compared with the host D3D12 runtime on an RX 9060 XT: it reports no typed UAV for the
family and refuses typed B8G8R8X8 textures that allow unordered access (the typeless
format is accepted). The BGRA8 image would have advertised storage, so
CheckFeatureSupport now leaves the typed UAV bits out, texture creation refuses typed
B8G8R8X8 with ALLOW_UNORDERED_ACCESS, CreateUnorderedAccessView gives a null descriptor
for the family, and its images get no storage usage. WARP writes the clear's alpha into
the X byte, as Vulkan does, so clears need no change.

Tests: d3d12_clear_test clears B8G8R8A8_UNORM and B8G8R8X8_UNORM against WARP;
d3d12_vulkan_device_test compares B8G8R8X8 footprints, the typed UAV bits and UAV/RTV
resource creation with the host runtime; d3d12_descriptor_test samples a B8G8R8X8 and a
B8G8R8A8 texture with the same bytes through the bindless set (alpha 1 against the
stored byte) and checks the refused views.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
List the B8G8R8X8 formats under what the Vulkan device implements: BGRA8 images whose
shader views read alpha as 1, a typeless family of their own, and no typed UAV, as on
the host runtime.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants