MayaFlux 1.0.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 1159 of file BackendWindowHandler.cpp.

1162{
1163 auto* ctx = find_window_context(window);
1164 if (!ctx) {
1166 "Window not registered for submit_and_present");
1167 return;
1168 }
1169
1170 auto graphics_queue = m_context.get_graphics_queue();
1171
1172 size_t frame_index = ctx->current_frame;
1173 auto& in_flight = ctx->in_flight[frame_index];
1174 auto& image_available = ctx->image_available[frame_index];
1175 auto& render_finished = ctx->render_finished[frame_index];
1176
1177 vk::Semaphore deferred_sem = m_resource_manager
1179 : nullptr;
1180
1181 std::vector<vk::Semaphore> wait_sems { image_available };
1182 std::vector<vk::PipelineStageFlags> wait_stages {
1183 vk::PipelineStageFlagBits::eColorAttachmentOutput
1184 };
1185
1186 if (deferred_sem) {
1187 wait_sems.push_back(deferred_sem);
1188 wait_stages.emplace_back(vk::PipelineStageFlagBits::eFragmentShader);
1189 }
1190
1191 vk::SubmitInfo submit_info {};
1192 submit_info.waitSemaphoreCount = static_cast<uint32_t>(wait_sems.size());
1193 submit_info.pWaitSemaphores = wait_sems.data();
1194 submit_info.pWaitDstStageMask = wait_stages.data();
1195 submit_info.commandBufferCount = 1;
1196 submit_info.pCommandBuffers = &command_buffer;
1197 submit_info.signalSemaphoreCount = 1;
1198 submit_info.pSignalSemaphores = &render_finished;
1199
1200 try {
1201 auto result = graphics_queue.submit(1, &submit_info, in_flight);
1202 ctx->slot_submission[frame_index] = ++ctx->submitted_frames;
1203 } catch (const vk::SystemError& e) {
1205 "Failed to submit primary command buffer: {}", e.what());
1206 return;
1207 }
1208
1209 bool present_success = ctx->swapchain->present(
1210 ctx->current_image_index, render_finished, graphics_queue);
1211
1212 if (!present_success) {
1213 ctx->needs_recreation = true;
1214 }
1215
1216 if (present_success)
1217 capture_frame(*ctx);
1218
1219 ctx->current_frame = (frame_index + 1) % ctx->in_flight.size();
1220
1222 "Window '{}': frame submitted and presented",
1223 window->get_create_info().title);
1224}
#define MF_RT_ERROR(comp, ctx,...)
#define MF_RT_TRACE(comp, ctx,...)
std::weak_ptr< Core::Window > window
Definition Picker.cpp:23
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, MF_RT_TRACE, and window.

Referenced by setup_backend_service().

+ Here is the caller graph for this function: