| Fling Engine 0.00.1 Fling Engine is a game engine written in Vulkan

FrameBuffer.h
Go to the documentation of this file.
1 #pragma once
2
3 #include "FlingVulkan.h"
4 #include "FlingTypes.h"
5 #include <vector>
6 #include <memory>
7
8 namespace Fling
9 {
13 struct AttachmentCreateInfo
14 {
15 UINT32 Width = {};
16 UINT32 Height = {};
17 UINT32 LayerCount = {};
18 VkFormat Format = {};
19 VkImageUsageFlags Usage = {};
20 };
21
22 struct FrameBufferAttachment
23 {
24 FrameBufferAttachment(AttachmentCreateInfo t_Info, const VkDevice& t_Dev);
25
26 ~FrameBufferAttachment();
27
28 void Release();
29
33 bool HasDepth();
34
38 bool HasStencil();
39
43 bool IsDepthStencil();
44
45 inline VkImage GetImageHandle() const { return m_Image; }
46 inline VkImageView GetViewHandle() const { return m_ImageView; }
47 inline VkFormat GetFormat() const { return m_Format; }
48 inline VkDeviceMemory GetMemoryHandle() const { return m_Memory; }
49 inline VkSampleCountFlagBits GetSampleCount() const { return m_Samples; }
50 inline VkImageSubresourceRange GetSubresourceRange() const { return m_SubresourceRange; }
51 inline VkAttachmentDescription GetDescription() const { return m_Description; }
52
53 private:
54
55 VkImage m_Image = VK_NULL_HANDLE;
56 VkDeviceMemory m_Memory = VK_NULL_HANDLE;
57 VkImageView m_ImageView = VK_NULL_HANDLE;
58 VkFormat m_Format = {};
59 VkSampleCountFlagBits m_Samples{ VK_SAMPLE_COUNT_1_BIT };
60 VkImageUsageFlags m_Usage{ VK_IMAGE_USAGE_SAMPLED_BIT };
61 VkImageSubresourceRange m_SubresourceRange = {};
62 VkAttachmentDescription m_Description = {};
63
64 const VkDevice& m_Device;
65 };
66
67 class FrameBuffer
68 {
69 public:
70 explicit FrameBuffer(const VkDevice& t_Dev, INT32 t_Width = 2048, INT32 t_Height = 2048);
71 ~FrameBuffer();
72
73 void SizeSize(INT32 w, INT32 h);
74 void Release();
75
76 VkSampler GetSamplerHandle() const { return m_Sampler; }
77 VkFramebuffer GetHandle() const { return m_FrameBuffer; }
78 VkRenderPass GetRenderPassHandle() const { return m_RenderPass; }
79
87 VkResult CreateRenderPass();
88
93 VkResult CreateSampler(VkFilter magFilter, VkFilter minFilter, VkSamplerAddressMode adressMode);
94
98 UINT32 AddAttachment(AttachmentCreateInfo t_CreateInfo);
99
104 FrameBufferAttachment* GetAttachmentAtIndex(UINT32 t_Index);
105
106 inline INT32 GetWidth() const { return m_Width; }
107 inline INT32 GetHeight() const { return m_Height; }
108
109 private:
110 INT32 m_Width = 0;
111 INT32 m_Height = 0;
112 VkFramebuffer m_FrameBuffer = VK_NULL_HANDLE;
113 VkRenderPass m_RenderPass = VK_NULL_HANDLE;
114 VkSampler m_Sampler = VK_NULL_HANDLE;
115 const VkDevice& m_Device;
116
117 std::vector<FrameBufferAttachment*> m_Attachments;
118 };
119 } // namespace Fling
Fling::FrameBufferAttachment::GetViewHandle
VkImageView GetViewHandle() const
Definition: FrameBuffer.h:46
Fling::FrameBufferAttachment::GetMemoryHandle
VkDeviceMemory GetMemoryHandle() const
Definition: FrameBuffer.h:48
FlingVulkan.h
Fling::FrameBuffer::GetHandle
VkFramebuffer GetHandle() const
Definition: FrameBuffer.h:77
Fling::FrameBufferAttachment::GetSubresourceRange
VkImageSubresourceRange GetSubresourceRange() const
Definition: FrameBuffer.h:50
Fling::AttachmentCreateInfo::Format
VkFormat Format
Definition: FrameBuffer.h:18
Fling::FrameBuffer::GetWidth
INT32 GetWidth() const
Definition: FrameBuffer.h:106
Fling::FrameBufferAttachment::GetDescription
VkAttachmentDescription GetDescription() const
Definition: FrameBuffer.h:51
Fling::AttachmentCreateInfo::Usage
VkImageUsageFlags Usage
Definition: FrameBuffer.h:19
Fling::FrameBuffer::m_Device
const VkDevice & m_Device
Definition: FrameBuffer.h:115
Fling::AttachmentCreateInfo::Width
UINT32 Width
Definition: FrameBuffer.h:15
Fling::FrameBufferAttachment::GetImageHandle
VkImage GetImageHandle() const
Definition: FrameBuffer.h:45
Fling::FrameBuffer::GetRenderPassHandle
VkRenderPass GetRenderPassHandle() const
Definition: FrameBuffer.h:78
INT32
int32_t INT32
Definition: FlingTypes.h:18
Fling::AttachmentCreateInfo::Height
UINT32 Height
Definition: FrameBuffer.h:16
Fling::FrameBufferAttachment::GetFormat
VkFormat GetFormat() const
Definition: FrameBuffer.h:47
Fling::FrameBuffer
Definition: FrameBuffer.h:67
Fling::FrameBufferAttachment::GetSampleCount
VkSampleCountFlagBits GetSampleCount() const
Definition: FrameBuffer.h:49
Fling::AttachmentCreateInfo
Describes the attributes of an attachment to be created.
Definition: FrameBuffer.h:13
Fling::FrameBuffer::GetHeight
INT32 GetHeight() const
Definition: FrameBuffer.h:107
UINT32
uint32_t UINT32
Definition: FlingTypes.h:13
Fling::FrameBuffer::GetSamplerHandle
VkSampler GetSamplerHandle() const
Definition: FrameBuffer.h:76
Fling::AttachmentCreateInfo::LayerCount
UINT32 LayerCount
Definition: FrameBuffer.h:17
Fling
Definition: Engine.h:29
Fling::FrameBufferAttachment
Definition: FrameBuffer.h:22
FlingTypes.h
Fling::FrameBuffer::m_Attachments
std::vector< FrameBufferAttachment * > m_Attachments
Definition: FrameBuffer.h:117
Fling::FrameBufferAttachment::m_Device
const VkDevice & m_Device
Definition: FrameBuffer.h:64