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,7 +210,15 @@ 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
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
gen_sources = [] gen_sources = []
install_headers(vulkan_headers, subdir : 'gstreamer-1.0/gst/vulkan') install_headers(vulkan_headers, subdir : 'gstreamer-1.0/gst/vulkan')
@ -265,8 +279,3 @@ if vulkan_dep.found() and has_vulkan_header
include_directories : [libsinc], include_directories : [libsinc],
sources: gen_sources, sources: gen_sources,
dependencies : [gstvideo_dep, gstbase_dep, vulkan_dep] + optional_deps) dependencies : [gstvideo_dep, gstbase_dep, vulkan_dep] + optional_deps)
elif get_option('vulkan').enabled()
error('GStreamer Vulkan integration required via options, but needed dependencies not found.')
else
gstvulkan_dep = dependency('', required : false)
endif

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())