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

Commit f234ad00 authored by Mathias Agopian's avatar Mathias Agopian Committed by Android (Google) Code Review
Browse files

Merge changes I7a6b9db4,Ib579f580

* changes:
  EGLConfig is now not remaped to an internal EGLConfig
  remove multiplexing of multiple EGL implementation
parents b49329ac 7773c435
Loading
Loading
Loading
Loading
+16 −39
Original line number Diff line number Diff line
@@ -118,12 +118,6 @@ status_t Loader::driver_t::set(void* hnd, int32_t api)

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

Loader::entry_t::entry_t(int dpy, int impl, const char* tag)
    : dpy(dpy), impl(impl), tag(tag) {
}

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

Loader::Loader()
{
    char line[256];
@@ -131,8 +125,9 @@ Loader::Loader()

    /* Special case for GLES emulation */
    if (checkGlesEmulationStatus() == 0) {
        ALOGD("Emulator without GPU support detected. Fallback to software renderer.");
        gConfig.add( entry_t(0, 0, "android") );
        ALOGD("Emulator without GPU support detected. "
              "Fallback to software renderer.");
        mDriverTag.setTo("android");
        return;
    }

@@ -141,14 +136,16 @@ Loader::Loader()
    if (cfg == NULL) {
        // default config
        ALOGD("egl.cfg not found, using default config");
        gConfig.add( entry_t(0, 0, "android") );
        mDriverTag.setTo("android");
    } else {
        while (fgets(line, 256, cfg)) {
            int dpy;
            int impl;
            int dpy, impl;
            if (sscanf(line, "%u %u %s", &dpy, &impl, tag) == 3) {
                //ALOGD(">>> %u %u %s", dpy, impl, tag);
                gConfig.add( entry_t(dpy, impl, tag) );
                // We only load the h/w accelerated implementation
                if (tag != String8("android")) {
                    mDriverTag = tag;
                }
            }
        }
        fclose(cfg);
@@ -160,30 +157,12 @@ Loader::~Loader()
    GLTrace_stop();
}

const char* Loader::getTag(int dpy, int impl)
void* Loader::open(egl_connection_t* cnx)
{
    const Vector<entry_t>& cfgs(gConfig);    
    const size_t c = cfgs.size();
    for (size_t i=0 ; i<c ; i++) {
        if (dpy == cfgs[i].dpy)
            if (impl == cfgs[i].impl)
                return cfgs[i].tag.string();
    }
    return 0;
}

void* Loader::open(EGLNativeDisplayType display, int impl, egl_connection_t* cnx)
{
    /*
     * TODO: if we don't find display/0, then use 0/0
     * (0/0 should always work)
     */
    
    void* dso;
    int index = int(display);
    driver_t* hnd = 0;
    
    char const* tag = getTag(index, impl);
    char const* tag = mDriverTag.string();
    if (tag) {
        dso = load_driver("GLES", tag, cnx, EGL | GLESv1_CM | GLESv2);
        if (dso) {
@@ -193,16 +172,14 @@ void* Loader::open(EGLNativeDisplayType display, int impl, egl_connection_t* cnx
            dso = load_driver("EGL", tag, cnx, EGL);
            if (dso) {
                hnd = new driver_t(dso);

                // TODO: make this more automated
                hnd->set( load_driver("GLESv1_CM", tag, cnx, GLESv1_CM), GLESv1_CM );

                hnd->set( load_driver("GLESv2",    tag, cnx, GLESv2),    GLESv2 );
            }
        }
    }

    LOG_FATAL_IF(!index && !impl && !hnd, 
    LOG_FATAL_IF(!index && !hnd,
            "couldn't find the default OpenGL ES implementation "
            "for default display");
    
@@ -221,7 +198,7 @@ void Loader::init_api(void* dso,
        __eglMustCastToProperFunctionPointerType* curr, 
        getProcAddressType getProcAddress) 
{
    const size_t SIZE = 256;
    const ssize_t SIZE = 256;
    char scrap[SIZE];
    while (*api) {
        char const * name = *api;
@@ -326,14 +303,14 @@ void *Loader::load_driver(const char* kind, const char *tag,
    if (mask & GLESv1_CM) {
        init_api(dso, gl_names,
            (__eglMustCastToProperFunctionPointerType*)
                &cnx->hooks[GLESv1_INDEX]->gl,
                &cnx->hooks[egl_connection_t::GLESv1_INDEX]->gl,
            getProcAddress);
    }

    if (mask & GLESv2) {
      init_api(dso, gl_names,
            (__eglMustCastToProperFunctionPointerType*)
                &cnx->hooks[GLESv2_INDEX]->gl,
                &cnx->hooks[egl_connection_t::GLESv2_INDEX]->gl,
            getProcAddress);
    }
    
+2 −13
Original line number Diff line number Diff line
@@ -24,7 +24,6 @@
#include <utils/Errors.h>
#include <utils/Singleton.h>
#include <utils/String8.h>
#include <utils/Vector.h>

#include <EGL/egl.h>

@@ -53,23 +52,13 @@ class Loader : public Singleton<Loader>
        void* dso[3];
    };
    
    struct entry_t {
        entry_t() { }
        entry_t(int dpy, int impl, const char* tag);
        int dpy;
        int impl;
        String8 tag;
    };

    Vector<entry_t> gConfig;    
    String8 mDriverTag;
    getProcAddressType getProcAddress;
    
    const char* getTag(int dpy, int impl);

public:
    ~Loader();
    
    void* open(EGLNativeDisplayType display, int impl, egl_connection_t* cnx);
    void* open(egl_connection_t* cnx);
    status_t close(void* driver);
    
private:
+13 −33
Original line number Diff line number Diff line
@@ -48,8 +48,8 @@
namespace android {
// ----------------------------------------------------------------------------

egl_connection_t gEGLImpl[IMPL_NUM_IMPLEMENTATIONS];
gl_hooks_t gHooks[2][IMPL_NUM_IMPLEMENTATIONS];
egl_connection_t gEGLImpl;
gl_hooks_t gHooks[2];
gl_hooks_t gHooksNoContext;
pthread_key_t gGLWrapperKey = -1;

@@ -187,16 +187,13 @@ egl_display_t* validate_display(EGLDisplay dpy) {
    return dp;
}

egl_connection_t* validate_display_config(EGLDisplay dpy, EGLConfig config,
egl_connection_t* validate_display_config(EGLDisplay dpy, EGLConfig,
        egl_display_t const*& dp) {
    dp = validate_display(dpy);
    if (!dp)
        return (egl_connection_t*) NULL;

    if (intptr_t(config) >= dp->numTotalConfigs) {
        return setError(EGL_BAD_CONFIG, (egl_connection_t*)NULL);
    }
    egl_connection_t* const cnx = &gEGLImpl[dp->configs[intptr_t(config)].impl];
    egl_connection_t* const cnx = &gEGLImpl;
    if (cnx->dso == 0) {
        return setError(EGL_BAD_CONFIG, (egl_connection_t*)NULL);
    }
@@ -228,7 +225,7 @@ EGLImageKHR egl_get_image_for_current_context(EGLImageKHR image)
    // EGL.

    egl_image_t const * const i = get_image(image);
    return i->images[c->impl];
    return i->image;
}

// ----------------------------------------------------------------------------
@@ -266,34 +263,17 @@ static EGLBoolean egl_init_drivers_locked() {
    // get our driver loader
    Loader& loader(Loader::getInstance());

    // dynamically load all our EGL implementations
    egl_connection_t* cnx;

    cnx = &gEGLImpl[IMPL_SOFTWARE];
    if (cnx->dso == 0) {
        cnx->hooks[GLESv1_INDEX] = &gHooks[GLESv1_INDEX][IMPL_SOFTWARE];
        cnx->hooks[GLESv2_INDEX] = &gHooks[GLESv2_INDEX][IMPL_SOFTWARE];
        cnx->dso = loader.open(EGL_DEFAULT_DISPLAY, 0, cnx);
    }

    cnx = &gEGLImpl[IMPL_HARDWARE];
    // dynamically load our EGL implementation
    egl_connection_t* cnx = &gEGLImpl;
    if (cnx->dso == 0) {
        char value[PROPERTY_VALUE_MAX];
        property_get("debug.egl.hw", value, "1");
        if (atoi(value) != 0) {
            cnx->hooks[GLESv1_INDEX] = &gHooks[GLESv1_INDEX][IMPL_HARDWARE];
            cnx->hooks[GLESv2_INDEX] = &gHooks[GLESv2_INDEX][IMPL_HARDWARE];
            cnx->dso = loader.open(EGL_DEFAULT_DISPLAY, 1, cnx);
        } else {
            ALOGD("3D hardware acceleration is disabled");
        }
    }

    if (!gEGLImpl[IMPL_SOFTWARE].dso && !gEGLImpl[IMPL_HARDWARE].dso) {
        return EGL_FALSE;
        cnx->hooks[egl_connection_t::GLESv1_INDEX] =
                &gHooks[egl_connection_t::GLESv1_INDEX];
        cnx->hooks[egl_connection_t::GLESv2_INDEX] =
                &gHooks[egl_connection_t::GLESv2_INDEX];
        cnx->dso = loader.open(cnx);
    }

    return EGL_TRUE;
    return cnx->dso ? EGL_TRUE : EGL_FALSE;
}

static pthread_mutex_t sInitDriverMutex = PTHREAD_MUTEX_INITIALIZER;
+126 −355

File changed.

Preview size limit exceeded, changes collapsed.

+27 −27
Original line number Diff line number Diff line
@@ -83,10 +83,10 @@ egl_cache_t* egl_cache_t::get() {

void egl_cache_t::initialize(egl_display_t *display) {
    Mutex::Autolock lock(mMutex);
    for (int i = 0; i < IMPL_NUM_IMPLEMENTATIONS; i++) {
        egl_connection_t* const cnx = &gEGLImpl[i];

    egl_connection_t* const cnx = &gEGLImpl;
    if (cnx->dso && cnx->major >= 0 && cnx->minor >= 0) {
            const char* exts = display->disp[i].queryString.extensions;
        const char* exts = display->disp.queryString.extensions;
        size_t bcExtLen = strlen(BC_EXT_STR);
        size_t extsLen = strlen(exts);
        bool equal = !strcmp(BC_EXT_STR, exts);
@@ -101,12 +101,12 @@ void egl_cache_t::initialize(egl_display_t *display) {
                            cnx->egl.eglGetProcAddress(
                                    "eglSetBlobCacheFuncsANDROID"));
            if (eglSetBlobCacheFuncsANDROID == NULL) {
                    ALOGE("EGL_ANDROID_blob_cache advertised by display %d, "
                            "but unable to get eglSetBlobCacheFuncsANDROID", i);
                    continue;
                ALOGE("EGL_ANDROID_blob_cache advertised, "
                        "but unable to get eglSetBlobCacheFuncsANDROID");
                return;
            }

                eglSetBlobCacheFuncsANDROID(display->disp[i].dpy,
            eglSetBlobCacheFuncsANDROID(display->disp.dpy,
                    android::setBlob, android::getBlob);
            EGLint err = cnx->egl.eglGetError();
            if (err != EGL_SUCCESS) {
@@ -115,7 +115,7 @@ void egl_cache_t::initialize(egl_display_t *display) {
            }
        }
    }
    }

    mInitialized = true;
}

Loading