title: Drawing to Multiple Windows Using Vulkan
body: <p>I am trying to create an application that could dynamically create additional windows. Each window will be drawn to using Vulkan and I know that this means that each window will have to contain it's own SwapChain resources (image views, framebuffers, etc.) and graphics pipeline (as it is references the swap chain's extents). I am wondering if each window will also have to remember its own present queue family or if I can assume that the same queue family can be used for each window. Specifically to find a present queue family you need to find out if a particular queue family supports surface presentation using:</p>
  <pre><code>VkResult vkGetPhysicalDeviceSurfaceSupportKHR(
      VkPhysicalDevice physicalDevice, 
      uint32_t queueFamilyIndex, 
      VkSurfaceKHR surface, 
      VkBool32* pSupported);
  </code></pre>
  <p>This requires a <code>VkSurfaceKHR</code> and thus the <code>HWND</code> and <code>HINSTANCE</code> of a particular window, but I'm not sure if the present queue family is likely to change between different windows created by the same operating system or if I can safely use the same one for each window.</p>
  <p>Similarly while reviewing <a href="https://vulkan-tutorial.com/Drawing_a_triangle/Swap_chain_recreation" rel="nofollow noreferrer">swap chain recreation within the vulkan-tutorial</a> I read that <code>VKSurfaceFormatKHR::format</code> rarely changes during window resize and that is the only reason the <strong>render pass</strong> needs to be reconstructed during the window resizing operation. How safe would it be to skip the render pass recreation in this step during window resizing and how well could the same render pass be used for different windows?</p>
  <p>If each window uses a similar graphics pipeline, more specifically uses the same synchronization objects, would it be typical to have each window append to the same command buffer and use a single <code>vkQueueSubmit</code>? I only ask because you need to create a command buffer for each frame in flight, and thus the number of command buffers required would be <code>numWindows * numFramesInFlight</code> which feels excessive, but I'm not sure if it would be any different from a single large command buffer (appended to by each window) per frame in flight.</p>
  <p>As an aside, the resources for drawing to multiple windows using Vulkan seems to be fairly scarce, so if anyone knows of any good ones I would greatly appreciate it.</p>