Reputation: 13886
Let's just say I have different versions of render passes depending on how many views/layers I want to render to, let's say 1 (for normal single-plane rendering), 2 (for VR), and 6 for cubemaps. So for each render pass type I might have these three sub-types. Each sub-type has this information given to create the render pass:
typedef struct VkRenderPassMultiviewCreateInfo {
VkStructureType sType;
const void* pNext;
uint32_t subpassCount;
const uint32_t* pViewMasks;
uint32_t dependencyCount;
const int32_t* pViewOffsets;
uint32_t correlationMaskCount;
const uint32_t* pCorrelationMasks;
} VkRenderPassMultiviewCreateInfo;
My question is, when we create a graphics pipeline you have to give a sub-pass. Does filling the above struct with different information result in the sub-passes in the render pass created not compatible with each other? And so necessitating the creation of separate graphics pipeline objects for each of the multiview types?
Upvotes: 0
Views: 1625
Reputation: 473302
With certain very minor exceptions (view count not being one of them), if the render passes are different, then you must use a different pipeline.
It should also be noted that multiview and layered rendering use the same underlying resources. That is, multiview is a form of layered rendering. As such, if a render pass/pipeline expects multiview, it cannot use layered rendering for non-multiview purposes. That is, in multiview each layer you render to is considered a "view" for multiview purposes. Which means that it automatically routes primitives to specific layers based on the view mask (all rendering commands in a multi-view subpass are automatically repeated for multiple views, and you're not allowed to write to Layer
). In layered rendering, it's up to the user code to which layer(s) a rendering command renders to)
Lastly, let us look at dynamic rendering in Vulkan 1.3 (aka: rendering without a render pass). With this feature, you don't have to build a render pass, and pipelines meant to be used for such rendering are not built against a render pass. However, this won't exactly fix your problem.
Even though you aren't building your pipelines against an entire VkRenderPass
structure, you still need to give the pipeline some idea of what you're rendering to. This is provided by the VkPipelineRenderingCreateInfo
at pipeline creation time. Among other things, this struct specifies the viewMask
for that subpass.
And this value must exactly match the value you used with vkCmdBeginRendering
. So you will need pipelines to be built against a specific multiview setup, and therefore, you will need separate pipelines for each multiview setup.
Single-view rendering should not be considered a special case of multi-view rendering. They are two different ways of rendering.
Upvotes: 1