aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntonio Maiorano <amaiorano@google.com>2021-02-19 09:57:24 -0500
committerswiftshader-scoped@luci-project-accounts.iam.gserviceaccount.com <swiftshader-scoped@luci-project-accounts.iam.gserviceaccount.com>2021-02-19 18:22:04 +0000
commit0540e683d4fc5116d1839ca7b4259146d7b127a0 (patch)
tree89adebc1f8e6f63378318147b2e939a0cd455733
parent35368945f0cb89f80e17129997ce2a17e51c2aa3 (diff)
downloadswiftshader-0540e683d4fc5116d1839ca7b4259146d7b127a0.tar.gz
Fix Win32SurfaceKHR::getSurfaceCapabilities asserting when hwnd is no longer valid
When vkGetPhysicalDeviceSurfaceCapabilitiesKHR is called, we now return VK_ERROR_SURFACE_LOST_KHR on Windows if the window handle (hwnd) is no longer valid. The assert was being tripped by Chromium's compositor_unittests for test LayerWithRealCompositorTest.BackgroundBlur. With this fix, instead of an assert, the test now fails because eglQuerySurface fails with EGL_BAD_SURFACE. Bug: chromium:1174372 Change-Id: I71164c30bddaa41753472389e996cebbff7fbf77 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/52928 Tested-by: Antonio Maiorano <amaiorano@google.com> Commit-Queue: Antonio Maiorano <amaiorano@google.com> Kokoro-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Nicolas Capens <nicolascapens@google.com>
-rw-r--r--src/WSI/Win32SurfaceKHR.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/WSI/Win32SurfaceKHR.cpp b/src/WSI/Win32SurfaceKHR.cpp
index d5e90ca8d..bc82f6ed5 100644
--- a/src/WSI/Win32SurfaceKHR.cpp
+++ b/src/WSI/Win32SurfaceKHR.cpp
@@ -22,6 +22,8 @@
namespace {
VkExtent2D getWindowSize(HWND hwnd)
{
+ ASSERT(IsWindow(hwnd) == TRUE);
+
RECT clientRect = {};
BOOL status = GetClientRect(hwnd, &clientRect);
ASSERT(status != 0);
@@ -60,6 +62,15 @@ VkResult Win32SurfaceKHR::getSurfaceCapabilities(VkSurfaceCapabilitiesKHR *pSurf
{
setCommonSurfaceCapabilities(pSurfaceCapabilities);
+ if(!IsWindow(hwnd))
+ {
+ VkExtent2D extent = { 0, 0 };
+ pSurfaceCapabilities->currentExtent = extent;
+ pSurfaceCapabilities->minImageExtent = extent;
+ pSurfaceCapabilities->maxImageExtent = extent;
+ return VK_ERROR_SURFACE_LOST_KHR;
+ }
+
VkExtent2D extent = getWindowSize(hwnd);
pSurfaceCapabilities->currentExtent = extent;
pSurfaceCapabilities->minImageExtent = extent;