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>
diff --git a/src/WSI/Win32SurfaceKHR.cpp b/src/WSI/Win32SurfaceKHR.cpp
index d5e90ca..bc82f6e 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 @@
 {
 	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;