649{
651 if (!ctx) {
653 "Window not registered for submit_and_present");
654 return;
655 }
656
658
659 size_t frame_index = ctx->current_frame;
660 auto& in_flight = ctx->in_flight[frame_index];
661 auto& image_available = ctx->image_available[frame_index];
662 auto& render_finished = ctx->render_finished[frame_index];
663
664 vk::SubmitInfo submit_info {};
665 vk::PipelineStageFlags wait_stages[] = { vk::PipelineStageFlagBits::eColorAttachmentOutput };
666 submit_info.waitSemaphoreCount = 1;
667 submit_info.pWaitSemaphores = &image_available;
668 submit_info.pWaitDstStageMask = wait_stages;
669 submit_info.commandBufferCount = 1;
670 submit_info.pCommandBuffers = &command_buffer;
671 submit_info.signalSemaphoreCount = 1;
672 submit_info.pSignalSemaphores = &render_finished;
673
674 try {
675 auto result = graphics_queue.submit(1, &submit_info, in_flight);
676 } catch (const vk::SystemError& e) {
678 "Failed to submit primary command buffer: {}", e.what());
679 return;
680 }
681
682 bool present_success = ctx->swapchain->present(
683 ctx->current_image_index, render_finished, graphics_queue);
684
685 if (!present_success) {
686 ctx->needs_recreation = true;
687 }
688
689 ctx->current_frame = (frame_index + 1) % ctx->in_flight.size();
690
692 "Window '{}': frame submitted and presented",
693 window->get_create_info().title);
694}
#define MF_RT_ERROR(comp, ctx,...)
#define MF_RT_TRACE(comp, ctx,...)
WindowRenderContext * find_window_context(const std::shared_ptr< Window > &window)
vk::Queue get_graphics_queue() const
Get graphics queue.
@ GraphicsCallback
Graphics/visual rendering callback - frame-rate real-time.
@ Core
Core engine, backend, subsystems.