| 596 | |
| 597 | template <vkb::BindingType bindingType> |
| 598 | inline bool RenderContext<bindingType>::handle_surface_changes(bool force_update) |
| 599 | { |
| 600 | if (!swapchain) |
| 601 | { |
| 602 | LOGW("Can't handle surface changes. No swapchain, offscreen rendering detected, skipping."); |
| 603 | return false; |
| 604 | } |
| 605 | |
| 606 | vk::SurfaceCapabilitiesKHR surface_properties = device.get_gpu().get_handle().getSurfaceCapabilitiesKHR(swapchain->get_surface()); |
| 607 | vk::Extent2D cur_extent; |
| 608 | |
| 609 | #if defined(VK_USE_PLATFORM_WAYLAND_KHR) |
| 610 | // On Wayland, currentExtent is typically {0xFFFFFFFF, 0xFFFFFFFF}, meaning |
| 611 | // the application determines the surface size. We need to get the size from |
| 612 | // the window instead. |
| 613 | cur_extent = vk::Extent2D{window.get_extent().width, window.get_extent().height}; |
| 614 | #else |
| 615 | cur_extent = surface_properties.currentExtent; |
| 616 | #endif |
| 617 | |
| 618 | if (cur_extent.width == 0xFFFFFFFF || cur_extent.height == 0xFFFFFFFF) |
| 619 | { |
| 620 | return false; |
| 621 | } |
| 622 | |
| 623 | // Only recreate the swapchain if the dimensions have changed; |
| 624 | // handle_surface_changes() is called on VK_SUBOPTIMAL_KHR, |
| 625 | // which might not be due to a surface resize |
| 626 | if (cur_extent.width != surface_extent.width || cur_extent.height != surface_extent.height || force_update) |
| 627 | { |
| 628 | // Recreate swapchain |
| 629 | device.get_handle().waitIdle(); |
| 630 | |
| 631 | update_swapchain_impl(cur_extent, pre_transform); |
| 632 | |
| 633 | surface_extent = cur_extent; |
| 634 | |
| 635 | return true; |
| 636 | } |
| 637 | |
| 638 | return false; |
| 639 | } |
| 640 | |
| 641 | template <vkb::BindingType bindingType> |
| 642 | inline bool RenderContext<bindingType>::has_swapchain() |
nothing calls this directly
no test coverage detected