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

◆ attach_render_pass()

bool MayaFlux::Core::BackendWindowHandler::attach_render_pass ( const std::shared_ptr< Window > &  window,
const std::shared_ptr< Core::VKRenderPass > &  render_pass 
)

Attach a user render pass and recreate sync objects with it Used by Portal when registering a window for rendering.

Definition at line 562 of file BackendWindowHandler.cpp.

565{
566 auto* context = find_window_context(window);
567 if (!context) {
569 "Window not registered");
570 return false;
571 }
572
573 if (!render_pass) {
575 "Cannot attach null render pass");
576 return false;
577 }
578
580
581 for (auto& fb : context->framebuffers) {
582 if (fb)
583 fb->cleanup(m_context.get_device());
584 }
585 context->framebuffers.clear();
586
587 if (context->render_pass) {
588 context->render_pass->cleanup(m_context.get_device());
589 }
590 context->render_pass = render_pass;
591 context->user_render_pass_attached = true;
592
593 uint32_t image_count = context->swapchain->get_image_count();
594 context->framebuffers.resize(image_count);
595 auto extent = context->swapchain->get_extent();
596 const auto& image_views = context->swapchain->get_image_views();
597
598 for (uint32_t i = 0; i < image_count; ++i) {
599 context->framebuffers[i] = std::make_unique<VKFramebuffer>();
600 std::vector<vk::ImageView> attachments = { image_views[i] };
601
602 if (!context->framebuffers[i]->create(
604 render_pass->get(),
605 attachments,
606 extent.width,
607 extent.height)) {
609 "Failed to create framebuffer {} with user render pass", i);
610 return false;
611 }
612 }
613
615 "Attached user render pass to window '{}' - recreated {} framebuffers",
616 window->get_create_info().title, image_count);
617
618 return true;
619}
#define MF_INFO(comp, ctx,...)
#define MF_ERROR(comp, ctx,...)
WindowRenderContext * find_window_context(const std::shared_ptr< Window > &window)
void wait_idle() const
Wait for device idle.
Definition VKContext.hpp:97
vk::Device get_device() const
Get logical device.
Definition VKContext.hpp:49
@ GraphicsCallback
Graphics/visual rendering callback - frame-rate real-time.
@ Core
Core engine, backend, subsystems.

References MayaFlux::Journal::Core, MayaFlux::Journal::GraphicsCallback, MF_ERROR, and MF_INFO.

Referenced by setup_backend_service().

+ Here is the caller graph for this function: