From ff09d1eb1f79e3d4f9ea045c1e53b4bb2f925004 Mon Sep 17 00:00:00 2001 From: fiestorra Date: Sun, 29 Nov 2026 23:14:08 +0100 Subject: [PATCH] dxgi: a refused vkCreateSwapchainKHR says what it was asked for 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. --- runtime/shims/dxgi_swapchain.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/runtime/shims/dxgi_swapchain.h b/runtime/shims/dxgi_swapchain.h index 1a3650208f..f2e6693d37 100644 --- a/runtime/shims/dxgi_swapchain.h +++ b/runtime/shims/dxgi_swapchain.h @@ -582,7 +582,16 @@ class VulkanSwapchain { ci.oldSwapchain = swapchain_; VkSwapchainKHR next = VK_NULL_HANDLE; - if (observe(fn_.create_swapchain(device_, &ci, nullptr, &next), "vkCreateSwapchainKHR (DXGI)") != VK_SUCCESS) { + if (const VkResult created = observe(fn_.create_swapchain(device_, &ci, nullptr, &next), + "vkCreateSwapchainKHR (DXGI)"); + created != VK_SUCCESS) { + // observe() speaks only for a lost device, so a swapchain the surface refuses used to vanish here and + // resurface later as "present failed", which names the symptom rather than the cause. Name the request. + std::fprintf(stderr, + "[rt] d3d12: vkCreateSwapchainKHR failed (VkResult %d): format %d, colour space %d, %ux%u, " + "present mode %d, images %u, composite alpha %d\n", + int(created), int(ci.imageFormat), int(ci.imageColorSpace), ci.imageExtent.width, + ci.imageExtent.height, int(ci.presentMode), ci.minImageCount, int(ci.compositeAlpha)); // oldSwapchain is retired even when the call fails: it can neither present nor be passed as // oldSwapchain again (VUID-VkSwapchainCreateInfoKHR-oldSwapchain-01933). Drop it and its buffers, as a // failed ResizeBuffers leaves the host's swap chain with none.