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

◆ recreate_swapchain_internal()

bool MayaFlux::Core::BackendWindowHandler::recreate_swapchain_internal ( WindowRenderContext context)
private

Internal logic to recreate swapchain and related resources.

Parameters
contextWindow render context
Returns
True if recreation succeeded

Definition at line 318 of file BackendWindowHandler.cpp.

319{
320 const auto& state = context.window->get_state();
321
322 for (auto& framebuffer : context.framebuffers) {
323 if (framebuffer) {
324 framebuffer->cleanup(m_context.get_device());
325 }
326 }
327 context.framebuffers.clear();
328
329 if (context.render_pass && !context.user_render_pass_attached) {
330 context.render_pass->cleanup(m_context.get_device());
331 context.render_pass.reset();
332 }
333
334 if (!context.swapchain->recreate(state.current_width, state.current_height)) {
336 "Failed to recreate swapchain for window '{}'",
337 context.window->get_create_info().title);
338 return false;
339 }
340
341 if (!context.user_render_pass_attached) {
342 context.render_pass = std::make_unique<VKRenderPass>();
343 if (!context.render_pass->create(
345 context.swapchain->get_image_format())) {
347 "Failed to recreate render pass for window '{}'",
348 context.window->get_create_info().title);
349 return false;
350 }
351 }
352
353 uint32_t image_count = context.swapchain->get_image_count();
354 context.framebuffers.resize(image_count);
355 auto extent = context.swapchain->get_extent();
356 const auto& image_views = context.swapchain->get_image_views();
357
358 for (uint32_t i = 0; i < image_count; ++i) {
359 context.framebuffers[i] = std::make_unique<VKFramebuffer>();
360 std::vector<vk::ImageView> attachments = { image_views[i] };
361
362 if (!context.framebuffers[i]->create(
364 context.render_pass->get(),
365 attachments,
366 extent.width,
367 extent.height)) {
369 "Failed to recreate framebuffer {} for window '{}'",
370 i, context.window->get_create_info().title);
371 return false;
372 }
373 }
374
375 return true;
376}
#define MF_RT_ERROR(comp, ctx,...)
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::Core::WindowRenderContext::framebuffers, MayaFlux::Journal::GraphicsCallback, MF_RT_ERROR, MayaFlux::Core::WindowRenderContext::render_pass, MayaFlux::Core::WindowRenderContext::swapchain, MayaFlux::Core::WindowRenderContext::user_render_pass_attached, and MayaFlux::Core::WindowRenderContext::window.