Skip to content

d3d12_depth_resolve: a host that does not average an edge AVERAGE is a host quirk (TEST-1470) - #6053

Closed
emirduran707 wants to merge 1 commit into
ItsNotRexed:mainfrom
emirduran707:test-1470-depth-average-host-quirk
Closed

emirduran707 wants to merge 1 commit into
ItsNotRexed:mainfrom
emirduran707:test-1470-depth-average-host-quirk

Conversation

@emirduran707

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: TEST-1470 (claim), from my finding.

Depends on: none.

What and why

d3d12_depth_resolve fails on unchanged main 561b65a8 on an AMD Radeon RX 9060 XT: the six edge AVERAGE depth resolves (D32 as R32_FLOAT, D24S8 as R24_X8, D32S8 as R32_X8X24; whole and rectangle) report "layer and host differ".

The cause is the host, not the layer. With a local printout of the differing texels (not in this PR), every one of them is a pixel on the triangle's edge, and the two sides give:

Pixel (rect 0, D32) Host D3D12 Layer
(7,0), (0,5) 0.5 0.375
(5,1), (1,4) 0.5 0.4375
(6,1), (2,4) 0.5 0.3125
(4,2), (3,3) 0.5 0.625

The clears are 0.25 to 0.75 and the triangle is drawn at 0.5, so the layer's values are means over four samples (one, two or three of them the triangle's). The host returns the triangle's 0.5 everywhere: one sample's value, not a mean. 8 of 48 texels differ for the whole subresource and 5 of 48 for the rectangle, the same pixels in all three formats (D24S8: 0x800000 against 0x500000 to 0x9fffff).

The test had no way to tell that apart from a layer bug, because the edge cases have no CPU model. This PR adds one that needs no coverage model: an AVERAGE over samples that differ lies strictly between their MIN and MAX, and the test already resolves the same edge case by MIN and by MAX.

  • The layer is now checked on its own: its edge AVERAGE must be strictly between its MIN and MAX in every pixel where those differ. This holds whatever the host does, so it also runs where there is no host.
  • The host: when its edge AVERAGE differs from the layer's, and its MIN and MAX equal the layer's, and its own AVERAGE is not strictly between its own MIN and MAX at some pixel where those differ, that is reported as a host quirk (counted with the others) instead of a failure. If the host does average and still differs from the layer, the test fails as before.

docs/d3d12_vulkan.md (the depth resolve paragraph) records the rule and the measurement.

Tested

AMD Radeon RX 9060 XT (RDNA4), driver 26.10.44, Windows 11, MSVC (VS 2022), LEONIDA_VK_DEVICE=9060. Synthetic clears and one triangle; no game files.

  • Before, main 561b65a8: d3d12_depth_resolve fails, 57 of 97 match, 18 host quirks, six AVERAGE lines with "layer and host differ". Against WARP: 71 of 71.
  • After, 73014cd9: passes, 4 of 4 runs, one of them with LEONIDA_VK_VALIDATION=1 (no VUID line). 57 of 97 match, 24 host quirks, 7 refusals alike; the six new lines read host quirk: the host's AVERAGE is strictly between its own MIN and MAX in 0 of the 8 pixels whose samples differ; the layer's is in all of them (0 of the 5 for the rectangle). Against WARP: 71 of 71, unchanged.
  • Negative control: with the layer check given the layer's MIN in place of its AVERAGE (one argument changed, then restored), the test fails with the layer's AVERAGE is strictly between its MIN and MAX in 0 of the 8 pixels whose samples differ for each case.
  • python -m unittest discover -s tests -p "test_docs*.py": 33 tests, OK. git diff --check: clean.

Not tested:

  • The branch where a host does average but still differs from the layer (it should fail as before): no such host here. On a Radeon 610M (AMD 26.11.2) and an RTX 5070 Ti the test already passed on main per @Etr0p's data point, so the new host branch is not reached there; a run on NVIDIA or Intel would confirm nothing changed for them.
  • Whether the RX 9060 XT's behaviour is the driver version (26.10.44) or RDNA4.
  • The rest of ctest: only this test was rebuilt and run. On this card main also fails d3d12_texture_tiles, d3d12_indirect_dispatch_count and d3d12_pipeline_library_host (D3D-597, D3D-594, D3D-600), which this PR does not touch.

AI-assisted: yes (Claude Code)

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. (Not a translator change.)

🤖 Generated with Claude Code

…a host quirk (TEST-1470)

On an RX 9060 XT (AMD 26.10.44) the six edge AVERAGE depth resolves failed
against the host: its D3D12 returns the triangle's depth, 0.5, for every
pixel on the edge, where the layer returns 0.3125 to 0.625 by how many of
the four samples the triangle covers.

The layer's AVERAGE of an edge case is now checked on its own: strictly
between its MIN and MAX in every pixel whose samples differ. A host whose
own AVERAGE is not, while its MIN and MAX equal the layer's, is reported
as a host quirk instead of a failure.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@Etr0p

Etr0p commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Regression check of 73014cd9 on hosts where the new rule shouldn't fire: pass, identical to main. Windows 11 26200, MSVC 14.44 RelWithDebInfo, Vulkan SDK 1.4.363.0. Layer and host on the same GPU (LEONIDA_VK_DEVICE), LEONIDA_VK_VALIDATION=0 and 1 each:

  • RTX 5070 Ti Laptop (NVIDIA 621.24): 97 of 97 match, 0 host quirks, 7 refusals alike; WARP 71 of 71.
  • Radeon 610M (RDNA2, AMD 26.11.2): 49 of 83 match, 18 host quirks, 7 refusals alike; WARP 57 of 57. The 18 quirks are the MIN/MAX resolves main already reports, and no AVERAGE resolve differs here (see my TEST-1470 data point in Coordinating who works on what (34) (moved to #6089) #5934).

So nothing that passed is now classified differently on RDNA2 or NVIDIA. AI-assisted (Claude Code).

@emirduran707

Copy link
Copy Markdown
Contributor Author

Comparison with #6091, with the result that was still missing: I ran #6091 (81b9611e) on the card the finding is from. AMD Radeon RX 9060 XT (RDNA4), driver 26.10.44, Windows 11, MSVC (VS 2022), LEONIDA_VK_DEVICE=9060.

Both PRs make the test pass on this card.

main 561b65a8 #6053 73014cd9 #6091 81b9611e
d3d12_depth_resolve fails, 6 AVERAGE lines passes, 4 of 4 runs (one with validation) passes, 4 of 4 runs (one with validation)
against the RX 9060 XT 57 of 97, 18 quirks 57 of 97, 24 quirks 57 of 97, 24 quirks
against WARP 71 of 71 71 of 71 71 of 71
the six cases are reported as failure host quirk: the host's AVERAGE is strictly between its own MIN and MAX in 0 of the 8 pixels whose samples differ; the layer's is in all of them differs from the layer (AMD host quirk)

One thing #6091's run shows that mine did not: with WARP's edge AVERAGE compared for real, WARP still matches 71 of 71 here, so on this machine the layer's edge AVERAGE equals WARP's byte for byte. That is a stronger statement about the layer than my check makes.

How they differ, from reading both diffs (not from a run that tells them apart; I did not inject faults into #6091):

#6053 #6091
When is a host AVERAGE difference a quirk? when the host's own AVERAGE is not strictly between its own MIN and MAX where those differ, and its MIN and MAX equal the layer's when the host adapter's VendorId is 0x1002
A host of any vendor that does not average classified fails, unless it is AMD
An AMD host that averages but differs from the layer fails reported as a quirk; the WARP comparison is what would catch a layer bug
What is checked about the layer's AVERAGE it is a mean: strictly between its own MIN and MAX where they differ. No host or WARP needed it equals WARP's, byte for byte. Needs WARP, and is the stronger check where WARP is there
WARP edge AVERAGE reported only, as on main a hard comparison
Files the test and docs/d3d12_vulkan.md the test

So they are not the same fix twice: mine decides "host quirk" from what the host returned, #6091 decides it from who made the host and adds a real reference for the layer. They conflict textually, but the two ideas fit together: the behaviour-based classification from here plus #6091's WARP comparison would give both.

I'm fine with whichever the maintainer or coordinator prefers:

I won't change this PR until one is chosen. For the record on order: my claim is here, #6091's is here.

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

@memorypressure

Copy link
Copy Markdown

Static review (the runtime test needs a GPU this CPU-only verifier cannot give it) against main 561b65a: the quirk path is sound — Planes defaults close to E_FAIL at line 89 so it cannot fire on skipped host resolves, the pre-existing "edge MIN and MAX must differ" invariant keeps the layer's strictly-between check non-vacuous, and feature-unsupported/WARP skips fall through to the ordinary comparison. The quirk fires only when the host's own AVERAGE equals its own MIN or MAX at a pixel where they differ while its MIN/MAX are byte-equal to the layer's — a host-attributed deviation, correctly reported rather than tolerated blanket-wide. Docs paragraph matches the code. Checks pending — the GPU legs are the remaining evidence. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only review).

@Halfect

Halfect commented Nov 23, 2026

Copy link
Copy Markdown

Thanks @emirduran707 — I updated #6091 to dfcfc15dd with the combined approach you suggested: your behavior-based host rule and layer AVERAGE invariant, plus this PR's strict WARP AVERAGE comparison. You are credited in the PR body.

Local NVIDIA and gfx1036 runs pass, and fault injection confirms that an averaging-but-different host still fails while a non-averaging host is classified without consulting vendor ID. The integrated head still needs RDNA4 verification; your RX 9060 XT measurements are cited as coming from this PR, not claimed as a local reproduction.

@emirduran707

Copy link
Copy Markdown
Contributor Author

Closing this in favour of #6091.

@Halfect folded this PR's two ideas into #6091 at dfcfc15d, with credit: the layer's edge AVERAGE checked as a mean on its own, and a host classified as a quirk by what it returned (its own AVERAGE not strictly between its own MIN and MAX) instead of by vendor. #6091 also keeps its hard WARP comparison for edge AVERAGE, which this PR does not have. So #6091 now does everything this one does, and the two conflict in d3d12_depth_resolve_test.cpp, so only one could land anyway.

I ran dfcfc15d on the card the finding is from (AMD Radeon RX 9060 XT, driver 26.10.44): passes, 4 of 4 runs, the six cases reported as host quirks by behaviour. Result: #6091 (comment)

Nothing from this branch is needed beyond what #6091 already took. Thanks to everyone who tested it here.

AI-assisted (Claude Code).

@Bhrema

Bhrema commented Nov 23, 2026

Copy link
Copy Markdown

Tested 73014cd9eb on AMD Radeon RX 6750 XT, driver 32.0.21045.16010, Windows 11 25H2 (10.0.26200), VS 18 Community, Vulkan SDK 1.4.363.1: pass.

Built with scripts\build_runtime.ps1 (RelWithDebInfo). Ran runtime\build\d3d12_depth_resolve_test.exe.

device: AMD Radeon RX 6750 XT
subgroup sizes: 32..64 (default 64)
Vulkan resolve modes: depth 0xd, stencil 0xd
depth/stencil resolves against AMD Radeon RX 6750 XT: 49 of 83 match, 18 host quirks, 7 refusals alike
depth/stencil resolves against WARP: 57 of 57 match, 0 host quirks, 7 refusals alike
depth/stencil resolves: 106 host comparisons matched, 12 refusals kept the destination, 14 modes the device lacks were refused; 20 edge MIN/MAX pairs differ
d3d12_depth_resolve_test: exit 0

Host quirks are reported for MIN/MAX (and edge pairs as information); the test no longer fails the run for host AVERAGE/edge differences. AI-assisted.

@shipped-it

Copy link
Copy Markdown

Tested 73014cd9eb8 on Linux (Arch): clang-cl 23.1.3 + xwin SDK 10.0.26100 cross-build — BUILD clean. Full ctest (245) under Wine 11.20/Xvfb on RX 7900 XTX/RADV: 226 passed; the 19 failures are all the known headless-env set (WARP-vs-RADV readback diffs, no-Vulkan-device-under-Wine, gameinput_host, present/swapchain), none in files this PR touches. Targeted test d3d12_depth_resolve: PASSED. VERDICT: pass. AI-assisted (omp coding assistant).

@caltr98

caltr98 commented Nov 23, 2026

Copy link
Copy Markdown

Tested 73014cd on NVIDIA GeForce RTX 5080 Laptop GPU, driver 621.14, Windows 11 (build 26300), MSVC 14.44, RelWithDebInfo: pass. d3d12_depth_resolve passes. AI-assisted.

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