class
GpuBuffer
Defines a buffer that can be used for operations on the GPU.
Public
Methods
~GpuBuffer
GetTotalSize
Returns the total size of this buffer in bytes.
GetSuballocationSize
In case this buffer is containing multiple sub-allocated buffers, returns the size of one sub-allocation.
Note this size might be different than requested during creation as platform alignment requirements for suballocation must be respected.
If the buffer doesn't have any suballocated buffers, this is equivalent to GetTotalSize().
GetInformation
Returns information describing the buffer.
Write
Writes the data into the CPU cached buffer.
Data will be synced with the render proxy on the next sync call.
WriteTyped
Same as Write(), but takes care of respecting the padding/alignment requirements of the provided type. (e.g. a 3x3 matrix will be padded with 4 bytes in each row). must contain at least as many bytes as the size provided in .
Returns the total number of written bytes, including the padding.
ZeroOut
Clears the specified area of the cache.
Data will be synced with the render proxy on the next sync call.
Read
Reads the data from the cached buffer.
Note the cached data only includes writes done by the CPU. It will not account for writes done explicitly on the render thread or on the GPU.
Map
Maps the cache buffer and returns an RAII mapped region that automatically handles flush on destruction.
- offset
- Offset in bytes from which to map.
- size
- Size of the region to map, in bytes.
- options
- Specifies read/write intent for the mapping.
Returns: RAII mapped region containing the mapped memory pointer.
Map
Maps the entire buffer and returns an RAII mapped region.
- options
- Specifies read/write intent for the mapping.
Returns: RAII mapped region containing the mapped memory pointer.
staticCreate
Creates a new buffer.
staticGetFormatSize
Returns the size of a single element in the buffer, of the provided format, in bytes.
staticGetIndexSize
Returns the size of a single index buffer element of the specified type, in bytes.
staticCalculateTotalBufferSize
Calculates the size of a buffer described by the provided information, in bytes.
staticCalculateSuballocatedBufferSize
Calculates the distance between two buffers, in case the buffer contains sub-allocated buffers.
This is guaranteed to be at least the request size of a single sub-allocated buffer, but may be larger due to alignment requirements.
staticCalculateSuballocatedBufferSize
Protected
Constructors
GpuBuffer
Methods
Initialize
Initializes all the internal data of this object.
Must be called right after construction for new objects, or after deserialization for deserialized objects. If requested, render proxy is created and queued for initialization on the render thread.
Destroy
Frees all the data held by this object.
If the object has a render proxy, the internal reference to the render proxy will be released, but the proxy will not be destroyed unless this was the last reference. If render proxy destruction does happen, it is not immediate, but rather queued for destruction on the render thread.
CreateRenderProxy
Creates an object that contains render thread specific data and methods for this object.
Can be null if such object is not required.
CreateRenderProxySyncPacket
Creates a data packet that will be used for syncing the core object with it's render proxy.
Caller must free the retrieved packet using the provided allocator when done using it.