diff --git a/meson.build b/meson.build index 59142c8a53b..1f3cb629a91 100644 --- a/meson.build +++ b/meson.build @@ -2304,6 +2304,13 @@ else vulkan_icd_lib_path = get_option('prefix') / get_option('libdir') endif +vulkan_manifest_per_architecture = get_option('vulkan-manifest-per-architecture') + +if vulkan_manifest_per_architecture + vulkan_manifest_suffix = '@0@.json'.format(host_machine.cpu()) +else + vulkan_manifest_suffix = 'json' +endif subdir('include') subdir('bin') diff --git a/meson.options b/meson.options index 75731475c12..5eed6c62a3d 100644 --- a/meson.options +++ b/meson.options @@ -286,6 +286,19 @@ option( 'Default: $datadir/vulkan/icd.d' ) +option( + 'vulkan-manifest-per-architecture', + type : 'boolean', + value : true, + description : 'If true, Vulkan ICDs have a separate JSON manifest per ' + + 'architecture, for example lvp_icd.x86_64.json. ' + + '(Recommended for non-default ${prefix}.) ' + + 'If false, all architectures share a single JSON manifest, ' + + 'for example lvp_icd.json, referencing the library by its ' + + 'basename. ' + + '(Recommended for Unix OS distros installing into /usr.)' +) + option( 'moltenvk-dir', type : 'string', diff --git a/src/amd/vulkan/meson.build b/src/amd/vulkan/meson.build index 8482848cff0..4ac7171e59e 100644 --- a/src/amd/vulkan/meson.build +++ b/src/amd/vulkan/meson.build @@ -283,7 +283,8 @@ icd_command = [ prog_python, '@INPUT0@', '--api-version', '1.4', '--xml', '@INPUT1@', '--sizeof-pointer', sizeof_pointer, - '--lib-path', vulkan_icd_lib_path / icd_file_name, + '--icd-lib-path', vulkan_icd_lib_path, + '--icd-filename', icd_file_name, '--out', '@OUTPUT@', ] if with_platform_windows @@ -293,7 +294,7 @@ endif radeon_icd = custom_target( 'radeon_icd', input : [vk_icd_gen, vk_api_xml], - output : 'radeon_icd.@0@.json'.format(host_machine.cpu()), + output : 'radeon_icd.' + vulkan_manifest_suffix, command : icd_command, build_by_default : true, install_dir : with_vulkan_icd_dir, @@ -310,7 +311,8 @@ _dev_icd = custom_target( prog_python, '@INPUT0@', '--api-version', '1.4', '--xml', '@INPUT1@', '--sizeof-pointer', sizeof_pointer, - '--lib-path', meson.current_build_dir() / icd_file_name, + '--icd-lib-path', meson.current_build_dir(), + '--icd-filename', icd_file_name, '--out', '@OUTPUT@', ], build_by_default : true, diff --git a/src/asahi/vulkan/meson.build b/src/asahi/vulkan/meson.build index 820ee2dc2da..a5e483cbcba 100644 --- a/src/asahi/vulkan/meson.build +++ b/src/asahi/vulkan/meson.build @@ -106,12 +106,13 @@ icd_file_name = libname_prefix + 'vulkan_asahi.' + libname_suffix asahi_icd = custom_target( input : [vk_icd_gen, vk_api_xml], - output : 'asahi_icd.@0@.json'.format(host_machine.cpu()), + output : 'asahi_icd.' + vulkan_manifest_suffix, command : [ prog_python, '@INPUT0@', '--api-version', '1.4', '--xml', '@INPUT1@', '--sizeof-pointer', sizeof_pointer, - '--lib-path', vulkan_icd_lib_path / icd_file_name, + '--icd-lib-path', vulkan_icd_lib_path, + '--icd-filename', icd_file_name, '--out', '@OUTPUT@', ], build_by_default : true, @@ -128,7 +129,8 @@ custom_target( prog_python, '@INPUT0@', '--api-version', '1.4', '--xml', '@INPUT1@', '--sizeof-pointer', sizeof_pointer, - '--lib-path', meson.current_build_dir() / icd_file_name, + '--icd-lib-path', meson.current_build_dir(), + '--icd-filename', icd_file_name, '--out', '@OUTPUT@', ], build_by_default : true, diff --git a/src/broadcom/vulkan/meson.build b/src/broadcom/vulkan/meson.build index 42c1e351ee3..d5cdbcd1ad5 100644 --- a/src/broadcom/vulkan/meson.build +++ b/src/broadcom/vulkan/meson.build @@ -127,12 +127,13 @@ icd_file_name = libname_prefix + 'vulkan_broadcom.' + libname_suffix broadcom_icd = custom_target( 'broadcom_icd', input : [vk_icd_gen, vk_api_xml], - output : 'broadcom_icd.@0@.json'.format(host_machine.cpu()), + output : 'broadcom_icd.' + vulkan_manifest_suffix, command : [ prog_python, '@INPUT0@', '--api-version', '1.3', '--xml', '@INPUT1@', '--sizeof-pointer', sizeof_pointer, - '--lib-path', vulkan_icd_lib_path / icd_file_name, + '--icd-lib-path', vulkan_icd_lib_path, + '--icd-filename', icd_file_name, '--out', '@OUTPUT@', ], build_by_default : true, @@ -150,7 +151,8 @@ _dev_icd = custom_target( prog_python, '@INPUT0@', '--api-version', '1.3', '--xml', '@INPUT1@', '--sizeof-pointer', sizeof_pointer, - '--lib-path', meson.current_build_dir() / icd_file_name, + '--icd-lib-path', meson.current_build_dir(), + '--icd-filename', icd_file_name, '--out', '@OUTPUT@', ], build_by_default : true, diff --git a/src/freedreno/vulkan/meson.build b/src/freedreno/vulkan/meson.build index 3c96a1ee4cf..278de60c90d 100644 --- a/src/freedreno/vulkan/meson.build +++ b/src/freedreno/vulkan/meson.build @@ -228,12 +228,13 @@ icd_file_name = libname_prefix + 'vulkan_freedreno.' + libname_suffix freedreno_icd = custom_target( 'freedreno_icd', input : [vk_icd_gen, vk_api_xml], - output : 'freedreno_icd.@0@.json'.format(host_machine.cpu()), + output : 'freedreno_icd.' + vulkan_manifest_suffix, command : [ prog_python, '@INPUT0@', '--api-version', '1.4', '--xml', '@INPUT1@', '--sizeof-pointer', sizeof_pointer, - '--lib-path', vulkan_icd_lib_path / icd_file_name, + '--icd-lib-path', vulkan_icd_lib_path, + '--icd-filename', icd_file_name, '--out', '@OUTPUT@', ], build_by_default : true, @@ -251,7 +252,8 @@ _dev_icd = custom_target( prog_python, '@INPUT0@', '--api-version', '1.4', '--xml', '@INPUT1@', '--sizeof-pointer', sizeof_pointer, - '--lib-path', meson.current_build_dir() / icd_file_name, + '--icd-lib-path', meson.current_build_dir(), + '--icd-filename', icd_file_name, '--out', '@OUTPUT@', ], build_by_default : true, diff --git a/src/gallium/targets/lavapipe/meson.build b/src/gallium/targets/lavapipe/meson.build index b79e3a4ca25..d1d4e5ba2b3 100644 --- a/src/gallium/targets/lavapipe/meson.build +++ b/src/gallium/targets/lavapipe/meson.build @@ -24,7 +24,8 @@ icd_command = [ prog_python, '@INPUT0@', '--api-version', '1.4', '--xml', '@INPUT1@', '--sizeof-pointer', sizeof_pointer, - '--lib-path', vulkan_icd_lib_path / icd_file_name, + '--icd-lib-path', vulkan_icd_lib_path, + '--icd-filename', icd_file_name, '--out', '@OUTPUT@', ] if host_machine.system() == 'windows' @@ -34,7 +35,7 @@ endif lvp_icd = custom_target( 'lvp_icd', input : [vk_icd_gen, vk_api_xml], - output : 'lvp_icd.@0@.json'.format(host_machine.cpu()), + output : 'lvp_icd.' + vulkan_manifest_suffix, command : icd_command, build_by_default : true, install_dir : with_vulkan_icd_dir, @@ -51,7 +52,8 @@ _dev_icd = custom_target( prog_python, '@INPUT0@', '--api-version', '1.4', '--xml', '@INPUT1@', '--sizeof-pointer', sizeof_pointer, - '--lib-path', meson.current_build_dir() / icd_file_name, + '--icd-lib-path', meson.current_build_dir(), + '--icd-filename', icd_file_name, '--out', '@OUTPUT@', ], build_by_default : true, diff --git a/src/gfxstream/guest/vulkan/meson.build b/src/gfxstream/guest/vulkan/meson.build index 75db10a5f51..e8cc28aff34 100644 --- a/src/gfxstream/guest/vulkan/meson.build +++ b/src/gfxstream/guest/vulkan/meson.build @@ -66,7 +66,7 @@ icd_file_name = libname_prefix + 'vulkan_gfxstream.' + libname_suffix gfxstream_icd = custom_target( 'gfxstream_vk_icd', input: [vk_icd_gen, vk_api_xml], - output: 'gfxstream_vk_icd.@0@.json'.format(host_machine.cpu()), + output : 'gfxstream_vk_icd.' + vulkan_manifest_suffix, command: [ prog_python, '@INPUT0@', @@ -76,8 +76,10 @@ gfxstream_icd = custom_target( '@INPUT1@', '--sizeof-pointer', sizeof_pointer, - '--lib-path', - vulkan_icd_lib_path / icd_file_name, + '--icd-lib-path', + vulkan_icd_lib_path, + '--icd-filename', + icd_file_name, '--out', '@OUTPUT@', ], @@ -100,8 +102,10 @@ _dev_icd = custom_target( '@INPUT1@', '--sizeof-pointer', sizeof_pointer, - '--lib-path', - meson.current_build_dir() / icd_file_name, + '--icd-lib-path', + meson.current_build_dir(), + '--icd-filename', + icd_file_name, '--out', '@OUTPUT@', ], diff --git a/src/imagination/vulkan/meson.build b/src/imagination/vulkan/meson.build index b44630b0852..1ff2f3ab4fd 100644 --- a/src/imagination/vulkan/meson.build +++ b/src/imagination/vulkan/meson.build @@ -144,12 +144,13 @@ icd_file_name = libname_prefix + 'vulkan_powervr_mesa.' + libname_suffix powervr_mesa_icd = custom_target( 'powervr_mesa_icd', input : [vk_icd_gen, vk_api_xml], - output : 'powervr_mesa_icd.@0@.json'.format(host_machine.cpu()), + output : 'powervr_mesa_icd.' + vulkan_manifest_suffix, command : [ prog_python, '@INPUT0@', '--api-version', '1.4', '--xml', '@INPUT1@', '--sizeof-pointer', sizeof_pointer, - '--lib-path', vulkan_icd_lib_path / icd_file_name, + '--icd-lib-path', vulkan_icd_lib_path, + '--icd-filename', icd_file_name, '--out', '@OUTPUT@', ], build_by_default : true, @@ -166,7 +167,8 @@ _dev_icd = custom_target( prog_python, '@INPUT0@', '--api-version', '1.4', '--xml', '@INPUT1@', '--sizeof-pointer', sizeof_pointer, - '--lib-path', meson.current_build_dir() / icd_file_name, + '--icd-lib-path', meson.current_build_dir(), + '--icd-filename', icd_file_name, '--out', '@OUTPUT@', ], build_by_default : true, diff --git a/src/intel/vulkan/meson.build b/src/intel/vulkan/meson.build index 907b0c4e7f1..a9640fdd0bd 100644 --- a/src/intel/vulkan/meson.build +++ b/src/intel/vulkan/meson.build @@ -50,12 +50,13 @@ icd_file_name = libname_prefix + 'vulkan_intel.' + libname_suffix intel_icd = custom_target( 'intel_icd', input : [vk_icd_gen, vk_api_xml], - output : 'intel_icd.@0@.json'.format(host_machine.cpu()), + output : 'intel_icd.' + vulkan_manifest_suffix, command : [ prog_python, '@INPUT0@', '--api-version', '1.4', '--xml', '@INPUT1@', '--sizeof-pointer', sizeof_pointer, - '--lib-path', vulkan_icd_lib_path / icd_file_name, + '--icd-lib-path', vulkan_icd_lib_path, + '--icd-filename', icd_file_name, '--out', '@OUTPUT@', ], build_by_default : true, @@ -73,7 +74,8 @@ _dev_icd = custom_target( prog_python, '@INPUT0@', '--api-version', '1.4', '--xml', '@INPUT1@', '--sizeof-pointer', sizeof_pointer, - '--lib-path', meson.current_build_dir() / icd_file_name, + '--icd-lib-path', meson.current_build_dir(), + '--icd-filename', icd_file_name, '--out', '@OUTPUT@', ], build_by_default : true, diff --git a/src/intel/vulkan_hasvk/meson.build b/src/intel/vulkan_hasvk/meson.build index ed5ac746355..ea1763429cb 100644 --- a/src/intel/vulkan_hasvk/meson.build +++ b/src/intel/vulkan_hasvk/meson.build @@ -21,12 +21,13 @@ icd_file_name = libname_prefix + 'vulkan_intel_hasvk.' + libname_suffix intel_hasvk_icd = custom_target( 'intel_hasvk_icd', input : [vk_icd_gen, vk_api_xml], - output : 'intel_hasvk_icd.@0@.json'.format(host_machine.cpu()), + output : 'intel_hasvk_icd.' + vulkan_manifest_suffix, command : [ prog_python, '@INPUT0@', '--api-version', '1.3', '--xml', '@INPUT1@', '--sizeof-pointer', sizeof_pointer, - '--lib-path', vulkan_icd_lib_path / icd_file_name, + '--icd-lib-path', vulkan_icd_lib_path, + '--icd-filename', icd_file_name, '--out', '@OUTPUT@', ], build_by_default : true, @@ -44,7 +45,8 @@ _dev_icd = custom_target( prog_python, '@INPUT0@', '--api-version', '1.3', '--xml', '@INPUT1@', '--sizeof-pointer', sizeof_pointer, - '--lib-path', meson.current_build_dir() / icd_file_name, + '--icd-lib-path', meson.current_build_dir(), + '--icd-filename', icd_file_name, '--out', '@OUTPUT@', ], build_by_default : true, diff --git a/src/kosmickrisp/vulkan/meson.build b/src/kosmickrisp/vulkan/meson.build index 41cfa8a6fec..8b7271424d1 100644 --- a/src/kosmickrisp/vulkan/meson.build +++ b/src/kosmickrisp/vulkan/meson.build @@ -177,14 +177,17 @@ libvulkan_kosmickrisp = shared_library( install : true, ) +icd_file_name = libname_prefix + 'vulkan_kosmickrisp.' + libname_suffix + kosmickrisp_mesa_icd = custom_target( 'kosmickrisp_mesa_icd', input : [vk_icd_gen, vk_api_xml], - output : 'kosmickrisp_mesa_icd.@0@.json'.format(host_machine.cpu()), + output : 'kosmickrisp_mesa_icd.' + vulkan_manifest_suffix, command : [ prog_python, '@INPUT0@', '--api-version', '1.3', '--xml', '@INPUT1@', - '--lib-path', get_option('prefix') / get_option('libdir') / 'libvulkan_kosmickrisp.dylib', + '--icd-lib-path', vulkan_icd_lib_path, + '--icd-filename', icd_file_name, '--out', '@OUTPUT@', ], build_by_default : true, @@ -200,7 +203,8 @@ kosmickrisp_icd = custom_target( command : [ prog_python, '@INPUT0@', '--api-version', '1.3', '--xml', '@INPUT1@', - '--lib-path', meson.current_build_dir() / 'libvulkan_kosmickrisp.dylib', + '--icd-lib-path', meson.current_build_dir(), + '--icd-filename', icd_file_name, '--out', '@OUTPUT@', ], build_by_default : true, diff --git a/src/microsoft/vulkan/meson.build b/src/microsoft/vulkan/meson.build index 0349d2ddc4e..99239a3e95b 100644 --- a/src/microsoft/vulkan/meson.build +++ b/src/microsoft/vulkan/meson.build @@ -80,7 +80,8 @@ icd_command = [ prog_python, '@INPUT0@', '--api-version', '1.1', '--xml', '@INPUT1@', '--sizeof-pointer', sizeof_pointer, - '--lib-path', vulkan_icd_lib_path / icd_file_name, + '--icd-lib-path', vulkan_icd_lib_path, + '--icd-filename', icd_file_name, '--out', '@OUTPUT@', ] @@ -88,7 +89,8 @@ icd_dev_command = [ prog_python, '@INPUT0@', '--api-version', '1.1', '--xml', '@INPUT1@', '--sizeof-pointer', sizeof_pointer, - '--lib-path', join_paths(meson.current_build_dir(), icd_file_name), + '--icd-lib-path', meson.current_build_dir(), + '--icd-filename', icd_file_name, '--out', '@OUTPUT@', ] @@ -100,7 +102,7 @@ endif dzn_icd = custom_target( 'dzn_icd', input : [vk_icd_gen, vk_api_xml], - output : 'dzn_icd.@0@.json'.format(host_machine.cpu()), + output : 'dzn_icd.' + vulkan_manifest_suffix, command : icd_command, build_by_default : true, install_dir : with_vulkan_icd_dir, diff --git a/src/nouveau/vulkan/meson.build b/src/nouveau/vulkan/meson.build index 0be5fed1b4b..e7c81209ad1 100644 --- a/src/nouveau/vulkan/meson.build +++ b/src/nouveau/vulkan/meson.build @@ -164,12 +164,13 @@ icd_file_name = libname_prefix + 'vulkan_nouveau.' + libname_suffix nouveau_icd = custom_target( 'nouveau_icd', input : [vk_icd_gen, vk_api_xml], - output : 'nouveau_icd.@0@.json'.format(host_machine.cpu()), + output : 'nouveau_icd.' + vulkan_manifest_suffix, command : [ prog_python, '@INPUT0@', '--api-version', '1.4', '--xml', '@INPUT1@', '--sizeof-pointer', sizeof_pointer, - '--lib-path', vulkan_icd_lib_path / icd_file_name, + '--icd-lib-path', vulkan_icd_lib_path, + '--icd-filename', icd_file_name, '--out', '@OUTPUT@', ], build_by_default : true, @@ -187,7 +188,8 @@ custom_target( prog_python, '@INPUT0@', '--api-version', '1.4', '--xml', '@INPUT1@', '--sizeof-pointer', sizeof_pointer, - '--lib-path', meson.current_build_dir() / icd_file_name, + '--icd-lib-path', meson.current_build_dir(), + '--icd-filename', icd_file_name, '--out', '@OUTPUT@', ], build_by_default : true, diff --git a/src/panfrost/vulkan/meson.build b/src/panfrost/vulkan/meson.build index 0f224db2464..e8ca0510d47 100644 --- a/src/panfrost/vulkan/meson.build +++ b/src/panfrost/vulkan/meson.build @@ -241,12 +241,13 @@ icd_file_name = libname_prefix + 'vulkan_panfrost.' + libname_suffix panfrost_icd = custom_target( 'panfrost_icd', input : [vk_icd_gen, vk_api_xml], - output : 'panfrost_icd.@0@.json'.format(host_machine.cpu()), + output : 'panfrost_icd.' + vulkan_manifest_suffix, command : [ prog_python, '@INPUT0@', '--api-version', '1.4', '--xml', '@INPUT1@', '--sizeof-pointer', sizeof_pointer, - '--lib-path', vulkan_icd_lib_path / icd_file_name, + '--icd-lib-path', vulkan_icd_lib_path, + '--icd-filename', icd_file_name, '--out', '@OUTPUT@', ], build_by_default : true, @@ -264,7 +265,8 @@ _dev_icd = custom_target( prog_python, '@INPUT0@', '--api-version', '1.4', '--xml', '@INPUT1@', '--sizeof-pointer', sizeof_pointer, - '--lib-path', meson.current_build_dir() / icd_file_name, + '--icd-lib-path', meson.current_build_dir(), + '--icd-filename', icd_file_name, '--out', '@OUTPUT@', ], build_by_default : true, diff --git a/src/virtio/vulkan/meson.build b/src/virtio/vulkan/meson.build index e41faf685f3..2ad2b6ff105 100644 --- a/src/virtio/vulkan/meson.build +++ b/src/virtio/vulkan/meson.build @@ -20,12 +20,13 @@ icd_file_name = libname_prefix + 'vulkan_virtio.' + libname_suffix virtio_icd = custom_target( 'virtio_icd', input : [vk_icd_gen, vk_api_xml], - output : 'virtio_icd.@0@.json'.format(host_machine.cpu()), + output : 'virtio_icd.' + vulkan_manifest_suffix, command : [ prog_python, '@INPUT0@', '--api-version', '1.4', '--xml', '@INPUT1@', '--sizeof-pointer', sizeof_pointer, - '--lib-path', vulkan_icd_lib_path / icd_file_name, + '--icd-lib-path', vulkan_icd_lib_path, + '--icd-filename', icd_file_name, '--out', '@OUTPUT@', ], build_by_default : true, @@ -43,7 +44,8 @@ _dev_icd = custom_target( prog_python, '@INPUT0@', '--api-version', '1.4', '--xml', '@INPUT1@', '--sizeof-pointer', sizeof_pointer, - '--lib-path', meson.current_build_dir() / icd_file_name, + '--icd-lib-path', meson.current_build_dir(), + '--icd-filename', icd_file_name, '--out', '@OUTPUT@', ], build_by_default : true, diff --git a/src/vulkan/util/vk_icd_gen.py b/src/vulkan/util/vk_icd_gen.py index 7760dd6b047..d5fb0f07dd5 100644 --- a/src/vulkan/util/vk_icd_gen.py +++ b/src/vulkan/util/vk_icd_gen.py @@ -22,6 +22,7 @@ import argparse import json +import os import re import xml.etree.ElementTree as et @@ -48,8 +49,10 @@ if __name__ == '__main__': help='Vulkan registry XML for patch version') parser.add_argument('--sizeof-pointer', required=False, type=int, help='sizeof(void*) on the host cpu') - parser.add_argument('--lib-path', required=True, - help='Path to installed library') + parser.add_argument('--icd-lib-path', required=True, + help='Folder of icd lib_path to installed library') + parser.add_argument('--icd-filename', required=True, + help='Filename of icd lib_path to installed library') parser.add_argument('--out', required=False, help='Output json file.') parser.add_argument('--use-backslash', action='store_true', @@ -63,7 +66,12 @@ if __name__ == '__main__': else: re.match(r'\d+\.\d+\.\d+', version) - lib_path = args.lib_path + lib_path = args.icd_filename + if args.out and len(os.path.basename(args.out).split('.')) == 3: + # The output filename is the form of '${icd_id}.${host_machine.cpu()}.json', + # that means vulkan_manifest_per_architecture are true. + lib_path = args.icd_lib_path + '/' + args.icd_filename + if args.use_backslash: lib_path = lib_path.replace('/', '\\')