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