1 #ifndef COREGL_INTERNAL_H
2 #define COREGL_INTERNAL_H
8 // Symbol definition for real
9 #define _COREGL_SYMBOL(IS_EXTENSION, RET_TYPE, FUNC_NAME, PARAM_LIST) extern RET_TYPE (*_sym_##FUNC_NAME) PARAM_LIST;
10 # include "headers/sym.h"
16 fprintf(stderr, __VA_ARGS__)
19 fprintf(stderr, __VA_ARGS__)
25 fprintf(stderr, __VA_ARGS__)
29 if (!(expr)) { fprintf(stderr, "\E[0;31;1m%s(%d) error. '"#expr"'\E[0m\n", __func__, __LINE__); }
35 typedef GLvoid * GLvoidptr;
36 typedef GLuint GLuintmask;
38 //#define COREGL_TRACE_ALL
39 #define COREGL_TRACE_CONTEXT_INFO
40 #define COREGL_TRACE_STATE_INFO
41 #define COREGL_TRACE_APICALL_INFO
43 #ifdef COREGL_TRACE_ALL
44 #define COREGL_TRACE_CONTEXT_INFO // Context state & thread state & Glue-context info
45 #define COREGL_TRACE_STATE_INFO // Glue-context state info
46 #define COREGL_TRACE_APICALL_INFO // API call frequency info
49 #define _COREGL_TRACE_OUTPUT_INTERVAL_SEC 5
51 #define _COREGL_INT_INIT_VALUE -3
54 # define GLERR(fn, fl, ln, op)
56 # define GLERR(fn, fl, ln, op)
59 #define _COREGL_NAME_MANGLE(name) ovr_##name
61 typedef struct _Trace_Data Trace_Data;
63 #ifdef COREGL_TRACE_APICALL_INFO
64 # define _COREGL_TRACE_API_BEGIN(api, hint, trace_total_time) \
65 trace_begin(api, hint, trace_total_time);
66 # define _COREGL_TRACE_API_END(api, hint, trace_total_time) \
67 trace_end(api, hint, trace_total_time);
68 # define _COREGL_TRACE_API_OUTPUT(force_output) \
69 trace_output(force_output);
71 # define _COREGL_TRACE_API_BEGIN(api, trace_total_time)
72 # define _COREGL_TRACE_API_END(api, trace_total_time)
73 # define _COREGL_TRACE_API_OUTPUT(force_output)
77 #define _COREGL_FAST_FUNC_BEGIN()
79 #define _COREGL_FAST_FUNC_END()
81 #define _COREGL_FAST_FUNC_SYMCALL_BEGIN()
83 #define _COREGL_FAST_FUNC_SYMCALL_END()
85 #define _COREGL_WRAP_FUNC_BEGIN() \
86 static void *trace_hint = NULL; \
87 trace_hint = _COREGL_TRACE_API_BEGIN(__func__, trace_hint, 1);
89 #define _COREGL_WRAP_FUNC_END() \
90 _COREGL_TRACE_API_END(__func__, trace_hint, 1);
92 typedef enum _CoreGL_Opt_Flag
99 extern CoreGL_Opt_Flag api_opt;
101 #ifndef _COREGL_DESKTOP_GL
102 typedef EGLSurface GLSurface;
103 typedef EGLDisplay GLDisplay;
104 typedef EGLContext GLContext;
106 typedef GLXDrawable GLSurface;
107 typedef Display GLDisplay;
108 typedef GLXContext GLContext;
111 typedef struct _GLContextState
119 typedef struct _GLThreadState
123 GLContextState *cstate;
124 GLSurface *rsurf_draw;
125 GLSurface *rsurf_read;
126 Trace_Data **ftd_table;
129 typedef struct _GLContext_List
134 GLContextState *cstate;
135 struct _GLContext_List *next;
138 extern void *glue_lib_handle;
139 extern void *egl_lib_handle;
141 extern GLContext_List *glctx_list;
143 #include "coregl_thread_pthread.h"
144 extern Mutex ctx_list_access_mutex;
146 typedef struct _General_Trace_List
149 struct _General_Trace_List *next;
150 } General_Trace_List;
152 extern General_Trace_List *thread_trace_list;
153 extern Mutex general_trace_lists_access_mutex;
155 extern int trace_api_flag;
156 extern int trace_ctx_flag;
157 extern int trace_state_flag;
158 extern int debug_nofp;
160 // Environment functions
161 extern const char *get_env_setting(const char *name);
163 // Main utility functions
164 extern int init_new_thread_state();
167 extern int mutex_lock(Mutex *mt);
168 extern int mutex_unlock(Mutex *mt);
169 extern int get_current_thread();
170 extern int set_current_thread_state(Mutex *mt, GLThreadState *tstate);
171 extern GLThreadState *get_current_thread_state();
174 // Context state functions
175 extern int add_context_state_to_list(const void *data, const int datalen, GLContextState *cstate, Mutex *mtx);
176 extern int remove_context_states_from_list(GLContextState *cstate, Mutex *mtx);
177 extern GLContextState *get_context_state_from_list(const void *data, const int datalen, Mutex *mtx);
180 // Override functions
181 extern void override_glue_normal_path();
182 extern void override_glue_fast_path();
183 extern void override_gl_normal_path();
184 extern void override_gl_fast_path();
185 extern void override_glue_apis(CoreGL_Opt_Flag opt);
186 extern void override_gl_apis(CoreGL_Opt_Flag opt);
189 // Debug & Trace functions
190 extern int add_to_general_trace_list(General_Trace_List **gtl, void *value);
191 extern int remove_from_general_trace_list(General_Trace_List **gtl, void *value);
192 extern void *trace_begin(const char *name, void *hint, int trace_total_time);
193 extern void *trace_end(const char *name, void *hint, int trace_total_time);
194 extern void trace_output(int force_output);
196 #endif // COREGL_INTERNAL_H