Skip to content

d3d12: map the 11 R8/R16 and A4B4G4R4 formats the host creates (D3D-259) - #1914

Merged
ItsNotRexed merged 2 commits into
ItsNotRexed:mainfrom
zneel:missing-formats
Nov 22, 2026
Merged

ItsNotRexed merged 2 commits into
ItsNotRexed:mainfrom
zneel:missing-formats

Conversation

@zneel

@zneel zneel commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

D3D-259: item 1 of my FORMAT_SUPPORT finding in #1380 (finding, claim). Items 2 and 3 are already merged (#1493, #1511), and #759 has since merged the B8G8R8X8 pair.

vulkan_format() had no entry for these 11 formats: R16_UINT, R16_SINT, R16_SNORM, R8_UINT, R8_SINT, R8_SNORM, R8_TYPELESS, R16G16_UNORM, R16G16_SNORM, R16G16B16A16_SNORM and A4B4G4R4_UNORM. Native D3D12 creates all of them, but on the layer CreateCommittedResource returned E_INVALIDARG and FORMAT_SUPPORT returned DXGI_ERROR_UNSUPPORTED.

Changes

  • vulkan_format() maps each one to its direct Vulkan format. R8_TYPELESS maps to typeless R8_UNORM, like the other typeless families.
  • A4B4G4R4_UNORM maps to VK_FORMAT_R4G4B4A4_UNORM_PACK16.
    • Native D3D12 keeps alpha in bits 0-3 and red in bits 12-15, the reverse of Vulkan's A4B4G4R4_PACK16.
    • I measured this on the RX 9070 XT and on WARP by clearing a 1x1 render target to pure R, G, B and A: it read back f000 / 0f00 / 00f0 / 000f. An independent shader-load probe agreed: texel 0x1234 loads as R=1, G=2, B=3, A=4.
    • Its T# row (GFX10_FORMAT_4_4_4_4_UNORM) reads the channels as W, Z, Y, X (channels_abgr).
    • UAV clears get an R4G4B4A4 layout row. Whether this format has a typed UAV depends on the driver: WARP has one, AMD's D3D12 driver doesn't, and the layer follows the Vulkan driver, as it does for the other hardware-dependent bits.
  • block_format() gives copies the texel sizes of the new Vulkan formats.
  • depth_colour_pair() pairs D16 with R16 SNORM/UINT/SINT, like the other R16_TYPELESS members.
  • color_resolve_format_matches() refuses every integer format by numeric class (DeviceState::numeric_class). The list it replaces missed the new R8/R16 integer formats, and also the SINT forms of R8G8B8A8, R32 and R32G32B32A32, which D3D12 doesn't resolve either.
  • FORMAT_SUPPORT reports IA_VERTEX_BUFFER only for formats vertex_format() accepts. Previously it reported every format Vulkan can fetch.

Overlap: @NWX10's #521 (D3D-45) and #589 also add most of these mappings, as part of their clear changes. Both still conflict with main. If either lands first, I'll rebase this onto it and keep what's still missing, plus the tests.

Tests

  • d3d12_vulkan_device, new new_format_round_trips, on the PC-ABI layer device:
    • Each format is reported as a 2D texture and is created, as on the host. A 4x4 upload copied in and back out reads back bit for bit.
    • Numeric type: each format both the layer and the host render to is cleared to (-3, -0.4, 0.25, 7) on both, and the bytes must match. Red is -3 because single-channel formats see only red: SNORM gives -1, SINT -3, UNORM and UINT 0. None of the values is an exact half step at 4, 8 or 16 bits.
    • An A4B4G4R4 render target is cleared to pure R, G, B and A and compared with the host's bit pattern, where the layer reports a render target.
    • The host device is the one on the Vulkan device's own adapter, as in compare_format_support. Host comparisons are skipped when there is none.
    • The existing FORMAT_SUPPORT comparison from d3d12: FORMAT_SUPPORT follows D3D12's per-format rules #1511 now covers the new formats: 94 formats compared, up from 80 on main.
  • d3d12_descriptor_test: samples A4B4G4R4 through a T#, next to B4G4R4A4 and B5G5R5A1, and checks its swizzle is channels_abgr.
  • d3d12_uav_clear_test:
    • The element layout is checked: red gives f000, alpha 000f.
    • Float and Uint clears of an A4B4G4R4 UAV run end to end where the layer reports a typed UAV.
  • d3d12_copy_xfmt: D16_UNORM → R16_UINT and R16_SNORM → D16_UNORM copies match the host and WARP.
  • A4B4G4R4 is skipped where the Vulkan driver can't sample R4G4B4A4_UNORM_PACK16. Vulkan doesn't require that format. The skip follows the driver's format properties, not the layer's answers, so a dropped mapping still fails.
  • Controls:
    • On main the new device check fails with 22 failures, two for each format (no 2D support and no create).
    • Wrong channel order: with A4B4G4R4 mapped to A4B4G4R4_PACK16 (plus a copy size for it), the clears read back exactly reversed (000f for red). The host clear comparison, the T# swizzle check and the UAV clear test fail too.
    • Wrong numeric type: with R16_SNORM mapped to R16_UNORM and R8_SINT to R8_UINT, the host clear comparison fails both (0000 vs 8001, 00 vs fd).

Tested on an AMD Radeon RX 9070 XT (RDNA4), AMD 26.11.2, Windows 11 Pro 26300, MSVC 14.51, at ea32ba2f on main 003e7812:

  • d3d12_vulkan_device: the new check passes, with 11 of 11 round trips, 10 render-target clears matching the host, and the A4B4G4R4 clears right. FORMAT_SUPPORT has 0 mismatches.
  • d3d12_descriptor_test, d3d12_uav_clear_test and d3d12_copy_xfmt: pass.
  • python -I tests/test_gfx10_descriptors.py: OK.
  • Full ctest: 105/107. Both failures happen the same way on main 003e7812 without this PR:
    • d3d12_vulkan_device's compare_allocation_info (tiled 2D 4x MSAA RGBA32F: ours 4194304, host UINT64_MAX; tiled 2D D32F 256x256: ours 262144, host 327680), after d3d12: support tiled placed textures (D3D-191) #1674 merged. My check runs before it.
    • d3d12_draw's bundle blend pixel (got 128,0,128,255, expected red 64).

The branch merges cleanly with current main (4eb6155d), which hasn't added any of these mappings.

@whattheflop, thanks for the RTX 3080 run at 629bcb2d. It showed NVIDIA has no render target for R4G4B4A4_PACK16, so the A4B4G4R4 clears are skipped there. The layer reports BUFFER for A4B4G4R4 where native doesn't. That's part of the BUFFER-on-packed-formats item left out of #1511.

Known limitations (they already apply to the other typeless families on main; I'll post them as a finding rather than widen this PR):

  • Typed RTVs: an RTV of a typeless resource in another format of its family uses the resource's format. Only the RGBA8 family is reinterpreted (CreateRenderTargetView, color_view_format). So an R8_UINT RTV of an R8_TYPELESS texture clears as R8_UNORM, as R16_TYPELESS and R16G16_TYPELESS views already do.
  • UAV clears of UNORM/SNORM views of float-backed typeless images (R16G16_TYPELESS, R16G16B16A16_TYPELESS) encode into the image's SFLOAT format.
  • SRVs of a D16 texture as R16_SNORM/UINT/SINT get a colour view with the depth aspect, as R16_FLOAT already does.
  • Plain ResolveSubresource doesn't call the integer check that ResolveSubresourceRegion does.

Out of scope: the depth-SRV, video and sampler-feedback formats, and typed buffers. Vonsek's finding in #1745 covers the translator's narrow integer typed-buffer formats.

Intel runs would be welcome. No game files. AI-assisted (Claude Code); two AI review passes, one of them adversarial, and I checked the results.

🤖 Generated with Claude Code

vulkan_format() had no entry for R16_UINT, R16_SINT, R16_SNORM, R8_UINT,
R8_SINT, R8_SNORM, R8_TYPELESS, R16G16_UNORM, R16G16_SNORM,
R16G16B16A16_SNORM or A4B4G4R4_UNORM, so CreateCommittedResource refused
them with E_INVALIDARG and FORMAT_SUPPORT answered DXGI_ERROR_UNSUPPORTED
where native D3D12 creates them (item 1 of the FORMAT_SUPPORT finding in
ItsNotRexed#1380).

A4B4G4R4_UNORM keeps alpha in bits 0-3 and red in 12-15 (cleared and
read back on native D3D12, RX 9070 XT and WARP), which is Vulkan's
R4G4B4A4_UNORM_PACK16; its T# row reads that as W, Z, Y, X.

Copies get the formats' texel sizes, D16 copies pair with R16 SNORM/UINT/
SINT like the other R16_TYPELESS members, and the colour-resolve check
refuses every integer format by numeric class instead of a list that
missed R8/R16 and the SINT forms of R8G8B8A8, R32 and R32G32B32A32.

Tests: d3d12_vulkan_device creates each format (as the host does), copies
a 4x4 upload in and back out bit for bit, and clears an A4B4G4R4 render
target to R, G, B and A; d3d12_descriptor_test samples A4B4G4R4 through
a T# alongside B4G4R4A4 and B5G5R5A1.

AI-assisted (Claude Code).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@whattheflop

Copy link
Copy Markdown
Contributor

AI-assisted independent NVIDIA verification for D3D-259 on exact head 629bcb2d9940f014ffd280ca6fcde46b2b36e745, with query-only control on upstream main 6a6704df1592e1dc4a3215ddf1423a78adb52045. The PR head branches from 003e7812.

  • RTX 3080, NVIDIA 616.64, Vulkan 1.4.351, Windows 11 25H2 build 26200.9974. The Vulkan device and native DXGI/D3D12 device matched by LUID (00000000:0000f789). Built both stock test targets at the PR head and the D3D12 runtime library at main with MSVC 19.38 x64, WinSDK 10.0.26100.0 and Ninja. The runs used scratch selections linked against those exact runtime libraries.
  • 4×4 upload/readback. Queried the exact single-sample, optimal-tiled Vulkan 2D image combinations (sampled + transfer source/destination, with mutable format for R8_TYPELESS) and native D3D12 FORMAT_SUPPORT before resource creation. All 11 formats created and copied both ways bit for bit on the PR layer and independently on native D3D12. This covers R16 UINT/SINT/SNORM, R8 UINT/SINT/SNORM/TYPELESS, R16G16 UNORM/SNORM, R16G16B16A16 SNORM, and A4B4G4R4 UNORM.
  • FORMAT_SUPPORT. The stock comparison's rules passed for 94 formats on the head with 0 mismatches. The same-adapter query-only main control covered 83 formats with 0 rule mismatches and returned DXGI_ERROR_UNSUPPORTED for each of the 11 additions. Native returned 2D support for all 11. The comparison checks selected rules across the reported flags.
  • A4B4G4R4. Both APIs reported sampling. VK_FORMAT_R4G4B4A4_UNORM_PACK16 accepted the exact 8×8 sampled + transfer image and the PR's bindless T# test checked channels_abgr and matched 64/64 RGBA texels. A separate native D3D12 SRV/point-sampler check with the same packed gradient also matched 64/64. The exact Vulkan render-target query returned VK_ERROR_FORMAT_NOT_SUPPORTED, and both the layer and native D3D12 lacked RENDER_TARGET. The pure R/G/B/A clears were therefore skipped on both paths. A4 FORMAT_SUPPORT masks (Support1/Support2) were 008013f1/00000000 on the layer and 008413f0/00000200 on native.
  • Diagnostics and scope. One process-local NVIDIA ICD, an empty implicit-layer path, and only VK_LAYER_KHRONOS_validation 1.4.363, confirmed in the instance/device chain, with synchronization validation enabled. The final selected run had zero Vulkan validation warnings/errors and zero native D3D12 debug warnings/errors. The stock sample SPIR-V passed independent spirv-val --target-env vulkan1.3 validation, and all 5 CPU gfx10 descriptor tests passed under uv. GPU coverage was limited to the selected valid paths above. No full GPU suite, game files, or Intel run.

- UAV clears of A4B4G4R4: an R4G4B4A4_PACK16 layout row (red in bits
  12-15, alpha in 0-3), unit-checked in conversion_checks and cleared end
  to end where the layer reports a typed UAV (the driver's call: WARP has
  one, AMD's D3D12 driver doesn't).
- FORMAT_SUPPORT reports IA_VERTEX_BUFFER only for formats input layouts
  accept (vertex_format), not every format Vulkan can fetch: R8/R16
  SNORM/SINT (and R8G8 SNORM/SINT) have no input-layout mapping yet.
- new_format_round_trips: each render-target format is cleared to
  (-3, -0.4, 0.25, 7) on the layer and on the host and the bytes compared,
  which catches a mapping of the right size but the wrong numeric type
  (R16_SNORM as UNORM, R8_SINT as UINT); no value is an exact half step.
  The host is the Vulkan device's own adapter, as in
  compare_format_support, not the default one.
- A4B4G4R4 is skipped where the Vulkan driver can't sample
  R4G4B4A4_UNORM_PACK16 (Vulkan doesn't require it), by the driver's
  format properties rather than the layer's answers; B4G4R4A4 and
  B5G5R5A1 are never skipped.
- d3d12_copy_xfmt: D16_UNORM <-> R16_UINT and R16_SNORM copies, the new
  members of depth_colour_pair, against the host and WARP.

AI-assisted (Claude Code).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@zneel zneel changed the title d3d12: map the 11 R8/R16 and A4B4G4R4 formats the host creates d3d12: map the 11 R8/R16 and A4B4G4R4 formats the host creates (D3D-259) Nov 22, 2026
@ttd0x

ttd0x commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

NVIDIA (Turing) run, as asked: NVIDIA GeForce RTX 2080 Ti, driver 610.88, Windows 11 Pro 26200, MSVC 14.52 (VS 18 Build Tools), Ninja RelWithDebInfo, at ea32ba2f (PR head with the review fixes; also run earlier at 629bcb2d with the same results).

d3d12_vulkan_device: exit 0.

  • new formats: 11 of 11 created and copied both ways bit for bit (host compared), 9 render-target clears matched the host, A4B4G4R4 render target not reported, skipped, 0 failures
  • FORMAT_SUPPORT against the host on NVIDIA GeForce RTX 2080 Ti: 94 formats compared, 0 mismatches. Since that is 0 mismatches, the host's native D3D12 on this driver doesn't report A4B4G4R4 as a render target either, so the RT skip matches the host.
  • copy comparison: 0 of 69 cases differ. compare_allocation_info did not fail here (the tiled MSAA RGBA32F / D32F mismatch you saw on the RX 9070 XT).

d3d12_descriptor_test: exit 0. A4B4G4R4 is sampled on NVIDIA:

B4G4R4A4 sampled: 64 texels matched
A4B4G4R4 sampled: 64 texels matched
B5G5R5A1 sampled: 64 texels matched

d3d12_uav_clear_test: exit 0, A4B4G4R4_UNORM: no typed UAV on this device, its clears skipped.
d3d12_copy_xfmt_test: exit 0, 44 compared, 0 differ.

Full ctest: 102/103 (6 skipped, gameinput disabled). The one failure is d3d12_draw:

bundle blend pixel (0, 0): got 127,0,127,255, expected red 64

It isn't from this PR: d3d12_draw_test built at the base 003e7812 alone fails the same way on this machine. That's the non-monotonic fence value that #1807 fixes.

No game files used.

@airp1ane

Copy link
Copy Markdown
Contributor

Tested ea32ba2 merged onto main 4eb6155 on Windows 11, RTX 4060 Ti (Ada), NVIDIA 621.24, MSVC (VS 2026), scripts/build_runtime.ps1 + ctest -C RelWithDebInfo: pass. 110 tests; every test passes except d3d12_draw, which fails identically on main itself (fence signal 21 is not above 30, fixed by #1995). No new failures against the main baseline.

AI-assisted (Claude Code).

@UlteriorMotive00

Copy link
Copy Markdown
Contributor

Tested ea32ba2f on RTX 5070 (Blackwell), NVIDIA 617.42, Windows 11 26300: pass

AI-assisted run for D3D-259: NVIDIA GeForce RTX 5070, driver 617.42 (32.0.16.1742), Windows 11 Home 26300, MSVC 14.44 (VS 2022 Build Tools), Ninja RelWithDebInfo via scripts/build_runtime.ps1, at ea32ba2f (PR head). LEONIDA_VK_DEVICE=5070 (the PC also has an AMD iGPU).

d3d12_vulkan_device: exit 0.

  • new formats: 11 of 11 created and copied both ways bit for bit (host compared), 9 render-target clears matched the host, A4B4G4R4 render target not reported, skipped, 0 failures
  • FORMAT_SUPPORT against the host on NVIDIA GeForce RTX 5070: 94 formats compared, 0 mismatches
  • FORMAT_INFO: 195 queries, 0 mismatches. CheckFeatureSupport options: 15 compared, 0 mismatches.
  • A4B4G4R4 has no render target on Blackwell either, the same as the RTX 3080 run, so its clears are skipped there.

d3d12_descriptor, d3d12_uav_clear, d3d12_copy_xfmt: pass.

Full ctest: 106/107 (gameinput disabled: no SDL3). The one failure is d3d12_draw's bundle blend pixel (got 127,0,127,255, expected red 64). It fails identically on main 4eb6155d built on the same machine, so it isn't from this PR. It matches the failure noted in the PR description (there 128,0,128).

@ItsNotRexed
ItsNotRexed merged commit 8dc359b into ItsNotRexed:main Nov 22, 2026
4 checks passed
@zneel
zneel deleted the missing-formats branch November 22, 2026 16:39
@Koro4e

Koro4e commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Tested ea32ba2 on NVIDIA GeForce RTX 3060 (driver 617.14), Windows 11 26200.9457, MSVC 14.44 RelWithDebInfo: pass. d3d12_vulkan_device, d3d12_descriptor, d3d12_uav_clear and d3d12_copy_xfmt all passed (15.4 s total for the four entries), covering the new R8/R16 and A4B4G4R4 formats' creations, views and clears.

@bielfreedom

Copy link
Copy Markdown

Tested ea32ba2f on AMD Radeon RX 9070 XT (RDNA4), AMD driver 32.0.32029.2010, Windows 11 Pro build 26200, MSVC build of runtime/ (-DLEONIDA_VULKAN_HEADERS_FETCH=ON): pass for everything this PR changes.

This PR's checks, from d3d12_vulkan_device:

  • new formats: 11 of 11 created and copied both ways bit for bit (host compared), 10 render-target clears matched the host, A4B4G4R4 render target cleared to R, G, B and A, 0 failures
  • FORMAT_SUPPORT against the host: 94 formats compared, 0 mismatches; FORMAT_INFO: 195 queries, 0 mismatches; CheckFeatureSupport options: 15 compared, 0 mismatches
  • d3d12_uav_clear, d3d12_descriptor and d3d12_copy_xfmt pass.

Full ctest: 97/98 pass. The one failure is d3d12_vulkan_device at EXPECT(allocation_mismatches <= 0) (GetResourceAllocationInfo against the host: depth, MSAA and tiled sizes). It is not from this PR: the PR's base 003e7812 fails at the same check with the same sizes on this GPU, and on current main (4eb6155d) d3d12_vulkan_device passes on the same machine. A rebase should clear it.

This is a second check from someone other than the author, on the same GPU model the author measured A4B4G4R4 on.

AI-assisted (Claude Code). No game files.

AAyberkU pushed a commit to AAyberkU/Leonida that referenced this pull request Nov 22, 2026
…he host has the format

new_format_round_trips (D3D-259, ItsNotRexed#1914) failed on a Windows 10 host with 'new format 191: the host refuses a texture the layer creates': A4B4G4R4_UNORM is not in Windows 10's D3D12, whose CheckFeatureSupport reports no 2D texture for it, and the test stops there so no later check runs. The host comparison now runs only for a format the host reports as a 2D texture; a host that reports it and still refuses it fails as before.
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.

8 participants