Skip to content

BUILD-768: views across B8G8R8X8 and B8G8R8A8 through castable-format lists - #3252

Merged
ItsNotRexed merged 2 commits into
ItsNotRexed:mainfrom
SpositoDouglas:x8-castable
Nov 22, 2026
Merged

ItsNotRexed merged 2 commits into
ItsNotRexed:mainfrom
SpositoDouglas:x8-castable

Conversation

@SpositoDouglas

Copy link
Copy Markdown
Contributor

What: a castable-format list (CreateCommittedResource3 / CreatePlacedResource2) may name the other family of a B8G8R8X8 or B8G8R8A8 texture. The layer kept the list only as Vulkan formats, where both families are BGRA8, so image_descriptor refused the view. Now the resource also keeps the DXGI list, a view may cross the families when the list names its format, and the view's format decides the alpha: 1 for B8G8R8X8, the stored byte for B8G8R8A8.

Measuring this found an older bug in the same function: a colour view in the other channel order, such as a B8G8R8A8 view of an R8G8B8A8 texture whose list names it, read red and blue unswapped. Both orders share one T# format code, and the swizzle came from the image's format. A colour view in the other order now takes its swizzle from its own format.

Why: BUILD-768, the second follow-up #759 / D3D-87 left out, after D3D-240; claim: #2516 (comment)

Measured on the host runtime before changing anything (RX 9060 XT with AMD's D3D12 driver, and WARP, both RelaxedFormatCastingSupported): a 4x4 texture whose texels are bytes B,G,R,X/A = 10, 20, 30, 40, read by a compute shader through each SRV.

Texture (castable list) SRV WARP and AMD read R, G, B, A (x255)
B8G8R8A8_UNORM ({B8G8R8X8_UNORM}) B8G8R8X8_UNORM 30, 20, 10, 255
B8G8R8X8_UNORM ({B8G8R8A8_UNORM}) B8G8R8A8_UNORM 30, 20, 10, 40
B8G8R8A8_TYPELESS ({B8G8R8X8_UNORM}) B8G8R8X8_UNORM 30, 20, 10, 255
B8G8R8X8_TYPELESS ({B8G8R8A8_UNORM}) B8G8R8A8_UNORM 30, 20, 10, 40
R8G8B8A8_UNORM ({B8G8R8X8_UNORM}) B8G8R8X8_UNORM 30, 20, 10, 255
R8G8B8A8_UNORM ({B8G8R8A8_UNORM}) B8G8R8A8_UNORM 30, 20, 10, 40

CreateCommittedResource3 returned S_OK for every list tried, sRGB variants included. A clear through a B8G8R8X8 RTV leaves the X byte different on the two (WARP 64 for UNORM and 0 for sRGB, AMD 0), so no test compares that byte.

Tests:

  • d3d12_descriptor_test: the B8G8R8X8 block grows from two textures to six, all uploaded with the same bytes. The four new ones are B8G8R8A8_UNORM listing B8G8R8X8_UNORM, B8G8R8X8_UNORM listing B8G8R8A8_UNORM, and R8G8B8A8_UNORM listing B8G8R8X8_UNORM or B8G8R8A8_UNORM, each viewed through the listed format. The test checks their T# formats and swizzles, checks that an unlisted format (B8G8R8X8_UNORM_SRGB) stays refused, and samples them through the bindless set. They must read the colours of the table above: alpha 1 through B8G8R8X8 views, the stored byte through B8G8R8A8 views, red and blue in the view's order.
  • Negative controls:
    • With the shim change reverted, the test fails where the first cross-family views are made (line 1232: image_at(cast_bgrx_slot, ...)).
    • With only the swizzle change reverted, it fails at line 1237: cast_rgba_image.swizzle == bgra_image.swizzle. That is the B8G8R8A8 view of an R8G8B8A8 texture, which involves no B8G8R8X8, so this second bug exists on main today.

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 16282101 + this PR
  • d3d12_descriptor_test, d3d12_clear_test (197/197 readbacks matched WARP), d3d12_uav_clear_test, d3d12_vulkan_device_test: pass, with and without LEONIDA_VK_VALIDATION=1 (0 validation errors)
  • d3d12_draw_test: 3/3 runs pass, and 3/3 with validation
  • ctest --test-dir runtime\build -C RelWithDebInfo: 129/129, the same with LEONIDA_VK_VALIDATION=1
  • python -I scripts\run_gpu_tests.py: 194 translated, 194 pass spirv-val; 175/189 pass and 14 skip, native wave64 and with LEONIDA_W64_EMULATE=1
  • python -m compileall -q make_game.py tools tests, python -I make_game.py --help: pass; tests/semantic: 4142 OK; pytest-based tests: 1479 passed, 16 skipped; python -I tests/test_*.py: 222/223. test_report_paths.py fails its macOS case-sensitive-volume test on this Windows machine, and this PR changes no Python file.

Not in this PR:

  • A typed B8G8R8X8 texture with ALLOW_UNORDERED_ACCESS and a list naming B8G8R8A8: the host accepts it, and the layer still refuses it. Accepting it needs storage usage on the image and B8G8R8A8 UAV views of a B8G8R8X8 texture.
  • RTVs across channel orders: the host clears an R8G8B8A8 texture through a listed B8G8R8A8 RTV in BGRA order, while the layer's RTV path for R8G8B8A8 resources knows the RGBA8 family only.

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

🤖 Generated with Claude Code

SpositoDouglas and others added 2 commits November 22, 2026 16:53
… list (BUILD-768)

A castable-format list may name the other family of a B8G8R8X8 or
B8G8R8A8 texture (relaxed casting). WARP and AMD's D3D12 driver accept
such lists both ways, typed and TYPELESS, and an SRV in a listed format
reads by its own format: alpha 1 for B8G8R8X8, the stored byte for
B8G8R8A8, and red and blue swapped when the list crosses channel orders
(an R8G8B8A8 texture read as B8G8R8A8 or B8G8R8X8). The layer kept the
list only as Vulkan formats, where both families are BGRA8, so it refused
a view across them, and its T# took the channel order from the image's
format, so a B8G8R8A8 view of an R8G8B8A8 texture read unswapped.

The resource now also keeps the list as the application gave it,
image_descriptor lets a view cross the families when the list names its
format, the alpha swizzle follows the view's format, and a colour view in
the other channel order takes its swizzle from that order (both orders
share one T# format code).

d3d12_descriptor_test adds a B8G8R8A8_UNORM texture listing
B8G8R8X8_UNORM, a B8G8R8X8_UNORM one listing B8G8R8A8_UNORM, and two
R8G8B8A8_UNORM ones listing B8G8R8X8_UNORM and B8G8R8A8_UNORM, each viewed
through the listed format: T# formats and swizzles, an unlisted format
refused, and the same bytes sampled through the bindless set.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Say that a castable-format list naming the other family lets a view cross
B8G8R8X8 and B8G8R8A8, that the view's format decides the alpha and the
channel order, and that a typed B8G8R8X8 texture with unordered access
and such a list is still refused, where the host accepts it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 22, 2026 19:53

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.

@hidrogenone

Copy link
Copy Markdown
Contributor

Tested 86743073 on NVIDIA GeForce RTX 5080 (Blackwell), driver 32.0.16.2124, Windows 11, Vulkan SDK 1.4.357.0. Build: VS 2026 (MSVC 19.51), Windows SDK 10.0.26100, Ninja RelWithDebInfo.

ctest -R d3d12_descriptor → pass (0.3s). First NVIDIA coverage for the B8G8R8X8 / B8G8R8A8 castable views (BUILD-768) on this adapter. AI-assisted.

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.

4 participants