Skip to content

Tests: seven host comparisons take their hardware reference on the layer's own adapter (LEONIDA_HOST_ADAPTER was ignored) - #2910

Merged
ItsNotRexed merged 3 commits into
ItsNotRexed:mainfrom
zzEmmazz:tests-host-reference-on-layer-adapter
Nov 23, 2026
Merged

ItsNotRexed merged 3 commits into
ItsNotRexed:mainfrom
zzEmmazz:tests-host-reference-on-layer-adapter

Conversation

@zzEmmazz

@zzEmmazz zzEmmazz commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

New TEST item, claimed in the coordination issue: #2716 (comment)

What and why

Seven tests compare the layer with Windows D3D12 on a hardware adapter and on WARP, and created the hardware reference with D3D12CreateDevice(nullptr, ...): d3d12_copy_xfmt, d3d12_depth_resolve, d3d12_fence_events, d3d12_indirect_zero, d3d12_node_mask, d3d12_query_rules and d3d12_resource_desc. That is D3D12's default adapter, and none of them read LEONIDA_HOST_ADAPTER, which docs/testing.md says picks the host side.

On a PC with two GPUs the layer then runs on one GPU and the host driver on the other. #1785 fixed this for d3d12_vulkan_device; these seven still had it.

runtime/test/host_adapter.h picks the adapter by the rule d3d12_copy_compare.h follows:

  1. the adapter LEONIDA_HOST_ADAPTER names (part of its name, without case). A name that matches no adapter fails the run. warp leaves the hardware pass out, since these tests always compare with WARP as well;
  2. else the adapter behind the layer's Vulkan device (VkPhysicalDeviceIDProperties::deviceLUID);
  3. else the default adapter, as before (no LUID, or no D3D12 device on that adapter).

The tests print the adapter's name where they printed "the default adapter". On a PC with one GPU nothing else changes. docs/d3d12_vulkan.md says which tests pick the host side through which header.

Not changed: d3d12_fence_timing asks for a NUMA host on purpose, d3d12_buffer_tiles looks for any adapter with tiled resources tier 2, and d3d12_bundle says in its header that it does not read LEONIDA_HOST_ADAPTER.

Review follow-up: explicit selections

The two reported edge cases are fixed in the shared helpers. The environment getter now resizes and retries when the value does not fit its buffer, and copycmp::create_host() uses that same getter to distinguish explicit selection. An explicitly named adapter also passes the null-output D3D12 availability probe before it is returned; failure releases the adapter and ends the run, matching the copy-comparison path.

A new Windows CPU CTest, host_adapter, checks the real Win32 getter with unset, empty, mixed-case, 127-, 128- and 300-character values. Two subprocess cases check fatal failure for a long nonexistent selection and for an enumerated named adapter whose stubbed D3D12 probe fails. The probe checks its adapter, feature level, interface ID and null output. DXGI enumerates a real adapter; no D3D12 device is created and no GPU commands run.

On Windows 11, MSVC 19.50.35717, Vulkan headers 1.4.363.0: the CPU test and CTest registration pass (8 checks, CTest 1/1). The 128/300-character reads and both fatal-path checks failed before the header fix. All seven affected test translation units compile with the updated helper; test_ctest_registration.py, test_docs_repo_paths.py and git diff --check pass. The hardware test results below are earlier adapter-routing validation; the full GPU suite was not repeated for this follow-up.

Measured

Ryzen 7 9700X iGPU (RDNA2, AMD 32.0.21042.62, Vulkan driver 2.0.353) next to an RTX 3070 (NVIDIA 610.74), which is the default adapter. Windows 11, MSVC 14.50 (VS 2026). The "before" lines are from main 49475796; everything else was run again after rebasing onto ec8ec4c9.

d3d12_depth_resolve, hardware pass:

layer host before host after result
Radeon RTX 3070 Radeon 17 of 26 match and 9 host quirks both times, but four quirks change: before, "D24S8 stencil as X24_G8" MIN/MAX (whole and rectangle), which are NVIDIA's; after, "D24S8 depth" MIN/MAX, which are the Radeon driver's
RTX 3070 RTX 3070 RTX 3070 19 of 31 match, 12 host quirks, unchanged

Before the change LEONIDA_HOST_ADAPTER=radeon gave the same lines as leaving it unset, with the layer on either GPU. After it, LEONIDA_VK_DEVICE=3070 LEONIDA_HOST_ADAPTER=radeon reports 22 of 31 and 9 host quirks against the Radeon.

Host quirks per driver, from those runs (the host differs from the clears, the layer matches them): both have D24S8 stencil MIN/MAX and "R24G8_TYPELESS stencil as D24S8" MAX; NVIDIA adds "stencil as X24_G8" MIN/MAX and "depth as R24_X8" AVERAGE; AMD adds D24S8 depth MIN/MAX. The comment in the test named only NVIDIA's rectangle resolves and now says this.

The other six tests print the same results against either adapter on this PC, apart from the adapter's name.

Tested

  • The seven tests, layer on each GPU, with LEONIDA_HOST_ADAPTER unset, naming the other GPU, and warp: 35 runs, all exit 0, each naming the adapter asked for. LEONIDA_HOST_ADAPTER=nosuchgpu: all seven exit 1 with no such adapter.
  • ctest -j 4 with LEONIDA_VK_DEVICE=radeon and with LEONIDA_VK_DEVICE=3070, on ec8ec4c9 plus this commit: 129 of 129 pass on each.
  • python -I tests/test_docs_repo_paths.py, test_docs_links.py, test_docs_list_items.py, test_ctest_registration.py: OK.

No game files. Not tested under Wine or on Linux.

AI-assisted.

…yer's own adapter

d3d12_copy_xfmt, d3d12_depth_resolve, d3d12_fence_events, d3d12_indirect_zero,
d3d12_node_mask, d3d12_query_rules and d3d12_resource_desc created their hardware
reference with D3D12CreateDevice(nullptr), the default adapter, and did not read
LEONIDA_HOST_ADAPTER. On a PC with two GPUs the layer then ran on one GPU and the
host driver on the other.

runtime/test/host_adapter.h picks the adapter by the rule d3d12_copy_compare.h
already follows for d3d12_vulkan_device: the adapter LEONIDA_HOST_ADAPTER names
(a name that matches none fails the run; "warp" leaves the hardware pass out),
else the adapter behind the Vulkan device (deviceLUID), else the default adapter.
The tests print the adapter's name instead of "the default adapter".

Measured on a Ryzen 7 9700X iGPU (AMD 32.0.21042.62) next to an RTX 3070
(NVIDIA 610.74, the default adapter): d3d12_depth_resolve with the layer on the
Radeon set aside nine resolves as host quirks before and after, but four of them
were NVIDIA's ("D24S8 stencil as X24_G8"); against the Radeon's own driver the
four are D24S8 depth MIN/MAX. The other six tests print the same results against
either adapter.

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

Copy link
Copy Markdown
Contributor

Code read of 839e14dc (I didn't build it). hostadapter::reference looks right:

  • LEONIDA_HOST_ADAPTER picks by case-insensitive substring and exits on a typo instead of silently passing. warp skips only the hardware pass.
  • Unset, it enumerates the adapter by the Vulkan device's deviceLUID and checks with a null-device D3D12CreateDevice that D3D12 can use it. Non-matching candidates are released, and every other case falls back to the default adapter as before.

That fixes the two-GPU case the comment measures, where the layer ran on one GPU and the "host" reference on the other. All seven tests now print the adapter actually used.

Since the header says copycmp::create_host applies "the same rule", one implementation calling the other (or both sharing this header) would keep the two from drifting apart the next time the selection rule changes.

AI-assisted review (Claude Code).

@hidrogenone

Copy link
Copy Markdown
Contributor

Tested 839e14dc on NVIDIA GeForce RTX 5080 (Blackwell; driver 32.0.16.2124, Windows 11, Vulkan SDK 1.4.357.0). Build: VS 2026 (MSVC 19.51), Windows SDK 10.0.26100, Ninja RelWithDebInfo.

All seven host-comparison tests pass (ctest, 7/7):

d3d12_fence_events ...... Passed
d3d12_depth_resolve ..... Passed
d3d12_resource_desc ..... Passed
d3d12_node_mask ......... Passed
d3d12_indirect_zero ..... Passed
d3d12_copy_xfmt ......... Passed
d3d12_query_rules ....... Passed

Single-GPU machine, so the host reference and the layer resolve to the same RTX 5080 — this confirms the change doesn't regress the host comparisons on an NVIDIA single-adapter setup. AI-assisted.

…me match from host_adapter.h

Review of ItsNotRexed#2910: host_adapter.h said it follows the same rule as
d3d12_copy_compare.h, with the variable read and the adapter name matched in
both. hostadapter::wanted() and hostadapter::named() now do that once, and
copycmp::try_create_host calls them, so the two cannot come to read the
variable differently.

No change in behaviour: d3d12_vulkan_device, d3d12_buffer_uav, d3d12_shader_cache
and d3d12_stencil_copy give the same exit codes as main with the variable unset,
naming either GPU in any case, "warp" and a name that matches nothing.

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

Copy link
Copy Markdown
Contributor Author

@tupacfan04 thanks, done in 91d26fba: hostadapter::wanted() reads LEONIDA_HOST_ADAPTER and hostadapter::named() matches the adapter name, and copycmp::try_create_host now calls both instead of its own copy. The LUID and WARP branches and the device creation through the System32 d3d12.dll stay in d3d12_copy_compare.h, since only that header needs them.

No change in behaviour: with the variable unset, naming either GPU (also as RaDeOn), warp and a name that matches nothing, d3d12_vulkan_device, d3d12_buffer_uav, d3d12_shader_cache and d3d12_stencil_copy give the same exit codes as main 77444fa0, and the seven tests of this PR behave as before. ctest -j 4: 129 of 129 on the Ryzen 7 9700X iGPU and on the RTX 3070.

One thing I saw on the way, the same on main: LEONIDA_VK_DEVICE=radeon LEONIDA_HOST_ADAPTER=3070 d3d12_vulkan_device_test fails with invalid arguments format 67 RT: ours 0x00000000, host 0x80070057. That is the Radeon layer against the NVIDIA host on purpose, so I left it alone.

@hidrogenone thanks for the RTX 5080 run.

@aguedou-34

Copy link
Copy Markdown

Tested 839e14dc1e83e4d30a18cb8bd5fb3f5b6361b367 on Windows 11 with an RTX 3070 Laptop (591.59) and Ryzen 7 5800H Radeon iGPU (31.0.21921.1000), with Vulkan validation enabled.

  • Auto-selection used the Vulkan adapter as the native D3D12 reference. The parent ec8ec4c9 used the default RTX even with Vulkan on the Radeon and LEONIDA_HOST_ADAPTER=radeon.
  • The seven tests passed with the RTX as the host reference and in WARP-only mode. With the Radeon as host, only d3d12_query_rules failed, on either Vulkan GPU. A native probe confirmed CopyQueueTimestampQueriesSupported=FALSE and E_INVALIDARG for CreateQueryHeap(COPY_QUEUE_TIMESTAMP). The layer created the heap successfully.
  • An unknown 127-character adapter name failed with no such adapter. At 128 characters, d3d12_resource_desc silently selected the RTX and passed.

Synthetic inputs only. Tested with assistance from OpenAI Codex.

@ICUMADETHIS

Copy link
Copy Markdown
Contributor

Tested 91d26fba on top of main 77444fa0 (Windows 11 26300, RTX 2080 Ti on 621.14, MSVC 14.44, single GPU): pass, and ctest -j 4 is 121/121.

I ran everything that picks a host adapter with LEONIDA_HOST_ADAPTER unset, 2080, RTX, warp and nosuchgpu. The seven tests now fail on the typo (on main they passed silently). d3d12_vulkan_device, d3d12_shader_cache and d3d12_stencil_copy behave the same as on main after the switch to hostadapter::named(). With nothing set, the output matches main apart from the adapter name; d3d12_depth_resolve gives 19 of 31 and 12 host quirks on both.

One small thing: if the name matches an adapter with no D3D12 device, copycmp fails the run, but the seven tests just skip their hardware pass. Checking D3D12CreateDevice(found, ..., nullptr) in reference() before returning the named adapter, like the LUID branch already does, would line them up.

AI-assisted.

@2-CD

2-CD commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Windows + GPU check: RTX 5080 + RTX 3070 Ti (NVIDIA 621.01) + AMD Radeon iGPU (Ryzen 9 9950X3D, driver 32.0.13018.6), Windows 11, MSVC RelWithDebInfo/Ninja, CMake 4.4.5, glslang 16.6.0, spirv-tools v2026.4, llvm-mc via scripts/build_llvm_mc.ps1. Tested head 91d26fb. A three-GPU machine - exactly the multi-adapter case this PR targets.

  • Clean build, 0 errors.
  • Adapter matrix over the seven tests: layer=default host=auto 7/7; layer=3070 Ti host=auto (LUID) 7/7; layer=iGPU host=auto (LUID) 7/7; layer=3070 Ti host=Radeon 7/7; host=warp 7/7; LEONIDA_HOST_ADAPTER=nosuchgpu: all seven exit 1 with no such adapter as intended.
  • -V spot check with LEONIDA_VK_DEVICE=3070 LEONIDA_HOST_ADAPTER=Radeon: the layer prints device: NVIDIA GeForce RTX 3070 Ti and every host comparison line names against AMD Radeon(TM) Graphics - the host reference follows the requested adapter, not the default. The Radeon host quirks shown (D24S8 depth/stencil MIN/MAX) match the AMD quirks in your Measured section.
  • Full ctest -C RelWithDebInfo -j 6: 117/117 on the RTX 5080 and 117/117 on the iGPU (the four window-showing present/swapchain tests excluded from the loops).
  • Heads-up on overlap: this PR edits runtime/test/d3d12_depth_resolve_test.cpp at the host-adapter creation; Wait 30 s for the depth resolve fence, not 5 s, so parallel GPU tests… #2916 edits the fence wait at :155 of the same file. Different regions - no textual conflict expected whichever merges first.
  • The PR's unstable CI state did not reproduce locally; every run green.

Synthetic fixtures only, no game files. AI-assisted (opencode); runs on my machine.

@FaKL-Code

Copy link
Copy Markdown
Contributor

Tested 91d26fb (merged onto main 77444fa) on NVIDIA GeForce RTX 4060 Ti, driver 610.88 (32.0.16.1088), Windows 11 26200, MSVC 14.51.36231 (VS 2026), Vulkan SDK 1.4.363.0: pass

  • Merges cleanly; no new compiler warnings against main.
  • ctest: 120 of 120 pass (same 8 skips as main). The seven edited tests (d3d12_copy_xfmt, d3d12_depth_resolve, d3d12_fence_events, d3d12_indirect_zero, d3d12_node_mask, d3d12_query_rules, d3d12_resource_desc) all pass with LEONIDA_HOST_ADAPTER unset.
  • Loader test passes; validation run: 48 tests clean (2 skipped, as on main).
  • d3d12_resource_desc_test by hand with LEONIDA_HOST_ADAPTER:
    • warp: hardware pass skipped, only "resource desc against WARP: 26 of 26 descriptions match", exit 0.
    • nvidia: compares against "NVIDIA GeForce RTX 4060 Ti" then WARP, 26 of 26 match in both, exit 0.
    • nosuchgpu: prints LEONIDA_HOST_ADAPTER=nosuchgpu: no such adapter and exits 1.

AI-assisted (Claude).

@zzEmmazz

Copy link
Copy Markdown
Contributor Author

Addressed both outstanding edge cases in db6749c.

  • The long-selector case now resizes and retries the real environment read, and copycmp::create_host() uses the shared getter for its explicit-selection check. A 300-character nonexistent name fails instead of silently selecting or skipping a default reference.
  • The named adapter availability case now runs the same null-output FL11_0 D3D12 probe as the LUID path; failure releases the adapter and exits 1 with the same diagnostic as copycmp.

New Windows CPU regression: six real Win32 environment cases (unset, empty, mixed case, 127/128/300 characters) and two subprocess fatal paths. The named-adapter case enumerates a real DXGI adapter but stubs device creation and verifies the exact availability-probe arguments. All eight checks and CTest host_adapter pass; the original headers fail the 128/300-character cases and both fatal paths. All seven consumer C++ files compile cleanly. MSVC 19.50.35717, Windows 11, Vulkan headers 1.4.363.0; no D3D12 device or GPU commands, no game files.

The PR description distinguishes this CPU follow-up from the earlier hardware comparison results. AI-assisted (Codex).

dev-ewann pushed a commit to dev-ewann/Leonida that referenced this pull request Nov 22, 2026
@kacper-serewis

Copy link
Copy Markdown
Contributor

Rechecked db6749c vs 91d26fb. All eight Windows CPU controls passed. The parent lost both 128- and 300-character values, accepted a long nonexistent selector, and returned the unavailable named adapter without probing. Head preserved both strings and rejected both failures; the named selection made exactly one FL11_0 probe with null output. The real DXGI enumeration included an RTX 5070; D3D12 creation was stubbed. AI-assisted.

@evilclanker9000

Copy link
Copy Markdown
Contributor

Tested db6749c on Windows 11 (MSVC BuildTools 2022, Ninja, RelWithDebInfo, -j 4; no Vulkan validation layer installed), one GPU at a time, device line confirmed: AMD Radeon RDNA2 iGPU (driver 26.10.1) and NVIDIA RTX 5080 (driver 616.92). Ran ctest -R "^(d3d12_copy_xfmt|d3d12_depth_resolve|d3d12_fence_events|d3d12_indirect_zero|d3d12_node_mask|d3d12_query_rules|d3d12_resource_desc|host_adapter)$" (the tests this PR adds/changes): pass on both GPUs, 8/8 each. No game files.

AI-assisted.

@kapitche

Copy link
Copy Markdown
Contributor

Tested db6749c merged with main 98fa503 (merged tree b6546df22c) on Windows 11, RTX 4080 SUPER + Intel UHD 770 (MSVC 14.51): pass. Full runtime build from the merged tree.

  • ctest -R "host_adapter|d3d12_copy|d3d12_depth24|d3d12_buffer_uav|d3d12_stencil_copy|queue_proxy|d3d12_vulkan_device": 7/7 pass on NVIDIA and 7/7 on Intel (the layer's device each time). host_adapter itself passes in 0.1 s on both.
  • With LEONIDA_HOST_ADAPTER set to NVIDIA, Intel or warp, d3d12_copy_xfmt|d3d12_depth24|host_adapter pass 3/3 each. With nosuchgpu one of the three fails, as the header comment promises (no silent pass).
  • Control: main's host_adapter.h and d3d12_copy_compare.h with the PR's host_adapter_test: that test fails (0/1).

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.