Initial addition of input blocks

This commit is contained in:
Alejandro Saucedo 2020-10-04 08:07:17 +01:00
parent 652e010895
commit a1e25fc792
13 changed files with 181 additions and 170 deletions

View file

@ -2,18 +2,10 @@ cmake_minimum_required(VERSION 3.4.1)
add_subdirectory(../../../../../../../ ${CMAKE_CURRENT_BINARY_DIR}/kompute_build)
set(ANDROID_APP_GLUE_DIR ${ANDROID_NDK}/sources/android/native_app_glue)
set(VK_ANDROID_COMMON_DIR ${ANDROID_NDK}/sources/third_party/vulkan/src/common)
set(VK_ANDROID_INCLUDE_DIR ${ANDROID_NDK}/sources/third_party/vulkan/src/include)
## build native_app_glue as a static lib
#include_directories(${ANDROID_APP_GLUE_DIR})
#add_library(app-glue STATIC
# ${ANDROID_APP_GLUE_DIR}/android_native_app_glue.c)
# build vulkan app
add_library(kompute-jni SHARED
kompute-jni.cpp)
KomputeJniNative.cpp)
include_directories(
${VK_ANDROID_COMMON_DIR}
@ -24,12 +16,8 @@ include_directories(
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 \
-DVK_USE_PLATFORM_ANDROID_KHR=1 -DKOMPUTE_DISABLE_VK_DEBUG_LAYERS=1")
#set(CMAKE_SHARED_LINKER_FLAGS
# "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate")
target_link_libraries(kompute-jni
kompute
# app-glue
log
kompute_vk_ndk_wrapper
android)

View file

@ -27,12 +27,9 @@
#include "kompute/Kompute.hpp"
// Functions interacting with Android native activity
//void android_main(struct android_app* state);
//void terminate(void);
//void handle_cmd(android_app* app, int32_t cmd);
#ifndef KOMPUTE_VK_INIT_RETRIES
#define KOMPUTE_VK_INIT_RETRIES 5
#endif
// Android log function wrappers
static const char* kTAG = "KomputeJni";
@ -44,51 +41,28 @@ static const char* kTAG = "KomputeJni";
((void)__android_log_print(ANDROID_LOG_ERROR, kTAG, __VA_ARGS__))
extern "C" {
JNIEXPORT jstring JNICALL
Java_com_ethicalml_komputejni_KomputeJni_stringFromJNI(JNIEnv *env, jobject thiz) {
#if defined(__arm__)
#if defined(__ARM_ARCH_7A__)
#if defined(__ARM_NEON__)
#if defined(__ARM_PCS_VFP)
#define ABI "armeabi-v7a/NEON (hard-float)"
#else
#define ABI "armeabi-v7a/NEON"
#endif
#else
#if defined(__ARM_PCS_VFP)
#define ABI "armeabi-v7a (hard-float)"
#else
#define ABI "armeabi-v7a"
#endif
#endif
#else
#define ABI "armeabi"
#endif
#elif defined(__i386__)
#define ABI "x86"
#elif defined(__x86_64__)
#define ABI "x86_64"
#elif defined(__mips64) /* mips64el-* toolchain defines __mips__ too */
#define ABI "mips64"
#elif defined(__mips__)
#define ABI "mips"
#elif defined(__aarch64__)
#define ABI "arm64-v8a"
#else
#define ABI "unknown"
#endif
JNIEXPORT jboolean JNICALL
Java_com_ethicalml_kompute_KomputeJni_initVulkan(JNIEnv *env, jobject thiz) {
LOGI("Initialising vulkan");
// TODO: This optionally to be initialized from Kompute
if(!InitVulkan()) {
sleep(1);
if (!InitVulkan()) {
LOGE("Vulkan is unavailable, install vulkan and re-start");
return (*env).NewStringUTF("ERROR");
uint32_t totalRetries = 0;
while (totalRetries < KOMPUTE_VK_INIT_RETRIES) {
if(InitVulkan()) {
break;
}
totalRetries++;
}
return totalRetries < KOMPUTE_VK_INIT_RETRIES;
}
JNIEXPORT jstring JNICALL
Java_com_ethicalml_kompute_KomputeJni_stringFromJNI(JNIEnv *env, jobject thiz) {
LOGI("Creating manager");
kp::Manager mgr;
@ -110,6 +84,6 @@ Java_com_ethicalml_komputejni_KomputeJni_stringFromJNI(JNIEnv *env, jobject thiz
LOGI("%f ", i);
}
return (*env).NewStringUTF("SUCCESS");
return env->NewStringUTF("Result is: ");
}
}