// must be recreated:
demo_resize(demo);
} else if (err == VK_SUBOPTIMAL_KHR) {
- // demo->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 a resize
+ VkSurfaceCapabilitiesKHR surfCapabilities;
+ err = demo->fpGetPhysicalDeviceSurfaceCapabilitiesKHR(demo->gpu, demo->surface, &surfCapabilities);
+ assert(!err);
+ if (surfCapabilities.currentExtent.width != demo->width || surfCapabilities.currentExtent.height != demo->height) {
+ demo_resize(demo);
+ }
} else if (err == VK_ERROR_SURFACE_LOST_KHR) {
vkDestroySurfaceKHR(demo->inst, demo->surface, NULL);
demo_create_surface(demo);
// 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();