4#include <vulkan/vulkan.h>
18 std::same_as<T, AttachmentDescription::BoundAttachmentDescription> || std::same_as<T, std::pair<AttachmentDescription::BoundAttachmentDescription, bool>>;
40 Subpass(VkPipelineBindPoint bindPoint = VkPipelineBindPoint::VK_PIPELINE_BIND_POINT_GRAPHICS,
const BA&... boundAttachments) : subpass{} {
42 buildAttachmentsTypesArrays(boundAttachments...);
45 subpass.pipelineBindPoint = bindPoint;
46 subpass.inputAttachmentCount = inputRefs.size();
47 subpass.pInputAttachments = inputRefs.empty() ? nullptr : inputRefs.data();
48 subpass.colorAttachmentCount = colorRefs.size();
49 subpass.pColorAttachments = colorRefs.empty() ? nullptr : colorRefs.data();;
50 subpass.pDepthStencilAttachment = depthStencilRefs.empty() ? nullptr : depthStencilRefs.data();;
51 subpass.preserveAttachmentCount = preserveRefs.size();
52 subpass.pPreserveAttachments = preserveRefs.empty() ? nullptr : preserveRefs.data();
61 Subpass(VkSubpassDescription baseSubpass) : subpass{ baseSubpass } {}
80 std::vector<VkPipelineColorBlendAttachmentState> result;
81 for (
const auto& acbm : colorBlendingModes) {
82 result.push_back(+acbm);
91 void buildAttachmentsTypesArrays(
const BA&... boundAttachments) {
93 std::vector<std::pair<AttachmentDescription::BoundAttachmentDescription, bool>> parsedBoundAttachments;
94 (parsedBoundAttachments.push_back(parseBoundAttachment(boundAttachments)), ...);
97 for (
const auto& boundAttachment : parsedBoundAttachments) {
99 if (boundAttachment.second) {
100 preserveRefs.push_back(boundAttachment.first.getAttachmentReferenceIndex());
104 switch (boundAttachment.first.getType()) {
106 inputRefs.push_back(boundAttachment.first.getAttachmentReference());
109 colorRefs.push_back(boundAttachment.first.getAttachmentReference());
110 colorBlendingModes.push_back(boundAttachment.first.getColorBlendingMode());
113 depthStencilRefs.push_back(boundAttachment.first.getAttachmentReference());
125 static std::pair<AttachmentDescription::BoundAttachmentDescription, bool> parseBoundAttachment(
const AttachmentDescription::BoundAttachmentDescription& boundAttachment) {
126 return { boundAttachment,
false };
130 static std::pair<AttachmentDescription::BoundAttachmentDescription, bool> parseBoundAttachment(
const std::pair<AttachmentDescription::BoundAttachmentDescription, bool>& boundAttachment) {
131 return { boundAttachment.first, boundAttachment.second };
135 VkSubpassDescription subpass;
138 std::vector<VkAttachmentReference> inputRefs;
139 std::vector<VkAttachmentReference> colorRefs;
140 std::vector<VkAttachmentReference> depthStencilRefs;
142 std::vector<uint32_t> preserveRefs;
144 std::vector<AttachmentColorBlendingMode> colorBlendingModes;
A Subpass is a step of a RenderPass.
Definition: Subpass.h:28
Subpass(VkSubpassDescription baseSubpass)
Creates a Subpass starting from the underlying Vulkan object.
Definition: Subpass.h:61
const VkSubpassDescription & operator+()
Returns the underlying Vulkan VkSubpassDescription.
Definition: Subpass.h:69
std::vector< VkPipelineColorBlendAttachmentState > getColorBlendingDescriptors() const
Returns the VkPipelineColorBlendAttachmentState descriptors of the color attachments of this subpass.
Definition: Subpass.h:79
Subpass(VkPipelineBindPoint bindPoint=VkPipelineBindPoint::VK_PIPELINE_BIND_POINT_GRAPHICS, const BA &... boundAttachments)
Creates a Subpass with the specified attachments.
Definition: Subpass.h:40
Generic runtime exception thrown by Vulkan-related functions.
Definition: VulkanException.h:13
Definition: Attachment.h:11