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 {
14  {
15  UINT32 Width = {};
16  UINT32 Height = {};
18  VkFormat Format = {};
19  VkImageUsageFlags Usage = {};
20  };
21 
23  {
24  FrameBufferAttachment(AttachmentCreateInfo t_Info, const VkDevice& t_Dev);
25 
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 
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
VkImageView GetViewHandle() const
Definition: FrameBuffer.h:46
VkDeviceMemory GetMemoryHandle() const
Definition: FrameBuffer.h:48
VkFramebuffer GetHandle() const
Definition: FrameBuffer.h:77
VkImageSubresourceRange GetSubresourceRange() const
Definition: FrameBuffer.h:50
VkFormat Format
Definition: FrameBuffer.h:18
INT32 GetWidth() const
Definition: FrameBuffer.h:106
VkAttachmentDescription GetDescription() const
Definition: FrameBuffer.h:51
VkImageUsageFlags Usage
Definition: FrameBuffer.h:19
const VkDevice & m_Device
Definition: FrameBuffer.h:115
UINT32 Width
Definition: FrameBuffer.h:15
VkImage GetImageHandle() const
Definition: FrameBuffer.h:45
VkRenderPass GetRenderPassHandle() const
Definition: FrameBuffer.h:78
int32_t INT32
Definition: FlingTypes.h:18
UINT32 Height
Definition: FrameBuffer.h:16
VkFormat GetFormat() const
Definition: FrameBuffer.h:47
Definition: FrameBuffer.h:67
VkSampleCountFlagBits GetSampleCount() const
Definition: FrameBuffer.h:49
Describes the attributes of an attachment to be created.
Definition: FrameBuffer.h:13
INT32 GetHeight() const
Definition: FrameBuffer.h:107
uint32_t UINT32
Definition: FlingTypes.h:13
VkSampler GetSamplerHandle() const
Definition: FrameBuffer.h:76
UINT32 LayerCount
Definition: FrameBuffer.h:17
Definition: Engine.h:29
Definition: FrameBuffer.h:22
std::vector< FrameBufferAttachment * > m_Attachments
Definition: FrameBuffer.h:117
const VkDevice & m_Device
Definition: FrameBuffer.h:64