cmake: Allow build system to disable arm neon intrinsics

main
Anonymous Maarten 2023-02-26 01:51:19 +01:00 committed by Anonymous Maarten
parent 46de6241d7
commit fc4085b54e
6 changed files with 22 additions and 13 deletions

View File

@ -912,6 +912,7 @@ if(SDL_ASSEMBLY)
if(SDL_ARMSIMD)
cmake_push_check_state()
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -x assembler-with-cpp")
list(APPEND CMAKE_REQUIRED_LINK_OPTIONS -x none)
check_c_source_compiles("
.text
.arch armv6
@ -921,6 +922,8 @@ if(SDL_ASSEMBLY)
#ifndef __ARM_EABI__
#error EABI is required (to be sure that calling conventions are compatible)
#endif
main:
.global main
pld [r0]
uqadd8 r0, r0, r0
" ARMSIMD_FOUND)
@ -929,8 +932,10 @@ if(SDL_ASSEMBLY)
if(ARMSIMD_FOUND)
set(HAVE_ARMSIMD TRUE)
set(SDL_ARM_SIMD_BLITTERS 1)
enable_language(ASM)
file(GLOB ARMSIMD_SOURCES ${SDL3_SOURCE_DIR}/src/video/arm/pixman-arm-simd*.S)
list(APPEND SOURCE_FILES ${ARMSIMD_SOURCES})
set_property(SOURCE ${ARMSIMD_SOURCES} APPEND PROPERTY COMPILE_OPTIONS -x assembler-with-cpp)
set(WARN_ABOUT_ARM_SIMD_ASM_MIT TRUE)
endif()
endif()
@ -938,6 +943,7 @@ if(SDL_ASSEMBLY)
if(SDL_ARMNEON)
cmake_push_check_state()
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -x assembler-with-cpp")
list(APPEND CMAKE_REQUIRED_LINK_OPTIONS -x none)
check_c_source_compiles("
.text
.fpu neon
@ -949,6 +955,8 @@ if(SDL_ASSEMBLY)
#ifndef __ARM_EABI__
#error EABI is required (to be sure that calling conventions are compatible)
#endif
main:
.global main
pld [r0]
vmovn.u16 d0, q0
" ARMNEON_FOUND)
@ -957,8 +965,10 @@ if(SDL_ASSEMBLY)
if(ARMNEON_FOUND)
set(HAVE_ARMNEON TRUE)
set(SDL_ARM_NEON_BLITTERS 1)
enable_language(ASM)
file(GLOB ARMNEON_SOURCES ${SDL3_SOURCE_DIR}/src/video/arm/pixman-arm-neon*.S)
list(APPEND SOURCE_FILES ${ARMNEON_SOURCES})
set_property(SOURCE ${ARMNEON_SOURCES} APPEND PROPERTY COMPILE_OPTIONS -x assembler-with-cpp)
set(WARN_ABOUT_ARM_NEON_ASM_MIT TRUE)
endif()
endif()
@ -1028,6 +1038,10 @@ if(NOT HAVE_LASX)
set(SDL_DISABLE_LASX 1)
endif()
if(NOT HAVE_ARMNEON)
set(SDL_DISABLE_NEON 1)
endif()
# TODO: Can't deactivate on FreeBSD? w/o LIBC, SDL_stdinc.h can't define
# anything.
if(SDL_LIBC)
@ -3161,21 +3175,21 @@ if(UNIX)
endif()
if(WARN_ABOUT_ARM_SIMD_ASM_MIT)
message(STATUS "")
message(STATUS "SDL is being built with ARM SIMD optimizations, which")
message(STATUS "uses code licensed under the MIT license. If this is a")
message(STATUS "problem, please disable that code by rerunning CMake with:")
message(STATUS "")
message(STATUS " -DSDL_ARMSIMD=OFF")
message(STATUS "")
endif()
if(WARN_ABOUT_ARM_NEON_ASM_MIT)
message(STATUS "")
message(STATUS "SDL is being built with ARM NEON optimizations, which")
message(STATUS "uses code licensed under the MIT license. If this is a")
message(STATUS "problem, please disable that code by rerunning CMake with:")
message(STATUS "")
message(STATUS " -DSDL_ARMNEON=OFF")
message(STATUS "")
endif()
if(ANDROID)

View File

@ -65,7 +65,7 @@ _m_prefetch(void *__P)
#endif
#elif defined(__MINGW64_VERSION_MAJOR)
#include <intrin.h>
#if !defined(SDL_DISABLE_ARM_NEON_H) && defined(__ARM_NEON)
#if defined(__ARM_NEON) && !defined(SDL_DISABLE_NEON)
# include <arm_neon.h>
#endif
#else
@ -73,7 +73,7 @@ _m_prefetch(void *__P)
#if defined(HAVE_ALTIVEC_H) && defined(__ALTIVEC__) && !defined(__APPLE_ALTIVEC__) && defined(SDL_ENABLE_ALTIVEC_H)
#include <altivec.h>
#endif
#if !defined(SDL_DISABLE_ARM_NEON_H)
#if !defined(SDL_DISABLE_NEON)
# if defined(__ARM_NEON)
# include <arm_neon.h>
# elif defined(__WINDOWS__) || defined(__WINRT__) || defined(__GDK__)

View File

@ -594,5 +594,6 @@ typedef unsigned int uintptr_t;
#cmakedefine SDL_DISABLE_MMX 1
#cmakedefine SDL_DISABLE_LSX 1
#cmakedefine SDL_DISABLE_LASX 1
#cmakedefine SDL_DISABLE_NEON 1
#endif /* SDL_build_config_h_ */

View File

@ -186,8 +186,7 @@
#include <SDL3/SDL.h>
#include <SDL3/SDL_intrin.h>
#ifdef __ARM_NEON
#if defined(__ARM_NEON) && !defined(SDL_DISABLE_NEON)
#define HAVE_NEON_INTRINSICS 1
#endif

View File

@ -23,10 +23,6 @@
#include "SDL_audio_c.h"
#include "SDL_audiocvt_c.h"
#ifdef __ARM_NEON
#define HAVE_NEON_INTRINSICS 1
#endif
#if defined(__x86_64__) && HAVE_SSE2_INTRINSICS
#define NEED_SCALAR_CONVERTER_FALLBACKS 0 /* x86_64 guarantees SSE2. */
#elif __MACOS__ && HAVE_SSE2_INTRINSICS

View File

@ -332,14 +332,13 @@ static int scale_mat(const Uint32 *src, int src_w, int src_h, int src_pitch,
return 0;
}
#if defined(__ARM_NEON)
#define HAVE_NEON_INTRINSICS 1
#if HAVE_NEON_INTRINSICS
#define CAST_uint8x8_t (uint8x8_t)
#define CAST_uint32x2_t (uint32x2_t)
#endif
#if defined(__WINRT__) || defined(_MSC_VER)
#if defined(HAVE_NEON_INTRINSICS)
#if HAVE_NEON_INTRINSICS
#undef CAST_uint8x8_t
#undef CAST_uint32x2_t
#define CAST_uint8x8_t