Class Buffer#

Inheritance Relationships#

Derived Type#

Class Documentation#

class Buffer#

Subclassed by TRAP::Graphics::API::VulkanBuffer

Public Functions

virtual ~Buffer()#

Destructor.

consteval Buffer(const Buffer&) noexcept = delete#

Copy constructor.

consteval Buffer &operator=(const Buffer&) noexcept = delete#

Copy assignment operator.

constexpr Buffer(Buffer&&) noexcept = default#

Move constructor.

Buffer &operator=(Buffer&&) noexcept = default#

Move assignment operator.

constexpr u64 GetSize() const noexcept#

Retrieve the size of the buffer in bytes.

Returns:

Size of the buffer in bytes.

constexpr RendererAPI::DescriptorType GetDescriptors() const noexcept#

Retrieve the type of descriptor.

Returns:

Type of descriptor.

constexpr RendererAPI::ResourceMemoryUsage GetMemoryUsage() const noexcept#

Retrieve the usage of the buffer memory.

Returns:

Usage of the buffer memory.

template<typename T = u8>
constexpr std::span<T> GetCPUMappedAddress() const noexcept#

Retrieve the CPU mapped memory range of the buffer.

Note

MapBuffer must be called before accessing the buffer on the CPU.

Returns:

CPU mapped memory range of the buffer.

virtual bool MapBuffer(const RendererAPI::ReadRange &range = {}) = 0#

Map a region of the buffer to the CPU.

Note

MapBuffer must not be called if memory usage is GPU only.

Parameters:

rangeOptional range of the buffer to map. Default: Whole buffer.

Returns:

Returns true if the buffer was successfully mapped, false otherwise.

virtual void UnMapBuffer() = 0#

Unmap CPU mapped memory region.

Note

UnMapBuffer must not be called if memory usage is GPU only.

Public Static Functions

static TRAP::Ref<Buffer> Create(const RendererAPI::BufferDesc &desc)#

Create a new buffer from the given description.

Parameters:

descBuffer description.

Returns:

Created buffer.

Protected Functions

Buffer(u64 size, RendererAPI::DescriptorType descriptorType, RendererAPI::ResourceMemoryUsage memoryUsage)#

Constructor.

Protected Attributes

std::span<u8> m_CPUMappedAddress = {}#
u64 m_size = 0#
RendererAPI::DescriptorType m_descriptors = RendererAPI::DescriptorType::Undefined#
RendererAPI::ResourceMemoryUsage m_memoryUsage = RendererAPI::ResourceMemoryUsage::Unknown#