OSDN Git Service

vulkan: Add apk_library_dir virtual branch
authorJesse Hall <jessehall@google.com>
Fri, 9 Oct 2015 05:21:10 +0000 (22:21 -0700)
committerJesse Hall <jessehall@google.com>
Mon, 25 Jan 2016 21:49:31 +0000 (13:49 -0800)
Change-Id: Idf479bedf2e8e49612818a816084f91f074c5397
(cherry picked from commit c28bf8bf2c8514cb983fec090c90ddbf0ba43b37)

vulkan/patches/README [new file with mode: 0644]
vulkan/patches/frameworks_base-apk_library_dir/0001-Adding-plumbing-for-passing-the-lib-directory.patch [new file with mode: 0644]

diff --git a/vulkan/patches/README b/vulkan/patches/README
new file mode 100644 (file)
index 0000000..64ccf5d
--- /dev/null
@@ -0,0 +1,19 @@
+frameworks/native/vulkan/patches
+================================
+Each subdirectory corresponds to a sequence of patches. These are
+"virtual branches": we only have one shared branch, so these let us
+share experimental or auxiliary changes without disturbing the main
+branch.
+
+To apply:
+$ cd <somewhere in target git repo>
+$ git am $VULKAN_PATCHES/$PATCH_DIR/*
+
+
+frameworks_base-apk_library_dir
+-------------------------------
+This branch is for frameworks/base. It modifies the framework to
+inform the Vulkan loader, during activity startup, where the
+activity's native library directory. The loader will search this
+directory for layer libraries. Without this change, layers will only
+be loaded from a global location under /data.
diff --git a/vulkan/patches/frameworks_base-apk_library_dir/0001-Adding-plumbing-for-passing-the-lib-directory.patch b/vulkan/patches/frameworks_base-apk_library_dir/0001-Adding-plumbing-for-passing-the-lib-directory.patch
new file mode 100644 (file)
index 0000000..81022d6
--- /dev/null
@@ -0,0 +1,133 @@
+From 5c7e465f1d11bccecdc5cacce87d1fd7deeb5adb Mon Sep 17 00:00:00 2001
+From: Michael Lentine <mlentine@google.com>
+Date: Mon, 14 Sep 2015 13:28:25 -0500
+Subject: [PATCH] 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: Ie5709ac46f47c4af5c020d604a479e78745d7777
+---
+ core/java/android/app/ActivityThread.java    |  7 +++++--
+ core/java/android/view/HardwareRenderer.java | 11 +++++++++++
+ core/java/android/view/ThreadedRenderer.java |  1 +
+ core/jni/Android.mk                          |  2 ++
+ core/jni/android_view_ThreadedRenderer.cpp   | 15 +++++++++++++++
+ 5 files changed, 34 insertions(+), 2 deletions(-)
+
+diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java
+index da21eaf..76608c6 100644
+--- a/core/java/android/app/ActivityThread.java
++++ b/core/java/android/app/ActivityThread.java
+@@ -4520,8 +4520,11 @@ public final class ActivityThread {
+             } else {
+                 Log.e(TAG, "Unable to setupGraphicsSupport due to missing code-cache directory");
+             }
+-        }
+-
++        } 
++        
++        // Add the lib dir path to hardware renderer so that vulkan layers
++        // can be searched for within that directory.
++        HardwareRenderer.setLibDir(data.info.getLibDir());
+         final boolean is24Hr = "24".equals(mCoreSettings.getString(Settings.System.TIME_12_24));
+         DateFormat.set24HourTimePref(is24Hr);
+diff --git a/core/java/android/view/HardwareRenderer.java b/core/java/android/view/HardwareRenderer.java
+index 5e58250..ed99115 100644
+--- a/core/java/android/view/HardwareRenderer.java
++++ b/core/java/android/view/HardwareRenderer.java
+@@ -301,6 +301,17 @@ public abstract class HardwareRenderer {
+     }
+     /**
++     * 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);
++    }
++
++    /**
+      * Indicates that the specified hardware layer needs to be updated
+      * as soon as possible.
+      *
+diff --git a/core/java/android/view/ThreadedRenderer.java b/core/java/android/view/ThreadedRenderer.java
+index f6119e2..d3e5175 100644
+--- a/core/java/android/view/ThreadedRenderer.java
++++ b/core/java/android/view/ThreadedRenderer.java
+@@ -492,6 +492,7 @@ public class ThreadedRenderer extends HardwareRenderer {
+     }
+     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 6b07a47..438e95b 100644
+--- a/core/jni/Android.mk
++++ b/core/jni/Android.mk
+@@ -177,6 +177,7 @@ LOCAL_C_INCLUDES += \
+     $(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 \
+@@ -225,6 +226,7 @@ LOCAL_SHARED_LIBRARIES := \
+     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 47132f4..69e8ca6 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/StrongPointer.h>
+ #include <android_runtime/android_view_Surface.h>
+@@ -448,6 +449,18 @@ static void android_view_ThreadedRenderer_setupShadersDiskCache(JNIEnv* env, job
+ }
+ // ----------------------------------------------------------------------------
++// 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
+ // ----------------------------------------------------------------------------
+@@ -487,6 +500,8 @@ static JNINativeMethod gMethods[] = {
+     { "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 },
+ };
+ int register_android_view_ThreadedRenderer(JNIEnv* env) {
+-- 
+2.6.0.rc2.230.g3dd15c0
+