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

Attachment reference.

Wraps a VkAttachmentReference2. Used to reference attachments inside a SubpassDescription, which is subsequently passed to a RenderPass. See its documentation for a high-level overview.

Compatibility with VkAttachmentReference

While the class operates on the VkAttachmentReference2 structure that's new in Vulkan 1.2 or is provided by the KHR_create_renderpass2 extension, conversion from and to VkAttachmentReference is provided to some extent — you can create an AttachmentReference from it, call various methods on the instance and then get a VkAttachmentReference back again using vkAttachmentReference().

For direct editing of the Vulkan structure, it's recommended to edit the VkAttachmentReference2 fields and then perform the conversion instead of editing the resulting VkAttachmentReference, as additional safety checks may be done during the conversion to ensure no information is lost.

Please note that the conversion to VkAttachmentReference will ignore all fields that are present only in VkAttachmentReference2 — in particular, the whole pNext pointer chain is omitted. When performing the conversion it's your responsibility to ensure nothing significant was in the fields that were left out.

Constructors, destructors, conversion operators

AttachmentReference(UnsignedInt attachment, ImageLayout layout) explicit
Constructor.
AttachmentReference()
Construct with no attachment.
AttachmentReference(NoInitT) explicit noexcept
Construct without initializing the contents.
AttachmentReference(const VkAttachmentReference2& reference) explicit
Construct from existing data.
AttachmentReference(const VkAttachmentReference& reference) explicit
Construct from a VkAttachmentReference
operator const VkAttachmentReference2*() const
operator const VkAttachmentReference2&() const

Public functions

auto operator*() -> VkAttachmentReference2&
Underlying VkAttachmentReference2 structure.
auto operator*() const -> const VkAttachmentReference2&
auto operator->() -> VkAttachmentReference2*
auto operator->() const -> const VkAttachmentReference2*
auto vkAttachmentReference() const -> VkAttachmentReference
Corresponding VkAttachmentReference structure.

Function documentation

Magnum::Vk::AttachmentReference::AttachmentReference(UnsignedInt attachment, ImageLayout layout) explicit

Constructor.

Parameters
attachment Attachment index from the list passed to RenderPassCreateInfo::setAttachments()
layout Image layout. Should correspond to what's passed to initialLayout and finalLayout in AttachmentDescription constructor.

The following VkAttachmentReference2 fields are pre-filled in addition to sType, everything else is zero-filled:

  • attachment
  • layout

Magnum::Vk::AttachmentReference::AttachmentReference()

Construct with no attachment.

The following VkAttachmentReference2 fields are pre-filled in addition to sType, everything else is zero-filled:

Magnum::Vk::AttachmentReference::AttachmentReference(NoInitT) explicit noexcept

Construct without initializing the contents.

Note that not even the sType field is set — the structure has to be fully initialized afterwards in order to be usable.

Magnum::Vk::AttachmentReference::AttachmentReference(const VkAttachmentReference2& reference) explicit

Construct from existing data.

Copies the existing values verbatim, pointers are kept unchanged without taking over the ownership. Modifying the newly created instance will not modify the original data nor the pointed-to data.

Magnum::Vk::AttachmentReference::AttachmentReference(const VkAttachmentReference& reference) explicit

Construct from a VkAttachmentReference

Compared to the above, fills the common subset of VkAttachmentReference2, sets sType and zero-fills pNext and aspectMask.

Magnum::Vk::AttachmentReference::operator const VkAttachmentReference2*() const

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

Magnum::Vk::AttachmentReference::operator const VkAttachmentReference2&() const

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

The class is implicitly convertible to a reference in addition to a pointer because the type is commonly used in arrays as well, which would be annoying to do with a pointer conversion.

const VkAttachmentReference2& Magnum::Vk::AttachmentReference::operator*() const

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

VkAttachmentReference2* Magnum::Vk::AttachmentReference::operator->()

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

const VkAttachmentReference2* Magnum::Vk::AttachmentReference::operator->() const

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

VkAttachmentReference Magnum::Vk::AttachmentReference::vkAttachmentReference() const

Corresponding VkAttachmentReference structure.

Provided for compatibility with Vulkan implementations that don't support version 1.2 or the KHR_create_renderpass2 extension. See Compatibility with VkAttachmentReference for more information.