summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Li <davidxli@google.com>2011-02-03 10:26:30 -0800
committerDavid Li <davidxli@google.com>2011-02-03 10:26:30 -0800
commita15cd3d6d90715bf22a292ac63e2fbf72ec48959 (patch)
treeab0a33cb4e4536b6349bda9cac793f438c5bda64
parent3225321119408735f16b72b539c9fb7d80683552 (diff)
Delete unnecessary files.
Signed-off-by: David Li <davidxli@google.com>
-rw-r--r--src/mapi/glapi/.gitignore11
-rw-r--r--src/mapi/glapi/glapi_dispatch.c92
-rw-r--r--src/mapi/glapi/glapi_entrypoint.c344
-rw-r--r--src/mapi/glapi/glapi_getproc.c666
-rw-r--r--src/mapi/glapi/glapi_nop.c117
-rw-r--r--src/mapi/glapi/glthread.c7
-rw-r--r--src/mapi/mapi/entry.c65
-rw-r--r--src/mapi/mapi/mapi.c190
-rw-r--r--src/mapi/mapi/stub.c166
-rw-r--r--src/mapi/mapi/table.c56
-rw-r--r--src/mapi/mapi/u_current.c277
-rw-r--r--src/mapi/mapi/u_execmem.c145
-rw-r--r--src/mapi/mapi/u_thread.c254
-rw-r--r--src/mesa/main/context.c1885
-rw-r--r--src/mesa/main/debug.c633
-rw-r--r--src/mesa/main/get.c2464
-rw-r--r--src/mesa/main/getstring.c251
-rw-r--r--src/mesa/main/hash.c547
-rw-r--r--src/mesa/main/imports.c1032
-rw-r--r--src/mesa/main/version.c284
-rw-r--r--src/mesa/main/vsnprintf.c165
21 files changed, 0 insertions, 9651 deletions
diff --git a/src/mapi/glapi/.gitignore b/src/mapi/glapi/.gitignore
deleted file mode 100644
index e706bc2..0000000
--- a/src/mapi/glapi/.gitignore
+++ /dev/null
@@ -1,11 +0,0 @@
-.cvsignore
-glX_proto_common.pyo
-glX_proto_common.pyc
-typeexpr.pyo
-typeexpr.pyc
-license.pyo
-license.pyc
-gl_XML.pyo
-gl_XML.pyc
-glX_XML.pyo
-glX_XML.pyc
diff --git a/src/mapi/glapi/glapi_dispatch.c b/src/mapi/glapi/glapi_dispatch.c
deleted file mode 100644
index 989f4a3..0000000
--- a/src/mapi/glapi/glapi_dispatch.c
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version: 6.3
- *
- * Copyright (C) 1999-2004 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.
- */
-
-
-/**
- * \file glapi_dispatch.c
- *
- * This file generates all the gl* function entrypoints. This code is not
- * used if optimized assembly stubs are available (e.g., using
- * glapi/glapi_x86.S on IA32 or glapi/glapi_sparc.S on SPARC).
- *
- * \note
- * This file is also used to build the client-side libGL that loads DRI-based
- * device drivers. At build-time it is symlinked to src/glx.
- *
- * \author Brian Paul <brian@precisioninsight.com>
- */
-
-#include "glapi/glapi_priv.h"
-#include "glapi/glapitable.h"
-
-
-#if !(defined(USE_X86_ASM) || defined(USE_X86_64_ASM) || defined(USE_SPARC_ASM))
-
-#if defined(WIN32)
-#define KEYWORD1 GLAPI
-#else
-#define KEYWORD1 PUBLIC
-#endif
-
-#define KEYWORD2 GLAPIENTRY
-
-#if defined(USE_MGL_NAMESPACE)
-#define NAME(func) mgl##func
-#else
-#define NAME(func) gl##func
-#endif
-
-#if 0 /* Use this to log GL calls to stdout (for DEBUG only!) */
-
-#define F stdout
-#define DISPATCH(FUNC, ARGS, MESSAGE) \
- fprintf MESSAGE; \
- GET_DISPATCH()->FUNC ARGS
-
-#define RETURN_DISPATCH(FUNC, ARGS, MESSAGE) \
- fprintf MESSAGE; \
- return GET_DISPATCH()->FUNC ARGS
-
-#else
-
-#define DISPATCH(FUNC, ARGS, MESSAGE) \
- GET_DISPATCH()->FUNC ARGS
-
-#define RETURN_DISPATCH(FUNC, ARGS, MESSAGE) \
- return GET_DISPATCH()->FUNC ARGS
-
-#endif /* logging */
-
-
-#ifndef GLAPIENTRY
-#define GLAPIENTRY
-#endif
-
-#ifdef GLX_INDIRECT_RENDERING
-/* those link to libglapi.a should provide the entry points */
-#define _GLAPI_SKIP_PROTO_ENTRY_POINTS
-#endif
-#include "glapi/glapitemp.h"
-
-#endif /* USE_X86_ASM */
diff --git a/src/mapi/glapi/glapi_entrypoint.c b/src/mapi/glapi/glapi_entrypoint.c
deleted file mode 100644
index 993ccb9..0000000
--- a/src/mapi/glapi/glapi_entrypoint.c
+++ /dev/null
@@ -1,344 +0,0 @@
-/*
- * 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.
- */
-
-/**
- * \file glapi_entrypoint.c
- *
- * Arch-specific code for manipulating GL API entrypoints (dispatch stubs).
- */
-
-
-#include "glapi/glapi_priv.h"
-#include "mapi/u_execmem.h"
-
-
-#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(DISPATCH_FUNCTION_SIZE)
-
-_glapi_proc
-get_entrypoint_address(unsigned int functionOffset)
-{
- return (_glapi_proc) (gl_dispatch_functions_start
- + (DISPATCH_FUNCTION_SIZE * functionOffset));
-}
-
-#endif
-
-
-#if defined(USE_X86_ASM)
-
-/**
- * Perform platform-specific GL API entry-point fixups.
- */
-static void
-init_glapi_relocs( void )
-{
-#if 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
-}
-
-
-/**
- * Generate a dispatch function (entrypoint) which jumps through
- * the given slot number (offset) in the current dispatch table.
- * We need assembly language in order to accomplish this.
- */
-_glapi_proc
-generate_entrypoint(unsigned int functionOffset)
-{
- /* 32 is chosen as something of a magic offset. For x86, the dispatch
- * at offset 32 is the first one where the offset in the
- * "jmp OFFSET*4(%eax)" can't be encoded in a single byte.
- */
- const GLubyte * const template_func = gl_dispatch_functions_start
- + (DISPATCH_FUNCTION_SIZE * 32);
- GLubyte * const code = (GLubyte *) u_execmem_alloc(DISPATCH_FUNCTION_SIZE);
-
-
- if ( code != NULL ) {
- (void) memcpy(code, template_func, DISPATCH_FUNCTION_SIZE);
- fill_in_entrypoint_offset( (_glapi_proc) code, functionOffset );
- }
-
- return (_glapi_proc) code;
-}
-
-
-/**
- * This function inserts a new dispatch offset into the assembly language
- * stub that was generated with the preceeding function.
- */
-void
-fill_in_entrypoint_offset(_glapi_proc entrypoint, unsigned int offset)
-{
- GLubyte * const code = (GLubyte *) entrypoint;
-
-#if defined(GLX_USE_TLS)
- *((unsigned int *)(code + 8)) = 4 * offset;
-#elif defined(THREADS)
- *((unsigned int *)(code + 11)) = 4 * offset;
- *((unsigned int *)(code + 22)) = 4 * offset;
-#else
- *((unsigned int *)(code + 7)) = 4 * offset;
-#endif
-}
-
-
-#elif defined(USE_SPARC_ASM)
-
-extern void __glapi_sparc_icache_flush(unsigned int *);
-
-static void
-init_glapi_relocs( void )
-{
-#if defined(PTHREADS) || defined(GLX_USE_TLS)
- 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
-
-#ifdef 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
-}
-
-
-_glapi_proc
-generate_entrypoint(GLuint functionOffset)
-{
-#if defined(PTHREADS) || defined(GLX_USE_TLS)
- static const unsigned int template[] = {
- 0x07000000, /* sethi %hi(0), %g3 */
- 0x8210000f, /* mov %o7, %g1 */
- 0x40000000, /* call */
- 0x9e100001, /* mov %g1, %o7 */
- };
-#ifdef GLX_USE_TLS
- extern unsigned int __glapi_sparc_tls_stub;
- unsigned long call_dest = (unsigned long ) &__glapi_sparc_tls_stub;
-#else
- extern unsigned int __glapi_sparc_pthread_stub;
- unsigned long call_dest = (unsigned long ) &__glapi_sparc_pthread_stub;
-#endif
- unsigned int *code = (unsigned int *) u_execmem_alloc(sizeof(template));
- if (code) {
- code[0] = template[0] | (functionOffset & 0x3fffff);
- code[1] = template[1];
- __glapi_sparc_icache_flush(&code[0]);
- code[2] = template[2] |
- (((call_dest - ((unsigned long) &code[2]))
- >> 2) & 0x3fffffff);
- code[3] = template[3];
- __glapi_sparc_icache_flush(&code[2]);
- }
- return (_glapi_proc) code;
-#endif
-}
-
-
-void
-fill_in_entrypoint_offset(_glapi_proc entrypoint, GLuint offset)
-{
- unsigned int *code = (unsigned int *) entrypoint;
-
- code[0] &= ~0x3fffff;
- code[0] |= (offset * sizeof(void *)) & 0x3fffff;
- __glapi_sparc_icache_flush(&code[0]);
-}
-
-
-#else /* USE_*_ASM */
-
-static void
-init_glapi_relocs( void )
-{
-}
-
-
-_glapi_proc
-generate_entrypoint(GLuint functionOffset)
-{
- (void) functionOffset;
- return NULL;
-}
-
-
-void
-fill_in_entrypoint_offset(_glapi_proc entrypoint, GLuint offset)
-{
- /* an unimplemented architecture */
- (void) entrypoint;
- (void) offset;
-}
-
-#endif /* USE_*_ASM */
-
-
-void
-init_glapi_relocs_once( void )
-{
-#if defined(PTHREADS) || defined(GLX_USE_TLS)
- static pthread_once_t once_control = PTHREAD_ONCE_INIT;
- pthread_once( & once_control, init_glapi_relocs );
-#endif
-}
diff --git a/src/mapi/glapi/glapi_getproc.c b/src/mapi/glapi/glapi_getproc.c
deleted file mode 100644
index 0a6ff77..0000000
--- a/src/mapi/glapi/glapi_getproc.c
+++ /dev/null
@@ -1,666 +0,0 @@
-/*
- * 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.
- */
-
-/**
- * \file glapi_getproc.c
- *
- * Code for implementing glXGetProcAddress(), etc.
- * This was originally in glapi.c but refactored out.
- */
-
-
-#include "glapi/glapi_priv.h"
-#include "glapi/glapitable.h"
-
-
-#define FIRST_DYNAMIC_OFFSET (sizeof(struct _glapi_table) / sizeof(void *))
-
-
-/**********************************************************************
- * Static function management.
- */
-
-
-#if !defined(DISPATCH_FUNCTION_SIZE)
-# define NEED_FUNCTION_POINTER
-#endif
-#include "glapi/glprocs.h"
-
-
-/**
- * Search the table of static entrypoint functions for the named function
- * and return the corresponding glprocs_table_t entry.
- */
-static const glprocs_table_t *
-get_static_proc( const char * n )
-{
- GLuint i;
- for (i = 0; static_functions[i].Name_offset >= 0; i++) {
- const char *testName = gl_string_table + static_functions[i].Name_offset;
-#ifdef MANGLE
- /* skip the prefix on the name */
- if (strcmp(testName, n + 1) == 0)
-#else
- if (strcmp(testName, n) == 0)
-#endif
- {
- return &static_functions[i];
- }
- }
- return NULL;
-}
-
-
-/**
- * Return dispatch table offset of the named static (built-in) function.
- * Return -1 if function not found.
- */
-static GLint
-get_static_proc_offset(const char *funcName)
-{
- const glprocs_table_t * const f = get_static_proc( funcName );
- if (f == NULL) {
- return -1;
- }
-
- return f->Offset;
-}
-
-
-
-/**
- * Return dispatch function address for the named static (built-in) function.
- * Return NULL if function not found.
- */
-static _glapi_proc
-get_static_proc_address(const char *funcName)
-{
- const glprocs_table_t * const f = get_static_proc( funcName );
- if (f == NULL) {
- return NULL;
- }
-
-#if defined(DISPATCH_FUNCTION_SIZE) && defined(GLX_INDIRECT_RENDERING)
- return (f->Address == NULL)
- ? get_entrypoint_address(f->Offset)
- : f->Address;
-#elif defined(DISPATCH_FUNCTION_SIZE)
- return get_entrypoint_address(f->Offset);
-#else
- return f->Address;
-#endif
-}
-
-
-
-/**
- * Return the name of the function at the given offset in the dispatch
- * table. For debugging only.
- */
-static const char *
-get_static_proc_name( GLuint offset )
-{
- GLuint i;
- for (i = 0; static_functions[i].Name_offset >= 0; i++) {
- if (static_functions[i].Offset == offset) {
- return gl_string_table + static_functions[i].Name_offset;
- }
- }
- return NULL;
-}
-
-
-
-/**********************************************************************
- * Extension function management.
- */
-
-
-/**
- * Track information about a function added to the GL API.
- */
-struct _glapi_function {
- /**
- * Name of the function.
- */
- const char * name;
-
-
- /**
- * Text string that describes the types of the parameters passed to the
- * named function. Parameter types are converted to characters using the
- * following rules:
- * - 'i' for \c GLint, \c GLuint, and \c GLenum
- * - 'p' for any pointer type
- * - 'f' for \c GLfloat and \c GLclampf
- * - 'd' for \c GLdouble and \c GLclampd
- */
- const char * parameter_signature;
-
-
- /**
- * Offset in the dispatch table where the pointer to the real function is
- * located. If the driver has not requested that the named function be
- * added to the dispatch table, this will have the value ~0.
- */
- unsigned dispatch_offset;
-
-
- /**
- * Pointer to the dispatch stub for the named function.
- *
- * \todo
- * The semantic of this field should be changed slightly. Currently, it
- * is always expected to be non-\c NULL. However, it would be better to
- * only allocate the entry-point stub when the application requests the
- * function via \c glXGetProcAddress. This would save memory for all the
- * functions that the driver exports but that the application never wants
- * to call.
- */
- _glapi_proc dispatch_stub;
-};
-
-
-static struct _glapi_function ExtEntryTable[MAX_EXTENSION_FUNCS];
-static GLuint NumExtEntryPoints = 0;
-
-
-static struct _glapi_function *
-get_extension_proc(const char *funcName)
-{
- GLuint i;
- for (i = 0; i < NumExtEntryPoints; i++) {
- if (strcmp(ExtEntryTable[i].name, funcName) == 0) {
- return & ExtEntryTable[i];
- }
- }
- return NULL;
-}
-
-
-static GLint
-get_extension_proc_offset(const char *funcName)
-{
- const struct _glapi_function * const f = get_extension_proc( funcName );
- if (f == NULL) {
- return -1;
- }
-
- return f->dispatch_offset;
-}
-
-
-static _glapi_proc
-get_extension_proc_address(const char *funcName)
-{
- const struct _glapi_function * const f = get_extension_proc( funcName );
- if (f == NULL) {
- return NULL;
- }
-
- return f->dispatch_stub;
-}
-
-
-static const char *
-get_extension_proc_name(GLuint offset)
-{
- GLuint i;
- for (i = 0; i < NumExtEntryPoints; i++) {
- if (ExtEntryTable[i].dispatch_offset == offset) {
- return ExtEntryTable[i].name;
- }
- }
- return NULL;
-}
-
-
-/**
- * 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
- *
- * Use a temporary dispatch offset of ~0 (i.e. -1). Later, when the driver
- * calls \c _glapi_add_dispatch we'll put in the proper offset. If that
- * never happens, and the user calls this function, he'll segfault. That's
- * what you get when you try calling a GL function that doesn't really exist.
- *
- * \param funcName Name of the function to create an entry-point for.
- *
- * \sa _glapi_add_entrypoint
- */
-
-static struct _glapi_function *
-add_function_name( const char * funcName )
-{
- struct _glapi_function * entry = NULL;
- _glapi_proc entrypoint = NULL;
- char * name_dup = NULL;
-
- if (NumExtEntryPoints >= MAX_EXTENSION_FUNCS)
- return NULL;
-
- if (funcName == NULL)
- return NULL;
-
- name_dup = str_dup(funcName);
- if (name_dup == NULL)
- return NULL;
-
- entrypoint = generate_entrypoint(~0);
-
- if (entrypoint == NULL) {
- free(name_dup);
- return NULL;
- }
-
- entry = & ExtEntryTable[NumExtEntryPoints];
- NumExtEntryPoints++;
-
- entry->name = name_dup;
- entry->parameter_signature = NULL;
- entry->dispatch_offset = ~0;
- entry->dispatch_stub = entrypoint;
-
- return entry;
-}
-
-
-static struct _glapi_function *
-set_entry_info( struct _glapi_function * entry, const char * signature, unsigned offset )
-{
- char * sig_dup = NULL;
-
- if (signature == NULL)
- return NULL;
-
- sig_dup = str_dup(signature);
- if (sig_dup == NULL)
- return NULL;
-
- fill_in_entrypoint_offset(entry->dispatch_stub, offset);
-
- entry->parameter_signature = sig_dup;
- entry->dispatch_offset = offset;
-
- return entry;
-}
-
-
-/**
- * Fill-in the dispatch stub for the named function.
- *
- * This function is intended to be called by a hardware driver. When called,
- * a dispatch stub may be created created for the function. A pointer to this
- * dispatch function will be returned by glXGetProcAddress.
- *
- * \param function_names Array of pointers to function names that should
- * share a common dispatch offset.
- * \param parameter_signature String representing the types of the parameters
- * passed to the named function. Parameter types
- * are converted to characters using the following
- * rules:
- * - 'i' for \c GLint, \c GLuint, and \c GLenum
- * - 'p' for any pointer type
- * - 'f' for \c GLfloat and \c GLclampf
- * - 'd' for \c GLdouble and \c GLclampd
- *
- * \returns
- * The offset in the dispatch table of the named function. A pointer to the
- * driver's implementation of the named function should be stored at
- * \c dispatch_table[\c offset]. Return -1 if error/problem.
- *
- * \sa glXGetProcAddress
- *
- * \warning
- * This function can only handle up to 8 names at a time. As far as I know,
- * the maximum number of names ever associated with an existing GL function is
- * 4 (\c glPointParameterfSGIS, \c glPointParameterfEXT,
- * \c glPointParameterfARB, and \c glPointParameterf), so this should not be
- * too painful of a limitation.
- *
- * \todo
- * Determine whether or not \c parameter_signature should be allowed to be
- * \c NULL. It doesn't seem like much of a hardship for drivers to have to
- * pass in an empty string.
- *
- * \todo
- * Determine if code should be added to reject function names that start with
- * 'glX'.
- *
- * \bug
- * Add code to compare \c parameter_signature with the parameter signature of
- * a static function. In order to do that, we need to find a way to \b get
- * the parameter signature of a static function.
- */
-
-int
-_glapi_add_dispatch( const char * const * function_names,
- const char * parameter_signature )
-{
- static int next_dynamic_offset = FIRST_DYNAMIC_OFFSET;
- const char * const real_sig = (parameter_signature != NULL)
- ? parameter_signature : "";
- struct _glapi_function * entry[8];
- GLboolean is_static[8];
- unsigned i;
- int offset = ~0;
-
- init_glapi_relocs_once();
-
- (void) memset( is_static, 0, sizeof( is_static ) );
- (void) memset( entry, 0, sizeof( entry ) );
-
- /* Find the _single_ dispatch offset for all function names that already
- * exist (and have a dispatch offset).
- */
-
- for ( i = 0 ; function_names[i] != NULL ; i++ ) {
- const char * funcName = function_names[i];
- int static_offset;
- int extension_offset;
-
- if (funcName[0] != 'g' || funcName[1] != 'l')
- return -1;
-
- /* search built-in functions */
- static_offset = get_static_proc_offset(funcName);
-
- if (static_offset >= 0) {
-
- is_static[i] = GL_TRUE;
-
- /* FIXME: Make sure the parameter signatures match! How do we get
- * FIXME: the parameter signature for static functions?
- */
-
- if ( (offset != ~0) && (static_offset != offset) ) {
- return -1;
- }
-
- offset = static_offset;
-
- continue;
- }
-
- /* search added extension functions */
- entry[i] = get_extension_proc(funcName);
-
- if (entry[i] != NULL) {
- extension_offset = entry[i]->dispatch_offset;
-
- /* The offset may be ~0 if the function name was added by
- * glXGetProcAddress but never filled in by the driver.
- */
-
- if (extension_offset == ~0) {
- continue;
- }
-
- if (strcmp(real_sig, entry[i]->parameter_signature) != 0) {
- return -1;
- }
-
- if ( (offset != ~0) && (extension_offset != offset) ) {
- return -1;
- }
-
- offset = extension_offset;
- }
- }
-
- /* If all function names are either new (or with no dispatch offset),
- * allocate a new dispatch offset.
- */
-
- if (offset == ~0) {
- offset = next_dynamic_offset;
- next_dynamic_offset++;
- }
-
- /* Fill in the dispatch offset for the new function names (and those with
- * no dispatch offset).
- */
-
- for ( i = 0 ; function_names[i] != NULL ; i++ ) {
- if (is_static[i]) {
- continue;
- }
-
- /* generate entrypoints for new function names */
- if (entry[i] == NULL) {
- entry[i] = add_function_name( function_names[i] );
- if (entry[i] == NULL) {
- /* FIXME: Possible memory leak here. */
- return -1;
- }
- }
-
- if (entry[i]->dispatch_offset == ~0) {
- set_entry_info( entry[i], real_sig, offset );
- }
- }
-
- return offset;
-}
-
-
-/**
- * Return offset of entrypoint for named function within dispatch table.
- */
-GLint
-_glapi_get_proc_offset(const char *funcName)
-{
- GLint offset;
-
- /* search extension functions first */
- offset = get_extension_proc_offset(funcName);
- if (offset >= 0)
- return offset;
-
- /* search static functions */
- return get_static_proc_offset(funcName);
-}
-
-
-
-/**
- * Return pointer to the named function. If the function name isn't found
- * in the name of static functions, try generating a new API entrypoint on
- * the fly with assembly language.
- */
-_glapi_proc
-_glapi_get_proc_address(const char *funcName)
-{
- _glapi_proc func;
- struct _glapi_function * entry;
-
- init_glapi_relocs_once();
-
-#ifdef MANGLE
- /* skip the prefix on the name */
- if (funcName[1] != 'g' || funcName[2] != 'l')
- return NULL;
-#else
- if (funcName[0] != 'g' || funcName[1] != 'l')
- return NULL;
-#endif
-
- /* search extension functions first */
- func = get_extension_proc_address(funcName);
- if (func)
- return func;
-
- /* search static functions */
- func = get_static_proc_address(funcName);
- if (func)
- return func;
-
- /* generate entrypoint, dispatch offset must be filled in by the driver */
- entry = add_function_name(funcName);
- if (entry == NULL)
- return NULL;
-
- return entry->dispatch_stub;
-}
-
-
-
-/**
- * Return the name of the function at the given dispatch offset.
- * This is only intended for debugging.
- */
-const char *
-_glapi_get_proc_name(GLuint offset)
-{
- const char * n;
-
- /* search built-in functions */
- n = get_static_proc_name(offset);
- if ( n != NULL ) {
- return n;
- }
-
- /* search added extension functions */
- return get_extension_proc_name(offset);
-}
-
-
-
-/**********************************************************************
- * GL API table functions.
- */
-
-
-/**
- * Return size of dispatch table struct as number of functions (or
- * slots).
- */
-GLuint
-_glapi_get_dispatch_table_size(void)
-{
- /*
- * 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.
- */
- return FIRST_DYNAMIC_OFFSET + MAX_EXTENSION_FUNCS;
-}
-
-
-/**
- * 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.
- */
-void
-_glapi_check_table(const struct _glapi_table *table)
-{
-#ifdef EXTRA_DEBUG /* set to DEBUG for extra DEBUG */
- {
- GLuint BeginOffset = _glapi_get_proc_offset("glBegin");
- char *BeginFunc = (char*) &table->Begin;
- GLuint offset = (BeginFunc - (char *) table) / sizeof(void *);
- assert(BeginOffset == offset);
- }
- {
- GLuint viewportOffset = _glapi_get_proc_offset("glViewport");
- char *viewportFunc = (char*) &table->Viewport;
- GLuint offset = (viewportFunc - (char *) table) / sizeof(void *);
- assert(viewportOffset == offset);
- }
- {
- GLuint VertexPointerOffset = _glapi_get_proc_offset("glVertexPointer");
- char *VertexPointerFunc = (char*) &table->VertexPointer;
- GLuint offset = (VertexPointerFunc - (char *) table) / sizeof(void *);
- assert(VertexPointerOffset == offset);
- }
- {
- GLuint ResetMinMaxOffset = _glapi_get_proc_offset("glResetMinmax");
- char *ResetMinMaxFunc = (char*) &table->ResetMinmax;
- GLuint offset = (ResetMinMaxFunc - (char *) table) / sizeof(void *);
- assert(ResetMinMaxOffset == offset);
- }
- {
- GLuint blendColorOffset = _glapi_get_proc_offset("glBlendColor");
- char *blendColorFunc = (char*) &table->BlendColor;
- GLuint offset = (blendColorFunc - (char *) table) / sizeof(void *);
- assert(blendColorOffset == offset);
- }
- {
- GLuint secondaryColor3fOffset = _glapi_get_proc_offset("glSecondaryColor3fEXT");
- char *secondaryColor3fFunc = (char*) &table->SecondaryColor3fEXT;
- GLuint offset = (secondaryColor3fFunc - (char *) table) / sizeof(void *);
- assert(secondaryColor3fOffset == offset);
- }
- {
- GLuint pointParameterivOffset = _glapi_get_proc_offset("glPointParameterivNV");
- char *pointParameterivFunc = (char*) &table->PointParameterivNV;
- GLuint offset = (pointParameterivFunc - (char *) table) / sizeof(void *);
- assert(pointParameterivOffset == offset);
- }
- {
- GLuint setFenceOffset = _glapi_get_proc_offset("glSetFenceNV");
- char *setFenceFunc = (char*) &table->SetFenceNV;
- GLuint offset = (setFenceFunc - (char *) table) / sizeof(void *);
- assert(setFenceOffset == offset);
- }
-#else
- (void) table;
-#endif
-}
diff --git a/src/mapi/glapi/glapi_nop.c b/src/mapi/glapi/glapi_nop.c
deleted file mode 100644
index 9b09297..0000000
--- a/src/mapi/glapi/glapi_nop.c
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version: 7.8
- *
- * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
- * Copyright (C) 2010 VMware, Inc. 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
- * THE AUTHORS 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.
- */
-
-
-/**
- * No-op dispatch table.
- *
- * This file defines a special dispatch table which is loaded with no-op
- * functions.
- *
- * When there's no current rendering context, calling a GL function like
- * glBegin() is a no-op. Apps should never normally do this. So as a
- * debugging aid, each of the no-op functions will emit a warning to
- * stderr if the MESA_DEBUG or LIBGL_DEBUG env var is set.
- */
-
-
-
-#include "glapi/glapi_priv.h"
-
-
-void
-_glapi_noop_enable_warnings(unsigned char enable)
-{
-}
-
-void
-_glapi_set_warning_func(_glapi_proc func)
-{
-}
-
-#ifdef DEBUG
-
-/**
- * Called by each of the no-op GL entrypoints.
- */
-static int
-Warn(const char *func)
-{
-#if !defined(_WIN32_WCE)
- if (getenv("MESA_DEBUG") || getenv("LIBGL_DEBUG")) {
- fprintf(stderr, "GL User Error: gl%s called without a rendering context\n",
- func);
- }
-#endif
- return 0;
-}
-
-
-/**
- * This is called if the user somehow calls an unassigned GL dispatch function.
- */
-static GLint
-NoOpUnused(void)
-{
- return Warn(" function");
-}
-
-/*
- * Defines for the glapitemp.h functions.
- */
-#define KEYWORD1 static
-#define KEYWORD1_ALT static
-#define KEYWORD2 GLAPIENTRY
-#define NAME(func) NoOp##func
-#define DISPATCH(func, args, msg) Warn(#func);
-#define RETURN_DISPATCH(func, args, msg) Warn(#func); return 0
-
-
-/*
- * Defines for the table of no-op entry points.
- */
-#define TABLE_ENTRY(name) (_glapi_proc) NoOp##name
-
-#else
-
-static int
-NoOpGeneric(void)
-{
-#if !defined(_WIN32_WCE)
- if (getenv("MESA_DEBUG") || getenv("LIBGL_DEBUG")) {
- fprintf(stderr, "GL User Error: calling GL function without a rendering context\n");
- }
-#endif
- return 0;
-}
-
-#define TABLE_ENTRY(name) (_glapi_proc) NoOpGeneric
-
-#endif
-
-#define DISPATCH_TABLE_NAME __glapi_noop_table
-#define UNUSED_TABLE_NAME __unused_noop_functions
-
-#include "glapi/glapitemp.h"
diff --git a/src/mapi/glapi/glthread.c b/src/mapi/glapi/glthread.c
deleted file mode 100644
index 0091538..0000000
--- a/src/mapi/glapi/glthread.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include "glapi/glapi.h"
-
-unsigned long
-_glthread_GetID(void)
-{
- return u_thread_self();
-}
diff --git a/src/mapi/mapi/entry.c b/src/mapi/mapi/entry.c
deleted file mode 100644
index fdf2a89..0000000
--- a/src/mapi/mapi/entry.c
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version: 7.9
- *
- * Copyright (C) 2010 LunarG Inc.
- *
- * 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
- * THE AUTHORS OR COPYRIGHT HOLDERS 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.
- *
- * Authors:
- * Chia-I Wu <olv@lunarg.com>
- */
-
-#include "entry.h"
-
-#if defined(USE_X86_ASM) && defined(__GNUC__)
-# ifdef GLX_USE_TLS
-# include "entry_x86_tls.h"
-# else
-# include "entry_x86_tsd.h"
-# endif
-#elif defined(USE_X86_64_ASM) && defined(__GNUC__) && defined(GLX_USE_TLS)
-# include "entry_x86-64_tls.h"
-#else
-
-#include <stdlib.h>
-#include "u_current.h"
-#include "table.h"
-
-/* C version of the public entries */
-#define MAPI_TMP_PUBLIC_ENTRIES
-#include "mapi_tmp.h"
-
-void
-entry_patch_public(void)
-{
-}
-
-mapi_func
-entry_generate(int slot)
-{
- return NULL;
-}
-
-void
-entry_patch(mapi_func entry, int slot)
-{
-}
-
-#endif /* asm */
diff --git a/src/mapi/mapi/mapi.c b/src/mapi/mapi/mapi.c
deleted file mode 100644
index 5476d37..0000000
--- a/src/mapi/mapi/mapi.c
+++ /dev/null
@@ -1,190 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version: 7.9
- *
- * Copyright (C) 2010 LunarG Inc.
- *
- * 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
- * THE AUTHORS OR COPYRIGHT HOLDERS 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.
- *
- * Authors:
- * Chia-I Wu <olv@lunarg.com>
- */
-
-#include <stdlib.h>
-#include <string.h>
-
-#include "u_current.h"
-#include "u_thread.h"
-#include "mapi.h"
-#include "stub.h"
-#include "table.h"
-
-/* dynamic stubs will run out before this array */
-static const struct mapi_stub *mapi_stub_map[MAPI_TABLE_NUM_SLOTS];
-static int mapi_num_stubs;
-
-static const struct mapi_stub *
-get_stub(const char *name, const struct mapi_stub *alias)
-{
- const struct mapi_stub *stub;
-
- stub = stub_find_public(name);
- if (!stub) {
- struct mapi_stub *dyn = stub_find_dynamic(name, 1);
- if (dyn) {
- stub_fix_dynamic(dyn, alias);
- stub = dyn;
- }
- }
-
- return stub;
-}
-
-/**
- * Initialize mapi. spec consists of NULL-separated strings. The first string
- * denotes the version. It is followed by variable numbers of entries. Each
- * entry can have multiple names. An empty name terminates an entry. An empty
- * entry terminates the spec. A spec of two entries, Foo and Bar, is as
- * follows
- *
- * "1\0"
- * "Foo\0"
- * "FooEXT\0"
- * "\0"
- * "Bar\0"
- * "\0"
- */
-void
-mapi_init(const char *spec)
-{
- u_mutex_declare_static(mutex);
- const char *p;
- int ver, count;
-
- u_mutex_lock(mutex);
-
- /* already initialized */
- if (mapi_num_stubs) {
- u_mutex_unlock(mutex);
- return;
- }
-
- count = 0;
- p = spec;
-
- /* parse version string */
- ver = atoi(p);
- if (ver != 1) {
- u_mutex_unlock(mutex);
- return;
- }
- p += strlen(p) + 1;
-
- while (*p) {
- const struct mapi_stub *stub;
-
- stub = get_stub(p, NULL);
- /* out of dynamic entries */
- if (!stub)
- break;
- p += strlen(p) + 1;
-
- while (*p) {
- get_stub(p, stub);
- p += strlen(p) + 1;
- }
-
- mapi_stub_map[count++] = stub;
- p++;
- }
-
- mapi_num_stubs = count;
-
- u_mutex_unlock(mutex);
-}
-
-/**
- * Return the address of an entry. Optionally generate the entry if it does
- * not exist.
- */
-mapi_proc
-mapi_get_proc_address(const char *name)
-{
- const struct mapi_stub *stub;
-
- stub = stub_find_public(name);
- if (!stub)
- stub = stub_find_dynamic(name, 0);
-
- return (stub) ? (mapi_proc) stub->addr : NULL;
-}
-
-/**
- * Create a dispatch table.
- */
-struct mapi_table *
-mapi_table_create(void)
-{
- const struct mapi_table *noop = table_get_noop();
- struct mapi_table *tbl;
-
- tbl = malloc(MAPI_TABLE_SIZE);
- if (tbl)
- memcpy(tbl, noop, MAPI_TABLE_SIZE);
-
- return tbl;
-}
-
-/**
- * Destroy a dispatch table.
- */
-void
-mapi_table_destroy(struct mapi_table *tbl)
-{
- free(tbl);
-}
-
-/**
- * Fill a dispatch table. The order of the procs is determined when mapi_init
- * is called.
- */
-void
-mapi_table_fill(struct mapi_table *tbl, const mapi_proc *procs)
-{
- const struct mapi_table *noop = table_get_noop();
- int i;
-
- for (i = 0; i < mapi_num_stubs; i++) {
- const struct mapi_stub *stub = mapi_stub_map[i];
- mapi_func func = (mapi_func) procs[i];
-
- if (!func)
- func = table_get_func(noop, stub);
- table_set_func(tbl, stub, func);
- }
-}
-
-/**
- * Make a dispatch table current.
- */
-void
-mapi_table_make_current(const struct mapi_table *tbl)
-{
- u_current_set(tbl);
-}
diff --git a/src/mapi/mapi/stub.c b/src/mapi/mapi/stub.c
deleted file mode 100644
index 3594eac..0000000
--- a/src/mapi/mapi/stub.c
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version: 7.9
- *
- * Copyright (C) 2010 LunarG Inc.
- *
- * 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
- * THE AUTHORS OR COPYRIGHT HOLDERS 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.
- *
- * Authors:
- * Chia-I Wu <olv@lunarg.com>
- */
-
-#include <stdlib.h>
-#include <stddef.h> /* for offsetof */
-#include <string.h>
-#include <assert.h>
-
-#include "u_current.h"
-#include "u_thread.h"
-#include "entry.h"
-#include "stub.h"
-#include "table.h"
-
-#define ARRAY_SIZE(x) (sizeof(x)/sizeof((x)[0]))
-
-/* define public_string_pool and public_stubs */
-#define MAPI_TMP_PUBLIC_STUBS
-#include "mapi_tmp.h"
-
-static struct mapi_stub dynamic_stubs[MAPI_TABLE_NUM_DYNAMIC];
-static int num_dynamic_stubs;
-static int next_dynamic_slot = MAPI_TABLE_NUM_STATIC;
-
-void
-stub_init_once(void)
-{
-#ifdef PTHREADS
- static pthread_once_t once = PTHREAD_ONCE_INIT;
- pthread_once(&once, entry_patch_public);
-#else
- static int first = 1;
- if (first) {
- first = 0;
- entry_patch_public();
- }
-#endif
-}
-
-static int
-stub_compare(const void *key, const void *elem)
-{
- const char *name = (const char *) key;
- const struct mapi_stub *stub = (const struct mapi_stub *) elem;
- const char *stub_name;
-
- stub_name = &public_string_pool[(unsigned long) stub->name];
-
- return strcmp(name, stub_name);
-}
-
-/**
- * Return the public stub with the given name.
- */
-const struct mapi_stub *
-stub_find_public(const char *name)
-{
- return (const struct mapi_stub *) bsearch(name, public_stubs,
- ARRAY_SIZE(public_stubs), sizeof(public_stubs[0]), stub_compare);
-}
-
-/**
- * Add a dynamic stub.
- */
-static struct mapi_stub *
-stub_add_dynamic(const char *name)
-{
- struct mapi_stub *stub;
- int idx;
-
- idx = num_dynamic_stubs;
- /* minus 1 to make sure we can never reach the last slot */
- if (idx >= MAPI_TABLE_NUM_DYNAMIC - 1)
- return NULL;
-
- stub = &dynamic_stubs[idx];
-
- /* dispatch to the last slot, which is reserved for no-op */
- stub->addr = entry_generate(
- MAPI_TABLE_NUM_STATIC + MAPI_TABLE_NUM_DYNAMIC - 1);
- if (!stub->addr)
- return NULL;
-
- stub->name = (const void *) name;
- /* to be fixed later */
- stub->slot = -1;
-
- num_dynamic_stubs = idx + 1;
-
- return stub;
-}
-
-/**
- * Return the dynamic stub with the given name. If no such stub exists and
- * generate is true, a new stub is generated.
- */
-struct mapi_stub *
-stub_find_dynamic(const char *name, int generate)
-{
- u_mutex_declare_static(dynamic_mutex);
- struct mapi_stub *stub = NULL;
- int count, i;
-
- u_mutex_lock(dynamic_mutex);
-
- if (generate)
- assert(!stub_find_public(name));
-
- count = num_dynamic_stubs;
- for (i = 0; i < count; i++) {
- if (strcmp(name, (const char *) dynamic_stubs[i].name) == 0) {
- stub = &dynamic_stubs[i];
- break;
- }
- }
-
- /* generate a dynamic stub */
- if (generate && !stub)
- stub = stub_add_dynamic(name);
-
- u_mutex_unlock(dynamic_mutex);
-
- return stub;
-}
-
-void
-stub_fix_dynamic(struct mapi_stub *stub, const struct mapi_stub *alias)
-{
- int slot;
-
- if (stub->slot >= 0)
- return;
-
- if (alias)
- slot = alias->slot;
- else
- slot = next_dynamic_slot++;
-
- entry_patch(stub->addr, slot);
- stub->slot = slot;
-}
diff --git a/src/mapi/mapi/table.c b/src/mapi/mapi/table.c
deleted file mode 100644
index 8f4f700..0000000
--- a/src/mapi/mapi/table.c
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version: 7.9
- *
- * Copyright (C) 2010 LunarG Inc.
- *
- * 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
- * THE AUTHORS OR COPYRIGHT HOLDERS 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.
- *
- * Authors:
- * Chia-I Wu <olv@lunarg.com>
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-
-#include "stub.h"
-#include "table.h"
-
-static void
-noop_warn(const char *name)
-{
- static int debug = -1;
-
- if (debug < 0)
- debug = (getenv("MESA_DEBUG") || getenv("LIBGL_DEBUG"));
-
- if (debug)
- fprintf(stderr, "%s is no-op", name);
-}
-
-static int
-noop_generic(void)
-{
- noop_warn("function");
- return 0;
-}
-
-/* define noop_array */
-#define MAPI_TMP_NOOP_ARRAY
-#include "mapi_tmp.h"
diff --git a/src/mapi/mapi/u_current.c b/src/mapi/mapi/u_current.c
deleted file mode 100644
index 77a593b..0000000
--- a/src/mapi/mapi/u_current.c
+++ /dev/null
@@ -1,277 +0,0 @@
-/*
- * 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.
- */
-
-
-/*
- * This file manages the OpenGL API dispatch layer.
- * The dispatch table (struct _glapi_table) is basically just a list
- * of function pointers.
- * There are functions to set/get the current dispatch table for the
- * current thread and to manage registration/dispatch of dynamically
- * added extension functions.
- *
- * It's intended that this file and the other glapi*.[ch] files are
- * flexible enough to be reused in several places: XFree86, DRI-
- * based libGL.so, and perhaps the SGI SI.
- *
- * NOTE: There are no dependencies on Mesa in this code.
- *
- * Versions (API changes):
- * 2000/02/23 - original version for Mesa 3.3 and XFree86 4.0
- * 2001/01/16 - added dispatch override feature for Mesa 3.5
- * 2002/06/28 - added _glapi_set_warning_func(), Mesa 4.1.
- * 2002/10/01 - _glapi_get_proc_address() will now generate new entrypoints
- * itself (using offset ~0). _glapi_add_entrypoint() can be
- * called afterward and it'll fill in the correct dispatch
- * offset. This allows DRI libGL to avoid probing for DRI
- * drivers! No changes to the public glapi interface.
- */
-
-#include "u_current.h"
-#include "u_thread.h"
-
-#ifndef MAPI_GLAPI_CURRENT
-
-#include "table.h"
-#include "stub.h"
-
-#else
-
-extern void init_glapi_relocs_once(void);
-extern void (*__glapi_noop_table[])(void);
-
-#define table_noop_array __glapi_noop_table
-#define stub_init_once() init_glapi_relocs_once()
-
-#endif
-
-/**
- * \name Current dispatch and current context control variables
- *
- * Depending on whether or not multithreading is support, and the type of
- * support available, several variables are used to store the current context
- * pointer and the current dispatch table pointer. In the non-threaded case,
- * the variables \c _glapi_Dispatch and \c _glapi_Context are used for this
- * purpose.
- *
- * In the "normal" threaded case, the variables \c _glapi_Dispatch and
- * \c _glapi_Context will be \c NULL if an application is detected as being
- * multithreaded. Single-threaded applications will use \c _glapi_Dispatch
- * and \c _glapi_Context just like the case without any threading support.
- * When \c _glapi_Dispatch and \c _glapi_Context are \c NULL, the thread state
- * data \c _gl_DispatchTSD and \c ContextTSD are used. Drivers and the
- * static dispatch functions access these variables via \c _glapi_get_dispatch
- * and \c _glapi_get_context.
- *
- * There is a race condition in setting \c _glapi_Dispatch to \c NULL. It is
- * possible for the original thread to be setting it at the same instant a new
- * thread, perhaps running on a different processor, is clearing it. Because
- * of that, \c ThreadSafe, which can only ever be changed to \c GL_TRUE, is
- * used to determine whether or not the application is multithreaded.
- *
- * In the TLS case, the variables \c _glapi_Dispatch and \c _glapi_Context are
- * hardcoded to \c NULL. Instead the TLS variables \c _glapi_tls_Dispatch and
- * \c _glapi_tls_Context are used. Having \c _glapi_Dispatch and
- * \c _glapi_Context be hardcoded to \c NULL maintains binary compatability
- * between TLS enabled loaders and non-TLS DRI drivers.
- */
-/*@{*/
-#if defined(GLX_USE_TLS)
-
-__thread struct mapi_table *u_current_table_tls
- __attribute__((tls_model("initial-exec")))
- = (struct mapi_table *) table_noop_array;
-
-__thread void *u_current_user_tls
- __attribute__((tls_model("initial-exec")));
-
-const struct mapi_table *u_current_table;
-const void *u_current_user;
-
-#else
-
-struct mapi_table *u_current_table =
- (struct mapi_table *) table_noop_array;
-void *u_current_user;
-
-#ifdef THREADS
-struct u_tsd u_current_table_tsd;
-static struct u_tsd u_current_user_tsd;
-static int ThreadSafe;
-#endif /* THREADS */
-
-#endif /* defined(GLX_USE_TLS) */
-/*@}*/
-
-
-void
-u_current_destroy(void)
-{
-#if defined(THREADS) && defined(WIN32)
- u_tsd_destroy(&u_current_table_tsd);
- u_tsd_destroy(&u_current_user_tsd);
-#endif
-}
-
-
-#if defined(THREADS) && !defined(GLX_USE_TLS)
-
-static void
-u_current_init_tsd(void)
-{
- u_tsd_init(&u_current_table_tsd);
- u_tsd_init(&u_current_user_tsd);
-}
-
-/**
- * Mutex for multithread check.
- */
-#ifdef WIN32
-/* _glthread_DECLARE_STATIC_MUTEX is broken on windows. There will be race! */
-#define CHECK_MULTITHREAD_LOCK()
-#define CHECK_MULTITHREAD_UNLOCK()
-#else
-u_mutex_declare_static(ThreadCheckMutex);
-#define CHECK_MULTITHREAD_LOCK() u_mutex_lock(ThreadCheckMutex)
-#define CHECK_MULTITHREAD_UNLOCK() u_mutex_unlock(ThreadCheckMutex)
-#endif
-
-/**
- * We should call this periodically from a function such as glXMakeCurrent
- * in order to test if multiple threads are being used.
- */
-void
-u_current_init(void)
-{
- static unsigned long knownID;
- static int firstCall = 1;
-
- if (ThreadSafe)
- return;
-
- CHECK_MULTITHREAD_LOCK();
- if (firstCall) {
- u_current_init_tsd();
-
- knownID = u_thread_self();
- firstCall = 0;
- }
- else if (knownID != u_thread_self()) {
- ThreadSafe = 1;
- u_current_set_internal(NULL);
- u_current_set_user_internal(NULL);
- }
- CHECK_MULTITHREAD_UNLOCK();
-}
-
-#else
-
-void
-u_current_init(void)
-{
-}
-
-#endif
-
-
-
-/**
- * Set the current context pointer for this thread.
- * The context pointer is an opaque type which should be cast to
- * void from the real context pointer type.
- */
-void
-u_current_set_user_internal(void *ptr)
-{
- u_current_init();
-
-#if defined(GLX_USE_TLS)
- u_current_user_tls = ptr;
-#elif defined(THREADS)
- u_tsd_set(&u_current_user_tsd, ptr);
- u_current_user = (ThreadSafe) ? NULL : ptr;
-#else
- u_current_user = ptr;
-#endif
-}
-
-/**
- * Get the current context pointer for this thread.
- * The context pointer is an opaque type which should be cast from
- * void to the real context pointer type.
- */
-void *
-u_current_get_user_internal(void)
-{
-#if defined(GLX_USE_TLS)
- return u_current_user_tls;
-#elif defined(THREADS)
- return (ThreadSafe)
- ? u_tsd_get(&u_current_user_tsd)
- : u_current_user;
-#else
- return u_current_user;
-#endif
-}
-
-/**
- * Set the global or per-thread dispatch table pointer.
- * If the dispatch parameter is NULL we'll plug in the no-op dispatch
- * table (__glapi_noop_table).
- */
-void
-u_current_set_internal(struct mapi_table *tbl)
-{
- u_current_init();
-
- stub_init_once();
-
- if (!tbl)
- tbl = (struct mapi_table *) table_noop_array;
-
-#if defined(GLX_USE_TLS)
- u_current_table_tls = tbl;
-#elif defined(THREADS)
- u_tsd_set(&u_current_table_tsd, (void *) tbl);
- u_current_table = (ThreadSafe) ? NULL : tbl;
-#else
- u_current_table = tbl;
-#endif
-}
-
-/**
- * Return pointer to current dispatch table for calling thread.
- */
-struct mapi_table *
-u_current_get_internal(void)
-{
-#if defined(GLX_USE_TLS)
- return u_current_table_tls;
-#elif defined(THREADS)
- return (struct mapi_table *) ((ThreadSafe) ?
- u_tsd_get(&u_current_table_tsd) : (void *) u_current_table);
-#else
- return u_current_table;
-#endif
-}
diff --git a/src/mapi/mapi/u_execmem.c b/src/mapi/mapi/u_execmem.c
deleted file mode 100644
index e5072e0..0000000
--- a/src/mapi/mapi/u_execmem.c
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version: 6.5
- *
- * Copyright (C) 1999-2005 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.
- */
-
-
-/**
- * \file glapi_execmem.c
- *
- * Function for allocating executable memory for dispatch stubs.
- *
- * Copied from main/execmem.c and simplified for dispatch stubs.
- */
-
-
-#include "u_compiler.h"
-#include "u_thread.h"
-#include "u_execmem.h"
-
-
-#define EXEC_MAP_SIZE (4*1024)
-
-u_mutex_declare_static(exec_mutex);
-
-static unsigned int head = 0;
-
-static unsigned char *exec_mem = (unsigned char *)0;
-
-
-#if defined(__linux__) || defined(__OpenBSD__) || defined(_NetBSD__) || defined(__sun)
-
-#include <unistd.h>
-#include <sys/mman.h>
-
-#ifdef MESA_SELINUX
-#include <selinux/selinux.h>
-#endif
-
-
-#ifndef MAP_ANONYMOUS
-#define MAP_ANONYMOUS MAP_ANON
-#endif
-
-
-/*
- * Dispatch stubs are of fixed size and never freed. Thus, we do not need to
- * overlay a heap, we just mmap a page and manage through an index.
- */
-
-static int
-init_map(void)
-{
-#ifdef MESA_SELINUX
- if (is_selinux_enabled()) {
- if (!security_get_boolean_active("allow_execmem") ||
- !security_get_boolean_pending("allow_execmem"))
- return 0;
- }
-#endif
-
- if (!exec_mem)
- exec_mem = mmap(NULL, EXEC_MAP_SIZE, PROT_EXEC | PROT_READ | PROT_WRITE,
- MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
-
- return (exec_mem != MAP_FAILED);
-}
-
-
-#elif defined(_WIN32)
-
-#include <windows.h>
-
-
-/*
- * Avoid Data Execution Prevention.
- */
-
-static int
-init_map(void)
-{
- exec_mem = VirtualAlloc(NULL, EXEC_MAP_SIZE, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
-
- return (exec_mem != NULL);
-}
-
-
-#else
-
-#include <stdlib.h>
-
-static int
-init_map(void)
-{
- exec_mem = malloc(EXEC_MAP_SIZE);
-
- return (exec_mem != NULL);
-}
-
-
-#endif
-
-void *
-u_execmem_alloc(unsigned int size)
-{
- void *addr = NULL;
-
- u_mutex_lock(exec_mutex);
-
- if (!init_map())
- goto bail;
-
- /* free space check, assumes no integer overflow */
- if (head + size > EXEC_MAP_SIZE)
- goto bail;
-
- /* allocation, assumes proper addr and size alignement */
- addr = exec_mem + head;
- head += size;
-
-bail:
- u_mutex_unlock(exec_mutex);
-
- return addr;
-}
-
-
diff --git a/src/mapi/mapi/u_thread.c b/src/mapi/mapi/u_thread.c
deleted file mode 100644
index e9eae55..0000000
--- a/src/mapi/mapi/u_thread.c
+++ /dev/null
@@ -1,254 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version: 6.5.1
- *
- * Copyright (C) 1999-2006 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.
- */
-
-
-#include <stdio.h>
-#include <stdlib.h>
-#include "u_compiler.h"
-#include "u_thread.h"
-
-
-/*
- * This file should still compile even when THREADS is not defined.
- * This is to make things easier to deal with on the makefile scene..
- */
-#ifdef THREADS
-#include <errno.h>
-
-/*
- * Error messages
- */
-#define INIT_TSD_ERROR "_glthread_: failed to allocate key for thread specific data"
-#define GET_TSD_ERROR "_glthread_: failed to get thread specific data"
-#define SET_TSD_ERROR "_glthread_: thread failed to set thread specific data"
-
-
-/*
- * Magic number to determine if a TSD object has been initialized.
- * Kind of a hack but there doesn't appear to be a better cross-platform
- * solution.
- */
-#define INIT_MAGIC 0xff8adc98
-
-
-
-/*
- * POSIX Threads -- The best way to go if your platform supports them.
- * Solaris >= 2.5 have POSIX threads, IRIX >= 6.4 reportedly
- * has them, and many of the free Unixes now have them.
- * Be sure to use appropriate -mt or -D_REENTRANT type
- * compile flags when building.
- */
-#ifdef PTHREADS
-
-unsigned long
-u_thread_self(void)
-{
- return (unsigned long) pthread_self();
-}
-
-
-void
-u_tsd_init(struct u_tsd *tsd)
-{
- if (pthread_key_create(&tsd->key, NULL/*free*/) != 0) {
- perror(INIT_TSD_ERROR);
- exit(-1);
- }
- tsd->initMagic = INIT_MAGIC;
-}
-
-
-void *
-u_tsd_get(struct u_tsd *tsd)
-{
- if (tsd->initMagic != (int) INIT_MAGIC) {
- u_tsd_init(tsd);
- }
- return pthread_getspecific(tsd->key);
-}
-
-
-void
-u_tsd_set(struct u_tsd *tsd, void *ptr)
-{
- if (tsd->initMagic != (int) INIT_MAGIC) {
- u_tsd_init(tsd);
- }
- if (pthread_setspecific(tsd->key, ptr) != 0) {
- perror(SET_TSD_ERROR);
- exit(-1);
- }
-}
-
-#endif /* PTHREADS */
-
-
-
-/*
- * Win32 Threads. The only available option for Windows 95/NT.
- * Be sure that you compile using the Multithreaded runtime, otherwise
- * bad things will happen.
- */
-#ifdef WIN32
-
-static void InsteadOf_exit(int nCode)
-{
- DWORD dwErr = GetLastError();
-}
-
-unsigned long
-u_thread_self(void)
-{
- return GetCurrentThreadId();
-}
-
-
-void
-u_tsd_init(struct u_tsd *tsd)
-{
- tsd->key = TlsAlloc();
- if (tsd->key == TLS_OUT_OF_INDEXES) {
- perror(INIT_TSD_ERROR);
- InsteadOf_exit(-1);
- }
- tsd->initMagic = INIT_MAGIC;
-}
-
-
-void
-u_tsd_destroy(struct u_tsd *tsd)
-{
- if (tsd->initMagic != INIT_MAGIC) {
- return;
- }
- TlsFree(tsd->key);
- tsd->initMagic = 0x0;
-}
-
-
-void *
-u_tsd_get(struct u_tsd *tsd)
-{
- if (tsd->initMagic != INIT_MAGIC) {
- u_tsd_init(tsd);
- }
- return TlsGetValue(tsd->key);
-}
-
-
-void
-u_tsd_set(struct u_tsd *tsd, void *ptr)
-{
- /* the following code assumes that the struct u_tsd has been initialized
- to zero at creation */
- if (tsd->initMagic != INIT_MAGIC) {
- u_tsd_init(tsd);
- }
- if (TlsSetValue(tsd->key, ptr) == 0) {
- perror(SET_TSD_ERROR);
- InsteadOf_exit(-1);
- }
-}
-
-#endif /* WIN32 */
-
-/*
- * BeOS threads
- */
-#ifdef BEOS_THREADS
-
-unsigned long
-u_thread_self(void)
-{
- return (unsigned long) find_thread(NULL);
-}
-
-void
-u_tsd_init(struct u_tsd *tsd)
-{
- tsd->key = tls_allocate();
- tsd->initMagic = INIT_MAGIC;
-}
-
-void *
-u_tsd_get(struct u_tsd *tsd)
-{
- if (tsd->initMagic != (int) INIT_MAGIC) {
- u_tsd_init(tsd);
- }
- return tls_get(tsd->key);
-}
-
-void
-u_tsd_set(struct u_tsd *tsd, void *ptr)
-{
- if (tsd->initMagic != (int) INIT_MAGIC) {
- u_tsd_init(tsd);
- }
- tls_set(tsd->key, ptr);
-}
-
-#endif /* BEOS_THREADS */
-
-
-
-#else /* THREADS */
-
-
-/*
- * no-op functions
- */
-
-unsigned long
-_glthread_GetID(void)
-{
- return 0;
-}
-
-
-void
-u_tsd_init(struct u_tsd *tsd)
-{
- (void) tsd;
-}
-
-
-void *
-u_tsd_get(struct u_tsd *tsd)
-{
- (void) tsd;
- return NULL;
-}
-
-
-void
-u_tsd_set(struct u_tsd *tsd, void *ptr)
-{
- (void) tsd;
- (void) ptr;
-}
-
-
-#endif /* THREADS */
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
deleted file mode 100644
index f42a566..0000000
--- a/src/mesa/main/context.c
+++ /dev/null
@@ -1,1885 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version: 7.3
- *
- * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
- * Copyright (C) 2008 VMware, Inc. 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.
- */
-
-/**
- * \file context.c
- * Mesa context/visual/framebuffer management functions.
- * \author Brian Paul
- */
-
-/**
- * \mainpage Mesa Main Module
- *
- * \section MainIntroduction Introduction
- *
- * The Mesa Main module consists of all the files in the main/ directory.
- * Among the features of this module are:
- * <UL>
- * <LI> Structures to represent most GL state </LI>
- * <LI> State set/get functions </LI>
- * <LI> Display lists </LI>
- * <LI> Texture unit, object and image handling </LI>
- * <LI> Matrix and attribute stacks </LI>
- * </UL>
- *
- * Other modules are responsible for API dispatch, vertex transformation,
- * point/line/triangle setup, rasterization, vertex array caching,
- * vertex/fragment programs/shaders, etc.
- *
- *
- * \section AboutDoxygen About Doxygen
- *
- * If you're viewing this information as Doxygen-generated HTML you'll
- * see the documentation index at the top of this page.
- *
- * The first line lists the Mesa source code modules.
- * The second line lists the indexes available for viewing the documentation
- * for each module.
- *
- * Selecting the <b>Main page</b> link will display a summary of the module
- * (this page).
- *
- * Selecting <b>Data Structures</b> will list all C structures.
- *
- * Selecting the <b>File List</b> link will list all the source files in
- * the module.
- * Selecting a filename will show a list of all functions defined in that file.
- *
- * Selecting the <b>Data Fields</b> link will display a list of all
- * documented structure members.
- *
- * Selecting the <b>Globals</b> link will display a list
- * of all functions, structures, global variables and macros in the module.
- *
- */
-
-
-#include "glheader.h"
-#include "mfeatures.h"
-#include "imports.h"
-#include "accum.h"
-#include "api_exec.h"
-#include "arrayobj.h"
-#include "attrib.h"
-#include "blend.h"
-#include "buffers.h"
-#include "bufferobj.h"
-#include "context.h"
-#include "cpuinfo.h"
-#include "debug.h"
-#include "depth.h"
-#include "dlist.h"
-#include "eval.h"
-#include "extensions.h"
-#include "fbobject.h"
-#include "feedback.h"
-#include "fog.h"
-#include "framebuffer.h"
-#include "hint.h"
-#include "hash.h"
-#include "light.h"
-#include "lines.h"
-#include "macros.h"
-#include "matrix.h"
-#include "multisample.h"
-#include "pixel.h"
-#include "pixelstore.h"
-#include "points.h"
-#include "polygon.h"
-#include "queryobj.h"
-#include "syncobj.h"
-#include "rastpos.h"
-#include "remap.h"
-#include "scissor.h"
-#include "shared.h"
-#include "shaderobj.h"
-#include "simple_list.h"
-#include "state.h"
-#include "stencil.h"
-#include "texcompress_s3tc.h"
-#include "texstate.h"
-#include "transformfeedback.h"
-#include "mtypes.h"
-#include "varray.h"
-#include "version.h"
-#include "viewport.h"
-#include "vtxfmt.h"
-#include "program/program.h"
-#include "program/prog_print.h"
-#if _HAVE_FULL_GL
-#include "math/m_matrix.h"
-#endif
-#include "main/dispatch.h" /* for _gloffset_COUNT */
-
-#ifdef USE_SPARC_ASM
-#include "sparc/sparc.h"
-#endif
-
-#include "glsl_parser_extras.h"
-#include <stdbool.h>
-
-
-#ifndef MESA_VERBOSE
-int MESA_VERBOSE = 0;
-#endif
-
-#ifndef MESA_DEBUG_FLAGS
-int MESA_DEBUG_FLAGS = 0;
-#endif
-
-
-/* ubyte -> float conversion */
-GLfloat _mesa_ubyte_to_float_color_tab[256];
-
-
-
-/**
- * Swap buffers notification callback.
- *
- * \param ctx GL context.
- *
- * Called by window system just before swapping buffers.
- * We have to finish any pending rendering.
- */
-void
-_mesa_notifySwapBuffers(struct gl_context *ctx)
-{
- if (MESA_VERBOSE & VERBOSE_SWAPBUFFERS)
- _mesa_debug(ctx, "SwapBuffers\n");
- FLUSH_CURRENT( ctx, 0 );
- if (ctx->Driver.Flush) {
- ctx->Driver.Flush(ctx);
- }
-}
-
-
-/**********************************************************************/
-/** \name GL Visual allocation/destruction */
-/**********************************************************************/
-/*@{*/
-
-/**
- * Allocates a struct gl_config structure and initializes it via
- * _mesa_initialize_visual().
- *
- * \param dbFlag double buffering
- * \param stereoFlag stereo buffer
- * \param depthBits requested bits per depth buffer value. Any value in [0, 32]
- * is acceptable but the actual depth type will be GLushort or GLuint as
- * needed.
- * \param stencilBits requested minimum bits per stencil buffer value
- * \param accumRedBits, accumGreenBits, accumBlueBits, accumAlphaBits number of bits per color component in accum buffer.
- * \param indexBits number of bits per pixel if \p rgbFlag is GL_FALSE
- * \param redBits number of bits per color component in frame buffer for RGB(A)
- * mode. We always use 8 in core Mesa though.
- * \param greenBits same as above.
- * \param blueBits same as above.
- * \param alphaBits same as above.
- * \param numSamples not really used.
- *
- * \return pointer to new struct gl_config or NULL if requested parameters can't be
- * met.
- *
- * \note Need to add params for level and numAuxBuffers (at least)
- */
-struct gl_config *
-_mesa_create_visual( GLboolean dbFlag,
- GLboolean stereoFlag,
- GLint redBits,
- GLint greenBits,
- GLint blueBits,
- GLint alphaBits,
- GLint depthBits,
- GLint stencilBits,
- GLint accumRedBits,
- GLint accumGreenBits,
- GLint accumBlueBits,
- GLint accumAlphaBits,
- GLint numSamples )
-{
- struct gl_config *vis = CALLOC_STRUCT(gl_config);
- if (vis) {
- if (!_mesa_initialize_visual(vis, dbFlag, stereoFlag,
- redBits, greenBits, blueBits, alphaBits,
- depthBits, stencilBits,
- accumRedBits, accumGreenBits,
- accumBlueBits, accumAlphaBits,
- numSamples)) {
- free(vis);
- return NULL;
- }
- }
- return vis;
-}
-
-
-/**
- * Makes some sanity checks and fills in the fields of the struct
- * gl_config object with the given parameters. If the caller needs to
- * set additional fields, he should just probably init the whole
- * gl_config object himself.
- *
- * \return GL_TRUE on success, or GL_FALSE on failure.
- *
- * \sa _mesa_create_visual() above for the parameter description.
- */
-GLboolean
-_mesa_initialize_visual( struct gl_config *vis,
- GLboolean dbFlag,
- GLboolean stereoFlag,
- GLint redBits,
- GLint greenBits,
- GLint blueBits,
- GLint alphaBits,
- GLint depthBits,
- GLint stencilBits,
- GLint accumRedBits,
- GLint accumGreenBits,
- GLint accumBlueBits,
- GLint accumAlphaBits,
- GLint numSamples )
-{
- assert(vis);
-
- if (depthBits < 0 || depthBits > 32) {
- return GL_FALSE;
- }
- if (stencilBits < 0 || stencilBits > STENCIL_BITS) {
- return GL_FALSE;
- }
- assert(accumRedBits >= 0);
- assert(accumGreenBits >= 0);
- assert(accumBlueBits >= 0);
- assert(accumAlphaBits >= 0);
-
- vis->rgbMode = GL_TRUE;
- vis->doubleBufferMode = dbFlag;
- vis->stereoMode = stereoFlag;
-
- vis->redBits = redBits;
- vis->greenBits = greenBits;
- vis->blueBits = blueBits;
- vis->alphaBits = alphaBits;
- vis->rgbBits = redBits + greenBits + blueBits;
-
- vis->indexBits = 0;
- vis->depthBits = depthBits;
- vis->stencilBits = stencilBits;
-
- vis->accumRedBits = accumRedBits;
- vis->accumGreenBits = accumGreenBits;
- vis->accumBlueBits = accumBlueBits;
- vis->accumAlphaBits = accumAlphaBits;
-
- vis->haveAccumBuffer = accumRedBits > 0;
- vis->haveDepthBuffer = depthBits > 0;
- vis->haveStencilBuffer = stencilBits > 0;
-
- vis->numAuxBuffers = 0;
- vis->level = 0;
- vis->sampleBuffers = numSamples > 0 ? 1 : 0;
- vis->samples = numSamples;
-
- return GL_TRUE;
-}
-
-
-/**
- * Destroy a visual and free its memory.
- *
- * \param vis visual.
- *
- * Frees the visual structure.
- */
-void
-_mesa_destroy_visual( struct gl_config *vis )
-{
- free(vis);
-}
-
-/*@}*/
-
-
-/**********************************************************************/
-/** \name Context allocation, initialization, destroying
- *
- * The purpose of the most initialization functions here is to provide the
- * default state values according to the OpenGL specification.
- */
-/**********************************************************************/
-/*@{*/
-
-
-/**
- * This is lame. gdb only seems to recognize enum types that are
- * actually used somewhere. We want to be able to print/use enum
- * values such as TEXTURE_2D_INDEX in gdb. But we don't actually use
- * the gl_texture_index type anywhere. Thus, this lame function.
- */
-static void
-dummy_enum_func(void)
-{
- gl_buffer_index bi = BUFFER_FRONT_LEFT;
- gl_face_index fi = FACE_POS_X;
- gl_frag_attrib fa = FRAG_ATTRIB_WPOS;
- gl_frag_result fr = FRAG_RESULT_DEPTH;
- gl_texture_index ti = TEXTURE_2D_ARRAY_INDEX;
- gl_vert_attrib va = VERT_ATTRIB_POS;
- gl_vert_result vr = VERT_RESULT_HPOS;
- gl_geom_attrib ga = GEOM_ATTRIB_POSITION;
- gl_geom_result gr = GEOM_RESULT_POS;
-
- (void) bi;
- (void) fi;
- (void) fa;
- (void) fr;
- (void) ti;
- (void) va;
- (void) vr;
- (void) ga;
- (void) gr;
-}
-
-
-/**
- * One-time initialization mutex lock.
- *
- * \sa Used by one_time_init().
- */
-_glthread_DECLARE_STATIC_MUTEX(OneTimeLock);
-
-
-
-/**
- * Calls all the various one-time-init functions in Mesa.
- *
- * While holding a global mutex lock, calls several initialization functions,
- * and sets the glapi callbacks if the \c MESA_DEBUG environment variable is
- * defined.
- *
- * \sa _math_init().
- */
-static void
-one_time_init( struct gl_context *ctx )
-{
- static GLbitfield api_init_mask = 0x0;
-
- _glthread_LOCK_MUTEX(OneTimeLock);
-
- /* truly one-time init */
- if (!api_init_mask) {
- GLuint i;
-
- /* do some implementation tests */
- assert( sizeof(GLbyte) == 1 );
- assert( sizeof(GLubyte) == 1 );
- assert( sizeof(GLshort) == 2 );
- assert( sizeof(GLushort) == 2 );
- assert( sizeof(GLint) == 4 );
- assert( sizeof(GLuint) == 4 );
-
- _mesa_get_cpu_features();
-
- _mesa_init_sqrt_table();
-
- /* context dependence is never a one-time thing... */
- _mesa_init_get_hash(ctx);
-
- for (i = 0; i < 256; i++) {
- _mesa_ubyte_to_float_color_tab[i] = (float) i / 255.0F;
- }
-
-#if defined(DEBUG) && defined(__DATE__) && defined(__TIME__)
- if (MESA_VERBOSE != 0) {
- _mesa_debug(ctx, "Mesa %s DEBUG build %s %s\n",
- MESA_VERSION_STRING, __DATE__, __TIME__);
- }
-#endif
- }
-
- /* per-API one-time init */
- if (!(api_init_mask & (1 << ctx->API))) {
- /*
- * This is fine as ES does not use the remap table, but it may not be
- * future-proof. We cannot always initialize the remap table because
- * when an app is linked to libGLES*, there are not enough dynamic
- * entries.
- */
- if (ctx->API == API_OPENGL)
- _mesa_init_remap_table();
- }
-
- api_init_mask |= 1 << ctx->API;
-
- _glthread_UNLOCK_MUTEX(OneTimeLock);
-
- /* Hopefully atexit() is widely available. If not, we may need some
- * #ifdef tests here.
- */
- atexit(_mesa_destroy_shader_compiler);
-
- dummy_enum_func();
-}
-
-
-/**
- * Initialize fields of gl_current_attrib (aka ctx->Current.*)
- */
-static void
-_mesa_init_current(struct gl_context *ctx)
-{
- GLuint i;
-
- /* Init all to (0,0,0,1) */
- for (i = 0; i < Elements(ctx->Current.Attrib); i++) {
- ASSIGN_4V( ctx->Current.Attrib[i], 0.0, 0.0, 0.0, 1.0 );
- }
-
- /* redo special cases: */
- ASSIGN_4V( ctx->Current.Attrib[VERT_ATTRIB_WEIGHT], 1.0, 0.0, 0.0, 0.0 );
- ASSIGN_4V( ctx->Current.Attrib[VERT_ATTRIB_NORMAL], 0.0, 0.0, 1.0, 1.0 );
- ASSIGN_4V( ctx->Current.Attrib[VERT_ATTRIB_COLOR0], 1.0, 1.0, 1.0, 1.0 );
- ASSIGN_4V( ctx->Current.Attrib[VERT_ATTRIB_COLOR1], 0.0, 0.0, 0.0, 1.0 );
- ASSIGN_4V( ctx->Current.Attrib[VERT_ATTRIB_COLOR_INDEX], 1.0, 0.0, 0.0, 1.0 );
- ASSIGN_4V( ctx->Current.Attrib[VERT_ATTRIB_EDGEFLAG], 1.0, 0.0, 0.0, 1.0 );
-}
-
-
-/**
- * Init vertex/fragment/geometry program limits.
- * Important: drivers should override these with actual limits.
- */
-static void
-init_program_limits(GLenum type, struct gl_program_constants *prog)
-{
- prog->MaxInstructions = MAX_PROGRAM_INSTRUCTIONS;
- prog->MaxAluInstructions = MAX_PROGRAM_INSTRUCTIONS;
- prog->MaxTexInstructions = MAX_PROGRAM_INSTRUCTIONS;
- prog->MaxTexIndirections = MAX_PROGRAM_INSTRUCTIONS;
- prog->MaxTemps = MAX_PROGRAM_TEMPS;
- prog->MaxEnvParams = MAX_PROGRAM_ENV_PARAMS;
- prog->MaxLocalParams = MAX_PROGRAM_LOCAL_PARAMS;
- prog->MaxUniformComponents = 4 * MAX_UNIFORMS;
-
- switch (type) {
- case GL_VERTEX_PROGRAM_ARB:
- prog->MaxParameters = MAX_VERTEX_PROGRAM_PARAMS;
- prog->MaxAttribs = MAX_NV_VERTEX_PROGRAM_INPUTS;
- prog->MaxAddressRegs = MAX_VERTEX_PROGRAM_ADDRESS_REGS;
- break;
- case GL_FRAGMENT_PROGRAM_ARB:
- prog->MaxParameters = MAX_NV_FRAGMENT_PROGRAM_PARAMS;
- prog->MaxAttribs = MAX_NV_FRAGMENT_PROGRAM_INPUTS;
- prog->MaxAddressRegs = MAX_FRAGMENT_PROGRAM_ADDRESS_REGS;
- break;
- case MESA_GEOMETRY_PROGRAM:
- prog->MaxParameters = MAX_NV_VERTEX_PROGRAM_PARAMS;
- prog->MaxAttribs = MAX_NV_VERTEX_PROGRAM_INPUTS;
- prog->MaxAddressRegs = MAX_VERTEX_PROGRAM_ADDRESS_REGS;
-
- prog->MaxGeometryTextureImageUnits = MAX_GEOMETRY_TEXTURE_IMAGE_UNITS;
- prog->MaxGeometryVaryingComponents = MAX_GEOMETRY_VARYING_COMPONENTS;
- prog->MaxVertexVaryingComponents = MAX_VERTEX_VARYING_COMPONENTS;
- prog->MaxGeometryUniformComponents = MAX_GEOMETRY_UNIFORM_COMPONENTS;
- prog->MaxGeometryOutputVertices = MAX_GEOMETRY_OUTPUT_VERTICES;
- prog->MaxGeometryTotalOutputComponents = MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS;
- break;
- default:
- assert(0 && "Bad program type in init_program_limits()");
- }
-
- /* Set the native limits to zero. This implies that there is no native
- * support for shaders. Let the drivers fill in the actual values.
- */
- prog->MaxNativeInstructions = 0;
- prog->MaxNativeAluInstructions = 0;
- prog->MaxNativeTexInstructions = 0;
- prog->MaxNativeTexIndirections = 0;
- prog->MaxNativeAttribs = 0;
- prog->MaxNativeTemps = 0;
- prog->MaxNativeAddressRegs = 0;
- prog->MaxNativeParameters = 0;
-}
-
-
-/**
- * Initialize fields of gl_constants (aka ctx->Const.*).
- * Use defaults from config.h. The device drivers will often override
- * some of these values (such as number of texture units).
- */
-static void
-_mesa_init_constants(struct gl_context *ctx)
-{
- assert(ctx);
-
- /* Constants, may be overriden (usually only reduced) by device drivers */
- ctx->Const.MaxTextureMbytes = MAX_TEXTURE_MBYTES;
- ctx->Const.MaxTextureLevels = MAX_TEXTURE_LEVELS;
- ctx->Const.Max3DTextureLevels = MAX_3D_TEXTURE_LEVELS;
- ctx->Const.MaxCubeTextureLevels = MAX_CUBE_TEXTURE_LEVELS;
- ctx->Const.MaxTextureRectSize = MAX_TEXTURE_RECT_SIZE;
- ctx->Const.MaxArrayTextureLayers = MAX_ARRAY_TEXTURE_LAYERS;
- ctx->Const.MaxTextureCoordUnits = MAX_TEXTURE_COORD_UNITS;
- ctx->Const.MaxTextureImageUnits = MAX_TEXTURE_IMAGE_UNITS;
- ctx->Const.MaxTextureUnits = MIN2(ctx->Const.MaxTextureCoordUnits,
- ctx->Const.MaxTextureImageUnits);
- ctx->Const.MaxTextureMaxAnisotropy = MAX_TEXTURE_MAX_ANISOTROPY;
- ctx->Const.MaxTextureLodBias = MAX_TEXTURE_LOD_BIAS;
- ctx->Const.MaxArrayLockSize = MAX_ARRAY_LOCK_SIZE;
- ctx->Const.SubPixelBits = SUB_PIXEL_BITS;
- ctx->Const.MinPointSize = MIN_POINT_SIZE;
- ctx->Const.MaxPointSize = MAX_POINT_SIZE;
- ctx->Const.MinPointSizeAA = MIN_POINT_SIZE;
- ctx->Const.MaxPointSizeAA = MAX_POINT_SIZE;
- ctx->Const.PointSizeGranularity = (GLfloat) POINT_SIZE_GRANULARITY;
- ctx->Const.MinLineWidth = MIN_LINE_WIDTH;
- ctx->Const.MaxLineWidth = MAX_LINE_WIDTH;
- ctx->Const.MinLineWidthAA = MIN_LINE_WIDTH;
- ctx->Const.MaxLineWidthAA = MAX_LINE_WIDTH;
- ctx->Const.LineWidthGranularity = (GLfloat) LINE_WIDTH_GRANULARITY;
- ctx->Const.MaxColorTableSize = MAX_COLOR_TABLE_SIZE;
- ctx->Const.MaxClipPlanes = MAX_CLIP_PLANES;
- ctx->Const.MaxLights = MAX_LIGHTS;
- ctx->Const.MaxShininess = 128.0;
- ctx->Const.MaxSpotExponent = 128.0;
- ctx->Const.MaxViewportWidth = MAX_WIDTH;
- ctx->Const.MaxViewportHeight = MAX_HEIGHT;
-#if FEATURE_ARB_vertex_program
- init_program_limits(GL_VERTEX_PROGRAM_ARB, &ctx->Const.VertexProgram);
-#endif
-#if FEATURE_ARB_fragment_program
- init_program_limits(GL_FRAGMENT_PROGRAM_ARB, &ctx->Const.FragmentProgram);
-#endif
-#if FEATURE_ARB_geometry_shader4
- init_program_limits(MESA_GEOMETRY_PROGRAM, &ctx->Const.GeometryProgram);
-#endif
- ctx->Const.MaxProgramMatrices = MAX_PROGRAM_MATRICES;
- ctx->Const.MaxProgramMatrixStackDepth = MAX_PROGRAM_MATRIX_STACK_DEPTH;
-
- /* CheckArrayBounds is overriden by drivers/x11 for X server */
- ctx->Const.CheckArrayBounds = GL_FALSE;
-
- /* GL_ARB_draw_buffers */
- ctx->Const.MaxDrawBuffers = MAX_DRAW_BUFFERS;
-
-#if FEATURE_EXT_framebuffer_object
- ctx->Const.MaxColorAttachments = MAX_COLOR_ATTACHMENTS;
- ctx->Const.MaxRenderbufferSize = MAX_WIDTH;
-#endif
-
-#if FEATURE_ARB_vertex_shader
- ctx->Const.MaxVertexTextureImageUnits = MAX_VERTEX_TEXTURE_IMAGE_UNITS;
- ctx->Const.MaxCombinedTextureImageUnits = MAX_COMBINED_TEXTURE_IMAGE_UNITS;
- ctx->Const.MaxVarying = MAX_VARYING;
-#endif
-
- /* Shading language version */
- if (ctx->API == API_OPENGL) {
- ctx->Const.GLSLVersion = 120;
- }
- else if (ctx->API == API_OPENGLES2) {
- ctx->Const.GLSLVersion = 100;
- }
- else if (ctx->API == API_OPENGLES) {
- ctx->Const.GLSLVersion = 0; /* GLSL not supported */
- }
-
- /* GL_ARB_framebuffer_object */
- ctx->Const.MaxSamples = 0;
-
- /* GL_ARB_sync */
- ctx->Const.MaxServerWaitTimeout = (GLuint64) ~0;
-
- /* GL_ATI_envmap_bumpmap */
- ctx->Const.SupportedBumpUnits = SUPPORTED_ATI_BUMP_UNITS;
-
- /* GL_EXT_provoking_vertex */
- ctx->Const.QuadsFollowProvokingVertexConvention = GL_TRUE;
-
- /* GL_EXT_transform_feedback */
- ctx->Const.MaxTransformFeedbackSeparateAttribs = MAX_FEEDBACK_ATTRIBS;
- ctx->Const.MaxTransformFeedbackSeparateComponents = 4 * MAX_FEEDBACK_ATTRIBS;
- ctx->Const.MaxTransformFeedbackInterleavedComponents = 4 * MAX_FEEDBACK_ATTRIBS;
-
- /* GL 3.2: hard-coded for now: */
- ctx->Const.ProfileMask = GL_CONTEXT_COMPATIBILITY_PROFILE_BIT;
-
- /** GL_EXT_gpu_shader4 */
- ctx->Const.MinProgramTexelOffset = -8;
- ctx->Const.MaxProgramTexelOffset = 7;
-}
-
-
-/**
- * Do some sanity checks on the limits/constants for the given context.
- * Only called the first time a context is bound.
- */
-static void
-check_context_limits(struct gl_context *ctx)
-{
- /* check that we don't exceed the size of various bitfields */
- assert(VERT_RESULT_MAX <=
- (8 * sizeof(ctx->VertexProgram._Current->Base.OutputsWritten)));
- assert(FRAG_ATTRIB_MAX <=
- (8 * sizeof(ctx->FragmentProgram._Current->Base.InputsRead)));
-
- assert(MAX_COMBINED_TEXTURE_IMAGE_UNITS <= 8 * sizeof(GLbitfield));
-
- /* shader-related checks */
- assert(ctx->Const.FragmentProgram.MaxLocalParams <= MAX_PROGRAM_LOCAL_PARAMS);
- assert(ctx->Const.VertexProgram.MaxLocalParams <= MAX_PROGRAM_LOCAL_PARAMS);
-
- assert(MAX_NV_FRAGMENT_PROGRAM_TEMPS <= MAX_PROGRAM_TEMPS);
- assert(MAX_NV_VERTEX_PROGRAM_TEMPS <= MAX_PROGRAM_TEMPS);
- assert(MAX_NV_VERTEX_PROGRAM_INPUTS <= VERT_ATTRIB_MAX);
- assert(MAX_NV_VERTEX_PROGRAM_OUTPUTS <= VERT_RESULT_MAX);
-
- /* Texture unit checks */
- assert(ctx->Const.MaxTextureImageUnits > 0);
- assert(ctx->Const.MaxTextureImageUnits <= MAX_TEXTURE_IMAGE_UNITS);
- assert(ctx->Const.MaxTextureCoordUnits > 0);
- assert(ctx->Const.MaxTextureCoordUnits <= MAX_TEXTURE_COORD_UNITS);
- assert(ctx->Const.MaxTextureUnits > 0);
- assert(ctx->Const.MaxTextureUnits <= MAX_TEXTURE_IMAGE_UNITS);
- assert(ctx->Const.MaxTextureUnits <= MAX_TEXTURE_COORD_UNITS);
- assert(ctx->Const.MaxTextureUnits == MIN2(ctx->Const.MaxTextureImageUnits,
- ctx->Const.MaxTextureCoordUnits));
- assert(ctx->Const.MaxCombinedTextureImageUnits > 0);
- assert(ctx->Const.MaxCombinedTextureImageUnits <= MAX_COMBINED_TEXTURE_IMAGE_UNITS);
- assert(ctx->Const.MaxTextureCoordUnits <= MAX_COMBINED_TEXTURE_IMAGE_UNITS);
- /* number of coord units cannot be greater than number of image units */
- assert(ctx->Const.MaxTextureCoordUnits <= ctx->Const.MaxTextureImageUnits);
-
-
- /* Texture size checks */
- assert(ctx->Const.MaxTextureLevels <= MAX_TEXTURE_LEVELS);
- assert(ctx->Const.Max3DTextureLevels <= MAX_3D_TEXTURE_LEVELS);
- assert(ctx->Const.MaxCubeTextureLevels <= MAX_CUBE_TEXTURE_LEVELS);
- assert(ctx->Const.MaxTextureRectSize <= MAX_TEXTURE_RECT_SIZE);
-
- /* make sure largest texture image is <= MAX_WIDTH in size */
- assert((1 << (ctx->Const.MaxTextureLevels - 1)) <= MAX_WIDTH);
- assert((1 << (ctx->Const.MaxCubeTextureLevels - 1)) <= MAX_WIDTH);
- assert((1 << (ctx->Const.Max3DTextureLevels - 1)) <= MAX_WIDTH);
-
- /* Texture level checks */
- assert(MAX_TEXTURE_LEVELS >= MAX_3D_TEXTURE_LEVELS);
- assert(MAX_TEXTURE_LEVELS >= MAX_CUBE_TEXTURE_LEVELS);
-
- /* Max texture size should be <= max viewport size (render to texture) */
- assert((1 << (MAX_TEXTURE_LEVELS - 1)) <= MAX_WIDTH);
-
- assert(ctx->Const.MaxViewportWidth <= MAX_WIDTH);
- assert(ctx->Const.MaxViewportHeight <= MAX_WIDTH);
-
- assert(ctx->Const.MaxDrawBuffers <= MAX_DRAW_BUFFERS);
-
- /* if this fails, add more enum values to gl_buffer_index */
- assert(BUFFER_COLOR0 + MAX_DRAW_BUFFERS <= BUFFER_COUNT);
-
- /* XXX probably add more tests */
-}
-
-
-/**
- * Initialize the attribute groups in a GL context.
- *
- * \param ctx GL context.
- *
- * Initializes all the attributes, calling the respective <tt>init*</tt>
- * functions for the more complex data structures.
- */
-static GLboolean
-init_attrib_groups(struct gl_context *ctx)
-{
- assert(ctx);
-
- /* Constants */
- _mesa_init_constants( ctx );
-
- /* Extensions */
- _mesa_init_extensions( ctx );
-
- /* Attribute Groups */
- _mesa_init_accum( ctx );
- _mesa_init_attrib( ctx );
- _mesa_init_buffer_objects( ctx );
- _mesa_init_color( ctx );
- _mesa_init_current( ctx );
- _mesa_init_depth( ctx );
- _mesa_init_debug( ctx );
- _mesa_init_display_list( ctx );
- _mesa_init_eval( ctx );
- _mesa_init_fbobjects( ctx );
- _mesa_init_feedback( ctx );
- _mesa_init_fog( ctx );
- _mesa_init_hint( ctx );
- _mesa_init_line( ctx );
- _mesa_init_lighting( ctx );
- _mesa_init_matrix( ctx );
- _mesa_init_multisample( ctx );
- _mesa_init_pixel( ctx );
- _mesa_init_pixelstore( ctx );
- _mesa_init_point( ctx );
- _mesa_init_polygon( ctx );
- _mesa_init_program( ctx );
- _mesa_init_queryobj( ctx );
- _mesa_init_sync( ctx );
- _mesa_init_rastpos( ctx );
- _mesa_init_scissor( ctx );
- _mesa_init_shader_state( ctx );
- _mesa_init_stencil( ctx );
- _mesa_init_transform( ctx );
- _mesa_init_transform_feedback( ctx );
- _mesa_init_varray( ctx );
- _mesa_init_viewport( ctx );
-
- if (!_mesa_init_texture( ctx ))
- return GL_FALSE;
-
- _mesa_init_texture_s3tc( ctx );
-
- /* Miscellaneous */
- ctx->NewState = _NEW_ALL;
- ctx->ErrorValue = (GLenum) GL_NO_ERROR;
- ctx->varying_vp_inputs = ~0;
-
- return GL_TRUE;
-}
-
-
-/**
- * Update default objects in a GL context with respect to shared state.
- *
- * \param ctx GL context.
- *
- * Removes references to old default objects, (texture objects, program
- * objects, etc.) and changes to reference those from the current shared
- * state.
- */
-static GLboolean
-update_default_objects(struct gl_context *ctx)
-{
- assert(ctx);
-
- _mesa_update_default_objects_program(ctx);
- _mesa_update_default_objects_texture(ctx);
- _mesa_update_default_objects_buffer_objects(ctx);
-
- return GL_TRUE;
-}
-
-
-/**
- * This is the default function we plug into all dispatch table slots
- * This helps prevents a segfault when someone calls a GL function without
- * first checking if the extension's supported.
- */
-static int
-generic_nop(void)
-{
- _mesa_warning(NULL, "User called no-op dispatch function (an unsupported extension function?)");
- return 0;
-}
-
-
-/**
- * Allocate and initialize a new dispatch table.
- */
-struct _glapi_table *
-_mesa_alloc_dispatch_table(int size)
-{
- /* Find the larger of Mesa's dispatch table and libGL's dispatch table.
- * In practice, this'll be the same for stand-alone Mesa. But for DRI
- * Mesa we do this to accomodate different versions of libGL and various
- * DRI drivers.
- */
- GLint numEntries = MAX2(_glapi_get_dispatch_table_size(), _gloffset_COUNT);
- struct _glapi_table *table;
-
- /* should never happen, but just in case */
- numEntries = MAX2(numEntries, size);
-
- table = (struct _glapi_table *) malloc(numEntries * sizeof(_glapi_proc));
- if (table) {
- _glapi_proc *entry = (_glapi_proc *) table;
- GLint i;
- for (i = 0; i < numEntries; i++) {
- entry[i] = (_glapi_proc) generic_nop;
- }
- }
- return table;
-}
-
-
-/**
- * Initialize a struct gl_context struct (rendering context).
- *
- * This includes allocating all the other structs and arrays which hang off of
- * the context by pointers.
- * Note that the driver needs to pass in its dd_function_table here since
- * we need to at least call driverFunctions->NewTextureObject to create the
- * default texture objects.
- *
- * Called by _mesa_create_context().
- *
- * Performs the imports and exports callback tables initialization, and
- * miscellaneous one-time initializations. If no shared context is supplied one
- * is allocated, and increase its reference count. Setups the GL API dispatch
- * tables. Initialize the TNL module. Sets the maximum Z buffer depth.
- * Finally queries the \c MESA_DEBUG and \c MESA_VERBOSE environment variables
- * for debug flags.
- *
- * \param ctx the context to initialize
- * \param api the GL API type to create the context for
- * \param visual describes the visual attributes for this context
- * \param share_list points to context to share textures, display lists,
- * etc with, or NULL
- * \param driverFunctions table of device driver functions for this context
- * to use
- * \param driverContext pointer to driver-specific context data
- */
-GLboolean
-_mesa_initialize_context_for_api(struct gl_context *ctx,
- gl_api api,
- const struct gl_config *visual,
- struct gl_context *share_list,
- const struct dd_function_table *driverFunctions,
- void *driverContext)
-{
- struct gl_shared_state *shared;
- int i;
-
- /*ASSERT(driverContext);*/
- assert(driverFunctions->NewTextureObject);
- assert(driverFunctions->FreeTexImageData);
-
- ctx->API = api;
- ctx->Visual = *visual;
- ctx->DrawBuffer = NULL;
- ctx->ReadBuffer = NULL;
- ctx->WinSysDrawBuffer = NULL;
- ctx->WinSysReadBuffer = NULL;
-
- /* misc one-time initializations */
- one_time_init(ctx);
-
- /* Plug in driver functions and context pointer here.
- * This is important because when we call alloc_shared_state() below
- * we'll call ctx->Driver.NewTextureObject() to create the default
- * textures.
- */
- ctx->Driver = *driverFunctions;
- ctx->DriverCtx = driverContext;
-
- if (share_list) {
- /* share state with another context */
- shared = share_list->Shared;
- }
- else {
- /* allocate new, unshared state */
- shared = _mesa_alloc_shared_state(ctx);
- if (!shared)
- return GL_FALSE;
- }
-
- _glthread_LOCK_MUTEX(shared->Mutex);
- ctx->Shared = shared;
- shared->RefCount++;
- _glthread_UNLOCK_MUTEX(shared->Mutex);
-
- if (!init_attrib_groups( ctx )) {
- _mesa_release_shared_state(ctx, ctx->Shared);
- return GL_FALSE;
- }
-
-#if FEATURE_dispatch
- /* setup the API dispatch tables */
- switch (ctx->API) {
-#if FEATURE_GL
- case API_OPENGL:
- ctx->Exec = _mesa_create_exec_table();
- break;
-#endif
-#if FEATURE_ES1
- case API_OPENGLES:
- ctx->Exec = _mesa_create_exec_table_es1();
- break;
-#endif
-#if FEATURE_ES2
- case API_OPENGLES2:
- ctx->Exec = _mesa_create_exec_table_es2();
- break;
-#endif
- default:
- _mesa_problem(ctx, "unknown or unsupported API");
- break;
- }
-
- if (!ctx->Exec) {
- _mesa_release_shared_state(ctx, ctx->Shared);
- return GL_FALSE;
- }
-#endif
- ctx->CurrentDispatch = ctx->Exec;
-
- ctx->FragmentProgram._MaintainTexEnvProgram
- = (_mesa_getenv("MESA_TEX_PROG") != NULL);
-
- ctx->VertexProgram._MaintainTnlProgram
- = (_mesa_getenv("MESA_TNL_PROG") != NULL);
- if (ctx->VertexProgram._MaintainTnlProgram) {
- /* this is required... */
- ctx->FragmentProgram._MaintainTexEnvProgram = GL_TRUE;
- }
-
- switch (ctx->API) {
- case API_OPENGL:
-#if FEATURE_dlist
- ctx->Save = _mesa_create_save_table();
- if (!ctx->Save) {
- _mesa_release_shared_state(ctx, ctx->Shared);
- free(ctx->Exec);
- return GL_FALSE;
- }
-
- _mesa_install_save_vtxfmt( ctx, &ctx->ListState.ListVtxfmt );
-#endif
- break;
- case API_OPENGLES:
- /**
- * GL_OES_texture_cube_map says
- * "Initially all texture generation modes are set to REFLECTION_MAP_OES"
- */
- for (i = 0; i < MAX_TEXTURE_UNITS; i++) {
- struct gl_texture_unit *texUnit = &ctx->Texture.Unit[i];
- texUnit->GenS.Mode = GL_REFLECTION_MAP_NV;
- texUnit->GenT.Mode = GL_REFLECTION_MAP_NV;
- texUnit->GenR.Mode = GL_REFLECTION_MAP_NV;
- texUnit->GenS._ModeBit = TEXGEN_REFLECTION_MAP_NV;
- texUnit->GenT._ModeBit = TEXGEN_REFLECTION_MAP_NV;
- texUnit->GenR._ModeBit = TEXGEN_REFLECTION_MAP_NV;
- }
- break;
- case API_OPENGLES2:
- ctx->FragmentProgram._MaintainTexEnvProgram = GL_TRUE;
- ctx->VertexProgram._MaintainTnlProgram = GL_TRUE;
- ctx->Point.PointSprite = GL_TRUE; /* always on for ES 2.x */
- break;
- }
-
- ctx->FirstTimeCurrent = GL_TRUE;
-
- return GL_TRUE;
-}
-
-
-/**
- * Initialize an OpenGL context.
- */
-GLboolean
-_mesa_initialize_context(struct gl_context *ctx,
- const struct gl_config *visual,
- struct gl_context *share_list,
- const struct dd_function_table *driverFunctions,
- void *driverContext)
-{
- return _mesa_initialize_context_for_api(ctx,
- API_OPENGL,
- visual,
- share_list,
- driverFunctions,
- driverContext);
-}
-
-
-/**
- * Allocate and initialize a struct gl_context structure.
- * Note that the driver needs to pass in its dd_function_table here since
- * we need to at least call driverFunctions->NewTextureObject to initialize
- * the rendering context.
- *
- * \param api the GL API type to create the context for
- * \param visual a struct gl_config pointer (we copy the struct contents)
- * \param share_list another context to share display lists with or NULL
- * \param driverFunctions points to the dd_function_table into which the
- * driver has plugged in all its special functions.
- * \param driverContext points to the device driver's private context state
- *
- * \return pointer to a new __struct gl_contextRec or NULL if error.
- */
-struct gl_context *
-_mesa_create_context_for_api(gl_api api,
- const struct gl_config *visual,
- struct gl_context *share_list,
- const struct dd_function_table *driverFunctions,
- void *driverContext)
-{
- struct gl_context *ctx;
-
- ASSERT(visual);
- /*ASSERT(driverContext);*/
-
- ctx = (struct gl_context *) calloc(1, sizeof(struct gl_context));
- if (!ctx)
- return NULL;
-
- if (_mesa_initialize_context_for_api(ctx, api, visual, share_list,
- driverFunctions, driverContext)) {
- return ctx;
- }
- else {
- free(ctx);
- return NULL;
- }
-}
-
-
-/**
- * Create an OpenGL context.
- */
-struct gl_context *
-_mesa_create_context(const struct gl_config *visual,
- struct gl_context *share_list,
- const struct dd_function_table *driverFunctions,
- void *driverContext)
-{
- return _mesa_create_context_for_api(API_OPENGL, visual,
- share_list,
- driverFunctions,
- driverContext);
-}
-
-
-/**
- * Free the data associated with the given context.
- *
- * But doesn't free the struct gl_context struct itself.
- *
- * \sa _mesa_initialize_context() and init_attrib_groups().
- */
-void
-_mesa_free_context_data( struct gl_context *ctx )
-{
- if (!_mesa_get_current_context()){
- /* No current context, but we may need one in order to delete
- * texture objs, etc. So temporarily bind the context now.
- */
- _mesa_make_current(ctx, NULL, NULL);
- }
-
- /* unreference WinSysDraw/Read buffers */
- _mesa_reference_framebuffer(&ctx->WinSysDrawBuffer, NULL);
- _mesa_reference_framebuffer(&ctx->WinSysReadBuffer, NULL);
- _mesa_reference_framebuffer(&ctx->DrawBuffer, NULL);
- _mesa_reference_framebuffer(&ctx->ReadBuffer, NULL);
-
- _mesa_reference_vertprog(ctx, &ctx->VertexProgram.Current, NULL);
- _mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current, NULL);
- _mesa_reference_vertprog(ctx, &ctx->VertexProgram._TnlProgram, NULL);
-
- _mesa_reference_fragprog(ctx, &ctx->FragmentProgram.Current, NULL);
- _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current, NULL);
- _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._TexEnvProgram, NULL);
-
- _mesa_free_attrib_data(ctx);
- _mesa_free_buffer_objects(ctx);
- _mesa_free_lighting_data( ctx );
- _mesa_free_eval_data( ctx );
- _mesa_free_texture_data( ctx );
- _mesa_free_matrix_data( ctx );
- _mesa_free_viewport_data( ctx );
- _mesa_free_program_data(ctx);
- _mesa_free_shader_state(ctx);
- _mesa_free_queryobj_data(ctx);
- _mesa_free_sync_data(ctx);
- _mesa_free_varray_data(ctx);
- _mesa_free_transform_feedback(ctx);
-
- _mesa_delete_array_object(ctx, ctx->Array.DefaultArrayObj);
-
-#if FEATURE_ARB_pixel_buffer_object
- _mesa_reference_buffer_object(ctx, &ctx->Pack.BufferObj, NULL);
- _mesa_reference_buffer_object(ctx, &ctx->Unpack.BufferObj, NULL);
- _mesa_reference_buffer_object(ctx, &ctx->DefaultPacking.BufferObj, NULL);
-#endif
-
-#if FEATURE_ARB_vertex_buffer_object
- _mesa_reference_buffer_object(ctx, &ctx->Array.ArrayBufferObj, NULL);
- _mesa_reference_buffer_object(ctx, &ctx->Array.ElementArrayBufferObj, NULL);
-#endif
-
- /* free dispatch tables */
- free(ctx->Exec);
- free(ctx->Save);
-
- /* Shared context state (display lists, textures, etc) */
- _mesa_release_shared_state( ctx, ctx->Shared );
-
- /* needs to be after freeing shared state */
- _mesa_free_display_list_data(ctx);
-
- if (ctx->Extensions.String)
- free((void *) ctx->Extensions.String);
-
- if (ctx->VersionString)
- free(ctx->VersionString);
-
- /* unbind the context if it's currently bound */
- if (ctx == _mesa_get_current_context()) {
- _mesa_make_current(NULL, NULL, NULL);
- }
-}
-
-
-/**
- * Destroy a struct gl_context structure.
- *
- * \param ctx GL context.
- *
- * Calls _mesa_free_context_data() and frees the gl_context object itself.
- */
-void
-_mesa_destroy_context( struct gl_context *ctx )
-{
- if (ctx) {
- _mesa_free_context_data(ctx);
- free( (void *) ctx );
- }
-}
-
-
-#if _HAVE_FULL_GL
-/**
- * Copy attribute groups from one context to another.
- *
- * \param src source context
- * \param dst destination context
- * \param mask bitwise OR of GL_*_BIT flags
- *
- * According to the bits specified in \p mask, copies the corresponding
- * attributes from \p src into \p dst. For many of the attributes a simple \c
- * memcpy is not enough due to the existence of internal pointers in their data
- * structures.
- */
-void
-_mesa_copy_context( const struct gl_context *src, struct gl_context *dst, GLuint mask )
-{
- if (mask & GL_ACCUM_BUFFER_BIT) {
- /* OK to memcpy */
- dst->Accum = src->Accum;
- }
- if (mask & GL_COLOR_BUFFER_BIT) {
- /* OK to memcpy */
- dst->Color = src->Color;
- }
- if (mask & GL_CURRENT_BIT) {
- /* OK to memcpy */
- dst->Current = src->Current;
- }
- if (mask & GL_DEPTH_BUFFER_BIT) {
- /* OK to memcpy */
- dst->Depth = src->Depth;
- }
- if (mask & GL_ENABLE_BIT) {
- /* no op */
- }
- if (mask & GL_EVAL_BIT) {
- /* OK to memcpy */
- dst->Eval = src->Eval;
- }
- if (mask & GL_FOG_BIT) {
- /* OK to memcpy */
- dst->Fog = src->Fog;
- }
- if (mask & GL_HINT_BIT) {
- /* OK to memcpy */
- dst->Hint = src->Hint;
- }
- if (mask & GL_LIGHTING_BIT) {
- GLuint i;
- /* begin with memcpy */
- dst->Light = src->Light;
- /* fixup linked lists to prevent pointer insanity */
- make_empty_list( &(dst->Light.EnabledList) );
- for (i = 0; i < MAX_LIGHTS; i++) {
- if (dst->Light.Light[i].Enabled) {
- insert_at_tail(&(dst->Light.EnabledList), &(dst->Light.Light[i]));
- }
- }
- }
- if (mask & GL_LINE_BIT) {
- /* OK to memcpy */
- dst->Line = src->Line;
- }
- if (mask & GL_LIST_BIT) {
- /* OK to memcpy */
- dst->List = src->List;
- }
- if (mask & GL_PIXEL_MODE_BIT) {
- /* OK to memcpy */
- dst->Pixel = src->Pixel;
- }
- if (mask & GL_POINT_BIT) {
- /* OK to memcpy */
- dst->Point = src->Point;
- }
- if (mask & GL_POLYGON_BIT) {
- /* OK to memcpy */
- dst->Polygon = src->Polygon;
- }
- if (mask & GL_POLYGON_STIPPLE_BIT) {
- /* Use loop instead of memcpy due to problem with Portland Group's
- * C compiler. Reported by John Stone.
- */
- GLuint i;
- for (i = 0; i < 32; i++) {
- dst->PolygonStipple[i] = src->PolygonStipple[i];
- }
- }
- if (mask & GL_SCISSOR_BIT) {
- /* OK to memcpy */
- dst->Scissor = src->Scissor;
- }
- if (mask & GL_STENCIL_BUFFER_BIT) {
- /* OK to memcpy */
- dst->Stencil = src->Stencil;
- }
- if (mask & GL_TEXTURE_BIT) {
- /* Cannot memcpy because of pointers */
- _mesa_copy_texture_state(src, dst);
- }
- if (mask & GL_TRANSFORM_BIT) {
- /* OK to memcpy */
- dst->Transform = src->Transform;
- }
- if (mask & GL_VIEWPORT_BIT) {
- /* Cannot use memcpy, because of pointers in GLmatrix _WindowMap */
- dst->Viewport.X = src->Viewport.X;
- dst->Viewport.Y = src->Viewport.Y;
- dst->Viewport.Width = src->Viewport.Width;
- dst->Viewport.Height = src->Viewport.Height;
- dst->Viewport.Near = src->Viewport.Near;
- dst->Viewport.Far = src->Viewport.Far;
- _math_matrix_copy(&dst->Viewport._WindowMap, &src->Viewport._WindowMap);
- }
-
- /* XXX FIXME: Call callbacks?
- */
- dst->NewState = _NEW_ALL;
-}
-#endif
-
-
-/**
- * Check if the given context can render into the given framebuffer
- * by checking visual attributes.
- *
- * Most of these tests could go away because Mesa is now pretty flexible
- * in terms of mixing rendering contexts with framebuffers. As long
- * as RGB vs. CI mode agree, we're probably good.
- *
- * \return GL_TRUE if compatible, GL_FALSE otherwise.
- */
-static GLboolean
-check_compatible(const struct gl_context *ctx,
- const struct gl_framebuffer *buffer)
-{
- const struct gl_config *ctxvis = &ctx->Visual;
- const struct gl_config *bufvis = &buffer->Visual;
-
- if (buffer == _mesa_get_incomplete_framebuffer())
- return GL_TRUE;
-
-#if 0
- /* disabling this fixes the fgl_glxgears pbuffer demo */
- if (ctxvis->doubleBufferMode && !bufvis->doubleBufferMode)
- return GL_FALSE;
-#endif
- if (ctxvis->stereoMode && !bufvis->stereoMode)
- return GL_FALSE;
- if (ctxvis->haveAccumBuffer && !bufvis->haveAccumBuffer)
- return GL_FALSE;
- if (ctxvis->haveDepthBuffer && !bufvis->haveDepthBuffer)
- return GL_FALSE;
- if (ctxvis->haveStencilBuffer && !bufvis->haveStencilBuffer)
- return GL_FALSE;
- if (ctxvis->redMask && ctxvis->redMask != bufvis->redMask)
- return GL_FALSE;
- if (ctxvis->greenMask && ctxvis->greenMask != bufvis->greenMask)
- return GL_FALSE;
- if (ctxvis->blueMask && ctxvis->blueMask != bufvis->blueMask)
- return GL_FALSE;
-#if 0
- /* disabled (see bug 11161) */
- if (ctxvis->depthBits && ctxvis->depthBits != bufvis->depthBits)
- return GL_FALSE;
-#endif
- if (ctxvis->stencilBits && ctxvis->stencilBits != bufvis->stencilBits)
- return GL_FALSE;
-
- return GL_TRUE;
-}
-
-
-/**
- * Do one-time initialization for the given framebuffer. Specifically,
- * ask the driver for the window's current size and update the framebuffer
- * object to match.
- * Really, the device driver should totally take care of this.
- */
-static void
-initialize_framebuffer_size(struct gl_context *ctx, struct gl_framebuffer *fb)
-{
- GLuint width, height;
- if (ctx->Driver.GetBufferSize) {
- ctx->Driver.GetBufferSize(fb, &width, &height);
- if (ctx->Driver.ResizeBuffers)
- ctx->Driver.ResizeBuffers(ctx, fb, width, height);
- fb->Initialized = GL_TRUE;
- }
-}
-
-
-/**
- * Check if the viewport/scissor size has not yet been initialized.
- * Initialize the size if the given width and height are non-zero.
- */
-void
-_mesa_check_init_viewport(struct gl_context *ctx, GLuint width, GLuint height)
-{
- if (!ctx->ViewportInitialized && width > 0 && height > 0) {
- /* Note: set flag here, before calling _mesa_set_viewport(), to prevent
- * potential infinite recursion.
- */
- ctx->ViewportInitialized = GL_TRUE;
- _mesa_set_viewport(ctx, 0, 0, width, height);
- _mesa_set_scissor(ctx, 0, 0, width, height);
- }
-}
-
-
-/**
- * Bind the given context to the given drawBuffer and readBuffer and
- * make it the current context for the calling thread.
- * We'll render into the drawBuffer and read pixels from the
- * readBuffer (i.e. glRead/CopyPixels, glCopyTexImage, etc).
- *
- * We check that the context's and framebuffer's visuals are compatible
- * and return immediately if they're not.
- *
- * \param newCtx the new GL context. If NULL then there will be no current GL
- * context.
- * \param drawBuffer the drawing framebuffer
- * \param readBuffer the reading framebuffer
- */
-GLboolean
-_mesa_make_current( struct gl_context *newCtx,
- struct gl_framebuffer *drawBuffer,
- struct gl_framebuffer *readBuffer )
-{
- GET_CURRENT_CONTEXT(curCtx);
-
- if (MESA_VERBOSE & VERBOSE_API)
- _mesa_debug(newCtx, "_mesa_make_current()\n");
-
- /* Check that the context's and framebuffer's visuals are compatible.
- */
- if (newCtx && drawBuffer && newCtx->WinSysDrawBuffer != drawBuffer) {
- if (!check_compatible(newCtx, drawBuffer)) {
- _mesa_warning(newCtx,
- "MakeCurrent: incompatible visuals for context and drawbuffer");
- return GL_FALSE;
- }
- }
- if (newCtx && readBuffer && newCtx->WinSysReadBuffer != readBuffer) {
- if (!check_compatible(newCtx, readBuffer)) {
- _mesa_warning(newCtx,
- "MakeCurrent: incompatible visuals for context and readbuffer");
- return GL_FALSE;
- }
- }
-
- if (curCtx &&
- (curCtx->WinSysDrawBuffer || curCtx->WinSysReadBuffer) && /* make sure this context is valid for flushing */
- curCtx != newCtx)
- _mesa_flush(curCtx);
-
- /* We used to call _glapi_check_multithread() here. Now do it in drivers */
- _glapi_set_context((void *) newCtx);
- ASSERT(_mesa_get_current_context() == newCtx);
-
- if (!newCtx) {
- _glapi_set_dispatch(NULL); /* none current */
- }
- else {
- _glapi_set_dispatch(newCtx->CurrentDispatch);
-
- if (drawBuffer && readBuffer) {
- /* TODO: check if newCtx and buffer's visual match??? */
-
- ASSERT(drawBuffer->Name == 0);
- ASSERT(readBuffer->Name == 0);
- _mesa_reference_framebuffer(&newCtx->WinSysDrawBuffer, drawBuffer);
- _mesa_reference_framebuffer(&newCtx->WinSysReadBuffer, readBuffer);
-
- /*
- * Only set the context's Draw/ReadBuffer fields if they're NULL
- * or not bound to a user-created FBO.
- */
- if (!newCtx->DrawBuffer || newCtx->DrawBuffer->Name == 0) {
- /* KW: merge conflict here, revisit.
- */
- /* fix up the fb fields - these will end up wrong otherwise
- * if the DRIdrawable changes, and everything relies on them.
- * This is a bit messy (same as needed in _mesa_BindFramebufferEXT)
- */
- unsigned int i;
- GLenum buffers[MAX_DRAW_BUFFERS];
-
- _mesa_reference_framebuffer(&newCtx->DrawBuffer, drawBuffer);
-
- for(i = 0; i < newCtx->Const.MaxDrawBuffers; i++) {
- buffers[i] = newCtx->Color.DrawBuffer[i];
- }
-
- _mesa_drawbuffers(newCtx, newCtx->Const.MaxDrawBuffers,
- buffers, NULL);
- }
- if (!newCtx->ReadBuffer || newCtx->ReadBuffer->Name == 0) {
- _mesa_reference_framebuffer(&newCtx->ReadBuffer, readBuffer);
- }
-
- /* XXX only set this flag if we're really changing the draw/read
- * framebuffer bindings.
- */
- newCtx->NewState |= _NEW_BUFFERS;
-
-#if 1
- /* We want to get rid of these lines: */
-
-#if _HAVE_FULL_GL
- if (!drawBuffer->Initialized) {
- initialize_framebuffer_size(newCtx, drawBuffer);
- }
- if (readBuffer != drawBuffer && !readBuffer->Initialized) {
- initialize_framebuffer_size(newCtx, readBuffer);
- }
-
- _mesa_resizebuffers(newCtx);
-#endif
-
-#else
- /* We want the drawBuffer and readBuffer to be initialized by
- * the driver.
- * This generally means the Width and Height match the actual
- * window size and the renderbuffers (both hardware and software
- * based) are allocated to match. The later can generally be
- * done with a call to _mesa_resize_framebuffer().
- *
- * It's theoretically possible for a buffer to have zero width
- * or height, but for now, assert check that the driver did what's
- * expected of it.
- */
- ASSERT(drawBuffer->Width > 0);
- ASSERT(drawBuffer->Height > 0);
-#endif
-
- if (drawBuffer) {
- _mesa_check_init_viewport(newCtx,
- drawBuffer->Width, drawBuffer->Height);
- }
- }
-
- if (newCtx->FirstTimeCurrent) {
- _mesa_compute_version(newCtx);
-
- newCtx->Extensions.String = _mesa_make_extension_string(newCtx);
-
- check_context_limits(newCtx);
-
- /* We can use this to help debug user's problems. Tell them to set
- * the MESA_INFO env variable before running their app. Then the
- * first time each context is made current we'll print some useful
- * information.
- */
- if (_mesa_getenv("MESA_INFO")) {
- _mesa_print_info();
- }
-
- newCtx->FirstTimeCurrent = GL_FALSE;
- }
- }
-
- return GL_TRUE;
-}
-
-
-/**
- * Make context 'ctx' share the display lists, textures and programs
- * that are associated with 'ctxToShare'.
- * Any display lists, textures or programs associated with 'ctx' will
- * be deleted if nobody else is sharing them.
- */
-GLboolean
-_mesa_share_state(struct gl_context *ctx, struct gl_context *ctxToShare)
-{
- if (ctx && ctxToShare && ctx->Shared && ctxToShare->Shared) {
- struct gl_shared_state *oldSharedState = ctx->Shared;
-
- ctx->Shared = ctxToShare->Shared;
-
- _glthread_LOCK_MUTEX(ctx->Shared->Mutex);
- ctx->Shared->RefCount++;
- _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex);
-
- update_default_objects(ctx);
-
- _mesa_release_shared_state(ctx, oldSharedState);
-
- return GL_TRUE;
- }
- else {
- return GL_FALSE;
- }
-}
-
-
-
-/**
- * \return pointer to the current GL context for this thread.
- *
- * Calls _glapi_get_context(). This isn't the fastest way to get the current
- * context. If you need speed, see the #GET_CURRENT_CONTEXT macro in
- * context.h.
- */
-struct gl_context *
-_mesa_get_current_context( void )
-{
- return (struct gl_context *) _glapi_get_context();
-}
-
-
-/**
- * Get context's current API dispatch table.
- *
- * It'll either be the immediate-mode execute dispatcher or the display list
- * compile dispatcher.
- *
- * \param ctx GL context.
- *
- * \return pointer to dispatch_table.
- *
- * Simply returns __struct gl_contextRec::CurrentDispatch.
- */
-struct _glapi_table *
-_mesa_get_dispatch(struct gl_context *ctx)
-{
- return ctx->CurrentDispatch;
-}
-
-/*@}*/
-
-
-/**********************************************************************/
-/** \name Miscellaneous functions */
-/**********************************************************************/
-/*@{*/
-
-/**
- * Record an error.
- *
- * \param ctx GL context.
- * \param error error code.
- *
- * Records the given error code and call the driver's dd_function_table::Error
- * function if defined.
- *
- * \sa
- * This is called via _mesa_error().
- */
-void
-_mesa_record_error(struct gl_context *ctx, GLenum error)
-{
- if (!ctx)
- return;
-
- if (ctx->ErrorValue == GL_NO_ERROR) {
- ctx->ErrorValue = error;
- }
-
- /* Call device driver's error handler, if any. This is used on the Mac. */
- if (ctx->Driver.Error) {
- ctx->Driver.Error(ctx);
- }
-}
-
-
-/**
- * Flush commands and wait for completion.
- */
-void
-_mesa_finish(struct gl_context *ctx)
-{
- FLUSH_CURRENT( ctx, 0 );
- if (ctx->Driver.Finish) {
- ctx->Driver.Finish(ctx);
- }
-}
-
-
-/**
- * Flush commands.
- */
-void
-_mesa_flush(struct gl_context *ctx)
-{
- FLUSH_CURRENT( ctx, 0 );
- if (ctx->Driver.Flush) {
- ctx->Driver.Flush(ctx);
- }
-}
-
-
-
-/**
- * Execute glFinish().
- *
- * Calls the #ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH macro and the
- * dd_function_table::Finish driver callback, if not NULL.
- */
-void GLAPIENTRY
-_mesa_Finish(void)
-{
- GET_CURRENT_CONTEXT(ctx);
- ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
- _mesa_finish(ctx);
-}
-
-
-/**
- * Execute glFlush().
- *
- * Calls the #ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH macro and the
- * dd_function_table::Flush driver callback, if not NULL.
- */
-void GLAPIENTRY
-_mesa_Flush(void)
-{
- GET_CURRENT_CONTEXT(ctx);
- ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
- _mesa_flush(ctx);
-}
-
-
-/**
- * Set mvp_with_dp4 flag. If a driver has a preference for DP4 over
- * MUL/MAD, or vice versa, call this function to register that.
- * Otherwise we default to MUL/MAD.
- */
-void
-_mesa_set_mvp_with_dp4( struct gl_context *ctx,
- GLboolean flag )
-{
- ctx->mvp_with_dp4 = flag;
-}
-
-
-
-/**
- * Prior to drawing anything with glBegin, glDrawArrays, etc. this function
- * is called to see if it's valid to render. This involves checking that
- * the current shader is valid and the framebuffer is complete.
- * If an error is detected it'll be recorded here.
- * \return GL_TRUE if OK to render, GL_FALSE if not
- */
-GLboolean
-_mesa_valid_to_render(struct gl_context *ctx, const char *where)
-{
- bool vert_from_glsl_shader = false;
- bool geom_from_glsl_shader = false;
- bool frag_from_glsl_shader = false;
-
- /* This depends on having up to date derived state (shaders) */
- if (ctx->NewState)
- _mesa_update_state(ctx);
-
- if (ctx->Shader.CurrentVertexProgram) {
- vert_from_glsl_shader = true;
-
- if (!ctx->Shader.CurrentVertexProgram->LinkStatus) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "%s(shader not linked)", where);
- return GL_FALSE;
- }
-#if 0 /* not normally enabled */
- {
- char errMsg[100];
- if (!_mesa_validate_shader_program(ctx,
- ctx->Shader.CurrentVertexProgram,
- errMsg)) {
- _mesa_warning(ctx, "Shader program %u is invalid: %s",
- ctx->Shader.CurrentVertexProgram->Name, errMsg);
- }
- }
-#endif
- }
-
- if (ctx->Shader.CurrentGeometryProgram) {
- geom_from_glsl_shader = true;
-
- if (!ctx->Shader.CurrentGeometryProgram->LinkStatus) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "%s(shader not linked)", where);
- return GL_FALSE;
- }
-#if 0 /* not normally enabled */
- {
- char errMsg[100];
- if (!_mesa_validate_shader_program(ctx,
- ctx->Shader.CurrentGeometryProgram,
- errMsg)) {
- _mesa_warning(ctx, "Shader program %u is invalid: %s",
- ctx->Shader.CurrentGeometryProgram->Name, errMsg);
- }
- }
-#endif
- }
-
- if (ctx->Shader.CurrentFragmentProgram) {
- frag_from_glsl_shader = true;
-
- if (!ctx->Shader.CurrentFragmentProgram->LinkStatus) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "%s(shader not linked)", where);
- return GL_FALSE;
- }
-#if 0 /* not normally enabled */
- {
- char errMsg[100];
- if (!_mesa_validate_shader_program(ctx,
- ctx->Shader.CurrentFragmentProgram,
- errMsg)) {
- _mesa_warning(ctx, "Shader program %u is invalid: %s",
- ctx->Shader.CurrentFragmentProgram->Name, errMsg);
- }
- }
-#endif
- }
-
- /* Any shader stages that are not supplied by the GLSL shader and have
- * assembly shaders enabled must now be validated.
- */
- if (!vert_from_glsl_shader
- && ctx->VertexProgram.Enabled && !ctx->VertexProgram._Enabled) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "%s(vertex program not valid)", where);
- return GL_FALSE;
- }
-
- /* FINISHME: If GL_NV_geometry_program4 is ever supported, the current
- * FINISHME: geometry program should validated here.
- */
- (void) geom_from_glsl_shader;
-
- if (!frag_from_glsl_shader) {
- if (ctx->FragmentProgram.Enabled && !ctx->FragmentProgram._Enabled) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "%s(fragment program not valid)", where);
- return GL_FALSE;
- }
-
- /* If drawing to integer-valued color buffers, there must be an
- * active fragment shader (GL_EXT_texture_integer).
- */
- if (ctx->DrawBuffer && ctx->DrawBuffer->_IntegerColor) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "%s(integer format but no fragment shader)", where);
- return GL_FALSE;
- }
- }
-
- if (ctx->DrawBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) {
- _mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION_EXT,
- "%s(incomplete framebuffer)", where);
- return GL_FALSE;
- }
-
-#ifdef DEBUG
- if (ctx->Shader.Flags & GLSL_LOG) {
- struct gl_shader_program *shProg[MESA_SHADER_TYPES];
- gl_shader_type i;
-
- shProg[MESA_SHADER_VERTEX] = ctx->Shader.CurrentVertexProgram;
- shProg[MESA_SHADER_GEOMETRY] = ctx->Shader.CurrentGeometryProgram;
- shProg[MESA_SHADER_FRAGMENT] = ctx->Shader.CurrentFragmentProgram;
-
- for (i = 0; i < MESA_SHADER_TYPES; i++) {
- struct gl_shader *sh;
-
- if (shProg[i] == NULL || shProg[i]->_Used
- || shProg[i]->_LinkedShaders[i] == NULL)
- continue;
-
- /* This is the first time this shader is being used.
- * Append shader's constants/uniforms to log file.
- *
- * The logic is a little odd here. We only want to log data for each
- * shader target that will actually be used, and we only want to log
- * it once. It's possible to have a program bound to the vertex
- * shader target that also supplied a fragment shader. If that
- * program isn't also bound to the fragment shader target we don't
- * want to log its fragment data.
- */
- sh = shProg[i]->_LinkedShaders[i];
- switch (sh->Type) {
- case GL_VERTEX_SHADER:
- _mesa_append_uniforms_to_file(sh, &shProg[i]->VertexProgram->Base);
- break;
-
- case GL_GEOMETRY_SHADER_ARB:
- _mesa_append_uniforms_to_file(sh,
- &shProg[i]->GeometryProgram->Base);
- break;
-
- case GL_FRAGMENT_SHADER:
- _mesa_append_uniforms_to_file(sh,
- &shProg[i]->FragmentProgram->Base);
- break;
- }
- }
-
- for (i = 0; i < MESA_SHADER_TYPES; i++) {
- if (shProg[i] != NULL)
- shProg[i]->_Used = GL_TRUE;
- }
- }
-#endif
-
- return GL_TRUE;
-}
-
-
-/*@}*/
diff --git a/src/mesa/main/debug.c b/src/mesa/main/debug.c
deleted file mode 100644
index 79aa535..0000000
--- a/src/mesa/main/debug.c
+++ /dev/null
@@ -1,633 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version: 6.5
- *
- * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
- * Copyright (C) 2009 VMware, Inc. 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.
- */
-
-#include "mtypes.h"
-#include "attrib.h"
-#include "colormac.h"
-#include "enums.h"
-#include "formats.h"
-#include "hash.h"
-#include "imports.h"
-#include "debug.h"
-#include "get.h"
-#include "pixelstore.h"
-#include "readpix.h"
-#include "texobj.h"
-
-
-/**
- * Primitive names
- */
-const char *_mesa_prim_name[GL_POLYGON+4] = {
- "GL_POINTS",
- "GL_LINES",
- "GL_LINE_LOOP",
- "GL_LINE_STRIP",
- "GL_TRIANGLES",
- "GL_TRIANGLE_STRIP",
- "GL_TRIANGLE_FAN",
- "GL_QUADS",
- "GL_QUAD_STRIP",
- "GL_POLYGON",
- "outside begin/end",
- "inside unknown primitive",
- "unknown state"
-};
-
-
-static const char *
-tex_target_name(GLenum tgt)
-{
- static const struct {
- GLenum target;
- const char *name;
- } tex_targets[] = {
- { GL_TEXTURE_1D, "GL_TEXTURE_1D" },
- { GL_TEXTURE_2D, "GL_TEXTURE_2D" },
- { GL_TEXTURE_3D, "GL_TEXTURE_3D" },
- { GL_TEXTURE_CUBE_MAP, "GL_TEXTURE_CUBE_MAP" },
- { GL_TEXTURE_RECTANGLE, "GL_TEXTURE_RECTANGLE" },
- { GL_TEXTURE_1D_ARRAY_EXT, "GL_TEXTURE_1D_ARRAY" },
- { GL_TEXTURE_2D_ARRAY_EXT, "GL_TEXTURE_2D_ARRAY" }
- };
- GLuint i;
- for (i = 0; i < Elements(tex_targets); i++) {
- if (tex_targets[i].target == tgt)
- return tex_targets[i].name;
- }
- return "UNKNOWN TEX TARGET";
-}
-
-
-void
-_mesa_print_state( const char *msg, GLuint state )
-{
- _mesa_debug(NULL,
- "%s: (0x%x) %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
- msg,
- state,
- (state & _NEW_MODELVIEW) ? "ctx->ModelView, " : "",
- (state & _NEW_PROJECTION) ? "ctx->Projection, " : "",
- (state & _NEW_TEXTURE_MATRIX) ? "ctx->TextureMatrix, " : "",
- (state & _NEW_ACCUM) ? "ctx->Accum, " : "",
- (state & _NEW_COLOR) ? "ctx->Color, " : "",
- (state & _NEW_DEPTH) ? "ctx->Depth, " : "",
- (state & _NEW_EVAL) ? "ctx->Eval/EvalMap, " : "",
- (state & _NEW_FOG) ? "ctx->Fog, " : "",
- (state & _NEW_HINT) ? "ctx->Hint, " : "",
- (state & _NEW_LIGHT) ? "ctx->Light, " : "",
- (state & _NEW_LINE) ? "ctx->Line, " : "",
- (state & _NEW_PIXEL) ? "ctx->Pixel, " : "",
- (state & _NEW_POINT) ? "ctx->Point, " : "",
- (state & _NEW_POLYGON) ? "ctx->Polygon, " : "",
- (state & _NEW_POLYGONSTIPPLE) ? "ctx->PolygonStipple, " : "",
- (state & _NEW_SCISSOR) ? "ctx->Scissor, " : "",
- (state & _NEW_STENCIL) ? "ctx->Stencil, " : "",
- (state & _NEW_TEXTURE) ? "ctx->Texture, " : "",
- (state & _NEW_TRANSFORM) ? "ctx->Transform, " : "",
- (state & _NEW_VIEWPORT) ? "ctx->Viewport, " : "",
- (state & _NEW_PACKUNPACK) ? "ctx->Pack/Unpack, " : "",
- (state & _NEW_ARRAY) ? "ctx->Array, " : "",
- (state & _NEW_RENDERMODE) ? "ctx->RenderMode, " : "",
- (state & _NEW_BUFFERS) ? "ctx->Visual, ctx->DrawBuffer,, " : "");
-}
-
-
-
-void
-_mesa_print_tri_caps( const char *name, GLuint flags )
-{
- _mesa_debug(NULL,
- "%s: (0x%x) %s%s%s%s%s%s%s%s%s%s%s%s%s\n",
- name,
- flags,
- (flags & DD_FLATSHADE) ? "flat-shade, " : "",
- (flags & DD_SEPARATE_SPECULAR) ? "separate-specular, " : "",
- (flags & DD_TRI_LIGHT_TWOSIDE) ? "tri-light-twoside, " : "",
- (flags & DD_TRI_TWOSTENCIL) ? "tri-twostencil, " : "",
- (flags & DD_TRI_UNFILLED) ? "tri-unfilled, " : "",
- (flags & DD_TRI_STIPPLE) ? "tri-stipple, " : "",
- (flags & DD_TRI_OFFSET) ? "tri-offset, " : "",
- (flags & DD_TRI_SMOOTH) ? "tri-smooth, " : "",
- (flags & DD_LINE_SMOOTH) ? "line-smooth, " : "",
- (flags & DD_LINE_STIPPLE) ? "line-stipple, " : "",
- (flags & DD_POINT_SMOOTH) ? "point-smooth, " : "",
- (flags & DD_POINT_ATTEN) ? "point-atten, " : "",
- (flags & DD_TRI_CULL_FRONT_BACK) ? "cull-all, " : ""
- );
-}
-
-
-/**
- * Print information about this Mesa version and build options.
- */
-void _mesa_print_info( void )
-{
- _mesa_debug(NULL, "Mesa GL_VERSION = %s\n",
- (char *) _mesa_GetString(GL_VERSION));
- _mesa_debug(NULL, "Mesa GL_RENDERER = %s\n",
- (char *) _mesa_GetString(GL_RENDERER));
- _mesa_debug(NULL, "Mesa GL_VENDOR = %s\n",
- (char *) _mesa_GetString(GL_VENDOR));
- _mesa_debug(NULL, "Mesa GL_EXTENSIONS = %s\n",
- (char *) _mesa_GetString(GL_EXTENSIONS));
-#if defined(THREADS)
- _mesa_debug(NULL, "Mesa thread-safe: YES\n");
-#else
- _mesa_debug(NULL, "Mesa thread-safe: NO\n");
-#endif
-#if defined(USE_X86_ASM)
- _mesa_debug(NULL, "Mesa x86-optimized: YES\n");
-#else
- _mesa_debug(NULL, "Mesa x86-optimized: NO\n");
-#endif
-#if defined(USE_SPARC_ASM)
- _mesa_debug(NULL, "Mesa sparc-optimized: YES\n");
-#else
- _mesa_debug(NULL, "Mesa sparc-optimized: NO\n");
-#endif
-}
-
-
-/**
- * Set the debugging flags.
- *
- * \param debug debug string
- *
- * If compiled with debugging support then search for keywords in \p debug and
- * enables the verbose debug output of the respective feature.
- */
-static void add_debug_flags( const char *debug )
-{
-#ifdef DEBUG
- struct debug_option {
- const char *name;
- GLbitfield flag;
- };
- static const struct debug_option debug_opt[] = {
- { "varray", VERBOSE_VARRAY },
- { "tex", VERBOSE_TEXTURE },
- { "mat", VERBOSE_MATERIAL },
- { "pipe", VERBOSE_PIPELINE },
- { "driver", VERBOSE_DRIVER },
- { "state", VERBOSE_STATE },
- { "api", VERBOSE_API },
- { "list", VERBOSE_DISPLAY_LIST },
- { "lighting", VERBOSE_LIGHTING },
- { "disassem", VERBOSE_DISASSEM },
- { "draw", VERBOSE_DRAW },
- { "swap", VERBOSE_SWAPBUFFERS }
- };
- GLuint i;
-
- MESA_VERBOSE = 0x0;
- for (i = 0; i < Elements(debug_opt); i++) {
- if (strstr(debug, debug_opt[i].name))
- MESA_VERBOSE |= debug_opt[i].flag;
- }
-
- /* Debug flag:
- */
- if (strstr(debug, "flush"))
- MESA_DEBUG_FLAGS |= DEBUG_ALWAYS_FLUSH;
-
-#if defined(_FPU_GETCW) && defined(_FPU_SETCW)
- if (strstr(debug, "fpexceptions")) {
- /* raise FP exceptions */
- fpu_control_t mask;
- _FPU_GETCW(mask);
- mask &= ~(_FPU_MASK_IM | _FPU_MASK_DM | _FPU_MASK_ZM
- | _FPU_MASK_OM | _FPU_MASK_UM);
- _FPU_SETCW(mask);
- }
-#endif
-
-#else
- (void) debug;
-#endif
-}
-
-
-void
-_mesa_init_debug( struct gl_context *ctx )
-{
- char *c;
-
- /* Dither disable */
- ctx->NoDither = _mesa_getenv("MESA_NO_DITHER") ? GL_TRUE : GL_FALSE;
- if (ctx->NoDither) {
- if (_mesa_getenv("MESA_DEBUG")) {
- _mesa_debug(ctx, "MESA_NO_DITHER set - dithering disabled\n");
- }
- ctx->Color.DitherFlag = GL_FALSE;
- }
-
- c = _mesa_getenv("MESA_DEBUG");
- if (c)
- add_debug_flags(c);
-
- c = _mesa_getenv("MESA_VERBOSE");
- if (c)
- add_debug_flags(c);
-}
-
-
-/*
- * Write ppm file
- */
-static void
-write_ppm(const char *filename, const GLubyte *buffer, int width, int height,
- int comps, int rcomp, int gcomp, int bcomp, GLboolean invert)
-{
- FILE *f = fopen( filename, "w" );
- if (f) {
- int x, y;
- const GLubyte *ptr = buffer;
- fprintf(f,"P6\n");
- fprintf(f,"# ppm-file created by osdemo.c\n");
- fprintf(f,"%i %i\n", width,height);
- fprintf(f,"255\n");
- fclose(f);
- f = fopen( filename, "ab" ); /* reopen in binary append mode */
- for (y=0; y < height; y++) {
- for (x = 0; x < width; x++) {
- int yy = invert ? (height - 1 - y) : y;
- int i = (yy * width + x) * comps;
- fputc(ptr[i+rcomp], f); /* write red */
- fputc(ptr[i+gcomp], f); /* write green */
- fputc(ptr[i+bcomp], f); /* write blue */
- }
- }
- fclose(f);
- }
-}
-
-
-/**
- * Write a texture image to a ppm file.
- * \param face cube face in [0,5]
- * \param level mipmap level
- */
-static void
-write_texture_image(struct gl_texture_object *texObj,
- GLuint face, GLuint level)
-{
- struct gl_texture_image *img = texObj->Image[face][level];
- if (img) {
- GET_CURRENT_CONTEXT(ctx);
- struct gl_pixelstore_attrib store;
- GLubyte *buffer;
- char s[100];
-
- buffer = (GLubyte *) malloc(img->Width * img->Height
- * img->Depth * 4);
-
- store = ctx->Pack; /* save */
- ctx->Pack = ctx->DefaultPacking;
-
- ctx->Driver.GetTexImage(ctx, texObj->Target, level,
- GL_RGBA, GL_UNSIGNED_BYTE,
- buffer, texObj, img);
-
- /* make filename */
- _mesa_snprintf(s, sizeof(s), "/tmp/tex%u.l%u.f%u.ppm", texObj->Name, level, face);
-
- printf(" Writing image level %u to %s\n", level, s);
- write_ppm(s, buffer, img->Width, img->Height, 4, 0, 1, 2, GL_FALSE);
-
- ctx->Pack = store; /* restore */
-
- free(buffer);
- }
-}
-
-
-/**
- * Write renderbuffer image to a ppm file.
- */
-static void
-write_renderbuffer_image(const struct gl_renderbuffer *rb)
-{
- GET_CURRENT_CONTEXT(ctx);
- GLubyte *buffer;
- char s[100];
- GLenum format, type;
-
- if (rb->_BaseFormat == GL_RGB ||
- rb->_BaseFormat == GL_RGBA) {
- format = GL_RGBA;
- type = GL_UNSIGNED_BYTE;
- }
- else if (rb->_BaseFormat == GL_DEPTH_STENCIL) {
- format = GL_DEPTH_STENCIL;
- type = GL_UNSIGNED_INT_24_8;
- }
- else {
- return;
- }
-
- buffer = (GLubyte *) malloc(rb->Width * rb->Height * 4);
-
- ctx->Driver.ReadPixels(ctx, 0, 0, rb->Width, rb->Height,
- format, type, &ctx->DefaultPacking, buffer);
-
- /* make filename */
- _mesa_snprintf(s, sizeof(s), "/tmp/renderbuffer%u.ppm", rb->Name);
-
- printf(" Writing renderbuffer image to %s\n", s);
- write_ppm(s, buffer, rb->Width, rb->Height, 4, 0, 1, 2, GL_TRUE);
-
- free(buffer);
-}
-
-
-/** How many texture images (mipmap levels, faces) to write to files */
-#define WRITE_NONE 0
-#define WRITE_ONE 1
-#define WRITE_ALL 2
-
-static GLuint WriteImages;
-
-
-static void
-dump_texture(struct gl_texture_object *texObj, GLuint writeImages)
-{
- const GLuint numFaces = texObj->Target == GL_TEXTURE_CUBE_MAP ? 6 : 1;
- GLboolean written = GL_FALSE;
- GLuint i, j;
-
- printf("Texture %u\n", texObj->Name);
- printf(" Target %s\n", tex_target_name(texObj->Target));
- for (i = 0; i < MAX_TEXTURE_LEVELS; i++) {
- for (j = 0; j < numFaces; j++) {
- struct gl_texture_image *texImg = texObj->Image[j][i];
- if (texImg) {
- printf(" Face %u level %u: %d x %d x %d, format %s at %p\n",
- j, i,
- texImg->Width, texImg->Height, texImg->Depth,
- _mesa_get_format_name(texImg->TexFormat),
- texImg->Data);
- if (writeImages == WRITE_ALL ||
- (writeImages == WRITE_ONE && !written)) {
- write_texture_image(texObj, j, i);
- written = GL_TRUE;
- }
- }
- }
- }
-}
-
-
-/**
- * Dump a single texture.
- */
-void
-_mesa_dump_texture(GLuint texture, GLuint writeImages)
-{
- GET_CURRENT_CONTEXT(ctx);
- struct gl_texture_object *texObj = _mesa_lookup_texture(ctx, texture);
- if (texObj) {
- dump_texture(texObj, writeImages);
- }
-}
-
-
-static void
-dump_texture_cb(GLuint id, void *data, void *userData)
-{
- struct gl_texture_object *texObj = (struct gl_texture_object *) data;
- (void) userData;
- dump_texture(texObj, WriteImages);
-}
-
-
-/**
- * Print basic info about all texture objext to stdout.
- * If dumpImages is true, write PPM of level[0] image to a file.
- */
-void
-_mesa_dump_textures(GLuint writeImages)
-{
- GET_CURRENT_CONTEXT(ctx);
- WriteImages = writeImages;
- _mesa_HashWalk(ctx->Shared->TexObjects, dump_texture_cb, ctx);
-}
-
-
-static void
-dump_renderbuffer(const struct gl_renderbuffer *rb, GLboolean writeImage)
-{
- printf("Renderbuffer %u: %u x %u IntFormat = %s\n",
- rb->Name, rb->Width, rb->Height,
- _mesa_lookup_enum_by_nr(rb->InternalFormat));
- if (writeImage) {
- write_renderbuffer_image(rb);
- }
-}
-
-
-static void
-dump_renderbuffer_cb(GLuint id, void *data, void *userData)
-{
- const struct gl_renderbuffer *rb = (const struct gl_renderbuffer *) data;
- (void) userData;
- dump_renderbuffer(rb, WriteImages);
-}
-
-
-/**
- * Print basic info about all renderbuffers to stdout.
- * If dumpImages is true, write PPM of level[0] image to a file.
- */
-void
-_mesa_dump_renderbuffers(GLboolean writeImages)
-{
- GET_CURRENT_CONTEXT(ctx);
- WriteImages = writeImages;
- _mesa_HashWalk(ctx->Shared->RenderBuffers, dump_renderbuffer_cb, ctx);
-}
-
-
-
-void
-_mesa_dump_color_buffer(const char *filename)
-{
- GET_CURRENT_CONTEXT(ctx);
- const GLuint w = ctx->DrawBuffer->Width;
- const GLuint h = ctx->DrawBuffer->Height;
- GLubyte *buf;
-
- buf = (GLubyte *) malloc(w * h * 4);
-
- _mesa_PushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT);
- _mesa_PixelStorei(GL_PACK_ALIGNMENT, 1);
- _mesa_PixelStorei(GL_PACK_INVERT_MESA, GL_TRUE);
-
- _mesa_ReadPixels(0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, buf);
-
- printf("ReadBuffer %p 0x%x DrawBuffer %p 0x%x\n",
- (void *) ctx->ReadBuffer->_ColorReadBuffer,
- ctx->ReadBuffer->ColorReadBuffer,
- (void *) ctx->DrawBuffer->_ColorDrawBuffers[0],
- ctx->DrawBuffer->ColorDrawBuffer[0]);
- printf("Writing %d x %d color buffer to %s\n", w, h, filename);
- write_ppm(filename, buf, w, h, 4, 0, 1, 2, GL_TRUE);
-
- _mesa_PopClientAttrib();
-
- free(buf);
-}
-
-
-void
-_mesa_dump_depth_buffer(const char *filename)
-{
- GET_CURRENT_CONTEXT(ctx);
- const GLuint w = ctx->DrawBuffer->Width;
- const GLuint h = ctx->DrawBuffer->Height;
- GLuint *buf;
- GLubyte *buf2;
- GLuint i;
-
- buf = (GLuint *) malloc(w * h * 4); /* 4 bpp */
- buf2 = (GLubyte *) malloc(w * h * 3); /* 3 bpp */
-
- _mesa_PushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT);
- _mesa_PixelStorei(GL_PACK_ALIGNMENT, 1);
- _mesa_PixelStorei(GL_PACK_INVERT_MESA, GL_TRUE);
-
- _mesa_ReadPixels(0, 0, w, h, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, buf);
-
- /* spread 24 bits of Z across R, G, B */
- for (i = 0; i < w * h; i++) {
- buf2[i*3+0] = (buf[i] >> 24) & 0xff;
- buf2[i*3+1] = (buf[i] >> 16) & 0xff;
- buf2[i*3+2] = (buf[i] >> 8) & 0xff;
- }
-
- printf("Writing %d x %d depth buffer to %s\n", w, h, filename);
- write_ppm(filename, buf2, w, h, 3, 0, 1, 2, GL_TRUE);
-
- _mesa_PopClientAttrib();
-
- free(buf);
- free(buf2);
-}
-
-
-void
-_mesa_dump_stencil_buffer(const char *filename)
-{
- GET_CURRENT_CONTEXT(ctx);
- const GLuint w = ctx->DrawBuffer->Width;
- const GLuint h = ctx->DrawBuffer->Height;
- GLubyte *buf;
- GLubyte *buf2;
- GLuint i;
-
- buf = (GLubyte *) malloc(w * h); /* 1 bpp */
- buf2 = (GLubyte *) malloc(w * h * 3); /* 3 bpp */
-
- _mesa_PushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT);
- _mesa_PixelStorei(GL_PACK_ALIGNMENT, 1);
- _mesa_PixelStorei(GL_PACK_INVERT_MESA, GL_TRUE);
-
- _mesa_ReadPixels(0, 0, w, h, GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, buf);
-
- for (i = 0; i < w * h; i++) {
- buf2[i*3+0] = buf[i];
- buf2[i*3+1] = (buf[i] & 127) * 2;
- buf2[i*3+2] = (buf[i] - 128) * 2;
- }
-
- printf("Writing %d x %d stencil buffer to %s\n", w, h, filename);
- write_ppm(filename, buf2, w, h, 3, 0, 1, 2, GL_TRUE);
-
- _mesa_PopClientAttrib();
-
- free(buf);
- free(buf2);
-}
-
-
-/**
- * Quick and dirty function to "print" a texture to stdout.
- */
-void
-_mesa_print_texture(struct gl_context *ctx, const struct gl_texture_image *img)
-{
-#if CHAN_TYPE != GL_UNSIGNED_BYTE
- _mesa_problem(NULL, "PrintTexture not supported");
-#else
- GLuint i, j, c;
- const GLubyte *data = (const GLubyte *) img->Data;
-
- if (!data) {
- printf("No texture data\n");
- return;
- }
-
- /* XXX add more formats or make into a new format utility function */
- switch (img->TexFormat) {
- case MESA_FORMAT_A8:
- case MESA_FORMAT_L8:
- case MESA_FORMAT_I8:
- case MESA_FORMAT_CI8:
- c = 1;
- break;
- case MESA_FORMAT_AL88:
- case MESA_FORMAT_AL88_REV:
- c = 2;
- break;
- case MESA_FORMAT_RGB888:
- case MESA_FORMAT_BGR888:
- c = 3;
- break;
- case MESA_FORMAT_RGBA8888:
- case MESA_FORMAT_ARGB8888:
- c = 4;
- break;
- default:
- _mesa_problem(NULL, "error in PrintTexture\n");
- return;
- }
-
- for (i = 0; i < img->Height; i++) {
- for (j = 0; j < img->Width; j++) {
- if (c==1)
- printf("%02x ", data[0]);
- else if (c==2)
- printf("%02x%02x ", data[0], data[1]);
- else if (c==3)
- printf("%02x%02x%02x ", data[0], data[1], data[2]);
- else if (c==4)
- printf("%02x%02x%02x%02x ", data[0], data[1], data[2], data[3]);
- data += (img->RowStride - img->Width) * c;
- }
- /* XXX use img->ImageStride here */
- printf("\n");
- }
-#endif
-}
diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
deleted file mode 100644
index 5ae35b8..0000000
--- a/src/mesa/main/get.c
+++ /dev/null
@@ -1,2464 +0,0 @@
-/*
- * Copyright (C) 2010 Brian Paul All Rights Reserved.
- * Copyright (C) 2010 Intel Corporation
- *
- * 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.
- *
- * Author: Kristian Høgsberg <krh@bitplanet.net>
- */
-
-#include "glheader.h"
-#include "context.h"
-#include "enable.h"
-#include "enums.h"
-#include "extensions.h"
-#include "get.h"
-#include "macros.h"
-#include "mtypes.h"
-#include "state.h"
-#include "texcompress.h"
-#include "framebuffer.h"
-
-/* This is a table driven implemetation of the glGet*v() functions.
- * The basic idea is that most getters just look up an int somewhere
- * in struct gl_context and then convert it to a bool or float according to
- * which of glGetIntegerv() glGetBooleanv() etc is being called.
- * Instead of generating code to do this, we can just record the enum
- * value and the offset into struct gl_context in an array of structs. Then
- * in glGet*(), we lookup the struct for the enum in question, and use
- * the offset to get the int we need.
- *
- * Sometimes we need to look up a float, a boolean, a bit in a
- * bitfield, a matrix or other types instead, so we need to track the
- * type of the value in struct gl_context. And sometimes the value isn't in
- * struct gl_context but in the drawbuffer, the array object, current texture
- * unit, or maybe it's a computed value. So we need to also track
- * where or how to find the value. Finally, we sometimes need to
- * check that one of a number of extensions are enabled, the GL
- * version or flush or call _mesa_update_state(). This is done by
- * attaching optional extra information to the value description
- * struct, it's sort of like an array of opcodes that describe extra
- * checks or actions.
- *
- * Putting all this together we end up with struct value_desc below,
- * and with a couple of macros to help, the table of struct value_desc
- * is about as concise as the specification in the old python script.
- */
-
-#undef CONST
-
-#define FLOAT_TO_BOOLEAN(X) ( (X) ? GL_TRUE : GL_FALSE )
-#define FLOAT_TO_FIXED(F) ( ((F) * 65536.0f > INT_MAX) ? INT_MAX : \
- ((F) * 65536.0f < INT_MIN) ? INT_MIN : \
- (GLint) ((F) * 65536.0f) )
-
-#define INT_TO_BOOLEAN(I) ( (I) ? GL_TRUE : GL_FALSE )
-#define INT_TO_FIXED(I) ( ((I) > SHRT_MAX) ? INT_MAX : \
- ((I) < SHRT_MIN) ? INT_MIN : \
- (GLint) ((I) * 65536) )
-
-#define INT64_TO_BOOLEAN(I) ( (I) ? GL_TRUE : GL_FALSE )
-#define INT64_TO_INT(I) ( (GLint)((I > INT_MAX) ? INT_MAX : ((I < INT_MIN) ? INT_MIN : (I))) )
-
-#define BOOLEAN_TO_INT(B) ( (GLint) (B) )
-#define BOOLEAN_TO_INT64(B) ( (GLint64) (B) )
-#define BOOLEAN_TO_FLOAT(B) ( (B) ? 1.0F : 0.0F )
-#define BOOLEAN_TO_FIXED(B) ( (GLint) ((B) ? 1 : 0) << 16 )
-
-#define ENUM_TO_INT64(E) ( (GLint64) (E) )
-#define ENUM_TO_FIXED(E) (E)
-
-enum value_type {
- TYPE_INVALID,
- TYPE_API_MASK,
- TYPE_INT,
- TYPE_INT_2,
- TYPE_INT_3,
- TYPE_INT_4,
- TYPE_INT_N,
- TYPE_INT64,
- TYPE_ENUM,
- TYPE_ENUM_2,
- TYPE_BOOLEAN,
- TYPE_BIT_0,
- TYPE_BIT_1,
- TYPE_BIT_2,
- TYPE_BIT_3,
- TYPE_BIT_4,
- TYPE_BIT_5,
- TYPE_FLOAT,
- TYPE_FLOAT_2,
- TYPE_FLOAT_3,
- TYPE_FLOAT_4,
- TYPE_FLOATN,
- TYPE_FLOATN_2,
- TYPE_FLOATN_3,
- TYPE_FLOATN_4,
- TYPE_DOUBLEN,
- TYPE_MATRIX,
- TYPE_MATRIX_T,
- TYPE_CONST
-};
-
-enum value_location {
- LOC_BUFFER,
- LOC_CONTEXT,
- LOC_ARRAY,
- LOC_TEXUNIT,
- LOC_CUSTOM
-};
-
-enum value_extra {
- EXTRA_END = 0x8000,
- EXTRA_VERSION_30,
- EXTRA_VERSION_31,
- EXTRA_VERSION_32,
- EXTRA_VERSION_ES2,
- EXTRA_NEW_BUFFERS,
- EXTRA_VALID_DRAW_BUFFER,
- EXTRA_VALID_TEXTURE_UNIT,
- EXTRA_FLUSH_CURRENT,
-};
-
-#define NO_EXTRA NULL
-#define NO_OFFSET 0
-
-struct value_desc {
- GLenum pname;
- GLubyte location; /**< enum value_location */
- GLubyte type; /**< enum value_type */
- int offset;
- const int *extra;
-};
-
-union value {
- GLfloat value_float;
- GLfloat value_float_4[4];
- GLmatrix *value_matrix;
- GLint value_int;
- GLint value_int_4[4];
- GLint64 value_int64;
- GLenum value_enum;
-
- /* Sigh, see GL_COMPRESSED_TEXTURE_FORMATS_ARB handling */
- struct {
- GLint n, ints[100];
- } value_int_n;
- GLboolean value_bool;
-};
-
-#define BUFFER_FIELD(field, type) \
- LOC_BUFFER, type, offsetof(struct gl_framebuffer, field)
-#define CONTEXT_FIELD(field, type) \
- LOC_CONTEXT, type, offsetof(struct gl_context, field)
-#define ARRAY_FIELD(field, type) \
- LOC_ARRAY, type, offsetof(struct gl_array_object, field)
-#define CONST(value) \
- LOC_CONTEXT, TYPE_CONST, value
-
-#define BUFFER_INT(field) BUFFER_FIELD(field, TYPE_INT)
-#define BUFFER_ENUM(field) BUFFER_FIELD(field, TYPE_ENUM)
-#define BUFFER_BOOL(field) BUFFER_FIELD(field, TYPE_BOOLEAN)
-
-#define CONTEXT_INT(field) CONTEXT_FIELD(field, TYPE_INT)
-#define CONTEXT_INT2(field) CONTEXT_FIELD(field, TYPE_INT_2)
-#define CONTEXT_INT64(field) CONTEXT_FIELD(field, TYPE_INT64)
-#define CONTEXT_ENUM(field) CONTEXT_FIELD(field, TYPE_ENUM)
-#define CONTEXT_ENUM2(field) CONTEXT_FIELD(field, TYPE_ENUM_2)
-#define CONTEXT_BOOL(field) CONTEXT_FIELD(field, TYPE_BOOLEAN)
-#define CONTEXT_BIT0(field) CONTEXT_FIELD(field, TYPE_BIT_0)
-#define CONTEXT_BIT1(field) CONTEXT_FIELD(field, TYPE_BIT_1)
-#define CONTEXT_BIT2(field) CONTEXT_FIELD(field, TYPE_BIT_2)
-#define CONTEXT_BIT3(field) CONTEXT_FIELD(field, TYPE_BIT_3)
-#define CONTEXT_BIT4(field) CONTEXT_FIELD(field, TYPE_BIT_4)
-#define CONTEXT_BIT5(field) CONTEXT_FIELD(field, TYPE_BIT_5)
-#define CONTEXT_FLOAT(field) CONTEXT_FIELD(field, TYPE_FLOAT)
-#define CONTEXT_FLOAT2(field) CONTEXT_FIELD(field, TYPE_FLOAT_2)
-#define CONTEXT_FLOAT3(field) CONTEXT_FIELD(field, TYPE_FLOAT_3)
-#define CONTEXT_FLOAT4(field) CONTEXT_FIELD(field, TYPE_FLOAT_4)
-#define CONTEXT_MATRIX(field) CONTEXT_FIELD(field, TYPE_MATRIX)
-#define CONTEXT_MATRIX_T(field) CONTEXT_FIELD(field, TYPE_MATRIX_T)
-
-#define ARRAY_INT(field) ARRAY_FIELD(field, TYPE_INT)
-#define ARRAY_ENUM(field) ARRAY_FIELD(field, TYPE_ENUM)
-#define ARRAY_BOOL(field) ARRAY_FIELD(field, TYPE_BOOLEAN)
-
-#define EXT(f) \
- offsetof(struct gl_extensions, f)
-
-#define EXTRA_EXT(e) \
- static const int extra_##e[] = { \
- EXT(e), EXTRA_END \
- }
-
-#define EXTRA_EXT2(e1, e2) \
- static const int extra_##e1##_##e2[] = { \
- EXT(e1), EXT(e2), EXTRA_END \
- }
-
-/* The 'extra' mechanism is a way to specify extra checks (such as
- * extensions or specific gl versions) or actions (flush current, new
- * buffers) that we need to do before looking up an enum. We need to
- * declare them all up front so we can refer to them in the value_desc
- * structs below. */
-
-static const int extra_new_buffers[] = {
- EXTRA_NEW_BUFFERS,
- EXTRA_END
-};
-
-static const int extra_valid_draw_buffer[] = {
- EXTRA_VALID_DRAW_BUFFER,
- EXTRA_END
-};
-
-static const int extra_valid_texture_unit[] = {
- EXTRA_VALID_TEXTURE_UNIT,
- EXTRA_END
-};
-
-static const int extra_flush_current_valid_texture_unit[] = {
- EXTRA_FLUSH_CURRENT,
- EXTRA_VALID_TEXTURE_UNIT,
- EXTRA_END
-};
-
-static const int extra_flush_current[] = {
- EXTRA_FLUSH_CURRENT,
- EXTRA_END
-};
-
-static const int extra_new_buffers_OES_read_format[] = {
- EXTRA_NEW_BUFFERS,
- EXT(OES_read_format),
- EXTRA_END
-};
-
-static const int extra_EXT_secondary_color_flush_current[] = {
- EXT(EXT_secondary_color),
- EXTRA_FLUSH_CURRENT,
- EXTRA_END
-};
-
-static const int extra_EXT_fog_coord_flush_current[] = {
- EXT(EXT_fog_coord),
- EXTRA_FLUSH_CURRENT,
- EXTRA_END
-};
-
-static const int extra_EXT_texture_integer[] = {
- EXT(EXT_texture_integer),
- EXTRA_END
-};
-
-static const int extra_EXT_gpu_shader4[] = {
- EXT(EXT_gpu_shader4),
- EXTRA_END
-};
-
-
-EXTRA_EXT(ARB_multitexture);
-EXTRA_EXT(ARB_texture_cube_map);
-EXTRA_EXT(MESA_texture_array);
-EXTRA_EXT2(EXT_secondary_color, ARB_vertex_program);
-EXTRA_EXT(EXT_secondary_color);
-EXTRA_EXT(EXT_fog_coord);
-EXTRA_EXT(EXT_texture_lod_bias);
-EXTRA_EXT(EXT_texture_filter_anisotropic);
-EXTRA_EXT(IBM_rasterpos_clip);
-EXTRA_EXT(NV_point_sprite);
-EXTRA_EXT(SGIS_generate_mipmap);
-EXTRA_EXT(NV_vertex_program);
-EXTRA_EXT(NV_fragment_program);
-EXTRA_EXT(NV_texture_rectangle);
-EXTRA_EXT(EXT_stencil_two_side);
-EXTRA_EXT(NV_light_max_exponent);
-EXTRA_EXT(SGI_texture_color_table);
-EXTRA_EXT(EXT_depth_bounds_test);
-EXTRA_EXT(ARB_depth_clamp);
-EXTRA_EXT(ATI_fragment_shader);
-EXTRA_EXT(EXT_framebuffer_blit);
-EXTRA_EXT(ARB_shader_objects);
-EXTRA_EXT(EXT_provoking_vertex);
-EXTRA_EXT(ARB_fragment_shader);
-EXTRA_EXT(ARB_fragment_program);
-EXTRA_EXT2(ARB_framebuffer_object, EXT_framebuffer_multisample);
-EXTRA_EXT(EXT_framebuffer_object);
-EXTRA_EXT(APPLE_vertex_array_object);
-EXTRA_EXT(ARB_seamless_cube_map);
-EXTRA_EXT(EXT_compiled_vertex_array);
-EXTRA_EXT(ARB_sync);
-EXTRA_EXT(ARB_vertex_shader);
-EXTRA_EXT(EXT_transform_feedback);
-EXTRA_EXT(ARB_transform_feedback2);
-EXTRA_EXT(EXT_pixel_buffer_object);
-EXTRA_EXT(ARB_vertex_program);
-EXTRA_EXT2(NV_point_sprite, ARB_point_sprite);
-EXTRA_EXT2(ARB_fragment_program, NV_fragment_program);
-EXTRA_EXT2(ARB_vertex_program, NV_vertex_program);
-EXTRA_EXT2(ARB_vertex_program, ARB_fragment_program);
-EXTRA_EXT(ARB_vertex_buffer_object);
-EXTRA_EXT(ARB_geometry_shader4);
-EXTRA_EXT(ARB_copy_buffer);
-
-static const int
-extra_ARB_vertex_program_ARB_fragment_program_NV_vertex_program[] = {
- EXT(ARB_vertex_program),
- EXT(ARB_fragment_program),
- EXT(NV_vertex_program),
- EXTRA_END
-};
-
-static const int
-extra_NV_vertex_program_ARB_vertex_program_ARB_fragment_program_NV_vertex_program[] = {
- EXT(NV_vertex_program),
- EXT(ARB_vertex_program),
- EXT(ARB_fragment_program),
- EXT(NV_vertex_program),
- EXTRA_END
-};
-
-static const int
-extra_NV_primitive_restart[] = {
- EXT(NV_primitive_restart),
- EXTRA_END
-};
-
-static const int extra_version_30[] = { EXTRA_VERSION_30, EXTRA_END };
-static const int extra_version_31[] = { EXTRA_VERSION_31, EXTRA_END };
-static const int extra_version_32[] = { EXTRA_VERSION_32, EXTRA_END };
-
-static const int
-extra_ARB_vertex_program_version_es2[] = {
- EXT(ARB_vertex_program),
- EXTRA_VERSION_ES2,
- EXTRA_END
-};
-
-#define API_OPENGL_BIT (1 << API_OPENGL)
-#define API_OPENGLES_BIT (1 << API_OPENGLES)
-#define API_OPENGLES2_BIT (1 << API_OPENGLES2)
-
-/* This is the big table describing all the enums we accept in
- * glGet*v(). The table is partitioned into six parts: enums
- * understood by all GL APIs (OpenGL, GLES and GLES2), enums shared
- * between OpenGL and GLES, enums exclusive to GLES, etc for the
- * remaining combinations. When we add the enums to the hash table in
- * _mesa_init_get_hash(), we only add the enums for the API we're
- * instantiating and the different sections are guarded by #if
- * FEATURE_GL etc to make sure we only compile in the enums we may
- * need. */
-
-static const struct value_desc values[] = {
- /* Enums shared between OpenGL, GLES1 and GLES2 */
- { 0, 0, TYPE_API_MASK,
- API_OPENGL_BIT | API_OPENGLES_BIT | API_OPENGLES2_BIT, NO_EXTRA},
- { GL_ALPHA_BITS, BUFFER_INT(Visual.alphaBits), extra_new_buffers },
- { GL_BLEND, CONTEXT_BIT0(Color.BlendEnabled), NO_EXTRA },
- { GL_BLEND_SRC, CONTEXT_ENUM(Color.BlendSrcRGB), NO_EXTRA },
- { GL_BLUE_BITS, BUFFER_INT(Visual.blueBits), extra_new_buffers },
- { GL_COLOR_CLEAR_VALUE, CONTEXT_FIELD(Color.ClearColor[0], TYPE_FLOATN_4), NO_EXTRA },
- { GL_COLOR_WRITEMASK, LOC_CUSTOM, TYPE_INT_4, 0, NO_EXTRA },
- { GL_CULL_FACE, CONTEXT_BOOL(Polygon.CullFlag), NO_EXTRA },
- { GL_CULL_FACE_MODE, CONTEXT_ENUM(Polygon.CullFaceMode), NO_EXTRA },
- { GL_DEPTH_BITS, BUFFER_INT(Visual.depthBits), NO_EXTRA },
- { GL_DEPTH_CLEAR_VALUE, CONTEXT_FIELD(Depth.Clear, TYPE_DOUBLEN), NO_EXTRA },
- { GL_DEPTH_FUNC, CONTEXT_ENUM(Depth.Func), NO_EXTRA },
- { GL_DEPTH_RANGE, CONTEXT_FIELD(Viewport.Near, TYPE_FLOATN_2), NO_EXTRA },
- { GL_DEPTH_TEST, CONTEXT_BOOL(Depth.Test), NO_EXTRA },
- { GL_DEPTH_WRITEMASK, CONTEXT_BOOL(Depth.Mask), NO_EXTRA },
- { GL_DITHER, CONTEXT_BOOL(Color.DitherFlag), NO_EXTRA },
- { GL_FRONT_FACE, CONTEXT_ENUM(Polygon.FrontFace), NO_EXTRA },
- { GL_GREEN_BITS, BUFFER_INT(Visual.greenBits), extra_new_buffers },
- { GL_LINE_WIDTH, CONTEXT_FLOAT(Line.Width), NO_EXTRA },
- { GL_ALIASED_LINE_WIDTH_RANGE, CONTEXT_FLOAT2(Const.MinLineWidth), NO_EXTRA },
- { GL_MAX_ELEMENTS_VERTICES, CONTEXT_INT(Const.MaxArrayLockSize), NO_EXTRA },
- { GL_MAX_ELEMENTS_INDICES, CONTEXT_INT(Const.MaxArrayLockSize), NO_EXTRA },
- { GL_MAX_TEXTURE_SIZE, LOC_CUSTOM, TYPE_INT,
- offsetof(struct gl_context, Const.MaxTextureLevels), NO_EXTRA },
- { GL_MAX_VIEWPORT_DIMS, CONTEXT_INT2(Const.MaxViewportWidth), NO_EXTRA },
- { GL_PACK_ALIGNMENT, CONTEXT_INT(Pack.Alignment), NO_EXTRA },
- { GL_ALIASED_POINT_SIZE_RANGE, CONTEXT_FLOAT2(Const.MinPointSize), NO_EXTRA },
- { GL_POLYGON_OFFSET_FACTOR, CONTEXT_FLOAT(Polygon.OffsetFactor ), NO_EXTRA },
- { GL_POLYGON_OFFSET_UNITS, CONTEXT_FLOAT(Polygon.OffsetUnits ), NO_EXTRA },
- { GL_POLYGON_OFFSET_FILL, CONTEXT_BOOL(Polygon.OffsetFill), NO_EXTRA },
- { GL_RED_BITS, BUFFER_INT(Visual.redBits), extra_new_buffers },
- { GL_SCISSOR_BOX, LOC_CUSTOM, TYPE_INT_4, 0, NO_EXTRA },
- { GL_SCISSOR_TEST, CONTEXT_BOOL(Scissor.Enabled), NO_EXTRA },
- { GL_STENCIL_BITS, BUFFER_INT(Visual.stencilBits), NO_EXTRA },
- { GL_STENCIL_CLEAR_VALUE, CONTEXT_INT(Stencil.Clear), NO_EXTRA },
- { GL_STENCIL_FAIL, LOC_CUSTOM, TYPE_ENUM, NO_OFFSET, NO_EXTRA },
- { GL_STENCIL_FUNC, LOC_CUSTOM, TYPE_ENUM, NO_OFFSET, NO_EXTRA },
- { GL_STENCIL_PASS_DEPTH_FAIL, LOC_CUSTOM, TYPE_ENUM, NO_OFFSET, NO_EXTRA },
- { GL_STENCIL_PASS_DEPTH_PASS, LOC_CUSTOM, TYPE_ENUM, NO_OFFSET, NO_EXTRA },
- { GL_STENCIL_REF, LOC_CUSTOM, TYPE_INT, NO_OFFSET, NO_EXTRA },
- { GL_STENCIL_TEST, CONTEXT_BOOL(Stencil.Enabled), NO_EXTRA },
- { GL_STENCIL_VALUE_MASK, LOC_CUSTOM, TYPE_INT, NO_OFFSET, NO_EXTRA },
- { GL_STENCIL_WRITEMASK, LOC_CUSTOM, TYPE_INT, NO_OFFSET, NO_EXTRA },
- { GL_SUBPIXEL_BITS, CONTEXT_INT(Const.SubPixelBits), NO_EXTRA },
- { GL_TEXTURE_BINDING_2D, LOC_CUSTOM, TYPE_INT, TEXTURE_2D_INDEX, NO_EXTRA },
- { GL_UNPACK_ALIGNMENT, CONTEXT_INT(Unpack.Alignment), NO_EXTRA },
- { GL_VIEWPORT, LOC_CUSTOM, TYPE_INT_4, 0, NO_EXTRA },
-
- /* GL_ARB_multitexture */
- { GL_ACTIVE_TEXTURE_ARB,
- LOC_CUSTOM, TYPE_INT, 0, extra_ARB_multitexture },
-
- /* Note that all the OES_* extensions require that the Mesa "struct
- * gl_extensions" include a member with the name of the extension.
- * That structure does not yet include OES extensions (and we're
- * not sure whether it will). If it does, all the OES_*
- * extensions below should mark the dependency. */
-
- /* GL_ARB_texture_cube_map */
- { GL_TEXTURE_BINDING_CUBE_MAP_ARB, LOC_CUSTOM, TYPE_INT,
- TEXTURE_CUBE_INDEX, extra_ARB_texture_cube_map },
- { GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB, LOC_CUSTOM, TYPE_INT,
- offsetof(struct gl_context, Const.MaxCubeTextureLevels),
- extra_ARB_texture_cube_map }, /* XXX: OES_texture_cube_map */
-
- /* XXX: OES_blend_subtract */
- { GL_BLEND_SRC_RGB_EXT, CONTEXT_ENUM(Color.BlendSrcRGB), NO_EXTRA },
- { GL_BLEND_DST_RGB_EXT, CONTEXT_ENUM(Color.BlendDstRGB), NO_EXTRA },
- { GL_BLEND_SRC_ALPHA_EXT, CONTEXT_ENUM(Color.BlendSrcA), NO_EXTRA },
- { GL_BLEND_DST_ALPHA_EXT, CONTEXT_ENUM(Color.BlendDstA), NO_EXTRA },
-
- /* GL_BLEND_EQUATION_RGB, which is what we're really after, is
- * defined identically to GL_BLEND_EQUATION. */
- { GL_BLEND_EQUATION, CONTEXT_ENUM(Color.BlendEquationRGB), NO_EXTRA },
- { GL_BLEND_EQUATION_ALPHA_EXT, CONTEXT_ENUM(Color.BlendEquationA), NO_EXTRA },
-
- /* GL_ARB_texture_compression */
- { GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB, LOC_CUSTOM, TYPE_INT, 0, NO_EXTRA },
- { GL_COMPRESSED_TEXTURE_FORMATS_ARB, LOC_CUSTOM, TYPE_INT_N, 0, NO_EXTRA },
-
- /* GL_ARB_multisample */
- { GL_SAMPLE_ALPHA_TO_COVERAGE_ARB,
- CONTEXT_BOOL(Multisample.SampleAlphaToCoverage), NO_EXTRA },
- { GL_SAMPLE_COVERAGE_ARB, CONTEXT_BOOL(Multisample.SampleCoverage), NO_EXTRA },
- { GL_SAMPLE_COVERAGE_VALUE_ARB,
- CONTEXT_FLOAT(Multisample.SampleCoverageValue), NO_EXTRA },
- { GL_SAMPLE_COVERAGE_INVERT_ARB,
- CONTEXT_BOOL(Multisample.SampleCoverageInvert), NO_EXTRA },
- { GL_SAMPLE_BUFFERS_ARB, BUFFER_INT(Visual.sampleBuffers), NO_EXTRA },
- { GL_SAMPLES_ARB, BUFFER_INT(Visual.samples), NO_EXTRA },
-
- /* GL_SGIS_generate_mipmap */
- { GL_GENERATE_MIPMAP_HINT_SGIS, CONTEXT_ENUM(Hint.GenerateMipmap),
- extra_SGIS_generate_mipmap },
-
- /* GL_ARB_vertex_buffer_object */
- { GL_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT, 0, NO_EXTRA },
-
- /* GL_ARB_vertex_buffer_object */
- /* GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB - not supported */
- { GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT, 0,
- extra_ARB_vertex_buffer_object },
-
- /* GL_ARB_copy_buffer */
- { GL_COPY_READ_BUFFER, LOC_CUSTOM, TYPE_INT, 0, extra_ARB_copy_buffer },
- { GL_COPY_WRITE_BUFFER, LOC_CUSTOM, TYPE_INT, 0, extra_ARB_copy_buffer },
-
- /* GL_OES_read_format */
- { GL_IMPLEMENTATION_COLOR_READ_TYPE_OES, LOC_CUSTOM, TYPE_INT, 0,
- extra_new_buffers_OES_read_format },
- { GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES, LOC_CUSTOM, TYPE_INT, 0,
- extra_new_buffers_OES_read_format },
-
- /* GL_EXT_framebuffer_object */
- { GL_FRAMEBUFFER_BINDING_EXT, BUFFER_INT(Name),
- extra_EXT_framebuffer_object },
- { GL_RENDERBUFFER_BINDING_EXT, LOC_CUSTOM, TYPE_INT, 0,
- extra_EXT_framebuffer_object },
- { GL_MAX_RENDERBUFFER_SIZE_EXT, CONTEXT_INT(Const.MaxRenderbufferSize),
- extra_EXT_framebuffer_object },
-
- /* This entry isn't spec'ed for GLES 2, but is needed for Mesa's
- * GLSL: */
- { GL_MAX_CLIP_PLANES, CONTEXT_INT(Const.MaxClipPlanes), NO_EXTRA },
-
-#if FEATURE_GL || FEATURE_ES1
- /* Enums in OpenGL and GLES1 */
- { 0, 0, TYPE_API_MASK, API_OPENGL_BIT | API_OPENGLES_BIT, NO_EXTRA },
- { GL_LIGHT0, CONTEXT_BOOL(Light.Light[0].Enabled), NO_EXTRA },
- { GL_LIGHT1, CONTEXT_BOOL(Light.Light[1].Enabled), NO_EXTRA },
- { GL_LIGHT2, CONTEXT_BOOL(Light.Light[2].Enabled), NO_EXTRA },
- { GL_LIGHT3, CONTEXT_BOOL(Light.Light[3].Enabled), NO_EXTRA },
- { GL_LIGHT4, CONTEXT_BOOL(Light.Light[4].Enabled), NO_EXTRA },
- { GL_LIGHT5, CONTEXT_BOOL(Light.Light[5].Enabled), NO_EXTRA },
- { GL_LIGHT6, CONTEXT_BOOL(Light.Light[6].Enabled), NO_EXTRA },
- { GL_LIGHT7, CONTEXT_BOOL(Light.Light[7].Enabled), NO_EXTRA },
- { GL_LIGHTING, CONTEXT_BOOL(Light.Enabled), NO_EXTRA },
- { GL_LIGHT_MODEL_AMBIENT,
- CONTEXT_FIELD(Light.Model.Ambient[0], TYPE_FLOATN_4), NO_EXTRA },
- { GL_LIGHT_MODEL_TWO_SIDE, CONTEXT_BOOL(Light.Model.TwoSide), NO_EXTRA },
- { GL_ALPHA_TEST, CONTEXT_BOOL(Color.AlphaEnabled), NO_EXTRA },
- { GL_ALPHA_TEST_FUNC, CONTEXT_ENUM(Color.AlphaFunc), NO_EXTRA },
- { GL_ALPHA_TEST_REF, CONTEXT_FIELD(Color.AlphaRef, TYPE_FLOATN), NO_EXTRA },
- { GL_BLEND_DST, CONTEXT_ENUM(Color.BlendDstRGB), NO_EXTRA },
- { GL_CLIP_PLANE0, CONTEXT_BIT0(Transform.ClipPlanesEnabled), NO_EXTRA },
- { GL_CLIP_PLANE1, CONTEXT_BIT1(Transform.ClipPlanesEnabled), NO_EXTRA },
- { GL_CLIP_PLANE2, CONTEXT_BIT2(Transform.ClipPlanesEnabled), NO_EXTRA },
- { GL_CLIP_PLANE3, CONTEXT_BIT3(Transform.ClipPlanesEnabled), NO_EXTRA },
- { GL_CLIP_PLANE4, CONTEXT_BIT4(Transform.ClipPlanesEnabled), NO_EXTRA },
- { GL_CLIP_PLANE5, CONTEXT_BIT5(Transform.ClipPlanesEnabled), NO_EXTRA },
- { GL_COLOR_MATERIAL, CONTEXT_BOOL(Light.ColorMaterialEnabled), NO_EXTRA },
- { GL_CURRENT_COLOR,
- CONTEXT_FIELD(Current.Attrib[VERT_ATTRIB_COLOR0][0], TYPE_FLOATN_4),
- extra_flush_current },
- { GL_CURRENT_NORMAL,
- CONTEXT_FIELD(Current.Attrib[VERT_ATTRIB_NORMAL][0], TYPE_FLOATN_3),
- extra_flush_current },
- { GL_CURRENT_TEXTURE_COORDS, LOC_CUSTOM, TYPE_FLOAT_4, 0,
- extra_flush_current_valid_texture_unit },
- { GL_DISTANCE_ATTENUATION_EXT, CONTEXT_FLOAT3(Point.Params[0]), NO_EXTRA },
- { GL_FOG, CONTEXT_BOOL(Fog.Enabled), NO_EXTRA },
- { GL_FOG_COLOR, CONTEXT_FIELD(Fog.Color[0], TYPE_FLOATN_4), NO_EXTRA },
- { GL_FOG_DENSITY, CONTEXT_FLOAT(Fog.Density), NO_EXTRA },
- { GL_FOG_END, CONTEXT_FLOAT(Fog.End), NO_EXTRA },
- { GL_FOG_HINT, CONTEXT_ENUM(Hint.Fog), NO_EXTRA },
- { GL_FOG_MODE, CONTEXT_ENUM(Fog.Mode), NO_EXTRA },
- { GL_FOG_START, CONTEXT_FLOAT(Fog.Start), NO_EXTRA },
- { GL_LINE_SMOOTH, CONTEXT_BOOL(Line.SmoothFlag), NO_EXTRA },
- { GL_LINE_SMOOTH_HINT, CONTEXT_ENUM(Hint.LineSmooth), NO_EXTRA },
- { GL_LINE_WIDTH_RANGE, CONTEXT_FLOAT2(Const.MinLineWidthAA), NO_EXTRA },
- { GL_COLOR_LOGIC_OP, CONTEXT_BOOL(Color.ColorLogicOpEnabled), NO_EXTRA },
- { GL_LOGIC_OP_MODE, CONTEXT_ENUM(Color.LogicOp), NO_EXTRA },
- { GL_MATRIX_MODE, CONTEXT_ENUM(Transform.MatrixMode), NO_EXTRA },
- { GL_MAX_MODELVIEW_STACK_DEPTH, CONST(MAX_MODELVIEW_STACK_DEPTH), NO_EXTRA },
- { GL_MAX_PROJECTION_STACK_DEPTH, CONST(MAX_PROJECTION_STACK_DEPTH), NO_EXTRA },
- { GL_MAX_TEXTURE_STACK_DEPTH, CONST(MAX_TEXTURE_STACK_DEPTH), NO_EXTRA },
- { GL_MODELVIEW_MATRIX, CONTEXT_MATRIX(ModelviewMatrixStack.Top), NO_EXTRA },
- { GL_MODELVIEW_STACK_DEPTH, LOC_CUSTOM, TYPE_INT,
- offsetof(struct gl_context, ModelviewMatrixStack.Depth), NO_EXTRA },
- { GL_NORMALIZE, CONTEXT_BOOL(Transform.Normalize), NO_EXTRA },
- { GL_PACK_SKIP_IMAGES_EXT, CONTEXT_INT(Pack.SkipImages), NO_EXTRA },
- { GL_PERSPECTIVE_CORRECTION_HINT, CONTEXT_ENUM(Hint.PerspectiveCorrection), NO_EXTRA },
- { GL_POINT_SIZE, CONTEXT_FLOAT(Point.Size), NO_EXTRA },
- { GL_POINT_SIZE_RANGE, CONTEXT_FLOAT2(Const.MinPointSizeAA), NO_EXTRA },
- { GL_POINT_SMOOTH, CONTEXT_BOOL(Point.SmoothFlag), NO_EXTRA },
- { GL_POINT_SMOOTH_HINT, CONTEXT_ENUM(Hint.PointSmooth), NO_EXTRA },
- { GL_POINT_SIZE_MIN_EXT, CONTEXT_FLOAT(Point.MinSize), NO_EXTRA },
- { GL_POINT_SIZE_MAX_EXT, CONTEXT_FLOAT(Point.MaxSize), NO_EXTRA },
- { GL_POINT_FADE_THRESHOLD_SIZE_EXT, CONTEXT_FLOAT(Point.Threshold), NO_EXTRA },
- { GL_PROJECTION_MATRIX, CONTEXT_MATRIX(ProjectionMatrixStack.Top), NO_EXTRA },
- { GL_PROJECTION_STACK_DEPTH, LOC_CUSTOM, TYPE_INT,
- offsetof(struct gl_context, ProjectionMatrixStack.Depth), NO_EXTRA },
- { GL_RESCALE_NORMAL, CONTEXT_BOOL(Transform.RescaleNormals), NO_EXTRA },
- { GL_SHADE_MODEL, CONTEXT_ENUM(Light.ShadeModel), NO_EXTRA },
- { GL_TEXTURE_2D, LOC_CUSTOM, TYPE_BOOLEAN, 0, NO_EXTRA },
- { GL_TEXTURE_MATRIX, LOC_CUSTOM, TYPE_MATRIX, 0, extra_valid_texture_unit },
- { GL_TEXTURE_STACK_DEPTH, LOC_CUSTOM, TYPE_INT, 0,
- extra_valid_texture_unit },
-
- { GL_VERTEX_ARRAY, ARRAY_BOOL(Vertex.Enabled), NO_EXTRA },
- { GL_VERTEX_ARRAY_SIZE, ARRAY_INT(Vertex.Size), NO_EXTRA },
- { GL_VERTEX_ARRAY_TYPE, ARRAY_ENUM(Vertex.Type), NO_EXTRA },
- { GL_VERTEX_ARRAY_STRIDE, ARRAY_INT(Vertex.Stride), NO_EXTRA },
- { GL_NORMAL_ARRAY, ARRAY_ENUM(Normal.Enabled), NO_EXTRA },
- { GL_NORMAL_ARRAY_TYPE, ARRAY_ENUM(Normal.Type), NO_EXTRA },
- { GL_NORMAL_ARRAY_STRIDE, ARRAY_INT(Normal.Stride), NO_EXTRA },
- { GL_COLOR_ARRAY, ARRAY_BOOL(Color.Enabled), NO_EXTRA },
- { GL_COLOR_ARRAY_SIZE, ARRAY_INT(Color.Size), NO_EXTRA },
- { GL_COLOR_ARRAY_TYPE, ARRAY_ENUM(Color.Type), NO_EXTRA },
- { GL_COLOR_ARRAY_STRIDE, ARRAY_INT(Color.Stride), NO_EXTRA },
- { GL_TEXTURE_COORD_ARRAY,
- LOC_CUSTOM, TYPE_BOOLEAN, offsetof(struct gl_client_array, Enabled), NO_EXTRA },
- { GL_TEXTURE_COORD_ARRAY_SIZE,
- LOC_CUSTOM, TYPE_BOOLEAN, offsetof(struct gl_client_array, Size), NO_EXTRA },
- { GL_TEXTURE_COORD_ARRAY_TYPE,
- LOC_CUSTOM, TYPE_BOOLEAN, offsetof(struct gl_client_array, Type), NO_EXTRA },
- { GL_TEXTURE_COORD_ARRAY_STRIDE,
- LOC_CUSTOM, TYPE_BOOLEAN, offsetof(struct gl_client_array, Stride), NO_EXTRA },
-
- /* GL_ARB_multitexture */
- { GL_MAX_TEXTURE_UNITS_ARB,
- CONTEXT_INT(Const.MaxTextureUnits), extra_ARB_multitexture },
- { GL_CLIENT_ACTIVE_TEXTURE_ARB,
- LOC_CUSTOM, TYPE_INT, 0, extra_ARB_multitexture },
-
- /* GL_ARB_texture_cube_map */
- { GL_TEXTURE_CUBE_MAP_ARB, LOC_CUSTOM, TYPE_BOOLEAN, 0, NO_EXTRA },
- /* S, T, and R are always set at the same time */
- { GL_TEXTURE_GEN_STR_OES, LOC_TEXUNIT, TYPE_BIT_0,
- offsetof(struct gl_texture_unit, TexGenEnabled), NO_EXTRA },
-
- /* GL_ARB_multisample */
- { GL_MULTISAMPLE_ARB, CONTEXT_BOOL(Multisample.Enabled), NO_EXTRA },
- { GL_SAMPLE_ALPHA_TO_ONE_ARB, CONTEXT_BOOL(Multisample.SampleAlphaToOne), NO_EXTRA },
-
- /* GL_ARB_vertex_buffer_object */
- { GL_VERTEX_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT,
- offsetof(struct gl_array_object, Vertex.BufferObj), NO_EXTRA },
- { GL_NORMAL_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT,
- offsetof(struct gl_array_object, Normal.BufferObj), NO_EXTRA },
- { GL_COLOR_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT,
- offsetof(struct gl_array_object, Color.BufferObj), NO_EXTRA },
- { GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT, NO_OFFSET, NO_EXTRA },
-
- /* GL_OES_point_sprite */
- { GL_POINT_SPRITE_NV,
- CONTEXT_BOOL(Point.PointSprite),
- extra_NV_point_sprite_ARB_point_sprite },
-
- /* GL_ARB_fragment_shader */
- { GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB,
- CONTEXT_INT(Const.FragmentProgram.MaxUniformComponents),
- extra_ARB_fragment_shader },
-
- /* GL_ARB_vertex_shader */
- { GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB,
- CONTEXT_INT(Const.VertexProgram.MaxUniformComponents),
- extra_ARB_vertex_shader },
- { GL_MAX_VARYING_FLOATS_ARB, LOC_CUSTOM, TYPE_INT, 0,
- extra_ARB_vertex_shader },
-
- /* GL_EXT_texture_lod_bias */
- { GL_MAX_TEXTURE_LOD_BIAS_EXT, CONTEXT_FLOAT(Const.MaxTextureLodBias),
- extra_EXT_texture_lod_bias },
-
- /* GL_EXT_texture_filter_anisotropic */
- { GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT,
- CONTEXT_FLOAT(Const.MaxTextureMaxAnisotropy),
- extra_EXT_texture_filter_anisotropic },
-#endif /* FEATURE_GL || FEATURE_ES1 */
-
-#if FEATURE_ES1
- { 0, 0, TYPE_API_MASK, API_OPENGLES_BIT },
- /* XXX: OES_matrix_get */
- { GL_MODELVIEW_MATRIX_FLOAT_AS_INT_BITS_OES },
- { GL_PROJECTION_MATRIX_FLOAT_AS_INT_BITS_OES },
- { GL_TEXTURE_MATRIX_FLOAT_AS_INT_BITS_OES },
-
- /* OES_point_size_array */
- { GL_POINT_SIZE_ARRAY_OES, ARRAY_FIELD(PointSize.Enabled, TYPE_BOOLEAN) },
- { GL_POINT_SIZE_ARRAY_TYPE_OES, ARRAY_FIELD(PointSize.Type, TYPE_ENUM) },
- { GL_POINT_SIZE_ARRAY_STRIDE_OES, ARRAY_FIELD(PointSize.Stride, TYPE_INT) },
- { GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES, LOC_CUSTOM, TYPE_INT, 0 },
-#endif /* FEATURE_ES1 */
-
-#if FEATURE_GL || FEATURE_ES2
- { 0, 0, TYPE_API_MASK, API_OPENGL_BIT | API_OPENGLES2_BIT, NO_EXTRA },
- /* This entry isn't spec'ed for GLES 2, but is needed for Mesa's GLSL: */
- { GL_MAX_LIGHTS, CONTEXT_INT(Const.MaxLights), NO_EXTRA },
- { GL_MAX_TEXTURE_COORDS_ARB, /* == GL_MAX_TEXTURE_COORDS_NV */
- CONTEXT_INT(Const.MaxTextureCoordUnits),
- extra_ARB_fragment_program_NV_fragment_program },
-
- /* GL_ARB_draw_buffers */
- { GL_MAX_DRAW_BUFFERS_ARB, CONTEXT_INT(Const.MaxDrawBuffers), NO_EXTRA },
-
- { GL_BLEND_COLOR_EXT, CONTEXT_FIELD(Color.BlendColor[0], TYPE_FLOATN_4), NO_EXTRA },
- /* GL_ARB_fragment_program */
- { GL_MAX_TEXTURE_IMAGE_UNITS_ARB, /* == GL_MAX_TEXTURE_IMAGE_UNITS_NV */
- CONTEXT_INT(Const.MaxTextureImageUnits),
- extra_ARB_fragment_program_NV_fragment_program },
- { GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB,
- CONTEXT_INT(Const.MaxVertexTextureImageUnits), extra_ARB_vertex_shader },
- { GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB,
- CONTEXT_INT(Const.MaxCombinedTextureImageUnits),
- extra_ARB_vertex_shader },
-
- /* GL_ARB_shader_objects
- * Actually, this token isn't part of GL_ARB_shader_objects, but is
- * close enough for now. */
- { GL_CURRENT_PROGRAM, LOC_CUSTOM, TYPE_INT, 0, extra_ARB_shader_objects },
-
- /* OpenGL 2.0 */
- { GL_STENCIL_BACK_FUNC, CONTEXT_ENUM(Stencil.Function[1]), NO_EXTRA },
- { GL_STENCIL_BACK_VALUE_MASK, CONTEXT_INT(Stencil.ValueMask[1]), NO_EXTRA },
- { GL_STENCIL_BACK_WRITEMASK, CONTEXT_INT(Stencil.WriteMask[1]), NO_EXTRA },
- { GL_STENCIL_BACK_REF, CONTEXT_INT(Stencil.Ref[1]), NO_EXTRA },
- { GL_STENCIL_BACK_FAIL, CONTEXT_ENUM(Stencil.FailFunc[1]), NO_EXTRA },
- { GL_STENCIL_BACK_PASS_DEPTH_FAIL, CONTEXT_ENUM(Stencil.ZFailFunc[1]), NO_EXTRA },
- { GL_STENCIL_BACK_PASS_DEPTH_PASS, CONTEXT_ENUM(Stencil.ZPassFunc[1]), NO_EXTRA },
-
- { GL_MAX_VERTEX_ATTRIBS_ARB,
- CONTEXT_INT(Const.VertexProgram.MaxAttribs),
- extra_ARB_vertex_program_version_es2 },
-
- /* OES_texture_3D */
- { GL_TEXTURE_BINDING_3D, LOC_CUSTOM, TYPE_INT, TEXTURE_3D_INDEX, NO_EXTRA },
- { GL_MAX_3D_TEXTURE_SIZE, LOC_CUSTOM, TYPE_INT,
- offsetof(struct gl_context, Const.Max3DTextureLevels), NO_EXTRA },
-
- /* GL_ARB_fragment_program/OES_standard_derivatives */
- { GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB,
- CONTEXT_ENUM(Hint.FragmentShaderDerivative), extra_ARB_fragment_shader },
-#endif /* FEATURE_GL || FEATURE_ES2 */
-
-#if FEATURE_ES2
- /* Enums unique to OpenGL ES 2.0 */
- { 0, 0, TYPE_API_MASK, API_OPENGLES2_BIT, NO_EXTRA },
- { GL_MAX_FRAGMENT_UNIFORM_VECTORS, LOC_CUSTOM, TYPE_INT, 0, NO_EXTRA },
- { GL_MAX_VARYING_VECTORS, CONTEXT_INT(Const.MaxVarying), NO_EXTRA },
- { GL_MAX_VERTEX_UNIFORM_VECTORS, LOC_CUSTOM, TYPE_INT, 0, NO_EXTRA },
- { GL_SHADER_COMPILER, CONST(1), NO_EXTRA },
- /* OES_get_program_binary */
- { GL_NUM_SHADER_BINARY_FORMATS, CONST(0), NO_EXTRA },
- { GL_SHADER_BINARY_FORMATS, CONST(0), NO_EXTRA },
-#endif /* FEATURE_ES2 */
-
-#if FEATURE_GL
- /* Remaining enums are only in OpenGL */
- { 0, 0, TYPE_API_MASK, API_OPENGL_BIT, NO_EXTRA },
- { GL_ACCUM_RED_BITS, BUFFER_INT(Visual.accumRedBits), NO_EXTRA },
- { GL_ACCUM_GREEN_BITS, BUFFER_INT(Visual.accumGreenBits), NO_EXTRA },
- { GL_ACCUM_BLUE_BITS, BUFFER_INT(Visual.accumBlueBits), NO_EXTRA },
- { GL_ACCUM_ALPHA_BITS, BUFFER_INT(Visual.accumAlphaBits), NO_EXTRA },
- { GL_ACCUM_CLEAR_VALUE, CONTEXT_FIELD(Accum.ClearColor[0], TYPE_FLOATN_4), NO_EXTRA },
- { GL_ALPHA_BIAS, CONTEXT_FLOAT(Pixel.AlphaBias), NO_EXTRA },
- { GL_ALPHA_SCALE, CONTEXT_FLOAT(Pixel.AlphaScale), NO_EXTRA },
- { GL_ATTRIB_STACK_DEPTH, CONTEXT_INT(AttribStackDepth), NO_EXTRA },
- { GL_AUTO_NORMAL, CONTEXT_BOOL(Eval.AutoNormal), NO_EXTRA },
- { GL_AUX_BUFFERS, BUFFER_INT(Visual.numAuxBuffers), NO_EXTRA },
- { GL_BLUE_BIAS, CONTEXT_FLOAT(Pixel.BlueBias), NO_EXTRA },
- { GL_BLUE_SCALE, CONTEXT_FLOAT(Pixel.BlueScale), NO_EXTRA },
- { GL_CLIENT_ATTRIB_STACK_DEPTH, CONTEXT_INT(ClientAttribStackDepth), NO_EXTRA },
- { GL_COLOR_MATERIAL_FACE, CONTEXT_ENUM(Light.ColorMaterialFace), NO_EXTRA },
- { GL_COLOR_MATERIAL_PARAMETER, CONTEXT_ENUM(Light.ColorMaterialMode), NO_EXTRA },
- { GL_CURRENT_INDEX,
- CONTEXT_FLOAT(Current.Attrib[VERT_ATTRIB_COLOR_INDEX][0]),
- extra_flush_current },
- { GL_CURRENT_RASTER_COLOR,
- CONTEXT_FIELD(Current.RasterColor[0], TYPE_FLOATN_4), NO_EXTRA },
- { GL_CURRENT_RASTER_DISTANCE, CONTEXT_FLOAT(Current.RasterDistance), NO_EXTRA },
- { GL_CURRENT_RASTER_INDEX, CONST(1), NO_EXTRA },
- { GL_CURRENT_RASTER_POSITION, CONTEXT_FLOAT4(Current.RasterPos[0]), NO_EXTRA },
- { GL_CURRENT_RASTER_SECONDARY_COLOR,
- CONTEXT_FIELD(Current.RasterSecondaryColor[0], TYPE_FLOATN_4), NO_EXTRA },
- { GL_CURRENT_RASTER_TEXTURE_COORDS, LOC_CUSTOM, TYPE_FLOAT_4, 0,
- extra_valid_texture_unit },
- { GL_CURRENT_RASTER_POSITION_VALID, CONTEXT_BOOL(Current.RasterPosValid), NO_EXTRA },
- { GL_DEPTH_BIAS, CONTEXT_FLOAT(Pixel.DepthBias), NO_EXTRA },
- { GL_DEPTH_SCALE, CONTEXT_FLOAT(Pixel.DepthScale), NO_EXTRA },
- { GL_DOUBLEBUFFER, BUFFER_INT(Visual.doubleBufferMode), NO_EXTRA },
- { GL_DRAW_BUFFER, BUFFER_ENUM(ColorDrawBuffer[0]), NO_EXTRA },
- { GL_EDGE_FLAG, LOC_CUSTOM, TYPE_BOOLEAN, 0, NO_EXTRA },
- { GL_FEEDBACK_BUFFER_SIZE, CONTEXT_INT(Feedback.BufferSize), NO_EXTRA },
- { GL_FEEDBACK_BUFFER_TYPE, CONTEXT_ENUM(Feedback.Type), NO_EXTRA },
- { GL_FOG_INDEX, CONTEXT_FLOAT(Fog.Index), NO_EXTRA },
- { GL_GREEN_BIAS, CONTEXT_FLOAT(Pixel.GreenBias), NO_EXTRA },
- { GL_GREEN_SCALE, CONTEXT_FLOAT(Pixel.GreenScale), NO_EXTRA },
- { GL_INDEX_BITS, BUFFER_INT(Visual.indexBits), extra_new_buffers },
- { GL_INDEX_CLEAR_VALUE, CONTEXT_INT(Color.ClearIndex), NO_EXTRA },
- { GL_INDEX_MODE, CONST(0) , NO_EXTRA},
- { GL_INDEX_OFFSET, CONTEXT_INT(Pixel.IndexOffset), NO_EXTRA },
- { GL_INDEX_SHIFT, CONTEXT_INT(Pixel.IndexShift), NO_EXTRA },
- { GL_INDEX_WRITEMASK, CONTEXT_INT(Color.IndexMask), NO_EXTRA },
- { GL_LIGHT_MODEL_COLOR_CONTROL, CONTEXT_ENUM(Light.Model.ColorControl), NO_EXTRA },
- { GL_LIGHT_MODEL_LOCAL_VIEWER, CONTEXT_BOOL(Light.Model.LocalViewer), NO_EXTRA },
- { GL_LINE_STIPPLE, CONTEXT_BOOL(Line.StippleFlag), NO_EXTRA },
- { GL_LINE_STIPPLE_PATTERN, LOC_CUSTOM, TYPE_INT, 0, NO_EXTRA },
- { GL_LINE_STIPPLE_REPEAT, CONTEXT_INT(Line.StippleFactor), NO_EXTRA },
- { GL_LINE_WIDTH_GRANULARITY, CONTEXT_FLOAT(Const.LineWidthGranularity), NO_EXTRA },
- { GL_LIST_BASE, CONTEXT_INT(List.ListBase), NO_EXTRA },
- { GL_LIST_INDEX, LOC_CUSTOM, TYPE_INT, 0, NO_EXTRA },
- { GL_LIST_MODE, LOC_CUSTOM, TYPE_ENUM, 0, NO_EXTRA },
- { GL_INDEX_LOGIC_OP, CONTEXT_BOOL(Color.IndexLogicOpEnabled), NO_EXTRA },
- { GL_MAP1_COLOR_4, CONTEXT_BOOL(Eval.Map1Color4), NO_EXTRA },
- { GL_MAP1_GRID_DOMAIN, CONTEXT_FLOAT2(Eval.MapGrid1u1), NO_EXTRA },
- { GL_MAP1_GRID_SEGMENTS, CONTEXT_INT(Eval.MapGrid1un), NO_EXTRA },
- { GL_MAP1_INDEX, CONTEXT_BOOL(Eval.Map1Index), NO_EXTRA },
- { GL_MAP1_NORMAL, CONTEXT_BOOL(Eval.Map1Normal), NO_EXTRA },
- { GL_MAP1_TEXTURE_COORD_1, CONTEXT_BOOL(Eval.Map1TextureCoord1), NO_EXTRA },
- { GL_MAP1_TEXTURE_COORD_2, CONTEXT_BOOL(Eval.Map1TextureCoord2), NO_EXTRA },
- { GL_MAP1_TEXTURE_COORD_3, CONTEXT_BOOL(Eval.Map1TextureCoord3), NO_EXTRA },
- { GL_MAP1_TEXTURE_COORD_4, CONTEXT_BOOL(Eval.Map1TextureCoord4), NO_EXTRA },
- { GL_MAP1_VERTEX_3, CONTEXT_BOOL(Eval.Map1Vertex3), NO_EXTRA },
- { GL_MAP1_VERTEX_4, CONTEXT_BOOL(Eval.Map1Vertex4), NO_EXTRA },
- { GL_MAP2_COLOR_4, CONTEXT_BOOL(Eval.Map2Color4), NO_EXTRA },
- { GL_MAP2_GRID_DOMAIN, LOC_CUSTOM, TYPE_FLOAT_4, 0, NO_EXTRA },
- { GL_MAP2_GRID_SEGMENTS, CONTEXT_INT2(Eval.MapGrid2un), NO_EXTRA },
- { GL_MAP2_INDEX, CONTEXT_BOOL(Eval.Map2Index), NO_EXTRA },
- { GL_MAP2_NORMAL, CONTEXT_BOOL(Eval.Map2Normal), NO_EXTRA },
- { GL_MAP2_TEXTURE_COORD_1, CONTEXT_BOOL(Eval.Map2TextureCoord1), NO_EXTRA },
- { GL_MAP2_TEXTURE_COORD_2, CONTEXT_BOOL(Eval.Map2TextureCoord2), NO_EXTRA },
- { GL_MAP2_TEXTURE_COORD_3, CONTEXT_BOOL(Eval.Map2TextureCoord3), NO_EXTRA },
- { GL_MAP2_TEXTURE_COORD_4, CONTEXT_BOOL(Eval.Map2TextureCoord4), NO_EXTRA },
- { GL_MAP2_VERTEX_3, CONTEXT_BOOL(Eval.Map2Vertex3), NO_EXTRA },
- { GL_MAP2_VERTEX_4, CONTEXT_BOOL(Eval.Map2Vertex4), NO_EXTRA },
- { GL_MAP_COLOR, CONTEXT_BOOL(Pixel.MapColorFlag), NO_EXTRA },
- { GL_MAP_STENCIL, CONTEXT_BOOL(Pixel.MapStencilFlag), NO_EXTRA },
- { GL_MAX_ATTRIB_STACK_DEPTH, CONST(MAX_ATTRIB_STACK_DEPTH), NO_EXTRA },
- { GL_MAX_CLIENT_ATTRIB_STACK_DEPTH, CONST(MAX_CLIENT_ATTRIB_STACK_DEPTH), NO_EXTRA },
-
- { GL_MAX_EVAL_ORDER, CONST(MAX_EVAL_ORDER), NO_EXTRA },
- { GL_MAX_LIST_NESTING, CONST(MAX_LIST_NESTING), NO_EXTRA },
- { GL_MAX_NAME_STACK_DEPTH, CONST(MAX_NAME_STACK_DEPTH), NO_EXTRA },
- { GL_MAX_PIXEL_MAP_TABLE, CONST(MAX_PIXEL_MAP_TABLE), NO_EXTRA },
- { GL_NAME_STACK_DEPTH, CONTEXT_INT(Select.NameStackDepth), NO_EXTRA },
- { GL_PACK_LSB_FIRST, CONTEXT_BOOL(Pack.LsbFirst), NO_EXTRA },
- { GL_PACK_ROW_LENGTH, CONTEXT_INT(Pack.RowLength), NO_EXTRA },
- { GL_PACK_SKIP_PIXELS, CONTEXT_INT(Pack.SkipPixels), NO_EXTRA },
- { GL_PACK_SKIP_ROWS, CONTEXT_INT(Pack.SkipRows), NO_EXTRA },
- { GL_PACK_SWAP_BYTES, CONTEXT_BOOL(Pack.SwapBytes), NO_EXTRA },
- { GL_PACK_IMAGE_HEIGHT_EXT, CONTEXT_INT(Pack.ImageHeight), NO_EXTRA },
- { GL_PACK_INVERT_MESA, CONTEXT_BOOL(Pack.Invert), NO_EXTRA },
- { GL_PIXEL_MAP_A_TO_A_SIZE, CONTEXT_INT(PixelMaps.AtoA.Size), NO_EXTRA },
- { GL_PIXEL_MAP_B_TO_B_SIZE, CONTEXT_INT(PixelMaps.BtoB.Size), NO_EXTRA },
- { GL_PIXEL_MAP_G_TO_G_SIZE, CONTEXT_INT(PixelMaps.GtoG.Size), NO_EXTRA },
- { GL_PIXEL_MAP_I_TO_A_SIZE, CONTEXT_INT(PixelMaps.ItoA.Size), NO_EXTRA },
- { GL_PIXEL_MAP_I_TO_B_SIZE, CONTEXT_INT(PixelMaps.ItoB.Size), NO_EXTRA },
- { GL_PIXEL_MAP_I_TO_G_SIZE, CONTEXT_INT(PixelMaps.ItoG.Size), NO_EXTRA },
- { GL_PIXEL_MAP_I_TO_I_SIZE, CONTEXT_INT(PixelMaps.ItoI.Size), NO_EXTRA },
- { GL_PIXEL_MAP_I_TO_R_SIZE, CONTEXT_INT(PixelMaps.ItoR.Size), NO_EXTRA },
- { GL_PIXEL_MAP_R_TO_R_SIZE, CONTEXT_INT(PixelMaps.RtoR.Size), NO_EXTRA },
- { GL_PIXEL_MAP_S_TO_S_SIZE, CONTEXT_INT(PixelMaps.StoS.Size), NO_EXTRA },
- { GL_POINT_SIZE_GRANULARITY, CONTEXT_FLOAT(Const.PointSizeGranularity), NO_EXTRA },
- { GL_POLYGON_MODE, CONTEXT_ENUM2(Polygon.FrontMode), NO_EXTRA },
- { GL_POLYGON_OFFSET_BIAS_EXT, CONTEXT_FLOAT(Polygon.OffsetUnits), NO_EXTRA },
- { GL_POLYGON_OFFSET_POINT, CONTEXT_BOOL(Polygon.OffsetPoint), NO_EXTRA },
- { GL_POLYGON_OFFSET_LINE, CONTEXT_BOOL(Polygon.OffsetLine), NO_EXTRA },
- { GL_POLYGON_SMOOTH, CONTEXT_BOOL(Polygon.SmoothFlag), NO_EXTRA },
- { GL_POLYGON_SMOOTH_HINT, CONTEXT_ENUM(Hint.PolygonSmooth), NO_EXTRA },
- { GL_POLYGON_STIPPLE, CONTEXT_BOOL(Polygon.StippleFlag), NO_EXTRA },
- { GL_READ_BUFFER, LOC_CUSTOM, TYPE_ENUM, NO_OFFSET, NO_EXTRA },
- { GL_RED_BIAS, CONTEXT_FLOAT(Pixel.RedBias), NO_EXTRA },
- { GL_RED_SCALE, CONTEXT_FLOAT(Pixel.RedScale), NO_EXTRA },
- { GL_RENDER_MODE, CONTEXT_ENUM(RenderMode), NO_EXTRA },
- { GL_RGBA_MODE, CONST(1), NO_EXTRA },
- { GL_SELECTION_BUFFER_SIZE, CONTEXT_INT(Select.BufferSize), NO_EXTRA },
- { GL_SHARED_TEXTURE_PALETTE_EXT, CONTEXT_BOOL(Texture.SharedPalette), NO_EXTRA },
-
- { GL_STEREO, BUFFER_INT(Visual.stereoMode), NO_EXTRA },
-
- { GL_TEXTURE_1D, LOC_CUSTOM, TYPE_BOOLEAN, NO_OFFSET, NO_EXTRA },
- { GL_TEXTURE_3D, LOC_CUSTOM, TYPE_BOOLEAN, NO_OFFSET, NO_EXTRA },
- { GL_TEXTURE_1D_ARRAY_EXT, LOC_CUSTOM, TYPE_BOOLEAN, NO_OFFSET, NO_EXTRA },
- { GL_TEXTURE_2D_ARRAY_EXT, LOC_CUSTOM, TYPE_BOOLEAN, NO_OFFSET, NO_EXTRA },
-
- { GL_TEXTURE_BINDING_1D, LOC_CUSTOM, TYPE_INT, TEXTURE_1D_INDEX, NO_EXTRA },
- { GL_TEXTURE_BINDING_1D_ARRAY, LOC_CUSTOM, TYPE_INT,
- TEXTURE_1D_ARRAY_INDEX, extra_MESA_texture_array },
- { GL_TEXTURE_BINDING_2D_ARRAY, LOC_CUSTOM, TYPE_INT,
- TEXTURE_1D_ARRAY_INDEX, extra_MESA_texture_array },
- { GL_MAX_ARRAY_TEXTURE_LAYERS_EXT,
- CONTEXT_INT(Const.MaxArrayTextureLayers), extra_MESA_texture_array },
-
- { GL_TEXTURE_GEN_S, LOC_TEXUNIT, TYPE_BIT_0,
- offsetof(struct gl_texture_unit, TexGenEnabled), NO_EXTRA },
- { GL_TEXTURE_GEN_T, LOC_TEXUNIT, TYPE_BIT_1,
- offsetof(struct gl_texture_unit, TexGenEnabled), NO_EXTRA },
- { GL_TEXTURE_GEN_R, LOC_TEXUNIT, TYPE_BIT_2,
- offsetof(struct gl_texture_unit, TexGenEnabled), NO_EXTRA },
- { GL_TEXTURE_GEN_Q, LOC_TEXUNIT, TYPE_BIT_3,
- offsetof(struct gl_texture_unit, TexGenEnabled), NO_EXTRA },
- { GL_UNPACK_LSB_FIRST, CONTEXT_BOOL(Unpack.LsbFirst), NO_EXTRA },
- { GL_UNPACK_ROW_LENGTH, CONTEXT_INT(Unpack.RowLength), NO_EXTRA },
- { GL_UNPACK_SKIP_PIXELS, CONTEXT_INT(Unpack.SkipPixels), NO_EXTRA },
- { GL_UNPACK_SKIP_ROWS, CONTEXT_INT(Unpack.SkipRows), NO_EXTRA },
- { GL_UNPACK_SWAP_BYTES, CONTEXT_BOOL(Unpack.SwapBytes), NO_EXTRA },
- { GL_UNPACK_SKIP_IMAGES_EXT, CONTEXT_INT(Unpack.SkipImages), NO_EXTRA },
- { GL_UNPACK_IMAGE_HEIGHT_EXT, CONTEXT_INT(Unpack.ImageHeight), NO_EXTRA },
- { GL_UNPACK_CLIENT_STORAGE_APPLE, CONTEXT_BOOL(Unpack.ClientStorage), NO_EXTRA },
- { GL_ZOOM_X, CONTEXT_FLOAT(Pixel.ZoomX), NO_EXTRA },
- { GL_ZOOM_Y, CONTEXT_FLOAT(Pixel.ZoomY), NO_EXTRA },
-
- /* Vertex arrays */
- { GL_VERTEX_ARRAY_COUNT_EXT, CONST(0), NO_EXTRA },
- { GL_NORMAL_ARRAY_COUNT_EXT, CONST(0), NO_EXTRA },
- { GL_COLOR_ARRAY_COUNT_EXT, CONST(0), NO_EXTRA },
- { GL_INDEX_ARRAY, ARRAY_BOOL(Index.Enabled), NO_EXTRA },
- { GL_INDEX_ARRAY_TYPE, ARRAY_ENUM(Index.Type), NO_EXTRA },
- { GL_INDEX_ARRAY_STRIDE, ARRAY_INT(Index.Stride), NO_EXTRA },
- { GL_INDEX_ARRAY_COUNT_EXT, CONST(0), NO_EXTRA },
- { GL_TEXTURE_COORD_ARRAY_COUNT_EXT, CONST(0), NO_EXTRA },
- { GL_EDGE_FLAG_ARRAY, ARRAY_BOOL(EdgeFlag.Enabled), NO_EXTRA },
- { GL_EDGE_FLAG_ARRAY_STRIDE, ARRAY_INT(EdgeFlag.Stride), NO_EXTRA },
- { GL_EDGE_FLAG_ARRAY_COUNT_EXT, CONST(0), NO_EXTRA },
-
- /* GL_ARB_texture_compression */
- { GL_TEXTURE_COMPRESSION_HINT_ARB, CONTEXT_INT(Hint.TextureCompression), NO_EXTRA },
-
- /* GL_EXT_compiled_vertex_array */
- { GL_ARRAY_ELEMENT_LOCK_FIRST_EXT, CONTEXT_INT(Array.LockFirst),
- extra_EXT_compiled_vertex_array },
- { GL_ARRAY_ELEMENT_LOCK_COUNT_EXT, CONTEXT_INT(Array.LockCount),
- extra_EXT_compiled_vertex_array },
-
- /* GL_ARB_transpose_matrix */
- { GL_TRANSPOSE_MODELVIEW_MATRIX_ARB,
- CONTEXT_MATRIX_T(ModelviewMatrixStack), NO_EXTRA },
- { GL_TRANSPOSE_PROJECTION_MATRIX_ARB,
- CONTEXT_MATRIX_T(ProjectionMatrixStack.Top), NO_EXTRA },
- { GL_TRANSPOSE_TEXTURE_MATRIX_ARB, CONTEXT_MATRIX_T(TextureMatrixStack), NO_EXTRA },
-
- /* GL_SGI_texture_color_table */
- { GL_TEXTURE_COLOR_TABLE_SGI, LOC_TEXUNIT, TYPE_BOOLEAN,
- offsetof(struct gl_texture_unit, ColorTableEnabled),
- extra_SGI_texture_color_table },
-
- /* GL_EXT_secondary_color */
- { GL_COLOR_SUM_EXT, CONTEXT_BOOL(Fog.ColorSumEnabled),
- extra_EXT_secondary_color_ARB_vertex_program },
- { GL_CURRENT_SECONDARY_COLOR_EXT,
- CONTEXT_FIELD(Current.Attrib[VERT_ATTRIB_COLOR1][0], TYPE_FLOATN_4),
- extra_EXT_secondary_color_flush_current },
- { GL_SECONDARY_COLOR_ARRAY_EXT, ARRAY_BOOL(SecondaryColor.Enabled),
- extra_EXT_secondary_color },
- { GL_SECONDARY_COLOR_ARRAY_TYPE_EXT, ARRAY_ENUM(SecondaryColor.Type),
- extra_EXT_secondary_color },
- { GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT, ARRAY_INT(SecondaryColor.Stride),
- extra_EXT_secondary_color },
- { GL_SECONDARY_COLOR_ARRAY_SIZE_EXT, ARRAY_INT(SecondaryColor.Size),
- extra_EXT_secondary_color },
-
- /* GL_EXT_fog_coord */
- { GL_CURRENT_FOG_COORDINATE_EXT,
- CONTEXT_FLOAT(Current.Attrib[VERT_ATTRIB_FOG][0]),
- extra_EXT_fog_coord_flush_current },
- { GL_FOG_COORDINATE_ARRAY_EXT, ARRAY_BOOL(FogCoord.Enabled),
- extra_EXT_fog_coord },
- { GL_FOG_COORDINATE_ARRAY_TYPE_EXT, ARRAY_ENUM(FogCoord.Type),
- extra_EXT_fog_coord },
- { GL_FOG_COORDINATE_ARRAY_STRIDE_EXT, ARRAY_INT(FogCoord.Stride),
- extra_EXT_fog_coord },
- { GL_FOG_COORDINATE_SOURCE_EXT, CONTEXT_ENUM(Fog.FogCoordinateSource),
- extra_EXT_fog_coord },
-
- /* GL_IBM_rasterpos_clip */
- { GL_RASTER_POSITION_UNCLIPPED_IBM,
- CONTEXT_BOOL(Transform.RasterPositionUnclipped),
- extra_IBM_rasterpos_clip },
-
- /* GL_NV_point_sprite */
- { GL_POINT_SPRITE_R_MODE_NV,
- CONTEXT_ENUM(Point.SpriteRMode), extra_NV_point_sprite },
- { GL_POINT_SPRITE_COORD_ORIGIN, CONTEXT_ENUM(Point.SpriteOrigin),
- extra_NV_point_sprite_ARB_point_sprite },
-
- /* GL_NV_vertex_program */
- { GL_VERTEX_PROGRAM_BINDING_NV, LOC_CUSTOM, TYPE_INT, 0,
- extra_NV_vertex_program },
- { GL_VERTEX_ATTRIB_ARRAY0_NV, ARRAY_BOOL(VertexAttrib[0].Enabled),
- extra_NV_vertex_program },
- { GL_VERTEX_ATTRIB_ARRAY1_NV, ARRAY_BOOL(VertexAttrib[1].Enabled),
- extra_NV_vertex_program },
- { GL_VERTEX_ATTRIB_ARRAY2_NV, ARRAY_BOOL(VertexAttrib[2].Enabled),
- extra_NV_vertex_program },
- { GL_VERTEX_ATTRIB_ARRAY3_NV, ARRAY_BOOL(VertexAttrib[3].Enabled),
- extra_NV_vertex_program },
- { GL_VERTEX_ATTRIB_ARRAY4_NV, ARRAY_BOOL(VertexAttrib[4].Enabled),
- extra_NV_vertex_program },
- { GL_VERTEX_ATTRIB_ARRAY5_NV, ARRAY_BOOL(VertexAttrib[5].Enabled),
- extra_NV_vertex_program },
- { GL_VERTEX_ATTRIB_ARRAY6_NV, ARRAY_BOOL(VertexAttrib[6].Enabled),
- extra_NV_vertex_program },
- { GL_VERTEX_ATTRIB_ARRAY7_NV, ARRAY_BOOL(VertexAttrib[7].Enabled),
- extra_NV_vertex_program },
- { GL_VERTEX_ATTRIB_ARRAY8_NV, ARRAY_BOOL(VertexAttrib[8].Enabled),
- extra_NV_vertex_program },
- { GL_VERTEX_ATTRIB_ARRAY9_NV, ARRAY_BOOL(VertexAttrib[9].Enabled),
- extra_NV_vertex_program },
- { GL_VERTEX_ATTRIB_ARRAY10_NV, ARRAY_BOOL(VertexAttrib[10].Enabled),
- extra_NV_vertex_program },
- { GL_VERTEX_ATTRIB_ARRAY11_NV, ARRAY_BOOL(VertexAttrib[11].Enabled),
- extra_NV_vertex_program },
- { GL_VERTEX_ATTRIB_ARRAY12_NV, ARRAY_BOOL(VertexAttrib[12].Enabled),
- extra_NV_vertex_program },
- { GL_VERTEX_ATTRIB_ARRAY13_NV, ARRAY_BOOL(VertexAttrib[13].Enabled),
- extra_NV_vertex_program },
- { GL_VERTEX_ATTRIB_ARRAY14_NV, ARRAY_BOOL(VertexAttrib[14].Enabled),
- extra_NV_vertex_program },
- { GL_VERTEX_ATTRIB_ARRAY15_NV, ARRAY_BOOL(VertexAttrib[15].Enabled),
- extra_NV_vertex_program },
- { GL_MAP1_VERTEX_ATTRIB0_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[0]),
- extra_NV_vertex_program },
- { GL_MAP1_VERTEX_ATTRIB1_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[1]),
- extra_NV_vertex_program },
- { GL_MAP1_VERTEX_ATTRIB2_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[2]),
- extra_NV_vertex_program },
- { GL_MAP1_VERTEX_ATTRIB3_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[3]),
- extra_NV_vertex_program },
- { GL_MAP1_VERTEX_ATTRIB4_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[4]),
- extra_NV_vertex_program },
- { GL_MAP1_VERTEX_ATTRIB5_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[5]),
- extra_NV_vertex_program },
- { GL_MAP1_VERTEX_ATTRIB6_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[6]),
- extra_NV_vertex_program },
- { GL_MAP1_VERTEX_ATTRIB7_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[7]),
- extra_NV_vertex_program },
- { GL_MAP1_VERTEX_ATTRIB8_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[8]),
- extra_NV_vertex_program },
- { GL_MAP1_VERTEX_ATTRIB9_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[9]),
- extra_NV_vertex_program },
- { GL_MAP1_VERTEX_ATTRIB10_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[10]),
- extra_NV_vertex_program },
- { GL_MAP1_VERTEX_ATTRIB11_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[11]),
- extra_NV_vertex_program },
- { GL_MAP1_VERTEX_ATTRIB12_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[12]),
- extra_NV_vertex_program },
- { GL_MAP1_VERTEX_ATTRIB13_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[13]),
- extra_NV_vertex_program },
- { GL_MAP1_VERTEX_ATTRIB14_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[14]),
- extra_NV_vertex_program },
- { GL_MAP1_VERTEX_ATTRIB15_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[15]),
- extra_NV_vertex_program },
-
- /* GL_NV_fragment_program */
- { GL_FRAGMENT_PROGRAM_NV, CONTEXT_BOOL(FragmentProgram.Enabled),
- extra_NV_fragment_program },
- { GL_FRAGMENT_PROGRAM_BINDING_NV, LOC_CUSTOM, TYPE_INT, 0,
- extra_NV_fragment_program },
- { GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV,
- CONST(MAX_NV_FRAGMENT_PROGRAM_PARAMS),
- extra_NV_fragment_program },
-
- /* GL_NV_texture_rectangle */
- { GL_TEXTURE_RECTANGLE_NV,
- LOC_CUSTOM, TYPE_BOOLEAN, 0, extra_NV_texture_rectangle },
- { GL_TEXTURE_BINDING_RECTANGLE_NV,
- LOC_CUSTOM, TYPE_INT, TEXTURE_RECT_INDEX, extra_NV_texture_rectangle },
- { GL_MAX_RECTANGLE_TEXTURE_SIZE_NV,
- CONTEXT_INT(Const.MaxTextureRectSize), extra_NV_texture_rectangle },
-
- /* GL_EXT_stencil_two_side */
- { GL_STENCIL_TEST_TWO_SIDE_EXT, CONTEXT_BOOL(Stencil.TestTwoSide),
- extra_EXT_stencil_two_side },
- { GL_ACTIVE_STENCIL_FACE_EXT, LOC_CUSTOM, TYPE_ENUM, NO_OFFSET, NO_EXTRA },
-
- /* GL_NV_light_max_exponent */
- { GL_MAX_SHININESS_NV, CONTEXT_FLOAT(Const.MaxShininess),
- extra_NV_light_max_exponent },
- { GL_MAX_SPOT_EXPONENT_NV, CONTEXT_FLOAT(Const.MaxSpotExponent),
- extra_NV_light_max_exponent },
-
- /* GL_NV_primitive_restart */
- { GL_PRIMITIVE_RESTART_NV, CONTEXT_BOOL(Array.PrimitiveRestart),
- extra_NV_primitive_restart },
- { GL_PRIMITIVE_RESTART_INDEX_NV, CONTEXT_INT(Array.RestartIndex),
- extra_NV_primitive_restart },
-
- /* GL_ARB_vertex_buffer_object */
- { GL_INDEX_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT,
- offsetof(struct gl_array_object, Index.BufferObj), NO_EXTRA },
- { GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT,
- offsetof(struct gl_array_object, EdgeFlag.BufferObj), NO_EXTRA },
- { GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT,
- offsetof(struct gl_array_object, SecondaryColor.BufferObj), NO_EXTRA },
- { GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT,
- offsetof(struct gl_array_object, FogCoord.BufferObj), NO_EXTRA },
-
- /* GL_EXT_pixel_buffer_object */
- { GL_PIXEL_PACK_BUFFER_BINDING_EXT, LOC_CUSTOM, TYPE_INT, 0,
- extra_EXT_pixel_buffer_object },
- { GL_PIXEL_UNPACK_BUFFER_BINDING_EXT, LOC_CUSTOM, TYPE_INT, 0,
- extra_EXT_pixel_buffer_object },
-
- /* GL_ARB_vertex_program */
- { GL_VERTEX_PROGRAM_ARB, /* == GL_VERTEX_PROGRAM_NV */
- CONTEXT_BOOL(VertexProgram.Enabled),
- extra_ARB_vertex_program_NV_vertex_program },
- { GL_VERTEX_PROGRAM_POINT_SIZE_ARB, /* == GL_VERTEX_PROGRAM_POINT_SIZE_NV*/
- CONTEXT_BOOL(VertexProgram.PointSizeEnabled),
- extra_ARB_vertex_program_NV_vertex_program },
- { GL_VERTEX_PROGRAM_TWO_SIDE_ARB, /* == GL_VERTEX_PROGRAM_TWO_SIDE_NV */
- CONTEXT_BOOL(VertexProgram.TwoSideEnabled),
- extra_ARB_vertex_program_NV_vertex_program },
- { GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB, /* == GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV */
- CONTEXT_INT(Const.MaxProgramMatrixStackDepth),
- extra_ARB_vertex_program_ARB_fragment_program_NV_vertex_program },
- { GL_MAX_PROGRAM_MATRICES_ARB, /* == GL_MAX_TRACK_MATRICES_NV */
- CONTEXT_INT(Const.MaxProgramMatrices),
- extra_ARB_vertex_program_ARB_fragment_program_NV_vertex_program },
- { GL_CURRENT_MATRIX_STACK_DEPTH_ARB, /* == GL_CURRENT_MATRIX_STACK_DEPTH_NV */
- LOC_CUSTOM, TYPE_INT, 0,
- extra_ARB_vertex_program_ARB_fragment_program_NV_vertex_program },
-
- { GL_CURRENT_MATRIX_ARB, /* == GL_CURRENT_MATRIX_NV */
- LOC_CUSTOM, TYPE_MATRIX, 0,
- extra_ARB_vertex_program_ARB_fragment_program_NV_vertex_program },
- { GL_TRANSPOSE_CURRENT_MATRIX_ARB, /* == GL_CURRENT_MATRIX_NV */
- LOC_CUSTOM, TYPE_MATRIX, 0,
- extra_ARB_vertex_program_ARB_fragment_program },
-
- { GL_PROGRAM_ERROR_POSITION_ARB, /* == GL_PROGRAM_ERROR_POSITION_NV */
- CONTEXT_INT(Program.ErrorPos),
- extra_NV_vertex_program_ARB_vertex_program_ARB_fragment_program_NV_vertex_program },
-
- /* GL_ARB_fragment_program */
- { GL_FRAGMENT_PROGRAM_ARB, CONTEXT_BOOL(FragmentProgram.Enabled),
- extra_ARB_fragment_program },
-
- /* GL_EXT_depth_bounds_test */
- { GL_DEPTH_BOUNDS_TEST_EXT, CONTEXT_BOOL(Depth.BoundsTest),
- extra_EXT_depth_bounds_test },
- { GL_DEPTH_BOUNDS_EXT, CONTEXT_FLOAT2(Depth.BoundsMin),
- extra_EXT_depth_bounds_test },
-
- /* GL_ARB_depth_clamp*/
- { GL_DEPTH_CLAMP, CONTEXT_BOOL(Transform.DepthClamp),
- extra_ARB_depth_clamp },
-
- /* GL_ARB_draw_buffers */
- { GL_DRAW_BUFFER0_ARB, BUFFER_ENUM(ColorDrawBuffer[0]), NO_EXTRA },
- { GL_DRAW_BUFFER1_ARB, BUFFER_ENUM(ColorDrawBuffer[1]),
- extra_valid_draw_buffer },
- { GL_DRAW_BUFFER2_ARB, BUFFER_ENUM(ColorDrawBuffer[2]),
- extra_valid_draw_buffer },
- { GL_DRAW_BUFFER3_ARB, BUFFER_ENUM(ColorDrawBuffer[3]),
- extra_valid_draw_buffer },
- { GL_DRAW_BUFFER4_ARB, BUFFER_ENUM(ColorDrawBuffer[4]),
- extra_valid_draw_buffer },
- { GL_DRAW_BUFFER5_ARB, BUFFER_ENUM(ColorDrawBuffer[5]),
- extra_valid_draw_buffer },
- { GL_DRAW_BUFFER6_ARB, BUFFER_ENUM(ColorDrawBuffer[6]),
- extra_valid_draw_buffer },
- { GL_DRAW_BUFFER7_ARB, BUFFER_ENUM(ColorDrawBuffer[7]),
- extra_valid_draw_buffer },
-
- /* GL_ATI_fragment_shader */
- { GL_NUM_FRAGMENT_REGISTERS_ATI, CONST(6), extra_ATI_fragment_shader },
- { GL_NUM_FRAGMENT_CONSTANTS_ATI, CONST(8), extra_ATI_fragment_shader },
- { GL_NUM_PASSES_ATI, CONST(2), extra_ATI_fragment_shader },
- { GL_NUM_INSTRUCTIONS_PER_PASS_ATI, CONST(8), extra_ATI_fragment_shader },
- { GL_NUM_INSTRUCTIONS_TOTAL_ATI, CONST(16), extra_ATI_fragment_shader },
- { GL_COLOR_ALPHA_PAIRING_ATI, CONST(GL_TRUE), extra_ATI_fragment_shader },
- { GL_NUM_LOOPBACK_COMPONENTS_ATI, CONST(3), extra_ATI_fragment_shader },
- { GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI,
- CONST(3), extra_ATI_fragment_shader },
-
- /* GL_EXT_framebuffer_object */
- { GL_MAX_COLOR_ATTACHMENTS_EXT, CONTEXT_INT(Const.MaxColorAttachments),
- extra_EXT_framebuffer_object },
-
- /* GL_EXT_framebuffer_blit
- * NOTE: GL_DRAW_FRAMEBUFFER_BINDING_EXT == GL_FRAMEBUFFER_BINDING_EXT */
- { GL_READ_FRAMEBUFFER_BINDING_EXT, LOC_CUSTOM, TYPE_INT, 0,
- extra_EXT_framebuffer_blit },
-
- /* GL_EXT_provoking_vertex */
- { GL_PROVOKING_VERTEX_EXT,
- CONTEXT_BOOL(Light.ProvokingVertex), extra_EXT_provoking_vertex },
- { GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT,
- CONTEXT_BOOL(Const.QuadsFollowProvokingVertexConvention),
- extra_EXT_provoking_vertex },
-
- /* GL_ARB_framebuffer_object */
- { GL_MAX_SAMPLES, CONTEXT_INT(Const.MaxSamples),
- extra_ARB_framebuffer_object_EXT_framebuffer_multisample },
-
- /* GL_APPLE_vertex_array_object */
- { GL_VERTEX_ARRAY_BINDING_APPLE, ARRAY_INT(Name),
- extra_APPLE_vertex_array_object },
-
- /* GL_ARB_seamless_cube_map */
- { GL_TEXTURE_CUBE_MAP_SEAMLESS,
- CONTEXT_BOOL(Texture.CubeMapSeamless), extra_ARB_seamless_cube_map },
-
- /* GL_ARB_sync */
- { GL_MAX_SERVER_WAIT_TIMEOUT,
- CONTEXT_INT64(Const.MaxServerWaitTimeout), extra_ARB_sync },
-
- /* GL_EXT_texture_integer */
- { GL_RGBA_INTEGER_MODE_EXT, BUFFER_BOOL(_IntegerColor),
- extra_EXT_texture_integer },
-
- /* GL_EXT_transform_feedback */
- { GL_TRANSFORM_FEEDBACK_BUFFER_BINDING, LOC_CUSTOM, TYPE_INT, 0,
- extra_EXT_transform_feedback },
- { GL_RASTERIZER_DISCARD, CONTEXT_BOOL(TransformFeedback.RasterDiscard),
- extra_EXT_transform_feedback },
- { GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS,
- CONTEXT_INT(Const.MaxTransformFeedbackInterleavedComponents),
- extra_EXT_transform_feedback },
- { GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS,
- CONTEXT_INT(Const.MaxTransformFeedbackSeparateAttribs),
- extra_EXT_transform_feedback },
- { GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS,
- CONTEXT_INT(Const.MaxTransformFeedbackSeparateComponents),
- extra_EXT_transform_feedback },
-
- /* GL_ARB_transform_feedback2 */
- { GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED, LOC_CUSTOM, TYPE_BOOLEAN, 0,
- extra_ARB_transform_feedback2 },
- { GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE, LOC_CUSTOM, TYPE_BOOLEAN, 0,
- extra_ARB_transform_feedback2 },
- { GL_TRANSFORM_FEEDBACK_BINDING, LOC_CUSTOM, TYPE_INT, 0,
- extra_ARB_transform_feedback2 },
-
- /* GL_ARB_geometry_shader4 */
- { GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB,
- CONTEXT_INT(Const.GeometryProgram.MaxGeometryTextureImageUnits),
- extra_ARB_geometry_shader4 },
- { GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB,
- CONTEXT_INT(Const.GeometryProgram.MaxGeometryOutputVertices),
- extra_ARB_geometry_shader4 },
- { GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB,
- CONTEXT_INT(Const.GeometryProgram.MaxGeometryTotalOutputComponents),
- extra_ARB_geometry_shader4 },
- { GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB,
- CONTEXT_INT(Const.GeometryProgram.MaxGeometryUniformComponents),
- extra_ARB_geometry_shader4 },
- { GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB,
- CONTEXT_INT(Const.GeometryProgram.MaxGeometryVaryingComponents),
- extra_ARB_geometry_shader4 },
- { GL_MAX_VERTEX_VARYING_COMPONENTS_ARB,
- CONTEXT_INT(Const.GeometryProgram.MaxVertexVaryingComponents),
- extra_ARB_geometry_shader4 },
-
- /* GL_EXT_gpu_shader4 / GL 3.0 */
- { GL_MIN_PROGRAM_TEXEL_OFFSET,
- CONTEXT_INT(Const.MinProgramTexelOffset),
- extra_EXT_gpu_shader4 },
- { GL_MAX_PROGRAM_TEXEL_OFFSET,
- CONTEXT_INT(Const.MaxProgramTexelOffset),
- extra_EXT_gpu_shader4 },
-
- /* GL 3.0 */
- { GL_NUM_EXTENSIONS, LOC_CUSTOM, TYPE_INT, 0, extra_version_30 },
- { GL_MAJOR_VERSION, CONTEXT_INT(VersionMajor), extra_version_30 },
- { GL_MINOR_VERSION, CONTEXT_INT(VersionMinor), extra_version_30 },
- { GL_CONTEXT_FLAGS, CONTEXT_INT(Const.ContextFlags), extra_version_30 },
-
- /* GL 3.1 */
- /* NOTE: different enum values for GL_PRIMITIVE_RESTART_NV
- * vs. GL_PRIMITIVE_RESTART!
- */
- { GL_PRIMITIVE_RESTART, CONTEXT_BOOL(Array.PrimitiveRestart),
- extra_version_31 },
- { GL_PRIMITIVE_RESTART_INDEX, CONTEXT_INT(Array.RestartIndex),
- extra_version_31 },
-
-
- /* GL 3.2 */
- { GL_CONTEXT_PROFILE_MASK, CONTEXT_INT(Const.ProfileMask),
- extra_version_32 },
-#endif /* FEATURE_GL */
-};
-
-/* All we need now is a way to look up the value struct from the enum.
- * The code generated by gcc for the old generated big switch
- * statement is a big, balanced, open coded if/else tree, essentially
- * an unrolled binary search. It would be natural to sort the new
- * enum table and use bsearch(), but we will use a read-only hash
- * table instead. bsearch() has a nice guaranteed worst case
- * performance, but we're also guaranteed to hit that worst case
- * (log2(n) iterations) for about half the enums. Instead, using an
- * open addressing hash table, we can find the enum on the first try
- * for 80% of the enums, 1 collision for 10% and never more than 5
- * collisions for any enum (typical numbers). And the code is very
- * simple, even though it feels a little magic. */
-
-static unsigned short table[1024];
-static const int prime_factor = 89, prime_step = 281;
-
-#ifdef GET_DEBUG
-static void
-print_table_stats(void)
-{
- int i, j, collisions[11], count, hash, mask;
- const struct value_desc *d;
-
- count = 0;
- mask = Elements(table) - 1;
- memset(collisions, 0, sizeof collisions);
-
- for (i = 0; i < Elements(table); i++) {
- if (!table[i])
- continue;
- count++;
- d = &values[table[i]];
- hash = (d->pname * prime_factor);
- j = 0;
- while (1) {
- if (values[table[hash & mask]].pname == d->pname)
- break;
- hash += prime_step;
- j++;
- }
-
- if (j < 10)
- collisions[j]++;
- else
- collisions[10]++;
- }
-
- printf("number of enums: %d (total %d)\n", count, Elements(values));
- for (i = 0; i < Elements(collisions) - 1; i++)
- if (collisions[i] > 0)
- printf(" %d enums with %d %scollisions\n",
- collisions[i], i, i == 10 ? "or more " : "");
-}
-#endif
-
-/**
- * Initialize the enum hash for a given API
- *
- * This is called from one_time_init() to insert the enum values that
- * are valid for the API in question into the enum hash table.
- *
- * \param the current context, for determining the API in question
- */
-void _mesa_init_get_hash(struct gl_context *ctx)
-{
- int i, hash, index, mask;
- int api_mask = 0, api_bit;
-
- mask = Elements(table) - 1;
- api_bit = 1 << ctx->API;
-
- for (i = 0; i < Elements(values); i++) {
- if (values[i].type == TYPE_API_MASK) {
- api_mask = values[i].offset;
- continue;
- }
- if (!(api_mask & api_bit))
- continue;
-
- hash = (values[i].pname * prime_factor) & mask;
- while (1) {
- index = hash & mask;
- if (!table[index]) {
- table[index] = i;
- break;
- }
- hash += prime_step;
- }
- }
-
-#ifdef GET_DEBUG
- print_table_stats();
-#endif
-}
-
-/**
- * Handle irregular enums
- *
- * Some values don't conform to the "well-known type at context
- * pointer + offset" pattern, so we have this function to catch all
- * the corner cases. Typically, it's a computed value or a one-off
- * pointer to a custom struct or something.
- *
- * In this case we can't return a pointer to the value, so we'll have
- * to use the temporary variable 'v' declared back in the calling
- * glGet*v() function to store the result.
- *
- * \param ctx the current context
- * \param d the struct value_desc that describes the enum
- * \param v pointer to the tmp declared in the calling glGet*v() function
- */
-static void
-find_custom_value(struct gl_context *ctx, const struct value_desc *d, union value *v)
-{
- struct gl_buffer_object *buffer_obj;
- struct gl_client_array *array;
- GLuint unit, *p;
-
- switch (d->pname) {
- case GL_TEXTURE_1D:
- case GL_TEXTURE_2D:
- case GL_TEXTURE_3D:
- case GL_TEXTURE_1D_ARRAY_EXT:
- case GL_TEXTURE_2D_ARRAY_EXT:
- case GL_TEXTURE_CUBE_MAP_ARB:
- case GL_TEXTURE_RECTANGLE_NV:
- v->value_bool = _mesa_IsEnabled(d->pname);
- break;
-
- case GL_LINE_STIPPLE_PATTERN:
- /* This is the only GLushort, special case it here by promoting
- * to an int rather than introducing a new type. */
- v->value_int = ctx->Line.StipplePattern;
- break;
-
- case GL_CURRENT_RASTER_TEXTURE_COORDS:
- unit = ctx->Texture.CurrentUnit;
- v->value_float_4[0] = ctx->Current.RasterTexCoords[unit][0];
- v->value_float_4[1] = ctx->Current.RasterTexCoords[unit][1];
- v->value_float_4[2] = ctx->Current.RasterTexCoords[unit][2];
- v->value_float_4[3] = ctx->Current.RasterTexCoords[unit][3];
- break;
-
- case GL_CURRENT_TEXTURE_COORDS:
- unit = ctx->Texture.CurrentUnit;
- v->value_float_4[0] = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][0];
- v->value_float_4[1] = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][1];
- v->value_float_4[2] = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][2];
- v->value_float_4[3] = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][3];
- break;
-
- case GL_COLOR_WRITEMASK:
- v->value_int_4[0] = ctx->Color.ColorMask[0][RCOMP] ? 1 : 0;
- v->value_int_4[1] = ctx->Color.ColorMask[0][GCOMP] ? 1 : 0;
- v->value_int_4[2] = ctx->Color.ColorMask[0][BCOMP] ? 1 : 0;
- v->value_int_4[3] = ctx->Color.ColorMask[0][ACOMP] ? 1 : 0;
- break;
-
- case GL_EDGE_FLAG:
- v->value_bool = ctx->Current.Attrib[VERT_ATTRIB_EDGEFLAG][0] == 1.0;
- break;
-
- case GL_READ_BUFFER:
- v->value_enum = ctx->ReadBuffer->ColorReadBuffer;
- break;
-
- case GL_MAP2_GRID_DOMAIN:
- v->value_float_4[0] = ctx->Eval.MapGrid2u1;
- v->value_float_4[1] = ctx->Eval.MapGrid2u2;
- v->value_float_4[2] = ctx->Eval.MapGrid2v1;
- v->value_float_4[3] = ctx->Eval.MapGrid2v2;
- break;
-
- case GL_TEXTURE_STACK_DEPTH:
- unit = ctx->Texture.CurrentUnit;
- v->value_int = ctx->TextureMatrixStack[unit].Depth + 1;
- break;
- case GL_TEXTURE_MATRIX:
- unit = ctx->Texture.CurrentUnit;
- v->value_matrix = ctx->TextureMatrixStack[unit].Top;
- break;
-
- case GL_TEXTURE_COORD_ARRAY:
- case GL_TEXTURE_COORD_ARRAY_SIZE:
- case GL_TEXTURE_COORD_ARRAY_TYPE:
- case GL_TEXTURE_COORD_ARRAY_STRIDE:
- array = &ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture];
- v->value_int = *(GLuint *) ((char *) array + d->offset);
- break;
-
- case GL_ACTIVE_TEXTURE_ARB:
- v->value_int = GL_TEXTURE0_ARB + ctx->Texture.CurrentUnit;
- break;
- case GL_CLIENT_ACTIVE_TEXTURE_ARB:
- v->value_int = GL_TEXTURE0_ARB + ctx->Array.ActiveTexture;
- break;
-
- case GL_MODELVIEW_STACK_DEPTH:
- case GL_PROJECTION_STACK_DEPTH:
- v->value_int = *(GLint *) ((char *) ctx + d->offset) + 1;
- break;
-
- case GL_MAX_TEXTURE_SIZE:
- case GL_MAX_3D_TEXTURE_SIZE:
- case GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB:
- p = (GLuint *) ((char *) ctx + d->offset);
- v->value_int = 1 << (*p - 1);
- break;
-
- case GL_SCISSOR_BOX:
- v->value_int_4[0] = ctx->Scissor.X;
- v->value_int_4[1] = ctx->Scissor.Y;
- v->value_int_4[2] = ctx->Scissor.Width;
- v->value_int_4[3] = ctx->Scissor.Height;
- break;
-
- case GL_LIST_INDEX:
- v->value_int =
- ctx->ListState.CurrentList ? ctx->ListState.CurrentList->Name : 0;
- break;
- case GL_LIST_MODE:
- if (!ctx->CompileFlag)
- v->value_enum = 0;
- else if (ctx->ExecuteFlag)
- v->value_enum = GL_COMPILE_AND_EXECUTE;
- else
- v->value_enum = GL_COMPILE;
- break;
-
- case GL_VIEWPORT:
- v->value_int_4[0] = ctx->Viewport.X;
- v->value_int_4[1] = ctx->Viewport.Y;
- v->value_int_4[2] = ctx->Viewport.Width;
- v->value_int_4[3] = ctx->Viewport.Height;
- break;
-
- case GL_ACTIVE_STENCIL_FACE_EXT:
- v->value_enum = ctx->Stencil.ActiveFace ? GL_BACK : GL_FRONT;
- break;
-
- case GL_STENCIL_FAIL:
- v->value_enum = ctx->Stencil.FailFunc[ctx->Stencil.ActiveFace];
- break;
- case GL_STENCIL_FUNC:
- v->value_enum = ctx->Stencil.Function[ctx->Stencil.ActiveFace];
- break;
- case GL_STENCIL_PASS_DEPTH_FAIL:
- v->value_enum = ctx->Stencil.ZFailFunc[ctx->Stencil.ActiveFace];
- break;
- case GL_STENCIL_PASS_DEPTH_PASS:
- v->value_enum = ctx->Stencil.ZPassFunc[ctx->Stencil.ActiveFace];
- break;
- case GL_STENCIL_REF:
- v->value_int = ctx->Stencil.Ref[ctx->Stencil.ActiveFace];
- break;
- case GL_STENCIL_VALUE_MASK:
- v->value_int = ctx->Stencil.ValueMask[ctx->Stencil.ActiveFace];
- break;
- case GL_STENCIL_WRITEMASK:
- v->value_int = ctx->Stencil.WriteMask[ctx->Stencil.ActiveFace];
- break;
-
- case GL_NUM_EXTENSIONS:
- v->value_int = _mesa_get_extension_count(ctx);
- break;
-
- case GL_IMPLEMENTATION_COLOR_READ_TYPE_OES:
- v->value_int = _mesa_get_color_read_type(ctx);
- break;
- case GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES:
- v->value_int = _mesa_get_color_read_format(ctx);
- break;
-
- case GL_CURRENT_MATRIX_STACK_DEPTH_ARB:
- v->value_int = ctx->CurrentStack->Depth + 1;
- break;
- case GL_CURRENT_MATRIX_ARB:
- case GL_TRANSPOSE_CURRENT_MATRIX_ARB:
- v->value_matrix = ctx->CurrentStack->Top;
- break;
-
- case GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB:
- v->value_int = _mesa_get_compressed_formats(ctx, NULL, GL_FALSE);
- break;
- case GL_COMPRESSED_TEXTURE_FORMATS_ARB:
- v->value_int_n.n =
- _mesa_get_compressed_formats(ctx, v->value_int_n.ints, GL_FALSE);
- ASSERT(v->value_int_n.n <= 100);
- break;
-
- case GL_MAX_VARYING_FLOATS_ARB:
- v->value_int = ctx->Const.MaxVarying * 4;
- break;
-
- /* Various object names */
-
- case GL_TEXTURE_BINDING_1D:
- case GL_TEXTURE_BINDING_2D:
- case GL_TEXTURE_BINDING_3D:
- case GL_TEXTURE_BINDING_1D_ARRAY_EXT:
- case GL_TEXTURE_BINDING_2D_ARRAY_EXT:
- case GL_TEXTURE_BINDING_CUBE_MAP_ARB:
- case GL_TEXTURE_BINDING_RECTANGLE_NV:
- unit = ctx->Texture.CurrentUnit;
- v->value_int =
- ctx->Texture.Unit[unit].CurrentTex[d->offset]->Name;
- break;
-
- /* GL_ARB_vertex_buffer_object */
- case GL_VERTEX_ARRAY_BUFFER_BINDING_ARB:
- case GL_NORMAL_ARRAY_BUFFER_BINDING_ARB:
- case GL_COLOR_ARRAY_BUFFER_BINDING_ARB:
- case GL_INDEX_ARRAY_BUFFER_BINDING_ARB:
- case GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB:
- case GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB:
- case GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB:
- buffer_obj = (struct gl_buffer_object *)
- ((char *) ctx->Array.ArrayObj + d->offset);
- v->value_int = buffer_obj->Name;
- break;
- case GL_ARRAY_BUFFER_BINDING_ARB:
- v->value_int = ctx->Array.ArrayBufferObj->Name;
- break;
- case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB:
- v->value_int =
- ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].BufferObj->Name;
- break;
- case GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB:
- v->value_int = ctx->Array.ElementArrayBufferObj->Name;
- break;
-
- /* ARB_copy_buffer */
- case GL_COPY_READ_BUFFER:
- v->value_int = ctx->CopyReadBuffer->Name;
- break;
- case GL_COPY_WRITE_BUFFER:
- v->value_int = ctx->CopyWriteBuffer->Name;
- break;
-
- case GL_FRAGMENT_PROGRAM_BINDING_NV:
- v->value_int =
- ctx->FragmentProgram.Current ? ctx->FragmentProgram.Current->Base.Id : 0;
- break;
- case GL_VERTEX_PROGRAM_BINDING_NV:
- v->value_int =
- ctx->VertexProgram.Current ? ctx->VertexProgram.Current->Base.Id : 0;
- break;
- case GL_PIXEL_PACK_BUFFER_BINDING_EXT:
- v->value_int = ctx->Pack.BufferObj->Name;
- break;
- case GL_PIXEL_UNPACK_BUFFER_BINDING_EXT:
- v->value_int = ctx->Unpack.BufferObj->Name;
- break;
- case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING:
- v->value_int = ctx->TransformFeedback.CurrentBuffer->Name;
- break;
- case GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED:
- v->value_int = ctx->TransformFeedback.CurrentObject->Paused;
- break;
- case GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE:
- v->value_int = ctx->TransformFeedback.CurrentObject->Active;
- break;
- case GL_TRANSFORM_FEEDBACK_BINDING:
- v->value_int = ctx->TransformFeedback.CurrentObject->Name;
- break;
- case GL_CURRENT_PROGRAM:
- v->value_int =
- ctx->Shader.ActiveProgram ? ctx->Shader.ActiveProgram->Name : 0;
- break;
- case GL_READ_FRAMEBUFFER_BINDING_EXT:
- v->value_int = ctx->ReadBuffer->Name;
- break;
- case GL_RENDERBUFFER_BINDING_EXT:
- v->value_int =
- ctx->CurrentRenderbuffer ? ctx->CurrentRenderbuffer->Name : 0;
- break;
- case GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES:
- v->value_int = ctx->Array.ArrayObj->PointSize.BufferObj->Name;
- break;
-
- case GL_MAX_VERTEX_UNIFORM_VECTORS:
- v->value_int = ctx->Const.VertexProgram.MaxUniformComponents / 4;
- break;
-
- case GL_MAX_FRAGMENT_UNIFORM_VECTORS:
- v->value_int = ctx->Const.FragmentProgram.MaxUniformComponents / 4;
- break;
- }
-}
-
-/**
- * Check extra constraints on a struct value_desc descriptor
- *
- * If a struct value_desc has a non-NULL extra pointer, it means that
- * there are a number of extra constraints to check or actions to
- * perform. The extras is just an integer array where each integer
- * encode different constraints or actions.
- *
- * \param ctx current context
- * \param func name of calling glGet*v() function for error reporting
- * \param d the struct value_desc that has the extra constraints
- *
- * \return GL_FALSE if one of the constraints was not satisfied,
- * otherwise GL_TRUE.
- */
-static GLboolean
-check_extra(struct gl_context *ctx, const char *func, const struct value_desc *d)
-{
- const GLuint version = ctx->VersionMajor * 10 + ctx->VersionMinor;
- int total, enabled;
- const int *e;
-
- total = 0;
- enabled = 0;
- for (e = d->extra; *e != EXTRA_END; e++)
- switch (*e) {
- case EXTRA_VERSION_30:
- if (version >= 30) {
- total++;
- enabled++;
- }
- break;
- case EXTRA_VERSION_31:
- if (version >= 31) {
- total++;
- enabled++;
- }
- break;
- case EXTRA_VERSION_32:
- if (version >= 32) {
- total++;
- enabled++;
- }
- break;
- case EXTRA_VERSION_ES2:
- if (ctx->API == API_OPENGLES2) {
- total++;
- enabled++;
- }
- break;
- case EXTRA_NEW_BUFFERS:
- if (ctx->NewState & _NEW_BUFFERS)
- _mesa_update_state(ctx);
- break;
- case EXTRA_FLUSH_CURRENT:
- FLUSH_CURRENT(ctx, 0);
- break;
- case EXTRA_VALID_DRAW_BUFFER:
- if (d->pname - GL_DRAW_BUFFER0_ARB >= ctx->Const.MaxDrawBuffers) {
- _mesa_error(ctx, GL_INVALID_OPERATION, "%s(draw buffer %u)",
- func, d->pname - GL_DRAW_BUFFER0_ARB);
- return GL_FALSE;
- }
- break;
- case EXTRA_VALID_TEXTURE_UNIT:
- if (ctx->Texture.CurrentUnit >= ctx->Const.MaxTextureCoordUnits) {
- _mesa_error(ctx, GL_INVALID_OPERATION, "%s(texture %u)",
- func, ctx->Texture.CurrentUnit);
- return GL_FALSE;
- }
- break;
- case EXTRA_END:
- break;
- default: /* *e is a offset into the extension struct */
- total++;
- if (*(GLboolean *) ((char *) &ctx->Extensions + *e))
- enabled++;
- break;
- }
-
- if (total > 0 && enabled == 0) {
- _mesa_error(ctx, GL_INVALID_ENUM, "%s(pname=%s)", func,
- _mesa_lookup_enum_by_nr(d->pname));
- return GL_FALSE;
- }
-
- return GL_TRUE;
-}
-
-static const struct value_desc error_value =
- { 0, 0, TYPE_INVALID, NO_OFFSET, NO_EXTRA };
-
-/**
- * Find the struct value_desc corresponding to the enum 'pname'.
- *
- * We hash the enum value to get an index into the 'table' array,
- * which holds the index in the 'values' array of struct value_desc.
- * Once we've found the entry, we do the extra checks, if any, then
- * look up the value and return a pointer to it.
- *
- * If the value has to be computed (for example, it's the result of a
- * function call or we need to add 1 to it), we use the tmp 'v' to
- * store the result.
- *
- * \param func name of glGet*v() func for error reporting
- * \param pname the enum value we're looking up
- * \param p is were we return the pointer to the value
- * \param v a tmp union value variable in the calling glGet*v() function
- *
- * \return the struct value_desc corresponding to the enum or a struct
- * value_desc of TYPE_INVALID if not found. This lets the calling
- * glGet*v() function jump right into a switch statement and
- * handle errors there instead of having to check for NULL.
- */
-static const struct value_desc *
-find_value(const char *func, GLenum pname, void **p, union value *v)
-{
- GET_CURRENT_CONTEXT(ctx);
- struct gl_texture_unit *unit;
- int mask, hash;
- const struct value_desc *d;
-
- mask = Elements(table) - 1;
- hash = (pname * prime_factor);
- while (1) {
- d = &values[table[hash & mask]];
-
- /* If the enum isn't valid, the hash walk ends with index 0,
- * which is the API mask entry at the beginning of values[]. */
- if (unlikely(d->type == TYPE_API_MASK)) {
- _mesa_error(ctx, GL_INVALID_ENUM, "%s(pname=%s)", func,
- _mesa_lookup_enum_by_nr(pname));
- return &error_value;
- }
-
- if (likely(d->pname == pname))
- break;
-
- hash += prime_step;
- }
-
- if (unlikely(d->extra && !check_extra(ctx, func, d)))
- return &error_value;
-
- switch (d->location) {
- case LOC_BUFFER:
- *p = ((char *) ctx->DrawBuffer + d->offset);
- return d;
- case LOC_CONTEXT:
- *p = ((char *) ctx + d->offset);
- return d;
- case LOC_ARRAY:
- *p = ((char *) ctx->Array.ArrayObj + d->offset);
- return d;
- case LOC_TEXUNIT:
- unit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
- *p = ((char *) unit + d->offset);
- return d;
- case LOC_CUSTOM:
- find_custom_value(ctx, d, v);
- *p = v;
- return d;
- default:
- assert(0);
- break;
- }
-
- /* silence warning */
- return &error_value;
-}
-
-static const int transpose[] = {
- 0, 4, 8, 12,
- 1, 5, 9, 13,
- 2, 6, 10, 14,
- 3, 7, 11, 15
-};
-
-void GLAPIENTRY
-_mesa_GetBooleanv(GLenum pname, GLboolean *params)
-{
- const struct value_desc *d;
- union value v;
- GLmatrix *m;
- int shift, i;
- void *p;
-
- d = find_value("glGetBooleanv", pname, &p, &v);
- switch (d->type) {
- case TYPE_INVALID:
- break;
- case TYPE_CONST:
- params[0] = INT_TO_BOOLEAN(d->offset);
- break;
-
- case TYPE_FLOAT_4:
- case TYPE_FLOATN_4:
- params[3] = FLOAT_TO_BOOLEAN(((GLfloat *) p)[3]);
- case TYPE_FLOAT_3:
- case TYPE_FLOATN_3:
- params[2] = FLOAT_TO_BOOLEAN(((GLfloat *) p)[2]);
- case TYPE_FLOAT_2:
- case TYPE_FLOATN_2:
- params[1] = FLOAT_TO_BOOLEAN(((GLfloat *) p)[1]);
- case TYPE_FLOAT:
- case TYPE_FLOATN:
- params[0] = FLOAT_TO_BOOLEAN(((GLfloat *) p)[0]);
- break;
-
- case TYPE_DOUBLEN:
- params[0] = FLOAT_TO_BOOLEAN(((GLdouble *) p)[0]);
- break;
-
- case TYPE_INT_4:
- params[3] = INT_TO_BOOLEAN(((GLint *) p)[3]);
- case TYPE_INT_3:
- params[2] = INT_TO_BOOLEAN(((GLint *) p)[2]);
- case TYPE_INT_2:
- case TYPE_ENUM_2:
- params[1] = INT_TO_BOOLEAN(((GLint *) p)[1]);
- case TYPE_INT:
- case TYPE_ENUM:
- params[0] = INT_TO_BOOLEAN(((GLint *) p)[0]);
- break;
-
- case TYPE_INT_N:
- for (i = 0; i < v.value_int_n.n; i++)
- params[i] = INT_TO_BOOLEAN(v.value_int_n.ints[i]);
- break;
-
- case TYPE_INT64:
- params[0] = INT64_TO_BOOLEAN(((GLint64 *) p)[0]);
- break;
-
- case TYPE_BOOLEAN:
- params[0] = ((GLboolean*) p)[0];
- break;
-
- case TYPE_MATRIX:
- m = *(GLmatrix **) p;
- for (i = 0; i < 16; i++)
- params[i] = FLOAT_TO_BOOLEAN(m->m[i]);
- break;
-
- case TYPE_MATRIX_T:
- m = *(GLmatrix **) p;
- for (i = 0; i < 16; i++)
- params[i] = FLOAT_TO_BOOLEAN(m->m[transpose[i]]);
- break;
-
- case TYPE_BIT_0:
- case TYPE_BIT_1:
- case TYPE_BIT_2:
- case TYPE_BIT_3:
- case TYPE_BIT_4:
- case TYPE_BIT_5:
- shift = d->type - TYPE_BIT_0;
- params[0] = (*(GLbitfield *) p >> shift) & 1;
- break;
- }
-}
-
-void GLAPIENTRY
-_mesa_GetFloatv(GLenum pname, GLfloat *params)
-{
- const struct value_desc *d;
- union value v;
- GLmatrix *m;
- int shift, i;
- void *p;
-
- d = find_value("glGetFloatv", pname, &p, &v);
- switch (d->type) {
- case TYPE_INVALID:
- break;
- case TYPE_CONST:
- params[0] = (GLfloat) d->offset;
- break;
-
- case TYPE_FLOAT_4:
- case TYPE_FLOATN_4:
- params[3] = ((GLfloat *) p)[3];
- case TYPE_FLOAT_3:
- case TYPE_FLOATN_3:
- params[2] = ((GLfloat *) p)[2];
- case TYPE_FLOAT_2:
- case TYPE_FLOATN_2:
- params[1] = ((GLfloat *) p)[1];
- case TYPE_FLOAT:
- case TYPE_FLOATN:
- params[0] = ((GLfloat *) p)[0];
- break;
-
- case TYPE_DOUBLEN:
- params[0] = ((GLdouble *) p)[0];
- break;
-
- case TYPE_INT_4:
- params[3] = (GLfloat) (((GLint *) p)[3]);
- case TYPE_INT_3:
- params[2] = (GLfloat) (((GLint *) p)[2]);
- case TYPE_INT_2:
- case TYPE_ENUM_2:
- params[1] = (GLfloat) (((GLint *) p)[1]);
- case TYPE_INT:
- case TYPE_ENUM:
- params[0] = (GLfloat) (((GLint *) p)[0]);
- break;
-
- case TYPE_INT_N:
- for (i = 0; i < v.value_int_n.n; i++)
- params[i] = INT_TO_FLOAT(v.value_int_n.ints[i]);
- break;
-
- case TYPE_INT64:
- params[0] = ((GLint64 *) p)[0];
- break;
-
- case TYPE_BOOLEAN:
- params[0] = BOOLEAN_TO_FLOAT(*(GLboolean*) p);
- break;
-
- case TYPE_MATRIX:
- m = *(GLmatrix **) p;
- for (i = 0; i < 16; i++)
- params[i] = m->m[i];
- break;
-
- case TYPE_MATRIX_T:
- m = *(GLmatrix **) p;
- for (i = 0; i < 16; i++)
- params[i] = m->m[transpose[i]];
- break;
-
- case TYPE_BIT_0:
- case TYPE_BIT_1:
- case TYPE_BIT_2:
- case TYPE_BIT_3:
- case TYPE_BIT_4:
- case TYPE_BIT_5:
- shift = d->type - TYPE_BIT_0;
- params[0] = BOOLEAN_TO_FLOAT((*(GLbitfield *) p >> shift) & 1);
- break;
- }
-}
-
-void GLAPIENTRY
-_mesa_GetIntegerv(GLenum pname, GLint *params)
-{
- const struct value_desc *d;
- union value v;
- GLmatrix *m;
- int shift, i;
- void *p;
-
- d = find_value("glGetIntegerv", pname, &p, &v);
- switch (d->type) {
- case TYPE_INVALID:
- break;
- case TYPE_CONST:
- params[0] = d->offset;
- break;
-
- case TYPE_FLOAT_4:
- params[3] = IROUND(((GLfloat *) p)[3]);
- case TYPE_FLOAT_3:
- params[2] = IROUND(((GLfloat *) p)[2]);
- case TYPE_FLOAT_2:
- params[1] = IROUND(((GLfloat *) p)[1]);
- case TYPE_FLOAT:
- params[0] = IROUND(((GLfloat *) p)[0]);
- break;
-
- case TYPE_FLOATN_4:
- params[3] = FLOAT_TO_INT(((GLfloat *) p)[3]);
- case TYPE_FLOATN_3:
- params[2] = FLOAT_TO_INT(((GLfloat *) p)[2]);
- case TYPE_FLOATN_2:
- params[1] = FLOAT_TO_INT(((GLfloat *) p)[1]);
- case TYPE_FLOATN:
- params[0] = FLOAT_TO_INT(((GLfloat *) p)[0]);
- break;
-
- case TYPE_DOUBLEN:
- params[0] = FLOAT_TO_INT(((GLdouble *) p)[0]);
- break;
-
- case TYPE_INT_4:
- params[3] = ((GLint *) p)[3];
- case TYPE_INT_3:
- params[2] = ((GLint *) p)[2];
- case TYPE_INT_2:
- case TYPE_ENUM_2:
- params[1] = ((GLint *) p)[1];
- case TYPE_INT:
- case TYPE_ENUM:
- params[0] = ((GLint *) p)[0];
- break;
-
- case TYPE_INT_N:
- for (i = 0; i < v.value_int_n.n; i++)
- params[i] = v.value_int_n.ints[i];
- break;
-
- case TYPE_INT64:
- params[0] = INT64_TO_INT(((GLint64 *) p)[0]);
- break;
-
- case TYPE_BOOLEAN:
- params[0] = BOOLEAN_TO_INT(*(GLboolean*) p);
- break;
-
- case TYPE_MATRIX:
- m = *(GLmatrix **) p;
- for (i = 0; i < 16; i++)
- params[i] = FLOAT_TO_INT(m->m[i]);
- break;
-
- case TYPE_MATRIX_T:
- m = *(GLmatrix **) p;
- for (i = 0; i < 16; i++)
- params[i] = FLOAT_TO_INT(m->m[transpose[i]]);
- break;
-
- case TYPE_BIT_0:
- case TYPE_BIT_1:
- case TYPE_BIT_2:
- case TYPE_BIT_3:
- case TYPE_BIT_4:
- case TYPE_BIT_5:
- shift = d->type - TYPE_BIT_0;
- params[0] = (*(GLbitfield *) p >> shift) & 1;
- break;
- }
-}
-
-#if FEATURE_ARB_sync
-void GLAPIENTRY
-_mesa_GetInteger64v(GLenum pname, GLint64 *params)
-{
- const struct value_desc *d;
- union value v;
- GLmatrix *m;
- int shift, i;
- void *p;
-
- d = find_value("glGetInteger64v", pname, &p, &v);
- switch (d->type) {
- case TYPE_INVALID:
- break;
- case TYPE_CONST:
- params[0] = d->offset;
- break;
-
- case TYPE_FLOAT_4:
- params[3] = IROUND64(((GLfloat *) p)[3]);
- case TYPE_FLOAT_3:
- params[2] = IROUND64(((GLfloat *) p)[2]);
- case TYPE_FLOAT_2:
- params[1] = IROUND64(((GLfloat *) p)[1]);
- case TYPE_FLOAT:
- params[0] = IROUND64(((GLfloat *) p)[0]);
- break;
-
- case TYPE_FLOATN_4:
- params[3] = FLOAT_TO_INT64(((GLfloat *) p)[3]);
- case TYPE_FLOATN_3:
- params[2] = FLOAT_TO_INT64(((GLfloat *) p)[2]);
- case TYPE_FLOATN_2:
- params[1] = FLOAT_TO_INT64(((GLfloat *) p)[1]);
- case TYPE_FLOATN:
- params[0] = FLOAT_TO_INT64(((GLfloat *) p)[0]);
- break;
-
- case TYPE_DOUBLEN:
- params[0] = FLOAT_TO_INT64(((GLdouble *) p)[0]);
- break;
-
- case TYPE_INT_4:
- params[3] = ((GLint *) p)[3];
- case TYPE_INT_3:
- params[2] = ((GLint *) p)[2];
- case TYPE_INT_2:
- case TYPE_ENUM_2:
- params[1] = ((GLint *) p)[1];
- case TYPE_INT:
- case TYPE_ENUM:
- params[0] = ((GLint *) p)[0];
- break;
-
- case TYPE_INT_N:
- for (i = 0; i < v.value_int_n.n; i++)
- params[i] = INT_TO_BOOLEAN(v.value_int_n.ints[i]);
- break;
-
- case TYPE_INT64:
- params[0] = ((GLint64 *) p)[0];
- break;
-
- case TYPE_BOOLEAN:
- params[0] = ((GLboolean*) p)[0];
- break;
-
- case TYPE_MATRIX:
- m = *(GLmatrix **) p;
- for (i = 0; i < 16; i++)
- params[i] = FLOAT_TO_INT64(m->m[i]);
- break;
-
- case TYPE_MATRIX_T:
- m = *(GLmatrix **) p;
- for (i = 0; i < 16; i++)
- params[i] = FLOAT_TO_INT64(m->m[transpose[i]]);
- break;
-
- case TYPE_BIT_0:
- case TYPE_BIT_1:
- case TYPE_BIT_2:
- case TYPE_BIT_3:
- case TYPE_BIT_4:
- case TYPE_BIT_5:
- shift = d->type - TYPE_BIT_0;
- params[0] = (*(GLbitfield *) p >> shift) & 1;
- break;
- }
-}
-#endif /* FEATURE_ARB_sync */
-
-void GLAPIENTRY
-_mesa_GetDoublev(GLenum pname, GLdouble *params)
-{
- const struct value_desc *d;
- union value v;
- GLmatrix *m;
- int shift, i;
- void *p;
-
- d = find_value("glGetDoublev", pname, &p, &v);
- switch (d->type) {
- case TYPE_INVALID:
- break;
- case TYPE_CONST:
- params[0] = d->offset;
- break;
-
- case TYPE_FLOAT_4:
- case TYPE_FLOATN_4:
- params[3] = ((GLfloat *) p)[3];
- case TYPE_FLOAT_3:
- case TYPE_FLOATN_3:
- params[2] = ((GLfloat *) p)[2];
- case TYPE_FLOAT_2:
- case TYPE_FLOATN_2:
- params[1] = ((GLfloat *) p)[1];
- case TYPE_FLOAT:
- case TYPE_FLOATN:
- params[0] = ((GLfloat *) p)[0];
- break;
-
- case TYPE_DOUBLEN:
- params[0] = ((GLdouble *) p)[0];
- break;
-
- case TYPE_INT_4:
- params[3] = ((GLint *) p)[3];
- case TYPE_INT_3:
- params[2] = ((GLint *) p)[2];
- case TYPE_INT_2:
- case TYPE_ENUM_2:
- params[1] = ((GLint *) p)[1];
- case TYPE_INT:
- case TYPE_ENUM:
- params[0] = ((GLint *) p)[0];
- break;
-
- case TYPE_INT_N:
- for (i = 0; i < v.value_int_n.n; i++)
- params[i] = v.value_int_n.ints[i];
- break;
-
- case TYPE_INT64:
- params[0] = ((GLint64 *) p)[0];
- break;
-
- case TYPE_BOOLEAN:
- params[0] = *(GLboolean*) p;
- break;
-
- case TYPE_MATRIX:
- m = *(GLmatrix **) p;
- for (i = 0; i < 16; i++)
- params[i] = m->m[i];
- break;
-
- case TYPE_MATRIX_T:
- m = *(GLmatrix **) p;
- for (i = 0; i < 16; i++)
- params[i] = m->m[transpose[i]];
- break;
-
- case TYPE_BIT_0:
- case TYPE_BIT_1:
- case TYPE_BIT_2:
- case TYPE_BIT_3:
- case TYPE_BIT_4:
- case TYPE_BIT_5:
- shift = d->type - TYPE_BIT_0;
- params[0] = (*(GLbitfield *) p >> shift) & 1;
- break;
- }
-}
-
-static enum value_type
-find_value_indexed(const char *func, GLenum pname, int index, union value *v)
-{
- GET_CURRENT_CONTEXT(ctx);
-
- switch (pname) {
-
- case GL_BLEND:
- if (index >= ctx->Const.MaxDrawBuffers)
- goto invalid_value;
- if (!ctx->Extensions.EXT_draw_buffers2)
- goto invalid_enum;
- v->value_int = (ctx->Color.BlendEnabled >> index) & 1;
- return TYPE_INT;
-
- case GL_COLOR_WRITEMASK:
- if (index >= ctx->Const.MaxDrawBuffers)
- goto invalid_value;
- if (!ctx->Extensions.EXT_draw_buffers2)
- goto invalid_enum;
- v->value_int_4[0] = ctx->Color.ColorMask[index][RCOMP] ? 1 : 0;
- v->value_int_4[1] = ctx->Color.ColorMask[index][GCOMP] ? 1 : 0;
- v->value_int_4[2] = ctx->Color.ColorMask[index][BCOMP] ? 1 : 0;
- v->value_int_4[3] = ctx->Color.ColorMask[index][ACOMP] ? 1 : 0;
- return TYPE_INT_4;
-
- case GL_TRANSFORM_FEEDBACK_BUFFER_START:
- if (index >= ctx->Const.MaxTransformFeedbackSeparateAttribs)
- goto invalid_value;
- if (!ctx->Extensions.EXT_transform_feedback)
- goto invalid_enum;
- v->value_int64 = ctx->TransformFeedback.CurrentObject->Offset[index];
- return TYPE_INT64;
-
- case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE:
- if (index >= ctx->Const.MaxTransformFeedbackSeparateAttribs)
- goto invalid_value;
- if (!ctx->Extensions.EXT_transform_feedback)
- goto invalid_enum;
- v->value_int64 = ctx->TransformFeedback.CurrentObject->Size[index];
- return TYPE_INT64;
-
- case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING:
- if (index >= ctx->Const.MaxTransformFeedbackSeparateAttribs)
- goto invalid_value;
- if (!ctx->Extensions.EXT_transform_feedback)
- goto invalid_enum;
- v->value_int = ctx->TransformFeedback.CurrentObject->Buffers[index]->Name;
- return TYPE_INT;
- }
-
- invalid_enum:
- _mesa_error(ctx, GL_INVALID_ENUM, "%s(pname=%s)", func,
- _mesa_lookup_enum_by_nr(pname));
- return TYPE_INVALID;
- invalid_value:
- _mesa_error(ctx, GL_INVALID_VALUE, "%s(pname=%s)", func,
- _mesa_lookup_enum_by_nr(pname));
- return TYPE_INVALID;
-}
-
-void GLAPIENTRY
-_mesa_GetBooleanIndexedv( GLenum pname, GLuint index, GLboolean *params )
-{
- union value v;
-
- switch (find_value_indexed("glGetBooleanIndexedv", pname, index, &v)) {
- case TYPE_INT:
- params[0] = INT_TO_BOOLEAN(v.value_int);
- break;
- case TYPE_INT_4:
- params[0] = INT_TO_BOOLEAN(v.value_int_4[0]);
- params[1] = INT_TO_BOOLEAN(v.value_int_4[1]);
- params[2] = INT_TO_BOOLEAN(v.value_int_4[2]);
- params[3] = INT_TO_BOOLEAN(v.value_int_4[3]);
- break;
- case TYPE_INT64:
- params[0] = INT64_TO_BOOLEAN(v.value_int);
- break;
- default:
- assert(0);
- }
-}
-
-void GLAPIENTRY
-_mesa_GetIntegerIndexedv( GLenum pname, GLuint index, GLint *params )
-{
- union value v;
-
- switch (find_value_indexed("glGetIntegerIndexedv", pname, index, &v)) {
- case TYPE_INT:
- params[0] = v.value_int;
- break;
- case TYPE_INT_4:
- params[0] = v.value_int_4[0];
- params[1] = v.value_int_4[1];
- params[2] = v.value_int_4[2];
- params[3] = v.value_int_4[3];
- break;
- case TYPE_INT64:
- params[0] = INT64_TO_INT(v.value_int);
- break;
- default:
- assert(0);
- }
-}
-
-#if FEATURE_ARB_sync
-void GLAPIENTRY
-_mesa_GetInteger64Indexedv( GLenum pname, GLuint index, GLint64 *params )
-{
- union value v;
-
- switch (find_value_indexed("glGetIntegerIndexedv", pname, index, &v)) {
- case TYPE_INT:
- params[0] = v.value_int;
- break;
- case TYPE_INT_4:
- params[0] = v.value_int_4[0];
- params[1] = v.value_int_4[1];
- params[2] = v.value_int_4[2];
- params[3] = v.value_int_4[3];
- break;
- case TYPE_INT64:
- params[0] = v.value_int;
- break;
- default:
- assert(0);
- }
-}
-#endif /* FEATURE_ARB_sync */
-
-#if FEATURE_ES1
-void GLAPIENTRY
-_mesa_GetFixedv(GLenum pname, GLfixed *params)
-{
- const struct value_desc *d;
- union value v;
- GLmatrix *m;
- int shift, i;
- void *p;
-
- d = find_value("glGetDoublev", pname, &p, &v);
- switch (d->type) {
- case TYPE_INVALID:
- break;
- case TYPE_CONST:
- params[0] = INT_TO_FIXED(d->offset);
- break;
-
- case TYPE_FLOAT_4:
- case TYPE_FLOATN_4:
- params[3] = FLOAT_TO_FIXED(((GLfloat *) p)[3]);
- case TYPE_FLOAT_3:
- case TYPE_FLOATN_3:
- params[2] = FLOAT_TO_FIXED(((GLfloat *) p)[2]);
- case TYPE_FLOAT_2:
- case TYPE_FLOATN_2:
- params[1] = FLOAT_TO_FIXED(((GLfloat *) p)[1]);
- case TYPE_FLOAT:
- case TYPE_FLOATN:
- params[0] = FLOAT_TO_FIXED(((GLfloat *) p)[0]);
- break;
-
- case TYPE_DOUBLEN:
- params[0] = FLOAT_TO_FIXED(((GLdouble *) p)[0]);
- break;
-
- case TYPE_INT_4:
- params[3] = INT_TO_FIXED(((GLint *) p)[3]);
- case TYPE_INT_3:
- params[2] = INT_TO_FIXED(((GLint *) p)[2]);
- case TYPE_INT_2:
- case TYPE_ENUM_2:
- params[1] = INT_TO_FIXED(((GLint *) p)[1]);
- case TYPE_INT:
- case TYPE_ENUM:
- params[0] = INT_TO_FIXED(((GLint *) p)[0]);
- break;
-
- case TYPE_INT_N:
- for (i = 0; i < v.value_int_n.n; i++)
- params[i] = INT_TO_FIXED(v.value_int_n.ints[i]);
- break;
-
- case TYPE_INT64:
- params[0] = ((GLint64 *) p)[0];
- break;
-
- case TYPE_BOOLEAN:
- params[0] = BOOLEAN_TO_FIXED(((GLboolean*) p)[0]);
- break;
-
- case TYPE_MATRIX:
- m = *(GLmatrix **) p;
- for (i = 0; i < 16; i++)
- params[i] = FLOAT_TO_FIXED(m->m[i]);
- break;
-
- case TYPE_MATRIX_T:
- m = *(GLmatrix **) p;
- for (i = 0; i < 16; i++)
- params[i] = FLOAT_TO_FIXED(m->m[transpose[i]]);
- break;
-
- case TYPE_BIT_0:
- case TYPE_BIT_1:
- case TYPE_BIT_2:
- case TYPE_BIT_3:
- case TYPE_BIT_4:
- case TYPE_BIT_5:
- shift = d->type - TYPE_BIT_0;
- params[0] = BOOLEAN_TO_FIXED((*(GLbitfield *) p >> shift) & 1);
- break;
- }
-}
-#endif
diff --git a/src/mesa/main/getstring.c b/src/mesa/main/getstring.c
deleted file mode 100644
index bfa283f..0000000
--- a/src/mesa/main/getstring.c
+++ /dev/null
@@ -1,251 +0,0 @@
-/*
- * 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.
- */
-
-
-
-#include "glheader.h"
-#include "context.h"
-#include "get.h"
-#include "enums.h"
-#include "extensions.h"
-
-
-/**
- * Return the string for a glGetString(GL_SHADING_LANGUAGE_VERSION) query.
- */
-static const GLubyte *
-shading_language_version(struct gl_context *ctx)
-{
- switch (ctx->API) {
- case API_OPENGL:
- if (!ctx->Extensions.ARB_shader_objects) {
- _mesa_error(ctx, GL_INVALID_ENUM, "glGetString");
- return (const GLubyte *) 0;
- }
-
- switch (ctx->Const.GLSLVersion) {
- case 110:
- return (const GLubyte *) "1.10";
- case 120:
- return (const GLubyte *) "1.20";
- case 130:
- return (const GLubyte *) "1.30";
- default:
- _mesa_problem(ctx,
- "Invalid GLSL version in shading_language_version()");
- return (const GLubyte *) 0;
- }
- break;
-
- case API_OPENGLES2:
- return (const GLubyte *) "OpenGL ES GLSL ES 1.0.16";
-
- case API_OPENGLES:
- /* fall-through */
-
- default:
- _mesa_problem(ctx, "Unexpected API value in shading_language_version()");
- return (const GLubyte *) 0;
- }
-}
-
-
-/**
- * Query string-valued state. The return value should _not_ be freed by
- * the caller.
- *
- * \param name the state variable to query.
- *
- * \sa glGetString().
- *
- * Tries to get the string from dd_function_table::GetString, otherwise returns
- * the hardcoded strings.
- */
-const GLubyte * GLAPIENTRY
-_mesa_GetString( GLenum name )
-{
- GET_CURRENT_CONTEXT(ctx);
- static const char *vendor = "Brian Paul";
- static const char *renderer = "Mesa";
-
- if (!ctx)
- return NULL;
-
- ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, NULL);
-
- /* this is a required driver function */
- assert(ctx->Driver.GetString);
- {
- /* Give the driver the chance to handle this query */
- const GLubyte *str = (*ctx->Driver.GetString)(ctx, name);
- if (str)
- return str;
- }
-
- switch (name) {
- case GL_VENDOR:
- return (const GLubyte *) vendor;
- case GL_RENDERER:
- return (const GLubyte *) renderer;
- case GL_VERSION:
- return (const GLubyte *) ctx->VersionString;
- case GL_EXTENSIONS:
- return (const GLubyte *) ctx->Extensions.String;
-#if FEATURE_ARB_shading_language_100 || FEATURE_ES2
- case GL_SHADING_LANGUAGE_VERSION:
- return shading_language_version(ctx);
-#endif
-#if FEATURE_NV_fragment_program || FEATURE_ARB_fragment_program || \
- FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program
- case GL_PROGRAM_ERROR_STRING_NV:
- if (ctx->Extensions.NV_fragment_program ||
- ctx->Extensions.ARB_fragment_program ||
- ctx->Extensions.NV_vertex_program ||
- ctx->Extensions.ARB_vertex_program) {
- return (const GLubyte *) ctx->Program.ErrorString;
- }
- /* FALL-THROUGH */
-#endif
- default:
- _mesa_error( ctx, GL_INVALID_ENUM, "glGetString" );
- return (const GLubyte *) 0;
- }
-}
-
-
-/**
- * GL3
- */
-const GLubyte * GLAPIENTRY
-_mesa_GetStringi(GLenum name, GLuint index)
-{
- GET_CURRENT_CONTEXT(ctx);
-
- if (!ctx)
- return NULL;
-
- ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, NULL);
-
- switch (name) {
- case GL_EXTENSIONS:
- if (index >= _mesa_get_extension_count(ctx)) {
- _mesa_error(ctx, GL_INVALID_VALUE, "glGetStringi(index=%u)", index);
- return (const GLubyte *) 0;
- }
- return _mesa_get_enabled_extension(ctx, index);
- default:
- _mesa_error( ctx, GL_INVALID_ENUM, "glGetString" );
- return (const GLubyte *) 0;
- }
-}
-
-
-
-/**
- * Return pointer-valued state, such as a vertex array pointer.
- *
- * \param pname names state to be queried
- * \param params returns the pointer value
- *
- * \sa glGetPointerv().
- *
- * Tries to get the specified pointer via dd_function_table::GetPointerv,
- * otherwise gets the specified pointer from the current context.
- */
-void GLAPIENTRY
-_mesa_GetPointerv( GLenum pname, GLvoid **params )
-{
- GET_CURRENT_CONTEXT(ctx);
- const GLuint clientUnit = ctx->Array.ActiveTexture;
- ASSERT_OUTSIDE_BEGIN_END(ctx);
-
- if (!params)
- return;
-
- if (MESA_VERBOSE & VERBOSE_API)
- _mesa_debug(ctx, "glGetPointerv %s\n", _mesa_lookup_enum_by_nr(pname));
-
- switch (pname) {
- case GL_VERTEX_ARRAY_POINTER:
- *params = (GLvoid *) ctx->Array.ArrayObj->Vertex.Ptr;
- break;
- case GL_NORMAL_ARRAY_POINTER:
- *params = (GLvoid *) ctx->Array.ArrayObj->Normal.Ptr;
- break;
- case GL_COLOR_ARRAY_POINTER:
- *params = (GLvoid *) ctx->Array.ArrayObj->Color.Ptr;
- break;
- case GL_SECONDARY_COLOR_ARRAY_POINTER_EXT:
- *params = (GLvoid *) ctx->Array.ArrayObj->SecondaryColor.Ptr;
- break;
- case GL_FOG_COORDINATE_ARRAY_POINTER_EXT:
- *params = (GLvoid *) ctx->Array.ArrayObj->FogCoord.Ptr;
- break;
- case GL_INDEX_ARRAY_POINTER:
- *params = (GLvoid *) ctx->Array.ArrayObj->Index.Ptr;
- break;
- case GL_TEXTURE_COORD_ARRAY_POINTER:
- *params = (GLvoid *) ctx->Array.ArrayObj->TexCoord[clientUnit].Ptr;
- break;
- case GL_EDGE_FLAG_ARRAY_POINTER:
- *params = (GLvoid *) ctx->Array.ArrayObj->EdgeFlag.Ptr;
- break;
- case GL_FEEDBACK_BUFFER_POINTER:
- *params = ctx->Feedback.Buffer;
- break;
- case GL_SELECTION_BUFFER_POINTER:
- *params = ctx->Select.Buffer;
- break;
-#if FEATURE_point_size_array
- case GL_POINT_SIZE_ARRAY_POINTER_OES:
- *params = (GLvoid *) ctx->Array.ArrayObj->PointSize.Ptr;
- break;
-#endif
- default:
- _mesa_error( ctx, GL_INVALID_ENUM, "glGetPointerv" );
- return;
- }
-}
-
-
-/**
- * Returns the current GL error code, or GL_NO_ERROR.
- * \return current error code
- *
- * Returns __struct gl_contextRec::ErrorValue.
- */
-GLenum GLAPIENTRY
-_mesa_GetError( void )
-{
- GET_CURRENT_CONTEXT(ctx);
- GLenum e = ctx->ErrorValue;
- ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, 0);
-
- if (MESA_VERBOSE & VERBOSE_API)
- _mesa_debug(ctx, "glGetError <-- %s\n", _mesa_lookup_enum_by_nr(e));
-
- ctx->ErrorValue = (GLenum) GL_NO_ERROR;
- ctx->ErrorDebugCount = 0;
- return e;
-}
diff --git a/src/mesa/main/hash.c b/src/mesa/main/hash.c
deleted file mode 100644
index 72d924d..0000000
--- a/src/mesa/main/hash.c
+++ /dev/null
@@ -1,547 +0,0 @@
-/**
- * \file hash.c
- * Generic hash table.
- *
- * Used for display lists, texture objects, vertex/fragment programs,
- * buffer objects, etc. The hash functions are thread-safe.
- *
- * \note key=0 is illegal.
- *
- * \author Brian Paul
- */
-
-/*
- * Mesa 3-D graphics library
- * Version: 6.5.1
- *
- * Copyright (C) 1999-2006 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.
- */
-
-
-#include "glheader.h"
-#include "imports.h"
-#include "glapi/glthread.h"
-#include "hash.h"
-
-
-#define TABLE_SIZE 1023 /**< Size of lookup table/array */
-
-#define HASH_FUNC(K) ((K) % TABLE_SIZE)
-
-
-/**
- * An entry in the hash table.
- */
-struct HashEntry {
- GLuint Key; /**< the entry's key */
- void *Data; /**< the entry's data */
- struct HashEntry *Next; /**< pointer to next entry */
-};
-
-
-/**
- * The hash table data structure.
- */
-struct _mesa_HashTable {
- struct HashEntry *Table[TABLE_SIZE]; /**< the lookup table */
- GLuint MaxKey; /**< highest key inserted so far */
- _glthread_Mutex Mutex; /**< mutual exclusion lock */
- _glthread_Mutex WalkMutex; /**< for _mesa_HashWalk() */
- GLboolean InDeleteAll; /**< Debug check */
-};
-
-
-
-/**
- * Create a new hash table.
- *
- * \return pointer to a new, empty hash table.
- */
-struct _mesa_HashTable *
-_mesa_NewHashTable(void)
-{
- struct _mesa_HashTable *table = CALLOC_STRUCT(_mesa_HashTable);
- if (table) {
- _glthread_INIT_MUTEX(table->Mutex);
- _glthread_INIT_MUTEX(table->WalkMutex);
- }
- return table;
-}
-
-
-
-/**
- * Delete a hash table.
- * Frees each entry on the hash table and then the hash table structure itself.
- * Note that the caller should have already traversed the table and deleted
- * the objects in the table (i.e. We don't free the entries' data pointer).
- *
- * \param table the hash table to delete.
- */
-void
-_mesa_DeleteHashTable(struct _mesa_HashTable *table)
-{
- GLuint pos;
- assert(table);
- for (pos = 0; pos < TABLE_SIZE; pos++) {
- struct HashEntry *entry = table->Table[pos];
- while (entry) {
- struct HashEntry *next = entry->Next;
- if (entry->Data) {
- _mesa_problem(NULL,
- "In _mesa_DeleteHashTable, found non-freed data");
- }
- free(entry);
- entry = next;
- }
- }
- _glthread_DESTROY_MUTEX(table->Mutex);
- _glthread_DESTROY_MUTEX(table->WalkMutex);
- free(table);
-}
-
-
-
-/**
- * Lookup an entry in the hash table, without locking.
- * \sa _mesa_HashLookup
- */
-static INLINE void *
-_mesa_HashLookup_unlocked(struct _mesa_HashTable *table, GLuint key)
-{
- GLuint pos;
- const struct HashEntry *entry;
-
- assert(table);
- assert(key);
-
- pos = HASH_FUNC(key);
- entry = table->Table[pos];
- while (entry) {
- if (entry->Key == key) {
- return entry->Data;
- }
- entry = entry->Next;
- }
- return NULL;
-}
-
-
-/**
- * Lookup an entry in the hash table.
- *
- * \param table the hash table.
- * \param key the key.
- *
- * \return pointer to user's data or NULL if key not in table
- */
-void *
-_mesa_HashLookup(struct _mesa_HashTable *table, GLuint key)
-{
- void *res;
- assert(table);
- _glthread_LOCK_MUTEX(table->Mutex);
- res = _mesa_HashLookup_unlocked(table, key);
- _glthread_UNLOCK_MUTEX(table->Mutex);
- return res;
-}
-
-
-/**
- * Insert a key/pointer pair into the hash table.
- * If an entry with this key already exists we'll replace the existing entry.
- *
- * \param table the hash table.
- * \param key the key (not zero).
- * \param data pointer to user data.
- */
-void
-_mesa_HashInsert(struct _mesa_HashTable *table, GLuint key, void *data)
-{
- /* search for existing entry with this key */
- GLuint pos;
- struct HashEntry *entry;
-
- assert(table);
- assert(key);
-
- _glthread_LOCK_MUTEX(table->Mutex);
-
- if (key > table->MaxKey)
- table->MaxKey = key;
-
- pos = HASH_FUNC(key);
-
- /* check if replacing an existing entry with same key */
- for (entry = table->Table[pos]; entry; entry = entry->Next) {
- if (entry->Key == key) {
- /* replace entry's data */
-#if 0 /* not sure this check is always valid */
- if (entry->Data) {
- _mesa_problem(NULL, "Memory leak detected in _mesa_HashInsert");
- }
-#endif
- entry->Data = data;
- _glthread_UNLOCK_MUTEX(table->Mutex);
- return;
- }
- }
-
- /* alloc and insert new table entry */
- entry = MALLOC_STRUCT(HashEntry);
- if (entry) {
- entry->Key = key;
- entry->Data = data;
- entry->Next = table->Table[pos];
- table->Table[pos] = entry;
- }
-
- _glthread_UNLOCK_MUTEX(table->Mutex);
-}
-
-
-
-/**
- * Remove an entry from the hash table.
- *
- * \param table the hash table.
- * \param key key of entry to remove.
- *
- * While holding the hash table's lock, searches the entry with the matching
- * key and unlinks it.
- */
-void
-_mesa_HashRemove(struct _mesa_HashTable *table, GLuint key)
-{
- GLuint pos;
- struct HashEntry *entry, *prev;
-
- assert(table);
- assert(key);
-
- /* have to check this outside of mutex lock */
- if (table->InDeleteAll) {
- _mesa_problem(NULL, "_mesa_HashRemove illegally called from "
- "_mesa_HashDeleteAll callback function");
- return;
- }
-
- _glthread_LOCK_MUTEX(table->Mutex);
-
- pos = HASH_FUNC(key);
- prev = NULL;
- entry = table->Table[pos];
- while (entry) {
- if (entry->Key == key) {
- /* found it! */
- if (prev) {
- prev->Next = entry->Next;
- }
- else {
- table->Table[pos] = entry->Next;
- }
- free(entry);
- _glthread_UNLOCK_MUTEX(table->Mutex);
- return;
- }
- prev = entry;
- entry = entry->Next;
- }
-
- _glthread_UNLOCK_MUTEX(table->Mutex);
-}
-
-
-
-/**
- * Delete all entries in a hash table, but don't delete the table itself.
- * Invoke the given callback function for each table entry.
- *
- * \param table the hash table to delete
- * \param callback the callback function
- * \param userData arbitrary pointer to pass along to the callback
- * (this is typically a struct gl_context pointer)
- */
-void
-_mesa_HashDeleteAll(struct _mesa_HashTable *table,
- void (*callback)(GLuint key, void *data, void *userData),
- void *userData)
-{
- GLuint pos;
- ASSERT(table);
- ASSERT(callback);
- _glthread_LOCK_MUTEX(table->Mutex);
- table->InDeleteAll = GL_TRUE;
- for (pos = 0; pos < TABLE_SIZE; pos++) {
- struct HashEntry *entry, *next;
- for (entry = table->Table[pos]; entry; entry = next) {
- callback(entry->Key, entry->Data, userData);
- next = entry->Next;
- free(entry);
- }
- table->Table[pos] = NULL;
- }
- table->InDeleteAll = GL_FALSE;
- _glthread_UNLOCK_MUTEX(table->Mutex);
-}
-
-
-/**
- * Walk over all entries in a hash table, calling callback function for each.
- * Note: we use a separate mutex in this function to avoid a recursive
- * locking deadlock (in case the callback calls _mesa_HashRemove()) and to
- * prevent multiple threads/contexts from getting tangled up.
- * A lock-less version of this function could be used when the table will
- * not be modified.
- * \param table the hash table to walk
- * \param callback the callback function
- * \param userData arbitrary pointer to pass along to the callback
- * (this is typically a struct gl_context pointer)
- */
-void
-_mesa_HashWalk(const struct _mesa_HashTable *table,
- void (*callback)(GLuint key, void *data, void *userData),
- void *userData)
-{
- /* cast-away const */
- struct _mesa_HashTable *table2 = (struct _mesa_HashTable *) table;
- GLuint pos;
- ASSERT(table);
- ASSERT(callback);
- _glthread_LOCK_MUTEX(table2->WalkMutex);
- for (pos = 0; pos < TABLE_SIZE; pos++) {
- struct HashEntry *entry, *next;
- for (entry = table->Table[pos]; entry; entry = next) {
- /* save 'next' pointer now in case the callback deletes the entry */
- next = entry->Next;
- callback(entry->Key, entry->Data, userData);
- }
- }
- _glthread_UNLOCK_MUTEX(table2->WalkMutex);
-}
-
-
-/**
- * Return the key of the "first" entry in the hash table.
- * While holding the lock, walks through all table positions until finding
- * the first entry of the first non-empty one.
- *
- * \param table the hash table
- * \return key for the "first" entry in the hash table.
- */
-GLuint
-_mesa_HashFirstEntry(struct _mesa_HashTable *table)
-{
- GLuint pos;
- assert(table);
- _glthread_LOCK_MUTEX(table->Mutex);
- for (pos = 0; pos < TABLE_SIZE; pos++) {
- if (table->Table[pos]) {
- _glthread_UNLOCK_MUTEX(table->Mutex);
- return table->Table[pos]->Key;
- }
- }
- _glthread_UNLOCK_MUTEX(table->Mutex);
- return 0;
-}
-
-
-/**
- * Given a hash table key, return the next key. This is used to walk
- * over all entries in the table. Note that the keys returned during
- * walking won't be in any particular order.
- * \return next hash key or 0 if end of table.
- */
-GLuint
-_mesa_HashNextEntry(const struct _mesa_HashTable *table, GLuint key)
-{
- const struct HashEntry *entry;
- GLuint pos;
-
- assert(table);
- assert(key);
-
- /* Find the entry with given key */
- pos = HASH_FUNC(key);
- for (entry = table->Table[pos]; entry ; entry = entry->Next) {
- if (entry->Key == key) {
- break;
- }
- }
-
- if (!entry) {
- /* the given key was not found, so we can't find the next entry */
- return 0;
- }
-
- if (entry->Next) {
- /* return next in linked list */
- return entry->Next->Key;
- }
- else {
- /* look for next non-empty table slot */
- pos++;
- while (pos < TABLE_SIZE) {
- if (table->Table[pos]) {
- return table->Table[pos]->Key;
- }
- pos++;
- }
- return 0;
- }
-}
-
-
-/**
- * Dump contents of hash table for debugging.
- *
- * \param table the hash table.
- */
-void
-_mesa_HashPrint(const struct _mesa_HashTable *table)
-{
- GLuint pos;
- assert(table);
- for (pos = 0; pos < TABLE_SIZE; pos++) {
- const struct HashEntry *entry = table->Table[pos];
- while (entry) {
- _mesa_debug(NULL, "%u %p\n", entry->Key, entry->Data);
- entry = entry->Next;
- }
- }
-}
-
-
-
-/**
- * Find a block of adjacent unused hash keys.
- *
- * \param table the hash table.
- * \param numKeys number of keys needed.
- *
- * \return Starting key of free block or 0 if failure.
- *
- * If there are enough free keys between the maximum key existing in the table
- * (_mesa_HashTable::MaxKey) and the maximum key possible, then simply return
- * the adjacent key. Otherwise do a full search for a free key block in the
- * allowable key range.
- */
-GLuint
-_mesa_HashFindFreeKeyBlock(struct _mesa_HashTable *table, GLuint numKeys)
-{
- const GLuint maxKey = ~((GLuint) 0);
- _glthread_LOCK_MUTEX(table->Mutex);
- if (maxKey - numKeys > table->MaxKey) {
- /* the quick solution */
- _glthread_UNLOCK_MUTEX(table->Mutex);
- return table->MaxKey + 1;
- }
- else {
- /* the slow solution */
- GLuint freeCount = 0;
- GLuint freeStart = 1;
- GLuint key;
- for (key = 1; key != maxKey; key++) {
- if (_mesa_HashLookup_unlocked(table, key)) {
- /* darn, this key is already in use */
- freeCount = 0;
- freeStart = key+1;
- }
- else {
- /* this key not in use, check if we've found enough */
- freeCount++;
- if (freeCount == numKeys) {
- _glthread_UNLOCK_MUTEX(table->Mutex);
- return freeStart;
- }
- }
- }
- /* cannot allocate a block of numKeys consecutive keys */
- _glthread_UNLOCK_MUTEX(table->Mutex);
- return 0;
- }
-}
-
-
-#if 0 /* debug only */
-
-/**
- * Test walking over all the entries in a hash table.
- */
-static void
-test_hash_walking(void)
-{
- struct _mesa_HashTable *t = _mesa_NewHashTable();
- const GLuint limit = 50000;
- GLuint i;
-
- /* create some entries */
- for (i = 0; i < limit; i++) {
- GLuint dummy;
- GLuint k = (rand() % (limit * 10)) + 1;
- while (_mesa_HashLookup(t, k)) {
- /* id already in use, try another */
- k = (rand() % (limit * 10)) + 1;
- }
- _mesa_HashInsert(t, k, &dummy);
- }
-
- /* walk over all entries */
- {
- GLuint k = _mesa_HashFirstEntry(t);
- GLuint count = 0;
- while (k) {
- GLuint knext = _mesa_HashNextEntry(t, k);
- assert(knext != k);
- _mesa_HashRemove(t, k);
- count++;
- k = knext;
- }
- assert(count == limit);
- k = _mesa_HashFirstEntry(t);
- assert(k==0);
- }
-
- _mesa_DeleteHashTable(t);
-}
-
-
-void
-_mesa_test_hash_functions(void)
-{
- int a, b, c;
- struct _mesa_HashTable *t;
-
- t = _mesa_NewHashTable();
- _mesa_HashInsert(t, 501, &a);
- _mesa_HashInsert(t, 10, &c);
- _mesa_HashInsert(t, 0xfffffff8, &b);
- /*_mesa_HashPrint(t);*/
-
- assert(_mesa_HashLookup(t,501));
- assert(!_mesa_HashLookup(t,1313));
- assert(_mesa_HashFindFreeKeyBlock(t, 100));
-
- _mesa_DeleteHashTable(t);
-
- test_hash_walking();
-}
-
-#endif
diff --git a/src/mesa/main/imports.c b/src/mesa/main/imports.c
deleted file mode 100644
index cefbf4d..0000000
--- a/src/mesa/main/imports.c
+++ /dev/null
@@ -1,1032 +0,0 @@
-/**
- * \file imports.c
- * Standard C library function wrappers.
- *
- * Imports are services which the device driver or window system or
- * operating system provides to the core renderer. The core renderer (Mesa)
- * will call these functions in order to do memory allocation, simple I/O,
- * etc.
- *
- * Some drivers will want to override/replace this file with something
- * specialized, but that'll be rare.
- *
- * Eventually, I want to move roll the glheader.h file into this.
- *
- * \todo Functions still needed:
- * - scanf
- * - qsort
- * - rand and RAND_MAX
- */
-
-/*
- * Mesa 3-D graphics library
- * Version: 7.1
- *
- * Copyright (C) 1999-2007 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.
- */
-
-
-
-#include "imports.h"
-#include "context.h"
-#include "version.h"
-
-#ifdef _GNU_SOURCE
-#include <locale.h>
-#ifdef __APPLE__
-#include <xlocale.h>
-#endif
-#endif
-
-
-#define MAXSTRING 4000 /* for vsnprintf() */
-
-#ifdef WIN32
-#define vsnprintf _vsnprintf
-#elif defined(__IBMC__) || defined(__IBMCPP__) || ( defined(__VMS) && __CRTL_VER < 70312000 )
-extern int vsnprintf(char *str, size_t count, const char *fmt, va_list arg);
-#ifdef __VMS
-#include "vsnprintf.c"
-#endif
-#endif
-
-/**********************************************************************/
-/** \name Memory */
-/*@{*/
-
-/**
- * Allocate aligned memory.
- *
- * \param bytes number of bytes to allocate.
- * \param alignment alignment (must be greater than zero).
- *
- * Allocates extra memory to accommodate rounding up the address for
- * alignment and to record the real malloc address.
- *
- * \sa _mesa_align_free().
- */
-void *
-_mesa_align_malloc(size_t bytes, unsigned long alignment)
-{
-#if defined(HAVE_POSIX_MEMALIGN)
- void *mem;
- int err = posix_memalign(& mem, alignment, bytes);
- if (err)
- return NULL;
- return mem;
-#elif defined(_WIN32) && defined(_MSC_VER)
- return _aligned_malloc(bytes, alignment);
-#else
- uintptr_t ptr, buf;
-
- ASSERT( alignment > 0 );
-
- ptr = (uintptr_t) malloc(bytes + alignment + sizeof(void *));
- if (!ptr)
- return NULL;
-
- buf = (ptr + alignment + sizeof(void *)) & ~(uintptr_t)(alignment - 1);
- *(uintptr_t *)(buf - sizeof(void *)) = ptr;
-
-#ifdef DEBUG
- /* mark the non-aligned area */
- while ( ptr < buf - sizeof(void *) ) {
- *(unsigned long *)ptr = 0xcdcdcdcd;
- ptr += sizeof(unsigned long);
- }
-#endif
-
- return (void *) buf;
-#endif /* defined(HAVE_POSIX_MEMALIGN) */
-}
-
-/**
- * Same as _mesa_align_malloc(), but using calloc(1, ) instead of
- * malloc()
- */
-void *
-_mesa_align_calloc(size_t bytes, unsigned long alignment)
-{
-#if defined(HAVE_POSIX_MEMALIGN)
- void *mem;
-
- mem = _mesa_align_malloc(bytes, alignment);
- if (mem != NULL) {
- (void) memset(mem, 0, bytes);
- }
-
- return mem;
-#elif defined(_WIN32) && defined(_MSC_VER)
- void *mem;
-
- mem = _aligned_malloc(bytes, alignment);
- if (mem != NULL) {
- (void) memset(mem, 0, bytes);
- }
-
- return mem;
-#else
- uintptr_t ptr, buf;
-
- ASSERT( alignment > 0 );
-
- ptr = (uintptr_t) calloc(1, bytes + alignment + sizeof(void *));
- if (!ptr)
- return NULL;
-
- buf = (ptr + alignment + sizeof(void *)) & ~(uintptr_t)(alignment - 1);
- *(uintptr_t *)(buf - sizeof(void *)) = ptr;
-
-#ifdef DEBUG
- /* mark the non-aligned area */
- while ( ptr < buf - sizeof(void *) ) {
- *(unsigned long *)ptr = 0xcdcdcdcd;
- ptr += sizeof(unsigned long);
- }
-#endif
-
- return (void *)buf;
-#endif /* defined(HAVE_POSIX_MEMALIGN) */
-}
-
-/**
- * Free memory which was allocated with either _mesa_align_malloc()
- * or _mesa_align_calloc().
- * \param ptr pointer to the memory to be freed.
- * The actual address to free is stored in the word immediately before the
- * address the client sees.
- */
-void
-_mesa_align_free(void *ptr)
-{
-#if defined(HAVE_POSIX_MEMALIGN)
- free(ptr);
-#elif defined(_WIN32) && defined(_MSC_VER)
- _aligned_free(ptr);
-#else
- void **cubbyHole = (void **) ((char *) ptr - sizeof(void *));
- void *realAddr = *cubbyHole;
- free(realAddr);
-#endif /* defined(HAVE_POSIX_MEMALIGN) */
-}
-
-/**
- * Reallocate memory, with alignment.
- */
-void *
-_mesa_align_realloc(void *oldBuffer, size_t oldSize, size_t newSize,
- unsigned long alignment)
-{
-#if defined(_WIN32) && defined(_MSC_VER)
- (void) oldSize;
- return _aligned_realloc(oldBuffer, newSize, alignment);
-#else
- const size_t copySize = (oldSize < newSize) ? oldSize : newSize;
- void *newBuf = _mesa_align_malloc(newSize, alignment);
- if (newBuf && oldBuffer && copySize > 0) {
- memcpy(newBuf, oldBuffer, copySize);
- }
- if (oldBuffer)
- _mesa_align_free(oldBuffer);
- return newBuf;
-#endif
-}
-
-
-
-/** Reallocate memory */
-void *
-_mesa_realloc(void *oldBuffer, size_t oldSize, size_t newSize)
-{
- const size_t copySize = (oldSize < newSize) ? oldSize : newSize;
- void *newBuffer = malloc(newSize);
- if (newBuffer && oldBuffer && copySize > 0)
- memcpy(newBuffer, oldBuffer, copySize);
- if (oldBuffer)
- free(oldBuffer);
- return newBuffer;
-}
-
-/**
- * Fill memory with a constant 16bit word.
- * \param dst destination pointer.
- * \param val value.
- * \param n number of words.
- */
-void
-_mesa_memset16( unsigned short *dst, unsigned short val, size_t n )
-{
- while (n-- > 0)
- *dst++ = val;
-}
-
-/*@}*/
-
-
-/**********************************************************************/
-/** \name Math */
-/*@{*/
-
-/** Wrapper around sqrt() */
-double
-_mesa_sqrtd(double x)
-{
- return sqrt(x);
-}
-
-
-/*
- * A High Speed, Low Precision Square Root
- * by Paul Lalonde and Robert Dawson
- * from "Graphics Gems", Academic Press, 1990
- *
- * SPARC implementation of a fast square root by table
- * lookup.
- * SPARC floating point format is as follows:
- *
- * BIT 31 30 23 22 0
- * sign exponent mantissa
- */
-static short sqrttab[0x100]; /* declare table of square roots */
-
-void
-_mesa_init_sqrt_table(void)
-{
-#if defined(USE_IEEE) && !defined(DEBUG)
- unsigned short i;
- fi_type fi; /* to access the bits of a float in C quickly */
- /* we use a union defined in glheader.h */
-
- for(i=0; i<= 0x7f; i++) {
- fi.i = 0;
-
- /*
- * Build a float with the bit pattern i as mantissa
- * and an exponent of 0, stored as 127
- */
-
- fi.i = (i << 16) | (127 << 23);
- fi.f = _mesa_sqrtd(fi.f);
-
- /*
- * Take the square root then strip the first 7 bits of
- * the mantissa into the table
- */
-
- sqrttab[i] = (fi.i & 0x7fffff) >> 16;
-
- /*
- * Repeat the process, this time with an exponent of
- * 1, stored as 128
- */
-
- fi.i = 0;
- fi.i = (i << 16) | (128 << 23);
- fi.f = sqrt(fi.f);
- sqrttab[i+0x80] = (fi.i & 0x7fffff) >> 16;
- }
-#else
- (void) sqrttab; /* silence compiler warnings */
-#endif /*HAVE_FAST_MATH*/
-}
-
-
-/**
- * Single precision square root.
- */
-float
-_mesa_sqrtf( float x )
-{
-#if defined(USE_IEEE) && !defined(DEBUG)
- fi_type num;
- /* to access the bits of a float in C
- * we use a union from glheader.h */
-
- short e; /* the exponent */
- if (x == 0.0F) return 0.0F; /* check for square root of 0 */
- num.f = x;
- e = (num.i >> 23) - 127; /* get the exponent - on a SPARC the */
- /* exponent is stored with 127 added */
- num.i &= 0x7fffff; /* leave only the mantissa */
- if (e & 0x01) num.i |= 0x800000;
- /* the exponent is odd so we have to */
- /* look it up in the second half of */
- /* the lookup table, so we set the */
- /* high bit */
- e >>= 1; /* divide the exponent by two */
- /* note that in C the shift */
- /* operators are sign preserving */
- /* for signed operands */
- /* Do the table lookup, based on the quaternary mantissa,
- * then reconstruct the result back into a float
- */
- num.i = ((sqrttab[num.i >> 16]) << 16) | ((e + 127) << 23);
-
- return num.f;
-#else
- return (float) _mesa_sqrtd((double) x);
-#endif
-}
-
-
-/**
- inv_sqrt - A single precision 1/sqrt routine for IEEE format floats.
- written by Josh Vanderhoof, based on newsgroup posts by James Van Buskirk
- and Vesa Karvonen.
-*/
-float
-_mesa_inv_sqrtf(float n)
-{
-#if defined(USE_IEEE) && !defined(DEBUG)
- float r0, x0, y0;
- float r1, x1, y1;
- float r2, x2, y2;
-#if 0 /* not used, see below -BP */
- float r3, x3, y3;
-#endif
- fi_type u;
- unsigned int magic;
-
- /*
- Exponent part of the magic number -
-
- We want to:
- 1. subtract the bias from the exponent,
- 2. negate it
- 3. divide by two (rounding towards -inf)
- 4. add the bias back
-
- Which is the same as subtracting the exponent from 381 and dividing
- by 2.
-
- floor(-(x - 127) / 2) + 127 = floor((381 - x) / 2)
- */
-
- magic = 381 << 23;
-
- /*
- Significand part of magic number -
-
- With the current magic number, "(magic - u.i) >> 1" will give you:
-
- for 1 <= u.f <= 2: 1.25 - u.f / 4
- for 2 <= u.f <= 4: 1.00 - u.f / 8
-
- This isn't a bad approximation of 1/sqrt. The maximum difference from
- 1/sqrt will be around .06. After three Newton-Raphson iterations, the
- maximum difference is less than 4.5e-8. (Which is actually close
- enough to make the following bias academic...)
-
- To get a better approximation you can add a bias to the magic
- number. For example, if you subtract 1/2 of the maximum difference in
- the first approximation (.03), you will get the following function:
-
- for 1 <= u.f <= 2: 1.22 - u.f / 4
- for 2 <= u.f <= 3.76: 0.97 - u.f / 8
- for 3.76 <= u.f <= 4: 0.72 - u.f / 16
- (The 3.76 to 4 range is where the result is < .5.)
-
- This is the closest possible initial approximation, but with a maximum
- error of 8e-11 after three NR iterations, it is still not perfect. If
- you subtract 0.0332281 instead of .03, the maximum error will be
- 2.5e-11 after three NR iterations, which should be about as close as
- is possible.
-
- for 1 <= u.f <= 2: 1.2167719 - u.f / 4
- for 2 <= u.f <= 3.73: 0.9667719 - u.f / 8
- for 3.73 <= u.f <= 4: 0.7167719 - u.f / 16
-
- */
-
- magic -= (int)(0.0332281 * (1 << 25));
-
- u.f = n;
- u.i = (magic - u.i) >> 1;
-
- /*
- Instead of Newton-Raphson, we use Goldschmidt's algorithm, which
- allows more parallelism. From what I understand, the parallelism
- comes at the cost of less precision, because it lets error
- accumulate across iterations.
- */
- x0 = 1.0f;
- y0 = 0.5f * n;
- r0 = u.f;
-
- x1 = x0 * r0;
- y1 = y0 * r0 * r0;
- r1 = 1.5f - y1;
-
- x2 = x1 * r1;
- y2 = y1 * r1 * r1;
- r2 = 1.5f - y2;
-
-#if 1
- return x2 * r2; /* we can stop here, and be conformant -BP */
-#else
- x3 = x2 * r2;
- y3 = y2 * r2 * r2;
- r3 = 1.5f - y3;
-
- return x3 * r3;
-#endif
-#else
- return (float) (1.0 / sqrt(n));
-#endif
-}
-
-/**
- * Find the first bit set in a word.
- */
-int
-_mesa_ffs(int32_t i)
-{
-#if (defined(_WIN32) ) || defined(__IBMC__) || defined(__IBMCPP__)
- register int bit = 0;
- if (i != 0) {
- if ((i & 0xffff) == 0) {
- bit += 16;
- i >>= 16;
- }
- if ((i & 0xff) == 0) {
- bit += 8;
- i >>= 8;
- }
- if ((i & 0xf) == 0) {
- bit += 4;
- i >>= 4;
- }
- while ((i & 1) == 0) {
- bit++;
- i >>= 1;
- }
- bit++;
- }
- return bit;
-#else
- return ffs(i);
-#endif
-}
-
-
-/**
- * Find position of first bit set in given value.
- * XXX Warning: this function can only be used on 64-bit systems!
- * \return position of least-significant bit set, starting at 1, return zero
- * if no bits set.
- */
-int
-_mesa_ffsll(int64_t val)
-{
-#ifdef ffsll
- return ffsll(val);
-#else
- int bit;
-
- assert(sizeof(val) == 8);
-
- bit = _mesa_ffs((int32_t)val);
- if (bit != 0)
- return bit;
-
- bit = _mesa_ffs((int32_t)(val >> 32));
- if (bit != 0)
- return 32 + bit;
-
- return 0;
-#endif
-}
-
-
-/**
- * Return number of bits set in given GLuint.
- */
-unsigned int
-_mesa_bitcount(unsigned int n)
-{
-#if defined(__GNUC__) && \
- ((_GNUC__ == 3 && __GNUC_MINOR__ >= 4) || __GNUC__ >= 4)
- return __builtin_popcount(n);
-#else
- unsigned int bits;
- for (bits = 0; n > 0; n = n >> 1) {
- bits += (n & 1);
- }
- return bits;
-#endif
-}
-
-
-/**
- * Convert a 4-byte float to a 2-byte half float.
- * Based on code from:
- * http://www.opengl.org/discussion_boards/ubb/Forum3/HTML/008786.html
- */
-GLhalfARB
-_mesa_float_to_half(float val)
-{
- const fi_type fi = {val};
- const int flt_m = fi.i & 0x7fffff;
- const int flt_e = (fi.i >> 23) & 0xff;
- const int flt_s = (fi.i >> 31) & 0x1;
- int s, e, m = 0;
- GLhalfARB result;
-
- /* sign bit */
- s = flt_s;
-
- /* handle special cases */
- if ((flt_e == 0) && (flt_m == 0)) {
- /* zero */
- /* m = 0; - already set */
- e = 0;
- }
- else if ((flt_e == 0) && (flt_m != 0)) {
- /* denorm -- denorm float maps to 0 half */
- /* m = 0; - already set */
- e = 0;
- }
- else if ((flt_e == 0xff) && (flt_m == 0)) {
- /* infinity */
- /* m = 0; - already set */
- e = 31;
- }
- else if ((flt_e == 0xff) && (flt_m != 0)) {
- /* NaN */
- m = 1;
- e = 31;
- }
- else {
- /* regular number */
- const int new_exp = flt_e - 127;
- if (new_exp < -24) {
- /* this maps to 0 */
- /* m = 0; - already set */
- e = 0;
- }
- else if (new_exp < -14) {
- /* this maps to a denorm */
- unsigned int exp_val = (unsigned int) (-14 - new_exp); /* 2^-exp_val*/
- e = 0;
- switch (exp_val) {
- case 0:
- _mesa_warning(NULL,
- "float_to_half: logical error in denorm creation!\n");
- /* m = 0; - already set */
- break;
- case 1: m = 512 + (flt_m >> 14); break;
- case 2: m = 256 + (flt_m >> 15); break;
- case 3: m = 128 + (flt_m >> 16); break;
- case 4: m = 64 + (flt_m >> 17); break;
- case 5: m = 32 + (flt_m >> 18); break;
- case 6: m = 16 + (flt_m >> 19); break;
- case 7: m = 8 + (flt_m >> 20); break;
- case 8: m = 4 + (flt_m >> 21); break;
- case 9: m = 2 + (flt_m >> 22); break;
- case 10: m = 1; break;
- }
- }
- else if (new_exp > 15) {
- /* map this value to infinity */
- /* m = 0; - already set */
- e = 31;
- }
- else {
- /* regular */
- e = new_exp + 15;
- m = flt_m >> 13;
- }
- }
-
- result = (s << 15) | (e << 10) | m;
- return result;
-}
-
-
-/**
- * Convert a 2-byte half float to a 4-byte float.
- * Based on code from:
- * http://www.opengl.org/discussion_boards/ubb/Forum3/HTML/008786.html
- */
-float
-_mesa_half_to_float(GLhalfARB val)
-{
- /* XXX could also use a 64K-entry lookup table */
- const int m = val & 0x3ff;
- const int e = (val >> 10) & 0x1f;
- const int s = (val >> 15) & 0x1;
- int flt_m, flt_e, flt_s;
- fi_type fi;
- float result;
-
- /* sign bit */
- flt_s = s;
-
- /* handle special cases */
- if ((e == 0) && (m == 0)) {
- /* zero */
- flt_m = 0;
- flt_e = 0;
- }
- else if ((e == 0) && (m != 0)) {
- /* denorm -- denorm half will fit in non-denorm single */
- const float half_denorm = 1.0f / 16384.0f; /* 2^-14 */
- float mantissa = ((float) (m)) / 1024.0f;
- float sign = s ? -1.0f : 1.0f;
- return sign * mantissa * half_denorm;
- }
- else if ((e == 31) && (m == 0)) {
- /* infinity */
- flt_e = 0xff;
- flt_m = 0;
- }
- else if ((e == 31) && (m != 0)) {
- /* NaN */
- flt_e = 0xff;
- flt_m = 1;
- }
- else {
- /* regular */
- flt_e = e + 112;
- flt_m = m << 13;
- }
-
- fi.i = (flt_s << 31) | (flt_e << 23) | flt_m;
- result = fi.f;
- return result;
-}
-
-/*@}*/
-
-
-/**********************************************************************/
-/** \name Sort & Search */
-/*@{*/
-
-/**
- * Wrapper for bsearch().
- */
-void *
-_mesa_bsearch( const void *key, const void *base, size_t nmemb, size_t size,
- int (*compar)(const void *, const void *) )
-{
-#if defined(_WIN32_WCE)
- void *mid;
- int cmp;
- while (nmemb) {
- nmemb >>= 1;
- mid = (char *)base + nmemb * size;
- cmp = (*compar)(key, mid);
- if (cmp == 0)
- return mid;
- if (cmp > 0) {
- base = (char *)mid + size;
- --nmemb;
- }
- }
- return NULL;
-#else
- return bsearch(key, base, nmemb, size, compar);
-#endif
-}
-
-/*@}*/
-
-
-/**********************************************************************/
-/** \name Environment vars */
-/*@{*/
-
-/**
- * Wrapper for getenv().
- */
-char *
-_mesa_getenv( const char *var )
-{
-#if defined(_XBOX) || defined(_WIN32_WCE)
- return NULL;
-#else
- return getenv(var);
-#endif
-}
-
-/*@}*/
-
-
-/**********************************************************************/
-/** \name String */
-/*@{*/
-
-/**
- * Implemented using malloc() and strcpy.
- * Note that NULL is handled accordingly.
- */
-char *
-_mesa_strdup( const char *s )
-{
- if (s) {
- size_t l = strlen(s);
- char *s2 = (char *) malloc(l + 1);
- if (s2)
- strcpy(s2, s);
- return s2;
- }
- else {
- return NULL;
- }
-}
-
-/** Wrapper around strtof() */
-float
-_mesa_strtof( const char *s, char **end )
-{
-#if defined(_GNU_SOURCE) && !defined(__CYGWIN__) && !defined(__FreeBSD__)
- static locale_t loc = NULL;
- if (!loc) {
- loc = newlocale(LC_CTYPE_MASK, "C", NULL);
- }
- return strtof_l(s, end, loc);
-#elif defined(_ISOC99_SOURCE) || (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE >= 600)
- return strtof(s, end);
-#else
- return (float)strtod(s, end);
-#endif
-}
-
-/** Compute simple checksum/hash for a string */
-unsigned int
-_mesa_str_checksum(const char *str)
-{
- /* This could probably be much better */
- unsigned int sum, i;
- const char *c;
- sum = i = 1;
- for (c = str; *c; c++, i++)
- sum += *c * (i % 100);
- return sum + i;
-}
-
-
-/*@}*/
-
-
-/** Wrapper around vsnprintf() */
-int
-_mesa_snprintf( char *str, size_t size, const char *fmt, ... )
-{
- int r;
- va_list args;
- va_start( args, fmt );
- r = vsnprintf( str, size, fmt, args );
- va_end( args );
- return r;
-}
-
-
-/**********************************************************************/
-/** \name Diagnostics */
-/*@{*/
-
-static void
-output_if_debug(const char *prefixString, const char *outputString,
- GLboolean newline)
-{
- static int debug = -1;
-
- /* Check the MESA_DEBUG environment variable if it hasn't
- * been checked yet. We only have to check it once...
- */
- if (debug == -1) {
- char *env = _mesa_getenv("MESA_DEBUG");
-
- /* In a debug build, we print warning messages *unless*
- * MESA_DEBUG is 0. In a non-debug build, we don't
- * print warning messages *unless* MESA_DEBUG is
- * set *to any value*.
- */
-#ifdef DEBUG
- debug = (env != NULL && atoi(env) == 0) ? 0 : 1;
-#else
- debug = (env != NULL) ? 1 : 0;
-#endif
- }
-
- /* Now only print the string if we're required to do so. */
- if (debug) {
- fprintf(stderr, "%s: %s", prefixString, outputString);
- if (newline)
- fprintf(stderr, "\n");
-
-#if defined(_WIN32) && !defined(_WIN32_WCE)
- /* stderr from windows applications without console is not usually
- * visible, so communicate with the debugger instead */
- {
- char buf[4096];
- _mesa_snprintf(buf, sizeof(buf), "%s: %s%s", prefixString, outputString, newline ? "\n" : "");
- OutputDebugStringA(buf);
- }
-#endif
- }
-}
-
-
-/**
- * Return string version of GL error code.
- */
-static const char *
-error_string( GLenum error )
-{
- switch (error) {
- case GL_NO_ERROR:
- return "GL_NO_ERROR";
- case GL_INVALID_VALUE:
- return "GL_INVALID_VALUE";
- case GL_INVALID_ENUM:
- return "GL_INVALID_ENUM";
- case GL_INVALID_OPERATION:
- return "GL_INVALID_OPERATION";
- case GL_STACK_OVERFLOW:
- return "GL_STACK_OVERFLOW";
- case GL_STACK_UNDERFLOW:
- return "GL_STACK_UNDERFLOW";
- case GL_OUT_OF_MEMORY:
- return "GL_OUT_OF_MEMORY";
- case GL_TABLE_TOO_LARGE:
- return "GL_TABLE_TOO_LARGE";
- case GL_INVALID_FRAMEBUFFER_OPERATION_EXT:
- return "GL_INVALID_FRAMEBUFFER_OPERATION";
- default:
- return "unknown";
- }
-}
-
-
-/**
- * When a new type of error is recorded, print a message describing
- * previous errors which were accumulated.
- */
-static void
-flush_delayed_errors( struct gl_context *ctx )
-{
- char s[MAXSTRING];
-
- if (ctx->ErrorDebugCount) {
- _mesa_snprintf(s, MAXSTRING, "%d similar %s errors",
- ctx->ErrorDebugCount,
- error_string(ctx->ErrorValue));
-
- output_if_debug("Mesa", s, GL_TRUE);
-
- ctx->ErrorDebugCount = 0;
- }
-}
-
-
-/**
- * Report a warning (a recoverable error condition) to stderr if
- * either DEBUG is defined or the MESA_DEBUG env var is set.
- *
- * \param ctx GL context.
- * \param fmtString printf()-like format string.
- */
-void
-_mesa_warning( struct gl_context *ctx, const char *fmtString, ... )
-{
- char str[MAXSTRING];
- va_list args;
- va_start( args, fmtString );
- (void) vsnprintf( str, MAXSTRING, fmtString, args );
- va_end( args );
-
- if (ctx)
- flush_delayed_errors( ctx );
-
- output_if_debug("Mesa warning", str, GL_TRUE);
-}
-
-
-/**
- * Report an internal implementation problem.
- * Prints the message to stderr via fprintf().
- *
- * \param ctx GL context.
- * \param fmtString problem description string.
- */
-void
-_mesa_problem( const struct gl_context *ctx, const char *fmtString, ... )
-{
- va_list args;
- char str[MAXSTRING];
- (void) ctx;
-
- va_start( args, fmtString );
- vsnprintf( str, MAXSTRING, fmtString, args );
- va_end( args );
-
- fprintf(stderr, "Mesa %s implementation error: %s\n", MESA_VERSION_STRING, str);
- fprintf(stderr, "Please report at bugzilla.freedesktop.org\n");
-}
-
-
-/**
- * Record an OpenGL state error. These usually occur when the user
- * passes invalid parameters to a GL function.
- *
- * If debugging is enabled (either at compile-time via the DEBUG macro, or
- * run-time via the MESA_DEBUG environment variable), report the error with
- * _mesa_debug().
- *
- * \param ctx the GL context.
- * \param error the error value.
- * \param fmtString printf() style format string, followed by optional args
- */
-void
-_mesa_error( struct gl_context *ctx, GLenum error, const char *fmtString, ... )
-{
- static GLint debug = -1;
-
- /* Check debug environment variable only once:
- */
- if (debug == -1) {
- const char *debugEnv = _mesa_getenv("MESA_DEBUG");
-
-#ifdef DEBUG
- if (debugEnv && strstr(debugEnv, "silent"))
- debug = GL_FALSE;
- else
- debug = GL_TRUE;
-#else
- if (debugEnv)
- debug = GL_TRUE;
- else
- debug = GL_FALSE;
-#endif
- }
-
- if (debug) {
- if (ctx->ErrorValue == error &&
- ctx->ErrorDebugFmtString == fmtString) {
- ctx->ErrorDebugCount++;
- }
- else {
- char s[MAXSTRING], s2[MAXSTRING];
- va_list args;
-
- flush_delayed_errors( ctx );
-
- va_start(args, fmtString);
- vsnprintf(s, MAXSTRING, fmtString, args);
- va_end(args);
-
- _mesa_snprintf(s2, MAXSTRING, "%s in %s", error_string(error), s);
- output_if_debug("Mesa: User error", s2, GL_TRUE);
-
- ctx->ErrorDebugFmtString = fmtString;
- ctx->ErrorDebugCount = 0;
- }
- }
-
- _mesa_record_error(ctx, error);
-}
-
-
-/**
- * Report debug information. Print error message to stderr via fprintf().
- * No-op if DEBUG mode not enabled.
- *
- * \param ctx GL context.
- * \param fmtString printf()-style format string, followed by optional args.
- */
-void
-_mesa_debug( const struct gl_context *ctx, const char *fmtString, ... )
-{
-#ifdef DEBUG
- char s[MAXSTRING];
- va_list args;
- va_start(args, fmtString);
- vsnprintf(s, MAXSTRING, fmtString, args);
- va_end(args);
- output_if_debug("Mesa", s, GL_FALSE);
-#endif /* DEBUG */
- (void) ctx;
- (void) fmtString;
-}
-
-/*@}*/
diff --git a/src/mesa/main/version.c b/src/mesa/main/version.c
deleted file mode 100644
index 69a28da..0000000
--- a/src/mesa/main/version.c
+++ /dev/null
@@ -1,284 +0,0 @@
-/*
- * Mesa 3-D graphics library
- *
- * Copyright (C) 2010 VMware, Inc. 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
- * THE AUTHORS 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.
- */
-
-
-#include "context.h"
-#include "version.h"
-
-
-
-/**
- * Examine enabled GL extensions to determine GL version.
- * Return major and minor version numbers.
- */
-static void
-compute_version(struct gl_context *ctx)
-{
- GLuint major, minor;
- static const int max = 100;
-
- const GLboolean ver_1_3 = (ctx->Extensions.ARB_multisample &&
- ctx->Extensions.ARB_multitexture &&
- ctx->Extensions.ARB_texture_border_clamp &&
- ctx->Extensions.ARB_texture_compression &&
- ctx->Extensions.ARB_texture_cube_map &&
- ctx->Extensions.EXT_texture_env_add &&
- ctx->Extensions.ARB_texture_env_combine &&
- ctx->Extensions.ARB_texture_env_dot3);
- const GLboolean ver_1_4 = (ver_1_3 &&
- ctx->Extensions.ARB_depth_texture &&
- ctx->Extensions.ARB_shadow &&
- ctx->Extensions.ARB_texture_env_crossbar &&
- ctx->Extensions.ARB_texture_mirrored_repeat &&
- ctx->Extensions.ARB_window_pos &&
- ctx->Extensions.EXT_blend_color &&
- ctx->Extensions.EXT_blend_func_separate &&
- ctx->Extensions.EXT_blend_minmax &&
- ctx->Extensions.EXT_blend_subtract &&
- ctx->Extensions.EXT_fog_coord &&
- ctx->Extensions.EXT_multi_draw_arrays &&
- ctx->Extensions.EXT_point_parameters &&
- ctx->Extensions.EXT_secondary_color &&
- ctx->Extensions.EXT_stencil_wrap &&
- ctx->Extensions.EXT_texture_lod_bias &&
- ctx->Extensions.SGIS_generate_mipmap);
- const GLboolean ver_1_5 = (ver_1_4 &&
- ctx->Extensions.ARB_occlusion_query &&
- ctx->Extensions.ARB_vertex_buffer_object &&
- ctx->Extensions.EXT_shadow_funcs);
- const GLboolean ver_2_0 = (ver_1_5 &&
- ctx->Extensions.ARB_draw_buffers &&
- ctx->Extensions.ARB_point_sprite &&
- ctx->Extensions.ARB_shader_objects &&
- ctx->Extensions.ARB_vertex_shader &&
- ctx->Extensions.ARB_fragment_shader &&
- ctx->Extensions.ARB_texture_non_power_of_two &&
- ctx->Extensions.EXT_blend_equation_separate &&
-
- /* Technically, 2.0 requires the functionality
- * of the EXT version. Enable 2.0 if either
- * extension is available, and assume that a
- * driver that only exposes the ATI extension
- * will fallback to software when necessary.
- */
- (ctx->Extensions.EXT_stencil_two_side
- || ctx->Extensions.ATI_separate_stencil));
- const GLboolean ver_2_1 = (ver_2_0 &&
- ctx->Const.GLSLVersion >= 120 &&
- ctx->Extensions.EXT_pixel_buffer_object &&
- ctx->Extensions.EXT_texture_sRGB);
- const GLboolean ver_3_0 = (ver_2_1 &&
- ctx->Extensions.ARB_half_float_pixel &&
- ctx->Extensions.ARB_map_buffer_range &&
- ctx->Extensions.ARB_texture_float &&
- ctx->Extensions.ARB_texture_rg &&
- ctx->Extensions.ARB_texture_compression_rgtc &&
- ctx->Extensions.APPLE_vertex_array_object &&
- ctx->Extensions.EXT_draw_buffers2 &&
- ctx->Extensions.EXT_framebuffer_blit &&
- ctx->Extensions.EXT_framebuffer_multisample &&
- ctx->Extensions.EXT_framebuffer_object &&
- ctx->Extensions.EXT_framebuffer_sRGB &&
- ctx->Extensions.EXT_packed_depth_stencil &&
- ctx->Extensions.EXT_packed_float &&
- ctx->Extensions.EXT_texture_array &&
- ctx->Extensions.EXT_texture_integer &&
- ctx->Extensions.EXT_texture_shared_exponent &&
- ctx->Extensions.EXT_transform_feedback &&
- ctx->Extensions.NV_conditional_render);
- const GLboolean ver_3_1 = (ver_3_0 &&
- ctx->Extensions.ARB_copy_buffer &&
- ctx->Extensions.ARB_draw_instanced &&
- ctx->Extensions.ARB_texture_buffer_object &&
- ctx->Extensions.ARB_uniform_buffer_object &&
- ctx->Extensions.NV_primitive_restart &&
- ctx->Extensions.NV_texture_rectangle &&
- ctx->Const.MaxVertexTextureImageUnits >= 16);
- const GLboolean ver_3_2 = (ver_3_1 &&
- ctx->Extensions.ARB_depth_clamp &&
- ctx->Extensions.ARB_draw_elements_base_vertex &&
- ctx->Extensions.ARB_fragment_coord_conventions &&
- ctx->Extensions.ARB_geometry_shader4 &&
- ctx->Extensions.EXT_provoking_vertex &&
- ctx->Extensions.ARB_seamless_cube_map &&
- ctx->Extensions.ARB_sync &&
- ctx->Extensions.ARB_texture_multisample &&
- ctx->Extensions.EXT_vertex_array_bgra);
- const GLboolean ver_3_3 = (ver_3_2 &&
- ctx->Extensions.ARB_blend_func_extended &&
- ctx->Extensions.ARB_explicit_attrib_location &&
- ctx->Extensions.ARB_instanced_arrays &&
- ctx->Extensions.ARB_occlusion_query2 &&
- ctx->Extensions.ARB_sampler_objects &&
- ctx->Extensions.ARB_texture_rgb10_a2ui &&
- ctx->Extensions.ARB_timer_query &&
- ctx->Extensions.ARB_vertex_type_2_10_10_10_rev &&
- ctx->Extensions.EXT_texture_swizzle);
-
- if (ver_3_3) {
- major = 3;
- minor = 3;
- }
- else if (ver_3_2) {
- major = 3;
- minor = 2;
- }
- else if (ver_3_1) {
- major = 3;
- minor = 1;
- }
- else if (ver_3_0) {
- major = 3;
- minor = 0;
- }
- else if (ver_2_1) {
- major = 2;
- minor = 1;
- }
- else if (ver_2_0) {
- major = 2;
- minor = 0;
- }
- else if (ver_1_5) {
- major = 1;
- minor = 5;
- }
- else if (ver_1_4) {
- major = 1;
- minor = 4;
- }
- else if (ver_1_3) {
- major = 1;
- minor = 3;
- }
- else {
- major = 1;
- minor = 2;
- }
-
- ctx->VersionMajor = major;
- ctx->VersionMinor = minor;
- ctx->VersionString = (char *) malloc(max);
- if (ctx->VersionString) {
- _mesa_snprintf(ctx->VersionString, max,
- "%u.%u Mesa " MESA_VERSION_STRING,
- ctx->VersionMajor, ctx->VersionMinor);
- }
-}
-
-static void
-compute_version_es1(struct gl_context *ctx)
-{
- static const int max = 100;
-
- /* OpenGL ES 1.0 is derived from OpenGL 1.3 */
- const GLboolean ver_1_0 = (ctx->Extensions.ARB_multisample &&
- ctx->Extensions.ARB_multitexture &&
- ctx->Extensions.ARB_texture_compression &&
- ctx->Extensions.EXT_texture_env_add &&
- ctx->Extensions.ARB_texture_env_combine &&
- ctx->Extensions.ARB_texture_env_dot3);
- /* OpenGL ES 1.1 is derived from OpenGL 1.5 */
- const GLboolean ver_1_1 = (ver_1_0 &&
- ctx->Extensions.EXT_point_parameters &&
- ctx->Extensions.SGIS_generate_mipmap &&
- ctx->Extensions.ARB_vertex_buffer_object);
-
- if (ver_1_1) {
- ctx->VersionMajor = 1;
- ctx->VersionMinor = 1;
- } else if (ver_1_0) {
- ctx->VersionMajor = 1;
- ctx->VersionMinor = 0;
- } else {
- _mesa_problem(ctx, "Incomplete OpenGL ES 1.0 support.");
- }
-
- ctx->VersionString = (char *) malloc(max);
- if (ctx->VersionString) {
- _mesa_snprintf(ctx->VersionString, max,
- "OpenGL ES-CM 1.%d Mesa " MESA_VERSION_STRING,
- ctx->VersionMinor);
- }
-}
-
-static void
-compute_version_es2(struct gl_context *ctx)
-{
- static const int max = 100;
-
- /* OpenGL ES 2.0 is derived from OpenGL 2.0 */
- const GLboolean ver_2_0 = (ctx->Extensions.ARB_multisample &&
- ctx->Extensions.ARB_multitexture &&
- ctx->Extensions.ARB_texture_compression &&
- ctx->Extensions.ARB_texture_cube_map &&
- ctx->Extensions.ARB_texture_mirrored_repeat &&
- ctx->Extensions.EXT_blend_color &&
- ctx->Extensions.EXT_blend_func_separate &&
- ctx->Extensions.EXT_blend_minmax &&
- ctx->Extensions.EXT_blend_subtract &&
- ctx->Extensions.EXT_stencil_wrap &&
- ctx->Extensions.ARB_vertex_buffer_object &&
- ctx->Extensions.ARB_shader_objects &&
- ctx->Extensions.ARB_vertex_shader &&
- ctx->Extensions.ARB_fragment_shader &&
- ctx->Extensions.ARB_texture_non_power_of_two &&
- ctx->Extensions.EXT_blend_equation_separate);
- if (ver_2_0) {
- ctx->VersionMajor = 2;
- ctx->VersionMinor = 0;
- } else {
- _mesa_problem(ctx, "Incomplete OpenGL ES 2.0 support.");
- }
-
- ctx->VersionString = (char *) malloc(max);
- if (ctx->VersionString) {
- _mesa_snprintf(ctx->VersionString, max,
- "OpenGL ES 2.0 Mesa " MESA_VERSION_STRING);
- }
-}
-
-/**
- * Set the context's VersionMajor, VersionMinor, VersionString fields.
- * This should only be called once as part of context initialization
- * or to perform version check for GLX_ARB_create_context_profile.
- */
-void
-_mesa_compute_version(struct gl_context *ctx)
-{
- if (ctx->VersionMajor)
- return;
-
- switch (ctx->API) {
- case API_OPENGL:
- compute_version(ctx);
- break;
- case API_OPENGLES:
- compute_version_es1(ctx);
- break;
- case API_OPENGLES2:
- compute_version_es2(ctx);
- break;
- }
-
-}
diff --git a/src/mesa/main/vsnprintf.c b/src/mesa/main/vsnprintf.c
deleted file mode 100644
index ab6c740..0000000
--- a/src/mesa/main/vsnprintf.c
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * Revision 12: http://theos.com/~deraadt/snprintf.c
- *
- * Copyright (c) 1997 Theo de Raadt
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef __VMS
-# include <sys/param.h>
-#endif
-#include <sys/types.h>
-#include <sys/mman.h>
-#include <signal.h>
-#include <stdio.h>
-#if __STDC__
-#include <stdarg.h>
-#include <stdlib.h>
-#else
-#include <varargs.h>
-#endif
-#include <setjmp.h>
-#include <unistd.h>
-#include <string.h>
-
-#ifndef roundup
-#define roundup(x, y) ((((x)+((y)-1))/(y))*(y))
-#endif
-
-#ifdef __sgi
-#define size_t ssize_t
-#endif
-
-static int pgsize;
-static char *curobj;
-static int caught;
-static sigjmp_buf bail;
-
-#define EXTRABYTES 2 /* XXX: why 2? you don't want to know */
-
-static char *
-msetup(str, n)
- char *str;
- size_t n;
-{
- char *e;
-
- if (n == 0)
- return NULL;
- if (pgsize == 0)
- pgsize = getpagesize();
- curobj = (char *)malloc(n + EXTRABYTES + pgsize * 2);
- if (curobj == NULL)
- return NULL;
- e = curobj + n + EXTRABYTES;
- e = (char *)roundup((unsigned long)e, pgsize);
- if (mprotect(e, pgsize, PROT_NONE) == -1) {
- free(curobj);
- curobj = NULL;
- return NULL;
- }
- e = e - n - EXTRABYTES;
- *e = '\0';
- return (e);
-}
-
-static void
- mcatch( int a )
-{
- siglongjmp(bail, 1);
-}
-
-static void
-mcleanup(str, n, p)
- char *str;
- size_t n;
- char *p;
-{
- strncpy(str, p, n-1);
- str[n-1] = '\0';
- if (mprotect((caddr_t)(p + n + EXTRABYTES), pgsize,
- PROT_READ|PROT_WRITE|PROT_EXEC) == -1)
- mprotect((caddr_t)(p + n + EXTRABYTES), pgsize,
- PROT_READ|PROT_WRITE);
- free(curobj);
-}
-
-int
-#if __STDC__
-vsnprintf(char *str, size_t n, char const *fmt, va_list ap)
-#else
-vsnprintf(str, n, fmt, ap)
- char *str;
- size_t n;
- char *fmt;
- char *ap;
-#endif
-{
- struct sigaction osa, nsa;
- char *p;
- int ret = n + 1; /* if we bail, indicated we overflowed */
-
- memset(&nsa, 0, sizeof nsa);
- nsa.sa_handler = mcatch;
- sigemptyset(&nsa.sa_mask);
-
- p = msetup(str, n);
- if (p == NULL) {
- *str = '\0';
- return 0;
- }
- if (sigsetjmp(bail, 1) == 0) {
- if (sigaction(SIGSEGV, &nsa, &osa) == -1) {
- mcleanup(str, n, p);
- return (0);
- }
- ret = vsprintf(p, fmt, ap);
- }
- mcleanup(str, n, p);
- (void) sigaction(SIGSEGV, &osa, NULL);
- return (ret);
-}
-
-int
-#if __STDC__
-snprintf(char *str, size_t n, char const *fmt, ...)
-#else
-snprintf(str, n, fmt, va_alist)
- char *str;
- size_t n;
- char *fmt;
- va_dcl
-#endif
-{
- va_list ap;
-#if __STDC__
- va_start(ap, fmt);
-#else
- va_start(ap);
-#endif
-
- return (vsnprintf(str, n, fmt, ap));
- va_end(ap);
-}
-
-
-