Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d9f0ec41 authored by Cody Northrop's avatar Cody Northrop
Browse files

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
parent 87a562ce
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ cc_library_shared {

    shared_libs: [
        "liblog",
        "libcutils",
    ],

    export_include_dirs: ["include"],
+17 −0
Original line number Diff line number Diff line
@@ -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 @@ namespace android {
    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 @@ bool android_getAngleDeveloperOptIn() {
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();
}
}
+9 −5
Original line number Diff line number Diff line
@@ -29,6 +29,8 @@ class GraphicsEnv {
public:
    static GraphicsEnv& getInstance();

    int getCanLoadSystemLibraries();

    // Set a search path for loading graphics drivers. The path is a list of
    // directories separated by ':'. A directory can be contained in a zip file
    // (drivers must be stored uncompressed and page aligned); such elements
@@ -90,6 +92,8 @@ android_namespace_t* android_getAngleNamespace();
    const char* android_getAngleAppName();
    const char* android_getAngleAppPref();
    bool android_getAngleDeveloperOptIn();
    const char* android_getLayerPaths();
    const char* android_getDebugLayers();
}

#endif // ANDROID_UI_GRAPHICS_ENV_H
+4 −0
Original line number Diff line number Diff line
@@ -140,6 +140,7 @@ cc_library_shared {
        "EGL/egl_cache.cpp",
        "EGL/egl_display.cpp",
        "EGL/egl_object.cpp",
        "EGL/egl_layers.cpp",
        "EGL/egl.cpp",
        "EGL/eglApi.cpp",
        "EGL/egl_platform_entries.cpp",
@@ -150,8 +151,11 @@ cc_library_shared {
        "libvndksupport",
        "android.hardware.configstore@1.0",
        "android.hardware.configstore-utils",
        "libbase",
        "libhidlbase",
        "libhidltransport",
        "libnativebridge",
        "libnativeloader",
        "libutils",
    ],
    static_libs: [
+9 −2
Original line number Diff line number Diff line
@@ -30,11 +30,10 @@
#include "egl_tls.h"
#include "egl_display.h"
#include "egl_object.h"
#include "egl_layers.h"
#include "CallStack.h"
#include "Loader.h"

typedef __eglMustCastToProperFunctionPointerType EGLFuncPointer;

// ----------------------------------------------------------------------------
namespace android {
// ----------------------------------------------------------------------------
@@ -196,6 +195,14 @@ static EGLBoolean egl_init_drivers_locked() {
        cnx->dso = loader.open(cnx);
    }

    // Check to see if any layers are enabled and route functions through them
    if (cnx->dso) {
        // Layers can be enabled long after the drivers have been loaded.
        // They will only be initialized once.
        LayerLoader& layer_loader(LayerLoader::getInstance());
        layer_loader.InitLayers(cnx);
    }

    return cnx->dso ? EGL_TRUE : EGL_FALSE;
}

Loading