cmake+video: always use altivec.h header for detection + introduce SDL_ENABLE_ALTIVEC

main
Anonymous Maarten 2023-03-15 04:56:55 +01:00 committed by Anonymous Maarten
parent 684709a5b6
commit d27db3defa
7 changed files with 14 additions and 20 deletions

View File

@ -856,23 +856,17 @@ if(SDL_ASSEMBLY)
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -maltivec") set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -maltivec")
check_c_source_compiles(" check_c_source_compiles("
#include <altivec.h> #include <altivec.h>
vector unsigned int vzero() {
return vec_splat_u32(0);
}
int main(int argc, char **argv) { return 0; }" HAVE_ALTIVEC_H_HDR)
check_c_source_compiles("
vector unsigned int vzero() { vector unsigned int vzero() {
return vec_splat_u32(0); return vec_splat_u32(0);
} }
int main(int argc, char **argv) { return 0; }" CPU_SUPPORTS_ALTIVEC) int main(int argc, char **argv) { return 0; }" CPU_SUPPORTS_ALTIVEC)
cmake_pop_check_state() cmake_pop_check_state()
if(CPU_SUPPORTS_ALTIVEC OR HAVE_ALTIVEC_H_HDR) if(CPU_SUPPORTS_ALTIVEC)
set(HAVE_ALTIVEC TRUE) # if only HAVE_ALTIVEC_H_HDR is set set(HAVE_ALTIVEC TRUE)
target_compile_options(sdl-build-options INTERFACE "-maltivec")
set(SDL_ALTIVEC_BLITTERS 1) set(SDL_ALTIVEC_BLITTERS 1)
if(HAVE_ALTIVEC_H_HDR) target_compile_options(sdl-build-options INTERFACE "-maltivec")
set(HAVE_ALTIVEC_H 1) set_property(SOURCE "${SDL3_SOURCE_DIR}/src/video/SDL_blit_N.c" APPEND PROPERTY COMPILE_DEFINITIONS "SDL_ENABLE_ALTIVEC")
endif() set_property(SOURCE "${SDL3_SOURCE_DIR}/src/video/SDL_blit_N.c" APPEND PROPERTY SKIP_PRECOMPILE_HEADERS 1)
endif() endif()
endif() endif()

View File

@ -36,10 +36,10 @@ function(check_cpu_architecture ARCH VARIABLE)
_internal_check_cpu_architecture("defined(__loongarch64)" loongarch64 ${VARIABLE}) _internal_check_cpu_architecture("defined(__loongarch64)" loongarch64 ${VARIABLE})
elseif(ARCH STREQUAL "emscripten") elseif(ARCH STREQUAL "emscripten")
_internal_check_cpu_architecture("defined(__EMSCRIPTEN__)" emscripten ${VARIABLE}) _internal_check_cpu_architecture("defined(__EMSCRIPTEN__)" emscripten ${VARIABLE})
elseif(ARCH STREQUAL "powerpc32")
_internal_check_cpu_architecture("defined(__PPC__) || defined(__powerpc__)" powerpc32 ${VARIABLE})
elseif(ARCH STREQUAL "powerpc64") elseif(ARCH STREQUAL "powerpc64")
_internal_check_cpu_architecture("defined(__PPC64__) || defined(__powerpc64__)" powerpc64 ${VARIABLE}) _internal_check_cpu_architecture("defined(__PPC64__) || defined(__powerpc64__)" powerpc64 ${VARIABLE})
elseif(ARCH STREQUAL "powerpc32")
_internal_check_cpu_architecture("(defined(__PPC__) || defined(__powerpc__)) && !defined(__powerpc64__)" powerpc32 ${VARIABLE})
else() else()
message(WARNING "Unknown CPU architectures (${ARCH}).") message(WARNING "Unknown CPU architectures (${ARCH}).")
set("${VARIABLE}" FALSE) set("${VARIABLE}" FALSE)

View File

@ -78,7 +78,7 @@ function(SDL_DetectCPUArchitecture)
endforeach() endforeach()
endif() endif()
set(sdl_known_archs x64 x86 arm64 arm32 emscripten powerpc32 powerpc64 loongarch64) set(sdl_known_archs x64 x86 arm64 arm32 emscripten powerpc64 powerpc32 loongarch64)
if(NOT sdl_cpu_names) if(NOT sdl_cpu_names)
set(found FALSE) set(found FALSE)
foreach(sdl_known_arch ${sdl_known_archs}) foreach(sdl_known_arch ${sdl_known_archs})

View File

@ -69,8 +69,8 @@ _m_prefetch(void *__P)
# include <arm_neon.h> # include <arm_neon.h>
#endif #endif
#else #else
/* altivec.h redefining bool causes a number of problems, see bugs 3993 and 4392, so you need to explicitly define SDL_ENABLE_ALTIVEC_H to have it included. */ /* altivec.h redefining bool causes a number of problems, see bugs 3993 and 4392, so you need to explicitly define SDL_ENABLE_ALTIVEC to have it included. */
#if defined(HAVE_ALTIVEC_H) && defined(__ALTIVEC__) && !defined(__APPLE_ALTIVEC__) && defined(SDL_ENABLE_ALTIVEC_H) #if defined(__ALTIVEC__) && defined(SDL_ENABLE_ALTIVEC)
#include <altivec.h> #include <altivec.h>
#endif #endif
#if !defined(SDL_DISABLE_NEON) #if !defined(SDL_DISABLE_NEON)

View File

@ -215,7 +215,6 @@
#cmakedefine HAVE_FLOAT_H 1 #cmakedefine HAVE_FLOAT_H 1
#endif /* HAVE_LIBC */ #endif /* HAVE_LIBC */
#cmakedefine HAVE_ALTIVEC_H 1
#cmakedefine HAVE_DBUS_DBUS_H 1 #cmakedefine HAVE_DBUS_DBUS_H 1
#cmakedefine HAVE_FCITX 1 #cmakedefine HAVE_FCITX 1
#cmakedefine HAVE_IBUS_IBUS_H 1 #cmakedefine HAVE_IBUS_IBUS_H 1

View File

@ -186,6 +186,10 @@
#include <SDL3/SDL.h> #include <SDL3/SDL.h>
#include <SDL3/SDL_intrin.h> #include <SDL3/SDL_intrin.h>
#if defined(__ALTIVEC__) && defined(SDL_ENABLE_ALTIVEC)
#define HAVE_ALTIVEC_INTRINSICS 1
#endif
#if defined(__ARM_NEON) && !defined(SDL_DISABLE_NEON) #if defined(__ARM_NEON) && !defined(SDL_DISABLE_NEON)
#define HAVE_NEON_INTRINSICS 1 #define HAVE_NEON_INTRINSICS 1
#endif #endif

View File

@ -46,9 +46,6 @@ enum blit_features
}; };
#if SDL_ALTIVEC_BLITTERS #if SDL_ALTIVEC_BLITTERS
#ifdef HAVE_ALTIVEC_H
#include <altivec.h>
#endif
#ifdef __MACOS__ #ifdef __MACOS__
#include <sys/sysctl.h> #include <sys/sysctl.h>
static size_t static size_t