HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RV_VKBuffer Class Reference

A vulkan buffer object. More...

#include <RV_VKBuffer.h>

Public Member Functions

VkBuffer getVkBuf ()
 Get the raw vulkan buffer handle. More...
 
const RV_VKBufferCreateInfogetInfo ()
 Get the create info the buffer was created with. More...
 
RV_VKMemory & getMemory ()
 Get the memory the buffer is backed by. More...
 
const RV_VKMemory & getMemory () const
 
exint gpuMemoryUsage () const
 Return the memory size this buffer uses, in bytes. More...
 
const RV_ResourceIDgetID () const
 Return unique ID for buffer object. More...
 
const UT_StringHoldergetName () const
 Return label for buffer object. More...
 
VkBufferView getVkView ()
 Fetch the buffer view assigned to this buffer, if any. More...
 
VkFormat getVkFormat () const
 Return the vulkan format of the buffer. More...
 
exint getSize () const
 Return the size of the buffer, in bytes. More...
 
VkBufferUsageFlags getUsage () const
 return the vulkan usage of the buffer when it was created More...
 
VkBufferUsageFlags getLastUsage () const
 return the current usage of this buffer More...
 
exint entries () const
 Number of elements in this buffer (eg. RGB 32b is 1 element) More...
 
RV_GPUType getGPUType () const
 Return the RV type of the buffer. More...
 
int getVectorSize () const
 Return the vector size of the buffer (1-4) More...
 
VkDeviceAddress getDeviceAddress () const
 Return the device address of the buffer. More...
 
bool uploadData (RV_Render *r, VkBufferUsageFlags new_usage, const void *data, exint data_size, exint data_offset=0)
 Upload data to the buffer Upload data to the buffer and add a barrier based on its usage. Returns true if the size+offset doesn't exceed the allocated size. More...
 
bool uploadData (RV_Render *r, const void *data, exint data_size, exint data_offset=0)
 Upload data to the buffer Upload data to the buffer. Returns true if the size+offset doesn't exceed the allocated size. More...
 
template<typename T , typename std::enable_if<!std::is_pointer< T >::value, int >::type = 0>
bool uploadData (RV_Render *r, const T &data)
 Span version of buffer upload. More...
 
template<typename T , typename std::enable_if<!std::is_pointer< T >::value, int >::type = 0>
bool uploadData (RV_Render *r, VkBufferUsageFlags new_usage, const T &data)
 
bool isMappedMemory () const
 return whether buffer was declared as CPU visible, and mapped More...
 
voidgetMappedMemory ()
 
bool copyData (RV_Render *r, RV_VKBuffer *buf, exint src_offset=0, exint dst_offset=0, exint sublen=-1)
 Download data from the buffer into buf More...
 
bool downloadData (RV_Render *r, void *data, exint data_size, exint offset=0, exint sublen=-1)
 
void clear (RV_Render *r)
 Clear the buffer with 0. More...
 
void addBarrier (RV_Render *r, VkBufferUsageFlags new_usage)
 Add a barrier for using the buffer in the future. More...
 
void addBarrier (RV_Render *r, VkBufferUsageFlags old_usage, VkBufferUsageFlags new_usage)
 Add a barrier for using the buffer in the future, changing its usage. More...
 
virtual ~RV_VKBuffer ()
 
void print () const
 Debug output of the buffer (but not its data). More...
 
 RV_VKBuffer (RV_Instance *inst, const RV_VKBufferCreateInfo *info, VkBuffer vk_buf, RV_VKMemoryPtr mem, RV_VKBufferViewPtr view, const PassKey &)
 

Static Public Member Functions

static RV_VKBufferPtr allocate (RV_Instance *inst, exint size, VkBufferUsageFlags usage, bool is_staging, VkFormat vk_format=VK_FORMAT_UNDEFINED, const char *name=nullptr, exint alignment=0)
 Allocate a new Buffer object Allocate a vulkan buffer is_staging - if true, buffer will be CPU visible. More...
 
static RV_VKBufferPtr allocate (RV_Instance *inst, exint size, VkBufferUsageFlags usage, RV_MemType mem_type, VkFormat vk_format=VK_FORMAT_UNDEFINED, const char *name=nullptr, exint alignment=0)
 Allocate a new Buffer object Allocate a vulkan buffer mem_type - Memory type to use. More...
 

Public Attributes

RV_StageGroup myWaitingBarrierStage = RV_STAGE_NONE
 
exint myWaitingBarrierGroupID = -1
 

Protected Attributes

RV_InstancemyInst = nullptr
 
VkBuffer myVkBuf = VK_NULL_HANDLE
 
RV_ResourceID myId
 
UT_StringHolder myName
 
UT_UniquePtr< const
RV_VKBufferCreateInfo
myCreateInfo
 
UT_UniquePtr< RV_VKBufferViewmyView
 
UT_UniquePtr< RV_VKMemory > myMemory
 
VkBufferUsageFlags myLastUsage
 

Detailed Description

A vulkan buffer object.

Definition at line 81 of file RV_VKBuffer.h.

Constructor & Destructor Documentation

virtual RV_VKBuffer::~RV_VKBuffer ( )
virtual
RV_VKBuffer::RV_VKBuffer ( RV_Instance inst,
const RV_VKBufferCreateInfo info,
VkBuffer  vk_buf,
RV_VKMemoryPtr  mem,
RV_VKBufferViewPtr  view,
const PassKey &   
)

Member Function Documentation

void RV_VKBuffer::addBarrier ( RV_Render r,
VkBufferUsageFlags  new_usage 
)
inline

Add a barrier for using the buffer in the future.

Definition at line 214 of file RV_VKBuffer.h.

void RV_VKBuffer::addBarrier ( RV_Render r,
VkBufferUsageFlags  old_usage,
VkBufferUsageFlags  new_usage 
)

Add a barrier for using the buffer in the future, changing its usage.

static RV_VKBufferPtr RV_VKBuffer::allocate ( RV_Instance inst,
exint  size,
VkBufferUsageFlags  usage,
bool  is_staging,
VkFormat  vk_format = VK_FORMAT_UNDEFINED,
const char *  name = nullptr,
exint  alignment = 0 
)
static

Allocate a new Buffer object Allocate a vulkan buffer is_staging - if true, buffer will be CPU visible.

vk_format - if provided, a BufferView is only created – only needed for texel buffer usage

static RV_VKBufferPtr RV_VKBuffer::allocate ( RV_Instance inst,
exint  size,
VkBufferUsageFlags  usage,
RV_MemType  mem_type,
VkFormat  vk_format = VK_FORMAT_UNDEFINED,
const char *  name = nullptr,
exint  alignment = 0 
)
static

Allocate a new Buffer object Allocate a vulkan buffer mem_type - Memory type to use.

vk_format - if provided, a BufferView is only created – only needed for texel buffer usage

void RV_VKBuffer::clear ( RV_Render r)

Clear the buffer with 0.

bool RV_VKBuffer::copyData ( RV_Render r,
RV_VKBuffer buf,
exint  src_offset = 0,
exint  dst_offset = 0,
exint  sublen = -1 
)

Download data from the buffer into buf

bool RV_VKBuffer::downloadData ( RV_Render r,
void data,
exint  data_size,
exint  offset = 0,
exint  sublen = -1 
)

Donwload data from the buffer to data. Returns false if the operation would read data out-of-range or there was an error.

exint RV_VKBuffer::entries ( ) const

Number of elements in this buffer (eg. RGB 32b is 1 element)

VkDeviceAddress RV_VKBuffer::getDeviceAddress ( ) const

Return the device address of the buffer.

RV_GPUType RV_VKBuffer::getGPUType ( ) const

Return the RV type of the buffer.

const RV_ResourceID& RV_VKBuffer::getID ( ) const
inline

Return unique ID for buffer object.

Definition at line 123 of file RV_VKBuffer.h.

const RV_VKBufferCreateInfo& RV_VKBuffer::getInfo ( )
inline

Get the create info the buffer was created with.

Definition at line 116 of file RV_VKBuffer.h.

VkBufferUsageFlags RV_VKBuffer::getLastUsage ( ) const
inline

return the current usage of this buffer

Definition at line 144 of file RV_VKBuffer.h.

void* RV_VKBuffer::getMappedMemory ( )

Get a CPU mapped ptr to the raw memory. Will return nullptr if buffer wasn't declared as CPU visible

RV_VKMemory& RV_VKBuffer::getMemory ( )
inline

Get the memory the buffer is backed by.

Definition at line 118 of file RV_VKBuffer.h.

const RV_VKMemory& RV_VKBuffer::getMemory ( ) const
inline

Definition at line 119 of file RV_VKBuffer.h.

const UT_StringHolder& RV_VKBuffer::getName ( ) const
inline

Return label for buffer object.

Definition at line 125 of file RV_VKBuffer.h.

exint RV_VKBuffer::getSize ( ) const
inline

Return the size of the buffer, in bytes.

Definition at line 140 of file RV_VKBuffer.h.

VkBufferUsageFlags RV_VKBuffer::getUsage ( ) const
inline

return the vulkan usage of the buffer when it was created

Definition at line 142 of file RV_VKBuffer.h.

int RV_VKBuffer::getVectorSize ( ) const

Return the vector size of the buffer (1-4)

VkBuffer RV_VKBuffer::getVkBuf ( )
inline

Get the raw vulkan buffer handle.

Definition at line 114 of file RV_VKBuffer.h.

VkFormat RV_VKBuffer::getVkFormat ( ) const
inline

Return the vulkan format of the buffer.

Definition at line 134 of file RV_VKBuffer.h.

VkBufferView RV_VKBuffer::getVkView ( )
inline

Fetch the buffer view assigned to this buffer, if any.

Definition at line 128 of file RV_VKBuffer.h.

exint RV_VKBuffer::gpuMemoryUsage ( ) const

Return the memory size this buffer uses, in bytes.

bool RV_VKBuffer::isMappedMemory ( ) const

return whether buffer was declared as CPU visible, and mapped

void RV_VKBuffer::print ( ) const

Debug output of the buffer (but not its data).

bool RV_VKBuffer::uploadData ( RV_Render r,
VkBufferUsageFlags  new_usage,
const void data,
exint  data_size,
exint  data_offset = 0 
)

Upload data to the buffer Upload data to the buffer and add a barrier based on its usage. Returns true if the size+offset doesn't exceed the allocated size.

bool RV_VKBuffer::uploadData ( RV_Render r,
const void data,
exint  data_size,
exint  data_offset = 0 
)

Upload data to the buffer Upload data to the buffer. Returns true if the size+offset doesn't exceed the allocated size.

template<typename T , typename std::enable_if<!std::is_pointer< T >::value, int >::type = 0>
bool RV_VKBuffer::uploadData ( RV_Render r,
const T data 
)
inline

Span version of buffer upload.

Definition at line 173 of file RV_VKBuffer.h.

template<typename T , typename std::enable_if<!std::is_pointer< T >::value, int >::type = 0>
bool RV_VKBuffer::uploadData ( RV_Render r,
VkBufferUsageFlags  new_usage,
const T data 
)
inline

Definition at line 181 of file RV_VKBuffer.h.

Member Data Documentation

UT_UniquePtr<const RV_VKBufferCreateInfo> RV_VKBuffer::myCreateInfo
protected

Definition at line 240 of file RV_VKBuffer.h.

RV_ResourceID RV_VKBuffer::myId
protected

Definition at line 238 of file RV_VKBuffer.h.

RV_Instance* RV_VKBuffer::myInst = nullptr
protected

Definition at line 235 of file RV_VKBuffer.h.

VkBufferUsageFlags RV_VKBuffer::myLastUsage
protected

Definition at line 244 of file RV_VKBuffer.h.

UT_UniquePtr<RV_VKMemory> RV_VKBuffer::myMemory
protected

Definition at line 243 of file RV_VKBuffer.h.

UT_StringHolder RV_VKBuffer::myName
protected

Definition at line 239 of file RV_VKBuffer.h.

UT_UniquePtr<RV_VKBufferView> RV_VKBuffer::myView
protected

Definition at line 242 of file RV_VKBuffer.h.

VkBuffer RV_VKBuffer::myVkBuf = VK_NULL_HANDLE
protected

Definition at line 237 of file RV_VKBuffer.h.

exint RV_VKBuffer::myWaitingBarrierGroupID = -1

Definition at line 248 of file RV_VKBuffer.h.

RV_StageGroup RV_VKBuffer::myWaitingBarrierStage = RV_STAGE_NONE

Definition at line 247 of file RV_VKBuffer.h.


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