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

Commit 015ed67e authored by Courtney Goeltzenleuchter's avatar Courtney Goeltzenleuchter
Browse files

Determine EGL version

Want to indicate that egl is version 1.5 if the underlying driver
supports 1.5 or 1.4 and necessary extensions.

Test: cts-tradefed run commandAndExit cts -m CtsDeqpTestCases --module-arg 'CtsDeqpTestCases:include-filter:dEQP-EGL.*'

Bug: 80297325
Change-Id: I6eec551caa4572a4fdce43cb35c6888aeae89c79
(cherry picked from commit 4416a7015f08492fbe6aaad7d22685dc32410bd1)
parent b28648c6
Loading
Loading
Loading
Loading
+48 −2
Original line number Diff line number Diff line
@@ -46,7 +46,8 @@ namespace android {
// ----------------------------------------------------------------------------

static char const * const sVendorString     = "Android";
static char const * const sVersionString    = "1.4 Android META-EGL";
static char const* const sVersionString14 = "1.4 Android META-EGL";
static char const* const sVersionString15 = "1.5 Android META-EGL";
static char const * const sClientApiString  = "OpenGL_ES";

extern char const * const gBuiltinExtensionString;
@@ -358,7 +359,52 @@ EGLBoolean egl_display_t::initialize(EGLint *major, EGLint *minor) {

        // the query strings are per-display
        mVendorString = sVendorString;
        mVersionString = sVersionString;
        mVersionString.clear();
        cnx->driverVersion = EGL_MAKE_VERSION(1, 4, 0);
        if ((cnx->major == 1) && (cnx->minor == 5)) {
            mVersionString = sVersionString15;
            cnx->driverVersion = EGL_MAKE_VERSION(1, 5, 0);
        } else if ((cnx->major == 1) && (cnx->minor == 4)) {
            mVersionString = sVersionString14;
            // Extensions needed for an EGL 1.4 implementation to be
            // able to support EGL 1.5 functionality
            std::vector<const char*> egl15extensions = {
                    "EGL_EXT_client_extensions",
                    // "EGL_EXT_platform_base",  // implemented by EGL runtime
                    "EGL_KHR_image_base",
                    "EGL_KHR_fence_sync",
                    "EGL_KHR_wait_sync",
                    "EGL_KHR_create_context",
                    "EGL_EXT_create_context_robustness",
                    "EGL_KHR_gl_colorspace",
                    "EGL_ANDROID_native_fence_sync",
            };
            bool extensionsFound = true;
            for (const auto& name : egl15extensions) {
                extensionsFound &= findExtension(disp.queryString.extensions, name);
                ALOGV("Extension %s: %s", name,
                      findExtension(disp.queryString.extensions, name) ? "Found" : "Missing");
            }
            // NOTE: From the spec:
            // Creation of fence sync objects requires support from the bound
            // client API, and will not succeed unless the client API satisfies:
            // client API is OpenGL ES, and either the OpenGL ES version is 3.0
            // or greater, or the GL_OES_EGL_sync extension is supported.
            // We don't have a way to check the GL_EXTENSIONS string at this
            // point in the code, assume that GL_OES_EGL_sync is supported
            // because EGL_KHR_fence_sync is supported (as verified above).
            if (extensionsFound) {
                // Have everything needed to emulate EGL 1.5 so report EGL 1.5
                // to the application.
                mVersionString = sVersionString15;
                cnx->major = 1;
                cnx->minor = 5;
            }
        }
        if (mVersionString.empty()) {
            ALOGW("Unexpected driver version: %d.%d, want 1.4 or 1.5", cnx->major, cnx->minor);
            mVersionString = sVersionString14;
        }
        mClientApiString = sClientApiString;

        mExtensionString = gBuiltinExtensionString;
+4 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@

#define VERSION_MAJOR 1
#define VERSION_MINOR 4
#define EGL_MAKE_VERSION(major, minor, patch) (((major) << 22) | ((minor) << 12) | (patch))

// ----------------------------------------------------------------------------
namespace android {
@@ -36,6 +37,7 @@ const unsigned int NUM_DISPLAYS = 1;

extern char const * const platform_names[];

// clang-format off
struct egl_connection_t {
    enum {
        GLESv1_INDEX = 0,
@@ -64,6 +66,7 @@ struct egl_connection_t {
    gl_hooks_t *        hooks[2];
    EGLint              major;
    EGLint              minor;
    EGLint              driverVersion;
    egl_t               egl;

    // Functions implemented or redirected by platform libraries
@@ -77,6 +80,7 @@ struct egl_connection_t {
    EGLint              angleBackend;
    void*               vendorEGL;
};
// clang-format on

// ----------------------------------------------------------------------------