Class UploadBatch#

Class Documentation#

class UploadBatch#

Records many textures’ and buffers’ uploads into one command buffer through one staging ring, a host-visible buffer filled front to back and reused after each submit: one fence wait per fill instead of one per upload. A staged Texture must stay where it is until finish(), which writes or, on a failed submit, empties it.

Public Functions

UploadBatch(std::shared_ptr<VulkanDevice> device, vk::CommandPool command_pool, vk::DeviceSize expected_bytes)#
UploadBatch(const UploadBatch&) = delete#
UploadBatch &operator=(const UploadBatch&) = delete#
UploadBatch(UploadBatch&&) = delete#
UploadBatch &operator=(UploadBatch&&) = delete#
~UploadBatch()#
bool finish()#

Submits what is recorded and waits for it; false when that submit failed.

std::span<std::byte> stageBuffer(vk::Buffer target, vk::DeviceSize byteCount)#

Records a copy of byteCount bytes into target, which the caller created; the ring bytes to fill before the next stage, or empty when there is no room or command buffer. A failed submit leaves the buffer unwritten.

inline std::size_t stagedCount() const#
inline std::size_t submitCount() const#
inline vk::DeviceSize ringBytes() const#

Public Static Attributes

static constexpr vk::DeviceSize kMaxRingBytes = vk::DeviceSize{64} << 20U#

The ring never holds more than this unless one texture needs more.

static constexpr vk::DeviceSize kOffsetAlignment = 16#

Each staged upload starts at a multiple of this, so a ring sized for a set of uploads counts it once per upload.