Class AllocatedBuffer

Inheritance Relationships

Base Type

Class Documentation

class AllocatedBuffer : public portal::renderer::vulkan::allocation::Allocated<vk::Buffer>

VMA-allocated Vulkan buffer with automatic memory management.

Inherits from Allocated<vk::Buffer>, providing VMA memory allocation/deallocation, memory mapping, and update methods. Stores buffer size and provides device address query.

Destruction automatically calls vmaDestroyBuffer to free both buffer and backing memory.

Public Functions

AllocatedBuffer()

Default constructor (creates null buffer)

inline AllocatedBuffer(std::nullptr_t)

Null constructor.

AllocatedBuffer(AllocatedBuffer &&other) noexcept

Move constructor.

AllocatedBuffer &operator=(AllocatedBuffer &&other) noexcept

Move assignment.

virtual AllocatedBuffer &operator=(std::nullptr_t) noexcept override

Null assignment.

AllocatedBuffer(const AllocatedBuffer&) = delete
AllocatedBuffer &operator=(const AllocatedBuffer&) = delete
~AllocatedBuffer() override

Destructor (calls vmaDestroyBuffer)

uint64_t get_device_address() const

Gets buffer device address (requires eShaderDeviceAddress usage)

Returns:

Buffer device address (for bindless/GPU-driven rendering)

vk::DeviceSize get_size() const

Gets buffer size.

Returns:

Size in bytes

Public Static Functions

static AllocatedBuffer create_staging_buffer(const VulkanDevice &device, vk::DeviceSize size, const void *data)

Creates staging buffer with data.

Parameters:
  • device – The Vulkan device

  • size – Buffer size in bytes

  • data – Data to copy into buffer

Returns:

AllocatedBuffer with HOST_VISIBLE memory and copied data

template<typename T>
static AllocatedBuffer create_staging_buffer(const VulkanDevice &device, const std::span<T> &data)

Creates staging buffer from std::span.

Template Parameters:

T – Element type

Parameters:
  • device – The Vulkan device

  • data – Span of data to copy

Returns:

AllocatedBuffer with HOST_VISIBLE memory

template<typename T>
static AllocatedBuffer create_staging_buffer(const VulkanDevice &device, const T &data)

Creates staging buffer from single object.

Template Parameters:

T – Object type

Parameters:
  • device – The Vulkan device

  • data – Object to copy

Returns:

AllocatedBuffer with HOST_VISIBLE memory

Protected Functions

AllocatedBuffer(const VulkanDevice &device, const BufferBuilder &builder)

Protected constructor (use BufferBuilder::build instead)

Parameters:
  • device – The Vulkan device

  • builder – Buffer builder with configuration

Friends

friend struct BufferBuilder