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 Diff line number Diff line
@@ -478,22 +478,38 @@ struct extention_map_t {
};

static const extention_map_t gExtentionMap[] = {
    { "glDrawTexsOES",              (void(*)())&glDrawTexsOES },
    { "glDrawTexiOES",              (void(*)())&glDrawTexiOES },
    { "glDrawTexfOES",              (void(*)())&glDrawTexfOES },
    { "glDrawTexxOES",              (void(*)())&glDrawTexxOES },
    { "glDrawTexsvOES",             (void(*)())&glDrawTexsvOES },
    { "glDrawTexivOES",             (void(*)())&glDrawTexivOES },
    { "glDrawTexfvOES",             (void(*)())&glDrawTexfvOES },
    { "glDrawTexxvOES",             (void(*)())&glDrawTexxvOES },
    { "glQueryMatrixxOES",          (void(*)())&glQueryMatrixxOES },
    { "glClipPlanef",               (void(*)())&glClipPlanef },
    { "glClipPlanex",               (void(*)())&glClipPlanex },
    { "glBindBuffer",               (void(*)())&glBindBuffer },
    { "glBufferData",               (void(*)())&glBufferData },
    { "glBufferSubData",            (void(*)())&glBufferSubData },
    { "glDeleteBuffers",            (void(*)())&glDeleteBuffers },
    { "glGenBuffers",               (void(*)())&glGenBuffers },
    { "glDrawTexsOES",
            (__eglMustCastToProperFunctionPointerType)&glDrawTexsOES },
    { "glDrawTexiOES",
            (__eglMustCastToProperFunctionPointerType)&glDrawTexiOES },
    { "glDrawTexfOES",
            (__eglMustCastToProperFunctionPointerType)&glDrawTexfOES },
    { "glDrawTexxOES",
            (__eglMustCastToProperFunctionPointerType)&glDrawTexxOES },
    { "glDrawTexsvOES",
            (__eglMustCastToProperFunctionPointerType)&glDrawTexsvOES },
    { "glDrawTexivOES",
            (__eglMustCastToProperFunctionPointerType)&glDrawTexivOES },
    { "glDrawTexfvOES",
            (__eglMustCastToProperFunctionPointerType)&glDrawTexfvOES },
    { "glDrawTexxvOES",
            (__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;
    if (makeCurrent(gl) == 0) {
        if (ctx) {
+0 −1
Original line number Diff line number Diff line
@@ -35,7 +35,6 @@ include $(CLEAR_VARS)

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

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

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

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

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

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 pthread_mutex_t gThreadLocalStorageKeyMutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_key_t gEGLThreadLocalStorageKey = -1;
@@ -278,29 +278,56 @@ void *load_driver(const char* driver, gl_hooks_t* hooks)
            driver, dlerror());

    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;
        gl_hooks_t::gl_t* gl = &hooks->gl;
        curr = (void**)gl;
        api = gl_names;

        gl_hooks_t::egl_t* egl = &hooks->egl;
        curr = (__eglMustCastToProperFunctionPointerType*)egl;
        api = egl_names;
        while (*api) {
            void* f = dlsym(dso, *api);
            //LOGD("<%s> @ 0x%p", *api, f);
            char const * name = *api;
            __eglMustCastToProperFunctionPointerType f = 
                (__eglMustCastToProperFunctionPointerType)dlsym(dso, name);
            if (f == NULL) {
                //LOGW("<%s> not found in %s", *api, driver);
                f = (void*)gl_unimplemented;
                // couldn't find the entry-point, use eglGetProcAddress()
                f = getProcAddress(name);
                if (f == NULL) {
                    f = (__eglMustCastToProperFunctionPointerType)0;
                }
            }
            *curr++ = f;
            api++;
        }
        gl_hooks_t::egl_t* egl = &hooks->egl;
        curr = (void**)egl;
        api = egl_names;
        
        gl_hooks_t::gl_t* gl = &hooks->gl;
        curr = (__eglMustCastToProperFunctionPointerType*)gl;
        api = gl_names;
        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) {
                //LOGW("<%s> not found in %s", *api, driver);
                f = (void*)0;
                    f = (__eglMustCastToProperFunctionPointerType)gl_unimplemented;
                }
            }
            *curr++ = f;
            api++;
@@ -429,18 +456,19 @@ egl_display_t* get_display(EGLDisplay dpy)
    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
egl_surface_t* get_surface(EGLSurface surface)
{
    egl_surface_t* s = (egl_surface_t *)surface;
    return s;
egl_surface_t* get_surface(EGLSurface surface) {   
    return egl_to_native_cast<egl_surface_t>(surface);
}

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

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);

    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);
    } 
    index = uintptr_t(config) & 0xFFFFFF;
@@ -491,13 +519,8 @@ static EGLBoolean validate_display_surface(EGLDisplay dpy, EGLSurface surface)
    return EGL_TRUE;
}

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

using namespace android;

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


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

using namespace android;

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

// ----------------------------------------------------------------------------
// 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
    // and the extension supported by our client implementation
    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];
        cnx->major = -1;
        cnx->minor = -1;
@@ -624,7 +659,7 @@ EGLBoolean eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor)
    }

    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];
        if (cnx->dso && cnx->major>=0 && cnx->minor>=0) {
            EGLint n;
@@ -663,7 +698,7 @@ EGLBoolean eglTerminate(EGLDisplay dpy)
        return EGL_TRUE;
        
    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];
        if (cnx->dso) {
            cnx->hooks->egl.eglTerminate(dp->dpys[i]);
@@ -706,7 +741,7 @@ EGLBoolean eglGetConfigs( EGLDisplay dpy,
        return EGL_TRUE;
    }
    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++) {
            *configs++ = MAKE_CONFIG(j, i);
            config_size--;
@@ -794,7 +829,7 @@ EGLBoolean eglChooseConfig( EGLDisplay dpy, const EGLint *attrib_list,
        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];
        if (cnx->dso) {
            if (cnx->hooks->egl.eglChooseConfig(
@@ -1107,7 +1142,7 @@ EGLBoolean eglWaitNative(EGLint engine)
EGLint eglGetError(void)
{
    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;
        egl_connection_t* const cnx = &gEGLImpl[i];
        if (cnx->dso)
@@ -1120,8 +1155,15 @@ EGLint eglGetError(void)
    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;
    addr = findProcAddress(procname, gExtentionMap, NELEM(gExtentionMap));
    if (addr) return addr;
@@ -1133,7 +1175,7 @@ void (*eglGetProcAddress(const char *procname))()
    
    addr = 0;
    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];
        if (cnx->dso) {
            if (cnx->hooks->egl.eglGetProcAddress) {
@@ -1266,7 +1308,7 @@ EGLBoolean eglSwapInterval(EGLDisplay dpy, EGLint interval)
    if (!dp) return setError(EGL_BAD_DISPLAY, EGL_FALSE);

    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];
        if (cnx->dso) {
            if (cnx->hooks->egl.eglSwapInterval) {
@@ -1309,7 +1351,7 @@ EGLBoolean eglBindAPI(EGLenum api)
{
    // bind this API on all EGLs
    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];
        if (cnx->dso) {
            if (cnx->hooks->egl.eglBindAPI) {
@@ -1324,7 +1366,7 @@ EGLBoolean eglBindAPI(EGLenum api)

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];
        if (cnx->dso) {
            if (cnx->hooks->egl.eglQueryAPI) {
@@ -1340,7 +1382,7 @@ EGLenum eglQueryAPI(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];
        if (cnx->dso) {
            if (cnx->hooks->egl.eglReleaseThread) {
+17 −9
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@
#include <cutils/properties.h>

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

using namespace android;

@@ -57,13 +58,6 @@ void glVertexPointerBounds(GLint size, GLenum type,
// 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 CALL_GL_API
#undef CALL_GL_API_RETURN
@@ -96,16 +90,15 @@ void glVertexPointerBounds(GLint size, GLenum type,

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

#endif


extern "C" {
#include "gl_api.in"
}
@@ -114,3 +107,18 @@ extern "C" {
#undef CALL_GL_API
#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