From bb1bed213c479b4991ec89af392b13e4aa657fcb Mon Sep 17 00:00:00 2001 From: Haegeun Park Date: Tue, 19 Jun 2012 22:59:40 -0700 Subject: [PATCH] [Refactoring] Modularization - Fastpath : fast egl-context module - Tracepath : API/CTX/STATE tracing module - Appopt : Application specific optimization module * Modify entrypoint for EGL symbol (workaround for fork() issue) --- CMakeLists.txt | 25 +- Makefile | 39 +- src/coregl.c | 389 +--- src/coregl.h | 13 - src/coregl_export.c | 37 +- src/coregl_export.h | 7 +- src/coregl_export_egl.c | 55 + src/coregl_export_glx.c | 0 src/coregl_fastpath.h | 154 -- src/coregl_fastpath_glx.c | 1194 ------------- src/coregl_internal.h | 120 +- src/coregl_override.c | 254 +-- src/coregl_thread_pthread.c | 9 +- src/coregl_trace.c | 457 +---- src/coregl_wrappath.c | 115 -- src/coregl_wrappath.h | 18 - src/coregl_wrappath_egl.c | 585 ------ src/coregl_wrappath_gl.c | 1873 -------------------- src/coregl_wrappath_glx.c | 352 ---- src/headers/sym.h | 6 +- src/headers/sym_gl.h | 8 - src/modules/appopt/coregl_appopt.c | 80 + src/modules/appopt/coregl_appopt.h | 47 + src/modules/appopt/coregl_appopt_egl.c | 3 + src/modules/appopt/coregl_appopt_gl.c | 3 + src/modules/coregl_module.c | 63 + src/modules/coregl_module.h | 25 + src/{ => modules/fastpath}/coregl_fastpath.c | 509 +++++- src/modules/fastpath/coregl_fastpath.h | 230 +++ src/{ => modules/fastpath}/coregl_fastpath_egl.c | 273 ++- src/{ => modules/fastpath}/coregl_fastpath_gl.c | 1347 +++++++------- src/{ => modules/fastpath}/coregl_fastpath_state.h | 0 src/modules/tracepath/coregl_tracepath.c | 683 +++++++ src/modules/tracepath/coregl_tracepath.h | 76 + src/modules/tracepath/coregl_tracepath_egl.c | 585 ++++++ src/modules/tracepath/coregl_tracepath_gl.c | 1844 +++++++++++++++++++ 36 files changed, 5131 insertions(+), 6347 deletions(-) delete mode 100644 src/coregl_export_glx.c delete mode 100644 src/coregl_fastpath.h delete mode 100644 src/coregl_fastpath_glx.c delete mode 100644 src/coregl_wrappath.c delete mode 100644 src/coregl_wrappath.h delete mode 100644 src/coregl_wrappath_egl.c delete mode 100644 src/coregl_wrappath_gl.c delete mode 100644 src/coregl_wrappath_glx.c create mode 100644 src/modules/appopt/coregl_appopt.c create mode 100644 src/modules/appopt/coregl_appopt.h create mode 100644 src/modules/appopt/coregl_appopt_egl.c create mode 100644 src/modules/appopt/coregl_appopt_gl.c create mode 100644 src/modules/coregl_module.c create mode 100644 src/modules/coregl_module.h rename src/{ => modules/fastpath}/coregl_fastpath.c (62%) create mode 100644 src/modules/fastpath/coregl_fastpath.h rename src/{ => modules/fastpath}/coregl_fastpath_egl.c (80%) rename src/{ => modules/fastpath}/coregl_fastpath_gl.c (60%) rename src/{ => modules/fastpath}/coregl_fastpath_state.h (100%) create mode 100644 src/modules/tracepath/coregl_tracepath.c create mode 100644 src/modules/tracepath/coregl_tracepath.h create mode 100644 src/modules/tracepath/coregl_tracepath_egl.c create mode 100644 src/modules/tracepath/coregl_tracepath_gl.c diff --git a/CMakeLists.txt b/CMakeLists.txt index eaa171b..692247f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,10 +22,27 @@ SET(CMAKE_SKIP_BUILD_RPATH TRUE) # Build coregl Library # ------------------------------ SET(COREGL "COREGL") -SET(SRCS_common src/coregl.c src/coregl_thread_pthread.c src/coregl_trace.c src/coregl_override.c - src/coregl_export.c src/coregl_export_egl.c src/coregl_export_gl.c - src/coregl_wrappath.c src/coregl_wrappath_egl.c src/coregl_wrappath_gl.c - src/coregl_fastpath.c src/coregl_fastpath_egl.c src/coregl_fastpath_gl.c) +SET(SRCS_common + src/coregl.c + src/coregl_thread_pthread.c + src/coregl_trace.c + src/coregl_export.c + src/coregl_export_egl.c + src/coregl_export_gl.c + src/modules/coregl_module.c + src/modules/tracepath/coregl_tracepath.c + src/modules/tracepath/coregl_tracepath_egl.c + src/modules/tracepath/coregl_tracepath_gl.c + + src/modules/fastpath/coregl_fastpath.c + src/modules/fastpath/coregl_fastpath_egl.c + src/modules/fastpath/coregl_fastpath_gl.c + + src/modules/appopt/coregl_appopt.c + src/modules/appopt/coregl_appopt_egl.c + src/modules/appopt/coregl_appopt_gl.c +) + #SET(HEADERS_common src/coregl_export.h src/coregl_fastpath.h src/coregl_fastpath_state.h src/coregl.h src/coregl_internal.h src/coregl_thread_pthread.h src/coregl_wrappath.h) INCLUDE(FindPkgConfig) diff --git a/Makefile b/Makefile index 569514e..bf8f11f 100644 --- a/Makefile +++ b/Makefile @@ -1,37 +1,38 @@ CC = gcc -CFLAGS = -g -O2 -fvisibility=hidden -fPIC -Wall -std=c99 \ - -D_COREGL_EMBEDDED_GL\ +CFLAGS = -g -O2 -fvisibility=hidden -fPIC -Wall -std=c99 + + +LDFLAGS = -g -O2 -fvisibility=hidden -Wall -std=c99 -lpthread -LDFLAGS = -g -O2 -fvisibility=hidden -Wall -std=c99 -fPIC -ldl -lpthread -lGLESv2 -lEGL SOURCES = \ src/coregl.c \ src/coregl_thread_pthread.c \ src/coregl_trace.c \ - src/coregl_override.c \ src/coregl_export.c \ src/coregl_export_egl.c \ src/coregl_export_gl.c \ - src/coregl_wrappath.c \ - src/coregl_wrappath_egl.c \ - src/coregl_wrappath_gl.c \ - src/coregl_fastpath.c \ - src/coregl_fastpath_egl.c \ - src/coregl_fastpath_gl.c - -BIN = libCOREGL.so.1.1 + src/modules/coregl_module.c \ + \ + src/modules/tracepath/coregl_tracepath.c \ + src/modules/tracepath/coregl_tracepath_egl.c \ + src/modules/tracepath/coregl_tracepath_gl.c \ + \ + src/modules/fastpath/coregl_fastpath.c \ + src/modules/fastpath/coregl_fastpath_egl.c \ + src/modules/fastpath/coregl_fastpath_gl.c \ + \ + src/modules/appopt/coregl_appopt.c \ + src/modules/appopt/coregl_appopt_egl.c \ + src/modules/appopt/coregl_appopt_gl.c + +BIN = libCOREGL.so OBJECTS = $(SOURCES:.c=.o) all : $(BIN) - ln -sf $(BIN) lib/libCOREGL.so - ln -sf $(BIN) lib/libCOREGL.so.1 - ln -sf $(BIN) lib/libEGL.so - ln -sf $(BIN) lib/libEGL.so.1 ln -sf $(BIN) lib/libEGL.so.1.4 - ln -sf $(BIN) lib/libGLESv2.so - ln -sf $(BIN) lib/libGLESv2.so.2 ln -sf $(BIN) lib/libGLESv2.so.2.0 cp src/headers/egl.h include/EGL/def_egl.h cp src/headers/gl.h include/GLES2/def_gl.h @@ -48,5 +49,5 @@ $(BIN) : $(OBJECTS) $(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@ clean: - rm -f $(OBJECTS) lib/* + rm -f $(OBJECTS) lib/$(BIN) diff --git a/src/coregl.c b/src/coregl.c index c6c4b7b..ab73a36 100644 --- a/src/coregl.c +++ b/src/coregl.c @@ -3,22 +3,10 @@ #include #include #include "coregl_internal.h" +#include "coregl_export.h" -CoreGL_Opt_Flag api_opt = COREGL_UNKNOWN_PATH; - -Mutex ctx_list_access_mutex = MUTEX_INITIALIZER; - -void *egl_lib_handle; -void *gl_lib_handle; - -GLContext_List *glctx_list = NULL; - -int trace_api_flag = 0; -int trace_ctx_flag = 0; -int trace_ctx_force_flag = 0; -int trace_state_flag = 0; -int debug_nofp = 0; -FILE *trace_fp = NULL; +void *egl_lib_handle; +void *gl_lib_handle; // Symbol definition for real #define _COREGL_SYMBOL(IS_EXTENSION, RET_TYPE, FUNC_NAME, PARAM_LIST) RET_TYPE (*_sym_##FUNC_NAME) PARAM_LIST; @@ -35,146 +23,22 @@ get_env_setting(const char *name) return fp_env; } -int -add_context_state_to_list(const void *option, const int option_len, GLContextState *cstate, Mutex *mtx) -{ - int ret = 0; - int tid = 0; - GLContext_List *current = NULL; - GLContext_List *newitm = NULL; - - if (mtx != NULL) AST(mutex_lock(mtx) == 1); - - AST(cstate != NULL); - - tid = get_current_thread(); - - current = glctx_list; - while (current != NULL) - { - if (current->option_len == option_len && - memcmp(current->option, option, option_len) == 0 && - current->thread_id == tid) - { - AST(current->cstate == cstate); - goto finish; - } - current = current->next; - } - - newitm = (GLContext_List *)calloc(1, sizeof(GLContext_List)); - if (newitm == NULL) - { - ERR("Failed to create context list.\n"); - goto finish; - } - - newitm->cstate = cstate; - newitm->thread_id = tid; - newitm->option_len = option_len; - newitm->option = (void *)malloc(option_len); - memcpy(newitm->option, option, option_len); - - if (glctx_list != NULL) - newitm->next = glctx_list; - - glctx_list = newitm; - - ret = 1; - goto finish; - -finish: - if (ret != 1) - { - if (newitm != NULL) - { - free(newitm); - newitm = NULL; - } - if (cstate != NULL) - { - free(cstate); - cstate = NULL; - } - } - if (mtx != NULL) AST(mutex_unlock(mtx) == 1); - - return ret; -} - -GLContextState * -get_context_state_from_list(const void *option, const int option_len, Mutex *mtx) -{ - GLContextState *ret = NULL; - GLContext_List *current = NULL; - int tid = 0; - - if (mtx != NULL) AST(mutex_lock(mtx) == 1); - - tid = get_current_thread(); - - current = glctx_list; - while (current != NULL) - { - if (current->option_len == option_len && - memcmp(current->option, option, option_len) == 0 && - current->thread_id == tid) - { - ret = current->cstate; - goto finish; - } - current = current->next; - } - goto finish; - -finish: - if (mtx != NULL) AST(mutex_unlock(mtx) == 1); - return ret; -} - -int -remove_context_states_from_list(GLContextState *cstate, Mutex *mtx) +void +cleanup_current_thread_state() { - int ret = 0; - int tid = 0; - GLContext_List *olditm = NULL; - GLContext_List *current = NULL; - - if (mtx != NULL) AST(mutex_lock(mtx) == 1); - - AST(cstate != NULL); + GLThreadState *tstate = NULL; - tid = get_current_thread(); - current = glctx_list; + tstate = get_current_thread_state(); - while (current != NULL) + if (tstate != NULL) { - if (current->cstate == cstate) - { - GLContext_List *nextitm = NULL; - if (olditm != NULL) - { - olditm->next = current->next; - nextitm = olditm->next; - } - else - { - glctx_list = current->next; - nextitm = glctx_list; - } - free(current); - ret = 1; - current = nextitm; - continue; - } - olditm = current; - current = current->next; + LOG("[COREGL] de-init thread state \n"); + deinit_modules_tstate(tstate); + free(tstate); + tstate = NULL; } - goto finish; -finish: - if (mtx != NULL) AST(mutex_unlock(mtx) == 1); - return ret; + set_current_thread_state(NULL); } int @@ -188,9 +52,10 @@ init_new_thread_state() tstate = (GLThreadState *)calloc(1, sizeof(GLThreadState)); tstate->thread_id = get_current_thread(); - tstate->binded_api = EGL_OPENGL_ES_API; - set_current_thread_state(&ctx_list_access_mutex, tstate); + init_modules_tstate(tstate); + + set_current_thread_state(tstate); #ifdef COREGL_TRACE_CONTEXT_INFO add_to_general_trace_list(&thread_trace_list, tstate); @@ -219,31 +84,16 @@ _glue_sym_init(void) #define FALLBAK(dst) \ if (!dst) { dst = (__typeof__(dst))_sym_missing; ERR("WARNING : symbol '"#dst"' missing!\n"); } - -#ifndef _COREGL_DESKTOP_GL -# define _COREGL_SYMBOL(IS_EXTENSION, RET_TYPE, FUNC_NAME, PARAM_LIST) \ - FINDSYM(egl_lib_handle, _sym_eglGetProcAddress, _sym_##FUNC_NAME, #FUNC_NAME); \ - if (IS_EXTENSION == GL_TRUE) { \ - FINDSYM(egl_lib_handle, _sym_eglGetProcAddress, _sym_##FUNC_NAME, #FUNC_NAME"EXT"); \ - FINDSYM(egl_lib_handle, _sym_eglGetProcAddress, _sym_##FUNC_NAME, #FUNC_NAME"ARB"); \ - FINDSYM(egl_lib_handle, _sym_eglGetProcAddress, _sym_##FUNC_NAME, #FUNC_NAME"OES"); \ - FINDSYM(egl_lib_handle, _sym_eglGetProcAddress, _sym_##FUNC_NAME, #FUNC_NAME"KHR"); \ - } else { FALLBAK(_sym_##FUNC_NAME); } -# include "headers/sym_egl.h" -# undef _COREGL_SYMBOL -#else -# define _COREGL_SYMBOL(IS_EXTENSION, RET_TYPE, FUNC_NAME, PARAM_LIST) \ - FINDSYM(glue_lib_handle, _sym_glXGetProcAddress, _sym_##FUNC_NAME, #FUNC_NAME); \ - if (IS_EXTENSION == GL_TRUE) { \ - FINDSYM(gl_lib_handle, _sym_glXGetProcAddress, _sym_##FUNC_NAME, #FUNC_NAME"EXT"); \ - FINDSYM(gl_lib_handle, _sym_glXGetProcAddress, _sym_##FUNC_NAME, #FUNC_NAME"ARB"); \ - FINDSYM(gl_lib_handle, _sym_glXGetProcAddress, _sym_##FUNC_NAME, #FUNC_NAME"OES"); \ - FINDSYM(gl_lib_handle, _sym_glXGetProcAddress, _sym_##FUNC_NAME, #FUNC_NAME"MESA"); \ - FINDSYM(gl_lib_handle, _sym_glXGetProcAddress, _sym_##FUNC_NAME, #FUNC_NAME"SGI"); \ - } else { FALLBAK(_sym_##FUNC_NAME); } -# include "headers/sym_glx.h" -# undef _COREGL_SYMBOL -#endif +#define _COREGL_SYMBOL(IS_EXTENSION, RET_TYPE, FUNC_NAME, PARAM_LIST) \ + FINDSYM(egl_lib_handle, _sym_eglGetProcAddress, _sym_##FUNC_NAME, #FUNC_NAME); \ + if (IS_EXTENSION == GL_TRUE) { \ + FINDSYM(egl_lib_handle, _sym_eglGetProcAddress, _sym_##FUNC_NAME, #FUNC_NAME"EXT"); \ + FINDSYM(egl_lib_handle, _sym_eglGetProcAddress, _sym_##FUNC_NAME, #FUNC_NAME"ARB"); \ + FINDSYM(egl_lib_handle, _sym_eglGetProcAddress, _sym_##FUNC_NAME, #FUNC_NAME"OES"); \ + FINDSYM(egl_lib_handle, _sym_eglGetProcAddress, _sym_##FUNC_NAME, #FUNC_NAME"KHR"); \ + } else { FALLBAK(_sym_##FUNC_NAME); } +#include "headers/sym_egl.h" +#undef _COREGL_SYMBOL #undef FINDSYM #undef FALLBAK @@ -261,28 +111,16 @@ _gl_sym_init(void) #define FALLBAK(dst) \ if (!dst) { dst = (__typeof__(dst))_sym_missing; ERR("WARNING : symbol '"#dst"' missing!\n"); } -#ifndef _COREGL_DESKTOP_GL -# define _COREGL_SYMBOL(IS_EXTENSION, RET_TYPE, FUNC_NAME, PARAM_LIST) \ - FINDSYM(gl_lib_handle, _sym_eglGetProcAddress, _sym_##FUNC_NAME, #FUNC_NAME); \ - if (IS_EXTENSION == GL_TRUE) { \ - FINDSYM(gl_lib_handle, _sym_eglGetProcAddress, _sym_##FUNC_NAME, #FUNC_NAME"EXT"); \ - FINDSYM(gl_lib_handle, _sym_eglGetProcAddress, _sym_##FUNC_NAME, #FUNC_NAME"ARB"); \ - FINDSYM(gl_lib_handle, _sym_eglGetProcAddress, _sym_##FUNC_NAME, #FUNC_NAME"OES"); \ - FINDSYM(gl_lib_handle, _sym_eglGetProcAddress, _sym_##FUNC_NAME, #FUNC_NAME"KHR"); \ - } else { FALLBAK(_sym_##FUNC_NAME); } -# include "headers/sym_gl.h" -# undef _COREGL_SYMBOL -#else -# define _COREGL_SYMBOL(IS_EXTENSION, RET_TYPE, FUNC_NAME, PARAM_LIST) \ - if (IS_EXTENSION == GL_TRUE) { \ - FINDSYM(gl_lib_handle, _sym_glXGetProcAddress, _sym_##FUNC_NAME, #FUNC_NAME); \ - FINDSYM(gl_lib_handle, _sym_glXGetProcAddress, _sym_##FUNC_NAME, #FUNC_NAME"EXT"); \ - FINDSYM(gl_lib_handle, _sym_glXGetProcAddress, _sym_##FUNC_NAME, #FUNC_NAME"ARB"); \ - FINDSYM(gl_lib_handle, _sym_glXGetProcAddress, _sym_##FUNC_NAME, #FUNC_NAME"OES"); \ +#define _COREGL_SYMBOL(IS_EXTENSION, RET_TYPE, FUNC_NAME, PARAM_LIST) \ + FINDSYM(gl_lib_handle, _sym_eglGetProcAddress, _sym_##FUNC_NAME, #FUNC_NAME); \ + if (IS_EXTENSION == GL_TRUE) { \ + FINDSYM(gl_lib_handle, _sym_eglGetProcAddress, _sym_##FUNC_NAME, #FUNC_NAME"EXT"); \ + FINDSYM(gl_lib_handle, _sym_eglGetProcAddress, _sym_##FUNC_NAME, #FUNC_NAME"ARB"); \ + FINDSYM(gl_lib_handle, _sym_eglGetProcAddress, _sym_##FUNC_NAME, #FUNC_NAME"OES"); \ + FINDSYM(gl_lib_handle, _sym_eglGetProcAddress, _sym_##FUNC_NAME, #FUNC_NAME"KHR"); \ } else { FALLBAK(_sym_##FUNC_NAME); } -# include "headers/sym_gl.h" -# undef _COREGL_SYMBOL -#endif +#include "headers/sym_gl.h" +#undef _COREGL_SYMBOL #undef FINDSYM #undef FALLBAK @@ -299,16 +137,9 @@ static int _gl_lib_init(void) { -#ifndef _COREGL_DESKTOP_GL //------------------------------------------------// // Open EGL Library as EGL is separate -#ifndef _COREGL_EMBED_EVAS egl_lib_handle = dlopen("libEGL_drv.so", RTLD_NOW); -#else - egl_lib_handle = dlopen("libEGL.so.1", RTLD_NOW); - if (!egl_lib_handle) - egl_lib_handle = dlopen("libEGL.so", RTLD_NOW); -#endif if (!egl_lib_handle) { ERR("\E[0;31;1mERROR : %s\E[0m\n\n", dlerror()); @@ -324,13 +155,7 @@ _gl_lib_init(void) } // use gl_lib handle for GL symbols -#ifndef _COREGL_EMBED_EVAS gl_lib_handle = dlopen("libGLESv2_drv.so", RTLD_NOW); -#else - gl_lib_handle = dlopen("libGLESv2.so.1", RTLD_NOW); - if (!gl_lib_handle) - gl_lib_handle = dlopen("libGLESv2.so", RTLD_NOW); -#endif if (!gl_lib_handle) { ERR("\E[0;31;1mERROR : %s\E[0m\n\n", dlerror()); @@ -346,160 +171,46 @@ _gl_lib_init(void) } //------------------------------------------------// -#else // GLX - - -#ifndef _COREGL_EMBED_EVAS - gl_lib_handle = dlopen("libGL_drv.so", RTLD_NOW); -#else - gl_lib_handle = dlopen("libGL.so.1", RTLD_NOW); - if (!gl_lib_handle) - gl_lib_handle = dlopen("libGL.so", RTLD_NOW); -#endif - if (!gl_lib_handle) - { - ERR("%s\n", dlerror()); - return 0; - } - - //------------------------------------------------// - -#endif // _COREGL_DESKTOP_GL - if (!_glue_sym_init()) return 0; if (!_gl_sym_init()) return 0; return 1; } -extern void init_fast_gl(); -extern void init_wrap_gl(); +static int +_gl_lib_deinit(void) +{ + if (egl_lib_handle) dlclose(egl_lib_handle); + if (gl_lib_handle) dlclose(gl_lib_handle); + + return 1; +} -#ifndef _COREGL_EMBED_EVAS -__attribute__((constructor)) -#endif int init_gl() { - int fastpath_opt = 0; - - LOG("[CoreGL] "); + LOG("[CoreGL] Library initializing..."); if (!_gl_lib_init()) return 0; - fastpath_opt = atoi(get_env_setting("COREGL_FASTPATH")); - - switch (fastpath_opt) - { - case 1: - api_opt = COREGL_FAST_PATH; - LOG(": (%d) Fastpath enabled...\n", fastpath_opt); - init_fast_gl(); - break; - default: - LOG(": (%d) Default API path enabled...\n", fastpath_opt); - api_opt = COREGL_NORMAL_PATH; - init_wrap_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 -#ifdef COREGL_TRACE_CONTEXT_INFO - trace_ctx_flag = atoi(get_env_setting("COREGL_TRACE_CTX")); -#endif -#ifdef COREGL_TRACE_CONTEXT_INFO - trace_ctx_force_flag = atoi(get_env_setting("COREGL_TRACE_CTX_FORCE")); -#endif -#ifdef COREGL_TRACE_STATE_INFO - trace_state_flag = atoi(get_env_setting("COREGL_TRACE_STATE")); -#endif + init_export(); - debug_nofp = atoi(get_env_setting("COREGL_DEBUG_NOFP")); + LOG(" -> Completed\n"); - - override_glue_apis(api_opt); - override_gl_apis(api_opt); + init_modules(); return 1; } -extern void free_fast_gl(); -extern void free_wrap_gl(); - -#ifndef _COREGL_EMBED_EVAS __attribute__((destructor)) -#endif void free_gl() { - GLContext_List *current = NULL; - - switch (api_opt) + if (export_initialized != 0) { - case COREGL_FAST_PATH: - free_fast_gl(); - break; - default: - free_wrap_gl(); - break; - } - - AST(mutex_lock(&ctx_list_access_mutex) == 1); + deinit_modules(); - { - // Destroy remained context & Detect leaks - int retry_destroy = 0; - - while (1) - { - retry_destroy = 0; - current = glctx_list; - while (current) - { - if (current->cstate != NULL) - { - ERR("\E[0;31;1mWARNING : Context attached to [dpy=%p|rctx=%p] has not been completely destroyed.(leak)\E[0m\n", current->cstate->rdpy, current->cstate->rctx); - -#ifndef _COREGL_DESKTOP_GL - _sym_eglMakeCurrent(current->cstate->rdpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); - _sym_eglDestroyContext(current->cstate->rdpy, current->cstate->rctx); -#else - _sym_glXDestroyContext(current->cstate->rdpy, current->cstate->rctx); -#endif - - remove_context_states_from_list(current->cstate, NULL); - retry_destroy = 1; - break; - } - - glctx_list = current->next; - free(current); - current = glctx_list; - } - if (retry_destroy == 0) break; - } + _gl_lib_deinit(); } - -#ifndef _COREGL_DESKTOP_GL - if (egl_lib_handle) dlclose(egl_lib_handle); -#endif - if (gl_lib_handle) dlclose(gl_lib_handle); - goto finish; - -finish: - AST(mutex_unlock(&ctx_list_access_mutex) == 1); } diff --git a/src/coregl.h b/src/coregl.h index 83ed8de..c03aec8 100644 --- a/src/coregl.h +++ b/src/coregl.h @@ -4,25 +4,12 @@ #include #include -#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX) -#else -# define _COREGL_DESKTOP_GL -#endif - -#if defined(_COREGL_EMBEDDED_GL) -#undef _COREGL_DESKTOP_GL -#endif - #define COREGL_API __attribute__((visibility("default"))) // Include GL/EGL/GLX types -#ifndef _COREGL_DESKTOP_GL # include # include # include "headers/egl.h" -#else -# include "headers/glx.h" -#endif # include "headers/gl.h" typedef void (*_eng_fn) (void); diff --git a/src/coregl_export.c b/src/coregl_export.c index eb04247..0752ba6 100644 --- a/src/coregl_export.c +++ b/src/coregl_export.c @@ -4,7 +4,40 @@ #include "headers/sym.h" #undef _COREGL_SYMBOL -#define _COREGL_SYMBOL(IS_EXTENSION, RET_TYPE, FUNC_NAME, PARAM_LIST) RET_TYPE (*wrp_##FUNC_NAME) PARAM_LIST = NULL; -#include "headers/sym.h" +#include "coregl_internal.h" +#include "coregl_export.h" + +#include + +#define COREGL_OVERRIDE_API(mangle, func, prefix) \ + mangle##func = prefix##func + +int export_initialized = 0; + +static void +_clean_overrides() +{ +#define OVERRIDE(f) COREGL_OVERRIDE_API(ovr_, f, _sym_) + +#define _COREGL_SYMBOL(IS_EXTENSION, RET_TYPE, FUNC_NAME, PARAM_LIST) OVERRIDE(FUNC_NAME); +# include "headers/sym_egl.h" +#undef _COREGL_SYMBOL + +#define _COREGL_SYMBOL(IS_EXTENSION, RET_TYPE, FUNC_NAME, PARAM_LIST) OVERRIDE(FUNC_NAME); +# include "headers/sym_gl.h" #undef _COREGL_SYMBOL +#undef OVERRIDE +} + +void +init_export() +{ + _clean_overrides(); +} + +void +deinit_export() +{ +} + diff --git a/src/coregl_export.h b/src/coregl_export.h index c0313b2..4ea111a 100644 --- a/src/coregl_export.h +++ b/src/coregl_export.h @@ -7,9 +7,10 @@ # include "headers/sym.h" #undef _COREGL_SYMBOL -#define _COREGL_SYMBOL(IS_EXTENSION, RET_TYPE, FUNC_NAME, PARAM_LIST) extern RET_TYPE (*wrp_##FUNC_NAME) PARAM_LIST; -# include "headers/sym.h" -#undef _COREGL_SYMBOL +extern int export_initialized; + +extern void init_export(); +extern void clean_overrides(); #endif // COREGL_EXPORT_H diff --git a/src/coregl_export_egl.c b/src/coregl_export_egl.c index a3493d6..255d915 100644 --- a/src/coregl_export_egl.c +++ b/src/coregl_export_egl.c @@ -1,44 +1,65 @@ #include "coregl_export.h" +Mutex init_export_mutex = MUTEX_INITIALIZER; + +#define INIT_EXPORT() \ + if (unlikely(export_initialized == 0)) \ + { \ + mutex_lock(&init_export_mutex); \ + if (export_initialized == 0) \ + { \ + init_gl(); \ + export_initialized = 1; \ + } \ + mutex_unlock(&init_export_mutex); \ + } + EGLint eglGetError(void) { + INIT_EXPORT(); return ovr_eglGetError(); } EGLDisplay eglGetDisplay(EGLNativeDisplayType display_id) { + INIT_EXPORT(); return ovr_eglGetDisplay(display_id); } EGLBoolean eglInitialize(EGLDisplay dpy, EGLint* major, EGLint* minor) { + INIT_EXPORT(); return ovr_eglInitialize(dpy, major, minor); } EGLBoolean eglTerminate(EGLDisplay dpy) { + INIT_EXPORT(); return ovr_eglTerminate(dpy); } EGLBoolean eglGetConfigs(EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config) { + INIT_EXPORT(); return ovr_eglGetConfigs(dpy, configs, config_size, num_config); } EGLBoolean eglChooseConfig(EGLDisplay dpy, const EGLint* attrib_list, EGLConfig* configs, EGLint config_size, EGLint* num_config) { + INIT_EXPORT(); return ovr_eglChooseConfig(dpy, attrib_list, configs, config_size, num_config); } EGLBoolean eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value) { + INIT_EXPORT(); return ovr_eglGetConfigAttrib(dpy, config, attribute, value); } @@ -46,204 +67,238 @@ eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *v EGLSurface eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint* attrib_list) { + INIT_EXPORT(); return ovr_eglCreateWindowSurface(dpy, config, win, attrib_list); } EGLSurface eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list) { + INIT_EXPORT(); return ovr_eglCreatePbufferSurface(dpy, config, attrib_list); } EGLSurface eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint* attrib_list) { + INIT_EXPORT(); return ovr_eglCreatePixmapSurface(dpy, config, pixmap, attrib_list); } EGLBoolean eglDestroySurface(EGLDisplay dpy, EGLSurface surface) { + INIT_EXPORT(); return ovr_eglDestroySurface(dpy, surface); } EGLBoolean eglQuerySurface(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value) { + INIT_EXPORT(); return ovr_eglQuerySurface(dpy, surface, attribute, value); } EGLBoolean eglBindAPI(EGLenum api) { + INIT_EXPORT(); return ovr_eglBindAPI(api); } EGLenum eglQueryAPI(void) { + INIT_EXPORT(); return ovr_eglQueryAPI(); } EGLBoolean eglWaitClient(void) { + INIT_EXPORT(); return ovr_eglWaitClient(); } EGLBoolean eglReleaseThread(void) { + INIT_EXPORT(); return ovr_eglReleaseThread(); } EGLSurface eglCreatePbufferFromClientBuffer(EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list) { + INIT_EXPORT(); return ovr_eglCreatePbufferFromClientBuffer(dpy, buftype, buffer, config, attrib_list); } EGLBoolean eglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value) { + INIT_EXPORT(); return ovr_eglSurfaceAttrib(dpy, surface, attribute, value); } EGLBoolean eglBindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer) { + INIT_EXPORT(); return ovr_eglBindTexImage(dpy, surface, buffer); } EGLBoolean eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer) { + INIT_EXPORT(); return ovr_eglReleaseTexImage(dpy, surface, buffer); } EGLBoolean eglSwapInterval(EGLDisplay dpy, EGLint interval) { + INIT_EXPORT(); return ovr_eglSwapInterval(dpy, interval); } EGLContext eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint* attrib_list) { + INIT_EXPORT(); return ovr_eglCreateContext(dpy, config, share_context, attrib_list); } EGLBoolean eglDestroyContext(EGLDisplay dpy, EGLContext ctx) { + INIT_EXPORT(); return ovr_eglDestroyContext(dpy, ctx); } EGLBoolean eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx) { + INIT_EXPORT(); return ovr_eglMakeCurrent(dpy, draw, read, ctx); } EGLContext eglGetCurrentContext(void) { + INIT_EXPORT(); return ovr_eglGetCurrentContext(); } EGLSurface eglGetCurrentSurface(EGLint readdraw) { + INIT_EXPORT(); return ovr_eglGetCurrentSurface(readdraw); } EGLDisplay eglGetCurrentDisplay(void) { + INIT_EXPORT(); return ovr_eglGetCurrentDisplay(); } EGLBoolean eglQueryContext(EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value) { + INIT_EXPORT(); return ovr_eglQueryContext(dpy, ctx, attribute, value); } EGLBoolean eglWaitGL(void) { + INIT_EXPORT(); return ovr_eglWaitGL(); } EGLBoolean eglWaitNative(EGLint engine) { + INIT_EXPORT(); return ovr_eglWaitNative(engine); } EGLBoolean eglSwapBuffers(EGLDisplay dpy, EGLSurface surface) { + INIT_EXPORT(); return ovr_eglSwapBuffers(dpy, surface); } EGLBoolean eglCopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target) { + INIT_EXPORT(); return ovr_eglCopyBuffers(dpy, surface, target); } _eng_fn eglGetProcAddress(const char* procname) { + INIT_EXPORT(); return ovr_eglGetProcAddress(procname); } const char * eglQueryString(EGLDisplay dpy, EGLint name) { + INIT_EXPORT(); return ovr_eglQueryString(dpy, name); } EGLImageKHR eglCreateImageKHR (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list) { + INIT_EXPORT(); return ovr_eglCreateImageKHR(dpy, ctx, target, buffer, attrib_list); } EGLBoolean eglDestroyImageKHR(EGLDisplay dpy, EGLImageKHR image) { + INIT_EXPORT(); return ovr_eglDestroyImageKHR(dpy, image); } void * eglMapImageSEC(EGLDisplay dpy, EGLImageKHR image) { + INIT_EXPORT(); return ovr_eglMapImageSEC(dpy, image); } EGLBoolean eglUnmapImageSEC(EGLDisplay dpy, EGLImageKHR image) { + INIT_EXPORT(); return ovr_eglUnmapImageSEC(dpy, image); } EGLBoolean eglGetImageAttribSEC(EGLDisplay dpy, EGLImageKHR image, EGLint attribute, EGLint *value) { + INIT_EXPORT(); return ovr_eglGetImageAttribSEC(dpy, image, attribute, value); } EGLBoolean eglLockSurfaceKHR(EGLDisplay display, EGLSurface surface, const EGLint *attrib_list) { + INIT_EXPORT(); return ovr_eglLockSurfaceKHR(display, surface, attrib_list); } EGLBoolean eglUnlockSurfaceKHR(EGLDisplay display, EGLSurface surface) { + INIT_EXPORT(); return ovr_eglUnlockSurfaceKHR(display, surface); } diff --git a/src/coregl_export_glx.c b/src/coregl_export_glx.c deleted file mode 100644 index e69de29..0000000 diff --git a/src/coregl_fastpath.h b/src/coregl_fastpath.h deleted file mode 100644 index d2311d4..0000000 --- a/src/coregl_fastpath.h +++ /dev/null @@ -1,154 +0,0 @@ -#ifndef COREGL_FASTPATH_H -#define COREGL_FASTPATH_H - -#include "coregl_internal.h" - -// Symbol definition for fastpath -#define _COREGL_SYMBOL(IS_EXTENSION, RET_TYPE, FUNC_NAME, PARAM_LIST) extern RET_TYPE (fpgl_##FUNC_NAME) PARAM_LIST; -# include "headers/sym.h" -#undef _COREGL_SYMBOL - -#define FLAG_BIT_0 0x01 -#define FLAG_BIT_1 0x02 -#define FLAG_BIT_2 0x04 -#define FLAG_BIT_3 0x08 -#define FLAG_BIT_4 0x10 -#define FLAG_BIT_5 0x20 -#define FLAG_BIT_6 0x40 -#define FLAG_BIT_7 0x80 - -#define MAX_TEXTURE_UNITS 32 -#define MAX_VERTEX_ATTRIBS 64 - -typedef struct -{ - GLuint tex_id; -} GL_Texture_State; - -typedef struct -{ - GLboolean modified; - GLboolean enabled; - GLuint buf_id; - GLint size; - GLenum type; - GLboolean normalized; - GLsizei stride; - const void *pointer; -} GL_Vertex_Array_State; - -typedef struct -{ - GLboolean modified; - GLfloat value[4]; -} GL_Vertex_Attrib; - - -#define MAGIC_GLFAST 0x73777770 -#define MAX_GL_OBJECT_SIZE 100000 - -typedef enum -{ - GL_OBJECT_TYPE_UNKNOWN = 0x0, - GL_OBJECT_TYPE_TEXTURE = 0x1000000, - GL_OBJECT_TYPE_BUFFER = 0x2000000, - GL_OBJECT_TYPE_FRAMEBUFFER = 0x3000000, - GL_OBJECT_TYPE_RENDERBUFFER = 0x4000000, - GL_OBJECT_TYPE_PROGRAM = 0x5000000, -} GL_Object_Type; - -typedef struct _GL_Object -{ - GLuint id; - GLuint real_id; - - struct _GL_Shared_Object_State *parent; -} GL_Object; - -typedef struct _GL_Shared_Object_State -{ - int ref_count; - - GL_Object *texture[MAX_GL_OBJECT_SIZE]; - GL_Object *buffer[MAX_GL_OBJECT_SIZE]; - GL_Object *framebuffer[MAX_GL_OBJECT_SIZE]; - GL_Object *renderbuffer[MAX_GL_OBJECT_SIZE]; - GL_Object *program[MAX_GL_OBJECT_SIZE]; -} GL_Shared_Object_State; - -typedef struct _GLGlueContext -{ - int magic; - int initialized; - int surface_attached; - - int ref_count; - int is_destroyed; - - int used_count; - - GLDisplay *rdpy; - GLContextState *cstate; - int thread_id; - - void *real_ctx_option; - int real_ctx_option_len; - - void *real_ctx_sharable_option; - int real_ctx_sharable_option_len; - - unsigned char _bind_flag; - unsigned char _enable_flag1; - unsigned char _enable_flag2; - unsigned char _clear_flag1; - unsigned char _clear_flag2; - unsigned char _tex_flag1; - unsigned char _blend_flag; - unsigned char _stencil_flag1; - unsigned char _stencil_flag2; - unsigned char _misc_flag1; - unsigned char _misc_flag2; - unsigned char _vattrib_flag; - - GL_Shared_Object_State *sostate; - - GLenum gl_error; - - // General state -#define GLUE_STATE(TYPE, NAME, SIZE, ARRAY_SIZE, DEFAULT_STMT, GET_STMT) TYPE NAME[ARRAY_SIZE]; -# include "coregl_fastpath_state.h" -#undef GLUE_STATE - -} GLGlueContext; - -typedef struct _GLGlueContext_List -{ - GLGlueContext *gctx; - struct _GLGlueContext_List *prev; - struct _GLGlueContext_List *next; -} GLGlueContext_List; - -extern GLGlueContext_List *gctx_list; - -extern GLGlueContext *initial_ctx; - -extern int debug_nofp; - -extern void init_fast_gl(); -extern void free_fast_gl(); - -extern int init_context_states(GLGlueContext *ctx); -extern void make_context_current(GLGlueContext *oldctx, GLGlueContext *newctx); - -#ifdef COREGL_TRACE_STATE_INFO -extern void dump_context_states(GLGlueContext *ctx, int force_output); -#endif - -extern GLuint sostate_create_object(GL_Shared_Object_State *sostate, GL_Object_Type type, GLuint name); -extern GLuint sostate_remove_object(GL_Shared_Object_State *sostate, GL_Object_Type type, GLuint glue_name); -extern GLuint sostate_get_object(GL_Shared_Object_State *sostate, GL_Object_Type type, GLuint name); -extern GLuint sostate_find_object(GL_Shared_Object_State *sostate, GL_Object_Type type, GLuint real_name); - - -#endif // COREGL_FASTPATH_H - diff --git a/src/coregl_fastpath_glx.c b/src/coregl_fastpath_glx.c deleted file mode 100644 index c90c86b..0000000 --- a/src/coregl_fastpath_glx.c +++ /dev/null @@ -1,1194 +0,0 @@ -#include "coregl_internal.h" -#include "coregl_fastpath.h" - -#include -#include -#include - -#define INIT_FAST_GLX_FUNC() \ - LOG("WARNING : GLX fastpath is not implemented!!!!\n"); - -#ifdef COREGL_FASTPATH_TRACE_CONTEXT_INFO - -typedef struct _General_Trace_List -{ - void *value; - struct _General_Trace_List *next; -} General_Trace_List; - -General_Trace_List *glue_ctx_trace_list = NULL; -General_Trace_List *thread_trace_list = NULL; -Mutex general_trace_lists_access_mutex = MUTEX_INITIALIZER; - -static int -_add_to_general_trace_list(General_Trace_List **gtl, void *value) -{ - int ret = 0; - General_Trace_List *newitm = NULL; - - AST(mutex_lock(&general_trace_lists_access_mutex) == 1); - - newitm = (General_Trace_List *)calloc(1, sizeof(General_Trace_List)); - newitm->value = value; - newitm->next = *gtl; - *gtl = newitm; - ret = 1; - goto finish; - -finish: - AST(mutex_unlock(&general_trace_lists_access_mutex) == 1); - return ret; -} - -static int -_remove_from_general_trace_list(General_Trace_List **gtl, void *value) -{ - int ret = 0; - General_Trace_List *current = NULL; - General_Trace_List *priv = NULL; - - AST(mutex_lock(&general_trace_lists_access_mutex) == 1); - - current = *gtl; - - while(current != NULL) - { - if (current->value == value) - { - if (priv == NULL) - *gtl = current->next; - else - priv->next = current->next; - - free(current); - ret = 1; - goto finish; - } - priv = current; - current = current->next; - } - goto finish; - -finish: - AST(mutex_unlock(&general_trace_lists_access_mutex) == 1); - - return ret; -} - -static void -_dump_context_info(const char *ment, int force_output) -{ - GLThreadState *tstate = NULL; - static struct timeval tv_last = { 0, 0 }; - - AST(mutex_lock(&ctx_list_access_mutex) == 1); - AST(mutex_lock(&general_trace_lists_access_mutex) == 1); - - if (!force_output) - { - struct timeval tv_now = { 0, 0 }; - AST(gettimeofday(&tv_now, NULL) == 0); - if (tv_now.tv_sec - tv_last.tv_sec < 5) - { - goto finish; - } - tv_last = tv_now; - } - - tstate = get_current_thread_state(); - - LOG("\n"); - LOG("\E[0;40;34m===================================================================================================================\E[0m\n"); - LOG("\E[0;32;1m Context info \E[1;37;1m: %s\E[0m\n", ment); - LOG("\E[0;40;34m===================================================================================================================\E[0m\n"); - - // Context State List - { - GLContextState *cstate = NULL; - void *iter = NULL; - - iter = traverse_context_state_from_list(NULL, &cstate); - while (cstate != NULL) - { - - LOG(" RealCTX [%12p] : EGLDPY=[%12p] EGLCTX=[%12p] GlueCTX=[%12p] <[%2d] GlueCTXs>\E[0m\n", - cstate, - cstate->rdpy, - cstate->rctx, - cstate->data, - cstate->ref_count); - - if (iter == NULL) break; - iter = traverse_context_state_from_list(iter, &cstate); - } - - } - - LOG("\E[0;40;33m...................................................................................................................\E[0m\n"); - - // Glue Context List - { - General_Trace_List *current = NULL; - current = glue_ctx_trace_list; - - while(current != NULL) - { - GLGlueContext *cur_gctx = (GLGlueContext *)current->value; - - LOG(" %c GlueCTX [%12p] : EGLDPY=[%12p] TID=[%12d]", - (cur_gctx->cstate != NULL && cur_gctx->cstate->data == cur_gctx) ? '*' : ' ', - cur_gctx, - cur_gctx->rdpy, - cur_gctx->thread_id); - - if (cur_gctx->cstate != NULL) - { - LOG(" RealCTX=[%12p]\n", - cur_gctx->cstate); - } - else - { - LOG(" (NOT BINDED) \E[0m\n"); - } - - current = current->next; - } - } - - LOG("\E[0;40;33m...................................................................................................................\E[0m\n"); - - // Thread State List - { - General_Trace_List *current = NULL; - current = thread_trace_list; - - while(current != NULL) - { - GLThreadState *cur_tstate = (GLThreadState *)current->value; - - LOG(" %c Thread [%12d] : Surf ", - (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); - } - else - { - LOG(" (NOT BINDED TO THREAD)\E[0m\n"); - } - - current = current->next; - } - } - - LOG("\E[0;40;34m===================================================================================================================\E[0m\n"); - LOG("\n"); - - goto finish; - -finish: - - AST(mutex_unlock(&general_trace_lists_access_mutex) == 1); - AST(mutex_unlock(&ctx_list_access_mutex) == 1); - -} - -#endif // COREGL_FASTPATH_TRACE_CONTEXT_INFO - - -typedef struct -{ - EGLint context_client_version; -} EGL_packed_attrib_list; - -typedef struct -{ - EGLDisplay dpy; - EGLConfig cfg; - EGL_packed_attrib_list attrib_list; -} EGL_packed_option; - -typedef struct -{ - EGLContext share_context; -} EGL_packed_sharable_option; - - -static int -_pack_egl_context_option(EGL_packed_option *pack_data, EGLDisplay dpy, EGLConfig cfg, const EGLint *attrib_list) -{ - int ret = 0; - - pack_data->dpy = dpy; - pack_data->cfg = cfg; - - // Default context attributes - pack_data->attrib_list.context_client_version = EGL_DONT_CARE; - - // Apply specified attributes - EGLint *attrib = (EGLint *)attrib_list; - while(attrib[0] != EGL_NONE) - { - switch(attrib[0]) - { - case EGL_CONTEXT_CLIENT_VERSION: - pack_data->attrib_list.context_client_version = attrib[1]; - break; - default: - ERR("Invalid context attribute.\n"); - goto finish; - } - attrib += 2; - } - ret = 1; - goto finish; - -finish: - return ret; -} - -static int -_unpack_egl_context_option(EGL_packed_option *pack_data, EGLDisplay *dpy, EGLConfig *cfg, EGLint *attrib_list, const int attrib_list_size) -{ - int ret = 0; - - AST(dpy != NULL); - AST(cfg != NULL); - AST(attrib_list != NULL); - AST(attrib_list_size < 1); - - *dpy = pack_data->dpy; - *cfg = pack_data->cfg; - - { - int attrib_list_index = 0; - - memset(attrib_list, 0x00, sizeof(int) * attrib_list_size); - - if (pack_data->attrib_list.context_client_version != EGL_DONT_CARE) - { - AST(attrib_list_index + 2 < attrib_list_size); - attrib_list[attrib_list_index] = EGL_CONTEXT_CLIENT_VERSION; - attrib_list[attrib_list_index + 1] = pack_data->attrib_list.context_client_version; - attrib_list_index += 2; - } - - attrib_list[attrib_list_index] = EGL_NONE; - } - ret = 1; - goto finish; - -finish: - return ret; -} - -static int -_pack_egl_context_sharable_option(EGL_packed_sharable_option *pack_data, EGLContext share_context) -{ - int ret = 0; - - pack_data->share_context = share_context; - - ret = 1; - goto finish; - -finish: - return ret; -} - -static int -_unpack_egl_context_sharable_option(EGL_packed_sharable_option *pack_data, EGLContext *share_context) -{ - int ret = 0; - - *share_context = pack_data->share_context; - - ret = 1; - goto finish; - -finish: - return ret; -} - -static void -_link_context_state(GLContextState *cstate, GLGlueContext *gctx) -{ - cstate->ref_count++; -} - -static void -_unlink_context_state(GLContextState *cstate, GLGlueContext *gctx) -{ - cstate->ref_count--; - if (cstate->ref_count == 0) - { - GLThreadState *tstate = NULL; - - AST(remove_context_state_from_list(cstate) == 1); - - tstate = get_current_thread_state(); - if (tstate != NULL) - { - if (tstate->cstate == cstate) - { - _sym_glXMakeCurrent(gctx->rdpy, tstate->rsurf_draw, NULL); - tstate->cstate = NULL; - } - } - _sym_glXDestroyContext(gctx->rdpy, cstate->rctx); - free(cstate); - cstate = NULL; - } -} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -//----------------------------------------------------------------// -// Fastpath GLX Functions // -// The functions have prefix 'fpgl_' for (fastpath gl) // -//----------------------------------------------------------------// -GLXContext -fpgl_glXCreateContext(Display* dpy, XVisualInfo* vis, GLXContext shareList, Bool direct) -{ - GLGlueContext *gctx = NULL; - GLContextState *cstate = NULL; - GLContextState *cstate_new = NULL; - GLContext ctx = NULL; - GLXContext real_share_context = NULL; - - EGL_packed_option *real_ctx_option = NULL; - EGL_packed_sharable_option *real_ctx_sharable_option = NULL; - - _COREGL_FAST_FUNC_BEGIN(); - - if (share_context != NULL) - { - GLGlueContext *share_gctx = NULL; - share_gctx = (GLGlueContext *)share_context; - if (share_gctx->cstate == NULL) - { - ERR("Invalid (not initialized) share context handle\n"); - goto finish; - } - real_share_context = share_gctx->cstate->rctx; - } - - - // Create a global context if it hasn't been created - if (cstate == NULL) - { - // Create a global context if it hasn't been created yet - ctx = _sym_glXCreateContext(dpy, vis, real_share_context, 1); - if (ctx == NULL) - { - ERR("Failed creating a glx global context for Fastpath.\n"); - goto finish; - } - - cstate_new = (GLContextState *)calloc(1, sizeof(GLContextState)); - if (cstate_new == NULL) - { - ERR("Error creating a new context state.\n"); - goto finish; - } - cstate_new->rctx = ctx; - cstate_new->rdpy = dpy; - cstate_new->data = NULL; - - ctx = NULL; - - AST(add_context_state_to_list(real_ctx_option, sizeof(EGL_packed_option), cstate_new) == 1); - - cstate = cstate_new; - } - - // Allocate a new context - gctx = (GLGlueContext *)calloc(1, sizeof(GLGlueContext)); - if (gctx == NULL) - { - ERR("Error creating a new GLGlueContext.\n"); - goto finish; - } - - gctx->magic = MAGIC_GLFAST; - gctx->initialized = 0; - gctx->rdpy = dpy; - gctx->thread_id = get_current_thread(); - - gctx->real_ctx_option = real_ctx_option; - gctx->real_ctx_option_len = sizeof(EGL_packed_option); - gctx->real_ctx_sharable_option = real_ctx_sharable_option; - gctx->real_ctx_sharable_option_len = sizeof(EGL_packed_sharable_option); - - gctx->cstate = cstate; - - _add_to_general_trace_list(&glue_ctx_trace_list, gctx); - - cstate->ref_count++; - -#ifdef COREGL_FASTPATH_TRACE_CONTEXT_INFO - { - char ment[256]; - sprintf(ment, "eglCreateContext completed (GlueCTX=[%12p])", gctx); - _dump_context_info(ment, 1); - } -#endif // COREGL_FASTPATH_TRACE_CONTEXT_INFO - - goto finish; - -finish: - if (gctx == NULL) - { - if (ctx != NULL) - { - _sym_eglDestroyContext(dpy, ctx); - ctx = NULL; - } - if (real_ctx_option != NULL) - { - free(real_ctx_option); - real_ctx_option = NULL; - } - if (real_ctx_sharable_option != NULL) - { - free(real_ctx_sharable_option); - real_ctx_sharable_option = NULL; - } - if (cstate_new != NULL) - { - remove_context_state_from_list(cstate_new); - free(cstate_new); - cstate_new = NULL; - } - } - - _COREGL_FAST_FUNC_END(); - return (GLXContext)gctx; -} - - - -void -fpgl_glXDestroyContext(Display* dpy, GLXContext ctx) -{ - int ret = 0; - GLGlueContext *gctx = NULL; - - _COREGL_FAST_FUNC_BEGIN(); - - gctx = (GLGlueContext *)ctx; - - if (gctx != NULL) - { - GLContextState *cstate = NULL; - if (gctx->magic != MAGIC_GLFAST) - { - ERR("Magic Check Failed!!!\n"); - ret = 0; - goto finish; - } - cstate = gctx->cstate; - AST(cstate != NULL); - - _unlink_context_state(cstate, gctx); - - _remove_from_general_trace_list(&glue_ctx_trace_list, gctx); - - if (gctx->real_ctx_option != NULL) - { - free(gctx->real_ctx_option); - gctx->real_ctx_option = NULL; - } - if (gctx->real_ctx_sharable_option != NULL) - { - free(gctx->real_ctx_sharable_option); - gctx->real_ctx_sharable_option = NULL; - } - free(gctx); - } - else - { - ERR("Invalid Context.\n"); - ret = 0; - goto finish; - } - -#ifdef COREGL_FASTPATH_TRACE_CONTEXT_INFO - { - char ment[256]; - sprintf(ment, "eglDestroyContext completed (GlueCTX=[%12p])", ctx); - _dump_context_info(ment, 1); - } -#endif // COREGL_FASTPATH_TRACE_CONTEXT_INFO - - ret = 1; - goto finish; - -finish: - _COREGL_FAST_FUNC_END(); - return ret; -} - - - - - - - - - -GLXContext -fpgl_glXGetCurrentContext(void) -{ - GLGlueContext *ret = NULL; - GLThreadState *tstate = NULL; - - _COREGL_FAST_FUNC_BEGIN(); - - tstate = get_current_thread_state(); - - if (tstate != NULL) - { - if (tstate->cstate != NULL) - { - ret = (GLGlueContext *)tstate->cstate->data; - } - } - goto finish; - -finish: - _COREGL_FAST_FUNC_END(); - return (EGLContext)ret; -} - - -GLXDrawable -fpgl_glXGetCurrentDrawable(void) -{ - GLXDrawable ret = None; - GLThreadState *tstate = NULL; - - _COREGL_FAST_FUNC_BEGIN(); - - tstate = get_current_thread_state(); - - if (tstate != NULL) - ret = (GLGlueContext *)tstate->rsurf_draw; - - goto finish; - -finish: - _COREGL_FAST_FUNC_END(); - return ret; -} - -Bool -fpgl_glXMakeCurrent(Display* dpy, GLXDrawable draw, GLXContext ctx) -{ - Bool ret = False; - Bool need_mc = False; - GLGlueContext *gctx = NULL; - - GLThreadState *tstate = NULL; - GLContextState *cstate = NULL; - - _COREGL_FAST_FUNC_BEGIN(); - - gctx = (GLGlueContext *)ctx; - - tstate = get_current_thread_state(); - if (tstate == NULL) - { - // TODO : Move to Initialize - tstate = (GLThreadState *)calloc(1, sizeof(GLThreadState)); - tstate->thread_id = get_current_thread(); - - set_current_thread_state(&ctx_list_access_mutex, tstate); - - _add_to_general_trace_list(&thread_trace_list, tstate); - - tstate = get_current_thread_state(); - AST(tstate != NULL); - } - - // Fast path for context deletion - if (ctx == NULL) - { - AST(gctx == NULL); - if (draw != None) - { - // BB : full makecurrent when draw/read is specified - if (!_sym_glXMakeCurrent(dpy, draw, NULL)) - { - ERR("Error making context current with the drawable.\n"); - ret = False; - goto finish; - } - tstate->cstate = NULL; - } - - tstate->rsurf_draw = draw; - tstate->rsurf_read = draw; - ret = True; - goto finish; - } - - AST(gctx != NULL); - AST(gctx->cstate != NULL); - - if (gctx->rdpy != dpy) - { - ERR("Invalid context (or invalid Display)\n"); - ret = False; - goto finish; - } - - AST(gctx->real_ctx_option != NULL); - AST(gctx->real_ctx_sharable_option != NULL); - - // Handle cross threading of context (when used by two or more gctx) - if (gctx->thread_id != get_current_thread() && gctx->cstate->ref_count > 1) - { - GLContextState *cstate_new = NULL; - GLXContext *new_real_ctx = NULL; - - // Create a new context - { -#define ATTRIB_LIST_BUFFER_SIZE 8 - - Display dpy = NULL; - EGLConfig config = NULL; - int attrib_list[ATTRIB_LIST_BUFFER_SIZE]; - GLXContext real_share_context = NULL; - - _unpack_egl_context_option(gctx->real_ctx_option, &dpy, &config, attrib_list, ATTRIB_LIST_BUFFER_SIZE); - _unpack_egl_context_sharable_option(gctx->real_ctx_sharable_option, &real_share_context); - - AST(dpy == gctx->rdpy); - - new_real_ctx = _sym_glXCreateContext(dpy, config, real_share_context); - if (new_real_ctx == NULL) - { - ERR("Failed creating a egl context.\n"); - goto finish; - } - } - - cstate_new = (GLContextState *)calloc(1, sizeof(GLContextState)); - if (cstate_new == NULL) - { - ERR("Error creating a new context state.\n"); - goto finish; - } - - cstate_new->rctx = new_real_ctx; - cstate_new->rdpy = gctx->rdpy; - cstate_new->data = gctx; - - // TODO : Setup context state for new real ctx - - AST(add_context_state_to_list(gctx->real_ctx_option, gctx->real_ctx_option_len, cstate_new) == 1); - - _unlink_context_state(gctx->cstate, gctx); - gctx->cstate = cstate_new; - _link_context_state(gctx->cstate, gctx); - - // Apply to new thread - gctx->thread_id = get_current_thread(); - - } - - // Check if the object is correct - if (gctx->magic != MAGIC_GLFAST) - { - ERR("Magic Check Failed!!!\n"); - ret = False; - goto finish; - - } - - cstate = tstate->cstate; - - // If it's a first time or drawable changed, do a make current - if (cstate == NULL) - { - cstate = get_context_state_from_list(gctx->real_ctx_option, gctx->real_ctx_option_len); - - if (cstate == NULL) - { - ERR("Error making context current because context not ready.\n"); - ret = False; - goto finish; - } - need_mc = EGL_TRUE; - } - - // If drawable changed, do a make current - if ((tstate->rsurf_draw != draw) || - (tstate->rsurf_read != read)) - need_mc = True; - - // If binded real context changed, do a make current - if (gctx->cstate == NULL || - gctx->cstate->rctx != cstate->rctx) - need_mc = True; - - if (need_mc == True) - { - // BB : full makecurrent - if (!_sym_glXMakeCurrent(dpy, draw, cstate->rctx)) - { - ERR("Error making context current with the drawable.\n"); - ret = False; - goto finish; - } - - tstate->cstate = cstate; - - tstate->rsurf_draw = draw; - tstate->rsurf_read = read; - - gctx->cstate = cstate; - } - - // Initialize context states - if (gctx->initialized == 0) - { - if (init_context_states(gctx) != 1) - { - ERR("Error intializing context\n"); - goto finish; - } - if (tstate->cstate->data == NULL) - tstate->cstate->data = (void *)gctx; - } - - AST(tstate->cstate->data != NULL); - - if (tstate->cstate->data != gctx) - { - // restore needed - make_context_current((GLGlueContext *)tstate->cstate->data, gctx); - tstate->cstate->data = (void *)gctx; - } - - ret = True; - goto finish; - -finish: - -#ifdef COREGL_FASTPATH_TRACE_CONTEXT_INFO - { - char ment[256]; - sprintf(ment, "eglMakeCurrent finished (GlueCTX=[%12p] Surf=[D:%12p R:%12p])", ctx, draw, read); - _dump_context_info(ment, 0); - } -#endif // COREGL_FASTPATH_TRACE_CONTEXT_INFO - - _COREGL_FAST_FUNC_END(); - return ret; -} - - - - - - - - - - - - -GLGlueContext ectx = (GLGlueContext)ctx; - -_COREGL_FAST_FUNC_BEGIN(); -INIT_FAST_GLX_FUNC(); - -// Check if the values are null -if ((draw == None) || (ctx == NULL)) -{ - if (current_ctx) - real_current_ctx = current_ctx; - - /* - if (!_sym_glXMakeCurrent(dpy, None, NULL)) - { - ERR("Error making context current with the drawable.\n"); - return False; - } - */ - - current_ctx = NULL; - current_surf = None; - - return 1; -} - -// Check if the object is correct -if (ectx->magic != MAGIC_GLFAST) -{ - ERR("Magic Check Failed!!!\n"); - return 0; -} - - -// If it's the first time -if (!global_ctx_initted) -{ - if (!_sym_glXMakeCurrent(dpy, draw, global_ctx)) - { - ERR("Error making context current with the drawable.\n"); - return False; - } - - current_ctx = ectx; - current_surf = draw; - - real_current_ctx = current_ctx; - - global_ctx_initted = 1; -} - - -if (!current_ctx) current_ctx = real_current_ctx; - -// If drawable changed, do a make current -if (current_surf != draw) -{ - if (!_sym_glXMakeCurrent(dpy, draw, global_ctx)) - { - ERR("Error making context current with the drawable.\n"); - return False; - } - current_surf = draw; -} - -// If it's first time... -if (ectx->first_time == 1) -{ - // FIXME!!!: - // Actually, i need to query the drawable size... - // Do some initializations that required make_current - _sym_glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &ectx->num_tex_units); - _sym_glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &ectx->num_vertex_attribs); - _sym_glGetIntegerv(GL_VIEWPORT, ectx->gl_viewport); - _sym_glGetIntegerv(GL_SCISSOR_BOX, ectx->gl_scissor_box); - DBG("----Num Tex Units: %d, Num Vertex Attribs: %d \n", ectx->num_tex_units, ectx->num_vertex_attribs); - - ectx->first_time = 0; -} - -// if context is same, return -if ((current_ctx == ectx) && (current_surf == draw)) -{ - return True; -} - -make_context_current(current_ctx, ectx); - -current_ctx = ectx; -current_surf = draw; - -return True; -goto finish; - -finish: -_COREGL_FAST_FUNC_END(); -} - - - - - - - - - - - - - - -//----------------------------------------------------------------// -// Fastpath GLX Functions // -// The functions have prefix 'fpgl_' for (fastpath gl) // -//----------------------------------------------------------------// -GLXContext -fpgl_glXCreateContext(Display* dpy, XVisualInfo* vis, GLXContext shareList, Bool direct) -{ - GLGlueContext ctx; - - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GLX_FUNC(); - - // Create a global context if it hasn't been created - if (!global_ctx) - { - global_dpy = dpy; - // Create a global context if it hasn't been created yet - global_ctx = _sym_glXCreateContext(dpy, vis, NULL, 1); - if (!global_ctx) - { - ERR("Failed creating a glX global context for FastPath.\n"); - return 0; - } - ctx_ref_count++; - } - - // Allocate a new context - ctx = calloc(1, sizeof(struct _GLGlueContext)); - if (!ctx) - { - ERR("Error creating a new GLGlueContext.\n"); - return NULL; - } - - if (!init_context_states(ctx)) - { - ERR("Error intialing intial context\n"); - free(ctx); - return NULL; - } - - ctx_ref_count++; - - return (GLXContext)ctx; - - goto finish; - -finish: - _COREGL_FAST_FUNC_END(); -} - - -void -fpgl_glXDestroyContext(Display* dpy, GLXContext ctx) -{ - GLGlueContext ectx = (GLGlueContext)ctx; - - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GLX_FUNC(); - - if (ctx != NULL) - { - if (ectx->magic != MAGIC_GLFAST) - { - ERR("Magic Check Failed!!!\n"); - return; - } - - if (ectx == current_ctx) - { - DBG("Destroying current context... %d\n", ctx_ref_count); - real_current_ctx = current_ctx; - current_ctx = NULL; - } - - if (ectx) - free(ectx); - - if (!(--ctx_ref_count)) - { - DBG("Destroying the global context...\n"); - _sym_glXDestroyContext(dpy, global_ctx); - global_ctx = NULL; - current_ctx = NULL; - real_current_ctx = NULL; - } - } - goto finish; - -finish: - _COREGL_FAST_FUNC_END(); -} - - - -GLXContext -fpgl_glXGetCurrentContext(void) -{ - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GLX_FUNC(); - - return (GLXContext)current_ctx; - goto finish; - -finish: - _COREGL_FAST_FUNC_END(); -} - - -GLXDrawable -fpgl_glXGetCurrentDrawable(void) -{ - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GLX_FUNC(); - - //return _sym_glXGetCurrentDrawable(); - return (GLXDrawable)current_surf; - goto finish; - -finish: - _COREGL_FAST_FUNC_END(); -} - - - -Bool -fpgl_glXMakeCurrent(Display* dpy, GLXDrawable draw, GLXContext ctx) -{ - GLGlueContext ectx = (GLGlueContext)ctx; - - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GLX_FUNC(); - - // Check if the values are null - if ((draw == None) || (ctx == NULL)) - { - if (current_ctx) - real_current_ctx = current_ctx; - - /* - if (!_sym_glXMakeCurrent(dpy, None, NULL)) - { - ERR("Error making context current with the drawable.\n"); - return False; - } - */ - - current_ctx = NULL; - current_surf = None; - - return 1; - } - - // Check if the object is correct - if (ectx->magic != MAGIC_GLFAST) - { - ERR("Magic Check Failed!!!\n"); - return 0; - } - - - // If it's the first time - if (!global_ctx_initted) - { - if (!_sym_glXMakeCurrent(dpy, draw, global_ctx)) - { - ERR("Error making context current with the drawable.\n"); - return False; - } - - current_ctx = ectx; - current_surf = draw; - - real_current_ctx = current_ctx; - - global_ctx_initted = 1; - } - - - if (!current_ctx) current_ctx = real_current_ctx; - - // If drawable changed, do a make current - if (current_surf != draw) - { - if (!_sym_glXMakeCurrent(dpy, draw, global_ctx)) - { - ERR("Error making context current with the drawable.\n"); - return False; - } - current_surf = draw; - } - - // If it's first time... - if (ectx->first_time == 1) - { - // FIXME!!!: - // Actually, i need to query the drawable size... - // Do some initializations that required make_current - _sym_glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &ectx->num_tex_units); - _sym_glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &ectx->num_vertex_attribs); - _sym_glGetIntegerv(GL_VIEWPORT, ectx->gl_viewport); - _sym_glGetIntegerv(GL_SCISSOR_BOX, ectx->gl_scissor_box); - DBG("----Num Tex Units: %d, Num Vertex Attribs: %d \n", ectx->num_tex_units, ectx->num_vertex_attribs); - - ectx->first_time = 0; - } - - // if context is same, return - if ((current_ctx == ectx) && (current_surf == draw)) - { - return True; - } - - make_context_current(current_ctx, ectx); - - current_ctx = ectx; - current_surf = draw; - - return True; - goto finish; - -finish: - _COREGL_FAST_FUNC_END(); -} - - -Bool -fpgl_glXMakeContextCurrent(Display* dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx) -{ - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GLX_FUNC(); - - ERR("NOT IMPLEMENTED YET!!! GLX Function Wrapped. Not fastpathed yet...\n"); - return _sym_glXMakeContextCurrent(dpy, draw, read, ctx); - goto finish; - -finish: - _COREGL_FAST_FUNC_END(); -} - -#endif - diff --git a/src/coregl_internal.h b/src/coregl_internal.h index 2e93e5c..76a18f6 100644 --- a/src/coregl_internal.h +++ b/src/coregl_internal.h @@ -5,6 +5,8 @@ #include "coregl.h" +#include "modules/coregl_module.h" + #define unlikely(x) __builtin_expect(x, 0) // Symbol definition for real @@ -26,11 +28,13 @@ # define LOG(...) \ fprintf(stderr, __VA_ARGS__) + # define TRACE(...) \ fprintf(trace_fp, __VA_ARGS__) - # define TRACE_END() \ fflush(trace_fp) +#define _COREGL_TRACE_OUTPUT_INTERVAL_SEC 5 + #ifdef COREGL_DEBUG # define AST(expr) \ @@ -43,16 +47,6 @@ typedef GLvoid * GLvoidptr; typedef GLuint GLuintmask; -#define COREGL_TRACE_ALL - -#ifdef COREGL_TRACE_ALL -#define COREGL_TRACE_CONTEXT_INFO // Context state & thread state & Glue-context info -#define COREGL_TRACE_STATE_INFO // Glue-context state info -#define COREGL_TRACE_APICALL_INFO // API call frequency info -#endif - -#define _COREGL_TRACE_OUTPUT_INTERVAL_SEC 5 - #define _COREGL_INT_INIT_VALUE -3 #ifdef COREGL_ERRORS @@ -63,89 +57,23 @@ typedef GLuint GLuintmask; typedef struct _Trace_Data Trace_Data; -#ifdef COREGL_TRACE_APICALL_INFO -# define _COREGL_TRACE_API_BEGIN(api, hint, trace_total_time) \ - trace_begin(api, hint, trace_total_time); -# define _COREGL_TRACE_API_END(api, hint, trace_total_time) \ - trace_end(api, hint, trace_total_time); -# define _COREGL_TRACE_API_OUTPUT(force_output) \ - trace_output(force_output); -#else -# define _COREGL_TRACE_API_BEGIN(api, hint, trace_total_time) NULL; -# define _COREGL_TRACE_API_END(api, hint, trace_total_time) -# define _COREGL_TRACE_API_OUTPUT(force_output) -#endif - - -#define _COREGL_FAST_FUNC_BEGIN() - -#define _COREGL_FAST_FUNC_END() - -#define _COREGL_FAST_FUNC_SYMCALL_BEGIN() - -#define _COREGL_FAST_FUNC_SYMCALL_END() - -#define _COREGL_WRAP_FUNC_BEGIN() \ - if (unlikely(trace_api_flag == 1)) \ - _COREGL_TRACE_API_BEGIN(__func__, NULL, 1); +#define COREGL_OVERRIDE_API(mangle, func, prefix) \ + mangle##func = prefix##func -#define _COREGL_WRAP_FUNC_END() \ - if (unlikely(trace_api_flag == 1)) \ - _COREGL_TRACE_API_END(__func__, NULL, 1); - -typedef enum _CoreGL_Opt_Flag -{ - COREGL_UNKNOWN_PATH, - COREGL_NORMAL_PATH, - COREGL_FAST_PATH -} CoreGL_Opt_Flag; - -extern CoreGL_Opt_Flag api_opt; - -#ifndef _COREGL_DESKTOP_GL typedef EGLSurface GLSurface; typedef EGLDisplay GLDisplay; typedef EGLContext GLContext; -#else -typedef GLXDrawable GLSurface; -typedef Display GLDisplay; -typedef GLXContext GLContext; -#endif - -typedef struct _GLContextState -{ - int ref_count; - GLContext *rctx; - GLDisplay *rdpy; - void *data; -} GLContextState; typedef struct _GLThreadState { int thread_id; - EGLenum binded_api; - GLContextState *cstate; - GLSurface *rsurf_draw; - GLSurface *rsurf_read; - Trace_Data **ftd_table; + void *module_data[COREGL_MAX_MODULES]; } GLThreadState; -typedef struct _GLContext_List -{ - void *option; - int option_len; - int thread_id; - GLContextState *cstate; - struct _GLContext_List *next; -} GLContext_List; - extern void *glue_lib_handle; extern void *egl_lib_handle; -extern GLContext_List *glctx_list; - #include "coregl_thread_pthread.h" -extern Mutex ctx_list_access_mutex; typedef struct _General_Trace_List { @@ -156,14 +84,15 @@ typedef struct _General_Trace_List extern General_Trace_List *thread_trace_list; extern Mutex general_trace_lists_access_mutex; +extern FILE *trace_fp; + extern int trace_api_flag; +extern int trace_api_all_flag; extern int trace_ctx_flag; extern int trace_ctx_force_flag; extern int trace_state_flag; -extern int debug_nofp; -extern FILE *trace_fp; -#define NEED_WRAPPING (trace_api_flag == 1 || trace_ctx_flag == 1 || trace_state_flag == 1) +#define USE_TRACEPATH (trace_api_flag == 1 || trace_ctx_flag == 1 || trace_state_flag == 1) // Environment functions extern const char *get_env_setting(const char *name); @@ -175,31 +104,24 @@ extern int init_new_thread_state(); extern int mutex_lock(Mutex *mt); extern int mutex_unlock(Mutex *mt); extern int get_current_thread(); -extern int set_current_thread_state(Mutex *mt, GLThreadState *tstate); +extern int set_current_thread_state(GLThreadState *tstate); extern GLThreadState *get_current_thread_state(); -// Context state functions -extern int add_context_state_to_list(const void *data, const int datalen, GLContextState *cstate, Mutex *mtx); -extern int remove_context_states_from_list(GLContextState *cstate, Mutex *mtx); -extern GLContextState *get_context_state_from_list(const void *data, const int datalen, Mutex *mtx); - - // Override functions -extern void override_glue_normal_path(); -extern void override_glue_fast_path(); -extern void override_gl_normal_path(); -extern void override_gl_fast_path(); -extern void override_glue_apis(CoreGL_Opt_Flag opt); -extern void override_gl_apis(CoreGL_Opt_Flag opt); +extern void init_export(); +extern void deinit_export(); + +// Module interfaces +extern void init_modules(); +extern void deinit_modules(); +extern void init_modules_tstate(GLThreadState *tstate); +extern void deinit_modules_tstate(GLThreadState *tstate); // Debug & Trace functions extern int add_to_general_trace_list(General_Trace_List **gtl, void *value); extern int remove_from_general_trace_list(General_Trace_List **gtl, void *value); -extern void *trace_begin(const char *name, void *hint, int trace_total_time); -extern void *trace_end(const char *name, void *hint, int trace_total_time); -extern void trace_output(int force_output); #endif // COREGL_INTERNAL_H diff --git a/src/coregl_override.c b/src/coregl_override.c index 4d6a640..536c0da 100644 --- a/src/coregl_override.c +++ b/src/coregl_override.c @@ -1,7 +1,5 @@ #include "coregl_internal.h" #include "coregl_export.h" -#include "coregl_wrappath.h" -#include "coregl_fastpath.h" #include @@ -9,266 +7,18 @@ mangle##func = prefix##func void -override_glue_normal_path() +init_overrides() { #define C_ORD(f) COREGL_OVERRIDE_API(ovr_, f, _sym_) -#define N_ORD(f) COREGL_OVERRIDE_API(ovr_, f, wpgl_); COREGL_OVERRIDE_API(wrp_, f, _sym_) - if (NEED_WRAPPING) - { -#define _COREGL_SYMBOL(IS_EXTENSION, RET_TYPE, FUNC_NAME, PARAM_LIST) N_ORD(FUNC_NAME); -# ifndef _COREGL_DESKTOP_GL -# include "headers/sym_egl.h" -# else -# include "headers/sym_glx.h" -# endif -#undef _COREGL_SYMBOL - } - else - { #define _COREGL_SYMBOL(IS_EXTENSION, RET_TYPE, FUNC_NAME, PARAM_LIST) C_ORD(FUNC_NAME); -# ifndef _COREGL_DESKTOP_GL -# include "headers/sym_egl.h" -# else -# include "headers/sym_glx.h" -# endif +# include "headers/sym_egl.h" #undef _COREGL_SYMBOL - } - -#undef N_ORD -#undef C_ORD -} - -void -override_glue_fast_path() -{ - // Inherit from normal path - override_glue_normal_path(); - -#define F_ORD(f) \ - if (NEED_WRAPPING) \ - COREGL_OVERRIDE_API(wrp_, f, fpgl_); \ - else \ - COREGL_OVERRIDE_API(ovr_, f, fpgl_); - - -#ifndef _COREGL_DESKTOP_GL - // Fast-Path Core Functions - F_ORD(eglGetProcAddress); - - F_ORD(eglBindAPI); - F_ORD(eglQueryAPI); - - F_ORD(eglCreateContext); - F_ORD(eglCreateImageKHR); - F_ORD(eglMakeCurrent); - F_ORD(eglDestroyContext); - F_ORD(eglQueryContext); - F_ORD(eglGetCurrentContext); - F_ORD(eglReleaseThread); - F_ORD(eglGetCurrentSurface); - F_ORD(eglTerminate); -#else - // Fastpath-ed Functions - F_ORD(glXCreateContext); - F_ORD(glXDestroyContext); - F_ORD(glXMakeCurrent); - F_ORD(glXGetCurrentContext); - F_ORD(glXGetCurrentDrawable); - - F_ORD(glXMakeContextCurrent); -#endif - -#undef F_ORD -} - -void -override_gl_normal_path() -{ -#define C_ORD(f) COREGL_OVERRIDE_API(ovr_, f, _sym_) -#define N_ORD(f) COREGL_OVERRIDE_API(ovr_, f, wpgl_); COREGL_OVERRIDE_API(wrp_, f, _sym_) - - if (NEED_WRAPPING) - { -#define _COREGL_SYMBOL(IS_EXTENSION, RET_TYPE, FUNC_NAME, PARAM_LIST) N_ORD(FUNC_NAME); -# include "headers/sym_gl.h" -#undef _COREGL_SYMBOL - } - else - { #define _COREGL_SYMBOL(IS_EXTENSION, RET_TYPE, FUNC_NAME, PARAM_LIST) C_ORD(FUNC_NAME); # include "headers/sym_gl.h" #undef _COREGL_SYMBOL - } -#undef N_ORD #undef C_ORD } -void -override_gl_fast_path() -{ - // Inherit from normal path - override_gl_normal_path(); - -#define F_ORD(f) \ - if (NEED_WRAPPING) \ - COREGL_OVERRIDE_API(wrp_, f, fpgl_); \ - else \ - COREGL_OVERRIDE_API(ovr_, f, fpgl_); - - // Fast-Path Functions - if (debug_nofp != 1) - { - F_ORD(glGetError); - - F_ORD(glGetIntegerv); - F_ORD(glGetFloatv); - F_ORD(glGetBooleanv); - - F_ORD(glActiveTexture); - F_ORD(glGenTextures); - F_ORD(glBindTexture); - F_ORD(glIsTexture); - F_ORD(glDeleteTextures); - F_ORD(glFramebufferTexture2D); - F_ORD(glFramebufferTexture2DMultisampleEXT); - - F_ORD(glGenBuffers); - F_ORD(glBindBuffer); - F_ORD(glIsBuffer); - F_ORD(glDeleteBuffers); - - F_ORD(glGenFramebuffers); - F_ORD(glBindFramebuffer); - F_ORD(glIsFramebuffer); - F_ORD(glDeleteFramebuffers); - - F_ORD(glGenRenderbuffers); - F_ORD(glBindRenderbuffer); - F_ORD(glFramebufferRenderbuffer); - F_ORD(glIsRenderbuffer); - F_ORD(glDeleteRenderbuffers); - - F_ORD(glCreateShader); - F_ORD(glCreateProgram); - F_ORD(glAttachShader); - F_ORD(glCompileShader); - F_ORD(glShaderBinary); - F_ORD(glDeleteShader); - F_ORD(glDetachShader); - F_ORD(glGetShaderiv); - F_ORD(glGetShaderInfoLog); - F_ORD(glGetShaderSource); - F_ORD(glIsShader); - F_ORD(glShaderSource); - F_ORD(glBindAttribLocation); - F_ORD(glDeleteProgram); - F_ORD(glDetachShader); - F_ORD(glGetActiveAttrib); - F_ORD(glGetActiveUniform); - F_ORD(glGetAttachedShaders); - F_ORD(glGetAttribLocation); - F_ORD(glGetProgramiv); - F_ORD(glGetProgramInfoLog); - F_ORD(glGetUniformfv); - F_ORD(glGetUniformiv); - F_ORD(glGetUniformLocation); - F_ORD(glIsProgram); - F_ORD(glLinkProgram); - F_ORD(glUseProgram); - F_ORD(glValidateProgram); - F_ORD(glGetProgramBinary); - F_ORD(glProgramBinary); - - F_ORD(glBlendColor); - F_ORD(glBlendEquation); - F_ORD(glBlendEquationSeparate); - F_ORD(glBlendFunc); - F_ORD(glBlendFuncSeparate); - F_ORD(glClearColor); - F_ORD(glClearDepthf); - F_ORD(glClearStencil); - F_ORD(glColorMask); - F_ORD(glCullFace); - F_ORD(glDepthFunc); - F_ORD(glDepthMask); - F_ORD(glDepthRangef); - F_ORD(glDisable); - F_ORD(glDisableVertexAttribArray); - F_ORD(glDrawArrays); - F_ORD(glDrawElements); - F_ORD(glEnable); - F_ORD(glEnableVertexAttribArray); - F_ORD(glFrontFace); - F_ORD(glGetVertexAttribfv); - F_ORD(glGetVertexAttribiv); - F_ORD(glGetVertexAttribPointerv); - F_ORD(glHint); - F_ORD(glLineWidth); - F_ORD(glPixelStorei); - F_ORD(glPolygonOffset); - F_ORD(glSampleCoverage); - F_ORD(glScissor); - F_ORD(glStencilFunc); - F_ORD(glStencilFuncSeparate); - F_ORD(glStencilMask); - F_ORD(glStencilMaskSeparate); - F_ORD(glStencilOp); - F_ORD(glStencilOpSeparate); - F_ORD(glVertexAttrib1f); - F_ORD(glVertexAttrib1fv); - F_ORD(glVertexAttrib2f); - F_ORD(glVertexAttrib2fv); - F_ORD(glVertexAttrib3f); - F_ORD(glVertexAttrib3fv); - F_ORD(glVertexAttrib4f); - F_ORD(glVertexAttrib4fv); - F_ORD(glVertexAttribPointer); - F_ORD(glViewport); - - F_ORD(glEGLImageTargetTexture2DOES); - - } - else - { - LOG("\E[0;35;1m[CoreGL] SKIP GL FASTPATH...\E[0m\n"); - } - -#undef F_ORD -} - - -void -override_glue_apis(CoreGL_Opt_Flag opt) -{ - switch (opt) - { - case COREGL_NORMAL_PATH: - override_glue_normal_path(); - break; - case COREGL_FAST_PATH: - override_glue_fast_path(); - break; - default: - ERR("Invalide GL Override Option!!!\n"); - } -} - -void -override_gl_apis(CoreGL_Opt_Flag opt) -{ - switch (opt) - { - case COREGL_NORMAL_PATH: - override_gl_normal_path(); - break; - case COREGL_FAST_PATH: - override_gl_fast_path(); - break; - default: - ERR("Invalide GL Override Option!!!\n"); - } -} - diff --git a/src/coregl_thread_pthread.c b/src/coregl_thread_pthread.c index aee8ae3..a06eb0f 100644 --- a/src/coregl_thread_pthread.c +++ b/src/coregl_thread_pthread.c @@ -5,10 +5,11 @@ int mutex_lock(Mutex *mt); int mutex_unlock(Mutex *mt); int get_current_thread(); -int set_current_thread_state(Mutex *mt, GLThreadState *tstate); +int set_current_thread_state(GLThreadState *tstate); GLThreadState * get_current_thread_state(); ////////////////////////////////////////////////////////////////////////// +static Mutex thread_key_mutex = MUTEX_INITIALIZER; static int thread_key_inited = 0; static pthread_key_t thread_key = 0; @@ -45,11 +46,11 @@ get_current_thread() } int -set_current_thread_state(Mutex *mt, GLThreadState *tstate) +set_current_thread_state(GLThreadState *tstate) { int ret = 0; - AST(mutex_lock(mt) == 1); + AST(mutex_lock(&thread_key_mutex) == 1); if (thread_key_inited == 0) { @@ -73,7 +74,7 @@ set_current_thread_state(Mutex *mt, GLThreadState *tstate) goto finish; finish: - AST(mutex_unlock(mt) == 1); + AST(mutex_unlock(&thread_key_mutex) == 1); return ret; } diff --git a/src/coregl_trace.c b/src/coregl_trace.c index 7628b92..4d1c335 100644 --- a/src/coregl_trace.c +++ b/src/coregl_trace.c @@ -4,138 +4,15 @@ #include #include -#define MAX_TRACE_NAME_LENGTH 256 -#define MAX_TRACE_TABLE_SIZE 65536 - -#define TIMEVAL_INIT { 0, 0 } - -struct _Trace_Data -{ - char name[MAX_TRACE_NAME_LENGTH]; - int call_count; - int last_call_count; - struct timeval elapsed_time; - struct timeval last_elapsed_time; - struct timeval total_elapsed_time; - struct timeval last_total_elapsed_time; - struct timeval last_time; - - int traced; - - struct _Trace_Data *next; -}; +int trace_api_flag = 0; +int trace_api_all_flag = 0; +int trace_ctx_flag = 0; +int trace_ctx_force_flag = 0; +int trace_state_flag = 0; General_Trace_List *thread_trace_list = NULL; Mutex general_trace_lists_access_mutex = MUTEX_INITIALIZER; -struct timeval initial_time = TIMEVAL_INIT; -struct timeval last_initial_time = TIMEVAL_INIT; - -struct timeval last_trace_time = TIMEVAL_INIT; -struct timeval other_elapsed_time = TIMEVAL_INIT; -struct timeval traced_other_elapsed_time = TIMEVAL_INIT; - - -static inline void -_add_timeval_period(struct timeval *tv_dst, struct timeval tv_now, struct timeval tv_old) -{ - tv_dst->tv_sec += tv_now.tv_sec - tv_old.tv_sec; - tv_dst->tv_usec += 1000000 + (tv_now.tv_usec - tv_old.tv_usec); - tv_dst->tv_sec += (tv_dst->tv_usec / 1000000) - 1; - tv_dst->tv_usec = tv_dst->tv_usec % 1000000; -} - -static inline void -_add_timeval(struct timeval *tv_dst, struct timeval tv_src) -{ - tv_dst->tv_sec += tv_src.tv_sec; - tv_dst->tv_usec += tv_src.tv_usec; - if (tv_dst->tv_usec > 1000000) - { - tv_dst->tv_usec -= 1000000; - tv_dst->tv_sec++; - } - else if (tv_dst->tv_usec < 0) - { - tv_dst->tv_usec += 1000000; - tv_dst->tv_sec--; - } -} - -static inline double -_get_timeval_period(struct timeval time_now, struct timeval time_old) -{ - return ((time_now.tv_sec - time_old.tv_sec) * 1000) + ((time_now.tv_usec - time_old.tv_usec) / 1000.0); -} - -static inline double -_get_timeval(struct timeval time) -{ - return (time.tv_sec * 1000) + (time.tv_usec / 1000.0); -} - -static unsigned short -_generate_hash_short(const char *string) -{ - unsigned short hash = 0; - int i; - - for (i = 0; i < strlen(string); i++) - { - hash = 253 * hash + string[i]; - } - return (hash ^ (hash >> 8)) % MAX_TRACE_TABLE_SIZE; -} - -static Trace_Data * -_get_trace_data(Trace_Data **ftd_table, const char *name) -{ - Trace_Data *ret = NULL; - Trace_Data *current = NULL; - Trace_Data *prev = NULL; - unsigned short hash = 0; - - AST(strlen(name) < MAX_TRACE_NAME_LENGTH); - - hash = _generate_hash_short(name); - - current = ftd_table[hash]; - - while (current != NULL && current->next != NULL) - { - if (strcmp(current->name, name) == 0) - break; - prev = current; - current = current->next; - } - - if (current != NULL) - { - ret = current; - } - else - { - Trace_Data *newitm = NULL; - newitm = (Trace_Data *)calloc(1, sizeof(Trace_Data)); - strcpy(newitm->name, name); - newitm->next = NULL; - - if (prev != NULL) - { - prev->next = newitm; - } - else - { - ftd_table[hash] = newitm; - } - ret = newitm; - } - - goto finish; - -finish: - return ret; -} int add_to_general_trace_list(General_Trace_List **gtl, void *value) @@ -192,327 +69,3 @@ finish: return ret; } -void * -trace_begin(const char *funcname, void *hint, int trace_total_time) -{ - Trace_Data *ftd = NULL; - struct timeval t = TIMEVAL_INIT; - - if (trace_api_flag == 1) - { - AST(gettimeofday(&t, NULL) == 0); - - ftd = (Trace_Data *)hint; - - if (ftd == NULL) - { - GLThreadState *tstate = NULL; - tstate = get_current_thread_state(); - - if (tstate == NULL) - { - init_new_thread_state(); - - tstate = get_current_thread_state(); - AST(tstate != NULL); - } - - if (tstate->ftd_table == NULL) - { - tstate->ftd_table = (Trace_Data **)calloc(1, sizeof(Trace_Data *) * MAX_TRACE_TABLE_SIZE); - } - - ftd = _get_trace_data(tstate->ftd_table, funcname); - } - - AST(ftd != NULL); - - ftd->call_count++; - AST(ftd->last_time.tv_sec == 0); - - AST(gettimeofday(&ftd->last_time, NULL) == 0); - - if (initial_time.tv_sec == 0) - { - initial_time = ftd->last_time; - last_initial_time = ftd->last_time; - } - - if (trace_total_time == 1) - { - if (last_trace_time.tv_sec != 0) - { - _add_timeval_period(&other_elapsed_time, t, last_trace_time); - last_trace_time.tv_sec = 0; - } - } - - } - - return ftd; -} - -void * -trace_end(const char *funcname, void *hint, int trace_total_time) -{ - Trace_Data *ftd = NULL; - struct timeval t = TIMEVAL_INIT; - - if (trace_api_flag == 1) - { - GLThreadState *tstate = NULL; - struct timeval elapsed_time = TIMEVAL_INIT; - - AST(gettimeofday(&t, NULL) == 0); - - ftd = (Trace_Data *)hint; - - if (ftd == NULL) - { - tstate = get_current_thread_state(); - - if (tstate == NULL) - { - init_new_thread_state(); - - tstate = get_current_thread_state(); - AST(tstate != NULL); - } - AST(tstate->ftd_table != NULL); - - ftd = _get_trace_data(tstate->ftd_table, funcname); - } - - AST(ftd != NULL); - - _add_timeval_period(&elapsed_time, t, ftd->last_time); - - _add_timeval(&ftd->elapsed_time, elapsed_time); - - - ftd->last_time.tv_sec = 0; - - if (trace_total_time == 1) - { - _add_timeval(&ftd->total_elapsed_time, elapsed_time); - - AST(gettimeofday(&last_trace_time, NULL) == 0); - - if (initial_time.tv_sec == 0) - { - initial_time = t; - last_initial_time = t; - } - } - - } - - - return ftd; -} - -void -trace_output(int force_output) -{ - static struct timeval tv_last = TIMEVAL_INIT; - struct timeval total_now = TIMEVAL_INIT; - GLThreadState *tstate = NULL; - Trace_Data **ftd_table = NULL; - - double total_elapsed_time = 0.0; - double total_elapsed_time_period = 0.0; - double total_opengl_elapsed_time = 0.0; - double total_opengl_elapsed_time_period = 0.0; - double total_other_elapsed_time = 0.0; - double total_other_elapsed_time_period = 0.0; - - double swaps_per_sec = 0.0; - - int i; - - if (trace_api_flag != 1) - { - goto finish; - } - - if (!force_output) - { - struct timeval tv_now = TIMEVAL_INIT; - AST(gettimeofday(&tv_now, NULL) == 0); - if (tv_now.tv_sec - tv_last.tv_sec < _COREGL_TRACE_OUTPUT_INTERVAL_SEC) - { - goto finish; - } - tv_last = tv_now; - } - - AST(gettimeofday(&total_now, NULL) == 0); - - total_elapsed_time = _get_timeval_period(total_now, initial_time); - total_elapsed_time_period = _get_timeval_period(total_now, last_initial_time); - last_initial_time = total_now; - - total_other_elapsed_time = _get_timeval(other_elapsed_time); - total_other_elapsed_time_period = _get_timeval_period(other_elapsed_time, traced_other_elapsed_time); - traced_other_elapsed_time = other_elapsed_time; - - tstate = get_current_thread_state(); - - if (tstate == NULL) - { - init_new_thread_state(); - - tstate = get_current_thread_state(); - AST(tstate != NULL); - } - - - ftd_table = tstate->ftd_table; - if (ftd_table == NULL) return; - - { - static Trace_Data *trace_hint_swap = NULL; - if (trace_hint_swap == NULL) - trace_hint_swap = _get_trace_data(ftd_table, "eglSwapBuffers"); - - if (trace_hint_swap != NULL && total_elapsed_time_period > 0) - { - swaps_per_sec = (trace_hint_swap->call_count - trace_hint_swap->last_call_count) / (total_elapsed_time_period / 1000); - } - } - - - 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++) - { - if (ftd_table[i] != NULL) - { - Trace_Data *current = ftd_table[i]; - - while (current != NULL) - { - double elapsed_time = _get_timeval(current->elapsed_time); - double elapsed_time_per_call = elapsed_time / current->call_count; - - total_opengl_elapsed_time += _get_timeval(current->total_elapsed_time); - total_opengl_elapsed_time_period += _get_timeval(current->total_elapsed_time) - _get_timeval(current->last_total_elapsed_time); - - current->traced = 0; - - if (current->call_count > current->last_call_count) - { - double elapsed_time_period = _get_timeval_period(current->elapsed_time, current->last_elapsed_time); - double elapsed_time_per_call_period = elapsed_time_period / (current->call_count - current->last_call_count); - char *fname = current->name; - - if (!strncmp(fname, "wpgl_", 5)) - fname = ¤t->name[5]; - - if (elapsed_time_per_call_period >= 0.01 || current->call_count - current->last_call_count > 1000) - { - 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", - fname, current->call_count, elapsed_time, elapsed_time_per_call, elapsed_time_per_call_period); - current->traced = 1; - } - } - current = current->next; - } - } - } - - { - int fp_env = 0; - fp_env = atoi(get_env_setting("COREGL_TRACE_API_ALL")); - if (fp_env == 1) - { - // other - for (i = 0; i < MAX_TRACE_TABLE_SIZE; i++) - { - if (ftd_table[i] != NULL) - { - Trace_Data *current = ftd_table[i]; - - while (current != NULL) - { - if (current->traced == 0) - { - double elapsed_time = _get_timeval(current->elapsed_time); - double elapsed_time_per_call = elapsed_time / current->call_count; - char *fname = current->name; - - if (!strncmp(fname, "wpgl_", 5)) - fname = ¤t->name[5]; - - TRACE(" %-42.42s : %10d call(s), %10.2f ms, %9.3f ms/API\n", - fname, current->call_count, elapsed_time, elapsed_time_per_call); - } - current = current->next; - } - } - } - } - } - - TRACE("\E[40;34m========================================================================================================================\E[0m\n"); - - 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); - - - 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); - - 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); - - 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); - - TRACE("\E[40;34m========================================================================================================================\E[0m\n"); - TRACE("\n"); - - for (i = 0; i < MAX_TRACE_TABLE_SIZE; i++) - { - if (ftd_table[i] != NULL) - { - Trace_Data *current = ftd_table[i]; - - while (current != NULL) - { - current->last_call_count = current->call_count; - current->last_elapsed_time = current->elapsed_time; - current->last_total_elapsed_time = current->total_elapsed_time; - current = current->next; - } - } - } - - TRACE_END(); - - goto finish; - -finish: - return; -} - diff --git a/src/coregl_wrappath.c b/src/coregl_wrappath.c deleted file mode 100644 index 1107aa5..0000000 --- a/src/coregl_wrappath.c +++ /dev/null @@ -1,115 +0,0 @@ -#include "coregl_wrappath.h" - -#include -#include -#include - -typedef struct _GLGlueFakeContext -{ - GLuint gl_num_tex_units[1]; - GLuint gl_num_vertex_attribs[1]; -} GLGlueFakeContext; - -GLGlueFakeContext initial_fake_ctx_real; -GLGlueFakeContext *initial_fake_ctx = &initial_fake_ctx_real; - - -static void -_get_texture_states(GLenum pname, GLint *params) -{ - GLuint cur_active_tex = 0; - - AST(initial_fake_ctx != NULL); - - _sym_glGetIntegerv(GL_ACTIVE_TEXTURE, (GLint *)&cur_active_tex); - int i; - for (i = 0; i < initial_fake_ctx->gl_num_tex_units[0]; i++) - { - _sym_glActiveTexture(GL_TEXTURE0 + i); - _sym_glGetIntegerv(pname, &(((GLint *)params)[i])); - } - _sym_glActiveTexture(cur_active_tex); -} - -void -init_wrap_gl() -{ -} - -void -free_wrap_gl() -{ -} - -void -dump_wrap_context_states(int force_output) -{ - static struct timeval tv_last = { 0, 0 }; - - if (unlikely(trace_state_flag != 1)) return; - - _sym_glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, (GLint *)initial_fake_ctx->gl_num_tex_units); - _sym_glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, (GLint *)initial_fake_ctx->gl_num_vertex_attribs); - - if (!force_output) - { - struct timeval tv_now = { 0, 0 }; - AST(gettimeofday(&tv_now, NULL) == 0); - if (tv_now.tv_sec - tv_last.tv_sec < _COREGL_TRACE_OUTPUT_INTERVAL_SEC) - { - goto finish; - } - tv_last = tv_now; - } - - 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" -#define PRINTF_CHAR_GLint "%10d" -#define PRINTF_CHAR_GLsizei "%10u" -#define PRINTF_CHAR_GLuint "%10u" -#define PRINTF_CHAR_GLuintmask "0x%8X" - -#define PRINTF_CHAR_GLclampf "%10.6f" -#define PRINTF_CHAR_GLfloat "%10.6f" - -#define PRINTF_CHAR_GLvoidptr "%10p" - -#define PRINTF_CHAR(type) PRINTF_CHAR_##type - -#define INITIAL_CTX initial_fake_ctx - -#define GLUE_STATE(TYPE, NAME, SIZE, ARRAY_SIZE, DEFAULT_STMT, GET_STMT) \ - { \ - TYPE valuedata[SIZE]; \ - TYPE *value = NULL; \ - value = valuedata; GET_STMT; value = valuedata; \ - TRACE("\E[0;37;1m %-30.30s : (\E[0m ", #NAME); \ - for (int i = 0; i < SIZE; i++) \ - { \ - if (i > 0) { \ - if (i % 4 == 0) \ - TRACE("\n %-30.30s ", "");\ - else \ - TRACE(", "); \ - } \ - TRACE("["PRINTF_CHAR(TYPE)"]", value[i]); \ - } \ - TRACE(" \E[0;37;1m)\E[0m\n"); \ - } -# include "coregl_fastpath_state.h" -#undef GLUE_STATE - - TRACE("\E[0;40;34m===================================================================================================================\E[0m\n"); - TRACE("\n"); - - TRACE_END(); - -finish: - return; -} - diff --git a/src/coregl_wrappath.h b/src/coregl_wrappath.h deleted file mode 100644 index 8761216..0000000 --- a/src/coregl_wrappath.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef COREGL_WRAPPATH_H -#define COREGL_WRAPPATH_H - -#include "coregl_internal.h" -#include "coregl_export.h" - -// Symbol definition for wrappath -#define _COREGL_SYMBOL(IS_EXTENSION, RET_TYPE, FUNC_NAME, PARAM_LIST) extern RET_TYPE (wpgl_##FUNC_NAME) PARAM_LIST; -# include "headers/sym.h" -#undef _COREGL_SYMBOL - -extern void init_wrap_gl(); -extern void free_wrap_gl(); - -extern void dump_wrap_context_states(int force_output); - -#endif // COREGL_WRAPPATH_H - diff --git a/src/coregl_wrappath_egl.c b/src/coregl_wrappath_egl.c deleted file mode 100644 index 92f9e85..0000000 --- a/src/coregl_wrappath_egl.c +++ /dev/null @@ -1,585 +0,0 @@ -#include "coregl_wrappath.h" - -EGLint -wpgl_eglGetError(void) -{ - EGLint ret = _COREGL_INT_INIT_VALUE; - - _COREGL_WRAP_FUNC_BEGIN(); - ret = wrp_eglGetError(); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); - return ret; -} - -EGLDisplay -wpgl_eglGetDisplay(EGLNativeDisplayType display_id) -{ - EGLDisplay ret = EGL_NO_DISPLAY; - - _COREGL_WRAP_FUNC_BEGIN(); - ret = wrp_eglGetDisplay(display_id); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); - return ret; -} - -EGLBoolean -wpgl_eglInitialize(EGLDisplay dpy, EGLint* major, EGLint* minor) -{ - EGLBoolean ret = EGL_FALSE; - _COREGL_WRAP_FUNC_BEGIN(); - ret = wrp_eglInitialize(dpy, major, minor); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); - return ret; -} - -EGLBoolean -wpgl_eglTerminate(EGLDisplay dpy) -{ - EGLBoolean ret = EGL_FALSE; - - _COREGL_WRAP_FUNC_BEGIN(); - ret = wrp_eglTerminate(dpy); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); - return ret; -} - -EGLBoolean -wpgl_eglGetConfigs(EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config) -{ - EGLBoolean ret = EGL_FALSE; - - _COREGL_WRAP_FUNC_BEGIN(); - ret = wrp_eglGetConfigs(dpy, configs, config_size, num_config); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); - return ret; -} - -EGLBoolean -wpgl_eglChooseConfig(EGLDisplay dpy, const EGLint* attrib_list, EGLConfig* configs, EGLint config_size, EGLint* num_config) -{ - EGLBoolean ret = EGL_FALSE; - - _COREGL_WRAP_FUNC_BEGIN(); - ret = wrp_eglChooseConfig(dpy, attrib_list, configs, config_size, num_config); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); - return ret; -} - -EGLBoolean -wpgl_eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value) -{ - EGLBoolean ret = EGL_FALSE; - - _COREGL_WRAP_FUNC_BEGIN(); - ret = wrp_eglGetConfigAttrib(dpy, config, attribute, value); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); - return ret; -} - - -EGLSurface -wpgl_eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint* attrib_list) -{ - EGLSurface ret = EGL_NO_SURFACE; - - _COREGL_WRAP_FUNC_BEGIN(); - ret = wrp_eglCreateWindowSurface(dpy, config, win, attrib_list); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); - return ret; -} - -EGLSurface -wpgl_eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list) -{ - EGLSurface ret = EGL_NO_SURFACE; - - _COREGL_WRAP_FUNC_BEGIN(); - ret = wrp_eglCreatePbufferSurface(dpy, config, attrib_list); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); - return ret; -} - -EGLSurface -wpgl_eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint* attrib_list) -{ - EGLSurface ret = EGL_NO_SURFACE; - - _COREGL_WRAP_FUNC_BEGIN(); - ret = wrp_eglCreatePixmapSurface(dpy, config, pixmap, attrib_list); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); - return ret; -} - -EGLBoolean -wpgl_eglDestroySurface(EGLDisplay dpy, EGLSurface surface) -{ - EGLBoolean ret = EGL_FALSE; - - _COREGL_WRAP_FUNC_BEGIN(); - ret = wrp_eglDestroySurface(dpy, surface); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); - return ret; -} - -EGLBoolean -wpgl_eglQuerySurface(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value) -{ - EGLBoolean ret = EGL_FALSE; - - _COREGL_WRAP_FUNC_BEGIN(); - ret = wrp_eglQuerySurface(dpy, surface, attribute, value); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); - return ret; -} - -EGLBoolean -wpgl_eglBindAPI(EGLenum api) -{ - EGLBoolean ret = EGL_FALSE; - - _COREGL_WRAP_FUNC_BEGIN(); - ret = wrp_eglBindAPI(api); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); - return ret; -} - -EGLenum -wpgl_eglQueryAPI(void) -{ - EGLenum ret = 0; - - _COREGL_WRAP_FUNC_BEGIN(); - ret = wrp_eglQueryAPI(); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); - return ret; -} - -EGLBoolean -wpgl_eglWaitClient(void) -{ - EGLBoolean ret = EGL_FALSE; - - _COREGL_WRAP_FUNC_BEGIN(); - ret = wrp_eglWaitClient(); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); - return ret; -} - -EGLBoolean -wpgl_eglReleaseThread(void) -{ - EGLBoolean ret = EGL_FALSE; - - _COREGL_WRAP_FUNC_BEGIN(); - ret = wrp_eglReleaseThread(); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); - return ret; -} - -EGLSurface -wpgl_eglCreatePbufferFromClientBuffer(EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list) -{ - EGLSurface ret = EGL_NO_SURFACE; - - _COREGL_WRAP_FUNC_BEGIN(); - ret = wrp_eglCreatePbufferFromClientBuffer(dpy, buftype, buffer, config, attrib_list); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); - return ret; -} - -EGLBoolean -wpgl_eglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value) -{ - EGLBoolean ret = EGL_FALSE; - - _COREGL_WRAP_FUNC_BEGIN(); - ret = wrp_eglSurfaceAttrib(dpy, surface, attribute, value); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); - return ret; -} - -EGLBoolean -wpgl_eglBindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer) -{ - EGLBoolean ret = EGL_FALSE; - - _COREGL_WRAP_FUNC_BEGIN(); - ret = wrp_eglBindTexImage(dpy, surface, buffer); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); - return ret; -} - -EGLBoolean -wpgl_eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer) -{ - EGLBoolean ret = EGL_FALSE; - - _COREGL_WRAP_FUNC_BEGIN(); - ret = wrp_eglReleaseTexImage(dpy, surface, buffer); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); - return ret; -} - -EGLBoolean -wpgl_eglSwapInterval(EGLDisplay dpy, EGLint interval) -{ - EGLBoolean ret = EGL_FALSE; - - _COREGL_WRAP_FUNC_BEGIN(); - ret = wrp_eglSwapInterval(dpy, interval); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); - return ret; -} - -EGLContext -wpgl_eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint* attrib_list) -{ - EGLContext ret = EGL_NO_CONTEXT; - - _COREGL_WRAP_FUNC_BEGIN(); - ret = wrp_eglCreateContext(dpy, config, share_context, attrib_list); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); - return ret; -} - -EGLBoolean -wpgl_eglDestroyContext(EGLDisplay dpy, EGLContext ctx) -{ - EGLBoolean ret = EGL_FALSE; - - _COREGL_WRAP_FUNC_BEGIN(); - ret = wrp_eglDestroyContext(dpy, ctx); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); - return ret; -} - -EGLBoolean -wpgl_eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx) -{ - EGLBoolean ret = EGL_FALSE; - - _COREGL_WRAP_FUNC_BEGIN(); - ret = wrp_eglMakeCurrent(dpy, draw, read, ctx); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -#ifdef COREGL_TRACE_STATE_INFO - if (unlikely(trace_state_flag == 1)) - { - if (wrp_eglMakeCurrent == _sym_eglMakeCurrent) - dump_wrap_context_states(0); - } -#endif // COREGL_TRACE_STATE_INFO - return ret; -} - -EGLContext -wpgl_eglGetCurrentContext(void) -{ - EGLContext ret = EGL_NO_CONTEXT; - - _COREGL_WRAP_FUNC_BEGIN(); - ret = wrp_eglGetCurrentContext(); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); - return ret; -} - -EGLSurface -wpgl_eglGetCurrentSurface(EGLint readdraw) -{ - EGLSurface ret = EGL_NO_SURFACE; - - _COREGL_WRAP_FUNC_BEGIN(); - ret = wrp_eglGetCurrentSurface(readdraw); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); - return ret; -} - -EGLDisplay -wpgl_eglGetCurrentDisplay(void) -{ - EGLDisplay ret = EGL_NO_DISPLAY; - - _COREGL_WRAP_FUNC_BEGIN(); - ret = wrp_eglGetCurrentDisplay(); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); - return ret; -} - -EGLBoolean -wpgl_eglQueryContext(EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value) -{ - EGLBoolean ret = EGL_FALSE; - - _COREGL_WRAP_FUNC_BEGIN(); - ret = wrp_eglQueryContext(dpy, ctx, attribute, value); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); - return ret; -} - -EGLBoolean -wpgl_eglWaitGL(void) -{ - EGLBoolean ret = EGL_FALSE; - - _COREGL_WRAP_FUNC_BEGIN(); - ret = wrp_eglWaitGL(); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); - return ret; -} - -EGLBoolean -wpgl_eglWaitNative(EGLint engine) -{ - EGLBoolean ret = EGL_FALSE; - - _COREGL_WRAP_FUNC_BEGIN(); - ret = wrp_eglWaitNative(engine); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); - return ret; -} - -EGLBoolean -wpgl_eglSwapBuffers(EGLDisplay dpy, EGLSurface surface) -{ - EGLBoolean ret = EGL_FALSE; - - _COREGL_WRAP_FUNC_BEGIN(); - ret = wrp_eglSwapBuffers(dpy, surface); - - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); - _COREGL_TRACE_API_OUTPUT(0); - return ret; -} - -EGLBoolean -wpgl_eglCopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target) -{ - EGLBoolean ret = EGL_FALSE; - - _COREGL_WRAP_FUNC_BEGIN(); - ret = wrp_eglCopyBuffers(dpy, surface, target); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); - return ret; -} - -_eng_fn -wpgl_eglGetProcAddress(const char* procname) -{ - _eng_fn ret = NULL; - - _COREGL_WRAP_FUNC_BEGIN(); - ret = wrp_eglGetProcAddress(procname); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); - return ret; -} - -const char * -wpgl_eglQueryString(EGLDisplay dpy, EGLint name) -{ - const char *ret = NULL; - - _COREGL_WRAP_FUNC_BEGIN(); - ret = wrp_eglQueryString(dpy, name); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); - return ret; -} - -EGLImageKHR -wpgl_eglCreateImageKHR (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list) -{ - void *ret = NULL; - - _COREGL_WRAP_FUNC_BEGIN(); - ret = wrp_eglCreateImageKHR(dpy, ctx, target, buffer, attrib_list); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); - return ret; -} - -EGLBoolean -wpgl_eglDestroyImageKHR(EGLDisplay dpy, EGLImageKHR image) -{ - EGLBoolean ret = EGL_FALSE; - - _COREGL_WRAP_FUNC_BEGIN(); - ret = wrp_eglDestroyImageKHR(dpy, image); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); - return ret; -} - -void * -wpgl_eglMapImageSEC(EGLDisplay dpy, EGLImageKHR image) -{ - void *ret = NULL; - - _COREGL_WRAP_FUNC_BEGIN(); - ret = wrp_eglMapImageSEC(dpy, image); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); - return ret; -} - -EGLBoolean -wpgl_eglUnmapImageSEC(EGLDisplay dpy, EGLImageKHR image) -{ - EGLBoolean ret = EGL_FALSE; - - _COREGL_WRAP_FUNC_BEGIN(); - ret = wrp_eglUnmapImageSEC(dpy, image); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); - return ret; -} - -EGLBoolean -wpgl_eglGetImageAttribSEC(EGLDisplay dpy, EGLImageKHR image, EGLint attribute, EGLint *value) -{ - EGLBoolean ret = EGL_FALSE; - - _COREGL_WRAP_FUNC_BEGIN(); - ret = wrp_eglGetImageAttribSEC(dpy, image, attribute, value); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); - return ret; -} - -EGLBoolean -wpgl_eglLockSurfaceKHR(EGLDisplay display, EGLSurface surface, const EGLint *attrib_list) -{ - EGLBoolean ret = EGL_FALSE; - - _COREGL_WRAP_FUNC_BEGIN(); - ret = wrp_eglLockSurfaceKHR(display, surface, attrib_list); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); - return ret; -} - -EGLBoolean -wpgl_eglUnlockSurfaceKHR(EGLDisplay display, EGLSurface surface) -{ - EGLBoolean ret = EGL_FALSE; - - _COREGL_WRAP_FUNC_BEGIN(); - ret = wrp_eglUnlockSurfaceKHR(display, surface); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); - return ret; -} - diff --git a/src/coregl_wrappath_gl.c b/src/coregl_wrappath_gl.c deleted file mode 100644 index 94b700e..0000000 --- a/src/coregl_wrappath_gl.c +++ /dev/null @@ -1,1873 +0,0 @@ -#include "coregl_wrappath.h" - -void -wpgl_glActiveTexture(GLenum texture) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glActiveTexture(texture); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glAttachShader(GLuint program, GLuint shader) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glAttachShader(program, shader); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glBindAttribLocation(GLuint program, GLuint index, const char* name) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glBindAttribLocation(program, index, name); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glBindBuffer(GLenum target, GLuint buffer) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glBindBuffer(target, buffer); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glBindFramebuffer(GLenum target, GLuint framebuffer) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glBindFramebuffer(target, framebuffer); - - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glBindRenderbuffer(GLenum target, GLuint renderbuffer) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glBindRenderbuffer(target, renderbuffer); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glBindTexture(GLenum target, GLuint texture) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glBindTexture(target, texture); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glBlendColor(red, green, blue, alpha); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glBlendEquation(GLenum mode) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glBlendEquation(mode); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glBlendEquationSeparate(modeRGB, modeAlpha); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glBlendFunc(GLenum sfactor, GLenum dfactor) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glBlendFunc(sfactor, dfactor); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glBufferData(GLenum target, GLsizeiptr size, const void* data, GLenum usage) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glBufferData(target, size, data, usage); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const void* data) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glBufferSubData(target, offset, size, data); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -GLenum -wpgl_glCheckFramebufferStatus(GLenum target) -{ - GLenum ret = GL_NONE; - - _COREGL_WRAP_FUNC_BEGIN(); - ret = wrp_glCheckFramebufferStatus(target); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); - return ret; -} - -void -wpgl_glClear(GLbitfield mask) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glClear(mask); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glClearColor(red, green, blue, alpha); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glClearDepthf(GLclampf depth) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glClearDepthf(depth); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glClearStencil(GLint s) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glClearStencil(s); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glColorMask(red, green, blue, alpha); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glCompileShader(GLuint shader) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glCompileShader(shader); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glCompressedTexImage2D(target, level, internalformat, width, height, border, imageSize, data); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glCompressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize, data); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glCopyTexImage2D(target, level, internalformat, x, y, width, height, border); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -GLuint -wpgl_glCreateProgram(void) -{ - GLuint ret = _COREGL_INT_INIT_VALUE; - - _COREGL_WRAP_FUNC_BEGIN(); - ret = wrp_glCreateProgram(); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); - return ret; -} - -GLuint -wpgl_glCreateShader(GLenum type) -{ - GLuint ret = _COREGL_INT_INIT_VALUE; - _COREGL_WRAP_FUNC_BEGIN(); - ret = wrp_glCreateShader(type); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); - return ret; -} - -void -wpgl_glCullFace(GLenum mode) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glCullFace(mode); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glDeleteBuffers(GLsizei n, const GLuint* buffers) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glDeleteBuffers(n, buffers); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glDeleteFramebuffers(n, framebuffers); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glDeleteProgram(GLuint program) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glDeleteProgram(program); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glDeleteRenderbuffers(n, renderbuffers); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glDeleteShader(GLuint shader) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glDeleteShader(shader); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glDeleteTextures(GLsizei n, const GLuint* textures) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glDeleteTextures(n, textures); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glDepthFunc(GLenum func) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glDepthFunc(func); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glDepthMask(GLboolean flag) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glDepthMask(flag); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glDepthRangef(GLclampf zNear, GLclampf zFar) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glDepthRangef(zNear, zFar); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glDetachShader(GLuint program, GLuint shader) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glDetachShader(program, shader); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glDisable(GLenum cap) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glDisable(cap); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glDisableVertexAttribArray(GLuint index) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glDisableVertexAttribArray(index); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glDrawArrays(GLenum mode, GLint first, GLsizei count) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glDrawArrays(mode, first, count); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glDrawElements(GLenum mode, GLsizei count, GLenum type, const void* indices) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glDrawElements(mode, count, type, indices); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glEnable(GLenum cap) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glEnable(cap); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glEnableVertexAttribArray(GLuint index) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glEnableVertexAttribArray(index); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glFinish(void) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glFinish(); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); - _COREGL_TRACE_API_OUTPUT(0); -} - -void -wpgl_glFlush(void) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glFlush(); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); - _COREGL_TRACE_API_OUTPUT(0); -} - -void -wpgl_glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glFramebufferRenderbuffer(target, attachment, renderbuffertarget, renderbuffer); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glFramebufferTexture2D(target, attachment, textarget, texture, level); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glFrontFace(GLenum mode) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glFrontFace(mode); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glGetVertexAttribfv(index, pname, params); - - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glGetVertexAttribiv(index, pname, params); - - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glGetVertexAttribPointerv(GLuint index, GLenum pname, void** pointer) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glGetVertexAttribPointerv(index, pname, pointer); - - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glHint(GLenum target, GLenum mode) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glHint(target, mode); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glGenBuffers(GLsizei n, GLuint* buffers) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glGenBuffers(n, buffers); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glGenerateMipmap(GLenum target) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glGenerateMipmap(target); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glGenFramebuffers(GLsizei n, GLuint* framebuffers) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glGenFramebuffers(n, framebuffers); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glGenRenderbuffers(GLsizei n, GLuint* renderbuffers) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glGenRenderbuffers(n, renderbuffers); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glGenTextures(GLsizei n, GLuint* textures) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glGenTextures(n, textures); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glGetActiveAttrib(program, index, bufsize, length, size, type, name); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glGetActiveUniform(program, index, bufsize, length, size, type, name); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glGetAttachedShaders(program, maxcount, count, shaders); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -int -wpgl_glGetAttribLocation(GLuint program, const char* name) -{ - int ret = _COREGL_INT_INIT_VALUE; - _COREGL_WRAP_FUNC_BEGIN(); - ret = wrp_glGetAttribLocation(program, name); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); - return ret; -} - -void -wpgl_glGetBooleanv(GLenum pname, GLboolean* params) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glGetBooleanv(pname, params); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glGetBufferParameteriv(GLenum target, GLenum pname, GLint* params) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glGetBufferParameteriv(target, pname, params); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -GLenum -wpgl_glGetError(void) -{ - GLenum ret = GL_NONE; - - _COREGL_WRAP_FUNC_BEGIN(); - ret = wrp_glGetError(); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); - return ret; -} - -void -wpgl_glGetFloatv(GLenum pname, GLfloat* params) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glGetFloatv(pname, params); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glGetFramebufferAttachmentParameteriv(target, attachment, pname, params); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glGetIntegerv(GLenum pname, GLint* params) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glGetIntegerv(pname, params); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glGetProgramiv(GLuint program, GLenum pname, GLint* params) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glGetProgramiv(program, pname, params); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, char* infolog) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glGetProgramInfoLog(program, bufsize, length, infolog); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glGetRenderbufferParameteriv(target, pname, params); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glGetShaderiv(GLuint shader, GLenum pname, GLint* params) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glGetShaderiv(shader, pname, params); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glGetShaderInfoLog(shader, bufsize, length, infolog); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) -{ - _COREGL_WRAP_FUNC_BEGIN(); -#ifndef _COREGL_DESKTOP_GL - wrp_glGetShaderPrecisionFormat(shadertype, precisiontype, range, precision); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); -#else - if (range) - { - range[0] = -126; // floor(log2(FLT_MIN)) - range[1] = 127; // floor(log2(FLT_MAX)) - } - if (precision) - { - precision[0] = 24; // floor(-log2((1.0/16777218.0))); - } - return; - shadertype = precisiontype = 0; -#endif - - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, char* source) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glGetShaderSource(shader, bufsize, length, source); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -const GLubyte * -wpgl_glGetString(GLenum name) -{ - const GLubyte *ret = NULL; - - _COREGL_WRAP_FUNC_BEGIN(); - ret = wrp_glGetString(name); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); - return ret; -} - -void -wpgl_glGetTexParameterfv(GLenum target, GLenum pname, GLfloat* params) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glGetTexParameterfv(target, pname, params); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glGetTexParameteriv(GLenum target, GLenum pname, GLint* params) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glGetTexParameteriv(target, pname, params); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glGetUniformfv(GLuint program, GLint location, GLfloat* params) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glGetUniformfv(program, location, params); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glGetUniformiv(GLuint program, GLint location, GLint* params) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glGetUniformiv(program, location, params); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} -int -wpgl_glGetUniformLocation(GLuint program, const char* name) -{ - int ret = _COREGL_INT_INIT_VALUE; - - _COREGL_WRAP_FUNC_BEGIN(); - ret = wrp_glGetUniformLocation(program, name); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); - return ret; -} - -GLboolean -wpgl_glIsBuffer(GLuint buffer) -{ - GLboolean ret = GL_FALSE; - - _COREGL_WRAP_FUNC_BEGIN(); - ret = wrp_glIsBuffer(buffer); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); - return ret; -} - -GLboolean -wpgl_glIsEnabled(GLenum cap) -{ - GLboolean ret = GL_FALSE; - - _COREGL_WRAP_FUNC_BEGIN(); - ret = wrp_glIsEnabled(cap); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); - return ret; -} - -GLboolean -wpgl_glIsFramebuffer(GLuint framebuffer) -{ - GLboolean ret = GL_FALSE; - - _COREGL_WRAP_FUNC_BEGIN(); - ret = wrp_glIsFramebuffer(framebuffer); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); - return ret; -} - -GLboolean -wpgl_glIsProgram(GLuint program) -{ - GLboolean ret; - _COREGL_WRAP_FUNC_BEGIN(); - ret = wrp_glIsProgram(program); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); - return ret; -} - -GLboolean -wpgl_glIsRenderbuffer(GLuint renderbuffer) -{ - GLboolean ret; - _COREGL_WRAP_FUNC_BEGIN(); - ret = wrp_glIsRenderbuffer(renderbuffer); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); - return ret; -} - -GLboolean -wpgl_glIsShader(GLuint shader) -{ - GLboolean ret; - _COREGL_WRAP_FUNC_BEGIN(); - ret = wrp_glIsShader(shader); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); - return ret; -} - -GLboolean -wpgl_glIsTexture(GLuint texture) -{ - GLboolean ret; - _COREGL_WRAP_FUNC_BEGIN(); - ret = wrp_glIsTexture(texture); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); - return ret; -} - -void -wpgl_glLineWidth(GLfloat width) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glLineWidth(width); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glLinkProgram(GLuint program) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glLinkProgram(program); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glPixelStorei(GLenum pname, GLint param) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glPixelStorei(pname, param); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glPolygonOffset(GLfloat factor, GLfloat units) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glPolygonOffset(factor, units); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glReadPixels(x, y, width, height, format, type, pixels); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glReleaseShaderCompiler(void) -{ - _COREGL_WRAP_FUNC_BEGIN(); -#ifndef _COREGL_DESKTOP_GL - wrp_glReleaseShaderCompiler(); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); -#else - //FIXME!!! need something here? - -#endif - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glRenderbufferStorage(target, internalformat, width, height); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glSampleCoverage(GLclampf value, GLboolean invert) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glSampleCoverage(value, invert); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glScissor(GLint x, GLint y, GLsizei width, GLsizei height) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glScissor(x, y, width, height); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLsizei length) -{ - _COREGL_WRAP_FUNC_BEGIN(); -#ifndef _COREGL_DESKTOP_GL - wrp_glShaderBinary(n, shaders, binaryformat, binary, length); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); -#else -// FIXME: need to dlsym/getprocaddress for this - return; - /* - n = binaryformat = length = 0; - shaders = binary = 0; - */ -#endif - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glShaderSource(GLuint shader, GLsizei count, const char** string, const GLint* length) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glShaderSource(shader, count, string, length); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glStencilFunc(GLenum func, GLint ref, GLuint mask) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glStencilFunc(func, ref, mask); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glStencilFuncSeparate(face, func, ref, mask); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glStencilMask(GLuint mask) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glStencilMask(mask); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glStencilMaskSeparate(GLenum face, GLuint mask) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glStencilMaskSeparate(face, mask); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glStencilOp(GLenum fail, GLenum zfail, GLenum zpass) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glStencilOp(fail, zfail, zpass); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glStencilOpSeparate(face, fail, zfail, zpass); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* pixels) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glTexImage2D(target, level, internalformat, width, height, border, format, type, pixels); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glTexParameterf(GLenum target, GLenum pname, GLfloat param) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glTexParameterf(target, pname, param); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glTexParameterfv(GLenum target, GLenum pname, const GLfloat* params) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glTexParameterfv(target, pname, params); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glTexParameteri(GLenum target, GLenum pname, GLint param) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glTexParameteri(target, pname, param); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glTexParameteriv(GLenum target, GLenum pname, const GLint* params) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glTexParameteriv(target, pname, params); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glUniform1f(GLint location, GLfloat x) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glUniform1f(location, x); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glUniform1fv(GLint location, GLsizei count, const GLfloat* v) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glUniform1fv(location, count, v); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glUniform1i(GLint location, GLint x) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glUniform1i(location, x); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glUniform1iv(GLint location, GLsizei count, const GLint* v) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glUniform1iv(location, count, v); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glUniform2f(GLint location, GLfloat x, GLfloat y) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glUniform2f(location, x, y); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glUniform2fv(GLint location, GLsizei count, const GLfloat* v) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glUniform2fv(location, count, v); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glUniform2i(GLint location, GLint x, GLint y) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glUniform2i(location, x, y); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glUniform2iv(GLint location, GLsizei count, const GLint* v) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glUniform2iv(location, count, v); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glUniform3f(location, x, y, z); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glUniform3fv(GLint location, GLsizei count, const GLfloat* v) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glUniform3fv(location, count, v); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glUniform3i(GLint location, GLint x, GLint y, GLint z) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glUniform3i(location, x, y, z); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glUniform3iv(GLint location, GLsizei count, const GLint* v) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glUniform3iv(location, count, v); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glUniform4f(location, x, y, z, w); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glUniform4fv(GLint location, GLsizei count, const GLfloat* v) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glUniform4fv(location, count, v); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glUniform4i(location, x, y, z, w); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glUniform4iv(GLint location, GLsizei count, const GLint* v) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glUniform4iv(location, count, v); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glUniformMatrix2fv(location, count, transpose, value); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glUniformMatrix3fv(location, count, transpose, value); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glUniformMatrix4fv(location, count, transpose, value); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glUseProgram(GLuint program) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glUseProgram(program); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glValidateProgram(GLuint program) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glValidateProgram(program); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glVertexAttrib1f(GLuint indx, GLfloat x) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glVertexAttrib1f(indx, x); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glVertexAttrib1fv(GLuint indx, const GLfloat* values) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glVertexAttrib1fv(indx, values); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glVertexAttrib2f(GLuint indx, GLfloat x, GLfloat y) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glVertexAttrib2f(indx, x, y); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glVertexAttrib2fv(GLuint indx, const GLfloat* values) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glVertexAttrib2fv(indx, values); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glVertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glVertexAttrib3f(indx, x, y, z); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glVertexAttrib3fv(GLuint indx, const GLfloat* values) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glVertexAttrib3fv(indx, values); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glVertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glVertexAttrib4f(indx, x, y, z, w); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glVertexAttrib4fv(GLuint indx, const GLfloat* values) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glVertexAttrib4fv(indx, values); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glVertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glVertexAttribPointer(indx, size, type, normalized, stride, ptr); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glViewport(GLint x, GLint y, GLsizei width, GLsizei height) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glViewport(x, y, width, height); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - - -// GLES Extensions... -void -wpgl_glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glEGLImageTargetTexture2DOES(target, image); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glEGLImageTargetRenderbufferStorageOES(GLenum target, GLeglImageOES image) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glEGLImageTargetRenderbufferStorageOES(target, image); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glGetProgramBinary(GLuint program, GLsizei bufsize, GLsizei* length, GLenum* binaryFormat, void* binary) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glGetProgramBinary(program, bufsize, length, binaryFormat, binary); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glProgramBinary(GLuint program, GLenum binaryFormat, const void* binary, GLint length) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glProgramBinary(program, binaryFormat, binary, length); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - - -void -wpgl_glProgramParameteri(GLuint program, GLuint pname, GLint value) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glProgramParameteri(program, pname, value); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glRenderbufferStorageMultisampleEXT(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glRenderbufferStorageMultisampleEXT(target, samples, internalformat, width, height); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glFramebufferTexture2DMultisampleEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glFramebufferTexture2DMultisampleEXT(target, attachment, textarget, texture, level, samples); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -wpgl_glDiscardFramebufferEXT(GLenum target, GLsizei numAttachments, const GLenum *attachments) -{ - _COREGL_WRAP_FUNC_BEGIN(); - wrp_glDiscardFramebufferEXT(target, numAttachments, attachments); - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - diff --git a/src/coregl_wrappath_glx.c b/src/coregl_wrappath_glx.c deleted file mode 100644 index 200dd3d..0000000 --- a/src/coregl_wrappath_glx.c +++ /dev/null @@ -1,352 +0,0 @@ -#include "coregl_wrappath.h" - -_eng_fn -glXGetProcAddress(const char* procName) -{ - _eng_fn ret = NULL; - - _COREGL_WRAP_FUNC_BEGIN(); - ret = glsym_glXGetProcAddress(procName); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); - return ret; -} - -XVisualInfo* -glXChooseVisual(Display* dpy, int screen, int* attribList) -{ - XVisualInfo *ret = NULL; - - _COREGL_WRAP_FUNC_BEGIN(); - ret = glsym_glXChooseVisual(dpy, screen, attribList); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); - return ret; -} - -GLXContext -glXCreateContext(Display* dpy, XVisualInfo* vis, GLXContext shareList, Bool direct) -{ - GLXContext ret = NULL; - - _COREGL_WRAP_FUNC_BEGIN(); - ret = glsym_glXCreateContext(dpy, vis, shareList, direct); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); - return ret; -} - -void -glXDestroyContext(Display* dpy, GLXContext ctx) -{ - _COREGL_WRAP_FUNC_BEGIN(); - glsym_glXDestroyContext(dpy, ctx); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -GLXContext -glXGetCurrentContext(void) -{ - GLXContext ret = NULL; - - _COREGL_WRAP_FUNC_BEGIN(); - ret = glsym_glXGetCurrentContext(); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); - return ret; -} - -GLXDrawable -glXGetCurrentDrawable(void) -{ - GLXDrawable ret = NULL; - - _COREGL_WRAP_FUNC_BEGIN(); - ret = glsym_glXGetCurrentDrawable(); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); - return ret; -} - - -Bool -glXMakeCurrent(Display* dpy, GLXDrawable draw, GLXContext ctx) -{ - Bool ret = False; - - _COREGL_WRAP_FUNC_BEGIN(); - ret = glsym_glXMakeCurrent(dpy, draw, ctx); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -glXSwapBuffers(Display* dpy, GLXDrawable draw) -{ - _COREGL_WRAP_FUNC_BEGIN(); - glsym_glXSwapBuffers(dpy, draw); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -glXWaitX(void) -{ - _COREGL_WRAP_FUNC_BEGIN(); - glsym_glXWaitX(); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -glXWaitGL(void) -{ - _COREGL_WRAP_FUNC_BEGIN(); - glsym_glXWaitGL(); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -Bool -glXQueryExtension(Display* dpy, int* errorb, int* event) -{ - Bool ret = False; - - _COREGL_WRAP_FUNC_BEGIN(); - ret = glsym_glXQueryExtension(dpy, errorb, event); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); - return ret; -} - -const char * -glXQueryExtensionsString(Display *dpy, int screen) -{ - const char *ret = NULL; - - _COREGL_WRAP_FUNC_BEGIN(); - ret = glsym_glXQueryExtensionsString(dpy, screen); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); - return ret; -} - -GLXFBConfig* -glXChooseFBConfig(Display* dpy, int screen, const int* attribList, int* nitems) -{ - GLXFBConfig *ret = NULL; - - _COREGL_WRAP_FUNC_BEGIN(); - ret = glsym_glXChooseFBConfig(dpy, screen, attribList, nitems); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); - return ret; -} - -GLXFBConfig* -glXGetFBConfigs(Display* dpy, int screen, int* nelements) -{ - GLXFBConfig *ret = NULL; - - _COREGL_WRAP_FUNC_BEGIN(); - ret = glsym_glXGetFBConfigs(dpy, screen, nelements); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); - return ret; -} - -//!!!!! FIXME Called too many times -int -glXGetFBConfigAttrib(Display* dpy, GLXFBConfig config, int attribute, int* value) -{ - int ret = _COREGL_INT_INIT_VALUE; - - _COREGL_WRAP_FUNC_BEGIN(); - ret = glsym_glXGetFBConfigAttrib(dpy, config, attribute, value); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); - return ret; -} - -//!!!!! FIXME Called too many times -XVisualInfo* -glXGetVisualFromFBConfig(Display* dpy, GLXFBConfig config) -{ - XVisualInfo *ret = NULL; - - _COREGL_WRAP_FUNC_BEGIN(); - ret = glsym_glXGetVisualFromFBConfig(dpy, config); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); - return ret; -} - -void -glXDestroyWindow(Display* dpy, GLXWindow window) -{ - _COREGL_WRAP_FUNC_BEGIN(); - glsym_glXDestroyWindow(dpy, window); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -Bool -glXMakeContextCurrent(Display* dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx) -{ - Bool ret = False; - - _COREGL_WRAP_FUNC_BEGIN(); - ret = glsym_glXMakeContextCurrent(dpy, draw, read, ctx); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); - return ret; -} - -void -glXBindTexImage(Display* dpy, GLXDrawable draw, int buffer, int* attribList) -{ - _COREGL_WRAP_FUNC_BEGIN(); - glsym_glXBindTexImage(dpy, draw, buffer, attribList); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -glXReleaseTexImage(Display* dpy, GLXDrawable draw, int buffer) -{ - _COREGL_WRAP_FUNC_BEGIN(); - glsym_glXReleaseTexImage(dpy, draw, buffer); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -int -glXGetVideoSync(unsigned int* count) -{ - int ret = _COREGL_INT_INIT_VALUE; - - _COREGL_WRAP_FUNC_BEGIN(); - ret = glsym_glXGetVideoSync(count); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); - return ret; -} - -int -glXWaitVideoSync(int divisor, int remainder, unsigned int* count) -{ - int ret = _COREGL_INT_INIT_VALUE; - - _COREGL_WRAP_FUNC_BEGIN(); - ret = glsym_glXWaitVideoSync(divisor, remainder, count); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); - return ret; -} - -XID -glXCreatePixmap(Display* dpy, void* config, Pixmap pixmap, const int* attribList) -{ - XID ret = None; - - _COREGL_WRAP_FUNC_BEGIN(); - ret = glsym_glXCreatePixmap(dpy, config, pixmap, attribList); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); - return ret; -} - -void -glXDestroyPixmap(Display* dpy, XID pixmap) -{ - _COREGL_WRAP_FUNC_BEGIN(); - glsym_glXDestroyPixmap(dpy, pixmap); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -void -glXQueryDrawable(Display* dpy, XID draw, int attribute, unsigned int* value) -{ - _COREGL_WRAP_FUNC_BEGIN(); - glsym_glXQueryDrawable(dpy, draw, attribute, value); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - -int -glXSwapIntervalSGI(int interval) -{ - int ret = _COREGL_INT_INIT_VALUE; - - _COREGL_WRAP_FUNC_BEGIN(); - ret = glsym_glXSwapIntervalSGI(interval); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); - return ret; -} - -void -glXSwapIntervalEXT(Display* dpy, GLXDrawable draw, int interval) -{ - _COREGL_WRAP_FUNC_BEGIN(); - glsym_glXSwapIntervalEXT(dpy, draw, interval); - goto finish; - -finish: - _COREGL_WRAP_FUNC_END(); -} - diff --git a/src/headers/sym.h b/src/headers/sym.h index 4f7ab6b..886087b 100644 --- a/src/headers/sym.h +++ b/src/headers/sym.h @@ -2,9 +2,5 @@ #include "sym_gl.h" -#ifndef _COREGL_DESKTOP_GL -# include "sym_egl.h" -#else -# include "sym_glx.h" -#endif +#include "sym_egl.h" diff --git a/src/headers/sym_gl.h b/src/headers/sym_gl.h index 45b992d..4983840 100644 --- a/src/headers/sym_gl.h +++ b/src/headers/sym_gl.h @@ -22,11 +22,7 @@ _COREGL_SYMBOL(GL_FALSE, void, glBufferSubData, (GLenum target, GLintptr offset, _COREGL_SYMBOL(GL_FALSE, GLenum, glCheckFramebufferStatus, (GLenum target)) _COREGL_SYMBOL(GL_FALSE, void, glClear, (GLbitfield mask)) _COREGL_SYMBOL(GL_FALSE, void, glClearColor, (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)) -#ifndef _COREGL_DESKTOP_GL _COREGL_SYMBOL(GL_FALSE, void, glClearDepthf, (GLclampf depth)) -#else -_COREGL_SYMBOL(GL_FALSE, void, glClearDepth, (GLclampf depth)) -#endif _COREGL_SYMBOL(GL_FALSE, void, glClearStencil, (GLint s)) _COREGL_SYMBOL(GL_FALSE, void, glColorMask, (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)) _COREGL_SYMBOL(GL_FALSE, void, glCompileShader, (GLuint shader)) @@ -45,11 +41,7 @@ _COREGL_SYMBOL(GL_FALSE, void, glDeleteShader, (GLuint shader)) _COREGL_SYMBOL(GL_FALSE, void, glDeleteTextures, (GLsizei n, const GLuint* textures)) _COREGL_SYMBOL(GL_FALSE, void, glDepthFunc, (GLenum func)) _COREGL_SYMBOL(GL_FALSE, void, glDepthMask, (GLboolean flag)) -#ifndef _COREGL_DESKTOP_GL _COREGL_SYMBOL(GL_FALSE, void, glDepthRangef, (GLclampf zNear, GLclampf zFar)) -#else -_COREGL_SYMBOL(GL_FALSE, void, glDepthRange, (GLclampf zNear, GLclampf zFar)) -#endif _COREGL_SYMBOL(GL_FALSE, void, glDetachShader, (GLuint program, GLuint shader)) _COREGL_SYMBOL(GL_FALSE, void, glDisable, (GLenum cap)) _COREGL_SYMBOL(GL_FALSE, void, glDisableVertexAttribArray, (GLuint index)) diff --git a/src/modules/appopt/coregl_appopt.c b/src/modules/appopt/coregl_appopt.c new file mode 100644 index 0000000..f872fa8 --- /dev/null +++ b/src/modules/appopt/coregl_appopt.c @@ -0,0 +1,80 @@ +#include "coregl_appopt.h" + +#include +#include +#include + +#define _COREGL_SYMBOL(IS_EXTENSION, RET_TYPE, FUNC_NAME, PARAM_LIST) RET_TYPE (*_orig_appopt_##FUNC_NAME) PARAM_LIST = NULL; +#include "../../headers/sym.h" +#undef _COREGL_SYMBOL + +void +init_modules_appopt() +{ + LOG("[CoreGL] : "); + + LOG("Not yet implemented\n"); + + appopt_apply_overrides(); +} + +void +deinit_modules_appopt() +{ +} + +void +init_modules_tstate_appopt(GLThreadState *tstate) +{ + MY_MODULE_TSTATE *tstate_mt = NULL; + + tstate_mt = (MY_MODULE_TSTATE *)calloc(1, sizeof(MY_MODULE_TSTATE)); + + + tstate->module_data[MY_MODULE_ID] = tstate_mt; +} + +void +deinit_modules_tstate_appopt(GLThreadState *tstate) +{ + if (tstate->module_data[MY_MODULE_ID] != NULL) + { + free(tstate->module_data[MY_MODULE_ID]); + tstate->module_data[MY_MODULE_ID] = NULL; + } +} + +void +appopt_apply_overrides() +{ + //appopt_apply_overrides_egl(1); + //appopt_apply_overrides_gl(1); +} + +#define OVERRIDE(f) \ + if (enable == 1) \ + { \ + COREGL_OVERRIDE_API(_orig_appopt_, f, ovr_); \ + COREGL_OVERRIDE_API(ovr_, f, appopt_); \ + } \ + else \ + { \ + AST(ovr_##f != NULL); \ + COREGL_OVERRIDE_API(ovr_, f, _orig_appopt_); \ + _orig_appopt_##f = NULL; \ + } + +void +appopt_apply_overrides_egl(int enable) +{ + // Fast-Path Core Functions +} + +void +appopt_apply_overrides_gl(int enable) +{ + // Fast-Path Functions +} + +#undef A_ORD + diff --git a/src/modules/appopt/coregl_appopt.h b/src/modules/appopt/coregl_appopt.h new file mode 100644 index 0000000..e8f7878 --- /dev/null +++ b/src/modules/appopt/coregl_appopt.h @@ -0,0 +1,47 @@ +#ifndef COREGL_APPOPT_H +#define COREGL_APPOPT_H + +#include "../coregl_module.h" + +#ifndef COREGL_USE_MODULE_APPOPT +#error "COREGL_USE_MODULE_APPOPT must defined!!!" +#endif + +#define MY_MODULE_ID COREGL_MODULE_APPOPT +#define MY_MODULE_TSTATE Appopt_ThreadState + +#include "../../coregl_internal.h" +#include "../../coregl_export.h" + +#define _COREGL_SYMBOL(IS_EXTENSION, RET_TYPE, FUNC_NAME, PARAM_LIST) extern RET_TYPE (*_orig_appopt_##FUNC_NAME) PARAM_LIST; +# include "../../headers/sym.h" +#undef _COREGL_SYMBOL + +// Symbol definition for appopt +#define _COREGL_SYMBOL(IS_EXTENSION, RET_TYPE, FUNC_NAME, PARAM_LIST) extern RET_TYPE (appopt_##FUNC_NAME) PARAM_LIST; +# include "../../headers/sym.h" +#undef _COREGL_SYMBOL + +typedef struct _Appopt_ThreadState +{ + void *_notusedyet; +} Appopt_ThreadState; + + +#define _COREGL_APPOPT_FUNC_BEGIN() + +#define _COREGL_APPOPT_FUNC_END() + + +extern void init_modules_appopt(); +extern void deinit_modules_appopt(); +extern void init_modules_tstate_appopt(GLThreadState *tstate); +extern void deinit_modules_tstate_appopt(GLThreadState *tstate); + +extern void appopt_apply_overrides(); +extern void appopt_apply_overrides_egl(int enable); +extern void appopt_apply_overrides_gl(int enable); + + +#endif // COREGL_APPOPT_H + diff --git a/src/modules/appopt/coregl_appopt_egl.c b/src/modules/appopt/coregl_appopt_egl.c new file mode 100644 index 0000000..4d42637 --- /dev/null +++ b/src/modules/appopt/coregl_appopt_egl.c @@ -0,0 +1,3 @@ +#include "coregl_appopt.h" + + diff --git a/src/modules/appopt/coregl_appopt_gl.c b/src/modules/appopt/coregl_appopt_gl.c new file mode 100644 index 0000000..4d42637 --- /dev/null +++ b/src/modules/appopt/coregl_appopt_gl.c @@ -0,0 +1,3 @@ +#include "coregl_appopt.h" + + diff --git a/src/modules/coregl_module.c b/src/modules/coregl_module.c new file mode 100644 index 0000000..42ad0e3 --- /dev/null +++ b/src/modules/coregl_module.c @@ -0,0 +1,63 @@ +#include "../coregl_internal.h" + +// TRACEPATH module +#include "tracepath/coregl_tracepath.h" +#undef MY_MODULE_ID +#undef MY_MODULE_TSTATE + +// FASTPATH module +#include "fastpath/coregl_fastpath.h" +#undef MY_MODULE_ID +#undef MY_MODULE_TSTATE + +// APIOPT module +#include "appopt/coregl_appopt.h" +#undef MY_MODULE_ID +#undef MY_MODULE_TSTATE + +void +init_modules() +{ + // Step 1 : Initialization + init_export(); + + // Step 2 : User Define Modules : Sequence is important! (Last module's API is called first) + init_modules_fastpath(); + init_modules_appopt(); + + // Step 3 : Common Wrapping Modules + init_modules_tracepath(); +} + +void +deinit_modules() +{ + // Step 1(rollback init 3) : Common Wrapping Modules + deinit_modules_tracepath(); + + // Step 2(rollback init 2) : User Define Modules : Sequence is important! + deinit_modules_appopt(); + deinit_modules_fastpath(); + + // Step 3(rollback init 1) : De-Initialization + deinit_export(); +} + +void +init_modules_tstate(GLThreadState *tstate) +{ + // Initialization for each thread state : Sequence is important! + init_modules_tstate_tracepath(tstate); + init_modules_tstate_fastpath(tstate); + init_modules_tstate_appopt(tstate); +} + +void +deinit_modules_tstate(GLThreadState *tstate) +{ + // De-Initialization for each thread state(rollback) : Sequence is important! + deinit_modules_tstate_appopt(tstate); + deinit_modules_tstate_fastpath(tstate); + deinit_modules_tstate_tracepath(tstate); +} + diff --git a/src/modules/coregl_module.h b/src/modules/coregl_module.h new file mode 100644 index 0000000..c4c3333 --- /dev/null +++ b/src/modules/coregl_module.h @@ -0,0 +1,25 @@ +#ifndef COREGL_MODULE_H +#define COREGL_MODULE_H + +#define COREGL_USE_MODULE_TRACEPATH +#define COREGL_USE_MODULE_FASTPATH +#define COREGL_USE_MODULE_APPOPT + + +typedef enum +{ + COREGL_MODULE_TRACEPATH = 0, + COREGL_MODULE_FASTPATH = 1, + COREGL_MODULE_APPOPT = 2 +} CoreGL_Modules; + +#define COREGL_MAX_MODULES 5 + +#define GET_MY_TSTATE(val, stmt) \ + if (stmt != NULL) \ + val = ((MY_MODULE_TSTATE *)(stmt)->module_data[MY_MODULE_ID]); \ + else \ + val = NULL + +#endif // COREGL_MODULE_H + diff --git a/src/coregl_fastpath.c b/src/modules/fastpath/coregl_fastpath.c similarity index 62% rename from src/coregl_fastpath.c rename to src/modules/fastpath/coregl_fastpath.c index 25d078a..cd0103d 100644 --- a/src/coregl_fastpath.c +++ b/src/modules/fastpath/coregl_fastpath.c @@ -4,12 +4,25 @@ #include #include -GLenum FPGL_Error = GL_NO_ERROR; +#define _COREGL_SYMBOL(IS_EXTENSION, RET_TYPE, FUNC_NAME, PARAM_LIST) RET_TYPE (*_orig_fastpath_##FUNC_NAME) PARAM_LIST = NULL; +#include "../../headers/sym.h" +#undef _COREGL_SYMBOL + +Fastpath_Opt_Flag fp_opt = FP_UNKNOWN_PATH; + +int debug_nofp = 0; +FILE *trace_fp = NULL; + +GLenum FPGL_Error = GL_NO_ERROR; GLGlueContext_List *gctx_list = NULL; -Mutex init_context_mutex = MUTEX_INITIALIZER; -GLGlueContext *initial_ctx = NULL; +Mutex init_context_mutex = MUTEX_INITIALIZER; +GLGlueContext *initial_ctx = NULL; + +Mutex ctx_list_access_mutex = MUTEX_INITIALIZER; + +GLContext_List *glctx_list = NULL; static void _get_texture_states(GLenum pname, GLint *params) @@ -38,15 +51,269 @@ _get_stencil_max_mask() } void -init_fast_gl() +init_modules_fastpath() { + int fastpath_opt = 0; + + LOG("[CoreGL] : "); + + fastpath_opt = atoi(get_env_setting("COREGL_FASTPATH")); + + switch (fastpath_opt) + { + case 1: + LOG("(%d) Fastpath enabled...\n", fastpath_opt); + fp_opt = FP_FAST_PATH; + break; + default: + LOG("(%d) Default API path enabled...\n", fastpath_opt); + fp_opt = FP_NORMAL_PATH; + break; + } + + debug_nofp = atoi(get_env_setting("COREGL_DEBUG_NOFP")); + + fastpath_apply_overrides(); + } void -free_fast_gl() +deinit_modules_fastpath() { + GLContext_List *current = NULL; + + AST(mutex_lock(&ctx_list_access_mutex) == 1); + + // Destroy remained context & Detect leaks + int retry_destroy = 0; + + while (1) + { + retry_destroy = 0; + current = glctx_list; + while (current) + { + if (current->cstate != NULL) + { + ERR("\E[0;31;1mWARNING : Context attached to [dpy=%p|rctx=%p] has not been completely destroyed.(leak)\E[0m\n", current->cstate->rdpy, current->cstate->rctx); + + _sym_eglMakeCurrent(current->cstate->rdpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); + _sym_eglDestroyContext(current->cstate->rdpy, current->cstate->rctx); + + fastpath_remove_context_states_from_list(current->cstate, NULL); + retry_destroy = 1; + break; + } + + glctx_list = current->next; + free(current); + current = glctx_list; + } + if (retry_destroy == 0) break; + } + goto finish; + +finish: + AST(mutex_unlock(&ctx_list_access_mutex) == 1); } +void +init_modules_tstate_fastpath(GLThreadState *tstate) +{ + MY_MODULE_TSTATE *tstate_mt = NULL; + + tstate_mt = (MY_MODULE_TSTATE *)calloc(1, sizeof(MY_MODULE_TSTATE)); + + tstate_mt->binded_api = EGL_OPENGL_ES_API; + + tstate->module_data[MY_MODULE_ID] = tstate_mt; +} + +void +deinit_modules_tstate_fastpath(GLThreadState *tstate) +{ + if (tstate->module_data[MY_MODULE_ID] != NULL) + { + free(tstate->module_data[MY_MODULE_ID]); + tstate->module_data[MY_MODULE_ID] = NULL; + } +} + +void +fastpath_apply_overrides() +{ + switch(fp_opt) + { + case FP_FAST_PATH: + fastpath_apply_overrides_egl(1); + fastpath_apply_overrides_gl(1); + break; + case FP_NORMAL_PATH: + break; + default: + ERR("Invalide GL Override Option!!!\n"); + break; + } +} + +#define OVERRIDE(f) \ + if (enable == 1) \ + { \ + COREGL_OVERRIDE_API(_orig_fastpath_, f, ovr_); \ + COREGL_OVERRIDE_API(ovr_, f, fastpath_); \ + } \ + else \ + { \ + AST(ovr_##f != NULL); \ + COREGL_OVERRIDE_API(ovr_, f, _orig_fastpath_); \ + _orig_fastpath_##f = NULL; \ + } + +void +fastpath_apply_overrides_egl(int enable) +{ + // Fast-Path Core Functions + OVERRIDE(eglGetProcAddress); + + OVERRIDE(eglBindAPI); + OVERRIDE(eglQueryAPI); + + OVERRIDE(eglCreateContext); + OVERRIDE(eglCreateImageKHR); + OVERRIDE(eglMakeCurrent); + OVERRIDE(eglDestroyContext); + OVERRIDE(eglQueryContext); + OVERRIDE(eglGetCurrentContext); + OVERRIDE(eglReleaseThread); + OVERRIDE(eglGetCurrentSurface); + OVERRIDE(eglTerminate); + +} + +void +fastpath_apply_overrides_gl(int enable) +{ + // Fast-Path Functions + if (debug_nofp != 1) + { + OVERRIDE(glGetError); + + OVERRIDE(glGetIntegerv); + OVERRIDE(glGetFloatv); + OVERRIDE(glGetBooleanv); + + OVERRIDE(glActiveTexture); + OVERRIDE(glGenTextures); + OVERRIDE(glBindTexture); + OVERRIDE(glIsTexture); + OVERRIDE(glDeleteTextures); + OVERRIDE(glFramebufferTexture2D); + OVERRIDE(glFramebufferTexture2DMultisampleEXT); + + OVERRIDE(glGenBuffers); + OVERRIDE(glBindBuffer); + OVERRIDE(glIsBuffer); + OVERRIDE(glDeleteBuffers); + + OVERRIDE(glGenFramebuffers); + OVERRIDE(glBindFramebuffer); + OVERRIDE(glIsFramebuffer); + OVERRIDE(glDeleteFramebuffers); + + OVERRIDE(glGenRenderbuffers); + OVERRIDE(glBindRenderbuffer); + OVERRIDE(glFramebufferRenderbuffer); + OVERRIDE(glIsRenderbuffer); + OVERRIDE(glDeleteRenderbuffers); + + OVERRIDE(glCreateShader); + OVERRIDE(glCreateProgram); + OVERRIDE(glAttachShader); + OVERRIDE(glCompileShader); + OVERRIDE(glShaderBinary); + OVERRIDE(glDeleteShader); + OVERRIDE(glDetachShader); + OVERRIDE(glGetShaderiv); + OVERRIDE(glGetShaderInfoLog); + OVERRIDE(glGetShaderSource); + OVERRIDE(glIsShader); + OVERRIDE(glShaderSource); + OVERRIDE(glBindAttribLocation); + OVERRIDE(glDeleteProgram); + OVERRIDE(glDetachShader); + OVERRIDE(glGetActiveAttrib); + OVERRIDE(glGetActiveUniform); + OVERRIDE(glGetAttachedShaders); + OVERRIDE(glGetAttribLocation); + OVERRIDE(glGetProgramiv); + OVERRIDE(glGetProgramInfoLog); + OVERRIDE(glGetUniformfv); + OVERRIDE(glGetUniformiv); + OVERRIDE(glGetUniformLocation); + OVERRIDE(glIsProgram); + OVERRIDE(glLinkProgram); + OVERRIDE(glUseProgram); + OVERRIDE(glValidateProgram); + OVERRIDE(glGetProgramBinary); + OVERRIDE(glProgramBinary); + + OVERRIDE(glBlendColor); + OVERRIDE(glBlendEquation); + OVERRIDE(glBlendEquationSeparate); + OVERRIDE(glBlendFunc); + OVERRIDE(glBlendFuncSeparate); + OVERRIDE(glClearColor); + OVERRIDE(glClearDepthf); + OVERRIDE(glClearStencil); + OVERRIDE(glColorMask); + OVERRIDE(glCullFace); + OVERRIDE(glDepthFunc); + OVERRIDE(glDepthMask); + OVERRIDE(glDepthRangef); + OVERRIDE(glDisable); + OVERRIDE(glDisableVertexAttribArray); + OVERRIDE(glDrawArrays); + OVERRIDE(glDrawElements); + OVERRIDE(glEnable); + OVERRIDE(glEnableVertexAttribArray); + OVERRIDE(glFrontFace); + OVERRIDE(glGetVertexAttribfv); + OVERRIDE(glGetVertexAttribiv); + OVERRIDE(glGetVertexAttribPointerv); + OVERRIDE(glHint); + OVERRIDE(glLineWidth); + OVERRIDE(glPixelStorei); + OVERRIDE(glPolygonOffset); + OVERRIDE(glSampleCoverage); + OVERRIDE(glScissor); + OVERRIDE(glStencilFunc); + OVERRIDE(glStencilFuncSeparate); + OVERRIDE(glStencilMask); + OVERRIDE(glStencilMaskSeparate); + OVERRIDE(glStencilOp); + OVERRIDE(glStencilOpSeparate); + OVERRIDE(glVertexAttrib1f); + OVERRIDE(glVertexAttrib1fv); + OVERRIDE(glVertexAttrib2f); + OVERRIDE(glVertexAttrib2fv); + OVERRIDE(glVertexAttrib3f); + OVERRIDE(glVertexAttrib3fv); + OVERRIDE(glVertexAttrib4f); + OVERRIDE(glVertexAttrib4fv); + OVERRIDE(glVertexAttribPointer); + OVERRIDE(glViewport); + + OVERRIDE(glEGLImageTargetTexture2DOES); + + } + else + { + LOG("\E[0;35;1m[CoreGL] SKIP GL FASTPATH...\E[0m\n"); + } +} + +#undef OVERRIDE + static GL_Object ** _get_shared_object(GL_Shared_Object_State *sostate, GL_Object_Type type) { @@ -67,9 +334,150 @@ _get_shared_object(GL_Shared_Object_State *sostate, GL_Object_Type type) } } +int +fastpath_add_context_state_to_list(const void *option, const int option_len, GLContextState *cstate, Mutex *mtx) +{ + int ret = 0; + int tid = 0; + GLContext_List *current = NULL; + GLContext_List *newitm = NULL; + + if (mtx != NULL) AST(mutex_lock(mtx) == 1); + + AST(cstate != NULL); + + tid = get_current_thread(); + + current = glctx_list; + while (current != NULL) + { + if (current->option_len == option_len && + memcmp(current->option, option, option_len) == 0 && + current->thread_id == tid) + { + AST(current->cstate == cstate); + goto finish; + } + current = current->next; + } + + newitm = (GLContext_List *)calloc(1, sizeof(GLContext_List)); + if (newitm == NULL) + { + ERR("Failed to create context list.\n"); + goto finish; + } + + newitm->cstate = cstate; + newitm->thread_id = tid; + newitm->option_len = option_len; + newitm->option = (void *)malloc(option_len); + memcpy(newitm->option, option, option_len); + + if (glctx_list != NULL) + newitm->next = glctx_list; + + glctx_list = newitm; + + ret = 1; + goto finish; + +finish: + if (ret != 1) + { + if (newitm != NULL) + { + free(newitm); + newitm = NULL; + } + if (cstate != NULL) + { + free(cstate); + cstate = NULL; + } + } + if (mtx != NULL) AST(mutex_unlock(mtx) == 1); + + return ret; +} + +GLContextState * +fastpath_get_context_state_from_list(const void *option, const int option_len, Mutex *mtx) +{ + GLContextState *ret = NULL; + GLContext_List *current = NULL; + int tid = 0; + + if (mtx != NULL) AST(mutex_lock(mtx) == 1); + + tid = get_current_thread(); + + current = glctx_list; + while (current != NULL) + { + if (current->option_len == option_len && + memcmp(current->option, option, option_len) == 0 && + current->thread_id == tid) + { + ret = current->cstate; + goto finish; + } + current = current->next; + } + goto finish; + +finish: + if (mtx != NULL) AST(mutex_unlock(mtx) == 1); + return ret; +} + +int +fastpath_remove_context_states_from_list(GLContextState *cstate, Mutex *mtx) +{ + int ret = 0; + int tid = 0; + GLContext_List *olditm = NULL; + GLContext_List *current = NULL; + + if (mtx != NULL) AST(mutex_lock(mtx) == 1); + + AST(cstate != NULL); + + tid = get_current_thread(); + current = glctx_list; + + while (current != NULL) + { + if (current->cstate == cstate) + { + GLContext_List *nextitm = NULL; + if (olditm != NULL) + { + olditm->next = current->next; + nextitm = olditm->next; + } + else + { + glctx_list = current->next; + nextitm = glctx_list; + } + free(current); + ret = 1; + current = nextitm; + continue; + } + olditm = current; + current = current->next; + } + goto finish; + +finish: + if (mtx != NULL) AST(mutex_unlock(mtx) == 1); + return ret; +} GLuint -sostate_create_object(GL_Shared_Object_State *sostate, GL_Object_Type type, GLuint real_name) +fastpath_sostate_create_object(GL_Shared_Object_State *sostate, GL_Object_Type type, GLuint real_name) { GL_Object **object = NULL; GLuint ret = _COREGL_INT_INIT_VALUE; @@ -96,7 +504,7 @@ finish: } GLuint -sostate_remove_object(GL_Shared_Object_State *sostate, GL_Object_Type type, GLuint glue_name) +fastpath_sostate_remove_object(GL_Shared_Object_State *sostate, GL_Object_Type type, GLuint glue_name) { GL_Object **object = NULL; GLuint ret = _COREGL_INT_INIT_VALUE; @@ -124,7 +532,7 @@ finish: } GLuint -sostate_get_object(GL_Shared_Object_State *sostate, GL_Object_Type type, GLuint glue_name) +fastpath_sostate_get_object(GL_Shared_Object_State *sostate, GL_Object_Type type, GLuint glue_name) { GL_Object **object = NULL; GLuint ret = _COREGL_INT_INIT_VALUE; @@ -149,7 +557,7 @@ finish: } GLuint -sostate_find_object(GL_Shared_Object_State *sostate, GL_Object_Type type, GLuint real_name) +fastpath_sostate_find_object(GL_Shared_Object_State *sostate, GL_Object_Type type, GLuint real_name) { GL_Object **object = NULL; GLuint ret = _COREGL_INT_INIT_VALUE; @@ -173,7 +581,7 @@ finish: } void -dump_context_states(GLGlueContext *ctx, int force_output) +fastpath_dump_context_states(GLGlueContext *ctx, int force_output) { static struct timeval tv_last = { 0, 0 }; @@ -243,7 +651,7 @@ finish: } int -init_context_states(GLGlueContext *ctx) +fastpath_init_context_states(GLGlueContext *ctx) { int ret = 0; @@ -385,8 +793,13 @@ finish: return ret; } +#ifdef COREGL_USE_MODULE_TRACEPATH +extern void *tracepath_api_trace_begin(const char *name, void *hint, int trace_total_time); +extern void *tracepath_api_trace_end(const char *name, void *hint, int trace_total_time); +#endif + void -make_context_current(GLGlueContext *oldctx, GLGlueContext *newctx) +fastpath_make_context_current(GLGlueContext *oldctx, GLGlueContext *newctx) { unsigned char flag = 0; int i = 0; @@ -396,24 +809,28 @@ make_context_current(GLGlueContext *oldctx, GLGlueContext *newctx) // Return if they're the same if (oldctx == newctx) goto finish; -#ifdef EVAS_GL_DEBUG -# define STATE_COMPARE(state) -# define STATES_COMPARE(state_ptr, bytes) -#else -# define STATE_COMPARE(state) \ +#define STATE_COMPARE(state) \ if ((oldctx->state) != (newctx->state)) -# define STATES_COMPARE(state_ptr, bytes) \ + +#define STATES_COMPARE(state_ptr, bytes) \ if ((memcmp((oldctx->state_ptr), (newctx->state_ptr), (bytes))) != 0) -#endif + +#ifdef COREGL_USE_MODULE_TRACEPATH static void *trace_hint_glfinish = NULL; - trace_hint_glfinish = _COREGL_TRACE_API_BEGIN("eglMakeCurrent(FP glFinish)", trace_hint_glfinish, 0); + trace_hint_glfinish = tracepath_api_trace_begin("eglMakeCurrent(FP glFinish)", trace_hint_glfinish, 0); +#endif // COREGL_USE_MODULE_TRACEPATH + _sym_glFlush(); - _COREGL_TRACE_API_END("eglMakeCurrent(FP glFinish)", trace_hint_glfinish, 0); +#ifdef COREGL_USE_MODULE_TRACEPATH + tracepath_api_trace_end("eglMakeCurrent(FP glFinish)", trace_hint_glfinish, 0); +#endif // COREGL_USE_MODULE_TRACEPATH +#ifdef COREGL_USE_MODULE_TRACEPATH static void *trace_hint_bindbuffers = NULL; - trace_hint_bindbuffers = _COREGL_TRACE_API_BEGIN("eglMakeCurrent(FP bind buffers)", trace_hint_bindbuffers, 0); + trace_hint_bindbuffers = tracepath_api_trace_begin("eglMakeCurrent(FP bind buffers)", trace_hint_bindbuffers, 0); +#endif // COREGL_USE_MODULE_TRACEPATH //------------------// // _bind_flag @@ -438,14 +855,18 @@ make_context_current(GLGlueContext *oldctx, GLGlueContext *newctx) } } - _COREGL_TRACE_API_END("eglMakeCurrent(FP bind buffers)", trace_hint_bindbuffers, 0); +#ifdef COREGL_USE_MODULE_TRACEPATH + tracepath_api_trace_end("eglMakeCurrent(FP bind buffers)", trace_hint_bindbuffers, 0); +#endif // COREGL_USE_MODULE_TRACEPATH //------------------// // Enable States // _enable_flag1 +#ifdef COREGL_USE_MODULE_TRACEPATH static void *trace_hint_enable_states = NULL; - trace_hint_enable_states = _COREGL_TRACE_API_BEGIN("eglMakeCurrent(FP enable states)", trace_hint_enable_states, 0); + trace_hint_enable_states = tracepath_api_trace_begin("eglMakeCurrent(FP enable states)", trace_hint_enable_states, 0); +#endif // COREGL_USE_MODULE_TRACEPATH flag = oldctx->_enable_flag1 | newctx->_enable_flag1; if (flag) @@ -521,12 +942,16 @@ make_context_current(GLGlueContext *oldctx, GLGlueContext *newctx) } } - _COREGL_TRACE_API_END("eglMakeCurrent(FP enable states)", trace_hint_enable_states, 0); +#ifdef COREGL_USE_MODULE_TRACEPATH + tracepath_api_trace_end("eglMakeCurrent(FP enable states)", trace_hint_enable_states, 0); +#endif // COREGL_USE_MODULE_TRACEPATH //------------------// // _clear_flag1 +#ifdef COREGL_USE_MODULE_TRACEPATH static void *trace_hint_clear_viewport = NULL; - trace_hint_clear_viewport = _COREGL_TRACE_API_BEGIN("eglMakeCurrent(FP clear/viewport)", trace_hint_clear_viewport, 0); + trace_hint_clear_viewport = tracepath_api_trace_begin("eglMakeCurrent(FP clear/viewport)", trace_hint_clear_viewport, 0); +#endif // COREGL_USE_MODULE_TRACEPATH flag = oldctx->_clear_flag1 | newctx->_clear_flag1; if (flag) @@ -589,12 +1014,16 @@ make_context_current(GLGlueContext *oldctx, GLGlueContext *newctx) } - _COREGL_TRACE_API_END("eglMakeCurrent(FP clear/viewport)", trace_hint_clear_viewport, 0); +#ifdef COREGL_USE_MODULE_TRACEPATH + tracepath_api_trace_end("eglMakeCurrent(FP clear/viewport)", trace_hint_clear_viewport, 0); +#endif // COREGL_USE_MODULE_TRACEPATH //------------------// // Texture here... +#ifdef COREGL_USE_MODULE_TRACEPATH static void *trace_hint_bind_textures = NULL; - trace_hint_bind_textures = _COREGL_TRACE_API_BEGIN("eglMakeCurrent(FP bind textures)", trace_hint_bind_textures, 0); + trace_hint_bind_textures = tracepath_api_trace_begin("eglMakeCurrent(FP bind textures)", trace_hint_bind_textures, 0); +#endif // COREGL_USE_MODULE_TRACEPATH flag = oldctx->_tex_flag1 | newctx->_tex_flag1; if (flag) @@ -623,11 +1052,15 @@ make_context_current(GLGlueContext *oldctx, GLGlueContext *newctx) _sym_glHint(GL_GENERATE_MIPMAP_HINT, newctx->gl_generate_mipmap_hint[0]); } } - _COREGL_TRACE_API_END("eglMakeCurrent(FP bind textures)", trace_hint_bind_textures, 0); +#ifdef COREGL_USE_MODULE_TRACEPATH + tracepath_api_trace_end("eglMakeCurrent(FP bind textures)", trace_hint_bind_textures, 0); +#endif // COREGL_USE_MODULE_TRACEPATH //------------------// +#ifdef COREGL_USE_MODULE_TRACEPATH static void *trace_hint_etc = NULL; - trace_hint_etc = _COREGL_TRACE_API_BEGIN("eglMakeCurrent(FP etc.)", trace_hint_etc, 0); + trace_hint_etc = tracepath_api_trace_begin("eglMakeCurrent(FP etc.)", trace_hint_etc, 0); +#endif // COREGL_USE_MODULE_TRACEPATH flag = oldctx->_blend_flag | newctx->_blend_flag; if (flag) @@ -768,11 +1201,16 @@ make_context_current(GLGlueContext *oldctx, GLGlueContext *newctx) _sym_glPixelStorei(GL_UNPACK_ALIGNMENT, newctx->gl_unpack_alignment[0]); } } - _COREGL_TRACE_API_END("eglMakeCurrent(FP etc.)", trace_hint_etc, 0); +#ifdef COREGL_USE_MODULE_TRACEPATH + tracepath_api_trace_end("eglMakeCurrent(FP etc.)", trace_hint_etc, 0); +#endif // COREGL_USE_MODULE_TRACEPATH // _varray_flag +#ifdef COREGL_USE_MODULE_TRACEPATH static void *trace_hint_vertex_attrib = NULL; - trace_hint_vertex_attrib = _COREGL_TRACE_API_BEGIN("eglMakeCurrent(FP vertex attrib)", trace_hint_vertex_attrib, 0); + trace_hint_vertex_attrib = tracepath_api_trace_begin("eglMakeCurrent(FP vertex attrib)", trace_hint_vertex_attrib, 0); +#endif // COREGL_USE_MODULE_TRACEPATH + flag = oldctx->_vattrib_flag | newctx->_vattrib_flag; if (flag) { @@ -817,14 +1255,17 @@ make_context_current(GLGlueContext *oldctx, GLGlueContext *newctx) } - _COREGL_TRACE_API_END("eglMakeCurrent(FP vertex attrib)", trace_hint_vertex_attrib, 0); +#ifdef COREGL_USE_MODULE_TRACEPATH + tracepath_api_trace_end("eglMakeCurrent(FP vertex attrib)", trace_hint_vertex_attrib, 0); +#endif // COREGL_USE_MODULE_TRACEPATH + goto finish; finish: #ifdef COREGL_TRACE_STATE_INFO if (unlikely(trace_state_flag == 1)) - dump_context_states(newctx, 0); + fastpath_dump_context_states(newctx, 0); #endif // COREGL_TRACE_STATE_INFO return; #undef STATE_COMPARE diff --git a/src/modules/fastpath/coregl_fastpath.h b/src/modules/fastpath/coregl_fastpath.h new file mode 100644 index 0000000..7c45eba --- /dev/null +++ b/src/modules/fastpath/coregl_fastpath.h @@ -0,0 +1,230 @@ +#ifndef COREGL_FASTPATH_H +#define COREGL_FASTPATH_H + +#include "../coregl_module.h" + +#ifndef COREGL_USE_MODULE_FASTPATH +#error "COREGL_USE_MODULE_FASTPATH must defined!!!" +#endif + +#define MY_MODULE_ID COREGL_MODULE_FASTPATH +#define MY_MODULE_TSTATE Fastpath_ThreadState + +#include "../../coregl_internal.h" +#include "../../coregl_export.h" + +#define _COREGL_SYMBOL(IS_EXTENSION, RET_TYPE, FUNC_NAME, PARAM_LIST) extern RET_TYPE (*_orig_fastpath_##FUNC_NAME) PARAM_LIST; +# include "../../headers/sym.h" +#undef _COREGL_SYMBOL + +// Symbol definition for fastpath +#define _COREGL_SYMBOL(IS_EXTENSION, RET_TYPE, FUNC_NAME, PARAM_LIST) extern RET_TYPE (fastpath_##FUNC_NAME) PARAM_LIST; +# include "../../headers/sym.h" +#undef _COREGL_SYMBOL + +#define COREGL_FASTPATH_TRACE_ALL + +#ifdef COREGL_FASTPATH_TRACE_ALL +#define COREGL_FASTPATH_TRACE_CONTEXT_INFO // Context state & thread state & Glue-context info +#define COREGL_FASTPATH_TRACE_STATE_INFO // Glue-context state info +#endif + + +#define _COREGL_FASTPATH_FUNC_BEGIN() + +#define _COREGL_FASTPATH_FUNC_END() + + +#define FLAG_BIT_0 0x01 +#define FLAG_BIT_1 0x02 +#define FLAG_BIT_2 0x04 +#define FLAG_BIT_3 0x08 +#define FLAG_BIT_4 0x10 +#define FLAG_BIT_5 0x20 +#define FLAG_BIT_6 0x40 +#define FLAG_BIT_7 0x80 + +#define MAX_TEXTURE_UNITS 32 +#define MAX_VERTEX_ATTRIBS 64 + +typedef enum _Fastpath_Opt_Flag +{ + FP_UNKNOWN_PATH, + FP_NORMAL_PATH, + FP_FAST_PATH +} Fastpath_Opt_Flag; + +extern Fastpath_Opt_Flag fp_opt; +extern int debug_nofp; + +typedef struct _GLContextState +{ + int ref_count; + GLContext *rctx; + GLDisplay *rdpy; + void *data; +} GLContextState; + +typedef struct _Fastpath_ThreadState +{ + EGLenum binded_api; + GLContextState *cstate; + GLSurface *rsurf_draw; + GLSurface *rsurf_read; +} Fastpath_ThreadState; + +typedef struct _GLContext_List +{ + void *option; + int option_len; + int thread_id; + GLContextState *cstate; + struct _GLContext_List *next; +} GLContext_List; + +extern GLContext_List *glctx_list; + +extern Mutex ctx_list_access_mutex; + +typedef struct +{ + GLuint tex_id; +} GL_Texture_State; + +typedef struct +{ + GLboolean modified; + GLboolean enabled; + GLuint buf_id; + GLint size; + GLenum type; + GLboolean normalized; + GLsizei stride; + const void *pointer; +} GL_Vertex_Array_State; + +typedef struct +{ + GLboolean modified; + GLfloat value[4]; +} GL_Vertex_Attrib; + + +#define MAGIC_GLFAST 0x73777770 +#define MAX_GL_OBJECT_SIZE 100000 + +typedef enum +{ + GL_OBJECT_TYPE_UNKNOWN = 0x0, + GL_OBJECT_TYPE_TEXTURE = 0x1000000, + GL_OBJECT_TYPE_BUFFER = 0x2000000, + GL_OBJECT_TYPE_FRAMEBUFFER = 0x3000000, + GL_OBJECT_TYPE_RENDERBUFFER = 0x4000000, + GL_OBJECT_TYPE_PROGRAM = 0x5000000, +} GL_Object_Type; + +typedef struct _GL_Object +{ + GLuint id; + GLuint real_id; + + struct _GL_Shared_Object_State *parent; +} GL_Object; + +typedef struct _GL_Shared_Object_State +{ + int ref_count; + + GL_Object *texture[MAX_GL_OBJECT_SIZE]; + GL_Object *buffer[MAX_GL_OBJECT_SIZE]; + GL_Object *framebuffer[MAX_GL_OBJECT_SIZE]; + GL_Object *renderbuffer[MAX_GL_OBJECT_SIZE]; + GL_Object *program[MAX_GL_OBJECT_SIZE]; +} GL_Shared_Object_State; + +typedef struct _GLGlueContext +{ + int magic; + int initialized; + int surface_attached; + + int ref_count; + int is_destroyed; + + int used_count; + + GLDisplay *rdpy; + GLContextState *cstate; + int thread_id; + + void *real_ctx_option; + int real_ctx_option_len; + + void *real_ctx_sharable_option; + int real_ctx_sharable_option_len; + + unsigned char _bind_flag; + unsigned char _enable_flag1; + unsigned char _enable_flag2; + unsigned char _clear_flag1; + unsigned char _clear_flag2; + unsigned char _tex_flag1; + unsigned char _blend_flag; + unsigned char _stencil_flag1; + unsigned char _stencil_flag2; + unsigned char _misc_flag1; + unsigned char _misc_flag2; + unsigned char _vattrib_flag; + + GL_Shared_Object_State *sostate; + + GLenum gl_error; + + // General state +#define GLUE_STATE(TYPE, NAME, SIZE, ARRAY_SIZE, DEFAULT_STMT, GET_STMT) TYPE NAME[ARRAY_SIZE]; +# include "coregl_fastpath_state.h" +#undef GLUE_STATE + +} GLGlueContext; + +typedef struct _GLGlueContext_List +{ + GLGlueContext *gctx; + struct _GLGlueContext_List *prev; + struct _GLGlueContext_List *next; +} GLGlueContext_List; + +extern GLGlueContext_List *gctx_list; + +extern GLGlueContext *initial_ctx; + +extern void init_modules_fastpath(); +extern void deinit_modules_fastpath(); +extern void init_modules_tstate_fastpath(GLThreadState *tstate); +extern void deinit_modules_tstate_fastpath(GLThreadState *tstate); + +extern void fastpath_apply_overrides(); +extern void fastpath_apply_overrides_egl(int enable); +extern void fastpath_apply_overrides_gl(int enable); + +extern int fastpath_init_context_states(GLGlueContext *ctx); +extern void fastpath_make_context_current(GLGlueContext *oldctx, GLGlueContext *newctx); + +#ifdef COREGL_TRACE_STATE_INFO +extern void fastpath_dump_context_states(GLGlueContext *ctx, int force_output); +#endif + +// Context state functions +extern int fastpath_add_context_state_to_list(const void *data, const int datalen, GLContextState *cstate, Mutex *mtx); +extern int fastpath_remove_context_states_from_list(GLContextState *cstate, Mutex *mtx); +extern GLContextState *fastpath_get_context_state_from_list(const void *data, const int datalen, Mutex *mtx); + +// Shared object state functions +extern GLuint fastpath_sostate_create_object(GL_Shared_Object_State *sostate, GL_Object_Type type, GLuint name); +extern GLuint fastpath_sostate_remove_object(GL_Shared_Object_State *sostate, GL_Object_Type type, GLuint glue_name); +extern GLuint fastpath_sostate_get_object(GL_Shared_Object_State *sostate, GL_Object_Type type, GLuint name); +extern GLuint fastpath_sostate_find_object(GL_Shared_Object_State *sostate, GL_Object_Type type, GLuint real_name); + + +#endif // COREGL_FASTPATH_H + diff --git a/src/coregl_fastpath_egl.c b/src/modules/fastpath/coregl_fastpath_egl.c similarity index 80% rename from src/coregl_fastpath_egl.c rename to src/modules/fastpath/coregl_fastpath_egl.c index c37c79d..74dd03b 100644 --- a/src/coregl_fastpath_egl.c +++ b/src/modules/fastpath/coregl_fastpath_egl.c @@ -5,7 +5,7 @@ #include #include -#ifdef COREGL_TRACE_CONTEXT_INFO +#ifdef COREGL_FASTPATH_TRACE_CONTEXT_INFO General_Trace_List *glue_ctx_trace_list = NULL; General_Trace_List *context_state_trace_list = NULL; @@ -13,7 +13,7 @@ General_Trace_List *context_state_trace_list = NULL; static void _dump_context_info(const char *ment, int force_output) { - GLThreadState *tstate = NULL; + MY_MODULE_TSTATE *tstate = NULL; static struct timeval tv_last = { 0, 0 }; if (trace_ctx_flag != 1) return; @@ -32,7 +32,7 @@ _dump_context_info(const char *ment, int force_output) tv_last = tv_now; } - tstate = get_current_thread_state(); + GET_MY_TSTATE(tstate, get_current_thread_state()); TRACE("\n"); TRACE("\E[40;34m========================================================================================================================\E[0m\n"); @@ -48,18 +48,22 @@ _dump_context_info(const char *ment, int force_output) while (current != NULL) { GLThreadState *cur_tstate = (GLThreadState *)current->value; + MY_MODULE_TSTATE *cur_tstate_tm = NULL; + + GET_MY_TSTATE(cur_tstate_tm, cur_tstate); + AST(cur_tstate_tm != NULL); TRACE(" %c Thread [%12d] : Surf ", - (tstate == cur_tstate) ? '*' : ' ', + (tstate == cur_tstate_tm) ? '*' : ' ', cur_tstate->thread_id, - cur_tstate->rsurf_draw, - cur_tstate->rsurf_read); + cur_tstate_tm->rsurf_draw, + cur_tstate_tm->rsurf_read); - if (cur_tstate->cstate != NULL) + if (cur_tstate_tm->cstate != NULL) { TRACE(" GlueCTX=[%12p] RealCTX=[%12p]\E[0m\n", - cur_tstate->cstate->data, - cur_tstate->cstate); + cur_tstate_tm->cstate->data, + cur_tstate_tm->cstate); } else { @@ -74,8 +78,12 @@ _dump_context_info(const char *ment, int force_output) while (current != NULL) { GLContextState *cur_cstate = (GLContextState *)current->value; + MY_MODULE_TSTATE *cur_tstate_tm = NULL; + + GET_MY_TSTATE(cur_tstate_tm, cur_tstate); + AST(cur_tstate_tm != NULL); - if (cur_tstate->cstate == cur_cstate) + if (cur_tstate_tm->cstate == cur_cstate) { TRACE(" -> RealCTX [%12p] : EGLDPY=[%12p] EGLCTX=[%12p] <[%2d] GlueCTXs>\E[0m\n", cur_cstate, @@ -140,10 +148,14 @@ _dump_context_info(const char *ment, int force_output) while (current_t != NULL) { GLThreadState *cur_tstate = (GLThreadState *)current_t->value; + MY_MODULE_TSTATE *cur_tstate_tm = NULL; + + GET_MY_TSTATE(cur_tstate_tm, cur_tstate); + AST(cur_tstate_tm != NULL); if (cur_tstate->thread_id == ((GLGlueContext *)cur_cstate->data)->thread_id) { - if (cur_tstate->cstate == cur_cstate) + if (cur_tstate_tm->cstate == cur_cstate) isbinded = 1; break; } @@ -230,7 +242,7 @@ finish: } -#endif // COREGL_TRACE_CONTEXT_INFO +#endif // COREGL_FASTPATH_TRACE_CONTEXT_INFO typedef struct @@ -369,27 +381,27 @@ _unlink_context_state(GLGlueContext *gctx, Mutex *ctx_list_mtx) if (cstate->ref_count == 0) { - GLThreadState *tstate = NULL; + MY_MODULE_TSTATE *tstate = NULL; AST(cstate->data == NULL || cstate->data == initial_ctx); -#ifdef COREGL_TRACE_CONTEXT_INFO +#ifdef COREGL_FASTPATH_TRACE_CONTEXT_INFO if (unlikely(trace_ctx_flag == 1)) remove_from_general_trace_list(&context_state_trace_list, cstate); -#endif // COREGL_TRACE_CONTEXT_INFO +#endif // COREGL_FASTPATH_TRACE_CONTEXT_INFO - AST(remove_context_states_from_list(cstate, ctx_list_mtx) == 1); + AST(fastpath_remove_context_states_from_list(cstate, ctx_list_mtx) == 1); - tstate = get_current_thread_state(); + GET_MY_TSTATE(tstate, get_current_thread_state()); if (tstate != NULL) { if (tstate->cstate == cstate) { - _sym_eglMakeCurrent(cstate->rdpy, tstate->rsurf_draw, tstate->rsurf_read, EGL_NO_CONTEXT); + _orig_fastpath_eglMakeCurrent(cstate->rdpy, tstate->rsurf_draw, tstate->rsurf_read, EGL_NO_CONTEXT); tstate->cstate = NULL; } } - _sym_eglDestroyContext(cstate->rdpy, cstate->rctx); + _orig_fastpath_eglDestroyContext(cstate->rdpy, cstate->rctx); free(cstate); cstate = NULL; } @@ -431,10 +443,10 @@ _remove_context_ref(GLGlueContext *gctx, Mutex *ctx_list_mtx) gctx->ref_count--; if (gctx->ref_count == 0) { -#ifdef COREGL_TRACE_CONTEXT_INFO +#ifdef COREGL_FASTPATH_TRACE_CONTEXT_INFO if (unlikely(trace_ctx_flag == 1)) remove_from_general_trace_list(&glue_ctx_trace_list, gctx); -#endif // COREGL_TRACE_CONTEXT_INFO +#endif // COREGL_FASTPATH_TRACE_CONTEXT_INFO _unlink_context_state(gctx, ctx_list_mtx); @@ -507,7 +519,7 @@ _bind_context_state(GLGlueContext *gctx, GLContextState *cstate, Mutex *ctx_list AST(newctx != NULL); AST(curctx != NULL); - make_context_current(curctx, newctx); + fastpath_make_context_current(curctx, newctx); cstate->data = (void *)newctx; _remove_context_ref(curctx, ctx_list_mtx); _add_context_ref(newctx); @@ -536,7 +548,7 @@ _egl_create_context(EGL_packed_option *real_ctx_option, GLContextState **cstate_ } // Find context state - cstate = get_context_state_from_list(real_ctx_option, sizeof(EGL_packed_option), &ctx_list_access_mutex); + cstate = fastpath_get_context_state_from_list(real_ctx_option, sizeof(EGL_packed_option), &ctx_list_access_mutex); // Create a real context if it hasn't been created if (cstate == NULL) @@ -563,7 +575,7 @@ _egl_create_context(EGL_packed_option *real_ctx_option, GLContextState **cstate_ } AST(mutex_unlock(&ctx_list_access_mutex) == 1); - *ctx = _sym_eglCreateContext(dpy, config, real_share_context, attrib_list); + *ctx = _orig_fastpath_eglCreateContext(dpy, config, real_share_context, attrib_list); if (*ctx == EGL_NO_CONTEXT) { @@ -581,12 +593,12 @@ _egl_create_context(EGL_packed_option *real_ctx_option, GLContextState **cstate_ (*cstate_new)->rdpy = dpy; (*cstate_new)->data = NULL; - AST(add_context_state_to_list(real_ctx_option, sizeof(EGL_packed_option), *cstate_new, &ctx_list_access_mutex) == 1); + AST(fastpath_add_context_state_to_list(real_ctx_option, sizeof(EGL_packed_option), *cstate_new, &ctx_list_access_mutex) == 1); -#ifdef COREGL_TRACE_CONTEXT_INFO +#ifdef COREGL_FASTPATH_TRACE_CONTEXT_INFO if (unlikely(trace_ctx_flag == 1)) add_to_general_trace_list(&context_state_trace_list, *cstate_new); -#endif // COREGL_TRACE_CONTEXT_INFO +#endif // COREGL_FASTPATH_TRACE_CONTEXT_INFO cstate = *cstate_new; } @@ -599,65 +611,48 @@ finish: } - - -//----------------------------------------------------------------// -// Fastpath EGL Functions // -// The functions have prefix 'fpgl_' for (fastpath gl) // -//----------------------------------------------------------------// - -extern EGLBoolean (*wrp_eglBindAPI)(EGLenum api); -extern EGLenum (*wrp_eglQueryAPI)(void); extern EGLBoolean (*ovr_eglBindAPI)(EGLenum api); extern EGLenum (*ovr_eglQueryAPI)(void); EGLBoolean -fpgl_eglBindAPI(EGLenum api) +fastpath_eglBindAPI(EGLenum api) { EGLBoolean ret = EGL_FALSE; - GLThreadState *tstate = NULL; + MY_MODULE_TSTATE *tstate = NULL; - _COREGL_FAST_FUNC_BEGIN(); - if (api_opt == COREGL_UNKNOWN_PATH) + _COREGL_FASTPATH_FUNC_BEGIN(); + if (fp_opt == FP_UNKNOWN_PATH) { ERR("\E[0;31;1mERROR : Invalid library link! (CoreGL path option is invalid)\E[0m\n"); goto finish; } - ret = _sym_eglBindAPI(api); + ret = _orig_fastpath_eglBindAPI(api); - tstate = get_current_thread_state(); + GET_MY_TSTATE(tstate, get_current_thread_state()); if (tstate == NULL) { AST(init_new_thread_state() == 1); - tstate = get_current_thread_state(); + GET_MY_TSTATE(tstate, get_current_thread_state()); AST(tstate != NULL); } { - EGLenum newapi = _sym_eglQueryAPI(); + EGLenum newapi = _orig_fastpath_eglQueryAPI(); if (tstate->binded_api != newapi) { if (newapi != EGL_OPENGL_ES_API) { // Fallback when binding other API // Fastpath restores when bind OPENGL_ES_API - override_glue_normal_path(); - if (trace_api_flag == 1) - { - wrp_eglBindAPI = fpgl_eglBindAPI; - wrp_eglQueryAPI = fpgl_eglQueryAPI; - } - else - { - ovr_eglBindAPI = fpgl_eglBindAPI; - ovr_eglQueryAPI = fpgl_eglQueryAPI; - } + fastpath_apply_overrides_egl(0); + ovr_eglBindAPI = fastpath_eglBindAPI; + ovr_eglQueryAPI = fastpath_eglQueryAPI; } else { - override_glue_fast_path(); + fastpath_apply_overrides_egl(1); } tstate->binded_api = newapi; } @@ -666,26 +661,26 @@ fpgl_eglBindAPI(EGLenum api) goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); return ret; } EGLenum -fpgl_eglQueryAPI(void) +fastpath_eglQueryAPI(void) { EGLenum ret = 0; - GLThreadState *tstate = NULL; + MY_MODULE_TSTATE *tstate = NULL; - _COREGL_FAST_FUNC_BEGIN(); - if (api_opt == COREGL_UNKNOWN_PATH) + _COREGL_FASTPATH_FUNC_BEGIN(); + if (fp_opt == FP_UNKNOWN_PATH) { ERR("\E[0;31;1mERROR : Invalid library link! (CoreGL path option is invalid)\E[0m\n"); goto finish; } - ret = _sym_eglQueryAPI(); + ret = _orig_fastpath_eglQueryAPI(); - tstate = get_current_thread_state(); + GET_MY_TSTATE(tstate, get_current_thread_state()); if (tstate != NULL) { AST(tstate->binded_api == ret); @@ -694,16 +689,16 @@ fpgl_eglQueryAPI(void) goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); return ret; } EGLContext -fpgl_eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint* attrib_list) +fastpath_eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint* attrib_list) { GLGlueContext *gctx = NULL; GLGlueContext_List *gctx_list_new = NULL; - GLThreadState *tstate = NULL; + MY_MODULE_TSTATE *tstate = NULL; GLContextState *cstate = NULL; GLContextState *cstate_new = NULL; GL_Shared_Object_State *sostate_new = NULL; @@ -713,13 +708,13 @@ fpgl_eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_context EGL_packed_sharable_option *real_ctx_sharable_option = NULL; // Special eject condition for binding API - tstate = get_current_thread_state(); + GET_MY_TSTATE(tstate, get_current_thread_state()); if (tstate != NULL && tstate->binded_api != EGL_OPENGL_ES_API) { - return _sym_eglCreateContext(dpy, config, share_context, attrib_list); + return _orig_fastpath_eglCreateContext(dpy, config, share_context, attrib_list); } - _COREGL_FAST_FUNC_BEGIN(); + _COREGL_FASTPATH_FUNC_BEGIN(); real_ctx_option = (EGL_packed_option *)calloc(1, sizeof(EGL_packed_option)); if (real_ctx_option == NULL) @@ -802,7 +797,7 @@ fpgl_eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_context AST(mutex_unlock(&ctx_list_access_mutex) == 1); } -#ifdef COREGL_TRACE_CONTEXT_INFO +#ifdef COREGL_FASTPATH_TRACE_CONTEXT_INFO if (unlikely(trace_ctx_flag == 1)) { char ment[256]; @@ -811,7 +806,7 @@ fpgl_eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_context sprintf(ment, "eglCreateContext completed (GlueCTX=[%12p])", gctx); _dump_context_info(ment, 1); } -#endif // COREGL_TRACE_CONTEXT_INFO +#endif // COREGL_FASTPATH_TRACE_CONTEXT_INFO goto finish; @@ -820,7 +815,7 @@ finish: { if (ctx != NULL) { - _sym_eglDestroyContext(dpy, ctx); + _orig_fastpath_eglDestroyContext(dpy, ctx); ctx = NULL; } if (sostate_new != NULL) @@ -840,12 +835,12 @@ finish: } if (cstate_new != NULL) { -#ifdef COREGL_TRACE_CONTEXT_INFO +#ifdef COREGL_FASTPATH_TRACE_CONTEXT_INFO if (unlikely(trace_ctx_flag == 1)) remove_from_general_trace_list(&context_state_trace_list, cstate_new); -#endif // COREGL_TRACE_CONTEXT_INFO +#endif // COREGL_FASTPATH_TRACE_CONTEXT_INFO - remove_context_states_from_list(cstate_new, &ctx_list_access_mutex); + fastpath_remove_context_states_from_list(cstate_new, &ctx_list_access_mutex); free(cstate_new); cstate_new = NULL; } @@ -867,17 +862,17 @@ finish: } } - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); return (EGLContext)gctx; } EGLBoolean -fpgl_eglDestroyContext(EGLDisplay dpy, EGLContext ctx) +fastpath_eglDestroyContext(EGLDisplay dpy, EGLContext ctx) { EGLBoolean ret = EGL_FALSE; GLGlueContext *gctx = NULL; - _COREGL_FAST_FUNC_BEGIN(); + _COREGL_FASTPATH_FUNC_BEGIN(); gctx = (GLGlueContext *)ctx; @@ -887,7 +882,7 @@ fpgl_eglDestroyContext(EGLDisplay dpy, EGLContext ctx) if (gctx->magic != MAGIC_GLFAST) { - ret = _sym_eglDestroyContext(dpy, ctx); + ret = _orig_fastpath_eglDestroyContext(dpy, ctx); goto finish; } @@ -911,27 +906,27 @@ fpgl_eglDestroyContext(EGLDisplay dpy, EGLContext ctx) goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); -#ifdef COREGL_TRACE_CONTEXT_INFO +#ifdef COREGL_FASTPATH_TRACE_CONTEXT_INFO if (unlikely(trace_ctx_flag == 1)) { char ment[256]; sprintf(ment, "eglDestroyContext completed (GlueCTX=[%12p])", ctx); _dump_context_info(ment, 1); } -#endif // COREGL_TRACE_CONTEXT_INFO +#endif // COREGL_FASTPATH_TRACE_CONTEXT_INFO return ret; } EGLBoolean -fpgl_eglQueryContext(EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value) +fastpath_eglQueryContext(EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value) { EGLBoolean ret = EGL_FALSE; EGLContext real_ctx = EGL_NO_CONTEXT; - _COREGL_FAST_FUNC_BEGIN(); + _COREGL_FASTPATH_FUNC_BEGIN(); if (ctx != EGL_NO_CONTEXT) { @@ -949,67 +944,65 @@ fpgl_eglQueryContext(EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *v } } - _COREGL_FAST_FUNC_SYMCALL_BEGIN(); - ret = _sym_eglQueryContext(dpy, real_ctx, attribute, value); - _COREGL_FAST_FUNC_SYMCALL_END(); + ret = _orig_fastpath_eglQueryContext(dpy, real_ctx, attribute, value); goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); return ret; } EGLBoolean -fpgl_eglReleaseThread(void) +fastpath_eglReleaseThread(void) { EGLBoolean ret = EGL_FALSE; EGLDisplay dpy = EGL_NO_DISPLAY; - GLThreadState *tstate = NULL; + MY_MODULE_TSTATE *tstate = NULL; - tstate = get_current_thread_state(); + GET_MY_TSTATE(tstate, get_current_thread_state()); // Special eject condition for binding API if (tstate != NULL && tstate->binded_api != EGL_OPENGL_ES_API) { - return _sym_eglReleaseThread(); + return _orig_fastpath_eglReleaseThread(); } - _COREGL_FAST_FUNC_BEGIN(); + _COREGL_FASTPATH_FUNC_BEGIN(); - dpy = _sym_eglGetCurrentDisplay(); + dpy = _orig_fastpath_eglGetCurrentDisplay(); AST(dpy != EGL_NO_DISPLAY); - fpgl_eglMakeCurrent(dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); - ret = _sym_eglReleaseThread(); + fastpath_eglMakeCurrent(dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); + ret = _orig_fastpath_eglReleaseThread(); goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); return ret; } EGLBoolean -fpgl_eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx) +fastpath_eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx) { EGLBoolean ret = EGL_FALSE; EGLBoolean need_mc = EGL_FALSE; GLGlueContext *gctx = NULL; - GLThreadState *tstate = NULL; + MY_MODULE_TSTATE *tstate = NULL; GLContextState *cstate = NULL; - tstate = get_current_thread_state(); + GET_MY_TSTATE(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); + return _orig_fastpath_eglMakeCurrent(dpy, draw, read, ctx); } - _COREGL_FAST_FUNC_BEGIN(); + _COREGL_FASTPATH_FUNC_BEGIN(); gctx = (GLGlueContext *)ctx; @@ -1017,7 +1010,7 @@ fpgl_eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext { AST(init_new_thread_state() == 1); - tstate = get_current_thread_state(); + GET_MY_TSTATE(tstate, get_current_thread_state()); AST(tstate != NULL); } @@ -1031,7 +1024,7 @@ fpgl_eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext _bind_context_state(NULL, tstate->cstate, &ctx_list_access_mutex); tstate->cstate = NULL; } - if (_sym_eglMakeCurrent(dpy, draw, read, ctx) != EGL_TRUE) + if (_orig_fastpath_eglMakeCurrent(dpy, draw, read, ctx) != EGL_TRUE) { ERR("WARNING : Error making context [%p] current. (invalid EGL display [%p] or EGL surface [D:%p/R:%p])\n", ctx, dpy, draw, read); ret = EGL_FALSE; @@ -1104,7 +1097,7 @@ fpgl_eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext // If it's a first time or drawable changed, do a make current if (cstate == NULL) { - cstate = get_context_state_from_list(gctx->real_ctx_option, gctx->real_ctx_option_len, &ctx_list_access_mutex); + cstate = fastpath_get_context_state_from_list(gctx->real_ctx_option, gctx->real_ctx_option_len, &ctx_list_access_mutex); if (cstate == NULL) { @@ -1129,7 +1122,7 @@ fpgl_eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext if (need_mc == EGL_TRUE) { // BB : full makecurrent - if (_sym_eglMakeCurrent(dpy, draw, read, gctx->cstate->rctx) != EGL_TRUE) + if (_orig_fastpath_eglMakeCurrent(dpy, draw, read, gctx->cstate->rctx) != EGL_TRUE) { ERR("Error making context current with the drawable.\n"); ret = EGL_FALSE; @@ -1145,7 +1138,7 @@ fpgl_eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext // Initialize context states if (gctx->initialized == 0) { - if (init_context_states(gctx) != 1) + if (fastpath_init_context_states(gctx) != 1) { ERR("Error intializing context\n"); goto finish; @@ -1159,7 +1152,7 @@ fpgl_eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext EGLint width = 0; EGLint height = 0; - _sym_glGetIntegerv(GL_VIEWPORT, box_buffer); + _orig_fastpath_glGetIntegerv(GL_VIEWPORT, box_buffer); width = box_buffer[2]; height = box_buffer[3]; @@ -1169,7 +1162,7 @@ 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); + _orig_fastpath_glGetIntegerv(GL_SCISSOR_BOX, box_buffer); width = box_buffer[2]; height = box_buffer[3]; @@ -1190,36 +1183,36 @@ fpgl_eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); -#ifdef COREGL_TRACE_CONTEXT_INFO +#ifdef COREGL_FASTPATH_TRACE_CONTEXT_INFO if (unlikely(trace_ctx_flag == 1)) { char ment[256]; sprintf(ment, "eglMakeCurrent finished (GlueCTX=[%12p] Surf=[D:%12p R:%12p])", ctx, draw, read); _dump_context_info(ment, 0); } -#endif // COREGL_TRACE_CONTEXT_INFO +#endif // COREGL_FASTPATH_TRACE_CONTEXT_INFO return ret; } EGLContext -fpgl_eglGetCurrentContext(void) +fastpath_eglGetCurrentContext(void) { GLGlueContext *ret = NULL; - GLThreadState *tstate = NULL; + MY_MODULE_TSTATE *tstate = NULL; - tstate = get_current_thread_state(); + GET_MY_TSTATE(tstate, get_current_thread_state()); // Special eject condition for binding API if (tstate != NULL && tstate->binded_api != EGL_OPENGL_ES_API) { - return _sym_eglGetCurrentContext(); + return _orig_fastpath_eglGetCurrentContext(); } - _COREGL_FAST_FUNC_BEGIN(); + _COREGL_FASTPATH_FUNC_BEGIN(); if (tstate != NULL) { @@ -1232,28 +1225,26 @@ fpgl_eglGetCurrentContext(void) goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); return (EGLContext)ret; } EGLSurface -fpgl_eglGetCurrentSurface(EGLint readdraw) +fastpath_eglGetCurrentSurface(EGLint readdraw) { EGLSurface ret = EGL_NO_SURFACE; - GLThreadState *tstate = NULL; + MY_MODULE_TSTATE *tstate = NULL; - tstate = get_current_thread_state(); + GET_MY_TSTATE(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); + return _orig_fastpath_eglGetCurrentSurface(readdraw); } - _COREGL_FAST_FUNC_BEGIN(); - - tstate = get_current_thread_state(); + _COREGL_FASTPATH_FUNC_BEGIN(); if (tstate != NULL) { @@ -1270,17 +1261,17 @@ fpgl_eglGetCurrentSurface(EGLint readdraw) goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); return ret; } EGLImageKHR -fpgl_eglCreateImageKHR (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list) +fastpath_eglCreateImageKHR (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list) { void *ret = NULL; EGLContext real_ctx = EGL_NO_CONTEXT; - _COREGL_FAST_FUNC_BEGIN(); + _COREGL_FASTPATH_FUNC_BEGIN(); if (ctx != NULL && ctx != EGL_NO_CONTEXT) { @@ -1296,21 +1287,21 @@ fpgl_eglCreateImageKHR (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClien real_ctx = gctx->cstate->rctx; } } - ret = _sym_eglCreateImageKHR(dpy, real_ctx, target, buffer, attrib_list); + ret = _orig_fastpath_eglCreateImageKHR(dpy, real_ctx, target, buffer, attrib_list); goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); return ret; } _eng_fn -fpgl_eglGetProcAddress(const char* procname) +fastpath_eglGetProcAddress(const char* procname) { _eng_fn ret = NULL; - _COREGL_FAST_FUNC_BEGIN(); + _COREGL_FASTPATH_FUNC_BEGIN(); #define _COREGL_SYMBOL(IS_EXTENSION, RET_TYPE, FUNC_NAME, PARAM_LIST) \ if (strcmp(procname, #FUNC_NAME) == 0) \ @@ -1318,11 +1309,11 @@ fpgl_eglGetProcAddress(const char* procname) ret = (_eng_fn)FUNC_NAME; \ goto finish; \ } -#include "headers/sym_egl.h" -#include "headers/sym_gl.h" +#include "../../headers/sym_egl.h" +#include "../../headers/sym_gl.h" #undef _COREGL_SYMBOL - ret = _sym_eglGetProcAddress(procname); + ret = _orig_fastpath_eglGetProcAddress(procname); if (ret != NULL) { LOG("\E[40;31;1mWARNING : COREGL can't support '%s' (unmanaged situation may occur)\E[0m\n", procname); @@ -1331,18 +1322,18 @@ fpgl_eglGetProcAddress(const char* procname) goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); return ret; } EGLBoolean -fpgl_eglTerminate(EGLDisplay dpy) +fastpath_eglTerminate(EGLDisplay dpy) { EGLBoolean ret = EGL_FALSE; GLGlueContext_List *current = NULL; GLGlueContext_List *remove_list = NULL; - _COREGL_FAST_FUNC_BEGIN(); + _COREGL_FASTPATH_FUNC_BEGIN(); AST(mutex_lock(&ctx_list_access_mutex) == 1); current = gctx_list; @@ -1364,17 +1355,17 @@ fpgl_eglTerminate(EGLDisplay dpy) current = remove_list; while (current != NULL) { - fpgl_eglDestroyContext(dpy, current->gctx); + fastpath_eglDestroyContext(dpy, current->gctx); remove_list = current->next; free(current); current = remove_list; } - ret = _sym_eglTerminate(dpy); + ret = _orig_fastpath_eglTerminate(dpy); goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); return ret; } diff --git a/src/coregl_fastpath_gl.c b/src/modules/fastpath/coregl_fastpath_gl.c similarity index 60% rename from src/coregl_fastpath_gl.c rename to src/modules/fastpath/coregl_fastpath_gl.c index a095ee0..625c7e9 100644 --- a/src/coregl_fastpath_gl.c +++ b/src/modules/fastpath/coregl_fastpath_gl.c @@ -2,22 +2,15 @@ #include -//----------------------------------------------------------------// -// // -// Fastpath GL Functions // -// The functions have prefix 'fpgl_' for (fastpath gl) // -// // -//----------------------------------------------------------------// - #define CURR_STATE_COMPARE(curr_state, state ) \ if ((current_ctx->curr_state[0]) != (state)) -#define DEFINE_FAST_GL_FUNC() \ - GLThreadState *tstate = NULL; \ +#define DEFINE_FASTPAH_GL_FUNC() \ + MY_MODULE_TSTATE *tstate = NULL; \ GLGlueContext *current_ctx = NULL; -#define INIT_FAST_GL_FUNC() \ - tstate = get_current_thread_state(); \ +#define INIT_FASTPATH_GL_FUNC() \ + GET_MY_TSTATE(tstate, get_current_thread_state()); \ if (tstate == NULL || tstate->cstate == NULL) \ { \ ERR("\E[0;31;1mWARNING : '%s' called when GLES2 context is not binded (Check MakeCurrent)!\E[0m\n", __func__); \ @@ -41,7 +34,7 @@ _get_real_obj(GL_Shared_Object_State *sostate, GL_Object_Type type, GLuint glue_ else { AST(sostate != NULL); - *real_handle = sostate_get_object(sostate, type, glue_handle); + *real_handle = fastpath_sostate_get_object(sostate, type, glue_handle); if (*real_handle == 0) return 0; } @@ -58,7 +51,7 @@ _get_glue_obj(GL_Shared_Object_State *sostate, GL_Object_Type type, GLuint real_ else { AST(sostate != NULL); - *glue_handle = sostate_find_object(sostate, type, real_handle); + *glue_handle = fastpath_sostate_find_object(sostate, type, real_handle); if (*glue_handle == 0) return 0; } @@ -69,10 +62,10 @@ static void _set_gl_error(GLenum error) { GLenum glerror = GL_NONE; - DEFINE_FAST_GL_FUNC(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + INIT_FASTPATH_GL_FUNC(); - glerror = _sym_glGetError(); + glerror = _orig_fastpath_glGetError(); if (current_ctx->gl_error == GL_NO_ERROR && glerror == GL_NO_ERROR && @@ -87,13 +80,13 @@ finish: } GLenum -fpgl_glGetError(void) +fastpath_glGetError(void) { GLenum ret = GL_NONE; - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); if (current_ctx->gl_error != GL_NO_ERROR) { @@ -102,27 +95,27 @@ fpgl_glGetError(void) } else { - ret = _sym_glGetError(); + ret = _orig_fastpath_glGetError(); } goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); return ret; } //////////////////////////////////////////////////////////////////////// void -fpgl_glActiveTexture(GLenum texture) +fastpath_glActiveTexture(GLenum texture) { - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); CURR_STATE_COMPARE(gl_active_texture, texture) { - _sym_glActiveTexture(texture); + _orig_fastpath_glActiveTexture(texture); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); @@ -132,19 +125,19 @@ fpgl_glActiveTexture(GLenum texture) goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } void -fpgl_glGenTextures(GLsizei n, GLuint* textures) +fastpath_glGenTextures(GLsizei n, GLuint* textures) { int i; GLuint *objid_array = NULL; - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); if (textures == NULL) goto finish; @@ -152,11 +145,11 @@ fpgl_glGenTextures(GLsizei n, GLuint* textures) objid_array = (GLuint *)calloc(1, sizeof(GLuint) * n); - _sym_glGenTextures(n, objid_array); + _orig_fastpath_glGenTextures(n, objid_array); for (i = 0; i < n; i++) { - textures[i] = sostate_create_object(current_ctx->sostate, GL_OBJECT_TYPE_TEXTURE, objid_array[i]); + textures[i] = fastpath_sostate_create_object(current_ctx->sostate, GL_OBJECT_TYPE_TEXTURE, objid_array[i]); } goto finish; @@ -167,19 +160,19 @@ finish: free(objid_array); objid_array = NULL; } - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } void -fpgl_glBindTexture(GLenum target, GLuint texture) +fastpath_glBindTexture(GLenum target, GLuint texture) { int active_idx; GLuint real_obj; - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); active_idx = current_ctx->gl_active_texture[0] - GL_TEXTURE0; @@ -193,7 +186,7 @@ fpgl_glBindTexture(GLenum target, GLuint texture) { if (current_ctx->gl_tex_2d_state[active_idx] != real_obj) { - _sym_glBindTexture(target, real_obj); + _orig_fastpath_glBindTexture(target, real_obj); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); @@ -206,7 +199,7 @@ fpgl_glBindTexture(GLenum target, GLuint texture) { if (current_ctx->gl_tex_cube_state[active_idx] != real_obj) { - _sym_glBindTexture(target, real_obj); + _orig_fastpath_glBindTexture(target, real_obj); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); @@ -218,18 +211,18 @@ fpgl_glBindTexture(GLenum target, GLuint texture) goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } void -fpgl_glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) +fastpath_glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) { GLuint real_obj; - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); if (GET_REAL_OBJ(GL_OBJECT_TYPE_TEXTURE, texture, &real_obj) != 1) { @@ -237,23 +230,23 @@ fpgl_glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, goto finish; } - _sym_glFramebufferTexture2D(target, attachment, textarget, real_obj, level); + _orig_fastpath_glFramebufferTexture2D(target, attachment, textarget, real_obj, level); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } void -fpgl_glFramebufferTexture2DMultisampleEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples) +fastpath_glFramebufferTexture2DMultisampleEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples) { GLuint real_obj; - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); if (GET_REAL_OBJ(GL_OBJECT_TYPE_TEXTURE, texture, &real_obj) != 1) { @@ -261,24 +254,24 @@ fpgl_glFramebufferTexture2DMultisampleEXT(GLenum target, GLenum attachment, GLen goto finish; } - _sym_glFramebufferTexture2DMultisampleEXT(target, attachment, textarget, real_obj, level, samples); + _orig_fastpath_glFramebufferTexture2DMultisampleEXT(target, attachment, textarget, real_obj, level, samples); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } GLboolean -fpgl_glIsTexture(GLuint texture) +fastpath_glIsTexture(GLuint texture) { GLboolean ret = GL_FALSE; GLuint real_obj; - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); if (GET_REAL_OBJ(GL_OBJECT_TYPE_TEXTURE, texture, &real_obj) != 1) { @@ -286,27 +279,27 @@ fpgl_glIsTexture(GLuint texture) goto finish; } - ret = _sym_glIsTexture(real_obj); + ret = _orig_fastpath_glIsTexture(real_obj); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); return ret; } void -fpgl_glDeleteTextures(GLsizei n, const GLuint* textures) +fastpath_glDeleteTextures(GLsizei n, const GLuint* textures) { int i, j; GLuint *objid_array = NULL; - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); if (textures == NULL) goto finish; @@ -321,14 +314,14 @@ fpgl_glDeleteTextures(GLsizei n, const GLuint* textures) int real_objid = _COREGL_INT_INIT_VALUE; if (textures[i] == 0) continue; - real_objid = sostate_get_object(current_ctx->sostate, GL_OBJECT_TYPE_TEXTURE, textures[i]); + real_objid = fastpath_sostate_get_object(current_ctx->sostate, GL_OBJECT_TYPE_TEXTURE, textures[i]); if (real_objid == 0) continue; - sostate_remove_object(current_ctx->sostate, GL_OBJECT_TYPE_TEXTURE, textures[i]); + fastpath_sostate_remove_object(current_ctx->sostate, GL_OBJECT_TYPE_TEXTURE, textures[i]); objid_array[real_n++] = real_objid; } - _sym_glDeleteTextures(real_n, objid_array); + _orig_fastpath_glDeleteTextures(real_n, objid_array); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); for (i = 0; i < real_n; i++) @@ -351,20 +344,20 @@ finish: free(objid_array); objid_array = NULL; } - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } //////////////////////////////////////////////////////////////////////// void -fpgl_glGenBuffers(GLsizei n, GLuint* buffers) +fastpath_glGenBuffers(GLsizei n, GLuint* buffers) { int i; GLuint *objid_array = NULL; - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); if (buffers == NULL) goto finish; @@ -372,11 +365,11 @@ fpgl_glGenBuffers(GLsizei n, GLuint* buffers) objid_array = (GLuint *)calloc(1, sizeof(GLuint) * n); - _sym_glGenBuffers(n, objid_array); + _orig_fastpath_glGenBuffers(n, objid_array); for (i = 0; i < n; i++) { - buffers[i] = sostate_create_object(current_ctx->sostate, GL_OBJECT_TYPE_BUFFER, objid_array[i]); + buffers[i] = fastpath_sostate_create_object(current_ctx->sostate, GL_OBJECT_TYPE_BUFFER, objid_array[i]); } goto finish; @@ -387,18 +380,18 @@ finish: free(objid_array); objid_array = NULL; } - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } void -fpgl_glBindBuffer(GLenum target, GLuint buffer) +fastpath_glBindBuffer(GLenum target, GLuint buffer) { GLuint real_obj; - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); if (GET_REAL_OBJ(GL_OBJECT_TYPE_BUFFER, buffer, &real_obj) != 1) { @@ -410,7 +403,7 @@ fpgl_glBindBuffer(GLenum target, GLuint buffer) { CURR_STATE_COMPARE(gl_array_buffer_binding, real_obj) { - _sym_glBindBuffer(target, real_obj); + _orig_fastpath_glBindBuffer(target, real_obj); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); @@ -425,7 +418,7 @@ fpgl_glBindBuffer(GLenum target, GLuint buffer) { CURR_STATE_COMPARE(gl_element_array_buffer_binding, real_obj) { - _sym_glBindBuffer(target, real_obj); + _orig_fastpath_glBindBuffer(target, real_obj); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); if (real_obj == 0) @@ -438,24 +431,24 @@ fpgl_glBindBuffer(GLenum target, GLuint buffer) else { // For error recording - _sym_glBindBuffer(target, real_obj); + _orig_fastpath_glBindBuffer(target, real_obj); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); } goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } GLboolean -fpgl_glIsBuffer(GLuint buffer) +fastpath_glIsBuffer(GLuint buffer) { GLboolean ret = GL_FALSE; GLuint real_obj; - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); if (GET_REAL_OBJ(GL_OBJECT_TYPE_BUFFER, buffer, &real_obj) != 1) { @@ -463,27 +456,27 @@ fpgl_glIsBuffer(GLuint buffer) goto finish; } - ret = _sym_glIsBuffer(real_obj); + ret = _orig_fastpath_glIsBuffer(real_obj); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); return ret; } void -fpgl_glDeleteBuffers(GLsizei n, const GLuint* buffers) +fastpath_glDeleteBuffers(GLsizei n, const GLuint* buffers) { int i; GLuint *objid_array = NULL; - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); if (buffers == NULL) goto finish; @@ -498,14 +491,14 @@ fpgl_glDeleteBuffers(GLsizei n, const GLuint* buffers) int real_objid = _COREGL_INT_INIT_VALUE; if (buffers[i] == 0) continue; - real_objid = sostate_get_object(current_ctx->sostate, GL_OBJECT_TYPE_BUFFER, buffers[i]); + real_objid = fastpath_sostate_get_object(current_ctx->sostate, GL_OBJECT_TYPE_BUFFER, buffers[i]); if (real_objid == 0) continue; - sostate_remove_object(current_ctx->sostate, GL_OBJECT_TYPE_BUFFER, buffers[i]); + fastpath_sostate_remove_object(current_ctx->sostate, GL_OBJECT_TYPE_BUFFER, buffers[i]); objid_array[real_n++] = real_objid; } - _sym_glDeleteBuffers(real_n, objid_array); + _orig_fastpath_glDeleteBuffers(real_n, objid_array); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); for (i = 0; i < real_n; i++) @@ -531,20 +524,20 @@ finish: free(objid_array); objid_array = NULL; } - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } ////////////////////////////////////////////////////////////////////////////////// void -fpgl_glGenFramebuffers(GLsizei n, GLuint* framebuffers) +fastpath_glGenFramebuffers(GLsizei n, GLuint* framebuffers) { int i; GLuint *objid_array = NULL; - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); if (framebuffers == NULL) goto finish; @@ -552,11 +545,11 @@ fpgl_glGenFramebuffers(GLsizei n, GLuint* framebuffers) objid_array = (GLuint *)calloc(1, sizeof(GLuint) * n); - _sym_glGenFramebuffers(n, objid_array); + _orig_fastpath_glGenFramebuffers(n, objid_array); for (i = 0; i < n; i++) { - framebuffers[i] = sostate_create_object(current_ctx->sostate, GL_OBJECT_TYPE_FRAMEBUFFER, objid_array[i]); + framebuffers[i] = fastpath_sostate_create_object(current_ctx->sostate, GL_OBJECT_TYPE_FRAMEBUFFER, objid_array[i]); } goto finish; @@ -567,18 +560,18 @@ finish: free(objid_array); objid_array = NULL; } - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } void -fpgl_glBindFramebuffer(GLenum target, GLuint framebuffer) +fastpath_glBindFramebuffer(GLenum target, GLuint framebuffer) { GLuint real_obj; - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); if (GET_REAL_OBJ(GL_OBJECT_TYPE_FRAMEBUFFER, framebuffer, &real_obj) != 1) { @@ -590,7 +583,7 @@ fpgl_glBindFramebuffer(GLenum target, GLuint framebuffer) { CURR_STATE_COMPARE(gl_framebuffer_binding, real_obj) { - _sym_glBindFramebuffer(target, real_obj); + _orig_fastpath_glBindFramebuffer(target, real_obj); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); if (real_obj == 0) @@ -603,25 +596,25 @@ fpgl_glBindFramebuffer(GLenum target, GLuint framebuffer) else { // For error recording - _sym_glBindFramebuffer(target, real_obj); + _orig_fastpath_glBindFramebuffer(target, real_obj); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); } goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } GLboolean -fpgl_glIsFramebuffer(GLuint framebuffer) +fastpath_glIsFramebuffer(GLuint framebuffer) { GLboolean ret = GL_FALSE; GLuint real_obj; - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); if (GET_REAL_OBJ(GL_OBJECT_TYPE_FRAMEBUFFER, framebuffer, &real_obj) != 1) { @@ -629,27 +622,27 @@ fpgl_glIsFramebuffer(GLuint framebuffer) goto finish; } - ret = _sym_glIsFramebuffer(real_obj); + ret = _orig_fastpath_glIsFramebuffer(real_obj); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); return ret; } void -fpgl_glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers) +fastpath_glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers) { int i; GLuint *objid_array = NULL; - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); if (framebuffers == NULL) goto finish; @@ -664,14 +657,14 @@ fpgl_glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers) int real_objid = _COREGL_INT_INIT_VALUE; if (framebuffers[i] == 0) continue; - real_objid = sostate_get_object(current_ctx->sostate, GL_OBJECT_TYPE_FRAMEBUFFER, framebuffers[i]); + real_objid = fastpath_sostate_get_object(current_ctx->sostate, GL_OBJECT_TYPE_FRAMEBUFFER, framebuffers[i]); if (real_objid == 0) continue; - sostate_remove_object(current_ctx->sostate, GL_OBJECT_TYPE_FRAMEBUFFER, framebuffers[i]); + fastpath_sostate_remove_object(current_ctx->sostate, GL_OBJECT_TYPE_FRAMEBUFFER, framebuffers[i]); objid_array[real_n++] = real_objid; } - _sym_glDeleteFramebuffers(real_n, objid_array); + _orig_fastpath_glDeleteFramebuffers(real_n, objid_array); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); for (i = 0; i < real_n; i++) @@ -692,20 +685,20 @@ finish: free(objid_array); objid_array = NULL; } - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } ////////////////////////////////////////////////////////////////////////////////// void -fpgl_glGenRenderbuffers(GLsizei n, GLuint* renderbuffers) +fastpath_glGenRenderbuffers(GLsizei n, GLuint* renderbuffers) { int i; GLuint *objid_array = NULL; - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); if (renderbuffers == NULL) goto finish; @@ -713,11 +706,11 @@ fpgl_glGenRenderbuffers(GLsizei n, GLuint* renderbuffers) objid_array = (GLuint *)calloc(1, sizeof(GLuint) * n); - _sym_glGenRenderbuffers(n, objid_array); + _orig_fastpath_glGenRenderbuffers(n, objid_array); for (i = 0; i < n; i++) { - renderbuffers[i] = sostate_create_object(current_ctx->sostate, GL_OBJECT_TYPE_RENDERBUFFER, objid_array[i]); + renderbuffers[i] = fastpath_sostate_create_object(current_ctx->sostate, GL_OBJECT_TYPE_RENDERBUFFER, objid_array[i]); } goto finish; @@ -728,18 +721,18 @@ finish: free(objid_array); objid_array = NULL; } - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } void -fpgl_glBindRenderbuffer(GLenum target, GLuint renderbuffer) +fastpath_glBindRenderbuffer(GLenum target, GLuint renderbuffer) { GLuint real_obj; - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); if (GET_REAL_OBJ(GL_OBJECT_TYPE_RENDERBUFFER, renderbuffer, &real_obj) != 1) { @@ -751,7 +744,7 @@ fpgl_glBindRenderbuffer(GLenum target, GLuint renderbuffer) { CURR_STATE_COMPARE(gl_renderbuffer_binding, real_obj) { - _sym_glBindRenderbuffer(target, real_obj); + _orig_fastpath_glBindRenderbuffer(target, real_obj); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); if (real_obj == 0) @@ -764,23 +757,23 @@ fpgl_glBindRenderbuffer(GLenum target, GLuint renderbuffer) else { // For error recording - _sym_glBindRenderbuffer(target, real_obj); + _orig_fastpath_glBindRenderbuffer(target, real_obj); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); } goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } void -fpgl_glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) +fastpath_glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) { GLuint real_obj; - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); if (GET_REAL_OBJ(GL_OBJECT_TYPE_RENDERBUFFER, renderbuffer, &real_obj) != 1) { @@ -788,25 +781,25 @@ fpgl_glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbu goto finish; } - _sym_glFramebufferRenderbuffer(target, attachment, renderbuffertarget, real_obj); + _orig_fastpath_glFramebufferRenderbuffer(target, attachment, renderbuffertarget, real_obj); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } GLboolean -fpgl_glIsRenderbuffer(GLuint renderbuffer) +fastpath_glIsRenderbuffer(GLuint renderbuffer) { GLboolean ret = GL_FALSE; GLuint real_obj; - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); if (GET_REAL_OBJ(GL_OBJECT_TYPE_RENDERBUFFER, renderbuffer, &real_obj) != 1) { @@ -814,27 +807,27 @@ fpgl_glIsRenderbuffer(GLuint renderbuffer) goto finish; } - ret = _sym_glIsRenderbuffer(real_obj); + ret = _orig_fastpath_glIsRenderbuffer(real_obj); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); return ret; } void -fpgl_glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers) +fastpath_glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers) { int i; GLuint *objid_array = NULL; - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); if (renderbuffers == NULL) goto finish; @@ -849,14 +842,14 @@ fpgl_glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers) int real_objid = _COREGL_INT_INIT_VALUE; if (renderbuffers[i] == 0) continue; - real_objid = sostate_get_object(current_ctx->sostate, GL_OBJECT_TYPE_RENDERBUFFER, renderbuffers[i]); + real_objid = fastpath_sostate_get_object(current_ctx->sostate, GL_OBJECT_TYPE_RENDERBUFFER, renderbuffers[i]); if (real_objid == 0) continue; - sostate_remove_object(current_ctx->sostate, GL_OBJECT_TYPE_RENDERBUFFER, renderbuffers[i]); + fastpath_sostate_remove_object(current_ctx->sostate, GL_OBJECT_TYPE_RENDERBUFFER, renderbuffers[i]); objid_array[real_n++] = real_objid; } - _sym_glDeleteRenderbuffers(real_n, objid_array); + _orig_fastpath_glDeleteRenderbuffers(real_n, objid_array); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); for (i = 0; i < real_n; i++) @@ -877,90 +870,90 @@ finish: free(objid_array); objid_array = NULL; } - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } ////////////////////////////////////////////////////////////////////////////////// GLuint -fpgl_glCreateProgram(void) +fastpath_glCreateProgram(void) { GLuint ret = _COREGL_INT_INIT_VALUE; GLuint real_obj = _COREGL_INT_INIT_VALUE; - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); AST(current_ctx->sostate != NULL); - real_obj = _sym_glCreateProgram(); + real_obj = _orig_fastpath_glCreateProgram(); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - ret = sostate_create_object(current_ctx->sostate, GL_OBJECT_TYPE_PROGRAM, real_obj); + ret = fastpath_sostate_create_object(current_ctx->sostate, GL_OBJECT_TYPE_PROGRAM, real_obj); goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); return ret; } GLuint -fpgl_glCreateShader(GLenum type) +fastpath_glCreateShader(GLenum type) { GLuint ret = _COREGL_INT_INIT_VALUE; GLuint real_obj = _COREGL_INT_INIT_VALUE; - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); AST(current_ctx->sostate != NULL); - real_obj = _sym_glCreateShader(type); + real_obj = _orig_fastpath_glCreateShader(type); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - ret = sostate_create_object(current_ctx->sostate, GL_OBJECT_TYPE_PROGRAM, real_obj); + ret = fastpath_sostate_create_object(current_ctx->sostate, GL_OBJECT_TYPE_PROGRAM, real_obj); goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); return ret; } void -fpgl_glShaderSource(GLuint shader, GLsizei count, const char** string, const GLint* length) +fastpath_glShaderSource(GLuint shader, GLsizei count, const char** string, const GLint* length) { GLuint real_obj; - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, shader, &real_obj) != 1) { _set_gl_error(GL_INVALID_VALUE); goto finish; } - _sym_glShaderSource(real_obj, count, string, length); + _orig_fastpath_glShaderSource(real_obj, count, string, length); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } void -fpgl_glShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLsizei length) +fastpath_glShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLsizei length) { int i; GLuint *objid_array = NULL; - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); if (shaders == NULL) goto finish; @@ -971,19 +964,11 @@ fpgl_glShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const for (i = 0; i < n; i++) { if (shaders[i] == 0) continue; - objid_array[i] = sostate_get_object(current_ctx->sostate, GL_OBJECT_TYPE_PROGRAM, shaders[i]); + objid_array[i] = fastpath_sostate_get_object(current_ctx->sostate, GL_OBJECT_TYPE_PROGRAM, shaders[i]); } -#ifndef _COREGL_DESKTOP_GL - _sym_glShaderBinary(n, objid_array, binaryformat, binary, length); + _orig_fastpath_glShaderBinary(n, objid_array, binaryformat, binary, length); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); -#else -// FIXME: need to dlsym/getprocaddress for this - /* - n = binaryformat = length = 0; - shaders = binary = 0; - */ -#endif goto finish; finish: @@ -993,17 +978,17 @@ finish: objid_array = NULL; } - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } void -fpgl_glCompileShader(GLuint shader) +fastpath_glCompileShader(GLuint shader) { GLuint real_obj; - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, shader, &real_obj) != 1) { @@ -1011,22 +996,22 @@ fpgl_glCompileShader(GLuint shader) goto finish; } - _sym_glCompileShader(real_obj); + _orig_fastpath_glCompileShader(real_obj); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } void -fpgl_glBindAttribLocation(GLuint program, GLuint index, const char* name) +fastpath_glBindAttribLocation(GLuint program, GLuint index, const char* name) { GLuint real_obj; - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) { @@ -1034,23 +1019,23 @@ fpgl_glBindAttribLocation(GLuint program, GLuint index, const char* name) goto finish; } - _sym_glBindAttribLocation(real_obj, index, name); + _orig_fastpath_glBindAttribLocation(real_obj, index, name); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } void -fpgl_glAttachShader(GLuint program, GLuint shader) +fastpath_glAttachShader(GLuint program, GLuint shader) { GLuint real_obj_program; GLuint real_obj_shader; - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj_program) != 1 || GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, shader, &real_obj_shader) != 1) @@ -1059,23 +1044,23 @@ fpgl_glAttachShader(GLuint program, GLuint shader) goto finish; } - _sym_glAttachShader(real_obj_program, real_obj_shader); + _orig_fastpath_glAttachShader(real_obj_program, real_obj_shader); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } void -fpgl_glDetachShader(GLuint program, GLuint shader) +fastpath_glDetachShader(GLuint program, GLuint shader) { GLuint real_obj_program; GLuint real_obj_shader; - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj_program) != 1 || GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, shader, &real_obj_shader) != 1) @@ -1084,23 +1069,23 @@ fpgl_glDetachShader(GLuint program, GLuint shader) goto finish; } - _sym_glDetachShader(real_obj_program, real_obj_shader); + _orig_fastpath_glDetachShader(real_obj_program, real_obj_shader); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } GLboolean -fpgl_glIsShader(GLuint shader) +fastpath_glIsShader(GLuint shader) { GLboolean ret = GL_FALSE; GLuint real_obj; - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, shader, &real_obj) != 1) { @@ -1108,24 +1093,24 @@ fpgl_glIsShader(GLuint shader) goto finish; } - ret = _sym_glIsShader(real_obj); + ret = _orig_fastpath_glIsShader(real_obj); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); return ret; } GLboolean -fpgl_glIsProgram(GLuint program) +fastpath_glIsProgram(GLuint program) { GLboolean ret = GL_FALSE; GLuint real_obj; - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) { @@ -1133,23 +1118,23 @@ fpgl_glIsProgram(GLuint program) goto finish; } - ret = _sym_glIsProgram(real_obj); + ret = _orig_fastpath_glIsProgram(real_obj); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); return ret; } void -fpgl_glLinkProgram(GLuint program) +fastpath_glLinkProgram(GLuint program) { GLuint real_obj; - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) { @@ -1157,22 +1142,22 @@ fpgl_glLinkProgram(GLuint program) goto finish; } - _sym_glLinkProgram(real_obj); + _orig_fastpath_glLinkProgram(real_obj); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } void -fpgl_glValidateProgram(GLuint program) +fastpath_glValidateProgram(GLuint program) { GLuint real_obj; - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) { @@ -1180,22 +1165,22 @@ fpgl_glValidateProgram(GLuint program) goto finish; } - _sym_glValidateProgram(real_obj); + _orig_fastpath_glValidateProgram(real_obj); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } void -fpgl_glUseProgram(GLuint program) +fastpath_glUseProgram(GLuint program) { GLuint real_obj; - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) { @@ -1205,7 +1190,7 @@ fpgl_glUseProgram(GLuint program) CURR_STATE_COMPARE(gl_current_program, real_obj) { - _sym_glUseProgram(real_obj); + _orig_fastpath_glUseProgram(real_obj); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); @@ -1215,17 +1200,17 @@ fpgl_glUseProgram(GLuint program) goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } void -fpgl_glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name) +fastpath_glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name) { GLuint real_obj; - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) { @@ -1233,22 +1218,22 @@ fpgl_glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei* l goto finish; } - _sym_glGetActiveAttrib(real_obj, index, bufsize, length, size, type, name); + _orig_fastpath_glGetActiveAttrib(real_obj, index, bufsize, length, size, type, name); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } void -fpgl_glGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name) +fastpath_glGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name) { GLuint real_obj; - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) { @@ -1256,24 +1241,24 @@ fpgl_glGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* goto finish; } - _sym_glGetActiveUniform(real_obj, index, bufsize, length, size, type, name); + _orig_fastpath_glGetActiveUniform(real_obj, index, bufsize, length, size, type, name); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } void -fpgl_glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders) +fastpath_glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders) { int i; GLsizei real_count = _COREGL_INT_INIT_VALUE; GLuint real_obj; - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) { @@ -1281,12 +1266,12 @@ fpgl_glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLui goto finish; } - _sym_glGetAttachedShaders(real_obj, maxcount, &real_count, shaders); + _orig_fastpath_glGetAttachedShaders(real_obj, maxcount, &real_count, shaders); for (i = 0; i < real_count; i++) { if (shaders[i] != 0) - shaders[i] = sostate_find_object(current_ctx->sostate, GL_OBJECT_TYPE_PROGRAM, shaders[i]); + shaders[i] = fastpath_sostate_find_object(current_ctx->sostate, GL_OBJECT_TYPE_PROGRAM, shaders[i]); } if (count != NULL) *count = real_count; @@ -1294,18 +1279,18 @@ fpgl_glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLui goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } int -fpgl_glGetAttribLocation(GLuint program, const char* name) +fastpath_glGetAttribLocation(GLuint program, const char* name) { int ret = _COREGL_INT_INIT_VALUE; GLuint real_obj; - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) { @@ -1313,23 +1298,23 @@ fpgl_glGetAttribLocation(GLuint program, const char* name) goto finish; } - ret = _sym_glGetAttribLocation(real_obj, name); + ret = _orig_fastpath_glGetAttribLocation(real_obj, name); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); return ret; } void -fpgl_glGetShaderiv(GLuint shader, GLenum pname, GLint* params) +fastpath_glGetShaderiv(GLuint shader, GLenum pname, GLint* params) { GLuint real_obj; - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, shader, &real_obj) != 1) { @@ -1337,22 +1322,22 @@ fpgl_glGetShaderiv(GLuint shader, GLenum pname, GLint* params) goto finish; } - _sym_glGetShaderiv(real_obj, pname, params); + _orig_fastpath_glGetShaderiv(real_obj, pname, params); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } void -fpgl_glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog) +fastpath_glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog) { GLuint real_obj; - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, shader, &real_obj) != 1) { @@ -1360,22 +1345,22 @@ fpgl_glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, char* i goto finish; } - _sym_glGetShaderInfoLog(real_obj, bufsize, length, infolog); + _orig_fastpath_glGetShaderInfoLog(real_obj, bufsize, length, infolog); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } void -fpgl_glGetProgramiv(GLuint program, GLenum pname, GLint* params) +fastpath_glGetProgramiv(GLuint program, GLenum pname, GLint* params) { GLuint real_obj; - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) { @@ -1383,22 +1368,22 @@ fpgl_glGetProgramiv(GLuint program, GLenum pname, GLint* params) goto finish; } - _sym_glGetProgramiv(real_obj, pname, params); + _orig_fastpath_glGetProgramiv(real_obj, pname, params); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } void -fpgl_glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, char* infolog) +fastpath_glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, char* infolog) { GLuint real_obj; - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) { @@ -1406,22 +1391,22 @@ fpgl_glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, char* goto finish; } - _sym_glGetProgramInfoLog(real_obj, bufsize, length, infolog); + _orig_fastpath_glGetProgramInfoLog(real_obj, bufsize, length, infolog); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } void -fpgl_glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, char* source) +fastpath_glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, char* source) { GLuint real_obj; - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, shader, &real_obj) != 1) { @@ -1429,22 +1414,22 @@ fpgl_glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, char* so goto finish; } - _sym_glGetShaderSource(real_obj, bufsize, length, source); + _orig_fastpath_glGetShaderSource(real_obj, bufsize, length, source); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } void -fpgl_glGetUniformfv(GLuint program, GLint location, GLfloat* params) +fastpath_glGetUniformfv(GLuint program, GLint location, GLfloat* params) { GLuint real_obj; - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) { @@ -1452,22 +1437,22 @@ fpgl_glGetUniformfv(GLuint program, GLint location, GLfloat* params) goto finish; } - _sym_glGetUniformfv(real_obj, location, params); + _orig_fastpath_glGetUniformfv(real_obj, location, params); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } void -fpgl_glGetUniformiv(GLuint program, GLint location, GLint* params) +fastpath_glGetUniformiv(GLuint program, GLint location, GLint* params) { GLuint real_obj; - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) { @@ -1475,22 +1460,22 @@ fpgl_glGetUniformiv(GLuint program, GLint location, GLint* params) goto finish; } - _sym_glGetUniformiv(real_obj, location, params); + _orig_fastpath_glGetUniformiv(real_obj, location, params); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } void -fpgl_glGetProgramBinary(GLuint program, GLsizei bufsize, GLsizei* length, GLenum* binaryFormat, void* binary) +fastpath_glGetProgramBinary(GLuint program, GLsizei bufsize, GLsizei* length, GLenum* binaryFormat, void* binary) { GLuint real_obj; - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) { @@ -1498,22 +1483,22 @@ fpgl_glGetProgramBinary(GLuint program, GLsizei bufsize, GLsizei* length, GLenum goto finish; } - _sym_glGetProgramBinary(real_obj, bufsize, length, binaryFormat, binary); + _orig_fastpath_glGetProgramBinary(real_obj, bufsize, length, binaryFormat, binary); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } void -fpgl_glProgramBinary(GLuint program, GLenum binaryFormat, const void* binary, GLint length) +fastpath_glProgramBinary(GLuint program, GLenum binaryFormat, const void* binary, GLint length) { GLuint real_obj; - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) { @@ -1521,23 +1506,23 @@ fpgl_glProgramBinary(GLuint program, GLenum binaryFormat, const void* binary, GL goto finish; } - _sym_glProgramBinary(real_obj, binaryFormat, binary, length); + _orig_fastpath_glProgramBinary(real_obj, binaryFormat, binary, length); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } void -fpgl_glProgramParameteri(GLuint program, GLuint pname, GLint value) +fastpath_glProgramParameteri(GLuint program, GLuint pname, GLint value) { GLuint real_obj; - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) { @@ -1545,23 +1530,23 @@ fpgl_glProgramParameteri(GLuint program, GLuint pname, GLint value) goto finish; } - _sym_glProgramParameteri(real_obj, pname, value); + _orig_fastpath_glProgramParameteri(real_obj, pname, value); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } int -fpgl_glGetUniformLocation(GLuint program, const char* name) +fastpath_glGetUniformLocation(GLuint program, const char* name) { int ret = _COREGL_INT_INIT_VALUE; GLuint real_obj; - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) { @@ -1570,23 +1555,23 @@ fpgl_glGetUniformLocation(GLuint program, const char* name) goto finish; } - ret = _sym_glGetUniformLocation(real_obj, name); + ret = _orig_fastpath_glGetUniformLocation(real_obj, name); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); return ret; } void -fpgl_glDeleteShader(GLuint shader) +fastpath_glDeleteShader(GLuint shader) { GLuint real_obj; - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, shader, &real_obj) != 1) { @@ -1594,27 +1579,27 @@ fpgl_glDeleteShader(GLuint shader) goto finish; } - _sym_glDeleteShader(real_obj); + _orig_fastpath_glDeleteShader(real_obj); if (real_obj != 0) { - AST(sostate_remove_object(current_ctx->sostate, GL_OBJECT_TYPE_PROGRAM, shader) == 1); + AST(fastpath_sostate_remove_object(current_ctx->sostate, GL_OBJECT_TYPE_PROGRAM, shader) == 1); } GLERR(__FUNCTION__, __FILE__, __LINE__, ""); goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } void -fpgl_glDeleteProgram(GLuint program) +fastpath_glDeleteProgram(GLuint program) { GLuint real_obj; - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) { @@ -1622,17 +1607,17 @@ fpgl_glDeleteProgram(GLuint program) goto finish; } - _sym_glDeleteProgram(real_obj); + _orig_fastpath_glDeleteProgram(real_obj); if (real_obj != 0) { - AST(sostate_remove_object(current_ctx->sostate, GL_OBJECT_TYPE_PROGRAM, program) == 1); + AST(fastpath_sostate_remove_object(current_ctx->sostate, GL_OBJECT_TYPE_PROGRAM, program) == 1); } GLERR(__FUNCTION__, __FILE__, __LINE__, ""); goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } @@ -1640,18 +1625,18 @@ finish: ////////////////////////////////////////////////////////////////////////////////// void -fpgl_glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) +fastpath_glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) { - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); if ((current_ctx->gl_blend_color[0] != red) || (current_ctx->gl_blend_color[1] != green) || (current_ctx->gl_blend_color[2] != blue) || (current_ctx->gl_blend_color[3] != alpha)) { - _sym_glBlendColor(red, green, blue, alpha); + _orig_fastpath_glBlendColor(red, green, blue, alpha); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); @@ -1664,43 +1649,43 @@ fpgl_glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } //!!! Optimze? void -fpgl_glBlendEquation(GLenum mode) +fastpath_glBlendEquation(GLenum mode) { - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); - _sym_glBlendEquation(mode); + _orig_fastpath_glBlendEquation(mode); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); current_ctx->_blend_flag |= (FLAG_BIT_5 | FLAG_BIT_6); - _sym_glGetIntegerv(GL_BLEND_EQUATION_RGB, (GLint*) & (current_ctx->gl_blend_equation_rgb)); - _sym_glGetIntegerv(GL_BLEND_EQUATION_ALPHA, (GLint*) & (current_ctx->gl_blend_equation_alpha)); + _orig_fastpath_glGetIntegerv(GL_BLEND_EQUATION_RGB, (GLint*) & (current_ctx->gl_blend_equation_rgb)); + _orig_fastpath_glGetIntegerv(GL_BLEND_EQUATION_ALPHA, (GLint*) & (current_ctx->gl_blend_equation_alpha)); goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } void -fpgl_glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha) +fastpath_glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha) { - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); if ((current_ctx->gl_blend_equation_rgb[0] != modeRGB) || (current_ctx->gl_blend_equation_alpha[0] != modeAlpha)) { - _sym_glBlendEquationSeparate(modeRGB, modeAlpha); + _orig_fastpath_glBlendEquationSeparate(modeRGB, modeAlpha); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); @@ -1711,47 +1696,47 @@ fpgl_glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha) goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } //!!! Optimze? void -fpgl_glBlendFunc(GLenum sfactor, GLenum dfactor) +fastpath_glBlendFunc(GLenum sfactor, GLenum dfactor) { - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); - _sym_glBlendFunc(sfactor, dfactor); + _orig_fastpath_glBlendFunc(sfactor, dfactor); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); current_ctx->_blend_flag |= (FLAG_BIT_1 | FLAG_BIT_2 | FLAG_BIT_3 | FLAG_BIT_4); - _sym_glGetIntegerv(GL_BLEND_SRC_RGB, (GLint*) & (current_ctx->gl_blend_src_rgb)); - _sym_glGetIntegerv(GL_BLEND_SRC_ALPHA, (GLint*) & (current_ctx->gl_blend_src_alpha)); - _sym_glGetIntegerv(GL_BLEND_DST_RGB, (GLint*) & (current_ctx->gl_blend_dst_rgb)); - _sym_glGetIntegerv(GL_BLEND_DST_ALPHA, (GLint*) & (current_ctx->gl_blend_dst_alpha)); + _orig_fastpath_glGetIntegerv(GL_BLEND_SRC_RGB, (GLint*) & (current_ctx->gl_blend_src_rgb)); + _orig_fastpath_glGetIntegerv(GL_BLEND_SRC_ALPHA, (GLint*) & (current_ctx->gl_blend_src_alpha)); + _orig_fastpath_glGetIntegerv(GL_BLEND_DST_RGB, (GLint*) & (current_ctx->gl_blend_dst_rgb)); + _orig_fastpath_glGetIntegerv(GL_BLEND_DST_ALPHA, (GLint*) & (current_ctx->gl_blend_dst_alpha)); goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } void -fpgl_glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) +fastpath_glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) { - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); if ((current_ctx->gl_blend_src_rgb[0] != srcRGB) || (current_ctx->gl_blend_dst_rgb[0] != dstRGB) || (current_ctx->gl_blend_src_alpha[0] != srcAlpha) || (current_ctx->gl_blend_dst_alpha[0] != dstAlpha)) { - _sym_glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha); + _orig_fastpath_glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); @@ -1764,23 +1749,23 @@ fpgl_glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum d goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } void -fpgl_glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) +fastpath_glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) { - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); if ((current_ctx->gl_color_clear_value[0] != red) || (current_ctx->gl_color_clear_value[1] != green) || (current_ctx->gl_color_clear_value[2] != blue) || (current_ctx->gl_color_clear_value[3] != alpha)) { - _sym_glClearColor(red, green, blue, alpha); + _orig_fastpath_glClearColor(red, green, blue, alpha); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); @@ -1793,20 +1778,20 @@ fpgl_glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } void -fpgl_glClearDepthf(GLclampf depth) +fastpath_glClearDepthf(GLclampf depth) { - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); CURR_STATE_COMPARE(gl_depth_clear_value, depth) { - _sym_glClearDepthf(depth); + _orig_fastpath_glClearDepthf(depth); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); @@ -1816,20 +1801,20 @@ fpgl_glClearDepthf(GLclampf depth) goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } void -fpgl_glClearStencil(GLint s) +fastpath_glClearStencil(GLint s) { - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); CURR_STATE_COMPARE(gl_stencil_clear_value, s) { - _sym_glClearStencil(s); + _orig_fastpath_glClearStencil(s); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); @@ -1839,23 +1824,23 @@ fpgl_glClearStencil(GLint s) goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } void -fpgl_glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) +fastpath_glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) { - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); if ((current_ctx->gl_color_writemask[0] != red) || (current_ctx->gl_color_writemask[1] != green) || (current_ctx->gl_color_writemask[2] != blue) || (current_ctx->gl_color_writemask[3] != alpha)) { - _sym_glColorMask(red, green, blue, alpha); + _orig_fastpath_glColorMask(red, green, blue, alpha); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); @@ -1868,20 +1853,20 @@ fpgl_glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } void -fpgl_glCullFace(GLenum mode) +fastpath_glCullFace(GLenum mode) { - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); CURR_STATE_COMPARE(gl_cull_face_mode, mode) { - _sym_glCullFace(mode); + _orig_fastpath_glCullFace(mode); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); @@ -1891,20 +1876,20 @@ fpgl_glCullFace(GLenum mode) goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } void -fpgl_glDepthFunc(GLenum func) +fastpath_glDepthFunc(GLenum func) { - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); CURR_STATE_COMPARE(gl_depth_func, func) { - _sym_glDepthFunc(func); + _orig_fastpath_glDepthFunc(func); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); @@ -1914,20 +1899,20 @@ fpgl_glDepthFunc(GLenum func) goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } void -fpgl_glDepthMask(GLboolean flag) +fastpath_glDepthMask(GLboolean flag) { - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); CURR_STATE_COMPARE(gl_depth_writemask, flag) { - _sym_glDepthMask(flag); + _orig_fastpath_glDepthMask(flag); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); @@ -1937,21 +1922,21 @@ fpgl_glDepthMask(GLboolean flag) goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } void -fpgl_glDepthRangef(GLclampf zNear, GLclampf zFar) +fastpath_glDepthRangef(GLclampf zNear, GLclampf zFar) { - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); if ((current_ctx->gl_depth_range[0] != zNear) || (current_ctx->gl_depth_range[1] != zFar)) { - _sym_glDepthRangef(zNear, zFar); + _orig_fastpath_glDepthRangef(zNear, zFar); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); @@ -1962,23 +1947,23 @@ fpgl_glDepthRangef(GLclampf zNear, GLclampf zFar) goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } void -fpgl_glDisable(GLenum cap) +fastpath_glDisable(GLenum cap) { - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); switch (cap) { case GL_BLEND: CURR_STATE_COMPARE(gl_blend, GL_FALSE) { - _sym_glDisable(cap); + _orig_fastpath_glDisable(cap); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); current_ctx->_enable_flag1 &= (~FLAG_BIT_0); current_ctx->gl_blend[0] = GL_FALSE; @@ -1987,7 +1972,7 @@ fpgl_glDisable(GLenum cap) case GL_CULL_FACE: CURR_STATE_COMPARE(gl_cull_face, GL_FALSE) { - _sym_glDisable(cap); + _orig_fastpath_glDisable(cap); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); current_ctx->_enable_flag1 &= (~FLAG_BIT_1); current_ctx->gl_cull_face[0] = GL_FALSE; @@ -1996,7 +1981,7 @@ fpgl_glDisable(GLenum cap) case GL_DEPTH_TEST: CURR_STATE_COMPARE(gl_depth_test, GL_FALSE) { - _sym_glDisable(cap); + _orig_fastpath_glDisable(cap); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); current_ctx->_enable_flag1 &= (~FLAG_BIT_2); current_ctx->gl_depth_test[0] = GL_FALSE; @@ -2005,7 +1990,7 @@ fpgl_glDisable(GLenum cap) case GL_DITHER: CURR_STATE_COMPARE(gl_dither, GL_FALSE) { - _sym_glDisable(cap); + _orig_fastpath_glDisable(cap); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); current_ctx->_enable_flag1 &= (~FLAG_BIT_3); current_ctx->gl_dither[0] = GL_FALSE; @@ -2014,7 +1999,7 @@ fpgl_glDisable(GLenum cap) case GL_POLYGON_OFFSET_FILL: CURR_STATE_COMPARE(gl_polygon_offset_fill, GL_FALSE) { - _sym_glDisable(cap); + _orig_fastpath_glDisable(cap); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); current_ctx->_enable_flag2 &= (~FLAG_BIT_0); current_ctx->gl_polygon_offset_fill[0] = GL_FALSE; @@ -2023,7 +2008,7 @@ fpgl_glDisable(GLenum cap) case GL_SAMPLE_ALPHA_TO_COVERAGE: CURR_STATE_COMPARE(gl_sample_alpha_to_coverage, GL_FALSE) { - _sym_glDisable(cap); + _orig_fastpath_glDisable(cap); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); current_ctx->_enable_flag2 &= (~FLAG_BIT_1); current_ctx->gl_sample_alpha_to_coverage[0] = GL_FALSE; @@ -2032,7 +2017,7 @@ fpgl_glDisable(GLenum cap) case GL_SAMPLE_COVERAGE: CURR_STATE_COMPARE(gl_sample_coverage, GL_FALSE) { - _sym_glDisable(cap); + _orig_fastpath_glDisable(cap); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); current_ctx->_enable_flag2 &= (~FLAG_BIT_2); current_ctx->gl_sample_coverage[0] = GL_FALSE; @@ -2041,7 +2026,7 @@ fpgl_glDisable(GLenum cap) case GL_SCISSOR_TEST: CURR_STATE_COMPARE(gl_scissor_test, GL_FALSE) { - _sym_glDisable(cap); + _orig_fastpath_glDisable(cap); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); current_ctx->_enable_flag2 &= (~FLAG_BIT_3); current_ctx->gl_scissor_test[0] = GL_FALSE; @@ -2050,7 +2035,7 @@ fpgl_glDisable(GLenum cap) case GL_STENCIL_TEST: CURR_STATE_COMPARE(gl_stencil_test, GL_FALSE) { - _sym_glDisable(cap); + _orig_fastpath_glDisable(cap); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); current_ctx->_enable_flag2 &= (~FLAG_BIT_4); current_ctx->gl_stencil_test[0] = GL_FALSE; @@ -2060,18 +2045,18 @@ fpgl_glDisable(GLenum cap) goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } void -fpgl_glDisableVertexAttribArray(GLuint index) +fastpath_glDisableVertexAttribArray(GLuint index) { - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); - _sym_glDisableVertexAttribArray(index); + _orig_fastpath_glDisableVertexAttribArray(index); current_ctx->_vattrib_flag |= FLAG_BIT_1; current_ctx->gl_vertex_array_enabled[index] = GL_FALSE; @@ -2079,53 +2064,53 @@ fpgl_glDisableVertexAttribArray(GLuint index) goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } void -fpgl_glDrawArrays(GLenum mode, GLint first, GLsizei count) +fastpath_glDrawArrays(GLenum mode, GLint first, GLsizei count) { - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); - _sym_glDrawArrays(mode, first, count); + _orig_fastpath_glDrawArrays(mode, first, count); goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } void -fpgl_glDrawElements(GLenum mode, GLsizei count, GLenum type, const void* indices) +fastpath_glDrawElements(GLenum mode, GLsizei count, GLenum type, const void* indices) { - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); - _sym_glDrawElements(mode, count, type, indices); + _orig_fastpath_glDrawElements(mode, count, type, indices); goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } void -fpgl_glEnable(GLenum cap) +fastpath_glEnable(GLenum cap) { - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); switch (cap) { case GL_BLEND: CURR_STATE_COMPARE(gl_blend, GL_TRUE) { - _sym_glEnable(cap); + _orig_fastpath_glEnable(cap); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); current_ctx->_enable_flag1 |= FLAG_BIT_0; @@ -2135,7 +2120,7 @@ fpgl_glEnable(GLenum cap) case GL_CULL_FACE: CURR_STATE_COMPARE(gl_cull_face, GL_TRUE) { - _sym_glEnable(cap); + _orig_fastpath_glEnable(cap); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); @@ -2146,7 +2131,7 @@ fpgl_glEnable(GLenum cap) case GL_DEPTH_TEST: CURR_STATE_COMPARE(gl_depth_test, GL_TRUE) { - _sym_glEnable(cap); + _orig_fastpath_glEnable(cap); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); @@ -2157,7 +2142,7 @@ fpgl_glEnable(GLenum cap) case GL_DITHER: CURR_STATE_COMPARE(gl_dither, GL_TRUE) { - _sym_glEnable(cap); + _orig_fastpath_glEnable(cap); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); @@ -2168,7 +2153,7 @@ fpgl_glEnable(GLenum cap) case GL_POLYGON_OFFSET_FILL: CURR_STATE_COMPARE(gl_polygon_offset_fill, GL_TRUE) { - _sym_glEnable(cap); + _orig_fastpath_glEnable(cap); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); @@ -2179,7 +2164,7 @@ fpgl_glEnable(GLenum cap) case GL_SAMPLE_ALPHA_TO_COVERAGE: CURR_STATE_COMPARE(gl_sample_alpha_to_coverage, GL_TRUE) { - _sym_glEnable(cap); + _orig_fastpath_glEnable(cap); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); @@ -2190,7 +2175,7 @@ fpgl_glEnable(GLenum cap) case GL_SAMPLE_COVERAGE: CURR_STATE_COMPARE(gl_sample_coverage, GL_TRUE) { - _sym_glEnable(cap); + _orig_fastpath_glEnable(cap); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); @@ -2201,7 +2186,7 @@ fpgl_glEnable(GLenum cap) case GL_SCISSOR_TEST: CURR_STATE_COMPARE(gl_scissor_test, GL_TRUE) { - _sym_glEnable(cap); + _orig_fastpath_glEnable(cap); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); @@ -2212,7 +2197,7 @@ fpgl_glEnable(GLenum cap) case GL_STENCIL_TEST: CURR_STATE_COMPARE(gl_stencil_test, GL_TRUE) { - _sym_glEnable(cap); + _orig_fastpath_glEnable(cap); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); @@ -2224,19 +2209,19 @@ fpgl_glEnable(GLenum cap) goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } // Optimze? void -fpgl_glEnableVertexAttribArray(GLuint index) +fastpath_glEnableVertexAttribArray(GLuint index) { - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); - _sym_glEnableVertexAttribArray(index); + _orig_fastpath_glEnableVertexAttribArray(index); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); @@ -2246,20 +2231,20 @@ fpgl_glEnableVertexAttribArray(GLuint index) goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } void -fpgl_glFrontFace(GLenum mode) +fastpath_glFrontFace(GLenum mode) { - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); CURR_STATE_COMPARE(gl_front_face, mode) { - _sym_glFrontFace(mode); + _orig_fastpath_glFrontFace(mode); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); @@ -2269,74 +2254,74 @@ fpgl_glFrontFace(GLenum mode) goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } void -fpgl_glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params) +fastpath_glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params) { - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); - _sym_glGetVertexAttribfv(index, pname, params); + _orig_fastpath_glGetVertexAttribfv(index, pname, params); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } void -fpgl_glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params) +fastpath_glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params) { - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); - _sym_glGetVertexAttribiv(index, pname, params); + _orig_fastpath_glGetVertexAttribiv(index, pname, params); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } void -fpgl_glGetVertexAttribPointerv(GLuint index, GLenum pname, void** pointer) +fastpath_glGetVertexAttribPointerv(GLuint index, GLenum pname, void** pointer) { - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); - _sym_glGetVertexAttribPointerv(index, pname, pointer); + _orig_fastpath_glGetVertexAttribPointerv(index, pname, pointer); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } // Fix Maybe? void -fpgl_glHint(GLenum target, GLenum mode) +fastpath_glHint(GLenum target, GLenum mode) { - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); if (target == GL_GENERATE_MIPMAP_HINT) { CURR_STATE_COMPARE(gl_generate_mipmap_hint, mode) { - _sym_glHint(target, mode); + _orig_fastpath_glHint(target, mode); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); @@ -2347,26 +2332,26 @@ fpgl_glHint(GLenum target, GLenum mode) else { // For GL Error to be picked up - _sym_glHint(target, mode); + _orig_fastpath_glHint(target, mode); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); } goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } void -fpgl_glLineWidth(GLfloat width) +fastpath_glLineWidth(GLfloat width) { - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); CURR_STATE_COMPARE(gl_line_width, width) { - _sym_glLineWidth(width); + _orig_fastpath_glLineWidth(width); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); @@ -2376,22 +2361,22 @@ fpgl_glLineWidth(GLfloat width) goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } void -fpgl_glPixelStorei(GLenum pname, GLint param) +fastpath_glPixelStorei(GLenum pname, GLint param) { - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); if (pname == GL_PACK_ALIGNMENT) { CURR_STATE_COMPARE(gl_pack_alignment, param) { - _sym_glPixelStorei(pname, param); + _orig_fastpath_glPixelStorei(pname, param); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); @@ -2403,7 +2388,7 @@ fpgl_glPixelStorei(GLenum pname, GLint param) { CURR_STATE_COMPARE(gl_unpack_alignment, param) { - _sym_glPixelStorei(pname, param); + _orig_fastpath_glPixelStorei(pname, param); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); @@ -2414,27 +2399,27 @@ fpgl_glPixelStorei(GLenum pname, GLint param) else { // For GL Error to be picked up - _sym_glPixelStorei(pname, param); + _orig_fastpath_glPixelStorei(pname, param); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); } goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } void -fpgl_glPolygonOffset(GLfloat factor, GLfloat units) +fastpath_glPolygonOffset(GLfloat factor, GLfloat units) { - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); if ((current_ctx->gl_polygon_offset_factor[0] != factor) || (current_ctx->gl_polygon_offset_units[0] != units)) { - _sym_glPolygonOffset(factor, units); + _orig_fastpath_glPolygonOffset(factor, units); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); @@ -2445,21 +2430,21 @@ fpgl_glPolygonOffset(GLfloat factor, GLfloat units) goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } void -fpgl_glSampleCoverage(GLclampf value, GLboolean invert) +fastpath_glSampleCoverage(GLclampf value, GLboolean invert) { - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); if ((current_ctx->gl_sample_coverage_value[0] != value) || (current_ctx->gl_sample_coverage_invert[0] != invert)) { - _sym_glSampleCoverage(value, invert); + _orig_fastpath_glSampleCoverage(value, invert); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); @@ -2470,23 +2455,23 @@ fpgl_glSampleCoverage(GLclampf value, GLboolean invert) goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } void -fpgl_glScissor(GLint x, GLint y, GLsizei width, GLsizei height) +fastpath_glScissor(GLint x, GLint y, GLsizei width, GLsizei height) { - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); if ((current_ctx->gl_scissor_box[0] != x) || (current_ctx->gl_scissor_box[1] != y) || (current_ctx->gl_scissor_box[2] != width) || (current_ctx->gl_scissor_box[3] != height)) { - _sym_glScissor(x, y, width, height); + _orig_fastpath_glScissor(x, y, width, height); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); @@ -2499,16 +2484,16 @@ fpgl_glScissor(GLint x, GLint y, GLsizei width, GLsizei height) goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } void -fpgl_glStencilFunc(GLenum func, GLint ref, GLuint mask) +fastpath_glStencilFunc(GLenum func, GLint ref, GLuint mask) { - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); if ((current_ctx->gl_stencil_func[0] != func) || (current_ctx->gl_stencil_ref[0] != ref) || @@ -2517,7 +2502,7 @@ fpgl_glStencilFunc(GLenum func, GLint ref, GLuint mask) (current_ctx->gl_stencil_back_ref[0] != ref) || (current_ctx->gl_stencil_back_value_mask[0] != mask)) { - _sym_glStencilFunc(func, ref, mask); + _orig_fastpath_glStencilFunc(func, ref, mask); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); @@ -2534,16 +2519,16 @@ fpgl_glStencilFunc(GLenum func, GLint ref, GLuint mask) goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } void -fpgl_glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask) +fastpath_glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask) { - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); if ((face == GL_FRONT) || (face == GL_FRONT_AND_BACK)) { @@ -2551,7 +2536,7 @@ fpgl_glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask) (current_ctx->gl_stencil_ref[0] != ref) || (current_ctx->gl_stencil_value_mask[0] != mask)) { - _sym_glStencilFuncSeparate(face, func, ref, mask); + _orig_fastpath_glStencilFuncSeparate(face, func, ref, mask); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); @@ -2568,7 +2553,7 @@ fpgl_glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask) (current_ctx->gl_stencil_back_ref[0] != ref) || (current_ctx->gl_stencil_back_value_mask[0] != mask)) { - _sym_glStencilFuncSeparate(face, func, ref, mask); + _orig_fastpath_glStencilFuncSeparate(face, func, ref, mask); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); @@ -2582,28 +2567,28 @@ fpgl_glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask) else { // Have GL pick up the error - _sym_glStencilFuncSeparate(face, func, ref, mask); + _orig_fastpath_glStencilFuncSeparate(face, func, ref, mask); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); } goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } void -fpgl_glStencilMask(GLuint mask) +fastpath_glStencilMask(GLuint mask) { - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); if ((current_ctx->gl_stencil_writemask[0] != mask) || (current_ctx->gl_stencil_back_writemask[0] != mask)) { - _sym_glStencilMask(mask); + _orig_fastpath_glStencilMask(mask); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); @@ -2616,22 +2601,22 @@ fpgl_glStencilMask(GLuint mask) goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } void -fpgl_glStencilMaskSeparate(GLenum face, GLuint mask) +fastpath_glStencilMaskSeparate(GLenum face, GLuint mask) { - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); if ((face == GL_FRONT) || (face == GL_FRONT_AND_BACK)) { if (current_ctx->gl_stencil_writemask[0] != mask) { - _sym_glStencilMaskSeparate(face, mask); + _orig_fastpath_glStencilMaskSeparate(face, mask); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); @@ -2643,7 +2628,7 @@ fpgl_glStencilMaskSeparate(GLenum face, GLuint mask) { if (current_ctx->gl_stencil_back_writemask[0] != mask) { - _sym_glStencilMaskSeparate(face, mask); + _orig_fastpath_glStencilMaskSeparate(face, mask); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); @@ -2654,22 +2639,22 @@ fpgl_glStencilMaskSeparate(GLenum face, GLuint mask) else { // Have GL pick up the error - _sym_glStencilMaskSeparate(face, mask); + _orig_fastpath_glStencilMaskSeparate(face, mask); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); } goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } void -fpgl_glStencilOp(GLenum fail, GLenum zfail, GLenum zpass) +fastpath_glStencilOp(GLenum fail, GLenum zfail, GLenum zpass) { - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); if ((current_ctx->gl_stencil_fail[0] != fail) || (current_ctx->gl_stencil_pass_depth_fail[0] != zfail) || @@ -2678,7 +2663,7 @@ fpgl_glStencilOp(GLenum fail, GLenum zfail, GLenum zpass) (current_ctx->gl_stencil_back_pass_depth_fail[0] != zfail) || (current_ctx->gl_stencil_back_pass_depth_pass[0] != zpass)) { - _sym_glStencilOp(fail, zfail, zpass); + _orig_fastpath_glStencilOp(fail, zfail, zpass); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); @@ -2695,16 +2680,16 @@ fpgl_glStencilOp(GLenum fail, GLenum zfail, GLenum zpass) goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } void -fpgl_glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass) +fastpath_glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass) { - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); if ((face == GL_FRONT) || (face == GL_FRONT_AND_BACK)) { @@ -2712,7 +2697,7 @@ fpgl_glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass) (current_ctx->gl_stencil_pass_depth_fail[0] != zfail) || (current_ctx->gl_stencil_pass_depth_pass[0] != zpass)) { - _sym_glStencilOpSeparate(face, fail, zfail, zpass); + _orig_fastpath_glStencilOpSeparate(face, fail, zfail, zpass); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); current_ctx->_stencil_flag1 |= (FLAG_BIT_3 | FLAG_BIT_4 | FLAG_BIT_5); @@ -2727,7 +2712,7 @@ fpgl_glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass) (current_ctx->gl_stencil_back_pass_depth_fail[0] != zfail) || (current_ctx->gl_stencil_back_pass_depth_pass[0] != zpass)) { - _sym_glStencilOpSeparate(face, fail, zfail, zpass); + _orig_fastpath_glStencilOpSeparate(face, fail, zfail, zpass); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); current_ctx->_stencil_flag2 |= (FLAG_BIT_3 | FLAG_BIT_4 | FLAG_BIT_5); @@ -2739,24 +2724,24 @@ fpgl_glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass) else { // For picking up error purpose - _sym_glStencilOpSeparate(face, fail, zfail, zpass); + _orig_fastpath_glStencilOpSeparate(face, fail, zfail, zpass); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); } goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } // Optmize? void -fpgl_glVertexAttrib1f(GLuint indx, GLfloat x) +fastpath_glVertexAttrib1f(GLuint indx, GLfloat x) { - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); - _sym_glVertexAttrib1f(indx, x); + _orig_fastpath_glVertexAttrib1f(indx, x); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); @@ -2768,19 +2753,19 @@ fpgl_glVertexAttrib1f(GLuint indx, GLfloat x) goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } // Optmize? void -fpgl_glVertexAttrib1fv(GLuint indx, const GLfloat* values) +fastpath_glVertexAttrib1fv(GLuint indx, const GLfloat* values) { - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); - _sym_glVertexAttrib1fv(indx, values); + _orig_fastpath_glVertexAttrib1fv(indx, values); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); @@ -2792,19 +2777,19 @@ fpgl_glVertexAttrib1fv(GLuint indx, const GLfloat* values) goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } // Optmize? void -fpgl_glVertexAttrib2f(GLuint indx, GLfloat x, GLfloat y) +fastpath_glVertexAttrib2f(GLuint indx, GLfloat x, GLfloat y) { - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); - _sym_glVertexAttrib2f(indx, x, y); + _orig_fastpath_glVertexAttrib2f(indx, x, y); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); @@ -2816,19 +2801,19 @@ fpgl_glVertexAttrib2f(GLuint indx, GLfloat x, GLfloat y) goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } // Optmize? void -fpgl_glVertexAttrib2fv(GLuint indx, const GLfloat* values) +fastpath_glVertexAttrib2fv(GLuint indx, const GLfloat* values) { - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); - _sym_glVertexAttrib2fv(indx, values); + _orig_fastpath_glVertexAttrib2fv(indx, values); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); @@ -2840,19 +2825,19 @@ fpgl_glVertexAttrib2fv(GLuint indx, const GLfloat* values) goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } // Optmize? void -fpgl_glVertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z) +fastpath_glVertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z) { - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); - _sym_glVertexAttrib3f(indx, x, y, z); + _orig_fastpath_glVertexAttrib3f(indx, x, y, z); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); @@ -2864,19 +2849,19 @@ fpgl_glVertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z) goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } // Optmize? void -fpgl_glVertexAttrib3fv(GLuint indx, const GLfloat* values) +fastpath_glVertexAttrib3fv(GLuint indx, const GLfloat* values) { - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); - _sym_glVertexAttrib3fv(indx, values); + _orig_fastpath_glVertexAttrib3fv(indx, values); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); @@ -2888,19 +2873,19 @@ fpgl_glVertexAttrib3fv(GLuint indx, const GLfloat* values) goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } // Optmize? void -fpgl_glVertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w) +fastpath_glVertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w) { - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); - _sym_glVertexAttrib4f(indx, x, y, z, w); + _orig_fastpath_glVertexAttrib4f(indx, x, y, z, w); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); @@ -2912,19 +2897,19 @@ fpgl_glVertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w) goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } // Optmize? void -fpgl_glVertexAttrib4fv(GLuint indx, const GLfloat* values) +fastpath_glVertexAttrib4fv(GLuint indx, const GLfloat* values) { - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); - _sym_glVertexAttrib4fv(indx, values); + _orig_fastpath_glVertexAttrib4fv(indx, values); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); @@ -2936,20 +2921,20 @@ fpgl_glVertexAttrib4fv(GLuint indx, const GLfloat* values) goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } // Optmize? void -fpgl_glVertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr) +fastpath_glVertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr) { - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); - _sym_glVertexAttribPointer(indx, size, type, normalized, stride, ptr); + _orig_fastpath_glVertexAttribPointer(indx, size, type, normalized, stride, ptr); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); @@ -2964,23 +2949,23 @@ fpgl_glVertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean norma goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } void -fpgl_glViewport(GLint x, GLint y, GLsizei width, GLsizei height) +fastpath_glViewport(GLint x, GLint y, GLsizei width, GLsizei height) { - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); if ((current_ctx->gl_viewport[0] != x) || (current_ctx->gl_viewport[1] != y) || (current_ctx->gl_viewport[2] != width) || (current_ctx->gl_viewport[3] != height)) { - _sym_glViewport(x, y, width, height); + _orig_fastpath_glViewport(x, y, width, height); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); @@ -2993,17 +2978,17 @@ fpgl_glViewport(GLint x, GLint y, GLsizei width, GLsizei height) goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } void -fpgl_glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image) +fastpath_glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image) { int tex_idx; - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); tex_idx = current_ctx->gl_active_texture[0] - GL_TEXTURE0; @@ -3017,14 +3002,14 @@ fpgl_glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image) break; } - _sym_glEGLImageTargetTexture2DOES(target, image); + _orig_fastpath_glEGLImageTargetTexture2DOES(target, image); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } #define TRANS_VALUE(index, value) \ @@ -3042,8 +3027,8 @@ _process_getfunc(GLenum pname, GLvoid *ptr, GLenum get_type) { GLboolean ret = GL_FALSE; - DEFINE_FAST_GL_FUNC(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + INIT_FASTPATH_GL_FUNC(); switch (pname) { @@ -3058,7 +3043,7 @@ _process_getfunc(GLenum pname, GLvoid *ptr, GLenum get_type) GLint real_obj_id = _COREGL_INT_INIT_VALUE; GLuint glue_obj_id = _COREGL_INT_INIT_VALUE; GL_Object_Type obj_type = GL_OBJECT_TYPE_UNKNOWN; - _sym_glGetIntegerv(pname, (GLint *)&real_obj_id); + _orig_fastpath_glGetIntegerv(pname, (GLint *)&real_obj_id); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); @@ -3098,56 +3083,56 @@ finish: void -fpgl_glGetBooleanv(GLenum pname, GLboolean* params) +fastpath_glGetBooleanv(GLenum pname, GLboolean* params) { - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); if (_process_getfunc(pname, params, GL_BOOL) != GL_TRUE) { - _sym_glGetBooleanv(pname, params); + _orig_fastpath_glGetBooleanv(pname, params); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); } goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } void -fpgl_glGetFloatv(GLenum pname, GLfloat* params) +fastpath_glGetFloatv(GLenum pname, GLfloat* params) { - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); if (_process_getfunc(pname, params, GL_FLOAT) != GL_TRUE) { - _sym_glGetFloatv(pname, params); + _orig_fastpath_glGetFloatv(pname, params); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); } goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } void -fpgl_glGetIntegerv(GLenum pname, GLint* params) +fastpath_glGetIntegerv(GLenum pname, GLint* params) { - DEFINE_FAST_GL_FUNC(); - _COREGL_FAST_FUNC_BEGIN(); - INIT_FAST_GL_FUNC(); + DEFINE_FASTPAH_GL_FUNC(); + _COREGL_FASTPATH_FUNC_BEGIN(); + INIT_FASTPATH_GL_FUNC(); if (_process_getfunc(pname, params, GL_INT) != GL_TRUE) { - _sym_glGetIntegerv(pname, params); + _orig_fastpath_glGetIntegerv(pname, params); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); } goto finish; finish: - _COREGL_FAST_FUNC_END(); + _COREGL_FASTPATH_FUNC_END(); } diff --git a/src/coregl_fastpath_state.h b/src/modules/fastpath/coregl_fastpath_state.h similarity index 100% rename from src/coregl_fastpath_state.h rename to src/modules/fastpath/coregl_fastpath_state.h diff --git a/src/modules/tracepath/coregl_tracepath.c b/src/modules/tracepath/coregl_tracepath.c new file mode 100644 index 0000000..e1fb75a --- /dev/null +++ b/src/modules/tracepath/coregl_tracepath.c @@ -0,0 +1,683 @@ +#include "coregl_tracepath.h" + +#include +#include +#include + +#define _COREGL_SYMBOL(IS_EXTENSION, RET_TYPE, FUNC_NAME, PARAM_LIST) RET_TYPE (*_orig_tracepath_##FUNC_NAME) PARAM_LIST = NULL; +#include "../../headers/sym.h" +#undef _COREGL_SYMBOL + +#define TIMEVAL_INIT { 0, 0 } + +#define MAX_TRACE_NAME_LENGTH 256 +#define MAX_TRACE_TABLE_SIZE 65536 + +struct _Trace_Data +{ + char name[MAX_TRACE_NAME_LENGTH]; + int call_count; + int last_call_count; + struct timeval elapsed_time; + struct timeval last_elapsed_time; + struct timeval total_elapsed_time; + struct timeval last_total_elapsed_time; + struct timeval last_time; + + int traced; + + struct _Trace_Data *next; +}; + +typedef struct _GLGlueFakeContext +{ + GLuint gl_num_tex_units[1]; + GLuint gl_num_vertex_attribs[1]; +} GLGlueFakeContext; + +GLGlueFakeContext initial_fake_ctx_real; +GLGlueFakeContext *initial_fake_ctx = &initial_fake_ctx_real; + +struct timeval initial_time = TIMEVAL_INIT; +struct timeval last_initial_time = TIMEVAL_INIT; + +struct timeval last_trace_time = TIMEVAL_INIT; +struct timeval other_elapsed_time = TIMEVAL_INIT; +struct timeval traced_other_elapsed_time = TIMEVAL_INIT; + +static void +_get_texture_states(GLenum pname, GLint *params) +{ + GLuint cur_active_tex = 0; + + AST(initial_fake_ctx != NULL); + + _sym_glGetIntegerv(GL_ACTIVE_TEXTURE, (GLint *)&cur_active_tex); + int i; + for (i = 0; i < initial_fake_ctx->gl_num_tex_units[0]; i++) + { + _sym_glActiveTexture(GL_TEXTURE0 + i); + _sym_glGetIntegerv(pname, &(((GLint *)params)[i])); + } + _sym_glActiveTexture(cur_active_tex); +} + +void +init_modules_tracepath() +{ + { + 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_TRACEPATH_TRACE_APICALL_INFO + trace_api_flag = atoi(get_env_setting("COREGL_TRACE_API")); + trace_api_all_flag = atoi(get_env_setting("COREGL_TRACE_API_ALL")); +#endif +#ifdef COREGL_TRACEPATH_TRACE_CONTEXT_INFO + trace_ctx_flag = atoi(get_env_setting("COREGL_TRACE_CTX")); + trace_ctx_force_flag = atoi(get_env_setting("COREGL_TRACE_CTX_FORCE")); +#endif +#ifdef COREGL_TRACEPATH_TRACE_STATE_INFO + trace_state_flag = atoi(get_env_setting("COREGL_TRACE_STATE")); +#endif + + if (USE_TRACEPATH) + { + LOG("[CoreGL] : "); + + if (trace_api_flag == 1) + { + LOG("(API) "); + if (trace_api_all_flag == 1) LOG("(API-ALL) "); + } + if (trace_ctx_flag == 1) { + LOG("(CONTEXT) "); + if (trace_ctx_force_flag == 1) LOG("(CONTEXT-FORCE) "); + } + if (trace_state_flag == 1) LOG("(STATE) "); + + LOG("enabled\n"); + } + + tracepath_apply_overrides(); + +} + +void +deinit_modules_tracepath() +{ +} + +void +init_modules_tstate_tracepath(GLThreadState *tstate) +{ + MY_MODULE_TSTATE *tstate_mt = NULL; + + tstate_mt = (MY_MODULE_TSTATE *)calloc(1, sizeof(MY_MODULE_TSTATE)); + + + tstate->module_data[MY_MODULE_ID] = tstate_mt; +} + +void +deinit_modules_tstate_tracepath(GLThreadState *tstate) +{ + if (tstate->module_data[MY_MODULE_ID] != NULL) + { + free(tstate->module_data[MY_MODULE_ID]); + tstate->module_data[MY_MODULE_ID] = NULL; + } +} + +void +tracepath_apply_overrides() +{ + if (USE_TRACEPATH) + { + tracepath_apply_overrides_egl(1); + tracepath_apply_overrides_gl(1); + } +} + +#define OVERRIDE(f) \ + if (enable == 1) \ + { \ + COREGL_OVERRIDE_API(_orig_tracepath_, f, ovr_); \ + COREGL_OVERRIDE_API(ovr_, f, tracepath_); \ + } \ + else \ + { \ + AST(ovr_##f != NULL); \ + COREGL_OVERRIDE_API(ovr_, f, _orig_tracepath_); \ + _orig_tracepath_##f = NULL; \ + } + +void +tracepath_apply_overrides_egl(int enable) +{ +#define _COREGL_SYMBOL(IS_EXTENSION, RET_TYPE, FUNC_NAME, PARAM_LIST) OVERRIDE(FUNC_NAME); +# include "../../headers/sym_egl.h" +#undef _COREGL_SYMBOL +} + +void +tracepath_apply_overrides_gl(int enable) +{ +#define _COREGL_SYMBOL(IS_EXTENSION, RET_TYPE, FUNC_NAME, PARAM_LIST) OVERRIDE(FUNC_NAME); +# include "../../headers/sym_gl.h" +#undef _COREGL_SYMBOL + +} + +#undef OVERRIDE + +void +tracepath_dump_context_states(int force_output) +{ + static struct timeval tv_last = { 0, 0 }; + + if (unlikely(trace_state_flag != 1)) return; + + _sym_glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, (GLint *)initial_fake_ctx->gl_num_tex_units); + _sym_glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, (GLint *)initial_fake_ctx->gl_num_vertex_attribs); + + if (!force_output) + { + struct timeval tv_now = { 0, 0 }; + AST(gettimeofday(&tv_now, NULL) == 0); + if (tv_now.tv_sec - tv_last.tv_sec < _COREGL_TRACE_OUTPUT_INTERVAL_SEC) + { + goto finish; + } + tv_last = tv_now; + } + + 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" +#define PRINTF_CHAR_GLint "%10d" +#define PRINTF_CHAR_GLsizei "%10u" +#define PRINTF_CHAR_GLuint "%10u" +#define PRINTF_CHAR_GLuintmask "0x%8X" + +#define PRINTF_CHAR_GLclampf "%10.6f" +#define PRINTF_CHAR_GLfloat "%10.6f" + +#define PRINTF_CHAR_GLvoidptr "%10p" + +#define PRINTF_CHAR(type) PRINTF_CHAR_##type + +#define INITIAL_CTX initial_fake_ctx + +#define GLUE_STATE(TYPE, NAME, SIZE, ARRAY_SIZE, DEFAULT_STMT, GET_STMT) \ + { \ + TYPE valuedata[SIZE]; \ + TYPE *value = NULL; \ + value = valuedata; GET_STMT; value = valuedata; \ + TRACE("\E[0;37;1m %-30.30s : (\E[0m ", #NAME); \ + for (int i = 0; i < SIZE; i++) \ + { \ + if (i > 0) { \ + if (i % 4 == 0) \ + TRACE("\n %-30.30s ", "");\ + else \ + TRACE(", "); \ + } \ + TRACE("["PRINTF_CHAR(TYPE)"]", value[i]); \ + } \ + TRACE(" \E[0;37;1m)\E[0m\n"); \ + } +# include "../fastpath/coregl_fastpath_state.h" +#undef GLUE_STATE + + TRACE("\E[0;40;34m===================================================================================================================\E[0m\n"); + TRACE("\n"); + + TRACE_END(); + +finish: + return; +} + + +static inline void +_add_timeval_period(struct timeval *tv_dst, struct timeval tv_now, struct timeval tv_old) +{ + tv_dst->tv_sec += tv_now.tv_sec - tv_old.tv_sec; + tv_dst->tv_usec += 1000000 + (tv_now.tv_usec - tv_old.tv_usec); + tv_dst->tv_sec += (tv_dst->tv_usec / 1000000) - 1; + tv_dst->tv_usec = tv_dst->tv_usec % 1000000; +} + +static inline void +_add_timeval(struct timeval *tv_dst, struct timeval tv_src) +{ + tv_dst->tv_sec += tv_src.tv_sec; + tv_dst->tv_usec += tv_src.tv_usec; + if (tv_dst->tv_usec > 1000000) + { + tv_dst->tv_usec -= 1000000; + tv_dst->tv_sec++; + } + else if (tv_dst->tv_usec < 0) + { + tv_dst->tv_usec += 1000000; + tv_dst->tv_sec--; + } +} + +static inline double +_get_timeval_period(struct timeval time_now, struct timeval time_old) +{ + return ((time_now.tv_sec - time_old.tv_sec) * 1000) + ((time_now.tv_usec - time_old.tv_usec) / 1000.0); +} + +static inline double +_get_timeval(struct timeval time) +{ + return (time.tv_sec * 1000) + (time.tv_usec / 1000.0); +} + +static unsigned short +_generate_hash_short(const char *string) +{ + unsigned short hash = 0; + int i; + + for (i = 0; i < strlen(string); i++) + { + hash = 253 * hash + string[i]; + } + return (hash ^ (hash >> 8)) % MAX_TRACE_TABLE_SIZE; +} + +static Trace_Data * +_get_trace_data(Trace_Data **ftd_table, const char *name) +{ + Trace_Data *ret = NULL; + Trace_Data *current = NULL; + Trace_Data *prev = NULL; + unsigned short hash = 0; + + AST(strlen(name) < MAX_TRACE_NAME_LENGTH); + + hash = _generate_hash_short(name); + + current = ftd_table[hash]; + + while (current != NULL && current->next != NULL) + { + if (strcmp(current->name, name) == 0) + break; + prev = current; + current = current->next; + } + + if (current != NULL) + { + ret = current; + } + else + { + Trace_Data *newitm = NULL; + newitm = (Trace_Data *)calloc(1, sizeof(Trace_Data)); + strcpy(newitm->name, name); + newitm->next = NULL; + + if (prev != NULL) + { + prev->next = newitm; + } + else + { + ftd_table[hash] = newitm; + } + ret = newitm; + } + + goto finish; + +finish: + return ret; +} + +void * +tracepath_api_trace_begin(const char *funcname, void *hint, int trace_total_time) +{ + Trace_Data *ftd = NULL; + struct timeval t = TIMEVAL_INIT; + + if (trace_api_flag == 1) + { + AST(gettimeofday(&t, NULL) == 0); + + ftd = (Trace_Data *)hint; + + if (ftd == NULL) + { + MY_MODULE_TSTATE *tstate = NULL; + GET_MY_TSTATE(tstate, get_current_thread_state()); + + if (tstate == NULL) + { + init_new_thread_state(); + + GET_MY_TSTATE(tstate, get_current_thread_state()); + AST(tstate != NULL); + } + + if (tstate->ftd_table == NULL) + { + tstate->ftd_table = (Trace_Data **)calloc(1, sizeof(Trace_Data *) * MAX_TRACE_TABLE_SIZE); + } + + ftd = _get_trace_data(tstate->ftd_table, funcname); + } + + AST(ftd != NULL); + + ftd->call_count++; + AST(ftd->last_time.tv_sec == 0); + + AST(gettimeofday(&ftd->last_time, NULL) == 0); + + if (initial_time.tv_sec == 0) + { + initial_time = ftd->last_time; + last_initial_time = ftd->last_time; + } + + if (trace_total_time == 1) + { + if (last_trace_time.tv_sec != 0) + { + _add_timeval_period(&other_elapsed_time, t, last_trace_time); + last_trace_time.tv_sec = 0; + } + } + + } + + return ftd; +} + +void * +tracepath_api_trace_end(const char *funcname, void *hint, int trace_total_time) +{ + Trace_Data *ftd = NULL; + struct timeval t = TIMEVAL_INIT; + + if (trace_api_flag == 1) + { + MY_MODULE_TSTATE *tstate = NULL; + struct timeval elapsed_time = TIMEVAL_INIT; + + AST(gettimeofday(&t, NULL) == 0); + + ftd = (Trace_Data *)hint; + + if (ftd == NULL) + { + GET_MY_TSTATE(tstate, get_current_thread_state()); + + if (tstate == NULL) + { + init_new_thread_state(); + + GET_MY_TSTATE(tstate, get_current_thread_state()); + AST(tstate != NULL); + } + + AST(tstate != NULL); + AST(tstate->ftd_table != NULL); + + ftd = _get_trace_data(tstate->ftd_table, funcname); + } + + AST(ftd != NULL); + + _add_timeval_period(&elapsed_time, t, ftd->last_time); + + _add_timeval(&ftd->elapsed_time, elapsed_time); + + + ftd->last_time.tv_sec = 0; + + if (trace_total_time == 1) + { + _add_timeval(&ftd->total_elapsed_time, elapsed_time); + + AST(gettimeofday(&last_trace_time, NULL) == 0); + + if (initial_time.tv_sec == 0) + { + initial_time = t; + last_initial_time = t; + } + } + + } + + + return ftd; +} + +void +tracepath_api_trace_output(int force_output) +{ + static struct timeval tv_last = TIMEVAL_INIT; + struct timeval total_now = TIMEVAL_INIT; + GLThreadState *tstate = NULL; + MY_MODULE_TSTATE *tstate_tm = NULL; + Trace_Data **ftd_table = NULL; + + double total_elapsed_time = 0.0; + double total_elapsed_time_period = 0.0; + double total_opengl_elapsed_time = 0.0; + double total_opengl_elapsed_time_period = 0.0; + double total_other_elapsed_time = 0.0; + double total_other_elapsed_time_period = 0.0; + + double swaps_per_sec = 0.0; + + int i; + + if (trace_api_flag != 1) + { + goto finish; + } + + if (!force_output) + { + struct timeval tv_now = TIMEVAL_INIT; + AST(gettimeofday(&tv_now, NULL) == 0); + if (tv_now.tv_sec - tv_last.tv_sec < _COREGL_TRACE_OUTPUT_INTERVAL_SEC) + { + goto finish; + } + tv_last = tv_now; + } + + AST(gettimeofday(&total_now, NULL) == 0); + + total_elapsed_time = _get_timeval_period(total_now, initial_time); + total_elapsed_time_period = _get_timeval_period(total_now, last_initial_time); + last_initial_time = total_now; + + total_other_elapsed_time = _get_timeval(other_elapsed_time); + total_other_elapsed_time_period = _get_timeval_period(other_elapsed_time, traced_other_elapsed_time); + traced_other_elapsed_time = other_elapsed_time; + + tstate = get_current_thread_state(); + + if (tstate == NULL) + { + init_new_thread_state(); + + tstate = get_current_thread_state(); + AST(tstate != NULL); + } + + GET_MY_TSTATE(tstate_tm, tstate); + if (tstate_tm == NULL) return; + + ftd_table = tstate_tm->ftd_table; + if (ftd_table == NULL) return; + + { + static Trace_Data *trace_hint_swap = NULL; + if (trace_hint_swap == NULL) + trace_hint_swap = _get_trace_data(ftd_table, "eglSwapBuffers"); + + if (trace_hint_swap != NULL && total_elapsed_time_period > 0) + { + swaps_per_sec = (trace_hint_swap->call_count - trace_hint_swap->last_call_count) / (total_elapsed_time_period / 1000); + } + } + + + 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++) + { + if (ftd_table[i] != NULL) + { + Trace_Data *current = ftd_table[i]; + + while (current != NULL) + { + double elapsed_time = _get_timeval(current->elapsed_time); + double elapsed_time_per_call = elapsed_time / current->call_count; + + total_opengl_elapsed_time += _get_timeval(current->total_elapsed_time); + total_opengl_elapsed_time_period += _get_timeval(current->total_elapsed_time) - _get_timeval(current->last_total_elapsed_time); + + current->traced = 0; + + if (current->call_count > current->last_call_count) + { + double elapsed_time_period = _get_timeval_period(current->elapsed_time, current->last_elapsed_time); + double elapsed_time_per_call_period = elapsed_time_period / (current->call_count - current->last_call_count); + char *fname = current->name; + + if (!strncmp(fname, "tracepath_", 10)) + fname = ¤t->name[10]; + + if (elapsed_time_per_call_period >= 0.01 || current->call_count - current->last_call_count > 1000) + { + 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", + fname, current->call_count, elapsed_time, elapsed_time_per_call, elapsed_time_per_call_period); + current->traced = 1; + } + } + current = current->next; + } + } + } + + { + int fp_env = 0; + fp_env = atoi(get_env_setting("COREGL_TRACE_API_ALL")); + if (fp_env == 1) + { + // other + for (i = 0; i < MAX_TRACE_TABLE_SIZE; i++) + { + if (ftd_table[i] != NULL) + { + Trace_Data *current = ftd_table[i]; + + while (current != NULL) + { + if (current->traced == 0) + { + double elapsed_time = _get_timeval(current->elapsed_time); + double elapsed_time_per_call = elapsed_time / current->call_count; + char *fname = current->name; + + if (!strncmp(fname, "tracepath_", 10)) + fname = ¤t->name[10]; + + TRACE(" %-42.42s : %10d call(s), %10.2f ms, %9.3f ms/API\n", + fname, current->call_count, elapsed_time, elapsed_time_per_call); + } + current = current->next; + } + } + } + } + } + + TRACE("\E[40;34m========================================================================================================================\E[0m\n"); + + 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); + + + 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); + + 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); + + 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); + + TRACE("\E[40;34m========================================================================================================================\E[0m\n"); + TRACE("\n"); + + for (i = 0; i < MAX_TRACE_TABLE_SIZE; i++) + { + if (ftd_table[i] != NULL) + { + Trace_Data *current = ftd_table[i]; + + while (current != NULL) + { + current->last_call_count = current->call_count; + current->last_elapsed_time = current->elapsed_time; + current->last_total_elapsed_time = current->total_elapsed_time; + current = current->next; + } + } + } + + TRACE_END(); + + goto finish; + +finish: + return; +} + diff --git a/src/modules/tracepath/coregl_tracepath.h b/src/modules/tracepath/coregl_tracepath.h new file mode 100644 index 0000000..8d6dd2b --- /dev/null +++ b/src/modules/tracepath/coregl_tracepath.h @@ -0,0 +1,76 @@ +#ifndef COREGL_TRACEPATH_H +#define COREGL_TRACEPATH_H + +#include "../coregl_module.h" + +#ifndef COREGL_USE_MODULE_TRACEPATH +#error "COREGL_USE_MODULE_TRACEPATH must defined!!!" +#endif + +#define MY_MODULE_ID COREGL_MODULE_TRACEPATH +#define MY_MODULE_TSTATE Tracepath_ThreadState + +#include "../../coregl_internal.h" +#include "../../coregl_export.h" + +#define _COREGL_SYMBOL(IS_EXTENSION, RET_TYPE, FUNC_NAME, PARAM_LIST) extern RET_TYPE (*_orig_tracepath_##FUNC_NAME) PARAM_LIST; +# include "../../headers/sym.h" +#undef _COREGL_SYMBOL + +// Symbol definition for tracepath +#define _COREGL_SYMBOL(IS_EXTENSION, RET_TYPE, FUNC_NAME, PARAM_LIST) extern RET_TYPE (tracepath_##FUNC_NAME) PARAM_LIST; +# include "../../headers/sym.h" +#undef _COREGL_SYMBOL + +#define COREGL_TRACEPATH_TRACE_ALL + +#ifdef COREGL_TRACEPATH_TRACE_ALL +#define COREGL_TRACEPATH_TRACE_CONTEXT_INFO // Context state & thread state & Glue-context info +#define COREGL_TRACEPATH_TRACE_STATE_INFO // Glue-context state info +#define COREGL_TRACEPATH_TRACE_APICALL_INFO // API call frequency info +#endif + +#ifdef COREGL_TRACEPATH_TRACE_APICALL_INFO +# define _COREGL_TRACE_API_BEGIN(api, hint, trace_total_time) \ + tracepath_api_trace_begin(api, hint, trace_total_time); +# define _COREGL_TRACE_API_END(api, hint, trace_total_time) \ + tracepath_api_trace_end(api, hint, trace_total_time); +# define _COREGL_TRACE_API_OUTPUT(force_output) \ + tracepath_api_trace_output(force_output); +#else +# define _COREGL_TRACE_API_BEGIN(api, hint, trace_total_time) NULL; +# define _COREGL_TRACE_API_END(api, hint, trace_total_time) +# define _COREGL_TRACE_API_OUTPUT(force_output) +#endif + +#define _COREGL_TRACEPATH_FUNC_BEGIN() \ + if (unlikely(trace_api_flag == 1)) \ + _COREGL_TRACE_API_BEGIN(__func__, NULL, 1); + +#define _COREGL_TRACEPATH_FUNC_END() \ + if (unlikely(trace_api_flag == 1)) \ + _COREGL_TRACE_API_END(__func__, NULL, 1); + +typedef struct _Tracepath_ThreadState +{ + Trace_Data **ftd_table; +} Tracepath_ThreadState; + +extern void init_modules_tracepath(); +extern void deinit_modules_tracepath(); +extern void init_modules_tstate_tracepath(GLThreadState *tstate); +extern void deinit_modules_tstate_tracepath(GLThreadState *tstate); + + +extern void tracepath_apply_overrides(); +extern void tracepath_apply_overrides_egl(); +extern void tracepath_apply_overrides_gl(); + +extern void tracepath_dump_context_states(int force_output); + +extern void *tracepath_api_trace_begin(const char *name, void *hint, int trace_total_time); +extern void *tracepath_api_trace_end(const char *name, void *hint, int trace_total_time); +extern void tracepath_api_trace_output(int force_output); + +#endif // COREGL_TRACEPATH_H + diff --git a/src/modules/tracepath/coregl_tracepath_egl.c b/src/modules/tracepath/coregl_tracepath_egl.c new file mode 100644 index 0000000..bd7d478 --- /dev/null +++ b/src/modules/tracepath/coregl_tracepath_egl.c @@ -0,0 +1,585 @@ +#include "coregl_tracepath.h" + +EGLint +tracepath_eglGetError(void) +{ + EGLint ret = _COREGL_INT_INIT_VALUE; + + _COREGL_TRACEPATH_FUNC_BEGIN(); + ret = _orig_tracepath_eglGetError(); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); + return ret; +} + +EGLDisplay +tracepath_eglGetDisplay(EGLNativeDisplayType display_id) +{ + EGLDisplay ret = EGL_NO_DISPLAY; + + _COREGL_TRACEPATH_FUNC_BEGIN(); + ret = _orig_tracepath_eglGetDisplay(display_id); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); + return ret; +} + +EGLBoolean +tracepath_eglInitialize(EGLDisplay dpy, EGLint* major, EGLint* minor) +{ + EGLBoolean ret = EGL_FALSE; + _COREGL_TRACEPATH_FUNC_BEGIN(); + ret = _orig_tracepath_eglInitialize(dpy, major, minor); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); + return ret; +} + +EGLBoolean +tracepath_eglTerminate(EGLDisplay dpy) +{ + EGLBoolean ret = EGL_FALSE; + + _COREGL_TRACEPATH_FUNC_BEGIN(); + ret = _orig_tracepath_eglTerminate(dpy); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); + return ret; +} + +EGLBoolean +tracepath_eglGetConfigs(EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config) +{ + EGLBoolean ret = EGL_FALSE; + + _COREGL_TRACEPATH_FUNC_BEGIN(); + ret = _orig_tracepath_eglGetConfigs(dpy, configs, config_size, num_config); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); + return ret; +} + +EGLBoolean +tracepath_eglChooseConfig(EGLDisplay dpy, const EGLint* attrib_list, EGLConfig* configs, EGLint config_size, EGLint* num_config) +{ + EGLBoolean ret = EGL_FALSE; + + _COREGL_TRACEPATH_FUNC_BEGIN(); + ret = _orig_tracepath_eglChooseConfig(dpy, attrib_list, configs, config_size, num_config); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); + return ret; +} + +EGLBoolean +tracepath_eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value) +{ + EGLBoolean ret = EGL_FALSE; + + _COREGL_TRACEPATH_FUNC_BEGIN(); + ret = _orig_tracepath_eglGetConfigAttrib(dpy, config, attribute, value); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); + return ret; +} + + +EGLSurface +tracepath_eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint* attrib_list) +{ + EGLSurface ret = EGL_NO_SURFACE; + + _COREGL_TRACEPATH_FUNC_BEGIN(); + ret = _orig_tracepath_eglCreateWindowSurface(dpy, config, win, attrib_list); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); + return ret; +} + +EGLSurface +tracepath_eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list) +{ + EGLSurface ret = EGL_NO_SURFACE; + + _COREGL_TRACEPATH_FUNC_BEGIN(); + ret = _orig_tracepath_eglCreatePbufferSurface(dpy, config, attrib_list); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); + return ret; +} + +EGLSurface +tracepath_eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint* attrib_list) +{ + EGLSurface ret = EGL_NO_SURFACE; + + _COREGL_TRACEPATH_FUNC_BEGIN(); + ret = _orig_tracepath_eglCreatePixmapSurface(dpy, config, pixmap, attrib_list); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); + return ret; +} + +EGLBoolean +tracepath_eglDestroySurface(EGLDisplay dpy, EGLSurface surface) +{ + EGLBoolean ret = EGL_FALSE; + + _COREGL_TRACEPATH_FUNC_BEGIN(); + ret = _orig_tracepath_eglDestroySurface(dpy, surface); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); + return ret; +} + +EGLBoolean +tracepath_eglQuerySurface(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value) +{ + EGLBoolean ret = EGL_FALSE; + + _COREGL_TRACEPATH_FUNC_BEGIN(); + ret = _orig_tracepath_eglQuerySurface(dpy, surface, attribute, value); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); + return ret; +} + +EGLBoolean +tracepath_eglBindAPI(EGLenum api) +{ + EGLBoolean ret = EGL_FALSE; + + _COREGL_TRACEPATH_FUNC_BEGIN(); + ret = _orig_tracepath_eglBindAPI(api); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); + return ret; +} + +EGLenum +tracepath_eglQueryAPI(void) +{ + EGLenum ret = 0; + + _COREGL_TRACEPATH_FUNC_BEGIN(); + ret = _orig_tracepath_eglQueryAPI(); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); + return ret; +} + +EGLBoolean +tracepath_eglWaitClient(void) +{ + EGLBoolean ret = EGL_FALSE; + + _COREGL_TRACEPATH_FUNC_BEGIN(); + ret = _orig_tracepath_eglWaitClient(); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); + return ret; +} + +EGLBoolean +tracepath_eglReleaseThread(void) +{ + EGLBoolean ret = EGL_FALSE; + + _COREGL_TRACEPATH_FUNC_BEGIN(); + ret = _orig_tracepath_eglReleaseThread(); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); + return ret; +} + +EGLSurface +tracepath_eglCreatePbufferFromClientBuffer(EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list) +{ + EGLSurface ret = EGL_NO_SURFACE; + + _COREGL_TRACEPATH_FUNC_BEGIN(); + ret = _orig_tracepath_eglCreatePbufferFromClientBuffer(dpy, buftype, buffer, config, attrib_list); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); + return ret; +} + +EGLBoolean +tracepath_eglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value) +{ + EGLBoolean ret = EGL_FALSE; + + _COREGL_TRACEPATH_FUNC_BEGIN(); + ret = _orig_tracepath_eglSurfaceAttrib(dpy, surface, attribute, value); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); + return ret; +} + +EGLBoolean +tracepath_eglBindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer) +{ + EGLBoolean ret = EGL_FALSE; + + _COREGL_TRACEPATH_FUNC_BEGIN(); + ret = _orig_tracepath_eglBindTexImage(dpy, surface, buffer); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); + return ret; +} + +EGLBoolean +tracepath_eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer) +{ + EGLBoolean ret = EGL_FALSE; + + _COREGL_TRACEPATH_FUNC_BEGIN(); + ret = _orig_tracepath_eglReleaseTexImage(dpy, surface, buffer); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); + return ret; +} + +EGLBoolean +tracepath_eglSwapInterval(EGLDisplay dpy, EGLint interval) +{ + EGLBoolean ret = EGL_FALSE; + + _COREGL_TRACEPATH_FUNC_BEGIN(); + ret = _orig_tracepath_eglSwapInterval(dpy, interval); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); + return ret; +} + +EGLContext +tracepath_eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint* attrib_list) +{ + EGLContext ret = EGL_NO_CONTEXT; + + _COREGL_TRACEPATH_FUNC_BEGIN(); + ret = _orig_tracepath_eglCreateContext(dpy, config, share_context, attrib_list); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); + return ret; +} + +EGLBoolean +tracepath_eglDestroyContext(EGLDisplay dpy, EGLContext ctx) +{ + EGLBoolean ret = EGL_FALSE; + + _COREGL_TRACEPATH_FUNC_BEGIN(); + ret = _orig_tracepath_eglDestroyContext(dpy, ctx); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); + return ret; +} + +EGLBoolean +tracepath_eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx) +{ + EGLBoolean ret = EGL_FALSE; + + _COREGL_TRACEPATH_FUNC_BEGIN(); + ret = _orig_tracepath_eglMakeCurrent(dpy, draw, read, ctx); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +#ifdef COREGL_TRACE_STATE_INFO + if (unlikely(trace_state_flag == 1)) + { + if (_orig_tracepath_eglMakeCurrent == _sym_eglMakeCurrent) + tracepath_dump_context_states(0); + } +#endif // COREGL_TRACE_STATE_INFO + return ret; +} + +EGLContext +tracepath_eglGetCurrentContext(void) +{ + EGLContext ret = EGL_NO_CONTEXT; + + _COREGL_TRACEPATH_FUNC_BEGIN(); + ret = _orig_tracepath_eglGetCurrentContext(); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); + return ret; +} + +EGLSurface +tracepath_eglGetCurrentSurface(EGLint readdraw) +{ + EGLSurface ret = EGL_NO_SURFACE; + + _COREGL_TRACEPATH_FUNC_BEGIN(); + ret = _orig_tracepath_eglGetCurrentSurface(readdraw); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); + return ret; +} + +EGLDisplay +tracepath_eglGetCurrentDisplay(void) +{ + EGLDisplay ret = EGL_NO_DISPLAY; + + _COREGL_TRACEPATH_FUNC_BEGIN(); + ret = _orig_tracepath_eglGetCurrentDisplay(); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); + return ret; +} + +EGLBoolean +tracepath_eglQueryContext(EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value) +{ + EGLBoolean ret = EGL_FALSE; + + _COREGL_TRACEPATH_FUNC_BEGIN(); + ret = _orig_tracepath_eglQueryContext(dpy, ctx, attribute, value); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); + return ret; +} + +EGLBoolean +tracepath_eglWaitGL(void) +{ + EGLBoolean ret = EGL_FALSE; + + _COREGL_TRACEPATH_FUNC_BEGIN(); + ret = _orig_tracepath_eglWaitGL(); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); + return ret; +} + +EGLBoolean +tracepath_eglWaitNative(EGLint engine) +{ + EGLBoolean ret = EGL_FALSE; + + _COREGL_TRACEPATH_FUNC_BEGIN(); + ret = _orig_tracepath_eglWaitNative(engine); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); + return ret; +} + +EGLBoolean +tracepath_eglSwapBuffers(EGLDisplay dpy, EGLSurface surface) +{ + EGLBoolean ret = EGL_FALSE; + + _COREGL_TRACEPATH_FUNC_BEGIN(); + ret = _orig_tracepath_eglSwapBuffers(dpy, surface); + + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); + _COREGL_TRACE_API_OUTPUT(0); + return ret; +} + +EGLBoolean +tracepath_eglCopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target) +{ + EGLBoolean ret = EGL_FALSE; + + _COREGL_TRACEPATH_FUNC_BEGIN(); + ret = _orig_tracepath_eglCopyBuffers(dpy, surface, target); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); + return ret; +} + +_eng_fn +tracepath_eglGetProcAddress(const char* procname) +{ + _eng_fn ret = NULL; + + _COREGL_TRACEPATH_FUNC_BEGIN(); + ret = _orig_tracepath_eglGetProcAddress(procname); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); + return ret; +} + +const char * +tracepath_eglQueryString(EGLDisplay dpy, EGLint name) +{ + const char *ret = NULL; + + _COREGL_TRACEPATH_FUNC_BEGIN(); + ret = _orig_tracepath_eglQueryString(dpy, name); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); + return ret; +} + +EGLImageKHR +tracepath_eglCreateImageKHR (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list) +{ + void *ret = NULL; + + _COREGL_TRACEPATH_FUNC_BEGIN(); + ret = _orig_tracepath_eglCreateImageKHR(dpy, ctx, target, buffer, attrib_list); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); + return ret; +} + +EGLBoolean +tracepath_eglDestroyImageKHR(EGLDisplay dpy, EGLImageKHR image) +{ + EGLBoolean ret = EGL_FALSE; + + _COREGL_TRACEPATH_FUNC_BEGIN(); + ret = _orig_tracepath_eglDestroyImageKHR(dpy, image); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); + return ret; +} + +void * +tracepath_eglMapImageSEC(EGLDisplay dpy, EGLImageKHR image) +{ + void *ret = NULL; + + _COREGL_TRACEPATH_FUNC_BEGIN(); + ret = _orig_tracepath_eglMapImageSEC(dpy, image); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); + return ret; +} + +EGLBoolean +tracepath_eglUnmapImageSEC(EGLDisplay dpy, EGLImageKHR image) +{ + EGLBoolean ret = EGL_FALSE; + + _COREGL_TRACEPATH_FUNC_BEGIN(); + ret = _orig_tracepath_eglUnmapImageSEC(dpy, image); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); + return ret; +} + +EGLBoolean +tracepath_eglGetImageAttribSEC(EGLDisplay dpy, EGLImageKHR image, EGLint attribute, EGLint *value) +{ + EGLBoolean ret = EGL_FALSE; + + _COREGL_TRACEPATH_FUNC_BEGIN(); + ret = _orig_tracepath_eglGetImageAttribSEC(dpy, image, attribute, value); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); + return ret; +} + +EGLBoolean +tracepath_eglLockSurfaceKHR(EGLDisplay display, EGLSurface surface, const EGLint *attrib_list) +{ + EGLBoolean ret = EGL_FALSE; + + _COREGL_TRACEPATH_FUNC_BEGIN(); + ret = _orig_tracepath_eglLockSurfaceKHR(display, surface, attrib_list); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); + return ret; +} + +EGLBoolean +tracepath_eglUnlockSurfaceKHR(EGLDisplay display, EGLSurface surface) +{ + EGLBoolean ret = EGL_FALSE; + + _COREGL_TRACEPATH_FUNC_BEGIN(); + ret = _orig_tracepath_eglUnlockSurfaceKHR(display, surface); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); + return ret; +} + diff --git a/src/modules/tracepath/coregl_tracepath_gl.c b/src/modules/tracepath/coregl_tracepath_gl.c new file mode 100644 index 0000000..2d6517e --- /dev/null +++ b/src/modules/tracepath/coregl_tracepath_gl.c @@ -0,0 +1,1844 @@ +#include "coregl_tracepath.h" + +void +tracepath_glActiveTexture(GLenum texture) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glActiveTexture(texture); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glAttachShader(GLuint program, GLuint shader) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glAttachShader(program, shader); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glBindAttribLocation(GLuint program, GLuint index, const char* name) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glBindAttribLocation(program, index, name); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glBindBuffer(GLenum target, GLuint buffer) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glBindBuffer(target, buffer); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glBindFramebuffer(GLenum target, GLuint framebuffer) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glBindFramebuffer(target, framebuffer); + + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glBindRenderbuffer(GLenum target, GLuint renderbuffer) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glBindRenderbuffer(target, renderbuffer); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glBindTexture(GLenum target, GLuint texture) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glBindTexture(target, texture); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glBlendColor(red, green, blue, alpha); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glBlendEquation(GLenum mode) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glBlendEquation(mode); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glBlendEquationSeparate(modeRGB, modeAlpha); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glBlendFunc(GLenum sfactor, GLenum dfactor) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glBlendFunc(sfactor, dfactor); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glBufferData(GLenum target, GLsizeiptr size, const void* data, GLenum usage) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glBufferData(target, size, data, usage); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const void* data) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glBufferSubData(target, offset, size, data); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +GLenum +tracepath_glCheckFramebufferStatus(GLenum target) +{ + GLenum ret = GL_NONE; + + _COREGL_TRACEPATH_FUNC_BEGIN(); + ret = _orig_tracepath_glCheckFramebufferStatus(target); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); + return ret; +} + +void +tracepath_glClear(GLbitfield mask) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glClear(mask); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glClearColor(red, green, blue, alpha); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glClearDepthf(GLclampf depth) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glClearDepthf(depth); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glClearStencil(GLint s) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glClearStencil(s); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glColorMask(red, green, blue, alpha); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glCompileShader(GLuint shader) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glCompileShader(shader); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glCompressedTexImage2D(target, level, internalformat, width, height, border, imageSize, data); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glCompressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize, data); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glCopyTexImage2D(target, level, internalformat, x, y, width, height, border); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +GLuint +tracepath_glCreateProgram(void) +{ + GLuint ret = _COREGL_INT_INIT_VALUE; + + _COREGL_TRACEPATH_FUNC_BEGIN(); + ret = _orig_tracepath_glCreateProgram(); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); + return ret; +} + +GLuint +tracepath_glCreateShader(GLenum type) +{ + GLuint ret = _COREGL_INT_INIT_VALUE; + _COREGL_TRACEPATH_FUNC_BEGIN(); + ret = _orig_tracepath_glCreateShader(type); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); + return ret; +} + +void +tracepath_glCullFace(GLenum mode) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glCullFace(mode); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glDeleteBuffers(GLsizei n, const GLuint* buffers) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glDeleteBuffers(n, buffers); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glDeleteFramebuffers(n, framebuffers); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glDeleteProgram(GLuint program) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glDeleteProgram(program); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glDeleteRenderbuffers(n, renderbuffers); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glDeleteShader(GLuint shader) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glDeleteShader(shader); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glDeleteTextures(GLsizei n, const GLuint* textures) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glDeleteTextures(n, textures); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glDepthFunc(GLenum func) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glDepthFunc(func); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glDepthMask(GLboolean flag) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glDepthMask(flag); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glDepthRangef(GLclampf zNear, GLclampf zFar) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glDepthRangef(zNear, zFar); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glDetachShader(GLuint program, GLuint shader) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glDetachShader(program, shader); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glDisable(GLenum cap) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glDisable(cap); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glDisableVertexAttribArray(GLuint index) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glDisableVertexAttribArray(index); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glDrawArrays(GLenum mode, GLint first, GLsizei count) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glDrawArrays(mode, first, count); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glDrawElements(GLenum mode, GLsizei count, GLenum type, const void* indices) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glDrawElements(mode, count, type, indices); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glEnable(GLenum cap) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glEnable(cap); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glEnableVertexAttribArray(GLuint index) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glEnableVertexAttribArray(index); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glFinish(void) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glFinish(); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); + _COREGL_TRACE_API_OUTPUT(0); +} + +void +tracepath_glFlush(void) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glFlush(); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); + _COREGL_TRACE_API_OUTPUT(0); +} + +void +tracepath_glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glFramebufferRenderbuffer(target, attachment, renderbuffertarget, renderbuffer); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glFramebufferTexture2D(target, attachment, textarget, texture, level); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glFrontFace(GLenum mode) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glFrontFace(mode); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glGetVertexAttribfv(index, pname, params); + + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glGetVertexAttribiv(index, pname, params); + + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glGetVertexAttribPointerv(GLuint index, GLenum pname, void** pointer) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glGetVertexAttribPointerv(index, pname, pointer); + + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glHint(GLenum target, GLenum mode) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glHint(target, mode); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glGenBuffers(GLsizei n, GLuint* buffers) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glGenBuffers(n, buffers); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glGenerateMipmap(GLenum target) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glGenerateMipmap(target); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glGenFramebuffers(GLsizei n, GLuint* framebuffers) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glGenFramebuffers(n, framebuffers); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glGenRenderbuffers(GLsizei n, GLuint* renderbuffers) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glGenRenderbuffers(n, renderbuffers); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glGenTextures(GLsizei n, GLuint* textures) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glGenTextures(n, textures); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glGetActiveAttrib(program, index, bufsize, length, size, type, name); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glGetActiveUniform(program, index, bufsize, length, size, type, name); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glGetAttachedShaders(program, maxcount, count, shaders); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +int +tracepath_glGetAttribLocation(GLuint program, const char* name) +{ + int ret = _COREGL_INT_INIT_VALUE; + _COREGL_TRACEPATH_FUNC_BEGIN(); + ret = _orig_tracepath_glGetAttribLocation(program, name); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); + return ret; +} + +void +tracepath_glGetBooleanv(GLenum pname, GLboolean* params) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glGetBooleanv(pname, params); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glGetBufferParameteriv(GLenum target, GLenum pname, GLint* params) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glGetBufferParameteriv(target, pname, params); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +GLenum +tracepath_glGetError(void) +{ + GLenum ret = GL_NONE; + + _COREGL_TRACEPATH_FUNC_BEGIN(); + ret = _orig_tracepath_glGetError(); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); + return ret; +} + +void +tracepath_glGetFloatv(GLenum pname, GLfloat* params) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glGetFloatv(pname, params); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glGetFramebufferAttachmentParameteriv(target, attachment, pname, params); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glGetIntegerv(GLenum pname, GLint* params) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glGetIntegerv(pname, params); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glGetProgramiv(GLuint program, GLenum pname, GLint* params) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glGetProgramiv(program, pname, params); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, char* infolog) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glGetProgramInfoLog(program, bufsize, length, infolog); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glGetRenderbufferParameteriv(target, pname, params); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glGetShaderiv(GLuint shader, GLenum pname, GLint* params) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glGetShaderiv(shader, pname, params); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glGetShaderInfoLog(shader, bufsize, length, infolog); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glGetShaderPrecisionFormat(shadertype, precisiontype, range, precision); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, char* source) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glGetShaderSource(shader, bufsize, length, source); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +const GLubyte * +tracepath_glGetString(GLenum name) +{ + const GLubyte *ret = NULL; + + _COREGL_TRACEPATH_FUNC_BEGIN(); + ret = _orig_tracepath_glGetString(name); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); + return ret; +} + +void +tracepath_glGetTexParameterfv(GLenum target, GLenum pname, GLfloat* params) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glGetTexParameterfv(target, pname, params); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glGetTexParameteriv(GLenum target, GLenum pname, GLint* params) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glGetTexParameteriv(target, pname, params); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glGetUniformfv(GLuint program, GLint location, GLfloat* params) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glGetUniformfv(program, location, params); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glGetUniformiv(GLuint program, GLint location, GLint* params) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glGetUniformiv(program, location, params); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} +int +tracepath_glGetUniformLocation(GLuint program, const char* name) +{ + int ret = _COREGL_INT_INIT_VALUE; + + _COREGL_TRACEPATH_FUNC_BEGIN(); + ret = _orig_tracepath_glGetUniformLocation(program, name); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); + return ret; +} + +GLboolean +tracepath_glIsBuffer(GLuint buffer) +{ + GLboolean ret = GL_FALSE; + + _COREGL_TRACEPATH_FUNC_BEGIN(); + ret = _orig_tracepath_glIsBuffer(buffer); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); + return ret; +} + +GLboolean +tracepath_glIsEnabled(GLenum cap) +{ + GLboolean ret = GL_FALSE; + + _COREGL_TRACEPATH_FUNC_BEGIN(); + ret = _orig_tracepath_glIsEnabled(cap); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); + return ret; +} + +GLboolean +tracepath_glIsFramebuffer(GLuint framebuffer) +{ + GLboolean ret = GL_FALSE; + + _COREGL_TRACEPATH_FUNC_BEGIN(); + ret = _orig_tracepath_glIsFramebuffer(framebuffer); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); + return ret; +} + +GLboolean +tracepath_glIsProgram(GLuint program) +{ + GLboolean ret; + _COREGL_TRACEPATH_FUNC_BEGIN(); + ret = _orig_tracepath_glIsProgram(program); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); + return ret; +} + +GLboolean +tracepath_glIsRenderbuffer(GLuint renderbuffer) +{ + GLboolean ret; + _COREGL_TRACEPATH_FUNC_BEGIN(); + ret = _orig_tracepath_glIsRenderbuffer(renderbuffer); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); + return ret; +} + +GLboolean +tracepath_glIsShader(GLuint shader) +{ + GLboolean ret; + _COREGL_TRACEPATH_FUNC_BEGIN(); + ret = _orig_tracepath_glIsShader(shader); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); + return ret; +} + +GLboolean +tracepath_glIsTexture(GLuint texture) +{ + GLboolean ret; + _COREGL_TRACEPATH_FUNC_BEGIN(); + ret = _orig_tracepath_glIsTexture(texture); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); + return ret; +} + +void +tracepath_glLineWidth(GLfloat width) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glLineWidth(width); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glLinkProgram(GLuint program) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glLinkProgram(program); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glPixelStorei(GLenum pname, GLint param) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glPixelStorei(pname, param); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glPolygonOffset(GLfloat factor, GLfloat units) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glPolygonOffset(factor, units); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glReadPixels(x, y, width, height, format, type, pixels); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glReleaseShaderCompiler(void) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glReleaseShaderCompiler(); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glRenderbufferStorage(target, internalformat, width, height); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glSampleCoverage(GLclampf value, GLboolean invert) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glSampleCoverage(value, invert); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glScissor(GLint x, GLint y, GLsizei width, GLsizei height) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glScissor(x, y, width, height); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLsizei length) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glShaderBinary(n, shaders, binaryformat, binary, length); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glShaderSource(GLuint shader, GLsizei count, const char** string, const GLint* length) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glShaderSource(shader, count, string, length); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glStencilFunc(GLenum func, GLint ref, GLuint mask) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glStencilFunc(func, ref, mask); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glStencilFuncSeparate(face, func, ref, mask); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glStencilMask(GLuint mask) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glStencilMask(mask); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glStencilMaskSeparate(GLenum face, GLuint mask) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glStencilMaskSeparate(face, mask); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glStencilOp(GLenum fail, GLenum zfail, GLenum zpass) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glStencilOp(fail, zfail, zpass); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glStencilOpSeparate(face, fail, zfail, zpass); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* pixels) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glTexImage2D(target, level, internalformat, width, height, border, format, type, pixels); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glTexParameterf(GLenum target, GLenum pname, GLfloat param) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glTexParameterf(target, pname, param); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glTexParameterfv(GLenum target, GLenum pname, const GLfloat* params) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glTexParameterfv(target, pname, params); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glTexParameteri(GLenum target, GLenum pname, GLint param) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glTexParameteri(target, pname, param); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glTexParameteriv(GLenum target, GLenum pname, const GLint* params) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glTexParameteriv(target, pname, params); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glUniform1f(GLint location, GLfloat x) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glUniform1f(location, x); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glUniform1fv(GLint location, GLsizei count, const GLfloat* v) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glUniform1fv(location, count, v); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glUniform1i(GLint location, GLint x) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glUniform1i(location, x); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glUniform1iv(GLint location, GLsizei count, const GLint* v) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glUniform1iv(location, count, v); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glUniform2f(GLint location, GLfloat x, GLfloat y) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glUniform2f(location, x, y); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glUniform2fv(GLint location, GLsizei count, const GLfloat* v) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glUniform2fv(location, count, v); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glUniform2i(GLint location, GLint x, GLint y) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glUniform2i(location, x, y); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glUniform2iv(GLint location, GLsizei count, const GLint* v) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glUniform2iv(location, count, v); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glUniform3f(location, x, y, z); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glUniform3fv(GLint location, GLsizei count, const GLfloat* v) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glUniform3fv(location, count, v); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glUniform3i(GLint location, GLint x, GLint y, GLint z) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glUniform3i(location, x, y, z); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glUniform3iv(GLint location, GLsizei count, const GLint* v) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glUniform3iv(location, count, v); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glUniform4f(location, x, y, z, w); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glUniform4fv(GLint location, GLsizei count, const GLfloat* v) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glUniform4fv(location, count, v); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glUniform4i(location, x, y, z, w); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glUniform4iv(GLint location, GLsizei count, const GLint* v) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glUniform4iv(location, count, v); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glUniformMatrix2fv(location, count, transpose, value); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glUniformMatrix3fv(location, count, transpose, value); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glUniformMatrix4fv(location, count, transpose, value); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glUseProgram(GLuint program) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glUseProgram(program); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glValidateProgram(GLuint program) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glValidateProgram(program); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glVertexAttrib1f(GLuint indx, GLfloat x) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glVertexAttrib1f(indx, x); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glVertexAttrib1fv(GLuint indx, const GLfloat* values) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glVertexAttrib1fv(indx, values); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glVertexAttrib2f(GLuint indx, GLfloat x, GLfloat y) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glVertexAttrib2f(indx, x, y); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glVertexAttrib2fv(GLuint indx, const GLfloat* values) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glVertexAttrib2fv(indx, values); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glVertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glVertexAttrib3f(indx, x, y, z); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glVertexAttrib3fv(GLuint indx, const GLfloat* values) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glVertexAttrib3fv(indx, values); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glVertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glVertexAttrib4f(indx, x, y, z, w); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glVertexAttrib4fv(GLuint indx, const GLfloat* values) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glVertexAttrib4fv(indx, values); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glVertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glVertexAttribPointer(indx, size, type, normalized, stride, ptr); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glViewport(GLint x, GLint y, GLsizei width, GLsizei height) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glViewport(x, y, width, height); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + + +// GLES Extensions... +void +tracepath_glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glEGLImageTargetTexture2DOES(target, image); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glEGLImageTargetRenderbufferStorageOES(GLenum target, GLeglImageOES image) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glEGLImageTargetRenderbufferStorageOES(target, image); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glGetProgramBinary(GLuint program, GLsizei bufsize, GLsizei* length, GLenum* binaryFormat, void* binary) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glGetProgramBinary(program, bufsize, length, binaryFormat, binary); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glProgramBinary(GLuint program, GLenum binaryFormat, const void* binary, GLint length) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glProgramBinary(program, binaryFormat, binary, length); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + + +void +tracepath_glProgramParameteri(GLuint program, GLuint pname, GLint value) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glProgramParameteri(program, pname, value); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glRenderbufferStorageMultisampleEXT(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glRenderbufferStorageMultisampleEXT(target, samples, internalformat, width, height); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glFramebufferTexture2DMultisampleEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glFramebufferTexture2DMultisampleEXT(target, attachment, textarget, texture, level, samples); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + +void +tracepath_glDiscardFramebufferEXT(GLenum target, GLsizei numAttachments, const GLenum *attachments) +{ + _COREGL_TRACEPATH_FUNC_BEGIN(); + _orig_tracepath_glDiscardFramebufferEXT(target, numAttachments, attachments); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + goto finish; + +finish: + _COREGL_TRACEPATH_FUNC_END(); +} + -- 2.7.4