1
$\begingroup$

I am integrating imgui into my app using glfw + vulkan example.

The function vkCreateSwapchainKHR() is also called by imgui setup logic in addition to my app on the same device and it fails with "internal drawable creation failed".

Under what circumstances, if any, would this be a valid approach?

Should my app and imgui share the same swapchain?

$\endgroup$
2
$\begingroup$

The Vulkan specification is very clear on this:

A native window cannot be associated with more than one non-retired swapchain at a time.

You can create a new swapchain for a surface, but only by passing the old swapchain as the oldSwapchain parameter, which will cause the old swapchain to enter the retired state.

So yes, both you and imGUI should get on the same page about who owns the swapchain.

$\endgroup$
  • $\begingroup$ Thanks for your response. Is it correct that, I will need to build a separate pipeline for ImGUI; it will only share the surface/swapchain with the actual app? $\endgroup$ – Vectorizer Jun 18 at 20:20
2
$\begingroup$

Dear ImGui doesn't attempt to create a swapchain for your main window.

The example code (main.cpp) in the Vulkan back-end calls a helper ImGui_ImplVulkanH_CreateWindowSwapChain() which calls vkCreateSwapchainKHR()... well, because it is an example app.. you should probably not call those helpers in those app, your app probably already creates a window and a swapchain.

When the multi-viewports feature enabled (only available in the 'docking' branch), it DOES create additional swap-chains for every secondary window it creates, those are not windows that you manage nor see at all so it shouldn't interferte with your window.

All the functions with the ImGui_ImplVulkanH_ prefix are documented in imgui_impl_vulkan.h as serving two purposes: facilitating writing the demo app, and internally by the multi-viewports system. You shouldn't need to call those from your app and therefore there's should not be multiple swapchains trying to associate to a same window.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.