cmake: Allow build system to disable arm neon intrinsics
parent
46de6241d7
commit
fc4085b54e
|
@ -912,6 +912,7 @@ if(SDL_ASSEMBLY)
|
||||||
if(SDL_ARMSIMD)
|
if(SDL_ARMSIMD)
|
||||||
cmake_push_check_state()
|
cmake_push_check_state()
|
||||||
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -x assembler-with-cpp")
|
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -x assembler-with-cpp")
|
||||||
|
list(APPEND CMAKE_REQUIRED_LINK_OPTIONS -x none)
|
||||||
check_c_source_compiles("
|
check_c_source_compiles("
|
||||||
.text
|
.text
|
||||||
.arch armv6
|
.arch armv6
|
||||||
|
@ -921,6 +922,8 @@ if(SDL_ASSEMBLY)
|
||||||
#ifndef __ARM_EABI__
|
#ifndef __ARM_EABI__
|
||||||
#error EABI is required (to be sure that calling conventions are compatible)
|
#error EABI is required (to be sure that calling conventions are compatible)
|
||||||
#endif
|
#endif
|
||||||
|
main:
|
||||||
|
.global main
|
||||||
pld [r0]
|
pld [r0]
|
||||||
uqadd8 r0, r0, r0
|
uqadd8 r0, r0, r0
|
||||||
" ARMSIMD_FOUND)
|
" ARMSIMD_FOUND)
|
||||||
|
@ -929,8 +932,10 @@ if(SDL_ASSEMBLY)
|
||||||
if(ARMSIMD_FOUND)
|
if(ARMSIMD_FOUND)
|
||||||
set(HAVE_ARMSIMD TRUE)
|
set(HAVE_ARMSIMD TRUE)
|
||||||
set(SDL_ARM_SIMD_BLITTERS 1)
|
set(SDL_ARM_SIMD_BLITTERS 1)
|
||||||
|
enable_language(ASM)
|
||||||
file(GLOB ARMSIMD_SOURCES ${SDL3_SOURCE_DIR}/src/video/arm/pixman-arm-simd*.S)
|
file(GLOB ARMSIMD_SOURCES ${SDL3_SOURCE_DIR}/src/video/arm/pixman-arm-simd*.S)
|
||||||
list(APPEND SOURCE_FILES ${ARMSIMD_SOURCES})
|
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)
|
set(WARN_ABOUT_ARM_SIMD_ASM_MIT TRUE)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
@ -938,6 +943,7 @@ if(SDL_ASSEMBLY)
|
||||||
if(SDL_ARMNEON)
|
if(SDL_ARMNEON)
|
||||||
cmake_push_check_state()
|
cmake_push_check_state()
|
||||||
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -x assembler-with-cpp")
|
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -x assembler-with-cpp")
|
||||||
|
list(APPEND CMAKE_REQUIRED_LINK_OPTIONS -x none)
|
||||||
check_c_source_compiles("
|
check_c_source_compiles("
|
||||||
.text
|
.text
|
||||||
.fpu neon
|
.fpu neon
|
||||||
|
@ -949,6 +955,8 @@ if(SDL_ASSEMBLY)
|
||||||
#ifndef __ARM_EABI__
|
#ifndef __ARM_EABI__
|
||||||
#error EABI is required (to be sure that calling conventions are compatible)
|
#error EABI is required (to be sure that calling conventions are compatible)
|
||||||
#endif
|
#endif
|
||||||
|
main:
|
||||||
|
.global main
|
||||||
pld [r0]
|
pld [r0]
|
||||||
vmovn.u16 d0, q0
|
vmovn.u16 d0, q0
|
||||||
" ARMNEON_FOUND)
|
" ARMNEON_FOUND)
|
||||||
|
@ -957,8 +965,10 @@ if(SDL_ASSEMBLY)
|
||||||
if(ARMNEON_FOUND)
|
if(ARMNEON_FOUND)
|
||||||
set(HAVE_ARMNEON TRUE)
|
set(HAVE_ARMNEON TRUE)
|
||||||
set(SDL_ARM_NEON_BLITTERS 1)
|
set(SDL_ARM_NEON_BLITTERS 1)
|
||||||
|
enable_language(ASM)
|
||||||
file(GLOB ARMNEON_SOURCES ${SDL3_SOURCE_DIR}/src/video/arm/pixman-arm-neon*.S)
|
file(GLOB ARMNEON_SOURCES ${SDL3_SOURCE_DIR}/src/video/arm/pixman-arm-neon*.S)
|
||||||
list(APPEND SOURCE_FILES ${ARMNEON_SOURCES})
|
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)
|
set(WARN_ABOUT_ARM_NEON_ASM_MIT TRUE)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
@ -1028,6 +1038,10 @@ if(NOT HAVE_LASX)
|
||||||
set(SDL_DISABLE_LASX 1)
|
set(SDL_DISABLE_LASX 1)
|
||||||
endif()
|
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
|
# TODO: Can't deactivate on FreeBSD? w/o LIBC, SDL_stdinc.h can't define
|
||||||
# anything.
|
# anything.
|
||||||
if(SDL_LIBC)
|
if(SDL_LIBC)
|
||||||
|
@ -3161,21 +3175,21 @@ if(UNIX)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(WARN_ABOUT_ARM_SIMD_ASM_MIT)
|
if(WARN_ABOUT_ARM_SIMD_ASM_MIT)
|
||||||
message(STATUS "")
|
|
||||||
message(STATUS "SDL is being built with ARM SIMD optimizations, which")
|
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 "uses code licensed under the MIT license. If this is a")
|
||||||
message(STATUS "problem, please disable that code by rerunning CMake with:")
|
message(STATUS "problem, please disable that code by rerunning CMake with:")
|
||||||
message(STATUS "")
|
message(STATUS "")
|
||||||
message(STATUS " -DSDL_ARMSIMD=OFF")
|
message(STATUS " -DSDL_ARMSIMD=OFF")
|
||||||
|
message(STATUS "")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(WARN_ABOUT_ARM_NEON_ASM_MIT)
|
if(WARN_ABOUT_ARM_NEON_ASM_MIT)
|
||||||
message(STATUS "")
|
|
||||||
message(STATUS "SDL is being built with ARM NEON optimizations, which")
|
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 "uses code licensed under the MIT license. If this is a")
|
||||||
message(STATUS "problem, please disable that code by rerunning CMake with:")
|
message(STATUS "problem, please disable that code by rerunning CMake with:")
|
||||||
message(STATUS "")
|
message(STATUS "")
|
||||||
message(STATUS " -DSDL_ARMNEON=OFF")
|
message(STATUS " -DSDL_ARMNEON=OFF")
|
||||||
|
message(STATUS "")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(ANDROID)
|
if(ANDROID)
|
||||||
|
|
|
@ -65,7 +65,7 @@ _m_prefetch(void *__P)
|
||||||
#endif
|
#endif
|
||||||
#elif defined(__MINGW64_VERSION_MAJOR)
|
#elif defined(__MINGW64_VERSION_MAJOR)
|
||||||
#include <intrin.h>
|
#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>
|
# include <arm_neon.h>
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
|
@ -73,7 +73,7 @@ _m_prefetch(void *__P)
|
||||||
#if defined(HAVE_ALTIVEC_H) && defined(__ALTIVEC__) && !defined(__APPLE_ALTIVEC__) && defined(SDL_ENABLE_ALTIVEC_H)
|
#if defined(HAVE_ALTIVEC_H) && defined(__ALTIVEC__) && !defined(__APPLE_ALTIVEC__) && defined(SDL_ENABLE_ALTIVEC_H)
|
||||||
#include <altivec.h>
|
#include <altivec.h>
|
||||||
#endif
|
#endif
|
||||||
#if !defined(SDL_DISABLE_ARM_NEON_H)
|
#if !defined(SDL_DISABLE_NEON)
|
||||||
# if defined(__ARM_NEON)
|
# if defined(__ARM_NEON)
|
||||||
# include <arm_neon.h>
|
# include <arm_neon.h>
|
||||||
# elif defined(__WINDOWS__) || defined(__WINRT__) || defined(__GDK__)
|
# elif defined(__WINDOWS__) || defined(__WINRT__) || defined(__GDK__)
|
||||||
|
|
|
@ -594,5 +594,6 @@ typedef unsigned int uintptr_t;
|
||||||
#cmakedefine SDL_DISABLE_MMX 1
|
#cmakedefine SDL_DISABLE_MMX 1
|
||||||
#cmakedefine SDL_DISABLE_LSX 1
|
#cmakedefine SDL_DISABLE_LSX 1
|
||||||
#cmakedefine SDL_DISABLE_LASX 1
|
#cmakedefine SDL_DISABLE_LASX 1
|
||||||
|
#cmakedefine SDL_DISABLE_NEON 1
|
||||||
|
|
||||||
#endif /* SDL_build_config_h_ */
|
#endif /* SDL_build_config_h_ */
|
||||||
|
|
|
@ -186,8 +186,7 @@
|
||||||
#include <SDL3/SDL.h>
|
#include <SDL3/SDL.h>
|
||||||
#include <SDL3/SDL_intrin.h>
|
#include <SDL3/SDL_intrin.h>
|
||||||
|
|
||||||
|
#if defined(__ARM_NEON) && !defined(SDL_DISABLE_NEON)
|
||||||
#ifdef __ARM_NEON
|
|
||||||
#define HAVE_NEON_INTRINSICS 1
|
#define HAVE_NEON_INTRINSICS 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -23,10 +23,6 @@
|
||||||
#include "SDL_audio_c.h"
|
#include "SDL_audio_c.h"
|
||||||
#include "SDL_audiocvt_c.h"
|
#include "SDL_audiocvt_c.h"
|
||||||
|
|
||||||
#ifdef __ARM_NEON
|
|
||||||
#define HAVE_NEON_INTRINSICS 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(__x86_64__) && HAVE_SSE2_INTRINSICS
|
#if defined(__x86_64__) && HAVE_SSE2_INTRINSICS
|
||||||
#define NEED_SCALAR_CONVERTER_FALLBACKS 0 /* x86_64 guarantees SSE2. */
|
#define NEED_SCALAR_CONVERTER_FALLBACKS 0 /* x86_64 guarantees SSE2. */
|
||||||
#elif __MACOS__ && HAVE_SSE2_INTRINSICS
|
#elif __MACOS__ && HAVE_SSE2_INTRINSICS
|
||||||
|
|
|
@ -332,14 +332,13 @@ static int scale_mat(const Uint32 *src, int src_w, int src_h, int src_pitch,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__ARM_NEON)
|
#if HAVE_NEON_INTRINSICS
|
||||||
#define HAVE_NEON_INTRINSICS 1
|
|
||||||
#define CAST_uint8x8_t (uint8x8_t)
|
#define CAST_uint8x8_t (uint8x8_t)
|
||||||
#define CAST_uint32x2_t (uint32x2_t)
|
#define CAST_uint32x2_t (uint32x2_t)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__WINRT__) || defined(_MSC_VER)
|
#if defined(__WINRT__) || defined(_MSC_VER)
|
||||||
#if defined(HAVE_NEON_INTRINSICS)
|
#if HAVE_NEON_INTRINSICS
|
||||||
#undef CAST_uint8x8_t
|
#undef CAST_uint8x8_t
|
||||||
#undef CAST_uint32x2_t
|
#undef CAST_uint32x2_t
|
||||||
#define CAST_uint8x8_t
|
#define CAST_uint8x8_t
|
||||||
|
|
Loading…
Reference in New Issue