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

◆ ensure_buffers()

bool MayaFlux::Portal::Graphics::PrimitiveMill::ensure_buffers ( const std::shared_ptr< Buffers::VKBuffer > &  source,
const Kakshya::VertexLayout layout,
uint32_t  total,
size_t  run_count 
)
private

Grows the destination ring, run and prefix buffers to fit.

Every slot is replaced at once, so one capacity covers them all. Doing so frees buffers a recorded draw may still name, hence the graphics queue drain first, and hence the 1.5x headroom: geometry a caller is actively adding to would otherwise re-grow, and stall, on nearly every cycle.

Definition at line 527 of file PrimitiveMill.cpp.

532{
534 .get_service<Registry::Service::BufferService>();
535 if (!svc) {
537 "PrimitiveMill: BufferService unavailable");
538 return false;
539 }
540
541 if (total > m_output_capacity || m_outputs.size() != m_output_ring) {
542 const auto grown = static_cast<uint32_t>(static_cast<float>(total) * 1.5F);
543
544 auto milled_layout = layout;
545 milled_layout.vertex_count = total;
546
547 if (!m_outputs.empty()) {
549 }
550
551 m_outputs.assign(m_output_ring, nullptr);
552 for (auto& slot : m_outputs) {
553 slot = std::make_shared<VKBuffer>(
554 static_cast<size_t>(grown) * layout.stride_bytes,
555 VKBuffer::Usage::VERTEX,
556 source->get_modality());
557 slot->set_vertex_layout(milled_layout);
558 svc->initialize_buffer(slot);
559 }
560
561 m_output_capacity = grown;
562 m_output_slot = 0;
563 m_descriptors_written = false;
564 m_bound_source.reset();
565 } else {
566 for (auto& slot : m_outputs) {
567 auto milled_layout = *slot->get_vertex_layout();
568 milled_layout.vertex_count = total;
569 slot->set_vertex_layout(milled_layout);
570 }
571 }
572
573 const auto run_bytes = std::max<size_t>(run_count * RUN_WORDS * sizeof(uint32_t), sizeof(uint32_t));
574 if (!m_run_buf || m_run_buf->get_size_bytes() < run_bytes) {
575 m_run_buf = std::make_shared<VKBuffer>(
576 run_bytes, VKBuffer::Usage::HOST_STORAGE, Kakshya::DataModality::UNKNOWN);
577 svc->initialize_buffer(m_run_buf);
578 m_bound_source.reset();
579 }
580
581 const auto prefix_bytes = std::max<size_t>(m_prefix.size() * sizeof(uint32_t), sizeof(uint32_t));
582 if (!m_prefix_buf || m_prefix_buf->get_size_bytes() < prefix_bytes) {
583 m_prefix_buf = std::make_shared<VKBuffer>(
584 prefix_bytes, VKBuffer::Usage::HOST_STORAGE, Kakshya::DataModality::UNKNOWN);
585 svc->initialize_buffer(m_prefix_buf);
586 m_bound_source.reset();
587 }
588
589 return !m_outputs.empty() && m_run_buf && m_prefix_buf;
590}
#define MF_RT_ERROR(comp, ctx,...)
uint32_t total
uint32_t run_count
std::weak_ptr< Buffers::VKBuffer > m_bound_source
Source the descriptor set currently points at, for invalidation.
std::shared_ptr< Buffers::VKBuffer > m_prefix_buf
std::shared_ptr< Buffers::VKBuffer > m_run_buf
std::vector< std::shared_ptr< Buffers::VKBuffer > > m_outputs
Milled buffers rotated between dispatches, all at m_output_capacity.
vk::Queue get_graphics_queue() const
Get Vulkan graphics queue.
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.
@ UNKNOWN
Unknown or undefined modality.
Source source()
Begin a Source chain.
Definition Plot.hpp:128
MAYAFLUX_API ShaderFoundry & get_shader_foundry()
Get the global shader compiler instance.

References MayaFlux::Portal::Graphics::ShaderFoundry::get_graphics_queue(), MayaFlux::Registry::BackendRegistry::get_service(), MayaFlux::Portal::Graphics::get_shader_foundry(), MayaFlux::Registry::BackendRegistry::instance(), m_bound_source, m_descriptors_written, m_output_capacity, m_output_ring, m_output_slot, m_outputs, m_prefix, m_prefix_buf, m_run_buf, MF_RT_ERROR, MayaFlux::Journal::Portal, MayaFlux::Journal::Rendering, run_count, MayaFlux::Kakshya::VertexLayout::stride_bytes, total, MayaFlux::Kakshya::UNKNOWN, and MayaFlux::Kakshya::VertexLayout::vertex_count.

Referenced by mill().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: