[vlc-devel] [PATCH v2 2/3] vulkan: force swapchain resize on display size change

Niklas Haas vlc at haasn.xyz
Fri May 15 20:28:59 CEST 2020


Given that you resize the swapchain manually now (and assuming this can
be relied on to always happen), we may want to also add this:

diff --git a/modules/video_output/vulkan/surface.c b/modules/video_output/vulkan/surface.c
index 64fd5d8bde..c2ff304c2e 100644
--- a/modules/video_output/vulkan/surface.c
+++ b/modules/video_output/vulkan/surface.c
@@ -82,6 +82,7 @@ static int Open (vlc_object_t *obj)
         .surface = vk->surface,
         .present_mode = var_InheritInteger(vk, "present-mode"),
         .swapchain_depth = var_InheritInteger(vk, "queue-depth"),
+        .allow_suboptimal = true,
     };
 
     vk->swapchain = pl_vulkan_create_swapchain(vk->vulkan, &swap_params);

(guarded by PL_API_VER >= 18 ofc)

This could in theory make window resizes smoother, at least it does for
mpv. For some reason window resizing is still extremely choppy with VLC
though.

On Thu,  7 May 2020 19:42:33 +0200, Alexandre Janniaux <ajanni at videolabs.io> wrote:
> On Windows the swapchain might not be re-created automatically, which
> result in glitches when using the vk output. This enforce the creation
> of the swapchain as soon as the display size is changed.
> 
> On Wayland, the size of the window is the size of the content so there
> is no automatic swapchain sizing and this call is mandatory.
> ---
>  modules/video_output/vulkan/display.c | 20 ++++++++++++++++++++
>  1 file changed, 20 insertions(+)
> 
> diff --git a/modules/video_output/vulkan/display.c b/modules/video_output/vulkan/display.c
> index 174627d67da..b65a654cb16 100644
> --- a/modules/video_output/vulkan/display.c
> +++ b/modules/video_output/vulkan/display.c
> @@ -351,6 +351,26 @@ static int Control(vout_display_t *vd, int query, va_list ap)
>      case VOUT_DISPLAY_CHANGE_ZOOM: {
>          vout_display_cfg_t cfg = *va_arg (ap, const vout_display_cfg_t *);
>          vout_display_PlacePicture(&sys->place, &vd->source, &cfg);
> +
> +        /* The following resize should be automatic on most platforms but can
> +         * trigger bugs on some platform with some drivers, that have been seen
> +         * on Windows in particular. Doing it right now enforce the correct
> +         * behavior and prevent these bugs.
> +         * In addition, platforms like Wayland need the call as the size of the
> +         * window is defined by the size of the content, and not the opposite.
> +         * The swapchain creation won't be done twice with this call. */
> +#if PL_API_VER >= 18
> +        if (query == VOUT_DISPLAY_CHANGE_DISPLAY_SIZE)
> +        {
> +            int width = (int) cfg.display.width;
> +            int height = (int) cfg.display.height;
> +            pl_swapchain_resize(sys->vk->swapchain, &width, &height);
> +
> +            if (width != (int) cfg.display.width
> +             || height != (int) cfg.display.height)
> +                return VLC_EGENERIC;
> +        }
> +#endif
>          return VLC_SUCCESS;
>      }
>  
> -- 
> 2.26.2
> 
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel


More information about the vlc-devel mailing list