diff options
Diffstat (limited to 'runtime/src/vulkan_present.h')
| -rw-r--r-- | runtime/src/vulkan_present.h | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/runtime/src/vulkan_present.h b/runtime/src/vulkan_present.h index a2874b4b3..53cc34df3 100644 --- a/runtime/src/vulkan_present.h +++ b/runtime/src/vulkan_present.h | |||
| @@ -160,8 +160,10 @@ public: | |||
| 160 | { | 160 | { |
| 161 | std::lock_guard lock(context_.submit_mutex()); | 161 | std::lock_guard lock(context_.submit_mutex()); |
| 162 | vk.vkQueueWaitIdle(queue_); | 162 | vk.vkQueueWaitIdle(queue_); |
| 163 | // A WSI layer may perform a device-wide idle while destroying the swapchain. | ||
| 164 | // Keep that implicit idle serialized with submits from every context queue. | ||
| 165 | release(swapchain_); | ||
| 163 | } | 166 | } |
| 164 | release(swapchain_); | ||
| 165 | swapchain_ = VK_NULL_HANDLE; | 167 | swapchain_ = VK_NULL_HANDLE; |
| 166 | release_capture(); | 168 | release_capture(); |
| 167 | composer_.reset(); | 169 | composer_.reset(); |
| @@ -863,7 +865,10 @@ private: | |||
| 863 | } | 865 | } |
| 864 | } | 866 | } |
| 865 | if (extent.width == 0 || extent.height == 0) { | 867 | if (extent.width == 0 || extent.height == 0) { |
| 866 | release(swapchain_); | 868 | { |
| 869 | std::lock_guard lock(context_.submit_mutex()); | ||
| 870 | release(swapchain_); | ||
| 871 | } | ||
| 867 | swapchain_ = VK_NULL_HANDLE; | 872 | swapchain_ = VK_NULL_HANDLE; |
| 868 | vsync_ = vsync; | 873 | vsync_ = vsync; |
| 869 | swapchain_srgb_ = srgb; | 874 | swapchain_srgb_ = srgb; |
| @@ -975,13 +980,18 @@ private: | |||
| 975 | info.oldSwapchain = old; | 980 | info.oldSwapchain = old; |
| 976 | VkSwapchainKHR fresh = VK_NULL_HANDLE; | 981 | VkSwapchainKHR fresh = VK_NULL_HANDLE; |
| 977 | const VkResult created = vkCreateSwapchainKHR_(device, &info, nullptr, &fresh); | 982 | const VkResult created = vkCreateSwapchainKHR_(device, &info, nullptr, &fresh); |
| 978 | release(old); // retired by the creation attempt, whether or not it succeeded | 983 | { |
| 984 | std::lock_guard lock(context_.submit_mutex()); | ||
| 985 | release(old); // retired by the creation attempt, whether or not it succeeded | ||
| 986 | } | ||
| 979 | if (created != VK_SUCCESS) return false; | 987 | if (created != VK_SUCCESS) return false; |
| 980 | 988 | ||
| 981 | std::vector<VkImage> images; | 989 | std::vector<VkImage> images; |
| 982 | std::vector<VkSemaphore> ready; | 990 | std::vector<VkSemaphore> ready; |
| 983 | const auto discard = [&] { | 991 | const auto discard = [&] { |
| 984 | for (VkSemaphore semaphore : ready) vk.vkDestroySemaphore(device, semaphore, nullptr); | 992 | for (VkSemaphore semaphore : ready) vk.vkDestroySemaphore(device, semaphore, nullptr); |
| 993 | // The WSI implementation may block on the device here too. | ||
| 994 | std::lock_guard lock(context_.submit_mutex()); | ||
| 985 | vkDestroySwapchainKHR_(device, fresh, nullptr); | 995 | vkDestroySwapchainKHR_(device, fresh, nullptr); |
| 986 | return false; | 996 | return false; |
| 987 | }; | 997 | }; |