[Scummvm-git-logs] scummvm master -> 79c30639793777a465dd57023fbb60b82093e144

sev- noreply at scummvm.org
Sun Aug 13 10:58:49 UTC 2023


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
3b1465120a ANDROID: Fix build
79c3063979 ANDROID: Improve CPU detection


Commit: 3b1465120ac7c090c13ee5e21103217fe599da09
    https://github.com/scummvm/scummvm/commit/3b1465120ac7c090c13ee5e21103217fe599da09
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2023-08-13T12:58:45+02:00

Commit Message:
ANDROID: Fix build

cpu-features needs to be compiled by us

Changed paths:
    backends/platform/android/module.mk
    configure


diff --git a/backends/platform/android/module.mk b/backends/platform/android/module.mk
index 8da89718f70..3cf43db6197 100644
--- a/backends/platform/android/module.mk
+++ b/backends/platform/android/module.mk
@@ -9,6 +9,16 @@ MODULE_OBJS := \
 	snprintf.o \
 	touchcontrols.o
 
+ifdef NEED_ANDROID_CPUFEATURES
+MODULE_OBJS += \
+	cpu-features.o
+$(MODULE)/android.o: CXXFLAGS += "-I$(ANDROID_NDK_ROOT)/sources/android/cpufeatures"
+# We don't configure a C compiler, use a C++ one in C mode
+$(MODULE)/cpu-features.o: $(ANDROID_NDK_ROOT)/sources/android/cpufeatures/cpu-features.c
+	$(QUIET)$(MKDIR) $(*D)
+	$(QUIET_CXX)$(CXX) $(CXXFLAGS) $(CPPFLAGS) -x c -std=c99 -c $(<) -o $@
+endif
+
 # We don't use rules.mk but rather manually update OBJS and MODULE_DIRS.
 MODULE_OBJS := $(addprefix $(MODULE)/, $(MODULE_OBJS))
 OBJS := $(MODULE_OBJS) $(OBJS)
diff --git a/configure b/configure
index 861ec5176b6..3946eba12a8 100755
--- a/configure
+++ b/configure
@@ -2106,6 +2106,15 @@ if test "$_host_os" = android; then
 		append_var LDFLAGS "-target ${_android_target}"
 	fi
 
+	case $_host_cpu in
+	aarch64)
+		add_line_to_config_mk 'NEED_ANDROID_CPUFEATURES = 1'
+		;;
+	arm|i686|x86_64)
+		add_line_to_config_mk 'NEED_ANDROID_CPUFEATURES = 1'
+		;;
+	esac
+
 	# These values can get overriden below by environments variables
 	_ar="$_android_toolchain/bin/$_ar"
 	_as="$_android_toolchain/bin/$_as"


Commit: 79c30639793777a465dd57023fbb60b82093e144
    https://github.com/scummvm/scummvm/commit/79c30639793777a465dd57023fbb60b82093e144
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2023-08-13T12:58:45+02:00

Commit Message:
ANDROID: Improve CPU detection

CPU architecture can be determined at build time.
Add support for x86 extensions.

Changed paths:
    backends/platform/android/android.cpp
    backends/platform/android/android.h
    configure


diff --git a/backends/platform/android/android.cpp b/backends/platform/android/android.cpp
index 4bd53188c34..3ff014a21c3 100644
--- a/backends/platform/android/android.cpp
+++ b/backends/platform/android/android.cpp
@@ -49,11 +49,14 @@
 #include <sys/time.h>
 #include <sys/resource.h>
 #include <sys/system_properties.h>
-#include <cpu-features.h>
 #include <time.h>
 #include <unistd.h>
 #include <dlfcn.h>
 
+#if defined(__arm__) || defined(__x86_64__) || defined(__i386__)
+#include <cpu-features.h>
+#endif
+
 #include "backends/platform/android/android.h"
 #include "backends/platform/android/jni-android.h"
 #include "backends/fs/android/android-fs.h"
@@ -445,13 +448,6 @@ void OSystem_Android::initBackend() {
 		}
 	}
 
-	// Quickly figure out if arm NEON is supported
-	if (android_getCpuFamily() == ANDROID_CPU_FAMILY_ARM) {
-		_neonSupport = android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON;
-	} else {
-		_neonSupport = android_getCpuFamily() == ANDROID_CPU_FAMILY_ARM64;
-	}
-
 	// Warning: ConfMan.registerDefault() can be used for a Session of ScummVM
 	//          but:
 	//              1. The values will NOT persist to storage
@@ -645,7 +641,52 @@ bool OSystem_Android::hasFeature(Feature f) {
 	if (f == kFeatureOpenGLForGame) return true;
 	/* GLES2 always supports shaders */
 	if (f == kFeatureShadersForGame) return true;
-	if (f == kFeatureCpuNEON) return _neonSupport;
+
+	if (f == kFeatureCpuNEON) {
+#if defined(__aarch64__)
+		// ARMv8 mandates NEON
+		return true;
+#elif defined(__arm__)
+		return (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON);
+#else
+		return false;
+#endif
+	}
+
+	if (f == kFeatureCpuSSE2) {
+#if defined(__x86_64__)
+		// x86_64 mandates SSE2
+		return true;
+#elif defined(__i386__) && defined(__SSE2__)
+		// Android NDK mandates SSE2 starting with Jellybean but some people tried hacks
+		// Allow to disable SSE2
+		return true;
+#else
+		return false;
+#endif
+	}
+
+	if (f == kFeatureCpuSSE41) {
+#if defined(__x86_64__) || defined(__i386__)
+		return (android_getCpuFeatures() & ANDROID_CPU_X86_FEATURE_SSE4_1);
+#else
+		return false;
+#endif
+	}
+
+	if (f == kFeatureCpuAVX2) {
+#if defined(__x86_64__)
+		// No AVX2 in 32-bits
+		return (android_getCpuFeatures() & ANDROID_CPU_X86_FEATURE_AVX2);
+#else
+		return false;
+#endif
+	}
+
+	if (f == kFeatureCpuAltivec) {
+		return false;
+	}
+
 	return ModularGraphicsBackend::hasFeature(f);
 }
 
diff --git a/backends/platform/android/android.h b/backends/platform/android/android.h
index 6fe584d7211..34a976078e4 100644
--- a/backends/platform/android/android.h
+++ b/backends/platform/android/android.h
@@ -177,8 +177,6 @@ private:
 	mutable void *_gles2DL;
 #endif
 
-	bool _neonSupport; // bool for whether or not arm NEON is supported
-
 	static void *timerThreadFunc(void *arg);
 	static void *audioThreadFunc(void *arg);
 	Common::String getSystemProperty(const char *name) const;
diff --git a/configure b/configure
index 3946eba12a8..53863104981 100755
--- a/configure
+++ b/configure
@@ -2108,7 +2108,6 @@ if test "$_host_os" = android; then
 
 	case $_host_cpu in
 	aarch64)
-		add_line_to_config_mk 'NEED_ANDROID_CPUFEATURES = 1'
 		;;
 	arm|i686|x86_64)
 		add_line_to_config_mk 'NEED_ANDROID_CPUFEATURES = 1'




More information about the Scummvm-git-logs mailing list