From 6366f6ab5983117c681aa310f6b2ea6b3f88bbe8 Mon Sep 17 00:00:00 2001 From: Jiaxun Yang Date: Wed, 22 Jan 2020 13:56:34 +0800 Subject: [PATCH 1/2] libobs: Build SIMDE on platforms without SSE2 SIMDE was introduced for aarch64 support, however, the library itself supports non-SIMD fallback, which allows us provide support to other platforms without code changes. There is another world beyond x86. So we can simply enable SIMDE for processors without SSE2 support. Signed-off-by: Jiaxun Yang --- CMakeLists.txt | 20 +++++++++++- deps/media-playback/CMakeLists.txt | 19 +++-------- libobs/CMakeLists.txt | 36 +++++++-------------- libobs/obsconfig.h.in | 1 + libobs/util/{aarch => simde}/check.h | 0 libobs/util/{aarch => simde}/hedley.h | 0 libobs/util/{aarch => simde}/mmx.h | 0 libobs/util/{aarch => simde}/simde-arch.h | 0 libobs/util/{aarch => simde}/simde-common.h | 0 libobs/util/{aarch => simde}/sse.h | 0 libobs/util/{aarch => simde}/sse2.h | 0 libobs/util/sse-intrin.h | 4 +-- 12 files changed, 38 insertions(+), 42 deletions(-) rename libobs/util/{aarch => simde}/check.h (100%) rename libobs/util/{aarch => simde}/hedley.h (100%) rename libobs/util/{aarch => simde}/mmx.h (100%) rename libobs/util/{aarch => simde}/simde-arch.h (100%) rename libobs/util/{aarch => simde}/simde-common.h (100%) rename libobs/util/{aarch => simde}/sse.h (100%) rename libobs/util/{aarch => simde}/sse2.h (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index ca67eb159..f4b44e00c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -78,8 +78,26 @@ if(${CMAKE_C_COMPILER_ID} MATCHES "Clang" OR ${CMAKE_CXX_COMPILER_ID} MATCHES "C set(CMAKE_COMPILER_IS_CLANG TRUE) endif() -if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)64(le)?") +if (MSVC_CXX_ARCHITECTURE_ID) + string(TOLOWER ${MSVC_CXX_ARCHITECTURE_ID} LOWERCASE_CMAKE_SYSTEM_PROCESSOR) +else () + string(TOLOWER ${CMAKE_SYSTEM_PROCESSOR} LOWERCASE_CMAKE_SYSTEM_PROCESSOR) +endif () + +if(LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "(i[3-6]86|x86|x64|x86_64|amd64)") + set(NEEDS_SIMDE "0") + if(NOT MSVC) + set(ARCH_SIMD_FLAGS "-mmmx" "-msse" "-msse2") + endif() +elseif(LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)64(le)?") + set(NEEDS_SIMDE "0") + set(ARCH_SIMD_FLAGS "-mvsx") add_compile_definitions(NO_WARN_X86_INTRINSICS) +else() + set(NEEDS_SIMDE "1") + add_definitions(-DNEEDS_SIMDE=1) + set(ARCH_SIMD_FLAGS "") + message(STATUS "No Native SSE2 SIMD Support - Using SIMDE") endif() if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANG) diff --git a/deps/media-playback/CMakeLists.txt b/deps/media-playback/CMakeLists.txt index 21d283c6f..13b365733 100644 --- a/deps/media-playback/CMakeLists.txt +++ b/deps/media-playback/CMakeLists.txt @@ -23,26 +23,15 @@ add_library(media-playback STATIC ${media-playback_SOURCES} ) -if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)64(le)?") - target_compile_options(media-playback - PUBLIC - -mvsx) - add_compile_definitions(NO_WARN_X86_INTRINSICS) -elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64") - target_compile_options(media-playback - PUBLIC) -elseif(NOT MSVC) - target_compile_options(media-playback - PUBLIC - -mmmx - -msse - -msse2) -endif() +target_compile_options(media-playback + PUBLIC + ${ARCH_SIMD_FLAGS}) target_include_directories(media-playback PUBLIC . ) + if(NOT MSVC) if(NOT MINGW) target_compile_options(media-playback PRIVATE -fPIC) diff --git a/libobs/CMakeLists.txt b/libobs/CMakeLists.txt index e7a5387d5..13df9ab0f 100644 --- a/libobs/CMakeLists.txt +++ b/libobs/CMakeLists.txt @@ -174,20 +174,21 @@ elseif(UNIX) util/pipe-posix.c util/platform-nix.c) - if(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64") + if(NEEDS_SIMDE) set(libobs_PLATFORM_HEADERS - util/aarch/check.h - util/aarch/hedley.h - util/aarch/mmx.h - util/aarch/simde-arch.h - util/aarch/simde-common.h - util/aarch/sse.h - util/aarch/sse2.h + util/simde/check.h + util/simde/hedley.h + util/simde/mmx.h + util/simde/simde-arch.h + util/simde/simde-common.h + util/simde/sse.h + util/simde/sse2.h util/threading-posix.h) else() set(libobs_PLATFORM_HEADERS util/threading-posix.h) endif() + if(HAVE_PULSEAUDIO) set(libobs_audio_monitoring_HEADERS audio-monitoring/pulse/pulseaudio-wrapper.h) @@ -475,22 +476,9 @@ target_compile_definitions(libobs PUBLIC HAVE_OBSCONFIG_H) -if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)64(le)?") - target_compile_options(libobs - PUBLIC - -mvsx) - add_compile_definitions(NO_WARN_X86_INTRINSICS) -elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64") - target_compile_options(libobs - PUBLIC) -elseif(NOT MSVC) - target_compile_options(libobs - PUBLIC - -mmmx - -msse - -msse2) -endif() - +target_compile_options(libobs + PUBLIC + ${ARCH_SIMD_FLAGS}) target_compile_options(libobs PUBLIC diff --git a/libobs/obsconfig.h.in b/libobs/obsconfig.h.in index a959f1482..1a09ebea0 100644 --- a/libobs/obsconfig.h.in +++ b/libobs/obsconfig.h.in @@ -19,6 +19,7 @@ #define HAVE_DBUS @HAVE_DBUS@ #define HAVE_PULSEAUDIO @HAVE_PULSEAUDIO@ #define USE_XINPUT @USE_XINPUT@ +#define NEEDS_SIMDE @NEEDS_SIMDE@ #define LIBOBS_IMAGEMAGICK_DIR_STYLE_6L 6 #define LIBOBS_IMAGEMAGICK_DIR_STYLE_7GE 7 #define LIBOBS_IMAGEMAGICK_DIR_STYLE @LIBOBS_IMAGEMAGICK_DIR_STYLE@ diff --git a/libobs/util/aarch/check.h b/libobs/util/simde/check.h similarity index 100% rename from libobs/util/aarch/check.h rename to libobs/util/simde/check.h diff --git a/libobs/util/aarch/hedley.h b/libobs/util/simde/hedley.h similarity index 100% rename from libobs/util/aarch/hedley.h rename to libobs/util/simde/hedley.h diff --git a/libobs/util/aarch/mmx.h b/libobs/util/simde/mmx.h similarity index 100% rename from libobs/util/aarch/mmx.h rename to libobs/util/simde/mmx.h diff --git a/libobs/util/aarch/simde-arch.h b/libobs/util/simde/simde-arch.h similarity index 100% rename from libobs/util/aarch/simde-arch.h rename to libobs/util/simde/simde-arch.h diff --git a/libobs/util/aarch/simde-common.h b/libobs/util/simde/simde-common.h similarity index 100% rename from libobs/util/aarch/simde-common.h rename to libobs/util/simde/simde-common.h diff --git a/libobs/util/aarch/sse.h b/libobs/util/simde/sse.h similarity index 100% rename from libobs/util/aarch/sse.h rename to libobs/util/simde/sse.h diff --git a/libobs/util/aarch/sse2.h b/libobs/util/simde/sse2.h similarity index 100% rename from libobs/util/aarch/sse2.h rename to libobs/util/simde/sse2.h diff --git a/libobs/util/sse-intrin.h b/libobs/util/sse-intrin.h index d15e0abe9..8136c92d0 100644 --- a/libobs/util/sse-intrin.h +++ b/libobs/util/sse-intrin.h @@ -17,9 +17,9 @@ #pragma once -#ifdef __aarch64__ +#if NEEDS_SIMDE -#include "aarch/sse2.h" +#include "simde/sse2.h" #define __m128 simde__m128 #define _mm_setzero_ps simde_mm_setzero_ps From af062863ab01591c4594b1d72e43ccc29e158714 Mon Sep 17 00:00:00 2001 From: Jiaxun Yang Date: Wed, 22 Jan 2020 14:41:42 +0800 Subject: [PATCH 2/2] linux-v4l2: Mark aarch64 and mips n64 as known platform Aarch64 and MIPS N64 ABI are safe to the uint to long cast. Signed-off-by: Jiaxun Yang --- plugins/linux-v4l2/v4l2-controls.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/linux-v4l2/v4l2-controls.c b/plugins/linux-v4l2/v4l2-controls.c index 0cf30849e..1f6f84cbd 100644 --- a/plugins/linux-v4l2/v4l2-controls.c +++ b/plugins/linux-v4l2/v4l2-controls.c @@ -27,7 +27,7 @@ along with this program. If not, see . #if defined(__i386__) #define UINT_TO_POINTER(val) ((void *)(unsigned int)(val)) #define POINTER_TO_UINT(p) ((unsigned int)(unsigned int)(p)) -#elif defined(__x86_64__) +#elif defined(__x86_64__) || defined(__aarch64__) || (_MIPS_SIM == _ABI64) #define UINT_TO_POINTER(val) ((void *)(unsigned long)(val)) #define POINTER_TO_UINT(p) ((unsigned int)(unsigned long)(p)) #else