From fda21f96c993652891e82e026c0e4d3aa3e8da7c Mon Sep 17 00:00:00 2001 From: saschawillems Date: Sun, 27 Nov 2016 13:44:10 +0100 Subject: [PATCH] Added compute N-Body Android build files --- android/build-all.bat | 1 + android/computenbody/.gitignore | 10 +++++ android/computenbody/AndroidManifest.xml | 27 +++++++++++++ android/computenbody/build.bat | 23 ++++++++++++ android/computenbody/jni/Android.mk | 48 ++++++++++++++++++++++++ android/computenbody/jni/Application.mk | 5 +++ android/uninstall-all.bat | 1 + computenbody/computenbody.cpp | 2 +- 8 files changed, 116 insertions(+), 1 deletion(-) create mode 100644 android/computenbody/.gitignore create mode 100644 android/computenbody/AndroidManifest.xml create mode 100644 android/computenbody/build.bat create mode 100644 android/computenbody/jni/Android.mk create mode 100644 android/computenbody/jni/Application.mk diff --git a/android/build-all.bat b/android/build-all.bat index 9597499d..cffa4f24 100644 --- a/android/build-all.bat +++ b/android/build-all.bat @@ -1,5 +1,6 @@ call _build geometryshader %1 call _build computeparticles %1 +call _build computenbody %1 call _build computeshader %1 call _build computecullandlod %1 call _build parallaxmapping %1 diff --git a/android/computenbody/.gitignore b/android/computenbody/.gitignore new file mode 100644 index 00000000..7a5d249c --- /dev/null +++ b/android/computenbody/.gitignore @@ -0,0 +1,10 @@ +/assets/ +/res/ +/bin/ +/libs/ +/obj/ +/build.xml +/local.properties +/project.properties +/proguard-project.txt +*.apk \ No newline at end of file diff --git a/android/computenbody/AndroidManifest.xml b/android/computenbody/AndroidManifest.xml new file mode 100644 index 00000000..254409f1 --- /dev/null +++ b/android/computenbody/AndroidManifest.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/android/computenbody/build.bat b/android/computenbody/build.bat new file mode 100644 index 00000000..fefb7a4b --- /dev/null +++ b/android/computenbody/build.bat @@ -0,0 +1,23 @@ +cd jni +call ndk-build +if %ERRORLEVEL% EQU 0 ( + cd.. + + mkdir "assets\shaders\base" + xcopy "..\..\data\shaders\base\*.spv" "assets\shaders\base" /Y + + mkdir "assets\shaders\computenbody" + xcopy "..\..\data\shaders\computenbody\*.spv" "assets\shaders\computenbody" /Y + + mkdir "assets\textures" + xcopy "..\..\data\textures\particle01_rgba.ktx" "assets\textures" /Y + xcopy "..\..\data\textures\particle_gradient_rgba.ktx" "assets\textures" /Y + + mkdir "res\drawable" + xcopy "..\..\android\images\icon.png" "res\drawable" /Y + + call ant debug -Dout.final.file=vulkanComputenbody.apk +) ELSE ( + echo error : ndk-build failed with errors! + cd.. +) diff --git a/android/computenbody/jni/Android.mk b/android/computenbody/jni/Android.mk new file mode 100644 index 00000000..fbfa9f7b --- /dev/null +++ b/android/computenbody/jni/Android.mk @@ -0,0 +1,48 @@ +LOCAL_PATH := $(call my-dir)/../../computenbody + +# assimp + +include $(CLEAR_VARS) + +LOCAL_MODULE := assimp +LOCAL_SRC_FILES := $(LOCAL_PATH)/../../libs/assimp/$(TARGET_ARCH_ABI)/libassimp.a +include $(PREBUILT_STATIC_LIBRARY) + +# vulkan example + +DATADIR := $(LOCAL_PATH)/../../data + +include $(CLEAR_VARS) + +LOCAL_MODULE := vulkanComputenbody + +PROJECT_FILES := $(wildcard $(LOCAL_PATH)/../../computenbody/*.cpp) +PROJECT_FILES += $(wildcard $(LOCAL_PATH)/../../base/*.cpp) + +LOCAL_CPPFLAGS := -std=c++11 +LOCAL_CPPFLAGS += -D__STDC_LIMIT_MACROS +LOCAL_CPPFLAGS += -DVK_NO_PROTOTYPES +LOCAL_CPPFLAGS += -DVK_USE_PLATFORM_ANDROID_KHR + +LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../external/ +LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../external/glm +LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../external/gli +LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../external/assimp +LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../base/ +#LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../base/android + +LOCAL_SRC_FILES := $(PROJECT_FILES) + +LOCAL_LDLIBS := -landroid -llog -lz + +LOCAL_DISABLE_FORMAT_STRING_CHECKS := true +LOCAL_DISABLE_FATAL_LINKER_WARNINGS := true + +LOCAL_STATIC_LIBRARIES += android_native_app_glue +LOCAL_STATIC_LIBRARIES += cpufeatures +LOCAL_STATIC_LIBRARIES += libassimp + +include $(BUILD_SHARED_LIBRARY) + +$(call import-module, android/native_app_glue) +$(call import-module, android/cpufeatures) diff --git a/android/computenbody/jni/Application.mk b/android/computenbody/jni/Application.mk new file mode 100644 index 00000000..62020feb --- /dev/null +++ b/android/computenbody/jni/Application.mk @@ -0,0 +1,5 @@ +APP_PLATFORM := android-19 +APP_ABI := armeabi-v7a +APP_STL := c++_static +APP_CPPFLAGS := -std=c++11 +NDK_TOOLCHAIN_VERSION := clang diff --git a/android/uninstall-all.bat b/android/uninstall-all.bat index 1f88de4d..4b6c3585 100644 --- a/android/uninstall-all.bat +++ b/android/uninstall-all.bat @@ -7,6 +7,7 @@ goto :exit :uninstall adb uninstall de.saschawillems.vulkanGeometryshader adb uninstall de.saschawillems.vulkanComputeparticles +adb uninstall de.saschawillems.vulkanComputenbody adb uninstall de.saschawillems.vulkanComputeshader adb uninstall de.saschawillems.vulkanParallaxmapping adb uninstall de.saschawillems.vulkanBloom diff --git a/computenbody/computenbody.cpp b/computenbody/computenbody.cpp index 6bfa18dd..a48fb692 100644 --- a/computenbody/computenbody.cpp +++ b/computenbody/computenbody.cpp @@ -25,7 +25,7 @@ #define ENABLE_VALIDATION false #if defined(__ANDROID__) // Lower particle count on Android for performance reasons -#define PARTICLES_PER_ATTRACTOR 2 * 1024 +#define PARTICLES_PER_ATTRACTOR 3 * 1024 #else #define PARTICLES_PER_ATTRACTOR 4 * 1024 #endif