OSDN Git Service

Merge branch 'master' into opengl-es-v2
[android-x86/external-mesa.git] / src / mesa / glapi / glapi.c
1 /*
2  * Mesa 3-D graphics library
3  * Version:  7.1
4  *
5  * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved.
6  *
7  * Permission is hereby granted, free of charge, to any person obtaining a
8  * copy of this software and associated documentation files (the "Software"),
9  * to deal in the Software without restriction, including without limitation
10  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11  * and/or sell copies of the Software, and to permit persons to whom the
12  * Software is furnished to do so, subject to the following conditions:
13  *
14  * The above copyright notice and this permission notice shall be included
15  * in all copies or substantial portions of the Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
20  * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21  * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  */
24
25
26 /*
27  * This file manages the OpenGL API dispatch layer.
28  * The dispatch table (struct _glapi_table) is basically just a list
29  * of function pointers.
30  * There are functions to set/get the current dispatch table for the
31  * current thread and to manage registration/dispatch of dynamically
32  * added extension functions.
33  *
34  * It's intended that this file and the other glapi*.[ch] files are
35  * flexible enough to be reused in several places:  XFree86, DRI-
36  * based libGL.so, and perhaps the SGI SI.
37  *
38  * NOTE: There are no dependencies on Mesa in this code.
39  *
40  * Versions (API changes):
41  *   2000/02/23  - original version for Mesa 3.3 and XFree86 4.0
42  *   2001/01/16  - added dispatch override feature for Mesa 3.5
43  *   2002/06/28  - added _glapi_set_warning_func(), Mesa 4.1.
44  *   2002/10/01  - _glapi_get_proc_address() will now generate new entrypoints
45  *                 itself (using offset ~0).  _glapi_add_entrypoint() can be
46  *                 called afterward and it'll fill in the correct dispatch
47  *                 offset.  This allows DRI libGL to avoid probing for DRI
48  *                 drivers!  No changes to the public glapi interface.
49  */
50
51
52
53 #ifdef HAVE_DIX_CONFIG_H
54
55 #include <dix-config.h>
56 #define PUBLIC
57
58 #else
59
60 #include "main/glheader.h"
61
62 #endif
63
64 #include "main/compiler.h"
65
66 #include <stdlib.h>
67 #include <string.h>
68 #ifdef DEBUG
69 #include <assert.h>
70 #endif
71
72 #include "glapi/glapi.h"
73 #include "glapi/glapioffsets.h"
74 #include "glapi/glapitable.h"
75
76 /***** BEGIN NO-OP DISPATCH *****/
77
78 static GLboolean WarnFlag = GL_FALSE;
79 static _glapi_warning_func warning_func;
80
81 /*
82  * Enable/disable printing of warning messages.
83  */
84 PUBLIC void
85 _glapi_noop_enable_warnings(GLboolean enable)
86 {
87    WarnFlag = enable;
88 }
89
90 /*
91  * Register a callback function for reporting errors.
92  */
93 PUBLIC void
94 _glapi_set_warning_func( _glapi_warning_func func )
95 {
96    warning_func = func;
97 }
98
99 static int
100 warn(const char *func)
101 {
102 #if !defined(_WIN32_WCE)
103    if ((WarnFlag || getenv("MESA_DEBUG") || getenv("LIBGL_DEBUG"))
104        && warning_func) {
105       warning_func(NULL, "GL User Error: called without context: %s", func);
106    }
107 #endif
108    return 0;
109 }
110
111 #ifdef DEBUG
112
113 #define KEYWORD1 static
114 #define KEYWORD1_ALT static
115 #define KEYWORD2 GLAPIENTRY
116 #define NAME(func)  NoOp##func
117
118 #define F NULL
119
120 #define DISPATCH(func, args, msg)                                             \
121    warn(#func);
122
123 #define RETURN_DISPATCH(func, args, msg)                                      \
124    return warn(#func);
125
126 #define TABLE_ENTRY(name) (_glapi_proc) NoOp##name
127
128 #else
129
130 static void
131 NoOpGeneric(void)
132 {
133    if ((WarnFlag || getenv("MESA_DEBUG") || getenv("LIBGL_DEBUG"))
134        && warning_func) {
135       warning_func(NULL, "GL User Error: calling GL function");
136    }
137 }
138
139 #define TABLE_ENTRY(name) (_glapi_proc) NoOpGeneric
140
141 #endif
142
143 #define DISPATCH_TABLE_NAME __glapi_noop_table
144 #define UNUSED_TABLE_NAME __unused_noop_functions
145
146 static GLint NoOpUnused(void)
147 {
148    return warn("extension function");
149 }
150
151 #include "glapi/glapitemp.h"
152
153 /***** END NO-OP DISPATCH *****/
154
155
156
157 /**
158  * \name Current dispatch and current context control variables
159  *
160  * Depending on whether or not multithreading is support, and the type of
161  * support available, several variables are used to store the current context
162  * pointer and the current dispatch table pointer.  In the non-threaded case,
163  * the variables \c _glapi_Dispatch and \c _glapi_Context are used for this
164  * purpose.
165  *
166  * In the "normal" threaded case, the variables \c _glapi_Dispatch and
167  * \c _glapi_Context will be \c NULL if an application is detected as being
168  * multithreaded.  Single-threaded applications will use \c _glapi_Dispatch
169  * and \c _glapi_Context just like the case without any threading support.
170  * When \c _glapi_Dispatch and \c _glapi_Context are \c NULL, the thread state
171  * data \c _gl_DispatchTSD and \c ContextTSD are used.  Drivers and the
172  * static dispatch functions access these variables via \c _glapi_get_dispatch
173  * and \c _glapi_get_context.
174  *
175  * There is a race condition in setting \c _glapi_Dispatch to \c NULL.  It is
176  * possible for the original thread to be setting it at the same instant a new
177  * thread, perhaps running on a different processor, is clearing it.  Because
178  * of that, \c ThreadSafe, which can only ever be changed to \c GL_TRUE, is
179  * used to determine whether or not the application is multithreaded.
180  * 
181  * In the TLS case, the variables \c _glapi_Dispatch and \c _glapi_Context are
182  * hardcoded to \c NULL.  Instead the TLS variables \c _glapi_tls_Dispatch and
183  * \c _glapi_tls_Context are used.  Having \c _glapi_Dispatch and
184  * \c _glapi_Context be hardcoded to \c NULL maintains binary compatability
185  * between TLS enabled loaders and non-TLS DRI drivers.
186  */
187 /*@{*/
188 #if defined(GLX_USE_TLS)
189
190 PUBLIC __thread struct _glapi_table * _glapi_tls_Dispatch
191     __attribute__((tls_model("initial-exec")))
192     = (struct _glapi_table *) __glapi_noop_table;
193
194 PUBLIC __thread void * _glapi_tls_Context
195     __attribute__((tls_model("initial-exec")));
196
197 PUBLIC const struct _glapi_table *_glapi_Dispatch = NULL;
198 PUBLIC const void *_glapi_Context = NULL;
199
200 #else
201
202 #if defined(THREADS)
203
204 #ifdef WIN32_THREADS
205 /* _glthread_DECLARE_STATIC_MUTEX is broken on windows.  There will be race! */
206 #define CHECK_MULTITHREAD_LOCK()
207 #define CHECK_MULTITHREAD_UNLOCK()
208 #else
209 _glthread_DECLARE_STATIC_MUTEX(ThreadCheckMutex);
210 #define CHECK_MULTITHREAD_LOCK() _glthread_LOCK_MUTEX(ThreadCheckMutex)
211 #define CHECK_MULTITHREAD_UNLOCK() _glthread_UNLOCK_MUTEX(ThreadCheckMutex)
212 #endif
213
214 static GLboolean ThreadSafe = GL_FALSE;  /**< In thread-safe mode? */
215 _glthread_TSD _gl_DispatchTSD;           /**< Per-thread dispatch pointer */
216 static _glthread_TSD ContextTSD;         /**< Per-thread context pointer */
217
218 #if defined(WIN32_THREADS)
219 void FreeTSD(_glthread_TSD *p);
220 void FreeAllTSD(void)
221 {
222    FreeTSD(&_gl_DispatchTSD);
223    FreeTSD(&ContextTSD);
224 }
225 #endif /* defined(WIN32_THREADS) */
226
227 #endif /* defined(THREADS) */
228
229 PUBLIC struct _glapi_table *_glapi_Dispatch = 
230   (struct _glapi_table *) __glapi_noop_table;
231 PUBLIC void *_glapi_Context = NULL;
232
233 #endif /* defined(GLX_USE_TLS) */
234 /*@}*/
235
236
237
238
239 /**
240  * We should call this periodically from a function such as glXMakeCurrent
241  * in order to test if multiple threads are being used.
242  */
243 PUBLIC void
244 _glapi_check_multithread(void)
245 {
246 #if defined(THREADS) && !defined(GLX_USE_TLS)
247    static unsigned long knownID;
248    static GLboolean firstCall = GL_TRUE;
249
250    if (ThreadSafe)
251       return;
252
253    CHECK_MULTITHREAD_LOCK();
254    if (firstCall) {
255       /* initialize TSDs */
256       (void) _glthread_GetTSD(&ContextTSD);
257       (void) _glthread_GetTSD(&_gl_DispatchTSD);
258
259       knownID = _glthread_GetID();
260       firstCall = GL_FALSE;
261    }
262    else if (knownID != _glthread_GetID()) {
263       ThreadSafe = GL_TRUE;
264       _glapi_set_dispatch(NULL);
265       _glapi_set_context(NULL);
266    }
267    CHECK_MULTITHREAD_UNLOCK();
268 #endif
269 }
270
271
272
273 /**
274  * Set the current context pointer for this thread.
275  * The context pointer is an opaque type which should be cast to
276  * void from the real context pointer type.
277  */
278 PUBLIC void
279 _glapi_set_context(void *context)
280 {
281    (void) __unused_noop_functions; /* silence a warning */
282 #if defined(GLX_USE_TLS)
283    _glapi_tls_Context = context;
284 #elif defined(THREADS)
285    _glthread_SetTSD(&ContextTSD, context);
286    _glapi_Context = (ThreadSafe) ? NULL : context;
287 #else
288    _glapi_Context = context;
289 #endif
290 }
291
292
293
294 /**
295  * Get the current context pointer for this thread.
296  * The context pointer is an opaque type which should be cast from
297  * void to the real context pointer type.
298  */
299 PUBLIC void *
300 _glapi_get_context(void)
301 {
302 #if defined(GLX_USE_TLS)
303    return _glapi_tls_Context;
304 #elif defined(THREADS)
305    if (ThreadSafe) {
306       return _glthread_GetTSD(&ContextTSD);
307    }
308    else {
309       return _glapi_Context;
310    }
311 #else
312    return _glapi_Context;
313 #endif
314 }
315
316 #ifdef USE_X86_ASM
317
318 #if defined( GLX_USE_TLS )
319 extern       GLubyte gl_dispatch_functions_start[];
320 extern       GLubyte gl_dispatch_functions_end[];
321 #else
322 extern const GLubyte gl_dispatch_functions_start[];
323 #endif
324
325 #endif /* USE_X86_ASM */
326
327
328 #if defined(USE_X64_64_ASM) && defined(GLX_USE_TLS)
329 # define DISPATCH_FUNCTION_SIZE  16
330 #elif defined(USE_X86_ASM)
331 # if defined(THREADS) && !defined(GLX_USE_TLS)
332 #  define DISPATCH_FUNCTION_SIZE  32
333 # else
334 #  define DISPATCH_FUNCTION_SIZE  16
335 # endif
336 #endif
337
338 #ifdef USE_SPARC_ASM
339 #ifdef GLX_USE_TLS
340 extern unsigned int __glapi_sparc_tls_stub;
341 #else
342 extern unsigned int __glapi_sparc_pthread_stub;
343 #endif
344 #endif
345
346 #if !defined(DISPATCH_FUNCTION_SIZE) && !defined(XFree86Server) && !defined(XGLServer)
347 # define NEED_FUNCTION_POINTER
348 #endif
349
350 #if defined(PTHREADS) || defined(GLX_USE_TLS)
351 /**
352  * Perform platform-specific GL API entry-point fixups.
353  */
354 static void
355 init_glapi_relocs( void )
356 {
357 #if defined(USE_X86_ASM) && defined(GLX_USE_TLS) && !defined(GLX_X86_READONLY_TEXT)
358     extern unsigned long _x86_get_dispatch(void);
359     char run_time_patch[] = {
360        0x65, 0xa1, 0, 0, 0, 0 /* movl %gs:0,%eax */
361     };
362     GLuint *offset = (GLuint *) &run_time_patch[2]; /* 32-bits for x86/32 */
363     const GLubyte * const get_disp = (const GLubyte *) run_time_patch;
364     GLubyte * curr_func = (GLubyte *) gl_dispatch_functions_start;
365
366     *offset = _x86_get_dispatch();
367     while ( curr_func != (GLubyte *) gl_dispatch_functions_end ) {
368         (void) memcpy( curr_func, get_disp, sizeof(run_time_patch));
369         curr_func += DISPATCH_FUNCTION_SIZE;
370     }
371 #endif
372 #ifdef USE_SPARC_ASM
373     extern void __glapi_sparc_icache_flush(unsigned int *);
374     static const unsigned int template[] = {
375 #ifdef GLX_USE_TLS
376         0x05000000, /* sethi %hi(_glapi_tls_Dispatch), %g2 */
377         0x8730e00a, /* srl %g3, 10, %g3 */
378         0x8410a000, /* or %g2, %lo(_glapi_tls_Dispatch), %g2 */
379 #ifdef __arch64__
380         0xc259c002, /* ldx [%g7 + %g2], %g1 */
381         0xc2584003, /* ldx [%g1 + %g3], %g1 */
382 #else
383         0xc201c002, /* ld [%g7 + %g2], %g1 */
384         0xc2004003, /* ld [%g1 + %g3], %g1 */
385 #endif
386         0x81c04000, /* jmp %g1 */
387         0x01000000, /* nop  */
388 #else
389 #ifdef __arch64__
390         0x03000000, /* 64-bit 0x00 --> sethi %hh(_glapi_Dispatch), %g1 */
391         0x05000000, /* 64-bit 0x04 --> sethi %lm(_glapi_Dispatch), %g2 */
392         0x82106000, /* 64-bit 0x08 --> or %g1, %hm(_glapi_Dispatch), %g1 */
393         0x8730e00a, /* 64-bit 0x0c --> srl %g3, 10, %g3 */
394         0x83287020, /* 64-bit 0x10 --> sllx %g1, 32, %g1 */
395         0x82004002, /* 64-bit 0x14 --> add %g1, %g2, %g1 */
396         0xc2586000, /* 64-bit 0x18 --> ldx [%g1 + %lo(_glapi_Dispatch)], %g1 */
397 #else
398         0x03000000, /* 32-bit 0x00 --> sethi %hi(_glapi_Dispatch), %g1 */
399         0x8730e00a, /* 32-bit 0x04 --> srl %g3, 10, %g3 */
400         0xc2006000, /* 32-bit 0x08 --> ld [%g1 + %lo(_glapi_Dispatch)], %g1 */
401 #endif
402         0x80a06000, /*             --> cmp %g1, 0 */
403         0x02800005, /*             --> be +4*5 */
404         0x01000000, /*             -->  nop  */
405 #ifdef __arch64__
406         0xc2584003, /* 64-bit      --> ldx [%g1 + %g3], %g1 */
407 #else
408         0xc2004003, /* 32-bit      --> ld [%g1 + %g3], %g1 */
409 #endif
410         0x81c04000, /*             --> jmp %g1 */
411         0x01000000, /*             --> nop  */
412 #ifdef __arch64__
413         0x9de3bf80, /* 64-bit      --> save  %sp, -128, %sp */
414 #else
415         0x9de3bfc0, /* 32-bit      --> save  %sp, -64, %sp */
416 #endif
417         0xa0100003, /*             --> mov  %g3, %l0 */
418         0x40000000, /*             --> call _glapi_get_dispatch */
419         0x01000000, /*             -->  nop */
420         0x82100008, /*             --> mov %o0, %g1 */
421         0x86100010, /*             --> mov %l0, %g3 */
422         0x10bffff7, /*             --> ba -4*9 */
423         0x81e80000, /*             -->  restore  */
424 #endif
425     };
426 #ifdef GLX_USE_TLS
427     extern unsigned long __glapi_sparc_get_dispatch(void);
428     unsigned int *code = &__glapi_sparc_tls_stub;
429     unsigned long dispatch = __glapi_sparc_get_dispatch();
430 #else
431     unsigned int *code = &__glapi_sparc_pthread_stub;
432     unsigned long dispatch = (unsigned long) &_glapi_Dispatch;
433     unsigned long call_dest = (unsigned long ) &_glapi_get_dispatch;
434     int idx;
435 #endif
436
437 #if defined(GLX_USE_TLS)
438     code[0] = template[0] | (dispatch >> 10);
439     code[1] = template[1];
440     __glapi_sparc_icache_flush(&code[0]);
441     code[2] = template[2] | (dispatch & 0x3ff);
442     code[3] = template[3];
443     __glapi_sparc_icache_flush(&code[2]);
444     code[4] = template[4];
445     code[5] = template[5];
446     __glapi_sparc_icache_flush(&code[4]);
447     code[6] = template[6];
448     __glapi_sparc_icache_flush(&code[6]);
449 #else
450 #if defined(__arch64__)
451     code[0] = template[0] | (dispatch >> (32 + 10));
452     code[1] = template[1] | ((dispatch & 0xffffffff) >> 10);
453     __glapi_sparc_icache_flush(&code[0]);
454     code[2] = template[2] | ((dispatch >> 32) & 0x3ff);
455     code[3] = template[3];
456     __glapi_sparc_icache_flush(&code[2]);
457     code[4] = template[4];
458     code[5] = template[5];
459     __glapi_sparc_icache_flush(&code[4]);
460     code[6] = template[6] | (dispatch & 0x3ff);
461     idx = 7;
462 #else
463     code[0] = template[0] | (dispatch >> 10);
464     code[1] = template[1];
465     __glapi_sparc_icache_flush(&code[0]);
466     code[2] = template[2] | (dispatch & 0x3ff);
467     idx = 3;
468 #endif
469     code[idx + 0] = template[idx + 0];
470     __glapi_sparc_icache_flush(&code[idx - 1]);
471     code[idx + 1] = template[idx + 1];
472     code[idx + 2] = template[idx + 2];
473     __glapi_sparc_icache_flush(&code[idx + 1]);
474     code[idx + 3] = template[idx + 3];
475     code[idx + 4] = template[idx + 4];
476     __glapi_sparc_icache_flush(&code[idx + 3]);
477     code[idx + 5] = template[idx + 5];
478     code[idx + 6] = template[idx + 6];
479     __glapi_sparc_icache_flush(&code[idx + 5]);
480     code[idx + 7] = template[idx + 7];
481     code[idx + 8] = template[idx + 8] |
482             (((call_dest - ((unsigned long) &code[idx + 8]))
483               >> 2) & 0x3fffffff);
484     __glapi_sparc_icache_flush(&code[idx + 7]);
485     code[idx + 9] = template[idx + 9];
486     code[idx + 10] = template[idx + 10];
487     __glapi_sparc_icache_flush(&code[idx + 9]);
488     code[idx + 11] = template[idx + 11];
489     code[idx + 12] = template[idx + 12];
490     __glapi_sparc_icache_flush(&code[idx + 11]);
491     code[idx + 13] = template[idx + 13];
492     __glapi_sparc_icache_flush(&code[idx + 13]);
493 #endif
494 #endif
495 }
496 #endif /* defined(PTHREADS) || defined(GLX_USE_TLS) */
497
498
499 /**
500  * Set the global or per-thread dispatch table pointer.
501  * If the dispatch parameter is NULL we'll plug in the no-op dispatch
502  * table (__glapi_noop_table).
503  */
504 PUBLIC void
505 _glapi_set_dispatch(struct _glapi_table *dispatch)
506 {
507 #if defined(PTHREADS) || defined(GLX_USE_TLS)
508    static pthread_once_t once_control = PTHREAD_ONCE_INIT;
509    pthread_once( & once_control, init_glapi_relocs );
510 #endif
511
512    if (!dispatch) {
513       /* use the no-op functions */
514       dispatch = (struct _glapi_table *) __glapi_noop_table;
515    }
516 #ifdef DEBUG
517    else {
518       _glapi_check_table(dispatch);
519    }
520 #endif
521
522 #if defined(GLX_USE_TLS)
523    _glapi_tls_Dispatch = dispatch;
524 #elif defined(THREADS)
525    _glthread_SetTSD(&_gl_DispatchTSD, (void *) dispatch);
526    _glapi_Dispatch = (ThreadSafe) ? NULL : dispatch;
527 #else /*THREADS*/
528    _glapi_Dispatch = dispatch;
529 #endif /*THREADS*/
530 }
531
532
533
534 /**
535  * Return pointer to current dispatch table for calling thread.
536  */
537 PUBLIC struct _glapi_table *
538 _glapi_get_dispatch(void)
539 {
540    struct _glapi_table * api;
541 #if defined(GLX_USE_TLS)
542    api = _glapi_tls_Dispatch;
543 #elif defined(THREADS)
544    api = (ThreadSafe)
545      ? (struct _glapi_table *) _glthread_GetTSD(&_gl_DispatchTSD)
546      : _glapi_Dispatch;
547 #else
548    api = _glapi_Dispatch;
549 #endif
550    return api;
551 }
552
553
554
555
556 /*
557  * The dispatch table size (number of entries) is the size of the
558  * _glapi_table struct plus the number of dynamic entries we can add.
559  * The extra slots can be filled in by DRI drivers that register new extension
560  * functions.
561  */
562 #define DISPATCH_TABLE_SIZE (sizeof(struct _glapi_table) / sizeof(void *) + MAX_EXTENSION_FUNCS)
563
564
565 /**
566  * Return size of dispatch table struct as number of functions (or
567  * slots).
568  */
569 PUBLIC GLuint
570 _glapi_get_dispatch_table_size(void)
571 {
572    return DISPATCH_TABLE_SIZE;
573 }
574
575
576 /**
577  * Make sure there are no NULL pointers in the given dispatch table.
578  * Intended for debugging purposes.
579  */
580 void
581 _glapi_check_table(const struct _glapi_table *table)
582 {
583 #ifdef EXTRA_DEBUG
584    const GLuint entries = _glapi_get_dispatch_table_size();
585    const void **tab = (const void **) table;
586    GLuint i;
587    for (i = 1; i < entries; i++) {
588       assert(tab[i]);
589    }
590
591    /* Do some spot checks to be sure that the dispatch table
592     * slots are assigned correctly.
593     */
594    {
595       GLuint BeginOffset = _glapi_get_proc_offset("glBegin");
596       char *BeginFunc = (char*) &table->Begin;
597       GLuint offset = (BeginFunc - (char *) table) / sizeof(void *);
598       assert(BeginOffset == _gloffset_Begin);
599       assert(BeginOffset == offset);
600    }
601    {
602       GLuint viewportOffset = _glapi_get_proc_offset("glViewport");
603       char *viewportFunc = (char*) &table->Viewport;
604       GLuint offset = (viewportFunc - (char *) table) / sizeof(void *);
605       assert(viewportOffset == _gloffset_Viewport);
606       assert(viewportOffset == offset);
607    }
608    {
609       GLuint VertexPointerOffset = _glapi_get_proc_offset("glVertexPointer");
610       char *VertexPointerFunc = (char*) &table->VertexPointer;
611       GLuint offset = (VertexPointerFunc - (char *) table) / sizeof(void *);
612       assert(VertexPointerOffset == _gloffset_VertexPointer);
613       assert(VertexPointerOffset == offset);
614    }
615    {
616       GLuint ResetMinMaxOffset = _glapi_get_proc_offset("glResetMinmax");
617       char *ResetMinMaxFunc = (char*) &table->ResetMinmax;
618       GLuint offset = (ResetMinMaxFunc - (char *) table) / sizeof(void *);
619       assert(ResetMinMaxOffset == _gloffset_ResetMinmax);
620       assert(ResetMinMaxOffset == offset);
621    }
622    {
623       GLuint blendColorOffset = _glapi_get_proc_offset("glBlendColor");
624       char *blendColorFunc = (char*) &table->BlendColor;
625       GLuint offset = (blendColorFunc - (char *) table) / sizeof(void *);
626       assert(blendColorOffset == _gloffset_BlendColor);
627       assert(blendColorOffset == offset);
628    }
629    {
630       GLuint secondaryColor3fOffset = _glapi_get_proc_offset("glSecondaryColor3fEXT");
631       char *secondaryColor3fFunc = (char*) &table->SecondaryColor3fEXT;
632       GLuint offset = (secondaryColor3fFunc - (char *) table) / sizeof(void *);
633       assert(secondaryColor3fOffset == _gloffset_SecondaryColor3fEXT);
634       assert(secondaryColor3fOffset == offset);
635    }
636    {
637       GLuint pointParameterivOffset = _glapi_get_proc_offset("glPointParameterivNV");
638       char *pointParameterivFunc = (char*) &table->PointParameterivNV;
639       GLuint offset = (pointParameterivFunc - (char *) table) / sizeof(void *);
640       assert(pointParameterivOffset == _gloffset_PointParameterivNV);
641       assert(pointParameterivOffset == offset);
642    }
643    {
644       GLuint setFenceOffset = _glapi_get_proc_offset("glSetFenceNV");
645       char *setFenceFunc = (char*) &table->SetFenceNV;
646       GLuint offset = (setFenceFunc - (char *) table) / sizeof(void *);
647       assert(setFenceOffset == _gloffset_SetFenceNV);
648       assert(setFenceOffset == offset);
649    }
650 #else
651    (void) table;
652 #endif
653 }