Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
RenderPassManager.h
Go to the documentation of this file.
1/* Copyright (C) 2023 Wildfire Games.
2 * This file is part of 0 A.D.
3 *
4 * 0 A.D. is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * 0 A.D. is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef INCLUDED_RENDERER_BACKEND_VULKAN_RENDERPASSMANAGER
19#define INCLUDED_RENDERER_BACKEND_VULKAN_RENDERPASSMANAGER
20
22
23#include <glad/vulkan.h>
24#include <optional>
25#include <unordered_map>
26#include <vector>
27
28namespace Renderer
29{
30
31namespace Backend
32{
33
34namespace Vulkan
35{
36
37class CDevice;
38
39/**
40 * A helper class to store unique render passes.
41 */
43{
44public:
47
48 /**
49 * @return a renderpass with required attachments. Currently we use only
50 * single subpass renderpasses.
51 * @note it should be called as rarely as possible.
52 */
53 VkRenderPass GetOrCreateRenderPass(
54 SColorAttachment* colorAttachment,
55 SDepthStencilAttachment* depthStencilAttachment);
56
57private:
58 CDevice* m_Device = nullptr;
59
61 {
62 VkFormat format;
65 };
66 struct Desc
67 {
69 std::optional<Attachment> colorAttachment;
70 std::optional<Attachment> depthStencilAttachment;
71 };
72 struct DescHash
73 {
74 size_t operator()(const Desc& desc) const;
75 };
76 struct DescEqual
77 {
78 bool operator()(const Desc& lhs, const Desc& rhs) const;
79 };
80 std::unordered_map<Desc, VkRenderPass, DescHash, DescEqual> m_RenderPassMap;
81};
82
83} // namespace Vulkan
84
85} // namespace Backend
86
87} // namespace Renderer
88
89#endif // INCLUDED_RENDERER_BACKEND_VULKAN_RENDERPASSMANAGER
Definition: Device.h:60
A helper class to store unique render passes.
Definition: RenderPassManager.h:43
CDevice * m_Device
Definition: RenderPassManager.h:58
CRenderPassManager(CDevice *device)
Definition: RenderPassManager.cpp:84
VkRenderPass GetOrCreateRenderPass(SColorAttachment *colorAttachment, SDepthStencilAttachment *depthStencilAttachment)
Definition: RenderPassManager.cpp:100
~CRenderPassManager()
Definition: RenderPassManager.cpp:89
std::unordered_map< Desc, VkRenderPass, DescHash, DescEqual > m_RenderPassMap
Definition: RenderPassManager.h:80
AttachmentStoreOp
Store operation is set for each attachment, what should be done with its content on EndFramebufferPas...
Definition: IFramebuffer.h:52
Backend
Definition: Backend.h:28
AttachmentLoadOp
Load operation is set for each attachment, what should be done with its content on BeginFramebufferPa...
Definition: IFramebuffer.h:37
Definition: VideoMode.h:29
Definition: IFramebuffer.h:60
Definition: IFramebuffer.h:68
VkFormat format
Definition: RenderPassManager.h:62
AttachmentStoreOp storeOp
Definition: RenderPassManager.h:64
AttachmentLoadOp loadOp
Definition: RenderPassManager.h:63
bool operator()(const Desc &lhs, const Desc &rhs) const
Definition: RenderPassManager.cpp:64
size_t operator()(const Desc &desc) const
Definition: RenderPassManager.cpp:38
Definition: RenderPassManager.h:67
std::optional< Attachment > colorAttachment
Definition: RenderPassManager.h:69
std::optional< Attachment > depthStencilAttachment
Definition: RenderPassManager.h:70
uint8_t sampleCount
Definition: RenderPassManager.h:68
unsigned char uint8_t
Definition: wposix_types.h:51