diff --git a/android/_build.bat b/android/_build.bat index b73d4347..8f9e1126 100644 --- a/android/_build.bat +++ b/android/_build.bat @@ -9,7 +9,11 @@ if NOT EXIST %1 ( call _setup.bat del _setup.bat ) - call build %2 + IF EXIST build.py ( + python build.py %2 + ) else ( + call build %2 + ) IF EXIST vulkan%1.apk ( if "%2" == "-deploy" ( echo deploying to device diff --git a/android/build-all.bat b/android/build-all.bat index 8697ac50..4ed809d2 100644 --- a/android/build-all.bat +++ b/android/build-all.bat @@ -39,4 +39,5 @@ call _build deferredshadows %1 call _build indirectdraw %1 call _build texturemipmapgen %1 call _build texture3d %1 -call _build specializationconstants %1 \ No newline at end of file +call _build specializationconstants %1 +call _build subpasses %1 \ No newline at end of file diff --git a/android/subpasses/.gitignore b/android/subpasses/.gitignore new file mode 100644 index 00000000..7a5d249c --- /dev/null +++ b/android/subpasses/.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/subpasses/AndroidManifest.xml b/android/subpasses/AndroidManifest.xml new file mode 100644 index 00000000..680e6914 --- /dev/null +++ b/android/subpasses/AndroidManifest.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/android/subpasses/build.py b/android/subpasses/build.py new file mode 100644 index 00000000..b88d7fac --- /dev/null +++ b/android/subpasses/build.py @@ -0,0 +1,54 @@ +import os +import shutil +import subprocess +import sys +import glob + +APK_NAME = "vulkanSubpasses" +SHADER_DIR = "subpasses" +ASSETS_MODELS = ["samplebuilding.dae", "samplebuilding_glass.dae"] +ASSETS_TEXTURES = ["colored_glass_bc3.ktx"] + +if subprocess.call("ndk-build", shell=True) == 0: + print("Build successful") + + # Assets + if not os.path.exists("./assets"): + os.makedirs("./assets") + + # Shaders + # Base + if not os.path.exists("./assets/shaders/base"): + os.makedirs("./assets/shaders/base") + for file in glob.glob("../../data/shaders/base/*.spv"): + shutil.copy(file, "./assets/shaders/base") + # Sample + if not os.path.exists("./assets/shaders/%s" % SHADER_DIR): + os.makedirs("./assets/shaders/%s" % SHADER_DIR) + for file in glob.glob("../../data/shaders/%s/*.spv" %SHADER_DIR): + shutil.copy(file, "./assets/shaders/%s" % SHADER_DIR) + # Textures + if not os.path.exists("./assets/textures"): + os.makedirs("./assets/textures") + for file in ASSETS_TEXTURES: + shutil.copy("../../data/textures/%s" % file, "./assets/textures") + # Models + if not os.path.exists("./assets/models"): + os.makedirs("./assets/models") + for file in ASSETS_MODELS: + shutil.copy("../../data/models/%s" % file, "./assets/models") + + # Icon + if not os.path.exists("./res/drawable"): + os.makedirs("./res/drawable") + shutil.copy("../../android/images/icon.png", "./res/drawable") + + if subprocess.call("ant debug -Dout.final.file=%s.apk" % APK_NAME, shell=True) == 0: + if len(sys.argv) > 1: + if sys.argv[1] == "-deploy": + if subprocess.call("adb install -r %s.apk" % APK_NAME, shell=True) != 0: + print("Could not deploy to device!") + else: + print("Error during build process!") +else: + print("Error building project!") diff --git a/android/subpasses/jni/Android.mk b/android/subpasses/jni/Android.mk new file mode 100644 index 00000000..2c3b57a3 --- /dev/null +++ b/android/subpasses/jni/Android.mk @@ -0,0 +1,48 @@ +LOCAL_PATH := $(call my-dir)/../../subpasses + +# 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 := vulkanSubpasses + +PROJECT_FILES := $(wildcard $(LOCAL_PATH)/../../subpasses/*.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/subpasses/jni/Application.mk b/android/subpasses/jni/Application.mk new file mode 100644 index 00000000..62020feb --- /dev/null +++ b/android/subpasses/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 2d349331..b5310792 100644 --- a/android/uninstall-all.bat +++ b/android/uninstall-all.bat @@ -46,6 +46,7 @@ adb uninstall de.saschawillems.vulkanIndirectdraw adb uninstall de.saschawillems.vulkanTexturemipmapgen adb uninstall de.saschawillems.vulkanTexture3d adb uninstall de.saschawillems.vulkanSpecializationconstants +adb uninstall de.saschawillems.vulkanSubpasses goto finish :exit