101e04c3fSmrg# Copyright © 2017 Intel Corporation
201e04c3fSmrg
301e04c3fSmrg# Permission is hereby granted, free of charge, to any person obtaining a copy
401e04c3fSmrg# of this software and associated documentation files (the "Software"), to deal
501e04c3fSmrg# in the Software without restriction, including without limitation the rights
601e04c3fSmrg# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
701e04c3fSmrg# copies of the Software, and to permit persons to whom the Software is
801e04c3fSmrg# furnished to do so, subject to the following conditions:
901e04c3fSmrg
1001e04c3fSmrg# The above copyright notice and this permission notice shall be included in
1101e04c3fSmrg# all copies or substantial portions of the Software.
1201e04c3fSmrg
1301e04c3fSmrg# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1401e04c3fSmrg# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1501e04c3fSmrg# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1601e04c3fSmrg# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1701e04c3fSmrg# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1801e04c3fSmrg# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1901e04c3fSmrg# SOFTWARE.
2001e04c3fSmrg
217ec681f3Smrg# Mesa-local imports in the Python files must be declared here for correct
227ec681f3Smrg# dependency tracking.
237ec681f3Smrgvk_extensions_depend_files = [
247ec681f3Smrg]
257ec681f3Smrgvk_extensions_gen_depend_files = [
267ec681f3Smrg  files('vk_extensions.py'),
277ec681f3Smrg  vk_extensions_depend_files,
287ec681f3Smrg]
297ec681f3Smrgvk_dispatch_table_gen_depend_files = [
307ec681f3Smrg  files('vk_extensions.py'),
317ec681f3Smrg  vk_extensions_depend_files,
327ec681f3Smrg]
337ec681f3Smrgvk_entrypoints_gen_depend_files = [
347ec681f3Smrg  files('vk_dispatch_table_gen.py'),
357ec681f3Smrg  vk_dispatch_table_gen_depend_files,
367ec681f3Smrg]
377ec681f3Smrgvk_cmd_queue_gen_depend_files = [
387ec681f3Smrg  files('vk_dispatch_table_gen.py'),
397ec681f3Smrg  vk_dispatch_table_gen_depend_files,
407ec681f3Smrg]
417ec681f3Smrgvk_commands_gen_depend_files = [
427ec681f3Smrg  files('vk_dispatch_table_gen.py'),
437ec681f3Smrg  vk_dispatch_table_gen_depend_files,
447ec681f3Smrg]
457ec681f3Smrgvk_physical_device_features_gen_depend_files = [
467ec681f3Smrg]
477ec681f3Smrg
487ec681f3Smrgvk_entrypoints_gen = files('vk_entrypoints_gen.py')
497ec681f3Smrgvk_extensions_gen = files('vk_extensions_gen.py')
507ec681f3Smrgvk_icd_gen = files('vk_icd_gen.py')
517ec681f3Smrgvk_commands_gen = files('vk_commands_gen.py')
527ec681f3Smrg
5301e04c3fSmrgfiles_vulkan_util = files(
547ec681f3Smrg  'vk_alloc.c',
5501e04c3fSmrg  'vk_alloc.h',
567ec681f3Smrg  'vk_cmd_copy.c',
577ec681f3Smrg  'vk_command_buffer.c',
587ec681f3Smrg  'vk_command_buffer.h',
5901e04c3fSmrg  'vk_debug_report.c',
6001e04c3fSmrg  'vk_debug_report.h',
617ec681f3Smrg  'vk_debug_utils.c',
627ec681f3Smrg  'vk_debug_utils.h',
637ec681f3Smrg  'vk_deferred_operation.c',
647ec681f3Smrg  'vk_deferred_operation.h',
657ec681f3Smrg  'vk_descriptors.c',
667ec681f3Smrg  'vk_descriptors.h',
677ec681f3Smrg  'vk_device.c',
687ec681f3Smrg  'vk_device.h',
697ec681f3Smrg  'vk_format.c',
707ec681f3Smrg  'vk_image.c',
717ec681f3Smrg  'vk_image.h',
727ec681f3Smrg  'vk_instance.c',
737ec681f3Smrg  'vk_instance.h',
747ec681f3Smrg  'vk_log.c',
757ec681f3Smrg  'vk_log.h',
767ec681f3Smrg  'vk_object.c',
777ec681f3Smrg  'vk_object.h',
787ec681f3Smrg  'vk_physical_device.c',
797ec681f3Smrg  'vk_physical_device.h',
807ec681f3Smrg  'vk_queue.c',
817ec681f3Smrg  'vk_queue.h',
827ec681f3Smrg  'vk_render_pass.c',
837ec681f3Smrg  'vk_shader_module.c',
847ec681f3Smrg  'vk_shader_module.h',
857ec681f3Smrg  'vk_synchronization2.c',
8601e04c3fSmrg  'vk_util.c',
8701e04c3fSmrg  'vk_util.h',
8801e04c3fSmrg)
8901e04c3fSmrg
907ec681f3Smrgvk_common_entrypoints = custom_target(
917ec681f3Smrg  'vk_common_entrypoints',
927ec681f3Smrg  input : [vk_entrypoints_gen, vk_api_xml],
937ec681f3Smrg  output : ['vk_common_entrypoints.h', 'vk_common_entrypoints.c'],
947ec681f3Smrg  command : [
957ec681f3Smrg    prog_python, '@INPUT0@', '--xml', '@INPUT1@', '--proto', '--weak',
967ec681f3Smrg    '--out-h', '@OUTPUT0@', '--out-c', '@OUTPUT1@', '--prefix', 'vk_common',
977ec681f3Smrg  ],
987ec681f3Smrg  depend_files : vk_entrypoints_gen_depend_files,
997ec681f3Smrg)
1007ec681f3Smrg
1017ec681f3Smrgvk_dispatch_table = custom_target(
1027ec681f3Smrg  'vk_dispatch_table',
1037ec681f3Smrg  input : ['vk_dispatch_table_gen.py', vk_api_xml],
1047ec681f3Smrg  output : ['vk_dispatch_table.c', 'vk_dispatch_table.h'],
1057ec681f3Smrg  command : [
1067ec681f3Smrg    prog_python, '@INPUT0@', '--xml', '@INPUT1@',
1077ec681f3Smrg    '--out-c', '@OUTPUT0@', '--out-h', '@OUTPUT1@'
1087ec681f3Smrg  ],
1097ec681f3Smrg  depend_files : vk_dispatch_table_gen_depend_files,
1107ec681f3Smrg)
1117ec681f3Smrg
11201e04c3fSmrgvk_enum_to_str = custom_target(
11301e04c3fSmrg  'vk_enum_to_str',
1148a1362adSmaya  input : ['gen_enum_to_str.py', vk_api_xml],
1157ec681f3Smrg  output : ['vk_enum_to_str.c', 'vk_enum_to_str.h', 'vk_enum_defines.h'],
11601e04c3fSmrg  command : [
1178a1362adSmaya    prog_python, '@INPUT0@', '--xml', '@INPUT1@',
1188a1362adSmaya    '--outdir', meson.current_build_dir()
11901e04c3fSmrg  ],
12001e04c3fSmrg)
12101e04c3fSmrg
1227ec681f3Smrgvk_extensions = custom_target(
1237ec681f3Smrg  'vk_extensions',
1247ec681f3Smrg  input : ['vk_extensions_gen.py', vk_api_xml],
1257ec681f3Smrg  output : ['vk_extensions.c', 'vk_extensions.h'],
1267ec681f3Smrg  command : [
1277ec681f3Smrg    prog_python, '@INPUT0@', '--xml', '@INPUT1@',
1287ec681f3Smrg    '--out-c', '@OUTPUT0@', '--out-h', '@OUTPUT1@'
1297ec681f3Smrg  ],
1307ec681f3Smrg  depend_files : vk_extensions_gen_depend_files,
1317ec681f3Smrg)
1327ec681f3Smrg
1337ec681f3Smrgvk_cmd_queue = custom_target(
1347ec681f3Smrg  'vk_cmd_queue',
1357ec681f3Smrg  input : ['vk_cmd_queue_gen.py', vk_api_xml],
1367ec681f3Smrg  output : ['vk_cmd_queue.c', 'vk_cmd_queue.h'],
1377ec681f3Smrg  command : [
1387ec681f3Smrg    prog_python, '@INPUT0@', '--xml', '@INPUT1@',
1397ec681f3Smrg    '--out-c', '@OUTPUT0@', '--out-h', '@OUTPUT1@'
1407ec681f3Smrg  ],
1417ec681f3Smrg  depend_files : vk_cmd_queue_gen_depend_files,
1427ec681f3Smrg)
1437ec681f3Smrg
1447ec681f3Smrgvk_physical_device_features = custom_target(
1457ec681f3Smrg  'vk_physical_device_features',
1467ec681f3Smrg  input : ['vk_physical_device_features.py', vk_api_xml],
1477ec681f3Smrg  output : ['vk_physical_device_features.c'],
1487ec681f3Smrg  command : [
1497ec681f3Smrg    prog_python, '@INPUT0@', '--xml', '@INPUT1@',
1507ec681f3Smrg    '--out-c', '@OUTPUT0@'
1517ec681f3Smrg  ],
1527ec681f3Smrg  depend_files : vk_physical_device_features_gen_depend_files,
1537ec681f3Smrg)
1547ec681f3Smrg
15501e04c3fSmrglibvulkan_util = static_library(
15601e04c3fSmrg  'vulkan_util',
1577ec681f3Smrg  [files_vulkan_util, vk_common_entrypoints, vk_dispatch_table,
1587ec681f3Smrg   vk_enum_to_str, vk_extensions, vk_cmd_queue, vk_physical_device_features],
1597ec681f3Smrg  include_directories : [inc_include, inc_src, inc_gallium],
1607ec681f3Smrg  dependencies : [vulkan_wsi_deps, idep_mesautil, idep_nir_headers],
1617ec681f3Smrg  # For glsl_type_singleton
1627ec681f3Smrg  link_with : libcompiler,
1637ec681f3Smrg  c_args : [vulkan_wsi_args],
1647ec681f3Smrg  gnu_symbol_visibility : 'hidden',
16501e04c3fSmrg  build_by_default : false,
16601e04c3fSmrg)
1678a1362adSmaya
1688a1362adSmayaidep_vulkan_util_headers = declare_dependency(
1697ec681f3Smrg  sources : [vk_dispatch_table[1], vk_enum_to_str[1], vk_extensions[1]],
1708a1362adSmaya  include_directories : include_directories('.')
1718a1362adSmaya)
1728a1362adSmaya
1737ec681f3Smrg# This is likely a bug in the Meson VS backend, as MSVC with ninja works fine.
1747ec681f3Smrg# See this discussion here:
1757ec681f3Smrg# https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10506
1767ec681f3Smrgif get_option('backend').startswith('vs')
1777ec681f3Smrg  idep_vulkan_util = declare_dependency(
1787ec681f3Smrg    link_with : libvulkan_util,
1797ec681f3Smrg    dependencies : idep_vulkan_util_headers
1807ec681f3Smrg  )
1817ec681f3Smrgelse
1827ec681f3Smrg  idep_vulkan_util = declare_dependency(
1837ec681f3Smrg    # Instruct users of this library to link with --whole-archive.  Otherwise,
1847ec681f3Smrg    # our weak function overloads may not resolve properly.
1857ec681f3Smrg    link_whole : libvulkan_util,
1867ec681f3Smrg    dependencies : idep_vulkan_util_headers
1877ec681f3Smrg  )
1887ec681f3Smrgendif
189