From a8e96342e57d1311f23c626af74f6c2c90db7114 Mon Sep 17 00:00:00 2001 From: Tony-LunarG Date: Fri, 4 Jun 2021 15:12:55 -0600 Subject: vkcube: Resize on SUBOPTIMAL if necessary Change-Id: I6421c661880695ba359969fb5e8752e2140167f5 --- cube/cube.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'cube/cube.cpp') diff --git a/cube/cube.cpp b/cube/cube.cpp index ed572e39..2e423922 100644 --- a/cube/cube.cpp +++ b/cube/cube.cpp @@ -807,8 +807,13 @@ void Demo::draw() { // must be recreated: resize(); } else if (result == vk::Result::eSuboptimalKHR) { - // swapchain is not as optimal as it could be, but the platform's - // presentation engine will still present the image correctly. + // SUBOPTIMAL could be due to resize + vk::SurfaceCapabilitiesKHR surfCapabilities; + auto result = gpu.getSurfaceCapabilitiesKHR(surface, &surfCapabilities); + VERIFY(result == vk::Result::eSuccess); + if (surfCapabilities.currentExtent.width != width || surfCapabilities.currentExtent.height != height) { + resize(); + } } else if (result == vk::Result::eErrorSurfaceLostKHR) { inst.destroySurfaceKHR(surface, nullptr); create_surface(); -- cgit v1.2.3