[vlc-devel] [PATCH 3/6] vout/vulkan: add X11 extension module

Rémi Denis-Courmont remi at remlab.net
Mon Oct 29 20:07:38 CET 2018


Le maanantaina 29. lokakuuta 2018, 15.28.51 EET Niklas Haas a écrit :
> From: Niklas Haas <git at haasn.xyz>
> 
> ---
>  modules/video_output/Makefile.am           |  9 +++
>  modules/video_output/vulkan/platform_xcb.c | 71 ++++++++++++++++++++++
>  2 files changed, 80 insertions(+)
>  create mode 100644 modules/video_output/vulkan/platform_xcb.c
> 
> diff --git a/modules/video_output/Makefile.am
> b/modules/video_output/Makefile.am index ec7273b9fe..96ee30c336 100644
> --- a/modules/video_output/Makefile.am
> +++ b/modules/video_output/Makefile.am
> @@ -140,8 +140,17 @@ libvk_plugin_la_SOURCES = $(VULKAN_COMMONSOURCES)
> video_output/vulkan/display.c libvk_plugin_la_CFLAGS = $(AM_CFLAGS)
> $(VULKAN_COMMONCFLAGS)
>  libvk_plugin_la_LIBADD = $(VULKAN_COMMONLIBS)
> 
> +libvk_x11_plugin_la_SOURCES = $(VULKAN_COMMONSOURCES)
> video_output/vulkan/surface.c \ +			     
> video_output/vulkan/platform_xcb.c
> +libvk_x11_plugin_la_CFLAGS = $(AM_CFLAGS) $(XCB_CFLAGS)
> $(VULKAN_COMMONCFLAGS) \ +			     -DVK_USE_PLATFORM_XCB_KHR
> -DPLATFORM_NAME=X11
> +libvk_x11_plugin_la_LIBADD = $(VULKAN_COMMONLIBS) $(XCB_LIBS)
> +
>  if HAVE_VULKAN
>  vout_LTLIBRARIES += libvk_plugin.la
> +if HAVE_XCB
> +vout_LTLIBRARIES += libvk_x11_plugin.la
> +endif
>  endif
> 
>  ### XCB ###
> diff --git a/modules/video_output/vulkan/platform_xcb.c
> b/modules/video_output/vulkan/platform_xcb.c new file mode 100644
> index 0000000000..a5f250a241
> --- /dev/null
> +++ b/modules/video_output/vulkan/platform_xcb.c
> @@ -0,0 +1,71 @@
> +/**
> + * @file platform_xcb.c
> + * @brief Vulkan platform-specific code for X11/xcb
> + */
> +/**************************************************************************
> *** + * Copyright © 2018 Niklas Haas
> + *
> + * 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 "platform.h"
> +
> +int vlc_vk_InitPlatform(vlc_vk_t *vk)
> +{
> +    if (vk->window->type != VOUT_WINDOW_TYPE_XID)
> +        return VLC_EGENERIC;
> +
> +    const char *display = vk->window->display.x11;
> +    xcb_connection_t *conn = vk->platform_sys = xcb_connect(display, NULL);
> +    if (xcb_connection_has_error(conn))
> +    {
> +        msg_Err(vk, "Failed connecting to X server (%s)",
> +                display ? display : "default");
> +        xcb_disconnect(conn);
> +        return VLC_EGENERIC;
> +    }
> +
> +    return VLC_SUCCESS;
> +}
> +
> +void vlc_vk_ClosePlatform(vlc_vk_t *vk)
> +{
> +    xcb_connection_t *conn = vk->platform_sys;
> +
> +    if (conn)

Looks like tautology.

> +        xcb_disconnect(conn);
> +}
> +
> +const char * const vlc_vk_PlatformExt = VK_KHR_XCB_SURFACE_EXTENSION_NAME;
> +
> +int vlc_vk_CreateSurface(vlc_vk_t *vk)
> +{
> +    VkInstance vkinst = vk->instance->instance;
> +    xcb_connection_t *conn = vk->platform_sys;
> +
> +    VkXcbSurfaceCreateInfoKHR xinfo = {
> +         .sType = VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR,
> +         .window = (xcb_window_t) vk->window->handle.xid,
> +         .connection = conn,
> +    };
> +
> +    VkResult res = vkCreateXcbSurfaceKHR(vkinst, &xinfo, NULL,
> &vk->surface); +    if (res != VK_SUCCESS) {
> +        msg_Err(vk, "Failed creating XCB surface");
> +        return VLC_EGENERIC;
> +    }
> +
> +    return VLC_SUCCESS;
> +}


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





More information about the vlc-devel mailing list