MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ initialize()

bool MayaFlux::Portal::Graphics::SlotArena::initialize ( size_t slot_bytes,
BufferUsageHint usage,
size_t slots = 2 )

Allocate the arena, releasing any previous buffer.

Parameters
slot_bytesBytes each slot holds
usageBuffer usage, which must be host visible
slotsInitial slot count
Returns
True if the buffer is allocated and mapped

Definition at line 35 of file SlotMachine.cpp.

36{
37 release();
38
39 if (!buffer_service() || slot_bytes == 0 || slots == 0) {
41 "SlotArena needs a buffer service, a slot size and at least one slot");
42 return false;
43 }
44
46 m_stride = (slot_bytes + k_slot_alignment - 1) / k_slot_alignment * k_slot_alignment;
47 m_usage = usage;
48
49 m_uses.clear();
50 m_uses.reserve(slots);
51 for (size_t i = 0; i < slots; ++i) {
52 m_uses.push_back(std::make_shared<std::atomic<uint32_t>>(0));
53 }
54
55 m_buffer = make_buffer(m_stride * slots, usage);
56
57 if (!m_buffer || !m_buffer->is_initialized() || !m_buffer->get_mapped_ptr()) {
59 "SlotArena buffer is not host visible");
60 release();
61 return false;
62 }
63
64 return true;
65}
#define MF_ERROR(comp, ctx,...)
void release()
Release the buffer once the work submitted so far completes.
std::vector< std::shared_ptr< std::atomic< uint32_t > > > m_uses
std::shared_ptr< Buffers::VKBuffer > m_buffer
@ BufferManagement
Buffer Management (Buffers::BufferManager, creating buffers).
@ Portal
High-level user-facing API layer.

References MayaFlux::Journal::BufferManagement, m_buffer, m_slot_bytes, m_stride, m_usage, m_uses, MF_ERROR, MayaFlux::Journal::Portal, release(), and slot_bytes().

Here is the call graph for this function: