diff --git a/0001-gallivm-temporary-disable-coroutines-on-loongarch64.patch b/0001-gallivm-temporary-disable-coroutines-on-loongarch64.patch new file mode 100644 index 0000000000000000000000000000000000000000..63975a7a884e61748e42aa65718039f0ce5fe705 --- /dev/null +++ b/0001-gallivm-temporary-disable-coroutines-on-loongarch64.patch @@ -0,0 +1,51 @@ +From 1118f758ab493c769cd3cca778778fd6c19ec610 Mon Sep 17 00:00:00 2001 +From: Your Name +Date: Wed, 8 May 2024 17:06:48 +0800 +Subject: [PATCH 1/3] gallivm: temporary disable coroutines on loongarch64 + +--- + src/gallium/auxiliary/gallivm/lp_bld.h | 4 ++++ + src/gallium/auxiliary/gallivm/lp_bld_init.c | 4 ++-- + 2 files changed, 6 insertions(+), 2 deletions(-) + +diff --git a/src/gallium/auxiliary/gallivm/lp_bld.h b/src/gallium/auxiliary/gallivm/lp_bld.h +index e1f6200..1254f0d 100644 +--- a/src/gallium/auxiliary/gallivm/lp_bld.h ++++ b/src/gallium/auxiliary/gallivm/lp_bld.h +@@ -85,7 +85,11 @@ + #define GALLIVM_HAVE_CORO 0 + #define GALLIVM_USE_NEW_PASS 1 + #elif LLVM_VERSION_MAJOR >= 8 ++#ifdef __loongarch__ ++#define GALLIVM_HAVE_CORO 0 ++#else + #define GALLIVM_HAVE_CORO 1 ++#endif + #define GALLIVM_USE_NEW_PASS 0 + #else + #define GALLIVM_HAVE_CORO 0 +diff --git a/src/gallium/auxiliary/gallivm/lp_bld_init.c b/src/gallium/auxiliary/gallivm/lp_bld_init.c +index cd2108f..3dc6cbc 100644 +--- a/src/gallium/auxiliary/gallivm/lp_bld_init.c ++++ b/src/gallium/auxiliary/gallivm/lp_bld_init.c +@@ -50,7 +50,7 @@ + #if LLVM_VERSION_MAJOR >= 7 + #include + #endif +-#if LLVM_VERSION_MAJOR <= 8 && (DETECT_ARCH_AARCH64 || DETECT_ARCH_ARM || DETECT_ARCH_S390 || DETECT_ARCH_MIPS64) ++#if LLVM_VERSION_MAJOR <= 8 && (DETECT_ARCH_AARCH64 || DETECT_ARCH_ARM || DETECT_ARCH_S390 || DETECT_ARCH_MIPS64 || DETECT_ARCH_LOONGARCH64) + #include + #endif + #include +@@ -141,7 +141,7 @@ create_pass_manager(struct gallivm_state *gallivm) + } + + #if GALLIVM_HAVE_CORO == 1 +-#if LLVM_VERSION_MAJOR <= 8 && (DETECT_ARCH_AARCH64 || DETECT_ARCH_ARM || DETECT_ARCH_S390 || DETECT_ARCH_MIPS64) ++#if LLVM_VERSION_MAJOR <= 8 && (DETECT_ARCH_AARCH64 || DETECT_ARCH_ARM || DETECT_ARCH_S390 || DETECT_ARCH_MIPS64 || DETECT_ARCH_LOONGARCH64) + LLVMAddArgumentPromotionPass(gallivm->cgpassmgr); + LLVMAddFunctionAttrsPass(gallivm->cgpassmgr); + #endif +-- +2.41.0 + diff --git a/0002-gallivm-arit-use-LLVMBuildFPToUI-when-the-float-is-n.patch b/0002-gallivm-arit-use-LLVMBuildFPToUI-when-the-float-is-n.patch new file mode 100644 index 0000000000000000000000000000000000000000..2aea59b2180bc1d5a89351fa61903524e5fba69f --- /dev/null +++ b/0002-gallivm-arit-use-LLVMBuildFPToUI-when-the-float-is-n.patch @@ -0,0 +1,28 @@ +From 087d8c2d19275b0293fd12a10a218661751bd162 Mon Sep 17 00:00:00 2001 +From: Your Name +Date: Wed, 8 May 2024 17:07:24 +0800 +Subject: [PATCH 2/3] gallivm: arit: use LLVMBuildFPToUI when the float is not + +--- + src/gallium/auxiliary/gallivm/lp_bld_arit.c | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/src/gallium/auxiliary/gallivm/lp_bld_arit.c b/src/gallium/auxiliary/gallivm/lp_bld_arit.c +index d0264e4..0a44cd7 100644 +--- a/src/gallium/auxiliary/gallivm/lp_bld_arit.c ++++ b/src/gallium/auxiliary/gallivm/lp_bld_arit.c +@@ -2389,7 +2389,10 @@ lp_build_iround(struct lp_build_context *bld, + res = LLVMBuildFAdd(builder, a, half, ""); + } + +- res = LLVMBuildFPToSI(builder, res, int_vec_type, ""); ++ if (type.sign) ++ res = LLVMBuildFPToSI(builder, res, int_vec_type, ""); ++ else ++ res = LLVMBuildFPToUI(builder, res, int_vec_type, ""); + + return res; + } +-- +2.41.0 + diff --git a/0003-gallivm-add-more-optlevel-for-debug-purpose-on.patch b/0003-gallivm-add-more-optlevel-for-debug-purpose-on.patch new file mode 100644 index 0000000000000000000000000000000000000000..7c2229c656b3e876d2818ecbffd43386ade9853c --- /dev/null +++ b/0003-gallivm-add-more-optlevel-for-debug-purpose-on.patch @@ -0,0 +1,64 @@ +From f0332e550001da1c27d989f987362a03852bdfcd Mon Sep 17 00:00:00 2001 +From: Your Name +Date: Wed, 8 May 2024 17:07:59 +0800 +Subject: [PATCH 3/3] gallivm: add more optlevel for debug purpose on + +--- + src/gallium/auxiliary/gallivm/lp_bld_debug.h | 6 ++++++ + src/gallium/auxiliary/gallivm/lp_bld_init.c | 16 +++++++++++++++- + 2 files changed, 21 insertions(+), 1 deletion(-) + +diff --git a/src/gallium/auxiliary/gallivm/lp_bld_debug.h b/src/gallium/auxiliary/gallivm/lp_bld_debug.h +index a8db59b..30100aa 100644 +--- a/src/gallium/auxiliary/gallivm/lp_bld_debug.h ++++ b/src/gallium/auxiliary/gallivm/lp_bld_debug.h +@@ -49,6 +49,12 @@ + #define GALLIVM_PERF_NO_OPT (1 << 3) + #define GALLIVM_PERF_NO_AOS_SAMPLING (1 << 4) + ++#if DETECT_ARCH_LOONGARCH64 ++#define GALLIVM_PERF_OPT_O1 (1 << 5) ++#define GALLIVM_PERF_OPT_O2 (1 << 6) ++#define GALLIVM_PERF_OPT_O3 (1 << 7) ++#endif ++ + #ifdef __cplusplus + extern "C" { + #endif +diff --git a/src/gallium/auxiliary/gallivm/lp_bld_init.c b/src/gallium/auxiliary/gallivm/lp_bld_init.c +index 3dc6cbc..17d84b2 100644 +--- a/src/gallium/auxiliary/gallivm/lp_bld_init.c ++++ b/src/gallium/auxiliary/gallivm/lp_bld_init.c +@@ -64,6 +64,11 @@ static const struct debug_named_value lp_bld_perf_flags[] = { + { "no_quad_lod", GALLIVM_PERF_NO_QUAD_LOD, "disable quad_lod optimization" }, + { "no_aos_sampling", GALLIVM_PERF_NO_AOS_SAMPLING, "disable aos sampling optimization" }, + { "nopt", GALLIVM_PERF_NO_OPT, "disable optimization passes to speed up shader compilation" }, ++#if DETECT_ARCH_LOONGARCH64 ++ { "o3", GALLIVM_PERF_OPT_O3, "enable aggressive optimization passes" }, ++ { "o2", GALLIVM_PERF_OPT_O2, "enable medium optimization passes" }, ++ { "o1", GALLIVM_PERF_OPT_O1, "enable less optimization passes" }, ++#endif + DEBUG_NAMED_VALUE_END + }; + +@@ -278,7 +283,16 @@ init_gallivm_engine(struct gallivm_state *gallivm) + optlevel = None; + } + else { +- optlevel = Default; ++#if DETECT_ARCH_LOONGARCH64 ++ if (gallivm_perf & GALLIVM_PERF_OPT_O3) ++ optlevel = Aggressive; ++ else if (gallivm_perf & GALLIVM_PERF_OPT_O2) ++ optlevel = Default; ++ else if (gallivm_perf & GALLIVM_PERF_OPT_O1) ++ optlevel = Less; ++ else ++#endif ++ optlevel = Default; + } + + ret = lp_build_create_jit_compiler_for_module(&gallivm->engine, +-- +2.41.0 + diff --git a/mesa.spec b/mesa.spec index 4deac08ac4957d65b935d759d3523d211b81c29d..8c72b75542ea34d3d267552cc079b4646695f092 100644 --- a/mesa.spec +++ b/mesa.spec @@ -1,4 +1,4 @@ -%define anolis_release 2 +%define anolis_release 3 %global with_hardware 1 %global with_vulkan_hw 1 @@ -47,6 +47,9 @@ Source1: Mesa-MLAA-License-Clarification-Email.txt Patch10: gnome-shell-glthread-disable.patch Patch11: 0001-zink-initialize-drm_fd-to-1.patch +Patch12: 0001-gallivm-temporary-disable-coroutines-on-loongarch64.patch +Patch13: 0002-gallivm-arit-use-LLVMBuildFPToUI-when-the-float-is-n.patch +Patch14: 0003-gallivm-add-more-optlevel-for-debug-purpose-on.patch BuildRequires: meson BuildRequires: gcc @@ -634,6 +637,9 @@ popd %endif %changelog +* Wed May 8 2024 Wenlong Zhang - 23.3.0-3 +- add loongarch64 support for mesa + * Mon Mar 25 2024 Bo Ren - 23.3.0-2 - Rebuild with python3.11