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

Commit b22db0fd authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes Ifae9b62e,I2673d2c9

* changes:
  Only load native EGL library if using GL back-end
  Only run ANGLE rules once
parents 727bbe2d b91b989d
Loading
Loading
Loading
Loading
+25 −4
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@
#include "egl_platform_entries.h"
#include "egl_trace.h"
#include "egldefs.h"
#include <EGL/eglext_angle.h>

extern "C" {
  android_namespace_t* android_get_exported_namespace(const char*);
@@ -541,6 +542,8 @@ static void* load_angle(const char* kind, android_namespace_t* ns, egl_connectio

    if (use_angle) {
        ALOGV("User set \"Developer Options\" to force the use of ANGLE");
    } else if (cnx->angleDecided) {
        use_angle = cnx->useAngle;
    } else {
        // The "Developer Options" value wasn't set to force the use of ANGLE.  Need to temporarily
        // load ANGLE and call the updatable opt-in/out logic:
@@ -610,6 +613,7 @@ static void* load_angle(const char* kind, android_namespace_t* ns, egl_connectio
            use_angle = false;
            ALOGV("Could not temporarily-load the ANGLE opt-in/out logic, cannot use ANGLE.");
        }
        cnx->angleDecided = true;
    }
    if (use_angle) {
        so = load_angle_from_namespace(kind, ns);
@@ -618,13 +622,30 @@ static void* load_angle(const char* kind, android_namespace_t* ns, egl_connectio
    if (so) {
        ALOGV("Loaded ANGLE %s library for %s (instead of native)",
              kind, app_name ? app_name : "nullptr");
        property_get("debug.angle.backend", prop, "UNSET");
        ALOGV("ANGLE's backend set to %s", prop);
        property_get("debug.hwui.renderer", prop, "UNSET");
        ALOGV("Skia's renderer set to %s", prop);
        cnx->useAngle = true;
        // Find and load vendor libEGL for ANGLE
        if (!cnx->vendorEGL) {

        EGLint angleBackendDefault = EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE;

        char prop[PROPERTY_VALUE_MAX];
        property_get("debug.angle.backend", prop, "0");
        switch (atoi(prop)) {
            case 1:
                ALOGV("%s: Requesting OpenGLES back-end", __FUNCTION__);
                angleBackendDefault = EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE;
                break;
            case 2:
                ALOGV("%s: Requesting Vulkan back-end", __FUNCTION__);
                angleBackendDefault = EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE;
                break;
            default:
                break;
        }

        cnx->angleBackend = angleBackendDefault;
        if (!cnx->vendorEGL && (cnx->angleBackend == EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE)) {
            // Find and load vendor libEGL for ANGLE's GL back-end to use.
            cnx->vendorEGL = load_system_driver("EGL");
        }
        return so;
+3 −48
Original line number Diff line number Diff line
@@ -128,56 +128,10 @@ EGLDisplay egl_display_t::getFromNativeDisplay(EGLNativeDisplayType disp,
    return sDisplay[uintptr_t(disp)].getPlatformDisplay(disp, attrib_list);
}

static bool addAnglePlatformAttributes(egl_connection_t* const cnx, const EGLAttrib* attrib_list,
static bool addAnglePlatformAttributes(egl_connection_t* const cnx,
                                       std::vector<EGLAttrib>& attrs) {
    intptr_t vendorEGL = (intptr_t)cnx->vendorEGL;

    EGLint angleBackendDefault = EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE;
    if (attrib_list) {
        while (*attrib_list != EGL_NONE) {
            EGLAttrib attr = *attrib_list++;
            EGLAttrib value = *attrib_list++;
            if (attr == EGL_PLATFORM_ANGLE_TYPE_ANGLE) {
                switch (value) {
                    case EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE:
                        angleBackendDefault = EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE;
                        break;
                    case EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE:
                    case EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE:
                        angleBackendDefault = value;
                        break;
                    default:
                        ALOGW("Invalid EGL_PLATFORM_ANGLE_TYPE_ANGLE attribute: 0x%" PRIxPTR,
                              value);
                        break;
                }
            }
        }
    }

    // Allow debug property to override application's
    char prop[PROPERTY_VALUE_MAX];
    property_get("debug.angle.backend", prop, "0");
    switch (atoi(prop)) {
        case 1:
            ALOGV("addAnglePlatformAttributes: Requesting OpenGLES back-end");
            angleBackendDefault = EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE;
            break;
        case 2:
            ALOGV("addAnglePlatformAttributes: Requesting Vulkan back-end");
            angleBackendDefault = EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE;
            break;
        default:
            break;
    }

    if (cnx->angleBackend == 0) {
        // Haven't been initialized yet, so set it.
        cnx->angleBackend = angleBackendDefault;
    } else if (cnx->angleBackend != angleBackendDefault) {
        return false;
    }

    attrs.reserve(4 * 2);

    attrs.push_back(EGL_PLATFORM_ANGLE_TYPE_ANGLE);
@@ -186,6 +140,7 @@ static bool addAnglePlatformAttributes(egl_connection_t* const cnx, const EGLAtt
    switch (cnx->angleBackend) {
        case EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE:
            ALOGV("%s: Requesting Vulkan ANGLE back-end", __FUNCTION__);
            char prop[PROPERTY_VALUE_MAX];
            property_get("debug.angle.validation", prop, "0");
            attrs.push_back(EGL_PLATFORM_ANGLE_DEBUG_LAYERS_ENABLED_ANGLE);
            attrs.push_back(atoi(prop));
@@ -260,7 +215,7 @@ static EGLDisplay getPlatformDisplayAngle(EGLNativeDisplayType display, egl_conn
            }
        }

        if (!addAnglePlatformAttributes(cnx, attrib_list, attrs)) {
        if (!addAnglePlatformAttributes(cnx, attrs)) {
            ALOGE("eglGetDisplay(%p) failed: Mismatch display request", display);
            *error = EGL_BAD_PARAMETER;
            return EGL_NO_DISPLAY;
+1 −0
Original line number Diff line number Diff line
@@ -76,6 +76,7 @@ struct egl_connection_t {
    void*               libGles1;
    void*               libGles2;

    bool                angleDecided;
    bool                useAngle;
    EGLint              angleBackend;
    void*               vendorEGL;