1 if get_option('vulkan').disabled()
2 gstvulkan_dep = dependency('', required: false)
9 'gstvkcommandbuffer.c',
11 'gstvkdescriptorcache.c',
12 'gstvkdescriptorset.c',
13 'gstvkdescriptorpool.c',
23 'gstvkimagebufferpool.c',
27 'gstvkphysicaldevice.c',
39 'gstvkbuffermemory.h',
41 'gstvkcommandbuffer.h',
43 'gstvkdescriptorcache.h',
44 'gstvkdescriptorset.h',
45 'gstvkdescriptorpool.h',
55 'gstvkimagebufferpool.h',
59 'gstvkphysicaldevice.h',
71 vulkan_xcb_headers = []
72 vulkan_wayland_headers = []
74 vulkan_windowing = false
78 has_vulkan_header = false
79 vulkan_dep = dependency('', required: false)
82 vulkan_conf = configuration_data()
83 vulkan_conf_options = [
84 'GST_VULKAN_HAVE_WINDOW_XCB',
85 'GST_VULKAN_HAVE_WINDOW_WAYLAND',
86 'GST_VULKAN_HAVE_WINDOW_COCOA',
87 'GST_VULKAN_HAVE_WINDOW_IOS',
88 'GST_VULKAN_HAVE_WINDOW_WIN32',
89 'GST_VULKAN_HAVE_WINDOW_ANDROID',
92 foreach option : vulkan_conf_options
93 vulkan_conf.set10(option, false)
96 if host_system == 'ios'
97 vulkan_dep = cc.find_library('MoltenVK', required : get_option('vulkan'))
98 elif host_system == 'windows'
99 vulkan_root = run_command(python3, '-c', 'import os; print(os.environ.get("VK_SDK_PATH"))').stdout().strip()
100 if vulkan_root != '' and vulkan_root != 'None'
102 if build_machine.cpu_family() == 'x86_64'
103 vulkan_lib_dir = join_paths(vulkan_root, 'Lib')
105 vulkan_lib_dir = join_paths(vulkan_root, 'Lib32')
108 vulkan_lib = cc.find_library('vulkan-1', dirs: vulkan_lib_dir,
109 required : get_option('vulkan'))
111 vulkan_inc_dir = join_paths(vulkan_root, 'Include')
112 has_vulkan_header = cc.has_header('vulkan/vulkan_core.h',
113 args: '-I' + vulkan_inc_dir)
115 if vulkan_lib.found() and has_vulkan_header
116 vulkan_dep = declare_dependency(include_directories: include_directories(vulkan_inc_dir),
117 dependencies: vulkan_lib)
121 vulkan_dep = dependency('vulkan', method: 'pkg-config', required : false)
122 if not vulkan_dep.found()
123 vulkan_dep = cc.find_library('vulkan', required : false)
127 if host_system != 'windows'
128 has_vulkan_header = cc.has_header('vulkan/vulkan_core.h')
131 if not has_vulkan_header and get_option('vulkan').enabled()
132 error('vulkan plugin enabled, but vulkan.h not found')
134 if not vulkan_dep.found() and get_option('vulkan').enabled()
135 error('vulkan plugin enabled, but could not find vulkan library')
138 xcb_dep = dependency('xcb', version : '>=1.10', required : get_option('x11'))
139 if xcb_dep.found() and cc.has_header('vulkan/vulkan_xcb.h', dependencies : vulkan_dep)
141 'xcb/gstvkdisplay_xcb.c',
142 'xcb/gstvkwindow_xcb.c',
143 'xcb/xcb_event_source.c',
145 vulkan_xcb_headers += [
146 'xcb/gstvkdisplay_xcb.h'
149 optional_deps += xcb_dep
150 vulkan_windowing = true
151 vulkan_conf.set10('GST_VULKAN_HAVE_WINDOW_XCB', 1)
154 wayland_client_dep = dependency('wayland-client', version : '>=1.4', required : get_option('wayland'))
155 if wayland_client_dep.found() and cc.has_header('vulkan/vulkan_wayland.h', dependencies : vulkan_dep)
157 'wayland/gstvkdisplay_wayland.c',
158 'wayland/gstvkwindow_wayland.c',
159 'wayland/wayland_event_source.c',
161 vulkan_wayland_headers += [
162 'wayland/gstvkdisplay_wayland.h'
165 optional_deps += wayland_client_dep
166 vulkan_windowing = true
167 vulkan_conf.set10('GST_VULKAN_HAVE_WINDOW_WAYLAND', 1)
170 if ['darwin', 'ios'].contains(host_system)
171 objc = meson.get_compiler('objc')
172 if not objc.has_argument('-fobjc-arc')
173 error('ARC is required for building')
176 vulkan_objc_args += ['-fobjc-arc']
178 foundation_dep = dependency('appleframeworks', modules : ['Foundation'], required : get_option('vulkan'))
179 quartzcore_dep = dependency('appleframeworks', modules : ['QuartzCore'], required : get_option('vulkan'))
180 corefoundation_dep = dependency('appleframeworks', modules : ['CoreFoundation'], required : get_option('vulkan'))
181 if foundation_dep.found() and quartzcore_dep.found() and corefoundation_dep.found()
182 optional_deps += [foundation_dep, corefoundation_dep, quartzcore_dep]
186 if host_system == 'darwin'
187 cocoa_dep = dependency('appleframeworks', modules : ['Cocoa'], required : get_option('vulkan'))
189 if cocoa_dep.found() and cc.has_header('vulkan/vulkan_macos.h', dependencies : vulkan_dep)
191 'cocoa/gstvkdisplay_cocoa.m',
192 'cocoa/gstvkwindow_cocoa.m',
194 optional_deps += [cocoa_dep]
195 vulkan_windowing = true
196 vulkan_conf.set10('GST_VULKAN_HAVE_WINDOW_COCOA', 1)
200 if host_system == 'ios'
201 uikit_dep = dependency('appleframeworks', modules : ['UIKit'], required : get_option('vulkan'))
203 if uikit_dep.found() and cc.has_header('vulkan/vulkan_ios.h', dependencies : vulkan_dep)
205 'ios/gstvkdisplay_ios.m',
206 'ios/gstvkwindow_ios.m',
208 optional_deps += [uikit_dep]
209 vulkan_windowing = true
210 vulkan_conf.set10('GST_VULKAN_HAVE_WINDOW_IOS', 1)
214 if host_system == 'windows'
215 gdi_dep = cc.find_library('gdi32', required : get_option('vulkan'))
217 # Cannot use internal dependency object with cc.has_header()
218 if gdi_dep.found() and cc.has_header('vulkan/vulkan_win32.h', args: '-I' + vulkan_inc_dir)
219 vulkan_sources += ['win32/gstvkwindow_win32.c']
220 optional_deps += [gdi_dep]
221 vulkan_windowing = true
222 vulkan_conf.set10('GST_VULKAN_HAVE_WINDOW_WIN32', 1)
226 if host_system == 'android'
227 if cc.has_header('vulkan/vulkan_android.h', dependencies : vulkan_dep)
229 'android/gstvkdisplay_android.c',
230 'android/gstvkwindow_android.c',
232 vulkan_windowing = true
233 vulkan_conf.set10('GST_VULKAN_HAVE_WINDOW_ANDROID', 1)
237 if not vulkan_windowing
238 warning('No Windowing system found. vulkansink will not work')
241 if not vulkan_dep.found() or not has_vulkan_header
242 if get_option('vulkan').enabled()
243 error('GStreamer Vulkan integration required via options, but needed dependencies not found.')
245 gstvulkan_dep = dependency('', required : false)
252 install_headers(vulkan_headers, subdir : 'gstreamer-1.0/gst/vulkan')
253 install_headers(vulkan_xcb_headers, subdir : 'gstreamer-1.0/gst/vulkan/xcb')
254 install_headers(vulkan_wayland_headers, subdir : 'gstreamer-1.0/gst/vulkan/wayland')
256 configure_file(input : 'gstvkconfig.h.meson',
257 output : 'gstvkconfig.h',
258 install_dir : join_paths(get_option('includedir'), 'gstreamer-1.0/gst/vulkan'),
259 configuration : vulkan_conf)
261 vulkan_enums = gnome.mkenums_simple('vulkan-enumtypes',
262 sources : vulkan_headers,
263 body_prefix : '#ifdef HAVE_CONFIG_H\n#include "config.h"\n#endif',
264 header_prefix : '#include <gst/vulkan/vulkan-prelude.h>',
265 decorator : 'GST_VULKAN_API',
266 install_header: true,
267 install_dir : join_paths(get_option('includedir'), 'gstreamer-1.0/gst/vulkan'))
268 vulkan_enumtypes_c = vulkan_enums[0]
269 vulkan_enumtypes_h = vulkan_enums[1]
270 gen_sources += [vulkan_enumtypes_h]
272 gstvulkan = library('gstvulkan-' + api_version,
273 vulkan_sources, vulkan_enumtypes_c, vulkan_enumtypes_h,
274 c_args : gst_plugins_bad_args + vulkan_defines + ['-DBUILDING_GST_VULKAN'],
275 objc_args : gst_plugins_bad_args + vulkan_defines + vulkan_objc_args + ['-DBUILDING_GST_VULKAN'],
276 include_directories : [configinc, libsinc],
277 version : libversion,
278 soversion : soversion,
279 darwin_versions : osxversion,
281 dependencies : [gstbase_dep, gstvideo_dep, vulkan_dep] + optional_deps)
284 extra_gir_includes = []
285 gobject_introspection_dep = dependency('gobject-introspection-1.0')
286 if gobject_introspection_dep.version().version_compare('>=1.61.1')
287 # This is the first version that contains Vulkan-1.0.gir
288 extra_gir_includes += ['Vulkan-1.0']
291 vulkan_gir = gnome.generate_gir(gstvulkan,
292 sources : vulkan_sources + vulkan_headers + [vulkan_enumtypes_h, vulkan_enumtypes_c],
293 namespace : 'GstVulkan',
294 nsversion : api_version,
295 identifier_prefix : 'Gst',
296 symbol_prefix : 'gst',
297 export_packages : 'gstreamer-vulkan-1.0',
298 includes : ['Gst-1.0', 'GstBase-1.0', 'GstVideo-1.0'] + extra_gir_includes,
300 extra_args : gir_init_section + ['--c-include=gst/vulkan/vulkan.h'],
301 dependencies : [gstvideo_dep, gst_dep, gstbase_dep] + optional_deps
303 gen_sources += vulkan_gir
306 gstvulkan_dep = declare_dependency(link_with : gstvulkan,
307 include_directories : [libsinc],
308 sources: gen_sources,
309 dependencies : [gstvideo_dep, gstbase_dep, vulkan_dep] + optional_deps)