Skip to content

d3d12: execute supported commands instead of dropping submission on unsupported command (D3D-408) - #3958

Open
chemokita13 wants to merge 1 commit into
ItsNotRexed:mainfrom
chemokita13:d3d12-unsupported-cmd-d3d-408
Open

chemokita13 wants to merge 1 commit into
ItsNotRexed:mainfrom
chemokita13:d3d12-unsupported-cmd-d3d-408

Conversation

@chemokita13

Copy link
Copy Markdown
Contributor

Resolves item D3D-408 (reported by @kotorvr in #3574#issuecomment-7086206014).

Summary

When encountering an unsupported command during command list preparation, ExecuteCommandLists previously dropped the entire submission and submitted nothing. During bring-up, this prevented supported commands (clears, barriers, copies, and draws) from running.

This PR implements tolerance for unsupported commands:

  • Logs each unsupported command variant once via detail::note_unsupported(...) to avoid log spam ([rt] d3d12: <what>: unsupported, skipped).
  • Marks unsupported commands as skipped (p.skip = true) during prepare() and bypasses them in emit().
  • Tolerant execution is enabled by default on VulkanQueue for bring-up, and can be toggled via rt::d3d12::set_tolerate_unsupported(queue, bool) for strict conformance testing.
  • Updates documentation in docs/d3d12_vulkan.md.
  • Adds a test in runtime/test/d3d12_vulkan_device_test.cpp testing both tolerance enabled (clear executes to readback) and tolerance disabled (ReplayResult::unsupported).

Tested on Windows without game files; verified LF line endings and standard tests pass. AI-assisted.

@rafaelpssz

Copy link
Copy Markdown
Contributor

Tested 947dc1a6 on Windows 11 with an RTX 3060 (driver 616.64) and Vulkan SDK 1.4.363.1, built with clang-cl + xwin (RelWithDebInfo). No game files.

  • d3d12_vulkan_device_test exits 0, including the new D3D-408 block. With tolerance off, the list holding CopyRaytracingAccelerationStructure returns ReplayResult::unsupported and submits nothing. With tolerance on, it returns success and every texel of the clear reads back green.
  • The unsupported command is logged exactly once: [rt] d3d12: CopyRaytracingAccelerationStructure: unsupported, skipped.
  • Under LEONIDA_VK_VALIDATION=1 it exits 0 with no validation messages.
  • Neighbouring tests that go through prepare/emit also pass: command_list and d3d12_descriptor.
  • No red run against the base. The test calls the new set_tolerate_unsupported / tolerate_unsupported, so it doesn't build without the change. Its strict-mode half is the base behaviour (refuse and submit nothing), and the tolerant half fails unless the skip path works.

One observation: tolerate_unsupported_ defaults to true (vulkan_backend.h:2123), so every existing test that relied on a refusal for an unsupported command now gets a success instead. The tests I ran don't hit this, but docs/d3d12_vulkan.md could say which tests or modes set it back to strict.

@chemokita13
chemokita13 force-pushed the d3d12-unsupported-cmd-d3d-408 branch from 2995f24 to e70045e Compare November 22, 2026 22:56
@chemokita13

Copy link
Copy Markdown
Contributor Author

Thanks for testing on RTX 3060 and verifying with Vulkan validation layers @rafaelpssz!

Regarding the observation: note that standalone unit tests calling prepare() directly still get tolerant = false by default, so direct replay tests retain strict rejection. At the queue level, VulkanQueue defaults to tolerate_unsupported_ = true for bring-up, and tests can toggle strict refusal via rt::d3d12::set_tolerate_unsupported(queue.p, false).

I've clarified this distinction in docs/d3d12_vulkan.md.

@shdann

shdann commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Test report. An AI tool helped me to do this test. I applied the diff of commit e70045e0 of this pull request to main (aa2988cc). I built it with MSVC 14.51 (RelWithDebInfo, Ninja) and ran ctest on Windows 11 with an NVIDIA GeForce RTX 4090.

Result

Two tests that pass on main fail with this pull request: vk_predicated_copy and d3d12_uav_clear.

[rt] d3d12: predicated copy: unsupported, skipped
line 94: queue.execute({&pointer,1})==ReplayResult::unsupported
[rt] d3d12: ClearUnorderedAccessView (non-attachment rect clear): unsupported, skipped
line 769: replay([&](ID3D12GraphicsCommandList* l) { l->ClearUnorderedAccessViewUint({0}, v_view, volume.p, values, 1, &rect); }) == leonida::ReplayResult::unsupported

Cause

The two checks are in runtime/test/vk_predicated_copy_test.cpp, line 94, and runtime/test/d3d12_uav_clear_test.cpp, line 769. Each check sends a list with an unsupported command through the queue. Each check expects the result ReplayResult::unsupported.

This pull request sets tolerate_unsupported_ = true as the default value of the queue. Thus the queue skips the command and returns success, and the two checks fail. This pull request does not change these two test files.

The earlier answer says that tests which call prepare() directly stay strict. That is correct, but these two tests use the queue.

Suggestion

Use one of these two options for each test:

  1. Call set_tolerate_unsupported(false) on the queue before the check. Then the test continues to check the strict mode.
  2. Change the check to agree with the new default behaviour. Then also make sure that the queue did not do the skipped command.

For vk_predicated_copy, the comment at line 93 says that a device without the helper must submit nothing. With the new default, the queue submits the other commands of the list. Make sure that this is the intended behaviour for a predicated copy.

Other tests also expect ReplayResult::unsupported. They pass on this GPU. They can fail on a device with different features. I did not examine each of them.

Small cost note

I did not measure this. note_unsupported runs for each skipped command in each ExecuteCommandLists call. Each call locks a global mutex and makes a std::string for the std::set lookup. A title that sends the same unsupported command in each frame pays this cost in each frame. A std::set<const char*>, or one flag for each message, removes the allocation.

Other results on this GPU

Build Tests Failures
main 133 d3d12_present, xbox_present
This pull request (e70045e0) 133 vk_predicated_copy, d3d12_uav_clear, d3d12_present, xbox_present

d3d12_present and xbox_present fail on this computer because of its window manager. Ignore them.

@Exopus-0x65f7ad0

Copy link
Copy Markdown

Tested e70045e0 on Windows 11 (26300), RTX 5060 Ti / 621.14, MSVC 14.51 (VS 2026), Vulkan SDK 1.4.363.0, RelWithDebInfo, clean build with -DLEONIDA_LLVM_MC (so the translated-shader D3D12 gate tests are built), full LEONIDA_VK_VALIDATION=1 ctest -j4: 142/144, two tests fail, both because tolerance is on by default and they still expect the strict answer:

  • vk_predicated_copy: line 94: queue.execute({&pointer,1})==ReplayResult::unsupported; the log shows [rt] d3d12: predicated copy: unsupported, skipped, so the copy is now skipped and the execute succeeds.
  • d3d12_uav_clear: line 769: replay(... ClearUnorderedAccessViewUint({0}, v_view, volume.p, values, 1, &rect) ...) == leonida::ReplayResult::unsupported; log: ClearUnorderedAccessView (non-attachment rect clear): unsupported, skipped.

Both pass on main here. Since these two check the refusal itself, they look like the "strict conformance" case your rt::d3d12::set_tolerate_unsupported(queue, false) is for (or the VulkanQueue setter in vk_predicated_copy). Switching them to strict mode should make them pass unchanged; alternatively, assert the skipped-and-succeeds result. Everything else passed, 0 VUIDs, 0 build errors.

Separately, this merges cleanly (no conflict in git merge-tree) with #4061, which refuses a list whose type doesn't match the queue before any preparation. That is a different rule: Windows' debug layer removes the device for it (message 836), so it stays a refusal under tolerant mode too.

AI-assisted (Claude Code).

@pwu2775-dev

Copy link
Copy Markdown
Contributor

Tested e70045e on NVIDIA GeForce RTX 4070 (driver 617.42), Windows 11 (26300), MSVC 19.44, scripts/build_runtime.ps1 (Ninja), RelWithDebInfo: fail. ctest 151/153; two existing tests now fail because tolerance is on by default:

  • vk_predicated_copy: line 94: queue.execute({&pointer,1})==ReplayResult::unsupported (log: predicated copy: unsupported, skipped).
  • d3d12_uav_clear: line 769: replay(... ClearUnorderedAccessViewUint ...) == leonida::ReplayResult::unsupported (log: ClearUnorderedAccessView (non-attachment rect clear): unsupported, skipped).

Both pass on #4557's head (155/155, which does not touch them), and this PR changes only d3d12_vulkan_device_test.cpp: they assert the strict unsupported result that tolerance now turns into a skip. They would need set_tolerate_unsupported(false) or updated expectations.

Also, tolerate_unsupported_ (vulkan_backend.h:2345) is a plain bool set through set_tolerate_unsupported; if a held batch is prepared on another thread, the read is unsynchronised.

AI-assisted: review by Codex (gpt-6.1-terra); the two test failures were run here and the flag was checked in the code.

@Vonsek

Vonsek commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested e70045e 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_vulkan_device$" (the test this PR changes): pass on both GPUs, 1/1 each. No game files.

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.

6 participants