1 gstvulkan_dep = dependency('', required: false)
2 gstvulkanxcb_dep = dependency('', required: false)
3 gstvulkanwyland_dep = dependency('', required: false)
4 if get_option('vulkan').disabled()
8 vulkan_sources = files(
11 'gstvkcommandbuffer.c',
13 'gstvkdescriptorcache.c',
14 'gstvkdescriptorset.c',
15 'gstvkdescriptorpool.c',
22 'gstvkfullscreenquad.c',
26 'gstvkimagebufferpool.c',
30 'gstvkphysicaldevice.c',
39 vulkan_headers = files(
42 'gstvkbuffermemory.h',
44 'gstvkcommandbuffer.h',
46 'gstvkdescriptorcache.h',
47 'gstvkdescriptorset.h',
48 'gstvkdescriptorpool.h',
55 'gstvkfullscreenquad.h',
59 'gstvkimagebufferpool.h',
63 'gstvkphysicaldevice.h',
75 vulkan_priv_sources = []
76 vulkan_xcb_sources = []
77 vulkan_xcb_headers = []
78 vulkan_wayland_sources = []
79 vulkan_wayland_headers = []
81 vulkan_windowing = false
85 has_vulkan_header = false
86 vulkan_dep = dependency('', required: false)
88 enabled_vulkan_winsys = []
90 vulkan_conf = configuration_data()
91 vulkan_conf_options = [
92 'GST_VULKAN_HAVE_WINDOW_XCB',
93 'GST_VULKAN_HAVE_WINDOW_WAYLAND',
94 'GST_VULKAN_HAVE_WINDOW_COCOA',
95 'GST_VULKAN_HAVE_WINDOW_IOS',
96 'GST_VULKAN_HAVE_WINDOW_WIN32',
97 'GST_VULKAN_HAVE_WINDOW_ANDROID',
100 foreach option : vulkan_conf_options
101 vulkan_conf.set10(option, false)
104 if ['ios', 'darwin'].contains(host_system)
105 # - ios does not support the loader/validation layers
106 # - We need to link directly to MoltenVK to be able to use
107 # MoltenVK-specific functions that use dispatchable handles (like
108 # retrieving the metal device from the VkDevice) which is currently waiting
109 # on implementing a proper Metal extension for Vulkan
110 # https://github.com/KhronosGroup/MoltenVK/issues/492
111 vulkan_dep = cc.find_library('MoltenVK', required : get_option('vulkan'))
112 elif host_system == 'windows'
113 vulkan_root = run_command(python3, '-c', 'import os; print(os.environ.get("VK_SDK_PATH"))').stdout().strip()
114 if vulkan_root != '' and vulkan_root != 'None'
116 if build_machine.cpu_family() == 'x86_64'
117 vulkan_lib_dir = join_paths(vulkan_root, 'Lib')
119 vulkan_lib_dir = join_paths(vulkan_root, 'Lib32')
122 vulkan_lib = cc.find_library('vulkan-1', dirs: vulkan_lib_dir,
123 required : get_option('vulkan'))
125 vulkan_inc_dir = join_paths(vulkan_root, 'Include')
126 has_vulkan_header = cc.has_header('vulkan/vulkan_core.h',
127 args: '-I' + vulkan_inc_dir)
129 if vulkan_lib.found() and has_vulkan_header
130 vulkan_dep = declare_dependency(include_directories: include_directories(vulkan_inc_dir),
131 dependencies: vulkan_lib)
135 vulkan_dep = dependency('vulkan', method: 'pkg-config', required : false)
136 if not vulkan_dep.found()
137 vulkan_dep = cc.find_library('vulkan', required : false)
141 if host_system != 'windows'
142 has_vulkan_header = cc.has_header('vulkan/vulkan_core.h')
145 if not has_vulkan_header and get_option('vulkan').enabled()
146 error('vulkan plugin enabled, but vulkan.h not found')
148 if not vulkan_dep.found() and get_option('vulkan').enabled()
149 error('vulkan plugin enabled, but could not find vulkan library')
152 xcb_dep = dependency('xcb', version : '>=1.10', required : get_option('x11'))
153 xkbcommon_dep = dependency('xkbcommon', required : get_option('x11'))
154 xkbcommon_x11_dep = dependency('xkbcommon-x11', required : get_option('x11'))
156 if xcb_dep.found() and xkbcommon_dep.found() and xkbcommon_x11_dep.found() and cc.has_header('vulkan/vulkan_xcb.h', dependencies : vulkan_dep)
157 vulkan_priv_sources += files(
158 'xcb/gstvkwindow_xcb.c',
159 'xcb/xcb_event_source.c',
161 vulkan_xcb_sources += files(
162 'xcb/gstvkdisplay_xcb.c',
164 vulkan_xcb_headers += files(
166 'xcb/gstvkdisplay_xcb.h'
169 optional_deps += [xcb_dep, xkbcommon_dep, xkbcommon_x11_dep]
170 vulkan_windowing = true
171 vulkan_conf.set10('GST_VULKAN_HAVE_WINDOW_XCB', 1)
172 enabled_vulkan_winsys += ['xcb']
175 wayland_client_dep = dependency('wayland-client', version : '>=1.4', required : get_option('wayland'))
176 if wayland_client_dep.found() and cc.has_header('vulkan/vulkan_wayland.h', dependencies : vulkan_dep)
177 vulkan_priv_sources += files(
178 'wayland/gstvkdisplay_wayland.c',
179 'wayland/gstvkwindow_wayland.c',
180 'wayland/wayland_event_source.c',
182 vulkan_wayland_sources += files(
183 'wayland/gstvkdisplay_wayland.c',
185 vulkan_wayland_headers += files(
187 'wayland/gstvkdisplay_wayland.h'
190 optional_deps += wayland_client_dep
191 vulkan_windowing = true
192 vulkan_conf.set10('GST_VULKAN_HAVE_WINDOW_WAYLAND', 1)
193 enabled_vulkan_winsys += ['wayland']
196 if ['darwin', 'ios'].contains(host_system)
197 objc = meson.get_compiler('objc')
198 if not objc.has_argument('-fobjc-arc')
199 error('ARC is required for building')
202 vulkan_objc_args += ['-fobjc-arc']
204 foundation_dep = dependency('appleframeworks', modules : ['Foundation'], required : get_option('vulkan'))
205 quartzcore_dep = dependency('appleframeworks', modules : ['QuartzCore'], required : get_option('vulkan'))
206 corefoundation_dep = dependency('appleframeworks', modules : ['CoreFoundation'], required : get_option('vulkan'))
207 if foundation_dep.found() and quartzcore_dep.found() and corefoundation_dep.found()
208 optional_deps += [foundation_dep, corefoundation_dep, quartzcore_dep]
212 if host_system == 'darwin'
213 cocoa_dep = dependency('appleframeworks', modules : ['Cocoa'], required : get_option('vulkan'))
215 if cocoa_dep.found() and cc.has_header('vulkan/vulkan_macos.h', dependencies : vulkan_dep)
216 vulkan_priv_sources += files(
217 'cocoa/gstvkdisplay_cocoa.m',
218 'cocoa/gstvkwindow_cocoa.m',
220 optional_deps += [cocoa_dep]
221 vulkan_windowing = true
222 vulkan_conf.set10('GST_VULKAN_HAVE_WINDOW_COCOA', 1)
223 enabled_vulkan_winsys += ['cocoa']
227 if host_system == 'ios'
228 uikit_dep = dependency('appleframeworks', modules : ['UIKit'], required : get_option('vulkan'))
230 if uikit_dep.found() and cc.has_header('vulkan/vulkan_ios.h', dependencies : vulkan_dep)
231 vulkan_priv_sources += files(
232 'ios/gstvkdisplay_ios.m',
233 'ios/gstvkwindow_ios.m',
235 optional_deps += [uikit_dep]
236 vulkan_windowing = true
237 vulkan_conf.set10('GST_VULKAN_HAVE_WINDOW_IOS', 1)
238 enabled_vulkan_winsys += ['ios']
242 if host_system == 'windows'
243 gdi_dep = cc.find_library('gdi32', required : get_option('vulkan'))
245 # Cannot use internal dependency object with cc.has_header()
246 if gdi_dep.found() and cc.has_header('vulkan/vulkan_win32.h', args: '-I' + vulkan_inc_dir)
247 vulkan_priv_sources += ['win32/gstvkwindow_win32.c']
248 optional_deps += [gdi_dep]
249 vulkan_windowing = true
250 vulkan_conf.set10('GST_VULKAN_HAVE_WINDOW_WIN32', 1)
251 enabled_vulkan_winsys += ['win32']
255 if host_system == 'android'
256 if cc.has_header('vulkan/vulkan_android.h', dependencies : vulkan_dep)
257 vulkan_priv_sources += files(
258 'android/gstvkdisplay_android.c',
259 'android/gstvkwindow_android.c',
261 vulkan_windowing = true
262 vulkan_conf.set10('GST_VULKAN_HAVE_WINDOW_ANDROID', 1)
263 enabled_vulkan_winsys += ['android']
267 if not vulkan_windowing
268 if get_option('vulkan').enabled()
269 error('No Windowing system found. vulkansink will not work')
271 message('No Windowing system found. vulkansink will not work')
275 # Only needed for the vulkan plugin, but doesn't make sense to build
276 # anything else vulkan related if we are not going to build the plugin
277 glslc = find_program('glslc', required: get_option('vulkan'))
279 if not vulkan_dep.found() or not has_vulkan_header or not glslc.found()
280 if get_option('vulkan').enabled()
281 error('GStreamer Vulkan integration required via options, but needed dependencies not found.')
289 install_headers(vulkan_headers, subdir : 'gstreamer-1.0/gst/vulkan')
291 configure_file(input : 'gstvkconfig.h.meson',
292 output : 'gstvkconfig.h',
293 install_dir : join_paths(get_option('includedir'), 'gstreamer-1.0/gst/vulkan'),
294 configuration : vulkan_conf)
296 glib_mkenums = find_program('glib-mkenums')
297 mkenums = find_program('vulkan_mkenum.py')
298 vulkan_enumtypes_h = custom_target('gstvulkanenum_h',
299 output : 'vulkan-enumtypes.h',
300 input : vulkan_headers,
302 install_dir : join_paths(get_option('includedir'), 'gstreamer-1.0/gst/vulkan/'),
303 command : [mkenums, glib_mkenums, '@OUTPUT@', '@INPUT@'])
305 vulkan_enumtypes_c = custom_target('gstvulkanenum_c',
306 output : 'vulkan-enumtypes.c',
307 input : vulkan_headers,
308 depends : [vulkan_enumtypes_h],
309 command : [mkenums, glib_mkenums, '@OUTPUT@', '@INPUT@'])
310 gen_sources += [vulkan_enumtypes_h]
312 gstvulkan = library('gstvulkan-' + api_version,
313 vulkan_sources, vulkan_priv_sources, vulkan_wayland_sources, vulkan_xcb_sources, vulkan_enumtypes_c, vulkan_enumtypes_h,
314 c_args : gst_plugins_bad_args + vulkan_defines + ['-DBUILDING_GST_VULKAN'],
315 objc_args : gst_plugins_bad_args + vulkan_defines + vulkan_objc_args + ['-DBUILDING_GST_VULKAN'],
316 include_directories : [configinc, libsinc],
317 version : libversion,
318 soversion : soversion,
319 darwin_versions : osxversion,
321 dependencies : [gstbase_dep, gstvideo_dep, vulkan_dep] + optional_deps,
322 # don't confuse gst/vulkan/xcb/xcb.h with xcb/xcb.h
323 implicit_include_directories : false)
325 library_def = {'lib': gstvulkan}
326 pkg_name = 'gstreamer-vulkan-1.0'
327 pkgconfig.generate(gstvulkan,
328 libraries : [gst_dep, gstbase_dep, gstvideo_dep],
329 variables : pkgconfig_variables,
330 subdirs : pkgconfig_subdirs,
332 description : 'GStreamer Vulkan support',
336 extra_gir_includes = []
337 gobject_introspection_dep = dependency('gobject-introspection-1.0')
338 if gobject_introspection_dep.version().version_compare('>=1.61.1')
339 # This is the first version that contains Vulkan-1.0.gir
340 extra_gir_includes += ['Vulkan-1.0']
344 'sources' : vulkan_sources + vulkan_headers + [vulkan_enumtypes_h, vulkan_enumtypes_c],
345 'namespace' : 'GstVulkan',
346 'nsversion' : api_version,
347 'identifier_prefix' : 'Gst',
348 'symbol_prefix' : 'gst',
349 'export_packages' : pkg_name,
350 'includes' : ['Gst-1.0', 'GstBase-1.0', 'GstVideo-1.0'] + extra_gir_includes,
352 'extra_args' : gir_init_section + ['--c-include=gst/vulkan/vulkan.h'],
353 'dependencies' : [gstvideo_dep, gst_dep, gstbase_dep] + optional_deps
356 library_def += {'gir': [gir]}
358 vulkan_gir = gnome.generate_gir(gstvulkan, kwargs: gir)
359 gen_sources += vulkan_gir
362 libraries += [[pkg_name, library_def]]
364 gstvulkan_dep = declare_dependency(link_with : gstvulkan,
365 include_directories : [libsinc],
366 sources: gen_sources,
367 dependencies : [gstvideo_dep, gstbase_dep, vulkan_dep] + optional_deps)
369 meson.override_dependency(pkg_name, gstvulkan_dep)
371 if enabled_vulkan_winsys.contains('xcb')
372 install_headers(vulkan_xcb_headers, subdir : 'gstreamer-1.0/gst/vulkan/xcb')
374 libraries : [gstvulkan],
376 subdirs : pkgconfig_subdirs,
377 name : 'gstreamer-vulkan-xcb-1.0',
378 description : 'GStreamer Vulkan support (XCB Specifics)',
383 'sources' : vulkan_xcb_sources + vulkan_xcb_headers,
384 'namespace' : 'GstVulkanXCB',
385 'nsversion' : api_version,
386 'identifier_prefix' : 'Gst',
387 'symbol_prefix' : 'gst',
388 'export_packages' : 'gstreamer-vulkan-xcb-1.0',
390 'extra_args' : gir_init_section + ['--c-include=gst/vulkan/xcb/xcb.h'],
391 'dependencies' : [gstvideo_dep, gst_dep, gstbase_dep] + optional_deps
395 gir += {'includes' : ['Gst-1.0', 'GstBase-1.0', 'GstVideo-1.0', vulkan_gir[0]] + extra_gir_includes}
396 vulkan_xcb_gir = gnome.generate_gir(gstvulkan, kwargs: gir)
399 gir += {'includes' :['Gst-1.0', 'GstBase-1.0', 'GstVideo-1.0', 'GstVulkan-1.0'] + extra_gir_includes}
400 library_def += {'gir': library_def['gir'] + [gir]}
402 gstvulkanxcb_dep = declare_dependency(dependencies : [gstvulkan_dep],
403 sources : vulkan_xcb_gir)
404 meson.override_dependency('gstreamer-vulkan-xcb-1.0', gstvulkanxcb_dep)
407 if enabled_vulkan_winsys.contains('wayland')
408 install_headers(vulkan_wayland_headers, subdir : 'gstreamer-1.0/gst/vulkan/wayland')
410 libraries : [gstvulkan],
411 requires : ['wayland-client'],
412 subdirs : pkgconfig_subdirs,
413 name : 'gstreamer-vulkan-wayland-1.0',
414 description : 'GStreamer Vulkan support (Wayland Specifics)',
416 vulkan_wayland_gir = []
419 'sources' : vulkan_wayland_sources + vulkan_wayland_headers,
420 'namespace' : 'GstVulkanWayland',
421 'nsversion' : api_version,
422 'identifier_prefix' : 'Gst',
423 'symbol_prefix' : 'gst',
424 'export_packages' : 'gstreamer-vulkan-wayland-1.0',
426 'extra_args' : gir_init_section + ['--c-include=gst/vulkan/wayland/wayland.h'],
427 'dependencies' : [gstvideo_dep, gst_dep, gstbase_dep] + optional_deps
430 gir += {'includes' : ['Gst-1.0', 'GstBase-1.0', 'GstVideo-1.0', vulkan_gir[0]] + extra_gir_includes}
431 vulkan_wayland_gir += gnome.generate_gir(gstvulkan, kwargs: gir)
433 gir += {'includes' :['Gst-1.0', 'GstBase-1.0', 'GstVideo-1.0', 'GstVulkan-1.0'] + extra_gir_includes}
434 library_def += {'gir': library_def['gir'] + [gir]}
436 gstvulkanwayland_dep = declare_dependency(dependencies : [gstvulkan_dep],
437 sources : vulkan_wayland_gir)
438 meson.override_dependency('gstreamer-vulkan-wayland-1.0', gstvulkanwayland_dep)