From 88924496c2ce4d6b1eb3bbd42dfa5a5a259ef4cd Mon Sep 17 00:00:00 2001 From: "A. Wilcox" Date: Fri, 22 Feb 2019 20:22:44 +0000 Subject: user/mesa: Fix swrast AltiVec detection on 32-bit PPC --- user/mesa/fix-non-altivec-ppc32.patch | 66 +++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 user/mesa/fix-non-altivec-ppc32.patch (limited to 'user/mesa/fix-non-altivec-ppc32.patch') diff --git a/user/mesa/fix-non-altivec-ppc32.patch b/user/mesa/fix-non-altivec-ppc32.patch new file mode 100644 index 000000000..846cf5031 --- /dev/null +++ b/user/mesa/fix-non-altivec-ppc32.patch @@ -0,0 +1,66 @@ +--- mesa-18.3.2/src/util/u_cpu_detect.c.old 2019-01-17 11:26:23.000000000 +0000 ++++ mesa-18.3.2/src/util/u_cpu_detect.c 2019-02-22 19:23:26.620000000 +0000 +@@ -41,6 +41,9 @@ + #if defined(PIPE_ARCH_PPC) + #if defined(PIPE_OS_APPLE) + #include ++#elif defined(PIPE_OS_LINUX) ++#include ++#include + #else + #include + #include +@@ -92,7 +95,7 @@ + #endif + + +-#if defined(PIPE_ARCH_PPC) && !defined(PIPE_OS_APPLE) ++#if defined(PIPE_ARCH_PPC) && !defined(PIPE_OS_APPLE) && !defined(PIPE_OS_LINUX) + static jmp_buf __lv_powerpc_jmpbuf; + static volatile sig_atomic_t __lv_powerpc_canjump = 0; + +@@ -126,7 +129,43 @@ + util_cpu_caps.has_altivec = 1; + } + } +-#else /* !PIPE_OS_APPLE */ ++#elif defined(PIPE_OS_LINUX) ++ /* Taken from FFmpeg 4.1.1 (LGPL-2.1+) */ ++ // The linux kernel could have the altivec support disabled ++ // even if the cpu has it. ++ int i, ret = 0; ++ int fd = open("/proc/self/auxv", O_RDONLY); ++ unsigned long buf[64] = { 0 }; ++ ssize_t count; ++ boolean enable_vsx = TRUE; ++ /* VSX instructions can be explicitly enabled/disabled via GALLIVM_VSX=1 or 0 */ ++ char *env_vsx = getenv("GALLIVM_VSX"); ++ if (env_vsx && env_vsx[0] == '0') { ++ enable_vsx = FALSE; ++ } ++ ++ if (fd < 0) ++ return 0; ++ ++ while ((count = read(fd, buf, sizeof(buf))) > 0) { ++ for (i = 0; i < count / sizeof(*buf); i += 2) { ++ if (buf[i] == AT_NULL) ++ goto out; ++ if (buf[i] == AT_HWCAP) { ++ if (buf[i + 1] & PPC_FEATURE_HAS_ALTIVEC) ++ util_cpu_caps.has_altivec = 1; ++#ifdef PPC_FEATURE_HAS_VSX ++ if (enable_vsx && buf[i + 1] & PPC_FEATURE_HAS_VSX) ++ util_cpu_caps.has_vsx = 1; ++#endif ++ goto out; ++ } ++ } ++ } ++ ++out: ++ close(fd); ++#else /* !PIPE_OS_APPLE, !PIPE_OS_LINUX */ + /* not on Apple/Darwin, do it the brute-force way */ + /* this is borrowed from the libmpeg2 library */ + signal(SIGILL, sigill_handler); -- cgit v1.2.3-60-g2f50