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

Commit 031a1dc6 authored by Android (Google) Code Review's avatar Android (Google) Code Review
Browse files

Merge change I6fc56997 into eclair

* changes:
  fix [2187212] add support for GLESv2 dispatch based on TLS
parents 76f95d0c 618fa109
Loading
Loading
Loading
Loading
+14 −12
Original line number Original line Diff line number Diff line
@@ -128,7 +128,7 @@ const char* Loader::getTag(int dpy, int impl)
    return 0;
    return 0;
}
}


void* Loader::open(EGLNativeDisplayType display, int impl, gl_hooks_t* hooks)
void* Loader::open(EGLNativeDisplayType display, int impl, egl_connection_t* cnx)
{
{
    /*
    /*
     * TODO: if we don't find display/0, then use 0/0
     * TODO: if we don't find display/0, then use 0/0
@@ -144,22 +144,22 @@ void* Loader::open(EGLNativeDisplayType display, int impl, gl_hooks_t* hooks)
    char const* tag = getTag(index, impl);
    char const* tag = getTag(index, impl);
    if (tag) {
    if (tag) {
        snprintf(path, PATH_MAX, format, "GLES", tag);
        snprintf(path, PATH_MAX, format, "GLES", tag);
        dso = load_driver(path, hooks, EGL | GLESv1_CM | GLESv2);
        dso = load_driver(path, cnx, EGL | GLESv1_CM | GLESv2);
        if (dso) {
        if (dso) {
            hnd = new driver_t(dso);
            hnd = new driver_t(dso);
        } else {
        } else {
            // Always load EGL first
            // Always load EGL first
            snprintf(path, PATH_MAX, format, "EGL", tag);
            snprintf(path, PATH_MAX, format, "EGL", tag);
            dso = load_driver(path, hooks, EGL);
            dso = load_driver(path, cnx, EGL);
            if (dso) {
            if (dso) {
                hnd = new driver_t(dso);
                hnd = new driver_t(dso);


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


                snprintf(path, PATH_MAX, format, "GLESv2", tag);
                snprintf(path, PATH_MAX, format, "GLESv2", tag);
                hnd->set( load_driver(path, hooks, GLESv2), GLESv2 );
                hnd->set( load_driver(path, cnx, GLESv2), GLESv2 );
            }
            }
        }
        }
    }
    }
@@ -223,7 +223,7 @@ void Loader::init_api(void* dso,
}
}


void *Loader::load_driver(const char* driver_absolute_path,
void *Loader::load_driver(const char* driver_absolute_path,
        gl_hooks_t* hooks, uint32_t mask)
        egl_connection_t* cnx, uint32_t mask)
{
{
    if (access(driver_absolute_path, R_OK)) {
    if (access(driver_absolute_path, R_OK)) {
        // this happens often, we don't want to log an error
        // this happens often, we don't want to log an error
@@ -245,7 +245,7 @@ void *Loader::load_driver(const char* driver_absolute_path,
        LOGE_IF(!getProcAddress, 
        LOGE_IF(!getProcAddress, 
                "can't find eglGetProcAddress() in %s", driver_absolute_path);
                "can't find eglGetProcAddress() in %s", driver_absolute_path);


        gl_hooks_t::egl_t* egl = &hooks->egl;
        egl_t* egl = &cnx->egl;
        __eglMustCastToProperFunctionPointerType* curr =
        __eglMustCastToProperFunctionPointerType* curr =
            (__eglMustCastToProperFunctionPointerType*)egl;
            (__eglMustCastToProperFunctionPointerType*)egl;
        char const * const * api = egl_names;
        char const * const * api = egl_names;
@@ -267,13 +267,15 @@ void *Loader::load_driver(const char* driver_absolute_path,
    
    
    if (mask & GLESv1_CM) {
    if (mask & GLESv1_CM) {
        init_api(dso, gl_names,
        init_api(dso, gl_names,
                (__eglMustCastToProperFunctionPointerType*)&hooks->gl, 
            (__eglMustCastToProperFunctionPointerType*)
                &cnx->hooks[GLESv1_INDEX]->gl,
            getProcAddress);
            getProcAddress);
    }
    }


    if (mask & GLESv2) {
    if (mask & GLESv2) {
      init_api(dso, gl2_names, 
      init_api(dso, gl_names,
            (__eglMustCastToProperFunctionPointerType*)&hooks->gl2, 
            (__eglMustCastToProperFunctionPointerType*)
                &cnx->hooks[GLESv2_INDEX]->gl,
            getProcAddress);
            getProcAddress);
    }
    }
    
    
+3 −3
Original line number Original line Diff line number Diff line
@@ -32,7 +32,7 @@
namespace android {
namespace android {
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------


struct gl_hooks_t;
struct egl_connection_t;


class Loader : public Singleton<Loader>
class Loader : public Singleton<Loader>
{
{
@@ -69,12 +69,12 @@ class Loader : public Singleton<Loader>
public:
public:
    ~Loader();
    ~Loader();
    
    
    void* open(EGLNativeDisplayType display, int impl, gl_hooks_t* hooks);
    void* open(EGLNativeDisplayType display, int impl, egl_connection_t* cnx);
    status_t close(void* driver);
    status_t close(void* driver);
    
    
private:
private:
    Loader();
    Loader();
    void *load_driver(const char* driver, gl_hooks_t* hooks, uint32_t mask);
    void *load_driver(const char* driver, egl_connection_t* cnx, uint32_t mask);


    static __attribute__((noinline))
    static __attribute__((noinline))
    void init_api(void* dso, 
    void init_api(void* dso, 
+120 −100

File changed.

Preview size limit exceeded, changes collapsed.

+1 −8
Original line number Original line Diff line number Diff line
@@ -41,14 +41,7 @@ void gl_unimplemented() {
#define EGL_ENTRY(_r, _api, ...) #_api,
#define EGL_ENTRY(_r, _api, ...) #_api,


char const * const gl_names[] = {
char const * const gl_names[] = {
    #include "GLES_CM/gl_entries.in"
    #include "entries.in"
    #include "GLES_CM/glext_entries.in"
    NULL
};

char const * const gl2_names[] = {
    #include "GLES2/gl2_entries.in"
    #include "GLES2/gl2ext_entries.in"
    NULL
    NULL
};
};


+3 −3
Original line number Original line Diff line number Diff line
@@ -53,7 +53,7 @@ using namespace android;
            "bx    lr                 \n"                       \
            "bx    lr                 \n"                       \
            :                                                   \
            :                                                   \
            : [tls] "J"(TLS_SLOT_OPENGL_API*4),                 \
            : [tls] "J"(TLS_SLOT_OPENGL_API*4),                 \
              [api] "J"(__builtin_offsetof(gl_hooks_t, gl2._api))    \
              [api] "J"(__builtin_offsetof(gl_hooks_t, gl._api))    \
            :                                                   \
            :                                                   \
            );
            );
    
    
@@ -66,11 +66,11 @@ using namespace android;
    #define API_ENTRY(_api) _api
    #define API_ENTRY(_api) _api


    #define CALL_GL_API(_api, ...)                                       \
    #define CALL_GL_API(_api, ...)                                       \
        gl_hooks_t::gl2_t const * const _c = &getGlThreadSpecific()->gl2; \
        gl_hooks_t::gl_t const * const _c = &getGlThreadSpecific()->gl;  \
        _c->_api(__VA_ARGS__)
        _c->_api(__VA_ARGS__)
    
    
    #define CALL_GL_API_RETURN(_api, ...)                                \
    #define CALL_GL_API_RETURN(_api, ...)                                \
        gl_hooks_t::gl2_t const * const _c = &getGlThreadSpecific()->gl2; \
        gl_hooks_t::gl_t const * const _c = &getGlThreadSpecific()->gl;  \
        return _c->_api(__VA_ARGS__)
        return _c->_api(__VA_ARGS__)


#endif
#endif
Loading