MCPcopy Create free account
hub / github.com/KhronosGroup/Vulkan-Samples / end_frame

Method end_frame

framework/rendering/render_context.h:445–493  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

443
444template <vkb::BindingType bindingType>
445inline void RenderContext<bindingType>::end_frame(SemaphoreType semaphore)
446{
447 assert(frame_active && "Frame is not active, please call begin_frame");
448
449 if (swapchain)
450 {
451 vk::SwapchainKHR vk_swapchain = swapchain->get_handle();
452 vk::PresentInfoKHR present_info{.waitSemaphoreCount = 1, .swapchainCount = 1, .pSwapchains = &vk_swapchain, .pImageIndices = &active_frame_index};
453 if constexpr (bindingType == BindingType::Cpp)
454 {
455 present_info.pWaitSemaphores = &semaphore;
456 }
457 else
458 {
459 present_info.pWaitSemaphores = reinterpret_cast<vk::Semaphore *>(&semaphore);
460 }
461
462 vk::DisplayPresentInfoKHR disp_present_info;
463 if (device.get_gpu().is_extension_supported(VK_KHR_DISPLAY_SWAPCHAIN_EXTENSION_NAME) &&
464 window.get_display_present_info(reinterpret_cast<VkDisplayPresentInfoKHR *>(&disp_present_info), surface_extent.width, surface_extent.height))
465 {
466 // Add display present info if supported and wanted
467 present_info.pNext = &disp_present_info;
468 }
469
470 vk::Result result;
471 try
472 {
473 result = queue.present(present_info);
474 }
475 catch (vk::OutOfDateKHRError & /*err*/)
476 {
477 result = vk::Result::eErrorOutOfDateKHR;
478 }
479
480 if (result == vk::Result::eSuboptimalKHR || result == vk::Result::eErrorOutOfDateKHR)
481 {
482 handle_surface_changes();
483 }
484 }
485
486 // Frame is not active anymore
487 if (acquired_semaphore)
488 {
489 release_owned_semaphore(acquired_semaphore);
490 acquired_semaphore = nullptr;
491 }
492 frame_active = false;
493}
494
495template <vkb::BindingType bindingType>
496inline vkb::rendering::RenderFrame<bindingType> &RenderContext<bindingType>::get_active_frame()

Callers 1

updateMethod · 0.80

Calls 4

get_handleMethod · 0.45
presentMethod · 0.45

Tested by

no test coverage detected