Commit Diff


commit - ac9b16a522f0c2fb288fd3c55d10b58f95f7be84
commit + 470381d40e6804b9c5de13556c9e60a6b9685a89
blob - ec37b14710614e0f31d454727768b4533db211e9
blob + 1583df7c5ad89ffbbc1674d99a20661f1f47555e
--- lib/mesa/0001-static-lavapipe.patch
+++ lib/mesa/0001-static-lavapipe.patch
@@ -1,5 +1,5 @@
 diff --git a/meson.build b/meson.build
-index 5eaae977f67..f9023c9b402 100644
+index 5eaae97..f9023c9 100644
 --- a/meson.build
 +++ b/meson.build
 @@ -1928,8 +1928,7 @@ if dep_llvm.found()
@@ -48,21 +48,48 @@ index 5eaae977f67..f9023c9b402 100644
  endif
  
  # Even if we find OpenMP, Gitlab CI fails to link with gcc/i386 and clang/anyarch.
-diff --git a/src/gallium/auxiliary/draw/draw_context.c b/src/gallium/auxiliary/draw/draw_context.c
-index 6bd9f58a1d1..c09dd709eb4 100644
---- a/src/gallium/auxiliary/draw/draw_context.c
-+++ b/src/gallium/auxiliary/draw/draw_context.c
-@@ -57,7 +57,7 @@ bool
- draw_get_option_use_llvm(void)
- {
- #if DRAW_LLVM_AVAILABLE
--   return debug_get_bool_option("DRAW_USE_LLVM", true);
-+   return debug_get_bool_option("DRAW_USE_LLVM", false);
- #else
-    return false;
- #endif
+diff --git a/src/gallium/auxiliary/gallivm/lp_bld_init_orc.cpp b/src/gallium/auxiliary/gallivm/lp_bld_init_orc.cpp
+index 16357fb..0e1f520 100644
+--- a/src/gallium/auxiliary/gallivm/lp_bld_init_orc.cpp
++++ b/src/gallium/auxiliary/gallivm/lp_bld_init_orc.cpp
+@@ -320,6 +320,26 @@ LLVMErrorRef module_transform_wrapper(
+    return LLVMOrcThreadSafeModuleWithModuleDo(*ModInOut, *module_transform, Ctx);
+ }
+ 
++static llvm::Expected<llvm::orc::JITDylibSP>
++lpjit_create_static_process_symbols_jd(llvm::orc::LLJIT &J)
++{
++   using llvm::orc::JITDylibSP;
++
++   auto &ES = J.getExecutionSession();
++   auto &JD = ES.createBareJITDylib("process_symbols");
++
++   /* ok, so lljit normally wires the process-symbols jitdylib to a
++    * DynamicLibrarySearchGenerator, which resolves the symbold through dlopen(NULL)
++    * for static we still need the process symbols jitdylib itself
++    * but we need definitions to come from explicit add_mapping_to_jd()
++    * calls instead of the host process loader
++    *
++    * this might mean we have to defin some external symbols in the future,
++    * if some new helper is called, and no one maps it
++    */
++   return JITDylibSP(&JD);
++}
++
+ LPJit::LPJit() :jit_dylib_count(0) {
+    using namespace llvm::orc;
+ 
+@@ -337,6 +357,8 @@ LPJit::LPJit() :jit_dylib_count(0) {
+    lljit = ExitOnErr(
+       LLJITBuilder()
+          .setJITTargetMachineBuilder(std::move(JTMB))
++         .setLinkProcessSymbolsByDefault(true)
++         .setProcessSymbolsJITDylibSetup(*lpjit_create_static_process_symbols_jd)
+ #ifdef USE_JITLINK
+          .setObjectLinkingLayerCreator(
+ #if LLVM_VERSION_MAJOR >= 21
 diff --git a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
-index ce8ca02bf74..5689dcfeb4a 100644
+index ce8ca02..5689dcf 100644
 --- a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
 +++ b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
 @@ -599,6 +599,9 @@ lp_build_create_jit_compiler_for_module(LLVMExecutionEngineRef *OutJIT,
@@ -96,21 +123,8 @@ index ce8ca02bf74..5689dcfeb4a 100644
     *OutError = strdup(Error.c_str());
     return 1;
  }
-diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c b/src/gallium/drivers/llvmpipe/lp_screen.c
-index 2b71e1bfffb..4a23ff7dd05 100644
---- a/src/gallium/drivers/llvmpipe/lp_screen.c
-+++ b/src/gallium/drivers/llvmpipe/lp_screen.c
-@@ -140,7 +140,7 @@ llvmpipe_init_shader_caps(struct pipe_screen *screen)
-       case MESA_SHADER_GEOMETRY:
-          draw_init_shader_caps(caps);
- 
--         if (debug_get_bool_option("DRAW_USE_LLVM", true)) {
-+         if (debug_get_bool_option("DRAW_USE_LLVM", false)) {
-             caps->max_const_buffers = LP_MAX_TGSI_CONST_BUFFERS;
-          } else {
-             /* At this time, the draw module and llvmpipe driver only
 diff --git a/src/gallium/frontends/lavapipe/lvp_device.c b/src/gallium/frontends/lavapipe/lvp_device.c
-index 187f17ccf1b..51b67409311 100644
+index 187f17c..42de27a 100644
 --- a/src/gallium/frontends/lavapipe/lvp_device.c
 +++ b/src/gallium/frontends/lavapipe/lvp_device.c
 @@ -27,6 +27,7 @@
@@ -179,17 +193,7 @@ index 187f17ccf1b..51b67409311 100644
     result = vk_physical_device_init(&device->vk, &instance->vk,
                                      NULL, NULL, NULL, &dispatch_table);
     if (result != VK_SUCCESS) {
-@@ -1598,9 +1644,6 @@ static struct drisw_loader_funcs lvp_sw_lf = {
- static VkResult
- lvp_enumerate_physical_devices(struct vk_instance *vk_instance)
- {
--   if (!draw_get_option_use_llvm())
--      return VK_SUCCESS;
--
-    struct lvp_instance *instance =
-       container_of(vk_instance, struct lvp_instance, vk);
- 
-@@ -1642,6 +1685,13 @@ lvp_device_get_cache_uuid(void *uuid)
+@@ -1642,6 +1688,13 @@ lvp_device_get_cache_uuid(void *uuid)
        memcpy(uuid, PACKAGE_VERSION, MIN2(strlen(PACKAGE_VERSION), VK_UUID_SIZE));
  }
  
@@ -203,7 +207,7 @@ index 187f17ccf1b..51b67409311 100644
  VKAPI_ATTR void VKAPI_CALL lvp_GetPhysicalDeviceQueueFamilyProperties2(
     VkPhysicalDevice                            physicalDevice,
     uint32_t*                                   pCount,
-@@ -1745,6 +1795,41 @@ VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL lvp_GetInstanceProcAddr(
+@@ -1745,6 +1798,41 @@ VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL lvp_GetInstanceProcAddr(
                                      pName);
  }
  
@@ -245,7 +249,7 @@ index 187f17ccf1b..51b67409311 100644
  /* The loader wants us to expose a second GetInstanceProcAddr function
   * to work around certain LD_PRELOAD issues seen in apps.
   */
-@@ -1756,6 +1841,14 @@ VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vk_icdGetInstanceProcAddr(
+@@ -1756,6 +1844,14 @@ VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vk_icdGetInstanceProcAddr(
     return lvp_GetInstanceProcAddr(instance, pName);
  }
  
@@ -260,7 +264,7 @@ index 187f17ccf1b..51b67409311 100644
  static void
  destroy_pipelines(struct lvp_queue *queue)
  {
-@@ -1887,12 +1980,43 @@ VKAPI_ATTR VkResult VKAPI_CALL lvp_CreateDevice(
+@@ -1887,12 +1983,43 @@ VKAPI_ATTR VkResult VKAPI_CALL lvp_CreateDevice(
     device->poison_mem = debug_get_bool_option("LVP_POISON_MEMORY", false);
     device->print_cmds = debug_get_bool_option("LVP_CMD_DEBUG", false);
  
@@ -306,7 +310,7 @@ index 187f17ccf1b..51b67409311 100644
                                      &physical_device->vk,
                                      &dispatch_table, pCreateInfo,
 diff --git a/src/gallium/frontends/lavapipe/lvp_wsi.c b/src/gallium/frontends/lavapipe/lvp_wsi.c
-index 83e96597033..5d439a7a80f 100644
+index 83e9659..5d439a7 100644
 --- a/src/gallium/frontends/lavapipe/lvp_wsi.c
 +++ b/src/gallium/frontends/lavapipe/lvp_wsi.c
 @@ -44,7 +44,7 @@ lvp_init_wsi(struct lvp_physical_device *physical_device)
@@ -318,97 +322,9 @@ index 83e96597033..5d439a7a80f 100644
     physical_device->vk.wsi_device = &physical_device->wsi_device;
  
     return VK_SUCCESS;
-diff --git a/src/gallium/targets/lavapipe/meson.build b/src/gallium/targets/lavapipe/meson.build
-index 41de1e5a0f1..8b1697f571d 100644
---- a/src/gallium/targets/lavapipe/meson.build
-+++ b/src/gallium/targets/lavapipe/meson.build
-@@ -1,4 +1,48 @@
- 
-+static_lvp_shim = custom_target(
-+  'lvp_static_shim',
-+  input : [files('lvp_static_shim_gen.py'), vk_api_xml],
-+  output : 'lvp_static_shim.c',
-+  command : [
-+    prog_python, '@INPUT0@', '--xml', '@INPUT1@',
-+    '--out-c', '@OUTPUT@',
-+    '--beta', with_vulkan_beta.to_string(),
-+  ],
-+  depend_files : vk_entrypoints_gen_depend_files,
-+)
-+
-+libvulkan_lvp_static = static_library(
-+  'vulkan_lvp_static',
-+  [ 'lavapipe_target.c', static_lvp_shim ],