<p>Dear ImGui doesn't attempt to create a swapchain for your main window.</p>

<p>The <strong>example</strong> code (main.cpp) in the Vulkan back-end calls a helper <code>ImGui_ImplVulkanH_CreateWindowSwapChain()</code> which calls <code>vkCreateSwapchainKHR()</code>... 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.</p>

<p>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.</p>

<p>All the functions with the <code>ImGui_ImplVulkanH_</code> 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.</p>

CC BY-SA 4.0
2019-08-03T19:22:20.637Z
2019-08-03T19:22:20.637Z
Omar
<p>The Vulkan specification is very clear on this:</p>

<blockquote>
  <p>A native window <strong>cannot</strong> be associated with more than one non-retired swapchain at a time.</p>
</blockquote>

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

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

CC BY-SA 4.0
2019-06-18T20:20:30.497Z
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?
Vectorizer
CC BY-SA 4.0
2019-06-17T02:11:06.240Z
2019-06-17T02:11:06.240Z
Nicol Bolas
<p>I am integrating imgui into my app using glfw + vulkan example.</p>

<p>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".</p>

<p>Under what circumstances, if any, would this be a valid approach?</p>

<p>Should my app and imgui share the same swapchain?</p>

<vulkan>
Multiple swapchains in Vulkan app with ImGui
Vectorizer
# Multiple swapchains in Vulkan app with ImGui

(Asked by: username_0 on 2019-06-16)

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?

**Tags:** vulkan


---

## 2 answers

### Answer by username_2 on 2019-06-17. Score: 4 | Accepted answer

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.

> **Comments:**
> **username_0**: 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?  

---

### Answer by username_1 on 2019-08-03. Score: 2

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.


---

