Using 2 renderpasses with deffernt number of subpasses on the same framebuffer

I have a framebuffer that was created with a renderpass with one subpass and i want to render to it with a render pass with one subpass and with another renderpass with zero subpasses(I know zero is not allowed. The validation layer yells at me. You can think its 2).

when I use vkCmdBeginRenderPass I get 2 errors:
1.
msgNum: 861854874 - Validation Error: [ VUID-VkRenderPassBeginInfo-renderPass-00904 ] Object 0: handle = 0xf56c9b0000000004, type = VK_OBJECT_TYPE_RENDER_PASS; Object 1: handle = 0xfa21a40000000003, type = VK_OBJECT_TYPE_RENDER_PASS; | MessageID = 0x335edc9a | vkCmdBeginRenderPass: RenderPasses incompatible between render pass w/ VkRenderPass 0xf56c9b0000000004 with a subpassCount of 0 and framebuffer w/ VkRenderPass 0xfa21a40000000003 with a subpassCount of 1. The Vulkan spec states: renderPass must be compatible with the renderPass member of the VkFramebufferCreateInfo structure specified when creating framebuffer

msgNum: 861854874 - Validation Error: [ VUID-VkRenderPassBeginInfo-renderPass-00904 ] Object 0: handle = 0xf56c9b0000000004, type = VK_OBJECT_TYPE_RENDER_PASS; Object 1: handle = 0xfa21a40000000003, type = VK_OBJECT_TYPE_RENDER_PASS; | MessageID = 0x335edc9a | vkCmdBeginRenderPass: RenderPasses incompatible between render pass w/ VkRenderPass 0xf56c9b0000000004 with a dependencyCount of 0 and framebuffer w/ VkRenderPass 0xfa21a40000000003 with a dependencyCount of 1. The Vulkan spec states: renderPass must be compatible with the renderPass member of the VkFramebufferCreateInfo structure specified when creating framebuffer.

My question is how can I render with 2 renderpasses with different number of subpasses.
It makes cense that the number of attachments needs to be the same and other properties like that but why does the number of subpasses needs to be the same and what is the right way to do this?

Pipelines are built against a specific renderpass. You cannot use them with a different renderpass.

i’m not using the same pipeline. I’m using the same frambuffer with differnt renderpasses that has differnt number of subpasses from the framebuffer(the number of subpasses of the render pass that the framebuffer was created with).

Is this allowed? because the first error says not.
which means if i created a framebuffer with a renderpass with only one subpass then all of the renderpasses i have must have only one subpass which is crazy.

Yes, framebuffers created relative to a specific render pass can only be used with a compatible render pass. But framebuffers are not all that important in the grand scheme of things. They don’t own images uniquely; they’re mostly just references to a set of images.

If for some reason you need to have multiple render passes (which based on your other posts, you don’t), then you can just give each one a framebuffer to go with it. Those framebuffers can reference the same image, and that’s fine.

1 Like