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

Subpass description.

Wraps a VkSubpassDescription2. This class is subsequently passed to a RenderPass, see its documentation for a high-level usage information.

Compatibility with VkSubpassDescription

While the class operates on the VkSubpassDescription2 structure that's new in Vulkan 1.2 or is provided by the KHR_create_renderpass2 extension, conversion from and to VkSubpassDescription is provided to some extent — you can create a SubpassDescription from it, call various methods on the instance and then get a VkSubpassDescription back again using vkSubpassDescription(). Note that, because of the nested data references, some internal pointers may still point to the originating instance, so be sure to keep it in scope for as long as needed.

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

Please note that the conversion to VkSubpassDescription will ignore all fields that are present only in VkSubpassDescription2 and its substructures — 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.

Public types

enum class Flag: UnsignedInt { }
Subpass description flag.
using Flags = Containers::EnumSet<Flag>
Subpass description flags.

Constructors, destructors, conversion operators

SubpassDescription(Flags flags = {}) explicit
Constructor.
SubpassDescription(NoInitT) explicit noexcept
Construct without initializing the contents.
SubpassDescription(const VkSubpassDescription2& description) explicit
Construct from existing data.
SubpassDescription(const VkSubpassDescription& description) explicit
Construct from a VkSubpassDescription
SubpassDescription(const SubpassDescription&) deleted
Copying is not allowed.
SubpassDescription(SubpassDescription&& other) noexcept
Move constructor.
operator const VkSubpassDescription2*() const
operator const VkSubpassDescription2&() const

Public functions

auto operator=(const SubpassDescription&) -> SubpassDescription& deleted
Copying is not allowed.
auto operator=(SubpassDescription&& other) -> SubpassDescription& noexcept
Move assignment.
auto setInputAttachments(Containers::ArrayView<const AttachmentReference> attachments) & -> SubpassDescription&
Set input attachments.
auto setInputAttachments(Containers::ArrayView<const AttachmentReference> attachments) && -> SubpassDescription&&
auto setInputAttachments(std::initializer_list<AttachmentReference> attachments) & -> SubpassDescription&
auto setInputAttachments(std::initializer_list<AttachmentReference> attachments) && -> SubpassDescription&&
auto setColorAttachments(Containers::ArrayView<const AttachmentReference> attachments, Containers::ArrayView<const AttachmentReference> resolveAttachments = {}) & -> SubpassDescription&
Set color attachments.
auto setColorAttachments(Containers::ArrayView<const AttachmentReference> attachments, Containers::ArrayView<const AttachmentReference> resolveAttachments = {}) && -> SubpassDescription&&
auto setColorAttachments(std::initializer_list<AttachmentReference> attachments, std::initializer_list<AttachmentReference> resolveAttachments = {}) & -> SubpassDescription&
auto setColorAttachments(std::initializer_list<AttachmentReference> attachments, std::initializer_list<AttachmentReference> resolveAttachments = {}) && -> SubpassDescription&&
auto setDepthStencilAttachment(AttachmentReference attachment) & -> SubpassDescription&
Set depth/stencil attachment.
auto setDepthStencilAttachment(AttachmentReference attachment) && -> SubpassDescription&&
auto setPreserveAttachments(Containers::ArrayView<const UnsignedInt> attachments) & -> SubpassDescription&
Set preserve attachments.
auto setPreserveAttachments(Containers::ArrayView<const UnsignedInt> attachments) && -> SubpassDescription&&
auto setPreserveAttachments(Containers::Array<UnsignedInt>&& attachments) & -> SubpassDescription&
auto setPreserveAttachments(Containers::Array<UnsignedInt>&& attachments) && -> SubpassDescription&&
auto setPreserveAttachments(std::initializer_list<UnsignedInt> attachments) & -> SubpassDescription&
auto setPreserveAttachments(std::initializer_list<UnsignedInt> attachments) && -> SubpassDescription&&
auto operator*() -> VkSubpassDescription2&
Underlying VkSubpassDescription2 structure.
auto operator*() const -> const VkSubpassDescription2&
auto operator->() -> VkSubpassDescription2*
auto operator->() const -> const VkSubpassDescription2*
auto vkSubpassDescription() const -> Containers::Array<VkSubpassDescription>
Corresponding VkSubpassDescription structure.

Enum documentation

enum class Magnum::Vk::SubpassDescription::Flag: UnsignedInt

Subpass description flag.

Wraps VkSubpassDescriptionFlagBits.

Typedef documentation

typedef Containers::EnumSet<Flag> Magnum::Vk::SubpassDescription::Flags

Subpass description flags.

Type-safe wrapper for VkSubpassDescriptionFlags.

Function documentation

Magnum::Vk::SubpassDescription::SubpassDescription(Flags flags = {}) explicit

Constructor.

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

Use setInputAttachments(), setColorAttachments(), setDepthStencilAttachment() and setPreserveAttachments() to set attachments. Note that a subpass without any attachment is valid as well.

Magnum::Vk::SubpassDescription::SubpassDescription(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::SubpassDescription::SubpassDescription(const VkSubpassDescription2& description) 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::SubpassDescription::SubpassDescription(const VkSubpassDescription& description) explicit

Construct from a VkSubpassDescription

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

Magnum::Vk::SubpassDescription::operator const VkSubpassDescription2*() 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::SubpassDescription::operator const VkSubpassDescription2&() 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.

SubpassDescription& Magnum::Vk::SubpassDescription::setInputAttachments(Containers::ArrayView<const AttachmentReference> attachments) &

Set input attachments.

Returns Reference to self (for method chaining)

Attachments that are being read from in this subpass. The elements correspond to shader input attachment indices, i.e. a shader input attachment index 5 will read from the attachment specified at offset 5 in this list. Attachment references should use either ImageLayout::General or ImageLayout::ShaderReadOnly; use a default-constructed AttachmentReference to specify that given input will be unused.

The following VkSubpassDescription2 fields are set by this function:

  • inputAttachmentCount and pInputAttachments to a copy of attachments

SubpassDescription&& Magnum::Vk::SubpassDescription::setInputAttachments(Containers::ArrayView<const AttachmentReference> attachments) &&

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

SubpassDescription& Magnum::Vk::SubpassDescription::setInputAttachments(std::initializer_list<AttachmentReference> attachments) &

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

SubpassDescription&& Magnum::Vk::SubpassDescription::setInputAttachments(std::initializer_list<AttachmentReference> attachments) &&

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

SubpassDescription& Magnum::Vk::SubpassDescription::setColorAttachments(Containers::ArrayView<const AttachmentReference> attachments, Containers::ArrayView<const AttachmentReference> resolveAttachments = {}) &

Set color attachments.

Returns Reference to self (for method chaining)

Color attachments that are being written to in this subpass. The resolveAttachments list is expected to be either empty or have the same size as attachments. If non-empty, each item has to have the same format as the corresponding item in attachments.

The elements correspond to shader color attachment indices, i.e. a shader output attachment index 5 will write from the attachment specified at offset 5 in this list. Attachment references should use either ImageLayout::General or ImageLayout::ColorAttachment; use a default-constructed AttachmentReference to specify that given output will be unused.

The following VkSubpassDescription2 fields are set by this function:

  • colorAttachmentCount and pColorAttachments to a copy of attachments
  • pResolveAttachments to a copy of resolveAttachments, if the parameter is non-empty

SubpassDescription&& Magnum::Vk::SubpassDescription::setColorAttachments(Containers::ArrayView<const AttachmentReference> attachments, Containers::ArrayView<const AttachmentReference> resolveAttachments = {}) &&

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

SubpassDescription& Magnum::Vk::SubpassDescription::setColorAttachments(std::initializer_list<AttachmentReference> attachments, std::initializer_list<AttachmentReference> resolveAttachments = {}) &

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

SubpassDescription&& Magnum::Vk::SubpassDescription::setColorAttachments(std::initializer_list<AttachmentReference> attachments, std::initializer_list<AttachmentReference> resolveAttachments = {}) &&

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

SubpassDescription& Magnum::Vk::SubpassDescription::setDepthStencilAttachment(AttachmentReference attachment) &

Set depth/stencil attachment.

Returns Reference to self (for method chaining)

Depth/stencil attachment that is being written to in this subpass. The attachment reference should use either ImageLayout::General or ImageLayout::DepthStencilAttachment; calling this function with a default-constructed AttachmentReference is equivalent to not calling it at all, and both mean there's no depth/stencil attachment.

The following VkSubpassDescription2 fields are set by this function:

  • pDepthStencilAttachment to a copy of attachment

SubpassDescription&& Magnum::Vk::SubpassDescription::setDepthStencilAttachment(AttachmentReference attachment) &&

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

SubpassDescription& Magnum::Vk::SubpassDescription::setPreserveAttachments(Containers::ArrayView<const UnsignedInt> attachments) &

Set preserve attachments.

Returns Reference to self (for method chaining)

Attachments that are not read or written by the subpass but have to be preserved throughout the subpass. The attachment values are indices into the list passed to RenderPassCreateInfo::setAttachments().

The following VkSubpassDescription2 fields are set by this function:

  • preserveAttachmentCount and pPreserveAttachments to a copy of attachments

SubpassDescription&& Magnum::Vk::SubpassDescription::setPreserveAttachments(Containers::ArrayView<const UnsignedInt> attachments) &&

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

SubpassDescription& Magnum::Vk::SubpassDescription::setPreserveAttachments(Containers::Array<UnsignedInt>&& attachments) &

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

SubpassDescription&& Magnum::Vk::SubpassDescription::setPreserveAttachments(Containers::Array<UnsignedInt>&& attachments) &&

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

SubpassDescription& Magnum::Vk::SubpassDescription::setPreserveAttachments(std::initializer_list<UnsignedInt> attachments) &

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

SubpassDescription&& Magnum::Vk::SubpassDescription::setPreserveAttachments(std::initializer_list<UnsignedInt> attachments) &&

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

const VkSubpassDescription2& Magnum::Vk::SubpassDescription::operator*() const

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

VkSubpassDescription2* Magnum::Vk::SubpassDescription::operator->()

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

const VkSubpassDescription2* Magnum::Vk::SubpassDescription::operator->() const

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

Containers::Array<VkSubpassDescription> Magnum::Vk::SubpassDescription::vkSubpassDescription() const

Corresponding VkSubpassDescription structure.

Provided for compatibility with Vulkan implementations that don't support version 1.2 or the KHR_create_renderpass2 extension. Because the type references structures not present in VkSubpassDescription2, it's returned wrapped it in a single-item array with the extra data appended at the end of the allocation. Note that, however, some internal pointers such as pPreserveAttachments may still point to the originating SubpassDescription instance, the returned allocation is not completely standalone. See Compatibility with VkSubpassDescription for more information.