Module: Mesa Branch: main Commit: 3923d43908fa3ac2c8535e33277229038333fe8f URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=3923d43908fa3ac2c8535e33277229038333fe8f
Author: Yiwei Zhang <zzyi...@chromium.org> Date: Thu Dec 21 01:57:50 2023 -0800 meson/vulkan/util: allow venus to drop compiler deps Files to compile: 451 => 232 Signed-off-by: Yiwei Zhang <zzyi...@chromium.org> Reviewed-by: Yonggang Luo <luoyongg...@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26783> --- meson.build | 14 ++++++++++++++ src/vulkan/runtime/meson.build | 7 +++++-- src/vulkan/runtime/vk_instance.c | 6 ++---- src/vulkan/util/vk_util.c | 17 +++++++++++++++++ src/vulkan/util/vk_util.h | 6 ++++++ 5 files changed, 44 insertions(+), 6 deletions(-) diff --git a/meson.build b/meson.build index 0c5a03de124..a53d50d036d 100644 --- a/meson.build +++ b/meson.build @@ -251,6 +251,20 @@ with_microsoft_vk = _vulkan_drivers.contains('microsoft-experimental') with_nouveau_vk = _vulkan_drivers.contains('nouveau-experimental') with_any_vk = _vulkan_drivers.length() != 0 +with_vk_compiler = [ + with_intel_vk, + with_intel_hasvk, + with_amd_vk, + with_freedreno_vk, + with_panfrost_vk, + with_swrast_vk, + with_broadcom_vk, + with_imagination_vk, + with_microsoft_vk, + with_nouveau_vk, +].contains(true) +pre_args += '-DUSE_VK_COMPILER=@0@'.format(with_vk_compiler ? '1' : '0') + freedreno_kmds = get_option('freedreno-kmds') if freedreno_kmds.length() != 0 and freedreno_kmds != [ 'msm' ] and with_freedreno_vk if freedreno_kmds.contains('msm') diff --git a/src/vulkan/runtime/meson.build b/src/vulkan/runtime/meson.build index 91a61b77594..6bfa1b499b1 100644 --- a/src/vulkan/runtime/meson.build +++ b/src/vulkan/runtime/meson.build @@ -121,11 +121,14 @@ vulkan_runtime_files = files( vulkan_runtime_deps = [ vulkan_wsi_deps, idep_mesautil, - idep_nir, - idep_vtn, + idep_nir_headers, idep_vulkan_util, ] +if with_vk_compiler + vulkan_runtime_deps += [idep_nir, idep_vtn] +endif + if dep_libdrm.found() vulkan_runtime_files += files('vk_drm_syncobj.c', 'vk_drm_syncobj.h') vulkan_runtime_deps += dep_libdrm diff --git a/src/vulkan/runtime/vk_instance.c b/src/vulkan/runtime/vk_instance.c index 68a4e43364b..31dc8b1ff69 100644 --- a/src/vulkan/runtime/vk_instance.c +++ b/src/vulkan/runtime/vk_instance.c @@ -34,8 +34,6 @@ #include "vk_debug_utils.h" #include "vk_physical_device.h" -#include "compiler/glsl_types.h" - #define VERSION_IS_1_0(version) \ (VK_API_VERSION_MAJOR(version) == 1 && VK_API_VERSION_MINOR(version) == 0) @@ -201,7 +199,7 @@ vk_instance_init(struct vk_instance *instance, instance->trace_frame = (uint32_t)debug_get_num_option("MESA_VK_TRACE_FRAME", 0xFFFFFFFF); instance->trace_trigger_file = getenv("MESA_VK_TRACE_TRIGGER"); - glsl_type_singleton_init_or_ref(); + vk_compiler_cache_init(); return VK_SUCCESS; } @@ -221,7 +219,7 @@ vk_instance_finish(struct vk_instance *instance) { destroy_physical_devices(instance); - glsl_type_singleton_decref(); + vk_compiler_cache_finish(); if (unlikely(!list_is_empty(&instance->debug_utils.callbacks))) { list_for_each_entry_safe(struct vk_debug_utils_messenger, messenger, &instance->debug_utils.callbacks, link) { diff --git a/src/vulkan/util/vk_util.c b/src/vulkan/util/vk_util.c index 841212034ec..afd009e26d5 100644 --- a/src/vulkan/util/vk_util.c +++ b/src/vulkan/util/vk_util.c @@ -29,6 +29,7 @@ #include "vk_util.h" #include "util/u_debug.h" +#include "compiler/glsl_types.h" #include "compiler/spirv/nir_spirv.h" uint32_t vk_get_driver_version(void) @@ -141,3 +142,19 @@ vk_spec_info_to_nir_spirv(const VkSpecializationInfo *spec_info, *out_num_spec_entries = num_spec_entries; return spec_entries; } + +void +vk_compiler_cache_init(void) +{ +#if USE_VK_COMPILER + glsl_type_singleton_init_or_ref(); +#endif +} + +void +vk_compiler_cache_finish(void) +{ +#if USE_VK_COMPILER + glsl_type_singleton_decref(); +#endif +} diff --git a/src/vulkan/util/vk_util.h b/src/vulkan/util/vk_util.h index d30e8ad007d..295f6e474b4 100644 --- a/src/vulkan/util/vk_util.h +++ b/src/vulkan/util/vk_util.h @@ -316,6 +316,12 @@ struct vk_pipeline_cache_header { memcpy((dest), (src), (count) * sizeof(*(src))); \ } while (0) +void +vk_compiler_cache_init(void); + +void +vk_compiler_cache_finish(void); + static inline gl_shader_stage vk_to_mesa_shader_stage(VkShaderStageFlagBits vk_stage) {