From 8cdc4b7a31d8a3eba4e2ae7cf32bdc808e46538d Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Fri, 12 May 2023 16:13:24 +0200 Subject: render/vulkan: wait for idle queue before destroying render buffer This fixes the following validation errors when shutting down Sway: 00:00:01.263 [wlr] [render/vulkan/vulkan.c:65] Validation Error: [ VUID-vkDestroyFramebuffer-framebuffer-00892 ] Object 0: handle = 0x62e00003c400, type = VK_OBJECT_TYPE_DEVICE; | MessageID = 0xdb308312 | Cannot call vkDestroyFramebuffer on VkFramebuffer 0x2e2cd000000002b[] that is currently in use by a command buffer. The Vulkan spec states: All submitted commands that refer to framebuffer must have completed execution (https://www.khronos.org/registry/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-vkDestroyFramebuffer-framebuffer-00892) (VUID-vkDestroyFramebuffer-framebuffer-00892) 00:00:01.264 [wlr] [render/vulkan/vulkan.c:65] Validation Error: [ VUID-vkDestroyImage-image-01000 ] Object 0: handle = 0x62e00003c400, type = VK_OBJECT_TYPE_DEVICE; | MessageID = 0xf2d29b5a | Cannot call vkDestroyImage on VkImage 0x3fbcd60000000028[] that is currently in use by a command buffer. The Vulkan spec states: All submitted commands that refer to image, either directly or via a VkImageView, must have completed execution (https://www.khronos.org/registry/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-vkDestroyImage-image-01000) (VUID-vkDestroyImage-image-01000) --- render/vulkan/renderer.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'render') diff --git a/render/vulkan/renderer.c b/render/vulkan/renderer.c index a9adc1af..b704caca 100644 --- a/render/vulkan/renderer.c +++ b/render/vulkan/renderer.c @@ -569,6 +569,13 @@ static void destroy_render_buffer(struct wlr_vk_render_buffer *buffer) { VkDevice dev = buffer->renderer->dev->dev; + // TODO: asynchronously wait for the command buffers using this render + // buffer to complete (just like we do for textures) + VkResult res = vkQueueWaitIdle(buffer->renderer->dev->queue); + if (res != VK_SUCCESS) { + wlr_vk_error("vkQueueWaitIdle", res); + } + vkDestroyFramebuffer(dev, buffer->framebuffer, NULL); vkDestroyImageView(dev, buffer->image_view, NULL); vkDestroyImage(dev, buffer->image, NULL); -- cgit v1.2.3