|
nngn
|
Manages staging buffers for a group of frames. More...
#include <staging.h>

Classes | |
| struct | Allocation |
| Result of a block allocation. More... | |
| struct | Frame |
| Data for a single frame. More... | |
| struct | FreeBuffer |
| Buffer in the free list, ready to be reused. More... | |
| struct | MappedRegion |
| Region mapped for writting. More... | |
Public Types | |
| using | Stats = GraphicsStats::Staging |
Public Member Functions | |
| StagingBuffer (void)=default | |
| ~StagingBuffer (void) | |
| Releases all buffers and device memory allocated. | |
| void | init (const Instance &inst, VkDevice dev, DeviceMemory *dev_mem, VkDeviceSize default_size) |
| Stats | stats (std::size_t i) const |
| void | resize (std::size_t n) |
Resizes to accommodate n frames. | |
| bool | write (std::size_t i, VkDeviceSize n, VkDeviceSize size, auto &&f) |
| Writes data for a frame, allocating extra memory as necessary. | |
| void | destroy (std::size_t i) |
Releases resources for frame i. | |
Private Member Functions | |
| const DedicatedBuffer * | cur_block (std::size_t i) const |
| DedicatedBuffer * | cur_block (std::size_t i) |
| Allocation | alloc (std::size_t i, VkDeviceSize n, VkDeviceSize size) |
Allocates at most n blocks of size bytes for frame i. | |
| MappedRegion | map (std::size_t i, VkDeviceSize n, VkDeviceSize size) |
| Maps a writeable region, allocating if necessary. | |
| void | retire_free () |
| Removes old unused buffers from the free list. | |
Private Attributes | |
| std::vector< Frame > | frames = {} |
| std::vector< FreeBuffer > | free = {} |
| const Instance * | inst = {} |
| VkDevice | dev = {} |
| DeviceMemory * | dev_mem = {} |
| VkDeviceSize | default_size = {} |
Manages staging buffers for a group of frames.
Allocates buffers and device memory in blocks as necessary for each new data block that is written.
|
default |
| nngn::StagingBuffer::~StagingBuffer | ( | void | ) |
Releases all buffers and device memory allocated.
|
private |
Allocates at most n blocks of size bytes for frame i.
Depending on the capacity cap of the current active block:
cap >= n * size, no allocation is performedsize <= cap && cap < n * size, no allocation is performedcap < size, a new block of size n * size is allocated In all cases, the returned allocation information has n equal to the number of blocks that should be written to the buffer, which may be less than the n parameter for case 2. 

|
inlineprivate |

|
inlineprivate |


| void nngn::StagingBuffer::destroy | ( | std::size_t | i | ) |
Releases resources for frame i.


|
inline |

|
private |
Maps a writeable region, allocating if necessary.
| i | frame index |
| n | number of elements |
| size | size of each element |

|
inline |
Resizes to accommodate n frames.


|
private |
Removes old unused buffers from the free list.
A buffer is removed if it has not been used for a full cycle of the total number of frames (i.e. size(this->frames)) since it was allocated. Regardless of age, a minimum of size(this->frames) is kept in the list.


| auto nngn::StagingBuffer::stats | ( | std::size_t | i | ) | const |


|
inline |
Writes data for a frame, allocating extra memory as necessary.
| i | frame index |
| n | number of elements |
| size | size of each element |
| f | Callable that generates the data. Parameters:
|


|
private |
|
private |
|
private |
|
private |
|
private |