Skip to content

d3d12: reject integer formats in plain resolves (D3D-274) - #2112

Merged
ItsNotRexed merged 1 commit into
ItsNotRexed:mainfrom
SirKingg:tpd1h81-deere-leonida-integer-resolve-fix
Nov 22, 2026
Merged

ItsNotRexed merged 1 commit into
ItsNotRexed:mainfrom
SirKingg:tpd1h81-deere-leonida-integer-resolve-fix

Conversation

@SirKingg

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: D3D-274 (claim)

What and why

Plain ResolveSubresource ignored its format argument and could send an integer colour image to vkCmdResolveImage. Reject an integer requested format or integer colour source/destination at recording, so Close fails. Reuse the existing Vulkan numeric-class classification, including SINT formats; keep non-integer and depth recording behavior unchanged.

Synthetic regression cases cover UINT, SINT, an integer resource requested as UNORM, UNORM/FLOAT controls, and depth recording. The existing GPU resolve comparison covers actual non-integer output. This is limited to plain resolves: #1914 separately changes the regional resolve helper and format mappings. The two heads merge cleanly; this PR does not depend on #1914.

AI-assisted (GitHub Copilot).

Tested

Windows, NVIDIA GeForce RTX 4070 Ti, driver 32.0.16.1088; MSVC 14.44 and Ninja. No game files.

  • cmake --build runtime\build --target d3d12_vulkan_device_test d3d12_draw_test d3d12_depth_resolve_test d3d12_com_test d3d12_typeless_rtv_test — passed.
  • ctest --test-dir runtime\build --output-on-failure -R "^d3d12_(vulkan_device|draw|depth_resolve|com|typeless_rtv)$" — 4 passed; d3d12_draw failed on the bundle blend pixel (127,0,127,255, expected red 64), identically on baseline 4eb6155d.
  • ctest --test-dir runtime\build -V -R "^d3d12_vulkan_device$" — passed; 9 new format cases, none skipped, and 60 existing resolve comparisons matched.
  • Baseline 4eb6155d with the initial regression cases and without the fix: all five tested integer cases incorrectly returned S_OK instead of E_INVALIDARG; the UNORM and FLOAT controls passed.

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 rule is introduced.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@Ingenioeren

Copy link
Copy Markdown

Independent Radeon check of 849f4b7 on an RX 6750 XT (RDNA2), AMD 26.11.2 (32.0.21045.29003), Vulkan 1.4.315, Windows 11 build 26200, and MSVC 19.43. I applied #2030 in both builds for Windows SDK 10.0.26100.0 compatibility. Vulkan validation was enabled.

  • On 4eb6155d with only this PR’s regression test added, all six invalid cases reached Close and returned S_OK.
  • On this PR, all nine plain-resolve cases passed with zero skips. The broader Vulkan device test matched the native D3D12 results in all 60 compared resolve cases, with 10 unsupported or host-unavailable cases skipped. d3d12_depth_resolve also passed.

Synthetic inputs only. AI-assisted verification.

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

Code & Hardware Verification Review (D3D-274 / PR #2112)

Verdict: Approve ✅

Environment & Toolchain

  • AI-Assisted: Yes
  • OS: Windows 11 Pro x64 (Build 26100)
  • Compiler: MSVC 2022 Community (cl.exe v19.44.35225.0, vcvars64)
  • Build System: CMake 4.4 + Ninja 1.13 (-DCMAKE_BUILD_TYPE=RelWithDebInfo -DLEONIDA_VULKAN_HEADERS_FETCH=ON)
  • GPU: NVIDIA GeForce RTX 2070 SUPER (8192 MB VRAM, Vulkan 1.4, Driver 595.79)
  • Clean-Room Policy: Verified without game files or private dumps.

Verification Results

  1. Python Syntax Check:

    • python -m compileall -q make_game.py tools tests -> PASS (exit code 0)
  2. Compilation & Linkage:

    • cmake --build runtime/build --target d3d12_vulkan_device_test d3d12_depth_resolve_test d3d12_com_test d3d12_typeless_rtv_test -> PASS (17/17 targets built and linked cleanly)
  3. CTest Suite (GPU / Vulkan Targets):

    • Command: ctest --test-dir runtime/build --output-on-failure -R "^d3d12_(vulkan_device|depth_resolve|com|typeless_rtv)$"
    • Result: 4/4 passed (100% pass rate, 13.85s real time)
      • d3d12_com: Passed (0.25s) — 16 colour, depth, and stencil texels matched; queue wait held the GPU.
      • d3d12_vulkan_device: Passed (7.95s) — 9 plain resolve format cases tested (0 unsupported skipped, 0 mismatches); 60 resolve comparisons matched; logged expected note: ResolveSubresource refused: integer colour formats cannot be resolved.
      • d3d12_typeless_rtv: Passed (3.80s) — 1730 WARP readbacks matched, 27 unsupported/invalid views rejected.
      • d3d12_depth_resolve: Passed (1.33s) — 45 host comparisons matched, 9 refusals kept the destination.
    • Note on LEONIDA_VK_VALIDATION=1: On this runner VK_LAYER_KHRONOS_validation explicit layer manifest is not installed in the system registry, so the runtime fails fast as designed when the layer is requested. Tests ran and passed directly on the physical NVIDIA driver runtime.

Code Analysis & Contract Conformance

  • Vulkan / D3D12 Contract Alignment: Vulkan vkCmdResolveImage forbids integer format images (Neither srcImage nor dstImage can have an integer format). In D3D12, ResolveSubresource rejects typed integer formats. Refusing integer resolves at command list recording time and causing Close() to return E_INVALIDARG complies with the D3D12 contract and prevents invalid Vulkan API usage.
  • DRY Implementation: Reusing DeviceState::numeric_class(vulkan_format(format, false).format) != 0 via helper color_resolve_format_is_integer directly aligns the recording check with CheckFeatureSupport, which already stripped D3D12_FORMAT_SUPPORT1_MULTISAMPLE_RESOLVE for integer formats.
  • Resource & Format Guarding: Inspecting integer_color(dst) and integer_color(src) alongside the requested format closes potential bypasses where resources are integer-typed but requested as non-integer/typeless.
  • Depth/Stencil Isolation: The check explicitly guards against false positives on depth/stencil targets (!(desc.Flags & D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL)), ensuring existing depth resolves are unaffected.
  • Documentation: docs/d3d12_vulkan.md is updated accurately to state that integer colour formats in the requested format or either resource are refused at recording and fail Close().

LGTM! All contracts pass cleanly.

@airp1ane

Copy link
Copy Markdown
Contributor

Tested 849f4b7 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).

@Koro4e

Koro4e commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Tested 849f4b7 on NVIDIA GeForce RTX 3060 (driver 617.14), Windows 11 26200.9457, MSVC 14.44 RelWithDebInfo: pass. The full d3d12_vulkan_device ctest entry passed (10.5 s), including the new integer-resolve refusals and the successful float resolves beside them.

@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 & Code Audit: PR #2112 (D3D-274)

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

  • GPU: NVIDIA GeForce RTX 2070 SUPER (8192 MB VRAM, Turing TU104, Compute Capability 7.5)
  • Driver: NVIDIA Game Ready / Studio 595.79 (Vulkan 1.4.304 / 1.4.363)
  • Validation Layers: Khronos Validation Layer active (LEONIDA_VK_VALIDATION=1)
  • Environment: Clean-room with synthetic test harnesses (zero game assets)

Test Execution & Results

Both runtime targets compiled and passed 100%:

Test Target Duration Status Vulkan Validation Errors
d3d12_vulkan_device 41.25s PASSED 0 errors
d3d12_depth_resolve 1.64s PASSED 0 errors

Verified Behavior

  • Plain Resolve Rejection: Verified that integer color formats (R8G8B8A8_UINT, R8G8B8A8_SINT, R32_UINT, R32_SINT, R32G32B32A32_SINT) are refused during command list recording (ResolveSubresource refused: integer colour formats cannot be resolved), correctly causing Close() to return E_INVALIDARG.
  • Typeless / Alias Protection: Combinations of integer resources requested as UNORM are properly rejected.
  • Host Parity: 60/60 resolve comparisons matched byte-for-byte with the native host D3D12 on the RTX 2070 SUPER.
  • Depth/Stencil Parity: 45 host comparisons in d3d12_depth_resolve_test matched with 0 regressions.

LGTM. Complies with both D3D12 resolve semantics and Vulkan vkCmdResolveImage constraints. Ready to merge.

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

@JRamos1993

Copy link
Copy Markdown
Contributor

Tested 849f4b7, merged onto main 4947579 (no conflicts), on an RTX 5090 (driver 616.92), Windows 11, MSVC 19.44, Vulkan SDK 1.4.363, fresh RelWithDebInfo build:

  • d3d12_vulkan_device: passes 20 of 20 runs, and passes under LEONIDA_VK_VALIDATION=1 with 0 validation messages.
  • Full ctest: 125/125. No new /W4 warnings.

AI-assisted (Claude Code).

@ItsNotRexed
ItsNotRexed merged commit 6f77e39 into ItsNotRexed:main Nov 22, 2026
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