Render passes operate in conjunction with framebuffers. Framebuffers represent a collection of specific memory attachments that a render pass instance uses.
Framebuffers are represented by VkFramebuffer
handles:
VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkFramebuffer)
To create a framebuffer, call:
VkResult vkCreateFramebuffer( VkDevice device, const VkFramebufferCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkFramebuffer* pFramebuffer);
device
is the logical device that creates the framebuffer.
pCreateInfo
points to a VkFramebufferCreateInfo
structure
which describes additional information about framebuffer creation.
pAllocator
controls host memory allocation as described in the
Memory Allocation chapter.
pFramebuffer
points to a VkFramebuffer
handle in which the
resulting framebuffer object is returned.
The VkFramebufferCreateInfo
structure is defined as:
typedef struct VkFramebufferCreateInfo { VkStructureType sType; const void* pNext; VkFramebufferCreateFlags flags; VkRenderPass renderPass; uint32_t attachmentCount; const VkImageView* pAttachments; uint32_t width; uint32_t height; uint32_t layers; } VkFramebufferCreateInfo;
sType
is the type of this structure.
pNext
is NULL
or a pointer to an extension-specific structure.
flags
is reserved for future use.
renderPass
is a render pass that defines what render passes the
framebuffer will be compatible with. See
Render Pass Compatibility for details.
attachmentCount
is the number of attachments.
pAttachments
is an array of VkImageView
handles, each of
which will be used as the corresponding attachment in a render pass
instance.
width
, height
and layers
define the dimensions of the
framebuffer.
Image subresources used as attachments must not be used via any non-attachment usage for the duration of a render pass instance.
![]() | Note |
---|---|
This restriction means that the render pass has full knowledge of all uses of all of the attachments, so that the implementation is able to make correct decisions about when and how to perform layout transitions, when to overlap execution of subpasses, etc. |
It is legal for a subpass to use no color or depth/stencil attachments, and
rather use shader side effects such as image stores and atomics to produce
an output. In this case, the subpass continues to use the width
,
height
, and layers
of the framebuffer to define the dimensions
of the rendering area, and the rasterizationSamples
from each
pipeline’s VkPipelineMultisampleStateCreateInfo
to define the number
of samples used in rasterization; however, if
VkPhysicalDeviceFeatures
::variableMultisampleRate
is
VK_FALSE
, then all pipelines to be bound with a given zero-attachment
subpass must have the same value for
VkPipelineMultisampleStateCreateInfo
::rasterizationSamples
.
To destroy a framebuffer, call:
void vkDestroyFramebuffer( VkDevice device, VkFramebuffer framebuffer, const VkAllocationCallbacks* pAllocator);
device
is the logical device that destroys the framebuffer.
framebuffer
is the handle of the framebuffer to destroy.
pAllocator
controls host memory allocation as described in the
Memory Allocation chapter.