Skip to content

RT-303: typed B8G8R8X8 textures with unordered access through a castable-format list - #4581

Open
SpositoDouglas wants to merge 3 commits into
ItsNotRexed:mainfrom
SpositoDouglas:x8-uav
Open

SpositoDouglas wants to merge 3 commits into
ItsNotRexed:mainfrom
SpositoDouglas:x8-uav

Conversation

@SpositoDouglas

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: RT-303 (claim: #4421 (comment))

Depends on: #4493 (D3D-466). This branch is built on its commit, which shows here until #4493 merges; the two commits of this PR are the last two. It uses the castable_list argument #4493 gives TextureCreateInfo.

What and why

A typed B8G8R8X8 texture with ALLOW_UNORDERED_ACCESS is valid on the host when its castable-format list names a format with a typed UAV. The layer refused every such texture (texture_format) and every UAV view of the family (CreateUnorderedAccessView). This is the follow-up #3252 named.

Now:

  • texture_format and allocation take whether the list names a format with a typed UAV, committed and placed. lists_typed_uav_format counts the formats CheckFeatureSupport reports with TYPED_UNORDERED_ACCESS_VIEW: a typed colour format, not sRGB, depth or B8G8R8X8, whose image can take storage writes.
  • The BGRA8 image gets storage usage, with mutable format and extended usage, so a B8G8R8X8_UNORM_SRGB texture's sRGB image need not take storage writes itself. bind_image keeps that image's views in formats without storage to sampling (VkImageViewUsageCreateInfo).
  • CreateUnorderedAccessView takes a UAV in a listed B8G8R8A8_UNORM or one-channel 32-bit format.

Still refused: a UAV in B8G8R8X8 itself, in a format the list doesn't name, and in the other channel order (R8G8B8A8_*). The last one because the bindless set's storage view takes the image's channel order (bind_image, vulkan_view_format), and the translator's image_store writes the components in order, without the T#'s DST_SEL, so an R8G8B8A8 UAV of the BGRA8 image would store red and blue swapped. Whether the console applies a T#'s swizzle to image stores isn't measured. The same question applies on main to an R8G8B8A8 texture with a B8G8R8A8 UAV through a list, which this PR doesn't touch.

Measured on the host before changing anything: CreateCommittedResource3 with ALLOW_UNORDERED_ACCESS, on WARP and on an RX 9060 XT with AMD's D3D12 driver (26.11.2). The two answer identically, byte for byte.

Texture Castable list WARP and AMD
B8G8R8X8_UNORM none E_INVALIDARG
B8G8R8X8_UNORM B8G8R8A8_UNORM S_OK
B8G8R8X8_UNORM B8G8R8A8_UNORM_SRGB E_INVALIDARG
B8G8R8X8_UNORM B8G8R8X8_UNORM_SRGB E_INVALIDARG
B8G8R8X8_UNORM R8G8B8A8_UNORM S_OK
B8G8R8X8_UNORM R8G8B8A8_UINT S_OK
B8G8R8X8_UNORM R32_UINT S_OK
B8G8R8X8_UNORM B8G8R8A8_UNORM, R8G8B8A8_UNORM S_OK
B8G8R8X8_UNORM_SRGB none E_INVALIDARG
B8G8R8X8_UNORM_SRGB B8G8R8A8_UNORM S_OK

Through a UAV in the listed format, with every texel starting as bytes 10, 20, 30, 40:

UAV Compute-shader store of (0.2, 0.4, 0.6, 0.25) ClearUnorderedAccessViewFloat, same value ClearUnorderedAccessViewUint (0x11, 0x22, 0x33, 0x44)
B8G8R8A8_UNORM 153, 102, 51, 64 153, 102, 51, 64 0x33, 0x22, 0x11, 0x44
R8G8B8A8_UNORM 51, 102, 153, 64 51, 102, 153, 64 0x11, 0x22, 0x33, 0x44

The alpha lands in the X byte, the same on both drivers. A texel the store doesn't touch keeps its bytes.

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; on main 03b09a08 + d3d12: sRGB and depth-only textures with unordered access created as the host does (D3D-466) #4493 + this PR.
  • d3d12_vulkan_device_test, new block:
    • creation: the ten textures above, committed and placed, against the measured answers and against the host on the layer's own adapter;
    • six UAV views and whether each gets a descriptor;
    • clears through a B8G8R8A8_UNORM UAV: float, uint, and a float rectangle over the uint clear. The bytes equal the measured ones and the host's, X byte included.
    • The block skips where BGRA8 has no storage images.
  • Negative control: with the shim change reverted, the test fails on every texture the host creates, committed and placed.
  • ctest --test-dir runtime\build -C RelWithDebInfo: 154/154, the same with LEONIDA_VK_VALIDATION=1.
  • d3d12_vulkan_device_test, d3d12_clear_test, d3d12_descriptor_test, d3d12_uav_clear_test, d3d12_r9g9b9e5_uav_test, typeless_rtv_test: pass, with and without validation, with no validation messages.
  • Not covered:
    • shader stores through these UAVs: only clears are checked on the layer, as there is no store fixture for them;
    • GPUs whose BGRA8 has no storage images, where the test skips.
  • No Python or translator file changes, so the Python checks and run_gpu_tests.py were not rerun.

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (No translator change.)

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

🤖 Generated with Claude Code

martingouv and others added 3 commits November 23, 2026 02:47
…the host does (D3D-466)

Typed R8G8B8A8_UNORM_SRGB, B8G8R8A8_UNORM_SRGB, D32_FLOAT and D16_UNORM have no
UAV view in D3D12 without a castable-format list, so their UAV-flagged images no
longer get VK_IMAGE_USAGE_STORAGE_BIT, which these Vulkan formats lack. The host
creates them; the layer refused them (sRGB on NVIDIA, all four on AMD).

The test this adds also showed what the storage bit had been refusing by chance:
the host refuses unordered access on D24_UNORM_S8_UINT and D32_FLOAT_S8X24_UINT,
and any volume texture in a depth format (with or without flags). Both are now
refused explicitly, in creation and GetResourceAllocationInfo alike.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…able-format list

A typed B8G8R8X8 texture with ALLOW_UNORDERED_ACCESS is valid on the
host when its castable-format list names a format with a typed UAV
(B8G8R8A8_UNORM, R8G8B8A8_UNORM, R8G8B8A8_UINT, R32_UINT): WARP and AMD's
D3D12 driver create it, committed or placed, and refuse it without a
list or with one naming only sRGB or B8G8R8X8 formats. Through a
B8G8R8A8_UNORM UAV both drivers store the alpha in the X byte, byte for
byte alike. The layer refused every such texture in texture_format and
every UAV view of the family.

texture_format and allocation now take whether the list names a format
with a typed UAV; the BGRA8 image then gets storage usage, with mutable
format and extended usage so a B8G8R8X8_UNORM_SRGB texture's sRGB image
need not take storage writes itself, and bind_image keeps that image's
views in formats without storage to sampling. CreateUnorderedAccessView
takes a listed B8G8R8A8_UNORM or one-channel 32-bit format. A UAV in
B8G8R8X8, in an unlisted format, or in the other channel order stays
refused: the bindless set's storage view takes the image's order, so an
R8G8B8A8 UAV would store red and blue swapped.

d3d12_vulkan_device_test creates ten such textures, committed and
placed, and compares the answers with the measured ones and the host's;
checks which UAV views get a descriptor; and clears through a
B8G8R8A8_UNORM UAV (float, uint, and a float rectangle over the uint
clear), comparing the bytes, the X byte included, with the measured ones
and the host's. It skips where BGRA8 has no storage images.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Say that a typed B8G8R8X8 texture allows unordered access when its
castable-format list names a format with a typed UAV, as on WARP and
AMD's D3D12 driver; how the layer creates its image and which UAV views
it takes; and what is left: UAVs in the other channel order, shader
stores through these views (only clears are checked), and GPUs whose
BGRA8 has no storage images.

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

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.

@justr4mzi

Copy link
Copy Markdown
Contributor

Verified PR #4581 on Windows 11 (25H2 26200.9974) / AMD Radeon RX 6700 XT (gfx1031, Adrenalin 26.11.2, Vulkan 1.4.315, MSVC 19.44.35230.0, Vulkan SDK 1.4.363.0) at head de466a29:

  • Build: configured Ninja RelWithDebInfo cleanly and built d3d12_vulkan_device_test ([11/11], exit 0).
  • RX 6700 XT full run (LEONIDA_HOST_ADAPTER=warp, standard & LEONIDA_VK_VALIDATION=1):
    • Exit 0 in both modes, 0 Vulkan validation errors (device: AMD Radeon RX 6700 XT (validation on), subgroup sizes: 32..64).
    • B8G8R8X8: typed UAV support and UAV/RTV resource creation match the host runtime -> passed.
    • B8G8R8X8 with unordered access: 10 castable lists created or refused, 6 UAV views given or refused, and B8G8R8A8 UAV clears matched the host runtime's answers and bytes -> passed (both committed and placed resources + float/uint/rect clears including X byte).
    • Note on default host adapter (AMD Radeon RX 6700 XT D3D12): when LEONIDA_HOST_ADAPTER is unset in this elevated session, the test passes FORMAT_INFO (195 queries), B8G8R8X8: typed UAV support..., sRGB/depth with unordered access, FORMAT_SUPPORT (94 formats), and copy comparison (0/75 diffs) before hitting the pre-existing host GLOBAL_REALTIME #2422 check at line 5244 (command_queue(host.p, rt_desc) == S_OK), which returns before the trailing castable/X8-UAV sections; LEONIDA_HOST_ADAPTER=warp keeps the layer on RX 6700 XT and exercises the entire PR end to end.
  • Docs & hygiene:
    • python -I -m unittest discover -s tests -p "test_docs*.py": 20/20 OK (20.023s).
    • scripts/check_no_game_data.py & git diff --check: clean (0).

Change looks solid: TextureCreateInfo, lists_typed_uav_format, bind_image (VK_IMAGE_CREATE_EXTENDED_USAGE_BIT + sampling-only VkImageViewUsageCreateInfo for non-storage view formats), and CreateUnorderedAccessView gating match host semantics and run cleanly under Vulkan validation on RDNA2.

AI-assisted (Gemini, Antigravity).

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