From f7aa6ba9064f64885a2ae24af8d51c7671d20b6d Mon Sep 17 00:00:00 2001 From: Mel Henning Date: Mon, 16 Jun 2025 20:04:11 -0400 Subject: [PATCH] vulkan: Specify library_arch in ICD files This should help vk-icd-loader skip libraries of the wrong bit width. Reviewed-by: Eric Engestrom Acked-by: Alyssa Rosenzweig Acked-by: Samuel Pitoiset Acked-by: Jesse Natalie Part-of: --- src/amd/vulkan/meson.build | 2 ++ src/asahi/vulkan/meson.build | 2 ++ src/broadcom/vulkan/meson.build | 2 ++ src/freedreno/vulkan/meson.build | 2 ++ src/gallium/targets/lavapipe/meson.build | 2 ++ src/gfxstream/guest/vulkan/meson.build | 2 ++ src/imagination/vulkan/meson.build | 2 ++ src/intel/vulkan/meson.build | 2 ++ src/intel/vulkan_hasvk/meson.build | 2 ++ src/microsoft/vulkan/meson.build | 2 ++ src/nouveau/vulkan/meson.build | 2 ++ src/panfrost/vulkan/meson.build | 2 ++ src/virtio/vulkan/meson.build | 2 ++ src/vulkan/util/vk_icd_gen.py | 9 ++++++++- 14 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/amd/vulkan/meson.build b/src/amd/vulkan/meson.build index af69d1a4a49..0187050f0be 100644 --- a/src/amd/vulkan/meson.build +++ b/src/amd/vulkan/meson.build @@ -280,6 +280,7 @@ endif icd_command = [ prog_python, '@INPUT0@', '--api-version', '1.4', '--xml', '@INPUT1@', + '--sizeof-pointer', sizeof_pointer, '--lib-path', join_paths(icd_lib_path, icd_file_name), '--out', '@OUTPUT@', ] @@ -306,6 +307,7 @@ _dev_icd = custom_target( command : [ prog_python, '@INPUT0@', '--api-version', '1.4', '--xml', '@INPUT1@', + '--sizeof-pointer', sizeof_pointer, '--lib-path', meson.current_build_dir() / icd_file_name, '--out', '@OUTPUT@', ], diff --git a/src/asahi/vulkan/meson.build b/src/asahi/vulkan/meson.build index c24c05014e1..f2709694ac4 100644 --- a/src/asahi/vulkan/meson.build +++ b/src/asahi/vulkan/meson.build @@ -115,6 +115,7 @@ asahi_icd = custom_target( command : [ prog_python, '@INPUT0@', '--api-version', '1.4', '--xml', '@INPUT1@', + '--sizeof-pointer', sizeof_pointer, '--lib-path', join_paths(icd_lib_path, icd_file_name), '--out', '@OUTPUT@', ], @@ -131,6 +132,7 @@ custom_target( command : [ prog_python, '@INPUT0@', '--api-version', '1.4', '--xml', '@INPUT1@', + '--sizeof-pointer', sizeof_pointer, '--lib-path', meson.current_build_dir() / icd_file_name, '--out', '@OUTPUT@', ], diff --git a/src/broadcom/vulkan/meson.build b/src/broadcom/vulkan/meson.build index 5ce5be0fd84..503bcd26f84 100644 --- a/src/broadcom/vulkan/meson.build +++ b/src/broadcom/vulkan/meson.build @@ -130,6 +130,7 @@ broadcom_icd = custom_target( command : [ prog_python, '@INPUT0@', '--api-version', '1.3', '--xml', '@INPUT1@', + '--sizeof-pointer', sizeof_pointer, '--lib-path', join_paths(get_option('prefix'), get_option('libdir'), 'libvulkan_broadcom.so'), '--out', '@OUTPUT@', @@ -148,6 +149,7 @@ _dev_icd = custom_target( command : [ prog_python, '@INPUT0@', '--api-version', '1.3', '--xml', '@INPUT1@', + '--sizeof-pointer', sizeof_pointer, '--lib-path', meson.current_build_dir() / 'libvulkan_broadcom.so', '--out', '@OUTPUT@', ], diff --git a/src/freedreno/vulkan/meson.build b/src/freedreno/vulkan/meson.build index d107cf2f2f1..faccd55f0da 100644 --- a/src/freedreno/vulkan/meson.build +++ b/src/freedreno/vulkan/meson.build @@ -201,6 +201,7 @@ freedreno_icd = custom_target( command : [ prog_python, '@INPUT0@', '--api-version', '1.4', '--xml', '@INPUT1@', + '--sizeof-pointer', sizeof_pointer, '--lib-path', join_paths(get_option('prefix'), get_option('libdir'), 'libvulkan_freedreno.so'), '--out', '@OUTPUT@', @@ -219,6 +220,7 @@ _dev_icd = custom_target( command : [ prog_python, '@INPUT0@', '--api-version', '1.4', '--xml', '@INPUT1@', + '--sizeof-pointer', sizeof_pointer, '--lib-path', meson.current_build_dir() / 'libvulkan_freedreno.so', '--out', '@OUTPUT@', ], diff --git a/src/gallium/targets/lavapipe/meson.build b/src/gallium/targets/lavapipe/meson.build index 08da3c084d1..25f0eb93c57 100644 --- a/src/gallium/targets/lavapipe/meson.build +++ b/src/gallium/targets/lavapipe/meson.build @@ -29,6 +29,7 @@ endif icd_command = [ prog_python, '@INPUT0@', '--api-version', '1.4', '--xml', '@INPUT1@', + '--sizeof-pointer', sizeof_pointer, '--lib-path', join_paths(icd_lib_path, icd_file_name), '--out', '@OUTPUT@', ] @@ -55,6 +56,7 @@ _dev_icd = custom_target( command : [ prog_python, '@INPUT0@', '--api-version', '1.4', '--xml', '@INPUT1@', + '--sizeof-pointer', sizeof_pointer, '--lib-path', meson.current_build_dir() / icd_file_name, '--out', '@OUTPUT@', ], diff --git a/src/gfxstream/guest/vulkan/meson.build b/src/gfxstream/guest/vulkan/meson.build index c6467ae3bf0..f76199242a3 100644 --- a/src/gfxstream/guest/vulkan/meson.build +++ b/src/gfxstream/guest/vulkan/meson.build @@ -45,6 +45,7 @@ gfxstream_icd = custom_target( command : [ prog_python, '@INPUT0@', '--api-version', '1.1', '--xml', '@INPUT1@', + '--sizeof-pointer', sizeof_pointer, '--lib-path', join_paths(get_option('prefix'), get_option('libdir'), 'libvulkan_gfxstream.so'), '--out', '@OUTPUT@', @@ -62,6 +63,7 @@ _dev_icd = custom_target( command : [ prog_python, '@INPUT0@', '--api-version', '1.3', '--xml', '@INPUT1@', + '--sizeof-pointer', sizeof_pointer, '--lib-path', meson.current_build_dir() / 'libvulkan_gfxstream.so', '--out', '@OUTPUT@', ], diff --git a/src/imagination/vulkan/meson.build b/src/imagination/vulkan/meson.build index 97073f0fe51..fa860e6826a 100644 --- a/src/imagination/vulkan/meson.build +++ b/src/imagination/vulkan/meson.build @@ -146,6 +146,7 @@ powervr_mesa_icd = custom_target( command : [ prog_python, '@INPUT0@', '--api-version', '1.0', '--xml', '@INPUT1@', + '--sizeof-pointer', sizeof_pointer, '--lib-path', get_option('prefix') / get_option('libdir') / 'libvulkan_powervr_mesa.so', '--out', '@OUTPUT@', ], @@ -162,6 +163,7 @@ _dev_icd = custom_target( command : [ prog_python, '@INPUT0@', '--api-version', '1.0', '--xml', '@INPUT1@', + '--sizeof-pointer', sizeof_pointer, '--lib-path', meson.current_build_dir() / 'libvulkan_powervr_mesa.so', '--out', '@OUTPUT@', ], diff --git a/src/intel/vulkan/meson.build b/src/intel/vulkan/meson.build index f2d1d0fbca7..f0e08762a04 100644 --- a/src/intel/vulkan/meson.build +++ b/src/intel/vulkan/meson.build @@ -52,6 +52,7 @@ intel_icd = custom_target( command : [ prog_python, '@INPUT0@', '--api-version', '1.4', '--xml', '@INPUT1@', + '--sizeof-pointer', sizeof_pointer, '--lib-path', join_paths(get_option('prefix'), get_option('libdir'), 'libvulkan_intel.so'), '--out', '@OUTPUT@', @@ -70,6 +71,7 @@ _dev_icd = custom_target( command : [ prog_python, '@INPUT0@', '--api-version', '1.4', '--xml', '@INPUT1@', + '--sizeof-pointer', sizeof_pointer, '--lib-path', meson.current_build_dir() / 'libvulkan_intel.so', '--out', '@OUTPUT@', ], diff --git a/src/intel/vulkan_hasvk/meson.build b/src/intel/vulkan_hasvk/meson.build index 5b46c44a9db..46b856633de 100644 --- a/src/intel/vulkan_hasvk/meson.build +++ b/src/intel/vulkan_hasvk/meson.build @@ -23,6 +23,7 @@ intel_hasvk_icd = custom_target( command : [ prog_python, '@INPUT0@', '--api-version', '1.3', '--xml', '@INPUT1@', + '--sizeof-pointer', sizeof_pointer, '--lib-path', join_paths(get_option('prefix'), get_option('libdir'), 'libvulkan_intel_hasvk.so'), '--out', '@OUTPUT@', @@ -41,6 +42,7 @@ _dev_icd = custom_target( command : [ prog_python, '@INPUT0@', '--api-version', '1.3', '--xml', '@INPUT1@', + '--sizeof-pointer', sizeof_pointer, '--lib-path', meson.current_build_dir() / 'libvulkan_intel_hasvk.so', '--out', '@OUTPUT@', ], diff --git a/src/microsoft/vulkan/meson.build b/src/microsoft/vulkan/meson.build index 4e05600be8b..c6ed8b9f6b7 100644 --- a/src/microsoft/vulkan/meson.build +++ b/src/microsoft/vulkan/meson.build @@ -85,6 +85,7 @@ endif icd_command = [ prog_python, '@INPUT0@', '--api-version', '1.1', '--xml', '@INPUT1@', + '--sizeof-pointer', sizeof_pointer, '--lib-path', join_paths(icd_lib_path, icd_file_name), '--out', '@OUTPUT@', ] @@ -92,6 +93,7 @@ icd_command = [ 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), '--out', '@OUTPUT@', ] diff --git a/src/nouveau/vulkan/meson.build b/src/nouveau/vulkan/meson.build index de9c786914d..afdaffc9b6f 100644 --- a/src/nouveau/vulkan/meson.build +++ b/src/nouveau/vulkan/meson.build @@ -179,6 +179,7 @@ nouveau_icd = custom_target( command : [ prog_python, '@INPUT0@', '--api-version', '1.4', '--xml', '@INPUT1@', + '--sizeof-pointer', sizeof_pointer, '--lib-path', join_paths(icd_lib_path, icd_file_name), '--out', '@OUTPUT@', ], @@ -196,6 +197,7 @@ custom_target( command : [ prog_python, '@INPUT0@', '--api-version', '1.4', '--xml', '@INPUT1@', + '--sizeof-pointer', sizeof_pointer, '--lib-path', meson.current_build_dir() / icd_file_name, '--out', '@OUTPUT@', ], diff --git a/src/panfrost/vulkan/meson.build b/src/panfrost/vulkan/meson.build index bf003c29c03..cd29b90a602 100644 --- a/src/panfrost/vulkan/meson.build +++ b/src/panfrost/vulkan/meson.build @@ -221,6 +221,7 @@ panfrost_icd = custom_target( command : [ prog_python, '@INPUT0@', '--api-version', '1.4', '--xml', '@INPUT1@', + '--sizeof-pointer', sizeof_pointer, '--lib-path', join_paths(get_option('prefix'), get_option('libdir'), 'libvulkan_panfrost.so'), '--out', '@OUTPUT@', @@ -239,6 +240,7 @@ _dev_icd = custom_target( command : [ prog_python, '@INPUT0@', '--api-version', '1.4', '--xml', '@INPUT1@', + '--sizeof-pointer', sizeof_pointer, '--lib-path', meson.current_build_dir() / 'libvulkan_panfrost.so', '--out', '@OUTPUT@', ], diff --git a/src/virtio/vulkan/meson.build b/src/virtio/vulkan/meson.build index 667e03fa13d..be864d41977 100644 --- a/src/virtio/vulkan/meson.build +++ b/src/virtio/vulkan/meson.build @@ -22,6 +22,7 @@ virtio_icd = custom_target( command : [ prog_python, '@INPUT0@', '--api-version', '1.3', '--xml', '@INPUT1@', + '--sizeof-pointer', sizeof_pointer, '--lib-path', join_paths(get_option('prefix'), get_option('libdir'), 'libvulkan_virtio.so'), '--out', '@OUTPUT@', @@ -40,6 +41,7 @@ _dev_icd = custom_target( command : [ prog_python, '@INPUT0@', '--api-version', '1.3', '--xml', '@INPUT1@', + '--sizeof-pointer', sizeof_pointer, '--lib-path', meson.current_build_dir() / 'libvulkan_virtio.so', '--out', '@OUTPUT@', ], diff --git a/src/vulkan/util/vk_icd_gen.py b/src/vulkan/util/vk_icd_gen.py index 5cdf6728205..15adf5f6d8a 100644 --- a/src/vulkan/util/vk_icd_gen.py +++ b/src/vulkan/util/vk_icd_gen.py @@ -46,6 +46,8 @@ if __name__ == '__main__': help='Vulkan API version.') parser.add_argument('--xml', required=False, 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('--out', required=False, @@ -66,13 +68,18 @@ if __name__ == '__main__': lib_path = lib_path.replace('/', '\\') json_data = { - 'file_format_version': '1.0.0', + 'file_format_version': '1.0.1', 'ICD': { 'library_path': lib_path, 'api_version': version, }, } + if args.sizeof_pointer: + bit_width = args.sizeof_pointer * 8 + if bit_width in [32, 64]: + json_data['ICD']['library_arch'] = str(bit_width) + json_params = { 'indent': 4, 'sort_keys': True,