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.


1 Answer 1


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.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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