A staging buffer is a buffer that resides on the GPU and be written to/from both CPU & GPU However the access in both cases is limited.
More...
|
| StagingBuffer (size_t internalBufferStart, size_t sizeBytes, VaoManager *vaoManager, bool uploadOnly) |
|
virtual | ~StagingBuffer () |
|
virtual size_t | _asyncDownload (BufferPacked *source, size_t srcOffset, size_t srcLength)=0 |
| Copies the GPU data in BufferPacked to the StagingBuffer so that it can be later read by the CPU using an AsyncTicket. More...
|
|
virtual void | _cancelDownload (size_t offset, size_t sizeBytes) |
| Releases memory assigned to a download that hasn't been mapped yet, to make space for another _asyncDownload call. More...
|
|
const void * | _mapForRead (size_t offset, size_t sizeBytes) |
| Maps the buffer for read acces for the CPU. More...
|
|
void | addReferenceCount () |
| Adds a reference count to the StagingBuffer. More...
|
|
virtual bool | canDownload (size_t length) const |
| Checks if this staging buffer has enough free space to use _asyncDownload. More...
|
|
uint64 | getLastUsedTimestamp () const |
| Returns the time in millisecond when the ref. count became 0. More...
|
|
uint32 | getLifetimeThreshold () const |
| Returns the time in milliseconds in which a StagingBuffer should live with a reference count of 0 before being deleted. More...
|
|
MappingState | getMappingState () const |
|
size_t | getMaxSize () |
|
int16 | getReferenceCount () const |
|
uint32 | getUnfencedTimeThreshold () const |
| Returns the time in milliseconds in which a StagingBuffer should hazards unfenced while with a reference count of 0. More...
|
|
bool | getUploadOnly () const |
| When true, this buffer can only be used for uploading to GPU. More...
|
|
void * | map (size_t sizeBytes) |
| Maps the given amount of bytes. More...
|
|
void | removeReferenceCount () |
| Decreases the reference count by one. More...
|
|
void | unmap (const Destination &destination) |
| Unmaps the mapped region and copies the data to the given region. More...
|
|
void | unmap (const Destination *destinations, size_t numDestinations) |
|
void | unmap (const DestinationVec &destinations) |
| Unmaps the mapped region and copies the data to multiple buffers. More...
|
|
virtual StagingStallType | uploadWillStall (size_t sizeBytes) |
| Returns true if our next call to map() with the same parameters will stall. More...
|
|
A staging buffer is a buffer that resides on the GPU and be written to/from both CPU & GPU However the access in both cases is limited.
GPUs can only copy (i.e. memcpy) to another real buffer (can't be used directly as i.e. texture or vertex buffer) and CPUs can only map it. In other words, a staging buffer is an intermediate buffer to transfer data between CPU & GPU
- See also
- BufferPacked) but it's not the same. A staging buffer can only map/unmap, and it's mapping operations don't accept an "elementStart" argument. Staging buffers always deal with bytes, not elements or bytes per element. RenderSystem implementations also synchronize the mapping differently to avoid excessive memory waste or stalling.
- Internally, the staging buffer will have a maximum size and use it as a ring buffer. i.e. if you have a 32MB staging buffer, you can upload 4 meshes of 8 MBs each. On the 5th one the system will first check if the first mesh has already been copied, otherwise it will stall. Trying to map more bytes than the total size is an error.
- Staging buffers can't be persistently mapped, since it beats the point.