<p>From a cursory examination of the documentation, the following seems apparent.</p>
<p>Vulkan mediates interactions between OS display regions (aka: windows) and a Vulkan application via an object called a <code>VkSurface</code>. If you want to draw to a window, you must create a surface associated with that window. A surface is created from a single window, so there is no way for a surface to be associated with multiple windows.</p>
<p>A surface is associated with a window, but it is also associated with Vulkan. But it is not associated with a specific <code>VkDevice</code>; it is instead associated with a <code>VkInstance</code>. Therefore, a <code>VkSurface</code> can be used (in theory) by any <code>VkDevice</code> created from that instance.</p>
<p>Rendering to a surface is (usually) mediated by a swapchain, which represents a series of images owned by the surface that you can render to and present their contents to that surface. A swapchain is therefore created with a surface, but it is also created with a specific <code>VkDevice</code> which is permitted to use the swapchain and its associated images. A surface can only be associated with a single (non-retired) swapchain.</p>
<p><em>However</em>, there does not appear to be any rule in Vulkan which requires that a <code>VkDevice</code> can only be associated with a <em>single</em> swapchain at a time. That is, it seems entire reasonable to have a single <code>VkDevice</code> that renders to multiple windows, each through their own swapchain.</p>
<p>Now, you might wish to create multiple graphics queues (where possible), so that one window does not have to wait on presentation from another window.</p>

CC BY-SA 4.0
2022-06-07T15:27:38.400Z
2022-06-07T15:27:38.400Z
Nicol Bolas
<p>I want to render on two windows. What are some stuffs that I should share, and what stuffs should I separate? I have a rendering program in Vulkan and want to add a window to it. It seems that I need two sets of MVP matrices and camera positions, both of which I already put in one uniform struct. I would imagine that I need to create a new instance of window and camera, but do I need another pipeline for this? how about command buffers? The data input is exactly the same for the two windows. I think all the uniforms and vertex data are the same except MVP matrices and camera positions.</p>

<vulkan>
rendering in two windows
Lily
# rendering in two windows

(Asked by: username_0 on 2022-06-07)

I want to render on two windows. What are some stuffs that I should share, and what stuffs should I separate? I have a rendering program in Vulkan and want to add a window to it. It seems that I need two sets of MVP matrices and camera positions, both of which I already put in one uniform struct. I would imagine that I need to create a new instance of window and camera, but do I need another pipeline for this? how about command buffers? The data input is exactly the same for the two windows. I think all the uniforms and vertex data are the same except MVP matrices and camera positions.

**Tags:** vulkan


---

## 1 answers

### Answer by username_1 on 2022-06-07. Score: 2

From a cursory examination of the documentation, the following seems apparent.

Vulkan mediates interactions between OS display regions (aka: windows) and a Vulkan application via an object called a `VkSurface`. If you want to draw to a window, you must create a surface associated with that window. A surface is created from a single window, so there is no way for a surface to be associated with multiple windows.

A surface is associated with a window, but it is also associated with Vulkan. But it is not associated with a specific `VkDevice`; it is instead associated with a `VkInstance`. Therefore, a `VkSurface` can be used (in theory) by any `VkDevice` created from that instance.

Rendering to a surface is (usually) mediated by a swapchain, which represents a series of images owned by the surface that you can render to and present their contents to that surface. A swapchain is therefore created with a surface, but it is also created with a specific `VkDevice` which is permitted to use the swapchain and its associated images. A surface can only be associated with a single (non-retired) swapchain.

*However*, there does not appear to be any rule in Vulkan which requires that a `VkDevice` can only be associated with a *single* swapchain at a time. That is, it seems entire reasonable to have a single `VkDevice` that renders to multiple windows, each through their own swapchain.

Now, you might wish to create multiple graphics queues (where possible), so that one window does not have to wait on presentation from another window.


---

