Rendering two windows

Hi! I want to render on two windows. What are some stuff that I should share, and what stuffs should I separate? It seems that I need two sets of MVP matrices and camera positions, both of which I 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 just need two viewers.
Should I approach this as what can be shared? or would you recommend approaching the problem from finding what needs to be separated?
New logical and physical device?

I find this question too general. Probably there are different approaches to this, depending upon what the application will do. I haven’t rendered in two windows simultaneously, so I cannot say much, but this is what I would try out for starters:
Shared elements: VkInstance, VkPhysicalDevice, VkDevice.
Non-shared elements: window, VkSurface, VkQueue, swap chain, VkRenderPass, descriptors (layout, pool, set), graphics pipeline, command buffer.
After finding a good configuration that works, you can can modify it in a way that works best for your applicaton.

Thank you! I wil be using the same data for both windows, and is it necessary for separate descriptors? why would you hope for different vkrenderPasses?

I want to imitate how two users use this same program to watch the 3D scenes with my own computer. I want to create a new window and do the exact same things as the other window, and let the two windows render samultaneously with two different camera positions and MVP matrices.

In the case of two windows that render the same thing from different point of view I think you can share vkRenderPass.

About descriptor sets, this is how I work with them: Each window has its own set of swap chain images, and each model to render has one descriptor set for each swap chain image (the M or V matrix may change between frames). Since each window requires a different MVP for the same object (because the V matrix is different), I would have a different set of descriptor sets for each object for each window.

Maybe you can use the same descriptor set, containing two MVP matrices, for both windows, but I think that you would have to indicate to the shader which MVP applies.

1 Like

Any separation is entirely up to you and your needs, since you can have the same device use both surfaces/swapchains. There is no “sharing” because they’re all just commands.

You could build the CBs for both render targets simultaneously. That is, you could iterate over the scene once, generating commands for each render target. How you arrange your code is up to you.

1 Like

You could use the multiview feature : VK_KHR_multiview(3)

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.