Skip to content

vulkan_replay: use cleared aspectMask for depth/stencil rect-clear attachment views - #7634

Open
KarolKurzyna wants to merge 1 commit into
ItsNotRexed:mainfrom
KarolKurzyna:fix/stencil-rect-clear-view-aspect
Open

KarolKurzyna wants to merge 1 commit into
ItsNotRexed:mainfrom
KarolKurzyna:fix/stencil-rect-clear-view-aspect

Conversation

@KarolKurzyna

Copy link
Copy Markdown
Contributor

Claimed in #7496 (comment) (originally observed on Intel UHD Graphics 770 in #166 (comment)).

Problem

In runtime/src/vulkan_replay.h (prepare()), ClearDepthStencil with rectangles called rect_view(..., p.binding.aspects) instead of using the cleared aspects. For a combined depth-stencil texture (D24_UNORM_S8_UINT or D32_FLOAT_S8X24_UINT), both a depth-only rectangle clear and a stencil-only rectangle clear therefore requested the same cached DEPTH | STENCIL VkImageView.

On Intel's proprietary Windows Vulkan driver (101.6129, Intel UHD Graphics 770, Vulkan 1.3.295), back-to-back depth-only then stencil-only rectangle clears sharing a combined DEPTH | STENCIL attachment view silently drop the stencil-only vkCmdClearAttachments — leaving the stencil plane at its pre-clear value across all 8 combined depth-stencil cases in d3d12_clear_formats (4 × D24_UNORM_S8_UINT and 4 × D32_FLOAT_S8X24_UINT), with 0 Vulkan validation errors.

Additionally, when !aspects (D3D-437: STENCIL on a depth-only view), p.skip = true was set but rect_view() was still called.

Fix

  1. In runtime/src/vulkan_replay.h, pass aspects (not p.binding.aspects) to rect_view() for ClearDepthStencil and skip calling rect_view() when !aspects.
  2. In runtime/test/d3d12_clear_test.cpp, add split-plane (depth-only rect followed by stencil-only rect) regression checks for DXGI_FORMAT_D24_UNORM_S8_UINT and DXGI_FORMAT_D32_FLOAT_S8X24_UINT compared against WARP.

Testing

Windows 11 x64 (10.0.26300), MSVC 19.52.37029 (VS 2026), Windows SDK 10.0.26100.0, Vulkan SDK 1.4.363.1, LEONIDA_VK_VALIDATION=1 (VK_LOADER_LAYERS_DISABLE=~implicit~), commit 69d7d53:

  • Negative control (new d3d12_clear_test against unpatched vulkan_replay.h on Intel UHD Graphics 770): FAIL on both formats (depth-stencil split-plane rect clear format 45: stencil readback differs from WARP and format 20: stencil readback differs from WARP).
  • Intel(R) UHD Graphics 770 (driver 101.6129, Vulkan 1.3.295, LEONIDA_VK_VALIDATION=1):
    • ctest -R "^(d3d12_clear|vk_command_replay|replay_clear_gate|d3d12_depth_resolve|d3d12_typeless_depth|d3d12_view_slices|d3d12_depth24_draw|d3d12_predicated_copy)$": 8/8 PASS (0 validation errors).
    • d3d12_clear_formats: depth-stencil diffs dropped from 8 → 0 (241 matched WARP vs 233 on main; only the 10 pre-existing 1-ULP sRGB diffs remain, 0 validation errors).
  • NVIDIA GeForce RTX 3070 Ti (driver 621.24, Vulkan 1.4.357, LEONIDA_VK_VALIDATION=1):
    • Same 8/8 CTest suite: 8/8 PASS (0 validation errors).
    • d3d12_clear_formats: PASS (251 matched WARP, 0 differ, 0 failed, 0 validation errors).

Synthetic tests only, no game data. AI-assisted.

prepare() passed p.binding.aspects (DEPTH | STENCIL) to rect_view() for
ClearDepthStencilView with rectangles even when clearing a single plane.
On Intel's proprietary Windows Vulkan driver (101.6129, UHD Graphics 770),
back-to-back depth-only then stencil-only rectangle clears sharing that
combined DEPTH | STENCIL attachment image view silently drop the stencil
vkCmdClearAttachments (8 of 8 combined depth-stencil cases in
d3d12_clear_formats).

Pass the actually cleared `aspects` to rect_view() so single-plane
rectangle clears use a matching single-aspect attachment view, and skip
rect_view() when !aspects (D3D-437). Add split-plane (depth-only then
stencil-only) rectangle clear regression cases for D24_UNORM_S8_UINT and
D32_FLOAT_S8X24_UINT to d3d12_clear_test.cpp.
@MartinIndra02

Copy link
Copy Markdown

Independent Windows + GPU test of 69d7d5353: pass.

Setup: Windows 11 x64, MSVC 19.44.35220 (RelWithDebInfo, Windows SDK 10.0.26100.0), NVIDIA GeForce RTX 3080 (driver 32.0.16.2124 / 621.24), Vulkan SDK 1.4.363.1, LEONIDA_VK_VALIDATION=1, no game files.

  • vk_command_replay_test.exe: PASS (exit 0, 0 validation errors).

AI-assisted review/test.

@jeangoes

Copy link
Copy Markdown

Tested 69d7d53 on Windows 11 against its merge base a779d64, on a second Intel iGPU of the same generation with a newer driver: UHD 730 (Gen12 Xe-LP, driver 101.7085), plus RTX 4060 (621.14). MSVC 14.44, Vulkan SDK 1.4.363.0, LEONIDA_VK_VALIDATION=1, 0 validation errors in every run: pass.

merge base + this PR's d3d12_clear_test.cpp (negative control) this PR
UHD 730 d3d12_clear_test pass, 234 readbacks matched WARP (both split-plane cases included) pass, 234
UHD 730 d3d12_clear_formats 241 matched, 10 differ (only the known 1-ULP sRGB ones, no depth-stencil) same
RTX 4060, all three (vk_command_replay_test too) pass; clear_formats 251/251 pass; 251/251

The driver bug doesn't reproduce on 101.7085: the new split-plane checks match WARP even with the unpatched vulkan_replay.h, and d3d12_clear_formats has no depth-stencil differences at the base (vs. 8 on your UHD 770 with 101.6129). Since 101.7085 is newer than 101.6129, Intel may have fixed it in between, so this negative control can't confirm the bug here. The fix itself is still right on its own terms (using the cleared aspects for the rect view, and not creating a view when the clear is skipped), and it changes nothing on either GPU here.

AI-assisted run.

@Ueslii

Ueslii commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested 69d7d5353991f68c5722958fa053eaa2141b1d65 on Windows 11 Pro (10.0.26200 Build 26200), AMD Ryzen 5 5500, 16 GB RAM, AMD Radeon RX 5600 XT (RDNA 1, Adrenalin / Vulkan driver 26.11.2, Windows driver 32.0.21045.29003, Vulkan 1.4.315), MSVC 19.52.37029.0 (VS 2026, Ninja RelWithDebInfo), Windows SDK 10.0.26100.0, Vulkan SDK 1.4.363.1 (synthetic inputs, no game files, LEONIDA_VK_VALIDATION=1): pass.

  • py -I scripts/check_no_game_data.py runtime/src/vulkan_replay.h runtime/test/d3d12_clear_test.cpp: exit 0.
  • cmake --build runtime\build --config RelWithDebInfo --target d3d12_clear_test d3d12_clear_formats_test: exit 0.
  • ctest --test-dir runtime/build -C RelWithDebInfo -R ^d3d12_clear --output-on-failure -V (with LEONIDA_VK_VALIDATION=1): 2/2 passed (2.63 s):
    • d3d12_clear: Passed (1.32 s) — device: AMD Radeon RX 5600 XT (validation on); 3D RTVs: 648 RGBA texels match WARP and expected slice colours; castable RTVs: 3 textures take their own and the listed format, and refuse 9 formats their lists don't name; RTV and DSV clears: 234 full/rectangle readbacks matched WARP
    • d3d12_clear_formats: Passed (1.30 s) — device: AMD Radeon RX 5600 XT (validation on); clears: 251 matched WARP, 0 differ, 0 failed, 0 in formats the layer does not expose, 0 skipped (WARP does not offer the format)

AI-assisted.

@eizispark

Copy link
Copy Markdown

Tested 69d7d53 merged onto main (5fa095b) on AMD Radeon RX 9070 XT, Adrenalin 26.11.1 (LLPC / Vulkan 1.4.359), Windows 11:

  • ctest (8/8 passed): d3d12_clear (including combined depth-stencil split-plane rectangle clear cases), d3d12_rgb9e5_rtv, d3d12_clear_formats, d3d12_uav_clear, d3d12_stencil_copy, d3d12_depth24_draw, vk_command_replay, replay_clear_gate

@CowBoYdu76

Copy link
Copy Markdown
Contributor

Tested 69d7d53 merged onto main dfe4e4a (clean merge) on Windows 11 build 26300, MSVC 19.44, Ninja RelWithDebInfo, Vulkan SDK 1.4.363.0, LEONIDA_VK_VALIDATION=1, with two GPUs picked by LEONIDA_VK_DEVICE: pass, no regression. The driver bug does not reproduce on this Intel driver, though.

RTX 4070 SUPER (NVIDIA 616.64) Intel UHD 770 (101.7092)
d3d12_clear (with the new split-plane checks) pass pass
vk_command_replay, replay_clear_gate, d3d12_typeless_depth, d3d12_view_slices pass pass
d3d12_clear_formats pass, 251 matched WARP 241 matched, 10 differ, the sRGB bytes only (the same as main; #7603)
d3d12_depth_resolve fails, the same as on main fails, the same as on main

AI-assisted (Claude Code). No game files.

@Ekabusto

Copy link
Copy Markdown

Tested 69d7d5353 on AMD Radeon RX 9070 XT (RDNA4), AMD driver 26.11.2, Windows 11 10.0.26300: pass, no
regression on AMD
.

  • d3d12_clear and d3d12_clear_formats pass. d3d12_vulkan_device fails at tiles == 1 (reserved 8x8 RGBA8
    tiling), the same assertion as on main on this card, which d3d12: GetResourceTiling splits NPOT and single-mip textures as AMD does #7149 covers. It's not from this PR.
  • Negative control: with the base's runtime/src/vulkan_replay.h, d3d12_clear still passes here. That fits your
    description: the dropped stencil clear is Intel's driver, and AMD's driver handles the shared DEPTH|STENCIL view.
    So this card confirms the fix is harmless on AMD, but it can't show the bug.

AI-assisted: yes (Claude ran the build and tests; results checked by me).

@trick-ye

Copy link
Copy Markdown

Tested 69d7d5353 merged onto main 6dda0630b on AMD Radeon RX 7800 XT (RDNA3), AMD 26.11.2 (Windows driver 32.0.32029.2010), Windows 11 26200: the new split-plane rectangle clears match WARP, and no recorded test status changed against main.

  • d3d12_clear_test, 3 of 3 direct runs exit 0: RTV and DSV clears: 234 full/rectangle readbacks matched WARP (main: 232, so the two new D24_UNORM_S8_UINT and D32_FLOAT_S8X24_UINT cases are counted and match). The log prints D24_UNORM_S8_UINT unavailable, using D32_SFLOAT_S8_UINT, so on this card both cases run on that one Vulkan format.
  • d3d12_clear_formats_test on the merge: 251 matched WARP, 0 differ, 0 failed, the same as main. That test already does a depth-only then a stencil-only rectangle clear back to back, so the sequence this PR describes for Intel already matched on this card before the change.
  • Whole suite, ctest -j 1: 274 tests, 255 pass, 13 skipped, 6 fail, on main 6dda0630b and on the merge alike (gameinput is listed as disabled and not counted). The six failures are the same in both: vk_queue_query_sync, d3d12_vulkan_device, d3d12_texture_tiles, d3d12_indirect_dispatch_count, d3d12_depth_resolve and d3d12_pipeline_library_host. No recorded test status differs; vk_command_replay, d3d12_clear, d3d12_clear_formats and d3d12_stencil_copy pass.
  • Not run with LEONIDA_VK_VALIDATION=1.
  • MSVC 14.42 (VS 2022), Windows SDK 10.0.26100, Vulkan SDK 1.4.363.0, RelWithDebInfo, LEONIDA_VK_DEVICE=7800, llvm-mc 23.1.6; the configured build completed (GameInput shim not built: no SDL3). Synthetic tests only, no game files.

AI-assisted (Claude Code).

@egexon

egexon commented Nov 23, 2026

Copy link
Copy Markdown

Tested 69d7d53 (merged onto main 867d922) on RTX 5070, NVIDIA 621.24, Windows 11, Vulkan validation layer on (LEONIDA_VK_VALIDATION=1, VK_VALIDATION_VALIDATE_SYNC=1): pass.

  • d3d12_clear: passes on main and with this PR, including the new back-to-back depth-only and stencil-only rect clears on D24_UNORM_S8_UINT and D32_FLOAT_S8X24_UINT, read back and compared with WARP.
  • The bug this fixes is on Intel's Windows driver, so on NVIDIA this is a no-regression result, not a reproduction.
  • d3d12_rgb9e5_rtv is skipped here, on main and with this PR.

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

@sgonzalez-glitch

Copy link
Copy Markdown

Tested 69d7d5353 (as part of #7619, #7634, #7653, #7667, #7704 and #7723 merged together onto main a90a79bd8) on NVIDIA GeForce RTX 2080, driver 621.24 (32.0.16.2124), Windows 11, MSVC 19.44 RelWithDebInfo: pass.

AI-assisted: yes

@BeetjeMatig

Copy link
Copy Markdown

Tested 69d7d53 (head of this PR) on RTX 5070 Ti (Blackwell, subgroup 32), NVIDIA 621.01, Windows 11, MSVC 14.44 (VS 2022 17.14 Build Tools), CMake 4.5.1 + Ninja, Vulkan headers sdk-1.4.363.0 (fetched), no game copy: pass, with a caveat.

I applied the diff to a clone of main at dfe4e4a (clean git apply), built d3d12_clear_test and ran it: exit 0, including "RTV and DSV clears: 234 full/rectangle readbacks matched WARP", which now includes the new split-plane rect clears on D24_UNORM_S8_UINT and D32_FLOAT_S8X24_UINT. Negative control: with vulkan_replay.h reverted to main and the PR's test kept, the test also passes on this GPU. The PR describes an Intel UHD 770 driver bug (101.6129), so NVIDIA does not reproduce the failure; this run shows the change is harmless here and the new cases match WARP, not that the fix works.

AI-assisted (Claude Code): checked by applying the diff to a private clone of main and building and running the tests above. No game data was used.

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.