1. A framebuffer object ( VkFramebuffer) references all of the VkImageView objects that represent the attachments specified during render pass creation. Essentially, framebuffers provide the attachments that a render pass needs while rendering.
For this part of the tutorial, the only attachment is the color attachment.
But, the image that we have to use for the attachment depends on which image the swap chain returns when we get one for presentation.
This means, we have to create a framebuffer for all of the images in the swap chain and use the one that matches up with the retrieved image at drawing time.
So basically, the VkImageView represents attachments, like the color attachment, and a framebuffer object references a VkImageView object.
VkFramebufferobject --> VkImageView object --> attachments (specified during render pass)
This is kinda confusing, so I found this picture from the LunarG website from a separate tutorial.
For this tutorial, the Swapchain provides a color attachment for each frame/ ImageView object. There is also a depth attachment that is reused with each color attachment for each frame.
The blocks in green show the nature of the attachments (ie. color or depth) described by the Render Pass. Until this part of the tutorial, there was no connection between the Render Pass attachment descriptions with the actual attachments in the Swapchain.
Framebuffers fix this issue. Framebuffers (yellow boxes) associate the actual attachments (the ColorBufferImage0 and ColorBufferImage1 in the Swapchain) with the Render Pass attachment descriptions.
So, to iterate, Framebuffers provide the attachments that a render pass needs while rendering.
The Swapchain contains frames/ImageView objects that contain Image objects. These frames each need an attachment, like a color attachment that describes aspects of the frame. Then, the Render Pass describes what attachments are needed for each frame, but doesn't actually contain the attachments. Finally, Framebuffers take the attachments described by the Render Pass and slot in the attachments found in the Swapchain. In this picture there is also a depth buffer attachment, but we didn't do that in our tutorial yet. Same idea though.