upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime/src/vulkan_present.h
diff options
context:
space:
mode:
authorpmilewsskiedu-gif <266377087+pmilewsskiedu-gif@users.noreply.github.com>2026-11-22 15:53:23 -0500
committerpmilewsskiedu-gif <266377087+pmilewsskiedu-gif@users.noreply.github.com>2026-11-22 15:53:23 -0500
commit3ff15669c2f221d1e310b888b0574f73bcaecbdf (patch)
tree022f4f24f49edae10e859a7e24a8c34c76eaaa51 /runtime/src/vulkan_present.h
parentf847748cc76bd3777f9c070c4034eb2fc1c04e64 (diff)
fix: serialize presenter swapchain destruction with Vulkan queue submissions
Diffstat (limited to 'runtime/src/vulkan_present.h')
-rw-r--r--runtime/src/vulkan_present.h16
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 };