|
MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
|
One host-visible buffer split into equal slots, with the slot chosen where the descriptor is pushed. More...
#include <SlotMachine.hpp>
Public Member Functions | |
| size_t | acquire () |
| A slot nothing holds a lease on, growing the arena if none is free. | |
| const std::shared_ptr< Buffers::VKBuffer > & | buffer () const noexcept |
| The backing buffer, which changes when the arena grows. | |
| std::shared_ptr< Buffers::VKBuffer > | detach () |
| Hand the buffer to the caller, leaving the arena empty. | |
| vk::DescriptorBufferInfo | info (size_t slot) const |
| Buffer, offset and range of a slot, ready for a descriptor write. | |
| bool | initialize (size_t slot_bytes, BufferUsageHint usage, size_t slots=2) |
| Allocate the arena, releasing any previous buffer. | |
| bool | is_initialized () const noexcept |
| SlotLease | lease (size_t slot) const |
| Claim a slot until the returned lease and its copies are gone. | |
| SlotArena & | operator= (const SlotArena &)=delete |
| SlotArena & | operator= (SlotArena &&)=delete |
| void | release () |
| Release the buffer once the work submitted so far completes. | |
| size_t | slot_bytes () const noexcept |
| size_t | slot_count () const noexcept |
| SlotArena ()=default | |
| SlotArena (const SlotArena &)=delete | |
| SlotArena (SlotArena &&)=delete | |
| void | write (size_t slot, const void *data, size_t size) |
| Copy bytes into a slot and flush them. | |
| ~SlotArena ()=default | |
Private Member Functions | |
| bool | grow () |
Private Attributes | |
| std::shared_ptr< Buffers::VKBuffer > | m_buffer |
| size_t | m_slot_bytes {} |
| size_t | m_stride {} |
| BufferUsageHint | m_usage {} |
| std::vector< std::shared_ptr< std::atomic< uint32_t > > > | m_uses |
One host-visible buffer split into equal slots, with the slot chosen where the descriptor is pushed.
For data the host rewrites while the GPU may still be reading an earlier version of it. The owner writes a slot nothing holds a lease on and pushes that slot's range. Whoever records the push takes a lease on the slot and the command buffer keeps it until its submission completes. Nothing waits: acquire() returns a slot with no lease, and grows the arena when every slot is held.
Slots are aligned to 256 bytes, the largest uniform buffer offset alignment Vulkan permits, so a slot's range is valid for uniform and storage bindings on every device.
Definition at line 95 of file SlotMachine.hpp.