class GpuResourceData

Inherits: IReflectable

You can use this class as a storage for reading and writing from/to various GPU resources.

It is meant to be created on main thread and used on the render thread. This class is abstract and specific resource types need to implement their own type of GpuResourceData.

Public

Constructors

GpuResourceData

GpuResourceData() = default

GpuResourceData

GpuResourceData(const GpuResourceData &copy)

Methods

~GpuResourceData

virtual ~GpuResourceData() noexcept

GetData

u8 *GetData() const

Returns pointer to the internal buffer.

SetData

void SetData(UPtr<u8[]> &data)

Sets the internal pointer to point at provided data.

GpuResourceData takes ownership of provided memory.

AllocateInternalBuffer

void AllocateInternalBuffer()

Allocates an internal buffer of a certain size.

If there is another buffer already allocated, it will be freed and new one will be allocated. Buffer size is determined based on parameters used for initializing the class.

AllocateInternalBuffer

void AllocateInternalBuffer(u32 size)

Allocates an internal buffer of a certain size.

If there is another buffer already allocated, it will be freed and new one will be allocated.

size
The size of the buffer in bytes.

FreeInternalBuffer

void FreeInternalBuffer()

Frees the internal buffer that was allocated using allocateInternalBuffer().

Called automatically when the instance of the class is destroyed.

SetExternalBuffer

void SetExternalBuffer(u8 *data)

Makes the internal data pointer point to some external data.

No copying is done, so you must ensure that external data exists as long as this class uses it. You are also responsible for deleting the data when you are done with it.

IsLocked

bool IsLocked() const

Checks if the internal buffer is locked due to some other thread using it.

LockInternal

void LockInternal() const

Locks the data and makes it available only to the render thread.

UnlockInternal

void UnlockInternal() const

Unlocks the data and makes it available to all threads.

staticGetRttiStatic

static RTTIType *GetRttiStatic()

GetRtti

RTTIType *GetRtti() const override

Returns an interface you can use to access class' Run Time Type Information.

Operators

operator=

GpuResourceData &operator=(const GpuResourceData &rhs)

Protected

Methods

GetInternalBufferSize

virtual u32 GetInternalBufferSize() const = 0

Returns the size of the internal buffer in bytes.

This is calculated based on parameters provided upon construction and specific implementation details.

Private

Fields

mData

u8 * mData

mOwnsData

bool mOwnsData

mLocked

bool mLocked