Skip to content

d3d12_depth_resolve_test: read the destination back in a valid list after a refused call - #8828

Closed
ersinhf wants to merge 2 commits into
ProjectLeonida:mainfrom
ersinhf:d3d12-depth-resolve-refused-list
Closed

ersinhf wants to merge 2 commits into
ProjectLeonida:mainfrom
ersinhf:d3d12-depth-resolve-refused-list

Conversation

@ersinhf

@ersinhf ersinhf commented Nov 23, 2026

Copy link
Copy Markdown

What

runtime/test/d3d12_depth_resolve_test.cpp fails its eight refused cases on NVIDIA (Ada): refused D24S8 depth AVERAGE rect 1: Close 0x80070057, destination changed and seven siblings.

#6610 refuses a whole batch when a list's recording failed (runtime/shims/d3d12_com.cpp:1549-1555, ExecuteCommandLists: list N is invalid; refusing batch). The refused loop executed its invalid list and then expected the destination to hold the clear values, which was true only while the layer replayed an invalid list. Now nothing of that list runs — neither the clears nor the readback copy — so the readback stays zero: the stencil plane reads 0x00 where the test wants the clear's 0x5a. Depth matched by coincidence (0.0), which is why the message said "destination changed" without saying where.

Measured with a temporary print in the test (reverted before this commit): all eight cases had depth identical to the expectation and stencil as the only mismatch, and each run carried list 0 is invalid; refusing batch.

Change

Clear the source and the destination in a valid list, put the refused call in the invalid one, and read the destination back in a third valid list. The check still proves that executing a refused list leaves the destination at the clear values, and no longer depends on the readback buffer's initial contents or on replaying an invalid list.

Tested

No game files were used, and nothing from the package is quoted.

Claim: #8683 (comment) (new item). Behaviour relied on: #6610, merged.

AI-assisted: written with DeepSeek V4.1 Flash in an OpenCode session. Every number, log line and command above comes from a real run on the machine named in it.

@smowlyy

smowlyy commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Verified head 4ed299c66 merged onto main (867d922f0) on native Windows 11 (10.0.26300.9974, MSVC 19.44, RelWithDebInfo, Vulkan SDK 1.4.363.0):

  • python -I scripts/check_no_game_data.py runtime/test/d3d12_depth_resolve_test.cpp: clean (exit 0)
  • cmake --build runtime/build --target d3d12_depth_resolve_test --parallel: built cleanly
  • LEONIDA_VK_VALIDATION=1 .\runtime\build\d3d12_depth_resolve_test.exe on NVIDIA GeForce RTX 5060 Ti (driver 610.88, Vulkan 1.4.341): passed with 0 validation errors (97 of 97 match against HW, 71 of 71 match against WARP; 168 host comparisons matched, 12 refusals kept the destination)

AI-assisted.

…fter a refused call

#6610 refuses the whole batch of a list whose Close failed, so executing the invalid list in the refused loop ran nothing: the readback stayed zero and the stencil plane read 0x00 where the test wanted the clear's 0x5a (depth happened to match).

Clear and read back in valid lists of their own, and keep only the refused call in the invalid one, so the check still proves that executing the refused list leaves the destination at the clear values.
@ersinhf
ersinhf force-pushed the d3d12-depth-resolve-refused-list branch from 4ed299c to e556bee Compare November 23, 2026 19:41
@ersinhf

ersinhf commented Nov 23, 2026

Copy link
Copy Markdown
Author

Rebased onto main 867d922f (60 commits since the first head) and reran: d3d12_depth_resolve_test.exe exits 0, with 145 host comparisons matched, 12 refusals kept the destination, 0 modes the device lacks were refused; 20 edge MIN/MAX pairs differ and depth/stencil resolves against WARP: 71 of 71 match.

The test file did not conflict; runtime/shims/d3d12_com.cpp gained 75 lines in that range and the test still passes on the new base.

AI-assisted: written with DeepSeek V4.1 Flash in an OpenCode session. Every number above comes from a real run on the RTX 4070 / NVIDIA 621.14 / Windows 11 26200 machine.

@awab128

awab128 commented Nov 23, 2026

Copy link
Copy Markdown

Tested e556bee4 (current head, on main 867d922f) on NVIDIA GeForce RTX 4060 Laptop GPU (Ada, subgroup 32), NVIDIA 621.35 (32.0.16.2135), Windows 11 10.0.26300, MSVC 14.44 (VS 2022 17.14 Build Tools), Visual Studio 17 2022 generator, Vulkan SDK 1.4.363.0: pass.

  • main 867d922f: d3d12_depth_resolve_test.exe exits 1 (74 of 97 match, 15 host quirks, 7 refusals alike against the GPU, 71 of 71 against WARP).
  • This PR's head, only the d3d12_depth_resolve_test target rebuilt: exits 0, with 145 host comparisons matched, 12 refusals kept the destination, 0 modes the device lacks were refused; 20 edge MIN/MAX pairs differ. The host comparison lines are unchanged from main (74 of 97 match, 15 host quirks, 7 refusals alike; WARP 71 of 71 match).

The 15 host quirks are the D24S8/D32S8 stencil MIN/MAX and depth AVERAGE cases where the NVIDIA driver differs from the clears and the layer matches them, the same set as on the RTX 4070 in #8720.

Full ctest on main 867d922f on this machine: 260 of 262 pass; the two failures are d3d12_vulkan_device (#8496) and d3d12_depth_resolve (this PR). No game files involved (LEONIDA_GAME_DIR unset).

AI-assisted (Claude Code).

@BeetjeMatig

Copy link
Copy Markdown

Tested e556bee 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), SPIRV-Tools 2026.4, no game copy: pass.

I applied the diff (runtime/test/d3d12_depth_resolve_test.cpp) to a build of main at dfe4e4a, rebuilt only d3d12_depth_resolve_test and ran it. On main the test fails here with the eight refused resolves reporting "Close 0x80070057, destination changed" (D24S8 depth AVERAGE rect 1, D24S8 stencil AVERAGE rect 0, and six more), the same list as #8720. With this PR it exits 0: 51 of 51 resolves match the host on the RTX 5070 Ti with 0 host quirks and 7 refusals alike, 37 of 37 match against WARP, and the summary line reads "88 host comparisons matched, 12 refusals kept the destination, 0 edge MIN/MAX pairs differ". The edge cases were skipped because glslangValidator was not available at build time.

I also ran #7905 and #7930 the same way and they give the same result here, so all three fix the same failure; it is worth picking one and closing the others.

AI-assisted (Claude Code): built and ran the test as described above. No game data was used.

@CrashOverride1010

Copy link
Copy Markdown

Tested on Windows 11 x64 with an NVIDIA GeForce RTX 5070 Ti (driver 617.42), MSVC 14.44, RelWithDebInfo: this PR's change to runtime/test/d3d12_depth_resolve_test.cpp (head e556bee4b) applied on main at 867d922.

  • Without it: d3d12_depth_resolve_test exits 1, with eight refused … Close 0x80070057, destination changed lines (all eight refused cases).
  • With it: exits 0. 97 of 97 resolves match the RTX 5070 Ti and 71 of 71 match WARP; 168 host comparisons matched, 12 refusals kept the destination.

For comparison: #7930 and #7905 also keep the destination check and pass here with the same counts; #9066 passes too, but stops comparing the destination.

AI-assisted test run (Claude Code).

@LewisStephens99

Copy link
Copy Markdown

Tested e556bee4b merged onto main 5d74c2723 on NVIDIA GeForce RTX 3080 (Ampere, subgroup 32), NVIDIA 616.92 (32.0.16.1692), Windows 11 10.0.26200, MSVC 14.44 (VS 2022 Build Tools), Ninja RelWithDebInfo, Vulkan SDK 1.4.363.0: pass. First Ampere result here.

  • main 5d74c2723 alone: d3d12_depth_resolve_test.exe exits 1 in 2 of 2 runs, with all eight refused … Close 0x80070057, destination changed lines (57 of 97 match, 24 host quirks, 7 refusals alike against the GPU, 71 of 71 against WARP).
  • With this PR merged (only the d3d12_depth_resolve_test target rebuilt): exits 0 in 3 of 3 runs, no destination changed lines: 128 host comparisons matched, 12 refusals kept the destination, 0 modes the device lacks were refused; 20 edge MIN/MAX pairs differ; WARP 71 of 71.
  • Again with LEONIDA_VK_VALIDATION=1: exit 0, no validation messages.
  • python -I scripts/check_no_game_data.py runtime/test/d3d12_depth_resolve_test.cpp: clean.

The 24 host quirks are the RTX 3080's own D3D12 driver differing from the clears (the layer matches them), more than the 15 reported on the 4060 Laptop; they don't affect the result.

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

@JaumeMarRib

Copy link
Copy Markdown

Tested e556bee on an RTX 5070 (NVIDIA 621.24, Windows 11 26100) on top of main 867d922: passes, with and without LEONIDA_VK_VALIDATION=1. Same as the runs above, so I won't repeat the numbers.

One thing I noticed reading the diff, though. The layer's own loop over cases also calls resolve_and_read(..., true, ...) for resolves that succeed (line 473). For those the second list does run, so the target ends up in RESOLVE_DEST, but the readback barrier still declares StateBefore = DEPTH_WRITE, because line 235 sets it whenever run_invalid is true. It doesn't show up in the results or in validation, probably because the layer tracks the real state on its own, but the barrier is wrong as written. Closing the resolve list before recording the readback barrier and picking StateBefore from that result (RESOLVE_DEST if it closed fine, DEPTH_WRITE if it was refused) would fix it. #7930 avoids it by putting the transitions to the resolve states in the first list.

@4usphs

4usphs commented Nov 23, 2026

Copy link
Copy Markdown

Tested on AMD Radeon RX 9070 XT (RDNA4, gfx1201), Adrenalin 26.11.2 (32.0.32029.2010), Windows 11 26200, MSVC (VS 2022 Build Tools). Head e556bee applied onto current main 867d922.

Built with scripts\build_runtime.ps1, ran ctest --test-dir runtime/build. No game files involved. AI-assisted (Claude Code).

…om the resolve list's Close

run_invalid is also used for resolves that succeed (the layer's own loop), so the split path must close the resolve list before the readback barrier is recorded and choose StateBefore from that result: RESOLVE_DEST when it closed, DEPTH_WRITE when the batch was refused and the clears in the first list stand.

Spotted in review by @JaumeMarRib on #8828.
@ersinhf

ersinhf commented Nov 23, 2026

Copy link
Copy Markdown
Author

You are right, and it is fixed in 0e2880165 (pushed on this branch). run_invalid is also what the layer's own loop passes for resolves that succeed, so the readback barrier could not take its source state from the parameter at all.

What the split path does now:

  • The resolve list is closed before the readback barrier is recorded, and StateBefore comes from that result: RESOLVE_DEST when it closed (the resolve ran), DEPTH_WRITE when its Close failed (the batch is refused as a whole, so the destination is still where the clears in the first list left it).
  • The refusal executes as its own batch first and the readback list second, so a refused list cannot take the readback down with it.
  • The single-list path (run_invalid false) keeps closing after the copies, unchanged.

Rerun on RTX 4070 / NVIDIA 621.14 / Windows 11 26200: d3d12_depth_resolve_test.exe exits 0, 145 host comparisons matched, 12 refusals kept the destination, 0 modes the device lacks were refused; 20 edge MIN/MAX pairs differ, WARP 71 of 71 match. Full ctest on this build: the test passes; the two failures are d3d12_vulkan_device (#8496's cause) and crt_timed_wait, which passes when run alone (load flake).

Same for the barrier in the successful cases, so the declared state now matches what ran. Thanks for reading the diff — that one would have stayed wrong while every test passed.

AI-assisted: written with DeepSeek V4.1 Flash in an OpenCode session. Every number above comes from a real run on the machine named in it.

@ersinhf

ersinhf commented Nov 23, 2026

Copy link
Copy Markdown
Author

Closing this as a duplicate — I should have found the earlier PRs before claiming it, and that is on me.

The same test, the same #6610 follow-up, five PRs on runtime/test/d3d12_depth_resolve_test.cpp:

PR opened shape
#7905 17:45 refused resolves checked against a destination cleared in its own list, +68/−34
#7930 17:48 the refused resolve read through a list of its own, +56/−24
#8415 18:40 keeps #7905 and adds the zero-filled readback / D32 canary, +76/−40
#9066 20:05 do not compare the destination of a refused list at all, +10/−7
#8828 (this) 19:35 three lists: clears / refused resolve / readback, +49/−9

So this is the second-newest of five, not a new fix. Per the repository's own rule the older PR wins and this one should close; the choice between #7905/#8415 and #9066 is the maintainers' and o-psi's to make (#8415 is the one described as the consolidation point).

One thing worth carrying over, because it cost a review round here and applies to every variant that splits the lists: run_invalid is also passed for resolves that succeed (the layer's own loop), so a readback barrier cannot take StateBefore = DEPTH_WRITE from that parameter. Either close the resolve list before recording the readback barrier and pick RESOLVE_DEST when it closed (0e2880165 here), or put the transitions to the resolve states in the first list, as #7930 does.

Thanks to everyone who ran it: smowlyy (RTX 5060 Ti), awab128 (4060 Laptop), BeetjeMatig and CrashOverride1010 (5070 Ti), LewisStephens99 (3080), JaumeMarRib (5070) and 4usphs (RX 9070 XT). Their checks are worth more on the PR that lands — #7905, #7930 and #8415 already have their own runs, and re-posting a line there is cheap if the maintainer asks for a specific card.

AI-assisted: written with DeepSeek V4.1 Flash in an OpenCode session.

@moistman7

Copy link
Copy Markdown

Tested merged onto main 867d922 (clean), Windows 11 Pro 26200, MSVC (VS Build Tools 2022), Vulkan SDK 1.4.363: fixes d3d12_depth_resolve on two more GPUs, including a non-NVIDIA one.

  • NVIDIA GeForce RTX 5090, driver 617.42: on 867d922 it fails 3/3, the same eight refused cases you describe (refused D24S8 depth AVERAGE rect 1: Close 0x80070057, destination changed and siblings, each with list 0 is invalid; refusing batch). With this PR it passes 3/3.
  • AMD Radeon iGPU of a Ryzen 7 9800X3D (gfx1036), AMD driver 2026.04.17: the same eight cases fail on 867d922, 3/3. With this PR it passes 3/3. Summary there: 106 host comparisons matched, 12 refusals kept the destination, 14 modes the device lacks were refused; 20 edge MIN/MAX pairs differ (49 of 83 match, 18 host quirks, 7 refusals alike against the AMD device, 57 of 57 against WARP).

Also merged with #8496, #7256, #7475 and #6149 (as a patch) in the same tree, with no conflicts; vk_queue_query_sync, d3d12_vulkan_device and d3d12_mesh still pass on both GPUs with all five in.

AI-assisted (Claude Code)

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.

9 participants