1 if get_option('vulkan').disabled()
2 gstvulkan_dep = dependency('', required: false)
9 'gstvkcommandbuffer.c',
11 'gstvkdescriptorcache.c',
12 'gstvkdescriptorset.c',
13 'gstvkdescriptorpool.c',
20 'gstvkfullscreenquad.c',
24 'gstvkimagebufferpool.c',
28 'gstvkphysicaldevice.c',
40 'gstvkbuffermemory.h',
42 'gstvkcommandbuffer.h',
44 'gstvkdescriptorcache.h',
45 'gstvkdescriptorset.h',
46 'gstvkdescriptorpool.h',
53 'gstvkfullscreenquad.h',
57 'gstvkimagebufferpool.h',
61 'gstvkphysicaldevice.h',
73 vulkan_xcb_headers = []
74 vulkan_wayland_headers = []
76 vulkan_windowing = false
80 has_vulkan_header = false
81 vulkan_dep = dependency('', required: false)
84 vulkan_conf = configuration_data()
85 vulkan_conf_options = [
86 'GST_VULKAN_HAVE_WINDOW_XCB',
87 'GST_VULKAN_HAVE_WINDOW_WAYLAND',
88 'GST_VULKAN_HAVE_WINDOW_COCOA',
89 'GST_VULKAN_HAVE_WINDOW_IOS',
90 'GST_VULKAN_HAVE_WINDOW_WIN32',
91 'GST_VULKAN_HAVE_WINDOW_ANDROID',
94 foreach option : vulkan_conf_options
95 vulkan_conf.set10(option, false)
98 if host_system == 'ios'
99 vulkan_dep = cc.find_library('MoltenVK', required : get_option('vulkan'))
100 elif host_system == 'windows'
101 vulkan_root = run_command(python3, '-c', 'import os; print(os.environ.get("VK_SDK_PATH"))').stdout().strip()
102 if vulkan_root != '' and vulkan_root != 'None'
104 if build_machine.cpu_family() == 'x86_64'
105 vulkan_lib_dir = join_paths(vulkan_root, 'Lib')
107 vulkan_lib_dir = join_paths(vulkan_root, 'Lib32')
110 vulkan_lib = cc.find_library('vulkan-1', dirs: vulkan_lib_dir,
111 required : get_option('vulkan'))
113 vulkan_inc_dir = join_paths(vulkan_root, 'Include')
114 has_vulkan_header = cc.has_header('vulkan/vulkan_core.h',
115 args: '-I' + vulkan_inc_dir)
117 if vulkan_lib.found() and has_vulkan_header
118 vulkan_dep = declare_dependency(include_directories: include_directories(vulkan_inc_dir),
119 dependencies: vulkan_lib)
123 vulkan_dep = dependency('vulkan', method: 'pkg-config', required : false)
124 if not vulkan_dep.found()
125 vulkan_dep = cc.find_library('vulkan', required : false)
129 if host_system != 'windows'
130 has_vulkan_header = cc.has_header('vulkan/vulkan_core.h')
133 if not has_vulkan_header and get_option('vulkan').enabled()
134 error('vulkan plugin enabled, but vulkan.h not found')
136 if not vulkan_dep.found() and get_option('vulkan').enabled()
137 error('vulkan plugin enabled, but could not find vulkan library')
140 xcb_dep = dependency('xcb', version : '>=1.10', required : get_option('x11'))
141 if xcb_dep.found() and cc.has_header('vulkan/vulkan_xcb.h', dependencies : vulkan_dep)
143 'xcb/gstvkdisplay_xcb.c',
144 'xcb/gstvkwindow_xcb.c',
145 'xcb/xcb_event_source.c',
147 vulkan_xcb_headers += [
148 'xcb/gstvkdisplay_xcb.h'
151 optional_deps += xcb_dep
152 vulkan_windowing = true
153 vulkan_conf.set10('GST_VULKAN_HAVE_WINDOW_XCB', 1)
156 wayland_client_dep = dependency('wayland-client', version : '>=1.4', required : get_option('wayland'))
157 if wayland_client_dep.found() and cc.has_header('vulkan/vulkan_wayland.h', dependencies : vulkan_dep)
159 'wayland/gstvkdisplay_wayland.c',
160 'wayland/gstvkwindow_wayland.c',
161 'wayland/wayland_event_source.c',
163 vulkan_wayland_headers += [
164 'wayland/gstvkdisplay_wayland.h'
167 optional_deps += wayland_client_dep
168 vulkan_windowing = true
169 vulkan_conf.set10('GST_VULKAN_HAVE_WINDOW_WAYLAND', 1)
172 if ['darwin', 'ios'].contains(host_system)
173 objc = meson.get_compiler('objc')
174 if not objc.has_argument('-fobjc-arc')
175 error('ARC is required for building')
178 vulkan_objc_args += ['-fobjc-arc']
180 foundation_dep = dependency('appleframeworks', modules : ['Foundation'], required : get_option('vulkan'))
181 quartzcore_dep = dependency('appleframeworks', modules : ['QuartzCore'], required : get_option('vulkan'))
182 corefoundation_dep = dependency('appleframeworks', modules : ['CoreFoundation'], required : get_option('vulkan'))
183 if foundation_dep.found() and quartzcore_dep.found() and corefoundation_dep.found()
184 optional_deps += [foundation_dep, corefoundation_dep, quartzcore_dep]
188 if host_system == 'darwin'
189 cocoa_dep = dependency('appleframeworks', modules : ['Cocoa'], required : get_option('vulkan'))
191 if cocoa_dep.found() and cc.has_header('vulkan/vulkan_macos.h', dependencies : vulkan_dep)
193 'cocoa/gstvkdisplay_cocoa.m',
194 'cocoa/gstvkwindow_cocoa.m',
196 optional_deps += [cocoa_dep]
197 vulkan_windowing = true
198 vulkan_conf.set10('GST_VULKAN_HAVE_WINDOW_COCOA', 1)
202 if host_system == 'ios'
203 uikit_dep = dependency('appleframeworks', modules : ['UIKit'], required : get_option('vulkan'))
205 if uikit_dep.found() and cc.has_header('vulkan/vulkan_ios.h', dependencies : vulkan_dep)
207 'ios/gstvkdisplay_ios.m',
208 'ios/gstvkwindow_ios.m',
210 optional_deps += [uikit_dep]
211 vulkan_windowing = true
212 vulkan_conf.set10('GST_VULKAN_HAVE_WINDOW_IOS', 1)
216 if host_system == 'windows'
217 gdi_dep = cc.find_library('gdi32', required : get_option('vulkan'))
219 # Cannot use internal dependency object with cc.has_header()
220 if gdi_dep.found() and cc.has_header('vulkan/vulkan_win32.h', args: '-I' + vulkan_inc_dir)
221 vulkan_sources += ['win32/gstvkwindow_win32.c']
222 optional_deps += [gdi_dep]
223 vulkan_windowing = true
224 vulkan_conf.set10('GST_VULKAN_HAVE_WINDOW_WIN32', 1)
228 if host_system == 'android'
229 if cc.has_header('vulkan/vulkan_android.h', dependencies : vulkan_dep)
231 'android/gstvkdisplay_android.c',
232 'android/gstvkwindow_android.c',
234 vulkan_windowing = true
235 vulkan_conf.set10('GST_VULKAN_HAVE_WINDOW_ANDROID', 1)
239 if not vulkan_windowing
240 warning('No Windowing system found. vulkansink will not work')
243 if not vulkan_dep.found() or not has_vulkan_header
244 if get_option('vulkan').enabled()
245 error('GStreamer Vulkan integration required via options, but needed dependencies not found.')
247 gstvulkan_dep = dependency('', required : false)
254 install_headers(vulkan_headers, subdir : 'gstreamer-1.0/gst/vulkan')
255 install_headers(vulkan_xcb_headers, subdir : 'gstreamer-1.0/gst/vulkan/xcb')
256 install_headers(vulkan_wayland_headers, subdir : 'gstreamer-1.0/gst/vulkan/wayland')
258 configure_file(input : 'gstvkconfig.h.meson',
259 output : 'gstvkconfig.h',
260 install_dir : join_paths(get_option('includedir'), 'gstreamer-1.0/gst/vulkan'),
261 configuration : vulkan_conf)
263 vulkan_enums = gnome.mkenums_simple('vulkan-enumtypes',
264 sources : vulkan_headers,
265 body_prefix : '#ifdef HAVE_CONFIG_H\n#include "config.h"\n#endif',
266 header_prefix : '#include <gst/vulkan/vulkan-prelude.h>',
267 decorator : 'GST_VULKAN_API',
268 install_header: true,
269 install_dir : join_paths(get_option('includedir'), 'gstreamer-1.0/gst/vulkan'))
270 vulkan_enumtypes_c = vulkan_enums[0]
271 vulkan_enumtypes_h = vulkan_enums[1]
272 gen_sources += [vulkan_enumtypes_h]
274 gstvulkan = library('gstvulkan-' + api_version,
275 vulkan_sources, vulkan_enumtypes_c, vulkan_enumtypes_h,
276 c_args : gst_plugins_bad_args + vulkan_defines + ['-DBUILDING_GST_VULKAN'],
277 objc_args : gst_plugins_bad_args + vulkan_defines + vulkan_objc_args + ['-DBUILDING_GST_VULKAN'],
278 include_directories : [configinc, libsinc],
279 version : libversion,
280 soversion : soversion,
281 darwin_versions : osxversion,
283 dependencies : [gstbase_dep, gstvideo_dep, vulkan_dep] + optional_deps)
286 extra_gir_includes = []
287 gobject_introspection_dep = dependency('gobject-introspection-1.0')
288 if gobject_introspection_dep.version().version_compare('>=1.61.1')
289 # This is the first version that contains Vulkan-1.0.gir
290 extra_gir_includes += ['Vulkan-1.0']
293 vulkan_gir = gnome.generate_gir(gstvulkan,
294 sources : vulkan_sources + vulkan_headers + [vulkan_enumtypes_h, vulkan_enumtypes_c],
295 namespace : 'GstVulkan',
296 nsversion : api_version,
297 identifier_prefix : 'Gst',
298 symbol_prefix : 'gst',
299 export_packages : 'gstreamer-vulkan-1.0',
300 includes : ['Gst-1.0', 'GstBase-1.0', 'GstVideo-1.0'] + extra_gir_includes,
302 extra_args : gir_init_section + ['--c-include=gst/vulkan/vulkan.h'],
303 dependencies : [gstvideo_dep, gst_dep, gstbase_dep] + optional_deps
305 gen_sources += vulkan_gir
308 gstvulkan_dep = declare_dependency(link_with : gstvulkan,
309 include_directories : [libsinc],
310 sources: gen_sources,
311 dependencies : [gstvideo_dep, gstbase_dep, vulkan_dep] + optional_deps)