[vlc-devel] [PATCH 06/17] vulkan: platform_xcb: rework as vulkan platform
Alexandre Janniaux
ajanni at videolabs.io
Mon Apr 12 13:32:22 UTC 2021
Instead of recompiling surface.c while implementing its public functions
and so as to implement the wayland surface provider side by side with
the XCB surface provider.
---
modules/video_output/vulkan/platform_xcb.c | 41 ++++++++++++++++++----
modules/video_output/xcb/Makefile.am | 1 -
2 files changed, 34 insertions(+), 8 deletions(-)
diff --git a/modules/video_output/vulkan/platform_xcb.c b/modules/video_output/vulkan/platform_xcb.c
index cb9bf21a08..72efbe9ef7 100644
--- a/modules/video_output/vulkan/platform_xcb.c
+++ b/modules/video_output/vulkan/platform_xcb.c
@@ -20,15 +20,31 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <vlc_common.h>
+#include <vlc_plugin.h>
+
#include "platform.h"
-int vlc_vk_InitPlatform(vlc_vk_t *vk)
+static void ClosePlatform(vlc_vk_t *vk);
+static int CreateSurface(vlc_vk_t *vk, VkInstance instance);
+
+static const struct vlc_vk_operations platform_ops =
+{
+ .close = ClosePlatform,
+ .create_surface = CreateSurface,
+};
+
+static int 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);
+ xcb_connection_t *conn = xcb_connect(display, NULL);
if (xcb_connection_has_error(conn))
{
msg_Err(vk, "Failed connecting to X server (%s)",
@@ -37,19 +53,20 @@ int vlc_vk_InitPlatform(vlc_vk_t *vk)
return VLC_EGENERIC;
}
+ vk->platform_sys = conn;
+ vk->platform_ext = VK_KHR_XCB_SURFACE_EXTENSION_NAME;
+ vk->ops = &platform_ops;
+
return VLC_SUCCESS;
}
-void vlc_vk_ClosePlatform(vlc_vk_t *vk)
+static void ClosePlatform(vlc_vk_t *vk)
{
xcb_connection_t *conn = vk->platform_sys;
-
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)
+static int CreateSurface(vlc_vk_t *vk, VkInstance vkinst)
{
xcb_connection_t *conn = vk->platform_sys;
@@ -67,3 +84,13 @@ int vlc_vk_CreateSurface(vlc_vk_t *vk, VkInstance vkinst)
return VLC_SUCCESS;
}
+
+vlc_module_begin()
+ set_shortname("Vulkan XCB")
+ set_description(N_("XCB/X11 platform support for Vulkan"))
+ set_category(CAT_VIDEO)
+ set_subcategory(SUBCAT_VIDEO_VOUT)
+ set_capability("vulkan platform", 50)
+ set_callback(InitPlatform)
+ add_shortcut("vk_x11")
+vlc_module_end()
diff --git a/modules/video_output/xcb/Makefile.am b/modules/video_output/xcb/Makefile.am
index f946e07ce7..e7d6527229 100644
--- a/modules/video_output/xcb/Makefile.am
+++ b/modules/video_output/xcb/Makefile.am
@@ -33,7 +33,6 @@ libxcb_window_plugin_la_LIBADD = $(XPROTO_LIBS) $(XCB_LIBS) \
$(XCB_XKB_LIBS) $(XKBCOMMON_X11_LIBS)
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) \
--
2.31.1
More information about the vlc-devel
mailing list