tp::HostMappedMemory class

Represents tp::Buffer memory mapped for host access by the application. Automatically handles cache management for incoherent memory types and unmaps the memory when destroyed, if the memory is not mapped persistently.

Constructors, destructors, conversion operators

HostMappedMemory(Buffer* mappedBuffer, uint64_t mappingOffset, uint64_t mappingSize, MemoryAccess accessType)
Maps a range of tp::Buffer memory. See tp::BufferView::mapForHostAccess for more convenient mapping of tp::BufferView objects.

Public functions

template<typename T>
auto getArrayView() -> ArrayView<T>
Returns an array view of the mapped memory interpreted as the given type.
template<typename T>
auto getArrayView() const -> ArrayView<const T>
Returns an array view of the mapped memory interpreted as the given type.
template<typename T>
auto getArrayView(uint64_t byteOffset, uint64_t count) -> ArrayView<T>
Returns an array view of the mapped memory with a byte offset interpreted as count elements of the given type.
template<typename T>
auto getArrayView(uint64_t byteOffset, uint64_t count) const -> ArrayView<const T>
Returns an array view of the mapped memory with a byte offset interpreted as count elements of the given type.
template<typename T = void>
auto getPtr() -> T*
Returns a pointer to the mapped memory interpreted as the given type.
template<typename T = void>
auto getPtr() const -> const T*
Returns a pointer to the mapped memory interpreted as the given type.
template<typename T = void>
auto getPtr(uint64_t byteOffset) -> T*
Returns a pointer to the mapped memory with a byte offset interpreted as the given type.
template<typename T = void>
auto getPtr(uint64_t byteOffset) const -> const T*
Returns a pointer to the mapped memory with a byte offset interpreted as the given type.
auto getSize() const -> uint64_t
Returns the size of the mapped memory in bytes.
auto isNull() const -> bool
Returns true if no memory is mapped.

Function documentation

tp::HostMappedMemory::HostMappedMemory(Buffer* mappedBuffer, uint64_t mappingOffset, uint64_t mappingSize, MemoryAccess accessType)

Maps a range of tp::Buffer memory. See tp::BufferView::mapForHostAccess for more convenient mapping of tp::BufferView objects.

Parameters
mappedBuffer The tp::Buffer to map.
mappingOffset The base offset to the memory range to be mapped.
mappingSize The size of the memory range to be mapped.
accessType The type of access.