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 <sebastian.wick@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27592>
This commit is contained in:
Pierre-Eric Pelloux-Prayer 2024-02-13 09:14:55 +01:00 committed by Marge Bot
parent f9787864e0
commit 9a00a360ad

View file

@ -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)