tp::Buffer class

Represents a linear array of data visible to the device.

They are not used directly, but instead are passed to commands or descriptors through tp::BufferView objects that view a contiguous range of its data.

Base classes

class Ownable
A customizable base class that is used for objects returned by the API in an OwningPtr.

Public static functions

static auto getRequiredViewAlignment(const Device* device, BufferUsageMask usage) -> uint64_t
Returns the minimum required alignment in bytes for the views of any buffer with the given usage flags. It is always a power of two not larger than 256 bytes.

Constructors, destructors, conversion operators

operator const BufferView() const
Casting operator returning the default tp::BufferView object.

Public functions

auto createTexelView(uint64_t offset, uint64_t size, Format format) -> BufferView
Creates a texel buffer view of the buffer data.
auto getDefaultView() const -> const BufferView
Returns the default tp::BufferView object that views the entire buffer range.
auto getDeviceAddress() const -> VkDeviceAddress
Returns the device address of the buffer that can then be used for accessing it in shaders.
auto getMemoryLocation() const -> MemoryLocation
Returns the tp::MemoryLocation that the buffer has been allocated from.
auto getRequiredViewAlignment() const -> uint64_t
Returns the minimum required alignment in bytes for the views of this buffer. It is always a power of two not larger than 256 bytes.
auto getSize() const -> uint64_t
Returns the size of the buffer in bytes.
auto getView(uint64_t offset, uint64_t size) const -> BufferView
Returns a view of a specified contiguous range of the buffer data.
auto mapForHostAccess(MemoryAccess accessType) const -> HostMappedMemory
Maps the buffer to visible memory, allowing it to be written or read out by the application.
auto vkGetBufferHandle() const -> VkBufferHandle
Returns the associated VkBuffer handle.
auto vmaGetMemoryAllocationHandle() const -> VmaAllocationHandle
Returns the associated <a href='https://gpuopen-librariesandsdks.github.io/VulkanMemoryAllocator/html/struct_vma_allocation.html">VmaAllocation handle.

Function documentation

static uint64_t tp::Buffer::getRequiredViewAlignment(const Device* device, BufferUsageMask usage)

Returns the minimum required alignment in bytes for the views of any buffer with the given usage flags. It is always a power of two not larger than 256 bytes.

Parameters
device The device that the parent buffer will be allocated from.
usage The usage of the buffer.

tp::Buffer::operator const BufferView() const

Casting operator returning the default tp::BufferView object.

BufferView tp::Buffer::createTexelView(uint64_t offset, uint64_t size, Format format)

Creates a texel buffer view of the buffer data.

Parameters
offset The offset to the viewed buffer in bytes. Must be a multiple of tp::Buffer::getRequiredViewAlignment.
size The size of the buffer view in bytes.
format The format that the viewed data will be interpreted as when bound as a texel buffer descriptor. Must not be tp::Format::Undefined.

VkDeviceAddress tp::Buffer::getDeviceAddress() const

Returns the device address of the buffer that can then be used for accessing it in shaders.

BufferView tp::Buffer::getView(uint64_t offset, uint64_t size) const

Returns a view of a specified contiguous range of the buffer data.

Parameters
offset The offset to the viewed buffer in bytes. Must be a multiple of tp::Buffer::getRequiredViewAlignment.
size The size of the buffer view in bytes.

HostMappedMemory tp::Buffer::mapForHostAccess(MemoryAccess accessType) const

Maps the buffer to visible memory, allowing it to be written or read out by the application.

Parameters
accessType Specifies the allowed types of access.
Returns Returns tp::HostMappedMemory object that can be used to access the memory.