Skip to content

Runtime: support shifted depth and stencil resolves - #4745

Open
gabrielsteglich wants to merge 1 commit into
ItsNotRexed:mainfrom
gabrielsteglich:feat/offset-depth-stencil-resolve
Open

gabrielsteglich wants to merge 1 commit into
ItsNotRexed:mainfrom
gabrielsteglich:feat/offset-depth-stencil-resolve

Conversation

@gabrielsteglich

Copy link
Copy Markdown
Contributor

Claimed in coordination issue #4683.

Depends on: #3977, #3019

The branch is based directly on main. #3977 overlaps in vulkan_replay.h. #3019 already conflicts with main and changes the same replay paths.

What and why

ResolveSubresourceRegion can now write a depth or stencil rectangle to a different origin in a same-format 2D texture. Replay resolves the selected plane into a single-sample temporary image at the source coordinates, then copies only that rectangle to the destination. This preserves the surrounding texels and other plane.

The command queue keeps temporaries alive until submitted work is complete. The D3D12 entry point checks source and destination mip bounds. Enhanced barriers with SYNC_RESOLVE cover the final Vulkan copy.

Tested

Commit 68a33c75 on Windows 11 Pro build 26300, NVIDIA GeForce RTX 3090 with driver 621.01, MSVC 19.44.35229, Windows SDK 10.0.26100.0, Vulkan SDK 1.4.363.0, RelWithDebInfo. Vulkan synchronization validation was enabled with LEONIDA_VK_VALIDATION=1.

  • Base 98fa503f returned E_INVALIDARG at Close for all 11 shifted cases in the new fixture. The patch passes all 11, covering 13 shifted copies, rectangle edges, overlapping writes with Enhanced Barriers, and consecutive submissions on one DIRECT queue. Nine negative cases preserve the destination.
  • All 36 eligible WARP comparisons matched. The fixture independently checks both destination planes against the expected values. It matched 27 native RTX 3090 comparisons and recorded 15 host differences, including the D24S8 stencil behavior.
  • The focused D3D12 and CPU replay tests passed 2/2 with zero Vulkan validation errors. The API trace recorded 13 shifted copies and four reuses of a temporary image after an intervening submit and semaphore wait.
  • Full runtime suite: 158 passed, eight skipped, one disabled, zero failures. The base suite had 157 passed with the same skips and disabled test. Documentation links, CTest registration, CI registration, and the no-game-data check passed.

AI-assisted: yes. Independently reviewed before submission.

Checklist

  • No game data, keys or decryption. Tests use synthetic images.

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

Built and ran both tests at 68a33c756 on Windows 11, RTX 5070 Ti:

  • d3d12_depth_resolve_test -> exit 0: 42 of 42 match against the NVIDIA host, 36 of 36 match against WARP, 5 refusals alike; 11 shifted cases matched the clears, 78 host comparisons matched, 9 refusals kept the destination.
  • replay_depth_resolve_offset_test -> exit 0: intermediate failures and stencil-only copy verified.

Shifted depth and stencil resolves are now replayed with the correct offsets through vulkan_replay.h/vulkan_backend.h, and the two tests cover the shifted rects, the host comparisons, refusals and the stencil-only copy. git diff --check clean. No blocking issue.

@Atomic258

Copy link
Copy Markdown

Tested 68a33c75 on Windows 11, NVIDIA GeForce RTX 5090 (driver 617.42), MSVC 19.44, Vulkan SDK 1.4.363, RelWithDebInfo. Vulkan synchronization validation enabled via LEONIDA_VK_VALIDATION=1 for the depth-resolve run.

  • d3d12_depth_resolve_test -> exit 0: 42 of 42 match vs NVIDIA host, 36 of 36 match vs WARP, 5 refusals alike; 11 shifted cases matched the clears, 78 host comparisons matched, 9 refusals kept the destination.
  • replay_depth_resolve_offset_test (new target, registered in runtime/CMakeLists.txt) -> exit 0: intermediate failures and stencil-only copy verified.
  • Regression pass over tests sharing vulkan_replay.h/vulkan_backend.h: replay_copy_offset_test, replay_readback_stages_test, replay_clear_gate_test, replay_write_immediate_predication_test, replay_uav_clear_offset_test, replay_query_predication_test, replay_query_edges_test, depth24_convert_test, vk_command_replay_test, typeless_rtv_test, d3d12_state_map_test -> all exit 0.
  • git diff --check clean.

No blocking issue. AI-assisted.

@justr4mzi

Copy link
Copy Markdown
Contributor

Verified commit 68a33c75 locally on Windows 11 x64 (AMD Radeon RX 6700 XT, driver 26.11.2, RelWithDebInfo):

  • Built d3d12_depth_resolve_test.exe and replay_depth_resolve_offset_test.exe ([13/13]).
  • ctest --test-dir build --output-on-failure -R "^(d3d12_depth_resolve|replay_depth_resolve_offset)$" -V:
    • Standard: 2/2 passed (1.35 sec real: d3d12_depth_resolve 1.20 sec, replay_depth_resolve_offset 0.13 sec).
    • LEONIDA_VK_VALIDATION=1: 2/2 passed (1.05 sec real: d3d12_depth_resolve 1.02 sec, replay_depth_resolve_offset 0.02 sec, 0 validation errors).
  • AMD RDNA2 (RX 6700 XT) details from d3d12_depth_resolve_test.exe (VAL=1, exit 0):
    • Vulkan resolve modes: depth 0xd, stencil 0xd (no AVERAGE support; exercises D24_UNORM_S8_UINT unavailable, using D32_SFLOAT_S8_UINT; format 45/44 fallback).
    • depth/stencil resolves against AMD Radeon RX 6700 XT: 21 of 35 match, 14 host quirks, 5 refusals alike (layer matches clears on the D24S8 cases where AMD D3D12 host differs).
    • depth/stencil resolves against WARP: 29 of 29 match, 0 host quirks, 5 refusals alike.
    • Summary: 9 shifted cases matched the clears, 50 host comparisons matched, 9 refusals kept the destination, 7 modes the device lacks were refused.
  • Direct replay_depth_resolve_offset_test.exe (VAL=1): exit 0 (depth/stencil resolve offset: intermediate failures and stencil-only copy verified).
  • Repo checks: tests/test_ctest_registration.py (4/4 in 0.862s), tests/test_docs_*.py (30/30 in 34.380s), scripts/check_no_game_data.py exit 0, and git diff --check exit 0.

Reviewed runtime/shims/d3d12_vulkan_device.cpp, runtime/src/vulkan_backend.h, runtime/src/vulkan_replay.h, runtime/test/d3d12_depth_resolve_test.cpp, runtime/test/replay_depth_resolve_offset_test.cpp, runtime/CMakeLists.txt, and docs/d3d12_vulkan.md; looks solid.

AI-assisted (Gemini, Antigravity).

@tupacfan04

Copy link
Copy Markdown
Contributor

PASS. MSVC build of the new and existing depth-resolve tests; replay_depth_resolve_offset passes, and d3d12_depth_resolve_test on the RTX 5070 passes 42/42 host and 36/36 WARP comparisons (including the 11 shifted cases). The 13 related CTests, docs tests (30), CTest/CI registration, compileall, check_no_game_data and git diff --check pass. Negative control: zeroing srcOffset in the copy fails the new test. Merge clean.

One non-blocking cost: the temporary image is full-mip-sized even for a small source rectangle (runtime/src/vulkan_replay.h:2673 passed to runtime/src/vulkan_backend.h:2238), so a tiny shifted resolve on a large target allocates a full-size image. Correct, but potentially expensive.

Approve. AI-assisted review, no game files, no game data.

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.

5 participants