Lugdunum  0.1.0
RenderPass.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <list>
4 
6 
7 namespace lug {
8 namespace Graphics {
9 namespace Vulkan {
10 namespace API {
11 
12 class Device;
13 
14 namespace Builder {
15 
16 class RenderPass {
17 public:
18  using AttachmentIndex = const VkAttachmentDescription*;
19  using SubpassIndex = const VkSubpassDescription*;
20 
23  VkImageLayout layout{VK_IMAGE_LAYOUT_UNDEFINED};
24  };
25 
27  VkPipelineBindPoint pipelineBindPoint{VK_PIPELINE_BIND_POINT_GRAPHICS};
28  std::vector<AttachmentReference> inputAttachments{};
29  std::vector<AttachmentReference> colorAttachments{};
30  std::vector<AttachmentReference> resolveAttachments{};
31  AttachmentReference depthStencilAttachment{};
32  std::vector<AttachmentIndex> preserveAttachments{};
33  };
34 
36  SubpassIndex srcSubpass{nullptr};
37  SubpassIndex dstSubpass{nullptr};
38  VkPipelineStageFlags srcStageMask{0};
39  VkPipelineStageFlags dstStageMask{0};
40  VkAccessFlags srcAccessMask{0};
41  VkAccessFlags dstAccessMask{0};
42  VkDependencyFlags dependencyFlags{0};
43  };
44 
45 public:
46  RenderPass(const API::Device& device);
47 
48  RenderPass(const RenderPass&) = delete;
49  RenderPass(RenderPass&&) = delete;
50 
51  RenderPass& operator=(const RenderPass&) = delete;
52  RenderPass& operator=(RenderPass&&) = delete;
53 
54  ~RenderPass() = default;
55 
56  // Setters
57  AttachmentIndex addAttachment(const VkAttachmentDescription& attachmentDescription);
58  SubpassIndex addSubpass(const SubpassDescription& subpassDescription);
59  void addSubpassDependency(const SubpassDependency& subpassDependency);
60 
61  // Build methods
62  bool build(API::RenderPass& instance, VkResult* returnResult = nullptr);
63  std::unique_ptr<API::RenderPass> build(VkResult* returnResult = nullptr);
64 
65 private:
67  std::vector<VkAttachmentReference> inputAttachments;
68  std::vector<VkAttachmentReference> colorAttachments;
69  std::vector<VkAttachmentReference> resolveAttachments;
70  VkAttachmentReference depthStencilAttachment;
71  std::vector<uint32_t> preserveAttachments;
72  };
73 
74 private:
76 
77  std::list<VkAttachmentDescription> _attachments;
78  std::list<VkSubpassDescription> _subpasses;
79  std::list<SubpassResources> _subpassesResources;
80  std::list<VkSubpassDependency> _dependencies;
81 };
82 
83 } // Builder
84 } // API
85 } // Vulkan
86 } // Graphics
87 } // lug
bool build(API::RenderPass &instance, VkResult *returnResult=nullptr)
Definition: RenderPass.cpp:122
AttachmentIndex addAttachment(const VkAttachmentDescription &attachmentDescription)
Definition: RenderPass.cpp:16
std::list< VkSubpassDescription > _subpasses
Definition: RenderPass.hpp:78
std::list< VkAttachmentDescription > _attachments
Definition: RenderPass.hpp:77
SubpassIndex addSubpass(const SubpassDescription &subpassDescription)
Definition: RenderPass.cpp:21
const VkSubpassDescription * SubpassIndex
Definition: RenderPass.hpp:19
const VkAttachmentDescription * AttachmentIndex
Definition: RenderPass.hpp:18
void addSubpassDependency(const SubpassDependency &subpassDependency)
Definition: RenderPass.cpp:94
std::list< VkSubpassDependency > _dependencies
Definition: RenderPass.hpp:80
std::list< SubpassResources > _subpassesResources
Definition: RenderPass.hpp:79
RenderPass & operator=(const RenderPass &)=delete