Fling Engine  0.00.1
Fling Engine is a game engine written in Vulkan
Buffer.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "FlingVulkan.h"
4 #include "FlingExports.h"
5 
6 namespace Fling
7 {
11  class FLING_API Buffer
12  {
13  public:
14 
20  : m_Size(0)
21  , m_Buffer(VK_NULL_HANDLE)
22  , m_BufferMemory(VK_NULL_HANDLE)
23  {
24  }
25 
34  Buffer(
35  const VkDeviceSize& t_Size,
36  const VkBufferUsageFlags& t_Usage,
37  const VkMemoryPropertyFlags& t_Properties,
38  const void* t_Data = nullptr
39  );
40 
44  ~Buffer();
45 
46  const VkBuffer& GetVkBuffer() const { return m_Buffer; }
47 
48  const VkDeviceMemory& GetVkDeviceMemory() const { return m_BufferMemory; }
49 
50  const VkDeviceSize& GetSize() const { return m_Size; }
51 
52 
60  static void CopyBuffer(Buffer* t_SrcBuffer, Buffer* t_DstBuffer, VkDeviceSize t_Size);
61 
66  void Release();
67 
73  bool IsUsed() const { return m_BufferMemory != VK_NULL_HANDLE && m_Buffer != VK_NULL_HANDLE && m_Size; }
74 
75  private:
76 
82  void MapMemory(void** t_Data) const;
83 
87  void UnmapMemory();
88 
90  VkDeviceSize m_Size;
91 
93  VkBuffer m_Buffer;
94 
96  VkDeviceMemory m_BufferMemory;
97  };
98 } // namespace Fling
VkDeviceMemory m_BufferMemory
Pointer to the physcial device memory for this buffer.
Definition: Buffer.h:96
const VkDeviceMemory & GetVkDeviceMemory() const
Definition: Buffer.h:48
const VkBuffer & GetVkBuffer() const
Definition: Buffer.h:46
VkDeviceSize m_Size
The size of this buffer in bytes.
Definition: Buffer.h:90
bool IsUsed() const
Check if this buffer's vulkan assets are used.
Definition: Buffer.h:73
VkBuffer m_Buffer
Vulkan logical buffer object.
Definition: Buffer.h:93
A Buffer represents a Vulkan buffer with a size, buffer pointer, and buffer memory.
Definition: Buffer.h:11
const VkDeviceSize & GetSize() const
Definition: Buffer.h:50
Definition: Engine.h:13
Buffer()
Default Ctor for a buffer.
Definition: Buffer.h:19