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/+/52928Tested-by: 's avatarAntonio Maiorano <amaiorano@google.com> Commit-Queue: Antonio Maiorano <amaiorano@google.com> Kokoro-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent 35368945
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment