Add GLES specific setting for layers
This allows loading layers for GLES and Vulkan at the
same time by adding a GLES specific setting:
GPU_DEBUG_LAYERS_GLES
which mirrors the existing setting:
GPU_DEBUG_LAYERS
The Vulkan and GLES loaders now scan distinct layer
lists, correcting an issue that would prevent Vulkan
from loading when it failed to find GLES layers.
Bug: 110883880
Test: Load a GLES layer when running ANGLE with Vulkan backend
Test: cts-tradefed run singleCommand cts -m CtsGpuToolsHostTestCases
Change-Id: I370be4ce6fdde9e95989eb1f274add8b5790263e
diff --git a/core/java/android/os/GraphicsEnvironment.java b/core/java/android/os/GraphicsEnvironment.java
index 0c56d48..ab048c5 100644
--- a/core/java/android/os/GraphicsEnvironment.java
+++ b/core/java/android/os/GraphicsEnvironment.java
@@ -170,10 +170,18 @@
String layers = coreSettings.getString(Settings.Global.GPU_DEBUG_LAYERS);
- Log.i(TAG, "Debug layer list: " + layers);
+ Log.i(TAG, "Vulkan debug layer list: " + layers);
if (layers != null && !layers.isEmpty()) {
setDebugLayers(layers);
}
+
+ String layersGLES =
+ coreSettings.getString(Settings.Global.GPU_DEBUG_LAYERS_GLES);
+
+ Log.i(TAG, "GLES debug layer list: " + layersGLES);
+ if (layersGLES != null && !layersGLES.isEmpty()) {
+ setDebugLayersGLES(layersGLES);
+ }
}
}
}
@@ -424,6 +432,7 @@
private static native int getCanLoadSystemLibraries();
private static native void setLayerPaths(ClassLoader classLoader, String layerPaths);
private static native void setDebugLayers(String layers);
+ private static native void setDebugLayersGLES(String layers);
private static native void setDriverPath(String path);
private static native void setAngleInfo(String path, String appPackage, String appPref,
boolean devOptIn, FileDescriptor rulesFd,
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index 0ef56b0..a945917 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -11692,13 +11692,20 @@
public static final String ANGLE_ENABLED_APP = "angle_enabled_app";
/**
- * Ordered GPU debug layer list
+ * Ordered GPU debug layer list for Vulkan
* i.e. <layer1>:<layer2>:...:<layerN>
* @hide
*/
public static final String GPU_DEBUG_LAYERS = "gpu_debug_layers";
/**
+ * Ordered GPU debug layer list for GLES
+ * i.e. <layer1>:<layer2>:...:<layerN>
+ * @hide
+ */
+ public static final String GPU_DEBUG_LAYERS_GLES = "gpu_debug_layers_gles";
+
+ /**
* Addition app for GPU layer discovery
* @hide
*/
diff --git a/core/jni/android_os_GraphicsEnvironment.cpp b/core/jni/android_os_GraphicsEnvironment.cpp
index e64da5c..80572f3 100644
--- a/core/jni/android_os_GraphicsEnvironment.cpp
+++ b/core/jni/android_os_GraphicsEnvironment.cpp
@@ -58,12 +58,20 @@
}
}
+void setDebugLayersGLES_native(JNIEnv* env, jobject clazz, jstring layers) {
+ if (layers != nullptr) {
+ ScopedUtfChars layersChars(env, layers);
+ android::GraphicsEnv::getInstance().setDebugLayersGLES(layersChars.c_str());
+ }
+}
+
const JNINativeMethod g_methods[] = {
{ "getCanLoadSystemLibraries", "()I", reinterpret_cast<void*>(getCanLoadSystemLibraries_native) },
{ "setDriverPath", "(Ljava/lang/String;)V", reinterpret_cast<void*>(setDriverPath) },
{ "setAngleInfo", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZLjava/io/FileDescriptor;JJ)V", reinterpret_cast<void*>(setAngleInfo_native) },
{ "setLayerPaths", "(Ljava/lang/ClassLoader;Ljava/lang/String;)V", reinterpret_cast<void*>(setLayerPaths_native) },
{ "setDebugLayers", "(Ljava/lang/String;)V", reinterpret_cast<void*>(setDebugLayers_native) },
+ { "setDebugLayersGLES", "(Ljava/lang/String;)V", reinterpret_cast<void*>(setDebugLayersGLES_native) },
};
const char* const kGraphicsEnvironmentName = "android/os/GraphicsEnvironment";
diff --git a/core/proto/android/providers/settings/global.proto b/core/proto/android/providers/settings/global.proto
index 47dbc07..3072977 100644
--- a/core/proto/android/providers/settings/global.proto
+++ b/core/proto/android/providers/settings/global.proto
@@ -394,13 +394,16 @@
// App allowed to load GPU debug layers.
optional SettingProto debug_app = 1;
- // Ordered GPU debug layer list
+ // Ordered GPU debug layer list for Vulkan
// i.e. <layer1>:<layer2>:...:<layerN>
optional SettingProto debug_layers = 2 [ (android.privacy).dest = DEST_AUTOMATIC ];
// App will load ANGLE instead of native GLES drivers.
optional SettingProto angle_enabled_app = 3;
// App that can provide layer libraries.
optional SettingProto debug_layer_app = 4;
+ // Ordered GPU debug layer list for GLES
+ // i.e. <layer1>:<layer2>:...:<layerN>
+ optional SettingProto debug_layers_gles = 5;
}
optional Gpu gpu = 59;
diff --git a/core/tests/coretests/src/android/provider/SettingsBackupTest.java b/core/tests/coretests/src/android/provider/SettingsBackupTest.java
index 182f189..c298770 100644
--- a/core/tests/coretests/src/android/provider/SettingsBackupTest.java
+++ b/core/tests/coretests/src/android/provider/SettingsBackupTest.java
@@ -451,6 +451,7 @@
Settings.Global.ENABLE_GPU_DEBUG_LAYERS,
Settings.Global.GPU_DEBUG_APP,
Settings.Global.GPU_DEBUG_LAYERS,
+ Settings.Global.GPU_DEBUG_LAYERS_GLES,
Settings.Global.ANGLE_ENABLED_APP,
Settings.Global.GPU_DEBUG_LAYER_APP,
Settings.Global.ENABLE_GNSS_RAW_MEAS_FULL_TRACKING,