Search code examples
vulkan

Can you attach a null image view handle to a framebuffer?


My depth buffer goes in attachment 0, and colour in attachment 1. If I don't want a depth buffer can I attach a null image view handle to the framebuffer in the first attachment [0], and then with the render pass set the pDepthAttachment to nullptr? And also vice-versa, in the framebuffer have a depth image view at [0], and a null image view at [1]. And in the render pass set the pDepthAttachment to a reference with attachment [0] (the depth buffer), and set a reference at pColourAttachment with on reference that specifies attachment 1?

In other words can any image views in the framebuffer attachments be null? If it can't then that makes the whole VK_ATTACHMENT_UNUSED rather limiting, as you'd always need to attach SOME image view.


Solution

  • From the Valid Usage rules for VkFramebufferCreateInfo:

    If flags does not include VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT and attachmentCount is not 0, pAttachments must be a valid pointer to an array of attachmentCount valid VkImageView handles

    Emphasis not added.