Rootless Debug for GLES
Add the ability to enable debug layers for OpenGL ES.
This update concides with changes to framework/base to
control the enabling logic in GraphicsEnvironment.
Refer to go/rootless-gpu-debug-gles for design overview.
To learn more about creating GLES layers, refer to
https://developer.android.com/ndk/guides/
Test: cts-tradefed run singleCommand cts -m CtsGpuToolsHostTestCases
Bug: 110883880
Bug: 117515773
Change-Id: I0334cd9cd386f20bf40adac117e3144b0f76b7d3
diff --git a/libs/graphicsenv/GraphicsEnv.cpp b/libs/graphicsenv/GraphicsEnv.cpp
index 2a7d76e..3328ad7 100644
--- a/libs/graphicsenv/GraphicsEnv.cpp
+++ b/libs/graphicsenv/GraphicsEnv.cpp
@@ -18,9 +18,12 @@
#define LOG_TAG "GraphicsEnv"
#include <graphicsenv/GraphicsEnv.h>
+#include <sys/prctl.h>
+
#include <mutex>
#include <android/dlext.h>
+#include <cutils/properties.h>
#include <log/log.h>
// TODO(b/37049319) Get this from a header once one exists
@@ -46,6 +49,14 @@
return env;
}
+int GraphicsEnv::getCanLoadSystemLibraries() {
+ if (property_get_bool("ro.debuggable", false) && prctl(PR_GET_DUMPABLE, 0, 0, 0, 0)) {
+ // Return an integer value since this crosses library boundaries
+ return 1;
+ }
+ return 0;
+}
+
void GraphicsEnv::setDriverPath(const std::string path) {
if (!mDriverPath.empty()) {
ALOGV("ignoring attempt to change driver path from '%s' to '%s'",
@@ -181,4 +192,10 @@
const char* android_getAngleAppPref() {
return android::GraphicsEnv::getInstance().getAngleAppPref();
}
+const char* android_getLayerPaths() {
+ return android::GraphicsEnv::getInstance().getLayerPaths().c_str();
+}
+const char* android_getDebugLayers() {
+ return android::GraphicsEnv::getInstance().getDebugLayers().c_str();
+}
}