Grows the destination ring, run and prefix arenas to fit.
Every slot is replaced at once and the outgoing buffers are released once the work submitted so far completes. The 1.5x headroom keeps geometry that is being added to from re-growing on nearly every cycle.
575{
578 if (!svc) {
580 "PrimitiveMill: BufferService unavailable");
581 return false;
582 }
583
585 const auto grown = static_cast<uint32_t>(static_cast<float>(total) * 1.5F);
586
587 auto milled_layout = layout;
588 milled_layout.vertex_count = total;
589
592 for (const auto& buffer : outgoing) {
593 svc->destroy_buffer(buffer);
594 }
595 });
596 }
597
600 slot = std::make_shared<VKBuffer>(
601 static_cast<size_t>(grown) * layout.stride_bytes,
602 VKBuffer::Usage::VERTEX,
604 slot->set_vertex_layout(milled_layout);
605 svc->initialize_buffer(slot);
606 }
607
610 } else {
612 auto milled_layout = *slot->get_vertex_layout();
613 milled_layout.vertex_count = total;
614 slot->set_vertex_layout(milled_layout);
615 }
616 }
617
618 const auto arena_slots =
static_cast<size_t>(
m_output_ring) + 1;
619 const auto fit_arena = [arena_slots](std::unique_ptr<SlotArena>& arena, size_t bytes) {
620 if (arena && arena->slot_bytes() >= bytes) {
621 return;
622 }
623 if (!arena) {
624 arena = std::make_unique<SlotArena>();
625 }
626 arena->initialize(
627 static_cast<size_t>(static_cast<float>(bytes) * 1.5F),
629 };
630
631 fit_arena(
m_run_arena, std::max<size_t>(run_count * RUN_WORDS *
sizeof(uint32_t),
sizeof(uint32_t)));
633
637}
#define MF_RT_ERROR(comp, ctx,...)
std::unique_ptr< SlotArena > m_prefix_arena
std::vector< uint32_t > m_prefix
uint32_t m_output_capacity
std::unique_ptr< SlotArena > m_run_arena
std::vector< std::shared_ptr< Buffers::VKBuffer > > m_outputs
Milled buffers rotated between dispatches, all at m_output_capacity.
void release_after_submit(std::function< void()> release)
Run a release action once every submission made so far has completed.
Interface * get_service()
Query for a backend service.
static BackendRegistry & instance()
Get the global registry instance.
@ Rendering
GPU rendering operations (graphics pipeline, frame rendering).
@ Portal
High-level user-facing API layer.
MAYAFLUX_API ShaderFoundry & get_shader_foundry()
Get the global shader compiler instance.
@ HOST_STORAGE
Host-visible storage buffer (eStorageBuffer + eHostVisible|eHostCoherent).