vulkan: allow building venus without libcompiler

This is done by introduce idep_vulkan_lite_runtime, and only venus
depends on  idep_vulkan_lite_runtime.

Modify the meson and source files to allow building venus without
the compiler.

See details Venus build metrics at the MR description.

gfxstream-vulkan forwards the shader to the host, and doesn't
need to convert into NIR in the guest.  This results in faster
builds and less parts of Mesa to build.  Also venus does the
same thing too, that's what the build is keyed on right now
as an in-tree user.

v7: By Yonggang Luo <luoyonggang@gmail.com>
  Add idep_vulkan_common_entrypoints_h into vulkan_lite_runtime_deps because
  vk_instance.c depends on idep_vulkan_common_entrypoints_h but vk_common_entrypoints is
  not compiled in library `vulkan_lite_instance`.
  Rename idep_vulkan_runtime_headers to idep_vulkan_lite_runtime_headers because
  both lite/full runtime library depends on this, but lite should not depends on full
  vk_meta_private.h added into vulkan_runtime_files

v6: By Yonggang Luo <luoyonggang@gmail.com>
  get vulkan_lite_runtime_files and vulkan_runtime_files sorted

v5: By Yiwei Zhang <zzyiwei@chromium.org>
  both vk_sampler and vk_ycbcr_conversion can stay in the lite runtime

v4: By Yonggang Luo <luoyonggang@gmail.com>
  only build vk_instance.(c|h) twice for reduce compiling time

v3: By Yiwei Zhang <zzyiwei@chromium.org>
  less code changes by introduce libvulkan_lite_runtime

v2: By Yonggang Luo <luoyonggang@gmail.com>
  allow building Vulkan without libcompiler without compiling flags, the
  venus is always built without libcompiler

v1: By Gurchetan Singh <gurchetansingh@google.com>
  allow building Vulkan without libcompiler

Signed-off-by: Gurchetan Singh <gurchetansingh@google.com>
Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Yonggang Luo <luoyonggang@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26574>
This commit is contained in:
Yonggang Luo 2024-03-05 02:58:22 +08:00 committed by Marge Bot
parent a367cd4931
commit fe2ec50844
3 changed files with 136 additions and 63 deletions

View file

@ -77,7 +77,7 @@ vn_deps = [
dep_thread,
idep_mesautil,
idep_vulkan_util,
idep_vulkan_runtime,
idep_vulkan_lite_runtime,
idep_vulkan_wsi,
idep_xmlconfig,
]

View file

@ -21,7 +21,7 @@
# Mesa-local imports in the Python files must be declared here for correct
# dependency tracking.
vulkan_runtime_files = files(
vulkan_lite_runtime_files = files(
'rmv/vk_rmv_common.c',
'rmv/vk_rmv_common.h',
'rmv/vk_rmv_exporter.c',
@ -64,25 +64,10 @@ vulkan_runtime_files = files(
'vk_graphics_state.h',
'vk_image.c',
'vk_image.h',
'vk_instance.c',
'vk_instance.h',
'vk_log.c',
'vk_log.h',
'vk_meta.c',
'vk_meta.h',
'vk_meta_blit_resolve.c',
'vk_meta_draw_rects.c',
'vk_meta_clear.c',
'vk_nir.c',
'vk_nir.h',
'vk_nir_convert_ycbcr.c',
'vk_nir_convert_ycbcr.h',
'vk_object.c',
'vk_object.h',
'vk_pipeline.c',
'vk_pipeline.h',
'vk_pipeline_cache.c',
'vk_pipeline_cache.h',
'vk_physical_device.c',
'vk_physical_device.h',
'vk_pipeline_layout.c',
@ -92,14 +77,11 @@ vulkan_runtime_files = files(
'vk_queue.c',
'vk_queue.h',
'vk_render_pass.c',
'vk_render_pass.h',
'vk_sampler.c',
'vk_sampler.h',
'vk_semaphore.c',
'vk_semaphore.h',
'vk_shader.c',
'vk_shader.h',
'vk_shader_module.c',
'vk_shader_module.h',
'vk_standard_sample_locations.c',
'vk_standard_sample_locations.h',
'vk_sync.c',
@ -112,40 +94,27 @@ vulkan_runtime_files = files(
'vk_sync_timeline.h',
'vk_synchronization.c',
'vk_synchronization.h',
'vk_texcompress_etc2.c',
'vk_texcompress_etc2.h',
'vk_video.c',
'vk_video.h',
'vk_ycbcr_conversion.c',
'vk_ycbcr_conversion.h',
)
vulkan_runtime_deps = [
vulkan_lite_runtime_deps = [
vulkan_wsi_deps,
idep_mesautil,
idep_nir,
idep_vtn,
idep_nir_headers,
idep_vulkan_util,
]
if dep_libdrm.found()
vulkan_runtime_files += files('vk_drm_syncobj.c', 'vk_drm_syncobj.h')
vulkan_runtime_deps += dep_libdrm
vulkan_lite_runtime_files += files('vk_drm_syncobj.c', 'vk_drm_syncobj.h')
vulkan_lite_runtime_deps += dep_libdrm
endif
if with_platform_android
vulkan_runtime_files += files('vk_android.c', 'vk_android.h')
vulkan_runtime_deps += dep_android
endif
if prog_glslang.found()
vulkan_runtime_files += files('vk_texcompress_astc.c', 'vk_texcompress_astc.h')
vulkan_runtime_files += custom_target(
'astc_spv.h',
input : astc_decoder_glsl_file,
output : 'astc_spv.h',
command : [prog_glslang, '-V', '-S', 'comp', '-x', '-o', '@OUTPUT@', '@INPUT@'] + glslang_quiet,
)
vulkan_lite_runtime_files += files('vk_android.c', 'vk_android.h')
vulkan_lite_runtime_deps += dep_android
endif
vk_common_entrypoints = custom_target(
@ -243,13 +212,107 @@ vk_format_info = custom_target(
],
)
vulkan_lite_runtime_files += [
vk_common_entrypoints,
vk_cmd_queue,
vk_cmd_enqueue_entrypoints,
vk_dispatch_trampolines,
vk_physical_device_features,
vk_physical_device_properties,
vk_synchronization_helpers,
vk_format_info,
]
idep_vulkan_common_entrypoints_h = declare_dependency(
sources : [vk_common_entrypoints[0]]
)
vulkan_lite_runtime_deps += idep_vulkan_common_entrypoints_h
libvulkan_lite_runtime = static_library(
'vulkan_lite_runtime',
vulkan_lite_runtime_files,
include_directories : [inc_include, inc_src],
dependencies : vulkan_lite_runtime_deps,
c_args : c_msvc_compat_args,
gnu_symbol_visibility : 'hidden',
build_by_default : false,
)
libvulkan_lite_instance = static_library(
'vulkan_lite_instance',
['vk_instance.c', 'vk_instance.h',],
include_directories : [inc_include, inc_src],
dependencies : vulkan_lite_runtime_deps,
c_args : ['-DVK_LITE_RUNTIME_INSTANCE=1', c_msvc_compat_args],
gnu_symbol_visibility : 'hidden',
build_by_default : false,
)
idep_vulkan_lite_runtime_headers = declare_dependency(
sources : [vk_cmd_queue[1], vk_physical_device_features[1], vk_physical_device_properties[1]],
include_directories : include_directories('.'),
)
# This is likely a bug in the Meson VS backend, as MSVC with ninja works fine.
# See this discussion here:
# https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10506
if get_option('backend').startswith('vs')
idep_vulkan_lite_runtime = declare_dependency(
link_with : [libvulkan_lite_runtime, libvulkan_lite_instance],
dependencies : idep_vulkan_lite_runtime_headers
)
else
idep_vulkan_lite_runtime = declare_dependency(
# Instruct users of this library to link with --whole-archive. Otherwise,
# our weak function overloads may not resolve properly.
link_whole : [libvulkan_lite_runtime, libvulkan_lite_instance],
dependencies : idep_vulkan_lite_runtime_headers
)
endif
vulkan_runtime_files = files(
'vk_meta.c',
'vk_meta.h',
'vk_meta_blit_resolve.c',
'vk_meta_clear.c',
'vk_meta_draw_rects.c',
'vk_meta_private.h',
'vk_nir.c',
'vk_nir.h',
'vk_nir_convert_ycbcr.c',
'vk_nir_convert_ycbcr.h',
'vk_pipeline.c',
'vk_pipeline.h',
'vk_pipeline_cache.c',
'vk_pipeline_cache.h',
'vk_shader.c',
'vk_shader.h',
'vk_shader_module.c',
'vk_shader_module.h',
'vk_texcompress_etc2.c',
'vk_texcompress_etc2.h',
)
vulkan_runtime_deps = [
vulkan_lite_runtime_deps,
idep_nir,
idep_vtn,
]
if prog_glslang.found()
vulkan_runtime_files += files('vk_texcompress_astc.c', 'vk_texcompress_astc.h')
vulkan_runtime_files += custom_target(
'astc_spv.h',
input : astc_decoder_glsl_file,
output : 'astc_spv.h',
command : [prog_glslang, '-V', '-S', 'comp', '-x', '-o', '@OUTPUT@', '@INPUT@'] + glslang_quiet,
)
endif
libvulkan_runtime = static_library(
'vulkan_runtime',
[vulkan_runtime_files, vk_common_entrypoints,
vk_cmd_queue, vk_cmd_enqueue_entrypoints,
vk_dispatch_trampolines, vk_physical_device_features,
vk_physical_device_properties, vk_synchronization_helpers,
vk_format_info],
[vulkan_runtime_files],
include_directories : [inc_include, inc_src],
dependencies : vulkan_runtime_deps,
c_args : c_msvc_compat_args,
@ -257,28 +320,31 @@ libvulkan_runtime = static_library(
build_by_default : false,
)
idep_vulkan_runtime_headers = declare_dependency(
sources : [vk_cmd_queue[1], vk_physical_device_features[1], vk_physical_device_properties[1]],
include_directories : include_directories('.'),
libvulkan_instance = static_library(
'vulkan_instance',
['vk_instance.c', 'vk_instance.h',],
include_directories : [inc_include, inc_src],
dependencies : vulkan_runtime_deps,
c_args : ['-DVK_LITE_RUNTIME_INSTANCE=0', c_msvc_compat_args],
gnu_symbol_visibility : 'hidden',
build_by_default : false,
)
idep_vulkan_common_entrypoints_h = declare_dependency(
sources : [vk_common_entrypoints[0]]
)
# This is likely a bug in the Meson VS backend, as MSVC with ninja works fine.
# See this discussion here:
# https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10506
if get_option('backend').startswith('vs')
idep_vulkan_runtime = declare_dependency(
link_with : libvulkan_runtime,
dependencies : idep_vulkan_runtime_headers
idep_vulkan_runtime_body = declare_dependency(
link_with : [libvulkan_lite_runtime, libvulkan_runtime, libvulkan_instance],
)
else
idep_vulkan_runtime = declare_dependency(
# Instruct users of this library to link with --whole-archive. Otherwise,
# our weak function overloads may not resolve properly.
link_whole : libvulkan_runtime,
dependencies : idep_vulkan_runtime_headers
idep_vulkan_runtime_body = declare_dependency(
link_whole : [libvulkan_lite_runtime, libvulkan_runtime, libvulkan_instance],
)
endif
idep_vulkan_runtime_headers = idep_vulkan_lite_runtime_headers
idep_vulkan_runtime = declare_dependency(
dependencies : [
idep_vulkan_runtime_headers,
idep_vulkan_runtime_body,
]
)

View file

@ -34,7 +34,9 @@
#include "vk_debug_utils.h"
#include "vk_physical_device.h"
#if !VK_LITE_RUNTIME_INSTANCE
#include "compiler/glsl_types.h"
#endif
#define VERSION_IS_1_0(version) \
(VK_API_VERSION_MAJOR(version) == 1 && VK_API_VERSION_MINOR(version) == 0)
@ -201,7 +203,9 @@ 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 = secure_getenv("MESA_VK_TRACE_TRIGGER");
#if !VK_LITE_RUNTIME_INSTANCE
glsl_type_singleton_init_or_ref();
#endif
return VK_SUCCESS;
}
@ -221,7 +225,10 @@ vk_instance_finish(struct vk_instance *instance)
{
destroy_physical_devices(instance);
#if !VK_LITE_RUNTIME_INSTANCE
glsl_type_singleton_decref();
#endif
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) {