NDEVR
API Documentation
VulkanComputeBuffer

A GPU storage buffer (SSBO) for compute shader use, with a separate staging buffer for host-visible upload/download transfers. More...

Public Member Functions

void allocate (VkDeviceSize byte_size, bool device_local=false)
 Allocate the buffer.
VkBuffer buffer () const
 The device-local VkBuffer (for binding as SSBO in descriptor sets).
VkDeviceSize byteSize () const
 The allocated byte size.
void cleanup ()
 Free all Vulkan resources.
void download (void *data, VkDeviceSize byte_size) const
 Download data from device buffer to CPU via staging.
bool isAllocated () const
 Whether the buffer has been allocated.
void upload (const void *data, VkDeviceSize byte_size)
 Upload data from CPU to the device buffer via staging.

Detailed Description

A GPU storage buffer (SSBO) for compute shader use, with a separate staging buffer for host-visible upload/download transfers.


Allocates a device-local VkBuffer with STORAGE_BUFFER | TRANSFER_SRC | TRANSFER_DST usage, plus a host-visible staging buffer for data transfers. Follows the same pattern as VulkanBuffer::CreateVKBuffer but is specialized for compute shader SSBO access.

Definition at line 47 of file VulkanComputeBuffer.h.

Member Function Documentation

◆ allocate()

void VulkanComputeBuffer::allocate ( VkDeviceSize byte_size,
bool device_local = false )

Allocate the buffer.

Parameters
byte_sizeTotal size in bytes
device_localWhen true, allocates DEVICE_LOCAL memory for shader use plus a HOST_VISIBLE staging buffer for transfers (best performance on discrete GPUs). When false, uses a single HOST_VISIBLE buffer (simplest, fine for integrated GPUs or small buffers).

◆ download()

void VulkanComputeBuffer::download ( void * data,
VkDeviceSize byte_size ) const

Download data from device buffer to CPU via staging.

Parameters
dataDestination pointer
byte_sizeNumber of bytes to copy (must be <= allocated size)

◆ upload()

void VulkanComputeBuffer::upload ( const void * data,
VkDeviceSize byte_size )

Upload data from CPU to the device buffer via staging.

Parameters
dataSource pointer
byte_sizeNumber of bytes to copy (must be <= allocated size)

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