tp::BufferView class

Represents a non-owning 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 -> DeviceAddress
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(bool readAccess = true, bool writeAccess = true) const -> HostAccessibleMemory
Maps the viewed range of the buffer's memory for direct read or write operations by the application. tp::BufferView::mapForHostRead or tp::BufferView::mapForHostWrite should be preferred over this generic access.
auto mapForHostRead() const -> HostReadableMemory
Maps the viewed range of the buffer's memory for direct read operations by the application.
auto mapForHostWrite() const -> HostWritableMemory
Maps the viewed range of the buffer's memory for direct write operations 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.

DeviceAddress 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.

HostAccessibleMemory tp::BufferView::mapForHostAccess(bool readAccess = true, bool writeAccess = true) const

Maps the viewed range of the buffer's memory for direct read or write operations by the application. tp::BufferView::mapForHostRead or tp::BufferView::mapForHostWrite should be preferred over this generic access.

Parameters
readAccess If true, specifies that the application intends to read from the memory.
writeAccess If true, specifies that the application intends to write to the memory.

HostReadableMemory tp::BufferView::mapForHostRead() const

Maps the viewed range of the buffer's memory for direct read operations by the application.

HostWritableMemory tp::BufferView::mapForHostWrite() const

Maps the viewed range of the buffer's memory for direct write operations by the application.

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.