Skip to content

dxgi: a refused vkCreateSwapchainKHR says what it was asked for - #2650

Closed
fiestorra wants to merge 1 commit into
ProjectLeonida:mainfrom
fiestorra:fix/swapchain-failure-log
Closed

fiestorra wants to merge 1 commit into
ProjectLeonida:mainfrom
fiestorra:fix/swapchain-failure-log

Conversation

@fiestorra

@fiestorra fiestorra commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

observe() in runtime/src/vulkan_device_fault.h reports VK_ERROR_DEVICE_LOST and nothing else:

static VkResult observe(DeviceFaultDiagnostics* diagnostics, VkResult result, const char* operation) {
    if (result == VK_ERROR_DEVICE_LOST) { … report … }
    return result;
}

Every other failure of an observed operation is dropped. At the swapchain call site that means a refused vkCreateSwapchainKHR vanishes, rebuild() returns false, and the next thing anyone sees is

[rt] d3d12: present failed (VkResult -11)

which names the symptom and not the cause - I lost three rounds to exactly that while chasing a xbox_present failure on this machine.

The change

One log line at the failure point, where VkSwapchainCreateInfoKHR is still in hand: the VkResult, format, colour space, extent, present mode, image count and composite alpha. Behaviour is unchanged - the call still drops the old swapchain and returns false for the same reason, with the same comment explaining the VUID.

Tested

  • cmake --build runtime/build-ninja --target xbox_present_test builds clean;
  • run on this machine: the line does not fire, because the swapchain here is created successfully and the -11 comes from present()'s own deliberate refusal (runtime/src/vulkan_present.h:283, multisampled / non-blit format / no VK_FORMAT_FEATURE_BLIT_SRC_BIT);
  • vkGetPhysicalDeviceFormatProperties on both GPUs here reports BLIT_SRC for R8G8B8A8_UNORM, B8G8R8A8_UNORM, R8G8B8A8_SRGB and R16G16B16A16_SFLOAT, so this machine's refusal is about a specific source in that test rather than the environment.

So the line is untested in the firing direction, and I say so: what I verified is that it compiles, that it costs nothing on the working path, and that it would have answered the question I could not answer.

Why it is worth having even so

A layer that fails for a reason and prints a different one is a layer that makes every bug report harder. The next person to see present failed (VkResult -11) should be able to tell whether the swapchain was refused before anything was presented.

The extra commit at the tip (no longer carried)

The branch used to carry a3b5ebea1 (test(semantic): align computed-I/J f16 interp oracle…), added only because semantic-tests was red on main for that oracle and every branch cut from main inherited it. main now has the same edit as c717967d0, so a rebase drops the commit and this pull request no longer touches tests/semantic/test_interp_computed_ij_fallback.py - the diff is only what this change actually needs.

AI-assisted: yes - DeepSeek v4.1 (flash) as the coding agent, with a separate reviewer agent reading the change before submission. Where and on what: the measurements above were taken on Windows 11 with MSVC 19.44.35226 on an RTX 4090 (NVIDIA driver 621.24) where a C++ or GPU path is involved; Python and docs cases need none of it.

Written with an AI assistant.

@fiestorra

Copy link
Copy Markdown
Contributor Author

Rebased onto main 452d1d1b6 and now carries the one commit main is missing, like my other pull requests:

semantic-tests (ubuntu-latest) was red on main for the interp oracle (TEST-INTERP-COMPUTED-IJ-FALLBACK-RTZ),
so a branch cut from main inherits it and cannot show its own result. The commit is a3b5ebea1, the same one
#2633 carries; if #2633 merges first this becomes a duplicate and can be dropped, and if this lands first
#2633 becomes a no-op.

The change itself is unchanged and still verified on this machine (xbox_present builds and, where it applies, passes 3/3 after the rebase).

Written with an AI assistant.

@merzleckeier

Copy link
Copy Markdown
Contributor

I exercised the firing direction on fb663cb5 (GitHub merge 2f6c9452 into 452d1d1b6) using the existing synthetic dxgi_swapchain_count_test.

  • MEASURED. The unmodified test passed 3/3 on main and 3/3 on the merge. The merge emitted four vkCreateSwapchainKHR failed lines per run for the four injected VK_ERROR_OUT_OF_DEVICE_MEMORY returns, with minimum image counts 2, 3, 2, 2. Main emitted none.
  • MEASURED, selected fields and recovery. I ran the same additional mock case on both trees. DXGI requested 800×450 and three buffers. The mock captured the Vulkan call as 960×540, HDR10 colour space, format 64, immediate mode, four minimum images and inherit alpha, then returned VK_ERROR_SURFACE_LOST_KHR. The PR log matched every captured field in 3/3 runs. Both builds retired and destroyed the old swapchain, exposed zero backbuffers on failure, and successfully rebuilt without passing a retired handle. The recovered chain presented with its original two backbuffers in 3/3 runs on each tree.

Win64 clang-cl Release (/MD) under Wine 11.22. Synthetic Vulkan functions with the GPU disabled. AI-assisted with OpenAI Codex.

@fiestorra
fiestorra force-pushed the fix/swapchain-failure-log branch from fb663cb to ee32e67 Compare November 30, 2026 03:25
observe() reports VK_ERROR_DEVICE_LOST and nothing else, so a swapchain the
surface refuses used to disappear at the call site and surface later as
"present failed (VkResult -11)", which names the symptom and not the cause.
The request is in hand at the failure point: name the format, colour space,
extent, present mode, image count and composite alpha.

Verified here: the line does not fire on this machine, because the swapchain is
created and the -11 comes from present()'s own format refusal further down
(src/vulkan_present.h:283) - which is exactly the kind of confusion the line
exists to prevent.

Written with an AI assistant.
@fiestorra
fiestorra force-pushed the fix/swapchain-failure-log branch from ee32e67 to ff09d1e Compare November 30, 2026 13:55
@aslan2142

Copy link
Copy Markdown
Collaborator

Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (d3d12/) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, d3d12/, or general docs), please feel free to reopen it.

@aslan2142 aslan2142 closed this Dec 1, 2026
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.

3 participants