NDEVR
API Documentation
VulkanStagingRing

A ring buffer for staging GPU uploads. More...

Public Member Functions

 VulkanStagingRing (const VulkanDevice *device)
 Constructs a staging ring for the given device.
 ~VulkanStagingRing ()
 Destructor.
void begin ()
 Begins a new staging cycle.
void cleanup ()
 Releases all staging ring resources.
void end ()
 Ends the current staging cycle and submits pending transfers.
void ensureComplete ()
 Ensures all pending transfers are complete before returning.
void ensureSize (VkDeviceSize size)
 Ensures the staging buffer is at least the given size.
VkCommandBuffer getCommandBuffer ()
 Returns a command buffer for recording transfer commands.
void * mapData (VkDeviceSize size)
 Maps a region of the staging buffer for writing.
void moveData (VkBuffer target, VkDeviceSize src_offset, VkDeviceSize dst_offset, VkDeviceSize size)
 Moves data within a buffer using a transfer command.
void removePending (VkBuffer buffer)
 Removes all pending copy operations targeting the given buffer.
void sendData (VkBuffer dst, VkDeviceSize dst_offset_bytes)
 Queues a copy from the staging buffer to a destination buffer.
void sendData (VkImage dst, Vector< 2, uint04 > image_size, uint04 mip_level, uint04 image_layer, VkCommandBuffer command_buffer)
 Queues a copy from the staging buffer to a destination image.
void setData (const void *data, VkDeviceSize byte_size, VkDeviceSize alignment=1)
 Writes data into the staging buffer.
void setDeviceLost ()
 Handles device lost by resetting internal state.
void setSize (VkDeviceSize size)
 Sets the staging buffer to the given size.

Detailed Description

A ring buffer for staging GPU uploads.


Batches CPU-to-GPU data transfers through a shared staging buffer, submitting them as command buffers when ready.

Definition at line 34 of file VulkanStagingRing.h.

Constructor & Destructor Documentation

◆ VulkanStagingRing()

VulkanStagingRing::VulkanStagingRing ( const VulkanDevice * device)

Constructs a staging ring for the given device.

Parameters
[in]deviceThe Vulkan device.

◆ ~VulkanStagingRing()

VulkanStagingRing::~VulkanStagingRing ( )

Destructor.

Cleans up staging resources.

Member Function Documentation

◆ ensureSize()

void VulkanStagingRing::ensureSize ( VkDeviceSize size)

Ensures the staging buffer is at least the given size.

Parameters
[in]sizeThe minimum required size in bytes.

◆ getCommandBuffer()

VkCommandBuffer VulkanStagingRing::getCommandBuffer ( )

Returns a command buffer for recording transfer commands.

Returns
The VkCommandBuffer handle.

◆ mapData()

void * VulkanStagingRing::mapData ( VkDeviceSize size)

Maps a region of the staging buffer for writing.

Parameters
[in]sizeThe number of bytes to map.
Returns
A pointer to the mapped memory.

◆ moveData()

void VulkanStagingRing::moveData ( VkBuffer target,
VkDeviceSize src_offset,
VkDeviceSize dst_offset,
VkDeviceSize size )

Moves data within a buffer using a transfer command.

Parameters
[in]targetThe VkBuffer to move data within.
[in]src_offsetThe source byte offset.
[in]dst_offsetThe destination byte offset.
[in]sizeThe number of bytes to move.

◆ removePending()

void VulkanStagingRing::removePending ( VkBuffer buffer)

Removes all pending copy operations targeting the given buffer.

Parameters
[in]bufferThe VkBuffer to remove pending operations for.

◆ sendData() [1/2]

void VulkanStagingRing::sendData ( VkBuffer dst,
VkDeviceSize dst_offset_bytes )

Queues a copy from the staging buffer to a destination buffer.

Parameters
[in]dstThe destination VkBuffer.
[in]dst_offset_bytesThe byte offset in the destination buffer.

◆ sendData() [2/2]

void VulkanStagingRing::sendData ( VkImage dst,
Vector< 2, uint04 > image_size,
uint04 mip_level,
uint04 image_layer,
VkCommandBuffer command_buffer )

Queues a copy from the staging buffer to a destination image.

Parameters
[in]dstThe destination VkImage.
[in]image_sizeThe image dimensions.
[in]mip_levelThe target mip level.
[in]image_layerThe target array layer.
[in]command_bufferThe command buffer to record into.

◆ setData()

void VulkanStagingRing::setData ( const void * data,
VkDeviceSize byte_size,
VkDeviceSize alignment = 1 )

Writes data into the staging buffer.

Parameters
[in]dataPointer to the source data.
[in]byte_sizeThe number of bytes to write.
[in]alignmentThe required alignment in bytes.

◆ setSize()

void VulkanStagingRing::setSize ( VkDeviceSize size)

Sets the staging buffer to the given size.

Parameters
[in]sizeThe size in bytes.

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