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

Commit 53238bdd authored by Mathias Agopian's avatar Mathias Agopian
Browse files

integrate some OpenGL ES changes back from master_gl in preparation of opening GLES to the NDK.

parent 91a67808
Loading
Loading
Loading
Loading
+43 −25
Original line number Original line Diff line number Diff line
@@ -478,22 +478,38 @@ struct extention_map_t {
};
};


static const extention_map_t gExtentionMap[] = {
static const extention_map_t gExtentionMap[] = {
    { "glDrawTexsOES",              (void(*)())&glDrawTexsOES },
    { "glDrawTexsOES",
    { "glDrawTexiOES",              (void(*)())&glDrawTexiOES },
            (__eglMustCastToProperFunctionPointerType)&glDrawTexsOES },
    { "glDrawTexfOES",              (void(*)())&glDrawTexfOES },
    { "glDrawTexiOES",
    { "glDrawTexxOES",              (void(*)())&glDrawTexxOES },
            (__eglMustCastToProperFunctionPointerType)&glDrawTexiOES },
    { "glDrawTexsvOES",             (void(*)())&glDrawTexsvOES },
    { "glDrawTexfOES",
    { "glDrawTexivOES",             (void(*)())&glDrawTexivOES },
            (__eglMustCastToProperFunctionPointerType)&glDrawTexfOES },
    { "glDrawTexfvOES",             (void(*)())&glDrawTexfvOES },
    { "glDrawTexxOES",
    { "glDrawTexxvOES",             (void(*)())&glDrawTexxvOES },
            (__eglMustCastToProperFunctionPointerType)&glDrawTexxOES },
    { "glQueryMatrixxOES",          (void(*)())&glQueryMatrixxOES },
    { "glDrawTexsvOES",
    { "glClipPlanef",               (void(*)())&glClipPlanef },
            (__eglMustCastToProperFunctionPointerType)&glDrawTexsvOES },
    { "glClipPlanex",               (void(*)())&glClipPlanex },
    { "glDrawTexivOES",
    { "glBindBuffer",               (void(*)())&glBindBuffer },
            (__eglMustCastToProperFunctionPointerType)&glDrawTexivOES },
    { "glBufferData",               (void(*)())&glBufferData },
    { "glDrawTexfvOES",
    { "glBufferSubData",            (void(*)())&glBufferSubData },
            (__eglMustCastToProperFunctionPointerType)&glDrawTexfvOES },
    { "glDeleteBuffers",            (void(*)())&glDeleteBuffers },
    { "glDrawTexxvOES",
    { "glGenBuffers",               (void(*)())&glGenBuffers },
            (__eglMustCastToProperFunctionPointerType)&glDrawTexxvOES },
    { "glQueryMatrixxOES",
            (__eglMustCastToProperFunctionPointerType)&glQueryMatrixxOES },
    { "glClipPlanef",
            (__eglMustCastToProperFunctionPointerType)&glClipPlanef },
    { "glClipPlanex",
            (__eglMustCastToProperFunctionPointerType)&glClipPlanex },
    { "glBindBuffer",
            (__eglMustCastToProperFunctionPointerType)&glBindBuffer },
    { "glBufferData",
            (__eglMustCastToProperFunctionPointerType)&glBufferData },
    { "glBufferSubData",
            (__eglMustCastToProperFunctionPointerType)&glBufferSubData },
    { "glDeleteBuffers",
            (__eglMustCastToProperFunctionPointerType)&glDeleteBuffers },
    { "glGenBuffers",
            (__eglMustCastToProperFunctionPointerType)&glGenBuffers },
};
};


/* 
/* 
@@ -1299,6 +1315,8 @@ EGLBoolean eglMakeCurrent( EGLDisplay dpy, EGLSurface draw,
        }
        }
    }
    }


    // TODO: call connect / disconnect on the surface

    ogles_context_t* gl = (ogles_context_t*)ctx;
    ogles_context_t* gl = (ogles_context_t*)ctx;
    if (makeCurrent(gl) == 0) {
    if (makeCurrent(gl) == 0) {
        if (ctx) {
        if (ctx) {
+0 −1
Original line number Original line Diff line number Diff line
@@ -35,7 +35,6 @@ include $(CLEAR_VARS)


LOCAL_SRC_FILES:= 	\
LOCAL_SRC_FILES:= 	\
	GLES_CM/gl.cpp.arm 		\
	GLES_CM/gl.cpp.arm 		\
	GLES_CM/gl_logger.cpp 	\
#
#


LOCAL_SHARED_LIBRARIES += libcutils libutils libui libEGL
LOCAL_SHARED_LIBRARIES += libcutils libutils libui libEGL
+90 −48
Original line number Original line Diff line number Diff line
@@ -14,7 +14,7 @@
 ** limitations under the License.
 ** limitations under the License.
 */
 */


#define LOG_TAG "GLLogger"
#define LOG_TAG "libEGL"


#include <ctype.h>
#include <ctype.h>
#include <string.h>
#include <string.h>
@@ -69,9 +69,9 @@ private:


struct egl_display_t : public egl_object_t<'_dpy'>
struct egl_display_t : public egl_object_t<'_dpy'>
{
{
    EGLDisplay  dpys[2];
    EGLDisplay  dpys[IMPL_NUM_DRIVERS_IMPLEMENTATIONS];
    EGLConfig*  configs[2];
    EGLConfig*  configs[IMPL_NUM_DRIVERS_IMPLEMENTATIONS];
    EGLint      numConfigs[2];
    EGLint      numConfigs[IMPL_NUM_DRIVERS_IMPLEMENTATIONS];
    EGLint      numTotalConfigs;
    EGLint      numTotalConfigs;
    char const* extensionsString;
    char const* extensionsString;
    volatile int32_t refs;
    volatile int32_t refs;
@@ -81,7 +81,7 @@ struct egl_display_t : public egl_object_t<'_dpy'>
        char const * clientApi;
        char const * clientApi;
        char const * extensions;
        char const * extensions;
    };
    };
    strings_t   queryString[2];
    strings_t   queryString[IMPL_NUM_DRIVERS_IMPLEMENTATIONS];
};
};


struct egl_surface_t : public egl_object_t<'_srf'>
struct egl_surface_t : public egl_object_t<'_srf'>
@@ -156,7 +156,7 @@ static char const * const egl_names[] = {


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


egl_connection_t gEGLImpl[2];
egl_connection_t gEGLImpl[IMPL_NUM_DRIVERS_IMPLEMENTATIONS];
static egl_display_t gDisplay[NUM_DISPLAYS];
static egl_display_t gDisplay[NUM_DISPLAYS];
static pthread_mutex_t gThreadLocalStorageKeyMutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t gThreadLocalStorageKeyMutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_key_t gEGLThreadLocalStorageKey = -1;
static pthread_key_t gEGLThreadLocalStorageKey = -1;
@@ -278,29 +278,56 @@ void *load_driver(const char* driver, gl_hooks_t* hooks)
            driver, dlerror());
            driver, dlerror());


    if (dso) {
    if (dso) {
        void** curr;
        // first find the symbol for eglGetProcAddress
        
        typedef __eglMustCastToProperFunctionPointerType (*getProcAddressType)(
                const char*);
        
        getProcAddressType getProcAddress = 
            (getProcAddressType)dlsym(dso, "eglGetProcAddress");
        
        LOGE_IF(!getProcAddress, 
                "can't find eglGetProcAddress() in %s", driver);        
        
        __eglMustCastToProperFunctionPointerType* curr;
        char const * const * api;
        char const * const * api;
        gl_hooks_t::gl_t* gl = &hooks->gl;

        curr = (void**)gl;
        gl_hooks_t::egl_t* egl = &hooks->egl;
        api = gl_names;
        curr = (__eglMustCastToProperFunctionPointerType*)egl;
        api = egl_names;
        while (*api) {
        while (*api) {
            void* f = dlsym(dso, *api);
            char const * name = *api;
            //LOGD("<%s> @ 0x%p", *api, f);
            __eglMustCastToProperFunctionPointerType f = 
                (__eglMustCastToProperFunctionPointerType)dlsym(dso, name);
            if (f == NULL) {
            if (f == NULL) {
                //LOGW("<%s> not found in %s", *api, driver);
                // couldn't find the entry-point, use eglGetProcAddress()
                f = (void*)gl_unimplemented;
                f = getProcAddress(name);
                if (f == NULL) {
                    f = (__eglMustCastToProperFunctionPointerType)0;
                }
            }
            }
            *curr++ = f;
            *curr++ = f;
            api++;
            api++;
        }
        }
        gl_hooks_t::egl_t* egl = &hooks->egl;
        
        curr = (void**)egl;
        gl_hooks_t::gl_t* gl = &hooks->gl;
        api = egl_names;
        curr = (__eglMustCastToProperFunctionPointerType*)gl;
        api = gl_names;
        while (*api) {
        while (*api) {
            void* f = dlsym(dso, *api);
            char const * name = *api;
            // if the function starts with '__' it's a special case that
            // uses a wrapper. skip the '__' when looking into the real lib.
            if (name[0] == '_' && name[1] == '_') {
                name += 2;
            }
            __eglMustCastToProperFunctionPointerType f = 
                (__eglMustCastToProperFunctionPointerType)dlsym(dso, name);
            if (f == NULL) {
                // couldn't find the entry-point, use eglGetProcAddress()
                f = getProcAddress(name);
                if (f == NULL) {
                if (f == NULL) {
                //LOGW("<%s> not found in %s", *api, driver);
                    f = (__eglMustCastToProperFunctionPointerType)gl_unimplemented;
                f = (void*)0;
                }
            }
            }
            *curr++ = f;
            *curr++ = f;
            api++;
            api++;
@@ -429,18 +456,19 @@ egl_display_t* get_display(EGLDisplay dpy)
    return (index >= NUM_DISPLAYS) ? NULL : &gDisplay[index];
    return (index >= NUM_DISPLAYS) ? NULL : &gDisplay[index];
}
}


template<typename NATIVE, typename EGL>
static inline NATIVE* egl_to_native_cast(EGL arg) {
    return reinterpret_cast<NATIVE*>(arg);
}

static inline
static inline
egl_surface_t* get_surface(EGLSurface surface)
egl_surface_t* get_surface(EGLSurface surface) {   
{
    return egl_to_native_cast<egl_surface_t>(surface);
    egl_surface_t* s = (egl_surface_t *)surface;
    return s;
}
}


static inline
static inline
egl_context_t* get_context(EGLContext context)
egl_context_t* get_context(EGLContext context) {
{
    return egl_to_native_cast<egl_context_t>(context);
    egl_context_t* c = (egl_context_t *)context;
    return c;
}
}


static egl_connection_t* validate_display_config(
static egl_connection_t* validate_display_config(
@@ -451,7 +479,7 @@ static egl_connection_t* validate_display_config(
    if (!dp) return setError(EGL_BAD_DISPLAY, (egl_connection_t*)NULL);
    if (!dp) return setError(EGL_BAD_DISPLAY, (egl_connection_t*)NULL);


    impl = uintptr_t(config)>>24;
    impl = uintptr_t(config)>>24;
    if (uint32_t(impl) >= 2) {
    if (uint32_t(impl) >= IMPL_NUM_DRIVERS_IMPLEMENTATIONS) {
        return setError(EGL_BAD_CONFIG, (egl_connection_t*)NULL);
        return setError(EGL_BAD_CONFIG, (egl_connection_t*)NULL);
    } 
    } 
    index = uintptr_t(config) & 0xFFFFFF;
    index = uintptr_t(config) & 0xFFFFFF;
@@ -491,13 +519,8 @@ static EGLBoolean validate_display_surface(EGLDisplay dpy, EGLSurface surface)
    return EGL_TRUE;
    return EGL_TRUE;
}
}


// ----------------------------------------------------------------------------
}; // namespace android
// ----------------------------------------------------------------------------


using namespace android;
EGLDisplay egl_init_displays(NativeDisplayType display)

EGLDisplay eglGetDisplay(NativeDisplayType display)
{
{
    if (sEarlyInitState) {
    if (sEarlyInitState) {
        return EGL_NO_DISPLAY;
        return EGL_NO_DISPLAY;
@@ -573,6 +596,18 @@ EGLDisplay eglGetDisplay(NativeDisplayType display)
    return dpy;
    return dpy;
}
}



// ----------------------------------------------------------------------------
}; // namespace android
// ----------------------------------------------------------------------------

using namespace android;

EGLDisplay eglGetDisplay(NativeDisplayType display)
{
    return egl_init_displays(display);
}

// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// Initialization
// Initialization
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
@@ -594,7 +629,7 @@ EGLBoolean eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor)
    // build our own extension string first, based on the extension we know
    // build our own extension string first, based on the extension we know
    // and the extension supported by our client implementation
    // and the extension supported by our client implementation
    dp->extensionsString = strdup(gExtensionString);
    dp->extensionsString = strdup(gExtensionString);
    for (int i=0 ; i<2 ; i++) {
    for (int i=0 ; i<IMPL_NUM_DRIVERS_IMPLEMENTATIONS ; i++) {
        egl_connection_t* const cnx = &gEGLImpl[i];
        egl_connection_t* const cnx = &gEGLImpl[i];
        cnx->major = -1;
        cnx->major = -1;
        cnx->minor = -1;
        cnx->minor = -1;
@@ -624,7 +659,7 @@ EGLBoolean eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor)
    }
    }


    EGLBoolean res = EGL_FALSE;
    EGLBoolean res = EGL_FALSE;
    for (int i=0 ; i<2 ; i++) {
    for (int i=0 ; i<IMPL_NUM_DRIVERS_IMPLEMENTATIONS ; i++) {
        egl_connection_t* const cnx = &gEGLImpl[i];
        egl_connection_t* const cnx = &gEGLImpl[i];
        if (cnx->dso && cnx->major>=0 && cnx->minor>=0) {
        if (cnx->dso && cnx->major>=0 && cnx->minor>=0) {
            EGLint n;
            EGLint n;
@@ -663,7 +698,7 @@ EGLBoolean eglTerminate(EGLDisplay dpy)
        return EGL_TRUE;
        return EGL_TRUE;
        
        
    EGLBoolean res = EGL_FALSE;
    EGLBoolean res = EGL_FALSE;
    for (int i=0 ; i<2 ; i++) {
    for (int i=0 ; i<IMPL_NUM_DRIVERS_IMPLEMENTATIONS ; i++) {
        egl_connection_t* const cnx = &gEGLImpl[i];
        egl_connection_t* const cnx = &gEGLImpl[i];
        if (cnx->dso) {
        if (cnx->dso) {
            cnx->hooks->egl.eglTerminate(dp->dpys[i]);
            cnx->hooks->egl.eglTerminate(dp->dpys[i]);
@@ -706,7 +741,7 @@ EGLBoolean eglGetConfigs( EGLDisplay dpy,
        return EGL_TRUE;
        return EGL_TRUE;
    }
    }
    GLint n = 0;
    GLint n = 0;
    for (int j=0 ; j<2 ; j++) {
    for (int j=0 ; j<IMPL_NUM_DRIVERS_IMPLEMENTATIONS ; j++) {
        for (int i=0 ; i<dp->numConfigs[j] && config_size ; i++) {
        for (int i=0 ; i<dp->numConfigs[j] && config_size ; i++) {
            *configs++ = MAKE_CONFIG(j, i);
            *configs++ = MAKE_CONFIG(j, i);
            config_size--;
            config_size--;
@@ -794,7 +829,7 @@ EGLBoolean eglChooseConfig( EGLDisplay dpy, const EGLint *attrib_list,
        return res;
        return res;
    }
    }


    for (int i=0 ; i<2 ; i++) {
    for (int i=0 ; i<IMPL_NUM_DRIVERS_IMPLEMENTATIONS ; i++) {
        egl_connection_t* const cnx = &gEGLImpl[i];
        egl_connection_t* const cnx = &gEGLImpl[i];
        if (cnx->dso) {
        if (cnx->dso) {
            if (cnx->hooks->egl.eglChooseConfig(
            if (cnx->hooks->egl.eglChooseConfig(
@@ -1107,7 +1142,7 @@ EGLBoolean eglWaitNative(EGLint engine)
EGLint eglGetError(void)
EGLint eglGetError(void)
{
{
    EGLint result = EGL_SUCCESS;
    EGLint result = EGL_SUCCESS;
    for (int i=0 ; i<2 ; i++) {
    for (int i=0 ; i<IMPL_NUM_DRIVERS_IMPLEMENTATIONS ; i++) {
        EGLint err = EGL_SUCCESS;
        EGLint err = EGL_SUCCESS;
        egl_connection_t* const cnx = &gEGLImpl[i];
        egl_connection_t* const cnx = &gEGLImpl[i];
        if (cnx->dso)
        if (cnx->dso)
@@ -1120,8 +1155,15 @@ EGLint eglGetError(void)
    return result;
    return result;
}
}


void (*eglGetProcAddress(const char *procname))()
__eglMustCastToProperFunctionPointerType eglGetProcAddress(const char *procname)
{
{
    // eglGetProcAddress() could be the very first function called
    // in which case we must make sure we've initialized ourselves, this
    // happens the first time egl_get_display() is called.
    
    if (egl_init_displays(EGL_DEFAULT_DISPLAY) == EGL_NO_DISPLAY)
        return NULL;

    __eglMustCastToProperFunctionPointerType addr;
    __eglMustCastToProperFunctionPointerType addr;
    addr = findProcAddress(procname, gExtentionMap, NELEM(gExtentionMap));
    addr = findProcAddress(procname, gExtentionMap, NELEM(gExtentionMap));
    if (addr) return addr;
    if (addr) return addr;
@@ -1133,7 +1175,7 @@ void (*eglGetProcAddress(const char *procname))()
    
    
    addr = 0;
    addr = 0;
    int slot = -1;
    int slot = -1;
    for (int i=0 ; i<2 ; i++) {
    for (int i=0 ; i<IMPL_NUM_DRIVERS_IMPLEMENTATIONS ; i++) {
        egl_connection_t* const cnx = &gEGLImpl[i];
        egl_connection_t* const cnx = &gEGLImpl[i];
        if (cnx->dso) {
        if (cnx->dso) {
            if (cnx->hooks->egl.eglGetProcAddress) {
            if (cnx->hooks->egl.eglGetProcAddress) {
@@ -1266,7 +1308,7 @@ EGLBoolean eglSwapInterval(EGLDisplay dpy, EGLint interval)
    if (!dp) return setError(EGL_BAD_DISPLAY, EGL_FALSE);
    if (!dp) return setError(EGL_BAD_DISPLAY, EGL_FALSE);


    EGLBoolean res = EGL_TRUE;
    EGLBoolean res = EGL_TRUE;
    for (int i=0 ; i<2 ; i++) {
    for (int i=0 ; i<IMPL_NUM_DRIVERS_IMPLEMENTATIONS ; i++) {
        egl_connection_t* const cnx = &gEGLImpl[i];
        egl_connection_t* const cnx = &gEGLImpl[i];
        if (cnx->dso) {
        if (cnx->dso) {
            if (cnx->hooks->egl.eglSwapInterval) {
            if (cnx->hooks->egl.eglSwapInterval) {
@@ -1309,7 +1351,7 @@ EGLBoolean eglBindAPI(EGLenum api)
{
{
    // bind this API on all EGLs
    // bind this API on all EGLs
    EGLBoolean res = EGL_TRUE;
    EGLBoolean res = EGL_TRUE;
    for (int i=0 ; i<2 ; i++) {
    for (int i=0 ; i<IMPL_NUM_DRIVERS_IMPLEMENTATIONS ; i++) {
        egl_connection_t* const cnx = &gEGLImpl[i];
        egl_connection_t* const cnx = &gEGLImpl[i];
        if (cnx->dso) {
        if (cnx->dso) {
            if (cnx->hooks->egl.eglBindAPI) {
            if (cnx->hooks->egl.eglBindAPI) {
@@ -1324,7 +1366,7 @@ EGLBoolean eglBindAPI(EGLenum api)


EGLenum eglQueryAPI(void)
EGLenum eglQueryAPI(void)
{
{
    for (int i=0 ; i<2 ; i++) {
    for (int i=0 ; i<IMPL_NUM_DRIVERS_IMPLEMENTATIONS ; i++) {
        egl_connection_t* const cnx = &gEGLImpl[i];
        egl_connection_t* const cnx = &gEGLImpl[i];
        if (cnx->dso) {
        if (cnx->dso) {
            if (cnx->hooks->egl.eglQueryAPI) {
            if (cnx->hooks->egl.eglQueryAPI) {
@@ -1340,7 +1382,7 @@ EGLenum eglQueryAPI(void)


EGLBoolean eglReleaseThread(void)
EGLBoolean eglReleaseThread(void)
{
{
    for (int i=0 ; i<2 ; i++) {
    for (int i=0 ; i<IMPL_NUM_DRIVERS_IMPLEMENTATIONS ; i++) {
        egl_connection_t* const cnx = &gEGLImpl[i];
        egl_connection_t* const cnx = &gEGLImpl[i];
        if (cnx->dso) {
        if (cnx->dso) {
            if (cnx->hooks->egl.eglReleaseThread) {
            if (cnx->hooks->egl.eglReleaseThread) {
+17 −9
Original line number Original line Diff line number Diff line
@@ -29,6 +29,7 @@
#include <cutils/properties.h>
#include <cutils/properties.h>


#include "hooks.h"
#include "hooks.h"
#include "egl_impl.h"


using namespace android;
using namespace android;


@@ -57,13 +58,6 @@ void glVertexPointerBounds(GLint size, GLenum type,
// Actual GL entry-points
// Actual GL entry-points
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------


#if GL_LOGGER
#   include "gl_logger.h"
#   define GL_LOGGER_IMPL(_x) _x
#else
#   define GL_LOGGER_IMPL(_x)
#endif

#undef API_ENTRY
#undef API_ENTRY
#undef CALL_GL_API
#undef CALL_GL_API
#undef CALL_GL_API_RETURN
#undef CALL_GL_API_RETURN
@@ -96,16 +90,15 @@ void glVertexPointerBounds(GLint size, GLenum type,


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


#endif
#endif



extern "C" {
extern "C" {
#include "gl_api.in"
#include "gl_api.in"
}
}
@@ -114,3 +107,18 @@ extern "C" {
#undef CALL_GL_API
#undef CALL_GL_API
#undef CALL_GL_API_RETURN
#undef CALL_GL_API_RETURN



/*
 * These GL calls are special because they need to EGL to retrieve some
 * informations before they can execute.
 */


void glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image)
{
}

void glEGLImageTargetRenderbufferStorageOES(GLenum target, GLeglImageOES image)
{
}
+494 −340

File changed.

Preview size limit exceeded, changes collapsed.

Loading