Skip to content

d3d12_xs: warn once when LEONIDA_D3D12=vulkan names a device this build does not have - #8281

Closed
Koro4e wants to merge 2 commits into
ProjectLeonida:mainfrom
Koro4e:vulkan-env-no-device
Closed

Koro4e wants to merge 2 commits into
ProjectLeonida:mainfrom
Koro4e:vulkan-env-no-device

Conversation

@Koro4e

@Koro4e Koro4e commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

What and why

kett1m's finding on the coordination board (comment, claimed there): LEONIDA_D3D12=vulkan is only read inside #ifdef LEONIDA_VULKAN_DEVICE (runtime/shims/d3d12_xs.cpp), and a cross build configured without -DLEONIDA_VULKAN_HEADERS_FETCH=ON has no Vulkan device. The variable then changes nothing, the run quietly uses the host's D3D12 device, and under Wine that fails at D3D12XboxCreateDevice with E_INVALIDARG (12_0) or E_NOINTERFACE (11_0) — a build configuration mistake that reads as a device failure. ruvenesh lost time to exactly this on #7232; I hit the same silence on a Windows run the same day (the env var changed nothing and the D3D12 trace looked like a device stop).

The change

  • An #else branch reads LEONIDA_D3D12 once and prints one line naming the configure flag:
    [rt] d3d12_xs: LEONIDA_D3D12=vulkan ignored: this build has no Vulkan device. Reconfigure with -DLEONIDA_VULKAN_HEADERS_FETCH=ON (see docs/testing.md).
  • docs/testing.md, the cross-build section: one paragraph saying the same, so the runbook reader meets the explanation before the failure.

Checks

  • The #else branch is compile-checked with cl /c /W4 /permissive- /utf-8 without LEONIDA_VULKAN_DEVICE — clean.
  • The normal build (with the define) compiles and the boot run behaves as before — the branch only adds the warning path.

Notes

  • No new test: the branch is one fprintf behind an #ifdef flip that no test target exercises (the test builds all define the macro); a test would need a second configuration of the same target. Saying so plainly rather than shipping a fixture for it.
    agent: yes

…ld does not have

The variable is only read inside #ifdef LEONIDA_VULKAN_DEVICE, and a cross
build configured without -DLEONIDA_VULKAN_HEADERS_FETCH=ON has no Vulkan
device (the xwin toolchain does not find the Vulkan headers by itself).
LEONIDA_D3D12=vulkan then changes nothing and the run quietly uses the
host's D3D12 device, which under Wine fails at D3D12XboxCreateDevice with
E_INVALIDARG (12_0) or E_NOINTERFACE (11_0) and reads as a device problem
rather than a build one (reported by ruvenesh on ItsNotRexed#7232, found by kett1m on
the coordination board).

The #else reads the variable once and prints one line naming the configure
flag; docs/testing.md's cross-build section says the same. The #else branch
is compile-checked with cl /c without the define.
@cdomergue

Copy link
Copy Markdown

Verified the no-Vulkan build on native Windows x64 at 792c84992 (MSVC Release, WARP). The stock device_proxy_test passed both with LEONIDA_D3D12=vulkan and with the variable unset. The warning appeared only in the Vulkan-requested run, and the host device was created successfully.

One small mismatch with the commit's “warn once”: I added a second successful D3D12XboxCreateDevice call to the synthetic fixture in the same process, releasing the first device before creating the second. With vulkan I counted two fallback warnings on stderr. With the variable unset I counted zero. Both runs passed. A dedicated atomic flag, following the existing proxy_logged pattern above this branch, would give one warning per process. Set the flag only after the backend name matches.

AI-assisted (OpenAI Codex).

cdomergue's ItsNotRexed#8281 check counted two fallback warnings when a fixture made
a second successful D3D12XboxCreateDevice in the same process. Gate the
line behind an atomic flag following the proxy_logged pattern above, set
only after the backend name matches.
@Koro4e

Koro4e commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Fixed in 46eec624d: the line now sits behind a dedicated static std::atomic<bool> vulkan_ignored_logged{false} following the proxy_logged pattern above the branch, and the flag is set only after the backend name matches — so a second successful D3D12XboxCreateDevice in the same process stays silent, and a non-vulkan value never burns the flag.

Syntax-checked the #else branch at /W4 (the Vulkan build does not compile it). Thanks for the clean catch.

@sodove

sodove commented Nov 23, 2026

Copy link
Copy Markdown

Tested 46eec624d in GitHub test merge 48781f9b with 867d922f0 on Windows 11 Pro x64 build 26100, MSVC 19.44 and SDK 10.0.26100. CMake Release build with Vulkan package lookup and header fetch disabled. Device creation used WARP.

  • Four successful creations in one process, with the backend unset, explicitly set to a different value, then set to Vulkan twice. Exactly one warning, on the first Vulkan request.
  • Fresh processes confirmed zero warnings for two non-Vulkan requests and one warning for two Vulkan requests. All four devices were created successfully.
  • Replacing only d3d12_xs.cpp with the v1 implementation from 792c84992 produced two warnings in the mixed sequence. All four device creations still succeeded.

Restored the original sources. Stock device_proxy and device_proxy_trace passed 2/2. AI-assisted.

@comtek21516

Copy link
Copy Markdown

Tested 46eec624d on main at 867d922f0, in one tree with #8673 and #8124 (three clean merges): pass.

For this change. The PR adds no test. device_proxy, device_proxy_trace and the six xs_proxy_mock* tests, which go through d3d12_xs.cpp, pass natively; the xs_proxy_mock* ones and the layer tests pass under Wine on the GPU with LEONIDA_VK_DEVICE set to that GPU. The warning itself was not provoked: no run here named a device the build lacks, so this shows the change breaks nothing, not that the line prints.

Setup. Built with MSVC 14.52 (Visual Studio 18), Windows SDK 10.0.26100, Vulkan SDK 1.4.363.1, Ninja RelWithDebInfo on Windows Server 2025 (no Vulkan driver there), then the same binaries run through scripts/run_wine_tests.py under wine-11.0 (WineHQ stable, xvfb-run) on a Quadro RTX 4000 (Turing), NVIDIA 615.71.09, Ubuntu 22.04.5, where the layer tests report device: Quadro RTX 4000.

passed failed skipped
native Windows, this tree 150 4 124
Wine on the GPU, main 867d922f0 210 12 54
Wine on the GPU, this tree 214 11 54

Against main under Wine, the only differences are #8124's: its three new xs_console_slots* tests pass, and d3d12_vulkan_device goes from failed to passed. Every other test has the status it has on main. The four native failures are gameinput_host, d3d12_sparse_queue_family, vk_bindless_ps_tex and vk_bindless_ps_imgatomic, which fail the same way on main on that machine (#7452). The 11 left under Wine are host comparisons Wine cannot answer and d3d12_xdxr_rt, d3d12_indirect_rt, d3d12_indirect_dispatch_count, all failing on main too.

No game files used. AI-assisted (Claude Code).

@ddaikodaiko

Copy link
Copy Markdown

Code read at 46eec624 (no build possible here: this branch only compiles in a build without the Vulkan device, and the Windows box has the headers). I looked for the things that usually go wrong in this shape and found none:

  • The three-argument getenv_s(&backend_length, backend, "LEONIDA_D3D12") is MSVC's secure template overload, which deduces the char[16] size; it is not a typo of the four-argument form. I compiled a standalone snippet with MSVC 19.44 to be sure: with set "LEONIDA_D3D12=vulkan" it returns 0, len=7, buf="vulkan", strcmp == 0, so the warning fires as intended. It also compiles under /W4 with no warning.
  • The std::atomic<bool> guard is correct for "once per process", and std::atomic is already included/used in this translation unit.
  • #else is the right condition: with the Vulkan device compiled in, the #ifdef branch keeps its existing behaviour, and the docs paragraph in the PR names the same condition (no -DLEONIDA_VULKAN_HEADERS_FETCH=ON).

One limitation, not a defect: because the branch is #else, I cannot exercise the warning on a normal Windows build; it needs a cross build configured without the Vulkan headers. Nothing in the diff looks wrong on the read.

@Kerwinss

Copy link
Copy Markdown

Tested 46eec62 on Windows 11 Pro 10.0.26300, MSVC 14.51 (VS Build Tools 2026), Windows SDK 10.0.26100, NVIDIA GeForce RTX 4060 / 621.24, Khronos Vulkan headers via -DLEONIDA_VULKAN_HEADERS_FETCH=ON: pass, no regression.

Merged onto main 6312c05 (clean), full runtime build, ctest -C RelWithDebInfo -j4: 237/239. The only failures are the two main has on this GPU (d3d12_depth_resolve, fixed by #7985; d3d12_vulkan_device:6574).

This build has the Vulkan device (LEONIDA_VULKAN_DEVICE defined), so the new "this build does not have it" warning path is not exercised here; run_tiny_frame with LEONIDA_D3D12=vulkan still passes, so the normal path is unchanged.

AI-assisted (Claude Code). No game files.

@itsRevela

Copy link
Copy Markdown
Contributor

Tested 46eec624 merged onto main 867d922f on an NVIDIA GeForce RTX 3070 Ti (driver 610.88), Windows 11, MSVC 19.44 + Ninja, RelWithDebInfo: pass.

Full runtime ctest (267 tests): There is no dedicated test for the new warning; the rest of the suite is unaffected. The only failures are d3d12_depth_resolve, d3d12_indirect_rt and d3d12_vulkan_device, which fail the same way on main 867d922f alone. No new failure against that main.

AI-assisted (Claude Code).

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