summaryrefslogtreecommitdiff
path: root/src/dispatch_common.h
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2014-03-28 12:49:28 -0700
committerEric Anholt <eric@anholt.net>2014-03-28 16:33:53 -0700
commit370c49d5cdd8060ea2fee1e777311f86b495aa94 (patch)
tree641b30922f904411b2875862bfbe6411ffbe3053 /src/dispatch_common.h
parent11a946cbf5ebd4ba79915ab06434847ae2581e47 (diff)
downloadlibepoxy-370c49d5cdd8060ea2fee1e777311f86b495aa94.tar.gz
Use #defines to shrink the size of gl_generated_dispatch.c
I was running into file size limits with win32 debug symbols.
Diffstat (limited to 'src/dispatch_common.h')
-rw-r--r--src/dispatch_common.h93
1 files changed, 86 insertions, 7 deletions
diff --git a/src/dispatch_common.h b/src/dispatch_common.h
index a0722ff..aa8d04e 100644
--- a/src/dispatch_common.h
+++ b/src/dispatch_common.h
@@ -27,15 +27,18 @@
#define PLATFORM_HAS_EGL 0
#define PLATFORM_HAS_GLX 0
#define PLATFORM_HAS_WGL 1
-#define EPOXYAPIENTRY __declspec(dllexport) __stdcall
+#define EPOXYCALL __stdcall
+#define EPOXYAPIENTRY __declspec(dllexport) EPOXYCALL
#elif defined(__APPLE__)
#define PLATFORM_HAS_EGL 0
#define PLATFORM_HAS_GLX 1
#define PLATFORM_HAS_WGL 0
+#define EPOXYCALL
#else
#define PLATFORM_HAS_EGL 1
#define PLATFORM_HAS_GLX 1
#define PLATFORM_HAS_WGL 0
+#define EPOXYCALL
#endif
#include "epoxy/gl.h"
@@ -73,6 +76,76 @@
#define WRAPPER_VISIBILITY static GLAPIENTRY
#define WRAPPER(x) x ## _wrapped
+#if USING_DISPATCH_TABLE
+#define GEN_GLOBAL_REWRITE_PTR(name, args, passthrough)
+#define GEN_GLOBAL_REWRITE_PTR_RET(ret, name, args, passthrough)
+
+#define GEN_DISPATCH_TABLE_REWRITE_PTR(name, args, passthrough) \
+ static EPOXYCALL void \
+ name##_dispatch_table_rewrite_ptr args \
+ { \
+ struct dispatch_table *dispatch_table = get_dispatch_table(); \
+ \
+ dispatch_table->name = (void *)name##_resolver(); \
+ dispatch_table->name passthrough; \
+ }
+
+#define GEN_DISPATCH_TABLE_REWRITE_PTR_RET(ret, name, args, passthrough) \
+ static EPOXYCALL ret \
+ name##_dispatch_table_rewrite_ptr args \
+ { \
+ struct dispatch_table *dispatch_table = get_dispatch_table(); \
+ \
+ dispatch_table->name = (void *)name##_resolver(); \
+ return dispatch_table->name passthrough; \
+ }
+
+#define GEN_DISPATCH_TABLE_THUNK(name, args, passthrough) \
+ static EPOXYCALL void \
+ name##_dispatch_table_thunk args \
+ { \
+ get_dispatch_table()->name passthrough; \
+ }
+
+#define GEN_DISPATCH_TABLE_THUNK_RET(ret, name, args, passthrough) \
+ static EPOXYCALL ret \
+ name##_dispatch_table_thunk args \
+ { \
+ return get_dispatch_table()->name passthrough; \
+ }
+
+#else
+#define GEN_GLOBAL_REWRITE_PTR(name, args, passthrough) \
+ static EPOXYCALL void \
+ name##_global_rewrite_ptr args \
+ { \
+ name = (void *)name##_resolver(); \
+ name passthrough; \
+ }
+
+#define GEN_GLOBAL_REWRITE_PTR_RET(ret, name, args, passthrough) \
+ static EPOXYCALL ret \
+ name##_global_rewrite_ptr args \
+ { \
+ name = (void *)name##_resolver(); \
+ return name passthrough; \
+ }
+#define GEN_DISPATCH_TABLE_REWRITE_PTR(name, args, passthrough)
+#define GEN_DISPATCH_TABLE_REWRITE_PTR_RET(ret, name, args, passthrough)
+#define GEN_DISPATCH_TABLE_THUNK(name, args, passthrough)
+#define GEN_DISPATCH_TABLE_THUNK_RET(ret, name, args, passthrough)
+#endif
+
+#define GEN_THUNKS(name, args, passthrough) \
+ GEN_GLOBAL_REWRITE_PTR(name, args, passthrough) \
+ GEN_DISPATCH_TABLE_REWRITE_PTR(name, args, passthrough) \
+ GEN_DISPATCH_TABLE_THUNK(name, args, passthrough)
+
+#define GEN_THUNKS_RET(ret, name, args, passthrough) \
+ GEN_GLOBAL_REWRITE_PTR_RET(ret, name, args, passthrough) \
+ GEN_DISPATCH_TABLE_REWRITE_PTR_RET(ret, name, args, passthrough) \
+ GEN_DISPATCH_TABLE_THUNK_RET(ret, name, args, passthrough)
+
void *epoxy_egl_dlsym(const char *name);
void *epoxy_glx_dlsym(const char *name);
void *epoxy_gl_dlsym(const char *name);
@@ -96,16 +169,22 @@ void epoxy_print_failure_reasons(const char *name,
bool epoxy_extension_in_string(const char *extension_list, const char *ext);
-extern void UNWRAPPED_PROTO(epoxy_glBegin_unwrapped)(GLenum primtype);
-extern void UNWRAPPED_PROTO(epoxy_glEnd_unwrapped)(void);
+#define glBegin_unwrapped epoxy_glBegin_unwrapped
+#define glEnd_unwrapped epoxy_glEnd_unwrapped
+extern void UNWRAPPED_PROTO(glBegin_unwrapped)(GLenum primtype);
+extern void UNWRAPPED_PROTO(glEnd_unwrapped)(void);
#if USING_DISPATCH_TABLE
void gl_init_dispatch_table(void);
void wgl_init_dispatch_table(void);
extern uint32_t gl_tls_index, gl_tls_size;
extern uint32_t wgl_tls_index, wgl_tls_size;
-extern BOOL UNWRAPPED_PROTO(epoxy_wglMakeCurrent_unwrapped)(HDC hdc, HGLRC hglrc);
-extern BOOL UNWRAPPED_PROTO(epoxy_wglMakeContextCurrentARB_unwrapped)(HDC hDrawDC, HDC hReadDC, HGLRC hglrc);
-extern BOOL UNWRAPPED_PROTO(epoxy_wglMakeContextCurrentEXT_unwrapped)(HDC hDrawDC, HDC hReadDC, HGLRC hglrc);
-extern BOOL UNWRAPPED_PROTO(epoxy_wglMakeAssociatedContextCurrentAMD_unwrapped)(HGLRC hglrc);
+#define wglMakeCurrent_unwrapped epoxy_wglMakeCurrent_unwrapped
+#define wglMakeContextCurrentARB_unwrapped epoxy_wglMakeContextCurrentARB_unwrapped
+#define wglMakeContextCurrentEXT_unwrapped epoxy_wglMakeContextCurrentEXT_unwrapped
+#define wglMakeAssociatedContextCurrentAMD_unwrapped epoxy_wglMakeAssociatedContextCurrentAMD_unwrapped
+extern BOOL UNWRAPPED_PROTO(wglMakeCurrent_unwrapped)(HDC hdc, HGLRC hglrc);
+extern BOOL UNWRAPPED_PROTO(wglMakeContextCurrentARB_unwrapped)(HDC hDrawDC, HDC hReadDC, HGLRC hglrc);
+extern BOOL UNWRAPPED_PROTO(wglMakeContextCurrentEXT_unwrapped)(HDC hDrawDC, HDC hReadDC, HGLRC hglrc);
+extern BOOL UNWRAPPED_PROTO(wglMakeAssociatedContextCurrentAMD_unwrapped)(HGLRC hglrc);
#endif