Move Vulkan layer path setup to ApplicationLoaders

ThreadedRenderer was never the right place for this anyway, and
ApplicationLoaders can provide both the full library search path (not
just the extracted native library dir) as well as the application loader
namespace.

Bug: 28213888
Change-Id: Ibcc0a9178da4dba6f3f3105932fdac1a1d0261af
This commit is contained in:
Dimitry Ivanov
2016-04-19 11:11:01 -07:00
committed by Jesse Hall
parent 01a89bebeb
commit 0997908c95
7 changed files with 52 additions and 32 deletions

View File

@@ -5205,10 +5205,6 @@ 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.
ThreadedRenderer.setLibDir(data.info.getLibDir());
}
// Install the Network Security Config Provider. This must happen before the application

View File

@@ -65,6 +65,8 @@ class ApplicationLoaders {
Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER);
setupVulkanLayerPath(pathClassloader, librarySearchPath);
mLoaders.put(zip, pathClassloader);
return pathClassloader;
}
@@ -76,6 +78,8 @@ class ApplicationLoaders {
}
}
private static native void setupVulkanLayerPath(ClassLoader classLoader, String librarySearchPath);
/**
* Adds a new path the classpath of the given loader.
* @throws IllegalStateException if the provided class loader is not a {@link PathClassLoader}.

View File

@@ -251,17 +251,6 @@ public final class ThreadedRenderer {
ThreadedRenderer.setupShadersDiskCache(new File(cacheDir, CACHE_PATH_SHADERS).getAbsolutePath());
}
/**
* 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.
*
@@ -980,7 +969,6 @@ public final class ThreadedRenderer {
}
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);

View File

@@ -34,6 +34,7 @@ LOCAL_SRC_FILES:= \
com_google_android_gles_jni_EGLImpl.cpp \
com_google_android_gles_jni_GLImpl.cpp.arm \
android_app_Activity.cpp \
android_app_ApplicationLoaders.cpp \
android_app_NativeActivity.cpp \
android_app_admin_SecurityLog.cpp \
android_opengl_EGL14.cpp \

View File

@@ -181,6 +181,7 @@ extern int register_android_backup_BackupHelperDispatcher(JNIEnv *env);
extern int register_android_app_backup_FullBackup(JNIEnv *env);
extern int register_android_app_Activity(JNIEnv *env);
extern int register_android_app_ActivityThread(JNIEnv *env);
extern int register_android_app_ApplicationLoaders(JNIEnv *env);
extern int register_android_app_NativeActivity(JNIEnv *env);
extern int register_android_media_RemoteDisplay(JNIEnv *env);
extern int register_android_util_jar_StrictJarFile(JNIEnv* env);
@@ -1389,6 +1390,7 @@ static const RegJNIRec gRegJNI[] = {
REG_JNI(register_android_app_backup_FullBackup),
REG_JNI(register_android_app_Activity),
REG_JNI(register_android_app_ActivityThread),
REG_JNI(register_android_app_ApplicationLoaders),
REG_JNI(register_android_app_NativeActivity),
REG_JNI(register_android_util_jar_StrictJarFile),
REG_JNI(register_android_view_InputChannel),

View File

@@ -0,0 +1,45 @@
/*
* Copyright 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <nativehelper/ScopedUtfChars.h>
#include <nativeloader/native_loader.h>
#include <vulkan/vulkan_loader_data.h>
#include "core_jni_helpers.h"
static void setupVulkanLayerPath_native(JNIEnv* env, jobject clazz,
jobject classLoader, jstring librarySearchPath) {
ScopedUtfChars layerPathChars(env, librarySearchPath);
vulkan::LoaderData& loader_data = vulkan::LoaderData::GetInstance();
loader_data.layer_path = layerPathChars.c_str();
loader_data.app_namespace = android::FindNamespaceByClassLoader(env, classLoader);
}
static const JNINativeMethod g_methods[] = {
{ "setupVulkanLayerPath", "(Ljava/lang/ClassLoader;Ljava/lang/String;)V",
reinterpret_cast<void*>(setupVulkanLayerPath_native) },
};
static const char* const kApplicationLoadersName = "android/app/ApplicationLoaders";
namespace android
{
int register_android_app_ApplicationLoaders(JNIEnv* env) {
return RegisterMethodsOrDie(env, kApplicationLoadersName, g_methods, NELEM(g_methods));
}
} // namespace android

View File

@@ -28,7 +28,6 @@
#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>
@@ -50,7 +49,6 @@
#include <renderthread/RenderProxy.h>
#include <renderthread/RenderTask.h>
#include <renderthread/RenderThread.h>
#include <Vector.h>
namespace android {
@@ -717,18 +715,6 @@ static void android_view_ThreadedRenderer_setupShadersDiskCache(JNIEnv* env, job
env->ReleaseStringUTFChars(diskCachePath, cacheArray);
}
// ----------------------------------------------------------------------------
// 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
// ----------------------------------------------------------------------------
@@ -771,8 +757,6 @@ static const 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 },
{ "nAddRenderNode", "(JJZ)V", (void*) android_view_ThreadedRenderer_addRenderNode},
{ "nRemoveRenderNode", "(JJ)V", (void*) android_view_ThreadedRenderer_removeRenderNode},
{ "nDrawRenderNode", "(JJ)V", (void*) android_view_ThreadedRendererd_drawRenderNode},