[vlc-devel] [PATCH v2 3/3] add vulkan wayland platform

Rémi Denis-Courmont remi at remlab.net
Thu May 7 20:52:08 CEST 2020


Le torstaina 7. toukokuuta 2020, 20.42.34 EEST Alexandre Janniaux a écrit :
> ---
>  modules/video_output/wayland/Makefile.am | 11 +++++
>  modules/video_output/wayland/vulkan.c    | 57 ++++++++++++++++++++++++
>  2 files changed, 68 insertions(+)
>  create mode 100644 modules/video_output/wayland/vulkan.c
> 
> diff --git a/modules/video_output/wayland/Makefile.am
> b/modules/video_output/wayland/Makefile.am index 65dc2ad2992..2e0467ebb23
> 100644
> --- a/modules/video_output/wayland/Makefile.am
> +++ b/modules/video_output/wayland/Makefile.am
> @@ -73,6 +73,14 @@ libegl_wl_plugin_la_CPPFLAGS = $(AM_CPPFLAGS)
> -DUSE_PLATFORM_WAYLAND=1 libegl_wl_plugin_la_CFLAGS = $(AM_CFLAGS)
> $(EGL_CFLAGS) $(WAYLAND_EGL_CFLAGS) libegl_wl_plugin_la_LIBADD =
> $(EGL_LIBS) $(WAYLAND_EGL_LIBS)
> 
> +libvk_wl_plugin_la_SOURCES = $(VULKAN_COMMONSOURCES) \
> +	video_output/vulkan/surface.c \
> +	video_output/wayland/vulkan.c

The shorcuts taken by surface.c are okay as long as there was at mosty one 
"vulkan" module per install. surface.c is not too big, so it's okay to 
replicate the code but e.g. you should not have the same name for config items 
of different backends.

Also static strings are better defined as arrays than constant pointers (to an 
array), and you can't have macros in module name and description as it breaks 
gettext.

It's a bit unfair that it hits the Wayland patch, but it's effectively the first 
time that a single build would have multiple backends.

> +libvk_wl_plugin_la_CFLAGS = $(AM_CFLAGS) \
> +	$(WAYLAND_CFLAGS) $(VULKAN_COMMONCFLAGS) \
> +	-DVK_USE_PLATFORM_WAYLAND_KHR -DPLATFORM_NAME=Wayland
> +libvk_wl_plugin_la_LIBADD = $(VULKAN_COMMONLIBS) $(WAYLAND_LIBS)
> +
>  if HAVE_WAYLAND
>  BUILT_SOURCES += $(nodist_libwl_shm_plugin_la_SOURCES)
>  vout_LTLIBRARIES += libwl_shm_plugin.la
> @@ -82,4 +90,7 @@ vout_LTLIBRARIES += libxdg_shell_plugin.la
>  if HAVE_EGL
>  vout_LTLIBRARIES += libegl_wl_plugin.la
>  endif
> +if HAVE_VULKAN
> +vout_LTLIBRARIES += libvk_wl_plugin.la
> +endif
>  endif
> diff --git a/modules/video_output/wayland/vulkan.c
> b/modules/video_output/wayland/vulkan.c new file mode 100644
> index 00000000000..d326b6c1b7b
> --- /dev/null
> +++ b/modules/video_output/wayland/vulkan.c
> @@ -0,0 +1,57 @@
> +/**
> + * @file vulkan.c
> + * @brief Vulkan platform-specific code for Wayland
> + */
> +/**************************************************************************
> *** + * Copyright © 2020 VideoLabs
> + *
> + * This program is free software; you can redistribute it and/or modify it
> + * under the terms of the GNU Lesser General Public License as published by
> + * the Free Software Foundation; either version 2.1 of the License, or + *
> (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public License
> + * along with this program; if not, write to the Free Software Foundation,
> + * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. +
> ***************************************************************************
> **/ +
> +#include "../vulkan/platform.h"
> +
> +int vlc_vk_InitPlatform(vlc_vk_t *vk)
> +{
> +    if (vk->window->type != VOUT_WINDOW_TYPE_WAYLAND)
> +        return VLC_EGENERIC;
> +
> +    return VLC_SUCCESS;
> +}
> +
> +void vlc_vk_ClosePlatform(vlc_vk_t *vk)
> +{
> +    VLC_UNUSED(vk);
> +}
> +
> +const char * const vlc_vk_PlatformExt =
> VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME; +
> +int vlc_vk_CreateSurface(vlc_vk_t *vk)
> +{
> +    VkInstance vkinst = vk->instance->instance;
> +
> +    VkWaylandSurfaceCreateInfoKHR surface_info = {
> +        .sType = VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR,
> +        .display = vk->window->display.wl,
> +        .surface = vk->window->handle.wl,
> +    };
> +
> +    VkResult res = vkCreateWaylandSurfaceKHR(vkinst, &surface_info, NULL,
> &vk->surface); 
> if (res != VK_SUCCESS) {
> +        msg_Err(vk, "Failed creating Wayland surface");
> +        return VLC_EGENERIC;
> +    }
> +
> +    return VLC_SUCCESS;
> +}


-- 
雷米‧德尼-库尔蒙
http://www.remlab.net/





More information about the vlc-devel mailing list