3 * Mesa 3-D graphics library
6 * Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the "Software"),
10 * to deal in the Software without restriction, including without limitation
11 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 * and/or sell copies of the Software, and to permit persons to whom the
13 * Software is furnished to do so, subject to the following conditions:
15 * The above copyright notice and this permission notice shall be included
16 * in all copies or substantial portions of the Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
22 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 * This file manages the OpenGL API dispatch layer.
29 * The dispatch table (struct _glapi_table) is basically just a list
30 * of function pointers.
31 * There are functions to set/get the current dispatch table for the
32 * current thread and to manage registration/dispatch of dynamically
33 * added extension functions.
35 * It's intended that this file and the other glapi*.[ch] files are
36 * flexible enough to be reused in several places: XFree86, DRI-
37 * based libGL.so, and perhaps the SGI SI.
39 * NOTE: There are no dependencies on Mesa in this code.
41 * Versions (API changes):
42 * 2000/02/23 - original version for Mesa 3.3 and XFree86 4.0
43 * 2001/01/16 - added dispatch override feature for Mesa 3.5
44 * 2002/06/28 - added _glapi_set_warning_func(), Mesa 4.1.
45 * 2002/10/01 - _glapi_get_proc_address() will now generate new entrypoints
46 * itself (using offset ~0). _glapi_add_entrypoint() can be
47 * called afterward and it'll fill in the correct dispatch
48 * offset. This allows DRI libGL to avoid probing for DRI
49 * drivers! No changes to the public glapi interface.
56 #include "glapioffsets.h"
57 #include "glapitable.h"
60 /***** BEGIN NO-OP DISPATCH *****/
62 static GLboolean WarnFlag
= GL_FALSE
;
63 static _glapi_warning_func warning_func
;
67 * Enable/disable printing of warning messages.
70 _glapi_noop_enable_warnings(GLboolean enable
)
76 * Register a callback function for reporting errors.
79 _glapi_set_warning_func( _glapi_warning_func func
)
87 if ((WarnFlag
|| getenv("MESA_DEBUG") || getenv("LIBGL_DEBUG"))
97 #define KEYWORD1 static
98 #define KEYWORD2 GLAPIENTRY
99 #define NAME(func) NoOp##func
103 #define DISPATCH(func, args, msg) \
105 warning_func(NULL, "GL User Error: called without context:"); \
109 #define RETURN_DISPATCH(func, args, msg) \
111 warning_func(NULL, "GL User Error: called without context:"); \
116 #define DISPATCH_TABLE_NAME __glapi_noop_table
117 #define UNUSED_TABLE_NAME __usused_noop_functions
119 #define TABLE_ENTRY(name) (void *) NoOp##name
121 static int NoOpUnused(void)
124 warning_func(NULL
, "GL User Error: calling extension function without a current context\n");
129 #include "glapitemp.h"
131 /***** END NO-OP DISPATCH *****/
135 /***** BEGIN THREAD-SAFE DISPATCH *****/
140 * \name Multi-threaded control support variables
142 * If thread-safety is supported, there are two potential mechanisms that can
143 * be used. The old-style mechanism would set \c _glapi_Dispatch to a special
144 * thread-safe dispatch table. These dispatch routines would call
145 * \c _glapi_get_dispatch to get the actual dispatch pointer. In this
146 * setup \c _glapi_Dispatch could never be \c NULL. This dual layered
147 * dispatch setup performed great for single-threaded apps, but didn't
148 * perform well for multithreaded apps.
150 * In the new mechansim, there are two variables. The first is
151 * \c _glapi_DispatchTSD. In the single-threaded case, this variable points
152 * to the dispatch table. In the multi-threaded case, this variable is
153 * \c NULL, and thread-specific variable \c _gl_DispatchTSD points to the
154 * actual dispatch table. \c _glapi_DispatchTSD is used to signal to the
155 * static dispatch functions to call \c _glapi_get_dispatch to get the real
158 * There is a race condition in setting \c _glapi_DispatchTSD to \c NULL.
159 * It is possible for the original thread to be setting it at the same instant
160 * a new thread, perhaps running on a different processor, is clearing it.
161 * Because of that, \c ThreadSafe, which can only ever be changed to
162 * \c GL_TRUE, is used to determine whether or not the application is
166 static GLboolean ThreadSafe
= GL_FALSE
; /**< In thread-safe mode? */
167 _glthread_TSD _gl_DispatchTSD
; /**< Per-thread dispatch pointer */
168 static _glthread_TSD RealDispatchTSD
; /**< only when using override */
169 static _glthread_TSD ContextTSD
; /**< Per-thread context pointer */
173 #define DISPATCH_TABLE_NAME __glapi_threadsafe_table
174 #define UNUSED_TABLE_NAME __usused_threadsafe_functions
176 #define TABLE_ENTRY(name) (void *) gl##name
178 static int glUnused(void)
183 #include "glapitemp.h"
187 /***** END THREAD-SAFE DISPATCH *****/
191 struct _glapi_table
*_glapi_Dispatch
= (struct _glapi_table
*) __glapi_noop_table
;
192 #if defined( THREADS )
193 struct _glapi_table
*_glapi_DispatchTSD
= (struct _glapi_table
*) __glapi_noop_table
;
195 struct _glapi_table
*_glapi_RealDispatch
= (struct _glapi_table
*) __glapi_noop_table
;
198 /* Used when thread safety disabled */
199 void *_glapi_Context
= NULL
;
202 static GLboolean DispatchOverride
= GL_FALSE
;
206 /* strdup() is actually not a standard ANSI C or POSIX routine.
207 * Irix will not define it if ANSI mode is in effect.
210 str_dup(const char *str
)
213 copy
= (char*) malloc(strlen(str
) + 1);
223 * We should call this periodically from a function such as glXMakeCurrent
224 * in order to test if multiple threads are being used.
227 _glapi_check_multithread(void)
231 static unsigned long knownID
;
232 static GLboolean firstCall
= GL_TRUE
;
234 knownID
= _glthread_GetID();
235 firstCall
= GL_FALSE
;
237 else if (knownID
!= _glthread_GetID()) {
238 ThreadSafe
= GL_TRUE
;
239 _glapi_set_dispatch(NULL
);
242 else if (!_glapi_get_dispatch()) {
243 /* make sure that this thread's dispatch pointer isn't null */
244 _glapi_set_dispatch(NULL
);
252 * Set the current context pointer for this thread.
253 * The context pointer is an opaque type which should be cast to
254 * void from the real context pointer type.
257 _glapi_set_context(void *context
)
260 _glthread_SetTSD(&ContextTSD
, context
);
261 _glapi_Context
= (ThreadSafe
) ? NULL
: context
;
263 _glapi_Context
= context
;
270 * Get the current context pointer for this thread.
271 * The context pointer is an opaque type which should be cast from
272 * void to the real context pointer type.
275 _glapi_get_context(void)
279 return _glthread_GetTSD(&ContextTSD
);
282 return _glapi_Context
;
285 return _glapi_Context
;
292 * Set the global or per-thread dispatch table pointer.
295 _glapi_set_dispatch(struct _glapi_table
*dispatch
)
298 /* use the no-op functions */
299 dispatch
= (struct _glapi_table
*) __glapi_noop_table
;
303 _glapi_check_table(dispatch
);
308 if (DispatchOverride
) {
309 _glthread_SetTSD(&RealDispatchTSD
, (void *) dispatch
);
311 _glapi_RealDispatch
= (struct _glapi_table
*) __glapi_threadsafe_table
;
313 _glapi_RealDispatch
= dispatch
;
316 /* normal operation */
317 _glthread_SetTSD(&_gl_DispatchTSD
, (void *) dispatch
);
319 _glapi_Dispatch
= (struct _glapi_table
*) __glapi_threadsafe_table
;
320 _glapi_DispatchTSD
= NULL
;
323 _glapi_Dispatch
= dispatch
;
324 _glapi_DispatchTSD
= dispatch
;
328 if (DispatchOverride
) {
329 _glapi_RealDispatch
= dispatch
;
332 _glapi_Dispatch
= dispatch
;
340 * Return pointer to current dispatch table for calling thread.
342 struct _glapi_table
*
343 _glapi_get_dispatch(void)
347 if (DispatchOverride
) {
348 return (struct _glapi_table
*) _glthread_GetTSD(&RealDispatchTSD
);
351 return (struct _glapi_table
*) _glthread_GetTSD(&_gl_DispatchTSD
);
355 if (DispatchOverride
) {
356 assert(_glapi_RealDispatch
);
357 return _glapi_RealDispatch
;
360 assert(_glapi_DispatchTSD
);
361 return _glapi_DispatchTSD
;
365 return _glapi_Dispatch
;
371 * Notes on dispatch overrride:
373 * Dispatch override allows an external agent to hook into the GL dispatch
374 * mechanism before execution goes into the core rendering library. For
375 * example, a trace mechanism would insert itself as an overrider, print
376 * logging info for each GL function, then dispatch to the real GL function.
378 * libGLS (GL Stream library) is another agent that might use override.
380 * We don't allow more than one layer of overriding at this time.
381 * In the future we may allow nested/layered override. In that case
382 * _glapi_begin_dispatch_override() will return an override layer,
383 * _glapi_end_dispatch_override(layer) will remove an override layer
384 * and _glapi_get_override_dispatch(layer) will return the dispatch
385 * table for a given override layer. layer = 0 will be the "real"
390 * Return: dispatch override layer number.
393 _glapi_begin_dispatch_override(struct _glapi_table
*override
)
395 struct _glapi_table
*real
= _glapi_get_dispatch();
397 assert(!DispatchOverride
); /* can't nest at this time */
398 DispatchOverride
= GL_TRUE
;
400 _glapi_set_dispatch(real
);
403 _glthread_SetTSD(&_gl_DispatchTSD
, (void *) override
);
405 _glapi_Dispatch
= (struct _glapi_table
*) __glapi_threadsafe_table
;
406 _glapi_DispatchTSD
= NULL
;
409 _glapi_Dispatch
= override
;
410 _glapi_DispatchTSD
= override
;
413 _glapi_Dispatch
= override
;
420 _glapi_end_dispatch_override(int layer
)
422 struct _glapi_table
*real
= _glapi_get_dispatch();
424 DispatchOverride
= GL_FALSE
;
425 _glapi_set_dispatch(real
);
426 /* the rest of this isn't needed, just play it safe */
428 _glthread_SetTSD(&RealDispatchTSD
, NULL
);
430 _glapi_RealDispatch
= NULL
;
434 struct _glapi_table
*
435 _glapi_get_override_dispatch(int layer
)
438 return _glapi_get_dispatch();
441 if (DispatchOverride
) {
443 return (struct _glapi_table
*) _glthread_GetTSD(&_gl_DispatchTSD
);
445 return _glapi_Dispatch
;
455 struct name_address_offset
{
462 #if !defined( USE_X86_ASM )
463 #define NEED_FUNCTION_POINTER
466 /* The code in this file is auto-generated with Python */
470 static const glprocs_table_t
*
471 find_entry( const char * n
)
475 for ( i
= 0 ; static_functions
[i
].Name_offset
>= 0 ; i
++ ) {
476 const char * test_name
;
478 test_name
= gl_string_table
+ static_functions
[i
].Name_offset
;
479 if (strcmp(test_name
, n
) == 0) {
480 return & static_functions
[i
];
487 * Return dispatch table offset of the named static (built-in) function.
488 * Return -1 if function not found.
491 get_static_proc_offset(const char *funcName
)
493 const glprocs_table_t
* const f
= find_entry( funcName
);
503 extern const GLubyte gl_dispatch_functions_start
[];
505 # if defined(THREADS)
506 # define X86_DISPATCH_FUNCTION_SIZE 32
508 # define X86_DISPATCH_FUNCTION_SIZE 16
513 * Return dispatch function address the named static (built-in) function.
514 * Return NULL if function not found.
516 static const GLvoid
*
517 get_static_proc_address(const char *funcName
)
519 const glprocs_table_t
* const f
= find_entry( funcName
);
522 return gl_dispatch_functions_start
523 + (X86_DISPATCH_FUNCTION_SIZE
* f
->Offset
);
534 * Return dispatch function address the named static (built-in) function.
535 * Return NULL if function not found.
537 static const GLvoid
*
538 get_static_proc_address(const char *funcName
)
540 const glprocs_table_t
* const f
= find_entry( funcName
);
541 return ( f
!= NULL
) ? f
->Address
: NULL
;
544 #endif /* USE_X86_ASM */
548 get_static_proc_name( GLuint offset
)
552 for ( i
= 0 ; static_functions
[i
].Name_offset
>= 0 ; i
++ ) {
553 if (static_functions
[i
].Offset
== offset
) {
554 return gl_string_table
+ static_functions
[i
].Name_offset
;
562 /**********************************************************************
563 * Extension function management.
567 * Number of extension functions which we can dynamically add at runtime.
569 #define MAX_EXTENSION_FUNCS 300
573 * The disptach table size (number of entries) is the sizeof the
574 * _glapi_table struct plus the number of dynamic entries we can add.
575 * The extra slots can be filled in by DRI drivers that register new extension
578 #define DISPATCH_TABLE_SIZE (sizeof(struct _glapi_table) / sizeof(void *) + MAX_EXTENSION_FUNCS)
581 static struct name_address_offset ExtEntryTable
[MAX_EXTENSION_FUNCS
];
582 static GLuint NumExtEntryPoints
= 0;
585 extern void __glapi_sparc_icache_flush(unsigned int *);
589 * Generate a dispatch function (entrypoint) which jumps through
590 * the given slot number (offset) in the current dispatch table.
591 * We need assembly language in order to accomplish this.
594 generate_entrypoint(GLuint functionOffset
)
596 #if defined(USE_X86_ASM)
598 * This x86 code contributed by Josh Vanderhoof.
600 * 0: a1 10 32 54 76 movl __glapi_Dispatch,%eax
602 * 5: 85 c0 testl %eax,%eax
604 * 7: 74 06 je f <entrypoint+0xf>
606 * 9: ff a0 10 32 54 76 jmp *0x76543210(%eax)
608 * f: e8 fc ff ff ff call __glapi_get_dispatch
610 * 14: ff a0 10 32 54 76 jmp *0x76543210(%eax)
613 static const unsigned char insn_template
[] = {
614 0xa1, 0x00, 0x00, 0x00, 0x00,
617 0xff, 0xa0, 0x00, 0x00, 0x00, 0x00,
618 0xe8, 0x00, 0x00, 0x00, 0x00,
619 0xff, 0xa0, 0x00, 0x00, 0x00, 0x00
621 unsigned char *code
= (unsigned char *) malloc(sizeof(insn_template
));
622 unsigned int next_insn
;
624 memcpy(code
, insn_template
, sizeof(insn_template
));
626 #if defined( THREADS )
627 *(unsigned int *)(code
+ 0x01) = (unsigned int)&_glapi_DispatchTSD
;
629 *(unsigned int *)(code
+ 0x01) = (unsigned int)&_glapi_Dispatch
;
631 *(unsigned int *)(code
+ 0x0b) = (unsigned int)functionOffset
* 4;
632 next_insn
= (unsigned int)(code
+ 0x14);
633 *(unsigned int *)(code
+ 0x10) = (unsigned int)_glapi_get_dispatch
- next_insn
;
634 *(unsigned int *)(code
+ 0x16) = (unsigned int)functionOffset
* 4;
637 #elif defined(USE_SPARC_ASM)
639 #if defined(__sparc_v9__) && !defined(__linux__)
640 static const unsigned int insn_template
[] = {
641 0x05000000, /* sethi %uhi(_glapi_Dispatch), %g2 */
642 0x03000000, /* sethi %hi(_glapi_Dispatch), %g1 */
643 0x8410a000, /* or %g2, %ulo(_glapi_Dispatch), %g2 */
644 0x82106000, /* or %g1, %lo(_glapi_Dispatch), %g1 */
645 0x8528b020, /* sllx %g2, 32, %g2 */
646 0xc2584002, /* ldx [%g1 + %g2], %g1 */
647 0x05000000, /* sethi %hi(8 * glapioffset), %g2 */
648 0x8410a000, /* or %g2, %lo(8 * glapioffset), %g2 */
649 0xc6584002, /* ldx [%g1 + %g2], %g3 */
650 0x81c0c000, /* jmpl %g3, %g0 */
654 static const unsigned int insn_template
[] = {
655 0x03000000, /* sethi %hi(_glapi_Dispatch), %g1 */
656 0xc2006000, /* ld [%g1 + %lo(_glapi_Dispatch)], %g1 */
657 0xc6006000, /* ld [%g1 + %lo(4*glapioffset)], %g3 */
658 0x81c0c000, /* jmpl %g3, %g0 */
662 unsigned int *code
= (unsigned int *) malloc(sizeof(insn_template
));
663 unsigned long glapi_addr
= (unsigned long) &_glapi_Dispatch
;
665 memcpy(code
, insn_template
, sizeof(insn_template
));
667 #if defined(__sparc_v9__) && !defined(__linux__)
668 code
[0] |= (glapi_addr
>> (32 + 10));
669 code
[1] |= ((glapi_addr
& 0xffffffff) >> 10);
670 __glapi_sparc_icache_flush(&code
[0]);
671 code
[2] |= ((glapi_addr
>> 32) & ((1 << 10) - 1));
672 code
[3] |= (glapi_addr
& ((1 << 10) - 1));
673 __glapi_sparc_icache_flush(&code
[2]);
674 code
[6] |= ((functionOffset
* 8) >> 10);
675 code
[7] |= ((functionOffset
* 8) & ((1 << 10) - 1));
676 __glapi_sparc_icache_flush(&code
[6]);
678 code
[0] |= (glapi_addr
>> 10);
679 code
[1] |= (glapi_addr
& ((1 << 10) - 1));
680 __glapi_sparc_icache_flush(&code
[0]);
681 code
[2] |= (functionOffset
* 4);
682 __glapi_sparc_icache_flush(&code
[2]);
687 (void) functionOffset
;
689 #endif /* USE_*_ASM */
694 * This function inserts a new dispatch offset into the assembly language
695 * stub that was generated with the preceeding function.
698 fill_in_entrypoint_offset(void *entrypoint
, GLuint offset
)
700 #if defined(USE_X86_ASM)
702 unsigned char *code
= (unsigned char *) entrypoint
;
703 *(unsigned int *)(code
+ 0x0b) = offset
* 4;
704 *(unsigned int *)(code
+ 0x16) = offset
* 4;
706 #elif defined(USE_SPARC_ASM)
708 /* XXX this hasn't been tested! */
709 unsigned int *code
= (unsigned int *) entrypoint
;
710 #if defined(__sparc_v9__) && !defined(__linux__)
711 code
[6] = 0x05000000; /* sethi %hi(8 * glapioffset), %g2 */
712 code
[7] = 0x8410a000; /* or %g2, %lo(8 * glapioffset), %g2 */
713 code
[6] |= ((offset
* 8) >> 10);
714 code
[7] |= ((offset
* 8) & ((1 << 10) - 1));
715 __glapi_sparc_icache_flush(&code
[6]);
716 #else /* __sparc_v9__ && !linux */
717 code
[2] = 0xc6006000; /* ld [%g1 + %lo(4*glapioffset)], %g3 */
718 code
[2] |= (offset
* 4);
719 __glapi_sparc_icache_flush(&code
[2]);
720 #endif /* __sparc_v9__ && !linux */
724 /* an unimplemented architecture */
728 #endif /* USE_*_ASM */
733 * Add a new extension function entrypoint.
734 * Return: GL_TRUE = success or GL_FALSE = failure
737 _glapi_add_entrypoint(const char *funcName
, GLuint offset
)
739 /* trivial rejection test */
741 if (!funcName
|| funcName
[0] != 'm' || funcName
[1] != 'g' || funcName
[2] != 'l')
744 if (!funcName
|| funcName
[0] != 'g' || funcName
[1] != 'l')
748 /* first check if the named function is already statically present */
750 GLint index
= get_static_proc_offset(funcName
);
752 return (GLboolean
) ((GLuint
) index
== offset
); /* bad offset! */
756 /* See if this function has already been dynamically added */
759 for (i
= 0; i
< NumExtEntryPoints
; i
++) {
760 if (strcmp(ExtEntryTable
[i
].Name
, funcName
) == 0) {
761 /* function already registered */
762 if (ExtEntryTable
[i
].Offset
== offset
) {
763 return GL_TRUE
; /* offsets match */
765 else if (ExtEntryTable
[i
].Offset
== (GLuint
) ~0
766 && offset
< DISPATCH_TABLE_SIZE
) {
767 /* need to patch-up the dispatch code */
768 if (offset
!= (GLuint
) ~0) {
769 fill_in_entrypoint_offset(ExtEntryTable
[i
].Address
, offset
);
770 ExtEntryTable
[i
].Offset
= offset
;
775 return GL_FALSE
; /* bad offset! */
781 /* This is a new function, try to add it. */
782 if (NumExtEntryPoints
>= MAX_EXTENSION_FUNCS
||
783 offset
>= DISPATCH_TABLE_SIZE
) {
788 void *entrypoint
= generate_entrypoint(offset
);
790 return GL_FALSE
; /* couldn't generate assembly */
793 ExtEntryTable
[NumExtEntryPoints
].Name
= str_dup(funcName
);
794 ExtEntryTable
[NumExtEntryPoints
].Offset
= offset
;
795 ExtEntryTable
[NumExtEntryPoints
].Address
= entrypoint
;
798 return GL_TRUE
; /* success */
801 /* should never get here, silence compiler warnings */
807 * Return offset of entrypoint for named function within dispatch table.
810 _glapi_get_proc_offset(const char *funcName
)
812 /* search extension functions first */
814 for (i
= 0; i
< NumExtEntryPoints
; i
++) {
815 if (strcmp(ExtEntryTable
[i
].Name
, funcName
) == 0) {
816 return ExtEntryTable
[i
].Offset
;
820 /* search static functions */
821 return get_static_proc_offset(funcName
);
827 * Return entrypoint for named function.
830 _glapi_get_proc_address(const char *funcName
)
835 if (funcName
[0] != 'm' || funcName
[1] != 'g' || funcName
[2] != 'l')
838 if (funcName
[0] != 'g' || funcName
[1] != 'l')
842 /* search extension functions first */
843 for (i
= 0; i
< NumExtEntryPoints
; i
++) {
844 if (strcmp(ExtEntryTable
[i
].Name
, funcName
) == 0) {
845 return ExtEntryTable
[i
].Address
;
849 /* search static functions */
851 const GLvoid
*func
= get_static_proc_address(funcName
);
856 /* generate new entrypoint - use a temporary dispatch offset of
857 * ~0 (i.e. -1). Later, when the driver calls _glapi_add_entrypoint()
858 * we'll put in the proper offset. If that never happens, and the
859 * user calls this function, he'll segfault. That's what you get
860 * when you try calling a GL function that doesn't really exist.
862 if (NumExtEntryPoints
< MAX_EXTENSION_FUNCS
) {
863 GLvoid
*entrypoint
= generate_entrypoint(~0);
867 ExtEntryTable
[NumExtEntryPoints
].Name
= str_dup(funcName
);
868 ExtEntryTable
[NumExtEntryPoints
].Offset
= ~0;
869 ExtEntryTable
[NumExtEntryPoints
].Address
= entrypoint
;
875 /* no space for new functions! */
883 * Return the name of the function at the given dispatch offset.
884 * This is only intended for debugging.
887 _glapi_get_proc_name(GLuint offset
)
892 /* search built-in functions */
893 n
= get_static_proc_name(offset
);
898 /* search added extension functions */
899 for (i
= 0; i
< NumExtEntryPoints
; i
++) {
900 if (ExtEntryTable
[i
].Offset
== offset
) {
901 return ExtEntryTable
[i
].Name
;
910 * Return size of dispatch table struct as number of functions (or
914 _glapi_get_dispatch_table_size(void)
916 return DISPATCH_TABLE_SIZE
;
922 * Get API dispatcher version string.
925 _glapi_get_version(void)
927 return "20021001"; /* YYYYMMDD */
933 * Make sure there are no NULL pointers in the given dispatch table.
934 * Intended for debugging purposes.
937 _glapi_check_table(const struct _glapi_table
*table
)
940 const GLuint entries
= _glapi_get_dispatch_table_size();
941 const void **tab
= (const void **) table
;
943 for (i
= 1; i
< entries
; i
++) {
947 /* Do some spot checks to be sure that the dispatch table
948 * slots are assigned correctly.
951 GLuint BeginOffset
= _glapi_get_proc_offset("glBegin");
952 char *BeginFunc
= (char*) &table
->Begin
;
953 GLuint offset
= (BeginFunc
- (char *) table
) / sizeof(void *);
954 assert(BeginOffset
== _gloffset_Begin
);
955 assert(BeginOffset
== offset
);
958 GLuint viewportOffset
= _glapi_get_proc_offset("glViewport");
959 char *viewportFunc
= (char*) &table
->Viewport
;
960 GLuint offset
= (viewportFunc
- (char *) table
) / sizeof(void *);
961 assert(viewportOffset
== _gloffset_Viewport
);
962 assert(viewportOffset
== offset
);
965 GLuint VertexPointerOffset
= _glapi_get_proc_offset("glVertexPointer");
966 char *VertexPointerFunc
= (char*) &table
->VertexPointer
;
967 GLuint offset
= (VertexPointerFunc
- (char *) table
) / sizeof(void *);
968 assert(VertexPointerOffset
== _gloffset_VertexPointer
);
969 assert(VertexPointerOffset
== offset
);
972 GLuint ResetMinMaxOffset
= _glapi_get_proc_offset("glResetMinmax");
973 char *ResetMinMaxFunc
= (char*) &table
->ResetMinmax
;
974 GLuint offset
= (ResetMinMaxFunc
- (char *) table
) / sizeof(void *);
975 assert(ResetMinMaxOffset
== _gloffset_ResetMinmax
);
976 assert(ResetMinMaxOffset
== offset
);
979 GLuint blendColorOffset
= _glapi_get_proc_offset("glBlendColor");
980 char *blendColorFunc
= (char*) &table
->BlendColor
;
981 GLuint offset
= (blendColorFunc
- (char *) table
) / sizeof(void *);
982 assert(blendColorOffset
== _gloffset_BlendColor
);
983 assert(blendColorOffset
== offset
);
986 GLuint istextureOffset
= _glapi_get_proc_offset("glIsTextureEXT");
987 char *istextureFunc
= (char*) &table
->IsTextureEXT
;
988 GLuint offset
= (istextureFunc
- (char *) table
) / sizeof(void *);
989 assert(istextureOffset
== _gloffset_IsTextureEXT
);
990 assert(istextureOffset
== offset
);
993 GLuint secondaryColor3fOffset
= _glapi_get_proc_offset("glSecondaryColor3fEXT");
994 char *secondaryColor3fFunc
= (char*) &table
->SecondaryColor3fEXT
;
995 GLuint offset
= (secondaryColor3fFunc
- (char *) table
) / sizeof(void *);
996 assert(secondaryColor3fOffset
== _gloffset_SecondaryColor3fEXT
);
997 assert(secondaryColor3fOffset
== offset
);
998 assert(_glapi_get_proc_address("glSecondaryColor3fEXT") == (void *) &glSecondaryColor3fEXT
);
1001 GLuint pointParameterivOffset
= _glapi_get_proc_offset("glPointParameterivNV");
1002 char *pointParameterivFunc
= (char*) &table
->PointParameterivNV
;
1003 GLuint offset
= (pointParameterivFunc
- (char *) table
) / sizeof(void *);
1004 assert(pointParameterivOffset
== _gloffset_PointParameterivNV
);
1005 assert(pointParameterivOffset
== offset
);
1006 assert(_glapi_get_proc_address("glPointParameterivNV") == (void *) &glPointParameterivNV
);
1009 GLuint setFenceOffset
= _glapi_get_proc_offset("glSetFenceNV");
1010 char *setFenceFunc
= (char*) &table
->SetFenceNV
;
1011 GLuint offset
= (setFenceFunc
- (char *) table
) / sizeof(void *);
1012 assert(setFenceOffset
== _gloffset_SetFenceNV
);
1013 assert(setFenceOffset
== offset
);
1014 assert(_glapi_get_proc_address("glSetFenceNV") == (void *) &glSetFenceNV
);