Null render target in MRT setups

Hi all,

I’m trying to MRT render but with a bubble in the render targets. So for example writing to RT0 and RT2 (but NOT to RT1).
Note that I cannot change the shader atm and I do not have the render target that would go into slot 1 available (so VkColorComponentFlagBits is not an option).
I want to bind my RTs so that they have the following layout: RT0 - NULL - RT2 (something that works fine on different rendering APIs).

Can somebody point me into the right direction on how to setup the renderpasses and frame buffers?
I used VK_ATTACHMENT_UNUSED in the VkSubpassDescription for item 1 but what do I do with the VkAttachmentDescription (as provided to VkRenderPassCreateInfo) of that slot ? I tried to simply zero the struct but that does not work as the validation layer does not accept VK_FORMAT_UNDEFINED (among other validation errors).
Same question on how to handle that empty slot during the frame buffer creation. Inserting a VK_NULL_HANDLE view into the attachments of VkFramebufferCreateInfo does not work (crash but it is actually against the spec).

Anybody here has tips on how to proceed ?
Is it even allowed/possible to have a null RT inside a MRT setup ?


Is it even allowed/possible to have a null RT inside a MRT setup ?

No. If you create a render pass with some set of attachments, Vulkan assumes that you are serious about rendering to those attachments. Therefore, you can’t sometimes render to attachments and sometimes not with the same render pass.

Now, you can use a dummy image, set the write mask for that output to nothing, and then have your shader simply not write to it. But the attachment has to exist; the members of VkFramebufferCreatInfo::pAttachments must be valid VkImages, and therefore cannot be VK_NULL_HANDLE.