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

◆ submit_and_present()

void MayaFlux::Core::BackendWindowHandler::submit_and_present ( const std::shared_ptr< Window > &  window,
const vk::CommandBuffer &  command_buffer 
)

Definition at line 1138 of file BackendWindowHandler.cpp.

1141{
1142 auto* ctx = find_window_context(window);
1143 if (!ctx) {
1145 "Window not registered for submit_and_present");
1146 return;
1147 }
1148
1149 auto graphics_queue = m_context.get_graphics_queue();
1150
1151 size_t frame_index = ctx->current_frame;
1152 auto& in_flight = ctx->in_flight[frame_index];
1153 auto& image_available = ctx->image_available[frame_index];
1154 auto& render_finished = ctx->render_finished[frame_index];
1155
1156 vk::Semaphore deferred_sem = m_resource_manager
1158 : nullptr;
1159
1160 std::vector<vk::Semaphore> wait_sems { image_available };
1161 std::vector<vk::PipelineStageFlags> wait_stages {
1162 vk::PipelineStageFlagBits::eColorAttachmentOutput
1163 };
1164
1165 if (deferred_sem) {
1166 wait_sems.push_back(deferred_sem);
1167 wait_stages.emplace_back(vk::PipelineStageFlagBits::eFragmentShader);
1168 }
1169
1170 vk::SubmitInfo submit_info {};
1171 submit_info.waitSemaphoreCount = static_cast<uint32_t>(wait_sems.size());
1172 submit_info.pWaitSemaphores = wait_sems.data();
1173 submit_info.pWaitDstStageMask = wait_stages.data();
1174 submit_info.commandBufferCount = 1;
1175 submit_info.pCommandBuffers = &command_buffer;
1176 submit_info.signalSemaphoreCount = 1;
1177 submit_info.pSignalSemaphores = &render_finished;
1178
1179 try {
1180 auto result = graphics_queue.submit(1, &submit_info, in_flight);
1181 } catch (const vk::SystemError& e) {
1183 "Failed to submit primary command buffer: {}", e.what());
1184 return;
1185 }
1186
1187 bool present_success = ctx->swapchain->present(
1188 ctx->current_image_index, render_finished, graphics_queue);
1189
1190 if (!present_success) {
1191 ctx->needs_recreation = true;
1192 }
1193
1194 if (present_success)
1195 capture_frame(*ctx);
1196
1197 ctx->current_frame = (frame_index + 1) % ctx->in_flight.size();
1198
1200 "Window '{}': frame submitted and presented",
1201 window->get_create_info().title);
1202}
#define MF_RT_ERROR(comp, ctx,...)
#define MF_RT_TRACE(comp, ctx,...)
vk::Semaphore flush_deferred_commands()
Flush deferred commands and return a semaphore that signals when they are complete.
void capture_frame(WindowRenderContext &ctx)
Capture the current frame from a window's swapchain.
WindowRenderContext * find_window_context(const std::shared_ptr< Window > &window)
vk::Queue get_graphics_queue() const
Get graphics queue.
Definition VKContext.hpp:54
@ GraphicsCallback
Graphics/visual rendering callback - frame-rate real-time.
@ Core
Core engine, backend, subsystems.

References MayaFlux::Journal::Core, MayaFlux::Journal::GraphicsCallback, MF_RT_ERROR, and MF_RT_TRACE.

Referenced by setup_backend_service().

+ Here is the caller graph for this function: