From d2f3b6643964ada78803e7ef2d50b60f5c275acf Mon Sep 17 00:00:00 2001 From: llyyr Date: Wed, 11 Sep 2024 21:38:53 +0530 Subject: [PATCH] vulkan: don't tolerate suboptimal swapchain configurations The comment was probably only ever true for x11, and it currently isn't true anymore. X11 WSI used to return VK_SUBOPTIMAL_KHR in vkQueuePresentKHR and vkAcquireNextImageKHR before, but as of https://gitlab.freedesktop.org/mesa/mesa/-/commit/2b885b233f7a6300ae88732c179888c02788493d it only returns VK_SUBOPTIMAL_KHR in vkAcquireNextImageKHR for performance reasons. This makes it so that we don't have to tolerate suboptimal swapchain configurations for the sake of smoother resizing. On top of that, not recreating swapchain when it was suboptimal, it also prevented mpv from being directly scanned out when fullscreened on Wayland compositors. On Wayland, the preferred modifier from the wsi may change depending on whether the window is fullscreened or not for direct scan out. If mpv is fullscreened but not using modifiers that can be directly scanned out, mpv will be receive VK_SUBOPTIMAL_KHR from WSI and should recreate swapchain to use the right modifier with the format mpv picked. mpv will always get the format it picks, WSI can't give us a different format. This allows for recreating the swapchain with modifiers that will allow mpv to be directly scanned out when the window is fullscreened spanning an output on Wayland. I checked X11 and Wayland myself to have no regressions when resizing, and others have checked Windows and Mac to have no regressions. With this, direct scanout with Vulkan on Wayland should just work. You might also need https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31122 if your compositor enables explicit syncronization via linux-drm-syncobj-v1. --- video/out/vulkan/context.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/video/out/vulkan/context.c b/video/out/vulkan/context.c index 8d4ae95f2fdc1..6ae3a1912f2d3 100644 --- a/video/out/vulkan/context.c +++ b/video/out/vulkan/context.c @@ -265,9 +265,6 @@ bool ra_vk_ctx_init(struct ra_ctx *ctx, struct mpvk_ctx *vk, .surface = vk->surface, .present_mode = preferred_mode, .swapchain_depth = ctx->vo->opts->swapchain_depth, - // mpv already handles resize events, so gracefully allow suboptimal - // swapchains to exist in order to make resizing even smoother - .allow_suboptimal = true, }; if (p->opts->swap_mode >= 0) // user override