diff options
| author | Tony-LunarG <tony@lunarg.com> | 2019-09-11 14:32:23 -0600 |
|---|---|---|
| committer | Tony Barbour <tony@lunarg.com> | 2019-09-13 09:31:35 -0600 |
| commit | 6cebf14cc64c91f6278ad8d1e331bb9e4a6831f6 (patch) | |
| tree | ab2676420761b244e9215133660b4d5074db403e /cube/cube.cpp | |
| parent | c60f79013bd8abf65c9b680dfb3958fa27c8c1f6 (diff) | |
| download | usermoji-6cebf14cc64c91f6278ad8d1e331bb9e4a6831f6.tar.xz | |
cube: Handle SURFACE_LOST return code
Change-Id: I6989c7da3e36ec8531ff390ca9ee2f9710776f11
Diffstat (limited to 'cube/cube.cpp')
| -rw-r--r-- | cube/cube.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/cube/cube.cpp b/cube/cube.cpp index a6f600c0..48c1f728 100644 --- a/cube/cube.cpp +++ b/cube/cube.cpp @@ -242,6 +242,7 @@ struct Demo { void prepare_textures(); void resize(); + void create_surface(); void set_image_layout(vk::Image, vk::ImageAspectFlags, vk::ImageLayout, vk::ImageLayout, vk::AccessFlags, vk::PipelineStageFlags, vk::PipelineStageFlags); void update_data_buffer(); @@ -731,6 +732,10 @@ void Demo::draw() { // swapchain is not as optimal as it could be, but the platform's // presentation engine will still present the image correctly. break; + } else if (result == vk::Result::eErrorSurfaceLostKHR) { + inst.destroySurfaceKHR(surface, nullptr); + create_surface(); + resize(); } else { VERIFY(result == vk::Result::eSuccess); } @@ -793,6 +798,10 @@ void Demo::draw() { } 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. + } else if (result == vk::Result::eErrorSurfaceLostKHR) { + inst.destroySurfaceKHR(surface, nullptr); + create_surface(); + resize(); } else { VERIFY(result == vk::Result::eSuccess); } @@ -899,7 +908,7 @@ void Demo::init(int argc, char **argv) { presentMode = vk::PresentModeKHR::eFifo; frameCount = UINT32_MAX; use_xlib = false; - + #if defined(VK_USE_PLATFORM_MACOS_MVK) // MoltenVK may not allow host coherent mapping to linear tiled images // Force the use of a staging buffer to be safe @@ -1267,7 +1276,7 @@ void Demo::init_vk() { gpu.getFeatures(&physDevFeatures); } -void Demo::init_vk_swapchain() { +void Demo::create_surface() { // Create a WSI surface for the window: #if defined(VK_USE_PLATFORM_WIN32_KHR) { @@ -1317,6 +1326,10 @@ void Demo::init_vk_swapchain() { VERIFY(result == vk::Result::eSuccess); } #endif +} + +void Demo::init_vk_swapchain() { + create_surface(); // Iterate over each queue to learn whether it supports presenting: std::unique_ptr<vk::Bool32[]> supportsPresent(new vk::Bool32[queue_family_count]); for (uint32_t i = 0; i < queue_family_count; i++) { |
