Skip to content

Runtime: support color ResolveSubresourceRegion DECOMPRESS - #4884

Open
gabrielsteglich wants to merge 2 commits into
ItsNotRexed:mainfrom
gabrielsteglich:feat/color-resolve-decompress
Open

gabrielsteglich wants to merge 2 commits into
ItsNotRexed:mainfrom
gabrielsteglich:feat/color-resolve-decompress

Conversation

@gabrielsteglich

@gabrielsteglich gabrielsteglich commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: color ResolveSubresourceRegion DECOMPRESS

Depends on: #4745 (shared resolve synchronization and documentation), #4826 (shared swapchain-test code). The runtime change builds independently of both.

What and why

  • Replay DECOMPRESS for matching typed, uncompressed 2D color formats and sample counts. In-place resolves preserve the texels and synchronize the source. Out-of-place resolves use a Vulkan image copy that preserves sample count and respects source rectangles and destination offsets.
  • Support acquired swapchain images as single-sample destinations. Sources must be regular registered textures with transfer-source support.
  • Keep depth/stencil, compressed formats, format casts, and RGB96 emulation outside this path. In-place calls require matching source and destination origins, as documented by D3D12. Both native runtimes accepted Close for a mismatched-origin probe, so that probe was left unsubmitted and the layer regression checks for rejection.

Tested

Commit c20f06b8 on Windows 11 Pro build 26300, MSVC 19.44.35229, Windows SDK 10.0.26100.0, Vulkan SDK 1.4.363.0, x64 RelWithDebInfo. NVIDIA GeForce RTX 3090, driver 621.01, with Vulkan validation enabled and implicit layers disabled.

  • The follow-up changes only the test fixture’s chained field assignments flagged by MSVC. Both the focused and full suites were rerun at the new head. Independent NVIDIA/AMD testing covers the original e1074199 implementation.
  • Full runtime CTest: 159 passed, 8 skipped, 1 disabled, and 0 failures.
  • Focused CTest: 4/4 passed (d3d12_color_decompress, d3d12_depth_resolve, vk_command_replay, and dxgi_swapchain).
  • DECOMPRESS fixture: 10/10 on Leonida Vulkan and 9/9 each on native RTX 3090 D3D12 and WARP. It covers whole and shifted 1x copies, shifted 4x copies, in-place 1x and 4x resolves, untouched texels, and invalid calls. The same fixture rejected all five valid cases at Close on base de671352.
  • The swapchain test matched all 16,384 acquired-backbuffer pixels before Present with zero validation errors. A standalone native WARP control matched 48/48 backbuffer texels, including sentinels outside the copied region.

AI-assisted: yes (Codex).

  • All cases use synthetic data.

@tupacfan04

Copy link
Copy Markdown
Contributor

Tested e1074199 on Windows 11 x64 (MSVC 19.51.36260.0, NVIDIA RTX 5070, driver 621.24, Vulkan SDK 1.4.363.0): pass.

Built with -DBUILD_TESTING=ON and ran the focused targets directly:

  • d3d12_color_decompress_test: exit 0 — Leonida Vulkan 10/10, native RTX 5070 9/9, WARP 9/9 cases matched. This covers whole and shifted 1x copies, shifted 4x copies, in-place 1x and 4x resolves, untouched destination texels, and rejection of mismatched sample counts, mismatched formats, out-of-bounds source/destination, and displaced in-place calls. The test also checks that no new Vulkan validation errors appeared.
  • dxgi_swapchain_test: exit 0 — the new DECOMPRESS into an acquired backbuffer matched the copied pixels and the sentinels outside the region; CreateSwapChain/ForHwnd/CoreWindow, resize, present and readback paths passed with 0 validation errors.
  • d3d12_depth_resolve_test: exit 0 — 57 native/WARP comparisons matched and 9 refusals kept the destination.
  • vk_command_replay_test: exit 0 — scenes A–J (copies, clears, barriers, predication, volume copies, D32 resolves, overlapping-copy rejection) passed.

Build note, non-blocking: /W4 emits C4244 at runtime/test/d3d12_color_decompress_test.cpp:135 (D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES to the UINT16 subresource field); it does not affect the test result.

No Intel or AMD hardware available, so only NVIDIA + WARP were exercised. No game data used; synthetic fixtures only. AI-assisted verification.

@Ayinaki

Ayinaki commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested e107419 on RTX 5070, driver 616.86, Windows 10.0.26200: pass.

Built runtime with MSVC 14.52 (Visual Studio 18 2026, x64, RelWithDebInfo) and ran the targets this PR changes, with LEONIDA_VK_DEVICE="RTX 5070":

  • d3d12_color_decompress_test: "NVIDIA GeForce RTX 5070: 9/9 DECOMPRESS cases matched" and "WARP: 9/9 DECOMPRESS cases matched", so the color ResolveSubresourceRegion DECOMPRESS path agrees with the host runtime on both adapters.
  • dxgi_swapchain_test: PASS (CreateSwapChain, CreateSwapChainForHwnd, CreateSwapChainForCoreWindow and the rest), device line naming the RTX 5070.

Both exit 0.

@tupacfan04

Copy link
Copy Markdown
Contributor

VERIFIED SOUND. The suspected in-place layout hazard is not real: vulkan_replay.h:3583 records TRANSFER_SRC_OPTIMAL into the tracker, and d3d12_state::resolve_source is that same layout (:156-157), so the post-state matches the comment; the continue at :3588 only skips the self-copy and the destination transition. after_transfer_writes supplies the dependency when no transition is needed. Probe on RTX 5070 with validation: tracked layout after in-place DECOMPRESS plus RESOLVE_SOURCE->COPY_SOURCE is 6, texels intact red, zero replay VUIDs.

Tests: layer 10/10, RTX 5070 9/9, WARP 9/9, plus d3d12_depth_resolve, dxgi_swapchain and vk_command_replay pass with 0 validation errors; compileall and merge clean.

Nit: in-place is detected by VkImage (:1847, :3588) but by COM pointer in the shim (d3d12_vulkan_device.cpp:7674), so aliased ResourceIds sharing one image would leave the destination tracker id stale. Not reachable today.

AI-assisted review; synthetic fixtures only, no game files.

@XFlawless1

XFlawless1 commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Tested e1074199 merged with main 3faac557 (clean merge) on Windows 11 Pro 26300, MSVC 19.44, Vulkan SDK 1.4.363.0, RelWithDebInfo via scripts/build_runtime.ps1, LEONIDA_VK_VALIDATION=1, implicit layers off: pass on both GPUs.

RTX 5080, 621.14 Radeon iGPU of the Ryzen 7 9800X3D (RDNA2), 32.0.21042.62
d3d12_color_decompress, Leonida Vulkan 10/10 matched 10/10 matched
same fixture, native D3D12 on that GPU 9/9 9/9 on AMD's own D3D12 driver
same fixture, WARP 9/9 9/9
d3d12_depth_resolve, vk_command_replay, dxgi_swapchain pass pass
full ctest 171/171 170/171

No validation messages in either full run. So the DECOMPRESS behavior now matches a second native vendor besides the PR's RTX 3090 and WARP: whole and shifted 1x copies, shifted 4x copies, in-place 1x and 4x resolves, and the invalid calls.

The one Radeon failure is d3d12_sparse_queue_family_contract, which fails the same way on main. It's a validation + api_dump layer crash on the AMD driver (finding). In d3d12_depth_resolve the Radeon prints nine host quirk lines (D24S8 depth/stencil MIN/MAX: AMD's D3D12 differs from the clears and the layer matches them). main de671352 prints the same nine (17 of 26 match, 9 host quirks), so it's existing behavior the test already allows, not a change from this PR.

AI-assisted (Claude Code).

@gertify

gertify commented Nov 23, 2026

Copy link
Copy Markdown

Tested e107419 on NVIDIA GeForce RTX 4080 (driver 617.42), Windows 11, test programs cross-built with clang-cl + xwin: pass for the DECOMPRESS and depth resolve checks, by printed output.

  • d3d12_color_decompress_test: Leonida Vulkan 10/10 DECOMPRESS cases matched; native D3D12 on the RTX 4080 9/9 matched; WARP 9/9 matched.
  • d3d12_depth_resolve_test: 45 host comparisons matched, 9 refusals kept the destination, 0 modes the device lacks were refused.
  • dxgi_swapchain_test: not counted. The run was over ssh with no interactive window station, and the host runtime answered 0x887a0022 for every CreateSwapChainForHwnd case.

AI-assisted.

@ricardotanaka

Copy link
Copy Markdown

Re-tested the current head c20f06b8 (after the checks above, on e1074199) merged onto main 3faac557, on an AMD Radeon RX 7600 (RDNA3, AMD 26.11.2), Windows 11 26200, MSVC 19.44, RelWithDebInfo: pass, with and without LEONIDA_VK_VALIDATION=1. It adds a discrete RDNA3 on AMD's own D3D12 driver as the host reference.

  • d3d12_color_decompress: Leonida Vulkan: 10/10 DECOMPRESS cases matched, AMD Radeon RX 7600: 9/9, WARP: 9/9.
  • d3d12_depth_resolve: 48 host comparisons matched, 9 refusals kept the destination, 0 modes the device lacks were refused.

AI-assisted (Claude Code).

@amarovndres

Copy link
Copy Markdown

Tested c20f06b8 on AMD Radeon RX 9060 XT (RDNA4), AMD 26.10.1 (32.0.32015.7029), Windows 11 Pro (build 26200). d3d12_color_decompress_test and dxgi_swapchain_test were built from this head with MSVC (VS 2022 Build Tools, Windows SDK 10.0.26100). Pass.

  • d3d12_color_decompress: Leonida Vulkan 10/10 DECOMPRESS cases matched. The native AMD D3D12 adapter matched 9/9 and WARP 9/9, so the AMD host agrees with the reference on every case it runs.
  • dxgi_swapchain (the file this PR touches): CreateSwapChainForHwnd: 45 descriptions compared with the host runtime, 0 mismatches, then PASS (CreateSwapChain, ..., Present, ResizeBuffers; 0 validation errors). It also passes on main d974c88a built the same way.
  • Not run: the full ctest on this head (on main it is 168/169 here; the one failure is d3d12_sparse_queue_family_contract, check_sparse_queue_family: run api_dump and validation apart (TEST-1089) #4900).

AI-assisted (Claude Code). Synthetic tests only, no game files.

@memorypressure

Copy link
Copy Markdown

Verified on current main (3faac55, merges cleanly). The admission gate and replay agree: distinct resources replay as vkCmdCopyImage (samples preserved), in-place DECOMPRESS as a layout-preserving no-op with transfer dependency, restricted to same-format same-sample uncompressed TEXTURE2D with an RT-flag source, backbuffers destination-only, and in-place calls pinned to the same subresource and rectangle. test_ctest_registration, test_ci_registration, test_cmake_vulkan_missing and the docs guards all pass. The native RTX 3090/WARP probe results and the GPU test itself are hardware claims — not verifiable on this box (no GPU build). Merges clean with #4888, which also touches this area. CI was pending. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only run).

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