diff options
author | Ian Romanick <idr@us.ibm.com> | 2006-08-22 18:22:20 +0000 |
---|---|---|
committer | Ian Romanick <idr@us.ibm.com> | 2006-08-22 18:22:20 +0000 |
commit | d319edff1e34696ac165bb553d085e8f2e3df4e3 (patch) | |
tree | ff6c1bedf8ff4b806afd5eeba72551ceb406f9a6 | |
parent | 4e4b5f40081cb3e4cefe4dce30712d8d330c0774 (diff) |
The TLS dispatch functions for x86-64 are fixed-size, just like on
x86. This means that the position of each dispatch function can be
calculated as (dispatch_offset * size_of_function) + glNewList. This
allows us to not store the function pointers in glprocs_table_t.
This same optimization has been done for quite some time on x86. We
could probably also do this for some cases of the SPARC dispatch as
well.
-rw-r--r-- | src/mesa/glapi/glapi.c | 40 |
1 files changed, 22 insertions, 18 deletions
diff --git a/src/mesa/glapi/glapi.c b/src/mesa/glapi/glapi.c index b82304b2fc..e7a1b3b160 100644 --- a/src/mesa/glapi/glapi.c +++ b/src/mesa/glapi/glapi.c @@ -357,8 +357,18 @@ _glapi_get_dispatch(void) *** functionality. ***/ -#if !defined( USE_X86_ASM ) && !defined( XFree86Server ) && !defined ( XGLServer ) -#define NEED_FUNCTION_POINTER +#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 + +#if !defined(DISPATCH_FUNCTION_SIZE) && !defined(XFree86Server) && !defined(XGLServer) +# define NEED_FUNCTION_POINTER #endif /* The code in this file is auto-generated with Python */ @@ -408,12 +418,6 @@ extern GLubyte gl_dispatch_functions_end[]; extern const GLubyte gl_dispatch_functions_start[]; #endif -# if defined(THREADS) && !defined(GLX_USE_TLS) -# define X86_DISPATCH_FUNCTION_SIZE 32 -# else -# define X86_DISPATCH_FUNCTION_SIZE 16 -# endif - #endif /* USE_X86_ASM */ @@ -426,9 +430,9 @@ get_static_proc_address(const char *funcName) { const glprocs_table_t * const f = find_entry( funcName ); if (f) { -#ifdef USE_X86_ASM +#ifdef DISPATCH_FUNCTION_SIZE return (_glapi_proc) (gl_dispatch_functions_start - + (X86_DISPATCH_FUNCTION_SIZE * f->Offset)); + + (DISPATCH_FUNCTION_SIZE * f->Offset)); #else return f->Address; #endif @@ -545,12 +549,12 @@ generate_entrypoint(GLuint functionOffset) * "jmp OFFSET*4(%eax)" can't be encoded in a single byte. */ const GLubyte * const template_func = gl_dispatch_functions_start - + (X86_DISPATCH_FUNCTION_SIZE * 32); - GLubyte * const code = (GLubyte *) malloc( X86_DISPATCH_FUNCTION_SIZE ); + + (DISPATCH_FUNCTION_SIZE * 32); + GLubyte * const code = (GLubyte *) malloc(DISPATCH_FUNCTION_SIZE); if ( code != NULL ) { - (void) memcpy( code, template_func, X86_DISPATCH_FUNCTION_SIZE ); + (void) memcpy(code, template_func, DISPATCH_FUNCTION_SIZE); fill_in_entrypoint_offset( (_glapi_proc) code, functionOffset ); } @@ -621,15 +625,15 @@ fill_in_entrypoint_offset(_glapi_proc entrypoint, GLuint offset) #if defined(USE_X86_ASM) GLubyte * const code = (GLubyte *) entrypoint; -#if X86_DISPATCH_FUNCTION_SIZE == 32 +#if DISPATCH_FUNCTION_SIZE == 32 *((unsigned int *)(code + 11)) = 4 * offset; *((unsigned int *)(code + 22)) = 4 * offset; -#elif X86_DISPATCH_FUNCTION_SIZE == 16 && defined( GLX_USE_TLS ) +#elif DISPATCH_FUNCTION_SIZE == 16 && defined( GLX_USE_TLS ) *((unsigned int *)(code + 8)) = 4 * offset; -#elif X86_DISPATCH_FUNCTION_SIZE == 16 +#elif DISPATCH_FUNCTION_SIZE == 16 *((unsigned int *)(code + 7)) = 4 * offset; #else -# error Invalid X86_DISPATCH_FUNCTION_SIZE! +# error Invalid DISPATCH_FUNCTION_SIZE! #endif #elif defined(USE_SPARC_ASM) @@ -1042,7 +1046,7 @@ init_glapi_relocs( void ) while ( curr_func != (GLubyte *) gl_dispatch_functions_end ) { (void) memcpy( curr_func, get_disp, 6 ); - curr_func += X86_DISPATCH_FUNCTION_SIZE; + curr_func += DISPATCH_FUNCTION_SIZE; } #endif /* defined( USE_X86_ASM ) && defined( GLX_USE_TLS ) */ } |