ANDROID: vulkan: allow building Vulkan without libcompiler

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

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.

Bug: 327408955
Test: compile
Change-Id: Idd9529cf3dca54156bb42458b414d1937e674855
diff --git a/src/meson.build b/src/meson.build
index 62c65fa..8d78c82 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -69,7 +69,9 @@
 if with_gallium
   subdir('mapi')
 endif
-subdir('compiler')
+if with_vk_compiler
+  subdir('compiler')
+endif
 if with_tools.contains('drm-shim')
   subdir('drm-shim')
 endif
diff --git a/src/vulkan/runtime/meson.build b/src/vulkan/runtime/meson.build
index f706ba3..39a2626 100644
--- a/src/vulkan/runtime/meson.build
+++ b/src/vulkan/runtime/meson.build
@@ -60,31 +60,16 @@
   'vk_fence.h',
   'vk_framebuffer.c',
   'vk_framebuffer.h',
-  'vk_graphics_state.c',
-  '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_object_list.c',
   'vk_meta_object_list.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',
@@ -98,10 +83,6 @@
   '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',
@@ -114,8 +95,6 @@
   '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',
@@ -125,12 +104,36 @@
 vulkan_runtime_deps = [
   vulkan_wsi_deps,
   idep_mesautil,
-  idep_nir_headers,
   idep_vulkan_util,
 ]
 
+vulkan_compiler_files = files(
+  'vk_graphics_state.c',
+  'vk_graphics_state.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_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',
+)
+
 if with_vk_compiler
-  vulkan_runtime_deps += [idep_nir, idep_vtn]
+  vulkan_runtime_deps += [idep_vtn, idep_nir]
+  vulkan_runtime_files += vulkan_compiler_files
 endif
 
 if dep_libdrm.found()
@@ -143,7 +146,7 @@
   vulkan_runtime_deps += dep_android
 endif
 
-if prog_glslang.found()
+if prog_glslang.found() and with_vk_compiler
   vulkan_runtime_files += files('vk_texcompress_astc.c', 'vk_texcompress_astc.h')
   vulkan_runtime_files += custom_target(
     'astc_spv.h',
diff --git a/src/vulkan/runtime/vk_command_buffer.c b/src/vulkan/runtime/vk_command_buffer.c
index f678d9b..7e4c392 100644
--- a/src/vulkan/runtime/vk_command_buffer.c
+++ b/src/vulkan/runtime/vk_command_buffer.c
@@ -40,7 +40,9 @@
    command_buffer->pool = pool;
    command_buffer->level = level;
    command_buffer->ops = ops;
+#if USE_VK_COMPILER
    vk_dynamic_graphics_state_init(&command_buffer->dynamic_graphics_state);
+#endif
    command_buffer->state = MESA_VK_COMMAND_BUFFER_STATE_INITIAL;
    command_buffer->record_result = VK_SUCCESS;
    vk_cmd_queue_init(&command_buffer->cmd_queue, &pool->alloc);
@@ -56,7 +58,9 @@
 void
 vk_command_buffer_reset(struct vk_command_buffer *command_buffer)
 {
+#if USE_VK_COMPILER
    vk_dynamic_graphics_state_clear(&command_buffer->dynamic_graphics_state);
+#endif
    command_buffer->state = MESA_VK_COMMAND_BUFFER_STATE_INITIAL;
    command_buffer->record_result = VK_SUCCESS;
    vk_command_buffer_reset_render_pass(command_buffer);
diff --git a/src/vulkan/util/meson.build b/src/vulkan/util/meson.build
index 9dbe9dd..2f712bb 100644
--- a/src/vulkan/util/meson.build
+++ b/src/vulkan/util/meson.build
@@ -71,6 +71,9 @@
   'vk_format.c',
   'vk_util.c',
   'vk_util.h',
+)
+
+files_vulkan_util_compiler = files(
   'vk_util_compiler.c',
   'vk_util_compiler.h',
 )
@@ -120,12 +123,18 @@
   depend_files : vk_extensions_gen_depend_files,
 )
 
+vulkan_util_deps = [vulkan_wsi_deps, idep_mesautil]
+if with_vk_compiler
+  files_vulkan_util += files_vulkan_util_compiler
+  vulkan_util_deps += [idep_nir_headers]
+endif
+
 libvulkan_util = static_library(
   'vulkan_util',
   [files_vulkan_util, vk_dispatch_table, vk_enum_to_str,
    vk_struct_type_cast, vk_extensions],
   include_directories : [inc_include, inc_src],
-  dependencies : [vulkan_wsi_deps, idep_mesautil, idep_nir_headers],
+  dependencies : [vulkan_util_deps],
   c_args : [c_msvc_compat_args],
   gnu_symbol_visibility : 'hidden',
   build_by_default : false,
diff --git a/src/vulkan/util/vk_util.h b/src/vulkan/util/vk_util.h
index e691acb..c38eb9c 100644
--- a/src/vulkan/util/vk_util.h
+++ b/src/vulkan/util/vk_util.h
@@ -24,10 +24,16 @@
 #define VK_UTIL_H
 
 #include "util/macros.h"
+
 #include <stdlib.h>
 #include <string.h>
 
+#if USE_VK_COMPILER
 #include "vk_util_compiler.h"
+#else
+#include <stdbool.h>
+#endif
+
 #include "vk_struct_type_cast.h"
 
 #ifdef __cplusplus