aboutsummaryrefslogtreecommitdiff
path: root/cube/cube.cpp
diff options
context:
space:
mode:
authorTony-LunarG <tony@lunarg.com>2021-06-04 15:12:55 -0600
committerTony Barbour <tony@lunarg.com>2021-06-07 09:36:02 -0600
commita8e96342e57d1311f23c626af74f6c2c90db7114 (patch)
treea2621c7de6f374066028582dab945a278be2e522 /cube/cube.cpp
parent3ae088978f2107d79ac9a8eaec9ae0600f54f19f (diff)
downloadusermoji-a8e96342e57d1311f23c626af74f6c2c90db7114.tar.xz
vkcube: Resize on SUBOPTIMAL if necessary
Change-Id: I6421c661880695ba359969fb5e8752e2140167f5
Diffstat (limited to 'cube/cube.cpp')
-rw-r--r--cube/cube.cpp9
1 files changed, 7 insertions, 2 deletions
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();