tp::BufferView class

Represents the view of a contiguous range of tp::Buffer memory.

Optionally, it can be made to interpret the data in a particular format for binding to a tp::Descriptor of the tp::DescriptorType::TexelBuffer or tp::DescriptorType::StorageTexelBuffer types. Such buffer views are called texel buffer views.

Constructors, destructors, conversion operators

BufferView()
Constructs a null tp::BufferView.

Public functions

auto createTexelView(uint64_t offset, uint64_t size, Format format) -> BufferView
Creates a texel buffer view of the viewed buffer relative to this view.
auto getDeviceAddress() const -> VkDeviceAddress
Returns the device address of the buffer view that can then be used for accessing it in shaders.
auto getFormat() const -> Format
Returns the format of the buffer view. Texel buffer views have a format other than tp::Format::Undefined.
auto getMemoryLocation() const -> MemoryLocation
Returns the tp::MemoryLocation of the underlying buffer, or tp::MemoryLocation::Undefined if it doesn't exist yet.
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 view in bytes.
auto getView(uint64_t offset, uint64_t size) const -> BufferView
Returns another view of the viewed buffer relative to this view.
auto isNull() const -> bool
Returns true if the buffer view is null and does not view any resource.
auto mapForHostAccess(MemoryAccess accessType) const -> HostMappedMemory
Maps the viewed range of the buffer to visible memory, allowing it to be written or read out by the application.
auto viewsJobLocalBuffer() const -> bool
Returns true if the instance views a job-local buffer. Returns false if it views a persistent or a job preinitialized buffer and therefore can be mapped for host access.
auto vkGetBufferViewHandle() const -> VkBufferViewHandle
Returns the associated Vulkan VkBufferView handle of a texel buffer view, VK_NULL_HANDLE otherwise.
auto vkResolveBufferHandle(uint64_t* offset) const -> VkBufferHandle
Resolves and returns the underlying VkBuffer handle of this view or VK_NULL_HANDLE if it doesn't exist.

Friends

auto operator==(const BufferView&, const BufferView&) -> bool
Equality operator for tp::BufferView.

Function documentation

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

Creates a texel buffer view of the viewed buffer relative to this view.

Parameters
offset The additional 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::BufferView::getDeviceAddress() const

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

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

Returns another view of the viewed buffer relative to this view.

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

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

Maps the viewed range of 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 range.

VkBufferViewHandle tp::BufferView::vkGetBufferViewHandle() const

Returns the associated Vulkan VkBufferView handle of a texel buffer view, VK_NULL_HANDLE otherwise.

VkBufferHandle tp::BufferView::vkResolveBufferHandle(uint64_t* offset) const

Resolves and returns the underlying VkBuffer handle of this view or VK_NULL_HANDLE if it doesn't exist.

Parameters
offset An output parameter to which the offset of the view in bytes will be set if the underlying buffer exists.