Skip to content

d3d12: query sweep against the host, and two answers it found the layer got wrong - #4533

Open
Etoile-Bleu wants to merge 1 commit into
ItsNotRexed:mainfrom
Etoile-Bleu:d3d-query-sweep
Open

Etoile-Bleu wants to merge 1 commit into
ItsNotRexed:mainfrom
Etoile-Bleu:d3d-query-sweep

Conversation

@Etoile-Bleu

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: a new D3D item, claim

What and why

d3d12_query_sweep_test asks the Vulkan-backed device and Windows D3D12 (the layer's adapter and WARP) the same questions over all 192 DXGI formats and over grids of texture descriptions: FORMAT_SUPPORT, FORMAT_INFO, MULTISAMPLE_QUALITY_LEVELS, GetResourceAllocationInfo and GetCopyableFootprints. An answer counts only where the hardware adapter and WARP agree with each other, since where they differ there is nothing to match. The description grids are every format x 1D/2D/3D x seven extents x mips x array sizes, plus 26 render-target, depth and block-compressed kinds at 256..4096 with the flags an engine gives them, 1x and 4x.

The layer may know less than the host (it refuses a video format, reports no tiled support): those are gaps, printed with LEONIDA_SWEEP_GAPS=1. It must not claim more or answer differently, and those fail the run:

  • a Support1/Support2 bit, or a quality level, that the host lacks;
  • a size where the host refuses, or for the engine-style descriptions a size smaller than the host's (a smaller size is what would let two placed resources overlap);
  • a footprint that is not the host's (a refusal is a gap).

First run (RTX 5070 Ti, main 03b09a0): 17,069 answers compared, 1,659 skipped because the hosts disagree, 31 wrong. They are two causes, both fixed here:

  1. GetResourceAllocationInfo sized 3D textures in D16_UNORM, D32_FLOAT, D24_UNORM_S8_UINT and D32_FLOAT_S8X24_UINT without ALLOW_DEPTH_STENCIL (4 groups, 14 descriptions each). The host refuses them by format as well as by flag; the layer only had the flag check.
  2. MULTISAMPLE_QUALITY_LEVELS with the tiled flag answered one level for 27 formats where the host answers none: the stencil-bearing depth formats and their plane views (19-22, 44-47), R8G8_B8G8/G8R8_G8B8 (68, 69), the video formats (100-114) and the two sampler-feedback formats (189, 190), at 1x and, for the stencil ones, 4x as well. The same formats keep their plain answer without the flag, which is unchanged.

GetCopyableFootprints never differs in value: every footprint the layer answers is the host's, the rest are refusals.

Gaps the sweep sees and this PR leaves alone (listed so nobody has to find them again; LEONIDA_SWEEP_GAPS=1 prints all 216 groups): 4x render targets that also carry ALLOW_UNORDERED_ACCESS (8 formats; the layer refuses them, the host sizes them at 4 MiB), A8_UNORM as 1D/3D, the video and packed 4:2:2 formats, R32G8X24_TYPELESS without the depth flag, no TILED/OUTPUT_MERGER_LOGIC_OP/MULTISAMPLE_LOAD bits where the host has them, and one case where the layer's size is smaller than the host's: a D32_FLOAT_S8X24_UINT array with no depth flag (64x64x3, 0x10000 against 0x20000; the host sizes each plane on its own).

Overlaps: #4508 (D3D-467) changes the flag and quality checks of allocation() a few lines away; #3037 touches the rgb96 term of the tiled quality line. Either rebases onto the other in a line or two.

Tested

RTX 5070 Ti (621.24), Windows 11 Pro 10.0.26200, MSVC 2022 Build Tools RelWithDebInfo/Ninja, Vulkan SDK 1.4.363.0, on main 03b09a0 with this branch.

  • d3d12_query_sweep on main with the test only: exit 1, 31 wrong (27 quality-level groups, 4 allocation groups). With the two fixes: exit 0, 0 wrong, 216 gaps.
  • The test is not vacuous: it fails on the unfixed layer as above, and its rules are one-sided (a gap never fails the run).
  • Full ctest (-j 2), 155 tests: 145 pass, 9 skipped (no game data or hardware), 1 failed. The one failure, d3d12_present, failed once in that parallel run (it reads a screen pixel from its window); it passes alone and through ctest -R d3d12_present, and nothing here touches presentation.
  • Before the full run: d3d12_vulkan_device, d3d12_resource_desc, d3d12_com, d3d12_typeless_*, d3d12_clear, d3d12_descriptor, d3d12_depth_resolve, d3d12_copy_xfmt, d3d12_msaa_draw all pass.
  • Not run: other GPUs. The host-agreement rule means a PC where the hardware adapter and WARP differ skips those answers rather than failing; an AMD or Intel run is welcome and may add or remove gap lines.

No game data or shaders anywhere. AI-assisted.

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; the runtime README documents the new test.)

…er got wrong

d3d12_query_sweep_test asks the Vulkan-backed device and Windows D3D12 (the
layer's adapter and WARP) the same questions over all 192 DXGI formats and
grids of texture descriptions: FORMAT_SUPPORT, FORMAT_INFO,
MULTISAMPLE_QUALITY_LEVELS, GetResourceAllocationInfo and
GetCopyableFootprints. An answer counts only where the hardware adapter and
WARP agree. The layer may know less than the host (a gap); it must not claim
more or answer differently (a failure).

First run, 17,069 answers, found two such cases, fixed here:

- GetResourceAllocationInfo sized 3D textures in D16, D32, D24S8 and D32S8
  without ALLOW_DEPTH_STENCIL; the host refuses them by format as well as by
  flag.
- MULTISAMPLE_QUALITY_LEVELS with the tiled flag answered one level for the
  stencil-bearing depth formats and their plane views, the packed 4:2:2
  formats, the video formats and the sampler-feedback formats; the host
  answers none, at any sample count.

Footprints never differ in value: every GetCopyableFootprints answer is the
host's or a refusal.

@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_query_sweep_test at 9eb0b6a9 on Windows 11, RTX 5070 Ti: exit 0.

query sweep: layer against NVIDIA GeForce RTX 5070 Ti and WARP -> 17069 answers compared, 1659 skipped where the hosts disagree; 0 wrong, 216 gaps (the layer knows less than the host). The two corrected answers are covered by the sweep. No blocking issue.

@Etoile-Bleu

Copy link
Copy Markdown
Contributor Author

Built and ran d3d12_query_sweep_test at 9eb0b6a9 on Windows 11, RTX 5070 Ti: exit 0.

query sweep: layer against NVIDIA GeForce RTX 5070 Ti and WARP -> 17069 answers compared, 1659 skipped where the hosts disagree; 0 wrong, 216 gaps (the layer knows less than the host). The two corrected answers are covered by the sweep. No blocking issue.

Thanks bro 😄

@RELMYMathieu RELMYMathieu left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Built and ran d3d12_query_sweep_test at 9eb0b6a9 on Windows 11, RTX 3060 Ti 8GB (Ampere), driver 616.92: exit 0.

query sweep: layer against NVIDIA GeForce RTX 3060 Ti and WARP -> 17743 answers compared, 985 skipped where the hosts disagree; 0 wrong, 226 gaps. Both fixes work on Ampere, too. Good work.

@Flyander Flyander 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.

[P2] Fail when the reported allocation alignment is too small

allocation() records both SizeInBytes and Alignment, but allocation_rule and engine_allocation_rule inspect only ours[0]. A layer result with a valid size but Alignment smaller than the host/WARP result is therefore classified as a gap and does not fail the sweep. That can let the test pass while reporting an alignment too weak for CreatePlacedResource; Microsoft says callers must use GetResourceAllocationInfo for texture size and alignment characteristics: https://learn.microsoft.com/en-us/windows/win32/api/d3d12/nf-d3d12-id3d12device-getresourceallocationinfo%28uint_uint_constd3d12_resource_desc%29. Please classify an undersized alignment as an error whenever the agreed host result is valid, while a larger alignment can remain a gap.

@shdann

shdann commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested 9eb0b6a on NVIDIA GeForce RTX 4090 (driver 32.0.16.2101), Windows 11, MSVC 14.51: pass. Also pass on the integrated AMD Radeon adapter (driver 32.0.21043.5001). The build has no validation layers.

  • RTX 4090: d3d12_query_sweep_test.exe prints query sweep: layer against NVIDIA GeForce RTX 4090 and WARP and 17743 answers compared, 985 skipped where the hosts disagree; 0 wrong, 226 gaps. The exit status is 0.
  • AMD Radeon, with LEONIDA_VK_DEVICE=Radeon: query sweep: layer against AMD Radeon(TM) Graphics and WARP and 16096 answers compared, 2544 skipped where the hosts disagree; 0 wrong, 142 gaps. The exit status is 0.
  • ctest --output-on-failure -j 4 gives 135 tests: 133 pass and 2 fail. The 2 failures are d3d12_present and xbox_present; they fail on main 03b09a08 on this computer too, because of the window size.

Negative control: with runtime/shims/d3d12_vulkan_device.cpp from main, the sweep finds 31 wrong answers on the RTX 4090 (for example WRONG GetResourceAllocationInfo format 40 dim 4, ours 10000 10000, host ffffffffffffffff 10000) and 27 on the AMD adapter (for example WRONG MULTISAMPLE_QUALITY_LEVELS format 100, ours 0 1, host 0 0).

I found no defect. 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.

5 participants