Merge branch 'gallium-0.1' into gallium-tex-surfaces
[mesa.git] / src / mesa / glapi / glapi.c
index 95edbc9071ed5ce940ce2229dda1b025ddf2c326..47c57822732e7f15f8c57500f014a4eaf6ebf632 100644 (file)
@@ -240,6 +240,7 @@ _glapi_check_multithread(void)
       else if (knownID != _glthread_GetID()) {
          ThreadSafe = GL_TRUE;
          _glapi_set_dispatch(NULL);
+         _glapi_set_context(NULL);
       }
    }
    else if (!_glapi_get_dispatch()) {
@@ -430,7 +431,12 @@ get_static_proc_address(const char *funcName)
 {
    const glprocs_table_t * const f = find_entry( funcName );
    if (f) {
-#ifdef DISPATCH_FUNCTION_SIZE
+#if defined(DISPATCH_FUNCTION_SIZE) && defined(GLX_INDIRECT_RENDERING)
+      return (f->Address == NULL)
+        ? (_glapi_proc) (gl_dispatch_functions_start
+                         + (DISPATCH_FUNCTION_SIZE * f->Offset))
+         : f->Address;
+#elif defined(DISPATCH_FUNCTION_SIZE)
       return (_glapi_proc) (gl_dispatch_functions_start 
                             + (DISPATCH_FUNCTION_SIZE * f->Offset));
 #else
@@ -992,20 +998,12 @@ _glapi_check_table(const struct _glapi_table *table)
       assert(blendColorOffset == _gloffset_BlendColor);
       assert(blendColorOffset == offset);
    }
-   {
-      GLuint istextureOffset = _glapi_get_proc_offset("glIsTextureEXT");
-      char *istextureFunc = (char*) &table->IsTextureEXT;
-      GLuint offset = (istextureFunc - (char *) table) / sizeof(void *);
-      assert(istextureOffset == _gloffset_IsTextureEXT);
-      assert(istextureOffset == 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);
-      assert(_glapi_get_proc_address("glSecondaryColor3fEXT") == (_glapi_proc) &glSecondaryColor3fEXT);
    }
    {
       GLuint pointParameterivOffset = _glapi_get_proc_offset("glPointParameterivNV");
@@ -1013,7 +1011,6 @@ _glapi_check_table(const struct _glapi_table *table)
       GLuint offset = (pointParameterivFunc - (char *) table) / sizeof(void *);
       assert(pointParameterivOffset == _gloffset_PointParameterivNV);
       assert(pointParameterivOffset == offset);
-      assert(_glapi_get_proc_address("glPointParameterivNV") == (_glapi_proc) &glPointParameterivNV);
    }
    {
       GLuint setFenceOffset = _glapi_get_proc_offset("glSetFenceNV");
@@ -1031,22 +1028,24 @@ _glapi_check_table(const struct _glapi_table *table)
 #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 )
-    extern void * _x86_get_dispatch(void);
-    const GLubyte * const get_disp = (const GLubyte *) _x86_get_dispatch;
+#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, );
+       (void) memcpy( curr_func, get_disp, sizeof(run_time_patch));
        curr_func += DISPATCH_FUNCTION_SIZE;
     }
-#endif /* defined( USE_X86_ASM ) && defined( GLX_USE_TLS ) */
-}
 #endif
+}
+#endif /* defined(PTHREADS) || defined(GLX_USE_TLS) */