Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
Framebuffer.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_FRAMEBUFFER
19#define INCLUDED_RENDERER_BACKEND_VULKAN_FRAMEBUFFER
20
24
25#include <glad/vulkan.h>
26#include <memory>
27
28namespace Renderer
29{
30
31namespace Backend
32{
33
34namespace Vulkan
35{
36
37class CDevice;
38class CTexture;
39
40class CFramebuffer final : public IFramebuffer
41{
42public:
43 ~CFramebuffer() override;
44
45 IDevice* GetDevice() override;
46
47 const CColor& GetClearColor() const override { return m_ClearColor; }
48
49 uint32_t GetWidth() const override { return m_Width; }
50 uint32_t GetHeight() const override { return m_Height; }
52
53 VkRenderPass GetRenderPass() const { return m_RenderPass; }
54 VkFramebuffer GetFramebuffer() const { return m_Framebuffer; }
55
59
64
65 DeviceObjectUID GetUID() const { return m_UID; }
66
67private:
68 friend class CDevice;
69 friend class CSwapChain;
70
71 static std::unique_ptr<CFramebuffer> Create(
72 CDevice* device, const char* name,
73 SColorAttachment* colorAttachment, SDepthStencilAttachment* depthStencilAttachment);
74
75 CFramebuffer() = default;
76
77 CDevice* m_Device = nullptr;
78
80
82
86
91
92 VkRenderPass m_RenderPass = VK_NULL_HANDLE;
93 VkFramebuffer m_Framebuffer = VK_NULL_HANDLE;
94
95 // It's reponsibility of CFramebuffer owner to guarantee lifetime of
96 // attachments.
99};
100
101} // namespace Vulkan
102
103} // namespace Backend
104
105} // namespace Renderer
106
107#endif // INCLUDED_RENDERER_BACKEND_VULKAN_FRAMEBUFFER
Represents a texture object.
Definition: TextureManager.h:262
Definition: IDevice.h:48
IFramebuffer stores attachments which should be used by backend as rendering destinations.
Definition: IFramebuffer.h:85
Definition: Device.h:60
Definition: Framebuffer.h:41
AttachmentStoreOp GetDepthStencilAttachmentStoreOp() const
Definition: Framebuffer.h:63
DeviceObjectUID GetUID() const
Definition: Framebuffer.h:65
CTexture * GetDepthStencilAttachment()
Definition: Framebuffer.h:58
VkFramebuffer GetFramebuffer() const
Definition: Framebuffer.h:54
const ColorAttachments & GetColorAttachments()
Definition: Framebuffer.h:57
AttachmentLoadOp m_ColorAttachmentLoadOp
Definition: Framebuffer.h:87
AttachmentStoreOp m_ColorAttachmentStoreOp
Definition: Framebuffer.h:88
AttachmentStoreOp GetColorAttachmentStoreOp() const
Definition: Framebuffer.h:61
DeviceObjectUID m_UID
Definition: Framebuffer.h:79
uint32_t m_SampleCount
Definition: Framebuffer.h:85
VkRenderPass m_RenderPass
Definition: Framebuffer.h:92
AttachmentStoreOp m_DepthStencilAttachmentStoreOp
Definition: Framebuffer.h:90
AttachmentLoadOp m_DepthStencilAttachmentLoadOp
Definition: Framebuffer.h:89
AttachmentLoadOp GetDepthStencilAttachmentLoadOp() const
Definition: Framebuffer.h:62
CColor m_ClearColor
Definition: Framebuffer.h:81
ColorAttachments m_ColorAttachments
Definition: Framebuffer.h:97
uint32_t m_Width
Definition: Framebuffer.h:83
CDevice * m_Device
Definition: Framebuffer.h:77
const CColor & GetClearColor() const override
Returns a clear color for all color attachments of the framebuffer.
Definition: Framebuffer.h:47
VkRenderPass GetRenderPass() const
Definition: Framebuffer.h:53
static std::unique_ptr< CFramebuffer > Create(CDevice *device, const char *name, SColorAttachment *colorAttachment, SDepthStencilAttachment *depthStencilAttachment)
Definition: Framebuffer.cpp:38
CTexture * m_DepthStencilAttachment
Definition: Framebuffer.h:98
IDevice * GetDevice() override
Definition: Framebuffer.cpp:127
uint32_t GetWidth() const override
Definition: Framebuffer.h:49
uint32_t GetSampleCount() const
Definition: Framebuffer.h:51
AttachmentLoadOp GetColorAttachmentLoadOp() const
Definition: Framebuffer.h:60
~CFramebuffer() override
Definition: Framebuffer.cpp:120
VkFramebuffer m_Framebuffer
Definition: Framebuffer.h:93
uint32_t GetHeight() const override
Definition: Framebuffer.h:50
uint32_t m_Height
Definition: Framebuffer.h:84
Definition: SwapChain.h:44
Definition: Texture.h:41
static constexpr DeviceObjectUID INVALID_DEVICE_OBJECT_UID
Definition: DeviceObjectUID.h:41
uint32_t DeviceObjectUID
Unique identifier for a device object.
Definition: DeviceObjectUID.h:40
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: Color.h:43
Definition: IFramebuffer.h:60
Definition: IFramebuffer.h:68
unsigned int uint32_t
Definition: wposix_types.h:53