|
Foundation
|
Helper class for GPU buffer updates. More...
#include <StagingBuffer.hpp>
Public Types | |
| enum class | State { Idle , Transfer } |
Public Member Functions | |
| StagedBuffer (RHIDevice *device, Allocator *allocator, RHIBufferDesc const &desc={}, size_t stagingBudget=kFullSize, Optional< uint32_t > clearValue={}) | |
| Create the staging arena buffers. | |
| RHIBuffer * | GetBuffer () |
| Gets the GPU-only backing buffer. | |
| void | BeginTransfer () |
| Resets the staging buffer and aborts all pending data updates. | |
| StagingBuffer * | GetStagingBuffer () |
| Gets the current staging buffer for data uploads. | |
| void | Transfer (size_t dst_offset, Span< const char > data, size_t alignment=4) |
| Schedules a data upload to the given buffer at the given offset. | |
| void | EndTransfer () |
| Ends the transfer state, and pushes optimized copy commands to the given command list. | |
| bool | HasUpdates () |
| Check if there are any pending updates to be performed. | |
| void | Update (RHICommandList *cmd) |
| Push the scheduled uploads onto the command list. | |
Public Member Functions inherited from Foundation::RHI::RHIObject | |
| RHIObject ()=default | |
| RHIObject (RHIObject const &)=delete | |
| RHIObject & | operator= (const RHIObject &)=delete |
| RHIObject (RHIObject &&)=delete | |
| RHIObject & | operator= (RHIObject &&)=delete |
| virtual | ~RHIObject ()=default |
Helper class for GPU buffer updates.
This creates a GPU-only local buffer, and a staging buffer of arbitrary size
| Foundation::Rendering::StagedBuffer::StagedBuffer | ( | RHIDevice * | device, |
| Allocator * | allocator, | ||
| RHIBufferDesc const & | desc = {}, |
||
| size_t | stagingBudget = kFullSize, |
||
| Optional< uint32_t > | clearValue = {} |
||
| ) |
Create the staging arena buffers.
| desc | Description of the data buffer to be created. |
| stagingBudget | Size of the staging buffer. Defaults to kFullSize, which is the same size of the buffer created. |
| clearValue | Value to clear the buffer with at first update. Defaults to {}, which leaves the buffer uninitialized. |
| void Foundation::Rendering::StagedBuffer::BeginTransfer | ( | ) |
Resets the staging buffer and aborts all pending data updates.
| void Foundation::Rendering::StagedBuffer::EndTransfer | ( | ) |
Ends the transfer state, and pushes optimized copy commands to the given command list.
|
inline |
Gets the GPU-only backing buffer.
| StagingBuffer * Foundation::Rendering::StagedBuffer::GetStagingBuffer | ( | ) |
Gets the current staging buffer for data uploads.
This MUST be called between BeginTransfer and EndTransfer.
|
inline |
Check if there are any pending updates to be performed.
| void Foundation::Rendering::StagedBuffer::Transfer | ( | size_t | dst_offset, |
| Span< const char > | data, | ||
| size_t | alignment = 4 |
||
| ) |
Schedules a data upload to the given buffer at the given offset.
This MUST be called between BeginTransfer and EndTransfer.
| void Foundation::Rendering::StagedBuffer::Update | ( | RHICommandList * | cmd | ) |
Push the scheduled uploads onto the command list.
This MUST be called after EndTransfer, and before the command list is submitted.
Once executed, the previously scheduled uploads are considered done, and will be flushed.
|
private |
|
private |
|
private |
|
private |
|
private |