Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between framebuffer and image in Vulkan?

I've known that framebuffer is the final destination of the rendering pipeline and swapchain contains many image. So what is the relation between those two things? Which one is the actual render target? And does the framebuffer later attach the final picture of the current frame on the image view? If so, how will it transfer?

Describing this via paint or diagram would be pleased.

like image 634
EkBumYe Avatar asked Sep 18 '16 11:09

EkBumYe


People also ask

What is framebuffer in Vulkan?

Framebuffers represent a collection of memory attachments that are used by a render pass instance. Examples of these memory attachments include the color image buffers and depth buffer that we created in previous samples.

What is an image in Vulkan?

Images are the other “storage” type that Vulkan has, besides Buffers. Unlike buffers, images are more complicated due to all the logic they manage, and their settings. A VkImage is what holds the actual texture data.

What are Swapchain images?

The swap chain is essentially a queue of images that are waiting to be presented to the screen. Our application will acquire such an image to draw to it, and then return it to the queue.

What is an attachment in Vulkan?

But if we want to be fully correct: images are specific Vulkan resources that can be used for many purposes (descriptors/textures, attachments, staging resources); attachments are descriptions of resources used during rendering.

What is a framebuffer object in vkimageview?

A framebuffer object references all of the VkImageView objects that represent the attachments. In our case that will be only a single one: the color attachment. However, the image that we have to use for the attachment depends on which image the swap chain returns when we retrieve one for presentation.

What is a framebuffer?

A framebuffer is an array of multiple different images. But this definition, or at least to me, sounds more like what a swapchain is: a series of framebuffers.

What are the parameters of an image in Vulkan?

The parameters for an image are specified in a VkImageCreateInfo struct: The image type, specified in the imageType field, tells Vulkan with what kind of coordinate system the texels in the image are going to be addressed. It is possible to create 1D, 2D and 3D images.

What is the difference between a Vulkan shader and a sampler?

When using images in the vulkan API, almost always you will use them through a VkImageView. Samplers hold how exactly the texture is accessed in the shader. They control fixed pipeline state such as mipmap blending or nearest filtering.


Video Answer


2 Answers

  • VkFramebuffer + VkRenderPass defines the render target.

  • Render pass defines which attachment will be written with colors.

  • VkFramebuffer defines which VkImageView is to be which attachment.

  • VkImageView defines which part of VkImage to use.

  • VkImage defines which VkMemory is used and a format of the texel.


Or maybe in opposite sequence:

  • VkMemory is just a sequence of N bytes in memory.

  • VkImage object adds to it e.g. information about the format (so you can address by texels, not bytes).

  • VkImageView object helps select only part (array or mip) of the VkImage (like stringView, arrayView or whathaveyou does). Also can help to match to some incompatible interface (by type casting format).

  • VkFramebuffer binds a VkImageView with an attachment.

  • VkRenderpass defines which attachment will be drawn into

So it's not like you do not use an image. You do, through the Vulkan Framebuffer.

Swapchain image is no different from any other image. Except that the driver is the owner of the image. You can't destroy it directly or allocate it yourself. You just borrow it from the driver for the duration between acquire and present operation.

There's (usually) more of the swapchain images for the purposes of buffering and advance rendering. AFAIK you would need a separate VkFramebuffer for each image (which is annoying, but more in tune with what actually happens underneath).

enter image description here

like image 94
krOoze Avatar answered Sep 19 '22 19:09

krOoze


Probably the best single sentence from the Vulkan spec that describes framebuffers is:

The specific image views that will be used for the attachments, and their dimensions, are specified in VkFramebuffer objects.

Yes, you would need a VkFramebuffer object for each image in a swapchain, but you generally would need to allocate only one VkMemory for a depth buffer VkImage and then add the VkImageView for that single depth buffer VkImage to all of your framebuffers.

like image 37
Karl Schultz Avatar answered Sep 20 '22 19:09

Karl Schultz