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

Closed
fiestorra wants to merge 1 commit from upstream-pr/2650 into main
fiestorra commented 2026-11-29 22:14:16 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-11-29T22:14:16Z.


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.

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5555707044 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2650). Originally posted by [fiestorra](https://github.com/fiestorra) on 2026-11-29T22:14:16Z. --- `observe()` in `runtime/src/vulkan_device_fault.h` reports **`VK_ERROR_DEVICE_LOST` and nothing else**: ```cpp 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 commented 2026-11-29 22:22:05 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-11-29T22:22:05Z.


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.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7263616896 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2650#issuecomment-7263616896). Originally posted by [fiestorra](https://github.com/fiestorra) on 2026-11-29T22:22:05Z. --- 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 commented 2026-11-29 23:42:36 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-11-29T23:42:36Z.


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.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7264666418 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2650#issuecomment-7264666418). Originally posted by [merzleckeier](https://github.com/merzleckeier) on 2026-11-29T23:42:36Z. --- 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.
aslan2142 commented 2026-12-01 16:46:21 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T16:46:21Z.


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.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7318200435 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2650#issuecomment-7318200435). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T16:46:21Z. --- 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.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!2650
No description provided.