-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[render-graph|renderpass] Introduce renderpass wrapper
- Loading branch information
1 parent
2e0f516
commit 7d2fc47
Showing
5 changed files
with
117 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#pragma once | ||
|
||
#include <vulkan/vulkan_core.h> | ||
|
||
#include <string> | ||
#include <vector> | ||
|
||
namespace inexor::vulkan_renderer::wrapper { | ||
|
||
// Forward declaration | ||
class Device; | ||
|
||
/// RAII wrapper for VkRenderPass | ||
class RenderPass { | ||
private: | ||
const Device &m_device; | ||
VkRenderPass m_render_pass{VK_NULL_HANDLE}; | ||
std::string m_name; | ||
|
||
public: | ||
/// Default constructor | ||
/// @param device The device wrapper | ||
/// @param render_pass_ci The render pass create info | ||
/// @param name The internal debug name of the render pass | ||
RenderPass(const Device &device, const VkRenderPassCreateInfo &render_pass_ci, std::string name); | ||
|
||
/// Overloaded constructor which takes the attachment descriptions, subpass descriptions, and subpass dependencies | ||
/// @param device The device wrapper | ||
/// @param render_pass_ci The render pass create info | ||
/// @param attachments The attachment descriptions | ||
/// @param subpasses The subpass descriptions | ||
/// @param dependencies The dependencies | ||
/// @param name The internal debug name of the render pass | ||
RenderPass(const Device &device, const std::vector<VkAttachmentDescription> &attachments, | ||
const std::vector<VkSubpassDescription> &subpasses, const std::vector<VkSubpassDependency> &dependencies, | ||
std::string name); | ||
|
||
RenderPass(const RenderPass &) = delete; | ||
RenderPass(RenderPass &&) noexcept; | ||
~RenderPass(); | ||
|
||
RenderPass &operator=(const RenderPass &) = delete; | ||
RenderPass &operator=(RenderPass &&) = delete; | ||
|
||
[[nodiscard]] VkRenderPass render_pass() const noexcept { | ||
return m_render_pass; | ||
} | ||
}; | ||
|
||
} // namespace inexor::vulkan_renderer::wrapper |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#include "inexor/vulkan-renderer/wrapper/renderpass.hpp" | ||
|
||
#include "inexor/vulkan-renderer/wrapper/device.hpp" | ||
#include "inexor/vulkan-renderer/wrapper/make_info.hpp" | ||
|
||
#include <utility> | ||
|
||
namespace inexor::vulkan_renderer::wrapper { | ||
|
||
RenderPass::RenderPass(const Device &device, const VkRenderPassCreateInfo &render_pass_ci, std::string name) | ||
: m_device(device), m_name(std::move(name)) { | ||
m_device.create_render_pass(render_pass_ci, &m_render_pass, m_name); | ||
} | ||
|
||
RenderPass::RenderPass(const Device &device, const std::vector<VkAttachmentDescription> &attachments, | ||
const std::vector<VkSubpassDescription> &subpasses, | ||
const std::vector<VkSubpassDependency> &dependencies, std::string name) | ||
: RenderPass(device, | ||
wrapper::make_info<VkRenderPassCreateInfo>({ | ||
.attachmentCount = static_cast<std::uint32_t>(attachments.size()), | ||
.pAttachments = attachments.data(), | ||
.subpassCount = static_cast<std::uint32_t>(subpasses.size()), | ||
.pSubpasses = subpasses.data(), | ||
.dependencyCount = static_cast<std::uint32_t>(dependencies.size()), | ||
.pDependencies = dependencies.data(), | ||
}), | ||
std::move(name)) {} | ||
|
||
RenderPass::RenderPass(RenderPass &&other) noexcept : m_device(other.m_device) { | ||
m_render_pass = std::exchange(other.m_render_pass, VK_NULL_HANDLE); | ||
m_name = std::move(other.m_name); | ||
} | ||
|
||
RenderPass::~RenderPass() { | ||
vkDestroyRenderPass(m_device.device(), m_render_pass, nullptr); | ||
} | ||
|
||
} // namespace inexor::vulkan_renderer::wrapper |