From 9a00a360ad8bf0e32d41a8d4b4610833d137bb59 Mon Sep 17 00:00:00 2001 From: Pierre-Eric Pelloux-Prayer Date: Tue, 13 Feb 2024 09:14:55 +0100 Subject: [PATCH] wsi/wl: flush connection on swapchain failure wayland-client stores up to MAX_FDS_OUT (28) outgoing fds and then release them in batch later through close_fds. While this is not a problem in normal situation, because the app would also have a reference to the same buffers, this is an issue when these buffers are released (eg: because the swapchain creation failed). In this situation wayland-client owns the last ref to these buffers and prevent their deletion. This is an issue with dEQP-VK.wsi.wayland.swapchain.simulate_oom.image_extent because it creates swapchains in a fast loop with a failing allocator to fail the swapchain creation. Without this change, on a 16GB dGPU the test peaks at 95% VRAM / 60% GTT and completes in 1.5 sec. With this change, the max usage is 65% VRAM / 10% GTT and completes it in 0.3 sec. Reviewed-by: Sebastian Wick Part-of: --- src/vulkan/wsi/wsi_common_wayland.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/vulkan/wsi/wsi_common_wayland.c b/src/vulkan/wsi/wsi_common_wayland.c index 3a168d2113b..26d9f922020 100644 --- a/src/vulkan/wsi/wsi_common_wayland.c +++ b/src/vulkan/wsi/wsi_common_wayland.c @@ -2222,6 +2222,12 @@ static void wsi_wl_swapchain_chain_free(struct wsi_wl_swapchain *chain, const VkAllocationCallbacks *pAllocator) { + /* Force wayland-client to release fd sent during the swapchain + * creation (see MAX_FDS_OUT) to avoid filling up VRAM with + * released buffers. + */ + wl_display_flush(chain->wsi_wl_surface->display->wl_display); + if (chain->frame) wl_callback_destroy(chain->frame); if (chain->tearing_control)