Created
August 2, 2017 15:29
-
-
Save MilhouseVH/e13f2a8e47b278be15438c4a6d979e6c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From bb1c2d40fa123e41165e407cda8bcb7027b0d41e Mon Sep 17 00:00:00 2001 | |
From: croniccorey <[email protected]> | |
Date: Thu, 25 May 2017 03:58:40 -0400 | |
Subject: [PATCH] [Kodi] Update NEON support | |
- Define HAS_NEON when NEON cmake switch is set | |
- Aarch64 always has neon, Enable cmake switch and change CPUInfo to report it | |
- Don't set NEON_FLAGS if none exist, Not all targets need extra flags | |
- Don't use preprocessor to check for neon support, Instead use HAS_NEON set by cmake | |
--- | |
cmake/scripts/android/ArchSetup.cmake | 1 + | |
cmake/scripts/common/ArchSetup.cmake | 5 ++++- | |
cmake/scripts/ios/ArchSetup.cmake | 2 +- | |
cmake/scripts/linux/ArchSetup.cmake | 2 +- | |
xbmc/cores/VideoPlayer/VideoRenderers/LinuxRendererGLES.cpp | 2 +- | |
xbmc/cores/VideoPlayer/VideoRenderers/yuv2rgb.neon.S | 2 +- | |
xbmc/cores/VideoPlayer/VideoRenderers/yuv2rgb.neon.h | 2 +- | |
xbmc/guilib/MatrixGLES.cpp | 6 +++--- | |
xbmc/utils/CPUInfo.cpp | 8 ++++++-- | |
9 files changed, 19 insertions(+), 11 deletions(-) | |
diff --git a/cmake/scripts/android/ArchSetup.cmake b/cmake/scripts/android/ArchSetup.cmake | |
index fe7d4c15835f..17215a7aad80 100644 | |
--- a/cmake/scripts/android/ArchSetup.cmake | |
+++ b/cmake/scripts/android/ArchSetup.cmake | |
@@ -17,6 +17,7 @@ else() | |
set(NEON_FLAGS "-mfpu=neon -mvectorize-with-neon-quad") | |
elseif(CPU STREQUAL arm64-v8a) | |
set(ARCH aarch64) | |
+ set(NEON True) | |
elseif(CPU STREQUAL i686) | |
set(ARCH i486-linux) | |
set(NEON False) | |
diff --git a/cmake/scripts/common/ArchSetup.cmake b/cmake/scripts/common/ArchSetup.cmake | |
index 74afc8ccaf7c..8d5dba8bbeed 100644 | |
--- a/cmake/scripts/common/ArchSetup.cmake | |
+++ b/cmake/scripts/common/ArchSetup.cmake | |
@@ -146,7 +146,10 @@ if(NOT DEFINED NEON OR NEON) | |
option(ENABLE_NEON "Enable NEON optimization" ${NEON}) | |
if(ENABLE_NEON) | |
message(STATUS "NEON optimization enabled") | |
- add_options(ALL_LANGUAGES ALL_BUILDS ${NEON_FLAGS}) | |
+ add_definitions(-DHAS_NEON) | |
+ if(NEON_FLAGS) | |
+ add_options(ALL_LANGUAGES ALL_BUILDS ${NEON_FLAGS}) | |
+ endif() | |
endif() | |
endif() | |
diff --git a/cmake/scripts/ios/ArchSetup.cmake b/cmake/scripts/ios/ArchSetup.cmake | |
index dbb7c4858eef..20d8cd20eefb 100644 | |
--- a/cmake/scripts/ios/ArchSetup.cmake | |
+++ b/cmake/scripts/ios/ArchSetup.cmake | |
@@ -15,7 +15,7 @@ else() | |
if(CPU STREQUAL armv7 OR CPU STREQUAL arm64) | |
set(CMAKE_OSX_ARCHITECTURES ${CPU}) | |
set(ARCH arm-osx) | |
- set(NEON False) | |
+ set(NEON True) | |
else() | |
message(SEND_ERROR "Unknown CPU: ${CPU}") | |
endif() | |
diff --git a/cmake/scripts/linux/ArchSetup.cmake b/cmake/scripts/linux/ArchSetup.cmake | |
index eeed920aff57..53e5f1bd1204 100644 | |
--- a/cmake/scripts/linux/ArchSetup.cmake | |
+++ b/cmake/scripts/linux/ArchSetup.cmake | |
@@ -19,7 +19,7 @@ else() | |
set(NEON_FLAGS "-mfpu=neon -mvectorize-with-neon-quad") | |
elseif(CPU MATCHES aarch64 OR CPU MATCHES arm64) | |
set(ARCH aarch64) | |
- set(NEON False) | |
+ set(NEON True) | |
else() | |
message(SEND_ERROR "Unknown CPU: ${CPU}") | |
endif() | |
diff --git a/xbmc/cores/VideoPlayer/VideoRenderers/LinuxRendererGLES.cpp b/xbmc/cores/VideoPlayer/VideoRenderers/LinuxRendererGLES.cpp | |
index 2d5e603093ff..4681dff16107 100644 | |
--- a/xbmc/cores/VideoPlayer/VideoRenderers/LinuxRendererGLES.cpp | |
+++ b/xbmc/cores/VideoPlayer/VideoRenderers/LinuxRendererGLES.cpp | |
@@ -50,7 +50,7 @@ extern "C" { | |
#include "libswscale/swscale.h" | |
} | |
-#if defined(__ARM_NEON__) && !defined(__LP64__) | |
+#if defined(HAS_NEON) && !defined(__LP64__) | |
#include "yuv2rgb.neon.h" | |
#include "utils/CPUInfo.h" | |
#endif | |
diff --git a/xbmc/cores/VideoPlayer/VideoRenderers/yuv2rgb.neon.S b/xbmc/cores/VideoPlayer/VideoRenderers/yuv2rgb.neon.S | |
index 48bbe378ae8a..df7218b4fab0 100644 | |
--- a/xbmc/cores/VideoPlayer/VideoRenderers/yuv2rgb.neon.S | |
+++ b/xbmc/cores/VideoPlayer/VideoRenderers/yuv2rgb.neon.S | |
@@ -7,7 +7,7 @@ | |
// | |
// | |
// | |
-#if defined(__ARM_NEON__) && !defined(__LP64__) | |
+#if defined(HAS_NEON) && !defined(__LP64__) | |
/* Initial ARM Neon implementation of core YUV2RGB functions. */ | |
diff --git a/xbmc/cores/VideoPlayer/VideoRenderers/yuv2rgb.neon.h b/xbmc/cores/VideoPlayer/VideoRenderers/yuv2rgb.neon.h | |
index 6aeb368478a7..145f61e3704a 100644 | |
--- a/xbmc/cores/VideoPlayer/VideoRenderers/yuv2rgb.neon.h | |
+++ b/xbmc/cores/VideoPlayer/VideoRenderers/yuv2rgb.neon.h | |
@@ -22,7 +22,7 @@ | |
extern "C" { | |
#endif | |
-#if defined(__ARM_NEON__) && !defined(__LP64__) | |
+#if defined(HAS_NEON) && !defined(__LP64__) | |
void yuv420_2_rgb8888_neon | |
( | |
uint8_t *dst_ptr, | |
diff --git a/xbmc/guilib/MatrixGLES.cpp b/xbmc/guilib/MatrixGLES.cpp | |
index dbc8081d48de..0c73a56191c4 100644 | |
--- a/xbmc/guilib/MatrixGLES.cpp | |
+++ b/xbmc/guilib/MatrixGLES.cpp | |
@@ -27,7 +27,7 @@ | |
#include <cmath> | |
#include "MatrixGLES.h" | |
#include "utils/log.h" | |
-#if defined(__ARM_NEON__) | |
+#if defined(HAS_NEON) | |
#include "utils/CPUInfo.h" | |
#endif | |
@@ -139,7 +139,7 @@ void CMatrixGL::Rotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z) | |
MultMatrixf(matrix); | |
} | |
-#if defined(__ARM_NEON__) && !defined(__LP64__) | |
+#if defined(HAS_NEON) && !defined(__LP64__) | |
inline void Matrix4Mul(const float* src_mat_1, const float* src_mat_2, float* dst_mat) | |
{ | |
@@ -182,7 +182,7 @@ inline void Matrix4Mul(const float* src_mat_1, const float* src_mat_2, float* ds | |
#endif | |
void CMatrixGL::MultMatrixf(const GLfloat *matrix) | |
{ | |
-#if defined(__ARM_NEON__) && !defined(__LP64__) | |
+#if defined(HAS_NEON) && !defined(__LP64__) | |
if ((g_cpuInfo.GetCPUFeatures() & CPU_FEATURE_NEON) == CPU_FEATURE_NEON) | |
{ | |
GLfloat m[16]; | |
diff --git a/xbmc/utils/CPUInfo.cpp b/xbmc/utils/CPUInfo.cpp | |
index 5e2ebbd18d85..ff3a188b12de 100644 | |
--- a/xbmc/utils/CPUInfo.cpp | |
+++ b/xbmc/utils/CPUInfo.cpp | |
@@ -43,7 +43,7 @@ | |
#include <sys/resource.h> | |
#endif | |
-#if defined(TARGET_LINUX) && defined(__ARM_NEON__) && !defined(TARGET_ANDROID) | |
+#if defined(TARGET_LINUX) && defined(HAS_NEON) && !defined(TARGET_ANDROID) | |
#include <fcntl.h> | |
#include <unistd.h> | |
#include <elf.h> | |
@@ -957,7 +957,10 @@ bool CCPUInfo::HasNeon() | |
#elif defined(TARGET_DARWIN_IOS) | |
has_neon = 1; | |
-#elif defined(TARGET_LINUX) && defined(__ARM_NEON__) | |
+#elif defined(TARGET_LINUX) && defined(HAS_NEON) | |
+#if defined(__LP64__) | |
+ has_neon = 1; | |
+#else | |
if (has_neon == -1) | |
{ | |
has_neon = 0; | |
@@ -978,6 +981,7 @@ bool CCPUInfo::HasNeon() | |
close(fd); | |
} | |
} | |
+#endif | |
#endif | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment