| 443 | |
| 444 | template <vkb::BindingType bindingType> |
| 445 | inline 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 | |
| 495 | template <vkb::BindingType bindingType> |
| 496 | inline vkb::rendering::RenderFrame<bindingType> &RenderContext<bindingType>::get_active_frame() |
no test coverage detected