Fling Engine  0.00.1
Fling Engine is a game engine written in Vulkan
Public Member Functions | Static Public Member Functions | Data Fields | Private Attributes
Fling::Buffer Class Reference

A Buffer represents a Vulkan buffer with a size, buffer pointer, and buffer memory. More...

#include <Buffer.h>

Public Member Functions

 Buffer ()
 Default Ctor for a buffer. More...
 
 Buffer (const Buffer &t_Other)
 copy constructor. More...
 
 Buffer (const VkDeviceSize &t_Size, const VkBufferUsageFlags &t_Usage, const VkMemoryPropertyFlags &t_Properties, const void *t_Data=nullptr)
 Construct a new Buffer object. More...
 
 ~Buffer ()
 Destroy the Buffer object, frees Vk memory and destroys buffer. More...
 
bool operator== (const Buffer &other) const
 
bool operator!= (const Buffer &other) const
 
FORCEINLINE const VkBuffer & GetVkBuffer () const
 
FORCEINLINE const VkDeviceMemory & GetVkDeviceMemory () const
 
FORCEINLINE const VkDeviceSize & GetSize () const
 
FORCEINLINE VkDescriptorBufferInfo & GetDescriptor ()
 
void Release ()
 Destroy the VK buffer object, frees vk memory. More...
 
bool IsUsed () const
 Check if this buffer's Vulkan assets are used. More...
 
VkResult MapMemory (VkDeviceSize t_Size=VK_WHOLE_SIZE, VkDeviceSize t_Offset=0)
 Map the memory of this buffer to the given data. More...
 
void UnmapMemory ()
 Unmap this buffers memory from the Vulkan device. More...
 
void CreateBuffer (const VkDeviceSize &t_size, const VkBufferUsageFlags &t_Usage, const VkMemoryPropertyFlags &t_Properties, bool t_unmapBuffer, const void *t_Data=nullptr)
 Create a Buffer object. More...
 
void Flush (VkDeviceSize t_size, VkDeviceSize t_offset)
 Flush memory range to device. More...
 

Static Public Member Functions

static void CopyBuffer (Buffer *t_SrcBuffer, Buffer *t_DstBuffer, VkDeviceSize t_Size)
 Copy the contents of the source buffer to the destination buffer using a single command. More...
 

Data Fields

void * m_MappedMem = nullptr
 

Private Attributes

VkDeviceSize m_Size
 The size of this buffer in bytes. More...
 
VkBuffer m_Buffer
 Vulkan logical buffer object. More...
 
VkDeviceMemory m_BufferMemory
 Pointer to the physical device memory for this buffer. More...
 
VkDescriptorBufferInfo m_Descriptor
 The descriptor stores info about the offset, buffer, and; size of this. More...
 
VkDeviceSize m_Offset = 0
 Offset offset of buffer. More...
 

Detailed Description

A Buffer represents a Vulkan buffer with a size, buffer pointer, and buffer memory.

Constructor & Destructor Documentation

◆ Buffer() [1/3]

Fling::Buffer::Buffer ( )
inline

Default Ctor for a buffer.

Buffer is initialized to 0

◆ Buffer() [2/3]

Fling::Buffer::Buffer ( const Buffer t_Other)

copy constructor.

◆ Buffer() [3/3]

Fling::Buffer::Buffer ( const VkDeviceSize &  t_Size,
const VkBufferUsageFlags &  t_Usage,
const VkMemoryPropertyFlags &  t_Properties,
const void *  t_Data = nullptr 
)

Construct a new Buffer object.

Parameters
t_SizeSize of this buffer in bytes
t_UsageVk usage flags for this buffer
t_PropertiesVk props of this buffer, used to find the memory type
t_DataPointer to data that this buffer should map to, e.g. a staging buffer (Default = nullptr)

◆ ~Buffer()

Fling::Buffer::~Buffer ( )

Destroy the Buffer object, frees Vk memory and destroys buffer.

Member Function Documentation

◆ CopyBuffer()

void Fling::Buffer::CopyBuffer ( Buffer t_SrcBuffer,
Buffer t_DstBuffer,
VkDeviceSize  t_Size 
)
static

Copy the contents of the source buffer to the destination buffer using a single command.

Parameters
t_SrcBufferSource buffer data
t_DstBufferDestination buffer data
t_SizeSize of the data to copy

◆ CreateBuffer()

void Fling::Buffer::CreateBuffer ( const VkDeviceSize &  t_size,
const VkBufferUsageFlags &  t_Usage,
const VkMemoryPropertyFlags &  t_Properties,
bool  t_unmapBuffer,
const void *  t_Data = nullptr 
)

Create a Buffer object.

Parameters
t_sizedevice size
t_Usagebuffer usage flag
t_Propertiesmemory properties
t_unmapBufferflag to unmap buffer
t_Datadata to map to buffer

◆ Flush()

void Fling::Buffer::Flush ( VkDeviceSize  t_size,
VkDeviceSize  t_offset 
)

Flush memory range to device.

Parameters
t_sizeSize of the memory range to flush to
t_offsetoffset from the beginning

◆ GetDescriptor()

FORCEINLINE VkDescriptorBufferInfo& Fling::Buffer::GetDescriptor ( )
inline

◆ GetSize()

FORCEINLINE const VkDeviceSize& Fling::Buffer::GetSize ( ) const
inline

◆ GetVkBuffer()

FORCEINLINE const VkBuffer& Fling::Buffer::GetVkBuffer ( ) const
inline

◆ GetVkDeviceMemory()

FORCEINLINE const VkDeviceMemory& Fling::Buffer::GetVkDeviceMemory ( ) const
inline

◆ IsUsed()

bool Fling::Buffer::IsUsed ( ) const
inline

Check if this buffer's Vulkan assets are used.

Returns
true memory is not null and the size is greater than 0

◆ MapMemory()

VkResult Fling::Buffer::MapMemory ( VkDeviceSize  t_Size = VK_WHOLE_SIZE,
VkDeviceSize  t_Offset = 0 
)

Map the memory of this buffer to the given data.

Parameters
t_DataWhere to map this buffer's data to

◆ operator!=()

bool Fling::Buffer::operator!= ( const Buffer other) const

◆ operator==()

bool Fling::Buffer::operator== ( const Buffer other) const

◆ Release()

void Fling::Buffer::Release ( )

Destroy the VK buffer object, frees vk memory.

◆ UnmapMemory()

void Fling::Buffer::UnmapMemory ( )

Unmap this buffers memory from the Vulkan device.

Field Documentation

◆ m_Buffer

VkBuffer Fling::Buffer::m_Buffer
private

Vulkan logical buffer object.

◆ m_BufferMemory

VkDeviceMemory Fling::Buffer::m_BufferMemory
private

Pointer to the physical device memory for this buffer.

◆ m_Descriptor

VkDescriptorBufferInfo Fling::Buffer::m_Descriptor
private

The descriptor stores info about the offset, buffer, and; size of this.

◆ m_MappedMem

void* Fling::Buffer::m_MappedMem = nullptr

◆ m_Offset

VkDeviceSize Fling::Buffer::m_Offset = 0
private

Offset offset of buffer.

◆ m_Size

VkDeviceSize Fling::Buffer::m_Size
private

The size of this buffer in bytes.


The documentation for this class was generated from the following files: