|
| | GPUScene (RHIDevice *device, GPUSceneBudgets const &budgets, Allocator *alloc) |
| |
| void | CreateUpdatePasses (Renderer *renderer, ResourceHandle &outInstanceBuffer, ResourceHandle &outSharedBuffer, ResourceHandle &outConstBuffer, RHIDeviceQueueType queue=RHIDeviceQueueType::Graphics) |
| | Creates a pass that performs per-frame updates with correct synchronization.
|
| |
| template<typename T > |
| Span< T > | MapInstanceData () |
| | Maps the instance data for writing. The returned span is valid until UnmapInstanceData is called.
|
| |
| void | UnmapInstanceData () |
| | Unmaps the instance data, allowing other threads to map it again.
|
| |
| VirtualAllocation | PushShared (Span< const char > data, size_t alignment) |
| | Push a block of data into the Shared buffer.
|
| |
| Pair< size_t, size_t > | QueryShared (VirtualAllocation allocation) |
| |
| void | UpdateShared (VirtualAllocation allocation, Span< const char > data) |
| | Updates a previously allocated Shared allocation.
|
| |
| void | FreeShared (VirtualAllocation allocation) |
| | Frees a previously allocated Shared allocation.
|
| |
| VirtualAllocation | PushConst (Span< const char > data, size_t alignment) |
| | Push a block of data into the Const buffer.
|
| |
| Pair< size_t, size_t > | QueryConst (VirtualAllocation id) |
| | Query a previous const allocation.
|
| |
| void | UpdateConst (VirtualAllocation allocation, Span< const char > data) |
| | Updates a previously allocated Const allocation.
|
| |
| void | FreeConst (VirtualAllocation allocation) |
| | Frees a previously allocated const.
|
| |
Scene data management for asynchronous data updates/uploads on the GPU.
This implements a 3-tier buffer structure with:
- Instance Buffer [e.g. for instances, updated most frequently]
- Shared Buffer [e.g. for materials, geometry metadata, updated at different rates]
- Const Buffer [e.g. for geometry data (index,vertex,etc.), updated at different rates]
The names are merely a hint to how you could update the data at rates that the names imply (i.e. Instance > Shared > Const), though there's no limit, or inherently how these are transferred to the GPU. However, it's still recommended to follow such patterns.
The update order is well-defined through CreateUpdatePasses You can expect:
- Const, Shared to be updated before Instance [regardless of Push/Update call order]
- Instance to be updated after they have been updated [same as above]
Separation of buffers is done to reduce the amount of unnecessary barriers on buffers from e.g. to barrier the geometry data buffer even though we'd only touch bytes of instance data - if they're in the same unit.
- Note
- All updates are asynchronous - where incremental updates are deferred until GPU execution time, though may still block if the GPU transfer is unavailable