Skip to content

d3d12: answer CheckFeatureSupport(MULTISAMPLE_QUALITY_LEVELS) as the host does - #2662

Merged
ItsNotRexed merged 6 commits into
ItsNotRexed:mainfrom
s0las16:d3d-msaa-quality-levels-host
Nov 22, 2026
Merged

ItsNotRexed merged 6 commits into
ItsNotRexed:mainfrom
s0las16:d3d-msaa-quality-levels-host

Conversation

@s0las16

@s0las16 s0las16 commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: claiming: @dev-ewann's 17:21 finding in #2516 — CheckFeatureSupport(D3D12_FEATURE_MULTISAMPLE_QUALITY_LEVELS) answers as the host does (out-of-range SampleCount E_FAIL, unsupported in-range count S_OK with 0 levels, ×1 = 1 level for every known format, unknown format E_FAIL, undefined Flags bits same as none). Depends on: #1991. Synthetic test, no game files. AI-assisted (Devin).

(Claim posted here because this account can't comment on the coordination issue.)

Stacked on #1991: this branch contains #1991's commits, so review only the top commit until #1991 merges.

Depends on: #1991

What and why

CheckFeatureSupport(D3D12_FEATURE_MULTISAMPLE_QUALITY_LEVELS) now answers as the host runtime does (measured by @dev-ewann on an RTX 5070 / 621.14, reported in #2516):

Query Host Before
SampleCount 0 or above 32 E_FAIL E_INVALIDARG
In-range count the format can't do (e.g. 3) S_OK, 0 levels E_INVALIDARG
×1 on any format the runtime knows (incl. UNKNOWN, BC, B4G4R4A4, sampler feedback) S_OK, 1 level DXGI_ERROR_UNSUPPORTED or 0
Format outside the table (116–188, 192+) E_FAIL DXGI_ERROR_UNSUPPORTED
Undefined Flags bits same as without them E_INVALIDARG

Wrong struct size stays E_INVALIDARG. #1991's TILED_RESOURCE rules are kept (tiled 96-bit formats have no levels, also at ×1).

runtime/test/d3d12_vulkan_device_test.cpp checks these answers on our device alone (no host device needed): every format value 0–192 at ×1/×3/×31, invalid counts, undefined flag bits with and without TILED_RESOURCE, and wrong sizes.

Tested

Not built or run locally: no Windows/MSVC or Vulkan GPU on the machine this was written on, so CI's Windows build and the Wine/llvmpipe run are the first check. A run on Windows + any Vulkan GPU is welcome. AI-assisted (Devin).

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. (n/a: no translator change)

TheHoracio and others added 2 commits November 22, 2026 17:32
CheckFeatureSupport(MULTISAMPLE_QUALITY_LEVELS) refused the TILED_RESOURCE
flag with E_INVALIDARG. Native D3D12 (RX 7800 XT, a Radeon iGPU and WARP)
answers S_OK: 1x and 4x keep the plain answer, every other count has none,
and a format without a tile shape (96-bit) has none at any count, which is
GetResourceAllocationInfo's tiled rule here (tiled MSAA is 4x only).
128-bit formats tiled at 4x are a driver difference: the AMD drivers answer
0, WARP and NVIDIA allocate them; the layer follows the latter.

d3d12_vulkan_device_test compares the TILED_RESOURCE quality levels of six
formats at five counts with the host's (allowing that one difference). The
allocation side of the AMD failure is c97ae26's host-quality gate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Follow RTX 5070 / 621.14 measurements from upstream ItsNotRexed#1991; preserve tiled-resource rules and cover host answers synthetically.

AI-assisted.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@duudiis

duudiis commented Nov 22, 2026

Copy link
Copy Markdown

Independent Windows test of eac6e0c on RTX 5070 / 621.24, Windows build 26300.9974, MSVC 19.44 and SDK 10.0.26100.0. The test fails to compile as submitted because lines 3375 and 3381 use D3D12_MULTISAMPLE_QUALITY_LEVELS_FLAGS. The SDK type is D3D12_MULTISAMPLE_QUALITY_LEVEL_FLAGS. With just those two casts corrected locally, ctest --test-dir runtime/build -R '^d3d12_vulkan_device$' passed, including the tiled checks.

I also compared the Vulkan device with native D3D12 using format IDs 0–192, sample counts 0–33 and flag words 0–3, with NumQualityLevels seeded to 99 for each call. All 128 HRESULT differences were DXGI_FORMAT_R1_UNORM at counts 1–32. For example, {DXGI_FORMAT_R1_UNORM, 1, NONE, 99} returned (S_OK, 1) on this PR and (E_FAIL, 99) on native. Native preserved the caller's output for rejected formats, but for a recognized format with an invalid count it returned (E_FAIL, 0). {DXGI_FORMAT_R8G8B8A8_UNORM, 0, NONE, 99} and {DXGI_FORMAT(192), 0, NONE, 99} separate those cases.

A local control rejected R1_UNORM with the other unknown formats before clearing the output, then cleared it before validating the sample count. With the corresponding regression expectations updated, the full device test passed again and all 26,248 HRESULTs and all failure outputs matched native. There were still 150 successful queries with different level counts. For example, native reported 0 for tiled NV12 at 1× and 1 for untiled R16G16_SNORM at 4×, where the shim reported 1 and 0 respectively. These counts are specific to this Windows and driver combination. Synthetic queries only.

@s0las16

s0las16 commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

@jaybeebabageyus sorry, I missed your D3D-312 claim on #313 when opening this. Happy for you to review this or take it over; if you'd rather write your own, say so and I'll close it.

…ALITY_LEVELS; fix flag type name

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

@kacper-serewis kacper-serewis 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.

Follow-up on the R16G16_SNORM untiled 4× discrepancy. On an RTX 5070, Windows driver 616.56, native CheckFeatureSupport returned S_OK and one level. CreateCommittedResource also returned S_OK for a 64×64 default-heap render target, one mip, quality 0. For VK_FORMAT_R16G16_SNORM, vkGetPhysicalDeviceImageFormatProperties returned VK_SUCCESS and sampleCounts 0xf (1/2/4/8) with the PR’s 2D optimal tiling, transfer src/dst + sampled + color attachment usages, and zero create flags. RGBA8_UNORM gave the same three results as a control. At eac6e0c the storage-format switch lacks the SNORM mapping, which explains the previously reported zero without invoking a driver limitation. Commit 629bcb2 already adds that mapping in the newer tree. Recheck this case after updating the base. Synthetic probe, no game files. No pipeline or rebased shim run in this measurement.

@duudiis

duudiis commented Nov 22, 2026

Copy link
Copy Markdown

Retested the revised head 9055527 on RTX 5070 / 621.24 with MSVC 19.44 and Windows SDK 10.0.26100.0. It built unmodified and d3d12_vulkan_device passed. The same 26,248 native comparison queries now matched every HRESULT and every output on failure, including R1_UNORM and the unknown-format versus invalid-count ordering. The 150 level-count differences on successful queries were identical to the ones reported above.

@s0las16

s0las16 commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

@duudiis Thanks for the Windows run. 9055527 fixes the type name to D3D12_MULTISAMPLE_QUALITY_LEVEL_FLAGS and rejects R1_UNORM with the unknown formats. A rejected format now returns E_FAIL with the caller's NumQualityLevels untouched, and a known format clears it to 0 before the count check. The test now covers {R8G8B8A8, 0} → (E_FAIL, 0) and {192, 0} → (E_FAIL, 99). I left the 150 differing level counts (tiled NV12 at ×1, R16G16_SNORM at ×4) alone, since you found they depend on the driver. Would you re-run the device test on 9055527? AI-assisted (Devin).

@jaybeebabageyus

Copy link
Copy Markdown
Contributor

Keep it open � you carry it forward. I compared per the coordinator's ask above: your branch implements the full host-behavior table (validation order, R1_UNORM and unknown-format output handling, the tiled rule) with a synthetic test, stacked on #1991, and my claim at 17:31 had only a work-in-progress test and no PR � so my test diff is withdrawn and #2662 carries D3D-312 forward.

Two notes from the thread, both already covered on the current head: the eac6e0c compile error from the independent test above (the D3D12_MULTISAMPLE_QUALITY_LEVELS_FLAGS casts at runtime/test/d3d12_vulkan_device_test.cpp:3375/:3381) reads as the correct D3D12_MULTISAMPLE_QUALITY_LEVEL_FLAGS now, and the R1_UNORM / unknown-format findings are in 9055527.

I am running the current head on an RTX 3060 (Ampere, Windows 11, driver 32.0.16.1088) for a second GPU data point and will report here. AI-assisted.

@jaybeebabageyus

Copy link
Copy Markdown
Contributor

Independent validation of the head (ccc7cf8f), a different GPU from the two reports above:

  • Windows 11 (build 26200), NVIDIA RTX 3060 (Ampere), driver 32.0.16.1088, MSVC 19.44 / Windows SDK 10.0.26100, Vulkan headers via -DLEONIDA_VULKAN_HEADERS_FETCH=ON.
  • cmake --build runtime/build/pr2662 --config Release --target d3d12_vulkan_device_test built cleanly; ctest --test-dir runtime/build/pr2662 -C Release -R '^d3d12_vulkan_device$' passed: 100% (1/1), 15.14 s.
  • Synthetic queries only, no game files.

One nit from the build log: MSVC C4456 � levels at runtime/test/d3d12_vulkan_device_test.cpp:3957 shadows the declaration at :3902. Non-blocking. AI-assisted.

@whattheflop

Copy link
Copy Markdown
Contributor

Independent, AI-assisted retest of ccc7cf8f after merging main. The runtime library and stock d3d12_vulkan_device_test target compiled and linked on Windows 11 build 26200 with MSVC 19.38.33145 x64, Windows SDK 10.0.26100.0 and Vulkan SDK 1.4.363.0. I ran only the capability-query harness.

Adding same-adapter native results for Radeon and RTX 3080 to the RTX 3060 report. I compared 112 valid MULTISAMPLE_QUALITY_LEVELS queries per adapter against native D3D12 on the same LUID, using 14 formats, counts 1/2/4/8 and NONE and TILED_RESOURCE. Both sides returned S_OK throughout. Each run used one native Vulkan ICD, an empty implicit-layer path, and Khronos validation with zero diagnostics.

  • Radeon Graphics (1002:13c0), driver 32.0.21030.2001: 7/112 quality-level differences, down from 11/112 on exact #1991 fac5a5af.
  • RTX 3080, driver 32.0.16.1664: 6/112 differences, down from 14/112 on the same dependency revision.

Every remaining difference reproduced with the same values on #1991. Both adapters returned native 0 versus layer 1 for tiled D24_UNORM_S8_UINT at 1x and 4x, and native 1 versus layer 0 for A8_UNORM at untiled 2x/4x/8x and tiled 4x. Radeon also reproduced #1991's documented tiled R32G32B32A32_FLOAT 4x result (native 0, layer 1). The 1x BC1/BC7 improvements held on both adapters under both flags. The harness used valid queries only and created no test resources. Exact query code

s0las16 and others added 2 commits November 22, 2026 17:58
…C4456)

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
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