Skip to content

Runtime: typed RTVs of every typeless color family (D3D-275) - #2103

Merged
ItsNotRexed merged 2 commits into
ItsNotRexed:mainfrom
requiemsnkrp:d3d-275-typeless-views
Nov 22, 2026
Merged

ItsNotRexed merged 2 commits into
ItsNotRexed:mainfrom
requiemsnkrp:d3d-275-typeless-views

Conversation

@requiemsnkrp

Copy link
Copy Markdown

What and why

D3D-275 (claim), the views half of @zneel's finding; the resolves (D3D-274) are not touched.

CreateRenderTargetView reinterpreted only the RGBA8 typeless family and color_view_format (runtime/src/vulkan_replay.h) returned the resource's own format for the others, so a clear through a typed RTV of a non-RGBA8 TYPELESS texture wrote the resource's format.

  • ColorViewFormat holds the view's Vulkan format (the existing RGBA8 names keep their values, so callers are unchanged); CreateRenderTargetView accepts any typed format of a typeless texture's family.
  • The replay's "RGBA8 typeless" resource flag now means "any typeless color resource", and color_view_format accepts any format of the family, so the clear goes through a view in the RTV's format. Typeless images were already created mutable, so no image change.
  • Families: B8G8R8A8 (B8G8R8X8 kept apart, as D3D12 requires), R16G16B16A16, R32G32B32A32, R32G32, R16G16, R10G10B10A2, R8G8, R32, R16; RGBA8 unchanged.
  • Draws were already right: the replay builds the attachment view from the PSO's RTVFormats (viewed.format = pipeline->color_formats[slot]), which D3D12 requires to equal the RTV's. Confirmed by reverting the layer half of this PR: clears go back to 34 differing, draws still match. The test now covers both.
  • docs/d3d12_vulkan.md, typeless RTV section.

Tested

New d3d12_typeless_families_test: every typed view of each family, cleared to (0.5, 7, -1, 300) and read back, compared byte for byte with the host D3D12 on the same adapter (matched by LUID, not the default adapter); plus 8 full-screen draws (R16G16B16A16 UINT/FLOAT/UNORM, R32 UINT/FLOAT, R10G10B10A2 UINT/UNORM, R8G8B8A8_UINT) against the host with HLSL from d3dcompiler_47.

62 clears compared with NVIDIA GeForce RTX 3060, 0 differ; 10 view formats skipped; WARP differs from the host in 8
8 draws compared with NVIDIA GeForce RTX 3060, 0 differ
  • On origin/main 4eb6155 (test only): 34 of 62 clears differ, e.g. an R16G16B16A16_UNORM view of R16G16B16A16_TYPELESS: host ff7fffff0000ffff, main 0038004700bcb05c (the clear written as half floats); a B8G8R8A8_UNORM_SRGB view: host 00ffbcff, main 00ff7fff (no sRGB encoding).
  • The 10 skipped view formats have no Vulkan mapping on main (the R8 family, R16G16B16A16_SNORM, R16G16_UNORM/SNORM, R16_UINT/SNORM/SINT; d3d12: map the 11 R8/R16 and A4B4G4R4 formats the host creates (D3D-259) #1914 maps some). The test is driven by the layer's own format support, so they get covered when they are mapped; nothing here touches d3d12: map the 11 R8/R16 and A4B4G4R4 formats the host creates (D3D-259) #1914's files.
  • WARP differs from the host GPU in 8 (rounding 0.5 to UNORM/SNORM, R10G10B10A2_UNORM alpha); the host GPU is the reference.
  • LEONIDA_VK_VALIDATION=1: 0 validation errors.
  • Full ctest without the window tests: the only failures are d3d12_com (segfault), d3d12_debug_markers, d3d12_indirect_rt, d3d12_draw, d3d12_set0_compute, which fail the same way on origin/main 4eb6155 without this branch.

NVIDIA GeForce RTX 3060, driver 32.0.16.1714, Windows 11, MSVC 19.51, Windows SDK 10.0.26100. No game files. AI-assisted (Claude).

requiemsnkrp added 2 commits November 22, 2026 16:48
- ColorViewFormat now holds the view's VkFormat number (the RGBA8 names keep their values), and
  CreateRenderTargetView accepts any typed format of a TYPELESS color texture's family (B8G8R8A8 and
  B8G8R8X8 kept apart), not only RGBA8.
- ResourceBinding::rgba8_typeless becomes typeless (any TYPELESS color resource); color_view_format accepts a
  format of the resource's family (typeless_view_family, R8 included for when it is mapped), so clears go
  through a view in the RTV's format. Attachment views of every typeless image ask for color-attachment usage
  only.
- d3d12_typeless_families_test: every typed RTV format of each family, two clear values, bytes compared with
  the host D3D12 on the same adapter (LUID) and reported against WARP.
- docs/d3d12_vulkan.md: the typeless RTV section.

AI-assisted.
- d3d12_typeless_families_test also draws a full-screen pass (GLSL stand-ins of translated shaders found by FSSM
  hash; the host's HLSL through d3dcompiler_47) into R16G16B16A16_UINT/FLOAT/UNORM, R32_UINT/FLOAT,
  R10G10B10A2_UINT/UNORM and R8G8B8A8_UINT RTVs of TYPELESS textures, PSO RTVFormats naming the typed format:
  8 of 8 equal the host D3D12 on the same adapter, no validation error.
- Draws need no layer change: the replay's draw attachment view already takes the PSO's RTVFormats[slot]
  (GraphicsPipeline::color_formats), which D3D12 requires to equal the RTV's; the same draws matched before the
  clear fix too.
- test/glsl/ps_typeless_float.frag, ps_typeless_uint.frag; docs/d3d12_vulkan.md typeless RTV section.

AI-assisted.
@JavierBlanco23

Copy link
Copy Markdown
Contributor

Tested 88215f92 on NVIDIA GeForce RTX 5080, driver 616.56, Windows 11 (MSVC 19.44, Ninja): pass.

  • typeless_rtv_test.exe: 93 scenarios passed.
  • d3d12_typeless_rtv_test.exe: 1730 WARP readbacks matched, 27 unsupported/invalid views rejected.
  • d3d12_typeless_families_test.exe: 62/62 clears and 8/8 draws matched host RTX 5080 (0 differ; 10 view formats skipped; WARP differed in 8 clears).

@XenonXYX

Copy link
Copy Markdown

Tested 88215f92 on a GeForce RTX 5070 with a Ryzen 7 7800X3D, Windows 11 Pro 26H2 (build 26300.10075), and NVIDIA driver 610.88. The verbose d3d12_typeless_families output identified the RTX 5070 as both the Vulkan device and the native D3D12 reference.

All 62 clears and all 8 draws matched native D3D12 byte for byte. The test skipped 10 unsupported view formats (20 clear cases). No draws were skipped. WARP differed from the hardware reference on 8 clears. CTest passed.

AI-assisted test run.

@whattheflop

Copy link
Copy Markdown
Contributor

AI-assisted Radeon verification of D3D-275 on 88215f92eee084657f0c9665126e33b0c94a64f4 against 4eb6155d3ac4f9d3fadb0d095c4ce13e76783615 with a test-only overlay.

AMD Radeon(TM) Graphics (1002:13c0, Ryzen 7 9800X3D iGPU), Windows 11 25H2 build 26200.9974, Windows display driver 32.0.21030.2001, AMD proprietary Vulkan driver 25.10.30.02 (raw 0x800161, Vulkan 1.4.315). Vulkan, DXGI and the native D3D12 device each reported LUID 00000000:00012761. Built with MSVC 19.38.33145 and SDK 10.0.26100.0.

Runtime Clears matching native D3D12 Draws matching Vulkan validation errors
PR head 62/62 7/7 0
Pinned base 28/62 (34 differ) 7/7 0

Both runs used the same cases and native reference bytes. Ten clear view formats were skipped on each revision because the layer currently has no mapping: R16G16B16A16_SNORM, R16G16_UNORM/SNORM, R16_UINT/SNORM/SINT and the four R8 views. There were no additional Radeon format skips. Radeon rounds the R16G16B16A16_UNORM clear of 0.5 to 0x8000 (the RTX 3060 report has 0x7fff), and the PR matches the local native result.

I ran only d3d12_typeless_families_test using the unchanged runtime sources for each commit. The disposable test wrapper checks native format support and readback footprints, uses explicit PSO defaults and a 5-second fence deadline, and omits WARP. It retains seven draws (R16G16B16A16 UINT/FLOAT/UNORM, R32 UINT/FLOAT, R10G10B10A2 UINT/UNORM). I omitted the stock RGBA8 UINT draw because its shader writes 300 and 1000 into 8-bit channels, which Vulkan defines as poison. In-range constants would make that case portable. Vulkan fragment output rules

Runs were serial with a 60-second process deadline, one physical Vulkan device, the AMD ICD only, an empty implicit-layer path, and Khronos 1.4.363 core and synchronization validation. Scope was synthetic 4×4, single-sample, 2D RTV clears and draws with readback. The other parts of the original finding (UAV clears, depth SRVs and resolves) were outside GPU test scope. Original finding

@0xTehuti 0xTehuti 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.

GPU Verification & Review (NVIDIA Turing / RTX 2070 SUPER)

Tested and verified on Windows 11 with MSVC 2022, Ninja, CMake, and Vulkan SDK 1.4:

  • GPU: NVIDIA GeForce RTX 2070 SUPER (Driver 595.79, 8192 MB VRAM, Vulkan 1.4.363)
  • Validation Layers: Khronos Validation Layer active (LEONIDA_VK_VALIDATION=1)

Test Results

  • d3d12_vulkan_device: PASSED (8.57s, 0 validation errors)
  • d3d12_typeless_families_test: PASSED (62 clears and 8 full-screen draws matched byte-for-byte with the native host D3D12 on the RTX 2070 SUPER; 0 validation errors)

Engineering Review Notes

  • The extension of ColorViewFormat and handling of typeless color resource families (B8G8R8A8, R16G16B16A16, R32G32B32A32, R32G32, R16G16, R10G10B10A2, R8G8, R32, R16) works cleanly and eliminates clears falling back to incorrect formats.
  • Minor observation: in d3d12_typeless_families_test.cpp, line 395 introduces warning C4189: 'drawn': local variable is initialized but not referenced when shaders are conditionally omitted. Not blocking, but can be cleaned up in a future pass.

LGTM. Ready to merge from a Windows + NVIDIA hardware perspective.

AI-assisted verification (Orca / Antigravity). No game data used.

@airp1ane

Copy link
Copy Markdown
Contributor

Tested 88215f9 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. 111 tests; the new d3d12_typeless_families passes; 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).

@Jadiac5

Jadiac5 commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Tested 88215f92 on Windows 11, MSVC 19.44.35222, Vulkan SDK 1.4.363.1, AMD Radeon RX 9070 XT (RDNA4), driver 32.0.32029.2010: pass.

  • Full ctest: 118 listed, 117 run, 116 pass, 1 fail (d3d12_draw, the same failure as main at 4eb6155d).
  • d3d12_typeless_families did not skip and prints "62 clears compared with AMD Radeon RX 9070 XT, 0 differ; 10 view formats skipped; WARP differs from the host in 0" and "8 draws compared with AMD Radeon RX 9070 XT, 0 differ"; the same with LEONIDA_VK_VALIDATION=1.
  • One difference from the NVIDIA results above: they report WARP differing from the host in 8 clears; on this card it is 0.
  • It merges into 49475796 without conflict (git merge-tree); I did not build that merge. The 10 skipped view formats are the ones d3d12: map the 11 R8/R16 and A4B4G4R4 formats the host creates (D3D-259) #1914 maps, so fewer should skip there.

AI-assisted (Claude Code).

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