Adding plumbing for passing the lib directory.
Added call in handleBindApplication which will pass the library path into
HardwareRender which then passes it to libvulkan through ThreadedRenderer's
jni interface.
Change-Id: I7dc1fec9c7a1566716a4501a0d5697ea94e57b53
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java
index 99c275c..00c11d3 100644
--- a/core/java/android/app/ActivityThread.java
+++ b/core/java/android/app/ActivityThread.java
@@ -5082,6 +5082,10 @@
}
}
+ // Add the lib dir path to hardware renderer so that vulkan layers
+ // can be searched for within that directory.
+ ThreadedRenderer.setLibDir(data.info.getLibDir());
+
// Install the Network Security Config Provider. This must happen before the application
// code is loaded to prevent issues with instances of TLS objects being created before
// the provider is installed.
diff --git a/core/java/android/view/ThreadedRenderer.java b/core/java/android/view/ThreadedRenderer.java
index 78a63a6..8b06ecf 100644
--- a/core/java/android/view/ThreadedRenderer.java
+++ b/core/java/android/view/ThreadedRenderer.java
@@ -252,6 +252,17 @@
}
/**
+ * Sets the library directory to use as a search path for vulkan layers.
+ *
+ * @param libDir A directory that contains vulkan layers
+ *
+ * @hide
+ */
+ public static void setLibDir(String libDir) {
+ ThreadedRenderer.setupVulkanLayerPath(libDir);
+ }
+
+ /**
* Creates a hardware renderer using OpenGL.
*
* @param translucent True if the surface is translucent, false otherwise
@@ -979,6 +990,7 @@
}
static native void setupShadersDiskCache(String cacheFile);
+ static native void setupVulkanLayerPath(String layerPath);
private static native void nSetAtlas(long nativeProxy, GraphicBuffer buffer, long[] map);
private static native void nSetProcessStatsBuffer(long nativeProxy, int fd);
diff --git a/core/jni/Android.mk b/core/jni/Android.mk
index 8c4683d..ffa3fa6 100644
--- a/core/jni/Android.mk
+++ b/core/jni/Android.mk
@@ -184,6 +184,7 @@
$(LOCAL_PATH)/android/graphics \
$(LOCAL_PATH)/../../libs/hwui \
$(LOCAL_PATH)/../../../native/opengl/libs \
+ $(LOCAL_PATH)/../../../native/vulkan/include \
$(call include-path-for, bluedroid) \
$(call include-path-for, libhardware)/hardware \
$(call include-path-for, libhardware_legacy)/hardware_legacy \
@@ -233,6 +234,7 @@
libEGL \
libGLESv1_CM \
libGLESv2 \
+ libvulkan \
libETC1 \
libhardware \
libhardware_legacy \
diff --git a/core/jni/android_view_ThreadedRenderer.cpp b/core/jni/android_view_ThreadedRenderer.cpp
index edced56..8c907dd 100644
--- a/core/jni/android_view_ThreadedRenderer.cpp
+++ b/core/jni/android_view_ThreadedRenderer.cpp
@@ -27,6 +27,7 @@
#include <EGL/egl.h>
#include <EGL/eglext.h>
#include <EGL/egl_cache.h>
+#include <vulkan/vulkan_loader_data.h>
#include <utils/Looper.h>
#include <utils/RefBase.h>
@@ -618,6 +619,18 @@
}
// ----------------------------------------------------------------------------
+// Layers
+// ----------------------------------------------------------------------------
+
+static void android_view_ThreadedRenderer_setupVulkanLayerPath(JNIEnv* env, jobject clazz,
+ jstring layerPath) {
+
+ const char* layerArray = env->GetStringUTFChars(layerPath, NULL);
+ vulkan::LoaderData::GetInstance().layer_path = layerArray;
+ env->ReleaseStringUTFChars(layerPath, layerArray);
+}
+
+// ----------------------------------------------------------------------------
// JNI Glue
// ----------------------------------------------------------------------------
@@ -658,6 +671,8 @@
{ "nDumpProfileData", "([BLjava/io/FileDescriptor;)V", (void*) android_view_ThreadedRenderer_dumpProfileData },
{ "setupShadersDiskCache", "(Ljava/lang/String;)V",
(void*) android_view_ThreadedRenderer_setupShadersDiskCache },
+ { "setupVulkanLayerPath", "(Ljava/lang/String;)V",
+ (void*) android_view_ThreadedRenderer_setupVulkanLayerPath },
{ "nAddRenderNode", "(JJZ)V", (void*) android_view_ThreadedRenderer_addRenderNode},
{ "nRemoveRenderNode", "(JJ)V", (void*) android_view_ThreadedRenderer_removeRenderNode},
{ "nDrawRenderNode", "(JJ)V", (void*) android_view_ThreadedRendererd_drawRenderNode},