@@ -581,6 +581,8 @@ angle::Result WindowSurfaceVk::createSwapChain(vk::Context *context,
581581 const gl::Extents &extents,
582582 VkSwapchainKHR oldSwapchain)
583583{
584+ ANGLE_TRACE_EVENT0 (" gpu.angle" , " WindowSurfaceVk::createSwapchain" );
585+
584586 ASSERT (mSwapchain == VK_NULL_HANDLE);
585587
586588 RendererVk *renderer = context->getRenderer ();
@@ -705,40 +707,45 @@ bool WindowSurfaceVk::isMultiSampled() const
705707
706708angle::Result WindowSurfaceVk::checkForOutOfDateSwapchain (ContextVk *contextVk,
707709 uint32_t swapHistoryIndex,
708- bool swapchainOutOfDate )
710+ bool presentOutOfDate )
709711{
710712 bool swapIntervalChanged = mSwapchainPresentMode != mDesiredSwapchainPresentMode ;
711713
712- // Check for window resize and recreate swapchain if necessary.
713- gl::Extents currentExtents;
714- ANGLE_TRY (getCurrentWindowSize (contextVk, ¤tExtents));
715-
716- gl::Extents swapchainExtents (getWidth (), getHeight (), 0 );
717-
718- // If window size has changed, check with surface capabilities. It has been observed on
719- // Android that `getCurrentWindowSize()` returns 1920x1080 for example, while surface
720- // capabilities returns the size the surface was created with.
721- if (currentExtents != swapchainExtents)
714+ // If anything has changed, recreate the swapchain.
715+ if (swapIntervalChanged || presentOutOfDate ||
716+ contextVk->getRenderer ()->getFeatures ().perFrameWindowSizeQuery .enabled )
722717 {
723- const VkPhysicalDevice &physicalDevice = contextVk->getRenderer ()->getPhysicalDevice ();
724- ANGLE_VK_TRY (contextVk, vkGetPhysicalDeviceSurfaceCapabilitiesKHR (physicalDevice, mSurface ,
725- &mSurfaceCaps ));
718+ gl::Extents swapchainExtents (getWidth (), getHeight (), 0 );
726719
727- uint32_t width = mSurfaceCaps . currentExtent . width ;
728- uint32_t height = mSurfaceCaps . currentExtent . height ;
720+ gl::Extents currentExtents ;
721+ ANGLE_TRY ( getCurrentWindowSize (contextVk, ¤tExtents)) ;
729722
730- if (width != 0xFFFFFFFFu )
723+ // If window size has changed, check with surface capabilities. It has been observed on
724+ // Android that `getCurrentWindowSize()` returns 1920x1080 for example, while surface
725+ // capabilities returns the size the surface was created with.
726+ if (currentExtents != swapchainExtents)
731727 {
732- ASSERT (height != 0xFFFFFFFFu );
733- currentExtents.width = width;
734- currentExtents.height = height;
728+ const VkPhysicalDevice &physicalDevice = contextVk->getRenderer ()->getPhysicalDevice ();
729+ ANGLE_VK_TRY (contextVk, vkGetPhysicalDeviceSurfaceCapabilitiesKHR (
730+ physicalDevice, mSurface , &mSurfaceCaps ));
731+
732+ uint32_t width = mSurfaceCaps .currentExtent .width ;
733+ uint32_t height = mSurfaceCaps .currentExtent .height ;
734+
735+ if (width != 0xFFFFFFFFu )
736+ {
737+ ASSERT (height != 0xFFFFFFFFu );
738+ currentExtents.width = width;
739+ currentExtents.height = height;
740+ }
735741 }
736- }
737742
738- // If anything has changed, recreate the swapchain.
739- if (swapchainOutOfDate || swapIntervalChanged || currentExtents != swapchainExtents)
740- {
741- ANGLE_TRY (recreateSwapchain (contextVk, currentExtents, swapHistoryIndex));
743+ // Check for window resize and recreate swapchain if necessary.
744+ // Work-around for some device which does not return OUT_OF_DATE after window resizing
745+ if (swapIntervalChanged || presentOutOfDate || currentExtents != swapchainExtents)
746+ {
747+ ANGLE_TRY (recreateSwapchain (contextVk, currentExtents, swapHistoryIndex));
748+ }
742749 }
743750
744751 return angle::Result::Continue;
@@ -864,7 +871,7 @@ egl::Error WindowSurfaceVk::swap(const gl::Context *context)
864871angle::Result WindowSurfaceVk::present (ContextVk *contextVk,
865872 EGLint *rects,
866873 EGLint n_rects,
867- bool &swapchainOutOfDate )
874+ bool *presentOutOfDate )
868875{
869876 ANGLE_TRACE_EVENT0 (" gpu.angle" , " WindowSurfaceVk::present" );
870877
@@ -973,8 +980,8 @@ angle::Result WindowSurfaceVk::present(ContextVk *contextVk,
973980 // recreate the swapchain with a new window orientation. We aren't quite ready for that so just
974981 // ignore for now.
975982 // TODO: Check for preRotation: http://anglebug.com/3502
976- swapchainOutOfDate = result == VK_ERROR_OUT_OF_DATE_KHR;
977- if (!swapchainOutOfDate && result != VK_SUBOPTIMAL_KHR)
983+ *presentOutOfDate = result == VK_ERROR_OUT_OF_DATE_KHR;
984+ if (!*presentOutOfDate && result != VK_SUBOPTIMAL_KHR)
978985 {
979986 ANGLE_VK_TRY (contextVk, result);
980987 }
@@ -989,13 +996,13 @@ angle::Result WindowSurfaceVk::swapImpl(const gl::Context *context, EGLint *rect
989996 ContextVk *contextVk = vk::GetImpl (context);
990997 DisplayVk *displayVk = vk::GetImpl (context->getDisplay ());
991998
992- bool swapchainOutOfDate = false ;
999+ bool presentOutOfDate = false ;
9931000 // Save this now, since present() will increment the value.
9941001 size_t currentSwapHistoryIndex = mCurrentSwapHistoryIndex ;
9951002
996- ANGLE_TRY (present (contextVk, rects, n_rects, swapchainOutOfDate ));
1003+ ANGLE_TRY (present (contextVk, rects, n_rects, &presentOutOfDate ));
9971004
998- ANGLE_TRY (checkForOutOfDateSwapchain (contextVk, currentSwapHistoryIndex, swapchainOutOfDate ));
1005+ ANGLE_TRY (checkForOutOfDateSwapchain (contextVk, currentSwapHistoryIndex, presentOutOfDate ));
9991006
10001007 {
10011008 // Note: TRACE_EVENT0 is put here instead of inside the function to workaround this issue:
0 commit comments