PixelBullet  0.0.1
A C++ game engine
Loading...
Searching...
No Matches
Renderpass.hpp
1#pragma once
2
3#include <volk.h>
4
5#include <optional>
6#include <vector>
7
8namespace PixelBullet
9{
10 class LogicalDevice;
11 class RenderStage;
12
14 {
15 public:
17 {
18 public:
19 SubpassDescription(VkPipelineBindPoint bindPoint, std::vector<VkAttachmentReference> colorAttachments,
20 const std::optional<uint32_t>& depthAttachment)
21 : m_ColorAttachments(std::move(colorAttachments))
22 {
23 m_SubpassDescription.pipelineBindPoint = bindPoint;
24 m_SubpassDescription.colorAttachmentCount = static_cast<uint32_t>(this->m_ColorAttachments.size());
25 m_SubpassDescription.pColorAttachments =
26 this->m_ColorAttachments.empty() ? nullptr : this->m_ColorAttachments.data();
27
28 if (depthAttachment)
29 {
30 m_DepthStencilAttachment.attachment = *depthAttachment;
31 m_DepthStencilAttachment.layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
32 m_SubpassDescription.pDepthStencilAttachment = &m_DepthStencilAttachment;
33 }
34 }
35
37 SubpassDescription& operator=(const SubpassDescription&) = delete;
38
39 SubpassDescription(SubpassDescription&&) noexcept = default;
40 SubpassDescription& operator=(SubpassDescription&&) noexcept = default;
41
42 const VkSubpassDescription& GetSubpassDescription() const
43 {
44 return m_SubpassDescription;
45 }
46
47 private:
48 VkSubpassDescription m_SubpassDescription = {};
49 std::vector<VkAttachmentReference> m_ColorAttachments;
50 VkAttachmentReference m_DepthStencilAttachment = {};
51 };
52
53 Renderpass(const LogicalDevice& logicalDevice, const RenderStage& renderStage, VkFormat depthFormat,
54 VkFormat surfaceFormat, VkSampleCountFlagBits samples = VK_SAMPLE_COUNT_1_BIT);
56
57 operator const VkRenderPass&() const
58 {
59 return m_Renderpass;
60 }
61 const VkRenderPass& GetRenderpass() const
62 {
63 return m_Renderpass;
64 }
65
66 private:
67 const LogicalDevice& m_LogicalDevice;
68 VkRenderPass m_Renderpass = VK_NULL_HANDLE;
69 };
70} // namespace PixelBullet
Definition LogicalDevice.hpp:13
Definition RenderStage.hpp:205
Definition Renderpass.hpp:14