Skip to content

d3d12: CheckFeatureSupport answers the queries the host answers with zeros (D3D round 4c) - #4612

Open
kapitche wants to merge 3 commits into
ItsNotRexed:mainfrom
kapitche:kap-d3d4-c
Open

kapitche wants to merge 3 commits into
ItsNotRexed:mainfrom
kapitche:kap-d3d4-c

Conversation

@kapitche

Copy link
Copy Markdown
Contributor

Claimed in #4421 (D3D round 4c): #4421 (comment)

What broke: ID3D12Device::CheckFeatureSupport answered E_INVALIDARG for four feature values the host runtime answers. Repro: CheckFeatureSupport(static_cast<D3D12_FEATURE>(54), &data, 4) (D3D12_FEATURE_TIGHT_ALIGNMENT in the Agility SDK) returned 0x80070057; the RTX 4080 SUPER, the Intel UHD 770 and WARP all return S_OK with a zero payload (tier NOT_SUPPORTED). Values 17, 55 and 58 are in no header this repository builds against; the same three adapters answer them with all-zero payloads of 4, 24 and 4 bytes and refuse every other size.

Fix: the layer answers the four with those sizes and zeros (d3d12_feature_compat.h holds the values, beside 56 and 57); any other size is still E_INVALIDARG. Nothing here claims a capability: zero is NOT_SUPPORTED/FALSE for the documented one and the host's own answer for the others.

Test: new d3d12_feature_query_test (ctest d3d12_feature_query) asks every D3D12_FEATURE value from 0 to 80 for the smallest size the device accepts and for the HRESULT at sizes 0, size-4, size-1, size+1, size+4 and 2*size+8, on the layer and on both host adapters, and compares the payload of the queries every adapter answers the same way. A query counts only where both host adapters agree. Left out: OPTIONS (feature 0; #4026 makes the layer accept the console's larger structure), OPTIONS6 and OPTIONS10 (#469), FORMAT_SUPPORT, FORMAT_INFO and MULTISAMPLE_QUALITY_LEVELS (a description, not a size; Etoile-Bleu's sweep in #4421), and the per-adapter tiers.

Tested: Windows 11, MSVC 14.51, worktree built from this commit. d3d12_feature_query (71 features compared on the RTX 4080 SUPER, 73 on the Intel UHD 770 with VK_LOADER_DRIVERS_DISABLE=*nv*), d3d12_com and d3d12_vulkan_device pass on both. Negative control: with d3d12_vulkan_device.cpp and d3d12_feature_compat.h from upstream/main the test fails on both GPUs, 4 features differing (17, 54, 55, 58).

Touches d3d12_vulkan_device.cpp next to the existing 56/57 cases (a different place from #4026's OPTIONS case) and adds one block to runtime/CMakeLists.txt before the debug-markers test.

AI-assisted.

@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 d3d12_feature_query_test at 40cca935 on Windows 11, RTX 5070 Ti: exit 0 — feature queries: 71 features compared with 2 host adapters, 0 differ.

The layer logs the queries it answers with zeros (CheckFeatureSupport feature 74 through 80 on this device) and every compared answer matches the hardware and WARP hosts. The new d3d12_feature_compat.h keeps the queried feature list in one place. git diff --check clean. No blocking issue.

@shdann

shdann commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

The new test passes if feature 54 stops writing its output. I reproduced this at 40cca935 on an RTX 4090 and AMD Radeon Graphics.

  1. In d3d12_vulkan_device.cpp, remove only the assignment to SupportTier in the kFeatureTightAlignment case. Keep the size check and the S_OK return.
  2. Run cmake --build build --config RelWithDebInfo --target d3d12_feature_query_test.
  3. Run build/RelWithDebInfo/d3d12_feature_query_test.exe.

Expected: The test detects the missing output write. Actual: The test exits 0. It reports 71 matching features on NVIDIA and 72 on AMD. The buffer in ask already contains the expected zero.

I also called CheckFeatureSupport(static_cast<D3D12_FEATURE>(54), &tier, sizeof(tier)) with uint32_t tier = 0xa5a5a5a5u; for each device. The modified shim returns S_OK and leaves tier at 0xa5a5a5a5. Native NVIDIA, AMD and WARP return S_OK and write 0. Use a nonzero initial value for this output-only field so the test checks the write.

AI-assisted.

@rgvxsthi

Copy link
Copy Markdown
Contributor

Tested 40cca935 (already contains main d0835dd9) on AMD Radeon RX 9070 (RDNA4), AMD 26.11.2 (LLPC), Windows 11 Pro 10.0.26300, MSVC 14.44.35207, Windows SDK 10.0.26100, Vulkan SDK 1.4.363.0: pass.

  • d3d12_feature_query_test: 72 features compared with 2 host adapters, 0 differ (hosts: the RX 9070 and WARP), exit 0.
  • LEONIDA_PROBE=1, the rows this PR adds: 17 → layer 4 / host 4, 54 → 4 / 4, 55 → 24 / 24, 58 → 4 / 4 (56 and 57 unchanged, 4 / 4). Features 34, 50 and 52 are skipped because the two host adapters disagree with each other, as the test intends.
  • Built in a clean worktree with -DLEONIDA_REQUIRE_VULKAN=ON, Ninja, RelWithDebInfo.

Read the diff as well: the four new cases refuse every other size with E_INVALIDARG and write zeros only, so nothing claims a capability. No game files. AI-assisted (Claude Code).

@kapitche

Copy link
Copy Markdown
Contributor Author

Reproduced: with the SupportTier assignment removed from the feature 54 case, the test at 40cca93 still reported 0 differ on the RTX 4080 SUPER (70 features compared) and the Intel UHD 770 (72), because the buffer was zero-filled before every call.

Pushed b97506d: after the normal measurement, each query is asked again on a buffer filled with 0xA5, and the bytes are kept. For the payload features, where every host writes the whole payload whatever the buffer held (its 0xA5 run equals its zero-filled run), the layer's 0xA5 run must equal the host's bytes. I did not poison every feature: with a blanket poison, feature 17 fails on the host when its input is 0xA5 (the layer accepts it), and feature 55 leaves its input fields untouched on the host (12 bytes stay 0xA5), so those two are not output-only and the poisoned run is skipped for them. Feature 54, which the host writes in full, is checked.

Ran on Windows 11, MSVC 14.51, only d3d12_feature_query_test: unmodified head of the PR plus this commit, 0 differ on both GPUs (70 / 72 features). With only the SupportTier = 0 assignment removed (size check and S_OK kept): feature 54 differs and the test exits 1 on both the RTX 4080 SUPER and the Intel UHD 770. The old test with the same removal reported 0 differ.

…zeros (D3D round 4c)

Features 17, 54 (TIGHT_ALIGNMENT), 55 and 58 are answered by the host on the RTX 4080 SUPER, the UHD 770 and WARP with all-zero payloads of 4, 4, 24 and 4 bytes; the layer refused them with E_INVALIDARG. d3d12_feature_query sweeps every feature value and the sizes around each structure against both host adapters.
@Atomic258

Copy link
Copy Markdown
Contributor

Tested head b97506d3 — Windows, VS 2022 BuildTools + Ninja, NVIDIA RTX 5090 (driver 617.42) + AMD iGPU host reference, no game files: the PR's own new test fails here.

  • cmake --build runtime/build: clean; d3d12_feature_query registers as ctest GPU test results on GCN3 (RADV, native wave64), llvmpipe and Intel Gen9; build.py rejects every shader with LLVM 19 #88.
  • ctest -R d3d12_feature_query: feature queries: 71 features compared with 2 host adapters, 2 differ.
    • feature 17: both sides return E_INVALIDARG (hr 80070057), size 4 — but the layer wrote 00 00 00 00 into the output while the host left the 0xA5 fill untouched.
    • feature 55: same shape, size 24 — host buffer keeps its 0xA5 bytes (middle 12 bytes zeroed only), layer zeroed all 24.
    • Both host adapters agree the untouched-on-reject contract; the head commit message says the test should fail exactly when a query "stops writing its output" — so on this hardware the layer still writes zeros on the rejected paths for features 17 and 55.
  • Full ctest at this head: everything else passes; only the usual environmental skips (no LEONIDA_SHADERS/package/movie, vk_sync_validation, d3d12_first_light, rgb9e5_rtv — adapter lacks RGB9E5 RTVs). No other regressions.
  • git diff --check and scripts/check_no_game_data.py clean.

AI-assisted (Devin).

@rgvxsthi

Copy link
Copy Markdown
Contributor

Re-tested the new head b97506d3 (no merge with main) on AMD Radeon RX 9070 (RDNA4), AMD 26.11.2 (LLPC), Windows 11 Pro 10.0.26300, MSVC 14.44.35207, Windows SDK 10.0.26100, Vulkan SDK 1.4.363.0: fails here, the same way as @Atomic258's RTX 5090.

feature 17: layer size 4 (hr 80070057 00000000 80070057 80070057 80070057 80070057), host size 4 (hr 80070057 00000000 80070057 80070057 80070057 80070057)
feature 55: layer size 24 (hr 80070057 80070057 80070057 80070057 80070057 80070057), host size 24 (hr 80070057 80070057 80070057 80070057 80070057 80070057)
feature queries: 72 features compared with 2 host adapters, 2 differ

The HRESULTs match on both features, so the difference is in the bytes (host adapters: the RX 9070 and WARP). So with an AMD and an NVIDIA RTX 5090 failing and the RTX 4080 SUPER / UHD 770 passing, it looks like the host's handling of 17 and 55 on a poisoned buffer differs by machine, as with colour space 27 in #4610, rather than being layer-specific. My earlier pass on this PR was at 40cca935, before the poisoned-buffer check. No game files. AI-assisted (Claude Code).

@kapitche

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (one conflict in d3d12_feature_compat.h, both sides kept). After the rebase the poisoned-buffer re-query failed on features 17 and 55, whose payloads have input fields the host reads, so those two are now re-queried from a zeroed buffer instead of the 0xA5 fill. Every other feature still gets the poisoned buffer, so feature 54 is still covered.

Windows 11, MSVC 14.51, only d3d12_feature_query_test: 0 differ on the RTX 4080 SUPER (70 features) and on the Intel UHD 770 (72). Negative control: with the SupportTier assignment removed it reports 1 differ on both GPUs.

@rgvxsthi

Copy link
Copy Markdown
Contributor

Re-tested the rebased head 0e35ce48 (no merge with main) on AMD Radeon RX 9070 (RDNA4), AMD 26.11.2 (LLPC), Windows 11 Pro 10.0.26300, MSVC 14.44.35207, Windows SDK 10.0.26100, Vulkan SDK 1.4.363.0: pass.

  • d3d12_feature_query_test: 72 features compared with 2 host adapters, 0 differ, exit 0 (hosts: the RX 9070 and WARP).

The features 17 and 55 differences I reported at b97506d3 are gone with them read from a zeroed buffer. No game files. AI-assisted (Claude Code).

@nakebx

nakebx commented Nov 23, 2026

Copy link
Copy Markdown

Tested 0e35ce4 on NVIDIA GeForce RTX 3070 (Ampere), driver 610.88, Windows 11 Pro 10.0.26200: pass

  • ctest with LEONIDA_VK_VALIDATION=1: 100% tests passed, 0 failed out of 164
  • d3d12_feature_query_test run directly with the same setting: exit 0, "feature queries: 71 features compared with 2 host adapters, 0 differ"

Built with MSVC through scripts\build_runtime.ps1, Vulkan SDK 1.4.363.0. DISABLE_RTSS_LAYER=1 and DISABLE_VULKAN_OBS_CAPTURE=1 were set. Run with an AI-assisted script; the numbers are copied from the tool output.

@sh1shu1

sh1shu1 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested 0e35ce4 on NVIDIA RTX 4070 SUPER (driver 616.92), Windows 11 26200, MSVC 14.44, Vulkan SDK 1.4.363, RelWithDebInfo: pass, no regression against main 7b7d73f.

  • ctest: 170/172 passed; dxgi_device, dxgi_swapchain fails on main 7b7d73f too (not from this PR), same 9 skips as main 7b7d73f
  • d3d12_feature_query: 1/1
  • run_gpu_tests (LEONIDA_VK_VALIDATION=1): 170/217 native, 201/217 with LEONIDA_W64_EMULATE=1, 0 failed; identical to main 7b7d73f
    AI-assisted (Claude Code, Claude Fable 5.1).

@memorypressure

Copy link
Copy Markdown

Verified on Linux against main 3faac55: merges cleanly, compileall clean, and the CMake/CTest guards pass on the merged tree. The new C++ test cannot be built here, so the host-comparison claims (all-zero feature queries 17/55/58, tight-alignment tier 0 on the cited adapters) are unverified by design — the pending windows/linux-gpu-tools checks carry the verdict. Combines cleanly with sibling rounds #4609/#4610 (verified together). AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only review).

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.

8 participants