Major updates
authorHaegeun Park <haegeun.park@samsung.com>
Thu, 3 May 2012 07:32:24 +0000 (00:32 -0700)
committerHaegeun Park <haegeun.park@samsung.com>
Thu, 3 May 2012 07:32:24 +0000 (00:32 -0700)
  - Handled bind API
  - File could be specified for trace output (COREGL_LOG_FILE=<filename>)
  - Avoided Mali MP4 DDK surface resize bug (Solves first-scene issue of evas app)
  - Optimized API tracing module (Reduces CPU costs)
  - Fix minor bugs

src/coregl.c
src/coregl_fastpath.c
src/coregl_fastpath_egl.c
src/coregl_internal.h
src/coregl_trace.c
src/coregl_wrappath.c
src/coregl_wrappath_egl.c

index 006934d..c6c4b7b 100644 (file)
@@ -18,6 +18,7 @@ int                 trace_ctx_flag = 0;
 int                 trace_ctx_force_flag = 0;
 int                 trace_state_flag = 0;
 int                 debug_nofp = 0;
+FILE               *trace_fp = NULL;
 
 // Symbol definition for real
 #define _COREGL_SYMBOL(IS_EXTENSION, RET_TYPE, FUNC_NAME, PARAM_LIST)     RET_TYPE (*_sym_##FUNC_NAME) PARAM_LIST;
@@ -187,7 +188,7 @@ init_new_thread_state()
 
        tstate = (GLThreadState *)calloc(1, sizeof(GLThreadState));
        tstate->thread_id = get_current_thread();
-       tstate->binded_api = EGL_NONE;
+       tstate->binded_api = EGL_OPENGL_ES_API;
 
        set_current_thread_state(&ctx_list_access_mutex, tstate);
 
@@ -402,6 +403,17 @@ init_gl()
                        break;
        }
 
+       {
+               const char *output_file = NULL;
+               output_file = get_env_setting("COREGL_LOG_FILE");
+               if (strlen(output_file) > 0)
+               {
+                       trace_fp = fopen(output_file, "w");
+               }
+               if (trace_fp == NULL)
+                       trace_fp = stderr;
+       }
+
 #ifdef COREGL_TRACE_APICALL_INFO
        trace_api_flag = atoi(get_env_setting("COREGL_TRACE_API"));
 #endif
index 37a08ed..cc25d4e 100644 (file)
@@ -188,10 +188,10 @@ dump_context_states(GLGlueContext *ctx, int force_output)
                tv_last = tv_now;
        }
 
-       LOG("\n");
-       LOG("\E[0;40;34m========================================================================================================================\E[0m\n");
-       LOG("\E[0;32;1m  State info \E[1;37;1m: GlueCTX = %p\E[0m\n", ctx);
-       LOG("\E[0;40;34m========================================================================================================================\E[0m\n");
+       TRACE("\n");
+       TRACE("\E[0;40;34m========================================================================================================================\E[0m\n");
+       TRACE("\E[0;32;1m  State info \E[1;37;1m: GlueCTX = %p\E[0m\n", ctx);
+       TRACE("\E[0;40;34m========================================================================================================================\E[0m\n");
 
 #define PRINTF_CHAR_GLenum "%10d"
 #define PRINTF_CHAR_GLboolean "%10d"
@@ -213,26 +213,28 @@ dump_context_states(GLGlueContext *ctx, int force_output)
       TYPE valuedata[SIZE]; \
       TYPE *value = NULL; \
       value = valuedata; GET_STMT; value = valuedata; \
-      LOG("\E[0;37;1m %-30.30s : (\E[0m ", #NAME); \
+      TRACE("\E[0;37;1m %-30.30s : (\E[0m ", #NAME); \
       for (int i = 0; i < SIZE; i++) \
       { \
          if (i > 0) { \
             if (i % 4 == 0) \
-               LOG("\n %-30.30s     ", "");\
+               TRACE("\n %-30.30s     ", "");\
             else \
-               LOG(", "); \
+               TRACE(", "); \
          } \
-         LOG(PRINTF_CHAR(TYPE), ctx->NAME[i]); \
-         LOG("["PRINTF_CHAR(TYPE)"]", value[i]); \
+         TRACE(PRINTF_CHAR(TYPE), ctx->NAME[i]); \
+         TRACE("["PRINTF_CHAR(TYPE)"]", value[i]); \
       } \
-      LOG(" \E[0;37;1m)\E[0m\n"); \
+      TRACE(" \E[0;37;1m)\E[0m\n"); \
    }
 # include "coregl_fastpath_state.h"
 #undef GLUE_STATE
 #undef INITIAL_CTX
 
-       LOG("\E[0;40;34m========================================================================================================================\E[0m\n");
-       LOG("\n");
+       TRACE("\E[0;40;34m========================================================================================================================\E[0m\n");
+       TRACE("\n");
+
+       TRACE_END();
 
 finish:
        return;
index f01580b..835b899 100644 (file)
@@ -3,6 +3,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <sys/time.h>
+#include <execinfo.h>
 
 #ifdef COREGL_TRACE_CONTEXT_INFO
 
@@ -33,10 +34,10 @@ _dump_context_info(const char *ment, int force_output)
 
        tstate = get_current_thread_state();
 
-       LOG("\n");
-       LOG("\E[40;34m========================================================================================================================\E[0m\n");
-       LOG("\E[40;32;1m  Context info \E[1;37;1m: %s\E[0m\n", ment);
-       LOG("\E[40;34m========================================================================================================================\E[0m\n");
+       TRACE("\n");
+       TRACE("\E[40;34m========================================================================================================================\E[0m\n");
+       TRACE("\E[40;32;1m  Context info \E[1;37;1m: %s\E[0m\n", ment);
+       TRACE("\E[40;34m========================================================================================================================\E[0m\n");
 
 
        // Thread State List
@@ -48,21 +49,21 @@ _dump_context_info(const char *ment, int force_output)
                {
                        GLThreadState *cur_tstate = (GLThreadState *)current->value;
 
-                       LOG(" %c Thread  [%12d] : Surf <D=[%12p] R=[%12p]>",
-                           (tstate == cur_tstate) ? '*' : ' ',
-                           cur_tstate->thread_id,
-                           cur_tstate->rsurf_draw,
-                           cur_tstate->rsurf_read);
+                       TRACE(" %c Thread  [%12d] : Surf <D=[%12p] R=[%12p]>",
+                             (tstate == cur_tstate) ? '*' : ' ',
+                             cur_tstate->thread_id,
+                             cur_tstate->rsurf_draw,
+                             cur_tstate->rsurf_read);
 
                        if (cur_tstate->cstate != NULL)
                        {
-                               LOG(" GlueCTX=[%12p] RealCTX=[%12p]\E[0m\n",
-                                   cur_tstate->cstate->data,
-                                   cur_tstate->cstate);
+                               TRACE(" GlueCTX=[%12p] RealCTX=[%12p]\E[0m\n",
+                                     cur_tstate->cstate->data,
+                                     cur_tstate->cstate);
                        }
                        else
                        {
-                               LOG(" (NOT BINDED TO THREAD)\E[0m\n");
+                               TRACE(" (NOT BINDED TO THREAD)\E[0m\n");
                        }
 
                        // Binded Context State List
@@ -76,11 +77,11 @@ _dump_context_info(const char *ment, int force_output)
 
                                        if (cur_tstate->cstate == cur_cstate)
                                        {
-                                               LOG("   -> RealCTX [%12p] : EGLDPY=[%12p] EGLCTX=[%12p] <[%2d] GlueCTXs>\E[0m\n",
-                                                   cur_cstate,
-                                                   cur_cstate->rdpy,
-                                                   cur_cstate->rctx,
-                                                   cur_cstate->ref_count);
+                                               TRACE("   -> RealCTX [%12p] : EGLDPY=[%12p] EGLCTX=[%12p] <[%2d] GlueCTXs>\E[0m\n",
+                                                     cur_cstate,
+                                                     cur_cstate->rdpy,
+                                                     cur_cstate->rctx,
+                                                     cur_cstate->ref_count);
 
                                                // Binded Glue Context List
                                                {
@@ -93,14 +94,14 @@ _dump_context_info(const char *ment, int force_output)
 
                                                                if (cur_gctx->cstate == cur_cstate)
                                                                {
-                                                                       LOG("    -%c GlueCTX [%12p] : EGLDPY=[%12p] TID=[%12d] <MC count [%10d]>",
-                                                                           (cur_cstate->data == cur_gctx) ? '>' : '-',
-                                                                           cur_gctx,
-                                                                           cur_gctx->rdpy,
-                                                                           cur_gctx->thread_id,
-                                                                           cur_gctx->used_count);
-
-                                                                       LOG(" <Ref [%2d]>\E[0m\n", cur_gctx->ref_count);
+                                                                       TRACE("    -%c GlueCTX [%12p] : EGLDPY=[%12p] TID=[%12d] <MC count [%10d]>",
+                                                                             (cur_cstate->data == cur_gctx) ? '>' : '-',
+                                                                             cur_gctx,
+                                                                             cur_gctx->rdpy,
+                                                                             cur_gctx->thread_id,
+                                                                             cur_gctx->used_count);
+
+                                                                       TRACE(" <Ref [%2d]>\E[0m\n", cur_gctx->ref_count);
                                                                }
 
                                                                current = current->next;
@@ -118,7 +119,7 @@ _dump_context_info(const char *ment, int force_output)
                }
        }
 
-       LOG("\E[40;33m........................................................................................................................\E[0m\n");
+       TRACE("\E[40;33m........................................................................................................................\E[0m\n");
 
        // Not-binded Context State List
        {
@@ -152,11 +153,11 @@ _dump_context_info(const char *ment, int force_output)
 
                        if (isbinded == 0)
                        {
-                               LOG("   RealCTX   [%12p] : EGLDPY=[%12p] EGLCTX=[%12p] <[%2d] GlueCTXs>\E[0m\n",
-                                   cur_cstate,
-                                   cur_cstate->rdpy,
-                                   cur_cstate->rctx,
-                                   cur_cstate->ref_count);
+                               TRACE("   RealCTX   [%12p] : EGLDPY=[%12p] EGLCTX=[%12p] <[%2d] GlueCTXs>\E[0m\n",
+                                     cur_cstate,
+                                     cur_cstate->rdpy,
+                                     cur_cstate->rctx,
+                                     cur_cstate->ref_count);
 
                                // Binded Glue Context List
                                {
@@ -169,14 +170,14 @@ _dump_context_info(const char *ment, int force_output)
 
                                                if (cur_gctx->cstate == cur_cstate)
                                                {
-                                                       LOG("    -%c GlueCTX [%12p] : EGLDPY=[%12p] TID=[%12d] <MC count [%10d]>",
-                                                           (cur_cstate->data == cur_gctx) ? '>' : '-',
-                                                           cur_gctx,
-                                                           cur_gctx->rdpy,
-                                                           cur_gctx->thread_id,
-                                                           cur_gctx->used_count);
-
-                                                       LOG(" <Ref [%2d]>\E[0m\n", cur_gctx->ref_count);
+                                                       TRACE("    -%c GlueCTX [%12p] : EGLDPY=[%12p] TID=[%12d] <MC count [%10d]>",
+                                                             (cur_cstate->data == cur_gctx) ? '>' : '-',
+                                                             cur_gctx,
+                                                             cur_gctx->rdpy,
+                                                             cur_gctx->thread_id,
+                                                             cur_gctx->used_count);
+
+                                                       TRACE(" <Ref [%2d]>\E[0m\n", cur_gctx->ref_count);
                                                }
 
                                                current = current->next;
@@ -189,7 +190,7 @@ _dump_context_info(const char *ment, int force_output)
 
        }
 
-       LOG("\E[40;33m........................................................................................................................\E[0m\n");
+       TRACE("\E[40;33m........................................................................................................................\E[0m\n");
 
        // Not-binded Glue Context List
        {
@@ -202,21 +203,23 @@ _dump_context_info(const char *ment, int force_output)
 
                        if (cur_gctx->cstate == NULL)
                        {
-                               LOG("   GlueCTX [%12p]   : EGLDPY=[%12p] TID=[%12d] <MC count [%10d]>",
-                                   cur_gctx,
-                                   cur_gctx->rdpy,
-                                   cur_gctx->thread_id,
-                                   cur_gctx->used_count);
+                               TRACE("   GlueCTX [%12p]   : EGLDPY=[%12p] TID=[%12d] <MC count [%10d]>",
+                                     cur_gctx,
+                                     cur_gctx->rdpy,
+                                     cur_gctx->thread_id,
+                                     cur_gctx->used_count);
 
-                               LOG(" <Ref [%2d]>\E[0m\n", cur_gctx->ref_count);
+                               TRACE(" <Ref [%2d]>\E[0m\n", cur_gctx->ref_count);
                        }
 
                        current = current->next;
                }
        }
 
-       LOG("\E[40;34m========================================================================================================================\E[0m\n");
-       LOG("\n");
+       TRACE("\E[40;34m========================================================================================================================\E[0m\n");
+       TRACE("\n");
+
+       TRACE_END();
 
        goto finish;
 
@@ -581,7 +584,11 @@ fpgl_eglBindAPI(EGLenum api)
        GLThreadState *tstate = NULL;
 
        _COREGL_FAST_FUNC_BEGIN();
-       if (api_opt == COREGL_UNKNOWN_PATH) goto finish;
+       if (api_opt == COREGL_UNKNOWN_PATH)
+       {
+               ERR("\E[0;31;1mERROR : Invalid library link! (CoreGL path option is invalid)\E[0m\n");
+               goto finish;
+       }
 
        ret = _sym_eglBindAPI(api);
 
@@ -628,7 +635,11 @@ fpgl_eglQueryAPI(void)
        GLThreadState *tstate = NULL;
 
        _COREGL_FAST_FUNC_BEGIN();
-       if (api_opt == COREGL_UNKNOWN_PATH) goto finish;
+       if (api_opt == COREGL_UNKNOWN_PATH)
+       {
+               ERR("\E[0;31;1mERROR : Invalid library link! (CoreGL path option is invalid)\E[0m\n");
+               goto finish;
+       }
 
        ret = _sym_eglQueryAPI();
 
@@ -649,6 +660,7 @@ EGLContext
 fpgl_eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint* attrib_list)
 {
        GLGlueContext *gctx = NULL;
+       GLThreadState *tstate = NULL;
        GLContextState *cstate = NULL;
        GLContextState *cstate_new = NULL;
        GL_Shared_Object_State *sostate_new = NULL;
@@ -657,6 +669,13 @@ fpgl_eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_context
        EGL_packed_option *real_ctx_option = NULL;
        EGL_packed_sharable_option *real_ctx_sharable_option = NULL;
 
+       // Special eject condition for binding API
+       tstate = get_current_thread_state();
+       if (tstate != NULL && tstate->binded_api != EGL_OPENGL_ES_API)
+       {
+               return _sym_eglCreateContext(dpy, config, share_context, attrib_list);
+       }
+
        _COREGL_FAST_FUNC_BEGIN();
 
        real_ctx_option = (EGL_packed_option *)calloc(1, sizeof(EGL_packed_option));
@@ -779,15 +798,16 @@ fpgl_eglDestroyContext(EGLDisplay dpy, EGLContext ctx)
 
        gctx = (GLGlueContext *)ctx;
 
-       if (gctx != NULL)
+       if (gctx != NULL && gctx != EGL_NO_CONTEXT)
        {
                GLContextState *cstate = NULL;
+
                if (gctx->magic != MAGIC_GLFAST)
                {
-                       ERR("Magic Check Failed!!!\n");
-                       ret = EGL_FALSE;
+                       ret = _sym_eglDestroyContext(dpy, ctx);
                        goto finish;
                }
+
                cstate = gctx->cstate;
                AST(cstate != NULL);
 
@@ -838,8 +858,15 @@ fpgl_eglQueryContext(EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *v
                GLGlueContext *gctx = NULL;
                gctx = (GLGlueContext *)ctx;
 
-               AST(gctx->cstate != NULL);
-               real_ctx = gctx->cstate->rctx;
+               if (gctx->magic != MAGIC_GLFAST)
+               {
+                       real_ctx = ctx;
+               }
+               else
+               {
+                       AST(gctx->cstate != NULL);
+                       real_ctx = gctx->cstate->rctx;
+               }
        }
 
        _COREGL_FAST_FUNC_SYMCALL_BEGIN();
@@ -859,6 +886,15 @@ fpgl_eglReleaseThread(void)
 {
        EGLBoolean ret = EGL_FALSE;
        EGLDisplay dpy = EGL_NO_DISPLAY;
+       GLThreadState *tstate = NULL;
+
+       tstate = get_current_thread_state();
+
+       // Special eject condition for binding API
+       if (tstate != NULL && tstate->binded_api != EGL_OPENGL_ES_API)
+       {
+               return _sym_eglReleaseThread();
+       }
 
        _COREGL_FAST_FUNC_BEGIN();
 
@@ -885,11 +921,18 @@ fpgl_eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext
        GLThreadState *tstate = NULL;
        GLContextState *cstate = NULL;
 
+       tstate = get_current_thread_state();
+
+       // Special eject condition for binding API
+       if (tstate != NULL && tstate->binded_api != EGL_OPENGL_ES_API)
+       {
+               return _sym_eglMakeCurrent(dpy, draw, read, ctx);
+       }
+
        _COREGL_FAST_FUNC_BEGIN();
 
        gctx = (GLGlueContext *)ctx;
 
-       tstate = get_current_thread_state();
        if (tstate == NULL)
        {
                AST(init_new_thread_state() == 1);
@@ -1032,10 +1075,13 @@ fpgl_eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext
        // Setup initial Viewport & Scissor
        if (gctx->surface_attached == 0 && draw != EGL_NO_SURFACE)
        {
-               EGLint width;
-               EGLint height;
-               _sym_eglQuerySurface(dpy, draw, EGL_WIDTH, &width);
-               _sym_eglQuerySurface(dpy, draw, EGL_HEIGHT, &height);
+               EGLint box_buffer[4];
+               EGLint width = 0;
+               EGLint height = 0;
+
+               _sym_glGetIntegerv(GL_VIEWPORT, box_buffer);
+               width = box_buffer[2];
+               height = box_buffer[3];
 
                gctx->_clear_flag1 |= FLAG_BIT_0;
                gctx->gl_viewport[0] = 0;
@@ -1043,6 +1089,10 @@ fpgl_eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext
                gctx->gl_viewport[2] = width;
                gctx->gl_viewport[3] = height;
 
+               _sym_glGetIntegerv(GL_SCISSOR_BOX, box_buffer);
+               width = box_buffer[2];
+               height = box_buffer[3];
+
                gctx->_misc_flag2 |= FLAG_BIT_0;
                gctx->gl_scissor_box[0] = 0;
                gctx->gl_scissor_box[1] = 0;
@@ -1080,15 +1130,22 @@ fpgl_eglGetCurrentContext(void)
        GLGlueContext *ret = NULL;
        GLThreadState *tstate = NULL;
 
-       _COREGL_FAST_FUNC_BEGIN();
-
        tstate = get_current_thread_state();
 
+       // Special eject condition for binding API
+       if (tstate != NULL && tstate->binded_api != EGL_OPENGL_ES_API)
+       {
+               return _sym_eglGetCurrentContext();
+       }
+
+       _COREGL_FAST_FUNC_BEGIN();
+
        if (tstate != NULL)
        {
                if (tstate->cstate != NULL)
                {
                        ret = (GLGlueContext *)tstate->cstate->data;
+                       AST(ret->magic == MAGIC_GLFAST);
                }
        }
        goto finish;
@@ -1105,6 +1162,14 @@ fpgl_eglGetCurrentSurface(EGLint readdraw)
        EGLSurface ret = EGL_NO_SURFACE;
        GLThreadState *tstate = NULL;
 
+       tstate = get_current_thread_state();
+
+       // Special eject condition for binding API
+       if (tstate != NULL && tstate->binded_api != EGL_OPENGL_ES_API)
+       {
+               return _sym_eglGetCurrentSurface(readdraw);
+       }
+
        _COREGL_FAST_FUNC_BEGIN();
 
        tstate = get_current_thread_state();
index 220f331..0e2fbcc 100644 (file)
 # define LOG(...) \
      fprintf(stderr, __VA_ARGS__)
 
+# define TRACE(...) \
+     fprintf(trace_fp, __VA_ARGS__)
+
+# define TRACE_END() \
+     fflush(trace_fp)
+
 #ifdef COREGL_DEBUG
 # define AST(expr) \
      if (!(expr)) { fprintf(stderr, "\E[0;31;1m%s(%d) error. '"#expr"'\E[0m\n", __func__, __LINE__); }
@@ -84,10 +90,12 @@ typedef struct _Trace_Data Trace_Data;
 
 #define _COREGL_WRAP_FUNC_BEGIN() \
        static void *trace_hint = NULL; \
-   trace_hint = _COREGL_TRACE_API_BEGIN(__func__, trace_hint, 1);
+       if (trace_api_flag == 1) \
+               trace_hint = _COREGL_TRACE_API_BEGIN(__func__, trace_hint, 1);
 
 #define _COREGL_WRAP_FUNC_END() \
-   _COREGL_TRACE_API_END(__func__, trace_hint, 1);
+       if (trace_api_flag == 1) \
+               _COREGL_TRACE_API_END(__func__, trace_hint, 1);
 
 typedef enum _CoreGL_Opt_Flag
 {
@@ -157,6 +165,7 @@ extern int                 trace_ctx_flag;
 extern int                 trace_ctx_force_flag;
 extern int                 trace_state_flag;
 extern int                 debug_nofp;
+extern FILE               *trace_fp;
 
 // Environment functions
 extern const char         *get_env_setting(const char *name);
index b262649..0dbdabb 100644 (file)
@@ -263,10 +263,10 @@ trace_end(const char *funcname, void *hint, int trace_total_time)
                GLThreadState *tstate = NULL;
                struct timeval elapsed_time = TIMEVAL_INIT;
 
-               ftd = (Trace_Data *)hint;
-
                AST(gettimeofday(&t, NULL) == 0);
 
+               ftd = (Trace_Data *)hint;
+
                if (ftd == NULL)
                {
                        tstate = get_current_thread_state();
@@ -382,10 +382,10 @@ trace_output(int force_output)
        }
 
 
-       LOG("\n");
-       LOG("\E[40;34m========================================================================================================================\E[0m\n");
-       LOG("\E[40;32;1m  API call info \E[1;37;1m: Thread ID = %d  [Swaps per Second(P) = %7.2f]\E[0m\n", tstate->thread_id, swaps_per_sec);
-       LOG("\E[40;34m========================================================================================================================\E[0m\n");
+       TRACE("\n");
+       TRACE("\E[40;34m========================================================================================================================\E[0m\n");
+       TRACE("\E[40;32;1m  API call info \E[1;37;1m: Thread ID = %d  [Swaps per Second(P) = %7.2f]\E[0m\n", tstate->thread_id, swaps_per_sec);
+       TRACE("\E[40;34m========================================================================================================================\E[0m\n");
 
        // highlighted
        for (i = 0; i < MAX_TRACE_TABLE_SIZE; i++)
@@ -411,8 +411,8 @@ trace_output(int force_output)
 
                                        if (elapsed_time_per_call_period >= 0.01 || current->call_count - current->last_call_count > 1000)
                                        {
-                                               LOG("\E[40;37;1m %-42.42s : %10d call(s), %10.2f ms, %9.3f ms/API, %9.3f ms/API(P) \E[0m\n",
-                                                   current->name, current->call_count, elapsed_time, elapsed_time_per_call, elapsed_time_per_call_period);
+                                               TRACE("\E[40;37;1m %-42.42s : %10d call(s), %10.2f ms, %9.3f ms/API, %9.3f ms/API(P) \E[0m\n",
+                                                     current->name, current->call_count, elapsed_time, elapsed_time_per_call, elapsed_time_per_call_period);
                                                current->traced = 1;
                                        }
                                }
@@ -424,7 +424,7 @@ trace_output(int force_output)
        {
                int fp_env = 0;
                fp_env = atoi(get_env_setting("COREGL_TRACE_API_ALL"));
-               if (fp_env == 0)
+               if (fp_env == 1)
                {
                        // other
                        for (i = 0; i < MAX_TRACE_TABLE_SIZE; i++)
@@ -440,8 +440,8 @@ trace_output(int force_output)
                                                        double elapsed_time = _get_timeval(current->elapsed_time);
                                                        double elapsed_time_per_call = elapsed_time / current->call_count;
 
-                                                       LOG(" %-42.42s : %10d call(s), %10.2f ms, %9.3f ms/API\n",
-                                                           current->name, current->call_count, elapsed_time, elapsed_time_per_call);
+                                                       TRACE(" %-42.42s : %10d call(s), %10.2f ms, %9.3f ms/API\n",
+                                                             current->name, current->call_count, elapsed_time, elapsed_time_per_call);
                                                }
                                                current = current->next;
                                        }
@@ -450,39 +450,39 @@ trace_output(int force_output)
                }
        }
 
-       LOG("\E[40;34m========================================================================================================================\E[0m\n");
+       TRACE("\E[40;34m========================================================================================================================\E[0m\n");
 
-       LOG("\E[40;36;1m %-42.42s : %13.2f ms[%6.2f%%], %13.2f ms(P)[%6.2f%%]\E[0m\n",
-           "TOTAL elapsed Time",
-           total_elapsed_time,
-           100.0,
-           total_elapsed_time_period,
-           100.0);
+       TRACE("\E[40;36;1m %-42.42s : %13.2f ms[%6.2f%%], %13.2f ms(P)[%6.2f%%]\E[0m\n",
+             "TOTAL elapsed Time",
+             total_elapsed_time,
+             100.0,
+             total_elapsed_time_period,
+             100.0);
 
 
-       LOG("\E[40;36;1m %-42.42s : %13.2f ms[%6.2f%%], %13.2f ms(P)[%6.2f%%]\E[0m\n",
-           "OpenGL elapsed Time",
-           total_opengl_elapsed_time,
-           total_opengl_elapsed_time * 100.0 / total_elapsed_time,
-           total_opengl_elapsed_time_period,
-           total_opengl_elapsed_time_period * 100.0 / total_elapsed_time_period);
+       TRACE("\E[40;36;1m %-42.42s : %13.2f ms[%6.2f%%], %13.2f ms(P)[%6.2f%%]\E[0m\n",
+             "OpenGL elapsed Time",
+             total_opengl_elapsed_time,
+             total_opengl_elapsed_time * 100.0 / total_elapsed_time,
+             total_opengl_elapsed_time_period,
+             total_opengl_elapsed_time_period * 100.0 / total_elapsed_time_period);
 
-       LOG("\E[40;36;1m %-42.42s : %13.2f ms[%6.2f%%], %13.2f ms(P)[%6.2f%%]\E[0m\n",
-           "Out of OpenGL elapsed time",
-           total_other_elapsed_time,
-           total_other_elapsed_time * 100.0 / total_elapsed_time,
-           total_other_elapsed_time_period,
-           total_other_elapsed_time_period * 100.0 / total_elapsed_time_period);
+       TRACE("\E[40;36;1m %-42.42s : %13.2f ms[%6.2f%%], %13.2f ms(P)[%6.2f%%]\E[0m\n",
+             "Out of OpenGL elapsed time",
+             total_other_elapsed_time,
+             total_other_elapsed_time * 100.0 / total_elapsed_time,
+             total_other_elapsed_time_period,
+             total_other_elapsed_time_period * 100.0 / total_elapsed_time_period);
 
-       LOG("\E[40;36;1m %-42.42s : %13.2f ms[%6.2f%%], %13.2f ms(P)[%6.2f%%]\E[0m\n",
-           "CoreGL API tracing overhead",
-           total_elapsed_time - total_opengl_elapsed_time - total_other_elapsed_time,
-           (total_elapsed_time - total_opengl_elapsed_time - total_other_elapsed_time) * 100.0 / total_elapsed_time,
-           total_elapsed_time_period - total_opengl_elapsed_time_period - total_other_elapsed_time_period,
-           (total_elapsed_time_period - total_opengl_elapsed_time_period - total_other_elapsed_time_period) * 100.0 / total_elapsed_time_period);
+       TRACE("\E[40;36;1m %-42.42s : %13.2f ms[%6.2f%%], %13.2f ms(P)[%6.2f%%]\E[0m\n",
+             "CoreGL API tracing overhead",
+             total_elapsed_time - total_opengl_elapsed_time - total_other_elapsed_time,
+             (total_elapsed_time - total_opengl_elapsed_time - total_other_elapsed_time) * 100.0 / total_elapsed_time,
+             total_elapsed_time_period - total_opengl_elapsed_time_period - total_other_elapsed_time_period,
+             (total_elapsed_time_period - total_opengl_elapsed_time_period - total_other_elapsed_time_period) * 100.0 / total_elapsed_time_period);
 
-       LOG("\E[40;34m========================================================================================================================\E[0m\n");
-       LOG("\n");
+       TRACE("\E[40;34m========================================================================================================================\E[0m\n");
+       TRACE("\n");
 
        for (i = 0; i < MAX_TRACE_TABLE_SIZE; i++)
        {
@@ -500,6 +500,8 @@ trace_output(int force_output)
                }
        }
 
+       TRACE_END();
+
        goto finish;
 
 finish:
index 1351d17..5e79357 100644 (file)
@@ -67,10 +67,10 @@ dump_wrap_context_states(int force_output)
                tv_last = tv_now;
        }
 
-       LOG("\n");
-       LOG("\E[0;40;34m===================================================================================================================\E[0m\n");
-       LOG("\E[0;32;1m  State info \E[1;37;1m: (CURRENT BINDED CONTEXT)\E[0m\n");
-       LOG("\E[0;40;34m===================================================================================================================\E[0m\n");
+       TRACE("\n");
+       TRACE("\E[0;40;34m===================================================================================================================\E[0m\n");
+       TRACE("\E[0;32;1m  State info \E[1;37;1m: (CURRENT BINDED CONTEXT)\E[0m\n");
+       TRACE("\E[0;40;34m===================================================================================================================\E[0m\n");
 
 #define PRINTF_CHAR_GLenum "%10d"
 #define PRINTF_CHAR_GLboolean "%10d"
@@ -93,24 +93,26 @@ dump_wrap_context_states(int force_output)
       TYPE valuedata[SIZE]; \
       TYPE *value = NULL; \
       value = valuedata; GET_STMT; value = valuedata; \
-      LOG("\E[0;37;1m %-30.30s : (\E[0m ", #NAME); \
+      TRACE("\E[0;37;1m %-30.30s : (\E[0m ", #NAME); \
       for (int i = 0; i < SIZE; i++) \
       { \
          if (i > 0) { \
             if (i % 4 == 0) \
-               LOG("\n %-30.30s     ", "");\
+               TRACE("\n %-30.30s     ", "");\
             else \
-               LOG(", "); \
+               TRACE(", "); \
          } \
-         LOG("["PRINTF_CHAR(TYPE)"]", value[i]); \
+         TRACE("["PRINTF_CHAR(TYPE)"]", value[i]); \
       } \
-      LOG(" \E[0;37;1m)\E[0m\n"); \
+      TRACE(" \E[0;37;1m)\E[0m\n"); \
    }
 # include "coregl_fastpath_state.h"
 #undef GLUE_STATE
 
-       LOG("\E[0;40;34m===================================================================================================================\E[0m\n");
-       LOG("\n");
+       TRACE("\E[0;40;34m===================================================================================================================\E[0m\n");
+       TRACE("\n");
+
+       TRACE_END();
 
 finish:
        return;
index 4101e32..2b7ff51 100644 (file)
@@ -6,7 +6,6 @@ eglGetError(void)
        EGLint ret = _COREGL_INT_INIT_VALUE;
 
        _COREGL_WRAP_FUNC_BEGIN();
-       if (api_opt == COREGL_UNKNOWN_PATH) goto finish;
        ret = ovr_eglGetError();
        goto finish;
 
@@ -21,7 +20,6 @@ eglGetDisplay(EGLNativeDisplayType display_id)
        EGLDisplay ret = EGL_NO_DISPLAY;
 
        _COREGL_WRAP_FUNC_BEGIN();
-       if (api_opt == COREGL_UNKNOWN_PATH) goto finish;
        ret = ovr_eglGetDisplay(display_id);
        goto finish;
 
@@ -35,7 +33,6 @@ eglInitialize(EGLDisplay dpy, EGLint* major, EGLint* minor)
 {
        EGLBoolean ret = EGL_FALSE;
        _COREGL_WRAP_FUNC_BEGIN();
-       if (api_opt == COREGL_UNKNOWN_PATH) goto finish;
        ret = ovr_eglInitialize(dpy, major, minor);
        goto finish;
 
@@ -50,7 +47,6 @@ eglTerminate(EGLDisplay dpy)
        EGLBoolean ret = EGL_FALSE;
 
        _COREGL_WRAP_FUNC_BEGIN();
-       if (api_opt == COREGL_UNKNOWN_PATH) goto finish;
        ret = ovr_eglTerminate(dpy);
        goto finish;
 
@@ -178,7 +174,6 @@ eglBindAPI(EGLenum api)
        EGLBoolean ret = EGL_FALSE;
 
        _COREGL_WRAP_FUNC_BEGIN();
-       if (api_opt == COREGL_UNKNOWN_PATH) goto finish;
        ret = ovr_eglBindAPI(api);
        goto finish;
 
@@ -193,7 +188,6 @@ eglQueryAPI(void)
        EGLenum ret = 0;
 
        _COREGL_WRAP_FUNC_BEGIN();
-       if (api_opt == COREGL_UNKNOWN_PATH) goto finish;
        ret = ovr_eglQueryAPI();
        goto finish;
 
@@ -466,7 +460,6 @@ eglGetProcAddress(const char* procname)
        _eng_fn ret = NULL;
 
        _COREGL_WRAP_FUNC_BEGIN();
-       if (api_opt == COREGL_UNKNOWN_PATH) goto finish;
        ret = ovr_eglGetProcAddress(procname);
        goto finish;
 
@@ -481,7 +474,6 @@ eglQueryString(EGLDisplay dpy, EGLint name)
        const char *ret = NULL;
 
        _COREGL_WRAP_FUNC_BEGIN();
-       if (api_opt == COREGL_UNKNOWN_PATH) goto finish;
        ret = ovr_eglQueryString(dpy, name);
        goto finish;