vulkan: remove the winsys-specific headers from gst/vulkan/vulkan.h

Allows not having wayland, xcb, Cocoa, UIKit, windows.h included in the
public GstVulkan API.
This commit is contained in:
Matthew Waters 2019-09-18 23:49:08 +10:00
parent f7626c1f2a
commit a03d0a2638
12 changed files with 88 additions and 117 deletions

View file

@ -23,13 +23,8 @@
#include <gst/gst.h> #include <gst/gst.h>
#ifndef VK_USE_PLATFORM_MACOS_MVK
#error "VK_USE_PLATFORM_MACOS_MVK not defined before including this header"
#error "Either include vkapi.h or define VK_USE_PLATFORM_MACOS_MVK before including this header"
#endif
#include <vulkan/vulkan.h>
#include <gst/vulkan/vulkan.h> #include <gst/vulkan/vulkan.h>
#include <vulkan/vulkan_macos.h>
G_BEGIN_DECLS G_BEGIN_DECLS

View file

@ -22,6 +22,7 @@
#define __GST_VULKAN_WINDOW_COCOA_H__ #define __GST_VULKAN_WINDOW_COCOA_H__
#include <gst/vulkan/vulkan.h> #include <gst/vulkan/vulkan.h>
#include <vulkan/vulkan_macos.h>
G_BEGIN_DECLS G_BEGIN_DECLS

View file

@ -28,37 +28,6 @@
#include <gst/vulkan/vulkan_fwd.h> #include <gst/vulkan/vulkan_fwd.h>
#include <gst/vulkan/vulkan-enumtypes.h> #include <gst/vulkan/vulkan-enumtypes.h>
/* Need these defined to have access to winsys functions before including vulkan.h */ #include <vulkan/vulkan_core.h>
#if GST_VULKAN_HAVE_WINDOW_XCB
#ifndef VK_USE_PLATFORM_XCB_KHR
#define VK_USE_PLATFORM_XCB_KHR
#endif
#endif
#if GST_VULKAN_HAVE_WINDOW_WAYLAND
#ifndef VK_USE_PLATFORM_WAYLAND_KHR
#define VK_USE_PLATFORM_WAYLAND_KHR
#endif
#endif
#if GST_VULKAN_HAVE_WINDOW_COCOA
#ifndef VK_USE_PLATFORM_MACOS_MVK
#define VK_USE_PLATFORM_MACOS_MVK
#endif
#endif
#if GST_VULKAN_HAVE_WINDOW_IOS
#ifndef VK_USE_PLATFORM_IOS_MVK
#define VK_USE_PLATFORM_IOS_MVK
#endif
#endif
#if GST_VULKAN_HAVE_WINDOW_WIN32
#ifndef VK_USE_PLATFORM_WIN32_KHR
#define VK_USE_PLATFORM_WIN32_KHR
#endif
#endif
#include <vulkan/vulkan.h>
#endif /* __GST_VULKAN_API_H__ */ #endif /* __GST_VULKAN_API_H__ */

View file

@ -1,6 +1,6 @@
/* /*
* GStreamer * GStreamer
* Copyright (C) 2016 Matthew Waters <matthew@centricular.com> * Copyright (C) 2019 Matthew Waters <matthew@centricular.com>
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public * modify it under the terms of the GNU Library General Public
@ -30,4 +30,4 @@ void gst_vulkan_command_pool_release_buffer (GstVulkanCommandPool *
G_END_DECLS G_END_DECLS
#endif /* __GST_VULKAN_IMAGE_BUFFER_POOL_H__ */ #endif /* __GST_VULKAN_COMMAND_POOL_PRIVATE_H__ */

View file

@ -23,13 +23,8 @@
#include <gst/gst.h> #include <gst/gst.h>
#ifndef VK_USE_PLATFORM_IOS_MVK
#error "VK_USE_PLATFORM_IOS_MVK not defined before including this header"
#error "Either include vkapi.h or define VK_USE_PLATFORM_IOS_MVK before including this header"
#endif
#include <vulkan/vulkan.h>
#include <gst/vulkan/vulkan.h> #include <gst/vulkan/vulkan.h>
#include <vulkan/vulkan_ios.h>
G_BEGIN_DECLS G_BEGIN_DECLS

View file

@ -22,6 +22,7 @@
#define __GST_VULKAN_WINDOW_IOS_H__ #define __GST_VULKAN_WINDOW_IOS_H__
#include <gst/vulkan/vulkan.h> #include <gst/vulkan/vulkan.h>
#include <vulkan/vulkan_ios.h>
G_BEGIN_DECLS G_BEGIN_DECLS

View file

@ -93,7 +93,7 @@ elif host_system == 'windows'
required : get_option('vulkan')) required : get_option('vulkan'))
vulkan_inc_dir = join_paths(vulkan_root, 'Include') vulkan_inc_dir = join_paths(vulkan_root, 'Include')
has_vulkan_header = cc.has_header('vulkan/vulkan.h', has_vulkan_header = cc.has_header('vulkan/vulkan_core.h',
args: '-I' + vulkan_inc_dir) args: '-I' + vulkan_inc_dir)
if vulkan_lib.found() and has_vulkan_header if vulkan_lib.found() and has_vulkan_header
@ -102,19 +102,25 @@ elif host_system == 'windows'
endif endif
endif endif
else else
vulkan_dep = cc.find_library('vulkan', required : get_option('vulkan')) vulkan_dep = dependency('vulkan', method: 'pkg-config', required : false)
if not vulkan_dep.found()
vulkan_dep = cc.find_library('vulkan', required : false)
endif
endif endif
if host_system != 'windows' if host_system != 'windows'
has_vulkan_header = cc.has_header('vulkan/vulkan.h') has_vulkan_header = cc.has_header('vulkan/vulkan_core.h')
endif endif
if not has_vulkan_header and get_option('vulkan').enabled() if not has_vulkan_header and get_option('vulkan').enabled()
error('vulkan plugin enabled, but vulkan.h not found') error('vulkan plugin enabled, but vulkan.h not found')
endif endif
if not vulkan_dep.found() and get_option('vulkan').enabled()
error('vulkan plugin enabled, but could not find vulkan library')
endif
xcb_dep = dependency('xcb', version : '>=1.10', required : get_option('x11')) xcb_dep = dependency('xcb', version : '>=1.10', required : get_option('x11'))
if xcb_dep.found() if xcb_dep.found() and cc.has_header('vulkan/vulkan_xcb.h', dependencies : vulkan_dep)
vulkan_sources += [ vulkan_sources += [
'xcb/gstvkdisplay_xcb.c', 'xcb/gstvkdisplay_xcb.c',
'xcb/gstvkwindow_xcb.c', 'xcb/gstvkwindow_xcb.c',
@ -130,7 +136,7 @@ if xcb_dep.found()
endif endif
wayland_client_dep = dependency('wayland-client', version : '>=1.4', required : get_option('wayland')) wayland_client_dep = dependency('wayland-client', version : '>=1.4', required : get_option('wayland'))
if wayland_client_dep.found() if wayland_client_dep.found() and cc.has_header('vulkan/vulkan_wayland.h', dependencies : vulkan_dep)
vulkan_sources += [ vulkan_sources += [
'wayland/gstvkdisplay_wayland.c', 'wayland/gstvkdisplay_wayland.c',
'wayland/gstvkwindow_wayland.c', 'wayland/gstvkwindow_wayland.c',
@ -164,7 +170,7 @@ endif
if host_system == 'darwin' if host_system == 'darwin'
cocoa_dep = dependency('appleframeworks', modules : ['Cocoa'], required : get_option('vulkan')) cocoa_dep = dependency('appleframeworks', modules : ['Cocoa'], required : get_option('vulkan'))
if cocoa_dep.found() if cocoa_dep.found() and cc.has_header('vulkan/vulkan_macos.h', dependencies : vulkan_dep)
vulkan_sources += [ vulkan_sources += [
'cocoa/gstvkdisplay_cocoa.m', 'cocoa/gstvkdisplay_cocoa.m',
'cocoa/gstvkwindow_cocoa.m', 'cocoa/gstvkwindow_cocoa.m',
@ -178,7 +184,7 @@ endif
if host_system == 'ios' if host_system == 'ios'
uikit_dep = dependency('appleframeworks', modules : ['UIKit'], required : get_option('vulkan')) uikit_dep = dependency('appleframeworks', modules : ['UIKit'], required : get_option('vulkan'))
if uikit_dep.found() if uikit_dep.found() and cc.has_header('vulkan/vulkan_ios.h', dependencies : vulkan_dep)
vulkan_sources += [ vulkan_sources += [
'ios/gstvkdisplay_ios.m', 'ios/gstvkdisplay_ios.m',
'ios/gstvkwindow_ios.m', 'ios/gstvkwindow_ios.m',
@ -192,7 +198,7 @@ endif
if host_system == 'windows' if host_system == 'windows'
gdi_dep = cc.find_library('gdi32', required : get_option('vulkan')) gdi_dep = cc.find_library('gdi32', required : get_option('vulkan'))
if gdi_dep.found() if gdi_dep.found() and cc.has_header('vulkan/vulkan_win32.h', dependencies : vulkan_dep)
vulkan_sources += ['win32/gstvkwindow_win32.c'] vulkan_sources += ['win32/gstvkwindow_win32.c']
optional_deps += [gdi_dep] optional_deps += [gdi_dep]
vulkan_windowing = true vulkan_windowing = true
@ -204,69 +210,72 @@ if not vulkan_windowing
warning('No Windowing system found. vulkansink will not work') warning('No Windowing system found. vulkansink will not work')
endif endif
if vulkan_dep.found() and has_vulkan_header if not vulkan_dep.found() or not has_vulkan_header
gen_sources = [] 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
install_headers(vulkan_headers, subdir : 'gstreamer-1.0/gst/vulkan') gen_sources = []
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', install_headers(vulkan_headers, subdir : 'gstreamer-1.0/gst/vulkan')
output : 'gstvkconfig.h', install_headers(vulkan_xcb_headers, subdir : 'gstreamer-1.0/gst/vulkan/xcb')
install_dir : join_paths(get_option('includedir'), 'gstreamer-1.0/gst/vulkan'), install_headers(vulkan_wayland_headers, subdir : 'gstreamer-1.0/gst/vulkan/wayland')
configuration : vulkan_conf)
vulkan_enums = gnome.mkenums_simple('vulkan-enumtypes', configure_file(input : 'gstvkconfig.h.meson',
sources : vulkan_headers, output : 'gstvkconfig.h',
body_prefix : '#ifdef HAVE_CONFIG_H\n#include "config.h"\n#endif', install_dir : join_paths(get_option('includedir'), 'gstreamer-1.0/gst/vulkan'),
header_prefix : '#include <gst/vulkan/vulkan-prelude.h>', configuration : vulkan_conf)
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]
gen_sources += [vulkan_enumtypes_h]
gstvulkan = library('gstvulkan-' + api_version, vulkan_enums = gnome.mkenums_simple('vulkan-enumtypes',
vulkan_sources, vulkan_enumtypes_c, vulkan_enumtypes_h, sources : vulkan_headers,
c_args : gst_plugins_bad_args + vulkan_defines + ['-DBUILDING_GST_VULKAN'], body_prefix : '#ifdef HAVE_CONFIG_H\n#include "config.h"\n#endif',
objc_args : gst_plugins_bad_args + vulkan_defines + vulkan_objc_args + ['-DBUILDING_GST_VULKAN'], header_prefix : '#include <gst/vulkan/vulkan-prelude.h>',
include_directories : [configinc, libsinc], decorator : 'GST_VULKAN_API',
version : libversion, install_header: true,
soversion : soversion, install_dir : join_paths(get_option('includedir'), 'gstreamer-1.0/gst/vulkan'))
darwin_versions : osxversion, vulkan_enumtypes_c = vulkan_enums[0]
install : true, vulkan_enumtypes_h = vulkan_enums[1]
dependencies : [gstbase_dep, gstvideo_dep, vulkan_dep] + optional_deps) gen_sources += [vulkan_enumtypes_h]
if build_gir gstvulkan = library('gstvulkan-' + api_version,
extra_gir_includes = [] vulkan_sources, vulkan_enumtypes_c, vulkan_enumtypes_h,
gobject_introspection_dep = dependency('gobject-introspection-1.0') c_args : gst_plugins_bad_args + vulkan_defines + ['-DBUILDING_GST_VULKAN'],
if gobject_introspection_dep.version().version_compare('>=1.61.1') objc_args : gst_plugins_bad_args + vulkan_defines + vulkan_objc_args + ['-DBUILDING_GST_VULKAN'],
# This is the first version that contains Vulkan-1.0.gir include_directories : [configinc, libsinc],
extra_gir_includes += ['Vulkan-1.0'] version : libversion,
endif soversion : soversion,
darwin_versions : osxversion,
install : true,
dependencies : [gstbase_dep, gstvideo_dep, vulkan_dep] + optional_deps)
vulkan_gir = gnome.generate_gir(gstvulkan, if build_gir
sources : vulkan_sources + vulkan_headers + [vulkan_enumtypes_h, vulkan_enumtypes_c], extra_gir_includes = []
namespace : 'GstVulkan', gobject_introspection_dep = dependency('gobject-introspection-1.0')
nsversion : api_version, if gobject_introspection_dep.version().version_compare('>=1.61.1')
identifier_prefix : 'Gst', # This is the first version that contains Vulkan-1.0.gir
symbol_prefix : 'gst', extra_gir_includes += ['Vulkan-1.0']
export_packages : 'gstreamer-vulkan-1.0',
includes : ['Gst-1.0', 'GstBase-1.0', 'GstVideo-1.0'] + extra_gir_includes,
install : true,
extra_args : gir_init_section + ['--c-include=gst/vulkan/vulkan.h'],
dependencies : [gstvideo_dep, gst_dep, gstbase_dep] + optional_deps
)
gen_sources += vulkan_gir
endif endif
gstvulkan_dep = declare_dependency(link_with : gstvulkan, vulkan_gir = gnome.generate_gir(gstvulkan,
include_directories : [libsinc], sources : vulkan_sources + vulkan_headers + [vulkan_enumtypes_h, vulkan_enumtypes_c],
sources: gen_sources, namespace : 'GstVulkan',
dependencies : [gstvideo_dep, gstbase_dep, vulkan_dep] + optional_deps) nsversion : api_version,
elif get_option('vulkan').enabled() identifier_prefix : 'Gst',
error('GStreamer Vulkan integration required via options, but needed dependencies not found.') symbol_prefix : 'gst',
else export_packages : 'gstreamer-vulkan-1.0',
gstvulkan_dep = dependency('', required : false) includes : ['Gst-1.0', 'GstBase-1.0', 'GstVideo-1.0'] + extra_gir_includes,
install : true,
extra_args : gir_init_section + ['--c-include=gst/vulkan/vulkan.h'],
dependencies : [gstvideo_dep, gst_dep, gstbase_dep] + optional_deps
)
gen_sources += vulkan_gir
endif endif
gstvulkan_dep = declare_dependency(link_with : gstvulkan,
include_directories : [libsinc],
sources: gen_sources,
dependencies : [gstvideo_dep, gstbase_dep, vulkan_dep] + optional_deps)

View file

@ -26,6 +26,7 @@
#include <wayland-client.h> #include <wayland-client.h>
#include <gst/vulkan/vulkan.h> #include <gst/vulkan/vulkan.h>
#include <vulkan/vulkan_wayland.h>
G_BEGIN_DECLS G_BEGIN_DECLS

View file

@ -26,6 +26,8 @@
#include <gst/vulkan/vulkan.h> #include <gst/vulkan/vulkan.h>
#include <vulkan/vulkan_wayland.h>
G_BEGIN_DECLS G_BEGIN_DECLS
#define GST_TYPE_VULKAN_WINDOW_WAYLAND (gst_vulkan_window_wayland_get_type()) #define GST_TYPE_VULKAN_WINDOW_WAYLAND (gst_vulkan_window_wayland_get_type())

View file

@ -27,6 +27,7 @@
#define UNICODE #define UNICODE
#include <gst/vulkan/vulkan.h> #include <gst/vulkan/vulkan.h>
#include <vulkan/vulkan_win32.h>
G_BEGIN_DECLS G_BEGIN_DECLS

View file

@ -24,12 +24,7 @@
#include <gst/gst.h> #include <gst/gst.h>
#include <xcb/xcb.h> #include <xcb/xcb.h>
#include <vulkan/vulkan_xcb.h>
#ifndef VK_USE_PLATFORM_XCB_KHR
#error "VK_USE_PLATFORM_XCB_KHR not defined before including this header"
#error "Either include vkapi.h or define VK_USE_PLATFORM_XCB_KHR before including this header"
#endif
#include <vulkan/vulkan.h>
#include <gst/vulkan/vulkan.h> #include <gst/vulkan/vulkan.h>

View file

@ -25,6 +25,8 @@
#include <gst/vulkan/vulkan.h> #include <gst/vulkan/vulkan.h>
#include <vulkan/vulkan_xcb.h>
G_BEGIN_DECLS G_BEGIN_DECLS
#define GST_TYPE_VULKAN_WINDOW_XCB (gst_vulkan_window_xcb_get_type()) #define GST_TYPE_VULKAN_WINDOW_XCB (gst_vulkan_window_xcb_get_type())