From 15e74c9614888d5b6acabc620e42d4e9e09cd5b1 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Tue, 28 Jun 2016 08:39:33 +0800 Subject: [PATCH] Use the first Vulkan layer path The loader will scan the current layer path once when the first valid Vulkan command call is made. To avoid confusions and data races, never set the layer path more than once. This assumes the first layer path to be the app's library search path, which should be the case. Bug: 29780602 Change-Id: Ibb9e4de95902ee89413d213d237ea4f62ea35b38 --- core/jni/android_app_ApplicationLoaders.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/core/jni/android_app_ApplicationLoaders.cpp b/core/jni/android_app_ApplicationLoaders.cpp index 24ee9591fc2f9..3e7c039e2129c 100644 --- a/core/jni/android_app_ApplicationLoaders.cpp +++ b/core/jni/android_app_ApplicationLoaders.cpp @@ -14,6 +14,8 @@ * limitations under the License. */ +#define LOG_TAG "ApplicationLoaders" + #include #include #include @@ -22,10 +24,17 @@ static void setupVulkanLayerPath_native(JNIEnv* env, jobject clazz, jobject classLoader, jstring librarySearchPath) { + android_namespace_t* ns = android::FindNamespaceByClassLoader(env, classLoader); 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); + if (loader_data.layer_path.empty()) { + loader_data.layer_path = layerPathChars.c_str(); + loader_data.app_namespace = ns; + } else { + ALOGD("ignored Vulkan layer search path %s for namespace %p", + layerPathChars.c_str(), ns); + } } static const JNINativeMethod g_methods[] = {