Skip to content

d3d12: support typeless and castable RGBA8 RTVs on MSAA textures - #1874

Merged
ItsNotRexed merged 1 commit into
ItsNotRexed:mainfrom
Serrambi:d3d-rtv-msaa-castable
Nov 22, 2026
Merged

ItsNotRexed merged 1 commit into
ItsNotRexed:mainfrom
Serrambi:d3d-rtv-msaa-castable

Conversation

@Serrambi

Copy link
Copy Markdown
Contributor

Follow-up to finding #1745 (comment) (claimed in #1745 (comment)).

Summary

Allows typeless (DXGI_FORMAT_R8G8B8A8_TYPELESS) and castable (DXGI_FORMAT_R8G8B8A8_UNORM with a compatible format list) RGBA8 render-target view reinterpretation on multisampled 2D textures and 2D texture arrays (SampleDesc.Count > 1):

  • runtime/shims/d3d12_vulkan_device.cpp (CreateRenderTargetView): accept D3D12_RTV_DIMENSION_TEXTURE2DMS and D3D12_RTV_DIMENSION_TEXTURE2DMSARRAY when rd.SampleDesc.Count > 1, and keep TEXTURE2D / TEXTURE2DARRAY strictly gated to rd.SampleDesc.Count == 1.
  • runtime/src/vulkan_replay.h (detail::color_view_format): remove the resource.samples != 1 guard so ClearRenderTarget resolves the requested attachment format (vk.begin_rendering + vk.clear_attachments) on multisampled images as well.
  • runtime/test/typeless_rtv_test.cpp: test MSAA (samples = 4) single-layer and layered (first_layer = 1, layer_count = 2) replay for all five RGBA8 view formats instead of rejecting samples = 4.
  • runtime/test/d3d12_typeless_rtv_test.cpp: test 4x MSAA R8G8B8A8_TYPELESS and castable R8G8B8A8_UNORM ({UNORM, UNORM_SRGB}) clear -> ResolveSubresource -> readback against WARP (TEXTURE2DMS + TEXTURE2DMSARRAY, whole and partial rect), plus invalid view-dimension/slice-range/unlisted-format refusals.

Testing (no game files)

Tested on Windows 11 Pro, NVIDIA GeForce RTX 5070 Ti (driver 610.88, Vulkan SDK 1.4.363.0, MSVC 19.50.35719.0) after a clean runtime/build:

  • typeless_rtv_test.exe: passed (EXIT_CPU=0, 93 scenarios)
  • d3d12_typeless_rtv_test.exe (default and LEONIDA_VK_VALIDATION=1): passed (EXIT_GPU=0, EXIT_VAL=0, 1730 WARP readbacks matched, 27 views rejected, 0 validation errors)
  • ctest --output-on-failure -j 4: 102/103 passed (7 skipped/disabled; only d3d12_draw failed with the pre-existing main 003e7812 TEST-266 bundle-blend issue)

AI-Assisted (Gemini)

@whattheflop

whattheflop commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Windows Radeon and RTX 3080 verification (AI-assisted)

I verified D3D-241 at the exact open head e608a1b9929ade7da91253fc69c3659b61b41a7d. Its direct parent and reported PR base were both 003e78129303643a3fdc9e5f0e31a01b09759236. Live main was 6a6704df1592e1dc4a3215ddf1423a78adb52045. The diff admits the explicit multisampled RTV dimensions in the RGBA8 reinterpretation branch and removes the single-sample restriction from replay format selection. RTV creation, Replay

On Windows 11 Pro build 26200, I built the stock d3d12_typeless_rtv_test and typeless_rtv_test with MSVC x64 19.38.33145, Windows SDK 10.0.26100.0, Ninja and Vulkan SDK 1.4.363.0. The stock CPU test passed all 93 mock scenarios. A separate head-linked executable reused the stock positive MSAA helper and five case definitions. It ran committed 4x RGBA8 typeless and {UNORM, UNORM_SRGB} cast-list resources with explicit TEXTURE2DMS and TEXTURE2DMSARRAY RTVs, full-image and partial-rect clears, ordinary UNORM resolve and readback. The array cases checked both selected slices and both untouched slices. For the cast-list cases I used initial layout COMMON followed by an explicit legacy COMMON to RENDER_TARGET transition before using the stock legacy resolve transition. This keeps the host comparison on the documented enhanced-to-legacy interop path. The stock helper currently starts the cast-list resource in the enhanced RENDER_TARGET layout. The same explicit transition would make the stock reference sequence clearer.

Before submitting the cases, I checked the Vulkan image capabilities and native D3D12 and WARP flags. Both ICDs returned sample mask 0xf for UNORM, sRGB, mutable typeless backing and the mutable format list. WARP and each LUID-matched native adapter exposed Device10, Options12 enhanced barriers and relaxed casting, one 4? quality level (index 0) for all three RGBA8 formats, the typed MSAA RTV bits and UNORM resolve support. Each run used a single process-local ICD, an empty implicit-layer path, and explicit Khronos validation 1.4.363.0. The startup report listed Synchronization. Both runs exited 0 with zero Vulkan validation warnings or errors. The host debug queues reported only warning 820 for the omitted optimized clear value.

  • Ryzen 7 9800X3D Radeon iGPU (1002:13c0, Windows driver 32.0.21030.2001, AMD Vulkan 25.10.30.02, API 1.4.315). All five stock-color cases matched native Radeon byte for byte. WARP differed only in the seeded blue channel on the untouched outer array slices, by one code in 30 of 240 bytes per array case (0x4c WARP, 0x4d Radeon/Vulkan).
  • RTX 3080 (10de:2216, driver 616.64, Vulkan API 1.4.351). All five stock-color cases matched native D3D12 byte for byte. WARP differed by one code in 9 of 60 bytes in the typeless 2DMS rectangle case, and in 27 of 240 bytes per array case. The stock per-byte tolerance of one passed on both GPUs without changes.
  • Repeating all five cases on each GPU with endpoint colors gave exact equality across Vulkan, WARP and native D3D12, including the rectangle boundaries and untouched slices.

The successful selection covers committed textures with explicit views. Default/null descriptors, placed-resource behavior and the #1753 Radeon standard-swizzle allocation gap remain outside this evidence. The changed RTV gate is shared code, but the claim's placed case still needs its own result.

Scope disclosure: I invoked the stock GPU executable with --help assuming it supported a help flag. It instead ran the full suite once on the default RTX 3080, including rejection cases, outside the requested valid-only and isolated setup. The results above are from the separate capability-gated runs. The detached test checkout and review worktree were both clean.

@adriaespii

Copy link
Copy Markdown
Contributor

Tested e608a1b on AMD Radeon RX 9070 (RDNA4, driver 26.10.1 / Vulkan 1.4.359), Windows 11 Pro 24H2, MSVC 14.44 (VS 2022 Community), Vulkan SDK 1.4.363.0: pass (0 validation errors).

  • runtime/build/typeless_rtv_test.exe: PASS (typeless_rtv_test: 93 format, snapshot, whole/rectangle and rejection scenarios passed)
  • runtime/build/d3d12_typeless_rtv_test.exe (LEONIDA_VK_VALIDATION=1): PASS
    device: AMD Radeon RX 9070 (validation on)
    subgroup sizes: 32..64 (default 64), requirable in stages 0xf0, subgroupSizeControl on, computeFullSubgroups on
    typeless subresource regressions: 1584 mixed-format/automatic-mip/predicate cases; conditional rendering enabled
    typeless RTV: 1730 WARP readbacks matched, descriptor snapshots and format-cache order checked; 27 unsupported/invalid views rejected
    
    Exit code 0, 0 Vulkan validation errors.
  • ctest -R "typeless_rtv|d3d12_typeless_rtv": 2/2 passed (100%) in 10.39s.

Cross-vendor hardware check confirms MSAA typeless/castable RGBA8 RTVs, clears, format-cache order and WARP readback matches behave cleanly on AMD RDNA4. AI-assisted.

@ItsNotRexed
ItsNotRexed merged commit 98dc77c into ItsNotRexed:main Nov 22, 2026
4 checks passed
@Gabzinnn12

Copy link
Copy Markdown

Tested e608a1b on AMD Radeon RX 7600 (RDNA3), AMD 26.11.2 (LLPC), Windows 11, MSVC 19.44, Vulkan SDK 1.4.363.0: pass.

  • d3d12_typeless_rtv_test: exit 0 with and without LEONIDA_VK_VALIDATION=1 (+ VK_LAYER_VALIDATE_SYNC=1): 1730 WARP readbacks matched, 27 views rejected, no Vulkan validation errors reported.
  • typeless_rtv_test (CPU only): 93 scenarios passed.
  • ctest: 2 failed out of 103, d3d12_vulkan_device (line 3403: tiled 2D 4x MSAA RGBA32F allocation info, ours 4194304 bytes, host UINT64_MAX) and d3d12_draw (bundle blend pixel 128,0,128,255). Both fail the same way at this PR's merge base, main 003e781.

AI-assisted (Claude Code, reviewed with Codex). No game files.

@ezwinxdlmao

Copy link
Copy Markdown
Contributor

Tested e608a1b on an NVIDIA GeForce RTX 3050 Laptop GPU, driver 32.0.16.2101, Windows 11, native MSVC (VS 2022 Build Tools, Ninja, RelWithDebInfo): pass.

  • Full runtime build OK.
  • ctest -R typeless: d3d12_typeless_rtv and typeless_rtv pass (2/2).
  • Full ctest -j3: 101/103. The two failures are d3d12_vulkan_device (allocation_mismatches, line 3403; the host-size difference reported in Coordinating who works on what (5) (moved to #1380) #1218) and d3d12_draw (bundle blend pixel 127,0,127,255; TEST-266). Both fail identically on an unmodified main 003e7812, which is this PR's merge base, on the same GPU.

AI-assisted (Claude Code).

@Serrambi
Serrambi deleted the d3d-rtv-msaa-castable branch November 22, 2026 16:29
@sanakontorov-sys

Copy link
Copy Markdown

Tested e608a1b on NVIDIA GeForce RTX 5060 (Blackwell, driver 617.42, Vulkan 1.4.351), Windows 11 Pro build 26300, MSVC (VS 2026), LLVM_MC set, scripts\build_runtime.ps1, then ctest -j 4: pass for this change. d3d12_typeless_rtv and typeless_rtv pass; 106 of 107 run tests pass. The one failure is d3d12_draw ("fence signal 4 is not above 30"), which fails the same way on main 003e781 here and is fixed by #1807.

(Run with an AI coding agent.)

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.

7 participants