summaryrefslogtreecommitdiff
path: root/gst-libs/gst/vulkan
diff options
context:
space:
mode:
authorMatthew Waters <matthew@centricular.com>2020-08-11 21:56:39 +1000
committerGStreamer Merge Bot <gitlab-merge-bot@gstreamer-foundation.org>2020-08-15 02:55:30 +0000
commitbc95b5d99a844f590e04077a342f26ea877e2aad (patch)
tree3520e4ff7cc7d2bc8456676d39f972360cb46652 /gst-libs/gst/vulkan
parent314a8c023fe7f722821c73a1d06ebf6f62dd8806 (diff)
downloadgstreamer-plugins-bad-bc95b5d99a844f590e04077a342f26ea877e2aad.tar.gz
build/vulkan: split vulkan gir
also add to docs Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1506>
Diffstat (limited to 'gst-libs/gst/vulkan')
-rw-r--r--gst-libs/gst/vulkan/meson.build109
-rw-r--r--gst-libs/gst/vulkan/vulkan_fwd.h1
-rw-r--r--gst-libs/gst/vulkan/vulkan_mkenum.py55
-rw-r--r--gst-libs/gst/vulkan/wayland/wayland.h27
-rw-r--r--gst-libs/gst/vulkan/xcb/xcb.h27
5 files changed, 197 insertions, 22 deletions
diff --git a/gst-libs/gst/vulkan/meson.build b/gst-libs/gst/vulkan/meson.build
index e35b5553d..52a636898 100644
--- a/gst-libs/gst/vulkan/meson.build
+++ b/gst-libs/gst/vulkan/meson.build
@@ -1,5 +1,7 @@
+gstvulkan_dep = dependency('', required: false)
+gstvulkanxcb_dep = dependency('', required: false)
+gstvulkanwyland_dep = dependency('', required: false)
if get_option('vulkan').disabled()
- gstvulkan_dep = dependency('', required: false)
subdir_done()
endif
@@ -70,7 +72,10 @@ vulkan_headers = [
'vulkan.h',
]
+vulkan_priv_sources = []
+vulkan_xcb_sources = []
vulkan_xcb_headers = []
+vulkan_wayland_sources = []
vulkan_wayland_headers = []
vulkan_windowing = false
@@ -80,6 +85,7 @@ optional_deps = []
has_vulkan_header = false
vulkan_dep = dependency('', required: false)
vulkan_inc_dir = ''
+enabled_vulkan_winsys = []
vulkan_conf = configuration_data()
vulkan_conf_options = [
@@ -148,34 +154,43 @@ xkbcommon_dep = dependency('xkbcommon', required : get_option('x11'))
xkbcommon_x11_dep = dependency('xkbcommon-x11', required : get_option('x11'))
if xcb_dep.found() and xkbcommon_dep.found() and xkbcommon_x11_dep.found() and cc.has_header('vulkan/vulkan_xcb.h', dependencies : vulkan_dep)
- vulkan_sources += [
- 'xcb/gstvkdisplay_xcb.c',
+ vulkan_priv_sources += [
'xcb/gstvkwindow_xcb.c',
'xcb/xcb_event_source.c',
]
+ vulkan_xcb_sources += [
+ 'xcb/gstvkdisplay_xcb.c',
+ ]
vulkan_xcb_headers += [
+ 'xcb/xcb.h',
'xcb/gstvkdisplay_xcb.h'
]
optional_deps += [xcb_dep, xkbcommon_dep, xkbcommon_x11_dep]
vulkan_windowing = true
vulkan_conf.set10('GST_VULKAN_HAVE_WINDOW_XCB', 1)
+ enabled_vulkan_winsys += ['xcb']
endif
wayland_client_dep = dependency('wayland-client', version : '>=1.4', required : get_option('wayland'))
if wayland_client_dep.found() and cc.has_header('vulkan/vulkan_wayland.h', dependencies : vulkan_dep)
- vulkan_sources += [
+ vulkan_priv_sources += [
'wayland/gstvkdisplay_wayland.c',
'wayland/gstvkwindow_wayland.c',
'wayland/wayland_event_source.c',
]
+ vulkan_wayland_sources += [
+ 'wayland/gstvkdisplay_wayland.c',
+ ]
vulkan_wayland_headers += [
+ 'wayland/wayland.h',
'wayland/gstvkdisplay_wayland.h'
]
optional_deps += wayland_client_dep
vulkan_windowing = true
vulkan_conf.set10('GST_VULKAN_HAVE_WINDOW_WAYLAND', 1)
+ enabled_vulkan_winsys += ['wayland']
endif
if ['darwin', 'ios'].contains(host_system)
@@ -198,13 +213,14 @@ if host_system == 'darwin'
cocoa_dep = dependency('appleframeworks', modules : ['Cocoa'], required : get_option('vulkan'))
if cocoa_dep.found() and cc.has_header('vulkan/vulkan_macos.h', dependencies : vulkan_dep)
- vulkan_sources += [
+ vulkan_priv_sources += [
'cocoa/gstvkdisplay_cocoa.m',
'cocoa/gstvkwindow_cocoa.m',
]
optional_deps += [cocoa_dep]
vulkan_windowing = true
vulkan_conf.set10('GST_VULKAN_HAVE_WINDOW_COCOA', 1)
+ enabled_vulkan_winsys += ['cocoa']
endif
endif
@@ -212,13 +228,14 @@ if host_system == 'ios'
uikit_dep = dependency('appleframeworks', modules : ['UIKit'], required : get_option('vulkan'))
if uikit_dep.found() and cc.has_header('vulkan/vulkan_ios.h', dependencies : vulkan_dep)
- vulkan_sources += [
+ vulkan_priv_sources += [
'ios/gstvkdisplay_ios.m',
'ios/gstvkwindow_ios.m',
]
optional_deps += [uikit_dep]
vulkan_windowing = true
vulkan_conf.set10('GST_VULKAN_HAVE_WINDOW_IOS', 1)
+ enabled_vulkan_winsys += ['ios']
endif
endif
@@ -227,21 +244,23 @@ if host_system == 'windows'
# Cannot use internal dependency object with cc.has_header()
if gdi_dep.found() and cc.has_header('vulkan/vulkan_win32.h', args: '-I' + vulkan_inc_dir)
- vulkan_sources += ['win32/gstvkwindow_win32.c']
+ vulkan_priv_sources += ['win32/gstvkwindow_win32.c']
optional_deps += [gdi_dep]
vulkan_windowing = true
vulkan_conf.set10('GST_VULKAN_HAVE_WINDOW_WIN32', 1)
+ enabled_vulkan_winsys += ['win32']
endif
endif
if host_system == 'android'
if cc.has_header('vulkan/vulkan_android.h', dependencies : vulkan_dep)
- vulkan_sources += [
+ vulkan_priv_sources += [
'android/gstvkdisplay_android.c',
'android/gstvkwindow_android.c',
]
vulkan_windowing = true
vulkan_conf.set10('GST_VULKAN_HAVE_WINDOW_ANDROID', 1)
+ enabled_vulkan_winsys += ['android']
endif
endif
@@ -257,7 +276,6 @@ if not vulkan_dep.found() or not has_vulkan_header or not glslc.found()
if get_option('vulkan').enabled()
error('GStreamer Vulkan integration required via options, but needed dependencies not found.')
else
- gstvulkan_dep = dependency('', required : false)
subdir_done()
endif
endif
@@ -265,27 +283,30 @@ endif
gen_sources = []
install_headers(vulkan_headers, subdir : 'gstreamer-1.0/gst/vulkan')
-install_headers(vulkan_xcb_headers, subdir : 'gstreamer-1.0/gst/vulkan/xcb')
-install_headers(vulkan_wayland_headers, subdir : 'gstreamer-1.0/gst/vulkan/wayland')
configure_file(input : 'gstvkconfig.h.meson',
output : 'gstvkconfig.h',
install_dir : join_paths(get_option('includedir'), 'gstreamer-1.0/gst/vulkan'),
configuration : vulkan_conf)
-vulkan_enums = gnome.mkenums_simple('vulkan-enumtypes',
- sources : vulkan_headers,
- body_prefix : '#ifdef HAVE_CONFIG_H\n#include "config.h"\n#endif',
- header_prefix : '#include <gst/vulkan/vulkan-prelude.h>',
- decorator : 'GST_VULKAN_API',
- install_header: true,
- install_dir : join_paths(get_option('includedir'), 'gstreamer-1.0/gst/vulkan'))
-vulkan_enumtypes_c = vulkan_enums[0]
-vulkan_enumtypes_h = vulkan_enums[1]
+glib_mkenums = find_program('glib-mkenums')
+mkenums = find_program('vulkan_mkenum.py')
+vulkan_enumtypes_h = custom_target('gstvulkanenum_h',
+ output : 'vulkan-enumtypes.h',
+ input : vulkan_headers,
+ install : true,
+ install_dir : join_paths(get_option('includedir'), 'include/gstreamer-1.0/gst/vulkan/'),
+ command : [mkenums, glib_mkenums, '@OUTPUT@', '@INPUT@'])
+
+vulkan_enumtypes_c = custom_target('gstvulkanenum_c',
+ output : 'vulkan-enumtypes.c',
+ input : vulkan_headers,
+ depends : [vulkan_enumtypes_h],
+ command : [mkenums, glib_mkenums, '@OUTPUT@', '@INPUT@'])
gen_sources += [vulkan_enumtypes_h]
gstvulkan = library('gstvulkan-' + api_version,
- vulkan_sources, vulkan_enumtypes_c, vulkan_enumtypes_h,
+ vulkan_sources, vulkan_priv_sources, vulkan_wayland_sources, vulkan_xcb_sources, vulkan_enumtypes_c, vulkan_enumtypes_h,
c_args : gst_plugins_bad_args + vulkan_defines + ['-DBUILDING_GST_VULKAN'],
objc_args : gst_plugins_bad_args + vulkan_defines + vulkan_objc_args + ['-DBUILDING_GST_VULKAN'],
include_directories : [configinc, libsinc],
@@ -293,7 +314,9 @@ gstvulkan = library('gstvulkan-' + api_version,
soversion : soversion,
darwin_versions : osxversion,
install : true,
- dependencies : [gstbase_dep, gstvideo_dep, vulkan_dep] + optional_deps)
+ dependencies : [gstbase_dep, gstvideo_dep, vulkan_dep] + optional_deps,
+ # don't confuse gst/vulkan/xcb/xcb.h with xcb/xcb.h
+ implicit_include_directories : false)
if build_gir
extra_gir_includes = []
@@ -322,3 +345,45 @@ gstvulkan_dep = declare_dependency(link_with : gstvulkan,
include_directories : [libsinc],
sources: gen_sources,
dependencies : [gstvideo_dep, gstbase_dep, vulkan_dep] + optional_deps)
+
+if enabled_vulkan_winsys.contains('xcb')
+ install_headers(vulkan_xcb_headers, subdir : 'gstreamer-1.0/gst/vulkan/xcb')
+ vulkan_xcb_gir = []
+ if build_gir
+ vulkan_xcb_gir = gnome.generate_gir(gstvulkan,
+ sources : vulkan_xcb_sources + vulkan_xcb_headers,
+ namespace : 'GstVulkanXCB',
+ nsversion : api_version,
+ identifier_prefix : 'Gst',
+ symbol_prefix : 'gst',
+ export_packages : 'gstreamer-vulkan-xcb-1.0',
+ includes : ['Gst-1.0', 'GstBase-1.0', 'GstVideo-1.0', vulkan_gir[0]] + extra_gir_includes,
+ install : true,
+ extra_args : gir_init_section + ['--c-include=gst/vulkan/xcb/xcb.h'],
+ dependencies : [gstvideo_dep, gst_dep, gstbase_dep] + optional_deps
+ )
+ endif
+ gstvulkanxcb_dep = declare_dependency(dependencies : [gstvulkan_dep],
+ sources : vulkan_xcb_gir)
+endif
+
+if enabled_vulkan_winsys.contains('wayland')
+ install_headers(vulkan_wayland_headers, subdir : 'gstreamer-1.0/gst/vulkan/wayland')
+ vulkan_wayland_gir = []
+ if build_gir
+ vulkan_wayland_gir = gnome.generate_gir(gstvulkan,
+ sources : vulkan_wayland_sources + vulkan_wayland_headers,
+ namespace : 'GstVulkanWayland',
+ nsversion : api_version,
+ identifier_prefix : 'Gst',
+ symbol_prefix : 'gst',
+ export_packages : 'gstreamer-vulkan-wayland-1.0',
+ includes : ['Gst-1.0', 'GstBase-1.0', 'GstVideo-1.0', vulkan_gir[0]] + extra_gir_includes,
+ install : true,
+ extra_args : gir_init_section + ['--c-include=gst/vulkan/wayland/wayland.h'],
+ dependencies : [gstvideo_dep, gst_dep, gstbase_dep] + optional_deps
+ )
+ endif
+ gstvulkanwayland_dep = declare_dependency(dependencies : [gstvulkan_dep],
+ sources : vulkan_wayland_gir)
+endif
diff --git a/gst-libs/gst/vulkan/vulkan_fwd.h b/gst-libs/gst/vulkan/vulkan_fwd.h
index 8634b2834..ccf2fef0a 100644
--- a/gst-libs/gst/vulkan/vulkan_fwd.h
+++ b/gst-libs/gst/vulkan/vulkan_fwd.h
@@ -22,6 +22,7 @@
#define __GST_VULKAN_FWD_H__
#include <gst/gst.h>
+#include <gst/vulkan/vulkan-prelude.h>
G_BEGIN_DECLS
diff --git a/gst-libs/gst/vulkan/vulkan_mkenum.py b/gst-libs/gst/vulkan/vulkan_mkenum.py
new file mode 100644
index 000000000..0d1ecfe09
--- /dev/null
+++ b/gst-libs/gst/vulkan/vulkan_mkenum.py
@@ -0,0 +1,55 @@
+#!/usr/bin/env python3
+
+# This is in its own file rather than inside meson.build
+# because a) mixing the two is ugly and b) trying to
+# make special characters such as \n go through all
+# backends is a fool's errand.
+
+import sys, subprocess
+
+h_array = ['--fhead',
+ "#pragma once\n\n#include <gst/gst.h>\n#include <gst/vulkan/vulkan_fwd.h>\nG_BEGIN_DECLS\n",
+ '--fprod',
+ "\n/* enumerations from \"@basename@\" */\n",
+ '--vhead',
+ "GST_VULKAN_API\nGType @enum_name@_get_type (void);\n#define GST_TYPE_@ENUMSHORT@ (@enum_name@_get_type())\n",
+ '--ftail',
+ "G_END_DECLS"
+]
+
+c_array = ['--fhead',
+ "#ifdef HAVE_CONFIG_H\n#include \"config.h\"\n#endif\n#include \"vulkan-enumtypes.h\"\n\n#include <gst/vulkan/vulkan.h>\n\n#define C_ENUM(v) ((gint) v)\n#define C_FLAGS(v) ((guint) v)",
+ '--fprod',
+ "\n/* enumerations from \"@basename@\" */",
+ '--vhead',
+ "GType\n@enum_name@_get_type (void)\n{\n static volatile gsize g_define_type_id__volatile = 0;\n if (g_once_init_enter (&g_define_type_id__volatile)) {\n static const G@Type@Value values[] = {",
+ '--vprod',
+ " { C_@TYPE@ (@VALUENAME@), \"@VALUENAME@\", \"@valuenick@\" },",
+ '--vtail',
+ " { 0, NULL, NULL }\n };\n GType g_define_type_id = g_@type@_register_static (\"@EnumName@\", values);\n g_once_init_leave (&g_define_type_id__volatile, g_define_type_id);\n }\n return g_define_type_id__volatile;\n}\n"
+]
+
+cmd = []
+argn = 1
+# Find the full command needed to run glib-mkenums
+# On UNIX-like, this is just the full path to glib-mkenums
+# On Windows, this is the full path to interpreter + full path to glib-mkenums
+for arg in sys.argv[1:]:
+ cmd.append(arg)
+ argn += 1
+ if arg.endswith('glib-mkenums'):
+ break
+ofilename = sys.argv[argn]
+headers = sys.argv[argn + 1:]
+
+if ofilename.endswith('.h'):
+ arg_array = h_array
+else:
+ arg_array = c_array
+
+cmd_array = cmd + arg_array + headers
+pc = subprocess.Popen(cmd_array, stdout=subprocess.PIPE)
+(stdo, _) = pc.communicate()
+if pc.returncode != 0:
+ sys.exit(pc.returncode)
+open(ofilename, 'wb').write(stdo)
diff --git a/gst-libs/gst/vulkan/wayland/wayland.h b/gst-libs/gst/vulkan/wayland/wayland.h
new file mode 100644
index 000000000..2981f6091
--- /dev/null
+++ b/gst-libs/gst/vulkan/wayland/wayland.h
@@ -0,0 +1,27 @@
+/*
+ * GStreamer
+ * Copyright (C) 2020 Matthew Waters <matthew@centricular.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __GST_VULKAN_WAYLAND_H__
+#define __GST_VULKAN_WAYLAND_H__
+
+#include <gst/vulkan/vulkan.h>
+#include <gst/vulkan/wayland/gstvkdisplay_wayland.h>
+
+#endif /* __GST_VULKAN_WAYLAND_H__ */
diff --git a/gst-libs/gst/vulkan/xcb/xcb.h b/gst-libs/gst/vulkan/xcb/xcb.h
new file mode 100644
index 000000000..b2740e9b2
--- /dev/null
+++ b/gst-libs/gst/vulkan/xcb/xcb.h
@@ -0,0 +1,27 @@
+/*
+ * GStreamer
+ * Copyright (C) 2020 Matthew Waters <matthew@centricular.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __GST_VULKAN_XCB_H__
+#define __GST_VULKAN_XCB_H__
+
+#include <gst/vulkan/vulkan.h>
+#include <gst/vulkan/xcb/gstvkdisplay_xcb.h>
+
+#endif /* __GST_VULKAN_XCB_H__ */