From de60b13b33261a3dff3ebe26315616f0de2d0f83 Mon Sep 17 00:00:00 2001 From: yangxiaojuan Date: Mon, 14 Aug 2023 11:19:28 +0800 Subject: [PATCH] Add loongarch64 support --- ...ry-disable-coroutines-on-loongarch64.patch | 52 +++++++++++++++ ...-LLVMBuildFPToUI-when-the-float-is-n.patch | 29 ++++++++ ...-optlevel-for-debug-purpose-on-loong.patch | 66 +++++++++++++++++++ mesa.spec | 9 ++- 4 files changed, 155 insertions(+), 1 deletion(-) create mode 100644 0001-gallivm-temporary-disable-coroutines-on-loongarch64.patch create mode 100644 0002-gallivm-arit-use-LLVMBuildFPToUI-when-the-float-is-n.patch create mode 100644 0003-gallivm-add-more-optlevel-for-debug-purpose-on-loong.patch 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 0000000..8b8c5a6 --- /dev/null +++ b/0001-gallivm-temporary-disable-coroutines-on-loongarch64.patch @@ -0,0 +1,52 @@ +From a0fa9bba4095c62a1badb86b886787174a0cbce6 Mon Sep 17 00:00:00 2001 +From: suijingfeng +Date: Sun, 11 Jul 2021 06:12:17 +0800 +Subject: [PATCH 1/3] gallivm: temporary disable coroutines on loongarch64 + +Signed-off-by: suijingfeng +--- + 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 24d0823..5a27977 100644 +--- a/src/gallium/auxiliary/gallivm/lp_bld_init.c ++++ b/src/gallium/auxiliary/gallivm/lp_bld_init.c +@@ -50,7 +50,7 @@ + #if GALLIVM_USE_NEW_PASS == 1 + #include + #elif 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) + #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.20.1 + 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 0000000..04b2321 --- /dev/null +++ b/0002-gallivm-arit-use-LLVMBuildFPToUI-when-the-float-is-n.patch @@ -0,0 +1,29 @@ +From a72eb44c434a5584932053dafa91b0c60e6f104b Mon Sep 17 00:00:00 2001 +From: suijingfeng +Date: Mon, 16 Aug 2021 14:42:57 +0800 +Subject: [PATCH 2/3] gallivm: arit: use LLVMBuildFPToUI when the float is not + signed + +--- + 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 511c578..32ec3d0 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.20.1 + diff --git a/0003-gallivm-add-more-optlevel-for-debug-purpose-on-loong.patch b/0003-gallivm-add-more-optlevel-for-debug-purpose-on-loong.patch new file mode 100644 index 0000000..48e6373 --- /dev/null +++ b/0003-gallivm-add-more-optlevel-for-debug-purpose-on-loong.patch @@ -0,0 +1,66 @@ +From 598baf898eccc7886622ec6897d4982034edfb08 Mon Sep 17 00:00:00 2001 +From: suijingfeng +Date: Fri, 9 Jul 2021 15:25:06 +0800 +Subject: [PATCH 3/3] gallivm: add more optlevel for debug purpose on + loongarch64 + +Signed-off-by: suijingfeng +--- + 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 291e6d5..e08e2c6 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 5a27977..9cf9749 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.20.1 + diff --git a/mesa.spec b/mesa.spec index b3c40dc..122ecb5 100644 --- a/mesa.spec +++ b/mesa.spec @@ -1,4 +1,4 @@ -%define anolis_release 1 +%define anolis_release 2 %bcond_without hardware @@ -39,6 +39,10 @@ License: MIT URL: http://www.mesa3d.org Source0: https://archive.mesa3d.org/mesa-%{version}.tar.xz +Patch1001: 0001-gallivm-temporary-disable-coroutines-on-loongarch64.patch +Patch1002: 0002-gallivm-arit-use-LLVMBuildFPToUI-when-the-float-is-n.patch +Patch1003: 0003-gallivm-add-more-optlevel-for-debug-purpose-on-loong.patch + BuildRequires: gcc, gcc-c++, gettext, meson >= 1.0.0 %if %{with hardware} BuildRequires: kernel-headers @@ -789,6 +793,9 @@ ln -s %{_libdir}/libGLX_mesa.so.0 %{buildroot}%{_libdir}/libGLX_system.so.0 %endif %changelog +* Fri Nov 3 2023 Xiaojuan Yang - 23.1.8-2 +- Support Loongarch64 + * Wed Sep 27 2023 Funda Wang - 23.1.8-1 - New version 23.1.8 -- Gitee