PeriDyno 1.0.0
Loading...
Searching...
No Matches
vks::Buffer Class Reference

Encapsulates access to a Vulkan buffer backed up by device memory. More...

#include <VulkanBuffer.h>

Public Member Functions

 Buffer (VkDevice dev=nullptr)
 
 ~Buffer ()
 
VkResult map (VkDeviceSize size=VK_WHOLE_SIZE, VkDeviceSize offset=0)
 
void unmap ()
 
VkResult bind (VkDeviceSize offset=0)
 
void setupDescriptor (VkDeviceSize size=VK_WHOLE_SIZE, VkDeviceSize offset=0)
 
void copyTo (void *data, VkDeviceSize size)
 
VkResult flush (VkDeviceSize size=VK_WHOLE_SIZE, VkDeviceSize offset=0)
 
VkResult invalidate (VkDeviceSize size=VK_WHOLE_SIZE, VkDeviceSize offset=0)
 
void destroy ()
 

Public Attributes

VkDevice device
 
VkBuffer buffer = VK_NULL_HANDLE
 
VkDeviceMemory memory = VK_NULL_HANDLE
 
VkDescriptorBufferInfo descriptor
 
VkDeviceSize size = 0
 
VkDeviceSize alignment = 0
 
VkDeviceSize offset = 0
 
VmaAllocation allocation = VK_NULL_HANDLE
 
VmaAllocator allocator = VK_NULL_HANDLE
 
VkBool32 usePool = VK_FALSE
 
void * mapped = nullptr
 
VkBufferUsageFlags usageFlags
 Usage flags to be filled by external source at buffer creation (to query at some later point)
 
VkMemoryPropertyFlags memoryPropertyFlags
 Memory property flags to be filled by external source at buffer creation (to query at some later point)
 

Detailed Description

Encapsulates access to a Vulkan buffer backed up by device memory.

Note
To be filled by an external source like the VulkanDevice

Definition at line 27 of file VulkanBuffer.h.

Constructor & Destructor Documentation

◆ Buffer()

vks::Buffer::Buffer ( VkDevice dev = nullptr)

Definition at line 19 of file VulkanBuffer.cpp.

Here is the call graph for this function:

◆ ~Buffer()

vks::Buffer::~Buffer ( )

Definition at line 31 of file VulkanBuffer.cpp.

Here is the call graph for this function:

Member Function Documentation

◆ bind()

VkResult vks::Buffer::bind ( VkDeviceSize offset = 0)

Attach the allocated memory block to the buffer

Parameters
offset(Optional) Byte offset (from the beginning) for the memory region to bind
Returns
VkResult of the bindBufferMemory call

Definition at line 77 of file VulkanBuffer.cpp.

◆ copyTo()

void vks::Buffer::copyTo ( void * data,
VkDeviceSize size )

Copies the specified data to the mapped buffer

Parameters
dataPointer to the data to copy
sizeSize of the data to copy in machine units

Definition at line 107 of file VulkanBuffer.cpp.

Here is the call graph for this function:

◆ destroy()

void vks::Buffer::destroy ( )

Release all Vulkan resources held by this buffer

Definition at line 164 of file VulkanBuffer.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ flush()

VkResult vks::Buffer::flush ( VkDeviceSize size = VK_WHOLE_SIZE,
VkDeviceSize offset = 0 )

Flush a memory range of the buffer to make it visible to the device

Note
Only required for non-coherent memory
Parameters
size(Optional) Size of the memory range to flush. Pass VK_WHOLE_SIZE to flush the complete buffer range.
offset(Optional) Byte offset from beginning
Returns
VkResult of the flush call

Definition at line 123 of file VulkanBuffer.cpp.

◆ invalidate()

VkResult vks::Buffer::invalidate ( VkDeviceSize size = VK_WHOLE_SIZE,
VkDeviceSize offset = 0 )

Invalidate a memory range of the buffer to make it visible to the host

Note
Only required for non-coherent memory
Parameters
size(Optional) Size of the memory range to invalidate. Pass VK_WHOLE_SIZE to invalidate the complete buffer range.
offset(Optional) Byte offset from beginning
Returns
VkResult of the invalidate call

Definition at line 147 of file VulkanBuffer.cpp.

◆ map()

VkResult vks::Buffer::map ( VkDeviceSize size = VK_WHOLE_SIZE,
VkDeviceSize offset = 0 )

Map a memory range of this buffer. If successful, mapped points to the specified buffer range.

Parameters
size(Optional) Size of the memory range to map. Pass VK_WHOLE_SIZE to map the complete buffer range.
offset(Optional) Byte offset from beginning
Returns
VkResult of the buffer mapping call

Definition at line 44 of file VulkanBuffer.cpp.

◆ setupDescriptor()

void vks::Buffer::setupDescriptor ( VkDeviceSize size = VK_WHOLE_SIZE,
VkDeviceSize offset = 0 )

Setup the default descriptor for this buffer

Parameters
size(Optional) Size of the memory range of the descriptor
offset(Optional) Byte offset from beginning

Definition at line 93 of file VulkanBuffer.cpp.

◆ unmap()

void vks::Buffer::unmap ( )

Unmap a mapped memory range

Note
Does not return a result as vkUnmapMemory can't fail

Definition at line 58 of file VulkanBuffer.cpp.

Here is the caller graph for this function:

Member Data Documentation

◆ alignment

VkDeviceSize vks::Buffer::alignment = 0

Definition at line 46 of file VulkanBuffer.h.

◆ allocation

VmaAllocation vks::Buffer::allocation = VK_NULL_HANDLE

Definition at line 48 of file VulkanBuffer.h.

◆ allocator

VmaAllocator vks::Buffer::allocator = VK_NULL_HANDLE

Definition at line 49 of file VulkanBuffer.h.

◆ buffer

VkBuffer vks::Buffer::buffer = VK_NULL_HANDLE

Definition at line 42 of file VulkanBuffer.h.

◆ descriptor

VkDescriptorBufferInfo vks::Buffer::descriptor

Definition at line 44 of file VulkanBuffer.h.

◆ device

VkDevice vks::Buffer::device

Definition at line 41 of file VulkanBuffer.h.

◆ mapped

void* vks::Buffer::mapped = nullptr

Definition at line 51 of file VulkanBuffer.h.

◆ memory

VkDeviceMemory vks::Buffer::memory = VK_NULL_HANDLE

Definition at line 43 of file VulkanBuffer.h.

◆ memoryPropertyFlags

VkMemoryPropertyFlags vks::Buffer::memoryPropertyFlags

Memory property flags to be filled by external source at buffer creation (to query at some later point)

Definition at line 55 of file VulkanBuffer.h.

◆ offset

VkDeviceSize vks::Buffer::offset = 0

Definition at line 47 of file VulkanBuffer.h.

◆ size

VkDeviceSize vks::Buffer::size = 0

Definition at line 45 of file VulkanBuffer.h.

◆ usageFlags

VkBufferUsageFlags vks::Buffer::usageFlags

Usage flags to be filled by external source at buffer creation (to query at some later point)

Definition at line 53 of file VulkanBuffer.h.

◆ usePool

VkBool32 vks::Buffer::usePool = VK_FALSE

Definition at line 50 of file VulkanBuffer.h.


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