Magnum::Vk::Framebuffer class new in Git master


Wraps a VkFramebuffer, which connects a RenderPass together with concrete ImageViews for attachments.

Framebuffer creation

A framebuffer is created using FramebufferCreateInfo that takes a previously-created RenderPass together with ImageViews onto Images of desired sizes and compatible formats for all its attachments:

#include <Magnum/Vk/FramebufferCreateInfo.h>

Vk::Image color{device, Vk::ImageCreateInfo2D{               /* created before */
    Vk::PixelFormat::RGBA8Unorm, size, 1}, };
Vk::Image depth{device, Vk::ImageCreateInfo2D{
    Vk::PixelFormat::Depth24UnormStencil8UI, size, 1}, };
Vk::ImageView colorView{device, Vk::ImageViewCreateInfo2D{color}};
Vk::ImageView depthView{device, Vk::ImageViewCreateInfo2D{depth}};

Vk::RenderPass renderPass{device, Vk::RenderPassCreateInfo{} /* created before */
        Vk::AttachmentDescription{color.format(), },
        Vk::AttachmentDescription{depth.format(), },

Vk::Framebuffer framebuffer{device, Vk::FramebufferCreateInfo{renderPass, {
}, size}};

Public static functions

static auto wrap(Device& device, VkFramebuffer handle, const Vector3i& size, HandleFlags flags = {}) -> Framebuffer
Wrap existing Vulkan handle.

Constructors, destructors, conversion operators

Framebuffer(Device& device, const FramebufferCreateInfo& info) explicit
Framebuffer(NoCreateT) explicit
Construct without creating the framebuffer.
Framebuffer(const Framebuffer&) deleted
Copying is not allowed.
Framebuffer(Framebuffer&& other) noexcept
Move constructor.
operator VkFramebuffer()

Public functions

auto operator=(const Framebuffer&) -> Framebuffer& deleted
Copying is not allowed.
auto operator=(Framebuffer&& other) -> Framebuffer& noexcept
Move assignment.
auto handle() -> VkFramebuffer
Underlying VkFramebuffer handle.
auto handleFlags() const -> HandleFlags
Handle flags.
auto size() const -> Vector3i
Framebuffer size.
auto release() -> VkFramebuffer
Release the underlying Vulkan framebuffer.

Function documentation

static Framebuffer Magnum::Vk::Framebuffer::wrap(Device& device, VkFramebuffer handle, const Vector3i& size, HandleFlags flags = {})

Wrap existing Vulkan handle.

device Vulkan device the framebuffer is created on
handle The VkFramebuffer handle
size Width, height and layer count of the framebuffer. Available through size() afterwards.
flags Handle flags

The handle is expected to be originating from device. The size parameter is used for convenience RenderPass recording later. If it's unknown, pass a default-constructed value — you will then be able to only being a render pass by specifying a concrete size in RenderPassBeginInfo.

Unlike a framebuffer created using a constructor, the Vulkan framebuffer is by default not deleted on destruction, use flags for different behavior.

Magnum::Vk::Framebuffer::Framebuffer(Device& device, const FramebufferCreateInfo& info) explicit


device Vulkan device to create the framebuffer on
info Framebuffer creation info

Magnum::Vk::Framebuffer::Framebuffer(NoCreateT) explicit

Construct without creating the framebuffer.

The constructed instance is equivalent to moved-from state. Useful in cases where you will overwrite the instance later anyway. Move another object over it to make it useful.



Destroys associated VkFramebuffer handle, unless the instance was created using wrap() without HandleFlag::DestroyOnDestruction specified.

Magnum::Vk::Framebuffer::operator VkFramebuffer()

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

VkFramebuffer Magnum::Vk::Framebuffer::release()

Release the underlying Vulkan framebuffer.

Releases ownership of the Vulkan framebuffer and returns its handle so vkDestroyFramebuffer() is not called on destruction. The internal state is then equivalent to moved-from state.