MayaFlux 0.1.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
VKRenderPass.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <vulkan/vulkan.hpp>
4
5namespace MayaFlux::Core {
6
8 vk::Format format;
9 vk::SampleCountFlagBits samples { vk::SampleCountFlagBits::e1 };
10 vk::AttachmentLoadOp load_op { vk::AttachmentLoadOp::eClear };
11 vk::AttachmentStoreOp store_op { vk::AttachmentStoreOp::eStore };
12 vk::AttachmentLoadOp stencil_load_op { vk::AttachmentLoadOp::eDontCare };
13 vk::AttachmentStoreOp stencil_store_op { vk::AttachmentStoreOp::eDontCare };
14 vk::ImageLayout initial_layout { vk::ImageLayout::eUndefined };
15 vk::ImageLayout final_layout { vk::ImageLayout::ePresentSrcKHR };
16};
17
19 vk::PipelineBindPoint bind_point { vk::PipelineBindPoint::eGraphics };
20
21 std::vector<vk::AttachmentReference> color_attachments;
22 std::optional<vk::AttachmentReference> depth_stencil_attachment;
23 std::vector<vk::AttachmentReference> input_attachments;
24 std::vector<vk::AttachmentReference> resolve_attachments;
25 std::vector<uint32_t> preserve_attachments;
26};
27
29 uint32_t src_subpass { VK_SUBPASS_EXTERNAL };
30 uint32_t dst_subpass {};
31 vk::PipelineStageFlags src_stage_mask { vk::PipelineStageFlagBits::eColorAttachmentOutput };
32 vk::PipelineStageFlags dst_stage_mask { vk::PipelineStageFlagBits::eColorAttachmentOutput };
33 vk::AccessFlags src_access_mask;
34 vk::AccessFlags dst_access_mask { vk::AccessFlagBits::eColorAttachmentWrite };
35};
36
38 std::vector<AttachmentDescription> attachments;
39 std::vector<SubpassDescription> subpasses;
40 std::vector<SubpassDependency> dependencies;
41};
42
43/**
44 * @class VKRenderPass
45 * @brief A wrapper class for Vulkan Render Pass.
46 * This class encapsulates the creation and management of a Vulkan Render Pass,
47 * providing an easy-to-use interface for setting up rendering operations.
48 */
50public:
51 VKRenderPass() = default;
52
53 /**
54 * @brief Create a simple render pass with a single color attachment.
55 * @param device The Vulkan device to create the render pass on.
56 * @param color_format The format of the color attachment.
57 * @return True if the render pass was created successfully, false otherwise.
58 */
59 bool create(vk::Device device, vk::Format color_format);
60
61 /**
62 * @brief Create a render pass with the specified creation info.
63 * @param device The Vulkan device to create the render pass on.
64 * @param create_info The creation info for the render pass.
65 * @return True if the render pass was created successfully, false otherwise.
66 */
67 bool create(vk::Device device, const RenderPassCreateInfo& create_info);
68
69 /**
70 * @brief Clean up the render pass resources.
71 * @param device The Vulkan device to clean up the render pass on.
72 */
73 void cleanup(vk::Device device);
74
75 static RenderPassCreateInfo create_default_color_only(vk::Format color_format);
76 static RenderPassCreateInfo create_default_color_depth(vk::Format color_format, vk::Format depth_format);
77 static RenderPassCreateInfo create_offscreen_color(vk::Format color_format, vk::ImageLayout final_layout = vk::ImageLayout::eShaderReadOnlyOptimal);
78
79 /**
80 * @brief Get the underlying Vulkan Render Pass handle.
81 * @return The Vulkan Render Pass handle.
82 */
83 [[nodiscard]] vk::RenderPass get() const { return m_render_pass; }
84
85 /**
86 * @brief Get the attachment descriptions used in the render pass.
87 * @return A vector of attachment descriptions.
88 */
89 [[nodiscard]] const std::vector<AttachmentDescription>& get_attachments() const { return m_attachments; }
90
91private:
92 vk::RenderPass m_render_pass = nullptr;
93
94 std::vector<AttachmentDescription> m_attachments;
95};
96
97}
vk::RenderPass get() const
Get the underlying Vulkan Render Pass handle.
const std::vector< AttachmentDescription > & get_attachments() const
Get the attachment descriptions used in the render pass.
bool create(vk::Device device, vk::Format color_format)
Create a simple render pass with a single color attachment.
static RenderPassCreateInfo create_default_color_depth(vk::Format color_format, vk::Format depth_format)
static RenderPassCreateInfo create_offscreen_color(vk::Format color_format, vk::ImageLayout final_layout=vk::ImageLayout::eShaderReadOnlyOptimal)
static RenderPassCreateInfo create_default_color_only(vk::Format color_format)
void cleanup(vk::Device device)
Clean up the render pass resources.
std::vector< AttachmentDescription > m_attachments
A wrapper class for Vulkan Render Pass.
std::vector< AttachmentDescription > attachments
std::vector< SubpassDependency > dependencies
std::vector< SubpassDescription > subpasses
vk::PipelineStageFlags src_stage_mask
vk::PipelineStageFlags dst_stage_mask
std::vector< uint32_t > preserve_attachments
std::vector< vk::AttachmentReference > input_attachments
std::vector< vk::AttachmentReference > resolve_attachments
std::optional< vk::AttachmentReference > depth_stencil_attachment
std::vector< vk::AttachmentReference > color_attachments