From ec91810147425f4123ec80117109925e054cc66d Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Thu, 25 Feb 2010 17:52:04 +0200 Subject: glapi: minor ugliness to be able to copy to xorg --- src/mesa/glapi/glapi.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) (limited to 'src/mesa/glapi/glapi.c') diff --git a/src/mesa/glapi/glapi.c b/src/mesa/glapi/glapi.c index 469523d57c..631ffba3c7 100644 --- a/src/mesa/glapi/glapi.c +++ b/src/mesa/glapi/glapi.c @@ -51,22 +51,11 @@ #ifdef HAVE_DIX_CONFIG_H - #include -#define PUBLIC - +#include "glapi/mesa.h" #else - #include "main/glheader.h" - -#endif - #include "main/compiler.h" - -#include -#include -#ifdef DEBUG -#include #endif #include "glapi/glapi.h" -- cgit v1.2.3 From f1f33f929366e452046de27429fc730a83d11c4b Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Thu, 25 Feb 2010 17:52:05 +0200 Subject: glapi: EXTRA_DEBUG is never defined, make this explicit --- src/mesa/glapi/glapi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/mesa/glapi/glapi.c') diff --git a/src/mesa/glapi/glapi.c b/src/mesa/glapi/glapi.c index 631ffba3c7..2fa673d307 100644 --- a/src/mesa/glapi/glapi.c +++ b/src/mesa/glapi/glapi.c @@ -490,7 +490,7 @@ _glapi_get_dispatch_table_size(void) void _glapi_check_table(const struct _glapi_table *table) { -#ifdef EXTRA_DEBUG +#if 0 /* Enable this for extra DEBUG */ const GLuint entries = _glapi_get_dispatch_table_size(); const void **tab = (const void **) table; GLuint i; -- cgit v1.2.3 From 42f3241e04b6cd74829dfb64b4a154ac8a4e6a48 Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Sat, 27 Feb 2010 00:24:58 +0200 Subject: glapi.c: split check_table to not_null and get_proc --- src/mesa/glapi/glapi.c | 20 +++++++++++--------- src/mesa/glapi/glapi.h | 16 ++++++++++++---- 2 files changed, 23 insertions(+), 13 deletions(-) (limited to 'src/mesa/glapi/glapi.c') diff --git a/src/mesa/glapi/glapi.c b/src/mesa/glapi/glapi.c index 2fa673d307..764f1dba28 100644 --- a/src/mesa/glapi/glapi.c +++ b/src/mesa/glapi/glapi.c @@ -423,8 +423,9 @@ _glapi_set_dispatch(struct _glapi_table *dispatch) /* use the no-op functions */ dispatch = (struct _glapi_table *) __glapi_noop_table; } -#ifdef DEBUG +#if 0 /* enable this for extra DEBUG */ else { + _glapi_check_table_not_null(dispatch); _glapi_check_table(dispatch); } #endif @@ -488,19 +489,23 @@ _glapi_get_dispatch_table_size(void) * Intended for debugging purposes. */ void -_glapi_check_table(const struct _glapi_table *table) +_glapi_check_table_not_null(const struct _glapi_table *table) { -#if 0 /* Enable this for extra DEBUG */ const GLuint entries = _glapi_get_dispatch_table_size(); const void **tab = (const void **) table; GLuint i; for (i = 1; i < entries; i++) { assert(tab[i]); } +} - /* Do some spot checks to be sure that the dispatch table - * slots are assigned correctly. - */ +/** + * Do some spot checks to be sure that the dispatch table + * slots are assigned correctly. + */ +void +_glapi_check_table(const struct _glapi_table *table) +{ { GLuint BeginOffset = _glapi_get_proc_offset("glBegin"); char *BeginFunc = (char*) &table->Begin; @@ -557,7 +562,4 @@ _glapi_check_table(const struct _glapi_table *table) assert(setFenceOffset == _gloffset_SetFenceNV); assert(setFenceOffset == offset); } -#else - (void) table; -#endif } diff --git a/src/mesa/glapi/glapi.h b/src/mesa/glapi/glapi.h index 27571bdfbb..d84e38ae42 100644 --- a/src/mesa/glapi/glapi.h +++ b/src/mesa/glapi/glapi.h @@ -145,10 +145,6 @@ extern unsigned int _glapi_get_dispatch_table_size(void); -extern void -_glapi_check_table(const struct _glapi_table *table); - - extern int _glapi_add_dispatch( const char * const * function_names, const char * parameter_signature ); @@ -161,6 +157,18 @@ extern _glapi_proc _glapi_get_proc_address(const char *funcName); +/** + * GL API local functions and defines + */ + +extern void +_glapi_check_table_not_null(const struct _glapi_table *table); + + +extern void +_glapi_check_table(const struct _glapi_table *table); + + extern const char * _glapi_get_proc_name(unsigned int offset); -- cgit v1.2.3 From fae5758fac963ce014e3d43f1bca7fb489e02bf9 Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Fri, 26 Feb 2010 20:01:20 +0200 Subject: glapi.c: mv check_table to glapi_getproc.c --- src/mesa/glapi/glapi.c | 66 ----------------------------------------- src/mesa/glapi/glapi_getproc.c | 67 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 66 deletions(-) (limited to 'src/mesa/glapi/glapi.c') diff --git a/src/mesa/glapi/glapi.c b/src/mesa/glapi/glapi.c index 764f1dba28..2fe85a930e 100644 --- a/src/mesa/glapi/glapi.c +++ b/src/mesa/glapi/glapi.c @@ -59,7 +59,6 @@ #endif #include "glapi/glapi.h" -#include "glapi/glapioffsets.h" #include "glapi/glapitable.h" extern _glapi_proc __glapi_noop_table[]; @@ -498,68 +497,3 @@ _glapi_check_table_not_null(const struct _glapi_table *table) assert(tab[i]); } } - -/** - * Do some spot checks to be sure that the dispatch table - * slots are assigned correctly. - */ -void -_glapi_check_table(const struct _glapi_table *table) -{ - { - GLuint BeginOffset = _glapi_get_proc_offset("glBegin"); - char *BeginFunc = (char*) &table->Begin; - GLuint offset = (BeginFunc - (char *) table) / sizeof(void *); - assert(BeginOffset == _gloffset_Begin); - assert(BeginOffset == offset); - } - { - GLuint viewportOffset = _glapi_get_proc_offset("glViewport"); - char *viewportFunc = (char*) &table->Viewport; - GLuint offset = (viewportFunc - (char *) table) / sizeof(void *); - assert(viewportOffset == _gloffset_Viewport); - assert(viewportOffset == offset); - } - { - GLuint VertexPointerOffset = _glapi_get_proc_offset("glVertexPointer"); - char *VertexPointerFunc = (char*) &table->VertexPointer; - GLuint offset = (VertexPointerFunc - (char *) table) / sizeof(void *); - assert(VertexPointerOffset == _gloffset_VertexPointer); - assert(VertexPointerOffset == offset); - } - { - GLuint ResetMinMaxOffset = _glapi_get_proc_offset("glResetMinmax"); - char *ResetMinMaxFunc = (char*) &table->ResetMinmax; - GLuint offset = (ResetMinMaxFunc - (char *) table) / sizeof(void *); - assert(ResetMinMaxOffset == _gloffset_ResetMinmax); - assert(ResetMinMaxOffset == offset); - } - { - GLuint blendColorOffset = _glapi_get_proc_offset("glBlendColor"); - char *blendColorFunc = (char*) &table->BlendColor; - GLuint offset = (blendColorFunc - (char *) table) / sizeof(void *); - assert(blendColorOffset == _gloffset_BlendColor); - assert(blendColorOffset == offset); - } - { - GLuint secondaryColor3fOffset = _glapi_get_proc_offset("glSecondaryColor3fEXT"); - char *secondaryColor3fFunc = (char*) &table->SecondaryColor3fEXT; - GLuint offset = (secondaryColor3fFunc - (char *) table) / sizeof(void *); - assert(secondaryColor3fOffset == _gloffset_SecondaryColor3fEXT); - assert(secondaryColor3fOffset == offset); - } - { - GLuint pointParameterivOffset = _glapi_get_proc_offset("glPointParameterivNV"); - char *pointParameterivFunc = (char*) &table->PointParameterivNV; - GLuint offset = (pointParameterivFunc - (char *) table) / sizeof(void *); - assert(pointParameterivOffset == _gloffset_PointParameterivNV); - assert(pointParameterivOffset == offset); - } - { - GLuint setFenceOffset = _glapi_get_proc_offset("glSetFenceNV"); - char *setFenceFunc = (char*) &table->SetFenceNV; - GLuint offset = (setFenceFunc - (char *) table) / sizeof(void *); - assert(setFenceOffset == _gloffset_SetFenceNV); - assert(setFenceOffset == offset); - } -} diff --git a/src/mesa/glapi/glapi_getproc.c b/src/mesa/glapi/glapi_getproc.c index 69eb42c79e..a0a6ccca09 100644 --- a/src/mesa/glapi/glapi_getproc.c +++ b/src/mesa/glapi/glapi_getproc.c @@ -594,3 +594,70 @@ _glapi_get_proc_name(GLuint offset) } return NULL; } + + + +/** + * Do some spot checks to be sure that the dispatch table + * slots are assigned correctly. For debugging only. + */ +void +_glapi_check_table(const struct _glapi_table *table) +{ + { + GLuint BeginOffset = _glapi_get_proc_offset("glBegin"); + char *BeginFunc = (char*) &table->Begin; + GLuint offset = (BeginFunc - (char *) table) / sizeof(void *); + assert(BeginOffset == _gloffset_Begin); + assert(BeginOffset == offset); + } + { + GLuint viewportOffset = _glapi_get_proc_offset("glViewport"); + char *viewportFunc = (char*) &table->Viewport; + GLuint offset = (viewportFunc - (char *) table) / sizeof(void *); + assert(viewportOffset == _gloffset_Viewport); + assert(viewportOffset == offset); + } + { + GLuint VertexPointerOffset = _glapi_get_proc_offset("glVertexPointer"); + char *VertexPointerFunc = (char*) &table->VertexPointer; + GLuint offset = (VertexPointerFunc - (char *) table) / sizeof(void *); + assert(VertexPointerOffset == _gloffset_VertexPointer); + assert(VertexPointerOffset == offset); + } + { + GLuint ResetMinMaxOffset = _glapi_get_proc_offset("glResetMinmax"); + char *ResetMinMaxFunc = (char*) &table->ResetMinmax; + GLuint offset = (ResetMinMaxFunc - (char *) table) / sizeof(void *); + assert(ResetMinMaxOffset == _gloffset_ResetMinmax); + assert(ResetMinMaxOffset == offset); + } + { + GLuint blendColorOffset = _glapi_get_proc_offset("glBlendColor"); + char *blendColorFunc = (char*) &table->BlendColor; + GLuint offset = (blendColorFunc - (char *) table) / sizeof(void *); + assert(blendColorOffset == _gloffset_BlendColor); + assert(blendColorOffset == offset); + } + { + GLuint secondaryColor3fOffset = _glapi_get_proc_offset("glSecondaryColor3fEXT"); + char *secondaryColor3fFunc = (char*) &table->SecondaryColor3fEXT; + GLuint offset = (secondaryColor3fFunc - (char *) table) / sizeof(void *); + assert(secondaryColor3fOffset == _gloffset_SecondaryColor3fEXT); + assert(secondaryColor3fOffset == offset); + } + { + GLuint pointParameterivOffset = _glapi_get_proc_offset("glPointParameterivNV"); + char *pointParameterivFunc = (char*) &table->PointParameterivNV; + GLuint offset = (pointParameterivFunc - (char *) table) / sizeof(void *); + assert(pointParameterivOffset == _gloffset_PointParameterivNV); + assert(pointParameterivOffset == offset); + } + { + GLuint setFenceOffset = _glapi_get_proc_offset("glSetFenceNV"); + char *setFenceFunc = (char*) &table->SetFenceNV; + GLuint offset = (setFenceFunc - (char *) table) / sizeof(void *); + assert(setFenceOffset == _gloffset_SetFenceNV); + assert(setFenceOffset == offset); + } +} -- cgit v1.2.3 From cccdc1783fda33da6fc12befdf288b74866e5dfa Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Fri, 26 Feb 2010 23:43:46 +0200 Subject: glapi.c: mv init_glapi_relocs to glapi_getproc.c --- src/mesa/glapi/glapi.c | 186 +---------------------------------- src/mesa/glapi/glapi.h | 3 + src/mesa/glapi/glapi_getproc.c | 215 ++++++++++++++++++++++++++++++++++++----- 3 files changed, 196 insertions(+), 208 deletions(-) (limited to 'src/mesa/glapi/glapi.c') diff --git a/src/mesa/glapi/glapi.c b/src/mesa/glapi/glapi.c index 2fe85a930e..5c4a394527 100644 --- a/src/mesa/glapi/glapi.c +++ b/src/mesa/glapi/glapi.c @@ -222,187 +222,6 @@ _glapi_get_context(void) #endif } -#ifdef USE_X86_ASM - -#if defined( GLX_USE_TLS ) -extern GLubyte gl_dispatch_functions_start[]; -extern GLubyte gl_dispatch_functions_end[]; -#else -extern const GLubyte gl_dispatch_functions_start[]; -#endif - -#endif /* USE_X86_ASM */ - - -#if defined(USE_X64_64_ASM) && defined(GLX_USE_TLS) -# define DISPATCH_FUNCTION_SIZE 16 -#elif defined(USE_X86_ASM) -# if defined(THREADS) && !defined(GLX_USE_TLS) -# define DISPATCH_FUNCTION_SIZE 32 -# else -# define DISPATCH_FUNCTION_SIZE 16 -# endif -#endif - -#ifdef USE_SPARC_ASM -#ifdef GLX_USE_TLS -extern unsigned int __glapi_sparc_tls_stub; -#else -extern unsigned int __glapi_sparc_pthread_stub; -#endif -#endif - -#if !defined(DISPATCH_FUNCTION_SIZE) && !defined(XFree86Server) && !defined(XGLServer) -# define NEED_FUNCTION_POINTER -#endif - -#if defined(PTHREADS) || defined(GLX_USE_TLS) -/** - * Perform platform-specific GL API entry-point fixups. - */ -static void -init_glapi_relocs( void ) -{ -#if defined(USE_X86_ASM) && defined(GLX_USE_TLS) && !defined(GLX_X86_READONLY_TEXT) - extern unsigned long _x86_get_dispatch(void); - char run_time_patch[] = { - 0x65, 0xa1, 0, 0, 0, 0 /* movl %gs:0,%eax */ - }; - GLuint *offset = (GLuint *) &run_time_patch[2]; /* 32-bits for x86/32 */ - const GLubyte * const get_disp = (const GLubyte *) run_time_patch; - GLubyte * curr_func = (GLubyte *) gl_dispatch_functions_start; - - *offset = _x86_get_dispatch(); - while ( curr_func != (GLubyte *) gl_dispatch_functions_end ) { - (void) memcpy( curr_func, get_disp, sizeof(run_time_patch)); - curr_func += DISPATCH_FUNCTION_SIZE; - } -#endif -#ifdef USE_SPARC_ASM - extern void __glapi_sparc_icache_flush(unsigned int *); - static const unsigned int template[] = { -#ifdef GLX_USE_TLS - 0x05000000, /* sethi %hi(_glapi_tls_Dispatch), %g2 */ - 0x8730e00a, /* srl %g3, 10, %g3 */ - 0x8410a000, /* or %g2, %lo(_glapi_tls_Dispatch), %g2 */ -#ifdef __arch64__ - 0xc259c002, /* ldx [%g7 + %g2], %g1 */ - 0xc2584003, /* ldx [%g1 + %g3], %g1 */ -#else - 0xc201c002, /* ld [%g7 + %g2], %g1 */ - 0xc2004003, /* ld [%g1 + %g3], %g1 */ -#endif - 0x81c04000, /* jmp %g1 */ - 0x01000000, /* nop */ -#else -#ifdef __arch64__ - 0x03000000, /* 64-bit 0x00 --> sethi %hh(_glapi_Dispatch), %g1 */ - 0x05000000, /* 64-bit 0x04 --> sethi %lm(_glapi_Dispatch), %g2 */ - 0x82106000, /* 64-bit 0x08 --> or %g1, %hm(_glapi_Dispatch), %g1 */ - 0x8730e00a, /* 64-bit 0x0c --> srl %g3, 10, %g3 */ - 0x83287020, /* 64-bit 0x10 --> sllx %g1, 32, %g1 */ - 0x82004002, /* 64-bit 0x14 --> add %g1, %g2, %g1 */ - 0xc2586000, /* 64-bit 0x18 --> ldx [%g1 + %lo(_glapi_Dispatch)], %g1 */ -#else - 0x03000000, /* 32-bit 0x00 --> sethi %hi(_glapi_Dispatch), %g1 */ - 0x8730e00a, /* 32-bit 0x04 --> srl %g3, 10, %g3 */ - 0xc2006000, /* 32-bit 0x08 --> ld [%g1 + %lo(_glapi_Dispatch)], %g1 */ -#endif - 0x80a06000, /* --> cmp %g1, 0 */ - 0x02800005, /* --> be +4*5 */ - 0x01000000, /* --> nop */ -#ifdef __arch64__ - 0xc2584003, /* 64-bit --> ldx [%g1 + %g3], %g1 */ -#else - 0xc2004003, /* 32-bit --> ld [%g1 + %g3], %g1 */ -#endif - 0x81c04000, /* --> jmp %g1 */ - 0x01000000, /* --> nop */ -#ifdef __arch64__ - 0x9de3bf80, /* 64-bit --> save %sp, -128, %sp */ -#else - 0x9de3bfc0, /* 32-bit --> save %sp, -64, %sp */ -#endif - 0xa0100003, /* --> mov %g3, %l0 */ - 0x40000000, /* --> call _glapi_get_dispatch */ - 0x01000000, /* --> nop */ - 0x82100008, /* --> mov %o0, %g1 */ - 0x86100010, /* --> mov %l0, %g3 */ - 0x10bffff7, /* --> ba -4*9 */ - 0x81e80000, /* --> restore */ -#endif - }; -#ifdef GLX_USE_TLS - extern unsigned long __glapi_sparc_get_dispatch(void); - unsigned int *code = &__glapi_sparc_tls_stub; - unsigned long dispatch = __glapi_sparc_get_dispatch(); -#else - unsigned int *code = &__glapi_sparc_pthread_stub; - unsigned long dispatch = (unsigned long) &_glapi_Dispatch; - unsigned long call_dest = (unsigned long ) &_glapi_get_dispatch; - int idx; -#endif - -#if defined(GLX_USE_TLS) - code[0] = template[0] | (dispatch >> 10); - code[1] = template[1]; - __glapi_sparc_icache_flush(&code[0]); - code[2] = template[2] | (dispatch & 0x3ff); - code[3] = template[3]; - __glapi_sparc_icache_flush(&code[2]); - code[4] = template[4]; - code[5] = template[5]; - __glapi_sparc_icache_flush(&code[4]); - code[6] = template[6]; - __glapi_sparc_icache_flush(&code[6]); -#else -#if defined(__arch64__) - code[0] = template[0] | (dispatch >> (32 + 10)); - code[1] = template[1] | ((dispatch & 0xffffffff) >> 10); - __glapi_sparc_icache_flush(&code[0]); - code[2] = template[2] | ((dispatch >> 32) & 0x3ff); - code[3] = template[3]; - __glapi_sparc_icache_flush(&code[2]); - code[4] = template[4]; - code[5] = template[5]; - __glapi_sparc_icache_flush(&code[4]); - code[6] = template[6] | (dispatch & 0x3ff); - idx = 7; -#else - code[0] = template[0] | (dispatch >> 10); - code[1] = template[1]; - __glapi_sparc_icache_flush(&code[0]); - code[2] = template[2] | (dispatch & 0x3ff); - idx = 3; -#endif - code[idx + 0] = template[idx + 0]; - __glapi_sparc_icache_flush(&code[idx - 1]); - code[idx + 1] = template[idx + 1]; - code[idx + 2] = template[idx + 2]; - __glapi_sparc_icache_flush(&code[idx + 1]); - code[idx + 3] = template[idx + 3]; - code[idx + 4] = template[idx + 4]; - __glapi_sparc_icache_flush(&code[idx + 3]); - code[idx + 5] = template[idx + 5]; - code[idx + 6] = template[idx + 6]; - __glapi_sparc_icache_flush(&code[idx + 5]); - code[idx + 7] = template[idx + 7]; - code[idx + 8] = template[idx + 8] | - (((call_dest - ((unsigned long) &code[idx + 8])) - >> 2) & 0x3fffffff); - __glapi_sparc_icache_flush(&code[idx + 7]); - code[idx + 9] = template[idx + 9]; - code[idx + 10] = template[idx + 10]; - __glapi_sparc_icache_flush(&code[idx + 9]); - code[idx + 11] = template[idx + 11]; - code[idx + 12] = template[idx + 12]; - __glapi_sparc_icache_flush(&code[idx + 11]); - code[idx + 13] = template[idx + 13]; - __glapi_sparc_icache_flush(&code[idx + 13]); -#endif -#endif -} -#endif /* defined(PTHREADS) || defined(GLX_USE_TLS) */ /** @@ -413,10 +232,7 @@ init_glapi_relocs( void ) PUBLIC void _glapi_set_dispatch(struct _glapi_table *dispatch) { -#if defined(PTHREADS) || defined(GLX_USE_TLS) - static pthread_once_t once_control = PTHREAD_ONCE_INIT; - pthread_once( & once_control, init_glapi_relocs ); -#endif + init_glapi_relocs_once(); if (!dispatch) { /* use the no-op functions */ diff --git a/src/mesa/glapi/glapi.h b/src/mesa/glapi/glapi.h index d84e38ae42..0abec5df76 100644 --- a/src/mesa/glapi/glapi.h +++ b/src/mesa/glapi/glapi.h @@ -161,6 +161,9 @@ _glapi_get_proc_address(const char *funcName); * GL API local functions and defines */ +extern void +init_glapi_relocs_once(void); + extern void _glapi_check_table_not_null(const struct _glapi_table *table); diff --git a/src/mesa/glapi/glapi_getproc.c b/src/mesa/glapi/glapi_getproc.c index a0a6ccca09..5be6d65b56 100644 --- a/src/mesa/glapi/glapi_getproc.c +++ b/src/mesa/glapi/glapi_getproc.c @@ -43,27 +43,6 @@ #include "glapi/glapitable.h" -static void -fill_in_entrypoint_offset(_glapi_proc entrypoint, GLuint offset); - - -/** - * strdup() is actually not a standard ANSI C or POSIX routine. - * Irix will not define it if ANSI mode is in effect. - */ -static char * -str_dup(const char *str) -{ - char *copy; - copy = (char*) malloc(strlen(str) + 1); - if (!copy) - return NULL; - strcpy(copy, str); - return copy; -} - - - #if defined(USE_X64_64_ASM) && defined(GLX_USE_TLS) # define DISPATCH_FUNCTION_SIZE 16 #elif defined(USE_X86_ASM) @@ -121,7 +100,6 @@ get_static_proc_offset(const char *funcName) } -#if !defined(XFree86Server) && !defined(XGLServer) #ifdef USE_X86_ASM #if defined( GLX_USE_TLS ) @@ -134,6 +112,8 @@ extern const GLubyte gl_dispatch_functions_start[]; #endif /* USE_X86_ASM */ +#if !defined(XFree86Server) && !defined(XGLServer) + /** * Return dispatch function address for the named static (built-in) function. * Return NULL if function not found. @@ -182,6 +162,172 @@ get_static_proc_name( GLuint offset ) +#if defined(PTHREADS) || defined(GLX_USE_TLS) + +/** + * Perform platform-specific GL API entry-point fixups. + */ +static void +init_glapi_relocs( void ) +{ +#if defined(USE_X86_ASM) && defined(GLX_USE_TLS) && !defined(GLX_X86_READONLY_TEXT) + extern unsigned long _x86_get_dispatch(void); + char run_time_patch[] = { + 0x65, 0xa1, 0, 0, 0, 0 /* movl %gs:0,%eax */ + }; + GLuint *offset = (GLuint *) &run_time_patch[2]; /* 32-bits for x86/32 */ + const GLubyte * const get_disp = (const GLubyte *) run_time_patch; + GLubyte * curr_func = (GLubyte *) gl_dispatch_functions_start; + + *offset = _x86_get_dispatch(); + while ( curr_func != (GLubyte *) gl_dispatch_functions_end ) { + (void) memcpy( curr_func, get_disp, sizeof(run_time_patch)); + curr_func += DISPATCH_FUNCTION_SIZE; + } +#endif +#ifdef USE_SPARC_ASM + extern void __glapi_sparc_icache_flush(unsigned int *); + static const unsigned int template[] = { +#ifdef GLX_USE_TLS + 0x05000000, /* sethi %hi(_glapi_tls_Dispatch), %g2 */ + 0x8730e00a, /* srl %g3, 10, %g3 */ + 0x8410a000, /* or %g2, %lo(_glapi_tls_Dispatch), %g2 */ +#ifdef __arch64__ + 0xc259c002, /* ldx [%g7 + %g2], %g1 */ + 0xc2584003, /* ldx [%g1 + %g3], %g1 */ +#else + 0xc201c002, /* ld [%g7 + %g2], %g1 */ + 0xc2004003, /* ld [%g1 + %g3], %g1 */ +#endif + 0x81c04000, /* jmp %g1 */ + 0x01000000, /* nop */ +#else +#ifdef __arch64__ + 0x03000000, /* 64-bit 0x00 --> sethi %hh(_glapi_Dispatch), %g1 */ + 0x05000000, /* 64-bit 0x04 --> sethi %lm(_glapi_Dispatch), %g2 */ + 0x82106000, /* 64-bit 0x08 --> or %g1, %hm(_glapi_Dispatch), %g1 */ + 0x8730e00a, /* 64-bit 0x0c --> srl %g3, 10, %g3 */ + 0x83287020, /* 64-bit 0x10 --> sllx %g1, 32, %g1 */ + 0x82004002, /* 64-bit 0x14 --> add %g1, %g2, %g1 */ + 0xc2586000, /* 64-bit 0x18 --> ldx [%g1 + %lo(_glapi_Dispatch)], %g1 */ +#else + 0x03000000, /* 32-bit 0x00 --> sethi %hi(_glapi_Dispatch), %g1 */ + 0x8730e00a, /* 32-bit 0x04 --> srl %g3, 10, %g3 */ + 0xc2006000, /* 32-bit 0x08 --> ld [%g1 + %lo(_glapi_Dispatch)], %g1 */ +#endif + 0x80a06000, /* --> cmp %g1, 0 */ + 0x02800005, /* --> be +4*5 */ + 0x01000000, /* --> nop */ +#ifdef __arch64__ + 0xc2584003, /* 64-bit --> ldx [%g1 + %g3], %g1 */ +#else + 0xc2004003, /* 32-bit --> ld [%g1 + %g3], %g1 */ +#endif + 0x81c04000, /* --> jmp %g1 */ + 0x01000000, /* --> nop */ +#ifdef __arch64__ + 0x9de3bf80, /* 64-bit --> save %sp, -128, %sp */ +#else + 0x9de3bfc0, /* 32-bit --> save %sp, -64, %sp */ +#endif + 0xa0100003, /* --> mov %g3, %l0 */ + 0x40000000, /* --> call _glapi_get_dispatch */ + 0x01000000, /* --> nop */ + 0x82100008, /* --> mov %o0, %g1 */ + 0x86100010, /* --> mov %l0, %g3 */ + 0x10bffff7, /* --> ba -4*9 */ + 0x81e80000, /* --> restore */ +#endif + }; +#ifdef GLX_USE_TLS + extern unsigned int __glapi_sparc_tls_stub; + extern unsigned long __glapi_sparc_get_dispatch(void); + unsigned int *code = &__glapi_sparc_tls_stub; + unsigned long dispatch = __glapi_sparc_get_dispatch(); +#else + extern unsigned int __glapi_sparc_pthread_stub; + unsigned int *code = &__glapi_sparc_pthread_stub; + unsigned long dispatch = (unsigned long) &_glapi_Dispatch; + unsigned long call_dest = (unsigned long ) &_glapi_get_dispatch; + int idx; +#endif + +#if defined(GLX_USE_TLS) + code[0] = template[0] | (dispatch >> 10); + code[1] = template[1]; + __glapi_sparc_icache_flush(&code[0]); + code[2] = template[2] | (dispatch & 0x3ff); + code[3] = template[3]; + __glapi_sparc_icache_flush(&code[2]); + code[4] = template[4]; + code[5] = template[5]; + __glapi_sparc_icache_flush(&code[4]); + code[6] = template[6]; + __glapi_sparc_icache_flush(&code[6]); +#else +#if defined(__arch64__) + code[0] = template[0] | (dispatch >> (32 + 10)); + code[1] = template[1] | ((dispatch & 0xffffffff) >> 10); + __glapi_sparc_icache_flush(&code[0]); + code[2] = template[2] | ((dispatch >> 32) & 0x3ff); + code[3] = template[3]; + __glapi_sparc_icache_flush(&code[2]); + code[4] = template[4]; + code[5] = template[5]; + __glapi_sparc_icache_flush(&code[4]); + code[6] = template[6] | (dispatch & 0x3ff); + idx = 7; +#else + code[0] = template[0] | (dispatch >> 10); + code[1] = template[1]; + __glapi_sparc_icache_flush(&code[0]); + code[2] = template[2] | (dispatch & 0x3ff); + idx = 3; +#endif + code[idx + 0] = template[idx + 0]; + __glapi_sparc_icache_flush(&code[idx - 1]); + code[idx + 1] = template[idx + 1]; + code[idx + 2] = template[idx + 2]; + __glapi_sparc_icache_flush(&code[idx + 1]); + code[idx + 3] = template[idx + 3]; + code[idx + 4] = template[idx + 4]; + __glapi_sparc_icache_flush(&code[idx + 3]); + code[idx + 5] = template[idx + 5]; + code[idx + 6] = template[idx + 6]; + __glapi_sparc_icache_flush(&code[idx + 5]); + code[idx + 7] = template[idx + 7]; + code[idx + 8] = template[idx + 8] | + (((call_dest - ((unsigned long) &code[idx + 8])) + >> 2) & 0x3fffffff); + __glapi_sparc_icache_flush(&code[idx + 7]); + code[idx + 9] = template[idx + 9]; + code[idx + 10] = template[idx + 10]; + __glapi_sparc_icache_flush(&code[idx + 9]); + code[idx + 11] = template[idx + 11]; + code[idx + 12] = template[idx + 12]; + __glapi_sparc_icache_flush(&code[idx + 11]); + code[idx + 13] = template[idx + 13]; + __glapi_sparc_icache_flush(&code[idx + 13]); +#endif +#endif +} + +void +init_glapi_relocs_once( void ) +{ + static pthread_once_t once_control = PTHREAD_ONCE_INIT; + pthread_once( & once_control, init_glapi_relocs ); +} + +#else + +void +init_glapi_relocs_once( void ) { } + +#endif /* defined(PTHREADS) || defined(GLX_USE_TLS) */ + + + /********************************************************************** * Extension function management. */ @@ -239,6 +385,9 @@ static GLuint NumExtEntryPoints = 0; extern void __glapi_sparc_icache_flush(unsigned int *); #endif +static void +fill_in_entrypoint_offset(_glapi_proc entrypoint, GLuint offset); + /** * Generate a dispatch function (entrypoint) which jumps through * the given slot number (offset) in the current dispatch table. @@ -263,7 +412,9 @@ generate_entrypoint(GLuint functionOffset) } return (_glapi_proc) code; -#elif defined(USE_SPARC_ASM) && (defined(PTHREADS) || defined(GLX_USE_TLS)) +#elif defined(USE_SPARC_ASM) + +#if defined(PTHREADS) || defined(GLX_USE_TLS) static const unsigned int template[] = { 0x07000000, /* sethi %hi(0), %g3 */ 0x8210000f, /* mov %o7, %g1 */ @@ -289,6 +440,8 @@ generate_entrypoint(GLuint functionOffset) __glapi_sparc_icache_flush(&code[2]); } return (_glapi_proc) code; +#endif + #else (void) functionOffset; return NULL; @@ -332,6 +485,22 @@ fill_in_entrypoint_offset(_glapi_proc entrypoint, GLuint offset) } +/** + * strdup() is actually not a standard ANSI C or POSIX routine. + * Irix will not define it if ANSI mode is in effect. + */ +static char * +str_dup(const char *str) +{ + char *copy; + copy = (char*) malloc(strlen(str) + 1); + if (!copy) + return NULL; + strcpy(copy, str); + return copy; +} + + /** * Generate new entrypoint * -- cgit v1.2.3 From 7b454b00a4423937bd83ecff2d61ff08e6504707 Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Sat, 27 Feb 2010 15:19:44 +0200 Subject: glapi.c: misc cosmetic mainly, move the multithread check mutex out of the dispatch/context block, closer to where it is used. --- src/mesa/glapi/glapi.c | 61 +++++++++++++++++++++++++++----------------------- 1 file changed, 33 insertions(+), 28 deletions(-) (limited to 'src/mesa/glapi/glapi.c') diff --git a/src/mesa/glapi/glapi.c b/src/mesa/glapi/glapi.c index 5c4a394527..fe523073ca 100644 --- a/src/mesa/glapi/glapi.c +++ b/src/mesa/glapi/glapi.c @@ -105,24 +105,17 @@ PUBLIC __thread void * _glapi_tls_Context __attribute__((tls_model("initial-exec"))); PUBLIC const struct _glapi_table *_glapi_Dispatch = NULL; + PUBLIC const void *_glapi_Context = NULL; #else #if defined(THREADS) -#ifdef WIN32_THREADS -/* _glthread_DECLARE_STATIC_MUTEX is broken on windows. There will be race! */ -#define CHECK_MULTITHREAD_LOCK() -#define CHECK_MULTITHREAD_UNLOCK() -#else -_glthread_DECLARE_STATIC_MUTEX(ThreadCheckMutex); -#define CHECK_MULTITHREAD_LOCK() _glthread_LOCK_MUTEX(ThreadCheckMutex) -#define CHECK_MULTITHREAD_UNLOCK() _glthread_UNLOCK_MUTEX(ThreadCheckMutex) -#endif - static GLboolean ThreadSafe = GL_FALSE; /**< In thread-safe mode? */ + _glthread_TSD _gl_DispatchTSD; /**< Per-thread dispatch pointer */ + static _glthread_TSD ContextTSD; /**< Per-thread context pointer */ #if defined(WIN32_THREADS) @@ -136,8 +129,8 @@ void FreeAllTSD(void) #endif /* defined(THREADS) */ -PUBLIC struct _glapi_table *_glapi_Dispatch = - (struct _glapi_table *) __glapi_noop_table; +PUBLIC struct _glapi_table *_glapi_Dispatch = (struct _glapi_table *) __glapi_noop_table; + PUBLIC void *_glapi_Context = NULL; #endif /* defined(GLX_USE_TLS) */ @@ -145,6 +138,20 @@ PUBLIC void *_glapi_Context = NULL; +#if defined(THREADS) && !defined(GLX_USE_TLS) + +/** + * Mutex for multithread check. + */ +#ifdef WIN32_THREADS +/* _glthread_DECLARE_STATIC_MUTEX is broken on windows. There will be race! */ +#define CHECK_MULTITHREAD_LOCK() +#define CHECK_MULTITHREAD_UNLOCK() +#else +_glthread_DECLARE_STATIC_MUTEX(ThreadCheckMutex); +#define CHECK_MULTITHREAD_LOCK() _glthread_LOCK_MUTEX(ThreadCheckMutex) +#define CHECK_MULTITHREAD_UNLOCK() _glthread_UNLOCK_MUTEX(ThreadCheckMutex) +#endif /** * We should call this periodically from a function such as glXMakeCurrent @@ -153,7 +160,6 @@ PUBLIC void *_glapi_Context = NULL; PUBLIC void _glapi_check_multithread(void) { -#if defined(THREADS) && !defined(GLX_USE_TLS) static unsigned long knownID; static GLboolean firstCall = GL_TRUE; @@ -175,9 +181,15 @@ _glapi_check_multithread(void) _glapi_set_context(NULL); } CHECK_MULTITHREAD_UNLOCK(); -#endif } +#else + +PUBLIC void +_glapi_check_multithread(void) { } + +#endif + /** @@ -211,12 +223,7 @@ _glapi_get_context(void) #if defined(GLX_USE_TLS) return _glapi_tls_Context; #elif defined(THREADS) - if (ThreadSafe) { - return _glthread_GetTSD(&ContextTSD); - } - else { - return _glapi_Context; - } + return (ThreadSafe) ? _glthread_GetTSD(&ContextTSD) : _glapi_Context; #else return _glapi_Context; #endif @@ -234,7 +241,7 @@ _glapi_set_dispatch(struct _glapi_table *dispatch) { init_glapi_relocs_once(); - if (!dispatch) { + if (dispatch == NULL) { /* use the no-op functions */ dispatch = (struct _glapi_table *) __glapi_noop_table; } @@ -250,9 +257,9 @@ _glapi_set_dispatch(struct _glapi_table *dispatch) #elif defined(THREADS) _glthread_SetTSD(&_gl_DispatchTSD, (void *) dispatch); _glapi_Dispatch = (ThreadSafe) ? NULL : dispatch; -#else /*THREADS*/ +#else _glapi_Dispatch = dispatch; -#endif /*THREADS*/ +#endif } @@ -263,17 +270,15 @@ _glapi_set_dispatch(struct _glapi_table *dispatch) PUBLIC struct _glapi_table * _glapi_get_dispatch(void) { - struct _glapi_table * api; #if defined(GLX_USE_TLS) - api = _glapi_tls_Dispatch; + return _glapi_tls_Dispatch; #elif defined(THREADS) - api = (ThreadSafe) + return (ThreadSafe) ? (struct _glapi_table *) _glthread_GetTSD(&_gl_DispatchTSD) : _glapi_Dispatch; #else - api = _glapi_Dispatch; + return _glapi_Dispatch; #endif - return api; } -- cgit v1.2.3 From d41ab94d35cb47effbd2582289298be4f13c50e4 Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Mon, 1 Mar 2010 04:44:02 +0200 Subject: glapi.c: misc coscmetic for FreeTSD - move out of of the dispatch/context block to after corresponding init functions - use more consistent naming with corresponding init functions - XXX use _glthread_InitTSD() vs (void)_glthread_GetTSD() in _glapi_check_multithread() XXX --- src/gallium/state_trackers/wgl/stw_device.c | 4 ++-- src/mesa/glapi/glapi.c | 35 +++++++++++++++++++---------- src/mesa/glapi/glapi.h | 8 +++++++ src/mesa/glapi/glthread.c | 23 ++++++++++--------- src/mesa/glapi/glthread.h | 4 ++++ 5 files changed, 50 insertions(+), 24 deletions(-) (limited to 'src/mesa/glapi/glapi.c') diff --git a/src/gallium/state_trackers/wgl/stw_device.c b/src/gallium/state_trackers/wgl/stw_device.c index e5fa6ac8eb..472a2a5379 100644 --- a/src/gallium/state_trackers/wgl/stw_device.c +++ b/src/gallium/state_trackers/wgl/stw_device.c @@ -47,7 +47,6 @@ #ifdef WIN32_THREADS extern _glthread_Mutex OneTimeLock; -extern void FreeAllTSD(void); #endif @@ -183,7 +182,8 @@ stw_cleanup(void) #ifdef WIN32_THREADS _glthread_DESTROY_MUTEX(OneTimeLock); - FreeAllTSD(); + + _glapi_destroy_multithread(); #endif #ifdef DEBUG diff --git a/src/mesa/glapi/glapi.c b/src/mesa/glapi/glapi.c index fe523073ca..056abd7233 100644 --- a/src/mesa/glapi/glapi.c +++ b/src/mesa/glapi/glapi.c @@ -118,15 +118,6 @@ _glthread_TSD _gl_DispatchTSD; /**< Per-thread dispatch pointer */ static _glthread_TSD ContextTSD; /**< Per-thread context pointer */ -#if defined(WIN32_THREADS) -void FreeTSD(_glthread_TSD *p); -void FreeAllTSD(void) -{ - FreeTSD(&_gl_DispatchTSD); - FreeTSD(&ContextTSD); -} -#endif /* defined(WIN32_THREADS) */ - #endif /* defined(THREADS) */ PUBLIC struct _glapi_table *_glapi_Dispatch = (struct _glapi_table *) __glapi_noop_table; @@ -140,6 +131,22 @@ PUBLIC void *_glapi_Context = NULL; #if defined(THREADS) && !defined(GLX_USE_TLS) +void +_glapi_init_multithread(void) +{ + _glthread_InitTSD(&_gl_DispatchTSD); + _glthread_InitTSD(&ContextTSD); +} + +void +_glapi_destroy_multithread(void) +{ +#ifdef WIN32_THREADS + _glthread_DestroyTSD(&_gl_DispatchTSD); + _glthread_DestroyTSD(&ContextTSD); +#endif +} + /** * Mutex for multithread check. */ @@ -168,9 +175,7 @@ _glapi_check_multithread(void) CHECK_MULTITHREAD_LOCK(); if (firstCall) { - /* initialize TSDs */ - (void) _glthread_GetTSD(&ContextTSD); - (void) _glthread_GetTSD(&_gl_DispatchTSD); + _glapi_init_multithread(void) knownID = _glthread_GetID(); firstCall = GL_FALSE; @@ -185,6 +190,12 @@ _glapi_check_multithread(void) #else +void +_glapi_init_multithread(void) { } + +void +_glapi_destroy_multithread(void) { } + PUBLIC void _glapi_check_multithread(void) { } diff --git a/src/mesa/glapi/glapi.h b/src/mesa/glapi/glapi.h index 0abec5df76..2eae6d5c43 100644 --- a/src/mesa/glapi/glapi.h +++ b/src/mesa/glapi/glapi.h @@ -121,6 +121,14 @@ extern void *_glapi_Context; ** GL API public functions **/ +extern void +_glapi_init_multithread(void); + + +extern void +_glapi_destroy_multithread(void); + + extern void _glapi_check_multithread(void); diff --git a/src/mesa/glapi/glthread.c b/src/mesa/glapi/glthread.c index be4e2f754d..15401d730e 100644 --- a/src/mesa/glapi/glthread.c +++ b/src/mesa/glapi/glthread.c @@ -190,17 +190,9 @@ _glthread_SetTSD(_glthread_TSD *tsd, void *ptr) */ #ifdef WIN32_THREADS -void FreeTSD(_glthread_TSD *p) +static void InsteadOf_exit(int nCode) { - if (p->initMagic==INIT_MAGIC) { - TlsFree(p->key); - p->initMagic=0; - } -} - -void InsteadOf_exit(int nCode) -{ - DWORD dwErr=GetLastError(); + DWORD dwErr = GetLastError(); } PUBLIC unsigned long @@ -222,6 +214,17 @@ _glthread_InitTSD(_glthread_TSD *tsd) } +void +_glthread_DestroyTSD(_glthread_TSD *tsd) +{ + if (tsd->initMagic != INIT_MAGIC) { + return; + } + TlsFree(tsd->key); + tsd->initMagic = 0x0; +} + + void * _glthread_GetTSD(_glthread_TSD *tsd) { diff --git a/src/mesa/glapi/glthread.h b/src/mesa/glapi/glthread.h index be39501395..389c24204b 100644 --- a/src/mesa/glapi/glthread.h +++ b/src/mesa/glapi/glthread.h @@ -315,6 +315,10 @@ extern void _glthread_InitTSD(_glthread_TSD *); +extern void +_glthread_DestroyTSD(_glthread_TSD *); /* WIN32 only */ + + extern void * _glthread_GetTSD(_glthread_TSD *); -- cgit v1.2.3 From 6e48f17a1620dda83e0fedd68a8f004ed1fbfea9 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 1 Mar 2010 23:18:29 +0000 Subject: glapi: Fix syntax. --- src/mesa/glapi/glapi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/mesa/glapi/glapi.c') diff --git a/src/mesa/glapi/glapi.c b/src/mesa/glapi/glapi.c index 056abd7233..fcb30895aa 100644 --- a/src/mesa/glapi/glapi.c +++ b/src/mesa/glapi/glapi.c @@ -175,7 +175,7 @@ _glapi_check_multithread(void) CHECK_MULTITHREAD_LOCK(); if (firstCall) { - _glapi_init_multithread(void) + _glapi_init_multithread(); knownID = _glthread_GetID(); firstCall = GL_FALSE; -- cgit v1.2.3 From d3f24ab33c284325abaf4b250f8928d4d53836e1 Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Tue, 2 Mar 2010 03:31:16 +0200 Subject: glapi: fix compile with ES --- src/mesa/glapi/glapi.c | 6 +++++- src/mesa/glapi/glapi_getproc.c | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'src/mesa/glapi/glapi.c') diff --git a/src/mesa/glapi/glapi.c b/src/mesa/glapi/glapi.c index fcb30895aa..13de594aaf 100644 --- a/src/mesa/glapi/glapi.c +++ b/src/mesa/glapi/glapi.c @@ -256,7 +256,7 @@ _glapi_set_dispatch(struct _glapi_table *dispatch) /* use the no-op functions */ dispatch = (struct _glapi_table *) __glapi_noop_table; } -#if 0 /* enable this for extra DEBUG */ +#ifdef DEBUG else { _glapi_check_table_not_null(dispatch); _glapi_check_table(dispatch); @@ -322,10 +322,14 @@ _glapi_get_dispatch_table_size(void) void _glapi_check_table_not_null(const struct _glapi_table *table) { +#if 0 /* enable this for extra DEBUG */ const GLuint entries = _glapi_get_dispatch_table_size(); const void **tab = (const void **) table; GLuint i; for (i = 1; i < entries; i++) { assert(tab[i]); } +#else + (void) table; +#endif } diff --git a/src/mesa/glapi/glapi_getproc.c b/src/mesa/glapi/glapi_getproc.c index 5be6d65b56..a6dbf173e8 100644 --- a/src/mesa/glapi/glapi_getproc.c +++ b/src/mesa/glapi/glapi_getproc.c @@ -773,6 +773,7 @@ _glapi_get_proc_name(GLuint offset) void _glapi_check_table(const struct _glapi_table *table) { +#if 0 /* enable this for extra DEBUG */ { GLuint BeginOffset = _glapi_get_proc_offset("glBegin"); char *BeginFunc = (char*) &table->Begin; @@ -829,4 +830,7 @@ _glapi_check_table(const struct _glapi_table *table) assert(setFenceOffset == _gloffset_SetFenceNV); assert(setFenceOffset == offset); } +#else + (void) table; +#endif } -- cgit v1.2.3 From 2c8b5ffed9a787e896b540a95be48ef401d5f007 Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Tue, 9 Mar 2010 22:03:24 +0200 Subject: glapi: mv table functions to glapi_getproc.c and add local header --- src/mesa/glapi/glapi.c | 44 +-------------------------------- src/mesa/glapi/glapi.h | 21 ---------------- src/mesa/glapi/glapi_getproc.c | 56 ++++++++++++++++++++++++++++++++++++++++-- src/mesa/glapi/glapi_priv.h | 43 ++++++++++++++++++++++++++++++++ 4 files changed, 98 insertions(+), 66 deletions(-) create mode 100644 src/mesa/glapi/glapi_priv.h (limited to 'src/mesa/glapi/glapi.c') diff --git a/src/mesa/glapi/glapi.c b/src/mesa/glapi/glapi.c index 13de594aaf..ce85cf6a87 100644 --- a/src/mesa/glapi/glapi.c +++ b/src/mesa/glapi/glapi.c @@ -59,7 +59,7 @@ #endif #include "glapi/glapi.h" -#include "glapi/glapitable.h" +#include "glapi/glapi_priv.h" extern _glapi_proc __glapi_noop_table[]; @@ -291,45 +291,3 @@ _glapi_get_dispatch(void) return _glapi_Dispatch; #endif } - - - - -/* - * The dispatch table size (number of entries) is the size of the - * _glapi_table struct plus the number of dynamic entries we can add. - * The extra slots can be filled in by DRI drivers that register new extension - * functions. - */ -#define DISPATCH_TABLE_SIZE (sizeof(struct _glapi_table) / sizeof(void *) + MAX_EXTENSION_FUNCS) - - -/** - * Return size of dispatch table struct as number of functions (or - * slots). - */ -PUBLIC GLuint -_glapi_get_dispatch_table_size(void) -{ - return DISPATCH_TABLE_SIZE; -} - - -/** - * Make sure there are no NULL pointers in the given dispatch table. - * Intended for debugging purposes. - */ -void -_glapi_check_table_not_null(const struct _glapi_table *table) -{ -#if 0 /* enable this for extra DEBUG */ - const GLuint entries = _glapi_get_dispatch_table_size(); - const void **tab = (const void **) table; - GLuint i; - for (i = 1; i < entries; i++) { - assert(tab[i]); - } -#else - (void) table; -#endif -} diff --git a/src/mesa/glapi/glapi.h b/src/mesa/glapi/glapi.h index 1ca2e4beff..7dcf2e8910 100644 --- a/src/mesa/glapi/glapi.h +++ b/src/mesa/glapi/glapi.h @@ -165,29 +165,8 @@ extern _glapi_proc _glapi_get_proc_address(const char *funcName); -/** - * GL API local functions and defines - */ - -extern void -init_glapi_relocs_once(void); - -extern void -_glapi_check_table_not_null(const struct _glapi_table *table); - - -extern void -_glapi_check_table(const struct _glapi_table *table); - - extern const char * _glapi_get_proc_name(unsigned int offset); -/* - * Number of extension functions which we can dynamically add at runtime. - */ -#define MAX_EXTENSION_FUNCS 300 - - #endif diff --git a/src/mesa/glapi/glapi_getproc.c b/src/mesa/glapi/glapi_getproc.c index 2b89a8f4f4..fbf48f1388 100644 --- a/src/mesa/glapi/glapi_getproc.c +++ b/src/mesa/glapi/glapi_getproc.c @@ -39,8 +39,9 @@ #endif #include "glapi/glapi.h" -#include "glapi/glapioffsets.h" +#include "glapi/glapi_priv.h" #include "glapi/glapitable.h" +#include "glapi/glapioffsets.h" #if defined(USE_X64_64_ASM) && defined(GLX_USE_TLS) @@ -378,6 +379,12 @@ struct _glapi_function { }; +/* + * Number of extension functions which we can dynamically add at runtime. + */ +#define MAX_EXTENSION_FUNCS 300 + + static struct _glapi_function ExtEntryTable[MAX_EXTENSION_FUNCS]; static GLuint NumExtEntryPoints = 0; @@ -766,6 +773,51 @@ _glapi_get_proc_name(GLuint offset) +/********************************************************************** + * GL API table functions. + */ + + +/* + * The dispatch table size (number of entries) is the size of the + * _glapi_table struct plus the number of dynamic entries we can add. + * The extra slots can be filled in by DRI drivers that register new extension + * functions. + */ +#define DISPATCH_TABLE_SIZE (sizeof(struct _glapi_table) / sizeof(void *) + MAX_EXTENSION_FUNCS) + + +/** + * Return size of dispatch table struct as number of functions (or + * slots). + */ +PUBLIC GLuint +_glapi_get_dispatch_table_size(void) +{ + return DISPATCH_TABLE_SIZE; +} + + +/** + * Make sure there are no NULL pointers in the given dispatch table. + * Intended for debugging purposes. + */ +void +_glapi_check_table_not_null(const struct _glapi_table *table) +{ +#ifdef EXTRA_DEBUG /* set to DEBUG for extra DEBUG */ + const GLuint entries = _glapi_get_dispatch_table_size(); + const void **tab = (const void **) table; + GLuint i; + for (i = 1; i < entries; i++) { + assert(tab[i]); + } +#else + (void) table; +#endif +} + + /** * Do some spot checks to be sure that the dispatch table * slots are assigned correctly. For debugging only. @@ -773,7 +825,7 @@ _glapi_get_proc_name(GLuint offset) void _glapi_check_table(const struct _glapi_table *table) { -#if 0 /* enable this for extra DEBUG */ +#ifdef EXTRA_DEBUG /* set to DEBUG for extra DEBUG */ { GLuint BeginOffset = _glapi_get_proc_offset("glBegin"); char *BeginFunc = (char*) &table->Begin; diff --git a/src/mesa/glapi/glapi_priv.h b/src/mesa/glapi/glapi_priv.h new file mode 100644 index 0000000000..05eda99ccf --- /dev/null +++ b/src/mesa/glapi/glapi_priv.h @@ -0,0 +1,43 @@ +/* + * Mesa 3-D graphics library + * Version: 7.1 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#ifndef _GLAPI_PRIV_H +#define _GLAPI_PRIV_H + +#include "glthread.h" + +extern void +_glapi_check_table_not_null(const struct _glapi_table *table); + + +extern void +_glapi_check_table(const struct _glapi_table *table); + + +extern void +init_glapi_relocs_once(void); + + +#endif -- cgit v1.2.3