From dafebc5bb70303f0b5baf0b087cf4d9a64b5c7f0 Mon Sep 17 00:00:00 2001 From: marha Date: Mon, 12 Sep 2011 11:27:51 +0200 Subject: Synchronised line endinge with release branch --- mesalib/src/mesa/main/api_arrayelt.c | 3416 ++-- mesalib/src/mesa/main/api_exec.c | 1502 +- mesalib/src/mesa/main/attrib.c | 3126 ++-- mesalib/src/mesa/main/bufferobj.h | 318 +- mesalib/src/mesa/main/clear.c | 1150 +- mesalib/src/mesa/main/colortab.c | 338 +- mesalib/src/mesa/main/compiler.h | 988 +- mesalib/src/mesa/main/context.c | 3760 ++--- mesalib/src/mesa/main/context.h | 578 +- mesalib/src/mesa/main/convolve.c | 410 +- mesalib/src/mesa/main/dd.h | 2434 +-- mesalib/src/mesa/main/debug.h | 188 +- mesalib/src/mesa/main/depth.c | 348 +- mesalib/src/mesa/main/depthstencil.c | 2228 +-- mesalib/src/mesa/main/dlist.c | 21580 ++++++++++++------------- mesalib/src/mesa/main/drawpix.c | 604 +- mesalib/src/mesa/main/enable.c | 2826 ++-- mesalib/src/mesa/main/enums.c | 12704 +++++++-------- mesalib/src/mesa/main/es_generator.py | 1516 +- mesalib/src/mesa/main/eval.c | 2182 +-- mesalib/src/mesa/main/fbobject.c | 5398 +++---- mesalib/src/mesa/main/ff_fragment_shader.cpp | 3236 ++-- mesalib/src/mesa/main/fog.c | 408 +- mesalib/src/mesa/main/formats.c | 3864 ++--- mesalib/src/mesa/main/formats.h | 552 +- mesalib/src/mesa/main/framebuffer.c | 2196 +-- mesalib/src/mesa/main/get.c | 5238 +++--- mesalib/src/mesa/main/get.h | 162 +- mesalib/src/mesa/main/getstring.c | 540 +- mesalib/src/mesa/main/glheader.h | 334 +- mesalib/src/mesa/main/hint.c | 294 +- mesalib/src/mesa/main/histogram.c | 346 +- mesalib/src/mesa/main/imports.h | 1296 +- mesalib/src/mesa/main/lines.c | 234 +- mesalib/src/mesa/main/macros.h | 1450 +- mesalib/src/mesa/main/mfeatures.h | 292 +- mesalib/src/mesa/main/mtypes.h | 6898 ++++---- mesalib/src/mesa/main/pack.c | 10458 ++++++------ mesalib/src/mesa/main/pbo.c | 790 +- mesalib/src/mesa/main/pbo.h | 186 +- mesalib/src/mesa/main/pixel.c | 1462 +- mesalib/src/mesa/main/polygon.c | 660 +- mesalib/src/mesa/main/polygon.h | 140 +- mesalib/src/mesa/main/queryobj.c | 1248 +- mesalib/src/mesa/main/readpix.c | 556 +- mesalib/src/mesa/main/readpix.h | 94 +- mesalib/src/mesa/main/remap_helper.h | 14008 ++++++++-------- mesalib/src/mesa/main/renderbuffer.c | 5136 +++--- mesalib/src/mesa/main/renderbuffer.h | 242 +- mesalib/src/mesa/main/samplerobj.c | 2826 ++-- mesalib/src/mesa/main/samplerobj.h | 124 +- mesalib/src/mesa/main/shaderapi.c | 3896 ++--- mesalib/src/mesa/main/shared.c | 840 +- mesalib/src/mesa/main/shared.h | 78 +- mesalib/src/mesa/main/state.c | 1520 +- mesalib/src/mesa/main/stencil.c | 1228 +- mesalib/src/mesa/main/texcompress.c | 1052 +- mesalib/src/mesa/main/texcompress_rgtc.h | 154 +- mesalib/src/mesa/main/texcompress_rgtc_tmp.h | 836 +- mesalib/src/mesa/main/texcompress_s3tc.c | 1124 +- mesalib/src/mesa/main/texenv.c | 2086 +-- mesalib/src/mesa/main/texgetimage.c | 1706 +- mesalib/src/mesa/main/texgetimage.h | 130 +- mesalib/src/mesa/main/teximage.c | 7638 ++++----- mesalib/src/mesa/main/texobj.c | 2552 +-- mesalib/src/mesa/main/texparam.c | 2832 ++-- mesalib/src/mesa/main/texstate.c | 1700 +- mesalib/src/mesa/main/texstore.h | 418 +- mesalib/src/mesa/main/uniforms.c | 3034 ++-- mesalib/src/mesa/main/uniforms.h | 416 +- mesalib/src/mesa/main/varray.h | 558 +- 71 files changed, 83331 insertions(+), 83331 deletions(-) (limited to 'mesalib/src/mesa/main') diff --git a/mesalib/src/mesa/main/api_arrayelt.c b/mesalib/src/mesa/main/api_arrayelt.c index 742816248..b93a057e6 100644 --- a/mesalib/src/mesa/main/api_arrayelt.c +++ b/mesalib/src/mesa/main/api_arrayelt.c @@ -1,1708 +1,1708 @@ -/* - * 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. - */ - -/** - * This file implements the glArrayElement() function. - * It involves looking at the format/type of all the enabled vertex arrays - * and emitting a list of pointers to functions which set the per-vertex - * state for the element/index. - */ - - -/* Author: - * Keith Whitwell - */ - -#include "glheader.h" -#include "api_arrayelt.h" -#include "bufferobj.h" -#include "context.h" -#include "imports.h" -#include "macros.h" -#include "mfeatures.h" -#include "mtypes.h" -#include "main/dispatch.h" - -typedef void (GLAPIENTRY *array_func)( const void * ); - -typedef struct { - const struct gl_client_array *array; - int offset; -} AEarray; - -typedef void (GLAPIENTRY *attrib_func)( GLuint indx, const void *data ); - -typedef struct { - const struct gl_client_array *array; - attrib_func func; - GLuint index; -} AEattrib; - -typedef struct { - AEarray arrays[32]; - AEattrib attribs[VERT_ATTRIB_MAX + 1]; - GLuint NewState; - - struct gl_buffer_object *vbo[VERT_ATTRIB_MAX]; - GLuint nr_vbos; - GLboolean mapped_vbos; - -} AEcontext; - -#define AE_CONTEXT(ctx) ((AEcontext *)(ctx)->aelt_context) - - -/* - * Convert GL_BYTE, GL_UNSIGNED_BYTE, .. GL_DOUBLE into an integer - * in the range [0, 7]. Luckily these type tokens are sequentially - * numbered in gl.h, except for GL_DOUBLE. - */ -#define TYPE_IDX(t) ( (t) == GL_DOUBLE ? 7 : (t) & 7 ) - -#define NUM_TYPES 8 - - -#if FEATURE_arrayelt - - -static const int ColorFuncs[2][NUM_TYPES] = { - { - _gloffset_Color3bv, - _gloffset_Color3ubv, - _gloffset_Color3sv, - _gloffset_Color3usv, - _gloffset_Color3iv, - _gloffset_Color3uiv, - _gloffset_Color3fv, - _gloffset_Color3dv, - }, - { - _gloffset_Color4bv, - _gloffset_Color4ubv, - _gloffset_Color4sv, - _gloffset_Color4usv, - _gloffset_Color4iv, - _gloffset_Color4uiv, - _gloffset_Color4fv, - _gloffset_Color4dv, - }, -}; - -static const int VertexFuncs[3][NUM_TYPES] = { - { - -1, - -1, - _gloffset_Vertex2sv, - -1, - _gloffset_Vertex2iv, - -1, - _gloffset_Vertex2fv, - _gloffset_Vertex2dv, - }, - { - -1, - -1, - _gloffset_Vertex3sv, - -1, - _gloffset_Vertex3iv, - -1, - _gloffset_Vertex3fv, - _gloffset_Vertex3dv, - }, - { - -1, - -1, - _gloffset_Vertex4sv, - -1, - _gloffset_Vertex4iv, - -1, - _gloffset_Vertex4fv, - _gloffset_Vertex4dv, - }, -}; - -static const int IndexFuncs[NUM_TYPES] = { - -1, - _gloffset_Indexubv, - _gloffset_Indexsv, - -1, - _gloffset_Indexiv, - -1, - _gloffset_Indexfv, - _gloffset_Indexdv, -}; - -static const int NormalFuncs[NUM_TYPES] = { - _gloffset_Normal3bv, - -1, - _gloffset_Normal3sv, - -1, - _gloffset_Normal3iv, - -1, - _gloffset_Normal3fv, - _gloffset_Normal3dv, -}; - -/* Note: _gloffset_* for these may not be a compile-time constant. */ -static int SecondaryColorFuncs[NUM_TYPES]; -static int FogCoordFuncs[NUM_TYPES]; - - -/** - ** GL_NV_vertex_program - **/ - -/* GL_BYTE attributes */ - -static void GLAPIENTRY -VertexAttrib1NbvNV(GLuint index, const GLbyte *v) -{ - CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]))); -} - -static void GLAPIENTRY -VertexAttrib1bvNV(GLuint index, const GLbyte *v) -{ - CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, (GLfloat)v[0])); -} - -static void GLAPIENTRY -VertexAttrib2NbvNV(GLuint index, const GLbyte *v) -{ - CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]), BYTE_TO_FLOAT(v[1]))); -} - -static void GLAPIENTRY -VertexAttrib2bvNV(GLuint index, const GLbyte *v) -{ - CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1])); -} - -static void GLAPIENTRY -VertexAttrib3NbvNV(GLuint index, const GLbyte *v) -{ - CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]), - BYTE_TO_FLOAT(v[1]), - BYTE_TO_FLOAT(v[2]))); -} - -static void GLAPIENTRY -VertexAttrib3bvNV(GLuint index, const GLbyte *v) -{ - CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2])); -} - -static void GLAPIENTRY -VertexAttrib4NbvNV(GLuint index, const GLbyte *v) -{ - CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]), - BYTE_TO_FLOAT(v[1]), - BYTE_TO_FLOAT(v[2]), - BYTE_TO_FLOAT(v[3]))); -} - -static void GLAPIENTRY -VertexAttrib4bvNV(GLuint index, const GLbyte *v) -{ - CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2], (GLfloat)v[3])); -} - -/* GL_UNSIGNED_BYTE attributes */ - -static void GLAPIENTRY -VertexAttrib1NubvNV(GLuint index, const GLubyte *v) -{ - CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0]))); -} - -static void GLAPIENTRY -VertexAttrib1ubvNV(GLuint index, const GLubyte *v) -{ - CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, (GLfloat)v[0])); -} - -static void GLAPIENTRY -VertexAttrib2NubvNV(GLuint index, const GLubyte *v) -{ - CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0]), - UBYTE_TO_FLOAT(v[1]))); -} - -static void GLAPIENTRY -VertexAttrib2ubvNV(GLuint index, const GLubyte *v) -{ - CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1])); -} - -static void GLAPIENTRY -VertexAttrib3NubvNV(GLuint index, const GLubyte *v) -{ - CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0]), - UBYTE_TO_FLOAT(v[1]), - UBYTE_TO_FLOAT(v[2]))); -} -static void GLAPIENTRY -VertexAttrib3ubvNV(GLuint index, const GLubyte *v) -{ - CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, (GLfloat)v[0], - (GLfloat)v[1], (GLfloat)v[2])); -} - -static void GLAPIENTRY -VertexAttrib4NubvNV(GLuint index, const GLubyte *v) -{ - CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0]), - UBYTE_TO_FLOAT(v[1]), - UBYTE_TO_FLOAT(v[2]), - UBYTE_TO_FLOAT(v[3]))); -} - -static void GLAPIENTRY -VertexAttrib4ubvNV(GLuint index, const GLubyte *v) -{ - CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, (GLfloat)v[0], - (GLfloat)v[1], (GLfloat)v[2], - (GLfloat)v[3])); -} - -/* GL_SHORT attributes */ - -static void GLAPIENTRY -VertexAttrib1NsvNV(GLuint index, const GLshort *v) -{ - CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0]))); -} - -static void GLAPIENTRY -VertexAttrib1svNV(GLuint index, const GLshort *v) -{ - CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, (GLfloat)v[0])); -} - -static void GLAPIENTRY -VertexAttrib2NsvNV(GLuint index, const GLshort *v) -{ - CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0]), - SHORT_TO_FLOAT(v[1]))); -} - -static void GLAPIENTRY -VertexAttrib2svNV(GLuint index, const GLshort *v) -{ - CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1])); -} - -static void GLAPIENTRY -VertexAttrib3NsvNV(GLuint index, const GLshort *v) -{ - CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0]), - SHORT_TO_FLOAT(v[1]), - SHORT_TO_FLOAT(v[2]))); -} - -static void GLAPIENTRY -VertexAttrib3svNV(GLuint index, const GLshort *v) -{ - CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], - (GLfloat)v[2])); -} - -static void GLAPIENTRY -VertexAttrib4NsvNV(GLuint index, const GLshort *v) -{ - CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0]), - SHORT_TO_FLOAT(v[1]), - SHORT_TO_FLOAT(v[2]), - SHORT_TO_FLOAT(v[3]))); -} - -static void GLAPIENTRY -VertexAttrib4svNV(GLuint index, const GLshort *v) -{ - CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], - (GLfloat)v[2], (GLfloat)v[3])); -} - -/* GL_UNSIGNED_SHORT attributes */ - -static void GLAPIENTRY -VertexAttrib1NusvNV(GLuint index, const GLushort *v) -{ - CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]))); -} - -static void GLAPIENTRY -VertexAttrib1usvNV(GLuint index, const GLushort *v) -{ - CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, (GLfloat)v[0])); -} - -static void GLAPIENTRY -VertexAttrib2NusvNV(GLuint index, const GLushort *v) -{ - CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]), - USHORT_TO_FLOAT(v[1]))); -} - -static void GLAPIENTRY -VertexAttrib2usvNV(GLuint index, const GLushort *v) -{ - CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, (GLfloat)v[0], - (GLfloat)v[1])); -} - -static void GLAPIENTRY -VertexAttrib3NusvNV(GLuint index, const GLushort *v) -{ - CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]), - USHORT_TO_FLOAT(v[1]), - USHORT_TO_FLOAT(v[2]))); -} - -static void GLAPIENTRY -VertexAttrib3usvNV(GLuint index, const GLushort *v) -{ - CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], - (GLfloat)v[2])); -} - -static void GLAPIENTRY -VertexAttrib4NusvNV(GLuint index, const GLushort *v) -{ - CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]), - USHORT_TO_FLOAT(v[1]), - USHORT_TO_FLOAT(v[2]), - USHORT_TO_FLOAT(v[3]))); -} - -static void GLAPIENTRY -VertexAttrib4usvNV(GLuint index, const GLushort *v) -{ - CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], - (GLfloat)v[2], (GLfloat)v[3])); -} - -/* GL_INT attributes */ - -static void GLAPIENTRY -VertexAttrib1NivNV(GLuint index, const GLint *v) -{ - CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]))); -} - -static void GLAPIENTRY -VertexAttrib1ivNV(GLuint index, const GLint *v) -{ - CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, (GLfloat)v[0])); -} - -static void GLAPIENTRY -VertexAttrib2NivNV(GLuint index, const GLint *v) -{ - CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]), - INT_TO_FLOAT(v[1]))); -} - -static void GLAPIENTRY -VertexAttrib2ivNV(GLuint index, const GLint *v) -{ - CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1])); -} - -static void GLAPIENTRY -VertexAttrib3NivNV(GLuint index, const GLint *v) -{ - CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]), - INT_TO_FLOAT(v[1]), - INT_TO_FLOAT(v[2]))); -} - -static void GLAPIENTRY -VertexAttrib3ivNV(GLuint index, const GLint *v) -{ - CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], - (GLfloat)v[2])); -} - -static void GLAPIENTRY -VertexAttrib4NivNV(GLuint index, const GLint *v) -{ - CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]), - INT_TO_FLOAT(v[1]), - INT_TO_FLOAT(v[2]), - INT_TO_FLOAT(v[3]))); -} - -static void GLAPIENTRY -VertexAttrib4ivNV(GLuint index, const GLint *v) -{ - CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], - (GLfloat)v[2], (GLfloat)v[3])); -} - -/* GL_UNSIGNED_INT attributes */ - -static void GLAPIENTRY -VertexAttrib1NuivNV(GLuint index, const GLuint *v) -{ - CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]))); -} - -static void GLAPIENTRY -VertexAttrib1uivNV(GLuint index, const GLuint *v) -{ - CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, (GLfloat)v[0])); -} - -static void GLAPIENTRY -VertexAttrib2NuivNV(GLuint index, const GLuint *v) -{ - CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]), - UINT_TO_FLOAT(v[1]))); -} - -static void GLAPIENTRY -VertexAttrib2uivNV(GLuint index, const GLuint *v) -{ - CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, (GLfloat)v[0], - (GLfloat)v[1])); -} - -static void GLAPIENTRY -VertexAttrib3NuivNV(GLuint index, const GLuint *v) -{ - CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]), - UINT_TO_FLOAT(v[1]), - UINT_TO_FLOAT(v[2]))); -} - -static void GLAPIENTRY -VertexAttrib3uivNV(GLuint index, const GLuint *v) -{ - CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], - (GLfloat)v[2])); -} - -static void GLAPIENTRY -VertexAttrib4NuivNV(GLuint index, const GLuint *v) -{ - CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]), - UINT_TO_FLOAT(v[1]), - UINT_TO_FLOAT(v[2]), - UINT_TO_FLOAT(v[3]))); -} - -static void GLAPIENTRY -VertexAttrib4uivNV(GLuint index, const GLuint *v) -{ - CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], - (GLfloat)v[2], (GLfloat)v[3])); -} - -/* GL_FLOAT attributes */ - -static void GLAPIENTRY -VertexAttrib1fvNV(GLuint index, const GLfloat *v) -{ - CALL_VertexAttrib1fvNV(GET_DISPATCH(), (index, v)); -} - -static void GLAPIENTRY -VertexAttrib2fvNV(GLuint index, const GLfloat *v) -{ - CALL_VertexAttrib2fvNV(GET_DISPATCH(), (index, v)); -} - -static void GLAPIENTRY -VertexAttrib3fvNV(GLuint index, const GLfloat *v) -{ - CALL_VertexAttrib3fvNV(GET_DISPATCH(), (index, v)); -} - -static void GLAPIENTRY -VertexAttrib4fvNV(GLuint index, const GLfloat *v) -{ - CALL_VertexAttrib4fvNV(GET_DISPATCH(), (index, v)); -} - -/* GL_DOUBLE attributes */ - -static void GLAPIENTRY -VertexAttrib1dvNV(GLuint index, const GLdouble *v) -{ - CALL_VertexAttrib1dvNV(GET_DISPATCH(), (index, v)); -} - -static void GLAPIENTRY -VertexAttrib2dvNV(GLuint index, const GLdouble *v) -{ - CALL_VertexAttrib2dvNV(GET_DISPATCH(), (index, v)); -} - -static void GLAPIENTRY -VertexAttrib3dvNV(GLuint index, const GLdouble *v) -{ - CALL_VertexAttrib3dvNV(GET_DISPATCH(), (index, v)); -} - -static void GLAPIENTRY -VertexAttrib4dvNV(GLuint index, const GLdouble *v) -{ - CALL_VertexAttrib4dvNV(GET_DISPATCH(), (index, v)); -} - - -/* - * Array [size][type] of VertexAttrib functions - */ -static attrib_func AttribFuncsNV[2][4][NUM_TYPES] = { - { - /* non-normalized */ - { - /* size 1 */ - (attrib_func) VertexAttrib1bvNV, - (attrib_func) VertexAttrib1ubvNV, - (attrib_func) VertexAttrib1svNV, - (attrib_func) VertexAttrib1usvNV, - (attrib_func) VertexAttrib1ivNV, - (attrib_func) VertexAttrib1uivNV, - (attrib_func) VertexAttrib1fvNV, - (attrib_func) VertexAttrib1dvNV - }, - { - /* size 2 */ - (attrib_func) VertexAttrib2bvNV, - (attrib_func) VertexAttrib2ubvNV, - (attrib_func) VertexAttrib2svNV, - (attrib_func) VertexAttrib2usvNV, - (attrib_func) VertexAttrib2ivNV, - (attrib_func) VertexAttrib2uivNV, - (attrib_func) VertexAttrib2fvNV, - (attrib_func) VertexAttrib2dvNV - }, - { - /* size 3 */ - (attrib_func) VertexAttrib3bvNV, - (attrib_func) VertexAttrib3ubvNV, - (attrib_func) VertexAttrib3svNV, - (attrib_func) VertexAttrib3usvNV, - (attrib_func) VertexAttrib3ivNV, - (attrib_func) VertexAttrib3uivNV, - (attrib_func) VertexAttrib3fvNV, - (attrib_func) VertexAttrib3dvNV - }, - { - /* size 4 */ - (attrib_func) VertexAttrib4bvNV, - (attrib_func) VertexAttrib4ubvNV, - (attrib_func) VertexAttrib4svNV, - (attrib_func) VertexAttrib4usvNV, - (attrib_func) VertexAttrib4ivNV, - (attrib_func) VertexAttrib4uivNV, - (attrib_func) VertexAttrib4fvNV, - (attrib_func) VertexAttrib4dvNV - } - }, - { - /* normalized (except for float/double) */ - { - /* size 1 */ - (attrib_func) VertexAttrib1NbvNV, - (attrib_func) VertexAttrib1NubvNV, - (attrib_func) VertexAttrib1NsvNV, - (attrib_func) VertexAttrib1NusvNV, - (attrib_func) VertexAttrib1NivNV, - (attrib_func) VertexAttrib1NuivNV, - (attrib_func) VertexAttrib1fvNV, - (attrib_func) VertexAttrib1dvNV - }, - { - /* size 2 */ - (attrib_func) VertexAttrib2NbvNV, - (attrib_func) VertexAttrib2NubvNV, - (attrib_func) VertexAttrib2NsvNV, - (attrib_func) VertexAttrib2NusvNV, - (attrib_func) VertexAttrib2NivNV, - (attrib_func) VertexAttrib2NuivNV, - (attrib_func) VertexAttrib2fvNV, - (attrib_func) VertexAttrib2dvNV - }, - { - /* size 3 */ - (attrib_func) VertexAttrib3NbvNV, - (attrib_func) VertexAttrib3NubvNV, - (attrib_func) VertexAttrib3NsvNV, - (attrib_func) VertexAttrib3NusvNV, - (attrib_func) VertexAttrib3NivNV, - (attrib_func) VertexAttrib3NuivNV, - (attrib_func) VertexAttrib3fvNV, - (attrib_func) VertexAttrib3dvNV - }, - { - /* size 4 */ - (attrib_func) VertexAttrib4NbvNV, - (attrib_func) VertexAttrib4NubvNV, - (attrib_func) VertexAttrib4NsvNV, - (attrib_func) VertexAttrib4NusvNV, - (attrib_func) VertexAttrib4NivNV, - (attrib_func) VertexAttrib4NuivNV, - (attrib_func) VertexAttrib4fvNV, - (attrib_func) VertexAttrib4dvNV - } - } -}; - - -/** - ** GL_ARB_vertex_program - **/ - -/* GL_BYTE attributes */ - -static void GLAPIENTRY -VertexAttrib1NbvARB(GLuint index, const GLbyte *v) -{ - CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]))); -} - -static void GLAPIENTRY -VertexAttrib1bvARB(GLuint index, const GLbyte *v) -{ - CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, (GLfloat)v[0])); -} - -static void GLAPIENTRY -VertexAttrib2NbvARB(GLuint index, const GLbyte *v) -{ - CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]), BYTE_TO_FLOAT(v[1]))); -} - -static void GLAPIENTRY -VertexAttrib2bvARB(GLuint index, const GLbyte *v) -{ - CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1])); -} - -static void GLAPIENTRY -VertexAttrib3NbvARB(GLuint index, const GLbyte *v) -{ - CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]), - BYTE_TO_FLOAT(v[1]), - BYTE_TO_FLOAT(v[2]))); -} - -static void GLAPIENTRY -VertexAttrib3bvARB(GLuint index, const GLbyte *v) -{ - CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2])); -} - -static void GLAPIENTRY -VertexAttrib4NbvARB(GLuint index, const GLbyte *v) -{ - CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]), - BYTE_TO_FLOAT(v[1]), - BYTE_TO_FLOAT(v[2]), - BYTE_TO_FLOAT(v[3]))); -} - -static void GLAPIENTRY -VertexAttrib4bvARB(GLuint index, const GLbyte *v) -{ - CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2], (GLfloat)v[3])); -} - -/* GL_UNSIGNED_BYTE attributes */ - -static void GLAPIENTRY -VertexAttrib1NubvARB(GLuint index, const GLubyte *v) -{ - CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0]))); -} - -static void GLAPIENTRY -VertexAttrib1ubvARB(GLuint index, const GLubyte *v) -{ - CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, (GLfloat)v[0])); -} - -static void GLAPIENTRY -VertexAttrib2NubvARB(GLuint index, const GLubyte *v) -{ - CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, - UBYTE_TO_FLOAT(v[0]), - UBYTE_TO_FLOAT(v[1]))); -} - -static void GLAPIENTRY -VertexAttrib2ubvARB(GLuint index, const GLubyte *v) -{ - CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, - (GLfloat)v[0], (GLfloat)v[1])); -} - -static void GLAPIENTRY -VertexAttrib3NubvARB(GLuint index, const GLubyte *v) -{ - CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, - UBYTE_TO_FLOAT(v[0]), - UBYTE_TO_FLOAT(v[1]), - UBYTE_TO_FLOAT(v[2]))); -} -static void GLAPIENTRY -VertexAttrib3ubvARB(GLuint index, const GLubyte *v) -{ - CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, - (GLfloat)v[0], - (GLfloat)v[1], - (GLfloat)v[2])); -} - -static void GLAPIENTRY -VertexAttrib4NubvARB(GLuint index, const GLubyte *v) -{ - CALL_VertexAttrib4fARB(GET_DISPATCH(), - (index, - UBYTE_TO_FLOAT(v[0]), - UBYTE_TO_FLOAT(v[1]), - UBYTE_TO_FLOAT(v[2]), - UBYTE_TO_FLOAT(v[3]))); -} - -static void GLAPIENTRY -VertexAttrib4ubvARB(GLuint index, const GLubyte *v) -{ - CALL_VertexAttrib4fARB(GET_DISPATCH(), - (index, - (GLfloat)v[0], (GLfloat)v[1], - (GLfloat)v[2], (GLfloat)v[3])); -} - -/* GL_SHORT attributes */ - -static void GLAPIENTRY -VertexAttrib1NsvARB(GLuint index, const GLshort *v) -{ - CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0]))); -} - -static void GLAPIENTRY -VertexAttrib1svARB(GLuint index, const GLshort *v) -{ - CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, (GLfloat)v[0])); -} - -static void GLAPIENTRY -VertexAttrib2NsvARB(GLuint index, const GLshort *v) -{ - CALL_VertexAttrib2fARB(GET_DISPATCH(), - (index, SHORT_TO_FLOAT(v[0]), - SHORT_TO_FLOAT(v[1]))); -} - -static void GLAPIENTRY -VertexAttrib2svARB(GLuint index, const GLshort *v) -{ - CALL_VertexAttrib2fARB(GET_DISPATCH(), - (index, (GLfloat)v[0], (GLfloat)v[1])); -} - -static void GLAPIENTRY -VertexAttrib3NsvARB(GLuint index, const GLshort *v) -{ - CALL_VertexAttrib3fARB(GET_DISPATCH(), - (index, - SHORT_TO_FLOAT(v[0]), - SHORT_TO_FLOAT(v[1]), - SHORT_TO_FLOAT(v[2]))); -} - -static void GLAPIENTRY -VertexAttrib3svARB(GLuint index, const GLshort *v) -{ - CALL_VertexAttrib3fARB(GET_DISPATCH(), - (index, - (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2])); -} - -static void GLAPIENTRY -VertexAttrib4NsvARB(GLuint index, const GLshort *v) -{ - CALL_VertexAttrib4fARB(GET_DISPATCH(), - (index, - SHORT_TO_FLOAT(v[0]), - SHORT_TO_FLOAT(v[1]), - SHORT_TO_FLOAT(v[2]), - SHORT_TO_FLOAT(v[3]))); -} - -static void GLAPIENTRY -VertexAttrib4svARB(GLuint index, const GLshort *v) -{ - CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], - (GLfloat)v[2], (GLfloat)v[3])); -} - -/* GL_UNSIGNED_SHORT attributes */ - -static void GLAPIENTRY -VertexAttrib1NusvARB(GLuint index, const GLushort *v) -{ - CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]))); -} - -static void GLAPIENTRY -VertexAttrib1usvARB(GLuint index, const GLushort *v) -{ - CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, (GLfloat)v[0])); -} - -static void GLAPIENTRY -VertexAttrib2NusvARB(GLuint index, const GLushort *v) -{ - CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]), - USHORT_TO_FLOAT(v[1]))); -} - -static void GLAPIENTRY -VertexAttrib2usvARB(GLuint index, const GLushort *v) -{ - CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, (GLfloat)v[0], - (GLfloat)v[1])); -} - -static void GLAPIENTRY -VertexAttrib3NusvARB(GLuint index, const GLushort *v) -{ - CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]), - USHORT_TO_FLOAT(v[1]), - USHORT_TO_FLOAT(v[2]))); -} - -static void GLAPIENTRY -VertexAttrib3usvARB(GLuint index, const GLushort *v) -{ - CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, (GLfloat)v[0], - (GLfloat)v[1], (GLfloat)v[2])); -} - -static void GLAPIENTRY -VertexAttrib4NusvARB(GLuint index, const GLushort *v) -{ - CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]), - USHORT_TO_FLOAT(v[1]), - USHORT_TO_FLOAT(v[2]), - USHORT_TO_FLOAT(v[3]))); -} - -static void GLAPIENTRY -VertexAttrib4usvARB(GLuint index, const GLushort *v) -{ - CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2], (GLfloat)v[3])); -} - -/* GL_INT attributes */ - -static void GLAPIENTRY -VertexAttrib1NivARB(GLuint index, const GLint *v) -{ - CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]))); -} - -static void GLAPIENTRY -VertexAttrib1ivARB(GLuint index, const GLint *v) -{ - CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, (GLfloat)v[0])); -} - -static void GLAPIENTRY -VertexAttrib2NivARB(GLuint index, const GLint *v) -{ - CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]), - INT_TO_FLOAT(v[1]))); -} - -static void GLAPIENTRY -VertexAttrib2ivARB(GLuint index, const GLint *v) -{ - CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, (GLfloat)v[0], - (GLfloat)v[1])); -} - -static void GLAPIENTRY -VertexAttrib3NivARB(GLuint index, const GLint *v) -{ - CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]), - INT_TO_FLOAT(v[1]), - INT_TO_FLOAT(v[2]))); -} - -static void GLAPIENTRY -VertexAttrib3ivARB(GLuint index, const GLint *v) -{ - CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, (GLfloat)v[0], - (GLfloat)v[1], (GLfloat)v[2])); -} - -static void GLAPIENTRY -VertexAttrib4NivARB(GLuint index, const GLint *v) -{ - CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]), - INT_TO_FLOAT(v[1]), - INT_TO_FLOAT(v[2]), - INT_TO_FLOAT(v[3]))); -} - -static void GLAPIENTRY -VertexAttrib4ivARB(GLuint index, const GLint *v) -{ - CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], - (GLfloat)v[2], (GLfloat)v[3])); -} - -/* GL_UNSIGNED_INT attributes */ - -static void GLAPIENTRY -VertexAttrib1NuivARB(GLuint index, const GLuint *v) -{ - CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]))); -} - -static void GLAPIENTRY -VertexAttrib1uivARB(GLuint index, const GLuint *v) -{ - CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, (GLfloat)v[0])); -} - -static void GLAPIENTRY -VertexAttrib2NuivARB(GLuint index, const GLuint *v) -{ - CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]), - UINT_TO_FLOAT(v[1]))); -} - -static void GLAPIENTRY -VertexAttrib2uivARB(GLuint index, const GLuint *v) -{ - CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, (GLfloat)v[0], - (GLfloat)v[1])); -} - -static void GLAPIENTRY -VertexAttrib3NuivARB(GLuint index, const GLuint *v) -{ - CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]), - UINT_TO_FLOAT(v[1]), - UINT_TO_FLOAT(v[2]))); -} - -static void GLAPIENTRY -VertexAttrib3uivARB(GLuint index, const GLuint *v) -{ - CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, (GLfloat)v[0], - (GLfloat)v[1], (GLfloat)v[2])); -} - -static void GLAPIENTRY -VertexAttrib4NuivARB(GLuint index, const GLuint *v) -{ - CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]), - UINT_TO_FLOAT(v[1]), - UINT_TO_FLOAT(v[2]), - UINT_TO_FLOAT(v[3]))); -} - -static void GLAPIENTRY -VertexAttrib4uivARB(GLuint index, const GLuint *v) -{ - CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], - (GLfloat)v[2], (GLfloat)v[3])); -} - -/* GL_FLOAT attributes */ - -static void GLAPIENTRY -VertexAttrib1fvARB(GLuint index, const GLfloat *v) -{ - CALL_VertexAttrib1fvARB(GET_DISPATCH(), (index, v)); -} - -static void GLAPIENTRY -VertexAttrib2fvARB(GLuint index, const GLfloat *v) -{ - CALL_VertexAttrib2fvARB(GET_DISPATCH(), (index, v)); -} - -static void GLAPIENTRY -VertexAttrib3fvARB(GLuint index, const GLfloat *v) -{ - CALL_VertexAttrib3fvARB(GET_DISPATCH(), (index, v)); -} - -static void GLAPIENTRY -VertexAttrib4fvARB(GLuint index, const GLfloat *v) -{ - CALL_VertexAttrib4fvARB(GET_DISPATCH(), (index, v)); -} - -/* GL_DOUBLE attributes */ - -static void GLAPIENTRY -VertexAttrib1dvARB(GLuint index, const GLdouble *v) -{ - CALL_VertexAttrib1dvARB(GET_DISPATCH(), (index, v)); -} - -static void GLAPIENTRY -VertexAttrib2dvARB(GLuint index, const GLdouble *v) -{ - CALL_VertexAttrib2dvARB(GET_DISPATCH(), (index, v)); -} - -static void GLAPIENTRY -VertexAttrib3dvARB(GLuint index, const GLdouble *v) -{ - CALL_VertexAttrib3dvARB(GET_DISPATCH(), (index, v)); -} - -static void GLAPIENTRY -VertexAttrib4dvARB(GLuint index, const GLdouble *v) -{ - CALL_VertexAttrib4dvARB(GET_DISPATCH(), (index, v)); -} - - -/** - * Integer-valued attributes - */ -static void GLAPIENTRY -VertexAttribI1bv(GLuint index, const GLbyte *v) -{ - CALL_VertexAttribI1iEXT(GET_DISPATCH(), (index, v[0])); -} - -static void GLAPIENTRY -VertexAttribI2bv(GLuint index, const GLbyte *v) -{ - CALL_VertexAttribI2iEXT(GET_DISPATCH(), (index, v[0], v[1])); -} - -static void GLAPIENTRY -VertexAttribI3bv(GLuint index, const GLbyte *v) -{ - CALL_VertexAttribI3iEXT(GET_DISPATCH(), (index, v[0], v[1], v[2])); -} - -static void GLAPIENTRY -VertexAttribI4bv(GLuint index, const GLbyte *v) -{ - CALL_VertexAttribI4bvEXT(GET_DISPATCH(), (index, v)); -} - - -static void GLAPIENTRY -VertexAttribI1ubv(GLuint index, const GLubyte *v) -{ - CALL_VertexAttribI1uiEXT(GET_DISPATCH(), (index, v[0])); -} - -static void GLAPIENTRY -VertexAttribI2ubv(GLuint index, const GLubyte *v) -{ - CALL_VertexAttribI2uiEXT(GET_DISPATCH(), (index, v[0], v[1])); -} - -static void GLAPIENTRY -VertexAttribI3ubv(GLuint index, const GLubyte *v) -{ - CALL_VertexAttribI3uiEXT(GET_DISPATCH(), (index, v[0], v[1], v[2])); -} - -static void GLAPIENTRY -VertexAttribI4ubv(GLuint index, const GLubyte *v) -{ - CALL_VertexAttribI4ubvEXT(GET_DISPATCH(), (index, v)); -} - - - -static void GLAPIENTRY -VertexAttribI1sv(GLuint index, const GLshort *v) -{ - CALL_VertexAttribI1iEXT(GET_DISPATCH(), (index, v[0])); -} - -static void GLAPIENTRY -VertexAttribI2sv(GLuint index, const GLshort *v) -{ - CALL_VertexAttribI2iEXT(GET_DISPATCH(), (index, v[0], v[1])); -} - -static void GLAPIENTRY -VertexAttribI3sv(GLuint index, const GLshort *v) -{ - CALL_VertexAttribI3iEXT(GET_DISPATCH(), (index, v[0], v[1], v[2])); -} - -static void GLAPIENTRY -VertexAttribI4sv(GLuint index, const GLshort *v) -{ - CALL_VertexAttribI4svEXT(GET_DISPATCH(), (index, v)); -} - - -static void GLAPIENTRY -VertexAttribI1usv(GLuint index, const GLushort *v) -{ - CALL_VertexAttribI1uiEXT(GET_DISPATCH(), (index, v[0])); -} - -static void GLAPIENTRY -VertexAttribI2usv(GLuint index, const GLushort *v) -{ - CALL_VertexAttribI2uiEXT(GET_DISPATCH(), (index, v[0], v[1])); -} - -static void GLAPIENTRY -VertexAttribI3usv(GLuint index, const GLushort *v) -{ - CALL_VertexAttribI3uiEXT(GET_DISPATCH(), (index, v[0], v[1], v[2])); -} - -static void GLAPIENTRY -VertexAttribI4usv(GLuint index, const GLushort *v) -{ - CALL_VertexAttribI4usvEXT(GET_DISPATCH(), (index, v)); -} - - - -static void GLAPIENTRY -VertexAttribI1iv(GLuint index, const GLint *v) -{ - CALL_VertexAttribI1iEXT(GET_DISPATCH(), (index, v[0])); -} - -static void GLAPIENTRY -VertexAttribI2iv(GLuint index, const GLint *v) -{ - CALL_VertexAttribI2iEXT(GET_DISPATCH(), (index, v[0], v[1])); -} - -static void GLAPIENTRY -VertexAttribI3iv(GLuint index, const GLint *v) -{ - CALL_VertexAttribI3iEXT(GET_DISPATCH(), (index, v[0], v[1], v[2])); -} - -static void GLAPIENTRY -VertexAttribI4iv(GLuint index, const GLint *v) -{ - CALL_VertexAttribI4ivEXT(GET_DISPATCH(), (index, v)); -} - - -static void GLAPIENTRY -VertexAttribI1uiv(GLuint index, const GLuint *v) -{ - CALL_VertexAttribI1uiEXT(GET_DISPATCH(), (index, v[0])); -} - -static void GLAPIENTRY -VertexAttribI2uiv(GLuint index, const GLuint *v) -{ - CALL_VertexAttribI2uiEXT(GET_DISPATCH(), (index, v[0], v[1])); -} - -static void GLAPIENTRY -VertexAttribI3uiv(GLuint index, const GLuint *v) -{ - CALL_VertexAttribI3uiEXT(GET_DISPATCH(), (index, v[0], v[1], v[2])); -} - -static void GLAPIENTRY -VertexAttribI4uiv(GLuint index, const GLuint *v) -{ - CALL_VertexAttribI4uivEXT(GET_DISPATCH(), (index, v)); -} - - - - -/* - * Array [unnormalized/normalized/integer][size][type] of VertexAttrib - * functions - */ -static attrib_func AttribFuncsARB[3][4][NUM_TYPES] = { - { - /* non-normalized */ - { - /* size 1 */ - (attrib_func) VertexAttrib1bvARB, - (attrib_func) VertexAttrib1ubvARB, - (attrib_func) VertexAttrib1svARB, - (attrib_func) VertexAttrib1usvARB, - (attrib_func) VertexAttrib1ivARB, - (attrib_func) VertexAttrib1uivARB, - (attrib_func) VertexAttrib1fvARB, - (attrib_func) VertexAttrib1dvARB - }, - { - /* size 2 */ - (attrib_func) VertexAttrib2bvARB, - (attrib_func) VertexAttrib2ubvARB, - (attrib_func) VertexAttrib2svARB, - (attrib_func) VertexAttrib2usvARB, - (attrib_func) VertexAttrib2ivARB, - (attrib_func) VertexAttrib2uivARB, - (attrib_func) VertexAttrib2fvARB, - (attrib_func) VertexAttrib2dvARB - }, - { - /* size 3 */ - (attrib_func) VertexAttrib3bvARB, - (attrib_func) VertexAttrib3ubvARB, - (attrib_func) VertexAttrib3svARB, - (attrib_func) VertexAttrib3usvARB, - (attrib_func) VertexAttrib3ivARB, - (attrib_func) VertexAttrib3uivARB, - (attrib_func) VertexAttrib3fvARB, - (attrib_func) VertexAttrib3dvARB - }, - { - /* size 4 */ - (attrib_func) VertexAttrib4bvARB, - (attrib_func) VertexAttrib4ubvARB, - (attrib_func) VertexAttrib4svARB, - (attrib_func) VertexAttrib4usvARB, - (attrib_func) VertexAttrib4ivARB, - (attrib_func) VertexAttrib4uivARB, - (attrib_func) VertexAttrib4fvARB, - (attrib_func) VertexAttrib4dvARB - } - }, - { - /* normalized (except for float/double) */ - { - /* size 1 */ - (attrib_func) VertexAttrib1NbvARB, - (attrib_func) VertexAttrib1NubvARB, - (attrib_func) VertexAttrib1NsvARB, - (attrib_func) VertexAttrib1NusvARB, - (attrib_func) VertexAttrib1NivARB, - (attrib_func) VertexAttrib1NuivARB, - (attrib_func) VertexAttrib1fvARB, - (attrib_func) VertexAttrib1dvARB - }, - { - /* size 2 */ - (attrib_func) VertexAttrib2NbvARB, - (attrib_func) VertexAttrib2NubvARB, - (attrib_func) VertexAttrib2NsvARB, - (attrib_func) VertexAttrib2NusvARB, - (attrib_func) VertexAttrib2NivARB, - (attrib_func) VertexAttrib2NuivARB, - (attrib_func) VertexAttrib2fvARB, - (attrib_func) VertexAttrib2dvARB - }, - { - /* size 3 */ - (attrib_func) VertexAttrib3NbvARB, - (attrib_func) VertexAttrib3NubvARB, - (attrib_func) VertexAttrib3NsvARB, - (attrib_func) VertexAttrib3NusvARB, - (attrib_func) VertexAttrib3NivARB, - (attrib_func) VertexAttrib3NuivARB, - (attrib_func) VertexAttrib3fvARB, - (attrib_func) VertexAttrib3dvARB - }, - { - /* size 4 */ - (attrib_func) VertexAttrib4NbvARB, - (attrib_func) VertexAttrib4NubvARB, - (attrib_func) VertexAttrib4NsvARB, - (attrib_func) VertexAttrib4NusvARB, - (attrib_func) VertexAttrib4NivARB, - (attrib_func) VertexAttrib4NuivARB, - (attrib_func) VertexAttrib4fvARB, - (attrib_func) VertexAttrib4dvARB - } - }, - - { - /* integer-valued */ - { - /* size 1 */ - (attrib_func) VertexAttribI1bv, - (attrib_func) VertexAttribI1ubv, - (attrib_func) VertexAttribI1sv, - (attrib_func) VertexAttribI1usv, - (attrib_func) VertexAttribI1iv, - (attrib_func) VertexAttribI1uiv, - NULL, /* GL_FLOAT */ - NULL /* GL_DOUBLE */ - }, - { - /* size 2 */ - (attrib_func) VertexAttribI2bv, - (attrib_func) VertexAttribI2ubv, - (attrib_func) VertexAttribI2sv, - (attrib_func) VertexAttribI2usv, - (attrib_func) VertexAttribI2iv, - (attrib_func) VertexAttribI2uiv, - NULL, /* GL_FLOAT */ - NULL /* GL_DOUBLE */ - }, - { - /* size 3 */ - (attrib_func) VertexAttribI3bv, - (attrib_func) VertexAttribI3ubv, - (attrib_func) VertexAttribI3sv, - (attrib_func) VertexAttribI3usv, - (attrib_func) VertexAttribI3iv, - (attrib_func) VertexAttribI3uiv, - NULL, /* GL_FLOAT */ - NULL /* GL_DOUBLE */ - }, - { - /* size 4 */ - (attrib_func) VertexAttribI4bv, - (attrib_func) VertexAttribI4ubv, - (attrib_func) VertexAttribI4sv, - (attrib_func) VertexAttribI4usv, - (attrib_func) VertexAttribI4iv, - (attrib_func) VertexAttribI4uiv, - NULL, /* GL_FLOAT */ - NULL /* GL_DOUBLE */ - } - } -}; - -/**********************************************************************/ - - -GLboolean _ae_create_context( struct gl_context *ctx ) -{ - if (ctx->aelt_context) - return GL_TRUE; - - /* These _gloffset_* values may not be compile-time constants */ - SecondaryColorFuncs[0] = _gloffset_SecondaryColor3bvEXT; - SecondaryColorFuncs[1] = _gloffset_SecondaryColor3ubvEXT; - SecondaryColorFuncs[2] = _gloffset_SecondaryColor3svEXT; - SecondaryColorFuncs[3] = _gloffset_SecondaryColor3usvEXT; - SecondaryColorFuncs[4] = _gloffset_SecondaryColor3ivEXT; - SecondaryColorFuncs[5] = _gloffset_SecondaryColor3uivEXT; - SecondaryColorFuncs[6] = _gloffset_SecondaryColor3fvEXT; - SecondaryColorFuncs[7] = _gloffset_SecondaryColor3dvEXT; - - FogCoordFuncs[0] = -1; - FogCoordFuncs[1] = -1; - FogCoordFuncs[2] = -1; - FogCoordFuncs[3] = -1; - FogCoordFuncs[4] = -1; - FogCoordFuncs[5] = -1; - FogCoordFuncs[6] = _gloffset_FogCoordfvEXT; - FogCoordFuncs[7] = _gloffset_FogCoorddvEXT; - - ctx->aelt_context = CALLOC( sizeof(AEcontext) ); - if (!ctx->aelt_context) - return GL_FALSE; - - AE_CONTEXT(ctx)->NewState = ~0; - return GL_TRUE; -} - - -void _ae_destroy_context( struct gl_context *ctx ) -{ - if ( AE_CONTEXT( ctx ) ) { - FREE( ctx->aelt_context ); - ctx->aelt_context = NULL; - } -} - -static void check_vbo( AEcontext *actx, - struct gl_buffer_object *vbo ) -{ - if (_mesa_is_bufferobj(vbo) && !_mesa_bufferobj_mapped(vbo)) { - GLuint i; - for (i = 0; i < actx->nr_vbos; i++) - if (actx->vbo[i] == vbo) - return; - assert(actx->nr_vbos < VERT_ATTRIB_MAX); - actx->vbo[actx->nr_vbos++] = vbo; - } -} - - -/** - * Make a list of per-vertex functions to call for each glArrayElement call. - * These functions access the array data (i.e. glVertex, glColor, glNormal, - * etc). - * Note: this may be called during display list construction. - */ -static void _ae_update_state( struct gl_context *ctx ) -{ - AEcontext *actx = AE_CONTEXT(ctx); - AEarray *aa = actx->arrays; - AEattrib *at = actx->attribs; - GLuint i; - struct gl_array_object *arrayObj = ctx->Array.ArrayObj; - - actx->nr_vbos = 0; - - /* conventional vertex arrays */ - if (arrayObj->Index.Enabled) { - aa->array = &arrayObj->Index; - aa->offset = IndexFuncs[TYPE_IDX(aa->array->Type)]; - check_vbo(actx, aa->array->BufferObj); - aa++; - } - if (arrayObj->EdgeFlag.Enabled) { - aa->array = &arrayObj->EdgeFlag; - aa->offset = _gloffset_EdgeFlagv; - check_vbo(actx, aa->array->BufferObj); - aa++; - } - if (arrayObj->Normal.Enabled) { - aa->array = &arrayObj->Normal; - aa->offset = NormalFuncs[TYPE_IDX(aa->array->Type)]; - check_vbo(actx, aa->array->BufferObj); - aa++; - } - if (arrayObj->Color.Enabled) { - aa->array = &arrayObj->Color; - aa->offset = ColorFuncs[aa->array->Size-3][TYPE_IDX(aa->array->Type)]; - check_vbo(actx, aa->array->BufferObj); - aa++; - } - if (arrayObj->SecondaryColor.Enabled) { - aa->array = &arrayObj->SecondaryColor; - aa->offset = SecondaryColorFuncs[TYPE_IDX(aa->array->Type)]; - check_vbo(actx, aa->array->BufferObj); - aa++; - } - if (arrayObj->FogCoord.Enabled) { - aa->array = &arrayObj->FogCoord; - aa->offset = FogCoordFuncs[TYPE_IDX(aa->array->Type)]; - check_vbo(actx, aa->array->BufferObj); - aa++; - } - for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) { - struct gl_client_array *attribArray = &arrayObj->TexCoord[i]; - if (attribArray->Enabled) { - /* NOTE: we use generic glVertexAttribNV functions here. - * If we ever remove GL_NV_vertex_program this will have to change. - */ - at->array = attribArray; - ASSERT(!at->array->Normalized); - at->func = AttribFuncsNV[at->array->Normalized] - [at->array->Size-1] - [TYPE_IDX(at->array->Type)]; - at->index = VERT_ATTRIB_TEX0 + i; - check_vbo(actx, at->array->BufferObj); - at++; - } - } - - /* generic vertex attribute arrays */ - for (i = 1; i < Elements(arrayObj->VertexAttrib); i++) { /* skip zero! */ - struct gl_client_array *attribArray = &arrayObj->VertexAttrib[i]; - if (attribArray->Enabled) { - at->array = attribArray; - /* Note: we can't grab the _glapi_Dispatch->VertexAttrib1fvNV - * function pointer here (for float arrays) since the pointer may - * change from one execution of _ae_ArrayElement() to - * the next. Doing so caused UT to break. - */ - if (ctx->VertexProgram._Enabled - && ctx->VertexProgram.Current->IsNVProgram) { - at->func = AttribFuncsNV[at->array->Normalized] - [at->array->Size-1] - [TYPE_IDX(at->array->Type)]; - } - else { - GLint intOrNorm; - if (at->array->Integer) - intOrNorm = 2; - else if (at->array->Normalized) - intOrNorm = 1; - else - intOrNorm = 0; - - at->func = AttribFuncsARB[intOrNorm] - [at->array->Size-1] - [TYPE_IDX(at->array->Type)]; - } - at->index = i; - check_vbo(actx, at->array->BufferObj); - at++; - } - } - - /* finally, vertex position */ - if (arrayObj->VertexAttrib[0].Enabled) { - /* Use glVertex(v) instead of glVertexAttrib(0, v) to be sure it's - * issued as the last (provoking) attribute). - */ - aa->array = &arrayObj->VertexAttrib[0]; - assert(aa->array->Size >= 2); /* XXX fix someday? */ - aa->offset = VertexFuncs[aa->array->Size-2][TYPE_IDX(aa->array->Type)]; - check_vbo(actx, aa->array->BufferObj); - aa++; - } - else if (arrayObj->Vertex.Enabled) { - aa->array = &arrayObj->Vertex; - aa->offset = VertexFuncs[aa->array->Size-2][TYPE_IDX(aa->array->Type)]; - check_vbo(actx, aa->array->BufferObj); - aa++; - } - - check_vbo(actx, ctx->Array.ElementArrayBufferObj); - - ASSERT(at - actx->attribs <= VERT_ATTRIB_MAX); - ASSERT(aa - actx->arrays < 32); - at->func = NULL; /* terminate the list */ - aa->offset = -1; /* terminate the list */ - - actx->NewState = 0; -} - -void _ae_map_vbos( struct gl_context *ctx ) -{ - AEcontext *actx = AE_CONTEXT(ctx); - GLuint i; - - if (actx->mapped_vbos) - return; - - if (actx->NewState) - _ae_update_state(ctx); - - for (i = 0; i < actx->nr_vbos; i++) - ctx->Driver.MapBufferRange(ctx, 0, - actx->vbo[i]->Size, - GL_MAP_READ_BIT, - actx->vbo[i]); - - if (actx->nr_vbos) - actx->mapped_vbos = GL_TRUE; -} - -void _ae_unmap_vbos( struct gl_context *ctx ) -{ - AEcontext *actx = AE_CONTEXT(ctx); - GLuint i; - - if (!actx->mapped_vbos) - return; - - assert (!actx->NewState); - - for (i = 0; i < actx->nr_vbos; i++) - ctx->Driver.UnmapBuffer(ctx, actx->vbo[i]); - - actx->mapped_vbos = GL_FALSE; -} - - -/** - * Called via glArrayElement() and glDrawArrays(). - * Issue the glNormal, glVertex, glColor, glVertexAttrib, etc functions - * for all enabled vertex arrays (for elt-th element). - * Note: this may be called during display list construction. - */ -void GLAPIENTRY _ae_ArrayElement( GLint elt ) -{ - GET_CURRENT_CONTEXT(ctx); - const AEcontext *actx = AE_CONTEXT(ctx); - const AEarray *aa; - const AEattrib *at; - const struct _glapi_table * const disp = GET_DISPATCH(); - GLboolean do_map; - - if (actx->NewState) { - assert(!actx->mapped_vbos); - _ae_update_state( ctx ); - } - - /* Determine if w need to map/unmap VBOs */ - do_map = actx->nr_vbos && !actx->mapped_vbos; - - if (do_map) - _ae_map_vbos(ctx); - - /* emit generic attribute elements */ - for (at = actx->attribs; at->func; at++) { - const GLubyte *src - = ADD_POINTERS(at->array->BufferObj->Pointer, at->array->Ptr) - + elt * at->array->StrideB; - at->func( at->index, src ); - } - - /* emit conventional arrays elements */ - for (aa = actx->arrays; aa->offset != -1 ; aa++) { - const GLubyte *src - = ADD_POINTERS(aa->array->BufferObj->Pointer, aa->array->Ptr) - + elt * aa->array->StrideB; - CALL_by_offset( disp, (array_func), aa->offset, - ((const void *) src) ); - } - - if (do_map) - _ae_unmap_vbos(ctx); -} - - -void _ae_invalidate_state( struct gl_context *ctx, GLuint new_state ) -{ - AEcontext *actx = AE_CONTEXT(ctx); - - - /* Only interested in this subset of mesa state. Need to prune - * this down as both tnl/ and the drivers can raise statechanges - * for arcane reasons in the middle of seemingly atomic operations - * like DrawElements, over which we'd like to keep a known set of - * arrays and vbo's mapped. - * - * Luckily, neither the drivers nor tnl muck with the state that - * concerns us here: - */ - new_state &= _NEW_ARRAY | _NEW_PROGRAM; - if (new_state) { - assert(!actx->mapped_vbos); - actx->NewState |= new_state; - } -} - - -void _mesa_install_arrayelt_vtxfmt(struct _glapi_table *disp, - const GLvertexformat *vfmt) -{ - SET_ArrayElement(disp, vfmt->ArrayElement); -} - - -#endif /* FEATURE_arrayelt */ +/* + * 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. + */ + +/** + * This file implements the glArrayElement() function. + * It involves looking at the format/type of all the enabled vertex arrays + * and emitting a list of pointers to functions which set the per-vertex + * state for the element/index. + */ + + +/* Author: + * Keith Whitwell + */ + +#include "glheader.h" +#include "api_arrayelt.h" +#include "bufferobj.h" +#include "context.h" +#include "imports.h" +#include "macros.h" +#include "mfeatures.h" +#include "mtypes.h" +#include "main/dispatch.h" + +typedef void (GLAPIENTRY *array_func)( const void * ); + +typedef struct { + const struct gl_client_array *array; + int offset; +} AEarray; + +typedef void (GLAPIENTRY *attrib_func)( GLuint indx, const void *data ); + +typedef struct { + const struct gl_client_array *array; + attrib_func func; + GLuint index; +} AEattrib; + +typedef struct { + AEarray arrays[32]; + AEattrib attribs[VERT_ATTRIB_MAX + 1]; + GLuint NewState; + + struct gl_buffer_object *vbo[VERT_ATTRIB_MAX]; + GLuint nr_vbos; + GLboolean mapped_vbos; + +} AEcontext; + +#define AE_CONTEXT(ctx) ((AEcontext *)(ctx)->aelt_context) + + +/* + * Convert GL_BYTE, GL_UNSIGNED_BYTE, .. GL_DOUBLE into an integer + * in the range [0, 7]. Luckily these type tokens are sequentially + * numbered in gl.h, except for GL_DOUBLE. + */ +#define TYPE_IDX(t) ( (t) == GL_DOUBLE ? 7 : (t) & 7 ) + +#define NUM_TYPES 8 + + +#if FEATURE_arrayelt + + +static const int ColorFuncs[2][NUM_TYPES] = { + { + _gloffset_Color3bv, + _gloffset_Color3ubv, + _gloffset_Color3sv, + _gloffset_Color3usv, + _gloffset_Color3iv, + _gloffset_Color3uiv, + _gloffset_Color3fv, + _gloffset_Color3dv, + }, + { + _gloffset_Color4bv, + _gloffset_Color4ubv, + _gloffset_Color4sv, + _gloffset_Color4usv, + _gloffset_Color4iv, + _gloffset_Color4uiv, + _gloffset_Color4fv, + _gloffset_Color4dv, + }, +}; + +static const int VertexFuncs[3][NUM_TYPES] = { + { + -1, + -1, + _gloffset_Vertex2sv, + -1, + _gloffset_Vertex2iv, + -1, + _gloffset_Vertex2fv, + _gloffset_Vertex2dv, + }, + { + -1, + -1, + _gloffset_Vertex3sv, + -1, + _gloffset_Vertex3iv, + -1, + _gloffset_Vertex3fv, + _gloffset_Vertex3dv, + }, + { + -1, + -1, + _gloffset_Vertex4sv, + -1, + _gloffset_Vertex4iv, + -1, + _gloffset_Vertex4fv, + _gloffset_Vertex4dv, + }, +}; + +static const int IndexFuncs[NUM_TYPES] = { + -1, + _gloffset_Indexubv, + _gloffset_Indexsv, + -1, + _gloffset_Indexiv, + -1, + _gloffset_Indexfv, + _gloffset_Indexdv, +}; + +static const int NormalFuncs[NUM_TYPES] = { + _gloffset_Normal3bv, + -1, + _gloffset_Normal3sv, + -1, + _gloffset_Normal3iv, + -1, + _gloffset_Normal3fv, + _gloffset_Normal3dv, +}; + +/* Note: _gloffset_* for these may not be a compile-time constant. */ +static int SecondaryColorFuncs[NUM_TYPES]; +static int FogCoordFuncs[NUM_TYPES]; + + +/** + ** GL_NV_vertex_program + **/ + +/* GL_BYTE attributes */ + +static void GLAPIENTRY +VertexAttrib1NbvNV(GLuint index, const GLbyte *v) +{ + CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]))); +} + +static void GLAPIENTRY +VertexAttrib1bvNV(GLuint index, const GLbyte *v) +{ + CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, (GLfloat)v[0])); +} + +static void GLAPIENTRY +VertexAttrib2NbvNV(GLuint index, const GLbyte *v) +{ + CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]), BYTE_TO_FLOAT(v[1]))); +} + +static void GLAPIENTRY +VertexAttrib2bvNV(GLuint index, const GLbyte *v) +{ + CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1])); +} + +static void GLAPIENTRY +VertexAttrib3NbvNV(GLuint index, const GLbyte *v) +{ + CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]), + BYTE_TO_FLOAT(v[1]), + BYTE_TO_FLOAT(v[2]))); +} + +static void GLAPIENTRY +VertexAttrib3bvNV(GLuint index, const GLbyte *v) +{ + CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2])); +} + +static void GLAPIENTRY +VertexAttrib4NbvNV(GLuint index, const GLbyte *v) +{ + CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]), + BYTE_TO_FLOAT(v[1]), + BYTE_TO_FLOAT(v[2]), + BYTE_TO_FLOAT(v[3]))); +} + +static void GLAPIENTRY +VertexAttrib4bvNV(GLuint index, const GLbyte *v) +{ + CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2], (GLfloat)v[3])); +} + +/* GL_UNSIGNED_BYTE attributes */ + +static void GLAPIENTRY +VertexAttrib1NubvNV(GLuint index, const GLubyte *v) +{ + CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0]))); +} + +static void GLAPIENTRY +VertexAttrib1ubvNV(GLuint index, const GLubyte *v) +{ + CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, (GLfloat)v[0])); +} + +static void GLAPIENTRY +VertexAttrib2NubvNV(GLuint index, const GLubyte *v) +{ + CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0]), + UBYTE_TO_FLOAT(v[1]))); +} + +static void GLAPIENTRY +VertexAttrib2ubvNV(GLuint index, const GLubyte *v) +{ + CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1])); +} + +static void GLAPIENTRY +VertexAttrib3NubvNV(GLuint index, const GLubyte *v) +{ + CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0]), + UBYTE_TO_FLOAT(v[1]), + UBYTE_TO_FLOAT(v[2]))); +} +static void GLAPIENTRY +VertexAttrib3ubvNV(GLuint index, const GLubyte *v) +{ + CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, (GLfloat)v[0], + (GLfloat)v[1], (GLfloat)v[2])); +} + +static void GLAPIENTRY +VertexAttrib4NubvNV(GLuint index, const GLubyte *v) +{ + CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0]), + UBYTE_TO_FLOAT(v[1]), + UBYTE_TO_FLOAT(v[2]), + UBYTE_TO_FLOAT(v[3]))); +} + +static void GLAPIENTRY +VertexAttrib4ubvNV(GLuint index, const GLubyte *v) +{ + CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, (GLfloat)v[0], + (GLfloat)v[1], (GLfloat)v[2], + (GLfloat)v[3])); +} + +/* GL_SHORT attributes */ + +static void GLAPIENTRY +VertexAttrib1NsvNV(GLuint index, const GLshort *v) +{ + CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0]))); +} + +static void GLAPIENTRY +VertexAttrib1svNV(GLuint index, const GLshort *v) +{ + CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, (GLfloat)v[0])); +} + +static void GLAPIENTRY +VertexAttrib2NsvNV(GLuint index, const GLshort *v) +{ + CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0]), + SHORT_TO_FLOAT(v[1]))); +} + +static void GLAPIENTRY +VertexAttrib2svNV(GLuint index, const GLshort *v) +{ + CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1])); +} + +static void GLAPIENTRY +VertexAttrib3NsvNV(GLuint index, const GLshort *v) +{ + CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0]), + SHORT_TO_FLOAT(v[1]), + SHORT_TO_FLOAT(v[2]))); +} + +static void GLAPIENTRY +VertexAttrib3svNV(GLuint index, const GLshort *v) +{ + CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], + (GLfloat)v[2])); +} + +static void GLAPIENTRY +VertexAttrib4NsvNV(GLuint index, const GLshort *v) +{ + CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0]), + SHORT_TO_FLOAT(v[1]), + SHORT_TO_FLOAT(v[2]), + SHORT_TO_FLOAT(v[3]))); +} + +static void GLAPIENTRY +VertexAttrib4svNV(GLuint index, const GLshort *v) +{ + CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], + (GLfloat)v[2], (GLfloat)v[3])); +} + +/* GL_UNSIGNED_SHORT attributes */ + +static void GLAPIENTRY +VertexAttrib1NusvNV(GLuint index, const GLushort *v) +{ + CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]))); +} + +static void GLAPIENTRY +VertexAttrib1usvNV(GLuint index, const GLushort *v) +{ + CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, (GLfloat)v[0])); +} + +static void GLAPIENTRY +VertexAttrib2NusvNV(GLuint index, const GLushort *v) +{ + CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]), + USHORT_TO_FLOAT(v[1]))); +} + +static void GLAPIENTRY +VertexAttrib2usvNV(GLuint index, const GLushort *v) +{ + CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, (GLfloat)v[0], + (GLfloat)v[1])); +} + +static void GLAPIENTRY +VertexAttrib3NusvNV(GLuint index, const GLushort *v) +{ + CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]), + USHORT_TO_FLOAT(v[1]), + USHORT_TO_FLOAT(v[2]))); +} + +static void GLAPIENTRY +VertexAttrib3usvNV(GLuint index, const GLushort *v) +{ + CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], + (GLfloat)v[2])); +} + +static void GLAPIENTRY +VertexAttrib4NusvNV(GLuint index, const GLushort *v) +{ + CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]), + USHORT_TO_FLOAT(v[1]), + USHORT_TO_FLOAT(v[2]), + USHORT_TO_FLOAT(v[3]))); +} + +static void GLAPIENTRY +VertexAttrib4usvNV(GLuint index, const GLushort *v) +{ + CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], + (GLfloat)v[2], (GLfloat)v[3])); +} + +/* GL_INT attributes */ + +static void GLAPIENTRY +VertexAttrib1NivNV(GLuint index, const GLint *v) +{ + CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]))); +} + +static void GLAPIENTRY +VertexAttrib1ivNV(GLuint index, const GLint *v) +{ + CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, (GLfloat)v[0])); +} + +static void GLAPIENTRY +VertexAttrib2NivNV(GLuint index, const GLint *v) +{ + CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]), + INT_TO_FLOAT(v[1]))); +} + +static void GLAPIENTRY +VertexAttrib2ivNV(GLuint index, const GLint *v) +{ + CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1])); +} + +static void GLAPIENTRY +VertexAttrib3NivNV(GLuint index, const GLint *v) +{ + CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]), + INT_TO_FLOAT(v[1]), + INT_TO_FLOAT(v[2]))); +} + +static void GLAPIENTRY +VertexAttrib3ivNV(GLuint index, const GLint *v) +{ + CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], + (GLfloat)v[2])); +} + +static void GLAPIENTRY +VertexAttrib4NivNV(GLuint index, const GLint *v) +{ + CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]), + INT_TO_FLOAT(v[1]), + INT_TO_FLOAT(v[2]), + INT_TO_FLOAT(v[3]))); +} + +static void GLAPIENTRY +VertexAttrib4ivNV(GLuint index, const GLint *v) +{ + CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], + (GLfloat)v[2], (GLfloat)v[3])); +} + +/* GL_UNSIGNED_INT attributes */ + +static void GLAPIENTRY +VertexAttrib1NuivNV(GLuint index, const GLuint *v) +{ + CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]))); +} + +static void GLAPIENTRY +VertexAttrib1uivNV(GLuint index, const GLuint *v) +{ + CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, (GLfloat)v[0])); +} + +static void GLAPIENTRY +VertexAttrib2NuivNV(GLuint index, const GLuint *v) +{ + CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]), + UINT_TO_FLOAT(v[1]))); +} + +static void GLAPIENTRY +VertexAttrib2uivNV(GLuint index, const GLuint *v) +{ + CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, (GLfloat)v[0], + (GLfloat)v[1])); +} + +static void GLAPIENTRY +VertexAttrib3NuivNV(GLuint index, const GLuint *v) +{ + CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]), + UINT_TO_FLOAT(v[1]), + UINT_TO_FLOAT(v[2]))); +} + +static void GLAPIENTRY +VertexAttrib3uivNV(GLuint index, const GLuint *v) +{ + CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], + (GLfloat)v[2])); +} + +static void GLAPIENTRY +VertexAttrib4NuivNV(GLuint index, const GLuint *v) +{ + CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]), + UINT_TO_FLOAT(v[1]), + UINT_TO_FLOAT(v[2]), + UINT_TO_FLOAT(v[3]))); +} + +static void GLAPIENTRY +VertexAttrib4uivNV(GLuint index, const GLuint *v) +{ + CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], + (GLfloat)v[2], (GLfloat)v[3])); +} + +/* GL_FLOAT attributes */ + +static void GLAPIENTRY +VertexAttrib1fvNV(GLuint index, const GLfloat *v) +{ + CALL_VertexAttrib1fvNV(GET_DISPATCH(), (index, v)); +} + +static void GLAPIENTRY +VertexAttrib2fvNV(GLuint index, const GLfloat *v) +{ + CALL_VertexAttrib2fvNV(GET_DISPATCH(), (index, v)); +} + +static void GLAPIENTRY +VertexAttrib3fvNV(GLuint index, const GLfloat *v) +{ + CALL_VertexAttrib3fvNV(GET_DISPATCH(), (index, v)); +} + +static void GLAPIENTRY +VertexAttrib4fvNV(GLuint index, const GLfloat *v) +{ + CALL_VertexAttrib4fvNV(GET_DISPATCH(), (index, v)); +} + +/* GL_DOUBLE attributes */ + +static void GLAPIENTRY +VertexAttrib1dvNV(GLuint index, const GLdouble *v) +{ + CALL_VertexAttrib1dvNV(GET_DISPATCH(), (index, v)); +} + +static void GLAPIENTRY +VertexAttrib2dvNV(GLuint index, const GLdouble *v) +{ + CALL_VertexAttrib2dvNV(GET_DISPATCH(), (index, v)); +} + +static void GLAPIENTRY +VertexAttrib3dvNV(GLuint index, const GLdouble *v) +{ + CALL_VertexAttrib3dvNV(GET_DISPATCH(), (index, v)); +} + +static void GLAPIENTRY +VertexAttrib4dvNV(GLuint index, const GLdouble *v) +{ + CALL_VertexAttrib4dvNV(GET_DISPATCH(), (index, v)); +} + + +/* + * Array [size][type] of VertexAttrib functions + */ +static attrib_func AttribFuncsNV[2][4][NUM_TYPES] = { + { + /* non-normalized */ + { + /* size 1 */ + (attrib_func) VertexAttrib1bvNV, + (attrib_func) VertexAttrib1ubvNV, + (attrib_func) VertexAttrib1svNV, + (attrib_func) VertexAttrib1usvNV, + (attrib_func) VertexAttrib1ivNV, + (attrib_func) VertexAttrib1uivNV, + (attrib_func) VertexAttrib1fvNV, + (attrib_func) VertexAttrib1dvNV + }, + { + /* size 2 */ + (attrib_func) VertexAttrib2bvNV, + (attrib_func) VertexAttrib2ubvNV, + (attrib_func) VertexAttrib2svNV, + (attrib_func) VertexAttrib2usvNV, + (attrib_func) VertexAttrib2ivNV, + (attrib_func) VertexAttrib2uivNV, + (attrib_func) VertexAttrib2fvNV, + (attrib_func) VertexAttrib2dvNV + }, + { + /* size 3 */ + (attrib_func) VertexAttrib3bvNV, + (attrib_func) VertexAttrib3ubvNV, + (attrib_func) VertexAttrib3svNV, + (attrib_func) VertexAttrib3usvNV, + (attrib_func) VertexAttrib3ivNV, + (attrib_func) VertexAttrib3uivNV, + (attrib_func) VertexAttrib3fvNV, + (attrib_func) VertexAttrib3dvNV + }, + { + /* size 4 */ + (attrib_func) VertexAttrib4bvNV, + (attrib_func) VertexAttrib4ubvNV, + (attrib_func) VertexAttrib4svNV, + (attrib_func) VertexAttrib4usvNV, + (attrib_func) VertexAttrib4ivNV, + (attrib_func) VertexAttrib4uivNV, + (attrib_func) VertexAttrib4fvNV, + (attrib_func) VertexAttrib4dvNV + } + }, + { + /* normalized (except for float/double) */ + { + /* size 1 */ + (attrib_func) VertexAttrib1NbvNV, + (attrib_func) VertexAttrib1NubvNV, + (attrib_func) VertexAttrib1NsvNV, + (attrib_func) VertexAttrib1NusvNV, + (attrib_func) VertexAttrib1NivNV, + (attrib_func) VertexAttrib1NuivNV, + (attrib_func) VertexAttrib1fvNV, + (attrib_func) VertexAttrib1dvNV + }, + { + /* size 2 */ + (attrib_func) VertexAttrib2NbvNV, + (attrib_func) VertexAttrib2NubvNV, + (attrib_func) VertexAttrib2NsvNV, + (attrib_func) VertexAttrib2NusvNV, + (attrib_func) VertexAttrib2NivNV, + (attrib_func) VertexAttrib2NuivNV, + (attrib_func) VertexAttrib2fvNV, + (attrib_func) VertexAttrib2dvNV + }, + { + /* size 3 */ + (attrib_func) VertexAttrib3NbvNV, + (attrib_func) VertexAttrib3NubvNV, + (attrib_func) VertexAttrib3NsvNV, + (attrib_func) VertexAttrib3NusvNV, + (attrib_func) VertexAttrib3NivNV, + (attrib_func) VertexAttrib3NuivNV, + (attrib_func) VertexAttrib3fvNV, + (attrib_func) VertexAttrib3dvNV + }, + { + /* size 4 */ + (attrib_func) VertexAttrib4NbvNV, + (attrib_func) VertexAttrib4NubvNV, + (attrib_func) VertexAttrib4NsvNV, + (attrib_func) VertexAttrib4NusvNV, + (attrib_func) VertexAttrib4NivNV, + (attrib_func) VertexAttrib4NuivNV, + (attrib_func) VertexAttrib4fvNV, + (attrib_func) VertexAttrib4dvNV + } + } +}; + + +/** + ** GL_ARB_vertex_program + **/ + +/* GL_BYTE attributes */ + +static void GLAPIENTRY +VertexAttrib1NbvARB(GLuint index, const GLbyte *v) +{ + CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]))); +} + +static void GLAPIENTRY +VertexAttrib1bvARB(GLuint index, const GLbyte *v) +{ + CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, (GLfloat)v[0])); +} + +static void GLAPIENTRY +VertexAttrib2NbvARB(GLuint index, const GLbyte *v) +{ + CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]), BYTE_TO_FLOAT(v[1]))); +} + +static void GLAPIENTRY +VertexAttrib2bvARB(GLuint index, const GLbyte *v) +{ + CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1])); +} + +static void GLAPIENTRY +VertexAttrib3NbvARB(GLuint index, const GLbyte *v) +{ + CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]), + BYTE_TO_FLOAT(v[1]), + BYTE_TO_FLOAT(v[2]))); +} + +static void GLAPIENTRY +VertexAttrib3bvARB(GLuint index, const GLbyte *v) +{ + CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2])); +} + +static void GLAPIENTRY +VertexAttrib4NbvARB(GLuint index, const GLbyte *v) +{ + CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]), + BYTE_TO_FLOAT(v[1]), + BYTE_TO_FLOAT(v[2]), + BYTE_TO_FLOAT(v[3]))); +} + +static void GLAPIENTRY +VertexAttrib4bvARB(GLuint index, const GLbyte *v) +{ + CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2], (GLfloat)v[3])); +} + +/* GL_UNSIGNED_BYTE attributes */ + +static void GLAPIENTRY +VertexAttrib1NubvARB(GLuint index, const GLubyte *v) +{ + CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0]))); +} + +static void GLAPIENTRY +VertexAttrib1ubvARB(GLuint index, const GLubyte *v) +{ + CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, (GLfloat)v[0])); +} + +static void GLAPIENTRY +VertexAttrib2NubvARB(GLuint index, const GLubyte *v) +{ + CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, + UBYTE_TO_FLOAT(v[0]), + UBYTE_TO_FLOAT(v[1]))); +} + +static void GLAPIENTRY +VertexAttrib2ubvARB(GLuint index, const GLubyte *v) +{ + CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, + (GLfloat)v[0], (GLfloat)v[1])); +} + +static void GLAPIENTRY +VertexAttrib3NubvARB(GLuint index, const GLubyte *v) +{ + CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, + UBYTE_TO_FLOAT(v[0]), + UBYTE_TO_FLOAT(v[1]), + UBYTE_TO_FLOAT(v[2]))); +} +static void GLAPIENTRY +VertexAttrib3ubvARB(GLuint index, const GLubyte *v) +{ + CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, + (GLfloat)v[0], + (GLfloat)v[1], + (GLfloat)v[2])); +} + +static void GLAPIENTRY +VertexAttrib4NubvARB(GLuint index, const GLubyte *v) +{ + CALL_VertexAttrib4fARB(GET_DISPATCH(), + (index, + UBYTE_TO_FLOAT(v[0]), + UBYTE_TO_FLOAT(v[1]), + UBYTE_TO_FLOAT(v[2]), + UBYTE_TO_FLOAT(v[3]))); +} + +static void GLAPIENTRY +VertexAttrib4ubvARB(GLuint index, const GLubyte *v) +{ + CALL_VertexAttrib4fARB(GET_DISPATCH(), + (index, + (GLfloat)v[0], (GLfloat)v[1], + (GLfloat)v[2], (GLfloat)v[3])); +} + +/* GL_SHORT attributes */ + +static void GLAPIENTRY +VertexAttrib1NsvARB(GLuint index, const GLshort *v) +{ + CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0]))); +} + +static void GLAPIENTRY +VertexAttrib1svARB(GLuint index, const GLshort *v) +{ + CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, (GLfloat)v[0])); +} + +static void GLAPIENTRY +VertexAttrib2NsvARB(GLuint index, const GLshort *v) +{ + CALL_VertexAttrib2fARB(GET_DISPATCH(), + (index, SHORT_TO_FLOAT(v[0]), + SHORT_TO_FLOAT(v[1]))); +} + +static void GLAPIENTRY +VertexAttrib2svARB(GLuint index, const GLshort *v) +{ + CALL_VertexAttrib2fARB(GET_DISPATCH(), + (index, (GLfloat)v[0], (GLfloat)v[1])); +} + +static void GLAPIENTRY +VertexAttrib3NsvARB(GLuint index, const GLshort *v) +{ + CALL_VertexAttrib3fARB(GET_DISPATCH(), + (index, + SHORT_TO_FLOAT(v[0]), + SHORT_TO_FLOAT(v[1]), + SHORT_TO_FLOAT(v[2]))); +} + +static void GLAPIENTRY +VertexAttrib3svARB(GLuint index, const GLshort *v) +{ + CALL_VertexAttrib3fARB(GET_DISPATCH(), + (index, + (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2])); +} + +static void GLAPIENTRY +VertexAttrib4NsvARB(GLuint index, const GLshort *v) +{ + CALL_VertexAttrib4fARB(GET_DISPATCH(), + (index, + SHORT_TO_FLOAT(v[0]), + SHORT_TO_FLOAT(v[1]), + SHORT_TO_FLOAT(v[2]), + SHORT_TO_FLOAT(v[3]))); +} + +static void GLAPIENTRY +VertexAttrib4svARB(GLuint index, const GLshort *v) +{ + CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], + (GLfloat)v[2], (GLfloat)v[3])); +} + +/* GL_UNSIGNED_SHORT attributes */ + +static void GLAPIENTRY +VertexAttrib1NusvARB(GLuint index, const GLushort *v) +{ + CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]))); +} + +static void GLAPIENTRY +VertexAttrib1usvARB(GLuint index, const GLushort *v) +{ + CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, (GLfloat)v[0])); +} + +static void GLAPIENTRY +VertexAttrib2NusvARB(GLuint index, const GLushort *v) +{ + CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]), + USHORT_TO_FLOAT(v[1]))); +} + +static void GLAPIENTRY +VertexAttrib2usvARB(GLuint index, const GLushort *v) +{ + CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, (GLfloat)v[0], + (GLfloat)v[1])); +} + +static void GLAPIENTRY +VertexAttrib3NusvARB(GLuint index, const GLushort *v) +{ + CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]), + USHORT_TO_FLOAT(v[1]), + USHORT_TO_FLOAT(v[2]))); +} + +static void GLAPIENTRY +VertexAttrib3usvARB(GLuint index, const GLushort *v) +{ + CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, (GLfloat)v[0], + (GLfloat)v[1], (GLfloat)v[2])); +} + +static void GLAPIENTRY +VertexAttrib4NusvARB(GLuint index, const GLushort *v) +{ + CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]), + USHORT_TO_FLOAT(v[1]), + USHORT_TO_FLOAT(v[2]), + USHORT_TO_FLOAT(v[3]))); +} + +static void GLAPIENTRY +VertexAttrib4usvARB(GLuint index, const GLushort *v) +{ + CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2], (GLfloat)v[3])); +} + +/* GL_INT attributes */ + +static void GLAPIENTRY +VertexAttrib1NivARB(GLuint index, const GLint *v) +{ + CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]))); +} + +static void GLAPIENTRY +VertexAttrib1ivARB(GLuint index, const GLint *v) +{ + CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, (GLfloat)v[0])); +} + +static void GLAPIENTRY +VertexAttrib2NivARB(GLuint index, const GLint *v) +{ + CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]), + INT_TO_FLOAT(v[1]))); +} + +static void GLAPIENTRY +VertexAttrib2ivARB(GLuint index, const GLint *v) +{ + CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, (GLfloat)v[0], + (GLfloat)v[1])); +} + +static void GLAPIENTRY +VertexAttrib3NivARB(GLuint index, const GLint *v) +{ + CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]), + INT_TO_FLOAT(v[1]), + INT_TO_FLOAT(v[2]))); +} + +static void GLAPIENTRY +VertexAttrib3ivARB(GLuint index, const GLint *v) +{ + CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, (GLfloat)v[0], + (GLfloat)v[1], (GLfloat)v[2])); +} + +static void GLAPIENTRY +VertexAttrib4NivARB(GLuint index, const GLint *v) +{ + CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]), + INT_TO_FLOAT(v[1]), + INT_TO_FLOAT(v[2]), + INT_TO_FLOAT(v[3]))); +} + +static void GLAPIENTRY +VertexAttrib4ivARB(GLuint index, const GLint *v) +{ + CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], + (GLfloat)v[2], (GLfloat)v[3])); +} + +/* GL_UNSIGNED_INT attributes */ + +static void GLAPIENTRY +VertexAttrib1NuivARB(GLuint index, const GLuint *v) +{ + CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]))); +} + +static void GLAPIENTRY +VertexAttrib1uivARB(GLuint index, const GLuint *v) +{ + CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, (GLfloat)v[0])); +} + +static void GLAPIENTRY +VertexAttrib2NuivARB(GLuint index, const GLuint *v) +{ + CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]), + UINT_TO_FLOAT(v[1]))); +} + +static void GLAPIENTRY +VertexAttrib2uivARB(GLuint index, const GLuint *v) +{ + CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, (GLfloat)v[0], + (GLfloat)v[1])); +} + +static void GLAPIENTRY +VertexAttrib3NuivARB(GLuint index, const GLuint *v) +{ + CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]), + UINT_TO_FLOAT(v[1]), + UINT_TO_FLOAT(v[2]))); +} + +static void GLAPIENTRY +VertexAttrib3uivARB(GLuint index, const GLuint *v) +{ + CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, (GLfloat)v[0], + (GLfloat)v[1], (GLfloat)v[2])); +} + +static void GLAPIENTRY +VertexAttrib4NuivARB(GLuint index, const GLuint *v) +{ + CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]), + UINT_TO_FLOAT(v[1]), + UINT_TO_FLOAT(v[2]), + UINT_TO_FLOAT(v[3]))); +} + +static void GLAPIENTRY +VertexAttrib4uivARB(GLuint index, const GLuint *v) +{ + CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], + (GLfloat)v[2], (GLfloat)v[3])); +} + +/* GL_FLOAT attributes */ + +static void GLAPIENTRY +VertexAttrib1fvARB(GLuint index, const GLfloat *v) +{ + CALL_VertexAttrib1fvARB(GET_DISPATCH(), (index, v)); +} + +static void GLAPIENTRY +VertexAttrib2fvARB(GLuint index, const GLfloat *v) +{ + CALL_VertexAttrib2fvARB(GET_DISPATCH(), (index, v)); +} + +static void GLAPIENTRY +VertexAttrib3fvARB(GLuint index, const GLfloat *v) +{ + CALL_VertexAttrib3fvARB(GET_DISPATCH(), (index, v)); +} + +static void GLAPIENTRY +VertexAttrib4fvARB(GLuint index, const GLfloat *v) +{ + CALL_VertexAttrib4fvARB(GET_DISPATCH(), (index, v)); +} + +/* GL_DOUBLE attributes */ + +static void GLAPIENTRY +VertexAttrib1dvARB(GLuint index, const GLdouble *v) +{ + CALL_VertexAttrib1dvARB(GET_DISPATCH(), (index, v)); +} + +static void GLAPIENTRY +VertexAttrib2dvARB(GLuint index, const GLdouble *v) +{ + CALL_VertexAttrib2dvARB(GET_DISPATCH(), (index, v)); +} + +static void GLAPIENTRY +VertexAttrib3dvARB(GLuint index, const GLdouble *v) +{ + CALL_VertexAttrib3dvARB(GET_DISPATCH(), (index, v)); +} + +static void GLAPIENTRY +VertexAttrib4dvARB(GLuint index, const GLdouble *v) +{ + CALL_VertexAttrib4dvARB(GET_DISPATCH(), (index, v)); +} + + +/** + * Integer-valued attributes + */ +static void GLAPIENTRY +VertexAttribI1bv(GLuint index, const GLbyte *v) +{ + CALL_VertexAttribI1iEXT(GET_DISPATCH(), (index, v[0])); +} + +static void GLAPIENTRY +VertexAttribI2bv(GLuint index, const GLbyte *v) +{ + CALL_VertexAttribI2iEXT(GET_DISPATCH(), (index, v[0], v[1])); +} + +static void GLAPIENTRY +VertexAttribI3bv(GLuint index, const GLbyte *v) +{ + CALL_VertexAttribI3iEXT(GET_DISPATCH(), (index, v[0], v[1], v[2])); +} + +static void GLAPIENTRY +VertexAttribI4bv(GLuint index, const GLbyte *v) +{ + CALL_VertexAttribI4bvEXT(GET_DISPATCH(), (index, v)); +} + + +static void GLAPIENTRY +VertexAttribI1ubv(GLuint index, const GLubyte *v) +{ + CALL_VertexAttribI1uiEXT(GET_DISPATCH(), (index, v[0])); +} + +static void GLAPIENTRY +VertexAttribI2ubv(GLuint index, const GLubyte *v) +{ + CALL_VertexAttribI2uiEXT(GET_DISPATCH(), (index, v[0], v[1])); +} + +static void GLAPIENTRY +VertexAttribI3ubv(GLuint index, const GLubyte *v) +{ + CALL_VertexAttribI3uiEXT(GET_DISPATCH(), (index, v[0], v[1], v[2])); +} + +static void GLAPIENTRY +VertexAttribI4ubv(GLuint index, const GLubyte *v) +{ + CALL_VertexAttribI4ubvEXT(GET_DISPATCH(), (index, v)); +} + + + +static void GLAPIENTRY +VertexAttribI1sv(GLuint index, const GLshort *v) +{ + CALL_VertexAttribI1iEXT(GET_DISPATCH(), (index, v[0])); +} + +static void GLAPIENTRY +VertexAttribI2sv(GLuint index, const GLshort *v) +{ + CALL_VertexAttribI2iEXT(GET_DISPATCH(), (index, v[0], v[1])); +} + +static void GLAPIENTRY +VertexAttribI3sv(GLuint index, const GLshort *v) +{ + CALL_VertexAttribI3iEXT(GET_DISPATCH(), (index, v[0], v[1], v[2])); +} + +static void GLAPIENTRY +VertexAttribI4sv(GLuint index, const GLshort *v) +{ + CALL_VertexAttribI4svEXT(GET_DISPATCH(), (index, v)); +} + + +static void GLAPIENTRY +VertexAttribI1usv(GLuint index, const GLushort *v) +{ + CALL_VertexAttribI1uiEXT(GET_DISPATCH(), (index, v[0])); +} + +static void GLAPIENTRY +VertexAttribI2usv(GLuint index, const GLushort *v) +{ + CALL_VertexAttribI2uiEXT(GET_DISPATCH(), (index, v[0], v[1])); +} + +static void GLAPIENTRY +VertexAttribI3usv(GLuint index, const GLushort *v) +{ + CALL_VertexAttribI3uiEXT(GET_DISPATCH(), (index, v[0], v[1], v[2])); +} + +static void GLAPIENTRY +VertexAttribI4usv(GLuint index, const GLushort *v) +{ + CALL_VertexAttribI4usvEXT(GET_DISPATCH(), (index, v)); +} + + + +static void GLAPIENTRY +VertexAttribI1iv(GLuint index, const GLint *v) +{ + CALL_VertexAttribI1iEXT(GET_DISPATCH(), (index, v[0])); +} + +static void GLAPIENTRY +VertexAttribI2iv(GLuint index, const GLint *v) +{ + CALL_VertexAttribI2iEXT(GET_DISPATCH(), (index, v[0], v[1])); +} + +static void GLAPIENTRY +VertexAttribI3iv(GLuint index, const GLint *v) +{ + CALL_VertexAttribI3iEXT(GET_DISPATCH(), (index, v[0], v[1], v[2])); +} + +static void GLAPIENTRY +VertexAttribI4iv(GLuint index, const GLint *v) +{ + CALL_VertexAttribI4ivEXT(GET_DISPATCH(), (index, v)); +} + + +static void GLAPIENTRY +VertexAttribI1uiv(GLuint index, const GLuint *v) +{ + CALL_VertexAttribI1uiEXT(GET_DISPATCH(), (index, v[0])); +} + +static void GLAPIENTRY +VertexAttribI2uiv(GLuint index, const GLuint *v) +{ + CALL_VertexAttribI2uiEXT(GET_DISPATCH(), (index, v[0], v[1])); +} + +static void GLAPIENTRY +VertexAttribI3uiv(GLuint index, const GLuint *v) +{ + CALL_VertexAttribI3uiEXT(GET_DISPATCH(), (index, v[0], v[1], v[2])); +} + +static void GLAPIENTRY +VertexAttribI4uiv(GLuint index, const GLuint *v) +{ + CALL_VertexAttribI4uivEXT(GET_DISPATCH(), (index, v)); +} + + + + +/* + * Array [unnormalized/normalized/integer][size][type] of VertexAttrib + * functions + */ +static attrib_func AttribFuncsARB[3][4][NUM_TYPES] = { + { + /* non-normalized */ + { + /* size 1 */ + (attrib_func) VertexAttrib1bvARB, + (attrib_func) VertexAttrib1ubvARB, + (attrib_func) VertexAttrib1svARB, + (attrib_func) VertexAttrib1usvARB, + (attrib_func) VertexAttrib1ivARB, + (attrib_func) VertexAttrib1uivARB, + (attrib_func) VertexAttrib1fvARB, + (attrib_func) VertexAttrib1dvARB + }, + { + /* size 2 */ + (attrib_func) VertexAttrib2bvARB, + (attrib_func) VertexAttrib2ubvARB, + (attrib_func) VertexAttrib2svARB, + (attrib_func) VertexAttrib2usvARB, + (attrib_func) VertexAttrib2ivARB, + (attrib_func) VertexAttrib2uivARB, + (attrib_func) VertexAttrib2fvARB, + (attrib_func) VertexAttrib2dvARB + }, + { + /* size 3 */ + (attrib_func) VertexAttrib3bvARB, + (attrib_func) VertexAttrib3ubvARB, + (attrib_func) VertexAttrib3svARB, + (attrib_func) VertexAttrib3usvARB, + (attrib_func) VertexAttrib3ivARB, + (attrib_func) VertexAttrib3uivARB, + (attrib_func) VertexAttrib3fvARB, + (attrib_func) VertexAttrib3dvARB + }, + { + /* size 4 */ + (attrib_func) VertexAttrib4bvARB, + (attrib_func) VertexAttrib4ubvARB, + (attrib_func) VertexAttrib4svARB, + (attrib_func) VertexAttrib4usvARB, + (attrib_func) VertexAttrib4ivARB, + (attrib_func) VertexAttrib4uivARB, + (attrib_func) VertexAttrib4fvARB, + (attrib_func) VertexAttrib4dvARB + } + }, + { + /* normalized (except for float/double) */ + { + /* size 1 */ + (attrib_func) VertexAttrib1NbvARB, + (attrib_func) VertexAttrib1NubvARB, + (attrib_func) VertexAttrib1NsvARB, + (attrib_func) VertexAttrib1NusvARB, + (attrib_func) VertexAttrib1NivARB, + (attrib_func) VertexAttrib1NuivARB, + (attrib_func) VertexAttrib1fvARB, + (attrib_func) VertexAttrib1dvARB + }, + { + /* size 2 */ + (attrib_func) VertexAttrib2NbvARB, + (attrib_func) VertexAttrib2NubvARB, + (attrib_func) VertexAttrib2NsvARB, + (attrib_func) VertexAttrib2NusvARB, + (attrib_func) VertexAttrib2NivARB, + (attrib_func) VertexAttrib2NuivARB, + (attrib_func) VertexAttrib2fvARB, + (attrib_func) VertexAttrib2dvARB + }, + { + /* size 3 */ + (attrib_func) VertexAttrib3NbvARB, + (attrib_func) VertexAttrib3NubvARB, + (attrib_func) VertexAttrib3NsvARB, + (attrib_func) VertexAttrib3NusvARB, + (attrib_func) VertexAttrib3NivARB, + (attrib_func) VertexAttrib3NuivARB, + (attrib_func) VertexAttrib3fvARB, + (attrib_func) VertexAttrib3dvARB + }, + { + /* size 4 */ + (attrib_func) VertexAttrib4NbvARB, + (attrib_func) VertexAttrib4NubvARB, + (attrib_func) VertexAttrib4NsvARB, + (attrib_func) VertexAttrib4NusvARB, + (attrib_func) VertexAttrib4NivARB, + (attrib_func) VertexAttrib4NuivARB, + (attrib_func) VertexAttrib4fvARB, + (attrib_func) VertexAttrib4dvARB + } + }, + + { + /* integer-valued */ + { + /* size 1 */ + (attrib_func) VertexAttribI1bv, + (attrib_func) VertexAttribI1ubv, + (attrib_func) VertexAttribI1sv, + (attrib_func) VertexAttribI1usv, + (attrib_func) VertexAttribI1iv, + (attrib_func) VertexAttribI1uiv, + NULL, /* GL_FLOAT */ + NULL /* GL_DOUBLE */ + }, + { + /* size 2 */ + (attrib_func) VertexAttribI2bv, + (attrib_func) VertexAttribI2ubv, + (attrib_func) VertexAttribI2sv, + (attrib_func) VertexAttribI2usv, + (attrib_func) VertexAttribI2iv, + (attrib_func) VertexAttribI2uiv, + NULL, /* GL_FLOAT */ + NULL /* GL_DOUBLE */ + }, + { + /* size 3 */ + (attrib_func) VertexAttribI3bv, + (attrib_func) VertexAttribI3ubv, + (attrib_func) VertexAttribI3sv, + (attrib_func) VertexAttribI3usv, + (attrib_func) VertexAttribI3iv, + (attrib_func) VertexAttribI3uiv, + NULL, /* GL_FLOAT */ + NULL /* GL_DOUBLE */ + }, + { + /* size 4 */ + (attrib_func) VertexAttribI4bv, + (attrib_func) VertexAttribI4ubv, + (attrib_func) VertexAttribI4sv, + (attrib_func) VertexAttribI4usv, + (attrib_func) VertexAttribI4iv, + (attrib_func) VertexAttribI4uiv, + NULL, /* GL_FLOAT */ + NULL /* GL_DOUBLE */ + } + } +}; + +/**********************************************************************/ + + +GLboolean _ae_create_context( struct gl_context *ctx ) +{ + if (ctx->aelt_context) + return GL_TRUE; + + /* These _gloffset_* values may not be compile-time constants */ + SecondaryColorFuncs[0] = _gloffset_SecondaryColor3bvEXT; + SecondaryColorFuncs[1] = _gloffset_SecondaryColor3ubvEXT; + SecondaryColorFuncs[2] = _gloffset_SecondaryColor3svEXT; + SecondaryColorFuncs[3] = _gloffset_SecondaryColor3usvEXT; + SecondaryColorFuncs[4] = _gloffset_SecondaryColor3ivEXT; + SecondaryColorFuncs[5] = _gloffset_SecondaryColor3uivEXT; + SecondaryColorFuncs[6] = _gloffset_SecondaryColor3fvEXT; + SecondaryColorFuncs[7] = _gloffset_SecondaryColor3dvEXT; + + FogCoordFuncs[0] = -1; + FogCoordFuncs[1] = -1; + FogCoordFuncs[2] = -1; + FogCoordFuncs[3] = -1; + FogCoordFuncs[4] = -1; + FogCoordFuncs[5] = -1; + FogCoordFuncs[6] = _gloffset_FogCoordfvEXT; + FogCoordFuncs[7] = _gloffset_FogCoorddvEXT; + + ctx->aelt_context = CALLOC( sizeof(AEcontext) ); + if (!ctx->aelt_context) + return GL_FALSE; + + AE_CONTEXT(ctx)->NewState = ~0; + return GL_TRUE; +} + + +void _ae_destroy_context( struct gl_context *ctx ) +{ + if ( AE_CONTEXT( ctx ) ) { + FREE( ctx->aelt_context ); + ctx->aelt_context = NULL; + } +} + +static void check_vbo( AEcontext *actx, + struct gl_buffer_object *vbo ) +{ + if (_mesa_is_bufferobj(vbo) && !_mesa_bufferobj_mapped(vbo)) { + GLuint i; + for (i = 0; i < actx->nr_vbos; i++) + if (actx->vbo[i] == vbo) + return; + assert(actx->nr_vbos < VERT_ATTRIB_MAX); + actx->vbo[actx->nr_vbos++] = vbo; + } +} + + +/** + * Make a list of per-vertex functions to call for each glArrayElement call. + * These functions access the array data (i.e. glVertex, glColor, glNormal, + * etc). + * Note: this may be called during display list construction. + */ +static void _ae_update_state( struct gl_context *ctx ) +{ + AEcontext *actx = AE_CONTEXT(ctx); + AEarray *aa = actx->arrays; + AEattrib *at = actx->attribs; + GLuint i; + struct gl_array_object *arrayObj = ctx->Array.ArrayObj; + + actx->nr_vbos = 0; + + /* conventional vertex arrays */ + if (arrayObj->Index.Enabled) { + aa->array = &arrayObj->Index; + aa->offset = IndexFuncs[TYPE_IDX(aa->array->Type)]; + check_vbo(actx, aa->array->BufferObj); + aa++; + } + if (arrayObj->EdgeFlag.Enabled) { + aa->array = &arrayObj->EdgeFlag; + aa->offset = _gloffset_EdgeFlagv; + check_vbo(actx, aa->array->BufferObj); + aa++; + } + if (arrayObj->Normal.Enabled) { + aa->array = &arrayObj->Normal; + aa->offset = NormalFuncs[TYPE_IDX(aa->array->Type)]; + check_vbo(actx, aa->array->BufferObj); + aa++; + } + if (arrayObj->Color.Enabled) { + aa->array = &arrayObj->Color; + aa->offset = ColorFuncs[aa->array->Size-3][TYPE_IDX(aa->array->Type)]; + check_vbo(actx, aa->array->BufferObj); + aa++; + } + if (arrayObj->SecondaryColor.Enabled) { + aa->array = &arrayObj->SecondaryColor; + aa->offset = SecondaryColorFuncs[TYPE_IDX(aa->array->Type)]; + check_vbo(actx, aa->array->BufferObj); + aa++; + } + if (arrayObj->FogCoord.Enabled) { + aa->array = &arrayObj->FogCoord; + aa->offset = FogCoordFuncs[TYPE_IDX(aa->array->Type)]; + check_vbo(actx, aa->array->BufferObj); + aa++; + } + for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) { + struct gl_client_array *attribArray = &arrayObj->TexCoord[i]; + if (attribArray->Enabled) { + /* NOTE: we use generic glVertexAttribNV functions here. + * If we ever remove GL_NV_vertex_program this will have to change. + */ + at->array = attribArray; + ASSERT(!at->array->Normalized); + at->func = AttribFuncsNV[at->array->Normalized] + [at->array->Size-1] + [TYPE_IDX(at->array->Type)]; + at->index = VERT_ATTRIB_TEX0 + i; + check_vbo(actx, at->array->BufferObj); + at++; + } + } + + /* generic vertex attribute arrays */ + for (i = 1; i < Elements(arrayObj->VertexAttrib); i++) { /* skip zero! */ + struct gl_client_array *attribArray = &arrayObj->VertexAttrib[i]; + if (attribArray->Enabled) { + at->array = attribArray; + /* Note: we can't grab the _glapi_Dispatch->VertexAttrib1fvNV + * function pointer here (for float arrays) since the pointer may + * change from one execution of _ae_ArrayElement() to + * the next. Doing so caused UT to break. + */ + if (ctx->VertexProgram._Enabled + && ctx->VertexProgram.Current->IsNVProgram) { + at->func = AttribFuncsNV[at->array->Normalized] + [at->array->Size-1] + [TYPE_IDX(at->array->Type)]; + } + else { + GLint intOrNorm; + if (at->array->Integer) + intOrNorm = 2; + else if (at->array->Normalized) + intOrNorm = 1; + else + intOrNorm = 0; + + at->func = AttribFuncsARB[intOrNorm] + [at->array->Size-1] + [TYPE_IDX(at->array->Type)]; + } + at->index = i; + check_vbo(actx, at->array->BufferObj); + at++; + } + } + + /* finally, vertex position */ + if (arrayObj->VertexAttrib[0].Enabled) { + /* Use glVertex(v) instead of glVertexAttrib(0, v) to be sure it's + * issued as the last (provoking) attribute). + */ + aa->array = &arrayObj->VertexAttrib[0]; + assert(aa->array->Size >= 2); /* XXX fix someday? */ + aa->offset = VertexFuncs[aa->array->Size-2][TYPE_IDX(aa->array->Type)]; + check_vbo(actx, aa->array->BufferObj); + aa++; + } + else if (arrayObj->Vertex.Enabled) { + aa->array = &arrayObj->Vertex; + aa->offset = VertexFuncs[aa->array->Size-2][TYPE_IDX(aa->array->Type)]; + check_vbo(actx, aa->array->BufferObj); + aa++; + } + + check_vbo(actx, ctx->Array.ElementArrayBufferObj); + + ASSERT(at - actx->attribs <= VERT_ATTRIB_MAX); + ASSERT(aa - actx->arrays < 32); + at->func = NULL; /* terminate the list */ + aa->offset = -1; /* terminate the list */ + + actx->NewState = 0; +} + +void _ae_map_vbos( struct gl_context *ctx ) +{ + AEcontext *actx = AE_CONTEXT(ctx); + GLuint i; + + if (actx->mapped_vbos) + return; + + if (actx->NewState) + _ae_update_state(ctx); + + for (i = 0; i < actx->nr_vbos; i++) + ctx->Driver.MapBufferRange(ctx, 0, + actx->vbo[i]->Size, + GL_MAP_READ_BIT, + actx->vbo[i]); + + if (actx->nr_vbos) + actx->mapped_vbos = GL_TRUE; +} + +void _ae_unmap_vbos( struct gl_context *ctx ) +{ + AEcontext *actx = AE_CONTEXT(ctx); + GLuint i; + + if (!actx->mapped_vbos) + return; + + assert (!actx->NewState); + + for (i = 0; i < actx->nr_vbos; i++) + ctx->Driver.UnmapBuffer(ctx, actx->vbo[i]); + + actx->mapped_vbos = GL_FALSE; +} + + +/** + * Called via glArrayElement() and glDrawArrays(). + * Issue the glNormal, glVertex, glColor, glVertexAttrib, etc functions + * for all enabled vertex arrays (for elt-th element). + * Note: this may be called during display list construction. + */ +void GLAPIENTRY _ae_ArrayElement( GLint elt ) +{ + GET_CURRENT_CONTEXT(ctx); + const AEcontext *actx = AE_CONTEXT(ctx); + const AEarray *aa; + const AEattrib *at; + const struct _glapi_table * const disp = GET_DISPATCH(); + GLboolean do_map; + + if (actx->NewState) { + assert(!actx->mapped_vbos); + _ae_update_state( ctx ); + } + + /* Determine if w need to map/unmap VBOs */ + do_map = actx->nr_vbos && !actx->mapped_vbos; + + if (do_map) + _ae_map_vbos(ctx); + + /* emit generic attribute elements */ + for (at = actx->attribs; at->func; at++) { + const GLubyte *src + = ADD_POINTERS(at->array->BufferObj->Pointer, at->array->Ptr) + + elt * at->array->StrideB; + at->func( at->index, src ); + } + + /* emit conventional arrays elements */ + for (aa = actx->arrays; aa->offset != -1 ; aa++) { + const GLubyte *src + = ADD_POINTERS(aa->array->BufferObj->Pointer, aa->array->Ptr) + + elt * aa->array->StrideB; + CALL_by_offset( disp, (array_func), aa->offset, + ((const void *) src) ); + } + + if (do_map) + _ae_unmap_vbos(ctx); +} + + +void _ae_invalidate_state( struct gl_context *ctx, GLuint new_state ) +{ + AEcontext *actx = AE_CONTEXT(ctx); + + + /* Only interested in this subset of mesa state. Need to prune + * this down as both tnl/ and the drivers can raise statechanges + * for arcane reasons in the middle of seemingly atomic operations + * like DrawElements, over which we'd like to keep a known set of + * arrays and vbo's mapped. + * + * Luckily, neither the drivers nor tnl muck with the state that + * concerns us here: + */ + new_state &= _NEW_ARRAY | _NEW_PROGRAM; + if (new_state) { + assert(!actx->mapped_vbos); + actx->NewState |= new_state; + } +} + + +void _mesa_install_arrayelt_vtxfmt(struct _glapi_table *disp, + const GLvertexformat *vfmt) +{ + SET_ArrayElement(disp, vfmt->ArrayElement); +} + + +#endif /* FEATURE_arrayelt */ diff --git a/mesalib/src/mesa/main/api_exec.c b/mesalib/src/mesa/main/api_exec.c index ef4278992..93214dd0b 100644 --- a/mesalib/src/mesa/main/api_exec.c +++ b/mesalib/src/mesa/main/api_exec.c @@ -1,751 +1,751 @@ -/* - * 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 api_exec.c - * Initialize dispatch table with the immidiate mode functions. - */ - - -#include "mfeatures.h" -#include "accum.h" -#include "api_loopback.h" -#include "api_exec.h" -#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program -#include "arbprogram.h" -#endif -#include "atifragshader.h" -#include "attrib.h" -#include "blend.h" -#if FEATURE_ARB_vertex_buffer_object -#include "bufferobj.h" -#endif -#include "arrayobj.h" -#if FEATURE_draw_read_buffer -#include "buffers.h" -#endif -#include "clear.h" -#include "clip.h" -#include "colortab.h" -#include "condrender.h" -#include "context.h" -#include "convolve.h" -#include "depth.h" -#include "dlist.h" -#include "drawpix.h" -#include "rastpos.h" -#include "enable.h" -#include "eval.h" -#include "get.h" -#include "feedback.h" -#include "fog.h" -#if FEATURE_EXT_framebuffer_object -#include "fbobject.h" -#endif -#include "framebuffer.h" -#include "hint.h" -#include "histogram.h" -#include "imports.h" -#include "light.h" -#include "lines.h" -#include "matrix.h" -#include "multisample.h" -#include "pixel.h" -#include "pixelstore.h" -#include "points.h" -#include "polygon.h" -#include "queryobj.h" -#include "readpix.h" -#if FEATURE_ARB_sampler_objects -#include "samplerobj.h" -#endif -#include "scissor.h" -#include "stencil.h" -#include "texenv.h" -#include "texgetimage.h" -#include "teximage.h" -#include "texgen.h" -#include "texobj.h" -#include "texparam.h" -#include "texstate.h" -#include "texturebarrier.h" -#include "transformfeedback.h" -#include "mtypes.h" -#include "varray.h" -#include "viewport.h" -#if FEATURE_NV_vertex_program || FEATURE_NV_fragment_program -#include "nvprogram.h" -#endif -#if FEATURE_ARB_shader_objects -#include "shaderapi.h" -#include "uniforms.h" -#endif -#include "syncobj.h" -#include "main/dispatch.h" - - -#if FEATURE_GL - - -/** - * Initialize a dispatch table with pointers to Mesa's immediate-mode - * commands. - * - * Pointers to glBegin()/glEnd() object commands and a few others - * are provided via the GLvertexformat interface. - * - * \param ctx GL context to which \c exec belongs. - * \param exec dispatch table. - */ -struct _glapi_table * -_mesa_create_exec_table(void) -{ - struct _glapi_table *exec; - - exec = _mesa_alloc_dispatch_table(_gloffset_COUNT); - if (exec == NULL) - return NULL; - -#if _HAVE_FULL_GL - _mesa_loopback_init_api_table( exec ); -#endif - - /* load the dispatch slots we understand */ - SET_AlphaFunc(exec, _mesa_AlphaFunc); - SET_BlendFunc(exec, _mesa_BlendFunc); - SET_Clear(exec, _mesa_Clear); - SET_ClearColor(exec, _mesa_ClearColor); - SET_ClearStencil(exec, _mesa_ClearStencil); - SET_ColorMask(exec, _mesa_ColorMask); - SET_CullFace(exec, _mesa_CullFace); - SET_Disable(exec, _mesa_Disable); -#if FEATURE_draw_read_buffer - SET_DrawBuffer(exec, _mesa_DrawBuffer); - SET_ReadBuffer(exec, _mesa_ReadBuffer); -#endif - SET_Enable(exec, _mesa_Enable); - SET_Finish(exec, _mesa_Finish); - SET_Flush(exec, _mesa_Flush); - SET_FrontFace(exec, _mesa_FrontFace); - SET_Frustum(exec, _mesa_Frustum); - SET_GetError(exec, _mesa_GetError); - SET_GetFloatv(exec, _mesa_GetFloatv); - SET_GetString(exec, _mesa_GetString); - SET_LineStipple(exec, _mesa_LineStipple); - SET_LineWidth(exec, _mesa_LineWidth); - SET_LoadIdentity(exec, _mesa_LoadIdentity); - SET_LoadMatrixf(exec, _mesa_LoadMatrixf); - SET_LogicOp(exec, _mesa_LogicOp); - SET_MatrixMode(exec, _mesa_MatrixMode); - SET_MultMatrixf(exec, _mesa_MultMatrixf); - SET_Ortho(exec, _mesa_Ortho); - SET_PixelStorei(exec, _mesa_PixelStorei); - SET_PopMatrix(exec, _mesa_PopMatrix); - SET_PushMatrix(exec, _mesa_PushMatrix); - SET_Rotatef(exec, _mesa_Rotatef); - SET_Scalef(exec, _mesa_Scalef); - SET_Scissor(exec, _mesa_Scissor); - SET_ShadeModel(exec, _mesa_ShadeModel); - SET_StencilFunc(exec, _mesa_StencilFunc); - SET_StencilMask(exec, _mesa_StencilMask); - SET_StencilOp(exec, _mesa_StencilOp); - SET_TexEnvfv(exec, _mesa_TexEnvfv); - SET_TexEnvi(exec, _mesa_TexEnvi); - SET_TexImage2D(exec, _mesa_TexImage2D); - SET_TexParameteri(exec, _mesa_TexParameteri); - SET_Translatef(exec, _mesa_Translatef); - SET_Viewport(exec, _mesa_Viewport); - - _mesa_init_accum_dispatch(exec); - _mesa_init_dlist_dispatch(exec); - - SET_ClearDepth(exec, _mesa_ClearDepth); - SET_ClearIndex(exec, _mesa_ClearIndex); - SET_ClipPlane(exec, _mesa_ClipPlane); - SET_ColorMaterial(exec, _mesa_ColorMaterial); - SET_DepthFunc(exec, _mesa_DepthFunc); - SET_DepthMask(exec, _mesa_DepthMask); - SET_DepthRange(exec, _mesa_DepthRange); - - _mesa_init_drawpix_dispatch(exec); - _mesa_init_feedback_dispatch(exec); - - SET_FogCoordPointerEXT(exec, _mesa_FogCoordPointerEXT); - SET_Fogf(exec, _mesa_Fogf); - SET_Fogfv(exec, _mesa_Fogfv); - SET_Fogi(exec, _mesa_Fogi); - SET_Fogiv(exec, _mesa_Fogiv); - SET_GetClipPlane(exec, _mesa_GetClipPlane); - SET_GetBooleanv(exec, _mesa_GetBooleanv); - SET_GetDoublev(exec, _mesa_GetDoublev); - SET_GetIntegerv(exec, _mesa_GetIntegerv); - SET_GetLightfv(exec, _mesa_GetLightfv); - SET_GetLightiv(exec, _mesa_GetLightiv); - SET_GetMaterialfv(exec, _mesa_GetMaterialfv); - SET_GetMaterialiv(exec, _mesa_GetMaterialiv); - SET_GetPolygonStipple(exec, _mesa_GetPolygonStipple); - SET_GetTexEnvfv(exec, _mesa_GetTexEnvfv); - SET_GetTexEnviv(exec, _mesa_GetTexEnviv); - SET_GetTexLevelParameterfv(exec, _mesa_GetTexLevelParameterfv); - SET_GetTexLevelParameteriv(exec, _mesa_GetTexLevelParameteriv); - SET_GetTexParameterfv(exec, _mesa_GetTexParameterfv); - SET_GetTexParameteriv(exec, _mesa_GetTexParameteriv); - SET_GetTexImage(exec, _mesa_GetTexImage); - SET_Hint(exec, _mesa_Hint); - SET_IndexMask(exec, _mesa_IndexMask); - SET_IsEnabled(exec, _mesa_IsEnabled); - SET_LightModelf(exec, _mesa_LightModelf); - SET_LightModelfv(exec, _mesa_LightModelfv); - SET_LightModeli(exec, _mesa_LightModeli); - SET_LightModeliv(exec, _mesa_LightModeliv); - SET_Lightf(exec, _mesa_Lightf); - SET_Lightfv(exec, _mesa_Lightfv); - SET_Lighti(exec, _mesa_Lighti); - SET_Lightiv(exec, _mesa_Lightiv); - SET_LoadMatrixd(exec, _mesa_LoadMatrixd); - - _mesa_init_eval_dispatch(exec); - - SET_MultMatrixd(exec, _mesa_MultMatrixd); - - _mesa_init_pixel_dispatch(exec); - - SET_PixelStoref(exec, _mesa_PixelStoref); - SET_PointSize(exec, _mesa_PointSize); - SET_PolygonMode(exec, _mesa_PolygonMode); - SET_PolygonOffset(exec, _mesa_PolygonOffset); - SET_PolygonStipple(exec, _mesa_PolygonStipple); - - _mesa_init_attrib_dispatch(exec); - _mesa_init_rastpos_dispatch(exec); - - SET_ReadPixels(exec, _mesa_ReadPixels); - SET_Rotated(exec, _mesa_Rotated); - SET_Scaled(exec, _mesa_Scaled); - SET_SecondaryColorPointerEXT(exec, _mesa_SecondaryColorPointerEXT); - SET_TexEnvf(exec, _mesa_TexEnvf); - SET_TexEnviv(exec, _mesa_TexEnviv); - - _mesa_init_texgen_dispatch(exec); - - SET_TexImage1D(exec, _mesa_TexImage1D); - SET_TexParameterf(exec, _mesa_TexParameterf); - SET_TexParameterfv(exec, _mesa_TexParameterfv); - SET_TexParameteriv(exec, _mesa_TexParameteriv); - SET_Translated(exec, _mesa_Translated); - - /* 1.1 */ - SET_BindTexture(exec, _mesa_BindTexture); - SET_DeleteTextures(exec, _mesa_DeleteTextures); - SET_GenTextures(exec, _mesa_GenTextures); -#if _HAVE_FULL_GL - SET_AreTexturesResident(exec, _mesa_AreTexturesResident); - SET_ColorPointer(exec, _mesa_ColorPointer); - SET_CopyTexImage1D(exec, _mesa_CopyTexImage1D); - SET_CopyTexImage2D(exec, _mesa_CopyTexImage2D); - SET_CopyTexSubImage1D(exec, _mesa_CopyTexSubImage1D); - SET_CopyTexSubImage2D(exec, _mesa_CopyTexSubImage2D); - SET_DisableClientState(exec, _mesa_DisableClientState); - SET_EdgeFlagPointer(exec, _mesa_EdgeFlagPointer); - SET_EnableClientState(exec, _mesa_EnableClientState); - SET_GetPointerv(exec, _mesa_GetPointerv); - SET_IndexPointer(exec, _mesa_IndexPointer); - SET_InterleavedArrays(exec, _mesa_InterleavedArrays); - SET_IsTexture(exec, _mesa_IsTexture); - SET_NormalPointer(exec, _mesa_NormalPointer); - SET_PrioritizeTextures(exec, _mesa_PrioritizeTextures); - SET_TexCoordPointer(exec, _mesa_TexCoordPointer); - SET_TexSubImage1D(exec, _mesa_TexSubImage1D); - SET_TexSubImage2D(exec, _mesa_TexSubImage2D); - SET_VertexPointer(exec, _mesa_VertexPointer); -#endif - - /* 1.2 */ -#if _HAVE_FULL_GL - SET_CopyTexSubImage3D(exec, _mesa_CopyTexSubImage3D); - SET_TexImage3D(exec, _mesa_TexImage3D); - SET_TexSubImage3D(exec, _mesa_TexSubImage3D); -#endif - - /* OpenGL 1.2 GL_ARB_imaging */ - SET_BlendColor(exec, _mesa_BlendColor); - SET_BlendEquation(exec, _mesa_BlendEquation); - SET_BlendEquationSeparateEXT(exec, _mesa_BlendEquationSeparateEXT); - - _mesa_init_colortable_dispatch(exec); - _mesa_init_convolve_dispatch(exec); - _mesa_init_histogram_dispatch(exec); - - /* OpenGL 2.0 */ - SET_StencilFuncSeparate(exec, _mesa_StencilFuncSeparate); - SET_StencilMaskSeparate(exec, _mesa_StencilMaskSeparate); - SET_StencilOpSeparate(exec, _mesa_StencilOpSeparate); - -#if FEATURE_ARB_shader_objects - _mesa_init_shader_dispatch(exec); - _mesa_init_shader_uniform_dispatch(exec); -#endif - - /* 2. GL_EXT_blend_color */ -#if 0 -/* SET_BlendColorEXT(exec, _mesa_BlendColorEXT); */ -#endif - - /* 3. GL_EXT_polygon_offset */ -#if _HAVE_FULL_GL - SET_PolygonOffsetEXT(exec, _mesa_PolygonOffsetEXT); -#endif - - /* 6. GL_EXT_texture3d */ -#if 0 -/* SET_CopyTexSubImage3DEXT(exec, _mesa_CopyTexSubImage3D); */ -/* SET_TexImage3DEXT(exec, _mesa_TexImage3DEXT); */ -/* SET_TexSubImage3DEXT(exec, _mesa_TexSubImage3D); */ -#endif - - /* 11. GL_EXT_histogram */ -#if 0 - SET_GetHistogramEXT(exec, _mesa_GetHistogram); - SET_GetHistogramParameterfvEXT(exec, _mesa_GetHistogramParameterfv); - SET_GetHistogramParameterivEXT(exec, _mesa_GetHistogramParameteriv); - SET_GetMinmaxEXT(exec, _mesa_GetMinmax); - SET_GetMinmaxParameterfvEXT(exec, _mesa_GetMinmaxParameterfv); - SET_GetMinmaxParameterivEXT(exec, _mesa_GetMinmaxParameteriv); -#endif - - /* 14. SGI_color_table */ -#if 0 - SET_ColorTableSGI(exec, _mesa_ColorTable); - SET_ColorSubTableSGI(exec, _mesa_ColorSubTable); - SET_GetColorTableSGI(exec, _mesa_GetColorTable); - SET_GetColorTableParameterfvSGI(exec, _mesa_GetColorTableParameterfv); - SET_GetColorTableParameterivSGI(exec, _mesa_GetColorTableParameteriv); -#endif - - /* 30. GL_EXT_vertex_array */ -#if _HAVE_FULL_GL - SET_ColorPointerEXT(exec, _mesa_ColorPointerEXT); - SET_EdgeFlagPointerEXT(exec, _mesa_EdgeFlagPointerEXT); - SET_IndexPointerEXT(exec, _mesa_IndexPointerEXT); - SET_NormalPointerEXT(exec, _mesa_NormalPointerEXT); - SET_TexCoordPointerEXT(exec, _mesa_TexCoordPointerEXT); - SET_VertexPointerEXT(exec, _mesa_VertexPointerEXT); -#endif - - /* 37. GL_EXT_blend_minmax */ -#if 0 - SET_BlendEquationEXT(exec, _mesa_BlendEquationEXT); -#endif - - /* 54. GL_EXT_point_parameters */ -#if _HAVE_FULL_GL - SET_PointParameterfEXT(exec, _mesa_PointParameterf); - SET_PointParameterfvEXT(exec, _mesa_PointParameterfv); -#endif - - /* 95. GL_ARB_ES2_compatibility */ - SET_ClearDepthf(exec, _mesa_ClearDepthf); - SET_DepthRangef(exec, _mesa_DepthRangef); - - /* 97. GL_EXT_compiled_vertex_array */ -#if _HAVE_FULL_GL - SET_LockArraysEXT(exec, _mesa_LockArraysEXT); - SET_UnlockArraysEXT(exec, _mesa_UnlockArraysEXT); -#endif - - /* 148. GL_EXT_multi_draw_arrays */ -#if _HAVE_FULL_GL - SET_MultiDrawArraysEXT(exec, _mesa_MultiDrawArraysEXT); -#endif - - /* 173. GL_INGR_blend_func_separate */ -#if _HAVE_FULL_GL - SET_BlendFuncSeparateEXT(exec, _mesa_BlendFuncSeparateEXT); -#endif - - /* 196. GL_MESA_resize_buffers */ -#if _HAVE_FULL_GL - SET_ResizeBuffersMESA(exec, _mesa_ResizeBuffersMESA); -#endif - - /* 197. GL_MESA_window_pos */ - /* part of _mesa_init_rastpos_dispatch(exec); */ - - /* 200. GL_IBM_multimode_draw_arrays */ -#if _HAVE_FULL_GL - SET_MultiModeDrawArraysIBM(exec, _mesa_MultiModeDrawArraysIBM); - SET_MultiModeDrawElementsIBM(exec, _mesa_MultiModeDrawElementsIBM); -#endif - - /* 233. GL_NV_vertex_program */ -#if FEATURE_NV_vertex_program - SET_BindProgramNV(exec, _mesa_BindProgram); - SET_DeleteProgramsNV(exec, _mesa_DeletePrograms); - SET_ExecuteProgramNV(exec, _mesa_ExecuteProgramNV); - SET_GenProgramsNV(exec, _mesa_GenPrograms); - SET_AreProgramsResidentNV(exec, _mesa_AreProgramsResidentNV); - SET_RequestResidentProgramsNV(exec, _mesa_RequestResidentProgramsNV); - SET_GetProgramParameterfvNV(exec, _mesa_GetProgramParameterfvNV); - SET_GetProgramParameterdvNV(exec, _mesa_GetProgramParameterdvNV); - SET_GetProgramivNV(exec, _mesa_GetProgramivNV); - SET_GetProgramStringNV(exec, _mesa_GetProgramStringNV); - SET_GetTrackMatrixivNV(exec, _mesa_GetTrackMatrixivNV); - SET_GetVertexAttribdvNV(exec, _mesa_GetVertexAttribdvNV); - SET_GetVertexAttribfvNV(exec, _mesa_GetVertexAttribfvNV); - SET_GetVertexAttribivNV(exec, _mesa_GetVertexAttribivNV); - SET_GetVertexAttribPointervNV(exec, _mesa_GetVertexAttribPointervNV); - SET_IsProgramNV(exec, _mesa_IsProgramARB); - SET_LoadProgramNV(exec, _mesa_LoadProgramNV); - SET_ProgramEnvParameter4dARB(exec, _mesa_ProgramEnvParameter4dARB); /* alias to ProgramParameter4dNV */ - SET_ProgramEnvParameter4dvARB(exec, _mesa_ProgramEnvParameter4dvARB); /* alias to ProgramParameter4dvNV */ - SET_ProgramEnvParameter4fARB(exec, _mesa_ProgramEnvParameter4fARB); /* alias to ProgramParameter4fNV */ - SET_ProgramEnvParameter4fvARB(exec, _mesa_ProgramEnvParameter4fvARB); /* alias to ProgramParameter4fvNV */ - SET_ProgramParameters4dvNV(exec, _mesa_ProgramParameters4dvNV); - SET_ProgramParameters4fvNV(exec, _mesa_ProgramParameters4fvNV); - SET_TrackMatrixNV(exec, _mesa_TrackMatrixNV); - SET_VertexAttribPointerNV(exec, _mesa_VertexAttribPointerNV); - /* glVertexAttrib*NV functions handled in api_loopback.c */ -#endif - - /* 273. GL_APPLE_vertex_array_object */ - SET_BindVertexArrayAPPLE(exec, _mesa_BindVertexArrayAPPLE); - SET_DeleteVertexArraysAPPLE(exec, _mesa_DeleteVertexArraysAPPLE); - SET_GenVertexArraysAPPLE(exec, _mesa_GenVertexArraysAPPLE); - SET_IsVertexArrayAPPLE(exec, _mesa_IsVertexArrayAPPLE); - - /* 282. GL_NV_fragment_program */ -#if FEATURE_NV_fragment_program - SET_ProgramNamedParameter4fNV(exec, _mesa_ProgramNamedParameter4fNV); - SET_ProgramNamedParameter4dNV(exec, _mesa_ProgramNamedParameter4dNV); - SET_ProgramNamedParameter4fvNV(exec, _mesa_ProgramNamedParameter4fvNV); - SET_ProgramNamedParameter4dvNV(exec, _mesa_ProgramNamedParameter4dvNV); - SET_GetProgramNamedParameterfvNV(exec, _mesa_GetProgramNamedParameterfvNV); - SET_GetProgramNamedParameterdvNV(exec, _mesa_GetProgramNamedParameterdvNV); - SET_ProgramLocalParameter4dARB(exec, _mesa_ProgramLocalParameter4dARB); - SET_ProgramLocalParameter4dvARB(exec, _mesa_ProgramLocalParameter4dvARB); - SET_ProgramLocalParameter4fARB(exec, _mesa_ProgramLocalParameter4fARB); - SET_ProgramLocalParameter4fvARB(exec, _mesa_ProgramLocalParameter4fvARB); - SET_GetProgramLocalParameterdvARB(exec, _mesa_GetProgramLocalParameterdvARB); - SET_GetProgramLocalParameterfvARB(exec, _mesa_GetProgramLocalParameterfvARB); -#endif - - /* 262. GL_NV_point_sprite */ -#if _HAVE_FULL_GL - SET_PointParameteriNV(exec, _mesa_PointParameteri); - SET_PointParameterivNV(exec, _mesa_PointParameteriv); -#endif - - /* 268. GL_EXT_stencil_two_side */ -#if _HAVE_FULL_GL - SET_ActiveStencilFaceEXT(exec, _mesa_ActiveStencilFaceEXT); -#endif - - /* 285. GL_NV_primitive_restart */ - SET_PrimitiveRestartIndexNV(exec, _mesa_PrimitiveRestartIndex); - - /* ???. GL_EXT_depth_bounds_test */ - SET_DepthBoundsEXT(exec, _mesa_DepthBoundsEXT); - - /* 352. GL_EXT_transform_feedback */ - _mesa_init_transform_feedback_dispatch(exec); - - /* 364. GL_EXT_provoking_vertex */ - SET_ProvokingVertexEXT(exec, _mesa_ProvokingVertexEXT); - - /* ARB 1. GL_ARB_multitexture */ -#if _HAVE_FULL_GL - SET_ActiveTextureARB(exec, _mesa_ActiveTextureARB); - SET_ClientActiveTextureARB(exec, _mesa_ClientActiveTextureARB); -#endif - - /* ARB 3. GL_ARB_transpose_matrix */ -#if _HAVE_FULL_GL - SET_LoadTransposeMatrixdARB(exec, _mesa_LoadTransposeMatrixdARB); - SET_LoadTransposeMatrixfARB(exec, _mesa_LoadTransposeMatrixfARB); - SET_MultTransposeMatrixdARB(exec, _mesa_MultTransposeMatrixdARB); - SET_MultTransposeMatrixfARB(exec, _mesa_MultTransposeMatrixfARB); -#endif - - /* ARB 5. GL_ARB_multisample */ -#if _HAVE_FULL_GL - SET_SampleCoverageARB(exec, _mesa_SampleCoverageARB); -#endif - - /* ARB 12. GL_ARB_texture_compression */ -#if _HAVE_FULL_GL - SET_CompressedTexImage3DARB(exec, _mesa_CompressedTexImage3DARB); - SET_CompressedTexImage2DARB(exec, _mesa_CompressedTexImage2DARB); - SET_CompressedTexImage1DARB(exec, _mesa_CompressedTexImage1DARB); - SET_CompressedTexSubImage3DARB(exec, _mesa_CompressedTexSubImage3DARB); - SET_CompressedTexSubImage2DARB(exec, _mesa_CompressedTexSubImage2DARB); - SET_CompressedTexSubImage1DARB(exec, _mesa_CompressedTexSubImage1DARB); - SET_GetCompressedTexImageARB(exec, _mesa_GetCompressedTexImageARB); - - /* ARB 104. GL_ARB_robustness */ - SET_GetnCompressedTexImageARB(exec, _mesa_GetnCompressedTexImageARB); -#endif - - /* ARB 14. GL_ARB_point_parameters */ - /* reuse EXT_point_parameters functions */ - - /* ARB 26. GL_ARB_vertex_program */ - /* ARB 27. GL_ARB_fragment_program */ -#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program - /* glVertexAttrib1sARB aliases glVertexAttrib1sNV */ - /* glVertexAttrib1fARB aliases glVertexAttrib1fNV */ - /* glVertexAttrib1dARB aliases glVertexAttrib1dNV */ - /* glVertexAttrib2sARB aliases glVertexAttrib2sNV */ - /* glVertexAttrib2fARB aliases glVertexAttrib2fNV */ - /* glVertexAttrib2dARB aliases glVertexAttrib2dNV */ - /* glVertexAttrib3sARB aliases glVertexAttrib3sNV */ - /* glVertexAttrib3fARB aliases glVertexAttrib3fNV */ - /* glVertexAttrib3dARB aliases glVertexAttrib3dNV */ - /* glVertexAttrib4sARB aliases glVertexAttrib4sNV */ - /* glVertexAttrib4fARB aliases glVertexAttrib4fNV */ - /* glVertexAttrib4dARB aliases glVertexAttrib4dNV */ - /* glVertexAttrib4NubARB aliases glVertexAttrib4NubNV */ - /* glVertexAttrib1svARB aliases glVertexAttrib1svNV */ - /* glVertexAttrib1fvARB aliases glVertexAttrib1fvNV */ - /* glVertexAttrib1dvARB aliases glVertexAttrib1dvNV */ - /* glVertexAttrib2svARB aliases glVertexAttrib2svNV */ - /* glVertexAttrib2fvARB aliases glVertexAttrib2fvNV */ - /* glVertexAttrib2dvARB aliases glVertexAttrib2dvNV */ - /* glVertexAttrib3svARB aliases glVertexAttrib3svNV */ - /* glVertexAttrib3fvARB aliases glVertexAttrib3fvNV */ - /* glVertexAttrib3dvARB aliases glVertexAttrib3dvNV */ - /* glVertexAttrib4svARB aliases glVertexAttrib4svNV */ - /* glVertexAttrib4fvARB aliases glVertexAttrib4fvNV */ - /* glVertexAttrib4dvARB aliases glVertexAttrib4dvNV */ - /* glVertexAttrib4NubvARB aliases glVertexAttrib4NubvNV */ - /* glVertexAttrib4bvARB handled in api_loopback.c */ - /* glVertexAttrib4ivARB handled in api_loopback.c */ - /* glVertexAttrib4ubvARB handled in api_loopback.c */ - /* glVertexAttrib4usvARB handled in api_loopback.c */ - /* glVertexAttrib4uivARB handled in api_loopback.c */ - /* glVertexAttrib4NbvARB handled in api_loopback.c */ - /* glVertexAttrib4NsvARB handled in api_loopback.c */ - /* glVertexAttrib4NivARB handled in api_loopback.c */ - /* glVertexAttrib4NusvARB handled in api_loopback.c */ - /* glVertexAttrib4NuivARB handled in api_loopback.c */ - SET_VertexAttribPointerARB(exec, _mesa_VertexAttribPointerARB); - SET_EnableVertexAttribArrayARB(exec, _mesa_EnableVertexAttribArrayARB); - SET_DisableVertexAttribArrayARB(exec, _mesa_DisableVertexAttribArrayARB); - SET_ProgramStringARB(exec, _mesa_ProgramStringARB); - /* glBindProgramARB aliases glBindProgramNV */ - /* glDeleteProgramsARB aliases glDeleteProgramsNV */ - /* glGenProgramsARB aliases glGenProgramsNV */ - /* glIsProgramARB aliases glIsProgramNV */ - SET_GetVertexAttribdvARB(exec, _mesa_GetVertexAttribdvARB); - SET_GetVertexAttribfvARB(exec, _mesa_GetVertexAttribfvARB); - SET_GetVertexAttribivARB(exec, _mesa_GetVertexAttribivARB); - /* glGetVertexAttribPointervARB aliases glGetVertexAttribPointervNV */ - SET_ProgramEnvParameter4dARB(exec, _mesa_ProgramEnvParameter4dARB); - SET_ProgramEnvParameter4dvARB(exec, _mesa_ProgramEnvParameter4dvARB); - SET_ProgramEnvParameter4fARB(exec, _mesa_ProgramEnvParameter4fARB); - SET_ProgramEnvParameter4fvARB(exec, _mesa_ProgramEnvParameter4fvARB); - SET_ProgramLocalParameter4dARB(exec, _mesa_ProgramLocalParameter4dARB); - SET_ProgramLocalParameter4dvARB(exec, _mesa_ProgramLocalParameter4dvARB); - SET_ProgramLocalParameter4fARB(exec, _mesa_ProgramLocalParameter4fARB); - SET_ProgramLocalParameter4fvARB(exec, _mesa_ProgramLocalParameter4fvARB); - SET_GetProgramEnvParameterdvARB(exec, _mesa_GetProgramEnvParameterdvARB); - SET_GetProgramEnvParameterfvARB(exec, _mesa_GetProgramEnvParameterfvARB); - SET_GetProgramLocalParameterdvARB(exec, _mesa_GetProgramLocalParameterdvARB); - SET_GetProgramLocalParameterfvARB(exec, _mesa_GetProgramLocalParameterfvARB); - SET_GetProgramivARB(exec, _mesa_GetProgramivARB); - SET_GetProgramStringARB(exec, _mesa_GetProgramStringARB); -#endif - - /* ARB 28. GL_ARB_vertex_buffer_object */ -#if FEATURE_ARB_vertex_buffer_object - SET_BindBufferARB(exec, _mesa_BindBufferARB); - SET_BufferDataARB(exec, _mesa_BufferDataARB); - SET_BufferSubDataARB(exec, _mesa_BufferSubDataARB); - SET_DeleteBuffersARB(exec, _mesa_DeleteBuffersARB); - SET_GenBuffersARB(exec, _mesa_GenBuffersARB); - SET_GetBufferParameterivARB(exec, _mesa_GetBufferParameterivARB); - SET_GetBufferPointervARB(exec, _mesa_GetBufferPointervARB); - SET_GetBufferSubDataARB(exec, _mesa_GetBufferSubDataARB); - SET_IsBufferARB(exec, _mesa_IsBufferARB); - SET_MapBufferARB(exec, _mesa_MapBufferARB); - SET_UnmapBufferARB(exec, _mesa_UnmapBufferARB); -#endif - - /* ARB 29. GL_ARB_occlusion_query */ - _mesa_init_queryobj_dispatch(exec); - - /* ARB 37. GL_ARB_draw_buffers */ -#if FEATURE_draw_read_buffer - SET_DrawBuffersARB(exec, _mesa_DrawBuffersARB); -#endif - - /* ARB 104. GL_ARB_robustness */ - SET_GetGraphicsResetStatusARB(exec, _mesa_GetGraphicsResetStatusARB); - SET_GetnPolygonStippleARB(exec, _mesa_GetnPolygonStippleARB); - SET_GetnTexImageARB(exec, _mesa_GetnTexImageARB); - SET_ReadnPixelsARB(exec, _mesa_ReadnPixelsARB); - - /* GL_ARB_sync */ - _mesa_init_sync_dispatch(exec); - - /* GL_ATI_fragment_shader */ - _mesa_init_ati_fragment_shader_dispatch(exec); - - /* GL_ATI_envmap_bumpmap */ - SET_GetTexBumpParameterivATI(exec, _mesa_GetTexBumpParameterivATI); - SET_GetTexBumpParameterfvATI(exec, _mesa_GetTexBumpParameterfvATI); - SET_TexBumpParameterivATI(exec, _mesa_TexBumpParameterivATI); - SET_TexBumpParameterfvATI(exec, _mesa_TexBumpParameterfvATI); - -#if FEATURE_EXT_framebuffer_object - SET_IsRenderbufferEXT(exec, _mesa_IsRenderbufferEXT); - SET_BindRenderbufferEXT(exec, _mesa_BindRenderbufferEXT); - SET_DeleteRenderbuffersEXT(exec, _mesa_DeleteRenderbuffersEXT); - SET_GenRenderbuffersEXT(exec, _mesa_GenRenderbuffersEXT); - SET_RenderbufferStorageEXT(exec, _mesa_RenderbufferStorageEXT); - SET_GetRenderbufferParameterivEXT(exec, _mesa_GetRenderbufferParameterivEXT); - SET_IsFramebufferEXT(exec, _mesa_IsFramebufferEXT); - SET_BindFramebufferEXT(exec, _mesa_BindFramebufferEXT); - SET_DeleteFramebuffersEXT(exec, _mesa_DeleteFramebuffersEXT); - SET_GenFramebuffersEXT(exec, _mesa_GenFramebuffersEXT); - SET_CheckFramebufferStatusEXT(exec, _mesa_CheckFramebufferStatusEXT); - SET_FramebufferTexture1DEXT(exec, _mesa_FramebufferTexture1DEXT); - SET_FramebufferTexture2DEXT(exec, _mesa_FramebufferTexture2DEXT); - SET_FramebufferTexture3DEXT(exec, _mesa_FramebufferTexture3DEXT); - SET_FramebufferRenderbufferEXT(exec, _mesa_FramebufferRenderbufferEXT); - SET_GetFramebufferAttachmentParameterivEXT(exec, _mesa_GetFramebufferAttachmentParameterivEXT); - SET_GenerateMipmapEXT(exec, _mesa_GenerateMipmapEXT); -#endif - -#if FEATURE_EXT_framebuffer_blit - SET_BlitFramebufferEXT(exec, _mesa_BlitFramebufferEXT); -#endif - - /* GL_EXT_gpu_program_parameters */ -#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program - SET_ProgramEnvParameters4fvEXT(exec, _mesa_ProgramEnvParameters4fvEXT); - SET_ProgramLocalParameters4fvEXT(exec, _mesa_ProgramLocalParameters4fvEXT); -#endif - - /* GL_MESA_texture_array / GL_EXT_texture_array */ -#if FEATURE_EXT_framebuffer_object - SET_FramebufferTextureLayerEXT(exec, _mesa_FramebufferTextureLayerEXT); -#endif - - /* GL_ATI_separate_stencil */ - SET_StencilFuncSeparateATI(exec, _mesa_StencilFuncSeparateATI); - -#if FEATURE_ARB_framebuffer_object - /* The ARB_fbo functions are the union of - * GL_EXT_fbo, GL_EXT_framebuffer_blit, GL_EXT_texture_array - */ - SET_RenderbufferStorageMultisample(exec, _mesa_RenderbufferStorageMultisample); -#endif - -#if FEATURE_ARB_map_buffer_range - SET_MapBufferRange(exec, _mesa_MapBufferRange); - SET_FlushMappedBufferRange(exec, _mesa_FlushMappedBufferRange); -#endif - - /* GL_ARB_copy_buffer */ - SET_CopyBufferSubData(exec, _mesa_CopyBufferSubData); - - /* GL_ARB_vertex_array_object */ - SET_BindVertexArray(exec, _mesa_BindVertexArray); - SET_GenVertexArrays(exec, _mesa_GenVertexArrays); - - /* GL_EXT_draw_buffers2 */ - SET_ColorMaskIndexedEXT(exec, _mesa_ColorMaskIndexed); - SET_GetBooleanIndexedvEXT(exec, _mesa_GetBooleanIndexedv); - SET_GetIntegerIndexedvEXT(exec, _mesa_GetIntegerIndexedv); - SET_EnableIndexedEXT(exec, _mesa_EnableIndexed); - SET_DisableIndexedEXT(exec, _mesa_DisableIndexed); - SET_IsEnabledIndexedEXT(exec, _mesa_IsEnabledIndexed); - - /* GL_NV_conditional_render */ - SET_BeginConditionalRenderNV(exec, _mesa_BeginConditionalRender); - SET_EndConditionalRenderNV(exec, _mesa_EndConditionalRender); - -#if FEATURE_OES_EGL_image - SET_EGLImageTargetTexture2DOES(exec, _mesa_EGLImageTargetTexture2DOES); - SET_EGLImageTargetRenderbufferStorageOES(exec, _mesa_EGLImageTargetRenderbufferStorageOES); -#endif - -#if FEATURE_APPLE_object_purgeable - SET_ObjectPurgeableAPPLE(exec, _mesa_ObjectPurgeableAPPLE); - SET_ObjectUnpurgeableAPPLE(exec, _mesa_ObjectUnpurgeableAPPLE); - SET_GetObjectParameterivAPPLE(exec, _mesa_GetObjectParameterivAPPLE); -#endif - -#if FEATURE_ARB_geometry_shader4 - SET_FramebufferTextureARB(exec, _mesa_FramebufferTextureARB); - SET_FramebufferTextureFaceARB(exec, _mesa_FramebufferTextureFaceARB); -#endif - - SET_ClampColorARB(exec, _mesa_ClampColorARB); - - /* GL_EXT_texture_integer */ - SET_ClearColorIiEXT(exec, _mesa_ClearColorIiEXT); - SET_ClearColorIuiEXT(exec, _mesa_ClearColorIuiEXT); - SET_GetTexParameterIivEXT(exec, _mesa_GetTexParameterIiv); - SET_GetTexParameterIuivEXT(exec, _mesa_GetTexParameterIuiv); - SET_TexParameterIivEXT(exec, _mesa_TexParameterIiv); - SET_TexParameterIuivEXT(exec, _mesa_TexParameterIuiv); - - /* GL_EXT_gpu_shader4 / OpenGL 3.0 */ - SET_GetVertexAttribIivEXT(exec, _mesa_GetVertexAttribIiv); - SET_GetVertexAttribIuivEXT(exec, _mesa_GetVertexAttribIuiv); - SET_VertexAttribIPointerEXT(exec, _mesa_VertexAttribIPointer); - - /* GL 3.0 (functions not covered by other extensions) */ - SET_ClearBufferiv(exec, _mesa_ClearBufferiv); - SET_ClearBufferuiv(exec, _mesa_ClearBufferuiv); - SET_ClearBufferfv(exec, _mesa_ClearBufferfv); - SET_ClearBufferfi(exec, _mesa_ClearBufferfi); - SET_GetStringi(exec, _mesa_GetStringi); - SET_ClampColor(exec, _mesa_ClampColorARB); - - /* GL_ARB_instanced_arrays */ - SET_VertexAttribDivisorARB(exec, _mesa_VertexAttribDivisor); - - /* GL_ARB_draw_buffer_blend */ - SET_BlendFunciARB(exec, _mesa_BlendFunci); - SET_BlendFuncSeparateiARB(exec, _mesa_BlendFuncSeparatei); - SET_BlendEquationiARB(exec, _mesa_BlendEquationi); - SET_BlendEquationSeparateiARB(exec, _mesa_BlendEquationSeparatei); - - /* GL_NV_texture_barrier */ - SET_TextureBarrierNV(exec, _mesa_TextureBarrierNV); - - /* GL_ARB_texture_buffer_object */ - SET_TexBufferARB(exec, _mesa_TexBuffer); - -#if FEATURE_ARB_sampler_objects - _mesa_init_sampler_object_dispatch(exec); -#endif - - return exec; -} - -#endif /* FEATURE_GL */ +/* + * 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 api_exec.c + * Initialize dispatch table with the immidiate mode functions. + */ + + +#include "mfeatures.h" +#include "accum.h" +#include "api_loopback.h" +#include "api_exec.h" +#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program +#include "arbprogram.h" +#endif +#include "atifragshader.h" +#include "attrib.h" +#include "blend.h" +#if FEATURE_ARB_vertex_buffer_object +#include "bufferobj.h" +#endif +#include "arrayobj.h" +#if FEATURE_draw_read_buffer +#include "buffers.h" +#endif +#include "clear.h" +#include "clip.h" +#include "colortab.h" +#include "condrender.h" +#include "context.h" +#include "convolve.h" +#include "depth.h" +#include "dlist.h" +#include "drawpix.h" +#include "rastpos.h" +#include "enable.h" +#include "eval.h" +#include "get.h" +#include "feedback.h" +#include "fog.h" +#if FEATURE_EXT_framebuffer_object +#include "fbobject.h" +#endif +#include "framebuffer.h" +#include "hint.h" +#include "histogram.h" +#include "imports.h" +#include "light.h" +#include "lines.h" +#include "matrix.h" +#include "multisample.h" +#include "pixel.h" +#include "pixelstore.h" +#include "points.h" +#include "polygon.h" +#include "queryobj.h" +#include "readpix.h" +#if FEATURE_ARB_sampler_objects +#include "samplerobj.h" +#endif +#include "scissor.h" +#include "stencil.h" +#include "texenv.h" +#include "texgetimage.h" +#include "teximage.h" +#include "texgen.h" +#include "texobj.h" +#include "texparam.h" +#include "texstate.h" +#include "texturebarrier.h" +#include "transformfeedback.h" +#include "mtypes.h" +#include "varray.h" +#include "viewport.h" +#if FEATURE_NV_vertex_program || FEATURE_NV_fragment_program +#include "nvprogram.h" +#endif +#if FEATURE_ARB_shader_objects +#include "shaderapi.h" +#include "uniforms.h" +#endif +#include "syncobj.h" +#include "main/dispatch.h" + + +#if FEATURE_GL + + +/** + * Initialize a dispatch table with pointers to Mesa's immediate-mode + * commands. + * + * Pointers to glBegin()/glEnd() object commands and a few others + * are provided via the GLvertexformat interface. + * + * \param ctx GL context to which \c exec belongs. + * \param exec dispatch table. + */ +struct _glapi_table * +_mesa_create_exec_table(void) +{ + struct _glapi_table *exec; + + exec = _mesa_alloc_dispatch_table(_gloffset_COUNT); + if (exec == NULL) + return NULL; + +#if _HAVE_FULL_GL + _mesa_loopback_init_api_table( exec ); +#endif + + /* load the dispatch slots we understand */ + SET_AlphaFunc(exec, _mesa_AlphaFunc); + SET_BlendFunc(exec, _mesa_BlendFunc); + SET_Clear(exec, _mesa_Clear); + SET_ClearColor(exec, _mesa_ClearColor); + SET_ClearStencil(exec, _mesa_ClearStencil); + SET_ColorMask(exec, _mesa_ColorMask); + SET_CullFace(exec, _mesa_CullFace); + SET_Disable(exec, _mesa_Disable); +#if FEATURE_draw_read_buffer + SET_DrawBuffer(exec, _mesa_DrawBuffer); + SET_ReadBuffer(exec, _mesa_ReadBuffer); +#endif + SET_Enable(exec, _mesa_Enable); + SET_Finish(exec, _mesa_Finish); + SET_Flush(exec, _mesa_Flush); + SET_FrontFace(exec, _mesa_FrontFace); + SET_Frustum(exec, _mesa_Frustum); + SET_GetError(exec, _mesa_GetError); + SET_GetFloatv(exec, _mesa_GetFloatv); + SET_GetString(exec, _mesa_GetString); + SET_LineStipple(exec, _mesa_LineStipple); + SET_LineWidth(exec, _mesa_LineWidth); + SET_LoadIdentity(exec, _mesa_LoadIdentity); + SET_LoadMatrixf(exec, _mesa_LoadMatrixf); + SET_LogicOp(exec, _mesa_LogicOp); + SET_MatrixMode(exec, _mesa_MatrixMode); + SET_MultMatrixf(exec, _mesa_MultMatrixf); + SET_Ortho(exec, _mesa_Ortho); + SET_PixelStorei(exec, _mesa_PixelStorei); + SET_PopMatrix(exec, _mesa_PopMatrix); + SET_PushMatrix(exec, _mesa_PushMatrix); + SET_Rotatef(exec, _mesa_Rotatef); + SET_Scalef(exec, _mesa_Scalef); + SET_Scissor(exec, _mesa_Scissor); + SET_ShadeModel(exec, _mesa_ShadeModel); + SET_StencilFunc(exec, _mesa_StencilFunc); + SET_StencilMask(exec, _mesa_StencilMask); + SET_StencilOp(exec, _mesa_StencilOp); + SET_TexEnvfv(exec, _mesa_TexEnvfv); + SET_TexEnvi(exec, _mesa_TexEnvi); + SET_TexImage2D(exec, _mesa_TexImage2D); + SET_TexParameteri(exec, _mesa_TexParameteri); + SET_Translatef(exec, _mesa_Translatef); + SET_Viewport(exec, _mesa_Viewport); + + _mesa_init_accum_dispatch(exec); + _mesa_init_dlist_dispatch(exec); + + SET_ClearDepth(exec, _mesa_ClearDepth); + SET_ClearIndex(exec, _mesa_ClearIndex); + SET_ClipPlane(exec, _mesa_ClipPlane); + SET_ColorMaterial(exec, _mesa_ColorMaterial); + SET_DepthFunc(exec, _mesa_DepthFunc); + SET_DepthMask(exec, _mesa_DepthMask); + SET_DepthRange(exec, _mesa_DepthRange); + + _mesa_init_drawpix_dispatch(exec); + _mesa_init_feedback_dispatch(exec); + + SET_FogCoordPointerEXT(exec, _mesa_FogCoordPointerEXT); + SET_Fogf(exec, _mesa_Fogf); + SET_Fogfv(exec, _mesa_Fogfv); + SET_Fogi(exec, _mesa_Fogi); + SET_Fogiv(exec, _mesa_Fogiv); + SET_GetClipPlane(exec, _mesa_GetClipPlane); + SET_GetBooleanv(exec, _mesa_GetBooleanv); + SET_GetDoublev(exec, _mesa_GetDoublev); + SET_GetIntegerv(exec, _mesa_GetIntegerv); + SET_GetLightfv(exec, _mesa_GetLightfv); + SET_GetLightiv(exec, _mesa_GetLightiv); + SET_GetMaterialfv(exec, _mesa_GetMaterialfv); + SET_GetMaterialiv(exec, _mesa_GetMaterialiv); + SET_GetPolygonStipple(exec, _mesa_GetPolygonStipple); + SET_GetTexEnvfv(exec, _mesa_GetTexEnvfv); + SET_GetTexEnviv(exec, _mesa_GetTexEnviv); + SET_GetTexLevelParameterfv(exec, _mesa_GetTexLevelParameterfv); + SET_GetTexLevelParameteriv(exec, _mesa_GetTexLevelParameteriv); + SET_GetTexParameterfv(exec, _mesa_GetTexParameterfv); + SET_GetTexParameteriv(exec, _mesa_GetTexParameteriv); + SET_GetTexImage(exec, _mesa_GetTexImage); + SET_Hint(exec, _mesa_Hint); + SET_IndexMask(exec, _mesa_IndexMask); + SET_IsEnabled(exec, _mesa_IsEnabled); + SET_LightModelf(exec, _mesa_LightModelf); + SET_LightModelfv(exec, _mesa_LightModelfv); + SET_LightModeli(exec, _mesa_LightModeli); + SET_LightModeliv(exec, _mesa_LightModeliv); + SET_Lightf(exec, _mesa_Lightf); + SET_Lightfv(exec, _mesa_Lightfv); + SET_Lighti(exec, _mesa_Lighti); + SET_Lightiv(exec, _mesa_Lightiv); + SET_LoadMatrixd(exec, _mesa_LoadMatrixd); + + _mesa_init_eval_dispatch(exec); + + SET_MultMatrixd(exec, _mesa_MultMatrixd); + + _mesa_init_pixel_dispatch(exec); + + SET_PixelStoref(exec, _mesa_PixelStoref); + SET_PointSize(exec, _mesa_PointSize); + SET_PolygonMode(exec, _mesa_PolygonMode); + SET_PolygonOffset(exec, _mesa_PolygonOffset); + SET_PolygonStipple(exec, _mesa_PolygonStipple); + + _mesa_init_attrib_dispatch(exec); + _mesa_init_rastpos_dispatch(exec); + + SET_ReadPixels(exec, _mesa_ReadPixels); + SET_Rotated(exec, _mesa_Rotated); + SET_Scaled(exec, _mesa_Scaled); + SET_SecondaryColorPointerEXT(exec, _mesa_SecondaryColorPointerEXT); + SET_TexEnvf(exec, _mesa_TexEnvf); + SET_TexEnviv(exec, _mesa_TexEnviv); + + _mesa_init_texgen_dispatch(exec); + + SET_TexImage1D(exec, _mesa_TexImage1D); + SET_TexParameterf(exec, _mesa_TexParameterf); + SET_TexParameterfv(exec, _mesa_TexParameterfv); + SET_TexParameteriv(exec, _mesa_TexParameteriv); + SET_Translated(exec, _mesa_Translated); + + /* 1.1 */ + SET_BindTexture(exec, _mesa_BindTexture); + SET_DeleteTextures(exec, _mesa_DeleteTextures); + SET_GenTextures(exec, _mesa_GenTextures); +#if _HAVE_FULL_GL + SET_AreTexturesResident(exec, _mesa_AreTexturesResident); + SET_ColorPointer(exec, _mesa_ColorPointer); + SET_CopyTexImage1D(exec, _mesa_CopyTexImage1D); + SET_CopyTexImage2D(exec, _mesa_CopyTexImage2D); + SET_CopyTexSubImage1D(exec, _mesa_CopyTexSubImage1D); + SET_CopyTexSubImage2D(exec, _mesa_CopyTexSubImage2D); + SET_DisableClientState(exec, _mesa_DisableClientState); + SET_EdgeFlagPointer(exec, _mesa_EdgeFlagPointer); + SET_EnableClientState(exec, _mesa_EnableClientState); + SET_GetPointerv(exec, _mesa_GetPointerv); + SET_IndexPointer(exec, _mesa_IndexPointer); + SET_InterleavedArrays(exec, _mesa_InterleavedArrays); + SET_IsTexture(exec, _mesa_IsTexture); + SET_NormalPointer(exec, _mesa_NormalPointer); + SET_PrioritizeTextures(exec, _mesa_PrioritizeTextures); + SET_TexCoordPointer(exec, _mesa_TexCoordPointer); + SET_TexSubImage1D(exec, _mesa_TexSubImage1D); + SET_TexSubImage2D(exec, _mesa_TexSubImage2D); + SET_VertexPointer(exec, _mesa_VertexPointer); +#endif + + /* 1.2 */ +#if _HAVE_FULL_GL + SET_CopyTexSubImage3D(exec, _mesa_CopyTexSubImage3D); + SET_TexImage3D(exec, _mesa_TexImage3D); + SET_TexSubImage3D(exec, _mesa_TexSubImage3D); +#endif + + /* OpenGL 1.2 GL_ARB_imaging */ + SET_BlendColor(exec, _mesa_BlendColor); + SET_BlendEquation(exec, _mesa_BlendEquation); + SET_BlendEquationSeparateEXT(exec, _mesa_BlendEquationSeparateEXT); + + _mesa_init_colortable_dispatch(exec); + _mesa_init_convolve_dispatch(exec); + _mesa_init_histogram_dispatch(exec); + + /* OpenGL 2.0 */ + SET_StencilFuncSeparate(exec, _mesa_StencilFuncSeparate); + SET_StencilMaskSeparate(exec, _mesa_StencilMaskSeparate); + SET_StencilOpSeparate(exec, _mesa_StencilOpSeparate); + +#if FEATURE_ARB_shader_objects + _mesa_init_shader_dispatch(exec); + _mesa_init_shader_uniform_dispatch(exec); +#endif + + /* 2. GL_EXT_blend_color */ +#if 0 +/* SET_BlendColorEXT(exec, _mesa_BlendColorEXT); */ +#endif + + /* 3. GL_EXT_polygon_offset */ +#if _HAVE_FULL_GL + SET_PolygonOffsetEXT(exec, _mesa_PolygonOffsetEXT); +#endif + + /* 6. GL_EXT_texture3d */ +#if 0 +/* SET_CopyTexSubImage3DEXT(exec, _mesa_CopyTexSubImage3D); */ +/* SET_TexImage3DEXT(exec, _mesa_TexImage3DEXT); */ +/* SET_TexSubImage3DEXT(exec, _mesa_TexSubImage3D); */ +#endif + + /* 11. GL_EXT_histogram */ +#if 0 + SET_GetHistogramEXT(exec, _mesa_GetHistogram); + SET_GetHistogramParameterfvEXT(exec, _mesa_GetHistogramParameterfv); + SET_GetHistogramParameterivEXT(exec, _mesa_GetHistogramParameteriv); + SET_GetMinmaxEXT(exec, _mesa_GetMinmax); + SET_GetMinmaxParameterfvEXT(exec, _mesa_GetMinmaxParameterfv); + SET_GetMinmaxParameterivEXT(exec, _mesa_GetMinmaxParameteriv); +#endif + + /* 14. SGI_color_table */ +#if 0 + SET_ColorTableSGI(exec, _mesa_ColorTable); + SET_ColorSubTableSGI(exec, _mesa_ColorSubTable); + SET_GetColorTableSGI(exec, _mesa_GetColorTable); + SET_GetColorTableParameterfvSGI(exec, _mesa_GetColorTableParameterfv); + SET_GetColorTableParameterivSGI(exec, _mesa_GetColorTableParameteriv); +#endif + + /* 30. GL_EXT_vertex_array */ +#if _HAVE_FULL_GL + SET_ColorPointerEXT(exec, _mesa_ColorPointerEXT); + SET_EdgeFlagPointerEXT(exec, _mesa_EdgeFlagPointerEXT); + SET_IndexPointerEXT(exec, _mesa_IndexPointerEXT); + SET_NormalPointerEXT(exec, _mesa_NormalPointerEXT); + SET_TexCoordPointerEXT(exec, _mesa_TexCoordPointerEXT); + SET_VertexPointerEXT(exec, _mesa_VertexPointerEXT); +#endif + + /* 37. GL_EXT_blend_minmax */ +#if 0 + SET_BlendEquationEXT(exec, _mesa_BlendEquationEXT); +#endif + + /* 54. GL_EXT_point_parameters */ +#if _HAVE_FULL_GL + SET_PointParameterfEXT(exec, _mesa_PointParameterf); + SET_PointParameterfvEXT(exec, _mesa_PointParameterfv); +#endif + + /* 95. GL_ARB_ES2_compatibility */ + SET_ClearDepthf(exec, _mesa_ClearDepthf); + SET_DepthRangef(exec, _mesa_DepthRangef); + + /* 97. GL_EXT_compiled_vertex_array */ +#if _HAVE_FULL_GL + SET_LockArraysEXT(exec, _mesa_LockArraysEXT); + SET_UnlockArraysEXT(exec, _mesa_UnlockArraysEXT); +#endif + + /* 148. GL_EXT_multi_draw_arrays */ +#if _HAVE_FULL_GL + SET_MultiDrawArraysEXT(exec, _mesa_MultiDrawArraysEXT); +#endif + + /* 173. GL_INGR_blend_func_separate */ +#if _HAVE_FULL_GL + SET_BlendFuncSeparateEXT(exec, _mesa_BlendFuncSeparateEXT); +#endif + + /* 196. GL_MESA_resize_buffers */ +#if _HAVE_FULL_GL + SET_ResizeBuffersMESA(exec, _mesa_ResizeBuffersMESA); +#endif + + /* 197. GL_MESA_window_pos */ + /* part of _mesa_init_rastpos_dispatch(exec); */ + + /* 200. GL_IBM_multimode_draw_arrays */ +#if _HAVE_FULL_GL + SET_MultiModeDrawArraysIBM(exec, _mesa_MultiModeDrawArraysIBM); + SET_MultiModeDrawElementsIBM(exec, _mesa_MultiModeDrawElementsIBM); +#endif + + /* 233. GL_NV_vertex_program */ +#if FEATURE_NV_vertex_program + SET_BindProgramNV(exec, _mesa_BindProgram); + SET_DeleteProgramsNV(exec, _mesa_DeletePrograms); + SET_ExecuteProgramNV(exec, _mesa_ExecuteProgramNV); + SET_GenProgramsNV(exec, _mesa_GenPrograms); + SET_AreProgramsResidentNV(exec, _mesa_AreProgramsResidentNV); + SET_RequestResidentProgramsNV(exec, _mesa_RequestResidentProgramsNV); + SET_GetProgramParameterfvNV(exec, _mesa_GetProgramParameterfvNV); + SET_GetProgramParameterdvNV(exec, _mesa_GetProgramParameterdvNV); + SET_GetProgramivNV(exec, _mesa_GetProgramivNV); + SET_GetProgramStringNV(exec, _mesa_GetProgramStringNV); + SET_GetTrackMatrixivNV(exec, _mesa_GetTrackMatrixivNV); + SET_GetVertexAttribdvNV(exec, _mesa_GetVertexAttribdvNV); + SET_GetVertexAttribfvNV(exec, _mesa_GetVertexAttribfvNV); + SET_GetVertexAttribivNV(exec, _mesa_GetVertexAttribivNV); + SET_GetVertexAttribPointervNV(exec, _mesa_GetVertexAttribPointervNV); + SET_IsProgramNV(exec, _mesa_IsProgramARB); + SET_LoadProgramNV(exec, _mesa_LoadProgramNV); + SET_ProgramEnvParameter4dARB(exec, _mesa_ProgramEnvParameter4dARB); /* alias to ProgramParameter4dNV */ + SET_ProgramEnvParameter4dvARB(exec, _mesa_ProgramEnvParameter4dvARB); /* alias to ProgramParameter4dvNV */ + SET_ProgramEnvParameter4fARB(exec, _mesa_ProgramEnvParameter4fARB); /* alias to ProgramParameter4fNV */ + SET_ProgramEnvParameter4fvARB(exec, _mesa_ProgramEnvParameter4fvARB); /* alias to ProgramParameter4fvNV */ + SET_ProgramParameters4dvNV(exec, _mesa_ProgramParameters4dvNV); + SET_ProgramParameters4fvNV(exec, _mesa_ProgramParameters4fvNV); + SET_TrackMatrixNV(exec, _mesa_TrackMatrixNV); + SET_VertexAttribPointerNV(exec, _mesa_VertexAttribPointerNV); + /* glVertexAttrib*NV functions handled in api_loopback.c */ +#endif + + /* 273. GL_APPLE_vertex_array_object */ + SET_BindVertexArrayAPPLE(exec, _mesa_BindVertexArrayAPPLE); + SET_DeleteVertexArraysAPPLE(exec, _mesa_DeleteVertexArraysAPPLE); + SET_GenVertexArraysAPPLE(exec, _mesa_GenVertexArraysAPPLE); + SET_IsVertexArrayAPPLE(exec, _mesa_IsVertexArrayAPPLE); + + /* 282. GL_NV_fragment_program */ +#if FEATURE_NV_fragment_program + SET_ProgramNamedParameter4fNV(exec, _mesa_ProgramNamedParameter4fNV); + SET_ProgramNamedParameter4dNV(exec, _mesa_ProgramNamedParameter4dNV); + SET_ProgramNamedParameter4fvNV(exec, _mesa_ProgramNamedParameter4fvNV); + SET_ProgramNamedParameter4dvNV(exec, _mesa_ProgramNamedParameter4dvNV); + SET_GetProgramNamedParameterfvNV(exec, _mesa_GetProgramNamedParameterfvNV); + SET_GetProgramNamedParameterdvNV(exec, _mesa_GetProgramNamedParameterdvNV); + SET_ProgramLocalParameter4dARB(exec, _mesa_ProgramLocalParameter4dARB); + SET_ProgramLocalParameter4dvARB(exec, _mesa_ProgramLocalParameter4dvARB); + SET_ProgramLocalParameter4fARB(exec, _mesa_ProgramLocalParameter4fARB); + SET_ProgramLocalParameter4fvARB(exec, _mesa_ProgramLocalParameter4fvARB); + SET_GetProgramLocalParameterdvARB(exec, _mesa_GetProgramLocalParameterdvARB); + SET_GetProgramLocalParameterfvARB(exec, _mesa_GetProgramLocalParameterfvARB); +#endif + + /* 262. GL_NV_point_sprite */ +#if _HAVE_FULL_GL + SET_PointParameteriNV(exec, _mesa_PointParameteri); + SET_PointParameterivNV(exec, _mesa_PointParameteriv); +#endif + + /* 268. GL_EXT_stencil_two_side */ +#if _HAVE_FULL_GL + SET_ActiveStencilFaceEXT(exec, _mesa_ActiveStencilFaceEXT); +#endif + + /* 285. GL_NV_primitive_restart */ + SET_PrimitiveRestartIndexNV(exec, _mesa_PrimitiveRestartIndex); + + /* ???. GL_EXT_depth_bounds_test */ + SET_DepthBoundsEXT(exec, _mesa_DepthBoundsEXT); + + /* 352. GL_EXT_transform_feedback */ + _mesa_init_transform_feedback_dispatch(exec); + + /* 364. GL_EXT_provoking_vertex */ + SET_ProvokingVertexEXT(exec, _mesa_ProvokingVertexEXT); + + /* ARB 1. GL_ARB_multitexture */ +#if _HAVE_FULL_GL + SET_ActiveTextureARB(exec, _mesa_ActiveTextureARB); + SET_ClientActiveTextureARB(exec, _mesa_ClientActiveTextureARB); +#endif + + /* ARB 3. GL_ARB_transpose_matrix */ +#if _HAVE_FULL_GL + SET_LoadTransposeMatrixdARB(exec, _mesa_LoadTransposeMatrixdARB); + SET_LoadTransposeMatrixfARB(exec, _mesa_LoadTransposeMatrixfARB); + SET_MultTransposeMatrixdARB(exec, _mesa_MultTransposeMatrixdARB); + SET_MultTransposeMatrixfARB(exec, _mesa_MultTransposeMatrixfARB); +#endif + + /* ARB 5. GL_ARB_multisample */ +#if _HAVE_FULL_GL + SET_SampleCoverageARB(exec, _mesa_SampleCoverageARB); +#endif + + /* ARB 12. GL_ARB_texture_compression */ +#if _HAVE_FULL_GL + SET_CompressedTexImage3DARB(exec, _mesa_CompressedTexImage3DARB); + SET_CompressedTexImage2DARB(exec, _mesa_CompressedTexImage2DARB); + SET_CompressedTexImage1DARB(exec, _mesa_CompressedTexImage1DARB); + SET_CompressedTexSubImage3DARB(exec, _mesa_CompressedTexSubImage3DARB); + SET_CompressedTexSubImage2DARB(exec, _mesa_CompressedTexSubImage2DARB); + SET_CompressedTexSubImage1DARB(exec, _mesa_CompressedTexSubImage1DARB); + SET_GetCompressedTexImageARB(exec, _mesa_GetCompressedTexImageARB); + + /* ARB 104. GL_ARB_robustness */ + SET_GetnCompressedTexImageARB(exec, _mesa_GetnCompressedTexImageARB); +#endif + + /* ARB 14. GL_ARB_point_parameters */ + /* reuse EXT_point_parameters functions */ + + /* ARB 26. GL_ARB_vertex_program */ + /* ARB 27. GL_ARB_fragment_program */ +#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program + /* glVertexAttrib1sARB aliases glVertexAttrib1sNV */ + /* glVertexAttrib1fARB aliases glVertexAttrib1fNV */ + /* glVertexAttrib1dARB aliases glVertexAttrib1dNV */ + /* glVertexAttrib2sARB aliases glVertexAttrib2sNV */ + /* glVertexAttrib2fARB aliases glVertexAttrib2fNV */ + /* glVertexAttrib2dARB aliases glVertexAttrib2dNV */ + /* glVertexAttrib3sARB aliases glVertexAttrib3sNV */ + /* glVertexAttrib3fARB aliases glVertexAttrib3fNV */ + /* glVertexAttrib3dARB aliases glVertexAttrib3dNV */ + /* glVertexAttrib4sARB aliases glVertexAttrib4sNV */ + /* glVertexAttrib4fARB aliases glVertexAttrib4fNV */ + /* glVertexAttrib4dARB aliases glVertexAttrib4dNV */ + /* glVertexAttrib4NubARB aliases glVertexAttrib4NubNV */ + /* glVertexAttrib1svARB aliases glVertexAttrib1svNV */ + /* glVertexAttrib1fvARB aliases glVertexAttrib1fvNV */ + /* glVertexAttrib1dvARB aliases glVertexAttrib1dvNV */ + /* glVertexAttrib2svARB aliases glVertexAttrib2svNV */ + /* glVertexAttrib2fvARB aliases glVertexAttrib2fvNV */ + /* glVertexAttrib2dvARB aliases glVertexAttrib2dvNV */ + /* glVertexAttrib3svARB aliases glVertexAttrib3svNV */ + /* glVertexAttrib3fvARB aliases glVertexAttrib3fvNV */ + /* glVertexAttrib3dvARB aliases glVertexAttrib3dvNV */ + /* glVertexAttrib4svARB aliases glVertexAttrib4svNV */ + /* glVertexAttrib4fvARB aliases glVertexAttrib4fvNV */ + /* glVertexAttrib4dvARB aliases glVertexAttrib4dvNV */ + /* glVertexAttrib4NubvARB aliases glVertexAttrib4NubvNV */ + /* glVertexAttrib4bvARB handled in api_loopback.c */ + /* glVertexAttrib4ivARB handled in api_loopback.c */ + /* glVertexAttrib4ubvARB handled in api_loopback.c */ + /* glVertexAttrib4usvARB handled in api_loopback.c */ + /* glVertexAttrib4uivARB handled in api_loopback.c */ + /* glVertexAttrib4NbvARB handled in api_loopback.c */ + /* glVertexAttrib4NsvARB handled in api_loopback.c */ + /* glVertexAttrib4NivARB handled in api_loopback.c */ + /* glVertexAttrib4NusvARB handled in api_loopback.c */ + /* glVertexAttrib4NuivARB handled in api_loopback.c */ + SET_VertexAttribPointerARB(exec, _mesa_VertexAttribPointerARB); + SET_EnableVertexAttribArrayARB(exec, _mesa_EnableVertexAttribArrayARB); + SET_DisableVertexAttribArrayARB(exec, _mesa_DisableVertexAttribArrayARB); + SET_ProgramStringARB(exec, _mesa_ProgramStringARB); + /* glBindProgramARB aliases glBindProgramNV */ + /* glDeleteProgramsARB aliases glDeleteProgramsNV */ + /* glGenProgramsARB aliases glGenProgramsNV */ + /* glIsProgramARB aliases glIsProgramNV */ + SET_GetVertexAttribdvARB(exec, _mesa_GetVertexAttribdvARB); + SET_GetVertexAttribfvARB(exec, _mesa_GetVertexAttribfvARB); + SET_GetVertexAttribivARB(exec, _mesa_GetVertexAttribivARB); + /* glGetVertexAttribPointervARB aliases glGetVertexAttribPointervNV */ + SET_ProgramEnvParameter4dARB(exec, _mesa_ProgramEnvParameter4dARB); + SET_ProgramEnvParameter4dvARB(exec, _mesa_ProgramEnvParameter4dvARB); + SET_ProgramEnvParameter4fARB(exec, _mesa_ProgramEnvParameter4fARB); + SET_ProgramEnvParameter4fvARB(exec, _mesa_ProgramEnvParameter4fvARB); + SET_ProgramLocalParameter4dARB(exec, _mesa_ProgramLocalParameter4dARB); + SET_ProgramLocalParameter4dvARB(exec, _mesa_ProgramLocalParameter4dvARB); + SET_ProgramLocalParameter4fARB(exec, _mesa_ProgramLocalParameter4fARB); + SET_ProgramLocalParameter4fvARB(exec, _mesa_ProgramLocalParameter4fvARB); + SET_GetProgramEnvParameterdvARB(exec, _mesa_GetProgramEnvParameterdvARB); + SET_GetProgramEnvParameterfvARB(exec, _mesa_GetProgramEnvParameterfvARB); + SET_GetProgramLocalParameterdvARB(exec, _mesa_GetProgramLocalParameterdvARB); + SET_GetProgramLocalParameterfvARB(exec, _mesa_GetProgramLocalParameterfvARB); + SET_GetProgramivARB(exec, _mesa_GetProgramivARB); + SET_GetProgramStringARB(exec, _mesa_GetProgramStringARB); +#endif + + /* ARB 28. GL_ARB_vertex_buffer_object */ +#if FEATURE_ARB_vertex_buffer_object + SET_BindBufferARB(exec, _mesa_BindBufferARB); + SET_BufferDataARB(exec, _mesa_BufferDataARB); + SET_BufferSubDataARB(exec, _mesa_BufferSubDataARB); + SET_DeleteBuffersARB(exec, _mesa_DeleteBuffersARB); + SET_GenBuffersARB(exec, _mesa_GenBuffersARB); + SET_GetBufferParameterivARB(exec, _mesa_GetBufferParameterivARB); + SET_GetBufferPointervARB(exec, _mesa_GetBufferPointervARB); + SET_GetBufferSubDataARB(exec, _mesa_GetBufferSubDataARB); + SET_IsBufferARB(exec, _mesa_IsBufferARB); + SET_MapBufferARB(exec, _mesa_MapBufferARB); + SET_UnmapBufferARB(exec, _mesa_UnmapBufferARB); +#endif + + /* ARB 29. GL_ARB_occlusion_query */ + _mesa_init_queryobj_dispatch(exec); + + /* ARB 37. GL_ARB_draw_buffers */ +#if FEATURE_draw_read_buffer + SET_DrawBuffersARB(exec, _mesa_DrawBuffersARB); +#endif + + /* ARB 104. GL_ARB_robustness */ + SET_GetGraphicsResetStatusARB(exec, _mesa_GetGraphicsResetStatusARB); + SET_GetnPolygonStippleARB(exec, _mesa_GetnPolygonStippleARB); + SET_GetnTexImageARB(exec, _mesa_GetnTexImageARB); + SET_ReadnPixelsARB(exec, _mesa_ReadnPixelsARB); + + /* GL_ARB_sync */ + _mesa_init_sync_dispatch(exec); + + /* GL_ATI_fragment_shader */ + _mesa_init_ati_fragment_shader_dispatch(exec); + + /* GL_ATI_envmap_bumpmap */ + SET_GetTexBumpParameterivATI(exec, _mesa_GetTexBumpParameterivATI); + SET_GetTexBumpParameterfvATI(exec, _mesa_GetTexBumpParameterfvATI); + SET_TexBumpParameterivATI(exec, _mesa_TexBumpParameterivATI); + SET_TexBumpParameterfvATI(exec, _mesa_TexBumpParameterfvATI); + +#if FEATURE_EXT_framebuffer_object + SET_IsRenderbufferEXT(exec, _mesa_IsRenderbufferEXT); + SET_BindRenderbufferEXT(exec, _mesa_BindRenderbufferEXT); + SET_DeleteRenderbuffersEXT(exec, _mesa_DeleteRenderbuffersEXT); + SET_GenRenderbuffersEXT(exec, _mesa_GenRenderbuffersEXT); + SET_RenderbufferStorageEXT(exec, _mesa_RenderbufferStorageEXT); + SET_GetRenderbufferParameterivEXT(exec, _mesa_GetRenderbufferParameterivEXT); + SET_IsFramebufferEXT(exec, _mesa_IsFramebufferEXT); + SET_BindFramebufferEXT(exec, _mesa_BindFramebufferEXT); + SET_DeleteFramebuffersEXT(exec, _mesa_DeleteFramebuffersEXT); + SET_GenFramebuffersEXT(exec, _mesa_GenFramebuffersEXT); + SET_CheckFramebufferStatusEXT(exec, _mesa_CheckFramebufferStatusEXT); + SET_FramebufferTexture1DEXT(exec, _mesa_FramebufferTexture1DEXT); + SET_FramebufferTexture2DEXT(exec, _mesa_FramebufferTexture2DEXT); + SET_FramebufferTexture3DEXT(exec, _mesa_FramebufferTexture3DEXT); + SET_FramebufferRenderbufferEXT(exec, _mesa_FramebufferRenderbufferEXT); + SET_GetFramebufferAttachmentParameterivEXT(exec, _mesa_GetFramebufferAttachmentParameterivEXT); + SET_GenerateMipmapEXT(exec, _mesa_GenerateMipmapEXT); +#endif + +#if FEATURE_EXT_framebuffer_blit + SET_BlitFramebufferEXT(exec, _mesa_BlitFramebufferEXT); +#endif + + /* GL_EXT_gpu_program_parameters */ +#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program + SET_ProgramEnvParameters4fvEXT(exec, _mesa_ProgramEnvParameters4fvEXT); + SET_ProgramLocalParameters4fvEXT(exec, _mesa_ProgramLocalParameters4fvEXT); +#endif + + /* GL_MESA_texture_array / GL_EXT_texture_array */ +#if FEATURE_EXT_framebuffer_object + SET_FramebufferTextureLayerEXT(exec, _mesa_FramebufferTextureLayerEXT); +#endif + + /* GL_ATI_separate_stencil */ + SET_StencilFuncSeparateATI(exec, _mesa_StencilFuncSeparateATI); + +#if FEATURE_ARB_framebuffer_object + /* The ARB_fbo functions are the union of + * GL_EXT_fbo, GL_EXT_framebuffer_blit, GL_EXT_texture_array + */ + SET_RenderbufferStorageMultisample(exec, _mesa_RenderbufferStorageMultisample); +#endif + +#if FEATURE_ARB_map_buffer_range + SET_MapBufferRange(exec, _mesa_MapBufferRange); + SET_FlushMappedBufferRange(exec, _mesa_FlushMappedBufferRange); +#endif + + /* GL_ARB_copy_buffer */ + SET_CopyBufferSubData(exec, _mesa_CopyBufferSubData); + + /* GL_ARB_vertex_array_object */ + SET_BindVertexArray(exec, _mesa_BindVertexArray); + SET_GenVertexArrays(exec, _mesa_GenVertexArrays); + + /* GL_EXT_draw_buffers2 */ + SET_ColorMaskIndexedEXT(exec, _mesa_ColorMaskIndexed); + SET_GetBooleanIndexedvEXT(exec, _mesa_GetBooleanIndexedv); + SET_GetIntegerIndexedvEXT(exec, _mesa_GetIntegerIndexedv); + SET_EnableIndexedEXT(exec, _mesa_EnableIndexed); + SET_DisableIndexedEXT(exec, _mesa_DisableIndexed); + SET_IsEnabledIndexedEXT(exec, _mesa_IsEnabledIndexed); + + /* GL_NV_conditional_render */ + SET_BeginConditionalRenderNV(exec, _mesa_BeginConditionalRender); + SET_EndConditionalRenderNV(exec, _mesa_EndConditionalRender); + +#if FEATURE_OES_EGL_image + SET_EGLImageTargetTexture2DOES(exec, _mesa_EGLImageTargetTexture2DOES); + SET_EGLImageTargetRenderbufferStorageOES(exec, _mesa_EGLImageTargetRenderbufferStorageOES); +#endif + +#if FEATURE_APPLE_object_purgeable + SET_ObjectPurgeableAPPLE(exec, _mesa_ObjectPurgeableAPPLE); + SET_ObjectUnpurgeableAPPLE(exec, _mesa_ObjectUnpurgeableAPPLE); + SET_GetObjectParameterivAPPLE(exec, _mesa_GetObjectParameterivAPPLE); +#endif + +#if FEATURE_ARB_geometry_shader4 + SET_FramebufferTextureARB(exec, _mesa_FramebufferTextureARB); + SET_FramebufferTextureFaceARB(exec, _mesa_FramebufferTextureFaceARB); +#endif + + SET_ClampColorARB(exec, _mesa_ClampColorARB); + + /* GL_EXT_texture_integer */ + SET_ClearColorIiEXT(exec, _mesa_ClearColorIiEXT); + SET_ClearColorIuiEXT(exec, _mesa_ClearColorIuiEXT); + SET_GetTexParameterIivEXT(exec, _mesa_GetTexParameterIiv); + SET_GetTexParameterIuivEXT(exec, _mesa_GetTexParameterIuiv); + SET_TexParameterIivEXT(exec, _mesa_TexParameterIiv); + SET_TexParameterIuivEXT(exec, _mesa_TexParameterIuiv); + + /* GL_EXT_gpu_shader4 / OpenGL 3.0 */ + SET_GetVertexAttribIivEXT(exec, _mesa_GetVertexAttribIiv); + SET_GetVertexAttribIuivEXT(exec, _mesa_GetVertexAttribIuiv); + SET_VertexAttribIPointerEXT(exec, _mesa_VertexAttribIPointer); + + /* GL 3.0 (functions not covered by other extensions) */ + SET_ClearBufferiv(exec, _mesa_ClearBufferiv); + SET_ClearBufferuiv(exec, _mesa_ClearBufferuiv); + SET_ClearBufferfv(exec, _mesa_ClearBufferfv); + SET_ClearBufferfi(exec, _mesa_ClearBufferfi); + SET_GetStringi(exec, _mesa_GetStringi); + SET_ClampColor(exec, _mesa_ClampColorARB); + + /* GL_ARB_instanced_arrays */ + SET_VertexAttribDivisorARB(exec, _mesa_VertexAttribDivisor); + + /* GL_ARB_draw_buffer_blend */ + SET_BlendFunciARB(exec, _mesa_BlendFunci); + SET_BlendFuncSeparateiARB(exec, _mesa_BlendFuncSeparatei); + SET_BlendEquationiARB(exec, _mesa_BlendEquationi); + SET_BlendEquationSeparateiARB(exec, _mesa_BlendEquationSeparatei); + + /* GL_NV_texture_barrier */ + SET_TextureBarrierNV(exec, _mesa_TextureBarrierNV); + + /* GL_ARB_texture_buffer_object */ + SET_TexBufferARB(exec, _mesa_TexBuffer); + +#if FEATURE_ARB_sampler_objects + _mesa_init_sampler_object_dispatch(exec); +#endif + + return exec; +} + +#endif /* FEATURE_GL */ diff --git a/mesalib/src/mesa/main/attrib.c b/mesalib/src/mesa/main/attrib.c index ed461f1e7..573100402 100644 --- a/mesalib/src/mesa/main/attrib.c +++ b/mesalib/src/mesa/main/attrib.c @@ -1,1563 +1,1563 @@ -/* - * Mesa 3-D graphics library - * Version: 7.6 - * - * Copyright (C) 1999-2008 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 "glheader.h" -#include "imports.h" -#include "accum.h" -#include "arrayobj.h" -#include "attrib.h" -#include "blend.h" -#include "buffers.h" -#include "bufferobj.h" -#include "clear.h" -#include "colormac.h" -#include "context.h" -#include "depth.h" -#include "enable.h" -#include "enums.h" -#include "fog.h" -#include "hint.h" -#include "light.h" -#include "lines.h" -#include "macros.h" -#include "matrix.h" -#include "mfeatures.h" -#include "multisample.h" -#include "points.h" -#include "polygon.h" -#include "scissor.h" -#include "stencil.h" -#include "texenv.h" -#include "texgen.h" -#include "texobj.h" -#include "texparam.h" -#include "texstate.h" -#include "varray.h" -#include "viewport.h" -#include "mtypes.h" -#include "main/dispatch.h" - - -/** - * glEnable()/glDisable() attribute group (GL_ENABLE_BIT). - */ -struct gl_enable_attrib -{ - GLboolean AlphaTest; - GLboolean AutoNormal; - GLboolean Blend; - GLbitfield ClipPlanes; - GLboolean ColorMaterial; - GLboolean CullFace; - GLboolean DepthClamp; - GLboolean DepthTest; - GLboolean Dither; - GLboolean Fog; - GLboolean Light[MAX_LIGHTS]; - GLboolean Lighting; - GLboolean LineSmooth; - GLboolean LineStipple; - GLboolean IndexLogicOp; - GLboolean ColorLogicOp; - - GLboolean Map1Color4; - GLboolean Map1Index; - GLboolean Map1Normal; - GLboolean Map1TextureCoord1; - GLboolean Map1TextureCoord2; - GLboolean Map1TextureCoord3; - GLboolean Map1TextureCoord4; - GLboolean Map1Vertex3; - GLboolean Map1Vertex4; - GLboolean Map1Attrib[16]; /* GL_NV_vertex_program */ - GLboolean Map2Color4; - GLboolean Map2Index; - GLboolean Map2Normal; - GLboolean Map2TextureCoord1; - GLboolean Map2TextureCoord2; - GLboolean Map2TextureCoord3; - GLboolean Map2TextureCoord4; - GLboolean Map2Vertex3; - GLboolean Map2Vertex4; - GLboolean Map2Attrib[16]; /* GL_NV_vertex_program */ - - GLboolean Normalize; - GLboolean PixelTexture; - GLboolean PointSmooth; - GLboolean PolygonOffsetPoint; - GLboolean PolygonOffsetLine; - GLboolean PolygonOffsetFill; - GLboolean PolygonSmooth; - GLboolean PolygonStipple; - GLboolean RescaleNormals; - GLboolean Scissor; - GLboolean Stencil; - GLboolean StencilTwoSide; /* GL_EXT_stencil_two_side */ - GLboolean MultisampleEnabled; /* GL_ARB_multisample */ - GLboolean SampleAlphaToCoverage; /* GL_ARB_multisample */ - GLboolean SampleAlphaToOne; /* GL_ARB_multisample */ - GLboolean SampleCoverage; /* GL_ARB_multisample */ - GLboolean SampleCoverageInvert; /* GL_ARB_multisample */ - GLboolean RasterPositionUnclipped; /* GL_IBM_rasterpos_clip */ - - GLbitfield Texture[MAX_TEXTURE_UNITS]; - GLbitfield TexGen[MAX_TEXTURE_UNITS]; - - /* GL_ARB_vertex_program / GL_NV_vertex_program */ - GLboolean VertexProgram; - GLboolean VertexProgramPointSize; - GLboolean VertexProgramTwoSide; - - /* GL_ARB_point_sprite / GL_NV_point_sprite */ - GLboolean PointSprite; - GLboolean FragmentShaderATI; -}; - - -/** - * Node for the attribute stack. - */ -struct gl_attrib_node -{ - GLbitfield kind; - void *data; - struct gl_attrib_node *next; -}; - - - -/** - * Special struct for saving/restoring texture state (GL_TEXTURE_BIT) - */ -struct texture_state -{ - struct gl_texture_attrib Texture; /**< The usual context state */ - - /** to save per texture object state (wrap modes, filters, etc): */ - struct gl_texture_object SavedObj[MAX_TEXTURE_UNITS][NUM_TEXTURE_TARGETS]; - - /** - * To save references to texture objects (so they don't get accidentally - * deleted while saved in the attribute stack). - */ - struct gl_texture_object *SavedTexRef[MAX_TEXTURE_UNITS][NUM_TEXTURE_TARGETS]; -}; - - -#if FEATURE_attrib_stack - - -/** - * Allocate new attribute node of given type/kind. Attach payload data. - * Insert it into the linked list named by 'head'. - */ -static void -save_attrib_data(struct gl_attrib_node **head, - GLbitfield kind, void *payload) -{ - struct gl_attrib_node *n = MALLOC_STRUCT(gl_attrib_node); - if (n) { - n->kind = kind; - n->data = payload; - /* insert at head */ - n->next = *head; - *head = n; - } - else { - /* out of memory! */ - } -} - - -void GLAPIENTRY -_mesa_PushAttrib(GLbitfield mask) -{ - struct gl_attrib_node *head; - - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glPushAttrib %x\n", (int) mask); - - if (ctx->AttribStackDepth >= MAX_ATTRIB_STACK_DEPTH) { - _mesa_error( ctx, GL_STACK_OVERFLOW, "glPushAttrib" ); - return; - } - - /* Build linked list of attribute nodes which save all attribute */ - /* groups specified by the mask. */ - head = NULL; - - if (mask & GL_ACCUM_BUFFER_BIT) { - struct gl_accum_attrib *attr; - attr = MALLOC_STRUCT( gl_accum_attrib ); - memcpy( attr, &ctx->Accum, sizeof(struct gl_accum_attrib) ); - save_attrib_data(&head, GL_ACCUM_BUFFER_BIT, attr); - } - - if (mask & GL_COLOR_BUFFER_BIT) { - GLuint i; - struct gl_colorbuffer_attrib *attr; - attr = MALLOC_STRUCT( gl_colorbuffer_attrib ); - memcpy( attr, &ctx->Color, sizeof(struct gl_colorbuffer_attrib) ); - /* push the Draw FBO's DrawBuffer[] state, not ctx->Color.DrawBuffer[] */ - for (i = 0; i < ctx->Const.MaxDrawBuffers; i ++) - attr->DrawBuffer[i] = ctx->DrawBuffer->ColorDrawBuffer[i]; - save_attrib_data(&head, GL_COLOR_BUFFER_BIT, attr); - } - - if (mask & GL_CURRENT_BIT) { - struct gl_current_attrib *attr; - FLUSH_CURRENT( ctx, 0 ); - attr = MALLOC_STRUCT( gl_current_attrib ); - memcpy( attr, &ctx->Current, sizeof(struct gl_current_attrib) ); - save_attrib_data(&head, GL_CURRENT_BIT, attr); - } - - if (mask & GL_DEPTH_BUFFER_BIT) { - struct gl_depthbuffer_attrib *attr; - attr = MALLOC_STRUCT( gl_depthbuffer_attrib ); - memcpy( attr, &ctx->Depth, sizeof(struct gl_depthbuffer_attrib) ); - save_attrib_data(&head, GL_DEPTH_BUFFER_BIT, attr); - } - - if (mask & GL_ENABLE_BIT) { - struct gl_enable_attrib *attr; - GLuint i; - attr = MALLOC_STRUCT( gl_enable_attrib ); - /* Copy enable flags from all other attributes into the enable struct. */ - attr->AlphaTest = ctx->Color.AlphaEnabled; - attr->AutoNormal = ctx->Eval.AutoNormal; - attr->Blend = ctx->Color.BlendEnabled; - attr->ClipPlanes = ctx->Transform.ClipPlanesEnabled; - attr->ColorMaterial = ctx->Light.ColorMaterialEnabled; - attr->CullFace = ctx->Polygon.CullFlag; - attr->DepthClamp = ctx->Transform.DepthClamp; - attr->DepthTest = ctx->Depth.Test; - attr->Dither = ctx->Color.DitherFlag; - attr->Fog = ctx->Fog.Enabled; - for (i = 0; i < ctx->Const.MaxLights; i++) { - attr->Light[i] = ctx->Light.Light[i].Enabled; - } - attr->Lighting = ctx->Light.Enabled; - attr->LineSmooth = ctx->Line.SmoothFlag; - attr->LineStipple = ctx->Line.StippleFlag; - attr->IndexLogicOp = ctx->Color.IndexLogicOpEnabled; - attr->ColorLogicOp = ctx->Color.ColorLogicOpEnabled; - attr->Map1Color4 = ctx->Eval.Map1Color4; - attr->Map1Index = ctx->Eval.Map1Index; - attr->Map1Normal = ctx->Eval.Map1Normal; - attr->Map1TextureCoord1 = ctx->Eval.Map1TextureCoord1; - attr->Map1TextureCoord2 = ctx->Eval.Map1TextureCoord2; - attr->Map1TextureCoord3 = ctx->Eval.Map1TextureCoord3; - attr->Map1TextureCoord4 = ctx->Eval.Map1TextureCoord4; - attr->Map1Vertex3 = ctx->Eval.Map1Vertex3; - attr->Map1Vertex4 = ctx->Eval.Map1Vertex4; - memcpy(attr->Map1Attrib, ctx->Eval.Map1Attrib, sizeof(ctx->Eval.Map1Attrib)); - attr->Map2Color4 = ctx->Eval.Map2Color4; - attr->Map2Index = ctx->Eval.Map2Index; - attr->Map2Normal = ctx->Eval.Map2Normal; - attr->Map2TextureCoord1 = ctx->Eval.Map2TextureCoord1; - attr->Map2TextureCoord2 = ctx->Eval.Map2TextureCoord2; - attr->Map2TextureCoord3 = ctx->Eval.Map2TextureCoord3; - attr->Map2TextureCoord4 = ctx->Eval.Map2TextureCoord4; - attr->Map2Vertex3 = ctx->Eval.Map2Vertex3; - attr->Map2Vertex4 = ctx->Eval.Map2Vertex4; - memcpy(attr->Map2Attrib, ctx->Eval.Map2Attrib, sizeof(ctx->Eval.Map2Attrib)); - attr->Normalize = ctx->Transform.Normalize; - attr->RasterPositionUnclipped = ctx->Transform.RasterPositionUnclipped; - attr->PointSmooth = ctx->Point.SmoothFlag; - attr->PointSprite = ctx->Point.PointSprite; - attr->PolygonOffsetPoint = ctx->Polygon.OffsetPoint; - attr->PolygonOffsetLine = ctx->Polygon.OffsetLine; - attr->PolygonOffsetFill = ctx->Polygon.OffsetFill; - attr->PolygonSmooth = ctx->Polygon.SmoothFlag; - attr->PolygonStipple = ctx->Polygon.StippleFlag; - attr->RescaleNormals = ctx->Transform.RescaleNormals; - attr->Scissor = ctx->Scissor.Enabled; - attr->Stencil = ctx->Stencil.Enabled; - attr->StencilTwoSide = ctx->Stencil.TestTwoSide; - attr->MultisampleEnabled = ctx->Multisample.Enabled; - attr->SampleAlphaToCoverage = ctx->Multisample.SampleAlphaToCoverage; - attr->SampleAlphaToOne = ctx->Multisample.SampleAlphaToOne; - attr->SampleCoverage = ctx->Multisample.SampleCoverage; - attr->SampleCoverageInvert = ctx->Multisample.SampleCoverageInvert; - for (i = 0; i < ctx->Const.MaxTextureUnits; i++) { - attr->Texture[i] = ctx->Texture.Unit[i].Enabled; - attr->TexGen[i] = ctx->Texture.Unit[i].TexGenEnabled; - } - /* GL_NV_vertex_program */ - attr->VertexProgram = ctx->VertexProgram.Enabled; - attr->VertexProgramPointSize = ctx->VertexProgram.PointSizeEnabled; - attr->VertexProgramTwoSide = ctx->VertexProgram.TwoSideEnabled; - save_attrib_data(&head, GL_ENABLE_BIT, attr); - } - - if (mask & GL_EVAL_BIT) { - struct gl_eval_attrib *attr; - attr = MALLOC_STRUCT( gl_eval_attrib ); - memcpy( attr, &ctx->Eval, sizeof(struct gl_eval_attrib) ); - save_attrib_data(&head, GL_EVAL_BIT, attr); - } - - if (mask & GL_FOG_BIT) { - struct gl_fog_attrib *attr; - attr = MALLOC_STRUCT( gl_fog_attrib ); - memcpy( attr, &ctx->Fog, sizeof(struct gl_fog_attrib) ); - save_attrib_data(&head, GL_FOG_BIT, attr); - } - - if (mask & GL_HINT_BIT) { - struct gl_hint_attrib *attr; - attr = MALLOC_STRUCT( gl_hint_attrib ); - memcpy( attr, &ctx->Hint, sizeof(struct gl_hint_attrib) ); - save_attrib_data(&head, GL_HINT_BIT, attr); - } - - if (mask & GL_LIGHTING_BIT) { - struct gl_light_attrib *attr; - FLUSH_CURRENT(ctx, 0); /* flush material changes */ - attr = MALLOC_STRUCT( gl_light_attrib ); - memcpy( attr, &ctx->Light, sizeof(struct gl_light_attrib) ); - save_attrib_data(&head, GL_LIGHTING_BIT, attr); - } - - if (mask & GL_LINE_BIT) { - struct gl_line_attrib *attr; - attr = MALLOC_STRUCT( gl_line_attrib ); - memcpy( attr, &ctx->Line, sizeof(struct gl_line_attrib) ); - save_attrib_data(&head, GL_LINE_BIT, attr); - } - - if (mask & GL_LIST_BIT) { - struct gl_list_attrib *attr; - attr = MALLOC_STRUCT( gl_list_attrib ); - memcpy( attr, &ctx->List, sizeof(struct gl_list_attrib) ); - save_attrib_data(&head, GL_LIST_BIT, attr); - } - - if (mask & GL_PIXEL_MODE_BIT) { - struct gl_pixel_attrib *attr; - attr = MALLOC_STRUCT( gl_pixel_attrib ); - memcpy( attr, &ctx->Pixel, sizeof(struct gl_pixel_attrib) ); - /* push the Read FBO's ReadBuffer state, not ctx->Pixel.ReadBuffer */ - attr->ReadBuffer = ctx->ReadBuffer->ColorReadBuffer; - save_attrib_data(&head, GL_PIXEL_MODE_BIT, attr); - } - - if (mask & GL_POINT_BIT) { - struct gl_point_attrib *attr; - attr = MALLOC_STRUCT( gl_point_attrib ); - memcpy( attr, &ctx->Point, sizeof(struct gl_point_attrib) ); - save_attrib_data(&head, GL_POINT_BIT, attr); - } - - if (mask & GL_POLYGON_BIT) { - struct gl_polygon_attrib *attr; - attr = MALLOC_STRUCT( gl_polygon_attrib ); - memcpy( attr, &ctx->Polygon, sizeof(struct gl_polygon_attrib) ); - save_attrib_data(&head, GL_POLYGON_BIT, attr); - } - - if (mask & GL_POLYGON_STIPPLE_BIT) { - GLuint *stipple; - stipple = (GLuint *) MALLOC( 32*sizeof(GLuint) ); - memcpy( stipple, ctx->PolygonStipple, 32*sizeof(GLuint) ); - save_attrib_data(&head, GL_POLYGON_STIPPLE_BIT, stipple); - } - - if (mask & GL_SCISSOR_BIT) { - struct gl_scissor_attrib *attr; - attr = MALLOC_STRUCT( gl_scissor_attrib ); - memcpy( attr, &ctx->Scissor, sizeof(struct gl_scissor_attrib) ); - save_attrib_data(&head, GL_SCISSOR_BIT, attr); - } - - if (mask & GL_STENCIL_BUFFER_BIT) { - struct gl_stencil_attrib *attr; - attr = MALLOC_STRUCT( gl_stencil_attrib ); - memcpy( attr, &ctx->Stencil, sizeof(struct gl_stencil_attrib) ); - save_attrib_data(&head, GL_STENCIL_BUFFER_BIT, attr); - } - - if (mask & GL_TEXTURE_BIT) { - struct texture_state *texstate = CALLOC_STRUCT(texture_state); - GLuint u, tex; - - if (!texstate) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glPushAttrib(GL_TEXTURE_BIT)"); - goto end; - } - - _mesa_lock_context_textures(ctx); - - /* copy/save the bulk of texture state here */ - memcpy(&texstate->Texture, &ctx->Texture, sizeof(ctx->Texture)); - - /* Save references to the currently bound texture objects so they don't - * accidentally get deleted while referenced in the attribute stack. - */ - for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { - for (tex = 0; tex < NUM_TEXTURE_TARGETS; tex++) { - _mesa_reference_texobj(&texstate->SavedTexRef[u][tex], - ctx->Texture.Unit[u].CurrentTex[tex]); - } - } - - /* copy state/contents of the currently bound texture objects */ - for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { - for (tex = 0; tex < NUM_TEXTURE_TARGETS; tex++) { - _mesa_copy_texture_object(&texstate->SavedObj[u][tex], - ctx->Texture.Unit[u].CurrentTex[tex]); - } - } - - _mesa_unlock_context_textures(ctx); - - save_attrib_data(&head, GL_TEXTURE_BIT, texstate); - } - - if (mask & GL_TRANSFORM_BIT) { - struct gl_transform_attrib *attr; - attr = MALLOC_STRUCT( gl_transform_attrib ); - memcpy( attr, &ctx->Transform, sizeof(struct gl_transform_attrib) ); - save_attrib_data(&head, GL_TRANSFORM_BIT, attr); - } - - if (mask & GL_VIEWPORT_BIT) { - struct gl_viewport_attrib *attr; - attr = MALLOC_STRUCT( gl_viewport_attrib ); - memcpy( attr, &ctx->Viewport, sizeof(struct gl_viewport_attrib) ); - save_attrib_data(&head, GL_VIEWPORT_BIT, attr); - } - - /* GL_ARB_multisample */ - if (mask & GL_MULTISAMPLE_BIT_ARB) { - struct gl_multisample_attrib *attr; - attr = MALLOC_STRUCT( gl_multisample_attrib ); - memcpy( attr, &ctx->Multisample, sizeof(struct gl_multisample_attrib) ); - save_attrib_data(&head, GL_MULTISAMPLE_BIT_ARB, attr); - } - -end: - ctx->AttribStack[ctx->AttribStackDepth] = head; - ctx->AttribStackDepth++; -} - - - -static void -pop_enable_group(struct gl_context *ctx, const struct gl_enable_attrib *enable) -{ - const GLuint curTexUnitSave = ctx->Texture.CurrentUnit; - GLuint i; - -#define TEST_AND_UPDATE(VALUE, NEWVALUE, ENUM) \ - if ((VALUE) != (NEWVALUE)) { \ - _mesa_set_enable( ctx, ENUM, (NEWVALUE) ); \ - } - - TEST_AND_UPDATE(ctx->Color.AlphaEnabled, enable->AlphaTest, GL_ALPHA_TEST); - if (ctx->Color.BlendEnabled != enable->Blend) { - if (ctx->Extensions.EXT_draw_buffers2) { - GLuint i; - for (i = 0; i < ctx->Const.MaxDrawBuffers; i++) { - _mesa_set_enablei(ctx, GL_BLEND, i, (enable->Blend >> i) & 1); - } - } - else { - _mesa_set_enable(ctx, GL_BLEND, (enable->Blend & 1)); - } - } - - for (i=0;iTransform.ClipPlanesEnabled & mask) != (enable->ClipPlanes & mask)) - _mesa_set_enable(ctx, (GLenum) (GL_CLIP_PLANE0 + i), - (GLboolean) ((enable->ClipPlanes & mask) ? GL_TRUE : GL_FALSE)); - } - - TEST_AND_UPDATE(ctx->Light.ColorMaterialEnabled, enable->ColorMaterial, - GL_COLOR_MATERIAL); - TEST_AND_UPDATE(ctx->Polygon.CullFlag, enable->CullFace, GL_CULL_FACE); - TEST_AND_UPDATE(ctx->Transform.DepthClamp, enable->DepthClamp, - GL_DEPTH_CLAMP); - TEST_AND_UPDATE(ctx->Depth.Test, enable->DepthTest, GL_DEPTH_TEST); - TEST_AND_UPDATE(ctx->Color.DitherFlag, enable->Dither, GL_DITHER); - TEST_AND_UPDATE(ctx->Fog.Enabled, enable->Fog, GL_FOG); - TEST_AND_UPDATE(ctx->Light.Enabled, enable->Lighting, GL_LIGHTING); - TEST_AND_UPDATE(ctx->Line.SmoothFlag, enable->LineSmooth, GL_LINE_SMOOTH); - TEST_AND_UPDATE(ctx->Line.StippleFlag, enable->LineStipple, - GL_LINE_STIPPLE); - TEST_AND_UPDATE(ctx->Color.IndexLogicOpEnabled, enable->IndexLogicOp, - GL_INDEX_LOGIC_OP); - TEST_AND_UPDATE(ctx->Color.ColorLogicOpEnabled, enable->ColorLogicOp, - GL_COLOR_LOGIC_OP); - - TEST_AND_UPDATE(ctx->Eval.Map1Color4, enable->Map1Color4, GL_MAP1_COLOR_4); - TEST_AND_UPDATE(ctx->Eval.Map1Index, enable->Map1Index, GL_MAP1_INDEX); - TEST_AND_UPDATE(ctx->Eval.Map1Normal, enable->Map1Normal, GL_MAP1_NORMAL); - TEST_AND_UPDATE(ctx->Eval.Map1TextureCoord1, enable->Map1TextureCoord1, - GL_MAP1_TEXTURE_COORD_1); - TEST_AND_UPDATE(ctx->Eval.Map1TextureCoord2, enable->Map1TextureCoord2, - GL_MAP1_TEXTURE_COORD_2); - TEST_AND_UPDATE(ctx->Eval.Map1TextureCoord3, enable->Map1TextureCoord3, - GL_MAP1_TEXTURE_COORD_3); - TEST_AND_UPDATE(ctx->Eval.Map1TextureCoord4, enable->Map1TextureCoord4, - GL_MAP1_TEXTURE_COORD_4); - TEST_AND_UPDATE(ctx->Eval.Map1Vertex3, enable->Map1Vertex3, - GL_MAP1_VERTEX_3); - TEST_AND_UPDATE(ctx->Eval.Map1Vertex4, enable->Map1Vertex4, - GL_MAP1_VERTEX_4); - for (i = 0; i < 16; i++) { - TEST_AND_UPDATE(ctx->Eval.Map1Attrib[i], enable->Map1Attrib[i], - GL_MAP1_VERTEX_ATTRIB0_4_NV + i); - } - - TEST_AND_UPDATE(ctx->Eval.Map2Color4, enable->Map2Color4, GL_MAP2_COLOR_4); - TEST_AND_UPDATE(ctx->Eval.Map2Index, enable->Map2Index, GL_MAP2_INDEX); - TEST_AND_UPDATE(ctx->Eval.Map2Normal, enable->Map2Normal, GL_MAP2_NORMAL); - TEST_AND_UPDATE(ctx->Eval.Map2TextureCoord1, enable->Map2TextureCoord1, - GL_MAP2_TEXTURE_COORD_1); - TEST_AND_UPDATE(ctx->Eval.Map2TextureCoord2, enable->Map2TextureCoord2, - GL_MAP2_TEXTURE_COORD_2); - TEST_AND_UPDATE(ctx->Eval.Map2TextureCoord3, enable->Map2TextureCoord3, - GL_MAP2_TEXTURE_COORD_3); - TEST_AND_UPDATE(ctx->Eval.Map2TextureCoord4, enable->Map2TextureCoord4, - GL_MAP2_TEXTURE_COORD_4); - TEST_AND_UPDATE(ctx->Eval.Map2Vertex3, enable->Map2Vertex3, - GL_MAP2_VERTEX_3); - TEST_AND_UPDATE(ctx->Eval.Map2Vertex4, enable->Map2Vertex4, - GL_MAP2_VERTEX_4); - for (i = 0; i < 16; i++) { - TEST_AND_UPDATE(ctx->Eval.Map2Attrib[i], enable->Map2Attrib[i], - GL_MAP2_VERTEX_ATTRIB0_4_NV + i); - } - - TEST_AND_UPDATE(ctx->Eval.AutoNormal, enable->AutoNormal, GL_AUTO_NORMAL); - TEST_AND_UPDATE(ctx->Transform.Normalize, enable->Normalize, GL_NORMALIZE); - TEST_AND_UPDATE(ctx->Transform.RescaleNormals, enable->RescaleNormals, - GL_RESCALE_NORMAL_EXT); - TEST_AND_UPDATE(ctx->Transform.RasterPositionUnclipped, - enable->RasterPositionUnclipped, - GL_RASTER_POSITION_UNCLIPPED_IBM); - TEST_AND_UPDATE(ctx->Point.SmoothFlag, enable->PointSmooth, - GL_POINT_SMOOTH); - if (ctx->Extensions.NV_point_sprite || ctx->Extensions.ARB_point_sprite) { - TEST_AND_UPDATE(ctx->Point.PointSprite, enable->PointSprite, - GL_POINT_SPRITE_NV); - } - TEST_AND_UPDATE(ctx->Polygon.OffsetPoint, enable->PolygonOffsetPoint, - GL_POLYGON_OFFSET_POINT); - TEST_AND_UPDATE(ctx->Polygon.OffsetLine, enable->PolygonOffsetLine, - GL_POLYGON_OFFSET_LINE); - TEST_AND_UPDATE(ctx->Polygon.OffsetFill, enable->PolygonOffsetFill, - GL_POLYGON_OFFSET_FILL); - TEST_AND_UPDATE(ctx->Polygon.SmoothFlag, enable->PolygonSmooth, - GL_POLYGON_SMOOTH); - TEST_AND_UPDATE(ctx->Polygon.StippleFlag, enable->PolygonStipple, - GL_POLYGON_STIPPLE); - TEST_AND_UPDATE(ctx->Scissor.Enabled, enable->Scissor, GL_SCISSOR_TEST); - TEST_AND_UPDATE(ctx->Stencil.Enabled, enable->Stencil, GL_STENCIL_TEST); - if (ctx->Extensions.EXT_stencil_two_side) { - TEST_AND_UPDATE(ctx->Stencil.TestTwoSide, enable->StencilTwoSide, GL_STENCIL_TEST_TWO_SIDE_EXT); - } - TEST_AND_UPDATE(ctx->Multisample.Enabled, enable->MultisampleEnabled, - GL_MULTISAMPLE_ARB); - TEST_AND_UPDATE(ctx->Multisample.SampleAlphaToCoverage, - enable->SampleAlphaToCoverage, - GL_SAMPLE_ALPHA_TO_COVERAGE_ARB); - TEST_AND_UPDATE(ctx->Multisample.SampleAlphaToOne, - enable->SampleAlphaToOne, - GL_SAMPLE_ALPHA_TO_ONE_ARB); - TEST_AND_UPDATE(ctx->Multisample.SampleCoverage, - enable->SampleCoverage, - GL_SAMPLE_COVERAGE_ARB); - TEST_AND_UPDATE(ctx->Multisample.SampleCoverageInvert, - enable->SampleCoverageInvert, - GL_SAMPLE_COVERAGE_INVERT_ARB); - /* GL_ARB_vertex_program, GL_NV_vertex_program */ - TEST_AND_UPDATE(ctx->VertexProgram.Enabled, - enable->VertexProgram, - GL_VERTEX_PROGRAM_ARB); - TEST_AND_UPDATE(ctx->VertexProgram.PointSizeEnabled, - enable->VertexProgramPointSize, - GL_VERTEX_PROGRAM_POINT_SIZE_ARB); - TEST_AND_UPDATE(ctx->VertexProgram.TwoSideEnabled, - enable->VertexProgramTwoSide, - GL_VERTEX_PROGRAM_TWO_SIDE_ARB); - -#undef TEST_AND_UPDATE - - /* texture unit enables */ - for (i = 0; i < ctx->Const.MaxTextureUnits; i++) { - const GLbitfield enabled = enable->Texture[i]; - const GLbitfield genEnabled = enable->TexGen[i]; - - if (ctx->Texture.Unit[i].Enabled != enabled) { - _mesa_ActiveTextureARB(GL_TEXTURE0 + i); - - _mesa_set_enable(ctx, GL_TEXTURE_1D, - (enabled & TEXTURE_1D_BIT) ? GL_TRUE : GL_FALSE); - _mesa_set_enable(ctx, GL_TEXTURE_2D, - (enabled & TEXTURE_2D_BIT) ? GL_TRUE : GL_FALSE); - _mesa_set_enable(ctx, GL_TEXTURE_3D, - (enabled & TEXTURE_3D_BIT) ? GL_TRUE : GL_FALSE); - if (ctx->Extensions.NV_texture_rectangle) { - _mesa_set_enable(ctx, GL_TEXTURE_RECTANGLE_ARB, - (enabled & TEXTURE_RECT_BIT) ? GL_TRUE : GL_FALSE); - } - if (ctx->Extensions.ARB_texture_cube_map) { - _mesa_set_enable(ctx, GL_TEXTURE_CUBE_MAP, - (enabled & TEXTURE_CUBE_BIT) ? GL_TRUE : GL_FALSE); - } - if (ctx->Extensions.MESA_texture_array) { - _mesa_set_enable(ctx, GL_TEXTURE_1D_ARRAY_EXT, - (enabled & TEXTURE_1D_ARRAY_BIT) ? GL_TRUE : GL_FALSE); - _mesa_set_enable(ctx, GL_TEXTURE_2D_ARRAY_EXT, - (enabled & TEXTURE_2D_ARRAY_BIT) ? GL_TRUE : GL_FALSE); - } - } - - if (ctx->Texture.Unit[i].TexGenEnabled != genEnabled) { - _mesa_ActiveTextureARB(GL_TEXTURE0 + i); - _mesa_set_enable(ctx, GL_TEXTURE_GEN_S, - (genEnabled & S_BIT) ? GL_TRUE : GL_FALSE); - _mesa_set_enable(ctx, GL_TEXTURE_GEN_T, - (genEnabled & T_BIT) ? GL_TRUE : GL_FALSE); - _mesa_set_enable(ctx, GL_TEXTURE_GEN_R, - (genEnabled & R_BIT) ? GL_TRUE : GL_FALSE); - _mesa_set_enable(ctx, GL_TEXTURE_GEN_Q, - (genEnabled & Q_BIT) ? GL_TRUE : GL_FALSE); - } - } - - _mesa_ActiveTextureARB(GL_TEXTURE0 + curTexUnitSave); -} - - -/** - * Pop/restore texture attribute/group state. - */ -static void -pop_texture_group(struct gl_context *ctx, struct texture_state *texstate) -{ - GLuint u; - - _mesa_lock_context_textures(ctx); - - for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { - const struct gl_texture_unit *unit = &texstate->Texture.Unit[u]; - GLuint tgt; - - _mesa_ActiveTextureARB(GL_TEXTURE0_ARB + u); - _mesa_set_enable(ctx, GL_TEXTURE_1D, - (unit->Enabled & TEXTURE_1D_BIT) ? GL_TRUE : GL_FALSE); - _mesa_set_enable(ctx, GL_TEXTURE_2D, - (unit->Enabled & TEXTURE_2D_BIT) ? GL_TRUE : GL_FALSE); - _mesa_set_enable(ctx, GL_TEXTURE_3D, - (unit->Enabled & TEXTURE_3D_BIT) ? GL_TRUE : GL_FALSE); - if (ctx->Extensions.ARB_texture_cube_map) { - _mesa_set_enable(ctx, GL_TEXTURE_CUBE_MAP_ARB, - (unit->Enabled & TEXTURE_CUBE_BIT) ? GL_TRUE : GL_FALSE); - } - if (ctx->Extensions.NV_texture_rectangle) { - _mesa_set_enable(ctx, GL_TEXTURE_RECTANGLE_NV, - (unit->Enabled & TEXTURE_RECT_BIT) ? GL_TRUE : GL_FALSE); - } - if (ctx->Extensions.MESA_texture_array) { - _mesa_set_enable(ctx, GL_TEXTURE_1D_ARRAY_EXT, - (unit->Enabled & TEXTURE_1D_ARRAY_BIT) ? GL_TRUE : GL_FALSE); - _mesa_set_enable(ctx, GL_TEXTURE_2D_ARRAY_EXT, - (unit->Enabled & TEXTURE_2D_ARRAY_BIT) ? GL_TRUE : GL_FALSE); - } - - _mesa_TexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, unit->EnvMode); - _mesa_TexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, unit->EnvColor); - _mesa_TexGeni(GL_S, GL_TEXTURE_GEN_MODE, unit->GenS.Mode); - _mesa_TexGeni(GL_T, GL_TEXTURE_GEN_MODE, unit->GenT.Mode); - _mesa_TexGeni(GL_R, GL_TEXTURE_GEN_MODE, unit->GenR.Mode); - _mesa_TexGeni(GL_Q, GL_TEXTURE_GEN_MODE, unit->GenQ.Mode); - _mesa_TexGenfv(GL_S, GL_OBJECT_PLANE, unit->GenS.ObjectPlane); - _mesa_TexGenfv(GL_T, GL_OBJECT_PLANE, unit->GenT.ObjectPlane); - _mesa_TexGenfv(GL_R, GL_OBJECT_PLANE, unit->GenR.ObjectPlane); - _mesa_TexGenfv(GL_Q, GL_OBJECT_PLANE, unit->GenQ.ObjectPlane); - /* Eye plane done differently to avoid re-transformation */ - { - struct gl_texture_unit *destUnit = &ctx->Texture.Unit[u]; - COPY_4FV(destUnit->GenS.EyePlane, unit->GenS.EyePlane); - COPY_4FV(destUnit->GenT.EyePlane, unit->GenT.EyePlane); - COPY_4FV(destUnit->GenR.EyePlane, unit->GenR.EyePlane); - COPY_4FV(destUnit->GenQ.EyePlane, unit->GenQ.EyePlane); - if (ctx->Driver.TexGen) { - ctx->Driver.TexGen(ctx, GL_S, GL_EYE_PLANE, unit->GenS.EyePlane); - ctx->Driver.TexGen(ctx, GL_T, GL_EYE_PLANE, unit->GenT.EyePlane); - ctx->Driver.TexGen(ctx, GL_R, GL_EYE_PLANE, unit->GenR.EyePlane); - ctx->Driver.TexGen(ctx, GL_Q, GL_EYE_PLANE, unit->GenQ.EyePlane); - } - } - _mesa_set_enable(ctx, GL_TEXTURE_GEN_S, - ((unit->TexGenEnabled & S_BIT) ? GL_TRUE : GL_FALSE)); - _mesa_set_enable(ctx, GL_TEXTURE_GEN_T, - ((unit->TexGenEnabled & T_BIT) ? GL_TRUE : GL_FALSE)); - _mesa_set_enable(ctx, GL_TEXTURE_GEN_R, - ((unit->TexGenEnabled & R_BIT) ? GL_TRUE : GL_FALSE)); - _mesa_set_enable(ctx, GL_TEXTURE_GEN_Q, - ((unit->TexGenEnabled & Q_BIT) ? GL_TRUE : GL_FALSE)); - if (ctx->Extensions.EXT_texture_lod_bias) { - _mesa_TexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT, - GL_TEXTURE_LOD_BIAS_EXT, unit->LodBias); - } - if (ctx->Extensions.EXT_texture_env_combine || - ctx->Extensions.ARB_texture_env_combine) { - _mesa_TexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, - unit->Combine.ModeRGB); - _mesa_TexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, - unit->Combine.ModeA); - _mesa_TexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, - unit->Combine.SourceRGB[0]); - _mesa_TexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, - unit->Combine.SourceRGB[1]); - _mesa_TexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB, - unit->Combine.SourceRGB[2]); - _mesa_TexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, - unit->Combine.SourceA[0]); - _mesa_TexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA, - unit->Combine.SourceA[1]); - _mesa_TexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_ALPHA, - unit->Combine.SourceA[2]); - _mesa_TexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, - unit->Combine.OperandRGB[0]); - _mesa_TexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, - unit->Combine.OperandRGB[1]); - _mesa_TexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB, - unit->Combine.OperandRGB[2]); - _mesa_TexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, - unit->Combine.OperandA[0]); - _mesa_TexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, - unit->Combine.OperandA[1]); - _mesa_TexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_ALPHA, - unit->Combine.OperandA[2]); - _mesa_TexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE, - 1 << unit->Combine.ScaleShiftRGB); - _mesa_TexEnvi(GL_TEXTURE_ENV, GL_ALPHA_SCALE, - 1 << unit->Combine.ScaleShiftA); - } - - /* Restore texture object state for each target */ - for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++) { - const struct gl_texture_object *obj = NULL; - const struct gl_sampler_object *samp; - GLenum target; - - obj = &texstate->SavedObj[u][tgt]; - - /* don't restore state for unsupported targets to prevent - * raising GL errors. - */ - if (obj->Target == GL_TEXTURE_CUBE_MAP_ARB && - !ctx->Extensions.ARB_texture_cube_map) { - continue; - } - else if (obj->Target == GL_TEXTURE_RECTANGLE_NV && - !ctx->Extensions.NV_texture_rectangle) { - continue; - } - else if ((obj->Target == GL_TEXTURE_1D_ARRAY_EXT || - obj->Target == GL_TEXTURE_2D_ARRAY_EXT) && - !ctx->Extensions.MESA_texture_array) { - continue; - } - else if (obj->Target == GL_TEXTURE_BUFFER) - continue; - - target = obj->Target; - - _mesa_BindTexture(target, obj->Name); - - samp = &obj->Sampler; - - _mesa_TexParameterfv(target, GL_TEXTURE_BORDER_COLOR, samp->BorderColor.f); - _mesa_TexParameteri(target, GL_TEXTURE_WRAP_S, samp->WrapS); - _mesa_TexParameteri(target, GL_TEXTURE_WRAP_T, samp->WrapT); - _mesa_TexParameteri(target, GL_TEXTURE_WRAP_R, samp->WrapR); - _mesa_TexParameteri(target, GL_TEXTURE_MIN_FILTER, samp->MinFilter); - _mesa_TexParameteri(target, GL_TEXTURE_MAG_FILTER, samp->MagFilter); - _mesa_TexParameterf(target, GL_TEXTURE_MIN_LOD, samp->MinLod); - _mesa_TexParameterf(target, GL_TEXTURE_MAX_LOD, samp->MaxLod); - _mesa_TexParameterf(target, GL_TEXTURE_LOD_BIAS, samp->LodBias); - _mesa_TexParameterf(target, GL_TEXTURE_PRIORITY, obj->Priority); - _mesa_TexParameteri(target, GL_TEXTURE_BASE_LEVEL, obj->BaseLevel); - if (target != GL_TEXTURE_RECTANGLE_ARB) - _mesa_TexParameteri(target, GL_TEXTURE_MAX_LEVEL, obj->MaxLevel); - if (ctx->Extensions.EXT_texture_filter_anisotropic) { - _mesa_TexParameterf(target, GL_TEXTURE_MAX_ANISOTROPY_EXT, - samp->MaxAnisotropy); - } - if (ctx->Extensions.ARB_shadow_ambient) { - _mesa_TexParameterf(target, GL_TEXTURE_COMPARE_FAIL_VALUE_ARB, - samp->CompareFailValue); - } - } - - /* remove saved references to the texture objects */ - for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++) { - _mesa_reference_texobj(&texstate->SavedTexRef[u][tgt], NULL); - } - } - - _mesa_ActiveTextureARB(GL_TEXTURE0_ARB + texstate->Texture.CurrentUnit); - - _mesa_unlock_context_textures(ctx); -} - - -/* - * This function is kind of long just because we have to call a lot - * of device driver functions to update device driver state. - * - * XXX As it is now, most of the pop-code calls immediate-mode Mesa functions - * in order to restore GL state. This isn't terribly efficient but it - * ensures that dirty flags and any derived state gets updated correctly. - * We could at least check if the value to restore equals the current value - * and then skip the Mesa call. - */ -void GLAPIENTRY -_mesa_PopAttrib(void) -{ - struct gl_attrib_node *attr, *next; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (ctx->AttribStackDepth == 0) { - _mesa_error( ctx, GL_STACK_UNDERFLOW, "glPopAttrib" ); - return; - } - - ctx->AttribStackDepth--; - attr = ctx->AttribStack[ctx->AttribStackDepth]; - - while (attr) { - - if (MESA_VERBOSE & VERBOSE_API) { - _mesa_debug(ctx, "glPopAttrib %s\n", - _mesa_lookup_enum_by_nr(attr->kind)); - } - - switch (attr->kind) { - case GL_ACCUM_BUFFER_BIT: - { - const struct gl_accum_attrib *accum; - accum = (const struct gl_accum_attrib *) attr->data; - _mesa_ClearAccum(accum->ClearColor[0], - accum->ClearColor[1], - accum->ClearColor[2], - accum->ClearColor[3]); - } - break; - case GL_COLOR_BUFFER_BIT: - { - const struct gl_colorbuffer_attrib *color; - - color = (const struct gl_colorbuffer_attrib *) attr->data; - _mesa_ClearIndex((GLfloat) color->ClearIndex); - _mesa_ClearColor(color->ClearColorUnclamped[0], - color->ClearColorUnclamped[1], - color->ClearColorUnclamped[2], - color->ClearColorUnclamped[3]); - _mesa_IndexMask(color->IndexMask); - if (!ctx->Extensions.EXT_draw_buffers2) { - _mesa_ColorMask((GLboolean) (color->ColorMask[0][0] != 0), - (GLboolean) (color->ColorMask[0][1] != 0), - (GLboolean) (color->ColorMask[0][2] != 0), - (GLboolean) (color->ColorMask[0][3] != 0)); - } - else { - GLuint i; - for (i = 0; i < ctx->Const.MaxDrawBuffers; i++) { - _mesa_ColorMaskIndexed(i, - (GLboolean) (color->ColorMask[i][0] != 0), - (GLboolean) (color->ColorMask[i][1] != 0), - (GLboolean) (color->ColorMask[i][2] != 0), - (GLboolean) (color->ColorMask[i][3] != 0)); - } - } - { - /* Need to determine if more than one color output is - * specified. If so, call glDrawBuffersARB, else call - * glDrawBuffer(). This is a subtle, but essential point - * since GL_FRONT (for example) is illegal for the former - * function, but legal for the later. - */ - GLboolean multipleBuffers = GL_FALSE; - GLuint i; - - for (i = 1; i < ctx->Const.MaxDrawBuffers; i++) { - if (color->DrawBuffer[i] != GL_NONE) { - multipleBuffers = GL_TRUE; - break; - } - } - /* Call the API_level functions, not _mesa_drawbuffers() - * since we need to do error checking on the pop'd - * GL_DRAW_BUFFER. - * Ex: if GL_FRONT were pushed, but we're popping with a - * user FBO bound, GL_FRONT will be illegal and we'll need - * to record that error. Per OpenGL ARB decision. - */ - if (multipleBuffers) - _mesa_DrawBuffersARB(ctx->Const.MaxDrawBuffers, - color->DrawBuffer); - else - _mesa_DrawBuffer(color->DrawBuffer[0]); - } - _mesa_set_enable(ctx, GL_ALPHA_TEST, color->AlphaEnabled); - _mesa_AlphaFunc(color->AlphaFunc, color->AlphaRefUnclamped); - if (ctx->Color.BlendEnabled != color->BlendEnabled) { - if (ctx->Extensions.EXT_draw_buffers2) { - GLuint i; - for (i = 0; i < ctx->Const.MaxDrawBuffers; i++) { - _mesa_set_enablei(ctx, GL_BLEND, i, - (color->BlendEnabled >> i) & 1); - } - } - else { - _mesa_set_enable(ctx, GL_BLEND, (color->BlendEnabled & 1)); - } - } - if (ctx->Color._BlendFuncPerBuffer || - ctx->Color._BlendEquationPerBuffer) { - /* set blend per buffer */ - GLuint buf; - for (buf = 0; buf < ctx->Const.MaxDrawBuffers; buf++) { - _mesa_BlendFuncSeparatei(buf, color->Blend[buf].SrcRGB, - color->Blend[buf].DstRGB, - color->Blend[buf].SrcA, - color->Blend[buf].DstA); - _mesa_BlendEquationSeparatei(buf, - color->Blend[buf].EquationRGB, - color->Blend[buf].EquationA); - } - } - else { - /* set same blend modes for all buffers */ - _mesa_BlendFuncSeparateEXT(color->Blend[0].SrcRGB, - color->Blend[0].DstRGB, - color->Blend[0].SrcA, - color->Blend[0].DstA); - /* This special case is because glBlendEquationSeparateEXT - * cannot take GL_LOGIC_OP as a parameter. - */ - if (color->Blend[0].EquationRGB == - color->Blend[0].EquationA) { - _mesa_BlendEquation(color->Blend[0].EquationRGB); - } - else { - _mesa_BlendEquationSeparateEXT( - color->Blend[0].EquationRGB, - color->Blend[0].EquationA); - } - } - _mesa_BlendColor(color->BlendColorUnclamped[0], - color->BlendColorUnclamped[1], - color->BlendColorUnclamped[2], - color->BlendColorUnclamped[3]); - _mesa_LogicOp(color->LogicOp); - _mesa_set_enable(ctx, GL_COLOR_LOGIC_OP, - color->ColorLogicOpEnabled); - _mesa_set_enable(ctx, GL_INDEX_LOGIC_OP, - color->IndexLogicOpEnabled); - _mesa_set_enable(ctx, GL_DITHER, color->DitherFlag); - _mesa_ClampColorARB(GL_CLAMP_FRAGMENT_COLOR_ARB, color->ClampFragmentColor); - _mesa_ClampColorARB(GL_CLAMP_READ_COLOR_ARB, color->ClampReadColor); - } - break; - case GL_CURRENT_BIT: - FLUSH_CURRENT( ctx, 0 ); - memcpy( &ctx->Current, attr->data, - sizeof(struct gl_current_attrib) ); - break; - case GL_DEPTH_BUFFER_BIT: - { - const struct gl_depthbuffer_attrib *depth; - depth = (const struct gl_depthbuffer_attrib *) attr->data; - _mesa_DepthFunc(depth->Func); - _mesa_ClearDepth(depth->Clear); - _mesa_set_enable(ctx, GL_DEPTH_TEST, depth->Test); - _mesa_DepthMask(depth->Mask); - } - break; - case GL_ENABLE_BIT: - { - const struct gl_enable_attrib *enable; - enable = (const struct gl_enable_attrib *) attr->data; - pop_enable_group(ctx, enable); - ctx->NewState |= _NEW_ALL; - } - break; - case GL_EVAL_BIT: - memcpy( &ctx->Eval, attr->data, sizeof(struct gl_eval_attrib) ); - ctx->NewState |= _NEW_EVAL; - break; - case GL_FOG_BIT: - { - const struct gl_fog_attrib *fog; - fog = (const struct gl_fog_attrib *) attr->data; - _mesa_set_enable(ctx, GL_FOG, fog->Enabled); - _mesa_Fogfv(GL_FOG_COLOR, fog->Color); - _mesa_Fogf(GL_FOG_DENSITY, fog->Density); - _mesa_Fogf(GL_FOG_START, fog->Start); - _mesa_Fogf(GL_FOG_END, fog->End); - _mesa_Fogf(GL_FOG_INDEX, fog->Index); - _mesa_Fogi(GL_FOG_MODE, fog->Mode); - } - break; - case GL_HINT_BIT: - { - const struct gl_hint_attrib *hint; - hint = (const struct gl_hint_attrib *) attr->data; - _mesa_Hint(GL_PERSPECTIVE_CORRECTION_HINT, - hint->PerspectiveCorrection ); - _mesa_Hint(GL_POINT_SMOOTH_HINT, hint->PointSmooth); - _mesa_Hint(GL_LINE_SMOOTH_HINT, hint->LineSmooth); - _mesa_Hint(GL_POLYGON_SMOOTH_HINT, hint->PolygonSmooth); - _mesa_Hint(GL_FOG_HINT, hint->Fog); - _mesa_Hint(GL_CLIP_VOLUME_CLIPPING_HINT_EXT, - hint->ClipVolumeClipping); - _mesa_Hint(GL_TEXTURE_COMPRESSION_HINT_ARB, - hint->TextureCompression); - } - break; - case GL_LIGHTING_BIT: - { - GLuint i; - const struct gl_light_attrib *light; - light = (const struct gl_light_attrib *) attr->data; - /* lighting enable */ - _mesa_set_enable(ctx, GL_LIGHTING, light->Enabled); - /* per-light state */ - if (_math_matrix_is_dirty(ctx->ModelviewMatrixStack.Top)) - _math_matrix_analyse( ctx->ModelviewMatrixStack.Top ); - - for (i = 0; i < ctx->Const.MaxLights; i++) { - const struct gl_light *l = &light->Light[i]; - _mesa_set_enable(ctx, GL_LIGHT0 + i, l->Enabled); - _mesa_light(ctx, i, GL_AMBIENT, l->Ambient); - _mesa_light(ctx, i, GL_DIFFUSE, l->Diffuse); - _mesa_light(ctx, i, GL_SPECULAR, l->Specular ); - _mesa_light(ctx, i, GL_POSITION, l->EyePosition); - _mesa_light(ctx, i, GL_SPOT_DIRECTION, l->SpotDirection); - { - GLfloat p[4] = { 0 }; - p[0] = l->SpotExponent; - _mesa_light(ctx, i, GL_SPOT_EXPONENT, p); - } - { - GLfloat p[4] = { 0 }; - p[0] = l->SpotCutoff; - _mesa_light(ctx, i, GL_SPOT_CUTOFF, p); - } - { - GLfloat p[4] = { 0 }; - p[0] = l->ConstantAttenuation; - _mesa_light(ctx, i, GL_CONSTANT_ATTENUATION, p); - } - { - GLfloat p[4] = { 0 }; - p[0] = l->LinearAttenuation; - _mesa_light(ctx, i, GL_LINEAR_ATTENUATION, p); - } - { - GLfloat p[4] = { 0 }; - p[0] = l->QuadraticAttenuation; - _mesa_light(ctx, i, GL_QUADRATIC_ATTENUATION, p); - } - } - /* light model */ - _mesa_LightModelfv(GL_LIGHT_MODEL_AMBIENT, - light->Model.Ambient); - _mesa_LightModelf(GL_LIGHT_MODEL_LOCAL_VIEWER, - (GLfloat) light->Model.LocalViewer); - _mesa_LightModelf(GL_LIGHT_MODEL_TWO_SIDE, - (GLfloat) light->Model.TwoSide); - _mesa_LightModelf(GL_LIGHT_MODEL_COLOR_CONTROL, - (GLfloat) light->Model.ColorControl); - /* shade model */ - _mesa_ShadeModel(light->ShadeModel); - /* color material */ - _mesa_ColorMaterial(light->ColorMaterialFace, - light->ColorMaterialMode); - _mesa_set_enable(ctx, GL_COLOR_MATERIAL, - light->ColorMaterialEnabled); - /* materials */ - memcpy(&ctx->Light.Material, &light->Material, - sizeof(struct gl_material)); - _mesa_ClampColorARB(GL_CLAMP_VERTEX_COLOR_ARB, light->ClampVertexColor); - } - break; - case GL_LINE_BIT: - { - const struct gl_line_attrib *line; - line = (const struct gl_line_attrib *) attr->data; - _mesa_set_enable(ctx, GL_LINE_SMOOTH, line->SmoothFlag); - _mesa_set_enable(ctx, GL_LINE_STIPPLE, line->StippleFlag); - _mesa_LineStipple(line->StippleFactor, line->StipplePattern); - _mesa_LineWidth(line->Width); - } - break; - case GL_LIST_BIT: - memcpy( &ctx->List, attr->data, sizeof(struct gl_list_attrib) ); - break; - case GL_PIXEL_MODE_BIT: - memcpy( &ctx->Pixel, attr->data, sizeof(struct gl_pixel_attrib) ); - /* XXX what other pixel state needs to be set by function calls? */ - _mesa_ReadBuffer(ctx->Pixel.ReadBuffer); - ctx->NewState |= _NEW_PIXEL; - break; - case GL_POINT_BIT: - { - const struct gl_point_attrib *point; - point = (const struct gl_point_attrib *) attr->data; - _mesa_PointSize(point->Size); - _mesa_set_enable(ctx, GL_POINT_SMOOTH, point->SmoothFlag); - if (ctx->Extensions.EXT_point_parameters) { - _mesa_PointParameterfv(GL_DISTANCE_ATTENUATION_EXT, - point->Params); - _mesa_PointParameterf(GL_POINT_SIZE_MIN_EXT, - point->MinSize); - _mesa_PointParameterf(GL_POINT_SIZE_MAX_EXT, - point->MaxSize); - _mesa_PointParameterf(GL_POINT_FADE_THRESHOLD_SIZE_EXT, - point->Threshold); - } - if (ctx->Extensions.NV_point_sprite - || ctx->Extensions.ARB_point_sprite) { - GLuint u; - for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { - _mesa_TexEnvi(GL_POINT_SPRITE_NV, GL_COORD_REPLACE_NV, - (GLint) point->CoordReplace[u]); - } - _mesa_set_enable(ctx, GL_POINT_SPRITE_NV,point->PointSprite); - if (ctx->Extensions.NV_point_sprite) - _mesa_PointParameteri(GL_POINT_SPRITE_R_MODE_NV, - ctx->Point.SpriteRMode); - _mesa_PointParameterf(GL_POINT_SPRITE_COORD_ORIGIN, - (GLfloat)ctx->Point.SpriteOrigin); - } - } - break; - case GL_POLYGON_BIT: - { - const struct gl_polygon_attrib *polygon; - polygon = (const struct gl_polygon_attrib *) attr->data; - _mesa_CullFace(polygon->CullFaceMode); - _mesa_FrontFace(polygon->FrontFace); - _mesa_PolygonMode(GL_FRONT, polygon->FrontMode); - _mesa_PolygonMode(GL_BACK, polygon->BackMode); - _mesa_PolygonOffset(polygon->OffsetFactor, - polygon->OffsetUnits); - _mesa_set_enable(ctx, GL_POLYGON_SMOOTH, polygon->SmoothFlag); - _mesa_set_enable(ctx, GL_POLYGON_STIPPLE, polygon->StippleFlag); - _mesa_set_enable(ctx, GL_CULL_FACE, polygon->CullFlag); - _mesa_set_enable(ctx, GL_POLYGON_OFFSET_POINT, - polygon->OffsetPoint); - _mesa_set_enable(ctx, GL_POLYGON_OFFSET_LINE, - polygon->OffsetLine); - _mesa_set_enable(ctx, GL_POLYGON_OFFSET_FILL, - polygon->OffsetFill); - } - break; - case GL_POLYGON_STIPPLE_BIT: - memcpy( ctx->PolygonStipple, attr->data, 32*sizeof(GLuint) ); - ctx->NewState |= _NEW_POLYGONSTIPPLE; - if (ctx->Driver.PolygonStipple) - ctx->Driver.PolygonStipple( ctx, (const GLubyte *) attr->data ); - break; - case GL_SCISSOR_BIT: - { - const struct gl_scissor_attrib *scissor; - scissor = (const struct gl_scissor_attrib *) attr->data; - _mesa_Scissor(scissor->X, scissor->Y, - scissor->Width, scissor->Height); - _mesa_set_enable(ctx, GL_SCISSOR_TEST, scissor->Enabled); - } - break; - case GL_STENCIL_BUFFER_BIT: - { - const struct gl_stencil_attrib *stencil; - stencil = (const struct gl_stencil_attrib *) attr->data; - _mesa_set_enable(ctx, GL_STENCIL_TEST, stencil->Enabled); - _mesa_ClearStencil(stencil->Clear); - if (ctx->Extensions.EXT_stencil_two_side) { - _mesa_set_enable(ctx, GL_STENCIL_TEST_TWO_SIDE_EXT, - stencil->TestTwoSide); - _mesa_ActiveStencilFaceEXT(stencil->ActiveFace - ? GL_BACK : GL_FRONT); - } - /* front state */ - _mesa_StencilFuncSeparate(GL_FRONT, - stencil->Function[0], - stencil->Ref[0], - stencil->ValueMask[0]); - _mesa_StencilMaskSeparate(GL_FRONT, stencil->WriteMask[0]); - _mesa_StencilOpSeparate(GL_FRONT, stencil->FailFunc[0], - stencil->ZFailFunc[0], - stencil->ZPassFunc[0]); - /* back state */ - _mesa_StencilFuncSeparate(GL_BACK, - stencil->Function[1], - stencil->Ref[1], - stencil->ValueMask[1]); - _mesa_StencilMaskSeparate(GL_BACK, stencil->WriteMask[1]); - _mesa_StencilOpSeparate(GL_BACK, stencil->FailFunc[1], - stencil->ZFailFunc[1], - stencil->ZPassFunc[1]); - } - break; - case GL_TRANSFORM_BIT: - { - GLuint i; - const struct gl_transform_attrib *xform; - xform = (const struct gl_transform_attrib *) attr->data; - _mesa_MatrixMode(xform->MatrixMode); - if (_math_matrix_is_dirty(ctx->ProjectionMatrixStack.Top)) - _math_matrix_analyse( ctx->ProjectionMatrixStack.Top ); - - /* restore clip planes */ - for (i = 0; i < MAX_CLIP_PLANES; i++) { - const GLuint mask = 1 << i; - const GLfloat *eyePlane = xform->EyeUserPlane[i]; - COPY_4V(ctx->Transform.EyeUserPlane[i], eyePlane); - if (xform->ClipPlanesEnabled & mask) { - _mesa_set_enable(ctx, GL_CLIP_PLANE0 + i, GL_TRUE); - } - else { - _mesa_set_enable(ctx, GL_CLIP_PLANE0 + i, GL_FALSE); - } - if (ctx->Driver.ClipPlane) - ctx->Driver.ClipPlane( ctx, GL_CLIP_PLANE0 + i, eyePlane ); - } - - /* normalize/rescale */ - if (xform->Normalize != ctx->Transform.Normalize) - _mesa_set_enable(ctx, GL_NORMALIZE,ctx->Transform.Normalize); - if (xform->RescaleNormals != ctx->Transform.RescaleNormals) - _mesa_set_enable(ctx, GL_RESCALE_NORMAL_EXT, - ctx->Transform.RescaleNormals); - if (xform->DepthClamp != ctx->Transform.DepthClamp) - _mesa_set_enable(ctx, GL_DEPTH_CLAMP, - ctx->Transform.DepthClamp); - } - break; - case GL_TEXTURE_BIT: - /* Take care of texture object reference counters */ - { - struct texture_state *texstate - = (struct texture_state *) attr->data; - pop_texture_group(ctx, texstate); - ctx->NewState |= _NEW_TEXTURE; - } - break; - case GL_VIEWPORT_BIT: - { - const struct gl_viewport_attrib *vp; - vp = (const struct gl_viewport_attrib *) attr->data; - _mesa_Viewport(vp->X, vp->Y, vp->Width, vp->Height); - _mesa_DepthRange(vp->Near, vp->Far); - } - break; - case GL_MULTISAMPLE_BIT_ARB: - { - const struct gl_multisample_attrib *ms; - ms = (const struct gl_multisample_attrib *) attr->data; - _mesa_SampleCoverageARB(ms->SampleCoverageValue, - ms->SampleCoverageInvert); - } - break; - - default: - _mesa_problem( ctx, "Bad attrib flag in PopAttrib"); - break; - } - - next = attr->next; - FREE( attr->data ); - FREE( attr ); - attr = next; - } -} - - -/** - * Helper for incrementing/decrementing vertex buffer object reference - * counts when pushing/popping the GL_CLIENT_VERTEX_ARRAY_BIT attribute group. - */ -static void -adjust_buffer_object_ref_counts(struct gl_array_object *arrayObj, GLint step) -{ - GLuint i; - - arrayObj->Vertex.BufferObj->RefCount += step; - arrayObj->Weight.BufferObj->RefCount += step; - arrayObj->Normal.BufferObj->RefCount += step; - arrayObj->Color.BufferObj->RefCount += step; - arrayObj->SecondaryColor.BufferObj->RefCount += step; - arrayObj->FogCoord.BufferObj->RefCount += step; - arrayObj->Index.BufferObj->RefCount += step; - arrayObj->EdgeFlag.BufferObj->RefCount += step; - for (i = 0; i < Elements(arrayObj->TexCoord); i++) - arrayObj->TexCoord[i].BufferObj->RefCount += step; - for (i = 0; i < Elements(arrayObj->VertexAttrib); i++) - arrayObj->VertexAttrib[i].BufferObj->RefCount += step; -} - - -/** - * Copy gl_pixelstore_attrib from src to dst, updating buffer - * object refcounts. - */ -static void -copy_pixelstore(struct gl_context *ctx, - struct gl_pixelstore_attrib *dst, - const struct gl_pixelstore_attrib *src) -{ - dst->Alignment = src->Alignment; - dst->RowLength = src->RowLength; - dst->SkipPixels = src->SkipPixels; - dst->SkipRows = src->SkipRows; - dst->ImageHeight = src->ImageHeight; - dst->SkipImages = src->SkipImages; - dst->SwapBytes = src->SwapBytes; - dst->LsbFirst = src->LsbFirst; - dst->ClientStorage = src->ClientStorage; - dst->Invert = src->Invert; - _mesa_reference_buffer_object(ctx, &dst->BufferObj, src->BufferObj); -} - - -#define GL_CLIENT_PACK_BIT (1<<20) -#define GL_CLIENT_UNPACK_BIT (1<<21) - - -void GLAPIENTRY -_mesa_PushClientAttrib(GLbitfield mask) -{ - struct gl_attrib_node *head; - - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (ctx->ClientAttribStackDepth >= MAX_CLIENT_ATTRIB_STACK_DEPTH) { - _mesa_error( ctx, GL_STACK_OVERFLOW, "glPushClientAttrib" ); - return; - } - - /* Build linked list of attribute nodes which save all attribute - * groups specified by the mask. - */ - head = NULL; - - if (mask & GL_CLIENT_PIXEL_STORE_BIT) { - struct gl_pixelstore_attrib *attr; - /* packing attribs */ - attr = CALLOC_STRUCT( gl_pixelstore_attrib ); - copy_pixelstore(ctx, attr, &ctx->Pack); - save_attrib_data(&head, GL_CLIENT_PACK_BIT, attr); - /* unpacking attribs */ - attr = CALLOC_STRUCT( gl_pixelstore_attrib ); - copy_pixelstore(ctx, attr, &ctx->Unpack); - save_attrib_data(&head, GL_CLIENT_UNPACK_BIT, attr); - } - - if (mask & GL_CLIENT_VERTEX_ARRAY_BIT) { - struct gl_array_attrib *attr; - struct gl_array_object *obj; - - attr = MALLOC_STRUCT( gl_array_attrib ); - obj = MALLOC_STRUCT( gl_array_object ); - -#if FEATURE_ARB_vertex_buffer_object - /* increment ref counts since we're copying pointers to these objects */ - ctx->Array.ArrayBufferObj->RefCount++; - ctx->Array.ElementArrayBufferObj->RefCount++; -#endif - - memcpy( attr, &ctx->Array, sizeof(struct gl_array_attrib) ); - memcpy( obj, ctx->Array.ArrayObj, sizeof(struct gl_array_object) ); - - attr->ArrayObj = obj; - - save_attrib_data(&head, GL_CLIENT_VERTEX_ARRAY_BIT, attr); - - /* bump reference counts on buffer objects */ - adjust_buffer_object_ref_counts(ctx->Array.ArrayObj, 1); - } - - ctx->ClientAttribStack[ctx->ClientAttribStackDepth] = head; - ctx->ClientAttribStackDepth++; -} - - - - -void GLAPIENTRY -_mesa_PopClientAttrib(void) -{ - struct gl_attrib_node *node, *next; - - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (ctx->ClientAttribStackDepth == 0) { - _mesa_error( ctx, GL_STACK_UNDERFLOW, "glPopClientAttrib" ); - return; - } - - ctx->ClientAttribStackDepth--; - node = ctx->ClientAttribStack[ctx->ClientAttribStackDepth]; - - while (node) { - switch (node->kind) { - case GL_CLIENT_PACK_BIT: - { - struct gl_pixelstore_attrib *store = - (struct gl_pixelstore_attrib *) node->data; - copy_pixelstore(ctx, &ctx->Pack, store); - _mesa_reference_buffer_object(ctx, &store->BufferObj, NULL); - } - ctx->NewState |= _NEW_PACKUNPACK; - break; - case GL_CLIENT_UNPACK_BIT: - { - struct gl_pixelstore_attrib *store = - (struct gl_pixelstore_attrib *) node->data; - copy_pixelstore(ctx, &ctx->Unpack, store); - _mesa_reference_buffer_object(ctx, &store->BufferObj, NULL); - } - ctx->NewState |= _NEW_PACKUNPACK; - break; - case GL_CLIENT_VERTEX_ARRAY_BIT: { - struct gl_array_attrib * data = - (struct gl_array_attrib *) node->data; - - adjust_buffer_object_ref_counts(ctx->Array.ArrayObj, -1); - - ctx->Array.ActiveTexture = data->ActiveTexture; - if (data->LockCount != 0) - _mesa_LockArraysEXT(data->LockFirst, data->LockCount); - else if (ctx->Array.LockCount) - _mesa_UnlockArraysEXT(); - - _mesa_BindVertexArrayAPPLE( data->ArrayObj->Name ); - -#if FEATURE_ARB_vertex_buffer_object - _mesa_BindBufferARB(GL_ARRAY_BUFFER_ARB, - data->ArrayBufferObj->Name); - _mesa_BindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, - data->ElementArrayBufferObj->Name); -#endif - - memcpy( ctx->Array.ArrayObj, data->ArrayObj, - sizeof( struct gl_array_object ) ); - - FREE( data->ArrayObj ); - - /* FIXME: Should some bits in ctx->Array->NewState also be set - * FIXME: here? It seems like it should be set to inclusive-or - * FIXME: of the old ArrayObj->_Enabled and the new _Enabled. - */ - - ctx->NewState |= _NEW_ARRAY; - break; - } - default: - _mesa_problem( ctx, "Bad attrib flag in PopClientAttrib"); - break; - } - - next = node->next; - FREE( node->data ); - FREE( node ); - node = next; - } -} - - -void -_mesa_init_attrib_dispatch(struct _glapi_table *disp) -{ - SET_PopAttrib(disp, _mesa_PopAttrib); - SET_PushAttrib(disp, _mesa_PushAttrib); - SET_PopClientAttrib(disp, _mesa_PopClientAttrib); - SET_PushClientAttrib(disp, _mesa_PushClientAttrib); -} - - -#endif /* FEATURE_attrib_stack */ - - -/** - * Free any attribute state data that might be attached to the context. - */ -void -_mesa_free_attrib_data(struct gl_context *ctx) -{ - while (ctx->AttribStackDepth > 0) { - struct gl_attrib_node *attr, *next; - - ctx->AttribStackDepth--; - attr = ctx->AttribStack[ctx->AttribStackDepth]; - - while (attr) { - if (attr->kind == GL_TEXTURE_BIT) { - struct texture_state *texstate = (struct texture_state*)attr->data; - GLuint u, tgt; - /* clear references to the saved texture objects */ - for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { - for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++) { - _mesa_reference_texobj(&texstate->SavedTexRef[u][tgt], NULL); - } - } - } - else { - /* any other chunks of state that requires special handling? */ - } - - next = attr->next; - free(attr->data); - free(attr); - attr = next; - } - } -} - - -void _mesa_init_attrib( struct gl_context *ctx ) -{ - /* Renderer and client attribute stacks */ - ctx->AttribStackDepth = 0; - ctx->ClientAttribStackDepth = 0; -} +/* + * Mesa 3-D graphics library + * Version: 7.6 + * + * Copyright (C) 1999-2008 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 "glheader.h" +#include "imports.h" +#include "accum.h" +#include "arrayobj.h" +#include "attrib.h" +#include "blend.h" +#include "buffers.h" +#include "bufferobj.h" +#include "clear.h" +#include "colormac.h" +#include "context.h" +#include "depth.h" +#include "enable.h" +#include "enums.h" +#include "fog.h" +#include "hint.h" +#include "light.h" +#include "lines.h" +#include "macros.h" +#include "matrix.h" +#include "mfeatures.h" +#include "multisample.h" +#include "points.h" +#include "polygon.h" +#include "scissor.h" +#include "stencil.h" +#include "texenv.h" +#include "texgen.h" +#include "texobj.h" +#include "texparam.h" +#include "texstate.h" +#include "varray.h" +#include "viewport.h" +#include "mtypes.h" +#include "main/dispatch.h" + + +/** + * glEnable()/glDisable() attribute group (GL_ENABLE_BIT). + */ +struct gl_enable_attrib +{ + GLboolean AlphaTest; + GLboolean AutoNormal; + GLboolean Blend; + GLbitfield ClipPlanes; + GLboolean ColorMaterial; + GLboolean CullFace; + GLboolean DepthClamp; + GLboolean DepthTest; + GLboolean Dither; + GLboolean Fog; + GLboolean Light[MAX_LIGHTS]; + GLboolean Lighting; + GLboolean LineSmooth; + GLboolean LineStipple; + GLboolean IndexLogicOp; + GLboolean ColorLogicOp; + + GLboolean Map1Color4; + GLboolean Map1Index; + GLboolean Map1Normal; + GLboolean Map1TextureCoord1; + GLboolean Map1TextureCoord2; + GLboolean Map1TextureCoord3; + GLboolean Map1TextureCoord4; + GLboolean Map1Vertex3; + GLboolean Map1Vertex4; + GLboolean Map1Attrib[16]; /* GL_NV_vertex_program */ + GLboolean Map2Color4; + GLboolean Map2Index; + GLboolean Map2Normal; + GLboolean Map2TextureCoord1; + GLboolean Map2TextureCoord2; + GLboolean Map2TextureCoord3; + GLboolean Map2TextureCoord4; + GLboolean Map2Vertex3; + GLboolean Map2Vertex4; + GLboolean Map2Attrib[16]; /* GL_NV_vertex_program */ + + GLboolean Normalize; + GLboolean PixelTexture; + GLboolean PointSmooth; + GLboolean PolygonOffsetPoint; + GLboolean PolygonOffsetLine; + GLboolean PolygonOffsetFill; + GLboolean PolygonSmooth; + GLboolean PolygonStipple; + GLboolean RescaleNormals; + GLboolean Scissor; + GLboolean Stencil; + GLboolean StencilTwoSide; /* GL_EXT_stencil_two_side */ + GLboolean MultisampleEnabled; /* GL_ARB_multisample */ + GLboolean SampleAlphaToCoverage; /* GL_ARB_multisample */ + GLboolean SampleAlphaToOne; /* GL_ARB_multisample */ + GLboolean SampleCoverage; /* GL_ARB_multisample */ + GLboolean SampleCoverageInvert; /* GL_ARB_multisample */ + GLboolean RasterPositionUnclipped; /* GL_IBM_rasterpos_clip */ + + GLbitfield Texture[MAX_TEXTURE_UNITS]; + GLbitfield TexGen[MAX_TEXTURE_UNITS]; + + /* GL_ARB_vertex_program / GL_NV_vertex_program */ + GLboolean VertexProgram; + GLboolean VertexProgramPointSize; + GLboolean VertexProgramTwoSide; + + /* GL_ARB_point_sprite / GL_NV_point_sprite */ + GLboolean PointSprite; + GLboolean FragmentShaderATI; +}; + + +/** + * Node for the attribute stack. + */ +struct gl_attrib_node +{ + GLbitfield kind; + void *data; + struct gl_attrib_node *next; +}; + + + +/** + * Special struct for saving/restoring texture state (GL_TEXTURE_BIT) + */ +struct texture_state +{ + struct gl_texture_attrib Texture; /**< The usual context state */ + + /** to save per texture object state (wrap modes, filters, etc): */ + struct gl_texture_object SavedObj[MAX_TEXTURE_UNITS][NUM_TEXTURE_TARGETS]; + + /** + * To save references to texture objects (so they don't get accidentally + * deleted while saved in the attribute stack). + */ + struct gl_texture_object *SavedTexRef[MAX_TEXTURE_UNITS][NUM_TEXTURE_TARGETS]; +}; + + +#if FEATURE_attrib_stack + + +/** + * Allocate new attribute node of given type/kind. Attach payload data. + * Insert it into the linked list named by 'head'. + */ +static void +save_attrib_data(struct gl_attrib_node **head, + GLbitfield kind, void *payload) +{ + struct gl_attrib_node *n = MALLOC_STRUCT(gl_attrib_node); + if (n) { + n->kind = kind; + n->data = payload; + /* insert at head */ + n->next = *head; + *head = n; + } + else { + /* out of memory! */ + } +} + + +void GLAPIENTRY +_mesa_PushAttrib(GLbitfield mask) +{ + struct gl_attrib_node *head; + + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glPushAttrib %x\n", (int) mask); + + if (ctx->AttribStackDepth >= MAX_ATTRIB_STACK_DEPTH) { + _mesa_error( ctx, GL_STACK_OVERFLOW, "glPushAttrib" ); + return; + } + + /* Build linked list of attribute nodes which save all attribute */ + /* groups specified by the mask. */ + head = NULL; + + if (mask & GL_ACCUM_BUFFER_BIT) { + struct gl_accum_attrib *attr; + attr = MALLOC_STRUCT( gl_accum_attrib ); + memcpy( attr, &ctx->Accum, sizeof(struct gl_accum_attrib) ); + save_attrib_data(&head, GL_ACCUM_BUFFER_BIT, attr); + } + + if (mask & GL_COLOR_BUFFER_BIT) { + GLuint i; + struct gl_colorbuffer_attrib *attr; + attr = MALLOC_STRUCT( gl_colorbuffer_attrib ); + memcpy( attr, &ctx->Color, sizeof(struct gl_colorbuffer_attrib) ); + /* push the Draw FBO's DrawBuffer[] state, not ctx->Color.DrawBuffer[] */ + for (i = 0; i < ctx->Const.MaxDrawBuffers; i ++) + attr->DrawBuffer[i] = ctx->DrawBuffer->ColorDrawBuffer[i]; + save_attrib_data(&head, GL_COLOR_BUFFER_BIT, attr); + } + + if (mask & GL_CURRENT_BIT) { + struct gl_current_attrib *attr; + FLUSH_CURRENT( ctx, 0 ); + attr = MALLOC_STRUCT( gl_current_attrib ); + memcpy( attr, &ctx->Current, sizeof(struct gl_current_attrib) ); + save_attrib_data(&head, GL_CURRENT_BIT, attr); + } + + if (mask & GL_DEPTH_BUFFER_BIT) { + struct gl_depthbuffer_attrib *attr; + attr = MALLOC_STRUCT( gl_depthbuffer_attrib ); + memcpy( attr, &ctx->Depth, sizeof(struct gl_depthbuffer_attrib) ); + save_attrib_data(&head, GL_DEPTH_BUFFER_BIT, attr); + } + + if (mask & GL_ENABLE_BIT) { + struct gl_enable_attrib *attr; + GLuint i; + attr = MALLOC_STRUCT( gl_enable_attrib ); + /* Copy enable flags from all other attributes into the enable struct. */ + attr->AlphaTest = ctx->Color.AlphaEnabled; + attr->AutoNormal = ctx->Eval.AutoNormal; + attr->Blend = ctx->Color.BlendEnabled; + attr->ClipPlanes = ctx->Transform.ClipPlanesEnabled; + attr->ColorMaterial = ctx->Light.ColorMaterialEnabled; + attr->CullFace = ctx->Polygon.CullFlag; + attr->DepthClamp = ctx->Transform.DepthClamp; + attr->DepthTest = ctx->Depth.Test; + attr->Dither = ctx->Color.DitherFlag; + attr->Fog = ctx->Fog.Enabled; + for (i = 0; i < ctx->Const.MaxLights; i++) { + attr->Light[i] = ctx->Light.Light[i].Enabled; + } + attr->Lighting = ctx->Light.Enabled; + attr->LineSmooth = ctx->Line.SmoothFlag; + attr->LineStipple = ctx->Line.StippleFlag; + attr->IndexLogicOp = ctx->Color.IndexLogicOpEnabled; + attr->ColorLogicOp = ctx->Color.ColorLogicOpEnabled; + attr->Map1Color4 = ctx->Eval.Map1Color4; + attr->Map1Index = ctx->Eval.Map1Index; + attr->Map1Normal = ctx->Eval.Map1Normal; + attr->Map1TextureCoord1 = ctx->Eval.Map1TextureCoord1; + attr->Map1TextureCoord2 = ctx->Eval.Map1TextureCoord2; + attr->Map1TextureCoord3 = ctx->Eval.Map1TextureCoord3; + attr->Map1TextureCoord4 = ctx->Eval.Map1TextureCoord4; + attr->Map1Vertex3 = ctx->Eval.Map1Vertex3; + attr->Map1Vertex4 = ctx->Eval.Map1Vertex4; + memcpy(attr->Map1Attrib, ctx->Eval.Map1Attrib, sizeof(ctx->Eval.Map1Attrib)); + attr->Map2Color4 = ctx->Eval.Map2Color4; + attr->Map2Index = ctx->Eval.Map2Index; + attr->Map2Normal = ctx->Eval.Map2Normal; + attr->Map2TextureCoord1 = ctx->Eval.Map2TextureCoord1; + attr->Map2TextureCoord2 = ctx->Eval.Map2TextureCoord2; + attr->Map2TextureCoord3 = ctx->Eval.Map2TextureCoord3; + attr->Map2TextureCoord4 = ctx->Eval.Map2TextureCoord4; + attr->Map2Vertex3 = ctx->Eval.Map2Vertex3; + attr->Map2Vertex4 = ctx->Eval.Map2Vertex4; + memcpy(attr->Map2Attrib, ctx->Eval.Map2Attrib, sizeof(ctx->Eval.Map2Attrib)); + attr->Normalize = ctx->Transform.Normalize; + attr->RasterPositionUnclipped = ctx->Transform.RasterPositionUnclipped; + attr->PointSmooth = ctx->Point.SmoothFlag; + attr->PointSprite = ctx->Point.PointSprite; + attr->PolygonOffsetPoint = ctx->Polygon.OffsetPoint; + attr->PolygonOffsetLine = ctx->Polygon.OffsetLine; + attr->PolygonOffsetFill = ctx->Polygon.OffsetFill; + attr->PolygonSmooth = ctx->Polygon.SmoothFlag; + attr->PolygonStipple = ctx->Polygon.StippleFlag; + attr->RescaleNormals = ctx->Transform.RescaleNormals; + attr->Scissor = ctx->Scissor.Enabled; + attr->Stencil = ctx->Stencil.Enabled; + attr->StencilTwoSide = ctx->Stencil.TestTwoSide; + attr->MultisampleEnabled = ctx->Multisample.Enabled; + attr->SampleAlphaToCoverage = ctx->Multisample.SampleAlphaToCoverage; + attr->SampleAlphaToOne = ctx->Multisample.SampleAlphaToOne; + attr->SampleCoverage = ctx->Multisample.SampleCoverage; + attr->SampleCoverageInvert = ctx->Multisample.SampleCoverageInvert; + for (i = 0; i < ctx->Const.MaxTextureUnits; i++) { + attr->Texture[i] = ctx->Texture.Unit[i].Enabled; + attr->TexGen[i] = ctx->Texture.Unit[i].TexGenEnabled; + } + /* GL_NV_vertex_program */ + attr->VertexProgram = ctx->VertexProgram.Enabled; + attr->VertexProgramPointSize = ctx->VertexProgram.PointSizeEnabled; + attr->VertexProgramTwoSide = ctx->VertexProgram.TwoSideEnabled; + save_attrib_data(&head, GL_ENABLE_BIT, attr); + } + + if (mask & GL_EVAL_BIT) { + struct gl_eval_attrib *attr; + attr = MALLOC_STRUCT( gl_eval_attrib ); + memcpy( attr, &ctx->Eval, sizeof(struct gl_eval_attrib) ); + save_attrib_data(&head, GL_EVAL_BIT, attr); + } + + if (mask & GL_FOG_BIT) { + struct gl_fog_attrib *attr; + attr = MALLOC_STRUCT( gl_fog_attrib ); + memcpy( attr, &ctx->Fog, sizeof(struct gl_fog_attrib) ); + save_attrib_data(&head, GL_FOG_BIT, attr); + } + + if (mask & GL_HINT_BIT) { + struct gl_hint_attrib *attr; + attr = MALLOC_STRUCT( gl_hint_attrib ); + memcpy( attr, &ctx->Hint, sizeof(struct gl_hint_attrib) ); + save_attrib_data(&head, GL_HINT_BIT, attr); + } + + if (mask & GL_LIGHTING_BIT) { + struct gl_light_attrib *attr; + FLUSH_CURRENT(ctx, 0); /* flush material changes */ + attr = MALLOC_STRUCT( gl_light_attrib ); + memcpy( attr, &ctx->Light, sizeof(struct gl_light_attrib) ); + save_attrib_data(&head, GL_LIGHTING_BIT, attr); + } + + if (mask & GL_LINE_BIT) { + struct gl_line_attrib *attr; + attr = MALLOC_STRUCT( gl_line_attrib ); + memcpy( attr, &ctx->Line, sizeof(struct gl_line_attrib) ); + save_attrib_data(&head, GL_LINE_BIT, attr); + } + + if (mask & GL_LIST_BIT) { + struct gl_list_attrib *attr; + attr = MALLOC_STRUCT( gl_list_attrib ); + memcpy( attr, &ctx->List, sizeof(struct gl_list_attrib) ); + save_attrib_data(&head, GL_LIST_BIT, attr); + } + + if (mask & GL_PIXEL_MODE_BIT) { + struct gl_pixel_attrib *attr; + attr = MALLOC_STRUCT( gl_pixel_attrib ); + memcpy( attr, &ctx->Pixel, sizeof(struct gl_pixel_attrib) ); + /* push the Read FBO's ReadBuffer state, not ctx->Pixel.ReadBuffer */ + attr->ReadBuffer = ctx->ReadBuffer->ColorReadBuffer; + save_attrib_data(&head, GL_PIXEL_MODE_BIT, attr); + } + + if (mask & GL_POINT_BIT) { + struct gl_point_attrib *attr; + attr = MALLOC_STRUCT( gl_point_attrib ); + memcpy( attr, &ctx->Point, sizeof(struct gl_point_attrib) ); + save_attrib_data(&head, GL_POINT_BIT, attr); + } + + if (mask & GL_POLYGON_BIT) { + struct gl_polygon_attrib *attr; + attr = MALLOC_STRUCT( gl_polygon_attrib ); + memcpy( attr, &ctx->Polygon, sizeof(struct gl_polygon_attrib) ); + save_attrib_data(&head, GL_POLYGON_BIT, attr); + } + + if (mask & GL_POLYGON_STIPPLE_BIT) { + GLuint *stipple; + stipple = (GLuint *) MALLOC( 32*sizeof(GLuint) ); + memcpy( stipple, ctx->PolygonStipple, 32*sizeof(GLuint) ); + save_attrib_data(&head, GL_POLYGON_STIPPLE_BIT, stipple); + } + + if (mask & GL_SCISSOR_BIT) { + struct gl_scissor_attrib *attr; + attr = MALLOC_STRUCT( gl_scissor_attrib ); + memcpy( attr, &ctx->Scissor, sizeof(struct gl_scissor_attrib) ); + save_attrib_data(&head, GL_SCISSOR_BIT, attr); + } + + if (mask & GL_STENCIL_BUFFER_BIT) { + struct gl_stencil_attrib *attr; + attr = MALLOC_STRUCT( gl_stencil_attrib ); + memcpy( attr, &ctx->Stencil, sizeof(struct gl_stencil_attrib) ); + save_attrib_data(&head, GL_STENCIL_BUFFER_BIT, attr); + } + + if (mask & GL_TEXTURE_BIT) { + struct texture_state *texstate = CALLOC_STRUCT(texture_state); + GLuint u, tex; + + if (!texstate) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glPushAttrib(GL_TEXTURE_BIT)"); + goto end; + } + + _mesa_lock_context_textures(ctx); + + /* copy/save the bulk of texture state here */ + memcpy(&texstate->Texture, &ctx->Texture, sizeof(ctx->Texture)); + + /* Save references to the currently bound texture objects so they don't + * accidentally get deleted while referenced in the attribute stack. + */ + for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { + for (tex = 0; tex < NUM_TEXTURE_TARGETS; tex++) { + _mesa_reference_texobj(&texstate->SavedTexRef[u][tex], + ctx->Texture.Unit[u].CurrentTex[tex]); + } + } + + /* copy state/contents of the currently bound texture objects */ + for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { + for (tex = 0; tex < NUM_TEXTURE_TARGETS; tex++) { + _mesa_copy_texture_object(&texstate->SavedObj[u][tex], + ctx->Texture.Unit[u].CurrentTex[tex]); + } + } + + _mesa_unlock_context_textures(ctx); + + save_attrib_data(&head, GL_TEXTURE_BIT, texstate); + } + + if (mask & GL_TRANSFORM_BIT) { + struct gl_transform_attrib *attr; + attr = MALLOC_STRUCT( gl_transform_attrib ); + memcpy( attr, &ctx->Transform, sizeof(struct gl_transform_attrib) ); + save_attrib_data(&head, GL_TRANSFORM_BIT, attr); + } + + if (mask & GL_VIEWPORT_BIT) { + struct gl_viewport_attrib *attr; + attr = MALLOC_STRUCT( gl_viewport_attrib ); + memcpy( attr, &ctx->Viewport, sizeof(struct gl_viewport_attrib) ); + save_attrib_data(&head, GL_VIEWPORT_BIT, attr); + } + + /* GL_ARB_multisample */ + if (mask & GL_MULTISAMPLE_BIT_ARB) { + struct gl_multisample_attrib *attr; + attr = MALLOC_STRUCT( gl_multisample_attrib ); + memcpy( attr, &ctx->Multisample, sizeof(struct gl_multisample_attrib) ); + save_attrib_data(&head, GL_MULTISAMPLE_BIT_ARB, attr); + } + +end: + ctx->AttribStack[ctx->AttribStackDepth] = head; + ctx->AttribStackDepth++; +} + + + +static void +pop_enable_group(struct gl_context *ctx, const struct gl_enable_attrib *enable) +{ + const GLuint curTexUnitSave = ctx->Texture.CurrentUnit; + GLuint i; + +#define TEST_AND_UPDATE(VALUE, NEWVALUE, ENUM) \ + if ((VALUE) != (NEWVALUE)) { \ + _mesa_set_enable( ctx, ENUM, (NEWVALUE) ); \ + } + + TEST_AND_UPDATE(ctx->Color.AlphaEnabled, enable->AlphaTest, GL_ALPHA_TEST); + if (ctx->Color.BlendEnabled != enable->Blend) { + if (ctx->Extensions.EXT_draw_buffers2) { + GLuint i; + for (i = 0; i < ctx->Const.MaxDrawBuffers; i++) { + _mesa_set_enablei(ctx, GL_BLEND, i, (enable->Blend >> i) & 1); + } + } + else { + _mesa_set_enable(ctx, GL_BLEND, (enable->Blend & 1)); + } + } + + for (i=0;iTransform.ClipPlanesEnabled & mask) != (enable->ClipPlanes & mask)) + _mesa_set_enable(ctx, (GLenum) (GL_CLIP_PLANE0 + i), + (GLboolean) ((enable->ClipPlanes & mask) ? GL_TRUE : GL_FALSE)); + } + + TEST_AND_UPDATE(ctx->Light.ColorMaterialEnabled, enable->ColorMaterial, + GL_COLOR_MATERIAL); + TEST_AND_UPDATE(ctx->Polygon.CullFlag, enable->CullFace, GL_CULL_FACE); + TEST_AND_UPDATE(ctx->Transform.DepthClamp, enable->DepthClamp, + GL_DEPTH_CLAMP); + TEST_AND_UPDATE(ctx->Depth.Test, enable->DepthTest, GL_DEPTH_TEST); + TEST_AND_UPDATE(ctx->Color.DitherFlag, enable->Dither, GL_DITHER); + TEST_AND_UPDATE(ctx->Fog.Enabled, enable->Fog, GL_FOG); + TEST_AND_UPDATE(ctx->Light.Enabled, enable->Lighting, GL_LIGHTING); + TEST_AND_UPDATE(ctx->Line.SmoothFlag, enable->LineSmooth, GL_LINE_SMOOTH); + TEST_AND_UPDATE(ctx->Line.StippleFlag, enable->LineStipple, + GL_LINE_STIPPLE); + TEST_AND_UPDATE(ctx->Color.IndexLogicOpEnabled, enable->IndexLogicOp, + GL_INDEX_LOGIC_OP); + TEST_AND_UPDATE(ctx->Color.ColorLogicOpEnabled, enable->ColorLogicOp, + GL_COLOR_LOGIC_OP); + + TEST_AND_UPDATE(ctx->Eval.Map1Color4, enable->Map1Color4, GL_MAP1_COLOR_4); + TEST_AND_UPDATE(ctx->Eval.Map1Index, enable->Map1Index, GL_MAP1_INDEX); + TEST_AND_UPDATE(ctx->Eval.Map1Normal, enable->Map1Normal, GL_MAP1_NORMAL); + TEST_AND_UPDATE(ctx->Eval.Map1TextureCoord1, enable->Map1TextureCoord1, + GL_MAP1_TEXTURE_COORD_1); + TEST_AND_UPDATE(ctx->Eval.Map1TextureCoord2, enable->Map1TextureCoord2, + GL_MAP1_TEXTURE_COORD_2); + TEST_AND_UPDATE(ctx->Eval.Map1TextureCoord3, enable->Map1TextureCoord3, + GL_MAP1_TEXTURE_COORD_3); + TEST_AND_UPDATE(ctx->Eval.Map1TextureCoord4, enable->Map1TextureCoord4, + GL_MAP1_TEXTURE_COORD_4); + TEST_AND_UPDATE(ctx->Eval.Map1Vertex3, enable->Map1Vertex3, + GL_MAP1_VERTEX_3); + TEST_AND_UPDATE(ctx->Eval.Map1Vertex4, enable->Map1Vertex4, + GL_MAP1_VERTEX_4); + for (i = 0; i < 16; i++) { + TEST_AND_UPDATE(ctx->Eval.Map1Attrib[i], enable->Map1Attrib[i], + GL_MAP1_VERTEX_ATTRIB0_4_NV + i); + } + + TEST_AND_UPDATE(ctx->Eval.Map2Color4, enable->Map2Color4, GL_MAP2_COLOR_4); + TEST_AND_UPDATE(ctx->Eval.Map2Index, enable->Map2Index, GL_MAP2_INDEX); + TEST_AND_UPDATE(ctx->Eval.Map2Normal, enable->Map2Normal, GL_MAP2_NORMAL); + TEST_AND_UPDATE(ctx->Eval.Map2TextureCoord1, enable->Map2TextureCoord1, + GL_MAP2_TEXTURE_COORD_1); + TEST_AND_UPDATE(ctx->Eval.Map2TextureCoord2, enable->Map2TextureCoord2, + GL_MAP2_TEXTURE_COORD_2); + TEST_AND_UPDATE(ctx->Eval.Map2TextureCoord3, enable->Map2TextureCoord3, + GL_MAP2_TEXTURE_COORD_3); + TEST_AND_UPDATE(ctx->Eval.Map2TextureCoord4, enable->Map2TextureCoord4, + GL_MAP2_TEXTURE_COORD_4); + TEST_AND_UPDATE(ctx->Eval.Map2Vertex3, enable->Map2Vertex3, + GL_MAP2_VERTEX_3); + TEST_AND_UPDATE(ctx->Eval.Map2Vertex4, enable->Map2Vertex4, + GL_MAP2_VERTEX_4); + for (i = 0; i < 16; i++) { + TEST_AND_UPDATE(ctx->Eval.Map2Attrib[i], enable->Map2Attrib[i], + GL_MAP2_VERTEX_ATTRIB0_4_NV + i); + } + + TEST_AND_UPDATE(ctx->Eval.AutoNormal, enable->AutoNormal, GL_AUTO_NORMAL); + TEST_AND_UPDATE(ctx->Transform.Normalize, enable->Normalize, GL_NORMALIZE); + TEST_AND_UPDATE(ctx->Transform.RescaleNormals, enable->RescaleNormals, + GL_RESCALE_NORMAL_EXT); + TEST_AND_UPDATE(ctx->Transform.RasterPositionUnclipped, + enable->RasterPositionUnclipped, + GL_RASTER_POSITION_UNCLIPPED_IBM); + TEST_AND_UPDATE(ctx->Point.SmoothFlag, enable->PointSmooth, + GL_POINT_SMOOTH); + if (ctx->Extensions.NV_point_sprite || ctx->Extensions.ARB_point_sprite) { + TEST_AND_UPDATE(ctx->Point.PointSprite, enable->PointSprite, + GL_POINT_SPRITE_NV); + } + TEST_AND_UPDATE(ctx->Polygon.OffsetPoint, enable->PolygonOffsetPoint, + GL_POLYGON_OFFSET_POINT); + TEST_AND_UPDATE(ctx->Polygon.OffsetLine, enable->PolygonOffsetLine, + GL_POLYGON_OFFSET_LINE); + TEST_AND_UPDATE(ctx->Polygon.OffsetFill, enable->PolygonOffsetFill, + GL_POLYGON_OFFSET_FILL); + TEST_AND_UPDATE(ctx->Polygon.SmoothFlag, enable->PolygonSmooth, + GL_POLYGON_SMOOTH); + TEST_AND_UPDATE(ctx->Polygon.StippleFlag, enable->PolygonStipple, + GL_POLYGON_STIPPLE); + TEST_AND_UPDATE(ctx->Scissor.Enabled, enable->Scissor, GL_SCISSOR_TEST); + TEST_AND_UPDATE(ctx->Stencil.Enabled, enable->Stencil, GL_STENCIL_TEST); + if (ctx->Extensions.EXT_stencil_two_side) { + TEST_AND_UPDATE(ctx->Stencil.TestTwoSide, enable->StencilTwoSide, GL_STENCIL_TEST_TWO_SIDE_EXT); + } + TEST_AND_UPDATE(ctx->Multisample.Enabled, enable->MultisampleEnabled, + GL_MULTISAMPLE_ARB); + TEST_AND_UPDATE(ctx->Multisample.SampleAlphaToCoverage, + enable->SampleAlphaToCoverage, + GL_SAMPLE_ALPHA_TO_COVERAGE_ARB); + TEST_AND_UPDATE(ctx->Multisample.SampleAlphaToOne, + enable->SampleAlphaToOne, + GL_SAMPLE_ALPHA_TO_ONE_ARB); + TEST_AND_UPDATE(ctx->Multisample.SampleCoverage, + enable->SampleCoverage, + GL_SAMPLE_COVERAGE_ARB); + TEST_AND_UPDATE(ctx->Multisample.SampleCoverageInvert, + enable->SampleCoverageInvert, + GL_SAMPLE_COVERAGE_INVERT_ARB); + /* GL_ARB_vertex_program, GL_NV_vertex_program */ + TEST_AND_UPDATE(ctx->VertexProgram.Enabled, + enable->VertexProgram, + GL_VERTEX_PROGRAM_ARB); + TEST_AND_UPDATE(ctx->VertexProgram.PointSizeEnabled, + enable->VertexProgramPointSize, + GL_VERTEX_PROGRAM_POINT_SIZE_ARB); + TEST_AND_UPDATE(ctx->VertexProgram.TwoSideEnabled, + enable->VertexProgramTwoSide, + GL_VERTEX_PROGRAM_TWO_SIDE_ARB); + +#undef TEST_AND_UPDATE + + /* texture unit enables */ + for (i = 0; i < ctx->Const.MaxTextureUnits; i++) { + const GLbitfield enabled = enable->Texture[i]; + const GLbitfield genEnabled = enable->TexGen[i]; + + if (ctx->Texture.Unit[i].Enabled != enabled) { + _mesa_ActiveTextureARB(GL_TEXTURE0 + i); + + _mesa_set_enable(ctx, GL_TEXTURE_1D, + (enabled & TEXTURE_1D_BIT) ? GL_TRUE : GL_FALSE); + _mesa_set_enable(ctx, GL_TEXTURE_2D, + (enabled & TEXTURE_2D_BIT) ? GL_TRUE : GL_FALSE); + _mesa_set_enable(ctx, GL_TEXTURE_3D, + (enabled & TEXTURE_3D_BIT) ? GL_TRUE : GL_FALSE); + if (ctx->Extensions.NV_texture_rectangle) { + _mesa_set_enable(ctx, GL_TEXTURE_RECTANGLE_ARB, + (enabled & TEXTURE_RECT_BIT) ? GL_TRUE : GL_FALSE); + } + if (ctx->Extensions.ARB_texture_cube_map) { + _mesa_set_enable(ctx, GL_TEXTURE_CUBE_MAP, + (enabled & TEXTURE_CUBE_BIT) ? GL_TRUE : GL_FALSE); + } + if (ctx->Extensions.MESA_texture_array) { + _mesa_set_enable(ctx, GL_TEXTURE_1D_ARRAY_EXT, + (enabled & TEXTURE_1D_ARRAY_BIT) ? GL_TRUE : GL_FALSE); + _mesa_set_enable(ctx, GL_TEXTURE_2D_ARRAY_EXT, + (enabled & TEXTURE_2D_ARRAY_BIT) ? GL_TRUE : GL_FALSE); + } + } + + if (ctx->Texture.Unit[i].TexGenEnabled != genEnabled) { + _mesa_ActiveTextureARB(GL_TEXTURE0 + i); + _mesa_set_enable(ctx, GL_TEXTURE_GEN_S, + (genEnabled & S_BIT) ? GL_TRUE : GL_FALSE); + _mesa_set_enable(ctx, GL_TEXTURE_GEN_T, + (genEnabled & T_BIT) ? GL_TRUE : GL_FALSE); + _mesa_set_enable(ctx, GL_TEXTURE_GEN_R, + (genEnabled & R_BIT) ? GL_TRUE : GL_FALSE); + _mesa_set_enable(ctx, GL_TEXTURE_GEN_Q, + (genEnabled & Q_BIT) ? GL_TRUE : GL_FALSE); + } + } + + _mesa_ActiveTextureARB(GL_TEXTURE0 + curTexUnitSave); +} + + +/** + * Pop/restore texture attribute/group state. + */ +static void +pop_texture_group(struct gl_context *ctx, struct texture_state *texstate) +{ + GLuint u; + + _mesa_lock_context_textures(ctx); + + for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { + const struct gl_texture_unit *unit = &texstate->Texture.Unit[u]; + GLuint tgt; + + _mesa_ActiveTextureARB(GL_TEXTURE0_ARB + u); + _mesa_set_enable(ctx, GL_TEXTURE_1D, + (unit->Enabled & TEXTURE_1D_BIT) ? GL_TRUE : GL_FALSE); + _mesa_set_enable(ctx, GL_TEXTURE_2D, + (unit->Enabled & TEXTURE_2D_BIT) ? GL_TRUE : GL_FALSE); + _mesa_set_enable(ctx, GL_TEXTURE_3D, + (unit->Enabled & TEXTURE_3D_BIT) ? GL_TRUE : GL_FALSE); + if (ctx->Extensions.ARB_texture_cube_map) { + _mesa_set_enable(ctx, GL_TEXTURE_CUBE_MAP_ARB, + (unit->Enabled & TEXTURE_CUBE_BIT) ? GL_TRUE : GL_FALSE); + } + if (ctx->Extensions.NV_texture_rectangle) { + _mesa_set_enable(ctx, GL_TEXTURE_RECTANGLE_NV, + (unit->Enabled & TEXTURE_RECT_BIT) ? GL_TRUE : GL_FALSE); + } + if (ctx->Extensions.MESA_texture_array) { + _mesa_set_enable(ctx, GL_TEXTURE_1D_ARRAY_EXT, + (unit->Enabled & TEXTURE_1D_ARRAY_BIT) ? GL_TRUE : GL_FALSE); + _mesa_set_enable(ctx, GL_TEXTURE_2D_ARRAY_EXT, + (unit->Enabled & TEXTURE_2D_ARRAY_BIT) ? GL_TRUE : GL_FALSE); + } + + _mesa_TexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, unit->EnvMode); + _mesa_TexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, unit->EnvColor); + _mesa_TexGeni(GL_S, GL_TEXTURE_GEN_MODE, unit->GenS.Mode); + _mesa_TexGeni(GL_T, GL_TEXTURE_GEN_MODE, unit->GenT.Mode); + _mesa_TexGeni(GL_R, GL_TEXTURE_GEN_MODE, unit->GenR.Mode); + _mesa_TexGeni(GL_Q, GL_TEXTURE_GEN_MODE, unit->GenQ.Mode); + _mesa_TexGenfv(GL_S, GL_OBJECT_PLANE, unit->GenS.ObjectPlane); + _mesa_TexGenfv(GL_T, GL_OBJECT_PLANE, unit->GenT.ObjectPlane); + _mesa_TexGenfv(GL_R, GL_OBJECT_PLANE, unit->GenR.ObjectPlane); + _mesa_TexGenfv(GL_Q, GL_OBJECT_PLANE, unit->GenQ.ObjectPlane); + /* Eye plane done differently to avoid re-transformation */ + { + struct gl_texture_unit *destUnit = &ctx->Texture.Unit[u]; + COPY_4FV(destUnit->GenS.EyePlane, unit->GenS.EyePlane); + COPY_4FV(destUnit->GenT.EyePlane, unit->GenT.EyePlane); + COPY_4FV(destUnit->GenR.EyePlane, unit->GenR.EyePlane); + COPY_4FV(destUnit->GenQ.EyePlane, unit->GenQ.EyePlane); + if (ctx->Driver.TexGen) { + ctx->Driver.TexGen(ctx, GL_S, GL_EYE_PLANE, unit->GenS.EyePlane); + ctx->Driver.TexGen(ctx, GL_T, GL_EYE_PLANE, unit->GenT.EyePlane); + ctx->Driver.TexGen(ctx, GL_R, GL_EYE_PLANE, unit->GenR.EyePlane); + ctx->Driver.TexGen(ctx, GL_Q, GL_EYE_PLANE, unit->GenQ.EyePlane); + } + } + _mesa_set_enable(ctx, GL_TEXTURE_GEN_S, + ((unit->TexGenEnabled & S_BIT) ? GL_TRUE : GL_FALSE)); + _mesa_set_enable(ctx, GL_TEXTURE_GEN_T, + ((unit->TexGenEnabled & T_BIT) ? GL_TRUE : GL_FALSE)); + _mesa_set_enable(ctx, GL_TEXTURE_GEN_R, + ((unit->TexGenEnabled & R_BIT) ? GL_TRUE : GL_FALSE)); + _mesa_set_enable(ctx, GL_TEXTURE_GEN_Q, + ((unit->TexGenEnabled & Q_BIT) ? GL_TRUE : GL_FALSE)); + if (ctx->Extensions.EXT_texture_lod_bias) { + _mesa_TexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT, + GL_TEXTURE_LOD_BIAS_EXT, unit->LodBias); + } + if (ctx->Extensions.EXT_texture_env_combine || + ctx->Extensions.ARB_texture_env_combine) { + _mesa_TexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, + unit->Combine.ModeRGB); + _mesa_TexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, + unit->Combine.ModeA); + _mesa_TexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, + unit->Combine.SourceRGB[0]); + _mesa_TexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, + unit->Combine.SourceRGB[1]); + _mesa_TexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB, + unit->Combine.SourceRGB[2]); + _mesa_TexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, + unit->Combine.SourceA[0]); + _mesa_TexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA, + unit->Combine.SourceA[1]); + _mesa_TexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_ALPHA, + unit->Combine.SourceA[2]); + _mesa_TexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, + unit->Combine.OperandRGB[0]); + _mesa_TexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, + unit->Combine.OperandRGB[1]); + _mesa_TexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB, + unit->Combine.OperandRGB[2]); + _mesa_TexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, + unit->Combine.OperandA[0]); + _mesa_TexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, + unit->Combine.OperandA[1]); + _mesa_TexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_ALPHA, + unit->Combine.OperandA[2]); + _mesa_TexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE, + 1 << unit->Combine.ScaleShiftRGB); + _mesa_TexEnvi(GL_TEXTURE_ENV, GL_ALPHA_SCALE, + 1 << unit->Combine.ScaleShiftA); + } + + /* Restore texture object state for each target */ + for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++) { + const struct gl_texture_object *obj = NULL; + const struct gl_sampler_object *samp; + GLenum target; + + obj = &texstate->SavedObj[u][tgt]; + + /* don't restore state for unsupported targets to prevent + * raising GL errors. + */ + if (obj->Target == GL_TEXTURE_CUBE_MAP_ARB && + !ctx->Extensions.ARB_texture_cube_map) { + continue; + } + else if (obj->Target == GL_TEXTURE_RECTANGLE_NV && + !ctx->Extensions.NV_texture_rectangle) { + continue; + } + else if ((obj->Target == GL_TEXTURE_1D_ARRAY_EXT || + obj->Target == GL_TEXTURE_2D_ARRAY_EXT) && + !ctx->Extensions.MESA_texture_array) { + continue; + } + else if (obj->Target == GL_TEXTURE_BUFFER) + continue; + + target = obj->Target; + + _mesa_BindTexture(target, obj->Name); + + samp = &obj->Sampler; + + _mesa_TexParameterfv(target, GL_TEXTURE_BORDER_COLOR, samp->BorderColor.f); + _mesa_TexParameteri(target, GL_TEXTURE_WRAP_S, samp->WrapS); + _mesa_TexParameteri(target, GL_TEXTURE_WRAP_T, samp->WrapT); + _mesa_TexParameteri(target, GL_TEXTURE_WRAP_R, samp->WrapR); + _mesa_TexParameteri(target, GL_TEXTURE_MIN_FILTER, samp->MinFilter); + _mesa_TexParameteri(target, GL_TEXTURE_MAG_FILTER, samp->MagFilter); + _mesa_TexParameterf(target, GL_TEXTURE_MIN_LOD, samp->MinLod); + _mesa_TexParameterf(target, GL_TEXTURE_MAX_LOD, samp->MaxLod); + _mesa_TexParameterf(target, GL_TEXTURE_LOD_BIAS, samp->LodBias); + _mesa_TexParameterf(target, GL_TEXTURE_PRIORITY, obj->Priority); + _mesa_TexParameteri(target, GL_TEXTURE_BASE_LEVEL, obj->BaseLevel); + if (target != GL_TEXTURE_RECTANGLE_ARB) + _mesa_TexParameteri(target, GL_TEXTURE_MAX_LEVEL, obj->MaxLevel); + if (ctx->Extensions.EXT_texture_filter_anisotropic) { + _mesa_TexParameterf(target, GL_TEXTURE_MAX_ANISOTROPY_EXT, + samp->MaxAnisotropy); + } + if (ctx->Extensions.ARB_shadow_ambient) { + _mesa_TexParameterf(target, GL_TEXTURE_COMPARE_FAIL_VALUE_ARB, + samp->CompareFailValue); + } + } + + /* remove saved references to the texture objects */ + for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++) { + _mesa_reference_texobj(&texstate->SavedTexRef[u][tgt], NULL); + } + } + + _mesa_ActiveTextureARB(GL_TEXTURE0_ARB + texstate->Texture.CurrentUnit); + + _mesa_unlock_context_textures(ctx); +} + + +/* + * This function is kind of long just because we have to call a lot + * of device driver functions to update device driver state. + * + * XXX As it is now, most of the pop-code calls immediate-mode Mesa functions + * in order to restore GL state. This isn't terribly efficient but it + * ensures that dirty flags and any derived state gets updated correctly. + * We could at least check if the value to restore equals the current value + * and then skip the Mesa call. + */ +void GLAPIENTRY +_mesa_PopAttrib(void) +{ + struct gl_attrib_node *attr, *next; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + if (ctx->AttribStackDepth == 0) { + _mesa_error( ctx, GL_STACK_UNDERFLOW, "glPopAttrib" ); + return; + } + + ctx->AttribStackDepth--; + attr = ctx->AttribStack[ctx->AttribStackDepth]; + + while (attr) { + + if (MESA_VERBOSE & VERBOSE_API) { + _mesa_debug(ctx, "glPopAttrib %s\n", + _mesa_lookup_enum_by_nr(attr->kind)); + } + + switch (attr->kind) { + case GL_ACCUM_BUFFER_BIT: + { + const struct gl_accum_attrib *accum; + accum = (const struct gl_accum_attrib *) attr->data; + _mesa_ClearAccum(accum->ClearColor[0], + accum->ClearColor[1], + accum->ClearColor[2], + accum->ClearColor[3]); + } + break; + case GL_COLOR_BUFFER_BIT: + { + const struct gl_colorbuffer_attrib *color; + + color = (const struct gl_colorbuffer_attrib *) attr->data; + _mesa_ClearIndex((GLfloat) color->ClearIndex); + _mesa_ClearColor(color->ClearColorUnclamped[0], + color->ClearColorUnclamped[1], + color->ClearColorUnclamped[2], + color->ClearColorUnclamped[3]); + _mesa_IndexMask(color->IndexMask); + if (!ctx->Extensions.EXT_draw_buffers2) { + _mesa_ColorMask((GLboolean) (color->ColorMask[0][0] != 0), + (GLboolean) (color->ColorMask[0][1] != 0), + (GLboolean) (color->ColorMask[0][2] != 0), + (GLboolean) (color->ColorMask[0][3] != 0)); + } + else { + GLuint i; + for (i = 0; i < ctx->Const.MaxDrawBuffers; i++) { + _mesa_ColorMaskIndexed(i, + (GLboolean) (color->ColorMask[i][0] != 0), + (GLboolean) (color->ColorMask[i][1] != 0), + (GLboolean) (color->ColorMask[i][2] != 0), + (GLboolean) (color->ColorMask[i][3] != 0)); + } + } + { + /* Need to determine if more than one color output is + * specified. If so, call glDrawBuffersARB, else call + * glDrawBuffer(). This is a subtle, but essential point + * since GL_FRONT (for example) is illegal for the former + * function, but legal for the later. + */ + GLboolean multipleBuffers = GL_FALSE; + GLuint i; + + for (i = 1; i < ctx->Const.MaxDrawBuffers; i++) { + if (color->DrawBuffer[i] != GL_NONE) { + multipleBuffers = GL_TRUE; + break; + } + } + /* Call the API_level functions, not _mesa_drawbuffers() + * since we need to do error checking on the pop'd + * GL_DRAW_BUFFER. + * Ex: if GL_FRONT were pushed, but we're popping with a + * user FBO bound, GL_FRONT will be illegal and we'll need + * to record that error. Per OpenGL ARB decision. + */ + if (multipleBuffers) + _mesa_DrawBuffersARB(ctx->Const.MaxDrawBuffers, + color->DrawBuffer); + else + _mesa_DrawBuffer(color->DrawBuffer[0]); + } + _mesa_set_enable(ctx, GL_ALPHA_TEST, color->AlphaEnabled); + _mesa_AlphaFunc(color->AlphaFunc, color->AlphaRefUnclamped); + if (ctx->Color.BlendEnabled != color->BlendEnabled) { + if (ctx->Extensions.EXT_draw_buffers2) { + GLuint i; + for (i = 0; i < ctx->Const.MaxDrawBuffers; i++) { + _mesa_set_enablei(ctx, GL_BLEND, i, + (color->BlendEnabled >> i) & 1); + } + } + else { + _mesa_set_enable(ctx, GL_BLEND, (color->BlendEnabled & 1)); + } + } + if (ctx->Color._BlendFuncPerBuffer || + ctx->Color._BlendEquationPerBuffer) { + /* set blend per buffer */ + GLuint buf; + for (buf = 0; buf < ctx->Const.MaxDrawBuffers; buf++) { + _mesa_BlendFuncSeparatei(buf, color->Blend[buf].SrcRGB, + color->Blend[buf].DstRGB, + color->Blend[buf].SrcA, + color->Blend[buf].DstA); + _mesa_BlendEquationSeparatei(buf, + color->Blend[buf].EquationRGB, + color->Blend[buf].EquationA); + } + } + else { + /* set same blend modes for all buffers */ + _mesa_BlendFuncSeparateEXT(color->Blend[0].SrcRGB, + color->Blend[0].DstRGB, + color->Blend[0].SrcA, + color->Blend[0].DstA); + /* This special case is because glBlendEquationSeparateEXT + * cannot take GL_LOGIC_OP as a parameter. + */ + if (color->Blend[0].EquationRGB == + color->Blend[0].EquationA) { + _mesa_BlendEquation(color->Blend[0].EquationRGB); + } + else { + _mesa_BlendEquationSeparateEXT( + color->Blend[0].EquationRGB, + color->Blend[0].EquationA); + } + } + _mesa_BlendColor(color->BlendColorUnclamped[0], + color->BlendColorUnclamped[1], + color->BlendColorUnclamped[2], + color->BlendColorUnclamped[3]); + _mesa_LogicOp(color->LogicOp); + _mesa_set_enable(ctx, GL_COLOR_LOGIC_OP, + color->ColorLogicOpEnabled); + _mesa_set_enable(ctx, GL_INDEX_LOGIC_OP, + color->IndexLogicOpEnabled); + _mesa_set_enable(ctx, GL_DITHER, color->DitherFlag); + _mesa_ClampColorARB(GL_CLAMP_FRAGMENT_COLOR_ARB, color->ClampFragmentColor); + _mesa_ClampColorARB(GL_CLAMP_READ_COLOR_ARB, color->ClampReadColor); + } + break; + case GL_CURRENT_BIT: + FLUSH_CURRENT( ctx, 0 ); + memcpy( &ctx->Current, attr->data, + sizeof(struct gl_current_attrib) ); + break; + case GL_DEPTH_BUFFER_BIT: + { + const struct gl_depthbuffer_attrib *depth; + depth = (const struct gl_depthbuffer_attrib *) attr->data; + _mesa_DepthFunc(depth->Func); + _mesa_ClearDepth(depth->Clear); + _mesa_set_enable(ctx, GL_DEPTH_TEST, depth->Test); + _mesa_DepthMask(depth->Mask); + } + break; + case GL_ENABLE_BIT: + { + const struct gl_enable_attrib *enable; + enable = (const struct gl_enable_attrib *) attr->data; + pop_enable_group(ctx, enable); + ctx->NewState |= _NEW_ALL; + } + break; + case GL_EVAL_BIT: + memcpy( &ctx->Eval, attr->data, sizeof(struct gl_eval_attrib) ); + ctx->NewState |= _NEW_EVAL; + break; + case GL_FOG_BIT: + { + const struct gl_fog_attrib *fog; + fog = (const struct gl_fog_attrib *) attr->data; + _mesa_set_enable(ctx, GL_FOG, fog->Enabled); + _mesa_Fogfv(GL_FOG_COLOR, fog->Color); + _mesa_Fogf(GL_FOG_DENSITY, fog->Density); + _mesa_Fogf(GL_FOG_START, fog->Start); + _mesa_Fogf(GL_FOG_END, fog->End); + _mesa_Fogf(GL_FOG_INDEX, fog->Index); + _mesa_Fogi(GL_FOG_MODE, fog->Mode); + } + break; + case GL_HINT_BIT: + { + const struct gl_hint_attrib *hint; + hint = (const struct gl_hint_attrib *) attr->data; + _mesa_Hint(GL_PERSPECTIVE_CORRECTION_HINT, + hint->PerspectiveCorrection ); + _mesa_Hint(GL_POINT_SMOOTH_HINT, hint->PointSmooth); + _mesa_Hint(GL_LINE_SMOOTH_HINT, hint->LineSmooth); + _mesa_Hint(GL_POLYGON_SMOOTH_HINT, hint->PolygonSmooth); + _mesa_Hint(GL_FOG_HINT, hint->Fog); + _mesa_Hint(GL_CLIP_VOLUME_CLIPPING_HINT_EXT, + hint->ClipVolumeClipping); + _mesa_Hint(GL_TEXTURE_COMPRESSION_HINT_ARB, + hint->TextureCompression); + } + break; + case GL_LIGHTING_BIT: + { + GLuint i; + const struct gl_light_attrib *light; + light = (const struct gl_light_attrib *) attr->data; + /* lighting enable */ + _mesa_set_enable(ctx, GL_LIGHTING, light->Enabled); + /* per-light state */ + if (_math_matrix_is_dirty(ctx->ModelviewMatrixStack.Top)) + _math_matrix_analyse( ctx->ModelviewMatrixStack.Top ); + + for (i = 0; i < ctx->Const.MaxLights; i++) { + const struct gl_light *l = &light->Light[i]; + _mesa_set_enable(ctx, GL_LIGHT0 + i, l->Enabled); + _mesa_light(ctx, i, GL_AMBIENT, l->Ambient); + _mesa_light(ctx, i, GL_DIFFUSE, l->Diffuse); + _mesa_light(ctx, i, GL_SPECULAR, l->Specular ); + _mesa_light(ctx, i, GL_POSITION, l->EyePosition); + _mesa_light(ctx, i, GL_SPOT_DIRECTION, l->SpotDirection); + { + GLfloat p[4] = { 0 }; + p[0] = l->SpotExponent; + _mesa_light(ctx, i, GL_SPOT_EXPONENT, p); + } + { + GLfloat p[4] = { 0 }; + p[0] = l->SpotCutoff; + _mesa_light(ctx, i, GL_SPOT_CUTOFF, p); + } + { + GLfloat p[4] = { 0 }; + p[0] = l->ConstantAttenuation; + _mesa_light(ctx, i, GL_CONSTANT_ATTENUATION, p); + } + { + GLfloat p[4] = { 0 }; + p[0] = l->LinearAttenuation; + _mesa_light(ctx, i, GL_LINEAR_ATTENUATION, p); + } + { + GLfloat p[4] = { 0 }; + p[0] = l->QuadraticAttenuation; + _mesa_light(ctx, i, GL_QUADRATIC_ATTENUATION, p); + } + } + /* light model */ + _mesa_LightModelfv(GL_LIGHT_MODEL_AMBIENT, + light->Model.Ambient); + _mesa_LightModelf(GL_LIGHT_MODEL_LOCAL_VIEWER, + (GLfloat) light->Model.LocalViewer); + _mesa_LightModelf(GL_LIGHT_MODEL_TWO_SIDE, + (GLfloat) light->Model.TwoSide); + _mesa_LightModelf(GL_LIGHT_MODEL_COLOR_CONTROL, + (GLfloat) light->Model.ColorControl); + /* shade model */ + _mesa_ShadeModel(light->ShadeModel); + /* color material */ + _mesa_ColorMaterial(light->ColorMaterialFace, + light->ColorMaterialMode); + _mesa_set_enable(ctx, GL_COLOR_MATERIAL, + light->ColorMaterialEnabled); + /* materials */ + memcpy(&ctx->Light.Material, &light->Material, + sizeof(struct gl_material)); + _mesa_ClampColorARB(GL_CLAMP_VERTEX_COLOR_ARB, light->ClampVertexColor); + } + break; + case GL_LINE_BIT: + { + const struct gl_line_attrib *line; + line = (const struct gl_line_attrib *) attr->data; + _mesa_set_enable(ctx, GL_LINE_SMOOTH, line->SmoothFlag); + _mesa_set_enable(ctx, GL_LINE_STIPPLE, line->StippleFlag); + _mesa_LineStipple(line->StippleFactor, line->StipplePattern); + _mesa_LineWidth(line->Width); + } + break; + case GL_LIST_BIT: + memcpy( &ctx->List, attr->data, sizeof(struct gl_list_attrib) ); + break; + case GL_PIXEL_MODE_BIT: + memcpy( &ctx->Pixel, attr->data, sizeof(struct gl_pixel_attrib) ); + /* XXX what other pixel state needs to be set by function calls? */ + _mesa_ReadBuffer(ctx->Pixel.ReadBuffer); + ctx->NewState |= _NEW_PIXEL; + break; + case GL_POINT_BIT: + { + const struct gl_point_attrib *point; + point = (const struct gl_point_attrib *) attr->data; + _mesa_PointSize(point->Size); + _mesa_set_enable(ctx, GL_POINT_SMOOTH, point->SmoothFlag); + if (ctx->Extensions.EXT_point_parameters) { + _mesa_PointParameterfv(GL_DISTANCE_ATTENUATION_EXT, + point->Params); + _mesa_PointParameterf(GL_POINT_SIZE_MIN_EXT, + point->MinSize); + _mesa_PointParameterf(GL_POINT_SIZE_MAX_EXT, + point->MaxSize); + _mesa_PointParameterf(GL_POINT_FADE_THRESHOLD_SIZE_EXT, + point->Threshold); + } + if (ctx->Extensions.NV_point_sprite + || ctx->Extensions.ARB_point_sprite) { + GLuint u; + for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { + _mesa_TexEnvi(GL_POINT_SPRITE_NV, GL_COORD_REPLACE_NV, + (GLint) point->CoordReplace[u]); + } + _mesa_set_enable(ctx, GL_POINT_SPRITE_NV,point->PointSprite); + if (ctx->Extensions.NV_point_sprite) + _mesa_PointParameteri(GL_POINT_SPRITE_R_MODE_NV, + ctx->Point.SpriteRMode); + _mesa_PointParameterf(GL_POINT_SPRITE_COORD_ORIGIN, + (GLfloat)ctx->Point.SpriteOrigin); + } + } + break; + case GL_POLYGON_BIT: + { + const struct gl_polygon_attrib *polygon; + polygon = (const struct gl_polygon_attrib *) attr->data; + _mesa_CullFace(polygon->CullFaceMode); + _mesa_FrontFace(polygon->FrontFace); + _mesa_PolygonMode(GL_FRONT, polygon->FrontMode); + _mesa_PolygonMode(GL_BACK, polygon->BackMode); + _mesa_PolygonOffset(polygon->OffsetFactor, + polygon->OffsetUnits); + _mesa_set_enable(ctx, GL_POLYGON_SMOOTH, polygon->SmoothFlag); + _mesa_set_enable(ctx, GL_POLYGON_STIPPLE, polygon->StippleFlag); + _mesa_set_enable(ctx, GL_CULL_FACE, polygon->CullFlag); + _mesa_set_enable(ctx, GL_POLYGON_OFFSET_POINT, + polygon->OffsetPoint); + _mesa_set_enable(ctx, GL_POLYGON_OFFSET_LINE, + polygon->OffsetLine); + _mesa_set_enable(ctx, GL_POLYGON_OFFSET_FILL, + polygon->OffsetFill); + } + break; + case GL_POLYGON_STIPPLE_BIT: + memcpy( ctx->PolygonStipple, attr->data, 32*sizeof(GLuint) ); + ctx->NewState |= _NEW_POLYGONSTIPPLE; + if (ctx->Driver.PolygonStipple) + ctx->Driver.PolygonStipple( ctx, (const GLubyte *) attr->data ); + break; + case GL_SCISSOR_BIT: + { + const struct gl_scissor_attrib *scissor; + scissor = (const struct gl_scissor_attrib *) attr->data; + _mesa_Scissor(scissor->X, scissor->Y, + scissor->Width, scissor->Height); + _mesa_set_enable(ctx, GL_SCISSOR_TEST, scissor->Enabled); + } + break; + case GL_STENCIL_BUFFER_BIT: + { + const struct gl_stencil_attrib *stencil; + stencil = (const struct gl_stencil_attrib *) attr->data; + _mesa_set_enable(ctx, GL_STENCIL_TEST, stencil->Enabled); + _mesa_ClearStencil(stencil->Clear); + if (ctx->Extensions.EXT_stencil_two_side) { + _mesa_set_enable(ctx, GL_STENCIL_TEST_TWO_SIDE_EXT, + stencil->TestTwoSide); + _mesa_ActiveStencilFaceEXT(stencil->ActiveFace + ? GL_BACK : GL_FRONT); + } + /* front state */ + _mesa_StencilFuncSeparate(GL_FRONT, + stencil->Function[0], + stencil->Ref[0], + stencil->ValueMask[0]); + _mesa_StencilMaskSeparate(GL_FRONT, stencil->WriteMask[0]); + _mesa_StencilOpSeparate(GL_FRONT, stencil->FailFunc[0], + stencil->ZFailFunc[0], + stencil->ZPassFunc[0]); + /* back state */ + _mesa_StencilFuncSeparate(GL_BACK, + stencil->Function[1], + stencil->Ref[1], + stencil->ValueMask[1]); + _mesa_StencilMaskSeparate(GL_BACK, stencil->WriteMask[1]); + _mesa_StencilOpSeparate(GL_BACK, stencil->FailFunc[1], + stencil->ZFailFunc[1], + stencil->ZPassFunc[1]); + } + break; + case GL_TRANSFORM_BIT: + { + GLuint i; + const struct gl_transform_attrib *xform; + xform = (const struct gl_transform_attrib *) attr->data; + _mesa_MatrixMode(xform->MatrixMode); + if (_math_matrix_is_dirty(ctx->ProjectionMatrixStack.Top)) + _math_matrix_analyse( ctx->ProjectionMatrixStack.Top ); + + /* restore clip planes */ + for (i = 0; i < MAX_CLIP_PLANES; i++) { + const GLuint mask = 1 << i; + const GLfloat *eyePlane = xform->EyeUserPlane[i]; + COPY_4V(ctx->Transform.EyeUserPlane[i], eyePlane); + if (xform->ClipPlanesEnabled & mask) { + _mesa_set_enable(ctx, GL_CLIP_PLANE0 + i, GL_TRUE); + } + else { + _mesa_set_enable(ctx, GL_CLIP_PLANE0 + i, GL_FALSE); + } + if (ctx->Driver.ClipPlane) + ctx->Driver.ClipPlane( ctx, GL_CLIP_PLANE0 + i, eyePlane ); + } + + /* normalize/rescale */ + if (xform->Normalize != ctx->Transform.Normalize) + _mesa_set_enable(ctx, GL_NORMALIZE,ctx->Transform.Normalize); + if (xform->RescaleNormals != ctx->Transform.RescaleNormals) + _mesa_set_enable(ctx, GL_RESCALE_NORMAL_EXT, + ctx->Transform.RescaleNormals); + if (xform->DepthClamp != ctx->Transform.DepthClamp) + _mesa_set_enable(ctx, GL_DEPTH_CLAMP, + ctx->Transform.DepthClamp); + } + break; + case GL_TEXTURE_BIT: + /* Take care of texture object reference counters */ + { + struct texture_state *texstate + = (struct texture_state *) attr->data; + pop_texture_group(ctx, texstate); + ctx->NewState |= _NEW_TEXTURE; + } + break; + case GL_VIEWPORT_BIT: + { + const struct gl_viewport_attrib *vp; + vp = (const struct gl_viewport_attrib *) attr->data; + _mesa_Viewport(vp->X, vp->Y, vp->Width, vp->Height); + _mesa_DepthRange(vp->Near, vp->Far); + } + break; + case GL_MULTISAMPLE_BIT_ARB: + { + const struct gl_multisample_attrib *ms; + ms = (const struct gl_multisample_attrib *) attr->data; + _mesa_SampleCoverageARB(ms->SampleCoverageValue, + ms->SampleCoverageInvert); + } + break; + + default: + _mesa_problem( ctx, "Bad attrib flag in PopAttrib"); + break; + } + + next = attr->next; + FREE( attr->data ); + FREE( attr ); + attr = next; + } +} + + +/** + * Helper for incrementing/decrementing vertex buffer object reference + * counts when pushing/popping the GL_CLIENT_VERTEX_ARRAY_BIT attribute group. + */ +static void +adjust_buffer_object_ref_counts(struct gl_array_object *arrayObj, GLint step) +{ + GLuint i; + + arrayObj->Vertex.BufferObj->RefCount += step; + arrayObj->Weight.BufferObj->RefCount += step; + arrayObj->Normal.BufferObj->RefCount += step; + arrayObj->Color.BufferObj->RefCount += step; + arrayObj->SecondaryColor.BufferObj->RefCount += step; + arrayObj->FogCoord.BufferObj->RefCount += step; + arrayObj->Index.BufferObj->RefCount += step; + arrayObj->EdgeFlag.BufferObj->RefCount += step; + for (i = 0; i < Elements(arrayObj->TexCoord); i++) + arrayObj->TexCoord[i].BufferObj->RefCount += step; + for (i = 0; i < Elements(arrayObj->VertexAttrib); i++) + arrayObj->VertexAttrib[i].BufferObj->RefCount += step; +} + + +/** + * Copy gl_pixelstore_attrib from src to dst, updating buffer + * object refcounts. + */ +static void +copy_pixelstore(struct gl_context *ctx, + struct gl_pixelstore_attrib *dst, + const struct gl_pixelstore_attrib *src) +{ + dst->Alignment = src->Alignment; + dst->RowLength = src->RowLength; + dst->SkipPixels = src->SkipPixels; + dst->SkipRows = src->SkipRows; + dst->ImageHeight = src->ImageHeight; + dst->SkipImages = src->SkipImages; + dst->SwapBytes = src->SwapBytes; + dst->LsbFirst = src->LsbFirst; + dst->ClientStorage = src->ClientStorage; + dst->Invert = src->Invert; + _mesa_reference_buffer_object(ctx, &dst->BufferObj, src->BufferObj); +} + + +#define GL_CLIENT_PACK_BIT (1<<20) +#define GL_CLIENT_UNPACK_BIT (1<<21) + + +void GLAPIENTRY +_mesa_PushClientAttrib(GLbitfield mask) +{ + struct gl_attrib_node *head; + + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (ctx->ClientAttribStackDepth >= MAX_CLIENT_ATTRIB_STACK_DEPTH) { + _mesa_error( ctx, GL_STACK_OVERFLOW, "glPushClientAttrib" ); + return; + } + + /* Build linked list of attribute nodes which save all attribute + * groups specified by the mask. + */ + head = NULL; + + if (mask & GL_CLIENT_PIXEL_STORE_BIT) { + struct gl_pixelstore_attrib *attr; + /* packing attribs */ + attr = CALLOC_STRUCT( gl_pixelstore_attrib ); + copy_pixelstore(ctx, attr, &ctx->Pack); + save_attrib_data(&head, GL_CLIENT_PACK_BIT, attr); + /* unpacking attribs */ + attr = CALLOC_STRUCT( gl_pixelstore_attrib ); + copy_pixelstore(ctx, attr, &ctx->Unpack); + save_attrib_data(&head, GL_CLIENT_UNPACK_BIT, attr); + } + + if (mask & GL_CLIENT_VERTEX_ARRAY_BIT) { + struct gl_array_attrib *attr; + struct gl_array_object *obj; + + attr = MALLOC_STRUCT( gl_array_attrib ); + obj = MALLOC_STRUCT( gl_array_object ); + +#if FEATURE_ARB_vertex_buffer_object + /* increment ref counts since we're copying pointers to these objects */ + ctx->Array.ArrayBufferObj->RefCount++; + ctx->Array.ElementArrayBufferObj->RefCount++; +#endif + + memcpy( attr, &ctx->Array, sizeof(struct gl_array_attrib) ); + memcpy( obj, ctx->Array.ArrayObj, sizeof(struct gl_array_object) ); + + attr->ArrayObj = obj; + + save_attrib_data(&head, GL_CLIENT_VERTEX_ARRAY_BIT, attr); + + /* bump reference counts on buffer objects */ + adjust_buffer_object_ref_counts(ctx->Array.ArrayObj, 1); + } + + ctx->ClientAttribStack[ctx->ClientAttribStackDepth] = head; + ctx->ClientAttribStackDepth++; +} + + + + +void GLAPIENTRY +_mesa_PopClientAttrib(void) +{ + struct gl_attrib_node *node, *next; + + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + if (ctx->ClientAttribStackDepth == 0) { + _mesa_error( ctx, GL_STACK_UNDERFLOW, "glPopClientAttrib" ); + return; + } + + ctx->ClientAttribStackDepth--; + node = ctx->ClientAttribStack[ctx->ClientAttribStackDepth]; + + while (node) { + switch (node->kind) { + case GL_CLIENT_PACK_BIT: + { + struct gl_pixelstore_attrib *store = + (struct gl_pixelstore_attrib *) node->data; + copy_pixelstore(ctx, &ctx->Pack, store); + _mesa_reference_buffer_object(ctx, &store->BufferObj, NULL); + } + ctx->NewState |= _NEW_PACKUNPACK; + break; + case GL_CLIENT_UNPACK_BIT: + { + struct gl_pixelstore_attrib *store = + (struct gl_pixelstore_attrib *) node->data; + copy_pixelstore(ctx, &ctx->Unpack, store); + _mesa_reference_buffer_object(ctx, &store->BufferObj, NULL); + } + ctx->NewState |= _NEW_PACKUNPACK; + break; + case GL_CLIENT_VERTEX_ARRAY_BIT: { + struct gl_array_attrib * data = + (struct gl_array_attrib *) node->data; + + adjust_buffer_object_ref_counts(ctx->Array.ArrayObj, -1); + + ctx->Array.ActiveTexture = data->ActiveTexture; + if (data->LockCount != 0) + _mesa_LockArraysEXT(data->LockFirst, data->LockCount); + else if (ctx->Array.LockCount) + _mesa_UnlockArraysEXT(); + + _mesa_BindVertexArrayAPPLE( data->ArrayObj->Name ); + +#if FEATURE_ARB_vertex_buffer_object + _mesa_BindBufferARB(GL_ARRAY_BUFFER_ARB, + data->ArrayBufferObj->Name); + _mesa_BindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, + data->ElementArrayBufferObj->Name); +#endif + + memcpy( ctx->Array.ArrayObj, data->ArrayObj, + sizeof( struct gl_array_object ) ); + + FREE( data->ArrayObj ); + + /* FIXME: Should some bits in ctx->Array->NewState also be set + * FIXME: here? It seems like it should be set to inclusive-or + * FIXME: of the old ArrayObj->_Enabled and the new _Enabled. + */ + + ctx->NewState |= _NEW_ARRAY; + break; + } + default: + _mesa_problem( ctx, "Bad attrib flag in PopClientAttrib"); + break; + } + + next = node->next; + FREE( node->data ); + FREE( node ); + node = next; + } +} + + +void +_mesa_init_attrib_dispatch(struct _glapi_table *disp) +{ + SET_PopAttrib(disp, _mesa_PopAttrib); + SET_PushAttrib(disp, _mesa_PushAttrib); + SET_PopClientAttrib(disp, _mesa_PopClientAttrib); + SET_PushClientAttrib(disp, _mesa_PushClientAttrib); +} + + +#endif /* FEATURE_attrib_stack */ + + +/** + * Free any attribute state data that might be attached to the context. + */ +void +_mesa_free_attrib_data(struct gl_context *ctx) +{ + while (ctx->AttribStackDepth > 0) { + struct gl_attrib_node *attr, *next; + + ctx->AttribStackDepth--; + attr = ctx->AttribStack[ctx->AttribStackDepth]; + + while (attr) { + if (attr->kind == GL_TEXTURE_BIT) { + struct texture_state *texstate = (struct texture_state*)attr->data; + GLuint u, tgt; + /* clear references to the saved texture objects */ + for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { + for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++) { + _mesa_reference_texobj(&texstate->SavedTexRef[u][tgt], NULL); + } + } + } + else { + /* any other chunks of state that requires special handling? */ + } + + next = attr->next; + free(attr->data); + free(attr); + attr = next; + } + } +} + + +void _mesa_init_attrib( struct gl_context *ctx ) +{ + /* Renderer and client attribute stacks */ + ctx->AttribStackDepth = 0; + ctx->ClientAttribStackDepth = 0; +} diff --git a/mesalib/src/mesa/main/bufferobj.h b/mesalib/src/mesa/main/bufferobj.h index 7581b8e2c..f82e41411 100644 --- a/mesalib/src/mesa/main/bufferobj.h +++ b/mesalib/src/mesa/main/bufferobj.h @@ -1,159 +1,159 @@ -/* - * Mesa 3-D graphics library - * Version: 7.6 - * - * Copyright (C) 1999-2008 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. - */ - - - -#ifndef BUFFEROBJ_H -#define BUFFEROBJ_H - - -#include "mfeatures.h" -#include "mtypes.h" - - -/* - * Internal functions - */ - - -/** Is the given buffer object currently mapped? */ -static INLINE GLboolean -_mesa_bufferobj_mapped(const struct gl_buffer_object *obj) -{ - return obj->Pointer != NULL; -} - -/** - * Is the given buffer object a user-created buffer object? - * Mesa uses default buffer objects in several places. Default buffers - * always have Name==0. User created buffers have Name!=0. - */ -static INLINE GLboolean -_mesa_is_bufferobj(const struct gl_buffer_object *obj) -{ - return obj->Name != 0; -} - - -extern void -_mesa_init_buffer_objects( struct gl_context *ctx ); - -extern void -_mesa_free_buffer_objects( struct gl_context *ctx ); - -extern void -_mesa_update_default_objects_buffer_objects(struct gl_context *ctx); - - -extern struct gl_buffer_object * -_mesa_lookup_bufferobj(struct gl_context *ctx, GLuint buffer); - -extern void -_mesa_initialize_buffer_object( struct gl_buffer_object *obj, - GLuint name, GLenum target ); - -extern void -_mesa_reference_buffer_object_(struct gl_context *ctx, - struct gl_buffer_object **ptr, - struct gl_buffer_object *bufObj); - -static INLINE void -_mesa_reference_buffer_object(struct gl_context *ctx, - struct gl_buffer_object **ptr, - struct gl_buffer_object *bufObj) -{ - if (*ptr != bufObj) - _mesa_reference_buffer_object_(ctx, ptr, bufObj); -} - - -extern void -_mesa_init_buffer_object_functions(struct dd_function_table *driver); - - -/* - * API functions - */ - -extern void GLAPIENTRY -_mesa_BindBufferARB(GLenum target, GLuint buffer); - -extern void GLAPIENTRY -_mesa_DeleteBuffersARB(GLsizei n, const GLuint * buffer); - -extern void GLAPIENTRY -_mesa_GenBuffersARB(GLsizei n, GLuint * buffer); - -extern GLboolean GLAPIENTRY -_mesa_IsBufferARB(GLuint buffer); - -extern void GLAPIENTRY -_mesa_BufferDataARB(GLenum target, GLsizeiptrARB size, const GLvoid * data, GLenum usage); - -extern void GLAPIENTRY -_mesa_BufferSubDataARB(GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid * data); - -extern void GLAPIENTRY -_mesa_GetBufferSubDataARB(GLenum target, GLintptrARB offset, GLsizeiptrARB size, void * data); - -extern void * GLAPIENTRY -_mesa_MapBufferARB(GLenum target, GLenum access); - -extern GLboolean GLAPIENTRY -_mesa_UnmapBufferARB(GLenum target); - -extern void GLAPIENTRY -_mesa_GetBufferParameterivARB(GLenum target, GLenum pname, GLint *params); - -extern void GLAPIENTRY -_mesa_GetBufferParameteri64v(GLenum target, GLenum pname, GLint64 *params); - -extern void GLAPIENTRY -_mesa_GetBufferPointervARB(GLenum target, GLenum pname, GLvoid **params); - -extern void GLAPIENTRY -_mesa_CopyBufferSubData(GLenum readTarget, GLenum writeTarget, - GLintptr readOffset, GLintptr writeOffset, - GLsizeiptr size); - -extern void * GLAPIENTRY -_mesa_MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, - GLbitfield access); - -extern void GLAPIENTRY -_mesa_FlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length); - -#if FEATURE_APPLE_object_purgeable -extern GLenum GLAPIENTRY -_mesa_ObjectPurgeableAPPLE(GLenum objectType, GLuint name, GLenum option); - -extern GLenum GLAPIENTRY -_mesa_ObjectUnpurgeableAPPLE(GLenum objectType, GLuint name, GLenum option); - -extern void GLAPIENTRY -_mesa_GetObjectParameterivAPPLE(GLenum objectType, GLuint name, GLenum pname, GLint* params); -#endif - -#endif +/* + * Mesa 3-D graphics library + * Version: 7.6 + * + * Copyright (C) 1999-2008 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. + */ + + + +#ifndef BUFFEROBJ_H +#define BUFFEROBJ_H + + +#include "mfeatures.h" +#include "mtypes.h" + + +/* + * Internal functions + */ + + +/** Is the given buffer object currently mapped? */ +static INLINE GLboolean +_mesa_bufferobj_mapped(const struct gl_buffer_object *obj) +{ + return obj->Pointer != NULL; +} + +/** + * Is the given buffer object a user-created buffer object? + * Mesa uses default buffer objects in several places. Default buffers + * always have Name==0. User created buffers have Name!=0. + */ +static INLINE GLboolean +_mesa_is_bufferobj(const struct gl_buffer_object *obj) +{ + return obj->Name != 0; +} + + +extern void +_mesa_init_buffer_objects( struct gl_context *ctx ); + +extern void +_mesa_free_buffer_objects( struct gl_context *ctx ); + +extern void +_mesa_update_default_objects_buffer_objects(struct gl_context *ctx); + + +extern struct gl_buffer_object * +_mesa_lookup_bufferobj(struct gl_context *ctx, GLuint buffer); + +extern void +_mesa_initialize_buffer_object( struct gl_buffer_object *obj, + GLuint name, GLenum target ); + +extern void +_mesa_reference_buffer_object_(struct gl_context *ctx, + struct gl_buffer_object **ptr, + struct gl_buffer_object *bufObj); + +static INLINE void +_mesa_reference_buffer_object(struct gl_context *ctx, + struct gl_buffer_object **ptr, + struct gl_buffer_object *bufObj) +{ + if (*ptr != bufObj) + _mesa_reference_buffer_object_(ctx, ptr, bufObj); +} + + +extern void +_mesa_init_buffer_object_functions(struct dd_function_table *driver); + + +/* + * API functions + */ + +extern void GLAPIENTRY +_mesa_BindBufferARB(GLenum target, GLuint buffer); + +extern void GLAPIENTRY +_mesa_DeleteBuffersARB(GLsizei n, const GLuint * buffer); + +extern void GLAPIENTRY +_mesa_GenBuffersARB(GLsizei n, GLuint * buffer); + +extern GLboolean GLAPIENTRY +_mesa_IsBufferARB(GLuint buffer); + +extern void GLAPIENTRY +_mesa_BufferDataARB(GLenum target, GLsizeiptrARB size, const GLvoid * data, GLenum usage); + +extern void GLAPIENTRY +_mesa_BufferSubDataARB(GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid * data); + +extern void GLAPIENTRY +_mesa_GetBufferSubDataARB(GLenum target, GLintptrARB offset, GLsizeiptrARB size, void * data); + +extern void * GLAPIENTRY +_mesa_MapBufferARB(GLenum target, GLenum access); + +extern GLboolean GLAPIENTRY +_mesa_UnmapBufferARB(GLenum target); + +extern void GLAPIENTRY +_mesa_GetBufferParameterivARB(GLenum target, GLenum pname, GLint *params); + +extern void GLAPIENTRY +_mesa_GetBufferParameteri64v(GLenum target, GLenum pname, GLint64 *params); + +extern void GLAPIENTRY +_mesa_GetBufferPointervARB(GLenum target, GLenum pname, GLvoid **params); + +extern void GLAPIENTRY +_mesa_CopyBufferSubData(GLenum readTarget, GLenum writeTarget, + GLintptr readOffset, GLintptr writeOffset, + GLsizeiptr size); + +extern void * GLAPIENTRY +_mesa_MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, + GLbitfield access); + +extern void GLAPIENTRY +_mesa_FlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length); + +#if FEATURE_APPLE_object_purgeable +extern GLenum GLAPIENTRY +_mesa_ObjectPurgeableAPPLE(GLenum objectType, GLuint name, GLenum option); + +extern GLenum GLAPIENTRY +_mesa_ObjectUnpurgeableAPPLE(GLenum objectType, GLuint name, GLenum option); + +extern void GLAPIENTRY +_mesa_GetObjectParameterivAPPLE(GLenum objectType, GLuint name, GLenum pname, GLint* params); +#endif + +#endif diff --git a/mesalib/src/mesa/main/clear.c b/mesalib/src/mesa/main/clear.c index 449a8d6ec..fa95e4522 100644 --- a/mesalib/src/mesa/main/clear.c +++ b/mesalib/src/mesa/main/clear.c @@ -1,575 +1,575 @@ -/* - * 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. - */ - - -/** - * \file clear.c - * glClearColor, glClearIndex, glClear() functions. - */ - - - -#include "glheader.h" -#include "clear.h" -#include "context.h" -#include "colormac.h" -#include "enums.h" -#include "macros.h" -#include "mtypes.h" -#include "state.h" - - - -#if _HAVE_FULL_GL -void GLAPIENTRY -_mesa_ClearIndex( GLfloat c ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (ctx->Color.ClearIndex == (GLuint) c) - return; - - FLUSH_VERTICES(ctx, _NEW_COLOR); - ctx->Color.ClearIndex = (GLuint) c; -} -#endif - - -/** - * Specify the clear values for the color buffers. - * - * \param red red color component. - * \param green green color component. - * \param blue blue color component. - * \param alpha alpha component. - * - * \sa glClearColor(). - * - * Clamps the parameters and updates gl_colorbuffer_attrib::ClearColor. On a - * change, flushes the vertices and notifies the driver via the - * dd_function_table::ClearColor callback. - */ -void GLAPIENTRY -_mesa_ClearColor( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha ) -{ - GLfloat tmp[4]; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - tmp[0] = red; - tmp[1] = green; - tmp[2] = blue; - tmp[3] = alpha; - - if (TEST_EQ_4V(tmp, ctx->Color.ClearColorUnclamped)) - return; /* no change */ - - FLUSH_VERTICES(ctx, _NEW_COLOR); - COPY_4V(ctx->Color.ClearColorUnclamped, tmp); - - ctx->Color.ClearColor[0] = CLAMP(tmp[0], 0.0F, 1.0F); - ctx->Color.ClearColor[1] = CLAMP(tmp[1], 0.0F, 1.0F); - ctx->Color.ClearColor[2] = CLAMP(tmp[2], 0.0F, 1.0F); - ctx->Color.ClearColor[3] = CLAMP(tmp[3], 0.0F, 1.0F); - - if (ctx->Driver.ClearColor) { - /* it's OK to call glClearColor in CI mode but it should be a NOP */ - /* we pass the clamped color, since all drivers that need this don't - * support GL_ARB_color_buffer_float - */ - (*ctx->Driver.ClearColor)(ctx, ctx->Color.ClearColor); - } -} - - -/** - * GL_EXT_texture_integer - */ -void GLAPIENTRY -_mesa_ClearColorIiEXT(GLint r, GLint g, GLint b, GLint a) -{ - GLfloat tmp[4]; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - tmp[0] = (GLfloat) r; - tmp[1] = (GLfloat) g; - tmp[2] = (GLfloat) b; - tmp[3] = (GLfloat) a; - - if (TEST_EQ_4V(tmp, ctx->Color.ClearColor)) - return; /* no change */ - - FLUSH_VERTICES(ctx, _NEW_COLOR); - - /* XXX we should eventually have a float/int/uint union for - * the ctx->Color.ClearColor state. - */ - COPY_4V(ctx->Color.ClearColor, tmp); - - if (ctx->Driver.ClearColor) { - ctx->Driver.ClearColor(ctx, ctx->Color.ClearColor); - } -} - - -/** - * GL_EXT_texture_integer - */ -void GLAPIENTRY -_mesa_ClearColorIuiEXT(GLuint r, GLuint g, GLuint b, GLuint a) -{ - GLfloat tmp[4]; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - tmp[0] = (GLfloat) r; - tmp[1] = (GLfloat) g; - tmp[2] = (GLfloat) b; - tmp[3] = (GLfloat) a; - - if (TEST_EQ_4V(tmp, ctx->Color.ClearColor)) - return; /* no change */ - - FLUSH_VERTICES(ctx, _NEW_COLOR); - - /* XXX we should eventually have a float/int/uint union for - * the ctx->Color.ClearColor state. - */ - COPY_4V(ctx->Color.ClearColor, tmp); - - if (ctx->Driver.ClearColor) { - ctx->Driver.ClearColor(ctx, ctx->Color.ClearColor); - } -} - - -/** - * Clear buffers. - * - * \param mask bit-mask indicating the buffers to be cleared. - * - * Flushes the vertices and verifies the parameter. If __struct gl_contextRec::NewState - * is set then calls _mesa_update_state() to update gl_frame_buffer::_Xmin, - * etc. If the rasterization mode is set to GL_RENDER then requests the driver - * to clear the buffers, via the dd_function_table::Clear callback. - */ -void GLAPIENTRY -_mesa_Clear( GLbitfield mask ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - FLUSH_CURRENT(ctx, 0); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glClear 0x%x\n", mask); - - if (mask & ~(GL_COLOR_BUFFER_BIT | - GL_DEPTH_BUFFER_BIT | - GL_STENCIL_BUFFER_BIT | - GL_ACCUM_BUFFER_BIT)) { - /* invalid bit set */ - _mesa_error( ctx, GL_INVALID_VALUE, "glClear(0x%x)", mask); - return; - } - - if (ctx->NewState) { - _mesa_update_state( ctx ); /* update _Xmin, etc */ - } - - if (ctx->DrawBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) { - _mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION_EXT, - "glClear(incomplete framebuffer)"); - return; - } - - if (ctx->DrawBuffer->Width == 0 || ctx->DrawBuffer->Height == 0 || - ctx->DrawBuffer->_Xmin >= ctx->DrawBuffer->_Xmax || - ctx->DrawBuffer->_Ymin >= ctx->DrawBuffer->_Ymax) - return; - - if (ctx->RenderMode == GL_RENDER) { - GLbitfield bufferMask; - - /* don't clear depth buffer if depth writing disabled */ - if (!ctx->Depth.Mask) - mask &= ~GL_DEPTH_BUFFER_BIT; - - /* Build the bitmask to send to device driver's Clear function. - * Note that the GL_COLOR_BUFFER_BIT flag will expand to 0, 1, 2 or 4 - * of the BUFFER_BIT_FRONT/BACK_LEFT/RIGHT flags, or one of the - * BUFFER_BIT_COLORn flags. - */ - bufferMask = 0; - if (mask & GL_COLOR_BUFFER_BIT) { - GLuint i; - for (i = 0; i < ctx->DrawBuffer->_NumColorDrawBuffers; i++) { - bufferMask |= (1 << ctx->DrawBuffer->_ColorDrawBufferIndexes[i]); - } - } - - if ((mask & GL_DEPTH_BUFFER_BIT) - && ctx->DrawBuffer->Visual.haveDepthBuffer) { - bufferMask |= BUFFER_BIT_DEPTH; - } - - if ((mask & GL_STENCIL_BUFFER_BIT) - && ctx->DrawBuffer->Visual.haveStencilBuffer) { - bufferMask |= BUFFER_BIT_STENCIL; - } - - if ((mask & GL_ACCUM_BUFFER_BIT) - && ctx->DrawBuffer->Visual.haveAccumBuffer) { - bufferMask |= BUFFER_BIT_ACCUM; - } - - ASSERT(ctx->Driver.Clear); - ctx->Driver.Clear(ctx, bufferMask); - } -} - - -/** Returned by make_color_buffer_mask() for errors */ -#define INVALID_MASK ~0x0 - - -/** - * Convert the glClearBuffer 'drawbuffer' parameter into a bitmask of - * BUFFER_BIT_x values. - * Return INVALID_MASK if the drawbuffer value is invalid. - */ -static GLbitfield -make_color_buffer_mask(struct gl_context *ctx, GLint drawbuffer) -{ - const struct gl_renderbuffer_attachment *att = ctx->DrawBuffer->Attachment; - GLbitfield mask = 0x0; - - switch (drawbuffer) { - case GL_FRONT: - if (att[BUFFER_FRONT_LEFT].Renderbuffer) - mask |= BUFFER_BIT_FRONT_LEFT; - if (att[BUFFER_FRONT_RIGHT].Renderbuffer) - mask |= BUFFER_BIT_FRONT_RIGHT; - break; - case GL_BACK: - if (att[BUFFER_BACK_LEFT].Renderbuffer) - mask |= BUFFER_BIT_BACK_LEFT; - if (att[BUFFER_BACK_RIGHT].Renderbuffer) - mask |= BUFFER_BIT_BACK_RIGHT; - break; - case GL_LEFT: - if (att[BUFFER_FRONT_LEFT].Renderbuffer) - mask |= BUFFER_BIT_FRONT_LEFT; - if (att[BUFFER_BACK_LEFT].Renderbuffer) - mask |= BUFFER_BIT_BACK_LEFT; - break; - case GL_RIGHT: - if (att[BUFFER_FRONT_RIGHT].Renderbuffer) - mask |= BUFFER_BIT_FRONT_RIGHT; - if (att[BUFFER_BACK_RIGHT].Renderbuffer) - mask |= BUFFER_BIT_BACK_RIGHT; - break; - case GL_FRONT_AND_BACK: - if (att[BUFFER_FRONT_LEFT].Renderbuffer) - mask |= BUFFER_BIT_FRONT_LEFT; - if (att[BUFFER_BACK_LEFT].Renderbuffer) - mask |= BUFFER_BIT_BACK_LEFT; - if (att[BUFFER_FRONT_RIGHT].Renderbuffer) - mask |= BUFFER_BIT_FRONT_RIGHT; - if (att[BUFFER_BACK_RIGHT].Renderbuffer) - mask |= BUFFER_BIT_BACK_RIGHT; - break; - default: - if (drawbuffer < 0 || drawbuffer >= (GLint)ctx->Const.MaxDrawBuffers) { - mask = INVALID_MASK; - } - else if (att[BUFFER_COLOR0 + drawbuffer].Renderbuffer) { - mask |= (BUFFER_BIT_COLOR0 << drawbuffer); - } - } - - return mask; -} - - - -/** - * New in GL 3.0 - * Clear signed integer color buffer or stencil buffer (not depth). - */ -void GLAPIENTRY -_mesa_ClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint *value) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - FLUSH_CURRENT(ctx, 0); - - if (ctx->NewState) { - _mesa_update_state( ctx ); - } - - switch (buffer) { - case GL_STENCIL: - if (drawbuffer != 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glClearBufferiv(drawbuffer=%d)", - drawbuffer); - return; - } - else { - /* Save current stencil clear value, set to 'value', do the - * stencil clear and restore the clear value. - * XXX in the future we may have a new ctx->Driver.ClearBuffer() - * hook instead. - */ - const GLuint clearSave = ctx->Stencil.Clear; - ctx->Stencil.Clear = *value; - if (ctx->Driver.ClearStencil) - ctx->Driver.ClearStencil(ctx, *value); - ctx->Driver.Clear(ctx, BUFFER_BIT_STENCIL); - ctx->Stencil.Clear = clearSave; - if (ctx->Driver.ClearStencil) - ctx->Driver.ClearStencil(ctx, clearSave); - } - break; - case GL_COLOR: - { - const GLbitfield mask = make_color_buffer_mask(ctx, drawbuffer); - if (mask == INVALID_MASK) { - _mesa_error(ctx, GL_INVALID_VALUE, "glClearBufferiv(drawbuffer=%d)", - drawbuffer); - return; - } - else if (mask) { - /* XXX note: we're putting the integer clear values into the - * floating point state var. This will not always work. We'll - * need a new ctx->Driver.ClearBuffer() hook.... - */ - GLclampf clearSave[4]; - /* save color */ - COPY_4V(clearSave, ctx->Color.ClearColor); - /* set color */ - COPY_4V_CAST(ctx->Color.ClearColor, value, GLclampf); - if (ctx->Driver.ClearColor) - ctx->Driver.ClearColor(ctx, ctx->Color.ClearColor); - /* clear buffer(s) */ - ctx->Driver.Clear(ctx, mask); - /* restore color */ - COPY_4V(ctx->Color.ClearColor, clearSave); - if (ctx->Driver.ClearColor) - ctx->Driver.ClearColor(ctx, clearSave); - } - } - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glClearBufferiv(buffer=%s)", - _mesa_lookup_enum_by_nr(buffer)); - return; - } -} - - -/** - * New in GL 3.0 - * Clear unsigned integer color buffer (not depth, not stencil). - */ -void GLAPIENTRY -_mesa_ClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint *value) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - FLUSH_CURRENT(ctx, 0); - - if (ctx->NewState) { - _mesa_update_state( ctx ); - } - - switch (buffer) { - case GL_COLOR: - { - const GLbitfield mask = make_color_buffer_mask(ctx, drawbuffer); - if (mask == INVALID_MASK) { - _mesa_error(ctx, GL_INVALID_VALUE, "glClearBufferuiv(drawbuffer=%d)", - drawbuffer); - return; - } - else if (mask) { - /* XXX note: we're putting the uint clear values into the - * floating point state var. This will not always work. We'll - * need a new ctx->Driver.ClearBuffer() hook.... - */ - GLclampf clearSave[4]; - /* save color */ - COPY_4V(clearSave, ctx->Color.ClearColor); - /* set color */ - COPY_4V_CAST(ctx->Color.ClearColor, value, GLclampf); - if (ctx->Driver.ClearColor) - ctx->Driver.ClearColor(ctx, ctx->Color.ClearColor); - /* clear buffer(s) */ - ctx->Driver.Clear(ctx, mask); - /* restore color */ - COPY_4V(ctx->Color.ClearColor, clearSave); - if (ctx->Driver.ClearColor) - ctx->Driver.ClearColor(ctx, clearSave); - } - } - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glClearBufferuiv(buffer=%s)", - _mesa_lookup_enum_by_nr(buffer)); - return; - } -} - - -/** - * New in GL 3.0 - * Clear fixed-pt or float color buffer or depth buffer (not stencil). - */ -void GLAPIENTRY -_mesa_ClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat *value) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - FLUSH_CURRENT(ctx, 0); - - if (ctx->NewState) { - _mesa_update_state( ctx ); - } - - switch (buffer) { - case GL_DEPTH: - if (drawbuffer != 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glClearBufferfv(drawbuffer=%d)", - drawbuffer); - return; - } - else { - /* Save current depth clear value, set to 'value', do the - * depth clear and restore the clear value. - * XXX in the future we may have a new ctx->Driver.ClearBuffer() - * hook instead. - */ - const GLclampd clearSave = ctx->Depth.Clear; - ctx->Depth.Clear = *value; - if (ctx->Driver.ClearDepth) - ctx->Driver.ClearDepth(ctx, *value); - ctx->Driver.Clear(ctx, BUFFER_BIT_DEPTH); - ctx->Depth.Clear = clearSave; - if (ctx->Driver.ClearDepth) - ctx->Driver.ClearDepth(ctx, clearSave); - } - /* clear depth buffer to value */ - break; - case GL_COLOR: - { - const GLbitfield mask = make_color_buffer_mask(ctx, drawbuffer); - if (mask == INVALID_MASK) { - _mesa_error(ctx, GL_INVALID_VALUE, "glClearBufferfv(drawbuffer=%d)", - drawbuffer); - return; - } - else if (mask) { - GLclampf clearSave[4]; - /* save color */ - COPY_4V(clearSave, ctx->Color.ClearColor); - /* set color */ - COPY_4V_CAST(ctx->Color.ClearColor, value, GLclampf); - if (ctx->Driver.ClearColor) - ctx->Driver.ClearColor(ctx, ctx->Color.ClearColor); - /* clear buffer(s) */ - ctx->Driver.Clear(ctx, mask); - /* restore color */ - COPY_4V(ctx->Color.ClearColor, clearSave); - if (ctx->Driver.ClearColor) - ctx->Driver.ClearColor(ctx, clearSave); - } - } - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glClearBufferfv(buffer=%s)", - _mesa_lookup_enum_by_nr(buffer)); - return; - } -} - - -/** - * New in GL 3.0 - * Clear depth/stencil buffer only. - */ -void GLAPIENTRY -_mesa_ClearBufferfi(GLenum buffer, GLint drawbuffer, - GLfloat depth, GLint stencil) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - FLUSH_CURRENT(ctx, 0); - - if (buffer != GL_DEPTH_STENCIL) { - _mesa_error(ctx, GL_INVALID_ENUM, "glClearBufferfi(buffer=%s)", - _mesa_lookup_enum_by_nr(buffer)); - return; - } - - if (drawbuffer != 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glClearBufferfi(drawbuffer=%d)", - drawbuffer); - return; - } - - if (ctx->NewState) { - _mesa_update_state( ctx ); - } - - { - /* save current clear values */ - const GLclampd clearDepthSave = ctx->Depth.Clear; - const GLuint clearStencilSave = ctx->Stencil.Clear; - - /* set new clear values */ - ctx->Depth.Clear = depth; - ctx->Stencil.Clear = stencil; - if (ctx->Driver.ClearDepth) - ctx->Driver.ClearDepth(ctx, depth); - if (ctx->Driver.ClearStencil) - ctx->Driver.ClearStencil(ctx, stencil); - - /* clear buffers */ - ctx->Driver.Clear(ctx, BUFFER_BIT_DEPTH | BUFFER_BIT_STENCIL); - - /* restore */ - ctx->Depth.Clear = clearDepthSave; - ctx->Stencil.Clear = clearStencilSave; - if (ctx->Driver.ClearDepth) - ctx->Driver.ClearDepth(ctx, clearDepthSave); - if (ctx->Driver.ClearStencil) - ctx->Driver.ClearStencil(ctx, clearStencilSave); - } -} +/* + * 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. + */ + + +/** + * \file clear.c + * glClearColor, glClearIndex, glClear() functions. + */ + + + +#include "glheader.h" +#include "clear.h" +#include "context.h" +#include "colormac.h" +#include "enums.h" +#include "macros.h" +#include "mtypes.h" +#include "state.h" + + + +#if _HAVE_FULL_GL +void GLAPIENTRY +_mesa_ClearIndex( GLfloat c ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (ctx->Color.ClearIndex == (GLuint) c) + return; + + FLUSH_VERTICES(ctx, _NEW_COLOR); + ctx->Color.ClearIndex = (GLuint) c; +} +#endif + + +/** + * Specify the clear values for the color buffers. + * + * \param red red color component. + * \param green green color component. + * \param blue blue color component. + * \param alpha alpha component. + * + * \sa glClearColor(). + * + * Clamps the parameters and updates gl_colorbuffer_attrib::ClearColor. On a + * change, flushes the vertices and notifies the driver via the + * dd_function_table::ClearColor callback. + */ +void GLAPIENTRY +_mesa_ClearColor( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha ) +{ + GLfloat tmp[4]; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + tmp[0] = red; + tmp[1] = green; + tmp[2] = blue; + tmp[3] = alpha; + + if (TEST_EQ_4V(tmp, ctx->Color.ClearColorUnclamped)) + return; /* no change */ + + FLUSH_VERTICES(ctx, _NEW_COLOR); + COPY_4V(ctx->Color.ClearColorUnclamped, tmp); + + ctx->Color.ClearColor[0] = CLAMP(tmp[0], 0.0F, 1.0F); + ctx->Color.ClearColor[1] = CLAMP(tmp[1], 0.0F, 1.0F); + ctx->Color.ClearColor[2] = CLAMP(tmp[2], 0.0F, 1.0F); + ctx->Color.ClearColor[3] = CLAMP(tmp[3], 0.0F, 1.0F); + + if (ctx->Driver.ClearColor) { + /* it's OK to call glClearColor in CI mode but it should be a NOP */ + /* we pass the clamped color, since all drivers that need this don't + * support GL_ARB_color_buffer_float + */ + (*ctx->Driver.ClearColor)(ctx, ctx->Color.ClearColor); + } +} + + +/** + * GL_EXT_texture_integer + */ +void GLAPIENTRY +_mesa_ClearColorIiEXT(GLint r, GLint g, GLint b, GLint a) +{ + GLfloat tmp[4]; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + tmp[0] = (GLfloat) r; + tmp[1] = (GLfloat) g; + tmp[2] = (GLfloat) b; + tmp[3] = (GLfloat) a; + + if (TEST_EQ_4V(tmp, ctx->Color.ClearColor)) + return; /* no change */ + + FLUSH_VERTICES(ctx, _NEW_COLOR); + + /* XXX we should eventually have a float/int/uint union for + * the ctx->Color.ClearColor state. + */ + COPY_4V(ctx->Color.ClearColor, tmp); + + if (ctx->Driver.ClearColor) { + ctx->Driver.ClearColor(ctx, ctx->Color.ClearColor); + } +} + + +/** + * GL_EXT_texture_integer + */ +void GLAPIENTRY +_mesa_ClearColorIuiEXT(GLuint r, GLuint g, GLuint b, GLuint a) +{ + GLfloat tmp[4]; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + tmp[0] = (GLfloat) r; + tmp[1] = (GLfloat) g; + tmp[2] = (GLfloat) b; + tmp[3] = (GLfloat) a; + + if (TEST_EQ_4V(tmp, ctx->Color.ClearColor)) + return; /* no change */ + + FLUSH_VERTICES(ctx, _NEW_COLOR); + + /* XXX we should eventually have a float/int/uint union for + * the ctx->Color.ClearColor state. + */ + COPY_4V(ctx->Color.ClearColor, tmp); + + if (ctx->Driver.ClearColor) { + ctx->Driver.ClearColor(ctx, ctx->Color.ClearColor); + } +} + + +/** + * Clear buffers. + * + * \param mask bit-mask indicating the buffers to be cleared. + * + * Flushes the vertices and verifies the parameter. If __struct gl_contextRec::NewState + * is set then calls _mesa_update_state() to update gl_frame_buffer::_Xmin, + * etc. If the rasterization mode is set to GL_RENDER then requests the driver + * to clear the buffers, via the dd_function_table::Clear callback. + */ +void GLAPIENTRY +_mesa_Clear( GLbitfield mask ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + FLUSH_CURRENT(ctx, 0); + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glClear 0x%x\n", mask); + + if (mask & ~(GL_COLOR_BUFFER_BIT | + GL_DEPTH_BUFFER_BIT | + GL_STENCIL_BUFFER_BIT | + GL_ACCUM_BUFFER_BIT)) { + /* invalid bit set */ + _mesa_error( ctx, GL_INVALID_VALUE, "glClear(0x%x)", mask); + return; + } + + if (ctx->NewState) { + _mesa_update_state( ctx ); /* update _Xmin, etc */ + } + + if (ctx->DrawBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) { + _mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION_EXT, + "glClear(incomplete framebuffer)"); + return; + } + + if (ctx->DrawBuffer->Width == 0 || ctx->DrawBuffer->Height == 0 || + ctx->DrawBuffer->_Xmin >= ctx->DrawBuffer->_Xmax || + ctx->DrawBuffer->_Ymin >= ctx->DrawBuffer->_Ymax) + return; + + if (ctx->RenderMode == GL_RENDER) { + GLbitfield bufferMask; + + /* don't clear depth buffer if depth writing disabled */ + if (!ctx->Depth.Mask) + mask &= ~GL_DEPTH_BUFFER_BIT; + + /* Build the bitmask to send to device driver's Clear function. + * Note that the GL_COLOR_BUFFER_BIT flag will expand to 0, 1, 2 or 4 + * of the BUFFER_BIT_FRONT/BACK_LEFT/RIGHT flags, or one of the + * BUFFER_BIT_COLORn flags. + */ + bufferMask = 0; + if (mask & GL_COLOR_BUFFER_BIT) { + GLuint i; + for (i = 0; i < ctx->DrawBuffer->_NumColorDrawBuffers; i++) { + bufferMask |= (1 << ctx->DrawBuffer->_ColorDrawBufferIndexes[i]); + } + } + + if ((mask & GL_DEPTH_BUFFER_BIT) + && ctx->DrawBuffer->Visual.haveDepthBuffer) { + bufferMask |= BUFFER_BIT_DEPTH; + } + + if ((mask & GL_STENCIL_BUFFER_BIT) + && ctx->DrawBuffer->Visual.haveStencilBuffer) { + bufferMask |= BUFFER_BIT_STENCIL; + } + + if ((mask & GL_ACCUM_BUFFER_BIT) + && ctx->DrawBuffer->Visual.haveAccumBuffer) { + bufferMask |= BUFFER_BIT_ACCUM; + } + + ASSERT(ctx->Driver.Clear); + ctx->Driver.Clear(ctx, bufferMask); + } +} + + +/** Returned by make_color_buffer_mask() for errors */ +#define INVALID_MASK ~0x0 + + +/** + * Convert the glClearBuffer 'drawbuffer' parameter into a bitmask of + * BUFFER_BIT_x values. + * Return INVALID_MASK if the drawbuffer value is invalid. + */ +static GLbitfield +make_color_buffer_mask(struct gl_context *ctx, GLint drawbuffer) +{ + const struct gl_renderbuffer_attachment *att = ctx->DrawBuffer->Attachment; + GLbitfield mask = 0x0; + + switch (drawbuffer) { + case GL_FRONT: + if (att[BUFFER_FRONT_LEFT].Renderbuffer) + mask |= BUFFER_BIT_FRONT_LEFT; + if (att[BUFFER_FRONT_RIGHT].Renderbuffer) + mask |= BUFFER_BIT_FRONT_RIGHT; + break; + case GL_BACK: + if (att[BUFFER_BACK_LEFT].Renderbuffer) + mask |= BUFFER_BIT_BACK_LEFT; + if (att[BUFFER_BACK_RIGHT].Renderbuffer) + mask |= BUFFER_BIT_BACK_RIGHT; + break; + case GL_LEFT: + if (att[BUFFER_FRONT_LEFT].Renderbuffer) + mask |= BUFFER_BIT_FRONT_LEFT; + if (att[BUFFER_BACK_LEFT].Renderbuffer) + mask |= BUFFER_BIT_BACK_LEFT; + break; + case GL_RIGHT: + if (att[BUFFER_FRONT_RIGHT].Renderbuffer) + mask |= BUFFER_BIT_FRONT_RIGHT; + if (att[BUFFER_BACK_RIGHT].Renderbuffer) + mask |= BUFFER_BIT_BACK_RIGHT; + break; + case GL_FRONT_AND_BACK: + if (att[BUFFER_FRONT_LEFT].Renderbuffer) + mask |= BUFFER_BIT_FRONT_LEFT; + if (att[BUFFER_BACK_LEFT].Renderbuffer) + mask |= BUFFER_BIT_BACK_LEFT; + if (att[BUFFER_FRONT_RIGHT].Renderbuffer) + mask |= BUFFER_BIT_FRONT_RIGHT; + if (att[BUFFER_BACK_RIGHT].Renderbuffer) + mask |= BUFFER_BIT_BACK_RIGHT; + break; + default: + if (drawbuffer < 0 || drawbuffer >= (GLint)ctx->Const.MaxDrawBuffers) { + mask = INVALID_MASK; + } + else if (att[BUFFER_COLOR0 + drawbuffer].Renderbuffer) { + mask |= (BUFFER_BIT_COLOR0 << drawbuffer); + } + } + + return mask; +} + + + +/** + * New in GL 3.0 + * Clear signed integer color buffer or stencil buffer (not depth). + */ +void GLAPIENTRY +_mesa_ClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint *value) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + FLUSH_CURRENT(ctx, 0); + + if (ctx->NewState) { + _mesa_update_state( ctx ); + } + + switch (buffer) { + case GL_STENCIL: + if (drawbuffer != 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glClearBufferiv(drawbuffer=%d)", + drawbuffer); + return; + } + else { + /* Save current stencil clear value, set to 'value', do the + * stencil clear and restore the clear value. + * XXX in the future we may have a new ctx->Driver.ClearBuffer() + * hook instead. + */ + const GLuint clearSave = ctx->Stencil.Clear; + ctx->Stencil.Clear = *value; + if (ctx->Driver.ClearStencil) + ctx->Driver.ClearStencil(ctx, *value); + ctx->Driver.Clear(ctx, BUFFER_BIT_STENCIL); + ctx->Stencil.Clear = clearSave; + if (ctx->Driver.ClearStencil) + ctx->Driver.ClearStencil(ctx, clearSave); + } + break; + case GL_COLOR: + { + const GLbitfield mask = make_color_buffer_mask(ctx, drawbuffer); + if (mask == INVALID_MASK) { + _mesa_error(ctx, GL_INVALID_VALUE, "glClearBufferiv(drawbuffer=%d)", + drawbuffer); + return; + } + else if (mask) { + /* XXX note: we're putting the integer clear values into the + * floating point state var. This will not always work. We'll + * need a new ctx->Driver.ClearBuffer() hook.... + */ + GLclampf clearSave[4]; + /* save color */ + COPY_4V(clearSave, ctx->Color.ClearColor); + /* set color */ + COPY_4V_CAST(ctx->Color.ClearColor, value, GLclampf); + if (ctx->Driver.ClearColor) + ctx->Driver.ClearColor(ctx, ctx->Color.ClearColor); + /* clear buffer(s) */ + ctx->Driver.Clear(ctx, mask); + /* restore color */ + COPY_4V(ctx->Color.ClearColor, clearSave); + if (ctx->Driver.ClearColor) + ctx->Driver.ClearColor(ctx, clearSave); + } + } + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, "glClearBufferiv(buffer=%s)", + _mesa_lookup_enum_by_nr(buffer)); + return; + } +} + + +/** + * New in GL 3.0 + * Clear unsigned integer color buffer (not depth, not stencil). + */ +void GLAPIENTRY +_mesa_ClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint *value) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + FLUSH_CURRENT(ctx, 0); + + if (ctx->NewState) { + _mesa_update_state( ctx ); + } + + switch (buffer) { + case GL_COLOR: + { + const GLbitfield mask = make_color_buffer_mask(ctx, drawbuffer); + if (mask == INVALID_MASK) { + _mesa_error(ctx, GL_INVALID_VALUE, "glClearBufferuiv(drawbuffer=%d)", + drawbuffer); + return; + } + else if (mask) { + /* XXX note: we're putting the uint clear values into the + * floating point state var. This will not always work. We'll + * need a new ctx->Driver.ClearBuffer() hook.... + */ + GLclampf clearSave[4]; + /* save color */ + COPY_4V(clearSave, ctx->Color.ClearColor); + /* set color */ + COPY_4V_CAST(ctx->Color.ClearColor, value, GLclampf); + if (ctx->Driver.ClearColor) + ctx->Driver.ClearColor(ctx, ctx->Color.ClearColor); + /* clear buffer(s) */ + ctx->Driver.Clear(ctx, mask); + /* restore color */ + COPY_4V(ctx->Color.ClearColor, clearSave); + if (ctx->Driver.ClearColor) + ctx->Driver.ClearColor(ctx, clearSave); + } + } + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, "glClearBufferuiv(buffer=%s)", + _mesa_lookup_enum_by_nr(buffer)); + return; + } +} + + +/** + * New in GL 3.0 + * Clear fixed-pt or float color buffer or depth buffer (not stencil). + */ +void GLAPIENTRY +_mesa_ClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat *value) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + FLUSH_CURRENT(ctx, 0); + + if (ctx->NewState) { + _mesa_update_state( ctx ); + } + + switch (buffer) { + case GL_DEPTH: + if (drawbuffer != 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glClearBufferfv(drawbuffer=%d)", + drawbuffer); + return; + } + else { + /* Save current depth clear value, set to 'value', do the + * depth clear and restore the clear value. + * XXX in the future we may have a new ctx->Driver.ClearBuffer() + * hook instead. + */ + const GLclampd clearSave = ctx->Depth.Clear; + ctx->Depth.Clear = *value; + if (ctx->Driver.ClearDepth) + ctx->Driver.ClearDepth(ctx, *value); + ctx->Driver.Clear(ctx, BUFFER_BIT_DEPTH); + ctx->Depth.Clear = clearSave; + if (ctx->Driver.ClearDepth) + ctx->Driver.ClearDepth(ctx, clearSave); + } + /* clear depth buffer to value */ + break; + case GL_COLOR: + { + const GLbitfield mask = make_color_buffer_mask(ctx, drawbuffer); + if (mask == INVALID_MASK) { + _mesa_error(ctx, GL_INVALID_VALUE, "glClearBufferfv(drawbuffer=%d)", + drawbuffer); + return; + } + else if (mask) { + GLclampf clearSave[4]; + /* save color */ + COPY_4V(clearSave, ctx->Color.ClearColor); + /* set color */ + COPY_4V_CAST(ctx->Color.ClearColor, value, GLclampf); + if (ctx->Driver.ClearColor) + ctx->Driver.ClearColor(ctx, ctx->Color.ClearColor); + /* clear buffer(s) */ + ctx->Driver.Clear(ctx, mask); + /* restore color */ + COPY_4V(ctx->Color.ClearColor, clearSave); + if (ctx->Driver.ClearColor) + ctx->Driver.ClearColor(ctx, clearSave); + } + } + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, "glClearBufferfv(buffer=%s)", + _mesa_lookup_enum_by_nr(buffer)); + return; + } +} + + +/** + * New in GL 3.0 + * Clear depth/stencil buffer only. + */ +void GLAPIENTRY +_mesa_ClearBufferfi(GLenum buffer, GLint drawbuffer, + GLfloat depth, GLint stencil) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + FLUSH_CURRENT(ctx, 0); + + if (buffer != GL_DEPTH_STENCIL) { + _mesa_error(ctx, GL_INVALID_ENUM, "glClearBufferfi(buffer=%s)", + _mesa_lookup_enum_by_nr(buffer)); + return; + } + + if (drawbuffer != 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glClearBufferfi(drawbuffer=%d)", + drawbuffer); + return; + } + + if (ctx->NewState) { + _mesa_update_state( ctx ); + } + + { + /* save current clear values */ + const GLclampd clearDepthSave = ctx->Depth.Clear; + const GLuint clearStencilSave = ctx->Stencil.Clear; + + /* set new clear values */ + ctx->Depth.Clear = depth; + ctx->Stencil.Clear = stencil; + if (ctx->Driver.ClearDepth) + ctx->Driver.ClearDepth(ctx, depth); + if (ctx->Driver.ClearStencil) + ctx->Driver.ClearStencil(ctx, stencil); + + /* clear buffers */ + ctx->Driver.Clear(ctx, BUFFER_BIT_DEPTH | BUFFER_BIT_STENCIL); + + /* restore */ + ctx->Depth.Clear = clearDepthSave; + ctx->Stencil.Clear = clearStencilSave; + if (ctx->Driver.ClearDepth) + ctx->Driver.ClearDepth(ctx, clearDepthSave); + if (ctx->Driver.ClearStencil) + ctx->Driver.ClearStencil(ctx, clearStencilSave); + } +} diff --git a/mesalib/src/mesa/main/colortab.c b/mesalib/src/mesa/main/colortab.c index 5b12f9ff3..f20dee677 100644 --- a/mesalib/src/mesa/main/colortab.c +++ b/mesalib/src/mesa/main/colortab.c @@ -1,169 +1,169 @@ -/* - * 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 "glheader.h" -#include "bufferobj.h" -#include "colortab.h" -#include "context.h" -#include "image.h" -#include "macros.h" -#include "mfeatures.h" -#include "mtypes.h" -#include "pack.h" -#include "pbo.h" -#include "state.h" -#include "teximage.h" -#include "texstate.h" -#include "main/dispatch.h" - - -#if FEATURE_colortable - -void GLAPIENTRY -_mesa_ColorTable( GLenum target, GLenum internalFormat, - GLsizei width, GLenum format, GLenum type, - const GLvoid *data ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - _mesa_error(ctx, GL_INVALID_ENUM, "glColorTable(target)"); -} - - - -void GLAPIENTRY -_mesa_ColorSubTable( GLenum target, GLsizei start, - GLsizei count, GLenum format, GLenum type, - const GLvoid *data ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - _mesa_error(ctx, GL_INVALID_ENUM, "glColorSubTable(target)"); -} - - - -static void GLAPIENTRY -_mesa_CopyColorTable(GLenum target, GLenum internalformat, - GLint x, GLint y, GLsizei width) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - _mesa_error(ctx, GL_INVALID_ENUM, "glCopyColorTable(target)"); -} - - - -static void GLAPIENTRY -_mesa_CopyColorSubTable(GLenum target, GLsizei start, - GLint x, GLint y, GLsizei width) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - _mesa_error(ctx, GL_INVALID_ENUM, "glCopyColorSubTable(target)"); -} - - - -static void GLAPIENTRY -_mesa_GetnColorTableARB( GLenum target, GLenum format, GLenum type, - GLsizei bufSize, GLvoid *data ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - _mesa_error(ctx, GL_INVALID_ENUM, "glGetnColorTableARB(target)"); -} - - -static void GLAPIENTRY -_mesa_GetColorTable( GLenum target, GLenum format, - GLenum type, GLvoid *data ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - _mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTable(target)"); -} - - -static void GLAPIENTRY -_mesa_ColorTableParameterfv(GLenum target, GLenum pname, const GLfloat *params) -{ - /* no extensions use this function */ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - _mesa_error(ctx, GL_INVALID_ENUM, "glColorTableParameterfv(target)"); -} - - - -static void GLAPIENTRY -_mesa_ColorTableParameteriv(GLenum target, GLenum pname, const GLint *params) -{ - /* no extensions use this function */ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - _mesa_error(ctx, GL_INVALID_ENUM, "glColorTableParameteriv(target)"); -} - - - -static void GLAPIENTRY -_mesa_GetColorTableParameterfv( GLenum target, GLenum pname, GLfloat *params ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - _mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameterfv(target)"); -} - - - -static void GLAPIENTRY -_mesa_GetColorTableParameteriv( GLenum target, GLenum pname, GLint *params ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - _mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameteriv(target)"); -} - - -void -_mesa_init_colortable_dispatch(struct _glapi_table *disp) -{ - SET_ColorSubTable(disp, _mesa_ColorSubTable); - SET_ColorTable(disp, _mesa_ColorTable); - SET_ColorTableParameterfv(disp, _mesa_ColorTableParameterfv); - SET_ColorTableParameteriv(disp, _mesa_ColorTableParameteriv); - SET_CopyColorSubTable(disp, _mesa_CopyColorSubTable); - SET_CopyColorTable(disp, _mesa_CopyColorTable); - SET_GetColorTable(disp, _mesa_GetColorTable); - SET_GetColorTableParameterfv(disp, _mesa_GetColorTableParameterfv); - SET_GetColorTableParameteriv(disp, _mesa_GetColorTableParameteriv); - - /* GL_ARB_robustness */ - SET_GetnColorTableARB(disp, _mesa_GetnColorTableARB); -} - - -#endif /* FEATURE_colortable */ +/* + * 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 "glheader.h" +#include "bufferobj.h" +#include "colortab.h" +#include "context.h" +#include "image.h" +#include "macros.h" +#include "mfeatures.h" +#include "mtypes.h" +#include "pack.h" +#include "pbo.h" +#include "state.h" +#include "teximage.h" +#include "texstate.h" +#include "main/dispatch.h" + + +#if FEATURE_colortable + +void GLAPIENTRY +_mesa_ColorTable( GLenum target, GLenum internalFormat, + GLsizei width, GLenum format, GLenum type, + const GLvoid *data ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + _mesa_error(ctx, GL_INVALID_ENUM, "glColorTable(target)"); +} + + + +void GLAPIENTRY +_mesa_ColorSubTable( GLenum target, GLsizei start, + GLsizei count, GLenum format, GLenum type, + const GLvoid *data ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + _mesa_error(ctx, GL_INVALID_ENUM, "glColorSubTable(target)"); +} + + + +static void GLAPIENTRY +_mesa_CopyColorTable(GLenum target, GLenum internalformat, + GLint x, GLint y, GLsizei width) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + _mesa_error(ctx, GL_INVALID_ENUM, "glCopyColorTable(target)"); +} + + + +static void GLAPIENTRY +_mesa_CopyColorSubTable(GLenum target, GLsizei start, + GLint x, GLint y, GLsizei width) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + _mesa_error(ctx, GL_INVALID_ENUM, "glCopyColorSubTable(target)"); +} + + + +static void GLAPIENTRY +_mesa_GetnColorTableARB( GLenum target, GLenum format, GLenum type, + GLsizei bufSize, GLvoid *data ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + _mesa_error(ctx, GL_INVALID_ENUM, "glGetnColorTableARB(target)"); +} + + +static void GLAPIENTRY +_mesa_GetColorTable( GLenum target, GLenum format, + GLenum type, GLvoid *data ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + _mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTable(target)"); +} + + +static void GLAPIENTRY +_mesa_ColorTableParameterfv(GLenum target, GLenum pname, const GLfloat *params) +{ + /* no extensions use this function */ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + _mesa_error(ctx, GL_INVALID_ENUM, "glColorTableParameterfv(target)"); +} + + + +static void GLAPIENTRY +_mesa_ColorTableParameteriv(GLenum target, GLenum pname, const GLint *params) +{ + /* no extensions use this function */ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + _mesa_error(ctx, GL_INVALID_ENUM, "glColorTableParameteriv(target)"); +} + + + +static void GLAPIENTRY +_mesa_GetColorTableParameterfv( GLenum target, GLenum pname, GLfloat *params ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + _mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameterfv(target)"); +} + + + +static void GLAPIENTRY +_mesa_GetColorTableParameteriv( GLenum target, GLenum pname, GLint *params ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + _mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameteriv(target)"); +} + + +void +_mesa_init_colortable_dispatch(struct _glapi_table *disp) +{ + SET_ColorSubTable(disp, _mesa_ColorSubTable); + SET_ColorTable(disp, _mesa_ColorTable); + SET_ColorTableParameterfv(disp, _mesa_ColorTableParameterfv); + SET_ColorTableParameteriv(disp, _mesa_ColorTableParameteriv); + SET_CopyColorSubTable(disp, _mesa_CopyColorSubTable); + SET_CopyColorTable(disp, _mesa_CopyColorTable); + SET_GetColorTable(disp, _mesa_GetColorTable); + SET_GetColorTableParameterfv(disp, _mesa_GetColorTableParameterfv); + SET_GetColorTableParameteriv(disp, _mesa_GetColorTableParameteriv); + + /* GL_ARB_robustness */ + SET_GetnColorTableARB(disp, _mesa_GetnColorTableARB); +} + + +#endif /* FEATURE_colortable */ diff --git a/mesalib/src/mesa/main/compiler.h b/mesalib/src/mesa/main/compiler.h index d2caaaa79..89d6cda91 100644 --- a/mesalib/src/mesa/main/compiler.h +++ b/mesalib/src/mesa/main/compiler.h @@ -1,494 +1,494 @@ -/* - * Mesa 3-D graphics library - * Version: 7.5 - * - * Copyright (C) 1999-2008 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. - */ - - -/** - * \file compiler.h - * Compiler-related stuff. - */ - - -#ifndef COMPILER_H -#define COMPILER_H - - -#include -#include -#if defined(__alpha__) && defined(CCPML) -#include /* use Compaq's Fast Math Library on Alpha */ -#else -#include -#endif -#include -#include -#include -#include -#include -#include - - -#ifdef __cplusplus -extern "C" { -#endif - - -/** - * Get standard integer types - */ -#include - - -/** - * Sun compilers define __i386 instead of the gcc-style __i386__ - */ -#ifdef __SUNPRO_C -# if !defined(__i386__) && defined(__i386) -# define __i386__ -# elif !defined(__amd64__) && defined(__amd64) -# define __amd64__ -# elif !defined(__sparc__) && defined(__sparc) -# define __sparc__ -# endif -# if !defined(__volatile) -# define __volatile volatile -# endif -#endif - - -/** - * finite macro. - */ -#if defined(_MSC_VER) -# define finite _finite -#elif defined(__WATCOMC__) -# define finite _finite -#endif - - -/** - * Disable assorted warnings - */ -#if !defined(OPENSTEP) && (defined(__WIN32__) && !defined(__CYGWIN__)) && !defined(BUILD_FOR_SNAP) -# if !defined(__GNUC__) /* mingw environment */ -# pragma warning( disable : 4068 ) /* unknown pragma */ -# pragma warning( disable : 4710 ) /* function 'foo' not inlined */ -# pragma warning( disable : 4711 ) /* function 'foo' selected for automatic inline expansion */ -# pragma warning( disable : 4127 ) /* conditional expression is constant */ -# if defined(MESA_MINWARN) -# pragma warning( disable : 4244 ) /* '=' : conversion from 'const double ' to 'float ', possible loss of data */ -# pragma warning( disable : 4018 ) /* '<' : signed/unsigned mismatch */ -# pragma warning( disable : 4305 ) /* '=' : truncation from 'const double ' to 'float ' */ -# pragma warning( disable : 4550 ) /* 'function' undefined; assuming extern returning int */ -# pragma warning( disable : 4761 ) /* integral size mismatch in argument; conversion supplied */ -# endif -# endif -#endif -#if defined(__WATCOMC__) -# pragma disable_message(201) /* Disable unreachable code warnings */ -#endif - - - -/** - * Function inlining - */ -#ifndef inline -# ifdef __cplusplus - /* C++ supports inline keyword */ -# elif defined(__GNUC__) -# define inline __inline__ -# elif defined(_MSC_VER) -# define inline __inline -# elif defined(__ICL) -# define inline __inline -# elif defined(__INTEL_COMPILER) - /* Intel compiler supports inline keyword */ -# elif defined(__WATCOMC__) && (__WATCOMC__ >= 1100) -# define inline __inline -# elif defined(__SUNPRO_C) && defined(__C99FEATURES__) - /* C99 supports inline keyword */ -# elif (__STDC_VERSION__ >= 199901L) - /* C99 supports inline keyword */ -# else -# define inline -# endif -#endif -#ifndef INLINE -# define INLINE inline -#endif - - -/** - * PUBLIC/USED macros - * - * If we build the library with gcc's -fvisibility=hidden flag, we'll - * use the PUBLIC macro to mark functions that are to be exported. - * - * We also need to define a USED attribute, so the optimizer doesn't - * inline a static function that we later use in an alias. - ajax - */ -#ifndef PUBLIC -# if defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) -# define PUBLIC __attribute__((visibility("default"))) -# define USED __attribute__((used)) -# else -# define PUBLIC -# define USED -# endif -#endif - - -/** - * Some compilers don't like some of Mesa's const usage. In those places use - * CONST instead of const. Pass -DNO_CONST to compilers where this matters. - */ -#ifdef NO_CONST -# define CONST -#else -# define CONST const -#endif - - -/** - * __builtin_expect macros - */ -#if !defined(__GNUC__) -# define __builtin_expect(x, y) (x) -#endif - -#ifndef likely -# ifdef __GNUC__ -# define likely(x) __builtin_expect(!!(x), 1) -# define unlikely(x) __builtin_expect(!!(x), 0) -# else -# define likely(x) (x) -# define unlikely(x) (x) -# endif -#endif - -/** - * The __FUNCTION__ gcc variable is generally only used for debugging. - * If we're not using gcc, define __FUNCTION__ as a cpp symbol here. - * Don't define it if using a newer Windows compiler. - */ -#ifndef __FUNCTION__ -# if defined(__VMS) -# define __FUNCTION__ "VMS$NL:" -# elif !defined(__GNUC__) && !defined(__xlC__) && \ - (!defined(_MSC_VER) || _MSC_VER < 1300) -# if (__STDC_VERSION__ >= 199901L) /* C99 */ || \ - (defined(__SUNPRO_C) && defined(__C99FEATURES__)) -# define __FUNCTION__ __func__ -# else -# define __FUNCTION__ "" -# endif -# endif -#endif -#ifndef __func__ -# if (__STDC_VERSION__ >= 199901L) || \ - (defined(__SUNPRO_C) && defined(__C99FEATURES__)) - /* __func__ is part of C99 */ -# elif defined(_MSC_VER) -# if _MSC_VER >= 1300 -# define __func__ __FUNCTION__ -# else -# define __func__ "" -# endif -# endif -#endif - - -/** - * Either define MESA_BIG_ENDIAN or MESA_LITTLE_ENDIAN, and CPU_TO_LE32. - * Do not use these unless absolutely necessary! - * Try to use a runtime test instead. - * For now, only used by some DRI hardware drivers for color/texel packing. - */ -#if defined(BYTE_ORDER) && defined(BIG_ENDIAN) && BYTE_ORDER == BIG_ENDIAN -#if defined(__linux__) -#include -#define CPU_TO_LE32( x ) bswap_32( x ) -#elif defined(__APPLE__) -#include -#define CPU_TO_LE32( x ) CFSwapInt32HostToLittle( x ) -#elif (defined(_AIX) || defined(__blrts)) -static INLINE GLuint CPU_TO_LE32(GLuint x) -{ - return (((x & 0x000000ff) << 24) | - ((x & 0x0000ff00) << 8) | - ((x & 0x00ff0000) >> 8) | - ((x & 0xff000000) >> 24)); -} -#else /*__linux__ */ -#include -#define CPU_TO_LE32( x ) bswap32( x ) -#endif /*__linux__*/ -#define MESA_BIG_ENDIAN 1 -#else -#define CPU_TO_LE32( x ) ( x ) -#define MESA_LITTLE_ENDIAN 1 -#endif -#define LE32_TO_CPU( x ) CPU_TO_LE32( x ) - - - -#if !defined(CAPI) && defined(WIN32) && !defined(BUILD_FOR_SNAP) -#define CAPI _cdecl -#endif - - -/** - * Create a macro so that asm functions can be linked into compilers other - * than GNU C - */ -#ifndef _ASMAPI -#if defined(WIN32) && !defined(BUILD_FOR_SNAP)/* was: !defined( __GNUC__ ) && !defined( VMS ) && !defined( __INTEL_COMPILER )*/ -#define _ASMAPI __cdecl -#else -#define _ASMAPI -#endif -#ifdef PTR_DECL_IN_FRONT -#define _ASMAPIP * _ASMAPI -#else -#define _ASMAPIP _ASMAPI * -#endif -#endif - -#ifdef USE_X86_ASM -#define _NORMAPI _ASMAPI -#define _NORMAPIP _ASMAPIP -#else -#define _NORMAPI -#define _NORMAPIP * -#endif - - -/* This is a macro on IRIX */ -#ifdef _P -#undef _P -#endif - - -/* Turn off macro checking systems used by other libraries */ -#ifdef CHECK -#undef CHECK -#endif - - -/** - * ASSERT macro - */ -#if !defined(_WIN32_WCE) -#if defined(BUILD_FOR_SNAP) && defined(CHECKED) -# define ASSERT(X) _CHECK(X) -#elif defined(DEBUG) -# define ASSERT(X) assert(X) -#else -# define ASSERT(X) -#endif -#endif - -#if (__GNUC__ >= 3) -#define PRINTFLIKE(f, a) __attribute__ ((format(__printf__, f, a))) -#else -#define PRINTFLIKE(f, a) -#endif - -#ifndef NULL -#define NULL 0 -#endif - - -/** - * LONGSTRING macro - * gcc -pedantic warns about long string literals, LONGSTRING silences that. - */ -#if !defined(__GNUC__) -# define LONGSTRING -#else -# define LONGSTRING __extension__ -#endif - - -#ifndef M_PI -#define M_PI (3.14159265358979323846) -#endif - -#ifndef M_E -#define M_E (2.7182818284590452354) -#endif - -#ifndef M_LOG2E -#define M_LOG2E (1.4426950408889634074) -#endif - -#ifndef ONE_DIV_SQRT_LN2 -#define ONE_DIV_SQRT_LN2 (1.201122408786449815) -#endif - -#ifndef FLT_MAX_EXP -#define FLT_MAX_EXP 128 -#endif - - -/** - * USE_IEEE: Determine if we're using IEEE floating point - */ -#if defined(__i386__) || defined(__386__) || defined(__sparc__) || \ - defined(__s390x__) || defined(__powerpc__) || \ - defined(__x86_64__) || \ - defined(ia64) || defined(__ia64__) || \ - defined(__hppa__) || defined(hpux) || \ - defined(__mips) || defined(_MIPS_ARCH) || \ - defined(__arm__) || \ - defined(__sh__) || defined(__m32r__) || \ - (defined(__sun) && defined(_IEEE_754)) || \ - (defined(__alpha__) && (defined(__IEEE_FLOAT) || !defined(VMS))) -#define USE_IEEE -#define IEEE_ONE 0x3f800000 -#endif - - -/** - * START/END_FAST_MATH macros: - * - * START_FAST_MATH: Set x86 FPU to faster, 32-bit precision mode (and save - * original mode to a temporary). - * END_FAST_MATH: Restore x86 FPU to original mode. - */ -#if defined(__GNUC__) && defined(__i386__) -/* - * Set the x86 FPU control word to guarentee only 32 bits of precision - * are stored in registers. Allowing the FPU to store more introduces - * differences between situations where numbers are pulled out of memory - * vs. situations where the compiler is able to optimize register usage. - * - * In the worst case, we force the compiler to use a memory access to - * truncate the float, by specifying the 'volatile' keyword. - */ -/* Hardware default: All exceptions masked, extended double precision, - * round to nearest (IEEE compliant): - */ -#define DEFAULT_X86_FPU 0x037f -/* All exceptions masked, single precision, round to nearest: - */ -#define FAST_X86_FPU 0x003f -/* The fldcw instruction will cause any pending FP exceptions to be - * raised prior to entering the block, and we clear any pending - * exceptions before exiting the block. Hence, asm code has free - * reign over the FPU while in the fast math block. - */ -#if defined(NO_FAST_MATH) -#define START_FAST_MATH(x) \ -do { \ - static GLuint mask = DEFAULT_X86_FPU; \ - __asm__ ( "fnstcw %0" : "=m" (*&(x)) ); \ - __asm__ ( "fldcw %0" : : "m" (mask) ); \ -} while (0) -#else -#define START_FAST_MATH(x) \ -do { \ - static GLuint mask = FAST_X86_FPU; \ - __asm__ ( "fnstcw %0" : "=m" (*&(x)) ); \ - __asm__ ( "fldcw %0" : : "m" (mask) ); \ -} while (0) -#endif -/* Restore original FPU mode, and clear any exceptions that may have - * occurred in the FAST_MATH block. - */ -#define END_FAST_MATH(x) \ -do { \ - __asm__ ( "fnclex ; fldcw %0" : : "m" (*&(x)) ); \ -} while (0) - -#elif defined(__WATCOMC__) && defined(__386__) -#define DEFAULT_X86_FPU 0x037f /* See GCC comments above */ -#define FAST_X86_FPU 0x003f /* See GCC comments above */ -void _watcom_start_fast_math(unsigned short *x,unsigned short *mask); -#pragma aux _watcom_start_fast_math = \ - "fnstcw word ptr [eax]" \ - "fldcw word ptr [ecx]" \ - parm [eax] [ecx] \ - modify exact []; -void _watcom_end_fast_math(unsigned short *x); -#pragma aux _watcom_end_fast_math = \ - "fnclex" \ - "fldcw word ptr [eax]" \ - parm [eax] \ - modify exact []; -#if defined(NO_FAST_MATH) -#define START_FAST_MATH(x) \ -do { \ - static GLushort mask = DEFAULT_X86_FPU; \ - _watcom_start_fast_math(&x,&mask); \ -} while (0) -#else -#define START_FAST_MATH(x) \ -do { \ - static GLushort mask = FAST_X86_FPU; \ - _watcom_start_fast_math(&x,&mask); \ -} while (0) -#endif -#define END_FAST_MATH(x) _watcom_end_fast_math(&x) - -#elif defined(_MSC_VER) && defined(_M_IX86) -#define DEFAULT_X86_FPU 0x037f /* See GCC comments above */ -#define FAST_X86_FPU 0x003f /* See GCC comments above */ -#if defined(NO_FAST_MATH) -#define START_FAST_MATH(x) do {\ - static GLuint mask = DEFAULT_X86_FPU;\ - __asm fnstcw word ptr [x]\ - __asm fldcw word ptr [mask]\ -} while(0) -#else -#define START_FAST_MATH(x) do {\ - static GLuint mask = FAST_X86_FPU;\ - __asm fnstcw word ptr [x]\ - __asm fldcw word ptr [mask]\ -} while(0) -#endif -#define END_FAST_MATH(x) do {\ - __asm fnclex\ - __asm fldcw word ptr [x]\ -} while(0) - -#else -#define START_FAST_MATH(x) x = 0 -#define END_FAST_MATH(x) (void)(x) -#endif - - -#ifndef Elements -#define Elements(x) (sizeof(x)/sizeof(*(x))) -#endif - - - -#ifdef __cplusplus -} -#endif - - -#endif /* COMPILER_H */ +/* + * Mesa 3-D graphics library + * Version: 7.5 + * + * Copyright (C) 1999-2008 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. + */ + + +/** + * \file compiler.h + * Compiler-related stuff. + */ + + +#ifndef COMPILER_H +#define COMPILER_H + + +#include +#include +#if defined(__alpha__) && defined(CCPML) +#include /* use Compaq's Fast Math Library on Alpha */ +#else +#include +#endif +#include +#include +#include +#include +#include +#include + + +#ifdef __cplusplus +extern "C" { +#endif + + +/** + * Get standard integer types + */ +#include + + +/** + * Sun compilers define __i386 instead of the gcc-style __i386__ + */ +#ifdef __SUNPRO_C +# if !defined(__i386__) && defined(__i386) +# define __i386__ +# elif !defined(__amd64__) && defined(__amd64) +# define __amd64__ +# elif !defined(__sparc__) && defined(__sparc) +# define __sparc__ +# endif +# if !defined(__volatile) +# define __volatile volatile +# endif +#endif + + +/** + * finite macro. + */ +#if defined(_MSC_VER) +# define finite _finite +#elif defined(__WATCOMC__) +# define finite _finite +#endif + + +/** + * Disable assorted warnings + */ +#if !defined(OPENSTEP) && (defined(__WIN32__) && !defined(__CYGWIN__)) && !defined(BUILD_FOR_SNAP) +# if !defined(__GNUC__) /* mingw environment */ +# pragma warning( disable : 4068 ) /* unknown pragma */ +# pragma warning( disable : 4710 ) /* function 'foo' not inlined */ +# pragma warning( disable : 4711 ) /* function 'foo' selected for automatic inline expansion */ +# pragma warning( disable : 4127 ) /* conditional expression is constant */ +# if defined(MESA_MINWARN) +# pragma warning( disable : 4244 ) /* '=' : conversion from 'const double ' to 'float ', possible loss of data */ +# pragma warning( disable : 4018 ) /* '<' : signed/unsigned mismatch */ +# pragma warning( disable : 4305 ) /* '=' : truncation from 'const double ' to 'float ' */ +# pragma warning( disable : 4550 ) /* 'function' undefined; assuming extern returning int */ +# pragma warning( disable : 4761 ) /* integral size mismatch in argument; conversion supplied */ +# endif +# endif +#endif +#if defined(__WATCOMC__) +# pragma disable_message(201) /* Disable unreachable code warnings */ +#endif + + + +/** + * Function inlining + */ +#ifndef inline +# ifdef __cplusplus + /* C++ supports inline keyword */ +# elif defined(__GNUC__) +# define inline __inline__ +# elif defined(_MSC_VER) +# define inline __inline +# elif defined(__ICL) +# define inline __inline +# elif defined(__INTEL_COMPILER) + /* Intel compiler supports inline keyword */ +# elif defined(__WATCOMC__) && (__WATCOMC__ >= 1100) +# define inline __inline +# elif defined(__SUNPRO_C) && defined(__C99FEATURES__) + /* C99 supports inline keyword */ +# elif (__STDC_VERSION__ >= 199901L) + /* C99 supports inline keyword */ +# else +# define inline +# endif +#endif +#ifndef INLINE +# define INLINE inline +#endif + + +/** + * PUBLIC/USED macros + * + * If we build the library with gcc's -fvisibility=hidden flag, we'll + * use the PUBLIC macro to mark functions that are to be exported. + * + * We also need to define a USED attribute, so the optimizer doesn't + * inline a static function that we later use in an alias. - ajax + */ +#ifndef PUBLIC +# if defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) +# define PUBLIC __attribute__((visibility("default"))) +# define USED __attribute__((used)) +# else +# define PUBLIC +# define USED +# endif +#endif + + +/** + * Some compilers don't like some of Mesa's const usage. In those places use + * CONST instead of const. Pass -DNO_CONST to compilers where this matters. + */ +#ifdef NO_CONST +# define CONST +#else +# define CONST const +#endif + + +/** + * __builtin_expect macros + */ +#if !defined(__GNUC__) +# define __builtin_expect(x, y) (x) +#endif + +#ifndef likely +# ifdef __GNUC__ +# define likely(x) __builtin_expect(!!(x), 1) +# define unlikely(x) __builtin_expect(!!(x), 0) +# else +# define likely(x) (x) +# define unlikely(x) (x) +# endif +#endif + +/** + * The __FUNCTION__ gcc variable is generally only used for debugging. + * If we're not using gcc, define __FUNCTION__ as a cpp symbol here. + * Don't define it if using a newer Windows compiler. + */ +#ifndef __FUNCTION__ +# if defined(__VMS) +# define __FUNCTION__ "VMS$NL:" +# elif !defined(__GNUC__) && !defined(__xlC__) && \ + (!defined(_MSC_VER) || _MSC_VER < 1300) +# if (__STDC_VERSION__ >= 199901L) /* C99 */ || \ + (defined(__SUNPRO_C) && defined(__C99FEATURES__)) +# define __FUNCTION__ __func__ +# else +# define __FUNCTION__ "" +# endif +# endif +#endif +#ifndef __func__ +# if (__STDC_VERSION__ >= 199901L) || \ + (defined(__SUNPRO_C) && defined(__C99FEATURES__)) + /* __func__ is part of C99 */ +# elif defined(_MSC_VER) +# if _MSC_VER >= 1300 +# define __func__ __FUNCTION__ +# else +# define __func__ "" +# endif +# endif +#endif + + +/** + * Either define MESA_BIG_ENDIAN or MESA_LITTLE_ENDIAN, and CPU_TO_LE32. + * Do not use these unless absolutely necessary! + * Try to use a runtime test instead. + * For now, only used by some DRI hardware drivers for color/texel packing. + */ +#if defined(BYTE_ORDER) && defined(BIG_ENDIAN) && BYTE_ORDER == BIG_ENDIAN +#if defined(__linux__) +#include +#define CPU_TO_LE32( x ) bswap_32( x ) +#elif defined(__APPLE__) +#include +#define CPU_TO_LE32( x ) CFSwapInt32HostToLittle( x ) +#elif (defined(_AIX) || defined(__blrts)) +static INLINE GLuint CPU_TO_LE32(GLuint x) +{ + return (((x & 0x000000ff) << 24) | + ((x & 0x0000ff00) << 8) | + ((x & 0x00ff0000) >> 8) | + ((x & 0xff000000) >> 24)); +} +#else /*__linux__ */ +#include +#define CPU_TO_LE32( x ) bswap32( x ) +#endif /*__linux__*/ +#define MESA_BIG_ENDIAN 1 +#else +#define CPU_TO_LE32( x ) ( x ) +#define MESA_LITTLE_ENDIAN 1 +#endif +#define LE32_TO_CPU( x ) CPU_TO_LE32( x ) + + + +#if !defined(CAPI) && defined(WIN32) && !defined(BUILD_FOR_SNAP) +#define CAPI _cdecl +#endif + + +/** + * Create a macro so that asm functions can be linked into compilers other + * than GNU C + */ +#ifndef _ASMAPI +#if defined(WIN32) && !defined(BUILD_FOR_SNAP)/* was: !defined( __GNUC__ ) && !defined( VMS ) && !defined( __INTEL_COMPILER )*/ +#define _ASMAPI __cdecl +#else +#define _ASMAPI +#endif +#ifdef PTR_DECL_IN_FRONT +#define _ASMAPIP * _ASMAPI +#else +#define _ASMAPIP _ASMAPI * +#endif +#endif + +#ifdef USE_X86_ASM +#define _NORMAPI _ASMAPI +#define _NORMAPIP _ASMAPIP +#else +#define _NORMAPI +#define _NORMAPIP * +#endif + + +/* This is a macro on IRIX */ +#ifdef _P +#undef _P +#endif + + +/* Turn off macro checking systems used by other libraries */ +#ifdef CHECK +#undef CHECK +#endif + + +/** + * ASSERT macro + */ +#if !defined(_WIN32_WCE) +#if defined(BUILD_FOR_SNAP) && defined(CHECKED) +# define ASSERT(X) _CHECK(X) +#elif defined(DEBUG) +# define ASSERT(X) assert(X) +#else +# define ASSERT(X) +#endif +#endif + +#if (__GNUC__ >= 3) +#define PRINTFLIKE(f, a) __attribute__ ((format(__printf__, f, a))) +#else +#define PRINTFLIKE(f, a) +#endif + +#ifndef NULL +#define NULL 0 +#endif + + +/** + * LONGSTRING macro + * gcc -pedantic warns about long string literals, LONGSTRING silences that. + */ +#if !defined(__GNUC__) +# define LONGSTRING +#else +# define LONGSTRING __extension__ +#endif + + +#ifndef M_PI +#define M_PI (3.14159265358979323846) +#endif + +#ifndef M_E +#define M_E (2.7182818284590452354) +#endif + +#ifndef M_LOG2E +#define M_LOG2E (1.4426950408889634074) +#endif + +#ifndef ONE_DIV_SQRT_LN2 +#define ONE_DIV_SQRT_LN2 (1.201122408786449815) +#endif + +#ifndef FLT_MAX_EXP +#define FLT_MAX_EXP 128 +#endif + + +/** + * USE_IEEE: Determine if we're using IEEE floating point + */ +#if defined(__i386__) || defined(__386__) || defined(__sparc__) || \ + defined(__s390x__) || defined(__powerpc__) || \ + defined(__x86_64__) || \ + defined(ia64) || defined(__ia64__) || \ + defined(__hppa__) || defined(hpux) || \ + defined(__mips) || defined(_MIPS_ARCH) || \ + defined(__arm__) || \ + defined(__sh__) || defined(__m32r__) || \ + (defined(__sun) && defined(_IEEE_754)) || \ + (defined(__alpha__) && (defined(__IEEE_FLOAT) || !defined(VMS))) +#define USE_IEEE +#define IEEE_ONE 0x3f800000 +#endif + + +/** + * START/END_FAST_MATH macros: + * + * START_FAST_MATH: Set x86 FPU to faster, 32-bit precision mode (and save + * original mode to a temporary). + * END_FAST_MATH: Restore x86 FPU to original mode. + */ +#if defined(__GNUC__) && defined(__i386__) +/* + * Set the x86 FPU control word to guarentee only 32 bits of precision + * are stored in registers. Allowing the FPU to store more introduces + * differences between situations where numbers are pulled out of memory + * vs. situations where the compiler is able to optimize register usage. + * + * In the worst case, we force the compiler to use a memory access to + * truncate the float, by specifying the 'volatile' keyword. + */ +/* Hardware default: All exceptions masked, extended double precision, + * round to nearest (IEEE compliant): + */ +#define DEFAULT_X86_FPU 0x037f +/* All exceptions masked, single precision, round to nearest: + */ +#define FAST_X86_FPU 0x003f +/* The fldcw instruction will cause any pending FP exceptions to be + * raised prior to entering the block, and we clear any pending + * exceptions before exiting the block. Hence, asm code has free + * reign over the FPU while in the fast math block. + */ +#if defined(NO_FAST_MATH) +#define START_FAST_MATH(x) \ +do { \ + static GLuint mask = DEFAULT_X86_FPU; \ + __asm__ ( "fnstcw %0" : "=m" (*&(x)) ); \ + __asm__ ( "fldcw %0" : : "m" (mask) ); \ +} while (0) +#else +#define START_FAST_MATH(x) \ +do { \ + static GLuint mask = FAST_X86_FPU; \ + __asm__ ( "fnstcw %0" : "=m" (*&(x)) ); \ + __asm__ ( "fldcw %0" : : "m" (mask) ); \ +} while (0) +#endif +/* Restore original FPU mode, and clear any exceptions that may have + * occurred in the FAST_MATH block. + */ +#define END_FAST_MATH(x) \ +do { \ + __asm__ ( "fnclex ; fldcw %0" : : "m" (*&(x)) ); \ +} while (0) + +#elif defined(__WATCOMC__) && defined(__386__) +#define DEFAULT_X86_FPU 0x037f /* See GCC comments above */ +#define FAST_X86_FPU 0x003f /* See GCC comments above */ +void _watcom_start_fast_math(unsigned short *x,unsigned short *mask); +#pragma aux _watcom_start_fast_math = \ + "fnstcw word ptr [eax]" \ + "fldcw word ptr [ecx]" \ + parm [eax] [ecx] \ + modify exact []; +void _watcom_end_fast_math(unsigned short *x); +#pragma aux _watcom_end_fast_math = \ + "fnclex" \ + "fldcw word ptr [eax]" \ + parm [eax] \ + modify exact []; +#if defined(NO_FAST_MATH) +#define START_FAST_MATH(x) \ +do { \ + static GLushort mask = DEFAULT_X86_FPU; \ + _watcom_start_fast_math(&x,&mask); \ +} while (0) +#else +#define START_FAST_MATH(x) \ +do { \ + static GLushort mask = FAST_X86_FPU; \ + _watcom_start_fast_math(&x,&mask); \ +} while (0) +#endif +#define END_FAST_MATH(x) _watcom_end_fast_math(&x) + +#elif defined(_MSC_VER) && defined(_M_IX86) +#define DEFAULT_X86_FPU 0x037f /* See GCC comments above */ +#define FAST_X86_FPU 0x003f /* See GCC comments above */ +#if defined(NO_FAST_MATH) +#define START_FAST_MATH(x) do {\ + static GLuint mask = DEFAULT_X86_FPU;\ + __asm fnstcw word ptr [x]\ + __asm fldcw word ptr [mask]\ +} while(0) +#else +#define START_FAST_MATH(x) do {\ + static GLuint mask = FAST_X86_FPU;\ + __asm fnstcw word ptr [x]\ + __asm fldcw word ptr [mask]\ +} while(0) +#endif +#define END_FAST_MATH(x) do {\ + __asm fnclex\ + __asm fldcw word ptr [x]\ +} while(0) + +#else +#define START_FAST_MATH(x) x = 0 +#define END_FAST_MATH(x) (void)(x) +#endif + + +#ifndef Elements +#define Elements(x) (sizeof(x)/sizeof(*(x))) +#endif + + + +#ifdef __cplusplus +} +#endif + + +#endif /* COMPILER_H */ diff --git a/mesalib/src/mesa/main/context.c b/mesalib/src/mesa/main/context.c index a9b8316e3..0cf794735 100644 --- a/mesalib/src/mesa/main/context.c +++ b/mesalib/src/mesa/main/context.c @@ -1,1880 +1,1880 @@ -/* - * 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: - *
    - *
  • Structures to represent most GL state
  • - *
  • State set/get functions
  • - *
  • Display lists
  • - *
  • Texture unit, object and image handling
  • - *
  • Matrix and attribute stacks
  • - *
- * - * 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 Main page link will display a summary of the module - * (this page). - * - * Selecting Data Structures will list all C structures. - * - * Selecting the File List 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 Data Fields link will display a list of all - * documented structure members. - * - * Selecting the Globals 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 "formats.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 - - -#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 - -#ifdef DEBUG - _mesa_test_formats(); -#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->MaxAddressOffset = MAX_PROGRAM_LOCAL_PARAMS; - - 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; - prog->MaxUniformComponents = 4 * MAX_UNIFORMS; - 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; - prog->MaxUniformComponents = 4 * MAX_UNIFORMS; - 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->MaxUniformComponents = MAX_GEOMETRY_UNIFORM_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; - - /* Set GLSL datatype range/precision info assuming IEEE float values. - * Drivers should override these defaults as needed. - */ - prog->MediumFloat.RangeMin = 127; - prog->MediumFloat.RangeMax = 127; - prog->MediumFloat.Precision = 23; - prog->LowFloat = prog->HighFloat = prog->MediumFloat; - - /* Assume ints are stored as floats for now, since this is the least-common - * denominator. The OpenGL ES spec implies (page 132) that the precision - * of integer types should be 0. Practically speaking, IEEE - * single-precision floating point values can only store integers in the - * range [-0x01000000, 0x01000000] without loss of precision. - */ - prog->MediumInt.RangeMin = 24; - prog->MediumInt.RangeMax = 24; - prog->MediumInt.Precision = 0; - prog->LowInt = prog->HighInt = prog->MediumInt; -} - - -/** - * 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.MaxTextureBufferSize = 65536; - 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 -#if FEATURE_ARB_geometry_shader4 - ctx->Const.MaxGeometryTextureImageUnits = MAX_GEOMETRY_TEXTURE_IMAGE_UNITS; - ctx->Const.MaxVertexVaryingComponents = MAX_VERTEX_VARYING_COMPONENTS; - ctx->Const.MaxGeometryVaryingComponents = MAX_GEOMETRY_VARYING_COMPONENTS; - ctx->Const.MaxGeometryOutputVertices = MAX_GEOMETRY_OUTPUT_VERTICES; - ctx->Const.MaxGeometryTotalOutputComponents = MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS; -#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; - - /* GL_ARB_robustness */ - ctx->Const.ResetStrategy = GL_NO_RESET_NOTIFICATION_ARB; -} - - -/** - * 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 init* - * 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->ResetStatus = (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(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->FreeTextureImageBuffer); - - 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; - } - - /* Mesa core handles all the formats that mesa core knows about. - * Drivers will want to override this list with just the formats - * they can handle, and confirm that appropriate fallbacks exist in - * _mesa_choose_tex_format(). - */ - memset(&ctx->TextureFormatSupported, GL_TRUE, - sizeof(ctx->TextureFormatSupported)); - - 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; -} - - -/** - * 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(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(ctx, api, visual, share_list, - driverFunctions, driverContext)) { - return ctx; - } - else { - free(ctx); - return NULL; - } -} - - -/** - * 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) { - 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) { - _mesa_reference_framebuffer(&newCtx->DrawBuffer, drawBuffer); - /* Update the FBO's list of drawbuffers/renderbuffers. - * For winsys FBOs this comes from the GL state (which may have - * changed since the last time this FBO was bound). - */ - _mesa_update_draw_buffers(newCtx); - } - 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; -} - - -/*@}*/ +/* + * 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: + *
    + *
  • Structures to represent most GL state
  • + *
  • State set/get functions
  • + *
  • Display lists
  • + *
  • Texture unit, object and image handling
  • + *
  • Matrix and attribute stacks
  • + *
+ * + * 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 Main page link will display a summary of the module + * (this page). + * + * Selecting Data Structures will list all C structures. + * + * Selecting the File List 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 Data Fields link will display a list of all + * documented structure members. + * + * Selecting the Globals 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 "formats.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 + + +#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 + +#ifdef DEBUG + _mesa_test_formats(); +#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->MaxAddressOffset = MAX_PROGRAM_LOCAL_PARAMS; + + 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; + prog->MaxUniformComponents = 4 * MAX_UNIFORMS; + 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; + prog->MaxUniformComponents = 4 * MAX_UNIFORMS; + 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->MaxUniformComponents = MAX_GEOMETRY_UNIFORM_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; + + /* Set GLSL datatype range/precision info assuming IEEE float values. + * Drivers should override these defaults as needed. + */ + prog->MediumFloat.RangeMin = 127; + prog->MediumFloat.RangeMax = 127; + prog->MediumFloat.Precision = 23; + prog->LowFloat = prog->HighFloat = prog->MediumFloat; + + /* Assume ints are stored as floats for now, since this is the least-common + * denominator. The OpenGL ES spec implies (page 132) that the precision + * of integer types should be 0. Practically speaking, IEEE + * single-precision floating point values can only store integers in the + * range [-0x01000000, 0x01000000] without loss of precision. + */ + prog->MediumInt.RangeMin = 24; + prog->MediumInt.RangeMax = 24; + prog->MediumInt.Precision = 0; + prog->LowInt = prog->HighInt = prog->MediumInt; +} + + +/** + * 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.MaxTextureBufferSize = 65536; + 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 +#if FEATURE_ARB_geometry_shader4 + ctx->Const.MaxGeometryTextureImageUnits = MAX_GEOMETRY_TEXTURE_IMAGE_UNITS; + ctx->Const.MaxVertexVaryingComponents = MAX_VERTEX_VARYING_COMPONENTS; + ctx->Const.MaxGeometryVaryingComponents = MAX_GEOMETRY_VARYING_COMPONENTS; + ctx->Const.MaxGeometryOutputVertices = MAX_GEOMETRY_OUTPUT_VERTICES; + ctx->Const.MaxGeometryTotalOutputComponents = MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS; +#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; + + /* GL_ARB_robustness */ + ctx->Const.ResetStrategy = GL_NO_RESET_NOTIFICATION_ARB; +} + + +/** + * 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 init* + * 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->ResetStatus = (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(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->FreeTextureImageBuffer); + + 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; + } + + /* Mesa core handles all the formats that mesa core knows about. + * Drivers will want to override this list with just the formats + * they can handle, and confirm that appropriate fallbacks exist in + * _mesa_choose_tex_format(). + */ + memset(&ctx->TextureFormatSupported, GL_TRUE, + sizeof(ctx->TextureFormatSupported)); + + 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; +} + + +/** + * 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(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(ctx, api, visual, share_list, + driverFunctions, driverContext)) { + return ctx; + } + else { + free(ctx); + return NULL; + } +} + + +/** + * 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) { + 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) { + _mesa_reference_framebuffer(&newCtx->DrawBuffer, drawBuffer); + /* Update the FBO's list of drawbuffers/renderbuffers. + * For winsys FBOs this comes from the GL state (which may have + * changed since the last time this FBO was bound). + */ + _mesa_update_draw_buffers(newCtx); + } + 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/mesalib/src/mesa/main/context.h b/mesalib/src/mesa/main/context.h index 2e9fbc77a..a4c7ba2c5 100644 --- a/mesalib/src/mesa/main/context.h +++ b/mesalib/src/mesa/main/context.h @@ -1,289 +1,289 @@ -/* - * 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. - */ - - -/** - * \file context.h - * Mesa context and visual-related functions. - * - * There are three large Mesa data types/classes which are meant to be - * used by device drivers: - * - struct gl_context: this contains the Mesa rendering state - * - struct gl_config: this describes the color buffer (RGB vs. ci), whether - * or not there's a depth buffer, stencil buffer, etc. - * - struct gl_framebuffer: contains pointers to the depth buffer, stencil - * buffer, accum buffer and alpha buffers. - * - * These types should be encapsulated by corresponding device driver - * data types. See xmesa.h and xmesaP.h for an example. - * - * In OOP terms, struct gl_context, struct gl_config, and struct gl_framebuffer - * are base classes which the device driver must derive from. - * - * The following functions create and destroy these data types. - */ - - -#ifndef CONTEXT_H -#define CONTEXT_H - - -#include "imports.h" -#include "mtypes.h" - - -struct _glapi_table; - - -/** \name Visual-related functions */ -/*@{*/ - -extern 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 ); - -extern GLboolean -_mesa_initialize_visual( struct gl_config *v, - 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 ); - -extern void -_mesa_destroy_visual( struct gl_config *vis ); - -/*@}*/ - - -/** \name Context-related functions */ -/*@{*/ - -extern GLboolean -_mesa_initialize_context( 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 ); - -extern struct gl_context * -_mesa_create_context(gl_api api, - const struct gl_config *visual, - struct gl_context *share_list, - const struct dd_function_table *driverFunctions, - void *driverContext); - -extern void -_mesa_free_context_data( struct gl_context *ctx ); - -extern void -_mesa_destroy_context( struct gl_context *ctx ); - - -extern void -_mesa_copy_context(const struct gl_context *src, struct gl_context *dst, GLuint mask); - - -extern void -_mesa_check_init_viewport(struct gl_context *ctx, GLuint width, GLuint height); - -extern GLboolean -_mesa_make_current( struct gl_context *ctx, struct gl_framebuffer *drawBuffer, - struct gl_framebuffer *readBuffer ); - -extern GLboolean -_mesa_share_state(struct gl_context *ctx, struct gl_context *ctxToShare); - -extern struct gl_context * -_mesa_get_current_context(void); - -/*@}*/ - -extern void -_mesa_init_get_hash(struct gl_context *ctx); - -extern void -_mesa_notifySwapBuffers(struct gl_context *gc); - - -extern struct _glapi_table * -_mesa_get_dispatch(struct gl_context *ctx); - - -void -_mesa_set_mvp_with_dp4( struct gl_context *ctx, - GLboolean flag ); - - -extern GLboolean -_mesa_valid_to_render(struct gl_context *ctx, const char *where); - - - -/** \name Miscellaneous */ -/*@{*/ - -extern void -_mesa_record_error( struct gl_context *ctx, GLenum error ); - - -extern void -_mesa_finish(struct gl_context *ctx); - -extern void -_mesa_flush(struct gl_context *ctx); - - -extern void GLAPIENTRY -_mesa_Finish( void ); - -extern void GLAPIENTRY -_mesa_Flush( void ); - -/*@}*/ - - -/** - * \name Macros for flushing buffered rendering commands before state changes, - * checking if inside glBegin/glEnd, etc. - */ -/*@{*/ - -/** - * Flush vertices. - * - * \param ctx GL context. - * \param newstate new state. - * - * Checks if dd_function_table::NeedFlush is marked to flush stored vertices, - * and calls dd_function_table::FlushVertices if so. Marks - * __struct gl_contextRec::NewState with \p newstate. - */ -#define FLUSH_VERTICES(ctx, newstate) \ -do { \ - if (MESA_VERBOSE & VERBOSE_STATE) \ - _mesa_debug(ctx, "FLUSH_VERTICES in %s\n", MESA_FUNCTION);\ - if (ctx->Driver.NeedFlush & FLUSH_STORED_VERTICES) \ - ctx->Driver.FlushVertices(ctx, FLUSH_STORED_VERTICES); \ - ctx->NewState |= newstate; \ -} while (0) - -/** - * Flush current state. - * - * \param ctx GL context. - * \param newstate new state. - * - * Checks if dd_function_table::NeedFlush is marked to flush current state, - * and calls dd_function_table::FlushVertices if so. Marks - * __struct gl_contextRec::NewState with \p newstate. - */ -#define FLUSH_CURRENT(ctx, newstate) \ -do { \ - if (MESA_VERBOSE & VERBOSE_STATE) \ - _mesa_debug(ctx, "FLUSH_CURRENT in %s\n", MESA_FUNCTION); \ - if (ctx->Driver.NeedFlush & FLUSH_UPDATE_CURRENT) \ - ctx->Driver.FlushVertices(ctx, FLUSH_UPDATE_CURRENT); \ - ctx->NewState |= newstate; \ -} while (0) - -/** - * Macro to assert that the API call was made outside the - * glBegin()/glEnd() pair, with return value. - * - * \param ctx GL context. - * \param retval value to return value in case the assertion fails. - */ -#define ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, retval) \ -do { \ - if (ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END) { \ - _mesa_error(ctx, GL_INVALID_OPERATION, "Inside glBegin/glEnd"); \ - return retval; \ - } \ -} while (0) - -/** - * Macro to assert that the API call was made outside the - * glBegin()/glEnd() pair. - * - * \param ctx GL context. - */ -#define ASSERT_OUTSIDE_BEGIN_END(ctx) \ -do { \ - if (ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END) { \ - _mesa_error(ctx, GL_INVALID_OPERATION, "Inside glBegin/glEnd"); \ - return; \ - } \ -} while (0) - -/** - * Macro to assert that the API call was made outside the - * glBegin()/glEnd() pair and flush the vertices. - * - * \param ctx GL context. - */ -#define ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx) \ -do { \ - ASSERT_OUTSIDE_BEGIN_END(ctx); \ - FLUSH_VERTICES(ctx, 0); \ -} while (0) - -/** - * Macro to assert that the API call was made outside the - * glBegin()/glEnd() pair and flush the vertices, with return value. - * - * \param ctx GL context. - * \param retval value to return value in case the assertion fails. - */ -#define ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx, retval) \ -do { \ - ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, retval); \ - FLUSH_VERTICES(ctx, 0); \ -} while (0) - -/*@}*/ - - - -#endif /* CONTEXT_H */ +/* + * 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. + */ + + +/** + * \file context.h + * Mesa context and visual-related functions. + * + * There are three large Mesa data types/classes which are meant to be + * used by device drivers: + * - struct gl_context: this contains the Mesa rendering state + * - struct gl_config: this describes the color buffer (RGB vs. ci), whether + * or not there's a depth buffer, stencil buffer, etc. + * - struct gl_framebuffer: contains pointers to the depth buffer, stencil + * buffer, accum buffer and alpha buffers. + * + * These types should be encapsulated by corresponding device driver + * data types. See xmesa.h and xmesaP.h for an example. + * + * In OOP terms, struct gl_context, struct gl_config, and struct gl_framebuffer + * are base classes which the device driver must derive from. + * + * The following functions create and destroy these data types. + */ + + +#ifndef CONTEXT_H +#define CONTEXT_H + + +#include "imports.h" +#include "mtypes.h" + + +struct _glapi_table; + + +/** \name Visual-related functions */ +/*@{*/ + +extern 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 ); + +extern GLboolean +_mesa_initialize_visual( struct gl_config *v, + 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 ); + +extern void +_mesa_destroy_visual( struct gl_config *vis ); + +/*@}*/ + + +/** \name Context-related functions */ +/*@{*/ + +extern GLboolean +_mesa_initialize_context( 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 ); + +extern struct gl_context * +_mesa_create_context(gl_api api, + const struct gl_config *visual, + struct gl_context *share_list, + const struct dd_function_table *driverFunctions, + void *driverContext); + +extern void +_mesa_free_context_data( struct gl_context *ctx ); + +extern void +_mesa_destroy_context( struct gl_context *ctx ); + + +extern void +_mesa_copy_context(const struct gl_context *src, struct gl_context *dst, GLuint mask); + + +extern void +_mesa_check_init_viewport(struct gl_context *ctx, GLuint width, GLuint height); + +extern GLboolean +_mesa_make_current( struct gl_context *ctx, struct gl_framebuffer *drawBuffer, + struct gl_framebuffer *readBuffer ); + +extern GLboolean +_mesa_share_state(struct gl_context *ctx, struct gl_context *ctxToShare); + +extern struct gl_context * +_mesa_get_current_context(void); + +/*@}*/ + +extern void +_mesa_init_get_hash(struct gl_context *ctx); + +extern void +_mesa_notifySwapBuffers(struct gl_context *gc); + + +extern struct _glapi_table * +_mesa_get_dispatch(struct gl_context *ctx); + + +void +_mesa_set_mvp_with_dp4( struct gl_context *ctx, + GLboolean flag ); + + +extern GLboolean +_mesa_valid_to_render(struct gl_context *ctx, const char *where); + + + +/** \name Miscellaneous */ +/*@{*/ + +extern void +_mesa_record_error( struct gl_context *ctx, GLenum error ); + + +extern void +_mesa_finish(struct gl_context *ctx); + +extern void +_mesa_flush(struct gl_context *ctx); + + +extern void GLAPIENTRY +_mesa_Finish( void ); + +extern void GLAPIENTRY +_mesa_Flush( void ); + +/*@}*/ + + +/** + * \name Macros for flushing buffered rendering commands before state changes, + * checking if inside glBegin/glEnd, etc. + */ +/*@{*/ + +/** + * Flush vertices. + * + * \param ctx GL context. + * \param newstate new state. + * + * Checks if dd_function_table::NeedFlush is marked to flush stored vertices, + * and calls dd_function_table::FlushVertices if so. Marks + * __struct gl_contextRec::NewState with \p newstate. + */ +#define FLUSH_VERTICES(ctx, newstate) \ +do { \ + if (MESA_VERBOSE & VERBOSE_STATE) \ + _mesa_debug(ctx, "FLUSH_VERTICES in %s\n", MESA_FUNCTION);\ + if (ctx->Driver.NeedFlush & FLUSH_STORED_VERTICES) \ + ctx->Driver.FlushVertices(ctx, FLUSH_STORED_VERTICES); \ + ctx->NewState |= newstate; \ +} while (0) + +/** + * Flush current state. + * + * \param ctx GL context. + * \param newstate new state. + * + * Checks if dd_function_table::NeedFlush is marked to flush current state, + * and calls dd_function_table::FlushVertices if so. Marks + * __struct gl_contextRec::NewState with \p newstate. + */ +#define FLUSH_CURRENT(ctx, newstate) \ +do { \ + if (MESA_VERBOSE & VERBOSE_STATE) \ + _mesa_debug(ctx, "FLUSH_CURRENT in %s\n", MESA_FUNCTION); \ + if (ctx->Driver.NeedFlush & FLUSH_UPDATE_CURRENT) \ + ctx->Driver.FlushVertices(ctx, FLUSH_UPDATE_CURRENT); \ + ctx->NewState |= newstate; \ +} while (0) + +/** + * Macro to assert that the API call was made outside the + * glBegin()/glEnd() pair, with return value. + * + * \param ctx GL context. + * \param retval value to return value in case the assertion fails. + */ +#define ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, retval) \ +do { \ + if (ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END) { \ + _mesa_error(ctx, GL_INVALID_OPERATION, "Inside glBegin/glEnd"); \ + return retval; \ + } \ +} while (0) + +/** + * Macro to assert that the API call was made outside the + * glBegin()/glEnd() pair. + * + * \param ctx GL context. + */ +#define ASSERT_OUTSIDE_BEGIN_END(ctx) \ +do { \ + if (ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END) { \ + _mesa_error(ctx, GL_INVALID_OPERATION, "Inside glBegin/glEnd"); \ + return; \ + } \ +} while (0) + +/** + * Macro to assert that the API call was made outside the + * glBegin()/glEnd() pair and flush the vertices. + * + * \param ctx GL context. + */ +#define ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx) \ +do { \ + ASSERT_OUTSIDE_BEGIN_END(ctx); \ + FLUSH_VERTICES(ctx, 0); \ +} while (0) + +/** + * Macro to assert that the API call was made outside the + * glBegin()/glEnd() pair and flush the vertices, with return value. + * + * \param ctx GL context. + * \param retval value to return value in case the assertion fails. + */ +#define ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx, retval) \ +do { \ + ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, retval); \ + FLUSH_VERTICES(ctx, 0); \ +} while (0) + +/*@}*/ + + + +#endif /* CONTEXT_H */ diff --git a/mesalib/src/mesa/main/convolve.c b/mesalib/src/mesa/main/convolve.c index 104f71ff8..74f28da87 100644 --- a/mesalib/src/mesa/main/convolve.c +++ b/mesalib/src/mesa/main/convolve.c @@ -1,205 +1,205 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5.2 - * - * 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. - */ - - -/* - * Image convolution functions. - * - * Notes: filter kernel elements are indexed by and as in - * the GL spec. - */ - - -#include "glheader.h" -#include "bufferobj.h" -#include "colormac.h" -#include "convolve.h" -#include "macros.h" -#include "mfeatures.h" -#include "mtypes.h" -#include "main/dispatch.h" - - -#if FEATURE_convolve - -static void GLAPIENTRY -_mesa_ConvolutionFilter1D(GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *image) -{ - GET_CURRENT_CONTEXT(ctx); - - _mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionFilter1D"); -} - -static void GLAPIENTRY -_mesa_ConvolutionFilter2D(GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image) -{ - GET_CURRENT_CONTEXT(ctx); - - _mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionFilter2D"); -} - - -static void GLAPIENTRY -_mesa_ConvolutionParameterf(GLenum target, GLenum pname, GLfloat param) -{ - GET_CURRENT_CONTEXT(ctx); - - _mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionParameterf"); -} - - -static void GLAPIENTRY -_mesa_ConvolutionParameterfv(GLenum target, GLenum pname, const GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - - _mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionParameterfv"); -} - - -static void GLAPIENTRY -_mesa_ConvolutionParameteri(GLenum target, GLenum pname, GLint param) -{ - GET_CURRENT_CONTEXT(ctx); - - _mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionParameteri"); -} - - -static void GLAPIENTRY -_mesa_ConvolutionParameteriv(GLenum target, GLenum pname, const GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - - _mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionParameteriv"); -} - - -static void GLAPIENTRY -_mesa_CopyConvolutionFilter1D(GLenum target, GLenum internalFormat, GLint x, GLint y, GLsizei width) -{ - GET_CURRENT_CONTEXT(ctx); - - _mesa_error(ctx, GL_INVALID_ENUM, "glCopyConvolutionFilter1D"); -} - - -static void GLAPIENTRY -_mesa_CopyConvolutionFilter2D(GLenum target, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height) -{ - GET_CURRENT_CONTEXT(ctx); - - _mesa_error(ctx, GL_INVALID_ENUM, "glCopyConvolutionFilter2D"); -} - - -static void GLAPIENTRY -_mesa_GetnConvolutionFilterARB(GLenum target, GLenum format, GLenum type, - GLsizei bufSize, GLvoid *image) -{ - GET_CURRENT_CONTEXT(ctx); - - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetConvolutionFilter"); -} - - -static void GLAPIENTRY -_mesa_GetConvolutionFilter(GLenum target, GLenum format, GLenum type, - GLvoid *image) -{ - _mesa_GetnConvolutionFilterARB(target, format, type, INT_MAX, image); -} - - -static void GLAPIENTRY -_mesa_GetConvolutionParameterfv(GLenum target, GLenum pname, GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - - _mesa_error(ctx, GL_INVALID_ENUM, "glGetConvolutionParameterfv"); -} - - -static void GLAPIENTRY -_mesa_GetConvolutionParameteriv(GLenum target, GLenum pname, GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - - _mesa_error(ctx, GL_INVALID_ENUM, "glGetConvolutionParameteriv"); -} - - -static void GLAPIENTRY -_mesa_GetnSeparableFilterARB(GLenum target, GLenum format, GLenum type, - GLsizei rowBufSize, GLvoid *row, - GLsizei columnBufSize, GLvoid *column, - GLvoid *span) -{ - GET_CURRENT_CONTEXT(ctx); - - _mesa_error(ctx, GL_INVALID_ENUM, "glGetSeparableFilter"); -} - - -static void GLAPIENTRY -_mesa_GetSeparableFilter(GLenum target, GLenum format, GLenum type, - GLvoid *row, GLvoid *column, GLvoid *span) -{ - _mesa_GetnSeparableFilterARB(target, format, type, INT_MAX, row, - INT_MAX, column, span); -} - - -static void GLAPIENTRY -_mesa_SeparableFilter2D(GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column) -{ - GET_CURRENT_CONTEXT(ctx); - - _mesa_error(ctx, GL_INVALID_ENUM, "glSeparableFilter2D"); -} - -void -_mesa_init_convolve_dispatch(struct _glapi_table *disp) -{ - SET_ConvolutionFilter1D(disp, _mesa_ConvolutionFilter1D); - SET_ConvolutionFilter2D(disp, _mesa_ConvolutionFilter2D); - SET_ConvolutionParameterf(disp, _mesa_ConvolutionParameterf); - SET_ConvolutionParameterfv(disp, _mesa_ConvolutionParameterfv); - SET_ConvolutionParameteri(disp, _mesa_ConvolutionParameteri); - SET_ConvolutionParameteriv(disp, _mesa_ConvolutionParameteriv); - SET_CopyConvolutionFilter1D(disp, _mesa_CopyConvolutionFilter1D); - SET_CopyConvolutionFilter2D(disp, _mesa_CopyConvolutionFilter2D); - SET_GetConvolutionFilter(disp, _mesa_GetConvolutionFilter); - SET_GetConvolutionParameterfv(disp, _mesa_GetConvolutionParameterfv); - SET_GetConvolutionParameteriv(disp, _mesa_GetConvolutionParameteriv); - SET_SeparableFilter2D(disp, _mesa_SeparableFilter2D); - SET_GetSeparableFilter(disp, _mesa_GetSeparableFilter); - - /* GL_ARB_robustness */ - SET_GetnConvolutionFilterARB(disp, _mesa_GetnConvolutionFilterARB); - SET_GetnSeparableFilterARB(disp, _mesa_GetnSeparableFilterARB); -} - - -#endif /* FEATURE_convolve */ +/* + * Mesa 3-D graphics library + * Version: 6.5.2 + * + * 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. + */ + + +/* + * Image convolution functions. + * + * Notes: filter kernel elements are indexed by and as in + * the GL spec. + */ + + +#include "glheader.h" +#include "bufferobj.h" +#include "colormac.h" +#include "convolve.h" +#include "macros.h" +#include "mfeatures.h" +#include "mtypes.h" +#include "main/dispatch.h" + + +#if FEATURE_convolve + +static void GLAPIENTRY +_mesa_ConvolutionFilter1D(GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *image) +{ + GET_CURRENT_CONTEXT(ctx); + + _mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionFilter1D"); +} + +static void GLAPIENTRY +_mesa_ConvolutionFilter2D(GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image) +{ + GET_CURRENT_CONTEXT(ctx); + + _mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionFilter2D"); +} + + +static void GLAPIENTRY +_mesa_ConvolutionParameterf(GLenum target, GLenum pname, GLfloat param) +{ + GET_CURRENT_CONTEXT(ctx); + + _mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionParameterf"); +} + + +static void GLAPIENTRY +_mesa_ConvolutionParameterfv(GLenum target, GLenum pname, const GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + + _mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionParameterfv"); +} + + +static void GLAPIENTRY +_mesa_ConvolutionParameteri(GLenum target, GLenum pname, GLint param) +{ + GET_CURRENT_CONTEXT(ctx); + + _mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionParameteri"); +} + + +static void GLAPIENTRY +_mesa_ConvolutionParameteriv(GLenum target, GLenum pname, const GLint *params) +{ + GET_CURRENT_CONTEXT(ctx); + + _mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionParameteriv"); +} + + +static void GLAPIENTRY +_mesa_CopyConvolutionFilter1D(GLenum target, GLenum internalFormat, GLint x, GLint y, GLsizei width) +{ + GET_CURRENT_CONTEXT(ctx); + + _mesa_error(ctx, GL_INVALID_ENUM, "glCopyConvolutionFilter1D"); +} + + +static void GLAPIENTRY +_mesa_CopyConvolutionFilter2D(GLenum target, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height) +{ + GET_CURRENT_CONTEXT(ctx); + + _mesa_error(ctx, GL_INVALID_ENUM, "glCopyConvolutionFilter2D"); +} + + +static void GLAPIENTRY +_mesa_GetnConvolutionFilterARB(GLenum target, GLenum format, GLenum type, + GLsizei bufSize, GLvoid *image) +{ + GET_CURRENT_CONTEXT(ctx); + + _mesa_error(ctx, GL_INVALID_OPERATION, "glGetConvolutionFilter"); +} + + +static void GLAPIENTRY +_mesa_GetConvolutionFilter(GLenum target, GLenum format, GLenum type, + GLvoid *image) +{ + _mesa_GetnConvolutionFilterARB(target, format, type, INT_MAX, image); +} + + +static void GLAPIENTRY +_mesa_GetConvolutionParameterfv(GLenum target, GLenum pname, GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + + _mesa_error(ctx, GL_INVALID_ENUM, "glGetConvolutionParameterfv"); +} + + +static void GLAPIENTRY +_mesa_GetConvolutionParameteriv(GLenum target, GLenum pname, GLint *params) +{ + GET_CURRENT_CONTEXT(ctx); + + _mesa_error(ctx, GL_INVALID_ENUM, "glGetConvolutionParameteriv"); +} + + +static void GLAPIENTRY +_mesa_GetnSeparableFilterARB(GLenum target, GLenum format, GLenum type, + GLsizei rowBufSize, GLvoid *row, + GLsizei columnBufSize, GLvoid *column, + GLvoid *span) +{ + GET_CURRENT_CONTEXT(ctx); + + _mesa_error(ctx, GL_INVALID_ENUM, "glGetSeparableFilter"); +} + + +static void GLAPIENTRY +_mesa_GetSeparableFilter(GLenum target, GLenum format, GLenum type, + GLvoid *row, GLvoid *column, GLvoid *span) +{ + _mesa_GetnSeparableFilterARB(target, format, type, INT_MAX, row, + INT_MAX, column, span); +} + + +static void GLAPIENTRY +_mesa_SeparableFilter2D(GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column) +{ + GET_CURRENT_CONTEXT(ctx); + + _mesa_error(ctx, GL_INVALID_ENUM, "glSeparableFilter2D"); +} + +void +_mesa_init_convolve_dispatch(struct _glapi_table *disp) +{ + SET_ConvolutionFilter1D(disp, _mesa_ConvolutionFilter1D); + SET_ConvolutionFilter2D(disp, _mesa_ConvolutionFilter2D); + SET_ConvolutionParameterf(disp, _mesa_ConvolutionParameterf); + SET_ConvolutionParameterfv(disp, _mesa_ConvolutionParameterfv); + SET_ConvolutionParameteri(disp, _mesa_ConvolutionParameteri); + SET_ConvolutionParameteriv(disp, _mesa_ConvolutionParameteriv); + SET_CopyConvolutionFilter1D(disp, _mesa_CopyConvolutionFilter1D); + SET_CopyConvolutionFilter2D(disp, _mesa_CopyConvolutionFilter2D); + SET_GetConvolutionFilter(disp, _mesa_GetConvolutionFilter); + SET_GetConvolutionParameterfv(disp, _mesa_GetConvolutionParameterfv); + SET_GetConvolutionParameteriv(disp, _mesa_GetConvolutionParameteriv); + SET_SeparableFilter2D(disp, _mesa_SeparableFilter2D); + SET_GetSeparableFilter(disp, _mesa_GetSeparableFilter); + + /* GL_ARB_robustness */ + SET_GetnConvolutionFilterARB(disp, _mesa_GetnConvolutionFilterARB); + SET_GetnSeparableFilterARB(disp, _mesa_GetnSeparableFilterARB); +} + + +#endif /* FEATURE_convolve */ diff --git a/mesalib/src/mesa/main/dd.h b/mesalib/src/mesa/main/dd.h index 60c1d70a5..b77e4f092 100644 --- a/mesalib/src/mesa/main/dd.h +++ b/mesalib/src/mesa/main/dd.h @@ -1,1217 +1,1217 @@ -/** - * \file dd.h - * Device driver interfaces. - */ - -/* - * Mesa 3-D graphics library - * Version: 6.5.2 - * - * 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. - */ - - -#ifndef DD_INCLUDED -#define DD_INCLUDED - -/* THIS FILE ONLY INCLUDED BY mtypes.h !!!!! */ - -#include "glheader.h" - -struct gl_buffer_object; -struct gl_context; -struct gl_display_list; -struct gl_framebuffer; -struct gl_pixelstore_attrib; -struct gl_program; -struct gl_renderbuffer; -struct gl_renderbuffer_attachment; -struct gl_shader; -struct gl_shader_program; -struct gl_texture_image; -struct gl_texture_object; - -/* GL_ARB_vertex_buffer_object */ -/* Modifies GL_MAP_UNSYNCHRONIZED_BIT to allow driver to fail (return - * NULL) if buffer is unavailable for immediate mapping. - * - * Does GL_MAP_INVALIDATE_RANGE_BIT do this? It seems so, but it - * would require more book-keeping in the driver than seems necessary - * at this point. - * - * Does GL_MAP_INVALDIATE_BUFFER_BIT do this? Not really -- we don't - * want to provoke the driver to throw away the old storage, we will - * respect the contents of already referenced data. - */ -#define MESA_MAP_NOWAIT_BIT 0x0040 - - -/** - * Device driver function table. - * Core Mesa uses these function pointers to call into device drivers. - * Most of these functions directly correspond to OpenGL state commands. - * Core Mesa will call these functions after error checking has been done - * so that the drivers don't have to worry about error testing. - * - * Vertex transformation/clipping/lighting is patched into the T&L module. - * Rasterization functions are patched into the swrast module. - * - * Note: when new functions are added here, the drivers/common/driverfuncs.c - * file should be updated too!!! - */ -struct dd_function_table { - /** - * Return a string as needed by glGetString(). - * Only the GL_RENDERER query must be implemented. Otherwise, NULL can be - * returned. - */ - const GLubyte * (*GetString)( struct gl_context *ctx, GLenum name ); - - /** - * Notify the driver after Mesa has made some internal state changes. - * - * This is in addition to any state change callbacks Mesa may already have - * made. - */ - void (*UpdateState)( struct gl_context *ctx, GLbitfield new_state ); - - /** - * Get the width and height of the named buffer/window. - * - * Mesa uses this to determine when the driver's window size has changed. - * XXX OBSOLETE: this function will be removed in the future. - */ - void (*GetBufferSize)( struct gl_framebuffer *buffer, - GLuint *width, GLuint *height ); - - /** - * Resize the given framebuffer to the given size. - * XXX OBSOLETE: this function will be removed in the future. - */ - void (*ResizeBuffers)( struct gl_context *ctx, struct gl_framebuffer *fb, - GLuint width, GLuint height); - - /** - * Called whenever an error is generated. - * __struct gl_contextRec::ErrorValue contains the error value. - */ - void (*Error)( struct gl_context *ctx ); - - /** - * This is called whenever glFinish() is called. - */ - void (*Finish)( struct gl_context *ctx ); - - /** - * This is called whenever glFlush() is called. - */ - void (*Flush)( struct gl_context *ctx ); - - /** - * Clear the color/depth/stencil/accum buffer(s). - * \param buffers a bitmask of BUFFER_BIT_* flags indicating which - * renderbuffers need to be cleared. - */ - void (*Clear)( struct gl_context *ctx, GLbitfield buffers ); - - /** - * Execute glAccum command. - */ - void (*Accum)( struct gl_context *ctx, GLenum op, GLfloat value ); - - - /** - * Execute glRasterPos, updating the ctx->Current.Raster fields - */ - void (*RasterPos)( struct gl_context *ctx, const GLfloat v[4] ); - - /** - * \name Image-related functions - */ - /*@{*/ - - /** - * Called by glDrawPixels(). - * \p unpack describes how to unpack the source image data. - */ - void (*DrawPixels)( struct gl_context *ctx, - GLint x, GLint y, GLsizei width, GLsizei height, - GLenum format, GLenum type, - const struct gl_pixelstore_attrib *unpack, - const GLvoid *pixels ); - - /** - * Called by glReadPixels(). - */ - void (*ReadPixels)( struct gl_context *ctx, - GLint x, GLint y, GLsizei width, GLsizei height, - GLenum format, GLenum type, - const struct gl_pixelstore_attrib *unpack, - GLvoid *dest ); - - /** - * Called by glCopyPixels(). - */ - void (*CopyPixels)( struct gl_context *ctx, GLint srcx, GLint srcy, - GLsizei width, GLsizei height, - GLint dstx, GLint dsty, GLenum type ); - - /** - * Called by glBitmap(). - */ - void (*Bitmap)( struct gl_context *ctx, - GLint x, GLint y, GLsizei width, GLsizei height, - const struct gl_pixelstore_attrib *unpack, - const GLubyte *bitmap ); - /*@}*/ - - - /** - * \name Texture image functions - */ - /*@{*/ - - /** - * Choose actual hardware texture format given the user-provided source - * image format and type and the desired internal format. In some - * cases, srcFormat and srcType can be GL_NONE. - * Called by glTexImage(), etc. - */ - gl_format (*ChooseTextureFormat)( struct gl_context *ctx, GLint internalFormat, - GLenum srcFormat, GLenum srcType ); - - /** - * Called by glTexImage1D(). Simply copy the source texture data into the - * destination texture memory. The gl_texture_image fields, etc. will be - * fully initialized. - * The parameters are the same as glTexImage1D(), plus: - * \param packing describes how to unpack the source data. - * \param texObj is the target texture object. - * \param texImage is the target texture image. - */ - void (*TexImage1D)( struct gl_context *ctx, GLenum target, GLint level, - GLint internalFormat, - GLint width, GLint border, - GLenum format, GLenum type, const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage ); - - /** - * Called by glTexImage2D(). - * - * \sa dd_function_table::TexImage1D. - */ - void (*TexImage2D)( struct gl_context *ctx, GLenum target, GLint level, - GLint internalFormat, - GLint width, GLint height, GLint border, - GLenum format, GLenum type, const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage ); - - /** - * Called by glTexImage3D(). - * - * \sa dd_function_table::TexImage1D. - */ - void (*TexImage3D)( struct gl_context *ctx, GLenum target, GLint level, - GLint internalFormat, - GLint width, GLint height, GLint depth, GLint border, - GLenum format, GLenum type, const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage ); - - /** - * Called by glTexSubImage1D(). Replace a subset of the target texture - * with new texel data. - * \sa dd_function_table::TexImage1D. - */ - void (*TexSubImage1D)( struct gl_context *ctx, GLenum target, GLint level, - GLint xoffset, GLsizei width, - GLenum format, GLenum type, - const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage ); - - /** - * Called by glTexSubImage2D(). - * - * \sa dd_function_table::TexSubImage1D. - */ - void (*TexSubImage2D)( struct gl_context *ctx, GLenum target, GLint level, - GLint xoffset, GLint yoffset, - GLsizei width, GLsizei height, - GLenum format, GLenum type, - const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage ); - - /** - * Called by glTexSubImage3D(). - * - * \sa dd_function_table::TexSubImage1D. - */ - void (*TexSubImage3D)( struct gl_context *ctx, GLenum target, GLint level, - GLint xoffset, GLint yoffset, GLint zoffset, - GLsizei width, GLsizei height, GLint depth, - GLenum format, GLenum type, - const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage ); - - /** - * Called by glGetTexImage(). - */ - void (*GetTexImage)( struct gl_context *ctx, GLenum target, GLint level, - GLenum format, GLenum type, GLvoid *pixels, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage ); - - /** - * Called by glCopyTexSubImage1D(). - * - * Drivers should use a fallback routine from texstore.c if needed. - */ - void (*CopyTexSubImage1D)( struct gl_context *ctx, GLenum target, GLint level, - GLint xoffset, - GLint x, GLint y, GLsizei width ); - /** - * Called by glCopyTexSubImage2D(). - * - * Drivers should use a fallback routine from texstore.c if needed. - */ - void (*CopyTexSubImage2D)( struct gl_context *ctx, GLenum target, GLint level, - GLint xoffset, GLint yoffset, - GLint x, GLint y, - GLsizei width, GLsizei height ); - /** - * Called by glCopyTexSubImage3D(). - * - * Drivers should use a fallback routine from texstore.c if needed. - */ - void (*CopyTexSubImage3D)( struct gl_context *ctx, GLenum target, GLint level, - GLint xoffset, GLint yoffset, GLint zoffset, - GLint x, GLint y, - GLsizei width, GLsizei height ); - - /** - * Called by glGenerateMipmap() or when GL_GENERATE_MIPMAP_SGIS is enabled. - */ - void (*GenerateMipmap)(struct gl_context *ctx, GLenum target, - struct gl_texture_object *texObj); - - /** - * Called by glTexImage[123]D when user specifies a proxy texture - * target. - * - * \return GL_TRUE if the proxy test passes, or GL_FALSE if the test fails. - */ - GLboolean (*TestProxyTexImage)(struct gl_context *ctx, GLenum target, - GLint level, GLint internalFormat, - GLenum format, GLenum type, - GLint width, GLint height, - GLint depth, GLint border); - /*@}*/ - - - /** - * \name Compressed texture functions - */ - /*@{*/ - - /** - * Called by glCompressedTexImage1D(). - * - * \param target user specified. - * \param format user specified. - * \param type user specified. - * \param pixels user specified. - * \param packing indicates the image packing of pixels. - * \param texObj is the target texture object. - * \param texImage is the target texture image. It will have the texture \p - * width, \p height, \p depth, \p border and \p internalFormat information. - * - * \a retainInternalCopy is returned by this function and indicates whether - * core Mesa should keep an internal copy of the texture image. - */ - void (*CompressedTexImage1D)( struct gl_context *ctx, GLenum target, - GLint level, GLint internalFormat, - GLsizei width, GLint border, - GLsizei imageSize, const GLvoid *data, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage ); - /** - * Called by glCompressedTexImage2D(). - * - * \sa dd_function_table::CompressedTexImage1D. - */ - void (*CompressedTexImage2D)( struct gl_context *ctx, GLenum target, - GLint level, GLint internalFormat, - GLsizei width, GLsizei height, GLint border, - GLsizei imageSize, const GLvoid *data, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage ); - /** - * Called by glCompressedTexImage3D(). - * - * \sa dd_function_table::CompressedTexImage3D. - */ - void (*CompressedTexImage3D)( struct gl_context *ctx, GLenum target, - GLint level, GLint internalFormat, - GLsizei width, GLsizei height, GLsizei depth, - GLint border, - GLsizei imageSize, const GLvoid *data, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage ); - - /** - * Called by glCompressedTexSubImage1D(). - * - * \param target user specified. - * \param level user specified. - * \param xoffset user specified. - * \param yoffset user specified. - * \param zoffset user specified. - * \param width user specified. - * \param height user specified. - * \param depth user specified. - * \param imageSize user specified. - * \param data user specified. - * \param texObj is the target texture object. - * \param texImage is the target texture image. It will have the texture \p - * width, \p height, \p depth, \p border and \p internalFormat information. - */ - void (*CompressedTexSubImage1D)(struct gl_context *ctx, GLenum target, GLint level, - GLint xoffset, GLsizei width, - GLenum format, - GLsizei imageSize, const GLvoid *data, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage); - /** - * Called by glCompressedTexSubImage2D(). - * - * \sa dd_function_table::CompressedTexImage3D. - */ - void (*CompressedTexSubImage2D)(struct gl_context *ctx, GLenum target, GLint level, - GLint xoffset, GLint yoffset, - GLsizei width, GLint height, - GLenum format, - GLsizei imageSize, const GLvoid *data, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage); - /** - * Called by glCompressedTexSubImage3D(). - * - * \sa dd_function_table::CompressedTexImage3D. - */ - void (*CompressedTexSubImage3D)(struct gl_context *ctx, GLenum target, GLint level, - GLint xoffset, GLint yoffset, GLint zoffset, - GLsizei width, GLint height, GLint depth, - GLenum format, - GLsizei imageSize, const GLvoid *data, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage); - - - /** - * Called by glGetCompressedTexImage. - */ - void (*GetCompressedTexImage)(struct gl_context *ctx, GLenum target, GLint level, - GLvoid *img, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage); - - /*@}*/ - - /** - * \name Texture object functions - */ - /*@{*/ - - /** - * Called by glBindTexture(). - */ - void (*BindTexture)( struct gl_context *ctx, GLenum target, - struct gl_texture_object *tObj ); - - /** - * Called to allocate a new texture object. - * A new gl_texture_object should be returned. The driver should - * attach to it any device-specific info it needs. - */ - struct gl_texture_object * (*NewTextureObject)( struct gl_context *ctx, GLuint name, - GLenum target ); - /** - * Called when a texture object is about to be deallocated. - * - * Driver should delete the gl_texture_object object and anything - * hanging off of it. - */ - void (*DeleteTexture)( struct gl_context *ctx, struct gl_texture_object *tObj ); - - /** - * Called to allocate a new texture image object. - */ - struct gl_texture_image * (*NewTextureImage)( struct gl_context *ctx ); - - /** - * Called to free tImage->Data. - */ - void (*FreeTextureImageBuffer)( struct gl_context *ctx, struct gl_texture_image *tImage ); - - /** Map a slice of a texture image into user space. - * \param texImage the texture image - * \param slice the 3D image slice or array texture slice - * \param x, y, w, h region of interest - * \param mode bitmask of GL_MAP_READ_BIT, GL_MAP_WRITE_BIT - * \param mapOut returns start of mapping of region of interest - * \param rowStrideOut returns row stride (in bytes) - */ - void (*MapTextureImage)(struct gl_context *ctx, - struct gl_texture_image *texImage, - GLuint slice, - GLuint x, GLuint y, GLuint w, GLuint h, - GLbitfield mode, - GLubyte **mapOut, GLint *rowStrideOut); - - void (*UnmapTextureImage)(struct gl_context *ctx, - struct gl_texture_image *texImage, - GLuint slice); - - /** Map texture image data into user space */ - void (*MapTexture)( struct gl_context *ctx, struct gl_texture_object *tObj ); - /** Unmap texture images from user space */ - void (*UnmapTexture)( struct gl_context *ctx, struct gl_texture_object *tObj ); - - /** - * Note: no context argument. This function doesn't initially look - * like it belongs here, except that the driver is the only entity - * that knows for sure how the texture memory is allocated - via - * the above callbacks. There is then an argument that the driver - * knows what memcpy paths might be fast. Typically this is invoked with - * - * to -- a pointer into texture memory allocated by NewTextureImage() above. - * from -- a pointer into client memory or a mesa temporary. - * sz -- nr bytes to copy. - */ - void* (*TextureMemCpy)( void *to, const void *from, size_t sz ); - - /** - * Called by glAreTextureResident(). - */ - GLboolean (*IsTextureResident)( struct gl_context *ctx, - struct gl_texture_object *t ); - /*@}*/ - - - /** - * \name Vertex/fragment program functions - */ - /*@{*/ - /** Bind a vertex/fragment program */ - void (*BindProgram)(struct gl_context *ctx, GLenum target, struct gl_program *prog); - /** Allocate a new program */ - struct gl_program * (*NewProgram)(struct gl_context *ctx, GLenum target, GLuint id); - /** Delete a program */ - void (*DeleteProgram)(struct gl_context *ctx, struct gl_program *prog); - /** - * Notify driver that a program string (and GPU code) has been specified - * or modified. Return GL_TRUE or GL_FALSE to indicate if the program is - * supported by the driver. - */ - GLboolean (*ProgramStringNotify)(struct gl_context *ctx, GLenum target, - struct gl_program *prog); - - /** Query if program can be loaded onto hardware */ - GLboolean (*IsProgramNative)(struct gl_context *ctx, GLenum target, - struct gl_program *prog); - - /*@}*/ - - /** - * \name GLSL shader/program functions. - */ - /*@{*/ - /** - * Called when a shader program is linked. - * - * This gives drivers an opportunity to clone the IR and make their - * own transformations on it for the purposes of code generation. - */ - GLboolean (*LinkShader)(struct gl_context *ctx, struct gl_shader_program *shader); - /*@}*/ - - /** - * \name State-changing functions. - * - * \note drawing functions are above. - * - * These functions are called by their corresponding OpenGL API functions. - * They are \e also called by the gl_PopAttrib() function!!! - * May add more functions like these to the device driver in the future. - */ - /*@{*/ - /** Specify the alpha test function */ - void (*AlphaFunc)(struct gl_context *ctx, GLenum func, GLfloat ref); - /** Set the blend color */ - void (*BlendColor)(struct gl_context *ctx, const GLfloat color[4]); - /** Set the blend equation */ - void (*BlendEquationSeparate)(struct gl_context *ctx, GLenum modeRGB, GLenum modeA); - void (*BlendEquationSeparatei)(struct gl_context *ctx, GLuint buffer, - GLenum modeRGB, GLenum modeA); - /** Specify pixel arithmetic */ - void (*BlendFuncSeparate)(struct gl_context *ctx, - GLenum sfactorRGB, GLenum dfactorRGB, - GLenum sfactorA, GLenum dfactorA); - void (*BlendFuncSeparatei)(struct gl_context *ctx, GLuint buffer, - GLenum sfactorRGB, GLenum dfactorRGB, - GLenum sfactorA, GLenum dfactorA); - /** Specify clear values for the color buffers */ - void (*ClearColor)(struct gl_context *ctx, const GLfloat color[4]); - /** Specify the clear value for the depth buffer */ - void (*ClearDepth)(struct gl_context *ctx, GLclampd d); - /** Specify the clear value for the stencil buffer */ - void (*ClearStencil)(struct gl_context *ctx, GLint s); - /** Specify a plane against which all geometry is clipped */ - void (*ClipPlane)(struct gl_context *ctx, GLenum plane, const GLfloat *equation ); - /** Enable and disable writing of frame buffer color components */ - void (*ColorMask)(struct gl_context *ctx, GLboolean rmask, GLboolean gmask, - GLboolean bmask, GLboolean amask ); - void (*ColorMaskIndexed)(struct gl_context *ctx, GLuint buf, GLboolean rmask, - GLboolean gmask, GLboolean bmask, GLboolean amask); - /** Cause a material color to track the current color */ - void (*ColorMaterial)(struct gl_context *ctx, GLenum face, GLenum mode); - /** Specify whether front- or back-facing facets can be culled */ - void (*CullFace)(struct gl_context *ctx, GLenum mode); - /** Define front- and back-facing polygons */ - void (*FrontFace)(struct gl_context *ctx, GLenum mode); - /** Specify the value used for depth buffer comparisons */ - void (*DepthFunc)(struct gl_context *ctx, GLenum func); - /** Enable or disable writing into the depth buffer */ - void (*DepthMask)(struct gl_context *ctx, GLboolean flag); - /** Specify mapping of depth values from NDC to window coordinates */ - void (*DepthRange)(struct gl_context *ctx, GLclampd nearval, GLclampd farval); - /** Specify the current buffer for writing */ - void (*DrawBuffer)( struct gl_context *ctx, GLenum buffer ); - /** Specify the buffers for writing for fragment programs*/ - void (*DrawBuffers)( struct gl_context *ctx, GLsizei n, const GLenum *buffers ); - /** Enable or disable server-side gl capabilities */ - void (*Enable)(struct gl_context *ctx, GLenum cap, GLboolean state); - /** Specify fog parameters */ - void (*Fogfv)(struct gl_context *ctx, GLenum pname, const GLfloat *params); - /** Specify implementation-specific hints */ - void (*Hint)(struct gl_context *ctx, GLenum target, GLenum mode); - /** Set light source parameters. - * Note: for GL_POSITION and GL_SPOT_DIRECTION, params will have already - * been transformed to eye-space. - */ - void (*Lightfv)(struct gl_context *ctx, GLenum light, - GLenum pname, const GLfloat *params ); - /** Set the lighting model parameters */ - void (*LightModelfv)(struct gl_context *ctx, GLenum pname, const GLfloat *params); - /** Specify the line stipple pattern */ - void (*LineStipple)(struct gl_context *ctx, GLint factor, GLushort pattern ); - /** Specify the width of rasterized lines */ - void (*LineWidth)(struct gl_context *ctx, GLfloat width); - /** Specify a logical pixel operation for color index rendering */ - void (*LogicOpcode)(struct gl_context *ctx, GLenum opcode); - void (*PointParameterfv)(struct gl_context *ctx, GLenum pname, - const GLfloat *params); - /** Specify the diameter of rasterized points */ - void (*PointSize)(struct gl_context *ctx, GLfloat size); - /** Select a polygon rasterization mode */ - void (*PolygonMode)(struct gl_context *ctx, GLenum face, GLenum mode); - /** Set the scale and units used to calculate depth values */ - void (*PolygonOffset)(struct gl_context *ctx, GLfloat factor, GLfloat units); - /** Set the polygon stippling pattern */ - void (*PolygonStipple)(struct gl_context *ctx, const GLubyte *mask ); - /* Specifies the current buffer for reading */ - void (*ReadBuffer)( struct gl_context *ctx, GLenum buffer ); - /** Set rasterization mode */ - void (*RenderMode)(struct gl_context *ctx, GLenum mode ); - /** Define the scissor box */ - void (*Scissor)(struct gl_context *ctx, GLint x, GLint y, GLsizei w, GLsizei h); - /** Select flat or smooth shading */ - void (*ShadeModel)(struct gl_context *ctx, GLenum mode); - /** OpenGL 2.0 two-sided StencilFunc */ - void (*StencilFuncSeparate)(struct gl_context *ctx, GLenum face, GLenum func, - GLint ref, GLuint mask); - /** OpenGL 2.0 two-sided StencilMask */ - void (*StencilMaskSeparate)(struct gl_context *ctx, GLenum face, GLuint mask); - /** OpenGL 2.0 two-sided StencilOp */ - void (*StencilOpSeparate)(struct gl_context *ctx, GLenum face, GLenum fail, - GLenum zfail, GLenum zpass); - /** Control the generation of texture coordinates */ - void (*TexGen)(struct gl_context *ctx, GLenum coord, GLenum pname, - const GLfloat *params); - /** Set texture environment parameters */ - void (*TexEnv)(struct gl_context *ctx, GLenum target, GLenum pname, - const GLfloat *param); - /** Set texture parameters */ - void (*TexParameter)(struct gl_context *ctx, GLenum target, - struct gl_texture_object *texObj, - GLenum pname, const GLfloat *params); - /** Set the viewport */ - void (*Viewport)(struct gl_context *ctx, GLint x, GLint y, GLsizei w, GLsizei h); - /*@}*/ - - - /** - * \name Vertex/pixel buffer object functions - */ - /*@{*/ - void (*BindBuffer)( struct gl_context *ctx, GLenum target, - struct gl_buffer_object *obj ); - - struct gl_buffer_object * (*NewBufferObject)( struct gl_context *ctx, GLuint buffer, - GLenum target ); - - void (*DeleteBuffer)( struct gl_context *ctx, struct gl_buffer_object *obj ); - - GLboolean (*BufferData)( struct gl_context *ctx, GLenum target, GLsizeiptrARB size, - const GLvoid *data, GLenum usage, - struct gl_buffer_object *obj ); - - void (*BufferSubData)( struct gl_context *ctx, GLintptrARB offset, - GLsizeiptrARB size, const GLvoid *data, - struct gl_buffer_object *obj ); - - void (*GetBufferSubData)( struct gl_context *ctx, - GLintptrARB offset, GLsizeiptrARB size, - GLvoid *data, struct gl_buffer_object *obj ); - - void (*CopyBufferSubData)( struct gl_context *ctx, - struct gl_buffer_object *src, - struct gl_buffer_object *dst, - GLintptr readOffset, GLintptr writeOffset, - GLsizeiptr size ); - - /* May return NULL if MESA_MAP_NOWAIT_BIT is set in access: - */ - void * (*MapBufferRange)( struct gl_context *ctx, GLintptr offset, - GLsizeiptr length, GLbitfield access, - struct gl_buffer_object *obj); - - void (*FlushMappedBufferRange)(struct gl_context *ctx, - GLintptr offset, GLsizeiptr length, - struct gl_buffer_object *obj); - - GLboolean (*UnmapBuffer)( struct gl_context *ctx, - struct gl_buffer_object *obj ); - /*@}*/ - - /** - * \name Functions for GL_APPLE_object_purgeable - */ - /*@{*/ - /* variations on ObjectPurgeable */ - GLenum (*BufferObjectPurgeable)( struct gl_context *ctx, struct gl_buffer_object *obj, GLenum option ); - GLenum (*RenderObjectPurgeable)( struct gl_context *ctx, struct gl_renderbuffer *obj, GLenum option ); - GLenum (*TextureObjectPurgeable)( struct gl_context *ctx, struct gl_texture_object *obj, GLenum option ); - - /* variations on ObjectUnpurgeable */ - GLenum (*BufferObjectUnpurgeable)( struct gl_context *ctx, struct gl_buffer_object *obj, GLenum option ); - GLenum (*RenderObjectUnpurgeable)( struct gl_context *ctx, struct gl_renderbuffer *obj, GLenum option ); - GLenum (*TextureObjectUnpurgeable)( struct gl_context *ctx, struct gl_texture_object *obj, GLenum option ); - /*@}*/ - - /** - * \name Functions for GL_EXT_framebuffer_{object,blit}. - */ - /*@{*/ - struct gl_framebuffer * (*NewFramebuffer)(struct gl_context *ctx, GLuint name); - struct gl_renderbuffer * (*NewRenderbuffer)(struct gl_context *ctx, GLuint name); - void (*BindFramebuffer)(struct gl_context *ctx, GLenum target, - struct gl_framebuffer *drawFb, - struct gl_framebuffer *readFb); - void (*FramebufferRenderbuffer)(struct gl_context *ctx, - struct gl_framebuffer *fb, - GLenum attachment, - struct gl_renderbuffer *rb); - void (*RenderTexture)(struct gl_context *ctx, - struct gl_framebuffer *fb, - struct gl_renderbuffer_attachment *att); - void (*FinishRenderTexture)(struct gl_context *ctx, - struct gl_renderbuffer_attachment *att); - void (*ValidateFramebuffer)(struct gl_context *ctx, - struct gl_framebuffer *fb); - /*@}*/ - void (*BlitFramebuffer)(struct gl_context *ctx, - GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, - GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, - GLbitfield mask, GLenum filter); - - /** - * \name Query objects - */ - /*@{*/ - struct gl_query_object * (*NewQueryObject)(struct gl_context *ctx, GLuint id); - void (*DeleteQuery)(struct gl_context *ctx, struct gl_query_object *q); - void (*BeginQuery)(struct gl_context *ctx, struct gl_query_object *q); - void (*EndQuery)(struct gl_context *ctx, struct gl_query_object *q); - void (*CheckQuery)(struct gl_context *ctx, struct gl_query_object *q); - void (*WaitQuery)(struct gl_context *ctx, struct gl_query_object *q); - /*@}*/ - - - /** - * \name Vertex Array objects - */ - /*@{*/ - struct gl_array_object * (*NewArrayObject)(struct gl_context *ctx, GLuint id); - void (*DeleteArrayObject)(struct gl_context *ctx, struct gl_array_object *obj); - void (*BindArrayObject)(struct gl_context *ctx, struct gl_array_object *obj); - /*@}*/ - - /** - * \name GLSL-related functions (ARB extensions and OpenGL 2.x) - */ - /*@{*/ - struct gl_shader *(*NewShader)(struct gl_context *ctx, GLuint name, GLenum type); - void (*DeleteShader)(struct gl_context *ctx, struct gl_shader *shader); - struct gl_shader_program *(*NewShaderProgram)(struct gl_context *ctx, GLuint name); - void (*DeleteShaderProgram)(struct gl_context *ctx, - struct gl_shader_program *shProg); - void (*UseProgram)(struct gl_context *ctx, struct gl_shader_program *shProg); - /*@}*/ - - - /** - * \name Support for multiple T&L engines - */ - /*@{*/ - - /** - * Bitmask of state changes that require the current T&L module to be - * validated, using ValidateTnlModule() below. - */ - GLuint NeedValidate; - - /** - * Validate the current T&L module. - * - * This is called directly after UpdateState() when a state change that has - * occurred matches the dd_function_table::NeedValidate bitmask above. This - * ensures all computed values are up to date, thus allowing the driver to - * decide if the current T&L module needs to be swapped out. - * - * This must be non-NULL if a driver installs a custom T&L module and sets - * the dd_function_table::NeedValidate bitmask, but may be NULL otherwise. - */ - void (*ValidateTnlModule)( struct gl_context *ctx, GLuint new_state ); - - /** - * Set by the driver-supplied T&L engine. - * - * Set to PRIM_OUTSIDE_BEGIN_END when outside glBegin()/glEnd(). - */ - GLuint CurrentExecPrimitive; - - /** - * Current state of an in-progress compilation. - * - * May take on any of the additional values PRIM_OUTSIDE_BEGIN_END, - * PRIM_INSIDE_UNKNOWN_PRIM or PRIM_UNKNOWN defined above. - */ - GLuint CurrentSavePrimitive; - - -#define FLUSH_STORED_VERTICES 0x1 -#define FLUSH_UPDATE_CURRENT 0x2 - /** - * Set by the driver-supplied T&L engine whenever vertices are buffered - * between glBegin()/glEnd() objects or __struct gl_contextRec::Current is not - * updated. - * - * The dd_function_table::FlushVertices call below may be used to resolve - * these conditions. - */ - GLuint NeedFlush; - GLuint SaveNeedFlush; - - - /* Called prior to any of the GLvertexformat functions being - * called. Paired with Driver.FlushVertices(). - */ - void (*BeginVertices)( struct gl_context *ctx ); - - /** - * If inside glBegin()/glEnd(), it should ASSERT(0). Otherwise, if - * FLUSH_STORED_VERTICES bit in \p flags is set flushes any buffered - * vertices, if FLUSH_UPDATE_CURRENT bit is set updates - * __struct gl_contextRec::Current and gl_light_attrib::Material - * - * Note that the default T&L engine never clears the - * FLUSH_UPDATE_CURRENT bit, even after performing the update. - */ - void (*FlushVertices)( struct gl_context *ctx, GLuint flags ); - void (*SaveFlushVertices)( struct gl_context *ctx ); - - /** - * Give the driver the opportunity to hook in its own vtxfmt for - * compiling optimized display lists. This is called on each valid - * glBegin() during list compilation. - */ - GLboolean (*NotifySaveBegin)( struct gl_context *ctx, GLenum mode ); - - /** - * Notify driver that the special derived value _NeedEyeCoords has - * changed. - */ - void (*LightingSpaceChange)( struct gl_context *ctx ); - - /** - * Called by glNewList(). - * - * Let the T&L component know what is going on with display lists - * in time to make changes to dispatch tables, etc. - */ - void (*NewList)( struct gl_context *ctx, GLuint list, GLenum mode ); - /** - * Called by glEndList(). - * - * \sa dd_function_table::NewList. - */ - void (*EndList)( struct gl_context *ctx ); - - /** - * Called by glCallList(s). - * - * Notify the T&L component before and after calling a display list. - */ - void (*BeginCallList)( struct gl_context *ctx, - struct gl_display_list *dlist ); - /** - * Called by glEndCallList(). - * - * \sa dd_function_table::BeginCallList. - */ - void (*EndCallList)( struct gl_context *ctx ); - - - /** - * \name GL_ARB_sync interfaces - */ - /*@{*/ - struct gl_sync_object * (*NewSyncObject)(struct gl_context *, GLenum); - void (*FenceSync)(struct gl_context *, struct gl_sync_object *, GLenum, GLbitfield); - void (*DeleteSyncObject)(struct gl_context *, struct gl_sync_object *); - void (*CheckSync)(struct gl_context *, struct gl_sync_object *); - void (*ClientWaitSync)(struct gl_context *, struct gl_sync_object *, - GLbitfield, GLuint64); - void (*ServerWaitSync)(struct gl_context *, struct gl_sync_object *, - GLbitfield, GLuint64); - /*@}*/ - - /** GL_NV_conditional_render */ - void (*BeginConditionalRender)(struct gl_context *ctx, struct gl_query_object *q, - GLenum mode); - void (*EndConditionalRender)(struct gl_context *ctx, struct gl_query_object *q); - - /** - * \name GL_OES_draw_texture interface - */ - /*@{*/ - void (*DrawTex)(struct gl_context *ctx, GLfloat x, GLfloat y, GLfloat z, - GLfloat width, GLfloat height); - /*@}*/ - - /** - * \name GL_OES_EGL_image interface - */ - void (*EGLImageTargetTexture2D)(struct gl_context *ctx, GLenum target, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage, - GLeglImageOES image_handle); - void (*EGLImageTargetRenderbufferStorage)(struct gl_context *ctx, - struct gl_renderbuffer *rb, - void *image_handle); - - /** - * \name GL_EXT_transform_feedback interface - */ - struct gl_transform_feedback_object * - (*NewTransformFeedback)(struct gl_context *ctx, GLuint name); - void (*DeleteTransformFeedback)(struct gl_context *ctx, - struct gl_transform_feedback_object *obj); - void (*BeginTransformFeedback)(struct gl_context *ctx, GLenum mode, - struct gl_transform_feedback_object *obj); - void (*EndTransformFeedback)(struct gl_context *ctx, - struct gl_transform_feedback_object *obj); - void (*PauseTransformFeedback)(struct gl_context *ctx, - struct gl_transform_feedback_object *obj); - void (*ResumeTransformFeedback)(struct gl_context *ctx, - struct gl_transform_feedback_object *obj); - void (*DrawTransformFeedback)(struct gl_context *ctx, GLenum mode, - struct gl_transform_feedback_object *obj); - - /** - * \name GL_NV_texture_barrier interface - */ - void (*TextureBarrier)(struct gl_context *ctx); - - /** - * \name GL_ARB_sampler_objects - */ - struct gl_sampler_object * (*NewSamplerObject)(struct gl_context *ctx, - GLuint name); - void (*DeleteSamplerObject)(struct gl_context *ctx, - struct gl_sampler_object *samp); -}; - - -/** - * Transform/Clip/Lighting interface - * - * Drivers present a reduced set of the functions possible in - * glBegin()/glEnd() objects. Core mesa provides translation stubs for the - * remaining functions to map down to these entry points. - * - * These are the initial values to be installed into dispatch by - * mesa. If the T&L driver wants to modify the dispatch table - * while installed, it must do so itself. It would be possible for - * the vertexformat to install its own initial values for these - * functions, but this way there is an obvious list of what is - * expected of the driver. - * - * If the driver wants to hook in entry points other than those - * listed, it must restore them to their original values in - * the disable() callback, below. - */ -typedef struct { - /** - * \name Vertex - */ - /*@{*/ - void (GLAPIENTRYP ArrayElement)( GLint ); - void (GLAPIENTRYP Color3f)( GLfloat, GLfloat, GLfloat ); - void (GLAPIENTRYP Color3fv)( const GLfloat * ); - void (GLAPIENTRYP Color4f)( GLfloat, GLfloat, GLfloat, GLfloat ); - void (GLAPIENTRYP Color4fv)( const GLfloat * ); - void (GLAPIENTRYP EdgeFlag)( GLboolean ); - void (GLAPIENTRYP EvalCoord1f)( GLfloat ); - void (GLAPIENTRYP EvalCoord1fv)( const GLfloat * ); - void (GLAPIENTRYP EvalCoord2f)( GLfloat, GLfloat ); - void (GLAPIENTRYP EvalCoord2fv)( const GLfloat * ); - void (GLAPIENTRYP EvalPoint1)( GLint ); - void (GLAPIENTRYP EvalPoint2)( GLint, GLint ); - void (GLAPIENTRYP FogCoordfEXT)( GLfloat ); - void (GLAPIENTRYP FogCoordfvEXT)( const GLfloat * ); - void (GLAPIENTRYP Indexf)( GLfloat ); - void (GLAPIENTRYP Indexfv)( const GLfloat * ); - void (GLAPIENTRYP Materialfv)( GLenum face, GLenum pname, const GLfloat * ); - void (GLAPIENTRYP MultiTexCoord1fARB)( GLenum, GLfloat ); - void (GLAPIENTRYP MultiTexCoord1fvARB)( GLenum, const GLfloat * ); - void (GLAPIENTRYP MultiTexCoord2fARB)( GLenum, GLfloat, GLfloat ); - void (GLAPIENTRYP MultiTexCoord2fvARB)( GLenum, const GLfloat * ); - void (GLAPIENTRYP MultiTexCoord3fARB)( GLenum, GLfloat, GLfloat, GLfloat ); - void (GLAPIENTRYP MultiTexCoord3fvARB)( GLenum, const GLfloat * ); - void (GLAPIENTRYP MultiTexCoord4fARB)( GLenum, GLfloat, GLfloat, GLfloat, GLfloat ); - void (GLAPIENTRYP MultiTexCoord4fvARB)( GLenum, const GLfloat * ); - void (GLAPIENTRYP Normal3f)( GLfloat, GLfloat, GLfloat ); - void (GLAPIENTRYP Normal3fv)( const GLfloat * ); - void (GLAPIENTRYP SecondaryColor3fEXT)( GLfloat, GLfloat, GLfloat ); - void (GLAPIENTRYP SecondaryColor3fvEXT)( const GLfloat * ); - void (GLAPIENTRYP TexCoord1f)( GLfloat ); - void (GLAPIENTRYP TexCoord1fv)( const GLfloat * ); - void (GLAPIENTRYP TexCoord2f)( GLfloat, GLfloat ); - void (GLAPIENTRYP TexCoord2fv)( const GLfloat * ); - void (GLAPIENTRYP TexCoord3f)( GLfloat, GLfloat, GLfloat ); - void (GLAPIENTRYP TexCoord3fv)( const GLfloat * ); - void (GLAPIENTRYP TexCoord4f)( GLfloat, GLfloat, GLfloat, GLfloat ); - void (GLAPIENTRYP TexCoord4fv)( const GLfloat * ); - void (GLAPIENTRYP Vertex2f)( GLfloat, GLfloat ); - void (GLAPIENTRYP Vertex2fv)( const GLfloat * ); - void (GLAPIENTRYP Vertex3f)( GLfloat, GLfloat, GLfloat ); - void (GLAPIENTRYP Vertex3fv)( const GLfloat * ); - void (GLAPIENTRYP Vertex4f)( GLfloat, GLfloat, GLfloat, GLfloat ); - void (GLAPIENTRYP Vertex4fv)( const GLfloat * ); - void (GLAPIENTRYP CallList)( GLuint ); - void (GLAPIENTRYP CallLists)( GLsizei, GLenum, const GLvoid * ); - void (GLAPIENTRYP Begin)( GLenum ); - void (GLAPIENTRYP End)( void ); - void (GLAPIENTRYP PrimitiveRestartNV)( void ); - /* GL_NV_vertex_program */ - void (GLAPIENTRYP VertexAttrib1fNV)( GLuint index, GLfloat x ); - void (GLAPIENTRYP VertexAttrib1fvNV)( GLuint index, const GLfloat *v ); - void (GLAPIENTRYP VertexAttrib2fNV)( GLuint index, GLfloat x, GLfloat y ); - void (GLAPIENTRYP VertexAttrib2fvNV)( GLuint index, const GLfloat *v ); - void (GLAPIENTRYP VertexAttrib3fNV)( GLuint index, GLfloat x, GLfloat y, GLfloat z ); - void (GLAPIENTRYP VertexAttrib3fvNV)( GLuint index, const GLfloat *v ); - void (GLAPIENTRYP VertexAttrib4fNV)( GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w ); - void (GLAPIENTRYP VertexAttrib4fvNV)( GLuint index, const GLfloat *v ); - /* GL_ARB_vertex_program */ - void (GLAPIENTRYP VertexAttrib1fARB)( GLuint index, GLfloat x ); - void (GLAPIENTRYP VertexAttrib1fvARB)( GLuint index, const GLfloat *v ); - void (GLAPIENTRYP VertexAttrib2fARB)( GLuint index, GLfloat x, GLfloat y ); - void (GLAPIENTRYP VertexAttrib2fvARB)( GLuint index, const GLfloat *v ); - void (GLAPIENTRYP VertexAttrib3fARB)( GLuint index, GLfloat x, GLfloat y, GLfloat z ); - void (GLAPIENTRYP VertexAttrib3fvARB)( GLuint index, const GLfloat *v ); - void (GLAPIENTRYP VertexAttrib4fARB)( GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w ); - void (GLAPIENTRYP VertexAttrib4fvARB)( GLuint index, const GLfloat *v ); - - /* GL_EXT_gpu_shader4 / GL 3.0 */ - void (GLAPIENTRYP VertexAttribI1i)( GLuint index, GLint x); - void (GLAPIENTRYP VertexAttribI2i)( GLuint index, GLint x, GLint y); - void (GLAPIENTRYP VertexAttribI3i)( GLuint index, GLint x, GLint y, GLint z); - void (GLAPIENTRYP VertexAttribI4i)( GLuint index, GLint x, GLint y, GLint z, GLint w); - void (GLAPIENTRYP VertexAttribI2iv)( GLuint index, const GLint *v); - void (GLAPIENTRYP VertexAttribI3iv)( GLuint index, const GLint *v); - void (GLAPIENTRYP VertexAttribI4iv)( GLuint index, const GLint *v); - - void (GLAPIENTRYP VertexAttribI1ui)( GLuint index, GLuint x); - void (GLAPIENTRYP VertexAttribI2ui)( GLuint index, GLuint x, GLuint y); - void (GLAPIENTRYP VertexAttribI3ui)( GLuint index, GLuint x, GLuint y, GLuint z); - void (GLAPIENTRYP VertexAttribI4ui)( GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); - void (GLAPIENTRYP VertexAttribI2uiv)( GLuint index, const GLuint *v); - void (GLAPIENTRYP VertexAttribI3uiv)( GLuint index, const GLuint *v); - void (GLAPIENTRYP VertexAttribI4uiv)( GLuint index, const GLuint *v); - - /* GL_ARB_vertex_type_10_10_10_2_rev / GL3.3 */ - void (GLAPIENTRYP VertexP2ui)( GLenum type, GLuint value ); - void (GLAPIENTRYP VertexP2uiv)( GLenum type, const GLuint *value); - - void (GLAPIENTRYP VertexP3ui)( GLenum type, GLuint value ); - void (GLAPIENTRYP VertexP3uiv)( GLenum type, const GLuint *value); - - void (GLAPIENTRYP VertexP4ui)( GLenum type, GLuint value ); - void (GLAPIENTRYP VertexP4uiv)( GLenum type, const GLuint *value); - - void (GLAPIENTRYP TexCoordP1ui)( GLenum type, GLuint coords ); - void (GLAPIENTRYP TexCoordP1uiv)( GLenum type, const GLuint *coords ); - - void (GLAPIENTRYP TexCoordP2ui)( GLenum type, GLuint coords ); - void (GLAPIENTRYP TexCoordP2uiv)( GLenum type, const GLuint *coords ); - - void (GLAPIENTRYP TexCoordP3ui)( GLenum type, GLuint coords ); - void (GLAPIENTRYP TexCoordP3uiv)( GLenum type, const GLuint *coords ); - - void (GLAPIENTRYP TexCoordP4ui)( GLenum type, GLuint coords ); - void (GLAPIENTRYP TexCoordP4uiv)( GLenum type, const GLuint *coords ); - - void (GLAPIENTRYP MultiTexCoordP1ui)( GLenum texture, GLenum type, GLuint coords ); - void (GLAPIENTRYP MultiTexCoordP1uiv)( GLenum texture, GLenum type, const GLuint *coords ); - void (GLAPIENTRYP MultiTexCoordP2ui)( GLenum texture, GLenum type, GLuint coords ); - void (GLAPIENTRYP MultiTexCoordP2uiv)( GLenum texture, GLenum type, const GLuint *coords ); - void (GLAPIENTRYP MultiTexCoordP3ui)( GLenum texture, GLenum type, GLuint coords ); - void (GLAPIENTRYP MultiTexCoordP3uiv)( GLenum texture, GLenum type, const GLuint *coords ); - void (GLAPIENTRYP MultiTexCoordP4ui)( GLenum texture, GLenum type, GLuint coords ); - void (GLAPIENTRYP MultiTexCoordP4uiv)( GLenum texture, GLenum type, const GLuint *coords ); - - void (GLAPIENTRYP NormalP3ui)( GLenum type, GLuint coords ); - void (GLAPIENTRYP NormalP3uiv)( GLenum type, const GLuint *coords ); - - void (GLAPIENTRYP ColorP3ui)( GLenum type, GLuint color ); - void (GLAPIENTRYP ColorP3uiv)( GLenum type, const GLuint *color ); - - void (GLAPIENTRYP ColorP4ui)( GLenum type, GLuint color ); - void (GLAPIENTRYP ColorP4uiv)( GLenum type, const GLuint *color ); - - void (GLAPIENTRYP SecondaryColorP3ui)( GLenum type, GLuint color ); - void (GLAPIENTRYP SecondaryColorP3uiv)( GLenum type, const GLuint *color ); - - void (GLAPIENTRYP VertexAttribP1ui)( GLuint index, GLenum type, - GLboolean normalized, GLuint value); - void (GLAPIENTRYP VertexAttribP2ui)( GLuint index, GLenum type, - GLboolean normalized, GLuint value); - void (GLAPIENTRYP VertexAttribP3ui)( GLuint index, GLenum type, - GLboolean normalized, GLuint value); - void (GLAPIENTRYP VertexAttribP4ui)( GLuint index, GLenum type, - GLboolean normalized, GLuint value); - void (GLAPIENTRYP VertexAttribP1uiv)( GLuint index, GLenum type, - GLboolean normalized, - const GLuint *value); - void (GLAPIENTRYP VertexAttribP2uiv)( GLuint index, GLenum type, - GLboolean normalized, - const GLuint *value); - void (GLAPIENTRYP VertexAttribP3uiv)( GLuint index, GLenum type, - GLboolean normalized, - const GLuint *value); - void (GLAPIENTRYP VertexAttribP4uiv)( GLuint index, GLenum type, - GLboolean normalized, - const GLuint *value); - - /*@}*/ - - void (GLAPIENTRYP Rectf)( GLfloat, GLfloat, GLfloat, GLfloat ); - - /** - * \name Array - */ - /*@{*/ - void (GLAPIENTRYP DrawArrays)( GLenum mode, GLint start, GLsizei count ); - void (GLAPIENTRYP DrawElements)( GLenum mode, GLsizei count, GLenum type, - const GLvoid *indices ); - void (GLAPIENTRYP DrawRangeElements)( GLenum mode, GLuint start, - GLuint end, GLsizei count, - GLenum type, const GLvoid *indices ); - void (GLAPIENTRYP MultiDrawElementsEXT)( GLenum mode, const GLsizei *count, - GLenum type, - const GLvoid **indices, - GLsizei primcount); - void (GLAPIENTRYP DrawElementsBaseVertex)( GLenum mode, GLsizei count, - GLenum type, - const GLvoid *indices, - GLint basevertex ); - void (GLAPIENTRYP DrawRangeElementsBaseVertex)( GLenum mode, GLuint start, - GLuint end, GLsizei count, - GLenum type, - const GLvoid *indices, - GLint basevertex); - void (GLAPIENTRYP MultiDrawElementsBaseVertex)( GLenum mode, - const GLsizei *count, - GLenum type, - const GLvoid **indices, - GLsizei primcount, - const GLint *basevertex); - void (GLAPIENTRYP DrawArraysInstanced)(GLenum mode, GLint first, - GLsizei count, GLsizei primcount); - void (GLAPIENTRYP DrawElementsInstanced)(GLenum mode, GLsizei count, - GLenum type, const GLvoid *indices, - GLsizei primcount); - void (GLAPIENTRYP DrawElementsInstancedBaseVertex)(GLenum mode, GLsizei count, - GLenum type, const GLvoid *indices, - GLsizei primcount, GLint basevertex); - /*@}*/ - - /** - * \name Eval - * - * If you don't support eval, fallback to the default vertex format - * on receiving an eval call and use the pipeline mechanism to - * provide partial T&L acceleration. - * - * Mesa will provide a set of helper functions to do eval within - * accelerated vertex formats, eventually... - */ - /*@{*/ - void (GLAPIENTRYP EvalMesh1)( GLenum mode, GLint i1, GLint i2 ); - void (GLAPIENTRYP EvalMesh2)( GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 ); - /*@}*/ - -} GLvertexformat; - - -#endif /* DD_INCLUDED */ +/** + * \file dd.h + * Device driver interfaces. + */ + +/* + * Mesa 3-D graphics library + * Version: 6.5.2 + * + * 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. + */ + + +#ifndef DD_INCLUDED +#define DD_INCLUDED + +/* THIS FILE ONLY INCLUDED BY mtypes.h !!!!! */ + +#include "glheader.h" + +struct gl_buffer_object; +struct gl_context; +struct gl_display_list; +struct gl_framebuffer; +struct gl_pixelstore_attrib; +struct gl_program; +struct gl_renderbuffer; +struct gl_renderbuffer_attachment; +struct gl_shader; +struct gl_shader_program; +struct gl_texture_image; +struct gl_texture_object; + +/* GL_ARB_vertex_buffer_object */ +/* Modifies GL_MAP_UNSYNCHRONIZED_BIT to allow driver to fail (return + * NULL) if buffer is unavailable for immediate mapping. + * + * Does GL_MAP_INVALIDATE_RANGE_BIT do this? It seems so, but it + * would require more book-keeping in the driver than seems necessary + * at this point. + * + * Does GL_MAP_INVALDIATE_BUFFER_BIT do this? Not really -- we don't + * want to provoke the driver to throw away the old storage, we will + * respect the contents of already referenced data. + */ +#define MESA_MAP_NOWAIT_BIT 0x0040 + + +/** + * Device driver function table. + * Core Mesa uses these function pointers to call into device drivers. + * Most of these functions directly correspond to OpenGL state commands. + * Core Mesa will call these functions after error checking has been done + * so that the drivers don't have to worry about error testing. + * + * Vertex transformation/clipping/lighting is patched into the T&L module. + * Rasterization functions are patched into the swrast module. + * + * Note: when new functions are added here, the drivers/common/driverfuncs.c + * file should be updated too!!! + */ +struct dd_function_table { + /** + * Return a string as needed by glGetString(). + * Only the GL_RENDERER query must be implemented. Otherwise, NULL can be + * returned. + */ + const GLubyte * (*GetString)( struct gl_context *ctx, GLenum name ); + + /** + * Notify the driver after Mesa has made some internal state changes. + * + * This is in addition to any state change callbacks Mesa may already have + * made. + */ + void (*UpdateState)( struct gl_context *ctx, GLbitfield new_state ); + + /** + * Get the width and height of the named buffer/window. + * + * Mesa uses this to determine when the driver's window size has changed. + * XXX OBSOLETE: this function will be removed in the future. + */ + void (*GetBufferSize)( struct gl_framebuffer *buffer, + GLuint *width, GLuint *height ); + + /** + * Resize the given framebuffer to the given size. + * XXX OBSOLETE: this function will be removed in the future. + */ + void (*ResizeBuffers)( struct gl_context *ctx, struct gl_framebuffer *fb, + GLuint width, GLuint height); + + /** + * Called whenever an error is generated. + * __struct gl_contextRec::ErrorValue contains the error value. + */ + void (*Error)( struct gl_context *ctx ); + + /** + * This is called whenever glFinish() is called. + */ + void (*Finish)( struct gl_context *ctx ); + + /** + * This is called whenever glFlush() is called. + */ + void (*Flush)( struct gl_context *ctx ); + + /** + * Clear the color/depth/stencil/accum buffer(s). + * \param buffers a bitmask of BUFFER_BIT_* flags indicating which + * renderbuffers need to be cleared. + */ + void (*Clear)( struct gl_context *ctx, GLbitfield buffers ); + + /** + * Execute glAccum command. + */ + void (*Accum)( struct gl_context *ctx, GLenum op, GLfloat value ); + + + /** + * Execute glRasterPos, updating the ctx->Current.Raster fields + */ + void (*RasterPos)( struct gl_context *ctx, const GLfloat v[4] ); + + /** + * \name Image-related functions + */ + /*@{*/ + + /** + * Called by glDrawPixels(). + * \p unpack describes how to unpack the source image data. + */ + void (*DrawPixels)( struct gl_context *ctx, + GLint x, GLint y, GLsizei width, GLsizei height, + GLenum format, GLenum type, + const struct gl_pixelstore_attrib *unpack, + const GLvoid *pixels ); + + /** + * Called by glReadPixels(). + */ + void (*ReadPixels)( struct gl_context *ctx, + GLint x, GLint y, GLsizei width, GLsizei height, + GLenum format, GLenum type, + const struct gl_pixelstore_attrib *unpack, + GLvoid *dest ); + + /** + * Called by glCopyPixels(). + */ + void (*CopyPixels)( struct gl_context *ctx, GLint srcx, GLint srcy, + GLsizei width, GLsizei height, + GLint dstx, GLint dsty, GLenum type ); + + /** + * Called by glBitmap(). + */ + void (*Bitmap)( struct gl_context *ctx, + GLint x, GLint y, GLsizei width, GLsizei height, + const struct gl_pixelstore_attrib *unpack, + const GLubyte *bitmap ); + /*@}*/ + + + /** + * \name Texture image functions + */ + /*@{*/ + + /** + * Choose actual hardware texture format given the user-provided source + * image format and type and the desired internal format. In some + * cases, srcFormat and srcType can be GL_NONE. + * Called by glTexImage(), etc. + */ + gl_format (*ChooseTextureFormat)( struct gl_context *ctx, GLint internalFormat, + GLenum srcFormat, GLenum srcType ); + + /** + * Called by glTexImage1D(). Simply copy the source texture data into the + * destination texture memory. The gl_texture_image fields, etc. will be + * fully initialized. + * The parameters are the same as glTexImage1D(), plus: + * \param packing describes how to unpack the source data. + * \param texObj is the target texture object. + * \param texImage is the target texture image. + */ + void (*TexImage1D)( struct gl_context *ctx, GLenum target, GLint level, + GLint internalFormat, + GLint width, GLint border, + GLenum format, GLenum type, const GLvoid *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage ); + + /** + * Called by glTexImage2D(). + * + * \sa dd_function_table::TexImage1D. + */ + void (*TexImage2D)( struct gl_context *ctx, GLenum target, GLint level, + GLint internalFormat, + GLint width, GLint height, GLint border, + GLenum format, GLenum type, const GLvoid *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage ); + + /** + * Called by glTexImage3D(). + * + * \sa dd_function_table::TexImage1D. + */ + void (*TexImage3D)( struct gl_context *ctx, GLenum target, GLint level, + GLint internalFormat, + GLint width, GLint height, GLint depth, GLint border, + GLenum format, GLenum type, const GLvoid *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage ); + + /** + * Called by glTexSubImage1D(). Replace a subset of the target texture + * with new texel data. + * \sa dd_function_table::TexImage1D. + */ + void (*TexSubImage1D)( struct gl_context *ctx, GLenum target, GLint level, + GLint xoffset, GLsizei width, + GLenum format, GLenum type, + const GLvoid *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage ); + + /** + * Called by glTexSubImage2D(). + * + * \sa dd_function_table::TexSubImage1D. + */ + void (*TexSubImage2D)( struct gl_context *ctx, GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLsizei width, GLsizei height, + GLenum format, GLenum type, + const GLvoid *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage ); + + /** + * Called by glTexSubImage3D(). + * + * \sa dd_function_table::TexSubImage1D. + */ + void (*TexSubImage3D)( struct gl_context *ctx, GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLsizei width, GLsizei height, GLint depth, + GLenum format, GLenum type, + const GLvoid *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage ); + + /** + * Called by glGetTexImage(). + */ + void (*GetTexImage)( struct gl_context *ctx, GLenum target, GLint level, + GLenum format, GLenum type, GLvoid *pixels, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage ); + + /** + * Called by glCopyTexSubImage1D(). + * + * Drivers should use a fallback routine from texstore.c if needed. + */ + void (*CopyTexSubImage1D)( struct gl_context *ctx, GLenum target, GLint level, + GLint xoffset, + GLint x, GLint y, GLsizei width ); + /** + * Called by glCopyTexSubImage2D(). + * + * Drivers should use a fallback routine from texstore.c if needed. + */ + void (*CopyTexSubImage2D)( struct gl_context *ctx, GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLint x, GLint y, + GLsizei width, GLsizei height ); + /** + * Called by glCopyTexSubImage3D(). + * + * Drivers should use a fallback routine from texstore.c if needed. + */ + void (*CopyTexSubImage3D)( struct gl_context *ctx, GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLint x, GLint y, + GLsizei width, GLsizei height ); + + /** + * Called by glGenerateMipmap() or when GL_GENERATE_MIPMAP_SGIS is enabled. + */ + void (*GenerateMipmap)(struct gl_context *ctx, GLenum target, + struct gl_texture_object *texObj); + + /** + * Called by glTexImage[123]D when user specifies a proxy texture + * target. + * + * \return GL_TRUE if the proxy test passes, or GL_FALSE if the test fails. + */ + GLboolean (*TestProxyTexImage)(struct gl_context *ctx, GLenum target, + GLint level, GLint internalFormat, + GLenum format, GLenum type, + GLint width, GLint height, + GLint depth, GLint border); + /*@}*/ + + + /** + * \name Compressed texture functions + */ + /*@{*/ + + /** + * Called by glCompressedTexImage1D(). + * + * \param target user specified. + * \param format user specified. + * \param type user specified. + * \param pixels user specified. + * \param packing indicates the image packing of pixels. + * \param texObj is the target texture object. + * \param texImage is the target texture image. It will have the texture \p + * width, \p height, \p depth, \p border and \p internalFormat information. + * + * \a retainInternalCopy is returned by this function and indicates whether + * core Mesa should keep an internal copy of the texture image. + */ + void (*CompressedTexImage1D)( struct gl_context *ctx, GLenum target, + GLint level, GLint internalFormat, + GLsizei width, GLint border, + GLsizei imageSize, const GLvoid *data, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage ); + /** + * Called by glCompressedTexImage2D(). + * + * \sa dd_function_table::CompressedTexImage1D. + */ + void (*CompressedTexImage2D)( struct gl_context *ctx, GLenum target, + GLint level, GLint internalFormat, + GLsizei width, GLsizei height, GLint border, + GLsizei imageSize, const GLvoid *data, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage ); + /** + * Called by glCompressedTexImage3D(). + * + * \sa dd_function_table::CompressedTexImage3D. + */ + void (*CompressedTexImage3D)( struct gl_context *ctx, GLenum target, + GLint level, GLint internalFormat, + GLsizei width, GLsizei height, GLsizei depth, + GLint border, + GLsizei imageSize, const GLvoid *data, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage ); + + /** + * Called by glCompressedTexSubImage1D(). + * + * \param target user specified. + * \param level user specified. + * \param xoffset user specified. + * \param yoffset user specified. + * \param zoffset user specified. + * \param width user specified. + * \param height user specified. + * \param depth user specified. + * \param imageSize user specified. + * \param data user specified. + * \param texObj is the target texture object. + * \param texImage is the target texture image. It will have the texture \p + * width, \p height, \p depth, \p border and \p internalFormat information. + */ + void (*CompressedTexSubImage1D)(struct gl_context *ctx, GLenum target, GLint level, + GLint xoffset, GLsizei width, + GLenum format, + GLsizei imageSize, const GLvoid *data, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage); + /** + * Called by glCompressedTexSubImage2D(). + * + * \sa dd_function_table::CompressedTexImage3D. + */ + void (*CompressedTexSubImage2D)(struct gl_context *ctx, GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLsizei width, GLint height, + GLenum format, + GLsizei imageSize, const GLvoid *data, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage); + /** + * Called by glCompressedTexSubImage3D(). + * + * \sa dd_function_table::CompressedTexImage3D. + */ + void (*CompressedTexSubImage3D)(struct gl_context *ctx, GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLsizei width, GLint height, GLint depth, + GLenum format, + GLsizei imageSize, const GLvoid *data, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage); + + + /** + * Called by glGetCompressedTexImage. + */ + void (*GetCompressedTexImage)(struct gl_context *ctx, GLenum target, GLint level, + GLvoid *img, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage); + + /*@}*/ + + /** + * \name Texture object functions + */ + /*@{*/ + + /** + * Called by glBindTexture(). + */ + void (*BindTexture)( struct gl_context *ctx, GLenum target, + struct gl_texture_object *tObj ); + + /** + * Called to allocate a new texture object. + * A new gl_texture_object should be returned. The driver should + * attach to it any device-specific info it needs. + */ + struct gl_texture_object * (*NewTextureObject)( struct gl_context *ctx, GLuint name, + GLenum target ); + /** + * Called when a texture object is about to be deallocated. + * + * Driver should delete the gl_texture_object object and anything + * hanging off of it. + */ + void (*DeleteTexture)( struct gl_context *ctx, struct gl_texture_object *tObj ); + + /** + * Called to allocate a new texture image object. + */ + struct gl_texture_image * (*NewTextureImage)( struct gl_context *ctx ); + + /** + * Called to free tImage->Data. + */ + void (*FreeTextureImageBuffer)( struct gl_context *ctx, struct gl_texture_image *tImage ); + + /** Map a slice of a texture image into user space. + * \param texImage the texture image + * \param slice the 3D image slice or array texture slice + * \param x, y, w, h region of interest + * \param mode bitmask of GL_MAP_READ_BIT, GL_MAP_WRITE_BIT + * \param mapOut returns start of mapping of region of interest + * \param rowStrideOut returns row stride (in bytes) + */ + void (*MapTextureImage)(struct gl_context *ctx, + struct gl_texture_image *texImage, + GLuint slice, + GLuint x, GLuint y, GLuint w, GLuint h, + GLbitfield mode, + GLubyte **mapOut, GLint *rowStrideOut); + + void (*UnmapTextureImage)(struct gl_context *ctx, + struct gl_texture_image *texImage, + GLuint slice); + + /** Map texture image data into user space */ + void (*MapTexture)( struct gl_context *ctx, struct gl_texture_object *tObj ); + /** Unmap texture images from user space */ + void (*UnmapTexture)( struct gl_context *ctx, struct gl_texture_object *tObj ); + + /** + * Note: no context argument. This function doesn't initially look + * like it belongs here, except that the driver is the only entity + * that knows for sure how the texture memory is allocated - via + * the above callbacks. There is then an argument that the driver + * knows what memcpy paths might be fast. Typically this is invoked with + * + * to -- a pointer into texture memory allocated by NewTextureImage() above. + * from -- a pointer into client memory or a mesa temporary. + * sz -- nr bytes to copy. + */ + void* (*TextureMemCpy)( void *to, const void *from, size_t sz ); + + /** + * Called by glAreTextureResident(). + */ + GLboolean (*IsTextureResident)( struct gl_context *ctx, + struct gl_texture_object *t ); + /*@}*/ + + + /** + * \name Vertex/fragment program functions + */ + /*@{*/ + /** Bind a vertex/fragment program */ + void (*BindProgram)(struct gl_context *ctx, GLenum target, struct gl_program *prog); + /** Allocate a new program */ + struct gl_program * (*NewProgram)(struct gl_context *ctx, GLenum target, GLuint id); + /** Delete a program */ + void (*DeleteProgram)(struct gl_context *ctx, struct gl_program *prog); + /** + * Notify driver that a program string (and GPU code) has been specified + * or modified. Return GL_TRUE or GL_FALSE to indicate if the program is + * supported by the driver. + */ + GLboolean (*ProgramStringNotify)(struct gl_context *ctx, GLenum target, + struct gl_program *prog); + + /** Query if program can be loaded onto hardware */ + GLboolean (*IsProgramNative)(struct gl_context *ctx, GLenum target, + struct gl_program *prog); + + /*@}*/ + + /** + * \name GLSL shader/program functions. + */ + /*@{*/ + /** + * Called when a shader program is linked. + * + * This gives drivers an opportunity to clone the IR and make their + * own transformations on it for the purposes of code generation. + */ + GLboolean (*LinkShader)(struct gl_context *ctx, struct gl_shader_program *shader); + /*@}*/ + + /** + * \name State-changing functions. + * + * \note drawing functions are above. + * + * These functions are called by their corresponding OpenGL API functions. + * They are \e also called by the gl_PopAttrib() function!!! + * May add more functions like these to the device driver in the future. + */ + /*@{*/ + /** Specify the alpha test function */ + void (*AlphaFunc)(struct gl_context *ctx, GLenum func, GLfloat ref); + /** Set the blend color */ + void (*BlendColor)(struct gl_context *ctx, const GLfloat color[4]); + /** Set the blend equation */ + void (*BlendEquationSeparate)(struct gl_context *ctx, GLenum modeRGB, GLenum modeA); + void (*BlendEquationSeparatei)(struct gl_context *ctx, GLuint buffer, + GLenum modeRGB, GLenum modeA); + /** Specify pixel arithmetic */ + void (*BlendFuncSeparate)(struct gl_context *ctx, + GLenum sfactorRGB, GLenum dfactorRGB, + GLenum sfactorA, GLenum dfactorA); + void (*BlendFuncSeparatei)(struct gl_context *ctx, GLuint buffer, + GLenum sfactorRGB, GLenum dfactorRGB, + GLenum sfactorA, GLenum dfactorA); + /** Specify clear values for the color buffers */ + void (*ClearColor)(struct gl_context *ctx, const GLfloat color[4]); + /** Specify the clear value for the depth buffer */ + void (*ClearDepth)(struct gl_context *ctx, GLclampd d); + /** Specify the clear value for the stencil buffer */ + void (*ClearStencil)(struct gl_context *ctx, GLint s); + /** Specify a plane against which all geometry is clipped */ + void (*ClipPlane)(struct gl_context *ctx, GLenum plane, const GLfloat *equation ); + /** Enable and disable writing of frame buffer color components */ + void (*ColorMask)(struct gl_context *ctx, GLboolean rmask, GLboolean gmask, + GLboolean bmask, GLboolean amask ); + void (*ColorMaskIndexed)(struct gl_context *ctx, GLuint buf, GLboolean rmask, + GLboolean gmask, GLboolean bmask, GLboolean amask); + /** Cause a material color to track the current color */ + void (*ColorMaterial)(struct gl_context *ctx, GLenum face, GLenum mode); + /** Specify whether front- or back-facing facets can be culled */ + void (*CullFace)(struct gl_context *ctx, GLenum mode); + /** Define front- and back-facing polygons */ + void (*FrontFace)(struct gl_context *ctx, GLenum mode); + /** Specify the value used for depth buffer comparisons */ + void (*DepthFunc)(struct gl_context *ctx, GLenum func); + /** Enable or disable writing into the depth buffer */ + void (*DepthMask)(struct gl_context *ctx, GLboolean flag); + /** Specify mapping of depth values from NDC to window coordinates */ + void (*DepthRange)(struct gl_context *ctx, GLclampd nearval, GLclampd farval); + /** Specify the current buffer for writing */ + void (*DrawBuffer)( struct gl_context *ctx, GLenum buffer ); + /** Specify the buffers for writing for fragment programs*/ + void (*DrawBuffers)( struct gl_context *ctx, GLsizei n, const GLenum *buffers ); + /** Enable or disable server-side gl capabilities */ + void (*Enable)(struct gl_context *ctx, GLenum cap, GLboolean state); + /** Specify fog parameters */ + void (*Fogfv)(struct gl_context *ctx, GLenum pname, const GLfloat *params); + /** Specify implementation-specific hints */ + void (*Hint)(struct gl_context *ctx, GLenum target, GLenum mode); + /** Set light source parameters. + * Note: for GL_POSITION and GL_SPOT_DIRECTION, params will have already + * been transformed to eye-space. + */ + void (*Lightfv)(struct gl_context *ctx, GLenum light, + GLenum pname, const GLfloat *params ); + /** Set the lighting model parameters */ + void (*LightModelfv)(struct gl_context *ctx, GLenum pname, const GLfloat *params); + /** Specify the line stipple pattern */ + void (*LineStipple)(struct gl_context *ctx, GLint factor, GLushort pattern ); + /** Specify the width of rasterized lines */ + void (*LineWidth)(struct gl_context *ctx, GLfloat width); + /** Specify a logical pixel operation for color index rendering */ + void (*LogicOpcode)(struct gl_context *ctx, GLenum opcode); + void (*PointParameterfv)(struct gl_context *ctx, GLenum pname, + const GLfloat *params); + /** Specify the diameter of rasterized points */ + void (*PointSize)(struct gl_context *ctx, GLfloat size); + /** Select a polygon rasterization mode */ + void (*PolygonMode)(struct gl_context *ctx, GLenum face, GLenum mode); + /** Set the scale and units used to calculate depth values */ + void (*PolygonOffset)(struct gl_context *ctx, GLfloat factor, GLfloat units); + /** Set the polygon stippling pattern */ + void (*PolygonStipple)(struct gl_context *ctx, const GLubyte *mask ); + /* Specifies the current buffer for reading */ + void (*ReadBuffer)( struct gl_context *ctx, GLenum buffer ); + /** Set rasterization mode */ + void (*RenderMode)(struct gl_context *ctx, GLenum mode ); + /** Define the scissor box */ + void (*Scissor)(struct gl_context *ctx, GLint x, GLint y, GLsizei w, GLsizei h); + /** Select flat or smooth shading */ + void (*ShadeModel)(struct gl_context *ctx, GLenum mode); + /** OpenGL 2.0 two-sided StencilFunc */ + void (*StencilFuncSeparate)(struct gl_context *ctx, GLenum face, GLenum func, + GLint ref, GLuint mask); + /** OpenGL 2.0 two-sided StencilMask */ + void (*StencilMaskSeparate)(struct gl_context *ctx, GLenum face, GLuint mask); + /** OpenGL 2.0 two-sided StencilOp */ + void (*StencilOpSeparate)(struct gl_context *ctx, GLenum face, GLenum fail, + GLenum zfail, GLenum zpass); + /** Control the generation of texture coordinates */ + void (*TexGen)(struct gl_context *ctx, GLenum coord, GLenum pname, + const GLfloat *params); + /** Set texture environment parameters */ + void (*TexEnv)(struct gl_context *ctx, GLenum target, GLenum pname, + const GLfloat *param); + /** Set texture parameters */ + void (*TexParameter)(struct gl_context *ctx, GLenum target, + struct gl_texture_object *texObj, + GLenum pname, const GLfloat *params); + /** Set the viewport */ + void (*Viewport)(struct gl_context *ctx, GLint x, GLint y, GLsizei w, GLsizei h); + /*@}*/ + + + /** + * \name Vertex/pixel buffer object functions + */ + /*@{*/ + void (*BindBuffer)( struct gl_context *ctx, GLenum target, + struct gl_buffer_object *obj ); + + struct gl_buffer_object * (*NewBufferObject)( struct gl_context *ctx, GLuint buffer, + GLenum target ); + + void (*DeleteBuffer)( struct gl_context *ctx, struct gl_buffer_object *obj ); + + GLboolean (*BufferData)( struct gl_context *ctx, GLenum target, GLsizeiptrARB size, + const GLvoid *data, GLenum usage, + struct gl_buffer_object *obj ); + + void (*BufferSubData)( struct gl_context *ctx, GLintptrARB offset, + GLsizeiptrARB size, const GLvoid *data, + struct gl_buffer_object *obj ); + + void (*GetBufferSubData)( struct gl_context *ctx, + GLintptrARB offset, GLsizeiptrARB size, + GLvoid *data, struct gl_buffer_object *obj ); + + void (*CopyBufferSubData)( struct gl_context *ctx, + struct gl_buffer_object *src, + struct gl_buffer_object *dst, + GLintptr readOffset, GLintptr writeOffset, + GLsizeiptr size ); + + /* May return NULL if MESA_MAP_NOWAIT_BIT is set in access: + */ + void * (*MapBufferRange)( struct gl_context *ctx, GLintptr offset, + GLsizeiptr length, GLbitfield access, + struct gl_buffer_object *obj); + + void (*FlushMappedBufferRange)(struct gl_context *ctx, + GLintptr offset, GLsizeiptr length, + struct gl_buffer_object *obj); + + GLboolean (*UnmapBuffer)( struct gl_context *ctx, + struct gl_buffer_object *obj ); + /*@}*/ + + /** + * \name Functions for GL_APPLE_object_purgeable + */ + /*@{*/ + /* variations on ObjectPurgeable */ + GLenum (*BufferObjectPurgeable)( struct gl_context *ctx, struct gl_buffer_object *obj, GLenum option ); + GLenum (*RenderObjectPurgeable)( struct gl_context *ctx, struct gl_renderbuffer *obj, GLenum option ); + GLenum (*TextureObjectPurgeable)( struct gl_context *ctx, struct gl_texture_object *obj, GLenum option ); + + /* variations on ObjectUnpurgeable */ + GLenum (*BufferObjectUnpurgeable)( struct gl_context *ctx, struct gl_buffer_object *obj, GLenum option ); + GLenum (*RenderObjectUnpurgeable)( struct gl_context *ctx, struct gl_renderbuffer *obj, GLenum option ); + GLenum (*TextureObjectUnpurgeable)( struct gl_context *ctx, struct gl_texture_object *obj, GLenum option ); + /*@}*/ + + /** + * \name Functions for GL_EXT_framebuffer_{object,blit}. + */ + /*@{*/ + struct gl_framebuffer * (*NewFramebuffer)(struct gl_context *ctx, GLuint name); + struct gl_renderbuffer * (*NewRenderbuffer)(struct gl_context *ctx, GLuint name); + void (*BindFramebuffer)(struct gl_context *ctx, GLenum target, + struct gl_framebuffer *drawFb, + struct gl_framebuffer *readFb); + void (*FramebufferRenderbuffer)(struct gl_context *ctx, + struct gl_framebuffer *fb, + GLenum attachment, + struct gl_renderbuffer *rb); + void (*RenderTexture)(struct gl_context *ctx, + struct gl_framebuffer *fb, + struct gl_renderbuffer_attachment *att); + void (*FinishRenderTexture)(struct gl_context *ctx, + struct gl_renderbuffer_attachment *att); + void (*ValidateFramebuffer)(struct gl_context *ctx, + struct gl_framebuffer *fb); + /*@}*/ + void (*BlitFramebuffer)(struct gl_context *ctx, + GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, + GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, + GLbitfield mask, GLenum filter); + + /** + * \name Query objects + */ + /*@{*/ + struct gl_query_object * (*NewQueryObject)(struct gl_context *ctx, GLuint id); + void (*DeleteQuery)(struct gl_context *ctx, struct gl_query_object *q); + void (*BeginQuery)(struct gl_context *ctx, struct gl_query_object *q); + void (*EndQuery)(struct gl_context *ctx, struct gl_query_object *q); + void (*CheckQuery)(struct gl_context *ctx, struct gl_query_object *q); + void (*WaitQuery)(struct gl_context *ctx, struct gl_query_object *q); + /*@}*/ + + + /** + * \name Vertex Array objects + */ + /*@{*/ + struct gl_array_object * (*NewArrayObject)(struct gl_context *ctx, GLuint id); + void (*DeleteArrayObject)(struct gl_context *ctx, struct gl_array_object *obj); + void (*BindArrayObject)(struct gl_context *ctx, struct gl_array_object *obj); + /*@}*/ + + /** + * \name GLSL-related functions (ARB extensions and OpenGL 2.x) + */ + /*@{*/ + struct gl_shader *(*NewShader)(struct gl_context *ctx, GLuint name, GLenum type); + void (*DeleteShader)(struct gl_context *ctx, struct gl_shader *shader); + struct gl_shader_program *(*NewShaderProgram)(struct gl_context *ctx, GLuint name); + void (*DeleteShaderProgram)(struct gl_context *ctx, + struct gl_shader_program *shProg); + void (*UseProgram)(struct gl_context *ctx, struct gl_shader_program *shProg); + /*@}*/ + + + /** + * \name Support for multiple T&L engines + */ + /*@{*/ + + /** + * Bitmask of state changes that require the current T&L module to be + * validated, using ValidateTnlModule() below. + */ + GLuint NeedValidate; + + /** + * Validate the current T&L module. + * + * This is called directly after UpdateState() when a state change that has + * occurred matches the dd_function_table::NeedValidate bitmask above. This + * ensures all computed values are up to date, thus allowing the driver to + * decide if the current T&L module needs to be swapped out. + * + * This must be non-NULL if a driver installs a custom T&L module and sets + * the dd_function_table::NeedValidate bitmask, but may be NULL otherwise. + */ + void (*ValidateTnlModule)( struct gl_context *ctx, GLuint new_state ); + + /** + * Set by the driver-supplied T&L engine. + * + * Set to PRIM_OUTSIDE_BEGIN_END when outside glBegin()/glEnd(). + */ + GLuint CurrentExecPrimitive; + + /** + * Current state of an in-progress compilation. + * + * May take on any of the additional values PRIM_OUTSIDE_BEGIN_END, + * PRIM_INSIDE_UNKNOWN_PRIM or PRIM_UNKNOWN defined above. + */ + GLuint CurrentSavePrimitive; + + +#define FLUSH_STORED_VERTICES 0x1 +#define FLUSH_UPDATE_CURRENT 0x2 + /** + * Set by the driver-supplied T&L engine whenever vertices are buffered + * between glBegin()/glEnd() objects or __struct gl_contextRec::Current is not + * updated. + * + * The dd_function_table::FlushVertices call below may be used to resolve + * these conditions. + */ + GLuint NeedFlush; + GLuint SaveNeedFlush; + + + /* Called prior to any of the GLvertexformat functions being + * called. Paired with Driver.FlushVertices(). + */ + void (*BeginVertices)( struct gl_context *ctx ); + + /** + * If inside glBegin()/glEnd(), it should ASSERT(0). Otherwise, if + * FLUSH_STORED_VERTICES bit in \p flags is set flushes any buffered + * vertices, if FLUSH_UPDATE_CURRENT bit is set updates + * __struct gl_contextRec::Current and gl_light_attrib::Material + * + * Note that the default T&L engine never clears the + * FLUSH_UPDATE_CURRENT bit, even after performing the update. + */ + void (*FlushVertices)( struct gl_context *ctx, GLuint flags ); + void (*SaveFlushVertices)( struct gl_context *ctx ); + + /** + * Give the driver the opportunity to hook in its own vtxfmt for + * compiling optimized display lists. This is called on each valid + * glBegin() during list compilation. + */ + GLboolean (*NotifySaveBegin)( struct gl_context *ctx, GLenum mode ); + + /** + * Notify driver that the special derived value _NeedEyeCoords has + * changed. + */ + void (*LightingSpaceChange)( struct gl_context *ctx ); + + /** + * Called by glNewList(). + * + * Let the T&L component know what is going on with display lists + * in time to make changes to dispatch tables, etc. + */ + void (*NewList)( struct gl_context *ctx, GLuint list, GLenum mode ); + /** + * Called by glEndList(). + * + * \sa dd_function_table::NewList. + */ + void (*EndList)( struct gl_context *ctx ); + + /** + * Called by glCallList(s). + * + * Notify the T&L component before and after calling a display list. + */ + void (*BeginCallList)( struct gl_context *ctx, + struct gl_display_list *dlist ); + /** + * Called by glEndCallList(). + * + * \sa dd_function_table::BeginCallList. + */ + void (*EndCallList)( struct gl_context *ctx ); + + + /** + * \name GL_ARB_sync interfaces + */ + /*@{*/ + struct gl_sync_object * (*NewSyncObject)(struct gl_context *, GLenum); + void (*FenceSync)(struct gl_context *, struct gl_sync_object *, GLenum, GLbitfield); + void (*DeleteSyncObject)(struct gl_context *, struct gl_sync_object *); + void (*CheckSync)(struct gl_context *, struct gl_sync_object *); + void (*ClientWaitSync)(struct gl_context *, struct gl_sync_object *, + GLbitfield, GLuint64); + void (*ServerWaitSync)(struct gl_context *, struct gl_sync_object *, + GLbitfield, GLuint64); + /*@}*/ + + /** GL_NV_conditional_render */ + void (*BeginConditionalRender)(struct gl_context *ctx, struct gl_query_object *q, + GLenum mode); + void (*EndConditionalRender)(struct gl_context *ctx, struct gl_query_object *q); + + /** + * \name GL_OES_draw_texture interface + */ + /*@{*/ + void (*DrawTex)(struct gl_context *ctx, GLfloat x, GLfloat y, GLfloat z, + GLfloat width, GLfloat height); + /*@}*/ + + /** + * \name GL_OES_EGL_image interface + */ + void (*EGLImageTargetTexture2D)(struct gl_context *ctx, GLenum target, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage, + GLeglImageOES image_handle); + void (*EGLImageTargetRenderbufferStorage)(struct gl_context *ctx, + struct gl_renderbuffer *rb, + void *image_handle); + + /** + * \name GL_EXT_transform_feedback interface + */ + struct gl_transform_feedback_object * + (*NewTransformFeedback)(struct gl_context *ctx, GLuint name); + void (*DeleteTransformFeedback)(struct gl_context *ctx, + struct gl_transform_feedback_object *obj); + void (*BeginTransformFeedback)(struct gl_context *ctx, GLenum mode, + struct gl_transform_feedback_object *obj); + void (*EndTransformFeedback)(struct gl_context *ctx, + struct gl_transform_feedback_object *obj); + void (*PauseTransformFeedback)(struct gl_context *ctx, + struct gl_transform_feedback_object *obj); + void (*ResumeTransformFeedback)(struct gl_context *ctx, + struct gl_transform_feedback_object *obj); + void (*DrawTransformFeedback)(struct gl_context *ctx, GLenum mode, + struct gl_transform_feedback_object *obj); + + /** + * \name GL_NV_texture_barrier interface + */ + void (*TextureBarrier)(struct gl_context *ctx); + + /** + * \name GL_ARB_sampler_objects + */ + struct gl_sampler_object * (*NewSamplerObject)(struct gl_context *ctx, + GLuint name); + void (*DeleteSamplerObject)(struct gl_context *ctx, + struct gl_sampler_object *samp); +}; + + +/** + * Transform/Clip/Lighting interface + * + * Drivers present a reduced set of the functions possible in + * glBegin()/glEnd() objects. Core mesa provides translation stubs for the + * remaining functions to map down to these entry points. + * + * These are the initial values to be installed into dispatch by + * mesa. If the T&L driver wants to modify the dispatch table + * while installed, it must do so itself. It would be possible for + * the vertexformat to install its own initial values for these + * functions, but this way there is an obvious list of what is + * expected of the driver. + * + * If the driver wants to hook in entry points other than those + * listed, it must restore them to their original values in + * the disable() callback, below. + */ +typedef struct { + /** + * \name Vertex + */ + /*@{*/ + void (GLAPIENTRYP ArrayElement)( GLint ); + void (GLAPIENTRYP Color3f)( GLfloat, GLfloat, GLfloat ); + void (GLAPIENTRYP Color3fv)( const GLfloat * ); + void (GLAPIENTRYP Color4f)( GLfloat, GLfloat, GLfloat, GLfloat ); + void (GLAPIENTRYP Color4fv)( const GLfloat * ); + void (GLAPIENTRYP EdgeFlag)( GLboolean ); + void (GLAPIENTRYP EvalCoord1f)( GLfloat ); + void (GLAPIENTRYP EvalCoord1fv)( const GLfloat * ); + void (GLAPIENTRYP EvalCoord2f)( GLfloat, GLfloat ); + void (GLAPIENTRYP EvalCoord2fv)( const GLfloat * ); + void (GLAPIENTRYP EvalPoint1)( GLint ); + void (GLAPIENTRYP EvalPoint2)( GLint, GLint ); + void (GLAPIENTRYP FogCoordfEXT)( GLfloat ); + void (GLAPIENTRYP FogCoordfvEXT)( const GLfloat * ); + void (GLAPIENTRYP Indexf)( GLfloat ); + void (GLAPIENTRYP Indexfv)( const GLfloat * ); + void (GLAPIENTRYP Materialfv)( GLenum face, GLenum pname, const GLfloat * ); + void (GLAPIENTRYP MultiTexCoord1fARB)( GLenum, GLfloat ); + void (GLAPIENTRYP MultiTexCoord1fvARB)( GLenum, const GLfloat * ); + void (GLAPIENTRYP MultiTexCoord2fARB)( GLenum, GLfloat, GLfloat ); + void (GLAPIENTRYP MultiTexCoord2fvARB)( GLenum, const GLfloat * ); + void (GLAPIENTRYP MultiTexCoord3fARB)( GLenum, GLfloat, GLfloat, GLfloat ); + void (GLAPIENTRYP MultiTexCoord3fvARB)( GLenum, const GLfloat * ); + void (GLAPIENTRYP MultiTexCoord4fARB)( GLenum, GLfloat, GLfloat, GLfloat, GLfloat ); + void (GLAPIENTRYP MultiTexCoord4fvARB)( GLenum, const GLfloat * ); + void (GLAPIENTRYP Normal3f)( GLfloat, GLfloat, GLfloat ); + void (GLAPIENTRYP Normal3fv)( const GLfloat * ); + void (GLAPIENTRYP SecondaryColor3fEXT)( GLfloat, GLfloat, GLfloat ); + void (GLAPIENTRYP SecondaryColor3fvEXT)( const GLfloat * ); + void (GLAPIENTRYP TexCoord1f)( GLfloat ); + void (GLAPIENTRYP TexCoord1fv)( const GLfloat * ); + void (GLAPIENTRYP TexCoord2f)( GLfloat, GLfloat ); + void (GLAPIENTRYP TexCoord2fv)( const GLfloat * ); + void (GLAPIENTRYP TexCoord3f)( GLfloat, GLfloat, GLfloat ); + void (GLAPIENTRYP TexCoord3fv)( const GLfloat * ); + void (GLAPIENTRYP TexCoord4f)( GLfloat, GLfloat, GLfloat, GLfloat ); + void (GLAPIENTRYP TexCoord4fv)( const GLfloat * ); + void (GLAPIENTRYP Vertex2f)( GLfloat, GLfloat ); + void (GLAPIENTRYP Vertex2fv)( const GLfloat * ); + void (GLAPIENTRYP Vertex3f)( GLfloat, GLfloat, GLfloat ); + void (GLAPIENTRYP Vertex3fv)( const GLfloat * ); + void (GLAPIENTRYP Vertex4f)( GLfloat, GLfloat, GLfloat, GLfloat ); + void (GLAPIENTRYP Vertex4fv)( const GLfloat * ); + void (GLAPIENTRYP CallList)( GLuint ); + void (GLAPIENTRYP CallLists)( GLsizei, GLenum, const GLvoid * ); + void (GLAPIENTRYP Begin)( GLenum ); + void (GLAPIENTRYP End)( void ); + void (GLAPIENTRYP PrimitiveRestartNV)( void ); + /* GL_NV_vertex_program */ + void (GLAPIENTRYP VertexAttrib1fNV)( GLuint index, GLfloat x ); + void (GLAPIENTRYP VertexAttrib1fvNV)( GLuint index, const GLfloat *v ); + void (GLAPIENTRYP VertexAttrib2fNV)( GLuint index, GLfloat x, GLfloat y ); + void (GLAPIENTRYP VertexAttrib2fvNV)( GLuint index, const GLfloat *v ); + void (GLAPIENTRYP VertexAttrib3fNV)( GLuint index, GLfloat x, GLfloat y, GLfloat z ); + void (GLAPIENTRYP VertexAttrib3fvNV)( GLuint index, const GLfloat *v ); + void (GLAPIENTRYP VertexAttrib4fNV)( GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w ); + void (GLAPIENTRYP VertexAttrib4fvNV)( GLuint index, const GLfloat *v ); + /* GL_ARB_vertex_program */ + void (GLAPIENTRYP VertexAttrib1fARB)( GLuint index, GLfloat x ); + void (GLAPIENTRYP VertexAttrib1fvARB)( GLuint index, const GLfloat *v ); + void (GLAPIENTRYP VertexAttrib2fARB)( GLuint index, GLfloat x, GLfloat y ); + void (GLAPIENTRYP VertexAttrib2fvARB)( GLuint index, const GLfloat *v ); + void (GLAPIENTRYP VertexAttrib3fARB)( GLuint index, GLfloat x, GLfloat y, GLfloat z ); + void (GLAPIENTRYP VertexAttrib3fvARB)( GLuint index, const GLfloat *v ); + void (GLAPIENTRYP VertexAttrib4fARB)( GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w ); + void (GLAPIENTRYP VertexAttrib4fvARB)( GLuint index, const GLfloat *v ); + + /* GL_EXT_gpu_shader4 / GL 3.0 */ + void (GLAPIENTRYP VertexAttribI1i)( GLuint index, GLint x); + void (GLAPIENTRYP VertexAttribI2i)( GLuint index, GLint x, GLint y); + void (GLAPIENTRYP VertexAttribI3i)( GLuint index, GLint x, GLint y, GLint z); + void (GLAPIENTRYP VertexAttribI4i)( GLuint index, GLint x, GLint y, GLint z, GLint w); + void (GLAPIENTRYP VertexAttribI2iv)( GLuint index, const GLint *v); + void (GLAPIENTRYP VertexAttribI3iv)( GLuint index, const GLint *v); + void (GLAPIENTRYP VertexAttribI4iv)( GLuint index, const GLint *v); + + void (GLAPIENTRYP VertexAttribI1ui)( GLuint index, GLuint x); + void (GLAPIENTRYP VertexAttribI2ui)( GLuint index, GLuint x, GLuint y); + void (GLAPIENTRYP VertexAttribI3ui)( GLuint index, GLuint x, GLuint y, GLuint z); + void (GLAPIENTRYP VertexAttribI4ui)( GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); + void (GLAPIENTRYP VertexAttribI2uiv)( GLuint index, const GLuint *v); + void (GLAPIENTRYP VertexAttribI3uiv)( GLuint index, const GLuint *v); + void (GLAPIENTRYP VertexAttribI4uiv)( GLuint index, const GLuint *v); + + /* GL_ARB_vertex_type_10_10_10_2_rev / GL3.3 */ + void (GLAPIENTRYP VertexP2ui)( GLenum type, GLuint value ); + void (GLAPIENTRYP VertexP2uiv)( GLenum type, const GLuint *value); + + void (GLAPIENTRYP VertexP3ui)( GLenum type, GLuint value ); + void (GLAPIENTRYP VertexP3uiv)( GLenum type, const GLuint *value); + + void (GLAPIENTRYP VertexP4ui)( GLenum type, GLuint value ); + void (GLAPIENTRYP VertexP4uiv)( GLenum type, const GLuint *value); + + void (GLAPIENTRYP TexCoordP1ui)( GLenum type, GLuint coords ); + void (GLAPIENTRYP TexCoordP1uiv)( GLenum type, const GLuint *coords ); + + void (GLAPIENTRYP TexCoordP2ui)( GLenum type, GLuint coords ); + void (GLAPIENTRYP TexCoordP2uiv)( GLenum type, const GLuint *coords ); + + void (GLAPIENTRYP TexCoordP3ui)( GLenum type, GLuint coords ); + void (GLAPIENTRYP TexCoordP3uiv)( GLenum type, const GLuint *coords ); + + void (GLAPIENTRYP TexCoordP4ui)( GLenum type, GLuint coords ); + void (GLAPIENTRYP TexCoordP4uiv)( GLenum type, const GLuint *coords ); + + void (GLAPIENTRYP MultiTexCoordP1ui)( GLenum texture, GLenum type, GLuint coords ); + void (GLAPIENTRYP MultiTexCoordP1uiv)( GLenum texture, GLenum type, const GLuint *coords ); + void (GLAPIENTRYP MultiTexCoordP2ui)( GLenum texture, GLenum type, GLuint coords ); + void (GLAPIENTRYP MultiTexCoordP2uiv)( GLenum texture, GLenum type, const GLuint *coords ); + void (GLAPIENTRYP MultiTexCoordP3ui)( GLenum texture, GLenum type, GLuint coords ); + void (GLAPIENTRYP MultiTexCoordP3uiv)( GLenum texture, GLenum type, const GLuint *coords ); + void (GLAPIENTRYP MultiTexCoordP4ui)( GLenum texture, GLenum type, GLuint coords ); + void (GLAPIENTRYP MultiTexCoordP4uiv)( GLenum texture, GLenum type, const GLuint *coords ); + + void (GLAPIENTRYP NormalP3ui)( GLenum type, GLuint coords ); + void (GLAPIENTRYP NormalP3uiv)( GLenum type, const GLuint *coords ); + + void (GLAPIENTRYP ColorP3ui)( GLenum type, GLuint color ); + void (GLAPIENTRYP ColorP3uiv)( GLenum type, const GLuint *color ); + + void (GLAPIENTRYP ColorP4ui)( GLenum type, GLuint color ); + void (GLAPIENTRYP ColorP4uiv)( GLenum type, const GLuint *color ); + + void (GLAPIENTRYP SecondaryColorP3ui)( GLenum type, GLuint color ); + void (GLAPIENTRYP SecondaryColorP3uiv)( GLenum type, const GLuint *color ); + + void (GLAPIENTRYP VertexAttribP1ui)( GLuint index, GLenum type, + GLboolean normalized, GLuint value); + void (GLAPIENTRYP VertexAttribP2ui)( GLuint index, GLenum type, + GLboolean normalized, GLuint value); + void (GLAPIENTRYP VertexAttribP3ui)( GLuint index, GLenum type, + GLboolean normalized, GLuint value); + void (GLAPIENTRYP VertexAttribP4ui)( GLuint index, GLenum type, + GLboolean normalized, GLuint value); + void (GLAPIENTRYP VertexAttribP1uiv)( GLuint index, GLenum type, + GLboolean normalized, + const GLuint *value); + void (GLAPIENTRYP VertexAttribP2uiv)( GLuint index, GLenum type, + GLboolean normalized, + const GLuint *value); + void (GLAPIENTRYP VertexAttribP3uiv)( GLuint index, GLenum type, + GLboolean normalized, + const GLuint *value); + void (GLAPIENTRYP VertexAttribP4uiv)( GLuint index, GLenum type, + GLboolean normalized, + const GLuint *value); + + /*@}*/ + + void (GLAPIENTRYP Rectf)( GLfloat, GLfloat, GLfloat, GLfloat ); + + /** + * \name Array + */ + /*@{*/ + void (GLAPIENTRYP DrawArrays)( GLenum mode, GLint start, GLsizei count ); + void (GLAPIENTRYP DrawElements)( GLenum mode, GLsizei count, GLenum type, + const GLvoid *indices ); + void (GLAPIENTRYP DrawRangeElements)( GLenum mode, GLuint start, + GLuint end, GLsizei count, + GLenum type, const GLvoid *indices ); + void (GLAPIENTRYP MultiDrawElementsEXT)( GLenum mode, const GLsizei *count, + GLenum type, + const GLvoid **indices, + GLsizei primcount); + void (GLAPIENTRYP DrawElementsBaseVertex)( GLenum mode, GLsizei count, + GLenum type, + const GLvoid *indices, + GLint basevertex ); + void (GLAPIENTRYP DrawRangeElementsBaseVertex)( GLenum mode, GLuint start, + GLuint end, GLsizei count, + GLenum type, + const GLvoid *indices, + GLint basevertex); + void (GLAPIENTRYP MultiDrawElementsBaseVertex)( GLenum mode, + const GLsizei *count, + GLenum type, + const GLvoid **indices, + GLsizei primcount, + const GLint *basevertex); + void (GLAPIENTRYP DrawArraysInstanced)(GLenum mode, GLint first, + GLsizei count, GLsizei primcount); + void (GLAPIENTRYP DrawElementsInstanced)(GLenum mode, GLsizei count, + GLenum type, const GLvoid *indices, + GLsizei primcount); + void (GLAPIENTRYP DrawElementsInstancedBaseVertex)(GLenum mode, GLsizei count, + GLenum type, const GLvoid *indices, + GLsizei primcount, GLint basevertex); + /*@}*/ + + /** + * \name Eval + * + * If you don't support eval, fallback to the default vertex format + * on receiving an eval call and use the pipeline mechanism to + * provide partial T&L acceleration. + * + * Mesa will provide a set of helper functions to do eval within + * accelerated vertex formats, eventually... + */ + /*@{*/ + void (GLAPIENTRYP EvalMesh1)( GLenum mode, GLint i1, GLint i2 ); + void (GLAPIENTRYP EvalMesh2)( GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 ); + /*@}*/ + +} GLvertexformat; + + +#endif /* DD_INCLUDED */ diff --git a/mesalib/src/mesa/main/debug.h b/mesalib/src/mesa/main/debug.h index 81d4b67d8..bc64a83bb 100644 --- a/mesalib/src/mesa/main/debug.h +++ b/mesalib/src/mesa/main/debug.h @@ -1,94 +1,94 @@ -/* - * Mesa 3-D graphics library - * Version: 6.1 - * - * 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 debug.h - * Debugging functions. - * - * \if subset - * (No-op) - * - * \endif - */ - - -#ifndef _DEBUG_H -#define _DEBUG_H - -#include "glheader.h" -#include "mfeatures.h" - -struct gl_context; -struct gl_texture_image; - -#if _HAVE_FULL_GL - -extern void _mesa_print_tri_caps( const char *name, GLuint flags ); -extern void _mesa_print_enable_flags( const char *msg, GLuint flags ); -extern void _mesa_print_state( const char *msg, GLuint state ); -extern void _mesa_print_info( void ); -extern void _mesa_init_debug( struct gl_context *ctx ); - -#else - -/** No-op */ -#define _mesa_print_state( m, s ) ((void)0) - -/** No-op */ -#define _mesa_print_info() ((void)0) - -/** No-op */ -#define _mesa_init_debug( c ) ((void)0) - -#endif - -extern void -_mesa_write_renderbuffer_image(const struct gl_renderbuffer *rb); - -extern void -_mesa_dump_texture(GLuint texture, GLuint writeImages); - -extern void -_mesa_dump_textures(GLuint writeImages); - -extern void -_mesa_dump_renderbuffers(GLboolean writeImages); - -extern void -_mesa_dump_color_buffer(const char *filename); - -extern void -_mesa_dump_depth_buffer(const char *filename); - -extern void -_mesa_dump_stencil_buffer(const char *filename); - -extern void -_mesa_dump_image(const char *filename, const void *image, GLuint w, GLuint h, - GLenum format, GLenum type); - -extern void -_mesa_print_texture(struct gl_context *ctx, struct gl_texture_image *img); - -#endif +/* + * Mesa 3-D graphics library + * Version: 6.1 + * + * 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 debug.h + * Debugging functions. + * + * \if subset + * (No-op) + * + * \endif + */ + + +#ifndef _DEBUG_H +#define _DEBUG_H + +#include "glheader.h" +#include "mfeatures.h" + +struct gl_context; +struct gl_texture_image; + +#if _HAVE_FULL_GL + +extern void _mesa_print_tri_caps( const char *name, GLuint flags ); +extern void _mesa_print_enable_flags( const char *msg, GLuint flags ); +extern void _mesa_print_state( const char *msg, GLuint state ); +extern void _mesa_print_info( void ); +extern void _mesa_init_debug( struct gl_context *ctx ); + +#else + +/** No-op */ +#define _mesa_print_state( m, s ) ((void)0) + +/** No-op */ +#define _mesa_print_info() ((void)0) + +/** No-op */ +#define _mesa_init_debug( c ) ((void)0) + +#endif + +extern void +_mesa_write_renderbuffer_image(const struct gl_renderbuffer *rb); + +extern void +_mesa_dump_texture(GLuint texture, GLuint writeImages); + +extern void +_mesa_dump_textures(GLuint writeImages); + +extern void +_mesa_dump_renderbuffers(GLboolean writeImages); + +extern void +_mesa_dump_color_buffer(const char *filename); + +extern void +_mesa_dump_depth_buffer(const char *filename); + +extern void +_mesa_dump_stencil_buffer(const char *filename); + +extern void +_mesa_dump_image(const char *filename, const void *image, GLuint w, GLuint h, + GLenum format, GLenum type); + +extern void +_mesa_print_texture(struct gl_context *ctx, struct gl_texture_image *img); + +#endif diff --git a/mesalib/src/mesa/main/depth.c b/mesalib/src/mesa/main/depth.c index d666ed5fe..52c69a6bc 100644 --- a/mesalib/src/mesa/main/depth.c +++ b/mesalib/src/mesa/main/depth.c @@ -1,174 +1,174 @@ -/* - * 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 "glheader.h" -#include "imports.h" -#include "context.h" -#include "depth.h" -#include "enums.h" -#include "macros.h" -#include "mtypes.h" - - -/**********************************************************************/ -/***** API Functions *****/ -/**********************************************************************/ - - - -void GLAPIENTRY -_mesa_ClearDepth( GLclampd depth ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glClearDepth(%f)\n", depth); - - depth = CLAMP( depth, 0.0, 1.0 ); - - if (ctx->Depth.Clear == depth) - return; - - FLUSH_VERTICES(ctx, _NEW_DEPTH); - ctx->Depth.Clear = depth; - if (ctx->Driver.ClearDepth) - (*ctx->Driver.ClearDepth)( ctx, ctx->Depth.Clear ); -} - - -void GLAPIENTRY -_mesa_ClearDepthf( GLclampf depth ) -{ - _mesa_ClearDepth(depth); -} - - -void GLAPIENTRY -_mesa_DepthFunc( GLenum func ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glDepthFunc %s\n", _mesa_lookup_enum_by_nr(func)); - - switch (func) { - case GL_LESS: /* (default) pass if incoming z < stored z */ - case GL_GEQUAL: - case GL_LEQUAL: - case GL_GREATER: - case GL_NOTEQUAL: - case GL_EQUAL: - case GL_ALWAYS: - case GL_NEVER: - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glDepth.Func" ); - return; - } - - if (ctx->Depth.Func == func) - return; - - FLUSH_VERTICES(ctx, _NEW_DEPTH); - ctx->Depth.Func = func; - - if (ctx->Driver.DepthFunc) - ctx->Driver.DepthFunc( ctx, func ); -} - - - -void GLAPIENTRY -_mesa_DepthMask( GLboolean flag ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glDepthMask %d\n", flag); - - /* - * GL_TRUE indicates depth buffer writing is enabled (default) - * GL_FALSE indicates depth buffer writing is disabled - */ - if (ctx->Depth.Mask == flag) - return; - - FLUSH_VERTICES(ctx, _NEW_DEPTH); - ctx->Depth.Mask = flag; - - if (ctx->Driver.DepthMask) - ctx->Driver.DepthMask( ctx, flag ); -} - - - -/** - * Specified by the GL_EXT_depth_bounds_test extension. - */ -void GLAPIENTRY -_mesa_DepthBoundsEXT( GLclampd zmin, GLclampd zmax ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glDepthBounds(%f, %f)\n", zmin, zmax); - - if (zmin > zmax) { - _mesa_error(ctx, GL_INVALID_VALUE, "glDepthBoundsEXT(zmin > zmax)"); - return; - } - - zmin = CLAMP(zmin, 0.0, 1.0); - zmax = CLAMP(zmax, 0.0, 1.0); - - if (ctx->Depth.BoundsMin == zmin && ctx->Depth.BoundsMax == zmax) - return; - - FLUSH_VERTICES(ctx, _NEW_DEPTH); - ctx->Depth.BoundsMin = (GLfloat) zmin; - ctx->Depth.BoundsMax = (GLfloat) zmax; -} - - -/**********************************************************************/ -/***** Initialization *****/ -/**********************************************************************/ - - -/** - * Initialize the depth buffer attribute group in the given context. - */ -void -_mesa_init_depth(struct gl_context *ctx) -{ - ctx->Depth.Test = GL_FALSE; - ctx->Depth.Clear = 1.0; - ctx->Depth.Func = GL_LESS; - ctx->Depth.Mask = GL_TRUE; -} +/* + * 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 "glheader.h" +#include "imports.h" +#include "context.h" +#include "depth.h" +#include "enums.h" +#include "macros.h" +#include "mtypes.h" + + +/**********************************************************************/ +/***** API Functions *****/ +/**********************************************************************/ + + + +void GLAPIENTRY +_mesa_ClearDepth( GLclampd depth ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glClearDepth(%f)\n", depth); + + depth = CLAMP( depth, 0.0, 1.0 ); + + if (ctx->Depth.Clear == depth) + return; + + FLUSH_VERTICES(ctx, _NEW_DEPTH); + ctx->Depth.Clear = depth; + if (ctx->Driver.ClearDepth) + (*ctx->Driver.ClearDepth)( ctx, ctx->Depth.Clear ); +} + + +void GLAPIENTRY +_mesa_ClearDepthf( GLclampf depth ) +{ + _mesa_ClearDepth(depth); +} + + +void GLAPIENTRY +_mesa_DepthFunc( GLenum func ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glDepthFunc %s\n", _mesa_lookup_enum_by_nr(func)); + + switch (func) { + case GL_LESS: /* (default) pass if incoming z < stored z */ + case GL_GEQUAL: + case GL_LEQUAL: + case GL_GREATER: + case GL_NOTEQUAL: + case GL_EQUAL: + case GL_ALWAYS: + case GL_NEVER: + break; + default: + _mesa_error( ctx, GL_INVALID_ENUM, "glDepth.Func" ); + return; + } + + if (ctx->Depth.Func == func) + return; + + FLUSH_VERTICES(ctx, _NEW_DEPTH); + ctx->Depth.Func = func; + + if (ctx->Driver.DepthFunc) + ctx->Driver.DepthFunc( ctx, func ); +} + + + +void GLAPIENTRY +_mesa_DepthMask( GLboolean flag ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glDepthMask %d\n", flag); + + /* + * GL_TRUE indicates depth buffer writing is enabled (default) + * GL_FALSE indicates depth buffer writing is disabled + */ + if (ctx->Depth.Mask == flag) + return; + + FLUSH_VERTICES(ctx, _NEW_DEPTH); + ctx->Depth.Mask = flag; + + if (ctx->Driver.DepthMask) + ctx->Driver.DepthMask( ctx, flag ); +} + + + +/** + * Specified by the GL_EXT_depth_bounds_test extension. + */ +void GLAPIENTRY +_mesa_DepthBoundsEXT( GLclampd zmin, GLclampd zmax ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glDepthBounds(%f, %f)\n", zmin, zmax); + + if (zmin > zmax) { + _mesa_error(ctx, GL_INVALID_VALUE, "glDepthBoundsEXT(zmin > zmax)"); + return; + } + + zmin = CLAMP(zmin, 0.0, 1.0); + zmax = CLAMP(zmax, 0.0, 1.0); + + if (ctx->Depth.BoundsMin == zmin && ctx->Depth.BoundsMax == zmax) + return; + + FLUSH_VERTICES(ctx, _NEW_DEPTH); + ctx->Depth.BoundsMin = (GLfloat) zmin; + ctx->Depth.BoundsMax = (GLfloat) zmax; +} + + +/**********************************************************************/ +/***** Initialization *****/ +/**********************************************************************/ + + +/** + * Initialize the depth buffer attribute group in the given context. + */ +void +_mesa_init_depth(struct gl_context *ctx) +{ + ctx->Depth.Test = GL_FALSE; + ctx->Depth.Clear = 1.0; + ctx->Depth.Func = GL_LESS; + ctx->Depth.Mask = GL_TRUE; +} diff --git a/mesalib/src/mesa/main/depthstencil.c b/mesalib/src/mesa/main/depthstencil.c index 1fdd1cc0e..40d6c9612 100644 --- a/mesalib/src/mesa/main/depthstencil.c +++ b/mesalib/src/mesa/main/depthstencil.c @@ -1,1114 +1,1114 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5 - * - * 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 "context.h" -#include "formats.h" -#include "mtypes.h" -#include "depthstencil.h" -#include "renderbuffer.h" - - -/** - * Adaptor/wrappers for GL_DEPTH_STENCIL renderbuffers. - * - * The problem with a GL_DEPTH_STENCIL renderbuffer is that sometimes we - * want to treat it as a stencil buffer, other times we want to treat it - * as a depth/z buffer and still other times when we want to treat it as - * a combined Z+stencil buffer! That implies we need three different sets - * of Get/Put functions. - * - * We solve this by wrapping the Z24_S8 or S8_Z24 renderbuffer with depth and - * stencil adaptors, each with the right kind of depth/stencil Get/Put functions. - */ - - -static void * -nop_get_pointer(struct gl_context *ctx, struct gl_renderbuffer *rb, GLint x, GLint y) -{ - (void) ctx; - (void) rb; - (void) x; - (void) y; - return NULL; -} - - -/** - * Delete a depth or stencil wrapper renderbuffer. - */ -static void -delete_wrapper(struct gl_renderbuffer *rb) -{ - ASSERT(rb->Format == MESA_FORMAT_S8 || - rb->Format == MESA_FORMAT_X8_Z24 || - rb->Format == MESA_FORMAT_Z32_FLOAT); - _mesa_reference_renderbuffer(&rb->Wrapped, NULL); - free(rb); -} - - -/** - * Realloc storage for wrapper. - */ -static GLboolean -alloc_wrapper_storage(struct gl_context *ctx, struct gl_renderbuffer *rb, - GLenum internalFormat, GLuint width, GLuint height) -{ - /* just pass this on to the wrapped renderbuffer */ - struct gl_renderbuffer *dsrb = rb->Wrapped; - GLboolean retVal; - - (void) internalFormat; - - ASSERT(dsrb->Format == MESA_FORMAT_Z24_S8 || - dsrb->Format == MESA_FORMAT_Z24_X8 || - dsrb->Format == MESA_FORMAT_S8_Z24 || - dsrb->Format == MESA_FORMAT_X8_Z24); - - retVal = dsrb->AllocStorage(ctx, dsrb, dsrb->InternalFormat, width, height); - if (retVal) { - rb->Width = width; - rb->Height = height; - rb->RowStride = dsrb->RowStride; - } - return retVal; -} - - - - -/*====================================================================== - * Depth wrapper around depth/stencil renderbuffer - */ - -static void -get_row_z24(struct gl_context *ctx, struct gl_renderbuffer *z24rb, GLuint count, - GLint x, GLint y, void *values) -{ - struct gl_renderbuffer *dsrb = z24rb->Wrapped; - GLuint temp[MAX_WIDTH], i; - GLuint *dst = (GLuint *) values; - const GLuint *src = (const GLuint *) dsrb->GetPointer(ctx, dsrb, x, y); - ASSERT(z24rb->DataType == GL_UNSIGNED_INT); - ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT); - if (!src) { - dsrb->GetRow(ctx, dsrb, count, x, y, temp); - src = temp; - } - if (dsrb->Format == MESA_FORMAT_Z24_S8) { - for (i = 0; i < count; i++) { - dst[i] = src[i] >> 8; - } - } - else { - assert(dsrb->Format == MESA_FORMAT_S8_Z24); - for (i = 0; i < count; i++) { - dst[i] = src[i] & 0xffffff; - } - } -} - -static void -get_values_z24(struct gl_context *ctx, struct gl_renderbuffer *z24rb, GLuint count, - const GLint x[], const GLint y[], void *values) -{ - struct gl_renderbuffer *dsrb = z24rb->Wrapped; - GLuint temp[MAX_WIDTH], i; - GLuint *dst = (GLuint *) values; - ASSERT(z24rb->DataType == GL_UNSIGNED_INT); - ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT); - ASSERT(count <= MAX_WIDTH); - /* don't bother trying direct access */ - dsrb->GetValues(ctx, dsrb, count, x, y, temp); - if (dsrb->Format == MESA_FORMAT_Z24_S8) { - for (i = 0; i < count; i++) { - dst[i] = temp[i] >> 8; - } - } - else { - assert(dsrb->Format == MESA_FORMAT_S8_Z24); - for (i = 0; i < count; i++) { - dst[i] = temp[i] & 0xffffff; - } - } -} - -static void -put_row_z24(struct gl_context *ctx, struct gl_renderbuffer *z24rb, GLuint count, - GLint x, GLint y, const void *values, const GLubyte *mask) -{ - struct gl_renderbuffer *dsrb = z24rb->Wrapped; - const GLuint *src = (const GLuint *) values; - GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x, y); - ASSERT(z24rb->DataType == GL_UNSIGNED_INT); - ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT); - if (dst) { - /* direct access */ - GLuint i; - if (dsrb->Format == MESA_FORMAT_Z24_S8) { - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - dst[i] = (src[i] << 8) | (dst[i] & 0xff); - } - } - } - else { - assert(dsrb->Format == MESA_FORMAT_S8_Z24); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - dst[i] = (src[i] & 0xffffff) | (dst[i] & 0xff000000); - } - } - } - } - else { - /* get, modify, put */ - GLuint temp[MAX_WIDTH], i; - dsrb->GetRow(ctx, dsrb, count, x, y, temp); - if (dsrb->Format == MESA_FORMAT_Z24_S8) { - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - temp[i] = (src[i] << 8) | (temp[i] & 0xff); - } - } - } - else { - assert(dsrb->Format == MESA_FORMAT_S8_Z24); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - temp[i] = (src[i] & 0xffffff) | (temp[i] & 0xff000000); - } - } - } - dsrb->PutRow(ctx, dsrb, count, x, y, temp, mask); - } -} - -static void -put_mono_row_z24(struct gl_context *ctx, struct gl_renderbuffer *z24rb, GLuint count, - GLint x, GLint y, const void *value, const GLubyte *mask) -{ - struct gl_renderbuffer *dsrb = z24rb->Wrapped; - GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x, y); - ASSERT(z24rb->DataType == GL_UNSIGNED_INT); - ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT); - if (dst) { - /* direct access */ - GLuint i; - if (dsrb->Format == MESA_FORMAT_Z24_S8) { - const GLuint shiftedVal = *((GLuint *) value) << 8; - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - dst[i] = shiftedVal | (dst[i] & 0xff); - } - } - } - else { - const GLuint shiftedVal = *((GLuint *) value); - assert(dsrb->Format == MESA_FORMAT_S8_Z24); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - dst[i] = shiftedVal | (dst[i] & 0xff000000); - } - } - } - } - else { - /* get, modify, put */ - GLuint temp[MAX_WIDTH], i; - dsrb->GetRow(ctx, dsrb, count, x, y, temp); - if (dsrb->Format == MESA_FORMAT_Z24_S8) { - const GLuint shiftedVal = *((GLuint *) value) << 8; - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - temp[i] = shiftedVal | (temp[i] & 0xff); - } - } - } - else { - const GLuint shiftedVal = *((GLuint *) value); - assert(dsrb->Format == MESA_FORMAT_S8_Z24); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - temp[i] = shiftedVal | (temp[i] & 0xff000000); - } - } - } - dsrb->PutRow(ctx, dsrb, count, x, y, temp, mask); - } -} - -static void -put_values_z24(struct gl_context *ctx, struct gl_renderbuffer *z24rb, GLuint count, - const GLint x[], const GLint y[], - const void *values, const GLubyte *mask) -{ - struct gl_renderbuffer *dsrb = z24rb->Wrapped; - const GLuint *src = (const GLuint *) values; - ASSERT(z24rb->DataType == GL_UNSIGNED_INT); - ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT); - if (dsrb->GetPointer(ctx, dsrb, 0, 0)) { - /* direct access */ - GLuint i; - if (dsrb->Format == MESA_FORMAT_Z24_S8) { - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x[i], y[i]); - *dst = (src[i] << 8) | (*dst & 0xff); - } - } - } - else { - assert(dsrb->Format == MESA_FORMAT_S8_Z24); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x[i], y[i]); - *dst = (src[i] & 0xffffff) | (*dst & 0xff000000); - } - } - } - } - else { - /* get, modify, put */ - GLuint temp[MAX_WIDTH], i; - dsrb->GetValues(ctx, dsrb, count, x, y, temp); - if (dsrb->Format == MESA_FORMAT_Z24_S8) { - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - temp[i] = (src[i] << 8) | (temp[i] & 0xff); - } - } - } - else { - assert(dsrb->Format == MESA_FORMAT_S8_Z24); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - temp[i] = (src[i] & 0xffffff) | (temp[i] & 0xff000000); - } - } - } - dsrb->PutValues(ctx, dsrb, count, x, y, temp, mask); - } -} - -static void -put_mono_values_z24(struct gl_context *ctx, struct gl_renderbuffer *z24rb, - GLuint count, const GLint x[], const GLint y[], - const void *value, const GLubyte *mask) -{ - struct gl_renderbuffer *dsrb = z24rb->Wrapped; - GLuint temp[MAX_WIDTH], i; - /* get, modify, put */ - dsrb->GetValues(ctx, dsrb, count, x, y, temp); - if (dsrb->Format == MESA_FORMAT_Z24_S8) { - const GLuint shiftedVal = *((GLuint *) value) << 8; - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - temp[i] = shiftedVal | (temp[i] & 0xff); - } - } - } - else { - const GLuint shiftedVal = *((GLuint *) value); - assert(dsrb->Format == MESA_FORMAT_S8_Z24); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - temp[i] = shiftedVal | (temp[i] & 0xff000000); - } - } - } - dsrb->PutValues(ctx, dsrb, count, x, y, temp, mask); -} - - -/** - * Wrap the given GL_DEPTH_STENCIL renderbuffer so that it acts like - * a depth renderbuffer. - * \return new depth renderbuffer - */ -struct gl_renderbuffer * -_mesa_new_z24_renderbuffer_wrapper(struct gl_context *ctx, - struct gl_renderbuffer *dsrb) -{ - struct gl_renderbuffer *z24rb; - - ASSERT(dsrb->Format == MESA_FORMAT_Z24_S8 || - dsrb->Format == MESA_FORMAT_Z24_X8 || - dsrb->Format == MESA_FORMAT_S8_Z24 || - dsrb->Format == MESA_FORMAT_X8_Z24); - ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT); - - z24rb = ctx->Driver.NewRenderbuffer(ctx, 0); - if (!z24rb) - return NULL; - - /* NOTE: need to do manual refcounting here */ - z24rb->Wrapped = dsrb; - dsrb->RefCount++; - - z24rb->Name = dsrb->Name; - z24rb->RefCount = 0; - z24rb->Width = dsrb->Width; - z24rb->Height = dsrb->Height; - z24rb->RowStride = dsrb->RowStride; - z24rb->InternalFormat = GL_DEPTH_COMPONENT24; - z24rb->Format = MESA_FORMAT_X8_Z24; - z24rb->_BaseFormat = GL_DEPTH_COMPONENT; - z24rb->DataType = GL_UNSIGNED_INT; - z24rb->Data = NULL; - z24rb->Delete = delete_wrapper; - z24rb->AllocStorage = alloc_wrapper_storage; - z24rb->GetPointer = nop_get_pointer; - z24rb->GetRow = get_row_z24; - z24rb->GetValues = get_values_z24; - z24rb->PutRow = put_row_z24; - z24rb->PutRowRGB = NULL; - z24rb->PutMonoRow = put_mono_row_z24; - z24rb->PutValues = put_values_z24; - z24rb->PutMonoValues = put_mono_values_z24; - - return z24rb; -} - - -static void -get_row_z32f(struct gl_context *ctx, struct gl_renderbuffer *z32frb, GLuint count, - GLint x, GLint y, void *values) -{ - struct gl_renderbuffer *dsrb = z32frb->Wrapped; - GLfloat temp[MAX_WIDTH*2]; - GLfloat *dst = (GLfloat *) values; - const GLfloat *src = (const GLfloat *) dsrb->GetPointer(ctx, dsrb, x, y); - GLuint i; - ASSERT(z32frb->DataType == GL_FLOAT); - ASSERT(dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV); - ASSERT(dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8); - if (!src) { - dsrb->GetRow(ctx, dsrb, count, x, y, temp); - src = temp; - } - for (i = 0; i < count; i++) { - dst[i] = src[i*2]; - } -} - -static void -get_values_z32f(struct gl_context *ctx, struct gl_renderbuffer *z32frb, GLuint count, - const GLint x[], const GLint y[], void *values) -{ - struct gl_renderbuffer *dsrb = z32frb->Wrapped; - GLfloat temp[MAX_WIDTH*2]; - GLfloat *dst = (GLfloat *) values; - GLuint i; - ASSERT(z32frb->DataType == GL_FLOAT); - ASSERT(dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV); - ASSERT(dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8); - ASSERT(count <= MAX_WIDTH); - /* don't bother trying direct access */ - dsrb->GetValues(ctx, dsrb, count, x, y, temp); - for (i = 0; i < count; i++) { - dst[i] = temp[i*2]; - } -} - -static void -put_row_z32f(struct gl_context *ctx, struct gl_renderbuffer *z32frb, GLuint count, - GLint x, GLint y, const void *values, const GLubyte *mask) -{ - struct gl_renderbuffer *dsrb = z32frb->Wrapped; - const GLfloat *src = (const GLfloat *) values; - GLfloat *dst = (GLfloat *) dsrb->GetPointer(ctx, dsrb, x, y); - ASSERT(z32frb->DataType == GL_FLOAT); - ASSERT(dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV); - ASSERT(dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8); - if (dst) { - /* direct access */ - GLuint i; - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - dst[i*2] = src[i]; - } - } - } - else { - /* get, modify, put */ - GLfloat temp[MAX_WIDTH*2]; - GLuint i; - dsrb->GetRow(ctx, dsrb, count, x, y, temp); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - temp[i*2] = src[i]; - } - } - dsrb->PutRow(ctx, dsrb, count, x, y, temp, mask); - } -} - -static void -put_mono_row_z32f(struct gl_context *ctx, struct gl_renderbuffer *z32frb, GLuint count, - GLint x, GLint y, const void *value, const GLubyte *mask) -{ - struct gl_renderbuffer *dsrb = z32frb->Wrapped; - GLfloat *dst = (GLfloat *) dsrb->GetPointer(ctx, dsrb, x, y); - ASSERT(z32frb->DataType == GL_FLOAT); - ASSERT(dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV); - ASSERT(dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8); - if (dst) { - /* direct access */ - GLuint i; - const GLfloat val = *(GLfloat*)value; - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - dst[i*2] = val; - } - } - } - else { - /* get, modify, put */ - GLfloat temp[MAX_WIDTH*2]; - GLuint i; - const GLfloat val = *(GLfloat *)value; - dsrb->GetRow(ctx, dsrb, count, x, y, temp); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - temp[i*2] = val; - } - } - dsrb->PutRow(ctx, dsrb, count, x, y, temp, mask); - } -} - -static void -put_values_z32f(struct gl_context *ctx, struct gl_renderbuffer *z32frb, GLuint count, - const GLint x[], const GLint y[], - const void *values, const GLubyte *mask) -{ - struct gl_renderbuffer *dsrb = z32frb->Wrapped; - const GLfloat *src = (const GLfloat *) values; - ASSERT(z32frb->DataType == GL_FLOAT); - ASSERT(dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV); - ASSERT(dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8); - if (dsrb->GetPointer(ctx, dsrb, 0, 0)) { - /* direct access */ - GLuint i; - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - GLfloat *dst = (GLfloat *) dsrb->GetPointer(ctx, dsrb, x[i], y[i]); - *dst = src[i]; - } - } - } - else { - /* get, modify, put */ - GLfloat temp[MAX_WIDTH*2]; - GLuint i; - dsrb->GetValues(ctx, dsrb, count, x, y, temp); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - temp[i*2] = src[i]; - } - } - dsrb->PutValues(ctx, dsrb, count, x, y, temp, mask); - } -} - -static void -put_mono_values_z32f(struct gl_context *ctx, struct gl_renderbuffer *z32frb, - GLuint count, const GLint x[], const GLint y[], - const void *value, const GLubyte *mask) -{ - struct gl_renderbuffer *dsrb = z32frb->Wrapped; - GLfloat temp[MAX_WIDTH*2]; - GLuint i; - const GLfloat val = *(GLfloat *)value; - ASSERT(z32frb->DataType == GL_FLOAT); - ASSERT(dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV); - ASSERT(dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8); - /* get, modify, put */ - dsrb->GetValues(ctx, dsrb, count, x, y, temp); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - temp[i*2] = val; - } - } - dsrb->PutValues(ctx, dsrb, count, x, y, temp, mask); -} - - -/** - * Wrap the given GL_DEPTH_STENCIL renderbuffer so that it acts like - * a depth renderbuffer. - * \return new depth renderbuffer - */ -struct gl_renderbuffer * -_mesa_new_z32f_renderbuffer_wrapper(struct gl_context *ctx, - struct gl_renderbuffer *dsrb) -{ - struct gl_renderbuffer *z32frb; - - ASSERT(dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8); - ASSERT(dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV); - - z32frb = ctx->Driver.NewRenderbuffer(ctx, 0); - if (!z32frb) - return NULL; - - /* NOTE: need to do manual refcounting here */ - z32frb->Wrapped = dsrb; - dsrb->RefCount++; - - z32frb->Name = dsrb->Name; - z32frb->RefCount = 0; - z32frb->Width = dsrb->Width; - z32frb->Height = dsrb->Height; - z32frb->RowStride = dsrb->RowStride; - z32frb->InternalFormat = GL_DEPTH_COMPONENT32F; - z32frb->Format = MESA_FORMAT_Z32_FLOAT; - z32frb->_BaseFormat = GL_DEPTH_COMPONENT; - z32frb->DataType = GL_FLOAT; - z32frb->Data = NULL; - z32frb->Delete = delete_wrapper; - z32frb->AllocStorage = alloc_wrapper_storage; - z32frb->GetPointer = nop_get_pointer; - z32frb->GetRow = get_row_z32f; - z32frb->GetValues = get_values_z32f; - z32frb->PutRow = put_row_z32f; - z32frb->PutRowRGB = NULL; - z32frb->PutMonoRow = put_mono_row_z32f; - z32frb->PutValues = put_values_z32f; - z32frb->PutMonoValues = put_mono_values_z32f; - - return z32frb; -} - - -/*====================================================================== - * Stencil wrapper around depth/stencil renderbuffer - */ - -static void -get_row_s8(struct gl_context *ctx, struct gl_renderbuffer *s8rb, GLuint count, - GLint x, GLint y, void *values) -{ - struct gl_renderbuffer *dsrb = s8rb->Wrapped; - GLuint temp[MAX_WIDTH*2], i; - GLubyte *dst = (GLubyte *) values; - const GLuint *src = (const GLuint *) dsrb->GetPointer(ctx, dsrb, x, y); - ASSERT(s8rb->DataType == GL_UNSIGNED_BYTE); - ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT || - dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV); - if (!src) { - dsrb->GetRow(ctx, dsrb, count, x, y, temp); - src = temp; - } - if (dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8) { - for (i = 0; i < count; i++) { - dst[i] = src[i*2+1] & 0xff; - } - } - else if (dsrb->Format == MESA_FORMAT_Z24_S8) { - for (i = 0; i < count; i++) { - dst[i] = src[i] & 0xff; - } - } - else { - assert(dsrb->Format == MESA_FORMAT_S8_Z24); - for (i = 0; i < count; i++) { - dst[i] = src[i] >> 24; - } - } -} - -static void -get_values_s8(struct gl_context *ctx, struct gl_renderbuffer *s8rb, GLuint count, - const GLint x[], const GLint y[], void *values) -{ - struct gl_renderbuffer *dsrb = s8rb->Wrapped; - GLuint temp[MAX_WIDTH*2], i; - GLubyte *dst = (GLubyte *) values; - ASSERT(s8rb->DataType == GL_UNSIGNED_BYTE); - ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT || - dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV); - ASSERT(count <= MAX_WIDTH); - /* don't bother trying direct access */ - dsrb->GetValues(ctx, dsrb, count, x, y, temp); - if (dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8) { - for (i = 0; i < count; i++) { - dst[i] = temp[i*2+1] & 0xff; - } - } - else if (dsrb->Format == MESA_FORMAT_Z24_S8) { - for (i = 0; i < count; i++) { - dst[i] = temp[i] & 0xff; - } - } - else { - assert(dsrb->Format == MESA_FORMAT_S8_Z24); - for (i = 0; i < count; i++) { - dst[i] = temp[i] >> 24; - } - } -} - -static void -put_row_s8(struct gl_context *ctx, struct gl_renderbuffer *s8rb, GLuint count, - GLint x, GLint y, const void *values, const GLubyte *mask) -{ - struct gl_renderbuffer *dsrb = s8rb->Wrapped; - const GLubyte *src = (const GLubyte *) values; - GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x, y); - ASSERT(s8rb->DataType == GL_UNSIGNED_BYTE); - ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT || - dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV); - if (dst) { - /* direct access */ - GLuint i; - if (dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8) { - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - dst[i*2+1] = src[i]; - } - } - } - else if (dsrb->Format == MESA_FORMAT_Z24_S8) { - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - dst[i] = (dst[i] & 0xffffff00) | src[i]; - } - } - } - else { - assert(dsrb->Format == MESA_FORMAT_S8_Z24); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - dst[i] = (dst[i] & 0xffffff) | (src[i] << 24); - } - } - } - } - else { - /* get, modify, put */ - GLuint temp[MAX_WIDTH*2], i; - dsrb->GetRow(ctx, dsrb, count, x, y, temp); - if (dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8) { - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - temp[i*2+1] = src[i]; - } - } - } - else if (dsrb->Format == MESA_FORMAT_Z24_S8) { - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - temp[i] = (temp[i] & 0xffffff00) | src[i]; - } - } - } - else { - assert(dsrb->Format == MESA_FORMAT_S8_Z24); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - temp[i] = (temp[i] & 0xffffff) | (src[i] << 24); - } - } - } - dsrb->PutRow(ctx, dsrb, count, x, y, temp, mask); - } -} - -static void -put_mono_row_s8(struct gl_context *ctx, struct gl_renderbuffer *s8rb, GLuint count, - GLint x, GLint y, const void *value, const GLubyte *mask) -{ - struct gl_renderbuffer *dsrb = s8rb->Wrapped; - const GLubyte val = *((GLubyte *) value); - GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x, y); - ASSERT(s8rb->DataType == GL_UNSIGNED_BYTE); - ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT || - dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV); - if (dst) { - /* direct access */ - GLuint i; - if (dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8) { - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - dst[i*2+1] = val; - } - } - } - else if (dsrb->Format == MESA_FORMAT_Z24_S8) { - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - dst[i] = (dst[i] & 0xffffff00) | val; - } - } - } - else { - assert(dsrb->Format == MESA_FORMAT_S8_Z24); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - dst[i] = (dst[i] & 0xffffff) | (val << 24); - } - } - } - } - else { - /* get, modify, put */ - GLuint temp[MAX_WIDTH*2], i; - dsrb->GetRow(ctx, dsrb, count, x, y, temp); - if (dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8) { - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - temp[i*2+1] = val; - } - } - } - else if (dsrb->Format == MESA_FORMAT_Z24_S8) { - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - temp[i] = (temp[i] & 0xffffff00) | val; - } - } - } - else { - assert(dsrb->Format == MESA_FORMAT_S8_Z24); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - temp[i] = (temp[i] & 0xffffff) | (val << 24); - } - } - } - dsrb->PutRow(ctx, dsrb, count, x, y, temp, mask); - } -} - -static void -put_values_s8(struct gl_context *ctx, struct gl_renderbuffer *s8rb, GLuint count, - const GLint x[], const GLint y[], - const void *values, const GLubyte *mask) -{ - struct gl_renderbuffer *dsrb = s8rb->Wrapped; - const GLubyte *src = (const GLubyte *) values; - ASSERT(s8rb->DataType == GL_UNSIGNED_BYTE); - ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT || - dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV); - if (dsrb->GetPointer(ctx, dsrb, 0, 0)) { - /* direct access */ - GLuint i; - if (dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8) { - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x[i], y[i]); - dst[1] = src[i]; - } - } - } - else if (dsrb->Format == MESA_FORMAT_Z24_S8) { - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x[i], y[i]); - *dst = (*dst & 0xffffff00) | src[i]; - } - } - } - else { - assert(dsrb->Format == MESA_FORMAT_S8_Z24); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x[i], y[i]); - *dst = (*dst & 0xffffff) | (src[i] << 24); - } - } - } - } - else { - /* get, modify, put */ - GLuint temp[MAX_WIDTH*2], i; - dsrb->GetValues(ctx, dsrb, count, x, y, temp); - if (dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8) { - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - temp[i*2+1] = src[i]; - } - } - } - else if (dsrb->Format == MESA_FORMAT_Z24_S8) { - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - temp[i] = (temp[i] & 0xffffff00) | src[i]; - } - } - } - else { - assert(dsrb->Format == MESA_FORMAT_S8_Z24); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - temp[i] = (temp[i] & 0xffffff) | (src[i] << 24); - } - } - } - dsrb->PutValues(ctx, dsrb, count, x, y, temp, mask); - } -} - -static void -put_mono_values_s8(struct gl_context *ctx, struct gl_renderbuffer *s8rb, GLuint count, - const GLint x[], const GLint y[], - const void *value, const GLubyte *mask) -{ - struct gl_renderbuffer *dsrb = s8rb->Wrapped; - GLuint temp[MAX_WIDTH*2], i; - const GLubyte val = *((GLubyte *) value); - /* get, modify, put */ - dsrb->GetValues(ctx, dsrb, count, x, y, temp); - if (dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8) { - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - temp[i*2+1] = val; - } - } - } - else if (dsrb->Format == MESA_FORMAT_Z24_S8) { - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - temp[i] = (temp[i] & 0xffffff00) | val; - } - } - } - else { - assert(dsrb->Format == MESA_FORMAT_S8_Z24); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - temp[i] = (temp[i] & 0xffffff) | (val << 24); - } - } - } - dsrb->PutValues(ctx, dsrb, count, x, y, temp, mask); -} - - -/** - * Wrap the given GL_DEPTH_STENCIL renderbuffer so that it acts like - * a stencil renderbuffer. - * \return new stencil renderbuffer - */ -struct gl_renderbuffer * -_mesa_new_s8_renderbuffer_wrapper(struct gl_context *ctx, struct gl_renderbuffer *dsrb) -{ - struct gl_renderbuffer *s8rb; - - ASSERT(dsrb->Format == MESA_FORMAT_Z24_S8 || - dsrb->Format == MESA_FORMAT_S8_Z24 || - dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8); - ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT || - dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV); - - s8rb = ctx->Driver.NewRenderbuffer(ctx, 0); - if (!s8rb) - return NULL; - - /* NOTE: need to do manual refcounting here */ - s8rb->Wrapped = dsrb; - dsrb->RefCount++; - - s8rb->Name = dsrb->Name; - s8rb->RefCount = 0; - s8rb->Width = dsrb->Width; - s8rb->Height = dsrb->Height; - s8rb->RowStride = dsrb->RowStride; - s8rb->InternalFormat = GL_STENCIL_INDEX8_EXT; - s8rb->Format = MESA_FORMAT_S8; - s8rb->_BaseFormat = GL_STENCIL_INDEX; - s8rb->DataType = GL_UNSIGNED_BYTE; - s8rb->Data = NULL; - s8rb->Delete = delete_wrapper; - s8rb->AllocStorage = alloc_wrapper_storage; - s8rb->GetPointer = nop_get_pointer; - s8rb->GetRow = get_row_s8; - s8rb->GetValues = get_values_s8; - s8rb->PutRow = put_row_s8; - s8rb->PutRowRGB = NULL; - s8rb->PutMonoRow = put_mono_row_s8; - s8rb->PutValues = put_values_s8; - s8rb->PutMonoValues = put_mono_values_s8; - - return s8rb; -} - - - -/** - ** The following functions are useful for hardware drivers that only - ** implement combined depth/stencil buffers. - ** The GL_EXT_framebuffer_object extension allows indepedent depth and - ** stencil buffers to be used in any combination. - ** Therefore, we sometimes have to merge separate depth and stencil - ** renderbuffers into a single depth+stencil renderbuffer. And sometimes - ** we have to split combined depth+stencil renderbuffers into separate - ** renderbuffers. - **/ - - -/** - * Extract stencil values from the combined depth/stencil renderbuffer, storing - * the values into a separate stencil renderbuffer. - * \param dsRb the source depth/stencil renderbuffer - * \param stencilRb the destination stencil renderbuffer - * (either 8-bit or 32-bit) - */ -void -_mesa_extract_stencil(struct gl_context *ctx, - struct gl_renderbuffer *dsRb, - struct gl_renderbuffer *stencilRb) -{ - GLuint row, width, height; - - ASSERT(dsRb); - ASSERT(stencilRb); - - ASSERT(dsRb->Format == MESA_FORMAT_Z24_S8); - ASSERT(dsRb->DataType == GL_UNSIGNED_INT_24_8_EXT); - ASSERT(stencilRb->Format == MESA_FORMAT_Z24_S8 || - stencilRb->Format == MESA_FORMAT_S8); - ASSERT(dsRb->Width == stencilRb->Width); - ASSERT(dsRb->Height == stencilRb->Height); - - width = dsRb->Width; - height = dsRb->Height; - - for (row = 0; row < height; row++) { - GLuint depthStencil[MAX_WIDTH]; - dsRb->GetRow(ctx, dsRb, width, 0, row, depthStencil); - if (stencilRb->Format == MESA_FORMAT_S8) { - /* 8bpp stencil */ - GLubyte stencil[MAX_WIDTH]; - GLuint i; - for (i = 0; i < width; i++) { - stencil[i] = depthStencil[i] & 0xff; - } - stencilRb->PutRow(ctx, stencilRb, width, 0, row, stencil, NULL); - } - else { - /* 32bpp stencil */ - /* the 24 depth bits will be ignored */ - ASSERT(stencilRb->Format == MESA_FORMAT_Z24_S8); - ASSERT(stencilRb->DataType == GL_UNSIGNED_INT_24_8_EXT); - stencilRb->PutRow(ctx, stencilRb, width, 0, row, depthStencil, NULL); - } - } -} - - -/** - * Copy stencil values from a stencil renderbuffer into a combined - * depth/stencil renderbuffer. - * \param dsRb the destination depth/stencil renderbuffer - * \param stencilRb the source stencil buffer (either 8-bit or 32-bit) - */ -void -_mesa_insert_stencil(struct gl_context *ctx, - struct gl_renderbuffer *dsRb, - struct gl_renderbuffer *stencilRb) -{ - GLuint row, width, height; - - ASSERT(dsRb); - ASSERT(stencilRb); - - ASSERT(dsRb->Format == MESA_FORMAT_Z24_S8); - ASSERT(dsRb->DataType == GL_UNSIGNED_INT_24_8_EXT); - ASSERT(stencilRb->Format == MESA_FORMAT_Z24_S8 || - stencilRb->Format == MESA_FORMAT_S8); - - ASSERT(dsRb->Width == stencilRb->Width); - ASSERT(dsRb->Height == stencilRb->Height); - - width = dsRb->Width; - height = dsRb->Height; - - for (row = 0; row < height; row++) { - GLuint depthStencil[MAX_WIDTH]; - - dsRb->GetRow(ctx, dsRb, width, 0, row, depthStencil); - - if (stencilRb->Format == MESA_FORMAT_S8) { - /* 8bpp stencil */ - GLubyte stencil[MAX_WIDTH]; - GLuint i; - stencilRb->GetRow(ctx, stencilRb, width, 0, row, stencil); - for (i = 0; i < width; i++) { - depthStencil[i] = (depthStencil[i] & 0xffffff00) | stencil[i]; - } - } - else { - /* 32bpp stencil buffer */ - GLuint stencil[MAX_WIDTH], i; - ASSERT(stencilRb->Format == MESA_FORMAT_Z24_S8); - ASSERT(stencilRb->DataType == GL_UNSIGNED_INT_24_8_EXT); - stencilRb->GetRow(ctx, stencilRb, width, 0, row, stencil); - for (i = 0; i < width; i++) { - depthStencil[i] - = (depthStencil[i] & 0xffffff00) | (stencil[i] & 0xff); - } - } - - dsRb->PutRow(ctx, dsRb, width, 0, row, depthStencil, NULL); - } -} - - -/** - * Convert the stencil buffer from 8bpp to 32bpp depth/stencil. - * \param stencilRb the stencil renderbuffer to promote - */ -void -_mesa_promote_stencil(struct gl_context *ctx, struct gl_renderbuffer *stencilRb) -{ - const GLsizei width = stencilRb->Width; - const GLsizei height = stencilRb->Height; - GLubyte *data; - GLint i, j, k; - - ASSERT(stencilRb->Format == MESA_FORMAT_S8); - ASSERT(stencilRb->Data); - - data = (GLubyte *) stencilRb->Data; - stencilRb->Data = NULL; - stencilRb->AllocStorage(ctx, stencilRb, GL_DEPTH24_STENCIL8_EXT, - width, height); - - ASSERT(stencilRb->DataType == GL_UNSIGNED_INT_24_8_EXT); - - k = 0; - for (i = 0; i < height; i++) { - GLuint depthStencil[MAX_WIDTH]; - for (j = 0; j < width; j++) { - depthStencil[j] = data[k++]; - } - stencilRb->PutRow(ctx, stencilRb, width, 0, i, depthStencil, NULL); - } - free(data); -} +/* + * Mesa 3-D graphics library + * Version: 6.5 + * + * 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 "context.h" +#include "formats.h" +#include "mtypes.h" +#include "depthstencil.h" +#include "renderbuffer.h" + + +/** + * Adaptor/wrappers for GL_DEPTH_STENCIL renderbuffers. + * + * The problem with a GL_DEPTH_STENCIL renderbuffer is that sometimes we + * want to treat it as a stencil buffer, other times we want to treat it + * as a depth/z buffer and still other times when we want to treat it as + * a combined Z+stencil buffer! That implies we need three different sets + * of Get/Put functions. + * + * We solve this by wrapping the Z24_S8 or S8_Z24 renderbuffer with depth and + * stencil adaptors, each with the right kind of depth/stencil Get/Put functions. + */ + + +static void * +nop_get_pointer(struct gl_context *ctx, struct gl_renderbuffer *rb, GLint x, GLint y) +{ + (void) ctx; + (void) rb; + (void) x; + (void) y; + return NULL; +} + + +/** + * Delete a depth or stencil wrapper renderbuffer. + */ +static void +delete_wrapper(struct gl_renderbuffer *rb) +{ + ASSERT(rb->Format == MESA_FORMAT_S8 || + rb->Format == MESA_FORMAT_X8_Z24 || + rb->Format == MESA_FORMAT_Z32_FLOAT); + _mesa_reference_renderbuffer(&rb->Wrapped, NULL); + free(rb); +} + + +/** + * Realloc storage for wrapper. + */ +static GLboolean +alloc_wrapper_storage(struct gl_context *ctx, struct gl_renderbuffer *rb, + GLenum internalFormat, GLuint width, GLuint height) +{ + /* just pass this on to the wrapped renderbuffer */ + struct gl_renderbuffer *dsrb = rb->Wrapped; + GLboolean retVal; + + (void) internalFormat; + + ASSERT(dsrb->Format == MESA_FORMAT_Z24_S8 || + dsrb->Format == MESA_FORMAT_Z24_X8 || + dsrb->Format == MESA_FORMAT_S8_Z24 || + dsrb->Format == MESA_FORMAT_X8_Z24); + + retVal = dsrb->AllocStorage(ctx, dsrb, dsrb->InternalFormat, width, height); + if (retVal) { + rb->Width = width; + rb->Height = height; + rb->RowStride = dsrb->RowStride; + } + return retVal; +} + + + + +/*====================================================================== + * Depth wrapper around depth/stencil renderbuffer + */ + +static void +get_row_z24(struct gl_context *ctx, struct gl_renderbuffer *z24rb, GLuint count, + GLint x, GLint y, void *values) +{ + struct gl_renderbuffer *dsrb = z24rb->Wrapped; + GLuint temp[MAX_WIDTH], i; + GLuint *dst = (GLuint *) values; + const GLuint *src = (const GLuint *) dsrb->GetPointer(ctx, dsrb, x, y); + ASSERT(z24rb->DataType == GL_UNSIGNED_INT); + ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT); + if (!src) { + dsrb->GetRow(ctx, dsrb, count, x, y, temp); + src = temp; + } + if (dsrb->Format == MESA_FORMAT_Z24_S8) { + for (i = 0; i < count; i++) { + dst[i] = src[i] >> 8; + } + } + else { + assert(dsrb->Format == MESA_FORMAT_S8_Z24); + for (i = 0; i < count; i++) { + dst[i] = src[i] & 0xffffff; + } + } +} + +static void +get_values_z24(struct gl_context *ctx, struct gl_renderbuffer *z24rb, GLuint count, + const GLint x[], const GLint y[], void *values) +{ + struct gl_renderbuffer *dsrb = z24rb->Wrapped; + GLuint temp[MAX_WIDTH], i; + GLuint *dst = (GLuint *) values; + ASSERT(z24rb->DataType == GL_UNSIGNED_INT); + ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT); + ASSERT(count <= MAX_WIDTH); + /* don't bother trying direct access */ + dsrb->GetValues(ctx, dsrb, count, x, y, temp); + if (dsrb->Format == MESA_FORMAT_Z24_S8) { + for (i = 0; i < count; i++) { + dst[i] = temp[i] >> 8; + } + } + else { + assert(dsrb->Format == MESA_FORMAT_S8_Z24); + for (i = 0; i < count; i++) { + dst[i] = temp[i] & 0xffffff; + } + } +} + +static void +put_row_z24(struct gl_context *ctx, struct gl_renderbuffer *z24rb, GLuint count, + GLint x, GLint y, const void *values, const GLubyte *mask) +{ + struct gl_renderbuffer *dsrb = z24rb->Wrapped; + const GLuint *src = (const GLuint *) values; + GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x, y); + ASSERT(z24rb->DataType == GL_UNSIGNED_INT); + ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT); + if (dst) { + /* direct access */ + GLuint i; + if (dsrb->Format == MESA_FORMAT_Z24_S8) { + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + dst[i] = (src[i] << 8) | (dst[i] & 0xff); + } + } + } + else { + assert(dsrb->Format == MESA_FORMAT_S8_Z24); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + dst[i] = (src[i] & 0xffffff) | (dst[i] & 0xff000000); + } + } + } + } + else { + /* get, modify, put */ + GLuint temp[MAX_WIDTH], i; + dsrb->GetRow(ctx, dsrb, count, x, y, temp); + if (dsrb->Format == MESA_FORMAT_Z24_S8) { + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + temp[i] = (src[i] << 8) | (temp[i] & 0xff); + } + } + } + else { + assert(dsrb->Format == MESA_FORMAT_S8_Z24); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + temp[i] = (src[i] & 0xffffff) | (temp[i] & 0xff000000); + } + } + } + dsrb->PutRow(ctx, dsrb, count, x, y, temp, mask); + } +} + +static void +put_mono_row_z24(struct gl_context *ctx, struct gl_renderbuffer *z24rb, GLuint count, + GLint x, GLint y, const void *value, const GLubyte *mask) +{ + struct gl_renderbuffer *dsrb = z24rb->Wrapped; + GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x, y); + ASSERT(z24rb->DataType == GL_UNSIGNED_INT); + ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT); + if (dst) { + /* direct access */ + GLuint i; + if (dsrb->Format == MESA_FORMAT_Z24_S8) { + const GLuint shiftedVal = *((GLuint *) value) << 8; + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + dst[i] = shiftedVal | (dst[i] & 0xff); + } + } + } + else { + const GLuint shiftedVal = *((GLuint *) value); + assert(dsrb->Format == MESA_FORMAT_S8_Z24); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + dst[i] = shiftedVal | (dst[i] & 0xff000000); + } + } + } + } + else { + /* get, modify, put */ + GLuint temp[MAX_WIDTH], i; + dsrb->GetRow(ctx, dsrb, count, x, y, temp); + if (dsrb->Format == MESA_FORMAT_Z24_S8) { + const GLuint shiftedVal = *((GLuint *) value) << 8; + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + temp[i] = shiftedVal | (temp[i] & 0xff); + } + } + } + else { + const GLuint shiftedVal = *((GLuint *) value); + assert(dsrb->Format == MESA_FORMAT_S8_Z24); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + temp[i] = shiftedVal | (temp[i] & 0xff000000); + } + } + } + dsrb->PutRow(ctx, dsrb, count, x, y, temp, mask); + } +} + +static void +put_values_z24(struct gl_context *ctx, struct gl_renderbuffer *z24rb, GLuint count, + const GLint x[], const GLint y[], + const void *values, const GLubyte *mask) +{ + struct gl_renderbuffer *dsrb = z24rb->Wrapped; + const GLuint *src = (const GLuint *) values; + ASSERT(z24rb->DataType == GL_UNSIGNED_INT); + ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT); + if (dsrb->GetPointer(ctx, dsrb, 0, 0)) { + /* direct access */ + GLuint i; + if (dsrb->Format == MESA_FORMAT_Z24_S8) { + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x[i], y[i]); + *dst = (src[i] << 8) | (*dst & 0xff); + } + } + } + else { + assert(dsrb->Format == MESA_FORMAT_S8_Z24); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x[i], y[i]); + *dst = (src[i] & 0xffffff) | (*dst & 0xff000000); + } + } + } + } + else { + /* get, modify, put */ + GLuint temp[MAX_WIDTH], i; + dsrb->GetValues(ctx, dsrb, count, x, y, temp); + if (dsrb->Format == MESA_FORMAT_Z24_S8) { + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + temp[i] = (src[i] << 8) | (temp[i] & 0xff); + } + } + } + else { + assert(dsrb->Format == MESA_FORMAT_S8_Z24); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + temp[i] = (src[i] & 0xffffff) | (temp[i] & 0xff000000); + } + } + } + dsrb->PutValues(ctx, dsrb, count, x, y, temp, mask); + } +} + +static void +put_mono_values_z24(struct gl_context *ctx, struct gl_renderbuffer *z24rb, + GLuint count, const GLint x[], const GLint y[], + const void *value, const GLubyte *mask) +{ + struct gl_renderbuffer *dsrb = z24rb->Wrapped; + GLuint temp[MAX_WIDTH], i; + /* get, modify, put */ + dsrb->GetValues(ctx, dsrb, count, x, y, temp); + if (dsrb->Format == MESA_FORMAT_Z24_S8) { + const GLuint shiftedVal = *((GLuint *) value) << 8; + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + temp[i] = shiftedVal | (temp[i] & 0xff); + } + } + } + else { + const GLuint shiftedVal = *((GLuint *) value); + assert(dsrb->Format == MESA_FORMAT_S8_Z24); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + temp[i] = shiftedVal | (temp[i] & 0xff000000); + } + } + } + dsrb->PutValues(ctx, dsrb, count, x, y, temp, mask); +} + + +/** + * Wrap the given GL_DEPTH_STENCIL renderbuffer so that it acts like + * a depth renderbuffer. + * \return new depth renderbuffer + */ +struct gl_renderbuffer * +_mesa_new_z24_renderbuffer_wrapper(struct gl_context *ctx, + struct gl_renderbuffer *dsrb) +{ + struct gl_renderbuffer *z24rb; + + ASSERT(dsrb->Format == MESA_FORMAT_Z24_S8 || + dsrb->Format == MESA_FORMAT_Z24_X8 || + dsrb->Format == MESA_FORMAT_S8_Z24 || + dsrb->Format == MESA_FORMAT_X8_Z24); + ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT); + + z24rb = ctx->Driver.NewRenderbuffer(ctx, 0); + if (!z24rb) + return NULL; + + /* NOTE: need to do manual refcounting here */ + z24rb->Wrapped = dsrb; + dsrb->RefCount++; + + z24rb->Name = dsrb->Name; + z24rb->RefCount = 0; + z24rb->Width = dsrb->Width; + z24rb->Height = dsrb->Height; + z24rb->RowStride = dsrb->RowStride; + z24rb->InternalFormat = GL_DEPTH_COMPONENT24; + z24rb->Format = MESA_FORMAT_X8_Z24; + z24rb->_BaseFormat = GL_DEPTH_COMPONENT; + z24rb->DataType = GL_UNSIGNED_INT; + z24rb->Data = NULL; + z24rb->Delete = delete_wrapper; + z24rb->AllocStorage = alloc_wrapper_storage; + z24rb->GetPointer = nop_get_pointer; + z24rb->GetRow = get_row_z24; + z24rb->GetValues = get_values_z24; + z24rb->PutRow = put_row_z24; + z24rb->PutRowRGB = NULL; + z24rb->PutMonoRow = put_mono_row_z24; + z24rb->PutValues = put_values_z24; + z24rb->PutMonoValues = put_mono_values_z24; + + return z24rb; +} + + +static void +get_row_z32f(struct gl_context *ctx, struct gl_renderbuffer *z32frb, GLuint count, + GLint x, GLint y, void *values) +{ + struct gl_renderbuffer *dsrb = z32frb->Wrapped; + GLfloat temp[MAX_WIDTH*2]; + GLfloat *dst = (GLfloat *) values; + const GLfloat *src = (const GLfloat *) dsrb->GetPointer(ctx, dsrb, x, y); + GLuint i; + ASSERT(z32frb->DataType == GL_FLOAT); + ASSERT(dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV); + ASSERT(dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8); + if (!src) { + dsrb->GetRow(ctx, dsrb, count, x, y, temp); + src = temp; + } + for (i = 0; i < count; i++) { + dst[i] = src[i*2]; + } +} + +static void +get_values_z32f(struct gl_context *ctx, struct gl_renderbuffer *z32frb, GLuint count, + const GLint x[], const GLint y[], void *values) +{ + struct gl_renderbuffer *dsrb = z32frb->Wrapped; + GLfloat temp[MAX_WIDTH*2]; + GLfloat *dst = (GLfloat *) values; + GLuint i; + ASSERT(z32frb->DataType == GL_FLOAT); + ASSERT(dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV); + ASSERT(dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8); + ASSERT(count <= MAX_WIDTH); + /* don't bother trying direct access */ + dsrb->GetValues(ctx, dsrb, count, x, y, temp); + for (i = 0; i < count; i++) { + dst[i] = temp[i*2]; + } +} + +static void +put_row_z32f(struct gl_context *ctx, struct gl_renderbuffer *z32frb, GLuint count, + GLint x, GLint y, const void *values, const GLubyte *mask) +{ + struct gl_renderbuffer *dsrb = z32frb->Wrapped; + const GLfloat *src = (const GLfloat *) values; + GLfloat *dst = (GLfloat *) dsrb->GetPointer(ctx, dsrb, x, y); + ASSERT(z32frb->DataType == GL_FLOAT); + ASSERT(dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV); + ASSERT(dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8); + if (dst) { + /* direct access */ + GLuint i; + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + dst[i*2] = src[i]; + } + } + } + else { + /* get, modify, put */ + GLfloat temp[MAX_WIDTH*2]; + GLuint i; + dsrb->GetRow(ctx, dsrb, count, x, y, temp); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + temp[i*2] = src[i]; + } + } + dsrb->PutRow(ctx, dsrb, count, x, y, temp, mask); + } +} + +static void +put_mono_row_z32f(struct gl_context *ctx, struct gl_renderbuffer *z32frb, GLuint count, + GLint x, GLint y, const void *value, const GLubyte *mask) +{ + struct gl_renderbuffer *dsrb = z32frb->Wrapped; + GLfloat *dst = (GLfloat *) dsrb->GetPointer(ctx, dsrb, x, y); + ASSERT(z32frb->DataType == GL_FLOAT); + ASSERT(dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV); + ASSERT(dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8); + if (dst) { + /* direct access */ + GLuint i; + const GLfloat val = *(GLfloat*)value; + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + dst[i*2] = val; + } + } + } + else { + /* get, modify, put */ + GLfloat temp[MAX_WIDTH*2]; + GLuint i; + const GLfloat val = *(GLfloat *)value; + dsrb->GetRow(ctx, dsrb, count, x, y, temp); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + temp[i*2] = val; + } + } + dsrb->PutRow(ctx, dsrb, count, x, y, temp, mask); + } +} + +static void +put_values_z32f(struct gl_context *ctx, struct gl_renderbuffer *z32frb, GLuint count, + const GLint x[], const GLint y[], + const void *values, const GLubyte *mask) +{ + struct gl_renderbuffer *dsrb = z32frb->Wrapped; + const GLfloat *src = (const GLfloat *) values; + ASSERT(z32frb->DataType == GL_FLOAT); + ASSERT(dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV); + ASSERT(dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8); + if (dsrb->GetPointer(ctx, dsrb, 0, 0)) { + /* direct access */ + GLuint i; + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + GLfloat *dst = (GLfloat *) dsrb->GetPointer(ctx, dsrb, x[i], y[i]); + *dst = src[i]; + } + } + } + else { + /* get, modify, put */ + GLfloat temp[MAX_WIDTH*2]; + GLuint i; + dsrb->GetValues(ctx, dsrb, count, x, y, temp); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + temp[i*2] = src[i]; + } + } + dsrb->PutValues(ctx, dsrb, count, x, y, temp, mask); + } +} + +static void +put_mono_values_z32f(struct gl_context *ctx, struct gl_renderbuffer *z32frb, + GLuint count, const GLint x[], const GLint y[], + const void *value, const GLubyte *mask) +{ + struct gl_renderbuffer *dsrb = z32frb->Wrapped; + GLfloat temp[MAX_WIDTH*2]; + GLuint i; + const GLfloat val = *(GLfloat *)value; + ASSERT(z32frb->DataType == GL_FLOAT); + ASSERT(dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV); + ASSERT(dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8); + /* get, modify, put */ + dsrb->GetValues(ctx, dsrb, count, x, y, temp); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + temp[i*2] = val; + } + } + dsrb->PutValues(ctx, dsrb, count, x, y, temp, mask); +} + + +/** + * Wrap the given GL_DEPTH_STENCIL renderbuffer so that it acts like + * a depth renderbuffer. + * \return new depth renderbuffer + */ +struct gl_renderbuffer * +_mesa_new_z32f_renderbuffer_wrapper(struct gl_context *ctx, + struct gl_renderbuffer *dsrb) +{ + struct gl_renderbuffer *z32frb; + + ASSERT(dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8); + ASSERT(dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV); + + z32frb = ctx->Driver.NewRenderbuffer(ctx, 0); + if (!z32frb) + return NULL; + + /* NOTE: need to do manual refcounting here */ + z32frb->Wrapped = dsrb; + dsrb->RefCount++; + + z32frb->Name = dsrb->Name; + z32frb->RefCount = 0; + z32frb->Width = dsrb->Width; + z32frb->Height = dsrb->Height; + z32frb->RowStride = dsrb->RowStride; + z32frb->InternalFormat = GL_DEPTH_COMPONENT32F; + z32frb->Format = MESA_FORMAT_Z32_FLOAT; + z32frb->_BaseFormat = GL_DEPTH_COMPONENT; + z32frb->DataType = GL_FLOAT; + z32frb->Data = NULL; + z32frb->Delete = delete_wrapper; + z32frb->AllocStorage = alloc_wrapper_storage; + z32frb->GetPointer = nop_get_pointer; + z32frb->GetRow = get_row_z32f; + z32frb->GetValues = get_values_z32f; + z32frb->PutRow = put_row_z32f; + z32frb->PutRowRGB = NULL; + z32frb->PutMonoRow = put_mono_row_z32f; + z32frb->PutValues = put_values_z32f; + z32frb->PutMonoValues = put_mono_values_z32f; + + return z32frb; +} + + +/*====================================================================== + * Stencil wrapper around depth/stencil renderbuffer + */ + +static void +get_row_s8(struct gl_context *ctx, struct gl_renderbuffer *s8rb, GLuint count, + GLint x, GLint y, void *values) +{ + struct gl_renderbuffer *dsrb = s8rb->Wrapped; + GLuint temp[MAX_WIDTH*2], i; + GLubyte *dst = (GLubyte *) values; + const GLuint *src = (const GLuint *) dsrb->GetPointer(ctx, dsrb, x, y); + ASSERT(s8rb->DataType == GL_UNSIGNED_BYTE); + ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT || + dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV); + if (!src) { + dsrb->GetRow(ctx, dsrb, count, x, y, temp); + src = temp; + } + if (dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8) { + for (i = 0; i < count; i++) { + dst[i] = src[i*2+1] & 0xff; + } + } + else if (dsrb->Format == MESA_FORMAT_Z24_S8) { + for (i = 0; i < count; i++) { + dst[i] = src[i] & 0xff; + } + } + else { + assert(dsrb->Format == MESA_FORMAT_S8_Z24); + for (i = 0; i < count; i++) { + dst[i] = src[i] >> 24; + } + } +} + +static void +get_values_s8(struct gl_context *ctx, struct gl_renderbuffer *s8rb, GLuint count, + const GLint x[], const GLint y[], void *values) +{ + struct gl_renderbuffer *dsrb = s8rb->Wrapped; + GLuint temp[MAX_WIDTH*2], i; + GLubyte *dst = (GLubyte *) values; + ASSERT(s8rb->DataType == GL_UNSIGNED_BYTE); + ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT || + dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV); + ASSERT(count <= MAX_WIDTH); + /* don't bother trying direct access */ + dsrb->GetValues(ctx, dsrb, count, x, y, temp); + if (dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8) { + for (i = 0; i < count; i++) { + dst[i] = temp[i*2+1] & 0xff; + } + } + else if (dsrb->Format == MESA_FORMAT_Z24_S8) { + for (i = 0; i < count; i++) { + dst[i] = temp[i] & 0xff; + } + } + else { + assert(dsrb->Format == MESA_FORMAT_S8_Z24); + for (i = 0; i < count; i++) { + dst[i] = temp[i] >> 24; + } + } +} + +static void +put_row_s8(struct gl_context *ctx, struct gl_renderbuffer *s8rb, GLuint count, + GLint x, GLint y, const void *values, const GLubyte *mask) +{ + struct gl_renderbuffer *dsrb = s8rb->Wrapped; + const GLubyte *src = (const GLubyte *) values; + GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x, y); + ASSERT(s8rb->DataType == GL_UNSIGNED_BYTE); + ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT || + dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV); + if (dst) { + /* direct access */ + GLuint i; + if (dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8) { + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + dst[i*2+1] = src[i]; + } + } + } + else if (dsrb->Format == MESA_FORMAT_Z24_S8) { + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + dst[i] = (dst[i] & 0xffffff00) | src[i]; + } + } + } + else { + assert(dsrb->Format == MESA_FORMAT_S8_Z24); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + dst[i] = (dst[i] & 0xffffff) | (src[i] << 24); + } + } + } + } + else { + /* get, modify, put */ + GLuint temp[MAX_WIDTH*2], i; + dsrb->GetRow(ctx, dsrb, count, x, y, temp); + if (dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8) { + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + temp[i*2+1] = src[i]; + } + } + } + else if (dsrb->Format == MESA_FORMAT_Z24_S8) { + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + temp[i] = (temp[i] & 0xffffff00) | src[i]; + } + } + } + else { + assert(dsrb->Format == MESA_FORMAT_S8_Z24); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + temp[i] = (temp[i] & 0xffffff) | (src[i] << 24); + } + } + } + dsrb->PutRow(ctx, dsrb, count, x, y, temp, mask); + } +} + +static void +put_mono_row_s8(struct gl_context *ctx, struct gl_renderbuffer *s8rb, GLuint count, + GLint x, GLint y, const void *value, const GLubyte *mask) +{ + struct gl_renderbuffer *dsrb = s8rb->Wrapped; + const GLubyte val = *((GLubyte *) value); + GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x, y); + ASSERT(s8rb->DataType == GL_UNSIGNED_BYTE); + ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT || + dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV); + if (dst) { + /* direct access */ + GLuint i; + if (dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8) { + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + dst[i*2+1] = val; + } + } + } + else if (dsrb->Format == MESA_FORMAT_Z24_S8) { + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + dst[i] = (dst[i] & 0xffffff00) | val; + } + } + } + else { + assert(dsrb->Format == MESA_FORMAT_S8_Z24); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + dst[i] = (dst[i] & 0xffffff) | (val << 24); + } + } + } + } + else { + /* get, modify, put */ + GLuint temp[MAX_WIDTH*2], i; + dsrb->GetRow(ctx, dsrb, count, x, y, temp); + if (dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8) { + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + temp[i*2+1] = val; + } + } + } + else if (dsrb->Format == MESA_FORMAT_Z24_S8) { + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + temp[i] = (temp[i] & 0xffffff00) | val; + } + } + } + else { + assert(dsrb->Format == MESA_FORMAT_S8_Z24); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + temp[i] = (temp[i] & 0xffffff) | (val << 24); + } + } + } + dsrb->PutRow(ctx, dsrb, count, x, y, temp, mask); + } +} + +static void +put_values_s8(struct gl_context *ctx, struct gl_renderbuffer *s8rb, GLuint count, + const GLint x[], const GLint y[], + const void *values, const GLubyte *mask) +{ + struct gl_renderbuffer *dsrb = s8rb->Wrapped; + const GLubyte *src = (const GLubyte *) values; + ASSERT(s8rb->DataType == GL_UNSIGNED_BYTE); + ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT || + dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV); + if (dsrb->GetPointer(ctx, dsrb, 0, 0)) { + /* direct access */ + GLuint i; + if (dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8) { + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x[i], y[i]); + dst[1] = src[i]; + } + } + } + else if (dsrb->Format == MESA_FORMAT_Z24_S8) { + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x[i], y[i]); + *dst = (*dst & 0xffffff00) | src[i]; + } + } + } + else { + assert(dsrb->Format == MESA_FORMAT_S8_Z24); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x[i], y[i]); + *dst = (*dst & 0xffffff) | (src[i] << 24); + } + } + } + } + else { + /* get, modify, put */ + GLuint temp[MAX_WIDTH*2], i; + dsrb->GetValues(ctx, dsrb, count, x, y, temp); + if (dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8) { + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + temp[i*2+1] = src[i]; + } + } + } + else if (dsrb->Format == MESA_FORMAT_Z24_S8) { + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + temp[i] = (temp[i] & 0xffffff00) | src[i]; + } + } + } + else { + assert(dsrb->Format == MESA_FORMAT_S8_Z24); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + temp[i] = (temp[i] & 0xffffff) | (src[i] << 24); + } + } + } + dsrb->PutValues(ctx, dsrb, count, x, y, temp, mask); + } +} + +static void +put_mono_values_s8(struct gl_context *ctx, struct gl_renderbuffer *s8rb, GLuint count, + const GLint x[], const GLint y[], + const void *value, const GLubyte *mask) +{ + struct gl_renderbuffer *dsrb = s8rb->Wrapped; + GLuint temp[MAX_WIDTH*2], i; + const GLubyte val = *((GLubyte *) value); + /* get, modify, put */ + dsrb->GetValues(ctx, dsrb, count, x, y, temp); + if (dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8) { + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + temp[i*2+1] = val; + } + } + } + else if (dsrb->Format == MESA_FORMAT_Z24_S8) { + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + temp[i] = (temp[i] & 0xffffff00) | val; + } + } + } + else { + assert(dsrb->Format == MESA_FORMAT_S8_Z24); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + temp[i] = (temp[i] & 0xffffff) | (val << 24); + } + } + } + dsrb->PutValues(ctx, dsrb, count, x, y, temp, mask); +} + + +/** + * Wrap the given GL_DEPTH_STENCIL renderbuffer so that it acts like + * a stencil renderbuffer. + * \return new stencil renderbuffer + */ +struct gl_renderbuffer * +_mesa_new_s8_renderbuffer_wrapper(struct gl_context *ctx, struct gl_renderbuffer *dsrb) +{ + struct gl_renderbuffer *s8rb; + + ASSERT(dsrb->Format == MESA_FORMAT_Z24_S8 || + dsrb->Format == MESA_FORMAT_S8_Z24 || + dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8); + ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT || + dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV); + + s8rb = ctx->Driver.NewRenderbuffer(ctx, 0); + if (!s8rb) + return NULL; + + /* NOTE: need to do manual refcounting here */ + s8rb->Wrapped = dsrb; + dsrb->RefCount++; + + s8rb->Name = dsrb->Name; + s8rb->RefCount = 0; + s8rb->Width = dsrb->Width; + s8rb->Height = dsrb->Height; + s8rb->RowStride = dsrb->RowStride; + s8rb->InternalFormat = GL_STENCIL_INDEX8_EXT; + s8rb->Format = MESA_FORMAT_S8; + s8rb->_BaseFormat = GL_STENCIL_INDEX; + s8rb->DataType = GL_UNSIGNED_BYTE; + s8rb->Data = NULL; + s8rb->Delete = delete_wrapper; + s8rb->AllocStorage = alloc_wrapper_storage; + s8rb->GetPointer = nop_get_pointer; + s8rb->GetRow = get_row_s8; + s8rb->GetValues = get_values_s8; + s8rb->PutRow = put_row_s8; + s8rb->PutRowRGB = NULL; + s8rb->PutMonoRow = put_mono_row_s8; + s8rb->PutValues = put_values_s8; + s8rb->PutMonoValues = put_mono_values_s8; + + return s8rb; +} + + + +/** + ** The following functions are useful for hardware drivers that only + ** implement combined depth/stencil buffers. + ** The GL_EXT_framebuffer_object extension allows indepedent depth and + ** stencil buffers to be used in any combination. + ** Therefore, we sometimes have to merge separate depth and stencil + ** renderbuffers into a single depth+stencil renderbuffer. And sometimes + ** we have to split combined depth+stencil renderbuffers into separate + ** renderbuffers. + **/ + + +/** + * Extract stencil values from the combined depth/stencil renderbuffer, storing + * the values into a separate stencil renderbuffer. + * \param dsRb the source depth/stencil renderbuffer + * \param stencilRb the destination stencil renderbuffer + * (either 8-bit or 32-bit) + */ +void +_mesa_extract_stencil(struct gl_context *ctx, + struct gl_renderbuffer *dsRb, + struct gl_renderbuffer *stencilRb) +{ + GLuint row, width, height; + + ASSERT(dsRb); + ASSERT(stencilRb); + + ASSERT(dsRb->Format == MESA_FORMAT_Z24_S8); + ASSERT(dsRb->DataType == GL_UNSIGNED_INT_24_8_EXT); + ASSERT(stencilRb->Format == MESA_FORMAT_Z24_S8 || + stencilRb->Format == MESA_FORMAT_S8); + ASSERT(dsRb->Width == stencilRb->Width); + ASSERT(dsRb->Height == stencilRb->Height); + + width = dsRb->Width; + height = dsRb->Height; + + for (row = 0; row < height; row++) { + GLuint depthStencil[MAX_WIDTH]; + dsRb->GetRow(ctx, dsRb, width, 0, row, depthStencil); + if (stencilRb->Format == MESA_FORMAT_S8) { + /* 8bpp stencil */ + GLubyte stencil[MAX_WIDTH]; + GLuint i; + for (i = 0; i < width; i++) { + stencil[i] = depthStencil[i] & 0xff; + } + stencilRb->PutRow(ctx, stencilRb, width, 0, row, stencil, NULL); + } + else { + /* 32bpp stencil */ + /* the 24 depth bits will be ignored */ + ASSERT(stencilRb->Format == MESA_FORMAT_Z24_S8); + ASSERT(stencilRb->DataType == GL_UNSIGNED_INT_24_8_EXT); + stencilRb->PutRow(ctx, stencilRb, width, 0, row, depthStencil, NULL); + } + } +} + + +/** + * Copy stencil values from a stencil renderbuffer into a combined + * depth/stencil renderbuffer. + * \param dsRb the destination depth/stencil renderbuffer + * \param stencilRb the source stencil buffer (either 8-bit or 32-bit) + */ +void +_mesa_insert_stencil(struct gl_context *ctx, + struct gl_renderbuffer *dsRb, + struct gl_renderbuffer *stencilRb) +{ + GLuint row, width, height; + + ASSERT(dsRb); + ASSERT(stencilRb); + + ASSERT(dsRb->Format == MESA_FORMAT_Z24_S8); + ASSERT(dsRb->DataType == GL_UNSIGNED_INT_24_8_EXT); + ASSERT(stencilRb->Format == MESA_FORMAT_Z24_S8 || + stencilRb->Format == MESA_FORMAT_S8); + + ASSERT(dsRb->Width == stencilRb->Width); + ASSERT(dsRb->Height == stencilRb->Height); + + width = dsRb->Width; + height = dsRb->Height; + + for (row = 0; row < height; row++) { + GLuint depthStencil[MAX_WIDTH]; + + dsRb->GetRow(ctx, dsRb, width, 0, row, depthStencil); + + if (stencilRb->Format == MESA_FORMAT_S8) { + /* 8bpp stencil */ + GLubyte stencil[MAX_WIDTH]; + GLuint i; + stencilRb->GetRow(ctx, stencilRb, width, 0, row, stencil); + for (i = 0; i < width; i++) { + depthStencil[i] = (depthStencil[i] & 0xffffff00) | stencil[i]; + } + } + else { + /* 32bpp stencil buffer */ + GLuint stencil[MAX_WIDTH], i; + ASSERT(stencilRb->Format == MESA_FORMAT_Z24_S8); + ASSERT(stencilRb->DataType == GL_UNSIGNED_INT_24_8_EXT); + stencilRb->GetRow(ctx, stencilRb, width, 0, row, stencil); + for (i = 0; i < width; i++) { + depthStencil[i] + = (depthStencil[i] & 0xffffff00) | (stencil[i] & 0xff); + } + } + + dsRb->PutRow(ctx, dsRb, width, 0, row, depthStencil, NULL); + } +} + + +/** + * Convert the stencil buffer from 8bpp to 32bpp depth/stencil. + * \param stencilRb the stencil renderbuffer to promote + */ +void +_mesa_promote_stencil(struct gl_context *ctx, struct gl_renderbuffer *stencilRb) +{ + const GLsizei width = stencilRb->Width; + const GLsizei height = stencilRb->Height; + GLubyte *data; + GLint i, j, k; + + ASSERT(stencilRb->Format == MESA_FORMAT_S8); + ASSERT(stencilRb->Data); + + data = (GLubyte *) stencilRb->Data; + stencilRb->Data = NULL; + stencilRb->AllocStorage(ctx, stencilRb, GL_DEPTH24_STENCIL8_EXT, + width, height); + + ASSERT(stencilRb->DataType == GL_UNSIGNED_INT_24_8_EXT); + + k = 0; + for (i = 0; i < height; i++) { + GLuint depthStencil[MAX_WIDTH]; + for (j = 0; j < width; j++) { + depthStencil[j] = data[k++]; + } + stencilRb->PutRow(ctx, stencilRb, width, 0, i, depthStencil, NULL); + } + free(data); +} diff --git a/mesalib/src/mesa/main/dlist.c b/mesalib/src/mesa/main/dlist.c index 234fd8ee8..6e075b4e5 100644 --- a/mesalib/src/mesa/main/dlist.c +++ b/mesalib/src/mesa/main/dlist.c @@ -1,10790 +1,10790 @@ -/* - * Mesa 3-D graphics library - * Version: 7.7 - * - * Copyright (C) 1999-2008 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. - */ - - -/** - * \file dlist.c - * Display lists management functions. - */ - -#include "glheader.h" -#include "imports.h" -#include "api_arrayelt.h" -#include "api_exec.h" -#include "api_loopback.h" -#if FEATURE_ATI_fragment_shader -#include "atifragshader.h" -#endif -#include "config.h" -#include "mfeatures.h" -#if FEATURE_ARB_vertex_buffer_object -#include "bufferobj.h" -#endif -#include "arrayobj.h" -#include "context.h" -#include "dlist.h" -#include "enums.h" -#include "eval.h" -#include "framebuffer.h" -#include "glapi/glapi.h" -#include "hash.h" -#include "image.h" -#include "light.h" -#include "macros.h" -#include "pack.h" -#include "pbo.h" -#include "queryobj.h" -#include "samplerobj.h" -#include "shaderapi.h" -#include "syncobj.h" -#include "teximage.h" -#include "mtypes.h" -#include "varray.h" -#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program -#include "arbprogram.h" -#endif -#if FEATURE_NV_vertex_program || FEATURE_NV_fragment_program -#include "nvprogram.h" -#endif - -#include "math/m_matrix.h" - -#include "main/dispatch.h" - - - -/** - * Other parts of Mesa (such as the VBO module) can plug into the display - * list system. This structure describes new display list instructions. - */ -struct gl_list_instruction -{ - GLuint Size; - void (*Execute)( struct gl_context *ctx, void *data ); - void (*Destroy)( struct gl_context *ctx, void *data ); - void (*Print)( struct gl_context *ctx, void *data ); -}; - - -#define MAX_DLIST_EXT_OPCODES 16 - -/** - * Used by device drivers to hook new commands into display lists. - */ -struct gl_list_extensions -{ - struct gl_list_instruction Opcode[MAX_DLIST_EXT_OPCODES]; - GLuint NumOpcodes; -}; - - - -/** - * Flush vertices. - * - * \param ctx GL context. - * - * Checks if dd_function_table::SaveNeedFlush is marked to flush - * stored (save) vertices, and calls - * dd_function_table::SaveFlushVertices if so. - */ -#define SAVE_FLUSH_VERTICES(ctx) \ -do { \ - if (ctx->Driver.SaveNeedFlush) \ - ctx->Driver.SaveFlushVertices(ctx); \ -} while (0) - - -/** - * Macro to assert that the API call was made outside the - * glBegin()/glEnd() pair, with return value. - * - * \param ctx GL context. - * \param retval value to return value in case the assertion fails. - */ -#define ASSERT_OUTSIDE_SAVE_BEGIN_END_WITH_RETVAL(ctx, retval) \ -do { \ - if (ctx->Driver.CurrentSavePrimitive <= GL_POLYGON || \ - ctx->Driver.CurrentSavePrimitive == PRIM_INSIDE_UNKNOWN_PRIM) { \ - _mesa_compile_error( ctx, GL_INVALID_OPERATION, "begin/end" ); \ - return retval; \ - } \ -} while (0) - -/** - * Macro to assert that the API call was made outside the - * glBegin()/glEnd() pair. - * - * \param ctx GL context. - */ -#define ASSERT_OUTSIDE_SAVE_BEGIN_END(ctx) \ -do { \ - if (ctx->Driver.CurrentSavePrimitive <= GL_POLYGON || \ - ctx->Driver.CurrentSavePrimitive == PRIM_INSIDE_UNKNOWN_PRIM) { \ - _mesa_compile_error( ctx, GL_INVALID_OPERATION, "begin/end" ); \ - return; \ - } \ -} while (0) - -/** - * Macro to assert that the API call was made outside the - * glBegin()/glEnd() pair and flush the vertices. - * - * \param ctx GL context. - */ -#define ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx) \ -do { \ - ASSERT_OUTSIDE_SAVE_BEGIN_END(ctx); \ - SAVE_FLUSH_VERTICES(ctx); \ -} while (0) - -/** - * Macro to assert that the API call was made outside the - * glBegin()/glEnd() pair and flush the vertices, with return value. - * - * \param ctx GL context. - * \param retval value to return value in case the assertion fails. - */ -#define ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx, retval)\ -do { \ - ASSERT_OUTSIDE_SAVE_BEGIN_END_WITH_RETVAL(ctx, retval); \ - SAVE_FLUSH_VERTICES(ctx); \ -} while (0) - - - -/** - * Display list opcodes. - * - * The fact that these identifiers are assigned consecutive - * integer values starting at 0 is very important, see InstSize array usage) - */ -typedef enum -{ - OPCODE_INVALID = -1, /* Force signed enum */ - OPCODE_ACCUM, - OPCODE_ALPHA_FUNC, - OPCODE_BIND_TEXTURE, - OPCODE_BITMAP, - OPCODE_BLEND_COLOR, - OPCODE_BLEND_EQUATION, - OPCODE_BLEND_EQUATION_SEPARATE, - OPCODE_BLEND_FUNC_SEPARATE, - - OPCODE_BLEND_EQUATION_I, - OPCODE_BLEND_EQUATION_SEPARATE_I, - OPCODE_BLEND_FUNC_I, - OPCODE_BLEND_FUNC_SEPARATE_I, - - OPCODE_CALL_LIST, - OPCODE_CALL_LIST_OFFSET, - OPCODE_CLEAR, - OPCODE_CLEAR_ACCUM, - OPCODE_CLEAR_COLOR, - OPCODE_CLEAR_DEPTH, - OPCODE_CLEAR_INDEX, - OPCODE_CLEAR_STENCIL, - OPCODE_CLEAR_BUFFER_IV, - OPCODE_CLEAR_BUFFER_UIV, - OPCODE_CLEAR_BUFFER_FV, - OPCODE_CLEAR_BUFFER_FI, - OPCODE_CLIP_PLANE, - OPCODE_COLOR_MASK, - OPCODE_COLOR_MASK_INDEXED, - OPCODE_COLOR_MATERIAL, - OPCODE_COLOR_TABLE, - OPCODE_COLOR_TABLE_PARAMETER_FV, - OPCODE_COLOR_TABLE_PARAMETER_IV, - OPCODE_COLOR_SUB_TABLE, - OPCODE_CONVOLUTION_FILTER_1D, - OPCODE_CONVOLUTION_FILTER_2D, - OPCODE_CONVOLUTION_PARAMETER_I, - OPCODE_CONVOLUTION_PARAMETER_IV, - OPCODE_CONVOLUTION_PARAMETER_F, - OPCODE_CONVOLUTION_PARAMETER_FV, - OPCODE_COPY_COLOR_SUB_TABLE, - OPCODE_COPY_COLOR_TABLE, - OPCODE_COPY_PIXELS, - OPCODE_COPY_TEX_IMAGE1D, - OPCODE_COPY_TEX_IMAGE2D, - OPCODE_COPY_TEX_SUB_IMAGE1D, - OPCODE_COPY_TEX_SUB_IMAGE2D, - OPCODE_COPY_TEX_SUB_IMAGE3D, - OPCODE_CULL_FACE, - OPCODE_DEPTH_FUNC, - OPCODE_DEPTH_MASK, - OPCODE_DEPTH_RANGE, - OPCODE_DISABLE, - OPCODE_DISABLE_INDEXED, - OPCODE_DRAW_BUFFER, - OPCODE_DRAW_PIXELS, - OPCODE_ENABLE, - OPCODE_ENABLE_INDEXED, - OPCODE_EVALMESH1, - OPCODE_EVALMESH2, - OPCODE_FOG, - OPCODE_FRONT_FACE, - OPCODE_FRUSTUM, - OPCODE_HINT, - OPCODE_HISTOGRAM, - OPCODE_INDEX_MASK, - OPCODE_INIT_NAMES, - OPCODE_LIGHT, - OPCODE_LIGHT_MODEL, - OPCODE_LINE_STIPPLE, - OPCODE_LINE_WIDTH, - OPCODE_LIST_BASE, - OPCODE_LOAD_IDENTITY, - OPCODE_LOAD_MATRIX, - OPCODE_LOAD_NAME, - OPCODE_LOGIC_OP, - OPCODE_MAP1, - OPCODE_MAP2, - OPCODE_MAPGRID1, - OPCODE_MAPGRID2, - OPCODE_MATRIX_MODE, - OPCODE_MIN_MAX, - OPCODE_MULT_MATRIX, - OPCODE_ORTHO, - OPCODE_PASSTHROUGH, - OPCODE_PIXEL_MAP, - OPCODE_PIXEL_TRANSFER, - OPCODE_PIXEL_ZOOM, - OPCODE_POINT_SIZE, - OPCODE_POINT_PARAMETERS, - OPCODE_POLYGON_MODE, - OPCODE_POLYGON_STIPPLE, - OPCODE_POLYGON_OFFSET, - OPCODE_POP_ATTRIB, - OPCODE_POP_MATRIX, - OPCODE_POP_NAME, - OPCODE_PRIORITIZE_TEXTURE, - OPCODE_PUSH_ATTRIB, - OPCODE_PUSH_MATRIX, - OPCODE_PUSH_NAME, - OPCODE_RASTER_POS, - OPCODE_READ_BUFFER, - OPCODE_RESET_HISTOGRAM, - OPCODE_RESET_MIN_MAX, - OPCODE_ROTATE, - OPCODE_SCALE, - OPCODE_SCISSOR, - OPCODE_SELECT_TEXTURE_SGIS, - OPCODE_SELECT_TEXTURE_COORD_SET, - OPCODE_SHADE_MODEL, - OPCODE_STENCIL_FUNC, - OPCODE_STENCIL_MASK, - OPCODE_STENCIL_OP, - OPCODE_TEXENV, - OPCODE_TEXGEN, - OPCODE_TEXPARAMETER, - OPCODE_TEX_IMAGE1D, - OPCODE_TEX_IMAGE2D, - OPCODE_TEX_IMAGE3D, - OPCODE_TEX_SUB_IMAGE1D, - OPCODE_TEX_SUB_IMAGE2D, - OPCODE_TEX_SUB_IMAGE3D, - OPCODE_TRANSLATE, - OPCODE_VIEWPORT, - OPCODE_WINDOW_POS, - /* GL_ARB_multitexture */ - OPCODE_ACTIVE_TEXTURE, - /* GL_ARB_texture_compression */ - OPCODE_COMPRESSED_TEX_IMAGE_1D, - OPCODE_COMPRESSED_TEX_IMAGE_2D, - OPCODE_COMPRESSED_TEX_IMAGE_3D, - OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D, - OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D, - OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D, - /* GL_ARB_multisample */ - OPCODE_SAMPLE_COVERAGE, - /* GL_ARB_window_pos */ - OPCODE_WINDOW_POS_ARB, - /* GL_NV_vertex_program */ - OPCODE_BIND_PROGRAM_NV, - OPCODE_EXECUTE_PROGRAM_NV, - OPCODE_REQUEST_RESIDENT_PROGRAMS_NV, - OPCODE_LOAD_PROGRAM_NV, - OPCODE_TRACK_MATRIX_NV, - /* GL_NV_fragment_program */ - OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, - OPCODE_PROGRAM_NAMED_PARAMETER_NV, - /* GL_EXT_stencil_two_side */ - OPCODE_ACTIVE_STENCIL_FACE_EXT, - /* GL_EXT_depth_bounds_test */ - OPCODE_DEPTH_BOUNDS_EXT, - /* GL_ARB_vertex/fragment_program */ - OPCODE_PROGRAM_STRING_ARB, - OPCODE_PROGRAM_ENV_PARAMETER_ARB, - /* GL_ARB_occlusion_query */ - OPCODE_BEGIN_QUERY_ARB, - OPCODE_END_QUERY_ARB, - /* GL_ARB_draw_buffers */ - OPCODE_DRAW_BUFFERS_ARB, - /* GL_ATI_fragment_shader */ - OPCODE_TEX_BUMP_PARAMETER_ATI, - /* GL_ATI_fragment_shader */ - OPCODE_BIND_FRAGMENT_SHADER_ATI, - OPCODE_SET_FRAGMENT_SHADER_CONSTANTS_ATI, - /* OpenGL 2.0 */ - OPCODE_STENCIL_FUNC_SEPARATE, - OPCODE_STENCIL_OP_SEPARATE, - OPCODE_STENCIL_MASK_SEPARATE, - - /* GL_ARB_shader_objects */ - OPCODE_USE_PROGRAM, - OPCODE_UNIFORM_1F, - OPCODE_UNIFORM_2F, - OPCODE_UNIFORM_3F, - OPCODE_UNIFORM_4F, - OPCODE_UNIFORM_1FV, - OPCODE_UNIFORM_2FV, - OPCODE_UNIFORM_3FV, - OPCODE_UNIFORM_4FV, - OPCODE_UNIFORM_1I, - OPCODE_UNIFORM_2I, - OPCODE_UNIFORM_3I, - OPCODE_UNIFORM_4I, - OPCODE_UNIFORM_1IV, - OPCODE_UNIFORM_2IV, - OPCODE_UNIFORM_3IV, - OPCODE_UNIFORM_4IV, - OPCODE_UNIFORM_MATRIX22, - OPCODE_UNIFORM_MATRIX33, - OPCODE_UNIFORM_MATRIX44, - OPCODE_UNIFORM_MATRIX23, - OPCODE_UNIFORM_MATRIX32, - OPCODE_UNIFORM_MATRIX24, - OPCODE_UNIFORM_MATRIX42, - OPCODE_UNIFORM_MATRIX34, - OPCODE_UNIFORM_MATRIX43, - - /* OpenGL 3.0 */ - OPCODE_UNIFORM_1UI, - OPCODE_UNIFORM_2UI, - OPCODE_UNIFORM_3UI, - OPCODE_UNIFORM_4UI, - OPCODE_UNIFORM_1UIV, - OPCODE_UNIFORM_2UIV, - OPCODE_UNIFORM_3UIV, - OPCODE_UNIFORM_4UIV, - - /* GL_ARB_color_buffer_float */ - OPCODE_CLAMP_COLOR, - - /* GL_EXT_framebuffer_blit */ - OPCODE_BLIT_FRAMEBUFFER, - - /* Vertex attributes -- fallback for when optimized display - * list build isn't active. - */ - OPCODE_ATTR_1F_NV, - OPCODE_ATTR_2F_NV, - OPCODE_ATTR_3F_NV, - OPCODE_ATTR_4F_NV, - OPCODE_ATTR_1F_ARB, - OPCODE_ATTR_2F_ARB, - OPCODE_ATTR_3F_ARB, - OPCODE_ATTR_4F_ARB, - OPCODE_MATERIAL, - OPCODE_BEGIN, - OPCODE_END, - OPCODE_RECTF, - OPCODE_EVAL_C1, - OPCODE_EVAL_C2, - OPCODE_EVAL_P1, - OPCODE_EVAL_P2, - - /* GL_EXT_provoking_vertex */ - OPCODE_PROVOKING_VERTEX, - - /* GL_EXT_transform_feedback */ - OPCODE_BEGIN_TRANSFORM_FEEDBACK, - OPCODE_END_TRANSFORM_FEEDBACK, - OPCODE_BIND_TRANSFORM_FEEDBACK, - OPCODE_PAUSE_TRANSFORM_FEEDBACK, - OPCODE_RESUME_TRANSFORM_FEEDBACK, - OPCODE_DRAW_TRANSFORM_FEEDBACK, - - /* GL_EXT_texture_integer */ - OPCODE_CLEARCOLOR_I, - OPCODE_CLEARCOLOR_UI, - OPCODE_TEXPARAMETER_I, - OPCODE_TEXPARAMETER_UI, - - /* GL_EXT_separate_shader_objects */ - OPCODE_ACTIVE_PROGRAM_EXT, - OPCODE_USE_SHADER_PROGRAM_EXT, - - /* GL_ARB_instanced_arrays */ - OPCODE_VERTEX_ATTRIB_DIVISOR, - - /* GL_NV_texture_barrier */ - OPCODE_TEXTURE_BARRIER_NV, - - /* GL_ARB_sampler_object */ - OPCODE_BIND_SAMPLER, - OPCODE_SAMPLER_PARAMETERIV, - OPCODE_SAMPLER_PARAMETERFV, - OPCODE_SAMPLER_PARAMETERIIV, - OPCODE_SAMPLER_PARAMETERUIV, - - /* GL_ARB_geometry_shader4 */ - OPCODE_PROGRAM_PARAMETERI, - OPCODE_FRAMEBUFFER_TEXTURE, - OPCODE_FRAMEBUFFER_TEXTURE_FACE, - - /* GL_ARB_sync */ - OPCODE_WAIT_SYNC, - - /* The following three are meta instructions */ - OPCODE_ERROR, /* raise compiled-in error */ - OPCODE_CONTINUE, - OPCODE_END_OF_LIST, - OPCODE_EXT_0 -} OpCode; - - - -/** - * Display list node. - * - * Display list instructions are stored as sequences of "nodes". Nodes - * are allocated in blocks. Each block has BLOCK_SIZE nodes. Blocks - * are linked together with a pointer. - * - * Each instruction in the display list is stored as a sequence of - * contiguous nodes in memory. - * Each node is the union of a variety of data types. - */ -union gl_dlist_node -{ - OpCode opcode; - GLboolean b; - GLbitfield bf; - GLubyte ub; - GLshort s; - GLushort us; - GLint i; - GLuint ui; - GLenum e; - GLfloat f; - GLvoid *data; - void *next; /* If prev node's opcode==OPCODE_CONTINUE */ -}; - - -typedef union gl_dlist_node Node; - - -/** - * Used to store a 64-bit uint in a pair of "Nodes" for the sake of 32-bit - * environment. In 64-bit env, sizeof(Node)==8 anyway. - */ -union uint64_pair -{ - GLuint64 uint64; - GLuint uint32[2]; -}; - - -/** - * How many nodes to allocate at a time. - * - * \note Reduced now that we hold vertices etc. elsewhere. - */ -#define BLOCK_SIZE 256 - - - -/** - * Number of nodes of storage needed for each instruction. - * Sizes for dynamically allocated opcodes are stored in the context struct. - */ -static GLuint InstSize[OPCODE_END_OF_LIST + 1]; - - -#if FEATURE_dlist - - -void mesa_print_display_list(GLuint list); - - -/**********************************************************************/ -/***** Private *****/ -/**********************************************************************/ - - -/** - * Make an empty display list. This is used by glGenLists() to - * reserve display list IDs. - */ -static struct gl_display_list * -make_list(GLuint name, GLuint count) -{ - struct gl_display_list *dlist = CALLOC_STRUCT(gl_display_list); - dlist->Name = name; - dlist->Head = (Node *) malloc(sizeof(Node) * count); - dlist->Head[0].opcode = OPCODE_END_OF_LIST; - return dlist; -} - - -/** - * Lookup function to just encapsulate casting. - */ -static INLINE struct gl_display_list * -lookup_list(struct gl_context *ctx, GLuint list) -{ - return (struct gl_display_list *) - _mesa_HashLookup(ctx->Shared->DisplayList, list); -} - - -/** Is the given opcode an extension code? */ -static INLINE GLboolean -is_ext_opcode(OpCode opcode) -{ - return (opcode >= OPCODE_EXT_0); -} - - -/** Destroy an extended opcode instruction */ -static GLint -ext_opcode_destroy(struct gl_context *ctx, Node *node) -{ - const GLint i = node[0].opcode - OPCODE_EXT_0; - GLint step; - ctx->ListExt->Opcode[i].Destroy(ctx, &node[1]); - step = ctx->ListExt->Opcode[i].Size; - return step; -} - - -/** Execute an extended opcode instruction */ -static GLint -ext_opcode_execute(struct gl_context *ctx, Node *node) -{ - const GLint i = node[0].opcode - OPCODE_EXT_0; - GLint step; - ctx->ListExt->Opcode[i].Execute(ctx, &node[1]); - step = ctx->ListExt->Opcode[i].Size; - return step; -} - - -/** Print an extended opcode instruction */ -static GLint -ext_opcode_print(struct gl_context *ctx, Node *node) -{ - const GLint i = node[0].opcode - OPCODE_EXT_0; - GLint step; - ctx->ListExt->Opcode[i].Print(ctx, &node[1]); - step = ctx->ListExt->Opcode[i].Size; - return step; -} - - -/** - * Delete the named display list, but don't remove from hash table. - * \param dlist - display list pointer - */ -void -_mesa_delete_list(struct gl_context *ctx, struct gl_display_list *dlist) -{ - Node *n, *block; - GLboolean done; - - n = block = dlist->Head; - - done = block ? GL_FALSE : GL_TRUE; - while (!done) { - const OpCode opcode = n[0].opcode; - - /* check for extension opcodes first */ - if (is_ext_opcode(opcode)) { - n += ext_opcode_destroy(ctx, n); - } - else { - switch (opcode) { - /* for some commands, we need to free malloc'd memory */ - case OPCODE_MAP1: - free(n[6].data); - n += InstSize[n[0].opcode]; - break; - case OPCODE_MAP2: - free(n[10].data); - n += InstSize[n[0].opcode]; - break; - case OPCODE_DRAW_PIXELS: - free(n[5].data); - n += InstSize[n[0].opcode]; - break; - case OPCODE_BITMAP: - free(n[7].data); - n += InstSize[n[0].opcode]; - break; - case OPCODE_COLOR_TABLE: - free(n[6].data); - n += InstSize[n[0].opcode]; - break; - case OPCODE_COLOR_SUB_TABLE: - free(n[6].data); - n += InstSize[n[0].opcode]; - break; - case OPCODE_CONVOLUTION_FILTER_1D: - free(n[6].data); - n += InstSize[n[0].opcode]; - break; - case OPCODE_CONVOLUTION_FILTER_2D: - free(n[7].data); - n += InstSize[n[0].opcode]; - break; - case OPCODE_POLYGON_STIPPLE: - free(n[1].data); - n += InstSize[n[0].opcode]; - break; - case OPCODE_TEX_IMAGE1D: - free(n[8].data); - n += InstSize[n[0].opcode]; - break; - case OPCODE_TEX_IMAGE2D: - free(n[9].data); - n += InstSize[n[0].opcode]; - break; - case OPCODE_TEX_IMAGE3D: - free(n[10].data); - n += InstSize[n[0].opcode]; - break; - case OPCODE_TEX_SUB_IMAGE1D: - free(n[7].data); - n += InstSize[n[0].opcode]; - break; - case OPCODE_TEX_SUB_IMAGE2D: - free(n[9].data); - n += InstSize[n[0].opcode]; - break; - case OPCODE_TEX_SUB_IMAGE3D: - free(n[11].data); - n += InstSize[n[0].opcode]; - break; - case OPCODE_COMPRESSED_TEX_IMAGE_1D: - free(n[7].data); - n += InstSize[n[0].opcode]; - break; - case OPCODE_COMPRESSED_TEX_IMAGE_2D: - free(n[8].data); - n += InstSize[n[0].opcode]; - break; - case OPCODE_COMPRESSED_TEX_IMAGE_3D: - free(n[9].data); - n += InstSize[n[0].opcode]; - break; - case OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D: - free(n[7].data); - n += InstSize[n[0].opcode]; - break; - case OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D: - free(n[9].data); - n += InstSize[n[0].opcode]; - break; - case OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D: - free(n[11].data); - n += InstSize[n[0].opcode]; - break; -#if FEATURE_NV_vertex_program - case OPCODE_LOAD_PROGRAM_NV: - free(n[4].data); /* program string */ - n += InstSize[n[0].opcode]; - break; - case OPCODE_REQUEST_RESIDENT_PROGRAMS_NV: - free(n[2].data); /* array of program ids */ - n += InstSize[n[0].opcode]; - break; -#endif -#if FEATURE_NV_fragment_program - case OPCODE_PROGRAM_NAMED_PARAMETER_NV: - free(n[3].data); /* parameter name */ - n += InstSize[n[0].opcode]; - break; -#endif -#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program - case OPCODE_PROGRAM_STRING_ARB: - free(n[4].data); /* program string */ - n += InstSize[n[0].opcode]; - break; -#endif - case OPCODE_UNIFORM_1FV: - case OPCODE_UNIFORM_2FV: - case OPCODE_UNIFORM_3FV: - case OPCODE_UNIFORM_4FV: - case OPCODE_UNIFORM_1IV: - case OPCODE_UNIFORM_2IV: - case OPCODE_UNIFORM_3IV: - case OPCODE_UNIFORM_4IV: - case OPCODE_UNIFORM_1UIV: - case OPCODE_UNIFORM_2UIV: - case OPCODE_UNIFORM_3UIV: - case OPCODE_UNIFORM_4UIV: - free(n[3].data); - n += InstSize[n[0].opcode]; - break; - case OPCODE_UNIFORM_MATRIX22: - case OPCODE_UNIFORM_MATRIX33: - case OPCODE_UNIFORM_MATRIX44: - case OPCODE_UNIFORM_MATRIX24: - case OPCODE_UNIFORM_MATRIX42: - case OPCODE_UNIFORM_MATRIX23: - case OPCODE_UNIFORM_MATRIX32: - case OPCODE_UNIFORM_MATRIX34: - case OPCODE_UNIFORM_MATRIX43: - free(n[4].data); - n += InstSize[n[0].opcode]; - break; - - case OPCODE_CONTINUE: - n = (Node *) n[1].next; - free(block); - block = n; - break; - case OPCODE_END_OF_LIST: - free(block); - done = GL_TRUE; - break; - default: - /* Most frequent case */ - n += InstSize[n[0].opcode]; - break; - } - } - } - - free(dlist); -} - - -/** - * Destroy a display list and remove from hash table. - * \param list - display list number - */ -static void -destroy_list(struct gl_context *ctx, GLuint list) -{ - struct gl_display_list *dlist; - - if (list == 0) - return; - - dlist = lookup_list(ctx, list); - if (!dlist) - return; - - _mesa_delete_list(ctx, dlist); - _mesa_HashRemove(ctx->Shared->DisplayList, list); -} - - -/* - * Translate the nth element of list from to GLint. - */ -static GLint -translate_id(GLsizei n, GLenum type, const GLvoid * list) -{ - GLbyte *bptr; - GLubyte *ubptr; - GLshort *sptr; - GLushort *usptr; - GLint *iptr; - GLuint *uiptr; - GLfloat *fptr; - - switch (type) { - case GL_BYTE: - bptr = (GLbyte *) list; - return (GLint) bptr[n]; - case GL_UNSIGNED_BYTE: - ubptr = (GLubyte *) list; - return (GLint) ubptr[n]; - case GL_SHORT: - sptr = (GLshort *) list; - return (GLint) sptr[n]; - case GL_UNSIGNED_SHORT: - usptr = (GLushort *) list; - return (GLint) usptr[n]; - case GL_INT: - iptr = (GLint *) list; - return iptr[n]; - case GL_UNSIGNED_INT: - uiptr = (GLuint *) list; - return (GLint) uiptr[n]; - case GL_FLOAT: - fptr = (GLfloat *) list; - return (GLint) FLOORF(fptr[n]); - case GL_2_BYTES: - ubptr = ((GLubyte *) list) + 2 * n; - return (GLint) ubptr[0] * 256 - + (GLint) ubptr[1]; - case GL_3_BYTES: - ubptr = ((GLubyte *) list) + 3 * n; - return (GLint) ubptr[0] * 65536 - + (GLint) ubptr[1] * 256 - + (GLint) ubptr[2]; - case GL_4_BYTES: - ubptr = ((GLubyte *) list) + 4 * n; - return (GLint) ubptr[0] * 16777216 - + (GLint) ubptr[1] * 65536 - + (GLint) ubptr[2] * 256 - + (GLint) ubptr[3]; - default: - return 0; - } -} - - - - -/**********************************************************************/ -/***** Public *****/ -/**********************************************************************/ - -/** - * Wrapper for _mesa_unpack_image() that handles pixel buffer objects. - * If we run out of memory, GL_OUT_OF_MEMORY will be recorded. - */ -static GLvoid * -unpack_image(struct gl_context *ctx, GLuint dimensions, - GLsizei width, GLsizei height, GLsizei depth, - GLenum format, GLenum type, const GLvoid * pixels, - const struct gl_pixelstore_attrib *unpack) -{ - if (!_mesa_is_bufferobj(unpack->BufferObj)) { - /* no PBO */ - GLvoid *image = _mesa_unpack_image(dimensions, width, height, depth, - format, type, pixels, unpack); - if (pixels && !image) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "display list construction"); - } - return image; - } - else if (_mesa_validate_pbo_access(dimensions, unpack, width, height, - depth, format, type, INT_MAX, pixels)) { - const GLubyte *map, *src; - GLvoid *image; - - map = (GLubyte *) - ctx->Driver.MapBufferRange(ctx, 0, unpack->BufferObj->Size, - GL_MAP_READ_BIT, unpack->BufferObj); - if (!map) { - /* unable to map src buffer! */ - _mesa_error(ctx, GL_INVALID_OPERATION, "unable to map PBO"); - return NULL; - } - - src = ADD_POINTERS(map, pixels); - image = _mesa_unpack_image(dimensions, width, height, depth, - format, type, src, unpack); - - ctx->Driver.UnmapBuffer(ctx, unpack->BufferObj); - - if (!image) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "display list construction"); - } - return image; - } - /* bad access! */ - return NULL; -} - - -/** - * Allocate space for a display list instruction (opcode + payload space). - * \param opcode the instruction opcode (OPCODE_* value) - * \param bytes instruction payload size (not counting opcode) - * \return pointer to allocated memory (the opcode space) - */ -static Node * -dlist_alloc(struct gl_context *ctx, OpCode opcode, GLuint bytes) -{ - const GLuint numNodes = 1 + (bytes + sizeof(Node) - 1) / sizeof(Node); - Node *n; - - if (opcode < (GLuint) OPCODE_EXT_0) { - if (InstSize[opcode] == 0) { - /* save instruction size now */ - InstSize[opcode] = numNodes; - } - else { - /* make sure instruction size agrees */ - ASSERT(numNodes == InstSize[opcode]); - } - } - - if (ctx->ListState.CurrentPos + numNodes + 2 > BLOCK_SIZE) { - /* This block is full. Allocate a new block and chain to it */ - Node *newblock; - n = ctx->ListState.CurrentBlock + ctx->ListState.CurrentPos; - n[0].opcode = OPCODE_CONTINUE; - newblock = (Node *) malloc(sizeof(Node) * BLOCK_SIZE); - if (!newblock) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "Building display list"); - return NULL; - } - n[1].next = (Node *) newblock; - ctx->ListState.CurrentBlock = newblock; - ctx->ListState.CurrentPos = 0; - } - - n = ctx->ListState.CurrentBlock + ctx->ListState.CurrentPos; - ctx->ListState.CurrentPos += numNodes; - - n[0].opcode = opcode; - - return n; -} - - - -/** - * Allocate space for a display list instruction. Used by callers outside - * this file for things like VBO vertex data. - * - * \param opcode the instruction opcode (OPCODE_* value) - * \param bytes instruction size in bytes, not counting opcode. - * \return pointer to the usable data area (not including the internal - * opcode). - */ -void * -_mesa_dlist_alloc(struct gl_context *ctx, GLuint opcode, GLuint bytes) -{ - Node *n = dlist_alloc(ctx, (OpCode) opcode, bytes); - if (n) - return n + 1; /* return pointer to payload area, after opcode */ - else - return NULL; -} - - -/** - * This function allows modules and drivers to get their own opcodes - * for extending display list functionality. - * \param ctx the rendering context - * \param size number of bytes for storing the new display list command - * \param execute function to execute the new display list command - * \param destroy function to destroy the new display list command - * \param print function to print the new display list command - * \return the new opcode number or -1 if error - */ -GLint -_mesa_dlist_alloc_opcode(struct gl_context *ctx, - GLuint size, - void (*execute) (struct gl_context *, void *), - void (*destroy) (struct gl_context *, void *), - void (*print) (struct gl_context *, void *)) -{ - if (ctx->ListExt->NumOpcodes < MAX_DLIST_EXT_OPCODES) { - const GLuint i = ctx->ListExt->NumOpcodes++; - ctx->ListExt->Opcode[i].Size = - 1 + (size + sizeof(Node) - 1) / sizeof(Node); - ctx->ListExt->Opcode[i].Execute = execute; - ctx->ListExt->Opcode[i].Destroy = destroy; - ctx->ListExt->Opcode[i].Print = print; - return i + OPCODE_EXT_0; - } - return -1; -} - - -/** - * Allocate space for a display list instruction. The space is basically - * an array of Nodes where node[0] holds the opcode, node[1] is the first - * function parameter, node[2] is the second parameter, etc. - * - * \param opcode one of OPCODE_x - * \param nparams number of function parameters - * \return pointer to start of instruction space - */ -static INLINE Node * -alloc_instruction(struct gl_context *ctx, OpCode opcode, GLuint nparams) -{ - return dlist_alloc(ctx, opcode, nparams * sizeof(Node)); -} - - - -/* - * Display List compilation functions - */ -static void GLAPIENTRY -save_Accum(GLenum op, GLfloat value) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_ACCUM, 2); - if (n) { - n[1].e = op; - n[2].f = value; - } - if (ctx->ExecuteFlag) { - CALL_Accum(ctx->Exec, (op, value)); - } -} - - -static void GLAPIENTRY -save_AlphaFunc(GLenum func, GLclampf ref) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_ALPHA_FUNC, 2); - if (n) { - n[1].e = func; - n[2].f = (GLfloat) ref; - } - if (ctx->ExecuteFlag) { - CALL_AlphaFunc(ctx->Exec, (func, ref)); - } -} - - -static void GLAPIENTRY -save_BindTexture(GLenum target, GLuint texture) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_BIND_TEXTURE, 2); - if (n) { - n[1].e = target; - n[2].ui = texture; - } - if (ctx->ExecuteFlag) { - CALL_BindTexture(ctx->Exec, (target, texture)); - } -} - - -static void GLAPIENTRY -save_Bitmap(GLsizei width, GLsizei height, - GLfloat xorig, GLfloat yorig, - GLfloat xmove, GLfloat ymove, const GLubyte * pixels) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_BITMAP, 7); - if (n) { - n[1].i = (GLint) width; - n[2].i = (GLint) height; - n[3].f = xorig; - n[4].f = yorig; - n[5].f = xmove; - n[6].f = ymove; - n[7].data = _mesa_unpack_bitmap(width, height, pixels, &ctx->Unpack); - } - if (ctx->ExecuteFlag) { - CALL_Bitmap(ctx->Exec, (width, height, - xorig, yorig, xmove, ymove, pixels)); - } -} - - -static void GLAPIENTRY -save_BlendEquation(GLenum mode) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_BLEND_EQUATION, 1); - if (n) { - n[1].e = mode; - } - if (ctx->ExecuteFlag) { - CALL_BlendEquation(ctx->Exec, (mode)); - } -} - - -static void GLAPIENTRY -save_BlendEquationSeparateEXT(GLenum modeRGB, GLenum modeA) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_BLEND_EQUATION_SEPARATE, 2); - if (n) { - n[1].e = modeRGB; - n[2].e = modeA; - } - if (ctx->ExecuteFlag) { - CALL_BlendEquationSeparateEXT(ctx->Exec, (modeRGB, modeA)); - } -} - - -static void GLAPIENTRY -save_BlendFuncSeparateEXT(GLenum sfactorRGB, GLenum dfactorRGB, - GLenum sfactorA, GLenum dfactorA) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_BLEND_FUNC_SEPARATE, 4); - if (n) { - n[1].e = sfactorRGB; - n[2].e = dfactorRGB; - n[3].e = sfactorA; - n[4].e = dfactorA; - } - if (ctx->ExecuteFlag) { - CALL_BlendFuncSeparateEXT(ctx->Exec, - (sfactorRGB, dfactorRGB, sfactorA, dfactorA)); - } -} - - -static void GLAPIENTRY -save_BlendFunc(GLenum srcfactor, GLenum dstfactor) -{ - save_BlendFuncSeparateEXT(srcfactor, dstfactor, srcfactor, dstfactor); -} - - -static void GLAPIENTRY -save_BlendColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_BLEND_COLOR, 4); - if (n) { - n[1].f = red; - n[2].f = green; - n[3].f = blue; - n[4].f = alpha; - } - if (ctx->ExecuteFlag) { - CALL_BlendColor(ctx->Exec, (red, green, blue, alpha)); - } -} - -/* GL_ARB_draw_buffers_blend */ -static void GLAPIENTRY -save_BlendFuncSeparatei(GLuint buf, GLenum sfactorRGB, GLenum dfactorRGB, - GLenum sfactorA, GLenum dfactorA) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_BLEND_FUNC_SEPARATE_I, 5); - if (n) { - n[1].ui = buf; - n[2].e = sfactorRGB; - n[3].e = dfactorRGB; - n[4].e = sfactorA; - n[5].e = dfactorA; - } - if (ctx->ExecuteFlag) { - CALL_BlendFuncSeparateiARB(ctx->Exec, (buf, sfactorRGB, dfactorRGB, - sfactorA, dfactorA)); - } -} - -/* GL_ARB_draw_buffers_blend */ -static void GLAPIENTRY -save_BlendFunci(GLuint buf, GLenum sfactor, GLenum dfactor) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_BLEND_FUNC_SEPARATE_I, 3); - if (n) { - n[1].ui = buf; - n[2].e = sfactor; - n[3].e = dfactor; - } - if (ctx->ExecuteFlag) { - CALL_BlendFunciARB(ctx->Exec, (buf, sfactor, dfactor)); - } -} - -/* GL_ARB_draw_buffers_blend */ -static void GLAPIENTRY -save_BlendEquationi(GLuint buf, GLenum mode) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_BLEND_EQUATION_I, 2); - if (n) { - n[1].ui = buf; - n[2].e = mode; - } - if (ctx->ExecuteFlag) { - CALL_BlendEquationiARB(ctx->Exec, (buf, mode)); - } -} - -/* GL_ARB_draw_buffers_blend */ -static void GLAPIENTRY -save_BlendEquationSeparatei(GLuint buf, GLenum modeRGB, GLenum modeA) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_BLEND_EQUATION_SEPARATE_I, 3); - if (n) { - n[1].ui = buf; - n[2].e = modeRGB; - n[3].e = modeA; - } - if (ctx->ExecuteFlag) { - CALL_BlendEquationSeparateiARB(ctx->Exec, (buf, modeRGB, modeA)); - } -} - - -static void invalidate_saved_current_state( struct gl_context *ctx ) -{ - GLint i; - - for (i = 0; i < VERT_ATTRIB_MAX; i++) - ctx->ListState.ActiveAttribSize[i] = 0; - - for (i = 0; i < MAT_ATTRIB_MAX; i++) - ctx->ListState.ActiveMaterialSize[i] = 0; - - memset(&ctx->ListState.Current, 0, sizeof ctx->ListState.Current); - - ctx->Driver.CurrentSavePrimitive = PRIM_UNKNOWN; -} - -static void GLAPIENTRY -save_CallList(GLuint list) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - SAVE_FLUSH_VERTICES(ctx); - - n = alloc_instruction(ctx, OPCODE_CALL_LIST, 1); - if (n) { - n[1].ui = list; - } - - /* After this, we don't know what state we're in. Invalidate all - * cached information previously gathered: - */ - invalidate_saved_current_state( ctx ); - - if (ctx->ExecuteFlag) { - _mesa_CallList(list); - } -} - - -static void GLAPIENTRY -save_CallLists(GLsizei num, GLenum type, const GLvoid * lists) -{ - GET_CURRENT_CONTEXT(ctx); - GLint i; - GLboolean typeErrorFlag; - - SAVE_FLUSH_VERTICES(ctx); - - switch (type) { - case GL_BYTE: - case GL_UNSIGNED_BYTE: - case GL_SHORT: - case GL_UNSIGNED_SHORT: - case GL_INT: - case GL_UNSIGNED_INT: - case GL_FLOAT: - case GL_2_BYTES: - case GL_3_BYTES: - case GL_4_BYTES: - typeErrorFlag = GL_FALSE; - break; - default: - typeErrorFlag = GL_TRUE; - } - - for (i = 0; i < num; i++) { - GLint list = translate_id(i, type, lists); - Node *n = alloc_instruction(ctx, OPCODE_CALL_LIST_OFFSET, 2); - if (n) { - n[1].i = list; - n[2].b = typeErrorFlag; - } - } - - /* After this, we don't know what state we're in. Invalidate all - * cached information previously gathered: - */ - invalidate_saved_current_state( ctx ); - - if (ctx->ExecuteFlag) { - CALL_CallLists(ctx->Exec, (num, type, lists)); - } -} - - -static void GLAPIENTRY -save_Clear(GLbitfield mask) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_CLEAR, 1); - if (n) { - n[1].bf = mask; - } - if (ctx->ExecuteFlag) { - CALL_Clear(ctx->Exec, (mask)); - } -} - - -static void GLAPIENTRY -save_ClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint *value) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_CLEAR_BUFFER_IV, 6); - if (n) { - n[1].e = buffer; - n[2].i = drawbuffer; - n[3].i = value[0]; - if (buffer == GL_COLOR) { - n[4].i = value[1]; - n[5].i = value[2]; - n[6].i = value[3]; - } - else { - n[4].i = 0; - n[5].i = 0; - n[6].i = 0; - } - } - if (ctx->ExecuteFlag) { - /*CALL_ClearBufferiv(ctx->Exec, (buffer, drawbuffer, value));*/ - } -} - - -static void GLAPIENTRY -save_ClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint *value) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_CLEAR_BUFFER_UIV, 6); - if (n) { - n[1].e = buffer; - n[2].i = drawbuffer; - n[3].ui = value[0]; - if (buffer == GL_COLOR) { - n[4].ui = value[1]; - n[5].ui = value[2]; - n[6].ui = value[3]; - } - else { - n[4].ui = 0; - n[5].ui = 0; - n[6].ui = 0; - } - } - if (ctx->ExecuteFlag) { - /*CALL_ClearBufferuiv(ctx->Exec, (buffer, drawbuffer, value));*/ - } -} - - -static void GLAPIENTRY -save_ClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat *value) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_CLEAR_BUFFER_FV, 6); - if (n) { - n[1].e = buffer; - n[2].i = drawbuffer; - n[3].f = value[0]; - if (buffer == GL_COLOR) { - n[4].f = value[1]; - n[5].f = value[2]; - n[6].f = value[3]; - } - else { - n[4].f = 0.0F; - n[5].f = 0.0F; - n[6].f = 0.0F; - } - } - if (ctx->ExecuteFlag) { - /*CALL_ClearBufferuiv(ctx->Exec, (buffer, drawbuffer, value));*/ - } -} - - -static void GLAPIENTRY -save_ClearBufferfi(GLenum buffer, GLint drawbuffer, - GLfloat depth, GLint stencil) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_CLEAR_BUFFER_FI, 4); - if (n) { - n[1].e = buffer; - n[2].i = drawbuffer; - n[3].f = depth; - n[4].i = stencil; - } - if (ctx->ExecuteFlag) { - /*CALL_ClearBufferfi(ctx->Exec, (buffer, drawbuffer, depth, stencil));*/ - } -} - - -static void GLAPIENTRY -save_ClearAccum(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_CLEAR_ACCUM, 4); - if (n) { - n[1].f = red; - n[2].f = green; - n[3].f = blue; - n[4].f = alpha; - } - if (ctx->ExecuteFlag) { - CALL_ClearAccum(ctx->Exec, (red, green, blue, alpha)); - } -} - - -static void GLAPIENTRY -save_ClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_CLEAR_COLOR, 4); - if (n) { - n[1].f = red; - n[2].f = green; - n[3].f = blue; - n[4].f = alpha; - } - if (ctx->ExecuteFlag) { - CALL_ClearColor(ctx->Exec, (red, green, blue, alpha)); - } -} - - -static void GLAPIENTRY -save_ClearDepth(GLclampd depth) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_CLEAR_DEPTH, 1); - if (n) { - n[1].f = (GLfloat) depth; - } - if (ctx->ExecuteFlag) { - CALL_ClearDepth(ctx->Exec, (depth)); - } -} - - -static void GLAPIENTRY -save_ClearIndex(GLfloat c) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_CLEAR_INDEX, 1); - if (n) { - n[1].f = c; - } - if (ctx->ExecuteFlag) { - CALL_ClearIndex(ctx->Exec, (c)); - } -} - - -static void GLAPIENTRY -save_ClearStencil(GLint s) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_CLEAR_STENCIL, 1); - if (n) { - n[1].i = s; - } - if (ctx->ExecuteFlag) { - CALL_ClearStencil(ctx->Exec, (s)); - } -} - - -static void GLAPIENTRY -save_ClipPlane(GLenum plane, const GLdouble * equ) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_CLIP_PLANE, 5); - if (n) { - n[1].e = plane; - n[2].f = (GLfloat) equ[0]; - n[3].f = (GLfloat) equ[1]; - n[4].f = (GLfloat) equ[2]; - n[5].f = (GLfloat) equ[3]; - } - if (ctx->ExecuteFlag) { - CALL_ClipPlane(ctx->Exec, (plane, equ)); - } -} - - - -static void GLAPIENTRY -save_ColorMask(GLboolean red, GLboolean green, - GLboolean blue, GLboolean alpha) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_COLOR_MASK, 4); - if (n) { - n[1].b = red; - n[2].b = green; - n[3].b = blue; - n[4].b = alpha; - } - if (ctx->ExecuteFlag) { - CALL_ColorMask(ctx->Exec, (red, green, blue, alpha)); - } -} - - -static void GLAPIENTRY -save_ColorMaskIndexed(GLuint buf, GLboolean red, GLboolean green, - GLboolean blue, GLboolean alpha) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_COLOR_MASK_INDEXED, 5); - if (n) { - n[1].ui = buf; - n[2].b = red; - n[3].b = green; - n[4].b = blue; - n[5].b = alpha; - } - if (ctx->ExecuteFlag) { - /*CALL_ColorMaskIndexedEXT(ctx->Exec, (buf, red, green, blue, alpha));*/ - } -} - - -static void GLAPIENTRY -save_ColorMaterial(GLenum face, GLenum mode) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - - n = alloc_instruction(ctx, OPCODE_COLOR_MATERIAL, 2); - if (n) { - n[1].e = face; - n[2].e = mode; - } - if (ctx->ExecuteFlag) { - CALL_ColorMaterial(ctx->Exec, (face, mode)); - } -} - - -static void GLAPIENTRY -save_ColorTable(GLenum target, GLenum internalFormat, - GLsizei width, GLenum format, GLenum type, - const GLvoid * table) -{ - GET_CURRENT_CONTEXT(ctx); - if (_mesa_is_proxy_texture(target)) { - /* execute immediately */ - CALL_ColorTable(ctx->Exec, (target, internalFormat, width, - format, type, table)); - } - else { - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_COLOR_TABLE, 6); - if (n) { - n[1].e = target; - n[2].e = internalFormat; - n[3].i = width; - n[4].e = format; - n[5].e = type; - n[6].data = unpack_image(ctx, 1, width, 1, 1, format, type, table, - &ctx->Unpack); - } - if (ctx->ExecuteFlag) { - CALL_ColorTable(ctx->Exec, (target, internalFormat, width, - format, type, table)); - } - } -} - - - -static void GLAPIENTRY -save_ColorTableParameterfv(GLenum target, GLenum pname, - const GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - - n = alloc_instruction(ctx, OPCODE_COLOR_TABLE_PARAMETER_FV, 6); - if (n) { - n[1].e = target; - n[2].e = pname; - n[3].f = params[0]; - if (pname == GL_COLOR_TABLE_SGI || - pname == GL_POST_CONVOLUTION_COLOR_TABLE_SGI || - pname == GL_TEXTURE_COLOR_TABLE_SGI) { - n[4].f = params[1]; - n[5].f = params[2]; - n[6].f = params[3]; - } - } - - if (ctx->ExecuteFlag) { - CALL_ColorTableParameterfv(ctx->Exec, (target, pname, params)); - } -} - - -static void GLAPIENTRY -save_ColorTableParameteriv(GLenum target, GLenum pname, const GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - - n = alloc_instruction(ctx, OPCODE_COLOR_TABLE_PARAMETER_IV, 6); - if (n) { - n[1].e = target; - n[2].e = pname; - n[3].i = params[0]; - if (pname == GL_COLOR_TABLE_SGI || - pname == GL_POST_CONVOLUTION_COLOR_TABLE_SGI || - pname == GL_TEXTURE_COLOR_TABLE_SGI) { - n[4].i = params[1]; - n[5].i = params[2]; - n[6].i = params[3]; - } - } - - if (ctx->ExecuteFlag) { - CALL_ColorTableParameteriv(ctx->Exec, (target, pname, params)); - } -} - - - -static void GLAPIENTRY -save_ColorSubTable(GLenum target, GLsizei start, GLsizei count, - GLenum format, GLenum type, const GLvoid * table) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_COLOR_SUB_TABLE, 6); - if (n) { - n[1].e = target; - n[2].i = start; - n[3].i = count; - n[4].e = format; - n[5].e = type; - n[6].data = unpack_image(ctx, 1, count, 1, 1, format, type, table, - &ctx->Unpack); - } - if (ctx->ExecuteFlag) { - CALL_ColorSubTable(ctx->Exec, - (target, start, count, format, type, table)); - } -} - - -static void GLAPIENTRY -save_CopyColorSubTable(GLenum target, GLsizei start, - GLint x, GLint y, GLsizei width) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_COPY_COLOR_SUB_TABLE, 5); - if (n) { - n[1].e = target; - n[2].i = start; - n[3].i = x; - n[4].i = y; - n[5].i = width; - } - if (ctx->ExecuteFlag) { - CALL_CopyColorSubTable(ctx->Exec, (target, start, x, y, width)); - } -} - - -static void GLAPIENTRY -save_CopyColorTable(GLenum target, GLenum internalformat, - GLint x, GLint y, GLsizei width) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_COPY_COLOR_TABLE, 5); - if (n) { - n[1].e = target; - n[2].e = internalformat; - n[3].i = x; - n[4].i = y; - n[5].i = width; - } - if (ctx->ExecuteFlag) { - CALL_CopyColorTable(ctx->Exec, (target, internalformat, x, y, width)); - } -} - - -static void GLAPIENTRY -save_ConvolutionFilter1D(GLenum target, GLenum internalFormat, GLsizei width, - GLenum format, GLenum type, const GLvoid * filter) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - - n = alloc_instruction(ctx, OPCODE_CONVOLUTION_FILTER_1D, 6); - if (n) { - n[1].e = target; - n[2].e = internalFormat; - n[3].i = width; - n[4].e = format; - n[5].e = type; - n[6].data = unpack_image(ctx, 1, width, 1, 1, format, type, filter, - &ctx->Unpack); - } - if (ctx->ExecuteFlag) { - CALL_ConvolutionFilter1D(ctx->Exec, (target, internalFormat, width, - format, type, filter)); - } -} - - -static void GLAPIENTRY -save_ConvolutionFilter2D(GLenum target, GLenum internalFormat, - GLsizei width, GLsizei height, GLenum format, - GLenum type, const GLvoid * filter) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - - n = alloc_instruction(ctx, OPCODE_CONVOLUTION_FILTER_2D, 7); - if (n) { - n[1].e = target; - n[2].e = internalFormat; - n[3].i = width; - n[4].i = height; - n[5].e = format; - n[6].e = type; - n[7].data = unpack_image(ctx, 2, width, height, 1, format, type, filter, - &ctx->Unpack); - } - if (ctx->ExecuteFlag) { - CALL_ConvolutionFilter2D(ctx->Exec, - (target, internalFormat, width, height, format, - type, filter)); - } -} - - -static void GLAPIENTRY -save_ConvolutionParameteri(GLenum target, GLenum pname, GLint param) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_CONVOLUTION_PARAMETER_I, 3); - if (n) { - n[1].e = target; - n[2].e = pname; - n[3].i = param; - } - if (ctx->ExecuteFlag) { - CALL_ConvolutionParameteri(ctx->Exec, (target, pname, param)); - } -} - - -static void GLAPIENTRY -save_ConvolutionParameteriv(GLenum target, GLenum pname, const GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_CONVOLUTION_PARAMETER_IV, 6); - if (n) { - n[1].e = target; - n[2].e = pname; - n[3].i = params[0]; - if (pname == GL_CONVOLUTION_BORDER_COLOR || - pname == GL_CONVOLUTION_FILTER_SCALE || - pname == GL_CONVOLUTION_FILTER_BIAS) { - n[4].i = params[1]; - n[5].i = params[2]; - n[6].i = params[3]; - } - else { - n[4].i = n[5].i = n[6].i = 0; - } - } - if (ctx->ExecuteFlag) { - CALL_ConvolutionParameteriv(ctx->Exec, (target, pname, params)); - } -} - - -static void GLAPIENTRY -save_ConvolutionParameterf(GLenum target, GLenum pname, GLfloat param) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_CONVOLUTION_PARAMETER_F, 3); - if (n) { - n[1].e = target; - n[2].e = pname; - n[3].f = param; - } - if (ctx->ExecuteFlag) { - CALL_ConvolutionParameterf(ctx->Exec, (target, pname, param)); - } -} - - -static void GLAPIENTRY -save_ConvolutionParameterfv(GLenum target, GLenum pname, - const GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_CONVOLUTION_PARAMETER_FV, 6); - if (n) { - n[1].e = target; - n[2].e = pname; - n[3].f = params[0]; - if (pname == GL_CONVOLUTION_BORDER_COLOR || - pname == GL_CONVOLUTION_FILTER_SCALE || - pname == GL_CONVOLUTION_FILTER_BIAS) { - n[4].f = params[1]; - n[5].f = params[2]; - n[6].f = params[3]; - } - else { - n[4].f = n[5].f = n[6].f = 0.0F; - } - } - if (ctx->ExecuteFlag) { - CALL_ConvolutionParameterfv(ctx->Exec, (target, pname, params)); - } -} - - -static void GLAPIENTRY -save_CopyPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_COPY_PIXELS, 5); - if (n) { - n[1].i = x; - n[2].i = y; - n[3].i = (GLint) width; - n[4].i = (GLint) height; - n[5].e = type; - } - if (ctx->ExecuteFlag) { - CALL_CopyPixels(ctx->Exec, (x, y, width, height, type)); - } -} - - - -static void GLAPIENTRY -save_CopyTexImage1D(GLenum target, GLint level, GLenum internalformat, - GLint x, GLint y, GLsizei width, GLint border) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_COPY_TEX_IMAGE1D, 7); - if (n) { - n[1].e = target; - n[2].i = level; - n[3].e = internalformat; - n[4].i = x; - n[5].i = y; - n[6].i = width; - n[7].i = border; - } - if (ctx->ExecuteFlag) { - CALL_CopyTexImage1D(ctx->Exec, (target, level, internalformat, - x, y, width, border)); - } -} - - -static void GLAPIENTRY -save_CopyTexImage2D(GLenum target, GLint level, - GLenum internalformat, - GLint x, GLint y, GLsizei width, - GLsizei height, GLint border) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_COPY_TEX_IMAGE2D, 8); - if (n) { - n[1].e = target; - n[2].i = level; - n[3].e = internalformat; - n[4].i = x; - n[5].i = y; - n[6].i = width; - n[7].i = height; - n[8].i = border; - } - if (ctx->ExecuteFlag) { - CALL_CopyTexImage2D(ctx->Exec, (target, level, internalformat, - x, y, width, height, border)); - } -} - - - -static void GLAPIENTRY -save_CopyTexSubImage1D(GLenum target, GLint level, - GLint xoffset, GLint x, GLint y, GLsizei width) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_COPY_TEX_SUB_IMAGE1D, 6); - if (n) { - n[1].e = target; - n[2].i = level; - n[3].i = xoffset; - n[4].i = x; - n[5].i = y; - n[6].i = width; - } - if (ctx->ExecuteFlag) { - CALL_CopyTexSubImage1D(ctx->Exec, - (target, level, xoffset, x, y, width)); - } -} - - -static void GLAPIENTRY -save_CopyTexSubImage2D(GLenum target, GLint level, - GLint xoffset, GLint yoffset, - GLint x, GLint y, GLsizei width, GLint height) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_COPY_TEX_SUB_IMAGE2D, 8); - if (n) { - n[1].e = target; - n[2].i = level; - n[3].i = xoffset; - n[4].i = yoffset; - n[5].i = x; - n[6].i = y; - n[7].i = width; - n[8].i = height; - } - if (ctx->ExecuteFlag) { - CALL_CopyTexSubImage2D(ctx->Exec, (target, level, xoffset, yoffset, - x, y, width, height)); - } -} - - -static void GLAPIENTRY -save_CopyTexSubImage3D(GLenum target, GLint level, - GLint xoffset, GLint yoffset, GLint zoffset, - GLint x, GLint y, GLsizei width, GLint height) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_COPY_TEX_SUB_IMAGE3D, 9); - if (n) { - n[1].e = target; - n[2].i = level; - n[3].i = xoffset; - n[4].i = yoffset; - n[5].i = zoffset; - n[6].i = x; - n[7].i = y; - n[8].i = width; - n[9].i = height; - } - if (ctx->ExecuteFlag) { - CALL_CopyTexSubImage3D(ctx->Exec, (target, level, - xoffset, yoffset, zoffset, - x, y, width, height)); - } -} - - -static void GLAPIENTRY -save_CullFace(GLenum mode) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_CULL_FACE, 1); - if (n) { - n[1].e = mode; - } - if (ctx->ExecuteFlag) { - CALL_CullFace(ctx->Exec, (mode)); - } -} - - -static void GLAPIENTRY -save_DepthFunc(GLenum func) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_DEPTH_FUNC, 1); - if (n) { - n[1].e = func; - } - if (ctx->ExecuteFlag) { - CALL_DepthFunc(ctx->Exec, (func)); - } -} - - -static void GLAPIENTRY -save_DepthMask(GLboolean mask) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_DEPTH_MASK, 1); - if (n) { - n[1].b = mask; - } - if (ctx->ExecuteFlag) { - CALL_DepthMask(ctx->Exec, (mask)); - } -} - - -static void GLAPIENTRY -save_DepthRange(GLclampd nearval, GLclampd farval) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_DEPTH_RANGE, 2); - if (n) { - n[1].f = (GLfloat) nearval; - n[2].f = (GLfloat) farval; - } - if (ctx->ExecuteFlag) { - CALL_DepthRange(ctx->Exec, (nearval, farval)); - } -} - - -static void GLAPIENTRY -save_Disable(GLenum cap) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_DISABLE, 1); - if (n) { - n[1].e = cap; - } - if (ctx->ExecuteFlag) { - CALL_Disable(ctx->Exec, (cap)); - } -} - - -static void GLAPIENTRY -save_DisableIndexed(GLuint index, GLenum cap) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_DISABLE_INDEXED, 2); - if (n) { - n[1].ui = index; - n[2].e = cap; - } - if (ctx->ExecuteFlag) { - CALL_DisableIndexedEXT(ctx->Exec, (index, cap)); - } -} - - -static void GLAPIENTRY -save_DrawBuffer(GLenum mode) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_DRAW_BUFFER, 1); - if (n) { - n[1].e = mode; - } - if (ctx->ExecuteFlag) { - CALL_DrawBuffer(ctx->Exec, (mode)); - } -} - - -static void GLAPIENTRY -save_DrawPixels(GLsizei width, GLsizei height, - GLenum format, GLenum type, const GLvoid * pixels) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - - n = alloc_instruction(ctx, OPCODE_DRAW_PIXELS, 5); - if (n) { - n[1].i = width; - n[2].i = height; - n[3].e = format; - n[4].e = type; - n[5].data = unpack_image(ctx, 2, width, height, 1, format, type, - pixels, &ctx->Unpack); - } - if (ctx->ExecuteFlag) { - CALL_DrawPixels(ctx->Exec, (width, height, format, type, pixels)); - } -} - - - -static void GLAPIENTRY -save_Enable(GLenum cap) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_ENABLE, 1); - if (n) { - n[1].e = cap; - } - if (ctx->ExecuteFlag) { - CALL_Enable(ctx->Exec, (cap)); - } -} - - - -static void GLAPIENTRY -save_EnableIndexed(GLuint index, GLenum cap) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_ENABLE_INDEXED, 2); - if (n) { - n[1].ui = index; - n[2].e = cap; - } - if (ctx->ExecuteFlag) { - CALL_EnableIndexedEXT(ctx->Exec, (index, cap)); - } -} - - - -static void GLAPIENTRY -save_EvalMesh1(GLenum mode, GLint i1, GLint i2) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_EVALMESH1, 3); - if (n) { - n[1].e = mode; - n[2].i = i1; - n[3].i = i2; - } - if (ctx->ExecuteFlag) { - CALL_EvalMesh1(ctx->Exec, (mode, i1, i2)); - } -} - - -static void GLAPIENTRY -save_EvalMesh2(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_EVALMESH2, 5); - if (n) { - n[1].e = mode; - n[2].i = i1; - n[3].i = i2; - n[4].i = j1; - n[5].i = j2; - } - if (ctx->ExecuteFlag) { - CALL_EvalMesh2(ctx->Exec, (mode, i1, i2, j1, j2)); - } -} - - - - -static void GLAPIENTRY -save_Fogfv(GLenum pname, const GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_FOG, 5); - if (n) { - n[1].e = pname; - n[2].f = params[0]; - n[3].f = params[1]; - n[4].f = params[2]; - n[5].f = params[3]; - } - if (ctx->ExecuteFlag) { - CALL_Fogfv(ctx->Exec, (pname, params)); - } -} - - -static void GLAPIENTRY -save_Fogf(GLenum pname, GLfloat param) -{ - GLfloat parray[4]; - parray[0] = param; - parray[1] = parray[2] = parray[3] = 0.0F; - save_Fogfv(pname, parray); -} - - -static void GLAPIENTRY -save_Fogiv(GLenum pname, const GLint *params) -{ - GLfloat p[4]; - switch (pname) { - case GL_FOG_MODE: - case GL_FOG_DENSITY: - case GL_FOG_START: - case GL_FOG_END: - case GL_FOG_INDEX: - p[0] = (GLfloat) *params; - p[1] = 0.0f; - p[2] = 0.0f; - p[3] = 0.0f; - break; - case GL_FOG_COLOR: - p[0] = INT_TO_FLOAT(params[0]); - p[1] = INT_TO_FLOAT(params[1]); - p[2] = INT_TO_FLOAT(params[2]); - p[3] = INT_TO_FLOAT(params[3]); - break; - default: - /* Error will be caught later in gl_Fogfv */ - ASSIGN_4V(p, 0.0F, 0.0F, 0.0F, 0.0F); - } - save_Fogfv(pname, p); -} - - -static void GLAPIENTRY -save_Fogi(GLenum pname, GLint param) -{ - GLint parray[4]; - parray[0] = param; - parray[1] = parray[2] = parray[3] = 0; - save_Fogiv(pname, parray); -} - - -static void GLAPIENTRY -save_FrontFace(GLenum mode) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_FRONT_FACE, 1); - if (n) { - n[1].e = mode; - } - if (ctx->ExecuteFlag) { - CALL_FrontFace(ctx->Exec, (mode)); - } -} - - -static void GLAPIENTRY -save_Frustum(GLdouble left, GLdouble right, - GLdouble bottom, GLdouble top, GLdouble nearval, GLdouble farval) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_FRUSTUM, 6); - if (n) { - n[1].f = (GLfloat) left; - n[2].f = (GLfloat) right; - n[3].f = (GLfloat) bottom; - n[4].f = (GLfloat) top; - n[5].f = (GLfloat) nearval; - n[6].f = (GLfloat) farval; - } - if (ctx->ExecuteFlag) { - CALL_Frustum(ctx->Exec, (left, right, bottom, top, nearval, farval)); - } -} - - -static void GLAPIENTRY -save_Hint(GLenum target, GLenum mode) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_HINT, 2); - if (n) { - n[1].e = target; - n[2].e = mode; - } - if (ctx->ExecuteFlag) { - CALL_Hint(ctx->Exec, (target, mode)); - } -} - - -static void GLAPIENTRY -save_Histogram(GLenum target, GLsizei width, GLenum internalFormat, - GLboolean sink) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_HISTOGRAM, 4); - if (n) { - n[1].e = target; - n[2].i = width; - n[3].e = internalFormat; - n[4].b = sink; - } - if (ctx->ExecuteFlag) { - CALL_Histogram(ctx->Exec, (target, width, internalFormat, sink)); - } -} - - -static void GLAPIENTRY -save_IndexMask(GLuint mask) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_INDEX_MASK, 1); - if (n) { - n[1].ui = mask; - } - if (ctx->ExecuteFlag) { - CALL_IndexMask(ctx->Exec, (mask)); - } -} - - -static void GLAPIENTRY -save_InitNames(void) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - (void) alloc_instruction(ctx, OPCODE_INIT_NAMES, 0); - if (ctx->ExecuteFlag) { - CALL_InitNames(ctx->Exec, ()); - } -} - - -static void GLAPIENTRY -save_Lightfv(GLenum light, GLenum pname, const GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_LIGHT, 6); - if (n) { - GLint i, nParams; - n[1].e = light; - n[2].e = pname; - switch (pname) { - case GL_AMBIENT: - nParams = 4; - break; - case GL_DIFFUSE: - nParams = 4; - break; - case GL_SPECULAR: - nParams = 4; - break; - case GL_POSITION: - nParams = 4; - break; - case GL_SPOT_DIRECTION: - nParams = 3; - break; - case GL_SPOT_EXPONENT: - nParams = 1; - break; - case GL_SPOT_CUTOFF: - nParams = 1; - break; - case GL_CONSTANT_ATTENUATION: - nParams = 1; - break; - case GL_LINEAR_ATTENUATION: - nParams = 1; - break; - case GL_QUADRATIC_ATTENUATION: - nParams = 1; - break; - default: - nParams = 0; - } - for (i = 0; i < nParams; i++) { - n[3 + i].f = params[i]; - } - } - if (ctx->ExecuteFlag) { - CALL_Lightfv(ctx->Exec, (light, pname, params)); - } -} - - -static void GLAPIENTRY -save_Lightf(GLenum light, GLenum pname, GLfloat param) -{ - GLfloat parray[4]; - parray[0] = param; - parray[1] = parray[2] = parray[3] = 0.0F; - save_Lightfv(light, pname, parray); -} - - -static void GLAPIENTRY -save_Lightiv(GLenum light, GLenum pname, const GLint *params) -{ - GLfloat fparam[4]; - switch (pname) { - case GL_AMBIENT: - case GL_DIFFUSE: - case GL_SPECULAR: - fparam[0] = INT_TO_FLOAT(params[0]); - fparam[1] = INT_TO_FLOAT(params[1]); - fparam[2] = INT_TO_FLOAT(params[2]); - fparam[3] = INT_TO_FLOAT(params[3]); - break; - case GL_POSITION: - fparam[0] = (GLfloat) params[0]; - fparam[1] = (GLfloat) params[1]; - fparam[2] = (GLfloat) params[2]; - fparam[3] = (GLfloat) params[3]; - break; - case GL_SPOT_DIRECTION: - fparam[0] = (GLfloat) params[0]; - fparam[1] = (GLfloat) params[1]; - fparam[2] = (GLfloat) params[2]; - break; - case GL_SPOT_EXPONENT: - case GL_SPOT_CUTOFF: - case GL_CONSTANT_ATTENUATION: - case GL_LINEAR_ATTENUATION: - case GL_QUADRATIC_ATTENUATION: - fparam[0] = (GLfloat) params[0]; - break; - default: - /* error will be caught later in gl_Lightfv */ - ; - } - save_Lightfv(light, pname, fparam); -} - - -static void GLAPIENTRY -save_Lighti(GLenum light, GLenum pname, GLint param) -{ - GLint parray[4]; - parray[0] = param; - parray[1] = parray[2] = parray[3] = 0; - save_Lightiv(light, pname, parray); -} - - -static void GLAPIENTRY -save_LightModelfv(GLenum pname, const GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_LIGHT_MODEL, 5); - if (n) { - n[1].e = pname; - n[2].f = params[0]; - n[3].f = params[1]; - n[4].f = params[2]; - n[5].f = params[3]; - } - if (ctx->ExecuteFlag) { - CALL_LightModelfv(ctx->Exec, (pname, params)); - } -} - - -static void GLAPIENTRY -save_LightModelf(GLenum pname, GLfloat param) -{ - GLfloat parray[4]; - parray[0] = param; - parray[1] = parray[2] = parray[3] = 0.0F; - save_LightModelfv(pname, parray); -} - - -static void GLAPIENTRY -save_LightModeliv(GLenum pname, const GLint *params) -{ - GLfloat fparam[4]; - switch (pname) { - case GL_LIGHT_MODEL_AMBIENT: - fparam[0] = INT_TO_FLOAT(params[0]); - fparam[1] = INT_TO_FLOAT(params[1]); - fparam[2] = INT_TO_FLOAT(params[2]); - fparam[3] = INT_TO_FLOAT(params[3]); - break; - case GL_LIGHT_MODEL_LOCAL_VIEWER: - case GL_LIGHT_MODEL_TWO_SIDE: - case GL_LIGHT_MODEL_COLOR_CONTROL: - fparam[0] = (GLfloat) params[0]; - fparam[1] = 0.0F; - fparam[2] = 0.0F; - fparam[3] = 0.0F; - break; - default: - /* Error will be caught later in gl_LightModelfv */ - ASSIGN_4V(fparam, 0.0F, 0.0F, 0.0F, 0.0F); - } - save_LightModelfv(pname, fparam); -} - - -static void GLAPIENTRY -save_LightModeli(GLenum pname, GLint param) -{ - GLint parray[4]; - parray[0] = param; - parray[1] = parray[2] = parray[3] = 0; - save_LightModeliv(pname, parray); -} - - -static void GLAPIENTRY -save_LineStipple(GLint factor, GLushort pattern) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_LINE_STIPPLE, 2); - if (n) { - n[1].i = factor; - n[2].us = pattern; - } - if (ctx->ExecuteFlag) { - CALL_LineStipple(ctx->Exec, (factor, pattern)); - } -} - - -static void GLAPIENTRY -save_LineWidth(GLfloat width) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_LINE_WIDTH, 1); - if (n) { - n[1].f = width; - } - if (ctx->ExecuteFlag) { - CALL_LineWidth(ctx->Exec, (width)); - } -} - - -static void GLAPIENTRY -save_ListBase(GLuint base) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_LIST_BASE, 1); - if (n) { - n[1].ui = base; - } - if (ctx->ExecuteFlag) { - CALL_ListBase(ctx->Exec, (base)); - } -} - - -static void GLAPIENTRY -save_LoadIdentity(void) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - (void) alloc_instruction(ctx, OPCODE_LOAD_IDENTITY, 0); - if (ctx->ExecuteFlag) { - CALL_LoadIdentity(ctx->Exec, ()); - } -} - - -static void GLAPIENTRY -save_LoadMatrixf(const GLfloat * m) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_LOAD_MATRIX, 16); - if (n) { - GLuint i; - for (i = 0; i < 16; i++) { - n[1 + i].f = m[i]; - } - } - if (ctx->ExecuteFlag) { - CALL_LoadMatrixf(ctx->Exec, (m)); - } -} - - -static void GLAPIENTRY -save_LoadMatrixd(const GLdouble * m) -{ - GLfloat f[16]; - GLint i; - for (i = 0; i < 16; i++) { - f[i] = (GLfloat) m[i]; - } - save_LoadMatrixf(f); -} - - -static void GLAPIENTRY -save_LoadName(GLuint name) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_LOAD_NAME, 1); - if (n) { - n[1].ui = name; - } - if (ctx->ExecuteFlag) { - CALL_LoadName(ctx->Exec, (name)); - } -} - - -static void GLAPIENTRY -save_LogicOp(GLenum opcode) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_LOGIC_OP, 1); - if (n) { - n[1].e = opcode; - } - if (ctx->ExecuteFlag) { - CALL_LogicOp(ctx->Exec, (opcode)); - } -} - - -static void GLAPIENTRY -save_Map1d(GLenum target, GLdouble u1, GLdouble u2, GLint stride, - GLint order, const GLdouble * points) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_MAP1, 6); - if (n) { - GLfloat *pnts = _mesa_copy_map_points1d(target, stride, order, points); - n[1].e = target; - n[2].f = (GLfloat) u1; - n[3].f = (GLfloat) u2; - n[4].i = _mesa_evaluator_components(target); /* stride */ - n[5].i = order; - n[6].data = (void *) pnts; - } - if (ctx->ExecuteFlag) { - CALL_Map1d(ctx->Exec, (target, u1, u2, stride, order, points)); - } -} - -static void GLAPIENTRY -save_Map1f(GLenum target, GLfloat u1, GLfloat u2, GLint stride, - GLint order, const GLfloat * points) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_MAP1, 6); - if (n) { - GLfloat *pnts = _mesa_copy_map_points1f(target, stride, order, points); - n[1].e = target; - n[2].f = u1; - n[3].f = u2; - n[4].i = _mesa_evaluator_components(target); /* stride */ - n[5].i = order; - n[6].data = (void *) pnts; - } - if (ctx->ExecuteFlag) { - CALL_Map1f(ctx->Exec, (target, u1, u2, stride, order, points)); - } -} - - -static void GLAPIENTRY -save_Map2d(GLenum target, - GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, - GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, - const GLdouble * points) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_MAP2, 10); - if (n) { - GLfloat *pnts = _mesa_copy_map_points2d(target, ustride, uorder, - vstride, vorder, points); - n[1].e = target; - n[2].f = (GLfloat) u1; - n[3].f = (GLfloat) u2; - n[4].f = (GLfloat) v1; - n[5].f = (GLfloat) v2; - /* XXX verify these strides are correct */ - n[6].i = _mesa_evaluator_components(target) * vorder; /*ustride */ - n[7].i = _mesa_evaluator_components(target); /*vstride */ - n[8].i = uorder; - n[9].i = vorder; - n[10].data = (void *) pnts; - } - if (ctx->ExecuteFlag) { - CALL_Map2d(ctx->Exec, (target, - u1, u2, ustride, uorder, - v1, v2, vstride, vorder, points)); - } -} - - -static void GLAPIENTRY -save_Map2f(GLenum target, - GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, - GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, - const GLfloat * points) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_MAP2, 10); - if (n) { - GLfloat *pnts = _mesa_copy_map_points2f(target, ustride, uorder, - vstride, vorder, points); - n[1].e = target; - n[2].f = u1; - n[3].f = u2; - n[4].f = v1; - n[5].f = v2; - /* XXX verify these strides are correct */ - n[6].i = _mesa_evaluator_components(target) * vorder; /*ustride */ - n[7].i = _mesa_evaluator_components(target); /*vstride */ - n[8].i = uorder; - n[9].i = vorder; - n[10].data = (void *) pnts; - } - if (ctx->ExecuteFlag) { - CALL_Map2f(ctx->Exec, (target, u1, u2, ustride, uorder, - v1, v2, vstride, vorder, points)); - } -} - - -static void GLAPIENTRY -save_MapGrid1f(GLint un, GLfloat u1, GLfloat u2) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_MAPGRID1, 3); - if (n) { - n[1].i = un; - n[2].f = u1; - n[3].f = u2; - } - if (ctx->ExecuteFlag) { - CALL_MapGrid1f(ctx->Exec, (un, u1, u2)); - } -} - - -static void GLAPIENTRY -save_MapGrid1d(GLint un, GLdouble u1, GLdouble u2) -{ - save_MapGrid1f(un, (GLfloat) u1, (GLfloat) u2); -} - - -static void GLAPIENTRY -save_MapGrid2f(GLint un, GLfloat u1, GLfloat u2, - GLint vn, GLfloat v1, GLfloat v2) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_MAPGRID2, 6); - if (n) { - n[1].i = un; - n[2].f = u1; - n[3].f = u2; - n[4].i = vn; - n[5].f = v1; - n[6].f = v2; - } - if (ctx->ExecuteFlag) { - CALL_MapGrid2f(ctx->Exec, (un, u1, u2, vn, v1, v2)); - } -} - - - -static void GLAPIENTRY -save_MapGrid2d(GLint un, GLdouble u1, GLdouble u2, - GLint vn, GLdouble v1, GLdouble v2) -{ - save_MapGrid2f(un, (GLfloat) u1, (GLfloat) u2, - vn, (GLfloat) v1, (GLfloat) v2); -} - - -static void GLAPIENTRY -save_MatrixMode(GLenum mode) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_MATRIX_MODE, 1); - if (n) { - n[1].e = mode; - } - if (ctx->ExecuteFlag) { - CALL_MatrixMode(ctx->Exec, (mode)); - } -} - - -static void GLAPIENTRY -save_Minmax(GLenum target, GLenum internalFormat, GLboolean sink) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_MIN_MAX, 3); - if (n) { - n[1].e = target; - n[2].e = internalFormat; - n[3].b = sink; - } - if (ctx->ExecuteFlag) { - CALL_Minmax(ctx->Exec, (target, internalFormat, sink)); - } -} - - -static void GLAPIENTRY -save_MultMatrixf(const GLfloat * m) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_MULT_MATRIX, 16); - if (n) { - GLuint i; - for (i = 0; i < 16; i++) { - n[1 + i].f = m[i]; - } - } - if (ctx->ExecuteFlag) { - CALL_MultMatrixf(ctx->Exec, (m)); - } -} - - -static void GLAPIENTRY -save_MultMatrixd(const GLdouble * m) -{ - GLfloat f[16]; - GLint i; - for (i = 0; i < 16; i++) { - f[i] = (GLfloat) m[i]; - } - save_MultMatrixf(f); -} - - -static void GLAPIENTRY -save_NewList(GLuint name, GLenum mode) -{ - GET_CURRENT_CONTEXT(ctx); - /* It's an error to call this function while building a display list */ - _mesa_error(ctx, GL_INVALID_OPERATION, "glNewList"); - (void) name; - (void) mode; -} - - - -static void GLAPIENTRY -save_Ortho(GLdouble left, GLdouble right, - GLdouble bottom, GLdouble top, GLdouble nearval, GLdouble farval) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_ORTHO, 6); - if (n) { - n[1].f = (GLfloat) left; - n[2].f = (GLfloat) right; - n[3].f = (GLfloat) bottom; - n[4].f = (GLfloat) top; - n[5].f = (GLfloat) nearval; - n[6].f = (GLfloat) farval; - } - if (ctx->ExecuteFlag) { - CALL_Ortho(ctx->Exec, (left, right, bottom, top, nearval, farval)); - } -} - - -static void GLAPIENTRY -save_PixelMapfv(GLenum map, GLint mapsize, const GLfloat *values) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_PIXEL_MAP, 3); - if (n) { - n[1].e = map; - n[2].i = mapsize; - n[3].data = (void *) malloc(mapsize * sizeof(GLfloat)); - memcpy(n[3].data, (void *) values, mapsize * sizeof(GLfloat)); - } - if (ctx->ExecuteFlag) { - CALL_PixelMapfv(ctx->Exec, (map, mapsize, values)); - } -} - - -static void GLAPIENTRY -save_PixelMapuiv(GLenum map, GLint mapsize, const GLuint *values) -{ - GLfloat fvalues[MAX_PIXEL_MAP_TABLE]; - GLint i; - if (map == GL_PIXEL_MAP_I_TO_I || map == GL_PIXEL_MAP_S_TO_S) { - for (i = 0; i < mapsize; i++) { - fvalues[i] = (GLfloat) values[i]; - } - } - else { - for (i = 0; i < mapsize; i++) { - fvalues[i] = UINT_TO_FLOAT(values[i]); - } - } - save_PixelMapfv(map, mapsize, fvalues); -} - - -static void GLAPIENTRY -save_PixelMapusv(GLenum map, GLint mapsize, const GLushort *values) -{ - GLfloat fvalues[MAX_PIXEL_MAP_TABLE]; - GLint i; - if (map == GL_PIXEL_MAP_I_TO_I || map == GL_PIXEL_MAP_S_TO_S) { - for (i = 0; i < mapsize; i++) { - fvalues[i] = (GLfloat) values[i]; - } - } - else { - for (i = 0; i < mapsize; i++) { - fvalues[i] = USHORT_TO_FLOAT(values[i]); - } - } - save_PixelMapfv(map, mapsize, fvalues); -} - - -static void GLAPIENTRY -save_PixelTransferf(GLenum pname, GLfloat param) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_PIXEL_TRANSFER, 2); - if (n) { - n[1].e = pname; - n[2].f = param; - } - if (ctx->ExecuteFlag) { - CALL_PixelTransferf(ctx->Exec, (pname, param)); - } -} - - -static void GLAPIENTRY -save_PixelTransferi(GLenum pname, GLint param) -{ - save_PixelTransferf(pname, (GLfloat) param); -} - - -static void GLAPIENTRY -save_PixelZoom(GLfloat xfactor, GLfloat yfactor) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_PIXEL_ZOOM, 2); - if (n) { - n[1].f = xfactor; - n[2].f = yfactor; - } - if (ctx->ExecuteFlag) { - CALL_PixelZoom(ctx->Exec, (xfactor, yfactor)); - } -} - - -static void GLAPIENTRY -save_PointParameterfvEXT(GLenum pname, const GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_POINT_PARAMETERS, 4); - if (n) { - n[1].e = pname; - n[2].f = params[0]; - n[3].f = params[1]; - n[4].f = params[2]; - } - if (ctx->ExecuteFlag) { - CALL_PointParameterfvEXT(ctx->Exec, (pname, params)); - } -} - - -static void GLAPIENTRY -save_PointParameterfEXT(GLenum pname, GLfloat param) -{ - GLfloat parray[3]; - parray[0] = param; - parray[1] = parray[2] = 0.0F; - save_PointParameterfvEXT(pname, parray); -} - -static void GLAPIENTRY -save_PointParameteriNV(GLenum pname, GLint param) -{ - GLfloat parray[3]; - parray[0] = (GLfloat) param; - parray[1] = parray[2] = 0.0F; - save_PointParameterfvEXT(pname, parray); -} - -static void GLAPIENTRY -save_PointParameterivNV(GLenum pname, const GLint * param) -{ - GLfloat parray[3]; - parray[0] = (GLfloat) param[0]; - parray[1] = parray[2] = 0.0F; - save_PointParameterfvEXT(pname, parray); -} - - -static void GLAPIENTRY -save_PointSize(GLfloat size) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_POINT_SIZE, 1); - if (n) { - n[1].f = size; - } - if (ctx->ExecuteFlag) { - CALL_PointSize(ctx->Exec, (size)); - } -} - - -static void GLAPIENTRY -save_PolygonMode(GLenum face, GLenum mode) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_POLYGON_MODE, 2); - if (n) { - n[1].e = face; - n[2].e = mode; - } - if (ctx->ExecuteFlag) { - CALL_PolygonMode(ctx->Exec, (face, mode)); - } -} - - -static void GLAPIENTRY -save_PolygonStipple(const GLubyte * pattern) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - - n = alloc_instruction(ctx, OPCODE_POLYGON_STIPPLE, 1); - if (n) { - n[1].data = unpack_image(ctx, 2, 32, 32, 1, GL_COLOR_INDEX, GL_BITMAP, - pattern, &ctx->Unpack); - } - if (ctx->ExecuteFlag) { - CALL_PolygonStipple(ctx->Exec, ((GLubyte *) pattern)); - } -} - - -static void GLAPIENTRY -save_PolygonOffset(GLfloat factor, GLfloat units) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_POLYGON_OFFSET, 2); - if (n) { - n[1].f = factor; - n[2].f = units; - } - if (ctx->ExecuteFlag) { - CALL_PolygonOffset(ctx->Exec, (factor, units)); - } -} - - -static void GLAPIENTRY -save_PolygonOffsetEXT(GLfloat factor, GLfloat bias) -{ - GET_CURRENT_CONTEXT(ctx); - /* XXX mult by DepthMaxF here??? */ - save_PolygonOffset(factor, ctx->DrawBuffer->_DepthMaxF * bias); -} - - -static void GLAPIENTRY -save_PopAttrib(void) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - (void) alloc_instruction(ctx, OPCODE_POP_ATTRIB, 0); - if (ctx->ExecuteFlag) { - CALL_PopAttrib(ctx->Exec, ()); - } -} - - -static void GLAPIENTRY -save_PopMatrix(void) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - (void) alloc_instruction(ctx, OPCODE_POP_MATRIX, 0); - if (ctx->ExecuteFlag) { - CALL_PopMatrix(ctx->Exec, ()); - } -} - - -static void GLAPIENTRY -save_PopName(void) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - (void) alloc_instruction(ctx, OPCODE_POP_NAME, 0); - if (ctx->ExecuteFlag) { - CALL_PopName(ctx->Exec, ()); - } -} - - -static void GLAPIENTRY -save_PrioritizeTextures(GLsizei num, const GLuint * textures, - const GLclampf * priorities) -{ - GET_CURRENT_CONTEXT(ctx); - GLint i; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - - for (i = 0; i < num; i++) { - Node *n; - n = alloc_instruction(ctx, OPCODE_PRIORITIZE_TEXTURE, 2); - if (n) { - n[1].ui = textures[i]; - n[2].f = priorities[i]; - } - } - if (ctx->ExecuteFlag) { - CALL_PrioritizeTextures(ctx->Exec, (num, textures, priorities)); - } -} - - -static void GLAPIENTRY -save_PushAttrib(GLbitfield mask) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_PUSH_ATTRIB, 1); - if (n) { - n[1].bf = mask; - } - if (ctx->ExecuteFlag) { - CALL_PushAttrib(ctx->Exec, (mask)); - } -} - - -static void GLAPIENTRY -save_PushMatrix(void) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - (void) alloc_instruction(ctx, OPCODE_PUSH_MATRIX, 0); - if (ctx->ExecuteFlag) { - CALL_PushMatrix(ctx->Exec, ()); - } -} - - -static void GLAPIENTRY -save_PushName(GLuint name) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_PUSH_NAME, 1); - if (n) { - n[1].ui = name; - } - if (ctx->ExecuteFlag) { - CALL_PushName(ctx->Exec, (name)); - } -} - - -static void GLAPIENTRY -save_RasterPos4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_RASTER_POS, 4); - if (n) { - n[1].f = x; - n[2].f = y; - n[3].f = z; - n[4].f = w; - } - if (ctx->ExecuteFlag) { - CALL_RasterPos4f(ctx->Exec, (x, y, z, w)); - } -} - -static void GLAPIENTRY -save_RasterPos2d(GLdouble x, GLdouble y) -{ - save_RasterPos4f((GLfloat) x, (GLfloat) y, 0.0F, 1.0F); -} - -static void GLAPIENTRY -save_RasterPos2f(GLfloat x, GLfloat y) -{ - save_RasterPos4f(x, y, 0.0F, 1.0F); -} - -static void GLAPIENTRY -save_RasterPos2i(GLint x, GLint y) -{ - save_RasterPos4f((GLfloat) x, (GLfloat) y, 0.0F, 1.0F); -} - -static void GLAPIENTRY -save_RasterPos2s(GLshort x, GLshort y) -{ - save_RasterPos4f(x, y, 0.0F, 1.0F); -} - -static void GLAPIENTRY -save_RasterPos3d(GLdouble x, GLdouble y, GLdouble z) -{ - save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F); -} - -static void GLAPIENTRY -save_RasterPos3f(GLfloat x, GLfloat y, GLfloat z) -{ - save_RasterPos4f(x, y, z, 1.0F); -} - -static void GLAPIENTRY -save_RasterPos3i(GLint x, GLint y, GLint z) -{ - save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F); -} - -static void GLAPIENTRY -save_RasterPos3s(GLshort x, GLshort y, GLshort z) -{ - save_RasterPos4f(x, y, z, 1.0F); -} - -static void GLAPIENTRY -save_RasterPos4d(GLdouble x, GLdouble y, GLdouble z, GLdouble w) -{ - save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w); -} - -static void GLAPIENTRY -save_RasterPos4i(GLint x, GLint y, GLint z, GLint w) -{ - save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w); -} - -static void GLAPIENTRY -save_RasterPos4s(GLshort x, GLshort y, GLshort z, GLshort w) -{ - save_RasterPos4f(x, y, z, w); -} - -static void GLAPIENTRY -save_RasterPos2dv(const GLdouble * v) -{ - save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F); -} - -static void GLAPIENTRY -save_RasterPos2fv(const GLfloat * v) -{ - save_RasterPos4f(v[0], v[1], 0.0F, 1.0F); -} - -static void GLAPIENTRY -save_RasterPos2iv(const GLint * v) -{ - save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F); -} - -static void GLAPIENTRY -save_RasterPos2sv(const GLshort * v) -{ - save_RasterPos4f(v[0], v[1], 0.0F, 1.0F); -} - -static void GLAPIENTRY -save_RasterPos3dv(const GLdouble * v) -{ - save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F); -} - -static void GLAPIENTRY -save_RasterPos3fv(const GLfloat * v) -{ - save_RasterPos4f(v[0], v[1], v[2], 1.0F); -} - -static void GLAPIENTRY -save_RasterPos3iv(const GLint * v) -{ - save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F); -} - -static void GLAPIENTRY -save_RasterPos3sv(const GLshort * v) -{ - save_RasterPos4f(v[0], v[1], v[2], 1.0F); -} - -static void GLAPIENTRY -save_RasterPos4dv(const GLdouble * v) -{ - save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], - (GLfloat) v[2], (GLfloat) v[3]); -} - -static void GLAPIENTRY -save_RasterPos4fv(const GLfloat * v) -{ - save_RasterPos4f(v[0], v[1], v[2], v[3]); -} - -static void GLAPIENTRY -save_RasterPos4iv(const GLint * v) -{ - save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], - (GLfloat) v[2], (GLfloat) v[3]); -} - -static void GLAPIENTRY -save_RasterPos4sv(const GLshort * v) -{ - save_RasterPos4f(v[0], v[1], v[2], v[3]); -} - - -static void GLAPIENTRY -save_PassThrough(GLfloat token) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_PASSTHROUGH, 1); - if (n) { - n[1].f = token; - } - if (ctx->ExecuteFlag) { - CALL_PassThrough(ctx->Exec, (token)); - } -} - - -static void GLAPIENTRY -save_ReadBuffer(GLenum mode) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_READ_BUFFER, 1); - if (n) { - n[1].e = mode; - } - if (ctx->ExecuteFlag) { - CALL_ReadBuffer(ctx->Exec, (mode)); - } -} - - -static void GLAPIENTRY -save_ResetHistogram(GLenum target) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_RESET_HISTOGRAM, 1); - if (n) { - n[1].e = target; - } - if (ctx->ExecuteFlag) { - CALL_ResetHistogram(ctx->Exec, (target)); - } -} - - -static void GLAPIENTRY -save_ResetMinmax(GLenum target) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_RESET_MIN_MAX, 1); - if (n) { - n[1].e = target; - } - if (ctx->ExecuteFlag) { - CALL_ResetMinmax(ctx->Exec, (target)); - } -} - - -static void GLAPIENTRY -save_Rotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_ROTATE, 4); - if (n) { - n[1].f = angle; - n[2].f = x; - n[3].f = y; - n[4].f = z; - } - if (ctx->ExecuteFlag) { - CALL_Rotatef(ctx->Exec, (angle, x, y, z)); - } -} - - -static void GLAPIENTRY -save_Rotated(GLdouble angle, GLdouble x, GLdouble y, GLdouble z) -{ - save_Rotatef((GLfloat) angle, (GLfloat) x, (GLfloat) y, (GLfloat) z); -} - - -static void GLAPIENTRY -save_Scalef(GLfloat x, GLfloat y, GLfloat z) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_SCALE, 3); - if (n) { - n[1].f = x; - n[2].f = y; - n[3].f = z; - } - if (ctx->ExecuteFlag) { - CALL_Scalef(ctx->Exec, (x, y, z)); - } -} - - -static void GLAPIENTRY -save_Scaled(GLdouble x, GLdouble y, GLdouble z) -{ - save_Scalef((GLfloat) x, (GLfloat) y, (GLfloat) z); -} - - -static void GLAPIENTRY -save_Scissor(GLint x, GLint y, GLsizei width, GLsizei height) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_SCISSOR, 4); - if (n) { - n[1].i = x; - n[2].i = y; - n[3].i = width; - n[4].i = height; - } - if (ctx->ExecuteFlag) { - CALL_Scissor(ctx->Exec, (x, y, width, height)); - } -} - - -static void GLAPIENTRY -save_ShadeModel(GLenum mode) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END(ctx); - - if (ctx->ExecuteFlag) { - CALL_ShadeModel(ctx->Exec, (mode)); - } - - if (ctx->ListState.Current.ShadeModel == mode) - return; - - SAVE_FLUSH_VERTICES(ctx); - - /* Only save the value if we know the statechange will take effect: - */ - if (ctx->Driver.CurrentSavePrimitive == PRIM_OUTSIDE_BEGIN_END) - ctx->ListState.Current.ShadeModel = mode; - - n = alloc_instruction(ctx, OPCODE_SHADE_MODEL, 1); - if (n) { - n[1].e = mode; - } -} - - -static void GLAPIENTRY -save_StencilFunc(GLenum func, GLint ref, GLuint mask) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_STENCIL_FUNC, 3); - if (n) { - n[1].e = func; - n[2].i = ref; - n[3].ui = mask; - } - if (ctx->ExecuteFlag) { - CALL_StencilFunc(ctx->Exec, (func, ref, mask)); - } -} - - -static void GLAPIENTRY -save_StencilMask(GLuint mask) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_STENCIL_MASK, 1); - if (n) { - n[1].ui = mask; - } - if (ctx->ExecuteFlag) { - CALL_StencilMask(ctx->Exec, (mask)); - } -} - - -static void GLAPIENTRY -save_StencilOp(GLenum fail, GLenum zfail, GLenum zpass) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_STENCIL_OP, 3); - if (n) { - n[1].e = fail; - n[2].e = zfail; - n[3].e = zpass; - } - if (ctx->ExecuteFlag) { - CALL_StencilOp(ctx->Exec, (fail, zfail, zpass)); - } -} - - -static void GLAPIENTRY -save_StencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_STENCIL_FUNC_SEPARATE, 4); - if (n) { - n[1].e = face; - n[2].e = func; - n[3].i = ref; - n[4].ui = mask; - } - if (ctx->ExecuteFlag) { - CALL_StencilFuncSeparate(ctx->Exec, (face, func, ref, mask)); - } -} - - -static void GLAPIENTRY -save_StencilFuncSeparateATI(GLenum frontfunc, GLenum backfunc, GLint ref, - GLuint mask) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - /* GL_FRONT */ - n = alloc_instruction(ctx, OPCODE_STENCIL_FUNC_SEPARATE, 4); - if (n) { - n[1].e = GL_FRONT; - n[2].e = frontfunc; - n[3].i = ref; - n[4].ui = mask; - } - /* GL_BACK */ - n = alloc_instruction(ctx, OPCODE_STENCIL_FUNC_SEPARATE, 4); - if (n) { - n[1].e = GL_BACK; - n[2].e = backfunc; - n[3].i = ref; - n[4].ui = mask; - } - if (ctx->ExecuteFlag) { - CALL_StencilFuncSeparate(ctx->Exec, (GL_FRONT, frontfunc, ref, mask)); - CALL_StencilFuncSeparate(ctx->Exec, (GL_BACK, backfunc, ref, mask)); - } -} - - -static void GLAPIENTRY -save_StencilMaskSeparate(GLenum face, GLuint mask) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_STENCIL_MASK_SEPARATE, 2); - if (n) { - n[1].e = face; - n[2].ui = mask; - } - if (ctx->ExecuteFlag) { - CALL_StencilMaskSeparate(ctx->Exec, (face, mask)); - } -} - - -static void GLAPIENTRY -save_StencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_STENCIL_OP_SEPARATE, 4); - if (n) { - n[1].e = face; - n[2].e = fail; - n[3].e = zfail; - n[4].e = zpass; - } - if (ctx->ExecuteFlag) { - CALL_StencilOpSeparate(ctx->Exec, (face, fail, zfail, zpass)); - } -} - - -static void GLAPIENTRY -save_TexEnvfv(GLenum target, GLenum pname, const GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_TEXENV, 6); - if (n) { - n[1].e = target; - n[2].e = pname; - if (pname == GL_TEXTURE_ENV_COLOR) { - n[3].f = params[0]; - n[4].f = params[1]; - n[5].f = params[2]; - n[6].f = params[3]; - } - else { - n[3].f = params[0]; - n[4].f = n[5].f = n[6].f = 0.0F; - } - } - if (ctx->ExecuteFlag) { - CALL_TexEnvfv(ctx->Exec, (target, pname, params)); - } -} - - -static void GLAPIENTRY -save_TexEnvf(GLenum target, GLenum pname, GLfloat param) -{ - GLfloat parray[4]; - parray[0] = (GLfloat) param; - parray[1] = parray[2] = parray[3] = 0.0F; - save_TexEnvfv(target, pname, parray); -} - - -static void GLAPIENTRY -save_TexEnvi(GLenum target, GLenum pname, GLint param) -{ - GLfloat p[4]; - p[0] = (GLfloat) param; - p[1] = p[2] = p[3] = 0.0F; - save_TexEnvfv(target, pname, p); -} - - -static void GLAPIENTRY -save_TexEnviv(GLenum target, GLenum pname, const GLint * param) -{ - GLfloat p[4]; - if (pname == GL_TEXTURE_ENV_COLOR) { - p[0] = INT_TO_FLOAT(param[0]); - p[1] = INT_TO_FLOAT(param[1]); - p[2] = INT_TO_FLOAT(param[2]); - p[3] = INT_TO_FLOAT(param[3]); - } - else { - p[0] = (GLfloat) param[0]; - p[1] = p[2] = p[3] = 0.0F; - } - save_TexEnvfv(target, pname, p); -} - - -static void GLAPIENTRY -save_TexGenfv(GLenum coord, GLenum pname, const GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_TEXGEN, 6); - if (n) { - n[1].e = coord; - n[2].e = pname; - n[3].f = params[0]; - n[4].f = params[1]; - n[5].f = params[2]; - n[6].f = params[3]; - } - if (ctx->ExecuteFlag) { - CALL_TexGenfv(ctx->Exec, (coord, pname, params)); - } -} - - -static void GLAPIENTRY -save_TexGeniv(GLenum coord, GLenum pname, const GLint *params) -{ - GLfloat p[4]; - p[0] = (GLfloat) params[0]; - p[1] = (GLfloat) params[1]; - p[2] = (GLfloat) params[2]; - p[3] = (GLfloat) params[3]; - save_TexGenfv(coord, pname, p); -} - - -static void GLAPIENTRY -save_TexGend(GLenum coord, GLenum pname, GLdouble param) -{ - GLfloat parray[4]; - parray[0] = (GLfloat) param; - parray[1] = parray[2] = parray[3] = 0.0F; - save_TexGenfv(coord, pname, parray); -} - - -static void GLAPIENTRY -save_TexGendv(GLenum coord, GLenum pname, const GLdouble *params) -{ - GLfloat p[4]; - p[0] = (GLfloat) params[0]; - p[1] = (GLfloat) params[1]; - p[2] = (GLfloat) params[2]; - p[3] = (GLfloat) params[3]; - save_TexGenfv(coord, pname, p); -} - - -static void GLAPIENTRY -save_TexGenf(GLenum coord, GLenum pname, GLfloat param) -{ - GLfloat parray[4]; - parray[0] = param; - parray[1] = parray[2] = parray[3] = 0.0F; - save_TexGenfv(coord, pname, parray); -} - - -static void GLAPIENTRY -save_TexGeni(GLenum coord, GLenum pname, GLint param) -{ - GLint parray[4]; - parray[0] = param; - parray[1] = parray[2] = parray[3] = 0; - save_TexGeniv(coord, pname, parray); -} - - -static void GLAPIENTRY -save_TexParameterfv(GLenum target, GLenum pname, const GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_TEXPARAMETER, 6); - if (n) { - n[1].e = target; - n[2].e = pname; - n[3].f = params[0]; - n[4].f = params[1]; - n[5].f = params[2]; - n[6].f = params[3]; - } - if (ctx->ExecuteFlag) { - CALL_TexParameterfv(ctx->Exec, (target, pname, params)); - } -} - - -static void GLAPIENTRY -save_TexParameterf(GLenum target, GLenum pname, GLfloat param) -{ - GLfloat parray[4]; - parray[0] = param; - parray[1] = parray[2] = parray[3] = 0.0F; - save_TexParameterfv(target, pname, parray); -} - - -static void GLAPIENTRY -save_TexParameteri(GLenum target, GLenum pname, GLint param) -{ - GLfloat fparam[4]; - fparam[0] = (GLfloat) param; - fparam[1] = fparam[2] = fparam[3] = 0.0F; - save_TexParameterfv(target, pname, fparam); -} - - -static void GLAPIENTRY -save_TexParameteriv(GLenum target, GLenum pname, const GLint *params) -{ - GLfloat fparam[4]; - fparam[0] = (GLfloat) params[0]; - fparam[1] = fparam[2] = fparam[3] = 0.0F; - save_TexParameterfv(target, pname, fparam); -} - - -static void GLAPIENTRY -save_TexImage1D(GLenum target, - GLint level, GLint components, - GLsizei width, GLint border, - GLenum format, GLenum type, const GLvoid * pixels) -{ - GET_CURRENT_CONTEXT(ctx); - if (target == GL_PROXY_TEXTURE_1D) { - /* don't compile, execute immediately */ - CALL_TexImage1D(ctx->Exec, (target, level, components, width, - border, format, type, pixels)); - } - else { - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_TEX_IMAGE1D, 8); - if (n) { - n[1].e = target; - n[2].i = level; - n[3].i = components; - n[4].i = (GLint) width; - n[5].i = border; - n[6].e = format; - n[7].e = type; - n[8].data = unpack_image(ctx, 1, width, 1, 1, format, type, - pixels, &ctx->Unpack); - } - if (ctx->ExecuteFlag) { - CALL_TexImage1D(ctx->Exec, (target, level, components, width, - border, format, type, pixels)); - } - } -} - - -static void GLAPIENTRY -save_TexImage2D(GLenum target, - GLint level, GLint components, - GLsizei width, GLsizei height, GLint border, - GLenum format, GLenum type, const GLvoid * pixels) -{ - GET_CURRENT_CONTEXT(ctx); - if (target == GL_PROXY_TEXTURE_2D) { - /* don't compile, execute immediately */ - CALL_TexImage2D(ctx->Exec, (target, level, components, width, - height, border, format, type, pixels)); - } - else { - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_TEX_IMAGE2D, 9); - if (n) { - n[1].e = target; - n[2].i = level; - n[3].i = components; - n[4].i = (GLint) width; - n[5].i = (GLint) height; - n[6].i = border; - n[7].e = format; - n[8].e = type; - n[9].data = unpack_image(ctx, 2, width, height, 1, format, type, - pixels, &ctx->Unpack); - } - if (ctx->ExecuteFlag) { - CALL_TexImage2D(ctx->Exec, (target, level, components, width, - height, border, format, type, pixels)); - } - } -} - - -static void GLAPIENTRY -save_TexImage3D(GLenum target, - GLint level, GLint internalFormat, - GLsizei width, GLsizei height, GLsizei depth, - GLint border, - GLenum format, GLenum type, const GLvoid * pixels) -{ - GET_CURRENT_CONTEXT(ctx); - if (target == GL_PROXY_TEXTURE_3D) { - /* don't compile, execute immediately */ - CALL_TexImage3D(ctx->Exec, (target, level, internalFormat, width, - height, depth, border, format, type, - pixels)); - } - else { - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_TEX_IMAGE3D, 10); - if (n) { - n[1].e = target; - n[2].i = level; - n[3].i = (GLint) internalFormat; - n[4].i = (GLint) width; - n[5].i = (GLint) height; - n[6].i = (GLint) depth; - n[7].i = border; - n[8].e = format; - n[9].e = type; - n[10].data = unpack_image(ctx, 3, width, height, depth, format, type, - pixels, &ctx->Unpack); - } - if (ctx->ExecuteFlag) { - CALL_TexImage3D(ctx->Exec, (target, level, internalFormat, width, - height, depth, border, format, type, - pixels)); - } - } -} - - -static void GLAPIENTRY -save_TexSubImage1D(GLenum target, GLint level, GLint xoffset, - GLsizei width, GLenum format, GLenum type, - const GLvoid * pixels) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - - n = alloc_instruction(ctx, OPCODE_TEX_SUB_IMAGE1D, 7); - if (n) { - n[1].e = target; - n[2].i = level; - n[3].i = xoffset; - n[4].i = (GLint) width; - n[5].e = format; - n[6].e = type; - n[7].data = unpack_image(ctx, 1, width, 1, 1, format, type, - pixels, &ctx->Unpack); - } - if (ctx->ExecuteFlag) { - CALL_TexSubImage1D(ctx->Exec, (target, level, xoffset, width, - format, type, pixels)); - } -} - - -static void GLAPIENTRY -save_TexSubImage2D(GLenum target, GLint level, - GLint xoffset, GLint yoffset, - GLsizei width, GLsizei height, - GLenum format, GLenum type, const GLvoid * pixels) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - - n = alloc_instruction(ctx, OPCODE_TEX_SUB_IMAGE2D, 9); - if (n) { - n[1].e = target; - n[2].i = level; - n[3].i = xoffset; - n[4].i = yoffset; - n[5].i = (GLint) width; - n[6].i = (GLint) height; - n[7].e = format; - n[8].e = type; - n[9].data = unpack_image(ctx, 2, width, height, 1, format, type, - pixels, &ctx->Unpack); - } - if (ctx->ExecuteFlag) { - CALL_TexSubImage2D(ctx->Exec, (target, level, xoffset, yoffset, - width, height, format, type, pixels)); - } -} - - -static void GLAPIENTRY -save_TexSubImage3D(GLenum target, GLint level, - GLint xoffset, GLint yoffset, GLint zoffset, - GLsizei width, GLsizei height, GLsizei depth, - GLenum format, GLenum type, const GLvoid * pixels) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - - n = alloc_instruction(ctx, OPCODE_TEX_SUB_IMAGE3D, 11); - if (n) { - n[1].e = target; - n[2].i = level; - n[3].i = xoffset; - n[4].i = yoffset; - n[5].i = zoffset; - n[6].i = (GLint) width; - n[7].i = (GLint) height; - n[8].i = (GLint) depth; - n[9].e = format; - n[10].e = type; - n[11].data = unpack_image(ctx, 3, width, height, depth, format, type, - pixels, &ctx->Unpack); - } - if (ctx->ExecuteFlag) { - CALL_TexSubImage3D(ctx->Exec, (target, level, - xoffset, yoffset, zoffset, - width, height, depth, format, type, - pixels)); - } -} - - -static void GLAPIENTRY -save_Translatef(GLfloat x, GLfloat y, GLfloat z) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_TRANSLATE, 3); - if (n) { - n[1].f = x; - n[2].f = y; - n[3].f = z; - } - if (ctx->ExecuteFlag) { - CALL_Translatef(ctx->Exec, (x, y, z)); - } -} - - -static void GLAPIENTRY -save_Translated(GLdouble x, GLdouble y, GLdouble z) -{ - save_Translatef((GLfloat) x, (GLfloat) y, (GLfloat) z); -} - - - -static void GLAPIENTRY -save_Viewport(GLint x, GLint y, GLsizei width, GLsizei height) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_VIEWPORT, 4); - if (n) { - n[1].i = x; - n[2].i = y; - n[3].i = (GLint) width; - n[4].i = (GLint) height; - } - if (ctx->ExecuteFlag) { - CALL_Viewport(ctx->Exec, (x, y, width, height)); - } -} - - -static void GLAPIENTRY -save_WindowPos4fMESA(GLfloat x, GLfloat y, GLfloat z, GLfloat w) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_WINDOW_POS, 4); - if (n) { - n[1].f = x; - n[2].f = y; - n[3].f = z; - n[4].f = w; - } - if (ctx->ExecuteFlag) { - CALL_WindowPos4fMESA(ctx->Exec, (x, y, z, w)); - } -} - -static void GLAPIENTRY -save_WindowPos2dMESA(GLdouble x, GLdouble y) -{ - save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, 0.0F, 1.0F); -} - -static void GLAPIENTRY -save_WindowPos2fMESA(GLfloat x, GLfloat y) -{ - save_WindowPos4fMESA(x, y, 0.0F, 1.0F); -} - -static void GLAPIENTRY -save_WindowPos2iMESA(GLint x, GLint y) -{ - save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, 0.0F, 1.0F); -} - -static void GLAPIENTRY -save_WindowPos2sMESA(GLshort x, GLshort y) -{ - save_WindowPos4fMESA(x, y, 0.0F, 1.0F); -} - -static void GLAPIENTRY -save_WindowPos3dMESA(GLdouble x, GLdouble y, GLdouble z) -{ - save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F); -} - -static void GLAPIENTRY -save_WindowPos3fMESA(GLfloat x, GLfloat y, GLfloat z) -{ - save_WindowPos4fMESA(x, y, z, 1.0F); -} - -static void GLAPIENTRY -save_WindowPos3iMESA(GLint x, GLint y, GLint z) -{ - save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F); -} - -static void GLAPIENTRY -save_WindowPos3sMESA(GLshort x, GLshort y, GLshort z) -{ - save_WindowPos4fMESA(x, y, z, 1.0F); -} - -static void GLAPIENTRY -save_WindowPos4dMESA(GLdouble x, GLdouble y, GLdouble z, GLdouble w) -{ - save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w); -} - -static void GLAPIENTRY -save_WindowPos4iMESA(GLint x, GLint y, GLint z, GLint w) -{ - save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w); -} - -static void GLAPIENTRY -save_WindowPos4sMESA(GLshort x, GLshort y, GLshort z, GLshort w) -{ - save_WindowPos4fMESA(x, y, z, w); -} - -static void GLAPIENTRY -save_WindowPos2dvMESA(const GLdouble * v) -{ - save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F); -} - -static void GLAPIENTRY -save_WindowPos2fvMESA(const GLfloat * v) -{ - save_WindowPos4fMESA(v[0], v[1], 0.0F, 1.0F); -} - -static void GLAPIENTRY -save_WindowPos2ivMESA(const GLint * v) -{ - save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F); -} - -static void GLAPIENTRY -save_WindowPos2svMESA(const GLshort * v) -{ - save_WindowPos4fMESA(v[0], v[1], 0.0F, 1.0F); -} - -static void GLAPIENTRY -save_WindowPos3dvMESA(const GLdouble * v) -{ - save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F); -} - -static void GLAPIENTRY -save_WindowPos3fvMESA(const GLfloat * v) -{ - save_WindowPos4fMESA(v[0], v[1], v[2], 1.0F); -} - -static void GLAPIENTRY -save_WindowPos3ivMESA(const GLint * v) -{ - save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F); -} - -static void GLAPIENTRY -save_WindowPos3svMESA(const GLshort * v) -{ - save_WindowPos4fMESA(v[0], v[1], v[2], 1.0F); -} - -static void GLAPIENTRY -save_WindowPos4dvMESA(const GLdouble * v) -{ - save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], - (GLfloat) v[2], (GLfloat) v[3]); -} - -static void GLAPIENTRY -save_WindowPos4fvMESA(const GLfloat * v) -{ - save_WindowPos4fMESA(v[0], v[1], v[2], v[3]); -} - -static void GLAPIENTRY -save_WindowPos4ivMESA(const GLint * v) -{ - save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], - (GLfloat) v[2], (GLfloat) v[3]); -} - -static void GLAPIENTRY -save_WindowPos4svMESA(const GLshort * v) -{ - save_WindowPos4fMESA(v[0], v[1], v[2], v[3]); -} - - - -/* GL_ARB_multitexture */ -static void GLAPIENTRY -save_ActiveTextureARB(GLenum target) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_ACTIVE_TEXTURE, 1); - if (n) { - n[1].e = target; - } - if (ctx->ExecuteFlag) { - CALL_ActiveTextureARB(ctx->Exec, (target)); - } -} - - -/* GL_ARB_transpose_matrix */ - -static void GLAPIENTRY -save_LoadTransposeMatrixdARB(const GLdouble m[16]) -{ - GLfloat tm[16]; - _math_transposefd(tm, m); - save_LoadMatrixf(tm); -} - - -static void GLAPIENTRY -save_LoadTransposeMatrixfARB(const GLfloat m[16]) -{ - GLfloat tm[16]; - _math_transposef(tm, m); - save_LoadMatrixf(tm); -} - - -static void GLAPIENTRY -save_MultTransposeMatrixdARB(const GLdouble m[16]) -{ - GLfloat tm[16]; - _math_transposefd(tm, m); - save_MultMatrixf(tm); -} - - -static void GLAPIENTRY -save_MultTransposeMatrixfARB(const GLfloat m[16]) -{ - GLfloat tm[16]; - _math_transposef(tm, m); - save_MultMatrixf(tm); -} - - -/* GL_ARB_texture_compression */ -static void GLAPIENTRY -save_CompressedTexImage1DARB(GLenum target, GLint level, - GLenum internalFormat, GLsizei width, - GLint border, GLsizei imageSize, - const GLvoid * data) -{ - GET_CURRENT_CONTEXT(ctx); - if (target == GL_PROXY_TEXTURE_1D) { - /* don't compile, execute immediately */ - CALL_CompressedTexImage1DARB(ctx->Exec, (target, level, internalFormat, - width, border, imageSize, - data)); - } - else { - Node *n; - GLvoid *image; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - /* make copy of image */ - image = malloc(imageSize); - if (!image) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage1DARB"); - return; - } - memcpy(image, data, imageSize); - n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_IMAGE_1D, 7); - if (n) { - n[1].e = target; - n[2].i = level; - n[3].e = internalFormat; - n[4].i = (GLint) width; - n[5].i = border; - n[6].i = imageSize; - n[7].data = image; - } - else if (image) { - free(image); - } - if (ctx->ExecuteFlag) { - CALL_CompressedTexImage1DARB(ctx->Exec, - (target, level, internalFormat, width, - border, imageSize, data)); - } - } -} - - -static void GLAPIENTRY -save_CompressedTexImage2DARB(GLenum target, GLint level, - GLenum internalFormat, GLsizei width, - GLsizei height, GLint border, GLsizei imageSize, - const GLvoid * data) -{ - GET_CURRENT_CONTEXT(ctx); - if (target == GL_PROXY_TEXTURE_2D) { - /* don't compile, execute immediately */ - CALL_CompressedTexImage2DARB(ctx->Exec, (target, level, internalFormat, - width, height, border, - imageSize, data)); - } - else { - Node *n; - GLvoid *image; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - /* make copy of image */ - image = malloc(imageSize); - if (!image) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2DARB"); - return; - } - memcpy(image, data, imageSize); - n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_IMAGE_2D, 8); - if (n) { - n[1].e = target; - n[2].i = level; - n[3].e = internalFormat; - n[4].i = (GLint) width; - n[5].i = (GLint) height; - n[6].i = border; - n[7].i = imageSize; - n[8].data = image; - } - else if (image) { - free(image); - } - if (ctx->ExecuteFlag) { - CALL_CompressedTexImage2DARB(ctx->Exec, - (target, level, internalFormat, width, - height, border, imageSize, data)); - } - } -} - - -static void GLAPIENTRY -save_CompressedTexImage3DARB(GLenum target, GLint level, - GLenum internalFormat, GLsizei width, - GLsizei height, GLsizei depth, GLint border, - GLsizei imageSize, const GLvoid * data) -{ - GET_CURRENT_CONTEXT(ctx); - if (target == GL_PROXY_TEXTURE_3D) { - /* don't compile, execute immediately */ - CALL_CompressedTexImage3DARB(ctx->Exec, (target, level, internalFormat, - width, height, depth, border, - imageSize, data)); - } - else { - Node *n; - GLvoid *image; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - /* make copy of image */ - image = malloc(imageSize); - if (!image) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage3DARB"); - return; - } - memcpy(image, data, imageSize); - n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_IMAGE_3D, 9); - if (n) { - n[1].e = target; - n[2].i = level; - n[3].e = internalFormat; - n[4].i = (GLint) width; - n[5].i = (GLint) height; - n[6].i = (GLint) depth; - n[7].i = border; - n[8].i = imageSize; - n[9].data = image; - } - else if (image) { - free(image); - } - if (ctx->ExecuteFlag) { - CALL_CompressedTexImage3DARB(ctx->Exec, - (target, level, internalFormat, width, - height, depth, border, imageSize, - data)); - } - } -} - - -static void GLAPIENTRY -save_CompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset, - GLsizei width, GLenum format, - GLsizei imageSize, const GLvoid * data) -{ - Node *n; - GLvoid *image; - - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - - /* make copy of image */ - image = malloc(imageSize); - if (!image) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage1DARB"); - return; - } - memcpy(image, data, imageSize); - n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D, 7); - if (n) { - n[1].e = target; - n[2].i = level; - n[3].i = xoffset; - n[4].i = (GLint) width; - n[5].e = format; - n[6].i = imageSize; - n[7].data = image; - } - else if (image) { - free(image); - } - if (ctx->ExecuteFlag) { - CALL_CompressedTexSubImage1DARB(ctx->Exec, (target, level, xoffset, - width, format, imageSize, - data)); - } -} - - -static void GLAPIENTRY -save_CompressedTexSubImage2DARB(GLenum target, GLint level, GLint xoffset, - GLint yoffset, GLsizei width, GLsizei height, - GLenum format, GLsizei imageSize, - const GLvoid * data) -{ - Node *n; - GLvoid *image; - - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - - /* make copy of image */ - image = malloc(imageSize); - if (!image) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage2DARB"); - return; - } - memcpy(image, data, imageSize); - n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D, 9); - if (n) { - n[1].e = target; - n[2].i = level; - n[3].i = xoffset; - n[4].i = yoffset; - n[5].i = (GLint) width; - n[6].i = (GLint) height; - n[7].e = format; - n[8].i = imageSize; - n[9].data = image; - } - else if (image) { - free(image); - } - if (ctx->ExecuteFlag) { - CALL_CompressedTexSubImage2DARB(ctx->Exec, - (target, level, xoffset, yoffset, width, - height, format, imageSize, data)); - } -} - - -static void GLAPIENTRY -save_CompressedTexSubImage3DARB(GLenum target, GLint level, GLint xoffset, - GLint yoffset, GLint zoffset, GLsizei width, - GLsizei height, GLsizei depth, GLenum format, - GLsizei imageSize, const GLvoid * data) -{ - Node *n; - GLvoid *image; - - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - - /* make copy of image */ - image = malloc(imageSize); - if (!image) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage3DARB"); - return; - } - memcpy(image, data, imageSize); - n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D, 11); - if (n) { - n[1].e = target; - n[2].i = level; - n[3].i = xoffset; - n[4].i = yoffset; - n[5].i = zoffset; - n[6].i = (GLint) width; - n[7].i = (GLint) height; - n[8].i = (GLint) depth; - n[9].e = format; - n[10].i = imageSize; - n[11].data = image; - } - else if (image) { - free(image); - } - if (ctx->ExecuteFlag) { - CALL_CompressedTexSubImage3DARB(ctx->Exec, - (target, level, xoffset, yoffset, - zoffset, width, height, depth, format, - imageSize, data)); - } -} - - -/* GL_ARB_multisample */ -static void GLAPIENTRY -save_SampleCoverageARB(GLclampf value, GLboolean invert) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_SAMPLE_COVERAGE, 2); - if (n) { - n[1].f = value; - n[2].b = invert; - } - if (ctx->ExecuteFlag) { - CALL_SampleCoverageARB(ctx->Exec, (value, invert)); - } -} - - -/* - * GL_NV_vertex_program - */ -#if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program -static void GLAPIENTRY -save_BindProgramNV(GLenum target, GLuint id) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_BIND_PROGRAM_NV, 2); - if (n) { - n[1].e = target; - n[2].ui = id; - } - if (ctx->ExecuteFlag) { - CALL_BindProgramNV(ctx->Exec, (target, id)); - } -} - -static void GLAPIENTRY -save_ProgramEnvParameter4fARB(GLenum target, GLuint index, - GLfloat x, GLfloat y, GLfloat z, GLfloat w) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_PROGRAM_ENV_PARAMETER_ARB, 6); - if (n) { - n[1].e = target; - n[2].ui = index; - n[3].f = x; - n[4].f = y; - n[5].f = z; - n[6].f = w; - } - if (ctx->ExecuteFlag) { - CALL_ProgramEnvParameter4fARB(ctx->Exec, (target, index, x, y, z, w)); - } -} - - -static void GLAPIENTRY -save_ProgramEnvParameter4fvARB(GLenum target, GLuint index, - const GLfloat *params) -{ - save_ProgramEnvParameter4fARB(target, index, params[0], params[1], - params[2], params[3]); -} - - -static void GLAPIENTRY -save_ProgramEnvParameters4fvEXT(GLenum target, GLuint index, GLsizei count, - const GLfloat * params) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - - if (count > 0) { - GLint i; - const GLfloat * p = params; - - for (i = 0 ; i < count ; i++) { - n = alloc_instruction(ctx, OPCODE_PROGRAM_ENV_PARAMETER_ARB, 6); - if (n) { - n[1].e = target; - n[2].ui = index; - n[3].f = p[0]; - n[4].f = p[1]; - n[5].f = p[2]; - n[6].f = p[3]; - p += 4; - } - } - } - - if (ctx->ExecuteFlag) { - CALL_ProgramEnvParameters4fvEXT(ctx->Exec, (target, index, count, params)); - } -} - - -static void GLAPIENTRY -save_ProgramEnvParameter4dARB(GLenum target, GLuint index, - GLdouble x, GLdouble y, GLdouble z, GLdouble w) -{ - save_ProgramEnvParameter4fARB(target, index, - (GLfloat) x, - (GLfloat) y, (GLfloat) z, (GLfloat) w); -} - - -static void GLAPIENTRY -save_ProgramEnvParameter4dvARB(GLenum target, GLuint index, - const GLdouble *params) -{ - save_ProgramEnvParameter4fARB(target, index, - (GLfloat) params[0], - (GLfloat) params[1], - (GLfloat) params[2], (GLfloat) params[3]); -} - -#endif /* FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program || FEATURE_NV_vertex_program */ - -#if FEATURE_NV_vertex_program -static void GLAPIENTRY -save_ExecuteProgramNV(GLenum target, GLuint id, const GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_EXECUTE_PROGRAM_NV, 6); - if (n) { - n[1].e = target; - n[2].ui = id; - n[3].f = params[0]; - n[4].f = params[1]; - n[5].f = params[2]; - n[6].f = params[3]; - } - if (ctx->ExecuteFlag) { - CALL_ExecuteProgramNV(ctx->Exec, (target, id, params)); - } -} - - -static void GLAPIENTRY -save_ProgramParameters4dvNV(GLenum target, GLuint index, - GLsizei num, const GLdouble *params) -{ - GLint i; - for (i = 0; i < num; i++) { - save_ProgramEnvParameter4dvARB(target, index + i, params + 4 * i); - } -} - - -static void GLAPIENTRY -save_ProgramParameters4fvNV(GLenum target, GLuint index, - GLsizei num, const GLfloat *params) -{ - GLint i; - for (i = 0; i < num; i++) { - save_ProgramEnvParameter4fvARB(target, index + i, params + 4 * i); - } -} - - -static void GLAPIENTRY -save_LoadProgramNV(GLenum target, GLuint id, GLsizei len, - const GLubyte * program) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - - n = alloc_instruction(ctx, OPCODE_LOAD_PROGRAM_NV, 4); - if (n) { - GLubyte *programCopy = (GLubyte *) malloc(len); - if (!programCopy) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glLoadProgramNV"); - return; - } - memcpy(programCopy, program, len); - n[1].e = target; - n[2].ui = id; - n[3].i = len; - n[4].data = programCopy; - } - if (ctx->ExecuteFlag) { - CALL_LoadProgramNV(ctx->Exec, (target, id, len, program)); - } -} - - -static void GLAPIENTRY -save_RequestResidentProgramsNV(GLsizei num, const GLuint * ids) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - - n = alloc_instruction(ctx, OPCODE_TRACK_MATRIX_NV, 2); - if (n) { - GLuint *idCopy = (GLuint *) malloc(num * sizeof(GLuint)); - if (!idCopy) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glRequestResidentProgramsNV"); - return; - } - memcpy(idCopy, ids, num * sizeof(GLuint)); - n[1].i = num; - n[2].data = idCopy; - } - if (ctx->ExecuteFlag) { - CALL_RequestResidentProgramsNV(ctx->Exec, (num, ids)); - } -} - - -static void GLAPIENTRY -save_TrackMatrixNV(GLenum target, GLuint address, - GLenum matrix, GLenum transform) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_TRACK_MATRIX_NV, 4); - if (n) { - n[1].e = target; - n[2].ui = address; - n[3].e = matrix; - n[4].e = transform; - } - if (ctx->ExecuteFlag) { - CALL_TrackMatrixNV(ctx->Exec, (target, address, matrix, transform)); - } -} -#endif /* FEATURE_NV_vertex_program */ - - -/* - * GL_NV_fragment_program - */ -#if FEATURE_NV_fragment_program -static void GLAPIENTRY -save_ProgramLocalParameter4fARB(GLenum target, GLuint index, - GLfloat x, GLfloat y, GLfloat z, GLfloat w) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6); - if (n) { - n[1].e = target; - n[2].ui = index; - n[3].f = x; - n[4].f = y; - n[5].f = z; - n[6].f = w; - } - if (ctx->ExecuteFlag) { - CALL_ProgramLocalParameter4fARB(ctx->Exec, (target, index, x, y, z, w)); - } -} - - -static void GLAPIENTRY -save_ProgramLocalParameter4fvARB(GLenum target, GLuint index, - const GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6); - if (n) { - n[1].e = target; - n[2].ui = index; - n[3].f = params[0]; - n[4].f = params[1]; - n[5].f = params[2]; - n[6].f = params[3]; - } - if (ctx->ExecuteFlag) { - CALL_ProgramLocalParameter4fvARB(ctx->Exec, (target, index, params)); - } -} - - -static void GLAPIENTRY -save_ProgramLocalParameters4fvEXT(GLenum target, GLuint index, GLsizei count, - const GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - - if (count > 0) { - GLint i; - const GLfloat * p = params; - - for (i = 0 ; i < count ; i++) { - n = alloc_instruction(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6); - if (n) { - n[1].e = target; - n[2].ui = index; - n[3].f = p[0]; - n[4].f = p[1]; - n[5].f = p[2]; - n[6].f = p[3]; - p += 4; - } - } - } - - if (ctx->ExecuteFlag) { - CALL_ProgramLocalParameters4fvEXT(ctx->Exec, (target, index, count, params)); - } -} - - -static void GLAPIENTRY -save_ProgramLocalParameter4dARB(GLenum target, GLuint index, - GLdouble x, GLdouble y, - GLdouble z, GLdouble w) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6); - if (n) { - n[1].e = target; - n[2].ui = index; - n[3].f = (GLfloat) x; - n[4].f = (GLfloat) y; - n[5].f = (GLfloat) z; - n[6].f = (GLfloat) w; - } - if (ctx->ExecuteFlag) { - CALL_ProgramLocalParameter4dARB(ctx->Exec, (target, index, x, y, z, w)); - } -} - - -static void GLAPIENTRY -save_ProgramLocalParameter4dvARB(GLenum target, GLuint index, - const GLdouble *params) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6); - if (n) { - n[1].e = target; - n[2].ui = index; - n[3].f = (GLfloat) params[0]; - n[4].f = (GLfloat) params[1]; - n[5].f = (GLfloat) params[2]; - n[6].f = (GLfloat) params[3]; - } - if (ctx->ExecuteFlag) { - CALL_ProgramLocalParameter4dvARB(ctx->Exec, (target, index, params)); - } -} - -static void GLAPIENTRY -save_ProgramNamedParameter4fNV(GLuint id, GLsizei len, const GLubyte * name, - GLfloat x, GLfloat y, GLfloat z, GLfloat w) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - - n = alloc_instruction(ctx, OPCODE_PROGRAM_NAMED_PARAMETER_NV, 6); - if (n) { - GLubyte *nameCopy = (GLubyte *) malloc(len); - if (!nameCopy) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glProgramNamedParameter4fNV"); - return; - } - memcpy(nameCopy, name, len); - n[1].ui = id; - n[2].i = len; - n[3].data = nameCopy; - n[4].f = x; - n[5].f = y; - n[6].f = z; - n[7].f = w; - } - if (ctx->ExecuteFlag) { - CALL_ProgramNamedParameter4fNV(ctx->Exec, (id, len, name, x, y, z, w)); - } -} - - -static void GLAPIENTRY -save_ProgramNamedParameter4fvNV(GLuint id, GLsizei len, const GLubyte * name, - const float v[]) -{ - save_ProgramNamedParameter4fNV(id, len, name, v[0], v[1], v[2], v[3]); -} - - -static void GLAPIENTRY -save_ProgramNamedParameter4dNV(GLuint id, GLsizei len, const GLubyte * name, - GLdouble x, GLdouble y, GLdouble z, GLdouble w) -{ - save_ProgramNamedParameter4fNV(id, len, name, (GLfloat) x, (GLfloat) y, - (GLfloat) z, (GLfloat) w); -} - - -static void GLAPIENTRY -save_ProgramNamedParameter4dvNV(GLuint id, GLsizei len, const GLubyte * name, - const double v[]) -{ - save_ProgramNamedParameter4fNV(id, len, name, (GLfloat) v[0], - (GLfloat) v[1], (GLfloat) v[2], - (GLfloat) v[3]); -} - -#endif /* FEATURE_NV_fragment_program */ - - - -/* GL_EXT_stencil_two_side */ -static void GLAPIENTRY -save_ActiveStencilFaceEXT(GLenum face) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_ACTIVE_STENCIL_FACE_EXT, 1); - if (n) { - n[1].e = face; - } - if (ctx->ExecuteFlag) { - CALL_ActiveStencilFaceEXT(ctx->Exec, (face)); - } -} - - -/* GL_EXT_depth_bounds_test */ -static void GLAPIENTRY -save_DepthBoundsEXT(GLclampd zmin, GLclampd zmax) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_DEPTH_BOUNDS_EXT, 2); - if (n) { - n[1].f = (GLfloat) zmin; - n[2].f = (GLfloat) zmax; - } - if (ctx->ExecuteFlag) { - CALL_DepthBoundsEXT(ctx->Exec, (zmin, zmax)); - } -} - - - -#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program - -static void GLAPIENTRY -save_ProgramStringARB(GLenum target, GLenum format, GLsizei len, - const GLvoid * string) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - - n = alloc_instruction(ctx, OPCODE_PROGRAM_STRING_ARB, 4); - if (n) { - GLubyte *programCopy = (GLubyte *) malloc(len); - if (!programCopy) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glProgramStringARB"); - return; - } - memcpy(programCopy, string, len); - n[1].e = target; - n[2].e = format; - n[3].i = len; - n[4].data = programCopy; - } - if (ctx->ExecuteFlag) { - CALL_ProgramStringARB(ctx->Exec, (target, format, len, string)); - } -} - -#endif /* FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program */ - - -#if FEATURE_queryobj - -static void GLAPIENTRY -save_BeginQueryARB(GLenum target, GLuint id) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_BEGIN_QUERY_ARB, 2); - if (n) { - n[1].e = target; - n[2].ui = id; - } - if (ctx->ExecuteFlag) { - CALL_BeginQueryARB(ctx->Exec, (target, id)); - } -} - - -static void GLAPIENTRY -save_EndQueryARB(GLenum target) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_END_QUERY_ARB, 1); - if (n) { - n[1].e = target; - } - if (ctx->ExecuteFlag) { - CALL_EndQueryARB(ctx->Exec, (target)); - } -} - -#endif /* FEATURE_queryobj */ - - -static void GLAPIENTRY -save_DrawBuffersARB(GLsizei count, const GLenum * buffers) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_DRAW_BUFFERS_ARB, 1 + MAX_DRAW_BUFFERS); - if (n) { - GLint i; - n[1].i = count; - if (count > MAX_DRAW_BUFFERS) - count = MAX_DRAW_BUFFERS; - for (i = 0; i < count; i++) { - n[2 + i].e = buffers[i]; - } - } - if (ctx->ExecuteFlag) { - CALL_DrawBuffersARB(ctx->Exec, (count, buffers)); - } -} - -static void GLAPIENTRY -save_TexBumpParameterfvATI(GLenum pname, const GLfloat *param) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - - n = alloc_instruction(ctx, OPCODE_TEX_BUMP_PARAMETER_ATI, 5); - if (n) { - n[1].ui = pname; - n[2].f = param[0]; - n[3].f = param[1]; - n[4].f = param[2]; - n[5].f = param[3]; - } - if (ctx->ExecuteFlag) { - CALL_TexBumpParameterfvATI(ctx->Exec, (pname, param)); - } -} - -static void GLAPIENTRY -save_TexBumpParameterivATI(GLenum pname, const GLint *param) -{ - GLfloat p[4]; - p[0] = INT_TO_FLOAT(param[0]); - p[1] = INT_TO_FLOAT(param[1]); - p[2] = INT_TO_FLOAT(param[2]); - p[3] = INT_TO_FLOAT(param[3]); - save_TexBumpParameterfvATI(pname, p); -} - -#if FEATURE_ATI_fragment_shader -static void GLAPIENTRY -save_BindFragmentShaderATI(GLuint id) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - - n = alloc_instruction(ctx, OPCODE_BIND_FRAGMENT_SHADER_ATI, 1); - if (n) { - n[1].ui = id; - } - if (ctx->ExecuteFlag) { - CALL_BindFragmentShaderATI(ctx->Exec, (id)); - } -} - -static void GLAPIENTRY -save_SetFragmentShaderConstantATI(GLuint dst, const GLfloat *value) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - - n = alloc_instruction(ctx, OPCODE_SET_FRAGMENT_SHADER_CONSTANTS_ATI, 5); - if (n) { - n[1].ui = dst; - n[2].f = value[0]; - n[3].f = value[1]; - n[4].f = value[2]; - n[5].f = value[3]; - } - if (ctx->ExecuteFlag) { - CALL_SetFragmentShaderConstantATI(ctx->Exec, (dst, value)); - } -} -#endif - -static void GLAPIENTRY -save_Attr1fNV(GLenum attr, GLfloat x) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - SAVE_FLUSH_VERTICES(ctx); - n = alloc_instruction(ctx, OPCODE_ATTR_1F_NV, 2); - if (n) { - n[1].e = attr; - n[2].f = x; - } - - ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS); - ctx->ListState.ActiveAttribSize[attr] = 1; - ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, 0, 0, 1); - - if (ctx->ExecuteFlag) { - CALL_VertexAttrib1fNV(ctx->Exec, (attr, x)); - } -} - -static void GLAPIENTRY -save_Attr2fNV(GLenum attr, GLfloat x, GLfloat y) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - SAVE_FLUSH_VERTICES(ctx); - n = alloc_instruction(ctx, OPCODE_ATTR_2F_NV, 3); - if (n) { - n[1].e = attr; - n[2].f = x; - n[3].f = y; - } - - ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS); - ctx->ListState.ActiveAttribSize[attr] = 2; - ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, 0, 1); - - if (ctx->ExecuteFlag) { - CALL_VertexAttrib2fNV(ctx->Exec, (attr, x, y)); - } -} - -static void GLAPIENTRY -save_Attr3fNV(GLenum attr, GLfloat x, GLfloat y, GLfloat z) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - SAVE_FLUSH_VERTICES(ctx); - n = alloc_instruction(ctx, OPCODE_ATTR_3F_NV, 4); - if (n) { - n[1].e = attr; - n[2].f = x; - n[3].f = y; - n[4].f = z; - } - - ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS); - ctx->ListState.ActiveAttribSize[attr] = 3; - ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, z, 1); - - if (ctx->ExecuteFlag) { - CALL_VertexAttrib3fNV(ctx->Exec, (attr, x, y, z)); - } -} - -static void GLAPIENTRY -save_Attr4fNV(GLenum attr, GLfloat x, GLfloat y, GLfloat z, GLfloat w) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - SAVE_FLUSH_VERTICES(ctx); - n = alloc_instruction(ctx, OPCODE_ATTR_4F_NV, 5); - if (n) { - n[1].e = attr; - n[2].f = x; - n[3].f = y; - n[4].f = z; - n[5].f = w; - } - - ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS); - ctx->ListState.ActiveAttribSize[attr] = 4; - ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, z, w); - - if (ctx->ExecuteFlag) { - CALL_VertexAttrib4fNV(ctx->Exec, (attr, x, y, z, w)); - } -} - - -static void GLAPIENTRY -save_Attr1fARB(GLenum attr, GLfloat x) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - SAVE_FLUSH_VERTICES(ctx); - n = alloc_instruction(ctx, OPCODE_ATTR_1F_ARB, 2); - if (n) { - n[1].e = attr; - n[2].f = x; - } - - ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS); - ctx->ListState.ActiveAttribSize[attr] = 1; - ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, 0, 0, 1); - - if (ctx->ExecuteFlag) { - CALL_VertexAttrib1fARB(ctx->Exec, (attr, x)); - } -} - -static void GLAPIENTRY -save_Attr2fARB(GLenum attr, GLfloat x, GLfloat y) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - SAVE_FLUSH_VERTICES(ctx); - n = alloc_instruction(ctx, OPCODE_ATTR_2F_ARB, 3); - if (n) { - n[1].e = attr; - n[2].f = x; - n[3].f = y; - } - - ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS); - ctx->ListState.ActiveAttribSize[attr] = 2; - ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, 0, 1); - - if (ctx->ExecuteFlag) { - CALL_VertexAttrib2fARB(ctx->Exec, (attr, x, y)); - } -} - -static void GLAPIENTRY -save_Attr3fARB(GLenum attr, GLfloat x, GLfloat y, GLfloat z) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - SAVE_FLUSH_VERTICES(ctx); - n = alloc_instruction(ctx, OPCODE_ATTR_3F_ARB, 4); - if (n) { - n[1].e = attr; - n[2].f = x; - n[3].f = y; - n[4].f = z; - } - - ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS); - ctx->ListState.ActiveAttribSize[attr] = 3; - ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, z, 1); - - if (ctx->ExecuteFlag) { - CALL_VertexAttrib3fARB(ctx->Exec, (attr, x, y, z)); - } -} - -static void GLAPIENTRY -save_Attr4fARB(GLenum attr, GLfloat x, GLfloat y, GLfloat z, GLfloat w) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - SAVE_FLUSH_VERTICES(ctx); - n = alloc_instruction(ctx, OPCODE_ATTR_4F_ARB, 5); - if (n) { - n[1].e = attr; - n[2].f = x; - n[3].f = y; - n[4].f = z; - n[5].f = w; - } - - ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS); - ctx->ListState.ActiveAttribSize[attr] = 4; - ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, z, w); - - if (ctx->ExecuteFlag) { - CALL_VertexAttrib4fARB(ctx->Exec, (attr, x, y, z, w)); - } -} - - -static void GLAPIENTRY -save_EvalCoord1f(GLfloat x) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - SAVE_FLUSH_VERTICES(ctx); - n = alloc_instruction(ctx, OPCODE_EVAL_C1, 1); - if (n) { - n[1].f = x; - } - if (ctx->ExecuteFlag) { - CALL_EvalCoord1f(ctx->Exec, (x)); - } -} - -static void GLAPIENTRY -save_EvalCoord1fv(const GLfloat * v) -{ - save_EvalCoord1f(v[0]); -} - -static void GLAPIENTRY -save_EvalCoord2f(GLfloat x, GLfloat y) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - SAVE_FLUSH_VERTICES(ctx); - n = alloc_instruction(ctx, OPCODE_EVAL_C2, 2); - if (n) { - n[1].f = x; - n[2].f = y; - } - if (ctx->ExecuteFlag) { - CALL_EvalCoord2f(ctx->Exec, (x, y)); - } -} - -static void GLAPIENTRY -save_EvalCoord2fv(const GLfloat * v) -{ - save_EvalCoord2f(v[0], v[1]); -} - - -static void GLAPIENTRY -save_EvalPoint1(GLint x) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - SAVE_FLUSH_VERTICES(ctx); - n = alloc_instruction(ctx, OPCODE_EVAL_P1, 1); - if (n) { - n[1].i = x; - } - if (ctx->ExecuteFlag) { - CALL_EvalPoint1(ctx->Exec, (x)); - } -} - -static void GLAPIENTRY -save_EvalPoint2(GLint x, GLint y) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - SAVE_FLUSH_VERTICES(ctx); - n = alloc_instruction(ctx, OPCODE_EVAL_P2, 2); - if (n) { - n[1].i = x; - n[2].i = y; - } - if (ctx->ExecuteFlag) { - CALL_EvalPoint2(ctx->Exec, (x, y)); - } -} - -static void GLAPIENTRY -save_Indexf(GLfloat x) -{ - save_Attr1fNV(VERT_ATTRIB_COLOR_INDEX, x); -} - -static void GLAPIENTRY -save_Indexfv(const GLfloat * v) -{ - save_Attr1fNV(VERT_ATTRIB_COLOR_INDEX, v[0]); -} - -static void GLAPIENTRY -save_EdgeFlag(GLboolean x) -{ - save_Attr1fNV(VERT_ATTRIB_EDGEFLAG, x ? (GLfloat)1.0 : (GLfloat)0.0); -} - -static INLINE GLboolean compare4fv( const GLfloat *a, - const GLfloat *b, - GLuint count ) -{ - return memcmp( a, b, count * sizeof(GLfloat) ) == 0; -} - - -static void GLAPIENTRY -save_Materialfv(GLenum face, GLenum pname, const GLfloat * param) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - int args, i; - GLuint bitmask; - - switch (face) { - case GL_BACK: - case GL_FRONT: - case GL_FRONT_AND_BACK: - break; - default: - _mesa_compile_error(ctx, GL_INVALID_ENUM, "material(face)"); - return; - } - - switch (pname) { - case GL_EMISSION: - case GL_AMBIENT: - case GL_DIFFUSE: - case GL_SPECULAR: - case GL_AMBIENT_AND_DIFFUSE: - args = 4; - break; - case GL_SHININESS: - args = 1; - break; - case GL_COLOR_INDEXES: - args = 3; - break; - default: - _mesa_compile_error(ctx, GL_INVALID_ENUM, "material(pname)"); - return; - } - - if (ctx->ExecuteFlag) { - CALL_Materialfv(ctx->Exec, (face, pname, param)); - } - - bitmask = _mesa_material_bitmask(ctx, face, pname, ~0, NULL); - - /* Try to eliminate redundant statechanges. Because it is legal to - * call glMaterial even inside begin/end calls, don't need to worry - * about ctx->Driver.CurrentSavePrimitive here. - */ - for (i = 0; i < MAT_ATTRIB_MAX; i++) { - if (bitmask & (1 << i)) { - if (ctx->ListState.ActiveMaterialSize[i] == args && - compare4fv(ctx->ListState.CurrentMaterial[i], param, args)) { - bitmask &= ~(1 << i); - } - else { - ctx->ListState.ActiveMaterialSize[i] = args; - COPY_SZ_4V(ctx->ListState.CurrentMaterial[i], args, param); - } - } - } - - /* If this call has effect, return early: - */ - if (bitmask == 0) - return; - - SAVE_FLUSH_VERTICES(ctx); - - n = alloc_instruction(ctx, OPCODE_MATERIAL, 6); - if (n) { - n[1].e = face; - n[2].e = pname; - for (i = 0; i < args; i++) - n[3 + i].f = param[i]; - } -} - -static void GLAPIENTRY -save_Begin(GLenum mode) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - GLboolean error = GL_FALSE; - - if ( /*mode < GL_POINTS || */ mode > GL_POLYGON) { - _mesa_compile_error(ctx, GL_INVALID_ENUM, "Begin (mode)"); - error = GL_TRUE; - } - else if (ctx->Driver.CurrentSavePrimitive == PRIM_UNKNOWN) { - /* Typically the first begin. This may raise an error on - * playback, depending on whether CallList is issued from inside - * a begin/end or not. - */ - ctx->Driver.CurrentSavePrimitive = PRIM_INSIDE_UNKNOWN_PRIM; - } - else if (ctx->Driver.CurrentSavePrimitive == PRIM_OUTSIDE_BEGIN_END) { - ctx->Driver.CurrentSavePrimitive = mode; - } - else { - _mesa_compile_error(ctx, GL_INVALID_OPERATION, "recursive begin"); - error = GL_TRUE; - } - - if (!error) { - /* Give the driver an opportunity to hook in an optimized - * display list compiler. - */ - if (ctx->Driver.NotifySaveBegin(ctx, mode)) - return; - - SAVE_FLUSH_VERTICES(ctx); - n = alloc_instruction(ctx, OPCODE_BEGIN, 1); - if (n) { - n[1].e = mode; - } - } - - if (ctx->ExecuteFlag) { - CALL_Begin(ctx->Exec, (mode)); - } -} - -static void GLAPIENTRY -save_End(void) -{ - GET_CURRENT_CONTEXT(ctx); - SAVE_FLUSH_VERTICES(ctx); - (void) alloc_instruction(ctx, OPCODE_END, 0); - ctx->Driver.CurrentSavePrimitive = PRIM_OUTSIDE_BEGIN_END; - if (ctx->ExecuteFlag) { - CALL_End(ctx->Exec, ()); - } -} - -static void GLAPIENTRY -save_Rectf(GLfloat a, GLfloat b, GLfloat c, GLfloat d) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - SAVE_FLUSH_VERTICES(ctx); - n = alloc_instruction(ctx, OPCODE_RECTF, 4); - if (n) { - n[1].f = a; - n[2].f = b; - n[3].f = c; - n[4].f = d; - } - if (ctx->ExecuteFlag) { - CALL_Rectf(ctx->Exec, (a, b, c, d)); - } -} - - -static void GLAPIENTRY -save_Vertex2f(GLfloat x, GLfloat y) -{ - save_Attr2fNV(VERT_ATTRIB_POS, x, y); -} - -static void GLAPIENTRY -save_Vertex2fv(const GLfloat * v) -{ - save_Attr2fNV(VERT_ATTRIB_POS, v[0], v[1]); -} - -static void GLAPIENTRY -save_Vertex3f(GLfloat x, GLfloat y, GLfloat z) -{ - save_Attr3fNV(VERT_ATTRIB_POS, x, y, z); -} - -static void GLAPIENTRY -save_Vertex3fv(const GLfloat * v) -{ - save_Attr3fNV(VERT_ATTRIB_POS, v[0], v[1], v[2]); -} - -static void GLAPIENTRY -save_Vertex4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w) -{ - save_Attr4fNV(VERT_ATTRIB_POS, x, y, z, w); -} - -static void GLAPIENTRY -save_Vertex4fv(const GLfloat * v) -{ - save_Attr4fNV(VERT_ATTRIB_POS, v[0], v[1], v[2], v[3]); -} - -static void GLAPIENTRY -save_TexCoord1f(GLfloat x) -{ - save_Attr1fNV(VERT_ATTRIB_TEX0, x); -} - -static void GLAPIENTRY -save_TexCoord1fv(const GLfloat * v) -{ - save_Attr1fNV(VERT_ATTRIB_TEX0, v[0]); -} - -static void GLAPIENTRY -save_TexCoord2f(GLfloat x, GLfloat y) -{ - save_Attr2fNV(VERT_ATTRIB_TEX0, x, y); -} - -static void GLAPIENTRY -save_TexCoord2fv(const GLfloat * v) -{ - save_Attr2fNV(VERT_ATTRIB_TEX0, v[0], v[1]); -} - -static void GLAPIENTRY -save_TexCoord3f(GLfloat x, GLfloat y, GLfloat z) -{ - save_Attr3fNV(VERT_ATTRIB_TEX0, x, y, z); -} - -static void GLAPIENTRY -save_TexCoord3fv(const GLfloat * v) -{ - save_Attr3fNV(VERT_ATTRIB_TEX0, v[0], v[1], v[2]); -} - -static void GLAPIENTRY -save_TexCoord4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w) -{ - save_Attr4fNV(VERT_ATTRIB_TEX0, x, y, z, w); -} - -static void GLAPIENTRY -save_TexCoord4fv(const GLfloat * v) -{ - save_Attr4fNV(VERT_ATTRIB_TEX0, v[0], v[1], v[2], v[3]); -} - -static void GLAPIENTRY -save_Normal3f(GLfloat x, GLfloat y, GLfloat z) -{ - save_Attr3fNV(VERT_ATTRIB_NORMAL, x, y, z); -} - -static void GLAPIENTRY -save_Normal3fv(const GLfloat * v) -{ - save_Attr3fNV(VERT_ATTRIB_NORMAL, v[0], v[1], v[2]); -} - -static void GLAPIENTRY -save_FogCoordfEXT(GLfloat x) -{ - save_Attr1fNV(VERT_ATTRIB_FOG, x); -} - -static void GLAPIENTRY -save_FogCoordfvEXT(const GLfloat * v) -{ - save_Attr1fNV(VERT_ATTRIB_FOG, v[0]); -} - -static void GLAPIENTRY -save_Color3f(GLfloat x, GLfloat y, GLfloat z) -{ - save_Attr3fNV(VERT_ATTRIB_COLOR0, x, y, z); -} - -static void GLAPIENTRY -save_Color3fv(const GLfloat * v) -{ - save_Attr3fNV(VERT_ATTRIB_COLOR0, v[0], v[1], v[2]); -} - -static void GLAPIENTRY -save_Color4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w) -{ - save_Attr4fNV(VERT_ATTRIB_COLOR0, x, y, z, w); -} - -static void GLAPIENTRY -save_Color4fv(const GLfloat * v) -{ - save_Attr4fNV(VERT_ATTRIB_COLOR0, v[0], v[1], v[2], v[3]); -} - -static void GLAPIENTRY -save_SecondaryColor3fEXT(GLfloat x, GLfloat y, GLfloat z) -{ - save_Attr3fNV(VERT_ATTRIB_COLOR1, x, y, z); -} - -static void GLAPIENTRY -save_SecondaryColor3fvEXT(const GLfloat * v) -{ - save_Attr3fNV(VERT_ATTRIB_COLOR1, v[0], v[1], v[2]); -} - - -/* Just call the respective ATTR for texcoord - */ -static void GLAPIENTRY -save_MultiTexCoord1f(GLenum target, GLfloat x) -{ - GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0; - save_Attr1fNV(attr, x); -} - -static void GLAPIENTRY -save_MultiTexCoord1fv(GLenum target, const GLfloat * v) -{ - GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0; - save_Attr1fNV(attr, v[0]); -} - -static void GLAPIENTRY -save_MultiTexCoord2f(GLenum target, GLfloat x, GLfloat y) -{ - GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0; - save_Attr2fNV(attr, x, y); -} - -static void GLAPIENTRY -save_MultiTexCoord2fv(GLenum target, const GLfloat * v) -{ - GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0; - save_Attr2fNV(attr, v[0], v[1]); -} - -static void GLAPIENTRY -save_MultiTexCoord3f(GLenum target, GLfloat x, GLfloat y, GLfloat z) -{ - GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0; - save_Attr3fNV(attr, x, y, z); -} - -static void GLAPIENTRY -save_MultiTexCoord3fv(GLenum target, const GLfloat * v) -{ - GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0; - save_Attr3fNV(attr, v[0], v[1], v[2]); -} - -static void GLAPIENTRY -save_MultiTexCoord4f(GLenum target, GLfloat x, GLfloat y, - GLfloat z, GLfloat w) -{ - GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0; - save_Attr4fNV(attr, x, y, z, w); -} - -static void GLAPIENTRY -save_MultiTexCoord4fv(GLenum target, const GLfloat * v) -{ - GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0; - save_Attr4fNV(attr, v[0], v[1], v[2], v[3]); -} - - -/** - * Record a GL_INVALID_VALUE error when a invalid vertex attribute - * index is found. - */ -static void -index_error(void) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_error(ctx, GL_INVALID_VALUE, "VertexAttribf(index)"); -} - - -/* First level for NV_vertex_program: - * - * Check for errors at compile time?. - */ -static void GLAPIENTRY -save_VertexAttrib1fNV(GLuint index, GLfloat x) -{ - if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) - save_Attr1fNV(index, x); - else - index_error(); -} - -static void GLAPIENTRY -save_VertexAttrib1fvNV(GLuint index, const GLfloat * v) -{ - if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) - save_Attr1fNV(index, v[0]); - else - index_error(); -} - -static void GLAPIENTRY -save_VertexAttrib2fNV(GLuint index, GLfloat x, GLfloat y) -{ - if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) - save_Attr2fNV(index, x, y); - else - index_error(); -} - -static void GLAPIENTRY -save_VertexAttrib2fvNV(GLuint index, const GLfloat * v) -{ - if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) - save_Attr2fNV(index, v[0], v[1]); - else - index_error(); -} - -static void GLAPIENTRY -save_VertexAttrib3fNV(GLuint index, GLfloat x, GLfloat y, GLfloat z) -{ - if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) - save_Attr3fNV(index, x, y, z); - else - index_error(); -} - -static void GLAPIENTRY -save_VertexAttrib3fvNV(GLuint index, const GLfloat * v) -{ - if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) - save_Attr3fNV(index, v[0], v[1], v[2]); - else - index_error(); -} - -static void GLAPIENTRY -save_VertexAttrib4fNV(GLuint index, GLfloat x, GLfloat y, - GLfloat z, GLfloat w) -{ - if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) - save_Attr4fNV(index, x, y, z, w); - else - index_error(); -} - -static void GLAPIENTRY -save_VertexAttrib4fvNV(GLuint index, const GLfloat * v) -{ - if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) - save_Attr4fNV(index, v[0], v[1], v[2], v[3]); - else - index_error(); -} - - - - -static void GLAPIENTRY -save_VertexAttrib1fARB(GLuint index, GLfloat x) -{ - if (index < MAX_VERTEX_GENERIC_ATTRIBS) - save_Attr1fARB(index, x); - else - index_error(); -} - -static void GLAPIENTRY -save_VertexAttrib1fvARB(GLuint index, const GLfloat * v) -{ - if (index < MAX_VERTEX_GENERIC_ATTRIBS) - save_Attr1fARB(index, v[0]); - else - index_error(); -} - -static void GLAPIENTRY -save_VertexAttrib2fARB(GLuint index, GLfloat x, GLfloat y) -{ - if (index < MAX_VERTEX_GENERIC_ATTRIBS) - save_Attr2fARB(index, x, y); - else - index_error(); -} - -static void GLAPIENTRY -save_VertexAttrib2fvARB(GLuint index, const GLfloat * v) -{ - if (index < MAX_VERTEX_GENERIC_ATTRIBS) - save_Attr2fARB(index, v[0], v[1]); - else - index_error(); -} - -static void GLAPIENTRY -save_VertexAttrib3fARB(GLuint index, GLfloat x, GLfloat y, GLfloat z) -{ - if (index < MAX_VERTEX_GENERIC_ATTRIBS) - save_Attr3fARB(index, x, y, z); - else - index_error(); -} - -static void GLAPIENTRY -save_VertexAttrib3fvARB(GLuint index, const GLfloat * v) -{ - if (index < MAX_VERTEX_GENERIC_ATTRIBS) - save_Attr3fARB(index, v[0], v[1], v[2]); - else - index_error(); -} - -static void GLAPIENTRY -save_VertexAttrib4fARB(GLuint index, GLfloat x, GLfloat y, GLfloat z, - GLfloat w) -{ - if (index < MAX_VERTEX_GENERIC_ATTRIBS) - save_Attr4fARB(index, x, y, z, w); - else - index_error(); -} - -static void GLAPIENTRY -save_VertexAttrib4fvARB(GLuint index, const GLfloat * v) -{ - if (index < MAX_VERTEX_GENERIC_ATTRIBS) - save_Attr4fARB(index, v[0], v[1], v[2], v[3]); - else - index_error(); -} - - -/* GL_ARB_shader_objects, GL_ARB_vertex/fragment_shader */ - -static void GLAPIENTRY -exec_BindAttribLocationARB(GLuint program, GLuint index, const GLchar *name) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_BindAttribLocationARB(ctx->Exec, (program, index, name)); -} - -static GLint GLAPIENTRY -exec_GetAttribLocationARB(GLuint program, const GLchar *name) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - return CALL_GetAttribLocationARB(ctx->Exec, (program, name)); -} - -static GLint GLAPIENTRY -exec_GetUniformLocationARB(GLuint program, const GLchar *name) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - return CALL_GetUniformLocationARB(ctx->Exec, (program, name)); -} -/* XXX more shader functions needed here */ - - -#if FEATURE_EXT_framebuffer_blit -static void GLAPIENTRY -save_BlitFramebufferEXT(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, - GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, - GLbitfield mask, GLenum filter) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_BLIT_FRAMEBUFFER, 10); - if (n) { - n[1].i = srcX0; - n[2].i = srcY0; - n[3].i = srcX1; - n[4].i = srcY1; - n[5].i = dstX0; - n[6].i = dstY0; - n[7].i = dstX1; - n[8].i = dstY1; - n[9].i = mask; - n[10].e = filter; - } - if (ctx->ExecuteFlag) { - CALL_BlitFramebufferEXT(ctx->Exec, (srcX0, srcY0, srcX1, srcY1, - dstX0, dstY0, dstX1, dstY1, - mask, filter)); - } -} -#endif - - -/** GL_EXT_provoking_vertex */ -static void GLAPIENTRY -save_ProvokingVertexEXT(GLenum mode) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_PROVOKING_VERTEX, 1); - if (n) { - n[1].e = mode; - } - if (ctx->ExecuteFlag) { - /*CALL_ProvokingVertexEXT(ctx->Exec, (mode));*/ - _mesa_ProvokingVertexEXT(mode); - } -} - - -/** GL_EXT_transform_feedback */ -static void GLAPIENTRY -save_BeginTransformFeedback(GLenum mode) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_BEGIN_TRANSFORM_FEEDBACK, 1); - if (n) { - n[1].e = mode; - } - if (ctx->ExecuteFlag) { - CALL_BeginTransformFeedbackEXT(ctx->Exec, (mode)); - } -} - - -/** GL_EXT_transform_feedback */ -static void GLAPIENTRY -save_EndTransformFeedback(void) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - (void) alloc_instruction(ctx, OPCODE_END_TRANSFORM_FEEDBACK, 0); - if (ctx->ExecuteFlag) { - CALL_EndTransformFeedbackEXT(ctx->Exec, ()); - } -} - -static void GLAPIENTRY -save_TransformFeedbackVaryings(GLuint program, GLsizei count, - const GLchar **varyings, GLenum bufferMode) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_problem(ctx, - "glTransformFeedbackVarying() display list support not done"); -} - -static void GLAPIENTRY -save_BindTransformFeedback(GLenum target, GLuint name) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_BIND_TRANSFORM_FEEDBACK, 2); - if (n) { - n[1].e = target; - n[2].ui = name; - } - if (ctx->ExecuteFlag) { - CALL_BindTransformFeedback(ctx->Exec, (target, name)); - } -} - -static void GLAPIENTRY -save_PauseTransformFeedback(void) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - (void) alloc_instruction(ctx, OPCODE_PAUSE_TRANSFORM_FEEDBACK, 0); - if (ctx->ExecuteFlag) { - CALL_PauseTransformFeedback(ctx->Exec, ()); - } -} - -static void GLAPIENTRY -save_ResumeTransformFeedback(void) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - (void) alloc_instruction(ctx, OPCODE_RESUME_TRANSFORM_FEEDBACK, 0); - if (ctx->ExecuteFlag) { - CALL_ResumeTransformFeedback(ctx->Exec, ()); - } -} - -static void GLAPIENTRY -save_DrawTransformFeedback(GLenum mode, GLuint name) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_DRAW_TRANSFORM_FEEDBACK, 2); - if (n) { - n[1].e = mode; - n[2].ui = name; - } - if (ctx->ExecuteFlag) { - CALL_DrawTransformFeedback(ctx->Exec, (mode, name)); - } -} - - -/* aka UseProgram() */ -static void GLAPIENTRY -save_UseProgramObjectARB(GLhandleARB program) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_USE_PROGRAM, 1); - if (n) { - n[1].ui = program; - } - if (ctx->ExecuteFlag) { - CALL_UseProgramObjectARB(ctx->Exec, (program)); - } -} - - -static void GLAPIENTRY -save_Uniform1fARB(GLint location, GLfloat x) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_1F, 2); - if (n) { - n[1].i = location; - n[2].f = x; - } - if (ctx->ExecuteFlag) { - CALL_Uniform1fARB(ctx->Exec, (location, x)); - } -} - - -static void GLAPIENTRY -save_Uniform2fARB(GLint location, GLfloat x, GLfloat y) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_2F, 3); - if (n) { - n[1].i = location; - n[2].f = x; - n[3].f = y; - } - if (ctx->ExecuteFlag) { - CALL_Uniform2fARB(ctx->Exec, (location, x, y)); - } -} - - -static void GLAPIENTRY -save_Uniform3fARB(GLint location, GLfloat x, GLfloat y, GLfloat z) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_3F, 4); - if (n) { - n[1].i = location; - n[2].f = x; - n[3].f = y; - n[4].f = z; - } - if (ctx->ExecuteFlag) { - CALL_Uniform3fARB(ctx->Exec, (location, x, y, z)); - } -} - - -static void GLAPIENTRY -save_Uniform4fARB(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_4F, 5); - if (n) { - n[1].i = location; - n[2].f = x; - n[3].f = y; - n[4].f = z; - n[5].f = w; - } - if (ctx->ExecuteFlag) { - CALL_Uniform4fARB(ctx->Exec, (location, x, y, z, w)); - } -} - - -/** Return copy of memory */ -static void * -memdup(const void *src, GLsizei bytes) -{ - void *b = bytes >= 0 ? malloc(bytes) : NULL; - if (b) - memcpy(b, src, bytes); - return b; -} - - -static void GLAPIENTRY -save_Uniform1fvARB(GLint location, GLsizei count, const GLfloat *v) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_1FV, 3); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].data = memdup(v, count * 1 * sizeof(GLfloat)); - } - if (ctx->ExecuteFlag) { - CALL_Uniform1fvARB(ctx->Exec, (location, count, v)); - } -} - -static void GLAPIENTRY -save_Uniform2fvARB(GLint location, GLsizei count, const GLfloat *v) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_2FV, 3); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].data = memdup(v, count * 2 * sizeof(GLfloat)); - } - if (ctx->ExecuteFlag) { - CALL_Uniform2fvARB(ctx->Exec, (location, count, v)); - } -} - -static void GLAPIENTRY -save_Uniform3fvARB(GLint location, GLsizei count, const GLfloat *v) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_3FV, 3); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].data = memdup(v, count * 3 * sizeof(GLfloat)); - } - if (ctx->ExecuteFlag) { - CALL_Uniform3fvARB(ctx->Exec, (location, count, v)); - } -} - -static void GLAPIENTRY -save_Uniform4fvARB(GLint location, GLsizei count, const GLfloat *v) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_4FV, 3); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].data = memdup(v, count * 4 * sizeof(GLfloat)); - } - if (ctx->ExecuteFlag) { - CALL_Uniform4fvARB(ctx->Exec, (location, count, v)); - } -} - - -static void GLAPIENTRY -save_Uniform1iARB(GLint location, GLint x) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_1I, 2); - if (n) { - n[1].i = location; - n[2].i = x; - } - if (ctx->ExecuteFlag) { - CALL_Uniform1iARB(ctx->Exec, (location, x)); - } -} - -static void GLAPIENTRY -save_Uniform2iARB(GLint location, GLint x, GLint y) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_2I, 3); - if (n) { - n[1].i = location; - n[2].i = x; - n[3].i = y; - } - if (ctx->ExecuteFlag) { - CALL_Uniform2iARB(ctx->Exec, (location, x, y)); - } -} - -static void GLAPIENTRY -save_Uniform3iARB(GLint location, GLint x, GLint y, GLint z) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_3I, 4); - if (n) { - n[1].i = location; - n[2].i = x; - n[3].i = y; - n[4].i = z; - } - if (ctx->ExecuteFlag) { - CALL_Uniform3iARB(ctx->Exec, (location, x, y, z)); - } -} - -static void GLAPIENTRY -save_Uniform4iARB(GLint location, GLint x, GLint y, GLint z, GLint w) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_4I, 5); - if (n) { - n[1].i = location; - n[2].i = x; - n[3].i = y; - n[4].i = z; - n[5].i = w; - } - if (ctx->ExecuteFlag) { - CALL_Uniform4iARB(ctx->Exec, (location, x, y, z, w)); - } -} - - - -static void GLAPIENTRY -save_Uniform1ivARB(GLint location, GLsizei count, const GLint *v) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_1IV, 3); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].data = memdup(v, count * 1 * sizeof(GLint)); - } - if (ctx->ExecuteFlag) { - CALL_Uniform1ivARB(ctx->Exec, (location, count, v)); - } -} - -static void GLAPIENTRY -save_Uniform2ivARB(GLint location, GLsizei count, const GLint *v) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_2IV, 3); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].data = memdup(v, count * 2 * sizeof(GLint)); - } - if (ctx->ExecuteFlag) { - CALL_Uniform2ivARB(ctx->Exec, (location, count, v)); - } -} - -static void GLAPIENTRY -save_Uniform3ivARB(GLint location, GLsizei count, const GLint *v) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_3IV, 3); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].data = memdup(v, count * 3 * sizeof(GLint)); - } - if (ctx->ExecuteFlag) { - CALL_Uniform3ivARB(ctx->Exec, (location, count, v)); - } -} - -static void GLAPIENTRY -save_Uniform4ivARB(GLint location, GLsizei count, const GLint *v) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_4IV, 3); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].data = memdup(v, count * 4 * sizeof(GLfloat)); - } - if (ctx->ExecuteFlag) { - CALL_Uniform4ivARB(ctx->Exec, (location, count, v)); - } -} - - - -static void GLAPIENTRY -save_Uniform1ui(GLint location, GLuint x) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_1UI, 2); - if (n) { - n[1].i = location; - n[2].i = x; - } - if (ctx->ExecuteFlag) { - /*CALL_Uniform1ui(ctx->Exec, (location, x));*/ - } -} - -static void GLAPIENTRY -save_Uniform2ui(GLint location, GLuint x, GLuint y) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_2UI, 3); - if (n) { - n[1].i = location; - n[2].i = x; - n[3].i = y; - } - if (ctx->ExecuteFlag) { - /*CALL_Uniform2ui(ctx->Exec, (location, x, y));*/ - } -} - -static void GLAPIENTRY -save_Uniform3ui(GLint location, GLuint x, GLuint y, GLuint z) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_3UI, 4); - if (n) { - n[1].i = location; - n[2].i = x; - n[3].i = y; - n[4].i = z; - } - if (ctx->ExecuteFlag) { - /*CALL_Uniform3ui(ctx->Exec, (location, x, y, z));*/ - } -} - -static void GLAPIENTRY -save_Uniform4ui(GLint location, GLuint x, GLuint y, GLuint z, GLuint w) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_4UI, 5); - if (n) { - n[1].i = location; - n[2].i = x; - n[3].i = y; - n[4].i = z; - n[5].i = w; - } - if (ctx->ExecuteFlag) { - /*CALL_Uniform4ui(ctx->Exec, (location, x, y, z, w));*/ - } -} - - - -static void GLAPIENTRY -save_Uniform1uiv(GLint location, GLsizei count, const GLuint *v) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_1UIV, 3); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].data = memdup(v, count * 1 * sizeof(*v)); - } - if (ctx->ExecuteFlag) { - /*CALL_Uniform1uiv(ctx->Exec, (location, count, v));*/ - } -} - -static void GLAPIENTRY -save_Uniform2uiv(GLint location, GLsizei count, const GLuint *v) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_2UIV, 3); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].data = memdup(v, count * 2 * sizeof(*v)); - } - if (ctx->ExecuteFlag) { - /*CALL_Uniform2uiv(ctx->Exec, (location, count, v));*/ - } -} - -static void GLAPIENTRY -save_Uniform3uiv(GLint location, GLsizei count, const GLuint *v) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_3UIV, 3); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].data = memdup(v, count * 3 * sizeof(*v)); - } - if (ctx->ExecuteFlag) { - /*CALL_Uniform3uiv(ctx->Exec, (location, count, v));*/ - } -} - -static void GLAPIENTRY -save_Uniform4uiv(GLint location, GLsizei count, const GLuint *v) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_4UIV, 3); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].data = memdup(v, count * 4 * sizeof(*v)); - } - if (ctx->ExecuteFlag) { - /*CALL_Uniform4uiv(ctx->Exec, (location, count, v));*/ - } -} - - - -static void GLAPIENTRY -save_UniformMatrix2fvARB(GLint location, GLsizei count, GLboolean transpose, - const GLfloat *m) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX22, 4); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].b = transpose; - n[4].data = memdup(m, count * 2 * 2 * sizeof(GLfloat)); - } - if (ctx->ExecuteFlag) { - CALL_UniformMatrix2fvARB(ctx->Exec, (location, count, transpose, m)); - } -} - -static void GLAPIENTRY -save_UniformMatrix3fvARB(GLint location, GLsizei count, GLboolean transpose, - const GLfloat *m) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX33, 4); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].b = transpose; - n[4].data = memdup(m, count * 3 * 3 * sizeof(GLfloat)); - } - if (ctx->ExecuteFlag) { - CALL_UniformMatrix3fvARB(ctx->Exec, (location, count, transpose, m)); - } -} - -static void GLAPIENTRY -save_UniformMatrix4fvARB(GLint location, GLsizei count, GLboolean transpose, - const GLfloat *m) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX44, 4); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].b = transpose; - n[4].data = memdup(m, count * 4 * 4 * sizeof(GLfloat)); - } - if (ctx->ExecuteFlag) { - CALL_UniformMatrix4fvARB(ctx->Exec, (location, count, transpose, m)); - } -} - - -static void GLAPIENTRY -save_UniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, - const GLfloat *m) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX23, 4); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].b = transpose; - n[4].data = memdup(m, count * 2 * 3 * sizeof(GLfloat)); - } - if (ctx->ExecuteFlag) { - CALL_UniformMatrix2x3fv(ctx->Exec, (location, count, transpose, m)); - } -} - -static void GLAPIENTRY -save_UniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, - const GLfloat *m) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX32, 4); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].b = transpose; - n[4].data = memdup(m, count * 3 * 2 * sizeof(GLfloat)); - } - if (ctx->ExecuteFlag) { - CALL_UniformMatrix3x2fv(ctx->Exec, (location, count, transpose, m)); - } -} - - -static void GLAPIENTRY -save_UniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, - const GLfloat *m) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX24, 4); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].b = transpose; - n[4].data = memdup(m, count * 2 * 4 * sizeof(GLfloat)); - } - if (ctx->ExecuteFlag) { - CALL_UniformMatrix2x4fv(ctx->Exec, (location, count, transpose, m)); - } -} - -static void GLAPIENTRY -save_UniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, - const GLfloat *m) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX42, 4); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].b = transpose; - n[4].data = memdup(m, count * 4 * 2 * sizeof(GLfloat)); - } - if (ctx->ExecuteFlag) { - CALL_UniformMatrix4x2fv(ctx->Exec, (location, count, transpose, m)); - } -} - - -static void GLAPIENTRY -save_UniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, - const GLfloat *m) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX34, 4); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].b = transpose; - n[4].data = memdup(m, count * 3 * 4 * sizeof(GLfloat)); - } - if (ctx->ExecuteFlag) { - CALL_UniformMatrix3x4fv(ctx->Exec, (location, count, transpose, m)); - } -} - -static void GLAPIENTRY -save_UniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, - const GLfloat *m) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX43, 4); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].b = transpose; - n[4].data = memdup(m, count * 4 * 3 * sizeof(GLfloat)); - } - if (ctx->ExecuteFlag) { - CALL_UniformMatrix4x3fv(ctx->Exec, (location, count, transpose, m)); - } -} - -static void GLAPIENTRY -save_ClampColorARB(GLenum target, GLenum clamp) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_CLAMP_COLOR, 2); - if (n) { - n[1].e = target; - n[2].e = clamp; - } - if (ctx->ExecuteFlag) { - CALL_ClampColorARB(ctx->Exec, (target, clamp)); - } -} - -static void GLAPIENTRY -save_UseShaderProgramEXT(GLenum type, GLuint program) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_USE_SHADER_PROGRAM_EXT, 2); - if (n) { - n[1].ui = type; - n[2].ui = program; - } - if (ctx->ExecuteFlag) { - CALL_UseShaderProgramEXT(ctx->Exec, (type, program)); - } -} - -static void GLAPIENTRY -save_ActiveProgramEXT(GLuint program) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_ACTIVE_PROGRAM_EXT, 1); - if (n) { - n[1].ui = program; - } - if (ctx->ExecuteFlag) { - CALL_ActiveProgramEXT(ctx->Exec, (program)); - } -} - -/** GL_EXT_texture_integer */ -static void GLAPIENTRY -save_ClearColorIi(GLint red, GLint green, GLint blue, GLint alpha) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_CLEARCOLOR_I, 4); - if (n) { - n[1].i = red; - n[2].i = green; - n[3].i = blue; - n[4].i = alpha; - } - if (ctx->ExecuteFlag) { - CALL_ClearColorIiEXT(ctx->Exec, (red, green, blue, alpha)); - } -} - -/** GL_EXT_texture_integer */ -static void GLAPIENTRY -save_ClearColorIui(GLuint red, GLuint green, GLuint blue, GLuint alpha) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_CLEARCOLOR_UI, 4); - if (n) { - n[1].ui = red; - n[2].ui = green; - n[3].ui = blue; - n[4].ui = alpha; - } - if (ctx->ExecuteFlag) { - CALL_ClearColorIuiEXT(ctx->Exec, (red, green, blue, alpha)); - } -} - -/** GL_EXT_texture_integer */ -static void GLAPIENTRY -save_TexParameterIiv(GLenum target, GLenum pname, const GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_TEXPARAMETER_I, 6); - if (n) { - n[1].e = target; - n[2].e = pname; - n[3].i = params[0]; - n[4].i = params[1]; - n[5].i = params[2]; - n[6].i = params[3]; - } - if (ctx->ExecuteFlag) { - CALL_TexParameterIivEXT(ctx->Exec, (target, pname, params)); - } -} - -/** GL_EXT_texture_integer */ -static void GLAPIENTRY -save_TexParameterIuiv(GLenum target, GLenum pname, const GLuint *params) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_TEXPARAMETER_UI, 6); - if (n) { - n[1].e = target; - n[2].e = pname; - n[3].ui = params[0]; - n[4].ui = params[1]; - n[5].ui = params[2]; - n[6].ui = params[3]; - } - if (ctx->ExecuteFlag) { - CALL_TexParameterIuivEXT(ctx->Exec, (target, pname, params)); - } -} - -/** GL_EXT_texture_integer */ -static void GLAPIENTRY -exec_GetTexParameterIiv(GLenum target, GLenum pname, GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetTexParameterIivEXT(ctx->Exec, (target, pname, params)); -} - -/** GL_EXT_texture_integer */ -static void GLAPIENTRY -exec_GetTexParameterIuiv(GLenum target, GLenum pname, GLuint *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetTexParameterIuivEXT(ctx->Exec, (target, pname, params)); -} - - -/* GL_ARB_instanced_arrays */ -static void GLAPIENTRY -save_VertexAttribDivisor(GLuint index, GLuint divisor) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_VERTEX_ATTRIB_DIVISOR, 2); - if (n) { - n[1].ui = index; - n[2].ui = divisor; - } - if (ctx->ExecuteFlag) { - CALL_VertexAttribDivisorARB(ctx->Exec, (index, divisor)); - } -} - - -/* GL_NV_texture_barrier */ -static void GLAPIENTRY -save_TextureBarrierNV(void) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - alloc_instruction(ctx, OPCODE_TEXTURE_BARRIER_NV, 0); - if (ctx->ExecuteFlag) { - CALL_TextureBarrierNV(ctx->Exec, ()); - } -} - - -/* GL_ARB_sampler_objects */ -static void GLAPIENTRY -save_BindSampler(GLuint unit, GLuint sampler) -{ - Node *n; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_BIND_SAMPLER, 2); - if (n) { - n[1].ui = unit; - n[2].ui = sampler; - } - if (ctx->ExecuteFlag) { - CALL_BindSampler(ctx->Exec, (unit, sampler)); - } -} - -static void GLAPIENTRY -save_SamplerParameteriv(GLuint sampler, GLenum pname, const GLint *params) -{ - Node *n; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_SAMPLER_PARAMETERIV, 6); - if (n) { - n[1].ui = sampler; - n[2].e = pname; - n[3].i = params[0]; - if (pname == GL_TEXTURE_BORDER_COLOR) { - n[4].i = params[1]; - n[5].i = params[2]; - n[6].i = params[3]; - } - else { - n[4].i = n[5].i = n[6].i = 0; - } - } - if (ctx->ExecuteFlag) { - CALL_SamplerParameteriv(ctx->Exec, (sampler, pname, params)); - } -} - -static void GLAPIENTRY -save_SamplerParameteri(GLuint sampler, GLenum pname, GLint param) -{ - save_SamplerParameteriv(sampler, pname, ¶m); -} - -static void GLAPIENTRY -save_SamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat *params) -{ - Node *n; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_SAMPLER_PARAMETERFV, 6); - if (n) { - n[1].ui = sampler; - n[2].e = pname; - n[3].f = params[0]; - if (pname == GL_TEXTURE_BORDER_COLOR) { - n[4].f = params[1]; - n[5].f = params[2]; - n[6].f = params[3]; - } - else { - n[4].f = n[5].f = n[6].f = 0.0F; - } - } - if (ctx->ExecuteFlag) { - CALL_SamplerParameterfv(ctx->Exec, (sampler, pname, params)); - } -} - -static void GLAPIENTRY -save_SamplerParameterf(GLuint sampler, GLenum pname, GLfloat param) -{ - save_SamplerParameterfv(sampler, pname, ¶m); -} - -static void GLAPIENTRY -save_SamplerParameterIiv(GLuint sampler, GLenum pname, const GLint *params) -{ - Node *n; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_SAMPLER_PARAMETERIIV, 6); - if (n) { - n[1].ui = sampler; - n[2].e = pname; - n[3].i = params[0]; - if (pname == GL_TEXTURE_BORDER_COLOR) { - n[4].i = params[1]; - n[5].i = params[2]; - n[6].i = params[3]; - } - else { - n[4].i = n[5].i = n[6].i = 0; - } - } - if (ctx->ExecuteFlag) { - CALL_SamplerParameterIiv(ctx->Exec, (sampler, pname, params)); - } -} - -static void GLAPIENTRY -save_SamplerParameterIuiv(GLuint sampler, GLenum pname, const GLuint *params) -{ - Node *n; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_SAMPLER_PARAMETERUIV, 6); - if (n) { - n[1].ui = sampler; - n[2].e = pname; - n[3].ui = params[0]; - if (pname == GL_TEXTURE_BORDER_COLOR) { - n[4].ui = params[1]; - n[5].ui = params[2]; - n[6].ui = params[3]; - } - else { - n[4].ui = n[5].ui = n[6].ui = 0; - } - } - if (ctx->ExecuteFlag) { - CALL_SamplerParameterIuiv(ctx->Exec, (sampler, pname, params)); - } -} - -/* GL_ARB_geometry_shader4 */ -static void GLAPIENTRY -save_ProgramParameteri(GLuint program, GLenum pname, GLint value) -{ - Node *n; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_PROGRAM_PARAMETERI, 3); - if (n) { - n[1].ui = program; - n[2].e = pname; - n[3].i = value; - } - if (ctx->ExecuteFlag) { - CALL_ProgramParameteriARB(ctx->Exec, (program, pname, value)); - } -} - -static void GLAPIENTRY -save_FramebufferTexture(GLenum target, GLenum attachment, - GLuint texture, GLint level) -{ - Node *n; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_FRAMEBUFFER_TEXTURE, 4); - if (n) { - n[1].e = target; - n[2].e = attachment; - n[3].ui = texture; - n[4].i = level; - } - if (ctx->ExecuteFlag) { - CALL_FramebufferTextureARB(ctx->Exec, (target, attachment, texture, level)); - } -} - -static void GLAPIENTRY -save_FramebufferTextureFace(GLenum target, GLenum attachment, - GLuint texture, GLint level, GLenum face) -{ - Node *n; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_FRAMEBUFFER_TEXTURE_FACE, 5); - if (n) { - n[1].e = target; - n[2].e = attachment; - n[3].ui = texture; - n[4].i = level; - n[5].e = face; - } - if (ctx->ExecuteFlag) { - CALL_FramebufferTextureFaceARB(ctx->Exec, (target, attachment, texture, - level, face)); - } -} - - - -static void GLAPIENTRY -save_WaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) -{ - Node *n; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_WAIT_SYNC, 4); - if (n) { - union uint64_pair p; - p.uint64 = timeout; - n[1].data = sync; - n[2].e = flags; - n[3].ui = p.uint32[0]; - n[4].ui = p.uint32[1]; - } - if (ctx->ExecuteFlag) { - CALL_WaitSync(ctx->Exec, (sync, flags, timeout)); - } -} - - -/** - * Save an error-generating command into display list. - * - * KW: Will appear in the list before the vertex buffer containing the - * command that provoked the error. I don't see this as a problem. - */ -static void -save_error(struct gl_context *ctx, GLenum error, const char *s) -{ - Node *n; - n = alloc_instruction(ctx, OPCODE_ERROR, 2); - if (n) { - n[1].e = error; - n[2].data = (void *) s; - } -} - - -/** - * Compile an error into current display list. - */ -void -_mesa_compile_error(struct gl_context *ctx, GLenum error, const char *s) -{ - if (ctx->CompileFlag) - save_error(ctx, error, s); - if (ctx->ExecuteFlag) - _mesa_error(ctx, error, "%s", s); -} - - -/** - * Test if ID names a display list. - */ -static GLboolean -islist(struct gl_context *ctx, GLuint list) -{ - if (list > 0 && lookup_list(ctx, list)) { - return GL_TRUE; - } - else { - return GL_FALSE; - } -} - - - -/**********************************************************************/ -/* Display list execution */ -/**********************************************************************/ - - -/* - * Execute a display list. Note that the ListBase offset must have already - * been added before calling this function. I.e. the list argument is - * the absolute list number, not relative to ListBase. - * \param list - display list number - */ -static void -execute_list(struct gl_context *ctx, GLuint list) -{ - struct gl_display_list *dlist; - Node *n; - GLboolean done; - - if (list == 0 || !islist(ctx, list)) - return; - - if (ctx->ListState.CallDepth == MAX_LIST_NESTING) { - /* raise an error? */ - return; - } - - dlist = lookup_list(ctx, list); - if (!dlist) - return; - - ctx->ListState.CallDepth++; - - if (ctx->Driver.BeginCallList) - ctx->Driver.BeginCallList(ctx, dlist); - - n = dlist->Head; - - done = GL_FALSE; - while (!done) { - const OpCode opcode = n[0].opcode; - - if (is_ext_opcode(opcode)) { - n += ext_opcode_execute(ctx, n); - } - else { - switch (opcode) { - case OPCODE_ERROR: - _mesa_error(ctx, n[1].e, "%s", (const char *) n[2].data); - break; - case OPCODE_ACCUM: - CALL_Accum(ctx->Exec, (n[1].e, n[2].f)); - break; - case OPCODE_ALPHA_FUNC: - CALL_AlphaFunc(ctx->Exec, (n[1].e, n[2].f)); - break; - case OPCODE_BIND_TEXTURE: - CALL_BindTexture(ctx->Exec, (n[1].e, n[2].ui)); - break; - case OPCODE_BITMAP: - { - const struct gl_pixelstore_attrib save = ctx->Unpack; - ctx->Unpack = ctx->DefaultPacking; - CALL_Bitmap(ctx->Exec, ((GLsizei) n[1].i, (GLsizei) n[2].i, - n[3].f, n[4].f, n[5].f, n[6].f, - (const GLubyte *) n[7].data)); - ctx->Unpack = save; /* restore */ - } - break; - case OPCODE_BLEND_COLOR: - CALL_BlendColor(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f)); - break; - case OPCODE_BLEND_EQUATION: - CALL_BlendEquation(ctx->Exec, (n[1].e)); - break; - case OPCODE_BLEND_EQUATION_SEPARATE: - CALL_BlendEquationSeparateEXT(ctx->Exec, (n[1].e, n[2].e)); - break; - case OPCODE_BLEND_FUNC_SEPARATE: - CALL_BlendFuncSeparateEXT(ctx->Exec, - (n[1].e, n[2].e, n[3].e, n[4].e)); - break; - - case OPCODE_BLEND_FUNC_I: - /* GL_ARB_draw_buffers_blend */ - CALL_BlendFunciARB(ctx->Exec, (n[1].ui, n[2].e, n[3].e)); - break; - case OPCODE_BLEND_FUNC_SEPARATE_I: - /* GL_ARB_draw_buffers_blend */ - CALL_BlendFuncSeparateiARB(ctx->Exec, (n[1].ui, n[2].e, n[3].e, - n[4].e, n[5].e)); - break; - case OPCODE_BLEND_EQUATION_I: - /* GL_ARB_draw_buffers_blend */ - CALL_BlendEquationiARB(ctx->Exec, (n[1].ui, n[2].e)); - break; - case OPCODE_BLEND_EQUATION_SEPARATE_I: - /* GL_ARB_draw_buffers_blend */ - CALL_BlendEquationSeparateiARB(ctx->Exec, - (n[1].ui, n[2].e, n[3].e)); - break; - - case OPCODE_CALL_LIST: - /* Generated by glCallList(), don't add ListBase */ - if (ctx->ListState.CallDepth < MAX_LIST_NESTING) { - execute_list(ctx, n[1].ui); - } - break; - case OPCODE_CALL_LIST_OFFSET: - /* Generated by glCallLists() so we must add ListBase */ - if (n[2].b) { - /* user specified a bad data type at compile time */ - _mesa_error(ctx, GL_INVALID_ENUM, "glCallLists(type)"); - } - else if (ctx->ListState.CallDepth < MAX_LIST_NESTING) { - GLuint list = (GLuint) (ctx->List.ListBase + n[1].i); - execute_list(ctx, list); - } - break; - case OPCODE_CLEAR: - CALL_Clear(ctx->Exec, (n[1].bf)); - break; - case OPCODE_CLEAR_BUFFER_IV: - { - /*GLint value[4]; - value[0] = n[3].i; - value[1] = n[4].i; - value[2] = n[5].i; - value[3] = n[6].i; - CALL_ClearBufferiv(ctx->Exec, (n[1].e, n[2].i, value));*/ - } - break; - case OPCODE_CLEAR_BUFFER_UIV: - { - /*GLuint value[4]; - value[0] = n[3].ui; - value[1] = n[4].ui; - value[2] = n[5].ui; - value[3] = n[6].ui; - CALL_ClearBufferiv(ctx->Exec, (n[1].e, n[2].i, value));*/ - } - break; - case OPCODE_CLEAR_BUFFER_FV: - { - /*GLfloat value[4]; - value[0] = n[3].f; - value[1] = n[4].f; - value[2] = n[5].f; - value[3] = n[6].f; - CALL_ClearBufferfv(ctx->Exec, (n[1].e, n[2].i, value));*/ - } - break; - case OPCODE_CLEAR_BUFFER_FI: - /*CALL_ClearBufferfi(ctx->Exec, (n[1].e, n[2].i, n[3].f, n[4].i));*/ - break; - case OPCODE_CLEAR_COLOR: - CALL_ClearColor(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f)); - break; - case OPCODE_CLEAR_ACCUM: - CALL_ClearAccum(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f)); - break; - case OPCODE_CLEAR_DEPTH: - CALL_ClearDepth(ctx->Exec, ((GLclampd) n[1].f)); - break; - case OPCODE_CLEAR_INDEX: - CALL_ClearIndex(ctx->Exec, ((GLfloat) n[1].ui)); - break; - case OPCODE_CLEAR_STENCIL: - CALL_ClearStencil(ctx->Exec, (n[1].i)); - break; - case OPCODE_CLIP_PLANE: - { - GLdouble eq[4]; - eq[0] = n[2].f; - eq[1] = n[3].f; - eq[2] = n[4].f; - eq[3] = n[5].f; - CALL_ClipPlane(ctx->Exec, (n[1].e, eq)); - } - break; - case OPCODE_COLOR_MASK: - CALL_ColorMask(ctx->Exec, (n[1].b, n[2].b, n[3].b, n[4].b)); - break; - case OPCODE_COLOR_MASK_INDEXED: - CALL_ColorMaskIndexedEXT(ctx->Exec, (n[1].ui, n[2].b, n[3].b, - n[4].b, n[5].b)); - break; - case OPCODE_COLOR_MATERIAL: - CALL_ColorMaterial(ctx->Exec, (n[1].e, n[2].e)); - break; - case OPCODE_COLOR_TABLE: - { - const struct gl_pixelstore_attrib save = ctx->Unpack; - ctx->Unpack = ctx->DefaultPacking; - CALL_ColorTable(ctx->Exec, (n[1].e, n[2].e, n[3].i, n[4].e, - n[5].e, n[6].data)); - ctx->Unpack = save; /* restore */ - } - break; - case OPCODE_COLOR_TABLE_PARAMETER_FV: - { - GLfloat params[4]; - params[0] = n[3].f; - params[1] = n[4].f; - params[2] = n[5].f; - params[3] = n[6].f; - CALL_ColorTableParameterfv(ctx->Exec, - (n[1].e, n[2].e, params)); - } - break; - case OPCODE_COLOR_TABLE_PARAMETER_IV: - { - GLint params[4]; - params[0] = n[3].i; - params[1] = n[4].i; - params[2] = n[5].i; - params[3] = n[6].i; - CALL_ColorTableParameteriv(ctx->Exec, - (n[1].e, n[2].e, params)); - } - break; - case OPCODE_COLOR_SUB_TABLE: - { - const struct gl_pixelstore_attrib save = ctx->Unpack; - ctx->Unpack = ctx->DefaultPacking; - CALL_ColorSubTable(ctx->Exec, (n[1].e, n[2].i, n[3].i, - n[4].e, n[5].e, n[6].data)); - ctx->Unpack = save; /* restore */ - } - break; - case OPCODE_CONVOLUTION_FILTER_1D: - { - const struct gl_pixelstore_attrib save = ctx->Unpack; - ctx->Unpack = ctx->DefaultPacking; - CALL_ConvolutionFilter1D(ctx->Exec, (n[1].e, n[2].i, n[3].i, - n[4].e, n[5].e, - n[6].data)); - ctx->Unpack = save; /* restore */ - } - break; - case OPCODE_CONVOLUTION_FILTER_2D: - { - const struct gl_pixelstore_attrib save = ctx->Unpack; - ctx->Unpack = ctx->DefaultPacking; - CALL_ConvolutionFilter2D(ctx->Exec, (n[1].e, n[2].i, n[3].i, - n[4].i, n[5].e, n[6].e, - n[7].data)); - ctx->Unpack = save; /* restore */ - } - break; - case OPCODE_CONVOLUTION_PARAMETER_I: - CALL_ConvolutionParameteri(ctx->Exec, (n[1].e, n[2].e, n[3].i)); - break; - case OPCODE_CONVOLUTION_PARAMETER_IV: - { - GLint params[4]; - params[0] = n[3].i; - params[1] = n[4].i; - params[2] = n[5].i; - params[3] = n[6].i; - CALL_ConvolutionParameteriv(ctx->Exec, - (n[1].e, n[2].e, params)); - } - break; - case OPCODE_CONVOLUTION_PARAMETER_F: - CALL_ConvolutionParameterf(ctx->Exec, (n[1].e, n[2].e, n[3].f)); - break; - case OPCODE_CONVOLUTION_PARAMETER_FV: - { - GLfloat params[4]; - params[0] = n[3].f; - params[1] = n[4].f; - params[2] = n[5].f; - params[3] = n[6].f; - CALL_ConvolutionParameterfv(ctx->Exec, - (n[1].e, n[2].e, params)); - } - break; - case OPCODE_COPY_COLOR_SUB_TABLE: - CALL_CopyColorSubTable(ctx->Exec, (n[1].e, n[2].i, - n[3].i, n[4].i, n[5].i)); - break; - case OPCODE_COPY_COLOR_TABLE: - CALL_CopyColorSubTable(ctx->Exec, (n[1].e, n[2].i, - n[3].i, n[4].i, n[5].i)); - break; - case OPCODE_COPY_PIXELS: - CALL_CopyPixels(ctx->Exec, (n[1].i, n[2].i, - (GLsizei) n[3].i, (GLsizei) n[4].i, - n[5].e)); - break; - case OPCODE_COPY_TEX_IMAGE1D: - CALL_CopyTexImage1D(ctx->Exec, (n[1].e, n[2].i, n[3].e, n[4].i, - n[5].i, n[6].i, n[7].i)); - break; - case OPCODE_COPY_TEX_IMAGE2D: - CALL_CopyTexImage2D(ctx->Exec, (n[1].e, n[2].i, n[3].e, n[4].i, - n[5].i, n[6].i, n[7].i, n[8].i)); - break; - case OPCODE_COPY_TEX_SUB_IMAGE1D: - CALL_CopyTexSubImage1D(ctx->Exec, (n[1].e, n[2].i, n[3].i, - n[4].i, n[5].i, n[6].i)); - break; - case OPCODE_COPY_TEX_SUB_IMAGE2D: - CALL_CopyTexSubImage2D(ctx->Exec, (n[1].e, n[2].i, n[3].i, - n[4].i, n[5].i, n[6].i, n[7].i, - n[8].i)); - break; - case OPCODE_COPY_TEX_SUB_IMAGE3D: - CALL_CopyTexSubImage3D(ctx->Exec, (n[1].e, n[2].i, n[3].i, - n[4].i, n[5].i, n[6].i, n[7].i, - n[8].i, n[9].i)); - break; - case OPCODE_CULL_FACE: - CALL_CullFace(ctx->Exec, (n[1].e)); - break; - case OPCODE_DEPTH_FUNC: - CALL_DepthFunc(ctx->Exec, (n[1].e)); - break; - case OPCODE_DEPTH_MASK: - CALL_DepthMask(ctx->Exec, (n[1].b)); - break; - case OPCODE_DEPTH_RANGE: - CALL_DepthRange(ctx->Exec, - ((GLclampd) n[1].f, (GLclampd) n[2].f)); - break; - case OPCODE_DISABLE: - CALL_Disable(ctx->Exec, (n[1].e)); - break; - case OPCODE_DISABLE_INDEXED: - CALL_DisableIndexedEXT(ctx->Exec, (n[1].ui, n[2].e)); - break; - case OPCODE_DRAW_BUFFER: - CALL_DrawBuffer(ctx->Exec, (n[1].e)); - break; - case OPCODE_DRAW_PIXELS: - { - const struct gl_pixelstore_attrib save = ctx->Unpack; - ctx->Unpack = ctx->DefaultPacking; - CALL_DrawPixels(ctx->Exec, (n[1].i, n[2].i, n[3].e, n[4].e, - n[5].data)); - ctx->Unpack = save; /* restore */ - } - break; - case OPCODE_ENABLE: - CALL_Enable(ctx->Exec, (n[1].e)); - break; - case OPCODE_ENABLE_INDEXED: - CALL_EnableIndexedEXT(ctx->Exec, (n[1].ui, n[2].e)); - break; - case OPCODE_EVALMESH1: - CALL_EvalMesh1(ctx->Exec, (n[1].e, n[2].i, n[3].i)); - break; - case OPCODE_EVALMESH2: - CALL_EvalMesh2(ctx->Exec, - (n[1].e, n[2].i, n[3].i, n[4].i, n[5].i)); - break; - case OPCODE_FOG: - { - GLfloat p[4]; - p[0] = n[2].f; - p[1] = n[3].f; - p[2] = n[4].f; - p[3] = n[5].f; - CALL_Fogfv(ctx->Exec, (n[1].e, p)); - } - break; - case OPCODE_FRONT_FACE: - CALL_FrontFace(ctx->Exec, (n[1].e)); - break; - case OPCODE_FRUSTUM: - CALL_Frustum(ctx->Exec, - (n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f)); - break; - case OPCODE_HINT: - CALL_Hint(ctx->Exec, (n[1].e, n[2].e)); - break; - case OPCODE_HISTOGRAM: - CALL_Histogram(ctx->Exec, (n[1].e, n[2].i, n[3].e, n[4].b)); - break; - case OPCODE_INDEX_MASK: - CALL_IndexMask(ctx->Exec, (n[1].ui)); - break; - case OPCODE_INIT_NAMES: - CALL_InitNames(ctx->Exec, ()); - break; - case OPCODE_LIGHT: - { - GLfloat p[4]; - p[0] = n[3].f; - p[1] = n[4].f; - p[2] = n[5].f; - p[3] = n[6].f; - CALL_Lightfv(ctx->Exec, (n[1].e, n[2].e, p)); - } - break; - case OPCODE_LIGHT_MODEL: - { - GLfloat p[4]; - p[0] = n[2].f; - p[1] = n[3].f; - p[2] = n[4].f; - p[3] = n[5].f; - CALL_LightModelfv(ctx->Exec, (n[1].e, p)); - } - break; - case OPCODE_LINE_STIPPLE: - CALL_LineStipple(ctx->Exec, (n[1].i, n[2].us)); - break; - case OPCODE_LINE_WIDTH: - CALL_LineWidth(ctx->Exec, (n[1].f)); - break; - case OPCODE_LIST_BASE: - CALL_ListBase(ctx->Exec, (n[1].ui)); - break; - case OPCODE_LOAD_IDENTITY: - CALL_LoadIdentity(ctx->Exec, ()); - break; - case OPCODE_LOAD_MATRIX: - if (sizeof(Node) == sizeof(GLfloat)) { - CALL_LoadMatrixf(ctx->Exec, (&n[1].f)); - } - else { - GLfloat m[16]; - GLuint i; - for (i = 0; i < 16; i++) { - m[i] = n[1 + i].f; - } - CALL_LoadMatrixf(ctx->Exec, (m)); - } - break; - case OPCODE_LOAD_NAME: - CALL_LoadName(ctx->Exec, (n[1].ui)); - break; - case OPCODE_LOGIC_OP: - CALL_LogicOp(ctx->Exec, (n[1].e)); - break; - case OPCODE_MAP1: - { - GLenum target = n[1].e; - GLint ustride = _mesa_evaluator_components(target); - GLint uorder = n[5].i; - GLfloat u1 = n[2].f; - GLfloat u2 = n[3].f; - CALL_Map1f(ctx->Exec, (target, u1, u2, ustride, uorder, - (GLfloat *) n[6].data)); - } - break; - case OPCODE_MAP2: - { - GLenum target = n[1].e; - GLfloat u1 = n[2].f; - GLfloat u2 = n[3].f; - GLfloat v1 = n[4].f; - GLfloat v2 = n[5].f; - GLint ustride = n[6].i; - GLint vstride = n[7].i; - GLint uorder = n[8].i; - GLint vorder = n[9].i; - CALL_Map2f(ctx->Exec, (target, u1, u2, ustride, uorder, - v1, v2, vstride, vorder, - (GLfloat *) n[10].data)); - } - break; - case OPCODE_MAPGRID1: - CALL_MapGrid1f(ctx->Exec, (n[1].i, n[2].f, n[3].f)); - break; - case OPCODE_MAPGRID2: - CALL_MapGrid2f(ctx->Exec, - (n[1].i, n[2].f, n[3].f, n[4].i, n[5].f, n[6].f)); - break; - case OPCODE_MATRIX_MODE: - CALL_MatrixMode(ctx->Exec, (n[1].e)); - break; - case OPCODE_MIN_MAX: - CALL_Minmax(ctx->Exec, (n[1].e, n[2].e, n[3].b)); - break; - case OPCODE_MULT_MATRIX: - if (sizeof(Node) == sizeof(GLfloat)) { - CALL_MultMatrixf(ctx->Exec, (&n[1].f)); - } - else { - GLfloat m[16]; - GLuint i; - for (i = 0; i < 16; i++) { - m[i] = n[1 + i].f; - } - CALL_MultMatrixf(ctx->Exec, (m)); - } - break; - case OPCODE_ORTHO: - CALL_Ortho(ctx->Exec, - (n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f)); - break; - case OPCODE_PASSTHROUGH: - CALL_PassThrough(ctx->Exec, (n[1].f)); - break; - case OPCODE_PIXEL_MAP: - CALL_PixelMapfv(ctx->Exec, - (n[1].e, n[2].i, (GLfloat *) n[3].data)); - break; - case OPCODE_PIXEL_TRANSFER: - CALL_PixelTransferf(ctx->Exec, (n[1].e, n[2].f)); - break; - case OPCODE_PIXEL_ZOOM: - CALL_PixelZoom(ctx->Exec, (n[1].f, n[2].f)); - break; - case OPCODE_POINT_SIZE: - CALL_PointSize(ctx->Exec, (n[1].f)); - break; - case OPCODE_POINT_PARAMETERS: - { - GLfloat params[3]; - params[0] = n[2].f; - params[1] = n[3].f; - params[2] = n[4].f; - CALL_PointParameterfvEXT(ctx->Exec, (n[1].e, params)); - } - break; - case OPCODE_POLYGON_MODE: - CALL_PolygonMode(ctx->Exec, (n[1].e, n[2].e)); - break; - case OPCODE_POLYGON_STIPPLE: - { - const struct gl_pixelstore_attrib save = ctx->Unpack; - ctx->Unpack = ctx->DefaultPacking; - CALL_PolygonStipple(ctx->Exec, ((GLubyte *) n[1].data)); - ctx->Unpack = save; /* restore */ - } - break; - case OPCODE_POLYGON_OFFSET: - CALL_PolygonOffset(ctx->Exec, (n[1].f, n[2].f)); - break; - case OPCODE_POP_ATTRIB: - CALL_PopAttrib(ctx->Exec, ()); - break; - case OPCODE_POP_MATRIX: - CALL_PopMatrix(ctx->Exec, ()); - break; - case OPCODE_POP_NAME: - CALL_PopName(ctx->Exec, ()); - break; - case OPCODE_PRIORITIZE_TEXTURE: - CALL_PrioritizeTextures(ctx->Exec, (1, &n[1].ui, &n[2].f)); - break; - case OPCODE_PUSH_ATTRIB: - CALL_PushAttrib(ctx->Exec, (n[1].bf)); - break; - case OPCODE_PUSH_MATRIX: - CALL_PushMatrix(ctx->Exec, ()); - break; - case OPCODE_PUSH_NAME: - CALL_PushName(ctx->Exec, (n[1].ui)); - break; - case OPCODE_RASTER_POS: - CALL_RasterPos4f(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f)); - break; - case OPCODE_READ_BUFFER: - CALL_ReadBuffer(ctx->Exec, (n[1].e)); - break; - case OPCODE_RESET_HISTOGRAM: - CALL_ResetHistogram(ctx->Exec, (n[1].e)); - break; - case OPCODE_RESET_MIN_MAX: - CALL_ResetMinmax(ctx->Exec, (n[1].e)); - break; - case OPCODE_ROTATE: - CALL_Rotatef(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f)); - break; - case OPCODE_SCALE: - CALL_Scalef(ctx->Exec, (n[1].f, n[2].f, n[3].f)); - break; - case OPCODE_SCISSOR: - CALL_Scissor(ctx->Exec, (n[1].i, n[2].i, n[3].i, n[4].i)); - break; - case OPCODE_SHADE_MODEL: - CALL_ShadeModel(ctx->Exec, (n[1].e)); - break; - case OPCODE_PROVOKING_VERTEX: - CALL_ProvokingVertexEXT(ctx->Exec, (n[1].e)); - break; - case OPCODE_STENCIL_FUNC: - CALL_StencilFunc(ctx->Exec, (n[1].e, n[2].i, n[3].ui)); - break; - case OPCODE_STENCIL_MASK: - CALL_StencilMask(ctx->Exec, (n[1].ui)); - break; - case OPCODE_STENCIL_OP: - CALL_StencilOp(ctx->Exec, (n[1].e, n[2].e, n[3].e)); - break; - case OPCODE_STENCIL_FUNC_SEPARATE: - CALL_StencilFuncSeparate(ctx->Exec, - (n[1].e, n[2].e, n[3].i, n[4].ui)); - break; - case OPCODE_STENCIL_MASK_SEPARATE: - CALL_StencilMaskSeparate(ctx->Exec, (n[1].e, n[2].ui)); - break; - case OPCODE_STENCIL_OP_SEPARATE: - CALL_StencilOpSeparate(ctx->Exec, - (n[1].e, n[2].e, n[3].e, n[4].e)); - break; - case OPCODE_TEXENV: - { - GLfloat params[4]; - params[0] = n[3].f; - params[1] = n[4].f; - params[2] = n[5].f; - params[3] = n[6].f; - CALL_TexEnvfv(ctx->Exec, (n[1].e, n[2].e, params)); - } - break; - case OPCODE_TEXGEN: - { - GLfloat params[4]; - params[0] = n[3].f; - params[1] = n[4].f; - params[2] = n[5].f; - params[3] = n[6].f; - CALL_TexGenfv(ctx->Exec, (n[1].e, n[2].e, params)); - } - break; - case OPCODE_TEXPARAMETER: - { - GLfloat params[4]; - params[0] = n[3].f; - params[1] = n[4].f; - params[2] = n[5].f; - params[3] = n[6].f; - CALL_TexParameterfv(ctx->Exec, (n[1].e, n[2].e, params)); - } - break; - case OPCODE_TEX_IMAGE1D: - { - const struct gl_pixelstore_attrib save = ctx->Unpack; - ctx->Unpack = ctx->DefaultPacking; - CALL_TexImage1D(ctx->Exec, (n[1].e, /* target */ - n[2].i, /* level */ - n[3].i, /* components */ - n[4].i, /* width */ - n[5].e, /* border */ - n[6].e, /* format */ - n[7].e, /* type */ - n[8].data)); - ctx->Unpack = save; /* restore */ - } - break; - case OPCODE_TEX_IMAGE2D: - { - const struct gl_pixelstore_attrib save = ctx->Unpack; - ctx->Unpack = ctx->DefaultPacking; - CALL_TexImage2D(ctx->Exec, (n[1].e, /* target */ - n[2].i, /* level */ - n[3].i, /* components */ - n[4].i, /* width */ - n[5].i, /* height */ - n[6].e, /* border */ - n[7].e, /* format */ - n[8].e, /* type */ - n[9].data)); - ctx->Unpack = save; /* restore */ - } - break; - case OPCODE_TEX_IMAGE3D: - { - const struct gl_pixelstore_attrib save = ctx->Unpack; - ctx->Unpack = ctx->DefaultPacking; - CALL_TexImage3D(ctx->Exec, (n[1].e, /* target */ - n[2].i, /* level */ - n[3].i, /* components */ - n[4].i, /* width */ - n[5].i, /* height */ - n[6].i, /* depth */ - n[7].e, /* border */ - n[8].e, /* format */ - n[9].e, /* type */ - n[10].data)); - ctx->Unpack = save; /* restore */ - } - break; - case OPCODE_TEX_SUB_IMAGE1D: - { - const struct gl_pixelstore_attrib save = ctx->Unpack; - ctx->Unpack = ctx->DefaultPacking; - CALL_TexSubImage1D(ctx->Exec, (n[1].e, n[2].i, n[3].i, - n[4].i, n[5].e, - n[6].e, n[7].data)); - ctx->Unpack = save; /* restore */ - } - break; - case OPCODE_TEX_SUB_IMAGE2D: - { - const struct gl_pixelstore_attrib save = ctx->Unpack; - ctx->Unpack = ctx->DefaultPacking; - CALL_TexSubImage2D(ctx->Exec, (n[1].e, n[2].i, n[3].i, - n[4].i, n[5].e, - n[6].i, n[7].e, n[8].e, - n[9].data)); - ctx->Unpack = save; /* restore */ - } - break; - case OPCODE_TEX_SUB_IMAGE3D: - { - const struct gl_pixelstore_attrib save = ctx->Unpack; - ctx->Unpack = ctx->DefaultPacking; - CALL_TexSubImage3D(ctx->Exec, (n[1].e, n[2].i, n[3].i, - n[4].i, n[5].i, n[6].i, n[7].i, - n[8].i, n[9].e, n[10].e, - n[11].data)); - ctx->Unpack = save; /* restore */ - } - break; - case OPCODE_TRANSLATE: - CALL_Translatef(ctx->Exec, (n[1].f, n[2].f, n[3].f)); - break; - case OPCODE_VIEWPORT: - CALL_Viewport(ctx->Exec, (n[1].i, n[2].i, - (GLsizei) n[3].i, (GLsizei) n[4].i)); - break; - case OPCODE_WINDOW_POS: - CALL_WindowPos4fMESA(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f)); - break; - case OPCODE_ACTIVE_TEXTURE: /* GL_ARB_multitexture */ - CALL_ActiveTextureARB(ctx->Exec, (n[1].e)); - break; - case OPCODE_COMPRESSED_TEX_IMAGE_1D: /* GL_ARB_texture_compression */ - CALL_CompressedTexImage1DARB(ctx->Exec, (n[1].e, n[2].i, n[3].e, - n[4].i, n[5].i, n[6].i, - n[7].data)); - break; - case OPCODE_COMPRESSED_TEX_IMAGE_2D: /* GL_ARB_texture_compression */ - CALL_CompressedTexImage2DARB(ctx->Exec, (n[1].e, n[2].i, n[3].e, - n[4].i, n[5].i, n[6].i, - n[7].i, n[8].data)); - break; - case OPCODE_COMPRESSED_TEX_IMAGE_3D: /* GL_ARB_texture_compression */ - CALL_CompressedTexImage3DARB(ctx->Exec, (n[1].e, n[2].i, n[3].e, - n[4].i, n[5].i, n[6].i, - n[7].i, n[8].i, - n[9].data)); - break; - case OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D: /* GL_ARB_texture_compress */ - CALL_CompressedTexSubImage1DARB(ctx->Exec, - (n[1].e, n[2].i, n[3].i, n[4].i, - n[5].e, n[6].i, n[7].data)); - break; - case OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D: /* GL_ARB_texture_compress */ - CALL_CompressedTexSubImage2DARB(ctx->Exec, - (n[1].e, n[2].i, n[3].i, n[4].i, - n[5].i, n[6].i, n[7].e, n[8].i, - n[9].data)); - break; - case OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D: /* GL_ARB_texture_compress */ - CALL_CompressedTexSubImage3DARB(ctx->Exec, - (n[1].e, n[2].i, n[3].i, n[4].i, - n[5].i, n[6].i, n[7].i, n[8].i, - n[9].e, n[10].i, n[11].data)); - break; - case OPCODE_SAMPLE_COVERAGE: /* GL_ARB_multisample */ - CALL_SampleCoverageARB(ctx->Exec, (n[1].f, n[2].b)); - break; - case OPCODE_WINDOW_POS_ARB: /* GL_ARB_window_pos */ - CALL_WindowPos3fMESA(ctx->Exec, (n[1].f, n[2].f, n[3].f)); - break; -#if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program - case OPCODE_BIND_PROGRAM_NV: /* GL_NV_vertex_program */ - CALL_BindProgramNV(ctx->Exec, (n[1].e, n[2].ui)); - break; -#endif -#if FEATURE_NV_vertex_program - case OPCODE_EXECUTE_PROGRAM_NV: - { - GLfloat v[4]; - v[0] = n[3].f; - v[1] = n[4].f; - v[2] = n[5].f; - v[3] = n[6].f; - CALL_ExecuteProgramNV(ctx->Exec, (n[1].e, n[2].ui, v)); - } - break; - case OPCODE_REQUEST_RESIDENT_PROGRAMS_NV: - CALL_RequestResidentProgramsNV(ctx->Exec, (n[1].ui, - (GLuint *) n[2].data)); - break; - case OPCODE_LOAD_PROGRAM_NV: - CALL_LoadProgramNV(ctx->Exec, (n[1].e, n[2].ui, n[3].i, - (const GLubyte *) n[4].data)); - break; - case OPCODE_TRACK_MATRIX_NV: - CALL_TrackMatrixNV(ctx->Exec, (n[1].e, n[2].ui, n[3].e, n[4].e)); - break; -#endif - -#if FEATURE_NV_fragment_program - case OPCODE_PROGRAM_LOCAL_PARAMETER_ARB: - CALL_ProgramLocalParameter4fARB(ctx->Exec, - (n[1].e, n[2].ui, n[3].f, n[4].f, - n[5].f, n[6].f)); - break; - case OPCODE_PROGRAM_NAMED_PARAMETER_NV: - CALL_ProgramNamedParameter4fNV(ctx->Exec, (n[1].ui, n[2].i, - (const GLubyte *) n[3]. - data, n[4].f, n[5].f, - n[6].f, n[7].f)); - break; -#endif - - case OPCODE_ACTIVE_STENCIL_FACE_EXT: - CALL_ActiveStencilFaceEXT(ctx->Exec, (n[1].e)); - break; - case OPCODE_DEPTH_BOUNDS_EXT: - CALL_DepthBoundsEXT(ctx->Exec, (n[1].f, n[2].f)); - break; -#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program - case OPCODE_PROGRAM_STRING_ARB: - CALL_ProgramStringARB(ctx->Exec, - (n[1].e, n[2].e, n[3].i, n[4].data)); - break; -#endif -#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program || FEATURE_NV_vertex_program - case OPCODE_PROGRAM_ENV_PARAMETER_ARB: - CALL_ProgramEnvParameter4fARB(ctx->Exec, (n[1].e, n[2].ui, n[3].f, - n[4].f, n[5].f, - n[6].f)); - break; -#endif -#if FEATURE_queryobj - case OPCODE_BEGIN_QUERY_ARB: - CALL_BeginQueryARB(ctx->Exec, (n[1].e, n[2].ui)); - break; - case OPCODE_END_QUERY_ARB: - CALL_EndQueryARB(ctx->Exec, (n[1].e)); - break; -#endif - case OPCODE_DRAW_BUFFERS_ARB: - { - GLenum buffers[MAX_DRAW_BUFFERS]; - GLint i, count = MIN2(n[1].i, MAX_DRAW_BUFFERS); - for (i = 0; i < count; i++) - buffers[i] = n[2 + i].e; - CALL_DrawBuffersARB(ctx->Exec, (n[1].i, buffers)); - } - break; -#if FEATURE_EXT_framebuffer_blit - case OPCODE_BLIT_FRAMEBUFFER: - CALL_BlitFramebufferEXT(ctx->Exec, (n[1].i, n[2].i, n[3].i, n[4].i, - n[5].i, n[6].i, n[7].i, n[8].i, - n[9].i, n[10].e)); - break; -#endif - - case OPCODE_USE_PROGRAM: - CALL_UseProgramObjectARB(ctx->Exec, (n[1].ui)); - break; - case OPCODE_USE_SHADER_PROGRAM_EXT: - CALL_UseShaderProgramEXT(ctx->Exec, (n[1].ui, n[2].ui)); - break; - case OPCODE_ACTIVE_PROGRAM_EXT: - CALL_ActiveProgramEXT(ctx->Exec, (n[1].ui)); - break; - case OPCODE_UNIFORM_1F: - CALL_Uniform1fARB(ctx->Exec, (n[1].i, n[2].f)); - break; - case OPCODE_UNIFORM_2F: - CALL_Uniform2fARB(ctx->Exec, (n[1].i, n[2].f, n[3].f)); - break; - case OPCODE_UNIFORM_3F: - CALL_Uniform3fARB(ctx->Exec, (n[1].i, n[2].f, n[3].f, n[4].f)); - break; - case OPCODE_UNIFORM_4F: - CALL_Uniform4fARB(ctx->Exec, - (n[1].i, n[2].f, n[3].f, n[4].f, n[5].f)); - break; - case OPCODE_UNIFORM_1FV: - CALL_Uniform1fvARB(ctx->Exec, (n[1].i, n[2].i, n[3].data)); - break; - case OPCODE_UNIFORM_2FV: - CALL_Uniform2fvARB(ctx->Exec, (n[1].i, n[2].i, n[3].data)); - break; - case OPCODE_UNIFORM_3FV: - CALL_Uniform3fvARB(ctx->Exec, (n[1].i, n[2].i, n[3].data)); - break; - case OPCODE_UNIFORM_4FV: - CALL_Uniform4fvARB(ctx->Exec, (n[1].i, n[2].i, n[3].data)); - break; - case OPCODE_UNIFORM_1I: - CALL_Uniform1iARB(ctx->Exec, (n[1].i, n[2].i)); - break; - case OPCODE_UNIFORM_2I: - CALL_Uniform2iARB(ctx->Exec, (n[1].i, n[2].i, n[3].i)); - break; - case OPCODE_UNIFORM_3I: - CALL_Uniform3iARB(ctx->Exec, (n[1].i, n[2].i, n[3].i, n[4].i)); - break; - case OPCODE_UNIFORM_4I: - CALL_Uniform4iARB(ctx->Exec, - (n[1].i, n[2].i, n[3].i, n[4].i, n[5].i)); - break; - case OPCODE_UNIFORM_1IV: - CALL_Uniform1ivARB(ctx->Exec, (n[1].i, n[2].i, n[3].data)); - break; - case OPCODE_UNIFORM_2IV: - CALL_Uniform2ivARB(ctx->Exec, (n[1].i, n[2].i, n[3].data)); - break; - case OPCODE_UNIFORM_3IV: - CALL_Uniform3ivARB(ctx->Exec, (n[1].i, n[2].i, n[3].data)); - break; - case OPCODE_UNIFORM_4IV: - CALL_Uniform4ivARB(ctx->Exec, (n[1].i, n[2].i, n[3].data)); - break; - case OPCODE_UNIFORM_1UI: - /*CALL_Uniform1uiARB(ctx->Exec, (n[1].i, n[2].i));*/ - break; - case OPCODE_UNIFORM_2UI: - /*CALL_Uniform2uiARB(ctx->Exec, (n[1].i, n[2].i, n[3].i));*/ - break; - case OPCODE_UNIFORM_3UI: - /*CALL_Uniform3uiARB(ctx->Exec, (n[1].i, n[2].i, n[3].i, n[4].i));*/ - break; - case OPCODE_UNIFORM_4UI: - /*CALL_Uniform4uiARB(ctx->Exec, - (n[1].i, n[2].i, n[3].i, n[4].i, n[5].i)); - */ - break; - case OPCODE_UNIFORM_1UIV: - /*CALL_Uniform1uivARB(ctx->Exec, (n[1].i, n[2].i, n[3].data));*/ - break; - case OPCODE_UNIFORM_2UIV: - /*CALL_Uniform2uivARB(ctx->Exec, (n[1].i, n[2].i, n[3].data));*/ - break; - case OPCODE_UNIFORM_3UIV: - /*CALL_Uniform3uivARB(ctx->Exec, (n[1].i, n[2].i, n[3].data));*/ - break; - case OPCODE_UNIFORM_4UIV: - /*CALL_Uniform4uivARB(ctx->Exec, (n[1].i, n[2].i, n[3].data));*/ - break; - case OPCODE_UNIFORM_MATRIX22: - CALL_UniformMatrix2fvARB(ctx->Exec, - (n[1].i, n[2].i, n[3].b, n[4].data)); - break; - case OPCODE_UNIFORM_MATRIX33: - CALL_UniformMatrix3fvARB(ctx->Exec, - (n[1].i, n[2].i, n[3].b, n[4].data)); - break; - case OPCODE_UNIFORM_MATRIX44: - CALL_UniformMatrix4fvARB(ctx->Exec, - (n[1].i, n[2].i, n[3].b, n[4].data)); - break; - case OPCODE_UNIFORM_MATRIX23: - CALL_UniformMatrix2x3fv(ctx->Exec, - (n[1].i, n[2].i, n[3].b, n[4].data)); - break; - case OPCODE_UNIFORM_MATRIX32: - CALL_UniformMatrix3x2fv(ctx->Exec, - (n[1].i, n[2].i, n[3].b, n[4].data)); - break; - case OPCODE_UNIFORM_MATRIX24: - CALL_UniformMatrix2x4fv(ctx->Exec, - (n[1].i, n[2].i, n[3].b, n[4].data)); - break; - case OPCODE_UNIFORM_MATRIX42: - CALL_UniformMatrix4x2fv(ctx->Exec, - (n[1].i, n[2].i, n[3].b, n[4].data)); - break; - case OPCODE_UNIFORM_MATRIX34: - CALL_UniformMatrix3x4fv(ctx->Exec, - (n[1].i, n[2].i, n[3].b, n[4].data)); - break; - case OPCODE_UNIFORM_MATRIX43: - CALL_UniformMatrix4x3fv(ctx->Exec, - (n[1].i, n[2].i, n[3].b, n[4].data)); - break; - - case OPCODE_CLAMP_COLOR: - CALL_ClampColorARB(ctx->Exec, (n[1].e, n[2].e)); - break; - - case OPCODE_TEX_BUMP_PARAMETER_ATI: - { - GLfloat values[4]; - GLuint i, pname = n[1].ui; - - for (i = 0; i < 4; i++) - values[i] = n[1 + i].f; - CALL_TexBumpParameterfvATI(ctx->Exec, (pname, values)); - } - break; -#if FEATURE_ATI_fragment_shader - case OPCODE_BIND_FRAGMENT_SHADER_ATI: - CALL_BindFragmentShaderATI(ctx->Exec, (n[1].i)); - break; - case OPCODE_SET_FRAGMENT_SHADER_CONSTANTS_ATI: - { - GLfloat values[4]; - GLuint i, dst = n[1].ui; - - for (i = 0; i < 4; i++) - values[i] = n[1 + i].f; - CALL_SetFragmentShaderConstantATI(ctx->Exec, (dst, values)); - } - break; -#endif - case OPCODE_ATTR_1F_NV: - CALL_VertexAttrib1fNV(ctx->Exec, (n[1].e, n[2].f)); - break; - case OPCODE_ATTR_2F_NV: - /* Really shouldn't have to do this - the Node structure - * is convenient, but it would be better to store the data - * packed appropriately so that it can be sent directly - * on. With x86_64 becoming common, this will start to - * matter more. - */ - if (sizeof(Node) == sizeof(GLfloat)) - CALL_VertexAttrib2fvNV(ctx->Exec, (n[1].e, &n[2].f)); - else - CALL_VertexAttrib2fNV(ctx->Exec, (n[1].e, n[2].f, n[3].f)); - break; - case OPCODE_ATTR_3F_NV: - if (sizeof(Node) == sizeof(GLfloat)) - CALL_VertexAttrib3fvNV(ctx->Exec, (n[1].e, &n[2].f)); - else - CALL_VertexAttrib3fNV(ctx->Exec, (n[1].e, n[2].f, n[3].f, - n[4].f)); - break; - case OPCODE_ATTR_4F_NV: - if (sizeof(Node) == sizeof(GLfloat)) - CALL_VertexAttrib4fvNV(ctx->Exec, (n[1].e, &n[2].f)); - else - CALL_VertexAttrib4fNV(ctx->Exec, (n[1].e, n[2].f, n[3].f, - n[4].f, n[5].f)); - break; - case OPCODE_ATTR_1F_ARB: - CALL_VertexAttrib1fARB(ctx->Exec, (n[1].e, n[2].f)); - break; - case OPCODE_ATTR_2F_ARB: - /* Really shouldn't have to do this - the Node structure - * is convenient, but it would be better to store the data - * packed appropriately so that it can be sent directly - * on. With x86_64 becoming common, this will start to - * matter more. - */ - if (sizeof(Node) == sizeof(GLfloat)) - CALL_VertexAttrib2fvARB(ctx->Exec, (n[1].e, &n[2].f)); - else - CALL_VertexAttrib2fARB(ctx->Exec, (n[1].e, n[2].f, n[3].f)); - break; - case OPCODE_ATTR_3F_ARB: - if (sizeof(Node) == sizeof(GLfloat)) - CALL_VertexAttrib3fvARB(ctx->Exec, (n[1].e, &n[2].f)); - else - CALL_VertexAttrib3fARB(ctx->Exec, (n[1].e, n[2].f, n[3].f, - n[4].f)); - break; - case OPCODE_ATTR_4F_ARB: - if (sizeof(Node) == sizeof(GLfloat)) - CALL_VertexAttrib4fvARB(ctx->Exec, (n[1].e, &n[2].f)); - else - CALL_VertexAttrib4fARB(ctx->Exec, (n[1].e, n[2].f, n[3].f, - n[4].f, n[5].f)); - break; - case OPCODE_MATERIAL: - if (sizeof(Node) == sizeof(GLfloat)) - CALL_Materialfv(ctx->Exec, (n[1].e, n[2].e, &n[3].f)); - else { - GLfloat f[4]; - f[0] = n[3].f; - f[1] = n[4].f; - f[2] = n[5].f; - f[3] = n[6].f; - CALL_Materialfv(ctx->Exec, (n[1].e, n[2].e, f)); - } - break; - case OPCODE_BEGIN: - CALL_Begin(ctx->Exec, (n[1].e)); - break; - case OPCODE_END: - CALL_End(ctx->Exec, ()); - break; - case OPCODE_RECTF: - CALL_Rectf(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f)); - break; - case OPCODE_EVAL_C1: - CALL_EvalCoord1f(ctx->Exec, (n[1].f)); - break; - case OPCODE_EVAL_C2: - CALL_EvalCoord2f(ctx->Exec, (n[1].f, n[2].f)); - break; - case OPCODE_EVAL_P1: - CALL_EvalPoint1(ctx->Exec, (n[1].i)); - break; - case OPCODE_EVAL_P2: - CALL_EvalPoint2(ctx->Exec, (n[1].i, n[2].i)); - break; - - /* GL_EXT_texture_integer */ - case OPCODE_CLEARCOLOR_I: - CALL_ClearColorIiEXT(ctx->Exec, (n[1].i, n[2].i, n[3].i, n[4].i)); - break; - case OPCODE_CLEARCOLOR_UI: - CALL_ClearColorIuiEXT(ctx->Exec, - (n[1].ui, n[2].ui, n[3].ui, n[4].ui)); - break; - case OPCODE_TEXPARAMETER_I: - { - GLint params[4]; - params[0] = n[3].i; - params[1] = n[4].i; - params[2] = n[5].i; - params[3] = n[6].i; - CALL_TexParameterIivEXT(ctx->Exec, (n[1].e, n[2].e, params)); - } - break; - case OPCODE_TEXPARAMETER_UI: - { - GLuint params[4]; - params[0] = n[3].ui; - params[1] = n[4].ui; - params[2] = n[5].ui; - params[3] = n[6].ui; - CALL_TexParameterIuivEXT(ctx->Exec, (n[1].e, n[2].e, params)); - } - break; - - case OPCODE_VERTEX_ATTRIB_DIVISOR: - /* GL_ARB_instanced_arrays */ - CALL_VertexAttribDivisorARB(ctx->Exec, (n[1].ui, n[2].ui)); - break; - - case OPCODE_TEXTURE_BARRIER_NV: - CALL_TextureBarrierNV(ctx->Exec, ()); - break; - - /* GL_EXT/ARB_transform_feedback */ - case OPCODE_BEGIN_TRANSFORM_FEEDBACK: - CALL_BeginTransformFeedbackEXT(ctx->Exec, (n[1].e)); - break; - case OPCODE_END_TRANSFORM_FEEDBACK: - CALL_EndTransformFeedbackEXT(ctx->Exec, ()); - break; - case OPCODE_BIND_TRANSFORM_FEEDBACK: - CALL_BindTransformFeedback(ctx->Exec, (n[1].e, n[2].ui)); - break; - case OPCODE_PAUSE_TRANSFORM_FEEDBACK: - CALL_PauseTransformFeedback(ctx->Exec, ()); - break; - case OPCODE_RESUME_TRANSFORM_FEEDBACK: - CALL_ResumeTransformFeedback(ctx->Exec, ()); - break; - case OPCODE_DRAW_TRANSFORM_FEEDBACK: - CALL_DrawTransformFeedback(ctx->Exec, (n[1].e, n[2].ui)); - break; - - - case OPCODE_BIND_SAMPLER: - CALL_BindSampler(ctx->Exec, (n[1].ui, n[2].ui)); - break; - case OPCODE_SAMPLER_PARAMETERIV: - { - GLint params[4]; - params[0] = n[3].i; - params[1] = n[4].i; - params[2] = n[5].i; - params[3] = n[6].i; - CALL_SamplerParameteriv(ctx->Exec, (n[1].ui, n[2].e, params)); - } - break; - case OPCODE_SAMPLER_PARAMETERFV: - { - GLfloat params[4]; - params[0] = n[3].f; - params[1] = n[4].f; - params[2] = n[5].f; - params[3] = n[6].f; - CALL_SamplerParameterfv(ctx->Exec, (n[1].ui, n[2].e, params)); - } - break; - case OPCODE_SAMPLER_PARAMETERIIV: - { - GLint params[4]; - params[0] = n[3].i; - params[1] = n[4].i; - params[2] = n[5].i; - params[3] = n[6].i; - CALL_SamplerParameterIiv(ctx->Exec, (n[1].ui, n[2].e, params)); - } - break; - case OPCODE_SAMPLER_PARAMETERUIV: - { - GLuint params[4]; - params[0] = n[3].ui; - params[1] = n[4].ui; - params[2] = n[5].ui; - params[3] = n[6].ui; - CALL_SamplerParameterIuiv(ctx->Exec, (n[1].ui, n[2].e, params)); - } - break; - - /* GL_ARB_geometry_shader4 */ - case OPCODE_PROGRAM_PARAMETERI: - CALL_ProgramParameteriARB(ctx->Exec, (n[1].ui, n[2].e, n[3].i)); - break; - case OPCODE_FRAMEBUFFER_TEXTURE: - CALL_FramebufferTextureARB(ctx->Exec, (n[1].e, n[2].e, - n[3].ui, n[4].i)); - break; - case OPCODE_FRAMEBUFFER_TEXTURE_FACE: - CALL_FramebufferTextureFaceARB(ctx->Exec, (n[1].e, n[2].e, - n[3].ui, n[4].i, n[5].e)); - break; - - /* GL_ARB_sync */ - case OPCODE_WAIT_SYNC: - { - union uint64_pair p; - p.uint32[0] = n[3].ui; - p.uint32[1] = n[4].ui; - CALL_WaitSync(ctx->Exec, (n[1].data, n[2].bf, p.uint64)); - } - break; - - case OPCODE_CONTINUE: - n = (Node *) n[1].next; - break; - case OPCODE_END_OF_LIST: - done = GL_TRUE; - break; - default: - { - char msg[1000]; - _mesa_snprintf(msg, sizeof(msg), "Error in execute_list: opcode=%d", - (int) opcode); - _mesa_problem(ctx, "%s", msg); - } - done = GL_TRUE; - } - - /* increment n to point to next compiled command */ - if (opcode != OPCODE_CONTINUE) { - n += InstSize[opcode]; - } - } - } - - if (ctx->Driver.EndCallList) - ctx->Driver.EndCallList(ctx); - - ctx->ListState.CallDepth--; -} - - - -/**********************************************************************/ -/* GL functions */ -/**********************************************************************/ - -/** - * Test if a display list number is valid. - */ -static GLboolean GLAPIENTRY -_mesa_IsList(GLuint list) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); /* must be called before assert */ - ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); - return islist(ctx, list); -} - - -/** - * Delete a sequence of consecutive display lists. - */ -static void GLAPIENTRY -_mesa_DeleteLists(GLuint list, GLsizei range) -{ - GET_CURRENT_CONTEXT(ctx); - GLuint i; - FLUSH_VERTICES(ctx, 0); /* must be called before assert */ - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (range < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glDeleteLists"); - return; - } - for (i = list; i < list + range; i++) { - destroy_list(ctx, i); - } -} - - -/** - * Return a display list number, n, such that lists n through n+range-1 - * are free. - */ -static GLuint GLAPIENTRY -_mesa_GenLists(GLsizei range) -{ - GET_CURRENT_CONTEXT(ctx); - GLuint base; - FLUSH_VERTICES(ctx, 0); /* must be called before assert */ - ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, 0); - - if (range < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glGenLists"); - return 0; - } - if (range == 0) { - return 0; - } - - /* - * Make this an atomic operation - */ - _glthread_LOCK_MUTEX(ctx->Shared->Mutex); - - base = _mesa_HashFindFreeKeyBlock(ctx->Shared->DisplayList, range); - if (base) { - /* reserve the list IDs by with empty/dummy lists */ - GLint i; - for (i = 0; i < range; i++) { - _mesa_HashInsert(ctx->Shared->DisplayList, base + i, - make_list(base + i, 1)); - } - } - - _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); - - return base; -} - - -/** - * Begin a new display list. - */ -static void GLAPIENTRY -_mesa_NewList(GLuint name, GLenum mode) -{ - GET_CURRENT_CONTEXT(ctx); - - FLUSH_CURRENT(ctx, 0); /* must be called before assert */ - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glNewList %u %s\n", name, - _mesa_lookup_enum_by_nr(mode)); - - if (name == 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glNewList"); - return; - } - - if (mode != GL_COMPILE && mode != GL_COMPILE_AND_EXECUTE) { - _mesa_error(ctx, GL_INVALID_ENUM, "glNewList"); - return; - } - - if (ctx->ListState.CurrentList) { - /* already compiling a display list */ - _mesa_error(ctx, GL_INVALID_OPERATION, "glNewList"); - return; - } - - ctx->CompileFlag = GL_TRUE; - ctx->ExecuteFlag = (mode == GL_COMPILE_AND_EXECUTE); - - /* Reset acumulated list state: - */ - invalidate_saved_current_state( ctx ); - - /* Allocate new display list */ - ctx->ListState.CurrentList = make_list(name, BLOCK_SIZE); - ctx->ListState.CurrentBlock = ctx->ListState.CurrentList->Head; - ctx->ListState.CurrentPos = 0; - - ctx->Driver.NewList(ctx, name, mode); - - ctx->CurrentDispatch = ctx->Save; - _glapi_set_dispatch(ctx->CurrentDispatch); -} - - -/** - * End definition of current display list. - */ -static void GLAPIENTRY -_mesa_EndList(void) -{ - GET_CURRENT_CONTEXT(ctx); - SAVE_FLUSH_VERTICES(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glEndList\n"); - - /* Check that a list is under construction */ - if (!ctx->ListState.CurrentList) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glEndList"); - return; - } - - /* Call before emitting END_OF_LIST, in case the driver wants to - * emit opcodes itself. - */ - ctx->Driver.EndList(ctx); - - (void) alloc_instruction(ctx, OPCODE_END_OF_LIST, 0); - - /* Destroy old list, if any */ - destroy_list(ctx, ctx->ListState.CurrentList->Name); - - /* Install the new list */ - _mesa_HashInsert(ctx->Shared->DisplayList, - ctx->ListState.CurrentList->Name, - ctx->ListState.CurrentList); - - - if (MESA_VERBOSE & VERBOSE_DISPLAY_LIST) - mesa_print_display_list(ctx->ListState.CurrentList->Name); - - ctx->ListState.CurrentList = NULL; - ctx->ExecuteFlag = GL_TRUE; - ctx->CompileFlag = GL_FALSE; - - ctx->CurrentDispatch = ctx->Exec; - _glapi_set_dispatch(ctx->CurrentDispatch); -} - - -void GLAPIENTRY -_mesa_CallList(GLuint list) -{ - GLboolean save_compile_flag; - GET_CURRENT_CONTEXT(ctx); - FLUSH_CURRENT(ctx, 0); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glCallList %d\n", list); - - if (list == 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glCallList(list==0)"); - return; - } - - if (0) - mesa_print_display_list( list ); - - /* VERY IMPORTANT: Save the CompileFlag status, turn it off, - * execute the display list, and restore the CompileFlag. - */ - save_compile_flag = ctx->CompileFlag; - if (save_compile_flag) { - ctx->CompileFlag = GL_FALSE; - } - - execute_list(ctx, list); - ctx->CompileFlag = save_compile_flag; - - /* also restore API function pointers to point to "save" versions */ - if (save_compile_flag) { - ctx->CurrentDispatch = ctx->Save; - _glapi_set_dispatch(ctx->CurrentDispatch); - } -} - - -/** - * Execute glCallLists: call multiple display lists. - */ -void GLAPIENTRY -_mesa_CallLists(GLsizei n, GLenum type, const GLvoid * lists) -{ - GET_CURRENT_CONTEXT(ctx); - GLint i; - GLboolean save_compile_flag; - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glCallLists %d\n", n); - - switch (type) { - case GL_BYTE: - case GL_UNSIGNED_BYTE: - case GL_SHORT: - case GL_UNSIGNED_SHORT: - case GL_INT: - case GL_UNSIGNED_INT: - case GL_FLOAT: - case GL_2_BYTES: - case GL_3_BYTES: - case GL_4_BYTES: - /* OK */ - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glCallLists(type)"); - return; - } - - /* Save the CompileFlag status, turn it off, execute display list, - * and restore the CompileFlag. - */ - save_compile_flag = ctx->CompileFlag; - ctx->CompileFlag = GL_FALSE; - - for (i = 0; i < n; i++) { - GLuint list = (GLuint) (ctx->List.ListBase + translate_id(i, type, lists)); - execute_list(ctx, list); - } - - ctx->CompileFlag = save_compile_flag; - - /* also restore API function pointers to point to "save" versions */ - if (save_compile_flag) { - ctx->CurrentDispatch = ctx->Save; - _glapi_set_dispatch(ctx->CurrentDispatch); - } -} - - -/** - * Set the offset added to list numbers in glCallLists. - */ -static void GLAPIENTRY -_mesa_ListBase(GLuint base) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); /* must be called before assert */ - ASSERT_OUTSIDE_BEGIN_END(ctx); - ctx->List.ListBase = base; -} - - -/* Can no longer assume ctx->Exec->Func is equal to _mesa_Func. - */ -static void GLAPIENTRY -exec_Finish(void) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_Finish(ctx->Exec, ()); -} - -static void GLAPIENTRY -exec_Flush(void) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_Flush(ctx->Exec, ()); -} - -static void GLAPIENTRY -exec_GetBooleanv(GLenum pname, GLboolean *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetBooleanv(ctx->Exec, (pname, params)); -} - -static void GLAPIENTRY -exec_GetClipPlane(GLenum plane, GLdouble * equation) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetClipPlane(ctx->Exec, (plane, equation)); -} - -static void GLAPIENTRY -exec_GetDoublev(GLenum pname, GLdouble *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetDoublev(ctx->Exec, (pname, params)); -} - -static GLenum GLAPIENTRY -exec_GetError(void) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - return CALL_GetError(ctx->Exec, ()); -} - -static void GLAPIENTRY -exec_GetFloatv(GLenum pname, GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetFloatv(ctx->Exec, (pname, params)); -} - -static void GLAPIENTRY -exec_GetIntegerv(GLenum pname, GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetIntegerv(ctx->Exec, (pname, params)); -} - -static void GLAPIENTRY -exec_GetLightfv(GLenum light, GLenum pname, GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetLightfv(ctx->Exec, (light, pname, params)); -} - -static void GLAPIENTRY -exec_GetLightiv(GLenum light, GLenum pname, GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetLightiv(ctx->Exec, (light, pname, params)); -} - -static void GLAPIENTRY -exec_GetMapdv(GLenum target, GLenum query, GLdouble * v) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetMapdv(ctx->Exec, (target, query, v)); -} - -static void GLAPIENTRY -exec_GetMapfv(GLenum target, GLenum query, GLfloat * v) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetMapfv(ctx->Exec, (target, query, v)); -} - -static void GLAPIENTRY -exec_GetMapiv(GLenum target, GLenum query, GLint * v) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetMapiv(ctx->Exec, (target, query, v)); -} - -static void GLAPIENTRY -exec_GetMaterialfv(GLenum face, GLenum pname, GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetMaterialfv(ctx->Exec, (face, pname, params)); -} - -static void GLAPIENTRY -exec_GetMaterialiv(GLenum face, GLenum pname, GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetMaterialiv(ctx->Exec, (face, pname, params)); -} - -static void GLAPIENTRY -exec_GetPixelMapfv(GLenum map, GLfloat *values) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetPixelMapfv(ctx->Exec, (map, values)); -} - -static void GLAPIENTRY -exec_GetPixelMapuiv(GLenum map, GLuint *values) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetPixelMapuiv(ctx->Exec, (map, values)); -} - -static void GLAPIENTRY -exec_GetPixelMapusv(GLenum map, GLushort *values) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetPixelMapusv(ctx->Exec, (map, values)); -} - -static void GLAPIENTRY -exec_GetPolygonStipple(GLubyte * dest) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetPolygonStipple(ctx->Exec, (dest)); -} - -static const GLubyte *GLAPIENTRY -exec_GetString(GLenum name) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - return CALL_GetString(ctx->Exec, (name)); -} - -static void GLAPIENTRY -exec_GetTexEnvfv(GLenum target, GLenum pname, GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetTexEnvfv(ctx->Exec, (target, pname, params)); -} - -static void GLAPIENTRY -exec_GetTexEnviv(GLenum target, GLenum pname, GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetTexEnviv(ctx->Exec, (target, pname, params)); -} - -static void GLAPIENTRY -exec_GetTexGendv(GLenum coord, GLenum pname, GLdouble *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetTexGendv(ctx->Exec, (coord, pname, params)); -} - -static void GLAPIENTRY -exec_GetTexGenfv(GLenum coord, GLenum pname, GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetTexGenfv(ctx->Exec, (coord, pname, params)); -} - -static void GLAPIENTRY -exec_GetTexGeniv(GLenum coord, GLenum pname, GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetTexGeniv(ctx->Exec, (coord, pname, params)); -} - -static void GLAPIENTRY -exec_GetTexImage(GLenum target, GLint level, GLenum format, - GLenum type, GLvoid * pixels) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetTexImage(ctx->Exec, (target, level, format, type, pixels)); -} - -static void GLAPIENTRY -exec_GetTexLevelParameterfv(GLenum target, GLint level, - GLenum pname, GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetTexLevelParameterfv(ctx->Exec, (target, level, pname, params)); -} - -static void GLAPIENTRY -exec_GetTexLevelParameteriv(GLenum target, GLint level, - GLenum pname, GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetTexLevelParameteriv(ctx->Exec, (target, level, pname, params)); -} - -static void GLAPIENTRY -exec_GetTexParameterfv(GLenum target, GLenum pname, GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetTexParameterfv(ctx->Exec, (target, pname, params)); -} - -static void GLAPIENTRY -exec_GetTexParameteriv(GLenum target, GLenum pname, GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetTexParameteriv(ctx->Exec, (target, pname, params)); -} - -static GLboolean GLAPIENTRY -exec_IsEnabled(GLenum cap) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - return CALL_IsEnabled(ctx->Exec, (cap)); -} - -static void GLAPIENTRY -exec_PixelStoref(GLenum pname, GLfloat param) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_PixelStoref(ctx->Exec, (pname, param)); -} - -static void GLAPIENTRY -exec_PixelStorei(GLenum pname, GLint param) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_PixelStorei(ctx->Exec, (pname, param)); -} - -static void GLAPIENTRY -exec_ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, - GLenum format, GLenum type, GLvoid * pixels) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_ReadPixels(ctx->Exec, (x, y, width, height, format, type, pixels)); -} - -static GLint GLAPIENTRY -exec_RenderMode(GLenum mode) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - return CALL_RenderMode(ctx->Exec, (mode)); -} - -static void GLAPIENTRY -exec_FeedbackBuffer(GLsizei size, GLenum type, GLfloat * buffer) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_FeedbackBuffer(ctx->Exec, (size, type, buffer)); -} - -static void GLAPIENTRY -exec_SelectBuffer(GLsizei size, GLuint * buffer) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_SelectBuffer(ctx->Exec, (size, buffer)); -} - -static GLboolean GLAPIENTRY -exec_AreTexturesResident(GLsizei n, const GLuint * texName, - GLboolean * residences) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - return CALL_AreTexturesResident(ctx->Exec, (n, texName, residences)); -} - -static void GLAPIENTRY -exec_ColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_ColorPointer(ctx->Exec, (size, type, stride, ptr)); -} - -static void GLAPIENTRY -exec_DeleteTextures(GLsizei n, const GLuint * texName) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_DeleteTextures(ctx->Exec, (n, texName)); -} - -static void GLAPIENTRY -exec_DisableClientState(GLenum cap) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_DisableClientState(ctx->Exec, (cap)); -} - -static void GLAPIENTRY -exec_EdgeFlagPointer(GLsizei stride, const GLvoid * vptr) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_EdgeFlagPointer(ctx->Exec, (stride, vptr)); -} - -static void GLAPIENTRY -exec_EnableClientState(GLenum cap) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_EnableClientState(ctx->Exec, (cap)); -} - -static void GLAPIENTRY -exec_GenTextures(GLsizei n, GLuint * texName) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GenTextures(ctx->Exec, (n, texName)); -} - -static void GLAPIENTRY -exec_GetPointerv(GLenum pname, GLvoid **params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetPointerv(ctx->Exec, (pname, params)); -} - -static void GLAPIENTRY -exec_IndexPointer(GLenum type, GLsizei stride, const GLvoid *ptr) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_IndexPointer(ctx->Exec, (type, stride, ptr)); -} - -static void GLAPIENTRY -exec_InterleavedArrays(GLenum format, GLsizei stride, const GLvoid * pointer) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_InterleavedArrays(ctx->Exec, (format, stride, pointer)); -} - -static GLboolean GLAPIENTRY -exec_IsTexture(GLuint texture) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - return CALL_IsTexture(ctx->Exec, (texture)); -} - -static void GLAPIENTRY -exec_NormalPointer(GLenum type, GLsizei stride, const GLvoid *ptr) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_NormalPointer(ctx->Exec, (type, stride, ptr)); -} - -static void GLAPIENTRY -exec_PopClientAttrib(void) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_PopClientAttrib(ctx->Exec, ()); -} - -static void GLAPIENTRY -exec_PushClientAttrib(GLbitfield mask) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_PushClientAttrib(ctx->Exec, (mask)); -} - -static void GLAPIENTRY -exec_TexCoordPointer(GLint size, GLenum type, GLsizei stride, - const GLvoid *ptr) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_TexCoordPointer(ctx->Exec, (size, type, stride, ptr)); -} - -static void GLAPIENTRY -exec_GetCompressedTexImageARB(GLenum target, GLint level, GLvoid * img) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetCompressedTexImageARB(ctx->Exec, (target, level, img)); -} - -static void GLAPIENTRY -exec_VertexPointer(GLint size, GLenum type, GLsizei stride, - const GLvoid *ptr) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_VertexPointer(ctx->Exec, (size, type, stride, ptr)); -} - -static void GLAPIENTRY -exec_CopyConvolutionFilter1D(GLenum target, GLenum internalFormat, - GLint x, GLint y, GLsizei width) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_CopyConvolutionFilter1D(ctx->Exec, - (target, internalFormat, x, y, width)); -} - -static void GLAPIENTRY -exec_CopyConvolutionFilter2D(GLenum target, GLenum internalFormat, - GLint x, GLint y, GLsizei width, GLsizei height) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_CopyConvolutionFilter2D(ctx->Exec, - (target, internalFormat, x, y, width, - height)); -} - -static void GLAPIENTRY -exec_GetColorTable(GLenum target, GLenum format, GLenum type, GLvoid * data) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetColorTable(ctx->Exec, (target, format, type, data)); -} - -static void GLAPIENTRY -exec_GetColorTableParameterfv(GLenum target, GLenum pname, GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetColorTableParameterfv(ctx->Exec, (target, pname, params)); -} - -static void GLAPIENTRY -exec_GetColorTableParameteriv(GLenum target, GLenum pname, GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetColorTableParameteriv(ctx->Exec, (target, pname, params)); -} - -static void GLAPIENTRY -exec_GetConvolutionFilter(GLenum target, GLenum format, GLenum type, - GLvoid * image) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetConvolutionFilter(ctx->Exec, (target, format, type, image)); -} - -static void GLAPIENTRY -exec_GetConvolutionParameterfv(GLenum target, GLenum pname, GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetConvolutionParameterfv(ctx->Exec, (target, pname, params)); -} - -static void GLAPIENTRY -exec_GetConvolutionParameteriv(GLenum target, GLenum pname, GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetConvolutionParameteriv(ctx->Exec, (target, pname, params)); -} - -static void GLAPIENTRY -exec_GetHistogram(GLenum target, GLboolean reset, GLenum format, - GLenum type, GLvoid *values) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetHistogram(ctx->Exec, (target, reset, format, type, values)); -} - -static void GLAPIENTRY -exec_GetHistogramParameterfv(GLenum target, GLenum pname, GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetHistogramParameterfv(ctx->Exec, (target, pname, params)); -} - -static void GLAPIENTRY -exec_GetHistogramParameteriv(GLenum target, GLenum pname, GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetHistogramParameteriv(ctx->Exec, (target, pname, params)); -} - -static void GLAPIENTRY -exec_GetMinmax(GLenum target, GLboolean reset, GLenum format, - GLenum type, GLvoid *values) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetMinmax(ctx->Exec, (target, reset, format, type, values)); -} - -static void GLAPIENTRY -exec_GetMinmaxParameterfv(GLenum target, GLenum pname, GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetMinmaxParameterfv(ctx->Exec, (target, pname, params)); -} - -static void GLAPIENTRY -exec_GetMinmaxParameteriv(GLenum target, GLenum pname, GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetMinmaxParameteriv(ctx->Exec, (target, pname, params)); -} - -static void GLAPIENTRY -exec_GetSeparableFilter(GLenum target, GLenum format, GLenum type, - GLvoid *row, GLvoid *column, GLvoid *span) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_GetSeparableFilter(ctx->Exec, - (target, format, type, row, column, span)); -} - -static void GLAPIENTRY -exec_SeparableFilter2D(GLenum target, GLenum internalFormat, - GLsizei width, GLsizei height, GLenum format, - GLenum type, const GLvoid *row, const GLvoid *column) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_SeparableFilter2D(ctx->Exec, - (target, internalFormat, width, height, format, - type, row, column)); -} - -static void GLAPIENTRY -exec_ColorPointerEXT(GLint size, GLenum type, GLsizei stride, - GLsizei count, const GLvoid *ptr) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_ColorPointerEXT(ctx->Exec, (size, type, stride, count, ptr)); -} - -static void GLAPIENTRY -exec_EdgeFlagPointerEXT(GLsizei stride, GLsizei count, const GLboolean *ptr) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_EdgeFlagPointerEXT(ctx->Exec, (stride, count, ptr)); -} - -static void GLAPIENTRY -exec_IndexPointerEXT(GLenum type, GLsizei stride, GLsizei count, - const GLvoid *ptr) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_IndexPointerEXT(ctx->Exec, (type, stride, count, ptr)); -} - -static void GLAPIENTRY -exec_NormalPointerEXT(GLenum type, GLsizei stride, GLsizei count, - const GLvoid *ptr) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_NormalPointerEXT(ctx->Exec, (type, stride, count, ptr)); -} - -static void GLAPIENTRY -exec_TexCoordPointerEXT(GLint size, GLenum type, GLsizei stride, - GLsizei count, const GLvoid *ptr) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_TexCoordPointerEXT(ctx->Exec, (size, type, stride, count, ptr)); -} - -static void GLAPIENTRY -exec_VertexPointerEXT(GLint size, GLenum type, GLsizei stride, - GLsizei count, const GLvoid *ptr) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_VertexPointerEXT(ctx->Exec, (size, type, stride, count, ptr)); -} - -static void GLAPIENTRY -exec_LockArraysEXT(GLint first, GLsizei count) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_LockArraysEXT(ctx->Exec, (first, count)); -} - -static void GLAPIENTRY -exec_UnlockArraysEXT(void) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_UnlockArraysEXT(ctx->Exec, ()); -} - -static void GLAPIENTRY -exec_ClientActiveTextureARB(GLenum target) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_ClientActiveTextureARB(ctx->Exec, (target)); -} - -static void GLAPIENTRY -exec_SecondaryColorPointerEXT(GLint size, GLenum type, - GLsizei stride, const GLvoid *ptr) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_SecondaryColorPointerEXT(ctx->Exec, (size, type, stride, ptr)); -} - -static void GLAPIENTRY -exec_FogCoordPointerEXT(GLenum type, GLsizei stride, const GLvoid *ptr) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_FogCoordPointerEXT(ctx->Exec, (type, stride, ptr)); -} - -/* GL_EXT_multi_draw_arrays */ -static void GLAPIENTRY -exec_MultiDrawArraysEXT(GLenum mode, const GLint *first, - const GLsizei *count, GLsizei primcount) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_MultiDrawArraysEXT(ctx->Exec, (mode, first, count, primcount)); -} - -/* GL_IBM_multimode_draw_arrays */ -static void GLAPIENTRY -exec_MultiModeDrawArraysIBM(const GLenum * mode, const GLint * first, - const GLsizei * count, GLsizei primcount, - GLint modestride) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_MultiModeDrawArraysIBM(ctx->Exec, - (mode, first, count, primcount, modestride)); -} - -/* GL_IBM_multimode_draw_arrays */ -static void GLAPIENTRY -exec_MultiModeDrawElementsIBM(const GLenum * mode, - const GLsizei * count, - GLenum type, - const GLvoid * const *indices, - GLsizei primcount, GLint modestride) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_MultiModeDrawElementsIBM(ctx->Exec, - (mode, count, type, indices, primcount, - modestride)); -} - - - -/** - * Setup the given dispatch table to point to Mesa's display list - * building functions. - * - * This does not include any of the tnl functions - they are - * initialized from _mesa_init_api_defaults and from the active vtxfmt - * struct. - */ -struct _glapi_table * -_mesa_create_save_table(void) -{ - struct _glapi_table *table; - - table = _mesa_alloc_dispatch_table(_gloffset_COUNT); - if (table == NULL) - return NULL; - - _mesa_loopback_init_api_table(table); - - /* GL 1.0 */ - SET_Accum(table, save_Accum); - SET_AlphaFunc(table, save_AlphaFunc); - SET_Bitmap(table, save_Bitmap); - SET_BlendFunc(table, save_BlendFunc); - SET_CallList(table, save_CallList); - SET_CallLists(table, save_CallLists); - SET_Clear(table, save_Clear); - SET_ClearAccum(table, save_ClearAccum); - SET_ClearColor(table, save_ClearColor); - SET_ClearDepth(table, save_ClearDepth); - SET_ClearIndex(table, save_ClearIndex); - SET_ClearStencil(table, save_ClearStencil); - SET_ClipPlane(table, save_ClipPlane); - SET_ColorMask(table, save_ColorMask); - SET_ColorMaskIndexedEXT(table, save_ColorMaskIndexed); - SET_ColorMaterial(table, save_ColorMaterial); - SET_CopyPixels(table, save_CopyPixels); - SET_CullFace(table, save_CullFace); - SET_DeleteLists(table, _mesa_DeleteLists); - SET_DepthFunc(table, save_DepthFunc); - SET_DepthMask(table, save_DepthMask); - SET_DepthRange(table, save_DepthRange); - SET_Disable(table, save_Disable); - SET_DisableIndexedEXT(table, save_DisableIndexed); - SET_DrawBuffer(table, save_DrawBuffer); - SET_DrawPixels(table, save_DrawPixels); - SET_Enable(table, save_Enable); - SET_EnableIndexedEXT(table, save_EnableIndexed); - SET_EndList(table, _mesa_EndList); - SET_EvalMesh1(table, save_EvalMesh1); - SET_EvalMesh2(table, save_EvalMesh2); - SET_Finish(table, exec_Finish); - SET_Flush(table, exec_Flush); - SET_Fogf(table, save_Fogf); - SET_Fogfv(table, save_Fogfv); - SET_Fogi(table, save_Fogi); - SET_Fogiv(table, save_Fogiv); - SET_FrontFace(table, save_FrontFace); - SET_Frustum(table, save_Frustum); - SET_GenLists(table, _mesa_GenLists); - SET_GetBooleanv(table, exec_GetBooleanv); - SET_GetClipPlane(table, exec_GetClipPlane); - SET_GetDoublev(table, exec_GetDoublev); - SET_GetError(table, exec_GetError); - SET_GetFloatv(table, exec_GetFloatv); - SET_GetIntegerv(table, exec_GetIntegerv); - SET_GetLightfv(table, exec_GetLightfv); - SET_GetLightiv(table, exec_GetLightiv); - SET_GetMapdv(table, exec_GetMapdv); - SET_GetMapfv(table, exec_GetMapfv); - SET_GetMapiv(table, exec_GetMapiv); - SET_GetMaterialfv(table, exec_GetMaterialfv); - SET_GetMaterialiv(table, exec_GetMaterialiv); - SET_GetPixelMapfv(table, exec_GetPixelMapfv); - SET_GetPixelMapuiv(table, exec_GetPixelMapuiv); - SET_GetPixelMapusv(table, exec_GetPixelMapusv); - SET_GetPolygonStipple(table, exec_GetPolygonStipple); - SET_GetString(table, exec_GetString); - SET_GetTexEnvfv(table, exec_GetTexEnvfv); - SET_GetTexEnviv(table, exec_GetTexEnviv); - SET_GetTexGendv(table, exec_GetTexGendv); - SET_GetTexGenfv(table, exec_GetTexGenfv); - SET_GetTexGeniv(table, exec_GetTexGeniv); - SET_GetTexImage(table, exec_GetTexImage); - SET_GetTexLevelParameterfv(table, exec_GetTexLevelParameterfv); - SET_GetTexLevelParameteriv(table, exec_GetTexLevelParameteriv); - SET_GetTexParameterfv(table, exec_GetTexParameterfv); - SET_GetTexParameteriv(table, exec_GetTexParameteriv); - SET_Hint(table, save_Hint); - SET_IndexMask(table, save_IndexMask); - SET_InitNames(table, save_InitNames); - SET_IsEnabled(table, exec_IsEnabled); - SET_IsList(table, _mesa_IsList); - SET_LightModelf(table, save_LightModelf); - SET_LightModelfv(table, save_LightModelfv); - SET_LightModeli(table, save_LightModeli); - SET_LightModeliv(table, save_LightModeliv); - SET_Lightf(table, save_Lightf); - SET_Lightfv(table, save_Lightfv); - SET_Lighti(table, save_Lighti); - SET_Lightiv(table, save_Lightiv); - SET_LineStipple(table, save_LineStipple); - SET_LineWidth(table, save_LineWidth); - SET_ListBase(table, save_ListBase); - SET_LoadIdentity(table, save_LoadIdentity); - SET_LoadMatrixd(table, save_LoadMatrixd); - SET_LoadMatrixf(table, save_LoadMatrixf); - SET_LoadName(table, save_LoadName); - SET_LogicOp(table, save_LogicOp); - SET_Map1d(table, save_Map1d); - SET_Map1f(table, save_Map1f); - SET_Map2d(table, save_Map2d); - SET_Map2f(table, save_Map2f); - SET_MapGrid1d(table, save_MapGrid1d); - SET_MapGrid1f(table, save_MapGrid1f); - SET_MapGrid2d(table, save_MapGrid2d); - SET_MapGrid2f(table, save_MapGrid2f); - SET_MatrixMode(table, save_MatrixMode); - SET_MultMatrixd(table, save_MultMatrixd); - SET_MultMatrixf(table, save_MultMatrixf); - SET_NewList(table, save_NewList); - SET_Ortho(table, save_Ortho); - SET_PassThrough(table, save_PassThrough); - SET_PixelMapfv(table, save_PixelMapfv); - SET_PixelMapuiv(table, save_PixelMapuiv); - SET_PixelMapusv(table, save_PixelMapusv); - SET_PixelStoref(table, exec_PixelStoref); - SET_PixelStorei(table, exec_PixelStorei); - SET_PixelTransferf(table, save_PixelTransferf); - SET_PixelTransferi(table, save_PixelTransferi); - SET_PixelZoom(table, save_PixelZoom); - SET_PointSize(table, save_PointSize); - SET_PolygonMode(table, save_PolygonMode); - SET_PolygonOffset(table, save_PolygonOffset); - SET_PolygonStipple(table, save_PolygonStipple); - SET_PopAttrib(table, save_PopAttrib); - SET_PopMatrix(table, save_PopMatrix); - SET_PopName(table, save_PopName); - SET_PushAttrib(table, save_PushAttrib); - SET_PushMatrix(table, save_PushMatrix); - SET_PushName(table, save_PushName); - SET_RasterPos2d(table, save_RasterPos2d); - SET_RasterPos2dv(table, save_RasterPos2dv); - SET_RasterPos2f(table, save_RasterPos2f); - SET_RasterPos2fv(table, save_RasterPos2fv); - SET_RasterPos2i(table, save_RasterPos2i); - SET_RasterPos2iv(table, save_RasterPos2iv); - SET_RasterPos2s(table, save_RasterPos2s); - SET_RasterPos2sv(table, save_RasterPos2sv); - SET_RasterPos3d(table, save_RasterPos3d); - SET_RasterPos3dv(table, save_RasterPos3dv); - SET_RasterPos3f(table, save_RasterPos3f); - SET_RasterPos3fv(table, save_RasterPos3fv); - SET_RasterPos3i(table, save_RasterPos3i); - SET_RasterPos3iv(table, save_RasterPos3iv); - SET_RasterPos3s(table, save_RasterPos3s); - SET_RasterPos3sv(table, save_RasterPos3sv); - SET_RasterPos4d(table, save_RasterPos4d); - SET_RasterPos4dv(table, save_RasterPos4dv); - SET_RasterPos4f(table, save_RasterPos4f); - SET_RasterPos4fv(table, save_RasterPos4fv); - SET_RasterPos4i(table, save_RasterPos4i); - SET_RasterPos4iv(table, save_RasterPos4iv); - SET_RasterPos4s(table, save_RasterPos4s); - SET_RasterPos4sv(table, save_RasterPos4sv); - SET_ReadBuffer(table, save_ReadBuffer); - SET_ReadPixels(table, exec_ReadPixels); - SET_RenderMode(table, exec_RenderMode); - SET_Rotated(table, save_Rotated); - SET_Rotatef(table, save_Rotatef); - SET_Scaled(table, save_Scaled); - SET_Scalef(table, save_Scalef); - SET_Scissor(table, save_Scissor); - SET_FeedbackBuffer(table, exec_FeedbackBuffer); - SET_SelectBuffer(table, exec_SelectBuffer); - SET_ShadeModel(table, save_ShadeModel); - SET_StencilFunc(table, save_StencilFunc); - SET_StencilMask(table, save_StencilMask); - SET_StencilOp(table, save_StencilOp); - SET_TexEnvf(table, save_TexEnvf); - SET_TexEnvfv(table, save_TexEnvfv); - SET_TexEnvi(table, save_TexEnvi); - SET_TexEnviv(table, save_TexEnviv); - SET_TexGend(table, save_TexGend); - SET_TexGendv(table, save_TexGendv); - SET_TexGenf(table, save_TexGenf); - SET_TexGenfv(table, save_TexGenfv); - SET_TexGeni(table, save_TexGeni); - SET_TexGeniv(table, save_TexGeniv); - SET_TexImage1D(table, save_TexImage1D); - SET_TexImage2D(table, save_TexImage2D); - SET_TexParameterf(table, save_TexParameterf); - SET_TexParameterfv(table, save_TexParameterfv); - SET_TexParameteri(table, save_TexParameteri); - SET_TexParameteriv(table, save_TexParameteriv); - SET_Translated(table, save_Translated); - SET_Translatef(table, save_Translatef); - SET_Viewport(table, save_Viewport); - - /* GL 1.1 */ - SET_AreTexturesResident(table, exec_AreTexturesResident); - SET_BindTexture(table, save_BindTexture); - SET_ColorPointer(table, exec_ColorPointer); - SET_CopyTexImage1D(table, save_CopyTexImage1D); - SET_CopyTexImage2D(table, save_CopyTexImage2D); - SET_CopyTexSubImage1D(table, save_CopyTexSubImage1D); - SET_CopyTexSubImage2D(table, save_CopyTexSubImage2D); - SET_DeleteTextures(table, exec_DeleteTextures); - SET_DisableClientState(table, exec_DisableClientState); - SET_EdgeFlagPointer(table, exec_EdgeFlagPointer); - SET_EnableClientState(table, exec_EnableClientState); - SET_GenTextures(table, exec_GenTextures); - SET_GetPointerv(table, exec_GetPointerv); - SET_IndexPointer(table, exec_IndexPointer); - SET_InterleavedArrays(table, exec_InterleavedArrays); - SET_IsTexture(table, exec_IsTexture); - SET_NormalPointer(table, exec_NormalPointer); - SET_PopClientAttrib(table, exec_PopClientAttrib); - SET_PrioritizeTextures(table, save_PrioritizeTextures); - SET_PushClientAttrib(table, exec_PushClientAttrib); - SET_TexCoordPointer(table, exec_TexCoordPointer); - SET_TexSubImage1D(table, save_TexSubImage1D); - SET_TexSubImage2D(table, save_TexSubImage2D); - SET_VertexPointer(table, exec_VertexPointer); - - /* GL 1.2 */ - SET_CopyTexSubImage3D(table, save_CopyTexSubImage3D); - SET_TexImage3D(table, save_TexImage3D); - SET_TexSubImage3D(table, save_TexSubImage3D); - - /* GL 2.0 */ - SET_StencilFuncSeparate(table, save_StencilFuncSeparate); - SET_StencilMaskSeparate(table, save_StencilMaskSeparate); - SET_StencilOpSeparate(table, save_StencilOpSeparate); - - /* ATI_separate_stencil */ - SET_StencilFuncSeparateATI(table, save_StencilFuncSeparateATI); - - /* GL_ARB_imaging */ - /* Not all are supported */ - SET_BlendColor(table, save_BlendColor); - SET_BlendEquation(table, save_BlendEquation); - SET_ColorSubTable(table, save_ColorSubTable); - SET_ColorTable(table, save_ColorTable); - SET_ColorTableParameterfv(table, save_ColorTableParameterfv); - SET_ColorTableParameteriv(table, save_ColorTableParameteriv); - SET_ConvolutionFilter1D(table, save_ConvolutionFilter1D); - SET_ConvolutionFilter2D(table, save_ConvolutionFilter2D); - SET_ConvolutionParameterf(table, save_ConvolutionParameterf); - SET_ConvolutionParameterfv(table, save_ConvolutionParameterfv); - SET_ConvolutionParameteri(table, save_ConvolutionParameteri); - SET_ConvolutionParameteriv(table, save_ConvolutionParameteriv); - SET_CopyColorSubTable(table, save_CopyColorSubTable); - SET_CopyColorTable(table, save_CopyColorTable); - SET_CopyConvolutionFilter1D(table, exec_CopyConvolutionFilter1D); - SET_CopyConvolutionFilter2D(table, exec_CopyConvolutionFilter2D); - SET_GetColorTable(table, exec_GetColorTable); - SET_GetColorTableParameterfv(table, exec_GetColorTableParameterfv); - SET_GetColorTableParameteriv(table, exec_GetColorTableParameteriv); - SET_GetConvolutionFilter(table, exec_GetConvolutionFilter); - SET_GetConvolutionParameterfv(table, exec_GetConvolutionParameterfv); - SET_GetConvolutionParameteriv(table, exec_GetConvolutionParameteriv); - SET_GetHistogram(table, exec_GetHistogram); - SET_GetHistogramParameterfv(table, exec_GetHistogramParameterfv); - SET_GetHistogramParameteriv(table, exec_GetHistogramParameteriv); - SET_GetMinmax(table, exec_GetMinmax); - SET_GetMinmaxParameterfv(table, exec_GetMinmaxParameterfv); - SET_GetMinmaxParameteriv(table, exec_GetMinmaxParameteriv); - SET_GetSeparableFilter(table, exec_GetSeparableFilter); - SET_Histogram(table, save_Histogram); - SET_Minmax(table, save_Minmax); - SET_ResetHistogram(table, save_ResetHistogram); - SET_ResetMinmax(table, save_ResetMinmax); - SET_SeparableFilter2D(table, exec_SeparableFilter2D); - - /* 2. GL_EXT_blend_color */ -#if 0 - SET_BlendColorEXT(table, save_BlendColorEXT); -#endif - - /* 3. GL_EXT_polygon_offset */ - SET_PolygonOffsetEXT(table, save_PolygonOffsetEXT); - - /* 6. GL_EXT_texture3d */ -#if 0 - SET_CopyTexSubImage3DEXT(table, save_CopyTexSubImage3D); - SET_TexImage3DEXT(table, save_TexImage3DEXT); - SET_TexSubImage3DEXT(table, save_TexSubImage3D); -#endif - - /* 14. GL_SGI_color_table */ -#if 0 - SET_ColorTableSGI(table, save_ColorTable); - SET_ColorSubTableSGI(table, save_ColorSubTable); - SET_GetColorTableSGI(table, exec_GetColorTable); - SET_GetColorTableParameterfvSGI(table, exec_GetColorTableParameterfv); - SET_GetColorTableParameterivSGI(table, exec_GetColorTableParameteriv); -#endif - - /* 30. GL_EXT_vertex_array */ - SET_ColorPointerEXT(table, exec_ColorPointerEXT); - SET_EdgeFlagPointerEXT(table, exec_EdgeFlagPointerEXT); - SET_IndexPointerEXT(table, exec_IndexPointerEXT); - SET_NormalPointerEXT(table, exec_NormalPointerEXT); - SET_TexCoordPointerEXT(table, exec_TexCoordPointerEXT); - SET_VertexPointerEXT(table, exec_VertexPointerEXT); - - /* 37. GL_EXT_blend_minmax */ -#if 0 - SET_BlendEquationEXT(table, save_BlendEquationEXT); -#endif - - /* 54. GL_EXT_point_parameters */ - SET_PointParameterfEXT(table, save_PointParameterfEXT); - SET_PointParameterfvEXT(table, save_PointParameterfvEXT); - - /* 97. GL_EXT_compiled_vertex_array */ - SET_LockArraysEXT(table, exec_LockArraysEXT); - SET_UnlockArraysEXT(table, exec_UnlockArraysEXT); - - /* 145. GL_EXT_secondary_color */ - SET_SecondaryColorPointerEXT(table, exec_SecondaryColorPointerEXT); - - /* 148. GL_EXT_multi_draw_arrays */ - SET_MultiDrawArraysEXT(table, exec_MultiDrawArraysEXT); - - /* 149. GL_EXT_fog_coord */ - SET_FogCoordPointerEXT(table, exec_FogCoordPointerEXT); - - /* 173. GL_EXT_blend_func_separate */ - SET_BlendFuncSeparateEXT(table, save_BlendFuncSeparateEXT); - - /* 196. GL_MESA_resize_buffers */ - SET_ResizeBuffersMESA(table, _mesa_ResizeBuffersMESA); - - /* 197. GL_MESA_window_pos */ - SET_WindowPos2dMESA(table, save_WindowPos2dMESA); - SET_WindowPos2dvMESA(table, save_WindowPos2dvMESA); - SET_WindowPos2fMESA(table, save_WindowPos2fMESA); - SET_WindowPos2fvMESA(table, save_WindowPos2fvMESA); - SET_WindowPos2iMESA(table, save_WindowPos2iMESA); - SET_WindowPos2ivMESA(table, save_WindowPos2ivMESA); - SET_WindowPos2sMESA(table, save_WindowPos2sMESA); - SET_WindowPos2svMESA(table, save_WindowPos2svMESA); - SET_WindowPos3dMESA(table, save_WindowPos3dMESA); - SET_WindowPos3dvMESA(table, save_WindowPos3dvMESA); - SET_WindowPos3fMESA(table, save_WindowPos3fMESA); - SET_WindowPos3fvMESA(table, save_WindowPos3fvMESA); - SET_WindowPos3iMESA(table, save_WindowPos3iMESA); - SET_WindowPos3ivMESA(table, save_WindowPos3ivMESA); - SET_WindowPos3sMESA(table, save_WindowPos3sMESA); - SET_WindowPos3svMESA(table, save_WindowPos3svMESA); - SET_WindowPos4dMESA(table, save_WindowPos4dMESA); - SET_WindowPos4dvMESA(table, save_WindowPos4dvMESA); - SET_WindowPos4fMESA(table, save_WindowPos4fMESA); - SET_WindowPos4fvMESA(table, save_WindowPos4fvMESA); - SET_WindowPos4iMESA(table, save_WindowPos4iMESA); - SET_WindowPos4ivMESA(table, save_WindowPos4ivMESA); - SET_WindowPos4sMESA(table, save_WindowPos4sMESA); - SET_WindowPos4svMESA(table, save_WindowPos4svMESA); - - /* 200. GL_IBM_multimode_draw_arrays */ - SET_MultiModeDrawArraysIBM(table, exec_MultiModeDrawArraysIBM); - SET_MultiModeDrawElementsIBM(table, exec_MultiModeDrawElementsIBM); - -#if FEATURE_NV_vertex_program - /* 233. GL_NV_vertex_program */ - /* The following commands DO NOT go into display lists: - * AreProgramsResidentNV, IsProgramNV, GenProgramsNV, DeleteProgramsNV, - * VertexAttribPointerNV, GetProgram*, GetVertexAttrib* - */ - SET_BindProgramNV(table, save_BindProgramNV); - SET_DeleteProgramsNV(table, _mesa_DeletePrograms); - SET_ExecuteProgramNV(table, save_ExecuteProgramNV); - SET_GenProgramsNV(table, _mesa_GenPrograms); - SET_AreProgramsResidentNV(table, _mesa_AreProgramsResidentNV); - SET_RequestResidentProgramsNV(table, save_RequestResidentProgramsNV); - SET_GetProgramParameterfvNV(table, _mesa_GetProgramParameterfvNV); - SET_GetProgramParameterdvNV(table, _mesa_GetProgramParameterdvNV); - SET_GetProgramivNV(table, _mesa_GetProgramivNV); - SET_GetProgramStringNV(table, _mesa_GetProgramStringNV); - SET_GetTrackMatrixivNV(table, _mesa_GetTrackMatrixivNV); - SET_GetVertexAttribdvNV(table, _mesa_GetVertexAttribdvNV); - SET_GetVertexAttribfvNV(table, _mesa_GetVertexAttribfvNV); - SET_GetVertexAttribivNV(table, _mesa_GetVertexAttribivNV); - SET_GetVertexAttribPointervNV(table, _mesa_GetVertexAttribPointervNV); - SET_IsProgramNV(table, _mesa_IsProgramARB); - SET_LoadProgramNV(table, save_LoadProgramNV); - SET_ProgramEnvParameter4dARB(table, save_ProgramEnvParameter4dARB); - SET_ProgramEnvParameter4dvARB(table, save_ProgramEnvParameter4dvARB); - SET_ProgramEnvParameter4fARB(table, save_ProgramEnvParameter4fARB); - SET_ProgramEnvParameter4fvARB(table, save_ProgramEnvParameter4fvARB); - SET_ProgramParameters4dvNV(table, save_ProgramParameters4dvNV); - SET_ProgramParameters4fvNV(table, save_ProgramParameters4fvNV); - SET_TrackMatrixNV(table, save_TrackMatrixNV); - SET_VertexAttribPointerNV(table, _mesa_VertexAttribPointerNV); -#endif - - /* 244. GL_ATI_envmap_bumpmap */ - SET_TexBumpParameterivATI(table, save_TexBumpParameterivATI); - SET_TexBumpParameterfvATI(table, save_TexBumpParameterfvATI); - - /* 245. GL_ATI_fragment_shader */ -#if FEATURE_ATI_fragment_shader - SET_BindFragmentShaderATI(table, save_BindFragmentShaderATI); - SET_SetFragmentShaderConstantATI(table, save_SetFragmentShaderConstantATI); -#endif - - /* 282. GL_NV_fragment_program */ -#if FEATURE_NV_fragment_program - SET_ProgramNamedParameter4fNV(table, save_ProgramNamedParameter4fNV); - SET_ProgramNamedParameter4dNV(table, save_ProgramNamedParameter4dNV); - SET_ProgramNamedParameter4fvNV(table, save_ProgramNamedParameter4fvNV); - SET_ProgramNamedParameter4dvNV(table, save_ProgramNamedParameter4dvNV); - SET_GetProgramNamedParameterfvNV(table, - _mesa_GetProgramNamedParameterfvNV); - SET_GetProgramNamedParameterdvNV(table, - _mesa_GetProgramNamedParameterdvNV); - SET_ProgramLocalParameter4dARB(table, save_ProgramLocalParameter4dARB); - SET_ProgramLocalParameter4dvARB(table, save_ProgramLocalParameter4dvARB); - SET_ProgramLocalParameter4fARB(table, save_ProgramLocalParameter4fARB); - SET_ProgramLocalParameter4fvARB(table, save_ProgramLocalParameter4fvARB); - SET_GetProgramLocalParameterdvARB(table, - _mesa_GetProgramLocalParameterdvARB); - SET_GetProgramLocalParameterfvARB(table, - _mesa_GetProgramLocalParameterfvARB); -#endif - - /* 262. GL_NV_point_sprite */ - SET_PointParameteriNV(table, save_PointParameteriNV); - SET_PointParameterivNV(table, save_PointParameterivNV); - - /* 268. GL_EXT_stencil_two_side */ - SET_ActiveStencilFaceEXT(table, save_ActiveStencilFaceEXT); - - /* 273. GL_APPLE_vertex_array_object */ - SET_BindVertexArrayAPPLE(table, _mesa_BindVertexArrayAPPLE); - SET_DeleteVertexArraysAPPLE(table, _mesa_DeleteVertexArraysAPPLE); - SET_GenVertexArraysAPPLE(table, _mesa_GenVertexArraysAPPLE); - SET_IsVertexArrayAPPLE(table, _mesa_IsVertexArrayAPPLE); - - /* GL_ARB_vertex_array_object */ - SET_BindVertexArray(table, _mesa_BindVertexArray); - SET_GenVertexArrays(table, _mesa_GenVertexArrays); - - /* ???. GL_EXT_depth_bounds_test */ - SET_DepthBoundsEXT(table, save_DepthBoundsEXT); - - /* ARB 1. GL_ARB_multitexture */ - SET_ActiveTextureARB(table, save_ActiveTextureARB); - SET_ClientActiveTextureARB(table, exec_ClientActiveTextureARB); - - /* ARB 3. GL_ARB_transpose_matrix */ - SET_LoadTransposeMatrixdARB(table, save_LoadTransposeMatrixdARB); - SET_LoadTransposeMatrixfARB(table, save_LoadTransposeMatrixfARB); - SET_MultTransposeMatrixdARB(table, save_MultTransposeMatrixdARB); - SET_MultTransposeMatrixfARB(table, save_MultTransposeMatrixfARB); - - /* ARB 5. GL_ARB_multisample */ - SET_SampleCoverageARB(table, save_SampleCoverageARB); - - /* ARB 12. GL_ARB_texture_compression */ - SET_CompressedTexImage3DARB(table, save_CompressedTexImage3DARB); - SET_CompressedTexImage2DARB(table, save_CompressedTexImage2DARB); - SET_CompressedTexImage1DARB(table, save_CompressedTexImage1DARB); - SET_CompressedTexSubImage3DARB(table, save_CompressedTexSubImage3DARB); - SET_CompressedTexSubImage2DARB(table, save_CompressedTexSubImage2DARB); - SET_CompressedTexSubImage1DARB(table, save_CompressedTexSubImage1DARB); - SET_GetCompressedTexImageARB(table, exec_GetCompressedTexImageARB); - - /* ARB 14. GL_ARB_point_parameters */ - /* aliased with EXT_point_parameters functions */ - - /* ARB 25. GL_ARB_window_pos */ - /* aliased with MESA_window_pos functions */ - - /* ARB 26. GL_ARB_vertex_program */ - /* ARB 27. GL_ARB_fragment_program */ -#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program - /* glVertexAttrib* functions alias the NV ones, handled elsewhere */ - SET_VertexAttribPointerARB(table, _mesa_VertexAttribPointerARB); - SET_EnableVertexAttribArrayARB(table, _mesa_EnableVertexAttribArrayARB); - SET_DisableVertexAttribArrayARB(table, _mesa_DisableVertexAttribArrayARB); - SET_ProgramStringARB(table, save_ProgramStringARB); - SET_BindProgramNV(table, save_BindProgramNV); - SET_DeleteProgramsNV(table, _mesa_DeletePrograms); - SET_GenProgramsNV(table, _mesa_GenPrograms); - SET_IsProgramNV(table, _mesa_IsProgramARB); - SET_GetVertexAttribdvARB(table, _mesa_GetVertexAttribdvARB); - SET_GetVertexAttribfvARB(table, _mesa_GetVertexAttribfvARB); - SET_GetVertexAttribivARB(table, _mesa_GetVertexAttribivARB); - SET_GetVertexAttribPointervNV(table, _mesa_GetVertexAttribPointervNV); - SET_ProgramEnvParameter4dARB(table, save_ProgramEnvParameter4dARB); - SET_ProgramEnvParameter4dvARB(table, save_ProgramEnvParameter4dvARB); - SET_ProgramEnvParameter4fARB(table, save_ProgramEnvParameter4fARB); - SET_ProgramEnvParameter4fvARB(table, save_ProgramEnvParameter4fvARB); - SET_ProgramLocalParameter4dARB(table, save_ProgramLocalParameter4dARB); - SET_ProgramLocalParameter4dvARB(table, save_ProgramLocalParameter4dvARB); - SET_ProgramLocalParameter4fARB(table, save_ProgramLocalParameter4fARB); - SET_ProgramLocalParameter4fvARB(table, save_ProgramLocalParameter4fvARB); - SET_GetProgramEnvParameterdvARB(table, _mesa_GetProgramEnvParameterdvARB); - SET_GetProgramEnvParameterfvARB(table, _mesa_GetProgramEnvParameterfvARB); - SET_GetProgramLocalParameterdvARB(table, - _mesa_GetProgramLocalParameterdvARB); - SET_GetProgramLocalParameterfvARB(table, - _mesa_GetProgramLocalParameterfvARB); - SET_GetProgramivARB(table, _mesa_GetProgramivARB); - SET_GetProgramStringARB(table, _mesa_GetProgramStringARB); -#endif - - /* ARB 28. GL_ARB_vertex_buffer_object */ -#if FEATURE_ARB_vertex_buffer_object - /* None of the extension's functions get compiled */ - SET_BindBufferARB(table, _mesa_BindBufferARB); - SET_BufferDataARB(table, _mesa_BufferDataARB); - SET_BufferSubDataARB(table, _mesa_BufferSubDataARB); - SET_DeleteBuffersARB(table, _mesa_DeleteBuffersARB); - SET_GenBuffersARB(table, _mesa_GenBuffersARB); - SET_GetBufferParameterivARB(table, _mesa_GetBufferParameterivARB); - SET_GetBufferPointervARB(table, _mesa_GetBufferPointervARB); - SET_GetBufferSubDataARB(table, _mesa_GetBufferSubDataARB); - SET_IsBufferARB(table, _mesa_IsBufferARB); - SET_MapBufferARB(table, _mesa_MapBufferARB); - SET_UnmapBufferARB(table, _mesa_UnmapBufferARB); -#endif - -#if FEATURE_queryobj - _mesa_init_queryobj_dispatch(table); /* glGetQuery, etc */ - SET_BeginQueryARB(table, save_BeginQueryARB); - SET_EndQueryARB(table, save_EndQueryARB); -#endif - - SET_DrawBuffersARB(table, save_DrawBuffersARB); - -#if FEATURE_EXT_framebuffer_blit - SET_BlitFramebufferEXT(table, save_BlitFramebufferEXT); -#endif - - /* GL_ARB_shader_objects */ - _mesa_init_shader_dispatch(table); /* Plug in glCreate/Delete/Get, etc */ - SET_UseProgramObjectARB(table, save_UseProgramObjectARB); - SET_Uniform1fARB(table, save_Uniform1fARB); - SET_Uniform2fARB(table, save_Uniform2fARB); - SET_Uniform3fARB(table, save_Uniform3fARB); - SET_Uniform4fARB(table, save_Uniform4fARB); - SET_Uniform1fvARB(table, save_Uniform1fvARB); - SET_Uniform2fvARB(table, save_Uniform2fvARB); - SET_Uniform3fvARB(table, save_Uniform3fvARB); - SET_Uniform4fvARB(table, save_Uniform4fvARB); - SET_Uniform1iARB(table, save_Uniform1iARB); - SET_Uniform2iARB(table, save_Uniform2iARB); - SET_Uniform3iARB(table, save_Uniform3iARB); - SET_Uniform4iARB(table, save_Uniform4iARB); - SET_Uniform1ivARB(table, save_Uniform1ivARB); - SET_Uniform2ivARB(table, save_Uniform2ivARB); - SET_Uniform3ivARB(table, save_Uniform3ivARB); - SET_Uniform4ivARB(table, save_Uniform4ivARB); - SET_UniformMatrix2fvARB(table, save_UniformMatrix2fvARB); - SET_UniformMatrix3fvARB(table, save_UniformMatrix3fvARB); - SET_UniformMatrix4fvARB(table, save_UniformMatrix4fvARB); - SET_UniformMatrix2x3fv(table, save_UniformMatrix2x3fv); - SET_UniformMatrix3x2fv(table, save_UniformMatrix3x2fv); - SET_UniformMatrix2x4fv(table, save_UniformMatrix2x4fv); - SET_UniformMatrix4x2fv(table, save_UniformMatrix4x2fv); - SET_UniformMatrix3x4fv(table, save_UniformMatrix3x4fv); - SET_UniformMatrix4x3fv(table, save_UniformMatrix4x3fv); - - /* ARB 30/31/32. GL_ARB_shader_objects, GL_ARB_vertex/fragment_shader */ - SET_BindAttribLocationARB(table, exec_BindAttribLocationARB); - SET_GetAttribLocationARB(table, exec_GetAttribLocationARB); - SET_GetUniformLocationARB(table, exec_GetUniformLocationARB); - /* XXX additional functions need to be implemented here! */ - - /* 299. GL_EXT_blend_equation_separate */ - SET_BlendEquationSeparateEXT(table, save_BlendEquationSeparateEXT); - - /* GL_EXT_gpu_program_parameters */ -#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program - SET_ProgramEnvParameters4fvEXT(table, save_ProgramEnvParameters4fvEXT); - SET_ProgramLocalParameters4fvEXT(table, save_ProgramLocalParameters4fvEXT); -#endif - - /* ARB 50. GL_ARB_map_buffer_range */ -#if FEATURE_ARB_map_buffer_range - SET_MapBufferRange(table, _mesa_MapBufferRange); /* no dlist save */ - SET_FlushMappedBufferRange(table, _mesa_FlushMappedBufferRange); /* no dl */ -#endif - - /* ARB 59. GL_ARB_copy_buffer */ - SET_CopyBufferSubData(table, _mesa_CopyBufferSubData); /* no dlist save */ - - /* 364. GL_EXT_provoking_vertex */ - SET_ProvokingVertexEXT(table, save_ProvokingVertexEXT); - - /* 371. GL_APPLE_object_purgeable */ -#if FEATURE_APPLE_object_purgeable - SET_ObjectPurgeableAPPLE(table, _mesa_ObjectPurgeableAPPLE); - SET_ObjectUnpurgeableAPPLE(table, _mesa_ObjectUnpurgeableAPPLE); - SET_GetObjectParameterivAPPLE(table, _mesa_GetObjectParameterivAPPLE); -#endif - - /* GL_EXT_texture_integer */ - SET_ClearColorIiEXT(table, save_ClearColorIi); - SET_ClearColorIuiEXT(table, save_ClearColorIui); - SET_TexParameterIivEXT(table, save_TexParameterIiv); - SET_TexParameterIuivEXT(table, save_TexParameterIuiv); - SET_GetTexParameterIivEXT(table, exec_GetTexParameterIiv); - SET_GetTexParameterIuivEXT(table, exec_GetTexParameterIuiv); - - /* 377. GL_EXT_separate_shader_objects */ - SET_UseShaderProgramEXT(table, save_UseShaderProgramEXT); - SET_ActiveProgramEXT(table, save_ActiveProgramEXT); - - /* GL_ARB_color_buffer_float */ - SET_ClampColorARB(table, save_ClampColorARB); - SET_ClampColor(table, save_ClampColorARB); - - /* GL 3.0 */ - SET_ClearBufferiv(table, save_ClearBufferiv); - SET_ClearBufferuiv(table, save_ClearBufferuiv); - SET_ClearBufferfv(table, save_ClearBufferfv); - SET_ClearBufferfi(table, save_ClearBufferfi); -#if 0 - SET_Uniform1ui(table, save_Uniform1ui); - SET_Uniform2ui(table, save_Uniform2ui); - SET_Uniform3ui(table, save_Uniform3ui); - SET_Uniform4ui(table, save_Uniform4ui); - SET_Uniform1uiv(table, save_Uniform1uiv); - SET_Uniform2uiv(table, save_Uniform2uiv); - SET_Uniform3uiv(table, save_Uniform3uiv); - SET_Uniform4uiv(table, save_Uniform4uiv); -#else - (void) save_Uniform1ui; - (void) save_Uniform2ui; - (void) save_Uniform3ui; - (void) save_Uniform4ui; - (void) save_Uniform1uiv; - (void) save_Uniform2uiv; - (void) save_Uniform3uiv; - (void) save_Uniform4uiv; -#endif - -#if FEATURE_EXT_transform_feedback - SET_BeginTransformFeedbackEXT(table, save_BeginTransformFeedback); - SET_EndTransformFeedbackEXT(table, save_EndTransformFeedback); - SET_TransformFeedbackVaryingsEXT(table, save_TransformFeedbackVaryings); - SET_BindTransformFeedback(table, save_BindTransformFeedback); - SET_PauseTransformFeedback(table, save_PauseTransformFeedback); - SET_ResumeTransformFeedback(table, save_ResumeTransformFeedback); - SET_DrawTransformFeedback(table, save_DrawTransformFeedback); -#endif - - /* GL_ARB_instanced_arrays */ - SET_VertexAttribDivisorARB(table, save_VertexAttribDivisor); - - /* GL_NV_texture_barrier */ - SET_TextureBarrierNV(table, save_TextureBarrierNV); - - /* GL_ARB_sampler_objects */ - _mesa_init_sampler_object_dispatch(table); /* plug in Gen/Get/etc functions */ - SET_BindSampler(table, save_BindSampler); - SET_SamplerParameteri(table, save_SamplerParameteri); - SET_SamplerParameterf(table, save_SamplerParameterf); - SET_SamplerParameteriv(table, save_SamplerParameteriv); - SET_SamplerParameterfv(table, save_SamplerParameterfv); - SET_SamplerParameterIiv(table, save_SamplerParameterIiv); - SET_SamplerParameterIuiv(table, save_SamplerParameterIuiv); - - /* GL_ARB_draw_buffer_blend */ - SET_BlendFunciARB(table, save_BlendFunci); - SET_BlendFuncSeparateiARB(table, save_BlendFuncSeparatei); - SET_BlendEquationiARB(table, save_BlendEquationi); - SET_BlendEquationSeparateiARB(table, save_BlendEquationSeparatei); - - /* GL_ARB_geometry_shader4 */ - SET_ProgramParameteriARB(table, save_ProgramParameteri); - SET_FramebufferTextureARB(table, save_FramebufferTexture); - SET_FramebufferTextureFaceARB(table, save_FramebufferTextureFace); - - /* GL_ARB_sync */ - _mesa_init_sync_dispatch(table); - SET_WaitSync(table, save_WaitSync); - - return table; -} - - - -static const char * -enum_string(GLenum k) -{ - return _mesa_lookup_enum_by_nr(k); -} - - -/** - * Print the commands in a display list. For debugging only. - * TODO: many commands aren't handled yet. - */ -static void GLAPIENTRY -print_list(struct gl_context *ctx, GLuint list) -{ - struct gl_display_list *dlist; - Node *n; - GLboolean done; - - if (!islist(ctx, list)) { - printf("%u is not a display list ID\n", list); - return; - } - - dlist = lookup_list(ctx, list); - if (!dlist) - return; - - n = dlist->Head; - - printf("START-LIST %u, address %p\n", list, (void *) n); - - done = n ? GL_FALSE : GL_TRUE; - while (!done) { - const OpCode opcode = n[0].opcode; - - if (is_ext_opcode(opcode)) { - n += ext_opcode_print(ctx, n); - } - else { - switch (opcode) { - case OPCODE_ACCUM: - printf("Accum %s %g\n", enum_string(n[1].e), n[2].f); - break; - case OPCODE_BITMAP: - printf("Bitmap %d %d %g %g %g %g %p\n", n[1].i, n[2].i, - n[3].f, n[4].f, n[5].f, n[6].f, (void *) n[7].data); - break; - case OPCODE_CALL_LIST: - printf("CallList %d\n", (int) n[1].ui); - break; - case OPCODE_CALL_LIST_OFFSET: - printf("CallList %d + offset %u = %u\n", (int) n[1].ui, - ctx->List.ListBase, ctx->List.ListBase + n[1].ui); - break; - case OPCODE_COLOR_TABLE_PARAMETER_FV: - printf("ColorTableParameterfv %s %s %f %f %f %f\n", - enum_string(n[1].e), enum_string(n[2].e), - n[3].f, n[4].f, n[5].f, n[6].f); - break; - case OPCODE_COLOR_TABLE_PARAMETER_IV: - printf("ColorTableParameteriv %s %s %d %d %d %d\n", - enum_string(n[1].e), enum_string(n[2].e), - n[3].i, n[4].i, n[5].i, n[6].i); - break; - case OPCODE_DISABLE: - printf("Disable %s\n", enum_string(n[1].e)); - break; - case OPCODE_ENABLE: - printf("Enable %s\n", enum_string(n[1].e)); - break; - case OPCODE_FRUSTUM: - printf("Frustum %g %g %g %g %g %g\n", - n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f); - break; - case OPCODE_LINE_STIPPLE: - printf("LineStipple %d %x\n", n[1].i, (int) n[2].us); - break; - case OPCODE_LOAD_IDENTITY: - printf("LoadIdentity\n"); - break; - case OPCODE_LOAD_MATRIX: - printf("LoadMatrix\n"); - printf(" %8f %8f %8f %8f\n", - n[1].f, n[5].f, n[9].f, n[13].f); - printf(" %8f %8f %8f %8f\n", - n[2].f, n[6].f, n[10].f, n[14].f); - printf(" %8f %8f %8f %8f\n", - n[3].f, n[7].f, n[11].f, n[15].f); - printf(" %8f %8f %8f %8f\n", - n[4].f, n[8].f, n[12].f, n[16].f); - break; - case OPCODE_MULT_MATRIX: - printf("MultMatrix (or Rotate)\n"); - printf(" %8f %8f %8f %8f\n", - n[1].f, n[5].f, n[9].f, n[13].f); - printf(" %8f %8f %8f %8f\n", - n[2].f, n[6].f, n[10].f, n[14].f); - printf(" %8f %8f %8f %8f\n", - n[3].f, n[7].f, n[11].f, n[15].f); - printf(" %8f %8f %8f %8f\n", - n[4].f, n[8].f, n[12].f, n[16].f); - break; - case OPCODE_ORTHO: - printf("Ortho %g %g %g %g %g %g\n", - n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f); - break; - case OPCODE_POP_ATTRIB: - printf("PopAttrib\n"); - break; - case OPCODE_POP_MATRIX: - printf("PopMatrix\n"); - break; - case OPCODE_POP_NAME: - printf("PopName\n"); - break; - case OPCODE_PUSH_ATTRIB: - printf("PushAttrib %x\n", n[1].bf); - break; - case OPCODE_PUSH_MATRIX: - printf("PushMatrix\n"); - break; - case OPCODE_PUSH_NAME: - printf("PushName %d\n", (int) n[1].ui); - break; - case OPCODE_RASTER_POS: - printf("RasterPos %g %g %g %g\n", - n[1].f, n[2].f, n[3].f, n[4].f); - break; - case OPCODE_ROTATE: - printf("Rotate %g %g %g %g\n", - n[1].f, n[2].f, n[3].f, n[4].f); - break; - case OPCODE_SCALE: - printf("Scale %g %g %g\n", n[1].f, n[2].f, n[3].f); - break; - case OPCODE_TRANSLATE: - printf("Translate %g %g %g\n", n[1].f, n[2].f, n[3].f); - break; - case OPCODE_BIND_TEXTURE: - printf("BindTexture %s %d\n", - _mesa_lookup_enum_by_nr(n[1].ui), n[2].ui); - break; - case OPCODE_SHADE_MODEL: - printf("ShadeModel %s\n", _mesa_lookup_enum_by_nr(n[1].ui)); - break; - case OPCODE_MAP1: - printf("Map1 %s %.3f %.3f %d %d\n", - _mesa_lookup_enum_by_nr(n[1].ui), - n[2].f, n[3].f, n[4].i, n[5].i); - break; - case OPCODE_MAP2: - printf("Map2 %s %.3f %.3f %.3f %.3f %d %d %d %d\n", - _mesa_lookup_enum_by_nr(n[1].ui), - n[2].f, n[3].f, n[4].f, n[5].f, - n[6].i, n[7].i, n[8].i, n[9].i); - break; - case OPCODE_MAPGRID1: - printf("MapGrid1 %d %.3f %.3f\n", n[1].i, n[2].f, n[3].f); - break; - case OPCODE_MAPGRID2: - printf("MapGrid2 %d %.3f %.3f, %d %.3f %.3f\n", - n[1].i, n[2].f, n[3].f, n[4].i, n[5].f, n[6].f); - break; - case OPCODE_EVALMESH1: - printf("EvalMesh1 %d %d\n", n[1].i, n[2].i); - break; - case OPCODE_EVALMESH2: - printf("EvalMesh2 %d %d %d %d\n", - n[1].i, n[2].i, n[3].i, n[4].i); - break; - - case OPCODE_ATTR_1F_NV: - printf("ATTR_1F_NV attr %d: %f\n", n[1].i, n[2].f); - break; - case OPCODE_ATTR_2F_NV: - printf("ATTR_2F_NV attr %d: %f %f\n", - n[1].i, n[2].f, n[3].f); - break; - case OPCODE_ATTR_3F_NV: - printf("ATTR_3F_NV attr %d: %f %f %f\n", - n[1].i, n[2].f, n[3].f, n[4].f); - break; - case OPCODE_ATTR_4F_NV: - printf("ATTR_4F_NV attr %d: %f %f %f %f\n", - n[1].i, n[2].f, n[3].f, n[4].f, n[5].f); - break; - case OPCODE_ATTR_1F_ARB: - printf("ATTR_1F_ARB attr %d: %f\n", n[1].i, n[2].f); - break; - case OPCODE_ATTR_2F_ARB: - printf("ATTR_2F_ARB attr %d: %f %f\n", - n[1].i, n[2].f, n[3].f); - break; - case OPCODE_ATTR_3F_ARB: - printf("ATTR_3F_ARB attr %d: %f %f %f\n", - n[1].i, n[2].f, n[3].f, n[4].f); - break; - case OPCODE_ATTR_4F_ARB: - printf("ATTR_4F_ARB attr %d: %f %f %f %f\n", - n[1].i, n[2].f, n[3].f, n[4].f, n[5].f); - break; - - case OPCODE_MATERIAL: - printf("MATERIAL %x %x: %f %f %f %f\n", - n[1].i, n[2].i, n[3].f, n[4].f, n[5].f, n[6].f); - break; - case OPCODE_BEGIN: - printf("BEGIN %x\n", n[1].i); - break; - case OPCODE_END: - printf("END\n"); - break; - case OPCODE_RECTF: - printf("RECTF %f %f %f %f\n", n[1].f, n[2].f, n[3].f, - n[4].f); - break; - case OPCODE_EVAL_C1: - printf("EVAL_C1 %f\n", n[1].f); - break; - case OPCODE_EVAL_C2: - printf("EVAL_C2 %f %f\n", n[1].f, n[2].f); - break; - case OPCODE_EVAL_P1: - printf("EVAL_P1 %d\n", n[1].i); - break; - case OPCODE_EVAL_P2: - printf("EVAL_P2 %d %d\n", n[1].i, n[2].i); - break; - - case OPCODE_PROVOKING_VERTEX: - printf("ProvokingVertex %s\n", - _mesa_lookup_enum_by_nr(n[1].ui)); - break; - - /* - * meta opcodes/commands - */ - case OPCODE_ERROR: - printf("Error: %s %s\n", - enum_string(n[1].e), (const char *) n[2].data); - break; - case OPCODE_CONTINUE: - printf("DISPLAY-LIST-CONTINUE\n"); - n = (Node *) n[1].next; - break; - case OPCODE_END_OF_LIST: - printf("END-LIST %u\n", list); - done = GL_TRUE; - break; - default: - if (opcode < 0 || opcode > OPCODE_END_OF_LIST) { - printf - ("ERROR IN DISPLAY LIST: opcode = %d, address = %p\n", - opcode, (void *) n); - return; - } - else { - printf("command %d, %u operands\n", opcode, - InstSize[opcode]); - } - } - /* increment n to point to next compiled command */ - if (opcode != OPCODE_CONTINUE) { - n += InstSize[opcode]; - } - } - } -} - - - -/** - * Clients may call this function to help debug display list problems. - * This function is _ONLY_FOR_DEBUGGING_PURPOSES_. It may be removed, - * changed, or break in the future without notice. - */ -void -mesa_print_display_list(GLuint list) -{ - GET_CURRENT_CONTEXT(ctx); - print_list(ctx, list); -} - - -/**********************************************************************/ -/***** Initialization *****/ -/**********************************************************************/ - -void -_mesa_save_vtxfmt_init(GLvertexformat * vfmt) -{ - _MESA_INIT_ARRAYELT_VTXFMT(vfmt, _ae_); - - vfmt->Begin = save_Begin; - - _MESA_INIT_DLIST_VTXFMT(vfmt, save_); - - vfmt->Color3f = save_Color3f; - vfmt->Color3fv = save_Color3fv; - vfmt->Color4f = save_Color4f; - vfmt->Color4fv = save_Color4fv; - vfmt->EdgeFlag = save_EdgeFlag; - vfmt->End = save_End; - - _MESA_INIT_EVAL_VTXFMT(vfmt, save_); - - vfmt->FogCoordfEXT = save_FogCoordfEXT; - vfmt->FogCoordfvEXT = save_FogCoordfvEXT; - vfmt->Indexf = save_Indexf; - vfmt->Indexfv = save_Indexfv; - vfmt->Materialfv = save_Materialfv; - vfmt->MultiTexCoord1fARB = save_MultiTexCoord1f; - vfmt->MultiTexCoord1fvARB = save_MultiTexCoord1fv; - vfmt->MultiTexCoord2fARB = save_MultiTexCoord2f; - vfmt->MultiTexCoord2fvARB = save_MultiTexCoord2fv; - vfmt->MultiTexCoord3fARB = save_MultiTexCoord3f; - vfmt->MultiTexCoord3fvARB = save_MultiTexCoord3fv; - vfmt->MultiTexCoord4fARB = save_MultiTexCoord4f; - vfmt->MultiTexCoord4fvARB = save_MultiTexCoord4fv; - vfmt->Normal3f = save_Normal3f; - vfmt->Normal3fv = save_Normal3fv; - vfmt->SecondaryColor3fEXT = save_SecondaryColor3fEXT; - vfmt->SecondaryColor3fvEXT = save_SecondaryColor3fvEXT; - vfmt->TexCoord1f = save_TexCoord1f; - vfmt->TexCoord1fv = save_TexCoord1fv; - vfmt->TexCoord2f = save_TexCoord2f; - vfmt->TexCoord2fv = save_TexCoord2fv; - vfmt->TexCoord3f = save_TexCoord3f; - vfmt->TexCoord3fv = save_TexCoord3fv; - vfmt->TexCoord4f = save_TexCoord4f; - vfmt->TexCoord4fv = save_TexCoord4fv; - vfmt->Vertex2f = save_Vertex2f; - vfmt->Vertex2fv = save_Vertex2fv; - vfmt->Vertex3f = save_Vertex3f; - vfmt->Vertex3fv = save_Vertex3fv; - vfmt->Vertex4f = save_Vertex4f; - vfmt->Vertex4fv = save_Vertex4fv; - vfmt->VertexAttrib1fNV = save_VertexAttrib1fNV; - vfmt->VertexAttrib1fvNV = save_VertexAttrib1fvNV; - vfmt->VertexAttrib2fNV = save_VertexAttrib2fNV; - vfmt->VertexAttrib2fvNV = save_VertexAttrib2fvNV; - vfmt->VertexAttrib3fNV = save_VertexAttrib3fNV; - vfmt->VertexAttrib3fvNV = save_VertexAttrib3fvNV; - vfmt->VertexAttrib4fNV = save_VertexAttrib4fNV; - vfmt->VertexAttrib4fvNV = save_VertexAttrib4fvNV; - vfmt->VertexAttrib1fARB = save_VertexAttrib1fARB; - vfmt->VertexAttrib1fvARB = save_VertexAttrib1fvARB; - vfmt->VertexAttrib2fARB = save_VertexAttrib2fARB; - vfmt->VertexAttrib2fvARB = save_VertexAttrib2fvARB; - vfmt->VertexAttrib3fARB = save_VertexAttrib3fARB; - vfmt->VertexAttrib3fvARB = save_VertexAttrib3fvARB; - vfmt->VertexAttrib4fARB = save_VertexAttrib4fARB; - vfmt->VertexAttrib4fvARB = save_VertexAttrib4fvARB; - - vfmt->Rectf = save_Rectf; - - /* The driver is required to implement these as - * 1) They can probably do a better job. - * 2) A lot of new mechanisms would have to be added to this module - * to support it. That code would probably never get used, - * because of (1). - */ -#if 0 - vfmt->DrawArrays = 0; - vfmt->DrawElements = 0; - vfmt->DrawRangeElements = 0; - vfmt->MultiDrawElemementsEXT = 0; - vfmt->DrawElementsBaseVertex = 0; - vfmt->DrawRangeElementsBaseVertex = 0; - vfmt->MultiDrawElemementsBaseVertex = 0; -#endif -} - - -void -_mesa_install_dlist_vtxfmt(struct _glapi_table *disp, - const GLvertexformat *vfmt) -{ - SET_CallList(disp, vfmt->CallList); - SET_CallLists(disp, vfmt->CallLists); -} - - -void _mesa_init_dlist_dispatch(struct _glapi_table *disp) -{ - SET_CallList(disp, _mesa_CallList); - SET_CallLists(disp, _mesa_CallLists); - - SET_DeleteLists(disp, _mesa_DeleteLists); - SET_EndList(disp, _mesa_EndList); - SET_GenLists(disp, _mesa_GenLists); - SET_IsList(disp, _mesa_IsList); - SET_ListBase(disp, _mesa_ListBase); - SET_NewList(disp, _mesa_NewList); -} - - -#endif /* FEATURE_dlist */ - - -/** - * Initialize display list state for given context. - */ -void -_mesa_init_display_list(struct gl_context *ctx) -{ - static GLboolean tableInitialized = GL_FALSE; - - /* zero-out the instruction size table, just once */ - if (!tableInitialized) { - memset(InstSize, 0, sizeof(InstSize)); - tableInitialized = GL_TRUE; - } - - /* extension info */ - ctx->ListExt = CALLOC_STRUCT(gl_list_extensions); - - /* Display list */ - ctx->ListState.CallDepth = 0; - ctx->ExecuteFlag = GL_TRUE; - ctx->CompileFlag = GL_FALSE; - ctx->ListState.CurrentBlock = NULL; - ctx->ListState.CurrentPos = 0; - - /* Display List group */ - ctx->List.ListBase = 0; - -#if FEATURE_dlist - _mesa_save_vtxfmt_init(&ctx->ListState.ListVtxfmt); -#endif -} - - -void -_mesa_free_display_list_data(struct gl_context *ctx) -{ - free(ctx->ListExt); - ctx->ListExt = NULL; -} +/* + * Mesa 3-D graphics library + * Version: 7.7 + * + * Copyright (C) 1999-2008 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. + */ + + +/** + * \file dlist.c + * Display lists management functions. + */ + +#include "glheader.h" +#include "imports.h" +#include "api_arrayelt.h" +#include "api_exec.h" +#include "api_loopback.h" +#if FEATURE_ATI_fragment_shader +#include "atifragshader.h" +#endif +#include "config.h" +#include "mfeatures.h" +#if FEATURE_ARB_vertex_buffer_object +#include "bufferobj.h" +#endif +#include "arrayobj.h" +#include "context.h" +#include "dlist.h" +#include "enums.h" +#include "eval.h" +#include "framebuffer.h" +#include "glapi/glapi.h" +#include "hash.h" +#include "image.h" +#include "light.h" +#include "macros.h" +#include "pack.h" +#include "pbo.h" +#include "queryobj.h" +#include "samplerobj.h" +#include "shaderapi.h" +#include "syncobj.h" +#include "teximage.h" +#include "mtypes.h" +#include "varray.h" +#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program +#include "arbprogram.h" +#endif +#if FEATURE_NV_vertex_program || FEATURE_NV_fragment_program +#include "nvprogram.h" +#endif + +#include "math/m_matrix.h" + +#include "main/dispatch.h" + + + +/** + * Other parts of Mesa (such as the VBO module) can plug into the display + * list system. This structure describes new display list instructions. + */ +struct gl_list_instruction +{ + GLuint Size; + void (*Execute)( struct gl_context *ctx, void *data ); + void (*Destroy)( struct gl_context *ctx, void *data ); + void (*Print)( struct gl_context *ctx, void *data ); +}; + + +#define MAX_DLIST_EXT_OPCODES 16 + +/** + * Used by device drivers to hook new commands into display lists. + */ +struct gl_list_extensions +{ + struct gl_list_instruction Opcode[MAX_DLIST_EXT_OPCODES]; + GLuint NumOpcodes; +}; + + + +/** + * Flush vertices. + * + * \param ctx GL context. + * + * Checks if dd_function_table::SaveNeedFlush is marked to flush + * stored (save) vertices, and calls + * dd_function_table::SaveFlushVertices if so. + */ +#define SAVE_FLUSH_VERTICES(ctx) \ +do { \ + if (ctx->Driver.SaveNeedFlush) \ + ctx->Driver.SaveFlushVertices(ctx); \ +} while (0) + + +/** + * Macro to assert that the API call was made outside the + * glBegin()/glEnd() pair, with return value. + * + * \param ctx GL context. + * \param retval value to return value in case the assertion fails. + */ +#define ASSERT_OUTSIDE_SAVE_BEGIN_END_WITH_RETVAL(ctx, retval) \ +do { \ + if (ctx->Driver.CurrentSavePrimitive <= GL_POLYGON || \ + ctx->Driver.CurrentSavePrimitive == PRIM_INSIDE_UNKNOWN_PRIM) { \ + _mesa_compile_error( ctx, GL_INVALID_OPERATION, "begin/end" ); \ + return retval; \ + } \ +} while (0) + +/** + * Macro to assert that the API call was made outside the + * glBegin()/glEnd() pair. + * + * \param ctx GL context. + */ +#define ASSERT_OUTSIDE_SAVE_BEGIN_END(ctx) \ +do { \ + if (ctx->Driver.CurrentSavePrimitive <= GL_POLYGON || \ + ctx->Driver.CurrentSavePrimitive == PRIM_INSIDE_UNKNOWN_PRIM) { \ + _mesa_compile_error( ctx, GL_INVALID_OPERATION, "begin/end" ); \ + return; \ + } \ +} while (0) + +/** + * Macro to assert that the API call was made outside the + * glBegin()/glEnd() pair and flush the vertices. + * + * \param ctx GL context. + */ +#define ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx) \ +do { \ + ASSERT_OUTSIDE_SAVE_BEGIN_END(ctx); \ + SAVE_FLUSH_VERTICES(ctx); \ +} while (0) + +/** + * Macro to assert that the API call was made outside the + * glBegin()/glEnd() pair and flush the vertices, with return value. + * + * \param ctx GL context. + * \param retval value to return value in case the assertion fails. + */ +#define ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx, retval)\ +do { \ + ASSERT_OUTSIDE_SAVE_BEGIN_END_WITH_RETVAL(ctx, retval); \ + SAVE_FLUSH_VERTICES(ctx); \ +} while (0) + + + +/** + * Display list opcodes. + * + * The fact that these identifiers are assigned consecutive + * integer values starting at 0 is very important, see InstSize array usage) + */ +typedef enum +{ + OPCODE_INVALID = -1, /* Force signed enum */ + OPCODE_ACCUM, + OPCODE_ALPHA_FUNC, + OPCODE_BIND_TEXTURE, + OPCODE_BITMAP, + OPCODE_BLEND_COLOR, + OPCODE_BLEND_EQUATION, + OPCODE_BLEND_EQUATION_SEPARATE, + OPCODE_BLEND_FUNC_SEPARATE, + + OPCODE_BLEND_EQUATION_I, + OPCODE_BLEND_EQUATION_SEPARATE_I, + OPCODE_BLEND_FUNC_I, + OPCODE_BLEND_FUNC_SEPARATE_I, + + OPCODE_CALL_LIST, + OPCODE_CALL_LIST_OFFSET, + OPCODE_CLEAR, + OPCODE_CLEAR_ACCUM, + OPCODE_CLEAR_COLOR, + OPCODE_CLEAR_DEPTH, + OPCODE_CLEAR_INDEX, + OPCODE_CLEAR_STENCIL, + OPCODE_CLEAR_BUFFER_IV, + OPCODE_CLEAR_BUFFER_UIV, + OPCODE_CLEAR_BUFFER_FV, + OPCODE_CLEAR_BUFFER_FI, + OPCODE_CLIP_PLANE, + OPCODE_COLOR_MASK, + OPCODE_COLOR_MASK_INDEXED, + OPCODE_COLOR_MATERIAL, + OPCODE_COLOR_TABLE, + OPCODE_COLOR_TABLE_PARAMETER_FV, + OPCODE_COLOR_TABLE_PARAMETER_IV, + OPCODE_COLOR_SUB_TABLE, + OPCODE_CONVOLUTION_FILTER_1D, + OPCODE_CONVOLUTION_FILTER_2D, + OPCODE_CONVOLUTION_PARAMETER_I, + OPCODE_CONVOLUTION_PARAMETER_IV, + OPCODE_CONVOLUTION_PARAMETER_F, + OPCODE_CONVOLUTION_PARAMETER_FV, + OPCODE_COPY_COLOR_SUB_TABLE, + OPCODE_COPY_COLOR_TABLE, + OPCODE_COPY_PIXELS, + OPCODE_COPY_TEX_IMAGE1D, + OPCODE_COPY_TEX_IMAGE2D, + OPCODE_COPY_TEX_SUB_IMAGE1D, + OPCODE_COPY_TEX_SUB_IMAGE2D, + OPCODE_COPY_TEX_SUB_IMAGE3D, + OPCODE_CULL_FACE, + OPCODE_DEPTH_FUNC, + OPCODE_DEPTH_MASK, + OPCODE_DEPTH_RANGE, + OPCODE_DISABLE, + OPCODE_DISABLE_INDEXED, + OPCODE_DRAW_BUFFER, + OPCODE_DRAW_PIXELS, + OPCODE_ENABLE, + OPCODE_ENABLE_INDEXED, + OPCODE_EVALMESH1, + OPCODE_EVALMESH2, + OPCODE_FOG, + OPCODE_FRONT_FACE, + OPCODE_FRUSTUM, + OPCODE_HINT, + OPCODE_HISTOGRAM, + OPCODE_INDEX_MASK, + OPCODE_INIT_NAMES, + OPCODE_LIGHT, + OPCODE_LIGHT_MODEL, + OPCODE_LINE_STIPPLE, + OPCODE_LINE_WIDTH, + OPCODE_LIST_BASE, + OPCODE_LOAD_IDENTITY, + OPCODE_LOAD_MATRIX, + OPCODE_LOAD_NAME, + OPCODE_LOGIC_OP, + OPCODE_MAP1, + OPCODE_MAP2, + OPCODE_MAPGRID1, + OPCODE_MAPGRID2, + OPCODE_MATRIX_MODE, + OPCODE_MIN_MAX, + OPCODE_MULT_MATRIX, + OPCODE_ORTHO, + OPCODE_PASSTHROUGH, + OPCODE_PIXEL_MAP, + OPCODE_PIXEL_TRANSFER, + OPCODE_PIXEL_ZOOM, + OPCODE_POINT_SIZE, + OPCODE_POINT_PARAMETERS, + OPCODE_POLYGON_MODE, + OPCODE_POLYGON_STIPPLE, + OPCODE_POLYGON_OFFSET, + OPCODE_POP_ATTRIB, + OPCODE_POP_MATRIX, + OPCODE_POP_NAME, + OPCODE_PRIORITIZE_TEXTURE, + OPCODE_PUSH_ATTRIB, + OPCODE_PUSH_MATRIX, + OPCODE_PUSH_NAME, + OPCODE_RASTER_POS, + OPCODE_READ_BUFFER, + OPCODE_RESET_HISTOGRAM, + OPCODE_RESET_MIN_MAX, + OPCODE_ROTATE, + OPCODE_SCALE, + OPCODE_SCISSOR, + OPCODE_SELECT_TEXTURE_SGIS, + OPCODE_SELECT_TEXTURE_COORD_SET, + OPCODE_SHADE_MODEL, + OPCODE_STENCIL_FUNC, + OPCODE_STENCIL_MASK, + OPCODE_STENCIL_OP, + OPCODE_TEXENV, + OPCODE_TEXGEN, + OPCODE_TEXPARAMETER, + OPCODE_TEX_IMAGE1D, + OPCODE_TEX_IMAGE2D, + OPCODE_TEX_IMAGE3D, + OPCODE_TEX_SUB_IMAGE1D, + OPCODE_TEX_SUB_IMAGE2D, + OPCODE_TEX_SUB_IMAGE3D, + OPCODE_TRANSLATE, + OPCODE_VIEWPORT, + OPCODE_WINDOW_POS, + /* GL_ARB_multitexture */ + OPCODE_ACTIVE_TEXTURE, + /* GL_ARB_texture_compression */ + OPCODE_COMPRESSED_TEX_IMAGE_1D, + OPCODE_COMPRESSED_TEX_IMAGE_2D, + OPCODE_COMPRESSED_TEX_IMAGE_3D, + OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D, + OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D, + OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D, + /* GL_ARB_multisample */ + OPCODE_SAMPLE_COVERAGE, + /* GL_ARB_window_pos */ + OPCODE_WINDOW_POS_ARB, + /* GL_NV_vertex_program */ + OPCODE_BIND_PROGRAM_NV, + OPCODE_EXECUTE_PROGRAM_NV, + OPCODE_REQUEST_RESIDENT_PROGRAMS_NV, + OPCODE_LOAD_PROGRAM_NV, + OPCODE_TRACK_MATRIX_NV, + /* GL_NV_fragment_program */ + OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, + OPCODE_PROGRAM_NAMED_PARAMETER_NV, + /* GL_EXT_stencil_two_side */ + OPCODE_ACTIVE_STENCIL_FACE_EXT, + /* GL_EXT_depth_bounds_test */ + OPCODE_DEPTH_BOUNDS_EXT, + /* GL_ARB_vertex/fragment_program */ + OPCODE_PROGRAM_STRING_ARB, + OPCODE_PROGRAM_ENV_PARAMETER_ARB, + /* GL_ARB_occlusion_query */ + OPCODE_BEGIN_QUERY_ARB, + OPCODE_END_QUERY_ARB, + /* GL_ARB_draw_buffers */ + OPCODE_DRAW_BUFFERS_ARB, + /* GL_ATI_fragment_shader */ + OPCODE_TEX_BUMP_PARAMETER_ATI, + /* GL_ATI_fragment_shader */ + OPCODE_BIND_FRAGMENT_SHADER_ATI, + OPCODE_SET_FRAGMENT_SHADER_CONSTANTS_ATI, + /* OpenGL 2.0 */ + OPCODE_STENCIL_FUNC_SEPARATE, + OPCODE_STENCIL_OP_SEPARATE, + OPCODE_STENCIL_MASK_SEPARATE, + + /* GL_ARB_shader_objects */ + OPCODE_USE_PROGRAM, + OPCODE_UNIFORM_1F, + OPCODE_UNIFORM_2F, + OPCODE_UNIFORM_3F, + OPCODE_UNIFORM_4F, + OPCODE_UNIFORM_1FV, + OPCODE_UNIFORM_2FV, + OPCODE_UNIFORM_3FV, + OPCODE_UNIFORM_4FV, + OPCODE_UNIFORM_1I, + OPCODE_UNIFORM_2I, + OPCODE_UNIFORM_3I, + OPCODE_UNIFORM_4I, + OPCODE_UNIFORM_1IV, + OPCODE_UNIFORM_2IV, + OPCODE_UNIFORM_3IV, + OPCODE_UNIFORM_4IV, + OPCODE_UNIFORM_MATRIX22, + OPCODE_UNIFORM_MATRIX33, + OPCODE_UNIFORM_MATRIX44, + OPCODE_UNIFORM_MATRIX23, + OPCODE_UNIFORM_MATRIX32, + OPCODE_UNIFORM_MATRIX24, + OPCODE_UNIFORM_MATRIX42, + OPCODE_UNIFORM_MATRIX34, + OPCODE_UNIFORM_MATRIX43, + + /* OpenGL 3.0 */ + OPCODE_UNIFORM_1UI, + OPCODE_UNIFORM_2UI, + OPCODE_UNIFORM_3UI, + OPCODE_UNIFORM_4UI, + OPCODE_UNIFORM_1UIV, + OPCODE_UNIFORM_2UIV, + OPCODE_UNIFORM_3UIV, + OPCODE_UNIFORM_4UIV, + + /* GL_ARB_color_buffer_float */ + OPCODE_CLAMP_COLOR, + + /* GL_EXT_framebuffer_blit */ + OPCODE_BLIT_FRAMEBUFFER, + + /* Vertex attributes -- fallback for when optimized display + * list build isn't active. + */ + OPCODE_ATTR_1F_NV, + OPCODE_ATTR_2F_NV, + OPCODE_ATTR_3F_NV, + OPCODE_ATTR_4F_NV, + OPCODE_ATTR_1F_ARB, + OPCODE_ATTR_2F_ARB, + OPCODE_ATTR_3F_ARB, + OPCODE_ATTR_4F_ARB, + OPCODE_MATERIAL, + OPCODE_BEGIN, + OPCODE_END, + OPCODE_RECTF, + OPCODE_EVAL_C1, + OPCODE_EVAL_C2, + OPCODE_EVAL_P1, + OPCODE_EVAL_P2, + + /* GL_EXT_provoking_vertex */ + OPCODE_PROVOKING_VERTEX, + + /* GL_EXT_transform_feedback */ + OPCODE_BEGIN_TRANSFORM_FEEDBACK, + OPCODE_END_TRANSFORM_FEEDBACK, + OPCODE_BIND_TRANSFORM_FEEDBACK, + OPCODE_PAUSE_TRANSFORM_FEEDBACK, + OPCODE_RESUME_TRANSFORM_FEEDBACK, + OPCODE_DRAW_TRANSFORM_FEEDBACK, + + /* GL_EXT_texture_integer */ + OPCODE_CLEARCOLOR_I, + OPCODE_CLEARCOLOR_UI, + OPCODE_TEXPARAMETER_I, + OPCODE_TEXPARAMETER_UI, + + /* GL_EXT_separate_shader_objects */ + OPCODE_ACTIVE_PROGRAM_EXT, + OPCODE_USE_SHADER_PROGRAM_EXT, + + /* GL_ARB_instanced_arrays */ + OPCODE_VERTEX_ATTRIB_DIVISOR, + + /* GL_NV_texture_barrier */ + OPCODE_TEXTURE_BARRIER_NV, + + /* GL_ARB_sampler_object */ + OPCODE_BIND_SAMPLER, + OPCODE_SAMPLER_PARAMETERIV, + OPCODE_SAMPLER_PARAMETERFV, + OPCODE_SAMPLER_PARAMETERIIV, + OPCODE_SAMPLER_PARAMETERUIV, + + /* GL_ARB_geometry_shader4 */ + OPCODE_PROGRAM_PARAMETERI, + OPCODE_FRAMEBUFFER_TEXTURE, + OPCODE_FRAMEBUFFER_TEXTURE_FACE, + + /* GL_ARB_sync */ + OPCODE_WAIT_SYNC, + + /* The following three are meta instructions */ + OPCODE_ERROR, /* raise compiled-in error */ + OPCODE_CONTINUE, + OPCODE_END_OF_LIST, + OPCODE_EXT_0 +} OpCode; + + + +/** + * Display list node. + * + * Display list instructions are stored as sequences of "nodes". Nodes + * are allocated in blocks. Each block has BLOCK_SIZE nodes. Blocks + * are linked together with a pointer. + * + * Each instruction in the display list is stored as a sequence of + * contiguous nodes in memory. + * Each node is the union of a variety of data types. + */ +union gl_dlist_node +{ + OpCode opcode; + GLboolean b; + GLbitfield bf; + GLubyte ub; + GLshort s; + GLushort us; + GLint i; + GLuint ui; + GLenum e; + GLfloat f; + GLvoid *data; + void *next; /* If prev node's opcode==OPCODE_CONTINUE */ +}; + + +typedef union gl_dlist_node Node; + + +/** + * Used to store a 64-bit uint in a pair of "Nodes" for the sake of 32-bit + * environment. In 64-bit env, sizeof(Node)==8 anyway. + */ +union uint64_pair +{ + GLuint64 uint64; + GLuint uint32[2]; +}; + + +/** + * How many nodes to allocate at a time. + * + * \note Reduced now that we hold vertices etc. elsewhere. + */ +#define BLOCK_SIZE 256 + + + +/** + * Number of nodes of storage needed for each instruction. + * Sizes for dynamically allocated opcodes are stored in the context struct. + */ +static GLuint InstSize[OPCODE_END_OF_LIST + 1]; + + +#if FEATURE_dlist + + +void mesa_print_display_list(GLuint list); + + +/**********************************************************************/ +/***** Private *****/ +/**********************************************************************/ + + +/** + * Make an empty display list. This is used by glGenLists() to + * reserve display list IDs. + */ +static struct gl_display_list * +make_list(GLuint name, GLuint count) +{ + struct gl_display_list *dlist = CALLOC_STRUCT(gl_display_list); + dlist->Name = name; + dlist->Head = (Node *) malloc(sizeof(Node) * count); + dlist->Head[0].opcode = OPCODE_END_OF_LIST; + return dlist; +} + + +/** + * Lookup function to just encapsulate casting. + */ +static INLINE struct gl_display_list * +lookup_list(struct gl_context *ctx, GLuint list) +{ + return (struct gl_display_list *) + _mesa_HashLookup(ctx->Shared->DisplayList, list); +} + + +/** Is the given opcode an extension code? */ +static INLINE GLboolean +is_ext_opcode(OpCode opcode) +{ + return (opcode >= OPCODE_EXT_0); +} + + +/** Destroy an extended opcode instruction */ +static GLint +ext_opcode_destroy(struct gl_context *ctx, Node *node) +{ + const GLint i = node[0].opcode - OPCODE_EXT_0; + GLint step; + ctx->ListExt->Opcode[i].Destroy(ctx, &node[1]); + step = ctx->ListExt->Opcode[i].Size; + return step; +} + + +/** Execute an extended opcode instruction */ +static GLint +ext_opcode_execute(struct gl_context *ctx, Node *node) +{ + const GLint i = node[0].opcode - OPCODE_EXT_0; + GLint step; + ctx->ListExt->Opcode[i].Execute(ctx, &node[1]); + step = ctx->ListExt->Opcode[i].Size; + return step; +} + + +/** Print an extended opcode instruction */ +static GLint +ext_opcode_print(struct gl_context *ctx, Node *node) +{ + const GLint i = node[0].opcode - OPCODE_EXT_0; + GLint step; + ctx->ListExt->Opcode[i].Print(ctx, &node[1]); + step = ctx->ListExt->Opcode[i].Size; + return step; +} + + +/** + * Delete the named display list, but don't remove from hash table. + * \param dlist - display list pointer + */ +void +_mesa_delete_list(struct gl_context *ctx, struct gl_display_list *dlist) +{ + Node *n, *block; + GLboolean done; + + n = block = dlist->Head; + + done = block ? GL_FALSE : GL_TRUE; + while (!done) { + const OpCode opcode = n[0].opcode; + + /* check for extension opcodes first */ + if (is_ext_opcode(opcode)) { + n += ext_opcode_destroy(ctx, n); + } + else { + switch (opcode) { + /* for some commands, we need to free malloc'd memory */ + case OPCODE_MAP1: + free(n[6].data); + n += InstSize[n[0].opcode]; + break; + case OPCODE_MAP2: + free(n[10].data); + n += InstSize[n[0].opcode]; + break; + case OPCODE_DRAW_PIXELS: + free(n[5].data); + n += InstSize[n[0].opcode]; + break; + case OPCODE_BITMAP: + free(n[7].data); + n += InstSize[n[0].opcode]; + break; + case OPCODE_COLOR_TABLE: + free(n[6].data); + n += InstSize[n[0].opcode]; + break; + case OPCODE_COLOR_SUB_TABLE: + free(n[6].data); + n += InstSize[n[0].opcode]; + break; + case OPCODE_CONVOLUTION_FILTER_1D: + free(n[6].data); + n += InstSize[n[0].opcode]; + break; + case OPCODE_CONVOLUTION_FILTER_2D: + free(n[7].data); + n += InstSize[n[0].opcode]; + break; + case OPCODE_POLYGON_STIPPLE: + free(n[1].data); + n += InstSize[n[0].opcode]; + break; + case OPCODE_TEX_IMAGE1D: + free(n[8].data); + n += InstSize[n[0].opcode]; + break; + case OPCODE_TEX_IMAGE2D: + free(n[9].data); + n += InstSize[n[0].opcode]; + break; + case OPCODE_TEX_IMAGE3D: + free(n[10].data); + n += InstSize[n[0].opcode]; + break; + case OPCODE_TEX_SUB_IMAGE1D: + free(n[7].data); + n += InstSize[n[0].opcode]; + break; + case OPCODE_TEX_SUB_IMAGE2D: + free(n[9].data); + n += InstSize[n[0].opcode]; + break; + case OPCODE_TEX_SUB_IMAGE3D: + free(n[11].data); + n += InstSize[n[0].opcode]; + break; + case OPCODE_COMPRESSED_TEX_IMAGE_1D: + free(n[7].data); + n += InstSize[n[0].opcode]; + break; + case OPCODE_COMPRESSED_TEX_IMAGE_2D: + free(n[8].data); + n += InstSize[n[0].opcode]; + break; + case OPCODE_COMPRESSED_TEX_IMAGE_3D: + free(n[9].data); + n += InstSize[n[0].opcode]; + break; + case OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D: + free(n[7].data); + n += InstSize[n[0].opcode]; + break; + case OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D: + free(n[9].data); + n += InstSize[n[0].opcode]; + break; + case OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D: + free(n[11].data); + n += InstSize[n[0].opcode]; + break; +#if FEATURE_NV_vertex_program + case OPCODE_LOAD_PROGRAM_NV: + free(n[4].data); /* program string */ + n += InstSize[n[0].opcode]; + break; + case OPCODE_REQUEST_RESIDENT_PROGRAMS_NV: + free(n[2].data); /* array of program ids */ + n += InstSize[n[0].opcode]; + break; +#endif +#if FEATURE_NV_fragment_program + case OPCODE_PROGRAM_NAMED_PARAMETER_NV: + free(n[3].data); /* parameter name */ + n += InstSize[n[0].opcode]; + break; +#endif +#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program + case OPCODE_PROGRAM_STRING_ARB: + free(n[4].data); /* program string */ + n += InstSize[n[0].opcode]; + break; +#endif + case OPCODE_UNIFORM_1FV: + case OPCODE_UNIFORM_2FV: + case OPCODE_UNIFORM_3FV: + case OPCODE_UNIFORM_4FV: + case OPCODE_UNIFORM_1IV: + case OPCODE_UNIFORM_2IV: + case OPCODE_UNIFORM_3IV: + case OPCODE_UNIFORM_4IV: + case OPCODE_UNIFORM_1UIV: + case OPCODE_UNIFORM_2UIV: + case OPCODE_UNIFORM_3UIV: + case OPCODE_UNIFORM_4UIV: + free(n[3].data); + n += InstSize[n[0].opcode]; + break; + case OPCODE_UNIFORM_MATRIX22: + case OPCODE_UNIFORM_MATRIX33: + case OPCODE_UNIFORM_MATRIX44: + case OPCODE_UNIFORM_MATRIX24: + case OPCODE_UNIFORM_MATRIX42: + case OPCODE_UNIFORM_MATRIX23: + case OPCODE_UNIFORM_MATRIX32: + case OPCODE_UNIFORM_MATRIX34: + case OPCODE_UNIFORM_MATRIX43: + free(n[4].data); + n += InstSize[n[0].opcode]; + break; + + case OPCODE_CONTINUE: + n = (Node *) n[1].next; + free(block); + block = n; + break; + case OPCODE_END_OF_LIST: + free(block); + done = GL_TRUE; + break; + default: + /* Most frequent case */ + n += InstSize[n[0].opcode]; + break; + } + } + } + + free(dlist); +} + + +/** + * Destroy a display list and remove from hash table. + * \param list - display list number + */ +static void +destroy_list(struct gl_context *ctx, GLuint list) +{ + struct gl_display_list *dlist; + + if (list == 0) + return; + + dlist = lookup_list(ctx, list); + if (!dlist) + return; + + _mesa_delete_list(ctx, dlist); + _mesa_HashRemove(ctx->Shared->DisplayList, list); +} + + +/* + * Translate the nth element of list from to GLint. + */ +static GLint +translate_id(GLsizei n, GLenum type, const GLvoid * list) +{ + GLbyte *bptr; + GLubyte *ubptr; + GLshort *sptr; + GLushort *usptr; + GLint *iptr; + GLuint *uiptr; + GLfloat *fptr; + + switch (type) { + case GL_BYTE: + bptr = (GLbyte *) list; + return (GLint) bptr[n]; + case GL_UNSIGNED_BYTE: + ubptr = (GLubyte *) list; + return (GLint) ubptr[n]; + case GL_SHORT: + sptr = (GLshort *) list; + return (GLint) sptr[n]; + case GL_UNSIGNED_SHORT: + usptr = (GLushort *) list; + return (GLint) usptr[n]; + case GL_INT: + iptr = (GLint *) list; + return iptr[n]; + case GL_UNSIGNED_INT: + uiptr = (GLuint *) list; + return (GLint) uiptr[n]; + case GL_FLOAT: + fptr = (GLfloat *) list; + return (GLint) FLOORF(fptr[n]); + case GL_2_BYTES: + ubptr = ((GLubyte *) list) + 2 * n; + return (GLint) ubptr[0] * 256 + + (GLint) ubptr[1]; + case GL_3_BYTES: + ubptr = ((GLubyte *) list) + 3 * n; + return (GLint) ubptr[0] * 65536 + + (GLint) ubptr[1] * 256 + + (GLint) ubptr[2]; + case GL_4_BYTES: + ubptr = ((GLubyte *) list) + 4 * n; + return (GLint) ubptr[0] * 16777216 + + (GLint) ubptr[1] * 65536 + + (GLint) ubptr[2] * 256 + + (GLint) ubptr[3]; + default: + return 0; + } +} + + + + +/**********************************************************************/ +/***** Public *****/ +/**********************************************************************/ + +/** + * Wrapper for _mesa_unpack_image() that handles pixel buffer objects. + * If we run out of memory, GL_OUT_OF_MEMORY will be recorded. + */ +static GLvoid * +unpack_image(struct gl_context *ctx, GLuint dimensions, + GLsizei width, GLsizei height, GLsizei depth, + GLenum format, GLenum type, const GLvoid * pixels, + const struct gl_pixelstore_attrib *unpack) +{ + if (!_mesa_is_bufferobj(unpack->BufferObj)) { + /* no PBO */ + GLvoid *image = _mesa_unpack_image(dimensions, width, height, depth, + format, type, pixels, unpack); + if (pixels && !image) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "display list construction"); + } + return image; + } + else if (_mesa_validate_pbo_access(dimensions, unpack, width, height, + depth, format, type, INT_MAX, pixels)) { + const GLubyte *map, *src; + GLvoid *image; + + map = (GLubyte *) + ctx->Driver.MapBufferRange(ctx, 0, unpack->BufferObj->Size, + GL_MAP_READ_BIT, unpack->BufferObj); + if (!map) { + /* unable to map src buffer! */ + _mesa_error(ctx, GL_INVALID_OPERATION, "unable to map PBO"); + return NULL; + } + + src = ADD_POINTERS(map, pixels); + image = _mesa_unpack_image(dimensions, width, height, depth, + format, type, src, unpack); + + ctx->Driver.UnmapBuffer(ctx, unpack->BufferObj); + + if (!image) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "display list construction"); + } + return image; + } + /* bad access! */ + return NULL; +} + + +/** + * Allocate space for a display list instruction (opcode + payload space). + * \param opcode the instruction opcode (OPCODE_* value) + * \param bytes instruction payload size (not counting opcode) + * \return pointer to allocated memory (the opcode space) + */ +static Node * +dlist_alloc(struct gl_context *ctx, OpCode opcode, GLuint bytes) +{ + const GLuint numNodes = 1 + (bytes + sizeof(Node) - 1) / sizeof(Node); + Node *n; + + if (opcode < (GLuint) OPCODE_EXT_0) { + if (InstSize[opcode] == 0) { + /* save instruction size now */ + InstSize[opcode] = numNodes; + } + else { + /* make sure instruction size agrees */ + ASSERT(numNodes == InstSize[opcode]); + } + } + + if (ctx->ListState.CurrentPos + numNodes + 2 > BLOCK_SIZE) { + /* This block is full. Allocate a new block and chain to it */ + Node *newblock; + n = ctx->ListState.CurrentBlock + ctx->ListState.CurrentPos; + n[0].opcode = OPCODE_CONTINUE; + newblock = (Node *) malloc(sizeof(Node) * BLOCK_SIZE); + if (!newblock) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "Building display list"); + return NULL; + } + n[1].next = (Node *) newblock; + ctx->ListState.CurrentBlock = newblock; + ctx->ListState.CurrentPos = 0; + } + + n = ctx->ListState.CurrentBlock + ctx->ListState.CurrentPos; + ctx->ListState.CurrentPos += numNodes; + + n[0].opcode = opcode; + + return n; +} + + + +/** + * Allocate space for a display list instruction. Used by callers outside + * this file for things like VBO vertex data. + * + * \param opcode the instruction opcode (OPCODE_* value) + * \param bytes instruction size in bytes, not counting opcode. + * \return pointer to the usable data area (not including the internal + * opcode). + */ +void * +_mesa_dlist_alloc(struct gl_context *ctx, GLuint opcode, GLuint bytes) +{ + Node *n = dlist_alloc(ctx, (OpCode) opcode, bytes); + if (n) + return n + 1; /* return pointer to payload area, after opcode */ + else + return NULL; +} + + +/** + * This function allows modules and drivers to get their own opcodes + * for extending display list functionality. + * \param ctx the rendering context + * \param size number of bytes for storing the new display list command + * \param execute function to execute the new display list command + * \param destroy function to destroy the new display list command + * \param print function to print the new display list command + * \return the new opcode number or -1 if error + */ +GLint +_mesa_dlist_alloc_opcode(struct gl_context *ctx, + GLuint size, + void (*execute) (struct gl_context *, void *), + void (*destroy) (struct gl_context *, void *), + void (*print) (struct gl_context *, void *)) +{ + if (ctx->ListExt->NumOpcodes < MAX_DLIST_EXT_OPCODES) { + const GLuint i = ctx->ListExt->NumOpcodes++; + ctx->ListExt->Opcode[i].Size = + 1 + (size + sizeof(Node) - 1) / sizeof(Node); + ctx->ListExt->Opcode[i].Execute = execute; + ctx->ListExt->Opcode[i].Destroy = destroy; + ctx->ListExt->Opcode[i].Print = print; + return i + OPCODE_EXT_0; + } + return -1; +} + + +/** + * Allocate space for a display list instruction. The space is basically + * an array of Nodes where node[0] holds the opcode, node[1] is the first + * function parameter, node[2] is the second parameter, etc. + * + * \param opcode one of OPCODE_x + * \param nparams number of function parameters + * \return pointer to start of instruction space + */ +static INLINE Node * +alloc_instruction(struct gl_context *ctx, OpCode opcode, GLuint nparams) +{ + return dlist_alloc(ctx, opcode, nparams * sizeof(Node)); +} + + + +/* + * Display List compilation functions + */ +static void GLAPIENTRY +save_Accum(GLenum op, GLfloat value) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_ACCUM, 2); + if (n) { + n[1].e = op; + n[2].f = value; + } + if (ctx->ExecuteFlag) { + CALL_Accum(ctx->Exec, (op, value)); + } +} + + +static void GLAPIENTRY +save_AlphaFunc(GLenum func, GLclampf ref) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_ALPHA_FUNC, 2); + if (n) { + n[1].e = func; + n[2].f = (GLfloat) ref; + } + if (ctx->ExecuteFlag) { + CALL_AlphaFunc(ctx->Exec, (func, ref)); + } +} + + +static void GLAPIENTRY +save_BindTexture(GLenum target, GLuint texture) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_BIND_TEXTURE, 2); + if (n) { + n[1].e = target; + n[2].ui = texture; + } + if (ctx->ExecuteFlag) { + CALL_BindTexture(ctx->Exec, (target, texture)); + } +} + + +static void GLAPIENTRY +save_Bitmap(GLsizei width, GLsizei height, + GLfloat xorig, GLfloat yorig, + GLfloat xmove, GLfloat ymove, const GLubyte * pixels) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_BITMAP, 7); + if (n) { + n[1].i = (GLint) width; + n[2].i = (GLint) height; + n[3].f = xorig; + n[4].f = yorig; + n[5].f = xmove; + n[6].f = ymove; + n[7].data = _mesa_unpack_bitmap(width, height, pixels, &ctx->Unpack); + } + if (ctx->ExecuteFlag) { + CALL_Bitmap(ctx->Exec, (width, height, + xorig, yorig, xmove, ymove, pixels)); + } +} + + +static void GLAPIENTRY +save_BlendEquation(GLenum mode) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_BLEND_EQUATION, 1); + if (n) { + n[1].e = mode; + } + if (ctx->ExecuteFlag) { + CALL_BlendEquation(ctx->Exec, (mode)); + } +} + + +static void GLAPIENTRY +save_BlendEquationSeparateEXT(GLenum modeRGB, GLenum modeA) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_BLEND_EQUATION_SEPARATE, 2); + if (n) { + n[1].e = modeRGB; + n[2].e = modeA; + } + if (ctx->ExecuteFlag) { + CALL_BlendEquationSeparateEXT(ctx->Exec, (modeRGB, modeA)); + } +} + + +static void GLAPIENTRY +save_BlendFuncSeparateEXT(GLenum sfactorRGB, GLenum dfactorRGB, + GLenum sfactorA, GLenum dfactorA) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_BLEND_FUNC_SEPARATE, 4); + if (n) { + n[1].e = sfactorRGB; + n[2].e = dfactorRGB; + n[3].e = sfactorA; + n[4].e = dfactorA; + } + if (ctx->ExecuteFlag) { + CALL_BlendFuncSeparateEXT(ctx->Exec, + (sfactorRGB, dfactorRGB, sfactorA, dfactorA)); + } +} + + +static void GLAPIENTRY +save_BlendFunc(GLenum srcfactor, GLenum dstfactor) +{ + save_BlendFuncSeparateEXT(srcfactor, dstfactor, srcfactor, dstfactor); +} + + +static void GLAPIENTRY +save_BlendColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_BLEND_COLOR, 4); + if (n) { + n[1].f = red; + n[2].f = green; + n[3].f = blue; + n[4].f = alpha; + } + if (ctx->ExecuteFlag) { + CALL_BlendColor(ctx->Exec, (red, green, blue, alpha)); + } +} + +/* GL_ARB_draw_buffers_blend */ +static void GLAPIENTRY +save_BlendFuncSeparatei(GLuint buf, GLenum sfactorRGB, GLenum dfactorRGB, + GLenum sfactorA, GLenum dfactorA) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_BLEND_FUNC_SEPARATE_I, 5); + if (n) { + n[1].ui = buf; + n[2].e = sfactorRGB; + n[3].e = dfactorRGB; + n[4].e = sfactorA; + n[5].e = dfactorA; + } + if (ctx->ExecuteFlag) { + CALL_BlendFuncSeparateiARB(ctx->Exec, (buf, sfactorRGB, dfactorRGB, + sfactorA, dfactorA)); + } +} + +/* GL_ARB_draw_buffers_blend */ +static void GLAPIENTRY +save_BlendFunci(GLuint buf, GLenum sfactor, GLenum dfactor) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_BLEND_FUNC_SEPARATE_I, 3); + if (n) { + n[1].ui = buf; + n[2].e = sfactor; + n[3].e = dfactor; + } + if (ctx->ExecuteFlag) { + CALL_BlendFunciARB(ctx->Exec, (buf, sfactor, dfactor)); + } +} + +/* GL_ARB_draw_buffers_blend */ +static void GLAPIENTRY +save_BlendEquationi(GLuint buf, GLenum mode) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_BLEND_EQUATION_I, 2); + if (n) { + n[1].ui = buf; + n[2].e = mode; + } + if (ctx->ExecuteFlag) { + CALL_BlendEquationiARB(ctx->Exec, (buf, mode)); + } +} + +/* GL_ARB_draw_buffers_blend */ +static void GLAPIENTRY +save_BlendEquationSeparatei(GLuint buf, GLenum modeRGB, GLenum modeA) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_BLEND_EQUATION_SEPARATE_I, 3); + if (n) { + n[1].ui = buf; + n[2].e = modeRGB; + n[3].e = modeA; + } + if (ctx->ExecuteFlag) { + CALL_BlendEquationSeparateiARB(ctx->Exec, (buf, modeRGB, modeA)); + } +} + + +static void invalidate_saved_current_state( struct gl_context *ctx ) +{ + GLint i; + + for (i = 0; i < VERT_ATTRIB_MAX; i++) + ctx->ListState.ActiveAttribSize[i] = 0; + + for (i = 0; i < MAT_ATTRIB_MAX; i++) + ctx->ListState.ActiveMaterialSize[i] = 0; + + memset(&ctx->ListState.Current, 0, sizeof ctx->ListState.Current); + + ctx->Driver.CurrentSavePrimitive = PRIM_UNKNOWN; +} + +static void GLAPIENTRY +save_CallList(GLuint list) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + SAVE_FLUSH_VERTICES(ctx); + + n = alloc_instruction(ctx, OPCODE_CALL_LIST, 1); + if (n) { + n[1].ui = list; + } + + /* After this, we don't know what state we're in. Invalidate all + * cached information previously gathered: + */ + invalidate_saved_current_state( ctx ); + + if (ctx->ExecuteFlag) { + _mesa_CallList(list); + } +} + + +static void GLAPIENTRY +save_CallLists(GLsizei num, GLenum type, const GLvoid * lists) +{ + GET_CURRENT_CONTEXT(ctx); + GLint i; + GLboolean typeErrorFlag; + + SAVE_FLUSH_VERTICES(ctx); + + switch (type) { + case GL_BYTE: + case GL_UNSIGNED_BYTE: + case GL_SHORT: + case GL_UNSIGNED_SHORT: + case GL_INT: + case GL_UNSIGNED_INT: + case GL_FLOAT: + case GL_2_BYTES: + case GL_3_BYTES: + case GL_4_BYTES: + typeErrorFlag = GL_FALSE; + break; + default: + typeErrorFlag = GL_TRUE; + } + + for (i = 0; i < num; i++) { + GLint list = translate_id(i, type, lists); + Node *n = alloc_instruction(ctx, OPCODE_CALL_LIST_OFFSET, 2); + if (n) { + n[1].i = list; + n[2].b = typeErrorFlag; + } + } + + /* After this, we don't know what state we're in. Invalidate all + * cached information previously gathered: + */ + invalidate_saved_current_state( ctx ); + + if (ctx->ExecuteFlag) { + CALL_CallLists(ctx->Exec, (num, type, lists)); + } +} + + +static void GLAPIENTRY +save_Clear(GLbitfield mask) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_CLEAR, 1); + if (n) { + n[1].bf = mask; + } + if (ctx->ExecuteFlag) { + CALL_Clear(ctx->Exec, (mask)); + } +} + + +static void GLAPIENTRY +save_ClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint *value) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_CLEAR_BUFFER_IV, 6); + if (n) { + n[1].e = buffer; + n[2].i = drawbuffer; + n[3].i = value[0]; + if (buffer == GL_COLOR) { + n[4].i = value[1]; + n[5].i = value[2]; + n[6].i = value[3]; + } + else { + n[4].i = 0; + n[5].i = 0; + n[6].i = 0; + } + } + if (ctx->ExecuteFlag) { + /*CALL_ClearBufferiv(ctx->Exec, (buffer, drawbuffer, value));*/ + } +} + + +static void GLAPIENTRY +save_ClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint *value) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_CLEAR_BUFFER_UIV, 6); + if (n) { + n[1].e = buffer; + n[2].i = drawbuffer; + n[3].ui = value[0]; + if (buffer == GL_COLOR) { + n[4].ui = value[1]; + n[5].ui = value[2]; + n[6].ui = value[3]; + } + else { + n[4].ui = 0; + n[5].ui = 0; + n[6].ui = 0; + } + } + if (ctx->ExecuteFlag) { + /*CALL_ClearBufferuiv(ctx->Exec, (buffer, drawbuffer, value));*/ + } +} + + +static void GLAPIENTRY +save_ClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat *value) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_CLEAR_BUFFER_FV, 6); + if (n) { + n[1].e = buffer; + n[2].i = drawbuffer; + n[3].f = value[0]; + if (buffer == GL_COLOR) { + n[4].f = value[1]; + n[5].f = value[2]; + n[6].f = value[3]; + } + else { + n[4].f = 0.0F; + n[5].f = 0.0F; + n[6].f = 0.0F; + } + } + if (ctx->ExecuteFlag) { + /*CALL_ClearBufferuiv(ctx->Exec, (buffer, drawbuffer, value));*/ + } +} + + +static void GLAPIENTRY +save_ClearBufferfi(GLenum buffer, GLint drawbuffer, + GLfloat depth, GLint stencil) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_CLEAR_BUFFER_FI, 4); + if (n) { + n[1].e = buffer; + n[2].i = drawbuffer; + n[3].f = depth; + n[4].i = stencil; + } + if (ctx->ExecuteFlag) { + /*CALL_ClearBufferfi(ctx->Exec, (buffer, drawbuffer, depth, stencil));*/ + } +} + + +static void GLAPIENTRY +save_ClearAccum(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_CLEAR_ACCUM, 4); + if (n) { + n[1].f = red; + n[2].f = green; + n[3].f = blue; + n[4].f = alpha; + } + if (ctx->ExecuteFlag) { + CALL_ClearAccum(ctx->Exec, (red, green, blue, alpha)); + } +} + + +static void GLAPIENTRY +save_ClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_CLEAR_COLOR, 4); + if (n) { + n[1].f = red; + n[2].f = green; + n[3].f = blue; + n[4].f = alpha; + } + if (ctx->ExecuteFlag) { + CALL_ClearColor(ctx->Exec, (red, green, blue, alpha)); + } +} + + +static void GLAPIENTRY +save_ClearDepth(GLclampd depth) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_CLEAR_DEPTH, 1); + if (n) { + n[1].f = (GLfloat) depth; + } + if (ctx->ExecuteFlag) { + CALL_ClearDepth(ctx->Exec, (depth)); + } +} + + +static void GLAPIENTRY +save_ClearIndex(GLfloat c) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_CLEAR_INDEX, 1); + if (n) { + n[1].f = c; + } + if (ctx->ExecuteFlag) { + CALL_ClearIndex(ctx->Exec, (c)); + } +} + + +static void GLAPIENTRY +save_ClearStencil(GLint s) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_CLEAR_STENCIL, 1); + if (n) { + n[1].i = s; + } + if (ctx->ExecuteFlag) { + CALL_ClearStencil(ctx->Exec, (s)); + } +} + + +static void GLAPIENTRY +save_ClipPlane(GLenum plane, const GLdouble * equ) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_CLIP_PLANE, 5); + if (n) { + n[1].e = plane; + n[2].f = (GLfloat) equ[0]; + n[3].f = (GLfloat) equ[1]; + n[4].f = (GLfloat) equ[2]; + n[5].f = (GLfloat) equ[3]; + } + if (ctx->ExecuteFlag) { + CALL_ClipPlane(ctx->Exec, (plane, equ)); + } +} + + + +static void GLAPIENTRY +save_ColorMask(GLboolean red, GLboolean green, + GLboolean blue, GLboolean alpha) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_COLOR_MASK, 4); + if (n) { + n[1].b = red; + n[2].b = green; + n[3].b = blue; + n[4].b = alpha; + } + if (ctx->ExecuteFlag) { + CALL_ColorMask(ctx->Exec, (red, green, blue, alpha)); + } +} + + +static void GLAPIENTRY +save_ColorMaskIndexed(GLuint buf, GLboolean red, GLboolean green, + GLboolean blue, GLboolean alpha) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_COLOR_MASK_INDEXED, 5); + if (n) { + n[1].ui = buf; + n[2].b = red; + n[3].b = green; + n[4].b = blue; + n[5].b = alpha; + } + if (ctx->ExecuteFlag) { + /*CALL_ColorMaskIndexedEXT(ctx->Exec, (buf, red, green, blue, alpha));*/ + } +} + + +static void GLAPIENTRY +save_ColorMaterial(GLenum face, GLenum mode) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + + n = alloc_instruction(ctx, OPCODE_COLOR_MATERIAL, 2); + if (n) { + n[1].e = face; + n[2].e = mode; + } + if (ctx->ExecuteFlag) { + CALL_ColorMaterial(ctx->Exec, (face, mode)); + } +} + + +static void GLAPIENTRY +save_ColorTable(GLenum target, GLenum internalFormat, + GLsizei width, GLenum format, GLenum type, + const GLvoid * table) +{ + GET_CURRENT_CONTEXT(ctx); + if (_mesa_is_proxy_texture(target)) { + /* execute immediately */ + CALL_ColorTable(ctx->Exec, (target, internalFormat, width, + format, type, table)); + } + else { + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_COLOR_TABLE, 6); + if (n) { + n[1].e = target; + n[2].e = internalFormat; + n[3].i = width; + n[4].e = format; + n[5].e = type; + n[6].data = unpack_image(ctx, 1, width, 1, 1, format, type, table, + &ctx->Unpack); + } + if (ctx->ExecuteFlag) { + CALL_ColorTable(ctx->Exec, (target, internalFormat, width, + format, type, table)); + } + } +} + + + +static void GLAPIENTRY +save_ColorTableParameterfv(GLenum target, GLenum pname, + const GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + + n = alloc_instruction(ctx, OPCODE_COLOR_TABLE_PARAMETER_FV, 6); + if (n) { + n[1].e = target; + n[2].e = pname; + n[3].f = params[0]; + if (pname == GL_COLOR_TABLE_SGI || + pname == GL_POST_CONVOLUTION_COLOR_TABLE_SGI || + pname == GL_TEXTURE_COLOR_TABLE_SGI) { + n[4].f = params[1]; + n[5].f = params[2]; + n[6].f = params[3]; + } + } + + if (ctx->ExecuteFlag) { + CALL_ColorTableParameterfv(ctx->Exec, (target, pname, params)); + } +} + + +static void GLAPIENTRY +save_ColorTableParameteriv(GLenum target, GLenum pname, const GLint *params) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + + n = alloc_instruction(ctx, OPCODE_COLOR_TABLE_PARAMETER_IV, 6); + if (n) { + n[1].e = target; + n[2].e = pname; + n[3].i = params[0]; + if (pname == GL_COLOR_TABLE_SGI || + pname == GL_POST_CONVOLUTION_COLOR_TABLE_SGI || + pname == GL_TEXTURE_COLOR_TABLE_SGI) { + n[4].i = params[1]; + n[5].i = params[2]; + n[6].i = params[3]; + } + } + + if (ctx->ExecuteFlag) { + CALL_ColorTableParameteriv(ctx->Exec, (target, pname, params)); + } +} + + + +static void GLAPIENTRY +save_ColorSubTable(GLenum target, GLsizei start, GLsizei count, + GLenum format, GLenum type, const GLvoid * table) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_COLOR_SUB_TABLE, 6); + if (n) { + n[1].e = target; + n[2].i = start; + n[3].i = count; + n[4].e = format; + n[5].e = type; + n[6].data = unpack_image(ctx, 1, count, 1, 1, format, type, table, + &ctx->Unpack); + } + if (ctx->ExecuteFlag) { + CALL_ColorSubTable(ctx->Exec, + (target, start, count, format, type, table)); + } +} + + +static void GLAPIENTRY +save_CopyColorSubTable(GLenum target, GLsizei start, + GLint x, GLint y, GLsizei width) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_COPY_COLOR_SUB_TABLE, 5); + if (n) { + n[1].e = target; + n[2].i = start; + n[3].i = x; + n[4].i = y; + n[5].i = width; + } + if (ctx->ExecuteFlag) { + CALL_CopyColorSubTable(ctx->Exec, (target, start, x, y, width)); + } +} + + +static void GLAPIENTRY +save_CopyColorTable(GLenum target, GLenum internalformat, + GLint x, GLint y, GLsizei width) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_COPY_COLOR_TABLE, 5); + if (n) { + n[1].e = target; + n[2].e = internalformat; + n[3].i = x; + n[4].i = y; + n[5].i = width; + } + if (ctx->ExecuteFlag) { + CALL_CopyColorTable(ctx->Exec, (target, internalformat, x, y, width)); + } +} + + +static void GLAPIENTRY +save_ConvolutionFilter1D(GLenum target, GLenum internalFormat, GLsizei width, + GLenum format, GLenum type, const GLvoid * filter) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + + n = alloc_instruction(ctx, OPCODE_CONVOLUTION_FILTER_1D, 6); + if (n) { + n[1].e = target; + n[2].e = internalFormat; + n[3].i = width; + n[4].e = format; + n[5].e = type; + n[6].data = unpack_image(ctx, 1, width, 1, 1, format, type, filter, + &ctx->Unpack); + } + if (ctx->ExecuteFlag) { + CALL_ConvolutionFilter1D(ctx->Exec, (target, internalFormat, width, + format, type, filter)); + } +} + + +static void GLAPIENTRY +save_ConvolutionFilter2D(GLenum target, GLenum internalFormat, + GLsizei width, GLsizei height, GLenum format, + GLenum type, const GLvoid * filter) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + + n = alloc_instruction(ctx, OPCODE_CONVOLUTION_FILTER_2D, 7); + if (n) { + n[1].e = target; + n[2].e = internalFormat; + n[3].i = width; + n[4].i = height; + n[5].e = format; + n[6].e = type; + n[7].data = unpack_image(ctx, 2, width, height, 1, format, type, filter, + &ctx->Unpack); + } + if (ctx->ExecuteFlag) { + CALL_ConvolutionFilter2D(ctx->Exec, + (target, internalFormat, width, height, format, + type, filter)); + } +} + + +static void GLAPIENTRY +save_ConvolutionParameteri(GLenum target, GLenum pname, GLint param) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_CONVOLUTION_PARAMETER_I, 3); + if (n) { + n[1].e = target; + n[2].e = pname; + n[3].i = param; + } + if (ctx->ExecuteFlag) { + CALL_ConvolutionParameteri(ctx->Exec, (target, pname, param)); + } +} + + +static void GLAPIENTRY +save_ConvolutionParameteriv(GLenum target, GLenum pname, const GLint *params) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_CONVOLUTION_PARAMETER_IV, 6); + if (n) { + n[1].e = target; + n[2].e = pname; + n[3].i = params[0]; + if (pname == GL_CONVOLUTION_BORDER_COLOR || + pname == GL_CONVOLUTION_FILTER_SCALE || + pname == GL_CONVOLUTION_FILTER_BIAS) { + n[4].i = params[1]; + n[5].i = params[2]; + n[6].i = params[3]; + } + else { + n[4].i = n[5].i = n[6].i = 0; + } + } + if (ctx->ExecuteFlag) { + CALL_ConvolutionParameteriv(ctx->Exec, (target, pname, params)); + } +} + + +static void GLAPIENTRY +save_ConvolutionParameterf(GLenum target, GLenum pname, GLfloat param) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_CONVOLUTION_PARAMETER_F, 3); + if (n) { + n[1].e = target; + n[2].e = pname; + n[3].f = param; + } + if (ctx->ExecuteFlag) { + CALL_ConvolutionParameterf(ctx->Exec, (target, pname, param)); + } +} + + +static void GLAPIENTRY +save_ConvolutionParameterfv(GLenum target, GLenum pname, + const GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_CONVOLUTION_PARAMETER_FV, 6); + if (n) { + n[1].e = target; + n[2].e = pname; + n[3].f = params[0]; + if (pname == GL_CONVOLUTION_BORDER_COLOR || + pname == GL_CONVOLUTION_FILTER_SCALE || + pname == GL_CONVOLUTION_FILTER_BIAS) { + n[4].f = params[1]; + n[5].f = params[2]; + n[6].f = params[3]; + } + else { + n[4].f = n[5].f = n[6].f = 0.0F; + } + } + if (ctx->ExecuteFlag) { + CALL_ConvolutionParameterfv(ctx->Exec, (target, pname, params)); + } +} + + +static void GLAPIENTRY +save_CopyPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_COPY_PIXELS, 5); + if (n) { + n[1].i = x; + n[2].i = y; + n[3].i = (GLint) width; + n[4].i = (GLint) height; + n[5].e = type; + } + if (ctx->ExecuteFlag) { + CALL_CopyPixels(ctx->Exec, (x, y, width, height, type)); + } +} + + + +static void GLAPIENTRY +save_CopyTexImage1D(GLenum target, GLint level, GLenum internalformat, + GLint x, GLint y, GLsizei width, GLint border) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_COPY_TEX_IMAGE1D, 7); + if (n) { + n[1].e = target; + n[2].i = level; + n[3].e = internalformat; + n[4].i = x; + n[5].i = y; + n[6].i = width; + n[7].i = border; + } + if (ctx->ExecuteFlag) { + CALL_CopyTexImage1D(ctx->Exec, (target, level, internalformat, + x, y, width, border)); + } +} + + +static void GLAPIENTRY +save_CopyTexImage2D(GLenum target, GLint level, + GLenum internalformat, + GLint x, GLint y, GLsizei width, + GLsizei height, GLint border) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_COPY_TEX_IMAGE2D, 8); + if (n) { + n[1].e = target; + n[2].i = level; + n[3].e = internalformat; + n[4].i = x; + n[5].i = y; + n[6].i = width; + n[7].i = height; + n[8].i = border; + } + if (ctx->ExecuteFlag) { + CALL_CopyTexImage2D(ctx->Exec, (target, level, internalformat, + x, y, width, height, border)); + } +} + + + +static void GLAPIENTRY +save_CopyTexSubImage1D(GLenum target, GLint level, + GLint xoffset, GLint x, GLint y, GLsizei width) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_COPY_TEX_SUB_IMAGE1D, 6); + if (n) { + n[1].e = target; + n[2].i = level; + n[3].i = xoffset; + n[4].i = x; + n[5].i = y; + n[6].i = width; + } + if (ctx->ExecuteFlag) { + CALL_CopyTexSubImage1D(ctx->Exec, + (target, level, xoffset, x, y, width)); + } +} + + +static void GLAPIENTRY +save_CopyTexSubImage2D(GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLint x, GLint y, GLsizei width, GLint height) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_COPY_TEX_SUB_IMAGE2D, 8); + if (n) { + n[1].e = target; + n[2].i = level; + n[3].i = xoffset; + n[4].i = yoffset; + n[5].i = x; + n[6].i = y; + n[7].i = width; + n[8].i = height; + } + if (ctx->ExecuteFlag) { + CALL_CopyTexSubImage2D(ctx->Exec, (target, level, xoffset, yoffset, + x, y, width, height)); + } +} + + +static void GLAPIENTRY +save_CopyTexSubImage3D(GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLint x, GLint y, GLsizei width, GLint height) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_COPY_TEX_SUB_IMAGE3D, 9); + if (n) { + n[1].e = target; + n[2].i = level; + n[3].i = xoffset; + n[4].i = yoffset; + n[5].i = zoffset; + n[6].i = x; + n[7].i = y; + n[8].i = width; + n[9].i = height; + } + if (ctx->ExecuteFlag) { + CALL_CopyTexSubImage3D(ctx->Exec, (target, level, + xoffset, yoffset, zoffset, + x, y, width, height)); + } +} + + +static void GLAPIENTRY +save_CullFace(GLenum mode) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_CULL_FACE, 1); + if (n) { + n[1].e = mode; + } + if (ctx->ExecuteFlag) { + CALL_CullFace(ctx->Exec, (mode)); + } +} + + +static void GLAPIENTRY +save_DepthFunc(GLenum func) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_DEPTH_FUNC, 1); + if (n) { + n[1].e = func; + } + if (ctx->ExecuteFlag) { + CALL_DepthFunc(ctx->Exec, (func)); + } +} + + +static void GLAPIENTRY +save_DepthMask(GLboolean mask) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_DEPTH_MASK, 1); + if (n) { + n[1].b = mask; + } + if (ctx->ExecuteFlag) { + CALL_DepthMask(ctx->Exec, (mask)); + } +} + + +static void GLAPIENTRY +save_DepthRange(GLclampd nearval, GLclampd farval) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_DEPTH_RANGE, 2); + if (n) { + n[1].f = (GLfloat) nearval; + n[2].f = (GLfloat) farval; + } + if (ctx->ExecuteFlag) { + CALL_DepthRange(ctx->Exec, (nearval, farval)); + } +} + + +static void GLAPIENTRY +save_Disable(GLenum cap) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_DISABLE, 1); + if (n) { + n[1].e = cap; + } + if (ctx->ExecuteFlag) { + CALL_Disable(ctx->Exec, (cap)); + } +} + + +static void GLAPIENTRY +save_DisableIndexed(GLuint index, GLenum cap) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_DISABLE_INDEXED, 2); + if (n) { + n[1].ui = index; + n[2].e = cap; + } + if (ctx->ExecuteFlag) { + CALL_DisableIndexedEXT(ctx->Exec, (index, cap)); + } +} + + +static void GLAPIENTRY +save_DrawBuffer(GLenum mode) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_DRAW_BUFFER, 1); + if (n) { + n[1].e = mode; + } + if (ctx->ExecuteFlag) { + CALL_DrawBuffer(ctx->Exec, (mode)); + } +} + + +static void GLAPIENTRY +save_DrawPixels(GLsizei width, GLsizei height, + GLenum format, GLenum type, const GLvoid * pixels) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + + n = alloc_instruction(ctx, OPCODE_DRAW_PIXELS, 5); + if (n) { + n[1].i = width; + n[2].i = height; + n[3].e = format; + n[4].e = type; + n[5].data = unpack_image(ctx, 2, width, height, 1, format, type, + pixels, &ctx->Unpack); + } + if (ctx->ExecuteFlag) { + CALL_DrawPixels(ctx->Exec, (width, height, format, type, pixels)); + } +} + + + +static void GLAPIENTRY +save_Enable(GLenum cap) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_ENABLE, 1); + if (n) { + n[1].e = cap; + } + if (ctx->ExecuteFlag) { + CALL_Enable(ctx->Exec, (cap)); + } +} + + + +static void GLAPIENTRY +save_EnableIndexed(GLuint index, GLenum cap) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_ENABLE_INDEXED, 2); + if (n) { + n[1].ui = index; + n[2].e = cap; + } + if (ctx->ExecuteFlag) { + CALL_EnableIndexedEXT(ctx->Exec, (index, cap)); + } +} + + + +static void GLAPIENTRY +save_EvalMesh1(GLenum mode, GLint i1, GLint i2) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_EVALMESH1, 3); + if (n) { + n[1].e = mode; + n[2].i = i1; + n[3].i = i2; + } + if (ctx->ExecuteFlag) { + CALL_EvalMesh1(ctx->Exec, (mode, i1, i2)); + } +} + + +static void GLAPIENTRY +save_EvalMesh2(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_EVALMESH2, 5); + if (n) { + n[1].e = mode; + n[2].i = i1; + n[3].i = i2; + n[4].i = j1; + n[5].i = j2; + } + if (ctx->ExecuteFlag) { + CALL_EvalMesh2(ctx->Exec, (mode, i1, i2, j1, j2)); + } +} + + + + +static void GLAPIENTRY +save_Fogfv(GLenum pname, const GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_FOG, 5); + if (n) { + n[1].e = pname; + n[2].f = params[0]; + n[3].f = params[1]; + n[4].f = params[2]; + n[5].f = params[3]; + } + if (ctx->ExecuteFlag) { + CALL_Fogfv(ctx->Exec, (pname, params)); + } +} + + +static void GLAPIENTRY +save_Fogf(GLenum pname, GLfloat param) +{ + GLfloat parray[4]; + parray[0] = param; + parray[1] = parray[2] = parray[3] = 0.0F; + save_Fogfv(pname, parray); +} + + +static void GLAPIENTRY +save_Fogiv(GLenum pname, const GLint *params) +{ + GLfloat p[4]; + switch (pname) { + case GL_FOG_MODE: + case GL_FOG_DENSITY: + case GL_FOG_START: + case GL_FOG_END: + case GL_FOG_INDEX: + p[0] = (GLfloat) *params; + p[1] = 0.0f; + p[2] = 0.0f; + p[3] = 0.0f; + break; + case GL_FOG_COLOR: + p[0] = INT_TO_FLOAT(params[0]); + p[1] = INT_TO_FLOAT(params[1]); + p[2] = INT_TO_FLOAT(params[2]); + p[3] = INT_TO_FLOAT(params[3]); + break; + default: + /* Error will be caught later in gl_Fogfv */ + ASSIGN_4V(p, 0.0F, 0.0F, 0.0F, 0.0F); + } + save_Fogfv(pname, p); +} + + +static void GLAPIENTRY +save_Fogi(GLenum pname, GLint param) +{ + GLint parray[4]; + parray[0] = param; + parray[1] = parray[2] = parray[3] = 0; + save_Fogiv(pname, parray); +} + + +static void GLAPIENTRY +save_FrontFace(GLenum mode) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_FRONT_FACE, 1); + if (n) { + n[1].e = mode; + } + if (ctx->ExecuteFlag) { + CALL_FrontFace(ctx->Exec, (mode)); + } +} + + +static void GLAPIENTRY +save_Frustum(GLdouble left, GLdouble right, + GLdouble bottom, GLdouble top, GLdouble nearval, GLdouble farval) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_FRUSTUM, 6); + if (n) { + n[1].f = (GLfloat) left; + n[2].f = (GLfloat) right; + n[3].f = (GLfloat) bottom; + n[4].f = (GLfloat) top; + n[5].f = (GLfloat) nearval; + n[6].f = (GLfloat) farval; + } + if (ctx->ExecuteFlag) { + CALL_Frustum(ctx->Exec, (left, right, bottom, top, nearval, farval)); + } +} + + +static void GLAPIENTRY +save_Hint(GLenum target, GLenum mode) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_HINT, 2); + if (n) { + n[1].e = target; + n[2].e = mode; + } + if (ctx->ExecuteFlag) { + CALL_Hint(ctx->Exec, (target, mode)); + } +} + + +static void GLAPIENTRY +save_Histogram(GLenum target, GLsizei width, GLenum internalFormat, + GLboolean sink) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_HISTOGRAM, 4); + if (n) { + n[1].e = target; + n[2].i = width; + n[3].e = internalFormat; + n[4].b = sink; + } + if (ctx->ExecuteFlag) { + CALL_Histogram(ctx->Exec, (target, width, internalFormat, sink)); + } +} + + +static void GLAPIENTRY +save_IndexMask(GLuint mask) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_INDEX_MASK, 1); + if (n) { + n[1].ui = mask; + } + if (ctx->ExecuteFlag) { + CALL_IndexMask(ctx->Exec, (mask)); + } +} + + +static void GLAPIENTRY +save_InitNames(void) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + (void) alloc_instruction(ctx, OPCODE_INIT_NAMES, 0); + if (ctx->ExecuteFlag) { + CALL_InitNames(ctx->Exec, ()); + } +} + + +static void GLAPIENTRY +save_Lightfv(GLenum light, GLenum pname, const GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_LIGHT, 6); + if (n) { + GLint i, nParams; + n[1].e = light; + n[2].e = pname; + switch (pname) { + case GL_AMBIENT: + nParams = 4; + break; + case GL_DIFFUSE: + nParams = 4; + break; + case GL_SPECULAR: + nParams = 4; + break; + case GL_POSITION: + nParams = 4; + break; + case GL_SPOT_DIRECTION: + nParams = 3; + break; + case GL_SPOT_EXPONENT: + nParams = 1; + break; + case GL_SPOT_CUTOFF: + nParams = 1; + break; + case GL_CONSTANT_ATTENUATION: + nParams = 1; + break; + case GL_LINEAR_ATTENUATION: + nParams = 1; + break; + case GL_QUADRATIC_ATTENUATION: + nParams = 1; + break; + default: + nParams = 0; + } + for (i = 0; i < nParams; i++) { + n[3 + i].f = params[i]; + } + } + if (ctx->ExecuteFlag) { + CALL_Lightfv(ctx->Exec, (light, pname, params)); + } +} + + +static void GLAPIENTRY +save_Lightf(GLenum light, GLenum pname, GLfloat param) +{ + GLfloat parray[4]; + parray[0] = param; + parray[1] = parray[2] = parray[3] = 0.0F; + save_Lightfv(light, pname, parray); +} + + +static void GLAPIENTRY +save_Lightiv(GLenum light, GLenum pname, const GLint *params) +{ + GLfloat fparam[4]; + switch (pname) { + case GL_AMBIENT: + case GL_DIFFUSE: + case GL_SPECULAR: + fparam[0] = INT_TO_FLOAT(params[0]); + fparam[1] = INT_TO_FLOAT(params[1]); + fparam[2] = INT_TO_FLOAT(params[2]); + fparam[3] = INT_TO_FLOAT(params[3]); + break; + case GL_POSITION: + fparam[0] = (GLfloat) params[0]; + fparam[1] = (GLfloat) params[1]; + fparam[2] = (GLfloat) params[2]; + fparam[3] = (GLfloat) params[3]; + break; + case GL_SPOT_DIRECTION: + fparam[0] = (GLfloat) params[0]; + fparam[1] = (GLfloat) params[1]; + fparam[2] = (GLfloat) params[2]; + break; + case GL_SPOT_EXPONENT: + case GL_SPOT_CUTOFF: + case GL_CONSTANT_ATTENUATION: + case GL_LINEAR_ATTENUATION: + case GL_QUADRATIC_ATTENUATION: + fparam[0] = (GLfloat) params[0]; + break; + default: + /* error will be caught later in gl_Lightfv */ + ; + } + save_Lightfv(light, pname, fparam); +} + + +static void GLAPIENTRY +save_Lighti(GLenum light, GLenum pname, GLint param) +{ + GLint parray[4]; + parray[0] = param; + parray[1] = parray[2] = parray[3] = 0; + save_Lightiv(light, pname, parray); +} + + +static void GLAPIENTRY +save_LightModelfv(GLenum pname, const GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_LIGHT_MODEL, 5); + if (n) { + n[1].e = pname; + n[2].f = params[0]; + n[3].f = params[1]; + n[4].f = params[2]; + n[5].f = params[3]; + } + if (ctx->ExecuteFlag) { + CALL_LightModelfv(ctx->Exec, (pname, params)); + } +} + + +static void GLAPIENTRY +save_LightModelf(GLenum pname, GLfloat param) +{ + GLfloat parray[4]; + parray[0] = param; + parray[1] = parray[2] = parray[3] = 0.0F; + save_LightModelfv(pname, parray); +} + + +static void GLAPIENTRY +save_LightModeliv(GLenum pname, const GLint *params) +{ + GLfloat fparam[4]; + switch (pname) { + case GL_LIGHT_MODEL_AMBIENT: + fparam[0] = INT_TO_FLOAT(params[0]); + fparam[1] = INT_TO_FLOAT(params[1]); + fparam[2] = INT_TO_FLOAT(params[2]); + fparam[3] = INT_TO_FLOAT(params[3]); + break; + case GL_LIGHT_MODEL_LOCAL_VIEWER: + case GL_LIGHT_MODEL_TWO_SIDE: + case GL_LIGHT_MODEL_COLOR_CONTROL: + fparam[0] = (GLfloat) params[0]; + fparam[1] = 0.0F; + fparam[2] = 0.0F; + fparam[3] = 0.0F; + break; + default: + /* Error will be caught later in gl_LightModelfv */ + ASSIGN_4V(fparam, 0.0F, 0.0F, 0.0F, 0.0F); + } + save_LightModelfv(pname, fparam); +} + + +static void GLAPIENTRY +save_LightModeli(GLenum pname, GLint param) +{ + GLint parray[4]; + parray[0] = param; + parray[1] = parray[2] = parray[3] = 0; + save_LightModeliv(pname, parray); +} + + +static void GLAPIENTRY +save_LineStipple(GLint factor, GLushort pattern) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_LINE_STIPPLE, 2); + if (n) { + n[1].i = factor; + n[2].us = pattern; + } + if (ctx->ExecuteFlag) { + CALL_LineStipple(ctx->Exec, (factor, pattern)); + } +} + + +static void GLAPIENTRY +save_LineWidth(GLfloat width) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_LINE_WIDTH, 1); + if (n) { + n[1].f = width; + } + if (ctx->ExecuteFlag) { + CALL_LineWidth(ctx->Exec, (width)); + } +} + + +static void GLAPIENTRY +save_ListBase(GLuint base) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_LIST_BASE, 1); + if (n) { + n[1].ui = base; + } + if (ctx->ExecuteFlag) { + CALL_ListBase(ctx->Exec, (base)); + } +} + + +static void GLAPIENTRY +save_LoadIdentity(void) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + (void) alloc_instruction(ctx, OPCODE_LOAD_IDENTITY, 0); + if (ctx->ExecuteFlag) { + CALL_LoadIdentity(ctx->Exec, ()); + } +} + + +static void GLAPIENTRY +save_LoadMatrixf(const GLfloat * m) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_LOAD_MATRIX, 16); + if (n) { + GLuint i; + for (i = 0; i < 16; i++) { + n[1 + i].f = m[i]; + } + } + if (ctx->ExecuteFlag) { + CALL_LoadMatrixf(ctx->Exec, (m)); + } +} + + +static void GLAPIENTRY +save_LoadMatrixd(const GLdouble * m) +{ + GLfloat f[16]; + GLint i; + for (i = 0; i < 16; i++) { + f[i] = (GLfloat) m[i]; + } + save_LoadMatrixf(f); +} + + +static void GLAPIENTRY +save_LoadName(GLuint name) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_LOAD_NAME, 1); + if (n) { + n[1].ui = name; + } + if (ctx->ExecuteFlag) { + CALL_LoadName(ctx->Exec, (name)); + } +} + + +static void GLAPIENTRY +save_LogicOp(GLenum opcode) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_LOGIC_OP, 1); + if (n) { + n[1].e = opcode; + } + if (ctx->ExecuteFlag) { + CALL_LogicOp(ctx->Exec, (opcode)); + } +} + + +static void GLAPIENTRY +save_Map1d(GLenum target, GLdouble u1, GLdouble u2, GLint stride, + GLint order, const GLdouble * points) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_MAP1, 6); + if (n) { + GLfloat *pnts = _mesa_copy_map_points1d(target, stride, order, points); + n[1].e = target; + n[2].f = (GLfloat) u1; + n[3].f = (GLfloat) u2; + n[4].i = _mesa_evaluator_components(target); /* stride */ + n[5].i = order; + n[6].data = (void *) pnts; + } + if (ctx->ExecuteFlag) { + CALL_Map1d(ctx->Exec, (target, u1, u2, stride, order, points)); + } +} + +static void GLAPIENTRY +save_Map1f(GLenum target, GLfloat u1, GLfloat u2, GLint stride, + GLint order, const GLfloat * points) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_MAP1, 6); + if (n) { + GLfloat *pnts = _mesa_copy_map_points1f(target, stride, order, points); + n[1].e = target; + n[2].f = u1; + n[3].f = u2; + n[4].i = _mesa_evaluator_components(target); /* stride */ + n[5].i = order; + n[6].data = (void *) pnts; + } + if (ctx->ExecuteFlag) { + CALL_Map1f(ctx->Exec, (target, u1, u2, stride, order, points)); + } +} + + +static void GLAPIENTRY +save_Map2d(GLenum target, + GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, + GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, + const GLdouble * points) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_MAP2, 10); + if (n) { + GLfloat *pnts = _mesa_copy_map_points2d(target, ustride, uorder, + vstride, vorder, points); + n[1].e = target; + n[2].f = (GLfloat) u1; + n[3].f = (GLfloat) u2; + n[4].f = (GLfloat) v1; + n[5].f = (GLfloat) v2; + /* XXX verify these strides are correct */ + n[6].i = _mesa_evaluator_components(target) * vorder; /*ustride */ + n[7].i = _mesa_evaluator_components(target); /*vstride */ + n[8].i = uorder; + n[9].i = vorder; + n[10].data = (void *) pnts; + } + if (ctx->ExecuteFlag) { + CALL_Map2d(ctx->Exec, (target, + u1, u2, ustride, uorder, + v1, v2, vstride, vorder, points)); + } +} + + +static void GLAPIENTRY +save_Map2f(GLenum target, + GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, + GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, + const GLfloat * points) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_MAP2, 10); + if (n) { + GLfloat *pnts = _mesa_copy_map_points2f(target, ustride, uorder, + vstride, vorder, points); + n[1].e = target; + n[2].f = u1; + n[3].f = u2; + n[4].f = v1; + n[5].f = v2; + /* XXX verify these strides are correct */ + n[6].i = _mesa_evaluator_components(target) * vorder; /*ustride */ + n[7].i = _mesa_evaluator_components(target); /*vstride */ + n[8].i = uorder; + n[9].i = vorder; + n[10].data = (void *) pnts; + } + if (ctx->ExecuteFlag) { + CALL_Map2f(ctx->Exec, (target, u1, u2, ustride, uorder, + v1, v2, vstride, vorder, points)); + } +} + + +static void GLAPIENTRY +save_MapGrid1f(GLint un, GLfloat u1, GLfloat u2) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_MAPGRID1, 3); + if (n) { + n[1].i = un; + n[2].f = u1; + n[3].f = u2; + } + if (ctx->ExecuteFlag) { + CALL_MapGrid1f(ctx->Exec, (un, u1, u2)); + } +} + + +static void GLAPIENTRY +save_MapGrid1d(GLint un, GLdouble u1, GLdouble u2) +{ + save_MapGrid1f(un, (GLfloat) u1, (GLfloat) u2); +} + + +static void GLAPIENTRY +save_MapGrid2f(GLint un, GLfloat u1, GLfloat u2, + GLint vn, GLfloat v1, GLfloat v2) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_MAPGRID2, 6); + if (n) { + n[1].i = un; + n[2].f = u1; + n[3].f = u2; + n[4].i = vn; + n[5].f = v1; + n[6].f = v2; + } + if (ctx->ExecuteFlag) { + CALL_MapGrid2f(ctx->Exec, (un, u1, u2, vn, v1, v2)); + } +} + + + +static void GLAPIENTRY +save_MapGrid2d(GLint un, GLdouble u1, GLdouble u2, + GLint vn, GLdouble v1, GLdouble v2) +{ + save_MapGrid2f(un, (GLfloat) u1, (GLfloat) u2, + vn, (GLfloat) v1, (GLfloat) v2); +} + + +static void GLAPIENTRY +save_MatrixMode(GLenum mode) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_MATRIX_MODE, 1); + if (n) { + n[1].e = mode; + } + if (ctx->ExecuteFlag) { + CALL_MatrixMode(ctx->Exec, (mode)); + } +} + + +static void GLAPIENTRY +save_Minmax(GLenum target, GLenum internalFormat, GLboolean sink) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_MIN_MAX, 3); + if (n) { + n[1].e = target; + n[2].e = internalFormat; + n[3].b = sink; + } + if (ctx->ExecuteFlag) { + CALL_Minmax(ctx->Exec, (target, internalFormat, sink)); + } +} + + +static void GLAPIENTRY +save_MultMatrixf(const GLfloat * m) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_MULT_MATRIX, 16); + if (n) { + GLuint i; + for (i = 0; i < 16; i++) { + n[1 + i].f = m[i]; + } + } + if (ctx->ExecuteFlag) { + CALL_MultMatrixf(ctx->Exec, (m)); + } +} + + +static void GLAPIENTRY +save_MultMatrixd(const GLdouble * m) +{ + GLfloat f[16]; + GLint i; + for (i = 0; i < 16; i++) { + f[i] = (GLfloat) m[i]; + } + save_MultMatrixf(f); +} + + +static void GLAPIENTRY +save_NewList(GLuint name, GLenum mode) +{ + GET_CURRENT_CONTEXT(ctx); + /* It's an error to call this function while building a display list */ + _mesa_error(ctx, GL_INVALID_OPERATION, "glNewList"); + (void) name; + (void) mode; +} + + + +static void GLAPIENTRY +save_Ortho(GLdouble left, GLdouble right, + GLdouble bottom, GLdouble top, GLdouble nearval, GLdouble farval) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_ORTHO, 6); + if (n) { + n[1].f = (GLfloat) left; + n[2].f = (GLfloat) right; + n[3].f = (GLfloat) bottom; + n[4].f = (GLfloat) top; + n[5].f = (GLfloat) nearval; + n[6].f = (GLfloat) farval; + } + if (ctx->ExecuteFlag) { + CALL_Ortho(ctx->Exec, (left, right, bottom, top, nearval, farval)); + } +} + + +static void GLAPIENTRY +save_PixelMapfv(GLenum map, GLint mapsize, const GLfloat *values) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_PIXEL_MAP, 3); + if (n) { + n[1].e = map; + n[2].i = mapsize; + n[3].data = (void *) malloc(mapsize * sizeof(GLfloat)); + memcpy(n[3].data, (void *) values, mapsize * sizeof(GLfloat)); + } + if (ctx->ExecuteFlag) { + CALL_PixelMapfv(ctx->Exec, (map, mapsize, values)); + } +} + + +static void GLAPIENTRY +save_PixelMapuiv(GLenum map, GLint mapsize, const GLuint *values) +{ + GLfloat fvalues[MAX_PIXEL_MAP_TABLE]; + GLint i; + if (map == GL_PIXEL_MAP_I_TO_I || map == GL_PIXEL_MAP_S_TO_S) { + for (i = 0; i < mapsize; i++) { + fvalues[i] = (GLfloat) values[i]; + } + } + else { + for (i = 0; i < mapsize; i++) { + fvalues[i] = UINT_TO_FLOAT(values[i]); + } + } + save_PixelMapfv(map, mapsize, fvalues); +} + + +static void GLAPIENTRY +save_PixelMapusv(GLenum map, GLint mapsize, const GLushort *values) +{ + GLfloat fvalues[MAX_PIXEL_MAP_TABLE]; + GLint i; + if (map == GL_PIXEL_MAP_I_TO_I || map == GL_PIXEL_MAP_S_TO_S) { + for (i = 0; i < mapsize; i++) { + fvalues[i] = (GLfloat) values[i]; + } + } + else { + for (i = 0; i < mapsize; i++) { + fvalues[i] = USHORT_TO_FLOAT(values[i]); + } + } + save_PixelMapfv(map, mapsize, fvalues); +} + + +static void GLAPIENTRY +save_PixelTransferf(GLenum pname, GLfloat param) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_PIXEL_TRANSFER, 2); + if (n) { + n[1].e = pname; + n[2].f = param; + } + if (ctx->ExecuteFlag) { + CALL_PixelTransferf(ctx->Exec, (pname, param)); + } +} + + +static void GLAPIENTRY +save_PixelTransferi(GLenum pname, GLint param) +{ + save_PixelTransferf(pname, (GLfloat) param); +} + + +static void GLAPIENTRY +save_PixelZoom(GLfloat xfactor, GLfloat yfactor) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_PIXEL_ZOOM, 2); + if (n) { + n[1].f = xfactor; + n[2].f = yfactor; + } + if (ctx->ExecuteFlag) { + CALL_PixelZoom(ctx->Exec, (xfactor, yfactor)); + } +} + + +static void GLAPIENTRY +save_PointParameterfvEXT(GLenum pname, const GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_POINT_PARAMETERS, 4); + if (n) { + n[1].e = pname; + n[2].f = params[0]; + n[3].f = params[1]; + n[4].f = params[2]; + } + if (ctx->ExecuteFlag) { + CALL_PointParameterfvEXT(ctx->Exec, (pname, params)); + } +} + + +static void GLAPIENTRY +save_PointParameterfEXT(GLenum pname, GLfloat param) +{ + GLfloat parray[3]; + parray[0] = param; + parray[1] = parray[2] = 0.0F; + save_PointParameterfvEXT(pname, parray); +} + +static void GLAPIENTRY +save_PointParameteriNV(GLenum pname, GLint param) +{ + GLfloat parray[3]; + parray[0] = (GLfloat) param; + parray[1] = parray[2] = 0.0F; + save_PointParameterfvEXT(pname, parray); +} + +static void GLAPIENTRY +save_PointParameterivNV(GLenum pname, const GLint * param) +{ + GLfloat parray[3]; + parray[0] = (GLfloat) param[0]; + parray[1] = parray[2] = 0.0F; + save_PointParameterfvEXT(pname, parray); +} + + +static void GLAPIENTRY +save_PointSize(GLfloat size) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_POINT_SIZE, 1); + if (n) { + n[1].f = size; + } + if (ctx->ExecuteFlag) { + CALL_PointSize(ctx->Exec, (size)); + } +} + + +static void GLAPIENTRY +save_PolygonMode(GLenum face, GLenum mode) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_POLYGON_MODE, 2); + if (n) { + n[1].e = face; + n[2].e = mode; + } + if (ctx->ExecuteFlag) { + CALL_PolygonMode(ctx->Exec, (face, mode)); + } +} + + +static void GLAPIENTRY +save_PolygonStipple(const GLubyte * pattern) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + + n = alloc_instruction(ctx, OPCODE_POLYGON_STIPPLE, 1); + if (n) { + n[1].data = unpack_image(ctx, 2, 32, 32, 1, GL_COLOR_INDEX, GL_BITMAP, + pattern, &ctx->Unpack); + } + if (ctx->ExecuteFlag) { + CALL_PolygonStipple(ctx->Exec, ((GLubyte *) pattern)); + } +} + + +static void GLAPIENTRY +save_PolygonOffset(GLfloat factor, GLfloat units) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_POLYGON_OFFSET, 2); + if (n) { + n[1].f = factor; + n[2].f = units; + } + if (ctx->ExecuteFlag) { + CALL_PolygonOffset(ctx->Exec, (factor, units)); + } +} + + +static void GLAPIENTRY +save_PolygonOffsetEXT(GLfloat factor, GLfloat bias) +{ + GET_CURRENT_CONTEXT(ctx); + /* XXX mult by DepthMaxF here??? */ + save_PolygonOffset(factor, ctx->DrawBuffer->_DepthMaxF * bias); +} + + +static void GLAPIENTRY +save_PopAttrib(void) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + (void) alloc_instruction(ctx, OPCODE_POP_ATTRIB, 0); + if (ctx->ExecuteFlag) { + CALL_PopAttrib(ctx->Exec, ()); + } +} + + +static void GLAPIENTRY +save_PopMatrix(void) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + (void) alloc_instruction(ctx, OPCODE_POP_MATRIX, 0); + if (ctx->ExecuteFlag) { + CALL_PopMatrix(ctx->Exec, ()); + } +} + + +static void GLAPIENTRY +save_PopName(void) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + (void) alloc_instruction(ctx, OPCODE_POP_NAME, 0); + if (ctx->ExecuteFlag) { + CALL_PopName(ctx->Exec, ()); + } +} + + +static void GLAPIENTRY +save_PrioritizeTextures(GLsizei num, const GLuint * textures, + const GLclampf * priorities) +{ + GET_CURRENT_CONTEXT(ctx); + GLint i; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + + for (i = 0; i < num; i++) { + Node *n; + n = alloc_instruction(ctx, OPCODE_PRIORITIZE_TEXTURE, 2); + if (n) { + n[1].ui = textures[i]; + n[2].f = priorities[i]; + } + } + if (ctx->ExecuteFlag) { + CALL_PrioritizeTextures(ctx->Exec, (num, textures, priorities)); + } +} + + +static void GLAPIENTRY +save_PushAttrib(GLbitfield mask) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_PUSH_ATTRIB, 1); + if (n) { + n[1].bf = mask; + } + if (ctx->ExecuteFlag) { + CALL_PushAttrib(ctx->Exec, (mask)); + } +} + + +static void GLAPIENTRY +save_PushMatrix(void) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + (void) alloc_instruction(ctx, OPCODE_PUSH_MATRIX, 0); + if (ctx->ExecuteFlag) { + CALL_PushMatrix(ctx->Exec, ()); + } +} + + +static void GLAPIENTRY +save_PushName(GLuint name) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_PUSH_NAME, 1); + if (n) { + n[1].ui = name; + } + if (ctx->ExecuteFlag) { + CALL_PushName(ctx->Exec, (name)); + } +} + + +static void GLAPIENTRY +save_RasterPos4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_RASTER_POS, 4); + if (n) { + n[1].f = x; + n[2].f = y; + n[3].f = z; + n[4].f = w; + } + if (ctx->ExecuteFlag) { + CALL_RasterPos4f(ctx->Exec, (x, y, z, w)); + } +} + +static void GLAPIENTRY +save_RasterPos2d(GLdouble x, GLdouble y) +{ + save_RasterPos4f((GLfloat) x, (GLfloat) y, 0.0F, 1.0F); +} + +static void GLAPIENTRY +save_RasterPos2f(GLfloat x, GLfloat y) +{ + save_RasterPos4f(x, y, 0.0F, 1.0F); +} + +static void GLAPIENTRY +save_RasterPos2i(GLint x, GLint y) +{ + save_RasterPos4f((GLfloat) x, (GLfloat) y, 0.0F, 1.0F); +} + +static void GLAPIENTRY +save_RasterPos2s(GLshort x, GLshort y) +{ + save_RasterPos4f(x, y, 0.0F, 1.0F); +} + +static void GLAPIENTRY +save_RasterPos3d(GLdouble x, GLdouble y, GLdouble z) +{ + save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F); +} + +static void GLAPIENTRY +save_RasterPos3f(GLfloat x, GLfloat y, GLfloat z) +{ + save_RasterPos4f(x, y, z, 1.0F); +} + +static void GLAPIENTRY +save_RasterPos3i(GLint x, GLint y, GLint z) +{ + save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F); +} + +static void GLAPIENTRY +save_RasterPos3s(GLshort x, GLshort y, GLshort z) +{ + save_RasterPos4f(x, y, z, 1.0F); +} + +static void GLAPIENTRY +save_RasterPos4d(GLdouble x, GLdouble y, GLdouble z, GLdouble w) +{ + save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w); +} + +static void GLAPIENTRY +save_RasterPos4i(GLint x, GLint y, GLint z, GLint w) +{ + save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w); +} + +static void GLAPIENTRY +save_RasterPos4s(GLshort x, GLshort y, GLshort z, GLshort w) +{ + save_RasterPos4f(x, y, z, w); +} + +static void GLAPIENTRY +save_RasterPos2dv(const GLdouble * v) +{ + save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F); +} + +static void GLAPIENTRY +save_RasterPos2fv(const GLfloat * v) +{ + save_RasterPos4f(v[0], v[1], 0.0F, 1.0F); +} + +static void GLAPIENTRY +save_RasterPos2iv(const GLint * v) +{ + save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F); +} + +static void GLAPIENTRY +save_RasterPos2sv(const GLshort * v) +{ + save_RasterPos4f(v[0], v[1], 0.0F, 1.0F); +} + +static void GLAPIENTRY +save_RasterPos3dv(const GLdouble * v) +{ + save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F); +} + +static void GLAPIENTRY +save_RasterPos3fv(const GLfloat * v) +{ + save_RasterPos4f(v[0], v[1], v[2], 1.0F); +} + +static void GLAPIENTRY +save_RasterPos3iv(const GLint * v) +{ + save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F); +} + +static void GLAPIENTRY +save_RasterPos3sv(const GLshort * v) +{ + save_RasterPos4f(v[0], v[1], v[2], 1.0F); +} + +static void GLAPIENTRY +save_RasterPos4dv(const GLdouble * v) +{ + save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], + (GLfloat) v[2], (GLfloat) v[3]); +} + +static void GLAPIENTRY +save_RasterPos4fv(const GLfloat * v) +{ + save_RasterPos4f(v[0], v[1], v[2], v[3]); +} + +static void GLAPIENTRY +save_RasterPos4iv(const GLint * v) +{ + save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], + (GLfloat) v[2], (GLfloat) v[3]); +} + +static void GLAPIENTRY +save_RasterPos4sv(const GLshort * v) +{ + save_RasterPos4f(v[0], v[1], v[2], v[3]); +} + + +static void GLAPIENTRY +save_PassThrough(GLfloat token) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_PASSTHROUGH, 1); + if (n) { + n[1].f = token; + } + if (ctx->ExecuteFlag) { + CALL_PassThrough(ctx->Exec, (token)); + } +} + + +static void GLAPIENTRY +save_ReadBuffer(GLenum mode) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_READ_BUFFER, 1); + if (n) { + n[1].e = mode; + } + if (ctx->ExecuteFlag) { + CALL_ReadBuffer(ctx->Exec, (mode)); + } +} + + +static void GLAPIENTRY +save_ResetHistogram(GLenum target) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_RESET_HISTOGRAM, 1); + if (n) { + n[1].e = target; + } + if (ctx->ExecuteFlag) { + CALL_ResetHistogram(ctx->Exec, (target)); + } +} + + +static void GLAPIENTRY +save_ResetMinmax(GLenum target) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_RESET_MIN_MAX, 1); + if (n) { + n[1].e = target; + } + if (ctx->ExecuteFlag) { + CALL_ResetMinmax(ctx->Exec, (target)); + } +} + + +static void GLAPIENTRY +save_Rotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_ROTATE, 4); + if (n) { + n[1].f = angle; + n[2].f = x; + n[3].f = y; + n[4].f = z; + } + if (ctx->ExecuteFlag) { + CALL_Rotatef(ctx->Exec, (angle, x, y, z)); + } +} + + +static void GLAPIENTRY +save_Rotated(GLdouble angle, GLdouble x, GLdouble y, GLdouble z) +{ + save_Rotatef((GLfloat) angle, (GLfloat) x, (GLfloat) y, (GLfloat) z); +} + + +static void GLAPIENTRY +save_Scalef(GLfloat x, GLfloat y, GLfloat z) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_SCALE, 3); + if (n) { + n[1].f = x; + n[2].f = y; + n[3].f = z; + } + if (ctx->ExecuteFlag) { + CALL_Scalef(ctx->Exec, (x, y, z)); + } +} + + +static void GLAPIENTRY +save_Scaled(GLdouble x, GLdouble y, GLdouble z) +{ + save_Scalef((GLfloat) x, (GLfloat) y, (GLfloat) z); +} + + +static void GLAPIENTRY +save_Scissor(GLint x, GLint y, GLsizei width, GLsizei height) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_SCISSOR, 4); + if (n) { + n[1].i = x; + n[2].i = y; + n[3].i = width; + n[4].i = height; + } + if (ctx->ExecuteFlag) { + CALL_Scissor(ctx->Exec, (x, y, width, height)); + } +} + + +static void GLAPIENTRY +save_ShadeModel(GLenum mode) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END(ctx); + + if (ctx->ExecuteFlag) { + CALL_ShadeModel(ctx->Exec, (mode)); + } + + if (ctx->ListState.Current.ShadeModel == mode) + return; + + SAVE_FLUSH_VERTICES(ctx); + + /* Only save the value if we know the statechange will take effect: + */ + if (ctx->Driver.CurrentSavePrimitive == PRIM_OUTSIDE_BEGIN_END) + ctx->ListState.Current.ShadeModel = mode; + + n = alloc_instruction(ctx, OPCODE_SHADE_MODEL, 1); + if (n) { + n[1].e = mode; + } +} + + +static void GLAPIENTRY +save_StencilFunc(GLenum func, GLint ref, GLuint mask) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_STENCIL_FUNC, 3); + if (n) { + n[1].e = func; + n[2].i = ref; + n[3].ui = mask; + } + if (ctx->ExecuteFlag) { + CALL_StencilFunc(ctx->Exec, (func, ref, mask)); + } +} + + +static void GLAPIENTRY +save_StencilMask(GLuint mask) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_STENCIL_MASK, 1); + if (n) { + n[1].ui = mask; + } + if (ctx->ExecuteFlag) { + CALL_StencilMask(ctx->Exec, (mask)); + } +} + + +static void GLAPIENTRY +save_StencilOp(GLenum fail, GLenum zfail, GLenum zpass) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_STENCIL_OP, 3); + if (n) { + n[1].e = fail; + n[2].e = zfail; + n[3].e = zpass; + } + if (ctx->ExecuteFlag) { + CALL_StencilOp(ctx->Exec, (fail, zfail, zpass)); + } +} + + +static void GLAPIENTRY +save_StencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_STENCIL_FUNC_SEPARATE, 4); + if (n) { + n[1].e = face; + n[2].e = func; + n[3].i = ref; + n[4].ui = mask; + } + if (ctx->ExecuteFlag) { + CALL_StencilFuncSeparate(ctx->Exec, (face, func, ref, mask)); + } +} + + +static void GLAPIENTRY +save_StencilFuncSeparateATI(GLenum frontfunc, GLenum backfunc, GLint ref, + GLuint mask) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + /* GL_FRONT */ + n = alloc_instruction(ctx, OPCODE_STENCIL_FUNC_SEPARATE, 4); + if (n) { + n[1].e = GL_FRONT; + n[2].e = frontfunc; + n[3].i = ref; + n[4].ui = mask; + } + /* GL_BACK */ + n = alloc_instruction(ctx, OPCODE_STENCIL_FUNC_SEPARATE, 4); + if (n) { + n[1].e = GL_BACK; + n[2].e = backfunc; + n[3].i = ref; + n[4].ui = mask; + } + if (ctx->ExecuteFlag) { + CALL_StencilFuncSeparate(ctx->Exec, (GL_FRONT, frontfunc, ref, mask)); + CALL_StencilFuncSeparate(ctx->Exec, (GL_BACK, backfunc, ref, mask)); + } +} + + +static void GLAPIENTRY +save_StencilMaskSeparate(GLenum face, GLuint mask) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_STENCIL_MASK_SEPARATE, 2); + if (n) { + n[1].e = face; + n[2].ui = mask; + } + if (ctx->ExecuteFlag) { + CALL_StencilMaskSeparate(ctx->Exec, (face, mask)); + } +} + + +static void GLAPIENTRY +save_StencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_STENCIL_OP_SEPARATE, 4); + if (n) { + n[1].e = face; + n[2].e = fail; + n[3].e = zfail; + n[4].e = zpass; + } + if (ctx->ExecuteFlag) { + CALL_StencilOpSeparate(ctx->Exec, (face, fail, zfail, zpass)); + } +} + + +static void GLAPIENTRY +save_TexEnvfv(GLenum target, GLenum pname, const GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_TEXENV, 6); + if (n) { + n[1].e = target; + n[2].e = pname; + if (pname == GL_TEXTURE_ENV_COLOR) { + n[3].f = params[0]; + n[4].f = params[1]; + n[5].f = params[2]; + n[6].f = params[3]; + } + else { + n[3].f = params[0]; + n[4].f = n[5].f = n[6].f = 0.0F; + } + } + if (ctx->ExecuteFlag) { + CALL_TexEnvfv(ctx->Exec, (target, pname, params)); + } +} + + +static void GLAPIENTRY +save_TexEnvf(GLenum target, GLenum pname, GLfloat param) +{ + GLfloat parray[4]; + parray[0] = (GLfloat) param; + parray[1] = parray[2] = parray[3] = 0.0F; + save_TexEnvfv(target, pname, parray); +} + + +static void GLAPIENTRY +save_TexEnvi(GLenum target, GLenum pname, GLint param) +{ + GLfloat p[4]; + p[0] = (GLfloat) param; + p[1] = p[2] = p[3] = 0.0F; + save_TexEnvfv(target, pname, p); +} + + +static void GLAPIENTRY +save_TexEnviv(GLenum target, GLenum pname, const GLint * param) +{ + GLfloat p[4]; + if (pname == GL_TEXTURE_ENV_COLOR) { + p[0] = INT_TO_FLOAT(param[0]); + p[1] = INT_TO_FLOAT(param[1]); + p[2] = INT_TO_FLOAT(param[2]); + p[3] = INT_TO_FLOAT(param[3]); + } + else { + p[0] = (GLfloat) param[0]; + p[1] = p[2] = p[3] = 0.0F; + } + save_TexEnvfv(target, pname, p); +} + + +static void GLAPIENTRY +save_TexGenfv(GLenum coord, GLenum pname, const GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_TEXGEN, 6); + if (n) { + n[1].e = coord; + n[2].e = pname; + n[3].f = params[0]; + n[4].f = params[1]; + n[5].f = params[2]; + n[6].f = params[3]; + } + if (ctx->ExecuteFlag) { + CALL_TexGenfv(ctx->Exec, (coord, pname, params)); + } +} + + +static void GLAPIENTRY +save_TexGeniv(GLenum coord, GLenum pname, const GLint *params) +{ + GLfloat p[4]; + p[0] = (GLfloat) params[0]; + p[1] = (GLfloat) params[1]; + p[2] = (GLfloat) params[2]; + p[3] = (GLfloat) params[3]; + save_TexGenfv(coord, pname, p); +} + + +static void GLAPIENTRY +save_TexGend(GLenum coord, GLenum pname, GLdouble param) +{ + GLfloat parray[4]; + parray[0] = (GLfloat) param; + parray[1] = parray[2] = parray[3] = 0.0F; + save_TexGenfv(coord, pname, parray); +} + + +static void GLAPIENTRY +save_TexGendv(GLenum coord, GLenum pname, const GLdouble *params) +{ + GLfloat p[4]; + p[0] = (GLfloat) params[0]; + p[1] = (GLfloat) params[1]; + p[2] = (GLfloat) params[2]; + p[3] = (GLfloat) params[3]; + save_TexGenfv(coord, pname, p); +} + + +static void GLAPIENTRY +save_TexGenf(GLenum coord, GLenum pname, GLfloat param) +{ + GLfloat parray[4]; + parray[0] = param; + parray[1] = parray[2] = parray[3] = 0.0F; + save_TexGenfv(coord, pname, parray); +} + + +static void GLAPIENTRY +save_TexGeni(GLenum coord, GLenum pname, GLint param) +{ + GLint parray[4]; + parray[0] = param; + parray[1] = parray[2] = parray[3] = 0; + save_TexGeniv(coord, pname, parray); +} + + +static void GLAPIENTRY +save_TexParameterfv(GLenum target, GLenum pname, const GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_TEXPARAMETER, 6); + if (n) { + n[1].e = target; + n[2].e = pname; + n[3].f = params[0]; + n[4].f = params[1]; + n[5].f = params[2]; + n[6].f = params[3]; + } + if (ctx->ExecuteFlag) { + CALL_TexParameterfv(ctx->Exec, (target, pname, params)); + } +} + + +static void GLAPIENTRY +save_TexParameterf(GLenum target, GLenum pname, GLfloat param) +{ + GLfloat parray[4]; + parray[0] = param; + parray[1] = parray[2] = parray[3] = 0.0F; + save_TexParameterfv(target, pname, parray); +} + + +static void GLAPIENTRY +save_TexParameteri(GLenum target, GLenum pname, GLint param) +{ + GLfloat fparam[4]; + fparam[0] = (GLfloat) param; + fparam[1] = fparam[2] = fparam[3] = 0.0F; + save_TexParameterfv(target, pname, fparam); +} + + +static void GLAPIENTRY +save_TexParameteriv(GLenum target, GLenum pname, const GLint *params) +{ + GLfloat fparam[4]; + fparam[0] = (GLfloat) params[0]; + fparam[1] = fparam[2] = fparam[3] = 0.0F; + save_TexParameterfv(target, pname, fparam); +} + + +static void GLAPIENTRY +save_TexImage1D(GLenum target, + GLint level, GLint components, + GLsizei width, GLint border, + GLenum format, GLenum type, const GLvoid * pixels) +{ + GET_CURRENT_CONTEXT(ctx); + if (target == GL_PROXY_TEXTURE_1D) { + /* don't compile, execute immediately */ + CALL_TexImage1D(ctx->Exec, (target, level, components, width, + border, format, type, pixels)); + } + else { + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_TEX_IMAGE1D, 8); + if (n) { + n[1].e = target; + n[2].i = level; + n[3].i = components; + n[4].i = (GLint) width; + n[5].i = border; + n[6].e = format; + n[7].e = type; + n[8].data = unpack_image(ctx, 1, width, 1, 1, format, type, + pixels, &ctx->Unpack); + } + if (ctx->ExecuteFlag) { + CALL_TexImage1D(ctx->Exec, (target, level, components, width, + border, format, type, pixels)); + } + } +} + + +static void GLAPIENTRY +save_TexImage2D(GLenum target, + GLint level, GLint components, + GLsizei width, GLsizei height, GLint border, + GLenum format, GLenum type, const GLvoid * pixels) +{ + GET_CURRENT_CONTEXT(ctx); + if (target == GL_PROXY_TEXTURE_2D) { + /* don't compile, execute immediately */ + CALL_TexImage2D(ctx->Exec, (target, level, components, width, + height, border, format, type, pixels)); + } + else { + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_TEX_IMAGE2D, 9); + if (n) { + n[1].e = target; + n[2].i = level; + n[3].i = components; + n[4].i = (GLint) width; + n[5].i = (GLint) height; + n[6].i = border; + n[7].e = format; + n[8].e = type; + n[9].data = unpack_image(ctx, 2, width, height, 1, format, type, + pixels, &ctx->Unpack); + } + if (ctx->ExecuteFlag) { + CALL_TexImage2D(ctx->Exec, (target, level, components, width, + height, border, format, type, pixels)); + } + } +} + + +static void GLAPIENTRY +save_TexImage3D(GLenum target, + GLint level, GLint internalFormat, + GLsizei width, GLsizei height, GLsizei depth, + GLint border, + GLenum format, GLenum type, const GLvoid * pixels) +{ + GET_CURRENT_CONTEXT(ctx); + if (target == GL_PROXY_TEXTURE_3D) { + /* don't compile, execute immediately */ + CALL_TexImage3D(ctx->Exec, (target, level, internalFormat, width, + height, depth, border, format, type, + pixels)); + } + else { + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_TEX_IMAGE3D, 10); + if (n) { + n[1].e = target; + n[2].i = level; + n[3].i = (GLint) internalFormat; + n[4].i = (GLint) width; + n[5].i = (GLint) height; + n[6].i = (GLint) depth; + n[7].i = border; + n[8].e = format; + n[9].e = type; + n[10].data = unpack_image(ctx, 3, width, height, depth, format, type, + pixels, &ctx->Unpack); + } + if (ctx->ExecuteFlag) { + CALL_TexImage3D(ctx->Exec, (target, level, internalFormat, width, + height, depth, border, format, type, + pixels)); + } + } +} + + +static void GLAPIENTRY +save_TexSubImage1D(GLenum target, GLint level, GLint xoffset, + GLsizei width, GLenum format, GLenum type, + const GLvoid * pixels) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + + n = alloc_instruction(ctx, OPCODE_TEX_SUB_IMAGE1D, 7); + if (n) { + n[1].e = target; + n[2].i = level; + n[3].i = xoffset; + n[4].i = (GLint) width; + n[5].e = format; + n[6].e = type; + n[7].data = unpack_image(ctx, 1, width, 1, 1, format, type, + pixels, &ctx->Unpack); + } + if (ctx->ExecuteFlag) { + CALL_TexSubImage1D(ctx->Exec, (target, level, xoffset, width, + format, type, pixels)); + } +} + + +static void GLAPIENTRY +save_TexSubImage2D(GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLsizei width, GLsizei height, + GLenum format, GLenum type, const GLvoid * pixels) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + + n = alloc_instruction(ctx, OPCODE_TEX_SUB_IMAGE2D, 9); + if (n) { + n[1].e = target; + n[2].i = level; + n[3].i = xoffset; + n[4].i = yoffset; + n[5].i = (GLint) width; + n[6].i = (GLint) height; + n[7].e = format; + n[8].e = type; + n[9].data = unpack_image(ctx, 2, width, height, 1, format, type, + pixels, &ctx->Unpack); + } + if (ctx->ExecuteFlag) { + CALL_TexSubImage2D(ctx->Exec, (target, level, xoffset, yoffset, + width, height, format, type, pixels)); + } +} + + +static void GLAPIENTRY +save_TexSubImage3D(GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLsizei width, GLsizei height, GLsizei depth, + GLenum format, GLenum type, const GLvoid * pixels) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + + n = alloc_instruction(ctx, OPCODE_TEX_SUB_IMAGE3D, 11); + if (n) { + n[1].e = target; + n[2].i = level; + n[3].i = xoffset; + n[4].i = yoffset; + n[5].i = zoffset; + n[6].i = (GLint) width; + n[7].i = (GLint) height; + n[8].i = (GLint) depth; + n[9].e = format; + n[10].e = type; + n[11].data = unpack_image(ctx, 3, width, height, depth, format, type, + pixels, &ctx->Unpack); + } + if (ctx->ExecuteFlag) { + CALL_TexSubImage3D(ctx->Exec, (target, level, + xoffset, yoffset, zoffset, + width, height, depth, format, type, + pixels)); + } +} + + +static void GLAPIENTRY +save_Translatef(GLfloat x, GLfloat y, GLfloat z) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_TRANSLATE, 3); + if (n) { + n[1].f = x; + n[2].f = y; + n[3].f = z; + } + if (ctx->ExecuteFlag) { + CALL_Translatef(ctx->Exec, (x, y, z)); + } +} + + +static void GLAPIENTRY +save_Translated(GLdouble x, GLdouble y, GLdouble z) +{ + save_Translatef((GLfloat) x, (GLfloat) y, (GLfloat) z); +} + + + +static void GLAPIENTRY +save_Viewport(GLint x, GLint y, GLsizei width, GLsizei height) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_VIEWPORT, 4); + if (n) { + n[1].i = x; + n[2].i = y; + n[3].i = (GLint) width; + n[4].i = (GLint) height; + } + if (ctx->ExecuteFlag) { + CALL_Viewport(ctx->Exec, (x, y, width, height)); + } +} + + +static void GLAPIENTRY +save_WindowPos4fMESA(GLfloat x, GLfloat y, GLfloat z, GLfloat w) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_WINDOW_POS, 4); + if (n) { + n[1].f = x; + n[2].f = y; + n[3].f = z; + n[4].f = w; + } + if (ctx->ExecuteFlag) { + CALL_WindowPos4fMESA(ctx->Exec, (x, y, z, w)); + } +} + +static void GLAPIENTRY +save_WindowPos2dMESA(GLdouble x, GLdouble y) +{ + save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, 0.0F, 1.0F); +} + +static void GLAPIENTRY +save_WindowPos2fMESA(GLfloat x, GLfloat y) +{ + save_WindowPos4fMESA(x, y, 0.0F, 1.0F); +} + +static void GLAPIENTRY +save_WindowPos2iMESA(GLint x, GLint y) +{ + save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, 0.0F, 1.0F); +} + +static void GLAPIENTRY +save_WindowPos2sMESA(GLshort x, GLshort y) +{ + save_WindowPos4fMESA(x, y, 0.0F, 1.0F); +} + +static void GLAPIENTRY +save_WindowPos3dMESA(GLdouble x, GLdouble y, GLdouble z) +{ + save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F); +} + +static void GLAPIENTRY +save_WindowPos3fMESA(GLfloat x, GLfloat y, GLfloat z) +{ + save_WindowPos4fMESA(x, y, z, 1.0F); +} + +static void GLAPIENTRY +save_WindowPos3iMESA(GLint x, GLint y, GLint z) +{ + save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F); +} + +static void GLAPIENTRY +save_WindowPos3sMESA(GLshort x, GLshort y, GLshort z) +{ + save_WindowPos4fMESA(x, y, z, 1.0F); +} + +static void GLAPIENTRY +save_WindowPos4dMESA(GLdouble x, GLdouble y, GLdouble z, GLdouble w) +{ + save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w); +} + +static void GLAPIENTRY +save_WindowPos4iMESA(GLint x, GLint y, GLint z, GLint w) +{ + save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w); +} + +static void GLAPIENTRY +save_WindowPos4sMESA(GLshort x, GLshort y, GLshort z, GLshort w) +{ + save_WindowPos4fMESA(x, y, z, w); +} + +static void GLAPIENTRY +save_WindowPos2dvMESA(const GLdouble * v) +{ + save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F); +} + +static void GLAPIENTRY +save_WindowPos2fvMESA(const GLfloat * v) +{ + save_WindowPos4fMESA(v[0], v[1], 0.0F, 1.0F); +} + +static void GLAPIENTRY +save_WindowPos2ivMESA(const GLint * v) +{ + save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F); +} + +static void GLAPIENTRY +save_WindowPos2svMESA(const GLshort * v) +{ + save_WindowPos4fMESA(v[0], v[1], 0.0F, 1.0F); +} + +static void GLAPIENTRY +save_WindowPos3dvMESA(const GLdouble * v) +{ + save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F); +} + +static void GLAPIENTRY +save_WindowPos3fvMESA(const GLfloat * v) +{ + save_WindowPos4fMESA(v[0], v[1], v[2], 1.0F); +} + +static void GLAPIENTRY +save_WindowPos3ivMESA(const GLint * v) +{ + save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F); +} + +static void GLAPIENTRY +save_WindowPos3svMESA(const GLshort * v) +{ + save_WindowPos4fMESA(v[0], v[1], v[2], 1.0F); +} + +static void GLAPIENTRY +save_WindowPos4dvMESA(const GLdouble * v) +{ + save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], + (GLfloat) v[2], (GLfloat) v[3]); +} + +static void GLAPIENTRY +save_WindowPos4fvMESA(const GLfloat * v) +{ + save_WindowPos4fMESA(v[0], v[1], v[2], v[3]); +} + +static void GLAPIENTRY +save_WindowPos4ivMESA(const GLint * v) +{ + save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], + (GLfloat) v[2], (GLfloat) v[3]); +} + +static void GLAPIENTRY +save_WindowPos4svMESA(const GLshort * v) +{ + save_WindowPos4fMESA(v[0], v[1], v[2], v[3]); +} + + + +/* GL_ARB_multitexture */ +static void GLAPIENTRY +save_ActiveTextureARB(GLenum target) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_ACTIVE_TEXTURE, 1); + if (n) { + n[1].e = target; + } + if (ctx->ExecuteFlag) { + CALL_ActiveTextureARB(ctx->Exec, (target)); + } +} + + +/* GL_ARB_transpose_matrix */ + +static void GLAPIENTRY +save_LoadTransposeMatrixdARB(const GLdouble m[16]) +{ + GLfloat tm[16]; + _math_transposefd(tm, m); + save_LoadMatrixf(tm); +} + + +static void GLAPIENTRY +save_LoadTransposeMatrixfARB(const GLfloat m[16]) +{ + GLfloat tm[16]; + _math_transposef(tm, m); + save_LoadMatrixf(tm); +} + + +static void GLAPIENTRY +save_MultTransposeMatrixdARB(const GLdouble m[16]) +{ + GLfloat tm[16]; + _math_transposefd(tm, m); + save_MultMatrixf(tm); +} + + +static void GLAPIENTRY +save_MultTransposeMatrixfARB(const GLfloat m[16]) +{ + GLfloat tm[16]; + _math_transposef(tm, m); + save_MultMatrixf(tm); +} + + +/* GL_ARB_texture_compression */ +static void GLAPIENTRY +save_CompressedTexImage1DARB(GLenum target, GLint level, + GLenum internalFormat, GLsizei width, + GLint border, GLsizei imageSize, + const GLvoid * data) +{ + GET_CURRENT_CONTEXT(ctx); + if (target == GL_PROXY_TEXTURE_1D) { + /* don't compile, execute immediately */ + CALL_CompressedTexImage1DARB(ctx->Exec, (target, level, internalFormat, + width, border, imageSize, + data)); + } + else { + Node *n; + GLvoid *image; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + /* make copy of image */ + image = malloc(imageSize); + if (!image) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage1DARB"); + return; + } + memcpy(image, data, imageSize); + n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_IMAGE_1D, 7); + if (n) { + n[1].e = target; + n[2].i = level; + n[3].e = internalFormat; + n[4].i = (GLint) width; + n[5].i = border; + n[6].i = imageSize; + n[7].data = image; + } + else if (image) { + free(image); + } + if (ctx->ExecuteFlag) { + CALL_CompressedTexImage1DARB(ctx->Exec, + (target, level, internalFormat, width, + border, imageSize, data)); + } + } +} + + +static void GLAPIENTRY +save_CompressedTexImage2DARB(GLenum target, GLint level, + GLenum internalFormat, GLsizei width, + GLsizei height, GLint border, GLsizei imageSize, + const GLvoid * data) +{ + GET_CURRENT_CONTEXT(ctx); + if (target == GL_PROXY_TEXTURE_2D) { + /* don't compile, execute immediately */ + CALL_CompressedTexImage2DARB(ctx->Exec, (target, level, internalFormat, + width, height, border, + imageSize, data)); + } + else { + Node *n; + GLvoid *image; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + /* make copy of image */ + image = malloc(imageSize); + if (!image) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2DARB"); + return; + } + memcpy(image, data, imageSize); + n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_IMAGE_2D, 8); + if (n) { + n[1].e = target; + n[2].i = level; + n[3].e = internalFormat; + n[4].i = (GLint) width; + n[5].i = (GLint) height; + n[6].i = border; + n[7].i = imageSize; + n[8].data = image; + } + else if (image) { + free(image); + } + if (ctx->ExecuteFlag) { + CALL_CompressedTexImage2DARB(ctx->Exec, + (target, level, internalFormat, width, + height, border, imageSize, data)); + } + } +} + + +static void GLAPIENTRY +save_CompressedTexImage3DARB(GLenum target, GLint level, + GLenum internalFormat, GLsizei width, + GLsizei height, GLsizei depth, GLint border, + GLsizei imageSize, const GLvoid * data) +{ + GET_CURRENT_CONTEXT(ctx); + if (target == GL_PROXY_TEXTURE_3D) { + /* don't compile, execute immediately */ + CALL_CompressedTexImage3DARB(ctx->Exec, (target, level, internalFormat, + width, height, depth, border, + imageSize, data)); + } + else { + Node *n; + GLvoid *image; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + /* make copy of image */ + image = malloc(imageSize); + if (!image) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage3DARB"); + return; + } + memcpy(image, data, imageSize); + n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_IMAGE_3D, 9); + if (n) { + n[1].e = target; + n[2].i = level; + n[3].e = internalFormat; + n[4].i = (GLint) width; + n[5].i = (GLint) height; + n[6].i = (GLint) depth; + n[7].i = border; + n[8].i = imageSize; + n[9].data = image; + } + else if (image) { + free(image); + } + if (ctx->ExecuteFlag) { + CALL_CompressedTexImage3DARB(ctx->Exec, + (target, level, internalFormat, width, + height, depth, border, imageSize, + data)); + } + } +} + + +static void GLAPIENTRY +save_CompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset, + GLsizei width, GLenum format, + GLsizei imageSize, const GLvoid * data) +{ + Node *n; + GLvoid *image; + + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + + /* make copy of image */ + image = malloc(imageSize); + if (!image) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage1DARB"); + return; + } + memcpy(image, data, imageSize); + n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D, 7); + if (n) { + n[1].e = target; + n[2].i = level; + n[3].i = xoffset; + n[4].i = (GLint) width; + n[5].e = format; + n[6].i = imageSize; + n[7].data = image; + } + else if (image) { + free(image); + } + if (ctx->ExecuteFlag) { + CALL_CompressedTexSubImage1DARB(ctx->Exec, (target, level, xoffset, + width, format, imageSize, + data)); + } +} + + +static void GLAPIENTRY +save_CompressedTexSubImage2DARB(GLenum target, GLint level, GLint xoffset, + GLint yoffset, GLsizei width, GLsizei height, + GLenum format, GLsizei imageSize, + const GLvoid * data) +{ + Node *n; + GLvoid *image; + + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + + /* make copy of image */ + image = malloc(imageSize); + if (!image) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage2DARB"); + return; + } + memcpy(image, data, imageSize); + n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D, 9); + if (n) { + n[1].e = target; + n[2].i = level; + n[3].i = xoffset; + n[4].i = yoffset; + n[5].i = (GLint) width; + n[6].i = (GLint) height; + n[7].e = format; + n[8].i = imageSize; + n[9].data = image; + } + else if (image) { + free(image); + } + if (ctx->ExecuteFlag) { + CALL_CompressedTexSubImage2DARB(ctx->Exec, + (target, level, xoffset, yoffset, width, + height, format, imageSize, data)); + } +} + + +static void GLAPIENTRY +save_CompressedTexSubImage3DARB(GLenum target, GLint level, GLint xoffset, + GLint yoffset, GLint zoffset, GLsizei width, + GLsizei height, GLsizei depth, GLenum format, + GLsizei imageSize, const GLvoid * data) +{ + Node *n; + GLvoid *image; + + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + + /* make copy of image */ + image = malloc(imageSize); + if (!image) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage3DARB"); + return; + } + memcpy(image, data, imageSize); + n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D, 11); + if (n) { + n[1].e = target; + n[2].i = level; + n[3].i = xoffset; + n[4].i = yoffset; + n[5].i = zoffset; + n[6].i = (GLint) width; + n[7].i = (GLint) height; + n[8].i = (GLint) depth; + n[9].e = format; + n[10].i = imageSize; + n[11].data = image; + } + else if (image) { + free(image); + } + if (ctx->ExecuteFlag) { + CALL_CompressedTexSubImage3DARB(ctx->Exec, + (target, level, xoffset, yoffset, + zoffset, width, height, depth, format, + imageSize, data)); + } +} + + +/* GL_ARB_multisample */ +static void GLAPIENTRY +save_SampleCoverageARB(GLclampf value, GLboolean invert) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_SAMPLE_COVERAGE, 2); + if (n) { + n[1].f = value; + n[2].b = invert; + } + if (ctx->ExecuteFlag) { + CALL_SampleCoverageARB(ctx->Exec, (value, invert)); + } +} + + +/* + * GL_NV_vertex_program + */ +#if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program +static void GLAPIENTRY +save_BindProgramNV(GLenum target, GLuint id) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_BIND_PROGRAM_NV, 2); + if (n) { + n[1].e = target; + n[2].ui = id; + } + if (ctx->ExecuteFlag) { + CALL_BindProgramNV(ctx->Exec, (target, id)); + } +} + +static void GLAPIENTRY +save_ProgramEnvParameter4fARB(GLenum target, GLuint index, + GLfloat x, GLfloat y, GLfloat z, GLfloat w) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_PROGRAM_ENV_PARAMETER_ARB, 6); + if (n) { + n[1].e = target; + n[2].ui = index; + n[3].f = x; + n[4].f = y; + n[5].f = z; + n[6].f = w; + } + if (ctx->ExecuteFlag) { + CALL_ProgramEnvParameter4fARB(ctx->Exec, (target, index, x, y, z, w)); + } +} + + +static void GLAPIENTRY +save_ProgramEnvParameter4fvARB(GLenum target, GLuint index, + const GLfloat *params) +{ + save_ProgramEnvParameter4fARB(target, index, params[0], params[1], + params[2], params[3]); +} + + +static void GLAPIENTRY +save_ProgramEnvParameters4fvEXT(GLenum target, GLuint index, GLsizei count, + const GLfloat * params) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + + if (count > 0) { + GLint i; + const GLfloat * p = params; + + for (i = 0 ; i < count ; i++) { + n = alloc_instruction(ctx, OPCODE_PROGRAM_ENV_PARAMETER_ARB, 6); + if (n) { + n[1].e = target; + n[2].ui = index; + n[3].f = p[0]; + n[4].f = p[1]; + n[5].f = p[2]; + n[6].f = p[3]; + p += 4; + } + } + } + + if (ctx->ExecuteFlag) { + CALL_ProgramEnvParameters4fvEXT(ctx->Exec, (target, index, count, params)); + } +} + + +static void GLAPIENTRY +save_ProgramEnvParameter4dARB(GLenum target, GLuint index, + GLdouble x, GLdouble y, GLdouble z, GLdouble w) +{ + save_ProgramEnvParameter4fARB(target, index, + (GLfloat) x, + (GLfloat) y, (GLfloat) z, (GLfloat) w); +} + + +static void GLAPIENTRY +save_ProgramEnvParameter4dvARB(GLenum target, GLuint index, + const GLdouble *params) +{ + save_ProgramEnvParameter4fARB(target, index, + (GLfloat) params[0], + (GLfloat) params[1], + (GLfloat) params[2], (GLfloat) params[3]); +} + +#endif /* FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program || FEATURE_NV_vertex_program */ + +#if FEATURE_NV_vertex_program +static void GLAPIENTRY +save_ExecuteProgramNV(GLenum target, GLuint id, const GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_EXECUTE_PROGRAM_NV, 6); + if (n) { + n[1].e = target; + n[2].ui = id; + n[3].f = params[0]; + n[4].f = params[1]; + n[5].f = params[2]; + n[6].f = params[3]; + } + if (ctx->ExecuteFlag) { + CALL_ExecuteProgramNV(ctx->Exec, (target, id, params)); + } +} + + +static void GLAPIENTRY +save_ProgramParameters4dvNV(GLenum target, GLuint index, + GLsizei num, const GLdouble *params) +{ + GLint i; + for (i = 0; i < num; i++) { + save_ProgramEnvParameter4dvARB(target, index + i, params + 4 * i); + } +} + + +static void GLAPIENTRY +save_ProgramParameters4fvNV(GLenum target, GLuint index, + GLsizei num, const GLfloat *params) +{ + GLint i; + for (i = 0; i < num; i++) { + save_ProgramEnvParameter4fvARB(target, index + i, params + 4 * i); + } +} + + +static void GLAPIENTRY +save_LoadProgramNV(GLenum target, GLuint id, GLsizei len, + const GLubyte * program) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + + n = alloc_instruction(ctx, OPCODE_LOAD_PROGRAM_NV, 4); + if (n) { + GLubyte *programCopy = (GLubyte *) malloc(len); + if (!programCopy) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glLoadProgramNV"); + return; + } + memcpy(programCopy, program, len); + n[1].e = target; + n[2].ui = id; + n[3].i = len; + n[4].data = programCopy; + } + if (ctx->ExecuteFlag) { + CALL_LoadProgramNV(ctx->Exec, (target, id, len, program)); + } +} + + +static void GLAPIENTRY +save_RequestResidentProgramsNV(GLsizei num, const GLuint * ids) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + + n = alloc_instruction(ctx, OPCODE_TRACK_MATRIX_NV, 2); + if (n) { + GLuint *idCopy = (GLuint *) malloc(num * sizeof(GLuint)); + if (!idCopy) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glRequestResidentProgramsNV"); + return; + } + memcpy(idCopy, ids, num * sizeof(GLuint)); + n[1].i = num; + n[2].data = idCopy; + } + if (ctx->ExecuteFlag) { + CALL_RequestResidentProgramsNV(ctx->Exec, (num, ids)); + } +} + + +static void GLAPIENTRY +save_TrackMatrixNV(GLenum target, GLuint address, + GLenum matrix, GLenum transform) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_TRACK_MATRIX_NV, 4); + if (n) { + n[1].e = target; + n[2].ui = address; + n[3].e = matrix; + n[4].e = transform; + } + if (ctx->ExecuteFlag) { + CALL_TrackMatrixNV(ctx->Exec, (target, address, matrix, transform)); + } +} +#endif /* FEATURE_NV_vertex_program */ + + +/* + * GL_NV_fragment_program + */ +#if FEATURE_NV_fragment_program +static void GLAPIENTRY +save_ProgramLocalParameter4fARB(GLenum target, GLuint index, + GLfloat x, GLfloat y, GLfloat z, GLfloat w) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6); + if (n) { + n[1].e = target; + n[2].ui = index; + n[3].f = x; + n[4].f = y; + n[5].f = z; + n[6].f = w; + } + if (ctx->ExecuteFlag) { + CALL_ProgramLocalParameter4fARB(ctx->Exec, (target, index, x, y, z, w)); + } +} + + +static void GLAPIENTRY +save_ProgramLocalParameter4fvARB(GLenum target, GLuint index, + const GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6); + if (n) { + n[1].e = target; + n[2].ui = index; + n[3].f = params[0]; + n[4].f = params[1]; + n[5].f = params[2]; + n[6].f = params[3]; + } + if (ctx->ExecuteFlag) { + CALL_ProgramLocalParameter4fvARB(ctx->Exec, (target, index, params)); + } +} + + +static void GLAPIENTRY +save_ProgramLocalParameters4fvEXT(GLenum target, GLuint index, GLsizei count, + const GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + + if (count > 0) { + GLint i; + const GLfloat * p = params; + + for (i = 0 ; i < count ; i++) { + n = alloc_instruction(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6); + if (n) { + n[1].e = target; + n[2].ui = index; + n[3].f = p[0]; + n[4].f = p[1]; + n[5].f = p[2]; + n[6].f = p[3]; + p += 4; + } + } + } + + if (ctx->ExecuteFlag) { + CALL_ProgramLocalParameters4fvEXT(ctx->Exec, (target, index, count, params)); + } +} + + +static void GLAPIENTRY +save_ProgramLocalParameter4dARB(GLenum target, GLuint index, + GLdouble x, GLdouble y, + GLdouble z, GLdouble w) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6); + if (n) { + n[1].e = target; + n[2].ui = index; + n[3].f = (GLfloat) x; + n[4].f = (GLfloat) y; + n[5].f = (GLfloat) z; + n[6].f = (GLfloat) w; + } + if (ctx->ExecuteFlag) { + CALL_ProgramLocalParameter4dARB(ctx->Exec, (target, index, x, y, z, w)); + } +} + + +static void GLAPIENTRY +save_ProgramLocalParameter4dvARB(GLenum target, GLuint index, + const GLdouble *params) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6); + if (n) { + n[1].e = target; + n[2].ui = index; + n[3].f = (GLfloat) params[0]; + n[4].f = (GLfloat) params[1]; + n[5].f = (GLfloat) params[2]; + n[6].f = (GLfloat) params[3]; + } + if (ctx->ExecuteFlag) { + CALL_ProgramLocalParameter4dvARB(ctx->Exec, (target, index, params)); + } +} + +static void GLAPIENTRY +save_ProgramNamedParameter4fNV(GLuint id, GLsizei len, const GLubyte * name, + GLfloat x, GLfloat y, GLfloat z, GLfloat w) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + + n = alloc_instruction(ctx, OPCODE_PROGRAM_NAMED_PARAMETER_NV, 6); + if (n) { + GLubyte *nameCopy = (GLubyte *) malloc(len); + if (!nameCopy) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glProgramNamedParameter4fNV"); + return; + } + memcpy(nameCopy, name, len); + n[1].ui = id; + n[2].i = len; + n[3].data = nameCopy; + n[4].f = x; + n[5].f = y; + n[6].f = z; + n[7].f = w; + } + if (ctx->ExecuteFlag) { + CALL_ProgramNamedParameter4fNV(ctx->Exec, (id, len, name, x, y, z, w)); + } +} + + +static void GLAPIENTRY +save_ProgramNamedParameter4fvNV(GLuint id, GLsizei len, const GLubyte * name, + const float v[]) +{ + save_ProgramNamedParameter4fNV(id, len, name, v[0], v[1], v[2], v[3]); +} + + +static void GLAPIENTRY +save_ProgramNamedParameter4dNV(GLuint id, GLsizei len, const GLubyte * name, + GLdouble x, GLdouble y, GLdouble z, GLdouble w) +{ + save_ProgramNamedParameter4fNV(id, len, name, (GLfloat) x, (GLfloat) y, + (GLfloat) z, (GLfloat) w); +} + + +static void GLAPIENTRY +save_ProgramNamedParameter4dvNV(GLuint id, GLsizei len, const GLubyte * name, + const double v[]) +{ + save_ProgramNamedParameter4fNV(id, len, name, (GLfloat) v[0], + (GLfloat) v[1], (GLfloat) v[2], + (GLfloat) v[3]); +} + +#endif /* FEATURE_NV_fragment_program */ + + + +/* GL_EXT_stencil_two_side */ +static void GLAPIENTRY +save_ActiveStencilFaceEXT(GLenum face) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_ACTIVE_STENCIL_FACE_EXT, 1); + if (n) { + n[1].e = face; + } + if (ctx->ExecuteFlag) { + CALL_ActiveStencilFaceEXT(ctx->Exec, (face)); + } +} + + +/* GL_EXT_depth_bounds_test */ +static void GLAPIENTRY +save_DepthBoundsEXT(GLclampd zmin, GLclampd zmax) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_DEPTH_BOUNDS_EXT, 2); + if (n) { + n[1].f = (GLfloat) zmin; + n[2].f = (GLfloat) zmax; + } + if (ctx->ExecuteFlag) { + CALL_DepthBoundsEXT(ctx->Exec, (zmin, zmax)); + } +} + + + +#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program + +static void GLAPIENTRY +save_ProgramStringARB(GLenum target, GLenum format, GLsizei len, + const GLvoid * string) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + + n = alloc_instruction(ctx, OPCODE_PROGRAM_STRING_ARB, 4); + if (n) { + GLubyte *programCopy = (GLubyte *) malloc(len); + if (!programCopy) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glProgramStringARB"); + return; + } + memcpy(programCopy, string, len); + n[1].e = target; + n[2].e = format; + n[3].i = len; + n[4].data = programCopy; + } + if (ctx->ExecuteFlag) { + CALL_ProgramStringARB(ctx->Exec, (target, format, len, string)); + } +} + +#endif /* FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program */ + + +#if FEATURE_queryobj + +static void GLAPIENTRY +save_BeginQueryARB(GLenum target, GLuint id) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_BEGIN_QUERY_ARB, 2); + if (n) { + n[1].e = target; + n[2].ui = id; + } + if (ctx->ExecuteFlag) { + CALL_BeginQueryARB(ctx->Exec, (target, id)); + } +} + + +static void GLAPIENTRY +save_EndQueryARB(GLenum target) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_END_QUERY_ARB, 1); + if (n) { + n[1].e = target; + } + if (ctx->ExecuteFlag) { + CALL_EndQueryARB(ctx->Exec, (target)); + } +} + +#endif /* FEATURE_queryobj */ + + +static void GLAPIENTRY +save_DrawBuffersARB(GLsizei count, const GLenum * buffers) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_DRAW_BUFFERS_ARB, 1 + MAX_DRAW_BUFFERS); + if (n) { + GLint i; + n[1].i = count; + if (count > MAX_DRAW_BUFFERS) + count = MAX_DRAW_BUFFERS; + for (i = 0; i < count; i++) { + n[2 + i].e = buffers[i]; + } + } + if (ctx->ExecuteFlag) { + CALL_DrawBuffersARB(ctx->Exec, (count, buffers)); + } +} + +static void GLAPIENTRY +save_TexBumpParameterfvATI(GLenum pname, const GLfloat *param) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + + n = alloc_instruction(ctx, OPCODE_TEX_BUMP_PARAMETER_ATI, 5); + if (n) { + n[1].ui = pname; + n[2].f = param[0]; + n[3].f = param[1]; + n[4].f = param[2]; + n[5].f = param[3]; + } + if (ctx->ExecuteFlag) { + CALL_TexBumpParameterfvATI(ctx->Exec, (pname, param)); + } +} + +static void GLAPIENTRY +save_TexBumpParameterivATI(GLenum pname, const GLint *param) +{ + GLfloat p[4]; + p[0] = INT_TO_FLOAT(param[0]); + p[1] = INT_TO_FLOAT(param[1]); + p[2] = INT_TO_FLOAT(param[2]); + p[3] = INT_TO_FLOAT(param[3]); + save_TexBumpParameterfvATI(pname, p); +} + +#if FEATURE_ATI_fragment_shader +static void GLAPIENTRY +save_BindFragmentShaderATI(GLuint id) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + + n = alloc_instruction(ctx, OPCODE_BIND_FRAGMENT_SHADER_ATI, 1); + if (n) { + n[1].ui = id; + } + if (ctx->ExecuteFlag) { + CALL_BindFragmentShaderATI(ctx->Exec, (id)); + } +} + +static void GLAPIENTRY +save_SetFragmentShaderConstantATI(GLuint dst, const GLfloat *value) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + + n = alloc_instruction(ctx, OPCODE_SET_FRAGMENT_SHADER_CONSTANTS_ATI, 5); + if (n) { + n[1].ui = dst; + n[2].f = value[0]; + n[3].f = value[1]; + n[4].f = value[2]; + n[5].f = value[3]; + } + if (ctx->ExecuteFlag) { + CALL_SetFragmentShaderConstantATI(ctx->Exec, (dst, value)); + } +} +#endif + +static void GLAPIENTRY +save_Attr1fNV(GLenum attr, GLfloat x) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + SAVE_FLUSH_VERTICES(ctx); + n = alloc_instruction(ctx, OPCODE_ATTR_1F_NV, 2); + if (n) { + n[1].e = attr; + n[2].f = x; + } + + ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS); + ctx->ListState.ActiveAttribSize[attr] = 1; + ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, 0, 0, 1); + + if (ctx->ExecuteFlag) { + CALL_VertexAttrib1fNV(ctx->Exec, (attr, x)); + } +} + +static void GLAPIENTRY +save_Attr2fNV(GLenum attr, GLfloat x, GLfloat y) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + SAVE_FLUSH_VERTICES(ctx); + n = alloc_instruction(ctx, OPCODE_ATTR_2F_NV, 3); + if (n) { + n[1].e = attr; + n[2].f = x; + n[3].f = y; + } + + ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS); + ctx->ListState.ActiveAttribSize[attr] = 2; + ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, 0, 1); + + if (ctx->ExecuteFlag) { + CALL_VertexAttrib2fNV(ctx->Exec, (attr, x, y)); + } +} + +static void GLAPIENTRY +save_Attr3fNV(GLenum attr, GLfloat x, GLfloat y, GLfloat z) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + SAVE_FLUSH_VERTICES(ctx); + n = alloc_instruction(ctx, OPCODE_ATTR_3F_NV, 4); + if (n) { + n[1].e = attr; + n[2].f = x; + n[3].f = y; + n[4].f = z; + } + + ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS); + ctx->ListState.ActiveAttribSize[attr] = 3; + ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, z, 1); + + if (ctx->ExecuteFlag) { + CALL_VertexAttrib3fNV(ctx->Exec, (attr, x, y, z)); + } +} + +static void GLAPIENTRY +save_Attr4fNV(GLenum attr, GLfloat x, GLfloat y, GLfloat z, GLfloat w) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + SAVE_FLUSH_VERTICES(ctx); + n = alloc_instruction(ctx, OPCODE_ATTR_4F_NV, 5); + if (n) { + n[1].e = attr; + n[2].f = x; + n[3].f = y; + n[4].f = z; + n[5].f = w; + } + + ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS); + ctx->ListState.ActiveAttribSize[attr] = 4; + ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, z, w); + + if (ctx->ExecuteFlag) { + CALL_VertexAttrib4fNV(ctx->Exec, (attr, x, y, z, w)); + } +} + + +static void GLAPIENTRY +save_Attr1fARB(GLenum attr, GLfloat x) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + SAVE_FLUSH_VERTICES(ctx); + n = alloc_instruction(ctx, OPCODE_ATTR_1F_ARB, 2); + if (n) { + n[1].e = attr; + n[2].f = x; + } + + ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS); + ctx->ListState.ActiveAttribSize[attr] = 1; + ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, 0, 0, 1); + + if (ctx->ExecuteFlag) { + CALL_VertexAttrib1fARB(ctx->Exec, (attr, x)); + } +} + +static void GLAPIENTRY +save_Attr2fARB(GLenum attr, GLfloat x, GLfloat y) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + SAVE_FLUSH_VERTICES(ctx); + n = alloc_instruction(ctx, OPCODE_ATTR_2F_ARB, 3); + if (n) { + n[1].e = attr; + n[2].f = x; + n[3].f = y; + } + + ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS); + ctx->ListState.ActiveAttribSize[attr] = 2; + ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, 0, 1); + + if (ctx->ExecuteFlag) { + CALL_VertexAttrib2fARB(ctx->Exec, (attr, x, y)); + } +} + +static void GLAPIENTRY +save_Attr3fARB(GLenum attr, GLfloat x, GLfloat y, GLfloat z) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + SAVE_FLUSH_VERTICES(ctx); + n = alloc_instruction(ctx, OPCODE_ATTR_3F_ARB, 4); + if (n) { + n[1].e = attr; + n[2].f = x; + n[3].f = y; + n[4].f = z; + } + + ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS); + ctx->ListState.ActiveAttribSize[attr] = 3; + ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, z, 1); + + if (ctx->ExecuteFlag) { + CALL_VertexAttrib3fARB(ctx->Exec, (attr, x, y, z)); + } +} + +static void GLAPIENTRY +save_Attr4fARB(GLenum attr, GLfloat x, GLfloat y, GLfloat z, GLfloat w) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + SAVE_FLUSH_VERTICES(ctx); + n = alloc_instruction(ctx, OPCODE_ATTR_4F_ARB, 5); + if (n) { + n[1].e = attr; + n[2].f = x; + n[3].f = y; + n[4].f = z; + n[5].f = w; + } + + ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS); + ctx->ListState.ActiveAttribSize[attr] = 4; + ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, z, w); + + if (ctx->ExecuteFlag) { + CALL_VertexAttrib4fARB(ctx->Exec, (attr, x, y, z, w)); + } +} + + +static void GLAPIENTRY +save_EvalCoord1f(GLfloat x) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + SAVE_FLUSH_VERTICES(ctx); + n = alloc_instruction(ctx, OPCODE_EVAL_C1, 1); + if (n) { + n[1].f = x; + } + if (ctx->ExecuteFlag) { + CALL_EvalCoord1f(ctx->Exec, (x)); + } +} + +static void GLAPIENTRY +save_EvalCoord1fv(const GLfloat * v) +{ + save_EvalCoord1f(v[0]); +} + +static void GLAPIENTRY +save_EvalCoord2f(GLfloat x, GLfloat y) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + SAVE_FLUSH_VERTICES(ctx); + n = alloc_instruction(ctx, OPCODE_EVAL_C2, 2); + if (n) { + n[1].f = x; + n[2].f = y; + } + if (ctx->ExecuteFlag) { + CALL_EvalCoord2f(ctx->Exec, (x, y)); + } +} + +static void GLAPIENTRY +save_EvalCoord2fv(const GLfloat * v) +{ + save_EvalCoord2f(v[0], v[1]); +} + + +static void GLAPIENTRY +save_EvalPoint1(GLint x) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + SAVE_FLUSH_VERTICES(ctx); + n = alloc_instruction(ctx, OPCODE_EVAL_P1, 1); + if (n) { + n[1].i = x; + } + if (ctx->ExecuteFlag) { + CALL_EvalPoint1(ctx->Exec, (x)); + } +} + +static void GLAPIENTRY +save_EvalPoint2(GLint x, GLint y) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + SAVE_FLUSH_VERTICES(ctx); + n = alloc_instruction(ctx, OPCODE_EVAL_P2, 2); + if (n) { + n[1].i = x; + n[2].i = y; + } + if (ctx->ExecuteFlag) { + CALL_EvalPoint2(ctx->Exec, (x, y)); + } +} + +static void GLAPIENTRY +save_Indexf(GLfloat x) +{ + save_Attr1fNV(VERT_ATTRIB_COLOR_INDEX, x); +} + +static void GLAPIENTRY +save_Indexfv(const GLfloat * v) +{ + save_Attr1fNV(VERT_ATTRIB_COLOR_INDEX, v[0]); +} + +static void GLAPIENTRY +save_EdgeFlag(GLboolean x) +{ + save_Attr1fNV(VERT_ATTRIB_EDGEFLAG, x ? (GLfloat)1.0 : (GLfloat)0.0); +} + +static INLINE GLboolean compare4fv( const GLfloat *a, + const GLfloat *b, + GLuint count ) +{ + return memcmp( a, b, count * sizeof(GLfloat) ) == 0; +} + + +static void GLAPIENTRY +save_Materialfv(GLenum face, GLenum pname, const GLfloat * param) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + int args, i; + GLuint bitmask; + + switch (face) { + case GL_BACK: + case GL_FRONT: + case GL_FRONT_AND_BACK: + break; + default: + _mesa_compile_error(ctx, GL_INVALID_ENUM, "material(face)"); + return; + } + + switch (pname) { + case GL_EMISSION: + case GL_AMBIENT: + case GL_DIFFUSE: + case GL_SPECULAR: + case GL_AMBIENT_AND_DIFFUSE: + args = 4; + break; + case GL_SHININESS: + args = 1; + break; + case GL_COLOR_INDEXES: + args = 3; + break; + default: + _mesa_compile_error(ctx, GL_INVALID_ENUM, "material(pname)"); + return; + } + + if (ctx->ExecuteFlag) { + CALL_Materialfv(ctx->Exec, (face, pname, param)); + } + + bitmask = _mesa_material_bitmask(ctx, face, pname, ~0, NULL); + + /* Try to eliminate redundant statechanges. Because it is legal to + * call glMaterial even inside begin/end calls, don't need to worry + * about ctx->Driver.CurrentSavePrimitive here. + */ + for (i = 0; i < MAT_ATTRIB_MAX; i++) { + if (bitmask & (1 << i)) { + if (ctx->ListState.ActiveMaterialSize[i] == args && + compare4fv(ctx->ListState.CurrentMaterial[i], param, args)) { + bitmask &= ~(1 << i); + } + else { + ctx->ListState.ActiveMaterialSize[i] = args; + COPY_SZ_4V(ctx->ListState.CurrentMaterial[i], args, param); + } + } + } + + /* If this call has effect, return early: + */ + if (bitmask == 0) + return; + + SAVE_FLUSH_VERTICES(ctx); + + n = alloc_instruction(ctx, OPCODE_MATERIAL, 6); + if (n) { + n[1].e = face; + n[2].e = pname; + for (i = 0; i < args; i++) + n[3 + i].f = param[i]; + } +} + +static void GLAPIENTRY +save_Begin(GLenum mode) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + GLboolean error = GL_FALSE; + + if ( /*mode < GL_POINTS || */ mode > GL_POLYGON) { + _mesa_compile_error(ctx, GL_INVALID_ENUM, "Begin (mode)"); + error = GL_TRUE; + } + else if (ctx->Driver.CurrentSavePrimitive == PRIM_UNKNOWN) { + /* Typically the first begin. This may raise an error on + * playback, depending on whether CallList is issued from inside + * a begin/end or not. + */ + ctx->Driver.CurrentSavePrimitive = PRIM_INSIDE_UNKNOWN_PRIM; + } + else if (ctx->Driver.CurrentSavePrimitive == PRIM_OUTSIDE_BEGIN_END) { + ctx->Driver.CurrentSavePrimitive = mode; + } + else { + _mesa_compile_error(ctx, GL_INVALID_OPERATION, "recursive begin"); + error = GL_TRUE; + } + + if (!error) { + /* Give the driver an opportunity to hook in an optimized + * display list compiler. + */ + if (ctx->Driver.NotifySaveBegin(ctx, mode)) + return; + + SAVE_FLUSH_VERTICES(ctx); + n = alloc_instruction(ctx, OPCODE_BEGIN, 1); + if (n) { + n[1].e = mode; + } + } + + if (ctx->ExecuteFlag) { + CALL_Begin(ctx->Exec, (mode)); + } +} + +static void GLAPIENTRY +save_End(void) +{ + GET_CURRENT_CONTEXT(ctx); + SAVE_FLUSH_VERTICES(ctx); + (void) alloc_instruction(ctx, OPCODE_END, 0); + ctx->Driver.CurrentSavePrimitive = PRIM_OUTSIDE_BEGIN_END; + if (ctx->ExecuteFlag) { + CALL_End(ctx->Exec, ()); + } +} + +static void GLAPIENTRY +save_Rectf(GLfloat a, GLfloat b, GLfloat c, GLfloat d) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + SAVE_FLUSH_VERTICES(ctx); + n = alloc_instruction(ctx, OPCODE_RECTF, 4); + if (n) { + n[1].f = a; + n[2].f = b; + n[3].f = c; + n[4].f = d; + } + if (ctx->ExecuteFlag) { + CALL_Rectf(ctx->Exec, (a, b, c, d)); + } +} + + +static void GLAPIENTRY +save_Vertex2f(GLfloat x, GLfloat y) +{ + save_Attr2fNV(VERT_ATTRIB_POS, x, y); +} + +static void GLAPIENTRY +save_Vertex2fv(const GLfloat * v) +{ + save_Attr2fNV(VERT_ATTRIB_POS, v[0], v[1]); +} + +static void GLAPIENTRY +save_Vertex3f(GLfloat x, GLfloat y, GLfloat z) +{ + save_Attr3fNV(VERT_ATTRIB_POS, x, y, z); +} + +static void GLAPIENTRY +save_Vertex3fv(const GLfloat * v) +{ + save_Attr3fNV(VERT_ATTRIB_POS, v[0], v[1], v[2]); +} + +static void GLAPIENTRY +save_Vertex4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w) +{ + save_Attr4fNV(VERT_ATTRIB_POS, x, y, z, w); +} + +static void GLAPIENTRY +save_Vertex4fv(const GLfloat * v) +{ + save_Attr4fNV(VERT_ATTRIB_POS, v[0], v[1], v[2], v[3]); +} + +static void GLAPIENTRY +save_TexCoord1f(GLfloat x) +{ + save_Attr1fNV(VERT_ATTRIB_TEX0, x); +} + +static void GLAPIENTRY +save_TexCoord1fv(const GLfloat * v) +{ + save_Attr1fNV(VERT_ATTRIB_TEX0, v[0]); +} + +static void GLAPIENTRY +save_TexCoord2f(GLfloat x, GLfloat y) +{ + save_Attr2fNV(VERT_ATTRIB_TEX0, x, y); +} + +static void GLAPIENTRY +save_TexCoord2fv(const GLfloat * v) +{ + save_Attr2fNV(VERT_ATTRIB_TEX0, v[0], v[1]); +} + +static void GLAPIENTRY +save_TexCoord3f(GLfloat x, GLfloat y, GLfloat z) +{ + save_Attr3fNV(VERT_ATTRIB_TEX0, x, y, z); +} + +static void GLAPIENTRY +save_TexCoord3fv(const GLfloat * v) +{ + save_Attr3fNV(VERT_ATTRIB_TEX0, v[0], v[1], v[2]); +} + +static void GLAPIENTRY +save_TexCoord4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w) +{ + save_Attr4fNV(VERT_ATTRIB_TEX0, x, y, z, w); +} + +static void GLAPIENTRY +save_TexCoord4fv(const GLfloat * v) +{ + save_Attr4fNV(VERT_ATTRIB_TEX0, v[0], v[1], v[2], v[3]); +} + +static void GLAPIENTRY +save_Normal3f(GLfloat x, GLfloat y, GLfloat z) +{ + save_Attr3fNV(VERT_ATTRIB_NORMAL, x, y, z); +} + +static void GLAPIENTRY +save_Normal3fv(const GLfloat * v) +{ + save_Attr3fNV(VERT_ATTRIB_NORMAL, v[0], v[1], v[2]); +} + +static void GLAPIENTRY +save_FogCoordfEXT(GLfloat x) +{ + save_Attr1fNV(VERT_ATTRIB_FOG, x); +} + +static void GLAPIENTRY +save_FogCoordfvEXT(const GLfloat * v) +{ + save_Attr1fNV(VERT_ATTRIB_FOG, v[0]); +} + +static void GLAPIENTRY +save_Color3f(GLfloat x, GLfloat y, GLfloat z) +{ + save_Attr3fNV(VERT_ATTRIB_COLOR0, x, y, z); +} + +static void GLAPIENTRY +save_Color3fv(const GLfloat * v) +{ + save_Attr3fNV(VERT_ATTRIB_COLOR0, v[0], v[1], v[2]); +} + +static void GLAPIENTRY +save_Color4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w) +{ + save_Attr4fNV(VERT_ATTRIB_COLOR0, x, y, z, w); +} + +static void GLAPIENTRY +save_Color4fv(const GLfloat * v) +{ + save_Attr4fNV(VERT_ATTRIB_COLOR0, v[0], v[1], v[2], v[3]); +} + +static void GLAPIENTRY +save_SecondaryColor3fEXT(GLfloat x, GLfloat y, GLfloat z) +{ + save_Attr3fNV(VERT_ATTRIB_COLOR1, x, y, z); +} + +static void GLAPIENTRY +save_SecondaryColor3fvEXT(const GLfloat * v) +{ + save_Attr3fNV(VERT_ATTRIB_COLOR1, v[0], v[1], v[2]); +} + + +/* Just call the respective ATTR for texcoord + */ +static void GLAPIENTRY +save_MultiTexCoord1f(GLenum target, GLfloat x) +{ + GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0; + save_Attr1fNV(attr, x); +} + +static void GLAPIENTRY +save_MultiTexCoord1fv(GLenum target, const GLfloat * v) +{ + GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0; + save_Attr1fNV(attr, v[0]); +} + +static void GLAPIENTRY +save_MultiTexCoord2f(GLenum target, GLfloat x, GLfloat y) +{ + GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0; + save_Attr2fNV(attr, x, y); +} + +static void GLAPIENTRY +save_MultiTexCoord2fv(GLenum target, const GLfloat * v) +{ + GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0; + save_Attr2fNV(attr, v[0], v[1]); +} + +static void GLAPIENTRY +save_MultiTexCoord3f(GLenum target, GLfloat x, GLfloat y, GLfloat z) +{ + GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0; + save_Attr3fNV(attr, x, y, z); +} + +static void GLAPIENTRY +save_MultiTexCoord3fv(GLenum target, const GLfloat * v) +{ + GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0; + save_Attr3fNV(attr, v[0], v[1], v[2]); +} + +static void GLAPIENTRY +save_MultiTexCoord4f(GLenum target, GLfloat x, GLfloat y, + GLfloat z, GLfloat w) +{ + GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0; + save_Attr4fNV(attr, x, y, z, w); +} + +static void GLAPIENTRY +save_MultiTexCoord4fv(GLenum target, const GLfloat * v) +{ + GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0; + save_Attr4fNV(attr, v[0], v[1], v[2], v[3]); +} + + +/** + * Record a GL_INVALID_VALUE error when a invalid vertex attribute + * index is found. + */ +static void +index_error(void) +{ + GET_CURRENT_CONTEXT(ctx); + _mesa_error(ctx, GL_INVALID_VALUE, "VertexAttribf(index)"); +} + + +/* First level for NV_vertex_program: + * + * Check for errors at compile time?. + */ +static void GLAPIENTRY +save_VertexAttrib1fNV(GLuint index, GLfloat x) +{ + if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) + save_Attr1fNV(index, x); + else + index_error(); +} + +static void GLAPIENTRY +save_VertexAttrib1fvNV(GLuint index, const GLfloat * v) +{ + if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) + save_Attr1fNV(index, v[0]); + else + index_error(); +} + +static void GLAPIENTRY +save_VertexAttrib2fNV(GLuint index, GLfloat x, GLfloat y) +{ + if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) + save_Attr2fNV(index, x, y); + else + index_error(); +} + +static void GLAPIENTRY +save_VertexAttrib2fvNV(GLuint index, const GLfloat * v) +{ + if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) + save_Attr2fNV(index, v[0], v[1]); + else + index_error(); +} + +static void GLAPIENTRY +save_VertexAttrib3fNV(GLuint index, GLfloat x, GLfloat y, GLfloat z) +{ + if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) + save_Attr3fNV(index, x, y, z); + else + index_error(); +} + +static void GLAPIENTRY +save_VertexAttrib3fvNV(GLuint index, const GLfloat * v) +{ + if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) + save_Attr3fNV(index, v[0], v[1], v[2]); + else + index_error(); +} + +static void GLAPIENTRY +save_VertexAttrib4fNV(GLuint index, GLfloat x, GLfloat y, + GLfloat z, GLfloat w) +{ + if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) + save_Attr4fNV(index, x, y, z, w); + else + index_error(); +} + +static void GLAPIENTRY +save_VertexAttrib4fvNV(GLuint index, const GLfloat * v) +{ + if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) + save_Attr4fNV(index, v[0], v[1], v[2], v[3]); + else + index_error(); +} + + + + +static void GLAPIENTRY +save_VertexAttrib1fARB(GLuint index, GLfloat x) +{ + if (index < MAX_VERTEX_GENERIC_ATTRIBS) + save_Attr1fARB(index, x); + else + index_error(); +} + +static void GLAPIENTRY +save_VertexAttrib1fvARB(GLuint index, const GLfloat * v) +{ + if (index < MAX_VERTEX_GENERIC_ATTRIBS) + save_Attr1fARB(index, v[0]); + else + index_error(); +} + +static void GLAPIENTRY +save_VertexAttrib2fARB(GLuint index, GLfloat x, GLfloat y) +{ + if (index < MAX_VERTEX_GENERIC_ATTRIBS) + save_Attr2fARB(index, x, y); + else + index_error(); +} + +static void GLAPIENTRY +save_VertexAttrib2fvARB(GLuint index, const GLfloat * v) +{ + if (index < MAX_VERTEX_GENERIC_ATTRIBS) + save_Attr2fARB(index, v[0], v[1]); + else + index_error(); +} + +static void GLAPIENTRY +save_VertexAttrib3fARB(GLuint index, GLfloat x, GLfloat y, GLfloat z) +{ + if (index < MAX_VERTEX_GENERIC_ATTRIBS) + save_Attr3fARB(index, x, y, z); + else + index_error(); +} + +static void GLAPIENTRY +save_VertexAttrib3fvARB(GLuint index, const GLfloat * v) +{ + if (index < MAX_VERTEX_GENERIC_ATTRIBS) + save_Attr3fARB(index, v[0], v[1], v[2]); + else + index_error(); +} + +static void GLAPIENTRY +save_VertexAttrib4fARB(GLuint index, GLfloat x, GLfloat y, GLfloat z, + GLfloat w) +{ + if (index < MAX_VERTEX_GENERIC_ATTRIBS) + save_Attr4fARB(index, x, y, z, w); + else + index_error(); +} + +static void GLAPIENTRY +save_VertexAttrib4fvARB(GLuint index, const GLfloat * v) +{ + if (index < MAX_VERTEX_GENERIC_ATTRIBS) + save_Attr4fARB(index, v[0], v[1], v[2], v[3]); + else + index_error(); +} + + +/* GL_ARB_shader_objects, GL_ARB_vertex/fragment_shader */ + +static void GLAPIENTRY +exec_BindAttribLocationARB(GLuint program, GLuint index, const GLchar *name) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_BindAttribLocationARB(ctx->Exec, (program, index, name)); +} + +static GLint GLAPIENTRY +exec_GetAttribLocationARB(GLuint program, const GLchar *name) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + return CALL_GetAttribLocationARB(ctx->Exec, (program, name)); +} + +static GLint GLAPIENTRY +exec_GetUniformLocationARB(GLuint program, const GLchar *name) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + return CALL_GetUniformLocationARB(ctx->Exec, (program, name)); +} +/* XXX more shader functions needed here */ + + +#if FEATURE_EXT_framebuffer_blit +static void GLAPIENTRY +save_BlitFramebufferEXT(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, + GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, + GLbitfield mask, GLenum filter) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_BLIT_FRAMEBUFFER, 10); + if (n) { + n[1].i = srcX0; + n[2].i = srcY0; + n[3].i = srcX1; + n[4].i = srcY1; + n[5].i = dstX0; + n[6].i = dstY0; + n[7].i = dstX1; + n[8].i = dstY1; + n[9].i = mask; + n[10].e = filter; + } + if (ctx->ExecuteFlag) { + CALL_BlitFramebufferEXT(ctx->Exec, (srcX0, srcY0, srcX1, srcY1, + dstX0, dstY0, dstX1, dstY1, + mask, filter)); + } +} +#endif + + +/** GL_EXT_provoking_vertex */ +static void GLAPIENTRY +save_ProvokingVertexEXT(GLenum mode) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_PROVOKING_VERTEX, 1); + if (n) { + n[1].e = mode; + } + if (ctx->ExecuteFlag) { + /*CALL_ProvokingVertexEXT(ctx->Exec, (mode));*/ + _mesa_ProvokingVertexEXT(mode); + } +} + + +/** GL_EXT_transform_feedback */ +static void GLAPIENTRY +save_BeginTransformFeedback(GLenum mode) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_BEGIN_TRANSFORM_FEEDBACK, 1); + if (n) { + n[1].e = mode; + } + if (ctx->ExecuteFlag) { + CALL_BeginTransformFeedbackEXT(ctx->Exec, (mode)); + } +} + + +/** GL_EXT_transform_feedback */ +static void GLAPIENTRY +save_EndTransformFeedback(void) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + (void) alloc_instruction(ctx, OPCODE_END_TRANSFORM_FEEDBACK, 0); + if (ctx->ExecuteFlag) { + CALL_EndTransformFeedbackEXT(ctx->Exec, ()); + } +} + +static void GLAPIENTRY +save_TransformFeedbackVaryings(GLuint program, GLsizei count, + const GLchar **varyings, GLenum bufferMode) +{ + GET_CURRENT_CONTEXT(ctx); + _mesa_problem(ctx, + "glTransformFeedbackVarying() display list support not done"); +} + +static void GLAPIENTRY +save_BindTransformFeedback(GLenum target, GLuint name) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_BIND_TRANSFORM_FEEDBACK, 2); + if (n) { + n[1].e = target; + n[2].ui = name; + } + if (ctx->ExecuteFlag) { + CALL_BindTransformFeedback(ctx->Exec, (target, name)); + } +} + +static void GLAPIENTRY +save_PauseTransformFeedback(void) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + (void) alloc_instruction(ctx, OPCODE_PAUSE_TRANSFORM_FEEDBACK, 0); + if (ctx->ExecuteFlag) { + CALL_PauseTransformFeedback(ctx->Exec, ()); + } +} + +static void GLAPIENTRY +save_ResumeTransformFeedback(void) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + (void) alloc_instruction(ctx, OPCODE_RESUME_TRANSFORM_FEEDBACK, 0); + if (ctx->ExecuteFlag) { + CALL_ResumeTransformFeedback(ctx->Exec, ()); + } +} + +static void GLAPIENTRY +save_DrawTransformFeedback(GLenum mode, GLuint name) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_DRAW_TRANSFORM_FEEDBACK, 2); + if (n) { + n[1].e = mode; + n[2].ui = name; + } + if (ctx->ExecuteFlag) { + CALL_DrawTransformFeedback(ctx->Exec, (mode, name)); + } +} + + +/* aka UseProgram() */ +static void GLAPIENTRY +save_UseProgramObjectARB(GLhandleARB program) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_USE_PROGRAM, 1); + if (n) { + n[1].ui = program; + } + if (ctx->ExecuteFlag) { + CALL_UseProgramObjectARB(ctx->Exec, (program)); + } +} + + +static void GLAPIENTRY +save_Uniform1fARB(GLint location, GLfloat x) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_1F, 2); + if (n) { + n[1].i = location; + n[2].f = x; + } + if (ctx->ExecuteFlag) { + CALL_Uniform1fARB(ctx->Exec, (location, x)); + } +} + + +static void GLAPIENTRY +save_Uniform2fARB(GLint location, GLfloat x, GLfloat y) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_2F, 3); + if (n) { + n[1].i = location; + n[2].f = x; + n[3].f = y; + } + if (ctx->ExecuteFlag) { + CALL_Uniform2fARB(ctx->Exec, (location, x, y)); + } +} + + +static void GLAPIENTRY +save_Uniform3fARB(GLint location, GLfloat x, GLfloat y, GLfloat z) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_3F, 4); + if (n) { + n[1].i = location; + n[2].f = x; + n[3].f = y; + n[4].f = z; + } + if (ctx->ExecuteFlag) { + CALL_Uniform3fARB(ctx->Exec, (location, x, y, z)); + } +} + + +static void GLAPIENTRY +save_Uniform4fARB(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_4F, 5); + if (n) { + n[1].i = location; + n[2].f = x; + n[3].f = y; + n[4].f = z; + n[5].f = w; + } + if (ctx->ExecuteFlag) { + CALL_Uniform4fARB(ctx->Exec, (location, x, y, z, w)); + } +} + + +/** Return copy of memory */ +static void * +memdup(const void *src, GLsizei bytes) +{ + void *b = bytes >= 0 ? malloc(bytes) : NULL; + if (b) + memcpy(b, src, bytes); + return b; +} + + +static void GLAPIENTRY +save_Uniform1fvARB(GLint location, GLsizei count, const GLfloat *v) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_1FV, 3); + if (n) { + n[1].i = location; + n[2].i = count; + n[3].data = memdup(v, count * 1 * sizeof(GLfloat)); + } + if (ctx->ExecuteFlag) { + CALL_Uniform1fvARB(ctx->Exec, (location, count, v)); + } +} + +static void GLAPIENTRY +save_Uniform2fvARB(GLint location, GLsizei count, const GLfloat *v) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_2FV, 3); + if (n) { + n[1].i = location; + n[2].i = count; + n[3].data = memdup(v, count * 2 * sizeof(GLfloat)); + } + if (ctx->ExecuteFlag) { + CALL_Uniform2fvARB(ctx->Exec, (location, count, v)); + } +} + +static void GLAPIENTRY +save_Uniform3fvARB(GLint location, GLsizei count, const GLfloat *v) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_3FV, 3); + if (n) { + n[1].i = location; + n[2].i = count; + n[3].data = memdup(v, count * 3 * sizeof(GLfloat)); + } + if (ctx->ExecuteFlag) { + CALL_Uniform3fvARB(ctx->Exec, (location, count, v)); + } +} + +static void GLAPIENTRY +save_Uniform4fvARB(GLint location, GLsizei count, const GLfloat *v) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_4FV, 3); + if (n) { + n[1].i = location; + n[2].i = count; + n[3].data = memdup(v, count * 4 * sizeof(GLfloat)); + } + if (ctx->ExecuteFlag) { + CALL_Uniform4fvARB(ctx->Exec, (location, count, v)); + } +} + + +static void GLAPIENTRY +save_Uniform1iARB(GLint location, GLint x) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_1I, 2); + if (n) { + n[1].i = location; + n[2].i = x; + } + if (ctx->ExecuteFlag) { + CALL_Uniform1iARB(ctx->Exec, (location, x)); + } +} + +static void GLAPIENTRY +save_Uniform2iARB(GLint location, GLint x, GLint y) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_2I, 3); + if (n) { + n[1].i = location; + n[2].i = x; + n[3].i = y; + } + if (ctx->ExecuteFlag) { + CALL_Uniform2iARB(ctx->Exec, (location, x, y)); + } +} + +static void GLAPIENTRY +save_Uniform3iARB(GLint location, GLint x, GLint y, GLint z) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_3I, 4); + if (n) { + n[1].i = location; + n[2].i = x; + n[3].i = y; + n[4].i = z; + } + if (ctx->ExecuteFlag) { + CALL_Uniform3iARB(ctx->Exec, (location, x, y, z)); + } +} + +static void GLAPIENTRY +save_Uniform4iARB(GLint location, GLint x, GLint y, GLint z, GLint w) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_4I, 5); + if (n) { + n[1].i = location; + n[2].i = x; + n[3].i = y; + n[4].i = z; + n[5].i = w; + } + if (ctx->ExecuteFlag) { + CALL_Uniform4iARB(ctx->Exec, (location, x, y, z, w)); + } +} + + + +static void GLAPIENTRY +save_Uniform1ivARB(GLint location, GLsizei count, const GLint *v) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_1IV, 3); + if (n) { + n[1].i = location; + n[2].i = count; + n[3].data = memdup(v, count * 1 * sizeof(GLint)); + } + if (ctx->ExecuteFlag) { + CALL_Uniform1ivARB(ctx->Exec, (location, count, v)); + } +} + +static void GLAPIENTRY +save_Uniform2ivARB(GLint location, GLsizei count, const GLint *v) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_2IV, 3); + if (n) { + n[1].i = location; + n[2].i = count; + n[3].data = memdup(v, count * 2 * sizeof(GLint)); + } + if (ctx->ExecuteFlag) { + CALL_Uniform2ivARB(ctx->Exec, (location, count, v)); + } +} + +static void GLAPIENTRY +save_Uniform3ivARB(GLint location, GLsizei count, const GLint *v) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_3IV, 3); + if (n) { + n[1].i = location; + n[2].i = count; + n[3].data = memdup(v, count * 3 * sizeof(GLint)); + } + if (ctx->ExecuteFlag) { + CALL_Uniform3ivARB(ctx->Exec, (location, count, v)); + } +} + +static void GLAPIENTRY +save_Uniform4ivARB(GLint location, GLsizei count, const GLint *v) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_4IV, 3); + if (n) { + n[1].i = location; + n[2].i = count; + n[3].data = memdup(v, count * 4 * sizeof(GLfloat)); + } + if (ctx->ExecuteFlag) { + CALL_Uniform4ivARB(ctx->Exec, (location, count, v)); + } +} + + + +static void GLAPIENTRY +save_Uniform1ui(GLint location, GLuint x) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_1UI, 2); + if (n) { + n[1].i = location; + n[2].i = x; + } + if (ctx->ExecuteFlag) { + /*CALL_Uniform1ui(ctx->Exec, (location, x));*/ + } +} + +static void GLAPIENTRY +save_Uniform2ui(GLint location, GLuint x, GLuint y) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_2UI, 3); + if (n) { + n[1].i = location; + n[2].i = x; + n[3].i = y; + } + if (ctx->ExecuteFlag) { + /*CALL_Uniform2ui(ctx->Exec, (location, x, y));*/ + } +} + +static void GLAPIENTRY +save_Uniform3ui(GLint location, GLuint x, GLuint y, GLuint z) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_3UI, 4); + if (n) { + n[1].i = location; + n[2].i = x; + n[3].i = y; + n[4].i = z; + } + if (ctx->ExecuteFlag) { + /*CALL_Uniform3ui(ctx->Exec, (location, x, y, z));*/ + } +} + +static void GLAPIENTRY +save_Uniform4ui(GLint location, GLuint x, GLuint y, GLuint z, GLuint w) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_4UI, 5); + if (n) { + n[1].i = location; + n[2].i = x; + n[3].i = y; + n[4].i = z; + n[5].i = w; + } + if (ctx->ExecuteFlag) { + /*CALL_Uniform4ui(ctx->Exec, (location, x, y, z, w));*/ + } +} + + + +static void GLAPIENTRY +save_Uniform1uiv(GLint location, GLsizei count, const GLuint *v) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_1UIV, 3); + if (n) { + n[1].i = location; + n[2].i = count; + n[3].data = memdup(v, count * 1 * sizeof(*v)); + } + if (ctx->ExecuteFlag) { + /*CALL_Uniform1uiv(ctx->Exec, (location, count, v));*/ + } +} + +static void GLAPIENTRY +save_Uniform2uiv(GLint location, GLsizei count, const GLuint *v) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_2UIV, 3); + if (n) { + n[1].i = location; + n[2].i = count; + n[3].data = memdup(v, count * 2 * sizeof(*v)); + } + if (ctx->ExecuteFlag) { + /*CALL_Uniform2uiv(ctx->Exec, (location, count, v));*/ + } +} + +static void GLAPIENTRY +save_Uniform3uiv(GLint location, GLsizei count, const GLuint *v) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_3UIV, 3); + if (n) { + n[1].i = location; + n[2].i = count; + n[3].data = memdup(v, count * 3 * sizeof(*v)); + } + if (ctx->ExecuteFlag) { + /*CALL_Uniform3uiv(ctx->Exec, (location, count, v));*/ + } +} + +static void GLAPIENTRY +save_Uniform4uiv(GLint location, GLsizei count, const GLuint *v) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_4UIV, 3); + if (n) { + n[1].i = location; + n[2].i = count; + n[3].data = memdup(v, count * 4 * sizeof(*v)); + } + if (ctx->ExecuteFlag) { + /*CALL_Uniform4uiv(ctx->Exec, (location, count, v));*/ + } +} + + + +static void GLAPIENTRY +save_UniformMatrix2fvARB(GLint location, GLsizei count, GLboolean transpose, + const GLfloat *m) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX22, 4); + if (n) { + n[1].i = location; + n[2].i = count; + n[3].b = transpose; + n[4].data = memdup(m, count * 2 * 2 * sizeof(GLfloat)); + } + if (ctx->ExecuteFlag) { + CALL_UniformMatrix2fvARB(ctx->Exec, (location, count, transpose, m)); + } +} + +static void GLAPIENTRY +save_UniformMatrix3fvARB(GLint location, GLsizei count, GLboolean transpose, + const GLfloat *m) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX33, 4); + if (n) { + n[1].i = location; + n[2].i = count; + n[3].b = transpose; + n[4].data = memdup(m, count * 3 * 3 * sizeof(GLfloat)); + } + if (ctx->ExecuteFlag) { + CALL_UniformMatrix3fvARB(ctx->Exec, (location, count, transpose, m)); + } +} + +static void GLAPIENTRY +save_UniformMatrix4fvARB(GLint location, GLsizei count, GLboolean transpose, + const GLfloat *m) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX44, 4); + if (n) { + n[1].i = location; + n[2].i = count; + n[3].b = transpose; + n[4].data = memdup(m, count * 4 * 4 * sizeof(GLfloat)); + } + if (ctx->ExecuteFlag) { + CALL_UniformMatrix4fvARB(ctx->Exec, (location, count, transpose, m)); + } +} + + +static void GLAPIENTRY +save_UniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, + const GLfloat *m) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX23, 4); + if (n) { + n[1].i = location; + n[2].i = count; + n[3].b = transpose; + n[4].data = memdup(m, count * 2 * 3 * sizeof(GLfloat)); + } + if (ctx->ExecuteFlag) { + CALL_UniformMatrix2x3fv(ctx->Exec, (location, count, transpose, m)); + } +} + +static void GLAPIENTRY +save_UniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, + const GLfloat *m) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX32, 4); + if (n) { + n[1].i = location; + n[2].i = count; + n[3].b = transpose; + n[4].data = memdup(m, count * 3 * 2 * sizeof(GLfloat)); + } + if (ctx->ExecuteFlag) { + CALL_UniformMatrix3x2fv(ctx->Exec, (location, count, transpose, m)); + } +} + + +static void GLAPIENTRY +save_UniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, + const GLfloat *m) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX24, 4); + if (n) { + n[1].i = location; + n[2].i = count; + n[3].b = transpose; + n[4].data = memdup(m, count * 2 * 4 * sizeof(GLfloat)); + } + if (ctx->ExecuteFlag) { + CALL_UniformMatrix2x4fv(ctx->Exec, (location, count, transpose, m)); + } +} + +static void GLAPIENTRY +save_UniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, + const GLfloat *m) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX42, 4); + if (n) { + n[1].i = location; + n[2].i = count; + n[3].b = transpose; + n[4].data = memdup(m, count * 4 * 2 * sizeof(GLfloat)); + } + if (ctx->ExecuteFlag) { + CALL_UniformMatrix4x2fv(ctx->Exec, (location, count, transpose, m)); + } +} + + +static void GLAPIENTRY +save_UniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, + const GLfloat *m) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX34, 4); + if (n) { + n[1].i = location; + n[2].i = count; + n[3].b = transpose; + n[4].data = memdup(m, count * 3 * 4 * sizeof(GLfloat)); + } + if (ctx->ExecuteFlag) { + CALL_UniformMatrix3x4fv(ctx->Exec, (location, count, transpose, m)); + } +} + +static void GLAPIENTRY +save_UniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, + const GLfloat *m) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX43, 4); + if (n) { + n[1].i = location; + n[2].i = count; + n[3].b = transpose; + n[4].data = memdup(m, count * 4 * 3 * sizeof(GLfloat)); + } + if (ctx->ExecuteFlag) { + CALL_UniformMatrix4x3fv(ctx->Exec, (location, count, transpose, m)); + } +} + +static void GLAPIENTRY +save_ClampColorARB(GLenum target, GLenum clamp) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_CLAMP_COLOR, 2); + if (n) { + n[1].e = target; + n[2].e = clamp; + } + if (ctx->ExecuteFlag) { + CALL_ClampColorARB(ctx->Exec, (target, clamp)); + } +} + +static void GLAPIENTRY +save_UseShaderProgramEXT(GLenum type, GLuint program) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_USE_SHADER_PROGRAM_EXT, 2); + if (n) { + n[1].ui = type; + n[2].ui = program; + } + if (ctx->ExecuteFlag) { + CALL_UseShaderProgramEXT(ctx->Exec, (type, program)); + } +} + +static void GLAPIENTRY +save_ActiveProgramEXT(GLuint program) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_ACTIVE_PROGRAM_EXT, 1); + if (n) { + n[1].ui = program; + } + if (ctx->ExecuteFlag) { + CALL_ActiveProgramEXT(ctx->Exec, (program)); + } +} + +/** GL_EXT_texture_integer */ +static void GLAPIENTRY +save_ClearColorIi(GLint red, GLint green, GLint blue, GLint alpha) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_CLEARCOLOR_I, 4); + if (n) { + n[1].i = red; + n[2].i = green; + n[3].i = blue; + n[4].i = alpha; + } + if (ctx->ExecuteFlag) { + CALL_ClearColorIiEXT(ctx->Exec, (red, green, blue, alpha)); + } +} + +/** GL_EXT_texture_integer */ +static void GLAPIENTRY +save_ClearColorIui(GLuint red, GLuint green, GLuint blue, GLuint alpha) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_CLEARCOLOR_UI, 4); + if (n) { + n[1].ui = red; + n[2].ui = green; + n[3].ui = blue; + n[4].ui = alpha; + } + if (ctx->ExecuteFlag) { + CALL_ClearColorIuiEXT(ctx->Exec, (red, green, blue, alpha)); + } +} + +/** GL_EXT_texture_integer */ +static void GLAPIENTRY +save_TexParameterIiv(GLenum target, GLenum pname, const GLint *params) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_TEXPARAMETER_I, 6); + if (n) { + n[1].e = target; + n[2].e = pname; + n[3].i = params[0]; + n[4].i = params[1]; + n[5].i = params[2]; + n[6].i = params[3]; + } + if (ctx->ExecuteFlag) { + CALL_TexParameterIivEXT(ctx->Exec, (target, pname, params)); + } +} + +/** GL_EXT_texture_integer */ +static void GLAPIENTRY +save_TexParameterIuiv(GLenum target, GLenum pname, const GLuint *params) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_TEXPARAMETER_UI, 6); + if (n) { + n[1].e = target; + n[2].e = pname; + n[3].ui = params[0]; + n[4].ui = params[1]; + n[5].ui = params[2]; + n[6].ui = params[3]; + } + if (ctx->ExecuteFlag) { + CALL_TexParameterIuivEXT(ctx->Exec, (target, pname, params)); + } +} + +/** GL_EXT_texture_integer */ +static void GLAPIENTRY +exec_GetTexParameterIiv(GLenum target, GLenum pname, GLint *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetTexParameterIivEXT(ctx->Exec, (target, pname, params)); +} + +/** GL_EXT_texture_integer */ +static void GLAPIENTRY +exec_GetTexParameterIuiv(GLenum target, GLenum pname, GLuint *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetTexParameterIuivEXT(ctx->Exec, (target, pname, params)); +} + + +/* GL_ARB_instanced_arrays */ +static void GLAPIENTRY +save_VertexAttribDivisor(GLuint index, GLuint divisor) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_VERTEX_ATTRIB_DIVISOR, 2); + if (n) { + n[1].ui = index; + n[2].ui = divisor; + } + if (ctx->ExecuteFlag) { + CALL_VertexAttribDivisorARB(ctx->Exec, (index, divisor)); + } +} + + +/* GL_NV_texture_barrier */ +static void GLAPIENTRY +save_TextureBarrierNV(void) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + alloc_instruction(ctx, OPCODE_TEXTURE_BARRIER_NV, 0); + if (ctx->ExecuteFlag) { + CALL_TextureBarrierNV(ctx->Exec, ()); + } +} + + +/* GL_ARB_sampler_objects */ +static void GLAPIENTRY +save_BindSampler(GLuint unit, GLuint sampler) +{ + Node *n; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_BIND_SAMPLER, 2); + if (n) { + n[1].ui = unit; + n[2].ui = sampler; + } + if (ctx->ExecuteFlag) { + CALL_BindSampler(ctx->Exec, (unit, sampler)); + } +} + +static void GLAPIENTRY +save_SamplerParameteriv(GLuint sampler, GLenum pname, const GLint *params) +{ + Node *n; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_SAMPLER_PARAMETERIV, 6); + if (n) { + n[1].ui = sampler; + n[2].e = pname; + n[3].i = params[0]; + if (pname == GL_TEXTURE_BORDER_COLOR) { + n[4].i = params[1]; + n[5].i = params[2]; + n[6].i = params[3]; + } + else { + n[4].i = n[5].i = n[6].i = 0; + } + } + if (ctx->ExecuteFlag) { + CALL_SamplerParameteriv(ctx->Exec, (sampler, pname, params)); + } +} + +static void GLAPIENTRY +save_SamplerParameteri(GLuint sampler, GLenum pname, GLint param) +{ + save_SamplerParameteriv(sampler, pname, ¶m); +} + +static void GLAPIENTRY +save_SamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat *params) +{ + Node *n; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_SAMPLER_PARAMETERFV, 6); + if (n) { + n[1].ui = sampler; + n[2].e = pname; + n[3].f = params[0]; + if (pname == GL_TEXTURE_BORDER_COLOR) { + n[4].f = params[1]; + n[5].f = params[2]; + n[6].f = params[3]; + } + else { + n[4].f = n[5].f = n[6].f = 0.0F; + } + } + if (ctx->ExecuteFlag) { + CALL_SamplerParameterfv(ctx->Exec, (sampler, pname, params)); + } +} + +static void GLAPIENTRY +save_SamplerParameterf(GLuint sampler, GLenum pname, GLfloat param) +{ + save_SamplerParameterfv(sampler, pname, ¶m); +} + +static void GLAPIENTRY +save_SamplerParameterIiv(GLuint sampler, GLenum pname, const GLint *params) +{ + Node *n; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_SAMPLER_PARAMETERIIV, 6); + if (n) { + n[1].ui = sampler; + n[2].e = pname; + n[3].i = params[0]; + if (pname == GL_TEXTURE_BORDER_COLOR) { + n[4].i = params[1]; + n[5].i = params[2]; + n[6].i = params[3]; + } + else { + n[4].i = n[5].i = n[6].i = 0; + } + } + if (ctx->ExecuteFlag) { + CALL_SamplerParameterIiv(ctx->Exec, (sampler, pname, params)); + } +} + +static void GLAPIENTRY +save_SamplerParameterIuiv(GLuint sampler, GLenum pname, const GLuint *params) +{ + Node *n; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_SAMPLER_PARAMETERUIV, 6); + if (n) { + n[1].ui = sampler; + n[2].e = pname; + n[3].ui = params[0]; + if (pname == GL_TEXTURE_BORDER_COLOR) { + n[4].ui = params[1]; + n[5].ui = params[2]; + n[6].ui = params[3]; + } + else { + n[4].ui = n[5].ui = n[6].ui = 0; + } + } + if (ctx->ExecuteFlag) { + CALL_SamplerParameterIuiv(ctx->Exec, (sampler, pname, params)); + } +} + +/* GL_ARB_geometry_shader4 */ +static void GLAPIENTRY +save_ProgramParameteri(GLuint program, GLenum pname, GLint value) +{ + Node *n; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_PROGRAM_PARAMETERI, 3); + if (n) { + n[1].ui = program; + n[2].e = pname; + n[3].i = value; + } + if (ctx->ExecuteFlag) { + CALL_ProgramParameteriARB(ctx->Exec, (program, pname, value)); + } +} + +static void GLAPIENTRY +save_FramebufferTexture(GLenum target, GLenum attachment, + GLuint texture, GLint level) +{ + Node *n; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_FRAMEBUFFER_TEXTURE, 4); + if (n) { + n[1].e = target; + n[2].e = attachment; + n[3].ui = texture; + n[4].i = level; + } + if (ctx->ExecuteFlag) { + CALL_FramebufferTextureARB(ctx->Exec, (target, attachment, texture, level)); + } +} + +static void GLAPIENTRY +save_FramebufferTextureFace(GLenum target, GLenum attachment, + GLuint texture, GLint level, GLenum face) +{ + Node *n; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_FRAMEBUFFER_TEXTURE_FACE, 5); + if (n) { + n[1].e = target; + n[2].e = attachment; + n[3].ui = texture; + n[4].i = level; + n[5].e = face; + } + if (ctx->ExecuteFlag) { + CALL_FramebufferTextureFaceARB(ctx->Exec, (target, attachment, texture, + level, face)); + } +} + + + +static void GLAPIENTRY +save_WaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) +{ + Node *n; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_WAIT_SYNC, 4); + if (n) { + union uint64_pair p; + p.uint64 = timeout; + n[1].data = sync; + n[2].e = flags; + n[3].ui = p.uint32[0]; + n[4].ui = p.uint32[1]; + } + if (ctx->ExecuteFlag) { + CALL_WaitSync(ctx->Exec, (sync, flags, timeout)); + } +} + + +/** + * Save an error-generating command into display list. + * + * KW: Will appear in the list before the vertex buffer containing the + * command that provoked the error. I don't see this as a problem. + */ +static void +save_error(struct gl_context *ctx, GLenum error, const char *s) +{ + Node *n; + n = alloc_instruction(ctx, OPCODE_ERROR, 2); + if (n) { + n[1].e = error; + n[2].data = (void *) s; + } +} + + +/** + * Compile an error into current display list. + */ +void +_mesa_compile_error(struct gl_context *ctx, GLenum error, const char *s) +{ + if (ctx->CompileFlag) + save_error(ctx, error, s); + if (ctx->ExecuteFlag) + _mesa_error(ctx, error, "%s", s); +} + + +/** + * Test if ID names a display list. + */ +static GLboolean +islist(struct gl_context *ctx, GLuint list) +{ + if (list > 0 && lookup_list(ctx, list)) { + return GL_TRUE; + } + else { + return GL_FALSE; + } +} + + + +/**********************************************************************/ +/* Display list execution */ +/**********************************************************************/ + + +/* + * Execute a display list. Note that the ListBase offset must have already + * been added before calling this function. I.e. the list argument is + * the absolute list number, not relative to ListBase. + * \param list - display list number + */ +static void +execute_list(struct gl_context *ctx, GLuint list) +{ + struct gl_display_list *dlist; + Node *n; + GLboolean done; + + if (list == 0 || !islist(ctx, list)) + return; + + if (ctx->ListState.CallDepth == MAX_LIST_NESTING) { + /* raise an error? */ + return; + } + + dlist = lookup_list(ctx, list); + if (!dlist) + return; + + ctx->ListState.CallDepth++; + + if (ctx->Driver.BeginCallList) + ctx->Driver.BeginCallList(ctx, dlist); + + n = dlist->Head; + + done = GL_FALSE; + while (!done) { + const OpCode opcode = n[0].opcode; + + if (is_ext_opcode(opcode)) { + n += ext_opcode_execute(ctx, n); + } + else { + switch (opcode) { + case OPCODE_ERROR: + _mesa_error(ctx, n[1].e, "%s", (const char *) n[2].data); + break; + case OPCODE_ACCUM: + CALL_Accum(ctx->Exec, (n[1].e, n[2].f)); + break; + case OPCODE_ALPHA_FUNC: + CALL_AlphaFunc(ctx->Exec, (n[1].e, n[2].f)); + break; + case OPCODE_BIND_TEXTURE: + CALL_BindTexture(ctx->Exec, (n[1].e, n[2].ui)); + break; + case OPCODE_BITMAP: + { + const struct gl_pixelstore_attrib save = ctx->Unpack; + ctx->Unpack = ctx->DefaultPacking; + CALL_Bitmap(ctx->Exec, ((GLsizei) n[1].i, (GLsizei) n[2].i, + n[3].f, n[4].f, n[5].f, n[6].f, + (const GLubyte *) n[7].data)); + ctx->Unpack = save; /* restore */ + } + break; + case OPCODE_BLEND_COLOR: + CALL_BlendColor(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f)); + break; + case OPCODE_BLEND_EQUATION: + CALL_BlendEquation(ctx->Exec, (n[1].e)); + break; + case OPCODE_BLEND_EQUATION_SEPARATE: + CALL_BlendEquationSeparateEXT(ctx->Exec, (n[1].e, n[2].e)); + break; + case OPCODE_BLEND_FUNC_SEPARATE: + CALL_BlendFuncSeparateEXT(ctx->Exec, + (n[1].e, n[2].e, n[3].e, n[4].e)); + break; + + case OPCODE_BLEND_FUNC_I: + /* GL_ARB_draw_buffers_blend */ + CALL_BlendFunciARB(ctx->Exec, (n[1].ui, n[2].e, n[3].e)); + break; + case OPCODE_BLEND_FUNC_SEPARATE_I: + /* GL_ARB_draw_buffers_blend */ + CALL_BlendFuncSeparateiARB(ctx->Exec, (n[1].ui, n[2].e, n[3].e, + n[4].e, n[5].e)); + break; + case OPCODE_BLEND_EQUATION_I: + /* GL_ARB_draw_buffers_blend */ + CALL_BlendEquationiARB(ctx->Exec, (n[1].ui, n[2].e)); + break; + case OPCODE_BLEND_EQUATION_SEPARATE_I: + /* GL_ARB_draw_buffers_blend */ + CALL_BlendEquationSeparateiARB(ctx->Exec, + (n[1].ui, n[2].e, n[3].e)); + break; + + case OPCODE_CALL_LIST: + /* Generated by glCallList(), don't add ListBase */ + if (ctx->ListState.CallDepth < MAX_LIST_NESTING) { + execute_list(ctx, n[1].ui); + } + break; + case OPCODE_CALL_LIST_OFFSET: + /* Generated by glCallLists() so we must add ListBase */ + if (n[2].b) { + /* user specified a bad data type at compile time */ + _mesa_error(ctx, GL_INVALID_ENUM, "glCallLists(type)"); + } + else if (ctx->ListState.CallDepth < MAX_LIST_NESTING) { + GLuint list = (GLuint) (ctx->List.ListBase + n[1].i); + execute_list(ctx, list); + } + break; + case OPCODE_CLEAR: + CALL_Clear(ctx->Exec, (n[1].bf)); + break; + case OPCODE_CLEAR_BUFFER_IV: + { + /*GLint value[4]; + value[0] = n[3].i; + value[1] = n[4].i; + value[2] = n[5].i; + value[3] = n[6].i; + CALL_ClearBufferiv(ctx->Exec, (n[1].e, n[2].i, value));*/ + } + break; + case OPCODE_CLEAR_BUFFER_UIV: + { + /*GLuint value[4]; + value[0] = n[3].ui; + value[1] = n[4].ui; + value[2] = n[5].ui; + value[3] = n[6].ui; + CALL_ClearBufferiv(ctx->Exec, (n[1].e, n[2].i, value));*/ + } + break; + case OPCODE_CLEAR_BUFFER_FV: + { + /*GLfloat value[4]; + value[0] = n[3].f; + value[1] = n[4].f; + value[2] = n[5].f; + value[3] = n[6].f; + CALL_ClearBufferfv(ctx->Exec, (n[1].e, n[2].i, value));*/ + } + break; + case OPCODE_CLEAR_BUFFER_FI: + /*CALL_ClearBufferfi(ctx->Exec, (n[1].e, n[2].i, n[3].f, n[4].i));*/ + break; + case OPCODE_CLEAR_COLOR: + CALL_ClearColor(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f)); + break; + case OPCODE_CLEAR_ACCUM: + CALL_ClearAccum(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f)); + break; + case OPCODE_CLEAR_DEPTH: + CALL_ClearDepth(ctx->Exec, ((GLclampd) n[1].f)); + break; + case OPCODE_CLEAR_INDEX: + CALL_ClearIndex(ctx->Exec, ((GLfloat) n[1].ui)); + break; + case OPCODE_CLEAR_STENCIL: + CALL_ClearStencil(ctx->Exec, (n[1].i)); + break; + case OPCODE_CLIP_PLANE: + { + GLdouble eq[4]; + eq[0] = n[2].f; + eq[1] = n[3].f; + eq[2] = n[4].f; + eq[3] = n[5].f; + CALL_ClipPlane(ctx->Exec, (n[1].e, eq)); + } + break; + case OPCODE_COLOR_MASK: + CALL_ColorMask(ctx->Exec, (n[1].b, n[2].b, n[3].b, n[4].b)); + break; + case OPCODE_COLOR_MASK_INDEXED: + CALL_ColorMaskIndexedEXT(ctx->Exec, (n[1].ui, n[2].b, n[3].b, + n[4].b, n[5].b)); + break; + case OPCODE_COLOR_MATERIAL: + CALL_ColorMaterial(ctx->Exec, (n[1].e, n[2].e)); + break; + case OPCODE_COLOR_TABLE: + { + const struct gl_pixelstore_attrib save = ctx->Unpack; + ctx->Unpack = ctx->DefaultPacking; + CALL_ColorTable(ctx->Exec, (n[1].e, n[2].e, n[3].i, n[4].e, + n[5].e, n[6].data)); + ctx->Unpack = save; /* restore */ + } + break; + case OPCODE_COLOR_TABLE_PARAMETER_FV: + { + GLfloat params[4]; + params[0] = n[3].f; + params[1] = n[4].f; + params[2] = n[5].f; + params[3] = n[6].f; + CALL_ColorTableParameterfv(ctx->Exec, + (n[1].e, n[2].e, params)); + } + break; + case OPCODE_COLOR_TABLE_PARAMETER_IV: + { + GLint params[4]; + params[0] = n[3].i; + params[1] = n[4].i; + params[2] = n[5].i; + params[3] = n[6].i; + CALL_ColorTableParameteriv(ctx->Exec, + (n[1].e, n[2].e, params)); + } + break; + case OPCODE_COLOR_SUB_TABLE: + { + const struct gl_pixelstore_attrib save = ctx->Unpack; + ctx->Unpack = ctx->DefaultPacking; + CALL_ColorSubTable(ctx->Exec, (n[1].e, n[2].i, n[3].i, + n[4].e, n[5].e, n[6].data)); + ctx->Unpack = save; /* restore */ + } + break; + case OPCODE_CONVOLUTION_FILTER_1D: + { + const struct gl_pixelstore_attrib save = ctx->Unpack; + ctx->Unpack = ctx->DefaultPacking; + CALL_ConvolutionFilter1D(ctx->Exec, (n[1].e, n[2].i, n[3].i, + n[4].e, n[5].e, + n[6].data)); + ctx->Unpack = save; /* restore */ + } + break; + case OPCODE_CONVOLUTION_FILTER_2D: + { + const struct gl_pixelstore_attrib save = ctx->Unpack; + ctx->Unpack = ctx->DefaultPacking; + CALL_ConvolutionFilter2D(ctx->Exec, (n[1].e, n[2].i, n[3].i, + n[4].i, n[5].e, n[6].e, + n[7].data)); + ctx->Unpack = save; /* restore */ + } + break; + case OPCODE_CONVOLUTION_PARAMETER_I: + CALL_ConvolutionParameteri(ctx->Exec, (n[1].e, n[2].e, n[3].i)); + break; + case OPCODE_CONVOLUTION_PARAMETER_IV: + { + GLint params[4]; + params[0] = n[3].i; + params[1] = n[4].i; + params[2] = n[5].i; + params[3] = n[6].i; + CALL_ConvolutionParameteriv(ctx->Exec, + (n[1].e, n[2].e, params)); + } + break; + case OPCODE_CONVOLUTION_PARAMETER_F: + CALL_ConvolutionParameterf(ctx->Exec, (n[1].e, n[2].e, n[3].f)); + break; + case OPCODE_CONVOLUTION_PARAMETER_FV: + { + GLfloat params[4]; + params[0] = n[3].f; + params[1] = n[4].f; + params[2] = n[5].f; + params[3] = n[6].f; + CALL_ConvolutionParameterfv(ctx->Exec, + (n[1].e, n[2].e, params)); + } + break; + case OPCODE_COPY_COLOR_SUB_TABLE: + CALL_CopyColorSubTable(ctx->Exec, (n[1].e, n[2].i, + n[3].i, n[4].i, n[5].i)); + break; + case OPCODE_COPY_COLOR_TABLE: + CALL_CopyColorSubTable(ctx->Exec, (n[1].e, n[2].i, + n[3].i, n[4].i, n[5].i)); + break; + case OPCODE_COPY_PIXELS: + CALL_CopyPixels(ctx->Exec, (n[1].i, n[2].i, + (GLsizei) n[3].i, (GLsizei) n[4].i, + n[5].e)); + break; + case OPCODE_COPY_TEX_IMAGE1D: + CALL_CopyTexImage1D(ctx->Exec, (n[1].e, n[2].i, n[3].e, n[4].i, + n[5].i, n[6].i, n[7].i)); + break; + case OPCODE_COPY_TEX_IMAGE2D: + CALL_CopyTexImage2D(ctx->Exec, (n[1].e, n[2].i, n[3].e, n[4].i, + n[5].i, n[6].i, n[7].i, n[8].i)); + break; + case OPCODE_COPY_TEX_SUB_IMAGE1D: + CALL_CopyTexSubImage1D(ctx->Exec, (n[1].e, n[2].i, n[3].i, + n[4].i, n[5].i, n[6].i)); + break; + case OPCODE_COPY_TEX_SUB_IMAGE2D: + CALL_CopyTexSubImage2D(ctx->Exec, (n[1].e, n[2].i, n[3].i, + n[4].i, n[5].i, n[6].i, n[7].i, + n[8].i)); + break; + case OPCODE_COPY_TEX_SUB_IMAGE3D: + CALL_CopyTexSubImage3D(ctx->Exec, (n[1].e, n[2].i, n[3].i, + n[4].i, n[5].i, n[6].i, n[7].i, + n[8].i, n[9].i)); + break; + case OPCODE_CULL_FACE: + CALL_CullFace(ctx->Exec, (n[1].e)); + break; + case OPCODE_DEPTH_FUNC: + CALL_DepthFunc(ctx->Exec, (n[1].e)); + break; + case OPCODE_DEPTH_MASK: + CALL_DepthMask(ctx->Exec, (n[1].b)); + break; + case OPCODE_DEPTH_RANGE: + CALL_DepthRange(ctx->Exec, + ((GLclampd) n[1].f, (GLclampd) n[2].f)); + break; + case OPCODE_DISABLE: + CALL_Disable(ctx->Exec, (n[1].e)); + break; + case OPCODE_DISABLE_INDEXED: + CALL_DisableIndexedEXT(ctx->Exec, (n[1].ui, n[2].e)); + break; + case OPCODE_DRAW_BUFFER: + CALL_DrawBuffer(ctx->Exec, (n[1].e)); + break; + case OPCODE_DRAW_PIXELS: + { + const struct gl_pixelstore_attrib save = ctx->Unpack; + ctx->Unpack = ctx->DefaultPacking; + CALL_DrawPixels(ctx->Exec, (n[1].i, n[2].i, n[3].e, n[4].e, + n[5].data)); + ctx->Unpack = save; /* restore */ + } + break; + case OPCODE_ENABLE: + CALL_Enable(ctx->Exec, (n[1].e)); + break; + case OPCODE_ENABLE_INDEXED: + CALL_EnableIndexedEXT(ctx->Exec, (n[1].ui, n[2].e)); + break; + case OPCODE_EVALMESH1: + CALL_EvalMesh1(ctx->Exec, (n[1].e, n[2].i, n[3].i)); + break; + case OPCODE_EVALMESH2: + CALL_EvalMesh2(ctx->Exec, + (n[1].e, n[2].i, n[3].i, n[4].i, n[5].i)); + break; + case OPCODE_FOG: + { + GLfloat p[4]; + p[0] = n[2].f; + p[1] = n[3].f; + p[2] = n[4].f; + p[3] = n[5].f; + CALL_Fogfv(ctx->Exec, (n[1].e, p)); + } + break; + case OPCODE_FRONT_FACE: + CALL_FrontFace(ctx->Exec, (n[1].e)); + break; + case OPCODE_FRUSTUM: + CALL_Frustum(ctx->Exec, + (n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f)); + break; + case OPCODE_HINT: + CALL_Hint(ctx->Exec, (n[1].e, n[2].e)); + break; + case OPCODE_HISTOGRAM: + CALL_Histogram(ctx->Exec, (n[1].e, n[2].i, n[3].e, n[4].b)); + break; + case OPCODE_INDEX_MASK: + CALL_IndexMask(ctx->Exec, (n[1].ui)); + break; + case OPCODE_INIT_NAMES: + CALL_InitNames(ctx->Exec, ()); + break; + case OPCODE_LIGHT: + { + GLfloat p[4]; + p[0] = n[3].f; + p[1] = n[4].f; + p[2] = n[5].f; + p[3] = n[6].f; + CALL_Lightfv(ctx->Exec, (n[1].e, n[2].e, p)); + } + break; + case OPCODE_LIGHT_MODEL: + { + GLfloat p[4]; + p[0] = n[2].f; + p[1] = n[3].f; + p[2] = n[4].f; + p[3] = n[5].f; + CALL_LightModelfv(ctx->Exec, (n[1].e, p)); + } + break; + case OPCODE_LINE_STIPPLE: + CALL_LineStipple(ctx->Exec, (n[1].i, n[2].us)); + break; + case OPCODE_LINE_WIDTH: + CALL_LineWidth(ctx->Exec, (n[1].f)); + break; + case OPCODE_LIST_BASE: + CALL_ListBase(ctx->Exec, (n[1].ui)); + break; + case OPCODE_LOAD_IDENTITY: + CALL_LoadIdentity(ctx->Exec, ()); + break; + case OPCODE_LOAD_MATRIX: + if (sizeof(Node) == sizeof(GLfloat)) { + CALL_LoadMatrixf(ctx->Exec, (&n[1].f)); + } + else { + GLfloat m[16]; + GLuint i; + for (i = 0; i < 16; i++) { + m[i] = n[1 + i].f; + } + CALL_LoadMatrixf(ctx->Exec, (m)); + } + break; + case OPCODE_LOAD_NAME: + CALL_LoadName(ctx->Exec, (n[1].ui)); + break; + case OPCODE_LOGIC_OP: + CALL_LogicOp(ctx->Exec, (n[1].e)); + break; + case OPCODE_MAP1: + { + GLenum target = n[1].e; + GLint ustride = _mesa_evaluator_components(target); + GLint uorder = n[5].i; + GLfloat u1 = n[2].f; + GLfloat u2 = n[3].f; + CALL_Map1f(ctx->Exec, (target, u1, u2, ustride, uorder, + (GLfloat *) n[6].data)); + } + break; + case OPCODE_MAP2: + { + GLenum target = n[1].e; + GLfloat u1 = n[2].f; + GLfloat u2 = n[3].f; + GLfloat v1 = n[4].f; + GLfloat v2 = n[5].f; + GLint ustride = n[6].i; + GLint vstride = n[7].i; + GLint uorder = n[8].i; + GLint vorder = n[9].i; + CALL_Map2f(ctx->Exec, (target, u1, u2, ustride, uorder, + v1, v2, vstride, vorder, + (GLfloat *) n[10].data)); + } + break; + case OPCODE_MAPGRID1: + CALL_MapGrid1f(ctx->Exec, (n[1].i, n[2].f, n[3].f)); + break; + case OPCODE_MAPGRID2: + CALL_MapGrid2f(ctx->Exec, + (n[1].i, n[2].f, n[3].f, n[4].i, n[5].f, n[6].f)); + break; + case OPCODE_MATRIX_MODE: + CALL_MatrixMode(ctx->Exec, (n[1].e)); + break; + case OPCODE_MIN_MAX: + CALL_Minmax(ctx->Exec, (n[1].e, n[2].e, n[3].b)); + break; + case OPCODE_MULT_MATRIX: + if (sizeof(Node) == sizeof(GLfloat)) { + CALL_MultMatrixf(ctx->Exec, (&n[1].f)); + } + else { + GLfloat m[16]; + GLuint i; + for (i = 0; i < 16; i++) { + m[i] = n[1 + i].f; + } + CALL_MultMatrixf(ctx->Exec, (m)); + } + break; + case OPCODE_ORTHO: + CALL_Ortho(ctx->Exec, + (n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f)); + break; + case OPCODE_PASSTHROUGH: + CALL_PassThrough(ctx->Exec, (n[1].f)); + break; + case OPCODE_PIXEL_MAP: + CALL_PixelMapfv(ctx->Exec, + (n[1].e, n[2].i, (GLfloat *) n[3].data)); + break; + case OPCODE_PIXEL_TRANSFER: + CALL_PixelTransferf(ctx->Exec, (n[1].e, n[2].f)); + break; + case OPCODE_PIXEL_ZOOM: + CALL_PixelZoom(ctx->Exec, (n[1].f, n[2].f)); + break; + case OPCODE_POINT_SIZE: + CALL_PointSize(ctx->Exec, (n[1].f)); + break; + case OPCODE_POINT_PARAMETERS: + { + GLfloat params[3]; + params[0] = n[2].f; + params[1] = n[3].f; + params[2] = n[4].f; + CALL_PointParameterfvEXT(ctx->Exec, (n[1].e, params)); + } + break; + case OPCODE_POLYGON_MODE: + CALL_PolygonMode(ctx->Exec, (n[1].e, n[2].e)); + break; + case OPCODE_POLYGON_STIPPLE: + { + const struct gl_pixelstore_attrib save = ctx->Unpack; + ctx->Unpack = ctx->DefaultPacking; + CALL_PolygonStipple(ctx->Exec, ((GLubyte *) n[1].data)); + ctx->Unpack = save; /* restore */ + } + break; + case OPCODE_POLYGON_OFFSET: + CALL_PolygonOffset(ctx->Exec, (n[1].f, n[2].f)); + break; + case OPCODE_POP_ATTRIB: + CALL_PopAttrib(ctx->Exec, ()); + break; + case OPCODE_POP_MATRIX: + CALL_PopMatrix(ctx->Exec, ()); + break; + case OPCODE_POP_NAME: + CALL_PopName(ctx->Exec, ()); + break; + case OPCODE_PRIORITIZE_TEXTURE: + CALL_PrioritizeTextures(ctx->Exec, (1, &n[1].ui, &n[2].f)); + break; + case OPCODE_PUSH_ATTRIB: + CALL_PushAttrib(ctx->Exec, (n[1].bf)); + break; + case OPCODE_PUSH_MATRIX: + CALL_PushMatrix(ctx->Exec, ()); + break; + case OPCODE_PUSH_NAME: + CALL_PushName(ctx->Exec, (n[1].ui)); + break; + case OPCODE_RASTER_POS: + CALL_RasterPos4f(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f)); + break; + case OPCODE_READ_BUFFER: + CALL_ReadBuffer(ctx->Exec, (n[1].e)); + break; + case OPCODE_RESET_HISTOGRAM: + CALL_ResetHistogram(ctx->Exec, (n[1].e)); + break; + case OPCODE_RESET_MIN_MAX: + CALL_ResetMinmax(ctx->Exec, (n[1].e)); + break; + case OPCODE_ROTATE: + CALL_Rotatef(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f)); + break; + case OPCODE_SCALE: + CALL_Scalef(ctx->Exec, (n[1].f, n[2].f, n[3].f)); + break; + case OPCODE_SCISSOR: + CALL_Scissor(ctx->Exec, (n[1].i, n[2].i, n[3].i, n[4].i)); + break; + case OPCODE_SHADE_MODEL: + CALL_ShadeModel(ctx->Exec, (n[1].e)); + break; + case OPCODE_PROVOKING_VERTEX: + CALL_ProvokingVertexEXT(ctx->Exec, (n[1].e)); + break; + case OPCODE_STENCIL_FUNC: + CALL_StencilFunc(ctx->Exec, (n[1].e, n[2].i, n[3].ui)); + break; + case OPCODE_STENCIL_MASK: + CALL_StencilMask(ctx->Exec, (n[1].ui)); + break; + case OPCODE_STENCIL_OP: + CALL_StencilOp(ctx->Exec, (n[1].e, n[2].e, n[3].e)); + break; + case OPCODE_STENCIL_FUNC_SEPARATE: + CALL_StencilFuncSeparate(ctx->Exec, + (n[1].e, n[2].e, n[3].i, n[4].ui)); + break; + case OPCODE_STENCIL_MASK_SEPARATE: + CALL_StencilMaskSeparate(ctx->Exec, (n[1].e, n[2].ui)); + break; + case OPCODE_STENCIL_OP_SEPARATE: + CALL_StencilOpSeparate(ctx->Exec, + (n[1].e, n[2].e, n[3].e, n[4].e)); + break; + case OPCODE_TEXENV: + { + GLfloat params[4]; + params[0] = n[3].f; + params[1] = n[4].f; + params[2] = n[5].f; + params[3] = n[6].f; + CALL_TexEnvfv(ctx->Exec, (n[1].e, n[2].e, params)); + } + break; + case OPCODE_TEXGEN: + { + GLfloat params[4]; + params[0] = n[3].f; + params[1] = n[4].f; + params[2] = n[5].f; + params[3] = n[6].f; + CALL_TexGenfv(ctx->Exec, (n[1].e, n[2].e, params)); + } + break; + case OPCODE_TEXPARAMETER: + { + GLfloat params[4]; + params[0] = n[3].f; + params[1] = n[4].f; + params[2] = n[5].f; + params[3] = n[6].f; + CALL_TexParameterfv(ctx->Exec, (n[1].e, n[2].e, params)); + } + break; + case OPCODE_TEX_IMAGE1D: + { + const struct gl_pixelstore_attrib save = ctx->Unpack; + ctx->Unpack = ctx->DefaultPacking; + CALL_TexImage1D(ctx->Exec, (n[1].e, /* target */ + n[2].i, /* level */ + n[3].i, /* components */ + n[4].i, /* width */ + n[5].e, /* border */ + n[6].e, /* format */ + n[7].e, /* type */ + n[8].data)); + ctx->Unpack = save; /* restore */ + } + break; + case OPCODE_TEX_IMAGE2D: + { + const struct gl_pixelstore_attrib save = ctx->Unpack; + ctx->Unpack = ctx->DefaultPacking; + CALL_TexImage2D(ctx->Exec, (n[1].e, /* target */ + n[2].i, /* level */ + n[3].i, /* components */ + n[4].i, /* width */ + n[5].i, /* height */ + n[6].e, /* border */ + n[7].e, /* format */ + n[8].e, /* type */ + n[9].data)); + ctx->Unpack = save; /* restore */ + } + break; + case OPCODE_TEX_IMAGE3D: + { + const struct gl_pixelstore_attrib save = ctx->Unpack; + ctx->Unpack = ctx->DefaultPacking; + CALL_TexImage3D(ctx->Exec, (n[1].e, /* target */ + n[2].i, /* level */ + n[3].i, /* components */ + n[4].i, /* width */ + n[5].i, /* height */ + n[6].i, /* depth */ + n[7].e, /* border */ + n[8].e, /* format */ + n[9].e, /* type */ + n[10].data)); + ctx->Unpack = save; /* restore */ + } + break; + case OPCODE_TEX_SUB_IMAGE1D: + { + const struct gl_pixelstore_attrib save = ctx->Unpack; + ctx->Unpack = ctx->DefaultPacking; + CALL_TexSubImage1D(ctx->Exec, (n[1].e, n[2].i, n[3].i, + n[4].i, n[5].e, + n[6].e, n[7].data)); + ctx->Unpack = save; /* restore */ + } + break; + case OPCODE_TEX_SUB_IMAGE2D: + { + const struct gl_pixelstore_attrib save = ctx->Unpack; + ctx->Unpack = ctx->DefaultPacking; + CALL_TexSubImage2D(ctx->Exec, (n[1].e, n[2].i, n[3].i, + n[4].i, n[5].e, + n[6].i, n[7].e, n[8].e, + n[9].data)); + ctx->Unpack = save; /* restore */ + } + break; + case OPCODE_TEX_SUB_IMAGE3D: + { + const struct gl_pixelstore_attrib save = ctx->Unpack; + ctx->Unpack = ctx->DefaultPacking; + CALL_TexSubImage3D(ctx->Exec, (n[1].e, n[2].i, n[3].i, + n[4].i, n[5].i, n[6].i, n[7].i, + n[8].i, n[9].e, n[10].e, + n[11].data)); + ctx->Unpack = save; /* restore */ + } + break; + case OPCODE_TRANSLATE: + CALL_Translatef(ctx->Exec, (n[1].f, n[2].f, n[3].f)); + break; + case OPCODE_VIEWPORT: + CALL_Viewport(ctx->Exec, (n[1].i, n[2].i, + (GLsizei) n[3].i, (GLsizei) n[4].i)); + break; + case OPCODE_WINDOW_POS: + CALL_WindowPos4fMESA(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f)); + break; + case OPCODE_ACTIVE_TEXTURE: /* GL_ARB_multitexture */ + CALL_ActiveTextureARB(ctx->Exec, (n[1].e)); + break; + case OPCODE_COMPRESSED_TEX_IMAGE_1D: /* GL_ARB_texture_compression */ + CALL_CompressedTexImage1DARB(ctx->Exec, (n[1].e, n[2].i, n[3].e, + n[4].i, n[5].i, n[6].i, + n[7].data)); + break; + case OPCODE_COMPRESSED_TEX_IMAGE_2D: /* GL_ARB_texture_compression */ + CALL_CompressedTexImage2DARB(ctx->Exec, (n[1].e, n[2].i, n[3].e, + n[4].i, n[5].i, n[6].i, + n[7].i, n[8].data)); + break; + case OPCODE_COMPRESSED_TEX_IMAGE_3D: /* GL_ARB_texture_compression */ + CALL_CompressedTexImage3DARB(ctx->Exec, (n[1].e, n[2].i, n[3].e, + n[4].i, n[5].i, n[6].i, + n[7].i, n[8].i, + n[9].data)); + break; + case OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D: /* GL_ARB_texture_compress */ + CALL_CompressedTexSubImage1DARB(ctx->Exec, + (n[1].e, n[2].i, n[3].i, n[4].i, + n[5].e, n[6].i, n[7].data)); + break; + case OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D: /* GL_ARB_texture_compress */ + CALL_CompressedTexSubImage2DARB(ctx->Exec, + (n[1].e, n[2].i, n[3].i, n[4].i, + n[5].i, n[6].i, n[7].e, n[8].i, + n[9].data)); + break; + case OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D: /* GL_ARB_texture_compress */ + CALL_CompressedTexSubImage3DARB(ctx->Exec, + (n[1].e, n[2].i, n[3].i, n[4].i, + n[5].i, n[6].i, n[7].i, n[8].i, + n[9].e, n[10].i, n[11].data)); + break; + case OPCODE_SAMPLE_COVERAGE: /* GL_ARB_multisample */ + CALL_SampleCoverageARB(ctx->Exec, (n[1].f, n[2].b)); + break; + case OPCODE_WINDOW_POS_ARB: /* GL_ARB_window_pos */ + CALL_WindowPos3fMESA(ctx->Exec, (n[1].f, n[2].f, n[3].f)); + break; +#if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program + case OPCODE_BIND_PROGRAM_NV: /* GL_NV_vertex_program */ + CALL_BindProgramNV(ctx->Exec, (n[1].e, n[2].ui)); + break; +#endif +#if FEATURE_NV_vertex_program + case OPCODE_EXECUTE_PROGRAM_NV: + { + GLfloat v[4]; + v[0] = n[3].f; + v[1] = n[4].f; + v[2] = n[5].f; + v[3] = n[6].f; + CALL_ExecuteProgramNV(ctx->Exec, (n[1].e, n[2].ui, v)); + } + break; + case OPCODE_REQUEST_RESIDENT_PROGRAMS_NV: + CALL_RequestResidentProgramsNV(ctx->Exec, (n[1].ui, + (GLuint *) n[2].data)); + break; + case OPCODE_LOAD_PROGRAM_NV: + CALL_LoadProgramNV(ctx->Exec, (n[1].e, n[2].ui, n[3].i, + (const GLubyte *) n[4].data)); + break; + case OPCODE_TRACK_MATRIX_NV: + CALL_TrackMatrixNV(ctx->Exec, (n[1].e, n[2].ui, n[3].e, n[4].e)); + break; +#endif + +#if FEATURE_NV_fragment_program + case OPCODE_PROGRAM_LOCAL_PARAMETER_ARB: + CALL_ProgramLocalParameter4fARB(ctx->Exec, + (n[1].e, n[2].ui, n[3].f, n[4].f, + n[5].f, n[6].f)); + break; + case OPCODE_PROGRAM_NAMED_PARAMETER_NV: + CALL_ProgramNamedParameter4fNV(ctx->Exec, (n[1].ui, n[2].i, + (const GLubyte *) n[3]. + data, n[4].f, n[5].f, + n[6].f, n[7].f)); + break; +#endif + + case OPCODE_ACTIVE_STENCIL_FACE_EXT: + CALL_ActiveStencilFaceEXT(ctx->Exec, (n[1].e)); + break; + case OPCODE_DEPTH_BOUNDS_EXT: + CALL_DepthBoundsEXT(ctx->Exec, (n[1].f, n[2].f)); + break; +#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program + case OPCODE_PROGRAM_STRING_ARB: + CALL_ProgramStringARB(ctx->Exec, + (n[1].e, n[2].e, n[3].i, n[4].data)); + break; +#endif +#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program || FEATURE_NV_vertex_program + case OPCODE_PROGRAM_ENV_PARAMETER_ARB: + CALL_ProgramEnvParameter4fARB(ctx->Exec, (n[1].e, n[2].ui, n[3].f, + n[4].f, n[5].f, + n[6].f)); + break; +#endif +#if FEATURE_queryobj + case OPCODE_BEGIN_QUERY_ARB: + CALL_BeginQueryARB(ctx->Exec, (n[1].e, n[2].ui)); + break; + case OPCODE_END_QUERY_ARB: + CALL_EndQueryARB(ctx->Exec, (n[1].e)); + break; +#endif + case OPCODE_DRAW_BUFFERS_ARB: + { + GLenum buffers[MAX_DRAW_BUFFERS]; + GLint i, count = MIN2(n[1].i, MAX_DRAW_BUFFERS); + for (i = 0; i < count; i++) + buffers[i] = n[2 + i].e; + CALL_DrawBuffersARB(ctx->Exec, (n[1].i, buffers)); + } + break; +#if FEATURE_EXT_framebuffer_blit + case OPCODE_BLIT_FRAMEBUFFER: + CALL_BlitFramebufferEXT(ctx->Exec, (n[1].i, n[2].i, n[3].i, n[4].i, + n[5].i, n[6].i, n[7].i, n[8].i, + n[9].i, n[10].e)); + break; +#endif + + case OPCODE_USE_PROGRAM: + CALL_UseProgramObjectARB(ctx->Exec, (n[1].ui)); + break; + case OPCODE_USE_SHADER_PROGRAM_EXT: + CALL_UseShaderProgramEXT(ctx->Exec, (n[1].ui, n[2].ui)); + break; + case OPCODE_ACTIVE_PROGRAM_EXT: + CALL_ActiveProgramEXT(ctx->Exec, (n[1].ui)); + break; + case OPCODE_UNIFORM_1F: + CALL_Uniform1fARB(ctx->Exec, (n[1].i, n[2].f)); + break; + case OPCODE_UNIFORM_2F: + CALL_Uniform2fARB(ctx->Exec, (n[1].i, n[2].f, n[3].f)); + break; + case OPCODE_UNIFORM_3F: + CALL_Uniform3fARB(ctx->Exec, (n[1].i, n[2].f, n[3].f, n[4].f)); + break; + case OPCODE_UNIFORM_4F: + CALL_Uniform4fARB(ctx->Exec, + (n[1].i, n[2].f, n[3].f, n[4].f, n[5].f)); + break; + case OPCODE_UNIFORM_1FV: + CALL_Uniform1fvARB(ctx->Exec, (n[1].i, n[2].i, n[3].data)); + break; + case OPCODE_UNIFORM_2FV: + CALL_Uniform2fvARB(ctx->Exec, (n[1].i, n[2].i, n[3].data)); + break; + case OPCODE_UNIFORM_3FV: + CALL_Uniform3fvARB(ctx->Exec, (n[1].i, n[2].i, n[3].data)); + break; + case OPCODE_UNIFORM_4FV: + CALL_Uniform4fvARB(ctx->Exec, (n[1].i, n[2].i, n[3].data)); + break; + case OPCODE_UNIFORM_1I: + CALL_Uniform1iARB(ctx->Exec, (n[1].i, n[2].i)); + break; + case OPCODE_UNIFORM_2I: + CALL_Uniform2iARB(ctx->Exec, (n[1].i, n[2].i, n[3].i)); + break; + case OPCODE_UNIFORM_3I: + CALL_Uniform3iARB(ctx->Exec, (n[1].i, n[2].i, n[3].i, n[4].i)); + break; + case OPCODE_UNIFORM_4I: + CALL_Uniform4iARB(ctx->Exec, + (n[1].i, n[2].i, n[3].i, n[4].i, n[5].i)); + break; + case OPCODE_UNIFORM_1IV: + CALL_Uniform1ivARB(ctx->Exec, (n[1].i, n[2].i, n[3].data)); + break; + case OPCODE_UNIFORM_2IV: + CALL_Uniform2ivARB(ctx->Exec, (n[1].i, n[2].i, n[3].data)); + break; + case OPCODE_UNIFORM_3IV: + CALL_Uniform3ivARB(ctx->Exec, (n[1].i, n[2].i, n[3].data)); + break; + case OPCODE_UNIFORM_4IV: + CALL_Uniform4ivARB(ctx->Exec, (n[1].i, n[2].i, n[3].data)); + break; + case OPCODE_UNIFORM_1UI: + /*CALL_Uniform1uiARB(ctx->Exec, (n[1].i, n[2].i));*/ + break; + case OPCODE_UNIFORM_2UI: + /*CALL_Uniform2uiARB(ctx->Exec, (n[1].i, n[2].i, n[3].i));*/ + break; + case OPCODE_UNIFORM_3UI: + /*CALL_Uniform3uiARB(ctx->Exec, (n[1].i, n[2].i, n[3].i, n[4].i));*/ + break; + case OPCODE_UNIFORM_4UI: + /*CALL_Uniform4uiARB(ctx->Exec, + (n[1].i, n[2].i, n[3].i, n[4].i, n[5].i)); + */ + break; + case OPCODE_UNIFORM_1UIV: + /*CALL_Uniform1uivARB(ctx->Exec, (n[1].i, n[2].i, n[3].data));*/ + break; + case OPCODE_UNIFORM_2UIV: + /*CALL_Uniform2uivARB(ctx->Exec, (n[1].i, n[2].i, n[3].data));*/ + break; + case OPCODE_UNIFORM_3UIV: + /*CALL_Uniform3uivARB(ctx->Exec, (n[1].i, n[2].i, n[3].data));*/ + break; + case OPCODE_UNIFORM_4UIV: + /*CALL_Uniform4uivARB(ctx->Exec, (n[1].i, n[2].i, n[3].data));*/ + break; + case OPCODE_UNIFORM_MATRIX22: + CALL_UniformMatrix2fvARB(ctx->Exec, + (n[1].i, n[2].i, n[3].b, n[4].data)); + break; + case OPCODE_UNIFORM_MATRIX33: + CALL_UniformMatrix3fvARB(ctx->Exec, + (n[1].i, n[2].i, n[3].b, n[4].data)); + break; + case OPCODE_UNIFORM_MATRIX44: + CALL_UniformMatrix4fvARB(ctx->Exec, + (n[1].i, n[2].i, n[3].b, n[4].data)); + break; + case OPCODE_UNIFORM_MATRIX23: + CALL_UniformMatrix2x3fv(ctx->Exec, + (n[1].i, n[2].i, n[3].b, n[4].data)); + break; + case OPCODE_UNIFORM_MATRIX32: + CALL_UniformMatrix3x2fv(ctx->Exec, + (n[1].i, n[2].i, n[3].b, n[4].data)); + break; + case OPCODE_UNIFORM_MATRIX24: + CALL_UniformMatrix2x4fv(ctx->Exec, + (n[1].i, n[2].i, n[3].b, n[4].data)); + break; + case OPCODE_UNIFORM_MATRIX42: + CALL_UniformMatrix4x2fv(ctx->Exec, + (n[1].i, n[2].i, n[3].b, n[4].data)); + break; + case OPCODE_UNIFORM_MATRIX34: + CALL_UniformMatrix3x4fv(ctx->Exec, + (n[1].i, n[2].i, n[3].b, n[4].data)); + break; + case OPCODE_UNIFORM_MATRIX43: + CALL_UniformMatrix4x3fv(ctx->Exec, + (n[1].i, n[2].i, n[3].b, n[4].data)); + break; + + case OPCODE_CLAMP_COLOR: + CALL_ClampColorARB(ctx->Exec, (n[1].e, n[2].e)); + break; + + case OPCODE_TEX_BUMP_PARAMETER_ATI: + { + GLfloat values[4]; + GLuint i, pname = n[1].ui; + + for (i = 0; i < 4; i++) + values[i] = n[1 + i].f; + CALL_TexBumpParameterfvATI(ctx->Exec, (pname, values)); + } + break; +#if FEATURE_ATI_fragment_shader + case OPCODE_BIND_FRAGMENT_SHADER_ATI: + CALL_BindFragmentShaderATI(ctx->Exec, (n[1].i)); + break; + case OPCODE_SET_FRAGMENT_SHADER_CONSTANTS_ATI: + { + GLfloat values[4]; + GLuint i, dst = n[1].ui; + + for (i = 0; i < 4; i++) + values[i] = n[1 + i].f; + CALL_SetFragmentShaderConstantATI(ctx->Exec, (dst, values)); + } + break; +#endif + case OPCODE_ATTR_1F_NV: + CALL_VertexAttrib1fNV(ctx->Exec, (n[1].e, n[2].f)); + break; + case OPCODE_ATTR_2F_NV: + /* Really shouldn't have to do this - the Node structure + * is convenient, but it would be better to store the data + * packed appropriately so that it can be sent directly + * on. With x86_64 becoming common, this will start to + * matter more. + */ + if (sizeof(Node) == sizeof(GLfloat)) + CALL_VertexAttrib2fvNV(ctx->Exec, (n[1].e, &n[2].f)); + else + CALL_VertexAttrib2fNV(ctx->Exec, (n[1].e, n[2].f, n[3].f)); + break; + case OPCODE_ATTR_3F_NV: + if (sizeof(Node) == sizeof(GLfloat)) + CALL_VertexAttrib3fvNV(ctx->Exec, (n[1].e, &n[2].f)); + else + CALL_VertexAttrib3fNV(ctx->Exec, (n[1].e, n[2].f, n[3].f, + n[4].f)); + break; + case OPCODE_ATTR_4F_NV: + if (sizeof(Node) == sizeof(GLfloat)) + CALL_VertexAttrib4fvNV(ctx->Exec, (n[1].e, &n[2].f)); + else + CALL_VertexAttrib4fNV(ctx->Exec, (n[1].e, n[2].f, n[3].f, + n[4].f, n[5].f)); + break; + case OPCODE_ATTR_1F_ARB: + CALL_VertexAttrib1fARB(ctx->Exec, (n[1].e, n[2].f)); + break; + case OPCODE_ATTR_2F_ARB: + /* Really shouldn't have to do this - the Node structure + * is convenient, but it would be better to store the data + * packed appropriately so that it can be sent directly + * on. With x86_64 becoming common, this will start to + * matter more. + */ + if (sizeof(Node) == sizeof(GLfloat)) + CALL_VertexAttrib2fvARB(ctx->Exec, (n[1].e, &n[2].f)); + else + CALL_VertexAttrib2fARB(ctx->Exec, (n[1].e, n[2].f, n[3].f)); + break; + case OPCODE_ATTR_3F_ARB: + if (sizeof(Node) == sizeof(GLfloat)) + CALL_VertexAttrib3fvARB(ctx->Exec, (n[1].e, &n[2].f)); + else + CALL_VertexAttrib3fARB(ctx->Exec, (n[1].e, n[2].f, n[3].f, + n[4].f)); + break; + case OPCODE_ATTR_4F_ARB: + if (sizeof(Node) == sizeof(GLfloat)) + CALL_VertexAttrib4fvARB(ctx->Exec, (n[1].e, &n[2].f)); + else + CALL_VertexAttrib4fARB(ctx->Exec, (n[1].e, n[2].f, n[3].f, + n[4].f, n[5].f)); + break; + case OPCODE_MATERIAL: + if (sizeof(Node) == sizeof(GLfloat)) + CALL_Materialfv(ctx->Exec, (n[1].e, n[2].e, &n[3].f)); + else { + GLfloat f[4]; + f[0] = n[3].f; + f[1] = n[4].f; + f[2] = n[5].f; + f[3] = n[6].f; + CALL_Materialfv(ctx->Exec, (n[1].e, n[2].e, f)); + } + break; + case OPCODE_BEGIN: + CALL_Begin(ctx->Exec, (n[1].e)); + break; + case OPCODE_END: + CALL_End(ctx->Exec, ()); + break; + case OPCODE_RECTF: + CALL_Rectf(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f)); + break; + case OPCODE_EVAL_C1: + CALL_EvalCoord1f(ctx->Exec, (n[1].f)); + break; + case OPCODE_EVAL_C2: + CALL_EvalCoord2f(ctx->Exec, (n[1].f, n[2].f)); + break; + case OPCODE_EVAL_P1: + CALL_EvalPoint1(ctx->Exec, (n[1].i)); + break; + case OPCODE_EVAL_P2: + CALL_EvalPoint2(ctx->Exec, (n[1].i, n[2].i)); + break; + + /* GL_EXT_texture_integer */ + case OPCODE_CLEARCOLOR_I: + CALL_ClearColorIiEXT(ctx->Exec, (n[1].i, n[2].i, n[3].i, n[4].i)); + break; + case OPCODE_CLEARCOLOR_UI: + CALL_ClearColorIuiEXT(ctx->Exec, + (n[1].ui, n[2].ui, n[3].ui, n[4].ui)); + break; + case OPCODE_TEXPARAMETER_I: + { + GLint params[4]; + params[0] = n[3].i; + params[1] = n[4].i; + params[2] = n[5].i; + params[3] = n[6].i; + CALL_TexParameterIivEXT(ctx->Exec, (n[1].e, n[2].e, params)); + } + break; + case OPCODE_TEXPARAMETER_UI: + { + GLuint params[4]; + params[0] = n[3].ui; + params[1] = n[4].ui; + params[2] = n[5].ui; + params[3] = n[6].ui; + CALL_TexParameterIuivEXT(ctx->Exec, (n[1].e, n[2].e, params)); + } + break; + + case OPCODE_VERTEX_ATTRIB_DIVISOR: + /* GL_ARB_instanced_arrays */ + CALL_VertexAttribDivisorARB(ctx->Exec, (n[1].ui, n[2].ui)); + break; + + case OPCODE_TEXTURE_BARRIER_NV: + CALL_TextureBarrierNV(ctx->Exec, ()); + break; + + /* GL_EXT/ARB_transform_feedback */ + case OPCODE_BEGIN_TRANSFORM_FEEDBACK: + CALL_BeginTransformFeedbackEXT(ctx->Exec, (n[1].e)); + break; + case OPCODE_END_TRANSFORM_FEEDBACK: + CALL_EndTransformFeedbackEXT(ctx->Exec, ()); + break; + case OPCODE_BIND_TRANSFORM_FEEDBACK: + CALL_BindTransformFeedback(ctx->Exec, (n[1].e, n[2].ui)); + break; + case OPCODE_PAUSE_TRANSFORM_FEEDBACK: + CALL_PauseTransformFeedback(ctx->Exec, ()); + break; + case OPCODE_RESUME_TRANSFORM_FEEDBACK: + CALL_ResumeTransformFeedback(ctx->Exec, ()); + break; + case OPCODE_DRAW_TRANSFORM_FEEDBACK: + CALL_DrawTransformFeedback(ctx->Exec, (n[1].e, n[2].ui)); + break; + + + case OPCODE_BIND_SAMPLER: + CALL_BindSampler(ctx->Exec, (n[1].ui, n[2].ui)); + break; + case OPCODE_SAMPLER_PARAMETERIV: + { + GLint params[4]; + params[0] = n[3].i; + params[1] = n[4].i; + params[2] = n[5].i; + params[3] = n[6].i; + CALL_SamplerParameteriv(ctx->Exec, (n[1].ui, n[2].e, params)); + } + break; + case OPCODE_SAMPLER_PARAMETERFV: + { + GLfloat params[4]; + params[0] = n[3].f; + params[1] = n[4].f; + params[2] = n[5].f; + params[3] = n[6].f; + CALL_SamplerParameterfv(ctx->Exec, (n[1].ui, n[2].e, params)); + } + break; + case OPCODE_SAMPLER_PARAMETERIIV: + { + GLint params[4]; + params[0] = n[3].i; + params[1] = n[4].i; + params[2] = n[5].i; + params[3] = n[6].i; + CALL_SamplerParameterIiv(ctx->Exec, (n[1].ui, n[2].e, params)); + } + break; + case OPCODE_SAMPLER_PARAMETERUIV: + { + GLuint params[4]; + params[0] = n[3].ui; + params[1] = n[4].ui; + params[2] = n[5].ui; + params[3] = n[6].ui; + CALL_SamplerParameterIuiv(ctx->Exec, (n[1].ui, n[2].e, params)); + } + break; + + /* GL_ARB_geometry_shader4 */ + case OPCODE_PROGRAM_PARAMETERI: + CALL_ProgramParameteriARB(ctx->Exec, (n[1].ui, n[2].e, n[3].i)); + break; + case OPCODE_FRAMEBUFFER_TEXTURE: + CALL_FramebufferTextureARB(ctx->Exec, (n[1].e, n[2].e, + n[3].ui, n[4].i)); + break; + case OPCODE_FRAMEBUFFER_TEXTURE_FACE: + CALL_FramebufferTextureFaceARB(ctx->Exec, (n[1].e, n[2].e, + n[3].ui, n[4].i, n[5].e)); + break; + + /* GL_ARB_sync */ + case OPCODE_WAIT_SYNC: + { + union uint64_pair p; + p.uint32[0] = n[3].ui; + p.uint32[1] = n[4].ui; + CALL_WaitSync(ctx->Exec, (n[1].data, n[2].bf, p.uint64)); + } + break; + + case OPCODE_CONTINUE: + n = (Node *) n[1].next; + break; + case OPCODE_END_OF_LIST: + done = GL_TRUE; + break; + default: + { + char msg[1000]; + _mesa_snprintf(msg, sizeof(msg), "Error in execute_list: opcode=%d", + (int) opcode); + _mesa_problem(ctx, "%s", msg); + } + done = GL_TRUE; + } + + /* increment n to point to next compiled command */ + if (opcode != OPCODE_CONTINUE) { + n += InstSize[opcode]; + } + } + } + + if (ctx->Driver.EndCallList) + ctx->Driver.EndCallList(ctx); + + ctx->ListState.CallDepth--; +} + + + +/**********************************************************************/ +/* GL functions */ +/**********************************************************************/ + +/** + * Test if a display list number is valid. + */ +static GLboolean GLAPIENTRY +_mesa_IsList(GLuint list) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); /* must be called before assert */ + ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); + return islist(ctx, list); +} + + +/** + * Delete a sequence of consecutive display lists. + */ +static void GLAPIENTRY +_mesa_DeleteLists(GLuint list, GLsizei range) +{ + GET_CURRENT_CONTEXT(ctx); + GLuint i; + FLUSH_VERTICES(ctx, 0); /* must be called before assert */ + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (range < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glDeleteLists"); + return; + } + for (i = list; i < list + range; i++) { + destroy_list(ctx, i); + } +} + + +/** + * Return a display list number, n, such that lists n through n+range-1 + * are free. + */ +static GLuint GLAPIENTRY +_mesa_GenLists(GLsizei range) +{ + GET_CURRENT_CONTEXT(ctx); + GLuint base; + FLUSH_VERTICES(ctx, 0); /* must be called before assert */ + ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, 0); + + if (range < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glGenLists"); + return 0; + } + if (range == 0) { + return 0; + } + + /* + * Make this an atomic operation + */ + _glthread_LOCK_MUTEX(ctx->Shared->Mutex); + + base = _mesa_HashFindFreeKeyBlock(ctx->Shared->DisplayList, range); + if (base) { + /* reserve the list IDs by with empty/dummy lists */ + GLint i; + for (i = 0; i < range; i++) { + _mesa_HashInsert(ctx->Shared->DisplayList, base + i, + make_list(base + i, 1)); + } + } + + _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); + + return base; +} + + +/** + * Begin a new display list. + */ +static void GLAPIENTRY +_mesa_NewList(GLuint name, GLenum mode) +{ + GET_CURRENT_CONTEXT(ctx); + + FLUSH_CURRENT(ctx, 0); /* must be called before assert */ + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glNewList %u %s\n", name, + _mesa_lookup_enum_by_nr(mode)); + + if (name == 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glNewList"); + return; + } + + if (mode != GL_COMPILE && mode != GL_COMPILE_AND_EXECUTE) { + _mesa_error(ctx, GL_INVALID_ENUM, "glNewList"); + return; + } + + if (ctx->ListState.CurrentList) { + /* already compiling a display list */ + _mesa_error(ctx, GL_INVALID_OPERATION, "glNewList"); + return; + } + + ctx->CompileFlag = GL_TRUE; + ctx->ExecuteFlag = (mode == GL_COMPILE_AND_EXECUTE); + + /* Reset acumulated list state: + */ + invalidate_saved_current_state( ctx ); + + /* Allocate new display list */ + ctx->ListState.CurrentList = make_list(name, BLOCK_SIZE); + ctx->ListState.CurrentBlock = ctx->ListState.CurrentList->Head; + ctx->ListState.CurrentPos = 0; + + ctx->Driver.NewList(ctx, name, mode); + + ctx->CurrentDispatch = ctx->Save; + _glapi_set_dispatch(ctx->CurrentDispatch); +} + + +/** + * End definition of current display list. + */ +static void GLAPIENTRY +_mesa_EndList(void) +{ + GET_CURRENT_CONTEXT(ctx); + SAVE_FLUSH_VERTICES(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glEndList\n"); + + /* Check that a list is under construction */ + if (!ctx->ListState.CurrentList) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glEndList"); + return; + } + + /* Call before emitting END_OF_LIST, in case the driver wants to + * emit opcodes itself. + */ + ctx->Driver.EndList(ctx); + + (void) alloc_instruction(ctx, OPCODE_END_OF_LIST, 0); + + /* Destroy old list, if any */ + destroy_list(ctx, ctx->ListState.CurrentList->Name); + + /* Install the new list */ + _mesa_HashInsert(ctx->Shared->DisplayList, + ctx->ListState.CurrentList->Name, + ctx->ListState.CurrentList); + + + if (MESA_VERBOSE & VERBOSE_DISPLAY_LIST) + mesa_print_display_list(ctx->ListState.CurrentList->Name); + + ctx->ListState.CurrentList = NULL; + ctx->ExecuteFlag = GL_TRUE; + ctx->CompileFlag = GL_FALSE; + + ctx->CurrentDispatch = ctx->Exec; + _glapi_set_dispatch(ctx->CurrentDispatch); +} + + +void GLAPIENTRY +_mesa_CallList(GLuint list) +{ + GLboolean save_compile_flag; + GET_CURRENT_CONTEXT(ctx); + FLUSH_CURRENT(ctx, 0); + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glCallList %d\n", list); + + if (list == 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glCallList(list==0)"); + return; + } + + if (0) + mesa_print_display_list( list ); + + /* VERY IMPORTANT: Save the CompileFlag status, turn it off, + * execute the display list, and restore the CompileFlag. + */ + save_compile_flag = ctx->CompileFlag; + if (save_compile_flag) { + ctx->CompileFlag = GL_FALSE; + } + + execute_list(ctx, list); + ctx->CompileFlag = save_compile_flag; + + /* also restore API function pointers to point to "save" versions */ + if (save_compile_flag) { + ctx->CurrentDispatch = ctx->Save; + _glapi_set_dispatch(ctx->CurrentDispatch); + } +} + + +/** + * Execute glCallLists: call multiple display lists. + */ +void GLAPIENTRY +_mesa_CallLists(GLsizei n, GLenum type, const GLvoid * lists) +{ + GET_CURRENT_CONTEXT(ctx); + GLint i; + GLboolean save_compile_flag; + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glCallLists %d\n", n); + + switch (type) { + case GL_BYTE: + case GL_UNSIGNED_BYTE: + case GL_SHORT: + case GL_UNSIGNED_SHORT: + case GL_INT: + case GL_UNSIGNED_INT: + case GL_FLOAT: + case GL_2_BYTES: + case GL_3_BYTES: + case GL_4_BYTES: + /* OK */ + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, "glCallLists(type)"); + return; + } + + /* Save the CompileFlag status, turn it off, execute display list, + * and restore the CompileFlag. + */ + save_compile_flag = ctx->CompileFlag; + ctx->CompileFlag = GL_FALSE; + + for (i = 0; i < n; i++) { + GLuint list = (GLuint) (ctx->List.ListBase + translate_id(i, type, lists)); + execute_list(ctx, list); + } + + ctx->CompileFlag = save_compile_flag; + + /* also restore API function pointers to point to "save" versions */ + if (save_compile_flag) { + ctx->CurrentDispatch = ctx->Save; + _glapi_set_dispatch(ctx->CurrentDispatch); + } +} + + +/** + * Set the offset added to list numbers in glCallLists. + */ +static void GLAPIENTRY +_mesa_ListBase(GLuint base) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); /* must be called before assert */ + ASSERT_OUTSIDE_BEGIN_END(ctx); + ctx->List.ListBase = base; +} + + +/* Can no longer assume ctx->Exec->Func is equal to _mesa_Func. + */ +static void GLAPIENTRY +exec_Finish(void) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_Finish(ctx->Exec, ()); +} + +static void GLAPIENTRY +exec_Flush(void) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_Flush(ctx->Exec, ()); +} + +static void GLAPIENTRY +exec_GetBooleanv(GLenum pname, GLboolean *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetBooleanv(ctx->Exec, (pname, params)); +} + +static void GLAPIENTRY +exec_GetClipPlane(GLenum plane, GLdouble * equation) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetClipPlane(ctx->Exec, (plane, equation)); +} + +static void GLAPIENTRY +exec_GetDoublev(GLenum pname, GLdouble *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetDoublev(ctx->Exec, (pname, params)); +} + +static GLenum GLAPIENTRY +exec_GetError(void) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + return CALL_GetError(ctx->Exec, ()); +} + +static void GLAPIENTRY +exec_GetFloatv(GLenum pname, GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetFloatv(ctx->Exec, (pname, params)); +} + +static void GLAPIENTRY +exec_GetIntegerv(GLenum pname, GLint *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetIntegerv(ctx->Exec, (pname, params)); +} + +static void GLAPIENTRY +exec_GetLightfv(GLenum light, GLenum pname, GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetLightfv(ctx->Exec, (light, pname, params)); +} + +static void GLAPIENTRY +exec_GetLightiv(GLenum light, GLenum pname, GLint *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetLightiv(ctx->Exec, (light, pname, params)); +} + +static void GLAPIENTRY +exec_GetMapdv(GLenum target, GLenum query, GLdouble * v) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetMapdv(ctx->Exec, (target, query, v)); +} + +static void GLAPIENTRY +exec_GetMapfv(GLenum target, GLenum query, GLfloat * v) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetMapfv(ctx->Exec, (target, query, v)); +} + +static void GLAPIENTRY +exec_GetMapiv(GLenum target, GLenum query, GLint * v) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetMapiv(ctx->Exec, (target, query, v)); +} + +static void GLAPIENTRY +exec_GetMaterialfv(GLenum face, GLenum pname, GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetMaterialfv(ctx->Exec, (face, pname, params)); +} + +static void GLAPIENTRY +exec_GetMaterialiv(GLenum face, GLenum pname, GLint *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetMaterialiv(ctx->Exec, (face, pname, params)); +} + +static void GLAPIENTRY +exec_GetPixelMapfv(GLenum map, GLfloat *values) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetPixelMapfv(ctx->Exec, (map, values)); +} + +static void GLAPIENTRY +exec_GetPixelMapuiv(GLenum map, GLuint *values) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetPixelMapuiv(ctx->Exec, (map, values)); +} + +static void GLAPIENTRY +exec_GetPixelMapusv(GLenum map, GLushort *values) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetPixelMapusv(ctx->Exec, (map, values)); +} + +static void GLAPIENTRY +exec_GetPolygonStipple(GLubyte * dest) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetPolygonStipple(ctx->Exec, (dest)); +} + +static const GLubyte *GLAPIENTRY +exec_GetString(GLenum name) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + return CALL_GetString(ctx->Exec, (name)); +} + +static void GLAPIENTRY +exec_GetTexEnvfv(GLenum target, GLenum pname, GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetTexEnvfv(ctx->Exec, (target, pname, params)); +} + +static void GLAPIENTRY +exec_GetTexEnviv(GLenum target, GLenum pname, GLint *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetTexEnviv(ctx->Exec, (target, pname, params)); +} + +static void GLAPIENTRY +exec_GetTexGendv(GLenum coord, GLenum pname, GLdouble *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetTexGendv(ctx->Exec, (coord, pname, params)); +} + +static void GLAPIENTRY +exec_GetTexGenfv(GLenum coord, GLenum pname, GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetTexGenfv(ctx->Exec, (coord, pname, params)); +} + +static void GLAPIENTRY +exec_GetTexGeniv(GLenum coord, GLenum pname, GLint *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetTexGeniv(ctx->Exec, (coord, pname, params)); +} + +static void GLAPIENTRY +exec_GetTexImage(GLenum target, GLint level, GLenum format, + GLenum type, GLvoid * pixels) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetTexImage(ctx->Exec, (target, level, format, type, pixels)); +} + +static void GLAPIENTRY +exec_GetTexLevelParameterfv(GLenum target, GLint level, + GLenum pname, GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetTexLevelParameterfv(ctx->Exec, (target, level, pname, params)); +} + +static void GLAPIENTRY +exec_GetTexLevelParameteriv(GLenum target, GLint level, + GLenum pname, GLint *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetTexLevelParameteriv(ctx->Exec, (target, level, pname, params)); +} + +static void GLAPIENTRY +exec_GetTexParameterfv(GLenum target, GLenum pname, GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetTexParameterfv(ctx->Exec, (target, pname, params)); +} + +static void GLAPIENTRY +exec_GetTexParameteriv(GLenum target, GLenum pname, GLint *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetTexParameteriv(ctx->Exec, (target, pname, params)); +} + +static GLboolean GLAPIENTRY +exec_IsEnabled(GLenum cap) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + return CALL_IsEnabled(ctx->Exec, (cap)); +} + +static void GLAPIENTRY +exec_PixelStoref(GLenum pname, GLfloat param) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_PixelStoref(ctx->Exec, (pname, param)); +} + +static void GLAPIENTRY +exec_PixelStorei(GLenum pname, GLint param) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_PixelStorei(ctx->Exec, (pname, param)); +} + +static void GLAPIENTRY +exec_ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, + GLenum format, GLenum type, GLvoid * pixels) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_ReadPixels(ctx->Exec, (x, y, width, height, format, type, pixels)); +} + +static GLint GLAPIENTRY +exec_RenderMode(GLenum mode) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + return CALL_RenderMode(ctx->Exec, (mode)); +} + +static void GLAPIENTRY +exec_FeedbackBuffer(GLsizei size, GLenum type, GLfloat * buffer) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_FeedbackBuffer(ctx->Exec, (size, type, buffer)); +} + +static void GLAPIENTRY +exec_SelectBuffer(GLsizei size, GLuint * buffer) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_SelectBuffer(ctx->Exec, (size, buffer)); +} + +static GLboolean GLAPIENTRY +exec_AreTexturesResident(GLsizei n, const GLuint * texName, + GLboolean * residences) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + return CALL_AreTexturesResident(ctx->Exec, (n, texName, residences)); +} + +static void GLAPIENTRY +exec_ColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_ColorPointer(ctx->Exec, (size, type, stride, ptr)); +} + +static void GLAPIENTRY +exec_DeleteTextures(GLsizei n, const GLuint * texName) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_DeleteTextures(ctx->Exec, (n, texName)); +} + +static void GLAPIENTRY +exec_DisableClientState(GLenum cap) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_DisableClientState(ctx->Exec, (cap)); +} + +static void GLAPIENTRY +exec_EdgeFlagPointer(GLsizei stride, const GLvoid * vptr) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_EdgeFlagPointer(ctx->Exec, (stride, vptr)); +} + +static void GLAPIENTRY +exec_EnableClientState(GLenum cap) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_EnableClientState(ctx->Exec, (cap)); +} + +static void GLAPIENTRY +exec_GenTextures(GLsizei n, GLuint * texName) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GenTextures(ctx->Exec, (n, texName)); +} + +static void GLAPIENTRY +exec_GetPointerv(GLenum pname, GLvoid **params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetPointerv(ctx->Exec, (pname, params)); +} + +static void GLAPIENTRY +exec_IndexPointer(GLenum type, GLsizei stride, const GLvoid *ptr) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_IndexPointer(ctx->Exec, (type, stride, ptr)); +} + +static void GLAPIENTRY +exec_InterleavedArrays(GLenum format, GLsizei stride, const GLvoid * pointer) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_InterleavedArrays(ctx->Exec, (format, stride, pointer)); +} + +static GLboolean GLAPIENTRY +exec_IsTexture(GLuint texture) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + return CALL_IsTexture(ctx->Exec, (texture)); +} + +static void GLAPIENTRY +exec_NormalPointer(GLenum type, GLsizei stride, const GLvoid *ptr) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_NormalPointer(ctx->Exec, (type, stride, ptr)); +} + +static void GLAPIENTRY +exec_PopClientAttrib(void) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_PopClientAttrib(ctx->Exec, ()); +} + +static void GLAPIENTRY +exec_PushClientAttrib(GLbitfield mask) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_PushClientAttrib(ctx->Exec, (mask)); +} + +static void GLAPIENTRY +exec_TexCoordPointer(GLint size, GLenum type, GLsizei stride, + const GLvoid *ptr) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_TexCoordPointer(ctx->Exec, (size, type, stride, ptr)); +} + +static void GLAPIENTRY +exec_GetCompressedTexImageARB(GLenum target, GLint level, GLvoid * img) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetCompressedTexImageARB(ctx->Exec, (target, level, img)); +} + +static void GLAPIENTRY +exec_VertexPointer(GLint size, GLenum type, GLsizei stride, + const GLvoid *ptr) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_VertexPointer(ctx->Exec, (size, type, stride, ptr)); +} + +static void GLAPIENTRY +exec_CopyConvolutionFilter1D(GLenum target, GLenum internalFormat, + GLint x, GLint y, GLsizei width) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_CopyConvolutionFilter1D(ctx->Exec, + (target, internalFormat, x, y, width)); +} + +static void GLAPIENTRY +exec_CopyConvolutionFilter2D(GLenum target, GLenum internalFormat, + GLint x, GLint y, GLsizei width, GLsizei height) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_CopyConvolutionFilter2D(ctx->Exec, + (target, internalFormat, x, y, width, + height)); +} + +static void GLAPIENTRY +exec_GetColorTable(GLenum target, GLenum format, GLenum type, GLvoid * data) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetColorTable(ctx->Exec, (target, format, type, data)); +} + +static void GLAPIENTRY +exec_GetColorTableParameterfv(GLenum target, GLenum pname, GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetColorTableParameterfv(ctx->Exec, (target, pname, params)); +} + +static void GLAPIENTRY +exec_GetColorTableParameteriv(GLenum target, GLenum pname, GLint *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetColorTableParameteriv(ctx->Exec, (target, pname, params)); +} + +static void GLAPIENTRY +exec_GetConvolutionFilter(GLenum target, GLenum format, GLenum type, + GLvoid * image) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetConvolutionFilter(ctx->Exec, (target, format, type, image)); +} + +static void GLAPIENTRY +exec_GetConvolutionParameterfv(GLenum target, GLenum pname, GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetConvolutionParameterfv(ctx->Exec, (target, pname, params)); +} + +static void GLAPIENTRY +exec_GetConvolutionParameteriv(GLenum target, GLenum pname, GLint *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetConvolutionParameteriv(ctx->Exec, (target, pname, params)); +} + +static void GLAPIENTRY +exec_GetHistogram(GLenum target, GLboolean reset, GLenum format, + GLenum type, GLvoid *values) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetHistogram(ctx->Exec, (target, reset, format, type, values)); +} + +static void GLAPIENTRY +exec_GetHistogramParameterfv(GLenum target, GLenum pname, GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetHistogramParameterfv(ctx->Exec, (target, pname, params)); +} + +static void GLAPIENTRY +exec_GetHistogramParameteriv(GLenum target, GLenum pname, GLint *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetHistogramParameteriv(ctx->Exec, (target, pname, params)); +} + +static void GLAPIENTRY +exec_GetMinmax(GLenum target, GLboolean reset, GLenum format, + GLenum type, GLvoid *values) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetMinmax(ctx->Exec, (target, reset, format, type, values)); +} + +static void GLAPIENTRY +exec_GetMinmaxParameterfv(GLenum target, GLenum pname, GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetMinmaxParameterfv(ctx->Exec, (target, pname, params)); +} + +static void GLAPIENTRY +exec_GetMinmaxParameteriv(GLenum target, GLenum pname, GLint *params) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetMinmaxParameteriv(ctx->Exec, (target, pname, params)); +} + +static void GLAPIENTRY +exec_GetSeparableFilter(GLenum target, GLenum format, GLenum type, + GLvoid *row, GLvoid *column, GLvoid *span) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_GetSeparableFilter(ctx->Exec, + (target, format, type, row, column, span)); +} + +static void GLAPIENTRY +exec_SeparableFilter2D(GLenum target, GLenum internalFormat, + GLsizei width, GLsizei height, GLenum format, + GLenum type, const GLvoid *row, const GLvoid *column) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_SeparableFilter2D(ctx->Exec, + (target, internalFormat, width, height, format, + type, row, column)); +} + +static void GLAPIENTRY +exec_ColorPointerEXT(GLint size, GLenum type, GLsizei stride, + GLsizei count, const GLvoid *ptr) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_ColorPointerEXT(ctx->Exec, (size, type, stride, count, ptr)); +} + +static void GLAPIENTRY +exec_EdgeFlagPointerEXT(GLsizei stride, GLsizei count, const GLboolean *ptr) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_EdgeFlagPointerEXT(ctx->Exec, (stride, count, ptr)); +} + +static void GLAPIENTRY +exec_IndexPointerEXT(GLenum type, GLsizei stride, GLsizei count, + const GLvoid *ptr) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_IndexPointerEXT(ctx->Exec, (type, stride, count, ptr)); +} + +static void GLAPIENTRY +exec_NormalPointerEXT(GLenum type, GLsizei stride, GLsizei count, + const GLvoid *ptr) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_NormalPointerEXT(ctx->Exec, (type, stride, count, ptr)); +} + +static void GLAPIENTRY +exec_TexCoordPointerEXT(GLint size, GLenum type, GLsizei stride, + GLsizei count, const GLvoid *ptr) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_TexCoordPointerEXT(ctx->Exec, (size, type, stride, count, ptr)); +} + +static void GLAPIENTRY +exec_VertexPointerEXT(GLint size, GLenum type, GLsizei stride, + GLsizei count, const GLvoid *ptr) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_VertexPointerEXT(ctx->Exec, (size, type, stride, count, ptr)); +} + +static void GLAPIENTRY +exec_LockArraysEXT(GLint first, GLsizei count) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_LockArraysEXT(ctx->Exec, (first, count)); +} + +static void GLAPIENTRY +exec_UnlockArraysEXT(void) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_UnlockArraysEXT(ctx->Exec, ()); +} + +static void GLAPIENTRY +exec_ClientActiveTextureARB(GLenum target) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_ClientActiveTextureARB(ctx->Exec, (target)); +} + +static void GLAPIENTRY +exec_SecondaryColorPointerEXT(GLint size, GLenum type, + GLsizei stride, const GLvoid *ptr) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_SecondaryColorPointerEXT(ctx->Exec, (size, type, stride, ptr)); +} + +static void GLAPIENTRY +exec_FogCoordPointerEXT(GLenum type, GLsizei stride, const GLvoid *ptr) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_FogCoordPointerEXT(ctx->Exec, (type, stride, ptr)); +} + +/* GL_EXT_multi_draw_arrays */ +static void GLAPIENTRY +exec_MultiDrawArraysEXT(GLenum mode, const GLint *first, + const GLsizei *count, GLsizei primcount) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_MultiDrawArraysEXT(ctx->Exec, (mode, first, count, primcount)); +} + +/* GL_IBM_multimode_draw_arrays */ +static void GLAPIENTRY +exec_MultiModeDrawArraysIBM(const GLenum * mode, const GLint * first, + const GLsizei * count, GLsizei primcount, + GLint modestride) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_MultiModeDrawArraysIBM(ctx->Exec, + (mode, first, count, primcount, modestride)); +} + +/* GL_IBM_multimode_draw_arrays */ +static void GLAPIENTRY +exec_MultiModeDrawElementsIBM(const GLenum * mode, + const GLsizei * count, + GLenum type, + const GLvoid * const *indices, + GLsizei primcount, GLint modestride) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + CALL_MultiModeDrawElementsIBM(ctx->Exec, + (mode, count, type, indices, primcount, + modestride)); +} + + + +/** + * Setup the given dispatch table to point to Mesa's display list + * building functions. + * + * This does not include any of the tnl functions - they are + * initialized from _mesa_init_api_defaults and from the active vtxfmt + * struct. + */ +struct _glapi_table * +_mesa_create_save_table(void) +{ + struct _glapi_table *table; + + table = _mesa_alloc_dispatch_table(_gloffset_COUNT); + if (table == NULL) + return NULL; + + _mesa_loopback_init_api_table(table); + + /* GL 1.0 */ + SET_Accum(table, save_Accum); + SET_AlphaFunc(table, save_AlphaFunc); + SET_Bitmap(table, save_Bitmap); + SET_BlendFunc(table, save_BlendFunc); + SET_CallList(table, save_CallList); + SET_CallLists(table, save_CallLists); + SET_Clear(table, save_Clear); + SET_ClearAccum(table, save_ClearAccum); + SET_ClearColor(table, save_ClearColor); + SET_ClearDepth(table, save_ClearDepth); + SET_ClearIndex(table, save_ClearIndex); + SET_ClearStencil(table, save_ClearStencil); + SET_ClipPlane(table, save_ClipPlane); + SET_ColorMask(table, save_ColorMask); + SET_ColorMaskIndexedEXT(table, save_ColorMaskIndexed); + SET_ColorMaterial(table, save_ColorMaterial); + SET_CopyPixels(table, save_CopyPixels); + SET_CullFace(table, save_CullFace); + SET_DeleteLists(table, _mesa_DeleteLists); + SET_DepthFunc(table, save_DepthFunc); + SET_DepthMask(table, save_DepthMask); + SET_DepthRange(table, save_DepthRange); + SET_Disable(table, save_Disable); + SET_DisableIndexedEXT(table, save_DisableIndexed); + SET_DrawBuffer(table, save_DrawBuffer); + SET_DrawPixels(table, save_DrawPixels); + SET_Enable(table, save_Enable); + SET_EnableIndexedEXT(table, save_EnableIndexed); + SET_EndList(table, _mesa_EndList); + SET_EvalMesh1(table, save_EvalMesh1); + SET_EvalMesh2(table, save_EvalMesh2); + SET_Finish(table, exec_Finish); + SET_Flush(table, exec_Flush); + SET_Fogf(table, save_Fogf); + SET_Fogfv(table, save_Fogfv); + SET_Fogi(table, save_Fogi); + SET_Fogiv(table, save_Fogiv); + SET_FrontFace(table, save_FrontFace); + SET_Frustum(table, save_Frustum); + SET_GenLists(table, _mesa_GenLists); + SET_GetBooleanv(table, exec_GetBooleanv); + SET_GetClipPlane(table, exec_GetClipPlane); + SET_GetDoublev(table, exec_GetDoublev); + SET_GetError(table, exec_GetError); + SET_GetFloatv(table, exec_GetFloatv); + SET_GetIntegerv(table, exec_GetIntegerv); + SET_GetLightfv(table, exec_GetLightfv); + SET_GetLightiv(table, exec_GetLightiv); + SET_GetMapdv(table, exec_GetMapdv); + SET_GetMapfv(table, exec_GetMapfv); + SET_GetMapiv(table, exec_GetMapiv); + SET_GetMaterialfv(table, exec_GetMaterialfv); + SET_GetMaterialiv(table, exec_GetMaterialiv); + SET_GetPixelMapfv(table, exec_GetPixelMapfv); + SET_GetPixelMapuiv(table, exec_GetPixelMapuiv); + SET_GetPixelMapusv(table, exec_GetPixelMapusv); + SET_GetPolygonStipple(table, exec_GetPolygonStipple); + SET_GetString(table, exec_GetString); + SET_GetTexEnvfv(table, exec_GetTexEnvfv); + SET_GetTexEnviv(table, exec_GetTexEnviv); + SET_GetTexGendv(table, exec_GetTexGendv); + SET_GetTexGenfv(table, exec_GetTexGenfv); + SET_GetTexGeniv(table, exec_GetTexGeniv); + SET_GetTexImage(table, exec_GetTexImage); + SET_GetTexLevelParameterfv(table, exec_GetTexLevelParameterfv); + SET_GetTexLevelParameteriv(table, exec_GetTexLevelParameteriv); + SET_GetTexParameterfv(table, exec_GetTexParameterfv); + SET_GetTexParameteriv(table, exec_GetTexParameteriv); + SET_Hint(table, save_Hint); + SET_IndexMask(table, save_IndexMask); + SET_InitNames(table, save_InitNames); + SET_IsEnabled(table, exec_IsEnabled); + SET_IsList(table, _mesa_IsList); + SET_LightModelf(table, save_LightModelf); + SET_LightModelfv(table, save_LightModelfv); + SET_LightModeli(table, save_LightModeli); + SET_LightModeliv(table, save_LightModeliv); + SET_Lightf(table, save_Lightf); + SET_Lightfv(table, save_Lightfv); + SET_Lighti(table, save_Lighti); + SET_Lightiv(table, save_Lightiv); + SET_LineStipple(table, save_LineStipple); + SET_LineWidth(table, save_LineWidth); + SET_ListBase(table, save_ListBase); + SET_LoadIdentity(table, save_LoadIdentity); + SET_LoadMatrixd(table, save_LoadMatrixd); + SET_LoadMatrixf(table, save_LoadMatrixf); + SET_LoadName(table, save_LoadName); + SET_LogicOp(table, save_LogicOp); + SET_Map1d(table, save_Map1d); + SET_Map1f(table, save_Map1f); + SET_Map2d(table, save_Map2d); + SET_Map2f(table, save_Map2f); + SET_MapGrid1d(table, save_MapGrid1d); + SET_MapGrid1f(table, save_MapGrid1f); + SET_MapGrid2d(table, save_MapGrid2d); + SET_MapGrid2f(table, save_MapGrid2f); + SET_MatrixMode(table, save_MatrixMode); + SET_MultMatrixd(table, save_MultMatrixd); + SET_MultMatrixf(table, save_MultMatrixf); + SET_NewList(table, save_NewList); + SET_Ortho(table, save_Ortho); + SET_PassThrough(table, save_PassThrough); + SET_PixelMapfv(table, save_PixelMapfv); + SET_PixelMapuiv(table, save_PixelMapuiv); + SET_PixelMapusv(table, save_PixelMapusv); + SET_PixelStoref(table, exec_PixelStoref); + SET_PixelStorei(table, exec_PixelStorei); + SET_PixelTransferf(table, save_PixelTransferf); + SET_PixelTransferi(table, save_PixelTransferi); + SET_PixelZoom(table, save_PixelZoom); + SET_PointSize(table, save_PointSize); + SET_PolygonMode(table, save_PolygonMode); + SET_PolygonOffset(table, save_PolygonOffset); + SET_PolygonStipple(table, save_PolygonStipple); + SET_PopAttrib(table, save_PopAttrib); + SET_PopMatrix(table, save_PopMatrix); + SET_PopName(table, save_PopName); + SET_PushAttrib(table, save_PushAttrib); + SET_PushMatrix(table, save_PushMatrix); + SET_PushName(table, save_PushName); + SET_RasterPos2d(table, save_RasterPos2d); + SET_RasterPos2dv(table, save_RasterPos2dv); + SET_RasterPos2f(table, save_RasterPos2f); + SET_RasterPos2fv(table, save_RasterPos2fv); + SET_RasterPos2i(table, save_RasterPos2i); + SET_RasterPos2iv(table, save_RasterPos2iv); + SET_RasterPos2s(table, save_RasterPos2s); + SET_RasterPos2sv(table, save_RasterPos2sv); + SET_RasterPos3d(table, save_RasterPos3d); + SET_RasterPos3dv(table, save_RasterPos3dv); + SET_RasterPos3f(table, save_RasterPos3f); + SET_RasterPos3fv(table, save_RasterPos3fv); + SET_RasterPos3i(table, save_RasterPos3i); + SET_RasterPos3iv(table, save_RasterPos3iv); + SET_RasterPos3s(table, save_RasterPos3s); + SET_RasterPos3sv(table, save_RasterPos3sv); + SET_RasterPos4d(table, save_RasterPos4d); + SET_RasterPos4dv(table, save_RasterPos4dv); + SET_RasterPos4f(table, save_RasterPos4f); + SET_RasterPos4fv(table, save_RasterPos4fv); + SET_RasterPos4i(table, save_RasterPos4i); + SET_RasterPos4iv(table, save_RasterPos4iv); + SET_RasterPos4s(table, save_RasterPos4s); + SET_RasterPos4sv(table, save_RasterPos4sv); + SET_ReadBuffer(table, save_ReadBuffer); + SET_ReadPixels(table, exec_ReadPixels); + SET_RenderMode(table, exec_RenderMode); + SET_Rotated(table, save_Rotated); + SET_Rotatef(table, save_Rotatef); + SET_Scaled(table, save_Scaled); + SET_Scalef(table, save_Scalef); + SET_Scissor(table, save_Scissor); + SET_FeedbackBuffer(table, exec_FeedbackBuffer); + SET_SelectBuffer(table, exec_SelectBuffer); + SET_ShadeModel(table, save_ShadeModel); + SET_StencilFunc(table, save_StencilFunc); + SET_StencilMask(table, save_StencilMask); + SET_StencilOp(table, save_StencilOp); + SET_TexEnvf(table, save_TexEnvf); + SET_TexEnvfv(table, save_TexEnvfv); + SET_TexEnvi(table, save_TexEnvi); + SET_TexEnviv(table, save_TexEnviv); + SET_TexGend(table, save_TexGend); + SET_TexGendv(table, save_TexGendv); + SET_TexGenf(table, save_TexGenf); + SET_TexGenfv(table, save_TexGenfv); + SET_TexGeni(table, save_TexGeni); + SET_TexGeniv(table, save_TexGeniv); + SET_TexImage1D(table, save_TexImage1D); + SET_TexImage2D(table, save_TexImage2D); + SET_TexParameterf(table, save_TexParameterf); + SET_TexParameterfv(table, save_TexParameterfv); + SET_TexParameteri(table, save_TexParameteri); + SET_TexParameteriv(table, save_TexParameteriv); + SET_Translated(table, save_Translated); + SET_Translatef(table, save_Translatef); + SET_Viewport(table, save_Viewport); + + /* GL 1.1 */ + SET_AreTexturesResident(table, exec_AreTexturesResident); + SET_BindTexture(table, save_BindTexture); + SET_ColorPointer(table, exec_ColorPointer); + SET_CopyTexImage1D(table, save_CopyTexImage1D); + SET_CopyTexImage2D(table, save_CopyTexImage2D); + SET_CopyTexSubImage1D(table, save_CopyTexSubImage1D); + SET_CopyTexSubImage2D(table, save_CopyTexSubImage2D); + SET_DeleteTextures(table, exec_DeleteTextures); + SET_DisableClientState(table, exec_DisableClientState); + SET_EdgeFlagPointer(table, exec_EdgeFlagPointer); + SET_EnableClientState(table, exec_EnableClientState); + SET_GenTextures(table, exec_GenTextures); + SET_GetPointerv(table, exec_GetPointerv); + SET_IndexPointer(table, exec_IndexPointer); + SET_InterleavedArrays(table, exec_InterleavedArrays); + SET_IsTexture(table, exec_IsTexture); + SET_NormalPointer(table, exec_NormalPointer); + SET_PopClientAttrib(table, exec_PopClientAttrib); + SET_PrioritizeTextures(table, save_PrioritizeTextures); + SET_PushClientAttrib(table, exec_PushClientAttrib); + SET_TexCoordPointer(table, exec_TexCoordPointer); + SET_TexSubImage1D(table, save_TexSubImage1D); + SET_TexSubImage2D(table, save_TexSubImage2D); + SET_VertexPointer(table, exec_VertexPointer); + + /* GL 1.2 */ + SET_CopyTexSubImage3D(table, save_CopyTexSubImage3D); + SET_TexImage3D(table, save_TexImage3D); + SET_TexSubImage3D(table, save_TexSubImage3D); + + /* GL 2.0 */ + SET_StencilFuncSeparate(table, save_StencilFuncSeparate); + SET_StencilMaskSeparate(table, save_StencilMaskSeparate); + SET_StencilOpSeparate(table, save_StencilOpSeparate); + + /* ATI_separate_stencil */ + SET_StencilFuncSeparateATI(table, save_StencilFuncSeparateATI); + + /* GL_ARB_imaging */ + /* Not all are supported */ + SET_BlendColor(table, save_BlendColor); + SET_BlendEquation(table, save_BlendEquation); + SET_ColorSubTable(table, save_ColorSubTable); + SET_ColorTable(table, save_ColorTable); + SET_ColorTableParameterfv(table, save_ColorTableParameterfv); + SET_ColorTableParameteriv(table, save_ColorTableParameteriv); + SET_ConvolutionFilter1D(table, save_ConvolutionFilter1D); + SET_ConvolutionFilter2D(table, save_ConvolutionFilter2D); + SET_ConvolutionParameterf(table, save_ConvolutionParameterf); + SET_ConvolutionParameterfv(table, save_ConvolutionParameterfv); + SET_ConvolutionParameteri(table, save_ConvolutionParameteri); + SET_ConvolutionParameteriv(table, save_ConvolutionParameteriv); + SET_CopyColorSubTable(table, save_CopyColorSubTable); + SET_CopyColorTable(table, save_CopyColorTable); + SET_CopyConvolutionFilter1D(table, exec_CopyConvolutionFilter1D); + SET_CopyConvolutionFilter2D(table, exec_CopyConvolutionFilter2D); + SET_GetColorTable(table, exec_GetColorTable); + SET_GetColorTableParameterfv(table, exec_GetColorTableParameterfv); + SET_GetColorTableParameteriv(table, exec_GetColorTableParameteriv); + SET_GetConvolutionFilter(table, exec_GetConvolutionFilter); + SET_GetConvolutionParameterfv(table, exec_GetConvolutionParameterfv); + SET_GetConvolutionParameteriv(table, exec_GetConvolutionParameteriv); + SET_GetHistogram(table, exec_GetHistogram); + SET_GetHistogramParameterfv(table, exec_GetHistogramParameterfv); + SET_GetHistogramParameteriv(table, exec_GetHistogramParameteriv); + SET_GetMinmax(table, exec_GetMinmax); + SET_GetMinmaxParameterfv(table, exec_GetMinmaxParameterfv); + SET_GetMinmaxParameteriv(table, exec_GetMinmaxParameteriv); + SET_GetSeparableFilter(table, exec_GetSeparableFilter); + SET_Histogram(table, save_Histogram); + SET_Minmax(table, save_Minmax); + SET_ResetHistogram(table, save_ResetHistogram); + SET_ResetMinmax(table, save_ResetMinmax); + SET_SeparableFilter2D(table, exec_SeparableFilter2D); + + /* 2. GL_EXT_blend_color */ +#if 0 + SET_BlendColorEXT(table, save_BlendColorEXT); +#endif + + /* 3. GL_EXT_polygon_offset */ + SET_PolygonOffsetEXT(table, save_PolygonOffsetEXT); + + /* 6. GL_EXT_texture3d */ +#if 0 + SET_CopyTexSubImage3DEXT(table, save_CopyTexSubImage3D); + SET_TexImage3DEXT(table, save_TexImage3DEXT); + SET_TexSubImage3DEXT(table, save_TexSubImage3D); +#endif + + /* 14. GL_SGI_color_table */ +#if 0 + SET_ColorTableSGI(table, save_ColorTable); + SET_ColorSubTableSGI(table, save_ColorSubTable); + SET_GetColorTableSGI(table, exec_GetColorTable); + SET_GetColorTableParameterfvSGI(table, exec_GetColorTableParameterfv); + SET_GetColorTableParameterivSGI(table, exec_GetColorTableParameteriv); +#endif + + /* 30. GL_EXT_vertex_array */ + SET_ColorPointerEXT(table, exec_ColorPointerEXT); + SET_EdgeFlagPointerEXT(table, exec_EdgeFlagPointerEXT); + SET_IndexPointerEXT(table, exec_IndexPointerEXT); + SET_NormalPointerEXT(table, exec_NormalPointerEXT); + SET_TexCoordPointerEXT(table, exec_TexCoordPointerEXT); + SET_VertexPointerEXT(table, exec_VertexPointerEXT); + + /* 37. GL_EXT_blend_minmax */ +#if 0 + SET_BlendEquationEXT(table, save_BlendEquationEXT); +#endif + + /* 54. GL_EXT_point_parameters */ + SET_PointParameterfEXT(table, save_PointParameterfEXT); + SET_PointParameterfvEXT(table, save_PointParameterfvEXT); + + /* 97. GL_EXT_compiled_vertex_array */ + SET_LockArraysEXT(table, exec_LockArraysEXT); + SET_UnlockArraysEXT(table, exec_UnlockArraysEXT); + + /* 145. GL_EXT_secondary_color */ + SET_SecondaryColorPointerEXT(table, exec_SecondaryColorPointerEXT); + + /* 148. GL_EXT_multi_draw_arrays */ + SET_MultiDrawArraysEXT(table, exec_MultiDrawArraysEXT); + + /* 149. GL_EXT_fog_coord */ + SET_FogCoordPointerEXT(table, exec_FogCoordPointerEXT); + + /* 173. GL_EXT_blend_func_separate */ + SET_BlendFuncSeparateEXT(table, save_BlendFuncSeparateEXT); + + /* 196. GL_MESA_resize_buffers */ + SET_ResizeBuffersMESA(table, _mesa_ResizeBuffersMESA); + + /* 197. GL_MESA_window_pos */ + SET_WindowPos2dMESA(table, save_WindowPos2dMESA); + SET_WindowPos2dvMESA(table, save_WindowPos2dvMESA); + SET_WindowPos2fMESA(table, save_WindowPos2fMESA); + SET_WindowPos2fvMESA(table, save_WindowPos2fvMESA); + SET_WindowPos2iMESA(table, save_WindowPos2iMESA); + SET_WindowPos2ivMESA(table, save_WindowPos2ivMESA); + SET_WindowPos2sMESA(table, save_WindowPos2sMESA); + SET_WindowPos2svMESA(table, save_WindowPos2svMESA); + SET_WindowPos3dMESA(table, save_WindowPos3dMESA); + SET_WindowPos3dvMESA(table, save_WindowPos3dvMESA); + SET_WindowPos3fMESA(table, save_WindowPos3fMESA); + SET_WindowPos3fvMESA(table, save_WindowPos3fvMESA); + SET_WindowPos3iMESA(table, save_WindowPos3iMESA); + SET_WindowPos3ivMESA(table, save_WindowPos3ivMESA); + SET_WindowPos3sMESA(table, save_WindowPos3sMESA); + SET_WindowPos3svMESA(table, save_WindowPos3svMESA); + SET_WindowPos4dMESA(table, save_WindowPos4dMESA); + SET_WindowPos4dvMESA(table, save_WindowPos4dvMESA); + SET_WindowPos4fMESA(table, save_WindowPos4fMESA); + SET_WindowPos4fvMESA(table, save_WindowPos4fvMESA); + SET_WindowPos4iMESA(table, save_WindowPos4iMESA); + SET_WindowPos4ivMESA(table, save_WindowPos4ivMESA); + SET_WindowPos4sMESA(table, save_WindowPos4sMESA); + SET_WindowPos4svMESA(table, save_WindowPos4svMESA); + + /* 200. GL_IBM_multimode_draw_arrays */ + SET_MultiModeDrawArraysIBM(table, exec_MultiModeDrawArraysIBM); + SET_MultiModeDrawElementsIBM(table, exec_MultiModeDrawElementsIBM); + +#if FEATURE_NV_vertex_program + /* 233. GL_NV_vertex_program */ + /* The following commands DO NOT go into display lists: + * AreProgramsResidentNV, IsProgramNV, GenProgramsNV, DeleteProgramsNV, + * VertexAttribPointerNV, GetProgram*, GetVertexAttrib* + */ + SET_BindProgramNV(table, save_BindProgramNV); + SET_DeleteProgramsNV(table, _mesa_DeletePrograms); + SET_ExecuteProgramNV(table, save_ExecuteProgramNV); + SET_GenProgramsNV(table, _mesa_GenPrograms); + SET_AreProgramsResidentNV(table, _mesa_AreProgramsResidentNV); + SET_RequestResidentProgramsNV(table, save_RequestResidentProgramsNV); + SET_GetProgramParameterfvNV(table, _mesa_GetProgramParameterfvNV); + SET_GetProgramParameterdvNV(table, _mesa_GetProgramParameterdvNV); + SET_GetProgramivNV(table, _mesa_GetProgramivNV); + SET_GetProgramStringNV(table, _mesa_GetProgramStringNV); + SET_GetTrackMatrixivNV(table, _mesa_GetTrackMatrixivNV); + SET_GetVertexAttribdvNV(table, _mesa_GetVertexAttribdvNV); + SET_GetVertexAttribfvNV(table, _mesa_GetVertexAttribfvNV); + SET_GetVertexAttribivNV(table, _mesa_GetVertexAttribivNV); + SET_GetVertexAttribPointervNV(table, _mesa_GetVertexAttribPointervNV); + SET_IsProgramNV(table, _mesa_IsProgramARB); + SET_LoadProgramNV(table, save_LoadProgramNV); + SET_ProgramEnvParameter4dARB(table, save_ProgramEnvParameter4dARB); + SET_ProgramEnvParameter4dvARB(table, save_ProgramEnvParameter4dvARB); + SET_ProgramEnvParameter4fARB(table, save_ProgramEnvParameter4fARB); + SET_ProgramEnvParameter4fvARB(table, save_ProgramEnvParameter4fvARB); + SET_ProgramParameters4dvNV(table, save_ProgramParameters4dvNV); + SET_ProgramParameters4fvNV(table, save_ProgramParameters4fvNV); + SET_TrackMatrixNV(table, save_TrackMatrixNV); + SET_VertexAttribPointerNV(table, _mesa_VertexAttribPointerNV); +#endif + + /* 244. GL_ATI_envmap_bumpmap */ + SET_TexBumpParameterivATI(table, save_TexBumpParameterivATI); + SET_TexBumpParameterfvATI(table, save_TexBumpParameterfvATI); + + /* 245. GL_ATI_fragment_shader */ +#if FEATURE_ATI_fragment_shader + SET_BindFragmentShaderATI(table, save_BindFragmentShaderATI); + SET_SetFragmentShaderConstantATI(table, save_SetFragmentShaderConstantATI); +#endif + + /* 282. GL_NV_fragment_program */ +#if FEATURE_NV_fragment_program + SET_ProgramNamedParameter4fNV(table, save_ProgramNamedParameter4fNV); + SET_ProgramNamedParameter4dNV(table, save_ProgramNamedParameter4dNV); + SET_ProgramNamedParameter4fvNV(table, save_ProgramNamedParameter4fvNV); + SET_ProgramNamedParameter4dvNV(table, save_ProgramNamedParameter4dvNV); + SET_GetProgramNamedParameterfvNV(table, + _mesa_GetProgramNamedParameterfvNV); + SET_GetProgramNamedParameterdvNV(table, + _mesa_GetProgramNamedParameterdvNV); + SET_ProgramLocalParameter4dARB(table, save_ProgramLocalParameter4dARB); + SET_ProgramLocalParameter4dvARB(table, save_ProgramLocalParameter4dvARB); + SET_ProgramLocalParameter4fARB(table, save_ProgramLocalParameter4fARB); + SET_ProgramLocalParameter4fvARB(table, save_ProgramLocalParameter4fvARB); + SET_GetProgramLocalParameterdvARB(table, + _mesa_GetProgramLocalParameterdvARB); + SET_GetProgramLocalParameterfvARB(table, + _mesa_GetProgramLocalParameterfvARB); +#endif + + /* 262. GL_NV_point_sprite */ + SET_PointParameteriNV(table, save_PointParameteriNV); + SET_PointParameterivNV(table, save_PointParameterivNV); + + /* 268. GL_EXT_stencil_two_side */ + SET_ActiveStencilFaceEXT(table, save_ActiveStencilFaceEXT); + + /* 273. GL_APPLE_vertex_array_object */ + SET_BindVertexArrayAPPLE(table, _mesa_BindVertexArrayAPPLE); + SET_DeleteVertexArraysAPPLE(table, _mesa_DeleteVertexArraysAPPLE); + SET_GenVertexArraysAPPLE(table, _mesa_GenVertexArraysAPPLE); + SET_IsVertexArrayAPPLE(table, _mesa_IsVertexArrayAPPLE); + + /* GL_ARB_vertex_array_object */ + SET_BindVertexArray(table, _mesa_BindVertexArray); + SET_GenVertexArrays(table, _mesa_GenVertexArrays); + + /* ???. GL_EXT_depth_bounds_test */ + SET_DepthBoundsEXT(table, save_DepthBoundsEXT); + + /* ARB 1. GL_ARB_multitexture */ + SET_ActiveTextureARB(table, save_ActiveTextureARB); + SET_ClientActiveTextureARB(table, exec_ClientActiveTextureARB); + + /* ARB 3. GL_ARB_transpose_matrix */ + SET_LoadTransposeMatrixdARB(table, save_LoadTransposeMatrixdARB); + SET_LoadTransposeMatrixfARB(table, save_LoadTransposeMatrixfARB); + SET_MultTransposeMatrixdARB(table, save_MultTransposeMatrixdARB); + SET_MultTransposeMatrixfARB(table, save_MultTransposeMatrixfARB); + + /* ARB 5. GL_ARB_multisample */ + SET_SampleCoverageARB(table, save_SampleCoverageARB); + + /* ARB 12. GL_ARB_texture_compression */ + SET_CompressedTexImage3DARB(table, save_CompressedTexImage3DARB); + SET_CompressedTexImage2DARB(table, save_CompressedTexImage2DARB); + SET_CompressedTexImage1DARB(table, save_CompressedTexImage1DARB); + SET_CompressedTexSubImage3DARB(table, save_CompressedTexSubImage3DARB); + SET_CompressedTexSubImage2DARB(table, save_CompressedTexSubImage2DARB); + SET_CompressedTexSubImage1DARB(table, save_CompressedTexSubImage1DARB); + SET_GetCompressedTexImageARB(table, exec_GetCompressedTexImageARB); + + /* ARB 14. GL_ARB_point_parameters */ + /* aliased with EXT_point_parameters functions */ + + /* ARB 25. GL_ARB_window_pos */ + /* aliased with MESA_window_pos functions */ + + /* ARB 26. GL_ARB_vertex_program */ + /* ARB 27. GL_ARB_fragment_program */ +#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program + /* glVertexAttrib* functions alias the NV ones, handled elsewhere */ + SET_VertexAttribPointerARB(table, _mesa_VertexAttribPointerARB); + SET_EnableVertexAttribArrayARB(table, _mesa_EnableVertexAttribArrayARB); + SET_DisableVertexAttribArrayARB(table, _mesa_DisableVertexAttribArrayARB); + SET_ProgramStringARB(table, save_ProgramStringARB); + SET_BindProgramNV(table, save_BindProgramNV); + SET_DeleteProgramsNV(table, _mesa_DeletePrograms); + SET_GenProgramsNV(table, _mesa_GenPrograms); + SET_IsProgramNV(table, _mesa_IsProgramARB); + SET_GetVertexAttribdvARB(table, _mesa_GetVertexAttribdvARB); + SET_GetVertexAttribfvARB(table, _mesa_GetVertexAttribfvARB); + SET_GetVertexAttribivARB(table, _mesa_GetVertexAttribivARB); + SET_GetVertexAttribPointervNV(table, _mesa_GetVertexAttribPointervNV); + SET_ProgramEnvParameter4dARB(table, save_ProgramEnvParameter4dARB); + SET_ProgramEnvParameter4dvARB(table, save_ProgramEnvParameter4dvARB); + SET_ProgramEnvParameter4fARB(table, save_ProgramEnvParameter4fARB); + SET_ProgramEnvParameter4fvARB(table, save_ProgramEnvParameter4fvARB); + SET_ProgramLocalParameter4dARB(table, save_ProgramLocalParameter4dARB); + SET_ProgramLocalParameter4dvARB(table, save_ProgramLocalParameter4dvARB); + SET_ProgramLocalParameter4fARB(table, save_ProgramLocalParameter4fARB); + SET_ProgramLocalParameter4fvARB(table, save_ProgramLocalParameter4fvARB); + SET_GetProgramEnvParameterdvARB(table, _mesa_GetProgramEnvParameterdvARB); + SET_GetProgramEnvParameterfvARB(table, _mesa_GetProgramEnvParameterfvARB); + SET_GetProgramLocalParameterdvARB(table, + _mesa_GetProgramLocalParameterdvARB); + SET_GetProgramLocalParameterfvARB(table, + _mesa_GetProgramLocalParameterfvARB); + SET_GetProgramivARB(table, _mesa_GetProgramivARB); + SET_GetProgramStringARB(table, _mesa_GetProgramStringARB); +#endif + + /* ARB 28. GL_ARB_vertex_buffer_object */ +#if FEATURE_ARB_vertex_buffer_object + /* None of the extension's functions get compiled */ + SET_BindBufferARB(table, _mesa_BindBufferARB); + SET_BufferDataARB(table, _mesa_BufferDataARB); + SET_BufferSubDataARB(table, _mesa_BufferSubDataARB); + SET_DeleteBuffersARB(table, _mesa_DeleteBuffersARB); + SET_GenBuffersARB(table, _mesa_GenBuffersARB); + SET_GetBufferParameterivARB(table, _mesa_GetBufferParameterivARB); + SET_GetBufferPointervARB(table, _mesa_GetBufferPointervARB); + SET_GetBufferSubDataARB(table, _mesa_GetBufferSubDataARB); + SET_IsBufferARB(table, _mesa_IsBufferARB); + SET_MapBufferARB(table, _mesa_MapBufferARB); + SET_UnmapBufferARB(table, _mesa_UnmapBufferARB); +#endif + +#if FEATURE_queryobj + _mesa_init_queryobj_dispatch(table); /* glGetQuery, etc */ + SET_BeginQueryARB(table, save_BeginQueryARB); + SET_EndQueryARB(table, save_EndQueryARB); +#endif + + SET_DrawBuffersARB(table, save_DrawBuffersARB); + +#if FEATURE_EXT_framebuffer_blit + SET_BlitFramebufferEXT(table, save_BlitFramebufferEXT); +#endif + + /* GL_ARB_shader_objects */ + _mesa_init_shader_dispatch(table); /* Plug in glCreate/Delete/Get, etc */ + SET_UseProgramObjectARB(table, save_UseProgramObjectARB); + SET_Uniform1fARB(table, save_Uniform1fARB); + SET_Uniform2fARB(table, save_Uniform2fARB); + SET_Uniform3fARB(table, save_Uniform3fARB); + SET_Uniform4fARB(table, save_Uniform4fARB); + SET_Uniform1fvARB(table, save_Uniform1fvARB); + SET_Uniform2fvARB(table, save_Uniform2fvARB); + SET_Uniform3fvARB(table, save_Uniform3fvARB); + SET_Uniform4fvARB(table, save_Uniform4fvARB); + SET_Uniform1iARB(table, save_Uniform1iARB); + SET_Uniform2iARB(table, save_Uniform2iARB); + SET_Uniform3iARB(table, save_Uniform3iARB); + SET_Uniform4iARB(table, save_Uniform4iARB); + SET_Uniform1ivARB(table, save_Uniform1ivARB); + SET_Uniform2ivARB(table, save_Uniform2ivARB); + SET_Uniform3ivARB(table, save_Uniform3ivARB); + SET_Uniform4ivARB(table, save_Uniform4ivARB); + SET_UniformMatrix2fvARB(table, save_UniformMatrix2fvARB); + SET_UniformMatrix3fvARB(table, save_UniformMatrix3fvARB); + SET_UniformMatrix4fvARB(table, save_UniformMatrix4fvARB); + SET_UniformMatrix2x3fv(table, save_UniformMatrix2x3fv); + SET_UniformMatrix3x2fv(table, save_UniformMatrix3x2fv); + SET_UniformMatrix2x4fv(table, save_UniformMatrix2x4fv); + SET_UniformMatrix4x2fv(table, save_UniformMatrix4x2fv); + SET_UniformMatrix3x4fv(table, save_UniformMatrix3x4fv); + SET_UniformMatrix4x3fv(table, save_UniformMatrix4x3fv); + + /* ARB 30/31/32. GL_ARB_shader_objects, GL_ARB_vertex/fragment_shader */ + SET_BindAttribLocationARB(table, exec_BindAttribLocationARB); + SET_GetAttribLocationARB(table, exec_GetAttribLocationARB); + SET_GetUniformLocationARB(table, exec_GetUniformLocationARB); + /* XXX additional functions need to be implemented here! */ + + /* 299. GL_EXT_blend_equation_separate */ + SET_BlendEquationSeparateEXT(table, save_BlendEquationSeparateEXT); + + /* GL_EXT_gpu_program_parameters */ +#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program + SET_ProgramEnvParameters4fvEXT(table, save_ProgramEnvParameters4fvEXT); + SET_ProgramLocalParameters4fvEXT(table, save_ProgramLocalParameters4fvEXT); +#endif + + /* ARB 50. GL_ARB_map_buffer_range */ +#if FEATURE_ARB_map_buffer_range + SET_MapBufferRange(table, _mesa_MapBufferRange); /* no dlist save */ + SET_FlushMappedBufferRange(table, _mesa_FlushMappedBufferRange); /* no dl */ +#endif + + /* ARB 59. GL_ARB_copy_buffer */ + SET_CopyBufferSubData(table, _mesa_CopyBufferSubData); /* no dlist save */ + + /* 364. GL_EXT_provoking_vertex */ + SET_ProvokingVertexEXT(table, save_ProvokingVertexEXT); + + /* 371. GL_APPLE_object_purgeable */ +#if FEATURE_APPLE_object_purgeable + SET_ObjectPurgeableAPPLE(table, _mesa_ObjectPurgeableAPPLE); + SET_ObjectUnpurgeableAPPLE(table, _mesa_ObjectUnpurgeableAPPLE); + SET_GetObjectParameterivAPPLE(table, _mesa_GetObjectParameterivAPPLE); +#endif + + /* GL_EXT_texture_integer */ + SET_ClearColorIiEXT(table, save_ClearColorIi); + SET_ClearColorIuiEXT(table, save_ClearColorIui); + SET_TexParameterIivEXT(table, save_TexParameterIiv); + SET_TexParameterIuivEXT(table, save_TexParameterIuiv); + SET_GetTexParameterIivEXT(table, exec_GetTexParameterIiv); + SET_GetTexParameterIuivEXT(table, exec_GetTexParameterIuiv); + + /* 377. GL_EXT_separate_shader_objects */ + SET_UseShaderProgramEXT(table, save_UseShaderProgramEXT); + SET_ActiveProgramEXT(table, save_ActiveProgramEXT); + + /* GL_ARB_color_buffer_float */ + SET_ClampColorARB(table, save_ClampColorARB); + SET_ClampColor(table, save_ClampColorARB); + + /* GL 3.0 */ + SET_ClearBufferiv(table, save_ClearBufferiv); + SET_ClearBufferuiv(table, save_ClearBufferuiv); + SET_ClearBufferfv(table, save_ClearBufferfv); + SET_ClearBufferfi(table, save_ClearBufferfi); +#if 0 + SET_Uniform1ui(table, save_Uniform1ui); + SET_Uniform2ui(table, save_Uniform2ui); + SET_Uniform3ui(table, save_Uniform3ui); + SET_Uniform4ui(table, save_Uniform4ui); + SET_Uniform1uiv(table, save_Uniform1uiv); + SET_Uniform2uiv(table, save_Uniform2uiv); + SET_Uniform3uiv(table, save_Uniform3uiv); + SET_Uniform4uiv(table, save_Uniform4uiv); +#else + (void) save_Uniform1ui; + (void) save_Uniform2ui; + (void) save_Uniform3ui; + (void) save_Uniform4ui; + (void) save_Uniform1uiv; + (void) save_Uniform2uiv; + (void) save_Uniform3uiv; + (void) save_Uniform4uiv; +#endif + +#if FEATURE_EXT_transform_feedback + SET_BeginTransformFeedbackEXT(table, save_BeginTransformFeedback); + SET_EndTransformFeedbackEXT(table, save_EndTransformFeedback); + SET_TransformFeedbackVaryingsEXT(table, save_TransformFeedbackVaryings); + SET_BindTransformFeedback(table, save_BindTransformFeedback); + SET_PauseTransformFeedback(table, save_PauseTransformFeedback); + SET_ResumeTransformFeedback(table, save_ResumeTransformFeedback); + SET_DrawTransformFeedback(table, save_DrawTransformFeedback); +#endif + + /* GL_ARB_instanced_arrays */ + SET_VertexAttribDivisorARB(table, save_VertexAttribDivisor); + + /* GL_NV_texture_barrier */ + SET_TextureBarrierNV(table, save_TextureBarrierNV); + + /* GL_ARB_sampler_objects */ + _mesa_init_sampler_object_dispatch(table); /* plug in Gen/Get/etc functions */ + SET_BindSampler(table, save_BindSampler); + SET_SamplerParameteri(table, save_SamplerParameteri); + SET_SamplerParameterf(table, save_SamplerParameterf); + SET_SamplerParameteriv(table, save_SamplerParameteriv); + SET_SamplerParameterfv(table, save_SamplerParameterfv); + SET_SamplerParameterIiv(table, save_SamplerParameterIiv); + SET_SamplerParameterIuiv(table, save_SamplerParameterIuiv); + + /* GL_ARB_draw_buffer_blend */ + SET_BlendFunciARB(table, save_BlendFunci); + SET_BlendFuncSeparateiARB(table, save_BlendFuncSeparatei); + SET_BlendEquationiARB(table, save_BlendEquationi); + SET_BlendEquationSeparateiARB(table, save_BlendEquationSeparatei); + + /* GL_ARB_geometry_shader4 */ + SET_ProgramParameteriARB(table, save_ProgramParameteri); + SET_FramebufferTextureARB(table, save_FramebufferTexture); + SET_FramebufferTextureFaceARB(table, save_FramebufferTextureFace); + + /* GL_ARB_sync */ + _mesa_init_sync_dispatch(table); + SET_WaitSync(table, save_WaitSync); + + return table; +} + + + +static const char * +enum_string(GLenum k) +{ + return _mesa_lookup_enum_by_nr(k); +} + + +/** + * Print the commands in a display list. For debugging only. + * TODO: many commands aren't handled yet. + */ +static void GLAPIENTRY +print_list(struct gl_context *ctx, GLuint list) +{ + struct gl_display_list *dlist; + Node *n; + GLboolean done; + + if (!islist(ctx, list)) { + printf("%u is not a display list ID\n", list); + return; + } + + dlist = lookup_list(ctx, list); + if (!dlist) + return; + + n = dlist->Head; + + printf("START-LIST %u, address %p\n", list, (void *) n); + + done = n ? GL_FALSE : GL_TRUE; + while (!done) { + const OpCode opcode = n[0].opcode; + + if (is_ext_opcode(opcode)) { + n += ext_opcode_print(ctx, n); + } + else { + switch (opcode) { + case OPCODE_ACCUM: + printf("Accum %s %g\n", enum_string(n[1].e), n[2].f); + break; + case OPCODE_BITMAP: + printf("Bitmap %d %d %g %g %g %g %p\n", n[1].i, n[2].i, + n[3].f, n[4].f, n[5].f, n[6].f, (void *) n[7].data); + break; + case OPCODE_CALL_LIST: + printf("CallList %d\n", (int) n[1].ui); + break; + case OPCODE_CALL_LIST_OFFSET: + printf("CallList %d + offset %u = %u\n", (int) n[1].ui, + ctx->List.ListBase, ctx->List.ListBase + n[1].ui); + break; + case OPCODE_COLOR_TABLE_PARAMETER_FV: + printf("ColorTableParameterfv %s %s %f %f %f %f\n", + enum_string(n[1].e), enum_string(n[2].e), + n[3].f, n[4].f, n[5].f, n[6].f); + break; + case OPCODE_COLOR_TABLE_PARAMETER_IV: + printf("ColorTableParameteriv %s %s %d %d %d %d\n", + enum_string(n[1].e), enum_string(n[2].e), + n[3].i, n[4].i, n[5].i, n[6].i); + break; + case OPCODE_DISABLE: + printf("Disable %s\n", enum_string(n[1].e)); + break; + case OPCODE_ENABLE: + printf("Enable %s\n", enum_string(n[1].e)); + break; + case OPCODE_FRUSTUM: + printf("Frustum %g %g %g %g %g %g\n", + n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f); + break; + case OPCODE_LINE_STIPPLE: + printf("LineStipple %d %x\n", n[1].i, (int) n[2].us); + break; + case OPCODE_LOAD_IDENTITY: + printf("LoadIdentity\n"); + break; + case OPCODE_LOAD_MATRIX: + printf("LoadMatrix\n"); + printf(" %8f %8f %8f %8f\n", + n[1].f, n[5].f, n[9].f, n[13].f); + printf(" %8f %8f %8f %8f\n", + n[2].f, n[6].f, n[10].f, n[14].f); + printf(" %8f %8f %8f %8f\n", + n[3].f, n[7].f, n[11].f, n[15].f); + printf(" %8f %8f %8f %8f\n", + n[4].f, n[8].f, n[12].f, n[16].f); + break; + case OPCODE_MULT_MATRIX: + printf("MultMatrix (or Rotate)\n"); + printf(" %8f %8f %8f %8f\n", + n[1].f, n[5].f, n[9].f, n[13].f); + printf(" %8f %8f %8f %8f\n", + n[2].f, n[6].f, n[10].f, n[14].f); + printf(" %8f %8f %8f %8f\n", + n[3].f, n[7].f, n[11].f, n[15].f); + printf(" %8f %8f %8f %8f\n", + n[4].f, n[8].f, n[12].f, n[16].f); + break; + case OPCODE_ORTHO: + printf("Ortho %g %g %g %g %g %g\n", + n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f); + break; + case OPCODE_POP_ATTRIB: + printf("PopAttrib\n"); + break; + case OPCODE_POP_MATRIX: + printf("PopMatrix\n"); + break; + case OPCODE_POP_NAME: + printf("PopName\n"); + break; + case OPCODE_PUSH_ATTRIB: + printf("PushAttrib %x\n", n[1].bf); + break; + case OPCODE_PUSH_MATRIX: + printf("PushMatrix\n"); + break; + case OPCODE_PUSH_NAME: + printf("PushName %d\n", (int) n[1].ui); + break; + case OPCODE_RASTER_POS: + printf("RasterPos %g %g %g %g\n", + n[1].f, n[2].f, n[3].f, n[4].f); + break; + case OPCODE_ROTATE: + printf("Rotate %g %g %g %g\n", + n[1].f, n[2].f, n[3].f, n[4].f); + break; + case OPCODE_SCALE: + printf("Scale %g %g %g\n", n[1].f, n[2].f, n[3].f); + break; + case OPCODE_TRANSLATE: + printf("Translate %g %g %g\n", n[1].f, n[2].f, n[3].f); + break; + case OPCODE_BIND_TEXTURE: + printf("BindTexture %s %d\n", + _mesa_lookup_enum_by_nr(n[1].ui), n[2].ui); + break; + case OPCODE_SHADE_MODEL: + printf("ShadeModel %s\n", _mesa_lookup_enum_by_nr(n[1].ui)); + break; + case OPCODE_MAP1: + printf("Map1 %s %.3f %.3f %d %d\n", + _mesa_lookup_enum_by_nr(n[1].ui), + n[2].f, n[3].f, n[4].i, n[5].i); + break; + case OPCODE_MAP2: + printf("Map2 %s %.3f %.3f %.3f %.3f %d %d %d %d\n", + _mesa_lookup_enum_by_nr(n[1].ui), + n[2].f, n[3].f, n[4].f, n[5].f, + n[6].i, n[7].i, n[8].i, n[9].i); + break; + case OPCODE_MAPGRID1: + printf("MapGrid1 %d %.3f %.3f\n", n[1].i, n[2].f, n[3].f); + break; + case OPCODE_MAPGRID2: + printf("MapGrid2 %d %.3f %.3f, %d %.3f %.3f\n", + n[1].i, n[2].f, n[3].f, n[4].i, n[5].f, n[6].f); + break; + case OPCODE_EVALMESH1: + printf("EvalMesh1 %d %d\n", n[1].i, n[2].i); + break; + case OPCODE_EVALMESH2: + printf("EvalMesh2 %d %d %d %d\n", + n[1].i, n[2].i, n[3].i, n[4].i); + break; + + case OPCODE_ATTR_1F_NV: + printf("ATTR_1F_NV attr %d: %f\n", n[1].i, n[2].f); + break; + case OPCODE_ATTR_2F_NV: + printf("ATTR_2F_NV attr %d: %f %f\n", + n[1].i, n[2].f, n[3].f); + break; + case OPCODE_ATTR_3F_NV: + printf("ATTR_3F_NV attr %d: %f %f %f\n", + n[1].i, n[2].f, n[3].f, n[4].f); + break; + case OPCODE_ATTR_4F_NV: + printf("ATTR_4F_NV attr %d: %f %f %f %f\n", + n[1].i, n[2].f, n[3].f, n[4].f, n[5].f); + break; + case OPCODE_ATTR_1F_ARB: + printf("ATTR_1F_ARB attr %d: %f\n", n[1].i, n[2].f); + break; + case OPCODE_ATTR_2F_ARB: + printf("ATTR_2F_ARB attr %d: %f %f\n", + n[1].i, n[2].f, n[3].f); + break; + case OPCODE_ATTR_3F_ARB: + printf("ATTR_3F_ARB attr %d: %f %f %f\n", + n[1].i, n[2].f, n[3].f, n[4].f); + break; + case OPCODE_ATTR_4F_ARB: + printf("ATTR_4F_ARB attr %d: %f %f %f %f\n", + n[1].i, n[2].f, n[3].f, n[4].f, n[5].f); + break; + + case OPCODE_MATERIAL: + printf("MATERIAL %x %x: %f %f %f %f\n", + n[1].i, n[2].i, n[3].f, n[4].f, n[5].f, n[6].f); + break; + case OPCODE_BEGIN: + printf("BEGIN %x\n", n[1].i); + break; + case OPCODE_END: + printf("END\n"); + break; + case OPCODE_RECTF: + printf("RECTF %f %f %f %f\n", n[1].f, n[2].f, n[3].f, + n[4].f); + break; + case OPCODE_EVAL_C1: + printf("EVAL_C1 %f\n", n[1].f); + break; + case OPCODE_EVAL_C2: + printf("EVAL_C2 %f %f\n", n[1].f, n[2].f); + break; + case OPCODE_EVAL_P1: + printf("EVAL_P1 %d\n", n[1].i); + break; + case OPCODE_EVAL_P2: + printf("EVAL_P2 %d %d\n", n[1].i, n[2].i); + break; + + case OPCODE_PROVOKING_VERTEX: + printf("ProvokingVertex %s\n", + _mesa_lookup_enum_by_nr(n[1].ui)); + break; + + /* + * meta opcodes/commands + */ + case OPCODE_ERROR: + printf("Error: %s %s\n", + enum_string(n[1].e), (const char *) n[2].data); + break; + case OPCODE_CONTINUE: + printf("DISPLAY-LIST-CONTINUE\n"); + n = (Node *) n[1].next; + break; + case OPCODE_END_OF_LIST: + printf("END-LIST %u\n", list); + done = GL_TRUE; + break; + default: + if (opcode < 0 || opcode > OPCODE_END_OF_LIST) { + printf + ("ERROR IN DISPLAY LIST: opcode = %d, address = %p\n", + opcode, (void *) n); + return; + } + else { + printf("command %d, %u operands\n", opcode, + InstSize[opcode]); + } + } + /* increment n to point to next compiled command */ + if (opcode != OPCODE_CONTINUE) { + n += InstSize[opcode]; + } + } + } +} + + + +/** + * Clients may call this function to help debug display list problems. + * This function is _ONLY_FOR_DEBUGGING_PURPOSES_. It may be removed, + * changed, or break in the future without notice. + */ +void +mesa_print_display_list(GLuint list) +{ + GET_CURRENT_CONTEXT(ctx); + print_list(ctx, list); +} + + +/**********************************************************************/ +/***** Initialization *****/ +/**********************************************************************/ + +void +_mesa_save_vtxfmt_init(GLvertexformat * vfmt) +{ + _MESA_INIT_ARRAYELT_VTXFMT(vfmt, _ae_); + + vfmt->Begin = save_Begin; + + _MESA_INIT_DLIST_VTXFMT(vfmt, save_); + + vfmt->Color3f = save_Color3f; + vfmt->Color3fv = save_Color3fv; + vfmt->Color4f = save_Color4f; + vfmt->Color4fv = save_Color4fv; + vfmt->EdgeFlag = save_EdgeFlag; + vfmt->End = save_End; + + _MESA_INIT_EVAL_VTXFMT(vfmt, save_); + + vfmt->FogCoordfEXT = save_FogCoordfEXT; + vfmt->FogCoordfvEXT = save_FogCoordfvEXT; + vfmt->Indexf = save_Indexf; + vfmt->Indexfv = save_Indexfv; + vfmt->Materialfv = save_Materialfv; + vfmt->MultiTexCoord1fARB = save_MultiTexCoord1f; + vfmt->MultiTexCoord1fvARB = save_MultiTexCoord1fv; + vfmt->MultiTexCoord2fARB = save_MultiTexCoord2f; + vfmt->MultiTexCoord2fvARB = save_MultiTexCoord2fv; + vfmt->MultiTexCoord3fARB = save_MultiTexCoord3f; + vfmt->MultiTexCoord3fvARB = save_MultiTexCoord3fv; + vfmt->MultiTexCoord4fARB = save_MultiTexCoord4f; + vfmt->MultiTexCoord4fvARB = save_MultiTexCoord4fv; + vfmt->Normal3f = save_Normal3f; + vfmt->Normal3fv = save_Normal3fv; + vfmt->SecondaryColor3fEXT = save_SecondaryColor3fEXT; + vfmt->SecondaryColor3fvEXT = save_SecondaryColor3fvEXT; + vfmt->TexCoord1f = save_TexCoord1f; + vfmt->TexCoord1fv = save_TexCoord1fv; + vfmt->TexCoord2f = save_TexCoord2f; + vfmt->TexCoord2fv = save_TexCoord2fv; + vfmt->TexCoord3f = save_TexCoord3f; + vfmt->TexCoord3fv = save_TexCoord3fv; + vfmt->TexCoord4f = save_TexCoord4f; + vfmt->TexCoord4fv = save_TexCoord4fv; + vfmt->Vertex2f = save_Vertex2f; + vfmt->Vertex2fv = save_Vertex2fv; + vfmt->Vertex3f = save_Vertex3f; + vfmt->Vertex3fv = save_Vertex3fv; + vfmt->Vertex4f = save_Vertex4f; + vfmt->Vertex4fv = save_Vertex4fv; + vfmt->VertexAttrib1fNV = save_VertexAttrib1fNV; + vfmt->VertexAttrib1fvNV = save_VertexAttrib1fvNV; + vfmt->VertexAttrib2fNV = save_VertexAttrib2fNV; + vfmt->VertexAttrib2fvNV = save_VertexAttrib2fvNV; + vfmt->VertexAttrib3fNV = save_VertexAttrib3fNV; + vfmt->VertexAttrib3fvNV = save_VertexAttrib3fvNV; + vfmt->VertexAttrib4fNV = save_VertexAttrib4fNV; + vfmt->VertexAttrib4fvNV = save_VertexAttrib4fvNV; + vfmt->VertexAttrib1fARB = save_VertexAttrib1fARB; + vfmt->VertexAttrib1fvARB = save_VertexAttrib1fvARB; + vfmt->VertexAttrib2fARB = save_VertexAttrib2fARB; + vfmt->VertexAttrib2fvARB = save_VertexAttrib2fvARB; + vfmt->VertexAttrib3fARB = save_VertexAttrib3fARB; + vfmt->VertexAttrib3fvARB = save_VertexAttrib3fvARB; + vfmt->VertexAttrib4fARB = save_VertexAttrib4fARB; + vfmt->VertexAttrib4fvARB = save_VertexAttrib4fvARB; + + vfmt->Rectf = save_Rectf; + + /* The driver is required to implement these as + * 1) They can probably do a better job. + * 2) A lot of new mechanisms would have to be added to this module + * to support it. That code would probably never get used, + * because of (1). + */ +#if 0 + vfmt->DrawArrays = 0; + vfmt->DrawElements = 0; + vfmt->DrawRangeElements = 0; + vfmt->MultiDrawElemementsEXT = 0; + vfmt->DrawElementsBaseVertex = 0; + vfmt->DrawRangeElementsBaseVertex = 0; + vfmt->MultiDrawElemementsBaseVertex = 0; +#endif +} + + +void +_mesa_install_dlist_vtxfmt(struct _glapi_table *disp, + const GLvertexformat *vfmt) +{ + SET_CallList(disp, vfmt->CallList); + SET_CallLists(disp, vfmt->CallLists); +} + + +void _mesa_init_dlist_dispatch(struct _glapi_table *disp) +{ + SET_CallList(disp, _mesa_CallList); + SET_CallLists(disp, _mesa_CallLists); + + SET_DeleteLists(disp, _mesa_DeleteLists); + SET_EndList(disp, _mesa_EndList); + SET_GenLists(disp, _mesa_GenLists); + SET_IsList(disp, _mesa_IsList); + SET_ListBase(disp, _mesa_ListBase); + SET_NewList(disp, _mesa_NewList); +} + + +#endif /* FEATURE_dlist */ + + +/** + * Initialize display list state for given context. + */ +void +_mesa_init_display_list(struct gl_context *ctx) +{ + static GLboolean tableInitialized = GL_FALSE; + + /* zero-out the instruction size table, just once */ + if (!tableInitialized) { + memset(InstSize, 0, sizeof(InstSize)); + tableInitialized = GL_TRUE; + } + + /* extension info */ + ctx->ListExt = CALLOC_STRUCT(gl_list_extensions); + + /* Display list */ + ctx->ListState.CallDepth = 0; + ctx->ExecuteFlag = GL_TRUE; + ctx->CompileFlag = GL_FALSE; + ctx->ListState.CurrentBlock = NULL; + ctx->ListState.CurrentPos = 0; + + /* Display List group */ + ctx->List.ListBase = 0; + +#if FEATURE_dlist + _mesa_save_vtxfmt_init(&ctx->ListState.ListVtxfmt); +#endif +} + + +void +_mesa_free_display_list_data(struct gl_context *ctx) +{ + free(ctx->ListExt); + ctx->ListExt = NULL; +} diff --git a/mesalib/src/mesa/main/drawpix.c b/mesalib/src/mesa/main/drawpix.c index cf54febe0..89c2b2697 100644 --- a/mesalib/src/mesa/main/drawpix.c +++ b/mesalib/src/mesa/main/drawpix.c @@ -1,302 +1,302 @@ -/* - * 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 "imports.h" -#include "bufferobj.h" -#include "context.h" -#include "drawpix.h" -#include "enums.h" -#include "feedback.h" -#include "framebuffer.h" -#include "mfeatures.h" -#include "pbo.h" -#include "readpix.h" -#include "state.h" -#include "dispatch.h" - - -#if FEATURE_drawpix - - -/* - * Execute glDrawPixels - */ -static void GLAPIENTRY -_mesa_DrawPixels( GLsizei width, GLsizei height, - GLenum format, GLenum type, const GLvoid *pixels ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glDrawPixels(%d, %d, %s, %s, %p) // to %s at %d, %d\n", - width, height, - _mesa_lookup_enum_by_nr(format), - _mesa_lookup_enum_by_nr(type), - pixels, - _mesa_lookup_enum_by_nr(ctx->DrawBuffer->ColorDrawBuffer[0]), - IROUND(ctx->Current.RasterPos[0]), - IROUND(ctx->Current.RasterPos[1])); - - - if (width < 0 || height < 0) { - _mesa_error( ctx, GL_INVALID_VALUE, "glDrawPixels(width or height < 0" ); - return; - } - - /* We're not using the current vertex program, and the driver may install - * its own. Note: this may dirty some state. - */ - _mesa_set_vp_override(ctx, GL_TRUE); - - /* Note: this call does state validation */ - if (!_mesa_valid_to_render(ctx, "glDrawPixels")) { - goto end; /* the error code was recorded */ - } - - if (_mesa_error_check_format_type(ctx, format, type, GL_TRUE)) { - goto end; /* the error code was recorded */ - } - - if (!ctx->Current.RasterPosValid) { - goto end; /* no-op, not an error */ - } - - if (ctx->RenderMode == GL_RENDER) { - if (width > 0 && height > 0) { - /* Round, to satisfy conformance tests (matches SGI's OpenGL) */ - GLint x = IROUND(ctx->Current.RasterPos[0]); - GLint y = IROUND(ctx->Current.RasterPos[1]); - - if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) { - /* unpack from PBO */ - if (!_mesa_validate_pbo_access(2, &ctx->Unpack, width, height, - 1, format, type, INT_MAX, pixels)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glDrawPixels(invalid PBO access)"); - goto end; - } - if (_mesa_bufferobj_mapped(ctx->Unpack.BufferObj)) { - /* buffer is mapped - that's an error */ - _mesa_error(ctx, GL_INVALID_OPERATION, - "glDrawPixels(PBO is mapped)"); - goto end; - } - } - - ctx->Driver.DrawPixels(ctx, x, y, width, height, format, type, - &ctx->Unpack, pixels); - } - } - else if (ctx->RenderMode == GL_FEEDBACK) { - /* Feedback the current raster pos info */ - FLUSH_CURRENT( ctx, 0 ); - _mesa_feedback_token( ctx, (GLfloat) (GLint) GL_DRAW_PIXEL_TOKEN ); - _mesa_feedback_vertex( ctx, - ctx->Current.RasterPos, - ctx->Current.RasterColor, - ctx->Current.RasterTexCoords[0] ); - } - else { - ASSERT(ctx->RenderMode == GL_SELECT); - /* Do nothing. See OpenGL Spec, Appendix B, Corollary 6. */ - } - -end: - _mesa_set_vp_override(ctx, GL_FALSE); -} - - -static void GLAPIENTRY -_mesa_CopyPixels( GLint srcx, GLint srcy, GLsizei width, GLsizei height, - GLenum type ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, - "glCopyPixels(%d, %d, %d, %d, %s) // from %s to %s at %d, %d\n", - srcx, srcy, width, height, - _mesa_lookup_enum_by_nr(type), - _mesa_lookup_enum_by_nr(ctx->ReadBuffer->ColorReadBuffer), - _mesa_lookup_enum_by_nr(ctx->DrawBuffer->ColorDrawBuffer[0]), - IROUND(ctx->Current.RasterPos[0]), - IROUND(ctx->Current.RasterPos[1])); - - if (width < 0 || height < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glCopyPixels(width or height < 0)"); - return; - } - - /* Note: more detailed 'type' checking is done by the - * _mesa_source/dest_buffer_exists() calls below. That's where we - * check if the stencil buffer exists, etc. - */ - if (type != GL_COLOR && - type != GL_DEPTH && - type != GL_STENCIL && - type != GL_DEPTH_STENCIL) { - _mesa_error(ctx, GL_INVALID_ENUM, "glCopyPixels(type=%s)", - _mesa_lookup_enum_by_nr(type)); - return; - } - - /* We're not using the current vertex program, and the driver may install - * it's own. Note: this may dirty some state. - */ - _mesa_set_vp_override(ctx, GL_TRUE); - - /* Note: this call does state validation */ - if (!_mesa_valid_to_render(ctx, "glCopyPixels")) { - goto end; /* the error code was recorded */ - } - - /* Check read buffer's status (draw buffer was already checked) */ - if (ctx->ReadBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) { - _mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION_EXT, - "glCopyPixels(incomplete framebuffer)" ); - goto end; - } - - if (!_mesa_source_buffer_exists(ctx, type) || - !_mesa_dest_buffer_exists(ctx, type)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glCopyPixels(missing source or dest buffer)"); - goto end; - } - - if (!ctx->Current.RasterPosValid || width == 0 || height == 0) { - goto end; /* no-op, not an error */ - } - - if (ctx->RenderMode == GL_RENDER) { - /* Round to satisfy conformance tests (matches SGI's OpenGL) */ - if (width > 0 && height > 0) { - GLint destx = IROUND(ctx->Current.RasterPos[0]); - GLint desty = IROUND(ctx->Current.RasterPos[1]); - ctx->Driver.CopyPixels( ctx, srcx, srcy, width, height, destx, desty, - type ); - } - } - else if (ctx->RenderMode == GL_FEEDBACK) { - FLUSH_CURRENT( ctx, 0 ); - _mesa_feedback_token( ctx, (GLfloat) (GLint) GL_COPY_PIXEL_TOKEN ); - _mesa_feedback_vertex( ctx, - ctx->Current.RasterPos, - ctx->Current.RasterColor, - ctx->Current.RasterTexCoords[0] ); - } - else { - ASSERT(ctx->RenderMode == GL_SELECT); - /* Do nothing. See OpenGL Spec, Appendix B, Corollary 6. */ - } - -end: - _mesa_set_vp_override(ctx, GL_FALSE); -} - - -static void GLAPIENTRY -_mesa_Bitmap( GLsizei width, GLsizei height, - GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, - const GLubyte *bitmap ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (width < 0 || height < 0) { - _mesa_error( ctx, GL_INVALID_VALUE, "glBitmap(width or height < 0)" ); - return; - } - - if (!ctx->Current.RasterPosValid) { - return; /* do nothing */ - } - - /* Note: this call does state validation */ - if (!_mesa_valid_to_render(ctx, "glBitmap")) { - /* the error code was recorded */ - return; - } - - if (ctx->RenderMode == GL_RENDER) { - /* Truncate, to satisfy conformance tests (matches SGI's OpenGL). */ - if (width > 0 && height > 0) { - const GLfloat epsilon = 0.0001F; - GLint x = IFLOOR(ctx->Current.RasterPos[0] + epsilon - xorig); - GLint y = IFLOOR(ctx->Current.RasterPos[1] + epsilon - yorig); - - if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) { - /* unpack from PBO */ - if (!_mesa_validate_pbo_access(2, &ctx->Unpack, width, height, - 1, GL_COLOR_INDEX, GL_BITMAP, - INT_MAX, (const GLvoid *) bitmap)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glBitmap(invalid PBO access)"); - return; - } - if (_mesa_bufferobj_mapped(ctx->Unpack.BufferObj)) { - /* buffer is mapped - that's an error */ - _mesa_error(ctx, GL_INVALID_OPERATION, - "glBitmap(PBO is mapped)"); - return; - } - } - - ctx->Driver.Bitmap( ctx, x, y, width, height, &ctx->Unpack, bitmap ); - } - } -#if _HAVE_FULL_GL - else if (ctx->RenderMode == GL_FEEDBACK) { - FLUSH_CURRENT(ctx, 0); - _mesa_feedback_token( ctx, (GLfloat) (GLint) GL_BITMAP_TOKEN ); - _mesa_feedback_vertex( ctx, - ctx->Current.RasterPos, - ctx->Current.RasterColor, - ctx->Current.RasterTexCoords[0] ); - } - else { - ASSERT(ctx->RenderMode == GL_SELECT); - /* Do nothing. See OpenGL Spec, Appendix B, Corollary 6. */ - } -#endif - - /* update raster position */ - ctx->Current.RasterPos[0] += xmove; - ctx->Current.RasterPos[1] += ymove; -} - - -void -_mesa_init_drawpix_dispatch(struct _glapi_table *disp) -{ - SET_Bitmap(disp, _mesa_Bitmap); - SET_CopyPixels(disp, _mesa_CopyPixels); - SET_DrawPixels(disp, _mesa_DrawPixels); -} - - -#endif /* FEATURE_drawpix */ +/* + * 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 "imports.h" +#include "bufferobj.h" +#include "context.h" +#include "drawpix.h" +#include "enums.h" +#include "feedback.h" +#include "framebuffer.h" +#include "mfeatures.h" +#include "pbo.h" +#include "readpix.h" +#include "state.h" +#include "dispatch.h" + + +#if FEATURE_drawpix + + +/* + * Execute glDrawPixels + */ +static void GLAPIENTRY +_mesa_DrawPixels( GLsizei width, GLsizei height, + GLenum format, GLenum type, const GLvoid *pixels ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glDrawPixels(%d, %d, %s, %s, %p) // to %s at %d, %d\n", + width, height, + _mesa_lookup_enum_by_nr(format), + _mesa_lookup_enum_by_nr(type), + pixels, + _mesa_lookup_enum_by_nr(ctx->DrawBuffer->ColorDrawBuffer[0]), + IROUND(ctx->Current.RasterPos[0]), + IROUND(ctx->Current.RasterPos[1])); + + + if (width < 0 || height < 0) { + _mesa_error( ctx, GL_INVALID_VALUE, "glDrawPixels(width or height < 0" ); + return; + } + + /* We're not using the current vertex program, and the driver may install + * its own. Note: this may dirty some state. + */ + _mesa_set_vp_override(ctx, GL_TRUE); + + /* Note: this call does state validation */ + if (!_mesa_valid_to_render(ctx, "glDrawPixels")) { + goto end; /* the error code was recorded */ + } + + if (_mesa_error_check_format_type(ctx, format, type, GL_TRUE)) { + goto end; /* the error code was recorded */ + } + + if (!ctx->Current.RasterPosValid) { + goto end; /* no-op, not an error */ + } + + if (ctx->RenderMode == GL_RENDER) { + if (width > 0 && height > 0) { + /* Round, to satisfy conformance tests (matches SGI's OpenGL) */ + GLint x = IROUND(ctx->Current.RasterPos[0]); + GLint y = IROUND(ctx->Current.RasterPos[1]); + + if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) { + /* unpack from PBO */ + if (!_mesa_validate_pbo_access(2, &ctx->Unpack, width, height, + 1, format, type, INT_MAX, pixels)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glDrawPixels(invalid PBO access)"); + goto end; + } + if (_mesa_bufferobj_mapped(ctx->Unpack.BufferObj)) { + /* buffer is mapped - that's an error */ + _mesa_error(ctx, GL_INVALID_OPERATION, + "glDrawPixels(PBO is mapped)"); + goto end; + } + } + + ctx->Driver.DrawPixels(ctx, x, y, width, height, format, type, + &ctx->Unpack, pixels); + } + } + else if (ctx->RenderMode == GL_FEEDBACK) { + /* Feedback the current raster pos info */ + FLUSH_CURRENT( ctx, 0 ); + _mesa_feedback_token( ctx, (GLfloat) (GLint) GL_DRAW_PIXEL_TOKEN ); + _mesa_feedback_vertex( ctx, + ctx->Current.RasterPos, + ctx->Current.RasterColor, + ctx->Current.RasterTexCoords[0] ); + } + else { + ASSERT(ctx->RenderMode == GL_SELECT); + /* Do nothing. See OpenGL Spec, Appendix B, Corollary 6. */ + } + +end: + _mesa_set_vp_override(ctx, GL_FALSE); +} + + +static void GLAPIENTRY +_mesa_CopyPixels( GLint srcx, GLint srcy, GLsizei width, GLsizei height, + GLenum type ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, + "glCopyPixels(%d, %d, %d, %d, %s) // from %s to %s at %d, %d\n", + srcx, srcy, width, height, + _mesa_lookup_enum_by_nr(type), + _mesa_lookup_enum_by_nr(ctx->ReadBuffer->ColorReadBuffer), + _mesa_lookup_enum_by_nr(ctx->DrawBuffer->ColorDrawBuffer[0]), + IROUND(ctx->Current.RasterPos[0]), + IROUND(ctx->Current.RasterPos[1])); + + if (width < 0 || height < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glCopyPixels(width or height < 0)"); + return; + } + + /* Note: more detailed 'type' checking is done by the + * _mesa_source/dest_buffer_exists() calls below. That's where we + * check if the stencil buffer exists, etc. + */ + if (type != GL_COLOR && + type != GL_DEPTH && + type != GL_STENCIL && + type != GL_DEPTH_STENCIL) { + _mesa_error(ctx, GL_INVALID_ENUM, "glCopyPixels(type=%s)", + _mesa_lookup_enum_by_nr(type)); + return; + } + + /* We're not using the current vertex program, and the driver may install + * it's own. Note: this may dirty some state. + */ + _mesa_set_vp_override(ctx, GL_TRUE); + + /* Note: this call does state validation */ + if (!_mesa_valid_to_render(ctx, "glCopyPixels")) { + goto end; /* the error code was recorded */ + } + + /* Check read buffer's status (draw buffer was already checked) */ + if (ctx->ReadBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) { + _mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION_EXT, + "glCopyPixels(incomplete framebuffer)" ); + goto end; + } + + if (!_mesa_source_buffer_exists(ctx, type) || + !_mesa_dest_buffer_exists(ctx, type)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glCopyPixels(missing source or dest buffer)"); + goto end; + } + + if (!ctx->Current.RasterPosValid || width == 0 || height == 0) { + goto end; /* no-op, not an error */ + } + + if (ctx->RenderMode == GL_RENDER) { + /* Round to satisfy conformance tests (matches SGI's OpenGL) */ + if (width > 0 && height > 0) { + GLint destx = IROUND(ctx->Current.RasterPos[0]); + GLint desty = IROUND(ctx->Current.RasterPos[1]); + ctx->Driver.CopyPixels( ctx, srcx, srcy, width, height, destx, desty, + type ); + } + } + else if (ctx->RenderMode == GL_FEEDBACK) { + FLUSH_CURRENT( ctx, 0 ); + _mesa_feedback_token( ctx, (GLfloat) (GLint) GL_COPY_PIXEL_TOKEN ); + _mesa_feedback_vertex( ctx, + ctx->Current.RasterPos, + ctx->Current.RasterColor, + ctx->Current.RasterTexCoords[0] ); + } + else { + ASSERT(ctx->RenderMode == GL_SELECT); + /* Do nothing. See OpenGL Spec, Appendix B, Corollary 6. */ + } + +end: + _mesa_set_vp_override(ctx, GL_FALSE); +} + + +static void GLAPIENTRY +_mesa_Bitmap( GLsizei width, GLsizei height, + GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, + const GLubyte *bitmap ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + if (width < 0 || height < 0) { + _mesa_error( ctx, GL_INVALID_VALUE, "glBitmap(width or height < 0)" ); + return; + } + + if (!ctx->Current.RasterPosValid) { + return; /* do nothing */ + } + + /* Note: this call does state validation */ + if (!_mesa_valid_to_render(ctx, "glBitmap")) { + /* the error code was recorded */ + return; + } + + if (ctx->RenderMode == GL_RENDER) { + /* Truncate, to satisfy conformance tests (matches SGI's OpenGL). */ + if (width > 0 && height > 0) { + const GLfloat epsilon = 0.0001F; + GLint x = IFLOOR(ctx->Current.RasterPos[0] + epsilon - xorig); + GLint y = IFLOOR(ctx->Current.RasterPos[1] + epsilon - yorig); + + if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) { + /* unpack from PBO */ + if (!_mesa_validate_pbo_access(2, &ctx->Unpack, width, height, + 1, GL_COLOR_INDEX, GL_BITMAP, + INT_MAX, (const GLvoid *) bitmap)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glBitmap(invalid PBO access)"); + return; + } + if (_mesa_bufferobj_mapped(ctx->Unpack.BufferObj)) { + /* buffer is mapped - that's an error */ + _mesa_error(ctx, GL_INVALID_OPERATION, + "glBitmap(PBO is mapped)"); + return; + } + } + + ctx->Driver.Bitmap( ctx, x, y, width, height, &ctx->Unpack, bitmap ); + } + } +#if _HAVE_FULL_GL + else if (ctx->RenderMode == GL_FEEDBACK) { + FLUSH_CURRENT(ctx, 0); + _mesa_feedback_token( ctx, (GLfloat) (GLint) GL_BITMAP_TOKEN ); + _mesa_feedback_vertex( ctx, + ctx->Current.RasterPos, + ctx->Current.RasterColor, + ctx->Current.RasterTexCoords[0] ); + } + else { + ASSERT(ctx->RenderMode == GL_SELECT); + /* Do nothing. See OpenGL Spec, Appendix B, Corollary 6. */ + } +#endif + + /* update raster position */ + ctx->Current.RasterPos[0] += xmove; + ctx->Current.RasterPos[1] += ymove; +} + + +void +_mesa_init_drawpix_dispatch(struct _glapi_table *disp) +{ + SET_Bitmap(disp, _mesa_Bitmap); + SET_CopyPixels(disp, _mesa_CopyPixels); + SET_DrawPixels(disp, _mesa_DrawPixels); +} + + +#endif /* FEATURE_drawpix */ diff --git a/mesalib/src/mesa/main/enable.c b/mesalib/src/mesa/main/enable.c index 93c675deb..4bf1809e7 100644 --- a/mesalib/src/mesa/main/enable.c +++ b/mesalib/src/mesa/main/enable.c @@ -1,1413 +1,1413 @@ -/** - * \file enable.c - * Enable/disable/query GL capabilities. - */ - -/* - * Mesa 3-D graphics library - * - * 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 "glheader.h" -#include "clip.h" -#include "context.h" -#include "enable.h" -#include "light.h" -#include "simple_list.h" -#include "mfeatures.h" -#include "mtypes.h" -#include "enums.h" -#include "api_arrayelt.h" -#include "texstate.h" - - - -#define CHECK_EXTENSION(EXTNAME, CAP) \ - if (!ctx->Extensions.EXTNAME) { \ - goto invalid_enum_error; \ - } - - -/** - * Helper to enable/disable client-side state. - */ -static void -client_state(struct gl_context *ctx, GLenum cap, GLboolean state) -{ - struct gl_array_object *arrayObj = ctx->Array.ArrayObj; - GLuint flag; - GLboolean *var; - - switch (cap) { - case GL_VERTEX_ARRAY: - var = &arrayObj->Vertex.Enabled; - flag = _NEW_ARRAY_VERTEX; - break; - case GL_NORMAL_ARRAY: - var = &arrayObj->Normal.Enabled; - flag = _NEW_ARRAY_NORMAL; - break; - case GL_COLOR_ARRAY: - var = &arrayObj->Color.Enabled; - flag = _NEW_ARRAY_COLOR0; - break; - case GL_INDEX_ARRAY: - var = &arrayObj->Index.Enabled; - flag = _NEW_ARRAY_INDEX; - break; - case GL_TEXTURE_COORD_ARRAY: - var = &arrayObj->TexCoord[ctx->Array.ActiveTexture].Enabled; - flag = _NEW_ARRAY_TEXCOORD(ctx->Array.ActiveTexture); - break; - case GL_EDGE_FLAG_ARRAY: - var = &arrayObj->EdgeFlag.Enabled; - flag = _NEW_ARRAY_EDGEFLAG; - break; - case GL_FOG_COORDINATE_ARRAY_EXT: - var = &arrayObj->FogCoord.Enabled; - flag = _NEW_ARRAY_FOGCOORD; - break; - case GL_SECONDARY_COLOR_ARRAY_EXT: - var = &arrayObj->SecondaryColor.Enabled; - flag = _NEW_ARRAY_COLOR1; - break; - -#if FEATURE_point_size_array - case GL_POINT_SIZE_ARRAY_OES: - var = &arrayObj->PointSize.Enabled; - flag = _NEW_ARRAY_POINT_SIZE; - break; -#endif - -#if FEATURE_NV_vertex_program - case GL_VERTEX_ATTRIB_ARRAY0_NV: - case GL_VERTEX_ATTRIB_ARRAY1_NV: - case GL_VERTEX_ATTRIB_ARRAY2_NV: - case GL_VERTEX_ATTRIB_ARRAY3_NV: - case GL_VERTEX_ATTRIB_ARRAY4_NV: - case GL_VERTEX_ATTRIB_ARRAY5_NV: - case GL_VERTEX_ATTRIB_ARRAY6_NV: - case GL_VERTEX_ATTRIB_ARRAY7_NV: - case GL_VERTEX_ATTRIB_ARRAY8_NV: - case GL_VERTEX_ATTRIB_ARRAY9_NV: - case GL_VERTEX_ATTRIB_ARRAY10_NV: - case GL_VERTEX_ATTRIB_ARRAY11_NV: - case GL_VERTEX_ATTRIB_ARRAY12_NV: - case GL_VERTEX_ATTRIB_ARRAY13_NV: - case GL_VERTEX_ATTRIB_ARRAY14_NV: - case GL_VERTEX_ATTRIB_ARRAY15_NV: - CHECK_EXTENSION(NV_vertex_program, cap); - { - GLint n = (GLint) cap - GL_VERTEX_ATTRIB_ARRAY0_NV; - ASSERT(n < Elements(ctx->Array.ArrayObj->VertexAttrib)); - var = &arrayObj->VertexAttrib[n].Enabled; - flag = _NEW_ARRAY_ATTRIB(n); - } - break; -#endif /* FEATURE_NV_vertex_program */ - - /* GL_NV_primitive_restart */ - case GL_PRIMITIVE_RESTART_NV: - if (!ctx->Extensions.NV_primitive_restart) { - goto invalid_enum_error; - } - var = &ctx->Array.PrimitiveRestart; - flag = 0; - break; - - default: - goto invalid_enum_error; - } - - if (*var == state) - return; - - FLUSH_VERTICES(ctx, _NEW_ARRAY); - ctx->Array.NewState |= flag; - - _ae_invalidate_state(ctx, _NEW_ARRAY); - - *var = state; - - if (state) - ctx->Array.ArrayObj->_Enabled |= flag; - else - ctx->Array.ArrayObj->_Enabled &= ~flag; - - if (ctx->Driver.Enable) { - ctx->Driver.Enable( ctx, cap, state ); - } - - return; - -invalid_enum_error: - _mesa_error(ctx, GL_INVALID_ENUM, "gl%sClientState(0x%x)", - state ? "Enable" : "Disable", cap); -} - - -/** - * Enable GL capability. - * \param cap state to enable/disable. - * - * Get's the current context, assures that we're outside glBegin()/glEnd() and - * calls client_state(). - */ -void GLAPIENTRY -_mesa_EnableClientState( GLenum cap ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - client_state( ctx, cap, GL_TRUE ); -} - - -/** - * Disable GL capability. - * \param cap state to enable/disable. - * - * Get's the current context, assures that we're outside glBegin()/glEnd() and - * calls client_state(). - */ -void GLAPIENTRY -_mesa_DisableClientState( GLenum cap ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - client_state( ctx, cap, GL_FALSE ); -} - - -#undef CHECK_EXTENSION -#define CHECK_EXTENSION(EXTNAME, CAP) \ - if (!ctx->Extensions.EXTNAME) { \ - goto invalid_enum_error; \ - } - -#define CHECK_EXTENSION2(EXT1, EXT2, CAP) \ - if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \ - goto invalid_enum_error; \ - } - - - -/** - * Return pointer to current texture unit for setting/getting coordinate - * state. - * Note that we'll set GL_INVALID_OPERATION and return NULL if the active - * texture unit is higher than the number of supported coordinate units. - */ -static struct gl_texture_unit * -get_texcoord_unit(struct gl_context *ctx) -{ - if (ctx->Texture.CurrentUnit >= ctx->Const.MaxTextureCoordUnits) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glEnable/Disable(texcoord unit)"); - return NULL; - } - else { - return &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; - } -} - - -/** - * Helper function to enable or disable a texture target. - * \param bit one of the TEXTURE_x_BIT values - * \return GL_TRUE if state is changing or GL_FALSE if no change - */ -static GLboolean -enable_texture(struct gl_context *ctx, GLboolean state, GLbitfield texBit) -{ - struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx); - const GLbitfield newenabled = state - ? (texUnit->Enabled | texBit) : (texUnit->Enabled & ~texBit); - - if (texUnit->Enabled == newenabled) - return GL_FALSE; - - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - texUnit->Enabled = newenabled; - return GL_TRUE; -} - - -/** - * Helper function to enable or disable state. - * - * \param ctx GL context. - * \param cap the state to enable/disable - * \param state whether to enable or disable the specified capability. - * - * Updates the current context and flushes the vertices as needed. For - * capabilities associated with extensions it verifies that those extensions - * are effectivly present before updating. Notifies the driver via - * dd_function_table::Enable. - */ -void -_mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) -{ - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "%s %s (newstate is %x)\n", - state ? "glEnable" : "glDisable", - _mesa_lookup_enum_by_nr(cap), - ctx->NewState); - - switch (cap) { - case GL_ALPHA_TEST: - if (ctx->Color.AlphaEnabled == state) - return; - FLUSH_VERTICES(ctx, _NEW_COLOR); - ctx->Color.AlphaEnabled = state; - break; - case GL_AUTO_NORMAL: - if (ctx->Eval.AutoNormal == state) - return; - FLUSH_VERTICES(ctx, _NEW_EVAL); - ctx->Eval.AutoNormal = state; - break; - case GL_BLEND: - { - GLbitfield newEnabled = - state * ((1 << ctx->Const.MaxDrawBuffers) - 1); - if (newEnabled != ctx->Color.BlendEnabled) { - FLUSH_VERTICES(ctx, _NEW_COLOR); - ctx->Color.BlendEnabled = newEnabled; - } - } - break; -#if FEATURE_userclip - case GL_CLIP_PLANE0: - case GL_CLIP_PLANE1: - case GL_CLIP_PLANE2: - case GL_CLIP_PLANE3: - case GL_CLIP_PLANE4: - case GL_CLIP_PLANE5: - { - const GLuint p = cap - GL_CLIP_PLANE0; - - if ((ctx->Transform.ClipPlanesEnabled & (1 << p)) - == ((GLuint) state << p)) - return; - - FLUSH_VERTICES(ctx, _NEW_TRANSFORM); - - if (state) { - ctx->Transform.ClipPlanesEnabled |= (1 << p); - _mesa_update_clip_plane(ctx, p); - } - else { - ctx->Transform.ClipPlanesEnabled &= ~(1 << p); - } - } - break; -#endif - case GL_COLOR_MATERIAL: - if (ctx->Light.ColorMaterialEnabled == state) - return; - FLUSH_VERTICES(ctx, _NEW_LIGHT); - FLUSH_CURRENT(ctx, 0); - ctx->Light.ColorMaterialEnabled = state; - if (state) { - _mesa_update_color_material( ctx, - ctx->Current.Attrib[VERT_ATTRIB_COLOR0] ); - } - break; - case GL_CULL_FACE: - if (ctx->Polygon.CullFlag == state) - return; - FLUSH_VERTICES(ctx, _NEW_POLYGON); - ctx->Polygon.CullFlag = state; - break; - case GL_DEPTH_TEST: - if (ctx->Depth.Test == state) - return; - FLUSH_VERTICES(ctx, _NEW_DEPTH); - ctx->Depth.Test = state; - break; - case GL_DITHER: - if (ctx->Color.DitherFlag == state) - return; - FLUSH_VERTICES(ctx, _NEW_COLOR); - ctx->Color.DitherFlag = state; - break; - case GL_FOG: - if (ctx->Fog.Enabled == state) - return; - FLUSH_VERTICES(ctx, _NEW_FOG); - ctx->Fog.Enabled = state; - break; - case GL_LIGHT0: - case GL_LIGHT1: - case GL_LIGHT2: - case GL_LIGHT3: - case GL_LIGHT4: - case GL_LIGHT5: - case GL_LIGHT6: - case GL_LIGHT7: - if (ctx->Light.Light[cap-GL_LIGHT0].Enabled == state) - return; - FLUSH_VERTICES(ctx, _NEW_LIGHT); - ctx->Light.Light[cap-GL_LIGHT0].Enabled = state; - if (state) { - insert_at_tail(&ctx->Light.EnabledList, - &ctx->Light.Light[cap-GL_LIGHT0]); - } - else { - remove_from_list(&ctx->Light.Light[cap-GL_LIGHT0]); - } - break; - case GL_LIGHTING: - if (ctx->Light.Enabled == state) - return; - FLUSH_VERTICES(ctx, _NEW_LIGHT); - ctx->Light.Enabled = state; - if (ctx->Light.Enabled && ctx->Light.Model.TwoSide) - ctx->_TriangleCaps |= DD_TRI_LIGHT_TWOSIDE; - else - ctx->_TriangleCaps &= ~DD_TRI_LIGHT_TWOSIDE; - break; - case GL_LINE_SMOOTH: - if (ctx->Line.SmoothFlag == state) - return; - FLUSH_VERTICES(ctx, _NEW_LINE); - ctx->Line.SmoothFlag = state; - ctx->_TriangleCaps ^= DD_LINE_SMOOTH; - break; - case GL_LINE_STIPPLE: - if (ctx->Line.StippleFlag == state) - return; - FLUSH_VERTICES(ctx, _NEW_LINE); - ctx->Line.StippleFlag = state; - ctx->_TriangleCaps ^= DD_LINE_STIPPLE; - break; - case GL_INDEX_LOGIC_OP: - if (ctx->Color.IndexLogicOpEnabled == state) - return; - FLUSH_VERTICES(ctx, _NEW_COLOR); - ctx->Color.IndexLogicOpEnabled = state; - break; - case GL_COLOR_LOGIC_OP: - if (ctx->Color.ColorLogicOpEnabled == state) - return; - FLUSH_VERTICES(ctx, _NEW_COLOR); - ctx->Color.ColorLogicOpEnabled = state; - break; - case GL_MAP1_COLOR_4: - if (ctx->Eval.Map1Color4 == state) - return; - FLUSH_VERTICES(ctx, _NEW_EVAL); - ctx->Eval.Map1Color4 = state; - break; - case GL_MAP1_INDEX: - if (ctx->Eval.Map1Index == state) - return; - FLUSH_VERTICES(ctx, _NEW_EVAL); - ctx->Eval.Map1Index = state; - break; - case GL_MAP1_NORMAL: - if (ctx->Eval.Map1Normal == state) - return; - FLUSH_VERTICES(ctx, _NEW_EVAL); - ctx->Eval.Map1Normal = state; - break; - case GL_MAP1_TEXTURE_COORD_1: - if (ctx->Eval.Map1TextureCoord1 == state) - return; - FLUSH_VERTICES(ctx, _NEW_EVAL); - ctx->Eval.Map1TextureCoord1 = state; - break; - case GL_MAP1_TEXTURE_COORD_2: - if (ctx->Eval.Map1TextureCoord2 == state) - return; - FLUSH_VERTICES(ctx, _NEW_EVAL); - ctx->Eval.Map1TextureCoord2 = state; - break; - case GL_MAP1_TEXTURE_COORD_3: - if (ctx->Eval.Map1TextureCoord3 == state) - return; - FLUSH_VERTICES(ctx, _NEW_EVAL); - ctx->Eval.Map1TextureCoord3 = state; - break; - case GL_MAP1_TEXTURE_COORD_4: - if (ctx->Eval.Map1TextureCoord4 == state) - return; - FLUSH_VERTICES(ctx, _NEW_EVAL); - ctx->Eval.Map1TextureCoord4 = state; - break; - case GL_MAP1_VERTEX_3: - if (ctx->Eval.Map1Vertex3 == state) - return; - FLUSH_VERTICES(ctx, _NEW_EVAL); - ctx->Eval.Map1Vertex3 = state; - break; - case GL_MAP1_VERTEX_4: - if (ctx->Eval.Map1Vertex4 == state) - return; - FLUSH_VERTICES(ctx, _NEW_EVAL); - ctx->Eval.Map1Vertex4 = state; - break; - case GL_MAP2_COLOR_4: - if (ctx->Eval.Map2Color4 == state) - return; - FLUSH_VERTICES(ctx, _NEW_EVAL); - ctx->Eval.Map2Color4 = state; - break; - case GL_MAP2_INDEX: - if (ctx->Eval.Map2Index == state) - return; - FLUSH_VERTICES(ctx, _NEW_EVAL); - ctx->Eval.Map2Index = state; - break; - case GL_MAP2_NORMAL: - if (ctx->Eval.Map2Normal == state) - return; - FLUSH_VERTICES(ctx, _NEW_EVAL); - ctx->Eval.Map2Normal = state; - break; - case GL_MAP2_TEXTURE_COORD_1: - if (ctx->Eval.Map2TextureCoord1 == state) - return; - FLUSH_VERTICES(ctx, _NEW_EVAL); - ctx->Eval.Map2TextureCoord1 = state; - break; - case GL_MAP2_TEXTURE_COORD_2: - if (ctx->Eval.Map2TextureCoord2 == state) - return; - FLUSH_VERTICES(ctx, _NEW_EVAL); - ctx->Eval.Map2TextureCoord2 = state; - break; - case GL_MAP2_TEXTURE_COORD_3: - if (ctx->Eval.Map2TextureCoord3 == state) - return; - FLUSH_VERTICES(ctx, _NEW_EVAL); - ctx->Eval.Map2TextureCoord3 = state; - break; - case GL_MAP2_TEXTURE_COORD_4: - if (ctx->Eval.Map2TextureCoord4 == state) - return; - FLUSH_VERTICES(ctx, _NEW_EVAL); - ctx->Eval.Map2TextureCoord4 = state; - break; - case GL_MAP2_VERTEX_3: - if (ctx->Eval.Map2Vertex3 == state) - return; - FLUSH_VERTICES(ctx, _NEW_EVAL); - ctx->Eval.Map2Vertex3 = state; - break; - case GL_MAP2_VERTEX_4: - if (ctx->Eval.Map2Vertex4 == state) - return; - FLUSH_VERTICES(ctx, _NEW_EVAL); - ctx->Eval.Map2Vertex4 = state; - break; - case GL_NORMALIZE: - if (ctx->Transform.Normalize == state) - return; - FLUSH_VERTICES(ctx, _NEW_TRANSFORM); - ctx->Transform.Normalize = state; - break; - case GL_POINT_SMOOTH: - if (ctx->Point.SmoothFlag == state) - return; - FLUSH_VERTICES(ctx, _NEW_POINT); - ctx->Point.SmoothFlag = state; - ctx->_TriangleCaps ^= DD_POINT_SMOOTH; - break; - case GL_POLYGON_SMOOTH: - if (ctx->Polygon.SmoothFlag == state) - return; - FLUSH_VERTICES(ctx, _NEW_POLYGON); - ctx->Polygon.SmoothFlag = state; - ctx->_TriangleCaps ^= DD_TRI_SMOOTH; - break; - case GL_POLYGON_STIPPLE: - if (ctx->Polygon.StippleFlag == state) - return; - FLUSH_VERTICES(ctx, _NEW_POLYGON); - ctx->Polygon.StippleFlag = state; - ctx->_TriangleCaps ^= DD_TRI_STIPPLE; - break; - case GL_POLYGON_OFFSET_POINT: - if (ctx->Polygon.OffsetPoint == state) - return; - FLUSH_VERTICES(ctx, _NEW_POLYGON); - ctx->Polygon.OffsetPoint = state; - break; - case GL_POLYGON_OFFSET_LINE: - if (ctx->Polygon.OffsetLine == state) - return; - FLUSH_VERTICES(ctx, _NEW_POLYGON); - ctx->Polygon.OffsetLine = state; - break; - case GL_POLYGON_OFFSET_FILL: - if (ctx->Polygon.OffsetFill == state) - return; - FLUSH_VERTICES(ctx, _NEW_POLYGON); - ctx->Polygon.OffsetFill = state; - break; - case GL_RESCALE_NORMAL_EXT: - if (ctx->Transform.RescaleNormals == state) - return; - FLUSH_VERTICES(ctx, _NEW_TRANSFORM); - ctx->Transform.RescaleNormals = state; - break; - case GL_SCISSOR_TEST: - if (ctx->Scissor.Enabled == state) - return; - FLUSH_VERTICES(ctx, _NEW_SCISSOR); - ctx->Scissor.Enabled = state; - break; - case GL_STENCIL_TEST: - if (ctx->Stencil.Enabled == state) - return; - FLUSH_VERTICES(ctx, _NEW_STENCIL); - ctx->Stencil.Enabled = state; - break; - case GL_TEXTURE_1D: - if (!enable_texture(ctx, state, TEXTURE_1D_BIT)) { - return; - } - break; - case GL_TEXTURE_2D: - if (!enable_texture(ctx, state, TEXTURE_2D_BIT)) { - return; - } - break; - case GL_TEXTURE_3D: - if (!enable_texture(ctx, state, TEXTURE_3D_BIT)) { - return; - } - break; - case GL_TEXTURE_GEN_S: - case GL_TEXTURE_GEN_T: - case GL_TEXTURE_GEN_R: - case GL_TEXTURE_GEN_Q: - { - struct gl_texture_unit *texUnit = get_texcoord_unit(ctx); - if (texUnit) { - GLbitfield coordBit = S_BIT << (cap - GL_TEXTURE_GEN_S); - GLbitfield newenabled = texUnit->TexGenEnabled & ~coordBit; - if (state) - newenabled |= coordBit; - if (texUnit->TexGenEnabled == newenabled) - return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - texUnit->TexGenEnabled = newenabled; - } - } - break; - -#if FEATURE_ES1 - case GL_TEXTURE_GEN_STR_OES: - /* disable S, T, and R at the same time */ - { - struct gl_texture_unit *texUnit = get_texcoord_unit(ctx); - if (texUnit) { - GLuint newenabled = - texUnit->TexGenEnabled & ~STR_BITS; - if (state) - newenabled |= STR_BITS; - if (texUnit->TexGenEnabled == newenabled) - return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - texUnit->TexGenEnabled = newenabled; - } - } - break; -#endif - - /* client-side state */ - case GL_VERTEX_ARRAY: - case GL_NORMAL_ARRAY: - case GL_COLOR_ARRAY: - case GL_INDEX_ARRAY: - case GL_TEXTURE_COORD_ARRAY: - case GL_EDGE_FLAG_ARRAY: - case GL_FOG_COORDINATE_ARRAY_EXT: - case GL_SECONDARY_COLOR_ARRAY_EXT: - case GL_POINT_SIZE_ARRAY_OES: - client_state( ctx, cap, state ); - return; - - /* GL_ARB_texture_cube_map */ - case GL_TEXTURE_CUBE_MAP_ARB: - CHECK_EXTENSION(ARB_texture_cube_map, cap); - if (!enable_texture(ctx, state, TEXTURE_CUBE_BIT)) { - return; - } - break; - - /* GL_EXT_secondary_color */ - case GL_COLOR_SUM_EXT: - CHECK_EXTENSION2(EXT_secondary_color, ARB_vertex_program, cap); - if (ctx->Fog.ColorSumEnabled == state) - return; - FLUSH_VERTICES(ctx, _NEW_FOG); - ctx->Fog.ColorSumEnabled = state; - break; - - /* GL_ARB_multisample */ - case GL_MULTISAMPLE_ARB: - if (ctx->Multisample.Enabled == state) - return; - FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE); - ctx->Multisample.Enabled = state; - break; - case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB: - if (ctx->Multisample.SampleAlphaToCoverage == state) - return; - FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE); - ctx->Multisample.SampleAlphaToCoverage = state; - break; - case GL_SAMPLE_ALPHA_TO_ONE_ARB: - if (ctx->Multisample.SampleAlphaToOne == state) - return; - FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE); - ctx->Multisample.SampleAlphaToOne = state; - break; - case GL_SAMPLE_COVERAGE_ARB: - if (ctx->Multisample.SampleCoverage == state) - return; - FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE); - ctx->Multisample.SampleCoverage = state; - break; - case GL_SAMPLE_COVERAGE_INVERT_ARB: - if (ctx->Multisample.SampleCoverageInvert == state) - return; - FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE); - ctx->Multisample.SampleCoverageInvert = state; - break; - - /* GL_IBM_rasterpos_clip */ - case GL_RASTER_POSITION_UNCLIPPED_IBM: - CHECK_EXTENSION(IBM_rasterpos_clip, cap); - if (ctx->Transform.RasterPositionUnclipped == state) - return; - FLUSH_VERTICES(ctx, _NEW_TRANSFORM); - ctx->Transform.RasterPositionUnclipped = state; - break; - - /* GL_NV_point_sprite */ - case GL_POINT_SPRITE_NV: - CHECK_EXTENSION2(NV_point_sprite, ARB_point_sprite, cap); - if (ctx->Point.PointSprite == state) - return; - FLUSH_VERTICES(ctx, _NEW_POINT); - ctx->Point.PointSprite = state; - break; - -#if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program - case GL_VERTEX_PROGRAM_ARB: - CHECK_EXTENSION2(ARB_vertex_program, NV_vertex_program, cap); - if (ctx->VertexProgram.Enabled == state) - return; - FLUSH_VERTICES(ctx, _NEW_PROGRAM); - ctx->VertexProgram.Enabled = state; - break; - case GL_VERTEX_PROGRAM_POINT_SIZE_ARB: - CHECK_EXTENSION2(ARB_vertex_program, NV_vertex_program, cap); - if (ctx->VertexProgram.PointSizeEnabled == state) - return; - FLUSH_VERTICES(ctx, _NEW_PROGRAM); - ctx->VertexProgram.PointSizeEnabled = state; - break; - case GL_VERTEX_PROGRAM_TWO_SIDE_ARB: - CHECK_EXTENSION2(ARB_vertex_program, NV_vertex_program, cap); - if (ctx->VertexProgram.TwoSideEnabled == state) - return; - FLUSH_VERTICES(ctx, _NEW_PROGRAM); - ctx->VertexProgram.TwoSideEnabled = state; - break; -#endif -#if FEATURE_NV_vertex_program - case GL_MAP1_VERTEX_ATTRIB0_4_NV: - case GL_MAP1_VERTEX_ATTRIB1_4_NV: - case GL_MAP1_VERTEX_ATTRIB2_4_NV: - case GL_MAP1_VERTEX_ATTRIB3_4_NV: - case GL_MAP1_VERTEX_ATTRIB4_4_NV: - case GL_MAP1_VERTEX_ATTRIB5_4_NV: - case GL_MAP1_VERTEX_ATTRIB6_4_NV: - case GL_MAP1_VERTEX_ATTRIB7_4_NV: - case GL_MAP1_VERTEX_ATTRIB8_4_NV: - case GL_MAP1_VERTEX_ATTRIB9_4_NV: - case GL_MAP1_VERTEX_ATTRIB10_4_NV: - case GL_MAP1_VERTEX_ATTRIB11_4_NV: - case GL_MAP1_VERTEX_ATTRIB12_4_NV: - case GL_MAP1_VERTEX_ATTRIB13_4_NV: - case GL_MAP1_VERTEX_ATTRIB14_4_NV: - case GL_MAP1_VERTEX_ATTRIB15_4_NV: - CHECK_EXTENSION(NV_vertex_program, cap); - { - const GLuint map = (GLuint) (cap - GL_MAP1_VERTEX_ATTRIB0_4_NV); - FLUSH_VERTICES(ctx, _NEW_EVAL); - ctx->Eval.Map1Attrib[map] = state; - } - break; - case GL_MAP2_VERTEX_ATTRIB0_4_NV: - case GL_MAP2_VERTEX_ATTRIB1_4_NV: - case GL_MAP2_VERTEX_ATTRIB2_4_NV: - case GL_MAP2_VERTEX_ATTRIB3_4_NV: - case GL_MAP2_VERTEX_ATTRIB4_4_NV: - case GL_MAP2_VERTEX_ATTRIB5_4_NV: - case GL_MAP2_VERTEX_ATTRIB6_4_NV: - case GL_MAP2_VERTEX_ATTRIB7_4_NV: - case GL_MAP2_VERTEX_ATTRIB8_4_NV: - case GL_MAP2_VERTEX_ATTRIB9_4_NV: - case GL_MAP2_VERTEX_ATTRIB10_4_NV: - case GL_MAP2_VERTEX_ATTRIB11_4_NV: - case GL_MAP2_VERTEX_ATTRIB12_4_NV: - case GL_MAP2_VERTEX_ATTRIB13_4_NV: - case GL_MAP2_VERTEX_ATTRIB14_4_NV: - case GL_MAP2_VERTEX_ATTRIB15_4_NV: - CHECK_EXTENSION(NV_vertex_program, cap); - { - const GLuint map = (GLuint) (cap - GL_MAP2_VERTEX_ATTRIB0_4_NV); - FLUSH_VERTICES(ctx, _NEW_EVAL); - ctx->Eval.Map2Attrib[map] = state; - } - break; -#endif /* FEATURE_NV_vertex_program */ - -#if FEATURE_NV_fragment_program - case GL_FRAGMENT_PROGRAM_NV: - CHECK_EXTENSION(NV_fragment_program, cap); - if (ctx->FragmentProgram.Enabled == state) - return; - FLUSH_VERTICES(ctx, _NEW_PROGRAM); - ctx->FragmentProgram.Enabled = state; - break; -#endif /* FEATURE_NV_fragment_program */ - - /* GL_NV_texture_rectangle */ - case GL_TEXTURE_RECTANGLE_NV: - CHECK_EXTENSION(NV_texture_rectangle, cap); - if (!enable_texture(ctx, state, TEXTURE_RECT_BIT)) { - return; - } - break; - - /* GL_EXT_stencil_two_side */ - case GL_STENCIL_TEST_TWO_SIDE_EXT: - CHECK_EXTENSION(EXT_stencil_two_side, cap); - if (ctx->Stencil.TestTwoSide == state) - return; - FLUSH_VERTICES(ctx, _NEW_STENCIL); - ctx->Stencil.TestTwoSide = state; - if (state) { - ctx->Stencil._BackFace = 2; - ctx->_TriangleCaps |= DD_TRI_TWOSTENCIL; - } else { - ctx->Stencil._BackFace = 1; - ctx->_TriangleCaps &= ~DD_TRI_TWOSTENCIL; - } - break; - -#if FEATURE_ARB_fragment_program - case GL_FRAGMENT_PROGRAM_ARB: - CHECK_EXTENSION(ARB_fragment_program, cap); - if (ctx->FragmentProgram.Enabled == state) - return; - FLUSH_VERTICES(ctx, _NEW_PROGRAM); - ctx->FragmentProgram.Enabled = state; - break; -#endif /* FEATURE_ARB_fragment_program */ - - /* GL_EXT_depth_bounds_test */ - case GL_DEPTH_BOUNDS_TEST_EXT: - CHECK_EXTENSION(EXT_depth_bounds_test, cap); - if (ctx->Depth.BoundsTest == state) - return; - FLUSH_VERTICES(ctx, _NEW_DEPTH); - ctx->Depth.BoundsTest = state; - break; - - case GL_DEPTH_CLAMP: - if (ctx->Transform.DepthClamp == state) - return; - CHECK_EXTENSION(ARB_depth_clamp, cap); - FLUSH_VERTICES(ctx, _NEW_TRANSFORM); - ctx->Transform.DepthClamp = state; - break; - -#if FEATURE_ATI_fragment_shader - case GL_FRAGMENT_SHADER_ATI: - CHECK_EXTENSION(ATI_fragment_shader, cap); - if (ctx->ATIFragmentShader.Enabled == state) - return; - FLUSH_VERTICES(ctx, _NEW_PROGRAM); - ctx->ATIFragmentShader.Enabled = state; - break; -#endif - - /* GL_MESA_texture_array */ - case GL_TEXTURE_1D_ARRAY_EXT: - CHECK_EXTENSION(MESA_texture_array, cap); - if (!enable_texture(ctx, state, TEXTURE_1D_ARRAY_BIT)) { - return; - } - break; - - case GL_TEXTURE_2D_ARRAY_EXT: - CHECK_EXTENSION(MESA_texture_array, cap); - if (!enable_texture(ctx, state, TEXTURE_2D_ARRAY_BIT)) { - return; - } - break; - - case GL_TEXTURE_CUBE_MAP_SEAMLESS: - CHECK_EXTENSION(ARB_seamless_cube_map, cap); - if (ctx->Texture.CubeMapSeamless != state) { - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - ctx->Texture.CubeMapSeamless = state; - } - break; - -#if FEATURE_EXT_transform_feedback - case GL_RASTERIZER_DISCARD: - CHECK_EXTENSION(EXT_transform_feedback, cap); - if (ctx->TransformFeedback.RasterDiscard != state) { - FLUSH_VERTICES(ctx, _NEW_TRANSFORM); - ctx->TransformFeedback.RasterDiscard = state; - } - break; -#endif - - /* GL 3.1 primitive restart. Note: this enum is different from - * GL_PRIMITIVE_RESTART_NV (which is client state). - */ - case GL_PRIMITIVE_RESTART: - if (ctx->VersionMajor * 10 + ctx->VersionMinor < 31) { - goto invalid_enum_error; - } - if (ctx->Array.PrimitiveRestart != state) { - FLUSH_VERTICES(ctx, _NEW_TRANSFORM); - ctx->Array.PrimitiveRestart = state; - } - break; - - /* GL3.0 - GL_framebuffer_sRGB */ - case GL_FRAMEBUFFER_SRGB_EXT: - CHECK_EXTENSION(EXT_framebuffer_sRGB, cap); - FLUSH_VERTICES(ctx, _NEW_BUFFERS); - ctx->Color.sRGBEnabled = state; - break; - - default: - goto invalid_enum_error; - } - - if (ctx->Driver.Enable) { - ctx->Driver.Enable( ctx, cap, state ); - } - - return; - -invalid_enum_error: - _mesa_error(ctx, GL_INVALID_ENUM, "gl%s(0x%x)", - state ? "Enable" : "Disable", cap); -} - - -/** - * Enable GL capability. Called by glEnable() - * \param cap state to enable. - */ -void GLAPIENTRY -_mesa_Enable( GLenum cap ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - _mesa_set_enable( ctx, cap, GL_TRUE ); -} - - -/** - * Disable GL capability. Called by glDisable() - * \param cap state to disable. - */ -void GLAPIENTRY -_mesa_Disable( GLenum cap ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - _mesa_set_enable( ctx, cap, GL_FALSE ); -} - - - -/** - * Enable/disable an indexed state var. - */ -void -_mesa_set_enablei(struct gl_context *ctx, GLenum cap, - GLuint index, GLboolean state) -{ - ASSERT(state == 0 || state == 1); - switch (cap) { - case GL_BLEND: - if (!ctx->Extensions.EXT_draw_buffers2) { - goto invalid_enum_error; - } - if (index >= ctx->Const.MaxDrawBuffers) { - _mesa_error(ctx, GL_INVALID_VALUE, "%s(index=%u)", - state ? "glEnableIndexed" : "glDisableIndexed", index); - return; - } - if (((ctx->Color.BlendEnabled >> index) & 1) != state) { - FLUSH_VERTICES(ctx, _NEW_COLOR); - if (state) - ctx->Color.BlendEnabled |= (1 << index); - else - ctx->Color.BlendEnabled &= ~(1 << index); - } - break; - default: - goto invalid_enum_error; - } - return; - -invalid_enum_error: - _mesa_error(ctx, GL_INVALID_ENUM, "%s(cap=%s)", - state ? "glEnablei" : "glDisablei", - _mesa_lookup_enum_by_nr(cap)); -} - - -void GLAPIENTRY -_mesa_DisableIndexed( GLenum cap, GLuint index ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - _mesa_set_enablei(ctx, cap, index, GL_FALSE); -} - - -void GLAPIENTRY -_mesa_EnableIndexed( GLenum cap, GLuint index ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - _mesa_set_enablei(ctx, cap, index, GL_TRUE); -} - - -GLboolean GLAPIENTRY -_mesa_IsEnabledIndexed( GLenum cap, GLuint index ) -{ - GET_CURRENT_CONTEXT(ctx); - switch (cap) { - case GL_BLEND: - if (index >= ctx->Const.MaxDrawBuffers) { - _mesa_error(ctx, GL_INVALID_VALUE, "glIsEnabledIndexed(index=%u)", - index); - return GL_FALSE; - } - return (ctx->Color.BlendEnabled >> index) & 1; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glIsEnabledIndexed(cap=%s)", - _mesa_lookup_enum_by_nr(cap)); - return GL_FALSE; - } -} - - - - -#undef CHECK_EXTENSION -#define CHECK_EXTENSION(EXTNAME) \ - if (!ctx->Extensions.EXTNAME) { \ - goto invalid_enum_error; \ - } - -#undef CHECK_EXTENSION2 -#define CHECK_EXTENSION2(EXT1, EXT2) \ - if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \ - goto invalid_enum_error; \ - } - - -/** - * Helper function to determine whether a texture target is enabled. - */ -static GLboolean -is_texture_enabled(struct gl_context *ctx, GLbitfield bit) -{ - const struct gl_texture_unit *const texUnit = - &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; - return (texUnit->Enabled & bit) ? GL_TRUE : GL_FALSE; -} - - -/** - * Return simple enable/disable state. - * - * \param cap state variable to query. - * - * Returns the state of the specified capability from the current GL context. - * For the capabilities associated with extensions verifies that those - * extensions are effectively present before reporting. - */ -GLboolean GLAPIENTRY -_mesa_IsEnabled( GLenum cap ) -{ - GET_CURRENT_CONTEXT(ctx); - switch (cap) { - case GL_ALPHA_TEST: - return ctx->Color.AlphaEnabled; - case GL_AUTO_NORMAL: - return ctx->Eval.AutoNormal; - case GL_BLEND: - return ctx->Color.BlendEnabled & 1; /* return state for buffer[0] */ - case GL_CLIP_PLANE0: - case GL_CLIP_PLANE1: - case GL_CLIP_PLANE2: - case GL_CLIP_PLANE3: - case GL_CLIP_PLANE4: - case GL_CLIP_PLANE5: - return (ctx->Transform.ClipPlanesEnabled >> (cap - GL_CLIP_PLANE0)) & 1; - case GL_COLOR_MATERIAL: - return ctx->Light.ColorMaterialEnabled; - case GL_CULL_FACE: - return ctx->Polygon.CullFlag; - case GL_DEPTH_TEST: - return ctx->Depth.Test; - case GL_DITHER: - return ctx->Color.DitherFlag; - case GL_FOG: - return ctx->Fog.Enabled; - case GL_LIGHTING: - return ctx->Light.Enabled; - case GL_LIGHT0: - case GL_LIGHT1: - case GL_LIGHT2: - case GL_LIGHT3: - case GL_LIGHT4: - case GL_LIGHT5: - case GL_LIGHT6: - case GL_LIGHT7: - return ctx->Light.Light[cap-GL_LIGHT0].Enabled; - case GL_LINE_SMOOTH: - return ctx->Line.SmoothFlag; - case GL_LINE_STIPPLE: - return ctx->Line.StippleFlag; - case GL_INDEX_LOGIC_OP: - return ctx->Color.IndexLogicOpEnabled; - case GL_COLOR_LOGIC_OP: - return ctx->Color.ColorLogicOpEnabled; - case GL_MAP1_COLOR_4: - return ctx->Eval.Map1Color4; - case GL_MAP1_INDEX: - return ctx->Eval.Map1Index; - case GL_MAP1_NORMAL: - return ctx->Eval.Map1Normal; - case GL_MAP1_TEXTURE_COORD_1: - return ctx->Eval.Map1TextureCoord1; - case GL_MAP1_TEXTURE_COORD_2: - return ctx->Eval.Map1TextureCoord2; - case GL_MAP1_TEXTURE_COORD_3: - return ctx->Eval.Map1TextureCoord3; - case GL_MAP1_TEXTURE_COORD_4: - return ctx->Eval.Map1TextureCoord4; - case GL_MAP1_VERTEX_3: - return ctx->Eval.Map1Vertex3; - case GL_MAP1_VERTEX_4: - return ctx->Eval.Map1Vertex4; - case GL_MAP2_COLOR_4: - return ctx->Eval.Map2Color4; - case GL_MAP2_INDEX: - return ctx->Eval.Map2Index; - case GL_MAP2_NORMAL: - return ctx->Eval.Map2Normal; - case GL_MAP2_TEXTURE_COORD_1: - return ctx->Eval.Map2TextureCoord1; - case GL_MAP2_TEXTURE_COORD_2: - return ctx->Eval.Map2TextureCoord2; - case GL_MAP2_TEXTURE_COORD_3: - return ctx->Eval.Map2TextureCoord3; - case GL_MAP2_TEXTURE_COORD_4: - return ctx->Eval.Map2TextureCoord4; - case GL_MAP2_VERTEX_3: - return ctx->Eval.Map2Vertex3; - case GL_MAP2_VERTEX_4: - return ctx->Eval.Map2Vertex4; - case GL_NORMALIZE: - return ctx->Transform.Normalize; - case GL_POINT_SMOOTH: - return ctx->Point.SmoothFlag; - case GL_POLYGON_SMOOTH: - return ctx->Polygon.SmoothFlag; - case GL_POLYGON_STIPPLE: - return ctx->Polygon.StippleFlag; - case GL_POLYGON_OFFSET_POINT: - return ctx->Polygon.OffsetPoint; - case GL_POLYGON_OFFSET_LINE: - return ctx->Polygon.OffsetLine; - case GL_POLYGON_OFFSET_FILL: - return ctx->Polygon.OffsetFill; - case GL_RESCALE_NORMAL_EXT: - return ctx->Transform.RescaleNormals; - case GL_SCISSOR_TEST: - return ctx->Scissor.Enabled; - case GL_STENCIL_TEST: - return ctx->Stencil.Enabled; - case GL_TEXTURE_1D: - return is_texture_enabled(ctx, TEXTURE_1D_BIT); - case GL_TEXTURE_2D: - return is_texture_enabled(ctx, TEXTURE_2D_BIT); - case GL_TEXTURE_3D: - return is_texture_enabled(ctx, TEXTURE_3D_BIT); - case GL_TEXTURE_GEN_S: - case GL_TEXTURE_GEN_T: - case GL_TEXTURE_GEN_R: - case GL_TEXTURE_GEN_Q: - { - const struct gl_texture_unit *texUnit = get_texcoord_unit(ctx); - if (texUnit) { - GLbitfield coordBit = S_BIT << (cap - GL_TEXTURE_GEN_S); - return (texUnit->TexGenEnabled & coordBit) ? GL_TRUE : GL_FALSE; - } - } - return GL_FALSE; -#if FEATURE_ES1 - case GL_TEXTURE_GEN_STR_OES: - { - const struct gl_texture_unit *texUnit = get_texcoord_unit(ctx); - if (texUnit) { - return (texUnit->TexGenEnabled & STR_BITS) == STR_BITS - ? GL_TRUE : GL_FALSE; - } - } -#endif - - /* client-side state */ - case GL_VERTEX_ARRAY: - return (ctx->Array.ArrayObj->Vertex.Enabled != 0); - case GL_NORMAL_ARRAY: - return (ctx->Array.ArrayObj->Normal.Enabled != 0); - case GL_COLOR_ARRAY: - return (ctx->Array.ArrayObj->Color.Enabled != 0); - case GL_INDEX_ARRAY: - return (ctx->Array.ArrayObj->Index.Enabled != 0); - case GL_TEXTURE_COORD_ARRAY: - return (ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture] - .Enabled != 0); - case GL_EDGE_FLAG_ARRAY: - return (ctx->Array.ArrayObj->EdgeFlag.Enabled != 0); - case GL_FOG_COORDINATE_ARRAY_EXT: - CHECK_EXTENSION(EXT_fog_coord); - return (ctx->Array.ArrayObj->FogCoord.Enabled != 0); - case GL_SECONDARY_COLOR_ARRAY_EXT: - CHECK_EXTENSION(EXT_secondary_color); - return (ctx->Array.ArrayObj->SecondaryColor.Enabled != 0); -#if FEATURE_point_size_array - case GL_POINT_SIZE_ARRAY_OES: - return (ctx->Array.ArrayObj->PointSize.Enabled != 0); -#endif - - /* GL_ARB_texture_cube_map */ - case GL_TEXTURE_CUBE_MAP_ARB: - CHECK_EXTENSION(ARB_texture_cube_map); - return is_texture_enabled(ctx, TEXTURE_CUBE_BIT); - - /* GL_EXT_secondary_color */ - case GL_COLOR_SUM_EXT: - CHECK_EXTENSION2(EXT_secondary_color, ARB_vertex_program); - return ctx->Fog.ColorSumEnabled; - - /* GL_ARB_multisample */ - case GL_MULTISAMPLE_ARB: - return ctx->Multisample.Enabled; - case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB: - return ctx->Multisample.SampleAlphaToCoverage; - case GL_SAMPLE_ALPHA_TO_ONE_ARB: - return ctx->Multisample.SampleAlphaToOne; - case GL_SAMPLE_COVERAGE_ARB: - return ctx->Multisample.SampleCoverage; - case GL_SAMPLE_COVERAGE_INVERT_ARB: - return ctx->Multisample.SampleCoverageInvert; - - /* GL_IBM_rasterpos_clip */ - case GL_RASTER_POSITION_UNCLIPPED_IBM: - CHECK_EXTENSION(IBM_rasterpos_clip); - return ctx->Transform.RasterPositionUnclipped; - - /* GL_NV_point_sprite */ - case GL_POINT_SPRITE_NV: - CHECK_EXTENSION2(NV_point_sprite, ARB_point_sprite) - return ctx->Point.PointSprite; - -#if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program - case GL_VERTEX_PROGRAM_ARB: - CHECK_EXTENSION2(ARB_vertex_program, NV_vertex_program); - return ctx->VertexProgram.Enabled; - case GL_VERTEX_PROGRAM_POINT_SIZE_ARB: - CHECK_EXTENSION2(ARB_vertex_program, NV_vertex_program); - return ctx->VertexProgram.PointSizeEnabled; - case GL_VERTEX_PROGRAM_TWO_SIDE_ARB: - CHECK_EXTENSION2(ARB_vertex_program, NV_vertex_program); - return ctx->VertexProgram.TwoSideEnabled; -#endif -#if FEATURE_NV_vertex_program - case GL_VERTEX_ATTRIB_ARRAY0_NV: - case GL_VERTEX_ATTRIB_ARRAY1_NV: - case GL_VERTEX_ATTRIB_ARRAY2_NV: - case GL_VERTEX_ATTRIB_ARRAY3_NV: - case GL_VERTEX_ATTRIB_ARRAY4_NV: - case GL_VERTEX_ATTRIB_ARRAY5_NV: - case GL_VERTEX_ATTRIB_ARRAY6_NV: - case GL_VERTEX_ATTRIB_ARRAY7_NV: - case GL_VERTEX_ATTRIB_ARRAY8_NV: - case GL_VERTEX_ATTRIB_ARRAY9_NV: - case GL_VERTEX_ATTRIB_ARRAY10_NV: - case GL_VERTEX_ATTRIB_ARRAY11_NV: - case GL_VERTEX_ATTRIB_ARRAY12_NV: - case GL_VERTEX_ATTRIB_ARRAY13_NV: - case GL_VERTEX_ATTRIB_ARRAY14_NV: - case GL_VERTEX_ATTRIB_ARRAY15_NV: - CHECK_EXTENSION(NV_vertex_program); - { - GLint n = (GLint) cap - GL_VERTEX_ATTRIB_ARRAY0_NV; - ASSERT(n < Elements(ctx->Array.ArrayObj->VertexAttrib)); - return (ctx->Array.ArrayObj->VertexAttrib[n].Enabled != 0); - } - case GL_MAP1_VERTEX_ATTRIB0_4_NV: - case GL_MAP1_VERTEX_ATTRIB1_4_NV: - case GL_MAP1_VERTEX_ATTRIB2_4_NV: - case GL_MAP1_VERTEX_ATTRIB3_4_NV: - case GL_MAP1_VERTEX_ATTRIB4_4_NV: - case GL_MAP1_VERTEX_ATTRIB5_4_NV: - case GL_MAP1_VERTEX_ATTRIB6_4_NV: - case GL_MAP1_VERTEX_ATTRIB7_4_NV: - case GL_MAP1_VERTEX_ATTRIB8_4_NV: - case GL_MAP1_VERTEX_ATTRIB9_4_NV: - case GL_MAP1_VERTEX_ATTRIB10_4_NV: - case GL_MAP1_VERTEX_ATTRIB11_4_NV: - case GL_MAP1_VERTEX_ATTRIB12_4_NV: - case GL_MAP1_VERTEX_ATTRIB13_4_NV: - case GL_MAP1_VERTEX_ATTRIB14_4_NV: - case GL_MAP1_VERTEX_ATTRIB15_4_NV: - CHECK_EXTENSION(NV_vertex_program); - { - const GLuint map = (GLuint) (cap - GL_MAP1_VERTEX_ATTRIB0_4_NV); - return ctx->Eval.Map1Attrib[map]; - } - case GL_MAP2_VERTEX_ATTRIB0_4_NV: - case GL_MAP2_VERTEX_ATTRIB1_4_NV: - case GL_MAP2_VERTEX_ATTRIB2_4_NV: - case GL_MAP2_VERTEX_ATTRIB3_4_NV: - case GL_MAP2_VERTEX_ATTRIB4_4_NV: - case GL_MAP2_VERTEX_ATTRIB5_4_NV: - case GL_MAP2_VERTEX_ATTRIB6_4_NV: - case GL_MAP2_VERTEX_ATTRIB7_4_NV: - case GL_MAP2_VERTEX_ATTRIB8_4_NV: - case GL_MAP2_VERTEX_ATTRIB9_4_NV: - case GL_MAP2_VERTEX_ATTRIB10_4_NV: - case GL_MAP2_VERTEX_ATTRIB11_4_NV: - case GL_MAP2_VERTEX_ATTRIB12_4_NV: - case GL_MAP2_VERTEX_ATTRIB13_4_NV: - case GL_MAP2_VERTEX_ATTRIB14_4_NV: - case GL_MAP2_VERTEX_ATTRIB15_4_NV: - CHECK_EXTENSION(NV_vertex_program); - { - const GLuint map = (GLuint) (cap - GL_MAP2_VERTEX_ATTRIB0_4_NV); - return ctx->Eval.Map2Attrib[map]; - } -#endif /* FEATURE_NV_vertex_program */ - -#if FEATURE_NV_fragment_program - case GL_FRAGMENT_PROGRAM_NV: - CHECK_EXTENSION(NV_fragment_program); - return ctx->FragmentProgram.Enabled; -#endif /* FEATURE_NV_fragment_program */ - - /* GL_NV_texture_rectangle */ - case GL_TEXTURE_RECTANGLE_NV: - CHECK_EXTENSION(NV_texture_rectangle); - return is_texture_enabled(ctx, TEXTURE_RECT_BIT); - - /* GL_EXT_stencil_two_side */ - case GL_STENCIL_TEST_TWO_SIDE_EXT: - CHECK_EXTENSION(EXT_stencil_two_side); - return ctx->Stencil.TestTwoSide; - -#if FEATURE_ARB_fragment_program - case GL_FRAGMENT_PROGRAM_ARB: - return ctx->FragmentProgram.Enabled; -#endif /* FEATURE_ARB_fragment_program */ - - /* GL_EXT_depth_bounds_test */ - case GL_DEPTH_BOUNDS_TEST_EXT: - CHECK_EXTENSION(EXT_depth_bounds_test); - return ctx->Depth.BoundsTest; - - /* GL_ARB_depth_clamp */ - case GL_DEPTH_CLAMP: - CHECK_EXTENSION(ARB_depth_clamp); - return ctx->Transform.DepthClamp; - -#if FEATURE_ATI_fragment_shader - case GL_FRAGMENT_SHADER_ATI: - CHECK_EXTENSION(ATI_fragment_shader); - return ctx->ATIFragmentShader.Enabled; -#endif /* FEATURE_ATI_fragment_shader */ - - case GL_TEXTURE_CUBE_MAP_SEAMLESS: - CHECK_EXTENSION(ARB_seamless_cube_map); - return ctx->Texture.CubeMapSeamless; - -#if FEATURE_EXT_transform_feedback - case GL_RASTERIZER_DISCARD: - CHECK_EXTENSION(EXT_transform_feedback); - return ctx->TransformFeedback.RasterDiscard; -#endif - - /* GL_NV_primitive_restart */ - case GL_PRIMITIVE_RESTART_NV: - if (!ctx->Extensions.NV_primitive_restart) { - goto invalid_enum_error; - } - return ctx->Array.PrimitiveRestart; - - /* GL 3.1 primitive restart */ - case GL_PRIMITIVE_RESTART: - if (ctx->VersionMajor * 10 + ctx->VersionMinor < 31) { - goto invalid_enum_error; - } - return ctx->Array.PrimitiveRestart; - - /* GL3.0 - GL_framebuffer_sRGB */ - case GL_FRAMEBUFFER_SRGB_EXT: - CHECK_EXTENSION(EXT_framebuffer_sRGB); - return ctx->Color.sRGBEnabled; - - default: - goto invalid_enum_error; - } - - return GL_FALSE; - -invalid_enum_error: - _mesa_error(ctx, GL_INVALID_ENUM, "glIsEnabled(0x%x)", (int) cap); - return GL_FALSE; -} +/** + * \file enable.c + * Enable/disable/query GL capabilities. + */ + +/* + * Mesa 3-D graphics library + * + * 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 "glheader.h" +#include "clip.h" +#include "context.h" +#include "enable.h" +#include "light.h" +#include "simple_list.h" +#include "mfeatures.h" +#include "mtypes.h" +#include "enums.h" +#include "api_arrayelt.h" +#include "texstate.h" + + + +#define CHECK_EXTENSION(EXTNAME, CAP) \ + if (!ctx->Extensions.EXTNAME) { \ + goto invalid_enum_error; \ + } + + +/** + * Helper to enable/disable client-side state. + */ +static void +client_state(struct gl_context *ctx, GLenum cap, GLboolean state) +{ + struct gl_array_object *arrayObj = ctx->Array.ArrayObj; + GLuint flag; + GLboolean *var; + + switch (cap) { + case GL_VERTEX_ARRAY: + var = &arrayObj->Vertex.Enabled; + flag = _NEW_ARRAY_VERTEX; + break; + case GL_NORMAL_ARRAY: + var = &arrayObj->Normal.Enabled; + flag = _NEW_ARRAY_NORMAL; + break; + case GL_COLOR_ARRAY: + var = &arrayObj->Color.Enabled; + flag = _NEW_ARRAY_COLOR0; + break; + case GL_INDEX_ARRAY: + var = &arrayObj->Index.Enabled; + flag = _NEW_ARRAY_INDEX; + break; + case GL_TEXTURE_COORD_ARRAY: + var = &arrayObj->TexCoord[ctx->Array.ActiveTexture].Enabled; + flag = _NEW_ARRAY_TEXCOORD(ctx->Array.ActiveTexture); + break; + case GL_EDGE_FLAG_ARRAY: + var = &arrayObj->EdgeFlag.Enabled; + flag = _NEW_ARRAY_EDGEFLAG; + break; + case GL_FOG_COORDINATE_ARRAY_EXT: + var = &arrayObj->FogCoord.Enabled; + flag = _NEW_ARRAY_FOGCOORD; + break; + case GL_SECONDARY_COLOR_ARRAY_EXT: + var = &arrayObj->SecondaryColor.Enabled; + flag = _NEW_ARRAY_COLOR1; + break; + +#if FEATURE_point_size_array + case GL_POINT_SIZE_ARRAY_OES: + var = &arrayObj->PointSize.Enabled; + flag = _NEW_ARRAY_POINT_SIZE; + break; +#endif + +#if FEATURE_NV_vertex_program + case GL_VERTEX_ATTRIB_ARRAY0_NV: + case GL_VERTEX_ATTRIB_ARRAY1_NV: + case GL_VERTEX_ATTRIB_ARRAY2_NV: + case GL_VERTEX_ATTRIB_ARRAY3_NV: + case GL_VERTEX_ATTRIB_ARRAY4_NV: + case GL_VERTEX_ATTRIB_ARRAY5_NV: + case GL_VERTEX_ATTRIB_ARRAY6_NV: + case GL_VERTEX_ATTRIB_ARRAY7_NV: + case GL_VERTEX_ATTRIB_ARRAY8_NV: + case GL_VERTEX_ATTRIB_ARRAY9_NV: + case GL_VERTEX_ATTRIB_ARRAY10_NV: + case GL_VERTEX_ATTRIB_ARRAY11_NV: + case GL_VERTEX_ATTRIB_ARRAY12_NV: + case GL_VERTEX_ATTRIB_ARRAY13_NV: + case GL_VERTEX_ATTRIB_ARRAY14_NV: + case GL_VERTEX_ATTRIB_ARRAY15_NV: + CHECK_EXTENSION(NV_vertex_program, cap); + { + GLint n = (GLint) cap - GL_VERTEX_ATTRIB_ARRAY0_NV; + ASSERT(n < Elements(ctx->Array.ArrayObj->VertexAttrib)); + var = &arrayObj->VertexAttrib[n].Enabled; + flag = _NEW_ARRAY_ATTRIB(n); + } + break; +#endif /* FEATURE_NV_vertex_program */ + + /* GL_NV_primitive_restart */ + case GL_PRIMITIVE_RESTART_NV: + if (!ctx->Extensions.NV_primitive_restart) { + goto invalid_enum_error; + } + var = &ctx->Array.PrimitiveRestart; + flag = 0; + break; + + default: + goto invalid_enum_error; + } + + if (*var == state) + return; + + FLUSH_VERTICES(ctx, _NEW_ARRAY); + ctx->Array.NewState |= flag; + + _ae_invalidate_state(ctx, _NEW_ARRAY); + + *var = state; + + if (state) + ctx->Array.ArrayObj->_Enabled |= flag; + else + ctx->Array.ArrayObj->_Enabled &= ~flag; + + if (ctx->Driver.Enable) { + ctx->Driver.Enable( ctx, cap, state ); + } + + return; + +invalid_enum_error: + _mesa_error(ctx, GL_INVALID_ENUM, "gl%sClientState(0x%x)", + state ? "Enable" : "Disable", cap); +} + + +/** + * Enable GL capability. + * \param cap state to enable/disable. + * + * Get's the current context, assures that we're outside glBegin()/glEnd() and + * calls client_state(). + */ +void GLAPIENTRY +_mesa_EnableClientState( GLenum cap ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + client_state( ctx, cap, GL_TRUE ); +} + + +/** + * Disable GL capability. + * \param cap state to enable/disable. + * + * Get's the current context, assures that we're outside glBegin()/glEnd() and + * calls client_state(). + */ +void GLAPIENTRY +_mesa_DisableClientState( GLenum cap ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + client_state( ctx, cap, GL_FALSE ); +} + + +#undef CHECK_EXTENSION +#define CHECK_EXTENSION(EXTNAME, CAP) \ + if (!ctx->Extensions.EXTNAME) { \ + goto invalid_enum_error; \ + } + +#define CHECK_EXTENSION2(EXT1, EXT2, CAP) \ + if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \ + goto invalid_enum_error; \ + } + + + +/** + * Return pointer to current texture unit for setting/getting coordinate + * state. + * Note that we'll set GL_INVALID_OPERATION and return NULL if the active + * texture unit is higher than the number of supported coordinate units. + */ +static struct gl_texture_unit * +get_texcoord_unit(struct gl_context *ctx) +{ + if (ctx->Texture.CurrentUnit >= ctx->Const.MaxTextureCoordUnits) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glEnable/Disable(texcoord unit)"); + return NULL; + } + else { + return &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; + } +} + + +/** + * Helper function to enable or disable a texture target. + * \param bit one of the TEXTURE_x_BIT values + * \return GL_TRUE if state is changing or GL_FALSE if no change + */ +static GLboolean +enable_texture(struct gl_context *ctx, GLboolean state, GLbitfield texBit) +{ + struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx); + const GLbitfield newenabled = state + ? (texUnit->Enabled | texBit) : (texUnit->Enabled & ~texBit); + + if (texUnit->Enabled == newenabled) + return GL_FALSE; + + FLUSH_VERTICES(ctx, _NEW_TEXTURE); + texUnit->Enabled = newenabled; + return GL_TRUE; +} + + +/** + * Helper function to enable or disable state. + * + * \param ctx GL context. + * \param cap the state to enable/disable + * \param state whether to enable or disable the specified capability. + * + * Updates the current context and flushes the vertices as needed. For + * capabilities associated with extensions it verifies that those extensions + * are effectivly present before updating. Notifies the driver via + * dd_function_table::Enable. + */ +void +_mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) +{ + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "%s %s (newstate is %x)\n", + state ? "glEnable" : "glDisable", + _mesa_lookup_enum_by_nr(cap), + ctx->NewState); + + switch (cap) { + case GL_ALPHA_TEST: + if (ctx->Color.AlphaEnabled == state) + return; + FLUSH_VERTICES(ctx, _NEW_COLOR); + ctx->Color.AlphaEnabled = state; + break; + case GL_AUTO_NORMAL: + if (ctx->Eval.AutoNormal == state) + return; + FLUSH_VERTICES(ctx, _NEW_EVAL); + ctx->Eval.AutoNormal = state; + break; + case GL_BLEND: + { + GLbitfield newEnabled = + state * ((1 << ctx->Const.MaxDrawBuffers) - 1); + if (newEnabled != ctx->Color.BlendEnabled) { + FLUSH_VERTICES(ctx, _NEW_COLOR); + ctx->Color.BlendEnabled = newEnabled; + } + } + break; +#if FEATURE_userclip + case GL_CLIP_PLANE0: + case GL_CLIP_PLANE1: + case GL_CLIP_PLANE2: + case GL_CLIP_PLANE3: + case GL_CLIP_PLANE4: + case GL_CLIP_PLANE5: + { + const GLuint p = cap - GL_CLIP_PLANE0; + + if ((ctx->Transform.ClipPlanesEnabled & (1 << p)) + == ((GLuint) state << p)) + return; + + FLUSH_VERTICES(ctx, _NEW_TRANSFORM); + + if (state) { + ctx->Transform.ClipPlanesEnabled |= (1 << p); + _mesa_update_clip_plane(ctx, p); + } + else { + ctx->Transform.ClipPlanesEnabled &= ~(1 << p); + } + } + break; +#endif + case GL_COLOR_MATERIAL: + if (ctx->Light.ColorMaterialEnabled == state) + return; + FLUSH_VERTICES(ctx, _NEW_LIGHT); + FLUSH_CURRENT(ctx, 0); + ctx->Light.ColorMaterialEnabled = state; + if (state) { + _mesa_update_color_material( ctx, + ctx->Current.Attrib[VERT_ATTRIB_COLOR0] ); + } + break; + case GL_CULL_FACE: + if (ctx->Polygon.CullFlag == state) + return; + FLUSH_VERTICES(ctx, _NEW_POLYGON); + ctx->Polygon.CullFlag = state; + break; + case GL_DEPTH_TEST: + if (ctx->Depth.Test == state) + return; + FLUSH_VERTICES(ctx, _NEW_DEPTH); + ctx->Depth.Test = state; + break; + case GL_DITHER: + if (ctx->Color.DitherFlag == state) + return; + FLUSH_VERTICES(ctx, _NEW_COLOR); + ctx->Color.DitherFlag = state; + break; + case GL_FOG: + if (ctx->Fog.Enabled == state) + return; + FLUSH_VERTICES(ctx, _NEW_FOG); + ctx->Fog.Enabled = state; + break; + case GL_LIGHT0: + case GL_LIGHT1: + case GL_LIGHT2: + case GL_LIGHT3: + case GL_LIGHT4: + case GL_LIGHT5: + case GL_LIGHT6: + case GL_LIGHT7: + if (ctx->Light.Light[cap-GL_LIGHT0].Enabled == state) + return; + FLUSH_VERTICES(ctx, _NEW_LIGHT); + ctx->Light.Light[cap-GL_LIGHT0].Enabled = state; + if (state) { + insert_at_tail(&ctx->Light.EnabledList, + &ctx->Light.Light[cap-GL_LIGHT0]); + } + else { + remove_from_list(&ctx->Light.Light[cap-GL_LIGHT0]); + } + break; + case GL_LIGHTING: + if (ctx->Light.Enabled == state) + return; + FLUSH_VERTICES(ctx, _NEW_LIGHT); + ctx->Light.Enabled = state; + if (ctx->Light.Enabled && ctx->Light.Model.TwoSide) + ctx->_TriangleCaps |= DD_TRI_LIGHT_TWOSIDE; + else + ctx->_TriangleCaps &= ~DD_TRI_LIGHT_TWOSIDE; + break; + case GL_LINE_SMOOTH: + if (ctx->Line.SmoothFlag == state) + return; + FLUSH_VERTICES(ctx, _NEW_LINE); + ctx->Line.SmoothFlag = state; + ctx->_TriangleCaps ^= DD_LINE_SMOOTH; + break; + case GL_LINE_STIPPLE: + if (ctx->Line.StippleFlag == state) + return; + FLUSH_VERTICES(ctx, _NEW_LINE); + ctx->Line.StippleFlag = state; + ctx->_TriangleCaps ^= DD_LINE_STIPPLE; + break; + case GL_INDEX_LOGIC_OP: + if (ctx->Color.IndexLogicOpEnabled == state) + return; + FLUSH_VERTICES(ctx, _NEW_COLOR); + ctx->Color.IndexLogicOpEnabled = state; + break; + case GL_COLOR_LOGIC_OP: + if (ctx->Color.ColorLogicOpEnabled == state) + return; + FLUSH_VERTICES(ctx, _NEW_COLOR); + ctx->Color.ColorLogicOpEnabled = state; + break; + case GL_MAP1_COLOR_4: + if (ctx->Eval.Map1Color4 == state) + return; + FLUSH_VERTICES(ctx, _NEW_EVAL); + ctx->Eval.Map1Color4 = state; + break; + case GL_MAP1_INDEX: + if (ctx->Eval.Map1Index == state) + return; + FLUSH_VERTICES(ctx, _NEW_EVAL); + ctx->Eval.Map1Index = state; + break; + case GL_MAP1_NORMAL: + if (ctx->Eval.Map1Normal == state) + return; + FLUSH_VERTICES(ctx, _NEW_EVAL); + ctx->Eval.Map1Normal = state; + break; + case GL_MAP1_TEXTURE_COORD_1: + if (ctx->Eval.Map1TextureCoord1 == state) + return; + FLUSH_VERTICES(ctx, _NEW_EVAL); + ctx->Eval.Map1TextureCoord1 = state; + break; + case GL_MAP1_TEXTURE_COORD_2: + if (ctx->Eval.Map1TextureCoord2 == state) + return; + FLUSH_VERTICES(ctx, _NEW_EVAL); + ctx->Eval.Map1TextureCoord2 = state; + break; + case GL_MAP1_TEXTURE_COORD_3: + if (ctx->Eval.Map1TextureCoord3 == state) + return; + FLUSH_VERTICES(ctx, _NEW_EVAL); + ctx->Eval.Map1TextureCoord3 = state; + break; + case GL_MAP1_TEXTURE_COORD_4: + if (ctx->Eval.Map1TextureCoord4 == state) + return; + FLUSH_VERTICES(ctx, _NEW_EVAL); + ctx->Eval.Map1TextureCoord4 = state; + break; + case GL_MAP1_VERTEX_3: + if (ctx->Eval.Map1Vertex3 == state) + return; + FLUSH_VERTICES(ctx, _NEW_EVAL); + ctx->Eval.Map1Vertex3 = state; + break; + case GL_MAP1_VERTEX_4: + if (ctx->Eval.Map1Vertex4 == state) + return; + FLUSH_VERTICES(ctx, _NEW_EVAL); + ctx->Eval.Map1Vertex4 = state; + break; + case GL_MAP2_COLOR_4: + if (ctx->Eval.Map2Color4 == state) + return; + FLUSH_VERTICES(ctx, _NEW_EVAL); + ctx->Eval.Map2Color4 = state; + break; + case GL_MAP2_INDEX: + if (ctx->Eval.Map2Index == state) + return; + FLUSH_VERTICES(ctx, _NEW_EVAL); + ctx->Eval.Map2Index = state; + break; + case GL_MAP2_NORMAL: + if (ctx->Eval.Map2Normal == state) + return; + FLUSH_VERTICES(ctx, _NEW_EVAL); + ctx->Eval.Map2Normal = state; + break; + case GL_MAP2_TEXTURE_COORD_1: + if (ctx->Eval.Map2TextureCoord1 == state) + return; + FLUSH_VERTICES(ctx, _NEW_EVAL); + ctx->Eval.Map2TextureCoord1 = state; + break; + case GL_MAP2_TEXTURE_COORD_2: + if (ctx->Eval.Map2TextureCoord2 == state) + return; + FLUSH_VERTICES(ctx, _NEW_EVAL); + ctx->Eval.Map2TextureCoord2 = state; + break; + case GL_MAP2_TEXTURE_COORD_3: + if (ctx->Eval.Map2TextureCoord3 == state) + return; + FLUSH_VERTICES(ctx, _NEW_EVAL); + ctx->Eval.Map2TextureCoord3 = state; + break; + case GL_MAP2_TEXTURE_COORD_4: + if (ctx->Eval.Map2TextureCoord4 == state) + return; + FLUSH_VERTICES(ctx, _NEW_EVAL); + ctx->Eval.Map2TextureCoord4 = state; + break; + case GL_MAP2_VERTEX_3: + if (ctx->Eval.Map2Vertex3 == state) + return; + FLUSH_VERTICES(ctx, _NEW_EVAL); + ctx->Eval.Map2Vertex3 = state; + break; + case GL_MAP2_VERTEX_4: + if (ctx->Eval.Map2Vertex4 == state) + return; + FLUSH_VERTICES(ctx, _NEW_EVAL); + ctx->Eval.Map2Vertex4 = state; + break; + case GL_NORMALIZE: + if (ctx->Transform.Normalize == state) + return; + FLUSH_VERTICES(ctx, _NEW_TRANSFORM); + ctx->Transform.Normalize = state; + break; + case GL_POINT_SMOOTH: + if (ctx->Point.SmoothFlag == state) + return; + FLUSH_VERTICES(ctx, _NEW_POINT); + ctx->Point.SmoothFlag = state; + ctx->_TriangleCaps ^= DD_POINT_SMOOTH; + break; + case GL_POLYGON_SMOOTH: + if (ctx->Polygon.SmoothFlag == state) + return; + FLUSH_VERTICES(ctx, _NEW_POLYGON); + ctx->Polygon.SmoothFlag = state; + ctx->_TriangleCaps ^= DD_TRI_SMOOTH; + break; + case GL_POLYGON_STIPPLE: + if (ctx->Polygon.StippleFlag == state) + return; + FLUSH_VERTICES(ctx, _NEW_POLYGON); + ctx->Polygon.StippleFlag = state; + ctx->_TriangleCaps ^= DD_TRI_STIPPLE; + break; + case GL_POLYGON_OFFSET_POINT: + if (ctx->Polygon.OffsetPoint == state) + return; + FLUSH_VERTICES(ctx, _NEW_POLYGON); + ctx->Polygon.OffsetPoint = state; + break; + case GL_POLYGON_OFFSET_LINE: + if (ctx->Polygon.OffsetLine == state) + return; + FLUSH_VERTICES(ctx, _NEW_POLYGON); + ctx->Polygon.OffsetLine = state; + break; + case GL_POLYGON_OFFSET_FILL: + if (ctx->Polygon.OffsetFill == state) + return; + FLUSH_VERTICES(ctx, _NEW_POLYGON); + ctx->Polygon.OffsetFill = state; + break; + case GL_RESCALE_NORMAL_EXT: + if (ctx->Transform.RescaleNormals == state) + return; + FLUSH_VERTICES(ctx, _NEW_TRANSFORM); + ctx->Transform.RescaleNormals = state; + break; + case GL_SCISSOR_TEST: + if (ctx->Scissor.Enabled == state) + return; + FLUSH_VERTICES(ctx, _NEW_SCISSOR); + ctx->Scissor.Enabled = state; + break; + case GL_STENCIL_TEST: + if (ctx->Stencil.Enabled == state) + return; + FLUSH_VERTICES(ctx, _NEW_STENCIL); + ctx->Stencil.Enabled = state; + break; + case GL_TEXTURE_1D: + if (!enable_texture(ctx, state, TEXTURE_1D_BIT)) { + return; + } + break; + case GL_TEXTURE_2D: + if (!enable_texture(ctx, state, TEXTURE_2D_BIT)) { + return; + } + break; + case GL_TEXTURE_3D: + if (!enable_texture(ctx, state, TEXTURE_3D_BIT)) { + return; + } + break; + case GL_TEXTURE_GEN_S: + case GL_TEXTURE_GEN_T: + case GL_TEXTURE_GEN_R: + case GL_TEXTURE_GEN_Q: + { + struct gl_texture_unit *texUnit = get_texcoord_unit(ctx); + if (texUnit) { + GLbitfield coordBit = S_BIT << (cap - GL_TEXTURE_GEN_S); + GLbitfield newenabled = texUnit->TexGenEnabled & ~coordBit; + if (state) + newenabled |= coordBit; + if (texUnit->TexGenEnabled == newenabled) + return; + FLUSH_VERTICES(ctx, _NEW_TEXTURE); + texUnit->TexGenEnabled = newenabled; + } + } + break; + +#if FEATURE_ES1 + case GL_TEXTURE_GEN_STR_OES: + /* disable S, T, and R at the same time */ + { + struct gl_texture_unit *texUnit = get_texcoord_unit(ctx); + if (texUnit) { + GLuint newenabled = + texUnit->TexGenEnabled & ~STR_BITS; + if (state) + newenabled |= STR_BITS; + if (texUnit->TexGenEnabled == newenabled) + return; + FLUSH_VERTICES(ctx, _NEW_TEXTURE); + texUnit->TexGenEnabled = newenabled; + } + } + break; +#endif + + /* client-side state */ + case GL_VERTEX_ARRAY: + case GL_NORMAL_ARRAY: + case GL_COLOR_ARRAY: + case GL_INDEX_ARRAY: + case GL_TEXTURE_COORD_ARRAY: + case GL_EDGE_FLAG_ARRAY: + case GL_FOG_COORDINATE_ARRAY_EXT: + case GL_SECONDARY_COLOR_ARRAY_EXT: + case GL_POINT_SIZE_ARRAY_OES: + client_state( ctx, cap, state ); + return; + + /* GL_ARB_texture_cube_map */ + case GL_TEXTURE_CUBE_MAP_ARB: + CHECK_EXTENSION(ARB_texture_cube_map, cap); + if (!enable_texture(ctx, state, TEXTURE_CUBE_BIT)) { + return; + } + break; + + /* GL_EXT_secondary_color */ + case GL_COLOR_SUM_EXT: + CHECK_EXTENSION2(EXT_secondary_color, ARB_vertex_program, cap); + if (ctx->Fog.ColorSumEnabled == state) + return; + FLUSH_VERTICES(ctx, _NEW_FOG); + ctx->Fog.ColorSumEnabled = state; + break; + + /* GL_ARB_multisample */ + case GL_MULTISAMPLE_ARB: + if (ctx->Multisample.Enabled == state) + return; + FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE); + ctx->Multisample.Enabled = state; + break; + case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB: + if (ctx->Multisample.SampleAlphaToCoverage == state) + return; + FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE); + ctx->Multisample.SampleAlphaToCoverage = state; + break; + case GL_SAMPLE_ALPHA_TO_ONE_ARB: + if (ctx->Multisample.SampleAlphaToOne == state) + return; + FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE); + ctx->Multisample.SampleAlphaToOne = state; + break; + case GL_SAMPLE_COVERAGE_ARB: + if (ctx->Multisample.SampleCoverage == state) + return; + FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE); + ctx->Multisample.SampleCoverage = state; + break; + case GL_SAMPLE_COVERAGE_INVERT_ARB: + if (ctx->Multisample.SampleCoverageInvert == state) + return; + FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE); + ctx->Multisample.SampleCoverageInvert = state; + break; + + /* GL_IBM_rasterpos_clip */ + case GL_RASTER_POSITION_UNCLIPPED_IBM: + CHECK_EXTENSION(IBM_rasterpos_clip, cap); + if (ctx->Transform.RasterPositionUnclipped == state) + return; + FLUSH_VERTICES(ctx, _NEW_TRANSFORM); + ctx->Transform.RasterPositionUnclipped = state; + break; + + /* GL_NV_point_sprite */ + case GL_POINT_SPRITE_NV: + CHECK_EXTENSION2(NV_point_sprite, ARB_point_sprite, cap); + if (ctx->Point.PointSprite == state) + return; + FLUSH_VERTICES(ctx, _NEW_POINT); + ctx->Point.PointSprite = state; + break; + +#if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program + case GL_VERTEX_PROGRAM_ARB: + CHECK_EXTENSION2(ARB_vertex_program, NV_vertex_program, cap); + if (ctx->VertexProgram.Enabled == state) + return; + FLUSH_VERTICES(ctx, _NEW_PROGRAM); + ctx->VertexProgram.Enabled = state; + break; + case GL_VERTEX_PROGRAM_POINT_SIZE_ARB: + CHECK_EXTENSION2(ARB_vertex_program, NV_vertex_program, cap); + if (ctx->VertexProgram.PointSizeEnabled == state) + return; + FLUSH_VERTICES(ctx, _NEW_PROGRAM); + ctx->VertexProgram.PointSizeEnabled = state; + break; + case GL_VERTEX_PROGRAM_TWO_SIDE_ARB: + CHECK_EXTENSION2(ARB_vertex_program, NV_vertex_program, cap); + if (ctx->VertexProgram.TwoSideEnabled == state) + return; + FLUSH_VERTICES(ctx, _NEW_PROGRAM); + ctx->VertexProgram.TwoSideEnabled = state; + break; +#endif +#if FEATURE_NV_vertex_program + case GL_MAP1_VERTEX_ATTRIB0_4_NV: + case GL_MAP1_VERTEX_ATTRIB1_4_NV: + case GL_MAP1_VERTEX_ATTRIB2_4_NV: + case GL_MAP1_VERTEX_ATTRIB3_4_NV: + case GL_MAP1_VERTEX_ATTRIB4_4_NV: + case GL_MAP1_VERTEX_ATTRIB5_4_NV: + case GL_MAP1_VERTEX_ATTRIB6_4_NV: + case GL_MAP1_VERTEX_ATTRIB7_4_NV: + case GL_MAP1_VERTEX_ATTRIB8_4_NV: + case GL_MAP1_VERTEX_ATTRIB9_4_NV: + case GL_MAP1_VERTEX_ATTRIB10_4_NV: + case GL_MAP1_VERTEX_ATTRIB11_4_NV: + case GL_MAP1_VERTEX_ATTRIB12_4_NV: + case GL_MAP1_VERTEX_ATTRIB13_4_NV: + case GL_MAP1_VERTEX_ATTRIB14_4_NV: + case GL_MAP1_VERTEX_ATTRIB15_4_NV: + CHECK_EXTENSION(NV_vertex_program, cap); + { + const GLuint map = (GLuint) (cap - GL_MAP1_VERTEX_ATTRIB0_4_NV); + FLUSH_VERTICES(ctx, _NEW_EVAL); + ctx->Eval.Map1Attrib[map] = state; + } + break; + case GL_MAP2_VERTEX_ATTRIB0_4_NV: + case GL_MAP2_VERTEX_ATTRIB1_4_NV: + case GL_MAP2_VERTEX_ATTRIB2_4_NV: + case GL_MAP2_VERTEX_ATTRIB3_4_NV: + case GL_MAP2_VERTEX_ATTRIB4_4_NV: + case GL_MAP2_VERTEX_ATTRIB5_4_NV: + case GL_MAP2_VERTEX_ATTRIB6_4_NV: + case GL_MAP2_VERTEX_ATTRIB7_4_NV: + case GL_MAP2_VERTEX_ATTRIB8_4_NV: + case GL_MAP2_VERTEX_ATTRIB9_4_NV: + case GL_MAP2_VERTEX_ATTRIB10_4_NV: + case GL_MAP2_VERTEX_ATTRIB11_4_NV: + case GL_MAP2_VERTEX_ATTRIB12_4_NV: + case GL_MAP2_VERTEX_ATTRIB13_4_NV: + case GL_MAP2_VERTEX_ATTRIB14_4_NV: + case GL_MAP2_VERTEX_ATTRIB15_4_NV: + CHECK_EXTENSION(NV_vertex_program, cap); + { + const GLuint map = (GLuint) (cap - GL_MAP2_VERTEX_ATTRIB0_4_NV); + FLUSH_VERTICES(ctx, _NEW_EVAL); + ctx->Eval.Map2Attrib[map] = state; + } + break; +#endif /* FEATURE_NV_vertex_program */ + +#if FEATURE_NV_fragment_program + case GL_FRAGMENT_PROGRAM_NV: + CHECK_EXTENSION(NV_fragment_program, cap); + if (ctx->FragmentProgram.Enabled == state) + return; + FLUSH_VERTICES(ctx, _NEW_PROGRAM); + ctx->FragmentProgram.Enabled = state; + break; +#endif /* FEATURE_NV_fragment_program */ + + /* GL_NV_texture_rectangle */ + case GL_TEXTURE_RECTANGLE_NV: + CHECK_EXTENSION(NV_texture_rectangle, cap); + if (!enable_texture(ctx, state, TEXTURE_RECT_BIT)) { + return; + } + break; + + /* GL_EXT_stencil_two_side */ + case GL_STENCIL_TEST_TWO_SIDE_EXT: + CHECK_EXTENSION(EXT_stencil_two_side, cap); + if (ctx->Stencil.TestTwoSide == state) + return; + FLUSH_VERTICES(ctx, _NEW_STENCIL); + ctx->Stencil.TestTwoSide = state; + if (state) { + ctx->Stencil._BackFace = 2; + ctx->_TriangleCaps |= DD_TRI_TWOSTENCIL; + } else { + ctx->Stencil._BackFace = 1; + ctx->_TriangleCaps &= ~DD_TRI_TWOSTENCIL; + } + break; + +#if FEATURE_ARB_fragment_program + case GL_FRAGMENT_PROGRAM_ARB: + CHECK_EXTENSION(ARB_fragment_program, cap); + if (ctx->FragmentProgram.Enabled == state) + return; + FLUSH_VERTICES(ctx, _NEW_PROGRAM); + ctx->FragmentProgram.Enabled = state; + break; +#endif /* FEATURE_ARB_fragment_program */ + + /* GL_EXT_depth_bounds_test */ + case GL_DEPTH_BOUNDS_TEST_EXT: + CHECK_EXTENSION(EXT_depth_bounds_test, cap); + if (ctx->Depth.BoundsTest == state) + return; + FLUSH_VERTICES(ctx, _NEW_DEPTH); + ctx->Depth.BoundsTest = state; + break; + + case GL_DEPTH_CLAMP: + if (ctx->Transform.DepthClamp == state) + return; + CHECK_EXTENSION(ARB_depth_clamp, cap); + FLUSH_VERTICES(ctx, _NEW_TRANSFORM); + ctx->Transform.DepthClamp = state; + break; + +#if FEATURE_ATI_fragment_shader + case GL_FRAGMENT_SHADER_ATI: + CHECK_EXTENSION(ATI_fragment_shader, cap); + if (ctx->ATIFragmentShader.Enabled == state) + return; + FLUSH_VERTICES(ctx, _NEW_PROGRAM); + ctx->ATIFragmentShader.Enabled = state; + break; +#endif + + /* GL_MESA_texture_array */ + case GL_TEXTURE_1D_ARRAY_EXT: + CHECK_EXTENSION(MESA_texture_array, cap); + if (!enable_texture(ctx, state, TEXTURE_1D_ARRAY_BIT)) { + return; + } + break; + + case GL_TEXTURE_2D_ARRAY_EXT: + CHECK_EXTENSION(MESA_texture_array, cap); + if (!enable_texture(ctx, state, TEXTURE_2D_ARRAY_BIT)) { + return; + } + break; + + case GL_TEXTURE_CUBE_MAP_SEAMLESS: + CHECK_EXTENSION(ARB_seamless_cube_map, cap); + if (ctx->Texture.CubeMapSeamless != state) { + FLUSH_VERTICES(ctx, _NEW_TEXTURE); + ctx->Texture.CubeMapSeamless = state; + } + break; + +#if FEATURE_EXT_transform_feedback + case GL_RASTERIZER_DISCARD: + CHECK_EXTENSION(EXT_transform_feedback, cap); + if (ctx->TransformFeedback.RasterDiscard != state) { + FLUSH_VERTICES(ctx, _NEW_TRANSFORM); + ctx->TransformFeedback.RasterDiscard = state; + } + break; +#endif + + /* GL 3.1 primitive restart. Note: this enum is different from + * GL_PRIMITIVE_RESTART_NV (which is client state). + */ + case GL_PRIMITIVE_RESTART: + if (ctx->VersionMajor * 10 + ctx->VersionMinor < 31) { + goto invalid_enum_error; + } + if (ctx->Array.PrimitiveRestart != state) { + FLUSH_VERTICES(ctx, _NEW_TRANSFORM); + ctx->Array.PrimitiveRestart = state; + } + break; + + /* GL3.0 - GL_framebuffer_sRGB */ + case GL_FRAMEBUFFER_SRGB_EXT: + CHECK_EXTENSION(EXT_framebuffer_sRGB, cap); + FLUSH_VERTICES(ctx, _NEW_BUFFERS); + ctx->Color.sRGBEnabled = state; + break; + + default: + goto invalid_enum_error; + } + + if (ctx->Driver.Enable) { + ctx->Driver.Enable( ctx, cap, state ); + } + + return; + +invalid_enum_error: + _mesa_error(ctx, GL_INVALID_ENUM, "gl%s(0x%x)", + state ? "Enable" : "Disable", cap); +} + + +/** + * Enable GL capability. Called by glEnable() + * \param cap state to enable. + */ +void GLAPIENTRY +_mesa_Enable( GLenum cap ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + _mesa_set_enable( ctx, cap, GL_TRUE ); +} + + +/** + * Disable GL capability. Called by glDisable() + * \param cap state to disable. + */ +void GLAPIENTRY +_mesa_Disable( GLenum cap ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + _mesa_set_enable( ctx, cap, GL_FALSE ); +} + + + +/** + * Enable/disable an indexed state var. + */ +void +_mesa_set_enablei(struct gl_context *ctx, GLenum cap, + GLuint index, GLboolean state) +{ + ASSERT(state == 0 || state == 1); + switch (cap) { + case GL_BLEND: + if (!ctx->Extensions.EXT_draw_buffers2) { + goto invalid_enum_error; + } + if (index >= ctx->Const.MaxDrawBuffers) { + _mesa_error(ctx, GL_INVALID_VALUE, "%s(index=%u)", + state ? "glEnableIndexed" : "glDisableIndexed", index); + return; + } + if (((ctx->Color.BlendEnabled >> index) & 1) != state) { + FLUSH_VERTICES(ctx, _NEW_COLOR); + if (state) + ctx->Color.BlendEnabled |= (1 << index); + else + ctx->Color.BlendEnabled &= ~(1 << index); + } + break; + default: + goto invalid_enum_error; + } + return; + +invalid_enum_error: + _mesa_error(ctx, GL_INVALID_ENUM, "%s(cap=%s)", + state ? "glEnablei" : "glDisablei", + _mesa_lookup_enum_by_nr(cap)); +} + + +void GLAPIENTRY +_mesa_DisableIndexed( GLenum cap, GLuint index ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + _mesa_set_enablei(ctx, cap, index, GL_FALSE); +} + + +void GLAPIENTRY +_mesa_EnableIndexed( GLenum cap, GLuint index ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + _mesa_set_enablei(ctx, cap, index, GL_TRUE); +} + + +GLboolean GLAPIENTRY +_mesa_IsEnabledIndexed( GLenum cap, GLuint index ) +{ + GET_CURRENT_CONTEXT(ctx); + switch (cap) { + case GL_BLEND: + if (index >= ctx->Const.MaxDrawBuffers) { + _mesa_error(ctx, GL_INVALID_VALUE, "glIsEnabledIndexed(index=%u)", + index); + return GL_FALSE; + } + return (ctx->Color.BlendEnabled >> index) & 1; + default: + _mesa_error(ctx, GL_INVALID_ENUM, "glIsEnabledIndexed(cap=%s)", + _mesa_lookup_enum_by_nr(cap)); + return GL_FALSE; + } +} + + + + +#undef CHECK_EXTENSION +#define CHECK_EXTENSION(EXTNAME) \ + if (!ctx->Extensions.EXTNAME) { \ + goto invalid_enum_error; \ + } + +#undef CHECK_EXTENSION2 +#define CHECK_EXTENSION2(EXT1, EXT2) \ + if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \ + goto invalid_enum_error; \ + } + + +/** + * Helper function to determine whether a texture target is enabled. + */ +static GLboolean +is_texture_enabled(struct gl_context *ctx, GLbitfield bit) +{ + const struct gl_texture_unit *const texUnit = + &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; + return (texUnit->Enabled & bit) ? GL_TRUE : GL_FALSE; +} + + +/** + * Return simple enable/disable state. + * + * \param cap state variable to query. + * + * Returns the state of the specified capability from the current GL context. + * For the capabilities associated with extensions verifies that those + * extensions are effectively present before reporting. + */ +GLboolean GLAPIENTRY +_mesa_IsEnabled( GLenum cap ) +{ + GET_CURRENT_CONTEXT(ctx); + switch (cap) { + case GL_ALPHA_TEST: + return ctx->Color.AlphaEnabled; + case GL_AUTO_NORMAL: + return ctx->Eval.AutoNormal; + case GL_BLEND: + return ctx->Color.BlendEnabled & 1; /* return state for buffer[0] */ + case GL_CLIP_PLANE0: + case GL_CLIP_PLANE1: + case GL_CLIP_PLANE2: + case GL_CLIP_PLANE3: + case GL_CLIP_PLANE4: + case GL_CLIP_PLANE5: + return (ctx->Transform.ClipPlanesEnabled >> (cap - GL_CLIP_PLANE0)) & 1; + case GL_COLOR_MATERIAL: + return ctx->Light.ColorMaterialEnabled; + case GL_CULL_FACE: + return ctx->Polygon.CullFlag; + case GL_DEPTH_TEST: + return ctx->Depth.Test; + case GL_DITHER: + return ctx->Color.DitherFlag; + case GL_FOG: + return ctx->Fog.Enabled; + case GL_LIGHTING: + return ctx->Light.Enabled; + case GL_LIGHT0: + case GL_LIGHT1: + case GL_LIGHT2: + case GL_LIGHT3: + case GL_LIGHT4: + case GL_LIGHT5: + case GL_LIGHT6: + case GL_LIGHT7: + return ctx->Light.Light[cap-GL_LIGHT0].Enabled; + case GL_LINE_SMOOTH: + return ctx->Line.SmoothFlag; + case GL_LINE_STIPPLE: + return ctx->Line.StippleFlag; + case GL_INDEX_LOGIC_OP: + return ctx->Color.IndexLogicOpEnabled; + case GL_COLOR_LOGIC_OP: + return ctx->Color.ColorLogicOpEnabled; + case GL_MAP1_COLOR_4: + return ctx->Eval.Map1Color4; + case GL_MAP1_INDEX: + return ctx->Eval.Map1Index; + case GL_MAP1_NORMAL: + return ctx->Eval.Map1Normal; + case GL_MAP1_TEXTURE_COORD_1: + return ctx->Eval.Map1TextureCoord1; + case GL_MAP1_TEXTURE_COORD_2: + return ctx->Eval.Map1TextureCoord2; + case GL_MAP1_TEXTURE_COORD_3: + return ctx->Eval.Map1TextureCoord3; + case GL_MAP1_TEXTURE_COORD_4: + return ctx->Eval.Map1TextureCoord4; + case GL_MAP1_VERTEX_3: + return ctx->Eval.Map1Vertex3; + case GL_MAP1_VERTEX_4: + return ctx->Eval.Map1Vertex4; + case GL_MAP2_COLOR_4: + return ctx->Eval.Map2Color4; + case GL_MAP2_INDEX: + return ctx->Eval.Map2Index; + case GL_MAP2_NORMAL: + return ctx->Eval.Map2Normal; + case GL_MAP2_TEXTURE_COORD_1: + return ctx->Eval.Map2TextureCoord1; + case GL_MAP2_TEXTURE_COORD_2: + return ctx->Eval.Map2TextureCoord2; + case GL_MAP2_TEXTURE_COORD_3: + return ctx->Eval.Map2TextureCoord3; + case GL_MAP2_TEXTURE_COORD_4: + return ctx->Eval.Map2TextureCoord4; + case GL_MAP2_VERTEX_3: + return ctx->Eval.Map2Vertex3; + case GL_MAP2_VERTEX_4: + return ctx->Eval.Map2Vertex4; + case GL_NORMALIZE: + return ctx->Transform.Normalize; + case GL_POINT_SMOOTH: + return ctx->Point.SmoothFlag; + case GL_POLYGON_SMOOTH: + return ctx->Polygon.SmoothFlag; + case GL_POLYGON_STIPPLE: + return ctx->Polygon.StippleFlag; + case GL_POLYGON_OFFSET_POINT: + return ctx->Polygon.OffsetPoint; + case GL_POLYGON_OFFSET_LINE: + return ctx->Polygon.OffsetLine; + case GL_POLYGON_OFFSET_FILL: + return ctx->Polygon.OffsetFill; + case GL_RESCALE_NORMAL_EXT: + return ctx->Transform.RescaleNormals; + case GL_SCISSOR_TEST: + return ctx->Scissor.Enabled; + case GL_STENCIL_TEST: + return ctx->Stencil.Enabled; + case GL_TEXTURE_1D: + return is_texture_enabled(ctx, TEXTURE_1D_BIT); + case GL_TEXTURE_2D: + return is_texture_enabled(ctx, TEXTURE_2D_BIT); + case GL_TEXTURE_3D: + return is_texture_enabled(ctx, TEXTURE_3D_BIT); + case GL_TEXTURE_GEN_S: + case GL_TEXTURE_GEN_T: + case GL_TEXTURE_GEN_R: + case GL_TEXTURE_GEN_Q: + { + const struct gl_texture_unit *texUnit = get_texcoord_unit(ctx); + if (texUnit) { + GLbitfield coordBit = S_BIT << (cap - GL_TEXTURE_GEN_S); + return (texUnit->TexGenEnabled & coordBit) ? GL_TRUE : GL_FALSE; + } + } + return GL_FALSE; +#if FEATURE_ES1 + case GL_TEXTURE_GEN_STR_OES: + { + const struct gl_texture_unit *texUnit = get_texcoord_unit(ctx); + if (texUnit) { + return (texUnit->TexGenEnabled & STR_BITS) == STR_BITS + ? GL_TRUE : GL_FALSE; + } + } +#endif + + /* client-side state */ + case GL_VERTEX_ARRAY: + return (ctx->Array.ArrayObj->Vertex.Enabled != 0); + case GL_NORMAL_ARRAY: + return (ctx->Array.ArrayObj->Normal.Enabled != 0); + case GL_COLOR_ARRAY: + return (ctx->Array.ArrayObj->Color.Enabled != 0); + case GL_INDEX_ARRAY: + return (ctx->Array.ArrayObj->Index.Enabled != 0); + case GL_TEXTURE_COORD_ARRAY: + return (ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture] + .Enabled != 0); + case GL_EDGE_FLAG_ARRAY: + return (ctx->Array.ArrayObj->EdgeFlag.Enabled != 0); + case GL_FOG_COORDINATE_ARRAY_EXT: + CHECK_EXTENSION(EXT_fog_coord); + return (ctx->Array.ArrayObj->FogCoord.Enabled != 0); + case GL_SECONDARY_COLOR_ARRAY_EXT: + CHECK_EXTENSION(EXT_secondary_color); + return (ctx->Array.ArrayObj->SecondaryColor.Enabled != 0); +#if FEATURE_point_size_array + case GL_POINT_SIZE_ARRAY_OES: + return (ctx->Array.ArrayObj->PointSize.Enabled != 0); +#endif + + /* GL_ARB_texture_cube_map */ + case GL_TEXTURE_CUBE_MAP_ARB: + CHECK_EXTENSION(ARB_texture_cube_map); + return is_texture_enabled(ctx, TEXTURE_CUBE_BIT); + + /* GL_EXT_secondary_color */ + case GL_COLOR_SUM_EXT: + CHECK_EXTENSION2(EXT_secondary_color, ARB_vertex_program); + return ctx->Fog.ColorSumEnabled; + + /* GL_ARB_multisample */ + case GL_MULTISAMPLE_ARB: + return ctx->Multisample.Enabled; + case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB: + return ctx->Multisample.SampleAlphaToCoverage; + case GL_SAMPLE_ALPHA_TO_ONE_ARB: + return ctx->Multisample.SampleAlphaToOne; + case GL_SAMPLE_COVERAGE_ARB: + return ctx->Multisample.SampleCoverage; + case GL_SAMPLE_COVERAGE_INVERT_ARB: + return ctx->Multisample.SampleCoverageInvert; + + /* GL_IBM_rasterpos_clip */ + case GL_RASTER_POSITION_UNCLIPPED_IBM: + CHECK_EXTENSION(IBM_rasterpos_clip); + return ctx->Transform.RasterPositionUnclipped; + + /* GL_NV_point_sprite */ + case GL_POINT_SPRITE_NV: + CHECK_EXTENSION2(NV_point_sprite, ARB_point_sprite) + return ctx->Point.PointSprite; + +#if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program + case GL_VERTEX_PROGRAM_ARB: + CHECK_EXTENSION2(ARB_vertex_program, NV_vertex_program); + return ctx->VertexProgram.Enabled; + case GL_VERTEX_PROGRAM_POINT_SIZE_ARB: + CHECK_EXTENSION2(ARB_vertex_program, NV_vertex_program); + return ctx->VertexProgram.PointSizeEnabled; + case GL_VERTEX_PROGRAM_TWO_SIDE_ARB: + CHECK_EXTENSION2(ARB_vertex_program, NV_vertex_program); + return ctx->VertexProgram.TwoSideEnabled; +#endif +#if FEATURE_NV_vertex_program + case GL_VERTEX_ATTRIB_ARRAY0_NV: + case GL_VERTEX_ATTRIB_ARRAY1_NV: + case GL_VERTEX_ATTRIB_ARRAY2_NV: + case GL_VERTEX_ATTRIB_ARRAY3_NV: + case GL_VERTEX_ATTRIB_ARRAY4_NV: + case GL_VERTEX_ATTRIB_ARRAY5_NV: + case GL_VERTEX_ATTRIB_ARRAY6_NV: + case GL_VERTEX_ATTRIB_ARRAY7_NV: + case GL_VERTEX_ATTRIB_ARRAY8_NV: + case GL_VERTEX_ATTRIB_ARRAY9_NV: + case GL_VERTEX_ATTRIB_ARRAY10_NV: + case GL_VERTEX_ATTRIB_ARRAY11_NV: + case GL_VERTEX_ATTRIB_ARRAY12_NV: + case GL_VERTEX_ATTRIB_ARRAY13_NV: + case GL_VERTEX_ATTRIB_ARRAY14_NV: + case GL_VERTEX_ATTRIB_ARRAY15_NV: + CHECK_EXTENSION(NV_vertex_program); + { + GLint n = (GLint) cap - GL_VERTEX_ATTRIB_ARRAY0_NV; + ASSERT(n < Elements(ctx->Array.ArrayObj->VertexAttrib)); + return (ctx->Array.ArrayObj->VertexAttrib[n].Enabled != 0); + } + case GL_MAP1_VERTEX_ATTRIB0_4_NV: + case GL_MAP1_VERTEX_ATTRIB1_4_NV: + case GL_MAP1_VERTEX_ATTRIB2_4_NV: + case GL_MAP1_VERTEX_ATTRIB3_4_NV: + case GL_MAP1_VERTEX_ATTRIB4_4_NV: + case GL_MAP1_VERTEX_ATTRIB5_4_NV: + case GL_MAP1_VERTEX_ATTRIB6_4_NV: + case GL_MAP1_VERTEX_ATTRIB7_4_NV: + case GL_MAP1_VERTEX_ATTRIB8_4_NV: + case GL_MAP1_VERTEX_ATTRIB9_4_NV: + case GL_MAP1_VERTEX_ATTRIB10_4_NV: + case GL_MAP1_VERTEX_ATTRIB11_4_NV: + case GL_MAP1_VERTEX_ATTRIB12_4_NV: + case GL_MAP1_VERTEX_ATTRIB13_4_NV: + case GL_MAP1_VERTEX_ATTRIB14_4_NV: + case GL_MAP1_VERTEX_ATTRIB15_4_NV: + CHECK_EXTENSION(NV_vertex_program); + { + const GLuint map = (GLuint) (cap - GL_MAP1_VERTEX_ATTRIB0_4_NV); + return ctx->Eval.Map1Attrib[map]; + } + case GL_MAP2_VERTEX_ATTRIB0_4_NV: + case GL_MAP2_VERTEX_ATTRIB1_4_NV: + case GL_MAP2_VERTEX_ATTRIB2_4_NV: + case GL_MAP2_VERTEX_ATTRIB3_4_NV: + case GL_MAP2_VERTEX_ATTRIB4_4_NV: + case GL_MAP2_VERTEX_ATTRIB5_4_NV: + case GL_MAP2_VERTEX_ATTRIB6_4_NV: + case GL_MAP2_VERTEX_ATTRIB7_4_NV: + case GL_MAP2_VERTEX_ATTRIB8_4_NV: + case GL_MAP2_VERTEX_ATTRIB9_4_NV: + case GL_MAP2_VERTEX_ATTRIB10_4_NV: + case GL_MAP2_VERTEX_ATTRIB11_4_NV: + case GL_MAP2_VERTEX_ATTRIB12_4_NV: + case GL_MAP2_VERTEX_ATTRIB13_4_NV: + case GL_MAP2_VERTEX_ATTRIB14_4_NV: + case GL_MAP2_VERTEX_ATTRIB15_4_NV: + CHECK_EXTENSION(NV_vertex_program); + { + const GLuint map = (GLuint) (cap - GL_MAP2_VERTEX_ATTRIB0_4_NV); + return ctx->Eval.Map2Attrib[map]; + } +#endif /* FEATURE_NV_vertex_program */ + +#if FEATURE_NV_fragment_program + case GL_FRAGMENT_PROGRAM_NV: + CHECK_EXTENSION(NV_fragment_program); + return ctx->FragmentProgram.Enabled; +#endif /* FEATURE_NV_fragment_program */ + + /* GL_NV_texture_rectangle */ + case GL_TEXTURE_RECTANGLE_NV: + CHECK_EXTENSION(NV_texture_rectangle); + return is_texture_enabled(ctx, TEXTURE_RECT_BIT); + + /* GL_EXT_stencil_two_side */ + case GL_STENCIL_TEST_TWO_SIDE_EXT: + CHECK_EXTENSION(EXT_stencil_two_side); + return ctx->Stencil.TestTwoSide; + +#if FEATURE_ARB_fragment_program + case GL_FRAGMENT_PROGRAM_ARB: + return ctx->FragmentProgram.Enabled; +#endif /* FEATURE_ARB_fragment_program */ + + /* GL_EXT_depth_bounds_test */ + case GL_DEPTH_BOUNDS_TEST_EXT: + CHECK_EXTENSION(EXT_depth_bounds_test); + return ctx->Depth.BoundsTest; + + /* GL_ARB_depth_clamp */ + case GL_DEPTH_CLAMP: + CHECK_EXTENSION(ARB_depth_clamp); + return ctx->Transform.DepthClamp; + +#if FEATURE_ATI_fragment_shader + case GL_FRAGMENT_SHADER_ATI: + CHECK_EXTENSION(ATI_fragment_shader); + return ctx->ATIFragmentShader.Enabled; +#endif /* FEATURE_ATI_fragment_shader */ + + case GL_TEXTURE_CUBE_MAP_SEAMLESS: + CHECK_EXTENSION(ARB_seamless_cube_map); + return ctx->Texture.CubeMapSeamless; + +#if FEATURE_EXT_transform_feedback + case GL_RASTERIZER_DISCARD: + CHECK_EXTENSION(EXT_transform_feedback); + return ctx->TransformFeedback.RasterDiscard; +#endif + + /* GL_NV_primitive_restart */ + case GL_PRIMITIVE_RESTART_NV: + if (!ctx->Extensions.NV_primitive_restart) { + goto invalid_enum_error; + } + return ctx->Array.PrimitiveRestart; + + /* GL 3.1 primitive restart */ + case GL_PRIMITIVE_RESTART: + if (ctx->VersionMajor * 10 + ctx->VersionMinor < 31) { + goto invalid_enum_error; + } + return ctx->Array.PrimitiveRestart; + + /* GL3.0 - GL_framebuffer_sRGB */ + case GL_FRAMEBUFFER_SRGB_EXT: + CHECK_EXTENSION(EXT_framebuffer_sRGB); + return ctx->Color.sRGBEnabled; + + default: + goto invalid_enum_error; + } + + return GL_FALSE; + +invalid_enum_error: + _mesa_error(ctx, GL_INVALID_ENUM, "glIsEnabled(0x%x)", (int) cap); + return GL_FALSE; +} diff --git a/mesalib/src/mesa/main/enums.c b/mesalib/src/mesa/main/enums.c index 58f1c19a2..a8962a78a 100644 --- a/mesalib/src/mesa/main/enums.c +++ b/mesalib/src/mesa/main/enums.c @@ -1,6352 +1,6352 @@ -/* DO NOT EDIT - This file generated automatically by gl_enums.py (from Mesa) script */ - -/* - * Copyright (C) 1999-2005 Brian Paul All Rights Reserved. - * 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, sub license, - * 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 (including the next - * paragraph) 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 NON-INFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL, - * AND/OR THEIR SUPPLIERS 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 "main/glheader.h" -#include "main/mfeatures.h" -#include "main/enums.h" -#include "main/imports.h" -#include "main/mtypes.h" - -typedef struct { - size_t offset; - int n; -} enum_elt; - -LONGSTRING static const char enum_string_table[] = - "GL_2D\0" - "GL_2_BYTES\0" - "GL_3D\0" - "GL_3D_COLOR\0" - "GL_3D_COLOR_TEXTURE\0" - "GL_3_BYTES\0" - "GL_4D_COLOR_TEXTURE\0" - "GL_4_BYTES\0" - "GL_ACCUM\0" - "GL_ACCUM_ALPHA_BITS\0" - "GL_ACCUM_BLUE_BITS\0" - "GL_ACCUM_BUFFER_BIT\0" - "GL_ACCUM_CLEAR_VALUE\0" - "GL_ACCUM_GREEN_BITS\0" - "GL_ACCUM_RED_BITS\0" - "GL_ACTIVE_ATTRIBUTES\0" - "GL_ACTIVE_ATTRIBUTE_MAX_LENGTH\0" - "GL_ACTIVE_PROGRAM_EXT\0" - "GL_ACTIVE_STENCIL_FACE_EXT\0" - "GL_ACTIVE_TEXTURE\0" - "GL_ACTIVE_TEXTURE_ARB\0" - "GL_ACTIVE_UNIFORMS\0" - "GL_ACTIVE_UNIFORM_MAX_LENGTH\0" - "GL_ACTIVE_VERTEX_UNITS_ARB\0" - "GL_ADD\0" - "GL_ADD_SIGNED\0" - "GL_ADD_SIGNED_ARB\0" - "GL_ADD_SIGNED_EXT\0" - "GL_ALIASED_LINE_WIDTH_RANGE\0" - "GL_ALIASED_POINT_SIZE_RANGE\0" - "GL_ALL_ATTRIB_BITS\0" - "GL_ALL_CLIENT_ATTRIB_BITS\0" - "GL_ALPHA\0" - "GL_ALPHA12\0" - "GL_ALPHA12_EXT\0" - "GL_ALPHA16\0" - "GL_ALPHA16I_EXT\0" - "GL_ALPHA16UI_EXT\0" - "GL_ALPHA16_EXT\0" - "GL_ALPHA32I_EXT\0" - "GL_ALPHA32UI_EXT\0" - "GL_ALPHA4\0" - "GL_ALPHA4_EXT\0" - "GL_ALPHA8\0" - "GL_ALPHA8I_EXT\0" - "GL_ALPHA8UI_EXT\0" - "GL_ALPHA8_EXT\0" - "GL_ALPHA_BIAS\0" - "GL_ALPHA_BITS\0" - "GL_ALPHA_INTEGER_EXT\0" - "GL_ALPHA_SCALE\0" - "GL_ALPHA_TEST\0" - "GL_ALPHA_TEST_FUNC\0" - "GL_ALPHA_TEST_REF\0" - "GL_ALREADY_SIGNALED\0" - "GL_ALWAYS\0" - "GL_AMBIENT\0" - "GL_AMBIENT_AND_DIFFUSE\0" - "GL_AND\0" - "GL_AND_INVERTED\0" - "GL_AND_REVERSE\0" - "GL_ARRAY_BUFFER\0" - "GL_ARRAY_BUFFER_BINDING\0" - "GL_ARRAY_BUFFER_BINDING_ARB\0" - "GL_ATTACHED_SHADERS\0" - "GL_ATTRIB_ARRAY_POINTER_NV\0" - "GL_ATTRIB_ARRAY_SIZE_NV\0" - "GL_ATTRIB_ARRAY_STRIDE_NV\0" - "GL_ATTRIB_ARRAY_TYPE_NV\0" - "GL_ATTRIB_STACK_DEPTH\0" - "GL_AUTO_NORMAL\0" - "GL_AUX0\0" - "GL_AUX1\0" - "GL_AUX2\0" - "GL_AUX3\0" - "GL_AUX_BUFFERS\0" - "GL_BACK\0" - "GL_BACK_LEFT\0" - "GL_BACK_RIGHT\0" - "GL_BGR\0" - "GL_BGRA\0" - "GL_BGRA_EXT\0" - "GL_BGRA_INTEGER\0" - "GL_BGRA_INTEGER_EXT\0" - "GL_BGR_INTEGER\0" - "GL_BGR_INTEGER_EXT\0" - "GL_BITMAP\0" - "GL_BITMAP_TOKEN\0" - "GL_BLEND\0" - "GL_BLEND_COLOR\0" - "GL_BLEND_COLOR_EXT\0" - "GL_BLEND_DST\0" - "GL_BLEND_DST_ALPHA\0" - "GL_BLEND_DST_ALPHA_OES\0" - "GL_BLEND_DST_RGB\0" - "GL_BLEND_DST_RGB_OES\0" - "GL_BLEND_EQUATION\0" - "GL_BLEND_EQUATION_ALPHA\0" - "GL_BLEND_EQUATION_ALPHA_EXT\0" - "GL_BLEND_EQUATION_ALPHA_OES\0" - "GL_BLEND_EQUATION_EXT\0" - "GL_BLEND_EQUATION_OES\0" - "GL_BLEND_EQUATION_RGB\0" - "GL_BLEND_EQUATION_RGB_EXT\0" - "GL_BLEND_EQUATION_RGB_OES\0" - "GL_BLEND_SRC\0" - "GL_BLEND_SRC_ALPHA\0" - "GL_BLEND_SRC_ALPHA_OES\0" - "GL_BLEND_SRC_RGB\0" - "GL_BLEND_SRC_RGB_OES\0" - "GL_BLUE\0" - "GL_BLUE_BIAS\0" - "GL_BLUE_BITS\0" - "GL_BLUE_INTEGER\0" - "GL_BLUE_INTEGER_EXT\0" - "GL_BLUE_SCALE\0" - "GL_BOOL\0" - "GL_BOOL_ARB\0" - "GL_BOOL_VEC2\0" - "GL_BOOL_VEC2_ARB\0" - "GL_BOOL_VEC3\0" - "GL_BOOL_VEC3_ARB\0" - "GL_BOOL_VEC4\0" - "GL_BOOL_VEC4_ARB\0" - "GL_BUFFER_ACCESS\0" - "GL_BUFFER_ACCESS_ARB\0" - "GL_BUFFER_ACCESS_FLAGS\0" - "GL_BUFFER_ACCESS_OES\0" - "GL_BUFFER_FLUSHING_UNMAP_APPLE\0" - "GL_BUFFER_MAPPED\0" - "GL_BUFFER_MAPPED_ARB\0" - "GL_BUFFER_MAPPED_OES\0" - "GL_BUFFER_MAP_LENGTH\0" - "GL_BUFFER_MAP_OFFSET\0" - "GL_BUFFER_MAP_POINTER\0" - "GL_BUFFER_MAP_POINTER_ARB\0" - "GL_BUFFER_MAP_POINTER_OES\0" - "GL_BUFFER_OBJECT_APPLE\0" - "GL_BUFFER_SERIALIZED_MODIFY_APPLE\0" - "GL_BUFFER_SIZE\0" - "GL_BUFFER_SIZE_ARB\0" - "GL_BUFFER_USAGE\0" - "GL_BUFFER_USAGE_ARB\0" - "GL_BUMP_ENVMAP_ATI\0" - "GL_BUMP_NUM_TEX_UNITS_ATI\0" - "GL_BUMP_ROT_MATRIX_ATI\0" - "GL_BUMP_ROT_MATRIX_SIZE_ATI\0" - "GL_BUMP_TARGET_ATI\0" - "GL_BUMP_TEX_UNITS_ATI\0" - "GL_BYTE\0" - "GL_C3F_V3F\0" - "GL_C4F_N3F_V3F\0" - "GL_C4UB_V2F\0" - "GL_C4UB_V3F\0" - "GL_CCW\0" - "GL_CLAMP\0" - "GL_CLAMP_FRAGMENT_COLOR_ARB\0" - "GL_CLAMP_READ_COLOR\0" - "GL_CLAMP_READ_COLOR_ARB\0" - "GL_CLAMP_TO_BORDER\0" - "GL_CLAMP_TO_BORDER_ARB\0" - "GL_CLAMP_TO_BORDER_SGIS\0" - "GL_CLAMP_TO_EDGE\0" - "GL_CLAMP_TO_EDGE_SGIS\0" - "GL_CLAMP_VERTEX_COLOR_ARB\0" - "GL_CLEAR\0" - "GL_CLIENT_ACTIVE_TEXTURE\0" - "GL_CLIENT_ACTIVE_TEXTURE_ARB\0" - "GL_CLIENT_ALL_ATTRIB_BITS\0" - "GL_CLIENT_ATTRIB_STACK_DEPTH\0" - "GL_CLIENT_PIXEL_STORE_BIT\0" - "GL_CLIENT_VERTEX_ARRAY_BIT\0" - "GL_CLIP_DISTANCE0\0" - "GL_CLIP_DISTANCE1\0" - "GL_CLIP_DISTANCE2\0" - "GL_CLIP_DISTANCE3\0" - "GL_CLIP_DISTANCE4\0" - "GL_CLIP_DISTANCE5\0" - "GL_CLIP_DISTANCE6\0" - "GL_CLIP_DISTANCE7\0" - "GL_CLIP_PLANE0\0" - "GL_CLIP_PLANE1\0" - "GL_CLIP_PLANE2\0" - "GL_CLIP_PLANE3\0" - "GL_CLIP_PLANE4\0" - "GL_CLIP_PLANE5\0" - "GL_CLIP_VOLUME_CLIPPING_HINT_EXT\0" - "GL_COEFF\0" - "GL_COLOR\0" - "GL_COLOR_ARRAY\0" - "GL_COLOR_ARRAY_BUFFER_BINDING\0" - "GL_COLOR_ARRAY_BUFFER_BINDING_ARB\0" - "GL_COLOR_ARRAY_POINTER\0" - "GL_COLOR_ARRAY_SIZE\0" - "GL_COLOR_ARRAY_STRIDE\0" - "GL_COLOR_ARRAY_TYPE\0" - "GL_COLOR_ATTACHMENT0\0" - "GL_COLOR_ATTACHMENT0_EXT\0" - "GL_COLOR_ATTACHMENT0_OES\0" - "GL_COLOR_ATTACHMENT1\0" - "GL_COLOR_ATTACHMENT10\0" - "GL_COLOR_ATTACHMENT10_EXT\0" - "GL_COLOR_ATTACHMENT11\0" - "GL_COLOR_ATTACHMENT11_EXT\0" - "GL_COLOR_ATTACHMENT12\0" - "GL_COLOR_ATTACHMENT12_EXT\0" - "GL_COLOR_ATTACHMENT13\0" - "GL_COLOR_ATTACHMENT13_EXT\0" - "GL_COLOR_ATTACHMENT14\0" - "GL_COLOR_ATTACHMENT14_EXT\0" - "GL_COLOR_ATTACHMENT15\0" - "GL_COLOR_ATTACHMENT15_EXT\0" - "GL_COLOR_ATTACHMENT1_EXT\0" - "GL_COLOR_ATTACHMENT2\0" - "GL_COLOR_ATTACHMENT2_EXT\0" - "GL_COLOR_ATTACHMENT3\0" - "GL_COLOR_ATTACHMENT3_EXT\0" - "GL_COLOR_ATTACHMENT4\0" - "GL_COLOR_ATTACHMENT4_EXT\0" - "GL_COLOR_ATTACHMENT5\0" - "GL_COLOR_ATTACHMENT5_EXT\0" - "GL_COLOR_ATTACHMENT6\0" - "GL_COLOR_ATTACHMENT6_EXT\0" - "GL_COLOR_ATTACHMENT7\0" - "GL_COLOR_ATTACHMENT7_EXT\0" - "GL_COLOR_ATTACHMENT8\0" - "GL_COLOR_ATTACHMENT8_EXT\0" - "GL_COLOR_ATTACHMENT9\0" - "GL_COLOR_ATTACHMENT9_EXT\0" - "GL_COLOR_BUFFER_BIT\0" - "GL_COLOR_CLEAR_VALUE\0" - "GL_COLOR_INDEX\0" - "GL_COLOR_INDEXES\0" - "GL_COLOR_LOGIC_OP\0" - "GL_COLOR_MATERIAL\0" - "GL_COLOR_MATERIAL_FACE\0" - "GL_COLOR_MATERIAL_PARAMETER\0" - "GL_COLOR_MATRIX\0" - "GL_COLOR_MATRIX_SGI\0" - "GL_COLOR_MATRIX_STACK_DEPTH\0" - "GL_COLOR_MATRIX_STACK_DEPTH_SGI\0" - "GL_COLOR_SUM\0" - "GL_COLOR_SUM_ARB\0" - "GL_COLOR_TABLE\0" - "GL_COLOR_TABLE_ALPHA_SIZE\0" - "GL_COLOR_TABLE_ALPHA_SIZE_EXT\0" - "GL_COLOR_TABLE_ALPHA_SIZE_SGI\0" - "GL_COLOR_TABLE_BIAS\0" - "GL_COLOR_TABLE_BIAS_SGI\0" - "GL_COLOR_TABLE_BLUE_SIZE\0" - "GL_COLOR_TABLE_BLUE_SIZE_EXT\0" - "GL_COLOR_TABLE_BLUE_SIZE_SGI\0" - "GL_COLOR_TABLE_FORMAT\0" - "GL_COLOR_TABLE_FORMAT_EXT\0" - "GL_COLOR_TABLE_FORMAT_SGI\0" - "GL_COLOR_TABLE_GREEN_SIZE\0" - "GL_COLOR_TABLE_GREEN_SIZE_EXT\0" - "GL_COLOR_TABLE_GREEN_SIZE_SGI\0" - "GL_COLOR_TABLE_INTENSITY_SIZE\0" - "GL_COLOR_TABLE_INTENSITY_SIZE_EXT\0" - "GL_COLOR_TABLE_INTENSITY_SIZE_SGI\0" - "GL_COLOR_TABLE_LUMINANCE_SIZE\0" - "GL_COLOR_TABLE_LUMINANCE_SIZE_EXT\0" - "GL_COLOR_TABLE_LUMINANCE_SIZE_SGI\0" - "GL_COLOR_TABLE_RED_SIZE\0" - "GL_COLOR_TABLE_RED_SIZE_EXT\0" - "GL_COLOR_TABLE_RED_SIZE_SGI\0" - "GL_COLOR_TABLE_SCALE\0" - "GL_COLOR_TABLE_SCALE_SGI\0" - "GL_COLOR_TABLE_WIDTH\0" - "GL_COLOR_TABLE_WIDTH_EXT\0" - "GL_COLOR_TABLE_WIDTH_SGI\0" - "GL_COLOR_WRITEMASK\0" - "GL_COMBINE\0" - "GL_COMBINE4\0" - "GL_COMBINE_ALPHA\0" - "GL_COMBINE_ALPHA_ARB\0" - "GL_COMBINE_ALPHA_EXT\0" - "GL_COMBINE_ARB\0" - "GL_COMBINE_EXT\0" - "GL_COMBINE_RGB\0" - "GL_COMBINE_RGB_ARB\0" - "GL_COMBINE_RGB_EXT\0" - "GL_COMPARE_REF_DEPTH_TO_TEXTURE_EXT\0" - "GL_COMPARE_REF_TO_TEXTURE\0" - "GL_COMPARE_R_TO_TEXTURE\0" - "GL_COMPARE_R_TO_TEXTURE_ARB\0" - "GL_COMPILE\0" - "GL_COMPILE_AND_EXECUTE\0" - "GL_COMPILE_STATUS\0" - "GL_COMPRESSED_ALPHA\0" - "GL_COMPRESSED_ALPHA_ARB\0" - "GL_COMPRESSED_INTENSITY\0" - "GL_COMPRESSED_INTENSITY_ARB\0" - "GL_COMPRESSED_LUMINANCE\0" - "GL_COMPRESSED_LUMINANCE_ALPHA\0" - "GL_COMPRESSED_LUMINANCE_ALPHA_ARB\0" - "GL_COMPRESSED_LUMINANCE_ARB\0" - "GL_COMPRESSED_RED\0" - "GL_COMPRESSED_RG\0" - "GL_COMPRESSED_RGB\0" - "GL_COMPRESSED_RGBA\0" - "GL_COMPRESSED_RGBA_ARB\0" - "GL_COMPRESSED_RGBA_FXT1_3DFX\0" - "GL_COMPRESSED_RGBA_S3TC_DXT1_EXT\0" - "GL_COMPRESSED_RGBA_S3TC_DXT3_EXT\0" - "GL_COMPRESSED_RGBA_S3TC_DXT5_EXT\0" - "GL_COMPRESSED_RGB_ARB\0" - "GL_COMPRESSED_RGB_FXT1_3DFX\0" - "GL_COMPRESSED_RGB_S3TC_DXT1_EXT\0" - "GL_COMPRESSED_SLUMINANCE\0" - "GL_COMPRESSED_SLUMINANCE_ALPHA\0" - "GL_COMPRESSED_SRGB\0" - "GL_COMPRESSED_SRGB_ALPHA\0" - "GL_COMPRESSED_TEXTURE_FORMATS\0" - "GL_CONDITION_SATISFIED\0" - "GL_CONSTANT\0" - "GL_CONSTANT_ALPHA\0" - "GL_CONSTANT_ALPHA_EXT\0" - "GL_CONSTANT_ARB\0" - "GL_CONSTANT_ATTENUATION\0" - "GL_CONSTANT_BORDER_HP\0" - "GL_CONSTANT_COLOR\0" - "GL_CONSTANT_COLOR_EXT\0" - "GL_CONSTANT_EXT\0" - "GL_CONTEXT_COMPATIBILITY_PROFILE_BIT\0" - "GL_CONTEXT_CORE_PROFILE_BIT\0" - "GL_CONTEXT_FLAGS\0" - "GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT\0" - "GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB\0" - "GL_CONTEXT_PROFILE_MASK\0" - "GL_CONVOLUTION_1D\0" - "GL_CONVOLUTION_2D\0" - "GL_CONVOLUTION_BORDER_COLOR\0" - "GL_CONVOLUTION_BORDER_COLOR_HP\0" - "GL_CONVOLUTION_BORDER_MODE\0" - "GL_CONVOLUTION_BORDER_MODE_EXT\0" - "GL_CONVOLUTION_FILTER_BIAS\0" - "GL_CONVOLUTION_FILTER_BIAS_EXT\0" - "GL_CONVOLUTION_FILTER_SCALE\0" - "GL_CONVOLUTION_FILTER_SCALE_EXT\0" - "GL_CONVOLUTION_FORMAT\0" - "GL_CONVOLUTION_FORMAT_EXT\0" - "GL_CONVOLUTION_HEIGHT\0" - "GL_CONVOLUTION_HEIGHT_EXT\0" - "GL_CONVOLUTION_WIDTH\0" - "GL_CONVOLUTION_WIDTH_EXT\0" - "GL_COORD_REPLACE\0" - "GL_COORD_REPLACE_ARB\0" - "GL_COORD_REPLACE_NV\0" - "GL_COORD_REPLACE_OES\0" - "GL_COPY\0" - "GL_COPY_INVERTED\0" - "GL_COPY_PIXEL_TOKEN\0" - "GL_COPY_READ_BUFFER\0" - "GL_COPY_WRITE_BUFFER\0" - "GL_CULL_FACE\0" - "GL_CULL_FACE_MODE\0" - "GL_CULL_VERTEX_EXT\0" - "GL_CULL_VERTEX_EYE_POSITION_EXT\0" - "GL_CULL_VERTEX_OBJECT_POSITION_EXT\0" - "GL_CURRENT_ATTRIB_NV\0" - "GL_CURRENT_BIT\0" - "GL_CURRENT_COLOR\0" - "GL_CURRENT_FOG_COORD\0" - "GL_CURRENT_FOG_COORDINATE\0" - "GL_CURRENT_INDEX\0" - "GL_CURRENT_MATRIX_ARB\0" - "GL_CURRENT_MATRIX_INDEX_ARB\0" - "GL_CURRENT_MATRIX_NV\0" - "GL_CURRENT_MATRIX_STACK_DEPTH_ARB\0" - "GL_CURRENT_MATRIX_STACK_DEPTH_NV\0" - "GL_CURRENT_NORMAL\0" - "GL_CURRENT_PALETTE_MATRIX_ARB\0" - "GL_CURRENT_PALETTE_MATRIX_OES\0" - "GL_CURRENT_PROGRAM\0" - "GL_CURRENT_QUERY\0" - "GL_CURRENT_QUERY_ARB\0" - "GL_CURRENT_RASTER_COLOR\0" - "GL_CURRENT_RASTER_DISTANCE\0" - "GL_CURRENT_RASTER_INDEX\0" - "GL_CURRENT_RASTER_POSITION\0" - "GL_CURRENT_RASTER_POSITION_VALID\0" - "GL_CURRENT_RASTER_SECONDARY_COLOR\0" - "GL_CURRENT_RASTER_TEXTURE_COORDS\0" - "GL_CURRENT_SECONDARY_COLOR\0" - "GL_CURRENT_TEXTURE_COORDS\0" - "GL_CURRENT_VERTEX_ATTRIB\0" - "GL_CURRENT_VERTEX_ATTRIB_ARB\0" - "GL_CURRENT_WEIGHT_ARB\0" - "GL_CW\0" - "GL_DEBUG_ASSERT_MESA\0" - "GL_DEBUG_OBJECT_MESA\0" - "GL_DEBUG_PRINT_MESA\0" - "GL_DECAL\0" - "GL_DECR\0" - "GL_DECR_WRAP\0" - "GL_DECR_WRAP_EXT\0" - "GL_DELETE_STATUS\0" - "GL_DEPTH\0" - "GL_DEPTH24_STENCIL8\0" - "GL_DEPTH24_STENCIL8_EXT\0" - "GL_DEPTH24_STENCIL8_OES\0" - "GL_DEPTH_ATTACHMENT\0" - "GL_DEPTH_ATTACHMENT_EXT\0" - "GL_DEPTH_ATTACHMENT_OES\0" - "GL_DEPTH_BIAS\0" - "GL_DEPTH_BITS\0" - "GL_DEPTH_BOUNDS_EXT\0" - "GL_DEPTH_BOUNDS_TEST_EXT\0" - "GL_DEPTH_BUFFER\0" - "GL_DEPTH_BUFFER_BIT\0" - "GL_DEPTH_CLAMP\0" - "GL_DEPTH_CLAMP_NV\0" - "GL_DEPTH_CLEAR_VALUE\0" - "GL_DEPTH_COMPONENT\0" - "GL_DEPTH_COMPONENT16\0" - "GL_DEPTH_COMPONENT16_ARB\0" - "GL_DEPTH_COMPONENT16_OES\0" - "GL_DEPTH_COMPONENT16_SGIX\0" - "GL_DEPTH_COMPONENT24\0" - "GL_DEPTH_COMPONENT24_ARB\0" - "GL_DEPTH_COMPONENT24_OES\0" - "GL_DEPTH_COMPONENT24_SGIX\0" - "GL_DEPTH_COMPONENT32\0" - "GL_DEPTH_COMPONENT32_ARB\0" - "GL_DEPTH_COMPONENT32_OES\0" - "GL_DEPTH_COMPONENT32_SGIX\0" - "GL_DEPTH_FUNC\0" - "GL_DEPTH_RANGE\0" - "GL_DEPTH_SCALE\0" - "GL_DEPTH_STENCIL\0" - "GL_DEPTH_STENCIL_ATTACHMENT\0" - "GL_DEPTH_STENCIL_EXT\0" - "GL_DEPTH_STENCIL_NV\0" - "GL_DEPTH_STENCIL_OES\0" - "GL_DEPTH_STENCIL_TO_BGRA_NV\0" - "GL_DEPTH_STENCIL_TO_RGBA_NV\0" - "GL_DEPTH_TEST\0" - "GL_DEPTH_TEXTURE_MODE\0" - "GL_DEPTH_TEXTURE_MODE_ARB\0" - "GL_DEPTH_WRITEMASK\0" - "GL_DIFFUSE\0" - "GL_DITHER\0" - "GL_DOMAIN\0" - "GL_DONT_CARE\0" - "GL_DOT3_RGB\0" - "GL_DOT3_RGBA\0" - "GL_DOT3_RGBA_ARB\0" - "GL_DOT3_RGBA_EXT\0" - "GL_DOT3_RGB_ARB\0" - "GL_DOT3_RGB_EXT\0" - "GL_DOUBLE\0" - "GL_DOUBLEBUFFER\0" - "GL_DRAW_BUFFER\0" - "GL_DRAW_BUFFER0\0" - "GL_DRAW_BUFFER0_ARB\0" - "GL_DRAW_BUFFER0_ATI\0" - "GL_DRAW_BUFFER1\0" - "GL_DRAW_BUFFER10\0" - "GL_DRAW_BUFFER10_ARB\0" - "GL_DRAW_BUFFER10_ATI\0" - "GL_DRAW_BUFFER11\0" - "GL_DRAW_BUFFER11_ARB\0" - "GL_DRAW_BUFFER11_ATI\0" - "GL_DRAW_BUFFER12\0" - "GL_DRAW_BUFFER12_ARB\0" - "GL_DRAW_BUFFER12_ATI\0" - "GL_DRAW_BUFFER13\0" - "GL_DRAW_BUFFER13_ARB\0" - "GL_DRAW_BUFFER13_ATI\0" - "GL_DRAW_BUFFER14\0" - "GL_DRAW_BUFFER14_ARB\0" - "GL_DRAW_BUFFER14_ATI\0" - "GL_DRAW_BUFFER15\0" - "GL_DRAW_BUFFER15_ARB\0" - "GL_DRAW_BUFFER15_ATI\0" - "GL_DRAW_BUFFER1_ARB\0" - "GL_DRAW_BUFFER1_ATI\0" - "GL_DRAW_BUFFER2\0" - "GL_DRAW_BUFFER2_ARB\0" - "GL_DRAW_BUFFER2_ATI\0" - "GL_DRAW_BUFFER3\0" - "GL_DRAW_BUFFER3_ARB\0" - "GL_DRAW_BUFFER3_ATI\0" - "GL_DRAW_BUFFER4\0" - "GL_DRAW_BUFFER4_ARB\0" - "GL_DRAW_BUFFER4_ATI\0" - "GL_DRAW_BUFFER5\0" - "GL_DRAW_BUFFER5_ARB\0" - "GL_DRAW_BUFFER5_ATI\0" - "GL_DRAW_BUFFER6\0" - "GL_DRAW_BUFFER6_ARB\0" - "GL_DRAW_BUFFER6_ATI\0" - "GL_DRAW_BUFFER7\0" - "GL_DRAW_BUFFER7_ARB\0" - "GL_DRAW_BUFFER7_ATI\0" - "GL_DRAW_BUFFER8\0" - "GL_DRAW_BUFFER8_ARB\0" - "GL_DRAW_BUFFER8_ATI\0" - "GL_DRAW_BUFFER9\0" - "GL_DRAW_BUFFER9_ARB\0" - "GL_DRAW_BUFFER9_ATI\0" - "GL_DRAW_FRAMEBUFFER\0" - "GL_DRAW_FRAMEBUFFER_BINDING\0" - "GL_DRAW_FRAMEBUFFER_BINDING_EXT\0" - "GL_DRAW_FRAMEBUFFER_EXT\0" - "GL_DRAW_PIXEL_TOKEN\0" - "GL_DST_ALPHA\0" - "GL_DST_COLOR\0" - "GL_DU8DV8_ATI\0" - "GL_DUDV_ATI\0" - "GL_DYNAMIC_COPY\0" - "GL_DYNAMIC_COPY_ARB\0" - "GL_DYNAMIC_DRAW\0" - "GL_DYNAMIC_DRAW_ARB\0" - "GL_DYNAMIC_READ\0" - "GL_DYNAMIC_READ_ARB\0" - "GL_EDGE_FLAG\0" - "GL_EDGE_FLAG_ARRAY\0" - "GL_EDGE_FLAG_ARRAY_BUFFER_BINDING\0" - "GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB\0" - "GL_EDGE_FLAG_ARRAY_POINTER\0" - "GL_EDGE_FLAG_ARRAY_STRIDE\0" - "GL_ELEMENT_ARRAY_BUFFER\0" - "GL_ELEMENT_ARRAY_BUFFER_BINDING\0" - "GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB\0" - "GL_EMISSION\0" - "GL_ENABLE_BIT\0" - "GL_EQUAL\0" - "GL_EQUIV\0" - "GL_EVAL_BIT\0" - "GL_EXP\0" - "GL_EXP2\0" - "GL_EXTENSIONS\0" - "GL_EYE_LINEAR\0" - "GL_EYE_PLANE\0" - "GL_EYE_PLANE_ABSOLUTE_NV\0" - "GL_EYE_RADIAL_NV\0" - "GL_FALSE\0" - "GL_FASTEST\0" - "GL_FEEDBACK\0" - "GL_FEEDBACK_BUFFER_POINTER\0" - "GL_FEEDBACK_BUFFER_SIZE\0" - "GL_FEEDBACK_BUFFER_TYPE\0" - "GL_FILL\0" - "GL_FIRST_VERTEX_CONVENTION\0" - "GL_FIRST_VERTEX_CONVENTION_EXT\0" - "GL_FIXED\0" - "GL_FIXED_OES\0" - "GL_FIXED_ONLY\0" - "GL_FIXED_ONLY_ARB\0" - "GL_FLAT\0" - "GL_FLOAT\0" - "GL_FLOAT_MAT2\0" - "GL_FLOAT_MAT2_ARB\0" - "GL_FLOAT_MAT2x3\0" - "GL_FLOAT_MAT2x4\0" - "GL_FLOAT_MAT3\0" - "GL_FLOAT_MAT3_ARB\0" - "GL_FLOAT_MAT3x2\0" - "GL_FLOAT_MAT3x4\0" - "GL_FLOAT_MAT4\0" - "GL_FLOAT_MAT4_ARB\0" - "GL_FLOAT_MAT4x2\0" - "GL_FLOAT_MAT4x3\0" - "GL_FLOAT_VEC2\0" - "GL_FLOAT_VEC2_ARB\0" - "GL_FLOAT_VEC3\0" - "GL_FLOAT_VEC3_ARB\0" - "GL_FLOAT_VEC4\0" - "GL_FLOAT_VEC4_ARB\0" - "GL_FOG\0" - "GL_FOG_BIT\0" - "GL_FOG_COLOR\0" - "GL_FOG_COORD\0" - "GL_FOG_COORDINATE\0" - "GL_FOG_COORDINATE_ARRAY\0" - "GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING\0" - "GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB\0" - "GL_FOG_COORDINATE_ARRAY_POINTER\0" - "GL_FOG_COORDINATE_ARRAY_STRIDE\0" - "GL_FOG_COORDINATE_ARRAY_TYPE\0" - "GL_FOG_COORDINATE_SOURCE\0" - "GL_FOG_COORD_ARRAY\0" - "GL_FOG_COORD_ARRAY_BUFFER_BINDING\0" - "GL_FOG_COORD_ARRAY_POINTER\0" - "GL_FOG_COORD_ARRAY_STRIDE\0" - "GL_FOG_COORD_ARRAY_TYPE\0" - "GL_FOG_COORD_SRC\0" - "GL_FOG_DENSITY\0" - "GL_FOG_DISTANCE_MODE_NV\0" - "GL_FOG_END\0" - "GL_FOG_HINT\0" - "GL_FOG_INDEX\0" - "GL_FOG_MODE\0" - "GL_FOG_OFFSET_SGIX\0" - "GL_FOG_OFFSET_VALUE_SGIX\0" - "GL_FOG_START\0" - "GL_FRAGMENT_DEPTH\0" - "GL_FRAGMENT_PROGRAM_ARB\0" - "GL_FRAGMENT_SHADER\0" - "GL_FRAGMENT_SHADER_ARB\0" - "GL_FRAGMENT_SHADER_DERIVATIVE_HINT\0" - "GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES\0" - "GL_FRAMEBUFFER\0" - "GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE\0" - "GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE\0" - "GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING\0" - "GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE\0" - "GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE\0" - "GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE\0" - "GL_FRAMEBUFFER_ATTACHMENT_LAYERED\0" - "GL_FRAMEBUFFER_ATTACHMENT_LAYERED_ARB\0" - "GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME\0" - "GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT\0" - "GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_OES\0" - "GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE\0" - "GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT\0" - "GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_OES\0" - "GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE\0" - "GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE\0" - "GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT\0" - "GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_OES\0" - "GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE\0" - "GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT\0" - "GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_OES\0" - "GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER\0" - "GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT\0" - "GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL\0" - "GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT\0" - "GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_OES\0" - "GL_FRAMEBUFFER_BINDING\0" - "GL_FRAMEBUFFER_BINDING_EXT\0" - "GL_FRAMEBUFFER_BINDING_OES\0" - "GL_FRAMEBUFFER_COMPLETE\0" - "GL_FRAMEBUFFER_COMPLETE_EXT\0" - "GL_FRAMEBUFFER_COMPLETE_OES\0" - "GL_FRAMEBUFFER_DEFAULT\0" - "GL_FRAMEBUFFER_EXT\0" - "GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT\0" - "GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT\0" - "GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_OES\0" - "GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS\0" - "GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT\0" - "GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_OES\0" - "GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER\0" - "GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT\0" - "GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_OES\0" - "GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT\0" - "GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT\0" - "GL_FRAMEBUFFER_INCOMPLETE_FORMATS_OES\0" - "GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB\0" - "GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS\0" - "GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_ARB\0" - "GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT\0" - "GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT\0" - "GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_OES\0" - "GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE\0" - "GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT\0" - "GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER\0" - "GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT\0" - "GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_OES\0" - "GL_FRAMEBUFFER_OES\0" - "GL_FRAMEBUFFER_STATUS_ERROR_EXT\0" - "GL_FRAMEBUFFER_UNDEFINED\0" - "GL_FRAMEBUFFER_UNSUPPORTED\0" - "GL_FRAMEBUFFER_UNSUPPORTED_EXT\0" - "GL_FRAMEBUFFER_UNSUPPORTED_OES\0" - "GL_FRONT\0" - "GL_FRONT_AND_BACK\0" - "GL_FRONT_FACE\0" - "GL_FRONT_LEFT\0" - "GL_FRONT_RIGHT\0" - "GL_FUNC_ADD\0" - "GL_FUNC_ADD_EXT\0" - "GL_FUNC_ADD_OES\0" - "GL_FUNC_REVERSE_SUBTRACT\0" - "GL_FUNC_REVERSE_SUBTRACT_EXT\0" - "GL_FUNC_REVERSE_SUBTRACT_OES\0" - "GL_FUNC_SUBTRACT\0" - "GL_FUNC_SUBTRACT_EXT\0" - "GL_FUNC_SUBTRACT_OES\0" - "GL_GENERATE_MIPMAP\0" - "GL_GENERATE_MIPMAP_HINT\0" - "GL_GENERATE_MIPMAP_HINT_SGIS\0" - "GL_GENERATE_MIPMAP_SGIS\0" - "GL_GEOMETRY_INPUT_TYPE\0" - "GL_GEOMETRY_INPUT_TYPE_ARB\0" - "GL_GEOMETRY_OUTPUT_TYPE\0" - "GL_GEOMETRY_OUTPUT_TYPE_ARB\0" - "GL_GEOMETRY_SHADER\0" - "GL_GEOMETRY_SHADER_ARB\0" - "GL_GEOMETRY_VERTICES_OUT\0" - "GL_GEOMETRY_VERTICES_OUT_ARB\0" - "GL_GEQUAL\0" - "GL_GREATER\0" - "GL_GREEN\0" - "GL_GREEN_BIAS\0" - "GL_GREEN_BITS\0" - "GL_GREEN_INTEGER\0" - "GL_GREEN_INTEGER_EXT\0" - "GL_GREEN_SCALE\0" - "GL_GUILTY_CONTEXT_RESET_ARB\0" - "GL_HALF_FLOAT\0" - "GL_HALF_FLOAT_OES\0" - "GL_HIGH_FLOAT\0" - "GL_HIGH_INT\0" - "GL_HINT_BIT\0" - "GL_HISTOGRAM\0" - "GL_HISTOGRAM_ALPHA_SIZE\0" - "GL_HISTOGRAM_ALPHA_SIZE_EXT\0" - "GL_HISTOGRAM_BLUE_SIZE\0" - "GL_HISTOGRAM_BLUE_SIZE_EXT\0" - "GL_HISTOGRAM_EXT\0" - "GL_HISTOGRAM_FORMAT\0" - "GL_HISTOGRAM_FORMAT_EXT\0" - "GL_HISTOGRAM_GREEN_SIZE\0" - "GL_HISTOGRAM_GREEN_SIZE_EXT\0" - "GL_HISTOGRAM_LUMINANCE_SIZE\0" - "GL_HISTOGRAM_LUMINANCE_SIZE_EXT\0" - "GL_HISTOGRAM_RED_SIZE\0" - "GL_HISTOGRAM_RED_SIZE_EXT\0" - "GL_HISTOGRAM_SINK\0" - "GL_HISTOGRAM_SINK_EXT\0" - "GL_HISTOGRAM_WIDTH\0" - "GL_HISTOGRAM_WIDTH_EXT\0" - "GL_IDENTITY_NV\0" - "GL_IGNORE_BORDER_HP\0" - "GL_IMPLEMENTATION_COLOR_READ_FORMAT\0" - "GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES\0" - "GL_IMPLEMENTATION_COLOR_READ_TYPE\0" - "GL_IMPLEMENTATION_COLOR_READ_TYPE_OES\0" - "GL_INCR\0" - "GL_INCR_WRAP\0" - "GL_INCR_WRAP_EXT\0" - "GL_INDEX\0" - "GL_INDEX_ARRAY\0" - "GL_INDEX_ARRAY_BUFFER_BINDING\0" - "GL_INDEX_ARRAY_BUFFER_BINDING_ARB\0" - "GL_INDEX_ARRAY_POINTER\0" - "GL_INDEX_ARRAY_STRIDE\0" - "GL_INDEX_ARRAY_TYPE\0" - "GL_INDEX_BITS\0" - "GL_INDEX_CLEAR_VALUE\0" - "GL_INDEX_LOGIC_OP\0" - "GL_INDEX_MODE\0" - "GL_INDEX_OFFSET\0" - "GL_INDEX_SHIFT\0" - "GL_INDEX_WRITEMASK\0" - "GL_INFO_LOG_LENGTH\0" - "GL_INNOCENT_CONTEXT_RESET_ARB\0" - "GL_INT\0" - "GL_INTENSITY\0" - "GL_INTENSITY12\0" - "GL_INTENSITY12_EXT\0" - "GL_INTENSITY16\0" - "GL_INTENSITY16I_EXT\0" - "GL_INTENSITY16UI_EXT\0" - "GL_INTENSITY16_EXT\0" - "GL_INTENSITY32I_EXT\0" - "GL_INTENSITY32UI_EXT\0" - "GL_INTENSITY4\0" - "GL_INTENSITY4_EXT\0" - "GL_INTENSITY8\0" - "GL_INTENSITY8I_EXT\0" - "GL_INTENSITY8UI_EXT\0" - "GL_INTENSITY8_EXT\0" - "GL_INTENSITY_EXT\0" - "GL_INTERLEAVED_ATTRIBS\0" - "GL_INTERLEAVED_ATTRIBS_EXT\0" - "GL_INTERPOLATE\0" - "GL_INTERPOLATE_ARB\0" - "GL_INTERPOLATE_EXT\0" - "GL_INT_10_10_10_2_OES\0" - "GL_INT_2_10_10_10_REV\0" - "GL_INT_SAMPLER_1D\0" - "GL_INT_SAMPLER_1D_ARRAY\0" - "GL_INT_SAMPLER_1D_ARRAY_EXT\0" - "GL_INT_SAMPLER_1D_EXT\0" - "GL_INT_SAMPLER_2D\0" - "GL_INT_SAMPLER_2D_ARRAY\0" - "GL_INT_SAMPLER_2D_ARRAY_EXT\0" - "GL_INT_SAMPLER_2D_EXT\0" - "GL_INT_SAMPLER_2D_RECT\0" - "GL_INT_SAMPLER_2D_RECT_EXT\0" - "GL_INT_SAMPLER_3D\0" - "GL_INT_SAMPLER_3D_EXT\0" - "GL_INT_SAMPLER_BUFFER\0" - "GL_INT_SAMPLER_BUFFER_EXT\0" - "GL_INT_SAMPLER_CUBE\0" - "GL_INT_SAMPLER_CUBE_EXT\0" - "GL_INT_VEC2\0" - "GL_INT_VEC2_ARB\0" - "GL_INT_VEC3\0" - "GL_INT_VEC3_ARB\0" - "GL_INT_VEC4\0" - "GL_INT_VEC4_ARB\0" - "GL_INVALID_ENUM\0" - "GL_INVALID_FRAMEBUFFER_OPERATION\0" - "GL_INVALID_FRAMEBUFFER_OPERATION_EXT\0" - "GL_INVALID_FRAMEBUFFER_OPERATION_OES\0" - "GL_INVALID_OPERATION\0" - "GL_INVALID_VALUE\0" - "GL_INVERSE_NV\0" - "GL_INVERSE_TRANSPOSE_NV\0" - "GL_INVERT\0" - "GL_KEEP\0" - "GL_LAST_VERTEX_CONVENTION\0" - "GL_LAST_VERTEX_CONVENTION_EXT\0" - "GL_LEFT\0" - "GL_LEQUAL\0" - "GL_LESS\0" - "GL_LIGHT0\0" - "GL_LIGHT1\0" - "GL_LIGHT2\0" - "GL_LIGHT3\0" - "GL_LIGHT4\0" - "GL_LIGHT5\0" - "GL_LIGHT6\0" - "GL_LIGHT7\0" - "GL_LIGHTING\0" - "GL_LIGHTING_BIT\0" - "GL_LIGHT_MODEL_AMBIENT\0" - "GL_LIGHT_MODEL_COLOR_CONTROL\0" - "GL_LIGHT_MODEL_COLOR_CONTROL_EXT\0" - "GL_LIGHT_MODEL_LOCAL_VIEWER\0" - "GL_LIGHT_MODEL_TWO_SIDE\0" - "GL_LINE\0" - "GL_LINEAR\0" - "GL_LINEAR_ATTENUATION\0" - "GL_LINEAR_CLIPMAP_LINEAR_SGIX\0" - "GL_LINEAR_CLIPMAP_NEAREST_SGIX\0" - "GL_LINEAR_MIPMAP_LINEAR\0" - "GL_LINEAR_MIPMAP_NEAREST\0" - "GL_LINES\0" - "GL_LINES_ADJACENCY\0" - "GL_LINES_ADJACENCY_ARB\0" - "GL_LINE_BIT\0" - "GL_LINE_LOOP\0" - "GL_LINE_RESET_TOKEN\0" - "GL_LINE_SMOOTH\0" - "GL_LINE_SMOOTH_HINT\0" - "GL_LINE_STIPPLE\0" - "GL_LINE_STIPPLE_PATTERN\0" - "GL_LINE_STIPPLE_REPEAT\0" - "GL_LINE_STRIP\0" - "GL_LINE_STRIP_ADJACENCY\0" - "GL_LINE_STRIP_ADJACENCY_ARB\0" - "GL_LINE_TOKEN\0" - "GL_LINE_WIDTH\0" - "GL_LINE_WIDTH_GRANULARITY\0" - "GL_LINE_WIDTH_RANGE\0" - "GL_LINK_STATUS\0" - "GL_LIST_BASE\0" - "GL_LIST_BIT\0" - "GL_LIST_INDEX\0" - "GL_LIST_MODE\0" - "GL_LOAD\0" - "GL_LOGIC_OP\0" - "GL_LOGIC_OP_MODE\0" - "GL_LOSE_CONTEXT_ON_RESET_ARB\0" - "GL_LOWER_LEFT\0" - "GL_LOW_FLOAT\0" - "GL_LOW_INT\0" - "GL_LUMINANCE\0" - "GL_LUMINANCE12\0" - "GL_LUMINANCE12_ALPHA12\0" - "GL_LUMINANCE12_ALPHA12_EXT\0" - "GL_LUMINANCE12_ALPHA4\0" - "GL_LUMINANCE12_ALPHA4_EXT\0" - "GL_LUMINANCE12_EXT\0" - "GL_LUMINANCE16\0" - "GL_LUMINANCE16I_EXT\0" - "GL_LUMINANCE16UI_EXT\0" - "GL_LUMINANCE16_ALPHA16\0" - "GL_LUMINANCE16_ALPHA16_EXT\0" - "GL_LUMINANCE16_EXT\0" - "GL_LUMINANCE32I_EXT\0" - "GL_LUMINANCE32UI_EXT\0" - "GL_LUMINANCE4\0" - "GL_LUMINANCE4_ALPHA4\0" - "GL_LUMINANCE4_ALPHA4_EXT\0" - "GL_LUMINANCE4_EXT\0" - "GL_LUMINANCE6_ALPHA2\0" - "GL_LUMINANCE6_ALPHA2_EXT\0" - "GL_LUMINANCE8\0" - "GL_LUMINANCE8I_EXT\0" - "GL_LUMINANCE8UI_EXT\0" - "GL_LUMINANCE8_ALPHA8\0" - "GL_LUMINANCE8_ALPHA8_EXT\0" - "GL_LUMINANCE8_EXT\0" - "GL_LUMINANCE_ALPHA\0" - "GL_LUMINANCE_ALPHA16I_EXT\0" - "GL_LUMINANCE_ALPHA16UI_EXT\0" - "GL_LUMINANCE_ALPHA32I_EXT\0" - "GL_LUMINANCE_ALPHA32UI_EXT\0" - "GL_LUMINANCE_ALPHA8I_EXT\0" - "GL_LUMINANCE_ALPHA8UI_EXT\0" - "GL_LUMINANCE_ALPHA_INTEGER_EXT\0" - "GL_LUMINANCE_INTEGER_EXT\0" - "GL_MAJOR_VERSION\0" - "GL_MAP1_COLOR_4\0" - "GL_MAP1_GRID_DOMAIN\0" - "GL_MAP1_GRID_SEGMENTS\0" - "GL_MAP1_INDEX\0" - "GL_MAP1_NORMAL\0" - "GL_MAP1_TEXTURE_COORD_1\0" - "GL_MAP1_TEXTURE_COORD_2\0" - "GL_MAP1_TEXTURE_COORD_3\0" - "GL_MAP1_TEXTURE_COORD_4\0" - "GL_MAP1_VERTEX_3\0" - "GL_MAP1_VERTEX_4\0" - "GL_MAP1_VERTEX_ATTRIB0_4_NV\0" - "GL_MAP1_VERTEX_ATTRIB10_4_NV\0" - "GL_MAP1_VERTEX_ATTRIB11_4_NV\0" - "GL_MAP1_VERTEX_ATTRIB12_4_NV\0" - "GL_MAP1_VERTEX_ATTRIB13_4_NV\0" - "GL_MAP1_VERTEX_ATTRIB14_4_NV\0" - "GL_MAP1_VERTEX_ATTRIB15_4_NV\0" - "GL_MAP1_VERTEX_ATTRIB1_4_NV\0" - "GL_MAP1_VERTEX_ATTRIB2_4_NV\0" - "GL_MAP1_VERTEX_ATTRIB3_4_NV\0" - "GL_MAP1_VERTEX_ATTRIB4_4_NV\0" - "GL_MAP1_VERTEX_ATTRIB5_4_NV\0" - "GL_MAP1_VERTEX_ATTRIB6_4_NV\0" - "GL_MAP1_VERTEX_ATTRIB7_4_NV\0" - "GL_MAP1_VERTEX_ATTRIB8_4_NV\0" - "GL_MAP1_VERTEX_ATTRIB9_4_NV\0" - "GL_MAP2_COLOR_4\0" - "GL_MAP2_GRID_DOMAIN\0" - "GL_MAP2_GRID_SEGMENTS\0" - "GL_MAP2_INDEX\0" - "GL_MAP2_NORMAL\0" - "GL_MAP2_TEXTURE_COORD_1\0" - "GL_MAP2_TEXTURE_COORD_2\0" - "GL_MAP2_TEXTURE_COORD_3\0" - "GL_MAP2_TEXTURE_COORD_4\0" - "GL_MAP2_VERTEX_3\0" - "GL_MAP2_VERTEX_4\0" - "GL_MAP2_VERTEX_ATTRIB0_4_NV\0" - "GL_MAP2_VERTEX_ATTRIB10_4_NV\0" - "GL_MAP2_VERTEX_ATTRIB11_4_NV\0" - "GL_MAP2_VERTEX_ATTRIB12_4_NV\0" - "GL_MAP2_VERTEX_ATTRIB13_4_NV\0" - "GL_MAP2_VERTEX_ATTRIB14_4_NV\0" - "GL_MAP2_VERTEX_ATTRIB15_4_NV\0" - "GL_MAP2_VERTEX_ATTRIB1_4_NV\0" - "GL_MAP2_VERTEX_ATTRIB2_4_NV\0" - "GL_MAP2_VERTEX_ATTRIB3_4_NV\0" - "GL_MAP2_VERTEX_ATTRIB4_4_NV\0" - "GL_MAP2_VERTEX_ATTRIB5_4_NV\0" - "GL_MAP2_VERTEX_ATTRIB6_4_NV\0" - "GL_MAP2_VERTEX_ATTRIB7_4_NV\0" - "GL_MAP2_VERTEX_ATTRIB8_4_NV\0" - "GL_MAP2_VERTEX_ATTRIB9_4_NV\0" - "GL_MAP_COLOR\0" - "GL_MAP_FLUSH_EXPLICIT_BIT\0" - "GL_MAP_INVALIDATE_BUFFER_BIT\0" - "GL_MAP_INVALIDATE_RANGE_BIT\0" - "GL_MAP_READ_BIT\0" - "GL_MAP_STENCIL\0" - "GL_MAP_UNSYNCHRONIZED_BIT\0" - "GL_MAP_WRITE_BIT\0" - "GL_MATRIX0_ARB\0" - "GL_MATRIX0_NV\0" - "GL_MATRIX10_ARB\0" - "GL_MATRIX11_ARB\0" - "GL_MATRIX12_ARB\0" - "GL_MATRIX13_ARB\0" - "GL_MATRIX14_ARB\0" - "GL_MATRIX15_ARB\0" - "GL_MATRIX16_ARB\0" - "GL_MATRIX17_ARB\0" - "GL_MATRIX18_ARB\0" - "GL_MATRIX19_ARB\0" - "GL_MATRIX1_ARB\0" - "GL_MATRIX1_NV\0" - "GL_MATRIX20_ARB\0" - "GL_MATRIX21_ARB\0" - "GL_MATRIX22_ARB\0" - "GL_MATRIX23_ARB\0" - "GL_MATRIX24_ARB\0" - "GL_MATRIX25_ARB\0" - "GL_MATRIX26_ARB\0" - "GL_MATRIX27_ARB\0" - "GL_MATRIX28_ARB\0" - "GL_MATRIX29_ARB\0" - "GL_MATRIX2_ARB\0" - "GL_MATRIX2_NV\0" - "GL_MATRIX30_ARB\0" - "GL_MATRIX31_ARB\0" - "GL_MATRIX3_ARB\0" - "GL_MATRIX3_NV\0" - "GL_MATRIX4_ARB\0" - "GL_MATRIX4_NV\0" - "GL_MATRIX5_ARB\0" - "GL_MATRIX5_NV\0" - "GL_MATRIX6_ARB\0" - "GL_MATRIX6_NV\0" - "GL_MATRIX7_ARB\0" - "GL_MATRIX7_NV\0" - "GL_MATRIX8_ARB\0" - "GL_MATRIX9_ARB\0" - "GL_MATRIX_INDEX_ARRAY_ARB\0" - "GL_MATRIX_INDEX_ARRAY_BUFFER_BINDING_OES\0" - "GL_MATRIX_INDEX_ARRAY_OES\0" - "GL_MATRIX_INDEX_ARRAY_POINTER_ARB\0" - "GL_MATRIX_INDEX_ARRAY_POINTER_OES\0" - "GL_MATRIX_INDEX_ARRAY_SIZE_ARB\0" - "GL_MATRIX_INDEX_ARRAY_SIZE_OES\0" - "GL_MATRIX_INDEX_ARRAY_STRIDE_ARB\0" - "GL_MATRIX_INDEX_ARRAY_STRIDE_OES\0" - "GL_MATRIX_INDEX_ARRAY_TYPE_ARB\0" - "GL_MATRIX_INDEX_ARRAY_TYPE_OES\0" - "GL_MATRIX_MODE\0" - "GL_MATRIX_PALETTE_ARB\0" - "GL_MATRIX_PALETTE_OES\0" - "GL_MAX\0" - "GL_MAX_3D_TEXTURE_SIZE\0" - "GL_MAX_3D_TEXTURE_SIZE_OES\0" - "GL_MAX_ARRAY_TEXTURE_LAYERS\0" - "GL_MAX_ARRAY_TEXTURE_LAYERS_EXT\0" - "GL_MAX_ATTRIB_STACK_DEPTH\0" - "GL_MAX_CLIENT_ATTRIB_STACK_DEPTH\0" - "GL_MAX_CLIPMAP_DEPTH_SGIX\0" - "GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX\0" - "GL_MAX_CLIP_DISTANCES\0" - "GL_MAX_CLIP_PLANES\0" - "GL_MAX_COLOR_ATTACHMENTS\0" - "GL_MAX_COLOR_ATTACHMENTS_EXT\0" - "GL_MAX_COLOR_MATRIX_STACK_DEPTH\0" - "GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI\0" - "GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS\0" - "GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB\0" - "GL_MAX_CONVOLUTION_HEIGHT\0" - "GL_MAX_CONVOLUTION_HEIGHT_EXT\0" - "GL_MAX_CONVOLUTION_WIDTH\0" - "GL_MAX_CONVOLUTION_WIDTH_EXT\0" - "GL_MAX_CUBE_MAP_TEXTURE_SIZE\0" - "GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB\0" - "GL_MAX_CUBE_MAP_TEXTURE_SIZE_OES\0" - "GL_MAX_DRAW_BUFFERS\0" - "GL_MAX_DRAW_BUFFERS_ARB\0" - "GL_MAX_DRAW_BUFFERS_ATI\0" - "GL_MAX_ELEMENTS_INDICES\0" - "GL_MAX_ELEMENTS_VERTICES\0" - "GL_MAX_EVAL_ORDER\0" - "GL_MAX_EXT\0" - "GL_MAX_FRAGMENT_INPUT_COMPONENTS\0" - "GL_MAX_FRAGMENT_UNIFORM_COMPONENTS\0" - "GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB\0" - "GL_MAX_FRAGMENT_UNIFORM_VECTORS\0" - "GL_MAX_GEOMETRY_INPUT_COMPONENTS\0" - "GL_MAX_GEOMETRY_OUTPUT_COMPONENTS\0" - "GL_MAX_GEOMETRY_OUTPUT_VERTICES\0" - "GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB\0" - "GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS\0" - "GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB\0" - "GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS\0" - "GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB\0" - "GL_MAX_GEOMETRY_UNIFORM_COMPONENTS\0" - "GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB\0" - "GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB\0" - "GL_MAX_LIGHTS\0" - "GL_MAX_LIST_NESTING\0" - "GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB\0" - "GL_MAX_MODELVIEW_STACK_DEPTH\0" - "GL_MAX_NAME_STACK_DEPTH\0" - "GL_MAX_PALETTE_MATRICES_ARB\0" - "GL_MAX_PALETTE_MATRICES_OES\0" - "GL_MAX_PIXEL_MAP_TABLE\0" - "GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB\0" - "GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB\0" - "GL_MAX_PROGRAM_ATTRIBS_ARB\0" - "GL_MAX_PROGRAM_CALL_DEPTH_NV\0" - "GL_MAX_PROGRAM_ENV_PARAMETERS_ARB\0" - "GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV\0" - "GL_MAX_PROGRAM_IF_DEPTH_NV\0" - "GL_MAX_PROGRAM_INSTRUCTIONS_ARB\0" - "GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB\0" - "GL_MAX_PROGRAM_LOOP_COUNT_NV\0" - "GL_MAX_PROGRAM_LOOP_DEPTH_NV\0" - "GL_MAX_PROGRAM_MATRICES_ARB\0" - "GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB\0" - "GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB\0" - "GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB\0" - "GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB\0" - "GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB\0" - "GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB\0" - "GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB\0" - "GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB\0" - "GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB\0" - "GL_MAX_PROGRAM_PARAMETERS_ARB\0" - "GL_MAX_PROGRAM_TEMPORARIES_ARB\0" - "GL_MAX_PROGRAM_TEXEL_OFFSET\0" - "GL_MAX_PROGRAM_TEXEL_OFFSET_EXT\0" - "GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB\0" - "GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB\0" - "GL_MAX_PROJECTION_STACK_DEPTH\0" - "GL_MAX_RECTANGLE_TEXTURE_SIZE\0" - "GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB\0" - "GL_MAX_RECTANGLE_TEXTURE_SIZE_NV\0" - "GL_MAX_RENDERBUFFER_SIZE\0" - "GL_MAX_RENDERBUFFER_SIZE_EXT\0" - "GL_MAX_RENDERBUFFER_SIZE_OES\0" - "GL_MAX_SAMPLES\0" - "GL_MAX_SAMPLES_EXT\0" - "GL_MAX_SERVER_WAIT_TIMEOUT\0" - "GL_MAX_SHININESS_NV\0" - "GL_MAX_SPOT_EXPONENT_NV\0" - "GL_MAX_TEXTURE_BUFFER_SIZE\0" - "GL_MAX_TEXTURE_BUFFER_SIZE_ARB\0" - "GL_MAX_TEXTURE_COORDS\0" - "GL_MAX_TEXTURE_COORDS_ARB\0" - "GL_MAX_TEXTURE_IMAGE_UNITS\0" - "GL_MAX_TEXTURE_IMAGE_UNITS_ARB\0" - "GL_MAX_TEXTURE_LOD_BIAS\0" - "GL_MAX_TEXTURE_LOD_BIAS_EXT\0" - "GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT\0" - "GL_MAX_TEXTURE_SIZE\0" - "GL_MAX_TEXTURE_STACK_DEPTH\0" - "GL_MAX_TEXTURE_UNITS\0" - "GL_MAX_TEXTURE_UNITS_ARB\0" - "GL_MAX_TRACK_MATRICES_NV\0" - "GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV\0" - "GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS\0" - "GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_EXT\0" - "GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS\0" - "GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_EXT\0" - "GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS\0" - "GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_EXT\0" - "GL_MAX_VARYING_COMPONENTS\0" - "GL_MAX_VARYING_FLOATS\0" - "GL_MAX_VARYING_FLOATS_ARB\0" - "GL_MAX_VARYING_VECTORS\0" - "GL_MAX_VERTEX_ATTRIBS\0" - "GL_MAX_VERTEX_ATTRIBS_ARB\0" - "GL_MAX_VERTEX_OUTPUT_COMPONENTS\0" - "GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS\0" - "GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB\0" - "GL_MAX_VERTEX_UNIFORM_COMPONENTS\0" - "GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB\0" - "GL_MAX_VERTEX_UNIFORM_VECTORS\0" - "GL_MAX_VERTEX_UNITS_ARB\0" - "GL_MAX_VERTEX_UNITS_OES\0" - "GL_MAX_VERTEX_VARYING_COMPONENTS_ARB\0" - "GL_MAX_VIEWPORT_DIMS\0" - "GL_MEDIUM_FLOAT\0" - "GL_MEDIUM_INT\0" - "GL_MIN\0" - "GL_MINMAX\0" - "GL_MINMAX_EXT\0" - "GL_MINMAX_FORMAT\0" - "GL_MINMAX_FORMAT_EXT\0" - "GL_MINMAX_SINK\0" - "GL_MINMAX_SINK_EXT\0" - "GL_MINOR_VERSION\0" - "GL_MIN_EXT\0" - "GL_MIN_PROGRAM_TEXEL_OFFSET\0" - "GL_MIN_PROGRAM_TEXEL_OFFSET_EXT\0" - "GL_MIRRORED_REPEAT\0" - "GL_MIRRORED_REPEAT_ARB\0" - "GL_MIRRORED_REPEAT_IBM\0" - "GL_MIRROR_CLAMP_ATI\0" - "GL_MIRROR_CLAMP_EXT\0" - "GL_MIRROR_CLAMP_TO_BORDER_EXT\0" - "GL_MIRROR_CLAMP_TO_EDGE_ATI\0" - "GL_MIRROR_CLAMP_TO_EDGE_EXT\0" - "GL_MODELVIEW\0" - "GL_MODELVIEW0_ARB\0" - "GL_MODELVIEW10_ARB\0" - "GL_MODELVIEW11_ARB\0" - "GL_MODELVIEW12_ARB\0" - "GL_MODELVIEW13_ARB\0" - "GL_MODELVIEW14_ARB\0" - "GL_MODELVIEW15_ARB\0" - "GL_MODELVIEW16_ARB\0" - "GL_MODELVIEW17_ARB\0" - "GL_MODELVIEW18_ARB\0" - "GL_MODELVIEW19_ARB\0" - "GL_MODELVIEW1_ARB\0" - "GL_MODELVIEW20_ARB\0" - "GL_MODELVIEW21_ARB\0" - "GL_MODELVIEW22_ARB\0" - "GL_MODELVIEW23_ARB\0" - "GL_MODELVIEW24_ARB\0" - "GL_MODELVIEW25_ARB\0" - "GL_MODELVIEW26_ARB\0" - "GL_MODELVIEW27_ARB\0" - "GL_MODELVIEW28_ARB\0" - "GL_MODELVIEW29_ARB\0" - "GL_MODELVIEW2_ARB\0" - "GL_MODELVIEW30_ARB\0" - "GL_MODELVIEW31_ARB\0" - "GL_MODELVIEW3_ARB\0" - "GL_MODELVIEW4_ARB\0" - "GL_MODELVIEW5_ARB\0" - "GL_MODELVIEW6_ARB\0" - "GL_MODELVIEW7_ARB\0" - "GL_MODELVIEW8_ARB\0" - "GL_MODELVIEW9_ARB\0" - "GL_MODELVIEW_MATRIX\0" - "GL_MODELVIEW_MATRIX_FLOAT_AS_INT_BITS_OES\0" - "GL_MODELVIEW_PROJECTION_NV\0" - "GL_MODELVIEW_STACK_DEPTH\0" - "GL_MODULATE\0" - "GL_MODULATE_ADD_ATI\0" - "GL_MODULATE_SIGNED_ADD_ATI\0" - "GL_MODULATE_SUBTRACT_ATI\0" - "GL_MULT\0" - "GL_MULTISAMPLE\0" - "GL_MULTISAMPLE_3DFX\0" - "GL_MULTISAMPLE_ARB\0" - "GL_MULTISAMPLE_BIT\0" - "GL_MULTISAMPLE_BIT_3DFX\0" - "GL_MULTISAMPLE_BIT_ARB\0" - "GL_MULTISAMPLE_FILTER_HINT_NV\0" - "GL_N3F_V3F\0" - "GL_NAME_STACK_DEPTH\0" - "GL_NAND\0" - "GL_NEAREST\0" - "GL_NEAREST_CLIPMAP_LINEAR_SGIX\0" - "GL_NEAREST_CLIPMAP_NEAREST_SGIX\0" - "GL_NEAREST_MIPMAP_LINEAR\0" - "GL_NEAREST_MIPMAP_NEAREST\0" - "GL_NEVER\0" - "GL_NICEST\0" - "GL_NONE\0" - "GL_NONE_OES\0" - "GL_NOOP\0" - "GL_NOR\0" - "GL_NORMALIZE\0" - "GL_NORMAL_ARRAY\0" - "GL_NORMAL_ARRAY_BUFFER_BINDING\0" - "GL_NORMAL_ARRAY_BUFFER_BINDING_ARB\0" - "GL_NORMAL_ARRAY_POINTER\0" - "GL_NORMAL_ARRAY_STRIDE\0" - "GL_NORMAL_ARRAY_TYPE\0" - "GL_NORMAL_MAP\0" - "GL_NORMAL_MAP_ARB\0" - "GL_NORMAL_MAP_NV\0" - "GL_NORMAL_MAP_OES\0" - "GL_NOTEQUAL\0" - "GL_NO_ERROR\0" - "GL_NO_RESET_NOTIFICATION_ARB\0" - "GL_NUM_COMPRESSED_TEXTURE_FORMATS\0" - "GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB\0" - "GL_NUM_EXTENSIONS\0" - "GL_NUM_PROGRAM_BINARY_FORMATS\0" - "GL_NUM_PROGRAM_BINARY_FORMATS_OES\0" - "GL_NUM_SHADER_BINARY_FORMATS\0" - "GL_OBJECT_ACTIVE_ATTRIBUTES_ARB\0" - "GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB\0" - "GL_OBJECT_ACTIVE_UNIFORMS_ARB\0" - "GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB\0" - "GL_OBJECT_ATTACHED_OBJECTS_ARB\0" - "GL_OBJECT_COMPILE_STATUS_ARB\0" - "GL_OBJECT_DELETE_STATUS_ARB\0" - "GL_OBJECT_INFO_LOG_LENGTH_ARB\0" - "GL_OBJECT_LINEAR\0" - "GL_OBJECT_LINK_STATUS_ARB\0" - "GL_OBJECT_PLANE\0" - "GL_OBJECT_SHADER_SOURCE_LENGTH_ARB\0" - "GL_OBJECT_SUBTYPE_ARB\0" - "GL_OBJECT_TYPE\0" - "GL_OBJECT_TYPE_ARB\0" - "GL_OBJECT_VALIDATE_STATUS_ARB\0" - "GL_OCCLUSION_TEST_HP\0" - "GL_OCCLUSION_TEST_RESULT_HP\0" - "GL_ONE\0" - "GL_ONE_MINUS_CONSTANT_ALPHA\0" - "GL_ONE_MINUS_CONSTANT_ALPHA_EXT\0" - "GL_ONE_MINUS_CONSTANT_COLOR\0" - "GL_ONE_MINUS_CONSTANT_COLOR_EXT\0" - "GL_ONE_MINUS_DST_ALPHA\0" - "GL_ONE_MINUS_DST_COLOR\0" - "GL_ONE_MINUS_SRC_ALPHA\0" - "GL_ONE_MINUS_SRC_COLOR\0" - "GL_OPERAND0_ALPHA\0" - "GL_OPERAND0_ALPHA_ARB\0" - "GL_OPERAND0_ALPHA_EXT\0" - "GL_OPERAND0_RGB\0" - "GL_OPERAND0_RGB_ARB\0" - "GL_OPERAND0_RGB_EXT\0" - "GL_OPERAND1_ALPHA\0" - "GL_OPERAND1_ALPHA_ARB\0" - "GL_OPERAND1_ALPHA_EXT\0" - "GL_OPERAND1_RGB\0" - "GL_OPERAND1_RGB_ARB\0" - "GL_OPERAND1_RGB_EXT\0" - "GL_OPERAND2_ALPHA\0" - "GL_OPERAND2_ALPHA_ARB\0" - "GL_OPERAND2_ALPHA_EXT\0" - "GL_OPERAND2_RGB\0" - "GL_OPERAND2_RGB_ARB\0" - "GL_OPERAND2_RGB_EXT\0" - "GL_OPERAND3_ALPHA_NV\0" - "GL_OPERAND3_RGB_NV\0" - "GL_OR\0" - "GL_ORDER\0" - "GL_OR_INVERTED\0" - "GL_OR_REVERSE\0" - "GL_OUT_OF_MEMORY\0" - "GL_PACK_ALIGNMENT\0" - "GL_PACK_IMAGE_HEIGHT\0" - "GL_PACK_INVERT_MESA\0" - "GL_PACK_LSB_FIRST\0" - "GL_PACK_ROW_LENGTH\0" - "GL_PACK_SKIP_IMAGES\0" - "GL_PACK_SKIP_PIXELS\0" - "GL_PACK_SKIP_ROWS\0" - "GL_PACK_SWAP_BYTES\0" - "GL_PALETTE4_R5_G6_B5_OES\0" - "GL_PALETTE4_RGB5_A1_OES\0" - "GL_PALETTE4_RGB8_OES\0" - "GL_PALETTE4_RGBA4_OES\0" - "GL_PALETTE4_RGBA8_OES\0" - "GL_PALETTE8_R5_G6_B5_OES\0" - "GL_PALETTE8_RGB5_A1_OES\0" - "GL_PALETTE8_RGB8_OES\0" - "GL_PALETTE8_RGBA4_OES\0" - "GL_PALETTE8_RGBA8_OES\0" - "GL_PASS_THROUGH_TOKEN\0" - "GL_PERSPECTIVE_CORRECTION_HINT\0" - "GL_PIXEL_MAP_A_TO_A\0" - "GL_PIXEL_MAP_A_TO_A_SIZE\0" - "GL_PIXEL_MAP_B_TO_B\0" - "GL_PIXEL_MAP_B_TO_B_SIZE\0" - "GL_PIXEL_MAP_G_TO_G\0" - "GL_PIXEL_MAP_G_TO_G_SIZE\0" - "GL_PIXEL_MAP_I_TO_A\0" - "GL_PIXEL_MAP_I_TO_A_SIZE\0" - "GL_PIXEL_MAP_I_TO_B\0" - "GL_PIXEL_MAP_I_TO_B_SIZE\0" - "GL_PIXEL_MAP_I_TO_G\0" - "GL_PIXEL_MAP_I_TO_G_SIZE\0" - "GL_PIXEL_MAP_I_TO_I\0" - "GL_PIXEL_MAP_I_TO_I_SIZE\0" - "GL_PIXEL_MAP_I_TO_R\0" - "GL_PIXEL_MAP_I_TO_R_SIZE\0" - "GL_PIXEL_MAP_R_TO_R\0" - "GL_PIXEL_MAP_R_TO_R_SIZE\0" - "GL_PIXEL_MAP_S_TO_S\0" - "GL_PIXEL_MAP_S_TO_S_SIZE\0" - "GL_PIXEL_MODE_BIT\0" - "GL_PIXEL_PACK_BUFFER\0" - "GL_PIXEL_PACK_BUFFER_BINDING\0" - "GL_PIXEL_PACK_BUFFER_BINDING_EXT\0" - "GL_PIXEL_PACK_BUFFER_EXT\0" - "GL_PIXEL_UNPACK_BUFFER\0" - "GL_PIXEL_UNPACK_BUFFER_BINDING\0" - "GL_PIXEL_UNPACK_BUFFER_BINDING_EXT\0" - "GL_PIXEL_UNPACK_BUFFER_EXT\0" - "GL_POINT\0" - "GL_POINTS\0" - "GL_POINT_BIT\0" - "GL_POINT_DISTANCE_ATTENUATION\0" - "GL_POINT_DISTANCE_ATTENUATION_ARB\0" - "GL_POINT_DISTANCE_ATTENUATION_EXT\0" - "GL_POINT_DISTANCE_ATTENUATION_SGIS\0" - "GL_POINT_FADE_THRESHOLD_SIZE\0" - "GL_POINT_FADE_THRESHOLD_SIZE_ARB\0" - "GL_POINT_FADE_THRESHOLD_SIZE_EXT\0" - "GL_POINT_FADE_THRESHOLD_SIZE_SGIS\0" - "GL_POINT_SIZE\0" - "GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES\0" - "GL_POINT_SIZE_ARRAY_OES\0" - "GL_POINT_SIZE_ARRAY_POINTER_OES\0" - "GL_POINT_SIZE_ARRAY_STRIDE_OES\0" - "GL_POINT_SIZE_ARRAY_TYPE_OES\0" - "GL_POINT_SIZE_GRANULARITY\0" - "GL_POINT_SIZE_MAX\0" - "GL_POINT_SIZE_MAX_ARB\0" - "GL_POINT_SIZE_MAX_EXT\0" - "GL_POINT_SIZE_MAX_SGIS\0" - "GL_POINT_SIZE_MIN\0" - "GL_POINT_SIZE_MIN_ARB\0" - "GL_POINT_SIZE_MIN_EXT\0" - "GL_POINT_SIZE_MIN_SGIS\0" - "GL_POINT_SIZE_RANGE\0" - "GL_POINT_SMOOTH\0" - "GL_POINT_SMOOTH_HINT\0" - "GL_POINT_SPRITE\0" - "GL_POINT_SPRITE_ARB\0" - "GL_POINT_SPRITE_COORD_ORIGIN\0" - "GL_POINT_SPRITE_NV\0" - "GL_POINT_SPRITE_OES\0" - "GL_POINT_SPRITE_R_MODE_NV\0" - "GL_POINT_TOKEN\0" - "GL_POLYGON\0" - "GL_POLYGON_BIT\0" - "GL_POLYGON_MODE\0" - "GL_POLYGON_OFFSET_BIAS\0" - "GL_POLYGON_OFFSET_FACTOR\0" - "GL_POLYGON_OFFSET_FILL\0" - "GL_POLYGON_OFFSET_LINE\0" - "GL_POLYGON_OFFSET_POINT\0" - "GL_POLYGON_OFFSET_UNITS\0" - "GL_POLYGON_SMOOTH\0" - "GL_POLYGON_SMOOTH_HINT\0" - "GL_POLYGON_STIPPLE\0" - "GL_POLYGON_STIPPLE_BIT\0" - "GL_POLYGON_TOKEN\0" - "GL_POSITION\0" - "GL_POST_COLOR_MATRIX_ALPHA_BIAS\0" - "GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI\0" - "GL_POST_COLOR_MATRIX_ALPHA_SCALE\0" - "GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI\0" - "GL_POST_COLOR_MATRIX_BLUE_BIAS\0" - "GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI\0" - "GL_POST_COLOR_MATRIX_BLUE_SCALE\0" - "GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI\0" - "GL_POST_COLOR_MATRIX_COLOR_TABLE\0" - "GL_POST_COLOR_MATRIX_GREEN_BIAS\0" - "GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI\0" - "GL_POST_COLOR_MATRIX_GREEN_SCALE\0" - "GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI\0" - "GL_POST_COLOR_MATRIX_RED_BIAS\0" - "GL_POST_COLOR_MATRIX_RED_BIAS_SGI\0" - "GL_POST_COLOR_MATRIX_RED_SCALE\0" - "GL_POST_COLOR_MATRIX_RED_SCALE_SGI\0" - "GL_POST_CONVOLUTION_ALPHA_BIAS\0" - "GL_POST_CONVOLUTION_ALPHA_BIAS_EXT\0" - "GL_POST_CONVOLUTION_ALPHA_SCALE\0" - "GL_POST_CONVOLUTION_ALPHA_SCALE_EXT\0" - "GL_POST_CONVOLUTION_BLUE_BIAS\0" - "GL_POST_CONVOLUTION_BLUE_BIAS_EXT\0" - "GL_POST_CONVOLUTION_BLUE_SCALE\0" - "GL_POST_CONVOLUTION_BLUE_SCALE_EXT\0" - "GL_POST_CONVOLUTION_COLOR_TABLE\0" - "GL_POST_CONVOLUTION_GREEN_BIAS\0" - "GL_POST_CONVOLUTION_GREEN_BIAS_EXT\0" - "GL_POST_CONVOLUTION_GREEN_SCALE\0" - "GL_POST_CONVOLUTION_GREEN_SCALE_EXT\0" - "GL_POST_CONVOLUTION_RED_BIAS\0" - "GL_POST_CONVOLUTION_RED_BIAS_EXT\0" - "GL_POST_CONVOLUTION_RED_SCALE\0" - "GL_POST_CONVOLUTION_RED_SCALE_EXT\0" - "GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX\0" - "GL_POST_TEXTURE_FILTER_BIAS_SGIX\0" - "GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX\0" - "GL_POST_TEXTURE_FILTER_SCALE_SGIX\0" - "GL_PREVIOUS\0" - "GL_PREVIOUS_ARB\0" - "GL_PREVIOUS_EXT\0" - "GL_PRIMARY_COLOR\0" - "GL_PRIMARY_COLOR_ARB\0" - "GL_PRIMARY_COLOR_EXT\0" - "GL_PRIMITIVES_GENERATED\0" - "GL_PRIMITIVES_GENERATED_EXT\0" - "GL_PRIMITIVE_RESTART\0" - "GL_PRIMITIVE_RESTART_INDEX\0" - "GL_PRIMITIVE_RESTART_INDEX_NV\0" - "GL_PRIMITIVE_RESTART_NV\0" - "GL_PROGRAM_ADDRESS_REGISTERS_ARB\0" - "GL_PROGRAM_ALU_INSTRUCTIONS_ARB\0" - "GL_PROGRAM_ATTRIBS_ARB\0" - "GL_PROGRAM_BINARY_FORMATS\0" - "GL_PROGRAM_BINARY_FORMATS_OES\0" - "GL_PROGRAM_BINARY_LENGTH\0" - "GL_PROGRAM_BINARY_LENGTH_OES\0" - "GL_PROGRAM_BINARY_RETRIEVABLE_HINT\0" - "GL_PROGRAM_BINDING_ARB\0" - "GL_PROGRAM_ERROR_POSITION_ARB\0" - "GL_PROGRAM_ERROR_POSITION_NV\0" - "GL_PROGRAM_ERROR_STRING_ARB\0" - "GL_PROGRAM_FORMAT_ARB\0" - "GL_PROGRAM_FORMAT_ASCII_ARB\0" - "GL_PROGRAM_INSTRUCTIONS_ARB\0" - "GL_PROGRAM_LENGTH_ARB\0" - "GL_PROGRAM_LENGTH_NV\0" - "GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB\0" - "GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB\0" - "GL_PROGRAM_NATIVE_ATTRIBS_ARB\0" - "GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB\0" - "GL_PROGRAM_NATIVE_PARAMETERS_ARB\0" - "GL_PROGRAM_NATIVE_TEMPORARIES_ARB\0" - "GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB\0" - "GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB\0" - "GL_PROGRAM_OBJECT_ARB\0" - "GL_PROGRAM_PARAMETERS_ARB\0" - "GL_PROGRAM_PARAMETER_NV\0" - "GL_PROGRAM_POINT_SIZE\0" - "GL_PROGRAM_POINT_SIZE_ARB\0" - "GL_PROGRAM_RESIDENT_NV\0" - "GL_PROGRAM_STRING_ARB\0" - "GL_PROGRAM_STRING_NV\0" - "GL_PROGRAM_TARGET_NV\0" - "GL_PROGRAM_TEMPORARIES_ARB\0" - "GL_PROGRAM_TEX_INDIRECTIONS_ARB\0" - "GL_PROGRAM_TEX_INSTRUCTIONS_ARB\0" - "GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB\0" - "GL_PROJECTION\0" - "GL_PROJECTION_MATRIX\0" - "GL_PROJECTION_MATRIX_FLOAT_AS_INT_BITS_OES\0" - "GL_PROJECTION_STACK_DEPTH\0" - "GL_PROVOKING_VERTEX\0" - "GL_PROVOKING_VERTEX_EXT\0" - "GL_PROXY_COLOR_TABLE\0" - "GL_PROXY_HISTOGRAM\0" - "GL_PROXY_HISTOGRAM_EXT\0" - "GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE\0" - "GL_PROXY_POST_CONVOLUTION_COLOR_TABLE\0" - "GL_PROXY_TEXTURE_1D\0" - "GL_PROXY_TEXTURE_1D_ARRAY\0" - "GL_PROXY_TEXTURE_1D_ARRAY_EXT\0" - "GL_PROXY_TEXTURE_1D_EXT\0" - "GL_PROXY_TEXTURE_2D\0" - "GL_PROXY_TEXTURE_2D_ARRAY\0" - "GL_PROXY_TEXTURE_2D_ARRAY_EXT\0" - "GL_PROXY_TEXTURE_2D_EXT\0" - "GL_PROXY_TEXTURE_3D\0" - "GL_PROXY_TEXTURE_COLOR_TABLE_SGI\0" - "GL_PROXY_TEXTURE_CUBE_MAP\0" - "GL_PROXY_TEXTURE_CUBE_MAP_ARB\0" - "GL_PROXY_TEXTURE_RECTANGLE\0" - "GL_PROXY_TEXTURE_RECTANGLE_ARB\0" - "GL_PROXY_TEXTURE_RECTANGLE_NV\0" - "GL_PURGEABLE_APPLE\0" - "GL_Q\0" - "GL_QUADRATIC_ATTENUATION\0" - "GL_QUADS\0" - "GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION\0" - "GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT\0" - "GL_QUAD_MESH_SUN\0" - "GL_QUAD_STRIP\0" - "GL_QUERY_BY_REGION_NO_WAIT\0" - "GL_QUERY_BY_REGION_NO_WAIT_NV\0" - "GL_QUERY_BY_REGION_WAIT\0" - "GL_QUERY_BY_REGION_WAIT_NV\0" - "GL_QUERY_COUNTER_BITS\0" - "GL_QUERY_COUNTER_BITS_ARB\0" - "GL_QUERY_NO_WAIT\0" - "GL_QUERY_NO_WAIT_NV\0" - "GL_QUERY_RESULT\0" - "GL_QUERY_RESULT_ARB\0" - "GL_QUERY_RESULT_AVAILABLE\0" - "GL_QUERY_RESULT_AVAILABLE_ARB\0" - "GL_QUERY_WAIT\0" - "GL_QUERY_WAIT_NV\0" - "GL_R\0" - "GL_R11F_G11F_B10F\0" - "GL_R16_SNORM\0" - "GL_R3_G3_B2\0" - "GL_R8_SNORM\0" - "GL_RASTERIZER_DISCARD\0" - "GL_RASTERIZER_DISCARD_EXT\0" - "GL_RASTER_POSITION_UNCLIPPED_IBM\0" - "GL_READ_BUFFER\0" - "GL_READ_FRAMEBUFFER\0" - "GL_READ_FRAMEBUFFER_BINDING\0" - "GL_READ_FRAMEBUFFER_BINDING_EXT\0" - "GL_READ_FRAMEBUFFER_EXT\0" - "GL_READ_ONLY\0" - "GL_READ_ONLY_ARB\0" - "GL_READ_WRITE\0" - "GL_READ_WRITE_ARB\0" - "GL_RED\0" - "GL_REDUCE\0" - "GL_REDUCE_EXT\0" - "GL_RED_BIAS\0" - "GL_RED_BITS\0" - "GL_RED_INTEGER\0" - "GL_RED_INTEGER_EXT\0" - "GL_RED_SCALE\0" - "GL_RED_SNORM\0" - "GL_REFLECTION_MAP\0" - "GL_REFLECTION_MAP_ARB\0" - "GL_REFLECTION_MAP_NV\0" - "GL_REFLECTION_MAP_OES\0" - "GL_RELEASED_APPLE\0" - "GL_RENDER\0" - "GL_RENDERBUFFER\0" - "GL_RENDERBUFFER_ALPHA_SIZE\0" - "GL_RENDERBUFFER_ALPHA_SIZE_OES\0" - "GL_RENDERBUFFER_BINDING\0" - "GL_RENDERBUFFER_BINDING_EXT\0" - "GL_RENDERBUFFER_BINDING_OES\0" - "GL_RENDERBUFFER_BLUE_SIZE\0" - "GL_RENDERBUFFER_BLUE_SIZE_OES\0" - "GL_RENDERBUFFER_DEPTH_SIZE\0" - "GL_RENDERBUFFER_DEPTH_SIZE_OES\0" - "GL_RENDERBUFFER_EXT\0" - "GL_RENDERBUFFER_GREEN_SIZE\0" - "GL_RENDERBUFFER_GREEN_SIZE_OES\0" - "GL_RENDERBUFFER_HEIGHT\0" - "GL_RENDERBUFFER_HEIGHT_EXT\0" - "GL_RENDERBUFFER_HEIGHT_OES\0" - "GL_RENDERBUFFER_INTERNAL_FORMAT\0" - "GL_RENDERBUFFER_INTERNAL_FORMAT_EXT\0" - "GL_RENDERBUFFER_INTERNAL_FORMAT_OES\0" - "GL_RENDERBUFFER_OES\0" - "GL_RENDERBUFFER_RED_SIZE\0" - "GL_RENDERBUFFER_RED_SIZE_OES\0" - "GL_RENDERBUFFER_SAMPLES\0" - "GL_RENDERBUFFER_SAMPLES_EXT\0" - "GL_RENDERBUFFER_STENCIL_SIZE\0" - "GL_RENDERBUFFER_STENCIL_SIZE_OES\0" - "GL_RENDERBUFFER_WIDTH\0" - "GL_RENDERBUFFER_WIDTH_EXT\0" - "GL_RENDERBUFFER_WIDTH_OES\0" - "GL_RENDERER\0" - "GL_RENDER_MODE\0" - "GL_REPEAT\0" - "GL_REPLACE\0" - "GL_REPLACE_EXT\0" - "GL_REPLICATE_BORDER_HP\0" - "GL_RESCALE_NORMAL\0" - "GL_RESCALE_NORMAL_EXT\0" - "GL_RESET_NOTIFICATION_STRATEGY_ARB\0" - "GL_RETAINED_APPLE\0" - "GL_RETURN\0" - "GL_RG16_SNORM\0" - "GL_RG8_SNORM\0" - "GL_RGB\0" - "GL_RGB10\0" - "GL_RGB10_A2\0" - "GL_RGB10_A2_EXT\0" - "GL_RGB10_EXT\0" - "GL_RGB12\0" - "GL_RGB12_EXT\0" - "GL_RGB16\0" - "GL_RGB16F\0" - "GL_RGB16I\0" - "GL_RGB16I_EXT\0" - "GL_RGB16UI\0" - "GL_RGB16UI_EXT\0" - "GL_RGB16_EXT\0" - "GL_RGB16_SNORM\0" - "GL_RGB2_EXT\0" - "GL_RGB32F\0" - "GL_RGB32I\0" - "GL_RGB32I_EXT\0" - "GL_RGB32UI\0" - "GL_RGB32UI_EXT\0" - "GL_RGB4\0" - "GL_RGB4_EXT\0" - "GL_RGB4_S3TC\0" - "GL_RGB5\0" - "GL_RGB565\0" - "GL_RGB565_OES\0" - "GL_RGB5_A1\0" - "GL_RGB5_A1_EXT\0" - "GL_RGB5_A1_OES\0" - "GL_RGB5_EXT\0" - "GL_RGB8\0" - "GL_RGB8I\0" - "GL_RGB8I_EXT\0" - "GL_RGB8UI\0" - "GL_RGB8UI_EXT\0" - "GL_RGB8_EXT\0" - "GL_RGB8_OES\0" - "GL_RGB8_SNORM\0" - "GL_RGB9_E5\0" - "GL_RGBA\0" - "GL_RGBA12\0" - "GL_RGBA12_EXT\0" - "GL_RGBA16\0" - "GL_RGBA16F\0" - "GL_RGBA16I\0" - "GL_RGBA16I_EXT\0" - "GL_RGBA16UI\0" - "GL_RGBA16UI_EXT\0" - "GL_RGBA16_EXT\0" - "GL_RGBA16_SNORM\0" - "GL_RGBA2\0" - "GL_RGBA2_EXT\0" - "GL_RGBA32F\0" - "GL_RGBA32I\0" - "GL_RGBA32I_EXT\0" - "GL_RGBA32UI\0" - "GL_RGBA32UI_EXT\0" - "GL_RGBA4\0" - "GL_RGBA4_DXT5_S3TC\0" - "GL_RGBA4_EXT\0" - "GL_RGBA4_OES\0" - "GL_RGBA4_S3TC\0" - "GL_RGBA8\0" - "GL_RGBA8I\0" - "GL_RGBA8I_EXT\0" - "GL_RGBA8UI\0" - "GL_RGBA8UI_EXT\0" - "GL_RGBA8_EXT\0" - "GL_RGBA8_OES\0" - "GL_RGBA8_SNORM\0" - "GL_RGBA_DXT5_S3TC\0" - "GL_RGBA_FLOAT_MODE_ARB\0" - "GL_RGBA_INTEGER\0" - "GL_RGBA_INTEGER_EXT\0" - "GL_RGBA_INTEGER_MODE_EXT\0" - "GL_RGBA_MODE\0" - "GL_RGBA_S3TC\0" - "GL_RGBA_SNORM\0" - "GL_RGB_INTEGER\0" - "GL_RGB_INTEGER_EXT\0" - "GL_RGB_S3TC\0" - "GL_RGB_SCALE\0" - "GL_RGB_SCALE_ARB\0" - "GL_RGB_SCALE_EXT\0" - "GL_RGB_SNORM\0" - "GL_RG_SNORM\0" - "GL_RIGHT\0" - "GL_S\0" - "GL_SAMPLER_1D\0" - "GL_SAMPLER_1D_ARRAY\0" - "GL_SAMPLER_1D_ARRAY_EXT\0" - "GL_SAMPLER_1D_ARRAY_SHADOW\0" - "GL_SAMPLER_1D_ARRAY_SHADOW_EXT\0" - "GL_SAMPLER_1D_SHADOW\0" - "GL_SAMPLER_2D\0" - "GL_SAMPLER_2D_ARRAY\0" - "GL_SAMPLER_2D_ARRAY_EXT\0" - "GL_SAMPLER_2D_ARRAY_SHADOW\0" - "GL_SAMPLER_2D_ARRAY_SHADOW_EXT\0" - "GL_SAMPLER_2D_RECT\0" - "GL_SAMPLER_2D_RECT_SHADOW\0" - "GL_SAMPLER_2D_SHADOW\0" - "GL_SAMPLER_3D\0" - "GL_SAMPLER_3D_OES\0" - "GL_SAMPLER_BINDING\0" - "GL_SAMPLER_BUFFER\0" - "GL_SAMPLER_BUFFER_EXT\0" - "GL_SAMPLER_CUBE\0" - "GL_SAMPLER_CUBE_SHADOW\0" - "GL_SAMPLER_CUBE_SHADOW_EXT\0" - "GL_SAMPLES\0" - "GL_SAMPLES_3DFX\0" - "GL_SAMPLES_ARB\0" - "GL_SAMPLES_PASSED\0" - "GL_SAMPLES_PASSED_ARB\0" - "GL_SAMPLE_ALPHA_TO_COVERAGE\0" - "GL_SAMPLE_ALPHA_TO_COVERAGE_ARB\0" - "GL_SAMPLE_ALPHA_TO_ONE\0" - "GL_SAMPLE_ALPHA_TO_ONE_ARB\0" - "GL_SAMPLE_BUFFERS\0" - "GL_SAMPLE_BUFFERS_3DFX\0" - "GL_SAMPLE_BUFFERS_ARB\0" - "GL_SAMPLE_COVERAGE\0" - "GL_SAMPLE_COVERAGE_ARB\0" - "GL_SAMPLE_COVERAGE_INVERT\0" - "GL_SAMPLE_COVERAGE_INVERT_ARB\0" - "GL_SAMPLE_COVERAGE_VALUE\0" - "GL_SAMPLE_COVERAGE_VALUE_ARB\0" - "GL_SCISSOR_BIT\0" - "GL_SCISSOR_BOX\0" - "GL_SCISSOR_TEST\0" - "GL_SECONDARY_COLOR_ARRAY\0" - "GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING\0" - "GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB\0" - "GL_SECONDARY_COLOR_ARRAY_POINTER\0" - "GL_SECONDARY_COLOR_ARRAY_SIZE\0" - "GL_SECONDARY_COLOR_ARRAY_STRIDE\0" - "GL_SECONDARY_COLOR_ARRAY_TYPE\0" - "GL_SELECT\0" - "GL_SELECTION_BUFFER_POINTER\0" - "GL_SELECTION_BUFFER_SIZE\0" - "GL_SEPARABLE_2D\0" - "GL_SEPARATE_ATTRIBS\0" - "GL_SEPARATE_ATTRIBS_EXT\0" - "GL_SEPARATE_SPECULAR_COLOR\0" - "GL_SEPARATE_SPECULAR_COLOR_EXT\0" - "GL_SET\0" - "GL_SHADER_BINARY_FORMATS\0" - "GL_SHADER_COMPILER\0" - "GL_SHADER_OBJECT_ARB\0" - "GL_SHADER_SOURCE_LENGTH\0" - "GL_SHADER_TYPE\0" - "GL_SHADE_MODEL\0" - "GL_SHADING_LANGUAGE_VERSION\0" - "GL_SHADOW_AMBIENT_SGIX\0" - "GL_SHARED_TEXTURE_PALETTE_EXT\0" - "GL_SHININESS\0" - "GL_SHORT\0" - "GL_SIGNALED\0" - "GL_SIGNED_NORMALIZED\0" - "GL_SINGLE_COLOR\0" - "GL_SINGLE_COLOR_EXT\0" - "GL_SLICE_ACCUM_SUN\0" - "GL_SLUMINANCE\0" - "GL_SLUMINANCE8\0" - "GL_SLUMINANCE8_ALPHA8\0" - "GL_SLUMINANCE_ALPHA\0" - "GL_SMOOTH\0" - "GL_SMOOTH_LINE_WIDTH_GRANULARITY\0" - "GL_SMOOTH_LINE_WIDTH_RANGE\0" - "GL_SMOOTH_POINT_SIZE_GRANULARITY\0" - "GL_SMOOTH_POINT_SIZE_RANGE\0" - "GL_SOURCE0_ALPHA\0" - "GL_SOURCE0_ALPHA_ARB\0" - "GL_SOURCE0_ALPHA_EXT\0" - "GL_SOURCE0_RGB\0" - "GL_SOURCE0_RGB_ARB\0" - "GL_SOURCE0_RGB_EXT\0" - "GL_SOURCE1_ALPHA\0" - "GL_SOURCE1_ALPHA_ARB\0" - "GL_SOURCE1_ALPHA_EXT\0" - "GL_SOURCE1_RGB\0" - "GL_SOURCE1_RGB_ARB\0" - "GL_SOURCE1_RGB_EXT\0" - "GL_SOURCE2_ALPHA\0" - "GL_SOURCE2_ALPHA_ARB\0" - "GL_SOURCE2_ALPHA_EXT\0" - "GL_SOURCE2_RGB\0" - "GL_SOURCE2_RGB_ARB\0" - "GL_SOURCE2_RGB_EXT\0" - "GL_SOURCE3_ALPHA_NV\0" - "GL_SOURCE3_RGB_NV\0" - "GL_SPECULAR\0" - "GL_SPHERE_MAP\0" - "GL_SPOT_CUTOFF\0" - "GL_SPOT_DIRECTION\0" - "GL_SPOT_EXPONENT\0" - "GL_SRC0_ALPHA\0" - "GL_SRC0_RGB\0" - "GL_SRC1_ALPHA\0" - "GL_SRC1_RGB\0" - "GL_SRC2_ALPHA\0" - "GL_SRC2_RGB\0" - "GL_SRC_ALPHA\0" - "GL_SRC_ALPHA_SATURATE\0" - "GL_SRC_COLOR\0" - "GL_SRGB\0" - "GL_SRGB8\0" - "GL_SRGB8_ALPHA8\0" - "GL_SRGB_ALPHA\0" - "GL_STACK_OVERFLOW\0" - "GL_STACK_UNDERFLOW\0" - "GL_STATIC_COPY\0" - "GL_STATIC_COPY_ARB\0" - "GL_STATIC_DRAW\0" - "GL_STATIC_DRAW_ARB\0" - "GL_STATIC_READ\0" - "GL_STATIC_READ_ARB\0" - "GL_STENCIL\0" - "GL_STENCIL_ATTACHMENT\0" - "GL_STENCIL_ATTACHMENT_EXT\0" - "GL_STENCIL_ATTACHMENT_OES\0" - "GL_STENCIL_BACK_FAIL\0" - "GL_STENCIL_BACK_FAIL_ATI\0" - "GL_STENCIL_BACK_FUNC\0" - "GL_STENCIL_BACK_FUNC_ATI\0" - "GL_STENCIL_BACK_PASS_DEPTH_FAIL\0" - "GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI\0" - "GL_STENCIL_BACK_PASS_DEPTH_PASS\0" - "GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI\0" - "GL_STENCIL_BACK_REF\0" - "GL_STENCIL_BACK_VALUE_MASK\0" - "GL_STENCIL_BACK_WRITEMASK\0" - "GL_STENCIL_BITS\0" - "GL_STENCIL_BUFFER\0" - "GL_STENCIL_BUFFER_BIT\0" - "GL_STENCIL_CLEAR_VALUE\0" - "GL_STENCIL_FAIL\0" - "GL_STENCIL_FUNC\0" - "GL_STENCIL_INDEX\0" - "GL_STENCIL_INDEX1\0" - "GL_STENCIL_INDEX16\0" - "GL_STENCIL_INDEX16_EXT\0" - "GL_STENCIL_INDEX1_EXT\0" - "GL_STENCIL_INDEX1_OES\0" - "GL_STENCIL_INDEX4\0" - "GL_STENCIL_INDEX4_EXT\0" - "GL_STENCIL_INDEX4_OES\0" - "GL_STENCIL_INDEX8\0" - "GL_STENCIL_INDEX8_EXT\0" - "GL_STENCIL_INDEX8_OES\0" - "GL_STENCIL_INDEX_EXT\0" - "GL_STENCIL_PASS_DEPTH_FAIL\0" - "GL_STENCIL_PASS_DEPTH_PASS\0" - "GL_STENCIL_REF\0" - "GL_STENCIL_TEST\0" - "GL_STENCIL_TEST_TWO_SIDE_EXT\0" - "GL_STENCIL_VALUE_MASK\0" - "GL_STENCIL_WRITEMASK\0" - "GL_STEREO\0" - "GL_STORAGE_CACHED_APPLE\0" - "GL_STORAGE_PRIVATE_APPLE\0" - "GL_STORAGE_SHARED_APPLE\0" - "GL_STREAM_COPY\0" - "GL_STREAM_COPY_ARB\0" - "GL_STREAM_DRAW\0" - "GL_STREAM_DRAW_ARB\0" - "GL_STREAM_READ\0" - "GL_STREAM_READ_ARB\0" - "GL_SUBPIXEL_BITS\0" - "GL_SUBTRACT\0" - "GL_SUBTRACT_ARB\0" - "GL_SYNC_CONDITION\0" - "GL_SYNC_FENCE\0" - "GL_SYNC_FLAGS\0" - "GL_SYNC_FLUSH_COMMANDS_BIT\0" - "GL_SYNC_GPU_COMMANDS_COMPLETE\0" - "GL_SYNC_STATUS\0" - "GL_T\0" - "GL_T2F_C3F_V3F\0" - "GL_T2F_C4F_N3F_V3F\0" - "GL_T2F_C4UB_V3F\0" - "GL_T2F_N3F_V3F\0" - "GL_T2F_V3F\0" - "GL_T4F_C4F_N3F_V4F\0" - "GL_T4F_V4F\0" - "GL_TABLE_TOO_LARGE_EXT\0" - "GL_TEXTURE\0" - "GL_TEXTURE0\0" - "GL_TEXTURE0_ARB\0" - "GL_TEXTURE1\0" - "GL_TEXTURE10\0" - "GL_TEXTURE10_ARB\0" - "GL_TEXTURE11\0" - "GL_TEXTURE11_ARB\0" - "GL_TEXTURE12\0" - "GL_TEXTURE12_ARB\0" - "GL_TEXTURE13\0" - "GL_TEXTURE13_ARB\0" - "GL_TEXTURE14\0" - "GL_TEXTURE14_ARB\0" - "GL_TEXTURE15\0" - "GL_TEXTURE15_ARB\0" - "GL_TEXTURE16\0" - "GL_TEXTURE16_ARB\0" - "GL_TEXTURE17\0" - "GL_TEXTURE17_ARB\0" - "GL_TEXTURE18\0" - "GL_TEXTURE18_ARB\0" - "GL_TEXTURE19\0" - "GL_TEXTURE19_ARB\0" - "GL_TEXTURE1_ARB\0" - "GL_TEXTURE2\0" - "GL_TEXTURE20\0" - "GL_TEXTURE20_ARB\0" - "GL_TEXTURE21\0" - "GL_TEXTURE21_ARB\0" - "GL_TEXTURE22\0" - "GL_TEXTURE22_ARB\0" - "GL_TEXTURE23\0" - "GL_TEXTURE23_ARB\0" - "GL_TEXTURE24\0" - "GL_TEXTURE24_ARB\0" - "GL_TEXTURE25\0" - "GL_TEXTURE25_ARB\0" - "GL_TEXTURE26\0" - "GL_TEXTURE26_ARB\0" - "GL_TEXTURE27\0" - "GL_TEXTURE27_ARB\0" - "GL_TEXTURE28\0" - "GL_TEXTURE28_ARB\0" - "GL_TEXTURE29\0" - "GL_TEXTURE29_ARB\0" - "GL_TEXTURE2_ARB\0" - "GL_TEXTURE3\0" - "GL_TEXTURE30\0" - "GL_TEXTURE30_ARB\0" - "GL_TEXTURE31\0" - "GL_TEXTURE31_ARB\0" - "GL_TEXTURE3_ARB\0" - "GL_TEXTURE4\0" - "GL_TEXTURE4_ARB\0" - "GL_TEXTURE5\0" - "GL_TEXTURE5_ARB\0" - "GL_TEXTURE6\0" - "GL_TEXTURE6_ARB\0" - "GL_TEXTURE7\0" - "GL_TEXTURE7_ARB\0" - "GL_TEXTURE8\0" - "GL_TEXTURE8_ARB\0" - "GL_TEXTURE9\0" - "GL_TEXTURE9_ARB\0" - "GL_TEXTURE_1D\0" - "GL_TEXTURE_1D_ARRAY\0" - "GL_TEXTURE_1D_ARRAY_EXT\0" - "GL_TEXTURE_2D\0" - "GL_TEXTURE_2D_ARRAY\0" - "GL_TEXTURE_2D_ARRAY_EXT\0" - "GL_TEXTURE_3D\0" - "GL_TEXTURE_3D_OES\0" - "GL_TEXTURE_ALPHA_SIZE\0" - "GL_TEXTURE_ALPHA_SIZE_EXT\0" - "GL_TEXTURE_BASE_LEVEL\0" - "GL_TEXTURE_BINDING_1D\0" - "GL_TEXTURE_BINDING_1D_ARRAY\0" - "GL_TEXTURE_BINDING_1D_ARRAY_EXT\0" - "GL_TEXTURE_BINDING_2D\0" - "GL_TEXTURE_BINDING_2D_ARRAY\0" - "GL_TEXTURE_BINDING_2D_ARRAY_EXT\0" - "GL_TEXTURE_BINDING_3D\0" - "GL_TEXTURE_BINDING_3D_OES\0" - "GL_TEXTURE_BINDING_BUFFER\0" - "GL_TEXTURE_BINDING_BUFFER_ARB\0" - "GL_TEXTURE_BINDING_CUBE_MAP\0" - "GL_TEXTURE_BINDING_CUBE_MAP_ARB\0" - "GL_TEXTURE_BINDING_CUBE_MAP_OES\0" - "GL_TEXTURE_BINDING_RECTANGLE\0" - "GL_TEXTURE_BINDING_RECTANGLE_ARB\0" - "GL_TEXTURE_BINDING_RECTANGLE_NV\0" - "GL_TEXTURE_BIT\0" - "GL_TEXTURE_BLUE_SIZE\0" - "GL_TEXTURE_BLUE_SIZE_EXT\0" - "GL_TEXTURE_BORDER\0" - "GL_TEXTURE_BORDER_COLOR\0" - "GL_TEXTURE_BUFFER\0" - "GL_TEXTURE_BUFFER_ARB\0" - "GL_TEXTURE_BUFFER_DATA_STORE_BINDING\0" - "GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB\0" - "GL_TEXTURE_BUFFER_FORMAT\0" - "GL_TEXTURE_BUFFER_FORMAT_ARB\0" - "GL_TEXTURE_CLIPMAP_CENTER_SGIX\0" - "GL_TEXTURE_CLIPMAP_DEPTH_SGIX\0" - "GL_TEXTURE_CLIPMAP_FRAME_SGIX\0" - "GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX\0" - "GL_TEXTURE_CLIPMAP_OFFSET_SGIX\0" - "GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX\0" - "GL_TEXTURE_COLOR_TABLE_SGI\0" - "GL_TEXTURE_COLOR_WRITEMASK_SGIS\0" - "GL_TEXTURE_COMPARE_FAIL_VALUE_ARB\0" - "GL_TEXTURE_COMPARE_FUNC\0" - "GL_TEXTURE_COMPARE_FUNC_ARB\0" - "GL_TEXTURE_COMPARE_MODE\0" - "GL_TEXTURE_COMPARE_MODE_ARB\0" - "GL_TEXTURE_COMPARE_OPERATOR_SGIX\0" - "GL_TEXTURE_COMPARE_SGIX\0" - "GL_TEXTURE_COMPONENTS\0" - "GL_TEXTURE_COMPRESSED\0" - "GL_TEXTURE_COMPRESSED_ARB\0" - "GL_TEXTURE_COMPRESSED_FORMATS_ARB\0" - "GL_TEXTURE_COMPRESSED_IMAGE_SIZE\0" - "GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB\0" - "GL_TEXTURE_COMPRESSION_HINT\0" - "GL_TEXTURE_COMPRESSION_HINT_ARB\0" - "GL_TEXTURE_COORD_ARRAY\0" - "GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING\0" - "GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB\0" - "GL_TEXTURE_COORD_ARRAY_POINTER\0" - "GL_TEXTURE_COORD_ARRAY_SIZE\0" - "GL_TEXTURE_COORD_ARRAY_STRIDE\0" - "GL_TEXTURE_COORD_ARRAY_TYPE\0" - "GL_TEXTURE_CROP_RECT_OES\0" - "GL_TEXTURE_CUBE_MAP\0" - "GL_TEXTURE_CUBE_MAP_ARB\0" - "GL_TEXTURE_CUBE_MAP_NEGATIVE_X\0" - "GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB\0" - "GL_TEXTURE_CUBE_MAP_NEGATIVE_X_OES\0" - "GL_TEXTURE_CUBE_MAP_NEGATIVE_Y\0" - "GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB\0" - "GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_OES\0" - "GL_TEXTURE_CUBE_MAP_NEGATIVE_Z\0" - "GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB\0" - "GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_OES\0" - "GL_TEXTURE_CUBE_MAP_OES\0" - "GL_TEXTURE_CUBE_MAP_POSITIVE_X\0" - "GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB\0" - "GL_TEXTURE_CUBE_MAP_POSITIVE_X_OES\0" - "GL_TEXTURE_CUBE_MAP_POSITIVE_Y\0" - "GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB\0" - "GL_TEXTURE_CUBE_MAP_POSITIVE_Y_OES\0" - "GL_TEXTURE_CUBE_MAP_POSITIVE_Z\0" - "GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB\0" - "GL_TEXTURE_CUBE_MAP_POSITIVE_Z_OES\0" - "GL_TEXTURE_CUBE_MAP_SEAMLESS\0" - "GL_TEXTURE_DEPTH\0" - "GL_TEXTURE_DEPTH_SIZE\0" - "GL_TEXTURE_DEPTH_SIZE_ARB\0" - "GL_TEXTURE_ENV\0" - "GL_TEXTURE_ENV_COLOR\0" - "GL_TEXTURE_ENV_MODE\0" - "GL_TEXTURE_FILTER_CONTROL\0" - "GL_TEXTURE_FILTER_CONTROL_EXT\0" - "GL_TEXTURE_GEN_MODE\0" - "GL_TEXTURE_GEN_MODE_OES\0" - "GL_TEXTURE_GEN_Q\0" - "GL_TEXTURE_GEN_R\0" - "GL_TEXTURE_GEN_S\0" - "GL_TEXTURE_GEN_STR_OES\0" - "GL_TEXTURE_GEN_T\0" - "GL_TEXTURE_GEQUAL_R_SGIX\0" - "GL_TEXTURE_GREEN_SIZE\0" - "GL_TEXTURE_GREEN_SIZE_EXT\0" - "GL_TEXTURE_HEIGHT\0" - "GL_TEXTURE_INDEX_SIZE_EXT\0" - "GL_TEXTURE_INTENSITY_SIZE\0" - "GL_TEXTURE_INTENSITY_SIZE_EXT\0" - "GL_TEXTURE_INTERNAL_FORMAT\0" - "GL_TEXTURE_LEQUAL_R_SGIX\0" - "GL_TEXTURE_LOD_BIAS\0" - "GL_TEXTURE_LOD_BIAS_EXT\0" - "GL_TEXTURE_LOD_BIAS_R_SGIX\0" - "GL_TEXTURE_LOD_BIAS_S_SGIX\0" - "GL_TEXTURE_LOD_BIAS_T_SGIX\0" - "GL_TEXTURE_LUMINANCE_SIZE\0" - "GL_TEXTURE_LUMINANCE_SIZE_EXT\0" - "GL_TEXTURE_MAG_FILTER\0" - "GL_TEXTURE_MATRIX\0" - "GL_TEXTURE_MATRIX_FLOAT_AS_INT_BITS_OES\0" - "GL_TEXTURE_MAX_ANISOTROPY_EXT\0" - "GL_TEXTURE_MAX_CLAMP_R_SGIX\0" - "GL_TEXTURE_MAX_CLAMP_S_SGIX\0" - "GL_TEXTURE_MAX_CLAMP_T_SGIX\0" - "GL_TEXTURE_MAX_LEVEL\0" - "GL_TEXTURE_MAX_LOD\0" - "GL_TEXTURE_MIN_FILTER\0" - "GL_TEXTURE_MIN_LOD\0" - "GL_TEXTURE_PRIORITY\0" - "GL_TEXTURE_RANGE_LENGTH_APPLE\0" - "GL_TEXTURE_RANGE_POINTER_APPLE\0" - "GL_TEXTURE_RECTANGLE\0" - "GL_TEXTURE_RECTANGLE_ARB\0" - "GL_TEXTURE_RECTANGLE_NV\0" - "GL_TEXTURE_RED_SIZE\0" - "GL_TEXTURE_RED_SIZE_EXT\0" - "GL_TEXTURE_RESIDENT\0" - "GL_TEXTURE_SHARED_SIZE\0" - "GL_TEXTURE_STACK_DEPTH\0" - "GL_TEXTURE_STENCIL_SIZE\0" - "GL_TEXTURE_STENCIL_SIZE_EXT\0" - "GL_TEXTURE_STORAGE_HINT_APPLE\0" - "GL_TEXTURE_TOO_LARGE_EXT\0" - "GL_TEXTURE_UNSIGNED_REMAP_MODE_NV\0" - "GL_TEXTURE_WIDTH\0" - "GL_TEXTURE_WRAP_R\0" - "GL_TEXTURE_WRAP_R_OES\0" - "GL_TEXTURE_WRAP_S\0" - "GL_TEXTURE_WRAP_T\0" - "GL_TIMEOUT_EXPIRED\0" - "GL_TIME_ELAPSED_EXT\0" - "GL_TRACK_MATRIX_NV\0" - "GL_TRACK_MATRIX_TRANSFORM_NV\0" - "GL_TRANSFORM_BIT\0" - "GL_TRANSFORM_FEEDBACK\0" - "GL_TRANSFORM_FEEDBACK_BINDING\0" - "GL_TRANSFORM_FEEDBACK_BUFFER\0" - "GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE\0" - "GL_TRANSFORM_FEEDBACK_BUFFER_BINDING\0" - "GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_EXT\0" - "GL_TRANSFORM_FEEDBACK_BUFFER_EXT\0" - "GL_TRANSFORM_FEEDBACK_BUFFER_MODE\0" - "GL_TRANSFORM_FEEDBACK_BUFFER_MODE_EXT\0" - "GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED\0" - "GL_TRANSFORM_FEEDBACK_BUFFER_SIZE\0" - "GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_EXT\0" - "GL_TRANSFORM_FEEDBACK_BUFFER_START\0" - "GL_TRANSFORM_FEEDBACK_BUFFER_START_EXT\0" - "GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN\0" - "GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_EXT\0" - "GL_TRANSFORM_FEEDBACK_VARYINGS\0" - "GL_TRANSFORM_FEEDBACK_VARYINGS_EXT\0" - "GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH\0" - "GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH_EXT\0" - "GL_TRANSPOSE_COLOR_MATRIX\0" - "GL_TRANSPOSE_COLOR_MATRIX_ARB\0" - "GL_TRANSPOSE_CURRENT_MATRIX_ARB\0" - "GL_TRANSPOSE_MODELVIEW_MATRIX\0" - "GL_TRANSPOSE_MODELVIEW_MATRIX_ARB\0" - "GL_TRANSPOSE_NV\0" - "GL_TRANSPOSE_PROJECTION_MATRIX\0" - "GL_TRANSPOSE_PROJECTION_MATRIX_ARB\0" - "GL_TRANSPOSE_TEXTURE_MATRIX\0" - "GL_TRANSPOSE_TEXTURE_MATRIX_ARB\0" - "GL_TRIANGLES\0" - "GL_TRIANGLES_ADJACENCY\0" - "GL_TRIANGLES_ADJACENCY_ARB\0" - "GL_TRIANGLE_FAN\0" - "GL_TRIANGLE_MESH_SUN\0" - "GL_TRIANGLE_STRIP\0" - "GL_TRIANGLE_STRIP_ADJACENCY\0" - "GL_TRIANGLE_STRIP_ADJACENCY_ARB\0" - "GL_TRUE\0" - "GL_UNDEFINED_APPLE\0" - "GL_UNKNOWN_CONTEXT_RESET_ARB\0" - "GL_UNPACK_ALIGNMENT\0" - "GL_UNPACK_IMAGE_HEIGHT\0" - "GL_UNPACK_LSB_FIRST\0" - "GL_UNPACK_ROW_LENGTH\0" - "GL_UNPACK_SKIP_IMAGES\0" - "GL_UNPACK_SKIP_PIXELS\0" - "GL_UNPACK_SKIP_ROWS\0" - "GL_UNPACK_SWAP_BYTES\0" - "GL_UNSIGNALED\0" - "GL_UNSIGNED_BYTE\0" - "GL_UNSIGNED_BYTE_2_3_3_REV\0" - "GL_UNSIGNED_BYTE_3_3_2\0" - "GL_UNSIGNED_INT\0" - "GL_UNSIGNED_INT_10F_11F_11F_REV\0" - "GL_UNSIGNED_INT_10_10_10_2\0" - "GL_UNSIGNED_INT_10_10_10_2_OES\0" - "GL_UNSIGNED_INT_24_8\0" - "GL_UNSIGNED_INT_24_8_EXT\0" - "GL_UNSIGNED_INT_24_8_NV\0" - "GL_UNSIGNED_INT_24_8_OES\0" - "GL_UNSIGNED_INT_2_10_10_10_REV\0" - "GL_UNSIGNED_INT_2_10_10_10_REV_EXT\0" - "GL_UNSIGNED_INT_5_9_9_9_REV\0" - "GL_UNSIGNED_INT_8_8_8_8\0" - "GL_UNSIGNED_INT_8_8_8_8_REV\0" - "GL_UNSIGNED_INT_SAMPLER_1D\0" - "GL_UNSIGNED_INT_SAMPLER_1D_ARRAY\0" - "GL_UNSIGNED_INT_SAMPLER_1D_ARRAY_EXT\0" - "GL_UNSIGNED_INT_SAMPLER_1D_EXT\0" - "GL_UNSIGNED_INT_SAMPLER_2D\0" - "GL_UNSIGNED_INT_SAMPLER_2D_ARRAY\0" - "GL_UNSIGNED_INT_SAMPLER_2D_ARRAY_EXT\0" - "GL_UNSIGNED_INT_SAMPLER_2D_EXT\0" - "GL_UNSIGNED_INT_SAMPLER_2D_RECT\0" - "GL_UNSIGNED_INT_SAMPLER_2D_RECT_EXT\0" - "GL_UNSIGNED_INT_SAMPLER_3D\0" - "GL_UNSIGNED_INT_SAMPLER_3D_EXT\0" - "GL_UNSIGNED_INT_SAMPLER_BUFFER\0" - "GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT\0" - "GL_UNSIGNED_INT_SAMPLER_CUBE\0" - "GL_UNSIGNED_INT_SAMPLER_CUBE_EXT\0" - "GL_UNSIGNED_INT_VEC2\0" - "GL_UNSIGNED_INT_VEC2_EXT\0" - "GL_UNSIGNED_INT_VEC3\0" - "GL_UNSIGNED_INT_VEC3_EXT\0" - "GL_UNSIGNED_INT_VEC4\0" - "GL_UNSIGNED_INT_VEC4_EXT\0" - "GL_UNSIGNED_NORMALIZED\0" - "GL_UNSIGNED_SHORT\0" - "GL_UNSIGNED_SHORT_1_5_5_5_REV\0" - "GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT\0" - "GL_UNSIGNED_SHORT_4_4_4_4\0" - "GL_UNSIGNED_SHORT_4_4_4_4_REV\0" - "GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT\0" - "GL_UNSIGNED_SHORT_5_5_5_1\0" - "GL_UNSIGNED_SHORT_5_6_5\0" - "GL_UNSIGNED_SHORT_5_6_5_REV\0" - "GL_UNSIGNED_SHORT_8_8_APPLE\0" - "GL_UNSIGNED_SHORT_8_8_MESA\0" - "GL_UNSIGNED_SHORT_8_8_REV_APPLE\0" - "GL_UNSIGNED_SHORT_8_8_REV_MESA\0" - "GL_UPPER_LEFT\0" - "GL_V2F\0" - "GL_V3F\0" - "GL_VALIDATE_STATUS\0" - "GL_VENDOR\0" - "GL_VERSION\0" - "GL_VERTEX_ARRAY\0" - "GL_VERTEX_ARRAY_BINDING\0" - "GL_VERTEX_ARRAY_BINDING_APPLE\0" - "GL_VERTEX_ARRAY_BUFFER_BINDING\0" - "GL_VERTEX_ARRAY_BUFFER_BINDING_ARB\0" - "GL_VERTEX_ARRAY_POINTER\0" - "GL_VERTEX_ARRAY_SIZE\0" - "GL_VERTEX_ARRAY_STRIDE\0" - "GL_VERTEX_ARRAY_TYPE\0" - "GL_VERTEX_ATTRIB_ARRAY0_NV\0" - "GL_VERTEX_ATTRIB_ARRAY10_NV\0" - "GL_VERTEX_ATTRIB_ARRAY11_NV\0" - "GL_VERTEX_ATTRIB_ARRAY12_NV\0" - "GL_VERTEX_ATTRIB_ARRAY13_NV\0" - "GL_VERTEX_ATTRIB_ARRAY14_NV\0" - "GL_VERTEX_ATTRIB_ARRAY15_NV\0" - "GL_VERTEX_ATTRIB_ARRAY1_NV\0" - "GL_VERTEX_ATTRIB_ARRAY2_NV\0" - "GL_VERTEX_ATTRIB_ARRAY3_NV\0" - "GL_VERTEX_ATTRIB_ARRAY4_NV\0" - "GL_VERTEX_ATTRIB_ARRAY5_NV\0" - "GL_VERTEX_ATTRIB_ARRAY6_NV\0" - "GL_VERTEX_ATTRIB_ARRAY7_NV\0" - "GL_VERTEX_ATTRIB_ARRAY8_NV\0" - "GL_VERTEX_ATTRIB_ARRAY9_NV\0" - "GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING\0" - "GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB\0" - "GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB\0" - "GL_VERTEX_ATTRIB_ARRAY_ENABLED\0" - "GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB\0" - "GL_VERTEX_ATTRIB_ARRAY_INTEGER\0" - "GL_VERTEX_ATTRIB_ARRAY_INTEGER_EXT\0" - "GL_VERTEX_ATTRIB_ARRAY_NORMALIZED\0" - "GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB\0" - "GL_VERTEX_ATTRIB_ARRAY_POINTER\0" - "GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB\0" - "GL_VERTEX_ATTRIB_ARRAY_SIZE\0" - "GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB\0" - "GL_VERTEX_ATTRIB_ARRAY_STRIDE\0" - "GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB\0" - "GL_VERTEX_ATTRIB_ARRAY_TYPE\0" - "GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB\0" - "GL_VERTEX_BLEND_ARB\0" - "GL_VERTEX_PROGRAM_ARB\0" - "GL_VERTEX_PROGRAM_BINDING_NV\0" - "GL_VERTEX_PROGRAM_NV\0" - "GL_VERTEX_PROGRAM_POINT_SIZE\0" - "GL_VERTEX_PROGRAM_POINT_SIZE_ARB\0" - "GL_VERTEX_PROGRAM_POINT_SIZE_NV\0" - "GL_VERTEX_PROGRAM_TWO_SIDE\0" - "GL_VERTEX_PROGRAM_TWO_SIDE_ARB\0" - "GL_VERTEX_PROGRAM_TWO_SIDE_NV\0" - "GL_VERTEX_SHADER\0" - "GL_VERTEX_SHADER_ARB\0" - "GL_VERTEX_STATE_PROGRAM_NV\0" - "GL_VIEWPORT\0" - "GL_VIEWPORT_BIT\0" - "GL_VOLATILE_APPLE\0" - "GL_WAIT_FAILED\0" - "GL_WEIGHT_ARRAY_ARB\0" - "GL_WEIGHT_ARRAY_BUFFER_BINDING\0" - "GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB\0" - "GL_WEIGHT_ARRAY_BUFFER_BINDING_OES\0" - "GL_WEIGHT_ARRAY_OES\0" - "GL_WEIGHT_ARRAY_POINTER_ARB\0" - "GL_WEIGHT_ARRAY_POINTER_OES\0" - "GL_WEIGHT_ARRAY_SIZE_ARB\0" - "GL_WEIGHT_ARRAY_SIZE_OES\0" - "GL_WEIGHT_ARRAY_STRIDE_ARB\0" - "GL_WEIGHT_ARRAY_STRIDE_OES\0" - "GL_WEIGHT_ARRAY_TYPE_ARB\0" - "GL_WEIGHT_ARRAY_TYPE_OES\0" - "GL_WEIGHT_SUM_UNITY_ARB\0" - "GL_WRAP_BORDER_SUN\0" - "GL_WRITE_ONLY\0" - "GL_WRITE_ONLY_ARB\0" - "GL_WRITE_ONLY_OES\0" - "GL_XOR\0" - "GL_YCBCR_422_APPLE\0" - "GL_YCBCR_MESA\0" - "GL_ZERO\0" - "GL_ZOOM_X\0" - "GL_ZOOM_Y\0" - ; - -static const enum_elt all_enums[2318] = -{ - { 0, 0x00000600 }, /* GL_2D */ - { 6, 0x00001407 }, /* GL_2_BYTES */ - { 17, 0x00000601 }, /* GL_3D */ - { 23, 0x00000602 }, /* GL_3D_COLOR */ - { 35, 0x00000603 }, /* GL_3D_COLOR_TEXTURE */ - { 55, 0x00001408 }, /* GL_3_BYTES */ - { 66, 0x00000604 }, /* GL_4D_COLOR_TEXTURE */ - { 86, 0x00001409 }, /* GL_4_BYTES */ - { 97, 0x00000100 }, /* GL_ACCUM */ - { 106, 0x00000D5B }, /* GL_ACCUM_ALPHA_BITS */ - { 126, 0x00000D5A }, /* GL_ACCUM_BLUE_BITS */ - { 145, 0x00000200 }, /* GL_ACCUM_BUFFER_BIT */ - { 165, 0x00000B80 }, /* GL_ACCUM_CLEAR_VALUE */ - { 186, 0x00000D59 }, /* GL_ACCUM_GREEN_BITS */ - { 206, 0x00000D58 }, /* GL_ACCUM_RED_BITS */ - { 224, 0x00008B89 }, /* GL_ACTIVE_ATTRIBUTES */ - { 245, 0x00008B8A }, /* GL_ACTIVE_ATTRIBUTE_MAX_LENGTH */ - { 276, 0x00008B8D }, /* GL_ACTIVE_PROGRAM_EXT */ - { 298, 0x00008911 }, /* GL_ACTIVE_STENCIL_FACE_EXT */ - { 325, 0x000084E0 }, /* GL_ACTIVE_TEXTURE */ - { 343, 0x000084E0 }, /* GL_ACTIVE_TEXTURE_ARB */ - { 365, 0x00008B86 }, /* GL_ACTIVE_UNIFORMS */ - { 384, 0x00008B87 }, /* GL_ACTIVE_UNIFORM_MAX_LENGTH */ - { 413, 0x000086A5 }, /* GL_ACTIVE_VERTEX_UNITS_ARB */ - { 440, 0x00000104 }, /* GL_ADD */ - { 447, 0x00008574 }, /* GL_ADD_SIGNED */ - { 461, 0x00008574 }, /* GL_ADD_SIGNED_ARB */ - { 479, 0x00008574 }, /* GL_ADD_SIGNED_EXT */ - { 497, 0x0000846E }, /* GL_ALIASED_LINE_WIDTH_RANGE */ - { 525, 0x0000846D }, /* GL_ALIASED_POINT_SIZE_RANGE */ - { 553, 0x000FFFFF }, /* GL_ALL_ATTRIB_BITS */ - { 572, 0xFFFFFFFF }, /* GL_ALL_CLIENT_ATTRIB_BITS */ - { 598, 0x00001906 }, /* GL_ALPHA */ - { 607, 0x0000803D }, /* GL_ALPHA12 */ - { 618, 0x0000803D }, /* GL_ALPHA12_EXT */ - { 633, 0x0000803E }, /* GL_ALPHA16 */ - { 644, 0x00008D8A }, /* GL_ALPHA16I_EXT */ - { 660, 0x00008D78 }, /* GL_ALPHA16UI_EXT */ - { 677, 0x0000803E }, /* GL_ALPHA16_EXT */ - { 692, 0x00008D84 }, /* GL_ALPHA32I_EXT */ - { 708, 0x00008D72 }, /* GL_ALPHA32UI_EXT */ - { 725, 0x0000803B }, /* GL_ALPHA4 */ - { 735, 0x0000803B }, /* GL_ALPHA4_EXT */ - { 749, 0x0000803C }, /* GL_ALPHA8 */ - { 759, 0x00008D90 }, /* GL_ALPHA8I_EXT */ - { 774, 0x00008D7E }, /* GL_ALPHA8UI_EXT */ - { 790, 0x0000803C }, /* GL_ALPHA8_EXT */ - { 804, 0x00000D1D }, /* GL_ALPHA_BIAS */ - { 818, 0x00000D55 }, /* GL_ALPHA_BITS */ - { 832, 0x00008D97 }, /* GL_ALPHA_INTEGER_EXT */ - { 853, 0x00000D1C }, /* GL_ALPHA_SCALE */ - { 868, 0x00000BC0 }, /* GL_ALPHA_TEST */ - { 882, 0x00000BC1 }, /* GL_ALPHA_TEST_FUNC */ - { 901, 0x00000BC2 }, /* GL_ALPHA_TEST_REF */ - { 919, 0x0000911A }, /* GL_ALREADY_SIGNALED */ - { 939, 0x00000207 }, /* GL_ALWAYS */ - { 949, 0x00001200 }, /* GL_AMBIENT */ - { 960, 0x00001602 }, /* GL_AMBIENT_AND_DIFFUSE */ - { 983, 0x00001501 }, /* GL_AND */ - { 990, 0x00001504 }, /* GL_AND_INVERTED */ - { 1006, 0x00001502 }, /* GL_AND_REVERSE */ - { 1021, 0x00008892 }, /* GL_ARRAY_BUFFER */ - { 1037, 0x00008894 }, /* GL_ARRAY_BUFFER_BINDING */ - { 1061, 0x00008894 }, /* GL_ARRAY_BUFFER_BINDING_ARB */ - { 1089, 0x00008B85 }, /* GL_ATTACHED_SHADERS */ - { 1109, 0x00008645 }, /* GL_ATTRIB_ARRAY_POINTER_NV */ - { 1136, 0x00008623 }, /* GL_ATTRIB_ARRAY_SIZE_NV */ - { 1160, 0x00008624 }, /* GL_ATTRIB_ARRAY_STRIDE_NV */ - { 1186, 0x00008625 }, /* GL_ATTRIB_ARRAY_TYPE_NV */ - { 1210, 0x00000BB0 }, /* GL_ATTRIB_STACK_DEPTH */ - { 1232, 0x00000D80 }, /* GL_AUTO_NORMAL */ - { 1247, 0x00000409 }, /* GL_AUX0 */ - { 1255, 0x0000040A }, /* GL_AUX1 */ - { 1263, 0x0000040B }, /* GL_AUX2 */ - { 1271, 0x0000040C }, /* GL_AUX3 */ - { 1279, 0x00000C00 }, /* GL_AUX_BUFFERS */ - { 1294, 0x00000405 }, /* GL_BACK */ - { 1302, 0x00000402 }, /* GL_BACK_LEFT */ - { 1315, 0x00000403 }, /* GL_BACK_RIGHT */ - { 1329, 0x000080E0 }, /* GL_BGR */ - { 1336, 0x000080E1 }, /* GL_BGRA */ - { 1344, 0x000080E1 }, /* GL_BGRA_EXT */ - { 1356, 0x00008D9B }, /* GL_BGRA_INTEGER */ - { 1372, 0x00008D9B }, /* GL_BGRA_INTEGER_EXT */ - { 1392, 0x00008D9A }, /* GL_BGR_INTEGER */ - { 1407, 0x00008D9A }, /* GL_BGR_INTEGER_EXT */ - { 1426, 0x00001A00 }, /* GL_BITMAP */ - { 1436, 0x00000704 }, /* GL_BITMAP_TOKEN */ - { 1452, 0x00000BE2 }, /* GL_BLEND */ - { 1461, 0x00008005 }, /* GL_BLEND_COLOR */ - { 1476, 0x00008005 }, /* GL_BLEND_COLOR_EXT */ - { 1495, 0x00000BE0 }, /* GL_BLEND_DST */ - { 1508, 0x000080CA }, /* GL_BLEND_DST_ALPHA */ - { 1527, 0x000080CA }, /* GL_BLEND_DST_ALPHA_OES */ - { 1550, 0x000080C8 }, /* GL_BLEND_DST_RGB */ - { 1567, 0x000080C8 }, /* GL_BLEND_DST_RGB_OES */ - { 1588, 0x00008009 }, /* GL_BLEND_EQUATION */ - { 1606, 0x0000883D }, /* GL_BLEND_EQUATION_ALPHA */ - { 1630, 0x0000883D }, /* GL_BLEND_EQUATION_ALPHA_EXT */ - { 1658, 0x0000883D }, /* GL_BLEND_EQUATION_ALPHA_OES */ - { 1686, 0x00008009 }, /* GL_BLEND_EQUATION_EXT */ - { 1708, 0x00008009 }, /* GL_BLEND_EQUATION_OES */ - { 1730, 0x00008009 }, /* GL_BLEND_EQUATION_RGB */ - { 1752, 0x00008009 }, /* GL_BLEND_EQUATION_RGB_EXT */ - { 1778, 0x00008009 }, /* GL_BLEND_EQUATION_RGB_OES */ - { 1804, 0x00000BE1 }, /* GL_BLEND_SRC */ - { 1817, 0x000080CB }, /* GL_BLEND_SRC_ALPHA */ - { 1836, 0x000080CB }, /* GL_BLEND_SRC_ALPHA_OES */ - { 1859, 0x000080C9 }, /* GL_BLEND_SRC_RGB */ - { 1876, 0x000080C9 }, /* GL_BLEND_SRC_RGB_OES */ - { 1897, 0x00001905 }, /* GL_BLUE */ - { 1905, 0x00000D1B }, /* GL_BLUE_BIAS */ - { 1918, 0x00000D54 }, /* GL_BLUE_BITS */ - { 1931, 0x00008D96 }, /* GL_BLUE_INTEGER */ - { 1947, 0x00008D96 }, /* GL_BLUE_INTEGER_EXT */ - { 1967, 0x00000D1A }, /* GL_BLUE_SCALE */ - { 1981, 0x00008B56 }, /* GL_BOOL */ - { 1989, 0x00008B56 }, /* GL_BOOL_ARB */ - { 2001, 0x00008B57 }, /* GL_BOOL_VEC2 */ - { 2014, 0x00008B57 }, /* GL_BOOL_VEC2_ARB */ - { 2031, 0x00008B58 }, /* GL_BOOL_VEC3 */ - { 2044, 0x00008B58 }, /* GL_BOOL_VEC3_ARB */ - { 2061, 0x00008B59 }, /* GL_BOOL_VEC4 */ - { 2074, 0x00008B59 }, /* GL_BOOL_VEC4_ARB */ - { 2091, 0x000088BB }, /* GL_BUFFER_ACCESS */ - { 2108, 0x000088BB }, /* GL_BUFFER_ACCESS_ARB */ - { 2129, 0x0000911F }, /* GL_BUFFER_ACCESS_FLAGS */ - { 2152, 0x000088BB }, /* GL_BUFFER_ACCESS_OES */ - { 2173, 0x00008A13 }, /* GL_BUFFER_FLUSHING_UNMAP_APPLE */ - { 2204, 0x000088BC }, /* GL_BUFFER_MAPPED */ - { 2221, 0x000088BC }, /* GL_BUFFER_MAPPED_ARB */ - { 2242, 0x000088BC }, /* GL_BUFFER_MAPPED_OES */ - { 2263, 0x00009120 }, /* GL_BUFFER_MAP_LENGTH */ - { 2284, 0x00009121 }, /* GL_BUFFER_MAP_OFFSET */ - { 2305, 0x000088BD }, /* GL_BUFFER_MAP_POINTER */ - { 2327, 0x000088BD }, /* GL_BUFFER_MAP_POINTER_ARB */ - { 2353, 0x000088BD }, /* GL_BUFFER_MAP_POINTER_OES */ - { 2379, 0x000085B3 }, /* GL_BUFFER_OBJECT_APPLE */ - { 2402, 0x00008A12 }, /* GL_BUFFER_SERIALIZED_MODIFY_APPLE */ - { 2436, 0x00008764 }, /* GL_BUFFER_SIZE */ - { 2451, 0x00008764 }, /* GL_BUFFER_SIZE_ARB */ - { 2470, 0x00008765 }, /* GL_BUFFER_USAGE */ - { 2486, 0x00008765 }, /* GL_BUFFER_USAGE_ARB */ - { 2506, 0x0000877B }, /* GL_BUMP_ENVMAP_ATI */ - { 2525, 0x00008777 }, /* GL_BUMP_NUM_TEX_UNITS_ATI */ - { 2551, 0x00008775 }, /* GL_BUMP_ROT_MATRIX_ATI */ - { 2574, 0x00008776 }, /* GL_BUMP_ROT_MATRIX_SIZE_ATI */ - { 2602, 0x0000877C }, /* GL_BUMP_TARGET_ATI */ - { 2621, 0x00008778 }, /* GL_BUMP_TEX_UNITS_ATI */ - { 2643, 0x00001400 }, /* GL_BYTE */ - { 2651, 0x00002A24 }, /* GL_C3F_V3F */ - { 2662, 0x00002A26 }, /* GL_C4F_N3F_V3F */ - { 2677, 0x00002A22 }, /* GL_C4UB_V2F */ - { 2689, 0x00002A23 }, /* GL_C4UB_V3F */ - { 2701, 0x00000901 }, /* GL_CCW */ - { 2708, 0x00002900 }, /* GL_CLAMP */ - { 2717, 0x0000891B }, /* GL_CLAMP_FRAGMENT_COLOR_ARB */ - { 2745, 0x0000891C }, /* GL_CLAMP_READ_COLOR */ - { 2765, 0x0000891C }, /* GL_CLAMP_READ_COLOR_ARB */ - { 2789, 0x0000812D }, /* GL_CLAMP_TO_BORDER */ - { 2808, 0x0000812D }, /* GL_CLAMP_TO_BORDER_ARB */ - { 2831, 0x0000812D }, /* GL_CLAMP_TO_BORDER_SGIS */ - { 2855, 0x0000812F }, /* GL_CLAMP_TO_EDGE */ - { 2872, 0x0000812F }, /* GL_CLAMP_TO_EDGE_SGIS */ - { 2894, 0x0000891A }, /* GL_CLAMP_VERTEX_COLOR_ARB */ - { 2920, 0x00001500 }, /* GL_CLEAR */ - { 2929, 0x000084E1 }, /* GL_CLIENT_ACTIVE_TEXTURE */ - { 2954, 0x000084E1 }, /* GL_CLIENT_ACTIVE_TEXTURE_ARB */ - { 2983, 0xFFFFFFFF }, /* GL_CLIENT_ALL_ATTRIB_BITS */ - { 3009, 0x00000BB1 }, /* GL_CLIENT_ATTRIB_STACK_DEPTH */ - { 3038, 0x00000001 }, /* GL_CLIENT_PIXEL_STORE_BIT */ - { 3064, 0x00000002 }, /* GL_CLIENT_VERTEX_ARRAY_BIT */ - { 3091, 0x00003000 }, /* GL_CLIP_DISTANCE0 */ - { 3109, 0x00003001 }, /* GL_CLIP_DISTANCE1 */ - { 3127, 0x00003002 }, /* GL_CLIP_DISTANCE2 */ - { 3145, 0x00003003 }, /* GL_CLIP_DISTANCE3 */ - { 3163, 0x00003004 }, /* GL_CLIP_DISTANCE4 */ - { 3181, 0x00003005 }, /* GL_CLIP_DISTANCE5 */ - { 3199, 0x00003006 }, /* GL_CLIP_DISTANCE6 */ - { 3217, 0x00003007 }, /* GL_CLIP_DISTANCE7 */ - { 3235, 0x00003000 }, /* GL_CLIP_PLANE0 */ - { 3250, 0x00003001 }, /* GL_CLIP_PLANE1 */ - { 3265, 0x00003002 }, /* GL_CLIP_PLANE2 */ - { 3280, 0x00003003 }, /* GL_CLIP_PLANE3 */ - { 3295, 0x00003004 }, /* GL_CLIP_PLANE4 */ - { 3310, 0x00003005 }, /* GL_CLIP_PLANE5 */ - { 3325, 0x000080F0 }, /* GL_CLIP_VOLUME_CLIPPING_HINT_EXT */ - { 3358, 0x00000A00 }, /* GL_COEFF */ - { 3367, 0x00001800 }, /* GL_COLOR */ - { 3376, 0x00008076 }, /* GL_COLOR_ARRAY */ - { 3391, 0x00008898 }, /* GL_COLOR_ARRAY_BUFFER_BINDING */ - { 3421, 0x00008898 }, /* GL_COLOR_ARRAY_BUFFER_BINDING_ARB */ - { 3455, 0x00008090 }, /* GL_COLOR_ARRAY_POINTER */ - { 3478, 0x00008081 }, /* GL_COLOR_ARRAY_SIZE */ - { 3498, 0x00008083 }, /* GL_COLOR_ARRAY_STRIDE */ - { 3520, 0x00008082 }, /* GL_COLOR_ARRAY_TYPE */ - { 3540, 0x00008CE0 }, /* GL_COLOR_ATTACHMENT0 */ - { 3561, 0x00008CE0 }, /* GL_COLOR_ATTACHMENT0_EXT */ - { 3586, 0x00008CE0 }, /* GL_COLOR_ATTACHMENT0_OES */ - { 3611, 0x00008CE1 }, /* GL_COLOR_ATTACHMENT1 */ - { 3632, 0x00008CEA }, /* GL_COLOR_ATTACHMENT10 */ - { 3654, 0x00008CEA }, /* GL_COLOR_ATTACHMENT10_EXT */ - { 3680, 0x00008CEB }, /* GL_COLOR_ATTACHMENT11 */ - { 3702, 0x00008CEB }, /* GL_COLOR_ATTACHMENT11_EXT */ - { 3728, 0x00008CEC }, /* GL_COLOR_ATTACHMENT12 */ - { 3750, 0x00008CEC }, /* GL_COLOR_ATTACHMENT12_EXT */ - { 3776, 0x00008CED }, /* GL_COLOR_ATTACHMENT13 */ - { 3798, 0x00008CED }, /* GL_COLOR_ATTACHMENT13_EXT */ - { 3824, 0x00008CEE }, /* GL_COLOR_ATTACHMENT14 */ - { 3846, 0x00008CEE }, /* GL_COLOR_ATTACHMENT14_EXT */ - { 3872, 0x00008CEF }, /* GL_COLOR_ATTACHMENT15 */ - { 3894, 0x00008CEF }, /* GL_COLOR_ATTACHMENT15_EXT */ - { 3920, 0x00008CE1 }, /* GL_COLOR_ATTACHMENT1_EXT */ - { 3945, 0x00008CE2 }, /* GL_COLOR_ATTACHMENT2 */ - { 3966, 0x00008CE2 }, /* GL_COLOR_ATTACHMENT2_EXT */ - { 3991, 0x00008CE3 }, /* GL_COLOR_ATTACHMENT3 */ - { 4012, 0x00008CE3 }, /* GL_COLOR_ATTACHMENT3_EXT */ - { 4037, 0x00008CE4 }, /* GL_COLOR_ATTACHMENT4 */ - { 4058, 0x00008CE4 }, /* GL_COLOR_ATTACHMENT4_EXT */ - { 4083, 0x00008CE5 }, /* GL_COLOR_ATTACHMENT5 */ - { 4104, 0x00008CE5 }, /* GL_COLOR_ATTACHMENT5_EXT */ - { 4129, 0x00008CE6 }, /* GL_COLOR_ATTACHMENT6 */ - { 4150, 0x00008CE6 }, /* GL_COLOR_ATTACHMENT6_EXT */ - { 4175, 0x00008CE7 }, /* GL_COLOR_ATTACHMENT7 */ - { 4196, 0x00008CE7 }, /* GL_COLOR_ATTACHMENT7_EXT */ - { 4221, 0x00008CE8 }, /* GL_COLOR_ATTACHMENT8 */ - { 4242, 0x00008CE8 }, /* GL_COLOR_ATTACHMENT8_EXT */ - { 4267, 0x00008CE9 }, /* GL_COLOR_ATTACHMENT9 */ - { 4288, 0x00008CE9 }, /* GL_COLOR_ATTACHMENT9_EXT */ - { 4313, 0x00004000 }, /* GL_COLOR_BUFFER_BIT */ - { 4333, 0x00000C22 }, /* GL_COLOR_CLEAR_VALUE */ - { 4354, 0x00001900 }, /* GL_COLOR_INDEX */ - { 4369, 0x00001603 }, /* GL_COLOR_INDEXES */ - { 4386, 0x00000BF2 }, /* GL_COLOR_LOGIC_OP */ - { 4404, 0x00000B57 }, /* GL_COLOR_MATERIAL */ - { 4422, 0x00000B55 }, /* GL_COLOR_MATERIAL_FACE */ - { 4445, 0x00000B56 }, /* GL_COLOR_MATERIAL_PARAMETER */ - { 4473, 0x000080B1 }, /* GL_COLOR_MATRIX */ - { 4489, 0x000080B1 }, /* GL_COLOR_MATRIX_SGI */ - { 4509, 0x000080B2 }, /* GL_COLOR_MATRIX_STACK_DEPTH */ - { 4537, 0x000080B2 }, /* GL_COLOR_MATRIX_STACK_DEPTH_SGI */ - { 4569, 0x00008458 }, /* GL_COLOR_SUM */ - { 4582, 0x00008458 }, /* GL_COLOR_SUM_ARB */ - { 4599, 0x000080D0 }, /* GL_COLOR_TABLE */ - { 4614, 0x000080DD }, /* GL_COLOR_TABLE_ALPHA_SIZE */ - { 4640, 0x000080DD }, /* GL_COLOR_TABLE_ALPHA_SIZE_EXT */ - { 4670, 0x000080DD }, /* GL_COLOR_TABLE_ALPHA_SIZE_SGI */ - { 4700, 0x000080D7 }, /* GL_COLOR_TABLE_BIAS */ - { 4720, 0x000080D7 }, /* GL_COLOR_TABLE_BIAS_SGI */ - { 4744, 0x000080DC }, /* GL_COLOR_TABLE_BLUE_SIZE */ - { 4769, 0x000080DC }, /* GL_COLOR_TABLE_BLUE_SIZE_EXT */ - { 4798, 0x000080DC }, /* GL_COLOR_TABLE_BLUE_SIZE_SGI */ - { 4827, 0x000080D8 }, /* GL_COLOR_TABLE_FORMAT */ - { 4849, 0x000080D8 }, /* GL_COLOR_TABLE_FORMAT_EXT */ - { 4875, 0x000080D8 }, /* GL_COLOR_TABLE_FORMAT_SGI */ - { 4901, 0x000080DB }, /* GL_COLOR_TABLE_GREEN_SIZE */ - { 4927, 0x000080DB }, /* GL_COLOR_TABLE_GREEN_SIZE_EXT */ - { 4957, 0x000080DB }, /* GL_COLOR_TABLE_GREEN_SIZE_SGI */ - { 4987, 0x000080DF }, /* GL_COLOR_TABLE_INTENSITY_SIZE */ - { 5017, 0x000080DF }, /* GL_COLOR_TABLE_INTENSITY_SIZE_EXT */ - { 5051, 0x000080DF }, /* GL_COLOR_TABLE_INTENSITY_SIZE_SGI */ - { 5085, 0x000080DE }, /* GL_COLOR_TABLE_LUMINANCE_SIZE */ - { 5115, 0x000080DE }, /* GL_COLOR_TABLE_LUMINANCE_SIZE_EXT */ - { 5149, 0x000080DE }, /* GL_COLOR_TABLE_LUMINANCE_SIZE_SGI */ - { 5183, 0x000080DA }, /* GL_COLOR_TABLE_RED_SIZE */ - { 5207, 0x000080DA }, /* GL_COLOR_TABLE_RED_SIZE_EXT */ - { 5235, 0x000080DA }, /* GL_COLOR_TABLE_RED_SIZE_SGI */ - { 5263, 0x000080D6 }, /* GL_COLOR_TABLE_SCALE */ - { 5284, 0x000080D6 }, /* GL_COLOR_TABLE_SCALE_SGI */ - { 5309, 0x000080D9 }, /* GL_COLOR_TABLE_WIDTH */ - { 5330, 0x000080D9 }, /* GL_COLOR_TABLE_WIDTH_EXT */ - { 5355, 0x000080D9 }, /* GL_COLOR_TABLE_WIDTH_SGI */ - { 5380, 0x00000C23 }, /* GL_COLOR_WRITEMASK */ - { 5399, 0x00008570 }, /* GL_COMBINE */ - { 5410, 0x00008503 }, /* GL_COMBINE4 */ - { 5422, 0x00008572 }, /* GL_COMBINE_ALPHA */ - { 5439, 0x00008572 }, /* GL_COMBINE_ALPHA_ARB */ - { 5460, 0x00008572 }, /* GL_COMBINE_ALPHA_EXT */ - { 5481, 0x00008570 }, /* GL_COMBINE_ARB */ - { 5496, 0x00008570 }, /* GL_COMBINE_EXT */ - { 5511, 0x00008571 }, /* GL_COMBINE_RGB */ - { 5526, 0x00008571 }, /* GL_COMBINE_RGB_ARB */ - { 5545, 0x00008571 }, /* GL_COMBINE_RGB_EXT */ - { 5564, 0x0000884E }, /* GL_COMPARE_REF_DEPTH_TO_TEXTURE_EXT */ - { 5600, 0x0000884E }, /* GL_COMPARE_REF_TO_TEXTURE */ - { 5626, 0x0000884E }, /* GL_COMPARE_R_TO_TEXTURE */ - { 5650, 0x0000884E }, /* GL_COMPARE_R_TO_TEXTURE_ARB */ - { 5678, 0x00001300 }, /* GL_COMPILE */ - { 5689, 0x00001301 }, /* GL_COMPILE_AND_EXECUTE */ - { 5712, 0x00008B81 }, /* GL_COMPILE_STATUS */ - { 5730, 0x000084E9 }, /* GL_COMPRESSED_ALPHA */ - { 5750, 0x000084E9 }, /* GL_COMPRESSED_ALPHA_ARB */ - { 5774, 0x000084EC }, /* GL_COMPRESSED_INTENSITY */ - { 5798, 0x000084EC }, /* GL_COMPRESSED_INTENSITY_ARB */ - { 5826, 0x000084EA }, /* GL_COMPRESSED_LUMINANCE */ - { 5850, 0x000084EB }, /* GL_COMPRESSED_LUMINANCE_ALPHA */ - { 5880, 0x000084EB }, /* GL_COMPRESSED_LUMINANCE_ALPHA_ARB */ - { 5914, 0x000084EA }, /* GL_COMPRESSED_LUMINANCE_ARB */ - { 5942, 0x00008225 }, /* GL_COMPRESSED_RED */ - { 5960, 0x00008226 }, /* GL_COMPRESSED_RG */ - { 5977, 0x000084ED }, /* GL_COMPRESSED_RGB */ - { 5995, 0x000084EE }, /* GL_COMPRESSED_RGBA */ - { 6014, 0x000084EE }, /* GL_COMPRESSED_RGBA_ARB */ - { 6037, 0x000086B1 }, /* GL_COMPRESSED_RGBA_FXT1_3DFX */ - { 6066, 0x000083F1 }, /* GL_COMPRESSED_RGBA_S3TC_DXT1_EXT */ - { 6099, 0x000083F2 }, /* GL_COMPRESSED_RGBA_S3TC_DXT3_EXT */ - { 6132, 0x000083F3 }, /* GL_COMPRESSED_RGBA_S3TC_DXT5_EXT */ - { 6165, 0x000084ED }, /* GL_COMPRESSED_RGB_ARB */ - { 6187, 0x000086B0 }, /* GL_COMPRESSED_RGB_FXT1_3DFX */ - { 6215, 0x000083F0 }, /* GL_COMPRESSED_RGB_S3TC_DXT1_EXT */ - { 6247, 0x00008C4A }, /* GL_COMPRESSED_SLUMINANCE */ - { 6272, 0x00008C4B }, /* GL_COMPRESSED_SLUMINANCE_ALPHA */ - { 6303, 0x00008C48 }, /* GL_COMPRESSED_SRGB */ - { 6322, 0x00008C49 }, /* GL_COMPRESSED_SRGB_ALPHA */ - { 6347, 0x000086A3 }, /* GL_COMPRESSED_TEXTURE_FORMATS */ - { 6377, 0x0000911C }, /* GL_CONDITION_SATISFIED */ - { 6400, 0x00008576 }, /* GL_CONSTANT */ - { 6412, 0x00008003 }, /* GL_CONSTANT_ALPHA */ - { 6430, 0x00008003 }, /* GL_CONSTANT_ALPHA_EXT */ - { 6452, 0x00008576 }, /* GL_CONSTANT_ARB */ - { 6468, 0x00001207 }, /* GL_CONSTANT_ATTENUATION */ - { 6492, 0x00008151 }, /* GL_CONSTANT_BORDER_HP */ - { 6514, 0x00008001 }, /* GL_CONSTANT_COLOR */ - { 6532, 0x00008001 }, /* GL_CONSTANT_COLOR_EXT */ - { 6554, 0x00008576 }, /* GL_CONSTANT_EXT */ - { 6570, 0x00000002 }, /* GL_CONTEXT_COMPATIBILITY_PROFILE_BIT */ - { 6607, 0x00000001 }, /* GL_CONTEXT_CORE_PROFILE_BIT */ - { 6635, 0x0000821E }, /* GL_CONTEXT_FLAGS */ - { 6652, 0x00000001 }, /* GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT */ - { 6691, 0x00000004 }, /* GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB */ - { 6729, 0x00009126 }, /* GL_CONTEXT_PROFILE_MASK */ - { 6753, 0x00008010 }, /* GL_CONVOLUTION_1D */ - { 6771, 0x00008011 }, /* GL_CONVOLUTION_2D */ - { 6789, 0x00008154 }, /* GL_CONVOLUTION_BORDER_COLOR */ - { 6817, 0x00008154 }, /* GL_CONVOLUTION_BORDER_COLOR_HP */ - { 6848, 0x00008013 }, /* GL_CONVOLUTION_BORDER_MODE */ - { 6875, 0x00008013 }, /* GL_CONVOLUTION_BORDER_MODE_EXT */ - { 6906, 0x00008015 }, /* GL_CONVOLUTION_FILTER_BIAS */ - { 6933, 0x00008015 }, /* GL_CONVOLUTION_FILTER_BIAS_EXT */ - { 6964, 0x00008014 }, /* GL_CONVOLUTION_FILTER_SCALE */ - { 6992, 0x00008014 }, /* GL_CONVOLUTION_FILTER_SCALE_EXT */ - { 7024, 0x00008017 }, /* GL_CONVOLUTION_FORMAT */ - { 7046, 0x00008017 }, /* GL_CONVOLUTION_FORMAT_EXT */ - { 7072, 0x00008019 }, /* GL_CONVOLUTION_HEIGHT */ - { 7094, 0x00008019 }, /* GL_CONVOLUTION_HEIGHT_EXT */ - { 7120, 0x00008018 }, /* GL_CONVOLUTION_WIDTH */ - { 7141, 0x00008018 }, /* GL_CONVOLUTION_WIDTH_EXT */ - { 7166, 0x00008862 }, /* GL_COORD_REPLACE */ - { 7183, 0x00008862 }, /* GL_COORD_REPLACE_ARB */ - { 7204, 0x00008862 }, /* GL_COORD_REPLACE_NV */ - { 7224, 0x00008862 }, /* GL_COORD_REPLACE_OES */ - { 7245, 0x00001503 }, /* GL_COPY */ - { 7253, 0x0000150C }, /* GL_COPY_INVERTED */ - { 7270, 0x00000706 }, /* GL_COPY_PIXEL_TOKEN */ - { 7290, 0x00008F36 }, /* GL_COPY_READ_BUFFER */ - { 7310, 0x00008F37 }, /* GL_COPY_WRITE_BUFFER */ - { 7331, 0x00000B44 }, /* GL_CULL_FACE */ - { 7344, 0x00000B45 }, /* GL_CULL_FACE_MODE */ - { 7362, 0x000081AA }, /* GL_CULL_VERTEX_EXT */ - { 7381, 0x000081AC }, /* GL_CULL_VERTEX_EYE_POSITION_EXT */ - { 7413, 0x000081AB }, /* GL_CULL_VERTEX_OBJECT_POSITION_EXT */ - { 7448, 0x00008626 }, /* GL_CURRENT_ATTRIB_NV */ - { 7469, 0x00000001 }, /* GL_CURRENT_BIT */ - { 7484, 0x00000B00 }, /* GL_CURRENT_COLOR */ - { 7501, 0x00008453 }, /* GL_CURRENT_FOG_COORD */ - { 7522, 0x00008453 }, /* GL_CURRENT_FOG_COORDINATE */ - { 7548, 0x00000B01 }, /* GL_CURRENT_INDEX */ - { 7565, 0x00008641 }, /* GL_CURRENT_MATRIX_ARB */ - { 7587, 0x00008845 }, /* GL_CURRENT_MATRIX_INDEX_ARB */ - { 7615, 0x00008641 }, /* GL_CURRENT_MATRIX_NV */ - { 7636, 0x00008640 }, /* GL_CURRENT_MATRIX_STACK_DEPTH_ARB */ - { 7670, 0x00008640 }, /* GL_CURRENT_MATRIX_STACK_DEPTH_NV */ - { 7703, 0x00000B02 }, /* GL_CURRENT_NORMAL */ - { 7721, 0x00008843 }, /* GL_CURRENT_PALETTE_MATRIX_ARB */ - { 7751, 0x00008843 }, /* GL_CURRENT_PALETTE_MATRIX_OES */ - { 7781, 0x00008B8D }, /* GL_CURRENT_PROGRAM */ - { 7800, 0x00008865 }, /* GL_CURRENT_QUERY */ - { 7817, 0x00008865 }, /* GL_CURRENT_QUERY_ARB */ - { 7838, 0x00000B04 }, /* GL_CURRENT_RASTER_COLOR */ - { 7862, 0x00000B09 }, /* GL_CURRENT_RASTER_DISTANCE */ - { 7889, 0x00000B05 }, /* GL_CURRENT_RASTER_INDEX */ - { 7913, 0x00000B07 }, /* GL_CURRENT_RASTER_POSITION */ - { 7940, 0x00000B08 }, /* GL_CURRENT_RASTER_POSITION_VALID */ - { 7973, 0x0000845F }, /* GL_CURRENT_RASTER_SECONDARY_COLOR */ - { 8007, 0x00000B06 }, /* GL_CURRENT_RASTER_TEXTURE_COORDS */ - { 8040, 0x00008459 }, /* GL_CURRENT_SECONDARY_COLOR */ - { 8067, 0x00000B03 }, /* GL_CURRENT_TEXTURE_COORDS */ - { 8093, 0x00008626 }, /* GL_CURRENT_VERTEX_ATTRIB */ - { 8118, 0x00008626 }, /* GL_CURRENT_VERTEX_ATTRIB_ARB */ - { 8147, 0x000086A8 }, /* GL_CURRENT_WEIGHT_ARB */ - { 8169, 0x00000900 }, /* GL_CW */ - { 8175, 0x0000875B }, /* GL_DEBUG_ASSERT_MESA */ - { 8196, 0x00008759 }, /* GL_DEBUG_OBJECT_MESA */ - { 8217, 0x0000875A }, /* GL_DEBUG_PRINT_MESA */ - { 8237, 0x00002101 }, /* GL_DECAL */ - { 8246, 0x00001E03 }, /* GL_DECR */ - { 8254, 0x00008508 }, /* GL_DECR_WRAP */ - { 8267, 0x00008508 }, /* GL_DECR_WRAP_EXT */ - { 8284, 0x00008B80 }, /* GL_DELETE_STATUS */ - { 8301, 0x00001801 }, /* GL_DEPTH */ - { 8310, 0x000088F0 }, /* GL_DEPTH24_STENCIL8 */ - { 8330, 0x000088F0 }, /* GL_DEPTH24_STENCIL8_EXT */ - { 8354, 0x000088F0 }, /* GL_DEPTH24_STENCIL8_OES */ - { 8378, 0x00008D00 }, /* GL_DEPTH_ATTACHMENT */ - { 8398, 0x00008D00 }, /* GL_DEPTH_ATTACHMENT_EXT */ - { 8422, 0x00008D00 }, /* GL_DEPTH_ATTACHMENT_OES */ - { 8446, 0x00000D1F }, /* GL_DEPTH_BIAS */ - { 8460, 0x00000D56 }, /* GL_DEPTH_BITS */ - { 8474, 0x00008891 }, /* GL_DEPTH_BOUNDS_EXT */ - { 8494, 0x00008890 }, /* GL_DEPTH_BOUNDS_TEST_EXT */ - { 8519, 0x00008223 }, /* GL_DEPTH_BUFFER */ - { 8535, 0x00000100 }, /* GL_DEPTH_BUFFER_BIT */ - { 8555, 0x0000864F }, /* GL_DEPTH_CLAMP */ - { 8570, 0x0000864F }, /* GL_DEPTH_CLAMP_NV */ - { 8588, 0x00000B73 }, /* GL_DEPTH_CLEAR_VALUE */ - { 8609, 0x00001902 }, /* GL_DEPTH_COMPONENT */ - { 8628, 0x000081A5 }, /* GL_DEPTH_COMPONENT16 */ - { 8649, 0x000081A5 }, /* GL_DEPTH_COMPONENT16_ARB */ - { 8674, 0x000081A5 }, /* GL_DEPTH_COMPONENT16_OES */ - { 8699, 0x000081A5 }, /* GL_DEPTH_COMPONENT16_SGIX */ - { 8725, 0x000081A6 }, /* GL_DEPTH_COMPONENT24 */ - { 8746, 0x000081A6 }, /* GL_DEPTH_COMPONENT24_ARB */ - { 8771, 0x000081A6 }, /* GL_DEPTH_COMPONENT24_OES */ - { 8796, 0x000081A6 }, /* GL_DEPTH_COMPONENT24_SGIX */ - { 8822, 0x000081A7 }, /* GL_DEPTH_COMPONENT32 */ - { 8843, 0x000081A7 }, /* GL_DEPTH_COMPONENT32_ARB */ - { 8868, 0x000081A7 }, /* GL_DEPTH_COMPONENT32_OES */ - { 8893, 0x000081A7 }, /* GL_DEPTH_COMPONENT32_SGIX */ - { 8919, 0x00000B74 }, /* GL_DEPTH_FUNC */ - { 8933, 0x00000B70 }, /* GL_DEPTH_RANGE */ - { 8948, 0x00000D1E }, /* GL_DEPTH_SCALE */ - { 8963, 0x000084F9 }, /* GL_DEPTH_STENCIL */ - { 8980, 0x0000821A }, /* GL_DEPTH_STENCIL_ATTACHMENT */ - { 9008, 0x000084F9 }, /* GL_DEPTH_STENCIL_EXT */ - { 9029, 0x000084F9 }, /* GL_DEPTH_STENCIL_NV */ - { 9049, 0x000084F9 }, /* GL_DEPTH_STENCIL_OES */ - { 9070, 0x0000886F }, /* GL_DEPTH_STENCIL_TO_BGRA_NV */ - { 9098, 0x0000886E }, /* GL_DEPTH_STENCIL_TO_RGBA_NV */ - { 9126, 0x00000B71 }, /* GL_DEPTH_TEST */ - { 9140, 0x0000884B }, /* GL_DEPTH_TEXTURE_MODE */ - { 9162, 0x0000884B }, /* GL_DEPTH_TEXTURE_MODE_ARB */ - { 9188, 0x00000B72 }, /* GL_DEPTH_WRITEMASK */ - { 9207, 0x00001201 }, /* GL_DIFFUSE */ - { 9218, 0x00000BD0 }, /* GL_DITHER */ - { 9228, 0x00000A02 }, /* GL_DOMAIN */ - { 9238, 0x00001100 }, /* GL_DONT_CARE */ - { 9251, 0x000086AE }, /* GL_DOT3_RGB */ - { 9263, 0x000086AF }, /* GL_DOT3_RGBA */ - { 9276, 0x000086AF }, /* GL_DOT3_RGBA_ARB */ - { 9293, 0x00008741 }, /* GL_DOT3_RGBA_EXT */ - { 9310, 0x000086AE }, /* GL_DOT3_RGB_ARB */ - { 9326, 0x00008740 }, /* GL_DOT3_RGB_EXT */ - { 9342, 0x0000140A }, /* GL_DOUBLE */ - { 9352, 0x00000C32 }, /* GL_DOUBLEBUFFER */ - { 9368, 0x00000C01 }, /* GL_DRAW_BUFFER */ - { 9383, 0x00008825 }, /* GL_DRAW_BUFFER0 */ - { 9399, 0x00008825 }, /* GL_DRAW_BUFFER0_ARB */ - { 9419, 0x00008825 }, /* GL_DRAW_BUFFER0_ATI */ - { 9439, 0x00008826 }, /* GL_DRAW_BUFFER1 */ - { 9455, 0x0000882F }, /* GL_DRAW_BUFFER10 */ - { 9472, 0x0000882F }, /* GL_DRAW_BUFFER10_ARB */ - { 9493, 0x0000882F }, /* GL_DRAW_BUFFER10_ATI */ - { 9514, 0x00008830 }, /* GL_DRAW_BUFFER11 */ - { 9531, 0x00008830 }, /* GL_DRAW_BUFFER11_ARB */ - { 9552, 0x00008830 }, /* GL_DRAW_BUFFER11_ATI */ - { 9573, 0x00008831 }, /* GL_DRAW_BUFFER12 */ - { 9590, 0x00008831 }, /* GL_DRAW_BUFFER12_ARB */ - { 9611, 0x00008831 }, /* GL_DRAW_BUFFER12_ATI */ - { 9632, 0x00008832 }, /* GL_DRAW_BUFFER13 */ - { 9649, 0x00008832 }, /* GL_DRAW_BUFFER13_ARB */ - { 9670, 0x00008832 }, /* GL_DRAW_BUFFER13_ATI */ - { 9691, 0x00008833 }, /* GL_DRAW_BUFFER14 */ - { 9708, 0x00008833 }, /* GL_DRAW_BUFFER14_ARB */ - { 9729, 0x00008833 }, /* GL_DRAW_BUFFER14_ATI */ - { 9750, 0x00008834 }, /* GL_DRAW_BUFFER15 */ - { 9767, 0x00008834 }, /* GL_DRAW_BUFFER15_ARB */ - { 9788, 0x00008834 }, /* GL_DRAW_BUFFER15_ATI */ - { 9809, 0x00008826 }, /* GL_DRAW_BUFFER1_ARB */ - { 9829, 0x00008826 }, /* GL_DRAW_BUFFER1_ATI */ - { 9849, 0x00008827 }, /* GL_DRAW_BUFFER2 */ - { 9865, 0x00008827 }, /* GL_DRAW_BUFFER2_ARB */ - { 9885, 0x00008827 }, /* GL_DRAW_BUFFER2_ATI */ - { 9905, 0x00008828 }, /* GL_DRAW_BUFFER3 */ - { 9921, 0x00008828 }, /* GL_DRAW_BUFFER3_ARB */ - { 9941, 0x00008828 }, /* GL_DRAW_BUFFER3_ATI */ - { 9961, 0x00008829 }, /* GL_DRAW_BUFFER4 */ - { 9977, 0x00008829 }, /* GL_DRAW_BUFFER4_ARB */ - { 9997, 0x00008829 }, /* GL_DRAW_BUFFER4_ATI */ - { 10017, 0x0000882A }, /* GL_DRAW_BUFFER5 */ - { 10033, 0x0000882A }, /* GL_DRAW_BUFFER5_ARB */ - { 10053, 0x0000882A }, /* GL_DRAW_BUFFER5_ATI */ - { 10073, 0x0000882B }, /* GL_DRAW_BUFFER6 */ - { 10089, 0x0000882B }, /* GL_DRAW_BUFFER6_ARB */ - { 10109, 0x0000882B }, /* GL_DRAW_BUFFER6_ATI */ - { 10129, 0x0000882C }, /* GL_DRAW_BUFFER7 */ - { 10145, 0x0000882C }, /* GL_DRAW_BUFFER7_ARB */ - { 10165, 0x0000882C }, /* GL_DRAW_BUFFER7_ATI */ - { 10185, 0x0000882D }, /* GL_DRAW_BUFFER8 */ - { 10201, 0x0000882D }, /* GL_DRAW_BUFFER8_ARB */ - { 10221, 0x0000882D }, /* GL_DRAW_BUFFER8_ATI */ - { 10241, 0x0000882E }, /* GL_DRAW_BUFFER9 */ - { 10257, 0x0000882E }, /* GL_DRAW_BUFFER9_ARB */ - { 10277, 0x0000882E }, /* GL_DRAW_BUFFER9_ATI */ - { 10297, 0x00008CA9 }, /* GL_DRAW_FRAMEBUFFER */ - { 10317, 0x00008CA6 }, /* GL_DRAW_FRAMEBUFFER_BINDING */ - { 10345, 0x00008CA6 }, /* GL_DRAW_FRAMEBUFFER_BINDING_EXT */ - { 10377, 0x00008CA9 }, /* GL_DRAW_FRAMEBUFFER_EXT */ - { 10401, 0x00000705 }, /* GL_DRAW_PIXEL_TOKEN */ - { 10421, 0x00000304 }, /* GL_DST_ALPHA */ - { 10434, 0x00000306 }, /* GL_DST_COLOR */ - { 10447, 0x0000877A }, /* GL_DU8DV8_ATI */ - { 10461, 0x00008779 }, /* GL_DUDV_ATI */ - { 10473, 0x000088EA }, /* GL_DYNAMIC_COPY */ - { 10489, 0x000088EA }, /* GL_DYNAMIC_COPY_ARB */ - { 10509, 0x000088E8 }, /* GL_DYNAMIC_DRAW */ - { 10525, 0x000088E8 }, /* GL_DYNAMIC_DRAW_ARB */ - { 10545, 0x000088E9 }, /* GL_DYNAMIC_READ */ - { 10561, 0x000088E9 }, /* GL_DYNAMIC_READ_ARB */ - { 10581, 0x00000B43 }, /* GL_EDGE_FLAG */ - { 10594, 0x00008079 }, /* GL_EDGE_FLAG_ARRAY */ - { 10613, 0x0000889B }, /* GL_EDGE_FLAG_ARRAY_BUFFER_BINDING */ - { 10647, 0x0000889B }, /* GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB */ - { 10685, 0x00008093 }, /* GL_EDGE_FLAG_ARRAY_POINTER */ - { 10712, 0x0000808C }, /* GL_EDGE_FLAG_ARRAY_STRIDE */ - { 10738, 0x00008893 }, /* GL_ELEMENT_ARRAY_BUFFER */ - { 10762, 0x00008895 }, /* GL_ELEMENT_ARRAY_BUFFER_BINDING */ - { 10794, 0x00008895 }, /* GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB */ - { 10830, 0x00001600 }, /* GL_EMISSION */ - { 10842, 0x00002000 }, /* GL_ENABLE_BIT */ - { 10856, 0x00000202 }, /* GL_EQUAL */ - { 10865, 0x00001509 }, /* GL_EQUIV */ - { 10874, 0x00010000 }, /* GL_EVAL_BIT */ - { 10886, 0x00000800 }, /* GL_EXP */ - { 10893, 0x00000801 }, /* GL_EXP2 */ - { 10901, 0x00001F03 }, /* GL_EXTENSIONS */ - { 10915, 0x00002400 }, /* GL_EYE_LINEAR */ - { 10929, 0x00002502 }, /* GL_EYE_PLANE */ - { 10942, 0x0000855C }, /* GL_EYE_PLANE_ABSOLUTE_NV */ - { 10967, 0x0000855B }, /* GL_EYE_RADIAL_NV */ - { 10984, 0x00000000 }, /* GL_FALSE */ - { 10993, 0x00001101 }, /* GL_FASTEST */ - { 11004, 0x00001C01 }, /* GL_FEEDBACK */ - { 11016, 0x00000DF0 }, /* GL_FEEDBACK_BUFFER_POINTER */ - { 11043, 0x00000DF1 }, /* GL_FEEDBACK_BUFFER_SIZE */ - { 11067, 0x00000DF2 }, /* GL_FEEDBACK_BUFFER_TYPE */ - { 11091, 0x00001B02 }, /* GL_FILL */ - { 11099, 0x00008E4D }, /* GL_FIRST_VERTEX_CONVENTION */ - { 11126, 0x00008E4D }, /* GL_FIRST_VERTEX_CONVENTION_EXT */ - { 11157, 0x0000140C }, /* GL_FIXED */ - { 11166, 0x0000140C }, /* GL_FIXED_OES */ - { 11179, 0x0000891D }, /* GL_FIXED_ONLY */ - { 11193, 0x0000891D }, /* GL_FIXED_ONLY_ARB */ - { 11211, 0x00001D00 }, /* GL_FLAT */ - { 11219, 0x00001406 }, /* GL_FLOAT */ - { 11228, 0x00008B5A }, /* GL_FLOAT_MAT2 */ - { 11242, 0x00008B5A }, /* GL_FLOAT_MAT2_ARB */ - { 11260, 0x00008B65 }, /* GL_FLOAT_MAT2x3 */ - { 11276, 0x00008B66 }, /* GL_FLOAT_MAT2x4 */ - { 11292, 0x00008B5B }, /* GL_FLOAT_MAT3 */ - { 11306, 0x00008B5B }, /* GL_FLOAT_MAT3_ARB */ - { 11324, 0x00008B67 }, /* GL_FLOAT_MAT3x2 */ - { 11340, 0x00008B68 }, /* GL_FLOAT_MAT3x4 */ - { 11356, 0x00008B5C }, /* GL_FLOAT_MAT4 */ - { 11370, 0x00008B5C }, /* GL_FLOAT_MAT4_ARB */ - { 11388, 0x00008B69 }, /* GL_FLOAT_MAT4x2 */ - { 11404, 0x00008B6A }, /* GL_FLOAT_MAT4x3 */ - { 11420, 0x00008B50 }, /* GL_FLOAT_VEC2 */ - { 11434, 0x00008B50 }, /* GL_FLOAT_VEC2_ARB */ - { 11452, 0x00008B51 }, /* GL_FLOAT_VEC3 */ - { 11466, 0x00008B51 }, /* GL_FLOAT_VEC3_ARB */ - { 11484, 0x00008B52 }, /* GL_FLOAT_VEC4 */ - { 11498, 0x00008B52 }, /* GL_FLOAT_VEC4_ARB */ - { 11516, 0x00000B60 }, /* GL_FOG */ - { 11523, 0x00000080 }, /* GL_FOG_BIT */ - { 11534, 0x00000B66 }, /* GL_FOG_COLOR */ - { 11547, 0x00008451 }, /* GL_FOG_COORD */ - { 11560, 0x00008451 }, /* GL_FOG_COORDINATE */ - { 11578, 0x00008457 }, /* GL_FOG_COORDINATE_ARRAY */ - { 11602, 0x0000889D }, /* GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING */ - { 11641, 0x0000889D }, /* GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB */ - { 11684, 0x00008456 }, /* GL_FOG_COORDINATE_ARRAY_POINTER */ - { 11716, 0x00008455 }, /* GL_FOG_COORDINATE_ARRAY_STRIDE */ - { 11747, 0x00008454 }, /* GL_FOG_COORDINATE_ARRAY_TYPE */ - { 11776, 0x00008450 }, /* GL_FOG_COORDINATE_SOURCE */ - { 11801, 0x00008457 }, /* GL_FOG_COORD_ARRAY */ - { 11820, 0x0000889D }, /* GL_FOG_COORD_ARRAY_BUFFER_BINDING */ - { 11854, 0x00008456 }, /* GL_FOG_COORD_ARRAY_POINTER */ - { 11881, 0x00008455 }, /* GL_FOG_COORD_ARRAY_STRIDE */ - { 11907, 0x00008454 }, /* GL_FOG_COORD_ARRAY_TYPE */ - { 11931, 0x00008450 }, /* GL_FOG_COORD_SRC */ - { 11948, 0x00000B62 }, /* GL_FOG_DENSITY */ - { 11963, 0x0000855A }, /* GL_FOG_DISTANCE_MODE_NV */ - { 11987, 0x00000B64 }, /* GL_FOG_END */ - { 11998, 0x00000C54 }, /* GL_FOG_HINT */ - { 12010, 0x00000B61 }, /* GL_FOG_INDEX */ - { 12023, 0x00000B65 }, /* GL_FOG_MODE */ - { 12035, 0x00008198 }, /* GL_FOG_OFFSET_SGIX */ - { 12054, 0x00008199 }, /* GL_FOG_OFFSET_VALUE_SGIX */ - { 12079, 0x00000B63 }, /* GL_FOG_START */ - { 12092, 0x00008452 }, /* GL_FRAGMENT_DEPTH */ - { 12110, 0x00008804 }, /* GL_FRAGMENT_PROGRAM_ARB */ - { 12134, 0x00008B30 }, /* GL_FRAGMENT_SHADER */ - { 12153, 0x00008B30 }, /* GL_FRAGMENT_SHADER_ARB */ - { 12176, 0x00008B8B }, /* GL_FRAGMENT_SHADER_DERIVATIVE_HINT */ - { 12211, 0x00008B8B }, /* GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES */ - { 12250, 0x00008D40 }, /* GL_FRAMEBUFFER */ - { 12265, 0x00008215 }, /* GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE */ - { 12302, 0x00008214 }, /* GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE */ - { 12338, 0x00008210 }, /* GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING */ - { 12379, 0x00008211 }, /* GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE */ - { 12420, 0x00008216 }, /* GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE */ - { 12457, 0x00008213 }, /* GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE */ - { 12494, 0x00008DA7 }, /* GL_FRAMEBUFFER_ATTACHMENT_LAYERED */ - { 12528, 0x00008DA7 }, /* GL_FRAMEBUFFER_ATTACHMENT_LAYERED_ARB */ - { 12566, 0x00008CD1 }, /* GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME */ - { 12604, 0x00008CD1 }, /* GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT */ - { 12646, 0x00008CD1 }, /* GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_OES */ - { 12688, 0x00008CD0 }, /* GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE */ - { 12726, 0x00008CD0 }, /* GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT */ - { 12768, 0x00008CD0 }, /* GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_OES */ - { 12810, 0x00008212 }, /* GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE */ - { 12845, 0x00008217 }, /* GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE */ - { 12884, 0x00008CD4 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT */ - { 12933, 0x00008CD4 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_OES */ - { 12982, 0x00008CD3 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE */ - { 13030, 0x00008CD3 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT */ - { 13082, 0x00008CD3 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_OES */ - { 13134, 0x00008CD4 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER */ - { 13174, 0x00008CD4 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT */ - { 13218, 0x00008CD2 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL */ - { 13258, 0x00008CD2 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT */ - { 13302, 0x00008CD2 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_OES */ - { 13346, 0x00008CA6 }, /* GL_FRAMEBUFFER_BINDING */ - { 13369, 0x00008CA6 }, /* GL_FRAMEBUFFER_BINDING_EXT */ - { 13396, 0x00008CA6 }, /* GL_FRAMEBUFFER_BINDING_OES */ - { 13423, 0x00008CD5 }, /* GL_FRAMEBUFFER_COMPLETE */ - { 13447, 0x00008CD5 }, /* GL_FRAMEBUFFER_COMPLETE_EXT */ - { 13475, 0x00008CD5 }, /* GL_FRAMEBUFFER_COMPLETE_OES */ - { 13503, 0x00008218 }, /* GL_FRAMEBUFFER_DEFAULT */ - { 13526, 0x00008D40 }, /* GL_FRAMEBUFFER_EXT */ - { 13545, 0x00008CD6 }, /* GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT */ - { 13582, 0x00008CD6 }, /* GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT */ - { 13623, 0x00008CD6 }, /* GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_OES */ - { 13664, 0x00008CD9 }, /* GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS */ - { 13701, 0x00008CD9 }, /* GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT */ - { 13742, 0x00008CD9 }, /* GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_OES */ - { 13783, 0x00008CDB }, /* GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER */ - { 13821, 0x00008CDB }, /* GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT */ - { 13863, 0x00008CDB }, /* GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_OES */ - { 13905, 0x00008CD8 }, /* GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT */ - { 13956, 0x00008CDA }, /* GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT */ - { 13994, 0x00008CDA }, /* GL_FRAMEBUFFER_INCOMPLETE_FORMATS_OES */ - { 14032, 0x00008DA9 }, /* GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB */ - { 14074, 0x00008DA8 }, /* GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS */ - { 14114, 0x00008DA8 }, /* GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_ARB */ - { 14158, 0x00008CD7 }, /* GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT */ - { 14203, 0x00008CD7 }, /* GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT */ - { 14252, 0x00008CD7 }, /* GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_OES */ - { 14301, 0x00008D56 }, /* GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE */ - { 14339, 0x00008D56 }, /* GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT */ - { 14381, 0x00008CDC }, /* GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER */ - { 14419, 0x00008CDC }, /* GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT */ - { 14461, 0x00008CDC }, /* GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_OES */ - { 14503, 0x00008D40 }, /* GL_FRAMEBUFFER_OES */ - { 14522, 0x00008CDE }, /* GL_FRAMEBUFFER_STATUS_ERROR_EXT */ - { 14554, 0x00008219 }, /* GL_FRAMEBUFFER_UNDEFINED */ - { 14579, 0x00008CDD }, /* GL_FRAMEBUFFER_UNSUPPORTED */ - { 14606, 0x00008CDD }, /* GL_FRAMEBUFFER_UNSUPPORTED_EXT */ - { 14637, 0x00008CDD }, /* GL_FRAMEBUFFER_UNSUPPORTED_OES */ - { 14668, 0x00000404 }, /* GL_FRONT */ - { 14677, 0x00000408 }, /* GL_FRONT_AND_BACK */ - { 14695, 0x00000B46 }, /* GL_FRONT_FACE */ - { 14709, 0x00000400 }, /* GL_FRONT_LEFT */ - { 14723, 0x00000401 }, /* GL_FRONT_RIGHT */ - { 14738, 0x00008006 }, /* GL_FUNC_ADD */ - { 14750, 0x00008006 }, /* GL_FUNC_ADD_EXT */ - { 14766, 0x00008006 }, /* GL_FUNC_ADD_OES */ - { 14782, 0x0000800B }, /* GL_FUNC_REVERSE_SUBTRACT */ - { 14807, 0x0000800B }, /* GL_FUNC_REVERSE_SUBTRACT_EXT */ - { 14836, 0x0000800B }, /* GL_FUNC_REVERSE_SUBTRACT_OES */ - { 14865, 0x0000800A }, /* GL_FUNC_SUBTRACT */ - { 14882, 0x0000800A }, /* GL_FUNC_SUBTRACT_EXT */ - { 14903, 0x0000800A }, /* GL_FUNC_SUBTRACT_OES */ - { 14924, 0x00008191 }, /* GL_GENERATE_MIPMAP */ - { 14943, 0x00008192 }, /* GL_GENERATE_MIPMAP_HINT */ - { 14967, 0x00008192 }, /* GL_GENERATE_MIPMAP_HINT_SGIS */ - { 14996, 0x00008191 }, /* GL_GENERATE_MIPMAP_SGIS */ - { 15020, 0x00008917 }, /* GL_GEOMETRY_INPUT_TYPE */ - { 15043, 0x00008DDB }, /* GL_GEOMETRY_INPUT_TYPE_ARB */ - { 15070, 0x00008918 }, /* GL_GEOMETRY_OUTPUT_TYPE */ - { 15094, 0x00008DDC }, /* GL_GEOMETRY_OUTPUT_TYPE_ARB */ - { 15122, 0x00008DD9 }, /* GL_GEOMETRY_SHADER */ - { 15141, 0x00008DD9 }, /* GL_GEOMETRY_SHADER_ARB */ - { 15164, 0x00008916 }, /* GL_GEOMETRY_VERTICES_OUT */ - { 15189, 0x00008DDA }, /* GL_GEOMETRY_VERTICES_OUT_ARB */ - { 15218, 0x00000206 }, /* GL_GEQUAL */ - { 15228, 0x00000204 }, /* GL_GREATER */ - { 15239, 0x00001904 }, /* GL_GREEN */ - { 15248, 0x00000D19 }, /* GL_GREEN_BIAS */ - { 15262, 0x00000D53 }, /* GL_GREEN_BITS */ - { 15276, 0x00008D95 }, /* GL_GREEN_INTEGER */ - { 15293, 0x00008D95 }, /* GL_GREEN_INTEGER_EXT */ - { 15314, 0x00000D18 }, /* GL_GREEN_SCALE */ - { 15329, 0x00008253 }, /* GL_GUILTY_CONTEXT_RESET_ARB */ - { 15357, 0x0000140B }, /* GL_HALF_FLOAT */ - { 15371, 0x00008D61 }, /* GL_HALF_FLOAT_OES */ - { 15389, 0x00008DF2 }, /* GL_HIGH_FLOAT */ - { 15403, 0x00008DF5 }, /* GL_HIGH_INT */ - { 15415, 0x00008000 }, /* GL_HINT_BIT */ - { 15427, 0x00008024 }, /* GL_HISTOGRAM */ - { 15440, 0x0000802B }, /* GL_HISTOGRAM_ALPHA_SIZE */ - { 15464, 0x0000802B }, /* GL_HISTOGRAM_ALPHA_SIZE_EXT */ - { 15492, 0x0000802A }, /* GL_HISTOGRAM_BLUE_SIZE */ - { 15515, 0x0000802A }, /* GL_HISTOGRAM_BLUE_SIZE_EXT */ - { 15542, 0x00008024 }, /* GL_HISTOGRAM_EXT */ - { 15559, 0x00008027 }, /* GL_HISTOGRAM_FORMAT */ - { 15579, 0x00008027 }, /* GL_HISTOGRAM_FORMAT_EXT */ - { 15603, 0x00008029 }, /* GL_HISTOGRAM_GREEN_SIZE */ - { 15627, 0x00008029 }, /* GL_HISTOGRAM_GREEN_SIZE_EXT */ - { 15655, 0x0000802C }, /* GL_HISTOGRAM_LUMINANCE_SIZE */ - { 15683, 0x0000802C }, /* GL_HISTOGRAM_LUMINANCE_SIZE_EXT */ - { 15715, 0x00008028 }, /* GL_HISTOGRAM_RED_SIZE */ - { 15737, 0x00008028 }, /* GL_HISTOGRAM_RED_SIZE_EXT */ - { 15763, 0x0000802D }, /* GL_HISTOGRAM_SINK */ - { 15781, 0x0000802D }, /* GL_HISTOGRAM_SINK_EXT */ - { 15803, 0x00008026 }, /* GL_HISTOGRAM_WIDTH */ - { 15822, 0x00008026 }, /* GL_HISTOGRAM_WIDTH_EXT */ - { 15845, 0x0000862A }, /* GL_IDENTITY_NV */ - { 15860, 0x00008150 }, /* GL_IGNORE_BORDER_HP */ - { 15880, 0x00008B9B }, /* GL_IMPLEMENTATION_COLOR_READ_FORMAT */ - { 15916, 0x00008B9B }, /* GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES */ - { 15956, 0x00008B9A }, /* GL_IMPLEMENTATION_COLOR_READ_TYPE */ - { 15990, 0x00008B9A }, /* GL_IMPLEMENTATION_COLOR_READ_TYPE_OES */ - { 16028, 0x00001E02 }, /* GL_INCR */ - { 16036, 0x00008507 }, /* GL_INCR_WRAP */ - { 16049, 0x00008507 }, /* GL_INCR_WRAP_EXT */ - { 16066, 0x00008222 }, /* GL_INDEX */ - { 16075, 0x00008077 }, /* GL_INDEX_ARRAY */ - { 16090, 0x00008899 }, /* GL_INDEX_ARRAY_BUFFER_BINDING */ - { 16120, 0x00008899 }, /* GL_INDEX_ARRAY_BUFFER_BINDING_ARB */ - { 16154, 0x00008091 }, /* GL_INDEX_ARRAY_POINTER */ - { 16177, 0x00008086 }, /* GL_INDEX_ARRAY_STRIDE */ - { 16199, 0x00008085 }, /* GL_INDEX_ARRAY_TYPE */ - { 16219, 0x00000D51 }, /* GL_INDEX_BITS */ - { 16233, 0x00000C20 }, /* GL_INDEX_CLEAR_VALUE */ - { 16254, 0x00000BF1 }, /* GL_INDEX_LOGIC_OP */ - { 16272, 0x00000C30 }, /* GL_INDEX_MODE */ - { 16286, 0x00000D13 }, /* GL_INDEX_OFFSET */ - { 16302, 0x00000D12 }, /* GL_INDEX_SHIFT */ - { 16317, 0x00000C21 }, /* GL_INDEX_WRITEMASK */ - { 16336, 0x00008B84 }, /* GL_INFO_LOG_LENGTH */ - { 16355, 0x00008254 }, /* GL_INNOCENT_CONTEXT_RESET_ARB */ - { 16385, 0x00001404 }, /* GL_INT */ - { 16392, 0x00008049 }, /* GL_INTENSITY */ - { 16405, 0x0000804C }, /* GL_INTENSITY12 */ - { 16420, 0x0000804C }, /* GL_INTENSITY12_EXT */ - { 16439, 0x0000804D }, /* GL_INTENSITY16 */ - { 16454, 0x00008D8B }, /* GL_INTENSITY16I_EXT */ - { 16474, 0x00008D79 }, /* GL_INTENSITY16UI_EXT */ - { 16495, 0x0000804D }, /* GL_INTENSITY16_EXT */ - { 16514, 0x00008D85 }, /* GL_INTENSITY32I_EXT */ - { 16534, 0x00008D73 }, /* GL_INTENSITY32UI_EXT */ - { 16555, 0x0000804A }, /* GL_INTENSITY4 */ - { 16569, 0x0000804A }, /* GL_INTENSITY4_EXT */ - { 16587, 0x0000804B }, /* GL_INTENSITY8 */ - { 16601, 0x00008D91 }, /* GL_INTENSITY8I_EXT */ - { 16620, 0x00008D7F }, /* GL_INTENSITY8UI_EXT */ - { 16640, 0x0000804B }, /* GL_INTENSITY8_EXT */ - { 16658, 0x00008049 }, /* GL_INTENSITY_EXT */ - { 16675, 0x00008C8C }, /* GL_INTERLEAVED_ATTRIBS */ - { 16698, 0x00008C8C }, /* GL_INTERLEAVED_ATTRIBS_EXT */ - { 16725, 0x00008575 }, /* GL_INTERPOLATE */ - { 16740, 0x00008575 }, /* GL_INTERPOLATE_ARB */ - { 16759, 0x00008575 }, /* GL_INTERPOLATE_EXT */ - { 16778, 0x00008DF7 }, /* GL_INT_10_10_10_2_OES */ - { 16800, 0x00008D9F }, /* GL_INT_2_10_10_10_REV */ - { 16822, 0x00008DC9 }, /* GL_INT_SAMPLER_1D */ - { 16840, 0x00008DCE }, /* GL_INT_SAMPLER_1D_ARRAY */ - { 16864, 0x00008DCE }, /* GL_INT_SAMPLER_1D_ARRAY_EXT */ - { 16892, 0x00008DC9 }, /* GL_INT_SAMPLER_1D_EXT */ - { 16914, 0x00008DCA }, /* GL_INT_SAMPLER_2D */ - { 16932, 0x00008DCF }, /* GL_INT_SAMPLER_2D_ARRAY */ - { 16956, 0x00008DCF }, /* GL_INT_SAMPLER_2D_ARRAY_EXT */ - { 16984, 0x00008DCA }, /* GL_INT_SAMPLER_2D_EXT */ - { 17006, 0x00008DCD }, /* GL_INT_SAMPLER_2D_RECT */ - { 17029, 0x00008DCD }, /* GL_INT_SAMPLER_2D_RECT_EXT */ - { 17056, 0x00008DCB }, /* GL_INT_SAMPLER_3D */ - { 17074, 0x00008DCB }, /* GL_INT_SAMPLER_3D_EXT */ - { 17096, 0x00008DD0 }, /* GL_INT_SAMPLER_BUFFER */ - { 17118, 0x00008DD0 }, /* GL_INT_SAMPLER_BUFFER_EXT */ - { 17144, 0x00008DCC }, /* GL_INT_SAMPLER_CUBE */ - { 17164, 0x00008DCC }, /* GL_INT_SAMPLER_CUBE_EXT */ - { 17188, 0x00008B53 }, /* GL_INT_VEC2 */ - { 17200, 0x00008B53 }, /* GL_INT_VEC2_ARB */ - { 17216, 0x00008B54 }, /* GL_INT_VEC3 */ - { 17228, 0x00008B54 }, /* GL_INT_VEC3_ARB */ - { 17244, 0x00008B55 }, /* GL_INT_VEC4 */ - { 17256, 0x00008B55 }, /* GL_INT_VEC4_ARB */ - { 17272, 0x00000500 }, /* GL_INVALID_ENUM */ - { 17288, 0x00000506 }, /* GL_INVALID_FRAMEBUFFER_OPERATION */ - { 17321, 0x00000506 }, /* GL_INVALID_FRAMEBUFFER_OPERATION_EXT */ - { 17358, 0x00000506 }, /* GL_INVALID_FRAMEBUFFER_OPERATION_OES */ - { 17395, 0x00000502 }, /* GL_INVALID_OPERATION */ - { 17416, 0x00000501 }, /* GL_INVALID_VALUE */ - { 17433, 0x0000862B }, /* GL_INVERSE_NV */ - { 17447, 0x0000862D }, /* GL_INVERSE_TRANSPOSE_NV */ - { 17471, 0x0000150A }, /* GL_INVERT */ - { 17481, 0x00001E00 }, /* GL_KEEP */ - { 17489, 0x00008E4E }, /* GL_LAST_VERTEX_CONVENTION */ - { 17515, 0x00008E4E }, /* GL_LAST_VERTEX_CONVENTION_EXT */ - { 17545, 0x00000406 }, /* GL_LEFT */ - { 17553, 0x00000203 }, /* GL_LEQUAL */ - { 17563, 0x00000201 }, /* GL_LESS */ - { 17571, 0x00004000 }, /* GL_LIGHT0 */ - { 17581, 0x00004001 }, /* GL_LIGHT1 */ - { 17591, 0x00004002 }, /* GL_LIGHT2 */ - { 17601, 0x00004003 }, /* GL_LIGHT3 */ - { 17611, 0x00004004 }, /* GL_LIGHT4 */ - { 17621, 0x00004005 }, /* GL_LIGHT5 */ - { 17631, 0x00004006 }, /* GL_LIGHT6 */ - { 17641, 0x00004007 }, /* GL_LIGHT7 */ - { 17651, 0x00000B50 }, /* GL_LIGHTING */ - { 17663, 0x00000040 }, /* GL_LIGHTING_BIT */ - { 17679, 0x00000B53 }, /* GL_LIGHT_MODEL_AMBIENT */ - { 17702, 0x000081F8 }, /* GL_LIGHT_MODEL_COLOR_CONTROL */ - { 17731, 0x000081F8 }, /* GL_LIGHT_MODEL_COLOR_CONTROL_EXT */ - { 17764, 0x00000B51 }, /* GL_LIGHT_MODEL_LOCAL_VIEWER */ - { 17792, 0x00000B52 }, /* GL_LIGHT_MODEL_TWO_SIDE */ - { 17816, 0x00001B01 }, /* GL_LINE */ - { 17824, 0x00002601 }, /* GL_LINEAR */ - { 17834, 0x00001208 }, /* GL_LINEAR_ATTENUATION */ - { 17856, 0x00008170 }, /* GL_LINEAR_CLIPMAP_LINEAR_SGIX */ - { 17886, 0x0000844F }, /* GL_LINEAR_CLIPMAP_NEAREST_SGIX */ - { 17917, 0x00002703 }, /* GL_LINEAR_MIPMAP_LINEAR */ - { 17941, 0x00002701 }, /* GL_LINEAR_MIPMAP_NEAREST */ - { 17966, 0x00000001 }, /* GL_LINES */ - { 17975, 0x0000000A }, /* GL_LINES_ADJACENCY */ - { 17994, 0x0000000A }, /* GL_LINES_ADJACENCY_ARB */ - { 18017, 0x00000004 }, /* GL_LINE_BIT */ - { 18029, 0x00000002 }, /* GL_LINE_LOOP */ - { 18042, 0x00000707 }, /* GL_LINE_RESET_TOKEN */ - { 18062, 0x00000B20 }, /* GL_LINE_SMOOTH */ - { 18077, 0x00000C52 }, /* GL_LINE_SMOOTH_HINT */ - { 18097, 0x00000B24 }, /* GL_LINE_STIPPLE */ - { 18113, 0x00000B25 }, /* GL_LINE_STIPPLE_PATTERN */ - { 18137, 0x00000B26 }, /* GL_LINE_STIPPLE_REPEAT */ - { 18160, 0x00000003 }, /* GL_LINE_STRIP */ - { 18174, 0x0000000B }, /* GL_LINE_STRIP_ADJACENCY */ - { 18198, 0x0000000B }, /* GL_LINE_STRIP_ADJACENCY_ARB */ - { 18226, 0x00000702 }, /* GL_LINE_TOKEN */ - { 18240, 0x00000B21 }, /* GL_LINE_WIDTH */ - { 18254, 0x00000B23 }, /* GL_LINE_WIDTH_GRANULARITY */ - { 18280, 0x00000B22 }, /* GL_LINE_WIDTH_RANGE */ - { 18300, 0x00008B82 }, /* GL_LINK_STATUS */ - { 18315, 0x00000B32 }, /* GL_LIST_BASE */ - { 18328, 0x00020000 }, /* GL_LIST_BIT */ - { 18340, 0x00000B33 }, /* GL_LIST_INDEX */ - { 18354, 0x00000B30 }, /* GL_LIST_MODE */ - { 18367, 0x00000101 }, /* GL_LOAD */ - { 18375, 0x00000BF1 }, /* GL_LOGIC_OP */ - { 18387, 0x00000BF0 }, /* GL_LOGIC_OP_MODE */ - { 18404, 0x00008252 }, /* GL_LOSE_CONTEXT_ON_RESET_ARB */ - { 18433, 0x00008CA1 }, /* GL_LOWER_LEFT */ - { 18447, 0x00008DF0 }, /* GL_LOW_FLOAT */ - { 18460, 0x00008DF3 }, /* GL_LOW_INT */ - { 18471, 0x00001909 }, /* GL_LUMINANCE */ - { 18484, 0x00008041 }, /* GL_LUMINANCE12 */ - { 18499, 0x00008047 }, /* GL_LUMINANCE12_ALPHA12 */ - { 18522, 0x00008047 }, /* GL_LUMINANCE12_ALPHA12_EXT */ - { 18549, 0x00008046 }, /* GL_LUMINANCE12_ALPHA4 */ - { 18571, 0x00008046 }, /* GL_LUMINANCE12_ALPHA4_EXT */ - { 18597, 0x00008041 }, /* GL_LUMINANCE12_EXT */ - { 18616, 0x00008042 }, /* GL_LUMINANCE16 */ - { 18631, 0x00008D8C }, /* GL_LUMINANCE16I_EXT */ - { 18651, 0x00008D7A }, /* GL_LUMINANCE16UI_EXT */ - { 18672, 0x00008048 }, /* GL_LUMINANCE16_ALPHA16 */ - { 18695, 0x00008048 }, /* GL_LUMINANCE16_ALPHA16_EXT */ - { 18722, 0x00008042 }, /* GL_LUMINANCE16_EXT */ - { 18741, 0x00008D86 }, /* GL_LUMINANCE32I_EXT */ - { 18761, 0x00008D74 }, /* GL_LUMINANCE32UI_EXT */ - { 18782, 0x0000803F }, /* GL_LUMINANCE4 */ - { 18796, 0x00008043 }, /* GL_LUMINANCE4_ALPHA4 */ - { 18817, 0x00008043 }, /* GL_LUMINANCE4_ALPHA4_EXT */ - { 18842, 0x0000803F }, /* GL_LUMINANCE4_EXT */ - { 18860, 0x00008044 }, /* GL_LUMINANCE6_ALPHA2 */ - { 18881, 0x00008044 }, /* GL_LUMINANCE6_ALPHA2_EXT */ - { 18906, 0x00008040 }, /* GL_LUMINANCE8 */ - { 18920, 0x00008D92 }, /* GL_LUMINANCE8I_EXT */ - { 18939, 0x00008D80 }, /* GL_LUMINANCE8UI_EXT */ - { 18959, 0x00008045 }, /* GL_LUMINANCE8_ALPHA8 */ - { 18980, 0x00008045 }, /* GL_LUMINANCE8_ALPHA8_EXT */ - { 19005, 0x00008040 }, /* GL_LUMINANCE8_EXT */ - { 19023, 0x0000190A }, /* GL_LUMINANCE_ALPHA */ - { 19042, 0x00008D8D }, /* GL_LUMINANCE_ALPHA16I_EXT */ - { 19068, 0x00008D7B }, /* GL_LUMINANCE_ALPHA16UI_EXT */ - { 19095, 0x00008D87 }, /* GL_LUMINANCE_ALPHA32I_EXT */ - { 19121, 0x00008D75 }, /* GL_LUMINANCE_ALPHA32UI_EXT */ - { 19148, 0x00008D93 }, /* GL_LUMINANCE_ALPHA8I_EXT */ - { 19173, 0x00008D81 }, /* GL_LUMINANCE_ALPHA8UI_EXT */ - { 19199, 0x00008D9D }, /* GL_LUMINANCE_ALPHA_INTEGER_EXT */ - { 19230, 0x00008D9C }, /* GL_LUMINANCE_INTEGER_EXT */ - { 19255, 0x0000821B }, /* GL_MAJOR_VERSION */ - { 19272, 0x00000D90 }, /* GL_MAP1_COLOR_4 */ - { 19288, 0x00000DD0 }, /* GL_MAP1_GRID_DOMAIN */ - { 19308, 0x00000DD1 }, /* GL_MAP1_GRID_SEGMENTS */ - { 19330, 0x00000D91 }, /* GL_MAP1_INDEX */ - { 19344, 0x00000D92 }, /* GL_MAP1_NORMAL */ - { 19359, 0x00000D93 }, /* GL_MAP1_TEXTURE_COORD_1 */ - { 19383, 0x00000D94 }, /* GL_MAP1_TEXTURE_COORD_2 */ - { 19407, 0x00000D95 }, /* GL_MAP1_TEXTURE_COORD_3 */ - { 19431, 0x00000D96 }, /* GL_MAP1_TEXTURE_COORD_4 */ - { 19455, 0x00000D97 }, /* GL_MAP1_VERTEX_3 */ - { 19472, 0x00000D98 }, /* GL_MAP1_VERTEX_4 */ - { 19489, 0x00008660 }, /* GL_MAP1_VERTEX_ATTRIB0_4_NV */ - { 19517, 0x0000866A }, /* GL_MAP1_VERTEX_ATTRIB10_4_NV */ - { 19546, 0x0000866B }, /* GL_MAP1_VERTEX_ATTRIB11_4_NV */ - { 19575, 0x0000866C }, /* GL_MAP1_VERTEX_ATTRIB12_4_NV */ - { 19604, 0x0000866D }, /* GL_MAP1_VERTEX_ATTRIB13_4_NV */ - { 19633, 0x0000866E }, /* GL_MAP1_VERTEX_ATTRIB14_4_NV */ - { 19662, 0x0000866F }, /* GL_MAP1_VERTEX_ATTRIB15_4_NV */ - { 19691, 0x00008661 }, /* GL_MAP1_VERTEX_ATTRIB1_4_NV */ - { 19719, 0x00008662 }, /* GL_MAP1_VERTEX_ATTRIB2_4_NV */ - { 19747, 0x00008663 }, /* GL_MAP1_VERTEX_ATTRIB3_4_NV */ - { 19775, 0x00008664 }, /* GL_MAP1_VERTEX_ATTRIB4_4_NV */ - { 19803, 0x00008665 }, /* GL_MAP1_VERTEX_ATTRIB5_4_NV */ - { 19831, 0x00008666 }, /* GL_MAP1_VERTEX_ATTRIB6_4_NV */ - { 19859, 0x00008667 }, /* GL_MAP1_VERTEX_ATTRIB7_4_NV */ - { 19887, 0x00008668 }, /* GL_MAP1_VERTEX_ATTRIB8_4_NV */ - { 19915, 0x00008669 }, /* GL_MAP1_VERTEX_ATTRIB9_4_NV */ - { 19943, 0x00000DB0 }, /* GL_MAP2_COLOR_4 */ - { 19959, 0x00000DD2 }, /* GL_MAP2_GRID_DOMAIN */ - { 19979, 0x00000DD3 }, /* GL_MAP2_GRID_SEGMENTS */ - { 20001, 0x00000DB1 }, /* GL_MAP2_INDEX */ - { 20015, 0x00000DB2 }, /* GL_MAP2_NORMAL */ - { 20030, 0x00000DB3 }, /* GL_MAP2_TEXTURE_COORD_1 */ - { 20054, 0x00000DB4 }, /* GL_MAP2_TEXTURE_COORD_2 */ - { 20078, 0x00000DB5 }, /* GL_MAP2_TEXTURE_COORD_3 */ - { 20102, 0x00000DB6 }, /* GL_MAP2_TEXTURE_COORD_4 */ - { 20126, 0x00000DB7 }, /* GL_MAP2_VERTEX_3 */ - { 20143, 0x00000DB8 }, /* GL_MAP2_VERTEX_4 */ - { 20160, 0x00008670 }, /* GL_MAP2_VERTEX_ATTRIB0_4_NV */ - { 20188, 0x0000867A }, /* GL_MAP2_VERTEX_ATTRIB10_4_NV */ - { 20217, 0x0000867B }, /* GL_MAP2_VERTEX_ATTRIB11_4_NV */ - { 20246, 0x0000867C }, /* GL_MAP2_VERTEX_ATTRIB12_4_NV */ - { 20275, 0x0000867D }, /* GL_MAP2_VERTEX_ATTRIB13_4_NV */ - { 20304, 0x0000867E }, /* GL_MAP2_VERTEX_ATTRIB14_4_NV */ - { 20333, 0x0000867F }, /* GL_MAP2_VERTEX_ATTRIB15_4_NV */ - { 20362, 0x00008671 }, /* GL_MAP2_VERTEX_ATTRIB1_4_NV */ - { 20390, 0x00008672 }, /* GL_MAP2_VERTEX_ATTRIB2_4_NV */ - { 20418, 0x00008673 }, /* GL_MAP2_VERTEX_ATTRIB3_4_NV */ - { 20446, 0x00008674 }, /* GL_MAP2_VERTEX_ATTRIB4_4_NV */ - { 20474, 0x00008675 }, /* GL_MAP2_VERTEX_ATTRIB5_4_NV */ - { 20502, 0x00008676 }, /* GL_MAP2_VERTEX_ATTRIB6_4_NV */ - { 20530, 0x00008677 }, /* GL_MAP2_VERTEX_ATTRIB7_4_NV */ - { 20558, 0x00008678 }, /* GL_MAP2_VERTEX_ATTRIB8_4_NV */ - { 20586, 0x00008679 }, /* GL_MAP2_VERTEX_ATTRIB9_4_NV */ - { 20614, 0x00000D10 }, /* GL_MAP_COLOR */ - { 20627, 0x00000010 }, /* GL_MAP_FLUSH_EXPLICIT_BIT */ - { 20653, 0x00000008 }, /* GL_MAP_INVALIDATE_BUFFER_BIT */ - { 20682, 0x00000004 }, /* GL_MAP_INVALIDATE_RANGE_BIT */ - { 20710, 0x00000001 }, /* GL_MAP_READ_BIT */ - { 20726, 0x00000D11 }, /* GL_MAP_STENCIL */ - { 20741, 0x00000020 }, /* GL_MAP_UNSYNCHRONIZED_BIT */ - { 20767, 0x00000002 }, /* GL_MAP_WRITE_BIT */ - { 20784, 0x000088C0 }, /* GL_MATRIX0_ARB */ - { 20799, 0x00008630 }, /* GL_MATRIX0_NV */ - { 20813, 0x000088CA }, /* GL_MATRIX10_ARB */ - { 20829, 0x000088CB }, /* GL_MATRIX11_ARB */ - { 20845, 0x000088CC }, /* GL_MATRIX12_ARB */ - { 20861, 0x000088CD }, /* GL_MATRIX13_ARB */ - { 20877, 0x000088CE }, /* GL_MATRIX14_ARB */ - { 20893, 0x000088CF }, /* GL_MATRIX15_ARB */ - { 20909, 0x000088D0 }, /* GL_MATRIX16_ARB */ - { 20925, 0x000088D1 }, /* GL_MATRIX17_ARB */ - { 20941, 0x000088D2 }, /* GL_MATRIX18_ARB */ - { 20957, 0x000088D3 }, /* GL_MATRIX19_ARB */ - { 20973, 0x000088C1 }, /* GL_MATRIX1_ARB */ - { 20988, 0x00008631 }, /* GL_MATRIX1_NV */ - { 21002, 0x000088D4 }, /* GL_MATRIX20_ARB */ - { 21018, 0x000088D5 }, /* GL_MATRIX21_ARB */ - { 21034, 0x000088D6 }, /* GL_MATRIX22_ARB */ - { 21050, 0x000088D7 }, /* GL_MATRIX23_ARB */ - { 21066, 0x000088D8 }, /* GL_MATRIX24_ARB */ - { 21082, 0x000088D9 }, /* GL_MATRIX25_ARB */ - { 21098, 0x000088DA }, /* GL_MATRIX26_ARB */ - { 21114, 0x000088DB }, /* GL_MATRIX27_ARB */ - { 21130, 0x000088DC }, /* GL_MATRIX28_ARB */ - { 21146, 0x000088DD }, /* GL_MATRIX29_ARB */ - { 21162, 0x000088C2 }, /* GL_MATRIX2_ARB */ - { 21177, 0x00008632 }, /* GL_MATRIX2_NV */ - { 21191, 0x000088DE }, /* GL_MATRIX30_ARB */ - { 21207, 0x000088DF }, /* GL_MATRIX31_ARB */ - { 21223, 0x000088C3 }, /* GL_MATRIX3_ARB */ - { 21238, 0x00008633 }, /* GL_MATRIX3_NV */ - { 21252, 0x000088C4 }, /* GL_MATRIX4_ARB */ - { 21267, 0x00008634 }, /* GL_MATRIX4_NV */ - { 21281, 0x000088C5 }, /* GL_MATRIX5_ARB */ - { 21296, 0x00008635 }, /* GL_MATRIX5_NV */ - { 21310, 0x000088C6 }, /* GL_MATRIX6_ARB */ - { 21325, 0x00008636 }, /* GL_MATRIX6_NV */ - { 21339, 0x000088C7 }, /* GL_MATRIX7_ARB */ - { 21354, 0x00008637 }, /* GL_MATRIX7_NV */ - { 21368, 0x000088C8 }, /* GL_MATRIX8_ARB */ - { 21383, 0x000088C9 }, /* GL_MATRIX9_ARB */ - { 21398, 0x00008844 }, /* GL_MATRIX_INDEX_ARRAY_ARB */ - { 21424, 0x00008B9E }, /* GL_MATRIX_INDEX_ARRAY_BUFFER_BINDING_OES */ - { 21465, 0x00008844 }, /* GL_MATRIX_INDEX_ARRAY_OES */ - { 21491, 0x00008849 }, /* GL_MATRIX_INDEX_ARRAY_POINTER_ARB */ - { 21525, 0x00008849 }, /* GL_MATRIX_INDEX_ARRAY_POINTER_OES */ - { 21559, 0x00008846 }, /* GL_MATRIX_INDEX_ARRAY_SIZE_ARB */ - { 21590, 0x00008846 }, /* GL_MATRIX_INDEX_ARRAY_SIZE_OES */ - { 21621, 0x00008848 }, /* GL_MATRIX_INDEX_ARRAY_STRIDE_ARB */ - { 21654, 0x00008848 }, /* GL_MATRIX_INDEX_ARRAY_STRIDE_OES */ - { 21687, 0x00008847 }, /* GL_MATRIX_INDEX_ARRAY_TYPE_ARB */ - { 21718, 0x00008847 }, /* GL_MATRIX_INDEX_ARRAY_TYPE_OES */ - { 21749, 0x00000BA0 }, /* GL_MATRIX_MODE */ - { 21764, 0x00008840 }, /* GL_MATRIX_PALETTE_ARB */ - { 21786, 0x00008840 }, /* GL_MATRIX_PALETTE_OES */ - { 21808, 0x00008008 }, /* GL_MAX */ - { 21815, 0x00008073 }, /* GL_MAX_3D_TEXTURE_SIZE */ - { 21838, 0x00008073 }, /* GL_MAX_3D_TEXTURE_SIZE_OES */ - { 21865, 0x000088FF }, /* GL_MAX_ARRAY_TEXTURE_LAYERS */ - { 21893, 0x000088FF }, /* GL_MAX_ARRAY_TEXTURE_LAYERS_EXT */ - { 21925, 0x00000D35 }, /* GL_MAX_ATTRIB_STACK_DEPTH */ - { 21951, 0x00000D3B }, /* GL_MAX_CLIENT_ATTRIB_STACK_DEPTH */ - { 21984, 0x00008177 }, /* GL_MAX_CLIPMAP_DEPTH_SGIX */ - { 22010, 0x00008178 }, /* GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX */ - { 22044, 0x00000D32 }, /* GL_MAX_CLIP_DISTANCES */ - { 22066, 0x00000D32 }, /* GL_MAX_CLIP_PLANES */ - { 22085, 0x00008CDF }, /* GL_MAX_COLOR_ATTACHMENTS */ - { 22110, 0x00008CDF }, /* GL_MAX_COLOR_ATTACHMENTS_EXT */ - { 22139, 0x000080B3 }, /* GL_MAX_COLOR_MATRIX_STACK_DEPTH */ - { 22171, 0x000080B3 }, /* GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI */ - { 22207, 0x00008B4D }, /* GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS */ - { 22243, 0x00008B4D }, /* GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB */ - { 22283, 0x0000801B }, /* GL_MAX_CONVOLUTION_HEIGHT */ - { 22309, 0x0000801B }, /* GL_MAX_CONVOLUTION_HEIGHT_EXT */ - { 22339, 0x0000801A }, /* GL_MAX_CONVOLUTION_WIDTH */ - { 22364, 0x0000801A }, /* GL_MAX_CONVOLUTION_WIDTH_EXT */ - { 22393, 0x0000851C }, /* GL_MAX_CUBE_MAP_TEXTURE_SIZE */ - { 22422, 0x0000851C }, /* GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB */ - { 22455, 0x0000851C }, /* GL_MAX_CUBE_MAP_TEXTURE_SIZE_OES */ - { 22488, 0x00008824 }, /* GL_MAX_DRAW_BUFFERS */ - { 22508, 0x00008824 }, /* GL_MAX_DRAW_BUFFERS_ARB */ - { 22532, 0x00008824 }, /* GL_MAX_DRAW_BUFFERS_ATI */ - { 22556, 0x000080E9 }, /* GL_MAX_ELEMENTS_INDICES */ - { 22580, 0x000080E8 }, /* GL_MAX_ELEMENTS_VERTICES */ - { 22605, 0x00000D30 }, /* GL_MAX_EVAL_ORDER */ - { 22623, 0x00008008 }, /* GL_MAX_EXT */ - { 22634, 0x00009125 }, /* GL_MAX_FRAGMENT_INPUT_COMPONENTS */ - { 22667, 0x00008B49 }, /* GL_MAX_FRAGMENT_UNIFORM_COMPONENTS */ - { 22702, 0x00008B49 }, /* GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB */ - { 22741, 0x00008DFD }, /* GL_MAX_FRAGMENT_UNIFORM_VECTORS */ - { 22773, 0x00009123 }, /* GL_MAX_GEOMETRY_INPUT_COMPONENTS */ - { 22806, 0x00009124 }, /* GL_MAX_GEOMETRY_OUTPUT_COMPONENTS */ - { 22840, 0x00008DE0 }, /* GL_MAX_GEOMETRY_OUTPUT_VERTICES */ - { 22872, 0x00008DE0 }, /* GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB */ - { 22908, 0x00008C29 }, /* GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS */ - { 22944, 0x00008C29 }, /* GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB */ - { 22984, 0x00008DE1 }, /* GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS */ - { 23024, 0x00008DE1 }, /* GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB */ - { 23068, 0x00008DDF }, /* GL_MAX_GEOMETRY_UNIFORM_COMPONENTS */ - { 23103, 0x00008DDF }, /* GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB */ - { 23142, 0x00008DDD }, /* GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB */ - { 23181, 0x00000D31 }, /* GL_MAX_LIGHTS */ - { 23195, 0x00000B31 }, /* GL_MAX_LIST_NESTING */ - { 23215, 0x00008841 }, /* GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB */ - { 23253, 0x00000D36 }, /* GL_MAX_MODELVIEW_STACK_DEPTH */ - { 23282, 0x00000D37 }, /* GL_MAX_NAME_STACK_DEPTH */ - { 23306, 0x00008842 }, /* GL_MAX_PALETTE_MATRICES_ARB */ - { 23334, 0x00008842 }, /* GL_MAX_PALETTE_MATRICES_OES */ - { 23362, 0x00000D34 }, /* GL_MAX_PIXEL_MAP_TABLE */ - { 23385, 0x000088B1 }, /* GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB */ - { 23422, 0x0000880B }, /* GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB */ - { 23458, 0x000088AD }, /* GL_MAX_PROGRAM_ATTRIBS_ARB */ - { 23485, 0x000088F5 }, /* GL_MAX_PROGRAM_CALL_DEPTH_NV */ - { 23514, 0x000088B5 }, /* GL_MAX_PROGRAM_ENV_PARAMETERS_ARB */ - { 23548, 0x000088F4 }, /* GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV */ - { 23584, 0x000088F6 }, /* GL_MAX_PROGRAM_IF_DEPTH_NV */ - { 23611, 0x000088A1 }, /* GL_MAX_PROGRAM_INSTRUCTIONS_ARB */ - { 23643, 0x000088B4 }, /* GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB */ - { 23679, 0x000088F8 }, /* GL_MAX_PROGRAM_LOOP_COUNT_NV */ - { 23708, 0x000088F7 }, /* GL_MAX_PROGRAM_LOOP_DEPTH_NV */ - { 23737, 0x0000862F }, /* GL_MAX_PROGRAM_MATRICES_ARB */ - { 23765, 0x0000862E }, /* GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB */ - { 23803, 0x000088B3 }, /* GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB */ - { 23847, 0x0000880E }, /* GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB */ - { 23890, 0x000088AF }, /* GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB */ - { 23924, 0x000088A3 }, /* GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB */ - { 23963, 0x000088AB }, /* GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB */ - { 24000, 0x000088A7 }, /* GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB */ - { 24038, 0x00008810 }, /* GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB */ - { 24081, 0x0000880F }, /* GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB */ - { 24124, 0x000088A9 }, /* GL_MAX_PROGRAM_PARAMETERS_ARB */ - { 24154, 0x000088A5 }, /* GL_MAX_PROGRAM_TEMPORARIES_ARB */ - { 24185, 0x00008905 }, /* GL_MAX_PROGRAM_TEXEL_OFFSET */ - { 24213, 0x00008905 }, /* GL_MAX_PROGRAM_TEXEL_OFFSET_EXT */ - { 24245, 0x0000880D }, /* GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB */ - { 24281, 0x0000880C }, /* GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB */ - { 24317, 0x00000D38 }, /* GL_MAX_PROJECTION_STACK_DEPTH */ - { 24347, 0x000084F8 }, /* GL_MAX_RECTANGLE_TEXTURE_SIZE */ - { 24377, 0x000084F8 }, /* GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB */ - { 24411, 0x000084F8 }, /* GL_MAX_RECTANGLE_TEXTURE_SIZE_NV */ - { 24444, 0x000084E8 }, /* GL_MAX_RENDERBUFFER_SIZE */ - { 24469, 0x000084E8 }, /* GL_MAX_RENDERBUFFER_SIZE_EXT */ - { 24498, 0x000084E8 }, /* GL_MAX_RENDERBUFFER_SIZE_OES */ - { 24527, 0x00008D57 }, /* GL_MAX_SAMPLES */ - { 24542, 0x00008D57 }, /* GL_MAX_SAMPLES_EXT */ - { 24561, 0x00009111 }, /* GL_MAX_SERVER_WAIT_TIMEOUT */ - { 24588, 0x00008504 }, /* GL_MAX_SHININESS_NV */ - { 24608, 0x00008505 }, /* GL_MAX_SPOT_EXPONENT_NV */ - { 24632, 0x00008C2B }, /* GL_MAX_TEXTURE_BUFFER_SIZE */ - { 24659, 0x00008C2B }, /* GL_MAX_TEXTURE_BUFFER_SIZE_ARB */ - { 24690, 0x00008871 }, /* GL_MAX_TEXTURE_COORDS */ - { 24712, 0x00008871 }, /* GL_MAX_TEXTURE_COORDS_ARB */ - { 24738, 0x00008872 }, /* GL_MAX_TEXTURE_IMAGE_UNITS */ - { 24765, 0x00008872 }, /* GL_MAX_TEXTURE_IMAGE_UNITS_ARB */ - { 24796, 0x000084FD }, /* GL_MAX_TEXTURE_LOD_BIAS */ - { 24820, 0x000084FD }, /* GL_MAX_TEXTURE_LOD_BIAS_EXT */ - { 24848, 0x000084FF }, /* GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT */ - { 24882, 0x00000D33 }, /* GL_MAX_TEXTURE_SIZE */ - { 24902, 0x00000D39 }, /* GL_MAX_TEXTURE_STACK_DEPTH */ - { 24929, 0x000084E2 }, /* GL_MAX_TEXTURE_UNITS */ - { 24950, 0x000084E2 }, /* GL_MAX_TEXTURE_UNITS_ARB */ - { 24975, 0x0000862F }, /* GL_MAX_TRACK_MATRICES_NV */ - { 25000, 0x0000862E }, /* GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV */ - { 25035, 0x00008C8A }, /* GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS */ - { 25084, 0x00008C8A }, /* GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_EXT */ - { 25137, 0x00008C8B }, /* GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS */ - { 25180, 0x00008C8B }, /* GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_EXT */ - { 25227, 0x00008C80 }, /* GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS */ - { 25273, 0x00008C80 }, /* GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_EXT */ - { 25323, 0x00008B4B }, /* GL_MAX_VARYING_COMPONENTS */ - { 25349, 0x00008B4B }, /* GL_MAX_VARYING_FLOATS */ - { 25371, 0x00008B4B }, /* GL_MAX_VARYING_FLOATS_ARB */ - { 25397, 0x00008DFC }, /* GL_MAX_VARYING_VECTORS */ - { 25420, 0x00008869 }, /* GL_MAX_VERTEX_ATTRIBS */ - { 25442, 0x00008869 }, /* GL_MAX_VERTEX_ATTRIBS_ARB */ - { 25468, 0x00009122 }, /* GL_MAX_VERTEX_OUTPUT_COMPONENTS */ - { 25500, 0x00008B4C }, /* GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS */ - { 25534, 0x00008B4C }, /* GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB */ - { 25572, 0x00008B4A }, /* GL_MAX_VERTEX_UNIFORM_COMPONENTS */ - { 25605, 0x00008B4A }, /* GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB */ - { 25642, 0x00008DFB }, /* GL_MAX_VERTEX_UNIFORM_VECTORS */ - { 25672, 0x000086A4 }, /* GL_MAX_VERTEX_UNITS_ARB */ - { 25696, 0x000086A4 }, /* GL_MAX_VERTEX_UNITS_OES */ - { 25720, 0x00008DDE }, /* GL_MAX_VERTEX_VARYING_COMPONENTS_ARB */ - { 25757, 0x00000D3A }, /* GL_MAX_VIEWPORT_DIMS */ - { 25778, 0x00008DF1 }, /* GL_MEDIUM_FLOAT */ - { 25794, 0x00008DF4 }, /* GL_MEDIUM_INT */ - { 25808, 0x00008007 }, /* GL_MIN */ - { 25815, 0x0000802E }, /* GL_MINMAX */ - { 25825, 0x0000802E }, /* GL_MINMAX_EXT */ - { 25839, 0x0000802F }, /* GL_MINMAX_FORMAT */ - { 25856, 0x0000802F }, /* GL_MINMAX_FORMAT_EXT */ - { 25877, 0x00008030 }, /* GL_MINMAX_SINK */ - { 25892, 0x00008030 }, /* GL_MINMAX_SINK_EXT */ - { 25911, 0x0000821C }, /* GL_MINOR_VERSION */ - { 25928, 0x00008007 }, /* GL_MIN_EXT */ - { 25939, 0x00008904 }, /* GL_MIN_PROGRAM_TEXEL_OFFSET */ - { 25967, 0x00008904 }, /* GL_MIN_PROGRAM_TEXEL_OFFSET_EXT */ - { 25999, 0x00008370 }, /* GL_MIRRORED_REPEAT */ - { 26018, 0x00008370 }, /* GL_MIRRORED_REPEAT_ARB */ - { 26041, 0x00008370 }, /* GL_MIRRORED_REPEAT_IBM */ - { 26064, 0x00008742 }, /* GL_MIRROR_CLAMP_ATI */ - { 26084, 0x00008742 }, /* GL_MIRROR_CLAMP_EXT */ - { 26104, 0x00008912 }, /* GL_MIRROR_CLAMP_TO_BORDER_EXT */ - { 26134, 0x00008743 }, /* GL_MIRROR_CLAMP_TO_EDGE_ATI */ - { 26162, 0x00008743 }, /* GL_MIRROR_CLAMP_TO_EDGE_EXT */ - { 26190, 0x00001700 }, /* GL_MODELVIEW */ - { 26203, 0x00001700 }, /* GL_MODELVIEW0_ARB */ - { 26221, 0x0000872A }, /* GL_MODELVIEW10_ARB */ - { 26240, 0x0000872B }, /* GL_MODELVIEW11_ARB */ - { 26259, 0x0000872C }, /* GL_MODELVIEW12_ARB */ - { 26278, 0x0000872D }, /* GL_MODELVIEW13_ARB */ - { 26297, 0x0000872E }, /* GL_MODELVIEW14_ARB */ - { 26316, 0x0000872F }, /* GL_MODELVIEW15_ARB */ - { 26335, 0x00008730 }, /* GL_MODELVIEW16_ARB */ - { 26354, 0x00008731 }, /* GL_MODELVIEW17_ARB */ - { 26373, 0x00008732 }, /* GL_MODELVIEW18_ARB */ - { 26392, 0x00008733 }, /* GL_MODELVIEW19_ARB */ - { 26411, 0x0000850A }, /* GL_MODELVIEW1_ARB */ - { 26429, 0x00008734 }, /* GL_MODELVIEW20_ARB */ - { 26448, 0x00008735 }, /* GL_MODELVIEW21_ARB */ - { 26467, 0x00008736 }, /* GL_MODELVIEW22_ARB */ - { 26486, 0x00008737 }, /* GL_MODELVIEW23_ARB */ - { 26505, 0x00008738 }, /* GL_MODELVIEW24_ARB */ - { 26524, 0x00008739 }, /* GL_MODELVIEW25_ARB */ - { 26543, 0x0000873A }, /* GL_MODELVIEW26_ARB */ - { 26562, 0x0000873B }, /* GL_MODELVIEW27_ARB */ - { 26581, 0x0000873C }, /* GL_MODELVIEW28_ARB */ - { 26600, 0x0000873D }, /* GL_MODELVIEW29_ARB */ - { 26619, 0x00008722 }, /* GL_MODELVIEW2_ARB */ - { 26637, 0x0000873E }, /* GL_MODELVIEW30_ARB */ - { 26656, 0x0000873F }, /* GL_MODELVIEW31_ARB */ - { 26675, 0x00008723 }, /* GL_MODELVIEW3_ARB */ - { 26693, 0x00008724 }, /* GL_MODELVIEW4_ARB */ - { 26711, 0x00008725 }, /* GL_MODELVIEW5_ARB */ - { 26729, 0x00008726 }, /* GL_MODELVIEW6_ARB */ - { 26747, 0x00008727 }, /* GL_MODELVIEW7_ARB */ - { 26765, 0x00008728 }, /* GL_MODELVIEW8_ARB */ - { 26783, 0x00008729 }, /* GL_MODELVIEW9_ARB */ - { 26801, 0x00000BA6 }, /* GL_MODELVIEW_MATRIX */ - { 26821, 0x0000898D }, /* GL_MODELVIEW_MATRIX_FLOAT_AS_INT_BITS_OES */ - { 26863, 0x00008629 }, /* GL_MODELVIEW_PROJECTION_NV */ - { 26890, 0x00000BA3 }, /* GL_MODELVIEW_STACK_DEPTH */ - { 26915, 0x00002100 }, /* GL_MODULATE */ - { 26927, 0x00008744 }, /* GL_MODULATE_ADD_ATI */ - { 26947, 0x00008745 }, /* GL_MODULATE_SIGNED_ADD_ATI */ - { 26974, 0x00008746 }, /* GL_MODULATE_SUBTRACT_ATI */ - { 26999, 0x00000103 }, /* GL_MULT */ - { 27007, 0x0000809D }, /* GL_MULTISAMPLE */ - { 27022, 0x000086B2 }, /* GL_MULTISAMPLE_3DFX */ - { 27042, 0x0000809D }, /* GL_MULTISAMPLE_ARB */ - { 27061, 0x20000000 }, /* GL_MULTISAMPLE_BIT */ - { 27080, 0x20000000 }, /* GL_MULTISAMPLE_BIT_3DFX */ - { 27104, 0x20000000 }, /* GL_MULTISAMPLE_BIT_ARB */ - { 27127, 0x00008534 }, /* GL_MULTISAMPLE_FILTER_HINT_NV */ - { 27157, 0x00002A25 }, /* GL_N3F_V3F */ - { 27168, 0x00000D70 }, /* GL_NAME_STACK_DEPTH */ - { 27188, 0x0000150E }, /* GL_NAND */ - { 27196, 0x00002600 }, /* GL_NEAREST */ - { 27207, 0x0000844E }, /* GL_NEAREST_CLIPMAP_LINEAR_SGIX */ - { 27238, 0x0000844D }, /* GL_NEAREST_CLIPMAP_NEAREST_SGIX */ - { 27270, 0x00002702 }, /* GL_NEAREST_MIPMAP_LINEAR */ - { 27295, 0x00002700 }, /* GL_NEAREST_MIPMAP_NEAREST */ - { 27321, 0x00000200 }, /* GL_NEVER */ - { 27330, 0x00001102 }, /* GL_NICEST */ - { 27340, 0x00000000 }, /* GL_NONE */ - { 27348, 0x00000000 }, /* GL_NONE_OES */ - { 27360, 0x00001505 }, /* GL_NOOP */ - { 27368, 0x00001508 }, /* GL_NOR */ - { 27375, 0x00000BA1 }, /* GL_NORMALIZE */ - { 27388, 0x00008075 }, /* GL_NORMAL_ARRAY */ - { 27404, 0x00008897 }, /* GL_NORMAL_ARRAY_BUFFER_BINDING */ - { 27435, 0x00008897 }, /* GL_NORMAL_ARRAY_BUFFER_BINDING_ARB */ - { 27470, 0x0000808F }, /* GL_NORMAL_ARRAY_POINTER */ - { 27494, 0x0000807F }, /* GL_NORMAL_ARRAY_STRIDE */ - { 27517, 0x0000807E }, /* GL_NORMAL_ARRAY_TYPE */ - { 27538, 0x00008511 }, /* GL_NORMAL_MAP */ - { 27552, 0x00008511 }, /* GL_NORMAL_MAP_ARB */ - { 27570, 0x00008511 }, /* GL_NORMAL_MAP_NV */ - { 27587, 0x00008511 }, /* GL_NORMAL_MAP_OES */ - { 27605, 0x00000205 }, /* GL_NOTEQUAL */ - { 27617, 0x00000000 }, /* GL_NO_ERROR */ - { 27629, 0x00008261 }, /* GL_NO_RESET_NOTIFICATION_ARB */ - { 27658, 0x000086A2 }, /* GL_NUM_COMPRESSED_TEXTURE_FORMATS */ - { 27692, 0x000086A2 }, /* GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB */ - { 27730, 0x0000821D }, /* GL_NUM_EXTENSIONS */ - { 27748, 0x000087FE }, /* GL_NUM_PROGRAM_BINARY_FORMATS */ - { 27778, 0x000087FE }, /* GL_NUM_PROGRAM_BINARY_FORMATS_OES */ - { 27812, 0x00008DF9 }, /* GL_NUM_SHADER_BINARY_FORMATS */ - { 27841, 0x00008B89 }, /* GL_OBJECT_ACTIVE_ATTRIBUTES_ARB */ - { 27873, 0x00008B8A }, /* GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB */ - { 27915, 0x00008B86 }, /* GL_OBJECT_ACTIVE_UNIFORMS_ARB */ - { 27945, 0x00008B87 }, /* GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB */ - { 27985, 0x00008B85 }, /* GL_OBJECT_ATTACHED_OBJECTS_ARB */ - { 28016, 0x00008B81 }, /* GL_OBJECT_COMPILE_STATUS_ARB */ - { 28045, 0x00008B80 }, /* GL_OBJECT_DELETE_STATUS_ARB */ - { 28073, 0x00008B84 }, /* GL_OBJECT_INFO_LOG_LENGTH_ARB */ - { 28103, 0x00002401 }, /* GL_OBJECT_LINEAR */ - { 28120, 0x00008B82 }, /* GL_OBJECT_LINK_STATUS_ARB */ - { 28146, 0x00002501 }, /* GL_OBJECT_PLANE */ - { 28162, 0x00008B88 }, /* GL_OBJECT_SHADER_SOURCE_LENGTH_ARB */ - { 28197, 0x00008B4F }, /* GL_OBJECT_SUBTYPE_ARB */ - { 28219, 0x00009112 }, /* GL_OBJECT_TYPE */ - { 28234, 0x00008B4E }, /* GL_OBJECT_TYPE_ARB */ - { 28253, 0x00008B83 }, /* GL_OBJECT_VALIDATE_STATUS_ARB */ - { 28283, 0x00008165 }, /* GL_OCCLUSION_TEST_HP */ - { 28304, 0x00008166 }, /* GL_OCCLUSION_TEST_RESULT_HP */ - { 28332, 0x00000001 }, /* GL_ONE */ - { 28339, 0x00008004 }, /* GL_ONE_MINUS_CONSTANT_ALPHA */ - { 28367, 0x00008004 }, /* GL_ONE_MINUS_CONSTANT_ALPHA_EXT */ - { 28399, 0x00008002 }, /* GL_ONE_MINUS_CONSTANT_COLOR */ - { 28427, 0x00008002 }, /* GL_ONE_MINUS_CONSTANT_COLOR_EXT */ - { 28459, 0x00000305 }, /* GL_ONE_MINUS_DST_ALPHA */ - { 28482, 0x00000307 }, /* GL_ONE_MINUS_DST_COLOR */ - { 28505, 0x00000303 }, /* GL_ONE_MINUS_SRC_ALPHA */ - { 28528, 0x00000301 }, /* GL_ONE_MINUS_SRC_COLOR */ - { 28551, 0x00008598 }, /* GL_OPERAND0_ALPHA */ - { 28569, 0x00008598 }, /* GL_OPERAND0_ALPHA_ARB */ - { 28591, 0x00008598 }, /* GL_OPERAND0_ALPHA_EXT */ - { 28613, 0x00008590 }, /* GL_OPERAND0_RGB */ - { 28629, 0x00008590 }, /* GL_OPERAND0_RGB_ARB */ - { 28649, 0x00008590 }, /* GL_OPERAND0_RGB_EXT */ - { 28669, 0x00008599 }, /* GL_OPERAND1_ALPHA */ - { 28687, 0x00008599 }, /* GL_OPERAND1_ALPHA_ARB */ - { 28709, 0x00008599 }, /* GL_OPERAND1_ALPHA_EXT */ - { 28731, 0x00008591 }, /* GL_OPERAND1_RGB */ - { 28747, 0x00008591 }, /* GL_OPERAND1_RGB_ARB */ - { 28767, 0x00008591 }, /* GL_OPERAND1_RGB_EXT */ - { 28787, 0x0000859A }, /* GL_OPERAND2_ALPHA */ - { 28805, 0x0000859A }, /* GL_OPERAND2_ALPHA_ARB */ - { 28827, 0x0000859A }, /* GL_OPERAND2_ALPHA_EXT */ - { 28849, 0x00008592 }, /* GL_OPERAND2_RGB */ - { 28865, 0x00008592 }, /* GL_OPERAND2_RGB_ARB */ - { 28885, 0x00008592 }, /* GL_OPERAND2_RGB_EXT */ - { 28905, 0x0000859B }, /* GL_OPERAND3_ALPHA_NV */ - { 28926, 0x00008593 }, /* GL_OPERAND3_RGB_NV */ - { 28945, 0x00001507 }, /* GL_OR */ - { 28951, 0x00000A01 }, /* GL_ORDER */ - { 28960, 0x0000150D }, /* GL_OR_INVERTED */ - { 28975, 0x0000150B }, /* GL_OR_REVERSE */ - { 28989, 0x00000505 }, /* GL_OUT_OF_MEMORY */ - { 29006, 0x00000D05 }, /* GL_PACK_ALIGNMENT */ - { 29024, 0x0000806C }, /* GL_PACK_IMAGE_HEIGHT */ - { 29045, 0x00008758 }, /* GL_PACK_INVERT_MESA */ - { 29065, 0x00000D01 }, /* GL_PACK_LSB_FIRST */ - { 29083, 0x00000D02 }, /* GL_PACK_ROW_LENGTH */ - { 29102, 0x0000806B }, /* GL_PACK_SKIP_IMAGES */ - { 29122, 0x00000D04 }, /* GL_PACK_SKIP_PIXELS */ - { 29142, 0x00000D03 }, /* GL_PACK_SKIP_ROWS */ - { 29160, 0x00000D00 }, /* GL_PACK_SWAP_BYTES */ - { 29179, 0x00008B92 }, /* GL_PALETTE4_R5_G6_B5_OES */ - { 29204, 0x00008B94 }, /* GL_PALETTE4_RGB5_A1_OES */ - { 29228, 0x00008B90 }, /* GL_PALETTE4_RGB8_OES */ - { 29249, 0x00008B93 }, /* GL_PALETTE4_RGBA4_OES */ - { 29271, 0x00008B91 }, /* GL_PALETTE4_RGBA8_OES */ - { 29293, 0x00008B97 }, /* GL_PALETTE8_R5_G6_B5_OES */ - { 29318, 0x00008B99 }, /* GL_PALETTE8_RGB5_A1_OES */ - { 29342, 0x00008B95 }, /* GL_PALETTE8_RGB8_OES */ - { 29363, 0x00008B98 }, /* GL_PALETTE8_RGBA4_OES */ - { 29385, 0x00008B96 }, /* GL_PALETTE8_RGBA8_OES */ - { 29407, 0x00000700 }, /* GL_PASS_THROUGH_TOKEN */ - { 29429, 0x00000C50 }, /* GL_PERSPECTIVE_CORRECTION_HINT */ - { 29460, 0x00000C79 }, /* GL_PIXEL_MAP_A_TO_A */ - { 29480, 0x00000CB9 }, /* GL_PIXEL_MAP_A_TO_A_SIZE */ - { 29505, 0x00000C78 }, /* GL_PIXEL_MAP_B_TO_B */ - { 29525, 0x00000CB8 }, /* GL_PIXEL_MAP_B_TO_B_SIZE */ - { 29550, 0x00000C77 }, /* GL_PIXEL_MAP_G_TO_G */ - { 29570, 0x00000CB7 }, /* GL_PIXEL_MAP_G_TO_G_SIZE */ - { 29595, 0x00000C75 }, /* GL_PIXEL_MAP_I_TO_A */ - { 29615, 0x00000CB5 }, /* GL_PIXEL_MAP_I_TO_A_SIZE */ - { 29640, 0x00000C74 }, /* GL_PIXEL_MAP_I_TO_B */ - { 29660, 0x00000CB4 }, /* GL_PIXEL_MAP_I_TO_B_SIZE */ - { 29685, 0x00000C73 }, /* GL_PIXEL_MAP_I_TO_G */ - { 29705, 0x00000CB3 }, /* GL_PIXEL_MAP_I_TO_G_SIZE */ - { 29730, 0x00000C70 }, /* GL_PIXEL_MAP_I_TO_I */ - { 29750, 0x00000CB0 }, /* GL_PIXEL_MAP_I_TO_I_SIZE */ - { 29775, 0x00000C72 }, /* GL_PIXEL_MAP_I_TO_R */ - { 29795, 0x00000CB2 }, /* GL_PIXEL_MAP_I_TO_R_SIZE */ - { 29820, 0x00000C76 }, /* GL_PIXEL_MAP_R_TO_R */ - { 29840, 0x00000CB6 }, /* GL_PIXEL_MAP_R_TO_R_SIZE */ - { 29865, 0x00000C71 }, /* GL_PIXEL_MAP_S_TO_S */ - { 29885, 0x00000CB1 }, /* GL_PIXEL_MAP_S_TO_S_SIZE */ - { 29910, 0x00000020 }, /* GL_PIXEL_MODE_BIT */ - { 29928, 0x000088EB }, /* GL_PIXEL_PACK_BUFFER */ - { 29949, 0x000088ED }, /* GL_PIXEL_PACK_BUFFER_BINDING */ - { 29978, 0x000088ED }, /* GL_PIXEL_PACK_BUFFER_BINDING_EXT */ - { 30011, 0x000088EB }, /* GL_PIXEL_PACK_BUFFER_EXT */ - { 30036, 0x000088EC }, /* GL_PIXEL_UNPACK_BUFFER */ - { 30059, 0x000088EF }, /* GL_PIXEL_UNPACK_BUFFER_BINDING */ - { 30090, 0x000088EF }, /* GL_PIXEL_UNPACK_BUFFER_BINDING_EXT */ - { 30125, 0x000088EC }, /* GL_PIXEL_UNPACK_BUFFER_EXT */ - { 30152, 0x00001B00 }, /* GL_POINT */ - { 30161, 0x00000000 }, /* GL_POINTS */ - { 30171, 0x00000002 }, /* GL_POINT_BIT */ - { 30184, 0x00008129 }, /* GL_POINT_DISTANCE_ATTENUATION */ - { 30214, 0x00008129 }, /* GL_POINT_DISTANCE_ATTENUATION_ARB */ - { 30248, 0x00008129 }, /* GL_POINT_DISTANCE_ATTENUATION_EXT */ - { 30282, 0x00008129 }, /* GL_POINT_DISTANCE_ATTENUATION_SGIS */ - { 30317, 0x00008128 }, /* GL_POINT_FADE_THRESHOLD_SIZE */ - { 30346, 0x00008128 }, /* GL_POINT_FADE_THRESHOLD_SIZE_ARB */ - { 30379, 0x00008128 }, /* GL_POINT_FADE_THRESHOLD_SIZE_EXT */ - { 30412, 0x00008128 }, /* GL_POINT_FADE_THRESHOLD_SIZE_SGIS */ - { 30446, 0x00000B11 }, /* GL_POINT_SIZE */ - { 30460, 0x00008B9F }, /* GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES */ - { 30499, 0x00008B9C }, /* GL_POINT_SIZE_ARRAY_OES */ - { 30523, 0x0000898C }, /* GL_POINT_SIZE_ARRAY_POINTER_OES */ - { 30555, 0x0000898B }, /* GL_POINT_SIZE_ARRAY_STRIDE_OES */ - { 30586, 0x0000898A }, /* GL_POINT_SIZE_ARRAY_TYPE_OES */ - { 30615, 0x00000B13 }, /* GL_POINT_SIZE_GRANULARITY */ - { 30641, 0x00008127 }, /* GL_POINT_SIZE_MAX */ - { 30659, 0x00008127 }, /* GL_POINT_SIZE_MAX_ARB */ - { 30681, 0x00008127 }, /* GL_POINT_SIZE_MAX_EXT */ - { 30703, 0x00008127 }, /* GL_POINT_SIZE_MAX_SGIS */ - { 30726, 0x00008126 }, /* GL_POINT_SIZE_MIN */ - { 30744, 0x00008126 }, /* GL_POINT_SIZE_MIN_ARB */ - { 30766, 0x00008126 }, /* GL_POINT_SIZE_MIN_EXT */ - { 30788, 0x00008126 }, /* GL_POINT_SIZE_MIN_SGIS */ - { 30811, 0x00000B12 }, /* GL_POINT_SIZE_RANGE */ - { 30831, 0x00000B10 }, /* GL_POINT_SMOOTH */ - { 30847, 0x00000C51 }, /* GL_POINT_SMOOTH_HINT */ - { 30868, 0x00008861 }, /* GL_POINT_SPRITE */ - { 30884, 0x00008861 }, /* GL_POINT_SPRITE_ARB */ - { 30904, 0x00008CA0 }, /* GL_POINT_SPRITE_COORD_ORIGIN */ - { 30933, 0x00008861 }, /* GL_POINT_SPRITE_NV */ - { 30952, 0x00008861 }, /* GL_POINT_SPRITE_OES */ - { 30972, 0x00008863 }, /* GL_POINT_SPRITE_R_MODE_NV */ - { 30998, 0x00000701 }, /* GL_POINT_TOKEN */ - { 31013, 0x00000009 }, /* GL_POLYGON */ - { 31024, 0x00000008 }, /* GL_POLYGON_BIT */ - { 31039, 0x00000B40 }, /* GL_POLYGON_MODE */ - { 31055, 0x00008039 }, /* GL_POLYGON_OFFSET_BIAS */ - { 31078, 0x00008038 }, /* GL_POLYGON_OFFSET_FACTOR */ - { 31103, 0x00008037 }, /* GL_POLYGON_OFFSET_FILL */ - { 31126, 0x00002A02 }, /* GL_POLYGON_OFFSET_LINE */ - { 31149, 0x00002A01 }, /* GL_POLYGON_OFFSET_POINT */ - { 31173, 0x00002A00 }, /* GL_POLYGON_OFFSET_UNITS */ - { 31197, 0x00000B41 }, /* GL_POLYGON_SMOOTH */ - { 31215, 0x00000C53 }, /* GL_POLYGON_SMOOTH_HINT */ - { 31238, 0x00000B42 }, /* GL_POLYGON_STIPPLE */ - { 31257, 0x00000010 }, /* GL_POLYGON_STIPPLE_BIT */ - { 31280, 0x00000703 }, /* GL_POLYGON_TOKEN */ - { 31297, 0x00001203 }, /* GL_POSITION */ - { 31309, 0x000080BB }, /* GL_POST_COLOR_MATRIX_ALPHA_BIAS */ - { 31341, 0x000080BB }, /* GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI */ - { 31377, 0x000080B7 }, /* GL_POST_COLOR_MATRIX_ALPHA_SCALE */ - { 31410, 0x000080B7 }, /* GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI */ - { 31447, 0x000080BA }, /* GL_POST_COLOR_MATRIX_BLUE_BIAS */ - { 31478, 0x000080BA }, /* GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI */ - { 31513, 0x000080B6 }, /* GL_POST_COLOR_MATRIX_BLUE_SCALE */ - { 31545, 0x000080B6 }, /* GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI */ - { 31581, 0x000080D2 }, /* GL_POST_COLOR_MATRIX_COLOR_TABLE */ - { 31614, 0x000080B9 }, /* GL_POST_COLOR_MATRIX_GREEN_BIAS */ - { 31646, 0x000080B9 }, /* GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI */ - { 31682, 0x000080B5 }, /* GL_POST_COLOR_MATRIX_GREEN_SCALE */ - { 31715, 0x000080B5 }, /* GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI */ - { 31752, 0x000080B8 }, /* GL_POST_COLOR_MATRIX_RED_BIAS */ - { 31782, 0x000080B8 }, /* GL_POST_COLOR_MATRIX_RED_BIAS_SGI */ - { 31816, 0x000080B4 }, /* GL_POST_COLOR_MATRIX_RED_SCALE */ - { 31847, 0x000080B4 }, /* GL_POST_COLOR_MATRIX_RED_SCALE_SGI */ - { 31882, 0x00008023 }, /* GL_POST_CONVOLUTION_ALPHA_BIAS */ - { 31913, 0x00008023 }, /* GL_POST_CONVOLUTION_ALPHA_BIAS_EXT */ - { 31948, 0x0000801F }, /* GL_POST_CONVOLUTION_ALPHA_SCALE */ - { 31980, 0x0000801F }, /* GL_POST_CONVOLUTION_ALPHA_SCALE_EXT */ - { 32016, 0x00008022 }, /* GL_POST_CONVOLUTION_BLUE_BIAS */ - { 32046, 0x00008022 }, /* GL_POST_CONVOLUTION_BLUE_BIAS_EXT */ - { 32080, 0x0000801E }, /* GL_POST_CONVOLUTION_BLUE_SCALE */ - { 32111, 0x0000801E }, /* GL_POST_CONVOLUTION_BLUE_SCALE_EXT */ - { 32146, 0x000080D1 }, /* GL_POST_CONVOLUTION_COLOR_TABLE */ - { 32178, 0x00008021 }, /* GL_POST_CONVOLUTION_GREEN_BIAS */ - { 32209, 0x00008021 }, /* GL_POST_CONVOLUTION_GREEN_BIAS_EXT */ - { 32244, 0x0000801D }, /* GL_POST_CONVOLUTION_GREEN_SCALE */ - { 32276, 0x0000801D }, /* GL_POST_CONVOLUTION_GREEN_SCALE_EXT */ - { 32312, 0x00008020 }, /* GL_POST_CONVOLUTION_RED_BIAS */ - { 32341, 0x00008020 }, /* GL_POST_CONVOLUTION_RED_BIAS_EXT */ - { 32374, 0x0000801C }, /* GL_POST_CONVOLUTION_RED_SCALE */ - { 32404, 0x0000801C }, /* GL_POST_CONVOLUTION_RED_SCALE_EXT */ - { 32438, 0x0000817B }, /* GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX */ - { 32477, 0x00008179 }, /* GL_POST_TEXTURE_FILTER_BIAS_SGIX */ - { 32510, 0x0000817C }, /* GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX */ - { 32550, 0x0000817A }, /* GL_POST_TEXTURE_FILTER_SCALE_SGIX */ - { 32584, 0x00008578 }, /* GL_PREVIOUS */ - { 32596, 0x00008578 }, /* GL_PREVIOUS_ARB */ - { 32612, 0x00008578 }, /* GL_PREVIOUS_EXT */ - { 32628, 0x00008577 }, /* GL_PRIMARY_COLOR */ - { 32645, 0x00008577 }, /* GL_PRIMARY_COLOR_ARB */ - { 32666, 0x00008577 }, /* GL_PRIMARY_COLOR_EXT */ - { 32687, 0x00008C87 }, /* GL_PRIMITIVES_GENERATED */ - { 32711, 0x00008C87 }, /* GL_PRIMITIVES_GENERATED_EXT */ - { 32739, 0x00008F9D }, /* GL_PRIMITIVE_RESTART */ - { 32760, 0x00008F9E }, /* GL_PRIMITIVE_RESTART_INDEX */ - { 32787, 0x00008559 }, /* GL_PRIMITIVE_RESTART_INDEX_NV */ - { 32817, 0x00008558 }, /* GL_PRIMITIVE_RESTART_NV */ - { 32841, 0x000088B0 }, /* GL_PROGRAM_ADDRESS_REGISTERS_ARB */ - { 32874, 0x00008805 }, /* GL_PROGRAM_ALU_INSTRUCTIONS_ARB */ - { 32906, 0x000088AC }, /* GL_PROGRAM_ATTRIBS_ARB */ - { 32929, 0x000087FF }, /* GL_PROGRAM_BINARY_FORMATS */ - { 32955, 0x000087FF }, /* GL_PROGRAM_BINARY_FORMATS_OES */ - { 32985, 0x00008741 }, /* GL_PROGRAM_BINARY_LENGTH */ - { 33010, 0x00008741 }, /* GL_PROGRAM_BINARY_LENGTH_OES */ - { 33039, 0x00008257 }, /* GL_PROGRAM_BINARY_RETRIEVABLE_HINT */ - { 33074, 0x00008677 }, /* GL_PROGRAM_BINDING_ARB */ - { 33097, 0x0000864B }, /* GL_PROGRAM_ERROR_POSITION_ARB */ - { 33127, 0x0000864B }, /* GL_PROGRAM_ERROR_POSITION_NV */ - { 33156, 0x00008874 }, /* GL_PROGRAM_ERROR_STRING_ARB */ - { 33184, 0x00008876 }, /* GL_PROGRAM_FORMAT_ARB */ - { 33206, 0x00008875 }, /* GL_PROGRAM_FORMAT_ASCII_ARB */ - { 33234, 0x000088A0 }, /* GL_PROGRAM_INSTRUCTIONS_ARB */ - { 33262, 0x00008627 }, /* GL_PROGRAM_LENGTH_ARB */ - { 33284, 0x00008627 }, /* GL_PROGRAM_LENGTH_NV */ - { 33305, 0x000088B2 }, /* GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB */ - { 33345, 0x00008808 }, /* GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB */ - { 33384, 0x000088AE }, /* GL_PROGRAM_NATIVE_ATTRIBS_ARB */ - { 33414, 0x000088A2 }, /* GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB */ - { 33449, 0x000088AA }, /* GL_PROGRAM_NATIVE_PARAMETERS_ARB */ - { 33482, 0x000088A6 }, /* GL_PROGRAM_NATIVE_TEMPORARIES_ARB */ - { 33516, 0x0000880A }, /* GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB */ - { 33555, 0x00008809 }, /* GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB */ - { 33594, 0x00008B40 }, /* GL_PROGRAM_OBJECT_ARB */ - { 33616, 0x000088A8 }, /* GL_PROGRAM_PARAMETERS_ARB */ - { 33642, 0x00008644 }, /* GL_PROGRAM_PARAMETER_NV */ - { 33666, 0x00008642 }, /* GL_PROGRAM_POINT_SIZE */ - { 33688, 0x00008642 }, /* GL_PROGRAM_POINT_SIZE_ARB */ - { 33714, 0x00008647 }, /* GL_PROGRAM_RESIDENT_NV */ - { 33737, 0x00008628 }, /* GL_PROGRAM_STRING_ARB */ - { 33759, 0x00008628 }, /* GL_PROGRAM_STRING_NV */ - { 33780, 0x00008646 }, /* GL_PROGRAM_TARGET_NV */ - { 33801, 0x000088A4 }, /* GL_PROGRAM_TEMPORARIES_ARB */ - { 33828, 0x00008807 }, /* GL_PROGRAM_TEX_INDIRECTIONS_ARB */ - { 33860, 0x00008806 }, /* GL_PROGRAM_TEX_INSTRUCTIONS_ARB */ - { 33892, 0x000088B6 }, /* GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB */ - { 33927, 0x00001701 }, /* GL_PROJECTION */ - { 33941, 0x00000BA7 }, /* GL_PROJECTION_MATRIX */ - { 33962, 0x0000898E }, /* GL_PROJECTION_MATRIX_FLOAT_AS_INT_BITS_OES */ - { 34005, 0x00000BA4 }, /* GL_PROJECTION_STACK_DEPTH */ - { 34031, 0x00008E4F }, /* GL_PROVOKING_VERTEX */ - { 34051, 0x00008E4F }, /* GL_PROVOKING_VERTEX_EXT */ - { 34075, 0x000080D3 }, /* GL_PROXY_COLOR_TABLE */ - { 34096, 0x00008025 }, /* GL_PROXY_HISTOGRAM */ - { 34115, 0x00008025 }, /* GL_PROXY_HISTOGRAM_EXT */ - { 34138, 0x000080D5 }, /* GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE */ - { 34177, 0x000080D4 }, /* GL_PROXY_POST_CONVOLUTION_COLOR_TABLE */ - { 34215, 0x00008063 }, /* GL_PROXY_TEXTURE_1D */ - { 34235, 0x00008C19 }, /* GL_PROXY_TEXTURE_1D_ARRAY */ - { 34261, 0x00008C19 }, /* GL_PROXY_TEXTURE_1D_ARRAY_EXT */ - { 34291, 0x00008063 }, /* GL_PROXY_TEXTURE_1D_EXT */ - { 34315, 0x00008064 }, /* GL_PROXY_TEXTURE_2D */ - { 34335, 0x00008C1B }, /* GL_PROXY_TEXTURE_2D_ARRAY */ - { 34361, 0x00008C1B }, /* GL_PROXY_TEXTURE_2D_ARRAY_EXT */ - { 34391, 0x00008064 }, /* GL_PROXY_TEXTURE_2D_EXT */ - { 34415, 0x00008070 }, /* GL_PROXY_TEXTURE_3D */ - { 34435, 0x000080BD }, /* GL_PROXY_TEXTURE_COLOR_TABLE_SGI */ - { 34468, 0x0000851B }, /* GL_PROXY_TEXTURE_CUBE_MAP */ - { 34494, 0x0000851B }, /* GL_PROXY_TEXTURE_CUBE_MAP_ARB */ - { 34524, 0x000084F7 }, /* GL_PROXY_TEXTURE_RECTANGLE */ - { 34551, 0x000084F7 }, /* GL_PROXY_TEXTURE_RECTANGLE_ARB */ - { 34582, 0x000084F7 }, /* GL_PROXY_TEXTURE_RECTANGLE_NV */ - { 34612, 0x00008A1D }, /* GL_PURGEABLE_APPLE */ - { 34631, 0x00002003 }, /* GL_Q */ - { 34636, 0x00001209 }, /* GL_QUADRATIC_ATTENUATION */ - { 34661, 0x00000007 }, /* GL_QUADS */ - { 34670, 0x00008E4C }, /* GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION */ - { 34714, 0x00008E4C }, /* GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT */ - { 34762, 0x00008614 }, /* GL_QUAD_MESH_SUN */ - { 34779, 0x00000008 }, /* GL_QUAD_STRIP */ - { 34793, 0x00008E16 }, /* GL_QUERY_BY_REGION_NO_WAIT */ - { 34820, 0x00008E16 }, /* GL_QUERY_BY_REGION_NO_WAIT_NV */ - { 34850, 0x00008E15 }, /* GL_QUERY_BY_REGION_WAIT */ - { 34874, 0x00008E15 }, /* GL_QUERY_BY_REGION_WAIT_NV */ - { 34901, 0x00008864 }, /* GL_QUERY_COUNTER_BITS */ - { 34923, 0x00008864 }, /* GL_QUERY_COUNTER_BITS_ARB */ - { 34949, 0x00008E14 }, /* GL_QUERY_NO_WAIT */ - { 34966, 0x00008E14 }, /* GL_QUERY_NO_WAIT_NV */ - { 34986, 0x00008866 }, /* GL_QUERY_RESULT */ - { 35002, 0x00008866 }, /* GL_QUERY_RESULT_ARB */ - { 35022, 0x00008867 }, /* GL_QUERY_RESULT_AVAILABLE */ - { 35048, 0x00008867 }, /* GL_QUERY_RESULT_AVAILABLE_ARB */ - { 35078, 0x00008E13 }, /* GL_QUERY_WAIT */ - { 35092, 0x00008E13 }, /* GL_QUERY_WAIT_NV */ - { 35109, 0x00002002 }, /* GL_R */ - { 35114, 0x00008C3A }, /* GL_R11F_G11F_B10F */ - { 35132, 0x00008F98 }, /* GL_R16_SNORM */ - { 35145, 0x00002A10 }, /* GL_R3_G3_B2 */ - { 35157, 0x00008F94 }, /* GL_R8_SNORM */ - { 35169, 0x00008C89 }, /* GL_RASTERIZER_DISCARD */ - { 35191, 0x00008C89 }, /* GL_RASTERIZER_DISCARD_EXT */ - { 35217, 0x00019262 }, /* GL_RASTER_POSITION_UNCLIPPED_IBM */ - { 35250, 0x00000C02 }, /* GL_READ_BUFFER */ - { 35265, 0x00008CA8 }, /* GL_READ_FRAMEBUFFER */ - { 35285, 0x00008CAA }, /* GL_READ_FRAMEBUFFER_BINDING */ - { 35313, 0x00008CAA }, /* GL_READ_FRAMEBUFFER_BINDING_EXT */ - { 35345, 0x00008CA8 }, /* GL_READ_FRAMEBUFFER_EXT */ - { 35369, 0x000088B8 }, /* GL_READ_ONLY */ - { 35382, 0x000088B8 }, /* GL_READ_ONLY_ARB */ - { 35399, 0x000088BA }, /* GL_READ_WRITE */ - { 35413, 0x000088BA }, /* GL_READ_WRITE_ARB */ - { 35431, 0x00001903 }, /* GL_RED */ - { 35438, 0x00008016 }, /* GL_REDUCE */ - { 35448, 0x00008016 }, /* GL_REDUCE_EXT */ - { 35462, 0x00000D15 }, /* GL_RED_BIAS */ - { 35474, 0x00000D52 }, /* GL_RED_BITS */ - { 35486, 0x00008D94 }, /* GL_RED_INTEGER */ - { 35501, 0x00008D94 }, /* GL_RED_INTEGER_EXT */ - { 35520, 0x00000D14 }, /* GL_RED_SCALE */ - { 35533, 0x00008F90 }, /* GL_RED_SNORM */ - { 35546, 0x00008512 }, /* GL_REFLECTION_MAP */ - { 35564, 0x00008512 }, /* GL_REFLECTION_MAP_ARB */ - { 35586, 0x00008512 }, /* GL_REFLECTION_MAP_NV */ - { 35607, 0x00008512 }, /* GL_REFLECTION_MAP_OES */ - { 35629, 0x00008A19 }, /* GL_RELEASED_APPLE */ - { 35647, 0x00001C00 }, /* GL_RENDER */ - { 35657, 0x00008D41 }, /* GL_RENDERBUFFER */ - { 35673, 0x00008D53 }, /* GL_RENDERBUFFER_ALPHA_SIZE */ - { 35700, 0x00008D53 }, /* GL_RENDERBUFFER_ALPHA_SIZE_OES */ - { 35731, 0x00008CA7 }, /* GL_RENDERBUFFER_BINDING */ - { 35755, 0x00008CA7 }, /* GL_RENDERBUFFER_BINDING_EXT */ - { 35783, 0x00008CA7 }, /* GL_RENDERBUFFER_BINDING_OES */ - { 35811, 0x00008D52 }, /* GL_RENDERBUFFER_BLUE_SIZE */ - { 35837, 0x00008D52 }, /* GL_RENDERBUFFER_BLUE_SIZE_OES */ - { 35867, 0x00008D54 }, /* GL_RENDERBUFFER_DEPTH_SIZE */ - { 35894, 0x00008D54 }, /* GL_RENDERBUFFER_DEPTH_SIZE_OES */ - { 35925, 0x00008D41 }, /* GL_RENDERBUFFER_EXT */ - { 35945, 0x00008D51 }, /* GL_RENDERBUFFER_GREEN_SIZE */ - { 35972, 0x00008D51 }, /* GL_RENDERBUFFER_GREEN_SIZE_OES */ - { 36003, 0x00008D43 }, /* GL_RENDERBUFFER_HEIGHT */ - { 36026, 0x00008D43 }, /* GL_RENDERBUFFER_HEIGHT_EXT */ - { 36053, 0x00008D43 }, /* GL_RENDERBUFFER_HEIGHT_OES */ - { 36080, 0x00008D44 }, /* GL_RENDERBUFFER_INTERNAL_FORMAT */ - { 36112, 0x00008D44 }, /* GL_RENDERBUFFER_INTERNAL_FORMAT_EXT */ - { 36148, 0x00008D44 }, /* GL_RENDERBUFFER_INTERNAL_FORMAT_OES */ - { 36184, 0x00008D41 }, /* GL_RENDERBUFFER_OES */ - { 36204, 0x00008D50 }, /* GL_RENDERBUFFER_RED_SIZE */ - { 36229, 0x00008D50 }, /* GL_RENDERBUFFER_RED_SIZE_OES */ - { 36258, 0x00008CAB }, /* GL_RENDERBUFFER_SAMPLES */ - { 36282, 0x00008CAB }, /* GL_RENDERBUFFER_SAMPLES_EXT */ - { 36310, 0x00008D55 }, /* GL_RENDERBUFFER_STENCIL_SIZE */ - { 36339, 0x00008D55 }, /* GL_RENDERBUFFER_STENCIL_SIZE_OES */ - { 36372, 0x00008D42 }, /* GL_RENDERBUFFER_WIDTH */ - { 36394, 0x00008D42 }, /* GL_RENDERBUFFER_WIDTH_EXT */ - { 36420, 0x00008D42 }, /* GL_RENDERBUFFER_WIDTH_OES */ - { 36446, 0x00001F01 }, /* GL_RENDERER */ - { 36458, 0x00000C40 }, /* GL_RENDER_MODE */ - { 36473, 0x00002901 }, /* GL_REPEAT */ - { 36483, 0x00001E01 }, /* GL_REPLACE */ - { 36494, 0x00008062 }, /* GL_REPLACE_EXT */ - { 36509, 0x00008153 }, /* GL_REPLICATE_BORDER_HP */ - { 36532, 0x0000803A }, /* GL_RESCALE_NORMAL */ - { 36550, 0x0000803A }, /* GL_RESCALE_NORMAL_EXT */ - { 36572, 0x00008256 }, /* GL_RESET_NOTIFICATION_STRATEGY_ARB */ - { 36607, 0x00008A1B }, /* GL_RETAINED_APPLE */ - { 36625, 0x00000102 }, /* GL_RETURN */ - { 36635, 0x00008F99 }, /* GL_RG16_SNORM */ - { 36649, 0x00008F95 }, /* GL_RG8_SNORM */ - { 36662, 0x00001907 }, /* GL_RGB */ - { 36669, 0x00008052 }, /* GL_RGB10 */ - { 36678, 0x00008059 }, /* GL_RGB10_A2 */ - { 36690, 0x00008059 }, /* GL_RGB10_A2_EXT */ - { 36706, 0x00008052 }, /* GL_RGB10_EXT */ - { 36719, 0x00008053 }, /* GL_RGB12 */ - { 36728, 0x00008053 }, /* GL_RGB12_EXT */ - { 36741, 0x00008054 }, /* GL_RGB16 */ - { 36750, 0x0000881B }, /* GL_RGB16F */ - { 36760, 0x00008D89 }, /* GL_RGB16I */ - { 36770, 0x00008D89 }, /* GL_RGB16I_EXT */ - { 36784, 0x00008D77 }, /* GL_RGB16UI */ - { 36795, 0x00008D77 }, /* GL_RGB16UI_EXT */ - { 36810, 0x00008054 }, /* GL_RGB16_EXT */ - { 36823, 0x00008F9A }, /* GL_RGB16_SNORM */ - { 36838, 0x0000804E }, /* GL_RGB2_EXT */ - { 36850, 0x00008815 }, /* GL_RGB32F */ - { 36860, 0x00008D83 }, /* GL_RGB32I */ - { 36870, 0x00008D83 }, /* GL_RGB32I_EXT */ - { 36884, 0x00008D71 }, /* GL_RGB32UI */ - { 36895, 0x00008D71 }, /* GL_RGB32UI_EXT */ - { 36910, 0x0000804F }, /* GL_RGB4 */ - { 36918, 0x0000804F }, /* GL_RGB4_EXT */ - { 36930, 0x000083A1 }, /* GL_RGB4_S3TC */ - { 36943, 0x00008050 }, /* GL_RGB5 */ - { 36951, 0x00008D62 }, /* GL_RGB565 */ - { 36961, 0x00008D62 }, /* GL_RGB565_OES */ - { 36975, 0x00008057 }, /* GL_RGB5_A1 */ - { 36986, 0x00008057 }, /* GL_RGB5_A1_EXT */ - { 37001, 0x00008057 }, /* GL_RGB5_A1_OES */ - { 37016, 0x00008050 }, /* GL_RGB5_EXT */ - { 37028, 0x00008051 }, /* GL_RGB8 */ - { 37036, 0x00008D8F }, /* GL_RGB8I */ - { 37045, 0x00008D8F }, /* GL_RGB8I_EXT */ - { 37058, 0x00008D7D }, /* GL_RGB8UI */ - { 37068, 0x00008D7D }, /* GL_RGB8UI_EXT */ - { 37082, 0x00008051 }, /* GL_RGB8_EXT */ - { 37094, 0x00008051 }, /* GL_RGB8_OES */ - { 37106, 0x00008F96 }, /* GL_RGB8_SNORM */ - { 37120, 0x00008C3D }, /* GL_RGB9_E5 */ - { 37131, 0x00001908 }, /* GL_RGBA */ - { 37139, 0x0000805A }, /* GL_RGBA12 */ - { 37149, 0x0000805A }, /* GL_RGBA12_EXT */ - { 37163, 0x0000805B }, /* GL_RGBA16 */ - { 37173, 0x0000881A }, /* GL_RGBA16F */ - { 37184, 0x00008D88 }, /* GL_RGBA16I */ - { 37195, 0x00008D88 }, /* GL_RGBA16I_EXT */ - { 37210, 0x00008D76 }, /* GL_RGBA16UI */ - { 37222, 0x00008D76 }, /* GL_RGBA16UI_EXT */ - { 37238, 0x0000805B }, /* GL_RGBA16_EXT */ - { 37252, 0x00008F9B }, /* GL_RGBA16_SNORM */ - { 37268, 0x00008055 }, /* GL_RGBA2 */ - { 37277, 0x00008055 }, /* GL_RGBA2_EXT */ - { 37290, 0x00008814 }, /* GL_RGBA32F */ - { 37301, 0x00008D82 }, /* GL_RGBA32I */ - { 37312, 0x00008D82 }, /* GL_RGBA32I_EXT */ - { 37327, 0x00008D70 }, /* GL_RGBA32UI */ - { 37339, 0x00008D70 }, /* GL_RGBA32UI_EXT */ - { 37355, 0x00008056 }, /* GL_RGBA4 */ - { 37364, 0x000083A5 }, /* GL_RGBA4_DXT5_S3TC */ - { 37383, 0x00008056 }, /* GL_RGBA4_EXT */ - { 37396, 0x00008056 }, /* GL_RGBA4_OES */ - { 37409, 0x000083A3 }, /* GL_RGBA4_S3TC */ - { 37423, 0x00008058 }, /* GL_RGBA8 */ - { 37432, 0x00008D8E }, /* GL_RGBA8I */ - { 37442, 0x00008D8E }, /* GL_RGBA8I_EXT */ - { 37456, 0x00008D7C }, /* GL_RGBA8UI */ - { 37467, 0x00008D7C }, /* GL_RGBA8UI_EXT */ - { 37482, 0x00008058 }, /* GL_RGBA8_EXT */ - { 37495, 0x00008058 }, /* GL_RGBA8_OES */ - { 37508, 0x00008F97 }, /* GL_RGBA8_SNORM */ - { 37523, 0x000083A4 }, /* GL_RGBA_DXT5_S3TC */ - { 37541, 0x00008820 }, /* GL_RGBA_FLOAT_MODE_ARB */ - { 37564, 0x00008D99 }, /* GL_RGBA_INTEGER */ - { 37580, 0x00008D99 }, /* GL_RGBA_INTEGER_EXT */ - { 37600, 0x00008D9E }, /* GL_RGBA_INTEGER_MODE_EXT */ - { 37625, 0x00000C31 }, /* GL_RGBA_MODE */ - { 37638, 0x000083A2 }, /* GL_RGBA_S3TC */ - { 37651, 0x00008F93 }, /* GL_RGBA_SNORM */ - { 37665, 0x00008D98 }, /* GL_RGB_INTEGER */ - { 37680, 0x00008D98 }, /* GL_RGB_INTEGER_EXT */ - { 37699, 0x000083A0 }, /* GL_RGB_S3TC */ - { 37711, 0x00008573 }, /* GL_RGB_SCALE */ - { 37724, 0x00008573 }, /* GL_RGB_SCALE_ARB */ - { 37741, 0x00008573 }, /* GL_RGB_SCALE_EXT */ - { 37758, 0x00008F92 }, /* GL_RGB_SNORM */ - { 37771, 0x00008F91 }, /* GL_RG_SNORM */ - { 37783, 0x00000407 }, /* GL_RIGHT */ - { 37792, 0x00002000 }, /* GL_S */ - { 37797, 0x00008B5D }, /* GL_SAMPLER_1D */ - { 37811, 0x00008DC0 }, /* GL_SAMPLER_1D_ARRAY */ - { 37831, 0x00008DC0 }, /* GL_SAMPLER_1D_ARRAY_EXT */ - { 37855, 0x00008DC3 }, /* GL_SAMPLER_1D_ARRAY_SHADOW */ - { 37882, 0x00008DC3 }, /* GL_SAMPLER_1D_ARRAY_SHADOW_EXT */ - { 37913, 0x00008B61 }, /* GL_SAMPLER_1D_SHADOW */ - { 37934, 0x00008B5E }, /* GL_SAMPLER_2D */ - { 37948, 0x00008DC1 }, /* GL_SAMPLER_2D_ARRAY */ - { 37968, 0x00008DC1 }, /* GL_SAMPLER_2D_ARRAY_EXT */ - { 37992, 0x00008DC4 }, /* GL_SAMPLER_2D_ARRAY_SHADOW */ - { 38019, 0x00008DC4 }, /* GL_SAMPLER_2D_ARRAY_SHADOW_EXT */ - { 38050, 0x00008B63 }, /* GL_SAMPLER_2D_RECT */ - { 38069, 0x00008B64 }, /* GL_SAMPLER_2D_RECT_SHADOW */ - { 38095, 0x00008B62 }, /* GL_SAMPLER_2D_SHADOW */ - { 38116, 0x00008B5F }, /* GL_SAMPLER_3D */ - { 38130, 0x00008B5F }, /* GL_SAMPLER_3D_OES */ - { 38148, 0x00008919 }, /* GL_SAMPLER_BINDING */ - { 38167, 0x00008DC2 }, /* GL_SAMPLER_BUFFER */ - { 38185, 0x00008DC2 }, /* GL_SAMPLER_BUFFER_EXT */ - { 38207, 0x00008B60 }, /* GL_SAMPLER_CUBE */ - { 38223, 0x00008DC5 }, /* GL_SAMPLER_CUBE_SHADOW */ - { 38246, 0x00008DC5 }, /* GL_SAMPLER_CUBE_SHADOW_EXT */ - { 38273, 0x000080A9 }, /* GL_SAMPLES */ - { 38284, 0x000086B4 }, /* GL_SAMPLES_3DFX */ - { 38300, 0x000080A9 }, /* GL_SAMPLES_ARB */ - { 38315, 0x00008914 }, /* GL_SAMPLES_PASSED */ - { 38333, 0x00008914 }, /* GL_SAMPLES_PASSED_ARB */ - { 38355, 0x0000809E }, /* GL_SAMPLE_ALPHA_TO_COVERAGE */ - { 38383, 0x0000809E }, /* GL_SAMPLE_ALPHA_TO_COVERAGE_ARB */ - { 38415, 0x0000809F }, /* GL_SAMPLE_ALPHA_TO_ONE */ - { 38438, 0x0000809F }, /* GL_SAMPLE_ALPHA_TO_ONE_ARB */ - { 38465, 0x000080A8 }, /* GL_SAMPLE_BUFFERS */ - { 38483, 0x000086B3 }, /* GL_SAMPLE_BUFFERS_3DFX */ - { 38506, 0x000080A8 }, /* GL_SAMPLE_BUFFERS_ARB */ - { 38528, 0x000080A0 }, /* GL_SAMPLE_COVERAGE */ - { 38547, 0x000080A0 }, /* GL_SAMPLE_COVERAGE_ARB */ - { 38570, 0x000080AB }, /* GL_SAMPLE_COVERAGE_INVERT */ - { 38596, 0x000080AB }, /* GL_SAMPLE_COVERAGE_INVERT_ARB */ - { 38626, 0x000080AA }, /* GL_SAMPLE_COVERAGE_VALUE */ - { 38651, 0x000080AA }, /* GL_SAMPLE_COVERAGE_VALUE_ARB */ - { 38680, 0x00080000 }, /* GL_SCISSOR_BIT */ - { 38695, 0x00000C10 }, /* GL_SCISSOR_BOX */ - { 38710, 0x00000C11 }, /* GL_SCISSOR_TEST */ - { 38726, 0x0000845E }, /* GL_SECONDARY_COLOR_ARRAY */ - { 38751, 0x0000889C }, /* GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING */ - { 38791, 0x0000889C }, /* GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB */ - { 38835, 0x0000845D }, /* GL_SECONDARY_COLOR_ARRAY_POINTER */ - { 38868, 0x0000845A }, /* GL_SECONDARY_COLOR_ARRAY_SIZE */ - { 38898, 0x0000845C }, /* GL_SECONDARY_COLOR_ARRAY_STRIDE */ - { 38930, 0x0000845B }, /* GL_SECONDARY_COLOR_ARRAY_TYPE */ - { 38960, 0x00001C02 }, /* GL_SELECT */ - { 38970, 0x00000DF3 }, /* GL_SELECTION_BUFFER_POINTER */ - { 38998, 0x00000DF4 }, /* GL_SELECTION_BUFFER_SIZE */ - { 39023, 0x00008012 }, /* GL_SEPARABLE_2D */ - { 39039, 0x00008C8D }, /* GL_SEPARATE_ATTRIBS */ - { 39059, 0x00008C8D }, /* GL_SEPARATE_ATTRIBS_EXT */ - { 39083, 0x000081FA }, /* GL_SEPARATE_SPECULAR_COLOR */ - { 39110, 0x000081FA }, /* GL_SEPARATE_SPECULAR_COLOR_EXT */ - { 39141, 0x0000150F }, /* GL_SET */ - { 39148, 0x00008DF8 }, /* GL_SHADER_BINARY_FORMATS */ - { 39173, 0x00008DFA }, /* GL_SHADER_COMPILER */ - { 39192, 0x00008B48 }, /* GL_SHADER_OBJECT_ARB */ - { 39213, 0x00008B88 }, /* GL_SHADER_SOURCE_LENGTH */ - { 39237, 0x00008B4F }, /* GL_SHADER_TYPE */ - { 39252, 0x00000B54 }, /* GL_SHADE_MODEL */ - { 39267, 0x00008B8C }, /* GL_SHADING_LANGUAGE_VERSION */ - { 39295, 0x000080BF }, /* GL_SHADOW_AMBIENT_SGIX */ - { 39318, 0x000081FB }, /* GL_SHARED_TEXTURE_PALETTE_EXT */ - { 39348, 0x00001601 }, /* GL_SHININESS */ - { 39361, 0x00001402 }, /* GL_SHORT */ - { 39370, 0x00009119 }, /* GL_SIGNALED */ - { 39382, 0x00008F9C }, /* GL_SIGNED_NORMALIZED */ - { 39403, 0x000081F9 }, /* GL_SINGLE_COLOR */ - { 39419, 0x000081F9 }, /* GL_SINGLE_COLOR_EXT */ - { 39439, 0x000085CC }, /* GL_SLICE_ACCUM_SUN */ - { 39458, 0x00008C46 }, /* GL_SLUMINANCE */ - { 39472, 0x00008C47 }, /* GL_SLUMINANCE8 */ - { 39487, 0x00008C45 }, /* GL_SLUMINANCE8_ALPHA8 */ - { 39509, 0x00008C44 }, /* GL_SLUMINANCE_ALPHA */ - { 39529, 0x00001D01 }, /* GL_SMOOTH */ - { 39539, 0x00000B23 }, /* GL_SMOOTH_LINE_WIDTH_GRANULARITY */ - { 39572, 0x00000B22 }, /* GL_SMOOTH_LINE_WIDTH_RANGE */ - { 39599, 0x00000B13 }, /* GL_SMOOTH_POINT_SIZE_GRANULARITY */ - { 39632, 0x00000B12 }, /* GL_SMOOTH_POINT_SIZE_RANGE */ - { 39659, 0x00008588 }, /* GL_SOURCE0_ALPHA */ - { 39676, 0x00008588 }, /* GL_SOURCE0_ALPHA_ARB */ - { 39697, 0x00008588 }, /* GL_SOURCE0_ALPHA_EXT */ - { 39718, 0x00008580 }, /* GL_SOURCE0_RGB */ - { 39733, 0x00008580 }, /* GL_SOURCE0_RGB_ARB */ - { 39752, 0x00008580 }, /* GL_SOURCE0_RGB_EXT */ - { 39771, 0x00008589 }, /* GL_SOURCE1_ALPHA */ - { 39788, 0x00008589 }, /* GL_SOURCE1_ALPHA_ARB */ - { 39809, 0x00008589 }, /* GL_SOURCE1_ALPHA_EXT */ - { 39830, 0x00008581 }, /* GL_SOURCE1_RGB */ - { 39845, 0x00008581 }, /* GL_SOURCE1_RGB_ARB */ - { 39864, 0x00008581 }, /* GL_SOURCE1_RGB_EXT */ - { 39883, 0x0000858A }, /* GL_SOURCE2_ALPHA */ - { 39900, 0x0000858A }, /* GL_SOURCE2_ALPHA_ARB */ - { 39921, 0x0000858A }, /* GL_SOURCE2_ALPHA_EXT */ - { 39942, 0x00008582 }, /* GL_SOURCE2_RGB */ - { 39957, 0x00008582 }, /* GL_SOURCE2_RGB_ARB */ - { 39976, 0x00008582 }, /* GL_SOURCE2_RGB_EXT */ - { 39995, 0x0000858B }, /* GL_SOURCE3_ALPHA_NV */ - { 40015, 0x00008583 }, /* GL_SOURCE3_RGB_NV */ - { 40033, 0x00001202 }, /* GL_SPECULAR */ - { 40045, 0x00002402 }, /* GL_SPHERE_MAP */ - { 40059, 0x00001206 }, /* GL_SPOT_CUTOFF */ - { 40074, 0x00001204 }, /* GL_SPOT_DIRECTION */ - { 40092, 0x00001205 }, /* GL_SPOT_EXPONENT */ - { 40109, 0x00008588 }, /* GL_SRC0_ALPHA */ - { 40123, 0x00008580 }, /* GL_SRC0_RGB */ - { 40135, 0x00008589 }, /* GL_SRC1_ALPHA */ - { 40149, 0x00008581 }, /* GL_SRC1_RGB */ - { 40161, 0x0000858A }, /* GL_SRC2_ALPHA */ - { 40175, 0x00008582 }, /* GL_SRC2_RGB */ - { 40187, 0x00000302 }, /* GL_SRC_ALPHA */ - { 40200, 0x00000308 }, /* GL_SRC_ALPHA_SATURATE */ - { 40222, 0x00000300 }, /* GL_SRC_COLOR */ - { 40235, 0x00008C40 }, /* GL_SRGB */ - { 40243, 0x00008C41 }, /* GL_SRGB8 */ - { 40252, 0x00008C43 }, /* GL_SRGB8_ALPHA8 */ - { 40268, 0x00008C42 }, /* GL_SRGB_ALPHA */ - { 40282, 0x00000503 }, /* GL_STACK_OVERFLOW */ - { 40300, 0x00000504 }, /* GL_STACK_UNDERFLOW */ - { 40319, 0x000088E6 }, /* GL_STATIC_COPY */ - { 40334, 0x000088E6 }, /* GL_STATIC_COPY_ARB */ - { 40353, 0x000088E4 }, /* GL_STATIC_DRAW */ - { 40368, 0x000088E4 }, /* GL_STATIC_DRAW_ARB */ - { 40387, 0x000088E5 }, /* GL_STATIC_READ */ - { 40402, 0x000088E5 }, /* GL_STATIC_READ_ARB */ - { 40421, 0x00001802 }, /* GL_STENCIL */ - { 40432, 0x00008D20 }, /* GL_STENCIL_ATTACHMENT */ - { 40454, 0x00008D20 }, /* GL_STENCIL_ATTACHMENT_EXT */ - { 40480, 0x00008D20 }, /* GL_STENCIL_ATTACHMENT_OES */ - { 40506, 0x00008801 }, /* GL_STENCIL_BACK_FAIL */ - { 40527, 0x00008801 }, /* GL_STENCIL_BACK_FAIL_ATI */ - { 40552, 0x00008800 }, /* GL_STENCIL_BACK_FUNC */ - { 40573, 0x00008800 }, /* GL_STENCIL_BACK_FUNC_ATI */ - { 40598, 0x00008802 }, /* GL_STENCIL_BACK_PASS_DEPTH_FAIL */ - { 40630, 0x00008802 }, /* GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI */ - { 40666, 0x00008803 }, /* GL_STENCIL_BACK_PASS_DEPTH_PASS */ - { 40698, 0x00008803 }, /* GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI */ - { 40734, 0x00008CA3 }, /* GL_STENCIL_BACK_REF */ - { 40754, 0x00008CA4 }, /* GL_STENCIL_BACK_VALUE_MASK */ - { 40781, 0x00008CA5 }, /* GL_STENCIL_BACK_WRITEMASK */ - { 40807, 0x00000D57 }, /* GL_STENCIL_BITS */ - { 40823, 0x00008224 }, /* GL_STENCIL_BUFFER */ - { 40841, 0x00000400 }, /* GL_STENCIL_BUFFER_BIT */ - { 40863, 0x00000B91 }, /* GL_STENCIL_CLEAR_VALUE */ - { 40886, 0x00000B94 }, /* GL_STENCIL_FAIL */ - { 40902, 0x00000B92 }, /* GL_STENCIL_FUNC */ - { 40918, 0x00001901 }, /* GL_STENCIL_INDEX */ - { 40935, 0x00008D46 }, /* GL_STENCIL_INDEX1 */ - { 40953, 0x00008D49 }, /* GL_STENCIL_INDEX16 */ - { 40972, 0x00008D49 }, /* GL_STENCIL_INDEX16_EXT */ - { 40995, 0x00008D46 }, /* GL_STENCIL_INDEX1_EXT */ - { 41017, 0x00008D46 }, /* GL_STENCIL_INDEX1_OES */ - { 41039, 0x00008D47 }, /* GL_STENCIL_INDEX4 */ - { 41057, 0x00008D47 }, /* GL_STENCIL_INDEX4_EXT */ - { 41079, 0x00008D47 }, /* GL_STENCIL_INDEX4_OES */ - { 41101, 0x00008D48 }, /* GL_STENCIL_INDEX8 */ - { 41119, 0x00008D48 }, /* GL_STENCIL_INDEX8_EXT */ - { 41141, 0x00008D48 }, /* GL_STENCIL_INDEX8_OES */ - { 41163, 0x00008D45 }, /* GL_STENCIL_INDEX_EXT */ - { 41184, 0x00000B95 }, /* GL_STENCIL_PASS_DEPTH_FAIL */ - { 41211, 0x00000B96 }, /* GL_STENCIL_PASS_DEPTH_PASS */ - { 41238, 0x00000B97 }, /* GL_STENCIL_REF */ - { 41253, 0x00000B90 }, /* GL_STENCIL_TEST */ - { 41269, 0x00008910 }, /* GL_STENCIL_TEST_TWO_SIDE_EXT */ - { 41298, 0x00000B93 }, /* GL_STENCIL_VALUE_MASK */ - { 41320, 0x00000B98 }, /* GL_STENCIL_WRITEMASK */ - { 41341, 0x00000C33 }, /* GL_STEREO */ - { 41351, 0x000085BE }, /* GL_STORAGE_CACHED_APPLE */ - { 41375, 0x000085BD }, /* GL_STORAGE_PRIVATE_APPLE */ - { 41400, 0x000085BF }, /* GL_STORAGE_SHARED_APPLE */ - { 41424, 0x000088E2 }, /* GL_STREAM_COPY */ - { 41439, 0x000088E2 }, /* GL_STREAM_COPY_ARB */ - { 41458, 0x000088E0 }, /* GL_STREAM_DRAW */ - { 41473, 0x000088E0 }, /* GL_STREAM_DRAW_ARB */ - { 41492, 0x000088E1 }, /* GL_STREAM_READ */ - { 41507, 0x000088E1 }, /* GL_STREAM_READ_ARB */ - { 41526, 0x00000D50 }, /* GL_SUBPIXEL_BITS */ - { 41543, 0x000084E7 }, /* GL_SUBTRACT */ - { 41555, 0x000084E7 }, /* GL_SUBTRACT_ARB */ - { 41571, 0x00009113 }, /* GL_SYNC_CONDITION */ - { 41589, 0x00009116 }, /* GL_SYNC_FENCE */ - { 41603, 0x00009115 }, /* GL_SYNC_FLAGS */ - { 41617, 0x00000001 }, /* GL_SYNC_FLUSH_COMMANDS_BIT */ - { 41644, 0x00009117 }, /* GL_SYNC_GPU_COMMANDS_COMPLETE */ - { 41674, 0x00009114 }, /* GL_SYNC_STATUS */ - { 41689, 0x00002001 }, /* GL_T */ - { 41694, 0x00002A2A }, /* GL_T2F_C3F_V3F */ - { 41709, 0x00002A2C }, /* GL_T2F_C4F_N3F_V3F */ - { 41728, 0x00002A29 }, /* GL_T2F_C4UB_V3F */ - { 41744, 0x00002A2B }, /* GL_T2F_N3F_V3F */ - { 41759, 0x00002A27 }, /* GL_T2F_V3F */ - { 41770, 0x00002A2D }, /* GL_T4F_C4F_N3F_V4F */ - { 41789, 0x00002A28 }, /* GL_T4F_V4F */ - { 41800, 0x00008031 }, /* GL_TABLE_TOO_LARGE_EXT */ - { 41823, 0x00001702 }, /* GL_TEXTURE */ - { 41834, 0x000084C0 }, /* GL_TEXTURE0 */ - { 41846, 0x000084C0 }, /* GL_TEXTURE0_ARB */ - { 41862, 0x000084C1 }, /* GL_TEXTURE1 */ - { 41874, 0x000084CA }, /* GL_TEXTURE10 */ - { 41887, 0x000084CA }, /* GL_TEXTURE10_ARB */ - { 41904, 0x000084CB }, /* GL_TEXTURE11 */ - { 41917, 0x000084CB }, /* GL_TEXTURE11_ARB */ - { 41934, 0x000084CC }, /* GL_TEXTURE12 */ - { 41947, 0x000084CC }, /* GL_TEXTURE12_ARB */ - { 41964, 0x000084CD }, /* GL_TEXTURE13 */ - { 41977, 0x000084CD }, /* GL_TEXTURE13_ARB */ - { 41994, 0x000084CE }, /* GL_TEXTURE14 */ - { 42007, 0x000084CE }, /* GL_TEXTURE14_ARB */ - { 42024, 0x000084CF }, /* GL_TEXTURE15 */ - { 42037, 0x000084CF }, /* GL_TEXTURE15_ARB */ - { 42054, 0x000084D0 }, /* GL_TEXTURE16 */ - { 42067, 0x000084D0 }, /* GL_TEXTURE16_ARB */ - { 42084, 0x000084D1 }, /* GL_TEXTURE17 */ - { 42097, 0x000084D1 }, /* GL_TEXTURE17_ARB */ - { 42114, 0x000084D2 }, /* GL_TEXTURE18 */ - { 42127, 0x000084D2 }, /* GL_TEXTURE18_ARB */ - { 42144, 0x000084D3 }, /* GL_TEXTURE19 */ - { 42157, 0x000084D3 }, /* GL_TEXTURE19_ARB */ - { 42174, 0x000084C1 }, /* GL_TEXTURE1_ARB */ - { 42190, 0x000084C2 }, /* GL_TEXTURE2 */ - { 42202, 0x000084D4 }, /* GL_TEXTURE20 */ - { 42215, 0x000084D4 }, /* GL_TEXTURE20_ARB */ - { 42232, 0x000084D5 }, /* GL_TEXTURE21 */ - { 42245, 0x000084D5 }, /* GL_TEXTURE21_ARB */ - { 42262, 0x000084D6 }, /* GL_TEXTURE22 */ - { 42275, 0x000084D6 }, /* GL_TEXTURE22_ARB */ - { 42292, 0x000084D7 }, /* GL_TEXTURE23 */ - { 42305, 0x000084D7 }, /* GL_TEXTURE23_ARB */ - { 42322, 0x000084D8 }, /* GL_TEXTURE24 */ - { 42335, 0x000084D8 }, /* GL_TEXTURE24_ARB */ - { 42352, 0x000084D9 }, /* GL_TEXTURE25 */ - { 42365, 0x000084D9 }, /* GL_TEXTURE25_ARB */ - { 42382, 0x000084DA }, /* GL_TEXTURE26 */ - { 42395, 0x000084DA }, /* GL_TEXTURE26_ARB */ - { 42412, 0x000084DB }, /* GL_TEXTURE27 */ - { 42425, 0x000084DB }, /* GL_TEXTURE27_ARB */ - { 42442, 0x000084DC }, /* GL_TEXTURE28 */ - { 42455, 0x000084DC }, /* GL_TEXTURE28_ARB */ - { 42472, 0x000084DD }, /* GL_TEXTURE29 */ - { 42485, 0x000084DD }, /* GL_TEXTURE29_ARB */ - { 42502, 0x000084C2 }, /* GL_TEXTURE2_ARB */ - { 42518, 0x000084C3 }, /* GL_TEXTURE3 */ - { 42530, 0x000084DE }, /* GL_TEXTURE30 */ - { 42543, 0x000084DE }, /* GL_TEXTURE30_ARB */ - { 42560, 0x000084DF }, /* GL_TEXTURE31 */ - { 42573, 0x000084DF }, /* GL_TEXTURE31_ARB */ - { 42590, 0x000084C3 }, /* GL_TEXTURE3_ARB */ - { 42606, 0x000084C4 }, /* GL_TEXTURE4 */ - { 42618, 0x000084C4 }, /* GL_TEXTURE4_ARB */ - { 42634, 0x000084C5 }, /* GL_TEXTURE5 */ - { 42646, 0x000084C5 }, /* GL_TEXTURE5_ARB */ - { 42662, 0x000084C6 }, /* GL_TEXTURE6 */ - { 42674, 0x000084C6 }, /* GL_TEXTURE6_ARB */ - { 42690, 0x000084C7 }, /* GL_TEXTURE7 */ - { 42702, 0x000084C7 }, /* GL_TEXTURE7_ARB */ - { 42718, 0x000084C8 }, /* GL_TEXTURE8 */ - { 42730, 0x000084C8 }, /* GL_TEXTURE8_ARB */ - { 42746, 0x000084C9 }, /* GL_TEXTURE9 */ - { 42758, 0x000084C9 }, /* GL_TEXTURE9_ARB */ - { 42774, 0x00000DE0 }, /* GL_TEXTURE_1D */ - { 42788, 0x00008C18 }, /* GL_TEXTURE_1D_ARRAY */ - { 42808, 0x00008C18 }, /* GL_TEXTURE_1D_ARRAY_EXT */ - { 42832, 0x00000DE1 }, /* GL_TEXTURE_2D */ - { 42846, 0x00008C1A }, /* GL_TEXTURE_2D_ARRAY */ - { 42866, 0x00008C1A }, /* GL_TEXTURE_2D_ARRAY_EXT */ - { 42890, 0x0000806F }, /* GL_TEXTURE_3D */ - { 42904, 0x0000806F }, /* GL_TEXTURE_3D_OES */ - { 42922, 0x0000805F }, /* GL_TEXTURE_ALPHA_SIZE */ - { 42944, 0x0000805F }, /* GL_TEXTURE_ALPHA_SIZE_EXT */ - { 42970, 0x0000813C }, /* GL_TEXTURE_BASE_LEVEL */ - { 42992, 0x00008068 }, /* GL_TEXTURE_BINDING_1D */ - { 43014, 0x00008C1C }, /* GL_TEXTURE_BINDING_1D_ARRAY */ - { 43042, 0x00008C1C }, /* GL_TEXTURE_BINDING_1D_ARRAY_EXT */ - { 43074, 0x00008069 }, /* GL_TEXTURE_BINDING_2D */ - { 43096, 0x00008C1D }, /* GL_TEXTURE_BINDING_2D_ARRAY */ - { 43124, 0x00008C1D }, /* GL_TEXTURE_BINDING_2D_ARRAY_EXT */ - { 43156, 0x0000806A }, /* GL_TEXTURE_BINDING_3D */ - { 43178, 0x0000806A }, /* GL_TEXTURE_BINDING_3D_OES */ - { 43204, 0x00008C2C }, /* GL_TEXTURE_BINDING_BUFFER */ - { 43230, 0x00008C2C }, /* GL_TEXTURE_BINDING_BUFFER_ARB */ - { 43260, 0x00008514 }, /* GL_TEXTURE_BINDING_CUBE_MAP */ - { 43288, 0x00008514 }, /* GL_TEXTURE_BINDING_CUBE_MAP_ARB */ - { 43320, 0x00008514 }, /* GL_TEXTURE_BINDING_CUBE_MAP_OES */ - { 43352, 0x000084F6 }, /* GL_TEXTURE_BINDING_RECTANGLE */ - { 43381, 0x000084F6 }, /* GL_TEXTURE_BINDING_RECTANGLE_ARB */ - { 43414, 0x000084F6 }, /* GL_TEXTURE_BINDING_RECTANGLE_NV */ - { 43446, 0x00040000 }, /* GL_TEXTURE_BIT */ - { 43461, 0x0000805E }, /* GL_TEXTURE_BLUE_SIZE */ - { 43482, 0x0000805E }, /* GL_TEXTURE_BLUE_SIZE_EXT */ - { 43507, 0x00001005 }, /* GL_TEXTURE_BORDER */ - { 43525, 0x00001004 }, /* GL_TEXTURE_BORDER_COLOR */ - { 43549, 0x00008C2A }, /* GL_TEXTURE_BUFFER */ - { 43567, 0x00008C2A }, /* GL_TEXTURE_BUFFER_ARB */ - { 43589, 0x00008C2D }, /* GL_TEXTURE_BUFFER_DATA_STORE_BINDING */ - { 43626, 0x00008C2D }, /* GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB */ - { 43667, 0x00008C2E }, /* GL_TEXTURE_BUFFER_FORMAT */ - { 43692, 0x00008C2E }, /* GL_TEXTURE_BUFFER_FORMAT_ARB */ - { 43721, 0x00008171 }, /* GL_TEXTURE_CLIPMAP_CENTER_SGIX */ - { 43752, 0x00008176 }, /* GL_TEXTURE_CLIPMAP_DEPTH_SGIX */ - { 43782, 0x00008172 }, /* GL_TEXTURE_CLIPMAP_FRAME_SGIX */ - { 43812, 0x00008175 }, /* GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX */ - { 43847, 0x00008173 }, /* GL_TEXTURE_CLIPMAP_OFFSET_SGIX */ - { 43878, 0x00008174 }, /* GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX */ - { 43916, 0x000080BC }, /* GL_TEXTURE_COLOR_TABLE_SGI */ - { 43943, 0x000081EF }, /* GL_TEXTURE_COLOR_WRITEMASK_SGIS */ - { 43975, 0x000080BF }, /* GL_TEXTURE_COMPARE_FAIL_VALUE_ARB */ - { 44009, 0x0000884D }, /* GL_TEXTURE_COMPARE_FUNC */ - { 44033, 0x0000884D }, /* GL_TEXTURE_COMPARE_FUNC_ARB */ - { 44061, 0x0000884C }, /* GL_TEXTURE_COMPARE_MODE */ - { 44085, 0x0000884C }, /* GL_TEXTURE_COMPARE_MODE_ARB */ - { 44113, 0x0000819B }, /* GL_TEXTURE_COMPARE_OPERATOR_SGIX */ - { 44146, 0x0000819A }, /* GL_TEXTURE_COMPARE_SGIX */ - { 44170, 0x00001003 }, /* GL_TEXTURE_COMPONENTS */ - { 44192, 0x000086A1 }, /* GL_TEXTURE_COMPRESSED */ - { 44214, 0x000086A1 }, /* GL_TEXTURE_COMPRESSED_ARB */ - { 44240, 0x000086A3 }, /* GL_TEXTURE_COMPRESSED_FORMATS_ARB */ - { 44274, 0x000086A0 }, /* GL_TEXTURE_COMPRESSED_IMAGE_SIZE */ - { 44307, 0x000086A0 }, /* GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB */ - { 44344, 0x000084EF }, /* GL_TEXTURE_COMPRESSION_HINT */ - { 44372, 0x000084EF }, /* GL_TEXTURE_COMPRESSION_HINT_ARB */ - { 44404, 0x00008078 }, /* GL_TEXTURE_COORD_ARRAY */ - { 44427, 0x0000889A }, /* GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING */ - { 44465, 0x0000889A }, /* GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB */ - { 44507, 0x00008092 }, /* GL_TEXTURE_COORD_ARRAY_POINTER */ - { 44538, 0x00008088 }, /* GL_TEXTURE_COORD_ARRAY_SIZE */ - { 44566, 0x0000808A }, /* GL_TEXTURE_COORD_ARRAY_STRIDE */ - { 44596, 0x00008089 }, /* GL_TEXTURE_COORD_ARRAY_TYPE */ - { 44624, 0x00008B9D }, /* GL_TEXTURE_CROP_RECT_OES */ - { 44649, 0x00008513 }, /* GL_TEXTURE_CUBE_MAP */ - { 44669, 0x00008513 }, /* GL_TEXTURE_CUBE_MAP_ARB */ - { 44693, 0x00008516 }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_X */ - { 44724, 0x00008516 }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB */ - { 44759, 0x00008516 }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_X_OES */ - { 44794, 0x00008518 }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Y */ - { 44825, 0x00008518 }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB */ - { 44860, 0x00008518 }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_OES */ - { 44895, 0x0000851A }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Z */ - { 44926, 0x0000851A }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB */ - { 44961, 0x0000851A }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_OES */ - { 44996, 0x00008513 }, /* GL_TEXTURE_CUBE_MAP_OES */ - { 45020, 0x00008515 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_X */ - { 45051, 0x00008515 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB */ - { 45086, 0x00008515 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_X_OES */ - { 45121, 0x00008517 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Y */ - { 45152, 0x00008517 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB */ - { 45187, 0x00008517 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Y_OES */ - { 45222, 0x00008519 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Z */ - { 45253, 0x00008519 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB */ - { 45288, 0x00008519 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Z_OES */ - { 45323, 0x000088F4 }, /* GL_TEXTURE_CUBE_MAP_SEAMLESS */ - { 45352, 0x00008071 }, /* GL_TEXTURE_DEPTH */ - { 45369, 0x0000884A }, /* GL_TEXTURE_DEPTH_SIZE */ - { 45391, 0x0000884A }, /* GL_TEXTURE_DEPTH_SIZE_ARB */ - { 45417, 0x00002300 }, /* GL_TEXTURE_ENV */ - { 45432, 0x00002201 }, /* GL_TEXTURE_ENV_COLOR */ - { 45453, 0x00002200 }, /* GL_TEXTURE_ENV_MODE */ - { 45473, 0x00008500 }, /* GL_TEXTURE_FILTER_CONTROL */ - { 45499, 0x00008500 }, /* GL_TEXTURE_FILTER_CONTROL_EXT */ - { 45529, 0x00002500 }, /* GL_TEXTURE_GEN_MODE */ - { 45549, 0x00002500 }, /* GL_TEXTURE_GEN_MODE_OES */ - { 45573, 0x00000C63 }, /* GL_TEXTURE_GEN_Q */ - { 45590, 0x00000C62 }, /* GL_TEXTURE_GEN_R */ - { 45607, 0x00000C60 }, /* GL_TEXTURE_GEN_S */ - { 45624, 0x00008D60 }, /* GL_TEXTURE_GEN_STR_OES */ - { 45647, 0x00000C61 }, /* GL_TEXTURE_GEN_T */ - { 45664, 0x0000819D }, /* GL_TEXTURE_GEQUAL_R_SGIX */ - { 45689, 0x0000805D }, /* GL_TEXTURE_GREEN_SIZE */ - { 45711, 0x0000805D }, /* GL_TEXTURE_GREEN_SIZE_EXT */ - { 45737, 0x00001001 }, /* GL_TEXTURE_HEIGHT */ - { 45755, 0x000080ED }, /* GL_TEXTURE_INDEX_SIZE_EXT */ - { 45781, 0x00008061 }, /* GL_TEXTURE_INTENSITY_SIZE */ - { 45807, 0x00008061 }, /* GL_TEXTURE_INTENSITY_SIZE_EXT */ - { 45837, 0x00001003 }, /* GL_TEXTURE_INTERNAL_FORMAT */ - { 45864, 0x0000819C }, /* GL_TEXTURE_LEQUAL_R_SGIX */ - { 45889, 0x00008501 }, /* GL_TEXTURE_LOD_BIAS */ - { 45909, 0x00008501 }, /* GL_TEXTURE_LOD_BIAS_EXT */ - { 45933, 0x00008190 }, /* GL_TEXTURE_LOD_BIAS_R_SGIX */ - { 45960, 0x0000818E }, /* GL_TEXTURE_LOD_BIAS_S_SGIX */ - { 45987, 0x0000818F }, /* GL_TEXTURE_LOD_BIAS_T_SGIX */ - { 46014, 0x00008060 }, /* GL_TEXTURE_LUMINANCE_SIZE */ - { 46040, 0x00008060 }, /* GL_TEXTURE_LUMINANCE_SIZE_EXT */ - { 46070, 0x00002800 }, /* GL_TEXTURE_MAG_FILTER */ - { 46092, 0x00000BA8 }, /* GL_TEXTURE_MATRIX */ - { 46110, 0x0000898F }, /* GL_TEXTURE_MATRIX_FLOAT_AS_INT_BITS_OES */ - { 46150, 0x000084FE }, /* GL_TEXTURE_MAX_ANISOTROPY_EXT */ - { 46180, 0x0000836B }, /* GL_TEXTURE_MAX_CLAMP_R_SGIX */ - { 46208, 0x00008369 }, /* GL_TEXTURE_MAX_CLAMP_S_SGIX */ - { 46236, 0x0000836A }, /* GL_TEXTURE_MAX_CLAMP_T_SGIX */ - { 46264, 0x0000813D }, /* GL_TEXTURE_MAX_LEVEL */ - { 46285, 0x0000813B }, /* GL_TEXTURE_MAX_LOD */ - { 46304, 0x00002801 }, /* GL_TEXTURE_MIN_FILTER */ - { 46326, 0x0000813A }, /* GL_TEXTURE_MIN_LOD */ - { 46345, 0x00008066 }, /* GL_TEXTURE_PRIORITY */ - { 46365, 0x000085B7 }, /* GL_TEXTURE_RANGE_LENGTH_APPLE */ - { 46395, 0x000085B8 }, /* GL_TEXTURE_RANGE_POINTER_APPLE */ - { 46426, 0x000084F5 }, /* GL_TEXTURE_RECTANGLE */ - { 46447, 0x000084F5 }, /* GL_TEXTURE_RECTANGLE_ARB */ - { 46472, 0x000084F5 }, /* GL_TEXTURE_RECTANGLE_NV */ - { 46496, 0x0000805C }, /* GL_TEXTURE_RED_SIZE */ - { 46516, 0x0000805C }, /* GL_TEXTURE_RED_SIZE_EXT */ - { 46540, 0x00008067 }, /* GL_TEXTURE_RESIDENT */ - { 46560, 0x00008C3F }, /* GL_TEXTURE_SHARED_SIZE */ - { 46583, 0x00000BA5 }, /* GL_TEXTURE_STACK_DEPTH */ - { 46606, 0x000088F1 }, /* GL_TEXTURE_STENCIL_SIZE */ - { 46630, 0x000088F1 }, /* GL_TEXTURE_STENCIL_SIZE_EXT */ - { 46658, 0x000085BC }, /* GL_TEXTURE_STORAGE_HINT_APPLE */ - { 46688, 0x00008065 }, /* GL_TEXTURE_TOO_LARGE_EXT */ - { 46713, 0x0000888F }, /* GL_TEXTURE_UNSIGNED_REMAP_MODE_NV */ - { 46747, 0x00001000 }, /* GL_TEXTURE_WIDTH */ - { 46764, 0x00008072 }, /* GL_TEXTURE_WRAP_R */ - { 46782, 0x00008072 }, /* GL_TEXTURE_WRAP_R_OES */ - { 46804, 0x00002802 }, /* GL_TEXTURE_WRAP_S */ - { 46822, 0x00002803 }, /* GL_TEXTURE_WRAP_T */ - { 46840, 0x0000911B }, /* GL_TIMEOUT_EXPIRED */ - { 46859, 0x000088BF }, /* GL_TIME_ELAPSED_EXT */ - { 46879, 0x00008648 }, /* GL_TRACK_MATRIX_NV */ - { 46898, 0x00008649 }, /* GL_TRACK_MATRIX_TRANSFORM_NV */ - { 46927, 0x00001000 }, /* GL_TRANSFORM_BIT */ - { 46944, 0x00008E22 }, /* GL_TRANSFORM_FEEDBACK */ - { 46966, 0x00008E25 }, /* GL_TRANSFORM_FEEDBACK_BINDING */ - { 46996, 0x00008C8E }, /* GL_TRANSFORM_FEEDBACK_BUFFER */ - { 47025, 0x00008E24 }, /* GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE */ - { 47061, 0x00008C8F }, /* GL_TRANSFORM_FEEDBACK_BUFFER_BINDING */ - { 47098, 0x00008C8F }, /* GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_EXT */ - { 47139, 0x00008C8E }, /* GL_TRANSFORM_FEEDBACK_BUFFER_EXT */ - { 47172, 0x00008C7F }, /* GL_TRANSFORM_FEEDBACK_BUFFER_MODE */ - { 47206, 0x00008C7F }, /* GL_TRANSFORM_FEEDBACK_BUFFER_MODE_EXT */ - { 47244, 0x00008E23 }, /* GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED */ - { 47280, 0x00008C85 }, /* GL_TRANSFORM_FEEDBACK_BUFFER_SIZE */ - { 47314, 0x00008C85 }, /* GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_EXT */ - { 47352, 0x00008C84 }, /* GL_TRANSFORM_FEEDBACK_BUFFER_START */ - { 47387, 0x00008C84 }, /* GL_TRANSFORM_FEEDBACK_BUFFER_START_EXT */ - { 47426, 0x00008C88 }, /* GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN */ - { 47467, 0x00008C88 }, /* GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_EXT */ - { 47512, 0x00008C83 }, /* GL_TRANSFORM_FEEDBACK_VARYINGS */ - { 47543, 0x00008C83 }, /* GL_TRANSFORM_FEEDBACK_VARYINGS_EXT */ - { 47578, 0x00008C76 }, /* GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH */ - { 47619, 0x00008C76 }, /* GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH_EXT */ - { 47664, 0x000084E6 }, /* GL_TRANSPOSE_COLOR_MATRIX */ - { 47690, 0x000084E6 }, /* GL_TRANSPOSE_COLOR_MATRIX_ARB */ - { 47720, 0x000088B7 }, /* GL_TRANSPOSE_CURRENT_MATRIX_ARB */ - { 47752, 0x000084E3 }, /* GL_TRANSPOSE_MODELVIEW_MATRIX */ - { 47782, 0x000084E3 }, /* GL_TRANSPOSE_MODELVIEW_MATRIX_ARB */ - { 47816, 0x0000862C }, /* GL_TRANSPOSE_NV */ - { 47832, 0x000084E4 }, /* GL_TRANSPOSE_PROJECTION_MATRIX */ - { 47863, 0x000084E4 }, /* GL_TRANSPOSE_PROJECTION_MATRIX_ARB */ - { 47898, 0x000084E5 }, /* GL_TRANSPOSE_TEXTURE_MATRIX */ - { 47926, 0x000084E5 }, /* GL_TRANSPOSE_TEXTURE_MATRIX_ARB */ - { 47958, 0x00000004 }, /* GL_TRIANGLES */ - { 47971, 0x0000000C }, /* GL_TRIANGLES_ADJACENCY */ - { 47994, 0x0000000C }, /* GL_TRIANGLES_ADJACENCY_ARB */ - { 48021, 0x00000006 }, /* GL_TRIANGLE_FAN */ - { 48037, 0x00008615 }, /* GL_TRIANGLE_MESH_SUN */ - { 48058, 0x00000005 }, /* GL_TRIANGLE_STRIP */ - { 48076, 0x0000000D }, /* GL_TRIANGLE_STRIP_ADJACENCY */ - { 48104, 0x0000000D }, /* GL_TRIANGLE_STRIP_ADJACENCY_ARB */ - { 48136, 0x00000001 }, /* GL_TRUE */ - { 48144, 0x00008A1C }, /* GL_UNDEFINED_APPLE */ - { 48163, 0x00008255 }, /* GL_UNKNOWN_CONTEXT_RESET_ARB */ - { 48192, 0x00000CF5 }, /* GL_UNPACK_ALIGNMENT */ - { 48212, 0x0000806E }, /* GL_UNPACK_IMAGE_HEIGHT */ - { 48235, 0x00000CF1 }, /* GL_UNPACK_LSB_FIRST */ - { 48255, 0x00000CF2 }, /* GL_UNPACK_ROW_LENGTH */ - { 48276, 0x0000806D }, /* GL_UNPACK_SKIP_IMAGES */ - { 48298, 0x00000CF4 }, /* GL_UNPACK_SKIP_PIXELS */ - { 48320, 0x00000CF3 }, /* GL_UNPACK_SKIP_ROWS */ - { 48340, 0x00000CF0 }, /* GL_UNPACK_SWAP_BYTES */ - { 48361, 0x00009118 }, /* GL_UNSIGNALED */ - { 48375, 0x00001401 }, /* GL_UNSIGNED_BYTE */ - { 48392, 0x00008362 }, /* GL_UNSIGNED_BYTE_2_3_3_REV */ - { 48419, 0x00008032 }, /* GL_UNSIGNED_BYTE_3_3_2 */ - { 48442, 0x00001405 }, /* GL_UNSIGNED_INT */ - { 48458, 0x00008C3B }, /* GL_UNSIGNED_INT_10F_11F_11F_REV */ - { 48490, 0x00008036 }, /* GL_UNSIGNED_INT_10_10_10_2 */ - { 48517, 0x00008DF6 }, /* GL_UNSIGNED_INT_10_10_10_2_OES */ - { 48548, 0x000084FA }, /* GL_UNSIGNED_INT_24_8 */ - { 48569, 0x000084FA }, /* GL_UNSIGNED_INT_24_8_EXT */ - { 48594, 0x000084FA }, /* GL_UNSIGNED_INT_24_8_NV */ - { 48618, 0x000084FA }, /* GL_UNSIGNED_INT_24_8_OES */ - { 48643, 0x00008368 }, /* GL_UNSIGNED_INT_2_10_10_10_REV */ - { 48674, 0x00008368 }, /* GL_UNSIGNED_INT_2_10_10_10_REV_EXT */ - { 48709, 0x00008C3E }, /* GL_UNSIGNED_INT_5_9_9_9_REV */ - { 48737, 0x00008035 }, /* GL_UNSIGNED_INT_8_8_8_8 */ - { 48761, 0x00008367 }, /* GL_UNSIGNED_INT_8_8_8_8_REV */ - { 48789, 0x00008DD1 }, /* GL_UNSIGNED_INT_SAMPLER_1D */ - { 48816, 0x00008DD6 }, /* GL_UNSIGNED_INT_SAMPLER_1D_ARRAY */ - { 48849, 0x00008DD6 }, /* GL_UNSIGNED_INT_SAMPLER_1D_ARRAY_EXT */ - { 48886, 0x00008DD1 }, /* GL_UNSIGNED_INT_SAMPLER_1D_EXT */ - { 48917, 0x00008DD2 }, /* GL_UNSIGNED_INT_SAMPLER_2D */ - { 48944, 0x00008DD7 }, /* GL_UNSIGNED_INT_SAMPLER_2D_ARRAY */ - { 48977, 0x00008DD7 }, /* GL_UNSIGNED_INT_SAMPLER_2D_ARRAY_EXT */ - { 49014, 0x00008DD2 }, /* GL_UNSIGNED_INT_SAMPLER_2D_EXT */ - { 49045, 0x00008DD5 }, /* GL_UNSIGNED_INT_SAMPLER_2D_RECT */ - { 49077, 0x00008DD5 }, /* GL_UNSIGNED_INT_SAMPLER_2D_RECT_EXT */ - { 49113, 0x00008DD3 }, /* GL_UNSIGNED_INT_SAMPLER_3D */ - { 49140, 0x00008DD3 }, /* GL_UNSIGNED_INT_SAMPLER_3D_EXT */ - { 49171, 0x00008DD8 }, /* GL_UNSIGNED_INT_SAMPLER_BUFFER */ - { 49202, 0x00008DD8 }, /* GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT */ - { 49237, 0x00008DD4 }, /* GL_UNSIGNED_INT_SAMPLER_CUBE */ - { 49266, 0x00008DD4 }, /* GL_UNSIGNED_INT_SAMPLER_CUBE_EXT */ - { 49299, 0x00008DC6 }, /* GL_UNSIGNED_INT_VEC2 */ - { 49320, 0x00008DC6 }, /* GL_UNSIGNED_INT_VEC2_EXT */ - { 49345, 0x00008DC7 }, /* GL_UNSIGNED_INT_VEC3 */ - { 49366, 0x00008DC7 }, /* GL_UNSIGNED_INT_VEC3_EXT */ - { 49391, 0x00008DC8 }, /* GL_UNSIGNED_INT_VEC4 */ - { 49412, 0x00008DC8 }, /* GL_UNSIGNED_INT_VEC4_EXT */ - { 49437, 0x00008C17 }, /* GL_UNSIGNED_NORMALIZED */ - { 49460, 0x00001403 }, /* GL_UNSIGNED_SHORT */ - { 49478, 0x00008366 }, /* GL_UNSIGNED_SHORT_1_5_5_5_REV */ - { 49508, 0x00008366 }, /* GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT */ - { 49542, 0x00008033 }, /* GL_UNSIGNED_SHORT_4_4_4_4 */ - { 49568, 0x00008365 }, /* GL_UNSIGNED_SHORT_4_4_4_4_REV */ - { 49598, 0x00008365 }, /* GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT */ - { 49632, 0x00008034 }, /* GL_UNSIGNED_SHORT_5_5_5_1 */ - { 49658, 0x00008363 }, /* GL_UNSIGNED_SHORT_5_6_5 */ - { 49682, 0x00008364 }, /* GL_UNSIGNED_SHORT_5_6_5_REV */ - { 49710, 0x000085BA }, /* GL_UNSIGNED_SHORT_8_8_APPLE */ - { 49738, 0x000085BA }, /* GL_UNSIGNED_SHORT_8_8_MESA */ - { 49765, 0x000085BB }, /* GL_UNSIGNED_SHORT_8_8_REV_APPLE */ - { 49797, 0x000085BB }, /* GL_UNSIGNED_SHORT_8_8_REV_MESA */ - { 49828, 0x00008CA2 }, /* GL_UPPER_LEFT */ - { 49842, 0x00002A20 }, /* GL_V2F */ - { 49849, 0x00002A21 }, /* GL_V3F */ - { 49856, 0x00008B83 }, /* GL_VALIDATE_STATUS */ - { 49875, 0x00001F00 }, /* GL_VENDOR */ - { 49885, 0x00001F02 }, /* GL_VERSION */ - { 49896, 0x00008074 }, /* GL_VERTEX_ARRAY */ - { 49912, 0x000085B5 }, /* GL_VERTEX_ARRAY_BINDING */ - { 49936, 0x000085B5 }, /* GL_VERTEX_ARRAY_BINDING_APPLE */ - { 49966, 0x00008896 }, /* GL_VERTEX_ARRAY_BUFFER_BINDING */ - { 49997, 0x00008896 }, /* GL_VERTEX_ARRAY_BUFFER_BINDING_ARB */ - { 50032, 0x0000808E }, /* GL_VERTEX_ARRAY_POINTER */ - { 50056, 0x0000807A }, /* GL_VERTEX_ARRAY_SIZE */ - { 50077, 0x0000807C }, /* GL_VERTEX_ARRAY_STRIDE */ - { 50100, 0x0000807B }, /* GL_VERTEX_ARRAY_TYPE */ - { 50121, 0x00008650 }, /* GL_VERTEX_ATTRIB_ARRAY0_NV */ - { 50148, 0x0000865A }, /* GL_VERTEX_ATTRIB_ARRAY10_NV */ - { 50176, 0x0000865B }, /* GL_VERTEX_ATTRIB_ARRAY11_NV */ - { 50204, 0x0000865C }, /* GL_VERTEX_ATTRIB_ARRAY12_NV */ - { 50232, 0x0000865D }, /* GL_VERTEX_ATTRIB_ARRAY13_NV */ - { 50260, 0x0000865E }, /* GL_VERTEX_ATTRIB_ARRAY14_NV */ - { 50288, 0x0000865F }, /* GL_VERTEX_ATTRIB_ARRAY15_NV */ - { 50316, 0x00008651 }, /* GL_VERTEX_ATTRIB_ARRAY1_NV */ - { 50343, 0x00008652 }, /* GL_VERTEX_ATTRIB_ARRAY2_NV */ - { 50370, 0x00008653 }, /* GL_VERTEX_ATTRIB_ARRAY3_NV */ - { 50397, 0x00008654 }, /* GL_VERTEX_ATTRIB_ARRAY4_NV */ - { 50424, 0x00008655 }, /* GL_VERTEX_ATTRIB_ARRAY5_NV */ - { 50451, 0x00008656 }, /* GL_VERTEX_ATTRIB_ARRAY6_NV */ - { 50478, 0x00008657 }, /* GL_VERTEX_ATTRIB_ARRAY7_NV */ - { 50505, 0x00008658 }, /* GL_VERTEX_ATTRIB_ARRAY8_NV */ - { 50532, 0x00008659 }, /* GL_VERTEX_ATTRIB_ARRAY9_NV */ - { 50559, 0x0000889F }, /* GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING */ - { 50597, 0x0000889F }, /* GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB */ - { 50639, 0x000088FE }, /* GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB */ - { 50674, 0x00008622 }, /* GL_VERTEX_ATTRIB_ARRAY_ENABLED */ - { 50705, 0x00008622 }, /* GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB */ - { 50740, 0x000088FD }, /* GL_VERTEX_ATTRIB_ARRAY_INTEGER */ - { 50771, 0x000088FD }, /* GL_VERTEX_ATTRIB_ARRAY_INTEGER_EXT */ - { 50806, 0x0000886A }, /* GL_VERTEX_ATTRIB_ARRAY_NORMALIZED */ - { 50840, 0x0000886A }, /* GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB */ - { 50878, 0x00008645 }, /* GL_VERTEX_ATTRIB_ARRAY_POINTER */ - { 50909, 0x00008645 }, /* GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB */ - { 50944, 0x00008623 }, /* GL_VERTEX_ATTRIB_ARRAY_SIZE */ - { 50972, 0x00008623 }, /* GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB */ - { 51004, 0x00008624 }, /* GL_VERTEX_ATTRIB_ARRAY_STRIDE */ - { 51034, 0x00008624 }, /* GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB */ - { 51068, 0x00008625 }, /* GL_VERTEX_ATTRIB_ARRAY_TYPE */ - { 51096, 0x00008625 }, /* GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB */ - { 51128, 0x000086A7 }, /* GL_VERTEX_BLEND_ARB */ - { 51148, 0x00008620 }, /* GL_VERTEX_PROGRAM_ARB */ - { 51170, 0x0000864A }, /* GL_VERTEX_PROGRAM_BINDING_NV */ - { 51199, 0x00008620 }, /* GL_VERTEX_PROGRAM_NV */ - { 51220, 0x00008642 }, /* GL_VERTEX_PROGRAM_POINT_SIZE */ - { 51249, 0x00008642 }, /* GL_VERTEX_PROGRAM_POINT_SIZE_ARB */ - { 51282, 0x00008642 }, /* GL_VERTEX_PROGRAM_POINT_SIZE_NV */ - { 51314, 0x00008643 }, /* GL_VERTEX_PROGRAM_TWO_SIDE */ - { 51341, 0x00008643 }, /* GL_VERTEX_PROGRAM_TWO_SIDE_ARB */ - { 51372, 0x00008643 }, /* GL_VERTEX_PROGRAM_TWO_SIDE_NV */ - { 51402, 0x00008B31 }, /* GL_VERTEX_SHADER */ - { 51419, 0x00008B31 }, /* GL_VERTEX_SHADER_ARB */ - { 51440, 0x00008621 }, /* GL_VERTEX_STATE_PROGRAM_NV */ - { 51467, 0x00000BA2 }, /* GL_VIEWPORT */ - { 51479, 0x00000800 }, /* GL_VIEWPORT_BIT */ - { 51495, 0x00008A1A }, /* GL_VOLATILE_APPLE */ - { 51513, 0x0000911D }, /* GL_WAIT_FAILED */ - { 51528, 0x000086AD }, /* GL_WEIGHT_ARRAY_ARB */ - { 51548, 0x0000889E }, /* GL_WEIGHT_ARRAY_BUFFER_BINDING */ - { 51579, 0x0000889E }, /* GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB */ - { 51614, 0x0000889E }, /* GL_WEIGHT_ARRAY_BUFFER_BINDING_OES */ - { 51649, 0x000086AD }, /* GL_WEIGHT_ARRAY_OES */ - { 51669, 0x000086AC }, /* GL_WEIGHT_ARRAY_POINTER_ARB */ - { 51697, 0x000086AC }, /* GL_WEIGHT_ARRAY_POINTER_OES */ - { 51725, 0x000086AB }, /* GL_WEIGHT_ARRAY_SIZE_ARB */ - { 51750, 0x000086AB }, /* GL_WEIGHT_ARRAY_SIZE_OES */ - { 51775, 0x000086AA }, /* GL_WEIGHT_ARRAY_STRIDE_ARB */ - { 51802, 0x000086AA }, /* GL_WEIGHT_ARRAY_STRIDE_OES */ - { 51829, 0x000086A9 }, /* GL_WEIGHT_ARRAY_TYPE_ARB */ - { 51854, 0x000086A9 }, /* GL_WEIGHT_ARRAY_TYPE_OES */ - { 51879, 0x000086A6 }, /* GL_WEIGHT_SUM_UNITY_ARB */ - { 51903, 0x000081D4 }, /* GL_WRAP_BORDER_SUN */ - { 51922, 0x000088B9 }, /* GL_WRITE_ONLY */ - { 51936, 0x000088B9 }, /* GL_WRITE_ONLY_ARB */ - { 51954, 0x000088B9 }, /* GL_WRITE_ONLY_OES */ - { 51972, 0x00001506 }, /* GL_XOR */ - { 51979, 0x000085B9 }, /* GL_YCBCR_422_APPLE */ - { 51998, 0x00008757 }, /* GL_YCBCR_MESA */ - { 52012, 0x00000000 }, /* GL_ZERO */ - { 52020, 0x00000D16 }, /* GL_ZOOM_X */ - { 52030, 0x00000D17 }, /* GL_ZOOM_Y */ -}; - -static const unsigned reduced_enums[1564] = -{ - 539, /* GL_FALSE */ - 835, /* GL_LINES */ - 839, /* GL_LINE_LOOP */ - 846, /* GL_LINE_STRIP */ - 2157, /* GL_TRIANGLES */ - 2162, /* GL_TRIANGLE_STRIP */ - 2160, /* GL_TRIANGLE_FAN */ - 1522, /* GL_QUADS */ - 1526, /* GL_QUAD_STRIP */ - 1390, /* GL_POLYGON */ - 836, /* GL_LINES_ADJACENCY */ - 847, /* GL_LINE_STRIP_ADJACENCY */ - 2158, /* GL_TRIANGLES_ADJACENCY */ - 2163, /* GL_TRIANGLE_STRIP_ADJACENCY */ - 1402, /* GL_POLYGON_STIPPLE_BIT */ - 1345, /* GL_PIXEL_MODE_BIT */ - 822, /* GL_LIGHTING_BIT */ - 573, /* GL_FOG_BIT */ - 8, /* GL_ACCUM */ - 858, /* GL_LOAD */ - 1612, /* GL_RETURN */ - 1210, /* GL_MULT */ - 24, /* GL_ADD */ - 1226, /* GL_NEVER */ - 812, /* GL_LESS */ - 529, /* GL_EQUAL */ - 811, /* GL_LEQUAL */ - 696, /* GL_GREATER */ - 1243, /* GL_NOTEQUAL */ - 695, /* GL_GEQUAL */ - 55, /* GL_ALWAYS */ - 1821, /* GL_SRC_COLOR */ - 1278, /* GL_ONE_MINUS_SRC_COLOR */ - 1819, /* GL_SRC_ALPHA */ - 1277, /* GL_ONE_MINUS_SRC_ALPHA */ - 508, /* GL_DST_ALPHA */ - 1275, /* GL_ONE_MINUS_DST_ALPHA */ - 509, /* GL_DST_COLOR */ - 1276, /* GL_ONE_MINUS_DST_COLOR */ - 1820, /* GL_SRC_ALPHA_SATURATE */ - 672, /* GL_FRONT_LEFT */ - 673, /* GL_FRONT_RIGHT */ - 77, /* GL_BACK_LEFT */ - 78, /* GL_BACK_RIGHT */ - 669, /* GL_FRONT */ - 76, /* GL_BACK */ - 810, /* GL_LEFT */ - 1702, /* GL_RIGHT */ - 670, /* GL_FRONT_AND_BACK */ - 71, /* GL_AUX0 */ - 72, /* GL_AUX1 */ - 73, /* GL_AUX2 */ - 74, /* GL_AUX3 */ - 798, /* GL_INVALID_ENUM */ - 803, /* GL_INVALID_VALUE */ - 802, /* GL_INVALID_OPERATION */ - 1826, /* GL_STACK_OVERFLOW */ - 1827, /* GL_STACK_UNDERFLOW */ - 1303, /* GL_OUT_OF_MEMORY */ - 799, /* GL_INVALID_FRAMEBUFFER_OPERATION */ - 0, /* GL_2D */ - 2, /* GL_3D */ - 3, /* GL_3D_COLOR */ - 4, /* GL_3D_COLOR_TEXTURE */ - 6, /* GL_4D_COLOR_TEXTURE */ - 1323, /* GL_PASS_THROUGH_TOKEN */ - 1389, /* GL_POINT_TOKEN */ - 849, /* GL_LINE_TOKEN */ - 1403, /* GL_POLYGON_TOKEN */ - 87, /* GL_BITMAP_TOKEN */ - 507, /* GL_DRAW_PIXEL_TOKEN */ - 353, /* GL_COPY_PIXEL_TOKEN */ - 840, /* GL_LINE_RESET_TOKEN */ - 532, /* GL_EXP */ - 533, /* GL_EXP2 */ - 390, /* GL_CW */ - 154, /* GL_CCW */ - 187, /* GL_COEFF */ - 1300, /* GL_ORDER */ - 444, /* GL_DOMAIN */ - 363, /* GL_CURRENT_COLOR */ - 366, /* GL_CURRENT_INDEX */ - 372, /* GL_CURRENT_NORMAL */ - 386, /* GL_CURRENT_TEXTURE_COORDS */ - 378, /* GL_CURRENT_RASTER_COLOR */ - 380, /* GL_CURRENT_RASTER_INDEX */ - 384, /* GL_CURRENT_RASTER_TEXTURE_COORDS */ - 381, /* GL_CURRENT_RASTER_POSITION */ - 382, /* GL_CURRENT_RASTER_POSITION_VALID */ - 379, /* GL_CURRENT_RASTER_DISTANCE */ - 1381, /* GL_POINT_SMOOTH */ - 1365, /* GL_POINT_SIZE */ - 1380, /* GL_POINT_SIZE_RANGE */ - 1371, /* GL_POINT_SIZE_GRANULARITY */ - 841, /* GL_LINE_SMOOTH */ - 850, /* GL_LINE_WIDTH */ - 852, /* GL_LINE_WIDTH_RANGE */ - 851, /* GL_LINE_WIDTH_GRANULARITY */ - 843, /* GL_LINE_STIPPLE */ - 844, /* GL_LINE_STIPPLE_PATTERN */ - 845, /* GL_LINE_STIPPLE_REPEAT */ - 857, /* GL_LIST_MODE */ - 1065, /* GL_MAX_LIST_NESTING */ - 854, /* GL_LIST_BASE */ - 856, /* GL_LIST_INDEX */ - 1392, /* GL_POLYGON_MODE */ - 1399, /* GL_POLYGON_SMOOTH */ - 1401, /* GL_POLYGON_STIPPLE */ - 518, /* GL_EDGE_FLAG */ - 356, /* GL_CULL_FACE */ - 357, /* GL_CULL_FACE_MODE */ - 671, /* GL_FRONT_FACE */ - 821, /* GL_LIGHTING */ - 826, /* GL_LIGHT_MODEL_LOCAL_VIEWER */ - 827, /* GL_LIGHT_MODEL_TWO_SIDE */ - 823, /* GL_LIGHT_MODEL_AMBIENT */ - 1768, /* GL_SHADE_MODEL */ - 235, /* GL_COLOR_MATERIAL_FACE */ - 236, /* GL_COLOR_MATERIAL_PARAMETER */ - 234, /* GL_COLOR_MATERIAL */ - 572, /* GL_FOG */ - 594, /* GL_FOG_INDEX */ - 590, /* GL_FOG_DENSITY */ - 598, /* GL_FOG_START */ - 592, /* GL_FOG_END */ - 595, /* GL_FOG_MODE */ - 574, /* GL_FOG_COLOR */ - 429, /* GL_DEPTH_RANGE */ - 438, /* GL_DEPTH_TEST */ - 441, /* GL_DEPTH_WRITEMASK */ - 414, /* GL_DEPTH_CLEAR_VALUE */ - 428, /* GL_DEPTH_FUNC */ - 12, /* GL_ACCUM_CLEAR_VALUE */ - 1871, /* GL_STENCIL_TEST */ - 1852, /* GL_STENCIL_CLEAR_VALUE */ - 1854, /* GL_STENCIL_FUNC */ - 1873, /* GL_STENCIL_VALUE_MASK */ - 1853, /* GL_STENCIL_FAIL */ - 1868, /* GL_STENCIL_PASS_DEPTH_FAIL */ - 1869, /* GL_STENCIL_PASS_DEPTH_PASS */ - 1870, /* GL_STENCIL_REF */ - 1874, /* GL_STENCIL_WRITEMASK */ - 1015, /* GL_MATRIX_MODE */ - 1232, /* GL_NORMALIZE */ - 2290, /* GL_VIEWPORT */ - 1205, /* GL_MODELVIEW_STACK_DEPTH */ - 1496, /* GL_PROJECTION_STACK_DEPTH */ - 2111, /* GL_TEXTURE_STACK_DEPTH */ - 1202, /* GL_MODELVIEW_MATRIX */ - 1494, /* GL_PROJECTION_MATRIX */ - 2091, /* GL_TEXTURE_MATRIX */ - 69, /* GL_ATTRIB_STACK_DEPTH */ - 169, /* GL_CLIENT_ATTRIB_STACK_DEPTH */ - 51, /* GL_ALPHA_TEST */ - 52, /* GL_ALPHA_TEST_FUNC */ - 53, /* GL_ALPHA_TEST_REF */ - 443, /* GL_DITHER */ - 91, /* GL_BLEND_DST */ - 105, /* GL_BLEND_SRC */ - 88, /* GL_BLEND */ - 860, /* GL_LOGIC_OP_MODE */ - 745, /* GL_INDEX_LOGIC_OP */ - 233, /* GL_COLOR_LOGIC_OP */ - 75, /* GL_AUX_BUFFERS */ - 454, /* GL_DRAW_BUFFER */ - 1549, /* GL_READ_BUFFER */ - 1745, /* GL_SCISSOR_BOX */ - 1746, /* GL_SCISSOR_TEST */ - 744, /* GL_INDEX_CLEAR_VALUE */ - 749, /* GL_INDEX_WRITEMASK */ - 230, /* GL_COLOR_CLEAR_VALUE */ - 272, /* GL_COLOR_WRITEMASK */ - 746, /* GL_INDEX_MODE */ - 1691, /* GL_RGBA_MODE */ - 453, /* GL_DOUBLEBUFFER */ - 1875, /* GL_STEREO */ - 1603, /* GL_RENDER_MODE */ - 1324, /* GL_PERSPECTIVE_CORRECTION_HINT */ - 1382, /* GL_POINT_SMOOTH_HINT */ - 842, /* GL_LINE_SMOOTH_HINT */ - 1400, /* GL_POLYGON_SMOOTH_HINT */ - 593, /* GL_FOG_HINT */ - 2071, /* GL_TEXTURE_GEN_S */ - 2073, /* GL_TEXTURE_GEN_T */ - 2070, /* GL_TEXTURE_GEN_R */ - 2069, /* GL_TEXTURE_GEN_Q */ - 1337, /* GL_PIXEL_MAP_I_TO_I */ - 1343, /* GL_PIXEL_MAP_S_TO_S */ - 1339, /* GL_PIXEL_MAP_I_TO_R */ - 1335, /* GL_PIXEL_MAP_I_TO_G */ - 1333, /* GL_PIXEL_MAP_I_TO_B */ - 1331, /* GL_PIXEL_MAP_I_TO_A */ - 1341, /* GL_PIXEL_MAP_R_TO_R */ - 1329, /* GL_PIXEL_MAP_G_TO_G */ - 1327, /* GL_PIXEL_MAP_B_TO_B */ - 1325, /* GL_PIXEL_MAP_A_TO_A */ - 1338, /* GL_PIXEL_MAP_I_TO_I_SIZE */ - 1344, /* GL_PIXEL_MAP_S_TO_S_SIZE */ - 1340, /* GL_PIXEL_MAP_I_TO_R_SIZE */ - 1336, /* GL_PIXEL_MAP_I_TO_G_SIZE */ - 1334, /* GL_PIXEL_MAP_I_TO_B_SIZE */ - 1332, /* GL_PIXEL_MAP_I_TO_A_SIZE */ - 1342, /* GL_PIXEL_MAP_R_TO_R_SIZE */ - 1330, /* GL_PIXEL_MAP_G_TO_G_SIZE */ - 1328, /* GL_PIXEL_MAP_B_TO_B_SIZE */ - 1326, /* GL_PIXEL_MAP_A_TO_A_SIZE */ - 2175, /* GL_UNPACK_SWAP_BYTES */ - 2170, /* GL_UNPACK_LSB_FIRST */ - 2171, /* GL_UNPACK_ROW_LENGTH */ - 2174, /* GL_UNPACK_SKIP_ROWS */ - 2173, /* GL_UNPACK_SKIP_PIXELS */ - 2168, /* GL_UNPACK_ALIGNMENT */ - 1312, /* GL_PACK_SWAP_BYTES */ - 1307, /* GL_PACK_LSB_FIRST */ - 1308, /* GL_PACK_ROW_LENGTH */ - 1311, /* GL_PACK_SKIP_ROWS */ - 1310, /* GL_PACK_SKIP_PIXELS */ - 1304, /* GL_PACK_ALIGNMENT */ - 956, /* GL_MAP_COLOR */ - 961, /* GL_MAP_STENCIL */ - 748, /* GL_INDEX_SHIFT */ - 747, /* GL_INDEX_OFFSET */ - 1565, /* GL_RED_SCALE */ - 1561, /* GL_RED_BIAS */ - 2316, /* GL_ZOOM_X */ - 2317, /* GL_ZOOM_Y */ - 702, /* GL_GREEN_SCALE */ - 698, /* GL_GREEN_BIAS */ - 115, /* GL_BLUE_SCALE */ - 111, /* GL_BLUE_BIAS */ - 50, /* GL_ALPHA_SCALE */ - 47, /* GL_ALPHA_BIAS */ - 430, /* GL_DEPTH_SCALE */ - 406, /* GL_DEPTH_BIAS */ - 1047, /* GL_MAX_EVAL_ORDER */ - 1064, /* GL_MAX_LIGHTS */ - 1027, /* GL_MAX_CLIP_DISTANCES */ - 1120, /* GL_MAX_TEXTURE_SIZE */ - 1071, /* GL_MAX_PIXEL_MAP_TABLE */ - 1023, /* GL_MAX_ATTRIB_STACK_DEPTH */ - 1067, /* GL_MAX_MODELVIEW_STACK_DEPTH */ - 1068, /* GL_MAX_NAME_STACK_DEPTH */ - 1099, /* GL_MAX_PROJECTION_STACK_DEPTH */ - 1121, /* GL_MAX_TEXTURE_STACK_DEPTH */ - 1147, /* GL_MAX_VIEWPORT_DIMS */ - 1024, /* GL_MAX_CLIENT_ATTRIB_STACK_DEPTH */ - 1885, /* GL_SUBPIXEL_BITS */ - 743, /* GL_INDEX_BITS */ - 1562, /* GL_RED_BITS */ - 699, /* GL_GREEN_BITS */ - 112, /* GL_BLUE_BITS */ - 48, /* GL_ALPHA_BITS */ - 407, /* GL_DEPTH_BITS */ - 1849, /* GL_STENCIL_BITS */ - 14, /* GL_ACCUM_RED_BITS */ - 13, /* GL_ACCUM_GREEN_BITS */ - 10, /* GL_ACCUM_BLUE_BITS */ - 9, /* GL_ACCUM_ALPHA_BITS */ - 1219, /* GL_NAME_STACK_DEPTH */ - 70, /* GL_AUTO_NORMAL */ - 902, /* GL_MAP1_COLOR_4 */ - 905, /* GL_MAP1_INDEX */ - 906, /* GL_MAP1_NORMAL */ - 907, /* GL_MAP1_TEXTURE_COORD_1 */ - 908, /* GL_MAP1_TEXTURE_COORD_2 */ - 909, /* GL_MAP1_TEXTURE_COORD_3 */ - 910, /* GL_MAP1_TEXTURE_COORD_4 */ - 911, /* GL_MAP1_VERTEX_3 */ - 912, /* GL_MAP1_VERTEX_4 */ - 929, /* GL_MAP2_COLOR_4 */ - 932, /* GL_MAP2_INDEX */ - 933, /* GL_MAP2_NORMAL */ - 934, /* GL_MAP2_TEXTURE_COORD_1 */ - 935, /* GL_MAP2_TEXTURE_COORD_2 */ - 936, /* GL_MAP2_TEXTURE_COORD_3 */ - 937, /* GL_MAP2_TEXTURE_COORD_4 */ - 938, /* GL_MAP2_VERTEX_3 */ - 939, /* GL_MAP2_VERTEX_4 */ - 903, /* GL_MAP1_GRID_DOMAIN */ - 904, /* GL_MAP1_GRID_SEGMENTS */ - 930, /* GL_MAP2_GRID_DOMAIN */ - 931, /* GL_MAP2_GRID_SEGMENTS */ - 1968, /* GL_TEXTURE_1D */ - 1971, /* GL_TEXTURE_2D */ - 542, /* GL_FEEDBACK_BUFFER_POINTER */ - 543, /* GL_FEEDBACK_BUFFER_SIZE */ - 544, /* GL_FEEDBACK_BUFFER_TYPE */ - 1755, /* GL_SELECTION_BUFFER_POINTER */ - 1756, /* GL_SELECTION_BUFFER_SIZE */ - 2117, /* GL_TEXTURE_WIDTH */ - 2077, /* GL_TEXTURE_HEIGHT */ - 2021, /* GL_TEXTURE_COMPONENTS */ - 1999, /* GL_TEXTURE_BORDER_COLOR */ - 1998, /* GL_TEXTURE_BORDER */ - 445, /* GL_DONT_CARE */ - 540, /* GL_FASTEST */ - 1227, /* GL_NICEST */ - 56, /* GL_AMBIENT */ - 442, /* GL_DIFFUSE */ - 1808, /* GL_SPECULAR */ - 1404, /* GL_POSITION */ - 1811, /* GL_SPOT_DIRECTION */ - 1812, /* GL_SPOT_EXPONENT */ - 1810, /* GL_SPOT_CUTOFF */ - 320, /* GL_CONSTANT_ATTENUATION */ - 830, /* GL_LINEAR_ATTENUATION */ - 1521, /* GL_QUADRATIC_ATTENUATION */ - 287, /* GL_COMPILE */ - 288, /* GL_COMPILE_AND_EXECUTE */ - 149, /* GL_BYTE */ - 2177, /* GL_UNSIGNED_BYTE */ - 1773, /* GL_SHORT */ - 2216, /* GL_UNSIGNED_SHORT */ - 752, /* GL_INT */ - 2180, /* GL_UNSIGNED_INT */ - 553, /* GL_FLOAT */ - 1, /* GL_2_BYTES */ - 5, /* GL_3_BYTES */ - 7, /* GL_4_BYTES */ - 452, /* GL_DOUBLE */ - 704, /* GL_HALF_FLOAT */ - 548, /* GL_FIXED */ - 165, /* GL_CLEAR */ - 58, /* GL_AND */ - 60, /* GL_AND_REVERSE */ - 351, /* GL_COPY */ - 59, /* GL_AND_INVERTED */ - 1230, /* GL_NOOP */ - 2312, /* GL_XOR */ - 1299, /* GL_OR */ - 1231, /* GL_NOR */ - 530, /* GL_EQUIV */ - 806, /* GL_INVERT */ - 1302, /* GL_OR_REVERSE */ - 352, /* GL_COPY_INVERTED */ - 1301, /* GL_OR_INVERTED */ - 1220, /* GL_NAND */ - 1762, /* GL_SET */ - 527, /* GL_EMISSION */ - 1772, /* GL_SHININESS */ - 57, /* GL_AMBIENT_AND_DIFFUSE */ - 232, /* GL_COLOR_INDEXES */ - 1169, /* GL_MODELVIEW */ - 1493, /* GL_PROJECTION */ - 1903, /* GL_TEXTURE */ - 188, /* GL_COLOR */ - 399, /* GL_DEPTH */ - 1834, /* GL_STENCIL */ - 231, /* GL_COLOR_INDEX */ - 1855, /* GL_STENCIL_INDEX */ - 415, /* GL_DEPTH_COMPONENT */ - 1558, /* GL_RED */ - 697, /* GL_GREEN */ - 110, /* GL_BLUE */ - 32, /* GL_ALPHA */ - 1615, /* GL_RGB */ - 1655, /* GL_RGBA */ - 865, /* GL_LUMINANCE */ - 892, /* GL_LUMINANCE_ALPHA */ - 86, /* GL_BITMAP */ - 1354, /* GL_POINT */ - 828, /* GL_LINE */ - 545, /* GL_FILL */ - 1572, /* GL_RENDER */ - 541, /* GL_FEEDBACK */ - 1754, /* GL_SELECT */ - 552, /* GL_FLAT */ - 1783, /* GL_SMOOTH */ - 807, /* GL_KEEP */ - 1605, /* GL_REPLACE */ - 733, /* GL_INCR */ - 395, /* GL_DECR */ - 2233, /* GL_VENDOR */ - 1602, /* GL_RENDERER */ - 2234, /* GL_VERSION */ - 534, /* GL_EXTENSIONS */ - 1703, /* GL_S */ - 1894, /* GL_T */ - 1541, /* GL_R */ - 1520, /* GL_Q */ - 1206, /* GL_MODULATE */ - 394, /* GL_DECAL */ - 2064, /* GL_TEXTURE_ENV_MODE */ - 2063, /* GL_TEXTURE_ENV_COLOR */ - 2062, /* GL_TEXTURE_ENV */ - 535, /* GL_EYE_LINEAR */ - 1260, /* GL_OBJECT_LINEAR */ - 1809, /* GL_SPHERE_MAP */ - 2067, /* GL_TEXTURE_GEN_MODE */ - 1262, /* GL_OBJECT_PLANE */ - 536, /* GL_EYE_PLANE */ - 1221, /* GL_NEAREST */ - 829, /* GL_LINEAR */ - 1225, /* GL_NEAREST_MIPMAP_NEAREST */ - 834, /* GL_LINEAR_MIPMAP_NEAREST */ - 1224, /* GL_NEAREST_MIPMAP_LINEAR */ - 833, /* GL_LINEAR_MIPMAP_LINEAR */ - 2090, /* GL_TEXTURE_MAG_FILTER */ - 2099, /* GL_TEXTURE_MIN_FILTER */ - 2120, /* GL_TEXTURE_WRAP_S */ - 2121, /* GL_TEXTURE_WRAP_T */ - 155, /* GL_CLAMP */ - 1604, /* GL_REPEAT */ - 1398, /* GL_POLYGON_OFFSET_UNITS */ - 1397, /* GL_POLYGON_OFFSET_POINT */ - 1396, /* GL_POLYGON_OFFSET_LINE */ - 1544, /* GL_R3_G3_B2 */ - 2230, /* GL_V2F */ - 2231, /* GL_V3F */ - 152, /* GL_C4UB_V2F */ - 153, /* GL_C4UB_V3F */ - 150, /* GL_C3F_V3F */ - 1218, /* GL_N3F_V3F */ - 151, /* GL_C4F_N3F_V3F */ - 1899, /* GL_T2F_V3F */ - 1901, /* GL_T4F_V4F */ - 1897, /* GL_T2F_C4UB_V3F */ - 1895, /* GL_T2F_C3F_V3F */ - 1898, /* GL_T2F_N3F_V3F */ - 1896, /* GL_T2F_C4F_N3F_V3F */ - 1900, /* GL_T4F_C4F_N3F_V4F */ - 172, /* GL_CLIP_DISTANCE0 */ - 173, /* GL_CLIP_DISTANCE1 */ - 174, /* GL_CLIP_DISTANCE2 */ - 175, /* GL_CLIP_DISTANCE3 */ - 176, /* GL_CLIP_DISTANCE4 */ - 177, /* GL_CLIP_DISTANCE5 */ - 178, /* GL_CLIP_DISTANCE6 */ - 179, /* GL_CLIP_DISTANCE7 */ - 813, /* GL_LIGHT0 */ - 814, /* GL_LIGHT1 */ - 815, /* GL_LIGHT2 */ - 816, /* GL_LIGHT3 */ - 817, /* GL_LIGHT4 */ - 818, /* GL_LIGHT5 */ - 819, /* GL_LIGHT6 */ - 820, /* GL_LIGHT7 */ - 708, /* GL_HINT_BIT */ - 322, /* GL_CONSTANT_COLOR */ - 1273, /* GL_ONE_MINUS_CONSTANT_COLOR */ - 317, /* GL_CONSTANT_ALPHA */ - 1271, /* GL_ONE_MINUS_CONSTANT_ALPHA */ - 89, /* GL_BLEND_COLOR */ - 674, /* GL_FUNC_ADD */ - 1150, /* GL_MIN */ - 1018, /* GL_MAX */ - 96, /* GL_BLEND_EQUATION */ - 680, /* GL_FUNC_SUBTRACT */ - 677, /* GL_FUNC_REVERSE_SUBTRACT */ - 331, /* GL_CONVOLUTION_1D */ - 332, /* GL_CONVOLUTION_2D */ - 1757, /* GL_SEPARABLE_2D */ - 335, /* GL_CONVOLUTION_BORDER_MODE */ - 339, /* GL_CONVOLUTION_FILTER_SCALE */ - 337, /* GL_CONVOLUTION_FILTER_BIAS */ - 1559, /* GL_REDUCE */ - 341, /* GL_CONVOLUTION_FORMAT */ - 345, /* GL_CONVOLUTION_WIDTH */ - 343, /* GL_CONVOLUTION_HEIGHT */ - 1037, /* GL_MAX_CONVOLUTION_WIDTH */ - 1035, /* GL_MAX_CONVOLUTION_HEIGHT */ - 1437, /* GL_POST_CONVOLUTION_RED_SCALE */ - 1433, /* GL_POST_CONVOLUTION_GREEN_SCALE */ - 1428, /* GL_POST_CONVOLUTION_BLUE_SCALE */ - 1424, /* GL_POST_CONVOLUTION_ALPHA_SCALE */ - 1435, /* GL_POST_CONVOLUTION_RED_BIAS */ - 1431, /* GL_POST_CONVOLUTION_GREEN_BIAS */ - 1426, /* GL_POST_CONVOLUTION_BLUE_BIAS */ - 1422, /* GL_POST_CONVOLUTION_ALPHA_BIAS */ - 709, /* GL_HISTOGRAM */ - 1500, /* GL_PROXY_HISTOGRAM */ - 725, /* GL_HISTOGRAM_WIDTH */ - 715, /* GL_HISTOGRAM_FORMAT */ - 721, /* GL_HISTOGRAM_RED_SIZE */ - 717, /* GL_HISTOGRAM_GREEN_SIZE */ - 712, /* GL_HISTOGRAM_BLUE_SIZE */ - 710, /* GL_HISTOGRAM_ALPHA_SIZE */ - 719, /* GL_HISTOGRAM_LUMINANCE_SIZE */ - 723, /* GL_HISTOGRAM_SINK */ - 1151, /* GL_MINMAX */ - 1153, /* GL_MINMAX_FORMAT */ - 1155, /* GL_MINMAX_SINK */ - 1902, /* GL_TABLE_TOO_LARGE_EXT */ - 2179, /* GL_UNSIGNED_BYTE_3_3_2 */ - 2219, /* GL_UNSIGNED_SHORT_4_4_4_4 */ - 2222, /* GL_UNSIGNED_SHORT_5_5_5_1 */ - 2191, /* GL_UNSIGNED_INT_8_8_8_8 */ - 2182, /* GL_UNSIGNED_INT_10_10_10_2 */ - 1395, /* GL_POLYGON_OFFSET_FILL */ - 1394, /* GL_POLYGON_OFFSET_FACTOR */ - 1393, /* GL_POLYGON_OFFSET_BIAS */ - 1608, /* GL_RESCALE_NORMAL */ - 41, /* GL_ALPHA4 */ - 43, /* GL_ALPHA8 */ - 33, /* GL_ALPHA12 */ - 35, /* GL_ALPHA16 */ - 880, /* GL_LUMINANCE4 */ - 886, /* GL_LUMINANCE8 */ - 866, /* GL_LUMINANCE12 */ - 872, /* GL_LUMINANCE16 */ - 881, /* GL_LUMINANCE4_ALPHA4 */ - 884, /* GL_LUMINANCE6_ALPHA2 */ - 889, /* GL_LUMINANCE8_ALPHA8 */ - 869, /* GL_LUMINANCE12_ALPHA4 */ - 867, /* GL_LUMINANCE12_ALPHA12 */ - 875, /* GL_LUMINANCE16_ALPHA16 */ - 753, /* GL_INTENSITY */ - 762, /* GL_INTENSITY4 */ - 764, /* GL_INTENSITY8 */ - 754, /* GL_INTENSITY12 */ - 756, /* GL_INTENSITY16 */ - 1630, /* GL_RGB2_EXT */ - 1636, /* GL_RGB4 */ - 1639, /* GL_RGB5 */ - 1646, /* GL_RGB8 */ - 1616, /* GL_RGB10 */ - 1620, /* GL_RGB12 */ - 1622, /* GL_RGB16 */ - 1666, /* GL_RGBA2 */ - 1673, /* GL_RGBA4 */ - 1642, /* GL_RGB5_A1 */ - 1678, /* GL_RGBA8 */ - 1617, /* GL_RGB10_A2 */ - 1656, /* GL_RGBA12 */ - 1658, /* GL_RGBA16 */ - 2107, /* GL_TEXTURE_RED_SIZE */ - 2075, /* GL_TEXTURE_GREEN_SIZE */ - 1996, /* GL_TEXTURE_BLUE_SIZE */ - 1976, /* GL_TEXTURE_ALPHA_SIZE */ - 2088, /* GL_TEXTURE_LUMINANCE_SIZE */ - 2079, /* GL_TEXTURE_INTENSITY_SIZE */ - 1606, /* GL_REPLACE_EXT */ - 1504, /* GL_PROXY_TEXTURE_1D */ - 1508, /* GL_PROXY_TEXTURE_2D */ - 2115, /* GL_TEXTURE_TOO_LARGE_EXT */ - 2101, /* GL_TEXTURE_PRIORITY */ - 2109, /* GL_TEXTURE_RESIDENT */ - 1979, /* GL_TEXTURE_BINDING_1D */ - 1982, /* GL_TEXTURE_BINDING_2D */ - 1985, /* GL_TEXTURE_BINDING_3D */ - 1309, /* GL_PACK_SKIP_IMAGES */ - 1305, /* GL_PACK_IMAGE_HEIGHT */ - 2172, /* GL_UNPACK_SKIP_IMAGES */ - 2169, /* GL_UNPACK_IMAGE_HEIGHT */ - 1974, /* GL_TEXTURE_3D */ - 1512, /* GL_PROXY_TEXTURE_3D */ - 2059, /* GL_TEXTURE_DEPTH */ - 2118, /* GL_TEXTURE_WRAP_R */ - 1019, /* GL_MAX_3D_TEXTURE_SIZE */ - 2235, /* GL_VERTEX_ARRAY */ - 1233, /* GL_NORMAL_ARRAY */ - 189, /* GL_COLOR_ARRAY */ - 737, /* GL_INDEX_ARRAY */ - 2029, /* GL_TEXTURE_COORD_ARRAY */ - 519, /* GL_EDGE_FLAG_ARRAY */ - 2241, /* GL_VERTEX_ARRAY_SIZE */ - 2243, /* GL_VERTEX_ARRAY_TYPE */ - 2242, /* GL_VERTEX_ARRAY_STRIDE */ - 1238, /* GL_NORMAL_ARRAY_TYPE */ - 1237, /* GL_NORMAL_ARRAY_STRIDE */ - 193, /* GL_COLOR_ARRAY_SIZE */ - 195, /* GL_COLOR_ARRAY_TYPE */ - 194, /* GL_COLOR_ARRAY_STRIDE */ - 742, /* GL_INDEX_ARRAY_TYPE */ - 741, /* GL_INDEX_ARRAY_STRIDE */ - 2033, /* GL_TEXTURE_COORD_ARRAY_SIZE */ - 2035, /* GL_TEXTURE_COORD_ARRAY_TYPE */ - 2034, /* GL_TEXTURE_COORD_ARRAY_STRIDE */ - 523, /* GL_EDGE_FLAG_ARRAY_STRIDE */ - 2240, /* GL_VERTEX_ARRAY_POINTER */ - 1236, /* GL_NORMAL_ARRAY_POINTER */ - 192, /* GL_COLOR_ARRAY_POINTER */ - 740, /* GL_INDEX_ARRAY_POINTER */ - 2032, /* GL_TEXTURE_COORD_ARRAY_POINTER */ - 522, /* GL_EDGE_FLAG_ARRAY_POINTER */ - 1211, /* GL_MULTISAMPLE */ - 1731, /* GL_SAMPLE_ALPHA_TO_COVERAGE */ - 1733, /* GL_SAMPLE_ALPHA_TO_ONE */ - 1738, /* GL_SAMPLE_COVERAGE */ - 1735, /* GL_SAMPLE_BUFFERS */ - 1726, /* GL_SAMPLES */ - 1742, /* GL_SAMPLE_COVERAGE_VALUE */ - 1740, /* GL_SAMPLE_COVERAGE_INVERT */ - 237, /* GL_COLOR_MATRIX */ - 239, /* GL_COLOR_MATRIX_STACK_DEPTH */ - 1031, /* GL_MAX_COLOR_MATRIX_STACK_DEPTH */ - 1420, /* GL_POST_COLOR_MATRIX_RED_SCALE */ - 1416, /* GL_POST_COLOR_MATRIX_GREEN_SCALE */ - 1411, /* GL_POST_COLOR_MATRIX_BLUE_SCALE */ - 1407, /* GL_POST_COLOR_MATRIX_ALPHA_SCALE */ - 1418, /* GL_POST_COLOR_MATRIX_RED_BIAS */ - 1414, /* GL_POST_COLOR_MATRIX_GREEN_BIAS */ - 1409, /* GL_POST_COLOR_MATRIX_BLUE_BIAS */ - 1405, /* GL_POST_COLOR_MATRIX_ALPHA_BIAS */ - 2012, /* GL_TEXTURE_COLOR_TABLE_SGI */ - 1513, /* GL_PROXY_TEXTURE_COLOR_TABLE_SGI */ - 2014, /* GL_TEXTURE_COMPARE_FAIL_VALUE_ARB */ - 94, /* GL_BLEND_DST_RGB */ - 108, /* GL_BLEND_SRC_RGB */ - 92, /* GL_BLEND_DST_ALPHA */ - 106, /* GL_BLEND_SRC_ALPHA */ - 243, /* GL_COLOR_TABLE */ - 1430, /* GL_POST_CONVOLUTION_COLOR_TABLE */ - 1413, /* GL_POST_COLOR_MATRIX_COLOR_TABLE */ - 1499, /* GL_PROXY_COLOR_TABLE */ - 1503, /* GL_PROXY_POST_CONVOLUTION_COLOR_TABLE */ - 1502, /* GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE */ - 267, /* GL_COLOR_TABLE_SCALE */ - 247, /* GL_COLOR_TABLE_BIAS */ - 252, /* GL_COLOR_TABLE_FORMAT */ - 269, /* GL_COLOR_TABLE_WIDTH */ - 264, /* GL_COLOR_TABLE_RED_SIZE */ - 255, /* GL_COLOR_TABLE_GREEN_SIZE */ - 249, /* GL_COLOR_TABLE_BLUE_SIZE */ - 244, /* GL_COLOR_TABLE_ALPHA_SIZE */ - 261, /* GL_COLOR_TABLE_LUMINANCE_SIZE */ - 258, /* GL_COLOR_TABLE_INTENSITY_SIZE */ - 79, /* GL_BGR */ - 80, /* GL_BGRA */ - 1046, /* GL_MAX_ELEMENTS_VERTICES */ - 1045, /* GL_MAX_ELEMENTS_INDICES */ - 2078, /* GL_TEXTURE_INDEX_SIZE_EXT */ - 186, /* GL_CLIP_VOLUME_CLIPPING_HINT_EXT */ - 1376, /* GL_POINT_SIZE_MIN */ - 1372, /* GL_POINT_SIZE_MAX */ - 1361, /* GL_POINT_FADE_THRESHOLD_SIZE */ - 1357, /* GL_POINT_DISTANCE_ATTENUATION */ - 159, /* GL_CLAMP_TO_BORDER */ - 162, /* GL_CLAMP_TO_EDGE */ - 2100, /* GL_TEXTURE_MIN_LOD */ - 2098, /* GL_TEXTURE_MAX_LOD */ - 1978, /* GL_TEXTURE_BASE_LEVEL */ - 2097, /* GL_TEXTURE_MAX_LEVEL */ - 728, /* GL_IGNORE_BORDER_HP */ - 321, /* GL_CONSTANT_BORDER_HP */ - 1607, /* GL_REPLICATE_BORDER_HP */ - 333, /* GL_CONVOLUTION_BORDER_COLOR */ - 1268, /* GL_OCCLUSION_TEST_HP */ - 1269, /* GL_OCCLUSION_TEST_RESULT_HP */ - 831, /* GL_LINEAR_CLIPMAP_LINEAR_SGIX */ - 2006, /* GL_TEXTURE_CLIPMAP_CENTER_SGIX */ - 2008, /* GL_TEXTURE_CLIPMAP_FRAME_SGIX */ - 2010, /* GL_TEXTURE_CLIPMAP_OFFSET_SGIX */ - 2011, /* GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX */ - 2009, /* GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX */ - 2007, /* GL_TEXTURE_CLIPMAP_DEPTH_SGIX */ - 1025, /* GL_MAX_CLIPMAP_DEPTH_SGIX */ - 1026, /* GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX */ - 1440, /* GL_POST_TEXTURE_FILTER_BIAS_SGIX */ - 1442, /* GL_POST_TEXTURE_FILTER_SCALE_SGIX */ - 1439, /* GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX */ - 1441, /* GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX */ - 2086, /* GL_TEXTURE_LOD_BIAS_S_SGIX */ - 2087, /* GL_TEXTURE_LOD_BIAS_T_SGIX */ - 2085, /* GL_TEXTURE_LOD_BIAS_R_SGIX */ - 683, /* GL_GENERATE_MIPMAP */ - 684, /* GL_GENERATE_MIPMAP_HINT */ - 596, /* GL_FOG_OFFSET_SGIX */ - 597, /* GL_FOG_OFFSET_VALUE_SGIX */ - 2020, /* GL_TEXTURE_COMPARE_SGIX */ - 2019, /* GL_TEXTURE_COMPARE_OPERATOR_SGIX */ - 2082, /* GL_TEXTURE_LEQUAL_R_SGIX */ - 2074, /* GL_TEXTURE_GEQUAL_R_SGIX */ - 416, /* GL_DEPTH_COMPONENT16 */ - 420, /* GL_DEPTH_COMPONENT24 */ - 424, /* GL_DEPTH_COMPONENT32 */ - 358, /* GL_CULL_VERTEX_EXT */ - 360, /* GL_CULL_VERTEX_OBJECT_POSITION_EXT */ - 359, /* GL_CULL_VERTEX_EYE_POSITION_EXT */ - 2308, /* GL_WRAP_BORDER_SUN */ - 2013, /* GL_TEXTURE_COLOR_WRITEMASK_SGIS */ - 824, /* GL_LIGHT_MODEL_COLOR_CONTROL */ - 1776, /* GL_SINGLE_COLOR */ - 1760, /* GL_SEPARATE_SPECULAR_COLOR */ - 1771, /* GL_SHARED_TEXTURE_PALETTE_EXT */ - 608, /* GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING */ - 609, /* GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE */ - 620, /* GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE */ - 611, /* GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE */ - 607, /* GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE */ - 606, /* GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE */ - 610, /* GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE */ - 621, /* GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE */ - 638, /* GL_FRAMEBUFFER_DEFAULT */ - 665, /* GL_FRAMEBUFFER_UNDEFINED */ - 432, /* GL_DEPTH_STENCIL_ATTACHMENT */ - 901, /* GL_MAJOR_VERSION */ - 1157, /* GL_MINOR_VERSION */ - 1248, /* GL_NUM_EXTENSIONS */ - 327, /* GL_CONTEXT_FLAGS */ - 736, /* GL_INDEX */ - 410, /* GL_DEPTH_BUFFER */ - 1850, /* GL_STENCIL_BUFFER */ - 298, /* GL_COMPRESSED_RED */ - 299, /* GL_COMPRESSED_RG */ - 861, /* GL_LOSE_CONTEXT_ON_RESET_ARB */ - 703, /* GL_GUILTY_CONTEXT_RESET_ARB */ - 751, /* GL_INNOCENT_CONTEXT_RESET_ARB */ - 2167, /* GL_UNKNOWN_CONTEXT_RESET_ARB */ - 1610, /* GL_RESET_NOTIFICATION_STRATEGY_ARB */ - 1462, /* GL_PROGRAM_BINARY_RETRIEVABLE_HINT */ - 1245, /* GL_NO_RESET_NOTIFICATION_ARB */ - 2178, /* GL_UNSIGNED_BYTE_2_3_3_REV */ - 2223, /* GL_UNSIGNED_SHORT_5_6_5 */ - 2224, /* GL_UNSIGNED_SHORT_5_6_5_REV */ - 2220, /* GL_UNSIGNED_SHORT_4_4_4_4_REV */ - 2217, /* GL_UNSIGNED_SHORT_1_5_5_5_REV */ - 2192, /* GL_UNSIGNED_INT_8_8_8_8_REV */ - 2188, /* GL_UNSIGNED_INT_2_10_10_10_REV */ - 2095, /* GL_TEXTURE_MAX_CLAMP_S_SGIX */ - 2096, /* GL_TEXTURE_MAX_CLAMP_T_SGIX */ - 2094, /* GL_TEXTURE_MAX_CLAMP_R_SGIX */ - 1161, /* GL_MIRRORED_REPEAT */ - 1696, /* GL_RGB_S3TC */ - 1638, /* GL_RGB4_S3TC */ - 1692, /* GL_RGBA_S3TC */ - 1677, /* GL_RGBA4_S3TC */ - 1686, /* GL_RGBA_DXT5_S3TC */ - 1674, /* GL_RGBA4_DXT5_S3TC */ - 309, /* GL_COMPRESSED_RGB_S3TC_DXT1_EXT */ - 304, /* GL_COMPRESSED_RGBA_S3TC_DXT1_EXT */ - 305, /* GL_COMPRESSED_RGBA_S3TC_DXT3_EXT */ - 306, /* GL_COMPRESSED_RGBA_S3TC_DXT5_EXT */ - 1223, /* GL_NEAREST_CLIPMAP_NEAREST_SGIX */ - 1222, /* GL_NEAREST_CLIPMAP_LINEAR_SGIX */ - 832, /* GL_LINEAR_CLIPMAP_NEAREST_SGIX */ - 583, /* GL_FOG_COORDINATE_SOURCE */ - 575, /* GL_FOG_COORD */ - 599, /* GL_FRAGMENT_DEPTH */ - 364, /* GL_CURRENT_FOG_COORD */ - 582, /* GL_FOG_COORDINATE_ARRAY_TYPE */ - 581, /* GL_FOG_COORDINATE_ARRAY_STRIDE */ - 580, /* GL_FOG_COORDINATE_ARRAY_POINTER */ - 577, /* GL_FOG_COORDINATE_ARRAY */ - 241, /* GL_COLOR_SUM */ - 385, /* GL_CURRENT_SECONDARY_COLOR */ - 1751, /* GL_SECONDARY_COLOR_ARRAY_SIZE */ - 1753, /* GL_SECONDARY_COLOR_ARRAY_TYPE */ - 1752, /* GL_SECONDARY_COLOR_ARRAY_STRIDE */ - 1750, /* GL_SECONDARY_COLOR_ARRAY_POINTER */ - 1747, /* GL_SECONDARY_COLOR_ARRAY */ - 383, /* GL_CURRENT_RASTER_SECONDARY_COLOR */ - 29, /* GL_ALIASED_POINT_SIZE_RANGE */ - 28, /* GL_ALIASED_LINE_WIDTH_RANGE */ - 1904, /* GL_TEXTURE0 */ - 1906, /* GL_TEXTURE1 */ - 1928, /* GL_TEXTURE2 */ - 1950, /* GL_TEXTURE3 */ - 1956, /* GL_TEXTURE4 */ - 1958, /* GL_TEXTURE5 */ - 1960, /* GL_TEXTURE6 */ - 1962, /* GL_TEXTURE7 */ - 1964, /* GL_TEXTURE8 */ - 1966, /* GL_TEXTURE9 */ - 1907, /* GL_TEXTURE10 */ - 1909, /* GL_TEXTURE11 */ - 1911, /* GL_TEXTURE12 */ - 1913, /* GL_TEXTURE13 */ - 1915, /* GL_TEXTURE14 */ - 1917, /* GL_TEXTURE15 */ - 1919, /* GL_TEXTURE16 */ - 1921, /* GL_TEXTURE17 */ - 1923, /* GL_TEXTURE18 */ - 1925, /* GL_TEXTURE19 */ - 1929, /* GL_TEXTURE20 */ - 1931, /* GL_TEXTURE21 */ - 1933, /* GL_TEXTURE22 */ - 1935, /* GL_TEXTURE23 */ - 1937, /* GL_TEXTURE24 */ - 1939, /* GL_TEXTURE25 */ - 1941, /* GL_TEXTURE26 */ - 1943, /* GL_TEXTURE27 */ - 1945, /* GL_TEXTURE28 */ - 1947, /* GL_TEXTURE29 */ - 1951, /* GL_TEXTURE30 */ - 1953, /* GL_TEXTURE31 */ - 19, /* GL_ACTIVE_TEXTURE */ - 166, /* GL_CLIENT_ACTIVE_TEXTURE */ - 1122, /* GL_MAX_TEXTURE_UNITS */ - 2150, /* GL_TRANSPOSE_MODELVIEW_MATRIX */ - 2153, /* GL_TRANSPOSE_PROJECTION_MATRIX */ - 2155, /* GL_TRANSPOSE_TEXTURE_MATRIX */ - 2147, /* GL_TRANSPOSE_COLOR_MATRIX */ - 1886, /* GL_SUBTRACT */ - 1103, /* GL_MAX_RENDERBUFFER_SIZE */ - 290, /* GL_COMPRESSED_ALPHA */ - 294, /* GL_COMPRESSED_LUMINANCE */ - 295, /* GL_COMPRESSED_LUMINANCE_ALPHA */ - 292, /* GL_COMPRESSED_INTENSITY */ - 300, /* GL_COMPRESSED_RGB */ - 301, /* GL_COMPRESSED_RGBA */ - 2027, /* GL_TEXTURE_COMPRESSION_HINT */ - 2104, /* GL_TEXTURE_RECTANGLE */ - 1992, /* GL_TEXTURE_BINDING_RECTANGLE */ - 1516, /* GL_PROXY_TEXTURE_RECTANGLE */ - 1100, /* GL_MAX_RECTANGLE_TEXTURE_SIZE */ - 431, /* GL_DEPTH_STENCIL */ - 2184, /* GL_UNSIGNED_INT_24_8 */ - 1117, /* GL_MAX_TEXTURE_LOD_BIAS */ - 2093, /* GL_TEXTURE_MAX_ANISOTROPY_EXT */ - 1119, /* GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT */ - 2065, /* GL_TEXTURE_FILTER_CONTROL */ - 2083, /* GL_TEXTURE_LOD_BIAS */ - 274, /* GL_COMBINE4 */ - 1109, /* GL_MAX_SHININESS_NV */ - 1110, /* GL_MAX_SPOT_EXPONENT_NV */ - 734, /* GL_INCR_WRAP */ - 396, /* GL_DECR_WRAP */ - 1181, /* GL_MODELVIEW1_ARB */ - 1239, /* GL_NORMAL_MAP */ - 1567, /* GL_REFLECTION_MAP */ - 2037, /* GL_TEXTURE_CUBE_MAP */ - 1989, /* GL_TEXTURE_BINDING_CUBE_MAP */ - 2049, /* GL_TEXTURE_CUBE_MAP_POSITIVE_X */ - 2039, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_X */ - 2052, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Y */ - 2042, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Y */ - 2055, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Z */ - 2045, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Z */ - 1514, /* GL_PROXY_TEXTURE_CUBE_MAP */ - 1039, /* GL_MAX_CUBE_MAP_TEXTURE_SIZE */ - 1217, /* GL_MULTISAMPLE_FILTER_HINT_NV */ - 1454, /* GL_PRIMITIVE_RESTART_NV */ - 1453, /* GL_PRIMITIVE_RESTART_INDEX_NV */ - 591, /* GL_FOG_DISTANCE_MODE_NV */ - 538, /* GL_EYE_RADIAL_NV */ - 537, /* GL_EYE_PLANE_ABSOLUTE_NV */ - 273, /* GL_COMBINE */ - 280, /* GL_COMBINE_RGB */ - 275, /* GL_COMBINE_ALPHA */ - 1697, /* GL_RGB_SCALE */ - 25, /* GL_ADD_SIGNED */ - 771, /* GL_INTERPOLATE */ - 316, /* GL_CONSTANT */ - 1446, /* GL_PRIMARY_COLOR */ - 1443, /* GL_PREVIOUS */ - 1791, /* GL_SOURCE0_RGB */ - 1797, /* GL_SOURCE1_RGB */ - 1803, /* GL_SOURCE2_RGB */ - 1807, /* GL_SOURCE3_RGB_NV */ - 1788, /* GL_SOURCE0_ALPHA */ - 1794, /* GL_SOURCE1_ALPHA */ - 1800, /* GL_SOURCE2_ALPHA */ - 1806, /* GL_SOURCE3_ALPHA_NV */ - 1282, /* GL_OPERAND0_RGB */ - 1288, /* GL_OPERAND1_RGB */ - 1294, /* GL_OPERAND2_RGB */ - 1298, /* GL_OPERAND3_RGB_NV */ - 1279, /* GL_OPERAND0_ALPHA */ - 1285, /* GL_OPERAND1_ALPHA */ - 1291, /* GL_OPERAND2_ALPHA */ - 1297, /* GL_OPERAND3_ALPHA_NV */ - 137, /* GL_BUFFER_OBJECT_APPLE */ - 2236, /* GL_VERTEX_ARRAY_BINDING */ - 2102, /* GL_TEXTURE_RANGE_LENGTH_APPLE */ - 2103, /* GL_TEXTURE_RANGE_POINTER_APPLE */ - 2313, /* GL_YCBCR_422_APPLE */ - 2225, /* GL_UNSIGNED_SHORT_8_8_APPLE */ - 2227, /* GL_UNSIGNED_SHORT_8_8_REV_APPLE */ - 2114, /* GL_TEXTURE_STORAGE_HINT_APPLE */ - 1877, /* GL_STORAGE_PRIVATE_APPLE */ - 1876, /* GL_STORAGE_CACHED_APPLE */ - 1878, /* GL_STORAGE_SHARED_APPLE */ - 1778, /* GL_SLICE_ACCUM_SUN */ - 1525, /* GL_QUAD_MESH_SUN */ - 2161, /* GL_TRIANGLE_MESH_SUN */ - 2278, /* GL_VERTEX_PROGRAM_ARB */ - 2289, /* GL_VERTEX_STATE_PROGRAM_NV */ - 2263, /* GL_VERTEX_ATTRIB_ARRAY_ENABLED */ - 2271, /* GL_VERTEX_ATTRIB_ARRAY_SIZE */ - 2273, /* GL_VERTEX_ATTRIB_ARRAY_STRIDE */ - 2275, /* GL_VERTEX_ATTRIB_ARRAY_TYPE */ - 387, /* GL_CURRENT_VERTEX_ATTRIB */ - 1470, /* GL_PROGRAM_LENGTH_ARB */ - 1486, /* GL_PROGRAM_STRING_ARB */ - 1204, /* GL_MODELVIEW_PROJECTION_NV */ - 727, /* GL_IDENTITY_NV */ - 804, /* GL_INVERSE_NV */ - 2152, /* GL_TRANSPOSE_NV */ - 805, /* GL_INVERSE_TRANSPOSE_NV */ - 1084, /* GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB */ - 1083, /* GL_MAX_PROGRAM_MATRICES_ARB */ - 965, /* GL_MATRIX0_NV */ - 977, /* GL_MATRIX1_NV */ - 989, /* GL_MATRIX2_NV */ - 993, /* GL_MATRIX3_NV */ - 995, /* GL_MATRIX4_NV */ - 997, /* GL_MATRIX5_NV */ - 999, /* GL_MATRIX6_NV */ - 1001, /* GL_MATRIX7_NV */ - 370, /* GL_CURRENT_MATRIX_STACK_DEPTH_ARB */ - 367, /* GL_CURRENT_MATRIX_ARB */ - 1483, /* GL_PROGRAM_POINT_SIZE */ - 2284, /* GL_VERTEX_PROGRAM_TWO_SIDE */ - 1482, /* GL_PROGRAM_PARAMETER_NV */ - 2269, /* GL_VERTEX_ATTRIB_ARRAY_POINTER */ - 1488, /* GL_PROGRAM_TARGET_NV */ - 1485, /* GL_PROGRAM_RESIDENT_NV */ - 2124, /* GL_TRACK_MATRIX_NV */ - 2125, /* GL_TRACK_MATRIX_TRANSFORM_NV */ - 2279, /* GL_VERTEX_PROGRAM_BINDING_NV */ - 1464, /* GL_PROGRAM_ERROR_POSITION_ARB */ - 412, /* GL_DEPTH_CLAMP */ - 2244, /* GL_VERTEX_ATTRIB_ARRAY0_NV */ - 2251, /* GL_VERTEX_ATTRIB_ARRAY1_NV */ - 2252, /* GL_VERTEX_ATTRIB_ARRAY2_NV */ - 2253, /* GL_VERTEX_ATTRIB_ARRAY3_NV */ - 2254, /* GL_VERTEX_ATTRIB_ARRAY4_NV */ - 2255, /* GL_VERTEX_ATTRIB_ARRAY5_NV */ - 2256, /* GL_VERTEX_ATTRIB_ARRAY6_NV */ - 2257, /* GL_VERTEX_ATTRIB_ARRAY7_NV */ - 2258, /* GL_VERTEX_ATTRIB_ARRAY8_NV */ - 2259, /* GL_VERTEX_ATTRIB_ARRAY9_NV */ - 2245, /* GL_VERTEX_ATTRIB_ARRAY10_NV */ - 2246, /* GL_VERTEX_ATTRIB_ARRAY11_NV */ - 2247, /* GL_VERTEX_ATTRIB_ARRAY12_NV */ - 2248, /* GL_VERTEX_ATTRIB_ARRAY13_NV */ - 2249, /* GL_VERTEX_ATTRIB_ARRAY14_NV */ - 2250, /* GL_VERTEX_ATTRIB_ARRAY15_NV */ - 913, /* GL_MAP1_VERTEX_ATTRIB0_4_NV */ - 920, /* GL_MAP1_VERTEX_ATTRIB1_4_NV */ - 921, /* GL_MAP1_VERTEX_ATTRIB2_4_NV */ - 922, /* GL_MAP1_VERTEX_ATTRIB3_4_NV */ - 923, /* GL_MAP1_VERTEX_ATTRIB4_4_NV */ - 924, /* GL_MAP1_VERTEX_ATTRIB5_4_NV */ - 925, /* GL_MAP1_VERTEX_ATTRIB6_4_NV */ - 926, /* GL_MAP1_VERTEX_ATTRIB7_4_NV */ - 927, /* GL_MAP1_VERTEX_ATTRIB8_4_NV */ - 928, /* GL_MAP1_VERTEX_ATTRIB9_4_NV */ - 914, /* GL_MAP1_VERTEX_ATTRIB10_4_NV */ - 915, /* GL_MAP1_VERTEX_ATTRIB11_4_NV */ - 916, /* GL_MAP1_VERTEX_ATTRIB12_4_NV */ - 917, /* GL_MAP1_VERTEX_ATTRIB13_4_NV */ - 918, /* GL_MAP1_VERTEX_ATTRIB14_4_NV */ - 919, /* GL_MAP1_VERTEX_ATTRIB15_4_NV */ - 940, /* GL_MAP2_VERTEX_ATTRIB0_4_NV */ - 947, /* GL_MAP2_VERTEX_ATTRIB1_4_NV */ - 948, /* GL_MAP2_VERTEX_ATTRIB2_4_NV */ - 949, /* GL_MAP2_VERTEX_ATTRIB3_4_NV */ - 950, /* GL_MAP2_VERTEX_ATTRIB4_4_NV */ - 951, /* GL_MAP2_VERTEX_ATTRIB5_4_NV */ - 952, /* GL_MAP2_VERTEX_ATTRIB6_4_NV */ - 1463, /* GL_PROGRAM_BINDING_ARB */ - 954, /* GL_MAP2_VERTEX_ATTRIB8_4_NV */ - 955, /* GL_MAP2_VERTEX_ATTRIB9_4_NV */ - 941, /* GL_MAP2_VERTEX_ATTRIB10_4_NV */ - 942, /* GL_MAP2_VERTEX_ATTRIB11_4_NV */ - 943, /* GL_MAP2_VERTEX_ATTRIB12_4_NV */ - 944, /* GL_MAP2_VERTEX_ATTRIB13_4_NV */ - 945, /* GL_MAP2_VERTEX_ATTRIB14_4_NV */ - 946, /* GL_MAP2_VERTEX_ATTRIB15_4_NV */ - 2025, /* GL_TEXTURE_COMPRESSED_IMAGE_SIZE */ - 2022, /* GL_TEXTURE_COMPRESSED */ - 1246, /* GL_NUM_COMPRESSED_TEXTURE_FORMATS */ - 314, /* GL_COMPRESSED_TEXTURE_FORMATS */ - 1144, /* GL_MAX_VERTEX_UNITS_ARB */ - 23, /* GL_ACTIVE_VERTEX_UNITS_ARB */ - 2307, /* GL_WEIGHT_SUM_UNITY_ARB */ - 2277, /* GL_VERTEX_BLEND_ARB */ - 389, /* GL_CURRENT_WEIGHT_ARB */ - 2305, /* GL_WEIGHT_ARRAY_TYPE_ARB */ - 2303, /* GL_WEIGHT_ARRAY_STRIDE_ARB */ - 2301, /* GL_WEIGHT_ARRAY_SIZE_ARB */ - 2299, /* GL_WEIGHT_ARRAY_POINTER_ARB */ - 2294, /* GL_WEIGHT_ARRAY_ARB */ - 446, /* GL_DOT3_RGB */ - 447, /* GL_DOT3_RGBA */ - 308, /* GL_COMPRESSED_RGB_FXT1_3DFX */ - 303, /* GL_COMPRESSED_RGBA_FXT1_3DFX */ - 1212, /* GL_MULTISAMPLE_3DFX */ - 1736, /* GL_SAMPLE_BUFFERS_3DFX */ - 1727, /* GL_SAMPLES_3DFX */ - 1192, /* GL_MODELVIEW2_ARB */ - 1195, /* GL_MODELVIEW3_ARB */ - 1196, /* GL_MODELVIEW4_ARB */ - 1197, /* GL_MODELVIEW5_ARB */ - 1198, /* GL_MODELVIEW6_ARB */ - 1199, /* GL_MODELVIEW7_ARB */ - 1200, /* GL_MODELVIEW8_ARB */ - 1201, /* GL_MODELVIEW9_ARB */ - 1171, /* GL_MODELVIEW10_ARB */ - 1172, /* GL_MODELVIEW11_ARB */ - 1173, /* GL_MODELVIEW12_ARB */ - 1174, /* GL_MODELVIEW13_ARB */ - 1175, /* GL_MODELVIEW14_ARB */ - 1176, /* GL_MODELVIEW15_ARB */ - 1177, /* GL_MODELVIEW16_ARB */ - 1178, /* GL_MODELVIEW17_ARB */ - 1179, /* GL_MODELVIEW18_ARB */ - 1180, /* GL_MODELVIEW19_ARB */ - 1182, /* GL_MODELVIEW20_ARB */ - 1183, /* GL_MODELVIEW21_ARB */ - 1184, /* GL_MODELVIEW22_ARB */ - 1185, /* GL_MODELVIEW23_ARB */ - 1186, /* GL_MODELVIEW24_ARB */ - 1187, /* GL_MODELVIEW25_ARB */ - 1188, /* GL_MODELVIEW26_ARB */ - 1189, /* GL_MODELVIEW27_ARB */ - 1190, /* GL_MODELVIEW28_ARB */ - 1191, /* GL_MODELVIEW29_ARB */ - 1193, /* GL_MODELVIEW30_ARB */ - 1194, /* GL_MODELVIEW31_ARB */ - 451, /* GL_DOT3_RGB_EXT */ - 1460, /* GL_PROGRAM_BINARY_LENGTH */ - 1165, /* GL_MIRROR_CLAMP_EXT */ - 1168, /* GL_MIRROR_CLAMP_TO_EDGE_EXT */ - 1207, /* GL_MODULATE_ADD_ATI */ - 1208, /* GL_MODULATE_SIGNED_ADD_ATI */ - 1209, /* GL_MODULATE_SUBTRACT_ATI */ - 2314, /* GL_YCBCR_MESA */ - 1306, /* GL_PACK_INVERT_MESA */ - 392, /* GL_DEBUG_OBJECT_MESA */ - 393, /* GL_DEBUG_PRINT_MESA */ - 391, /* GL_DEBUG_ASSERT_MESA */ - 139, /* GL_BUFFER_SIZE */ - 141, /* GL_BUFFER_USAGE */ - 145, /* GL_BUMP_ROT_MATRIX_ATI */ - 146, /* GL_BUMP_ROT_MATRIX_SIZE_ATI */ - 144, /* GL_BUMP_NUM_TEX_UNITS_ATI */ - 148, /* GL_BUMP_TEX_UNITS_ATI */ - 511, /* GL_DUDV_ATI */ - 510, /* GL_DU8DV8_ATI */ - 143, /* GL_BUMP_ENVMAP_ATI */ - 147, /* GL_BUMP_TARGET_ATI */ - 1249, /* GL_NUM_PROGRAM_BINARY_FORMATS */ - 1458, /* GL_PROGRAM_BINARY_FORMATS */ - 1840, /* GL_STENCIL_BACK_FUNC */ - 1838, /* GL_STENCIL_BACK_FAIL */ - 1842, /* GL_STENCIL_BACK_PASS_DEPTH_FAIL */ - 1844, /* GL_STENCIL_BACK_PASS_DEPTH_PASS */ - 600, /* GL_FRAGMENT_PROGRAM_ARB */ - 1456, /* GL_PROGRAM_ALU_INSTRUCTIONS_ARB */ - 1491, /* GL_PROGRAM_TEX_INSTRUCTIONS_ARB */ - 1490, /* GL_PROGRAM_TEX_INDIRECTIONS_ARB */ - 1473, /* GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB */ - 1479, /* GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB */ - 1478, /* GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB */ - 1073, /* GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB */ - 1098, /* GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB */ - 1097, /* GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB */ - 1086, /* GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB */ - 1092, /* GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB */ - 1091, /* GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB */ - 1668, /* GL_RGBA32F */ - 1631, /* GL_RGB32F */ - 1659, /* GL_RGBA16F */ - 1623, /* GL_RGB16F */ - 1687, /* GL_RGBA_FLOAT_MODE_ARB */ - 1042, /* GL_MAX_DRAW_BUFFERS */ - 455, /* GL_DRAW_BUFFER0 */ - 458, /* GL_DRAW_BUFFER1 */ - 479, /* GL_DRAW_BUFFER2 */ - 482, /* GL_DRAW_BUFFER3 */ - 485, /* GL_DRAW_BUFFER4 */ - 488, /* GL_DRAW_BUFFER5 */ - 491, /* GL_DRAW_BUFFER6 */ - 494, /* GL_DRAW_BUFFER7 */ - 497, /* GL_DRAW_BUFFER8 */ - 500, /* GL_DRAW_BUFFER9 */ - 459, /* GL_DRAW_BUFFER10 */ - 462, /* GL_DRAW_BUFFER11 */ - 465, /* GL_DRAW_BUFFER12 */ - 468, /* GL_DRAW_BUFFER13 */ - 471, /* GL_DRAW_BUFFER14 */ - 474, /* GL_DRAW_BUFFER15 */ - 97, /* GL_BLEND_EQUATION_ALPHA */ - 1016, /* GL_MATRIX_PALETTE_ARB */ - 1066, /* GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB */ - 1069, /* GL_MAX_PALETTE_MATRICES_ARB */ - 373, /* GL_CURRENT_PALETTE_MATRIX_ARB */ - 1004, /* GL_MATRIX_INDEX_ARRAY_ARB */ - 368, /* GL_CURRENT_MATRIX_INDEX_ARB */ - 1009, /* GL_MATRIX_INDEX_ARRAY_SIZE_ARB */ - 1013, /* GL_MATRIX_INDEX_ARRAY_TYPE_ARB */ - 1011, /* GL_MATRIX_INDEX_ARRAY_STRIDE_ARB */ - 1007, /* GL_MATRIX_INDEX_ARRAY_POINTER_ARB */ - 2060, /* GL_TEXTURE_DEPTH_SIZE */ - 439, /* GL_DEPTH_TEXTURE_MODE */ - 2017, /* GL_TEXTURE_COMPARE_MODE */ - 2015, /* GL_TEXTURE_COMPARE_FUNC */ - 284, /* GL_COMPARE_REF_TO_TEXTURE */ - 1383, /* GL_POINT_SPRITE */ - 347, /* GL_COORD_REPLACE */ - 1388, /* GL_POINT_SPRITE_R_MODE_NV */ - 1531, /* GL_QUERY_COUNTER_BITS */ - 376, /* GL_CURRENT_QUERY */ - 1535, /* GL_QUERY_RESULT */ - 1537, /* GL_QUERY_RESULT_AVAILABLE */ - 1136, /* GL_MAX_VERTEX_ATTRIBS */ - 2267, /* GL_VERTEX_ATTRIB_ARRAY_NORMALIZED */ - 437, /* GL_DEPTH_STENCIL_TO_RGBA_NV */ - 436, /* GL_DEPTH_STENCIL_TO_BGRA_NV */ - 1113, /* GL_MAX_TEXTURE_COORDS */ - 1115, /* GL_MAX_TEXTURE_IMAGE_UNITS */ - 1466, /* GL_PROGRAM_ERROR_STRING_ARB */ - 1468, /* GL_PROGRAM_FORMAT_ASCII_ARB */ - 1467, /* GL_PROGRAM_FORMAT_ARB */ - 2116, /* GL_TEXTURE_UNSIGNED_REMAP_MODE_NV */ - 409, /* GL_DEPTH_BOUNDS_TEST_EXT */ - 408, /* GL_DEPTH_BOUNDS_EXT */ - 61, /* GL_ARRAY_BUFFER */ - 524, /* GL_ELEMENT_ARRAY_BUFFER */ - 62, /* GL_ARRAY_BUFFER_BINDING */ - 525, /* GL_ELEMENT_ARRAY_BUFFER_BINDING */ - 2238, /* GL_VERTEX_ARRAY_BUFFER_BINDING */ - 1234, /* GL_NORMAL_ARRAY_BUFFER_BINDING */ - 190, /* GL_COLOR_ARRAY_BUFFER_BINDING */ - 738, /* GL_INDEX_ARRAY_BUFFER_BINDING */ - 2030, /* GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING */ - 520, /* GL_EDGE_FLAG_ARRAY_BUFFER_BINDING */ - 1748, /* GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING */ - 578, /* GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING */ - 2295, /* GL_WEIGHT_ARRAY_BUFFER_BINDING */ - 2260, /* GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING */ - 1469, /* GL_PROGRAM_INSTRUCTIONS_ARB */ - 1079, /* GL_MAX_PROGRAM_INSTRUCTIONS_ARB */ - 1475, /* GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB */ - 1088, /* GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB */ - 1489, /* GL_PROGRAM_TEMPORARIES_ARB */ - 1094, /* GL_MAX_PROGRAM_TEMPORARIES_ARB */ - 1477, /* GL_PROGRAM_NATIVE_TEMPORARIES_ARB */ - 1090, /* GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB */ - 1481, /* GL_PROGRAM_PARAMETERS_ARB */ - 1093, /* GL_MAX_PROGRAM_PARAMETERS_ARB */ - 1476, /* GL_PROGRAM_NATIVE_PARAMETERS_ARB */ - 1089, /* GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB */ - 1457, /* GL_PROGRAM_ATTRIBS_ARB */ - 1074, /* GL_MAX_PROGRAM_ATTRIBS_ARB */ - 1474, /* GL_PROGRAM_NATIVE_ATTRIBS_ARB */ - 1087, /* GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB */ - 1455, /* GL_PROGRAM_ADDRESS_REGISTERS_ARB */ - 1072, /* GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB */ - 1472, /* GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB */ - 1085, /* GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB */ - 1080, /* GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB */ - 1076, /* GL_MAX_PROGRAM_ENV_PARAMETERS_ARB */ - 1492, /* GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB */ - 2149, /* GL_TRANSPOSE_CURRENT_MATRIX_ARB */ - 1554, /* GL_READ_ONLY */ - 2309, /* GL_WRITE_ONLY */ - 1556, /* GL_READ_WRITE */ - 124, /* GL_BUFFER_ACCESS */ - 129, /* GL_BUFFER_MAPPED */ - 134, /* GL_BUFFER_MAP_POINTER */ - 2123, /* GL_TIME_ELAPSED_EXT */ - 964, /* GL_MATRIX0_ARB */ - 976, /* GL_MATRIX1_ARB */ - 988, /* GL_MATRIX2_ARB */ - 992, /* GL_MATRIX3_ARB */ - 994, /* GL_MATRIX4_ARB */ - 996, /* GL_MATRIX5_ARB */ - 998, /* GL_MATRIX6_ARB */ - 1000, /* GL_MATRIX7_ARB */ - 1002, /* GL_MATRIX8_ARB */ - 1003, /* GL_MATRIX9_ARB */ - 966, /* GL_MATRIX10_ARB */ - 967, /* GL_MATRIX11_ARB */ - 968, /* GL_MATRIX12_ARB */ - 969, /* GL_MATRIX13_ARB */ - 970, /* GL_MATRIX14_ARB */ - 971, /* GL_MATRIX15_ARB */ - 972, /* GL_MATRIX16_ARB */ - 973, /* GL_MATRIX17_ARB */ - 974, /* GL_MATRIX18_ARB */ - 975, /* GL_MATRIX19_ARB */ - 978, /* GL_MATRIX20_ARB */ - 979, /* GL_MATRIX21_ARB */ - 980, /* GL_MATRIX22_ARB */ - 981, /* GL_MATRIX23_ARB */ - 982, /* GL_MATRIX24_ARB */ - 983, /* GL_MATRIX25_ARB */ - 984, /* GL_MATRIX26_ARB */ - 985, /* GL_MATRIX27_ARB */ - 986, /* GL_MATRIX28_ARB */ - 987, /* GL_MATRIX29_ARB */ - 990, /* GL_MATRIX30_ARB */ - 991, /* GL_MATRIX31_ARB */ - 1881, /* GL_STREAM_DRAW */ - 1883, /* GL_STREAM_READ */ - 1879, /* GL_STREAM_COPY */ - 1830, /* GL_STATIC_DRAW */ - 1832, /* GL_STATIC_READ */ - 1828, /* GL_STATIC_COPY */ - 514, /* GL_DYNAMIC_DRAW */ - 516, /* GL_DYNAMIC_READ */ - 512, /* GL_DYNAMIC_COPY */ - 1346, /* GL_PIXEL_PACK_BUFFER */ - 1350, /* GL_PIXEL_UNPACK_BUFFER */ - 1347, /* GL_PIXEL_PACK_BUFFER_BINDING */ - 1351, /* GL_PIXEL_UNPACK_BUFFER_BINDING */ - 400, /* GL_DEPTH24_STENCIL8 */ - 2112, /* GL_TEXTURE_STENCIL_SIZE */ - 2058, /* GL_TEXTURE_CUBE_MAP_SEAMLESS */ - 1075, /* GL_MAX_PROGRAM_CALL_DEPTH_NV */ - 1078, /* GL_MAX_PROGRAM_IF_DEPTH_NV */ - 1082, /* GL_MAX_PROGRAM_LOOP_DEPTH_NV */ - 1081, /* GL_MAX_PROGRAM_LOOP_COUNT_NV */ - 2265, /* GL_VERTEX_ATTRIB_ARRAY_INTEGER */ - 2262, /* GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB */ - 1021, /* GL_MAX_ARRAY_TEXTURE_LAYERS */ - 1159, /* GL_MIN_PROGRAM_TEXEL_OFFSET */ - 1095, /* GL_MAX_PROGRAM_TEXEL_OFFSET */ - 1872, /* GL_STENCIL_TEST_TWO_SIDE_EXT */ - 18, /* GL_ACTIVE_STENCIL_FACE_EXT */ - 1166, /* GL_MIRROR_CLAMP_TO_BORDER_EXT */ - 1729, /* GL_SAMPLES_PASSED */ - 693, /* GL_GEOMETRY_VERTICES_OUT */ - 687, /* GL_GEOMETRY_INPUT_TYPE */ - 689, /* GL_GEOMETRY_OUTPUT_TYPE */ - 1720, /* GL_SAMPLER_BINDING */ - 164, /* GL_CLAMP_VERTEX_COLOR_ARB */ - 156, /* GL_CLAMP_FRAGMENT_COLOR_ARB */ - 157, /* GL_CLAMP_READ_COLOR */ - 550, /* GL_FIXED_ONLY */ - 1370, /* GL_POINT_SIZE_ARRAY_TYPE_OES */ - 1369, /* GL_POINT_SIZE_ARRAY_STRIDE_OES */ - 1368, /* GL_POINT_SIZE_ARRAY_POINTER_OES */ - 1203, /* GL_MODELVIEW_MATRIX_FLOAT_AS_INT_BITS_OES */ - 1495, /* GL_PROJECTION_MATRIX_FLOAT_AS_INT_BITS_OES */ - 2092, /* GL_TEXTURE_MATRIX_FLOAT_AS_INT_BITS_OES */ - 138, /* GL_BUFFER_SERIALIZED_MODIFY_APPLE */ - 128, /* GL_BUFFER_FLUSHING_UNMAP_APPLE */ - 1571, /* GL_RELEASED_APPLE */ - 2292, /* GL_VOLATILE_APPLE */ - 1611, /* GL_RETAINED_APPLE */ - 2166, /* GL_UNDEFINED_APPLE */ - 1519, /* GL_PURGEABLE_APPLE */ - 601, /* GL_FRAGMENT_SHADER */ - 2287, /* GL_VERTEX_SHADER */ - 1480, /* GL_PROGRAM_OBJECT_ARB */ - 1765, /* GL_SHADER_OBJECT_ARB */ - 1050, /* GL_MAX_FRAGMENT_UNIFORM_COMPONENTS */ - 1141, /* GL_MAX_VERTEX_UNIFORM_COMPONENTS */ - 1132, /* GL_MAX_VARYING_COMPONENTS */ - 1139, /* GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS */ - 1033, /* GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS */ - 1266, /* GL_OBJECT_TYPE_ARB */ - 1767, /* GL_SHADER_TYPE */ - 566, /* GL_FLOAT_VEC2 */ - 568, /* GL_FLOAT_VEC3 */ - 570, /* GL_FLOAT_VEC4 */ - 792, /* GL_INT_VEC2 */ - 794, /* GL_INT_VEC3 */ - 796, /* GL_INT_VEC4 */ - 116, /* GL_BOOL */ - 118, /* GL_BOOL_VEC2 */ - 120, /* GL_BOOL_VEC3 */ - 122, /* GL_BOOL_VEC4 */ - 554, /* GL_FLOAT_MAT2 */ - 558, /* GL_FLOAT_MAT3 */ - 562, /* GL_FLOAT_MAT4 */ - 1704, /* GL_SAMPLER_1D */ - 1710, /* GL_SAMPLER_2D */ - 1718, /* GL_SAMPLER_3D */ - 1723, /* GL_SAMPLER_CUBE */ - 1709, /* GL_SAMPLER_1D_SHADOW */ - 1717, /* GL_SAMPLER_2D_SHADOW */ - 1715, /* GL_SAMPLER_2D_RECT */ - 1716, /* GL_SAMPLER_2D_RECT_SHADOW */ - 556, /* GL_FLOAT_MAT2x3 */ - 557, /* GL_FLOAT_MAT2x4 */ - 560, /* GL_FLOAT_MAT3x2 */ - 561, /* GL_FLOAT_MAT3x4 */ - 564, /* GL_FLOAT_MAT4x2 */ - 565, /* GL_FLOAT_MAT4x3 */ - 398, /* GL_DELETE_STATUS */ - 289, /* GL_COMPILE_STATUS */ - 853, /* GL_LINK_STATUS */ - 2232, /* GL_VALIDATE_STATUS */ - 750, /* GL_INFO_LOG_LENGTH */ - 64, /* GL_ATTACHED_SHADERS */ - 21, /* GL_ACTIVE_UNIFORMS */ - 22, /* GL_ACTIVE_UNIFORM_MAX_LENGTH */ - 1766, /* GL_SHADER_SOURCE_LENGTH */ - 15, /* GL_ACTIVE_ATTRIBUTES */ - 16, /* GL_ACTIVE_ATTRIBUTE_MAX_LENGTH */ - 603, /* GL_FRAGMENT_SHADER_DERIVATIVE_HINT */ - 1769, /* GL_SHADING_LANGUAGE_VERSION */ - 375, /* GL_CURRENT_PROGRAM */ - 1315, /* GL_PALETTE4_RGB8_OES */ - 1317, /* GL_PALETTE4_RGBA8_OES */ - 1313, /* GL_PALETTE4_R5_G6_B5_OES */ - 1316, /* GL_PALETTE4_RGBA4_OES */ - 1314, /* GL_PALETTE4_RGB5_A1_OES */ - 1320, /* GL_PALETTE8_RGB8_OES */ - 1322, /* GL_PALETTE8_RGBA8_OES */ - 1318, /* GL_PALETTE8_R5_G6_B5_OES */ - 1321, /* GL_PALETTE8_RGBA4_OES */ - 1319, /* GL_PALETTE8_RGB5_A1_OES */ - 731, /* GL_IMPLEMENTATION_COLOR_READ_TYPE */ - 729, /* GL_IMPLEMENTATION_COLOR_READ_FORMAT */ - 1367, /* GL_POINT_SIZE_ARRAY_OES */ - 2036, /* GL_TEXTURE_CROP_RECT_OES */ - 1005, /* GL_MATRIX_INDEX_ARRAY_BUFFER_BINDING_OES */ - 1366, /* GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES */ - 2215, /* GL_UNSIGNED_NORMALIZED */ - 1969, /* GL_TEXTURE_1D_ARRAY */ - 1505, /* GL_PROXY_TEXTURE_1D_ARRAY */ - 1972, /* GL_TEXTURE_2D_ARRAY */ - 1509, /* GL_PROXY_TEXTURE_2D_ARRAY */ - 1980, /* GL_TEXTURE_BINDING_1D_ARRAY */ - 1983, /* GL_TEXTURE_BINDING_2D_ARRAY */ - 1057, /* GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS */ - 2000, /* GL_TEXTURE_BUFFER */ - 1111, /* GL_MAX_TEXTURE_BUFFER_SIZE */ - 1987, /* GL_TEXTURE_BINDING_BUFFER */ - 2002, /* GL_TEXTURE_BUFFER_DATA_STORE_BINDING */ - 2004, /* GL_TEXTURE_BUFFER_FORMAT */ - 1542, /* GL_R11F_G11F_B10F */ - 2181, /* GL_UNSIGNED_INT_10F_11F_11F_REV */ - 1654, /* GL_RGB9_E5 */ - 2190, /* GL_UNSIGNED_INT_5_9_9_9_REV */ - 2110, /* GL_TEXTURE_SHARED_SIZE */ - 1822, /* GL_SRGB */ - 1823, /* GL_SRGB8 */ - 1825, /* GL_SRGB_ALPHA */ - 1824, /* GL_SRGB8_ALPHA8 */ - 1782, /* GL_SLUMINANCE_ALPHA */ - 1781, /* GL_SLUMINANCE8_ALPHA8 */ - 1779, /* GL_SLUMINANCE */ - 1780, /* GL_SLUMINANCE8 */ - 312, /* GL_COMPRESSED_SRGB */ - 313, /* GL_COMPRESSED_SRGB_ALPHA */ - 310, /* GL_COMPRESSED_SLUMINANCE */ - 311, /* GL_COMPRESSED_SLUMINANCE_ALPHA */ - 2145, /* GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH */ - 2134, /* GL_TRANSFORM_FEEDBACK_BUFFER_MODE */ - 1130, /* GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS */ - 2143, /* GL_TRANSFORM_FEEDBACK_VARYINGS */ - 2139, /* GL_TRANSFORM_FEEDBACK_BUFFER_START */ - 2137, /* GL_TRANSFORM_FEEDBACK_BUFFER_SIZE */ - 1449, /* GL_PRIMITIVES_GENERATED */ - 2141, /* GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN */ - 1546, /* GL_RASTERIZER_DISCARD */ - 1126, /* GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS */ - 1128, /* GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS */ - 769, /* GL_INTERLEAVED_ATTRIBS */ - 1758, /* GL_SEPARATE_ATTRIBS */ - 2129, /* GL_TRANSFORM_FEEDBACK_BUFFER */ - 2131, /* GL_TRANSFORM_FEEDBACK_BUFFER_BINDING */ - 1385, /* GL_POINT_SPRITE_COORD_ORIGIN */ - 862, /* GL_LOWER_LEFT */ - 2229, /* GL_UPPER_LEFT */ - 1846, /* GL_STENCIL_BACK_REF */ - 1847, /* GL_STENCIL_BACK_VALUE_MASK */ - 1848, /* GL_STENCIL_BACK_WRITEMASK */ - 504, /* GL_DRAW_FRAMEBUFFER_BINDING */ - 1576, /* GL_RENDERBUFFER_BINDING */ - 1550, /* GL_READ_FRAMEBUFFER */ - 503, /* GL_DRAW_FRAMEBUFFER */ - 1551, /* GL_READ_FRAMEBUFFER_BINDING */ - 1595, /* GL_RENDERBUFFER_SAMPLES */ - 617, /* GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE */ - 614, /* GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME */ - 629, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL */ - 624, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE */ - 627, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER */ - 635, /* GL_FRAMEBUFFER_COMPLETE */ - 640, /* GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT */ - 655, /* GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT */ - 649, /* GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT */ - 644, /* GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT */ - 650, /* GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT */ - 646, /* GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER */ - 660, /* GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER */ - 666, /* GL_FRAMEBUFFER_UNSUPPORTED */ - 664, /* GL_FRAMEBUFFER_STATUS_ERROR_EXT */ - 1029, /* GL_MAX_COLOR_ATTACHMENTS */ - 196, /* GL_COLOR_ATTACHMENT0 */ - 199, /* GL_COLOR_ATTACHMENT1 */ - 213, /* GL_COLOR_ATTACHMENT2 */ - 215, /* GL_COLOR_ATTACHMENT3 */ - 217, /* GL_COLOR_ATTACHMENT4 */ - 219, /* GL_COLOR_ATTACHMENT5 */ - 221, /* GL_COLOR_ATTACHMENT6 */ - 223, /* GL_COLOR_ATTACHMENT7 */ - 225, /* GL_COLOR_ATTACHMENT8 */ - 227, /* GL_COLOR_ATTACHMENT9 */ - 200, /* GL_COLOR_ATTACHMENT10 */ - 202, /* GL_COLOR_ATTACHMENT11 */ - 204, /* GL_COLOR_ATTACHMENT12 */ - 206, /* GL_COLOR_ATTACHMENT13 */ - 208, /* GL_COLOR_ATTACHMENT14 */ - 210, /* GL_COLOR_ATTACHMENT15 */ - 403, /* GL_DEPTH_ATTACHMENT */ - 1835, /* GL_STENCIL_ATTACHMENT */ - 605, /* GL_FRAMEBUFFER */ - 1573, /* GL_RENDERBUFFER */ - 1599, /* GL_RENDERBUFFER_WIDTH */ - 1586, /* GL_RENDERBUFFER_HEIGHT */ - 1589, /* GL_RENDERBUFFER_INTERNAL_FORMAT */ - 1867, /* GL_STENCIL_INDEX_EXT */ - 1856, /* GL_STENCIL_INDEX1 */ - 1861, /* GL_STENCIL_INDEX4 */ - 1864, /* GL_STENCIL_INDEX8 */ - 1857, /* GL_STENCIL_INDEX16 */ - 1593, /* GL_RENDERBUFFER_RED_SIZE */ - 1584, /* GL_RENDERBUFFER_GREEN_SIZE */ - 1579, /* GL_RENDERBUFFER_BLUE_SIZE */ - 1574, /* GL_RENDERBUFFER_ALPHA_SIZE */ - 1581, /* GL_RENDERBUFFER_DEPTH_SIZE */ - 1597, /* GL_RENDERBUFFER_STENCIL_SIZE */ - 658, /* GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE */ - 1106, /* GL_MAX_SAMPLES */ - 2072, /* GL_TEXTURE_GEN_STR_OES */ - 705, /* GL_HALF_FLOAT_OES */ - 1640, /* GL_RGB565 */ - 1671, /* GL_RGBA32UI */ - 1634, /* GL_RGB32UI */ - 40, /* GL_ALPHA32UI_EXT */ - 761, /* GL_INTENSITY32UI_EXT */ - 879, /* GL_LUMINANCE32UI_EXT */ - 896, /* GL_LUMINANCE_ALPHA32UI_EXT */ - 1662, /* GL_RGBA16UI */ - 1626, /* GL_RGB16UI */ - 37, /* GL_ALPHA16UI_EXT */ - 758, /* GL_INTENSITY16UI_EXT */ - 874, /* GL_LUMINANCE16UI_EXT */ - 894, /* GL_LUMINANCE_ALPHA16UI_EXT */ - 1681, /* GL_RGBA8UI */ - 1649, /* GL_RGB8UI */ - 45, /* GL_ALPHA8UI_EXT */ - 766, /* GL_INTENSITY8UI_EXT */ - 888, /* GL_LUMINANCE8UI_EXT */ - 898, /* GL_LUMINANCE_ALPHA8UI_EXT */ - 1669, /* GL_RGBA32I */ - 1632, /* GL_RGB32I */ - 39, /* GL_ALPHA32I_EXT */ - 760, /* GL_INTENSITY32I_EXT */ - 878, /* GL_LUMINANCE32I_EXT */ - 895, /* GL_LUMINANCE_ALPHA32I_EXT */ - 1660, /* GL_RGBA16I */ - 1624, /* GL_RGB16I */ - 36, /* GL_ALPHA16I_EXT */ - 757, /* GL_INTENSITY16I_EXT */ - 873, /* GL_LUMINANCE16I_EXT */ - 893, /* GL_LUMINANCE_ALPHA16I_EXT */ - 1679, /* GL_RGBA8I */ - 1647, /* GL_RGB8I */ - 44, /* GL_ALPHA8I_EXT */ - 765, /* GL_INTENSITY8I_EXT */ - 887, /* GL_LUMINANCE8I_EXT */ - 897, /* GL_LUMINANCE_ALPHA8I_EXT */ - 1563, /* GL_RED_INTEGER */ - 700, /* GL_GREEN_INTEGER */ - 113, /* GL_BLUE_INTEGER */ - 49, /* GL_ALPHA_INTEGER_EXT */ - 1694, /* GL_RGB_INTEGER */ - 1688, /* GL_RGBA_INTEGER */ - 84, /* GL_BGR_INTEGER */ - 82, /* GL_BGRA_INTEGER */ - 900, /* GL_LUMINANCE_INTEGER_EXT */ - 899, /* GL_LUMINANCE_ALPHA_INTEGER_EXT */ - 1690, /* GL_RGBA_INTEGER_MODE_EXT */ - 775, /* GL_INT_2_10_10_10_REV */ - 612, /* GL_FRAMEBUFFER_ATTACHMENT_LAYERED */ - 653, /* GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS */ - 652, /* GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB */ - 1705, /* GL_SAMPLER_1D_ARRAY */ - 1711, /* GL_SAMPLER_2D_ARRAY */ - 1721, /* GL_SAMPLER_BUFFER */ - 1707, /* GL_SAMPLER_1D_ARRAY_SHADOW */ - 1713, /* GL_SAMPLER_2D_ARRAY_SHADOW */ - 1724, /* GL_SAMPLER_CUBE_SHADOW */ - 2209, /* GL_UNSIGNED_INT_VEC2 */ - 2211, /* GL_UNSIGNED_INT_VEC3 */ - 2213, /* GL_UNSIGNED_INT_VEC4 */ - 776, /* GL_INT_SAMPLER_1D */ - 780, /* GL_INT_SAMPLER_2D */ - 786, /* GL_INT_SAMPLER_3D */ - 790, /* GL_INT_SAMPLER_CUBE */ - 784, /* GL_INT_SAMPLER_2D_RECT */ - 777, /* GL_INT_SAMPLER_1D_ARRAY */ - 781, /* GL_INT_SAMPLER_2D_ARRAY */ - 788, /* GL_INT_SAMPLER_BUFFER */ - 2193, /* GL_UNSIGNED_INT_SAMPLER_1D */ - 2197, /* GL_UNSIGNED_INT_SAMPLER_2D */ - 2203, /* GL_UNSIGNED_INT_SAMPLER_3D */ - 2207, /* GL_UNSIGNED_INT_SAMPLER_CUBE */ - 2201, /* GL_UNSIGNED_INT_SAMPLER_2D_RECT */ - 2194, /* GL_UNSIGNED_INT_SAMPLER_1D_ARRAY */ - 2198, /* GL_UNSIGNED_INT_SAMPLER_2D_ARRAY */ - 2205, /* GL_UNSIGNED_INT_SAMPLER_BUFFER */ - 691, /* GL_GEOMETRY_SHADER */ - 694, /* GL_GEOMETRY_VERTICES_OUT_ARB */ - 688, /* GL_GEOMETRY_INPUT_TYPE_ARB */ - 690, /* GL_GEOMETRY_OUTPUT_TYPE_ARB */ - 1063, /* GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB */ - 1146, /* GL_MAX_VERTEX_VARYING_COMPONENTS_ARB */ - 1061, /* GL_MAX_GEOMETRY_UNIFORM_COMPONENTS */ - 1055, /* GL_MAX_GEOMETRY_OUTPUT_VERTICES */ - 1059, /* GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS */ - 863, /* GL_LOW_FLOAT */ - 1148, /* GL_MEDIUM_FLOAT */ - 706, /* GL_HIGH_FLOAT */ - 864, /* GL_LOW_INT */ - 1149, /* GL_MEDIUM_INT */ - 707, /* GL_HIGH_INT */ - 2183, /* GL_UNSIGNED_INT_10_10_10_2_OES */ - 774, /* GL_INT_10_10_10_2_OES */ - 1763, /* GL_SHADER_BINARY_FORMATS */ - 1251, /* GL_NUM_SHADER_BINARY_FORMATS */ - 1764, /* GL_SHADER_COMPILER */ - 1143, /* GL_MAX_VERTEX_UNIFORM_VECTORS */ - 1135, /* GL_MAX_VARYING_VECTORS */ - 1052, /* GL_MAX_FRAGMENT_UNIFORM_VECTORS */ - 1539, /* GL_QUERY_WAIT */ - 1533, /* GL_QUERY_NO_WAIT */ - 1529, /* GL_QUERY_BY_REGION_WAIT */ - 1527, /* GL_QUERY_BY_REGION_NO_WAIT */ - 2127, /* GL_TRANSFORM_FEEDBACK */ - 2136, /* GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED */ - 2130, /* GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE */ - 2128, /* GL_TRANSFORM_FEEDBACK_BINDING */ - 1523, /* GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION */ - 546, /* GL_FIRST_VERTEX_CONVENTION */ - 808, /* GL_LAST_VERTEX_CONVENTION */ - 1497, /* GL_PROVOKING_VERTEX */ - 354, /* GL_COPY_READ_BUFFER */ - 355, /* GL_COPY_WRITE_BUFFER */ - 1566, /* GL_RED_SNORM */ - 1701, /* GL_RG_SNORM */ - 1700, /* GL_RGB_SNORM */ - 1693, /* GL_RGBA_SNORM */ - 1545, /* GL_R8_SNORM */ - 1614, /* GL_RG8_SNORM */ - 1653, /* GL_RGB8_SNORM */ - 1685, /* GL_RGBA8_SNORM */ - 1543, /* GL_R16_SNORM */ - 1613, /* GL_RG16_SNORM */ - 1629, /* GL_RGB16_SNORM */ - 1665, /* GL_RGBA16_SNORM */ - 1775, /* GL_SIGNED_NORMALIZED */ - 1451, /* GL_PRIMITIVE_RESTART */ - 1452, /* GL_PRIMITIVE_RESTART_INDEX */ - 1108, /* GL_MAX_SERVER_WAIT_TIMEOUT */ - 1265, /* GL_OBJECT_TYPE */ - 1888, /* GL_SYNC_CONDITION */ - 1893, /* GL_SYNC_STATUS */ - 1890, /* GL_SYNC_FLAGS */ - 1889, /* GL_SYNC_FENCE */ - 1892, /* GL_SYNC_GPU_COMMANDS_COMPLETE */ - 2176, /* GL_UNSIGNALED */ - 1774, /* GL_SIGNALED */ - 54, /* GL_ALREADY_SIGNALED */ - 2122, /* GL_TIMEOUT_EXPIRED */ - 315, /* GL_CONDITION_SATISFIED */ - 2293, /* GL_WAIT_FAILED */ - 126, /* GL_BUFFER_ACCESS_FLAGS */ - 132, /* GL_BUFFER_MAP_LENGTH */ - 133, /* GL_BUFFER_MAP_OFFSET */ - 1138, /* GL_MAX_VERTEX_OUTPUT_COMPONENTS */ - 1053, /* GL_MAX_GEOMETRY_INPUT_COMPONENTS */ - 1054, /* GL_MAX_GEOMETRY_OUTPUT_COMPONENTS */ - 1049, /* GL_MAX_FRAGMENT_INPUT_COMPONENTS */ - 330, /* GL_CONTEXT_PROFILE_MASK */ - 531, /* GL_EVAL_BIT */ - 1548, /* GL_RASTER_POSITION_UNCLIPPED_IBM */ - 855, /* GL_LIST_BIT */ - 1995, /* GL_TEXTURE_BIT */ - 1744, /* GL_SCISSOR_BIT */ - 30, /* GL_ALL_ATTRIB_BITS */ - 1214, /* GL_MULTISAMPLE_BIT */ - 31, /* GL_ALL_CLIENT_ATTRIB_BITS */ -}; - -typedef int (*cfunc)(const void *, const void *); - -/** - * Compare a key name to an element in the \c all_enums array. - * - * \c bsearch always passes the key as the first parameter and the pointer - * to the array element as the second parameter. We can elimiate some - * extra work by taking advantage of that fact. - * - * \param a Pointer to the desired enum name. - * \param b Pointer to an element of the \c all_enums array. - */ -static int compar_name( const char *a, const enum_elt *b ) -{ - return strcmp( a, & enum_string_table[ b->offset ] ); -} - -/** - * Compare a key enum value to an element in the \c all_enums array. - * - * \c bsearch always passes the key as the first parameter and the pointer - * to the array element as the second parameter. We can elimiate some - * extra work by taking advantage of that fact. - * - * \param a Pointer to the desired enum name. - * \param b Pointer to an index into the \c all_enums array. - */ -static int compar_nr( const int *a, const unsigned *b ) -{ - return a[0] - all_enums[*b].n; -} - - -static char token_tmp[20]; - -const char *_mesa_lookup_enum_by_nr( int nr ) -{ - unsigned * i; - - i = (unsigned *) _mesa_bsearch(& nr, reduced_enums, - Elements(reduced_enums), - sizeof(reduced_enums[0]), - (cfunc) compar_nr); - - if ( i != NULL ) { - return & enum_string_table[ all_enums[ *i ].offset ]; - } - else { - /* this is not re-entrant safe, no big deal here */ - _mesa_snprintf(token_tmp, sizeof(token_tmp) - 1, "0x%x", nr); - token_tmp[sizeof(token_tmp) - 1] = '\0'; - return token_tmp; - } -} - -/** - * Primitive names - */ -static const char *prim_names[PRIM_UNKNOWN + 1] = { - "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" -}; - - -/* Get the name of an enum given that it is a primitive type. Avoids - * GL_FALSE/GL_POINTS ambiguity and others. - */ -const char * -_mesa_lookup_prim_by_nr(GLuint nr) -{ - if (nr < Elements(prim_names)) - return prim_names[nr]; - else - return "invalid mode"; -} - - -int _mesa_lookup_enum_by_name( const char *symbol ) -{ - enum_elt * f = NULL; - - if ( symbol != NULL ) { - f = (enum_elt *) _mesa_bsearch(symbol, all_enums, - Elements(all_enums), - sizeof( enum_elt ), - (cfunc) compar_name); - } - - return (f != NULL) ? f->n : -1; -} - - +/* DO NOT EDIT - This file generated automatically by gl_enums.py (from Mesa) script */ + +/* + * Copyright (C) 1999-2005 Brian Paul All Rights Reserved. + * 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, sub license, + * 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 (including the next + * paragraph) 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 NON-INFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL, + * AND/OR THEIR SUPPLIERS 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 "main/glheader.h" +#include "main/mfeatures.h" +#include "main/enums.h" +#include "main/imports.h" +#include "main/mtypes.h" + +typedef struct { + size_t offset; + int n; +} enum_elt; + +LONGSTRING static const char enum_string_table[] = + "GL_2D\0" + "GL_2_BYTES\0" + "GL_3D\0" + "GL_3D_COLOR\0" + "GL_3D_COLOR_TEXTURE\0" + "GL_3_BYTES\0" + "GL_4D_COLOR_TEXTURE\0" + "GL_4_BYTES\0" + "GL_ACCUM\0" + "GL_ACCUM_ALPHA_BITS\0" + "GL_ACCUM_BLUE_BITS\0" + "GL_ACCUM_BUFFER_BIT\0" + "GL_ACCUM_CLEAR_VALUE\0" + "GL_ACCUM_GREEN_BITS\0" + "GL_ACCUM_RED_BITS\0" + "GL_ACTIVE_ATTRIBUTES\0" + "GL_ACTIVE_ATTRIBUTE_MAX_LENGTH\0" + "GL_ACTIVE_PROGRAM_EXT\0" + "GL_ACTIVE_STENCIL_FACE_EXT\0" + "GL_ACTIVE_TEXTURE\0" + "GL_ACTIVE_TEXTURE_ARB\0" + "GL_ACTIVE_UNIFORMS\0" + "GL_ACTIVE_UNIFORM_MAX_LENGTH\0" + "GL_ACTIVE_VERTEX_UNITS_ARB\0" + "GL_ADD\0" + "GL_ADD_SIGNED\0" + "GL_ADD_SIGNED_ARB\0" + "GL_ADD_SIGNED_EXT\0" + "GL_ALIASED_LINE_WIDTH_RANGE\0" + "GL_ALIASED_POINT_SIZE_RANGE\0" + "GL_ALL_ATTRIB_BITS\0" + "GL_ALL_CLIENT_ATTRIB_BITS\0" + "GL_ALPHA\0" + "GL_ALPHA12\0" + "GL_ALPHA12_EXT\0" + "GL_ALPHA16\0" + "GL_ALPHA16I_EXT\0" + "GL_ALPHA16UI_EXT\0" + "GL_ALPHA16_EXT\0" + "GL_ALPHA32I_EXT\0" + "GL_ALPHA32UI_EXT\0" + "GL_ALPHA4\0" + "GL_ALPHA4_EXT\0" + "GL_ALPHA8\0" + "GL_ALPHA8I_EXT\0" + "GL_ALPHA8UI_EXT\0" + "GL_ALPHA8_EXT\0" + "GL_ALPHA_BIAS\0" + "GL_ALPHA_BITS\0" + "GL_ALPHA_INTEGER_EXT\0" + "GL_ALPHA_SCALE\0" + "GL_ALPHA_TEST\0" + "GL_ALPHA_TEST_FUNC\0" + "GL_ALPHA_TEST_REF\0" + "GL_ALREADY_SIGNALED\0" + "GL_ALWAYS\0" + "GL_AMBIENT\0" + "GL_AMBIENT_AND_DIFFUSE\0" + "GL_AND\0" + "GL_AND_INVERTED\0" + "GL_AND_REVERSE\0" + "GL_ARRAY_BUFFER\0" + "GL_ARRAY_BUFFER_BINDING\0" + "GL_ARRAY_BUFFER_BINDING_ARB\0" + "GL_ATTACHED_SHADERS\0" + "GL_ATTRIB_ARRAY_POINTER_NV\0" + "GL_ATTRIB_ARRAY_SIZE_NV\0" + "GL_ATTRIB_ARRAY_STRIDE_NV\0" + "GL_ATTRIB_ARRAY_TYPE_NV\0" + "GL_ATTRIB_STACK_DEPTH\0" + "GL_AUTO_NORMAL\0" + "GL_AUX0\0" + "GL_AUX1\0" + "GL_AUX2\0" + "GL_AUX3\0" + "GL_AUX_BUFFERS\0" + "GL_BACK\0" + "GL_BACK_LEFT\0" + "GL_BACK_RIGHT\0" + "GL_BGR\0" + "GL_BGRA\0" + "GL_BGRA_EXT\0" + "GL_BGRA_INTEGER\0" + "GL_BGRA_INTEGER_EXT\0" + "GL_BGR_INTEGER\0" + "GL_BGR_INTEGER_EXT\0" + "GL_BITMAP\0" + "GL_BITMAP_TOKEN\0" + "GL_BLEND\0" + "GL_BLEND_COLOR\0" + "GL_BLEND_COLOR_EXT\0" + "GL_BLEND_DST\0" + "GL_BLEND_DST_ALPHA\0" + "GL_BLEND_DST_ALPHA_OES\0" + "GL_BLEND_DST_RGB\0" + "GL_BLEND_DST_RGB_OES\0" + "GL_BLEND_EQUATION\0" + "GL_BLEND_EQUATION_ALPHA\0" + "GL_BLEND_EQUATION_ALPHA_EXT\0" + "GL_BLEND_EQUATION_ALPHA_OES\0" + "GL_BLEND_EQUATION_EXT\0" + "GL_BLEND_EQUATION_OES\0" + "GL_BLEND_EQUATION_RGB\0" + "GL_BLEND_EQUATION_RGB_EXT\0" + "GL_BLEND_EQUATION_RGB_OES\0" + "GL_BLEND_SRC\0" + "GL_BLEND_SRC_ALPHA\0" + "GL_BLEND_SRC_ALPHA_OES\0" + "GL_BLEND_SRC_RGB\0" + "GL_BLEND_SRC_RGB_OES\0" + "GL_BLUE\0" + "GL_BLUE_BIAS\0" + "GL_BLUE_BITS\0" + "GL_BLUE_INTEGER\0" + "GL_BLUE_INTEGER_EXT\0" + "GL_BLUE_SCALE\0" + "GL_BOOL\0" + "GL_BOOL_ARB\0" + "GL_BOOL_VEC2\0" + "GL_BOOL_VEC2_ARB\0" + "GL_BOOL_VEC3\0" + "GL_BOOL_VEC3_ARB\0" + "GL_BOOL_VEC4\0" + "GL_BOOL_VEC4_ARB\0" + "GL_BUFFER_ACCESS\0" + "GL_BUFFER_ACCESS_ARB\0" + "GL_BUFFER_ACCESS_FLAGS\0" + "GL_BUFFER_ACCESS_OES\0" + "GL_BUFFER_FLUSHING_UNMAP_APPLE\0" + "GL_BUFFER_MAPPED\0" + "GL_BUFFER_MAPPED_ARB\0" + "GL_BUFFER_MAPPED_OES\0" + "GL_BUFFER_MAP_LENGTH\0" + "GL_BUFFER_MAP_OFFSET\0" + "GL_BUFFER_MAP_POINTER\0" + "GL_BUFFER_MAP_POINTER_ARB\0" + "GL_BUFFER_MAP_POINTER_OES\0" + "GL_BUFFER_OBJECT_APPLE\0" + "GL_BUFFER_SERIALIZED_MODIFY_APPLE\0" + "GL_BUFFER_SIZE\0" + "GL_BUFFER_SIZE_ARB\0" + "GL_BUFFER_USAGE\0" + "GL_BUFFER_USAGE_ARB\0" + "GL_BUMP_ENVMAP_ATI\0" + "GL_BUMP_NUM_TEX_UNITS_ATI\0" + "GL_BUMP_ROT_MATRIX_ATI\0" + "GL_BUMP_ROT_MATRIX_SIZE_ATI\0" + "GL_BUMP_TARGET_ATI\0" + "GL_BUMP_TEX_UNITS_ATI\0" + "GL_BYTE\0" + "GL_C3F_V3F\0" + "GL_C4F_N3F_V3F\0" + "GL_C4UB_V2F\0" + "GL_C4UB_V3F\0" + "GL_CCW\0" + "GL_CLAMP\0" + "GL_CLAMP_FRAGMENT_COLOR_ARB\0" + "GL_CLAMP_READ_COLOR\0" + "GL_CLAMP_READ_COLOR_ARB\0" + "GL_CLAMP_TO_BORDER\0" + "GL_CLAMP_TO_BORDER_ARB\0" + "GL_CLAMP_TO_BORDER_SGIS\0" + "GL_CLAMP_TO_EDGE\0" + "GL_CLAMP_TO_EDGE_SGIS\0" + "GL_CLAMP_VERTEX_COLOR_ARB\0" + "GL_CLEAR\0" + "GL_CLIENT_ACTIVE_TEXTURE\0" + "GL_CLIENT_ACTIVE_TEXTURE_ARB\0" + "GL_CLIENT_ALL_ATTRIB_BITS\0" + "GL_CLIENT_ATTRIB_STACK_DEPTH\0" + "GL_CLIENT_PIXEL_STORE_BIT\0" + "GL_CLIENT_VERTEX_ARRAY_BIT\0" + "GL_CLIP_DISTANCE0\0" + "GL_CLIP_DISTANCE1\0" + "GL_CLIP_DISTANCE2\0" + "GL_CLIP_DISTANCE3\0" + "GL_CLIP_DISTANCE4\0" + "GL_CLIP_DISTANCE5\0" + "GL_CLIP_DISTANCE6\0" + "GL_CLIP_DISTANCE7\0" + "GL_CLIP_PLANE0\0" + "GL_CLIP_PLANE1\0" + "GL_CLIP_PLANE2\0" + "GL_CLIP_PLANE3\0" + "GL_CLIP_PLANE4\0" + "GL_CLIP_PLANE5\0" + "GL_CLIP_VOLUME_CLIPPING_HINT_EXT\0" + "GL_COEFF\0" + "GL_COLOR\0" + "GL_COLOR_ARRAY\0" + "GL_COLOR_ARRAY_BUFFER_BINDING\0" + "GL_COLOR_ARRAY_BUFFER_BINDING_ARB\0" + "GL_COLOR_ARRAY_POINTER\0" + "GL_COLOR_ARRAY_SIZE\0" + "GL_COLOR_ARRAY_STRIDE\0" + "GL_COLOR_ARRAY_TYPE\0" + "GL_COLOR_ATTACHMENT0\0" + "GL_COLOR_ATTACHMENT0_EXT\0" + "GL_COLOR_ATTACHMENT0_OES\0" + "GL_COLOR_ATTACHMENT1\0" + "GL_COLOR_ATTACHMENT10\0" + "GL_COLOR_ATTACHMENT10_EXT\0" + "GL_COLOR_ATTACHMENT11\0" + "GL_COLOR_ATTACHMENT11_EXT\0" + "GL_COLOR_ATTACHMENT12\0" + "GL_COLOR_ATTACHMENT12_EXT\0" + "GL_COLOR_ATTACHMENT13\0" + "GL_COLOR_ATTACHMENT13_EXT\0" + "GL_COLOR_ATTACHMENT14\0" + "GL_COLOR_ATTACHMENT14_EXT\0" + "GL_COLOR_ATTACHMENT15\0" + "GL_COLOR_ATTACHMENT15_EXT\0" + "GL_COLOR_ATTACHMENT1_EXT\0" + "GL_COLOR_ATTACHMENT2\0" + "GL_COLOR_ATTACHMENT2_EXT\0" + "GL_COLOR_ATTACHMENT3\0" + "GL_COLOR_ATTACHMENT3_EXT\0" + "GL_COLOR_ATTACHMENT4\0" + "GL_COLOR_ATTACHMENT4_EXT\0" + "GL_COLOR_ATTACHMENT5\0" + "GL_COLOR_ATTACHMENT5_EXT\0" + "GL_COLOR_ATTACHMENT6\0" + "GL_COLOR_ATTACHMENT6_EXT\0" + "GL_COLOR_ATTACHMENT7\0" + "GL_COLOR_ATTACHMENT7_EXT\0" + "GL_COLOR_ATTACHMENT8\0" + "GL_COLOR_ATTACHMENT8_EXT\0" + "GL_COLOR_ATTACHMENT9\0" + "GL_COLOR_ATTACHMENT9_EXT\0" + "GL_COLOR_BUFFER_BIT\0" + "GL_COLOR_CLEAR_VALUE\0" + "GL_COLOR_INDEX\0" + "GL_COLOR_INDEXES\0" + "GL_COLOR_LOGIC_OP\0" + "GL_COLOR_MATERIAL\0" + "GL_COLOR_MATERIAL_FACE\0" + "GL_COLOR_MATERIAL_PARAMETER\0" + "GL_COLOR_MATRIX\0" + "GL_COLOR_MATRIX_SGI\0" + "GL_COLOR_MATRIX_STACK_DEPTH\0" + "GL_COLOR_MATRIX_STACK_DEPTH_SGI\0" + "GL_COLOR_SUM\0" + "GL_COLOR_SUM_ARB\0" + "GL_COLOR_TABLE\0" + "GL_COLOR_TABLE_ALPHA_SIZE\0" + "GL_COLOR_TABLE_ALPHA_SIZE_EXT\0" + "GL_COLOR_TABLE_ALPHA_SIZE_SGI\0" + "GL_COLOR_TABLE_BIAS\0" + "GL_COLOR_TABLE_BIAS_SGI\0" + "GL_COLOR_TABLE_BLUE_SIZE\0" + "GL_COLOR_TABLE_BLUE_SIZE_EXT\0" + "GL_COLOR_TABLE_BLUE_SIZE_SGI\0" + "GL_COLOR_TABLE_FORMAT\0" + "GL_COLOR_TABLE_FORMAT_EXT\0" + "GL_COLOR_TABLE_FORMAT_SGI\0" + "GL_COLOR_TABLE_GREEN_SIZE\0" + "GL_COLOR_TABLE_GREEN_SIZE_EXT\0" + "GL_COLOR_TABLE_GREEN_SIZE_SGI\0" + "GL_COLOR_TABLE_INTENSITY_SIZE\0" + "GL_COLOR_TABLE_INTENSITY_SIZE_EXT\0" + "GL_COLOR_TABLE_INTENSITY_SIZE_SGI\0" + "GL_COLOR_TABLE_LUMINANCE_SIZE\0" + "GL_COLOR_TABLE_LUMINANCE_SIZE_EXT\0" + "GL_COLOR_TABLE_LUMINANCE_SIZE_SGI\0" + "GL_COLOR_TABLE_RED_SIZE\0" + "GL_COLOR_TABLE_RED_SIZE_EXT\0" + "GL_COLOR_TABLE_RED_SIZE_SGI\0" + "GL_COLOR_TABLE_SCALE\0" + "GL_COLOR_TABLE_SCALE_SGI\0" + "GL_COLOR_TABLE_WIDTH\0" + "GL_COLOR_TABLE_WIDTH_EXT\0" + "GL_COLOR_TABLE_WIDTH_SGI\0" + "GL_COLOR_WRITEMASK\0" + "GL_COMBINE\0" + "GL_COMBINE4\0" + "GL_COMBINE_ALPHA\0" + "GL_COMBINE_ALPHA_ARB\0" + "GL_COMBINE_ALPHA_EXT\0" + "GL_COMBINE_ARB\0" + "GL_COMBINE_EXT\0" + "GL_COMBINE_RGB\0" + "GL_COMBINE_RGB_ARB\0" + "GL_COMBINE_RGB_EXT\0" + "GL_COMPARE_REF_DEPTH_TO_TEXTURE_EXT\0" + "GL_COMPARE_REF_TO_TEXTURE\0" + "GL_COMPARE_R_TO_TEXTURE\0" + "GL_COMPARE_R_TO_TEXTURE_ARB\0" + "GL_COMPILE\0" + "GL_COMPILE_AND_EXECUTE\0" + "GL_COMPILE_STATUS\0" + "GL_COMPRESSED_ALPHA\0" + "GL_COMPRESSED_ALPHA_ARB\0" + "GL_COMPRESSED_INTENSITY\0" + "GL_COMPRESSED_INTENSITY_ARB\0" + "GL_COMPRESSED_LUMINANCE\0" + "GL_COMPRESSED_LUMINANCE_ALPHA\0" + "GL_COMPRESSED_LUMINANCE_ALPHA_ARB\0" + "GL_COMPRESSED_LUMINANCE_ARB\0" + "GL_COMPRESSED_RED\0" + "GL_COMPRESSED_RG\0" + "GL_COMPRESSED_RGB\0" + "GL_COMPRESSED_RGBA\0" + "GL_COMPRESSED_RGBA_ARB\0" + "GL_COMPRESSED_RGBA_FXT1_3DFX\0" + "GL_COMPRESSED_RGBA_S3TC_DXT1_EXT\0" + "GL_COMPRESSED_RGBA_S3TC_DXT3_EXT\0" + "GL_COMPRESSED_RGBA_S3TC_DXT5_EXT\0" + "GL_COMPRESSED_RGB_ARB\0" + "GL_COMPRESSED_RGB_FXT1_3DFX\0" + "GL_COMPRESSED_RGB_S3TC_DXT1_EXT\0" + "GL_COMPRESSED_SLUMINANCE\0" + "GL_COMPRESSED_SLUMINANCE_ALPHA\0" + "GL_COMPRESSED_SRGB\0" + "GL_COMPRESSED_SRGB_ALPHA\0" + "GL_COMPRESSED_TEXTURE_FORMATS\0" + "GL_CONDITION_SATISFIED\0" + "GL_CONSTANT\0" + "GL_CONSTANT_ALPHA\0" + "GL_CONSTANT_ALPHA_EXT\0" + "GL_CONSTANT_ARB\0" + "GL_CONSTANT_ATTENUATION\0" + "GL_CONSTANT_BORDER_HP\0" + "GL_CONSTANT_COLOR\0" + "GL_CONSTANT_COLOR_EXT\0" + "GL_CONSTANT_EXT\0" + "GL_CONTEXT_COMPATIBILITY_PROFILE_BIT\0" + "GL_CONTEXT_CORE_PROFILE_BIT\0" + "GL_CONTEXT_FLAGS\0" + "GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT\0" + "GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB\0" + "GL_CONTEXT_PROFILE_MASK\0" + "GL_CONVOLUTION_1D\0" + "GL_CONVOLUTION_2D\0" + "GL_CONVOLUTION_BORDER_COLOR\0" + "GL_CONVOLUTION_BORDER_COLOR_HP\0" + "GL_CONVOLUTION_BORDER_MODE\0" + "GL_CONVOLUTION_BORDER_MODE_EXT\0" + "GL_CONVOLUTION_FILTER_BIAS\0" + "GL_CONVOLUTION_FILTER_BIAS_EXT\0" + "GL_CONVOLUTION_FILTER_SCALE\0" + "GL_CONVOLUTION_FILTER_SCALE_EXT\0" + "GL_CONVOLUTION_FORMAT\0" + "GL_CONVOLUTION_FORMAT_EXT\0" + "GL_CONVOLUTION_HEIGHT\0" + "GL_CONVOLUTION_HEIGHT_EXT\0" + "GL_CONVOLUTION_WIDTH\0" + "GL_CONVOLUTION_WIDTH_EXT\0" + "GL_COORD_REPLACE\0" + "GL_COORD_REPLACE_ARB\0" + "GL_COORD_REPLACE_NV\0" + "GL_COORD_REPLACE_OES\0" + "GL_COPY\0" + "GL_COPY_INVERTED\0" + "GL_COPY_PIXEL_TOKEN\0" + "GL_COPY_READ_BUFFER\0" + "GL_COPY_WRITE_BUFFER\0" + "GL_CULL_FACE\0" + "GL_CULL_FACE_MODE\0" + "GL_CULL_VERTEX_EXT\0" + "GL_CULL_VERTEX_EYE_POSITION_EXT\0" + "GL_CULL_VERTEX_OBJECT_POSITION_EXT\0" + "GL_CURRENT_ATTRIB_NV\0" + "GL_CURRENT_BIT\0" + "GL_CURRENT_COLOR\0" + "GL_CURRENT_FOG_COORD\0" + "GL_CURRENT_FOG_COORDINATE\0" + "GL_CURRENT_INDEX\0" + "GL_CURRENT_MATRIX_ARB\0" + "GL_CURRENT_MATRIX_INDEX_ARB\0" + "GL_CURRENT_MATRIX_NV\0" + "GL_CURRENT_MATRIX_STACK_DEPTH_ARB\0" + "GL_CURRENT_MATRIX_STACK_DEPTH_NV\0" + "GL_CURRENT_NORMAL\0" + "GL_CURRENT_PALETTE_MATRIX_ARB\0" + "GL_CURRENT_PALETTE_MATRIX_OES\0" + "GL_CURRENT_PROGRAM\0" + "GL_CURRENT_QUERY\0" + "GL_CURRENT_QUERY_ARB\0" + "GL_CURRENT_RASTER_COLOR\0" + "GL_CURRENT_RASTER_DISTANCE\0" + "GL_CURRENT_RASTER_INDEX\0" + "GL_CURRENT_RASTER_POSITION\0" + "GL_CURRENT_RASTER_POSITION_VALID\0" + "GL_CURRENT_RASTER_SECONDARY_COLOR\0" + "GL_CURRENT_RASTER_TEXTURE_COORDS\0" + "GL_CURRENT_SECONDARY_COLOR\0" + "GL_CURRENT_TEXTURE_COORDS\0" + "GL_CURRENT_VERTEX_ATTRIB\0" + "GL_CURRENT_VERTEX_ATTRIB_ARB\0" + "GL_CURRENT_WEIGHT_ARB\0" + "GL_CW\0" + "GL_DEBUG_ASSERT_MESA\0" + "GL_DEBUG_OBJECT_MESA\0" + "GL_DEBUG_PRINT_MESA\0" + "GL_DECAL\0" + "GL_DECR\0" + "GL_DECR_WRAP\0" + "GL_DECR_WRAP_EXT\0" + "GL_DELETE_STATUS\0" + "GL_DEPTH\0" + "GL_DEPTH24_STENCIL8\0" + "GL_DEPTH24_STENCIL8_EXT\0" + "GL_DEPTH24_STENCIL8_OES\0" + "GL_DEPTH_ATTACHMENT\0" + "GL_DEPTH_ATTACHMENT_EXT\0" + "GL_DEPTH_ATTACHMENT_OES\0" + "GL_DEPTH_BIAS\0" + "GL_DEPTH_BITS\0" + "GL_DEPTH_BOUNDS_EXT\0" + "GL_DEPTH_BOUNDS_TEST_EXT\0" + "GL_DEPTH_BUFFER\0" + "GL_DEPTH_BUFFER_BIT\0" + "GL_DEPTH_CLAMP\0" + "GL_DEPTH_CLAMP_NV\0" + "GL_DEPTH_CLEAR_VALUE\0" + "GL_DEPTH_COMPONENT\0" + "GL_DEPTH_COMPONENT16\0" + "GL_DEPTH_COMPONENT16_ARB\0" + "GL_DEPTH_COMPONENT16_OES\0" + "GL_DEPTH_COMPONENT16_SGIX\0" + "GL_DEPTH_COMPONENT24\0" + "GL_DEPTH_COMPONENT24_ARB\0" + "GL_DEPTH_COMPONENT24_OES\0" + "GL_DEPTH_COMPONENT24_SGIX\0" + "GL_DEPTH_COMPONENT32\0" + "GL_DEPTH_COMPONENT32_ARB\0" + "GL_DEPTH_COMPONENT32_OES\0" + "GL_DEPTH_COMPONENT32_SGIX\0" + "GL_DEPTH_FUNC\0" + "GL_DEPTH_RANGE\0" + "GL_DEPTH_SCALE\0" + "GL_DEPTH_STENCIL\0" + "GL_DEPTH_STENCIL_ATTACHMENT\0" + "GL_DEPTH_STENCIL_EXT\0" + "GL_DEPTH_STENCIL_NV\0" + "GL_DEPTH_STENCIL_OES\0" + "GL_DEPTH_STENCIL_TO_BGRA_NV\0" + "GL_DEPTH_STENCIL_TO_RGBA_NV\0" + "GL_DEPTH_TEST\0" + "GL_DEPTH_TEXTURE_MODE\0" + "GL_DEPTH_TEXTURE_MODE_ARB\0" + "GL_DEPTH_WRITEMASK\0" + "GL_DIFFUSE\0" + "GL_DITHER\0" + "GL_DOMAIN\0" + "GL_DONT_CARE\0" + "GL_DOT3_RGB\0" + "GL_DOT3_RGBA\0" + "GL_DOT3_RGBA_ARB\0" + "GL_DOT3_RGBA_EXT\0" + "GL_DOT3_RGB_ARB\0" + "GL_DOT3_RGB_EXT\0" + "GL_DOUBLE\0" + "GL_DOUBLEBUFFER\0" + "GL_DRAW_BUFFER\0" + "GL_DRAW_BUFFER0\0" + "GL_DRAW_BUFFER0_ARB\0" + "GL_DRAW_BUFFER0_ATI\0" + "GL_DRAW_BUFFER1\0" + "GL_DRAW_BUFFER10\0" + "GL_DRAW_BUFFER10_ARB\0" + "GL_DRAW_BUFFER10_ATI\0" + "GL_DRAW_BUFFER11\0" + "GL_DRAW_BUFFER11_ARB\0" + "GL_DRAW_BUFFER11_ATI\0" + "GL_DRAW_BUFFER12\0" + "GL_DRAW_BUFFER12_ARB\0" + "GL_DRAW_BUFFER12_ATI\0" + "GL_DRAW_BUFFER13\0" + "GL_DRAW_BUFFER13_ARB\0" + "GL_DRAW_BUFFER13_ATI\0" + "GL_DRAW_BUFFER14\0" + "GL_DRAW_BUFFER14_ARB\0" + "GL_DRAW_BUFFER14_ATI\0" + "GL_DRAW_BUFFER15\0" + "GL_DRAW_BUFFER15_ARB\0" + "GL_DRAW_BUFFER15_ATI\0" + "GL_DRAW_BUFFER1_ARB\0" + "GL_DRAW_BUFFER1_ATI\0" + "GL_DRAW_BUFFER2\0" + "GL_DRAW_BUFFER2_ARB\0" + "GL_DRAW_BUFFER2_ATI\0" + "GL_DRAW_BUFFER3\0" + "GL_DRAW_BUFFER3_ARB\0" + "GL_DRAW_BUFFER3_ATI\0" + "GL_DRAW_BUFFER4\0" + "GL_DRAW_BUFFER4_ARB\0" + "GL_DRAW_BUFFER4_ATI\0" + "GL_DRAW_BUFFER5\0" + "GL_DRAW_BUFFER5_ARB\0" + "GL_DRAW_BUFFER5_ATI\0" + "GL_DRAW_BUFFER6\0" + "GL_DRAW_BUFFER6_ARB\0" + "GL_DRAW_BUFFER6_ATI\0" + "GL_DRAW_BUFFER7\0" + "GL_DRAW_BUFFER7_ARB\0" + "GL_DRAW_BUFFER7_ATI\0" + "GL_DRAW_BUFFER8\0" + "GL_DRAW_BUFFER8_ARB\0" + "GL_DRAW_BUFFER8_ATI\0" + "GL_DRAW_BUFFER9\0" + "GL_DRAW_BUFFER9_ARB\0" + "GL_DRAW_BUFFER9_ATI\0" + "GL_DRAW_FRAMEBUFFER\0" + "GL_DRAW_FRAMEBUFFER_BINDING\0" + "GL_DRAW_FRAMEBUFFER_BINDING_EXT\0" + "GL_DRAW_FRAMEBUFFER_EXT\0" + "GL_DRAW_PIXEL_TOKEN\0" + "GL_DST_ALPHA\0" + "GL_DST_COLOR\0" + "GL_DU8DV8_ATI\0" + "GL_DUDV_ATI\0" + "GL_DYNAMIC_COPY\0" + "GL_DYNAMIC_COPY_ARB\0" + "GL_DYNAMIC_DRAW\0" + "GL_DYNAMIC_DRAW_ARB\0" + "GL_DYNAMIC_READ\0" + "GL_DYNAMIC_READ_ARB\0" + "GL_EDGE_FLAG\0" + "GL_EDGE_FLAG_ARRAY\0" + "GL_EDGE_FLAG_ARRAY_BUFFER_BINDING\0" + "GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB\0" + "GL_EDGE_FLAG_ARRAY_POINTER\0" + "GL_EDGE_FLAG_ARRAY_STRIDE\0" + "GL_ELEMENT_ARRAY_BUFFER\0" + "GL_ELEMENT_ARRAY_BUFFER_BINDING\0" + "GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB\0" + "GL_EMISSION\0" + "GL_ENABLE_BIT\0" + "GL_EQUAL\0" + "GL_EQUIV\0" + "GL_EVAL_BIT\0" + "GL_EXP\0" + "GL_EXP2\0" + "GL_EXTENSIONS\0" + "GL_EYE_LINEAR\0" + "GL_EYE_PLANE\0" + "GL_EYE_PLANE_ABSOLUTE_NV\0" + "GL_EYE_RADIAL_NV\0" + "GL_FALSE\0" + "GL_FASTEST\0" + "GL_FEEDBACK\0" + "GL_FEEDBACK_BUFFER_POINTER\0" + "GL_FEEDBACK_BUFFER_SIZE\0" + "GL_FEEDBACK_BUFFER_TYPE\0" + "GL_FILL\0" + "GL_FIRST_VERTEX_CONVENTION\0" + "GL_FIRST_VERTEX_CONVENTION_EXT\0" + "GL_FIXED\0" + "GL_FIXED_OES\0" + "GL_FIXED_ONLY\0" + "GL_FIXED_ONLY_ARB\0" + "GL_FLAT\0" + "GL_FLOAT\0" + "GL_FLOAT_MAT2\0" + "GL_FLOAT_MAT2_ARB\0" + "GL_FLOAT_MAT2x3\0" + "GL_FLOAT_MAT2x4\0" + "GL_FLOAT_MAT3\0" + "GL_FLOAT_MAT3_ARB\0" + "GL_FLOAT_MAT3x2\0" + "GL_FLOAT_MAT3x4\0" + "GL_FLOAT_MAT4\0" + "GL_FLOAT_MAT4_ARB\0" + "GL_FLOAT_MAT4x2\0" + "GL_FLOAT_MAT4x3\0" + "GL_FLOAT_VEC2\0" + "GL_FLOAT_VEC2_ARB\0" + "GL_FLOAT_VEC3\0" + "GL_FLOAT_VEC3_ARB\0" + "GL_FLOAT_VEC4\0" + "GL_FLOAT_VEC4_ARB\0" + "GL_FOG\0" + "GL_FOG_BIT\0" + "GL_FOG_COLOR\0" + "GL_FOG_COORD\0" + "GL_FOG_COORDINATE\0" + "GL_FOG_COORDINATE_ARRAY\0" + "GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING\0" + "GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB\0" + "GL_FOG_COORDINATE_ARRAY_POINTER\0" + "GL_FOG_COORDINATE_ARRAY_STRIDE\0" + "GL_FOG_COORDINATE_ARRAY_TYPE\0" + "GL_FOG_COORDINATE_SOURCE\0" + "GL_FOG_COORD_ARRAY\0" + "GL_FOG_COORD_ARRAY_BUFFER_BINDING\0" + "GL_FOG_COORD_ARRAY_POINTER\0" + "GL_FOG_COORD_ARRAY_STRIDE\0" + "GL_FOG_COORD_ARRAY_TYPE\0" + "GL_FOG_COORD_SRC\0" + "GL_FOG_DENSITY\0" + "GL_FOG_DISTANCE_MODE_NV\0" + "GL_FOG_END\0" + "GL_FOG_HINT\0" + "GL_FOG_INDEX\0" + "GL_FOG_MODE\0" + "GL_FOG_OFFSET_SGIX\0" + "GL_FOG_OFFSET_VALUE_SGIX\0" + "GL_FOG_START\0" + "GL_FRAGMENT_DEPTH\0" + "GL_FRAGMENT_PROGRAM_ARB\0" + "GL_FRAGMENT_SHADER\0" + "GL_FRAGMENT_SHADER_ARB\0" + "GL_FRAGMENT_SHADER_DERIVATIVE_HINT\0" + "GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES\0" + "GL_FRAMEBUFFER\0" + "GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE\0" + "GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE\0" + "GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING\0" + "GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE\0" + "GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE\0" + "GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE\0" + "GL_FRAMEBUFFER_ATTACHMENT_LAYERED\0" + "GL_FRAMEBUFFER_ATTACHMENT_LAYERED_ARB\0" + "GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME\0" + "GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT\0" + "GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_OES\0" + "GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE\0" + "GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT\0" + "GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_OES\0" + "GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE\0" + "GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE\0" + "GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT\0" + "GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_OES\0" + "GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE\0" + "GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT\0" + "GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_OES\0" + "GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER\0" + "GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT\0" + "GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL\0" + "GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT\0" + "GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_OES\0" + "GL_FRAMEBUFFER_BINDING\0" + "GL_FRAMEBUFFER_BINDING_EXT\0" + "GL_FRAMEBUFFER_BINDING_OES\0" + "GL_FRAMEBUFFER_COMPLETE\0" + "GL_FRAMEBUFFER_COMPLETE_EXT\0" + "GL_FRAMEBUFFER_COMPLETE_OES\0" + "GL_FRAMEBUFFER_DEFAULT\0" + "GL_FRAMEBUFFER_EXT\0" + "GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT\0" + "GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT\0" + "GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_OES\0" + "GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS\0" + "GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT\0" + "GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_OES\0" + "GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER\0" + "GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT\0" + "GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_OES\0" + "GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT\0" + "GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT\0" + "GL_FRAMEBUFFER_INCOMPLETE_FORMATS_OES\0" + "GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB\0" + "GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS\0" + "GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_ARB\0" + "GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT\0" + "GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT\0" + "GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_OES\0" + "GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE\0" + "GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT\0" + "GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER\0" + "GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT\0" + "GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_OES\0" + "GL_FRAMEBUFFER_OES\0" + "GL_FRAMEBUFFER_STATUS_ERROR_EXT\0" + "GL_FRAMEBUFFER_UNDEFINED\0" + "GL_FRAMEBUFFER_UNSUPPORTED\0" + "GL_FRAMEBUFFER_UNSUPPORTED_EXT\0" + "GL_FRAMEBUFFER_UNSUPPORTED_OES\0" + "GL_FRONT\0" + "GL_FRONT_AND_BACK\0" + "GL_FRONT_FACE\0" + "GL_FRONT_LEFT\0" + "GL_FRONT_RIGHT\0" + "GL_FUNC_ADD\0" + "GL_FUNC_ADD_EXT\0" + "GL_FUNC_ADD_OES\0" + "GL_FUNC_REVERSE_SUBTRACT\0" + "GL_FUNC_REVERSE_SUBTRACT_EXT\0" + "GL_FUNC_REVERSE_SUBTRACT_OES\0" + "GL_FUNC_SUBTRACT\0" + "GL_FUNC_SUBTRACT_EXT\0" + "GL_FUNC_SUBTRACT_OES\0" + "GL_GENERATE_MIPMAP\0" + "GL_GENERATE_MIPMAP_HINT\0" + "GL_GENERATE_MIPMAP_HINT_SGIS\0" + "GL_GENERATE_MIPMAP_SGIS\0" + "GL_GEOMETRY_INPUT_TYPE\0" + "GL_GEOMETRY_INPUT_TYPE_ARB\0" + "GL_GEOMETRY_OUTPUT_TYPE\0" + "GL_GEOMETRY_OUTPUT_TYPE_ARB\0" + "GL_GEOMETRY_SHADER\0" + "GL_GEOMETRY_SHADER_ARB\0" + "GL_GEOMETRY_VERTICES_OUT\0" + "GL_GEOMETRY_VERTICES_OUT_ARB\0" + "GL_GEQUAL\0" + "GL_GREATER\0" + "GL_GREEN\0" + "GL_GREEN_BIAS\0" + "GL_GREEN_BITS\0" + "GL_GREEN_INTEGER\0" + "GL_GREEN_INTEGER_EXT\0" + "GL_GREEN_SCALE\0" + "GL_GUILTY_CONTEXT_RESET_ARB\0" + "GL_HALF_FLOAT\0" + "GL_HALF_FLOAT_OES\0" + "GL_HIGH_FLOAT\0" + "GL_HIGH_INT\0" + "GL_HINT_BIT\0" + "GL_HISTOGRAM\0" + "GL_HISTOGRAM_ALPHA_SIZE\0" + "GL_HISTOGRAM_ALPHA_SIZE_EXT\0" + "GL_HISTOGRAM_BLUE_SIZE\0" + "GL_HISTOGRAM_BLUE_SIZE_EXT\0" + "GL_HISTOGRAM_EXT\0" + "GL_HISTOGRAM_FORMAT\0" + "GL_HISTOGRAM_FORMAT_EXT\0" + "GL_HISTOGRAM_GREEN_SIZE\0" + "GL_HISTOGRAM_GREEN_SIZE_EXT\0" + "GL_HISTOGRAM_LUMINANCE_SIZE\0" + "GL_HISTOGRAM_LUMINANCE_SIZE_EXT\0" + "GL_HISTOGRAM_RED_SIZE\0" + "GL_HISTOGRAM_RED_SIZE_EXT\0" + "GL_HISTOGRAM_SINK\0" + "GL_HISTOGRAM_SINK_EXT\0" + "GL_HISTOGRAM_WIDTH\0" + "GL_HISTOGRAM_WIDTH_EXT\0" + "GL_IDENTITY_NV\0" + "GL_IGNORE_BORDER_HP\0" + "GL_IMPLEMENTATION_COLOR_READ_FORMAT\0" + "GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES\0" + "GL_IMPLEMENTATION_COLOR_READ_TYPE\0" + "GL_IMPLEMENTATION_COLOR_READ_TYPE_OES\0" + "GL_INCR\0" + "GL_INCR_WRAP\0" + "GL_INCR_WRAP_EXT\0" + "GL_INDEX\0" + "GL_INDEX_ARRAY\0" + "GL_INDEX_ARRAY_BUFFER_BINDING\0" + "GL_INDEX_ARRAY_BUFFER_BINDING_ARB\0" + "GL_INDEX_ARRAY_POINTER\0" + "GL_INDEX_ARRAY_STRIDE\0" + "GL_INDEX_ARRAY_TYPE\0" + "GL_INDEX_BITS\0" + "GL_INDEX_CLEAR_VALUE\0" + "GL_INDEX_LOGIC_OP\0" + "GL_INDEX_MODE\0" + "GL_INDEX_OFFSET\0" + "GL_INDEX_SHIFT\0" + "GL_INDEX_WRITEMASK\0" + "GL_INFO_LOG_LENGTH\0" + "GL_INNOCENT_CONTEXT_RESET_ARB\0" + "GL_INT\0" + "GL_INTENSITY\0" + "GL_INTENSITY12\0" + "GL_INTENSITY12_EXT\0" + "GL_INTENSITY16\0" + "GL_INTENSITY16I_EXT\0" + "GL_INTENSITY16UI_EXT\0" + "GL_INTENSITY16_EXT\0" + "GL_INTENSITY32I_EXT\0" + "GL_INTENSITY32UI_EXT\0" + "GL_INTENSITY4\0" + "GL_INTENSITY4_EXT\0" + "GL_INTENSITY8\0" + "GL_INTENSITY8I_EXT\0" + "GL_INTENSITY8UI_EXT\0" + "GL_INTENSITY8_EXT\0" + "GL_INTENSITY_EXT\0" + "GL_INTERLEAVED_ATTRIBS\0" + "GL_INTERLEAVED_ATTRIBS_EXT\0" + "GL_INTERPOLATE\0" + "GL_INTERPOLATE_ARB\0" + "GL_INTERPOLATE_EXT\0" + "GL_INT_10_10_10_2_OES\0" + "GL_INT_2_10_10_10_REV\0" + "GL_INT_SAMPLER_1D\0" + "GL_INT_SAMPLER_1D_ARRAY\0" + "GL_INT_SAMPLER_1D_ARRAY_EXT\0" + "GL_INT_SAMPLER_1D_EXT\0" + "GL_INT_SAMPLER_2D\0" + "GL_INT_SAMPLER_2D_ARRAY\0" + "GL_INT_SAMPLER_2D_ARRAY_EXT\0" + "GL_INT_SAMPLER_2D_EXT\0" + "GL_INT_SAMPLER_2D_RECT\0" + "GL_INT_SAMPLER_2D_RECT_EXT\0" + "GL_INT_SAMPLER_3D\0" + "GL_INT_SAMPLER_3D_EXT\0" + "GL_INT_SAMPLER_BUFFER\0" + "GL_INT_SAMPLER_BUFFER_EXT\0" + "GL_INT_SAMPLER_CUBE\0" + "GL_INT_SAMPLER_CUBE_EXT\0" + "GL_INT_VEC2\0" + "GL_INT_VEC2_ARB\0" + "GL_INT_VEC3\0" + "GL_INT_VEC3_ARB\0" + "GL_INT_VEC4\0" + "GL_INT_VEC4_ARB\0" + "GL_INVALID_ENUM\0" + "GL_INVALID_FRAMEBUFFER_OPERATION\0" + "GL_INVALID_FRAMEBUFFER_OPERATION_EXT\0" + "GL_INVALID_FRAMEBUFFER_OPERATION_OES\0" + "GL_INVALID_OPERATION\0" + "GL_INVALID_VALUE\0" + "GL_INVERSE_NV\0" + "GL_INVERSE_TRANSPOSE_NV\0" + "GL_INVERT\0" + "GL_KEEP\0" + "GL_LAST_VERTEX_CONVENTION\0" + "GL_LAST_VERTEX_CONVENTION_EXT\0" + "GL_LEFT\0" + "GL_LEQUAL\0" + "GL_LESS\0" + "GL_LIGHT0\0" + "GL_LIGHT1\0" + "GL_LIGHT2\0" + "GL_LIGHT3\0" + "GL_LIGHT4\0" + "GL_LIGHT5\0" + "GL_LIGHT6\0" + "GL_LIGHT7\0" + "GL_LIGHTING\0" + "GL_LIGHTING_BIT\0" + "GL_LIGHT_MODEL_AMBIENT\0" + "GL_LIGHT_MODEL_COLOR_CONTROL\0" + "GL_LIGHT_MODEL_COLOR_CONTROL_EXT\0" + "GL_LIGHT_MODEL_LOCAL_VIEWER\0" + "GL_LIGHT_MODEL_TWO_SIDE\0" + "GL_LINE\0" + "GL_LINEAR\0" + "GL_LINEAR_ATTENUATION\0" + "GL_LINEAR_CLIPMAP_LINEAR_SGIX\0" + "GL_LINEAR_CLIPMAP_NEAREST_SGIX\0" + "GL_LINEAR_MIPMAP_LINEAR\0" + "GL_LINEAR_MIPMAP_NEAREST\0" + "GL_LINES\0" + "GL_LINES_ADJACENCY\0" + "GL_LINES_ADJACENCY_ARB\0" + "GL_LINE_BIT\0" + "GL_LINE_LOOP\0" + "GL_LINE_RESET_TOKEN\0" + "GL_LINE_SMOOTH\0" + "GL_LINE_SMOOTH_HINT\0" + "GL_LINE_STIPPLE\0" + "GL_LINE_STIPPLE_PATTERN\0" + "GL_LINE_STIPPLE_REPEAT\0" + "GL_LINE_STRIP\0" + "GL_LINE_STRIP_ADJACENCY\0" + "GL_LINE_STRIP_ADJACENCY_ARB\0" + "GL_LINE_TOKEN\0" + "GL_LINE_WIDTH\0" + "GL_LINE_WIDTH_GRANULARITY\0" + "GL_LINE_WIDTH_RANGE\0" + "GL_LINK_STATUS\0" + "GL_LIST_BASE\0" + "GL_LIST_BIT\0" + "GL_LIST_INDEX\0" + "GL_LIST_MODE\0" + "GL_LOAD\0" + "GL_LOGIC_OP\0" + "GL_LOGIC_OP_MODE\0" + "GL_LOSE_CONTEXT_ON_RESET_ARB\0" + "GL_LOWER_LEFT\0" + "GL_LOW_FLOAT\0" + "GL_LOW_INT\0" + "GL_LUMINANCE\0" + "GL_LUMINANCE12\0" + "GL_LUMINANCE12_ALPHA12\0" + "GL_LUMINANCE12_ALPHA12_EXT\0" + "GL_LUMINANCE12_ALPHA4\0" + "GL_LUMINANCE12_ALPHA4_EXT\0" + "GL_LUMINANCE12_EXT\0" + "GL_LUMINANCE16\0" + "GL_LUMINANCE16I_EXT\0" + "GL_LUMINANCE16UI_EXT\0" + "GL_LUMINANCE16_ALPHA16\0" + "GL_LUMINANCE16_ALPHA16_EXT\0" + "GL_LUMINANCE16_EXT\0" + "GL_LUMINANCE32I_EXT\0" + "GL_LUMINANCE32UI_EXT\0" + "GL_LUMINANCE4\0" + "GL_LUMINANCE4_ALPHA4\0" + "GL_LUMINANCE4_ALPHA4_EXT\0" + "GL_LUMINANCE4_EXT\0" + "GL_LUMINANCE6_ALPHA2\0" + "GL_LUMINANCE6_ALPHA2_EXT\0" + "GL_LUMINANCE8\0" + "GL_LUMINANCE8I_EXT\0" + "GL_LUMINANCE8UI_EXT\0" + "GL_LUMINANCE8_ALPHA8\0" + "GL_LUMINANCE8_ALPHA8_EXT\0" + "GL_LUMINANCE8_EXT\0" + "GL_LUMINANCE_ALPHA\0" + "GL_LUMINANCE_ALPHA16I_EXT\0" + "GL_LUMINANCE_ALPHA16UI_EXT\0" + "GL_LUMINANCE_ALPHA32I_EXT\0" + "GL_LUMINANCE_ALPHA32UI_EXT\0" + "GL_LUMINANCE_ALPHA8I_EXT\0" + "GL_LUMINANCE_ALPHA8UI_EXT\0" + "GL_LUMINANCE_ALPHA_INTEGER_EXT\0" + "GL_LUMINANCE_INTEGER_EXT\0" + "GL_MAJOR_VERSION\0" + "GL_MAP1_COLOR_4\0" + "GL_MAP1_GRID_DOMAIN\0" + "GL_MAP1_GRID_SEGMENTS\0" + "GL_MAP1_INDEX\0" + "GL_MAP1_NORMAL\0" + "GL_MAP1_TEXTURE_COORD_1\0" + "GL_MAP1_TEXTURE_COORD_2\0" + "GL_MAP1_TEXTURE_COORD_3\0" + "GL_MAP1_TEXTURE_COORD_4\0" + "GL_MAP1_VERTEX_3\0" + "GL_MAP1_VERTEX_4\0" + "GL_MAP1_VERTEX_ATTRIB0_4_NV\0" + "GL_MAP1_VERTEX_ATTRIB10_4_NV\0" + "GL_MAP1_VERTEX_ATTRIB11_4_NV\0" + "GL_MAP1_VERTEX_ATTRIB12_4_NV\0" + "GL_MAP1_VERTEX_ATTRIB13_4_NV\0" + "GL_MAP1_VERTEX_ATTRIB14_4_NV\0" + "GL_MAP1_VERTEX_ATTRIB15_4_NV\0" + "GL_MAP1_VERTEX_ATTRIB1_4_NV\0" + "GL_MAP1_VERTEX_ATTRIB2_4_NV\0" + "GL_MAP1_VERTEX_ATTRIB3_4_NV\0" + "GL_MAP1_VERTEX_ATTRIB4_4_NV\0" + "GL_MAP1_VERTEX_ATTRIB5_4_NV\0" + "GL_MAP1_VERTEX_ATTRIB6_4_NV\0" + "GL_MAP1_VERTEX_ATTRIB7_4_NV\0" + "GL_MAP1_VERTEX_ATTRIB8_4_NV\0" + "GL_MAP1_VERTEX_ATTRIB9_4_NV\0" + "GL_MAP2_COLOR_4\0" + "GL_MAP2_GRID_DOMAIN\0" + "GL_MAP2_GRID_SEGMENTS\0" + "GL_MAP2_INDEX\0" + "GL_MAP2_NORMAL\0" + "GL_MAP2_TEXTURE_COORD_1\0" + "GL_MAP2_TEXTURE_COORD_2\0" + "GL_MAP2_TEXTURE_COORD_3\0" + "GL_MAP2_TEXTURE_COORD_4\0" + "GL_MAP2_VERTEX_3\0" + "GL_MAP2_VERTEX_4\0" + "GL_MAP2_VERTEX_ATTRIB0_4_NV\0" + "GL_MAP2_VERTEX_ATTRIB10_4_NV\0" + "GL_MAP2_VERTEX_ATTRIB11_4_NV\0" + "GL_MAP2_VERTEX_ATTRIB12_4_NV\0" + "GL_MAP2_VERTEX_ATTRIB13_4_NV\0" + "GL_MAP2_VERTEX_ATTRIB14_4_NV\0" + "GL_MAP2_VERTEX_ATTRIB15_4_NV\0" + "GL_MAP2_VERTEX_ATTRIB1_4_NV\0" + "GL_MAP2_VERTEX_ATTRIB2_4_NV\0" + "GL_MAP2_VERTEX_ATTRIB3_4_NV\0" + "GL_MAP2_VERTEX_ATTRIB4_4_NV\0" + "GL_MAP2_VERTEX_ATTRIB5_4_NV\0" + "GL_MAP2_VERTEX_ATTRIB6_4_NV\0" + "GL_MAP2_VERTEX_ATTRIB7_4_NV\0" + "GL_MAP2_VERTEX_ATTRIB8_4_NV\0" + "GL_MAP2_VERTEX_ATTRIB9_4_NV\0" + "GL_MAP_COLOR\0" + "GL_MAP_FLUSH_EXPLICIT_BIT\0" + "GL_MAP_INVALIDATE_BUFFER_BIT\0" + "GL_MAP_INVALIDATE_RANGE_BIT\0" + "GL_MAP_READ_BIT\0" + "GL_MAP_STENCIL\0" + "GL_MAP_UNSYNCHRONIZED_BIT\0" + "GL_MAP_WRITE_BIT\0" + "GL_MATRIX0_ARB\0" + "GL_MATRIX0_NV\0" + "GL_MATRIX10_ARB\0" + "GL_MATRIX11_ARB\0" + "GL_MATRIX12_ARB\0" + "GL_MATRIX13_ARB\0" + "GL_MATRIX14_ARB\0" + "GL_MATRIX15_ARB\0" + "GL_MATRIX16_ARB\0" + "GL_MATRIX17_ARB\0" + "GL_MATRIX18_ARB\0" + "GL_MATRIX19_ARB\0" + "GL_MATRIX1_ARB\0" + "GL_MATRIX1_NV\0" + "GL_MATRIX20_ARB\0" + "GL_MATRIX21_ARB\0" + "GL_MATRIX22_ARB\0" + "GL_MATRIX23_ARB\0" + "GL_MATRIX24_ARB\0" + "GL_MATRIX25_ARB\0" + "GL_MATRIX26_ARB\0" + "GL_MATRIX27_ARB\0" + "GL_MATRIX28_ARB\0" + "GL_MATRIX29_ARB\0" + "GL_MATRIX2_ARB\0" + "GL_MATRIX2_NV\0" + "GL_MATRIX30_ARB\0" + "GL_MATRIX31_ARB\0" + "GL_MATRIX3_ARB\0" + "GL_MATRIX3_NV\0" + "GL_MATRIX4_ARB\0" + "GL_MATRIX4_NV\0" + "GL_MATRIX5_ARB\0" + "GL_MATRIX5_NV\0" + "GL_MATRIX6_ARB\0" + "GL_MATRIX6_NV\0" + "GL_MATRIX7_ARB\0" + "GL_MATRIX7_NV\0" + "GL_MATRIX8_ARB\0" + "GL_MATRIX9_ARB\0" + "GL_MATRIX_INDEX_ARRAY_ARB\0" + "GL_MATRIX_INDEX_ARRAY_BUFFER_BINDING_OES\0" + "GL_MATRIX_INDEX_ARRAY_OES\0" + "GL_MATRIX_INDEX_ARRAY_POINTER_ARB\0" + "GL_MATRIX_INDEX_ARRAY_POINTER_OES\0" + "GL_MATRIX_INDEX_ARRAY_SIZE_ARB\0" + "GL_MATRIX_INDEX_ARRAY_SIZE_OES\0" + "GL_MATRIX_INDEX_ARRAY_STRIDE_ARB\0" + "GL_MATRIX_INDEX_ARRAY_STRIDE_OES\0" + "GL_MATRIX_INDEX_ARRAY_TYPE_ARB\0" + "GL_MATRIX_INDEX_ARRAY_TYPE_OES\0" + "GL_MATRIX_MODE\0" + "GL_MATRIX_PALETTE_ARB\0" + "GL_MATRIX_PALETTE_OES\0" + "GL_MAX\0" + "GL_MAX_3D_TEXTURE_SIZE\0" + "GL_MAX_3D_TEXTURE_SIZE_OES\0" + "GL_MAX_ARRAY_TEXTURE_LAYERS\0" + "GL_MAX_ARRAY_TEXTURE_LAYERS_EXT\0" + "GL_MAX_ATTRIB_STACK_DEPTH\0" + "GL_MAX_CLIENT_ATTRIB_STACK_DEPTH\0" + "GL_MAX_CLIPMAP_DEPTH_SGIX\0" + "GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX\0" + "GL_MAX_CLIP_DISTANCES\0" + "GL_MAX_CLIP_PLANES\0" + "GL_MAX_COLOR_ATTACHMENTS\0" + "GL_MAX_COLOR_ATTACHMENTS_EXT\0" + "GL_MAX_COLOR_MATRIX_STACK_DEPTH\0" + "GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI\0" + "GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS\0" + "GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB\0" + "GL_MAX_CONVOLUTION_HEIGHT\0" + "GL_MAX_CONVOLUTION_HEIGHT_EXT\0" + "GL_MAX_CONVOLUTION_WIDTH\0" + "GL_MAX_CONVOLUTION_WIDTH_EXT\0" + "GL_MAX_CUBE_MAP_TEXTURE_SIZE\0" + "GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB\0" + "GL_MAX_CUBE_MAP_TEXTURE_SIZE_OES\0" + "GL_MAX_DRAW_BUFFERS\0" + "GL_MAX_DRAW_BUFFERS_ARB\0" + "GL_MAX_DRAW_BUFFERS_ATI\0" + "GL_MAX_ELEMENTS_INDICES\0" + "GL_MAX_ELEMENTS_VERTICES\0" + "GL_MAX_EVAL_ORDER\0" + "GL_MAX_EXT\0" + "GL_MAX_FRAGMENT_INPUT_COMPONENTS\0" + "GL_MAX_FRAGMENT_UNIFORM_COMPONENTS\0" + "GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB\0" + "GL_MAX_FRAGMENT_UNIFORM_VECTORS\0" + "GL_MAX_GEOMETRY_INPUT_COMPONENTS\0" + "GL_MAX_GEOMETRY_OUTPUT_COMPONENTS\0" + "GL_MAX_GEOMETRY_OUTPUT_VERTICES\0" + "GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB\0" + "GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS\0" + "GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB\0" + "GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS\0" + "GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB\0" + "GL_MAX_GEOMETRY_UNIFORM_COMPONENTS\0" + "GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB\0" + "GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB\0" + "GL_MAX_LIGHTS\0" + "GL_MAX_LIST_NESTING\0" + "GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB\0" + "GL_MAX_MODELVIEW_STACK_DEPTH\0" + "GL_MAX_NAME_STACK_DEPTH\0" + "GL_MAX_PALETTE_MATRICES_ARB\0" + "GL_MAX_PALETTE_MATRICES_OES\0" + "GL_MAX_PIXEL_MAP_TABLE\0" + "GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB\0" + "GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB\0" + "GL_MAX_PROGRAM_ATTRIBS_ARB\0" + "GL_MAX_PROGRAM_CALL_DEPTH_NV\0" + "GL_MAX_PROGRAM_ENV_PARAMETERS_ARB\0" + "GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV\0" + "GL_MAX_PROGRAM_IF_DEPTH_NV\0" + "GL_MAX_PROGRAM_INSTRUCTIONS_ARB\0" + "GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB\0" + "GL_MAX_PROGRAM_LOOP_COUNT_NV\0" + "GL_MAX_PROGRAM_LOOP_DEPTH_NV\0" + "GL_MAX_PROGRAM_MATRICES_ARB\0" + "GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB\0" + "GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB\0" + "GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB\0" + "GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB\0" + "GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB\0" + "GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB\0" + "GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB\0" + "GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB\0" + "GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB\0" + "GL_MAX_PROGRAM_PARAMETERS_ARB\0" + "GL_MAX_PROGRAM_TEMPORARIES_ARB\0" + "GL_MAX_PROGRAM_TEXEL_OFFSET\0" + "GL_MAX_PROGRAM_TEXEL_OFFSET_EXT\0" + "GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB\0" + "GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB\0" + "GL_MAX_PROJECTION_STACK_DEPTH\0" + "GL_MAX_RECTANGLE_TEXTURE_SIZE\0" + "GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB\0" + "GL_MAX_RECTANGLE_TEXTURE_SIZE_NV\0" + "GL_MAX_RENDERBUFFER_SIZE\0" + "GL_MAX_RENDERBUFFER_SIZE_EXT\0" + "GL_MAX_RENDERBUFFER_SIZE_OES\0" + "GL_MAX_SAMPLES\0" + "GL_MAX_SAMPLES_EXT\0" + "GL_MAX_SERVER_WAIT_TIMEOUT\0" + "GL_MAX_SHININESS_NV\0" + "GL_MAX_SPOT_EXPONENT_NV\0" + "GL_MAX_TEXTURE_BUFFER_SIZE\0" + "GL_MAX_TEXTURE_BUFFER_SIZE_ARB\0" + "GL_MAX_TEXTURE_COORDS\0" + "GL_MAX_TEXTURE_COORDS_ARB\0" + "GL_MAX_TEXTURE_IMAGE_UNITS\0" + "GL_MAX_TEXTURE_IMAGE_UNITS_ARB\0" + "GL_MAX_TEXTURE_LOD_BIAS\0" + "GL_MAX_TEXTURE_LOD_BIAS_EXT\0" + "GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT\0" + "GL_MAX_TEXTURE_SIZE\0" + "GL_MAX_TEXTURE_STACK_DEPTH\0" + "GL_MAX_TEXTURE_UNITS\0" + "GL_MAX_TEXTURE_UNITS_ARB\0" + "GL_MAX_TRACK_MATRICES_NV\0" + "GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV\0" + "GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS\0" + "GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_EXT\0" + "GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS\0" + "GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_EXT\0" + "GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS\0" + "GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_EXT\0" + "GL_MAX_VARYING_COMPONENTS\0" + "GL_MAX_VARYING_FLOATS\0" + "GL_MAX_VARYING_FLOATS_ARB\0" + "GL_MAX_VARYING_VECTORS\0" + "GL_MAX_VERTEX_ATTRIBS\0" + "GL_MAX_VERTEX_ATTRIBS_ARB\0" + "GL_MAX_VERTEX_OUTPUT_COMPONENTS\0" + "GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS\0" + "GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB\0" + "GL_MAX_VERTEX_UNIFORM_COMPONENTS\0" + "GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB\0" + "GL_MAX_VERTEX_UNIFORM_VECTORS\0" + "GL_MAX_VERTEX_UNITS_ARB\0" + "GL_MAX_VERTEX_UNITS_OES\0" + "GL_MAX_VERTEX_VARYING_COMPONENTS_ARB\0" + "GL_MAX_VIEWPORT_DIMS\0" + "GL_MEDIUM_FLOAT\0" + "GL_MEDIUM_INT\0" + "GL_MIN\0" + "GL_MINMAX\0" + "GL_MINMAX_EXT\0" + "GL_MINMAX_FORMAT\0" + "GL_MINMAX_FORMAT_EXT\0" + "GL_MINMAX_SINK\0" + "GL_MINMAX_SINK_EXT\0" + "GL_MINOR_VERSION\0" + "GL_MIN_EXT\0" + "GL_MIN_PROGRAM_TEXEL_OFFSET\0" + "GL_MIN_PROGRAM_TEXEL_OFFSET_EXT\0" + "GL_MIRRORED_REPEAT\0" + "GL_MIRRORED_REPEAT_ARB\0" + "GL_MIRRORED_REPEAT_IBM\0" + "GL_MIRROR_CLAMP_ATI\0" + "GL_MIRROR_CLAMP_EXT\0" + "GL_MIRROR_CLAMP_TO_BORDER_EXT\0" + "GL_MIRROR_CLAMP_TO_EDGE_ATI\0" + "GL_MIRROR_CLAMP_TO_EDGE_EXT\0" + "GL_MODELVIEW\0" + "GL_MODELVIEW0_ARB\0" + "GL_MODELVIEW10_ARB\0" + "GL_MODELVIEW11_ARB\0" + "GL_MODELVIEW12_ARB\0" + "GL_MODELVIEW13_ARB\0" + "GL_MODELVIEW14_ARB\0" + "GL_MODELVIEW15_ARB\0" + "GL_MODELVIEW16_ARB\0" + "GL_MODELVIEW17_ARB\0" + "GL_MODELVIEW18_ARB\0" + "GL_MODELVIEW19_ARB\0" + "GL_MODELVIEW1_ARB\0" + "GL_MODELVIEW20_ARB\0" + "GL_MODELVIEW21_ARB\0" + "GL_MODELVIEW22_ARB\0" + "GL_MODELVIEW23_ARB\0" + "GL_MODELVIEW24_ARB\0" + "GL_MODELVIEW25_ARB\0" + "GL_MODELVIEW26_ARB\0" + "GL_MODELVIEW27_ARB\0" + "GL_MODELVIEW28_ARB\0" + "GL_MODELVIEW29_ARB\0" + "GL_MODELVIEW2_ARB\0" + "GL_MODELVIEW30_ARB\0" + "GL_MODELVIEW31_ARB\0" + "GL_MODELVIEW3_ARB\0" + "GL_MODELVIEW4_ARB\0" + "GL_MODELVIEW5_ARB\0" + "GL_MODELVIEW6_ARB\0" + "GL_MODELVIEW7_ARB\0" + "GL_MODELVIEW8_ARB\0" + "GL_MODELVIEW9_ARB\0" + "GL_MODELVIEW_MATRIX\0" + "GL_MODELVIEW_MATRIX_FLOAT_AS_INT_BITS_OES\0" + "GL_MODELVIEW_PROJECTION_NV\0" + "GL_MODELVIEW_STACK_DEPTH\0" + "GL_MODULATE\0" + "GL_MODULATE_ADD_ATI\0" + "GL_MODULATE_SIGNED_ADD_ATI\0" + "GL_MODULATE_SUBTRACT_ATI\0" + "GL_MULT\0" + "GL_MULTISAMPLE\0" + "GL_MULTISAMPLE_3DFX\0" + "GL_MULTISAMPLE_ARB\0" + "GL_MULTISAMPLE_BIT\0" + "GL_MULTISAMPLE_BIT_3DFX\0" + "GL_MULTISAMPLE_BIT_ARB\0" + "GL_MULTISAMPLE_FILTER_HINT_NV\0" + "GL_N3F_V3F\0" + "GL_NAME_STACK_DEPTH\0" + "GL_NAND\0" + "GL_NEAREST\0" + "GL_NEAREST_CLIPMAP_LINEAR_SGIX\0" + "GL_NEAREST_CLIPMAP_NEAREST_SGIX\0" + "GL_NEAREST_MIPMAP_LINEAR\0" + "GL_NEAREST_MIPMAP_NEAREST\0" + "GL_NEVER\0" + "GL_NICEST\0" + "GL_NONE\0" + "GL_NONE_OES\0" + "GL_NOOP\0" + "GL_NOR\0" + "GL_NORMALIZE\0" + "GL_NORMAL_ARRAY\0" + "GL_NORMAL_ARRAY_BUFFER_BINDING\0" + "GL_NORMAL_ARRAY_BUFFER_BINDING_ARB\0" + "GL_NORMAL_ARRAY_POINTER\0" + "GL_NORMAL_ARRAY_STRIDE\0" + "GL_NORMAL_ARRAY_TYPE\0" + "GL_NORMAL_MAP\0" + "GL_NORMAL_MAP_ARB\0" + "GL_NORMAL_MAP_NV\0" + "GL_NORMAL_MAP_OES\0" + "GL_NOTEQUAL\0" + "GL_NO_ERROR\0" + "GL_NO_RESET_NOTIFICATION_ARB\0" + "GL_NUM_COMPRESSED_TEXTURE_FORMATS\0" + "GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB\0" + "GL_NUM_EXTENSIONS\0" + "GL_NUM_PROGRAM_BINARY_FORMATS\0" + "GL_NUM_PROGRAM_BINARY_FORMATS_OES\0" + "GL_NUM_SHADER_BINARY_FORMATS\0" + "GL_OBJECT_ACTIVE_ATTRIBUTES_ARB\0" + "GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB\0" + "GL_OBJECT_ACTIVE_UNIFORMS_ARB\0" + "GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB\0" + "GL_OBJECT_ATTACHED_OBJECTS_ARB\0" + "GL_OBJECT_COMPILE_STATUS_ARB\0" + "GL_OBJECT_DELETE_STATUS_ARB\0" + "GL_OBJECT_INFO_LOG_LENGTH_ARB\0" + "GL_OBJECT_LINEAR\0" + "GL_OBJECT_LINK_STATUS_ARB\0" + "GL_OBJECT_PLANE\0" + "GL_OBJECT_SHADER_SOURCE_LENGTH_ARB\0" + "GL_OBJECT_SUBTYPE_ARB\0" + "GL_OBJECT_TYPE\0" + "GL_OBJECT_TYPE_ARB\0" + "GL_OBJECT_VALIDATE_STATUS_ARB\0" + "GL_OCCLUSION_TEST_HP\0" + "GL_OCCLUSION_TEST_RESULT_HP\0" + "GL_ONE\0" + "GL_ONE_MINUS_CONSTANT_ALPHA\0" + "GL_ONE_MINUS_CONSTANT_ALPHA_EXT\0" + "GL_ONE_MINUS_CONSTANT_COLOR\0" + "GL_ONE_MINUS_CONSTANT_COLOR_EXT\0" + "GL_ONE_MINUS_DST_ALPHA\0" + "GL_ONE_MINUS_DST_COLOR\0" + "GL_ONE_MINUS_SRC_ALPHA\0" + "GL_ONE_MINUS_SRC_COLOR\0" + "GL_OPERAND0_ALPHA\0" + "GL_OPERAND0_ALPHA_ARB\0" + "GL_OPERAND0_ALPHA_EXT\0" + "GL_OPERAND0_RGB\0" + "GL_OPERAND0_RGB_ARB\0" + "GL_OPERAND0_RGB_EXT\0" + "GL_OPERAND1_ALPHA\0" + "GL_OPERAND1_ALPHA_ARB\0" + "GL_OPERAND1_ALPHA_EXT\0" + "GL_OPERAND1_RGB\0" + "GL_OPERAND1_RGB_ARB\0" + "GL_OPERAND1_RGB_EXT\0" + "GL_OPERAND2_ALPHA\0" + "GL_OPERAND2_ALPHA_ARB\0" + "GL_OPERAND2_ALPHA_EXT\0" + "GL_OPERAND2_RGB\0" + "GL_OPERAND2_RGB_ARB\0" + "GL_OPERAND2_RGB_EXT\0" + "GL_OPERAND3_ALPHA_NV\0" + "GL_OPERAND3_RGB_NV\0" + "GL_OR\0" + "GL_ORDER\0" + "GL_OR_INVERTED\0" + "GL_OR_REVERSE\0" + "GL_OUT_OF_MEMORY\0" + "GL_PACK_ALIGNMENT\0" + "GL_PACK_IMAGE_HEIGHT\0" + "GL_PACK_INVERT_MESA\0" + "GL_PACK_LSB_FIRST\0" + "GL_PACK_ROW_LENGTH\0" + "GL_PACK_SKIP_IMAGES\0" + "GL_PACK_SKIP_PIXELS\0" + "GL_PACK_SKIP_ROWS\0" + "GL_PACK_SWAP_BYTES\0" + "GL_PALETTE4_R5_G6_B5_OES\0" + "GL_PALETTE4_RGB5_A1_OES\0" + "GL_PALETTE4_RGB8_OES\0" + "GL_PALETTE4_RGBA4_OES\0" + "GL_PALETTE4_RGBA8_OES\0" + "GL_PALETTE8_R5_G6_B5_OES\0" + "GL_PALETTE8_RGB5_A1_OES\0" + "GL_PALETTE8_RGB8_OES\0" + "GL_PALETTE8_RGBA4_OES\0" + "GL_PALETTE8_RGBA8_OES\0" + "GL_PASS_THROUGH_TOKEN\0" + "GL_PERSPECTIVE_CORRECTION_HINT\0" + "GL_PIXEL_MAP_A_TO_A\0" + "GL_PIXEL_MAP_A_TO_A_SIZE\0" + "GL_PIXEL_MAP_B_TO_B\0" + "GL_PIXEL_MAP_B_TO_B_SIZE\0" + "GL_PIXEL_MAP_G_TO_G\0" + "GL_PIXEL_MAP_G_TO_G_SIZE\0" + "GL_PIXEL_MAP_I_TO_A\0" + "GL_PIXEL_MAP_I_TO_A_SIZE\0" + "GL_PIXEL_MAP_I_TO_B\0" + "GL_PIXEL_MAP_I_TO_B_SIZE\0" + "GL_PIXEL_MAP_I_TO_G\0" + "GL_PIXEL_MAP_I_TO_G_SIZE\0" + "GL_PIXEL_MAP_I_TO_I\0" + "GL_PIXEL_MAP_I_TO_I_SIZE\0" + "GL_PIXEL_MAP_I_TO_R\0" + "GL_PIXEL_MAP_I_TO_R_SIZE\0" + "GL_PIXEL_MAP_R_TO_R\0" + "GL_PIXEL_MAP_R_TO_R_SIZE\0" + "GL_PIXEL_MAP_S_TO_S\0" + "GL_PIXEL_MAP_S_TO_S_SIZE\0" + "GL_PIXEL_MODE_BIT\0" + "GL_PIXEL_PACK_BUFFER\0" + "GL_PIXEL_PACK_BUFFER_BINDING\0" + "GL_PIXEL_PACK_BUFFER_BINDING_EXT\0" + "GL_PIXEL_PACK_BUFFER_EXT\0" + "GL_PIXEL_UNPACK_BUFFER\0" + "GL_PIXEL_UNPACK_BUFFER_BINDING\0" + "GL_PIXEL_UNPACK_BUFFER_BINDING_EXT\0" + "GL_PIXEL_UNPACK_BUFFER_EXT\0" + "GL_POINT\0" + "GL_POINTS\0" + "GL_POINT_BIT\0" + "GL_POINT_DISTANCE_ATTENUATION\0" + "GL_POINT_DISTANCE_ATTENUATION_ARB\0" + "GL_POINT_DISTANCE_ATTENUATION_EXT\0" + "GL_POINT_DISTANCE_ATTENUATION_SGIS\0" + "GL_POINT_FADE_THRESHOLD_SIZE\0" + "GL_POINT_FADE_THRESHOLD_SIZE_ARB\0" + "GL_POINT_FADE_THRESHOLD_SIZE_EXT\0" + "GL_POINT_FADE_THRESHOLD_SIZE_SGIS\0" + "GL_POINT_SIZE\0" + "GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES\0" + "GL_POINT_SIZE_ARRAY_OES\0" + "GL_POINT_SIZE_ARRAY_POINTER_OES\0" + "GL_POINT_SIZE_ARRAY_STRIDE_OES\0" + "GL_POINT_SIZE_ARRAY_TYPE_OES\0" + "GL_POINT_SIZE_GRANULARITY\0" + "GL_POINT_SIZE_MAX\0" + "GL_POINT_SIZE_MAX_ARB\0" + "GL_POINT_SIZE_MAX_EXT\0" + "GL_POINT_SIZE_MAX_SGIS\0" + "GL_POINT_SIZE_MIN\0" + "GL_POINT_SIZE_MIN_ARB\0" + "GL_POINT_SIZE_MIN_EXT\0" + "GL_POINT_SIZE_MIN_SGIS\0" + "GL_POINT_SIZE_RANGE\0" + "GL_POINT_SMOOTH\0" + "GL_POINT_SMOOTH_HINT\0" + "GL_POINT_SPRITE\0" + "GL_POINT_SPRITE_ARB\0" + "GL_POINT_SPRITE_COORD_ORIGIN\0" + "GL_POINT_SPRITE_NV\0" + "GL_POINT_SPRITE_OES\0" + "GL_POINT_SPRITE_R_MODE_NV\0" + "GL_POINT_TOKEN\0" + "GL_POLYGON\0" + "GL_POLYGON_BIT\0" + "GL_POLYGON_MODE\0" + "GL_POLYGON_OFFSET_BIAS\0" + "GL_POLYGON_OFFSET_FACTOR\0" + "GL_POLYGON_OFFSET_FILL\0" + "GL_POLYGON_OFFSET_LINE\0" + "GL_POLYGON_OFFSET_POINT\0" + "GL_POLYGON_OFFSET_UNITS\0" + "GL_POLYGON_SMOOTH\0" + "GL_POLYGON_SMOOTH_HINT\0" + "GL_POLYGON_STIPPLE\0" + "GL_POLYGON_STIPPLE_BIT\0" + "GL_POLYGON_TOKEN\0" + "GL_POSITION\0" + "GL_POST_COLOR_MATRIX_ALPHA_BIAS\0" + "GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI\0" + "GL_POST_COLOR_MATRIX_ALPHA_SCALE\0" + "GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI\0" + "GL_POST_COLOR_MATRIX_BLUE_BIAS\0" + "GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI\0" + "GL_POST_COLOR_MATRIX_BLUE_SCALE\0" + "GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI\0" + "GL_POST_COLOR_MATRIX_COLOR_TABLE\0" + "GL_POST_COLOR_MATRIX_GREEN_BIAS\0" + "GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI\0" + "GL_POST_COLOR_MATRIX_GREEN_SCALE\0" + "GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI\0" + "GL_POST_COLOR_MATRIX_RED_BIAS\0" + "GL_POST_COLOR_MATRIX_RED_BIAS_SGI\0" + "GL_POST_COLOR_MATRIX_RED_SCALE\0" + "GL_POST_COLOR_MATRIX_RED_SCALE_SGI\0" + "GL_POST_CONVOLUTION_ALPHA_BIAS\0" + "GL_POST_CONVOLUTION_ALPHA_BIAS_EXT\0" + "GL_POST_CONVOLUTION_ALPHA_SCALE\0" + "GL_POST_CONVOLUTION_ALPHA_SCALE_EXT\0" + "GL_POST_CONVOLUTION_BLUE_BIAS\0" + "GL_POST_CONVOLUTION_BLUE_BIAS_EXT\0" + "GL_POST_CONVOLUTION_BLUE_SCALE\0" + "GL_POST_CONVOLUTION_BLUE_SCALE_EXT\0" + "GL_POST_CONVOLUTION_COLOR_TABLE\0" + "GL_POST_CONVOLUTION_GREEN_BIAS\0" + "GL_POST_CONVOLUTION_GREEN_BIAS_EXT\0" + "GL_POST_CONVOLUTION_GREEN_SCALE\0" + "GL_POST_CONVOLUTION_GREEN_SCALE_EXT\0" + "GL_POST_CONVOLUTION_RED_BIAS\0" + "GL_POST_CONVOLUTION_RED_BIAS_EXT\0" + "GL_POST_CONVOLUTION_RED_SCALE\0" + "GL_POST_CONVOLUTION_RED_SCALE_EXT\0" + "GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX\0" + "GL_POST_TEXTURE_FILTER_BIAS_SGIX\0" + "GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX\0" + "GL_POST_TEXTURE_FILTER_SCALE_SGIX\0" + "GL_PREVIOUS\0" + "GL_PREVIOUS_ARB\0" + "GL_PREVIOUS_EXT\0" + "GL_PRIMARY_COLOR\0" + "GL_PRIMARY_COLOR_ARB\0" + "GL_PRIMARY_COLOR_EXT\0" + "GL_PRIMITIVES_GENERATED\0" + "GL_PRIMITIVES_GENERATED_EXT\0" + "GL_PRIMITIVE_RESTART\0" + "GL_PRIMITIVE_RESTART_INDEX\0" + "GL_PRIMITIVE_RESTART_INDEX_NV\0" + "GL_PRIMITIVE_RESTART_NV\0" + "GL_PROGRAM_ADDRESS_REGISTERS_ARB\0" + "GL_PROGRAM_ALU_INSTRUCTIONS_ARB\0" + "GL_PROGRAM_ATTRIBS_ARB\0" + "GL_PROGRAM_BINARY_FORMATS\0" + "GL_PROGRAM_BINARY_FORMATS_OES\0" + "GL_PROGRAM_BINARY_LENGTH\0" + "GL_PROGRAM_BINARY_LENGTH_OES\0" + "GL_PROGRAM_BINARY_RETRIEVABLE_HINT\0" + "GL_PROGRAM_BINDING_ARB\0" + "GL_PROGRAM_ERROR_POSITION_ARB\0" + "GL_PROGRAM_ERROR_POSITION_NV\0" + "GL_PROGRAM_ERROR_STRING_ARB\0" + "GL_PROGRAM_FORMAT_ARB\0" + "GL_PROGRAM_FORMAT_ASCII_ARB\0" + "GL_PROGRAM_INSTRUCTIONS_ARB\0" + "GL_PROGRAM_LENGTH_ARB\0" + "GL_PROGRAM_LENGTH_NV\0" + "GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB\0" + "GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB\0" + "GL_PROGRAM_NATIVE_ATTRIBS_ARB\0" + "GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB\0" + "GL_PROGRAM_NATIVE_PARAMETERS_ARB\0" + "GL_PROGRAM_NATIVE_TEMPORARIES_ARB\0" + "GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB\0" + "GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB\0" + "GL_PROGRAM_OBJECT_ARB\0" + "GL_PROGRAM_PARAMETERS_ARB\0" + "GL_PROGRAM_PARAMETER_NV\0" + "GL_PROGRAM_POINT_SIZE\0" + "GL_PROGRAM_POINT_SIZE_ARB\0" + "GL_PROGRAM_RESIDENT_NV\0" + "GL_PROGRAM_STRING_ARB\0" + "GL_PROGRAM_STRING_NV\0" + "GL_PROGRAM_TARGET_NV\0" + "GL_PROGRAM_TEMPORARIES_ARB\0" + "GL_PROGRAM_TEX_INDIRECTIONS_ARB\0" + "GL_PROGRAM_TEX_INSTRUCTIONS_ARB\0" + "GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB\0" + "GL_PROJECTION\0" + "GL_PROJECTION_MATRIX\0" + "GL_PROJECTION_MATRIX_FLOAT_AS_INT_BITS_OES\0" + "GL_PROJECTION_STACK_DEPTH\0" + "GL_PROVOKING_VERTEX\0" + "GL_PROVOKING_VERTEX_EXT\0" + "GL_PROXY_COLOR_TABLE\0" + "GL_PROXY_HISTOGRAM\0" + "GL_PROXY_HISTOGRAM_EXT\0" + "GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE\0" + "GL_PROXY_POST_CONVOLUTION_COLOR_TABLE\0" + "GL_PROXY_TEXTURE_1D\0" + "GL_PROXY_TEXTURE_1D_ARRAY\0" + "GL_PROXY_TEXTURE_1D_ARRAY_EXT\0" + "GL_PROXY_TEXTURE_1D_EXT\0" + "GL_PROXY_TEXTURE_2D\0" + "GL_PROXY_TEXTURE_2D_ARRAY\0" + "GL_PROXY_TEXTURE_2D_ARRAY_EXT\0" + "GL_PROXY_TEXTURE_2D_EXT\0" + "GL_PROXY_TEXTURE_3D\0" + "GL_PROXY_TEXTURE_COLOR_TABLE_SGI\0" + "GL_PROXY_TEXTURE_CUBE_MAP\0" + "GL_PROXY_TEXTURE_CUBE_MAP_ARB\0" + "GL_PROXY_TEXTURE_RECTANGLE\0" + "GL_PROXY_TEXTURE_RECTANGLE_ARB\0" + "GL_PROXY_TEXTURE_RECTANGLE_NV\0" + "GL_PURGEABLE_APPLE\0" + "GL_Q\0" + "GL_QUADRATIC_ATTENUATION\0" + "GL_QUADS\0" + "GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION\0" + "GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT\0" + "GL_QUAD_MESH_SUN\0" + "GL_QUAD_STRIP\0" + "GL_QUERY_BY_REGION_NO_WAIT\0" + "GL_QUERY_BY_REGION_NO_WAIT_NV\0" + "GL_QUERY_BY_REGION_WAIT\0" + "GL_QUERY_BY_REGION_WAIT_NV\0" + "GL_QUERY_COUNTER_BITS\0" + "GL_QUERY_COUNTER_BITS_ARB\0" + "GL_QUERY_NO_WAIT\0" + "GL_QUERY_NO_WAIT_NV\0" + "GL_QUERY_RESULT\0" + "GL_QUERY_RESULT_ARB\0" + "GL_QUERY_RESULT_AVAILABLE\0" + "GL_QUERY_RESULT_AVAILABLE_ARB\0" + "GL_QUERY_WAIT\0" + "GL_QUERY_WAIT_NV\0" + "GL_R\0" + "GL_R11F_G11F_B10F\0" + "GL_R16_SNORM\0" + "GL_R3_G3_B2\0" + "GL_R8_SNORM\0" + "GL_RASTERIZER_DISCARD\0" + "GL_RASTERIZER_DISCARD_EXT\0" + "GL_RASTER_POSITION_UNCLIPPED_IBM\0" + "GL_READ_BUFFER\0" + "GL_READ_FRAMEBUFFER\0" + "GL_READ_FRAMEBUFFER_BINDING\0" + "GL_READ_FRAMEBUFFER_BINDING_EXT\0" + "GL_READ_FRAMEBUFFER_EXT\0" + "GL_READ_ONLY\0" + "GL_READ_ONLY_ARB\0" + "GL_READ_WRITE\0" + "GL_READ_WRITE_ARB\0" + "GL_RED\0" + "GL_REDUCE\0" + "GL_REDUCE_EXT\0" + "GL_RED_BIAS\0" + "GL_RED_BITS\0" + "GL_RED_INTEGER\0" + "GL_RED_INTEGER_EXT\0" + "GL_RED_SCALE\0" + "GL_RED_SNORM\0" + "GL_REFLECTION_MAP\0" + "GL_REFLECTION_MAP_ARB\0" + "GL_REFLECTION_MAP_NV\0" + "GL_REFLECTION_MAP_OES\0" + "GL_RELEASED_APPLE\0" + "GL_RENDER\0" + "GL_RENDERBUFFER\0" + "GL_RENDERBUFFER_ALPHA_SIZE\0" + "GL_RENDERBUFFER_ALPHA_SIZE_OES\0" + "GL_RENDERBUFFER_BINDING\0" + "GL_RENDERBUFFER_BINDING_EXT\0" + "GL_RENDERBUFFER_BINDING_OES\0" + "GL_RENDERBUFFER_BLUE_SIZE\0" + "GL_RENDERBUFFER_BLUE_SIZE_OES\0" + "GL_RENDERBUFFER_DEPTH_SIZE\0" + "GL_RENDERBUFFER_DEPTH_SIZE_OES\0" + "GL_RENDERBUFFER_EXT\0" + "GL_RENDERBUFFER_GREEN_SIZE\0" + "GL_RENDERBUFFER_GREEN_SIZE_OES\0" + "GL_RENDERBUFFER_HEIGHT\0" + "GL_RENDERBUFFER_HEIGHT_EXT\0" + "GL_RENDERBUFFER_HEIGHT_OES\0" + "GL_RENDERBUFFER_INTERNAL_FORMAT\0" + "GL_RENDERBUFFER_INTERNAL_FORMAT_EXT\0" + "GL_RENDERBUFFER_INTERNAL_FORMAT_OES\0" + "GL_RENDERBUFFER_OES\0" + "GL_RENDERBUFFER_RED_SIZE\0" + "GL_RENDERBUFFER_RED_SIZE_OES\0" + "GL_RENDERBUFFER_SAMPLES\0" + "GL_RENDERBUFFER_SAMPLES_EXT\0" + "GL_RENDERBUFFER_STENCIL_SIZE\0" + "GL_RENDERBUFFER_STENCIL_SIZE_OES\0" + "GL_RENDERBUFFER_WIDTH\0" + "GL_RENDERBUFFER_WIDTH_EXT\0" + "GL_RENDERBUFFER_WIDTH_OES\0" + "GL_RENDERER\0" + "GL_RENDER_MODE\0" + "GL_REPEAT\0" + "GL_REPLACE\0" + "GL_REPLACE_EXT\0" + "GL_REPLICATE_BORDER_HP\0" + "GL_RESCALE_NORMAL\0" + "GL_RESCALE_NORMAL_EXT\0" + "GL_RESET_NOTIFICATION_STRATEGY_ARB\0" + "GL_RETAINED_APPLE\0" + "GL_RETURN\0" + "GL_RG16_SNORM\0" + "GL_RG8_SNORM\0" + "GL_RGB\0" + "GL_RGB10\0" + "GL_RGB10_A2\0" + "GL_RGB10_A2_EXT\0" + "GL_RGB10_EXT\0" + "GL_RGB12\0" + "GL_RGB12_EXT\0" + "GL_RGB16\0" + "GL_RGB16F\0" + "GL_RGB16I\0" + "GL_RGB16I_EXT\0" + "GL_RGB16UI\0" + "GL_RGB16UI_EXT\0" + "GL_RGB16_EXT\0" + "GL_RGB16_SNORM\0" + "GL_RGB2_EXT\0" + "GL_RGB32F\0" + "GL_RGB32I\0" + "GL_RGB32I_EXT\0" + "GL_RGB32UI\0" + "GL_RGB32UI_EXT\0" + "GL_RGB4\0" + "GL_RGB4_EXT\0" + "GL_RGB4_S3TC\0" + "GL_RGB5\0" + "GL_RGB565\0" + "GL_RGB565_OES\0" + "GL_RGB5_A1\0" + "GL_RGB5_A1_EXT\0" + "GL_RGB5_A1_OES\0" + "GL_RGB5_EXT\0" + "GL_RGB8\0" + "GL_RGB8I\0" + "GL_RGB8I_EXT\0" + "GL_RGB8UI\0" + "GL_RGB8UI_EXT\0" + "GL_RGB8_EXT\0" + "GL_RGB8_OES\0" + "GL_RGB8_SNORM\0" + "GL_RGB9_E5\0" + "GL_RGBA\0" + "GL_RGBA12\0" + "GL_RGBA12_EXT\0" + "GL_RGBA16\0" + "GL_RGBA16F\0" + "GL_RGBA16I\0" + "GL_RGBA16I_EXT\0" + "GL_RGBA16UI\0" + "GL_RGBA16UI_EXT\0" + "GL_RGBA16_EXT\0" + "GL_RGBA16_SNORM\0" + "GL_RGBA2\0" + "GL_RGBA2_EXT\0" + "GL_RGBA32F\0" + "GL_RGBA32I\0" + "GL_RGBA32I_EXT\0" + "GL_RGBA32UI\0" + "GL_RGBA32UI_EXT\0" + "GL_RGBA4\0" + "GL_RGBA4_DXT5_S3TC\0" + "GL_RGBA4_EXT\0" + "GL_RGBA4_OES\0" + "GL_RGBA4_S3TC\0" + "GL_RGBA8\0" + "GL_RGBA8I\0" + "GL_RGBA8I_EXT\0" + "GL_RGBA8UI\0" + "GL_RGBA8UI_EXT\0" + "GL_RGBA8_EXT\0" + "GL_RGBA8_OES\0" + "GL_RGBA8_SNORM\0" + "GL_RGBA_DXT5_S3TC\0" + "GL_RGBA_FLOAT_MODE_ARB\0" + "GL_RGBA_INTEGER\0" + "GL_RGBA_INTEGER_EXT\0" + "GL_RGBA_INTEGER_MODE_EXT\0" + "GL_RGBA_MODE\0" + "GL_RGBA_S3TC\0" + "GL_RGBA_SNORM\0" + "GL_RGB_INTEGER\0" + "GL_RGB_INTEGER_EXT\0" + "GL_RGB_S3TC\0" + "GL_RGB_SCALE\0" + "GL_RGB_SCALE_ARB\0" + "GL_RGB_SCALE_EXT\0" + "GL_RGB_SNORM\0" + "GL_RG_SNORM\0" + "GL_RIGHT\0" + "GL_S\0" + "GL_SAMPLER_1D\0" + "GL_SAMPLER_1D_ARRAY\0" + "GL_SAMPLER_1D_ARRAY_EXT\0" + "GL_SAMPLER_1D_ARRAY_SHADOW\0" + "GL_SAMPLER_1D_ARRAY_SHADOW_EXT\0" + "GL_SAMPLER_1D_SHADOW\0" + "GL_SAMPLER_2D\0" + "GL_SAMPLER_2D_ARRAY\0" + "GL_SAMPLER_2D_ARRAY_EXT\0" + "GL_SAMPLER_2D_ARRAY_SHADOW\0" + "GL_SAMPLER_2D_ARRAY_SHADOW_EXT\0" + "GL_SAMPLER_2D_RECT\0" + "GL_SAMPLER_2D_RECT_SHADOW\0" + "GL_SAMPLER_2D_SHADOW\0" + "GL_SAMPLER_3D\0" + "GL_SAMPLER_3D_OES\0" + "GL_SAMPLER_BINDING\0" + "GL_SAMPLER_BUFFER\0" + "GL_SAMPLER_BUFFER_EXT\0" + "GL_SAMPLER_CUBE\0" + "GL_SAMPLER_CUBE_SHADOW\0" + "GL_SAMPLER_CUBE_SHADOW_EXT\0" + "GL_SAMPLES\0" + "GL_SAMPLES_3DFX\0" + "GL_SAMPLES_ARB\0" + "GL_SAMPLES_PASSED\0" + "GL_SAMPLES_PASSED_ARB\0" + "GL_SAMPLE_ALPHA_TO_COVERAGE\0" + "GL_SAMPLE_ALPHA_TO_COVERAGE_ARB\0" + "GL_SAMPLE_ALPHA_TO_ONE\0" + "GL_SAMPLE_ALPHA_TO_ONE_ARB\0" + "GL_SAMPLE_BUFFERS\0" + "GL_SAMPLE_BUFFERS_3DFX\0" + "GL_SAMPLE_BUFFERS_ARB\0" + "GL_SAMPLE_COVERAGE\0" + "GL_SAMPLE_COVERAGE_ARB\0" + "GL_SAMPLE_COVERAGE_INVERT\0" + "GL_SAMPLE_COVERAGE_INVERT_ARB\0" + "GL_SAMPLE_COVERAGE_VALUE\0" + "GL_SAMPLE_COVERAGE_VALUE_ARB\0" + "GL_SCISSOR_BIT\0" + "GL_SCISSOR_BOX\0" + "GL_SCISSOR_TEST\0" + "GL_SECONDARY_COLOR_ARRAY\0" + "GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING\0" + "GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB\0" + "GL_SECONDARY_COLOR_ARRAY_POINTER\0" + "GL_SECONDARY_COLOR_ARRAY_SIZE\0" + "GL_SECONDARY_COLOR_ARRAY_STRIDE\0" + "GL_SECONDARY_COLOR_ARRAY_TYPE\0" + "GL_SELECT\0" + "GL_SELECTION_BUFFER_POINTER\0" + "GL_SELECTION_BUFFER_SIZE\0" + "GL_SEPARABLE_2D\0" + "GL_SEPARATE_ATTRIBS\0" + "GL_SEPARATE_ATTRIBS_EXT\0" + "GL_SEPARATE_SPECULAR_COLOR\0" + "GL_SEPARATE_SPECULAR_COLOR_EXT\0" + "GL_SET\0" + "GL_SHADER_BINARY_FORMATS\0" + "GL_SHADER_COMPILER\0" + "GL_SHADER_OBJECT_ARB\0" + "GL_SHADER_SOURCE_LENGTH\0" + "GL_SHADER_TYPE\0" + "GL_SHADE_MODEL\0" + "GL_SHADING_LANGUAGE_VERSION\0" + "GL_SHADOW_AMBIENT_SGIX\0" + "GL_SHARED_TEXTURE_PALETTE_EXT\0" + "GL_SHININESS\0" + "GL_SHORT\0" + "GL_SIGNALED\0" + "GL_SIGNED_NORMALIZED\0" + "GL_SINGLE_COLOR\0" + "GL_SINGLE_COLOR_EXT\0" + "GL_SLICE_ACCUM_SUN\0" + "GL_SLUMINANCE\0" + "GL_SLUMINANCE8\0" + "GL_SLUMINANCE8_ALPHA8\0" + "GL_SLUMINANCE_ALPHA\0" + "GL_SMOOTH\0" + "GL_SMOOTH_LINE_WIDTH_GRANULARITY\0" + "GL_SMOOTH_LINE_WIDTH_RANGE\0" + "GL_SMOOTH_POINT_SIZE_GRANULARITY\0" + "GL_SMOOTH_POINT_SIZE_RANGE\0" + "GL_SOURCE0_ALPHA\0" + "GL_SOURCE0_ALPHA_ARB\0" + "GL_SOURCE0_ALPHA_EXT\0" + "GL_SOURCE0_RGB\0" + "GL_SOURCE0_RGB_ARB\0" + "GL_SOURCE0_RGB_EXT\0" + "GL_SOURCE1_ALPHA\0" + "GL_SOURCE1_ALPHA_ARB\0" + "GL_SOURCE1_ALPHA_EXT\0" + "GL_SOURCE1_RGB\0" + "GL_SOURCE1_RGB_ARB\0" + "GL_SOURCE1_RGB_EXT\0" + "GL_SOURCE2_ALPHA\0" + "GL_SOURCE2_ALPHA_ARB\0" + "GL_SOURCE2_ALPHA_EXT\0" + "GL_SOURCE2_RGB\0" + "GL_SOURCE2_RGB_ARB\0" + "GL_SOURCE2_RGB_EXT\0" + "GL_SOURCE3_ALPHA_NV\0" + "GL_SOURCE3_RGB_NV\0" + "GL_SPECULAR\0" + "GL_SPHERE_MAP\0" + "GL_SPOT_CUTOFF\0" + "GL_SPOT_DIRECTION\0" + "GL_SPOT_EXPONENT\0" + "GL_SRC0_ALPHA\0" + "GL_SRC0_RGB\0" + "GL_SRC1_ALPHA\0" + "GL_SRC1_RGB\0" + "GL_SRC2_ALPHA\0" + "GL_SRC2_RGB\0" + "GL_SRC_ALPHA\0" + "GL_SRC_ALPHA_SATURATE\0" + "GL_SRC_COLOR\0" + "GL_SRGB\0" + "GL_SRGB8\0" + "GL_SRGB8_ALPHA8\0" + "GL_SRGB_ALPHA\0" + "GL_STACK_OVERFLOW\0" + "GL_STACK_UNDERFLOW\0" + "GL_STATIC_COPY\0" + "GL_STATIC_COPY_ARB\0" + "GL_STATIC_DRAW\0" + "GL_STATIC_DRAW_ARB\0" + "GL_STATIC_READ\0" + "GL_STATIC_READ_ARB\0" + "GL_STENCIL\0" + "GL_STENCIL_ATTACHMENT\0" + "GL_STENCIL_ATTACHMENT_EXT\0" + "GL_STENCIL_ATTACHMENT_OES\0" + "GL_STENCIL_BACK_FAIL\0" + "GL_STENCIL_BACK_FAIL_ATI\0" + "GL_STENCIL_BACK_FUNC\0" + "GL_STENCIL_BACK_FUNC_ATI\0" + "GL_STENCIL_BACK_PASS_DEPTH_FAIL\0" + "GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI\0" + "GL_STENCIL_BACK_PASS_DEPTH_PASS\0" + "GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI\0" + "GL_STENCIL_BACK_REF\0" + "GL_STENCIL_BACK_VALUE_MASK\0" + "GL_STENCIL_BACK_WRITEMASK\0" + "GL_STENCIL_BITS\0" + "GL_STENCIL_BUFFER\0" + "GL_STENCIL_BUFFER_BIT\0" + "GL_STENCIL_CLEAR_VALUE\0" + "GL_STENCIL_FAIL\0" + "GL_STENCIL_FUNC\0" + "GL_STENCIL_INDEX\0" + "GL_STENCIL_INDEX1\0" + "GL_STENCIL_INDEX16\0" + "GL_STENCIL_INDEX16_EXT\0" + "GL_STENCIL_INDEX1_EXT\0" + "GL_STENCIL_INDEX1_OES\0" + "GL_STENCIL_INDEX4\0" + "GL_STENCIL_INDEX4_EXT\0" + "GL_STENCIL_INDEX4_OES\0" + "GL_STENCIL_INDEX8\0" + "GL_STENCIL_INDEX8_EXT\0" + "GL_STENCIL_INDEX8_OES\0" + "GL_STENCIL_INDEX_EXT\0" + "GL_STENCIL_PASS_DEPTH_FAIL\0" + "GL_STENCIL_PASS_DEPTH_PASS\0" + "GL_STENCIL_REF\0" + "GL_STENCIL_TEST\0" + "GL_STENCIL_TEST_TWO_SIDE_EXT\0" + "GL_STENCIL_VALUE_MASK\0" + "GL_STENCIL_WRITEMASK\0" + "GL_STEREO\0" + "GL_STORAGE_CACHED_APPLE\0" + "GL_STORAGE_PRIVATE_APPLE\0" + "GL_STORAGE_SHARED_APPLE\0" + "GL_STREAM_COPY\0" + "GL_STREAM_COPY_ARB\0" + "GL_STREAM_DRAW\0" + "GL_STREAM_DRAW_ARB\0" + "GL_STREAM_READ\0" + "GL_STREAM_READ_ARB\0" + "GL_SUBPIXEL_BITS\0" + "GL_SUBTRACT\0" + "GL_SUBTRACT_ARB\0" + "GL_SYNC_CONDITION\0" + "GL_SYNC_FENCE\0" + "GL_SYNC_FLAGS\0" + "GL_SYNC_FLUSH_COMMANDS_BIT\0" + "GL_SYNC_GPU_COMMANDS_COMPLETE\0" + "GL_SYNC_STATUS\0" + "GL_T\0" + "GL_T2F_C3F_V3F\0" + "GL_T2F_C4F_N3F_V3F\0" + "GL_T2F_C4UB_V3F\0" + "GL_T2F_N3F_V3F\0" + "GL_T2F_V3F\0" + "GL_T4F_C4F_N3F_V4F\0" + "GL_T4F_V4F\0" + "GL_TABLE_TOO_LARGE_EXT\0" + "GL_TEXTURE\0" + "GL_TEXTURE0\0" + "GL_TEXTURE0_ARB\0" + "GL_TEXTURE1\0" + "GL_TEXTURE10\0" + "GL_TEXTURE10_ARB\0" + "GL_TEXTURE11\0" + "GL_TEXTURE11_ARB\0" + "GL_TEXTURE12\0" + "GL_TEXTURE12_ARB\0" + "GL_TEXTURE13\0" + "GL_TEXTURE13_ARB\0" + "GL_TEXTURE14\0" + "GL_TEXTURE14_ARB\0" + "GL_TEXTURE15\0" + "GL_TEXTURE15_ARB\0" + "GL_TEXTURE16\0" + "GL_TEXTURE16_ARB\0" + "GL_TEXTURE17\0" + "GL_TEXTURE17_ARB\0" + "GL_TEXTURE18\0" + "GL_TEXTURE18_ARB\0" + "GL_TEXTURE19\0" + "GL_TEXTURE19_ARB\0" + "GL_TEXTURE1_ARB\0" + "GL_TEXTURE2\0" + "GL_TEXTURE20\0" + "GL_TEXTURE20_ARB\0" + "GL_TEXTURE21\0" + "GL_TEXTURE21_ARB\0" + "GL_TEXTURE22\0" + "GL_TEXTURE22_ARB\0" + "GL_TEXTURE23\0" + "GL_TEXTURE23_ARB\0" + "GL_TEXTURE24\0" + "GL_TEXTURE24_ARB\0" + "GL_TEXTURE25\0" + "GL_TEXTURE25_ARB\0" + "GL_TEXTURE26\0" + "GL_TEXTURE26_ARB\0" + "GL_TEXTURE27\0" + "GL_TEXTURE27_ARB\0" + "GL_TEXTURE28\0" + "GL_TEXTURE28_ARB\0" + "GL_TEXTURE29\0" + "GL_TEXTURE29_ARB\0" + "GL_TEXTURE2_ARB\0" + "GL_TEXTURE3\0" + "GL_TEXTURE30\0" + "GL_TEXTURE30_ARB\0" + "GL_TEXTURE31\0" + "GL_TEXTURE31_ARB\0" + "GL_TEXTURE3_ARB\0" + "GL_TEXTURE4\0" + "GL_TEXTURE4_ARB\0" + "GL_TEXTURE5\0" + "GL_TEXTURE5_ARB\0" + "GL_TEXTURE6\0" + "GL_TEXTURE6_ARB\0" + "GL_TEXTURE7\0" + "GL_TEXTURE7_ARB\0" + "GL_TEXTURE8\0" + "GL_TEXTURE8_ARB\0" + "GL_TEXTURE9\0" + "GL_TEXTURE9_ARB\0" + "GL_TEXTURE_1D\0" + "GL_TEXTURE_1D_ARRAY\0" + "GL_TEXTURE_1D_ARRAY_EXT\0" + "GL_TEXTURE_2D\0" + "GL_TEXTURE_2D_ARRAY\0" + "GL_TEXTURE_2D_ARRAY_EXT\0" + "GL_TEXTURE_3D\0" + "GL_TEXTURE_3D_OES\0" + "GL_TEXTURE_ALPHA_SIZE\0" + "GL_TEXTURE_ALPHA_SIZE_EXT\0" + "GL_TEXTURE_BASE_LEVEL\0" + "GL_TEXTURE_BINDING_1D\0" + "GL_TEXTURE_BINDING_1D_ARRAY\0" + "GL_TEXTURE_BINDING_1D_ARRAY_EXT\0" + "GL_TEXTURE_BINDING_2D\0" + "GL_TEXTURE_BINDING_2D_ARRAY\0" + "GL_TEXTURE_BINDING_2D_ARRAY_EXT\0" + "GL_TEXTURE_BINDING_3D\0" + "GL_TEXTURE_BINDING_3D_OES\0" + "GL_TEXTURE_BINDING_BUFFER\0" + "GL_TEXTURE_BINDING_BUFFER_ARB\0" + "GL_TEXTURE_BINDING_CUBE_MAP\0" + "GL_TEXTURE_BINDING_CUBE_MAP_ARB\0" + "GL_TEXTURE_BINDING_CUBE_MAP_OES\0" + "GL_TEXTURE_BINDING_RECTANGLE\0" + "GL_TEXTURE_BINDING_RECTANGLE_ARB\0" + "GL_TEXTURE_BINDING_RECTANGLE_NV\0" + "GL_TEXTURE_BIT\0" + "GL_TEXTURE_BLUE_SIZE\0" + "GL_TEXTURE_BLUE_SIZE_EXT\0" + "GL_TEXTURE_BORDER\0" + "GL_TEXTURE_BORDER_COLOR\0" + "GL_TEXTURE_BUFFER\0" + "GL_TEXTURE_BUFFER_ARB\0" + "GL_TEXTURE_BUFFER_DATA_STORE_BINDING\0" + "GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB\0" + "GL_TEXTURE_BUFFER_FORMAT\0" + "GL_TEXTURE_BUFFER_FORMAT_ARB\0" + "GL_TEXTURE_CLIPMAP_CENTER_SGIX\0" + "GL_TEXTURE_CLIPMAP_DEPTH_SGIX\0" + "GL_TEXTURE_CLIPMAP_FRAME_SGIX\0" + "GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX\0" + "GL_TEXTURE_CLIPMAP_OFFSET_SGIX\0" + "GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX\0" + "GL_TEXTURE_COLOR_TABLE_SGI\0" + "GL_TEXTURE_COLOR_WRITEMASK_SGIS\0" + "GL_TEXTURE_COMPARE_FAIL_VALUE_ARB\0" + "GL_TEXTURE_COMPARE_FUNC\0" + "GL_TEXTURE_COMPARE_FUNC_ARB\0" + "GL_TEXTURE_COMPARE_MODE\0" + "GL_TEXTURE_COMPARE_MODE_ARB\0" + "GL_TEXTURE_COMPARE_OPERATOR_SGIX\0" + "GL_TEXTURE_COMPARE_SGIX\0" + "GL_TEXTURE_COMPONENTS\0" + "GL_TEXTURE_COMPRESSED\0" + "GL_TEXTURE_COMPRESSED_ARB\0" + "GL_TEXTURE_COMPRESSED_FORMATS_ARB\0" + "GL_TEXTURE_COMPRESSED_IMAGE_SIZE\0" + "GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB\0" + "GL_TEXTURE_COMPRESSION_HINT\0" + "GL_TEXTURE_COMPRESSION_HINT_ARB\0" + "GL_TEXTURE_COORD_ARRAY\0" + "GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING\0" + "GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB\0" + "GL_TEXTURE_COORD_ARRAY_POINTER\0" + "GL_TEXTURE_COORD_ARRAY_SIZE\0" + "GL_TEXTURE_COORD_ARRAY_STRIDE\0" + "GL_TEXTURE_COORD_ARRAY_TYPE\0" + "GL_TEXTURE_CROP_RECT_OES\0" + "GL_TEXTURE_CUBE_MAP\0" + "GL_TEXTURE_CUBE_MAP_ARB\0" + "GL_TEXTURE_CUBE_MAP_NEGATIVE_X\0" + "GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB\0" + "GL_TEXTURE_CUBE_MAP_NEGATIVE_X_OES\0" + "GL_TEXTURE_CUBE_MAP_NEGATIVE_Y\0" + "GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB\0" + "GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_OES\0" + "GL_TEXTURE_CUBE_MAP_NEGATIVE_Z\0" + "GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB\0" + "GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_OES\0" + "GL_TEXTURE_CUBE_MAP_OES\0" + "GL_TEXTURE_CUBE_MAP_POSITIVE_X\0" + "GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB\0" + "GL_TEXTURE_CUBE_MAP_POSITIVE_X_OES\0" + "GL_TEXTURE_CUBE_MAP_POSITIVE_Y\0" + "GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB\0" + "GL_TEXTURE_CUBE_MAP_POSITIVE_Y_OES\0" + "GL_TEXTURE_CUBE_MAP_POSITIVE_Z\0" + "GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB\0" + "GL_TEXTURE_CUBE_MAP_POSITIVE_Z_OES\0" + "GL_TEXTURE_CUBE_MAP_SEAMLESS\0" + "GL_TEXTURE_DEPTH\0" + "GL_TEXTURE_DEPTH_SIZE\0" + "GL_TEXTURE_DEPTH_SIZE_ARB\0" + "GL_TEXTURE_ENV\0" + "GL_TEXTURE_ENV_COLOR\0" + "GL_TEXTURE_ENV_MODE\0" + "GL_TEXTURE_FILTER_CONTROL\0" + "GL_TEXTURE_FILTER_CONTROL_EXT\0" + "GL_TEXTURE_GEN_MODE\0" + "GL_TEXTURE_GEN_MODE_OES\0" + "GL_TEXTURE_GEN_Q\0" + "GL_TEXTURE_GEN_R\0" + "GL_TEXTURE_GEN_S\0" + "GL_TEXTURE_GEN_STR_OES\0" + "GL_TEXTURE_GEN_T\0" + "GL_TEXTURE_GEQUAL_R_SGIX\0" + "GL_TEXTURE_GREEN_SIZE\0" + "GL_TEXTURE_GREEN_SIZE_EXT\0" + "GL_TEXTURE_HEIGHT\0" + "GL_TEXTURE_INDEX_SIZE_EXT\0" + "GL_TEXTURE_INTENSITY_SIZE\0" + "GL_TEXTURE_INTENSITY_SIZE_EXT\0" + "GL_TEXTURE_INTERNAL_FORMAT\0" + "GL_TEXTURE_LEQUAL_R_SGIX\0" + "GL_TEXTURE_LOD_BIAS\0" + "GL_TEXTURE_LOD_BIAS_EXT\0" + "GL_TEXTURE_LOD_BIAS_R_SGIX\0" + "GL_TEXTURE_LOD_BIAS_S_SGIX\0" + "GL_TEXTURE_LOD_BIAS_T_SGIX\0" + "GL_TEXTURE_LUMINANCE_SIZE\0" + "GL_TEXTURE_LUMINANCE_SIZE_EXT\0" + "GL_TEXTURE_MAG_FILTER\0" + "GL_TEXTURE_MATRIX\0" + "GL_TEXTURE_MATRIX_FLOAT_AS_INT_BITS_OES\0" + "GL_TEXTURE_MAX_ANISOTROPY_EXT\0" + "GL_TEXTURE_MAX_CLAMP_R_SGIX\0" + "GL_TEXTURE_MAX_CLAMP_S_SGIX\0" + "GL_TEXTURE_MAX_CLAMP_T_SGIX\0" + "GL_TEXTURE_MAX_LEVEL\0" + "GL_TEXTURE_MAX_LOD\0" + "GL_TEXTURE_MIN_FILTER\0" + "GL_TEXTURE_MIN_LOD\0" + "GL_TEXTURE_PRIORITY\0" + "GL_TEXTURE_RANGE_LENGTH_APPLE\0" + "GL_TEXTURE_RANGE_POINTER_APPLE\0" + "GL_TEXTURE_RECTANGLE\0" + "GL_TEXTURE_RECTANGLE_ARB\0" + "GL_TEXTURE_RECTANGLE_NV\0" + "GL_TEXTURE_RED_SIZE\0" + "GL_TEXTURE_RED_SIZE_EXT\0" + "GL_TEXTURE_RESIDENT\0" + "GL_TEXTURE_SHARED_SIZE\0" + "GL_TEXTURE_STACK_DEPTH\0" + "GL_TEXTURE_STENCIL_SIZE\0" + "GL_TEXTURE_STENCIL_SIZE_EXT\0" + "GL_TEXTURE_STORAGE_HINT_APPLE\0" + "GL_TEXTURE_TOO_LARGE_EXT\0" + "GL_TEXTURE_UNSIGNED_REMAP_MODE_NV\0" + "GL_TEXTURE_WIDTH\0" + "GL_TEXTURE_WRAP_R\0" + "GL_TEXTURE_WRAP_R_OES\0" + "GL_TEXTURE_WRAP_S\0" + "GL_TEXTURE_WRAP_T\0" + "GL_TIMEOUT_EXPIRED\0" + "GL_TIME_ELAPSED_EXT\0" + "GL_TRACK_MATRIX_NV\0" + "GL_TRACK_MATRIX_TRANSFORM_NV\0" + "GL_TRANSFORM_BIT\0" + "GL_TRANSFORM_FEEDBACK\0" + "GL_TRANSFORM_FEEDBACK_BINDING\0" + "GL_TRANSFORM_FEEDBACK_BUFFER\0" + "GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE\0" + "GL_TRANSFORM_FEEDBACK_BUFFER_BINDING\0" + "GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_EXT\0" + "GL_TRANSFORM_FEEDBACK_BUFFER_EXT\0" + "GL_TRANSFORM_FEEDBACK_BUFFER_MODE\0" + "GL_TRANSFORM_FEEDBACK_BUFFER_MODE_EXT\0" + "GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED\0" + "GL_TRANSFORM_FEEDBACK_BUFFER_SIZE\0" + "GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_EXT\0" + "GL_TRANSFORM_FEEDBACK_BUFFER_START\0" + "GL_TRANSFORM_FEEDBACK_BUFFER_START_EXT\0" + "GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN\0" + "GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_EXT\0" + "GL_TRANSFORM_FEEDBACK_VARYINGS\0" + "GL_TRANSFORM_FEEDBACK_VARYINGS_EXT\0" + "GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH\0" + "GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH_EXT\0" + "GL_TRANSPOSE_COLOR_MATRIX\0" + "GL_TRANSPOSE_COLOR_MATRIX_ARB\0" + "GL_TRANSPOSE_CURRENT_MATRIX_ARB\0" + "GL_TRANSPOSE_MODELVIEW_MATRIX\0" + "GL_TRANSPOSE_MODELVIEW_MATRIX_ARB\0" + "GL_TRANSPOSE_NV\0" + "GL_TRANSPOSE_PROJECTION_MATRIX\0" + "GL_TRANSPOSE_PROJECTION_MATRIX_ARB\0" + "GL_TRANSPOSE_TEXTURE_MATRIX\0" + "GL_TRANSPOSE_TEXTURE_MATRIX_ARB\0" + "GL_TRIANGLES\0" + "GL_TRIANGLES_ADJACENCY\0" + "GL_TRIANGLES_ADJACENCY_ARB\0" + "GL_TRIANGLE_FAN\0" + "GL_TRIANGLE_MESH_SUN\0" + "GL_TRIANGLE_STRIP\0" + "GL_TRIANGLE_STRIP_ADJACENCY\0" + "GL_TRIANGLE_STRIP_ADJACENCY_ARB\0" + "GL_TRUE\0" + "GL_UNDEFINED_APPLE\0" + "GL_UNKNOWN_CONTEXT_RESET_ARB\0" + "GL_UNPACK_ALIGNMENT\0" + "GL_UNPACK_IMAGE_HEIGHT\0" + "GL_UNPACK_LSB_FIRST\0" + "GL_UNPACK_ROW_LENGTH\0" + "GL_UNPACK_SKIP_IMAGES\0" + "GL_UNPACK_SKIP_PIXELS\0" + "GL_UNPACK_SKIP_ROWS\0" + "GL_UNPACK_SWAP_BYTES\0" + "GL_UNSIGNALED\0" + "GL_UNSIGNED_BYTE\0" + "GL_UNSIGNED_BYTE_2_3_3_REV\0" + "GL_UNSIGNED_BYTE_3_3_2\0" + "GL_UNSIGNED_INT\0" + "GL_UNSIGNED_INT_10F_11F_11F_REV\0" + "GL_UNSIGNED_INT_10_10_10_2\0" + "GL_UNSIGNED_INT_10_10_10_2_OES\0" + "GL_UNSIGNED_INT_24_8\0" + "GL_UNSIGNED_INT_24_8_EXT\0" + "GL_UNSIGNED_INT_24_8_NV\0" + "GL_UNSIGNED_INT_24_8_OES\0" + "GL_UNSIGNED_INT_2_10_10_10_REV\0" + "GL_UNSIGNED_INT_2_10_10_10_REV_EXT\0" + "GL_UNSIGNED_INT_5_9_9_9_REV\0" + "GL_UNSIGNED_INT_8_8_8_8\0" + "GL_UNSIGNED_INT_8_8_8_8_REV\0" + "GL_UNSIGNED_INT_SAMPLER_1D\0" + "GL_UNSIGNED_INT_SAMPLER_1D_ARRAY\0" + "GL_UNSIGNED_INT_SAMPLER_1D_ARRAY_EXT\0" + "GL_UNSIGNED_INT_SAMPLER_1D_EXT\0" + "GL_UNSIGNED_INT_SAMPLER_2D\0" + "GL_UNSIGNED_INT_SAMPLER_2D_ARRAY\0" + "GL_UNSIGNED_INT_SAMPLER_2D_ARRAY_EXT\0" + "GL_UNSIGNED_INT_SAMPLER_2D_EXT\0" + "GL_UNSIGNED_INT_SAMPLER_2D_RECT\0" + "GL_UNSIGNED_INT_SAMPLER_2D_RECT_EXT\0" + "GL_UNSIGNED_INT_SAMPLER_3D\0" + "GL_UNSIGNED_INT_SAMPLER_3D_EXT\0" + "GL_UNSIGNED_INT_SAMPLER_BUFFER\0" + "GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT\0" + "GL_UNSIGNED_INT_SAMPLER_CUBE\0" + "GL_UNSIGNED_INT_SAMPLER_CUBE_EXT\0" + "GL_UNSIGNED_INT_VEC2\0" + "GL_UNSIGNED_INT_VEC2_EXT\0" + "GL_UNSIGNED_INT_VEC3\0" + "GL_UNSIGNED_INT_VEC3_EXT\0" + "GL_UNSIGNED_INT_VEC4\0" + "GL_UNSIGNED_INT_VEC4_EXT\0" + "GL_UNSIGNED_NORMALIZED\0" + "GL_UNSIGNED_SHORT\0" + "GL_UNSIGNED_SHORT_1_5_5_5_REV\0" + "GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT\0" + "GL_UNSIGNED_SHORT_4_4_4_4\0" + "GL_UNSIGNED_SHORT_4_4_4_4_REV\0" + "GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT\0" + "GL_UNSIGNED_SHORT_5_5_5_1\0" + "GL_UNSIGNED_SHORT_5_6_5\0" + "GL_UNSIGNED_SHORT_5_6_5_REV\0" + "GL_UNSIGNED_SHORT_8_8_APPLE\0" + "GL_UNSIGNED_SHORT_8_8_MESA\0" + "GL_UNSIGNED_SHORT_8_8_REV_APPLE\0" + "GL_UNSIGNED_SHORT_8_8_REV_MESA\0" + "GL_UPPER_LEFT\0" + "GL_V2F\0" + "GL_V3F\0" + "GL_VALIDATE_STATUS\0" + "GL_VENDOR\0" + "GL_VERSION\0" + "GL_VERTEX_ARRAY\0" + "GL_VERTEX_ARRAY_BINDING\0" + "GL_VERTEX_ARRAY_BINDING_APPLE\0" + "GL_VERTEX_ARRAY_BUFFER_BINDING\0" + "GL_VERTEX_ARRAY_BUFFER_BINDING_ARB\0" + "GL_VERTEX_ARRAY_POINTER\0" + "GL_VERTEX_ARRAY_SIZE\0" + "GL_VERTEX_ARRAY_STRIDE\0" + "GL_VERTEX_ARRAY_TYPE\0" + "GL_VERTEX_ATTRIB_ARRAY0_NV\0" + "GL_VERTEX_ATTRIB_ARRAY10_NV\0" + "GL_VERTEX_ATTRIB_ARRAY11_NV\0" + "GL_VERTEX_ATTRIB_ARRAY12_NV\0" + "GL_VERTEX_ATTRIB_ARRAY13_NV\0" + "GL_VERTEX_ATTRIB_ARRAY14_NV\0" + "GL_VERTEX_ATTRIB_ARRAY15_NV\0" + "GL_VERTEX_ATTRIB_ARRAY1_NV\0" + "GL_VERTEX_ATTRIB_ARRAY2_NV\0" + "GL_VERTEX_ATTRIB_ARRAY3_NV\0" + "GL_VERTEX_ATTRIB_ARRAY4_NV\0" + "GL_VERTEX_ATTRIB_ARRAY5_NV\0" + "GL_VERTEX_ATTRIB_ARRAY6_NV\0" + "GL_VERTEX_ATTRIB_ARRAY7_NV\0" + "GL_VERTEX_ATTRIB_ARRAY8_NV\0" + "GL_VERTEX_ATTRIB_ARRAY9_NV\0" + "GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING\0" + "GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB\0" + "GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB\0" + "GL_VERTEX_ATTRIB_ARRAY_ENABLED\0" + "GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB\0" + "GL_VERTEX_ATTRIB_ARRAY_INTEGER\0" + "GL_VERTEX_ATTRIB_ARRAY_INTEGER_EXT\0" + "GL_VERTEX_ATTRIB_ARRAY_NORMALIZED\0" + "GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB\0" + "GL_VERTEX_ATTRIB_ARRAY_POINTER\0" + "GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB\0" + "GL_VERTEX_ATTRIB_ARRAY_SIZE\0" + "GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB\0" + "GL_VERTEX_ATTRIB_ARRAY_STRIDE\0" + "GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB\0" + "GL_VERTEX_ATTRIB_ARRAY_TYPE\0" + "GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB\0" + "GL_VERTEX_BLEND_ARB\0" + "GL_VERTEX_PROGRAM_ARB\0" + "GL_VERTEX_PROGRAM_BINDING_NV\0" + "GL_VERTEX_PROGRAM_NV\0" + "GL_VERTEX_PROGRAM_POINT_SIZE\0" + "GL_VERTEX_PROGRAM_POINT_SIZE_ARB\0" + "GL_VERTEX_PROGRAM_POINT_SIZE_NV\0" + "GL_VERTEX_PROGRAM_TWO_SIDE\0" + "GL_VERTEX_PROGRAM_TWO_SIDE_ARB\0" + "GL_VERTEX_PROGRAM_TWO_SIDE_NV\0" + "GL_VERTEX_SHADER\0" + "GL_VERTEX_SHADER_ARB\0" + "GL_VERTEX_STATE_PROGRAM_NV\0" + "GL_VIEWPORT\0" + "GL_VIEWPORT_BIT\0" + "GL_VOLATILE_APPLE\0" + "GL_WAIT_FAILED\0" + "GL_WEIGHT_ARRAY_ARB\0" + "GL_WEIGHT_ARRAY_BUFFER_BINDING\0" + "GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB\0" + "GL_WEIGHT_ARRAY_BUFFER_BINDING_OES\0" + "GL_WEIGHT_ARRAY_OES\0" + "GL_WEIGHT_ARRAY_POINTER_ARB\0" + "GL_WEIGHT_ARRAY_POINTER_OES\0" + "GL_WEIGHT_ARRAY_SIZE_ARB\0" + "GL_WEIGHT_ARRAY_SIZE_OES\0" + "GL_WEIGHT_ARRAY_STRIDE_ARB\0" + "GL_WEIGHT_ARRAY_STRIDE_OES\0" + "GL_WEIGHT_ARRAY_TYPE_ARB\0" + "GL_WEIGHT_ARRAY_TYPE_OES\0" + "GL_WEIGHT_SUM_UNITY_ARB\0" + "GL_WRAP_BORDER_SUN\0" + "GL_WRITE_ONLY\0" + "GL_WRITE_ONLY_ARB\0" + "GL_WRITE_ONLY_OES\0" + "GL_XOR\0" + "GL_YCBCR_422_APPLE\0" + "GL_YCBCR_MESA\0" + "GL_ZERO\0" + "GL_ZOOM_X\0" + "GL_ZOOM_Y\0" + ; + +static const enum_elt all_enums[2318] = +{ + { 0, 0x00000600 }, /* GL_2D */ + { 6, 0x00001407 }, /* GL_2_BYTES */ + { 17, 0x00000601 }, /* GL_3D */ + { 23, 0x00000602 }, /* GL_3D_COLOR */ + { 35, 0x00000603 }, /* GL_3D_COLOR_TEXTURE */ + { 55, 0x00001408 }, /* GL_3_BYTES */ + { 66, 0x00000604 }, /* GL_4D_COLOR_TEXTURE */ + { 86, 0x00001409 }, /* GL_4_BYTES */ + { 97, 0x00000100 }, /* GL_ACCUM */ + { 106, 0x00000D5B }, /* GL_ACCUM_ALPHA_BITS */ + { 126, 0x00000D5A }, /* GL_ACCUM_BLUE_BITS */ + { 145, 0x00000200 }, /* GL_ACCUM_BUFFER_BIT */ + { 165, 0x00000B80 }, /* GL_ACCUM_CLEAR_VALUE */ + { 186, 0x00000D59 }, /* GL_ACCUM_GREEN_BITS */ + { 206, 0x00000D58 }, /* GL_ACCUM_RED_BITS */ + { 224, 0x00008B89 }, /* GL_ACTIVE_ATTRIBUTES */ + { 245, 0x00008B8A }, /* GL_ACTIVE_ATTRIBUTE_MAX_LENGTH */ + { 276, 0x00008B8D }, /* GL_ACTIVE_PROGRAM_EXT */ + { 298, 0x00008911 }, /* GL_ACTIVE_STENCIL_FACE_EXT */ + { 325, 0x000084E0 }, /* GL_ACTIVE_TEXTURE */ + { 343, 0x000084E0 }, /* GL_ACTIVE_TEXTURE_ARB */ + { 365, 0x00008B86 }, /* GL_ACTIVE_UNIFORMS */ + { 384, 0x00008B87 }, /* GL_ACTIVE_UNIFORM_MAX_LENGTH */ + { 413, 0x000086A5 }, /* GL_ACTIVE_VERTEX_UNITS_ARB */ + { 440, 0x00000104 }, /* GL_ADD */ + { 447, 0x00008574 }, /* GL_ADD_SIGNED */ + { 461, 0x00008574 }, /* GL_ADD_SIGNED_ARB */ + { 479, 0x00008574 }, /* GL_ADD_SIGNED_EXT */ + { 497, 0x0000846E }, /* GL_ALIASED_LINE_WIDTH_RANGE */ + { 525, 0x0000846D }, /* GL_ALIASED_POINT_SIZE_RANGE */ + { 553, 0x000FFFFF }, /* GL_ALL_ATTRIB_BITS */ + { 572, 0xFFFFFFFF }, /* GL_ALL_CLIENT_ATTRIB_BITS */ + { 598, 0x00001906 }, /* GL_ALPHA */ + { 607, 0x0000803D }, /* GL_ALPHA12 */ + { 618, 0x0000803D }, /* GL_ALPHA12_EXT */ + { 633, 0x0000803E }, /* GL_ALPHA16 */ + { 644, 0x00008D8A }, /* GL_ALPHA16I_EXT */ + { 660, 0x00008D78 }, /* GL_ALPHA16UI_EXT */ + { 677, 0x0000803E }, /* GL_ALPHA16_EXT */ + { 692, 0x00008D84 }, /* GL_ALPHA32I_EXT */ + { 708, 0x00008D72 }, /* GL_ALPHA32UI_EXT */ + { 725, 0x0000803B }, /* GL_ALPHA4 */ + { 735, 0x0000803B }, /* GL_ALPHA4_EXT */ + { 749, 0x0000803C }, /* GL_ALPHA8 */ + { 759, 0x00008D90 }, /* GL_ALPHA8I_EXT */ + { 774, 0x00008D7E }, /* GL_ALPHA8UI_EXT */ + { 790, 0x0000803C }, /* GL_ALPHA8_EXT */ + { 804, 0x00000D1D }, /* GL_ALPHA_BIAS */ + { 818, 0x00000D55 }, /* GL_ALPHA_BITS */ + { 832, 0x00008D97 }, /* GL_ALPHA_INTEGER_EXT */ + { 853, 0x00000D1C }, /* GL_ALPHA_SCALE */ + { 868, 0x00000BC0 }, /* GL_ALPHA_TEST */ + { 882, 0x00000BC1 }, /* GL_ALPHA_TEST_FUNC */ + { 901, 0x00000BC2 }, /* GL_ALPHA_TEST_REF */ + { 919, 0x0000911A }, /* GL_ALREADY_SIGNALED */ + { 939, 0x00000207 }, /* GL_ALWAYS */ + { 949, 0x00001200 }, /* GL_AMBIENT */ + { 960, 0x00001602 }, /* GL_AMBIENT_AND_DIFFUSE */ + { 983, 0x00001501 }, /* GL_AND */ + { 990, 0x00001504 }, /* GL_AND_INVERTED */ + { 1006, 0x00001502 }, /* GL_AND_REVERSE */ + { 1021, 0x00008892 }, /* GL_ARRAY_BUFFER */ + { 1037, 0x00008894 }, /* GL_ARRAY_BUFFER_BINDING */ + { 1061, 0x00008894 }, /* GL_ARRAY_BUFFER_BINDING_ARB */ + { 1089, 0x00008B85 }, /* GL_ATTACHED_SHADERS */ + { 1109, 0x00008645 }, /* GL_ATTRIB_ARRAY_POINTER_NV */ + { 1136, 0x00008623 }, /* GL_ATTRIB_ARRAY_SIZE_NV */ + { 1160, 0x00008624 }, /* GL_ATTRIB_ARRAY_STRIDE_NV */ + { 1186, 0x00008625 }, /* GL_ATTRIB_ARRAY_TYPE_NV */ + { 1210, 0x00000BB0 }, /* GL_ATTRIB_STACK_DEPTH */ + { 1232, 0x00000D80 }, /* GL_AUTO_NORMAL */ + { 1247, 0x00000409 }, /* GL_AUX0 */ + { 1255, 0x0000040A }, /* GL_AUX1 */ + { 1263, 0x0000040B }, /* GL_AUX2 */ + { 1271, 0x0000040C }, /* GL_AUX3 */ + { 1279, 0x00000C00 }, /* GL_AUX_BUFFERS */ + { 1294, 0x00000405 }, /* GL_BACK */ + { 1302, 0x00000402 }, /* GL_BACK_LEFT */ + { 1315, 0x00000403 }, /* GL_BACK_RIGHT */ + { 1329, 0x000080E0 }, /* GL_BGR */ + { 1336, 0x000080E1 }, /* GL_BGRA */ + { 1344, 0x000080E1 }, /* GL_BGRA_EXT */ + { 1356, 0x00008D9B }, /* GL_BGRA_INTEGER */ + { 1372, 0x00008D9B }, /* GL_BGRA_INTEGER_EXT */ + { 1392, 0x00008D9A }, /* GL_BGR_INTEGER */ + { 1407, 0x00008D9A }, /* GL_BGR_INTEGER_EXT */ + { 1426, 0x00001A00 }, /* GL_BITMAP */ + { 1436, 0x00000704 }, /* GL_BITMAP_TOKEN */ + { 1452, 0x00000BE2 }, /* GL_BLEND */ + { 1461, 0x00008005 }, /* GL_BLEND_COLOR */ + { 1476, 0x00008005 }, /* GL_BLEND_COLOR_EXT */ + { 1495, 0x00000BE0 }, /* GL_BLEND_DST */ + { 1508, 0x000080CA }, /* GL_BLEND_DST_ALPHA */ + { 1527, 0x000080CA }, /* GL_BLEND_DST_ALPHA_OES */ + { 1550, 0x000080C8 }, /* GL_BLEND_DST_RGB */ + { 1567, 0x000080C8 }, /* GL_BLEND_DST_RGB_OES */ + { 1588, 0x00008009 }, /* GL_BLEND_EQUATION */ + { 1606, 0x0000883D }, /* GL_BLEND_EQUATION_ALPHA */ + { 1630, 0x0000883D }, /* GL_BLEND_EQUATION_ALPHA_EXT */ + { 1658, 0x0000883D }, /* GL_BLEND_EQUATION_ALPHA_OES */ + { 1686, 0x00008009 }, /* GL_BLEND_EQUATION_EXT */ + { 1708, 0x00008009 }, /* GL_BLEND_EQUATION_OES */ + { 1730, 0x00008009 }, /* GL_BLEND_EQUATION_RGB */ + { 1752, 0x00008009 }, /* GL_BLEND_EQUATION_RGB_EXT */ + { 1778, 0x00008009 }, /* GL_BLEND_EQUATION_RGB_OES */ + { 1804, 0x00000BE1 }, /* GL_BLEND_SRC */ + { 1817, 0x000080CB }, /* GL_BLEND_SRC_ALPHA */ + { 1836, 0x000080CB }, /* GL_BLEND_SRC_ALPHA_OES */ + { 1859, 0x000080C9 }, /* GL_BLEND_SRC_RGB */ + { 1876, 0x000080C9 }, /* GL_BLEND_SRC_RGB_OES */ + { 1897, 0x00001905 }, /* GL_BLUE */ + { 1905, 0x00000D1B }, /* GL_BLUE_BIAS */ + { 1918, 0x00000D54 }, /* GL_BLUE_BITS */ + { 1931, 0x00008D96 }, /* GL_BLUE_INTEGER */ + { 1947, 0x00008D96 }, /* GL_BLUE_INTEGER_EXT */ + { 1967, 0x00000D1A }, /* GL_BLUE_SCALE */ + { 1981, 0x00008B56 }, /* GL_BOOL */ + { 1989, 0x00008B56 }, /* GL_BOOL_ARB */ + { 2001, 0x00008B57 }, /* GL_BOOL_VEC2 */ + { 2014, 0x00008B57 }, /* GL_BOOL_VEC2_ARB */ + { 2031, 0x00008B58 }, /* GL_BOOL_VEC3 */ + { 2044, 0x00008B58 }, /* GL_BOOL_VEC3_ARB */ + { 2061, 0x00008B59 }, /* GL_BOOL_VEC4 */ + { 2074, 0x00008B59 }, /* GL_BOOL_VEC4_ARB */ + { 2091, 0x000088BB }, /* GL_BUFFER_ACCESS */ + { 2108, 0x000088BB }, /* GL_BUFFER_ACCESS_ARB */ + { 2129, 0x0000911F }, /* GL_BUFFER_ACCESS_FLAGS */ + { 2152, 0x000088BB }, /* GL_BUFFER_ACCESS_OES */ + { 2173, 0x00008A13 }, /* GL_BUFFER_FLUSHING_UNMAP_APPLE */ + { 2204, 0x000088BC }, /* GL_BUFFER_MAPPED */ + { 2221, 0x000088BC }, /* GL_BUFFER_MAPPED_ARB */ + { 2242, 0x000088BC }, /* GL_BUFFER_MAPPED_OES */ + { 2263, 0x00009120 }, /* GL_BUFFER_MAP_LENGTH */ + { 2284, 0x00009121 }, /* GL_BUFFER_MAP_OFFSET */ + { 2305, 0x000088BD }, /* GL_BUFFER_MAP_POINTER */ + { 2327, 0x000088BD }, /* GL_BUFFER_MAP_POINTER_ARB */ + { 2353, 0x000088BD }, /* GL_BUFFER_MAP_POINTER_OES */ + { 2379, 0x000085B3 }, /* GL_BUFFER_OBJECT_APPLE */ + { 2402, 0x00008A12 }, /* GL_BUFFER_SERIALIZED_MODIFY_APPLE */ + { 2436, 0x00008764 }, /* GL_BUFFER_SIZE */ + { 2451, 0x00008764 }, /* GL_BUFFER_SIZE_ARB */ + { 2470, 0x00008765 }, /* GL_BUFFER_USAGE */ + { 2486, 0x00008765 }, /* GL_BUFFER_USAGE_ARB */ + { 2506, 0x0000877B }, /* GL_BUMP_ENVMAP_ATI */ + { 2525, 0x00008777 }, /* GL_BUMP_NUM_TEX_UNITS_ATI */ + { 2551, 0x00008775 }, /* GL_BUMP_ROT_MATRIX_ATI */ + { 2574, 0x00008776 }, /* GL_BUMP_ROT_MATRIX_SIZE_ATI */ + { 2602, 0x0000877C }, /* GL_BUMP_TARGET_ATI */ + { 2621, 0x00008778 }, /* GL_BUMP_TEX_UNITS_ATI */ + { 2643, 0x00001400 }, /* GL_BYTE */ + { 2651, 0x00002A24 }, /* GL_C3F_V3F */ + { 2662, 0x00002A26 }, /* GL_C4F_N3F_V3F */ + { 2677, 0x00002A22 }, /* GL_C4UB_V2F */ + { 2689, 0x00002A23 }, /* GL_C4UB_V3F */ + { 2701, 0x00000901 }, /* GL_CCW */ + { 2708, 0x00002900 }, /* GL_CLAMP */ + { 2717, 0x0000891B }, /* GL_CLAMP_FRAGMENT_COLOR_ARB */ + { 2745, 0x0000891C }, /* GL_CLAMP_READ_COLOR */ + { 2765, 0x0000891C }, /* GL_CLAMP_READ_COLOR_ARB */ + { 2789, 0x0000812D }, /* GL_CLAMP_TO_BORDER */ + { 2808, 0x0000812D }, /* GL_CLAMP_TO_BORDER_ARB */ + { 2831, 0x0000812D }, /* GL_CLAMP_TO_BORDER_SGIS */ + { 2855, 0x0000812F }, /* GL_CLAMP_TO_EDGE */ + { 2872, 0x0000812F }, /* GL_CLAMP_TO_EDGE_SGIS */ + { 2894, 0x0000891A }, /* GL_CLAMP_VERTEX_COLOR_ARB */ + { 2920, 0x00001500 }, /* GL_CLEAR */ + { 2929, 0x000084E1 }, /* GL_CLIENT_ACTIVE_TEXTURE */ + { 2954, 0x000084E1 }, /* GL_CLIENT_ACTIVE_TEXTURE_ARB */ + { 2983, 0xFFFFFFFF }, /* GL_CLIENT_ALL_ATTRIB_BITS */ + { 3009, 0x00000BB1 }, /* GL_CLIENT_ATTRIB_STACK_DEPTH */ + { 3038, 0x00000001 }, /* GL_CLIENT_PIXEL_STORE_BIT */ + { 3064, 0x00000002 }, /* GL_CLIENT_VERTEX_ARRAY_BIT */ + { 3091, 0x00003000 }, /* GL_CLIP_DISTANCE0 */ + { 3109, 0x00003001 }, /* GL_CLIP_DISTANCE1 */ + { 3127, 0x00003002 }, /* GL_CLIP_DISTANCE2 */ + { 3145, 0x00003003 }, /* GL_CLIP_DISTANCE3 */ + { 3163, 0x00003004 }, /* GL_CLIP_DISTANCE4 */ + { 3181, 0x00003005 }, /* GL_CLIP_DISTANCE5 */ + { 3199, 0x00003006 }, /* GL_CLIP_DISTANCE6 */ + { 3217, 0x00003007 }, /* GL_CLIP_DISTANCE7 */ + { 3235, 0x00003000 }, /* GL_CLIP_PLANE0 */ + { 3250, 0x00003001 }, /* GL_CLIP_PLANE1 */ + { 3265, 0x00003002 }, /* GL_CLIP_PLANE2 */ + { 3280, 0x00003003 }, /* GL_CLIP_PLANE3 */ + { 3295, 0x00003004 }, /* GL_CLIP_PLANE4 */ + { 3310, 0x00003005 }, /* GL_CLIP_PLANE5 */ + { 3325, 0x000080F0 }, /* GL_CLIP_VOLUME_CLIPPING_HINT_EXT */ + { 3358, 0x00000A00 }, /* GL_COEFF */ + { 3367, 0x00001800 }, /* GL_COLOR */ + { 3376, 0x00008076 }, /* GL_COLOR_ARRAY */ + { 3391, 0x00008898 }, /* GL_COLOR_ARRAY_BUFFER_BINDING */ + { 3421, 0x00008898 }, /* GL_COLOR_ARRAY_BUFFER_BINDING_ARB */ + { 3455, 0x00008090 }, /* GL_COLOR_ARRAY_POINTER */ + { 3478, 0x00008081 }, /* GL_COLOR_ARRAY_SIZE */ + { 3498, 0x00008083 }, /* GL_COLOR_ARRAY_STRIDE */ + { 3520, 0x00008082 }, /* GL_COLOR_ARRAY_TYPE */ + { 3540, 0x00008CE0 }, /* GL_COLOR_ATTACHMENT0 */ + { 3561, 0x00008CE0 }, /* GL_COLOR_ATTACHMENT0_EXT */ + { 3586, 0x00008CE0 }, /* GL_COLOR_ATTACHMENT0_OES */ + { 3611, 0x00008CE1 }, /* GL_COLOR_ATTACHMENT1 */ + { 3632, 0x00008CEA }, /* GL_COLOR_ATTACHMENT10 */ + { 3654, 0x00008CEA }, /* GL_COLOR_ATTACHMENT10_EXT */ + { 3680, 0x00008CEB }, /* GL_COLOR_ATTACHMENT11 */ + { 3702, 0x00008CEB }, /* GL_COLOR_ATTACHMENT11_EXT */ + { 3728, 0x00008CEC }, /* GL_COLOR_ATTACHMENT12 */ + { 3750, 0x00008CEC }, /* GL_COLOR_ATTACHMENT12_EXT */ + { 3776, 0x00008CED }, /* GL_COLOR_ATTACHMENT13 */ + { 3798, 0x00008CED }, /* GL_COLOR_ATTACHMENT13_EXT */ + { 3824, 0x00008CEE }, /* GL_COLOR_ATTACHMENT14 */ + { 3846, 0x00008CEE }, /* GL_COLOR_ATTACHMENT14_EXT */ + { 3872, 0x00008CEF }, /* GL_COLOR_ATTACHMENT15 */ + { 3894, 0x00008CEF }, /* GL_COLOR_ATTACHMENT15_EXT */ + { 3920, 0x00008CE1 }, /* GL_COLOR_ATTACHMENT1_EXT */ + { 3945, 0x00008CE2 }, /* GL_COLOR_ATTACHMENT2 */ + { 3966, 0x00008CE2 }, /* GL_COLOR_ATTACHMENT2_EXT */ + { 3991, 0x00008CE3 }, /* GL_COLOR_ATTACHMENT3 */ + { 4012, 0x00008CE3 }, /* GL_COLOR_ATTACHMENT3_EXT */ + { 4037, 0x00008CE4 }, /* GL_COLOR_ATTACHMENT4 */ + { 4058, 0x00008CE4 }, /* GL_COLOR_ATTACHMENT4_EXT */ + { 4083, 0x00008CE5 }, /* GL_COLOR_ATTACHMENT5 */ + { 4104, 0x00008CE5 }, /* GL_COLOR_ATTACHMENT5_EXT */ + { 4129, 0x00008CE6 }, /* GL_COLOR_ATTACHMENT6 */ + { 4150, 0x00008CE6 }, /* GL_COLOR_ATTACHMENT6_EXT */ + { 4175, 0x00008CE7 }, /* GL_COLOR_ATTACHMENT7 */ + { 4196, 0x00008CE7 }, /* GL_COLOR_ATTACHMENT7_EXT */ + { 4221, 0x00008CE8 }, /* GL_COLOR_ATTACHMENT8 */ + { 4242, 0x00008CE8 }, /* GL_COLOR_ATTACHMENT8_EXT */ + { 4267, 0x00008CE9 }, /* GL_COLOR_ATTACHMENT9 */ + { 4288, 0x00008CE9 }, /* GL_COLOR_ATTACHMENT9_EXT */ + { 4313, 0x00004000 }, /* GL_COLOR_BUFFER_BIT */ + { 4333, 0x00000C22 }, /* GL_COLOR_CLEAR_VALUE */ + { 4354, 0x00001900 }, /* GL_COLOR_INDEX */ + { 4369, 0x00001603 }, /* GL_COLOR_INDEXES */ + { 4386, 0x00000BF2 }, /* GL_COLOR_LOGIC_OP */ + { 4404, 0x00000B57 }, /* GL_COLOR_MATERIAL */ + { 4422, 0x00000B55 }, /* GL_COLOR_MATERIAL_FACE */ + { 4445, 0x00000B56 }, /* GL_COLOR_MATERIAL_PARAMETER */ + { 4473, 0x000080B1 }, /* GL_COLOR_MATRIX */ + { 4489, 0x000080B1 }, /* GL_COLOR_MATRIX_SGI */ + { 4509, 0x000080B2 }, /* GL_COLOR_MATRIX_STACK_DEPTH */ + { 4537, 0x000080B2 }, /* GL_COLOR_MATRIX_STACK_DEPTH_SGI */ + { 4569, 0x00008458 }, /* GL_COLOR_SUM */ + { 4582, 0x00008458 }, /* GL_COLOR_SUM_ARB */ + { 4599, 0x000080D0 }, /* GL_COLOR_TABLE */ + { 4614, 0x000080DD }, /* GL_COLOR_TABLE_ALPHA_SIZE */ + { 4640, 0x000080DD }, /* GL_COLOR_TABLE_ALPHA_SIZE_EXT */ + { 4670, 0x000080DD }, /* GL_COLOR_TABLE_ALPHA_SIZE_SGI */ + { 4700, 0x000080D7 }, /* GL_COLOR_TABLE_BIAS */ + { 4720, 0x000080D7 }, /* GL_COLOR_TABLE_BIAS_SGI */ + { 4744, 0x000080DC }, /* GL_COLOR_TABLE_BLUE_SIZE */ + { 4769, 0x000080DC }, /* GL_COLOR_TABLE_BLUE_SIZE_EXT */ + { 4798, 0x000080DC }, /* GL_COLOR_TABLE_BLUE_SIZE_SGI */ + { 4827, 0x000080D8 }, /* GL_COLOR_TABLE_FORMAT */ + { 4849, 0x000080D8 }, /* GL_COLOR_TABLE_FORMAT_EXT */ + { 4875, 0x000080D8 }, /* GL_COLOR_TABLE_FORMAT_SGI */ + { 4901, 0x000080DB }, /* GL_COLOR_TABLE_GREEN_SIZE */ + { 4927, 0x000080DB }, /* GL_COLOR_TABLE_GREEN_SIZE_EXT */ + { 4957, 0x000080DB }, /* GL_COLOR_TABLE_GREEN_SIZE_SGI */ + { 4987, 0x000080DF }, /* GL_COLOR_TABLE_INTENSITY_SIZE */ + { 5017, 0x000080DF }, /* GL_COLOR_TABLE_INTENSITY_SIZE_EXT */ + { 5051, 0x000080DF }, /* GL_COLOR_TABLE_INTENSITY_SIZE_SGI */ + { 5085, 0x000080DE }, /* GL_COLOR_TABLE_LUMINANCE_SIZE */ + { 5115, 0x000080DE }, /* GL_COLOR_TABLE_LUMINANCE_SIZE_EXT */ + { 5149, 0x000080DE }, /* GL_COLOR_TABLE_LUMINANCE_SIZE_SGI */ + { 5183, 0x000080DA }, /* GL_COLOR_TABLE_RED_SIZE */ + { 5207, 0x000080DA }, /* GL_COLOR_TABLE_RED_SIZE_EXT */ + { 5235, 0x000080DA }, /* GL_COLOR_TABLE_RED_SIZE_SGI */ + { 5263, 0x000080D6 }, /* GL_COLOR_TABLE_SCALE */ + { 5284, 0x000080D6 }, /* GL_COLOR_TABLE_SCALE_SGI */ + { 5309, 0x000080D9 }, /* GL_COLOR_TABLE_WIDTH */ + { 5330, 0x000080D9 }, /* GL_COLOR_TABLE_WIDTH_EXT */ + { 5355, 0x000080D9 }, /* GL_COLOR_TABLE_WIDTH_SGI */ + { 5380, 0x00000C23 }, /* GL_COLOR_WRITEMASK */ + { 5399, 0x00008570 }, /* GL_COMBINE */ + { 5410, 0x00008503 }, /* GL_COMBINE4 */ + { 5422, 0x00008572 }, /* GL_COMBINE_ALPHA */ + { 5439, 0x00008572 }, /* GL_COMBINE_ALPHA_ARB */ + { 5460, 0x00008572 }, /* GL_COMBINE_ALPHA_EXT */ + { 5481, 0x00008570 }, /* GL_COMBINE_ARB */ + { 5496, 0x00008570 }, /* GL_COMBINE_EXT */ + { 5511, 0x00008571 }, /* GL_COMBINE_RGB */ + { 5526, 0x00008571 }, /* GL_COMBINE_RGB_ARB */ + { 5545, 0x00008571 }, /* GL_COMBINE_RGB_EXT */ + { 5564, 0x0000884E }, /* GL_COMPARE_REF_DEPTH_TO_TEXTURE_EXT */ + { 5600, 0x0000884E }, /* GL_COMPARE_REF_TO_TEXTURE */ + { 5626, 0x0000884E }, /* GL_COMPARE_R_TO_TEXTURE */ + { 5650, 0x0000884E }, /* GL_COMPARE_R_TO_TEXTURE_ARB */ + { 5678, 0x00001300 }, /* GL_COMPILE */ + { 5689, 0x00001301 }, /* GL_COMPILE_AND_EXECUTE */ + { 5712, 0x00008B81 }, /* GL_COMPILE_STATUS */ + { 5730, 0x000084E9 }, /* GL_COMPRESSED_ALPHA */ + { 5750, 0x000084E9 }, /* GL_COMPRESSED_ALPHA_ARB */ + { 5774, 0x000084EC }, /* GL_COMPRESSED_INTENSITY */ + { 5798, 0x000084EC }, /* GL_COMPRESSED_INTENSITY_ARB */ + { 5826, 0x000084EA }, /* GL_COMPRESSED_LUMINANCE */ + { 5850, 0x000084EB }, /* GL_COMPRESSED_LUMINANCE_ALPHA */ + { 5880, 0x000084EB }, /* GL_COMPRESSED_LUMINANCE_ALPHA_ARB */ + { 5914, 0x000084EA }, /* GL_COMPRESSED_LUMINANCE_ARB */ + { 5942, 0x00008225 }, /* GL_COMPRESSED_RED */ + { 5960, 0x00008226 }, /* GL_COMPRESSED_RG */ + { 5977, 0x000084ED }, /* GL_COMPRESSED_RGB */ + { 5995, 0x000084EE }, /* GL_COMPRESSED_RGBA */ + { 6014, 0x000084EE }, /* GL_COMPRESSED_RGBA_ARB */ + { 6037, 0x000086B1 }, /* GL_COMPRESSED_RGBA_FXT1_3DFX */ + { 6066, 0x000083F1 }, /* GL_COMPRESSED_RGBA_S3TC_DXT1_EXT */ + { 6099, 0x000083F2 }, /* GL_COMPRESSED_RGBA_S3TC_DXT3_EXT */ + { 6132, 0x000083F3 }, /* GL_COMPRESSED_RGBA_S3TC_DXT5_EXT */ + { 6165, 0x000084ED }, /* GL_COMPRESSED_RGB_ARB */ + { 6187, 0x000086B0 }, /* GL_COMPRESSED_RGB_FXT1_3DFX */ + { 6215, 0x000083F0 }, /* GL_COMPRESSED_RGB_S3TC_DXT1_EXT */ + { 6247, 0x00008C4A }, /* GL_COMPRESSED_SLUMINANCE */ + { 6272, 0x00008C4B }, /* GL_COMPRESSED_SLUMINANCE_ALPHA */ + { 6303, 0x00008C48 }, /* GL_COMPRESSED_SRGB */ + { 6322, 0x00008C49 }, /* GL_COMPRESSED_SRGB_ALPHA */ + { 6347, 0x000086A3 }, /* GL_COMPRESSED_TEXTURE_FORMATS */ + { 6377, 0x0000911C }, /* GL_CONDITION_SATISFIED */ + { 6400, 0x00008576 }, /* GL_CONSTANT */ + { 6412, 0x00008003 }, /* GL_CONSTANT_ALPHA */ + { 6430, 0x00008003 }, /* GL_CONSTANT_ALPHA_EXT */ + { 6452, 0x00008576 }, /* GL_CONSTANT_ARB */ + { 6468, 0x00001207 }, /* GL_CONSTANT_ATTENUATION */ + { 6492, 0x00008151 }, /* GL_CONSTANT_BORDER_HP */ + { 6514, 0x00008001 }, /* GL_CONSTANT_COLOR */ + { 6532, 0x00008001 }, /* GL_CONSTANT_COLOR_EXT */ + { 6554, 0x00008576 }, /* GL_CONSTANT_EXT */ + { 6570, 0x00000002 }, /* GL_CONTEXT_COMPATIBILITY_PROFILE_BIT */ + { 6607, 0x00000001 }, /* GL_CONTEXT_CORE_PROFILE_BIT */ + { 6635, 0x0000821E }, /* GL_CONTEXT_FLAGS */ + { 6652, 0x00000001 }, /* GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT */ + { 6691, 0x00000004 }, /* GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB */ + { 6729, 0x00009126 }, /* GL_CONTEXT_PROFILE_MASK */ + { 6753, 0x00008010 }, /* GL_CONVOLUTION_1D */ + { 6771, 0x00008011 }, /* GL_CONVOLUTION_2D */ + { 6789, 0x00008154 }, /* GL_CONVOLUTION_BORDER_COLOR */ + { 6817, 0x00008154 }, /* GL_CONVOLUTION_BORDER_COLOR_HP */ + { 6848, 0x00008013 }, /* GL_CONVOLUTION_BORDER_MODE */ + { 6875, 0x00008013 }, /* GL_CONVOLUTION_BORDER_MODE_EXT */ + { 6906, 0x00008015 }, /* GL_CONVOLUTION_FILTER_BIAS */ + { 6933, 0x00008015 }, /* GL_CONVOLUTION_FILTER_BIAS_EXT */ + { 6964, 0x00008014 }, /* GL_CONVOLUTION_FILTER_SCALE */ + { 6992, 0x00008014 }, /* GL_CONVOLUTION_FILTER_SCALE_EXT */ + { 7024, 0x00008017 }, /* GL_CONVOLUTION_FORMAT */ + { 7046, 0x00008017 }, /* GL_CONVOLUTION_FORMAT_EXT */ + { 7072, 0x00008019 }, /* GL_CONVOLUTION_HEIGHT */ + { 7094, 0x00008019 }, /* GL_CONVOLUTION_HEIGHT_EXT */ + { 7120, 0x00008018 }, /* GL_CONVOLUTION_WIDTH */ + { 7141, 0x00008018 }, /* GL_CONVOLUTION_WIDTH_EXT */ + { 7166, 0x00008862 }, /* GL_COORD_REPLACE */ + { 7183, 0x00008862 }, /* GL_COORD_REPLACE_ARB */ + { 7204, 0x00008862 }, /* GL_COORD_REPLACE_NV */ + { 7224, 0x00008862 }, /* GL_COORD_REPLACE_OES */ + { 7245, 0x00001503 }, /* GL_COPY */ + { 7253, 0x0000150C }, /* GL_COPY_INVERTED */ + { 7270, 0x00000706 }, /* GL_COPY_PIXEL_TOKEN */ + { 7290, 0x00008F36 }, /* GL_COPY_READ_BUFFER */ + { 7310, 0x00008F37 }, /* GL_COPY_WRITE_BUFFER */ + { 7331, 0x00000B44 }, /* GL_CULL_FACE */ + { 7344, 0x00000B45 }, /* GL_CULL_FACE_MODE */ + { 7362, 0x000081AA }, /* GL_CULL_VERTEX_EXT */ + { 7381, 0x000081AC }, /* GL_CULL_VERTEX_EYE_POSITION_EXT */ + { 7413, 0x000081AB }, /* GL_CULL_VERTEX_OBJECT_POSITION_EXT */ + { 7448, 0x00008626 }, /* GL_CURRENT_ATTRIB_NV */ + { 7469, 0x00000001 }, /* GL_CURRENT_BIT */ + { 7484, 0x00000B00 }, /* GL_CURRENT_COLOR */ + { 7501, 0x00008453 }, /* GL_CURRENT_FOG_COORD */ + { 7522, 0x00008453 }, /* GL_CURRENT_FOG_COORDINATE */ + { 7548, 0x00000B01 }, /* GL_CURRENT_INDEX */ + { 7565, 0x00008641 }, /* GL_CURRENT_MATRIX_ARB */ + { 7587, 0x00008845 }, /* GL_CURRENT_MATRIX_INDEX_ARB */ + { 7615, 0x00008641 }, /* GL_CURRENT_MATRIX_NV */ + { 7636, 0x00008640 }, /* GL_CURRENT_MATRIX_STACK_DEPTH_ARB */ + { 7670, 0x00008640 }, /* GL_CURRENT_MATRIX_STACK_DEPTH_NV */ + { 7703, 0x00000B02 }, /* GL_CURRENT_NORMAL */ + { 7721, 0x00008843 }, /* GL_CURRENT_PALETTE_MATRIX_ARB */ + { 7751, 0x00008843 }, /* GL_CURRENT_PALETTE_MATRIX_OES */ + { 7781, 0x00008B8D }, /* GL_CURRENT_PROGRAM */ + { 7800, 0x00008865 }, /* GL_CURRENT_QUERY */ + { 7817, 0x00008865 }, /* GL_CURRENT_QUERY_ARB */ + { 7838, 0x00000B04 }, /* GL_CURRENT_RASTER_COLOR */ + { 7862, 0x00000B09 }, /* GL_CURRENT_RASTER_DISTANCE */ + { 7889, 0x00000B05 }, /* GL_CURRENT_RASTER_INDEX */ + { 7913, 0x00000B07 }, /* GL_CURRENT_RASTER_POSITION */ + { 7940, 0x00000B08 }, /* GL_CURRENT_RASTER_POSITION_VALID */ + { 7973, 0x0000845F }, /* GL_CURRENT_RASTER_SECONDARY_COLOR */ + { 8007, 0x00000B06 }, /* GL_CURRENT_RASTER_TEXTURE_COORDS */ + { 8040, 0x00008459 }, /* GL_CURRENT_SECONDARY_COLOR */ + { 8067, 0x00000B03 }, /* GL_CURRENT_TEXTURE_COORDS */ + { 8093, 0x00008626 }, /* GL_CURRENT_VERTEX_ATTRIB */ + { 8118, 0x00008626 }, /* GL_CURRENT_VERTEX_ATTRIB_ARB */ + { 8147, 0x000086A8 }, /* GL_CURRENT_WEIGHT_ARB */ + { 8169, 0x00000900 }, /* GL_CW */ + { 8175, 0x0000875B }, /* GL_DEBUG_ASSERT_MESA */ + { 8196, 0x00008759 }, /* GL_DEBUG_OBJECT_MESA */ + { 8217, 0x0000875A }, /* GL_DEBUG_PRINT_MESA */ + { 8237, 0x00002101 }, /* GL_DECAL */ + { 8246, 0x00001E03 }, /* GL_DECR */ + { 8254, 0x00008508 }, /* GL_DECR_WRAP */ + { 8267, 0x00008508 }, /* GL_DECR_WRAP_EXT */ + { 8284, 0x00008B80 }, /* GL_DELETE_STATUS */ + { 8301, 0x00001801 }, /* GL_DEPTH */ + { 8310, 0x000088F0 }, /* GL_DEPTH24_STENCIL8 */ + { 8330, 0x000088F0 }, /* GL_DEPTH24_STENCIL8_EXT */ + { 8354, 0x000088F0 }, /* GL_DEPTH24_STENCIL8_OES */ + { 8378, 0x00008D00 }, /* GL_DEPTH_ATTACHMENT */ + { 8398, 0x00008D00 }, /* GL_DEPTH_ATTACHMENT_EXT */ + { 8422, 0x00008D00 }, /* GL_DEPTH_ATTACHMENT_OES */ + { 8446, 0x00000D1F }, /* GL_DEPTH_BIAS */ + { 8460, 0x00000D56 }, /* GL_DEPTH_BITS */ + { 8474, 0x00008891 }, /* GL_DEPTH_BOUNDS_EXT */ + { 8494, 0x00008890 }, /* GL_DEPTH_BOUNDS_TEST_EXT */ + { 8519, 0x00008223 }, /* GL_DEPTH_BUFFER */ + { 8535, 0x00000100 }, /* GL_DEPTH_BUFFER_BIT */ + { 8555, 0x0000864F }, /* GL_DEPTH_CLAMP */ + { 8570, 0x0000864F }, /* GL_DEPTH_CLAMP_NV */ + { 8588, 0x00000B73 }, /* GL_DEPTH_CLEAR_VALUE */ + { 8609, 0x00001902 }, /* GL_DEPTH_COMPONENT */ + { 8628, 0x000081A5 }, /* GL_DEPTH_COMPONENT16 */ + { 8649, 0x000081A5 }, /* GL_DEPTH_COMPONENT16_ARB */ + { 8674, 0x000081A5 }, /* GL_DEPTH_COMPONENT16_OES */ + { 8699, 0x000081A5 }, /* GL_DEPTH_COMPONENT16_SGIX */ + { 8725, 0x000081A6 }, /* GL_DEPTH_COMPONENT24 */ + { 8746, 0x000081A6 }, /* GL_DEPTH_COMPONENT24_ARB */ + { 8771, 0x000081A6 }, /* GL_DEPTH_COMPONENT24_OES */ + { 8796, 0x000081A6 }, /* GL_DEPTH_COMPONENT24_SGIX */ + { 8822, 0x000081A7 }, /* GL_DEPTH_COMPONENT32 */ + { 8843, 0x000081A7 }, /* GL_DEPTH_COMPONENT32_ARB */ + { 8868, 0x000081A7 }, /* GL_DEPTH_COMPONENT32_OES */ + { 8893, 0x000081A7 }, /* GL_DEPTH_COMPONENT32_SGIX */ + { 8919, 0x00000B74 }, /* GL_DEPTH_FUNC */ + { 8933, 0x00000B70 }, /* GL_DEPTH_RANGE */ + { 8948, 0x00000D1E }, /* GL_DEPTH_SCALE */ + { 8963, 0x000084F9 }, /* GL_DEPTH_STENCIL */ + { 8980, 0x0000821A }, /* GL_DEPTH_STENCIL_ATTACHMENT */ + { 9008, 0x000084F9 }, /* GL_DEPTH_STENCIL_EXT */ + { 9029, 0x000084F9 }, /* GL_DEPTH_STENCIL_NV */ + { 9049, 0x000084F9 }, /* GL_DEPTH_STENCIL_OES */ + { 9070, 0x0000886F }, /* GL_DEPTH_STENCIL_TO_BGRA_NV */ + { 9098, 0x0000886E }, /* GL_DEPTH_STENCIL_TO_RGBA_NV */ + { 9126, 0x00000B71 }, /* GL_DEPTH_TEST */ + { 9140, 0x0000884B }, /* GL_DEPTH_TEXTURE_MODE */ + { 9162, 0x0000884B }, /* GL_DEPTH_TEXTURE_MODE_ARB */ + { 9188, 0x00000B72 }, /* GL_DEPTH_WRITEMASK */ + { 9207, 0x00001201 }, /* GL_DIFFUSE */ + { 9218, 0x00000BD0 }, /* GL_DITHER */ + { 9228, 0x00000A02 }, /* GL_DOMAIN */ + { 9238, 0x00001100 }, /* GL_DONT_CARE */ + { 9251, 0x000086AE }, /* GL_DOT3_RGB */ + { 9263, 0x000086AF }, /* GL_DOT3_RGBA */ + { 9276, 0x000086AF }, /* GL_DOT3_RGBA_ARB */ + { 9293, 0x00008741 }, /* GL_DOT3_RGBA_EXT */ + { 9310, 0x000086AE }, /* GL_DOT3_RGB_ARB */ + { 9326, 0x00008740 }, /* GL_DOT3_RGB_EXT */ + { 9342, 0x0000140A }, /* GL_DOUBLE */ + { 9352, 0x00000C32 }, /* GL_DOUBLEBUFFER */ + { 9368, 0x00000C01 }, /* GL_DRAW_BUFFER */ + { 9383, 0x00008825 }, /* GL_DRAW_BUFFER0 */ + { 9399, 0x00008825 }, /* GL_DRAW_BUFFER0_ARB */ + { 9419, 0x00008825 }, /* GL_DRAW_BUFFER0_ATI */ + { 9439, 0x00008826 }, /* GL_DRAW_BUFFER1 */ + { 9455, 0x0000882F }, /* GL_DRAW_BUFFER10 */ + { 9472, 0x0000882F }, /* GL_DRAW_BUFFER10_ARB */ + { 9493, 0x0000882F }, /* GL_DRAW_BUFFER10_ATI */ + { 9514, 0x00008830 }, /* GL_DRAW_BUFFER11 */ + { 9531, 0x00008830 }, /* GL_DRAW_BUFFER11_ARB */ + { 9552, 0x00008830 }, /* GL_DRAW_BUFFER11_ATI */ + { 9573, 0x00008831 }, /* GL_DRAW_BUFFER12 */ + { 9590, 0x00008831 }, /* GL_DRAW_BUFFER12_ARB */ + { 9611, 0x00008831 }, /* GL_DRAW_BUFFER12_ATI */ + { 9632, 0x00008832 }, /* GL_DRAW_BUFFER13 */ + { 9649, 0x00008832 }, /* GL_DRAW_BUFFER13_ARB */ + { 9670, 0x00008832 }, /* GL_DRAW_BUFFER13_ATI */ + { 9691, 0x00008833 }, /* GL_DRAW_BUFFER14 */ + { 9708, 0x00008833 }, /* GL_DRAW_BUFFER14_ARB */ + { 9729, 0x00008833 }, /* GL_DRAW_BUFFER14_ATI */ + { 9750, 0x00008834 }, /* GL_DRAW_BUFFER15 */ + { 9767, 0x00008834 }, /* GL_DRAW_BUFFER15_ARB */ + { 9788, 0x00008834 }, /* GL_DRAW_BUFFER15_ATI */ + { 9809, 0x00008826 }, /* GL_DRAW_BUFFER1_ARB */ + { 9829, 0x00008826 }, /* GL_DRAW_BUFFER1_ATI */ + { 9849, 0x00008827 }, /* GL_DRAW_BUFFER2 */ + { 9865, 0x00008827 }, /* GL_DRAW_BUFFER2_ARB */ + { 9885, 0x00008827 }, /* GL_DRAW_BUFFER2_ATI */ + { 9905, 0x00008828 }, /* GL_DRAW_BUFFER3 */ + { 9921, 0x00008828 }, /* GL_DRAW_BUFFER3_ARB */ + { 9941, 0x00008828 }, /* GL_DRAW_BUFFER3_ATI */ + { 9961, 0x00008829 }, /* GL_DRAW_BUFFER4 */ + { 9977, 0x00008829 }, /* GL_DRAW_BUFFER4_ARB */ + { 9997, 0x00008829 }, /* GL_DRAW_BUFFER4_ATI */ + { 10017, 0x0000882A }, /* GL_DRAW_BUFFER5 */ + { 10033, 0x0000882A }, /* GL_DRAW_BUFFER5_ARB */ + { 10053, 0x0000882A }, /* GL_DRAW_BUFFER5_ATI */ + { 10073, 0x0000882B }, /* GL_DRAW_BUFFER6 */ + { 10089, 0x0000882B }, /* GL_DRAW_BUFFER6_ARB */ + { 10109, 0x0000882B }, /* GL_DRAW_BUFFER6_ATI */ + { 10129, 0x0000882C }, /* GL_DRAW_BUFFER7 */ + { 10145, 0x0000882C }, /* GL_DRAW_BUFFER7_ARB */ + { 10165, 0x0000882C }, /* GL_DRAW_BUFFER7_ATI */ + { 10185, 0x0000882D }, /* GL_DRAW_BUFFER8 */ + { 10201, 0x0000882D }, /* GL_DRAW_BUFFER8_ARB */ + { 10221, 0x0000882D }, /* GL_DRAW_BUFFER8_ATI */ + { 10241, 0x0000882E }, /* GL_DRAW_BUFFER9 */ + { 10257, 0x0000882E }, /* GL_DRAW_BUFFER9_ARB */ + { 10277, 0x0000882E }, /* GL_DRAW_BUFFER9_ATI */ + { 10297, 0x00008CA9 }, /* GL_DRAW_FRAMEBUFFER */ + { 10317, 0x00008CA6 }, /* GL_DRAW_FRAMEBUFFER_BINDING */ + { 10345, 0x00008CA6 }, /* GL_DRAW_FRAMEBUFFER_BINDING_EXT */ + { 10377, 0x00008CA9 }, /* GL_DRAW_FRAMEBUFFER_EXT */ + { 10401, 0x00000705 }, /* GL_DRAW_PIXEL_TOKEN */ + { 10421, 0x00000304 }, /* GL_DST_ALPHA */ + { 10434, 0x00000306 }, /* GL_DST_COLOR */ + { 10447, 0x0000877A }, /* GL_DU8DV8_ATI */ + { 10461, 0x00008779 }, /* GL_DUDV_ATI */ + { 10473, 0x000088EA }, /* GL_DYNAMIC_COPY */ + { 10489, 0x000088EA }, /* GL_DYNAMIC_COPY_ARB */ + { 10509, 0x000088E8 }, /* GL_DYNAMIC_DRAW */ + { 10525, 0x000088E8 }, /* GL_DYNAMIC_DRAW_ARB */ + { 10545, 0x000088E9 }, /* GL_DYNAMIC_READ */ + { 10561, 0x000088E9 }, /* GL_DYNAMIC_READ_ARB */ + { 10581, 0x00000B43 }, /* GL_EDGE_FLAG */ + { 10594, 0x00008079 }, /* GL_EDGE_FLAG_ARRAY */ + { 10613, 0x0000889B }, /* GL_EDGE_FLAG_ARRAY_BUFFER_BINDING */ + { 10647, 0x0000889B }, /* GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB */ + { 10685, 0x00008093 }, /* GL_EDGE_FLAG_ARRAY_POINTER */ + { 10712, 0x0000808C }, /* GL_EDGE_FLAG_ARRAY_STRIDE */ + { 10738, 0x00008893 }, /* GL_ELEMENT_ARRAY_BUFFER */ + { 10762, 0x00008895 }, /* GL_ELEMENT_ARRAY_BUFFER_BINDING */ + { 10794, 0x00008895 }, /* GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB */ + { 10830, 0x00001600 }, /* GL_EMISSION */ + { 10842, 0x00002000 }, /* GL_ENABLE_BIT */ + { 10856, 0x00000202 }, /* GL_EQUAL */ + { 10865, 0x00001509 }, /* GL_EQUIV */ + { 10874, 0x00010000 }, /* GL_EVAL_BIT */ + { 10886, 0x00000800 }, /* GL_EXP */ + { 10893, 0x00000801 }, /* GL_EXP2 */ + { 10901, 0x00001F03 }, /* GL_EXTENSIONS */ + { 10915, 0x00002400 }, /* GL_EYE_LINEAR */ + { 10929, 0x00002502 }, /* GL_EYE_PLANE */ + { 10942, 0x0000855C }, /* GL_EYE_PLANE_ABSOLUTE_NV */ + { 10967, 0x0000855B }, /* GL_EYE_RADIAL_NV */ + { 10984, 0x00000000 }, /* GL_FALSE */ + { 10993, 0x00001101 }, /* GL_FASTEST */ + { 11004, 0x00001C01 }, /* GL_FEEDBACK */ + { 11016, 0x00000DF0 }, /* GL_FEEDBACK_BUFFER_POINTER */ + { 11043, 0x00000DF1 }, /* GL_FEEDBACK_BUFFER_SIZE */ + { 11067, 0x00000DF2 }, /* GL_FEEDBACK_BUFFER_TYPE */ + { 11091, 0x00001B02 }, /* GL_FILL */ + { 11099, 0x00008E4D }, /* GL_FIRST_VERTEX_CONVENTION */ + { 11126, 0x00008E4D }, /* GL_FIRST_VERTEX_CONVENTION_EXT */ + { 11157, 0x0000140C }, /* GL_FIXED */ + { 11166, 0x0000140C }, /* GL_FIXED_OES */ + { 11179, 0x0000891D }, /* GL_FIXED_ONLY */ + { 11193, 0x0000891D }, /* GL_FIXED_ONLY_ARB */ + { 11211, 0x00001D00 }, /* GL_FLAT */ + { 11219, 0x00001406 }, /* GL_FLOAT */ + { 11228, 0x00008B5A }, /* GL_FLOAT_MAT2 */ + { 11242, 0x00008B5A }, /* GL_FLOAT_MAT2_ARB */ + { 11260, 0x00008B65 }, /* GL_FLOAT_MAT2x3 */ + { 11276, 0x00008B66 }, /* GL_FLOAT_MAT2x4 */ + { 11292, 0x00008B5B }, /* GL_FLOAT_MAT3 */ + { 11306, 0x00008B5B }, /* GL_FLOAT_MAT3_ARB */ + { 11324, 0x00008B67 }, /* GL_FLOAT_MAT3x2 */ + { 11340, 0x00008B68 }, /* GL_FLOAT_MAT3x4 */ + { 11356, 0x00008B5C }, /* GL_FLOAT_MAT4 */ + { 11370, 0x00008B5C }, /* GL_FLOAT_MAT4_ARB */ + { 11388, 0x00008B69 }, /* GL_FLOAT_MAT4x2 */ + { 11404, 0x00008B6A }, /* GL_FLOAT_MAT4x3 */ + { 11420, 0x00008B50 }, /* GL_FLOAT_VEC2 */ + { 11434, 0x00008B50 }, /* GL_FLOAT_VEC2_ARB */ + { 11452, 0x00008B51 }, /* GL_FLOAT_VEC3 */ + { 11466, 0x00008B51 }, /* GL_FLOAT_VEC3_ARB */ + { 11484, 0x00008B52 }, /* GL_FLOAT_VEC4 */ + { 11498, 0x00008B52 }, /* GL_FLOAT_VEC4_ARB */ + { 11516, 0x00000B60 }, /* GL_FOG */ + { 11523, 0x00000080 }, /* GL_FOG_BIT */ + { 11534, 0x00000B66 }, /* GL_FOG_COLOR */ + { 11547, 0x00008451 }, /* GL_FOG_COORD */ + { 11560, 0x00008451 }, /* GL_FOG_COORDINATE */ + { 11578, 0x00008457 }, /* GL_FOG_COORDINATE_ARRAY */ + { 11602, 0x0000889D }, /* GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING */ + { 11641, 0x0000889D }, /* GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB */ + { 11684, 0x00008456 }, /* GL_FOG_COORDINATE_ARRAY_POINTER */ + { 11716, 0x00008455 }, /* GL_FOG_COORDINATE_ARRAY_STRIDE */ + { 11747, 0x00008454 }, /* GL_FOG_COORDINATE_ARRAY_TYPE */ + { 11776, 0x00008450 }, /* GL_FOG_COORDINATE_SOURCE */ + { 11801, 0x00008457 }, /* GL_FOG_COORD_ARRAY */ + { 11820, 0x0000889D }, /* GL_FOG_COORD_ARRAY_BUFFER_BINDING */ + { 11854, 0x00008456 }, /* GL_FOG_COORD_ARRAY_POINTER */ + { 11881, 0x00008455 }, /* GL_FOG_COORD_ARRAY_STRIDE */ + { 11907, 0x00008454 }, /* GL_FOG_COORD_ARRAY_TYPE */ + { 11931, 0x00008450 }, /* GL_FOG_COORD_SRC */ + { 11948, 0x00000B62 }, /* GL_FOG_DENSITY */ + { 11963, 0x0000855A }, /* GL_FOG_DISTANCE_MODE_NV */ + { 11987, 0x00000B64 }, /* GL_FOG_END */ + { 11998, 0x00000C54 }, /* GL_FOG_HINT */ + { 12010, 0x00000B61 }, /* GL_FOG_INDEX */ + { 12023, 0x00000B65 }, /* GL_FOG_MODE */ + { 12035, 0x00008198 }, /* GL_FOG_OFFSET_SGIX */ + { 12054, 0x00008199 }, /* GL_FOG_OFFSET_VALUE_SGIX */ + { 12079, 0x00000B63 }, /* GL_FOG_START */ + { 12092, 0x00008452 }, /* GL_FRAGMENT_DEPTH */ + { 12110, 0x00008804 }, /* GL_FRAGMENT_PROGRAM_ARB */ + { 12134, 0x00008B30 }, /* GL_FRAGMENT_SHADER */ + { 12153, 0x00008B30 }, /* GL_FRAGMENT_SHADER_ARB */ + { 12176, 0x00008B8B }, /* GL_FRAGMENT_SHADER_DERIVATIVE_HINT */ + { 12211, 0x00008B8B }, /* GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES */ + { 12250, 0x00008D40 }, /* GL_FRAMEBUFFER */ + { 12265, 0x00008215 }, /* GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE */ + { 12302, 0x00008214 }, /* GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE */ + { 12338, 0x00008210 }, /* GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING */ + { 12379, 0x00008211 }, /* GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE */ + { 12420, 0x00008216 }, /* GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE */ + { 12457, 0x00008213 }, /* GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE */ + { 12494, 0x00008DA7 }, /* GL_FRAMEBUFFER_ATTACHMENT_LAYERED */ + { 12528, 0x00008DA7 }, /* GL_FRAMEBUFFER_ATTACHMENT_LAYERED_ARB */ + { 12566, 0x00008CD1 }, /* GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME */ + { 12604, 0x00008CD1 }, /* GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT */ + { 12646, 0x00008CD1 }, /* GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_OES */ + { 12688, 0x00008CD0 }, /* GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE */ + { 12726, 0x00008CD0 }, /* GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT */ + { 12768, 0x00008CD0 }, /* GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_OES */ + { 12810, 0x00008212 }, /* GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE */ + { 12845, 0x00008217 }, /* GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE */ + { 12884, 0x00008CD4 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT */ + { 12933, 0x00008CD4 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_OES */ + { 12982, 0x00008CD3 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE */ + { 13030, 0x00008CD3 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT */ + { 13082, 0x00008CD3 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_OES */ + { 13134, 0x00008CD4 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER */ + { 13174, 0x00008CD4 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT */ + { 13218, 0x00008CD2 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL */ + { 13258, 0x00008CD2 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT */ + { 13302, 0x00008CD2 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_OES */ + { 13346, 0x00008CA6 }, /* GL_FRAMEBUFFER_BINDING */ + { 13369, 0x00008CA6 }, /* GL_FRAMEBUFFER_BINDING_EXT */ + { 13396, 0x00008CA6 }, /* GL_FRAMEBUFFER_BINDING_OES */ + { 13423, 0x00008CD5 }, /* GL_FRAMEBUFFER_COMPLETE */ + { 13447, 0x00008CD5 }, /* GL_FRAMEBUFFER_COMPLETE_EXT */ + { 13475, 0x00008CD5 }, /* GL_FRAMEBUFFER_COMPLETE_OES */ + { 13503, 0x00008218 }, /* GL_FRAMEBUFFER_DEFAULT */ + { 13526, 0x00008D40 }, /* GL_FRAMEBUFFER_EXT */ + { 13545, 0x00008CD6 }, /* GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT */ + { 13582, 0x00008CD6 }, /* GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT */ + { 13623, 0x00008CD6 }, /* GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_OES */ + { 13664, 0x00008CD9 }, /* GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS */ + { 13701, 0x00008CD9 }, /* GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT */ + { 13742, 0x00008CD9 }, /* GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_OES */ + { 13783, 0x00008CDB }, /* GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER */ + { 13821, 0x00008CDB }, /* GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT */ + { 13863, 0x00008CDB }, /* GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_OES */ + { 13905, 0x00008CD8 }, /* GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT */ + { 13956, 0x00008CDA }, /* GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT */ + { 13994, 0x00008CDA }, /* GL_FRAMEBUFFER_INCOMPLETE_FORMATS_OES */ + { 14032, 0x00008DA9 }, /* GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB */ + { 14074, 0x00008DA8 }, /* GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS */ + { 14114, 0x00008DA8 }, /* GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_ARB */ + { 14158, 0x00008CD7 }, /* GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT */ + { 14203, 0x00008CD7 }, /* GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT */ + { 14252, 0x00008CD7 }, /* GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_OES */ + { 14301, 0x00008D56 }, /* GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE */ + { 14339, 0x00008D56 }, /* GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT */ + { 14381, 0x00008CDC }, /* GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER */ + { 14419, 0x00008CDC }, /* GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT */ + { 14461, 0x00008CDC }, /* GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_OES */ + { 14503, 0x00008D40 }, /* GL_FRAMEBUFFER_OES */ + { 14522, 0x00008CDE }, /* GL_FRAMEBUFFER_STATUS_ERROR_EXT */ + { 14554, 0x00008219 }, /* GL_FRAMEBUFFER_UNDEFINED */ + { 14579, 0x00008CDD }, /* GL_FRAMEBUFFER_UNSUPPORTED */ + { 14606, 0x00008CDD }, /* GL_FRAMEBUFFER_UNSUPPORTED_EXT */ + { 14637, 0x00008CDD }, /* GL_FRAMEBUFFER_UNSUPPORTED_OES */ + { 14668, 0x00000404 }, /* GL_FRONT */ + { 14677, 0x00000408 }, /* GL_FRONT_AND_BACK */ + { 14695, 0x00000B46 }, /* GL_FRONT_FACE */ + { 14709, 0x00000400 }, /* GL_FRONT_LEFT */ + { 14723, 0x00000401 }, /* GL_FRONT_RIGHT */ + { 14738, 0x00008006 }, /* GL_FUNC_ADD */ + { 14750, 0x00008006 }, /* GL_FUNC_ADD_EXT */ + { 14766, 0x00008006 }, /* GL_FUNC_ADD_OES */ + { 14782, 0x0000800B }, /* GL_FUNC_REVERSE_SUBTRACT */ + { 14807, 0x0000800B }, /* GL_FUNC_REVERSE_SUBTRACT_EXT */ + { 14836, 0x0000800B }, /* GL_FUNC_REVERSE_SUBTRACT_OES */ + { 14865, 0x0000800A }, /* GL_FUNC_SUBTRACT */ + { 14882, 0x0000800A }, /* GL_FUNC_SUBTRACT_EXT */ + { 14903, 0x0000800A }, /* GL_FUNC_SUBTRACT_OES */ + { 14924, 0x00008191 }, /* GL_GENERATE_MIPMAP */ + { 14943, 0x00008192 }, /* GL_GENERATE_MIPMAP_HINT */ + { 14967, 0x00008192 }, /* GL_GENERATE_MIPMAP_HINT_SGIS */ + { 14996, 0x00008191 }, /* GL_GENERATE_MIPMAP_SGIS */ + { 15020, 0x00008917 }, /* GL_GEOMETRY_INPUT_TYPE */ + { 15043, 0x00008DDB }, /* GL_GEOMETRY_INPUT_TYPE_ARB */ + { 15070, 0x00008918 }, /* GL_GEOMETRY_OUTPUT_TYPE */ + { 15094, 0x00008DDC }, /* GL_GEOMETRY_OUTPUT_TYPE_ARB */ + { 15122, 0x00008DD9 }, /* GL_GEOMETRY_SHADER */ + { 15141, 0x00008DD9 }, /* GL_GEOMETRY_SHADER_ARB */ + { 15164, 0x00008916 }, /* GL_GEOMETRY_VERTICES_OUT */ + { 15189, 0x00008DDA }, /* GL_GEOMETRY_VERTICES_OUT_ARB */ + { 15218, 0x00000206 }, /* GL_GEQUAL */ + { 15228, 0x00000204 }, /* GL_GREATER */ + { 15239, 0x00001904 }, /* GL_GREEN */ + { 15248, 0x00000D19 }, /* GL_GREEN_BIAS */ + { 15262, 0x00000D53 }, /* GL_GREEN_BITS */ + { 15276, 0x00008D95 }, /* GL_GREEN_INTEGER */ + { 15293, 0x00008D95 }, /* GL_GREEN_INTEGER_EXT */ + { 15314, 0x00000D18 }, /* GL_GREEN_SCALE */ + { 15329, 0x00008253 }, /* GL_GUILTY_CONTEXT_RESET_ARB */ + { 15357, 0x0000140B }, /* GL_HALF_FLOAT */ + { 15371, 0x00008D61 }, /* GL_HALF_FLOAT_OES */ + { 15389, 0x00008DF2 }, /* GL_HIGH_FLOAT */ + { 15403, 0x00008DF5 }, /* GL_HIGH_INT */ + { 15415, 0x00008000 }, /* GL_HINT_BIT */ + { 15427, 0x00008024 }, /* GL_HISTOGRAM */ + { 15440, 0x0000802B }, /* GL_HISTOGRAM_ALPHA_SIZE */ + { 15464, 0x0000802B }, /* GL_HISTOGRAM_ALPHA_SIZE_EXT */ + { 15492, 0x0000802A }, /* GL_HISTOGRAM_BLUE_SIZE */ + { 15515, 0x0000802A }, /* GL_HISTOGRAM_BLUE_SIZE_EXT */ + { 15542, 0x00008024 }, /* GL_HISTOGRAM_EXT */ + { 15559, 0x00008027 }, /* GL_HISTOGRAM_FORMAT */ + { 15579, 0x00008027 }, /* GL_HISTOGRAM_FORMAT_EXT */ + { 15603, 0x00008029 }, /* GL_HISTOGRAM_GREEN_SIZE */ + { 15627, 0x00008029 }, /* GL_HISTOGRAM_GREEN_SIZE_EXT */ + { 15655, 0x0000802C }, /* GL_HISTOGRAM_LUMINANCE_SIZE */ + { 15683, 0x0000802C }, /* GL_HISTOGRAM_LUMINANCE_SIZE_EXT */ + { 15715, 0x00008028 }, /* GL_HISTOGRAM_RED_SIZE */ + { 15737, 0x00008028 }, /* GL_HISTOGRAM_RED_SIZE_EXT */ + { 15763, 0x0000802D }, /* GL_HISTOGRAM_SINK */ + { 15781, 0x0000802D }, /* GL_HISTOGRAM_SINK_EXT */ + { 15803, 0x00008026 }, /* GL_HISTOGRAM_WIDTH */ + { 15822, 0x00008026 }, /* GL_HISTOGRAM_WIDTH_EXT */ + { 15845, 0x0000862A }, /* GL_IDENTITY_NV */ + { 15860, 0x00008150 }, /* GL_IGNORE_BORDER_HP */ + { 15880, 0x00008B9B }, /* GL_IMPLEMENTATION_COLOR_READ_FORMAT */ + { 15916, 0x00008B9B }, /* GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES */ + { 15956, 0x00008B9A }, /* GL_IMPLEMENTATION_COLOR_READ_TYPE */ + { 15990, 0x00008B9A }, /* GL_IMPLEMENTATION_COLOR_READ_TYPE_OES */ + { 16028, 0x00001E02 }, /* GL_INCR */ + { 16036, 0x00008507 }, /* GL_INCR_WRAP */ + { 16049, 0x00008507 }, /* GL_INCR_WRAP_EXT */ + { 16066, 0x00008222 }, /* GL_INDEX */ + { 16075, 0x00008077 }, /* GL_INDEX_ARRAY */ + { 16090, 0x00008899 }, /* GL_INDEX_ARRAY_BUFFER_BINDING */ + { 16120, 0x00008899 }, /* GL_INDEX_ARRAY_BUFFER_BINDING_ARB */ + { 16154, 0x00008091 }, /* GL_INDEX_ARRAY_POINTER */ + { 16177, 0x00008086 }, /* GL_INDEX_ARRAY_STRIDE */ + { 16199, 0x00008085 }, /* GL_INDEX_ARRAY_TYPE */ + { 16219, 0x00000D51 }, /* GL_INDEX_BITS */ + { 16233, 0x00000C20 }, /* GL_INDEX_CLEAR_VALUE */ + { 16254, 0x00000BF1 }, /* GL_INDEX_LOGIC_OP */ + { 16272, 0x00000C30 }, /* GL_INDEX_MODE */ + { 16286, 0x00000D13 }, /* GL_INDEX_OFFSET */ + { 16302, 0x00000D12 }, /* GL_INDEX_SHIFT */ + { 16317, 0x00000C21 }, /* GL_INDEX_WRITEMASK */ + { 16336, 0x00008B84 }, /* GL_INFO_LOG_LENGTH */ + { 16355, 0x00008254 }, /* GL_INNOCENT_CONTEXT_RESET_ARB */ + { 16385, 0x00001404 }, /* GL_INT */ + { 16392, 0x00008049 }, /* GL_INTENSITY */ + { 16405, 0x0000804C }, /* GL_INTENSITY12 */ + { 16420, 0x0000804C }, /* GL_INTENSITY12_EXT */ + { 16439, 0x0000804D }, /* GL_INTENSITY16 */ + { 16454, 0x00008D8B }, /* GL_INTENSITY16I_EXT */ + { 16474, 0x00008D79 }, /* GL_INTENSITY16UI_EXT */ + { 16495, 0x0000804D }, /* GL_INTENSITY16_EXT */ + { 16514, 0x00008D85 }, /* GL_INTENSITY32I_EXT */ + { 16534, 0x00008D73 }, /* GL_INTENSITY32UI_EXT */ + { 16555, 0x0000804A }, /* GL_INTENSITY4 */ + { 16569, 0x0000804A }, /* GL_INTENSITY4_EXT */ + { 16587, 0x0000804B }, /* GL_INTENSITY8 */ + { 16601, 0x00008D91 }, /* GL_INTENSITY8I_EXT */ + { 16620, 0x00008D7F }, /* GL_INTENSITY8UI_EXT */ + { 16640, 0x0000804B }, /* GL_INTENSITY8_EXT */ + { 16658, 0x00008049 }, /* GL_INTENSITY_EXT */ + { 16675, 0x00008C8C }, /* GL_INTERLEAVED_ATTRIBS */ + { 16698, 0x00008C8C }, /* GL_INTERLEAVED_ATTRIBS_EXT */ + { 16725, 0x00008575 }, /* GL_INTERPOLATE */ + { 16740, 0x00008575 }, /* GL_INTERPOLATE_ARB */ + { 16759, 0x00008575 }, /* GL_INTERPOLATE_EXT */ + { 16778, 0x00008DF7 }, /* GL_INT_10_10_10_2_OES */ + { 16800, 0x00008D9F }, /* GL_INT_2_10_10_10_REV */ + { 16822, 0x00008DC9 }, /* GL_INT_SAMPLER_1D */ + { 16840, 0x00008DCE }, /* GL_INT_SAMPLER_1D_ARRAY */ + { 16864, 0x00008DCE }, /* GL_INT_SAMPLER_1D_ARRAY_EXT */ + { 16892, 0x00008DC9 }, /* GL_INT_SAMPLER_1D_EXT */ + { 16914, 0x00008DCA }, /* GL_INT_SAMPLER_2D */ + { 16932, 0x00008DCF }, /* GL_INT_SAMPLER_2D_ARRAY */ + { 16956, 0x00008DCF }, /* GL_INT_SAMPLER_2D_ARRAY_EXT */ + { 16984, 0x00008DCA }, /* GL_INT_SAMPLER_2D_EXT */ + { 17006, 0x00008DCD }, /* GL_INT_SAMPLER_2D_RECT */ + { 17029, 0x00008DCD }, /* GL_INT_SAMPLER_2D_RECT_EXT */ + { 17056, 0x00008DCB }, /* GL_INT_SAMPLER_3D */ + { 17074, 0x00008DCB }, /* GL_INT_SAMPLER_3D_EXT */ + { 17096, 0x00008DD0 }, /* GL_INT_SAMPLER_BUFFER */ + { 17118, 0x00008DD0 }, /* GL_INT_SAMPLER_BUFFER_EXT */ + { 17144, 0x00008DCC }, /* GL_INT_SAMPLER_CUBE */ + { 17164, 0x00008DCC }, /* GL_INT_SAMPLER_CUBE_EXT */ + { 17188, 0x00008B53 }, /* GL_INT_VEC2 */ + { 17200, 0x00008B53 }, /* GL_INT_VEC2_ARB */ + { 17216, 0x00008B54 }, /* GL_INT_VEC3 */ + { 17228, 0x00008B54 }, /* GL_INT_VEC3_ARB */ + { 17244, 0x00008B55 }, /* GL_INT_VEC4 */ + { 17256, 0x00008B55 }, /* GL_INT_VEC4_ARB */ + { 17272, 0x00000500 }, /* GL_INVALID_ENUM */ + { 17288, 0x00000506 }, /* GL_INVALID_FRAMEBUFFER_OPERATION */ + { 17321, 0x00000506 }, /* GL_INVALID_FRAMEBUFFER_OPERATION_EXT */ + { 17358, 0x00000506 }, /* GL_INVALID_FRAMEBUFFER_OPERATION_OES */ + { 17395, 0x00000502 }, /* GL_INVALID_OPERATION */ + { 17416, 0x00000501 }, /* GL_INVALID_VALUE */ + { 17433, 0x0000862B }, /* GL_INVERSE_NV */ + { 17447, 0x0000862D }, /* GL_INVERSE_TRANSPOSE_NV */ + { 17471, 0x0000150A }, /* GL_INVERT */ + { 17481, 0x00001E00 }, /* GL_KEEP */ + { 17489, 0x00008E4E }, /* GL_LAST_VERTEX_CONVENTION */ + { 17515, 0x00008E4E }, /* GL_LAST_VERTEX_CONVENTION_EXT */ + { 17545, 0x00000406 }, /* GL_LEFT */ + { 17553, 0x00000203 }, /* GL_LEQUAL */ + { 17563, 0x00000201 }, /* GL_LESS */ + { 17571, 0x00004000 }, /* GL_LIGHT0 */ + { 17581, 0x00004001 }, /* GL_LIGHT1 */ + { 17591, 0x00004002 }, /* GL_LIGHT2 */ + { 17601, 0x00004003 }, /* GL_LIGHT3 */ + { 17611, 0x00004004 }, /* GL_LIGHT4 */ + { 17621, 0x00004005 }, /* GL_LIGHT5 */ + { 17631, 0x00004006 }, /* GL_LIGHT6 */ + { 17641, 0x00004007 }, /* GL_LIGHT7 */ + { 17651, 0x00000B50 }, /* GL_LIGHTING */ + { 17663, 0x00000040 }, /* GL_LIGHTING_BIT */ + { 17679, 0x00000B53 }, /* GL_LIGHT_MODEL_AMBIENT */ + { 17702, 0x000081F8 }, /* GL_LIGHT_MODEL_COLOR_CONTROL */ + { 17731, 0x000081F8 }, /* GL_LIGHT_MODEL_COLOR_CONTROL_EXT */ + { 17764, 0x00000B51 }, /* GL_LIGHT_MODEL_LOCAL_VIEWER */ + { 17792, 0x00000B52 }, /* GL_LIGHT_MODEL_TWO_SIDE */ + { 17816, 0x00001B01 }, /* GL_LINE */ + { 17824, 0x00002601 }, /* GL_LINEAR */ + { 17834, 0x00001208 }, /* GL_LINEAR_ATTENUATION */ + { 17856, 0x00008170 }, /* GL_LINEAR_CLIPMAP_LINEAR_SGIX */ + { 17886, 0x0000844F }, /* GL_LINEAR_CLIPMAP_NEAREST_SGIX */ + { 17917, 0x00002703 }, /* GL_LINEAR_MIPMAP_LINEAR */ + { 17941, 0x00002701 }, /* GL_LINEAR_MIPMAP_NEAREST */ + { 17966, 0x00000001 }, /* GL_LINES */ + { 17975, 0x0000000A }, /* GL_LINES_ADJACENCY */ + { 17994, 0x0000000A }, /* GL_LINES_ADJACENCY_ARB */ + { 18017, 0x00000004 }, /* GL_LINE_BIT */ + { 18029, 0x00000002 }, /* GL_LINE_LOOP */ + { 18042, 0x00000707 }, /* GL_LINE_RESET_TOKEN */ + { 18062, 0x00000B20 }, /* GL_LINE_SMOOTH */ + { 18077, 0x00000C52 }, /* GL_LINE_SMOOTH_HINT */ + { 18097, 0x00000B24 }, /* GL_LINE_STIPPLE */ + { 18113, 0x00000B25 }, /* GL_LINE_STIPPLE_PATTERN */ + { 18137, 0x00000B26 }, /* GL_LINE_STIPPLE_REPEAT */ + { 18160, 0x00000003 }, /* GL_LINE_STRIP */ + { 18174, 0x0000000B }, /* GL_LINE_STRIP_ADJACENCY */ + { 18198, 0x0000000B }, /* GL_LINE_STRIP_ADJACENCY_ARB */ + { 18226, 0x00000702 }, /* GL_LINE_TOKEN */ + { 18240, 0x00000B21 }, /* GL_LINE_WIDTH */ + { 18254, 0x00000B23 }, /* GL_LINE_WIDTH_GRANULARITY */ + { 18280, 0x00000B22 }, /* GL_LINE_WIDTH_RANGE */ + { 18300, 0x00008B82 }, /* GL_LINK_STATUS */ + { 18315, 0x00000B32 }, /* GL_LIST_BASE */ + { 18328, 0x00020000 }, /* GL_LIST_BIT */ + { 18340, 0x00000B33 }, /* GL_LIST_INDEX */ + { 18354, 0x00000B30 }, /* GL_LIST_MODE */ + { 18367, 0x00000101 }, /* GL_LOAD */ + { 18375, 0x00000BF1 }, /* GL_LOGIC_OP */ + { 18387, 0x00000BF0 }, /* GL_LOGIC_OP_MODE */ + { 18404, 0x00008252 }, /* GL_LOSE_CONTEXT_ON_RESET_ARB */ + { 18433, 0x00008CA1 }, /* GL_LOWER_LEFT */ + { 18447, 0x00008DF0 }, /* GL_LOW_FLOAT */ + { 18460, 0x00008DF3 }, /* GL_LOW_INT */ + { 18471, 0x00001909 }, /* GL_LUMINANCE */ + { 18484, 0x00008041 }, /* GL_LUMINANCE12 */ + { 18499, 0x00008047 }, /* GL_LUMINANCE12_ALPHA12 */ + { 18522, 0x00008047 }, /* GL_LUMINANCE12_ALPHA12_EXT */ + { 18549, 0x00008046 }, /* GL_LUMINANCE12_ALPHA4 */ + { 18571, 0x00008046 }, /* GL_LUMINANCE12_ALPHA4_EXT */ + { 18597, 0x00008041 }, /* GL_LUMINANCE12_EXT */ + { 18616, 0x00008042 }, /* GL_LUMINANCE16 */ + { 18631, 0x00008D8C }, /* GL_LUMINANCE16I_EXT */ + { 18651, 0x00008D7A }, /* GL_LUMINANCE16UI_EXT */ + { 18672, 0x00008048 }, /* GL_LUMINANCE16_ALPHA16 */ + { 18695, 0x00008048 }, /* GL_LUMINANCE16_ALPHA16_EXT */ + { 18722, 0x00008042 }, /* GL_LUMINANCE16_EXT */ + { 18741, 0x00008D86 }, /* GL_LUMINANCE32I_EXT */ + { 18761, 0x00008D74 }, /* GL_LUMINANCE32UI_EXT */ + { 18782, 0x0000803F }, /* GL_LUMINANCE4 */ + { 18796, 0x00008043 }, /* GL_LUMINANCE4_ALPHA4 */ + { 18817, 0x00008043 }, /* GL_LUMINANCE4_ALPHA4_EXT */ + { 18842, 0x0000803F }, /* GL_LUMINANCE4_EXT */ + { 18860, 0x00008044 }, /* GL_LUMINANCE6_ALPHA2 */ + { 18881, 0x00008044 }, /* GL_LUMINANCE6_ALPHA2_EXT */ + { 18906, 0x00008040 }, /* GL_LUMINANCE8 */ + { 18920, 0x00008D92 }, /* GL_LUMINANCE8I_EXT */ + { 18939, 0x00008D80 }, /* GL_LUMINANCE8UI_EXT */ + { 18959, 0x00008045 }, /* GL_LUMINANCE8_ALPHA8 */ + { 18980, 0x00008045 }, /* GL_LUMINANCE8_ALPHA8_EXT */ + { 19005, 0x00008040 }, /* GL_LUMINANCE8_EXT */ + { 19023, 0x0000190A }, /* GL_LUMINANCE_ALPHA */ + { 19042, 0x00008D8D }, /* GL_LUMINANCE_ALPHA16I_EXT */ + { 19068, 0x00008D7B }, /* GL_LUMINANCE_ALPHA16UI_EXT */ + { 19095, 0x00008D87 }, /* GL_LUMINANCE_ALPHA32I_EXT */ + { 19121, 0x00008D75 }, /* GL_LUMINANCE_ALPHA32UI_EXT */ + { 19148, 0x00008D93 }, /* GL_LUMINANCE_ALPHA8I_EXT */ + { 19173, 0x00008D81 }, /* GL_LUMINANCE_ALPHA8UI_EXT */ + { 19199, 0x00008D9D }, /* GL_LUMINANCE_ALPHA_INTEGER_EXT */ + { 19230, 0x00008D9C }, /* GL_LUMINANCE_INTEGER_EXT */ + { 19255, 0x0000821B }, /* GL_MAJOR_VERSION */ + { 19272, 0x00000D90 }, /* GL_MAP1_COLOR_4 */ + { 19288, 0x00000DD0 }, /* GL_MAP1_GRID_DOMAIN */ + { 19308, 0x00000DD1 }, /* GL_MAP1_GRID_SEGMENTS */ + { 19330, 0x00000D91 }, /* GL_MAP1_INDEX */ + { 19344, 0x00000D92 }, /* GL_MAP1_NORMAL */ + { 19359, 0x00000D93 }, /* GL_MAP1_TEXTURE_COORD_1 */ + { 19383, 0x00000D94 }, /* GL_MAP1_TEXTURE_COORD_2 */ + { 19407, 0x00000D95 }, /* GL_MAP1_TEXTURE_COORD_3 */ + { 19431, 0x00000D96 }, /* GL_MAP1_TEXTURE_COORD_4 */ + { 19455, 0x00000D97 }, /* GL_MAP1_VERTEX_3 */ + { 19472, 0x00000D98 }, /* GL_MAP1_VERTEX_4 */ + { 19489, 0x00008660 }, /* GL_MAP1_VERTEX_ATTRIB0_4_NV */ + { 19517, 0x0000866A }, /* GL_MAP1_VERTEX_ATTRIB10_4_NV */ + { 19546, 0x0000866B }, /* GL_MAP1_VERTEX_ATTRIB11_4_NV */ + { 19575, 0x0000866C }, /* GL_MAP1_VERTEX_ATTRIB12_4_NV */ + { 19604, 0x0000866D }, /* GL_MAP1_VERTEX_ATTRIB13_4_NV */ + { 19633, 0x0000866E }, /* GL_MAP1_VERTEX_ATTRIB14_4_NV */ + { 19662, 0x0000866F }, /* GL_MAP1_VERTEX_ATTRIB15_4_NV */ + { 19691, 0x00008661 }, /* GL_MAP1_VERTEX_ATTRIB1_4_NV */ + { 19719, 0x00008662 }, /* GL_MAP1_VERTEX_ATTRIB2_4_NV */ + { 19747, 0x00008663 }, /* GL_MAP1_VERTEX_ATTRIB3_4_NV */ + { 19775, 0x00008664 }, /* GL_MAP1_VERTEX_ATTRIB4_4_NV */ + { 19803, 0x00008665 }, /* GL_MAP1_VERTEX_ATTRIB5_4_NV */ + { 19831, 0x00008666 }, /* GL_MAP1_VERTEX_ATTRIB6_4_NV */ + { 19859, 0x00008667 }, /* GL_MAP1_VERTEX_ATTRIB7_4_NV */ + { 19887, 0x00008668 }, /* GL_MAP1_VERTEX_ATTRIB8_4_NV */ + { 19915, 0x00008669 }, /* GL_MAP1_VERTEX_ATTRIB9_4_NV */ + { 19943, 0x00000DB0 }, /* GL_MAP2_COLOR_4 */ + { 19959, 0x00000DD2 }, /* GL_MAP2_GRID_DOMAIN */ + { 19979, 0x00000DD3 }, /* GL_MAP2_GRID_SEGMENTS */ + { 20001, 0x00000DB1 }, /* GL_MAP2_INDEX */ + { 20015, 0x00000DB2 }, /* GL_MAP2_NORMAL */ + { 20030, 0x00000DB3 }, /* GL_MAP2_TEXTURE_COORD_1 */ + { 20054, 0x00000DB4 }, /* GL_MAP2_TEXTURE_COORD_2 */ + { 20078, 0x00000DB5 }, /* GL_MAP2_TEXTURE_COORD_3 */ + { 20102, 0x00000DB6 }, /* GL_MAP2_TEXTURE_COORD_4 */ + { 20126, 0x00000DB7 }, /* GL_MAP2_VERTEX_3 */ + { 20143, 0x00000DB8 }, /* GL_MAP2_VERTEX_4 */ + { 20160, 0x00008670 }, /* GL_MAP2_VERTEX_ATTRIB0_4_NV */ + { 20188, 0x0000867A }, /* GL_MAP2_VERTEX_ATTRIB10_4_NV */ + { 20217, 0x0000867B }, /* GL_MAP2_VERTEX_ATTRIB11_4_NV */ + { 20246, 0x0000867C }, /* GL_MAP2_VERTEX_ATTRIB12_4_NV */ + { 20275, 0x0000867D }, /* GL_MAP2_VERTEX_ATTRIB13_4_NV */ + { 20304, 0x0000867E }, /* GL_MAP2_VERTEX_ATTRIB14_4_NV */ + { 20333, 0x0000867F }, /* GL_MAP2_VERTEX_ATTRIB15_4_NV */ + { 20362, 0x00008671 }, /* GL_MAP2_VERTEX_ATTRIB1_4_NV */ + { 20390, 0x00008672 }, /* GL_MAP2_VERTEX_ATTRIB2_4_NV */ + { 20418, 0x00008673 }, /* GL_MAP2_VERTEX_ATTRIB3_4_NV */ + { 20446, 0x00008674 }, /* GL_MAP2_VERTEX_ATTRIB4_4_NV */ + { 20474, 0x00008675 }, /* GL_MAP2_VERTEX_ATTRIB5_4_NV */ + { 20502, 0x00008676 }, /* GL_MAP2_VERTEX_ATTRIB6_4_NV */ + { 20530, 0x00008677 }, /* GL_MAP2_VERTEX_ATTRIB7_4_NV */ + { 20558, 0x00008678 }, /* GL_MAP2_VERTEX_ATTRIB8_4_NV */ + { 20586, 0x00008679 }, /* GL_MAP2_VERTEX_ATTRIB9_4_NV */ + { 20614, 0x00000D10 }, /* GL_MAP_COLOR */ + { 20627, 0x00000010 }, /* GL_MAP_FLUSH_EXPLICIT_BIT */ + { 20653, 0x00000008 }, /* GL_MAP_INVALIDATE_BUFFER_BIT */ + { 20682, 0x00000004 }, /* GL_MAP_INVALIDATE_RANGE_BIT */ + { 20710, 0x00000001 }, /* GL_MAP_READ_BIT */ + { 20726, 0x00000D11 }, /* GL_MAP_STENCIL */ + { 20741, 0x00000020 }, /* GL_MAP_UNSYNCHRONIZED_BIT */ + { 20767, 0x00000002 }, /* GL_MAP_WRITE_BIT */ + { 20784, 0x000088C0 }, /* GL_MATRIX0_ARB */ + { 20799, 0x00008630 }, /* GL_MATRIX0_NV */ + { 20813, 0x000088CA }, /* GL_MATRIX10_ARB */ + { 20829, 0x000088CB }, /* GL_MATRIX11_ARB */ + { 20845, 0x000088CC }, /* GL_MATRIX12_ARB */ + { 20861, 0x000088CD }, /* GL_MATRIX13_ARB */ + { 20877, 0x000088CE }, /* GL_MATRIX14_ARB */ + { 20893, 0x000088CF }, /* GL_MATRIX15_ARB */ + { 20909, 0x000088D0 }, /* GL_MATRIX16_ARB */ + { 20925, 0x000088D1 }, /* GL_MATRIX17_ARB */ + { 20941, 0x000088D2 }, /* GL_MATRIX18_ARB */ + { 20957, 0x000088D3 }, /* GL_MATRIX19_ARB */ + { 20973, 0x000088C1 }, /* GL_MATRIX1_ARB */ + { 20988, 0x00008631 }, /* GL_MATRIX1_NV */ + { 21002, 0x000088D4 }, /* GL_MATRIX20_ARB */ + { 21018, 0x000088D5 }, /* GL_MATRIX21_ARB */ + { 21034, 0x000088D6 }, /* GL_MATRIX22_ARB */ + { 21050, 0x000088D7 }, /* GL_MATRIX23_ARB */ + { 21066, 0x000088D8 }, /* GL_MATRIX24_ARB */ + { 21082, 0x000088D9 }, /* GL_MATRIX25_ARB */ + { 21098, 0x000088DA }, /* GL_MATRIX26_ARB */ + { 21114, 0x000088DB }, /* GL_MATRIX27_ARB */ + { 21130, 0x000088DC }, /* GL_MATRIX28_ARB */ + { 21146, 0x000088DD }, /* GL_MATRIX29_ARB */ + { 21162, 0x000088C2 }, /* GL_MATRIX2_ARB */ + { 21177, 0x00008632 }, /* GL_MATRIX2_NV */ + { 21191, 0x000088DE }, /* GL_MATRIX30_ARB */ + { 21207, 0x000088DF }, /* GL_MATRIX31_ARB */ + { 21223, 0x000088C3 }, /* GL_MATRIX3_ARB */ + { 21238, 0x00008633 }, /* GL_MATRIX3_NV */ + { 21252, 0x000088C4 }, /* GL_MATRIX4_ARB */ + { 21267, 0x00008634 }, /* GL_MATRIX4_NV */ + { 21281, 0x000088C5 }, /* GL_MATRIX5_ARB */ + { 21296, 0x00008635 }, /* GL_MATRIX5_NV */ + { 21310, 0x000088C6 }, /* GL_MATRIX6_ARB */ + { 21325, 0x00008636 }, /* GL_MATRIX6_NV */ + { 21339, 0x000088C7 }, /* GL_MATRIX7_ARB */ + { 21354, 0x00008637 }, /* GL_MATRIX7_NV */ + { 21368, 0x000088C8 }, /* GL_MATRIX8_ARB */ + { 21383, 0x000088C9 }, /* GL_MATRIX9_ARB */ + { 21398, 0x00008844 }, /* GL_MATRIX_INDEX_ARRAY_ARB */ + { 21424, 0x00008B9E }, /* GL_MATRIX_INDEX_ARRAY_BUFFER_BINDING_OES */ + { 21465, 0x00008844 }, /* GL_MATRIX_INDEX_ARRAY_OES */ + { 21491, 0x00008849 }, /* GL_MATRIX_INDEX_ARRAY_POINTER_ARB */ + { 21525, 0x00008849 }, /* GL_MATRIX_INDEX_ARRAY_POINTER_OES */ + { 21559, 0x00008846 }, /* GL_MATRIX_INDEX_ARRAY_SIZE_ARB */ + { 21590, 0x00008846 }, /* GL_MATRIX_INDEX_ARRAY_SIZE_OES */ + { 21621, 0x00008848 }, /* GL_MATRIX_INDEX_ARRAY_STRIDE_ARB */ + { 21654, 0x00008848 }, /* GL_MATRIX_INDEX_ARRAY_STRIDE_OES */ + { 21687, 0x00008847 }, /* GL_MATRIX_INDEX_ARRAY_TYPE_ARB */ + { 21718, 0x00008847 }, /* GL_MATRIX_INDEX_ARRAY_TYPE_OES */ + { 21749, 0x00000BA0 }, /* GL_MATRIX_MODE */ + { 21764, 0x00008840 }, /* GL_MATRIX_PALETTE_ARB */ + { 21786, 0x00008840 }, /* GL_MATRIX_PALETTE_OES */ + { 21808, 0x00008008 }, /* GL_MAX */ + { 21815, 0x00008073 }, /* GL_MAX_3D_TEXTURE_SIZE */ + { 21838, 0x00008073 }, /* GL_MAX_3D_TEXTURE_SIZE_OES */ + { 21865, 0x000088FF }, /* GL_MAX_ARRAY_TEXTURE_LAYERS */ + { 21893, 0x000088FF }, /* GL_MAX_ARRAY_TEXTURE_LAYERS_EXT */ + { 21925, 0x00000D35 }, /* GL_MAX_ATTRIB_STACK_DEPTH */ + { 21951, 0x00000D3B }, /* GL_MAX_CLIENT_ATTRIB_STACK_DEPTH */ + { 21984, 0x00008177 }, /* GL_MAX_CLIPMAP_DEPTH_SGIX */ + { 22010, 0x00008178 }, /* GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX */ + { 22044, 0x00000D32 }, /* GL_MAX_CLIP_DISTANCES */ + { 22066, 0x00000D32 }, /* GL_MAX_CLIP_PLANES */ + { 22085, 0x00008CDF }, /* GL_MAX_COLOR_ATTACHMENTS */ + { 22110, 0x00008CDF }, /* GL_MAX_COLOR_ATTACHMENTS_EXT */ + { 22139, 0x000080B3 }, /* GL_MAX_COLOR_MATRIX_STACK_DEPTH */ + { 22171, 0x000080B3 }, /* GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI */ + { 22207, 0x00008B4D }, /* GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS */ + { 22243, 0x00008B4D }, /* GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB */ + { 22283, 0x0000801B }, /* GL_MAX_CONVOLUTION_HEIGHT */ + { 22309, 0x0000801B }, /* GL_MAX_CONVOLUTION_HEIGHT_EXT */ + { 22339, 0x0000801A }, /* GL_MAX_CONVOLUTION_WIDTH */ + { 22364, 0x0000801A }, /* GL_MAX_CONVOLUTION_WIDTH_EXT */ + { 22393, 0x0000851C }, /* GL_MAX_CUBE_MAP_TEXTURE_SIZE */ + { 22422, 0x0000851C }, /* GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB */ + { 22455, 0x0000851C }, /* GL_MAX_CUBE_MAP_TEXTURE_SIZE_OES */ + { 22488, 0x00008824 }, /* GL_MAX_DRAW_BUFFERS */ + { 22508, 0x00008824 }, /* GL_MAX_DRAW_BUFFERS_ARB */ + { 22532, 0x00008824 }, /* GL_MAX_DRAW_BUFFERS_ATI */ + { 22556, 0x000080E9 }, /* GL_MAX_ELEMENTS_INDICES */ + { 22580, 0x000080E8 }, /* GL_MAX_ELEMENTS_VERTICES */ + { 22605, 0x00000D30 }, /* GL_MAX_EVAL_ORDER */ + { 22623, 0x00008008 }, /* GL_MAX_EXT */ + { 22634, 0x00009125 }, /* GL_MAX_FRAGMENT_INPUT_COMPONENTS */ + { 22667, 0x00008B49 }, /* GL_MAX_FRAGMENT_UNIFORM_COMPONENTS */ + { 22702, 0x00008B49 }, /* GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB */ + { 22741, 0x00008DFD }, /* GL_MAX_FRAGMENT_UNIFORM_VECTORS */ + { 22773, 0x00009123 }, /* GL_MAX_GEOMETRY_INPUT_COMPONENTS */ + { 22806, 0x00009124 }, /* GL_MAX_GEOMETRY_OUTPUT_COMPONENTS */ + { 22840, 0x00008DE0 }, /* GL_MAX_GEOMETRY_OUTPUT_VERTICES */ + { 22872, 0x00008DE0 }, /* GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB */ + { 22908, 0x00008C29 }, /* GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS */ + { 22944, 0x00008C29 }, /* GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB */ + { 22984, 0x00008DE1 }, /* GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS */ + { 23024, 0x00008DE1 }, /* GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB */ + { 23068, 0x00008DDF }, /* GL_MAX_GEOMETRY_UNIFORM_COMPONENTS */ + { 23103, 0x00008DDF }, /* GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB */ + { 23142, 0x00008DDD }, /* GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB */ + { 23181, 0x00000D31 }, /* GL_MAX_LIGHTS */ + { 23195, 0x00000B31 }, /* GL_MAX_LIST_NESTING */ + { 23215, 0x00008841 }, /* GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB */ + { 23253, 0x00000D36 }, /* GL_MAX_MODELVIEW_STACK_DEPTH */ + { 23282, 0x00000D37 }, /* GL_MAX_NAME_STACK_DEPTH */ + { 23306, 0x00008842 }, /* GL_MAX_PALETTE_MATRICES_ARB */ + { 23334, 0x00008842 }, /* GL_MAX_PALETTE_MATRICES_OES */ + { 23362, 0x00000D34 }, /* GL_MAX_PIXEL_MAP_TABLE */ + { 23385, 0x000088B1 }, /* GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB */ + { 23422, 0x0000880B }, /* GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB */ + { 23458, 0x000088AD }, /* GL_MAX_PROGRAM_ATTRIBS_ARB */ + { 23485, 0x000088F5 }, /* GL_MAX_PROGRAM_CALL_DEPTH_NV */ + { 23514, 0x000088B5 }, /* GL_MAX_PROGRAM_ENV_PARAMETERS_ARB */ + { 23548, 0x000088F4 }, /* GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV */ + { 23584, 0x000088F6 }, /* GL_MAX_PROGRAM_IF_DEPTH_NV */ + { 23611, 0x000088A1 }, /* GL_MAX_PROGRAM_INSTRUCTIONS_ARB */ + { 23643, 0x000088B4 }, /* GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB */ + { 23679, 0x000088F8 }, /* GL_MAX_PROGRAM_LOOP_COUNT_NV */ + { 23708, 0x000088F7 }, /* GL_MAX_PROGRAM_LOOP_DEPTH_NV */ + { 23737, 0x0000862F }, /* GL_MAX_PROGRAM_MATRICES_ARB */ + { 23765, 0x0000862E }, /* GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB */ + { 23803, 0x000088B3 }, /* GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB */ + { 23847, 0x0000880E }, /* GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB */ + { 23890, 0x000088AF }, /* GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB */ + { 23924, 0x000088A3 }, /* GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB */ + { 23963, 0x000088AB }, /* GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB */ + { 24000, 0x000088A7 }, /* GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB */ + { 24038, 0x00008810 }, /* GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB */ + { 24081, 0x0000880F }, /* GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB */ + { 24124, 0x000088A9 }, /* GL_MAX_PROGRAM_PARAMETERS_ARB */ + { 24154, 0x000088A5 }, /* GL_MAX_PROGRAM_TEMPORARIES_ARB */ + { 24185, 0x00008905 }, /* GL_MAX_PROGRAM_TEXEL_OFFSET */ + { 24213, 0x00008905 }, /* GL_MAX_PROGRAM_TEXEL_OFFSET_EXT */ + { 24245, 0x0000880D }, /* GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB */ + { 24281, 0x0000880C }, /* GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB */ + { 24317, 0x00000D38 }, /* GL_MAX_PROJECTION_STACK_DEPTH */ + { 24347, 0x000084F8 }, /* GL_MAX_RECTANGLE_TEXTURE_SIZE */ + { 24377, 0x000084F8 }, /* GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB */ + { 24411, 0x000084F8 }, /* GL_MAX_RECTANGLE_TEXTURE_SIZE_NV */ + { 24444, 0x000084E8 }, /* GL_MAX_RENDERBUFFER_SIZE */ + { 24469, 0x000084E8 }, /* GL_MAX_RENDERBUFFER_SIZE_EXT */ + { 24498, 0x000084E8 }, /* GL_MAX_RENDERBUFFER_SIZE_OES */ + { 24527, 0x00008D57 }, /* GL_MAX_SAMPLES */ + { 24542, 0x00008D57 }, /* GL_MAX_SAMPLES_EXT */ + { 24561, 0x00009111 }, /* GL_MAX_SERVER_WAIT_TIMEOUT */ + { 24588, 0x00008504 }, /* GL_MAX_SHININESS_NV */ + { 24608, 0x00008505 }, /* GL_MAX_SPOT_EXPONENT_NV */ + { 24632, 0x00008C2B }, /* GL_MAX_TEXTURE_BUFFER_SIZE */ + { 24659, 0x00008C2B }, /* GL_MAX_TEXTURE_BUFFER_SIZE_ARB */ + { 24690, 0x00008871 }, /* GL_MAX_TEXTURE_COORDS */ + { 24712, 0x00008871 }, /* GL_MAX_TEXTURE_COORDS_ARB */ + { 24738, 0x00008872 }, /* GL_MAX_TEXTURE_IMAGE_UNITS */ + { 24765, 0x00008872 }, /* GL_MAX_TEXTURE_IMAGE_UNITS_ARB */ + { 24796, 0x000084FD }, /* GL_MAX_TEXTURE_LOD_BIAS */ + { 24820, 0x000084FD }, /* GL_MAX_TEXTURE_LOD_BIAS_EXT */ + { 24848, 0x000084FF }, /* GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT */ + { 24882, 0x00000D33 }, /* GL_MAX_TEXTURE_SIZE */ + { 24902, 0x00000D39 }, /* GL_MAX_TEXTURE_STACK_DEPTH */ + { 24929, 0x000084E2 }, /* GL_MAX_TEXTURE_UNITS */ + { 24950, 0x000084E2 }, /* GL_MAX_TEXTURE_UNITS_ARB */ + { 24975, 0x0000862F }, /* GL_MAX_TRACK_MATRICES_NV */ + { 25000, 0x0000862E }, /* GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV */ + { 25035, 0x00008C8A }, /* GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS */ + { 25084, 0x00008C8A }, /* GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_EXT */ + { 25137, 0x00008C8B }, /* GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS */ + { 25180, 0x00008C8B }, /* GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_EXT */ + { 25227, 0x00008C80 }, /* GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS */ + { 25273, 0x00008C80 }, /* GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_EXT */ + { 25323, 0x00008B4B }, /* GL_MAX_VARYING_COMPONENTS */ + { 25349, 0x00008B4B }, /* GL_MAX_VARYING_FLOATS */ + { 25371, 0x00008B4B }, /* GL_MAX_VARYING_FLOATS_ARB */ + { 25397, 0x00008DFC }, /* GL_MAX_VARYING_VECTORS */ + { 25420, 0x00008869 }, /* GL_MAX_VERTEX_ATTRIBS */ + { 25442, 0x00008869 }, /* GL_MAX_VERTEX_ATTRIBS_ARB */ + { 25468, 0x00009122 }, /* GL_MAX_VERTEX_OUTPUT_COMPONENTS */ + { 25500, 0x00008B4C }, /* GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS */ + { 25534, 0x00008B4C }, /* GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB */ + { 25572, 0x00008B4A }, /* GL_MAX_VERTEX_UNIFORM_COMPONENTS */ + { 25605, 0x00008B4A }, /* GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB */ + { 25642, 0x00008DFB }, /* GL_MAX_VERTEX_UNIFORM_VECTORS */ + { 25672, 0x000086A4 }, /* GL_MAX_VERTEX_UNITS_ARB */ + { 25696, 0x000086A4 }, /* GL_MAX_VERTEX_UNITS_OES */ + { 25720, 0x00008DDE }, /* GL_MAX_VERTEX_VARYING_COMPONENTS_ARB */ + { 25757, 0x00000D3A }, /* GL_MAX_VIEWPORT_DIMS */ + { 25778, 0x00008DF1 }, /* GL_MEDIUM_FLOAT */ + { 25794, 0x00008DF4 }, /* GL_MEDIUM_INT */ + { 25808, 0x00008007 }, /* GL_MIN */ + { 25815, 0x0000802E }, /* GL_MINMAX */ + { 25825, 0x0000802E }, /* GL_MINMAX_EXT */ + { 25839, 0x0000802F }, /* GL_MINMAX_FORMAT */ + { 25856, 0x0000802F }, /* GL_MINMAX_FORMAT_EXT */ + { 25877, 0x00008030 }, /* GL_MINMAX_SINK */ + { 25892, 0x00008030 }, /* GL_MINMAX_SINK_EXT */ + { 25911, 0x0000821C }, /* GL_MINOR_VERSION */ + { 25928, 0x00008007 }, /* GL_MIN_EXT */ + { 25939, 0x00008904 }, /* GL_MIN_PROGRAM_TEXEL_OFFSET */ + { 25967, 0x00008904 }, /* GL_MIN_PROGRAM_TEXEL_OFFSET_EXT */ + { 25999, 0x00008370 }, /* GL_MIRRORED_REPEAT */ + { 26018, 0x00008370 }, /* GL_MIRRORED_REPEAT_ARB */ + { 26041, 0x00008370 }, /* GL_MIRRORED_REPEAT_IBM */ + { 26064, 0x00008742 }, /* GL_MIRROR_CLAMP_ATI */ + { 26084, 0x00008742 }, /* GL_MIRROR_CLAMP_EXT */ + { 26104, 0x00008912 }, /* GL_MIRROR_CLAMP_TO_BORDER_EXT */ + { 26134, 0x00008743 }, /* GL_MIRROR_CLAMP_TO_EDGE_ATI */ + { 26162, 0x00008743 }, /* GL_MIRROR_CLAMP_TO_EDGE_EXT */ + { 26190, 0x00001700 }, /* GL_MODELVIEW */ + { 26203, 0x00001700 }, /* GL_MODELVIEW0_ARB */ + { 26221, 0x0000872A }, /* GL_MODELVIEW10_ARB */ + { 26240, 0x0000872B }, /* GL_MODELVIEW11_ARB */ + { 26259, 0x0000872C }, /* GL_MODELVIEW12_ARB */ + { 26278, 0x0000872D }, /* GL_MODELVIEW13_ARB */ + { 26297, 0x0000872E }, /* GL_MODELVIEW14_ARB */ + { 26316, 0x0000872F }, /* GL_MODELVIEW15_ARB */ + { 26335, 0x00008730 }, /* GL_MODELVIEW16_ARB */ + { 26354, 0x00008731 }, /* GL_MODELVIEW17_ARB */ + { 26373, 0x00008732 }, /* GL_MODELVIEW18_ARB */ + { 26392, 0x00008733 }, /* GL_MODELVIEW19_ARB */ + { 26411, 0x0000850A }, /* GL_MODELVIEW1_ARB */ + { 26429, 0x00008734 }, /* GL_MODELVIEW20_ARB */ + { 26448, 0x00008735 }, /* GL_MODELVIEW21_ARB */ + { 26467, 0x00008736 }, /* GL_MODELVIEW22_ARB */ + { 26486, 0x00008737 }, /* GL_MODELVIEW23_ARB */ + { 26505, 0x00008738 }, /* GL_MODELVIEW24_ARB */ + { 26524, 0x00008739 }, /* GL_MODELVIEW25_ARB */ + { 26543, 0x0000873A }, /* GL_MODELVIEW26_ARB */ + { 26562, 0x0000873B }, /* GL_MODELVIEW27_ARB */ + { 26581, 0x0000873C }, /* GL_MODELVIEW28_ARB */ + { 26600, 0x0000873D }, /* GL_MODELVIEW29_ARB */ + { 26619, 0x00008722 }, /* GL_MODELVIEW2_ARB */ + { 26637, 0x0000873E }, /* GL_MODELVIEW30_ARB */ + { 26656, 0x0000873F }, /* GL_MODELVIEW31_ARB */ + { 26675, 0x00008723 }, /* GL_MODELVIEW3_ARB */ + { 26693, 0x00008724 }, /* GL_MODELVIEW4_ARB */ + { 26711, 0x00008725 }, /* GL_MODELVIEW5_ARB */ + { 26729, 0x00008726 }, /* GL_MODELVIEW6_ARB */ + { 26747, 0x00008727 }, /* GL_MODELVIEW7_ARB */ + { 26765, 0x00008728 }, /* GL_MODELVIEW8_ARB */ + { 26783, 0x00008729 }, /* GL_MODELVIEW9_ARB */ + { 26801, 0x00000BA6 }, /* GL_MODELVIEW_MATRIX */ + { 26821, 0x0000898D }, /* GL_MODELVIEW_MATRIX_FLOAT_AS_INT_BITS_OES */ + { 26863, 0x00008629 }, /* GL_MODELVIEW_PROJECTION_NV */ + { 26890, 0x00000BA3 }, /* GL_MODELVIEW_STACK_DEPTH */ + { 26915, 0x00002100 }, /* GL_MODULATE */ + { 26927, 0x00008744 }, /* GL_MODULATE_ADD_ATI */ + { 26947, 0x00008745 }, /* GL_MODULATE_SIGNED_ADD_ATI */ + { 26974, 0x00008746 }, /* GL_MODULATE_SUBTRACT_ATI */ + { 26999, 0x00000103 }, /* GL_MULT */ + { 27007, 0x0000809D }, /* GL_MULTISAMPLE */ + { 27022, 0x000086B2 }, /* GL_MULTISAMPLE_3DFX */ + { 27042, 0x0000809D }, /* GL_MULTISAMPLE_ARB */ + { 27061, 0x20000000 }, /* GL_MULTISAMPLE_BIT */ + { 27080, 0x20000000 }, /* GL_MULTISAMPLE_BIT_3DFX */ + { 27104, 0x20000000 }, /* GL_MULTISAMPLE_BIT_ARB */ + { 27127, 0x00008534 }, /* GL_MULTISAMPLE_FILTER_HINT_NV */ + { 27157, 0x00002A25 }, /* GL_N3F_V3F */ + { 27168, 0x00000D70 }, /* GL_NAME_STACK_DEPTH */ + { 27188, 0x0000150E }, /* GL_NAND */ + { 27196, 0x00002600 }, /* GL_NEAREST */ + { 27207, 0x0000844E }, /* GL_NEAREST_CLIPMAP_LINEAR_SGIX */ + { 27238, 0x0000844D }, /* GL_NEAREST_CLIPMAP_NEAREST_SGIX */ + { 27270, 0x00002702 }, /* GL_NEAREST_MIPMAP_LINEAR */ + { 27295, 0x00002700 }, /* GL_NEAREST_MIPMAP_NEAREST */ + { 27321, 0x00000200 }, /* GL_NEVER */ + { 27330, 0x00001102 }, /* GL_NICEST */ + { 27340, 0x00000000 }, /* GL_NONE */ + { 27348, 0x00000000 }, /* GL_NONE_OES */ + { 27360, 0x00001505 }, /* GL_NOOP */ + { 27368, 0x00001508 }, /* GL_NOR */ + { 27375, 0x00000BA1 }, /* GL_NORMALIZE */ + { 27388, 0x00008075 }, /* GL_NORMAL_ARRAY */ + { 27404, 0x00008897 }, /* GL_NORMAL_ARRAY_BUFFER_BINDING */ + { 27435, 0x00008897 }, /* GL_NORMAL_ARRAY_BUFFER_BINDING_ARB */ + { 27470, 0x0000808F }, /* GL_NORMAL_ARRAY_POINTER */ + { 27494, 0x0000807F }, /* GL_NORMAL_ARRAY_STRIDE */ + { 27517, 0x0000807E }, /* GL_NORMAL_ARRAY_TYPE */ + { 27538, 0x00008511 }, /* GL_NORMAL_MAP */ + { 27552, 0x00008511 }, /* GL_NORMAL_MAP_ARB */ + { 27570, 0x00008511 }, /* GL_NORMAL_MAP_NV */ + { 27587, 0x00008511 }, /* GL_NORMAL_MAP_OES */ + { 27605, 0x00000205 }, /* GL_NOTEQUAL */ + { 27617, 0x00000000 }, /* GL_NO_ERROR */ + { 27629, 0x00008261 }, /* GL_NO_RESET_NOTIFICATION_ARB */ + { 27658, 0x000086A2 }, /* GL_NUM_COMPRESSED_TEXTURE_FORMATS */ + { 27692, 0x000086A2 }, /* GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB */ + { 27730, 0x0000821D }, /* GL_NUM_EXTENSIONS */ + { 27748, 0x000087FE }, /* GL_NUM_PROGRAM_BINARY_FORMATS */ + { 27778, 0x000087FE }, /* GL_NUM_PROGRAM_BINARY_FORMATS_OES */ + { 27812, 0x00008DF9 }, /* GL_NUM_SHADER_BINARY_FORMATS */ + { 27841, 0x00008B89 }, /* GL_OBJECT_ACTIVE_ATTRIBUTES_ARB */ + { 27873, 0x00008B8A }, /* GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB */ + { 27915, 0x00008B86 }, /* GL_OBJECT_ACTIVE_UNIFORMS_ARB */ + { 27945, 0x00008B87 }, /* GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB */ + { 27985, 0x00008B85 }, /* GL_OBJECT_ATTACHED_OBJECTS_ARB */ + { 28016, 0x00008B81 }, /* GL_OBJECT_COMPILE_STATUS_ARB */ + { 28045, 0x00008B80 }, /* GL_OBJECT_DELETE_STATUS_ARB */ + { 28073, 0x00008B84 }, /* GL_OBJECT_INFO_LOG_LENGTH_ARB */ + { 28103, 0x00002401 }, /* GL_OBJECT_LINEAR */ + { 28120, 0x00008B82 }, /* GL_OBJECT_LINK_STATUS_ARB */ + { 28146, 0x00002501 }, /* GL_OBJECT_PLANE */ + { 28162, 0x00008B88 }, /* GL_OBJECT_SHADER_SOURCE_LENGTH_ARB */ + { 28197, 0x00008B4F }, /* GL_OBJECT_SUBTYPE_ARB */ + { 28219, 0x00009112 }, /* GL_OBJECT_TYPE */ + { 28234, 0x00008B4E }, /* GL_OBJECT_TYPE_ARB */ + { 28253, 0x00008B83 }, /* GL_OBJECT_VALIDATE_STATUS_ARB */ + { 28283, 0x00008165 }, /* GL_OCCLUSION_TEST_HP */ + { 28304, 0x00008166 }, /* GL_OCCLUSION_TEST_RESULT_HP */ + { 28332, 0x00000001 }, /* GL_ONE */ + { 28339, 0x00008004 }, /* GL_ONE_MINUS_CONSTANT_ALPHA */ + { 28367, 0x00008004 }, /* GL_ONE_MINUS_CONSTANT_ALPHA_EXT */ + { 28399, 0x00008002 }, /* GL_ONE_MINUS_CONSTANT_COLOR */ + { 28427, 0x00008002 }, /* GL_ONE_MINUS_CONSTANT_COLOR_EXT */ + { 28459, 0x00000305 }, /* GL_ONE_MINUS_DST_ALPHA */ + { 28482, 0x00000307 }, /* GL_ONE_MINUS_DST_COLOR */ + { 28505, 0x00000303 }, /* GL_ONE_MINUS_SRC_ALPHA */ + { 28528, 0x00000301 }, /* GL_ONE_MINUS_SRC_COLOR */ + { 28551, 0x00008598 }, /* GL_OPERAND0_ALPHA */ + { 28569, 0x00008598 }, /* GL_OPERAND0_ALPHA_ARB */ + { 28591, 0x00008598 }, /* GL_OPERAND0_ALPHA_EXT */ + { 28613, 0x00008590 }, /* GL_OPERAND0_RGB */ + { 28629, 0x00008590 }, /* GL_OPERAND0_RGB_ARB */ + { 28649, 0x00008590 }, /* GL_OPERAND0_RGB_EXT */ + { 28669, 0x00008599 }, /* GL_OPERAND1_ALPHA */ + { 28687, 0x00008599 }, /* GL_OPERAND1_ALPHA_ARB */ + { 28709, 0x00008599 }, /* GL_OPERAND1_ALPHA_EXT */ + { 28731, 0x00008591 }, /* GL_OPERAND1_RGB */ + { 28747, 0x00008591 }, /* GL_OPERAND1_RGB_ARB */ + { 28767, 0x00008591 }, /* GL_OPERAND1_RGB_EXT */ + { 28787, 0x0000859A }, /* GL_OPERAND2_ALPHA */ + { 28805, 0x0000859A }, /* GL_OPERAND2_ALPHA_ARB */ + { 28827, 0x0000859A }, /* GL_OPERAND2_ALPHA_EXT */ + { 28849, 0x00008592 }, /* GL_OPERAND2_RGB */ + { 28865, 0x00008592 }, /* GL_OPERAND2_RGB_ARB */ + { 28885, 0x00008592 }, /* GL_OPERAND2_RGB_EXT */ + { 28905, 0x0000859B }, /* GL_OPERAND3_ALPHA_NV */ + { 28926, 0x00008593 }, /* GL_OPERAND3_RGB_NV */ + { 28945, 0x00001507 }, /* GL_OR */ + { 28951, 0x00000A01 }, /* GL_ORDER */ + { 28960, 0x0000150D }, /* GL_OR_INVERTED */ + { 28975, 0x0000150B }, /* GL_OR_REVERSE */ + { 28989, 0x00000505 }, /* GL_OUT_OF_MEMORY */ + { 29006, 0x00000D05 }, /* GL_PACK_ALIGNMENT */ + { 29024, 0x0000806C }, /* GL_PACK_IMAGE_HEIGHT */ + { 29045, 0x00008758 }, /* GL_PACK_INVERT_MESA */ + { 29065, 0x00000D01 }, /* GL_PACK_LSB_FIRST */ + { 29083, 0x00000D02 }, /* GL_PACK_ROW_LENGTH */ + { 29102, 0x0000806B }, /* GL_PACK_SKIP_IMAGES */ + { 29122, 0x00000D04 }, /* GL_PACK_SKIP_PIXELS */ + { 29142, 0x00000D03 }, /* GL_PACK_SKIP_ROWS */ + { 29160, 0x00000D00 }, /* GL_PACK_SWAP_BYTES */ + { 29179, 0x00008B92 }, /* GL_PALETTE4_R5_G6_B5_OES */ + { 29204, 0x00008B94 }, /* GL_PALETTE4_RGB5_A1_OES */ + { 29228, 0x00008B90 }, /* GL_PALETTE4_RGB8_OES */ + { 29249, 0x00008B93 }, /* GL_PALETTE4_RGBA4_OES */ + { 29271, 0x00008B91 }, /* GL_PALETTE4_RGBA8_OES */ + { 29293, 0x00008B97 }, /* GL_PALETTE8_R5_G6_B5_OES */ + { 29318, 0x00008B99 }, /* GL_PALETTE8_RGB5_A1_OES */ + { 29342, 0x00008B95 }, /* GL_PALETTE8_RGB8_OES */ + { 29363, 0x00008B98 }, /* GL_PALETTE8_RGBA4_OES */ + { 29385, 0x00008B96 }, /* GL_PALETTE8_RGBA8_OES */ + { 29407, 0x00000700 }, /* GL_PASS_THROUGH_TOKEN */ + { 29429, 0x00000C50 }, /* GL_PERSPECTIVE_CORRECTION_HINT */ + { 29460, 0x00000C79 }, /* GL_PIXEL_MAP_A_TO_A */ + { 29480, 0x00000CB9 }, /* GL_PIXEL_MAP_A_TO_A_SIZE */ + { 29505, 0x00000C78 }, /* GL_PIXEL_MAP_B_TO_B */ + { 29525, 0x00000CB8 }, /* GL_PIXEL_MAP_B_TO_B_SIZE */ + { 29550, 0x00000C77 }, /* GL_PIXEL_MAP_G_TO_G */ + { 29570, 0x00000CB7 }, /* GL_PIXEL_MAP_G_TO_G_SIZE */ + { 29595, 0x00000C75 }, /* GL_PIXEL_MAP_I_TO_A */ + { 29615, 0x00000CB5 }, /* GL_PIXEL_MAP_I_TO_A_SIZE */ + { 29640, 0x00000C74 }, /* GL_PIXEL_MAP_I_TO_B */ + { 29660, 0x00000CB4 }, /* GL_PIXEL_MAP_I_TO_B_SIZE */ + { 29685, 0x00000C73 }, /* GL_PIXEL_MAP_I_TO_G */ + { 29705, 0x00000CB3 }, /* GL_PIXEL_MAP_I_TO_G_SIZE */ + { 29730, 0x00000C70 }, /* GL_PIXEL_MAP_I_TO_I */ + { 29750, 0x00000CB0 }, /* GL_PIXEL_MAP_I_TO_I_SIZE */ + { 29775, 0x00000C72 }, /* GL_PIXEL_MAP_I_TO_R */ + { 29795, 0x00000CB2 }, /* GL_PIXEL_MAP_I_TO_R_SIZE */ + { 29820, 0x00000C76 }, /* GL_PIXEL_MAP_R_TO_R */ + { 29840, 0x00000CB6 }, /* GL_PIXEL_MAP_R_TO_R_SIZE */ + { 29865, 0x00000C71 }, /* GL_PIXEL_MAP_S_TO_S */ + { 29885, 0x00000CB1 }, /* GL_PIXEL_MAP_S_TO_S_SIZE */ + { 29910, 0x00000020 }, /* GL_PIXEL_MODE_BIT */ + { 29928, 0x000088EB }, /* GL_PIXEL_PACK_BUFFER */ + { 29949, 0x000088ED }, /* GL_PIXEL_PACK_BUFFER_BINDING */ + { 29978, 0x000088ED }, /* GL_PIXEL_PACK_BUFFER_BINDING_EXT */ + { 30011, 0x000088EB }, /* GL_PIXEL_PACK_BUFFER_EXT */ + { 30036, 0x000088EC }, /* GL_PIXEL_UNPACK_BUFFER */ + { 30059, 0x000088EF }, /* GL_PIXEL_UNPACK_BUFFER_BINDING */ + { 30090, 0x000088EF }, /* GL_PIXEL_UNPACK_BUFFER_BINDING_EXT */ + { 30125, 0x000088EC }, /* GL_PIXEL_UNPACK_BUFFER_EXT */ + { 30152, 0x00001B00 }, /* GL_POINT */ + { 30161, 0x00000000 }, /* GL_POINTS */ + { 30171, 0x00000002 }, /* GL_POINT_BIT */ + { 30184, 0x00008129 }, /* GL_POINT_DISTANCE_ATTENUATION */ + { 30214, 0x00008129 }, /* GL_POINT_DISTANCE_ATTENUATION_ARB */ + { 30248, 0x00008129 }, /* GL_POINT_DISTANCE_ATTENUATION_EXT */ + { 30282, 0x00008129 }, /* GL_POINT_DISTANCE_ATTENUATION_SGIS */ + { 30317, 0x00008128 }, /* GL_POINT_FADE_THRESHOLD_SIZE */ + { 30346, 0x00008128 }, /* GL_POINT_FADE_THRESHOLD_SIZE_ARB */ + { 30379, 0x00008128 }, /* GL_POINT_FADE_THRESHOLD_SIZE_EXT */ + { 30412, 0x00008128 }, /* GL_POINT_FADE_THRESHOLD_SIZE_SGIS */ + { 30446, 0x00000B11 }, /* GL_POINT_SIZE */ + { 30460, 0x00008B9F }, /* GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES */ + { 30499, 0x00008B9C }, /* GL_POINT_SIZE_ARRAY_OES */ + { 30523, 0x0000898C }, /* GL_POINT_SIZE_ARRAY_POINTER_OES */ + { 30555, 0x0000898B }, /* GL_POINT_SIZE_ARRAY_STRIDE_OES */ + { 30586, 0x0000898A }, /* GL_POINT_SIZE_ARRAY_TYPE_OES */ + { 30615, 0x00000B13 }, /* GL_POINT_SIZE_GRANULARITY */ + { 30641, 0x00008127 }, /* GL_POINT_SIZE_MAX */ + { 30659, 0x00008127 }, /* GL_POINT_SIZE_MAX_ARB */ + { 30681, 0x00008127 }, /* GL_POINT_SIZE_MAX_EXT */ + { 30703, 0x00008127 }, /* GL_POINT_SIZE_MAX_SGIS */ + { 30726, 0x00008126 }, /* GL_POINT_SIZE_MIN */ + { 30744, 0x00008126 }, /* GL_POINT_SIZE_MIN_ARB */ + { 30766, 0x00008126 }, /* GL_POINT_SIZE_MIN_EXT */ + { 30788, 0x00008126 }, /* GL_POINT_SIZE_MIN_SGIS */ + { 30811, 0x00000B12 }, /* GL_POINT_SIZE_RANGE */ + { 30831, 0x00000B10 }, /* GL_POINT_SMOOTH */ + { 30847, 0x00000C51 }, /* GL_POINT_SMOOTH_HINT */ + { 30868, 0x00008861 }, /* GL_POINT_SPRITE */ + { 30884, 0x00008861 }, /* GL_POINT_SPRITE_ARB */ + { 30904, 0x00008CA0 }, /* GL_POINT_SPRITE_COORD_ORIGIN */ + { 30933, 0x00008861 }, /* GL_POINT_SPRITE_NV */ + { 30952, 0x00008861 }, /* GL_POINT_SPRITE_OES */ + { 30972, 0x00008863 }, /* GL_POINT_SPRITE_R_MODE_NV */ + { 30998, 0x00000701 }, /* GL_POINT_TOKEN */ + { 31013, 0x00000009 }, /* GL_POLYGON */ + { 31024, 0x00000008 }, /* GL_POLYGON_BIT */ + { 31039, 0x00000B40 }, /* GL_POLYGON_MODE */ + { 31055, 0x00008039 }, /* GL_POLYGON_OFFSET_BIAS */ + { 31078, 0x00008038 }, /* GL_POLYGON_OFFSET_FACTOR */ + { 31103, 0x00008037 }, /* GL_POLYGON_OFFSET_FILL */ + { 31126, 0x00002A02 }, /* GL_POLYGON_OFFSET_LINE */ + { 31149, 0x00002A01 }, /* GL_POLYGON_OFFSET_POINT */ + { 31173, 0x00002A00 }, /* GL_POLYGON_OFFSET_UNITS */ + { 31197, 0x00000B41 }, /* GL_POLYGON_SMOOTH */ + { 31215, 0x00000C53 }, /* GL_POLYGON_SMOOTH_HINT */ + { 31238, 0x00000B42 }, /* GL_POLYGON_STIPPLE */ + { 31257, 0x00000010 }, /* GL_POLYGON_STIPPLE_BIT */ + { 31280, 0x00000703 }, /* GL_POLYGON_TOKEN */ + { 31297, 0x00001203 }, /* GL_POSITION */ + { 31309, 0x000080BB }, /* GL_POST_COLOR_MATRIX_ALPHA_BIAS */ + { 31341, 0x000080BB }, /* GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI */ + { 31377, 0x000080B7 }, /* GL_POST_COLOR_MATRIX_ALPHA_SCALE */ + { 31410, 0x000080B7 }, /* GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI */ + { 31447, 0x000080BA }, /* GL_POST_COLOR_MATRIX_BLUE_BIAS */ + { 31478, 0x000080BA }, /* GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI */ + { 31513, 0x000080B6 }, /* GL_POST_COLOR_MATRIX_BLUE_SCALE */ + { 31545, 0x000080B6 }, /* GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI */ + { 31581, 0x000080D2 }, /* GL_POST_COLOR_MATRIX_COLOR_TABLE */ + { 31614, 0x000080B9 }, /* GL_POST_COLOR_MATRIX_GREEN_BIAS */ + { 31646, 0x000080B9 }, /* GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI */ + { 31682, 0x000080B5 }, /* GL_POST_COLOR_MATRIX_GREEN_SCALE */ + { 31715, 0x000080B5 }, /* GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI */ + { 31752, 0x000080B8 }, /* GL_POST_COLOR_MATRIX_RED_BIAS */ + { 31782, 0x000080B8 }, /* GL_POST_COLOR_MATRIX_RED_BIAS_SGI */ + { 31816, 0x000080B4 }, /* GL_POST_COLOR_MATRIX_RED_SCALE */ + { 31847, 0x000080B4 }, /* GL_POST_COLOR_MATRIX_RED_SCALE_SGI */ + { 31882, 0x00008023 }, /* GL_POST_CONVOLUTION_ALPHA_BIAS */ + { 31913, 0x00008023 }, /* GL_POST_CONVOLUTION_ALPHA_BIAS_EXT */ + { 31948, 0x0000801F }, /* GL_POST_CONVOLUTION_ALPHA_SCALE */ + { 31980, 0x0000801F }, /* GL_POST_CONVOLUTION_ALPHA_SCALE_EXT */ + { 32016, 0x00008022 }, /* GL_POST_CONVOLUTION_BLUE_BIAS */ + { 32046, 0x00008022 }, /* GL_POST_CONVOLUTION_BLUE_BIAS_EXT */ + { 32080, 0x0000801E }, /* GL_POST_CONVOLUTION_BLUE_SCALE */ + { 32111, 0x0000801E }, /* GL_POST_CONVOLUTION_BLUE_SCALE_EXT */ + { 32146, 0x000080D1 }, /* GL_POST_CONVOLUTION_COLOR_TABLE */ + { 32178, 0x00008021 }, /* GL_POST_CONVOLUTION_GREEN_BIAS */ + { 32209, 0x00008021 }, /* GL_POST_CONVOLUTION_GREEN_BIAS_EXT */ + { 32244, 0x0000801D }, /* GL_POST_CONVOLUTION_GREEN_SCALE */ + { 32276, 0x0000801D }, /* GL_POST_CONVOLUTION_GREEN_SCALE_EXT */ + { 32312, 0x00008020 }, /* GL_POST_CONVOLUTION_RED_BIAS */ + { 32341, 0x00008020 }, /* GL_POST_CONVOLUTION_RED_BIAS_EXT */ + { 32374, 0x0000801C }, /* GL_POST_CONVOLUTION_RED_SCALE */ + { 32404, 0x0000801C }, /* GL_POST_CONVOLUTION_RED_SCALE_EXT */ + { 32438, 0x0000817B }, /* GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX */ + { 32477, 0x00008179 }, /* GL_POST_TEXTURE_FILTER_BIAS_SGIX */ + { 32510, 0x0000817C }, /* GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX */ + { 32550, 0x0000817A }, /* GL_POST_TEXTURE_FILTER_SCALE_SGIX */ + { 32584, 0x00008578 }, /* GL_PREVIOUS */ + { 32596, 0x00008578 }, /* GL_PREVIOUS_ARB */ + { 32612, 0x00008578 }, /* GL_PREVIOUS_EXT */ + { 32628, 0x00008577 }, /* GL_PRIMARY_COLOR */ + { 32645, 0x00008577 }, /* GL_PRIMARY_COLOR_ARB */ + { 32666, 0x00008577 }, /* GL_PRIMARY_COLOR_EXT */ + { 32687, 0x00008C87 }, /* GL_PRIMITIVES_GENERATED */ + { 32711, 0x00008C87 }, /* GL_PRIMITIVES_GENERATED_EXT */ + { 32739, 0x00008F9D }, /* GL_PRIMITIVE_RESTART */ + { 32760, 0x00008F9E }, /* GL_PRIMITIVE_RESTART_INDEX */ + { 32787, 0x00008559 }, /* GL_PRIMITIVE_RESTART_INDEX_NV */ + { 32817, 0x00008558 }, /* GL_PRIMITIVE_RESTART_NV */ + { 32841, 0x000088B0 }, /* GL_PROGRAM_ADDRESS_REGISTERS_ARB */ + { 32874, 0x00008805 }, /* GL_PROGRAM_ALU_INSTRUCTIONS_ARB */ + { 32906, 0x000088AC }, /* GL_PROGRAM_ATTRIBS_ARB */ + { 32929, 0x000087FF }, /* GL_PROGRAM_BINARY_FORMATS */ + { 32955, 0x000087FF }, /* GL_PROGRAM_BINARY_FORMATS_OES */ + { 32985, 0x00008741 }, /* GL_PROGRAM_BINARY_LENGTH */ + { 33010, 0x00008741 }, /* GL_PROGRAM_BINARY_LENGTH_OES */ + { 33039, 0x00008257 }, /* GL_PROGRAM_BINARY_RETRIEVABLE_HINT */ + { 33074, 0x00008677 }, /* GL_PROGRAM_BINDING_ARB */ + { 33097, 0x0000864B }, /* GL_PROGRAM_ERROR_POSITION_ARB */ + { 33127, 0x0000864B }, /* GL_PROGRAM_ERROR_POSITION_NV */ + { 33156, 0x00008874 }, /* GL_PROGRAM_ERROR_STRING_ARB */ + { 33184, 0x00008876 }, /* GL_PROGRAM_FORMAT_ARB */ + { 33206, 0x00008875 }, /* GL_PROGRAM_FORMAT_ASCII_ARB */ + { 33234, 0x000088A0 }, /* GL_PROGRAM_INSTRUCTIONS_ARB */ + { 33262, 0x00008627 }, /* GL_PROGRAM_LENGTH_ARB */ + { 33284, 0x00008627 }, /* GL_PROGRAM_LENGTH_NV */ + { 33305, 0x000088B2 }, /* GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB */ + { 33345, 0x00008808 }, /* GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB */ + { 33384, 0x000088AE }, /* GL_PROGRAM_NATIVE_ATTRIBS_ARB */ + { 33414, 0x000088A2 }, /* GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB */ + { 33449, 0x000088AA }, /* GL_PROGRAM_NATIVE_PARAMETERS_ARB */ + { 33482, 0x000088A6 }, /* GL_PROGRAM_NATIVE_TEMPORARIES_ARB */ + { 33516, 0x0000880A }, /* GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB */ + { 33555, 0x00008809 }, /* GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB */ + { 33594, 0x00008B40 }, /* GL_PROGRAM_OBJECT_ARB */ + { 33616, 0x000088A8 }, /* GL_PROGRAM_PARAMETERS_ARB */ + { 33642, 0x00008644 }, /* GL_PROGRAM_PARAMETER_NV */ + { 33666, 0x00008642 }, /* GL_PROGRAM_POINT_SIZE */ + { 33688, 0x00008642 }, /* GL_PROGRAM_POINT_SIZE_ARB */ + { 33714, 0x00008647 }, /* GL_PROGRAM_RESIDENT_NV */ + { 33737, 0x00008628 }, /* GL_PROGRAM_STRING_ARB */ + { 33759, 0x00008628 }, /* GL_PROGRAM_STRING_NV */ + { 33780, 0x00008646 }, /* GL_PROGRAM_TARGET_NV */ + { 33801, 0x000088A4 }, /* GL_PROGRAM_TEMPORARIES_ARB */ + { 33828, 0x00008807 }, /* GL_PROGRAM_TEX_INDIRECTIONS_ARB */ + { 33860, 0x00008806 }, /* GL_PROGRAM_TEX_INSTRUCTIONS_ARB */ + { 33892, 0x000088B6 }, /* GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB */ + { 33927, 0x00001701 }, /* GL_PROJECTION */ + { 33941, 0x00000BA7 }, /* GL_PROJECTION_MATRIX */ + { 33962, 0x0000898E }, /* GL_PROJECTION_MATRIX_FLOAT_AS_INT_BITS_OES */ + { 34005, 0x00000BA4 }, /* GL_PROJECTION_STACK_DEPTH */ + { 34031, 0x00008E4F }, /* GL_PROVOKING_VERTEX */ + { 34051, 0x00008E4F }, /* GL_PROVOKING_VERTEX_EXT */ + { 34075, 0x000080D3 }, /* GL_PROXY_COLOR_TABLE */ + { 34096, 0x00008025 }, /* GL_PROXY_HISTOGRAM */ + { 34115, 0x00008025 }, /* GL_PROXY_HISTOGRAM_EXT */ + { 34138, 0x000080D5 }, /* GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE */ + { 34177, 0x000080D4 }, /* GL_PROXY_POST_CONVOLUTION_COLOR_TABLE */ + { 34215, 0x00008063 }, /* GL_PROXY_TEXTURE_1D */ + { 34235, 0x00008C19 }, /* GL_PROXY_TEXTURE_1D_ARRAY */ + { 34261, 0x00008C19 }, /* GL_PROXY_TEXTURE_1D_ARRAY_EXT */ + { 34291, 0x00008063 }, /* GL_PROXY_TEXTURE_1D_EXT */ + { 34315, 0x00008064 }, /* GL_PROXY_TEXTURE_2D */ + { 34335, 0x00008C1B }, /* GL_PROXY_TEXTURE_2D_ARRAY */ + { 34361, 0x00008C1B }, /* GL_PROXY_TEXTURE_2D_ARRAY_EXT */ + { 34391, 0x00008064 }, /* GL_PROXY_TEXTURE_2D_EXT */ + { 34415, 0x00008070 }, /* GL_PROXY_TEXTURE_3D */ + { 34435, 0x000080BD }, /* GL_PROXY_TEXTURE_COLOR_TABLE_SGI */ + { 34468, 0x0000851B }, /* GL_PROXY_TEXTURE_CUBE_MAP */ + { 34494, 0x0000851B }, /* GL_PROXY_TEXTURE_CUBE_MAP_ARB */ + { 34524, 0x000084F7 }, /* GL_PROXY_TEXTURE_RECTANGLE */ + { 34551, 0x000084F7 }, /* GL_PROXY_TEXTURE_RECTANGLE_ARB */ + { 34582, 0x000084F7 }, /* GL_PROXY_TEXTURE_RECTANGLE_NV */ + { 34612, 0x00008A1D }, /* GL_PURGEABLE_APPLE */ + { 34631, 0x00002003 }, /* GL_Q */ + { 34636, 0x00001209 }, /* GL_QUADRATIC_ATTENUATION */ + { 34661, 0x00000007 }, /* GL_QUADS */ + { 34670, 0x00008E4C }, /* GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION */ + { 34714, 0x00008E4C }, /* GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT */ + { 34762, 0x00008614 }, /* GL_QUAD_MESH_SUN */ + { 34779, 0x00000008 }, /* GL_QUAD_STRIP */ + { 34793, 0x00008E16 }, /* GL_QUERY_BY_REGION_NO_WAIT */ + { 34820, 0x00008E16 }, /* GL_QUERY_BY_REGION_NO_WAIT_NV */ + { 34850, 0x00008E15 }, /* GL_QUERY_BY_REGION_WAIT */ + { 34874, 0x00008E15 }, /* GL_QUERY_BY_REGION_WAIT_NV */ + { 34901, 0x00008864 }, /* GL_QUERY_COUNTER_BITS */ + { 34923, 0x00008864 }, /* GL_QUERY_COUNTER_BITS_ARB */ + { 34949, 0x00008E14 }, /* GL_QUERY_NO_WAIT */ + { 34966, 0x00008E14 }, /* GL_QUERY_NO_WAIT_NV */ + { 34986, 0x00008866 }, /* GL_QUERY_RESULT */ + { 35002, 0x00008866 }, /* GL_QUERY_RESULT_ARB */ + { 35022, 0x00008867 }, /* GL_QUERY_RESULT_AVAILABLE */ + { 35048, 0x00008867 }, /* GL_QUERY_RESULT_AVAILABLE_ARB */ + { 35078, 0x00008E13 }, /* GL_QUERY_WAIT */ + { 35092, 0x00008E13 }, /* GL_QUERY_WAIT_NV */ + { 35109, 0x00002002 }, /* GL_R */ + { 35114, 0x00008C3A }, /* GL_R11F_G11F_B10F */ + { 35132, 0x00008F98 }, /* GL_R16_SNORM */ + { 35145, 0x00002A10 }, /* GL_R3_G3_B2 */ + { 35157, 0x00008F94 }, /* GL_R8_SNORM */ + { 35169, 0x00008C89 }, /* GL_RASTERIZER_DISCARD */ + { 35191, 0x00008C89 }, /* GL_RASTERIZER_DISCARD_EXT */ + { 35217, 0x00019262 }, /* GL_RASTER_POSITION_UNCLIPPED_IBM */ + { 35250, 0x00000C02 }, /* GL_READ_BUFFER */ + { 35265, 0x00008CA8 }, /* GL_READ_FRAMEBUFFER */ + { 35285, 0x00008CAA }, /* GL_READ_FRAMEBUFFER_BINDING */ + { 35313, 0x00008CAA }, /* GL_READ_FRAMEBUFFER_BINDING_EXT */ + { 35345, 0x00008CA8 }, /* GL_READ_FRAMEBUFFER_EXT */ + { 35369, 0x000088B8 }, /* GL_READ_ONLY */ + { 35382, 0x000088B8 }, /* GL_READ_ONLY_ARB */ + { 35399, 0x000088BA }, /* GL_READ_WRITE */ + { 35413, 0x000088BA }, /* GL_READ_WRITE_ARB */ + { 35431, 0x00001903 }, /* GL_RED */ + { 35438, 0x00008016 }, /* GL_REDUCE */ + { 35448, 0x00008016 }, /* GL_REDUCE_EXT */ + { 35462, 0x00000D15 }, /* GL_RED_BIAS */ + { 35474, 0x00000D52 }, /* GL_RED_BITS */ + { 35486, 0x00008D94 }, /* GL_RED_INTEGER */ + { 35501, 0x00008D94 }, /* GL_RED_INTEGER_EXT */ + { 35520, 0x00000D14 }, /* GL_RED_SCALE */ + { 35533, 0x00008F90 }, /* GL_RED_SNORM */ + { 35546, 0x00008512 }, /* GL_REFLECTION_MAP */ + { 35564, 0x00008512 }, /* GL_REFLECTION_MAP_ARB */ + { 35586, 0x00008512 }, /* GL_REFLECTION_MAP_NV */ + { 35607, 0x00008512 }, /* GL_REFLECTION_MAP_OES */ + { 35629, 0x00008A19 }, /* GL_RELEASED_APPLE */ + { 35647, 0x00001C00 }, /* GL_RENDER */ + { 35657, 0x00008D41 }, /* GL_RENDERBUFFER */ + { 35673, 0x00008D53 }, /* GL_RENDERBUFFER_ALPHA_SIZE */ + { 35700, 0x00008D53 }, /* GL_RENDERBUFFER_ALPHA_SIZE_OES */ + { 35731, 0x00008CA7 }, /* GL_RENDERBUFFER_BINDING */ + { 35755, 0x00008CA7 }, /* GL_RENDERBUFFER_BINDING_EXT */ + { 35783, 0x00008CA7 }, /* GL_RENDERBUFFER_BINDING_OES */ + { 35811, 0x00008D52 }, /* GL_RENDERBUFFER_BLUE_SIZE */ + { 35837, 0x00008D52 }, /* GL_RENDERBUFFER_BLUE_SIZE_OES */ + { 35867, 0x00008D54 }, /* GL_RENDERBUFFER_DEPTH_SIZE */ + { 35894, 0x00008D54 }, /* GL_RENDERBUFFER_DEPTH_SIZE_OES */ + { 35925, 0x00008D41 }, /* GL_RENDERBUFFER_EXT */ + { 35945, 0x00008D51 }, /* GL_RENDERBUFFER_GREEN_SIZE */ + { 35972, 0x00008D51 }, /* GL_RENDERBUFFER_GREEN_SIZE_OES */ + { 36003, 0x00008D43 }, /* GL_RENDERBUFFER_HEIGHT */ + { 36026, 0x00008D43 }, /* GL_RENDERBUFFER_HEIGHT_EXT */ + { 36053, 0x00008D43 }, /* GL_RENDERBUFFER_HEIGHT_OES */ + { 36080, 0x00008D44 }, /* GL_RENDERBUFFER_INTERNAL_FORMAT */ + { 36112, 0x00008D44 }, /* GL_RENDERBUFFER_INTERNAL_FORMAT_EXT */ + { 36148, 0x00008D44 }, /* GL_RENDERBUFFER_INTERNAL_FORMAT_OES */ + { 36184, 0x00008D41 }, /* GL_RENDERBUFFER_OES */ + { 36204, 0x00008D50 }, /* GL_RENDERBUFFER_RED_SIZE */ + { 36229, 0x00008D50 }, /* GL_RENDERBUFFER_RED_SIZE_OES */ + { 36258, 0x00008CAB }, /* GL_RENDERBUFFER_SAMPLES */ + { 36282, 0x00008CAB }, /* GL_RENDERBUFFER_SAMPLES_EXT */ + { 36310, 0x00008D55 }, /* GL_RENDERBUFFER_STENCIL_SIZE */ + { 36339, 0x00008D55 }, /* GL_RENDERBUFFER_STENCIL_SIZE_OES */ + { 36372, 0x00008D42 }, /* GL_RENDERBUFFER_WIDTH */ + { 36394, 0x00008D42 }, /* GL_RENDERBUFFER_WIDTH_EXT */ + { 36420, 0x00008D42 }, /* GL_RENDERBUFFER_WIDTH_OES */ + { 36446, 0x00001F01 }, /* GL_RENDERER */ + { 36458, 0x00000C40 }, /* GL_RENDER_MODE */ + { 36473, 0x00002901 }, /* GL_REPEAT */ + { 36483, 0x00001E01 }, /* GL_REPLACE */ + { 36494, 0x00008062 }, /* GL_REPLACE_EXT */ + { 36509, 0x00008153 }, /* GL_REPLICATE_BORDER_HP */ + { 36532, 0x0000803A }, /* GL_RESCALE_NORMAL */ + { 36550, 0x0000803A }, /* GL_RESCALE_NORMAL_EXT */ + { 36572, 0x00008256 }, /* GL_RESET_NOTIFICATION_STRATEGY_ARB */ + { 36607, 0x00008A1B }, /* GL_RETAINED_APPLE */ + { 36625, 0x00000102 }, /* GL_RETURN */ + { 36635, 0x00008F99 }, /* GL_RG16_SNORM */ + { 36649, 0x00008F95 }, /* GL_RG8_SNORM */ + { 36662, 0x00001907 }, /* GL_RGB */ + { 36669, 0x00008052 }, /* GL_RGB10 */ + { 36678, 0x00008059 }, /* GL_RGB10_A2 */ + { 36690, 0x00008059 }, /* GL_RGB10_A2_EXT */ + { 36706, 0x00008052 }, /* GL_RGB10_EXT */ + { 36719, 0x00008053 }, /* GL_RGB12 */ + { 36728, 0x00008053 }, /* GL_RGB12_EXT */ + { 36741, 0x00008054 }, /* GL_RGB16 */ + { 36750, 0x0000881B }, /* GL_RGB16F */ + { 36760, 0x00008D89 }, /* GL_RGB16I */ + { 36770, 0x00008D89 }, /* GL_RGB16I_EXT */ + { 36784, 0x00008D77 }, /* GL_RGB16UI */ + { 36795, 0x00008D77 }, /* GL_RGB16UI_EXT */ + { 36810, 0x00008054 }, /* GL_RGB16_EXT */ + { 36823, 0x00008F9A }, /* GL_RGB16_SNORM */ + { 36838, 0x0000804E }, /* GL_RGB2_EXT */ + { 36850, 0x00008815 }, /* GL_RGB32F */ + { 36860, 0x00008D83 }, /* GL_RGB32I */ + { 36870, 0x00008D83 }, /* GL_RGB32I_EXT */ + { 36884, 0x00008D71 }, /* GL_RGB32UI */ + { 36895, 0x00008D71 }, /* GL_RGB32UI_EXT */ + { 36910, 0x0000804F }, /* GL_RGB4 */ + { 36918, 0x0000804F }, /* GL_RGB4_EXT */ + { 36930, 0x000083A1 }, /* GL_RGB4_S3TC */ + { 36943, 0x00008050 }, /* GL_RGB5 */ + { 36951, 0x00008D62 }, /* GL_RGB565 */ + { 36961, 0x00008D62 }, /* GL_RGB565_OES */ + { 36975, 0x00008057 }, /* GL_RGB5_A1 */ + { 36986, 0x00008057 }, /* GL_RGB5_A1_EXT */ + { 37001, 0x00008057 }, /* GL_RGB5_A1_OES */ + { 37016, 0x00008050 }, /* GL_RGB5_EXT */ + { 37028, 0x00008051 }, /* GL_RGB8 */ + { 37036, 0x00008D8F }, /* GL_RGB8I */ + { 37045, 0x00008D8F }, /* GL_RGB8I_EXT */ + { 37058, 0x00008D7D }, /* GL_RGB8UI */ + { 37068, 0x00008D7D }, /* GL_RGB8UI_EXT */ + { 37082, 0x00008051 }, /* GL_RGB8_EXT */ + { 37094, 0x00008051 }, /* GL_RGB8_OES */ + { 37106, 0x00008F96 }, /* GL_RGB8_SNORM */ + { 37120, 0x00008C3D }, /* GL_RGB9_E5 */ + { 37131, 0x00001908 }, /* GL_RGBA */ + { 37139, 0x0000805A }, /* GL_RGBA12 */ + { 37149, 0x0000805A }, /* GL_RGBA12_EXT */ + { 37163, 0x0000805B }, /* GL_RGBA16 */ + { 37173, 0x0000881A }, /* GL_RGBA16F */ + { 37184, 0x00008D88 }, /* GL_RGBA16I */ + { 37195, 0x00008D88 }, /* GL_RGBA16I_EXT */ + { 37210, 0x00008D76 }, /* GL_RGBA16UI */ + { 37222, 0x00008D76 }, /* GL_RGBA16UI_EXT */ + { 37238, 0x0000805B }, /* GL_RGBA16_EXT */ + { 37252, 0x00008F9B }, /* GL_RGBA16_SNORM */ + { 37268, 0x00008055 }, /* GL_RGBA2 */ + { 37277, 0x00008055 }, /* GL_RGBA2_EXT */ + { 37290, 0x00008814 }, /* GL_RGBA32F */ + { 37301, 0x00008D82 }, /* GL_RGBA32I */ + { 37312, 0x00008D82 }, /* GL_RGBA32I_EXT */ + { 37327, 0x00008D70 }, /* GL_RGBA32UI */ + { 37339, 0x00008D70 }, /* GL_RGBA32UI_EXT */ + { 37355, 0x00008056 }, /* GL_RGBA4 */ + { 37364, 0x000083A5 }, /* GL_RGBA4_DXT5_S3TC */ + { 37383, 0x00008056 }, /* GL_RGBA4_EXT */ + { 37396, 0x00008056 }, /* GL_RGBA4_OES */ + { 37409, 0x000083A3 }, /* GL_RGBA4_S3TC */ + { 37423, 0x00008058 }, /* GL_RGBA8 */ + { 37432, 0x00008D8E }, /* GL_RGBA8I */ + { 37442, 0x00008D8E }, /* GL_RGBA8I_EXT */ + { 37456, 0x00008D7C }, /* GL_RGBA8UI */ + { 37467, 0x00008D7C }, /* GL_RGBA8UI_EXT */ + { 37482, 0x00008058 }, /* GL_RGBA8_EXT */ + { 37495, 0x00008058 }, /* GL_RGBA8_OES */ + { 37508, 0x00008F97 }, /* GL_RGBA8_SNORM */ + { 37523, 0x000083A4 }, /* GL_RGBA_DXT5_S3TC */ + { 37541, 0x00008820 }, /* GL_RGBA_FLOAT_MODE_ARB */ + { 37564, 0x00008D99 }, /* GL_RGBA_INTEGER */ + { 37580, 0x00008D99 }, /* GL_RGBA_INTEGER_EXT */ + { 37600, 0x00008D9E }, /* GL_RGBA_INTEGER_MODE_EXT */ + { 37625, 0x00000C31 }, /* GL_RGBA_MODE */ + { 37638, 0x000083A2 }, /* GL_RGBA_S3TC */ + { 37651, 0x00008F93 }, /* GL_RGBA_SNORM */ + { 37665, 0x00008D98 }, /* GL_RGB_INTEGER */ + { 37680, 0x00008D98 }, /* GL_RGB_INTEGER_EXT */ + { 37699, 0x000083A0 }, /* GL_RGB_S3TC */ + { 37711, 0x00008573 }, /* GL_RGB_SCALE */ + { 37724, 0x00008573 }, /* GL_RGB_SCALE_ARB */ + { 37741, 0x00008573 }, /* GL_RGB_SCALE_EXT */ + { 37758, 0x00008F92 }, /* GL_RGB_SNORM */ + { 37771, 0x00008F91 }, /* GL_RG_SNORM */ + { 37783, 0x00000407 }, /* GL_RIGHT */ + { 37792, 0x00002000 }, /* GL_S */ + { 37797, 0x00008B5D }, /* GL_SAMPLER_1D */ + { 37811, 0x00008DC0 }, /* GL_SAMPLER_1D_ARRAY */ + { 37831, 0x00008DC0 }, /* GL_SAMPLER_1D_ARRAY_EXT */ + { 37855, 0x00008DC3 }, /* GL_SAMPLER_1D_ARRAY_SHADOW */ + { 37882, 0x00008DC3 }, /* GL_SAMPLER_1D_ARRAY_SHADOW_EXT */ + { 37913, 0x00008B61 }, /* GL_SAMPLER_1D_SHADOW */ + { 37934, 0x00008B5E }, /* GL_SAMPLER_2D */ + { 37948, 0x00008DC1 }, /* GL_SAMPLER_2D_ARRAY */ + { 37968, 0x00008DC1 }, /* GL_SAMPLER_2D_ARRAY_EXT */ + { 37992, 0x00008DC4 }, /* GL_SAMPLER_2D_ARRAY_SHADOW */ + { 38019, 0x00008DC4 }, /* GL_SAMPLER_2D_ARRAY_SHADOW_EXT */ + { 38050, 0x00008B63 }, /* GL_SAMPLER_2D_RECT */ + { 38069, 0x00008B64 }, /* GL_SAMPLER_2D_RECT_SHADOW */ + { 38095, 0x00008B62 }, /* GL_SAMPLER_2D_SHADOW */ + { 38116, 0x00008B5F }, /* GL_SAMPLER_3D */ + { 38130, 0x00008B5F }, /* GL_SAMPLER_3D_OES */ + { 38148, 0x00008919 }, /* GL_SAMPLER_BINDING */ + { 38167, 0x00008DC2 }, /* GL_SAMPLER_BUFFER */ + { 38185, 0x00008DC2 }, /* GL_SAMPLER_BUFFER_EXT */ + { 38207, 0x00008B60 }, /* GL_SAMPLER_CUBE */ + { 38223, 0x00008DC5 }, /* GL_SAMPLER_CUBE_SHADOW */ + { 38246, 0x00008DC5 }, /* GL_SAMPLER_CUBE_SHADOW_EXT */ + { 38273, 0x000080A9 }, /* GL_SAMPLES */ + { 38284, 0x000086B4 }, /* GL_SAMPLES_3DFX */ + { 38300, 0x000080A9 }, /* GL_SAMPLES_ARB */ + { 38315, 0x00008914 }, /* GL_SAMPLES_PASSED */ + { 38333, 0x00008914 }, /* GL_SAMPLES_PASSED_ARB */ + { 38355, 0x0000809E }, /* GL_SAMPLE_ALPHA_TO_COVERAGE */ + { 38383, 0x0000809E }, /* GL_SAMPLE_ALPHA_TO_COVERAGE_ARB */ + { 38415, 0x0000809F }, /* GL_SAMPLE_ALPHA_TO_ONE */ + { 38438, 0x0000809F }, /* GL_SAMPLE_ALPHA_TO_ONE_ARB */ + { 38465, 0x000080A8 }, /* GL_SAMPLE_BUFFERS */ + { 38483, 0x000086B3 }, /* GL_SAMPLE_BUFFERS_3DFX */ + { 38506, 0x000080A8 }, /* GL_SAMPLE_BUFFERS_ARB */ + { 38528, 0x000080A0 }, /* GL_SAMPLE_COVERAGE */ + { 38547, 0x000080A0 }, /* GL_SAMPLE_COVERAGE_ARB */ + { 38570, 0x000080AB }, /* GL_SAMPLE_COVERAGE_INVERT */ + { 38596, 0x000080AB }, /* GL_SAMPLE_COVERAGE_INVERT_ARB */ + { 38626, 0x000080AA }, /* GL_SAMPLE_COVERAGE_VALUE */ + { 38651, 0x000080AA }, /* GL_SAMPLE_COVERAGE_VALUE_ARB */ + { 38680, 0x00080000 }, /* GL_SCISSOR_BIT */ + { 38695, 0x00000C10 }, /* GL_SCISSOR_BOX */ + { 38710, 0x00000C11 }, /* GL_SCISSOR_TEST */ + { 38726, 0x0000845E }, /* GL_SECONDARY_COLOR_ARRAY */ + { 38751, 0x0000889C }, /* GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING */ + { 38791, 0x0000889C }, /* GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB */ + { 38835, 0x0000845D }, /* GL_SECONDARY_COLOR_ARRAY_POINTER */ + { 38868, 0x0000845A }, /* GL_SECONDARY_COLOR_ARRAY_SIZE */ + { 38898, 0x0000845C }, /* GL_SECONDARY_COLOR_ARRAY_STRIDE */ + { 38930, 0x0000845B }, /* GL_SECONDARY_COLOR_ARRAY_TYPE */ + { 38960, 0x00001C02 }, /* GL_SELECT */ + { 38970, 0x00000DF3 }, /* GL_SELECTION_BUFFER_POINTER */ + { 38998, 0x00000DF4 }, /* GL_SELECTION_BUFFER_SIZE */ + { 39023, 0x00008012 }, /* GL_SEPARABLE_2D */ + { 39039, 0x00008C8D }, /* GL_SEPARATE_ATTRIBS */ + { 39059, 0x00008C8D }, /* GL_SEPARATE_ATTRIBS_EXT */ + { 39083, 0x000081FA }, /* GL_SEPARATE_SPECULAR_COLOR */ + { 39110, 0x000081FA }, /* GL_SEPARATE_SPECULAR_COLOR_EXT */ + { 39141, 0x0000150F }, /* GL_SET */ + { 39148, 0x00008DF8 }, /* GL_SHADER_BINARY_FORMATS */ + { 39173, 0x00008DFA }, /* GL_SHADER_COMPILER */ + { 39192, 0x00008B48 }, /* GL_SHADER_OBJECT_ARB */ + { 39213, 0x00008B88 }, /* GL_SHADER_SOURCE_LENGTH */ + { 39237, 0x00008B4F }, /* GL_SHADER_TYPE */ + { 39252, 0x00000B54 }, /* GL_SHADE_MODEL */ + { 39267, 0x00008B8C }, /* GL_SHADING_LANGUAGE_VERSION */ + { 39295, 0x000080BF }, /* GL_SHADOW_AMBIENT_SGIX */ + { 39318, 0x000081FB }, /* GL_SHARED_TEXTURE_PALETTE_EXT */ + { 39348, 0x00001601 }, /* GL_SHININESS */ + { 39361, 0x00001402 }, /* GL_SHORT */ + { 39370, 0x00009119 }, /* GL_SIGNALED */ + { 39382, 0x00008F9C }, /* GL_SIGNED_NORMALIZED */ + { 39403, 0x000081F9 }, /* GL_SINGLE_COLOR */ + { 39419, 0x000081F9 }, /* GL_SINGLE_COLOR_EXT */ + { 39439, 0x000085CC }, /* GL_SLICE_ACCUM_SUN */ + { 39458, 0x00008C46 }, /* GL_SLUMINANCE */ + { 39472, 0x00008C47 }, /* GL_SLUMINANCE8 */ + { 39487, 0x00008C45 }, /* GL_SLUMINANCE8_ALPHA8 */ + { 39509, 0x00008C44 }, /* GL_SLUMINANCE_ALPHA */ + { 39529, 0x00001D01 }, /* GL_SMOOTH */ + { 39539, 0x00000B23 }, /* GL_SMOOTH_LINE_WIDTH_GRANULARITY */ + { 39572, 0x00000B22 }, /* GL_SMOOTH_LINE_WIDTH_RANGE */ + { 39599, 0x00000B13 }, /* GL_SMOOTH_POINT_SIZE_GRANULARITY */ + { 39632, 0x00000B12 }, /* GL_SMOOTH_POINT_SIZE_RANGE */ + { 39659, 0x00008588 }, /* GL_SOURCE0_ALPHA */ + { 39676, 0x00008588 }, /* GL_SOURCE0_ALPHA_ARB */ + { 39697, 0x00008588 }, /* GL_SOURCE0_ALPHA_EXT */ + { 39718, 0x00008580 }, /* GL_SOURCE0_RGB */ + { 39733, 0x00008580 }, /* GL_SOURCE0_RGB_ARB */ + { 39752, 0x00008580 }, /* GL_SOURCE0_RGB_EXT */ + { 39771, 0x00008589 }, /* GL_SOURCE1_ALPHA */ + { 39788, 0x00008589 }, /* GL_SOURCE1_ALPHA_ARB */ + { 39809, 0x00008589 }, /* GL_SOURCE1_ALPHA_EXT */ + { 39830, 0x00008581 }, /* GL_SOURCE1_RGB */ + { 39845, 0x00008581 }, /* GL_SOURCE1_RGB_ARB */ + { 39864, 0x00008581 }, /* GL_SOURCE1_RGB_EXT */ + { 39883, 0x0000858A }, /* GL_SOURCE2_ALPHA */ + { 39900, 0x0000858A }, /* GL_SOURCE2_ALPHA_ARB */ + { 39921, 0x0000858A }, /* GL_SOURCE2_ALPHA_EXT */ + { 39942, 0x00008582 }, /* GL_SOURCE2_RGB */ + { 39957, 0x00008582 }, /* GL_SOURCE2_RGB_ARB */ + { 39976, 0x00008582 }, /* GL_SOURCE2_RGB_EXT */ + { 39995, 0x0000858B }, /* GL_SOURCE3_ALPHA_NV */ + { 40015, 0x00008583 }, /* GL_SOURCE3_RGB_NV */ + { 40033, 0x00001202 }, /* GL_SPECULAR */ + { 40045, 0x00002402 }, /* GL_SPHERE_MAP */ + { 40059, 0x00001206 }, /* GL_SPOT_CUTOFF */ + { 40074, 0x00001204 }, /* GL_SPOT_DIRECTION */ + { 40092, 0x00001205 }, /* GL_SPOT_EXPONENT */ + { 40109, 0x00008588 }, /* GL_SRC0_ALPHA */ + { 40123, 0x00008580 }, /* GL_SRC0_RGB */ + { 40135, 0x00008589 }, /* GL_SRC1_ALPHA */ + { 40149, 0x00008581 }, /* GL_SRC1_RGB */ + { 40161, 0x0000858A }, /* GL_SRC2_ALPHA */ + { 40175, 0x00008582 }, /* GL_SRC2_RGB */ + { 40187, 0x00000302 }, /* GL_SRC_ALPHA */ + { 40200, 0x00000308 }, /* GL_SRC_ALPHA_SATURATE */ + { 40222, 0x00000300 }, /* GL_SRC_COLOR */ + { 40235, 0x00008C40 }, /* GL_SRGB */ + { 40243, 0x00008C41 }, /* GL_SRGB8 */ + { 40252, 0x00008C43 }, /* GL_SRGB8_ALPHA8 */ + { 40268, 0x00008C42 }, /* GL_SRGB_ALPHA */ + { 40282, 0x00000503 }, /* GL_STACK_OVERFLOW */ + { 40300, 0x00000504 }, /* GL_STACK_UNDERFLOW */ + { 40319, 0x000088E6 }, /* GL_STATIC_COPY */ + { 40334, 0x000088E6 }, /* GL_STATIC_COPY_ARB */ + { 40353, 0x000088E4 }, /* GL_STATIC_DRAW */ + { 40368, 0x000088E4 }, /* GL_STATIC_DRAW_ARB */ + { 40387, 0x000088E5 }, /* GL_STATIC_READ */ + { 40402, 0x000088E5 }, /* GL_STATIC_READ_ARB */ + { 40421, 0x00001802 }, /* GL_STENCIL */ + { 40432, 0x00008D20 }, /* GL_STENCIL_ATTACHMENT */ + { 40454, 0x00008D20 }, /* GL_STENCIL_ATTACHMENT_EXT */ + { 40480, 0x00008D20 }, /* GL_STENCIL_ATTACHMENT_OES */ + { 40506, 0x00008801 }, /* GL_STENCIL_BACK_FAIL */ + { 40527, 0x00008801 }, /* GL_STENCIL_BACK_FAIL_ATI */ + { 40552, 0x00008800 }, /* GL_STENCIL_BACK_FUNC */ + { 40573, 0x00008800 }, /* GL_STENCIL_BACK_FUNC_ATI */ + { 40598, 0x00008802 }, /* GL_STENCIL_BACK_PASS_DEPTH_FAIL */ + { 40630, 0x00008802 }, /* GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI */ + { 40666, 0x00008803 }, /* GL_STENCIL_BACK_PASS_DEPTH_PASS */ + { 40698, 0x00008803 }, /* GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI */ + { 40734, 0x00008CA3 }, /* GL_STENCIL_BACK_REF */ + { 40754, 0x00008CA4 }, /* GL_STENCIL_BACK_VALUE_MASK */ + { 40781, 0x00008CA5 }, /* GL_STENCIL_BACK_WRITEMASK */ + { 40807, 0x00000D57 }, /* GL_STENCIL_BITS */ + { 40823, 0x00008224 }, /* GL_STENCIL_BUFFER */ + { 40841, 0x00000400 }, /* GL_STENCIL_BUFFER_BIT */ + { 40863, 0x00000B91 }, /* GL_STENCIL_CLEAR_VALUE */ + { 40886, 0x00000B94 }, /* GL_STENCIL_FAIL */ + { 40902, 0x00000B92 }, /* GL_STENCIL_FUNC */ + { 40918, 0x00001901 }, /* GL_STENCIL_INDEX */ + { 40935, 0x00008D46 }, /* GL_STENCIL_INDEX1 */ + { 40953, 0x00008D49 }, /* GL_STENCIL_INDEX16 */ + { 40972, 0x00008D49 }, /* GL_STENCIL_INDEX16_EXT */ + { 40995, 0x00008D46 }, /* GL_STENCIL_INDEX1_EXT */ + { 41017, 0x00008D46 }, /* GL_STENCIL_INDEX1_OES */ + { 41039, 0x00008D47 }, /* GL_STENCIL_INDEX4 */ + { 41057, 0x00008D47 }, /* GL_STENCIL_INDEX4_EXT */ + { 41079, 0x00008D47 }, /* GL_STENCIL_INDEX4_OES */ + { 41101, 0x00008D48 }, /* GL_STENCIL_INDEX8 */ + { 41119, 0x00008D48 }, /* GL_STENCIL_INDEX8_EXT */ + { 41141, 0x00008D48 }, /* GL_STENCIL_INDEX8_OES */ + { 41163, 0x00008D45 }, /* GL_STENCIL_INDEX_EXT */ + { 41184, 0x00000B95 }, /* GL_STENCIL_PASS_DEPTH_FAIL */ + { 41211, 0x00000B96 }, /* GL_STENCIL_PASS_DEPTH_PASS */ + { 41238, 0x00000B97 }, /* GL_STENCIL_REF */ + { 41253, 0x00000B90 }, /* GL_STENCIL_TEST */ + { 41269, 0x00008910 }, /* GL_STENCIL_TEST_TWO_SIDE_EXT */ + { 41298, 0x00000B93 }, /* GL_STENCIL_VALUE_MASK */ + { 41320, 0x00000B98 }, /* GL_STENCIL_WRITEMASK */ + { 41341, 0x00000C33 }, /* GL_STEREO */ + { 41351, 0x000085BE }, /* GL_STORAGE_CACHED_APPLE */ + { 41375, 0x000085BD }, /* GL_STORAGE_PRIVATE_APPLE */ + { 41400, 0x000085BF }, /* GL_STORAGE_SHARED_APPLE */ + { 41424, 0x000088E2 }, /* GL_STREAM_COPY */ + { 41439, 0x000088E2 }, /* GL_STREAM_COPY_ARB */ + { 41458, 0x000088E0 }, /* GL_STREAM_DRAW */ + { 41473, 0x000088E0 }, /* GL_STREAM_DRAW_ARB */ + { 41492, 0x000088E1 }, /* GL_STREAM_READ */ + { 41507, 0x000088E1 }, /* GL_STREAM_READ_ARB */ + { 41526, 0x00000D50 }, /* GL_SUBPIXEL_BITS */ + { 41543, 0x000084E7 }, /* GL_SUBTRACT */ + { 41555, 0x000084E7 }, /* GL_SUBTRACT_ARB */ + { 41571, 0x00009113 }, /* GL_SYNC_CONDITION */ + { 41589, 0x00009116 }, /* GL_SYNC_FENCE */ + { 41603, 0x00009115 }, /* GL_SYNC_FLAGS */ + { 41617, 0x00000001 }, /* GL_SYNC_FLUSH_COMMANDS_BIT */ + { 41644, 0x00009117 }, /* GL_SYNC_GPU_COMMANDS_COMPLETE */ + { 41674, 0x00009114 }, /* GL_SYNC_STATUS */ + { 41689, 0x00002001 }, /* GL_T */ + { 41694, 0x00002A2A }, /* GL_T2F_C3F_V3F */ + { 41709, 0x00002A2C }, /* GL_T2F_C4F_N3F_V3F */ + { 41728, 0x00002A29 }, /* GL_T2F_C4UB_V3F */ + { 41744, 0x00002A2B }, /* GL_T2F_N3F_V3F */ + { 41759, 0x00002A27 }, /* GL_T2F_V3F */ + { 41770, 0x00002A2D }, /* GL_T4F_C4F_N3F_V4F */ + { 41789, 0x00002A28 }, /* GL_T4F_V4F */ + { 41800, 0x00008031 }, /* GL_TABLE_TOO_LARGE_EXT */ + { 41823, 0x00001702 }, /* GL_TEXTURE */ + { 41834, 0x000084C0 }, /* GL_TEXTURE0 */ + { 41846, 0x000084C0 }, /* GL_TEXTURE0_ARB */ + { 41862, 0x000084C1 }, /* GL_TEXTURE1 */ + { 41874, 0x000084CA }, /* GL_TEXTURE10 */ + { 41887, 0x000084CA }, /* GL_TEXTURE10_ARB */ + { 41904, 0x000084CB }, /* GL_TEXTURE11 */ + { 41917, 0x000084CB }, /* GL_TEXTURE11_ARB */ + { 41934, 0x000084CC }, /* GL_TEXTURE12 */ + { 41947, 0x000084CC }, /* GL_TEXTURE12_ARB */ + { 41964, 0x000084CD }, /* GL_TEXTURE13 */ + { 41977, 0x000084CD }, /* GL_TEXTURE13_ARB */ + { 41994, 0x000084CE }, /* GL_TEXTURE14 */ + { 42007, 0x000084CE }, /* GL_TEXTURE14_ARB */ + { 42024, 0x000084CF }, /* GL_TEXTURE15 */ + { 42037, 0x000084CF }, /* GL_TEXTURE15_ARB */ + { 42054, 0x000084D0 }, /* GL_TEXTURE16 */ + { 42067, 0x000084D0 }, /* GL_TEXTURE16_ARB */ + { 42084, 0x000084D1 }, /* GL_TEXTURE17 */ + { 42097, 0x000084D1 }, /* GL_TEXTURE17_ARB */ + { 42114, 0x000084D2 }, /* GL_TEXTURE18 */ + { 42127, 0x000084D2 }, /* GL_TEXTURE18_ARB */ + { 42144, 0x000084D3 }, /* GL_TEXTURE19 */ + { 42157, 0x000084D3 }, /* GL_TEXTURE19_ARB */ + { 42174, 0x000084C1 }, /* GL_TEXTURE1_ARB */ + { 42190, 0x000084C2 }, /* GL_TEXTURE2 */ + { 42202, 0x000084D4 }, /* GL_TEXTURE20 */ + { 42215, 0x000084D4 }, /* GL_TEXTURE20_ARB */ + { 42232, 0x000084D5 }, /* GL_TEXTURE21 */ + { 42245, 0x000084D5 }, /* GL_TEXTURE21_ARB */ + { 42262, 0x000084D6 }, /* GL_TEXTURE22 */ + { 42275, 0x000084D6 }, /* GL_TEXTURE22_ARB */ + { 42292, 0x000084D7 }, /* GL_TEXTURE23 */ + { 42305, 0x000084D7 }, /* GL_TEXTURE23_ARB */ + { 42322, 0x000084D8 }, /* GL_TEXTURE24 */ + { 42335, 0x000084D8 }, /* GL_TEXTURE24_ARB */ + { 42352, 0x000084D9 }, /* GL_TEXTURE25 */ + { 42365, 0x000084D9 }, /* GL_TEXTURE25_ARB */ + { 42382, 0x000084DA }, /* GL_TEXTURE26 */ + { 42395, 0x000084DA }, /* GL_TEXTURE26_ARB */ + { 42412, 0x000084DB }, /* GL_TEXTURE27 */ + { 42425, 0x000084DB }, /* GL_TEXTURE27_ARB */ + { 42442, 0x000084DC }, /* GL_TEXTURE28 */ + { 42455, 0x000084DC }, /* GL_TEXTURE28_ARB */ + { 42472, 0x000084DD }, /* GL_TEXTURE29 */ + { 42485, 0x000084DD }, /* GL_TEXTURE29_ARB */ + { 42502, 0x000084C2 }, /* GL_TEXTURE2_ARB */ + { 42518, 0x000084C3 }, /* GL_TEXTURE3 */ + { 42530, 0x000084DE }, /* GL_TEXTURE30 */ + { 42543, 0x000084DE }, /* GL_TEXTURE30_ARB */ + { 42560, 0x000084DF }, /* GL_TEXTURE31 */ + { 42573, 0x000084DF }, /* GL_TEXTURE31_ARB */ + { 42590, 0x000084C3 }, /* GL_TEXTURE3_ARB */ + { 42606, 0x000084C4 }, /* GL_TEXTURE4 */ + { 42618, 0x000084C4 }, /* GL_TEXTURE4_ARB */ + { 42634, 0x000084C5 }, /* GL_TEXTURE5 */ + { 42646, 0x000084C5 }, /* GL_TEXTURE5_ARB */ + { 42662, 0x000084C6 }, /* GL_TEXTURE6 */ + { 42674, 0x000084C6 }, /* GL_TEXTURE6_ARB */ + { 42690, 0x000084C7 }, /* GL_TEXTURE7 */ + { 42702, 0x000084C7 }, /* GL_TEXTURE7_ARB */ + { 42718, 0x000084C8 }, /* GL_TEXTURE8 */ + { 42730, 0x000084C8 }, /* GL_TEXTURE8_ARB */ + { 42746, 0x000084C9 }, /* GL_TEXTURE9 */ + { 42758, 0x000084C9 }, /* GL_TEXTURE9_ARB */ + { 42774, 0x00000DE0 }, /* GL_TEXTURE_1D */ + { 42788, 0x00008C18 }, /* GL_TEXTURE_1D_ARRAY */ + { 42808, 0x00008C18 }, /* GL_TEXTURE_1D_ARRAY_EXT */ + { 42832, 0x00000DE1 }, /* GL_TEXTURE_2D */ + { 42846, 0x00008C1A }, /* GL_TEXTURE_2D_ARRAY */ + { 42866, 0x00008C1A }, /* GL_TEXTURE_2D_ARRAY_EXT */ + { 42890, 0x0000806F }, /* GL_TEXTURE_3D */ + { 42904, 0x0000806F }, /* GL_TEXTURE_3D_OES */ + { 42922, 0x0000805F }, /* GL_TEXTURE_ALPHA_SIZE */ + { 42944, 0x0000805F }, /* GL_TEXTURE_ALPHA_SIZE_EXT */ + { 42970, 0x0000813C }, /* GL_TEXTURE_BASE_LEVEL */ + { 42992, 0x00008068 }, /* GL_TEXTURE_BINDING_1D */ + { 43014, 0x00008C1C }, /* GL_TEXTURE_BINDING_1D_ARRAY */ + { 43042, 0x00008C1C }, /* GL_TEXTURE_BINDING_1D_ARRAY_EXT */ + { 43074, 0x00008069 }, /* GL_TEXTURE_BINDING_2D */ + { 43096, 0x00008C1D }, /* GL_TEXTURE_BINDING_2D_ARRAY */ + { 43124, 0x00008C1D }, /* GL_TEXTURE_BINDING_2D_ARRAY_EXT */ + { 43156, 0x0000806A }, /* GL_TEXTURE_BINDING_3D */ + { 43178, 0x0000806A }, /* GL_TEXTURE_BINDING_3D_OES */ + { 43204, 0x00008C2C }, /* GL_TEXTURE_BINDING_BUFFER */ + { 43230, 0x00008C2C }, /* GL_TEXTURE_BINDING_BUFFER_ARB */ + { 43260, 0x00008514 }, /* GL_TEXTURE_BINDING_CUBE_MAP */ + { 43288, 0x00008514 }, /* GL_TEXTURE_BINDING_CUBE_MAP_ARB */ + { 43320, 0x00008514 }, /* GL_TEXTURE_BINDING_CUBE_MAP_OES */ + { 43352, 0x000084F6 }, /* GL_TEXTURE_BINDING_RECTANGLE */ + { 43381, 0x000084F6 }, /* GL_TEXTURE_BINDING_RECTANGLE_ARB */ + { 43414, 0x000084F6 }, /* GL_TEXTURE_BINDING_RECTANGLE_NV */ + { 43446, 0x00040000 }, /* GL_TEXTURE_BIT */ + { 43461, 0x0000805E }, /* GL_TEXTURE_BLUE_SIZE */ + { 43482, 0x0000805E }, /* GL_TEXTURE_BLUE_SIZE_EXT */ + { 43507, 0x00001005 }, /* GL_TEXTURE_BORDER */ + { 43525, 0x00001004 }, /* GL_TEXTURE_BORDER_COLOR */ + { 43549, 0x00008C2A }, /* GL_TEXTURE_BUFFER */ + { 43567, 0x00008C2A }, /* GL_TEXTURE_BUFFER_ARB */ + { 43589, 0x00008C2D }, /* GL_TEXTURE_BUFFER_DATA_STORE_BINDING */ + { 43626, 0x00008C2D }, /* GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB */ + { 43667, 0x00008C2E }, /* GL_TEXTURE_BUFFER_FORMAT */ + { 43692, 0x00008C2E }, /* GL_TEXTURE_BUFFER_FORMAT_ARB */ + { 43721, 0x00008171 }, /* GL_TEXTURE_CLIPMAP_CENTER_SGIX */ + { 43752, 0x00008176 }, /* GL_TEXTURE_CLIPMAP_DEPTH_SGIX */ + { 43782, 0x00008172 }, /* GL_TEXTURE_CLIPMAP_FRAME_SGIX */ + { 43812, 0x00008175 }, /* GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX */ + { 43847, 0x00008173 }, /* GL_TEXTURE_CLIPMAP_OFFSET_SGIX */ + { 43878, 0x00008174 }, /* GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX */ + { 43916, 0x000080BC }, /* GL_TEXTURE_COLOR_TABLE_SGI */ + { 43943, 0x000081EF }, /* GL_TEXTURE_COLOR_WRITEMASK_SGIS */ + { 43975, 0x000080BF }, /* GL_TEXTURE_COMPARE_FAIL_VALUE_ARB */ + { 44009, 0x0000884D }, /* GL_TEXTURE_COMPARE_FUNC */ + { 44033, 0x0000884D }, /* GL_TEXTURE_COMPARE_FUNC_ARB */ + { 44061, 0x0000884C }, /* GL_TEXTURE_COMPARE_MODE */ + { 44085, 0x0000884C }, /* GL_TEXTURE_COMPARE_MODE_ARB */ + { 44113, 0x0000819B }, /* GL_TEXTURE_COMPARE_OPERATOR_SGIX */ + { 44146, 0x0000819A }, /* GL_TEXTURE_COMPARE_SGIX */ + { 44170, 0x00001003 }, /* GL_TEXTURE_COMPONENTS */ + { 44192, 0x000086A1 }, /* GL_TEXTURE_COMPRESSED */ + { 44214, 0x000086A1 }, /* GL_TEXTURE_COMPRESSED_ARB */ + { 44240, 0x000086A3 }, /* GL_TEXTURE_COMPRESSED_FORMATS_ARB */ + { 44274, 0x000086A0 }, /* GL_TEXTURE_COMPRESSED_IMAGE_SIZE */ + { 44307, 0x000086A0 }, /* GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB */ + { 44344, 0x000084EF }, /* GL_TEXTURE_COMPRESSION_HINT */ + { 44372, 0x000084EF }, /* GL_TEXTURE_COMPRESSION_HINT_ARB */ + { 44404, 0x00008078 }, /* GL_TEXTURE_COORD_ARRAY */ + { 44427, 0x0000889A }, /* GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING */ + { 44465, 0x0000889A }, /* GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB */ + { 44507, 0x00008092 }, /* GL_TEXTURE_COORD_ARRAY_POINTER */ + { 44538, 0x00008088 }, /* GL_TEXTURE_COORD_ARRAY_SIZE */ + { 44566, 0x0000808A }, /* GL_TEXTURE_COORD_ARRAY_STRIDE */ + { 44596, 0x00008089 }, /* GL_TEXTURE_COORD_ARRAY_TYPE */ + { 44624, 0x00008B9D }, /* GL_TEXTURE_CROP_RECT_OES */ + { 44649, 0x00008513 }, /* GL_TEXTURE_CUBE_MAP */ + { 44669, 0x00008513 }, /* GL_TEXTURE_CUBE_MAP_ARB */ + { 44693, 0x00008516 }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_X */ + { 44724, 0x00008516 }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB */ + { 44759, 0x00008516 }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_X_OES */ + { 44794, 0x00008518 }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Y */ + { 44825, 0x00008518 }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB */ + { 44860, 0x00008518 }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_OES */ + { 44895, 0x0000851A }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Z */ + { 44926, 0x0000851A }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB */ + { 44961, 0x0000851A }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_OES */ + { 44996, 0x00008513 }, /* GL_TEXTURE_CUBE_MAP_OES */ + { 45020, 0x00008515 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_X */ + { 45051, 0x00008515 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB */ + { 45086, 0x00008515 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_X_OES */ + { 45121, 0x00008517 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Y */ + { 45152, 0x00008517 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB */ + { 45187, 0x00008517 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Y_OES */ + { 45222, 0x00008519 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Z */ + { 45253, 0x00008519 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB */ + { 45288, 0x00008519 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Z_OES */ + { 45323, 0x000088F4 }, /* GL_TEXTURE_CUBE_MAP_SEAMLESS */ + { 45352, 0x00008071 }, /* GL_TEXTURE_DEPTH */ + { 45369, 0x0000884A }, /* GL_TEXTURE_DEPTH_SIZE */ + { 45391, 0x0000884A }, /* GL_TEXTURE_DEPTH_SIZE_ARB */ + { 45417, 0x00002300 }, /* GL_TEXTURE_ENV */ + { 45432, 0x00002201 }, /* GL_TEXTURE_ENV_COLOR */ + { 45453, 0x00002200 }, /* GL_TEXTURE_ENV_MODE */ + { 45473, 0x00008500 }, /* GL_TEXTURE_FILTER_CONTROL */ + { 45499, 0x00008500 }, /* GL_TEXTURE_FILTER_CONTROL_EXT */ + { 45529, 0x00002500 }, /* GL_TEXTURE_GEN_MODE */ + { 45549, 0x00002500 }, /* GL_TEXTURE_GEN_MODE_OES */ + { 45573, 0x00000C63 }, /* GL_TEXTURE_GEN_Q */ + { 45590, 0x00000C62 }, /* GL_TEXTURE_GEN_R */ + { 45607, 0x00000C60 }, /* GL_TEXTURE_GEN_S */ + { 45624, 0x00008D60 }, /* GL_TEXTURE_GEN_STR_OES */ + { 45647, 0x00000C61 }, /* GL_TEXTURE_GEN_T */ + { 45664, 0x0000819D }, /* GL_TEXTURE_GEQUAL_R_SGIX */ + { 45689, 0x0000805D }, /* GL_TEXTURE_GREEN_SIZE */ + { 45711, 0x0000805D }, /* GL_TEXTURE_GREEN_SIZE_EXT */ + { 45737, 0x00001001 }, /* GL_TEXTURE_HEIGHT */ + { 45755, 0x000080ED }, /* GL_TEXTURE_INDEX_SIZE_EXT */ + { 45781, 0x00008061 }, /* GL_TEXTURE_INTENSITY_SIZE */ + { 45807, 0x00008061 }, /* GL_TEXTURE_INTENSITY_SIZE_EXT */ + { 45837, 0x00001003 }, /* GL_TEXTURE_INTERNAL_FORMAT */ + { 45864, 0x0000819C }, /* GL_TEXTURE_LEQUAL_R_SGIX */ + { 45889, 0x00008501 }, /* GL_TEXTURE_LOD_BIAS */ + { 45909, 0x00008501 }, /* GL_TEXTURE_LOD_BIAS_EXT */ + { 45933, 0x00008190 }, /* GL_TEXTURE_LOD_BIAS_R_SGIX */ + { 45960, 0x0000818E }, /* GL_TEXTURE_LOD_BIAS_S_SGIX */ + { 45987, 0x0000818F }, /* GL_TEXTURE_LOD_BIAS_T_SGIX */ + { 46014, 0x00008060 }, /* GL_TEXTURE_LUMINANCE_SIZE */ + { 46040, 0x00008060 }, /* GL_TEXTURE_LUMINANCE_SIZE_EXT */ + { 46070, 0x00002800 }, /* GL_TEXTURE_MAG_FILTER */ + { 46092, 0x00000BA8 }, /* GL_TEXTURE_MATRIX */ + { 46110, 0x0000898F }, /* GL_TEXTURE_MATRIX_FLOAT_AS_INT_BITS_OES */ + { 46150, 0x000084FE }, /* GL_TEXTURE_MAX_ANISOTROPY_EXT */ + { 46180, 0x0000836B }, /* GL_TEXTURE_MAX_CLAMP_R_SGIX */ + { 46208, 0x00008369 }, /* GL_TEXTURE_MAX_CLAMP_S_SGIX */ + { 46236, 0x0000836A }, /* GL_TEXTURE_MAX_CLAMP_T_SGIX */ + { 46264, 0x0000813D }, /* GL_TEXTURE_MAX_LEVEL */ + { 46285, 0x0000813B }, /* GL_TEXTURE_MAX_LOD */ + { 46304, 0x00002801 }, /* GL_TEXTURE_MIN_FILTER */ + { 46326, 0x0000813A }, /* GL_TEXTURE_MIN_LOD */ + { 46345, 0x00008066 }, /* GL_TEXTURE_PRIORITY */ + { 46365, 0x000085B7 }, /* GL_TEXTURE_RANGE_LENGTH_APPLE */ + { 46395, 0x000085B8 }, /* GL_TEXTURE_RANGE_POINTER_APPLE */ + { 46426, 0x000084F5 }, /* GL_TEXTURE_RECTANGLE */ + { 46447, 0x000084F5 }, /* GL_TEXTURE_RECTANGLE_ARB */ + { 46472, 0x000084F5 }, /* GL_TEXTURE_RECTANGLE_NV */ + { 46496, 0x0000805C }, /* GL_TEXTURE_RED_SIZE */ + { 46516, 0x0000805C }, /* GL_TEXTURE_RED_SIZE_EXT */ + { 46540, 0x00008067 }, /* GL_TEXTURE_RESIDENT */ + { 46560, 0x00008C3F }, /* GL_TEXTURE_SHARED_SIZE */ + { 46583, 0x00000BA5 }, /* GL_TEXTURE_STACK_DEPTH */ + { 46606, 0x000088F1 }, /* GL_TEXTURE_STENCIL_SIZE */ + { 46630, 0x000088F1 }, /* GL_TEXTURE_STENCIL_SIZE_EXT */ + { 46658, 0x000085BC }, /* GL_TEXTURE_STORAGE_HINT_APPLE */ + { 46688, 0x00008065 }, /* GL_TEXTURE_TOO_LARGE_EXT */ + { 46713, 0x0000888F }, /* GL_TEXTURE_UNSIGNED_REMAP_MODE_NV */ + { 46747, 0x00001000 }, /* GL_TEXTURE_WIDTH */ + { 46764, 0x00008072 }, /* GL_TEXTURE_WRAP_R */ + { 46782, 0x00008072 }, /* GL_TEXTURE_WRAP_R_OES */ + { 46804, 0x00002802 }, /* GL_TEXTURE_WRAP_S */ + { 46822, 0x00002803 }, /* GL_TEXTURE_WRAP_T */ + { 46840, 0x0000911B }, /* GL_TIMEOUT_EXPIRED */ + { 46859, 0x000088BF }, /* GL_TIME_ELAPSED_EXT */ + { 46879, 0x00008648 }, /* GL_TRACK_MATRIX_NV */ + { 46898, 0x00008649 }, /* GL_TRACK_MATRIX_TRANSFORM_NV */ + { 46927, 0x00001000 }, /* GL_TRANSFORM_BIT */ + { 46944, 0x00008E22 }, /* GL_TRANSFORM_FEEDBACK */ + { 46966, 0x00008E25 }, /* GL_TRANSFORM_FEEDBACK_BINDING */ + { 46996, 0x00008C8E }, /* GL_TRANSFORM_FEEDBACK_BUFFER */ + { 47025, 0x00008E24 }, /* GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE */ + { 47061, 0x00008C8F }, /* GL_TRANSFORM_FEEDBACK_BUFFER_BINDING */ + { 47098, 0x00008C8F }, /* GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_EXT */ + { 47139, 0x00008C8E }, /* GL_TRANSFORM_FEEDBACK_BUFFER_EXT */ + { 47172, 0x00008C7F }, /* GL_TRANSFORM_FEEDBACK_BUFFER_MODE */ + { 47206, 0x00008C7F }, /* GL_TRANSFORM_FEEDBACK_BUFFER_MODE_EXT */ + { 47244, 0x00008E23 }, /* GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED */ + { 47280, 0x00008C85 }, /* GL_TRANSFORM_FEEDBACK_BUFFER_SIZE */ + { 47314, 0x00008C85 }, /* GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_EXT */ + { 47352, 0x00008C84 }, /* GL_TRANSFORM_FEEDBACK_BUFFER_START */ + { 47387, 0x00008C84 }, /* GL_TRANSFORM_FEEDBACK_BUFFER_START_EXT */ + { 47426, 0x00008C88 }, /* GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN */ + { 47467, 0x00008C88 }, /* GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_EXT */ + { 47512, 0x00008C83 }, /* GL_TRANSFORM_FEEDBACK_VARYINGS */ + { 47543, 0x00008C83 }, /* GL_TRANSFORM_FEEDBACK_VARYINGS_EXT */ + { 47578, 0x00008C76 }, /* GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH */ + { 47619, 0x00008C76 }, /* GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH_EXT */ + { 47664, 0x000084E6 }, /* GL_TRANSPOSE_COLOR_MATRIX */ + { 47690, 0x000084E6 }, /* GL_TRANSPOSE_COLOR_MATRIX_ARB */ + { 47720, 0x000088B7 }, /* GL_TRANSPOSE_CURRENT_MATRIX_ARB */ + { 47752, 0x000084E3 }, /* GL_TRANSPOSE_MODELVIEW_MATRIX */ + { 47782, 0x000084E3 }, /* GL_TRANSPOSE_MODELVIEW_MATRIX_ARB */ + { 47816, 0x0000862C }, /* GL_TRANSPOSE_NV */ + { 47832, 0x000084E4 }, /* GL_TRANSPOSE_PROJECTION_MATRIX */ + { 47863, 0x000084E4 }, /* GL_TRANSPOSE_PROJECTION_MATRIX_ARB */ + { 47898, 0x000084E5 }, /* GL_TRANSPOSE_TEXTURE_MATRIX */ + { 47926, 0x000084E5 }, /* GL_TRANSPOSE_TEXTURE_MATRIX_ARB */ + { 47958, 0x00000004 }, /* GL_TRIANGLES */ + { 47971, 0x0000000C }, /* GL_TRIANGLES_ADJACENCY */ + { 47994, 0x0000000C }, /* GL_TRIANGLES_ADJACENCY_ARB */ + { 48021, 0x00000006 }, /* GL_TRIANGLE_FAN */ + { 48037, 0x00008615 }, /* GL_TRIANGLE_MESH_SUN */ + { 48058, 0x00000005 }, /* GL_TRIANGLE_STRIP */ + { 48076, 0x0000000D }, /* GL_TRIANGLE_STRIP_ADJACENCY */ + { 48104, 0x0000000D }, /* GL_TRIANGLE_STRIP_ADJACENCY_ARB */ + { 48136, 0x00000001 }, /* GL_TRUE */ + { 48144, 0x00008A1C }, /* GL_UNDEFINED_APPLE */ + { 48163, 0x00008255 }, /* GL_UNKNOWN_CONTEXT_RESET_ARB */ + { 48192, 0x00000CF5 }, /* GL_UNPACK_ALIGNMENT */ + { 48212, 0x0000806E }, /* GL_UNPACK_IMAGE_HEIGHT */ + { 48235, 0x00000CF1 }, /* GL_UNPACK_LSB_FIRST */ + { 48255, 0x00000CF2 }, /* GL_UNPACK_ROW_LENGTH */ + { 48276, 0x0000806D }, /* GL_UNPACK_SKIP_IMAGES */ + { 48298, 0x00000CF4 }, /* GL_UNPACK_SKIP_PIXELS */ + { 48320, 0x00000CF3 }, /* GL_UNPACK_SKIP_ROWS */ + { 48340, 0x00000CF0 }, /* GL_UNPACK_SWAP_BYTES */ + { 48361, 0x00009118 }, /* GL_UNSIGNALED */ + { 48375, 0x00001401 }, /* GL_UNSIGNED_BYTE */ + { 48392, 0x00008362 }, /* GL_UNSIGNED_BYTE_2_3_3_REV */ + { 48419, 0x00008032 }, /* GL_UNSIGNED_BYTE_3_3_2 */ + { 48442, 0x00001405 }, /* GL_UNSIGNED_INT */ + { 48458, 0x00008C3B }, /* GL_UNSIGNED_INT_10F_11F_11F_REV */ + { 48490, 0x00008036 }, /* GL_UNSIGNED_INT_10_10_10_2 */ + { 48517, 0x00008DF6 }, /* GL_UNSIGNED_INT_10_10_10_2_OES */ + { 48548, 0x000084FA }, /* GL_UNSIGNED_INT_24_8 */ + { 48569, 0x000084FA }, /* GL_UNSIGNED_INT_24_8_EXT */ + { 48594, 0x000084FA }, /* GL_UNSIGNED_INT_24_8_NV */ + { 48618, 0x000084FA }, /* GL_UNSIGNED_INT_24_8_OES */ + { 48643, 0x00008368 }, /* GL_UNSIGNED_INT_2_10_10_10_REV */ + { 48674, 0x00008368 }, /* GL_UNSIGNED_INT_2_10_10_10_REV_EXT */ + { 48709, 0x00008C3E }, /* GL_UNSIGNED_INT_5_9_9_9_REV */ + { 48737, 0x00008035 }, /* GL_UNSIGNED_INT_8_8_8_8 */ + { 48761, 0x00008367 }, /* GL_UNSIGNED_INT_8_8_8_8_REV */ + { 48789, 0x00008DD1 }, /* GL_UNSIGNED_INT_SAMPLER_1D */ + { 48816, 0x00008DD6 }, /* GL_UNSIGNED_INT_SAMPLER_1D_ARRAY */ + { 48849, 0x00008DD6 }, /* GL_UNSIGNED_INT_SAMPLER_1D_ARRAY_EXT */ + { 48886, 0x00008DD1 }, /* GL_UNSIGNED_INT_SAMPLER_1D_EXT */ + { 48917, 0x00008DD2 }, /* GL_UNSIGNED_INT_SAMPLER_2D */ + { 48944, 0x00008DD7 }, /* GL_UNSIGNED_INT_SAMPLER_2D_ARRAY */ + { 48977, 0x00008DD7 }, /* GL_UNSIGNED_INT_SAMPLER_2D_ARRAY_EXT */ + { 49014, 0x00008DD2 }, /* GL_UNSIGNED_INT_SAMPLER_2D_EXT */ + { 49045, 0x00008DD5 }, /* GL_UNSIGNED_INT_SAMPLER_2D_RECT */ + { 49077, 0x00008DD5 }, /* GL_UNSIGNED_INT_SAMPLER_2D_RECT_EXT */ + { 49113, 0x00008DD3 }, /* GL_UNSIGNED_INT_SAMPLER_3D */ + { 49140, 0x00008DD3 }, /* GL_UNSIGNED_INT_SAMPLER_3D_EXT */ + { 49171, 0x00008DD8 }, /* GL_UNSIGNED_INT_SAMPLER_BUFFER */ + { 49202, 0x00008DD8 }, /* GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT */ + { 49237, 0x00008DD4 }, /* GL_UNSIGNED_INT_SAMPLER_CUBE */ + { 49266, 0x00008DD4 }, /* GL_UNSIGNED_INT_SAMPLER_CUBE_EXT */ + { 49299, 0x00008DC6 }, /* GL_UNSIGNED_INT_VEC2 */ + { 49320, 0x00008DC6 }, /* GL_UNSIGNED_INT_VEC2_EXT */ + { 49345, 0x00008DC7 }, /* GL_UNSIGNED_INT_VEC3 */ + { 49366, 0x00008DC7 }, /* GL_UNSIGNED_INT_VEC3_EXT */ + { 49391, 0x00008DC8 }, /* GL_UNSIGNED_INT_VEC4 */ + { 49412, 0x00008DC8 }, /* GL_UNSIGNED_INT_VEC4_EXT */ + { 49437, 0x00008C17 }, /* GL_UNSIGNED_NORMALIZED */ + { 49460, 0x00001403 }, /* GL_UNSIGNED_SHORT */ + { 49478, 0x00008366 }, /* GL_UNSIGNED_SHORT_1_5_5_5_REV */ + { 49508, 0x00008366 }, /* GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT */ + { 49542, 0x00008033 }, /* GL_UNSIGNED_SHORT_4_4_4_4 */ + { 49568, 0x00008365 }, /* GL_UNSIGNED_SHORT_4_4_4_4_REV */ + { 49598, 0x00008365 }, /* GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT */ + { 49632, 0x00008034 }, /* GL_UNSIGNED_SHORT_5_5_5_1 */ + { 49658, 0x00008363 }, /* GL_UNSIGNED_SHORT_5_6_5 */ + { 49682, 0x00008364 }, /* GL_UNSIGNED_SHORT_5_6_5_REV */ + { 49710, 0x000085BA }, /* GL_UNSIGNED_SHORT_8_8_APPLE */ + { 49738, 0x000085BA }, /* GL_UNSIGNED_SHORT_8_8_MESA */ + { 49765, 0x000085BB }, /* GL_UNSIGNED_SHORT_8_8_REV_APPLE */ + { 49797, 0x000085BB }, /* GL_UNSIGNED_SHORT_8_8_REV_MESA */ + { 49828, 0x00008CA2 }, /* GL_UPPER_LEFT */ + { 49842, 0x00002A20 }, /* GL_V2F */ + { 49849, 0x00002A21 }, /* GL_V3F */ + { 49856, 0x00008B83 }, /* GL_VALIDATE_STATUS */ + { 49875, 0x00001F00 }, /* GL_VENDOR */ + { 49885, 0x00001F02 }, /* GL_VERSION */ + { 49896, 0x00008074 }, /* GL_VERTEX_ARRAY */ + { 49912, 0x000085B5 }, /* GL_VERTEX_ARRAY_BINDING */ + { 49936, 0x000085B5 }, /* GL_VERTEX_ARRAY_BINDING_APPLE */ + { 49966, 0x00008896 }, /* GL_VERTEX_ARRAY_BUFFER_BINDING */ + { 49997, 0x00008896 }, /* GL_VERTEX_ARRAY_BUFFER_BINDING_ARB */ + { 50032, 0x0000808E }, /* GL_VERTEX_ARRAY_POINTER */ + { 50056, 0x0000807A }, /* GL_VERTEX_ARRAY_SIZE */ + { 50077, 0x0000807C }, /* GL_VERTEX_ARRAY_STRIDE */ + { 50100, 0x0000807B }, /* GL_VERTEX_ARRAY_TYPE */ + { 50121, 0x00008650 }, /* GL_VERTEX_ATTRIB_ARRAY0_NV */ + { 50148, 0x0000865A }, /* GL_VERTEX_ATTRIB_ARRAY10_NV */ + { 50176, 0x0000865B }, /* GL_VERTEX_ATTRIB_ARRAY11_NV */ + { 50204, 0x0000865C }, /* GL_VERTEX_ATTRIB_ARRAY12_NV */ + { 50232, 0x0000865D }, /* GL_VERTEX_ATTRIB_ARRAY13_NV */ + { 50260, 0x0000865E }, /* GL_VERTEX_ATTRIB_ARRAY14_NV */ + { 50288, 0x0000865F }, /* GL_VERTEX_ATTRIB_ARRAY15_NV */ + { 50316, 0x00008651 }, /* GL_VERTEX_ATTRIB_ARRAY1_NV */ + { 50343, 0x00008652 }, /* GL_VERTEX_ATTRIB_ARRAY2_NV */ + { 50370, 0x00008653 }, /* GL_VERTEX_ATTRIB_ARRAY3_NV */ + { 50397, 0x00008654 }, /* GL_VERTEX_ATTRIB_ARRAY4_NV */ + { 50424, 0x00008655 }, /* GL_VERTEX_ATTRIB_ARRAY5_NV */ + { 50451, 0x00008656 }, /* GL_VERTEX_ATTRIB_ARRAY6_NV */ + { 50478, 0x00008657 }, /* GL_VERTEX_ATTRIB_ARRAY7_NV */ + { 50505, 0x00008658 }, /* GL_VERTEX_ATTRIB_ARRAY8_NV */ + { 50532, 0x00008659 }, /* GL_VERTEX_ATTRIB_ARRAY9_NV */ + { 50559, 0x0000889F }, /* GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING */ + { 50597, 0x0000889F }, /* GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB */ + { 50639, 0x000088FE }, /* GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB */ + { 50674, 0x00008622 }, /* GL_VERTEX_ATTRIB_ARRAY_ENABLED */ + { 50705, 0x00008622 }, /* GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB */ + { 50740, 0x000088FD }, /* GL_VERTEX_ATTRIB_ARRAY_INTEGER */ + { 50771, 0x000088FD }, /* GL_VERTEX_ATTRIB_ARRAY_INTEGER_EXT */ + { 50806, 0x0000886A }, /* GL_VERTEX_ATTRIB_ARRAY_NORMALIZED */ + { 50840, 0x0000886A }, /* GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB */ + { 50878, 0x00008645 }, /* GL_VERTEX_ATTRIB_ARRAY_POINTER */ + { 50909, 0x00008645 }, /* GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB */ + { 50944, 0x00008623 }, /* GL_VERTEX_ATTRIB_ARRAY_SIZE */ + { 50972, 0x00008623 }, /* GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB */ + { 51004, 0x00008624 }, /* GL_VERTEX_ATTRIB_ARRAY_STRIDE */ + { 51034, 0x00008624 }, /* GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB */ + { 51068, 0x00008625 }, /* GL_VERTEX_ATTRIB_ARRAY_TYPE */ + { 51096, 0x00008625 }, /* GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB */ + { 51128, 0x000086A7 }, /* GL_VERTEX_BLEND_ARB */ + { 51148, 0x00008620 }, /* GL_VERTEX_PROGRAM_ARB */ + { 51170, 0x0000864A }, /* GL_VERTEX_PROGRAM_BINDING_NV */ + { 51199, 0x00008620 }, /* GL_VERTEX_PROGRAM_NV */ + { 51220, 0x00008642 }, /* GL_VERTEX_PROGRAM_POINT_SIZE */ + { 51249, 0x00008642 }, /* GL_VERTEX_PROGRAM_POINT_SIZE_ARB */ + { 51282, 0x00008642 }, /* GL_VERTEX_PROGRAM_POINT_SIZE_NV */ + { 51314, 0x00008643 }, /* GL_VERTEX_PROGRAM_TWO_SIDE */ + { 51341, 0x00008643 }, /* GL_VERTEX_PROGRAM_TWO_SIDE_ARB */ + { 51372, 0x00008643 }, /* GL_VERTEX_PROGRAM_TWO_SIDE_NV */ + { 51402, 0x00008B31 }, /* GL_VERTEX_SHADER */ + { 51419, 0x00008B31 }, /* GL_VERTEX_SHADER_ARB */ + { 51440, 0x00008621 }, /* GL_VERTEX_STATE_PROGRAM_NV */ + { 51467, 0x00000BA2 }, /* GL_VIEWPORT */ + { 51479, 0x00000800 }, /* GL_VIEWPORT_BIT */ + { 51495, 0x00008A1A }, /* GL_VOLATILE_APPLE */ + { 51513, 0x0000911D }, /* GL_WAIT_FAILED */ + { 51528, 0x000086AD }, /* GL_WEIGHT_ARRAY_ARB */ + { 51548, 0x0000889E }, /* GL_WEIGHT_ARRAY_BUFFER_BINDING */ + { 51579, 0x0000889E }, /* GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB */ + { 51614, 0x0000889E }, /* GL_WEIGHT_ARRAY_BUFFER_BINDING_OES */ + { 51649, 0x000086AD }, /* GL_WEIGHT_ARRAY_OES */ + { 51669, 0x000086AC }, /* GL_WEIGHT_ARRAY_POINTER_ARB */ + { 51697, 0x000086AC }, /* GL_WEIGHT_ARRAY_POINTER_OES */ + { 51725, 0x000086AB }, /* GL_WEIGHT_ARRAY_SIZE_ARB */ + { 51750, 0x000086AB }, /* GL_WEIGHT_ARRAY_SIZE_OES */ + { 51775, 0x000086AA }, /* GL_WEIGHT_ARRAY_STRIDE_ARB */ + { 51802, 0x000086AA }, /* GL_WEIGHT_ARRAY_STRIDE_OES */ + { 51829, 0x000086A9 }, /* GL_WEIGHT_ARRAY_TYPE_ARB */ + { 51854, 0x000086A9 }, /* GL_WEIGHT_ARRAY_TYPE_OES */ + { 51879, 0x000086A6 }, /* GL_WEIGHT_SUM_UNITY_ARB */ + { 51903, 0x000081D4 }, /* GL_WRAP_BORDER_SUN */ + { 51922, 0x000088B9 }, /* GL_WRITE_ONLY */ + { 51936, 0x000088B9 }, /* GL_WRITE_ONLY_ARB */ + { 51954, 0x000088B9 }, /* GL_WRITE_ONLY_OES */ + { 51972, 0x00001506 }, /* GL_XOR */ + { 51979, 0x000085B9 }, /* GL_YCBCR_422_APPLE */ + { 51998, 0x00008757 }, /* GL_YCBCR_MESA */ + { 52012, 0x00000000 }, /* GL_ZERO */ + { 52020, 0x00000D16 }, /* GL_ZOOM_X */ + { 52030, 0x00000D17 }, /* GL_ZOOM_Y */ +}; + +static const unsigned reduced_enums[1564] = +{ + 539, /* GL_FALSE */ + 835, /* GL_LINES */ + 839, /* GL_LINE_LOOP */ + 846, /* GL_LINE_STRIP */ + 2157, /* GL_TRIANGLES */ + 2162, /* GL_TRIANGLE_STRIP */ + 2160, /* GL_TRIANGLE_FAN */ + 1522, /* GL_QUADS */ + 1526, /* GL_QUAD_STRIP */ + 1390, /* GL_POLYGON */ + 836, /* GL_LINES_ADJACENCY */ + 847, /* GL_LINE_STRIP_ADJACENCY */ + 2158, /* GL_TRIANGLES_ADJACENCY */ + 2163, /* GL_TRIANGLE_STRIP_ADJACENCY */ + 1402, /* GL_POLYGON_STIPPLE_BIT */ + 1345, /* GL_PIXEL_MODE_BIT */ + 822, /* GL_LIGHTING_BIT */ + 573, /* GL_FOG_BIT */ + 8, /* GL_ACCUM */ + 858, /* GL_LOAD */ + 1612, /* GL_RETURN */ + 1210, /* GL_MULT */ + 24, /* GL_ADD */ + 1226, /* GL_NEVER */ + 812, /* GL_LESS */ + 529, /* GL_EQUAL */ + 811, /* GL_LEQUAL */ + 696, /* GL_GREATER */ + 1243, /* GL_NOTEQUAL */ + 695, /* GL_GEQUAL */ + 55, /* GL_ALWAYS */ + 1821, /* GL_SRC_COLOR */ + 1278, /* GL_ONE_MINUS_SRC_COLOR */ + 1819, /* GL_SRC_ALPHA */ + 1277, /* GL_ONE_MINUS_SRC_ALPHA */ + 508, /* GL_DST_ALPHA */ + 1275, /* GL_ONE_MINUS_DST_ALPHA */ + 509, /* GL_DST_COLOR */ + 1276, /* GL_ONE_MINUS_DST_COLOR */ + 1820, /* GL_SRC_ALPHA_SATURATE */ + 672, /* GL_FRONT_LEFT */ + 673, /* GL_FRONT_RIGHT */ + 77, /* GL_BACK_LEFT */ + 78, /* GL_BACK_RIGHT */ + 669, /* GL_FRONT */ + 76, /* GL_BACK */ + 810, /* GL_LEFT */ + 1702, /* GL_RIGHT */ + 670, /* GL_FRONT_AND_BACK */ + 71, /* GL_AUX0 */ + 72, /* GL_AUX1 */ + 73, /* GL_AUX2 */ + 74, /* GL_AUX3 */ + 798, /* GL_INVALID_ENUM */ + 803, /* GL_INVALID_VALUE */ + 802, /* GL_INVALID_OPERATION */ + 1826, /* GL_STACK_OVERFLOW */ + 1827, /* GL_STACK_UNDERFLOW */ + 1303, /* GL_OUT_OF_MEMORY */ + 799, /* GL_INVALID_FRAMEBUFFER_OPERATION */ + 0, /* GL_2D */ + 2, /* GL_3D */ + 3, /* GL_3D_COLOR */ + 4, /* GL_3D_COLOR_TEXTURE */ + 6, /* GL_4D_COLOR_TEXTURE */ + 1323, /* GL_PASS_THROUGH_TOKEN */ + 1389, /* GL_POINT_TOKEN */ + 849, /* GL_LINE_TOKEN */ + 1403, /* GL_POLYGON_TOKEN */ + 87, /* GL_BITMAP_TOKEN */ + 507, /* GL_DRAW_PIXEL_TOKEN */ + 353, /* GL_COPY_PIXEL_TOKEN */ + 840, /* GL_LINE_RESET_TOKEN */ + 532, /* GL_EXP */ + 533, /* GL_EXP2 */ + 390, /* GL_CW */ + 154, /* GL_CCW */ + 187, /* GL_COEFF */ + 1300, /* GL_ORDER */ + 444, /* GL_DOMAIN */ + 363, /* GL_CURRENT_COLOR */ + 366, /* GL_CURRENT_INDEX */ + 372, /* GL_CURRENT_NORMAL */ + 386, /* GL_CURRENT_TEXTURE_COORDS */ + 378, /* GL_CURRENT_RASTER_COLOR */ + 380, /* GL_CURRENT_RASTER_INDEX */ + 384, /* GL_CURRENT_RASTER_TEXTURE_COORDS */ + 381, /* GL_CURRENT_RASTER_POSITION */ + 382, /* GL_CURRENT_RASTER_POSITION_VALID */ + 379, /* GL_CURRENT_RASTER_DISTANCE */ + 1381, /* GL_POINT_SMOOTH */ + 1365, /* GL_POINT_SIZE */ + 1380, /* GL_POINT_SIZE_RANGE */ + 1371, /* GL_POINT_SIZE_GRANULARITY */ + 841, /* GL_LINE_SMOOTH */ + 850, /* GL_LINE_WIDTH */ + 852, /* GL_LINE_WIDTH_RANGE */ + 851, /* GL_LINE_WIDTH_GRANULARITY */ + 843, /* GL_LINE_STIPPLE */ + 844, /* GL_LINE_STIPPLE_PATTERN */ + 845, /* GL_LINE_STIPPLE_REPEAT */ + 857, /* GL_LIST_MODE */ + 1065, /* GL_MAX_LIST_NESTING */ + 854, /* GL_LIST_BASE */ + 856, /* GL_LIST_INDEX */ + 1392, /* GL_POLYGON_MODE */ + 1399, /* GL_POLYGON_SMOOTH */ + 1401, /* GL_POLYGON_STIPPLE */ + 518, /* GL_EDGE_FLAG */ + 356, /* GL_CULL_FACE */ + 357, /* GL_CULL_FACE_MODE */ + 671, /* GL_FRONT_FACE */ + 821, /* GL_LIGHTING */ + 826, /* GL_LIGHT_MODEL_LOCAL_VIEWER */ + 827, /* GL_LIGHT_MODEL_TWO_SIDE */ + 823, /* GL_LIGHT_MODEL_AMBIENT */ + 1768, /* GL_SHADE_MODEL */ + 235, /* GL_COLOR_MATERIAL_FACE */ + 236, /* GL_COLOR_MATERIAL_PARAMETER */ + 234, /* GL_COLOR_MATERIAL */ + 572, /* GL_FOG */ + 594, /* GL_FOG_INDEX */ + 590, /* GL_FOG_DENSITY */ + 598, /* GL_FOG_START */ + 592, /* GL_FOG_END */ + 595, /* GL_FOG_MODE */ + 574, /* GL_FOG_COLOR */ + 429, /* GL_DEPTH_RANGE */ + 438, /* GL_DEPTH_TEST */ + 441, /* GL_DEPTH_WRITEMASK */ + 414, /* GL_DEPTH_CLEAR_VALUE */ + 428, /* GL_DEPTH_FUNC */ + 12, /* GL_ACCUM_CLEAR_VALUE */ + 1871, /* GL_STENCIL_TEST */ + 1852, /* GL_STENCIL_CLEAR_VALUE */ + 1854, /* GL_STENCIL_FUNC */ + 1873, /* GL_STENCIL_VALUE_MASK */ + 1853, /* GL_STENCIL_FAIL */ + 1868, /* GL_STENCIL_PASS_DEPTH_FAIL */ + 1869, /* GL_STENCIL_PASS_DEPTH_PASS */ + 1870, /* GL_STENCIL_REF */ + 1874, /* GL_STENCIL_WRITEMASK */ + 1015, /* GL_MATRIX_MODE */ + 1232, /* GL_NORMALIZE */ + 2290, /* GL_VIEWPORT */ + 1205, /* GL_MODELVIEW_STACK_DEPTH */ + 1496, /* GL_PROJECTION_STACK_DEPTH */ + 2111, /* GL_TEXTURE_STACK_DEPTH */ + 1202, /* GL_MODELVIEW_MATRIX */ + 1494, /* GL_PROJECTION_MATRIX */ + 2091, /* GL_TEXTURE_MATRIX */ + 69, /* GL_ATTRIB_STACK_DEPTH */ + 169, /* GL_CLIENT_ATTRIB_STACK_DEPTH */ + 51, /* GL_ALPHA_TEST */ + 52, /* GL_ALPHA_TEST_FUNC */ + 53, /* GL_ALPHA_TEST_REF */ + 443, /* GL_DITHER */ + 91, /* GL_BLEND_DST */ + 105, /* GL_BLEND_SRC */ + 88, /* GL_BLEND */ + 860, /* GL_LOGIC_OP_MODE */ + 745, /* GL_INDEX_LOGIC_OP */ + 233, /* GL_COLOR_LOGIC_OP */ + 75, /* GL_AUX_BUFFERS */ + 454, /* GL_DRAW_BUFFER */ + 1549, /* GL_READ_BUFFER */ + 1745, /* GL_SCISSOR_BOX */ + 1746, /* GL_SCISSOR_TEST */ + 744, /* GL_INDEX_CLEAR_VALUE */ + 749, /* GL_INDEX_WRITEMASK */ + 230, /* GL_COLOR_CLEAR_VALUE */ + 272, /* GL_COLOR_WRITEMASK */ + 746, /* GL_INDEX_MODE */ + 1691, /* GL_RGBA_MODE */ + 453, /* GL_DOUBLEBUFFER */ + 1875, /* GL_STEREO */ + 1603, /* GL_RENDER_MODE */ + 1324, /* GL_PERSPECTIVE_CORRECTION_HINT */ + 1382, /* GL_POINT_SMOOTH_HINT */ + 842, /* GL_LINE_SMOOTH_HINT */ + 1400, /* GL_POLYGON_SMOOTH_HINT */ + 593, /* GL_FOG_HINT */ + 2071, /* GL_TEXTURE_GEN_S */ + 2073, /* GL_TEXTURE_GEN_T */ + 2070, /* GL_TEXTURE_GEN_R */ + 2069, /* GL_TEXTURE_GEN_Q */ + 1337, /* GL_PIXEL_MAP_I_TO_I */ + 1343, /* GL_PIXEL_MAP_S_TO_S */ + 1339, /* GL_PIXEL_MAP_I_TO_R */ + 1335, /* GL_PIXEL_MAP_I_TO_G */ + 1333, /* GL_PIXEL_MAP_I_TO_B */ + 1331, /* GL_PIXEL_MAP_I_TO_A */ + 1341, /* GL_PIXEL_MAP_R_TO_R */ + 1329, /* GL_PIXEL_MAP_G_TO_G */ + 1327, /* GL_PIXEL_MAP_B_TO_B */ + 1325, /* GL_PIXEL_MAP_A_TO_A */ + 1338, /* GL_PIXEL_MAP_I_TO_I_SIZE */ + 1344, /* GL_PIXEL_MAP_S_TO_S_SIZE */ + 1340, /* GL_PIXEL_MAP_I_TO_R_SIZE */ + 1336, /* GL_PIXEL_MAP_I_TO_G_SIZE */ + 1334, /* GL_PIXEL_MAP_I_TO_B_SIZE */ + 1332, /* GL_PIXEL_MAP_I_TO_A_SIZE */ + 1342, /* GL_PIXEL_MAP_R_TO_R_SIZE */ + 1330, /* GL_PIXEL_MAP_G_TO_G_SIZE */ + 1328, /* GL_PIXEL_MAP_B_TO_B_SIZE */ + 1326, /* GL_PIXEL_MAP_A_TO_A_SIZE */ + 2175, /* GL_UNPACK_SWAP_BYTES */ + 2170, /* GL_UNPACK_LSB_FIRST */ + 2171, /* GL_UNPACK_ROW_LENGTH */ + 2174, /* GL_UNPACK_SKIP_ROWS */ + 2173, /* GL_UNPACK_SKIP_PIXELS */ + 2168, /* GL_UNPACK_ALIGNMENT */ + 1312, /* GL_PACK_SWAP_BYTES */ + 1307, /* GL_PACK_LSB_FIRST */ + 1308, /* GL_PACK_ROW_LENGTH */ + 1311, /* GL_PACK_SKIP_ROWS */ + 1310, /* GL_PACK_SKIP_PIXELS */ + 1304, /* GL_PACK_ALIGNMENT */ + 956, /* GL_MAP_COLOR */ + 961, /* GL_MAP_STENCIL */ + 748, /* GL_INDEX_SHIFT */ + 747, /* GL_INDEX_OFFSET */ + 1565, /* GL_RED_SCALE */ + 1561, /* GL_RED_BIAS */ + 2316, /* GL_ZOOM_X */ + 2317, /* GL_ZOOM_Y */ + 702, /* GL_GREEN_SCALE */ + 698, /* GL_GREEN_BIAS */ + 115, /* GL_BLUE_SCALE */ + 111, /* GL_BLUE_BIAS */ + 50, /* GL_ALPHA_SCALE */ + 47, /* GL_ALPHA_BIAS */ + 430, /* GL_DEPTH_SCALE */ + 406, /* GL_DEPTH_BIAS */ + 1047, /* GL_MAX_EVAL_ORDER */ + 1064, /* GL_MAX_LIGHTS */ + 1027, /* GL_MAX_CLIP_DISTANCES */ + 1120, /* GL_MAX_TEXTURE_SIZE */ + 1071, /* GL_MAX_PIXEL_MAP_TABLE */ + 1023, /* GL_MAX_ATTRIB_STACK_DEPTH */ + 1067, /* GL_MAX_MODELVIEW_STACK_DEPTH */ + 1068, /* GL_MAX_NAME_STACK_DEPTH */ + 1099, /* GL_MAX_PROJECTION_STACK_DEPTH */ + 1121, /* GL_MAX_TEXTURE_STACK_DEPTH */ + 1147, /* GL_MAX_VIEWPORT_DIMS */ + 1024, /* GL_MAX_CLIENT_ATTRIB_STACK_DEPTH */ + 1885, /* GL_SUBPIXEL_BITS */ + 743, /* GL_INDEX_BITS */ + 1562, /* GL_RED_BITS */ + 699, /* GL_GREEN_BITS */ + 112, /* GL_BLUE_BITS */ + 48, /* GL_ALPHA_BITS */ + 407, /* GL_DEPTH_BITS */ + 1849, /* GL_STENCIL_BITS */ + 14, /* GL_ACCUM_RED_BITS */ + 13, /* GL_ACCUM_GREEN_BITS */ + 10, /* GL_ACCUM_BLUE_BITS */ + 9, /* GL_ACCUM_ALPHA_BITS */ + 1219, /* GL_NAME_STACK_DEPTH */ + 70, /* GL_AUTO_NORMAL */ + 902, /* GL_MAP1_COLOR_4 */ + 905, /* GL_MAP1_INDEX */ + 906, /* GL_MAP1_NORMAL */ + 907, /* GL_MAP1_TEXTURE_COORD_1 */ + 908, /* GL_MAP1_TEXTURE_COORD_2 */ + 909, /* GL_MAP1_TEXTURE_COORD_3 */ + 910, /* GL_MAP1_TEXTURE_COORD_4 */ + 911, /* GL_MAP1_VERTEX_3 */ + 912, /* GL_MAP1_VERTEX_4 */ + 929, /* GL_MAP2_COLOR_4 */ + 932, /* GL_MAP2_INDEX */ + 933, /* GL_MAP2_NORMAL */ + 934, /* GL_MAP2_TEXTURE_COORD_1 */ + 935, /* GL_MAP2_TEXTURE_COORD_2 */ + 936, /* GL_MAP2_TEXTURE_COORD_3 */ + 937, /* GL_MAP2_TEXTURE_COORD_4 */ + 938, /* GL_MAP2_VERTEX_3 */ + 939, /* GL_MAP2_VERTEX_4 */ + 903, /* GL_MAP1_GRID_DOMAIN */ + 904, /* GL_MAP1_GRID_SEGMENTS */ + 930, /* GL_MAP2_GRID_DOMAIN */ + 931, /* GL_MAP2_GRID_SEGMENTS */ + 1968, /* GL_TEXTURE_1D */ + 1971, /* GL_TEXTURE_2D */ + 542, /* GL_FEEDBACK_BUFFER_POINTER */ + 543, /* GL_FEEDBACK_BUFFER_SIZE */ + 544, /* GL_FEEDBACK_BUFFER_TYPE */ + 1755, /* GL_SELECTION_BUFFER_POINTER */ + 1756, /* GL_SELECTION_BUFFER_SIZE */ + 2117, /* GL_TEXTURE_WIDTH */ + 2077, /* GL_TEXTURE_HEIGHT */ + 2021, /* GL_TEXTURE_COMPONENTS */ + 1999, /* GL_TEXTURE_BORDER_COLOR */ + 1998, /* GL_TEXTURE_BORDER */ + 445, /* GL_DONT_CARE */ + 540, /* GL_FASTEST */ + 1227, /* GL_NICEST */ + 56, /* GL_AMBIENT */ + 442, /* GL_DIFFUSE */ + 1808, /* GL_SPECULAR */ + 1404, /* GL_POSITION */ + 1811, /* GL_SPOT_DIRECTION */ + 1812, /* GL_SPOT_EXPONENT */ + 1810, /* GL_SPOT_CUTOFF */ + 320, /* GL_CONSTANT_ATTENUATION */ + 830, /* GL_LINEAR_ATTENUATION */ + 1521, /* GL_QUADRATIC_ATTENUATION */ + 287, /* GL_COMPILE */ + 288, /* GL_COMPILE_AND_EXECUTE */ + 149, /* GL_BYTE */ + 2177, /* GL_UNSIGNED_BYTE */ + 1773, /* GL_SHORT */ + 2216, /* GL_UNSIGNED_SHORT */ + 752, /* GL_INT */ + 2180, /* GL_UNSIGNED_INT */ + 553, /* GL_FLOAT */ + 1, /* GL_2_BYTES */ + 5, /* GL_3_BYTES */ + 7, /* GL_4_BYTES */ + 452, /* GL_DOUBLE */ + 704, /* GL_HALF_FLOAT */ + 548, /* GL_FIXED */ + 165, /* GL_CLEAR */ + 58, /* GL_AND */ + 60, /* GL_AND_REVERSE */ + 351, /* GL_COPY */ + 59, /* GL_AND_INVERTED */ + 1230, /* GL_NOOP */ + 2312, /* GL_XOR */ + 1299, /* GL_OR */ + 1231, /* GL_NOR */ + 530, /* GL_EQUIV */ + 806, /* GL_INVERT */ + 1302, /* GL_OR_REVERSE */ + 352, /* GL_COPY_INVERTED */ + 1301, /* GL_OR_INVERTED */ + 1220, /* GL_NAND */ + 1762, /* GL_SET */ + 527, /* GL_EMISSION */ + 1772, /* GL_SHININESS */ + 57, /* GL_AMBIENT_AND_DIFFUSE */ + 232, /* GL_COLOR_INDEXES */ + 1169, /* GL_MODELVIEW */ + 1493, /* GL_PROJECTION */ + 1903, /* GL_TEXTURE */ + 188, /* GL_COLOR */ + 399, /* GL_DEPTH */ + 1834, /* GL_STENCIL */ + 231, /* GL_COLOR_INDEX */ + 1855, /* GL_STENCIL_INDEX */ + 415, /* GL_DEPTH_COMPONENT */ + 1558, /* GL_RED */ + 697, /* GL_GREEN */ + 110, /* GL_BLUE */ + 32, /* GL_ALPHA */ + 1615, /* GL_RGB */ + 1655, /* GL_RGBA */ + 865, /* GL_LUMINANCE */ + 892, /* GL_LUMINANCE_ALPHA */ + 86, /* GL_BITMAP */ + 1354, /* GL_POINT */ + 828, /* GL_LINE */ + 545, /* GL_FILL */ + 1572, /* GL_RENDER */ + 541, /* GL_FEEDBACK */ + 1754, /* GL_SELECT */ + 552, /* GL_FLAT */ + 1783, /* GL_SMOOTH */ + 807, /* GL_KEEP */ + 1605, /* GL_REPLACE */ + 733, /* GL_INCR */ + 395, /* GL_DECR */ + 2233, /* GL_VENDOR */ + 1602, /* GL_RENDERER */ + 2234, /* GL_VERSION */ + 534, /* GL_EXTENSIONS */ + 1703, /* GL_S */ + 1894, /* GL_T */ + 1541, /* GL_R */ + 1520, /* GL_Q */ + 1206, /* GL_MODULATE */ + 394, /* GL_DECAL */ + 2064, /* GL_TEXTURE_ENV_MODE */ + 2063, /* GL_TEXTURE_ENV_COLOR */ + 2062, /* GL_TEXTURE_ENV */ + 535, /* GL_EYE_LINEAR */ + 1260, /* GL_OBJECT_LINEAR */ + 1809, /* GL_SPHERE_MAP */ + 2067, /* GL_TEXTURE_GEN_MODE */ + 1262, /* GL_OBJECT_PLANE */ + 536, /* GL_EYE_PLANE */ + 1221, /* GL_NEAREST */ + 829, /* GL_LINEAR */ + 1225, /* GL_NEAREST_MIPMAP_NEAREST */ + 834, /* GL_LINEAR_MIPMAP_NEAREST */ + 1224, /* GL_NEAREST_MIPMAP_LINEAR */ + 833, /* GL_LINEAR_MIPMAP_LINEAR */ + 2090, /* GL_TEXTURE_MAG_FILTER */ + 2099, /* GL_TEXTURE_MIN_FILTER */ + 2120, /* GL_TEXTURE_WRAP_S */ + 2121, /* GL_TEXTURE_WRAP_T */ + 155, /* GL_CLAMP */ + 1604, /* GL_REPEAT */ + 1398, /* GL_POLYGON_OFFSET_UNITS */ + 1397, /* GL_POLYGON_OFFSET_POINT */ + 1396, /* GL_POLYGON_OFFSET_LINE */ + 1544, /* GL_R3_G3_B2 */ + 2230, /* GL_V2F */ + 2231, /* GL_V3F */ + 152, /* GL_C4UB_V2F */ + 153, /* GL_C4UB_V3F */ + 150, /* GL_C3F_V3F */ + 1218, /* GL_N3F_V3F */ + 151, /* GL_C4F_N3F_V3F */ + 1899, /* GL_T2F_V3F */ + 1901, /* GL_T4F_V4F */ + 1897, /* GL_T2F_C4UB_V3F */ + 1895, /* GL_T2F_C3F_V3F */ + 1898, /* GL_T2F_N3F_V3F */ + 1896, /* GL_T2F_C4F_N3F_V3F */ + 1900, /* GL_T4F_C4F_N3F_V4F */ + 172, /* GL_CLIP_DISTANCE0 */ + 173, /* GL_CLIP_DISTANCE1 */ + 174, /* GL_CLIP_DISTANCE2 */ + 175, /* GL_CLIP_DISTANCE3 */ + 176, /* GL_CLIP_DISTANCE4 */ + 177, /* GL_CLIP_DISTANCE5 */ + 178, /* GL_CLIP_DISTANCE6 */ + 179, /* GL_CLIP_DISTANCE7 */ + 813, /* GL_LIGHT0 */ + 814, /* GL_LIGHT1 */ + 815, /* GL_LIGHT2 */ + 816, /* GL_LIGHT3 */ + 817, /* GL_LIGHT4 */ + 818, /* GL_LIGHT5 */ + 819, /* GL_LIGHT6 */ + 820, /* GL_LIGHT7 */ + 708, /* GL_HINT_BIT */ + 322, /* GL_CONSTANT_COLOR */ + 1273, /* GL_ONE_MINUS_CONSTANT_COLOR */ + 317, /* GL_CONSTANT_ALPHA */ + 1271, /* GL_ONE_MINUS_CONSTANT_ALPHA */ + 89, /* GL_BLEND_COLOR */ + 674, /* GL_FUNC_ADD */ + 1150, /* GL_MIN */ + 1018, /* GL_MAX */ + 96, /* GL_BLEND_EQUATION */ + 680, /* GL_FUNC_SUBTRACT */ + 677, /* GL_FUNC_REVERSE_SUBTRACT */ + 331, /* GL_CONVOLUTION_1D */ + 332, /* GL_CONVOLUTION_2D */ + 1757, /* GL_SEPARABLE_2D */ + 335, /* GL_CONVOLUTION_BORDER_MODE */ + 339, /* GL_CONVOLUTION_FILTER_SCALE */ + 337, /* GL_CONVOLUTION_FILTER_BIAS */ + 1559, /* GL_REDUCE */ + 341, /* GL_CONVOLUTION_FORMAT */ + 345, /* GL_CONVOLUTION_WIDTH */ + 343, /* GL_CONVOLUTION_HEIGHT */ + 1037, /* GL_MAX_CONVOLUTION_WIDTH */ + 1035, /* GL_MAX_CONVOLUTION_HEIGHT */ + 1437, /* GL_POST_CONVOLUTION_RED_SCALE */ + 1433, /* GL_POST_CONVOLUTION_GREEN_SCALE */ + 1428, /* GL_POST_CONVOLUTION_BLUE_SCALE */ + 1424, /* GL_POST_CONVOLUTION_ALPHA_SCALE */ + 1435, /* GL_POST_CONVOLUTION_RED_BIAS */ + 1431, /* GL_POST_CONVOLUTION_GREEN_BIAS */ + 1426, /* GL_POST_CONVOLUTION_BLUE_BIAS */ + 1422, /* GL_POST_CONVOLUTION_ALPHA_BIAS */ + 709, /* GL_HISTOGRAM */ + 1500, /* GL_PROXY_HISTOGRAM */ + 725, /* GL_HISTOGRAM_WIDTH */ + 715, /* GL_HISTOGRAM_FORMAT */ + 721, /* GL_HISTOGRAM_RED_SIZE */ + 717, /* GL_HISTOGRAM_GREEN_SIZE */ + 712, /* GL_HISTOGRAM_BLUE_SIZE */ + 710, /* GL_HISTOGRAM_ALPHA_SIZE */ + 719, /* GL_HISTOGRAM_LUMINANCE_SIZE */ + 723, /* GL_HISTOGRAM_SINK */ + 1151, /* GL_MINMAX */ + 1153, /* GL_MINMAX_FORMAT */ + 1155, /* GL_MINMAX_SINK */ + 1902, /* GL_TABLE_TOO_LARGE_EXT */ + 2179, /* GL_UNSIGNED_BYTE_3_3_2 */ + 2219, /* GL_UNSIGNED_SHORT_4_4_4_4 */ + 2222, /* GL_UNSIGNED_SHORT_5_5_5_1 */ + 2191, /* GL_UNSIGNED_INT_8_8_8_8 */ + 2182, /* GL_UNSIGNED_INT_10_10_10_2 */ + 1395, /* GL_POLYGON_OFFSET_FILL */ + 1394, /* GL_POLYGON_OFFSET_FACTOR */ + 1393, /* GL_POLYGON_OFFSET_BIAS */ + 1608, /* GL_RESCALE_NORMAL */ + 41, /* GL_ALPHA4 */ + 43, /* GL_ALPHA8 */ + 33, /* GL_ALPHA12 */ + 35, /* GL_ALPHA16 */ + 880, /* GL_LUMINANCE4 */ + 886, /* GL_LUMINANCE8 */ + 866, /* GL_LUMINANCE12 */ + 872, /* GL_LUMINANCE16 */ + 881, /* GL_LUMINANCE4_ALPHA4 */ + 884, /* GL_LUMINANCE6_ALPHA2 */ + 889, /* GL_LUMINANCE8_ALPHA8 */ + 869, /* GL_LUMINANCE12_ALPHA4 */ + 867, /* GL_LUMINANCE12_ALPHA12 */ + 875, /* GL_LUMINANCE16_ALPHA16 */ + 753, /* GL_INTENSITY */ + 762, /* GL_INTENSITY4 */ + 764, /* GL_INTENSITY8 */ + 754, /* GL_INTENSITY12 */ + 756, /* GL_INTENSITY16 */ + 1630, /* GL_RGB2_EXT */ + 1636, /* GL_RGB4 */ + 1639, /* GL_RGB5 */ + 1646, /* GL_RGB8 */ + 1616, /* GL_RGB10 */ + 1620, /* GL_RGB12 */ + 1622, /* GL_RGB16 */ + 1666, /* GL_RGBA2 */ + 1673, /* GL_RGBA4 */ + 1642, /* GL_RGB5_A1 */ + 1678, /* GL_RGBA8 */ + 1617, /* GL_RGB10_A2 */ + 1656, /* GL_RGBA12 */ + 1658, /* GL_RGBA16 */ + 2107, /* GL_TEXTURE_RED_SIZE */ + 2075, /* GL_TEXTURE_GREEN_SIZE */ + 1996, /* GL_TEXTURE_BLUE_SIZE */ + 1976, /* GL_TEXTURE_ALPHA_SIZE */ + 2088, /* GL_TEXTURE_LUMINANCE_SIZE */ + 2079, /* GL_TEXTURE_INTENSITY_SIZE */ + 1606, /* GL_REPLACE_EXT */ + 1504, /* GL_PROXY_TEXTURE_1D */ + 1508, /* GL_PROXY_TEXTURE_2D */ + 2115, /* GL_TEXTURE_TOO_LARGE_EXT */ + 2101, /* GL_TEXTURE_PRIORITY */ + 2109, /* GL_TEXTURE_RESIDENT */ + 1979, /* GL_TEXTURE_BINDING_1D */ + 1982, /* GL_TEXTURE_BINDING_2D */ + 1985, /* GL_TEXTURE_BINDING_3D */ + 1309, /* GL_PACK_SKIP_IMAGES */ + 1305, /* GL_PACK_IMAGE_HEIGHT */ + 2172, /* GL_UNPACK_SKIP_IMAGES */ + 2169, /* GL_UNPACK_IMAGE_HEIGHT */ + 1974, /* GL_TEXTURE_3D */ + 1512, /* GL_PROXY_TEXTURE_3D */ + 2059, /* GL_TEXTURE_DEPTH */ + 2118, /* GL_TEXTURE_WRAP_R */ + 1019, /* GL_MAX_3D_TEXTURE_SIZE */ + 2235, /* GL_VERTEX_ARRAY */ + 1233, /* GL_NORMAL_ARRAY */ + 189, /* GL_COLOR_ARRAY */ + 737, /* GL_INDEX_ARRAY */ + 2029, /* GL_TEXTURE_COORD_ARRAY */ + 519, /* GL_EDGE_FLAG_ARRAY */ + 2241, /* GL_VERTEX_ARRAY_SIZE */ + 2243, /* GL_VERTEX_ARRAY_TYPE */ + 2242, /* GL_VERTEX_ARRAY_STRIDE */ + 1238, /* GL_NORMAL_ARRAY_TYPE */ + 1237, /* GL_NORMAL_ARRAY_STRIDE */ + 193, /* GL_COLOR_ARRAY_SIZE */ + 195, /* GL_COLOR_ARRAY_TYPE */ + 194, /* GL_COLOR_ARRAY_STRIDE */ + 742, /* GL_INDEX_ARRAY_TYPE */ + 741, /* GL_INDEX_ARRAY_STRIDE */ + 2033, /* GL_TEXTURE_COORD_ARRAY_SIZE */ + 2035, /* GL_TEXTURE_COORD_ARRAY_TYPE */ + 2034, /* GL_TEXTURE_COORD_ARRAY_STRIDE */ + 523, /* GL_EDGE_FLAG_ARRAY_STRIDE */ + 2240, /* GL_VERTEX_ARRAY_POINTER */ + 1236, /* GL_NORMAL_ARRAY_POINTER */ + 192, /* GL_COLOR_ARRAY_POINTER */ + 740, /* GL_INDEX_ARRAY_POINTER */ + 2032, /* GL_TEXTURE_COORD_ARRAY_POINTER */ + 522, /* GL_EDGE_FLAG_ARRAY_POINTER */ + 1211, /* GL_MULTISAMPLE */ + 1731, /* GL_SAMPLE_ALPHA_TO_COVERAGE */ + 1733, /* GL_SAMPLE_ALPHA_TO_ONE */ + 1738, /* GL_SAMPLE_COVERAGE */ + 1735, /* GL_SAMPLE_BUFFERS */ + 1726, /* GL_SAMPLES */ + 1742, /* GL_SAMPLE_COVERAGE_VALUE */ + 1740, /* GL_SAMPLE_COVERAGE_INVERT */ + 237, /* GL_COLOR_MATRIX */ + 239, /* GL_COLOR_MATRIX_STACK_DEPTH */ + 1031, /* GL_MAX_COLOR_MATRIX_STACK_DEPTH */ + 1420, /* GL_POST_COLOR_MATRIX_RED_SCALE */ + 1416, /* GL_POST_COLOR_MATRIX_GREEN_SCALE */ + 1411, /* GL_POST_COLOR_MATRIX_BLUE_SCALE */ + 1407, /* GL_POST_COLOR_MATRIX_ALPHA_SCALE */ + 1418, /* GL_POST_COLOR_MATRIX_RED_BIAS */ + 1414, /* GL_POST_COLOR_MATRIX_GREEN_BIAS */ + 1409, /* GL_POST_COLOR_MATRIX_BLUE_BIAS */ + 1405, /* GL_POST_COLOR_MATRIX_ALPHA_BIAS */ + 2012, /* GL_TEXTURE_COLOR_TABLE_SGI */ + 1513, /* GL_PROXY_TEXTURE_COLOR_TABLE_SGI */ + 2014, /* GL_TEXTURE_COMPARE_FAIL_VALUE_ARB */ + 94, /* GL_BLEND_DST_RGB */ + 108, /* GL_BLEND_SRC_RGB */ + 92, /* GL_BLEND_DST_ALPHA */ + 106, /* GL_BLEND_SRC_ALPHA */ + 243, /* GL_COLOR_TABLE */ + 1430, /* GL_POST_CONVOLUTION_COLOR_TABLE */ + 1413, /* GL_POST_COLOR_MATRIX_COLOR_TABLE */ + 1499, /* GL_PROXY_COLOR_TABLE */ + 1503, /* GL_PROXY_POST_CONVOLUTION_COLOR_TABLE */ + 1502, /* GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE */ + 267, /* GL_COLOR_TABLE_SCALE */ + 247, /* GL_COLOR_TABLE_BIAS */ + 252, /* GL_COLOR_TABLE_FORMAT */ + 269, /* GL_COLOR_TABLE_WIDTH */ + 264, /* GL_COLOR_TABLE_RED_SIZE */ + 255, /* GL_COLOR_TABLE_GREEN_SIZE */ + 249, /* GL_COLOR_TABLE_BLUE_SIZE */ + 244, /* GL_COLOR_TABLE_ALPHA_SIZE */ + 261, /* GL_COLOR_TABLE_LUMINANCE_SIZE */ + 258, /* GL_COLOR_TABLE_INTENSITY_SIZE */ + 79, /* GL_BGR */ + 80, /* GL_BGRA */ + 1046, /* GL_MAX_ELEMENTS_VERTICES */ + 1045, /* GL_MAX_ELEMENTS_INDICES */ + 2078, /* GL_TEXTURE_INDEX_SIZE_EXT */ + 186, /* GL_CLIP_VOLUME_CLIPPING_HINT_EXT */ + 1376, /* GL_POINT_SIZE_MIN */ + 1372, /* GL_POINT_SIZE_MAX */ + 1361, /* GL_POINT_FADE_THRESHOLD_SIZE */ + 1357, /* GL_POINT_DISTANCE_ATTENUATION */ + 159, /* GL_CLAMP_TO_BORDER */ + 162, /* GL_CLAMP_TO_EDGE */ + 2100, /* GL_TEXTURE_MIN_LOD */ + 2098, /* GL_TEXTURE_MAX_LOD */ + 1978, /* GL_TEXTURE_BASE_LEVEL */ + 2097, /* GL_TEXTURE_MAX_LEVEL */ + 728, /* GL_IGNORE_BORDER_HP */ + 321, /* GL_CONSTANT_BORDER_HP */ + 1607, /* GL_REPLICATE_BORDER_HP */ + 333, /* GL_CONVOLUTION_BORDER_COLOR */ + 1268, /* GL_OCCLUSION_TEST_HP */ + 1269, /* GL_OCCLUSION_TEST_RESULT_HP */ + 831, /* GL_LINEAR_CLIPMAP_LINEAR_SGIX */ + 2006, /* GL_TEXTURE_CLIPMAP_CENTER_SGIX */ + 2008, /* GL_TEXTURE_CLIPMAP_FRAME_SGIX */ + 2010, /* GL_TEXTURE_CLIPMAP_OFFSET_SGIX */ + 2011, /* GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX */ + 2009, /* GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX */ + 2007, /* GL_TEXTURE_CLIPMAP_DEPTH_SGIX */ + 1025, /* GL_MAX_CLIPMAP_DEPTH_SGIX */ + 1026, /* GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX */ + 1440, /* GL_POST_TEXTURE_FILTER_BIAS_SGIX */ + 1442, /* GL_POST_TEXTURE_FILTER_SCALE_SGIX */ + 1439, /* GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX */ + 1441, /* GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX */ + 2086, /* GL_TEXTURE_LOD_BIAS_S_SGIX */ + 2087, /* GL_TEXTURE_LOD_BIAS_T_SGIX */ + 2085, /* GL_TEXTURE_LOD_BIAS_R_SGIX */ + 683, /* GL_GENERATE_MIPMAP */ + 684, /* GL_GENERATE_MIPMAP_HINT */ + 596, /* GL_FOG_OFFSET_SGIX */ + 597, /* GL_FOG_OFFSET_VALUE_SGIX */ + 2020, /* GL_TEXTURE_COMPARE_SGIX */ + 2019, /* GL_TEXTURE_COMPARE_OPERATOR_SGIX */ + 2082, /* GL_TEXTURE_LEQUAL_R_SGIX */ + 2074, /* GL_TEXTURE_GEQUAL_R_SGIX */ + 416, /* GL_DEPTH_COMPONENT16 */ + 420, /* GL_DEPTH_COMPONENT24 */ + 424, /* GL_DEPTH_COMPONENT32 */ + 358, /* GL_CULL_VERTEX_EXT */ + 360, /* GL_CULL_VERTEX_OBJECT_POSITION_EXT */ + 359, /* GL_CULL_VERTEX_EYE_POSITION_EXT */ + 2308, /* GL_WRAP_BORDER_SUN */ + 2013, /* GL_TEXTURE_COLOR_WRITEMASK_SGIS */ + 824, /* GL_LIGHT_MODEL_COLOR_CONTROL */ + 1776, /* GL_SINGLE_COLOR */ + 1760, /* GL_SEPARATE_SPECULAR_COLOR */ + 1771, /* GL_SHARED_TEXTURE_PALETTE_EXT */ + 608, /* GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING */ + 609, /* GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE */ + 620, /* GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE */ + 611, /* GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE */ + 607, /* GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE */ + 606, /* GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE */ + 610, /* GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE */ + 621, /* GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE */ + 638, /* GL_FRAMEBUFFER_DEFAULT */ + 665, /* GL_FRAMEBUFFER_UNDEFINED */ + 432, /* GL_DEPTH_STENCIL_ATTACHMENT */ + 901, /* GL_MAJOR_VERSION */ + 1157, /* GL_MINOR_VERSION */ + 1248, /* GL_NUM_EXTENSIONS */ + 327, /* GL_CONTEXT_FLAGS */ + 736, /* GL_INDEX */ + 410, /* GL_DEPTH_BUFFER */ + 1850, /* GL_STENCIL_BUFFER */ + 298, /* GL_COMPRESSED_RED */ + 299, /* GL_COMPRESSED_RG */ + 861, /* GL_LOSE_CONTEXT_ON_RESET_ARB */ + 703, /* GL_GUILTY_CONTEXT_RESET_ARB */ + 751, /* GL_INNOCENT_CONTEXT_RESET_ARB */ + 2167, /* GL_UNKNOWN_CONTEXT_RESET_ARB */ + 1610, /* GL_RESET_NOTIFICATION_STRATEGY_ARB */ + 1462, /* GL_PROGRAM_BINARY_RETRIEVABLE_HINT */ + 1245, /* GL_NO_RESET_NOTIFICATION_ARB */ + 2178, /* GL_UNSIGNED_BYTE_2_3_3_REV */ + 2223, /* GL_UNSIGNED_SHORT_5_6_5 */ + 2224, /* GL_UNSIGNED_SHORT_5_6_5_REV */ + 2220, /* GL_UNSIGNED_SHORT_4_4_4_4_REV */ + 2217, /* GL_UNSIGNED_SHORT_1_5_5_5_REV */ + 2192, /* GL_UNSIGNED_INT_8_8_8_8_REV */ + 2188, /* GL_UNSIGNED_INT_2_10_10_10_REV */ + 2095, /* GL_TEXTURE_MAX_CLAMP_S_SGIX */ + 2096, /* GL_TEXTURE_MAX_CLAMP_T_SGIX */ + 2094, /* GL_TEXTURE_MAX_CLAMP_R_SGIX */ + 1161, /* GL_MIRRORED_REPEAT */ + 1696, /* GL_RGB_S3TC */ + 1638, /* GL_RGB4_S3TC */ + 1692, /* GL_RGBA_S3TC */ + 1677, /* GL_RGBA4_S3TC */ + 1686, /* GL_RGBA_DXT5_S3TC */ + 1674, /* GL_RGBA4_DXT5_S3TC */ + 309, /* GL_COMPRESSED_RGB_S3TC_DXT1_EXT */ + 304, /* GL_COMPRESSED_RGBA_S3TC_DXT1_EXT */ + 305, /* GL_COMPRESSED_RGBA_S3TC_DXT3_EXT */ + 306, /* GL_COMPRESSED_RGBA_S3TC_DXT5_EXT */ + 1223, /* GL_NEAREST_CLIPMAP_NEAREST_SGIX */ + 1222, /* GL_NEAREST_CLIPMAP_LINEAR_SGIX */ + 832, /* GL_LINEAR_CLIPMAP_NEAREST_SGIX */ + 583, /* GL_FOG_COORDINATE_SOURCE */ + 575, /* GL_FOG_COORD */ + 599, /* GL_FRAGMENT_DEPTH */ + 364, /* GL_CURRENT_FOG_COORD */ + 582, /* GL_FOG_COORDINATE_ARRAY_TYPE */ + 581, /* GL_FOG_COORDINATE_ARRAY_STRIDE */ + 580, /* GL_FOG_COORDINATE_ARRAY_POINTER */ + 577, /* GL_FOG_COORDINATE_ARRAY */ + 241, /* GL_COLOR_SUM */ + 385, /* GL_CURRENT_SECONDARY_COLOR */ + 1751, /* GL_SECONDARY_COLOR_ARRAY_SIZE */ + 1753, /* GL_SECONDARY_COLOR_ARRAY_TYPE */ + 1752, /* GL_SECONDARY_COLOR_ARRAY_STRIDE */ + 1750, /* GL_SECONDARY_COLOR_ARRAY_POINTER */ + 1747, /* GL_SECONDARY_COLOR_ARRAY */ + 383, /* GL_CURRENT_RASTER_SECONDARY_COLOR */ + 29, /* GL_ALIASED_POINT_SIZE_RANGE */ + 28, /* GL_ALIASED_LINE_WIDTH_RANGE */ + 1904, /* GL_TEXTURE0 */ + 1906, /* GL_TEXTURE1 */ + 1928, /* GL_TEXTURE2 */ + 1950, /* GL_TEXTURE3 */ + 1956, /* GL_TEXTURE4 */ + 1958, /* GL_TEXTURE5 */ + 1960, /* GL_TEXTURE6 */ + 1962, /* GL_TEXTURE7 */ + 1964, /* GL_TEXTURE8 */ + 1966, /* GL_TEXTURE9 */ + 1907, /* GL_TEXTURE10 */ + 1909, /* GL_TEXTURE11 */ + 1911, /* GL_TEXTURE12 */ + 1913, /* GL_TEXTURE13 */ + 1915, /* GL_TEXTURE14 */ + 1917, /* GL_TEXTURE15 */ + 1919, /* GL_TEXTURE16 */ + 1921, /* GL_TEXTURE17 */ + 1923, /* GL_TEXTURE18 */ + 1925, /* GL_TEXTURE19 */ + 1929, /* GL_TEXTURE20 */ + 1931, /* GL_TEXTURE21 */ + 1933, /* GL_TEXTURE22 */ + 1935, /* GL_TEXTURE23 */ + 1937, /* GL_TEXTURE24 */ + 1939, /* GL_TEXTURE25 */ + 1941, /* GL_TEXTURE26 */ + 1943, /* GL_TEXTURE27 */ + 1945, /* GL_TEXTURE28 */ + 1947, /* GL_TEXTURE29 */ + 1951, /* GL_TEXTURE30 */ + 1953, /* GL_TEXTURE31 */ + 19, /* GL_ACTIVE_TEXTURE */ + 166, /* GL_CLIENT_ACTIVE_TEXTURE */ + 1122, /* GL_MAX_TEXTURE_UNITS */ + 2150, /* GL_TRANSPOSE_MODELVIEW_MATRIX */ + 2153, /* GL_TRANSPOSE_PROJECTION_MATRIX */ + 2155, /* GL_TRANSPOSE_TEXTURE_MATRIX */ + 2147, /* GL_TRANSPOSE_COLOR_MATRIX */ + 1886, /* GL_SUBTRACT */ + 1103, /* GL_MAX_RENDERBUFFER_SIZE */ + 290, /* GL_COMPRESSED_ALPHA */ + 294, /* GL_COMPRESSED_LUMINANCE */ + 295, /* GL_COMPRESSED_LUMINANCE_ALPHA */ + 292, /* GL_COMPRESSED_INTENSITY */ + 300, /* GL_COMPRESSED_RGB */ + 301, /* GL_COMPRESSED_RGBA */ + 2027, /* GL_TEXTURE_COMPRESSION_HINT */ + 2104, /* GL_TEXTURE_RECTANGLE */ + 1992, /* GL_TEXTURE_BINDING_RECTANGLE */ + 1516, /* GL_PROXY_TEXTURE_RECTANGLE */ + 1100, /* GL_MAX_RECTANGLE_TEXTURE_SIZE */ + 431, /* GL_DEPTH_STENCIL */ + 2184, /* GL_UNSIGNED_INT_24_8 */ + 1117, /* GL_MAX_TEXTURE_LOD_BIAS */ + 2093, /* GL_TEXTURE_MAX_ANISOTROPY_EXT */ + 1119, /* GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT */ + 2065, /* GL_TEXTURE_FILTER_CONTROL */ + 2083, /* GL_TEXTURE_LOD_BIAS */ + 274, /* GL_COMBINE4 */ + 1109, /* GL_MAX_SHININESS_NV */ + 1110, /* GL_MAX_SPOT_EXPONENT_NV */ + 734, /* GL_INCR_WRAP */ + 396, /* GL_DECR_WRAP */ + 1181, /* GL_MODELVIEW1_ARB */ + 1239, /* GL_NORMAL_MAP */ + 1567, /* GL_REFLECTION_MAP */ + 2037, /* GL_TEXTURE_CUBE_MAP */ + 1989, /* GL_TEXTURE_BINDING_CUBE_MAP */ + 2049, /* GL_TEXTURE_CUBE_MAP_POSITIVE_X */ + 2039, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_X */ + 2052, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Y */ + 2042, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Y */ + 2055, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Z */ + 2045, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Z */ + 1514, /* GL_PROXY_TEXTURE_CUBE_MAP */ + 1039, /* GL_MAX_CUBE_MAP_TEXTURE_SIZE */ + 1217, /* GL_MULTISAMPLE_FILTER_HINT_NV */ + 1454, /* GL_PRIMITIVE_RESTART_NV */ + 1453, /* GL_PRIMITIVE_RESTART_INDEX_NV */ + 591, /* GL_FOG_DISTANCE_MODE_NV */ + 538, /* GL_EYE_RADIAL_NV */ + 537, /* GL_EYE_PLANE_ABSOLUTE_NV */ + 273, /* GL_COMBINE */ + 280, /* GL_COMBINE_RGB */ + 275, /* GL_COMBINE_ALPHA */ + 1697, /* GL_RGB_SCALE */ + 25, /* GL_ADD_SIGNED */ + 771, /* GL_INTERPOLATE */ + 316, /* GL_CONSTANT */ + 1446, /* GL_PRIMARY_COLOR */ + 1443, /* GL_PREVIOUS */ + 1791, /* GL_SOURCE0_RGB */ + 1797, /* GL_SOURCE1_RGB */ + 1803, /* GL_SOURCE2_RGB */ + 1807, /* GL_SOURCE3_RGB_NV */ + 1788, /* GL_SOURCE0_ALPHA */ + 1794, /* GL_SOURCE1_ALPHA */ + 1800, /* GL_SOURCE2_ALPHA */ + 1806, /* GL_SOURCE3_ALPHA_NV */ + 1282, /* GL_OPERAND0_RGB */ + 1288, /* GL_OPERAND1_RGB */ + 1294, /* GL_OPERAND2_RGB */ + 1298, /* GL_OPERAND3_RGB_NV */ + 1279, /* GL_OPERAND0_ALPHA */ + 1285, /* GL_OPERAND1_ALPHA */ + 1291, /* GL_OPERAND2_ALPHA */ + 1297, /* GL_OPERAND3_ALPHA_NV */ + 137, /* GL_BUFFER_OBJECT_APPLE */ + 2236, /* GL_VERTEX_ARRAY_BINDING */ + 2102, /* GL_TEXTURE_RANGE_LENGTH_APPLE */ + 2103, /* GL_TEXTURE_RANGE_POINTER_APPLE */ + 2313, /* GL_YCBCR_422_APPLE */ + 2225, /* GL_UNSIGNED_SHORT_8_8_APPLE */ + 2227, /* GL_UNSIGNED_SHORT_8_8_REV_APPLE */ + 2114, /* GL_TEXTURE_STORAGE_HINT_APPLE */ + 1877, /* GL_STORAGE_PRIVATE_APPLE */ + 1876, /* GL_STORAGE_CACHED_APPLE */ + 1878, /* GL_STORAGE_SHARED_APPLE */ + 1778, /* GL_SLICE_ACCUM_SUN */ + 1525, /* GL_QUAD_MESH_SUN */ + 2161, /* GL_TRIANGLE_MESH_SUN */ + 2278, /* GL_VERTEX_PROGRAM_ARB */ + 2289, /* GL_VERTEX_STATE_PROGRAM_NV */ + 2263, /* GL_VERTEX_ATTRIB_ARRAY_ENABLED */ + 2271, /* GL_VERTEX_ATTRIB_ARRAY_SIZE */ + 2273, /* GL_VERTEX_ATTRIB_ARRAY_STRIDE */ + 2275, /* GL_VERTEX_ATTRIB_ARRAY_TYPE */ + 387, /* GL_CURRENT_VERTEX_ATTRIB */ + 1470, /* GL_PROGRAM_LENGTH_ARB */ + 1486, /* GL_PROGRAM_STRING_ARB */ + 1204, /* GL_MODELVIEW_PROJECTION_NV */ + 727, /* GL_IDENTITY_NV */ + 804, /* GL_INVERSE_NV */ + 2152, /* GL_TRANSPOSE_NV */ + 805, /* GL_INVERSE_TRANSPOSE_NV */ + 1084, /* GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB */ + 1083, /* GL_MAX_PROGRAM_MATRICES_ARB */ + 965, /* GL_MATRIX0_NV */ + 977, /* GL_MATRIX1_NV */ + 989, /* GL_MATRIX2_NV */ + 993, /* GL_MATRIX3_NV */ + 995, /* GL_MATRIX4_NV */ + 997, /* GL_MATRIX5_NV */ + 999, /* GL_MATRIX6_NV */ + 1001, /* GL_MATRIX7_NV */ + 370, /* GL_CURRENT_MATRIX_STACK_DEPTH_ARB */ + 367, /* GL_CURRENT_MATRIX_ARB */ + 1483, /* GL_PROGRAM_POINT_SIZE */ + 2284, /* GL_VERTEX_PROGRAM_TWO_SIDE */ + 1482, /* GL_PROGRAM_PARAMETER_NV */ + 2269, /* GL_VERTEX_ATTRIB_ARRAY_POINTER */ + 1488, /* GL_PROGRAM_TARGET_NV */ + 1485, /* GL_PROGRAM_RESIDENT_NV */ + 2124, /* GL_TRACK_MATRIX_NV */ + 2125, /* GL_TRACK_MATRIX_TRANSFORM_NV */ + 2279, /* GL_VERTEX_PROGRAM_BINDING_NV */ + 1464, /* GL_PROGRAM_ERROR_POSITION_ARB */ + 412, /* GL_DEPTH_CLAMP */ + 2244, /* GL_VERTEX_ATTRIB_ARRAY0_NV */ + 2251, /* GL_VERTEX_ATTRIB_ARRAY1_NV */ + 2252, /* GL_VERTEX_ATTRIB_ARRAY2_NV */ + 2253, /* GL_VERTEX_ATTRIB_ARRAY3_NV */ + 2254, /* GL_VERTEX_ATTRIB_ARRAY4_NV */ + 2255, /* GL_VERTEX_ATTRIB_ARRAY5_NV */ + 2256, /* GL_VERTEX_ATTRIB_ARRAY6_NV */ + 2257, /* GL_VERTEX_ATTRIB_ARRAY7_NV */ + 2258, /* GL_VERTEX_ATTRIB_ARRAY8_NV */ + 2259, /* GL_VERTEX_ATTRIB_ARRAY9_NV */ + 2245, /* GL_VERTEX_ATTRIB_ARRAY10_NV */ + 2246, /* GL_VERTEX_ATTRIB_ARRAY11_NV */ + 2247, /* GL_VERTEX_ATTRIB_ARRAY12_NV */ + 2248, /* GL_VERTEX_ATTRIB_ARRAY13_NV */ + 2249, /* GL_VERTEX_ATTRIB_ARRAY14_NV */ + 2250, /* GL_VERTEX_ATTRIB_ARRAY15_NV */ + 913, /* GL_MAP1_VERTEX_ATTRIB0_4_NV */ + 920, /* GL_MAP1_VERTEX_ATTRIB1_4_NV */ + 921, /* GL_MAP1_VERTEX_ATTRIB2_4_NV */ + 922, /* GL_MAP1_VERTEX_ATTRIB3_4_NV */ + 923, /* GL_MAP1_VERTEX_ATTRIB4_4_NV */ + 924, /* GL_MAP1_VERTEX_ATTRIB5_4_NV */ + 925, /* GL_MAP1_VERTEX_ATTRIB6_4_NV */ + 926, /* GL_MAP1_VERTEX_ATTRIB7_4_NV */ + 927, /* GL_MAP1_VERTEX_ATTRIB8_4_NV */ + 928, /* GL_MAP1_VERTEX_ATTRIB9_4_NV */ + 914, /* GL_MAP1_VERTEX_ATTRIB10_4_NV */ + 915, /* GL_MAP1_VERTEX_ATTRIB11_4_NV */ + 916, /* GL_MAP1_VERTEX_ATTRIB12_4_NV */ + 917, /* GL_MAP1_VERTEX_ATTRIB13_4_NV */ + 918, /* GL_MAP1_VERTEX_ATTRIB14_4_NV */ + 919, /* GL_MAP1_VERTEX_ATTRIB15_4_NV */ + 940, /* GL_MAP2_VERTEX_ATTRIB0_4_NV */ + 947, /* GL_MAP2_VERTEX_ATTRIB1_4_NV */ + 948, /* GL_MAP2_VERTEX_ATTRIB2_4_NV */ + 949, /* GL_MAP2_VERTEX_ATTRIB3_4_NV */ + 950, /* GL_MAP2_VERTEX_ATTRIB4_4_NV */ + 951, /* GL_MAP2_VERTEX_ATTRIB5_4_NV */ + 952, /* GL_MAP2_VERTEX_ATTRIB6_4_NV */ + 1463, /* GL_PROGRAM_BINDING_ARB */ + 954, /* GL_MAP2_VERTEX_ATTRIB8_4_NV */ + 955, /* GL_MAP2_VERTEX_ATTRIB9_4_NV */ + 941, /* GL_MAP2_VERTEX_ATTRIB10_4_NV */ + 942, /* GL_MAP2_VERTEX_ATTRIB11_4_NV */ + 943, /* GL_MAP2_VERTEX_ATTRIB12_4_NV */ + 944, /* GL_MAP2_VERTEX_ATTRIB13_4_NV */ + 945, /* GL_MAP2_VERTEX_ATTRIB14_4_NV */ + 946, /* GL_MAP2_VERTEX_ATTRIB15_4_NV */ + 2025, /* GL_TEXTURE_COMPRESSED_IMAGE_SIZE */ + 2022, /* GL_TEXTURE_COMPRESSED */ + 1246, /* GL_NUM_COMPRESSED_TEXTURE_FORMATS */ + 314, /* GL_COMPRESSED_TEXTURE_FORMATS */ + 1144, /* GL_MAX_VERTEX_UNITS_ARB */ + 23, /* GL_ACTIVE_VERTEX_UNITS_ARB */ + 2307, /* GL_WEIGHT_SUM_UNITY_ARB */ + 2277, /* GL_VERTEX_BLEND_ARB */ + 389, /* GL_CURRENT_WEIGHT_ARB */ + 2305, /* GL_WEIGHT_ARRAY_TYPE_ARB */ + 2303, /* GL_WEIGHT_ARRAY_STRIDE_ARB */ + 2301, /* GL_WEIGHT_ARRAY_SIZE_ARB */ + 2299, /* GL_WEIGHT_ARRAY_POINTER_ARB */ + 2294, /* GL_WEIGHT_ARRAY_ARB */ + 446, /* GL_DOT3_RGB */ + 447, /* GL_DOT3_RGBA */ + 308, /* GL_COMPRESSED_RGB_FXT1_3DFX */ + 303, /* GL_COMPRESSED_RGBA_FXT1_3DFX */ + 1212, /* GL_MULTISAMPLE_3DFX */ + 1736, /* GL_SAMPLE_BUFFERS_3DFX */ + 1727, /* GL_SAMPLES_3DFX */ + 1192, /* GL_MODELVIEW2_ARB */ + 1195, /* GL_MODELVIEW3_ARB */ + 1196, /* GL_MODELVIEW4_ARB */ + 1197, /* GL_MODELVIEW5_ARB */ + 1198, /* GL_MODELVIEW6_ARB */ + 1199, /* GL_MODELVIEW7_ARB */ + 1200, /* GL_MODELVIEW8_ARB */ + 1201, /* GL_MODELVIEW9_ARB */ + 1171, /* GL_MODELVIEW10_ARB */ + 1172, /* GL_MODELVIEW11_ARB */ + 1173, /* GL_MODELVIEW12_ARB */ + 1174, /* GL_MODELVIEW13_ARB */ + 1175, /* GL_MODELVIEW14_ARB */ + 1176, /* GL_MODELVIEW15_ARB */ + 1177, /* GL_MODELVIEW16_ARB */ + 1178, /* GL_MODELVIEW17_ARB */ + 1179, /* GL_MODELVIEW18_ARB */ + 1180, /* GL_MODELVIEW19_ARB */ + 1182, /* GL_MODELVIEW20_ARB */ + 1183, /* GL_MODELVIEW21_ARB */ + 1184, /* GL_MODELVIEW22_ARB */ + 1185, /* GL_MODELVIEW23_ARB */ + 1186, /* GL_MODELVIEW24_ARB */ + 1187, /* GL_MODELVIEW25_ARB */ + 1188, /* GL_MODELVIEW26_ARB */ + 1189, /* GL_MODELVIEW27_ARB */ + 1190, /* GL_MODELVIEW28_ARB */ + 1191, /* GL_MODELVIEW29_ARB */ + 1193, /* GL_MODELVIEW30_ARB */ + 1194, /* GL_MODELVIEW31_ARB */ + 451, /* GL_DOT3_RGB_EXT */ + 1460, /* GL_PROGRAM_BINARY_LENGTH */ + 1165, /* GL_MIRROR_CLAMP_EXT */ + 1168, /* GL_MIRROR_CLAMP_TO_EDGE_EXT */ + 1207, /* GL_MODULATE_ADD_ATI */ + 1208, /* GL_MODULATE_SIGNED_ADD_ATI */ + 1209, /* GL_MODULATE_SUBTRACT_ATI */ + 2314, /* GL_YCBCR_MESA */ + 1306, /* GL_PACK_INVERT_MESA */ + 392, /* GL_DEBUG_OBJECT_MESA */ + 393, /* GL_DEBUG_PRINT_MESA */ + 391, /* GL_DEBUG_ASSERT_MESA */ + 139, /* GL_BUFFER_SIZE */ + 141, /* GL_BUFFER_USAGE */ + 145, /* GL_BUMP_ROT_MATRIX_ATI */ + 146, /* GL_BUMP_ROT_MATRIX_SIZE_ATI */ + 144, /* GL_BUMP_NUM_TEX_UNITS_ATI */ + 148, /* GL_BUMP_TEX_UNITS_ATI */ + 511, /* GL_DUDV_ATI */ + 510, /* GL_DU8DV8_ATI */ + 143, /* GL_BUMP_ENVMAP_ATI */ + 147, /* GL_BUMP_TARGET_ATI */ + 1249, /* GL_NUM_PROGRAM_BINARY_FORMATS */ + 1458, /* GL_PROGRAM_BINARY_FORMATS */ + 1840, /* GL_STENCIL_BACK_FUNC */ + 1838, /* GL_STENCIL_BACK_FAIL */ + 1842, /* GL_STENCIL_BACK_PASS_DEPTH_FAIL */ + 1844, /* GL_STENCIL_BACK_PASS_DEPTH_PASS */ + 600, /* GL_FRAGMENT_PROGRAM_ARB */ + 1456, /* GL_PROGRAM_ALU_INSTRUCTIONS_ARB */ + 1491, /* GL_PROGRAM_TEX_INSTRUCTIONS_ARB */ + 1490, /* GL_PROGRAM_TEX_INDIRECTIONS_ARB */ + 1473, /* GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB */ + 1479, /* GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB */ + 1478, /* GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB */ + 1073, /* GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB */ + 1098, /* GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB */ + 1097, /* GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB */ + 1086, /* GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB */ + 1092, /* GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB */ + 1091, /* GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB */ + 1668, /* GL_RGBA32F */ + 1631, /* GL_RGB32F */ + 1659, /* GL_RGBA16F */ + 1623, /* GL_RGB16F */ + 1687, /* GL_RGBA_FLOAT_MODE_ARB */ + 1042, /* GL_MAX_DRAW_BUFFERS */ + 455, /* GL_DRAW_BUFFER0 */ + 458, /* GL_DRAW_BUFFER1 */ + 479, /* GL_DRAW_BUFFER2 */ + 482, /* GL_DRAW_BUFFER3 */ + 485, /* GL_DRAW_BUFFER4 */ + 488, /* GL_DRAW_BUFFER5 */ + 491, /* GL_DRAW_BUFFER6 */ + 494, /* GL_DRAW_BUFFER7 */ + 497, /* GL_DRAW_BUFFER8 */ + 500, /* GL_DRAW_BUFFER9 */ + 459, /* GL_DRAW_BUFFER10 */ + 462, /* GL_DRAW_BUFFER11 */ + 465, /* GL_DRAW_BUFFER12 */ + 468, /* GL_DRAW_BUFFER13 */ + 471, /* GL_DRAW_BUFFER14 */ + 474, /* GL_DRAW_BUFFER15 */ + 97, /* GL_BLEND_EQUATION_ALPHA */ + 1016, /* GL_MATRIX_PALETTE_ARB */ + 1066, /* GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB */ + 1069, /* GL_MAX_PALETTE_MATRICES_ARB */ + 373, /* GL_CURRENT_PALETTE_MATRIX_ARB */ + 1004, /* GL_MATRIX_INDEX_ARRAY_ARB */ + 368, /* GL_CURRENT_MATRIX_INDEX_ARB */ + 1009, /* GL_MATRIX_INDEX_ARRAY_SIZE_ARB */ + 1013, /* GL_MATRIX_INDEX_ARRAY_TYPE_ARB */ + 1011, /* GL_MATRIX_INDEX_ARRAY_STRIDE_ARB */ + 1007, /* GL_MATRIX_INDEX_ARRAY_POINTER_ARB */ + 2060, /* GL_TEXTURE_DEPTH_SIZE */ + 439, /* GL_DEPTH_TEXTURE_MODE */ + 2017, /* GL_TEXTURE_COMPARE_MODE */ + 2015, /* GL_TEXTURE_COMPARE_FUNC */ + 284, /* GL_COMPARE_REF_TO_TEXTURE */ + 1383, /* GL_POINT_SPRITE */ + 347, /* GL_COORD_REPLACE */ + 1388, /* GL_POINT_SPRITE_R_MODE_NV */ + 1531, /* GL_QUERY_COUNTER_BITS */ + 376, /* GL_CURRENT_QUERY */ + 1535, /* GL_QUERY_RESULT */ + 1537, /* GL_QUERY_RESULT_AVAILABLE */ + 1136, /* GL_MAX_VERTEX_ATTRIBS */ + 2267, /* GL_VERTEX_ATTRIB_ARRAY_NORMALIZED */ + 437, /* GL_DEPTH_STENCIL_TO_RGBA_NV */ + 436, /* GL_DEPTH_STENCIL_TO_BGRA_NV */ + 1113, /* GL_MAX_TEXTURE_COORDS */ + 1115, /* GL_MAX_TEXTURE_IMAGE_UNITS */ + 1466, /* GL_PROGRAM_ERROR_STRING_ARB */ + 1468, /* GL_PROGRAM_FORMAT_ASCII_ARB */ + 1467, /* GL_PROGRAM_FORMAT_ARB */ + 2116, /* GL_TEXTURE_UNSIGNED_REMAP_MODE_NV */ + 409, /* GL_DEPTH_BOUNDS_TEST_EXT */ + 408, /* GL_DEPTH_BOUNDS_EXT */ + 61, /* GL_ARRAY_BUFFER */ + 524, /* GL_ELEMENT_ARRAY_BUFFER */ + 62, /* GL_ARRAY_BUFFER_BINDING */ + 525, /* GL_ELEMENT_ARRAY_BUFFER_BINDING */ + 2238, /* GL_VERTEX_ARRAY_BUFFER_BINDING */ + 1234, /* GL_NORMAL_ARRAY_BUFFER_BINDING */ + 190, /* GL_COLOR_ARRAY_BUFFER_BINDING */ + 738, /* GL_INDEX_ARRAY_BUFFER_BINDING */ + 2030, /* GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING */ + 520, /* GL_EDGE_FLAG_ARRAY_BUFFER_BINDING */ + 1748, /* GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING */ + 578, /* GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING */ + 2295, /* GL_WEIGHT_ARRAY_BUFFER_BINDING */ + 2260, /* GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING */ + 1469, /* GL_PROGRAM_INSTRUCTIONS_ARB */ + 1079, /* GL_MAX_PROGRAM_INSTRUCTIONS_ARB */ + 1475, /* GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB */ + 1088, /* GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB */ + 1489, /* GL_PROGRAM_TEMPORARIES_ARB */ + 1094, /* GL_MAX_PROGRAM_TEMPORARIES_ARB */ + 1477, /* GL_PROGRAM_NATIVE_TEMPORARIES_ARB */ + 1090, /* GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB */ + 1481, /* GL_PROGRAM_PARAMETERS_ARB */ + 1093, /* GL_MAX_PROGRAM_PARAMETERS_ARB */ + 1476, /* GL_PROGRAM_NATIVE_PARAMETERS_ARB */ + 1089, /* GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB */ + 1457, /* GL_PROGRAM_ATTRIBS_ARB */ + 1074, /* GL_MAX_PROGRAM_ATTRIBS_ARB */ + 1474, /* GL_PROGRAM_NATIVE_ATTRIBS_ARB */ + 1087, /* GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB */ + 1455, /* GL_PROGRAM_ADDRESS_REGISTERS_ARB */ + 1072, /* GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB */ + 1472, /* GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB */ + 1085, /* GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB */ + 1080, /* GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB */ + 1076, /* GL_MAX_PROGRAM_ENV_PARAMETERS_ARB */ + 1492, /* GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB */ + 2149, /* GL_TRANSPOSE_CURRENT_MATRIX_ARB */ + 1554, /* GL_READ_ONLY */ + 2309, /* GL_WRITE_ONLY */ + 1556, /* GL_READ_WRITE */ + 124, /* GL_BUFFER_ACCESS */ + 129, /* GL_BUFFER_MAPPED */ + 134, /* GL_BUFFER_MAP_POINTER */ + 2123, /* GL_TIME_ELAPSED_EXT */ + 964, /* GL_MATRIX0_ARB */ + 976, /* GL_MATRIX1_ARB */ + 988, /* GL_MATRIX2_ARB */ + 992, /* GL_MATRIX3_ARB */ + 994, /* GL_MATRIX4_ARB */ + 996, /* GL_MATRIX5_ARB */ + 998, /* GL_MATRIX6_ARB */ + 1000, /* GL_MATRIX7_ARB */ + 1002, /* GL_MATRIX8_ARB */ + 1003, /* GL_MATRIX9_ARB */ + 966, /* GL_MATRIX10_ARB */ + 967, /* GL_MATRIX11_ARB */ + 968, /* GL_MATRIX12_ARB */ + 969, /* GL_MATRIX13_ARB */ + 970, /* GL_MATRIX14_ARB */ + 971, /* GL_MATRIX15_ARB */ + 972, /* GL_MATRIX16_ARB */ + 973, /* GL_MATRIX17_ARB */ + 974, /* GL_MATRIX18_ARB */ + 975, /* GL_MATRIX19_ARB */ + 978, /* GL_MATRIX20_ARB */ + 979, /* GL_MATRIX21_ARB */ + 980, /* GL_MATRIX22_ARB */ + 981, /* GL_MATRIX23_ARB */ + 982, /* GL_MATRIX24_ARB */ + 983, /* GL_MATRIX25_ARB */ + 984, /* GL_MATRIX26_ARB */ + 985, /* GL_MATRIX27_ARB */ + 986, /* GL_MATRIX28_ARB */ + 987, /* GL_MATRIX29_ARB */ + 990, /* GL_MATRIX30_ARB */ + 991, /* GL_MATRIX31_ARB */ + 1881, /* GL_STREAM_DRAW */ + 1883, /* GL_STREAM_READ */ + 1879, /* GL_STREAM_COPY */ + 1830, /* GL_STATIC_DRAW */ + 1832, /* GL_STATIC_READ */ + 1828, /* GL_STATIC_COPY */ + 514, /* GL_DYNAMIC_DRAW */ + 516, /* GL_DYNAMIC_READ */ + 512, /* GL_DYNAMIC_COPY */ + 1346, /* GL_PIXEL_PACK_BUFFER */ + 1350, /* GL_PIXEL_UNPACK_BUFFER */ + 1347, /* GL_PIXEL_PACK_BUFFER_BINDING */ + 1351, /* GL_PIXEL_UNPACK_BUFFER_BINDING */ + 400, /* GL_DEPTH24_STENCIL8 */ + 2112, /* GL_TEXTURE_STENCIL_SIZE */ + 2058, /* GL_TEXTURE_CUBE_MAP_SEAMLESS */ + 1075, /* GL_MAX_PROGRAM_CALL_DEPTH_NV */ + 1078, /* GL_MAX_PROGRAM_IF_DEPTH_NV */ + 1082, /* GL_MAX_PROGRAM_LOOP_DEPTH_NV */ + 1081, /* GL_MAX_PROGRAM_LOOP_COUNT_NV */ + 2265, /* GL_VERTEX_ATTRIB_ARRAY_INTEGER */ + 2262, /* GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB */ + 1021, /* GL_MAX_ARRAY_TEXTURE_LAYERS */ + 1159, /* GL_MIN_PROGRAM_TEXEL_OFFSET */ + 1095, /* GL_MAX_PROGRAM_TEXEL_OFFSET */ + 1872, /* GL_STENCIL_TEST_TWO_SIDE_EXT */ + 18, /* GL_ACTIVE_STENCIL_FACE_EXT */ + 1166, /* GL_MIRROR_CLAMP_TO_BORDER_EXT */ + 1729, /* GL_SAMPLES_PASSED */ + 693, /* GL_GEOMETRY_VERTICES_OUT */ + 687, /* GL_GEOMETRY_INPUT_TYPE */ + 689, /* GL_GEOMETRY_OUTPUT_TYPE */ + 1720, /* GL_SAMPLER_BINDING */ + 164, /* GL_CLAMP_VERTEX_COLOR_ARB */ + 156, /* GL_CLAMP_FRAGMENT_COLOR_ARB */ + 157, /* GL_CLAMP_READ_COLOR */ + 550, /* GL_FIXED_ONLY */ + 1370, /* GL_POINT_SIZE_ARRAY_TYPE_OES */ + 1369, /* GL_POINT_SIZE_ARRAY_STRIDE_OES */ + 1368, /* GL_POINT_SIZE_ARRAY_POINTER_OES */ + 1203, /* GL_MODELVIEW_MATRIX_FLOAT_AS_INT_BITS_OES */ + 1495, /* GL_PROJECTION_MATRIX_FLOAT_AS_INT_BITS_OES */ + 2092, /* GL_TEXTURE_MATRIX_FLOAT_AS_INT_BITS_OES */ + 138, /* GL_BUFFER_SERIALIZED_MODIFY_APPLE */ + 128, /* GL_BUFFER_FLUSHING_UNMAP_APPLE */ + 1571, /* GL_RELEASED_APPLE */ + 2292, /* GL_VOLATILE_APPLE */ + 1611, /* GL_RETAINED_APPLE */ + 2166, /* GL_UNDEFINED_APPLE */ + 1519, /* GL_PURGEABLE_APPLE */ + 601, /* GL_FRAGMENT_SHADER */ + 2287, /* GL_VERTEX_SHADER */ + 1480, /* GL_PROGRAM_OBJECT_ARB */ + 1765, /* GL_SHADER_OBJECT_ARB */ + 1050, /* GL_MAX_FRAGMENT_UNIFORM_COMPONENTS */ + 1141, /* GL_MAX_VERTEX_UNIFORM_COMPONENTS */ + 1132, /* GL_MAX_VARYING_COMPONENTS */ + 1139, /* GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS */ + 1033, /* GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS */ + 1266, /* GL_OBJECT_TYPE_ARB */ + 1767, /* GL_SHADER_TYPE */ + 566, /* GL_FLOAT_VEC2 */ + 568, /* GL_FLOAT_VEC3 */ + 570, /* GL_FLOAT_VEC4 */ + 792, /* GL_INT_VEC2 */ + 794, /* GL_INT_VEC3 */ + 796, /* GL_INT_VEC4 */ + 116, /* GL_BOOL */ + 118, /* GL_BOOL_VEC2 */ + 120, /* GL_BOOL_VEC3 */ + 122, /* GL_BOOL_VEC4 */ + 554, /* GL_FLOAT_MAT2 */ + 558, /* GL_FLOAT_MAT3 */ + 562, /* GL_FLOAT_MAT4 */ + 1704, /* GL_SAMPLER_1D */ + 1710, /* GL_SAMPLER_2D */ + 1718, /* GL_SAMPLER_3D */ + 1723, /* GL_SAMPLER_CUBE */ + 1709, /* GL_SAMPLER_1D_SHADOW */ + 1717, /* GL_SAMPLER_2D_SHADOW */ + 1715, /* GL_SAMPLER_2D_RECT */ + 1716, /* GL_SAMPLER_2D_RECT_SHADOW */ + 556, /* GL_FLOAT_MAT2x3 */ + 557, /* GL_FLOAT_MAT2x4 */ + 560, /* GL_FLOAT_MAT3x2 */ + 561, /* GL_FLOAT_MAT3x4 */ + 564, /* GL_FLOAT_MAT4x2 */ + 565, /* GL_FLOAT_MAT4x3 */ + 398, /* GL_DELETE_STATUS */ + 289, /* GL_COMPILE_STATUS */ + 853, /* GL_LINK_STATUS */ + 2232, /* GL_VALIDATE_STATUS */ + 750, /* GL_INFO_LOG_LENGTH */ + 64, /* GL_ATTACHED_SHADERS */ + 21, /* GL_ACTIVE_UNIFORMS */ + 22, /* GL_ACTIVE_UNIFORM_MAX_LENGTH */ + 1766, /* GL_SHADER_SOURCE_LENGTH */ + 15, /* GL_ACTIVE_ATTRIBUTES */ + 16, /* GL_ACTIVE_ATTRIBUTE_MAX_LENGTH */ + 603, /* GL_FRAGMENT_SHADER_DERIVATIVE_HINT */ + 1769, /* GL_SHADING_LANGUAGE_VERSION */ + 375, /* GL_CURRENT_PROGRAM */ + 1315, /* GL_PALETTE4_RGB8_OES */ + 1317, /* GL_PALETTE4_RGBA8_OES */ + 1313, /* GL_PALETTE4_R5_G6_B5_OES */ + 1316, /* GL_PALETTE4_RGBA4_OES */ + 1314, /* GL_PALETTE4_RGB5_A1_OES */ + 1320, /* GL_PALETTE8_RGB8_OES */ + 1322, /* GL_PALETTE8_RGBA8_OES */ + 1318, /* GL_PALETTE8_R5_G6_B5_OES */ + 1321, /* GL_PALETTE8_RGBA4_OES */ + 1319, /* GL_PALETTE8_RGB5_A1_OES */ + 731, /* GL_IMPLEMENTATION_COLOR_READ_TYPE */ + 729, /* GL_IMPLEMENTATION_COLOR_READ_FORMAT */ + 1367, /* GL_POINT_SIZE_ARRAY_OES */ + 2036, /* GL_TEXTURE_CROP_RECT_OES */ + 1005, /* GL_MATRIX_INDEX_ARRAY_BUFFER_BINDING_OES */ + 1366, /* GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES */ + 2215, /* GL_UNSIGNED_NORMALIZED */ + 1969, /* GL_TEXTURE_1D_ARRAY */ + 1505, /* GL_PROXY_TEXTURE_1D_ARRAY */ + 1972, /* GL_TEXTURE_2D_ARRAY */ + 1509, /* GL_PROXY_TEXTURE_2D_ARRAY */ + 1980, /* GL_TEXTURE_BINDING_1D_ARRAY */ + 1983, /* GL_TEXTURE_BINDING_2D_ARRAY */ + 1057, /* GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS */ + 2000, /* GL_TEXTURE_BUFFER */ + 1111, /* GL_MAX_TEXTURE_BUFFER_SIZE */ + 1987, /* GL_TEXTURE_BINDING_BUFFER */ + 2002, /* GL_TEXTURE_BUFFER_DATA_STORE_BINDING */ + 2004, /* GL_TEXTURE_BUFFER_FORMAT */ + 1542, /* GL_R11F_G11F_B10F */ + 2181, /* GL_UNSIGNED_INT_10F_11F_11F_REV */ + 1654, /* GL_RGB9_E5 */ + 2190, /* GL_UNSIGNED_INT_5_9_9_9_REV */ + 2110, /* GL_TEXTURE_SHARED_SIZE */ + 1822, /* GL_SRGB */ + 1823, /* GL_SRGB8 */ + 1825, /* GL_SRGB_ALPHA */ + 1824, /* GL_SRGB8_ALPHA8 */ + 1782, /* GL_SLUMINANCE_ALPHA */ + 1781, /* GL_SLUMINANCE8_ALPHA8 */ + 1779, /* GL_SLUMINANCE */ + 1780, /* GL_SLUMINANCE8 */ + 312, /* GL_COMPRESSED_SRGB */ + 313, /* GL_COMPRESSED_SRGB_ALPHA */ + 310, /* GL_COMPRESSED_SLUMINANCE */ + 311, /* GL_COMPRESSED_SLUMINANCE_ALPHA */ + 2145, /* GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH */ + 2134, /* GL_TRANSFORM_FEEDBACK_BUFFER_MODE */ + 1130, /* GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS */ + 2143, /* GL_TRANSFORM_FEEDBACK_VARYINGS */ + 2139, /* GL_TRANSFORM_FEEDBACK_BUFFER_START */ + 2137, /* GL_TRANSFORM_FEEDBACK_BUFFER_SIZE */ + 1449, /* GL_PRIMITIVES_GENERATED */ + 2141, /* GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN */ + 1546, /* GL_RASTERIZER_DISCARD */ + 1126, /* GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS */ + 1128, /* GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS */ + 769, /* GL_INTERLEAVED_ATTRIBS */ + 1758, /* GL_SEPARATE_ATTRIBS */ + 2129, /* GL_TRANSFORM_FEEDBACK_BUFFER */ + 2131, /* GL_TRANSFORM_FEEDBACK_BUFFER_BINDING */ + 1385, /* GL_POINT_SPRITE_COORD_ORIGIN */ + 862, /* GL_LOWER_LEFT */ + 2229, /* GL_UPPER_LEFT */ + 1846, /* GL_STENCIL_BACK_REF */ + 1847, /* GL_STENCIL_BACK_VALUE_MASK */ + 1848, /* GL_STENCIL_BACK_WRITEMASK */ + 504, /* GL_DRAW_FRAMEBUFFER_BINDING */ + 1576, /* GL_RENDERBUFFER_BINDING */ + 1550, /* GL_READ_FRAMEBUFFER */ + 503, /* GL_DRAW_FRAMEBUFFER */ + 1551, /* GL_READ_FRAMEBUFFER_BINDING */ + 1595, /* GL_RENDERBUFFER_SAMPLES */ + 617, /* GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE */ + 614, /* GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME */ + 629, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL */ + 624, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE */ + 627, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER */ + 635, /* GL_FRAMEBUFFER_COMPLETE */ + 640, /* GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT */ + 655, /* GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT */ + 649, /* GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT */ + 644, /* GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT */ + 650, /* GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT */ + 646, /* GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER */ + 660, /* GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER */ + 666, /* GL_FRAMEBUFFER_UNSUPPORTED */ + 664, /* GL_FRAMEBUFFER_STATUS_ERROR_EXT */ + 1029, /* GL_MAX_COLOR_ATTACHMENTS */ + 196, /* GL_COLOR_ATTACHMENT0 */ + 199, /* GL_COLOR_ATTACHMENT1 */ + 213, /* GL_COLOR_ATTACHMENT2 */ + 215, /* GL_COLOR_ATTACHMENT3 */ + 217, /* GL_COLOR_ATTACHMENT4 */ + 219, /* GL_COLOR_ATTACHMENT5 */ + 221, /* GL_COLOR_ATTACHMENT6 */ + 223, /* GL_COLOR_ATTACHMENT7 */ + 225, /* GL_COLOR_ATTACHMENT8 */ + 227, /* GL_COLOR_ATTACHMENT9 */ + 200, /* GL_COLOR_ATTACHMENT10 */ + 202, /* GL_COLOR_ATTACHMENT11 */ + 204, /* GL_COLOR_ATTACHMENT12 */ + 206, /* GL_COLOR_ATTACHMENT13 */ + 208, /* GL_COLOR_ATTACHMENT14 */ + 210, /* GL_COLOR_ATTACHMENT15 */ + 403, /* GL_DEPTH_ATTACHMENT */ + 1835, /* GL_STENCIL_ATTACHMENT */ + 605, /* GL_FRAMEBUFFER */ + 1573, /* GL_RENDERBUFFER */ + 1599, /* GL_RENDERBUFFER_WIDTH */ + 1586, /* GL_RENDERBUFFER_HEIGHT */ + 1589, /* GL_RENDERBUFFER_INTERNAL_FORMAT */ + 1867, /* GL_STENCIL_INDEX_EXT */ + 1856, /* GL_STENCIL_INDEX1 */ + 1861, /* GL_STENCIL_INDEX4 */ + 1864, /* GL_STENCIL_INDEX8 */ + 1857, /* GL_STENCIL_INDEX16 */ + 1593, /* GL_RENDERBUFFER_RED_SIZE */ + 1584, /* GL_RENDERBUFFER_GREEN_SIZE */ + 1579, /* GL_RENDERBUFFER_BLUE_SIZE */ + 1574, /* GL_RENDERBUFFER_ALPHA_SIZE */ + 1581, /* GL_RENDERBUFFER_DEPTH_SIZE */ + 1597, /* GL_RENDERBUFFER_STENCIL_SIZE */ + 658, /* GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE */ + 1106, /* GL_MAX_SAMPLES */ + 2072, /* GL_TEXTURE_GEN_STR_OES */ + 705, /* GL_HALF_FLOAT_OES */ + 1640, /* GL_RGB565 */ + 1671, /* GL_RGBA32UI */ + 1634, /* GL_RGB32UI */ + 40, /* GL_ALPHA32UI_EXT */ + 761, /* GL_INTENSITY32UI_EXT */ + 879, /* GL_LUMINANCE32UI_EXT */ + 896, /* GL_LUMINANCE_ALPHA32UI_EXT */ + 1662, /* GL_RGBA16UI */ + 1626, /* GL_RGB16UI */ + 37, /* GL_ALPHA16UI_EXT */ + 758, /* GL_INTENSITY16UI_EXT */ + 874, /* GL_LUMINANCE16UI_EXT */ + 894, /* GL_LUMINANCE_ALPHA16UI_EXT */ + 1681, /* GL_RGBA8UI */ + 1649, /* GL_RGB8UI */ + 45, /* GL_ALPHA8UI_EXT */ + 766, /* GL_INTENSITY8UI_EXT */ + 888, /* GL_LUMINANCE8UI_EXT */ + 898, /* GL_LUMINANCE_ALPHA8UI_EXT */ + 1669, /* GL_RGBA32I */ + 1632, /* GL_RGB32I */ + 39, /* GL_ALPHA32I_EXT */ + 760, /* GL_INTENSITY32I_EXT */ + 878, /* GL_LUMINANCE32I_EXT */ + 895, /* GL_LUMINANCE_ALPHA32I_EXT */ + 1660, /* GL_RGBA16I */ + 1624, /* GL_RGB16I */ + 36, /* GL_ALPHA16I_EXT */ + 757, /* GL_INTENSITY16I_EXT */ + 873, /* GL_LUMINANCE16I_EXT */ + 893, /* GL_LUMINANCE_ALPHA16I_EXT */ + 1679, /* GL_RGBA8I */ + 1647, /* GL_RGB8I */ + 44, /* GL_ALPHA8I_EXT */ + 765, /* GL_INTENSITY8I_EXT */ + 887, /* GL_LUMINANCE8I_EXT */ + 897, /* GL_LUMINANCE_ALPHA8I_EXT */ + 1563, /* GL_RED_INTEGER */ + 700, /* GL_GREEN_INTEGER */ + 113, /* GL_BLUE_INTEGER */ + 49, /* GL_ALPHA_INTEGER_EXT */ + 1694, /* GL_RGB_INTEGER */ + 1688, /* GL_RGBA_INTEGER */ + 84, /* GL_BGR_INTEGER */ + 82, /* GL_BGRA_INTEGER */ + 900, /* GL_LUMINANCE_INTEGER_EXT */ + 899, /* GL_LUMINANCE_ALPHA_INTEGER_EXT */ + 1690, /* GL_RGBA_INTEGER_MODE_EXT */ + 775, /* GL_INT_2_10_10_10_REV */ + 612, /* GL_FRAMEBUFFER_ATTACHMENT_LAYERED */ + 653, /* GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS */ + 652, /* GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB */ + 1705, /* GL_SAMPLER_1D_ARRAY */ + 1711, /* GL_SAMPLER_2D_ARRAY */ + 1721, /* GL_SAMPLER_BUFFER */ + 1707, /* GL_SAMPLER_1D_ARRAY_SHADOW */ + 1713, /* GL_SAMPLER_2D_ARRAY_SHADOW */ + 1724, /* GL_SAMPLER_CUBE_SHADOW */ + 2209, /* GL_UNSIGNED_INT_VEC2 */ + 2211, /* GL_UNSIGNED_INT_VEC3 */ + 2213, /* GL_UNSIGNED_INT_VEC4 */ + 776, /* GL_INT_SAMPLER_1D */ + 780, /* GL_INT_SAMPLER_2D */ + 786, /* GL_INT_SAMPLER_3D */ + 790, /* GL_INT_SAMPLER_CUBE */ + 784, /* GL_INT_SAMPLER_2D_RECT */ + 777, /* GL_INT_SAMPLER_1D_ARRAY */ + 781, /* GL_INT_SAMPLER_2D_ARRAY */ + 788, /* GL_INT_SAMPLER_BUFFER */ + 2193, /* GL_UNSIGNED_INT_SAMPLER_1D */ + 2197, /* GL_UNSIGNED_INT_SAMPLER_2D */ + 2203, /* GL_UNSIGNED_INT_SAMPLER_3D */ + 2207, /* GL_UNSIGNED_INT_SAMPLER_CUBE */ + 2201, /* GL_UNSIGNED_INT_SAMPLER_2D_RECT */ + 2194, /* GL_UNSIGNED_INT_SAMPLER_1D_ARRAY */ + 2198, /* GL_UNSIGNED_INT_SAMPLER_2D_ARRAY */ + 2205, /* GL_UNSIGNED_INT_SAMPLER_BUFFER */ + 691, /* GL_GEOMETRY_SHADER */ + 694, /* GL_GEOMETRY_VERTICES_OUT_ARB */ + 688, /* GL_GEOMETRY_INPUT_TYPE_ARB */ + 690, /* GL_GEOMETRY_OUTPUT_TYPE_ARB */ + 1063, /* GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB */ + 1146, /* GL_MAX_VERTEX_VARYING_COMPONENTS_ARB */ + 1061, /* GL_MAX_GEOMETRY_UNIFORM_COMPONENTS */ + 1055, /* GL_MAX_GEOMETRY_OUTPUT_VERTICES */ + 1059, /* GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS */ + 863, /* GL_LOW_FLOAT */ + 1148, /* GL_MEDIUM_FLOAT */ + 706, /* GL_HIGH_FLOAT */ + 864, /* GL_LOW_INT */ + 1149, /* GL_MEDIUM_INT */ + 707, /* GL_HIGH_INT */ + 2183, /* GL_UNSIGNED_INT_10_10_10_2_OES */ + 774, /* GL_INT_10_10_10_2_OES */ + 1763, /* GL_SHADER_BINARY_FORMATS */ + 1251, /* GL_NUM_SHADER_BINARY_FORMATS */ + 1764, /* GL_SHADER_COMPILER */ + 1143, /* GL_MAX_VERTEX_UNIFORM_VECTORS */ + 1135, /* GL_MAX_VARYING_VECTORS */ + 1052, /* GL_MAX_FRAGMENT_UNIFORM_VECTORS */ + 1539, /* GL_QUERY_WAIT */ + 1533, /* GL_QUERY_NO_WAIT */ + 1529, /* GL_QUERY_BY_REGION_WAIT */ + 1527, /* GL_QUERY_BY_REGION_NO_WAIT */ + 2127, /* GL_TRANSFORM_FEEDBACK */ + 2136, /* GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED */ + 2130, /* GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE */ + 2128, /* GL_TRANSFORM_FEEDBACK_BINDING */ + 1523, /* GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION */ + 546, /* GL_FIRST_VERTEX_CONVENTION */ + 808, /* GL_LAST_VERTEX_CONVENTION */ + 1497, /* GL_PROVOKING_VERTEX */ + 354, /* GL_COPY_READ_BUFFER */ + 355, /* GL_COPY_WRITE_BUFFER */ + 1566, /* GL_RED_SNORM */ + 1701, /* GL_RG_SNORM */ + 1700, /* GL_RGB_SNORM */ + 1693, /* GL_RGBA_SNORM */ + 1545, /* GL_R8_SNORM */ + 1614, /* GL_RG8_SNORM */ + 1653, /* GL_RGB8_SNORM */ + 1685, /* GL_RGBA8_SNORM */ + 1543, /* GL_R16_SNORM */ + 1613, /* GL_RG16_SNORM */ + 1629, /* GL_RGB16_SNORM */ + 1665, /* GL_RGBA16_SNORM */ + 1775, /* GL_SIGNED_NORMALIZED */ + 1451, /* GL_PRIMITIVE_RESTART */ + 1452, /* GL_PRIMITIVE_RESTART_INDEX */ + 1108, /* GL_MAX_SERVER_WAIT_TIMEOUT */ + 1265, /* GL_OBJECT_TYPE */ + 1888, /* GL_SYNC_CONDITION */ + 1893, /* GL_SYNC_STATUS */ + 1890, /* GL_SYNC_FLAGS */ + 1889, /* GL_SYNC_FENCE */ + 1892, /* GL_SYNC_GPU_COMMANDS_COMPLETE */ + 2176, /* GL_UNSIGNALED */ + 1774, /* GL_SIGNALED */ + 54, /* GL_ALREADY_SIGNALED */ + 2122, /* GL_TIMEOUT_EXPIRED */ + 315, /* GL_CONDITION_SATISFIED */ + 2293, /* GL_WAIT_FAILED */ + 126, /* GL_BUFFER_ACCESS_FLAGS */ + 132, /* GL_BUFFER_MAP_LENGTH */ + 133, /* GL_BUFFER_MAP_OFFSET */ + 1138, /* GL_MAX_VERTEX_OUTPUT_COMPONENTS */ + 1053, /* GL_MAX_GEOMETRY_INPUT_COMPONENTS */ + 1054, /* GL_MAX_GEOMETRY_OUTPUT_COMPONENTS */ + 1049, /* GL_MAX_FRAGMENT_INPUT_COMPONENTS */ + 330, /* GL_CONTEXT_PROFILE_MASK */ + 531, /* GL_EVAL_BIT */ + 1548, /* GL_RASTER_POSITION_UNCLIPPED_IBM */ + 855, /* GL_LIST_BIT */ + 1995, /* GL_TEXTURE_BIT */ + 1744, /* GL_SCISSOR_BIT */ + 30, /* GL_ALL_ATTRIB_BITS */ + 1214, /* GL_MULTISAMPLE_BIT */ + 31, /* GL_ALL_CLIENT_ATTRIB_BITS */ +}; + +typedef int (*cfunc)(const void *, const void *); + +/** + * Compare a key name to an element in the \c all_enums array. + * + * \c bsearch always passes the key as the first parameter and the pointer + * to the array element as the second parameter. We can elimiate some + * extra work by taking advantage of that fact. + * + * \param a Pointer to the desired enum name. + * \param b Pointer to an element of the \c all_enums array. + */ +static int compar_name( const char *a, const enum_elt *b ) +{ + return strcmp( a, & enum_string_table[ b->offset ] ); +} + +/** + * Compare a key enum value to an element in the \c all_enums array. + * + * \c bsearch always passes the key as the first parameter and the pointer + * to the array element as the second parameter. We can elimiate some + * extra work by taking advantage of that fact. + * + * \param a Pointer to the desired enum name. + * \param b Pointer to an index into the \c all_enums array. + */ +static int compar_nr( const int *a, const unsigned *b ) +{ + return a[0] - all_enums[*b].n; +} + + +static char token_tmp[20]; + +const char *_mesa_lookup_enum_by_nr( int nr ) +{ + unsigned * i; + + i = (unsigned *) _mesa_bsearch(& nr, reduced_enums, + Elements(reduced_enums), + sizeof(reduced_enums[0]), + (cfunc) compar_nr); + + if ( i != NULL ) { + return & enum_string_table[ all_enums[ *i ].offset ]; + } + else { + /* this is not re-entrant safe, no big deal here */ + _mesa_snprintf(token_tmp, sizeof(token_tmp) - 1, "0x%x", nr); + token_tmp[sizeof(token_tmp) - 1] = '\0'; + return token_tmp; + } +} + +/** + * Primitive names + */ +static const char *prim_names[PRIM_UNKNOWN + 1] = { + "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" +}; + + +/* Get the name of an enum given that it is a primitive type. Avoids + * GL_FALSE/GL_POINTS ambiguity and others. + */ +const char * +_mesa_lookup_prim_by_nr(GLuint nr) +{ + if (nr < Elements(prim_names)) + return prim_names[nr]; + else + return "invalid mode"; +} + + +int _mesa_lookup_enum_by_name( const char *symbol ) +{ + enum_elt * f = NULL; + + if ( symbol != NULL ) { + f = (enum_elt *) _mesa_bsearch(symbol, all_enums, + Elements(all_enums), + sizeof( enum_elt ), + (cfunc) compar_name); + } + + return (f != NULL) ? f->n : -1; +} + + diff --git a/mesalib/src/mesa/main/es_generator.py b/mesalib/src/mesa/main/es_generator.py index 6b04c8b47..cad3deaef 100644 --- a/mesalib/src/mesa/main/es_generator.py +++ b/mesalib/src/mesa/main/es_generator.py @@ -1,758 +1,758 @@ -#************************************************************************* -# Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. -# 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 -# TUNGSTEN GRAPHICS 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. -#************************************************************************* - - -import sys, os -import APIspecutil as apiutil - -# These dictionary entries are used for automatic conversion. -# The string will be used as a format string with the conversion -# variable. -Converters = { - 'GLfloat': { - 'GLdouble': "(GLdouble) (%s)", - 'GLfixed' : "(GLint) (%s * 65536)", - }, - 'GLfixed': { - 'GLfloat': "(GLfloat) (%s / 65536.0f)", - 'GLdouble': "(GLdouble) (%s / 65536.0)", - }, - 'GLdouble': { - 'GLfloat': "(GLfloat) (%s)", - 'GLfixed': "(GLfixed) (%s * 65536)", - }, - 'GLclampf': { - 'GLclampd': "(GLclampd) (%s)", - 'GLclampx': "(GLclampx) (%s * 65536)", - }, - 'GLclampx': { - 'GLclampf': "(GLclampf) (%s / 65536.0f)", - 'GLclampd': "(GLclampd) (%s / 65536.0)", - }, - 'GLubyte': { - 'GLfloat': "(GLfloat) (%s / 255.0f)", - }, -} - -def GetBaseType(type): - typeTokens = type.split(' ') - baseType = None - typeModifiers = [] - for t in typeTokens: - if t in ['const', '*']: - typeModifiers.append(t) - else: - baseType = t - return (baseType, typeModifiers) - -def ConvertValue(value, fromType, toType): - """Returns a string that represents the given parameter string, - type-converted if necessary.""" - - if not Converters.has_key(fromType): - print >> sys.stderr, "No base converter for type '%s' found. Ignoring." % fromType - return value - - if not Converters[fromType].has_key(toType): - print >> sys.stderr, "No converter found for type '%s' to type '%s'. Ignoring." % (fromType, toType) - return value - - # This part is simple. Return the proper conversion. - conversionString = Converters[fromType][toType] - return conversionString % value - -FormatStrings = { - 'GLenum' : '0x%x', - 'GLfloat' : '%f', - 'GLint' : '%d', - 'GLbitfield' : '0x%x', -} -def GetFormatString(type): - if FormatStrings.has_key(type): - return FormatStrings[type] - else: - return None - - -###################################################################### -# Version-specific values to be used in the main script -# header: which header file to include -# api: what text specifies an API-level function -VersionSpecificValues = { - 'GLES1.1' : { - 'description' : 'GLES1.1 functions', - 'header' : 'GLES/gl.h', - 'extheader' : 'GLES/glext.h', - 'shortname' : 'es1' - }, - 'GLES2.0': { - 'description' : 'GLES2.0 functions', - 'header' : 'GLES2/gl2.h', - 'extheader' : 'GLES2/gl2ext.h', - 'shortname' : 'es2' - } -} - - -###################################################################### -# Main code for the script begins here. - -# Get the name of the program (without the directory part) for use in -# error messages. -program = os.path.basename(sys.argv[0]) - -# Set default values -verbose = 0 -functionList = "APIspec.xml" -version = "GLES1.1" - -# Allow for command-line switches -import getopt, time -options = "hvV:S:" -try: - optlist, args = getopt.getopt(sys.argv[1:], options) -except getopt.GetoptError, message: - sys.stderr.write("%s: %s. Use -h for help.\n" % (program, message)) - sys.exit(1) - -for option, optarg in optlist: - if option == "-h": - sys.stderr.write("Usage: %s [-%s]\n" % (program, options)) - sys.stderr.write("Parse an API specification file and generate wrapper functions for a given GLES version\n") - sys.stderr.write("-h gives help\n") - sys.stderr.write("-v is verbose\n") - sys.stderr.write("-V specifies GLES version to generate [%s]:\n" % version) - for key in VersionSpecificValues.keys(): - sys.stderr.write(" %s - %s\n" % (key, VersionSpecificValues[key]['description'])) - sys.stderr.write("-S specifies API specification file to use [%s]\n" % functionList) - sys.exit(1) - elif option == "-v": - verbose += 1 - elif option == "-V": - version = optarg - elif option == "-S": - functionList = optarg - -# Beyond switches, we support no further command-line arguments -if len(args) > 0: - sys.stderr.write("%s: only switch arguments are supported - use -h for help\n" % program) - sys.exit(1) - -# If we don't have a valid version, abort. -if not VersionSpecificValues.has_key(version): - sys.stderr.write("%s: version '%s' is not valid - use -h for help\n" % (program, version)) - sys.exit(1) - -# Grab the version-specific items we need to use -versionHeader = VersionSpecificValues[version]['header'] -versionExtHeader = VersionSpecificValues[version]['extheader'] -shortname = VersionSpecificValues[version]['shortname'] - -# If we get to here, we're good to go. The "version" parameter -# directs GetDispatchedFunctions to only allow functions from -# that "category" (version in our parlance). This allows -# functions with different declarations in different categories -# to exist (glTexImage2D, for example, is different between -# GLES1 and GLES2). -keys = apiutil.GetAllFunctions(functionList, version) - -allSpecials = apiutil.AllSpecials() - -print """/* DO NOT EDIT ************************************************* - * THIS FILE AUTOMATICALLY GENERATED BY THE %s SCRIPT - * API specification file: %s - * GLES version: %s - * date: %s - */ -""" % (program, functionList, version, time.strftime("%Y-%m-%d %H:%M:%S")) - -# The headers we choose are version-specific. -print """ -#include "%s" -#include "%s" -#include "main/mfeatures.h" -#include "main/compiler.h" -#include "main/api_exec.h" - -#if FEATURE_%s - -#ifndef GLAPIENTRYP -#define GLAPIENTRYP GL_APIENTRYP -#endif -""" % (versionHeader, versionExtHeader, shortname.upper()) - -# Everyone needs these types. -print """ -/* These types are needed for the Mesa veneer, but are not defined in - * the standard GLES headers. - */ -typedef double GLdouble; -typedef double GLclampd; - -/* Mesa error handling requires these */ -extern void *_mesa_get_current_context(void); -extern void _mesa_error(void *ctx, GLenum error, const char *fmtString, ... ); -""" - -# Finally we get to the all-important functions -print """/************************************************************* - * Generated functions begin here - */ -""" -for funcName in keys: - if verbose > 0: sys.stderr.write("%s: processing function %s\n" % (program, funcName)) - - # start figuring out what this function will look like. - returnType = apiutil.ReturnType(funcName) - props = apiutil.Properties(funcName) - params = apiutil.Parameters(funcName) - declarationString = apiutil.MakeDeclarationString(params) - - # In case of error, a function may have to return. Make - # sure we have valid return values in this case. - if returnType == "void": - errorReturn = "return" - elif returnType == "GLboolean": - errorReturn = "return GL_FALSE" - else: - errorReturn = "return (%s) 0" % returnType - - # These are the output of this large calculation block. - # passthroughDeclarationString: a typed set of parameters that - # will be used to create the "extern" reference for the - # underlying Mesa or support function. Note that as generated - # these have an extra ", " at the beginning, which will be - # removed before use. - # - # passthroughDeclarationString: an untyped list of parameters - # that will be used to call the underlying Mesa or support - # function (including references to converted parameters). - # This will also be generated with an extra ", " at the - # beginning, which will be removed before use. - # - # variables: C code to create any local variables determined to - # be necessary. - # conversionCodeOutgoing: C code to convert application parameters - # to a necessary type before calling the underlying support code. - # May be empty if no conversion is required. - # conversionCodeIncoming: C code to do the converse: convert - # values returned by underlying Mesa code to the types needed - # by the application. - # Note that *either* the conversionCodeIncoming will be used (for - # generated query functions), *or* the conversionCodeOutgoing will - # be used (for generated non-query functions), never both. - passthroughFuncName = "" - passthroughDeclarationString = "" - passthroughCallString = "" - prefixOverride = None - variables = [] - conversionCodeOutgoing = [] - conversionCodeIncoming = [] - switchCode = [] - - # Calculate the name of the underlying support function to call. - # By default, the passthrough function is named _mesa_. - # We're allowed to override the prefix and/or the function name - # for each function record, though. The "ConversionFunction" - # utility is poorly named, BTW... - if funcName in allSpecials: - # perform checks and pass through - funcPrefix = "_check_" - aliasprefix = "_es_" - else: - funcPrefix = "_es_" - aliasprefix = apiutil.AliasPrefix(funcName) - alias = apiutil.ConversionFunction(funcName) - prefixOverride = apiutil.FunctionPrefix(funcName) - if prefixOverride != "_mesa_": - aliasprefix = apiutil.FunctionPrefix(funcName) - if not alias: - # There may still be a Mesa alias for the function - if apiutil.Alias(funcName): - passthroughFuncName = "%s%s" % (aliasprefix, apiutil.Alias(funcName)) - else: - passthroughFuncName = "%s%s" % (aliasprefix, funcName) - else: # a specific alias is provided - passthroughFuncName = "%s%s" % (aliasprefix, alias) - - # Look at every parameter: each one may have only specific - # allowed values, or dependent parameters to check, or - # variant-sized vector arrays to calculate - for (paramName, paramType, paramMaxVecSize, paramConvertToType, paramValidValues, paramValueConversion) in params: - # We'll need this below if we're doing conversions - (paramBaseType, paramTypeModifiers) = GetBaseType(paramType) - - # Conversion management. - # We'll handle three cases, easiest to hardest: a parameter - # that doesn't require conversion, a scalar parameter that - # requires conversion, and a vector parameter that requires - # conversion. - if paramConvertToType == None: - # Unconverted parameters are easy, whether they're vector - # or scalar - just add them to the call list. No conversions - # or anything to worry about. - passthroughDeclarationString += ", %s %s" % (paramType, paramName) - passthroughCallString += ", %s" % paramName - - elif paramMaxVecSize == 0: # a scalar parameter that needs conversion - # A scalar to hold a converted parameter - variables.append(" %s converted_%s;" % (paramConvertToType, paramName)) - - # Outgoing conversion depends on whether we have to conditionally - # perform value conversion. - if paramValueConversion == "none": - conversionCodeOutgoing.append(" converted_%s = (%s) %s;" % (paramName, paramConvertToType, paramName)) - elif paramValueConversion == "some": - # We'll need a conditional variable to keep track of - # whether we're converting values or not. - if (" int convert_%s_value = 1;" % paramName) not in variables: - variables.append(" int convert_%s_value = 1;" % paramName) - - # Write code based on that conditional. - conversionCodeOutgoing.append(" if (convert_%s_value) {" % paramName) - conversionCodeOutgoing.append(" converted_%s = %s;" % (paramName, ConvertValue(paramName, paramBaseType, paramConvertToType))) - conversionCodeOutgoing.append(" } else {") - conversionCodeOutgoing.append(" converted_%s = (%s) %s;" % (paramName, paramConvertToType, paramName)) - conversionCodeOutgoing.append(" }") - else: # paramValueConversion == "all" - conversionCodeOutgoing.append(" converted_%s = %s;" % (paramName, ConvertValue(paramName, paramBaseType, paramConvertToType))) - - # Note that there can be no incoming conversion for a - # scalar parameter; changing the scalar will only change - # the local value, and won't ultimately change anything - # that passes back to the application. - - # Call strings. The unusual " ".join() call will join the - # array of parameter modifiers with spaces as separators. - passthroughDeclarationString += ", %s %s %s" % (paramConvertToType, " ".join(paramTypeModifiers), paramName) - passthroughCallString += ", converted_%s" % paramName - - else: # a vector parameter that needs conversion - # We'll need an index variable for conversions - if " register unsigned int i;" not in variables: - variables.append(" register unsigned int i;") - - # This variable will hold the (possibly variant) size of - # this array needing conversion. By default, we'll set - # it to the maximal size (which is correct for functions - # with a constant-sized vector parameter); for true - # variant arrays, we'll modify it with other code. - variables.append(" unsigned int n_%s = %d;" % (paramName, paramMaxVecSize)) - - # This array will hold the actual converted values. - variables.append(" %s converted_%s[%d];" % (paramConvertToType, paramName, paramMaxVecSize)) - - # Again, we choose the conversion code based on whether we - # have to always convert values, never convert values, or - # conditionally convert values. - if paramValueConversion == "none": - conversionCodeOutgoing.append(" for (i = 0; i < n_%s; i++) {" % paramName) - conversionCodeOutgoing.append(" converted_%s[i] = (%s) %s[i];" % (paramName, paramConvertToType, paramName)) - conversionCodeOutgoing.append(" }") - elif paramValueConversion == "some": - # We'll need a conditional variable to keep track of - # whether we're converting values or not. - if (" int convert_%s_value = 1;" % paramName) not in variables: - variables.append(" int convert_%s_value = 1;" % paramName) - # Write code based on that conditional. - conversionCodeOutgoing.append(" if (convert_%s_value) {" % paramName) - conversionCodeOutgoing.append(" for (i = 0; i < n_%s; i++) {" % paramName) - conversionCodeOutgoing.append(" converted_%s[i] = %s;" % (paramName, ConvertValue("%s[i]" % paramName, paramBaseType, paramConvertToType))) - conversionCodeOutgoing.append(" }") - conversionCodeOutgoing.append(" } else {") - conversionCodeOutgoing.append(" for (i = 0; i < n_%s; i++) {" % paramName) - conversionCodeOutgoing.append(" converted_%s[i] = (%s) %s[i];" % (paramName, paramConvertToType, paramName)) - conversionCodeOutgoing.append(" }") - conversionCodeOutgoing.append(" }") - else: # paramValueConversion == "all" - conversionCodeOutgoing.append(" for (i = 0; i < n_%s; i++) {" % paramName) - conversionCodeOutgoing.append(" converted_%s[i] = %s;" % (paramName, ConvertValue("%s[i]" % paramName, paramBaseType, paramConvertToType))) - - conversionCodeOutgoing.append(" }") - - # If instead we need an incoming conversion (i.e. results - # from Mesa have to be converted before handing back - # to the application), this is it. Fortunately, we don't - # have to worry about conditional value conversion - the - # functions that do (e.g. glGetFixedv()) are handled - # specially, outside this code generation. - # - # Whether we use incoming conversion or outgoing conversion - # is determined later - we only ever use one or the other. - - if paramValueConversion == "none": - conversionCodeIncoming.append(" for (i = 0; i < n_%s; i++) {" % paramName) - conversionCodeIncoming.append(" %s[i] = (%s) converted_%s[i];" % (paramName, paramConvertToType, paramName)) - conversionCodeIncoming.append(" }") - elif paramValueConversion == "some": - # We'll need a conditional variable to keep track of - # whether we're converting values or not. - if (" int convert_%s_value = 1;" % paramName) not in variables: - variables.append(" int convert_%s_value = 1;" % paramName) - - # Write code based on that conditional. - conversionCodeIncoming.append(" if (convert_%s_value) {" % paramName) - conversionCodeIncoming.append(" for (i = 0; i < n_%s; i++) {" % paramName) - conversionCodeIncoming.append(" %s[i] = %s;" % (paramName, ConvertValue("converted_%s[i]" % paramName, paramConvertToType, paramBaseType))) - conversionCodeIncoming.append(" }") - conversionCodeIncoming.append(" } else {") - conversionCodeIncoming.append(" for (i = 0; i < n_%s; i++) {" % paramName) - conversionCodeIncoming.append(" %s[i] = (%s) converted_%s[i];" % (paramName, paramBaseType, paramName)) - conversionCodeIncoming.append(" }") - conversionCodeIncoming.append(" }") - else: # paramValueConversion == "all" - conversionCodeIncoming.append(" for (i = 0; i < n_%s; i++) {" % paramName) - conversionCodeIncoming.append(" %s[i] = %s;" % (paramName, ConvertValue("converted_%s[i]" % paramName, paramConvertToType, paramBaseType))) - conversionCodeIncoming.append(" }") - - # Call strings. The unusual " ".join() call will join the - # array of parameter modifiers with spaces as separators. - passthroughDeclarationString += ", %s %s %s" % (paramConvertToType, " ".join(paramTypeModifiers), paramName) - passthroughCallString += ", converted_%s" % paramName - - # endif conversion management - - # Parameter checking. If the parameter has a specific list of - # valid values, we have to make sure that the passed-in values - # match these, or we make an error. - if len(paramValidValues) > 0: - # We're about to make a big switch statement with an - # error at the end. By default, the error is GL_INVALID_ENUM, - # unless we find a "case" statement in the middle with a - # non-GLenum value. - errorDefaultCase = "GL_INVALID_ENUM" - - # This parameter has specific valid values. Make a big - # switch statement to handle it. Note that the original - # parameters are always what is checked, not the - # converted parameters. - switchCode.append(" switch(%s) {" % paramName) - - for valueIndex in range(len(paramValidValues)): - (paramValue, dependentVecSize, dependentParamName, dependentValidValues, errorCode, valueConvert) = paramValidValues[valueIndex] - - # We're going to need information on the dependent param - # as well. - if dependentParamName: - depParamIndex = apiutil.FindParamIndex(params, dependentParamName) - if depParamIndex == None: - sys.stderr.write("%s: can't find dependent param '%s' for function '%s'\n" % (program, dependentParamName, funcName)) - - (depParamName, depParamType, depParamMaxVecSize, depParamConvertToType, depParamValidValues, depParamValueConversion) = params[depParamIndex] - else: - (depParamName, depParamType, depParamMaxVecSize, depParamConvertToType, depParamValidValues, depParamValueConversion) = (None, None, None, None, [], None) - - # This is a sneaky trick. It's valid syntax for a parameter - # that is *not* going to be converted to be declared - # with a dependent vector size; but in this case, the - # dependent vector size is unused and unnecessary. - # So check for this and ignore the dependent vector size - # if the parameter is not going to be converted. - if depParamConvertToType: - usedDependentVecSize = dependentVecSize - else: - usedDependentVecSize = None - - # We'll peek ahead at the next parameter, to see whether - # we can combine cases - if valueIndex + 1 < len(paramValidValues) : - (nextParamValue, nextDependentVecSize, nextDependentParamName, nextDependentValidValues, nextErrorCode, nextValueConvert) = paramValidValues[valueIndex + 1] - if depParamConvertToType: - usedNextDependentVecSize = nextDependentVecSize - else: - usedNextDependentVecSize = None - - # Create a case for this value. As a mnemonic, - # if we have a dependent vector size that we're ignoring, - # add it as a comment. - if usedDependentVecSize == None and dependentVecSize != None: - switchCode.append(" case %s: /* size %s */" % (paramValue, dependentVecSize)) - else: - switchCode.append(" case %s:" % paramValue) - - # If this is not a GLenum case, then switch our error - # if no value is matched to be GL_INVALID_VALUE instead - # of GL_INVALID_ENUM. (Yes, this does get confused - # if there are both values and GLenums in the same - # switch statement, which shouldn't happen.) - if paramValue[0:3] != "GL_": - errorDefaultCase = "GL_INVALID_VALUE" - - # If all the remaining parameters are identical to the - # next set, then we're done - we'll just create the - # official code on the next pass through, and the two - # cases will share the code. - if valueIndex + 1 < len(paramValidValues) and usedDependentVecSize == usedNextDependentVecSize and dependentParamName == nextDependentParamName and dependentValidValues == nextDependentValidValues and errorCode == nextErrorCode and valueConvert == nextValueConvert: - continue - - # Otherwise, we'll have to generate code for this case. - # Start off with a check: if there is a dependent parameter, - # and a list of valid values for that parameter, we need - # to generate an error if something other than one - # of those values is passed. - if len(dependentValidValues) > 0: - conditional="" - - # If the parameter being checked is actually an array, - # check only its first element. - if depParamMaxVecSize == 0: - valueToCheck = dependentParamName - else: - valueToCheck = "%s[0]" % dependentParamName - - for v in dependentValidValues: - conditional += " && %s != %s" % (valueToCheck, v) - switchCode.append(" if (%s) {" % conditional[4:]) - if errorCode == None: - errorCode = "GL_INVALID_ENUM" - switchCode.append(' _mesa_error(_mesa_get_current_context(), %s, "gl%s(%s=0x%s)", %s);' % (errorCode, funcName, paramName, "%x", paramName)) - switchCode.append(" %s;" % errorReturn) - switchCode.append(" }") - # endif there are dependent valid values - - # The dependent parameter may require conditional - # value conversion. If it does, and we don't want - # to convert values, we'll have to generate code for that - if depParamValueConversion == "some" and valueConvert == "noconvert": - switchCode.append(" convert_%s_value = 0;" % dependentParamName) - - # If there's a dependent vector size for this parameter - # that we're actually going to use (i.e. we need conversion), - # mark it. - if usedDependentVecSize: - switchCode.append(" n_%s = %s;" % (dependentParamName, dependentVecSize)) - - # In all cases, break out of the switch if any valid - # value is found. - switchCode.append(" break;") - - - # Need a default case to catch all the other, invalid - # parameter values. These will all generate errors. - switchCode.append(" default:") - if errorCode == None: - errorCode = "GL_INVALID_ENUM" - formatString = GetFormatString(paramType) - if formatString == None: - switchCode.append(' _mesa_error(_mesa_get_current_context(), %s, "gl%s(%s)");' % (errorCode, funcName, paramName)) - else: - switchCode.append(' _mesa_error(_mesa_get_current_context(), %s, "gl%s(%s=%s)", %s);' % (errorCode, funcName, paramName, formatString, paramName)) - switchCode.append(" %s;" % errorReturn) - - # End of our switch code. - switchCode.append(" }") - - # endfor every recognized parameter value - - # endfor every param - - # Here, the passthroughDeclarationString and passthroughCallString - # are complete; remove the extra ", " at the front of each. - passthroughDeclarationString = passthroughDeclarationString[2:] - passthroughCallString = passthroughCallString[2:] - if not passthroughDeclarationString: - passthroughDeclarationString = "void" - - # The Mesa functions are scattered across all the Mesa - # header files. The easiest way to manage declarations - # is to create them ourselves. - if funcName in allSpecials: - print "/* this function is special and is defined elsewhere */" - print "extern %s GL_APIENTRY %s(%s);" % (returnType, passthroughFuncName, passthroughDeclarationString) - - # A function may be a core function (i.e. it exists in - # the core specification), a core addition (extension - # functions added officially to the core), a required - # extension (usually an extension for an earlier version - # that has been officially adopted), or an optional extension. - # - # Core functions have a simple category (e.g. "GLES1.1"); - # we generate only a simple callback for them. - # - # Core additions have two category listings, one simple - # and one compound (e.g. ["GLES1.1", "GLES1.1:OES_fixed_point"]). - # We generate the core function, and also an extension function. - # - # Required extensions and implemented optional extensions - # have a single compound category "GLES1.1:OES_point_size_array". - # For these we generate just the extension function. - for categorySpec in apiutil.Categories(funcName): - compoundCategory = categorySpec.split(":") - - # This category isn't for us, if the base category doesn't match - # our version - if compoundCategory[0] != version: - continue - - # Otherwise, determine if we're writing code for a core - # function (no suffix) or an extension function. - if len(compoundCategory) == 1: - # This is a core function - extensionName = None - extensionSuffix = "" - else: - # This is an extension function. We'll need to append - # the extension suffix. - extensionName = compoundCategory[1] - extensionSuffix = extensionName.split("_")[0] - fullFuncName = funcPrefix + funcName + extensionSuffix - - # Now the generated function. The text used to mark an API-level - # function, oddly, is version-specific. - if extensionName: - print "/* Extension %s */" % extensionName - - if (not variables and - not switchCode and - not conversionCodeOutgoing and - not conversionCodeIncoming): - # pass through directly - print "#define %s %s" % (fullFuncName, passthroughFuncName) - print - continue - - print "static %s GL_APIENTRY %s(%s)" % (returnType, fullFuncName, declarationString) - print "{" - - # Start printing our code pieces. Start with any local - # variables we need. This unusual syntax joins the - # lines in the variables[] array with the "\n" separator. - if len(variables) > 0: - print "\n".join(variables) + "\n" - - # If there's any sort of parameter checking or variable - # array sizing, the switch code will contain it. - if len(switchCode) > 0: - print "\n".join(switchCode) + "\n" - - # In the case of an outgoing conversion (i.e. parameters must - # be converted before calling the underlying Mesa function), - # use the appropriate code. - if "get" not in props and len(conversionCodeOutgoing) > 0: - print "\n".join(conversionCodeOutgoing) + "\n" - - # Call the Mesa function. Note that there are very few functions - # that return a value (i.e. returnType is not "void"), and that - # none of them require incoming translation; so we're safe - # to generate code that directly returns in those cases, - # even though it's not completely independent. - - if returnType == "void": - print " %s(%s);" % (passthroughFuncName, passthroughCallString) - else: - print " return %s(%s);" % (passthroughFuncName, passthroughCallString) - - # If the function is one that returns values (i.e. "get" in props), - # it might return values of a different type than we need, that - # require conversion before passing back to the application. - if "get" in props and len(conversionCodeIncoming) > 0: - print "\n".join(conversionCodeIncoming) - - # All done. - print "}" - print - # end for each category provided for a function - -# end for each function - -print """ -#include "glapi/glapi.h" - -#if FEATURE_remap_table - -/* define esLocalRemapTable */ -#include "main/api_exec_%s_dispatch.h" - -#define need_MESA_remap_table -#include "main/api_exec_%s_remap_helper.h" - -static void -init_remap_table(void) -{ - _glthread_DECLARE_STATIC_MUTEX(mutex); - static GLboolean initialized = GL_FALSE; - const struct gl_function_pool_remap *remap = MESA_remap_table_functions; - int i; - - _glthread_LOCK_MUTEX(mutex); - if (initialized) { - _glthread_UNLOCK_MUTEX(mutex); - return; - } - - for (i = 0; i < esLocalRemapTable_size; i++) { - GLint offset; - const char *spec; - - /* sanity check */ - ASSERT(i == remap[i].remap_index); - spec = _mesa_function_pool + remap[i].pool_index; - - offset = _mesa_map_function_spec(spec); - esLocalRemapTable[i] = offset; - } - initialized = GL_TRUE; - _glthread_UNLOCK_MUTEX(mutex); -} - -#else /* FEATURE_remap_table */ - -#include "%sapi/main/dispatch.h" - -static INLINE void -init_remap_table(void) -{ -} - -#endif /* FEATURE_remap_table */ - -struct _glapi_table * -_mesa_create_exec_table_%s(void) -{ - struct _glapi_table *exec; - - exec = _mesa_alloc_dispatch_table(_gloffset_COUNT); - if (exec == NULL) - return NULL; - - init_remap_table(); -""" % (shortname, shortname, shortname, shortname) - -for func in keys: - prefix = "_es_" if func not in allSpecials else "_check_" - for spec in apiutil.Categories(func): - ext = spec.split(":") - # version does not match - if ext.pop(0) != version: - continue - entry = func - if ext: - suffix = ext[0].split("_")[0] - entry += suffix - print " SET_%s(exec, %s%s);" % (entry, prefix, entry) -print "" -print " return exec;" -print "}" - -print """ -#endif /* FEATURE_%s */""" % (shortname.upper()) +#************************************************************************* +# Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. +# 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 +# TUNGSTEN GRAPHICS 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. +#************************************************************************* + + +import sys, os +import APIspecutil as apiutil + +# These dictionary entries are used for automatic conversion. +# The string will be used as a format string with the conversion +# variable. +Converters = { + 'GLfloat': { + 'GLdouble': "(GLdouble) (%s)", + 'GLfixed' : "(GLint) (%s * 65536)", + }, + 'GLfixed': { + 'GLfloat': "(GLfloat) (%s / 65536.0f)", + 'GLdouble': "(GLdouble) (%s / 65536.0)", + }, + 'GLdouble': { + 'GLfloat': "(GLfloat) (%s)", + 'GLfixed': "(GLfixed) (%s * 65536)", + }, + 'GLclampf': { + 'GLclampd': "(GLclampd) (%s)", + 'GLclampx': "(GLclampx) (%s * 65536)", + }, + 'GLclampx': { + 'GLclampf': "(GLclampf) (%s / 65536.0f)", + 'GLclampd': "(GLclampd) (%s / 65536.0)", + }, + 'GLubyte': { + 'GLfloat': "(GLfloat) (%s / 255.0f)", + }, +} + +def GetBaseType(type): + typeTokens = type.split(' ') + baseType = None + typeModifiers = [] + for t in typeTokens: + if t in ['const', '*']: + typeModifiers.append(t) + else: + baseType = t + return (baseType, typeModifiers) + +def ConvertValue(value, fromType, toType): + """Returns a string that represents the given parameter string, + type-converted if necessary.""" + + if not Converters.has_key(fromType): + print >> sys.stderr, "No base converter for type '%s' found. Ignoring." % fromType + return value + + if not Converters[fromType].has_key(toType): + print >> sys.stderr, "No converter found for type '%s' to type '%s'. Ignoring." % (fromType, toType) + return value + + # This part is simple. Return the proper conversion. + conversionString = Converters[fromType][toType] + return conversionString % value + +FormatStrings = { + 'GLenum' : '0x%x', + 'GLfloat' : '%f', + 'GLint' : '%d', + 'GLbitfield' : '0x%x', +} +def GetFormatString(type): + if FormatStrings.has_key(type): + return FormatStrings[type] + else: + return None + + +###################################################################### +# Version-specific values to be used in the main script +# header: which header file to include +# api: what text specifies an API-level function +VersionSpecificValues = { + 'GLES1.1' : { + 'description' : 'GLES1.1 functions', + 'header' : 'GLES/gl.h', + 'extheader' : 'GLES/glext.h', + 'shortname' : 'es1' + }, + 'GLES2.0': { + 'description' : 'GLES2.0 functions', + 'header' : 'GLES2/gl2.h', + 'extheader' : 'GLES2/gl2ext.h', + 'shortname' : 'es2' + } +} + + +###################################################################### +# Main code for the script begins here. + +# Get the name of the program (without the directory part) for use in +# error messages. +program = os.path.basename(sys.argv[0]) + +# Set default values +verbose = 0 +functionList = "APIspec.xml" +version = "GLES1.1" + +# Allow for command-line switches +import getopt, time +options = "hvV:S:" +try: + optlist, args = getopt.getopt(sys.argv[1:], options) +except getopt.GetoptError, message: + sys.stderr.write("%s: %s. Use -h for help.\n" % (program, message)) + sys.exit(1) + +for option, optarg in optlist: + if option == "-h": + sys.stderr.write("Usage: %s [-%s]\n" % (program, options)) + sys.stderr.write("Parse an API specification file and generate wrapper functions for a given GLES version\n") + sys.stderr.write("-h gives help\n") + sys.stderr.write("-v is verbose\n") + sys.stderr.write("-V specifies GLES version to generate [%s]:\n" % version) + for key in VersionSpecificValues.keys(): + sys.stderr.write(" %s - %s\n" % (key, VersionSpecificValues[key]['description'])) + sys.stderr.write("-S specifies API specification file to use [%s]\n" % functionList) + sys.exit(1) + elif option == "-v": + verbose += 1 + elif option == "-V": + version = optarg + elif option == "-S": + functionList = optarg + +# Beyond switches, we support no further command-line arguments +if len(args) > 0: + sys.stderr.write("%s: only switch arguments are supported - use -h for help\n" % program) + sys.exit(1) + +# If we don't have a valid version, abort. +if not VersionSpecificValues.has_key(version): + sys.stderr.write("%s: version '%s' is not valid - use -h for help\n" % (program, version)) + sys.exit(1) + +# Grab the version-specific items we need to use +versionHeader = VersionSpecificValues[version]['header'] +versionExtHeader = VersionSpecificValues[version]['extheader'] +shortname = VersionSpecificValues[version]['shortname'] + +# If we get to here, we're good to go. The "version" parameter +# directs GetDispatchedFunctions to only allow functions from +# that "category" (version in our parlance). This allows +# functions with different declarations in different categories +# to exist (glTexImage2D, for example, is different between +# GLES1 and GLES2). +keys = apiutil.GetAllFunctions(functionList, version) + +allSpecials = apiutil.AllSpecials() + +print """/* DO NOT EDIT ************************************************* + * THIS FILE AUTOMATICALLY GENERATED BY THE %s SCRIPT + * API specification file: %s + * GLES version: %s + * date: %s + */ +""" % (program, functionList, version, time.strftime("%Y-%m-%d %H:%M:%S")) + +# The headers we choose are version-specific. +print """ +#include "%s" +#include "%s" +#include "main/mfeatures.h" +#include "main/compiler.h" +#include "main/api_exec.h" + +#if FEATURE_%s + +#ifndef GLAPIENTRYP +#define GLAPIENTRYP GL_APIENTRYP +#endif +""" % (versionHeader, versionExtHeader, shortname.upper()) + +# Everyone needs these types. +print """ +/* These types are needed for the Mesa veneer, but are not defined in + * the standard GLES headers. + */ +typedef double GLdouble; +typedef double GLclampd; + +/* Mesa error handling requires these */ +extern void *_mesa_get_current_context(void); +extern void _mesa_error(void *ctx, GLenum error, const char *fmtString, ... ); +""" + +# Finally we get to the all-important functions +print """/************************************************************* + * Generated functions begin here + */ +""" +for funcName in keys: + if verbose > 0: sys.stderr.write("%s: processing function %s\n" % (program, funcName)) + + # start figuring out what this function will look like. + returnType = apiutil.ReturnType(funcName) + props = apiutil.Properties(funcName) + params = apiutil.Parameters(funcName) + declarationString = apiutil.MakeDeclarationString(params) + + # In case of error, a function may have to return. Make + # sure we have valid return values in this case. + if returnType == "void": + errorReturn = "return" + elif returnType == "GLboolean": + errorReturn = "return GL_FALSE" + else: + errorReturn = "return (%s) 0" % returnType + + # These are the output of this large calculation block. + # passthroughDeclarationString: a typed set of parameters that + # will be used to create the "extern" reference for the + # underlying Mesa or support function. Note that as generated + # these have an extra ", " at the beginning, which will be + # removed before use. + # + # passthroughDeclarationString: an untyped list of parameters + # that will be used to call the underlying Mesa or support + # function (including references to converted parameters). + # This will also be generated with an extra ", " at the + # beginning, which will be removed before use. + # + # variables: C code to create any local variables determined to + # be necessary. + # conversionCodeOutgoing: C code to convert application parameters + # to a necessary type before calling the underlying support code. + # May be empty if no conversion is required. + # conversionCodeIncoming: C code to do the converse: convert + # values returned by underlying Mesa code to the types needed + # by the application. + # Note that *either* the conversionCodeIncoming will be used (for + # generated query functions), *or* the conversionCodeOutgoing will + # be used (for generated non-query functions), never both. + passthroughFuncName = "" + passthroughDeclarationString = "" + passthroughCallString = "" + prefixOverride = None + variables = [] + conversionCodeOutgoing = [] + conversionCodeIncoming = [] + switchCode = [] + + # Calculate the name of the underlying support function to call. + # By default, the passthrough function is named _mesa_. + # We're allowed to override the prefix and/or the function name + # for each function record, though. The "ConversionFunction" + # utility is poorly named, BTW... + if funcName in allSpecials: + # perform checks and pass through + funcPrefix = "_check_" + aliasprefix = "_es_" + else: + funcPrefix = "_es_" + aliasprefix = apiutil.AliasPrefix(funcName) + alias = apiutil.ConversionFunction(funcName) + prefixOverride = apiutil.FunctionPrefix(funcName) + if prefixOverride != "_mesa_": + aliasprefix = apiutil.FunctionPrefix(funcName) + if not alias: + # There may still be a Mesa alias for the function + if apiutil.Alias(funcName): + passthroughFuncName = "%s%s" % (aliasprefix, apiutil.Alias(funcName)) + else: + passthroughFuncName = "%s%s" % (aliasprefix, funcName) + else: # a specific alias is provided + passthroughFuncName = "%s%s" % (aliasprefix, alias) + + # Look at every parameter: each one may have only specific + # allowed values, or dependent parameters to check, or + # variant-sized vector arrays to calculate + for (paramName, paramType, paramMaxVecSize, paramConvertToType, paramValidValues, paramValueConversion) in params: + # We'll need this below if we're doing conversions + (paramBaseType, paramTypeModifiers) = GetBaseType(paramType) + + # Conversion management. + # We'll handle three cases, easiest to hardest: a parameter + # that doesn't require conversion, a scalar parameter that + # requires conversion, and a vector parameter that requires + # conversion. + if paramConvertToType == None: + # Unconverted parameters are easy, whether they're vector + # or scalar - just add them to the call list. No conversions + # or anything to worry about. + passthroughDeclarationString += ", %s %s" % (paramType, paramName) + passthroughCallString += ", %s" % paramName + + elif paramMaxVecSize == 0: # a scalar parameter that needs conversion + # A scalar to hold a converted parameter + variables.append(" %s converted_%s;" % (paramConvertToType, paramName)) + + # Outgoing conversion depends on whether we have to conditionally + # perform value conversion. + if paramValueConversion == "none": + conversionCodeOutgoing.append(" converted_%s = (%s) %s;" % (paramName, paramConvertToType, paramName)) + elif paramValueConversion == "some": + # We'll need a conditional variable to keep track of + # whether we're converting values or not. + if (" int convert_%s_value = 1;" % paramName) not in variables: + variables.append(" int convert_%s_value = 1;" % paramName) + + # Write code based on that conditional. + conversionCodeOutgoing.append(" if (convert_%s_value) {" % paramName) + conversionCodeOutgoing.append(" converted_%s = %s;" % (paramName, ConvertValue(paramName, paramBaseType, paramConvertToType))) + conversionCodeOutgoing.append(" } else {") + conversionCodeOutgoing.append(" converted_%s = (%s) %s;" % (paramName, paramConvertToType, paramName)) + conversionCodeOutgoing.append(" }") + else: # paramValueConversion == "all" + conversionCodeOutgoing.append(" converted_%s = %s;" % (paramName, ConvertValue(paramName, paramBaseType, paramConvertToType))) + + # Note that there can be no incoming conversion for a + # scalar parameter; changing the scalar will only change + # the local value, and won't ultimately change anything + # that passes back to the application. + + # Call strings. The unusual " ".join() call will join the + # array of parameter modifiers with spaces as separators. + passthroughDeclarationString += ", %s %s %s" % (paramConvertToType, " ".join(paramTypeModifiers), paramName) + passthroughCallString += ", converted_%s" % paramName + + else: # a vector parameter that needs conversion + # We'll need an index variable for conversions + if " register unsigned int i;" not in variables: + variables.append(" register unsigned int i;") + + # This variable will hold the (possibly variant) size of + # this array needing conversion. By default, we'll set + # it to the maximal size (which is correct for functions + # with a constant-sized vector parameter); for true + # variant arrays, we'll modify it with other code. + variables.append(" unsigned int n_%s = %d;" % (paramName, paramMaxVecSize)) + + # This array will hold the actual converted values. + variables.append(" %s converted_%s[%d];" % (paramConvertToType, paramName, paramMaxVecSize)) + + # Again, we choose the conversion code based on whether we + # have to always convert values, never convert values, or + # conditionally convert values. + if paramValueConversion == "none": + conversionCodeOutgoing.append(" for (i = 0; i < n_%s; i++) {" % paramName) + conversionCodeOutgoing.append(" converted_%s[i] = (%s) %s[i];" % (paramName, paramConvertToType, paramName)) + conversionCodeOutgoing.append(" }") + elif paramValueConversion == "some": + # We'll need a conditional variable to keep track of + # whether we're converting values or not. + if (" int convert_%s_value = 1;" % paramName) not in variables: + variables.append(" int convert_%s_value = 1;" % paramName) + # Write code based on that conditional. + conversionCodeOutgoing.append(" if (convert_%s_value) {" % paramName) + conversionCodeOutgoing.append(" for (i = 0; i < n_%s; i++) {" % paramName) + conversionCodeOutgoing.append(" converted_%s[i] = %s;" % (paramName, ConvertValue("%s[i]" % paramName, paramBaseType, paramConvertToType))) + conversionCodeOutgoing.append(" }") + conversionCodeOutgoing.append(" } else {") + conversionCodeOutgoing.append(" for (i = 0; i < n_%s; i++) {" % paramName) + conversionCodeOutgoing.append(" converted_%s[i] = (%s) %s[i];" % (paramName, paramConvertToType, paramName)) + conversionCodeOutgoing.append(" }") + conversionCodeOutgoing.append(" }") + else: # paramValueConversion == "all" + conversionCodeOutgoing.append(" for (i = 0; i < n_%s; i++) {" % paramName) + conversionCodeOutgoing.append(" converted_%s[i] = %s;" % (paramName, ConvertValue("%s[i]" % paramName, paramBaseType, paramConvertToType))) + + conversionCodeOutgoing.append(" }") + + # If instead we need an incoming conversion (i.e. results + # from Mesa have to be converted before handing back + # to the application), this is it. Fortunately, we don't + # have to worry about conditional value conversion - the + # functions that do (e.g. glGetFixedv()) are handled + # specially, outside this code generation. + # + # Whether we use incoming conversion or outgoing conversion + # is determined later - we only ever use one or the other. + + if paramValueConversion == "none": + conversionCodeIncoming.append(" for (i = 0; i < n_%s; i++) {" % paramName) + conversionCodeIncoming.append(" %s[i] = (%s) converted_%s[i];" % (paramName, paramConvertToType, paramName)) + conversionCodeIncoming.append(" }") + elif paramValueConversion == "some": + # We'll need a conditional variable to keep track of + # whether we're converting values or not. + if (" int convert_%s_value = 1;" % paramName) not in variables: + variables.append(" int convert_%s_value = 1;" % paramName) + + # Write code based on that conditional. + conversionCodeIncoming.append(" if (convert_%s_value) {" % paramName) + conversionCodeIncoming.append(" for (i = 0; i < n_%s; i++) {" % paramName) + conversionCodeIncoming.append(" %s[i] = %s;" % (paramName, ConvertValue("converted_%s[i]" % paramName, paramConvertToType, paramBaseType))) + conversionCodeIncoming.append(" }") + conversionCodeIncoming.append(" } else {") + conversionCodeIncoming.append(" for (i = 0; i < n_%s; i++) {" % paramName) + conversionCodeIncoming.append(" %s[i] = (%s) converted_%s[i];" % (paramName, paramBaseType, paramName)) + conversionCodeIncoming.append(" }") + conversionCodeIncoming.append(" }") + else: # paramValueConversion == "all" + conversionCodeIncoming.append(" for (i = 0; i < n_%s; i++) {" % paramName) + conversionCodeIncoming.append(" %s[i] = %s;" % (paramName, ConvertValue("converted_%s[i]" % paramName, paramConvertToType, paramBaseType))) + conversionCodeIncoming.append(" }") + + # Call strings. The unusual " ".join() call will join the + # array of parameter modifiers with spaces as separators. + passthroughDeclarationString += ", %s %s %s" % (paramConvertToType, " ".join(paramTypeModifiers), paramName) + passthroughCallString += ", converted_%s" % paramName + + # endif conversion management + + # Parameter checking. If the parameter has a specific list of + # valid values, we have to make sure that the passed-in values + # match these, or we make an error. + if len(paramValidValues) > 0: + # We're about to make a big switch statement with an + # error at the end. By default, the error is GL_INVALID_ENUM, + # unless we find a "case" statement in the middle with a + # non-GLenum value. + errorDefaultCase = "GL_INVALID_ENUM" + + # This parameter has specific valid values. Make a big + # switch statement to handle it. Note that the original + # parameters are always what is checked, not the + # converted parameters. + switchCode.append(" switch(%s) {" % paramName) + + for valueIndex in range(len(paramValidValues)): + (paramValue, dependentVecSize, dependentParamName, dependentValidValues, errorCode, valueConvert) = paramValidValues[valueIndex] + + # We're going to need information on the dependent param + # as well. + if dependentParamName: + depParamIndex = apiutil.FindParamIndex(params, dependentParamName) + if depParamIndex == None: + sys.stderr.write("%s: can't find dependent param '%s' for function '%s'\n" % (program, dependentParamName, funcName)) + + (depParamName, depParamType, depParamMaxVecSize, depParamConvertToType, depParamValidValues, depParamValueConversion) = params[depParamIndex] + else: + (depParamName, depParamType, depParamMaxVecSize, depParamConvertToType, depParamValidValues, depParamValueConversion) = (None, None, None, None, [], None) + + # This is a sneaky trick. It's valid syntax for a parameter + # that is *not* going to be converted to be declared + # with a dependent vector size; but in this case, the + # dependent vector size is unused and unnecessary. + # So check for this and ignore the dependent vector size + # if the parameter is not going to be converted. + if depParamConvertToType: + usedDependentVecSize = dependentVecSize + else: + usedDependentVecSize = None + + # We'll peek ahead at the next parameter, to see whether + # we can combine cases + if valueIndex + 1 < len(paramValidValues) : + (nextParamValue, nextDependentVecSize, nextDependentParamName, nextDependentValidValues, nextErrorCode, nextValueConvert) = paramValidValues[valueIndex + 1] + if depParamConvertToType: + usedNextDependentVecSize = nextDependentVecSize + else: + usedNextDependentVecSize = None + + # Create a case for this value. As a mnemonic, + # if we have a dependent vector size that we're ignoring, + # add it as a comment. + if usedDependentVecSize == None and dependentVecSize != None: + switchCode.append(" case %s: /* size %s */" % (paramValue, dependentVecSize)) + else: + switchCode.append(" case %s:" % paramValue) + + # If this is not a GLenum case, then switch our error + # if no value is matched to be GL_INVALID_VALUE instead + # of GL_INVALID_ENUM. (Yes, this does get confused + # if there are both values and GLenums in the same + # switch statement, which shouldn't happen.) + if paramValue[0:3] != "GL_": + errorDefaultCase = "GL_INVALID_VALUE" + + # If all the remaining parameters are identical to the + # next set, then we're done - we'll just create the + # official code on the next pass through, and the two + # cases will share the code. + if valueIndex + 1 < len(paramValidValues) and usedDependentVecSize == usedNextDependentVecSize and dependentParamName == nextDependentParamName and dependentValidValues == nextDependentValidValues and errorCode == nextErrorCode and valueConvert == nextValueConvert: + continue + + # Otherwise, we'll have to generate code for this case. + # Start off with a check: if there is a dependent parameter, + # and a list of valid values for that parameter, we need + # to generate an error if something other than one + # of those values is passed. + if len(dependentValidValues) > 0: + conditional="" + + # If the parameter being checked is actually an array, + # check only its first element. + if depParamMaxVecSize == 0: + valueToCheck = dependentParamName + else: + valueToCheck = "%s[0]" % dependentParamName + + for v in dependentValidValues: + conditional += " && %s != %s" % (valueToCheck, v) + switchCode.append(" if (%s) {" % conditional[4:]) + if errorCode == None: + errorCode = "GL_INVALID_ENUM" + switchCode.append(' _mesa_error(_mesa_get_current_context(), %s, "gl%s(%s=0x%s)", %s);' % (errorCode, funcName, paramName, "%x", paramName)) + switchCode.append(" %s;" % errorReturn) + switchCode.append(" }") + # endif there are dependent valid values + + # The dependent parameter may require conditional + # value conversion. If it does, and we don't want + # to convert values, we'll have to generate code for that + if depParamValueConversion == "some" and valueConvert == "noconvert": + switchCode.append(" convert_%s_value = 0;" % dependentParamName) + + # If there's a dependent vector size for this parameter + # that we're actually going to use (i.e. we need conversion), + # mark it. + if usedDependentVecSize: + switchCode.append(" n_%s = %s;" % (dependentParamName, dependentVecSize)) + + # In all cases, break out of the switch if any valid + # value is found. + switchCode.append(" break;") + + + # Need a default case to catch all the other, invalid + # parameter values. These will all generate errors. + switchCode.append(" default:") + if errorCode == None: + errorCode = "GL_INVALID_ENUM" + formatString = GetFormatString(paramType) + if formatString == None: + switchCode.append(' _mesa_error(_mesa_get_current_context(), %s, "gl%s(%s)");' % (errorCode, funcName, paramName)) + else: + switchCode.append(' _mesa_error(_mesa_get_current_context(), %s, "gl%s(%s=%s)", %s);' % (errorCode, funcName, paramName, formatString, paramName)) + switchCode.append(" %s;" % errorReturn) + + # End of our switch code. + switchCode.append(" }") + + # endfor every recognized parameter value + + # endfor every param + + # Here, the passthroughDeclarationString and passthroughCallString + # are complete; remove the extra ", " at the front of each. + passthroughDeclarationString = passthroughDeclarationString[2:] + passthroughCallString = passthroughCallString[2:] + if not passthroughDeclarationString: + passthroughDeclarationString = "void" + + # The Mesa functions are scattered across all the Mesa + # header files. The easiest way to manage declarations + # is to create them ourselves. + if funcName in allSpecials: + print "/* this function is special and is defined elsewhere */" + print "extern %s GL_APIENTRY %s(%s);" % (returnType, passthroughFuncName, passthroughDeclarationString) + + # A function may be a core function (i.e. it exists in + # the core specification), a core addition (extension + # functions added officially to the core), a required + # extension (usually an extension for an earlier version + # that has been officially adopted), or an optional extension. + # + # Core functions have a simple category (e.g. "GLES1.1"); + # we generate only a simple callback for them. + # + # Core additions have two category listings, one simple + # and one compound (e.g. ["GLES1.1", "GLES1.1:OES_fixed_point"]). + # We generate the core function, and also an extension function. + # + # Required extensions and implemented optional extensions + # have a single compound category "GLES1.1:OES_point_size_array". + # For these we generate just the extension function. + for categorySpec in apiutil.Categories(funcName): + compoundCategory = categorySpec.split(":") + + # This category isn't for us, if the base category doesn't match + # our version + if compoundCategory[0] != version: + continue + + # Otherwise, determine if we're writing code for a core + # function (no suffix) or an extension function. + if len(compoundCategory) == 1: + # This is a core function + extensionName = None + extensionSuffix = "" + else: + # This is an extension function. We'll need to append + # the extension suffix. + extensionName = compoundCategory[1] + extensionSuffix = extensionName.split("_")[0] + fullFuncName = funcPrefix + funcName + extensionSuffix + + # Now the generated function. The text used to mark an API-level + # function, oddly, is version-specific. + if extensionName: + print "/* Extension %s */" % extensionName + + if (not variables and + not switchCode and + not conversionCodeOutgoing and + not conversionCodeIncoming): + # pass through directly + print "#define %s %s" % (fullFuncName, passthroughFuncName) + print + continue + + print "static %s GL_APIENTRY %s(%s)" % (returnType, fullFuncName, declarationString) + print "{" + + # Start printing our code pieces. Start with any local + # variables we need. This unusual syntax joins the + # lines in the variables[] array with the "\n" separator. + if len(variables) > 0: + print "\n".join(variables) + "\n" + + # If there's any sort of parameter checking or variable + # array sizing, the switch code will contain it. + if len(switchCode) > 0: + print "\n".join(switchCode) + "\n" + + # In the case of an outgoing conversion (i.e. parameters must + # be converted before calling the underlying Mesa function), + # use the appropriate code. + if "get" not in props and len(conversionCodeOutgoing) > 0: + print "\n".join(conversionCodeOutgoing) + "\n" + + # Call the Mesa function. Note that there are very few functions + # that return a value (i.e. returnType is not "void"), and that + # none of them require incoming translation; so we're safe + # to generate code that directly returns in those cases, + # even though it's not completely independent. + + if returnType == "void": + print " %s(%s);" % (passthroughFuncName, passthroughCallString) + else: + print " return %s(%s);" % (passthroughFuncName, passthroughCallString) + + # If the function is one that returns values (i.e. "get" in props), + # it might return values of a different type than we need, that + # require conversion before passing back to the application. + if "get" in props and len(conversionCodeIncoming) > 0: + print "\n".join(conversionCodeIncoming) + + # All done. + print "}" + print + # end for each category provided for a function + +# end for each function + +print """ +#include "glapi/glapi.h" + +#if FEATURE_remap_table + +/* define esLocalRemapTable */ +#include "main/api_exec_%s_dispatch.h" + +#define need_MESA_remap_table +#include "main/api_exec_%s_remap_helper.h" + +static void +init_remap_table(void) +{ + _glthread_DECLARE_STATIC_MUTEX(mutex); + static GLboolean initialized = GL_FALSE; + const struct gl_function_pool_remap *remap = MESA_remap_table_functions; + int i; + + _glthread_LOCK_MUTEX(mutex); + if (initialized) { + _glthread_UNLOCK_MUTEX(mutex); + return; + } + + for (i = 0; i < esLocalRemapTable_size; i++) { + GLint offset; + const char *spec; + + /* sanity check */ + ASSERT(i == remap[i].remap_index); + spec = _mesa_function_pool + remap[i].pool_index; + + offset = _mesa_map_function_spec(spec); + esLocalRemapTable[i] = offset; + } + initialized = GL_TRUE; + _glthread_UNLOCK_MUTEX(mutex); +} + +#else /* FEATURE_remap_table */ + +#include "%sapi/main/dispatch.h" + +static INLINE void +init_remap_table(void) +{ +} + +#endif /* FEATURE_remap_table */ + +struct _glapi_table * +_mesa_create_exec_table_%s(void) +{ + struct _glapi_table *exec; + + exec = _mesa_alloc_dispatch_table(_gloffset_COUNT); + if (exec == NULL) + return NULL; + + init_remap_table(); +""" % (shortname, shortname, shortname, shortname) + +for func in keys: + prefix = "_es_" if func not in allSpecials else "_check_" + for spec in apiutil.Categories(func): + ext = spec.split(":") + # version does not match + if ext.pop(0) != version: + continue + entry = func + if ext: + suffix = ext[0].split("_")[0] + entry += suffix + print " SET_%s(exec, %s%s);" % (entry, prefix, entry) +print "" +print " return exec;" +print "}" + +print """ +#endif /* FEATURE_%s */""" % (shortname.upper()) diff --git a/mesalib/src/mesa/main/eval.c b/mesalib/src/mesa/main/eval.c index 2deaddc19..e651715f7 100644 --- a/mesalib/src/mesa/main/eval.c +++ b/mesalib/src/mesa/main/eval.c @@ -1,1091 +1,1091 @@ - -/* - * Mesa 3-D graphics library - * Version: 5.1 - * - * Copyright (C) 1999-2003 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. - */ - - -/* - * eval.c was written by - * Bernd Barsuhn (bdbarsuh@cip.informatik.uni-erlangen.de) and - * Volker Weiss (vrweiss@cip.informatik.uni-erlangen.de). - * - * My original implementation of evaluators was simplistic and didn't - * compute surface normal vectors properly. Bernd and Volker applied - * used more sophisticated methods to get better results. - * - * Thanks guys! - */ - - -#include "glheader.h" -#include "imports.h" -#include "colormac.h" -#include "context.h" -#include "eval.h" -#include "macros.h" -#include "mfeatures.h" -#include "mtypes.h" -#include "main/dispatch.h" - - -#if FEATURE_evaluators - - -/* - * Return the number of components per control point for any type of - * evaluator. Return 0 if bad target. - * See table 5.1 in the OpenGL 1.2 spec. - */ -GLuint _mesa_evaluator_components( GLenum target ) -{ - switch (target) { - case GL_MAP1_VERTEX_3: return 3; - case GL_MAP1_VERTEX_4: return 4; - case GL_MAP1_INDEX: return 1; - case GL_MAP1_COLOR_4: return 4; - case GL_MAP1_NORMAL: return 3; - case GL_MAP1_TEXTURE_COORD_1: return 1; - case GL_MAP1_TEXTURE_COORD_2: return 2; - case GL_MAP1_TEXTURE_COORD_3: return 3; - case GL_MAP1_TEXTURE_COORD_4: return 4; - case GL_MAP2_VERTEX_3: return 3; - case GL_MAP2_VERTEX_4: return 4; - case GL_MAP2_INDEX: return 1; - case GL_MAP2_COLOR_4: return 4; - case GL_MAP2_NORMAL: return 3; - case GL_MAP2_TEXTURE_COORD_1: return 1; - case GL_MAP2_TEXTURE_COORD_2: return 2; - case GL_MAP2_TEXTURE_COORD_3: return 3; - case GL_MAP2_TEXTURE_COORD_4: return 4; - default: break; - } - - /* XXX need to check for the vertex program extension - if (!ctx->Extensions.NV_vertex_program) - return 0; - */ - - if (target >= GL_MAP1_VERTEX_ATTRIB0_4_NV && - target <= GL_MAP1_VERTEX_ATTRIB15_4_NV) - return 4; - - if (target >= GL_MAP2_VERTEX_ATTRIB0_4_NV && - target <= GL_MAP2_VERTEX_ATTRIB15_4_NV) - return 4; - - return 0; -} - - -/* - * Return pointer to the gl_1d_map struct for the named target. - */ -static struct gl_1d_map * -get_1d_map( struct gl_context *ctx, GLenum target ) -{ - switch (target) { - case GL_MAP1_VERTEX_3: - return &ctx->EvalMap.Map1Vertex3; - case GL_MAP1_VERTEX_4: - return &ctx->EvalMap.Map1Vertex4; - case GL_MAP1_INDEX: - return &ctx->EvalMap.Map1Index; - case GL_MAP1_COLOR_4: - return &ctx->EvalMap.Map1Color4; - case GL_MAP1_NORMAL: - return &ctx->EvalMap.Map1Normal; - case GL_MAP1_TEXTURE_COORD_1: - return &ctx->EvalMap.Map1Texture1; - case GL_MAP1_TEXTURE_COORD_2: - return &ctx->EvalMap.Map1Texture2; - case GL_MAP1_TEXTURE_COORD_3: - return &ctx->EvalMap.Map1Texture3; - case GL_MAP1_TEXTURE_COORD_4: - return &ctx->EvalMap.Map1Texture4; - case GL_MAP1_VERTEX_ATTRIB0_4_NV: - case GL_MAP1_VERTEX_ATTRIB1_4_NV: - case GL_MAP1_VERTEX_ATTRIB2_4_NV: - case GL_MAP1_VERTEX_ATTRIB3_4_NV: - case GL_MAP1_VERTEX_ATTRIB4_4_NV: - case GL_MAP1_VERTEX_ATTRIB5_4_NV: - case GL_MAP1_VERTEX_ATTRIB6_4_NV: - case GL_MAP1_VERTEX_ATTRIB7_4_NV: - case GL_MAP1_VERTEX_ATTRIB8_4_NV: - case GL_MAP1_VERTEX_ATTRIB9_4_NV: - case GL_MAP1_VERTEX_ATTRIB10_4_NV: - case GL_MAP1_VERTEX_ATTRIB11_4_NV: - case GL_MAP1_VERTEX_ATTRIB12_4_NV: - case GL_MAP1_VERTEX_ATTRIB13_4_NV: - case GL_MAP1_VERTEX_ATTRIB14_4_NV: - case GL_MAP1_VERTEX_ATTRIB15_4_NV: - if (!ctx->Extensions.NV_vertex_program) - return NULL; - return &ctx->EvalMap.Map1Attrib[target - GL_MAP1_VERTEX_ATTRIB0_4_NV]; - default: - return NULL; - } -} - - -/* - * Return pointer to the gl_2d_map struct for the named target. - */ -static struct gl_2d_map * -get_2d_map( struct gl_context *ctx, GLenum target ) -{ - switch (target) { - case GL_MAP2_VERTEX_3: - return &ctx->EvalMap.Map2Vertex3; - case GL_MAP2_VERTEX_4: - return &ctx->EvalMap.Map2Vertex4; - case GL_MAP2_INDEX: - return &ctx->EvalMap.Map2Index; - case GL_MAP2_COLOR_4: - return &ctx->EvalMap.Map2Color4; - case GL_MAP2_NORMAL: - return &ctx->EvalMap.Map2Normal; - case GL_MAP2_TEXTURE_COORD_1: - return &ctx->EvalMap.Map2Texture1; - case GL_MAP2_TEXTURE_COORD_2: - return &ctx->EvalMap.Map2Texture2; - case GL_MAP2_TEXTURE_COORD_3: - return &ctx->EvalMap.Map2Texture3; - case GL_MAP2_TEXTURE_COORD_4: - return &ctx->EvalMap.Map2Texture4; - case GL_MAP2_VERTEX_ATTRIB0_4_NV: - case GL_MAP2_VERTEX_ATTRIB1_4_NV: - case GL_MAP2_VERTEX_ATTRIB2_4_NV: - case GL_MAP2_VERTEX_ATTRIB3_4_NV: - case GL_MAP2_VERTEX_ATTRIB4_4_NV: - case GL_MAP2_VERTEX_ATTRIB5_4_NV: - case GL_MAP2_VERTEX_ATTRIB6_4_NV: - case GL_MAP2_VERTEX_ATTRIB7_4_NV: - case GL_MAP2_VERTEX_ATTRIB8_4_NV: - case GL_MAP2_VERTEX_ATTRIB9_4_NV: - case GL_MAP2_VERTEX_ATTRIB10_4_NV: - case GL_MAP2_VERTEX_ATTRIB11_4_NV: - case GL_MAP2_VERTEX_ATTRIB12_4_NV: - case GL_MAP2_VERTEX_ATTRIB13_4_NV: - case GL_MAP2_VERTEX_ATTRIB14_4_NV: - case GL_MAP2_VERTEX_ATTRIB15_4_NV: - if (!ctx->Extensions.NV_vertex_program) - return NULL; - return &ctx->EvalMap.Map2Attrib[target - GL_MAP2_VERTEX_ATTRIB0_4_NV]; - default: - return NULL; - } -} - - -/**********************************************************************/ -/*** Copy and deallocate control points ***/ -/**********************************************************************/ - - -/* - * Copy 1-parametric evaluator control points from user-specified - * memory space to a buffer of contiguous control points. - * \param see glMap1f for details - * \return pointer to buffer of contiguous control points or NULL if out - * of memory. - */ -GLfloat *_mesa_copy_map_points1f( GLenum target, GLint ustride, GLint uorder, - const GLfloat *points ) -{ - GLfloat *buffer, *p; - GLint i, k, size = _mesa_evaluator_components(target); - - if (!points || !size) - return NULL; - - buffer = (GLfloat *) MALLOC(uorder * size * sizeof(GLfloat)); - - if (buffer) - for (i = 0, p = buffer; i < uorder; i++, points += ustride) - for (k = 0; k < size; k++) - *p++ = points[k]; - - return buffer; -} - - - -/* - * Same as above but convert doubles to floats. - */ -GLfloat *_mesa_copy_map_points1d( GLenum target, GLint ustride, GLint uorder, - const GLdouble *points ) -{ - GLfloat *buffer, *p; - GLint i, k, size = _mesa_evaluator_components(target); - - if (!points || !size) - return NULL; - - buffer = (GLfloat *) MALLOC(uorder * size * sizeof(GLfloat)); - - if (buffer) - for (i = 0, p = buffer; i < uorder; i++, points += ustride) - for (k = 0; k < size; k++) - *p++ = (GLfloat) points[k]; - - return buffer; -} - - - -/* - * Copy 2-parametric evaluator control points from user-specified - * memory space to a buffer of contiguous control points. - * Additional memory is allocated to be used by the horner and - * de Casteljau evaluation schemes. - * - * \param see glMap2f for details - * \return pointer to buffer of contiguous control points or NULL if out - * of memory. - */ -GLfloat *_mesa_copy_map_points2f( GLenum target, - GLint ustride, GLint uorder, - GLint vstride, GLint vorder, - const GLfloat *points ) -{ - GLfloat *buffer, *p; - GLint i, j, k, size, dsize, hsize; - GLint uinc; - - size = _mesa_evaluator_components(target); - - if (!points || size==0) { - return NULL; - } - - /* max(uorder, vorder) additional points are used in */ - /* horner evaluation and uorder*vorder additional */ - /* values are needed for de Casteljau */ - dsize = (uorder == 2 && vorder == 2)? 0 : uorder*vorder; - hsize = (uorder > vorder ? uorder : vorder)*size; - - if(hsize>dsize) - buffer = (GLfloat *) MALLOC((uorder*vorder*size+hsize)*sizeof(GLfloat)); - else - buffer = (GLfloat *) MALLOC((uorder*vorder*size+dsize)*sizeof(GLfloat)); - - /* compute the increment value for the u-loop */ - uinc = ustride - vorder*vstride; - - if (buffer) - for (i=0, p=buffer; i vorder ? uorder : vorder)*size; - - if(hsize>dsize) - buffer = (GLfloat *) MALLOC((uorder*vorder*size+hsize)*sizeof(GLfloat)); - else - buffer = (GLfloat *) MALLOC((uorder*vorder*size+dsize)*sizeof(GLfloat)); - - /* compute the increment value for the u-loop */ - uinc = ustride - vorder*vstride; - - if (buffer) - for (i=0, p=buffer; i MAX_EVAL_ORDER) { - _mesa_error( ctx, GL_INVALID_VALUE, "glMap1(order)" ); - return; - } - if (!points) { - _mesa_error( ctx, GL_INVALID_VALUE, "glMap1(points)" ); - return; - } - - k = _mesa_evaluator_components( target ); - if (k == 0) { - _mesa_error( ctx, GL_INVALID_ENUM, "glMap1(target)" ); - } - - if (ustride < k) { - _mesa_error( ctx, GL_INVALID_VALUE, "glMap1(stride)" ); - return; - } - - if (ctx->Texture.CurrentUnit != 0) { - /* See OpenGL 1.2.1 spec, section F.2.13 */ - _mesa_error( ctx, GL_INVALID_OPERATION, "glMap2(ACTIVE_TEXTURE != 0)" ); - return; - } - - map = get_1d_map(ctx, target); - if (!map) { - _mesa_error( ctx, GL_INVALID_ENUM, "glMap1(target)" ); - return; - } - - /* make copy of the control points */ - if (type == GL_FLOAT) - pnts = _mesa_copy_map_points1f(target, ustride, uorder, (GLfloat*) points); - else - pnts = _mesa_copy_map_points1d(target, ustride, uorder, (GLdouble*) points); - - - FLUSH_VERTICES(ctx, _NEW_EVAL); - map->Order = uorder; - map->u1 = u1; - map->u2 = u2; - map->du = 1.0F / (u2 - u1); - if (map->Points) - FREE( map->Points ); - map->Points = pnts; -} - - - -static void GLAPIENTRY -_mesa_Map1f( GLenum target, GLfloat u1, GLfloat u2, GLint stride, - GLint order, const GLfloat *points ) -{ - map1(target, u1, u2, stride, order, points, GL_FLOAT); -} - - -static void GLAPIENTRY -_mesa_Map1d( GLenum target, GLdouble u1, GLdouble u2, GLint stride, - GLint order, const GLdouble *points ) -{ - map1(target, (GLfloat) u1, (GLfloat) u2, stride, order, points, GL_DOUBLE); -} - - -static void -map2( GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, - GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, - const GLvoid *points, GLenum type ) -{ - GET_CURRENT_CONTEXT(ctx); - GLint k; - GLfloat *pnts; - struct gl_2d_map *map = NULL; - - ASSERT_OUTSIDE_BEGIN_END(ctx); - ASSERT(type == GL_FLOAT || type == GL_DOUBLE); - - if (u1==u2) { - _mesa_error( ctx, GL_INVALID_VALUE, "glMap2(u1,u2)" ); - return; - } - - if (v1==v2) { - _mesa_error( ctx, GL_INVALID_VALUE, "glMap2(v1,v2)" ); - return; - } - - if (uorder<1 || uorder>MAX_EVAL_ORDER) { - _mesa_error( ctx, GL_INVALID_VALUE, "glMap2(uorder)" ); - return; - } - - if (vorder<1 || vorder>MAX_EVAL_ORDER) { - _mesa_error( ctx, GL_INVALID_VALUE, "glMap2(vorder)" ); - return; - } - - k = _mesa_evaluator_components( target ); - if (k==0) { - _mesa_error( ctx, GL_INVALID_ENUM, "glMap2(target)" ); - } - - if (ustride < k) { - _mesa_error( ctx, GL_INVALID_VALUE, "glMap2(ustride)" ); - return; - } - if (vstride < k) { - _mesa_error( ctx, GL_INVALID_VALUE, "glMap2(vstride)" ); - return; - } - - if (ctx->Texture.CurrentUnit != 0) { - /* See OpenGL 1.2.1 spec, section F.2.13 */ - _mesa_error( ctx, GL_INVALID_OPERATION, "glMap2(ACTIVE_TEXTURE != 0)" ); - return; - } - - map = get_2d_map(ctx, target); - if (!map) { - _mesa_error( ctx, GL_INVALID_ENUM, "glMap2(target)" ); - return; - } - - /* make copy of the control points */ - if (type == GL_FLOAT) - pnts = _mesa_copy_map_points2f(target, ustride, uorder, - vstride, vorder, (GLfloat*) points); - else - pnts = _mesa_copy_map_points2d(target, ustride, uorder, - vstride, vorder, (GLdouble*) points); - - - FLUSH_VERTICES(ctx, _NEW_EVAL); - map->Uorder = uorder; - map->u1 = u1; - map->u2 = u2; - map->du = 1.0F / (u2 - u1); - map->Vorder = vorder; - map->v1 = v1; - map->v2 = v2; - map->dv = 1.0F / (v2 - v1); - if (map->Points) - FREE( map->Points ); - map->Points = pnts; -} - - -static void GLAPIENTRY -_mesa_Map2f( GLenum target, - GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, - GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, - const GLfloat *points) -{ - map2(target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, - points, GL_FLOAT); -} - - -static void GLAPIENTRY -_mesa_Map2d( GLenum target, - GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, - GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, - const GLdouble *points ) -{ - map2(target, (GLfloat) u1, (GLfloat) u2, ustride, uorder, - (GLfloat) v1, (GLfloat) v2, vstride, vorder, points, GL_DOUBLE); -} - - - -static void GLAPIENTRY -_mesa_GetnMapdvARB( GLenum target, GLenum query, GLsizei bufSize, GLdouble *v ) -{ - GET_CURRENT_CONTEXT(ctx); - struct gl_1d_map *map1d; - struct gl_2d_map *map2d; - GLint i, n; - GLfloat *data; - GLuint comps; - GLsizei numBytes; - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - comps = _mesa_evaluator_components(target); - if (!comps) { - _mesa_error( ctx, GL_INVALID_ENUM, "glGetMapdv(target)" ); - return; - } - - map1d = get_1d_map(ctx, target); - map2d = get_2d_map(ctx, target); - ASSERT(map1d || map2d); - - switch (query) { - case GL_COEFF: - if (map1d) { - data = map1d->Points; - n = map1d->Order * comps; - } - else { - data = map2d->Points; - n = map2d->Uorder * map2d->Vorder * comps; - } - if (data) { - numBytes = n * sizeof *v; - if (bufSize < numBytes) - goto overflow; - for (i=0;iOrder; - } - else { - numBytes = 2 * sizeof *v; - if (bufSize < numBytes) - goto overflow; - v[0] = (GLdouble) map2d->Uorder; - v[1] = (GLdouble) map2d->Vorder; - } - break; - case GL_DOMAIN: - if (map1d) { - numBytes = 2 * sizeof *v; - if (bufSize < numBytes) - goto overflow; - v[0] = (GLdouble) map1d->u1; - v[1] = (GLdouble) map1d->u2; - } - else { - numBytes = 4 * sizeof *v; - if (bufSize < numBytes) - goto overflow; - v[0] = (GLdouble) map2d->u1; - v[1] = (GLdouble) map2d->u2; - v[2] = (GLdouble) map2d->v1; - v[3] = (GLdouble) map2d->v2; - } - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glGetMapdv(query)" ); - } - return; - -overflow: - _mesa_error( ctx, GL_INVALID_OPERATION, - "glGetnMapdvARB(out of bounds: bufSize is %d," - " but %d bytes are required)", bufSize, numBytes ); -} - -static void GLAPIENTRY -_mesa_GetMapdv( GLenum target, GLenum query, GLdouble *v ) -{ - _mesa_GetnMapdvARB(target, query, INT_MAX, v); -} - -static void GLAPIENTRY -_mesa_GetnMapfvARB( GLenum target, GLenum query, GLsizei bufSize, GLfloat *v ) -{ - GET_CURRENT_CONTEXT(ctx); - struct gl_1d_map *map1d; - struct gl_2d_map *map2d; - GLint i, n; - GLfloat *data; - GLuint comps; - GLsizei numBytes; - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - comps = _mesa_evaluator_components(target); - if (!comps) { - _mesa_error( ctx, GL_INVALID_ENUM, "glGetMapfv(target)" ); - return; - } - - map1d = get_1d_map(ctx, target); - map2d = get_2d_map(ctx, target); - ASSERT(map1d || map2d); - - switch (query) { - case GL_COEFF: - if (map1d) { - data = map1d->Points; - n = map1d->Order * comps; - } - else { - data = map2d->Points; - n = map2d->Uorder * map2d->Vorder * comps; - } - if (data) { - numBytes = n * sizeof *v; - if (bufSize < numBytes) - goto overflow; - for (i=0;iOrder; - } - else { - numBytes = 2 * sizeof *v; - if (bufSize < numBytes) - goto overflow; - v[0] = (GLfloat) map2d->Uorder; - v[1] = (GLfloat) map2d->Vorder; - } - break; - case GL_DOMAIN: - if (map1d) { - numBytes = 2 * sizeof *v; - if (bufSize < numBytes) - goto overflow; - v[0] = map1d->u1; - v[1] = map1d->u2; - } - else { - numBytes = 4 * sizeof *v; - if (bufSize < numBytes) - goto overflow; - v[0] = map2d->u1; - v[1] = map2d->u2; - v[2] = map2d->v1; - v[3] = map2d->v2; - } - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glGetMapfv(query)" ); - } - return; - -overflow: - _mesa_error( ctx, GL_INVALID_OPERATION, - "glGetnMapfvARB(out of bounds: bufSize is %d," - " but %d bytes are required)", bufSize, numBytes ); -} - - -static void GLAPIENTRY -_mesa_GetMapfv( GLenum target, GLenum query, GLfloat *v ) -{ - _mesa_GetnMapfvARB(target, query, INT_MAX, v); -} - - -static void GLAPIENTRY -_mesa_GetnMapivARB( GLenum target, GLenum query, GLsizei bufSize, GLint *v ) -{ - GET_CURRENT_CONTEXT(ctx); - struct gl_1d_map *map1d; - struct gl_2d_map *map2d; - GLuint i, n; - GLfloat *data; - GLuint comps; - GLsizei numBytes; - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - comps = _mesa_evaluator_components(target); - if (!comps) { - _mesa_error( ctx, GL_INVALID_ENUM, "glGetMapiv(target)" ); - return; - } - - map1d = get_1d_map(ctx, target); - map2d = get_2d_map(ctx, target); - ASSERT(map1d || map2d); - - switch (query) { - case GL_COEFF: - if (map1d) { - data = map1d->Points; - n = map1d->Order * comps; - } - else { - data = map2d->Points; - n = map2d->Uorder * map2d->Vorder * comps; - } - if (data) { - numBytes = n * sizeof *v; - if (bufSize < numBytes) - goto overflow; - for (i=0;iOrder; - } - else { - numBytes = 2 * sizeof *v; - if (bufSize < numBytes) - goto overflow; - v[0] = map2d->Uorder; - v[1] = map2d->Vorder; - } - break; - case GL_DOMAIN: - if (map1d) { - numBytes = 2 * sizeof *v; - if (bufSize < numBytes) - goto overflow; - v[0] = IROUND(map1d->u1); - v[1] = IROUND(map1d->u2); - } - else { - numBytes = 4 * sizeof *v; - if (bufSize < numBytes) - goto overflow; - v[0] = IROUND(map2d->u1); - v[1] = IROUND(map2d->u2); - v[2] = IROUND(map2d->v1); - v[3] = IROUND(map2d->v2); - } - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glGetMapiv(query)" ); - } - return; - -overflow: - _mesa_error( ctx, GL_INVALID_OPERATION, - "glGetnMapivARB(out of bounds: bufSize is %d," - " but %d bytes are required)", bufSize, numBytes ); -} - - -static void GLAPIENTRY -_mesa_GetMapiv( GLenum target, GLenum query, GLint *v ) -{ - _mesa_GetnMapivARB(target, query, INT_MAX, v); -} - - -static void GLAPIENTRY -_mesa_MapGrid1f( GLint un, GLfloat u1, GLfloat u2 ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (un<1) { - _mesa_error( ctx, GL_INVALID_VALUE, "glMapGrid1f" ); - return; - } - FLUSH_VERTICES(ctx, _NEW_EVAL); - ctx->Eval.MapGrid1un = un; - ctx->Eval.MapGrid1u1 = u1; - ctx->Eval.MapGrid1u2 = u2; - ctx->Eval.MapGrid1du = (u2 - u1) / (GLfloat) un; -} - - -static void GLAPIENTRY -_mesa_MapGrid1d( GLint un, GLdouble u1, GLdouble u2 ) -{ - _mesa_MapGrid1f( un, (GLfloat) u1, (GLfloat) u2 ); -} - - -static void GLAPIENTRY -_mesa_MapGrid2f( GLint un, GLfloat u1, GLfloat u2, - GLint vn, GLfloat v1, GLfloat v2 ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (un<1) { - _mesa_error( ctx, GL_INVALID_VALUE, "glMapGrid2f(un)" ); - return; - } - if (vn<1) { - _mesa_error( ctx, GL_INVALID_VALUE, "glMapGrid2f(vn)" ); - return; - } - - FLUSH_VERTICES(ctx, _NEW_EVAL); - ctx->Eval.MapGrid2un = un; - ctx->Eval.MapGrid2u1 = u1; - ctx->Eval.MapGrid2u2 = u2; - ctx->Eval.MapGrid2du = (u2 - u1) / (GLfloat) un; - ctx->Eval.MapGrid2vn = vn; - ctx->Eval.MapGrid2v1 = v1; - ctx->Eval.MapGrid2v2 = v2; - ctx->Eval.MapGrid2dv = (v2 - v1) / (GLfloat) vn; -} - - -static void GLAPIENTRY -_mesa_MapGrid2d( GLint un, GLdouble u1, GLdouble u2, - GLint vn, GLdouble v1, GLdouble v2 ) -{ - _mesa_MapGrid2f( un, (GLfloat) u1, (GLfloat) u2, - vn, (GLfloat) v1, (GLfloat) v2 ); -} - - -void -_mesa_install_eval_vtxfmt(struct _glapi_table *disp, - const GLvertexformat *vfmt) -{ - SET_EvalCoord1f(disp, vfmt->EvalCoord1f); - SET_EvalCoord1fv(disp, vfmt->EvalCoord1fv); - SET_EvalCoord2f(disp, vfmt->EvalCoord2f); - SET_EvalCoord2fv(disp, vfmt->EvalCoord2fv); - SET_EvalPoint1(disp, vfmt->EvalPoint1); - SET_EvalPoint2(disp, vfmt->EvalPoint2); - - SET_EvalMesh1(disp, vfmt->EvalMesh1); - SET_EvalMesh2(disp, vfmt->EvalMesh2); -} - - -void -_mesa_init_eval_dispatch(struct _glapi_table *disp) -{ - SET_GetMapdv(disp, _mesa_GetMapdv); - SET_GetMapfv(disp, _mesa_GetMapfv); - SET_GetMapiv(disp, _mesa_GetMapiv); - SET_Map1d(disp, _mesa_Map1d); - SET_Map1f(disp, _mesa_Map1f); - SET_Map2d(disp, _mesa_Map2d); - SET_Map2f(disp, _mesa_Map2f); - SET_MapGrid1d(disp, _mesa_MapGrid1d); - SET_MapGrid1f(disp, _mesa_MapGrid1f); - SET_MapGrid2d(disp, _mesa_MapGrid2d); - SET_MapGrid2f(disp, _mesa_MapGrid2f); - - /* GL_ARB_robustness */ - SET_GetnMapdvARB(disp, _mesa_GetnMapdvARB); - SET_GetnMapfvARB(disp, _mesa_GetnMapfvARB); - SET_GetnMapivARB(disp, _mesa_GetnMapivARB); -} - - -#endif /* FEATURE_evaluators */ - - -/**********************************************************************/ -/***** Initialization *****/ -/**********************************************************************/ - -/** - * Initialize a 1-D evaluator map. - */ -static void -init_1d_map( struct gl_1d_map *map, int n, const float *initial ) -{ - map->Order = 1; - map->u1 = 0.0; - map->u2 = 1.0; - map->Points = (GLfloat *) MALLOC(n * sizeof(GLfloat)); - if (map->Points) { - GLint i; - for (i=0;iPoints[i] = initial[i]; - } -} - - -/** - * Initialize a 2-D evaluator map - */ -static void -init_2d_map( struct gl_2d_map *map, int n, const float *initial ) -{ - map->Uorder = 1; - map->Vorder = 1; - map->u1 = 0.0; - map->u2 = 1.0; - map->v1 = 0.0; - map->v2 = 1.0; - map->Points = (GLfloat *) MALLOC(n * sizeof(GLfloat)); - if (map->Points) { - GLint i; - for (i=0;iPoints[i] = initial[i]; - } -} - - -void _mesa_init_eval( struct gl_context *ctx ) -{ - int i; - - /* Evaluators group */ - ctx->Eval.Map1Color4 = GL_FALSE; - ctx->Eval.Map1Index = GL_FALSE; - ctx->Eval.Map1Normal = GL_FALSE; - ctx->Eval.Map1TextureCoord1 = GL_FALSE; - ctx->Eval.Map1TextureCoord2 = GL_FALSE; - ctx->Eval.Map1TextureCoord3 = GL_FALSE; - ctx->Eval.Map1TextureCoord4 = GL_FALSE; - ctx->Eval.Map1Vertex3 = GL_FALSE; - ctx->Eval.Map1Vertex4 = GL_FALSE; - memset(ctx->Eval.Map1Attrib, 0, sizeof(ctx->Eval.Map1Attrib)); - ctx->Eval.Map2Color4 = GL_FALSE; - ctx->Eval.Map2Index = GL_FALSE; - ctx->Eval.Map2Normal = GL_FALSE; - ctx->Eval.Map2TextureCoord1 = GL_FALSE; - ctx->Eval.Map2TextureCoord2 = GL_FALSE; - ctx->Eval.Map2TextureCoord3 = GL_FALSE; - ctx->Eval.Map2TextureCoord4 = GL_FALSE; - ctx->Eval.Map2Vertex3 = GL_FALSE; - ctx->Eval.Map2Vertex4 = GL_FALSE; - memset(ctx->Eval.Map2Attrib, 0, sizeof(ctx->Eval.Map2Attrib)); - ctx->Eval.AutoNormal = GL_FALSE; - ctx->Eval.MapGrid1un = 1; - ctx->Eval.MapGrid1u1 = 0.0; - ctx->Eval.MapGrid1u2 = 1.0; - ctx->Eval.MapGrid2un = 1; - ctx->Eval.MapGrid2vn = 1; - ctx->Eval.MapGrid2u1 = 0.0; - ctx->Eval.MapGrid2u2 = 1.0; - ctx->Eval.MapGrid2v1 = 0.0; - ctx->Eval.MapGrid2v2 = 1.0; - - /* Evaluator data */ - { - static GLfloat vertex[4] = { 0.0, 0.0, 0.0, 1.0 }; - static GLfloat normal[3] = { 0.0, 0.0, 1.0 }; - static GLfloat index[1] = { 1.0 }; - static GLfloat color[4] = { 1.0, 1.0, 1.0, 1.0 }; - static GLfloat texcoord[4] = { 0.0, 0.0, 0.0, 1.0 }; - static GLfloat attrib[4] = { 0.0, 0.0, 0.0, 1.0 }; - - init_1d_map( &ctx->EvalMap.Map1Vertex3, 3, vertex ); - init_1d_map( &ctx->EvalMap.Map1Vertex4, 4, vertex ); - init_1d_map( &ctx->EvalMap.Map1Index, 1, index ); - init_1d_map( &ctx->EvalMap.Map1Color4, 4, color ); - init_1d_map( &ctx->EvalMap.Map1Normal, 3, normal ); - init_1d_map( &ctx->EvalMap.Map1Texture1, 1, texcoord ); - init_1d_map( &ctx->EvalMap.Map1Texture2, 2, texcoord ); - init_1d_map( &ctx->EvalMap.Map1Texture3, 3, texcoord ); - init_1d_map( &ctx->EvalMap.Map1Texture4, 4, texcoord ); - for (i = 0; i < 16; i++) - init_1d_map( ctx->EvalMap.Map1Attrib + i, 4, attrib ); - - init_2d_map( &ctx->EvalMap.Map2Vertex3, 3, vertex ); - init_2d_map( &ctx->EvalMap.Map2Vertex4, 4, vertex ); - init_2d_map( &ctx->EvalMap.Map2Index, 1, index ); - init_2d_map( &ctx->EvalMap.Map2Color4, 4, color ); - init_2d_map( &ctx->EvalMap.Map2Normal, 3, normal ); - init_2d_map( &ctx->EvalMap.Map2Texture1, 1, texcoord ); - init_2d_map( &ctx->EvalMap.Map2Texture2, 2, texcoord ); - init_2d_map( &ctx->EvalMap.Map2Texture3, 3, texcoord ); - init_2d_map( &ctx->EvalMap.Map2Texture4, 4, texcoord ); - for (i = 0; i < 16; i++) - init_2d_map( ctx->EvalMap.Map2Attrib + i, 4, attrib ); - } -} - - -void _mesa_free_eval_data( struct gl_context *ctx ) -{ - int i; - - /* Free evaluator data */ - if (ctx->EvalMap.Map1Vertex3.Points) - FREE( ctx->EvalMap.Map1Vertex3.Points ); - if (ctx->EvalMap.Map1Vertex4.Points) - FREE( ctx->EvalMap.Map1Vertex4.Points ); - if (ctx->EvalMap.Map1Index.Points) - FREE( ctx->EvalMap.Map1Index.Points ); - if (ctx->EvalMap.Map1Color4.Points) - FREE( ctx->EvalMap.Map1Color4.Points ); - if (ctx->EvalMap.Map1Normal.Points) - FREE( ctx->EvalMap.Map1Normal.Points ); - if (ctx->EvalMap.Map1Texture1.Points) - FREE( ctx->EvalMap.Map1Texture1.Points ); - if (ctx->EvalMap.Map1Texture2.Points) - FREE( ctx->EvalMap.Map1Texture2.Points ); - if (ctx->EvalMap.Map1Texture3.Points) - FREE( ctx->EvalMap.Map1Texture3.Points ); - if (ctx->EvalMap.Map1Texture4.Points) - FREE( ctx->EvalMap.Map1Texture4.Points ); - for (i = 0; i < 16; i++) - FREE((ctx->EvalMap.Map1Attrib[i].Points)); - - if (ctx->EvalMap.Map2Vertex3.Points) - FREE( ctx->EvalMap.Map2Vertex3.Points ); - if (ctx->EvalMap.Map2Vertex4.Points) - FREE( ctx->EvalMap.Map2Vertex4.Points ); - if (ctx->EvalMap.Map2Index.Points) - FREE( ctx->EvalMap.Map2Index.Points ); - if (ctx->EvalMap.Map2Color4.Points) - FREE( ctx->EvalMap.Map2Color4.Points ); - if (ctx->EvalMap.Map2Normal.Points) - FREE( ctx->EvalMap.Map2Normal.Points ); - if (ctx->EvalMap.Map2Texture1.Points) - FREE( ctx->EvalMap.Map2Texture1.Points ); - if (ctx->EvalMap.Map2Texture2.Points) - FREE( ctx->EvalMap.Map2Texture2.Points ); - if (ctx->EvalMap.Map2Texture3.Points) - FREE( ctx->EvalMap.Map2Texture3.Points ); - if (ctx->EvalMap.Map2Texture4.Points) - FREE( ctx->EvalMap.Map2Texture4.Points ); - for (i = 0; i < 16; i++) - FREE((ctx->EvalMap.Map2Attrib[i].Points)); -} + +/* + * Mesa 3-D graphics library + * Version: 5.1 + * + * Copyright (C) 1999-2003 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. + */ + + +/* + * eval.c was written by + * Bernd Barsuhn (bdbarsuh@cip.informatik.uni-erlangen.de) and + * Volker Weiss (vrweiss@cip.informatik.uni-erlangen.de). + * + * My original implementation of evaluators was simplistic and didn't + * compute surface normal vectors properly. Bernd and Volker applied + * used more sophisticated methods to get better results. + * + * Thanks guys! + */ + + +#include "glheader.h" +#include "imports.h" +#include "colormac.h" +#include "context.h" +#include "eval.h" +#include "macros.h" +#include "mfeatures.h" +#include "mtypes.h" +#include "main/dispatch.h" + + +#if FEATURE_evaluators + + +/* + * Return the number of components per control point for any type of + * evaluator. Return 0 if bad target. + * See table 5.1 in the OpenGL 1.2 spec. + */ +GLuint _mesa_evaluator_components( GLenum target ) +{ + switch (target) { + case GL_MAP1_VERTEX_3: return 3; + case GL_MAP1_VERTEX_4: return 4; + case GL_MAP1_INDEX: return 1; + case GL_MAP1_COLOR_4: return 4; + case GL_MAP1_NORMAL: return 3; + case GL_MAP1_TEXTURE_COORD_1: return 1; + case GL_MAP1_TEXTURE_COORD_2: return 2; + case GL_MAP1_TEXTURE_COORD_3: return 3; + case GL_MAP1_TEXTURE_COORD_4: return 4; + case GL_MAP2_VERTEX_3: return 3; + case GL_MAP2_VERTEX_4: return 4; + case GL_MAP2_INDEX: return 1; + case GL_MAP2_COLOR_4: return 4; + case GL_MAP2_NORMAL: return 3; + case GL_MAP2_TEXTURE_COORD_1: return 1; + case GL_MAP2_TEXTURE_COORD_2: return 2; + case GL_MAP2_TEXTURE_COORD_3: return 3; + case GL_MAP2_TEXTURE_COORD_4: return 4; + default: break; + } + + /* XXX need to check for the vertex program extension + if (!ctx->Extensions.NV_vertex_program) + return 0; + */ + + if (target >= GL_MAP1_VERTEX_ATTRIB0_4_NV && + target <= GL_MAP1_VERTEX_ATTRIB15_4_NV) + return 4; + + if (target >= GL_MAP2_VERTEX_ATTRIB0_4_NV && + target <= GL_MAP2_VERTEX_ATTRIB15_4_NV) + return 4; + + return 0; +} + + +/* + * Return pointer to the gl_1d_map struct for the named target. + */ +static struct gl_1d_map * +get_1d_map( struct gl_context *ctx, GLenum target ) +{ + switch (target) { + case GL_MAP1_VERTEX_3: + return &ctx->EvalMap.Map1Vertex3; + case GL_MAP1_VERTEX_4: + return &ctx->EvalMap.Map1Vertex4; + case GL_MAP1_INDEX: + return &ctx->EvalMap.Map1Index; + case GL_MAP1_COLOR_4: + return &ctx->EvalMap.Map1Color4; + case GL_MAP1_NORMAL: + return &ctx->EvalMap.Map1Normal; + case GL_MAP1_TEXTURE_COORD_1: + return &ctx->EvalMap.Map1Texture1; + case GL_MAP1_TEXTURE_COORD_2: + return &ctx->EvalMap.Map1Texture2; + case GL_MAP1_TEXTURE_COORD_3: + return &ctx->EvalMap.Map1Texture3; + case GL_MAP1_TEXTURE_COORD_4: + return &ctx->EvalMap.Map1Texture4; + case GL_MAP1_VERTEX_ATTRIB0_4_NV: + case GL_MAP1_VERTEX_ATTRIB1_4_NV: + case GL_MAP1_VERTEX_ATTRIB2_4_NV: + case GL_MAP1_VERTEX_ATTRIB3_4_NV: + case GL_MAP1_VERTEX_ATTRIB4_4_NV: + case GL_MAP1_VERTEX_ATTRIB5_4_NV: + case GL_MAP1_VERTEX_ATTRIB6_4_NV: + case GL_MAP1_VERTEX_ATTRIB7_4_NV: + case GL_MAP1_VERTEX_ATTRIB8_4_NV: + case GL_MAP1_VERTEX_ATTRIB9_4_NV: + case GL_MAP1_VERTEX_ATTRIB10_4_NV: + case GL_MAP1_VERTEX_ATTRIB11_4_NV: + case GL_MAP1_VERTEX_ATTRIB12_4_NV: + case GL_MAP1_VERTEX_ATTRIB13_4_NV: + case GL_MAP1_VERTEX_ATTRIB14_4_NV: + case GL_MAP1_VERTEX_ATTRIB15_4_NV: + if (!ctx->Extensions.NV_vertex_program) + return NULL; + return &ctx->EvalMap.Map1Attrib[target - GL_MAP1_VERTEX_ATTRIB0_4_NV]; + default: + return NULL; + } +} + + +/* + * Return pointer to the gl_2d_map struct for the named target. + */ +static struct gl_2d_map * +get_2d_map( struct gl_context *ctx, GLenum target ) +{ + switch (target) { + case GL_MAP2_VERTEX_3: + return &ctx->EvalMap.Map2Vertex3; + case GL_MAP2_VERTEX_4: + return &ctx->EvalMap.Map2Vertex4; + case GL_MAP2_INDEX: + return &ctx->EvalMap.Map2Index; + case GL_MAP2_COLOR_4: + return &ctx->EvalMap.Map2Color4; + case GL_MAP2_NORMAL: + return &ctx->EvalMap.Map2Normal; + case GL_MAP2_TEXTURE_COORD_1: + return &ctx->EvalMap.Map2Texture1; + case GL_MAP2_TEXTURE_COORD_2: + return &ctx->EvalMap.Map2Texture2; + case GL_MAP2_TEXTURE_COORD_3: + return &ctx->EvalMap.Map2Texture3; + case GL_MAP2_TEXTURE_COORD_4: + return &ctx->EvalMap.Map2Texture4; + case GL_MAP2_VERTEX_ATTRIB0_4_NV: + case GL_MAP2_VERTEX_ATTRIB1_4_NV: + case GL_MAP2_VERTEX_ATTRIB2_4_NV: + case GL_MAP2_VERTEX_ATTRIB3_4_NV: + case GL_MAP2_VERTEX_ATTRIB4_4_NV: + case GL_MAP2_VERTEX_ATTRIB5_4_NV: + case GL_MAP2_VERTEX_ATTRIB6_4_NV: + case GL_MAP2_VERTEX_ATTRIB7_4_NV: + case GL_MAP2_VERTEX_ATTRIB8_4_NV: + case GL_MAP2_VERTEX_ATTRIB9_4_NV: + case GL_MAP2_VERTEX_ATTRIB10_4_NV: + case GL_MAP2_VERTEX_ATTRIB11_4_NV: + case GL_MAP2_VERTEX_ATTRIB12_4_NV: + case GL_MAP2_VERTEX_ATTRIB13_4_NV: + case GL_MAP2_VERTEX_ATTRIB14_4_NV: + case GL_MAP2_VERTEX_ATTRIB15_4_NV: + if (!ctx->Extensions.NV_vertex_program) + return NULL; + return &ctx->EvalMap.Map2Attrib[target - GL_MAP2_VERTEX_ATTRIB0_4_NV]; + default: + return NULL; + } +} + + +/**********************************************************************/ +/*** Copy and deallocate control points ***/ +/**********************************************************************/ + + +/* + * Copy 1-parametric evaluator control points from user-specified + * memory space to a buffer of contiguous control points. + * \param see glMap1f for details + * \return pointer to buffer of contiguous control points or NULL if out + * of memory. + */ +GLfloat *_mesa_copy_map_points1f( GLenum target, GLint ustride, GLint uorder, + const GLfloat *points ) +{ + GLfloat *buffer, *p; + GLint i, k, size = _mesa_evaluator_components(target); + + if (!points || !size) + return NULL; + + buffer = (GLfloat *) MALLOC(uorder * size * sizeof(GLfloat)); + + if (buffer) + for (i = 0, p = buffer; i < uorder; i++, points += ustride) + for (k = 0; k < size; k++) + *p++ = points[k]; + + return buffer; +} + + + +/* + * Same as above but convert doubles to floats. + */ +GLfloat *_mesa_copy_map_points1d( GLenum target, GLint ustride, GLint uorder, + const GLdouble *points ) +{ + GLfloat *buffer, *p; + GLint i, k, size = _mesa_evaluator_components(target); + + if (!points || !size) + return NULL; + + buffer = (GLfloat *) MALLOC(uorder * size * sizeof(GLfloat)); + + if (buffer) + for (i = 0, p = buffer; i < uorder; i++, points += ustride) + for (k = 0; k < size; k++) + *p++ = (GLfloat) points[k]; + + return buffer; +} + + + +/* + * Copy 2-parametric evaluator control points from user-specified + * memory space to a buffer of contiguous control points. + * Additional memory is allocated to be used by the horner and + * de Casteljau evaluation schemes. + * + * \param see glMap2f for details + * \return pointer to buffer of contiguous control points or NULL if out + * of memory. + */ +GLfloat *_mesa_copy_map_points2f( GLenum target, + GLint ustride, GLint uorder, + GLint vstride, GLint vorder, + const GLfloat *points ) +{ + GLfloat *buffer, *p; + GLint i, j, k, size, dsize, hsize; + GLint uinc; + + size = _mesa_evaluator_components(target); + + if (!points || size==0) { + return NULL; + } + + /* max(uorder, vorder) additional points are used in */ + /* horner evaluation and uorder*vorder additional */ + /* values are needed for de Casteljau */ + dsize = (uorder == 2 && vorder == 2)? 0 : uorder*vorder; + hsize = (uorder > vorder ? uorder : vorder)*size; + + if(hsize>dsize) + buffer = (GLfloat *) MALLOC((uorder*vorder*size+hsize)*sizeof(GLfloat)); + else + buffer = (GLfloat *) MALLOC((uorder*vorder*size+dsize)*sizeof(GLfloat)); + + /* compute the increment value for the u-loop */ + uinc = ustride - vorder*vstride; + + if (buffer) + for (i=0, p=buffer; i vorder ? uorder : vorder)*size; + + if(hsize>dsize) + buffer = (GLfloat *) MALLOC((uorder*vorder*size+hsize)*sizeof(GLfloat)); + else + buffer = (GLfloat *) MALLOC((uorder*vorder*size+dsize)*sizeof(GLfloat)); + + /* compute the increment value for the u-loop */ + uinc = ustride - vorder*vstride; + + if (buffer) + for (i=0, p=buffer; i MAX_EVAL_ORDER) { + _mesa_error( ctx, GL_INVALID_VALUE, "glMap1(order)" ); + return; + } + if (!points) { + _mesa_error( ctx, GL_INVALID_VALUE, "glMap1(points)" ); + return; + } + + k = _mesa_evaluator_components( target ); + if (k == 0) { + _mesa_error( ctx, GL_INVALID_ENUM, "glMap1(target)" ); + } + + if (ustride < k) { + _mesa_error( ctx, GL_INVALID_VALUE, "glMap1(stride)" ); + return; + } + + if (ctx->Texture.CurrentUnit != 0) { + /* See OpenGL 1.2.1 spec, section F.2.13 */ + _mesa_error( ctx, GL_INVALID_OPERATION, "glMap2(ACTIVE_TEXTURE != 0)" ); + return; + } + + map = get_1d_map(ctx, target); + if (!map) { + _mesa_error( ctx, GL_INVALID_ENUM, "glMap1(target)" ); + return; + } + + /* make copy of the control points */ + if (type == GL_FLOAT) + pnts = _mesa_copy_map_points1f(target, ustride, uorder, (GLfloat*) points); + else + pnts = _mesa_copy_map_points1d(target, ustride, uorder, (GLdouble*) points); + + + FLUSH_VERTICES(ctx, _NEW_EVAL); + map->Order = uorder; + map->u1 = u1; + map->u2 = u2; + map->du = 1.0F / (u2 - u1); + if (map->Points) + FREE( map->Points ); + map->Points = pnts; +} + + + +static void GLAPIENTRY +_mesa_Map1f( GLenum target, GLfloat u1, GLfloat u2, GLint stride, + GLint order, const GLfloat *points ) +{ + map1(target, u1, u2, stride, order, points, GL_FLOAT); +} + + +static void GLAPIENTRY +_mesa_Map1d( GLenum target, GLdouble u1, GLdouble u2, GLint stride, + GLint order, const GLdouble *points ) +{ + map1(target, (GLfloat) u1, (GLfloat) u2, stride, order, points, GL_DOUBLE); +} + + +static void +map2( GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, + GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, + const GLvoid *points, GLenum type ) +{ + GET_CURRENT_CONTEXT(ctx); + GLint k; + GLfloat *pnts; + struct gl_2d_map *map = NULL; + + ASSERT_OUTSIDE_BEGIN_END(ctx); + ASSERT(type == GL_FLOAT || type == GL_DOUBLE); + + if (u1==u2) { + _mesa_error( ctx, GL_INVALID_VALUE, "glMap2(u1,u2)" ); + return; + } + + if (v1==v2) { + _mesa_error( ctx, GL_INVALID_VALUE, "glMap2(v1,v2)" ); + return; + } + + if (uorder<1 || uorder>MAX_EVAL_ORDER) { + _mesa_error( ctx, GL_INVALID_VALUE, "glMap2(uorder)" ); + return; + } + + if (vorder<1 || vorder>MAX_EVAL_ORDER) { + _mesa_error( ctx, GL_INVALID_VALUE, "glMap2(vorder)" ); + return; + } + + k = _mesa_evaluator_components( target ); + if (k==0) { + _mesa_error( ctx, GL_INVALID_ENUM, "glMap2(target)" ); + } + + if (ustride < k) { + _mesa_error( ctx, GL_INVALID_VALUE, "glMap2(ustride)" ); + return; + } + if (vstride < k) { + _mesa_error( ctx, GL_INVALID_VALUE, "glMap2(vstride)" ); + return; + } + + if (ctx->Texture.CurrentUnit != 0) { + /* See OpenGL 1.2.1 spec, section F.2.13 */ + _mesa_error( ctx, GL_INVALID_OPERATION, "glMap2(ACTIVE_TEXTURE != 0)" ); + return; + } + + map = get_2d_map(ctx, target); + if (!map) { + _mesa_error( ctx, GL_INVALID_ENUM, "glMap2(target)" ); + return; + } + + /* make copy of the control points */ + if (type == GL_FLOAT) + pnts = _mesa_copy_map_points2f(target, ustride, uorder, + vstride, vorder, (GLfloat*) points); + else + pnts = _mesa_copy_map_points2d(target, ustride, uorder, + vstride, vorder, (GLdouble*) points); + + + FLUSH_VERTICES(ctx, _NEW_EVAL); + map->Uorder = uorder; + map->u1 = u1; + map->u2 = u2; + map->du = 1.0F / (u2 - u1); + map->Vorder = vorder; + map->v1 = v1; + map->v2 = v2; + map->dv = 1.0F / (v2 - v1); + if (map->Points) + FREE( map->Points ); + map->Points = pnts; +} + + +static void GLAPIENTRY +_mesa_Map2f( GLenum target, + GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, + GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, + const GLfloat *points) +{ + map2(target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, + points, GL_FLOAT); +} + + +static void GLAPIENTRY +_mesa_Map2d( GLenum target, + GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, + GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, + const GLdouble *points ) +{ + map2(target, (GLfloat) u1, (GLfloat) u2, ustride, uorder, + (GLfloat) v1, (GLfloat) v2, vstride, vorder, points, GL_DOUBLE); +} + + + +static void GLAPIENTRY +_mesa_GetnMapdvARB( GLenum target, GLenum query, GLsizei bufSize, GLdouble *v ) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_1d_map *map1d; + struct gl_2d_map *map2d; + GLint i, n; + GLfloat *data; + GLuint comps; + GLsizei numBytes; + + ASSERT_OUTSIDE_BEGIN_END(ctx); + + comps = _mesa_evaluator_components(target); + if (!comps) { + _mesa_error( ctx, GL_INVALID_ENUM, "glGetMapdv(target)" ); + return; + } + + map1d = get_1d_map(ctx, target); + map2d = get_2d_map(ctx, target); + ASSERT(map1d || map2d); + + switch (query) { + case GL_COEFF: + if (map1d) { + data = map1d->Points; + n = map1d->Order * comps; + } + else { + data = map2d->Points; + n = map2d->Uorder * map2d->Vorder * comps; + } + if (data) { + numBytes = n * sizeof *v; + if (bufSize < numBytes) + goto overflow; + for (i=0;iOrder; + } + else { + numBytes = 2 * sizeof *v; + if (bufSize < numBytes) + goto overflow; + v[0] = (GLdouble) map2d->Uorder; + v[1] = (GLdouble) map2d->Vorder; + } + break; + case GL_DOMAIN: + if (map1d) { + numBytes = 2 * sizeof *v; + if (bufSize < numBytes) + goto overflow; + v[0] = (GLdouble) map1d->u1; + v[1] = (GLdouble) map1d->u2; + } + else { + numBytes = 4 * sizeof *v; + if (bufSize < numBytes) + goto overflow; + v[0] = (GLdouble) map2d->u1; + v[1] = (GLdouble) map2d->u2; + v[2] = (GLdouble) map2d->v1; + v[3] = (GLdouble) map2d->v2; + } + break; + default: + _mesa_error( ctx, GL_INVALID_ENUM, "glGetMapdv(query)" ); + } + return; + +overflow: + _mesa_error( ctx, GL_INVALID_OPERATION, + "glGetnMapdvARB(out of bounds: bufSize is %d," + " but %d bytes are required)", bufSize, numBytes ); +} + +static void GLAPIENTRY +_mesa_GetMapdv( GLenum target, GLenum query, GLdouble *v ) +{ + _mesa_GetnMapdvARB(target, query, INT_MAX, v); +} + +static void GLAPIENTRY +_mesa_GetnMapfvARB( GLenum target, GLenum query, GLsizei bufSize, GLfloat *v ) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_1d_map *map1d; + struct gl_2d_map *map2d; + GLint i, n; + GLfloat *data; + GLuint comps; + GLsizei numBytes; + + ASSERT_OUTSIDE_BEGIN_END(ctx); + + comps = _mesa_evaluator_components(target); + if (!comps) { + _mesa_error( ctx, GL_INVALID_ENUM, "glGetMapfv(target)" ); + return; + } + + map1d = get_1d_map(ctx, target); + map2d = get_2d_map(ctx, target); + ASSERT(map1d || map2d); + + switch (query) { + case GL_COEFF: + if (map1d) { + data = map1d->Points; + n = map1d->Order * comps; + } + else { + data = map2d->Points; + n = map2d->Uorder * map2d->Vorder * comps; + } + if (data) { + numBytes = n * sizeof *v; + if (bufSize < numBytes) + goto overflow; + for (i=0;iOrder; + } + else { + numBytes = 2 * sizeof *v; + if (bufSize < numBytes) + goto overflow; + v[0] = (GLfloat) map2d->Uorder; + v[1] = (GLfloat) map2d->Vorder; + } + break; + case GL_DOMAIN: + if (map1d) { + numBytes = 2 * sizeof *v; + if (bufSize < numBytes) + goto overflow; + v[0] = map1d->u1; + v[1] = map1d->u2; + } + else { + numBytes = 4 * sizeof *v; + if (bufSize < numBytes) + goto overflow; + v[0] = map2d->u1; + v[1] = map2d->u2; + v[2] = map2d->v1; + v[3] = map2d->v2; + } + break; + default: + _mesa_error( ctx, GL_INVALID_ENUM, "glGetMapfv(query)" ); + } + return; + +overflow: + _mesa_error( ctx, GL_INVALID_OPERATION, + "glGetnMapfvARB(out of bounds: bufSize is %d," + " but %d bytes are required)", bufSize, numBytes ); +} + + +static void GLAPIENTRY +_mesa_GetMapfv( GLenum target, GLenum query, GLfloat *v ) +{ + _mesa_GetnMapfvARB(target, query, INT_MAX, v); +} + + +static void GLAPIENTRY +_mesa_GetnMapivARB( GLenum target, GLenum query, GLsizei bufSize, GLint *v ) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_1d_map *map1d; + struct gl_2d_map *map2d; + GLuint i, n; + GLfloat *data; + GLuint comps; + GLsizei numBytes; + + ASSERT_OUTSIDE_BEGIN_END(ctx); + + comps = _mesa_evaluator_components(target); + if (!comps) { + _mesa_error( ctx, GL_INVALID_ENUM, "glGetMapiv(target)" ); + return; + } + + map1d = get_1d_map(ctx, target); + map2d = get_2d_map(ctx, target); + ASSERT(map1d || map2d); + + switch (query) { + case GL_COEFF: + if (map1d) { + data = map1d->Points; + n = map1d->Order * comps; + } + else { + data = map2d->Points; + n = map2d->Uorder * map2d->Vorder * comps; + } + if (data) { + numBytes = n * sizeof *v; + if (bufSize < numBytes) + goto overflow; + for (i=0;iOrder; + } + else { + numBytes = 2 * sizeof *v; + if (bufSize < numBytes) + goto overflow; + v[0] = map2d->Uorder; + v[1] = map2d->Vorder; + } + break; + case GL_DOMAIN: + if (map1d) { + numBytes = 2 * sizeof *v; + if (bufSize < numBytes) + goto overflow; + v[0] = IROUND(map1d->u1); + v[1] = IROUND(map1d->u2); + } + else { + numBytes = 4 * sizeof *v; + if (bufSize < numBytes) + goto overflow; + v[0] = IROUND(map2d->u1); + v[1] = IROUND(map2d->u2); + v[2] = IROUND(map2d->v1); + v[3] = IROUND(map2d->v2); + } + break; + default: + _mesa_error( ctx, GL_INVALID_ENUM, "glGetMapiv(query)" ); + } + return; + +overflow: + _mesa_error( ctx, GL_INVALID_OPERATION, + "glGetnMapivARB(out of bounds: bufSize is %d," + " but %d bytes are required)", bufSize, numBytes ); +} + + +static void GLAPIENTRY +_mesa_GetMapiv( GLenum target, GLenum query, GLint *v ) +{ + _mesa_GetnMapivARB(target, query, INT_MAX, v); +} + + +static void GLAPIENTRY +_mesa_MapGrid1f( GLint un, GLfloat u1, GLfloat u2 ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (un<1) { + _mesa_error( ctx, GL_INVALID_VALUE, "glMapGrid1f" ); + return; + } + FLUSH_VERTICES(ctx, _NEW_EVAL); + ctx->Eval.MapGrid1un = un; + ctx->Eval.MapGrid1u1 = u1; + ctx->Eval.MapGrid1u2 = u2; + ctx->Eval.MapGrid1du = (u2 - u1) / (GLfloat) un; +} + + +static void GLAPIENTRY +_mesa_MapGrid1d( GLint un, GLdouble u1, GLdouble u2 ) +{ + _mesa_MapGrid1f( un, (GLfloat) u1, (GLfloat) u2 ); +} + + +static void GLAPIENTRY +_mesa_MapGrid2f( GLint un, GLfloat u1, GLfloat u2, + GLint vn, GLfloat v1, GLfloat v2 ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (un<1) { + _mesa_error( ctx, GL_INVALID_VALUE, "glMapGrid2f(un)" ); + return; + } + if (vn<1) { + _mesa_error( ctx, GL_INVALID_VALUE, "glMapGrid2f(vn)" ); + return; + } + + FLUSH_VERTICES(ctx, _NEW_EVAL); + ctx->Eval.MapGrid2un = un; + ctx->Eval.MapGrid2u1 = u1; + ctx->Eval.MapGrid2u2 = u2; + ctx->Eval.MapGrid2du = (u2 - u1) / (GLfloat) un; + ctx->Eval.MapGrid2vn = vn; + ctx->Eval.MapGrid2v1 = v1; + ctx->Eval.MapGrid2v2 = v2; + ctx->Eval.MapGrid2dv = (v2 - v1) / (GLfloat) vn; +} + + +static void GLAPIENTRY +_mesa_MapGrid2d( GLint un, GLdouble u1, GLdouble u2, + GLint vn, GLdouble v1, GLdouble v2 ) +{ + _mesa_MapGrid2f( un, (GLfloat) u1, (GLfloat) u2, + vn, (GLfloat) v1, (GLfloat) v2 ); +} + + +void +_mesa_install_eval_vtxfmt(struct _glapi_table *disp, + const GLvertexformat *vfmt) +{ + SET_EvalCoord1f(disp, vfmt->EvalCoord1f); + SET_EvalCoord1fv(disp, vfmt->EvalCoord1fv); + SET_EvalCoord2f(disp, vfmt->EvalCoord2f); + SET_EvalCoord2fv(disp, vfmt->EvalCoord2fv); + SET_EvalPoint1(disp, vfmt->EvalPoint1); + SET_EvalPoint2(disp, vfmt->EvalPoint2); + + SET_EvalMesh1(disp, vfmt->EvalMesh1); + SET_EvalMesh2(disp, vfmt->EvalMesh2); +} + + +void +_mesa_init_eval_dispatch(struct _glapi_table *disp) +{ + SET_GetMapdv(disp, _mesa_GetMapdv); + SET_GetMapfv(disp, _mesa_GetMapfv); + SET_GetMapiv(disp, _mesa_GetMapiv); + SET_Map1d(disp, _mesa_Map1d); + SET_Map1f(disp, _mesa_Map1f); + SET_Map2d(disp, _mesa_Map2d); + SET_Map2f(disp, _mesa_Map2f); + SET_MapGrid1d(disp, _mesa_MapGrid1d); + SET_MapGrid1f(disp, _mesa_MapGrid1f); + SET_MapGrid2d(disp, _mesa_MapGrid2d); + SET_MapGrid2f(disp, _mesa_MapGrid2f); + + /* GL_ARB_robustness */ + SET_GetnMapdvARB(disp, _mesa_GetnMapdvARB); + SET_GetnMapfvARB(disp, _mesa_GetnMapfvARB); + SET_GetnMapivARB(disp, _mesa_GetnMapivARB); +} + + +#endif /* FEATURE_evaluators */ + + +/**********************************************************************/ +/***** Initialization *****/ +/**********************************************************************/ + +/** + * Initialize a 1-D evaluator map. + */ +static void +init_1d_map( struct gl_1d_map *map, int n, const float *initial ) +{ + map->Order = 1; + map->u1 = 0.0; + map->u2 = 1.0; + map->Points = (GLfloat *) MALLOC(n * sizeof(GLfloat)); + if (map->Points) { + GLint i; + for (i=0;iPoints[i] = initial[i]; + } +} + + +/** + * Initialize a 2-D evaluator map + */ +static void +init_2d_map( struct gl_2d_map *map, int n, const float *initial ) +{ + map->Uorder = 1; + map->Vorder = 1; + map->u1 = 0.0; + map->u2 = 1.0; + map->v1 = 0.0; + map->v2 = 1.0; + map->Points = (GLfloat *) MALLOC(n * sizeof(GLfloat)); + if (map->Points) { + GLint i; + for (i=0;iPoints[i] = initial[i]; + } +} + + +void _mesa_init_eval( struct gl_context *ctx ) +{ + int i; + + /* Evaluators group */ + ctx->Eval.Map1Color4 = GL_FALSE; + ctx->Eval.Map1Index = GL_FALSE; + ctx->Eval.Map1Normal = GL_FALSE; + ctx->Eval.Map1TextureCoord1 = GL_FALSE; + ctx->Eval.Map1TextureCoord2 = GL_FALSE; + ctx->Eval.Map1TextureCoord3 = GL_FALSE; + ctx->Eval.Map1TextureCoord4 = GL_FALSE; + ctx->Eval.Map1Vertex3 = GL_FALSE; + ctx->Eval.Map1Vertex4 = GL_FALSE; + memset(ctx->Eval.Map1Attrib, 0, sizeof(ctx->Eval.Map1Attrib)); + ctx->Eval.Map2Color4 = GL_FALSE; + ctx->Eval.Map2Index = GL_FALSE; + ctx->Eval.Map2Normal = GL_FALSE; + ctx->Eval.Map2TextureCoord1 = GL_FALSE; + ctx->Eval.Map2TextureCoord2 = GL_FALSE; + ctx->Eval.Map2TextureCoord3 = GL_FALSE; + ctx->Eval.Map2TextureCoord4 = GL_FALSE; + ctx->Eval.Map2Vertex3 = GL_FALSE; + ctx->Eval.Map2Vertex4 = GL_FALSE; + memset(ctx->Eval.Map2Attrib, 0, sizeof(ctx->Eval.Map2Attrib)); + ctx->Eval.AutoNormal = GL_FALSE; + ctx->Eval.MapGrid1un = 1; + ctx->Eval.MapGrid1u1 = 0.0; + ctx->Eval.MapGrid1u2 = 1.0; + ctx->Eval.MapGrid2un = 1; + ctx->Eval.MapGrid2vn = 1; + ctx->Eval.MapGrid2u1 = 0.0; + ctx->Eval.MapGrid2u2 = 1.0; + ctx->Eval.MapGrid2v1 = 0.0; + ctx->Eval.MapGrid2v2 = 1.0; + + /* Evaluator data */ + { + static GLfloat vertex[4] = { 0.0, 0.0, 0.0, 1.0 }; + static GLfloat normal[3] = { 0.0, 0.0, 1.0 }; + static GLfloat index[1] = { 1.0 }; + static GLfloat color[4] = { 1.0, 1.0, 1.0, 1.0 }; + static GLfloat texcoord[4] = { 0.0, 0.0, 0.0, 1.0 }; + static GLfloat attrib[4] = { 0.0, 0.0, 0.0, 1.0 }; + + init_1d_map( &ctx->EvalMap.Map1Vertex3, 3, vertex ); + init_1d_map( &ctx->EvalMap.Map1Vertex4, 4, vertex ); + init_1d_map( &ctx->EvalMap.Map1Index, 1, index ); + init_1d_map( &ctx->EvalMap.Map1Color4, 4, color ); + init_1d_map( &ctx->EvalMap.Map1Normal, 3, normal ); + init_1d_map( &ctx->EvalMap.Map1Texture1, 1, texcoord ); + init_1d_map( &ctx->EvalMap.Map1Texture2, 2, texcoord ); + init_1d_map( &ctx->EvalMap.Map1Texture3, 3, texcoord ); + init_1d_map( &ctx->EvalMap.Map1Texture4, 4, texcoord ); + for (i = 0; i < 16; i++) + init_1d_map( ctx->EvalMap.Map1Attrib + i, 4, attrib ); + + init_2d_map( &ctx->EvalMap.Map2Vertex3, 3, vertex ); + init_2d_map( &ctx->EvalMap.Map2Vertex4, 4, vertex ); + init_2d_map( &ctx->EvalMap.Map2Index, 1, index ); + init_2d_map( &ctx->EvalMap.Map2Color4, 4, color ); + init_2d_map( &ctx->EvalMap.Map2Normal, 3, normal ); + init_2d_map( &ctx->EvalMap.Map2Texture1, 1, texcoord ); + init_2d_map( &ctx->EvalMap.Map2Texture2, 2, texcoord ); + init_2d_map( &ctx->EvalMap.Map2Texture3, 3, texcoord ); + init_2d_map( &ctx->EvalMap.Map2Texture4, 4, texcoord ); + for (i = 0; i < 16; i++) + init_2d_map( ctx->EvalMap.Map2Attrib + i, 4, attrib ); + } +} + + +void _mesa_free_eval_data( struct gl_context *ctx ) +{ + int i; + + /* Free evaluator data */ + if (ctx->EvalMap.Map1Vertex3.Points) + FREE( ctx->EvalMap.Map1Vertex3.Points ); + if (ctx->EvalMap.Map1Vertex4.Points) + FREE( ctx->EvalMap.Map1Vertex4.Points ); + if (ctx->EvalMap.Map1Index.Points) + FREE( ctx->EvalMap.Map1Index.Points ); + if (ctx->EvalMap.Map1Color4.Points) + FREE( ctx->EvalMap.Map1Color4.Points ); + if (ctx->EvalMap.Map1Normal.Points) + FREE( ctx->EvalMap.Map1Normal.Points ); + if (ctx->EvalMap.Map1Texture1.Points) + FREE( ctx->EvalMap.Map1Texture1.Points ); + if (ctx->EvalMap.Map1Texture2.Points) + FREE( ctx->EvalMap.Map1Texture2.Points ); + if (ctx->EvalMap.Map1Texture3.Points) + FREE( ctx->EvalMap.Map1Texture3.Points ); + if (ctx->EvalMap.Map1Texture4.Points) + FREE( ctx->EvalMap.Map1Texture4.Points ); + for (i = 0; i < 16; i++) + FREE((ctx->EvalMap.Map1Attrib[i].Points)); + + if (ctx->EvalMap.Map2Vertex3.Points) + FREE( ctx->EvalMap.Map2Vertex3.Points ); + if (ctx->EvalMap.Map2Vertex4.Points) + FREE( ctx->EvalMap.Map2Vertex4.Points ); + if (ctx->EvalMap.Map2Index.Points) + FREE( ctx->EvalMap.Map2Index.Points ); + if (ctx->EvalMap.Map2Color4.Points) + FREE( ctx->EvalMap.Map2Color4.Points ); + if (ctx->EvalMap.Map2Normal.Points) + FREE( ctx->EvalMap.Map2Normal.Points ); + if (ctx->EvalMap.Map2Texture1.Points) + FREE( ctx->EvalMap.Map2Texture1.Points ); + if (ctx->EvalMap.Map2Texture2.Points) + FREE( ctx->EvalMap.Map2Texture2.Points ); + if (ctx->EvalMap.Map2Texture3.Points) + FREE( ctx->EvalMap.Map2Texture3.Points ); + if (ctx->EvalMap.Map2Texture4.Points) + FREE( ctx->EvalMap.Map2Texture4.Points ); + for (i = 0; i < 16; i++) + FREE((ctx->EvalMap.Map2Attrib[i].Points)); +} diff --git a/mesalib/src/mesa/main/fbobject.c b/mesalib/src/mesa/main/fbobject.c index 74ba27190..fd371aba8 100644 --- a/mesalib/src/mesa/main/fbobject.c +++ b/mesalib/src/mesa/main/fbobject.c @@ -1,2699 +1,2699 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (C) 1999-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. - */ - - -/* - * GL_EXT/ARB_framebuffer_object extensions - * - * Authors: - * Brian Paul - */ - - -#include "buffers.h" -#include "context.h" -#include "enums.h" -#include "fbobject.h" -#include "formats.h" -#include "framebuffer.h" -#include "hash.h" -#include "macros.h" -#include "mfeatures.h" -#include "mtypes.h" -#include "renderbuffer.h" -#include "state.h" -#include "teximage.h" -#include "texobj.h" - - -/** Set this to 1 to help debug FBO incompleteness problems */ -#define DEBUG_FBO 0 - -/** Set this to 1 to debug/log glBlitFramebuffer() calls */ -#define DEBUG_BLIT 0 - - -/** - * Notes: - * - * None of the GL_EXT_framebuffer_object functions are compiled into - * display lists. - */ - - - -/* - * When glGenRender/FramebuffersEXT() is called we insert pointers to - * these placeholder objects into the hash table. - * Later, when the object ID is first bound, we replace the placeholder - * with the real frame/renderbuffer. - */ -static struct gl_framebuffer DummyFramebuffer; -static struct gl_renderbuffer DummyRenderbuffer; - -/* We bind this framebuffer when applications pass a NULL - * drawable/surface in make current. */ -static struct gl_framebuffer IncompleteFramebuffer; - - -static INLINE GLboolean -is_cube_face(GLenum target) -{ - return (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X && - target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z); -} - - -/** - * Is the given FBO a user-created FBO? - */ -static INLINE GLboolean -is_user_fbo(const struct gl_framebuffer *fb) -{ - return fb->Name != 0; -} - - -/** - * Is the given FBO a window system FBO (like an X window)? - */ -static INLINE GLboolean -is_winsys_fbo(const struct gl_framebuffer *fb) -{ - return fb->Name == 0; -} - - -static void -delete_dummy_renderbuffer(struct gl_renderbuffer *rb) -{ - /* no op */ -} - -static void -delete_dummy_framebuffer(struct gl_framebuffer *fb) -{ - /* no op */ -} - - -void -_mesa_init_fbobjects(struct gl_context *ctx) -{ - _glthread_INIT_MUTEX(DummyFramebuffer.Mutex); - _glthread_INIT_MUTEX(DummyRenderbuffer.Mutex); - _glthread_INIT_MUTEX(IncompleteFramebuffer.Mutex); - DummyFramebuffer.Delete = delete_dummy_framebuffer; - DummyRenderbuffer.Delete = delete_dummy_renderbuffer; - IncompleteFramebuffer.Delete = delete_dummy_framebuffer; -} - -struct gl_framebuffer * -_mesa_get_incomplete_framebuffer(void) -{ - return &IncompleteFramebuffer; -} - -/** - * Helper routine for getting a gl_renderbuffer. - */ -struct gl_renderbuffer * -_mesa_lookup_renderbuffer(struct gl_context *ctx, GLuint id) -{ - struct gl_renderbuffer *rb; - - if (id == 0) - return NULL; - - rb = (struct gl_renderbuffer *) - _mesa_HashLookup(ctx->Shared->RenderBuffers, id); - return rb; -} - - -/** - * Helper routine for getting a gl_framebuffer. - */ -struct gl_framebuffer * -_mesa_lookup_framebuffer(struct gl_context *ctx, GLuint id) -{ - struct gl_framebuffer *fb; - - if (id == 0) - return NULL; - - fb = (struct gl_framebuffer *) - _mesa_HashLookup(ctx->Shared->FrameBuffers, id); - return fb; -} - - -/** - * Mark the given framebuffer as invalid. This will force the - * test for framebuffer completeness to be done before the framebuffer - * is used. - */ -static void -invalidate_framebuffer(struct gl_framebuffer *fb) -{ - fb->_Status = 0; /* "indeterminate" */ -} - - -/** - * Return the gl_framebuffer object which corresponds to the given - * framebuffer target, such as GL_DRAW_FRAMEBUFFER. - * Check support for GL_EXT_framebuffer_blit to determine if certain - * targets are legal. - * \return gl_framebuffer pointer or NULL if target is illegal - */ -static struct gl_framebuffer * -get_framebuffer_target(struct gl_context *ctx, GLenum target) -{ - switch (target) { - case GL_DRAW_FRAMEBUFFER: - return ctx->Extensions.EXT_framebuffer_blit ? ctx->DrawBuffer : NULL; - case GL_READ_FRAMEBUFFER: - return ctx->Extensions.EXT_framebuffer_blit ? ctx->ReadBuffer : NULL; - case GL_FRAMEBUFFER_EXT: - return ctx->DrawBuffer; - default: - return NULL; - } -} - - -/** - * Given a GL_*_ATTACHMENTn token, return a pointer to the corresponding - * gl_renderbuffer_attachment object. - * This function is only used for user-created FB objects, not the - * default / window-system FB object. - * If \p attachment is GL_DEPTH_STENCIL_ATTACHMENT, return a pointer to - * the depth buffer attachment point. - */ -struct gl_renderbuffer_attachment * -_mesa_get_attachment(struct gl_context *ctx, struct gl_framebuffer *fb, - GLenum attachment) -{ - GLuint i; - - assert(is_user_fbo(fb)); - - switch (attachment) { - case GL_COLOR_ATTACHMENT0_EXT: - case GL_COLOR_ATTACHMENT1_EXT: - case GL_COLOR_ATTACHMENT2_EXT: - case GL_COLOR_ATTACHMENT3_EXT: - case GL_COLOR_ATTACHMENT4_EXT: - case GL_COLOR_ATTACHMENT5_EXT: - case GL_COLOR_ATTACHMENT6_EXT: - case GL_COLOR_ATTACHMENT7_EXT: - case GL_COLOR_ATTACHMENT8_EXT: - case GL_COLOR_ATTACHMENT9_EXT: - case GL_COLOR_ATTACHMENT10_EXT: - case GL_COLOR_ATTACHMENT11_EXT: - case GL_COLOR_ATTACHMENT12_EXT: - case GL_COLOR_ATTACHMENT13_EXT: - case GL_COLOR_ATTACHMENT14_EXT: - case GL_COLOR_ATTACHMENT15_EXT: - i = attachment - GL_COLOR_ATTACHMENT0_EXT; - if (i >= ctx->Const.MaxColorAttachments) { - return NULL; - } - return &fb->Attachment[BUFFER_COLOR0 + i]; - case GL_DEPTH_STENCIL_ATTACHMENT: - /* fall-through */ - case GL_DEPTH_BUFFER: - /* fall-through / new in GL 3.0 */ - case GL_DEPTH_ATTACHMENT_EXT: - return &fb->Attachment[BUFFER_DEPTH]; - case GL_STENCIL_BUFFER: - /* fall-through / new in GL 3.0 */ - case GL_STENCIL_ATTACHMENT_EXT: - return &fb->Attachment[BUFFER_STENCIL]; - default: - return NULL; - } -} - - -/** - * As above, but only used for getting attachments of the default / - * window-system framebuffer (not user-created framebuffer objects). - */ -static struct gl_renderbuffer_attachment * -_mesa_get_fb0_attachment(struct gl_context *ctx, struct gl_framebuffer *fb, - GLenum attachment) -{ - assert(is_winsys_fbo(fb)); - - switch (attachment) { - case GL_FRONT_LEFT: - return &fb->Attachment[BUFFER_FRONT_LEFT]; - case GL_FRONT_RIGHT: - return &fb->Attachment[BUFFER_FRONT_RIGHT]; - case GL_BACK_LEFT: - return &fb->Attachment[BUFFER_BACK_LEFT]; - case GL_BACK_RIGHT: - return &fb->Attachment[BUFFER_BACK_RIGHT]; - case GL_AUX0: - if (fb->Visual.numAuxBuffers == 1) { - return &fb->Attachment[BUFFER_AUX0]; - } - return NULL; - case GL_DEPTH_BUFFER: - /* fall-through / new in GL 3.0 */ - case GL_DEPTH_ATTACHMENT_EXT: - return &fb->Attachment[BUFFER_DEPTH]; - case GL_STENCIL_BUFFER: - /* fall-through / new in GL 3.0 */ - case GL_STENCIL_ATTACHMENT_EXT: - return &fb->Attachment[BUFFER_STENCIL]; - default: - return NULL; - } -} - - - -/** - * Remove any texture or renderbuffer attached to the given attachment - * point. Update reference counts, etc. - */ -void -_mesa_remove_attachment(struct gl_context *ctx, - struct gl_renderbuffer_attachment *att) -{ - if (att->Type == GL_TEXTURE) { - ASSERT(att->Texture); - if (ctx->Driver.FinishRenderTexture) { - /* tell driver that we're done rendering to this texture. */ - ctx->Driver.FinishRenderTexture(ctx, att); - } - _mesa_reference_texobj(&att->Texture, NULL); /* unbind */ - ASSERT(!att->Texture); - } - if (att->Type == GL_TEXTURE || att->Type == GL_RENDERBUFFER_EXT) { - ASSERT(!att->Texture); - _mesa_reference_renderbuffer(&att->Renderbuffer, NULL); /* unbind */ - ASSERT(!att->Renderbuffer); - } - att->Type = GL_NONE; - att->Complete = GL_TRUE; -} - - -/** - * Bind a texture object to an attachment point. - * The previous binding, if any, will be removed first. - */ -void -_mesa_set_texture_attachment(struct gl_context *ctx, - struct gl_framebuffer *fb, - struct gl_renderbuffer_attachment *att, - struct gl_texture_object *texObj, - GLenum texTarget, GLuint level, GLuint zoffset) -{ - if (att->Texture == texObj) { - /* re-attaching same texture */ - ASSERT(att->Type == GL_TEXTURE); - if (ctx->Driver.FinishRenderTexture) - ctx->Driver.FinishRenderTexture(ctx, att); - } - else { - /* new attachment */ - if (ctx->Driver.FinishRenderTexture && att->Texture) - ctx->Driver.FinishRenderTexture(ctx, att); - _mesa_remove_attachment(ctx, att); - att->Type = GL_TEXTURE; - assert(!att->Texture); - _mesa_reference_texobj(&att->Texture, texObj); - } - - /* always update these fields */ - att->TextureLevel = level; - att->CubeMapFace = _mesa_tex_target_to_face(texTarget); - att->Zoffset = zoffset; - att->Complete = GL_FALSE; - - if (_mesa_get_attachment_teximage(att)) { - ctx->Driver.RenderTexture(ctx, fb, att); - } - - invalidate_framebuffer(fb); -} - - -/** - * Bind a renderbuffer to an attachment point. - * The previous binding, if any, will be removed first. - */ -void -_mesa_set_renderbuffer_attachment(struct gl_context *ctx, - struct gl_renderbuffer_attachment *att, - struct gl_renderbuffer *rb) -{ - /* XXX check if re-doing same attachment, exit early */ - _mesa_remove_attachment(ctx, att); - att->Type = GL_RENDERBUFFER_EXT; - att->Texture = NULL; /* just to be safe */ - att->Complete = GL_FALSE; - _mesa_reference_renderbuffer(&att->Renderbuffer, rb); -} - - -/** - * Fallback for ctx->Driver.FramebufferRenderbuffer() - * Attach a renderbuffer object to a framebuffer object. - */ -void -_mesa_framebuffer_renderbuffer(struct gl_context *ctx, - struct gl_framebuffer *fb, - GLenum attachment, struct gl_renderbuffer *rb) -{ - struct gl_renderbuffer_attachment *att; - - _glthread_LOCK_MUTEX(fb->Mutex); - - att = _mesa_get_attachment(ctx, fb, attachment); - ASSERT(att); - if (rb) { - _mesa_set_renderbuffer_attachment(ctx, att, rb); - if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) { - /* do stencil attachment here (depth already done above) */ - att = _mesa_get_attachment(ctx, fb, GL_STENCIL_ATTACHMENT_EXT); - assert(att); - _mesa_set_renderbuffer_attachment(ctx, att, rb); - } - rb->AttachedAnytime = GL_TRUE; - } - else { - _mesa_remove_attachment(ctx, att); - } - - invalidate_framebuffer(fb); - - _glthread_UNLOCK_MUTEX(fb->Mutex); -} - - -/** - * Fallback for ctx->Driver.ValidateFramebuffer() - * Check if the renderbuffer's formats are supported by the software - * renderer. - * Drivers should probably override this. - */ -void -_mesa_validate_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb) -{ - gl_buffer_index buf; - for (buf = 0; buf < BUFFER_COUNT; buf++) { - const struct gl_renderbuffer *rb = fb->Attachment[buf].Renderbuffer; - if (rb) { - switch (rb->_BaseFormat) { - case GL_ALPHA: - case GL_LUMINANCE_ALPHA: - case GL_LUMINANCE: - case GL_INTENSITY: - case GL_RED: - case GL_RG: - fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED; - return; - - default: - switch (rb->Format) { - /* XXX This list is likely incomplete. */ - case MESA_FORMAT_RGB9_E5_FLOAT: - fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED; - return; - default:; - /* render buffer format is supported by software rendering */ - } - } - } - } -} - - -/** - * For debug only. - */ -static void -att_incomplete(const char *msg) -{ -#if DEBUG_FBO - _mesa_debug(NULL, "attachment incomplete: %s\n", msg); -#else - (void) msg; -#endif -} - - -/** - * For debug only. - */ -static void -fbo_incomplete(const char *msg, int index) -{ -#if DEBUG_FBO - _mesa_debug(NULL, "FBO Incomplete: %s [%d]\n", msg, index); -#else - (void) msg; - (void) index; -#endif -} - - -/** - * Is the given base format a legal format for a color renderbuffer? - */ -GLboolean -_mesa_is_legal_color_format(const struct gl_context *ctx, GLenum baseFormat) -{ - switch (baseFormat) { - case GL_RGB: - case GL_RGBA: - return GL_TRUE; - case GL_LUMINANCE: - case GL_LUMINANCE_ALPHA: - case GL_INTENSITY: - case GL_ALPHA: - return ctx->Extensions.ARB_framebuffer_object; - case GL_RED: - case GL_RG: - return ctx->Extensions.ARB_texture_rg; - default: - return GL_FALSE; - } -} - - -/** - * Is the given base format a legal format for a depth/stencil renderbuffer? - */ -static GLboolean -is_legal_depth_format(const struct gl_context *ctx, GLenum baseFormat) -{ - switch (baseFormat) { - case GL_DEPTH_COMPONENT: - case GL_DEPTH_STENCIL_EXT: - return GL_TRUE; - default: - return GL_FALSE; - } -} - - -/** - * Test if an attachment point is complete and update its Complete field. - * \param format if GL_COLOR, this is a color attachment point, - * if GL_DEPTH, this is a depth component attachment point, - * if GL_STENCIL, this is a stencil component attachment point. - */ -static void -test_attachment_completeness(const struct gl_context *ctx, GLenum format, - struct gl_renderbuffer_attachment *att) -{ - assert(format == GL_COLOR || format == GL_DEPTH || format == GL_STENCIL); - - /* assume complete */ - att->Complete = GL_TRUE; - - /* Look for reasons why the attachment might be incomplete */ - if (att->Type == GL_TEXTURE) { - const struct gl_texture_object *texObj = att->Texture; - struct gl_texture_image *texImage; - GLenum baseFormat; - - if (!texObj) { - att_incomplete("no texobj"); - att->Complete = GL_FALSE; - return; - } - - texImage = texObj->Image[att->CubeMapFace][att->TextureLevel]; - if (!texImage) { - att_incomplete("no teximage"); - att->Complete = GL_FALSE; - return; - } - if (texImage->Width < 1 || texImage->Height < 1) { - att_incomplete("teximage width/height=0"); - printf("texobj = %u\n", texObj->Name); - printf("level = %d\n", att->TextureLevel); - att->Complete = GL_FALSE; - return; - } - if (texObj->Target == GL_TEXTURE_3D && att->Zoffset >= texImage->Depth) { - att_incomplete("bad z offset"); - att->Complete = GL_FALSE; - return; - } - - baseFormat = _mesa_get_format_base_format(texImage->TexFormat); - - if (format == GL_COLOR) { - if (!_mesa_is_legal_color_format(ctx, baseFormat)) { - att_incomplete("bad format"); - att->Complete = GL_FALSE; - return; - } - if (_mesa_is_format_compressed(texImage->TexFormat)) { - att_incomplete("compressed internalformat"); - att->Complete = GL_FALSE; - return; - } - } - else if (format == GL_DEPTH) { - if (baseFormat == GL_DEPTH_COMPONENT) { - /* OK */ - } - else if (ctx->Extensions.EXT_packed_depth_stencil && - ctx->Extensions.ARB_depth_texture && - baseFormat == GL_DEPTH_STENCIL_EXT) { - /* OK */ - } - else { - att->Complete = GL_FALSE; - att_incomplete("bad depth format"); - return; - } - } - else { - ASSERT(format == GL_STENCIL); - if (ctx->Extensions.EXT_packed_depth_stencil && - ctx->Extensions.ARB_depth_texture && - baseFormat == GL_DEPTH_STENCIL_EXT) { - /* OK */ - } - else { - /* no such thing as stencil-only textures */ - att_incomplete("illegal stencil texture"); - att->Complete = GL_FALSE; - return; - } - } - } - else if (att->Type == GL_RENDERBUFFER_EXT) { - const GLenum baseFormat = - _mesa_get_format_base_format(att->Renderbuffer->Format); - - ASSERT(att->Renderbuffer); - if (!att->Renderbuffer->InternalFormat || - att->Renderbuffer->Width < 1 || - att->Renderbuffer->Height < 1) { - att_incomplete("0x0 renderbuffer"); - att->Complete = GL_FALSE; - return; - } - if (format == GL_COLOR) { - if (!_mesa_is_legal_color_format(ctx, baseFormat)) { - att_incomplete("bad renderbuffer color format"); - att->Complete = GL_FALSE; - return; - } - } - else if (format == GL_DEPTH) { - if (baseFormat == GL_DEPTH_COMPONENT) { - /* OK */ - } - else if (ctx->Extensions.EXT_packed_depth_stencil && - baseFormat == GL_DEPTH_STENCIL_EXT) { - /* OK */ - } - else { - att_incomplete("bad renderbuffer depth format"); - att->Complete = GL_FALSE; - return; - } - } - else { - assert(format == GL_STENCIL); - if (baseFormat == GL_STENCIL_INDEX) { - /* OK */ - } - else if (ctx->Extensions.EXT_packed_depth_stencil && - baseFormat == GL_DEPTH_STENCIL_EXT) { - /* OK */ - } - else { - att->Complete = GL_FALSE; - att_incomplete("bad renderbuffer stencil format"); - return; - } - } - } - else { - ASSERT(att->Type == GL_NONE); - /* complete */ - return; - } -} - - -/** - * Test if the given framebuffer object is complete and update its - * Status field with the results. - * Calls the ctx->Driver.ValidateFramebuffer() function to allow the - * driver to make hardware-specific validation/completeness checks. - * Also update the framebuffer's Width and Height fields if the - * framebuffer is complete. - */ -void -_mesa_test_framebuffer_completeness(struct gl_context *ctx, - struct gl_framebuffer *fb) -{ - GLuint numImages; - GLenum intFormat = GL_NONE; /* color buffers' internal format */ - GLuint minWidth = ~0, minHeight = ~0, maxWidth = 0, maxHeight = 0; - GLint numSamples = -1; - GLint i; - GLuint j; - - assert(is_user_fbo(fb)); - - numImages = 0; - fb->Width = 0; - fb->Height = 0; - - /* Start at -2 to more easily loop over all attachment points. - * -2: depth buffer - * -1: stencil buffer - * >=0: color buffer - */ - for (i = -2; i < (GLint) ctx->Const.MaxColorAttachments; i++) { - struct gl_renderbuffer_attachment *att; - GLenum f; - gl_format attFormat; - - /* - * XXX for ARB_fbo, only check color buffers that are named by - * GL_READ_BUFFER and GL_DRAW_BUFFERi. - */ - - /* check for attachment completeness - */ - if (i == -2) { - att = &fb->Attachment[BUFFER_DEPTH]; - test_attachment_completeness(ctx, GL_DEPTH, att); - if (!att->Complete) { - fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT; - fbo_incomplete("depth attachment incomplete", -1); - return; - } - } - else if (i == -1) { - att = &fb->Attachment[BUFFER_STENCIL]; - test_attachment_completeness(ctx, GL_STENCIL, att); - if (!att->Complete) { - fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT; - fbo_incomplete("stencil attachment incomplete", -1); - return; - } - } - else { - att = &fb->Attachment[BUFFER_COLOR0 + i]; - test_attachment_completeness(ctx, GL_COLOR, att); - if (!att->Complete) { - fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT; - fbo_incomplete("color attachment incomplete", i); - return; - } - } - - /* get width, height, format of the renderbuffer/texture - */ - if (att->Type == GL_TEXTURE) { - const struct gl_texture_image *texImg = - _mesa_get_attachment_teximage(att); - minWidth = MIN2(minWidth, texImg->Width); - maxWidth = MAX2(maxWidth, texImg->Width); - minHeight = MIN2(minHeight, texImg->Height); - maxHeight = MAX2(maxHeight, texImg->Height); - f = texImg->_BaseFormat; - attFormat = texImg->TexFormat; - numImages++; - if (!_mesa_is_legal_color_format(ctx, f) && - !is_legal_depth_format(ctx, f)) { - fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT; - fbo_incomplete("texture attachment incomplete", -1); - return; - } - } - else if (att->Type == GL_RENDERBUFFER_EXT) { - minWidth = MIN2(minWidth, att->Renderbuffer->Width); - maxWidth = MAX2(minWidth, att->Renderbuffer->Width); - minHeight = MIN2(minHeight, att->Renderbuffer->Height); - maxHeight = MAX2(minHeight, att->Renderbuffer->Height); - f = att->Renderbuffer->InternalFormat; - attFormat = att->Renderbuffer->Format; - numImages++; - } - else { - assert(att->Type == GL_NONE); - continue; - } - - if (att->Renderbuffer && numSamples < 0) { - /* first buffer */ - numSamples = att->Renderbuffer->NumSamples; - } - - /* check if integer color */ - fb->_IntegerColor = _mesa_is_format_integer_color(attFormat); - - /* Error-check width, height, format, samples - */ - if (numImages == 1) { - /* save format, num samples */ - if (i >= 0) { - intFormat = f; - } - } - else { - if (!ctx->Extensions.ARB_framebuffer_object) { - /* check that width, height, format are same */ - if (minWidth != maxWidth || minHeight != maxHeight) { - fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT; - fbo_incomplete("width or height mismatch", -1); - return; - } - /* check that all color buffer have same format */ - if (intFormat != GL_NONE && f != intFormat) { - fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT; - fbo_incomplete("format mismatch", -1); - return; - } - } - if (att->Renderbuffer && - att->Renderbuffer->NumSamples != numSamples) { - fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE; - fbo_incomplete("inconsistant number of samples", i); - return; - } - - } - } - -#if FEATURE_GL - if (ctx->API == API_OPENGL && !ctx->Extensions.ARB_ES2_compatibility) { - /* Check that all DrawBuffers are present */ - for (j = 0; j < ctx->Const.MaxDrawBuffers; j++) { - if (fb->ColorDrawBuffer[j] != GL_NONE) { - const struct gl_renderbuffer_attachment *att - = _mesa_get_attachment(ctx, fb, fb->ColorDrawBuffer[j]); - assert(att); - if (att->Type == GL_NONE) { - fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT; - fbo_incomplete("missing drawbuffer", j); - return; - } - } - } - - /* Check that the ReadBuffer is present */ - if (fb->ColorReadBuffer != GL_NONE) { - const struct gl_renderbuffer_attachment *att - = _mesa_get_attachment(ctx, fb, fb->ColorReadBuffer); - assert(att); - if (att->Type == GL_NONE) { - fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT; - fbo_incomplete("missing readbuffer", -1); - return; - } - } - } -#else - (void) j; -#endif - - if (numImages == 0) { - fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT; - fbo_incomplete("no attachments", -1); - return; - } - - /* Provisionally set status = COMPLETE ... */ - fb->_Status = GL_FRAMEBUFFER_COMPLETE_EXT; - - /* ... but the driver may say the FB is incomplete. - * Drivers will most likely set the status to GL_FRAMEBUFFER_UNSUPPORTED - * if anything. - */ - if (ctx->Driver.ValidateFramebuffer) { - ctx->Driver.ValidateFramebuffer(ctx, fb); - if (fb->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) { - fbo_incomplete("driver marked FBO as incomplete", -1); - } - } - - if (fb->_Status == GL_FRAMEBUFFER_COMPLETE_EXT) { - /* - * Note that if ARB_framebuffer_object is supported and the attached - * renderbuffers/textures are different sizes, the framebuffer - * width/height will be set to the smallest width/height. - */ - fb->Width = minWidth; - fb->Height = minHeight; - - /* finally, update the visual info for the framebuffer */ - _mesa_update_framebuffer_visual(ctx, fb); - } -} - - -GLboolean GLAPIENTRY -_mesa_IsRenderbufferEXT(GLuint renderbuffer) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); - if (renderbuffer) { - struct gl_renderbuffer *rb = _mesa_lookup_renderbuffer(ctx, renderbuffer); - if (rb != NULL && rb != &DummyRenderbuffer) - return GL_TRUE; - } - return GL_FALSE; -} - - -void GLAPIENTRY -_mesa_BindRenderbufferEXT(GLenum target, GLuint renderbuffer) -{ - struct gl_renderbuffer *newRb; - GET_CURRENT_CONTEXT(ctx); - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (target != GL_RENDERBUFFER_EXT) { - _mesa_error(ctx, GL_INVALID_ENUM, "glBindRenderbufferEXT(target)"); - return; - } - - /* No need to flush here since the render buffer binding has no - * effect on rendering state. - */ - - if (renderbuffer) { - newRb = _mesa_lookup_renderbuffer(ctx, renderbuffer); - if (newRb == &DummyRenderbuffer) { - /* ID was reserved, but no real renderbuffer object made yet */ - newRb = NULL; - } - else if (!newRb && ctx->Extensions.ARB_framebuffer_object) { - /* All RB IDs must be Gen'd */ - _mesa_error(ctx, GL_INVALID_OPERATION, "glBindRenderbuffer(buffer)"); - return; - } - - if (!newRb) { - /* create new renderbuffer object */ - newRb = ctx->Driver.NewRenderbuffer(ctx, renderbuffer); - if (!newRb) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindRenderbufferEXT"); - return; - } - ASSERT(newRb->AllocStorage); - _mesa_HashInsert(ctx->Shared->RenderBuffers, renderbuffer, newRb); - newRb->RefCount = 1; /* referenced by hash table */ - } - } - else { - newRb = NULL; - } - - ASSERT(newRb != &DummyRenderbuffer); - - _mesa_reference_renderbuffer(&ctx->CurrentRenderbuffer, newRb); -} - - -/** - * If the given renderbuffer is anywhere attached to the framebuffer, detach - * the renderbuffer. - * This is used when a renderbuffer object is deleted. - * The spec calls for unbinding. - */ -static void -detach_renderbuffer(struct gl_context *ctx, - struct gl_framebuffer *fb, - struct gl_renderbuffer *rb) -{ - GLuint i; - for (i = 0; i < BUFFER_COUNT; i++) { - if (fb->Attachment[i].Renderbuffer == rb) { - _mesa_remove_attachment(ctx, &fb->Attachment[i]); - } - } - invalidate_framebuffer(fb); -} - - -void GLAPIENTRY -_mesa_DeleteRenderbuffersEXT(GLsizei n, const GLuint *renderbuffers) -{ - GLint i; - GET_CURRENT_CONTEXT(ctx); - - ASSERT_OUTSIDE_BEGIN_END(ctx); - FLUSH_VERTICES(ctx, _NEW_BUFFERS); - - for (i = 0; i < n; i++) { - if (renderbuffers[i] > 0) { - struct gl_renderbuffer *rb; - rb = _mesa_lookup_renderbuffer(ctx, renderbuffers[i]); - if (rb) { - /* check if deleting currently bound renderbuffer object */ - if (rb == ctx->CurrentRenderbuffer) { - /* bind default */ - ASSERT(rb->RefCount >= 2); - _mesa_BindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0); - } - - if (is_user_fbo(ctx->DrawBuffer)) { - detach_renderbuffer(ctx, ctx->DrawBuffer, rb); - } - if (is_user_fbo(ctx->ReadBuffer) - && ctx->ReadBuffer != ctx->DrawBuffer) { - detach_renderbuffer(ctx, ctx->ReadBuffer, rb); - } - - /* Remove from hash table immediately, to free the ID. - * But the object will not be freed until it's no longer - * referenced anywhere else. - */ - _mesa_HashRemove(ctx->Shared->RenderBuffers, renderbuffers[i]); - - if (rb != &DummyRenderbuffer) { - /* no longer referenced by hash table */ - _mesa_reference_renderbuffer(&rb, NULL); - } - } - } - } -} - - -void GLAPIENTRY -_mesa_GenRenderbuffersEXT(GLsizei n, GLuint *renderbuffers) -{ - GET_CURRENT_CONTEXT(ctx); - GLuint first; - GLint i; - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (n < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glGenRenderbuffersEXT(n)"); - return; - } - - if (!renderbuffers) - return; - - first = _mesa_HashFindFreeKeyBlock(ctx->Shared->RenderBuffers, n); - - for (i = 0; i < n; i++) { - GLuint name = first + i; - renderbuffers[i] = name; - /* insert dummy placeholder into hash table */ - _glthread_LOCK_MUTEX(ctx->Shared->Mutex); - _mesa_HashInsert(ctx->Shared->RenderBuffers, name, &DummyRenderbuffer); - _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); - } -} - - -/** - * Given an internal format token for a render buffer, return the - * corresponding base format (one of GL_RGB, GL_RGBA, GL_STENCIL_INDEX, - * GL_DEPTH_COMPONENT, GL_DEPTH_STENCIL_EXT, GL_ALPHA, GL_LUMINANCE, - * GL_LUMINANCE_ALPHA, GL_INTENSITY, etc). - * - * This is similar to _mesa_base_tex_format() but the set of valid - * internal formats is different. - * - * Note that even if a format is determined to be legal here, validation - * of the FBO may fail if the format is not supported by the driver/GPU. - * - * \param internalFormat as passed to glRenderbufferStorage() - * \return the base internal format, or 0 if internalFormat is illegal - */ -GLenum -_mesa_base_fbo_format(struct gl_context *ctx, GLenum internalFormat) -{ - /* - * Notes: some formats such as alpha, luminance, etc. were added - * with GL_ARB_framebuffer_object. - */ - switch (internalFormat) { - case GL_ALPHA: - case GL_ALPHA4: - case GL_ALPHA8: - case GL_ALPHA12: - case GL_ALPHA16: - return ctx->Extensions.ARB_framebuffer_object ? GL_ALPHA : 0; - case GL_LUMINANCE: - case GL_LUMINANCE4: - case GL_LUMINANCE8: - case GL_LUMINANCE12: - case GL_LUMINANCE16: - return ctx->Extensions.ARB_framebuffer_object ? GL_LUMINANCE : 0; - case GL_LUMINANCE_ALPHA: - case GL_LUMINANCE4_ALPHA4: - case GL_LUMINANCE6_ALPHA2: - case GL_LUMINANCE8_ALPHA8: - case GL_LUMINANCE12_ALPHA4: - case GL_LUMINANCE12_ALPHA12: - case GL_LUMINANCE16_ALPHA16: - return ctx->Extensions.ARB_framebuffer_object ? GL_LUMINANCE_ALPHA : 0; - case GL_INTENSITY: - case GL_INTENSITY4: - case GL_INTENSITY8: - case GL_INTENSITY12: - case GL_INTENSITY16: - return ctx->Extensions.ARB_framebuffer_object ? GL_INTENSITY : 0; - case GL_RGB: - case GL_R3_G3_B2: - case GL_RGB4: - case GL_RGB5: - case GL_RGB8: - case GL_RGB10: - case GL_RGB12: - case GL_RGB16: - case GL_SRGB8_EXT: - return GL_RGB; - case GL_RGBA: - case GL_RGBA2: - case GL_RGBA4: - case GL_RGB5_A1: - case GL_RGBA8: - case GL_RGB10_A2: - case GL_RGBA12: - case GL_RGBA16: - case GL_SRGB8_ALPHA8_EXT: - return GL_RGBA; - case GL_STENCIL_INDEX: - case GL_STENCIL_INDEX1_EXT: - case GL_STENCIL_INDEX4_EXT: - case GL_STENCIL_INDEX8_EXT: - case GL_STENCIL_INDEX16_EXT: - return GL_STENCIL_INDEX; - case GL_DEPTH_COMPONENT: - case GL_DEPTH_COMPONENT16: - case GL_DEPTH_COMPONENT24: - case GL_DEPTH_COMPONENT32: - return GL_DEPTH_COMPONENT; - case GL_DEPTH_STENCIL_EXT: - case GL_DEPTH24_STENCIL8_EXT: - if (ctx->Extensions.EXT_packed_depth_stencil) - return GL_DEPTH_STENCIL_EXT; - else - return 0; - case GL_DEPTH_COMPONENT32F: - if (ctx->Extensions.ARB_depth_buffer_float) - return GL_DEPTH_COMPONENT; - else - return 0; - case GL_DEPTH32F_STENCIL8: - if (ctx->Extensions.ARB_depth_buffer_float) - return GL_DEPTH_STENCIL; - else - return 0; - case GL_RED: - case GL_R8: - case GL_R16: - return ctx->Extensions.ARB_texture_rg ? GL_RED : 0; - case GL_RG: - case GL_RG8: - case GL_RG16: - return ctx->Extensions.ARB_texture_rg ? GL_RG : 0; - /* signed normalized texture formats */ - case GL_RED_SNORM: - case GL_R8_SNORM: - case GL_R16_SNORM: - return ctx->Extensions.EXT_texture_snorm ? GL_RED : 0; - case GL_RG_SNORM: - case GL_RG8_SNORM: - case GL_RG16_SNORM: - return ctx->Extensions.EXT_texture_snorm ? GL_RG : 0; - case GL_RGB_SNORM: - case GL_RGB8_SNORM: - case GL_RGB16_SNORM: - return ctx->Extensions.EXT_texture_snorm ? GL_RGB : 0; - case GL_RGBA_SNORM: - case GL_RGBA8_SNORM: - case GL_RGBA16_SNORM: - return ctx->Extensions.EXT_texture_snorm ? GL_RGBA : 0; - case GL_ALPHA_SNORM: - case GL_ALPHA8_SNORM: - case GL_ALPHA16_SNORM: - return ctx->Extensions.EXT_texture_snorm && - ctx->Extensions.ARB_framebuffer_object ? GL_ALPHA : 0; - case GL_LUMINANCE_SNORM: - case GL_LUMINANCE8_SNORM: - case GL_LUMINANCE16_SNORM: - return ctx->Extensions.EXT_texture_snorm && - ctx->Extensions.ARB_framebuffer_object ? GL_LUMINANCE : 0; - case GL_LUMINANCE_ALPHA_SNORM: - case GL_LUMINANCE8_ALPHA8_SNORM: - case GL_LUMINANCE16_ALPHA16_SNORM: - return ctx->Extensions.EXT_texture_snorm && - ctx->Extensions.ARB_framebuffer_object ? GL_LUMINANCE_ALPHA : 0; - case GL_INTENSITY_SNORM: - case GL_INTENSITY8_SNORM: - case GL_INTENSITY16_SNORM: - return ctx->Extensions.EXT_texture_snorm && - ctx->Extensions.ARB_framebuffer_object ? GL_INTENSITY : 0; - case GL_R16F: - case GL_R32F: - return ctx->Extensions.ARB_texture_rg && - ctx->Extensions.ARB_texture_float ? GL_RED : 0; - case GL_RG16F: - case GL_RG32F: - return ctx->Extensions.ARB_texture_rg && - ctx->Extensions.ARB_texture_float ? GL_RG : 0; - case GL_RGB16F: - case GL_RGB32F: - return ctx->Extensions.ARB_texture_float ? GL_RGB : 0; - case GL_RGBA16F: - case GL_RGBA32F: - return ctx->Extensions.ARB_texture_float ? GL_RGBA : 0; - case GL_ALPHA16F_ARB: - case GL_ALPHA32F_ARB: - return ctx->Extensions.ARB_texture_float && - ctx->Extensions.ARB_framebuffer_object ? GL_ALPHA : 0; - case GL_LUMINANCE16F_ARB: - case GL_LUMINANCE32F_ARB: - return ctx->Extensions.ARB_texture_float && - ctx->Extensions.ARB_framebuffer_object ? GL_LUMINANCE : 0; - case GL_LUMINANCE_ALPHA16F_ARB: - case GL_LUMINANCE_ALPHA32F_ARB: - return ctx->Extensions.ARB_texture_float && - ctx->Extensions.ARB_framebuffer_object ? GL_LUMINANCE_ALPHA : 0; - case GL_INTENSITY16F_ARB: - case GL_INTENSITY32F_ARB: - return ctx->Extensions.ARB_texture_float && - ctx->Extensions.ARB_framebuffer_object ? GL_INTENSITY : 0; - case GL_RGB9_E5: - return ctx->Extensions.EXT_texture_shared_exponent ? GL_RGB : 0; - case GL_R11F_G11F_B10F: - return ctx->Extensions.EXT_packed_float ? GL_RGB : 0; - /* XXX add integer formats eventually */ - default: - return 0; - } -} - - -/** - * Invalidate a renderbuffer attachment. Called from _mesa_HashWalk(). - */ -static void -invalidate_rb(GLuint key, void *data, void *userData) -{ - struct gl_framebuffer *fb = (struct gl_framebuffer *) data; - struct gl_renderbuffer *rb = (struct gl_renderbuffer *) userData; - - /* If this is a user-created FBO */ - if (is_user_fbo(fb)) { - GLuint i; - for (i = 0; i < BUFFER_COUNT; i++) { - struct gl_renderbuffer_attachment *att = fb->Attachment + i; - if (att->Type == GL_RENDERBUFFER && - att->Renderbuffer == rb) { - /* Mark fb status as indeterminate to force re-validation */ - fb->_Status = 0; - return; - } - } - } -} - - -/** sentinal value, see below */ -#define NO_SAMPLES 1000 - - -/** - * Helper function used by _mesa_RenderbufferStorageEXT() and - * _mesa_RenderbufferStorageMultisample(). - * samples will be NO_SAMPLES if called by _mesa_RenderbufferStorageEXT(). - */ -static void -renderbuffer_storage(GLenum target, GLenum internalFormat, - GLsizei width, GLsizei height, GLsizei samples) -{ - const char *func = samples == NO_SAMPLES ? - "glRenderbufferStorage" : "RenderbufferStorageMultisample"; - struct gl_renderbuffer *rb; - GLenum baseFormat; - GET_CURRENT_CONTEXT(ctx); - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (target != GL_RENDERBUFFER_EXT) { - _mesa_error(ctx, GL_INVALID_ENUM, "%s(target)", func); - return; - } - - baseFormat = _mesa_base_fbo_format(ctx, internalFormat); - if (baseFormat == 0) { - _mesa_error(ctx, GL_INVALID_ENUM, "%s(internalFormat)", func); - return; - } - - if (width < 1 || width > (GLsizei) ctx->Const.MaxRenderbufferSize) { - _mesa_error(ctx, GL_INVALID_VALUE, "%s(width)", func); - return; - } - - if (height < 1 || height > (GLsizei) ctx->Const.MaxRenderbufferSize) { - _mesa_error(ctx, GL_INVALID_VALUE, "%s(height)", func); - return; - } - - if (samples == NO_SAMPLES) { - /* NumSamples == 0 indicates non-multisampling */ - samples = 0; - } - else if (samples > (GLsizei) ctx->Const.MaxSamples) { - /* note: driver may choose to use more samples than what's requested */ - _mesa_error(ctx, GL_INVALID_VALUE, "%s(samples)", func); - return; - } - - rb = ctx->CurrentRenderbuffer; - if (!rb) { - _mesa_error(ctx, GL_INVALID_OPERATION, "%s", func); - return; - } - - FLUSH_VERTICES(ctx, _NEW_BUFFERS); - - if (rb->InternalFormat == internalFormat && - rb->Width == (GLuint) width && - rb->Height == (GLuint) height) { - /* no change in allocation needed */ - return; - } - - /* These MUST get set by the AllocStorage func */ - rb->Format = MESA_FORMAT_NONE; - rb->NumSamples = samples; - - /* Now allocate the storage */ - ASSERT(rb->AllocStorage); - if (rb->AllocStorage(ctx, rb, internalFormat, width, height)) { - /* No error - check/set fields now */ - assert(rb->Format != MESA_FORMAT_NONE); - assert(rb->Width == (GLuint) width); - assert(rb->Height == (GLuint) height); - rb->InternalFormat = internalFormat; - rb->_BaseFormat = baseFormat; - assert(rb->_BaseFormat != 0); - } - else { - /* Probably ran out of memory - clear the fields */ - rb->Width = 0; - rb->Height = 0; - rb->Format = MESA_FORMAT_NONE; - rb->InternalFormat = GL_NONE; - rb->_BaseFormat = GL_NONE; - rb->NumSamples = 0; - } - - /* Invalidate the framebuffers the renderbuffer is attached in. */ - if (rb->AttachedAnytime) { - _mesa_HashWalk(ctx->Shared->FrameBuffers, invalidate_rb, rb); - } -} - - -#if FEATURE_OES_EGL_image -void GLAPIENTRY -_mesa_EGLImageTargetRenderbufferStorageOES(GLenum target, GLeglImageOES image) -{ - struct gl_renderbuffer *rb; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (!ctx->Extensions.OES_EGL_image) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glEGLImageTargetRenderbufferStorageOES(unsupported)"); - return; - } - - if (target != GL_RENDERBUFFER) { - _mesa_error(ctx, GL_INVALID_ENUM, - "EGLImageTargetRenderbufferStorageOES"); - return; - } - - rb = ctx->CurrentRenderbuffer; - if (!rb) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "EGLImageTargetRenderbufferStorageOES"); - return; - } - - FLUSH_VERTICES(ctx, _NEW_BUFFERS); - - ctx->Driver.EGLImageTargetRenderbufferStorage(ctx, rb, image); -} -#endif - - -/** - * Helper function for _mesa_GetRenderbufferParameterivEXT() and - * _mesa_GetFramebufferAttachmentParameterivEXT() - * We have to be careful to respect the base format. For example, if a - * renderbuffer/texture was created with internalFormat=GL_RGB but the - * driver actually chose a GL_RGBA format, when the user queries ALPHA_SIZE - * we need to return zero. - */ -static GLint -get_component_bits(GLenum pname, GLenum baseFormat, gl_format format) -{ - switch (pname) { - case GL_RENDERBUFFER_RED_SIZE_EXT: - case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE: - if (baseFormat == GL_RGB || baseFormat == GL_RGBA || - baseFormat == GL_RG || baseFormat == GL_RED) - return _mesa_get_format_bits(format, pname); - else - return 0; - case GL_RENDERBUFFER_GREEN_SIZE_EXT: - case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE: - if (baseFormat == GL_RGB || baseFormat == GL_RGBA || baseFormat == GL_RG) - return _mesa_get_format_bits(format, pname); - else - return 0; - case GL_RENDERBUFFER_BLUE_SIZE_EXT: - case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE: - if (baseFormat == GL_RGB || baseFormat == GL_RGBA) - return _mesa_get_format_bits(format, pname); - else - return 0; - case GL_RENDERBUFFER_ALPHA_SIZE_EXT: - case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE: - if (baseFormat == GL_RGBA || baseFormat == GL_ALPHA || - baseFormat == GL_LUMINANCE_ALPHA) - return _mesa_get_format_bits(format, pname); - else - return 0; - case GL_RENDERBUFFER_DEPTH_SIZE_EXT: - case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE: - if (baseFormat == GL_DEPTH_COMPONENT || baseFormat == GL_DEPTH_STENCIL) - return _mesa_get_format_bits(format, pname); - else - return 0; - case GL_RENDERBUFFER_STENCIL_SIZE_EXT: - case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE: - if (baseFormat == GL_STENCIL_INDEX || baseFormat == GL_DEPTH_STENCIL) - return _mesa_get_format_bits(format, pname); - else - return 0; - default: - return 0; - } -} - - - -void GLAPIENTRY -_mesa_RenderbufferStorageEXT(GLenum target, GLenum internalFormat, - GLsizei width, GLsizei height) -{ - /* GL_ARB_fbo says calling this function is equivalent to calling - * glRenderbufferStorageMultisample() with samples=0. We pass in - * a token value here just for error reporting purposes. - */ - renderbuffer_storage(target, internalFormat, width, height, NO_SAMPLES); -} - - -void GLAPIENTRY -_mesa_RenderbufferStorageMultisample(GLenum target, GLsizei samples, - GLenum internalFormat, - GLsizei width, GLsizei height) -{ - renderbuffer_storage(target, internalFormat, width, height, samples); -} - - -/** - * OpenGL ES version of glRenderBufferStorage. - */ -void GLAPIENTRY -_es_RenderbufferStorageEXT(GLenum target, GLenum internalFormat, - GLsizei width, GLsizei height) -{ - switch (internalFormat) { - case GL_RGB565: - /* XXX this confuses GL_RENDERBUFFER_INTERNAL_FORMAT_OES */ - /* choose a closest format */ - internalFormat = GL_RGB5; - break; - default: - break; - } - - renderbuffer_storage(target, internalFormat, width, height, 0); -} - - -void GLAPIENTRY -_mesa_GetRenderbufferParameterivEXT(GLenum target, GLenum pname, GLint *params) -{ - struct gl_renderbuffer *rb; - GET_CURRENT_CONTEXT(ctx); - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (target != GL_RENDERBUFFER_EXT) { - _mesa_error(ctx, GL_INVALID_ENUM, - "glGetRenderbufferParameterivEXT(target)"); - return; - } - - rb = ctx->CurrentRenderbuffer; - if (!rb) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetRenderbufferParameterivEXT"); - return; - } - - /* No need to flush here since we're just quering state which is - * not effected by rendering. - */ - - switch (pname) { - case GL_RENDERBUFFER_WIDTH_EXT: - *params = rb->Width; - return; - case GL_RENDERBUFFER_HEIGHT_EXT: - *params = rb->Height; - return; - case GL_RENDERBUFFER_INTERNAL_FORMAT_EXT: - *params = rb->InternalFormat; - return; - case GL_RENDERBUFFER_RED_SIZE_EXT: - case GL_RENDERBUFFER_GREEN_SIZE_EXT: - case GL_RENDERBUFFER_BLUE_SIZE_EXT: - case GL_RENDERBUFFER_ALPHA_SIZE_EXT: - case GL_RENDERBUFFER_DEPTH_SIZE_EXT: - case GL_RENDERBUFFER_STENCIL_SIZE_EXT: - *params = get_component_bits(pname, rb->_BaseFormat, rb->Format); - break; - case GL_RENDERBUFFER_SAMPLES: - if (ctx->Extensions.ARB_framebuffer_object) { - *params = rb->NumSamples; - break; - } - /* fallthrough */ - default: - _mesa_error(ctx, GL_INVALID_ENUM, - "glGetRenderbufferParameterivEXT(target)"); - return; - } -} - - -GLboolean GLAPIENTRY -_mesa_IsFramebufferEXT(GLuint framebuffer) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); - if (framebuffer) { - struct gl_framebuffer *rb = _mesa_lookup_framebuffer(ctx, framebuffer); - if (rb != NULL && rb != &DummyFramebuffer) - return GL_TRUE; - } - return GL_FALSE; -} - - -/** - * Check if any of the attachments of the given framebuffer are textures - * (render to texture). Call ctx->Driver.RenderTexture() for such - * attachments. - */ -static void -check_begin_texture_render(struct gl_context *ctx, struct gl_framebuffer *fb) -{ - GLuint i; - ASSERT(ctx->Driver.RenderTexture); - - if (is_winsys_fbo(fb)) - return; /* can't render to texture with winsys framebuffers */ - - for (i = 0; i < BUFFER_COUNT; i++) { - struct gl_renderbuffer_attachment *att = fb->Attachment + i; - if (att->Texture && _mesa_get_attachment_teximage(att)) { - ctx->Driver.RenderTexture(ctx, fb, att); - } - } -} - - -/** - * Examine all the framebuffer's attachments to see if any are textures. - * If so, call ctx->Driver.FinishRenderTexture() for each texture to - * notify the device driver that the texture image may have changed. - */ -static void -check_end_texture_render(struct gl_context *ctx, struct gl_framebuffer *fb) -{ - if (is_winsys_fbo(fb)) - return; /* can't render to texture with winsys framebuffers */ - - if (ctx->Driver.FinishRenderTexture) { - GLuint i; - for (i = 0; i < BUFFER_COUNT; i++) { - struct gl_renderbuffer_attachment *att = fb->Attachment + i; - if (att->Texture && att->Renderbuffer) { - ctx->Driver.FinishRenderTexture(ctx, att); - } - } - } -} - - -void GLAPIENTRY -_mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer) -{ - struct gl_framebuffer *newDrawFb, *newReadFb; - struct gl_framebuffer *oldDrawFb, *oldReadFb; - GLboolean bindReadBuf, bindDrawBuf; - GET_CURRENT_CONTEXT(ctx); - -#ifdef DEBUG - if (ctx->Extensions.ARB_framebuffer_object) { - ASSERT(ctx->Extensions.EXT_framebuffer_object); - ASSERT(ctx->Extensions.EXT_framebuffer_blit); - } -#endif - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (!ctx->Extensions.EXT_framebuffer_object) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glBindFramebufferEXT(unsupported)"); - return; - } - - switch (target) { -#if FEATURE_EXT_framebuffer_blit - case GL_DRAW_FRAMEBUFFER_EXT: - if (!ctx->Extensions.EXT_framebuffer_blit) { - _mesa_error(ctx, GL_INVALID_ENUM, "glBindFramebufferEXT(target)"); - return; - } - bindDrawBuf = GL_TRUE; - bindReadBuf = GL_FALSE; - break; - case GL_READ_FRAMEBUFFER_EXT: - if (!ctx->Extensions.EXT_framebuffer_blit) { - _mesa_error(ctx, GL_INVALID_ENUM, "glBindFramebufferEXT(target)"); - return; - } - bindDrawBuf = GL_FALSE; - bindReadBuf = GL_TRUE; - break; -#endif - case GL_FRAMEBUFFER_EXT: - bindDrawBuf = GL_TRUE; - bindReadBuf = GL_TRUE; - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glBindFramebufferEXT(target)"); - return; - } - - if (framebuffer) { - /* Binding a user-created framebuffer object */ - newDrawFb = _mesa_lookup_framebuffer(ctx, framebuffer); - if (newDrawFb == &DummyFramebuffer) { - /* ID was reserved, but no real framebuffer object made yet */ - newDrawFb = NULL; - } - else if (!newDrawFb && ctx->Extensions.ARB_framebuffer_object) { - /* All FBO IDs must be Gen'd */ - _mesa_error(ctx, GL_INVALID_OPERATION, "glBindFramebuffer(buffer)"); - return; - } - - if (!newDrawFb) { - /* create new framebuffer object */ - newDrawFb = ctx->Driver.NewFramebuffer(ctx, framebuffer); - if (!newDrawFb) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindFramebufferEXT"); - return; - } - _mesa_HashInsert(ctx->Shared->FrameBuffers, framebuffer, newDrawFb); - } - newReadFb = newDrawFb; - } - else { - /* Binding the window system framebuffer (which was originally set - * with MakeCurrent). - */ - newDrawFb = ctx->WinSysDrawBuffer; - newReadFb = ctx->WinSysReadBuffer; - } - - ASSERT(newDrawFb); - ASSERT(newDrawFb != &DummyFramebuffer); - - /* save pointers to current/old framebuffers */ - oldDrawFb = ctx->DrawBuffer; - oldReadFb = ctx->ReadBuffer; - - /* check if really changing bindings */ - if (oldDrawFb == newDrawFb) - bindDrawBuf = GL_FALSE; - if (oldReadFb == newReadFb) - bindReadBuf = GL_FALSE; - - /* - * OK, now bind the new Draw/Read framebuffers, if they're changing. - * - * We also check if we're beginning and/or ending render-to-texture. - * When a framebuffer with texture attachments is unbound, call - * ctx->Driver.FinishRenderTexture(). - * When a framebuffer with texture attachments is bound, call - * ctx->Driver.RenderTexture(). - * - * Note that if the ReadBuffer has texture attachments we don't consider - * that a render-to-texture case. - */ - if (bindReadBuf) { - FLUSH_VERTICES(ctx, _NEW_BUFFERS); - - /* check if old readbuffer was render-to-texture */ - check_end_texture_render(ctx, oldReadFb); - - _mesa_reference_framebuffer(&ctx->ReadBuffer, newReadFb); - } - - if (bindDrawBuf) { - FLUSH_VERTICES(ctx, _NEW_BUFFERS); - - /* check if old read/draw buffers were render-to-texture */ - if (!bindReadBuf) - check_end_texture_render(ctx, oldReadFb); - - if (oldDrawFb != oldReadFb) - check_end_texture_render(ctx, oldDrawFb); - - /* check if newly bound framebuffer has any texture attachments */ - check_begin_texture_render(ctx, newDrawFb); - - _mesa_reference_framebuffer(&ctx->DrawBuffer, newDrawFb); - } - - if ((bindDrawBuf || bindReadBuf) && ctx->Driver.BindFramebuffer) { - ctx->Driver.BindFramebuffer(ctx, target, newDrawFb, newReadFb); - } -} - - -void GLAPIENTRY -_mesa_DeleteFramebuffersEXT(GLsizei n, const GLuint *framebuffers) -{ - GLint i; - GET_CURRENT_CONTEXT(ctx); - - ASSERT_OUTSIDE_BEGIN_END(ctx); - FLUSH_VERTICES(ctx, _NEW_BUFFERS); - - for (i = 0; i < n; i++) { - if (framebuffers[i] > 0) { - struct gl_framebuffer *fb; - fb = _mesa_lookup_framebuffer(ctx, framebuffers[i]); - if (fb) { - ASSERT(fb == &DummyFramebuffer || fb->Name == framebuffers[i]); - - /* check if deleting currently bound framebuffer object */ - if (ctx->Extensions.EXT_framebuffer_blit) { - /* separate draw/read binding points */ - if (fb == ctx->DrawBuffer) { - /* bind default */ - ASSERT(fb->RefCount >= 2); - _mesa_BindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, 0); - } - if (fb == ctx->ReadBuffer) { - /* bind default */ - ASSERT(fb->RefCount >= 2); - _mesa_BindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, 0); - } - } - else { - /* only one binding point for read/draw buffers */ - if (fb == ctx->DrawBuffer || fb == ctx->ReadBuffer) { - /* bind default */ - ASSERT(fb->RefCount >= 2); - _mesa_BindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); - } - } - - /* remove from hash table immediately, to free the ID */ - _mesa_HashRemove(ctx->Shared->FrameBuffers, framebuffers[i]); - - if (fb != &DummyFramebuffer) { - /* But the object will not be freed until it's no longer - * bound in any context. - */ - _mesa_reference_framebuffer(&fb, NULL); - } - } - } - } -} - - -void GLAPIENTRY -_mesa_GenFramebuffersEXT(GLsizei n, GLuint *framebuffers) -{ - GET_CURRENT_CONTEXT(ctx); - GLuint first; - GLint i; - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (n < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glGenFramebuffersEXT(n)"); - return; - } - - if (!framebuffers) - return; - - first = _mesa_HashFindFreeKeyBlock(ctx->Shared->FrameBuffers, n); - - for (i = 0; i < n; i++) { - GLuint name = first + i; - framebuffers[i] = name; - /* insert dummy placeholder into hash table */ - _glthread_LOCK_MUTEX(ctx->Shared->Mutex); - _mesa_HashInsert(ctx->Shared->FrameBuffers, name, &DummyFramebuffer); - _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); - } -} - - - -GLenum GLAPIENTRY -_mesa_CheckFramebufferStatusEXT(GLenum target) -{ - struct gl_framebuffer *buffer; - GET_CURRENT_CONTEXT(ctx); - - ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, 0); - - buffer = get_framebuffer_target(ctx, target); - if (!buffer) { - _mesa_error(ctx, GL_INVALID_ENUM, "glCheckFramebufferStatus(target)"); - return 0; - } - - if (is_winsys_fbo(buffer)) { - /* The window system / default framebuffer is always complete */ - return GL_FRAMEBUFFER_COMPLETE_EXT; - } - - /* No need to flush here */ - - if (buffer->_Status != GL_FRAMEBUFFER_COMPLETE) { - _mesa_test_framebuffer_completeness(ctx, buffer); - } - - return buffer->_Status; -} - - - -/** - * Common code called by glFramebufferTexture1D/2D/3DEXT(). - */ -static void -framebuffer_texture(struct gl_context *ctx, const char *caller, GLenum target, - GLenum attachment, GLenum textarget, GLuint texture, - GLint level, GLint zoffset) -{ - struct gl_renderbuffer_attachment *att; - struct gl_texture_object *texObj = NULL; - struct gl_framebuffer *fb; - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - fb = get_framebuffer_target(ctx, target); - if (!fb) { - _mesa_error(ctx, GL_INVALID_ENUM, - "glFramebufferTexture%sEXT(target=0x%x)", caller, target); - return; - } - - /* check framebuffer binding */ - if (is_winsys_fbo(fb)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glFramebufferTexture%sEXT", caller); - return; - } - - - /* The textarget, level, and zoffset parameters are only validated if - * texture is non-zero. - */ - if (texture) { - GLboolean err = GL_TRUE; - - texObj = _mesa_lookup_texture(ctx, texture); - if (texObj != NULL) { - if (textarget == 0) { - /* XXX what's the purpose of this? */ - err = (texObj->Target != GL_TEXTURE_3D) && - (texObj->Target != GL_TEXTURE_1D_ARRAY_EXT) && - (texObj->Target != GL_TEXTURE_2D_ARRAY_EXT); - } - else { - err = (texObj->Target == GL_TEXTURE_CUBE_MAP) - ? !is_cube_face(textarget) - : (texObj->Target != textarget); - } - } - else { - /* can't render to a non-existant texture */ - _mesa_error(ctx, GL_INVALID_OPERATION, - "glFramebufferTexture%sEXT(non existant texture)", - caller); - return; - } - - if (err) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glFramebufferTexture%sEXT(texture target mismatch)", - caller); - return; - } - - if (texObj->Target == GL_TEXTURE_3D) { - const GLint maxSize = 1 << (ctx->Const.Max3DTextureLevels - 1); - if (zoffset < 0 || zoffset >= maxSize) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glFramebufferTexture%sEXT(zoffset)", caller); - return; - } - } - else if ((texObj->Target == GL_TEXTURE_1D_ARRAY_EXT) || - (texObj->Target == GL_TEXTURE_2D_ARRAY_EXT)) { - if (zoffset < 0 || zoffset >= ctx->Const.MaxArrayTextureLayers) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glFramebufferTexture%sEXT(layer)", caller); - return; - } - } - - if ((level < 0) || - (level >= _mesa_max_texture_levels(ctx, texObj->Target))) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glFramebufferTexture%sEXT(level)", caller); - return; - } - } - - att = _mesa_get_attachment(ctx, fb, attachment); - if (att == NULL) { - _mesa_error(ctx, GL_INVALID_ENUM, - "glFramebufferTexture%sEXT(attachment)", caller); - return; - } - - FLUSH_VERTICES(ctx, _NEW_BUFFERS); - - _glthread_LOCK_MUTEX(fb->Mutex); - if (texObj) { - _mesa_set_texture_attachment(ctx, fb, att, texObj, textarget, - level, zoffset); - /* Set the render-to-texture flag. We'll check this flag in - * glTexImage() and friends to determine if we need to revalidate - * any FBOs that might be rendering into this texture. - * This flag never gets cleared since it's non-trivial to determine - * when all FBOs might be done rendering to this texture. That's OK - * though since it's uncommon to render to a texture then repeatedly - * call glTexImage() to change images in the texture. - */ - texObj->_RenderToTexture = GL_TRUE; - } - else { - _mesa_remove_attachment(ctx, att); - } - - invalidate_framebuffer(fb); - - _glthread_UNLOCK_MUTEX(fb->Mutex); -} - - - -void GLAPIENTRY -_mesa_FramebufferTexture1DEXT(GLenum target, GLenum attachment, - GLenum textarget, GLuint texture, GLint level) -{ - GET_CURRENT_CONTEXT(ctx); - - if (texture != 0) { - GLboolean error; - - switch (textarget) { - case GL_TEXTURE_1D: - error = GL_FALSE; - break; - case GL_TEXTURE_1D_ARRAY: - error = !ctx->Extensions.EXT_texture_array; - break; - default: - error = GL_TRUE; - } - - if (error) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glFramebufferTexture1DEXT(textarget=%s)", - _mesa_lookup_enum_by_nr(textarget)); - return; - } - } - - framebuffer_texture(ctx, "1D", target, attachment, textarget, texture, - level, 0); -} - - -void GLAPIENTRY -_mesa_FramebufferTexture2DEXT(GLenum target, GLenum attachment, - GLenum textarget, GLuint texture, GLint level) -{ - GET_CURRENT_CONTEXT(ctx); - - if (texture != 0) { - GLboolean error; - - switch (textarget) { - case GL_TEXTURE_2D: - error = GL_FALSE; - break; - case GL_TEXTURE_RECTANGLE: - error = !ctx->Extensions.NV_texture_rectangle; - break; - case GL_TEXTURE_CUBE_MAP_POSITIVE_X: - case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: - case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: - case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: - case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: - case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: - error = !ctx->Extensions.ARB_texture_cube_map; - break; - case GL_TEXTURE_2D_ARRAY: - error = !ctx->Extensions.EXT_texture_array; - break; - default: - error = GL_FALSE; - } - - if (error) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glFramebufferTexture2DEXT(textarget=%s)", - _mesa_lookup_enum_by_nr(textarget)); - return; - } - } - - framebuffer_texture(ctx, "2D", target, attachment, textarget, texture, - level, 0); -} - - -void GLAPIENTRY -_mesa_FramebufferTexture3DEXT(GLenum target, GLenum attachment, - GLenum textarget, GLuint texture, - GLint level, GLint zoffset) -{ - GET_CURRENT_CONTEXT(ctx); - - if ((texture != 0) && (textarget != GL_TEXTURE_3D)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glFramebufferTexture3DEXT(textarget)"); - return; - } - - framebuffer_texture(ctx, "3D", target, attachment, textarget, texture, - level, zoffset); -} - - -void GLAPIENTRY -_mesa_FramebufferTextureLayerEXT(GLenum target, GLenum attachment, - GLuint texture, GLint level, GLint layer) -{ - GET_CURRENT_CONTEXT(ctx); - - framebuffer_texture(ctx, "Layer", target, attachment, 0, texture, - level, layer); -} - - -void GLAPIENTRY -_mesa_FramebufferRenderbufferEXT(GLenum target, GLenum attachment, - GLenum renderbufferTarget, - GLuint renderbuffer) -{ - struct gl_renderbuffer_attachment *att; - struct gl_framebuffer *fb; - struct gl_renderbuffer *rb; - GET_CURRENT_CONTEXT(ctx); - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - fb = get_framebuffer_target(ctx, target); - if (!fb) { - _mesa_error(ctx, GL_INVALID_ENUM, "glFramebufferRenderbufferEXT(target)"); - return; - } - - if (renderbufferTarget != GL_RENDERBUFFER_EXT) { - _mesa_error(ctx, GL_INVALID_ENUM, - "glFramebufferRenderbufferEXT(renderbufferTarget)"); - return; - } - - if (is_winsys_fbo(fb)) { - /* Can't attach new renderbuffers to a window system framebuffer */ - _mesa_error(ctx, GL_INVALID_OPERATION, "glFramebufferRenderbufferEXT"); - return; - } - - att = _mesa_get_attachment(ctx, fb, attachment); - if (att == NULL) { - _mesa_error(ctx, GL_INVALID_ENUM, - "glFramebufferRenderbufferEXT(invalid attachment %s)", - _mesa_lookup_enum_by_nr(attachment)); - return; - } - - if (renderbuffer) { - rb = _mesa_lookup_renderbuffer(ctx, renderbuffer); - if (!rb) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glFramebufferRenderbufferEXT(non-existant" - " renderbuffer %u)", renderbuffer); - return; - } - else if (rb == &DummyRenderbuffer) { - /* This is what NVIDIA does */ - _mesa_error(ctx, GL_INVALID_VALUE, - "glFramebufferRenderbufferEXT(renderbuffer %u)", - renderbuffer); - return; - } - } - else { - /* remove renderbuffer attachment */ - rb = NULL; - } - - if (attachment == GL_DEPTH_STENCIL_ATTACHMENT && - rb && rb->Format != MESA_FORMAT_NONE) { - /* make sure the renderbuffer is a depth/stencil format */ - const GLenum baseFormat = _mesa_get_format_base_format(rb->Format); - if (baseFormat != GL_DEPTH_STENCIL) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glFramebufferRenderbufferEXT(renderbuffer" - " is not DEPTH_STENCIL format)"); - return; - } - } - - - FLUSH_VERTICES(ctx, _NEW_BUFFERS); - - assert(ctx->Driver.FramebufferRenderbuffer); - ctx->Driver.FramebufferRenderbuffer(ctx, fb, attachment, rb); - - /* Some subsequent GL commands may depend on the framebuffer's visual - * after the binding is updated. Update visual info now. - */ - _mesa_update_framebuffer_visual(ctx, fb); -} - - -void GLAPIENTRY -_mesa_GetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment, - GLenum pname, GLint *params) -{ - const struct gl_renderbuffer_attachment *att; - struct gl_framebuffer *buffer; - GLenum err; - GET_CURRENT_CONTEXT(ctx); - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - /* The error differs in GL andd GLES. */ - err = ctx->API == API_OPENGL ? GL_INVALID_OPERATION : GL_INVALID_ENUM; - - buffer = get_framebuffer_target(ctx, target); - if (!buffer) { - _mesa_error(ctx, GL_INVALID_ENUM, - "glGetFramebufferAttachmentParameterivEXT(target)"); - return; - } - - if (is_winsys_fbo(buffer)) { - /* the default / window-system FBO */ - att = _mesa_get_fb0_attachment(ctx, buffer, attachment); - } - else { - /* user-created framebuffer FBO */ - att = _mesa_get_attachment(ctx, buffer, attachment); - } - - if (att == NULL) { - _mesa_error(ctx, GL_INVALID_ENUM, - "glGetFramebufferAttachmentParameterivEXT(attachment)"); - return; - } - - if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) { - /* the depth and stencil attachments must point to the same buffer */ - const struct gl_renderbuffer_attachment *depthAtt, *stencilAtt; - depthAtt = _mesa_get_attachment(ctx, buffer, GL_DEPTH_ATTACHMENT); - stencilAtt = _mesa_get_attachment(ctx, buffer, GL_STENCIL_ATTACHMENT); - if (depthAtt->Renderbuffer != stencilAtt->Renderbuffer) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetFramebufferAttachmentParameterivEXT(DEPTH/STENCIL" - " attachments differ)"); - return; - } - } - - /* No need to flush here */ - - switch (pname) { - case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT: - *params = is_winsys_fbo(buffer) ? GL_FRAMEBUFFER_DEFAULT : att->Type; - return; - case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT: - if (att->Type == GL_RENDERBUFFER_EXT) { - *params = att->Renderbuffer->Name; - } - else if (att->Type == GL_TEXTURE) { - *params = att->Texture->Name; - } - else { - assert(att->Type == GL_NONE); - if (ctx->API == API_OPENGL) { - *params = 0; - } else { - _mesa_error(ctx, GL_INVALID_ENUM, - "glGetFramebufferAttachmentParameterivEXT(pname)"); - } - } - return; - case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT: - if (att->Type == GL_TEXTURE) { - *params = att->TextureLevel; - } - else if (att->Type == GL_NONE) { - _mesa_error(ctx, err, - "glGetFramebufferAttachmentParameterivEXT(pname)"); - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, - "glGetFramebufferAttachmentParameterivEXT(pname)"); - } - return; - case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT: - if (att->Type == GL_TEXTURE) { - if (att->Texture && att->Texture->Target == GL_TEXTURE_CUBE_MAP) { - *params = GL_TEXTURE_CUBE_MAP_POSITIVE_X + att->CubeMapFace; - } - else { - *params = 0; - } - } - else if (att->Type == GL_NONE) { - _mesa_error(ctx, err, - "glGetFramebufferAttachmentParameterivEXT(pname)"); - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, - "glGetFramebufferAttachmentParameterivEXT(pname)"); - } - return; - case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT: - if (att->Type == GL_TEXTURE) { - if (att->Texture && att->Texture->Target == GL_TEXTURE_3D) { - *params = att->Zoffset; - } - else { - *params = 0; - } - } - else if (att->Type == GL_NONE) { - _mesa_error(ctx, err, - "glGetFramebufferAttachmentParameterivEXT(pname)"); - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, - "glGetFramebufferAttachmentParameterivEXT(pname)"); - } - return; - case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING: - if (!ctx->Extensions.ARB_framebuffer_object) { - _mesa_error(ctx, GL_INVALID_ENUM, - "glGetFramebufferAttachmentParameterivEXT(pname)"); - } - else if (att->Type == GL_NONE) { - _mesa_error(ctx, err, - "glGetFramebufferAttachmentParameterivEXT(pname)"); - } - else { - if (ctx->Extensions.EXT_framebuffer_sRGB && ctx->Const.sRGBCapable) { - *params = _mesa_get_format_color_encoding(att->Renderbuffer->Format); - } - else { - /* According to ARB_framebuffer_sRGB, we should return LINEAR - * if the sRGB conversion is unsupported. */ - *params = GL_LINEAR; - } - } - return; - case GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE: - if (!ctx->Extensions.ARB_framebuffer_object) { - _mesa_error(ctx, GL_INVALID_ENUM, - "glGetFramebufferAttachmentParameterivEXT(pname)"); - return; - } - else if (att->Type == GL_NONE) { - _mesa_error(ctx, err, - "glGetFramebufferAttachmentParameterivEXT(pname)"); - } - else { - gl_format format = att->Renderbuffer->Format; - if (format == MESA_FORMAT_S8) { - /* special cases */ - *params = GL_INDEX; - } - else if (format == MESA_FORMAT_Z32_FLOAT_X24S8) { - /* depends on the attachment parameter */ - if (attachment == GL_STENCIL_ATTACHMENT) { - *params = GL_INDEX; - } - else { - *params = GL_FLOAT; - } - } - else { - *params = _mesa_get_format_datatype(format); - } - } - return; - case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE: - case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE: - case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE: - case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE: - case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE: - case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE: - if (!ctx->Extensions.ARB_framebuffer_object) { - _mesa_error(ctx, GL_INVALID_ENUM, - "glGetFramebufferAttachmentParameterivEXT(pname)"); - } - else if (att->Type == GL_NONE) { - _mesa_error(ctx, err, - "glGetFramebufferAttachmentParameterivEXT(pname)"); - } - else if (att->Texture) { - const struct gl_texture_image *texImage = - _mesa_select_tex_image(ctx, att->Texture, att->Texture->Target, - att->TextureLevel); - if (texImage) { - *params = get_component_bits(pname, texImage->_BaseFormat, - texImage->TexFormat); - } - else { - *params = 0; - } - } - else if (att->Renderbuffer) { - *params = get_component_bits(pname, att->Renderbuffer->_BaseFormat, - att->Renderbuffer->Format); - } - else { - _mesa_problem(ctx, "glGetFramebufferAttachmentParameterivEXT:" - " invalid FBO attachment structure"); - } - return; - default: - _mesa_error(ctx, GL_INVALID_ENUM, - "glGetFramebufferAttachmentParameterivEXT(pname)"); - return; - } -} - - -void GLAPIENTRY -_mesa_GenerateMipmapEXT(GLenum target) -{ - struct gl_texture_object *texObj; - GLboolean error; - - GET_CURRENT_CONTEXT(ctx); - - ASSERT_OUTSIDE_BEGIN_END(ctx); - FLUSH_VERTICES(ctx, _NEW_BUFFERS); - - switch (target) { - case GL_TEXTURE_1D: - case GL_TEXTURE_2D: - case GL_TEXTURE_3D: - error = GL_FALSE; - break; - case GL_TEXTURE_CUBE_MAP: - error = !ctx->Extensions.ARB_texture_cube_map; - break; - case GL_TEXTURE_1D_ARRAY: - case GL_TEXTURE_2D_ARRAY: - error = !ctx->Extensions.EXT_texture_array; - break; - default: - error = GL_TRUE; - } - - if (error) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGenerateMipmapEXT(target=%s)", - _mesa_lookup_enum_by_nr(target)); - return; - } - - texObj = _mesa_get_current_tex_object(ctx, target); - - if (texObj->BaseLevel >= texObj->MaxLevel) { - /* nothing to do */ - return; - } - - if (texObj->Target == GL_TEXTURE_CUBE_MAP && - !_mesa_cube_complete(texObj)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGenerateMipmap(incomplete cube map)"); - return; - } - - _mesa_lock_texture(ctx, texObj); - if (target == GL_TEXTURE_CUBE_MAP) { - GLuint face; - for (face = 0; face < 6; face++) - ctx->Driver.GenerateMipmap(ctx, - GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB + face, - texObj); - } - else { - ctx->Driver.GenerateMipmap(ctx, target, texObj); - } - _mesa_unlock_texture(ctx, texObj); -} - - -#if FEATURE_EXT_framebuffer_blit - -static const struct gl_renderbuffer_attachment * -find_attachment(const struct gl_framebuffer *fb, - const struct gl_renderbuffer *rb) -{ - GLuint i; - for (i = 0; i < Elements(fb->Attachment); i++) { - if (fb->Attachment[i].Renderbuffer == rb) - return &fb->Attachment[i]; - } - return NULL; -} - - - -/** - * Blit rectangular region, optionally from one framebuffer to another. - * - * Note, if the src buffer is multisampled and the dest is not, this is - * when the samples must be resolved to a single color. - */ -void GLAPIENTRY -_mesa_BlitFramebufferEXT(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, - GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, - GLbitfield mask, GLenum filter) -{ - const GLbitfield legalMaskBits = (GL_COLOR_BUFFER_BIT | - GL_DEPTH_BUFFER_BIT | - GL_STENCIL_BUFFER_BIT); - const struct gl_framebuffer *readFb, *drawFb; - const struct gl_renderbuffer *colorReadRb, *colorDrawRb; - GET_CURRENT_CONTEXT(ctx); - - ASSERT_OUTSIDE_BEGIN_END(ctx); - FLUSH_VERTICES(ctx, _NEW_BUFFERS); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, - "glBlitFramebuffer(%d, %d, %d, %d, %d, %d, %d, %d, 0x%x, %s)\n", - srcX0, srcY0, srcX1, srcY1, - dstX0, dstY0, dstX1, dstY1, - mask, _mesa_lookup_enum_by_nr(filter)); - - if (ctx->NewState) { - _mesa_update_state(ctx); - } - - readFb = ctx->ReadBuffer; - drawFb = ctx->DrawBuffer; - - if (!readFb || !drawFb) { - /* This will normally never happen but someday we may want to - * support MakeCurrent() with no drawables. - */ - return; - } - - /* check for complete framebuffers */ - if (drawFb->_Status != GL_FRAMEBUFFER_COMPLETE_EXT || - readFb->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) { - _mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION_EXT, - "glBlitFramebufferEXT(incomplete draw/read buffers)"); - return; - } - - if (filter != GL_NEAREST && filter != GL_LINEAR) { - _mesa_error(ctx, GL_INVALID_ENUM, "glBlitFramebufferEXT(filter)"); - return; - } - - if (mask & ~legalMaskBits) { - _mesa_error( ctx, GL_INVALID_VALUE, "glBlitFramebufferEXT(mask)"); - return; - } - - /* depth/stencil must be blitted with nearest filtering */ - if ((mask & (GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT)) - && filter != GL_NEAREST) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glBlitFramebufferEXT(depth/stencil requires GL_NEAREST filter)"); - return; - } - - /* get color read/draw renderbuffers */ - if (mask & GL_COLOR_BUFFER_BIT) { - colorReadRb = readFb->_ColorReadBuffer; - colorDrawRb = drawFb->_ColorDrawBuffers[0]; - - /* From the EXT_framebuffer_object spec: - * - * "If a buffer is specified in and does not exist in both - * the read and draw framebuffers, the corresponding bit is silently - * ignored." - */ - if ((colorReadRb == NULL) || (colorDrawRb == NULL)) { - colorReadRb = colorDrawRb = NULL; - mask &= ~GL_COLOR_BUFFER_BIT; - } - } - else { - colorReadRb = colorDrawRb = NULL; - } - - if (mask & GL_STENCIL_BUFFER_BIT) { - struct gl_renderbuffer *readRb = readFb->_StencilBuffer; - struct gl_renderbuffer *drawRb = drawFb->_StencilBuffer; - - /* From the EXT_framebuffer_object spec: - * - * "If a buffer is specified in and does not exist in both - * the read and draw framebuffers, the corresponding bit is silently - * ignored." - */ - if ((readRb == NULL) || (drawRb == NULL)) { - readRb = drawRb = NULL; - mask &= ~GL_STENCIL_BUFFER_BIT; - } - else if (_mesa_get_format_bits(readRb->Format, GL_STENCIL_BITS) != - _mesa_get_format_bits(drawRb->Format, GL_STENCIL_BITS)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glBlitFramebufferEXT(stencil buffer size mismatch)"); - return; - } - } - - if (mask & GL_DEPTH_BUFFER_BIT) { - struct gl_renderbuffer *readRb = readFb->_DepthBuffer; - struct gl_renderbuffer *drawRb = drawFb->_DepthBuffer; - - /* From the EXT_framebuffer_object spec: - * - * "If a buffer is specified in and does not exist in both - * the read and draw framebuffers, the corresponding bit is silently - * ignored." - */ - if ((readRb == NULL) || (drawRb == NULL)) { - readRb = drawRb = NULL; - mask &= ~GL_DEPTH_BUFFER_BIT; - } - else if (_mesa_get_format_bits(readRb->Format, GL_DEPTH_BITS) != - _mesa_get_format_bits(drawRb->Format, GL_DEPTH_BITS)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glBlitFramebufferEXT(depth buffer size mismatch)"); - return; - } - } - - if (readFb->Visual.samples > 0 && - drawFb->Visual.samples > 0 && - readFb->Visual.samples != drawFb->Visual.samples) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glBlitFramebufferEXT(mismatched samples"); - return; - } - - /* extra checks for multisample copies... */ - if (readFb->Visual.samples > 0 || drawFb->Visual.samples > 0) { - /* src and dest region sizes must be the same */ - if (srcX1 - srcX0 != dstX1 - dstX0 || - srcY1 - srcY0 != dstY1 - dstY0) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glBlitFramebufferEXT(bad src/dst multisample region sizes)"); - return; - } - - /* color formats must match */ - if (colorReadRb && - colorDrawRb && - colorReadRb->Format != colorDrawRb->Format) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glBlitFramebufferEXT(bad src/dst multisample pixel formats)"); - return; - } - } - - if (!ctx->Extensions.EXT_framebuffer_blit) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glBlitFramebufferEXT"); - return; - } - - /* Debug code */ - if (DEBUG_BLIT) { - printf("glBlitFramebuffer(%d, %d, %d, %d, %d, %d, %d, %d," - " 0x%x, 0x%x)\n", - srcX0, srcY0, srcX1, srcY1, - dstX0, dstY0, dstX1, dstY1, - mask, filter); - if (colorReadRb) { - const struct gl_renderbuffer_attachment *att; - - att = find_attachment(readFb, colorReadRb); - printf(" Src FBO %u RB %u (%dx%d) ", - readFb->Name, colorReadRb->Name, - colorReadRb->Width, colorReadRb->Height); - if (att && att->Texture) { - printf("Tex %u tgt 0x%x level %u face %u", - att->Texture->Name, - att->Texture->Target, - att->TextureLevel, - att->CubeMapFace); - } - printf("\n"); - - att = find_attachment(drawFb, colorDrawRb); - printf(" Dst FBO %u RB %u (%dx%d) ", - drawFb->Name, colorDrawRb->Name, - colorDrawRb->Width, colorDrawRb->Height); - if (att && att->Texture) { - printf("Tex %u tgt 0x%x level %u face %u", - att->Texture->Name, - att->Texture->Target, - att->TextureLevel, - att->CubeMapFace); - } - printf("\n"); - } - } - - if (!mask) { - return; - } - - ASSERT(ctx->Driver.BlitFramebuffer); - ctx->Driver.BlitFramebuffer(ctx, - srcX0, srcY0, srcX1, srcY1, - dstX0, dstY0, dstX1, dstY1, - mask, filter); -} -#endif /* FEATURE_EXT_framebuffer_blit */ - -#if FEATURE_ARB_geometry_shader4 -void GLAPIENTRY -_mesa_FramebufferTextureARB(GLenum target, GLenum attachment, - GLuint texture, GLint level) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_error(ctx, GL_INVALID_OPERATION, - "glFramebufferTextureARB " - "not implemented!"); -} - -void GLAPIENTRY -_mesa_FramebufferTextureFaceARB(GLenum target, GLenum attachment, - GLuint texture, GLint level, GLenum face) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_error(ctx, GL_INVALID_OPERATION, - "glFramebufferTextureFaceARB " - "not implemented!"); -} -#endif /* FEATURE_ARB_geometry_shader4 */ +/* + * Mesa 3-D graphics library + * Version: 7.1 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (C) 1999-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. + */ + + +/* + * GL_EXT/ARB_framebuffer_object extensions + * + * Authors: + * Brian Paul + */ + + +#include "buffers.h" +#include "context.h" +#include "enums.h" +#include "fbobject.h" +#include "formats.h" +#include "framebuffer.h" +#include "hash.h" +#include "macros.h" +#include "mfeatures.h" +#include "mtypes.h" +#include "renderbuffer.h" +#include "state.h" +#include "teximage.h" +#include "texobj.h" + + +/** Set this to 1 to help debug FBO incompleteness problems */ +#define DEBUG_FBO 0 + +/** Set this to 1 to debug/log glBlitFramebuffer() calls */ +#define DEBUG_BLIT 0 + + +/** + * Notes: + * + * None of the GL_EXT_framebuffer_object functions are compiled into + * display lists. + */ + + + +/* + * When glGenRender/FramebuffersEXT() is called we insert pointers to + * these placeholder objects into the hash table. + * Later, when the object ID is first bound, we replace the placeholder + * with the real frame/renderbuffer. + */ +static struct gl_framebuffer DummyFramebuffer; +static struct gl_renderbuffer DummyRenderbuffer; + +/* We bind this framebuffer when applications pass a NULL + * drawable/surface in make current. */ +static struct gl_framebuffer IncompleteFramebuffer; + + +static INLINE GLboolean +is_cube_face(GLenum target) +{ + return (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X && + target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z); +} + + +/** + * Is the given FBO a user-created FBO? + */ +static INLINE GLboolean +is_user_fbo(const struct gl_framebuffer *fb) +{ + return fb->Name != 0; +} + + +/** + * Is the given FBO a window system FBO (like an X window)? + */ +static INLINE GLboolean +is_winsys_fbo(const struct gl_framebuffer *fb) +{ + return fb->Name == 0; +} + + +static void +delete_dummy_renderbuffer(struct gl_renderbuffer *rb) +{ + /* no op */ +} + +static void +delete_dummy_framebuffer(struct gl_framebuffer *fb) +{ + /* no op */ +} + + +void +_mesa_init_fbobjects(struct gl_context *ctx) +{ + _glthread_INIT_MUTEX(DummyFramebuffer.Mutex); + _glthread_INIT_MUTEX(DummyRenderbuffer.Mutex); + _glthread_INIT_MUTEX(IncompleteFramebuffer.Mutex); + DummyFramebuffer.Delete = delete_dummy_framebuffer; + DummyRenderbuffer.Delete = delete_dummy_renderbuffer; + IncompleteFramebuffer.Delete = delete_dummy_framebuffer; +} + +struct gl_framebuffer * +_mesa_get_incomplete_framebuffer(void) +{ + return &IncompleteFramebuffer; +} + +/** + * Helper routine for getting a gl_renderbuffer. + */ +struct gl_renderbuffer * +_mesa_lookup_renderbuffer(struct gl_context *ctx, GLuint id) +{ + struct gl_renderbuffer *rb; + + if (id == 0) + return NULL; + + rb = (struct gl_renderbuffer *) + _mesa_HashLookup(ctx->Shared->RenderBuffers, id); + return rb; +} + + +/** + * Helper routine for getting a gl_framebuffer. + */ +struct gl_framebuffer * +_mesa_lookup_framebuffer(struct gl_context *ctx, GLuint id) +{ + struct gl_framebuffer *fb; + + if (id == 0) + return NULL; + + fb = (struct gl_framebuffer *) + _mesa_HashLookup(ctx->Shared->FrameBuffers, id); + return fb; +} + + +/** + * Mark the given framebuffer as invalid. This will force the + * test for framebuffer completeness to be done before the framebuffer + * is used. + */ +static void +invalidate_framebuffer(struct gl_framebuffer *fb) +{ + fb->_Status = 0; /* "indeterminate" */ +} + + +/** + * Return the gl_framebuffer object which corresponds to the given + * framebuffer target, such as GL_DRAW_FRAMEBUFFER. + * Check support for GL_EXT_framebuffer_blit to determine if certain + * targets are legal. + * \return gl_framebuffer pointer or NULL if target is illegal + */ +static struct gl_framebuffer * +get_framebuffer_target(struct gl_context *ctx, GLenum target) +{ + switch (target) { + case GL_DRAW_FRAMEBUFFER: + return ctx->Extensions.EXT_framebuffer_blit ? ctx->DrawBuffer : NULL; + case GL_READ_FRAMEBUFFER: + return ctx->Extensions.EXT_framebuffer_blit ? ctx->ReadBuffer : NULL; + case GL_FRAMEBUFFER_EXT: + return ctx->DrawBuffer; + default: + return NULL; + } +} + + +/** + * Given a GL_*_ATTACHMENTn token, return a pointer to the corresponding + * gl_renderbuffer_attachment object. + * This function is only used for user-created FB objects, not the + * default / window-system FB object. + * If \p attachment is GL_DEPTH_STENCIL_ATTACHMENT, return a pointer to + * the depth buffer attachment point. + */ +struct gl_renderbuffer_attachment * +_mesa_get_attachment(struct gl_context *ctx, struct gl_framebuffer *fb, + GLenum attachment) +{ + GLuint i; + + assert(is_user_fbo(fb)); + + switch (attachment) { + case GL_COLOR_ATTACHMENT0_EXT: + case GL_COLOR_ATTACHMENT1_EXT: + case GL_COLOR_ATTACHMENT2_EXT: + case GL_COLOR_ATTACHMENT3_EXT: + case GL_COLOR_ATTACHMENT4_EXT: + case GL_COLOR_ATTACHMENT5_EXT: + case GL_COLOR_ATTACHMENT6_EXT: + case GL_COLOR_ATTACHMENT7_EXT: + case GL_COLOR_ATTACHMENT8_EXT: + case GL_COLOR_ATTACHMENT9_EXT: + case GL_COLOR_ATTACHMENT10_EXT: + case GL_COLOR_ATTACHMENT11_EXT: + case GL_COLOR_ATTACHMENT12_EXT: + case GL_COLOR_ATTACHMENT13_EXT: + case GL_COLOR_ATTACHMENT14_EXT: + case GL_COLOR_ATTACHMENT15_EXT: + i = attachment - GL_COLOR_ATTACHMENT0_EXT; + if (i >= ctx->Const.MaxColorAttachments) { + return NULL; + } + return &fb->Attachment[BUFFER_COLOR0 + i]; + case GL_DEPTH_STENCIL_ATTACHMENT: + /* fall-through */ + case GL_DEPTH_BUFFER: + /* fall-through / new in GL 3.0 */ + case GL_DEPTH_ATTACHMENT_EXT: + return &fb->Attachment[BUFFER_DEPTH]; + case GL_STENCIL_BUFFER: + /* fall-through / new in GL 3.0 */ + case GL_STENCIL_ATTACHMENT_EXT: + return &fb->Attachment[BUFFER_STENCIL]; + default: + return NULL; + } +} + + +/** + * As above, but only used for getting attachments of the default / + * window-system framebuffer (not user-created framebuffer objects). + */ +static struct gl_renderbuffer_attachment * +_mesa_get_fb0_attachment(struct gl_context *ctx, struct gl_framebuffer *fb, + GLenum attachment) +{ + assert(is_winsys_fbo(fb)); + + switch (attachment) { + case GL_FRONT_LEFT: + return &fb->Attachment[BUFFER_FRONT_LEFT]; + case GL_FRONT_RIGHT: + return &fb->Attachment[BUFFER_FRONT_RIGHT]; + case GL_BACK_LEFT: + return &fb->Attachment[BUFFER_BACK_LEFT]; + case GL_BACK_RIGHT: + return &fb->Attachment[BUFFER_BACK_RIGHT]; + case GL_AUX0: + if (fb->Visual.numAuxBuffers == 1) { + return &fb->Attachment[BUFFER_AUX0]; + } + return NULL; + case GL_DEPTH_BUFFER: + /* fall-through / new in GL 3.0 */ + case GL_DEPTH_ATTACHMENT_EXT: + return &fb->Attachment[BUFFER_DEPTH]; + case GL_STENCIL_BUFFER: + /* fall-through / new in GL 3.0 */ + case GL_STENCIL_ATTACHMENT_EXT: + return &fb->Attachment[BUFFER_STENCIL]; + default: + return NULL; + } +} + + + +/** + * Remove any texture or renderbuffer attached to the given attachment + * point. Update reference counts, etc. + */ +void +_mesa_remove_attachment(struct gl_context *ctx, + struct gl_renderbuffer_attachment *att) +{ + if (att->Type == GL_TEXTURE) { + ASSERT(att->Texture); + if (ctx->Driver.FinishRenderTexture) { + /* tell driver that we're done rendering to this texture. */ + ctx->Driver.FinishRenderTexture(ctx, att); + } + _mesa_reference_texobj(&att->Texture, NULL); /* unbind */ + ASSERT(!att->Texture); + } + if (att->Type == GL_TEXTURE || att->Type == GL_RENDERBUFFER_EXT) { + ASSERT(!att->Texture); + _mesa_reference_renderbuffer(&att->Renderbuffer, NULL); /* unbind */ + ASSERT(!att->Renderbuffer); + } + att->Type = GL_NONE; + att->Complete = GL_TRUE; +} + + +/** + * Bind a texture object to an attachment point. + * The previous binding, if any, will be removed first. + */ +void +_mesa_set_texture_attachment(struct gl_context *ctx, + struct gl_framebuffer *fb, + struct gl_renderbuffer_attachment *att, + struct gl_texture_object *texObj, + GLenum texTarget, GLuint level, GLuint zoffset) +{ + if (att->Texture == texObj) { + /* re-attaching same texture */ + ASSERT(att->Type == GL_TEXTURE); + if (ctx->Driver.FinishRenderTexture) + ctx->Driver.FinishRenderTexture(ctx, att); + } + else { + /* new attachment */ + if (ctx->Driver.FinishRenderTexture && att->Texture) + ctx->Driver.FinishRenderTexture(ctx, att); + _mesa_remove_attachment(ctx, att); + att->Type = GL_TEXTURE; + assert(!att->Texture); + _mesa_reference_texobj(&att->Texture, texObj); + } + + /* always update these fields */ + att->TextureLevel = level; + att->CubeMapFace = _mesa_tex_target_to_face(texTarget); + att->Zoffset = zoffset; + att->Complete = GL_FALSE; + + if (_mesa_get_attachment_teximage(att)) { + ctx->Driver.RenderTexture(ctx, fb, att); + } + + invalidate_framebuffer(fb); +} + + +/** + * Bind a renderbuffer to an attachment point. + * The previous binding, if any, will be removed first. + */ +void +_mesa_set_renderbuffer_attachment(struct gl_context *ctx, + struct gl_renderbuffer_attachment *att, + struct gl_renderbuffer *rb) +{ + /* XXX check if re-doing same attachment, exit early */ + _mesa_remove_attachment(ctx, att); + att->Type = GL_RENDERBUFFER_EXT; + att->Texture = NULL; /* just to be safe */ + att->Complete = GL_FALSE; + _mesa_reference_renderbuffer(&att->Renderbuffer, rb); +} + + +/** + * Fallback for ctx->Driver.FramebufferRenderbuffer() + * Attach a renderbuffer object to a framebuffer object. + */ +void +_mesa_framebuffer_renderbuffer(struct gl_context *ctx, + struct gl_framebuffer *fb, + GLenum attachment, struct gl_renderbuffer *rb) +{ + struct gl_renderbuffer_attachment *att; + + _glthread_LOCK_MUTEX(fb->Mutex); + + att = _mesa_get_attachment(ctx, fb, attachment); + ASSERT(att); + if (rb) { + _mesa_set_renderbuffer_attachment(ctx, att, rb); + if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) { + /* do stencil attachment here (depth already done above) */ + att = _mesa_get_attachment(ctx, fb, GL_STENCIL_ATTACHMENT_EXT); + assert(att); + _mesa_set_renderbuffer_attachment(ctx, att, rb); + } + rb->AttachedAnytime = GL_TRUE; + } + else { + _mesa_remove_attachment(ctx, att); + } + + invalidate_framebuffer(fb); + + _glthread_UNLOCK_MUTEX(fb->Mutex); +} + + +/** + * Fallback for ctx->Driver.ValidateFramebuffer() + * Check if the renderbuffer's formats are supported by the software + * renderer. + * Drivers should probably override this. + */ +void +_mesa_validate_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb) +{ + gl_buffer_index buf; + for (buf = 0; buf < BUFFER_COUNT; buf++) { + const struct gl_renderbuffer *rb = fb->Attachment[buf].Renderbuffer; + if (rb) { + switch (rb->_BaseFormat) { + case GL_ALPHA: + case GL_LUMINANCE_ALPHA: + case GL_LUMINANCE: + case GL_INTENSITY: + case GL_RED: + case GL_RG: + fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED; + return; + + default: + switch (rb->Format) { + /* XXX This list is likely incomplete. */ + case MESA_FORMAT_RGB9_E5_FLOAT: + fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED; + return; + default:; + /* render buffer format is supported by software rendering */ + } + } + } + } +} + + +/** + * For debug only. + */ +static void +att_incomplete(const char *msg) +{ +#if DEBUG_FBO + _mesa_debug(NULL, "attachment incomplete: %s\n", msg); +#else + (void) msg; +#endif +} + + +/** + * For debug only. + */ +static void +fbo_incomplete(const char *msg, int index) +{ +#if DEBUG_FBO + _mesa_debug(NULL, "FBO Incomplete: %s [%d]\n", msg, index); +#else + (void) msg; + (void) index; +#endif +} + + +/** + * Is the given base format a legal format for a color renderbuffer? + */ +GLboolean +_mesa_is_legal_color_format(const struct gl_context *ctx, GLenum baseFormat) +{ + switch (baseFormat) { + case GL_RGB: + case GL_RGBA: + return GL_TRUE; + case GL_LUMINANCE: + case GL_LUMINANCE_ALPHA: + case GL_INTENSITY: + case GL_ALPHA: + return ctx->Extensions.ARB_framebuffer_object; + case GL_RED: + case GL_RG: + return ctx->Extensions.ARB_texture_rg; + default: + return GL_FALSE; + } +} + + +/** + * Is the given base format a legal format for a depth/stencil renderbuffer? + */ +static GLboolean +is_legal_depth_format(const struct gl_context *ctx, GLenum baseFormat) +{ + switch (baseFormat) { + case GL_DEPTH_COMPONENT: + case GL_DEPTH_STENCIL_EXT: + return GL_TRUE; + default: + return GL_FALSE; + } +} + + +/** + * Test if an attachment point is complete and update its Complete field. + * \param format if GL_COLOR, this is a color attachment point, + * if GL_DEPTH, this is a depth component attachment point, + * if GL_STENCIL, this is a stencil component attachment point. + */ +static void +test_attachment_completeness(const struct gl_context *ctx, GLenum format, + struct gl_renderbuffer_attachment *att) +{ + assert(format == GL_COLOR || format == GL_DEPTH || format == GL_STENCIL); + + /* assume complete */ + att->Complete = GL_TRUE; + + /* Look for reasons why the attachment might be incomplete */ + if (att->Type == GL_TEXTURE) { + const struct gl_texture_object *texObj = att->Texture; + struct gl_texture_image *texImage; + GLenum baseFormat; + + if (!texObj) { + att_incomplete("no texobj"); + att->Complete = GL_FALSE; + return; + } + + texImage = texObj->Image[att->CubeMapFace][att->TextureLevel]; + if (!texImage) { + att_incomplete("no teximage"); + att->Complete = GL_FALSE; + return; + } + if (texImage->Width < 1 || texImage->Height < 1) { + att_incomplete("teximage width/height=0"); + printf("texobj = %u\n", texObj->Name); + printf("level = %d\n", att->TextureLevel); + att->Complete = GL_FALSE; + return; + } + if (texObj->Target == GL_TEXTURE_3D && att->Zoffset >= texImage->Depth) { + att_incomplete("bad z offset"); + att->Complete = GL_FALSE; + return; + } + + baseFormat = _mesa_get_format_base_format(texImage->TexFormat); + + if (format == GL_COLOR) { + if (!_mesa_is_legal_color_format(ctx, baseFormat)) { + att_incomplete("bad format"); + att->Complete = GL_FALSE; + return; + } + if (_mesa_is_format_compressed(texImage->TexFormat)) { + att_incomplete("compressed internalformat"); + att->Complete = GL_FALSE; + return; + } + } + else if (format == GL_DEPTH) { + if (baseFormat == GL_DEPTH_COMPONENT) { + /* OK */ + } + else if (ctx->Extensions.EXT_packed_depth_stencil && + ctx->Extensions.ARB_depth_texture && + baseFormat == GL_DEPTH_STENCIL_EXT) { + /* OK */ + } + else { + att->Complete = GL_FALSE; + att_incomplete("bad depth format"); + return; + } + } + else { + ASSERT(format == GL_STENCIL); + if (ctx->Extensions.EXT_packed_depth_stencil && + ctx->Extensions.ARB_depth_texture && + baseFormat == GL_DEPTH_STENCIL_EXT) { + /* OK */ + } + else { + /* no such thing as stencil-only textures */ + att_incomplete("illegal stencil texture"); + att->Complete = GL_FALSE; + return; + } + } + } + else if (att->Type == GL_RENDERBUFFER_EXT) { + const GLenum baseFormat = + _mesa_get_format_base_format(att->Renderbuffer->Format); + + ASSERT(att->Renderbuffer); + if (!att->Renderbuffer->InternalFormat || + att->Renderbuffer->Width < 1 || + att->Renderbuffer->Height < 1) { + att_incomplete("0x0 renderbuffer"); + att->Complete = GL_FALSE; + return; + } + if (format == GL_COLOR) { + if (!_mesa_is_legal_color_format(ctx, baseFormat)) { + att_incomplete("bad renderbuffer color format"); + att->Complete = GL_FALSE; + return; + } + } + else if (format == GL_DEPTH) { + if (baseFormat == GL_DEPTH_COMPONENT) { + /* OK */ + } + else if (ctx->Extensions.EXT_packed_depth_stencil && + baseFormat == GL_DEPTH_STENCIL_EXT) { + /* OK */ + } + else { + att_incomplete("bad renderbuffer depth format"); + att->Complete = GL_FALSE; + return; + } + } + else { + assert(format == GL_STENCIL); + if (baseFormat == GL_STENCIL_INDEX) { + /* OK */ + } + else if (ctx->Extensions.EXT_packed_depth_stencil && + baseFormat == GL_DEPTH_STENCIL_EXT) { + /* OK */ + } + else { + att->Complete = GL_FALSE; + att_incomplete("bad renderbuffer stencil format"); + return; + } + } + } + else { + ASSERT(att->Type == GL_NONE); + /* complete */ + return; + } +} + + +/** + * Test if the given framebuffer object is complete and update its + * Status field with the results. + * Calls the ctx->Driver.ValidateFramebuffer() function to allow the + * driver to make hardware-specific validation/completeness checks. + * Also update the framebuffer's Width and Height fields if the + * framebuffer is complete. + */ +void +_mesa_test_framebuffer_completeness(struct gl_context *ctx, + struct gl_framebuffer *fb) +{ + GLuint numImages; + GLenum intFormat = GL_NONE; /* color buffers' internal format */ + GLuint minWidth = ~0, minHeight = ~0, maxWidth = 0, maxHeight = 0; + GLint numSamples = -1; + GLint i; + GLuint j; + + assert(is_user_fbo(fb)); + + numImages = 0; + fb->Width = 0; + fb->Height = 0; + + /* Start at -2 to more easily loop over all attachment points. + * -2: depth buffer + * -1: stencil buffer + * >=0: color buffer + */ + for (i = -2; i < (GLint) ctx->Const.MaxColorAttachments; i++) { + struct gl_renderbuffer_attachment *att; + GLenum f; + gl_format attFormat; + + /* + * XXX for ARB_fbo, only check color buffers that are named by + * GL_READ_BUFFER and GL_DRAW_BUFFERi. + */ + + /* check for attachment completeness + */ + if (i == -2) { + att = &fb->Attachment[BUFFER_DEPTH]; + test_attachment_completeness(ctx, GL_DEPTH, att); + if (!att->Complete) { + fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT; + fbo_incomplete("depth attachment incomplete", -1); + return; + } + } + else if (i == -1) { + att = &fb->Attachment[BUFFER_STENCIL]; + test_attachment_completeness(ctx, GL_STENCIL, att); + if (!att->Complete) { + fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT; + fbo_incomplete("stencil attachment incomplete", -1); + return; + } + } + else { + att = &fb->Attachment[BUFFER_COLOR0 + i]; + test_attachment_completeness(ctx, GL_COLOR, att); + if (!att->Complete) { + fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT; + fbo_incomplete("color attachment incomplete", i); + return; + } + } + + /* get width, height, format of the renderbuffer/texture + */ + if (att->Type == GL_TEXTURE) { + const struct gl_texture_image *texImg = + _mesa_get_attachment_teximage(att); + minWidth = MIN2(minWidth, texImg->Width); + maxWidth = MAX2(maxWidth, texImg->Width); + minHeight = MIN2(minHeight, texImg->Height); + maxHeight = MAX2(maxHeight, texImg->Height); + f = texImg->_BaseFormat; + attFormat = texImg->TexFormat; + numImages++; + if (!_mesa_is_legal_color_format(ctx, f) && + !is_legal_depth_format(ctx, f)) { + fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT; + fbo_incomplete("texture attachment incomplete", -1); + return; + } + } + else if (att->Type == GL_RENDERBUFFER_EXT) { + minWidth = MIN2(minWidth, att->Renderbuffer->Width); + maxWidth = MAX2(minWidth, att->Renderbuffer->Width); + minHeight = MIN2(minHeight, att->Renderbuffer->Height); + maxHeight = MAX2(minHeight, att->Renderbuffer->Height); + f = att->Renderbuffer->InternalFormat; + attFormat = att->Renderbuffer->Format; + numImages++; + } + else { + assert(att->Type == GL_NONE); + continue; + } + + if (att->Renderbuffer && numSamples < 0) { + /* first buffer */ + numSamples = att->Renderbuffer->NumSamples; + } + + /* check if integer color */ + fb->_IntegerColor = _mesa_is_format_integer_color(attFormat); + + /* Error-check width, height, format, samples + */ + if (numImages == 1) { + /* save format, num samples */ + if (i >= 0) { + intFormat = f; + } + } + else { + if (!ctx->Extensions.ARB_framebuffer_object) { + /* check that width, height, format are same */ + if (minWidth != maxWidth || minHeight != maxHeight) { + fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT; + fbo_incomplete("width or height mismatch", -1); + return; + } + /* check that all color buffer have same format */ + if (intFormat != GL_NONE && f != intFormat) { + fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT; + fbo_incomplete("format mismatch", -1); + return; + } + } + if (att->Renderbuffer && + att->Renderbuffer->NumSamples != numSamples) { + fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE; + fbo_incomplete("inconsistant number of samples", i); + return; + } + + } + } + +#if FEATURE_GL + if (ctx->API == API_OPENGL && !ctx->Extensions.ARB_ES2_compatibility) { + /* Check that all DrawBuffers are present */ + for (j = 0; j < ctx->Const.MaxDrawBuffers; j++) { + if (fb->ColorDrawBuffer[j] != GL_NONE) { + const struct gl_renderbuffer_attachment *att + = _mesa_get_attachment(ctx, fb, fb->ColorDrawBuffer[j]); + assert(att); + if (att->Type == GL_NONE) { + fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT; + fbo_incomplete("missing drawbuffer", j); + return; + } + } + } + + /* Check that the ReadBuffer is present */ + if (fb->ColorReadBuffer != GL_NONE) { + const struct gl_renderbuffer_attachment *att + = _mesa_get_attachment(ctx, fb, fb->ColorReadBuffer); + assert(att); + if (att->Type == GL_NONE) { + fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT; + fbo_incomplete("missing readbuffer", -1); + return; + } + } + } +#else + (void) j; +#endif + + if (numImages == 0) { + fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT; + fbo_incomplete("no attachments", -1); + return; + } + + /* Provisionally set status = COMPLETE ... */ + fb->_Status = GL_FRAMEBUFFER_COMPLETE_EXT; + + /* ... but the driver may say the FB is incomplete. + * Drivers will most likely set the status to GL_FRAMEBUFFER_UNSUPPORTED + * if anything. + */ + if (ctx->Driver.ValidateFramebuffer) { + ctx->Driver.ValidateFramebuffer(ctx, fb); + if (fb->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) { + fbo_incomplete("driver marked FBO as incomplete", -1); + } + } + + if (fb->_Status == GL_FRAMEBUFFER_COMPLETE_EXT) { + /* + * Note that if ARB_framebuffer_object is supported and the attached + * renderbuffers/textures are different sizes, the framebuffer + * width/height will be set to the smallest width/height. + */ + fb->Width = minWidth; + fb->Height = minHeight; + + /* finally, update the visual info for the framebuffer */ + _mesa_update_framebuffer_visual(ctx, fb); + } +} + + +GLboolean GLAPIENTRY +_mesa_IsRenderbufferEXT(GLuint renderbuffer) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); + if (renderbuffer) { + struct gl_renderbuffer *rb = _mesa_lookup_renderbuffer(ctx, renderbuffer); + if (rb != NULL && rb != &DummyRenderbuffer) + return GL_TRUE; + } + return GL_FALSE; +} + + +void GLAPIENTRY +_mesa_BindRenderbufferEXT(GLenum target, GLuint renderbuffer) +{ + struct gl_renderbuffer *newRb; + GET_CURRENT_CONTEXT(ctx); + + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (target != GL_RENDERBUFFER_EXT) { + _mesa_error(ctx, GL_INVALID_ENUM, "glBindRenderbufferEXT(target)"); + return; + } + + /* No need to flush here since the render buffer binding has no + * effect on rendering state. + */ + + if (renderbuffer) { + newRb = _mesa_lookup_renderbuffer(ctx, renderbuffer); + if (newRb == &DummyRenderbuffer) { + /* ID was reserved, but no real renderbuffer object made yet */ + newRb = NULL; + } + else if (!newRb && ctx->Extensions.ARB_framebuffer_object) { + /* All RB IDs must be Gen'd */ + _mesa_error(ctx, GL_INVALID_OPERATION, "glBindRenderbuffer(buffer)"); + return; + } + + if (!newRb) { + /* create new renderbuffer object */ + newRb = ctx->Driver.NewRenderbuffer(ctx, renderbuffer); + if (!newRb) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindRenderbufferEXT"); + return; + } + ASSERT(newRb->AllocStorage); + _mesa_HashInsert(ctx->Shared->RenderBuffers, renderbuffer, newRb); + newRb->RefCount = 1; /* referenced by hash table */ + } + } + else { + newRb = NULL; + } + + ASSERT(newRb != &DummyRenderbuffer); + + _mesa_reference_renderbuffer(&ctx->CurrentRenderbuffer, newRb); +} + + +/** + * If the given renderbuffer is anywhere attached to the framebuffer, detach + * the renderbuffer. + * This is used when a renderbuffer object is deleted. + * The spec calls for unbinding. + */ +static void +detach_renderbuffer(struct gl_context *ctx, + struct gl_framebuffer *fb, + struct gl_renderbuffer *rb) +{ + GLuint i; + for (i = 0; i < BUFFER_COUNT; i++) { + if (fb->Attachment[i].Renderbuffer == rb) { + _mesa_remove_attachment(ctx, &fb->Attachment[i]); + } + } + invalidate_framebuffer(fb); +} + + +void GLAPIENTRY +_mesa_DeleteRenderbuffersEXT(GLsizei n, const GLuint *renderbuffers) +{ + GLint i; + GET_CURRENT_CONTEXT(ctx); + + ASSERT_OUTSIDE_BEGIN_END(ctx); + FLUSH_VERTICES(ctx, _NEW_BUFFERS); + + for (i = 0; i < n; i++) { + if (renderbuffers[i] > 0) { + struct gl_renderbuffer *rb; + rb = _mesa_lookup_renderbuffer(ctx, renderbuffers[i]); + if (rb) { + /* check if deleting currently bound renderbuffer object */ + if (rb == ctx->CurrentRenderbuffer) { + /* bind default */ + ASSERT(rb->RefCount >= 2); + _mesa_BindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0); + } + + if (is_user_fbo(ctx->DrawBuffer)) { + detach_renderbuffer(ctx, ctx->DrawBuffer, rb); + } + if (is_user_fbo(ctx->ReadBuffer) + && ctx->ReadBuffer != ctx->DrawBuffer) { + detach_renderbuffer(ctx, ctx->ReadBuffer, rb); + } + + /* Remove from hash table immediately, to free the ID. + * But the object will not be freed until it's no longer + * referenced anywhere else. + */ + _mesa_HashRemove(ctx->Shared->RenderBuffers, renderbuffers[i]); + + if (rb != &DummyRenderbuffer) { + /* no longer referenced by hash table */ + _mesa_reference_renderbuffer(&rb, NULL); + } + } + } + } +} + + +void GLAPIENTRY +_mesa_GenRenderbuffersEXT(GLsizei n, GLuint *renderbuffers) +{ + GET_CURRENT_CONTEXT(ctx); + GLuint first; + GLint i; + + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (n < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glGenRenderbuffersEXT(n)"); + return; + } + + if (!renderbuffers) + return; + + first = _mesa_HashFindFreeKeyBlock(ctx->Shared->RenderBuffers, n); + + for (i = 0; i < n; i++) { + GLuint name = first + i; + renderbuffers[i] = name; + /* insert dummy placeholder into hash table */ + _glthread_LOCK_MUTEX(ctx->Shared->Mutex); + _mesa_HashInsert(ctx->Shared->RenderBuffers, name, &DummyRenderbuffer); + _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); + } +} + + +/** + * Given an internal format token for a render buffer, return the + * corresponding base format (one of GL_RGB, GL_RGBA, GL_STENCIL_INDEX, + * GL_DEPTH_COMPONENT, GL_DEPTH_STENCIL_EXT, GL_ALPHA, GL_LUMINANCE, + * GL_LUMINANCE_ALPHA, GL_INTENSITY, etc). + * + * This is similar to _mesa_base_tex_format() but the set of valid + * internal formats is different. + * + * Note that even if a format is determined to be legal here, validation + * of the FBO may fail if the format is not supported by the driver/GPU. + * + * \param internalFormat as passed to glRenderbufferStorage() + * \return the base internal format, or 0 if internalFormat is illegal + */ +GLenum +_mesa_base_fbo_format(struct gl_context *ctx, GLenum internalFormat) +{ + /* + * Notes: some formats such as alpha, luminance, etc. were added + * with GL_ARB_framebuffer_object. + */ + switch (internalFormat) { + case GL_ALPHA: + case GL_ALPHA4: + case GL_ALPHA8: + case GL_ALPHA12: + case GL_ALPHA16: + return ctx->Extensions.ARB_framebuffer_object ? GL_ALPHA : 0; + case GL_LUMINANCE: + case GL_LUMINANCE4: + case GL_LUMINANCE8: + case GL_LUMINANCE12: + case GL_LUMINANCE16: + return ctx->Extensions.ARB_framebuffer_object ? GL_LUMINANCE : 0; + case GL_LUMINANCE_ALPHA: + case GL_LUMINANCE4_ALPHA4: + case GL_LUMINANCE6_ALPHA2: + case GL_LUMINANCE8_ALPHA8: + case GL_LUMINANCE12_ALPHA4: + case GL_LUMINANCE12_ALPHA12: + case GL_LUMINANCE16_ALPHA16: + return ctx->Extensions.ARB_framebuffer_object ? GL_LUMINANCE_ALPHA : 0; + case GL_INTENSITY: + case GL_INTENSITY4: + case GL_INTENSITY8: + case GL_INTENSITY12: + case GL_INTENSITY16: + return ctx->Extensions.ARB_framebuffer_object ? GL_INTENSITY : 0; + case GL_RGB: + case GL_R3_G3_B2: + case GL_RGB4: + case GL_RGB5: + case GL_RGB8: + case GL_RGB10: + case GL_RGB12: + case GL_RGB16: + case GL_SRGB8_EXT: + return GL_RGB; + case GL_RGBA: + case GL_RGBA2: + case GL_RGBA4: + case GL_RGB5_A1: + case GL_RGBA8: + case GL_RGB10_A2: + case GL_RGBA12: + case GL_RGBA16: + case GL_SRGB8_ALPHA8_EXT: + return GL_RGBA; + case GL_STENCIL_INDEX: + case GL_STENCIL_INDEX1_EXT: + case GL_STENCIL_INDEX4_EXT: + case GL_STENCIL_INDEX8_EXT: + case GL_STENCIL_INDEX16_EXT: + return GL_STENCIL_INDEX; + case GL_DEPTH_COMPONENT: + case GL_DEPTH_COMPONENT16: + case GL_DEPTH_COMPONENT24: + case GL_DEPTH_COMPONENT32: + return GL_DEPTH_COMPONENT; + case GL_DEPTH_STENCIL_EXT: + case GL_DEPTH24_STENCIL8_EXT: + if (ctx->Extensions.EXT_packed_depth_stencil) + return GL_DEPTH_STENCIL_EXT; + else + return 0; + case GL_DEPTH_COMPONENT32F: + if (ctx->Extensions.ARB_depth_buffer_float) + return GL_DEPTH_COMPONENT; + else + return 0; + case GL_DEPTH32F_STENCIL8: + if (ctx->Extensions.ARB_depth_buffer_float) + return GL_DEPTH_STENCIL; + else + return 0; + case GL_RED: + case GL_R8: + case GL_R16: + return ctx->Extensions.ARB_texture_rg ? GL_RED : 0; + case GL_RG: + case GL_RG8: + case GL_RG16: + return ctx->Extensions.ARB_texture_rg ? GL_RG : 0; + /* signed normalized texture formats */ + case GL_RED_SNORM: + case GL_R8_SNORM: + case GL_R16_SNORM: + return ctx->Extensions.EXT_texture_snorm ? GL_RED : 0; + case GL_RG_SNORM: + case GL_RG8_SNORM: + case GL_RG16_SNORM: + return ctx->Extensions.EXT_texture_snorm ? GL_RG : 0; + case GL_RGB_SNORM: + case GL_RGB8_SNORM: + case GL_RGB16_SNORM: + return ctx->Extensions.EXT_texture_snorm ? GL_RGB : 0; + case GL_RGBA_SNORM: + case GL_RGBA8_SNORM: + case GL_RGBA16_SNORM: + return ctx->Extensions.EXT_texture_snorm ? GL_RGBA : 0; + case GL_ALPHA_SNORM: + case GL_ALPHA8_SNORM: + case GL_ALPHA16_SNORM: + return ctx->Extensions.EXT_texture_snorm && + ctx->Extensions.ARB_framebuffer_object ? GL_ALPHA : 0; + case GL_LUMINANCE_SNORM: + case GL_LUMINANCE8_SNORM: + case GL_LUMINANCE16_SNORM: + return ctx->Extensions.EXT_texture_snorm && + ctx->Extensions.ARB_framebuffer_object ? GL_LUMINANCE : 0; + case GL_LUMINANCE_ALPHA_SNORM: + case GL_LUMINANCE8_ALPHA8_SNORM: + case GL_LUMINANCE16_ALPHA16_SNORM: + return ctx->Extensions.EXT_texture_snorm && + ctx->Extensions.ARB_framebuffer_object ? GL_LUMINANCE_ALPHA : 0; + case GL_INTENSITY_SNORM: + case GL_INTENSITY8_SNORM: + case GL_INTENSITY16_SNORM: + return ctx->Extensions.EXT_texture_snorm && + ctx->Extensions.ARB_framebuffer_object ? GL_INTENSITY : 0; + case GL_R16F: + case GL_R32F: + return ctx->Extensions.ARB_texture_rg && + ctx->Extensions.ARB_texture_float ? GL_RED : 0; + case GL_RG16F: + case GL_RG32F: + return ctx->Extensions.ARB_texture_rg && + ctx->Extensions.ARB_texture_float ? GL_RG : 0; + case GL_RGB16F: + case GL_RGB32F: + return ctx->Extensions.ARB_texture_float ? GL_RGB : 0; + case GL_RGBA16F: + case GL_RGBA32F: + return ctx->Extensions.ARB_texture_float ? GL_RGBA : 0; + case GL_ALPHA16F_ARB: + case GL_ALPHA32F_ARB: + return ctx->Extensions.ARB_texture_float && + ctx->Extensions.ARB_framebuffer_object ? GL_ALPHA : 0; + case GL_LUMINANCE16F_ARB: + case GL_LUMINANCE32F_ARB: + return ctx->Extensions.ARB_texture_float && + ctx->Extensions.ARB_framebuffer_object ? GL_LUMINANCE : 0; + case GL_LUMINANCE_ALPHA16F_ARB: + case GL_LUMINANCE_ALPHA32F_ARB: + return ctx->Extensions.ARB_texture_float && + ctx->Extensions.ARB_framebuffer_object ? GL_LUMINANCE_ALPHA : 0; + case GL_INTENSITY16F_ARB: + case GL_INTENSITY32F_ARB: + return ctx->Extensions.ARB_texture_float && + ctx->Extensions.ARB_framebuffer_object ? GL_INTENSITY : 0; + case GL_RGB9_E5: + return ctx->Extensions.EXT_texture_shared_exponent ? GL_RGB : 0; + case GL_R11F_G11F_B10F: + return ctx->Extensions.EXT_packed_float ? GL_RGB : 0; + /* XXX add integer formats eventually */ + default: + return 0; + } +} + + +/** + * Invalidate a renderbuffer attachment. Called from _mesa_HashWalk(). + */ +static void +invalidate_rb(GLuint key, void *data, void *userData) +{ + struct gl_framebuffer *fb = (struct gl_framebuffer *) data; + struct gl_renderbuffer *rb = (struct gl_renderbuffer *) userData; + + /* If this is a user-created FBO */ + if (is_user_fbo(fb)) { + GLuint i; + for (i = 0; i < BUFFER_COUNT; i++) { + struct gl_renderbuffer_attachment *att = fb->Attachment + i; + if (att->Type == GL_RENDERBUFFER && + att->Renderbuffer == rb) { + /* Mark fb status as indeterminate to force re-validation */ + fb->_Status = 0; + return; + } + } + } +} + + +/** sentinal value, see below */ +#define NO_SAMPLES 1000 + + +/** + * Helper function used by _mesa_RenderbufferStorageEXT() and + * _mesa_RenderbufferStorageMultisample(). + * samples will be NO_SAMPLES if called by _mesa_RenderbufferStorageEXT(). + */ +static void +renderbuffer_storage(GLenum target, GLenum internalFormat, + GLsizei width, GLsizei height, GLsizei samples) +{ + const char *func = samples == NO_SAMPLES ? + "glRenderbufferStorage" : "RenderbufferStorageMultisample"; + struct gl_renderbuffer *rb; + GLenum baseFormat; + GET_CURRENT_CONTEXT(ctx); + + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (target != GL_RENDERBUFFER_EXT) { + _mesa_error(ctx, GL_INVALID_ENUM, "%s(target)", func); + return; + } + + baseFormat = _mesa_base_fbo_format(ctx, internalFormat); + if (baseFormat == 0) { + _mesa_error(ctx, GL_INVALID_ENUM, "%s(internalFormat)", func); + return; + } + + if (width < 1 || width > (GLsizei) ctx->Const.MaxRenderbufferSize) { + _mesa_error(ctx, GL_INVALID_VALUE, "%s(width)", func); + return; + } + + if (height < 1 || height > (GLsizei) ctx->Const.MaxRenderbufferSize) { + _mesa_error(ctx, GL_INVALID_VALUE, "%s(height)", func); + return; + } + + if (samples == NO_SAMPLES) { + /* NumSamples == 0 indicates non-multisampling */ + samples = 0; + } + else if (samples > (GLsizei) ctx->Const.MaxSamples) { + /* note: driver may choose to use more samples than what's requested */ + _mesa_error(ctx, GL_INVALID_VALUE, "%s(samples)", func); + return; + } + + rb = ctx->CurrentRenderbuffer; + if (!rb) { + _mesa_error(ctx, GL_INVALID_OPERATION, "%s", func); + return; + } + + FLUSH_VERTICES(ctx, _NEW_BUFFERS); + + if (rb->InternalFormat == internalFormat && + rb->Width == (GLuint) width && + rb->Height == (GLuint) height) { + /* no change in allocation needed */ + return; + } + + /* These MUST get set by the AllocStorage func */ + rb->Format = MESA_FORMAT_NONE; + rb->NumSamples = samples; + + /* Now allocate the storage */ + ASSERT(rb->AllocStorage); + if (rb->AllocStorage(ctx, rb, internalFormat, width, height)) { + /* No error - check/set fields now */ + assert(rb->Format != MESA_FORMAT_NONE); + assert(rb->Width == (GLuint) width); + assert(rb->Height == (GLuint) height); + rb->InternalFormat = internalFormat; + rb->_BaseFormat = baseFormat; + assert(rb->_BaseFormat != 0); + } + else { + /* Probably ran out of memory - clear the fields */ + rb->Width = 0; + rb->Height = 0; + rb->Format = MESA_FORMAT_NONE; + rb->InternalFormat = GL_NONE; + rb->_BaseFormat = GL_NONE; + rb->NumSamples = 0; + } + + /* Invalidate the framebuffers the renderbuffer is attached in. */ + if (rb->AttachedAnytime) { + _mesa_HashWalk(ctx->Shared->FrameBuffers, invalidate_rb, rb); + } +} + + +#if FEATURE_OES_EGL_image +void GLAPIENTRY +_mesa_EGLImageTargetRenderbufferStorageOES(GLenum target, GLeglImageOES image) +{ + struct gl_renderbuffer *rb; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (!ctx->Extensions.OES_EGL_image) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glEGLImageTargetRenderbufferStorageOES(unsupported)"); + return; + } + + if (target != GL_RENDERBUFFER) { + _mesa_error(ctx, GL_INVALID_ENUM, + "EGLImageTargetRenderbufferStorageOES"); + return; + } + + rb = ctx->CurrentRenderbuffer; + if (!rb) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "EGLImageTargetRenderbufferStorageOES"); + return; + } + + FLUSH_VERTICES(ctx, _NEW_BUFFERS); + + ctx->Driver.EGLImageTargetRenderbufferStorage(ctx, rb, image); +} +#endif + + +/** + * Helper function for _mesa_GetRenderbufferParameterivEXT() and + * _mesa_GetFramebufferAttachmentParameterivEXT() + * We have to be careful to respect the base format. For example, if a + * renderbuffer/texture was created with internalFormat=GL_RGB but the + * driver actually chose a GL_RGBA format, when the user queries ALPHA_SIZE + * we need to return zero. + */ +static GLint +get_component_bits(GLenum pname, GLenum baseFormat, gl_format format) +{ + switch (pname) { + case GL_RENDERBUFFER_RED_SIZE_EXT: + case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE: + if (baseFormat == GL_RGB || baseFormat == GL_RGBA || + baseFormat == GL_RG || baseFormat == GL_RED) + return _mesa_get_format_bits(format, pname); + else + return 0; + case GL_RENDERBUFFER_GREEN_SIZE_EXT: + case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE: + if (baseFormat == GL_RGB || baseFormat == GL_RGBA || baseFormat == GL_RG) + return _mesa_get_format_bits(format, pname); + else + return 0; + case GL_RENDERBUFFER_BLUE_SIZE_EXT: + case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE: + if (baseFormat == GL_RGB || baseFormat == GL_RGBA) + return _mesa_get_format_bits(format, pname); + else + return 0; + case GL_RENDERBUFFER_ALPHA_SIZE_EXT: + case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE: + if (baseFormat == GL_RGBA || baseFormat == GL_ALPHA || + baseFormat == GL_LUMINANCE_ALPHA) + return _mesa_get_format_bits(format, pname); + else + return 0; + case GL_RENDERBUFFER_DEPTH_SIZE_EXT: + case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE: + if (baseFormat == GL_DEPTH_COMPONENT || baseFormat == GL_DEPTH_STENCIL) + return _mesa_get_format_bits(format, pname); + else + return 0; + case GL_RENDERBUFFER_STENCIL_SIZE_EXT: + case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE: + if (baseFormat == GL_STENCIL_INDEX || baseFormat == GL_DEPTH_STENCIL) + return _mesa_get_format_bits(format, pname); + else + return 0; + default: + return 0; + } +} + + + +void GLAPIENTRY +_mesa_RenderbufferStorageEXT(GLenum target, GLenum internalFormat, + GLsizei width, GLsizei height) +{ + /* GL_ARB_fbo says calling this function is equivalent to calling + * glRenderbufferStorageMultisample() with samples=0. We pass in + * a token value here just for error reporting purposes. + */ + renderbuffer_storage(target, internalFormat, width, height, NO_SAMPLES); +} + + +void GLAPIENTRY +_mesa_RenderbufferStorageMultisample(GLenum target, GLsizei samples, + GLenum internalFormat, + GLsizei width, GLsizei height) +{ + renderbuffer_storage(target, internalFormat, width, height, samples); +} + + +/** + * OpenGL ES version of glRenderBufferStorage. + */ +void GLAPIENTRY +_es_RenderbufferStorageEXT(GLenum target, GLenum internalFormat, + GLsizei width, GLsizei height) +{ + switch (internalFormat) { + case GL_RGB565: + /* XXX this confuses GL_RENDERBUFFER_INTERNAL_FORMAT_OES */ + /* choose a closest format */ + internalFormat = GL_RGB5; + break; + default: + break; + } + + renderbuffer_storage(target, internalFormat, width, height, 0); +} + + +void GLAPIENTRY +_mesa_GetRenderbufferParameterivEXT(GLenum target, GLenum pname, GLint *params) +{ + struct gl_renderbuffer *rb; + GET_CURRENT_CONTEXT(ctx); + + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (target != GL_RENDERBUFFER_EXT) { + _mesa_error(ctx, GL_INVALID_ENUM, + "glGetRenderbufferParameterivEXT(target)"); + return; + } + + rb = ctx->CurrentRenderbuffer; + if (!rb) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glGetRenderbufferParameterivEXT"); + return; + } + + /* No need to flush here since we're just quering state which is + * not effected by rendering. + */ + + switch (pname) { + case GL_RENDERBUFFER_WIDTH_EXT: + *params = rb->Width; + return; + case GL_RENDERBUFFER_HEIGHT_EXT: + *params = rb->Height; + return; + case GL_RENDERBUFFER_INTERNAL_FORMAT_EXT: + *params = rb->InternalFormat; + return; + case GL_RENDERBUFFER_RED_SIZE_EXT: + case GL_RENDERBUFFER_GREEN_SIZE_EXT: + case GL_RENDERBUFFER_BLUE_SIZE_EXT: + case GL_RENDERBUFFER_ALPHA_SIZE_EXT: + case GL_RENDERBUFFER_DEPTH_SIZE_EXT: + case GL_RENDERBUFFER_STENCIL_SIZE_EXT: + *params = get_component_bits(pname, rb->_BaseFormat, rb->Format); + break; + case GL_RENDERBUFFER_SAMPLES: + if (ctx->Extensions.ARB_framebuffer_object) { + *params = rb->NumSamples; + break; + } + /* fallthrough */ + default: + _mesa_error(ctx, GL_INVALID_ENUM, + "glGetRenderbufferParameterivEXT(target)"); + return; + } +} + + +GLboolean GLAPIENTRY +_mesa_IsFramebufferEXT(GLuint framebuffer) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); + if (framebuffer) { + struct gl_framebuffer *rb = _mesa_lookup_framebuffer(ctx, framebuffer); + if (rb != NULL && rb != &DummyFramebuffer) + return GL_TRUE; + } + return GL_FALSE; +} + + +/** + * Check if any of the attachments of the given framebuffer are textures + * (render to texture). Call ctx->Driver.RenderTexture() for such + * attachments. + */ +static void +check_begin_texture_render(struct gl_context *ctx, struct gl_framebuffer *fb) +{ + GLuint i; + ASSERT(ctx->Driver.RenderTexture); + + if (is_winsys_fbo(fb)) + return; /* can't render to texture with winsys framebuffers */ + + for (i = 0; i < BUFFER_COUNT; i++) { + struct gl_renderbuffer_attachment *att = fb->Attachment + i; + if (att->Texture && _mesa_get_attachment_teximage(att)) { + ctx->Driver.RenderTexture(ctx, fb, att); + } + } +} + + +/** + * Examine all the framebuffer's attachments to see if any are textures. + * If so, call ctx->Driver.FinishRenderTexture() for each texture to + * notify the device driver that the texture image may have changed. + */ +static void +check_end_texture_render(struct gl_context *ctx, struct gl_framebuffer *fb) +{ + if (is_winsys_fbo(fb)) + return; /* can't render to texture with winsys framebuffers */ + + if (ctx->Driver.FinishRenderTexture) { + GLuint i; + for (i = 0; i < BUFFER_COUNT; i++) { + struct gl_renderbuffer_attachment *att = fb->Attachment + i; + if (att->Texture && att->Renderbuffer) { + ctx->Driver.FinishRenderTexture(ctx, att); + } + } + } +} + + +void GLAPIENTRY +_mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer) +{ + struct gl_framebuffer *newDrawFb, *newReadFb; + struct gl_framebuffer *oldDrawFb, *oldReadFb; + GLboolean bindReadBuf, bindDrawBuf; + GET_CURRENT_CONTEXT(ctx); + +#ifdef DEBUG + if (ctx->Extensions.ARB_framebuffer_object) { + ASSERT(ctx->Extensions.EXT_framebuffer_object); + ASSERT(ctx->Extensions.EXT_framebuffer_blit); + } +#endif + + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (!ctx->Extensions.EXT_framebuffer_object) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glBindFramebufferEXT(unsupported)"); + return; + } + + switch (target) { +#if FEATURE_EXT_framebuffer_blit + case GL_DRAW_FRAMEBUFFER_EXT: + if (!ctx->Extensions.EXT_framebuffer_blit) { + _mesa_error(ctx, GL_INVALID_ENUM, "glBindFramebufferEXT(target)"); + return; + } + bindDrawBuf = GL_TRUE; + bindReadBuf = GL_FALSE; + break; + case GL_READ_FRAMEBUFFER_EXT: + if (!ctx->Extensions.EXT_framebuffer_blit) { + _mesa_error(ctx, GL_INVALID_ENUM, "glBindFramebufferEXT(target)"); + return; + } + bindDrawBuf = GL_FALSE; + bindReadBuf = GL_TRUE; + break; +#endif + case GL_FRAMEBUFFER_EXT: + bindDrawBuf = GL_TRUE; + bindReadBuf = GL_TRUE; + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, "glBindFramebufferEXT(target)"); + return; + } + + if (framebuffer) { + /* Binding a user-created framebuffer object */ + newDrawFb = _mesa_lookup_framebuffer(ctx, framebuffer); + if (newDrawFb == &DummyFramebuffer) { + /* ID was reserved, but no real framebuffer object made yet */ + newDrawFb = NULL; + } + else if (!newDrawFb && ctx->Extensions.ARB_framebuffer_object) { + /* All FBO IDs must be Gen'd */ + _mesa_error(ctx, GL_INVALID_OPERATION, "glBindFramebuffer(buffer)"); + return; + } + + if (!newDrawFb) { + /* create new framebuffer object */ + newDrawFb = ctx->Driver.NewFramebuffer(ctx, framebuffer); + if (!newDrawFb) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindFramebufferEXT"); + return; + } + _mesa_HashInsert(ctx->Shared->FrameBuffers, framebuffer, newDrawFb); + } + newReadFb = newDrawFb; + } + else { + /* Binding the window system framebuffer (which was originally set + * with MakeCurrent). + */ + newDrawFb = ctx->WinSysDrawBuffer; + newReadFb = ctx->WinSysReadBuffer; + } + + ASSERT(newDrawFb); + ASSERT(newDrawFb != &DummyFramebuffer); + + /* save pointers to current/old framebuffers */ + oldDrawFb = ctx->DrawBuffer; + oldReadFb = ctx->ReadBuffer; + + /* check if really changing bindings */ + if (oldDrawFb == newDrawFb) + bindDrawBuf = GL_FALSE; + if (oldReadFb == newReadFb) + bindReadBuf = GL_FALSE; + + /* + * OK, now bind the new Draw/Read framebuffers, if they're changing. + * + * We also check if we're beginning and/or ending render-to-texture. + * When a framebuffer with texture attachments is unbound, call + * ctx->Driver.FinishRenderTexture(). + * When a framebuffer with texture attachments is bound, call + * ctx->Driver.RenderTexture(). + * + * Note that if the ReadBuffer has texture attachments we don't consider + * that a render-to-texture case. + */ + if (bindReadBuf) { + FLUSH_VERTICES(ctx, _NEW_BUFFERS); + + /* check if old readbuffer was render-to-texture */ + check_end_texture_render(ctx, oldReadFb); + + _mesa_reference_framebuffer(&ctx->ReadBuffer, newReadFb); + } + + if (bindDrawBuf) { + FLUSH_VERTICES(ctx, _NEW_BUFFERS); + + /* check if old read/draw buffers were render-to-texture */ + if (!bindReadBuf) + check_end_texture_render(ctx, oldReadFb); + + if (oldDrawFb != oldReadFb) + check_end_texture_render(ctx, oldDrawFb); + + /* check if newly bound framebuffer has any texture attachments */ + check_begin_texture_render(ctx, newDrawFb); + + _mesa_reference_framebuffer(&ctx->DrawBuffer, newDrawFb); + } + + if ((bindDrawBuf || bindReadBuf) && ctx->Driver.BindFramebuffer) { + ctx->Driver.BindFramebuffer(ctx, target, newDrawFb, newReadFb); + } +} + + +void GLAPIENTRY +_mesa_DeleteFramebuffersEXT(GLsizei n, const GLuint *framebuffers) +{ + GLint i; + GET_CURRENT_CONTEXT(ctx); + + ASSERT_OUTSIDE_BEGIN_END(ctx); + FLUSH_VERTICES(ctx, _NEW_BUFFERS); + + for (i = 0; i < n; i++) { + if (framebuffers[i] > 0) { + struct gl_framebuffer *fb; + fb = _mesa_lookup_framebuffer(ctx, framebuffers[i]); + if (fb) { + ASSERT(fb == &DummyFramebuffer || fb->Name == framebuffers[i]); + + /* check if deleting currently bound framebuffer object */ + if (ctx->Extensions.EXT_framebuffer_blit) { + /* separate draw/read binding points */ + if (fb == ctx->DrawBuffer) { + /* bind default */ + ASSERT(fb->RefCount >= 2); + _mesa_BindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, 0); + } + if (fb == ctx->ReadBuffer) { + /* bind default */ + ASSERT(fb->RefCount >= 2); + _mesa_BindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, 0); + } + } + else { + /* only one binding point for read/draw buffers */ + if (fb == ctx->DrawBuffer || fb == ctx->ReadBuffer) { + /* bind default */ + ASSERT(fb->RefCount >= 2); + _mesa_BindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); + } + } + + /* remove from hash table immediately, to free the ID */ + _mesa_HashRemove(ctx->Shared->FrameBuffers, framebuffers[i]); + + if (fb != &DummyFramebuffer) { + /* But the object will not be freed until it's no longer + * bound in any context. + */ + _mesa_reference_framebuffer(&fb, NULL); + } + } + } + } +} + + +void GLAPIENTRY +_mesa_GenFramebuffersEXT(GLsizei n, GLuint *framebuffers) +{ + GET_CURRENT_CONTEXT(ctx); + GLuint first; + GLint i; + + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (n < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glGenFramebuffersEXT(n)"); + return; + } + + if (!framebuffers) + return; + + first = _mesa_HashFindFreeKeyBlock(ctx->Shared->FrameBuffers, n); + + for (i = 0; i < n; i++) { + GLuint name = first + i; + framebuffers[i] = name; + /* insert dummy placeholder into hash table */ + _glthread_LOCK_MUTEX(ctx->Shared->Mutex); + _mesa_HashInsert(ctx->Shared->FrameBuffers, name, &DummyFramebuffer); + _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); + } +} + + + +GLenum GLAPIENTRY +_mesa_CheckFramebufferStatusEXT(GLenum target) +{ + struct gl_framebuffer *buffer; + GET_CURRENT_CONTEXT(ctx); + + ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, 0); + + buffer = get_framebuffer_target(ctx, target); + if (!buffer) { + _mesa_error(ctx, GL_INVALID_ENUM, "glCheckFramebufferStatus(target)"); + return 0; + } + + if (is_winsys_fbo(buffer)) { + /* The window system / default framebuffer is always complete */ + return GL_FRAMEBUFFER_COMPLETE_EXT; + } + + /* No need to flush here */ + + if (buffer->_Status != GL_FRAMEBUFFER_COMPLETE) { + _mesa_test_framebuffer_completeness(ctx, buffer); + } + + return buffer->_Status; +} + + + +/** + * Common code called by glFramebufferTexture1D/2D/3DEXT(). + */ +static void +framebuffer_texture(struct gl_context *ctx, const char *caller, GLenum target, + GLenum attachment, GLenum textarget, GLuint texture, + GLint level, GLint zoffset) +{ + struct gl_renderbuffer_attachment *att; + struct gl_texture_object *texObj = NULL; + struct gl_framebuffer *fb; + + ASSERT_OUTSIDE_BEGIN_END(ctx); + + fb = get_framebuffer_target(ctx, target); + if (!fb) { + _mesa_error(ctx, GL_INVALID_ENUM, + "glFramebufferTexture%sEXT(target=0x%x)", caller, target); + return; + } + + /* check framebuffer binding */ + if (is_winsys_fbo(fb)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glFramebufferTexture%sEXT", caller); + return; + } + + + /* The textarget, level, and zoffset parameters are only validated if + * texture is non-zero. + */ + if (texture) { + GLboolean err = GL_TRUE; + + texObj = _mesa_lookup_texture(ctx, texture); + if (texObj != NULL) { + if (textarget == 0) { + /* XXX what's the purpose of this? */ + err = (texObj->Target != GL_TEXTURE_3D) && + (texObj->Target != GL_TEXTURE_1D_ARRAY_EXT) && + (texObj->Target != GL_TEXTURE_2D_ARRAY_EXT); + } + else { + err = (texObj->Target == GL_TEXTURE_CUBE_MAP) + ? !is_cube_face(textarget) + : (texObj->Target != textarget); + } + } + else { + /* can't render to a non-existant texture */ + _mesa_error(ctx, GL_INVALID_OPERATION, + "glFramebufferTexture%sEXT(non existant texture)", + caller); + return; + } + + if (err) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glFramebufferTexture%sEXT(texture target mismatch)", + caller); + return; + } + + if (texObj->Target == GL_TEXTURE_3D) { + const GLint maxSize = 1 << (ctx->Const.Max3DTextureLevels - 1); + if (zoffset < 0 || zoffset >= maxSize) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glFramebufferTexture%sEXT(zoffset)", caller); + return; + } + } + else if ((texObj->Target == GL_TEXTURE_1D_ARRAY_EXT) || + (texObj->Target == GL_TEXTURE_2D_ARRAY_EXT)) { + if (zoffset < 0 || zoffset >= ctx->Const.MaxArrayTextureLayers) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glFramebufferTexture%sEXT(layer)", caller); + return; + } + } + + if ((level < 0) || + (level >= _mesa_max_texture_levels(ctx, texObj->Target))) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glFramebufferTexture%sEXT(level)", caller); + return; + } + } + + att = _mesa_get_attachment(ctx, fb, attachment); + if (att == NULL) { + _mesa_error(ctx, GL_INVALID_ENUM, + "glFramebufferTexture%sEXT(attachment)", caller); + return; + } + + FLUSH_VERTICES(ctx, _NEW_BUFFERS); + + _glthread_LOCK_MUTEX(fb->Mutex); + if (texObj) { + _mesa_set_texture_attachment(ctx, fb, att, texObj, textarget, + level, zoffset); + /* Set the render-to-texture flag. We'll check this flag in + * glTexImage() and friends to determine if we need to revalidate + * any FBOs that might be rendering into this texture. + * This flag never gets cleared since it's non-trivial to determine + * when all FBOs might be done rendering to this texture. That's OK + * though since it's uncommon to render to a texture then repeatedly + * call glTexImage() to change images in the texture. + */ + texObj->_RenderToTexture = GL_TRUE; + } + else { + _mesa_remove_attachment(ctx, att); + } + + invalidate_framebuffer(fb); + + _glthread_UNLOCK_MUTEX(fb->Mutex); +} + + + +void GLAPIENTRY +_mesa_FramebufferTexture1DEXT(GLenum target, GLenum attachment, + GLenum textarget, GLuint texture, GLint level) +{ + GET_CURRENT_CONTEXT(ctx); + + if (texture != 0) { + GLboolean error; + + switch (textarget) { + case GL_TEXTURE_1D: + error = GL_FALSE; + break; + case GL_TEXTURE_1D_ARRAY: + error = !ctx->Extensions.EXT_texture_array; + break; + default: + error = GL_TRUE; + } + + if (error) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glFramebufferTexture1DEXT(textarget=%s)", + _mesa_lookup_enum_by_nr(textarget)); + return; + } + } + + framebuffer_texture(ctx, "1D", target, attachment, textarget, texture, + level, 0); +} + + +void GLAPIENTRY +_mesa_FramebufferTexture2DEXT(GLenum target, GLenum attachment, + GLenum textarget, GLuint texture, GLint level) +{ + GET_CURRENT_CONTEXT(ctx); + + if (texture != 0) { + GLboolean error; + + switch (textarget) { + case GL_TEXTURE_2D: + error = GL_FALSE; + break; + case GL_TEXTURE_RECTANGLE: + error = !ctx->Extensions.NV_texture_rectangle; + break; + case GL_TEXTURE_CUBE_MAP_POSITIVE_X: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: + error = !ctx->Extensions.ARB_texture_cube_map; + break; + case GL_TEXTURE_2D_ARRAY: + error = !ctx->Extensions.EXT_texture_array; + break; + default: + error = GL_FALSE; + } + + if (error) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glFramebufferTexture2DEXT(textarget=%s)", + _mesa_lookup_enum_by_nr(textarget)); + return; + } + } + + framebuffer_texture(ctx, "2D", target, attachment, textarget, texture, + level, 0); +} + + +void GLAPIENTRY +_mesa_FramebufferTexture3DEXT(GLenum target, GLenum attachment, + GLenum textarget, GLuint texture, + GLint level, GLint zoffset) +{ + GET_CURRENT_CONTEXT(ctx); + + if ((texture != 0) && (textarget != GL_TEXTURE_3D)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glFramebufferTexture3DEXT(textarget)"); + return; + } + + framebuffer_texture(ctx, "3D", target, attachment, textarget, texture, + level, zoffset); +} + + +void GLAPIENTRY +_mesa_FramebufferTextureLayerEXT(GLenum target, GLenum attachment, + GLuint texture, GLint level, GLint layer) +{ + GET_CURRENT_CONTEXT(ctx); + + framebuffer_texture(ctx, "Layer", target, attachment, 0, texture, + level, layer); +} + + +void GLAPIENTRY +_mesa_FramebufferRenderbufferEXT(GLenum target, GLenum attachment, + GLenum renderbufferTarget, + GLuint renderbuffer) +{ + struct gl_renderbuffer_attachment *att; + struct gl_framebuffer *fb; + struct gl_renderbuffer *rb; + GET_CURRENT_CONTEXT(ctx); + + ASSERT_OUTSIDE_BEGIN_END(ctx); + + fb = get_framebuffer_target(ctx, target); + if (!fb) { + _mesa_error(ctx, GL_INVALID_ENUM, "glFramebufferRenderbufferEXT(target)"); + return; + } + + if (renderbufferTarget != GL_RENDERBUFFER_EXT) { + _mesa_error(ctx, GL_INVALID_ENUM, + "glFramebufferRenderbufferEXT(renderbufferTarget)"); + return; + } + + if (is_winsys_fbo(fb)) { + /* Can't attach new renderbuffers to a window system framebuffer */ + _mesa_error(ctx, GL_INVALID_OPERATION, "glFramebufferRenderbufferEXT"); + return; + } + + att = _mesa_get_attachment(ctx, fb, attachment); + if (att == NULL) { + _mesa_error(ctx, GL_INVALID_ENUM, + "glFramebufferRenderbufferEXT(invalid attachment %s)", + _mesa_lookup_enum_by_nr(attachment)); + return; + } + + if (renderbuffer) { + rb = _mesa_lookup_renderbuffer(ctx, renderbuffer); + if (!rb) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glFramebufferRenderbufferEXT(non-existant" + " renderbuffer %u)", renderbuffer); + return; + } + else if (rb == &DummyRenderbuffer) { + /* This is what NVIDIA does */ + _mesa_error(ctx, GL_INVALID_VALUE, + "glFramebufferRenderbufferEXT(renderbuffer %u)", + renderbuffer); + return; + } + } + else { + /* remove renderbuffer attachment */ + rb = NULL; + } + + if (attachment == GL_DEPTH_STENCIL_ATTACHMENT && + rb && rb->Format != MESA_FORMAT_NONE) { + /* make sure the renderbuffer is a depth/stencil format */ + const GLenum baseFormat = _mesa_get_format_base_format(rb->Format); + if (baseFormat != GL_DEPTH_STENCIL) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glFramebufferRenderbufferEXT(renderbuffer" + " is not DEPTH_STENCIL format)"); + return; + } + } + + + FLUSH_VERTICES(ctx, _NEW_BUFFERS); + + assert(ctx->Driver.FramebufferRenderbuffer); + ctx->Driver.FramebufferRenderbuffer(ctx, fb, attachment, rb); + + /* Some subsequent GL commands may depend on the framebuffer's visual + * after the binding is updated. Update visual info now. + */ + _mesa_update_framebuffer_visual(ctx, fb); +} + + +void GLAPIENTRY +_mesa_GetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment, + GLenum pname, GLint *params) +{ + const struct gl_renderbuffer_attachment *att; + struct gl_framebuffer *buffer; + GLenum err; + GET_CURRENT_CONTEXT(ctx); + + ASSERT_OUTSIDE_BEGIN_END(ctx); + + /* The error differs in GL andd GLES. */ + err = ctx->API == API_OPENGL ? GL_INVALID_OPERATION : GL_INVALID_ENUM; + + buffer = get_framebuffer_target(ctx, target); + if (!buffer) { + _mesa_error(ctx, GL_INVALID_ENUM, + "glGetFramebufferAttachmentParameterivEXT(target)"); + return; + } + + if (is_winsys_fbo(buffer)) { + /* the default / window-system FBO */ + att = _mesa_get_fb0_attachment(ctx, buffer, attachment); + } + else { + /* user-created framebuffer FBO */ + att = _mesa_get_attachment(ctx, buffer, attachment); + } + + if (att == NULL) { + _mesa_error(ctx, GL_INVALID_ENUM, + "glGetFramebufferAttachmentParameterivEXT(attachment)"); + return; + } + + if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) { + /* the depth and stencil attachments must point to the same buffer */ + const struct gl_renderbuffer_attachment *depthAtt, *stencilAtt; + depthAtt = _mesa_get_attachment(ctx, buffer, GL_DEPTH_ATTACHMENT); + stencilAtt = _mesa_get_attachment(ctx, buffer, GL_STENCIL_ATTACHMENT); + if (depthAtt->Renderbuffer != stencilAtt->Renderbuffer) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glGetFramebufferAttachmentParameterivEXT(DEPTH/STENCIL" + " attachments differ)"); + return; + } + } + + /* No need to flush here */ + + switch (pname) { + case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT: + *params = is_winsys_fbo(buffer) ? GL_FRAMEBUFFER_DEFAULT : att->Type; + return; + case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT: + if (att->Type == GL_RENDERBUFFER_EXT) { + *params = att->Renderbuffer->Name; + } + else if (att->Type == GL_TEXTURE) { + *params = att->Texture->Name; + } + else { + assert(att->Type == GL_NONE); + if (ctx->API == API_OPENGL) { + *params = 0; + } else { + _mesa_error(ctx, GL_INVALID_ENUM, + "glGetFramebufferAttachmentParameterivEXT(pname)"); + } + } + return; + case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT: + if (att->Type == GL_TEXTURE) { + *params = att->TextureLevel; + } + else if (att->Type == GL_NONE) { + _mesa_error(ctx, err, + "glGetFramebufferAttachmentParameterivEXT(pname)"); + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, + "glGetFramebufferAttachmentParameterivEXT(pname)"); + } + return; + case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT: + if (att->Type == GL_TEXTURE) { + if (att->Texture && att->Texture->Target == GL_TEXTURE_CUBE_MAP) { + *params = GL_TEXTURE_CUBE_MAP_POSITIVE_X + att->CubeMapFace; + } + else { + *params = 0; + } + } + else if (att->Type == GL_NONE) { + _mesa_error(ctx, err, + "glGetFramebufferAttachmentParameterivEXT(pname)"); + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, + "glGetFramebufferAttachmentParameterivEXT(pname)"); + } + return; + case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT: + if (att->Type == GL_TEXTURE) { + if (att->Texture && att->Texture->Target == GL_TEXTURE_3D) { + *params = att->Zoffset; + } + else { + *params = 0; + } + } + else if (att->Type == GL_NONE) { + _mesa_error(ctx, err, + "glGetFramebufferAttachmentParameterivEXT(pname)"); + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, + "glGetFramebufferAttachmentParameterivEXT(pname)"); + } + return; + case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING: + if (!ctx->Extensions.ARB_framebuffer_object) { + _mesa_error(ctx, GL_INVALID_ENUM, + "glGetFramebufferAttachmentParameterivEXT(pname)"); + } + else if (att->Type == GL_NONE) { + _mesa_error(ctx, err, + "glGetFramebufferAttachmentParameterivEXT(pname)"); + } + else { + if (ctx->Extensions.EXT_framebuffer_sRGB && ctx->Const.sRGBCapable) { + *params = _mesa_get_format_color_encoding(att->Renderbuffer->Format); + } + else { + /* According to ARB_framebuffer_sRGB, we should return LINEAR + * if the sRGB conversion is unsupported. */ + *params = GL_LINEAR; + } + } + return; + case GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE: + if (!ctx->Extensions.ARB_framebuffer_object) { + _mesa_error(ctx, GL_INVALID_ENUM, + "glGetFramebufferAttachmentParameterivEXT(pname)"); + return; + } + else if (att->Type == GL_NONE) { + _mesa_error(ctx, err, + "glGetFramebufferAttachmentParameterivEXT(pname)"); + } + else { + gl_format format = att->Renderbuffer->Format; + if (format == MESA_FORMAT_S8) { + /* special cases */ + *params = GL_INDEX; + } + else if (format == MESA_FORMAT_Z32_FLOAT_X24S8) { + /* depends on the attachment parameter */ + if (attachment == GL_STENCIL_ATTACHMENT) { + *params = GL_INDEX; + } + else { + *params = GL_FLOAT; + } + } + else { + *params = _mesa_get_format_datatype(format); + } + } + return; + case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE: + case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE: + case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE: + case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE: + case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE: + case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE: + if (!ctx->Extensions.ARB_framebuffer_object) { + _mesa_error(ctx, GL_INVALID_ENUM, + "glGetFramebufferAttachmentParameterivEXT(pname)"); + } + else if (att->Type == GL_NONE) { + _mesa_error(ctx, err, + "glGetFramebufferAttachmentParameterivEXT(pname)"); + } + else if (att->Texture) { + const struct gl_texture_image *texImage = + _mesa_select_tex_image(ctx, att->Texture, att->Texture->Target, + att->TextureLevel); + if (texImage) { + *params = get_component_bits(pname, texImage->_BaseFormat, + texImage->TexFormat); + } + else { + *params = 0; + } + } + else if (att->Renderbuffer) { + *params = get_component_bits(pname, att->Renderbuffer->_BaseFormat, + att->Renderbuffer->Format); + } + else { + _mesa_problem(ctx, "glGetFramebufferAttachmentParameterivEXT:" + " invalid FBO attachment structure"); + } + return; + default: + _mesa_error(ctx, GL_INVALID_ENUM, + "glGetFramebufferAttachmentParameterivEXT(pname)"); + return; + } +} + + +void GLAPIENTRY +_mesa_GenerateMipmapEXT(GLenum target) +{ + struct gl_texture_object *texObj; + GLboolean error; + + GET_CURRENT_CONTEXT(ctx); + + ASSERT_OUTSIDE_BEGIN_END(ctx); + FLUSH_VERTICES(ctx, _NEW_BUFFERS); + + switch (target) { + case GL_TEXTURE_1D: + case GL_TEXTURE_2D: + case GL_TEXTURE_3D: + error = GL_FALSE; + break; + case GL_TEXTURE_CUBE_MAP: + error = !ctx->Extensions.ARB_texture_cube_map; + break; + case GL_TEXTURE_1D_ARRAY: + case GL_TEXTURE_2D_ARRAY: + error = !ctx->Extensions.EXT_texture_array; + break; + default: + error = GL_TRUE; + } + + if (error) { + _mesa_error(ctx, GL_INVALID_ENUM, "glGenerateMipmapEXT(target=%s)", + _mesa_lookup_enum_by_nr(target)); + return; + } + + texObj = _mesa_get_current_tex_object(ctx, target); + + if (texObj->BaseLevel >= texObj->MaxLevel) { + /* nothing to do */ + return; + } + + if (texObj->Target == GL_TEXTURE_CUBE_MAP && + !_mesa_cube_complete(texObj)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glGenerateMipmap(incomplete cube map)"); + return; + } + + _mesa_lock_texture(ctx, texObj); + if (target == GL_TEXTURE_CUBE_MAP) { + GLuint face; + for (face = 0; face < 6; face++) + ctx->Driver.GenerateMipmap(ctx, + GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB + face, + texObj); + } + else { + ctx->Driver.GenerateMipmap(ctx, target, texObj); + } + _mesa_unlock_texture(ctx, texObj); +} + + +#if FEATURE_EXT_framebuffer_blit + +static const struct gl_renderbuffer_attachment * +find_attachment(const struct gl_framebuffer *fb, + const struct gl_renderbuffer *rb) +{ + GLuint i; + for (i = 0; i < Elements(fb->Attachment); i++) { + if (fb->Attachment[i].Renderbuffer == rb) + return &fb->Attachment[i]; + } + return NULL; +} + + + +/** + * Blit rectangular region, optionally from one framebuffer to another. + * + * Note, if the src buffer is multisampled and the dest is not, this is + * when the samples must be resolved to a single color. + */ +void GLAPIENTRY +_mesa_BlitFramebufferEXT(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, + GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, + GLbitfield mask, GLenum filter) +{ + const GLbitfield legalMaskBits = (GL_COLOR_BUFFER_BIT | + GL_DEPTH_BUFFER_BIT | + GL_STENCIL_BUFFER_BIT); + const struct gl_framebuffer *readFb, *drawFb; + const struct gl_renderbuffer *colorReadRb, *colorDrawRb; + GET_CURRENT_CONTEXT(ctx); + + ASSERT_OUTSIDE_BEGIN_END(ctx); + FLUSH_VERTICES(ctx, _NEW_BUFFERS); + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, + "glBlitFramebuffer(%d, %d, %d, %d, %d, %d, %d, %d, 0x%x, %s)\n", + srcX0, srcY0, srcX1, srcY1, + dstX0, dstY0, dstX1, dstY1, + mask, _mesa_lookup_enum_by_nr(filter)); + + if (ctx->NewState) { + _mesa_update_state(ctx); + } + + readFb = ctx->ReadBuffer; + drawFb = ctx->DrawBuffer; + + if (!readFb || !drawFb) { + /* This will normally never happen but someday we may want to + * support MakeCurrent() with no drawables. + */ + return; + } + + /* check for complete framebuffers */ + if (drawFb->_Status != GL_FRAMEBUFFER_COMPLETE_EXT || + readFb->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) { + _mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION_EXT, + "glBlitFramebufferEXT(incomplete draw/read buffers)"); + return; + } + + if (filter != GL_NEAREST && filter != GL_LINEAR) { + _mesa_error(ctx, GL_INVALID_ENUM, "glBlitFramebufferEXT(filter)"); + return; + } + + if (mask & ~legalMaskBits) { + _mesa_error( ctx, GL_INVALID_VALUE, "glBlitFramebufferEXT(mask)"); + return; + } + + /* depth/stencil must be blitted with nearest filtering */ + if ((mask & (GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT)) + && filter != GL_NEAREST) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glBlitFramebufferEXT(depth/stencil requires GL_NEAREST filter)"); + return; + } + + /* get color read/draw renderbuffers */ + if (mask & GL_COLOR_BUFFER_BIT) { + colorReadRb = readFb->_ColorReadBuffer; + colorDrawRb = drawFb->_ColorDrawBuffers[0]; + + /* From the EXT_framebuffer_object spec: + * + * "If a buffer is specified in and does not exist in both + * the read and draw framebuffers, the corresponding bit is silently + * ignored." + */ + if ((colorReadRb == NULL) || (colorDrawRb == NULL)) { + colorReadRb = colorDrawRb = NULL; + mask &= ~GL_COLOR_BUFFER_BIT; + } + } + else { + colorReadRb = colorDrawRb = NULL; + } + + if (mask & GL_STENCIL_BUFFER_BIT) { + struct gl_renderbuffer *readRb = readFb->_StencilBuffer; + struct gl_renderbuffer *drawRb = drawFb->_StencilBuffer; + + /* From the EXT_framebuffer_object spec: + * + * "If a buffer is specified in and does not exist in both + * the read and draw framebuffers, the corresponding bit is silently + * ignored." + */ + if ((readRb == NULL) || (drawRb == NULL)) { + readRb = drawRb = NULL; + mask &= ~GL_STENCIL_BUFFER_BIT; + } + else if (_mesa_get_format_bits(readRb->Format, GL_STENCIL_BITS) != + _mesa_get_format_bits(drawRb->Format, GL_STENCIL_BITS)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glBlitFramebufferEXT(stencil buffer size mismatch)"); + return; + } + } + + if (mask & GL_DEPTH_BUFFER_BIT) { + struct gl_renderbuffer *readRb = readFb->_DepthBuffer; + struct gl_renderbuffer *drawRb = drawFb->_DepthBuffer; + + /* From the EXT_framebuffer_object spec: + * + * "If a buffer is specified in and does not exist in both + * the read and draw framebuffers, the corresponding bit is silently + * ignored." + */ + if ((readRb == NULL) || (drawRb == NULL)) { + readRb = drawRb = NULL; + mask &= ~GL_DEPTH_BUFFER_BIT; + } + else if (_mesa_get_format_bits(readRb->Format, GL_DEPTH_BITS) != + _mesa_get_format_bits(drawRb->Format, GL_DEPTH_BITS)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glBlitFramebufferEXT(depth buffer size mismatch)"); + return; + } + } + + if (readFb->Visual.samples > 0 && + drawFb->Visual.samples > 0 && + readFb->Visual.samples != drawFb->Visual.samples) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glBlitFramebufferEXT(mismatched samples"); + return; + } + + /* extra checks for multisample copies... */ + if (readFb->Visual.samples > 0 || drawFb->Visual.samples > 0) { + /* src and dest region sizes must be the same */ + if (srcX1 - srcX0 != dstX1 - dstX0 || + srcY1 - srcY0 != dstY1 - dstY0) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glBlitFramebufferEXT(bad src/dst multisample region sizes)"); + return; + } + + /* color formats must match */ + if (colorReadRb && + colorDrawRb && + colorReadRb->Format != colorDrawRb->Format) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glBlitFramebufferEXT(bad src/dst multisample pixel formats)"); + return; + } + } + + if (!ctx->Extensions.EXT_framebuffer_blit) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glBlitFramebufferEXT"); + return; + } + + /* Debug code */ + if (DEBUG_BLIT) { + printf("glBlitFramebuffer(%d, %d, %d, %d, %d, %d, %d, %d," + " 0x%x, 0x%x)\n", + srcX0, srcY0, srcX1, srcY1, + dstX0, dstY0, dstX1, dstY1, + mask, filter); + if (colorReadRb) { + const struct gl_renderbuffer_attachment *att; + + att = find_attachment(readFb, colorReadRb); + printf(" Src FBO %u RB %u (%dx%d) ", + readFb->Name, colorReadRb->Name, + colorReadRb->Width, colorReadRb->Height); + if (att && att->Texture) { + printf("Tex %u tgt 0x%x level %u face %u", + att->Texture->Name, + att->Texture->Target, + att->TextureLevel, + att->CubeMapFace); + } + printf("\n"); + + att = find_attachment(drawFb, colorDrawRb); + printf(" Dst FBO %u RB %u (%dx%d) ", + drawFb->Name, colorDrawRb->Name, + colorDrawRb->Width, colorDrawRb->Height); + if (att && att->Texture) { + printf("Tex %u tgt 0x%x level %u face %u", + att->Texture->Name, + att->Texture->Target, + att->TextureLevel, + att->CubeMapFace); + } + printf("\n"); + } + } + + if (!mask) { + return; + } + + ASSERT(ctx->Driver.BlitFramebuffer); + ctx->Driver.BlitFramebuffer(ctx, + srcX0, srcY0, srcX1, srcY1, + dstX0, dstY0, dstX1, dstY1, + mask, filter); +} +#endif /* FEATURE_EXT_framebuffer_blit */ + +#if FEATURE_ARB_geometry_shader4 +void GLAPIENTRY +_mesa_FramebufferTextureARB(GLenum target, GLenum attachment, + GLuint texture, GLint level) +{ + GET_CURRENT_CONTEXT(ctx); + _mesa_error(ctx, GL_INVALID_OPERATION, + "glFramebufferTextureARB " + "not implemented!"); +} + +void GLAPIENTRY +_mesa_FramebufferTextureFaceARB(GLenum target, GLenum attachment, + GLuint texture, GLint level, GLenum face) +{ + GET_CURRENT_CONTEXT(ctx); + _mesa_error(ctx, GL_INVALID_OPERATION, + "glFramebufferTextureFaceARB " + "not implemented!"); +} +#endif /* FEATURE_ARB_geometry_shader4 */ diff --git a/mesalib/src/mesa/main/ff_fragment_shader.cpp b/mesalib/src/mesa/main/ff_fragment_shader.cpp index d8635c0b5..7cc172168 100644 --- a/mesalib/src/mesa/main/ff_fragment_shader.cpp +++ b/mesalib/src/mesa/main/ff_fragment_shader.cpp @@ -1,1618 +1,1618 @@ -/************************************************************************** - * - * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. - * All Rights Reserved. - * Copyright 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, sub license, 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 (including the - * next paragraph) 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 NON-INFRINGEMENT. - * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS 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. - * - **************************************************************************/ - -extern "C" { -#include "glheader.h" -#include "imports.h" -#include "mtypes.h" -#include "program/program.h" -#include "program/prog_parameter.h" -#include "program/prog_cache.h" -#include "program/prog_instruction.h" -#include "program/prog_print.h" -#include "program/prog_statevars.h" -#include "program/programopt.h" -#include "texenvprogram.h" -} - -/* - * Note on texture units: - * - * The number of texture units supported by fixed-function fragment - * processing is MAX_TEXTURE_COORD_UNITS, not MAX_TEXTURE_IMAGE_UNITS. - * That's because there's a one-to-one correspondence between texture - * coordinates and samplers in fixed-function processing. - * - * Since fixed-function vertex processing is limited to MAX_TEXTURE_COORD_UNITS - * sets of texcoords, so is fixed-function fragment processing. - * - * We can safely use ctx->Const.MaxTextureUnits for loop bounds. - */ - - -struct texenvprog_cache_item -{ - GLuint hash; - void *key; - struct gl_fragment_program *data; - struct texenvprog_cache_item *next; -}; - -static GLboolean -texenv_doing_secondary_color(struct gl_context *ctx) -{ - if (ctx->Light.Enabled && - (ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR)) - return GL_TRUE; - - if (ctx->Fog.ColorSumEnabled) - return GL_TRUE; - - return GL_FALSE; -} - -/** - * Up to nine instructions per tex unit, plus fog, specular color. - */ -#define MAX_INSTRUCTIONS ((MAX_TEXTURE_COORD_UNITS * 9) + 12) - -#define DISASSEM (MESA_VERBOSE & VERBOSE_DISASSEM) - -struct mode_opt { -#ifdef __GNUC__ - __extension__ GLubyte Source:4; /**< SRC_x */ - __extension__ GLubyte Operand:3; /**< OPR_x */ -#else - GLubyte Source; /**< SRC_x */ - GLubyte Operand; /**< OPR_x */ -#endif -}; - -struct state_key { - GLuint nr_enabled_units:8; - GLuint enabled_units:8; - GLuint separate_specular:1; - GLuint fog_enabled:1; - GLuint fog_mode:2; /**< FOG_x */ - GLuint inputs_available:12; - GLuint num_draw_buffers:4; - - /* NOTE: This array of structs must be last! (see "keySize" below) */ - struct { - GLuint enabled:1; - GLuint source_index:3; /**< TEXTURE_x_INDEX */ - GLuint shadow:1; - GLuint ScaleShiftRGB:2; - GLuint ScaleShiftA:2; - - GLuint NumArgsRGB:3; /**< up to MAX_COMBINER_TERMS */ - GLuint ModeRGB:5; /**< MODE_x */ - - GLuint NumArgsA:3; /**< up to MAX_COMBINER_TERMS */ - GLuint ModeA:5; /**< MODE_x */ - - GLuint texture_cyl_wrap:1; /**< For gallium test/debug only */ - - struct mode_opt OptRGB[MAX_COMBINER_TERMS]; - struct mode_opt OptA[MAX_COMBINER_TERMS]; - } unit[MAX_TEXTURE_UNITS]; -}; - -#define FOG_LINEAR 0 -#define FOG_EXP 1 -#define FOG_EXP2 2 -#define FOG_UNKNOWN 3 - -static GLuint translate_fog_mode( GLenum mode ) -{ - switch (mode) { - case GL_LINEAR: return FOG_LINEAR; - case GL_EXP: return FOG_EXP; - case GL_EXP2: return FOG_EXP2; - default: return FOG_UNKNOWN; - } -} - -#define OPR_SRC_COLOR 0 -#define OPR_ONE_MINUS_SRC_COLOR 1 -#define OPR_SRC_ALPHA 2 -#define OPR_ONE_MINUS_SRC_ALPHA 3 -#define OPR_ZERO 4 -#define OPR_ONE 5 -#define OPR_UNKNOWN 7 - -static GLuint translate_operand( GLenum operand ) -{ - switch (operand) { - case GL_SRC_COLOR: return OPR_SRC_COLOR; - case GL_ONE_MINUS_SRC_COLOR: return OPR_ONE_MINUS_SRC_COLOR; - case GL_SRC_ALPHA: return OPR_SRC_ALPHA; - case GL_ONE_MINUS_SRC_ALPHA: return OPR_ONE_MINUS_SRC_ALPHA; - case GL_ZERO: return OPR_ZERO; - case GL_ONE: return OPR_ONE; - default: - assert(0); - return OPR_UNKNOWN; - } -} - -#define SRC_TEXTURE 0 -#define SRC_TEXTURE0 1 -#define SRC_TEXTURE1 2 -#define SRC_TEXTURE2 3 -#define SRC_TEXTURE3 4 -#define SRC_TEXTURE4 5 -#define SRC_TEXTURE5 6 -#define SRC_TEXTURE6 7 -#define SRC_TEXTURE7 8 -#define SRC_CONSTANT 9 -#define SRC_PRIMARY_COLOR 10 -#define SRC_PREVIOUS 11 -#define SRC_ZERO 12 -#define SRC_UNKNOWN 15 - -static GLuint translate_source( GLenum src ) -{ - switch (src) { - case GL_TEXTURE: return SRC_TEXTURE; - case GL_TEXTURE0: - case GL_TEXTURE1: - case GL_TEXTURE2: - case GL_TEXTURE3: - case GL_TEXTURE4: - case GL_TEXTURE5: - case GL_TEXTURE6: - case GL_TEXTURE7: return SRC_TEXTURE0 + (src - GL_TEXTURE0); - case GL_CONSTANT: return SRC_CONSTANT; - case GL_PRIMARY_COLOR: return SRC_PRIMARY_COLOR; - case GL_PREVIOUS: return SRC_PREVIOUS; - case GL_ZERO: - return SRC_ZERO; - default: - assert(0); - return SRC_UNKNOWN; - } -} - -#define MODE_REPLACE 0 /* r = a0 */ -#define MODE_MODULATE 1 /* r = a0 * a1 */ -#define MODE_ADD 2 /* r = a0 + a1 */ -#define MODE_ADD_SIGNED 3 /* r = a0 + a1 - 0.5 */ -#define MODE_INTERPOLATE 4 /* r = a0 * a2 + a1 * (1 - a2) */ -#define MODE_SUBTRACT 5 /* r = a0 - a1 */ -#define MODE_DOT3_RGB 6 /* r = a0 . a1 */ -#define MODE_DOT3_RGB_EXT 7 /* r = a0 . a1 */ -#define MODE_DOT3_RGBA 8 /* r = a0 . a1 */ -#define MODE_DOT3_RGBA_EXT 9 /* r = a0 . a1 */ -#define MODE_MODULATE_ADD_ATI 10 /* r = a0 * a2 + a1 */ -#define MODE_MODULATE_SIGNED_ADD_ATI 11 /* r = a0 * a2 + a1 - 0.5 */ -#define MODE_MODULATE_SUBTRACT_ATI 12 /* r = a0 * a2 - a1 */ -#define MODE_ADD_PRODUCTS 13 /* r = a0 * a1 + a2 * a3 */ -#define MODE_ADD_PRODUCTS_SIGNED 14 /* r = a0 * a1 + a2 * a3 - 0.5 */ -#define MODE_BUMP_ENVMAP_ATI 15 /* special */ -#define MODE_UNKNOWN 16 - -/** - * Translate GL combiner state into a MODE_x value - */ -static GLuint translate_mode( GLenum envMode, GLenum mode ) -{ - switch (mode) { - case GL_REPLACE: return MODE_REPLACE; - case GL_MODULATE: return MODE_MODULATE; - case GL_ADD: - if (envMode == GL_COMBINE4_NV) - return MODE_ADD_PRODUCTS; - else - return MODE_ADD; - case GL_ADD_SIGNED: - if (envMode == GL_COMBINE4_NV) - return MODE_ADD_PRODUCTS_SIGNED; - else - return MODE_ADD_SIGNED; - case GL_INTERPOLATE: return MODE_INTERPOLATE; - case GL_SUBTRACT: return MODE_SUBTRACT; - case GL_DOT3_RGB: return MODE_DOT3_RGB; - case GL_DOT3_RGB_EXT: return MODE_DOT3_RGB_EXT; - case GL_DOT3_RGBA: return MODE_DOT3_RGBA; - case GL_DOT3_RGBA_EXT: return MODE_DOT3_RGBA_EXT; - case GL_MODULATE_ADD_ATI: return MODE_MODULATE_ADD_ATI; - case GL_MODULATE_SIGNED_ADD_ATI: return MODE_MODULATE_SIGNED_ADD_ATI; - case GL_MODULATE_SUBTRACT_ATI: return MODE_MODULATE_SUBTRACT_ATI; - case GL_BUMP_ENVMAP_ATI: return MODE_BUMP_ENVMAP_ATI; - default: - assert(0); - return MODE_UNKNOWN; - } -} - - -/** - * Do we need to clamp the results of the given texture env/combine mode? - * If the inputs to the mode are in [0,1] we don't always have to clamp - * the results. - */ -static GLboolean -need_saturate( GLuint mode ) -{ - switch (mode) { - case MODE_REPLACE: - case MODE_MODULATE: - case MODE_INTERPOLATE: - return GL_FALSE; - case MODE_ADD: - case MODE_ADD_SIGNED: - case MODE_SUBTRACT: - case MODE_DOT3_RGB: - case MODE_DOT3_RGB_EXT: - case MODE_DOT3_RGBA: - case MODE_DOT3_RGBA_EXT: - case MODE_MODULATE_ADD_ATI: - case MODE_MODULATE_SIGNED_ADD_ATI: - case MODE_MODULATE_SUBTRACT_ATI: - case MODE_ADD_PRODUCTS: - case MODE_ADD_PRODUCTS_SIGNED: - case MODE_BUMP_ENVMAP_ATI: - return GL_TRUE; - default: - assert(0); - return GL_FALSE; - } -} - - - -/** - * Translate TEXTURE_x_BIT to TEXTURE_x_INDEX. - */ -static GLuint translate_tex_src_bit( GLbitfield bit ) -{ - ASSERT(bit); - return _mesa_ffs(bit) - 1; -} - - -#define VERT_BIT_TEX_ANY (0xff << VERT_ATTRIB_TEX0) -#define VERT_RESULT_TEX_ANY (0xff << VERT_RESULT_TEX0) - -/** - * Identify all possible varying inputs. The fragment program will - * never reference non-varying inputs, but will track them via state - * constants instead. - * - * This function figures out all the inputs that the fragment program - * has access to. The bitmask is later reduced to just those which - * are actually referenced. - */ -static GLbitfield get_fp_input_mask( struct gl_context *ctx ) -{ - /* _NEW_PROGRAM */ - const GLboolean vertexShader = - (ctx->Shader.CurrentVertexProgram && - ctx->Shader.CurrentVertexProgram->LinkStatus && - ctx->Shader.CurrentVertexProgram->VertexProgram); - const GLboolean vertexProgram = ctx->VertexProgram._Enabled; - GLbitfield fp_inputs = 0x0; - - if (ctx->VertexProgram._Overriden) { - /* Somebody's messing with the vertex program and we don't have - * a clue what's happening. Assume that it could be producing - * all possible outputs. - */ - fp_inputs = ~0; - } - else if (ctx->RenderMode == GL_FEEDBACK) { - /* _NEW_RENDERMODE */ - fp_inputs = (FRAG_BIT_COL0 | FRAG_BIT_TEX0); - } - else if (!(vertexProgram || vertexShader)) { - /* Fixed function vertex logic */ - /* _NEW_ARRAY */ - GLbitfield varying_inputs = ctx->varying_vp_inputs; - - /* These get generated in the setup routine regardless of the - * vertex program: - */ - /* _NEW_POINT */ - if (ctx->Point.PointSprite) - varying_inputs |= FRAG_BITS_TEX_ANY; - - /* First look at what values may be computed by the generated - * vertex program: - */ - /* _NEW_LIGHT */ - if (ctx->Light.Enabled) { - fp_inputs |= FRAG_BIT_COL0; - - if (texenv_doing_secondary_color(ctx)) - fp_inputs |= FRAG_BIT_COL1; - } - - /* _NEW_TEXTURE */ - fp_inputs |= (ctx->Texture._TexGenEnabled | - ctx->Texture._TexMatEnabled) << FRAG_ATTRIB_TEX0; - - /* Then look at what might be varying as a result of enabled - * arrays, etc: - */ - if (varying_inputs & VERT_BIT_COLOR0) - fp_inputs |= FRAG_BIT_COL0; - if (varying_inputs & VERT_BIT_COLOR1) - fp_inputs |= FRAG_BIT_COL1; - - fp_inputs |= (((varying_inputs & VERT_BIT_TEX_ANY) >> VERT_ATTRIB_TEX0) - << FRAG_ATTRIB_TEX0); - - } - else { - /* calculate from vp->outputs */ - struct gl_vertex_program *vprog; - GLbitfield64 vp_outputs; - - /* Choose GLSL vertex shader over ARB vertex program. Need this - * since vertex shader state validation comes after fragment state - * validation (see additional comments in state.c). - */ - if (vertexShader) - vprog = ctx->Shader.CurrentVertexProgram->VertexProgram; - else - vprog = ctx->VertexProgram.Current; - - vp_outputs = vprog->Base.OutputsWritten; - - /* These get generated in the setup routine regardless of the - * vertex program: - */ - /* _NEW_POINT */ - if (ctx->Point.PointSprite) - vp_outputs |= FRAG_BITS_TEX_ANY; - - if (vp_outputs & (1 << VERT_RESULT_COL0)) - fp_inputs |= FRAG_BIT_COL0; - if (vp_outputs & (1 << VERT_RESULT_COL1)) - fp_inputs |= FRAG_BIT_COL1; - - fp_inputs |= (((vp_outputs & VERT_RESULT_TEX_ANY) >> VERT_RESULT_TEX0) - << FRAG_ATTRIB_TEX0); - } - - return fp_inputs; -} - - -/** - * Examine current texture environment state and generate a unique - * key to identify it. - */ -static GLuint make_state_key( struct gl_context *ctx, struct state_key *key ) -{ - GLuint i, j; - GLbitfield inputs_referenced = FRAG_BIT_COL0; - const GLbitfield inputs_available = get_fp_input_mask( ctx ); - GLuint keySize; - - memset(key, 0, sizeof(*key)); - - /* _NEW_TEXTURE */ - for (i = 0; i < ctx->Const.MaxTextureUnits; i++) { - const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[i]; - const struct gl_texture_object *texObj = texUnit->_Current; - const struct gl_tex_env_combine_state *comb = texUnit->_CurrentCombine; - GLenum format; - - if (!texUnit->_ReallyEnabled || !texUnit->Enabled) - continue; - - format = texObj->Image[0][texObj->BaseLevel]->_BaseFormat; - - key->unit[i].enabled = 1; - key->enabled_units |= (1<nr_enabled_units = i + 1; - inputs_referenced |= FRAG_BIT_TEX(i); - - key->unit[i].source_index = - translate_tex_src_bit(texUnit->_ReallyEnabled); - - key->unit[i].shadow = - ((texObj->Sampler.CompareMode == GL_COMPARE_R_TO_TEXTURE) && - ((format == GL_DEPTH_COMPONENT) || - (format == GL_DEPTH_STENCIL_EXT))); - - key->unit[i].NumArgsRGB = comb->_NumArgsRGB; - key->unit[i].NumArgsA = comb->_NumArgsA; - - key->unit[i].ModeRGB = - translate_mode(texUnit->EnvMode, comb->ModeRGB); - key->unit[i].ModeA = - translate_mode(texUnit->EnvMode, comb->ModeA); - - key->unit[i].ScaleShiftRGB = comb->ScaleShiftRGB; - key->unit[i].ScaleShiftA = comb->ScaleShiftA; - - for (j = 0; j < MAX_COMBINER_TERMS; j++) { - key->unit[i].OptRGB[j].Operand = translate_operand(comb->OperandRGB[j]); - key->unit[i].OptA[j].Operand = translate_operand(comb->OperandA[j]); - key->unit[i].OptRGB[j].Source = translate_source(comb->SourceRGB[j]); - key->unit[i].OptA[j].Source = translate_source(comb->SourceA[j]); - } - - if (key->unit[i].ModeRGB == MODE_BUMP_ENVMAP_ATI) { - /* requires some special translation */ - key->unit[i].NumArgsRGB = 2; - key->unit[i].ScaleShiftRGB = 0; - key->unit[i].OptRGB[0].Operand = OPR_SRC_COLOR; - key->unit[i].OptRGB[0].Source = SRC_TEXTURE; - key->unit[i].OptRGB[1].Operand = OPR_SRC_COLOR; - key->unit[i].OptRGB[1].Source = texUnit->BumpTarget - GL_TEXTURE0 + SRC_TEXTURE0; - } - - /* this is a back-door for enabling cylindrical texture wrap mode */ - if (texObj->Priority == 0.125) - key->unit[i].texture_cyl_wrap = 1; - } - - /* _NEW_LIGHT | _NEW_FOG */ - if (texenv_doing_secondary_color(ctx)) { - key->separate_specular = 1; - inputs_referenced |= FRAG_BIT_COL1; - } - - /* _NEW_FOG */ - if (ctx->Fog.Enabled) { - key->fog_enabled = 1; - key->fog_mode = translate_fog_mode(ctx->Fog.Mode); - inputs_referenced |= FRAG_BIT_FOGC; /* maybe */ - } - - /* _NEW_BUFFERS */ - key->num_draw_buffers = ctx->DrawBuffer->_NumColorDrawBuffers; - - key->inputs_available = (inputs_available & inputs_referenced); - - /* compute size of state key, ignoring unused texture units */ - keySize = sizeof(*key) - sizeof(key->unit) - + key->nr_enabled_units * sizeof(key->unit[0]); - - return keySize; -} - - -/** - * Use uregs to represent registers internally, translate to Mesa's - * expected formats on emit. - * - * NOTE: These are passed by value extensively in this file rather - * than as usual by pointer reference. If this disturbs you, try - * remembering they are just 32bits in size. - * - * GCC is smart enough to deal with these dword-sized structures in - * much the same way as if I had defined them as dwords and was using - * macros to access and set the fields. This is much nicer and easier - * to evolve. - */ -struct ureg { - GLuint file:4; - GLuint idx:8; - GLuint negatebase:1; - GLuint swz:12; - GLuint pad:7; -}; - -static const struct ureg undef = { - PROGRAM_UNDEFINED, - 255, - 0, - 0, - 0 -}; - - -/** State used to build the fragment program: - */ -struct texenv_fragment_program { - struct gl_fragment_program *program; - struct state_key *state; - - GLbitfield alu_temps; /**< Track texture indirections, see spec. */ - GLbitfield temps_output; /**< Track texture indirections, see spec. */ - GLbitfield temp_in_use; /**< Tracks temporary regs which are in use. */ - GLboolean error; - - struct ureg src_texture[MAX_TEXTURE_COORD_UNITS]; - /* Reg containing each texture unit's sampled texture color, - * else undef. - */ - - struct ureg texcoord_tex[MAX_TEXTURE_COORD_UNITS]; - /* Reg containing texcoord for a texture unit, - * needed for bump mapping, else undef. - */ - - struct ureg src_previous; /**< Reg containing color from previous - * stage. May need to be decl'd. - */ - - GLuint last_tex_stage; /**< Number of last enabled texture unit */ - - struct ureg half; - struct ureg one; - struct ureg zero; -}; - - - -static struct ureg make_ureg(GLuint file, GLuint idx) -{ - struct ureg reg; - reg.file = file; - reg.idx = idx; - reg.negatebase = 0; - reg.swz = SWIZZLE_NOOP; - reg.pad = 0; - return reg; -} - -static struct ureg swizzle( struct ureg reg, int x, int y, int z, int w ) -{ - reg.swz = MAKE_SWIZZLE4(GET_SWZ(reg.swz, x), - GET_SWZ(reg.swz, y), - GET_SWZ(reg.swz, z), - GET_SWZ(reg.swz, w)); - - return reg; -} - -static struct ureg swizzle1( struct ureg reg, int x ) -{ - return swizzle(reg, x, x, x, x); -} - -static struct ureg negate( struct ureg reg ) -{ - reg.negatebase ^= 1; - return reg; -} - -static GLboolean is_undef( struct ureg reg ) -{ - return reg.file == PROGRAM_UNDEFINED; -} - - -static struct ureg get_temp( struct texenv_fragment_program *p ) -{ - GLint bit; - - /* First try and reuse temps which have been used already: - */ - bit = _mesa_ffs( ~p->temp_in_use & p->alu_temps ); - - /* Then any unused temporary: - */ - if (!bit) - bit = _mesa_ffs( ~p->temp_in_use ); - - if (!bit) { - _mesa_problem(NULL, "%s: out of temporaries\n", __FILE__); - exit(1); - } - - if ((GLuint) bit > p->program->Base.NumTemporaries) - p->program->Base.NumTemporaries = bit; - - p->temp_in_use |= 1<<(bit-1); - return make_ureg(PROGRAM_TEMPORARY, (bit-1)); -} - -static struct ureg get_tex_temp( struct texenv_fragment_program *p ) -{ - int bit; - - /* First try to find available temp not previously used (to avoid - * starting a new texture indirection). According to the spec, the - * ~p->temps_output isn't necessary, but will keep it there for - * now: - */ - bit = _mesa_ffs( ~p->temp_in_use & ~p->alu_temps & ~p->temps_output ); - - /* Then any unused temporary: - */ - if (!bit) - bit = _mesa_ffs( ~p->temp_in_use ); - - if (!bit) { - _mesa_problem(NULL, "%s: out of temporaries\n", __FILE__); - exit(1); - } - - if ((GLuint) bit > p->program->Base.NumTemporaries) - p->program->Base.NumTemporaries = bit; - - p->temp_in_use |= 1<<(bit-1); - return make_ureg(PROGRAM_TEMPORARY, (bit-1)); -} - - -/** Mark a temp reg as being no longer allocatable. */ -static void reserve_temp( struct texenv_fragment_program *p, struct ureg r ) -{ - if (r.file == PROGRAM_TEMPORARY) - p->temps_output |= (1 << r.idx); -} - - -static void release_temps(struct gl_context *ctx, struct texenv_fragment_program *p ) -{ - GLuint max_temp = ctx->Const.FragmentProgram.MaxTemps; - - /* KW: To support tex_env_crossbar, don't release the registers in - * temps_output. - */ - if (max_temp >= sizeof(int) * 8) - p->temp_in_use = p->temps_output; - else - p->temp_in_use = ~((1<temps_output; -} - - -static struct ureg register_param5( struct texenv_fragment_program *p, - GLint s0, - GLint s1, - GLint s2, - GLint s3, - GLint s4) -{ - int tokens[STATE_LENGTH]; - GLuint idx; - tokens[0] = s0; - tokens[1] = s1; - tokens[2] = s2; - tokens[3] = s3; - tokens[4] = s4; - idx = _mesa_add_state_reference(p->program->Base.Parameters, - (gl_state_index *)tokens); - return make_ureg(PROGRAM_STATE_VAR, idx); -} - - -#define register_param1(p,s0) register_param5(p,s0,0,0,0,0) -#define register_param2(p,s0,s1) register_param5(p,s0,s1,0,0,0) -#define register_param3(p,s0,s1,s2) register_param5(p,s0,s1,s2,0,0) -#define register_param4(p,s0,s1,s2,s3) register_param5(p,s0,s1,s2,s3,0) - -static GLuint frag_to_vert_attrib( GLuint attrib ) -{ - switch (attrib) { - case FRAG_ATTRIB_COL0: return VERT_ATTRIB_COLOR0; - case FRAG_ATTRIB_COL1: return VERT_ATTRIB_COLOR1; - default: - assert(attrib >= FRAG_ATTRIB_TEX0); - assert(attrib <= FRAG_ATTRIB_TEX7); - return attrib - FRAG_ATTRIB_TEX0 + VERT_ATTRIB_TEX0; - } -} - - -static struct ureg register_input( struct texenv_fragment_program *p, GLuint input ) -{ - if (p->state->inputs_available & (1<program->Base.InputsRead |= (1 << input); - return make_ureg(PROGRAM_INPUT, input); - } - else { - GLuint idx = frag_to_vert_attrib( input ); - return register_param3( p, STATE_INTERNAL, STATE_CURRENT_ATTRIB_MAYBE_VP_CLAMPED, idx ); - } -} - - -static void emit_arg( struct prog_src_register *reg, - struct ureg ureg ) -{ - reg->File = ureg.file; - reg->Index = ureg.idx; - reg->Swizzle = ureg.swz; - reg->Negate = ureg.negatebase ? NEGATE_XYZW : NEGATE_NONE; - reg->Abs = GL_FALSE; -} - -static void emit_dst( struct prog_dst_register *dst, - struct ureg ureg, GLuint mask ) -{ - dst->File = ureg.file; - dst->Index = ureg.idx; - dst->WriteMask = mask; - dst->CondMask = COND_TR; /* always pass cond test */ - dst->CondSwizzle = SWIZZLE_NOOP; -} - -static struct prog_instruction * -emit_op(struct texenv_fragment_program *p, - enum prog_opcode op, - struct ureg dest, - GLuint mask, - GLboolean saturate, - struct ureg src0, - struct ureg src1, - struct ureg src2 ) -{ - const GLuint nr = p->program->Base.NumInstructions++; - struct prog_instruction *inst = &p->program->Base.Instructions[nr]; - - assert(nr < MAX_INSTRUCTIONS); - - _mesa_init_instructions(inst, 1); - inst->Opcode = op; - - emit_arg( &inst->SrcReg[0], src0 ); - emit_arg( &inst->SrcReg[1], src1 ); - emit_arg( &inst->SrcReg[2], src2 ); - - inst->SaturateMode = saturate ? SATURATE_ZERO_ONE : SATURATE_OFF; - - emit_dst( &inst->DstReg, dest, mask ); - -#if 0 - /* Accounting for indirection tracking: - */ - if (dest.file == PROGRAM_TEMPORARY) - p->temps_output |= 1 << dest.idx; -#endif - - return inst; -} - - -static struct ureg emit_arith( struct texenv_fragment_program *p, - enum prog_opcode op, - struct ureg dest, - GLuint mask, - GLboolean saturate, - struct ureg src0, - struct ureg src1, - struct ureg src2 ) -{ - emit_op(p, op, dest, mask, saturate, src0, src1, src2); - - /* Accounting for indirection tracking: - */ - if (src0.file == PROGRAM_TEMPORARY) - p->alu_temps |= 1 << src0.idx; - - if (!is_undef(src1) && src1.file == PROGRAM_TEMPORARY) - p->alu_temps |= 1 << src1.idx; - - if (!is_undef(src2) && src2.file == PROGRAM_TEMPORARY) - p->alu_temps |= 1 << src2.idx; - - if (dest.file == PROGRAM_TEMPORARY) - p->alu_temps |= 1 << dest.idx; - - p->program->Base.NumAluInstructions++; - return dest; -} - -static struct ureg emit_texld( struct texenv_fragment_program *p, - enum prog_opcode op, - struct ureg dest, - GLuint destmask, - GLuint tex_unit, - GLuint tex_idx, - GLuint tex_shadow, - struct ureg coord ) -{ - struct prog_instruction *inst = emit_op( p, op, - dest, destmask, - GL_FALSE, /* don't saturate? */ - coord, /* arg 0? */ - undef, - undef); - - inst->TexSrcTarget = tex_idx; - inst->TexSrcUnit = tex_unit; - inst->TexShadow = tex_shadow; - - p->program->Base.NumTexInstructions++; - - /* Accounting for indirection tracking: - */ - reserve_temp(p, dest); - -#if 0 - /* Is this a texture indirection? - */ - if ((coord.file == PROGRAM_TEMPORARY && - (p->temps_output & (1<alu_temps & (1<program->Base.NumTexIndirections++; - p->temps_output = 1<alu_temps = 0; - assert(0); /* KW: texture env crossbar */ - } -#endif - - return dest; -} - - -static struct ureg register_const4f( struct texenv_fragment_program *p, - GLfloat s0, - GLfloat s1, - GLfloat s2, - GLfloat s3) -{ - GLfloat values[4]; - GLuint idx, swizzle; - struct ureg r; - values[0] = s0; - values[1] = s1; - values[2] = s2; - values[3] = s3; - idx = _mesa_add_unnamed_constant( p->program->Base.Parameters, - (gl_constant_value *) values, 4, - &swizzle ); - r = make_ureg(PROGRAM_CONSTANT, idx); - r.swz = swizzle; - return r; -} - -#define register_scalar_const(p, s0) register_const4f(p, s0, s0, s0, s0) -#define register_const1f(p, s0) register_const4f(p, s0, 0, 0, 1) -#define register_const2f(p, s0, s1) register_const4f(p, s0, s1, 0, 1) -#define register_const3f(p, s0, s1, s2) register_const4f(p, s0, s1, s2, 1) - - -static struct ureg get_one( struct texenv_fragment_program *p ) -{ - if (is_undef(p->one)) - p->one = register_scalar_const(p, 1.0); - return p->one; -} - -static struct ureg get_half( struct texenv_fragment_program *p ) -{ - if (is_undef(p->half)) - p->half = register_scalar_const(p, 0.5); - return p->half; -} - -static struct ureg get_zero( struct texenv_fragment_program *p ) -{ - if (is_undef(p->zero)) - p->zero = register_scalar_const(p, 0.0); - return p->zero; -} - - -static void program_error( struct texenv_fragment_program *p, const char *msg ) -{ - _mesa_problem(NULL, "%s", msg); - p->error = 1; -} - -static struct ureg get_source( struct texenv_fragment_program *p, - GLuint src, GLuint unit ) -{ - switch (src) { - case SRC_TEXTURE: - assert(!is_undef(p->src_texture[unit])); - return p->src_texture[unit]; - - case SRC_TEXTURE0: - case SRC_TEXTURE1: - case SRC_TEXTURE2: - case SRC_TEXTURE3: - case SRC_TEXTURE4: - case SRC_TEXTURE5: - case SRC_TEXTURE6: - case SRC_TEXTURE7: - assert(!is_undef(p->src_texture[src - SRC_TEXTURE0])); - return p->src_texture[src - SRC_TEXTURE0]; - - case SRC_CONSTANT: - return register_param2(p, STATE_TEXENV_COLOR, unit); - - case SRC_PRIMARY_COLOR: - return register_input(p, FRAG_ATTRIB_COL0); - - case SRC_ZERO: - return get_zero(p); - - case SRC_PREVIOUS: - if (is_undef(p->src_previous)) - return register_input(p, FRAG_ATTRIB_COL0); - else - return p->src_previous; - - default: - assert(0); - return undef; - } -} - -static struct ureg emit_combine_source( struct texenv_fragment_program *p, - GLuint mask, - GLuint unit, - GLuint source, - GLuint operand ) -{ - struct ureg arg, src, one; - - src = get_source(p, source, unit); - - switch (operand) { - case OPR_ONE_MINUS_SRC_COLOR: - /* Get unused tmp, - * Emit tmp = 1.0 - arg.xyzw - */ - arg = get_temp( p ); - one = get_one( p ); - return emit_arith( p, OPCODE_SUB, arg, mask, 0, one, src, undef); - - case OPR_SRC_ALPHA: - if (mask == WRITEMASK_W) - return src; - else - return swizzle1( src, SWIZZLE_W ); - case OPR_ONE_MINUS_SRC_ALPHA: - /* Get unused tmp, - * Emit tmp = 1.0 - arg.wwww - */ - arg = get_temp(p); - one = get_one(p); - return emit_arith(p, OPCODE_SUB, arg, mask, 0, - one, swizzle1(src, SWIZZLE_W), undef); - case OPR_ZERO: - return get_zero(p); - case OPR_ONE: - return get_one(p); - case OPR_SRC_COLOR: - return src; - default: - assert(0); - return src; - } -} - -/** - * Check if the RGB and Alpha sources and operands match for the given - * texture unit's combinder state. When the RGB and A sources and - * operands match, we can emit fewer instructions. - */ -static GLboolean args_match( const struct state_key *key, GLuint unit ) -{ - GLuint i, numArgs = key->unit[unit].NumArgsRGB; - - for (i = 0; i < numArgs; i++) { - if (key->unit[unit].OptA[i].Source != key->unit[unit].OptRGB[i].Source) - return GL_FALSE; - - switch (key->unit[unit].OptA[i].Operand) { - case OPR_SRC_ALPHA: - switch (key->unit[unit].OptRGB[i].Operand) { - case OPR_SRC_COLOR: - case OPR_SRC_ALPHA: - break; - default: - return GL_FALSE; - } - break; - case OPR_ONE_MINUS_SRC_ALPHA: - switch (key->unit[unit].OptRGB[i].Operand) { - case OPR_ONE_MINUS_SRC_COLOR: - case OPR_ONE_MINUS_SRC_ALPHA: - break; - default: - return GL_FALSE; - } - break; - default: - return GL_FALSE; /* impossible */ - } - } - - return GL_TRUE; -} - -static struct ureg emit_combine( struct texenv_fragment_program *p, - struct ureg dest, - GLuint mask, - GLboolean saturate, - GLuint unit, - GLuint nr, - GLuint mode, - const struct mode_opt *opt) -{ - struct ureg src[MAX_COMBINER_TERMS]; - struct ureg tmp, half; - GLuint i; - - assert(nr <= MAX_COMBINER_TERMS); - - for (i = 0; i < nr; i++) - src[i] = emit_combine_source( p, mask, unit, opt[i].Source, opt[i].Operand ); - - switch (mode) { - case MODE_REPLACE: - if (mask == WRITEMASK_XYZW && !saturate) - return src[0]; - else - return emit_arith( p, OPCODE_MOV, dest, mask, saturate, src[0], undef, undef ); - case MODE_MODULATE: - return emit_arith( p, OPCODE_MUL, dest, mask, saturate, - src[0], src[1], undef ); - case MODE_ADD: - return emit_arith( p, OPCODE_ADD, dest, mask, saturate, - src[0], src[1], undef ); - case MODE_ADD_SIGNED: - /* tmp = arg0 + arg1 - * result = tmp - .5 - */ - half = get_half(p); - tmp = get_temp( p ); - emit_arith( p, OPCODE_ADD, tmp, mask, 0, src[0], src[1], undef ); - emit_arith( p, OPCODE_SUB, dest, mask, saturate, tmp, half, undef ); - return dest; - case MODE_INTERPOLATE: - /* Arg0 * (Arg2) + Arg1 * (1-Arg2) -- note arguments are reordered: - */ - return emit_arith( p, OPCODE_LRP, dest, mask, saturate, src[2], src[0], src[1] ); - - case MODE_SUBTRACT: - return emit_arith( p, OPCODE_SUB, dest, mask, saturate, src[0], src[1], undef ); - - case MODE_DOT3_RGBA: - case MODE_DOT3_RGBA_EXT: - case MODE_DOT3_RGB_EXT: - case MODE_DOT3_RGB: { - struct ureg tmp0 = get_temp( p ); - struct ureg tmp1 = get_temp( p ); - struct ureg neg1 = register_scalar_const(p, -1); - struct ureg two = register_scalar_const(p, 2); - - /* tmp0 = 2*src0 - 1 - * tmp1 = 2*src1 - 1 - * - * dst = tmp0 dot3 tmp1 - */ - emit_arith( p, OPCODE_MAD, tmp0, WRITEMASK_XYZW, 0, - two, src[0], neg1); - - if (memcmp(&src[0], &src[1], sizeof(struct ureg)) == 0) - tmp1 = tmp0; - else - emit_arith( p, OPCODE_MAD, tmp1, WRITEMASK_XYZW, 0, - two, src[1], neg1); - emit_arith( p, OPCODE_DP3, dest, mask, saturate, tmp0, tmp1, undef); - return dest; - } - case MODE_MODULATE_ADD_ATI: - /* Arg0 * Arg2 + Arg1 */ - return emit_arith( p, OPCODE_MAD, dest, mask, saturate, - src[0], src[2], src[1] ); - case MODE_MODULATE_SIGNED_ADD_ATI: { - /* Arg0 * Arg2 + Arg1 - 0.5 */ - struct ureg tmp0 = get_temp(p); - half = get_half(p); - emit_arith( p, OPCODE_MAD, tmp0, mask, 0, src[0], src[2], src[1] ); - emit_arith( p, OPCODE_SUB, dest, mask, saturate, tmp0, half, undef ); - return dest; - } - case MODE_MODULATE_SUBTRACT_ATI: - /* Arg0 * Arg2 - Arg1 */ - emit_arith( p, OPCODE_MAD, dest, mask, 0, src[0], src[2], negate(src[1]) ); - return dest; - case MODE_ADD_PRODUCTS: - /* Arg0 * Arg1 + Arg2 * Arg3 */ - { - struct ureg tmp0 = get_temp(p); - emit_arith( p, OPCODE_MUL, tmp0, mask, 0, src[0], src[1], undef ); - emit_arith( p, OPCODE_MAD, dest, mask, saturate, src[2], src[3], tmp0 ); - } - return dest; - case MODE_ADD_PRODUCTS_SIGNED: - /* Arg0 * Arg1 + Arg2 * Arg3 - 0.5 */ - { - struct ureg tmp0 = get_temp(p); - half = get_half(p); - emit_arith( p, OPCODE_MUL, tmp0, mask, 0, src[0], src[1], undef ); - emit_arith( p, OPCODE_MAD, tmp0, mask, 0, src[2], src[3], tmp0 ); - emit_arith( p, OPCODE_SUB, dest, mask, saturate, tmp0, half, undef ); - } - return dest; - case MODE_BUMP_ENVMAP_ATI: - /* special - not handled here */ - assert(0); - return src[0]; - default: - assert(0); - return src[0]; - } -} - - -/** - * Generate instructions for one texture unit's env/combiner mode. - */ -static struct ureg -emit_texenv(struct texenv_fragment_program *p, GLuint unit) -{ - const struct state_key *key = p->state; - GLboolean rgb_saturate, alpha_saturate; - GLuint rgb_shift, alpha_shift; - struct ureg out, dest; - - if (!key->unit[unit].enabled) { - return get_source(p, SRC_PREVIOUS, 0); - } - if (key->unit[unit].ModeRGB == MODE_BUMP_ENVMAP_ATI) { - /* this isn't really a env stage delivering a color and handled elsewhere */ - return get_source(p, SRC_PREVIOUS, 0); - } - - switch (key->unit[unit].ModeRGB) { - case MODE_DOT3_RGB_EXT: - alpha_shift = key->unit[unit].ScaleShiftA; - rgb_shift = 0; - break; - case MODE_DOT3_RGBA_EXT: - alpha_shift = 0; - rgb_shift = 0; - break; - default: - rgb_shift = key->unit[unit].ScaleShiftRGB; - alpha_shift = key->unit[unit].ScaleShiftA; - break; - } - - /* If we'll do rgb/alpha shifting don't saturate in emit_combine(). - * We don't want to clamp twice. - */ - if (rgb_shift) - rgb_saturate = GL_FALSE; /* saturate after rgb shift */ - else if (need_saturate(key->unit[unit].ModeRGB)) - rgb_saturate = GL_TRUE; - else - rgb_saturate = GL_FALSE; - - if (alpha_shift) - alpha_saturate = GL_FALSE; /* saturate after alpha shift */ - else if (need_saturate(key->unit[unit].ModeA)) - alpha_saturate = GL_TRUE; - else - alpha_saturate = GL_FALSE; - - /* If this is the very last calculation (and various other conditions - * are met), emit directly to the color output register. Otherwise, - * emit to a temporary register. - */ - if (key->separate_specular || - unit != p->last_tex_stage || - alpha_shift || - key->num_draw_buffers != 1 || - rgb_shift) - dest = get_temp( p ); - else - dest = make_ureg(PROGRAM_OUTPUT, FRAG_RESULT_COLOR); - - /* Emit the RGB and A combine ops - */ - if (key->unit[unit].ModeRGB == key->unit[unit].ModeA && - args_match(key, unit)) { - out = emit_combine( p, dest, WRITEMASK_XYZW, rgb_saturate, - unit, - key->unit[unit].NumArgsRGB, - key->unit[unit].ModeRGB, - key->unit[unit].OptRGB); - } - else if (key->unit[unit].ModeRGB == MODE_DOT3_RGBA_EXT || - key->unit[unit].ModeRGB == MODE_DOT3_RGBA) { - out = emit_combine( p, dest, WRITEMASK_XYZW, rgb_saturate, - unit, - key->unit[unit].NumArgsRGB, - key->unit[unit].ModeRGB, - key->unit[unit].OptRGB); - } - else { - /* Need to do something to stop from re-emitting identical - * argument calculations here: - */ - out = emit_combine( p, dest, WRITEMASK_XYZ, rgb_saturate, - unit, - key->unit[unit].NumArgsRGB, - key->unit[unit].ModeRGB, - key->unit[unit].OptRGB); - out = emit_combine( p, dest, WRITEMASK_W, alpha_saturate, - unit, - key->unit[unit].NumArgsA, - key->unit[unit].ModeA, - key->unit[unit].OptA); - } - - /* Deal with the final shift: - */ - if (alpha_shift || rgb_shift) { - struct ureg shift; - GLboolean saturate = GL_TRUE; /* always saturate at this point */ - - if (rgb_shift == alpha_shift) { - shift = register_scalar_const(p, (GLfloat)(1<src_texture[unit])) { - const GLuint texTarget = p->state->unit[unit].source_index; - struct ureg texcoord; - struct ureg tmp = get_tex_temp( p ); - - if (is_undef(p->texcoord_tex[unit])) { - texcoord = register_input(p, FRAG_ATTRIB_TEX0+unit); - } - else { - /* might want to reuse this reg for tex output actually */ - texcoord = p->texcoord_tex[unit]; - } - - /* TODO: Use D0_MASK_XY where possible. - */ - if (p->state->unit[unit].enabled) { - GLboolean shadow = GL_FALSE; - - if (p->state->unit[unit].shadow) { - p->program->Base.ShadowSamplers |= 1 << unit; - shadow = GL_TRUE; - } - - p->src_texture[unit] = emit_texld( p, OPCODE_TXP, - tmp, WRITEMASK_XYZW, - unit, texTarget, shadow, - texcoord ); - - p->program->Base.SamplersUsed |= (1 << unit); - /* This identity mapping should already be in place - * (see _mesa_init_program_struct()) but let's be safe. - */ - p->program->Base.SamplerUnits[unit] = unit; - } - else - p->src_texture[unit] = get_zero(p); - - if (p->state->unit[unit].texture_cyl_wrap) { - /* set flag which is checked by Mesa->Gallium program translation */ - p->program->Base.InputFlags[0] |= PROG_PARAM_BIT_CYL_WRAP; - } - - } -} - -static GLboolean load_texenv_source( struct texenv_fragment_program *p, - GLuint src, GLuint unit ) -{ - switch (src) { - case SRC_TEXTURE: - load_texture(p, unit); - break; - - case SRC_TEXTURE0: - case SRC_TEXTURE1: - case SRC_TEXTURE2: - case SRC_TEXTURE3: - case SRC_TEXTURE4: - case SRC_TEXTURE5: - case SRC_TEXTURE6: - case SRC_TEXTURE7: - load_texture(p, src - SRC_TEXTURE0); - break; - - default: - /* not a texture src - do nothing */ - break; - } - - return GL_TRUE; -} - - -/** - * Generate instructions for loading all texture source terms. - */ -static GLboolean -load_texunit_sources( struct texenv_fragment_program *p, GLuint unit ) -{ - const struct state_key *key = p->state; - GLuint i; - - for (i = 0; i < key->unit[unit].NumArgsRGB; i++) { - load_texenv_source( p, key->unit[unit].OptRGB[i].Source, unit ); - } - - for (i = 0; i < key->unit[unit].NumArgsA; i++) { - load_texenv_source( p, key->unit[unit].OptA[i].Source, unit ); - } - - return GL_TRUE; -} - -/** - * Generate instructions for loading bump map textures. - */ -static GLboolean -load_texunit_bumpmap( struct texenv_fragment_program *p, GLuint unit ) -{ - const struct state_key *key = p->state; - GLuint bumpedUnitNr = key->unit[unit].OptRGB[1].Source - SRC_TEXTURE0; - struct ureg texcDst, bumpMapRes; - struct ureg constdudvcolor = register_const4f(p, 0.0, 0.0, 0.0, 1.0); - struct ureg texcSrc = register_input(p, FRAG_ATTRIB_TEX0 + bumpedUnitNr); - struct ureg rotMat0 = register_param3( p, STATE_INTERNAL, STATE_ROT_MATRIX_0, unit ); - struct ureg rotMat1 = register_param3( p, STATE_INTERNAL, STATE_ROT_MATRIX_1, unit ); - - load_texenv_source( p, unit + SRC_TEXTURE0, unit ); - - bumpMapRes = get_source(p, key->unit[unit].OptRGB[0].Source, unit); - texcDst = get_tex_temp( p ); - p->texcoord_tex[bumpedUnitNr] = texcDst; - - /* Apply rot matrix and add coords to be available in next phase. - * dest = (Arg0.xxxx * rotMat0 + Arg1) + (Arg0.yyyy * rotMat1) - * note only 2 coords are affected the rest are left unchanged (mul by 0) - */ - emit_arith( p, OPCODE_MAD, texcDst, WRITEMASK_XYZW, 0, - swizzle1(bumpMapRes, SWIZZLE_X), rotMat0, texcSrc ); - emit_arith( p, OPCODE_MAD, texcDst, WRITEMASK_XYZW, 0, - swizzle1(bumpMapRes, SWIZZLE_Y), rotMat1, texcDst ); - - /* Move 0,0,0,1 into bumpmap src if someone (crossbar) is foolish - * enough to access this later, should optimize away. - */ - emit_arith( p, OPCODE_MOV, bumpMapRes, WRITEMASK_XYZW, 0, - constdudvcolor, undef, undef ); - - return GL_TRUE; -} - -/** - * Generate a new fragment program which implements the context's - * current texture env/combine mode. - */ -static void -create_new_program(struct gl_context *ctx, struct state_key *key, - struct gl_fragment_program *program) -{ - struct prog_instruction instBuffer[MAX_INSTRUCTIONS]; - struct texenv_fragment_program p; - GLuint unit; - struct ureg cf, out; - int i; - - memset(&p, 0, sizeof(p)); - p.state = key; - p.program = program; - - /* During code generation, use locally-allocated instruction buffer, - * then alloc dynamic storage below. - */ - p.program->Base.Instructions = instBuffer; - p.program->Base.Target = GL_FRAGMENT_PROGRAM_ARB; - p.program->Base.String = NULL; - p.program->Base.NumTexIndirections = 1; /* is this right? */ - p.program->Base.NumTexInstructions = 0; - p.program->Base.NumAluInstructions = 0; - p.program->Base.NumInstructions = 0; - p.program->Base.NumTemporaries = 0; - p.program->Base.NumParameters = 0; - p.program->Base.NumAttributes = 0; - p.program->Base.NumAddressRegs = 0; - p.program->Base.Parameters = _mesa_new_parameter_list(); - p.program->Base.InputsRead = 0x0; - - if (key->num_draw_buffers == 1) - p.program->Base.OutputsWritten = 1 << FRAG_RESULT_COLOR; - else { - for (i = 0; i < key->num_draw_buffers; i++) - p.program->Base.OutputsWritten |= (1 << (FRAG_RESULT_DATA0 + i)); - } - - for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) { - p.src_texture[unit] = undef; - p.texcoord_tex[unit] = undef; - } - - p.src_previous = undef; - p.half = undef; - p.zero = undef; - p.one = undef; - - p.last_tex_stage = 0; - release_temps(ctx, &p); - - if (key->enabled_units && key->num_draw_buffers) { - GLboolean needbumpstage = GL_FALSE; - - /* Zeroth pass - bump map textures first */ - for (unit = 0; unit < key->nr_enabled_units; unit++) - if (key->unit[unit].enabled && - key->unit[unit].ModeRGB == MODE_BUMP_ENVMAP_ATI) { - needbumpstage = GL_TRUE; - load_texunit_bumpmap( &p, unit ); - } - if (needbumpstage) - p.program->Base.NumTexIndirections++; - - /* First pass - to support texture_env_crossbar, first identify - * all referenced texture sources and emit texld instructions - * for each: - */ - for (unit = 0; unit < key->nr_enabled_units; unit++) - if (key->unit[unit].enabled) { - load_texunit_sources( &p, unit ); - p.last_tex_stage = unit; - } - - /* Second pass - emit combine instructions to build final color: - */ - for (unit = 0; unit < key->nr_enabled_units; unit++) - if (key->unit[unit].enabled) { - p.src_previous = emit_texenv( &p, unit ); - reserve_temp(&p, p.src_previous); /* don't re-use this temp reg */ - release_temps(ctx, &p); /* release all temps */ - } - } - - cf = get_source( &p, SRC_PREVIOUS, 0 ); - - for (i = 0; i < key->num_draw_buffers; i++) { - if (key->num_draw_buffers == 1) - out = make_ureg( PROGRAM_OUTPUT, FRAG_RESULT_COLOR ); - else { - out = make_ureg( PROGRAM_OUTPUT, FRAG_RESULT_DATA0 + i ); - } - - if (key->separate_specular) { - /* Emit specular add. - */ - struct ureg s = register_input(&p, FRAG_ATTRIB_COL1); - emit_arith( &p, OPCODE_ADD, out, WRITEMASK_XYZ, 0, cf, s, undef ); - emit_arith( &p, OPCODE_MOV, out, WRITEMASK_W, 0, cf, undef, undef ); - } - else if (memcmp(&cf, &out, sizeof(cf)) != 0) { - /* Will wind up in here if no texture enabled or a couple of - * other scenarios (GL_REPLACE for instance). - */ - emit_arith( &p, OPCODE_MOV, out, WRITEMASK_XYZW, 0, cf, undef, undef ); - } - } - /* Finish up: - */ - emit_arith( &p, OPCODE_END, undef, WRITEMASK_XYZW, 0, undef, undef, undef); - - /* Allocate final instruction array. This has to be done before calling - * _mesa_append_fog_code because that function frees the Base.Instructions. - * At this point, Base.Instructions points to stack data, so it's a really - * bad idea to free it. - */ - p.program->Base.Instructions - = _mesa_alloc_instructions(p.program->Base.NumInstructions); - if (!p.program->Base.Instructions) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, - "generating tex env program"); - return; - } - _mesa_copy_instructions(p.program->Base.Instructions, instBuffer, - p.program->Base.NumInstructions); - - /* Append fog code. This must be done before checking the program against - * the limits becuase it will potentially add some instructions. - */ - if (key->fog_enabled) { - _mesa_append_fog_code(ctx, p.program, ctx->Fog.Mode, GL_FALSE); - } - - if (p.program->Base.NumTexIndirections > ctx->Const.FragmentProgram.MaxTexIndirections) - program_error(&p, "Exceeded max nr indirect texture lookups"); - - if (p.program->Base.NumTexInstructions > ctx->Const.FragmentProgram.MaxTexInstructions) - program_error(&p, "Exceeded max TEX instructions"); - - if (p.program->Base.NumAluInstructions > ctx->Const.FragmentProgram.MaxAluInstructions) - program_error(&p, "Exceeded max ALU instructions"); - - ASSERT(p.program->Base.NumInstructions <= MAX_INSTRUCTIONS); - - /* Notify driver the fragment program has (actually) changed. - */ - if (ctx->Driver.ProgramStringNotify) { - GLboolean ok = ctx->Driver.ProgramStringNotify(ctx, - GL_FRAGMENT_PROGRAM_ARB, - &p.program->Base); - /* Driver should be able to handle any texenv programs as long as - * the driver correctly reported max number of texture units correctly, - * etc. - */ - ASSERT(ok); - (void) ok; /* silence unused var warning */ - } - - if (DISASSEM) { - _mesa_print_program(&p.program->Base); - printf("\n"); - } -} - -extern "C" { - -/** - * Return a fragment program which implements the current - * fixed-function texture, fog and color-sum operations. - */ -struct gl_fragment_program * -_mesa_get_fixed_func_fragment_program(struct gl_context *ctx) -{ - struct gl_fragment_program *prog; - struct state_key key; - GLuint keySize; - - keySize = make_state_key(ctx, &key); - - prog = (struct gl_fragment_program *) - _mesa_search_program_cache(ctx->FragmentProgram.Cache, - &key, keySize); - - if (!prog) { - prog = (struct gl_fragment_program *) - ctx->Driver.NewProgram(ctx, GL_FRAGMENT_PROGRAM_ARB, 0); - - create_new_program(ctx, &key, prog); - - _mesa_program_cache_insert(ctx, ctx->FragmentProgram.Cache, - &key, keySize, &prog->Base); - } - - return prog; -} - -} +/************************************************************************** + * + * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * Copyright 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, sub license, 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 (including the + * next paragraph) 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 NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS 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. + * + **************************************************************************/ + +extern "C" { +#include "glheader.h" +#include "imports.h" +#include "mtypes.h" +#include "program/program.h" +#include "program/prog_parameter.h" +#include "program/prog_cache.h" +#include "program/prog_instruction.h" +#include "program/prog_print.h" +#include "program/prog_statevars.h" +#include "program/programopt.h" +#include "texenvprogram.h" +} + +/* + * Note on texture units: + * + * The number of texture units supported by fixed-function fragment + * processing is MAX_TEXTURE_COORD_UNITS, not MAX_TEXTURE_IMAGE_UNITS. + * That's because there's a one-to-one correspondence between texture + * coordinates and samplers in fixed-function processing. + * + * Since fixed-function vertex processing is limited to MAX_TEXTURE_COORD_UNITS + * sets of texcoords, so is fixed-function fragment processing. + * + * We can safely use ctx->Const.MaxTextureUnits for loop bounds. + */ + + +struct texenvprog_cache_item +{ + GLuint hash; + void *key; + struct gl_fragment_program *data; + struct texenvprog_cache_item *next; +}; + +static GLboolean +texenv_doing_secondary_color(struct gl_context *ctx) +{ + if (ctx->Light.Enabled && + (ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR)) + return GL_TRUE; + + if (ctx->Fog.ColorSumEnabled) + return GL_TRUE; + + return GL_FALSE; +} + +/** + * Up to nine instructions per tex unit, plus fog, specular color. + */ +#define MAX_INSTRUCTIONS ((MAX_TEXTURE_COORD_UNITS * 9) + 12) + +#define DISASSEM (MESA_VERBOSE & VERBOSE_DISASSEM) + +struct mode_opt { +#ifdef __GNUC__ + __extension__ GLubyte Source:4; /**< SRC_x */ + __extension__ GLubyte Operand:3; /**< OPR_x */ +#else + GLubyte Source; /**< SRC_x */ + GLubyte Operand; /**< OPR_x */ +#endif +}; + +struct state_key { + GLuint nr_enabled_units:8; + GLuint enabled_units:8; + GLuint separate_specular:1; + GLuint fog_enabled:1; + GLuint fog_mode:2; /**< FOG_x */ + GLuint inputs_available:12; + GLuint num_draw_buffers:4; + + /* NOTE: This array of structs must be last! (see "keySize" below) */ + struct { + GLuint enabled:1; + GLuint source_index:3; /**< TEXTURE_x_INDEX */ + GLuint shadow:1; + GLuint ScaleShiftRGB:2; + GLuint ScaleShiftA:2; + + GLuint NumArgsRGB:3; /**< up to MAX_COMBINER_TERMS */ + GLuint ModeRGB:5; /**< MODE_x */ + + GLuint NumArgsA:3; /**< up to MAX_COMBINER_TERMS */ + GLuint ModeA:5; /**< MODE_x */ + + GLuint texture_cyl_wrap:1; /**< For gallium test/debug only */ + + struct mode_opt OptRGB[MAX_COMBINER_TERMS]; + struct mode_opt OptA[MAX_COMBINER_TERMS]; + } unit[MAX_TEXTURE_UNITS]; +}; + +#define FOG_LINEAR 0 +#define FOG_EXP 1 +#define FOG_EXP2 2 +#define FOG_UNKNOWN 3 + +static GLuint translate_fog_mode( GLenum mode ) +{ + switch (mode) { + case GL_LINEAR: return FOG_LINEAR; + case GL_EXP: return FOG_EXP; + case GL_EXP2: return FOG_EXP2; + default: return FOG_UNKNOWN; + } +} + +#define OPR_SRC_COLOR 0 +#define OPR_ONE_MINUS_SRC_COLOR 1 +#define OPR_SRC_ALPHA 2 +#define OPR_ONE_MINUS_SRC_ALPHA 3 +#define OPR_ZERO 4 +#define OPR_ONE 5 +#define OPR_UNKNOWN 7 + +static GLuint translate_operand( GLenum operand ) +{ + switch (operand) { + case GL_SRC_COLOR: return OPR_SRC_COLOR; + case GL_ONE_MINUS_SRC_COLOR: return OPR_ONE_MINUS_SRC_COLOR; + case GL_SRC_ALPHA: return OPR_SRC_ALPHA; + case GL_ONE_MINUS_SRC_ALPHA: return OPR_ONE_MINUS_SRC_ALPHA; + case GL_ZERO: return OPR_ZERO; + case GL_ONE: return OPR_ONE; + default: + assert(0); + return OPR_UNKNOWN; + } +} + +#define SRC_TEXTURE 0 +#define SRC_TEXTURE0 1 +#define SRC_TEXTURE1 2 +#define SRC_TEXTURE2 3 +#define SRC_TEXTURE3 4 +#define SRC_TEXTURE4 5 +#define SRC_TEXTURE5 6 +#define SRC_TEXTURE6 7 +#define SRC_TEXTURE7 8 +#define SRC_CONSTANT 9 +#define SRC_PRIMARY_COLOR 10 +#define SRC_PREVIOUS 11 +#define SRC_ZERO 12 +#define SRC_UNKNOWN 15 + +static GLuint translate_source( GLenum src ) +{ + switch (src) { + case GL_TEXTURE: return SRC_TEXTURE; + case GL_TEXTURE0: + case GL_TEXTURE1: + case GL_TEXTURE2: + case GL_TEXTURE3: + case GL_TEXTURE4: + case GL_TEXTURE5: + case GL_TEXTURE6: + case GL_TEXTURE7: return SRC_TEXTURE0 + (src - GL_TEXTURE0); + case GL_CONSTANT: return SRC_CONSTANT; + case GL_PRIMARY_COLOR: return SRC_PRIMARY_COLOR; + case GL_PREVIOUS: return SRC_PREVIOUS; + case GL_ZERO: + return SRC_ZERO; + default: + assert(0); + return SRC_UNKNOWN; + } +} + +#define MODE_REPLACE 0 /* r = a0 */ +#define MODE_MODULATE 1 /* r = a0 * a1 */ +#define MODE_ADD 2 /* r = a0 + a1 */ +#define MODE_ADD_SIGNED 3 /* r = a0 + a1 - 0.5 */ +#define MODE_INTERPOLATE 4 /* r = a0 * a2 + a1 * (1 - a2) */ +#define MODE_SUBTRACT 5 /* r = a0 - a1 */ +#define MODE_DOT3_RGB 6 /* r = a0 . a1 */ +#define MODE_DOT3_RGB_EXT 7 /* r = a0 . a1 */ +#define MODE_DOT3_RGBA 8 /* r = a0 . a1 */ +#define MODE_DOT3_RGBA_EXT 9 /* r = a0 . a1 */ +#define MODE_MODULATE_ADD_ATI 10 /* r = a0 * a2 + a1 */ +#define MODE_MODULATE_SIGNED_ADD_ATI 11 /* r = a0 * a2 + a1 - 0.5 */ +#define MODE_MODULATE_SUBTRACT_ATI 12 /* r = a0 * a2 - a1 */ +#define MODE_ADD_PRODUCTS 13 /* r = a0 * a1 + a2 * a3 */ +#define MODE_ADD_PRODUCTS_SIGNED 14 /* r = a0 * a1 + a2 * a3 - 0.5 */ +#define MODE_BUMP_ENVMAP_ATI 15 /* special */ +#define MODE_UNKNOWN 16 + +/** + * Translate GL combiner state into a MODE_x value + */ +static GLuint translate_mode( GLenum envMode, GLenum mode ) +{ + switch (mode) { + case GL_REPLACE: return MODE_REPLACE; + case GL_MODULATE: return MODE_MODULATE; + case GL_ADD: + if (envMode == GL_COMBINE4_NV) + return MODE_ADD_PRODUCTS; + else + return MODE_ADD; + case GL_ADD_SIGNED: + if (envMode == GL_COMBINE4_NV) + return MODE_ADD_PRODUCTS_SIGNED; + else + return MODE_ADD_SIGNED; + case GL_INTERPOLATE: return MODE_INTERPOLATE; + case GL_SUBTRACT: return MODE_SUBTRACT; + case GL_DOT3_RGB: return MODE_DOT3_RGB; + case GL_DOT3_RGB_EXT: return MODE_DOT3_RGB_EXT; + case GL_DOT3_RGBA: return MODE_DOT3_RGBA; + case GL_DOT3_RGBA_EXT: return MODE_DOT3_RGBA_EXT; + case GL_MODULATE_ADD_ATI: return MODE_MODULATE_ADD_ATI; + case GL_MODULATE_SIGNED_ADD_ATI: return MODE_MODULATE_SIGNED_ADD_ATI; + case GL_MODULATE_SUBTRACT_ATI: return MODE_MODULATE_SUBTRACT_ATI; + case GL_BUMP_ENVMAP_ATI: return MODE_BUMP_ENVMAP_ATI; + default: + assert(0); + return MODE_UNKNOWN; + } +} + + +/** + * Do we need to clamp the results of the given texture env/combine mode? + * If the inputs to the mode are in [0,1] we don't always have to clamp + * the results. + */ +static GLboolean +need_saturate( GLuint mode ) +{ + switch (mode) { + case MODE_REPLACE: + case MODE_MODULATE: + case MODE_INTERPOLATE: + return GL_FALSE; + case MODE_ADD: + case MODE_ADD_SIGNED: + case MODE_SUBTRACT: + case MODE_DOT3_RGB: + case MODE_DOT3_RGB_EXT: + case MODE_DOT3_RGBA: + case MODE_DOT3_RGBA_EXT: + case MODE_MODULATE_ADD_ATI: + case MODE_MODULATE_SIGNED_ADD_ATI: + case MODE_MODULATE_SUBTRACT_ATI: + case MODE_ADD_PRODUCTS: + case MODE_ADD_PRODUCTS_SIGNED: + case MODE_BUMP_ENVMAP_ATI: + return GL_TRUE; + default: + assert(0); + return GL_FALSE; + } +} + + + +/** + * Translate TEXTURE_x_BIT to TEXTURE_x_INDEX. + */ +static GLuint translate_tex_src_bit( GLbitfield bit ) +{ + ASSERT(bit); + return _mesa_ffs(bit) - 1; +} + + +#define VERT_BIT_TEX_ANY (0xff << VERT_ATTRIB_TEX0) +#define VERT_RESULT_TEX_ANY (0xff << VERT_RESULT_TEX0) + +/** + * Identify all possible varying inputs. The fragment program will + * never reference non-varying inputs, but will track them via state + * constants instead. + * + * This function figures out all the inputs that the fragment program + * has access to. The bitmask is later reduced to just those which + * are actually referenced. + */ +static GLbitfield get_fp_input_mask( struct gl_context *ctx ) +{ + /* _NEW_PROGRAM */ + const GLboolean vertexShader = + (ctx->Shader.CurrentVertexProgram && + ctx->Shader.CurrentVertexProgram->LinkStatus && + ctx->Shader.CurrentVertexProgram->VertexProgram); + const GLboolean vertexProgram = ctx->VertexProgram._Enabled; + GLbitfield fp_inputs = 0x0; + + if (ctx->VertexProgram._Overriden) { + /* Somebody's messing with the vertex program and we don't have + * a clue what's happening. Assume that it could be producing + * all possible outputs. + */ + fp_inputs = ~0; + } + else if (ctx->RenderMode == GL_FEEDBACK) { + /* _NEW_RENDERMODE */ + fp_inputs = (FRAG_BIT_COL0 | FRAG_BIT_TEX0); + } + else if (!(vertexProgram || vertexShader)) { + /* Fixed function vertex logic */ + /* _NEW_ARRAY */ + GLbitfield varying_inputs = ctx->varying_vp_inputs; + + /* These get generated in the setup routine regardless of the + * vertex program: + */ + /* _NEW_POINT */ + if (ctx->Point.PointSprite) + varying_inputs |= FRAG_BITS_TEX_ANY; + + /* First look at what values may be computed by the generated + * vertex program: + */ + /* _NEW_LIGHT */ + if (ctx->Light.Enabled) { + fp_inputs |= FRAG_BIT_COL0; + + if (texenv_doing_secondary_color(ctx)) + fp_inputs |= FRAG_BIT_COL1; + } + + /* _NEW_TEXTURE */ + fp_inputs |= (ctx->Texture._TexGenEnabled | + ctx->Texture._TexMatEnabled) << FRAG_ATTRIB_TEX0; + + /* Then look at what might be varying as a result of enabled + * arrays, etc: + */ + if (varying_inputs & VERT_BIT_COLOR0) + fp_inputs |= FRAG_BIT_COL0; + if (varying_inputs & VERT_BIT_COLOR1) + fp_inputs |= FRAG_BIT_COL1; + + fp_inputs |= (((varying_inputs & VERT_BIT_TEX_ANY) >> VERT_ATTRIB_TEX0) + << FRAG_ATTRIB_TEX0); + + } + else { + /* calculate from vp->outputs */ + struct gl_vertex_program *vprog; + GLbitfield64 vp_outputs; + + /* Choose GLSL vertex shader over ARB vertex program. Need this + * since vertex shader state validation comes after fragment state + * validation (see additional comments in state.c). + */ + if (vertexShader) + vprog = ctx->Shader.CurrentVertexProgram->VertexProgram; + else + vprog = ctx->VertexProgram.Current; + + vp_outputs = vprog->Base.OutputsWritten; + + /* These get generated in the setup routine regardless of the + * vertex program: + */ + /* _NEW_POINT */ + if (ctx->Point.PointSprite) + vp_outputs |= FRAG_BITS_TEX_ANY; + + if (vp_outputs & (1 << VERT_RESULT_COL0)) + fp_inputs |= FRAG_BIT_COL0; + if (vp_outputs & (1 << VERT_RESULT_COL1)) + fp_inputs |= FRAG_BIT_COL1; + + fp_inputs |= (((vp_outputs & VERT_RESULT_TEX_ANY) >> VERT_RESULT_TEX0) + << FRAG_ATTRIB_TEX0); + } + + return fp_inputs; +} + + +/** + * Examine current texture environment state and generate a unique + * key to identify it. + */ +static GLuint make_state_key( struct gl_context *ctx, struct state_key *key ) +{ + GLuint i, j; + GLbitfield inputs_referenced = FRAG_BIT_COL0; + const GLbitfield inputs_available = get_fp_input_mask( ctx ); + GLuint keySize; + + memset(key, 0, sizeof(*key)); + + /* _NEW_TEXTURE */ + for (i = 0; i < ctx->Const.MaxTextureUnits; i++) { + const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[i]; + const struct gl_texture_object *texObj = texUnit->_Current; + const struct gl_tex_env_combine_state *comb = texUnit->_CurrentCombine; + GLenum format; + + if (!texUnit->_ReallyEnabled || !texUnit->Enabled) + continue; + + format = texObj->Image[0][texObj->BaseLevel]->_BaseFormat; + + key->unit[i].enabled = 1; + key->enabled_units |= (1<nr_enabled_units = i + 1; + inputs_referenced |= FRAG_BIT_TEX(i); + + key->unit[i].source_index = + translate_tex_src_bit(texUnit->_ReallyEnabled); + + key->unit[i].shadow = + ((texObj->Sampler.CompareMode == GL_COMPARE_R_TO_TEXTURE) && + ((format == GL_DEPTH_COMPONENT) || + (format == GL_DEPTH_STENCIL_EXT))); + + key->unit[i].NumArgsRGB = comb->_NumArgsRGB; + key->unit[i].NumArgsA = comb->_NumArgsA; + + key->unit[i].ModeRGB = + translate_mode(texUnit->EnvMode, comb->ModeRGB); + key->unit[i].ModeA = + translate_mode(texUnit->EnvMode, comb->ModeA); + + key->unit[i].ScaleShiftRGB = comb->ScaleShiftRGB; + key->unit[i].ScaleShiftA = comb->ScaleShiftA; + + for (j = 0; j < MAX_COMBINER_TERMS; j++) { + key->unit[i].OptRGB[j].Operand = translate_operand(comb->OperandRGB[j]); + key->unit[i].OptA[j].Operand = translate_operand(comb->OperandA[j]); + key->unit[i].OptRGB[j].Source = translate_source(comb->SourceRGB[j]); + key->unit[i].OptA[j].Source = translate_source(comb->SourceA[j]); + } + + if (key->unit[i].ModeRGB == MODE_BUMP_ENVMAP_ATI) { + /* requires some special translation */ + key->unit[i].NumArgsRGB = 2; + key->unit[i].ScaleShiftRGB = 0; + key->unit[i].OptRGB[0].Operand = OPR_SRC_COLOR; + key->unit[i].OptRGB[0].Source = SRC_TEXTURE; + key->unit[i].OptRGB[1].Operand = OPR_SRC_COLOR; + key->unit[i].OptRGB[1].Source = texUnit->BumpTarget - GL_TEXTURE0 + SRC_TEXTURE0; + } + + /* this is a back-door for enabling cylindrical texture wrap mode */ + if (texObj->Priority == 0.125) + key->unit[i].texture_cyl_wrap = 1; + } + + /* _NEW_LIGHT | _NEW_FOG */ + if (texenv_doing_secondary_color(ctx)) { + key->separate_specular = 1; + inputs_referenced |= FRAG_BIT_COL1; + } + + /* _NEW_FOG */ + if (ctx->Fog.Enabled) { + key->fog_enabled = 1; + key->fog_mode = translate_fog_mode(ctx->Fog.Mode); + inputs_referenced |= FRAG_BIT_FOGC; /* maybe */ + } + + /* _NEW_BUFFERS */ + key->num_draw_buffers = ctx->DrawBuffer->_NumColorDrawBuffers; + + key->inputs_available = (inputs_available & inputs_referenced); + + /* compute size of state key, ignoring unused texture units */ + keySize = sizeof(*key) - sizeof(key->unit) + + key->nr_enabled_units * sizeof(key->unit[0]); + + return keySize; +} + + +/** + * Use uregs to represent registers internally, translate to Mesa's + * expected formats on emit. + * + * NOTE: These are passed by value extensively in this file rather + * than as usual by pointer reference. If this disturbs you, try + * remembering they are just 32bits in size. + * + * GCC is smart enough to deal with these dword-sized structures in + * much the same way as if I had defined them as dwords and was using + * macros to access and set the fields. This is much nicer and easier + * to evolve. + */ +struct ureg { + GLuint file:4; + GLuint idx:8; + GLuint negatebase:1; + GLuint swz:12; + GLuint pad:7; +}; + +static const struct ureg undef = { + PROGRAM_UNDEFINED, + 255, + 0, + 0, + 0 +}; + + +/** State used to build the fragment program: + */ +struct texenv_fragment_program { + struct gl_fragment_program *program; + struct state_key *state; + + GLbitfield alu_temps; /**< Track texture indirections, see spec. */ + GLbitfield temps_output; /**< Track texture indirections, see spec. */ + GLbitfield temp_in_use; /**< Tracks temporary regs which are in use. */ + GLboolean error; + + struct ureg src_texture[MAX_TEXTURE_COORD_UNITS]; + /* Reg containing each texture unit's sampled texture color, + * else undef. + */ + + struct ureg texcoord_tex[MAX_TEXTURE_COORD_UNITS]; + /* Reg containing texcoord for a texture unit, + * needed for bump mapping, else undef. + */ + + struct ureg src_previous; /**< Reg containing color from previous + * stage. May need to be decl'd. + */ + + GLuint last_tex_stage; /**< Number of last enabled texture unit */ + + struct ureg half; + struct ureg one; + struct ureg zero; +}; + + + +static struct ureg make_ureg(GLuint file, GLuint idx) +{ + struct ureg reg; + reg.file = file; + reg.idx = idx; + reg.negatebase = 0; + reg.swz = SWIZZLE_NOOP; + reg.pad = 0; + return reg; +} + +static struct ureg swizzle( struct ureg reg, int x, int y, int z, int w ) +{ + reg.swz = MAKE_SWIZZLE4(GET_SWZ(reg.swz, x), + GET_SWZ(reg.swz, y), + GET_SWZ(reg.swz, z), + GET_SWZ(reg.swz, w)); + + return reg; +} + +static struct ureg swizzle1( struct ureg reg, int x ) +{ + return swizzle(reg, x, x, x, x); +} + +static struct ureg negate( struct ureg reg ) +{ + reg.negatebase ^= 1; + return reg; +} + +static GLboolean is_undef( struct ureg reg ) +{ + return reg.file == PROGRAM_UNDEFINED; +} + + +static struct ureg get_temp( struct texenv_fragment_program *p ) +{ + GLint bit; + + /* First try and reuse temps which have been used already: + */ + bit = _mesa_ffs( ~p->temp_in_use & p->alu_temps ); + + /* Then any unused temporary: + */ + if (!bit) + bit = _mesa_ffs( ~p->temp_in_use ); + + if (!bit) { + _mesa_problem(NULL, "%s: out of temporaries\n", __FILE__); + exit(1); + } + + if ((GLuint) bit > p->program->Base.NumTemporaries) + p->program->Base.NumTemporaries = bit; + + p->temp_in_use |= 1<<(bit-1); + return make_ureg(PROGRAM_TEMPORARY, (bit-1)); +} + +static struct ureg get_tex_temp( struct texenv_fragment_program *p ) +{ + int bit; + + /* First try to find available temp not previously used (to avoid + * starting a new texture indirection). According to the spec, the + * ~p->temps_output isn't necessary, but will keep it there for + * now: + */ + bit = _mesa_ffs( ~p->temp_in_use & ~p->alu_temps & ~p->temps_output ); + + /* Then any unused temporary: + */ + if (!bit) + bit = _mesa_ffs( ~p->temp_in_use ); + + if (!bit) { + _mesa_problem(NULL, "%s: out of temporaries\n", __FILE__); + exit(1); + } + + if ((GLuint) bit > p->program->Base.NumTemporaries) + p->program->Base.NumTemporaries = bit; + + p->temp_in_use |= 1<<(bit-1); + return make_ureg(PROGRAM_TEMPORARY, (bit-1)); +} + + +/** Mark a temp reg as being no longer allocatable. */ +static void reserve_temp( struct texenv_fragment_program *p, struct ureg r ) +{ + if (r.file == PROGRAM_TEMPORARY) + p->temps_output |= (1 << r.idx); +} + + +static void release_temps(struct gl_context *ctx, struct texenv_fragment_program *p ) +{ + GLuint max_temp = ctx->Const.FragmentProgram.MaxTemps; + + /* KW: To support tex_env_crossbar, don't release the registers in + * temps_output. + */ + if (max_temp >= sizeof(int) * 8) + p->temp_in_use = p->temps_output; + else + p->temp_in_use = ~((1<temps_output; +} + + +static struct ureg register_param5( struct texenv_fragment_program *p, + GLint s0, + GLint s1, + GLint s2, + GLint s3, + GLint s4) +{ + int tokens[STATE_LENGTH]; + GLuint idx; + tokens[0] = s0; + tokens[1] = s1; + tokens[2] = s2; + tokens[3] = s3; + tokens[4] = s4; + idx = _mesa_add_state_reference(p->program->Base.Parameters, + (gl_state_index *)tokens); + return make_ureg(PROGRAM_STATE_VAR, idx); +} + + +#define register_param1(p,s0) register_param5(p,s0,0,0,0,0) +#define register_param2(p,s0,s1) register_param5(p,s0,s1,0,0,0) +#define register_param3(p,s0,s1,s2) register_param5(p,s0,s1,s2,0,0) +#define register_param4(p,s0,s1,s2,s3) register_param5(p,s0,s1,s2,s3,0) + +static GLuint frag_to_vert_attrib( GLuint attrib ) +{ + switch (attrib) { + case FRAG_ATTRIB_COL0: return VERT_ATTRIB_COLOR0; + case FRAG_ATTRIB_COL1: return VERT_ATTRIB_COLOR1; + default: + assert(attrib >= FRAG_ATTRIB_TEX0); + assert(attrib <= FRAG_ATTRIB_TEX7); + return attrib - FRAG_ATTRIB_TEX0 + VERT_ATTRIB_TEX0; + } +} + + +static struct ureg register_input( struct texenv_fragment_program *p, GLuint input ) +{ + if (p->state->inputs_available & (1<program->Base.InputsRead |= (1 << input); + return make_ureg(PROGRAM_INPUT, input); + } + else { + GLuint idx = frag_to_vert_attrib( input ); + return register_param3( p, STATE_INTERNAL, STATE_CURRENT_ATTRIB_MAYBE_VP_CLAMPED, idx ); + } +} + + +static void emit_arg( struct prog_src_register *reg, + struct ureg ureg ) +{ + reg->File = ureg.file; + reg->Index = ureg.idx; + reg->Swizzle = ureg.swz; + reg->Negate = ureg.negatebase ? NEGATE_XYZW : NEGATE_NONE; + reg->Abs = GL_FALSE; +} + +static void emit_dst( struct prog_dst_register *dst, + struct ureg ureg, GLuint mask ) +{ + dst->File = ureg.file; + dst->Index = ureg.idx; + dst->WriteMask = mask; + dst->CondMask = COND_TR; /* always pass cond test */ + dst->CondSwizzle = SWIZZLE_NOOP; +} + +static struct prog_instruction * +emit_op(struct texenv_fragment_program *p, + enum prog_opcode op, + struct ureg dest, + GLuint mask, + GLboolean saturate, + struct ureg src0, + struct ureg src1, + struct ureg src2 ) +{ + const GLuint nr = p->program->Base.NumInstructions++; + struct prog_instruction *inst = &p->program->Base.Instructions[nr]; + + assert(nr < MAX_INSTRUCTIONS); + + _mesa_init_instructions(inst, 1); + inst->Opcode = op; + + emit_arg( &inst->SrcReg[0], src0 ); + emit_arg( &inst->SrcReg[1], src1 ); + emit_arg( &inst->SrcReg[2], src2 ); + + inst->SaturateMode = saturate ? SATURATE_ZERO_ONE : SATURATE_OFF; + + emit_dst( &inst->DstReg, dest, mask ); + +#if 0 + /* Accounting for indirection tracking: + */ + if (dest.file == PROGRAM_TEMPORARY) + p->temps_output |= 1 << dest.idx; +#endif + + return inst; +} + + +static struct ureg emit_arith( struct texenv_fragment_program *p, + enum prog_opcode op, + struct ureg dest, + GLuint mask, + GLboolean saturate, + struct ureg src0, + struct ureg src1, + struct ureg src2 ) +{ + emit_op(p, op, dest, mask, saturate, src0, src1, src2); + + /* Accounting for indirection tracking: + */ + if (src0.file == PROGRAM_TEMPORARY) + p->alu_temps |= 1 << src0.idx; + + if (!is_undef(src1) && src1.file == PROGRAM_TEMPORARY) + p->alu_temps |= 1 << src1.idx; + + if (!is_undef(src2) && src2.file == PROGRAM_TEMPORARY) + p->alu_temps |= 1 << src2.idx; + + if (dest.file == PROGRAM_TEMPORARY) + p->alu_temps |= 1 << dest.idx; + + p->program->Base.NumAluInstructions++; + return dest; +} + +static struct ureg emit_texld( struct texenv_fragment_program *p, + enum prog_opcode op, + struct ureg dest, + GLuint destmask, + GLuint tex_unit, + GLuint tex_idx, + GLuint tex_shadow, + struct ureg coord ) +{ + struct prog_instruction *inst = emit_op( p, op, + dest, destmask, + GL_FALSE, /* don't saturate? */ + coord, /* arg 0? */ + undef, + undef); + + inst->TexSrcTarget = tex_idx; + inst->TexSrcUnit = tex_unit; + inst->TexShadow = tex_shadow; + + p->program->Base.NumTexInstructions++; + + /* Accounting for indirection tracking: + */ + reserve_temp(p, dest); + +#if 0 + /* Is this a texture indirection? + */ + if ((coord.file == PROGRAM_TEMPORARY && + (p->temps_output & (1<alu_temps & (1<program->Base.NumTexIndirections++; + p->temps_output = 1<alu_temps = 0; + assert(0); /* KW: texture env crossbar */ + } +#endif + + return dest; +} + + +static struct ureg register_const4f( struct texenv_fragment_program *p, + GLfloat s0, + GLfloat s1, + GLfloat s2, + GLfloat s3) +{ + GLfloat values[4]; + GLuint idx, swizzle; + struct ureg r; + values[0] = s0; + values[1] = s1; + values[2] = s2; + values[3] = s3; + idx = _mesa_add_unnamed_constant( p->program->Base.Parameters, + (gl_constant_value *) values, 4, + &swizzle ); + r = make_ureg(PROGRAM_CONSTANT, idx); + r.swz = swizzle; + return r; +} + +#define register_scalar_const(p, s0) register_const4f(p, s0, s0, s0, s0) +#define register_const1f(p, s0) register_const4f(p, s0, 0, 0, 1) +#define register_const2f(p, s0, s1) register_const4f(p, s0, s1, 0, 1) +#define register_const3f(p, s0, s1, s2) register_const4f(p, s0, s1, s2, 1) + + +static struct ureg get_one( struct texenv_fragment_program *p ) +{ + if (is_undef(p->one)) + p->one = register_scalar_const(p, 1.0); + return p->one; +} + +static struct ureg get_half( struct texenv_fragment_program *p ) +{ + if (is_undef(p->half)) + p->half = register_scalar_const(p, 0.5); + return p->half; +} + +static struct ureg get_zero( struct texenv_fragment_program *p ) +{ + if (is_undef(p->zero)) + p->zero = register_scalar_const(p, 0.0); + return p->zero; +} + + +static void program_error( struct texenv_fragment_program *p, const char *msg ) +{ + _mesa_problem(NULL, "%s", msg); + p->error = 1; +} + +static struct ureg get_source( struct texenv_fragment_program *p, + GLuint src, GLuint unit ) +{ + switch (src) { + case SRC_TEXTURE: + assert(!is_undef(p->src_texture[unit])); + return p->src_texture[unit]; + + case SRC_TEXTURE0: + case SRC_TEXTURE1: + case SRC_TEXTURE2: + case SRC_TEXTURE3: + case SRC_TEXTURE4: + case SRC_TEXTURE5: + case SRC_TEXTURE6: + case SRC_TEXTURE7: + assert(!is_undef(p->src_texture[src - SRC_TEXTURE0])); + return p->src_texture[src - SRC_TEXTURE0]; + + case SRC_CONSTANT: + return register_param2(p, STATE_TEXENV_COLOR, unit); + + case SRC_PRIMARY_COLOR: + return register_input(p, FRAG_ATTRIB_COL0); + + case SRC_ZERO: + return get_zero(p); + + case SRC_PREVIOUS: + if (is_undef(p->src_previous)) + return register_input(p, FRAG_ATTRIB_COL0); + else + return p->src_previous; + + default: + assert(0); + return undef; + } +} + +static struct ureg emit_combine_source( struct texenv_fragment_program *p, + GLuint mask, + GLuint unit, + GLuint source, + GLuint operand ) +{ + struct ureg arg, src, one; + + src = get_source(p, source, unit); + + switch (operand) { + case OPR_ONE_MINUS_SRC_COLOR: + /* Get unused tmp, + * Emit tmp = 1.0 - arg.xyzw + */ + arg = get_temp( p ); + one = get_one( p ); + return emit_arith( p, OPCODE_SUB, arg, mask, 0, one, src, undef); + + case OPR_SRC_ALPHA: + if (mask == WRITEMASK_W) + return src; + else + return swizzle1( src, SWIZZLE_W ); + case OPR_ONE_MINUS_SRC_ALPHA: + /* Get unused tmp, + * Emit tmp = 1.0 - arg.wwww + */ + arg = get_temp(p); + one = get_one(p); + return emit_arith(p, OPCODE_SUB, arg, mask, 0, + one, swizzle1(src, SWIZZLE_W), undef); + case OPR_ZERO: + return get_zero(p); + case OPR_ONE: + return get_one(p); + case OPR_SRC_COLOR: + return src; + default: + assert(0); + return src; + } +} + +/** + * Check if the RGB and Alpha sources and operands match for the given + * texture unit's combinder state. When the RGB and A sources and + * operands match, we can emit fewer instructions. + */ +static GLboolean args_match( const struct state_key *key, GLuint unit ) +{ + GLuint i, numArgs = key->unit[unit].NumArgsRGB; + + for (i = 0; i < numArgs; i++) { + if (key->unit[unit].OptA[i].Source != key->unit[unit].OptRGB[i].Source) + return GL_FALSE; + + switch (key->unit[unit].OptA[i].Operand) { + case OPR_SRC_ALPHA: + switch (key->unit[unit].OptRGB[i].Operand) { + case OPR_SRC_COLOR: + case OPR_SRC_ALPHA: + break; + default: + return GL_FALSE; + } + break; + case OPR_ONE_MINUS_SRC_ALPHA: + switch (key->unit[unit].OptRGB[i].Operand) { + case OPR_ONE_MINUS_SRC_COLOR: + case OPR_ONE_MINUS_SRC_ALPHA: + break; + default: + return GL_FALSE; + } + break; + default: + return GL_FALSE; /* impossible */ + } + } + + return GL_TRUE; +} + +static struct ureg emit_combine( struct texenv_fragment_program *p, + struct ureg dest, + GLuint mask, + GLboolean saturate, + GLuint unit, + GLuint nr, + GLuint mode, + const struct mode_opt *opt) +{ + struct ureg src[MAX_COMBINER_TERMS]; + struct ureg tmp, half; + GLuint i; + + assert(nr <= MAX_COMBINER_TERMS); + + for (i = 0; i < nr; i++) + src[i] = emit_combine_source( p, mask, unit, opt[i].Source, opt[i].Operand ); + + switch (mode) { + case MODE_REPLACE: + if (mask == WRITEMASK_XYZW && !saturate) + return src[0]; + else + return emit_arith( p, OPCODE_MOV, dest, mask, saturate, src[0], undef, undef ); + case MODE_MODULATE: + return emit_arith( p, OPCODE_MUL, dest, mask, saturate, + src[0], src[1], undef ); + case MODE_ADD: + return emit_arith( p, OPCODE_ADD, dest, mask, saturate, + src[0], src[1], undef ); + case MODE_ADD_SIGNED: + /* tmp = arg0 + arg1 + * result = tmp - .5 + */ + half = get_half(p); + tmp = get_temp( p ); + emit_arith( p, OPCODE_ADD, tmp, mask, 0, src[0], src[1], undef ); + emit_arith( p, OPCODE_SUB, dest, mask, saturate, tmp, half, undef ); + return dest; + case MODE_INTERPOLATE: + /* Arg0 * (Arg2) + Arg1 * (1-Arg2) -- note arguments are reordered: + */ + return emit_arith( p, OPCODE_LRP, dest, mask, saturate, src[2], src[0], src[1] ); + + case MODE_SUBTRACT: + return emit_arith( p, OPCODE_SUB, dest, mask, saturate, src[0], src[1], undef ); + + case MODE_DOT3_RGBA: + case MODE_DOT3_RGBA_EXT: + case MODE_DOT3_RGB_EXT: + case MODE_DOT3_RGB: { + struct ureg tmp0 = get_temp( p ); + struct ureg tmp1 = get_temp( p ); + struct ureg neg1 = register_scalar_const(p, -1); + struct ureg two = register_scalar_const(p, 2); + + /* tmp0 = 2*src0 - 1 + * tmp1 = 2*src1 - 1 + * + * dst = tmp0 dot3 tmp1 + */ + emit_arith( p, OPCODE_MAD, tmp0, WRITEMASK_XYZW, 0, + two, src[0], neg1); + + if (memcmp(&src[0], &src[1], sizeof(struct ureg)) == 0) + tmp1 = tmp0; + else + emit_arith( p, OPCODE_MAD, tmp1, WRITEMASK_XYZW, 0, + two, src[1], neg1); + emit_arith( p, OPCODE_DP3, dest, mask, saturate, tmp0, tmp1, undef); + return dest; + } + case MODE_MODULATE_ADD_ATI: + /* Arg0 * Arg2 + Arg1 */ + return emit_arith( p, OPCODE_MAD, dest, mask, saturate, + src[0], src[2], src[1] ); + case MODE_MODULATE_SIGNED_ADD_ATI: { + /* Arg0 * Arg2 + Arg1 - 0.5 */ + struct ureg tmp0 = get_temp(p); + half = get_half(p); + emit_arith( p, OPCODE_MAD, tmp0, mask, 0, src[0], src[2], src[1] ); + emit_arith( p, OPCODE_SUB, dest, mask, saturate, tmp0, half, undef ); + return dest; + } + case MODE_MODULATE_SUBTRACT_ATI: + /* Arg0 * Arg2 - Arg1 */ + emit_arith( p, OPCODE_MAD, dest, mask, 0, src[0], src[2], negate(src[1]) ); + return dest; + case MODE_ADD_PRODUCTS: + /* Arg0 * Arg1 + Arg2 * Arg3 */ + { + struct ureg tmp0 = get_temp(p); + emit_arith( p, OPCODE_MUL, tmp0, mask, 0, src[0], src[1], undef ); + emit_arith( p, OPCODE_MAD, dest, mask, saturate, src[2], src[3], tmp0 ); + } + return dest; + case MODE_ADD_PRODUCTS_SIGNED: + /* Arg0 * Arg1 + Arg2 * Arg3 - 0.5 */ + { + struct ureg tmp0 = get_temp(p); + half = get_half(p); + emit_arith( p, OPCODE_MUL, tmp0, mask, 0, src[0], src[1], undef ); + emit_arith( p, OPCODE_MAD, tmp0, mask, 0, src[2], src[3], tmp0 ); + emit_arith( p, OPCODE_SUB, dest, mask, saturate, tmp0, half, undef ); + } + return dest; + case MODE_BUMP_ENVMAP_ATI: + /* special - not handled here */ + assert(0); + return src[0]; + default: + assert(0); + return src[0]; + } +} + + +/** + * Generate instructions for one texture unit's env/combiner mode. + */ +static struct ureg +emit_texenv(struct texenv_fragment_program *p, GLuint unit) +{ + const struct state_key *key = p->state; + GLboolean rgb_saturate, alpha_saturate; + GLuint rgb_shift, alpha_shift; + struct ureg out, dest; + + if (!key->unit[unit].enabled) { + return get_source(p, SRC_PREVIOUS, 0); + } + if (key->unit[unit].ModeRGB == MODE_BUMP_ENVMAP_ATI) { + /* this isn't really a env stage delivering a color and handled elsewhere */ + return get_source(p, SRC_PREVIOUS, 0); + } + + switch (key->unit[unit].ModeRGB) { + case MODE_DOT3_RGB_EXT: + alpha_shift = key->unit[unit].ScaleShiftA; + rgb_shift = 0; + break; + case MODE_DOT3_RGBA_EXT: + alpha_shift = 0; + rgb_shift = 0; + break; + default: + rgb_shift = key->unit[unit].ScaleShiftRGB; + alpha_shift = key->unit[unit].ScaleShiftA; + break; + } + + /* If we'll do rgb/alpha shifting don't saturate in emit_combine(). + * We don't want to clamp twice. + */ + if (rgb_shift) + rgb_saturate = GL_FALSE; /* saturate after rgb shift */ + else if (need_saturate(key->unit[unit].ModeRGB)) + rgb_saturate = GL_TRUE; + else + rgb_saturate = GL_FALSE; + + if (alpha_shift) + alpha_saturate = GL_FALSE; /* saturate after alpha shift */ + else if (need_saturate(key->unit[unit].ModeA)) + alpha_saturate = GL_TRUE; + else + alpha_saturate = GL_FALSE; + + /* If this is the very last calculation (and various other conditions + * are met), emit directly to the color output register. Otherwise, + * emit to a temporary register. + */ + if (key->separate_specular || + unit != p->last_tex_stage || + alpha_shift || + key->num_draw_buffers != 1 || + rgb_shift) + dest = get_temp( p ); + else + dest = make_ureg(PROGRAM_OUTPUT, FRAG_RESULT_COLOR); + + /* Emit the RGB and A combine ops + */ + if (key->unit[unit].ModeRGB == key->unit[unit].ModeA && + args_match(key, unit)) { + out = emit_combine( p, dest, WRITEMASK_XYZW, rgb_saturate, + unit, + key->unit[unit].NumArgsRGB, + key->unit[unit].ModeRGB, + key->unit[unit].OptRGB); + } + else if (key->unit[unit].ModeRGB == MODE_DOT3_RGBA_EXT || + key->unit[unit].ModeRGB == MODE_DOT3_RGBA) { + out = emit_combine( p, dest, WRITEMASK_XYZW, rgb_saturate, + unit, + key->unit[unit].NumArgsRGB, + key->unit[unit].ModeRGB, + key->unit[unit].OptRGB); + } + else { + /* Need to do something to stop from re-emitting identical + * argument calculations here: + */ + out = emit_combine( p, dest, WRITEMASK_XYZ, rgb_saturate, + unit, + key->unit[unit].NumArgsRGB, + key->unit[unit].ModeRGB, + key->unit[unit].OptRGB); + out = emit_combine( p, dest, WRITEMASK_W, alpha_saturate, + unit, + key->unit[unit].NumArgsA, + key->unit[unit].ModeA, + key->unit[unit].OptA); + } + + /* Deal with the final shift: + */ + if (alpha_shift || rgb_shift) { + struct ureg shift; + GLboolean saturate = GL_TRUE; /* always saturate at this point */ + + if (rgb_shift == alpha_shift) { + shift = register_scalar_const(p, (GLfloat)(1<src_texture[unit])) { + const GLuint texTarget = p->state->unit[unit].source_index; + struct ureg texcoord; + struct ureg tmp = get_tex_temp( p ); + + if (is_undef(p->texcoord_tex[unit])) { + texcoord = register_input(p, FRAG_ATTRIB_TEX0+unit); + } + else { + /* might want to reuse this reg for tex output actually */ + texcoord = p->texcoord_tex[unit]; + } + + /* TODO: Use D0_MASK_XY where possible. + */ + if (p->state->unit[unit].enabled) { + GLboolean shadow = GL_FALSE; + + if (p->state->unit[unit].shadow) { + p->program->Base.ShadowSamplers |= 1 << unit; + shadow = GL_TRUE; + } + + p->src_texture[unit] = emit_texld( p, OPCODE_TXP, + tmp, WRITEMASK_XYZW, + unit, texTarget, shadow, + texcoord ); + + p->program->Base.SamplersUsed |= (1 << unit); + /* This identity mapping should already be in place + * (see _mesa_init_program_struct()) but let's be safe. + */ + p->program->Base.SamplerUnits[unit] = unit; + } + else + p->src_texture[unit] = get_zero(p); + + if (p->state->unit[unit].texture_cyl_wrap) { + /* set flag which is checked by Mesa->Gallium program translation */ + p->program->Base.InputFlags[0] |= PROG_PARAM_BIT_CYL_WRAP; + } + + } +} + +static GLboolean load_texenv_source( struct texenv_fragment_program *p, + GLuint src, GLuint unit ) +{ + switch (src) { + case SRC_TEXTURE: + load_texture(p, unit); + break; + + case SRC_TEXTURE0: + case SRC_TEXTURE1: + case SRC_TEXTURE2: + case SRC_TEXTURE3: + case SRC_TEXTURE4: + case SRC_TEXTURE5: + case SRC_TEXTURE6: + case SRC_TEXTURE7: + load_texture(p, src - SRC_TEXTURE0); + break; + + default: + /* not a texture src - do nothing */ + break; + } + + return GL_TRUE; +} + + +/** + * Generate instructions for loading all texture source terms. + */ +static GLboolean +load_texunit_sources( struct texenv_fragment_program *p, GLuint unit ) +{ + const struct state_key *key = p->state; + GLuint i; + + for (i = 0; i < key->unit[unit].NumArgsRGB; i++) { + load_texenv_source( p, key->unit[unit].OptRGB[i].Source, unit ); + } + + for (i = 0; i < key->unit[unit].NumArgsA; i++) { + load_texenv_source( p, key->unit[unit].OptA[i].Source, unit ); + } + + return GL_TRUE; +} + +/** + * Generate instructions for loading bump map textures. + */ +static GLboolean +load_texunit_bumpmap( struct texenv_fragment_program *p, GLuint unit ) +{ + const struct state_key *key = p->state; + GLuint bumpedUnitNr = key->unit[unit].OptRGB[1].Source - SRC_TEXTURE0; + struct ureg texcDst, bumpMapRes; + struct ureg constdudvcolor = register_const4f(p, 0.0, 0.0, 0.0, 1.0); + struct ureg texcSrc = register_input(p, FRAG_ATTRIB_TEX0 + bumpedUnitNr); + struct ureg rotMat0 = register_param3( p, STATE_INTERNAL, STATE_ROT_MATRIX_0, unit ); + struct ureg rotMat1 = register_param3( p, STATE_INTERNAL, STATE_ROT_MATRIX_1, unit ); + + load_texenv_source( p, unit + SRC_TEXTURE0, unit ); + + bumpMapRes = get_source(p, key->unit[unit].OptRGB[0].Source, unit); + texcDst = get_tex_temp( p ); + p->texcoord_tex[bumpedUnitNr] = texcDst; + + /* Apply rot matrix and add coords to be available in next phase. + * dest = (Arg0.xxxx * rotMat0 + Arg1) + (Arg0.yyyy * rotMat1) + * note only 2 coords are affected the rest are left unchanged (mul by 0) + */ + emit_arith( p, OPCODE_MAD, texcDst, WRITEMASK_XYZW, 0, + swizzle1(bumpMapRes, SWIZZLE_X), rotMat0, texcSrc ); + emit_arith( p, OPCODE_MAD, texcDst, WRITEMASK_XYZW, 0, + swizzle1(bumpMapRes, SWIZZLE_Y), rotMat1, texcDst ); + + /* Move 0,0,0,1 into bumpmap src if someone (crossbar) is foolish + * enough to access this later, should optimize away. + */ + emit_arith( p, OPCODE_MOV, bumpMapRes, WRITEMASK_XYZW, 0, + constdudvcolor, undef, undef ); + + return GL_TRUE; +} + +/** + * Generate a new fragment program which implements the context's + * current texture env/combine mode. + */ +static void +create_new_program(struct gl_context *ctx, struct state_key *key, + struct gl_fragment_program *program) +{ + struct prog_instruction instBuffer[MAX_INSTRUCTIONS]; + struct texenv_fragment_program p; + GLuint unit; + struct ureg cf, out; + int i; + + memset(&p, 0, sizeof(p)); + p.state = key; + p.program = program; + + /* During code generation, use locally-allocated instruction buffer, + * then alloc dynamic storage below. + */ + p.program->Base.Instructions = instBuffer; + p.program->Base.Target = GL_FRAGMENT_PROGRAM_ARB; + p.program->Base.String = NULL; + p.program->Base.NumTexIndirections = 1; /* is this right? */ + p.program->Base.NumTexInstructions = 0; + p.program->Base.NumAluInstructions = 0; + p.program->Base.NumInstructions = 0; + p.program->Base.NumTemporaries = 0; + p.program->Base.NumParameters = 0; + p.program->Base.NumAttributes = 0; + p.program->Base.NumAddressRegs = 0; + p.program->Base.Parameters = _mesa_new_parameter_list(); + p.program->Base.InputsRead = 0x0; + + if (key->num_draw_buffers == 1) + p.program->Base.OutputsWritten = 1 << FRAG_RESULT_COLOR; + else { + for (i = 0; i < key->num_draw_buffers; i++) + p.program->Base.OutputsWritten |= (1 << (FRAG_RESULT_DATA0 + i)); + } + + for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) { + p.src_texture[unit] = undef; + p.texcoord_tex[unit] = undef; + } + + p.src_previous = undef; + p.half = undef; + p.zero = undef; + p.one = undef; + + p.last_tex_stage = 0; + release_temps(ctx, &p); + + if (key->enabled_units && key->num_draw_buffers) { + GLboolean needbumpstage = GL_FALSE; + + /* Zeroth pass - bump map textures first */ + for (unit = 0; unit < key->nr_enabled_units; unit++) + if (key->unit[unit].enabled && + key->unit[unit].ModeRGB == MODE_BUMP_ENVMAP_ATI) { + needbumpstage = GL_TRUE; + load_texunit_bumpmap( &p, unit ); + } + if (needbumpstage) + p.program->Base.NumTexIndirections++; + + /* First pass - to support texture_env_crossbar, first identify + * all referenced texture sources and emit texld instructions + * for each: + */ + for (unit = 0; unit < key->nr_enabled_units; unit++) + if (key->unit[unit].enabled) { + load_texunit_sources( &p, unit ); + p.last_tex_stage = unit; + } + + /* Second pass - emit combine instructions to build final color: + */ + for (unit = 0; unit < key->nr_enabled_units; unit++) + if (key->unit[unit].enabled) { + p.src_previous = emit_texenv( &p, unit ); + reserve_temp(&p, p.src_previous); /* don't re-use this temp reg */ + release_temps(ctx, &p); /* release all temps */ + } + } + + cf = get_source( &p, SRC_PREVIOUS, 0 ); + + for (i = 0; i < key->num_draw_buffers; i++) { + if (key->num_draw_buffers == 1) + out = make_ureg( PROGRAM_OUTPUT, FRAG_RESULT_COLOR ); + else { + out = make_ureg( PROGRAM_OUTPUT, FRAG_RESULT_DATA0 + i ); + } + + if (key->separate_specular) { + /* Emit specular add. + */ + struct ureg s = register_input(&p, FRAG_ATTRIB_COL1); + emit_arith( &p, OPCODE_ADD, out, WRITEMASK_XYZ, 0, cf, s, undef ); + emit_arith( &p, OPCODE_MOV, out, WRITEMASK_W, 0, cf, undef, undef ); + } + else if (memcmp(&cf, &out, sizeof(cf)) != 0) { + /* Will wind up in here if no texture enabled or a couple of + * other scenarios (GL_REPLACE for instance). + */ + emit_arith( &p, OPCODE_MOV, out, WRITEMASK_XYZW, 0, cf, undef, undef ); + } + } + /* Finish up: + */ + emit_arith( &p, OPCODE_END, undef, WRITEMASK_XYZW, 0, undef, undef, undef); + + /* Allocate final instruction array. This has to be done before calling + * _mesa_append_fog_code because that function frees the Base.Instructions. + * At this point, Base.Instructions points to stack data, so it's a really + * bad idea to free it. + */ + p.program->Base.Instructions + = _mesa_alloc_instructions(p.program->Base.NumInstructions); + if (!p.program->Base.Instructions) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, + "generating tex env program"); + return; + } + _mesa_copy_instructions(p.program->Base.Instructions, instBuffer, + p.program->Base.NumInstructions); + + /* Append fog code. This must be done before checking the program against + * the limits becuase it will potentially add some instructions. + */ + if (key->fog_enabled) { + _mesa_append_fog_code(ctx, p.program, ctx->Fog.Mode, GL_FALSE); + } + + if (p.program->Base.NumTexIndirections > ctx->Const.FragmentProgram.MaxTexIndirections) + program_error(&p, "Exceeded max nr indirect texture lookups"); + + if (p.program->Base.NumTexInstructions > ctx->Const.FragmentProgram.MaxTexInstructions) + program_error(&p, "Exceeded max TEX instructions"); + + if (p.program->Base.NumAluInstructions > ctx->Const.FragmentProgram.MaxAluInstructions) + program_error(&p, "Exceeded max ALU instructions"); + + ASSERT(p.program->Base.NumInstructions <= MAX_INSTRUCTIONS); + + /* Notify driver the fragment program has (actually) changed. + */ + if (ctx->Driver.ProgramStringNotify) { + GLboolean ok = ctx->Driver.ProgramStringNotify(ctx, + GL_FRAGMENT_PROGRAM_ARB, + &p.program->Base); + /* Driver should be able to handle any texenv programs as long as + * the driver correctly reported max number of texture units correctly, + * etc. + */ + ASSERT(ok); + (void) ok; /* silence unused var warning */ + } + + if (DISASSEM) { + _mesa_print_program(&p.program->Base); + printf("\n"); + } +} + +extern "C" { + +/** + * Return a fragment program which implements the current + * fixed-function texture, fog and color-sum operations. + */ +struct gl_fragment_program * +_mesa_get_fixed_func_fragment_program(struct gl_context *ctx) +{ + struct gl_fragment_program *prog; + struct state_key key; + GLuint keySize; + + keySize = make_state_key(ctx, &key); + + prog = (struct gl_fragment_program *) + _mesa_search_program_cache(ctx->FragmentProgram.Cache, + &key, keySize); + + if (!prog) { + prog = (struct gl_fragment_program *) + ctx->Driver.NewProgram(ctx, GL_FRAGMENT_PROGRAM_ARB, 0); + + create_new_program(ctx, &key, prog); + + _mesa_program_cache_insert(ctx, ctx->FragmentProgram.Cache, + &key, keySize, &prog->Base); + } + + return prog; +} + +} diff --git a/mesalib/src/mesa/main/fog.c b/mesalib/src/mesa/main/fog.c index cc3c9d12f..88aa31a7f 100644 --- a/mesalib/src/mesa/main/fog.c +++ b/mesalib/src/mesa/main/fog.c @@ -1,204 +1,204 @@ -/* - * Mesa 3-D graphics library - * Version: 5.1 - * - * Copyright (C) 1999-2003 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 "colormac.h" -#include "context.h" -#include "fog.h" -#include "macros.h" -#include "mtypes.h" - - - -void GLAPIENTRY -_mesa_Fogf(GLenum pname, GLfloat param) -{ - GLfloat fparam[4]; - fparam[0] = param; - fparam[1] = fparam[2] = fparam[3] = 0.0F; - _mesa_Fogfv(pname, fparam); -} - - -void GLAPIENTRY -_mesa_Fogi(GLenum pname, GLint param ) -{ - GLfloat fparam[4]; - fparam[0] = (GLfloat) param; - fparam[1] = fparam[2] = fparam[3] = 0.0F; - _mesa_Fogfv(pname, fparam); -} - - -void GLAPIENTRY -_mesa_Fogiv(GLenum pname, const GLint *params ) -{ - GLfloat p[4]; - switch (pname) { - case GL_FOG_MODE: - case GL_FOG_DENSITY: - case GL_FOG_START: - case GL_FOG_END: - case GL_FOG_INDEX: - case GL_FOG_COORDINATE_SOURCE_EXT: - p[0] = (GLfloat) *params; - break; - case GL_FOG_COLOR: - p[0] = INT_TO_FLOAT( params[0] ); - p[1] = INT_TO_FLOAT( params[1] ); - p[2] = INT_TO_FLOAT( params[2] ); - p[3] = INT_TO_FLOAT( params[3] ); - break; - default: - /* Error will be caught later in _mesa_Fogfv */ - ASSIGN_4V(p, 0.0F, 0.0F, 0.0F, 0.0F); - } - _mesa_Fogfv(pname, p); -} - - -/** - * Update the gl_fog_attrib::_Scale field. - */ -static void -update_fog_scale(struct gl_context *ctx) -{ - if (ctx->Fog.End == ctx->Fog.Start) - ctx->Fog._Scale = 1.0f; - else - ctx->Fog._Scale = 1.0f / (ctx->Fog.End - ctx->Fog.Start); -} - - -void GLAPIENTRY -_mesa_Fogfv( GLenum pname, const GLfloat *params ) -{ - GET_CURRENT_CONTEXT(ctx); - GLenum m; - ASSERT_OUTSIDE_BEGIN_END(ctx); - - switch (pname) { - case GL_FOG_MODE: - m = (GLenum) (GLint) *params; - switch (m) { - case GL_LINEAR: - case GL_EXP: - case GL_EXP2: - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glFog" ); - return; - } - if (ctx->Fog.Mode == m) - return; - FLUSH_VERTICES(ctx, _NEW_FOG); - ctx->Fog.Mode = m; - break; - case GL_FOG_DENSITY: - if (*params<0.0) { - _mesa_error( ctx, GL_INVALID_VALUE, "glFog" ); - return; - } - if (ctx->Fog.Density == *params) - return; - FLUSH_VERTICES(ctx, _NEW_FOG); - ctx->Fog.Density = *params; - break; - case GL_FOG_START: - if (ctx->Fog.Start == *params) - return; - FLUSH_VERTICES(ctx, _NEW_FOG); - ctx->Fog.Start = *params; - update_fog_scale(ctx); - break; - case GL_FOG_END: - if (ctx->Fog.End == *params) - return; - FLUSH_VERTICES(ctx, _NEW_FOG); - ctx->Fog.End = *params; - update_fog_scale(ctx); - break; - case GL_FOG_INDEX: - if (ctx->Fog.Index == *params) - return; - FLUSH_VERTICES(ctx, _NEW_FOG); - ctx->Fog.Index = *params; - break; - case GL_FOG_COLOR: - if (TEST_EQ_4V(ctx->Fog.Color, params)) - return; - FLUSH_VERTICES(ctx, _NEW_FOG); - ctx->Fog.ColorUnclamped[0] = params[0]; - ctx->Fog.ColorUnclamped[1] = params[1]; - ctx->Fog.ColorUnclamped[2] = params[2]; - ctx->Fog.ColorUnclamped[3] = params[3]; - ctx->Fog.Color[0] = CLAMP(params[0], 0.0F, 1.0F); - ctx->Fog.Color[1] = CLAMP(params[1], 0.0F, 1.0F); - ctx->Fog.Color[2] = CLAMP(params[2], 0.0F, 1.0F); - ctx->Fog.Color[3] = CLAMP(params[3], 0.0F, 1.0F); - break; - case GL_FOG_COORDINATE_SOURCE_EXT: { - GLenum p = (GLenum) (GLint) *params; - if (!ctx->Extensions.EXT_fog_coord || - (p != GL_FOG_COORDINATE_EXT && p != GL_FRAGMENT_DEPTH_EXT)) { - _mesa_error(ctx, GL_INVALID_ENUM, "glFog"); - return; - } - if (ctx->Fog.FogCoordinateSource == p) - return; - FLUSH_VERTICES(ctx, _NEW_FOG); - ctx->Fog.FogCoordinateSource = p; - break; - } - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glFog" ); - return; - } - - if (ctx->Driver.Fogfv) { - (*ctx->Driver.Fogfv)( ctx, pname, params ); - } -} - - -/**********************************************************************/ -/***** Initialization *****/ -/**********************************************************************/ - -void _mesa_init_fog( struct gl_context * ctx ) -{ - /* Fog group */ - ctx->Fog.Enabled = GL_FALSE; - ctx->Fog.Mode = GL_EXP; - ASSIGN_4V( ctx->Fog.Color, 0.0, 0.0, 0.0, 0.0 ); - ASSIGN_4V( ctx->Fog.ColorUnclamped, 0.0, 0.0, 0.0, 0.0 ); - ctx->Fog.Index = 0.0; - ctx->Fog.Density = 1.0; - ctx->Fog.Start = 0.0; - ctx->Fog.End = 1.0; - ctx->Fog.ColorSumEnabled = GL_FALSE; - ctx->Fog.FogCoordinateSource = GL_FRAGMENT_DEPTH_EXT; - ctx->Fog._Scale = 1.0f; -} +/* + * Mesa 3-D graphics library + * Version: 5.1 + * + * Copyright (C) 1999-2003 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 "colormac.h" +#include "context.h" +#include "fog.h" +#include "macros.h" +#include "mtypes.h" + + + +void GLAPIENTRY +_mesa_Fogf(GLenum pname, GLfloat param) +{ + GLfloat fparam[4]; + fparam[0] = param; + fparam[1] = fparam[2] = fparam[3] = 0.0F; + _mesa_Fogfv(pname, fparam); +} + + +void GLAPIENTRY +_mesa_Fogi(GLenum pname, GLint param ) +{ + GLfloat fparam[4]; + fparam[0] = (GLfloat) param; + fparam[1] = fparam[2] = fparam[3] = 0.0F; + _mesa_Fogfv(pname, fparam); +} + + +void GLAPIENTRY +_mesa_Fogiv(GLenum pname, const GLint *params ) +{ + GLfloat p[4]; + switch (pname) { + case GL_FOG_MODE: + case GL_FOG_DENSITY: + case GL_FOG_START: + case GL_FOG_END: + case GL_FOG_INDEX: + case GL_FOG_COORDINATE_SOURCE_EXT: + p[0] = (GLfloat) *params; + break; + case GL_FOG_COLOR: + p[0] = INT_TO_FLOAT( params[0] ); + p[1] = INT_TO_FLOAT( params[1] ); + p[2] = INT_TO_FLOAT( params[2] ); + p[3] = INT_TO_FLOAT( params[3] ); + break; + default: + /* Error will be caught later in _mesa_Fogfv */ + ASSIGN_4V(p, 0.0F, 0.0F, 0.0F, 0.0F); + } + _mesa_Fogfv(pname, p); +} + + +/** + * Update the gl_fog_attrib::_Scale field. + */ +static void +update_fog_scale(struct gl_context *ctx) +{ + if (ctx->Fog.End == ctx->Fog.Start) + ctx->Fog._Scale = 1.0f; + else + ctx->Fog._Scale = 1.0f / (ctx->Fog.End - ctx->Fog.Start); +} + + +void GLAPIENTRY +_mesa_Fogfv( GLenum pname, const GLfloat *params ) +{ + GET_CURRENT_CONTEXT(ctx); + GLenum m; + ASSERT_OUTSIDE_BEGIN_END(ctx); + + switch (pname) { + case GL_FOG_MODE: + m = (GLenum) (GLint) *params; + switch (m) { + case GL_LINEAR: + case GL_EXP: + case GL_EXP2: + break; + default: + _mesa_error( ctx, GL_INVALID_ENUM, "glFog" ); + return; + } + if (ctx->Fog.Mode == m) + return; + FLUSH_VERTICES(ctx, _NEW_FOG); + ctx->Fog.Mode = m; + break; + case GL_FOG_DENSITY: + if (*params<0.0) { + _mesa_error( ctx, GL_INVALID_VALUE, "glFog" ); + return; + } + if (ctx->Fog.Density == *params) + return; + FLUSH_VERTICES(ctx, _NEW_FOG); + ctx->Fog.Density = *params; + break; + case GL_FOG_START: + if (ctx->Fog.Start == *params) + return; + FLUSH_VERTICES(ctx, _NEW_FOG); + ctx->Fog.Start = *params; + update_fog_scale(ctx); + break; + case GL_FOG_END: + if (ctx->Fog.End == *params) + return; + FLUSH_VERTICES(ctx, _NEW_FOG); + ctx->Fog.End = *params; + update_fog_scale(ctx); + break; + case GL_FOG_INDEX: + if (ctx->Fog.Index == *params) + return; + FLUSH_VERTICES(ctx, _NEW_FOG); + ctx->Fog.Index = *params; + break; + case GL_FOG_COLOR: + if (TEST_EQ_4V(ctx->Fog.Color, params)) + return; + FLUSH_VERTICES(ctx, _NEW_FOG); + ctx->Fog.ColorUnclamped[0] = params[0]; + ctx->Fog.ColorUnclamped[1] = params[1]; + ctx->Fog.ColorUnclamped[2] = params[2]; + ctx->Fog.ColorUnclamped[3] = params[3]; + ctx->Fog.Color[0] = CLAMP(params[0], 0.0F, 1.0F); + ctx->Fog.Color[1] = CLAMP(params[1], 0.0F, 1.0F); + ctx->Fog.Color[2] = CLAMP(params[2], 0.0F, 1.0F); + ctx->Fog.Color[3] = CLAMP(params[3], 0.0F, 1.0F); + break; + case GL_FOG_COORDINATE_SOURCE_EXT: { + GLenum p = (GLenum) (GLint) *params; + if (!ctx->Extensions.EXT_fog_coord || + (p != GL_FOG_COORDINATE_EXT && p != GL_FRAGMENT_DEPTH_EXT)) { + _mesa_error(ctx, GL_INVALID_ENUM, "glFog"); + return; + } + if (ctx->Fog.FogCoordinateSource == p) + return; + FLUSH_VERTICES(ctx, _NEW_FOG); + ctx->Fog.FogCoordinateSource = p; + break; + } + default: + _mesa_error( ctx, GL_INVALID_ENUM, "glFog" ); + return; + } + + if (ctx->Driver.Fogfv) { + (*ctx->Driver.Fogfv)( ctx, pname, params ); + } +} + + +/**********************************************************************/ +/***** Initialization *****/ +/**********************************************************************/ + +void _mesa_init_fog( struct gl_context * ctx ) +{ + /* Fog group */ + ctx->Fog.Enabled = GL_FALSE; + ctx->Fog.Mode = GL_EXP; + ASSIGN_4V( ctx->Fog.Color, 0.0, 0.0, 0.0, 0.0 ); + ASSIGN_4V( ctx->Fog.ColorUnclamped, 0.0, 0.0, 0.0, 0.0 ); + ctx->Fog.Index = 0.0; + ctx->Fog.Density = 1.0; + ctx->Fog.Start = 0.0; + ctx->Fog.End = 1.0; + ctx->Fog.ColorSumEnabled = GL_FALSE; + ctx->Fog.FogCoordinateSource = GL_FRAGMENT_DEPTH_EXT; + ctx->Fog._Scale = 1.0f; +} diff --git a/mesalib/src/mesa/main/formats.c b/mesalib/src/mesa/main/formats.c index 47f876b76..11d670689 100644 --- a/mesalib/src/mesa/main/formats.c +++ b/mesalib/src/mesa/main/formats.c @@ -1,1932 +1,1932 @@ -/* - * Mesa 3-D graphics library - * Version: 7.7 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (c) 2008-2009 VMware, 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 - * 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 "formats.h" -#include "mfeatures.h" - - -/** - * Information about texture formats. - */ -struct gl_format_info -{ - gl_format Name; - - /** text name for debugging */ - const char *StrName; - - /** - * Base format is one of GL_RED, GL_RG, GL_RGB, GL_RGBA, GL_ALPHA, - * GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_INTENSITY, GL_YCBCR_MESA, - * GL_DEPTH_COMPONENT, GL_STENCIL_INDEX, GL_DEPTH_STENCIL, GL_DUDV_ATI. - */ - GLenum BaseFormat; - - /** - * Logical data type: one of GL_UNSIGNED_NORMALIZED, GL_SIGNED_NORMALIZED, - * GL_UNSIGNED_INT, GL_INT, GL_FLOAT. - */ - GLenum DataType; - - GLubyte RedBits; - GLubyte GreenBits; - GLubyte BlueBits; - GLubyte AlphaBits; - GLubyte LuminanceBits; - GLubyte IntensityBits; - GLubyte IndexBits; - GLubyte DepthBits; - GLubyte StencilBits; - - /** - * To describe compressed formats. If not compressed, Width=Height=1. - */ - GLubyte BlockWidth, BlockHeight; - GLubyte BytesPerBlock; -}; - - -/** - * Info about each format. - * These must be in the same order as the MESA_FORMAT_* enums so that - * we can do lookups without searching. - */ -static struct gl_format_info format_info[MESA_FORMAT_COUNT] = -{ - { - MESA_FORMAT_NONE, /* Name */ - "MESA_FORMAT_NONE", /* StrName */ - GL_NONE, /* BaseFormat */ - GL_NONE, /* DataType */ - 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 0, 0, 0 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_RGBA8888, /* Name */ - "MESA_FORMAT_RGBA8888", /* StrName */ - GL_RGBA, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 8, 8, 8, 8, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 4 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_RGBA8888_REV, /* Name */ - "MESA_FORMAT_RGBA8888_REV", /* StrName */ - GL_RGBA, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 8, 8, 8, 8, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 4 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_ARGB8888, /* Name */ - "MESA_FORMAT_ARGB8888", /* StrName */ - GL_RGBA, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 8, 8, 8, 8, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 4 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_ARGB8888_REV, /* Name */ - "MESA_FORMAT_ARGB8888_REV", /* StrName */ - GL_RGBA, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 8, 8, 8, 8, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 4 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_XRGB8888, /* Name */ - "MESA_FORMAT_XRGB8888", /* StrName */ - GL_RGB, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 8, 8, 8, 0, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 4 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_XRGB8888_REV, /* Name */ - "MESA_FORMAT_XRGB8888_REV", /* StrName */ - GL_RGB, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 8, 8, 8, 0, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 4 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_RGB888, /* Name */ - "MESA_FORMAT_RGB888", /* StrName */ - GL_RGB, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 8, 8, 8, 0, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 3 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_BGR888, /* Name */ - "MESA_FORMAT_BGR888", /* StrName */ - GL_RGB, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 8, 8, 8, 0, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 3 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_RGB565, /* Name */ - "MESA_FORMAT_RGB565", /* StrName */ - GL_RGB, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 5, 6, 5, 0, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 2 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_RGB565_REV, /* Name */ - "MESA_FORMAT_RGB565_REV", /* StrName */ - GL_RGB, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 5, 6, 5, 0, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 2 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_ARGB4444, /* Name */ - "MESA_FORMAT_ARGB4444", /* StrName */ - GL_RGBA, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 4, 4, 4, 4, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 2 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_ARGB4444_REV, /* Name */ - "MESA_FORMAT_ARGB4444_REV", /* StrName */ - GL_RGBA, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 4, 4, 4, 4, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 2 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_RGBA5551, /* Name */ - "MESA_FORMAT_RGBA5551", /* StrName */ - GL_RGBA, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 5, 5, 5, 1, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 2 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_ARGB1555, /* Name */ - "MESA_FORMAT_ARGB1555", /* StrName */ - GL_RGBA, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 5, 5, 5, 1, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 2 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_ARGB1555_REV, /* Name */ - "MESA_FORMAT_ARGB1555_REV", /* StrName */ - GL_RGBA, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 5, 5, 5, 1, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 2 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_AL44, /* Name */ - "MESA_FORMAT_AL44", /* StrName */ - GL_LUMINANCE_ALPHA, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 0, 0, 0, 4, /* Red/Green/Blue/AlphaBits */ - 4, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 1 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_AL88, /* Name */ - "MESA_FORMAT_AL88", /* StrName */ - GL_LUMINANCE_ALPHA, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 0, 0, 0, 8, /* Red/Green/Blue/AlphaBits */ - 8, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 2 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_AL88_REV, /* Name */ - "MESA_FORMAT_AL88_REV", /* StrName */ - GL_LUMINANCE_ALPHA, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 0, 0, 0, 8, /* Red/Green/Blue/AlphaBits */ - 8, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 2 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_AL1616, /* Name */ - "MESA_FORMAT_AL1616", /* StrName */ - GL_LUMINANCE_ALPHA, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 0, 0, 0, 16, /* Red/Green/Blue/AlphaBits */ - 16, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 4 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_AL1616_REV, /* Name */ - "MESA_FORMAT_AL1616_REV", /* StrName */ - GL_LUMINANCE_ALPHA, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 0, 0, 0, 16, /* Red/Green/Blue/AlphaBits */ - 16, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 4 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_RGB332, /* Name */ - "MESA_FORMAT_RGB332", /* StrName */ - GL_RGB, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 3, 3, 2, 0, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 1 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_A8, /* Name */ - "MESA_FORMAT_A8", /* StrName */ - GL_ALPHA, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 0, 0, 0, 8, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 1 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_A16, /* Name */ - "MESA_FORMAT_A16", /* StrName */ - GL_ALPHA, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 0, 0, 0, 16, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 2 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_L8, /* Name */ - "MESA_FORMAT_L8", /* StrName */ - GL_LUMINANCE, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ - 8, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 1 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_L16, /* Name */ - "MESA_FORMAT_L16", /* StrName */ - GL_LUMINANCE, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ - 16, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 2 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_I8, /* Name */ - "MESA_FORMAT_I8", /* StrName */ - GL_INTENSITY, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ - 0, 8, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 1 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_I16, /* Name */ - "MESA_FORMAT_I16", /* StrName */ - GL_INTENSITY, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ - 0, 16, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 2 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_YCBCR, /* Name */ - "MESA_FORMAT_YCBCR", /* StrName */ - GL_YCBCR_MESA, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 2 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_YCBCR_REV, /* Name */ - "MESA_FORMAT_YCBCR_REV", /* StrName */ - GL_YCBCR_MESA, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 2 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_R8, - "MESA_FORMAT_R8", - GL_RED, - GL_UNSIGNED_NORMALIZED, - 8, 0, 0, 0, - 0, 0, 0, 0, 0, - 1, 1, 1 - }, - { - MESA_FORMAT_RG88, - "MESA_FORMAT_RG88", - GL_RG, - GL_UNSIGNED_NORMALIZED, - 8, 8, 0, 0, - 0, 0, 0, 0, 0, - 1, 1, 2 - }, - { - MESA_FORMAT_RG88_REV, - "MESA_FORMAT_RG88_REV", - GL_RG, - GL_UNSIGNED_NORMALIZED, - 8, 8, 0, 0, - 0, 0, 0, 0, 0, - 1, 1, 2 - }, - { - MESA_FORMAT_R16, - "MESA_FORMAT_R16", - GL_RED, - GL_UNSIGNED_NORMALIZED, - 16, 0, 0, 0, - 0, 0, 0, 0, 0, - 1, 1, 2 - }, - { - MESA_FORMAT_RG1616, - "MESA_FORMAT_RG1616", - GL_RG, - GL_UNSIGNED_NORMALIZED, - 16, 16, 0, 0, - 0, 0, 0, 0, 0, - 1, 1, 4 - }, - { - MESA_FORMAT_RG1616_REV, - "MESA_FORMAT_RG1616_REV", - GL_RG, - GL_UNSIGNED_NORMALIZED, - 16, 16, 0, 0, - 0, 0, 0, 0, 0, - 1, 1, 4 - }, - { - MESA_FORMAT_ARGB2101010, - "MESA_FORMAT_ARGB2101010", - GL_RGBA, - GL_UNSIGNED_NORMALIZED, - 10, 10, 10, 2, - 0, 0, 0, 0, 0, - 1, 1, 4 - }, - { - MESA_FORMAT_Z24_S8, /* Name */ - "MESA_FORMAT_Z24_S8", /* StrName */ - GL_DEPTH_STENCIL, /* BaseFormat */ - GL_UNSIGNED_INT, /* DataType */ - 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 24, 8, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 4 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_S8_Z24, /* Name */ - "MESA_FORMAT_S8_Z24", /* StrName */ - GL_DEPTH_STENCIL, /* BaseFormat */ - GL_UNSIGNED_INT, /* DataType */ - 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 24, 8, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 4 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_Z16, /* Name */ - "MESA_FORMAT_Z16", /* StrName */ - GL_DEPTH_COMPONENT, /* BaseFormat */ - GL_UNSIGNED_INT, /* DataType */ - 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 16, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 2 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_X8_Z24, /* Name */ - "MESA_FORMAT_X8_Z24", /* StrName */ - GL_DEPTH_COMPONENT, /* BaseFormat */ - GL_UNSIGNED_INT, /* DataType */ - 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 24, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 4 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_Z24_X8, /* Name */ - "MESA_FORMAT_Z24_X8", /* StrName */ - GL_DEPTH_COMPONENT, /* BaseFormat */ - GL_UNSIGNED_INT, /* DataType */ - 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 24, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 4 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_Z32, /* Name */ - "MESA_FORMAT_Z32", /* StrName */ - GL_DEPTH_COMPONENT, /* BaseFormat */ - GL_UNSIGNED_INT, /* DataType */ - 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 32, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 4 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_S8, /* Name */ - "MESA_FORMAT_S8", /* StrName */ - GL_STENCIL_INDEX, /* BaseFormat */ - GL_UNSIGNED_INT, /* DataType */ - 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 8, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 1 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_SRGB8, - "MESA_FORMAT_SRGB8", - GL_RGB, - GL_UNSIGNED_NORMALIZED, - 8, 8, 8, 0, - 0, 0, 0, 0, 0, - 1, 1, 3 - }, - { - MESA_FORMAT_SRGBA8, - "MESA_FORMAT_SRGBA8", - GL_RGBA, - GL_UNSIGNED_NORMALIZED, - 8, 8, 8, 8, - 0, 0, 0, 0, 0, - 1, 1, 4 - }, - { - MESA_FORMAT_SARGB8, - "MESA_FORMAT_SARGB8", - GL_RGBA, - GL_UNSIGNED_NORMALIZED, - 8, 8, 8, 8, - 0, 0, 0, 0, 0, - 1, 1, 4 - }, - { - MESA_FORMAT_SL8, - "MESA_FORMAT_SL8", - GL_LUMINANCE, - GL_UNSIGNED_NORMALIZED, - 0, 0, 0, 0, - 8, 0, 0, 0, 0, - 1, 1, 1 - }, - { - MESA_FORMAT_SLA8, - "MESA_FORMAT_SLA8", - GL_LUMINANCE_ALPHA, - GL_UNSIGNED_NORMALIZED, - 0, 0, 0, 8, - 8, 0, 0, 0, 0, - 1, 1, 2 - }, - { - MESA_FORMAT_SRGB_DXT1, /* Name */ - "MESA_FORMAT_SRGB_DXT1", /* StrName */ - GL_RGB, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 4, 4, 4, 0, /* approx Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 4, 4, 8 /* 8 bytes per 4x4 block */ - }, - { - MESA_FORMAT_SRGBA_DXT1, - "MESA_FORMAT_SRGBA_DXT1", - GL_RGBA, - GL_UNSIGNED_NORMALIZED, - 4, 4, 4, 4, - 0, 0, 0, 0, 0, - 4, 4, 8 /* 8 bytes per 4x4 block */ - }, - { - MESA_FORMAT_SRGBA_DXT3, - "MESA_FORMAT_SRGBA_DXT3", - GL_RGBA, - GL_UNSIGNED_NORMALIZED, - 4, 4, 4, 4, - 0, 0, 0, 0, 0, - 4, 4, 16 /* 16 bytes per 4x4 block */ - }, - { - MESA_FORMAT_SRGBA_DXT5, - "MESA_FORMAT_SRGBA_DXT5", - GL_RGBA, - GL_UNSIGNED_NORMALIZED, - 4, 4, 4, 4, - 0, 0, 0, 0, 0, - 4, 4, 16 /* 16 bytes per 4x4 block */ - }, - - { - MESA_FORMAT_RGB_FXT1, - "MESA_FORMAT_RGB_FXT1", - GL_RGB, - GL_UNSIGNED_NORMALIZED, - 4, 4, 4, 0, /* approx Red/Green/BlueBits */ - 0, 0, 0, 0, 0, - 8, 4, 16 /* 16 bytes per 8x4 block */ - }, - { - MESA_FORMAT_RGBA_FXT1, - "MESA_FORMAT_RGBA_FXT1", - GL_RGBA, - GL_UNSIGNED_NORMALIZED, - 4, 4, 4, 1, /* approx Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, - 8, 4, 16 /* 16 bytes per 8x4 block */ - }, - - { - MESA_FORMAT_RGB_DXT1, /* Name */ - "MESA_FORMAT_RGB_DXT1", /* StrName */ - GL_RGB, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 4, 4, 4, 0, /* approx Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 4, 4, 8 /* 8 bytes per 4x4 block */ - }, - { - MESA_FORMAT_RGBA_DXT1, - "MESA_FORMAT_RGBA_DXT1", - GL_RGBA, - GL_UNSIGNED_NORMALIZED, - 4, 4, 4, 4, - 0, 0, 0, 0, 0, - 4, 4, 8 /* 8 bytes per 4x4 block */ - }, - { - MESA_FORMAT_RGBA_DXT3, - "MESA_FORMAT_RGBA_DXT3", - GL_RGBA, - GL_UNSIGNED_NORMALIZED, - 4, 4, 4, 4, - 0, 0, 0, 0, 0, - 4, 4, 16 /* 16 bytes per 4x4 block */ - }, - { - MESA_FORMAT_RGBA_DXT5, - "MESA_FORMAT_RGBA_DXT5", - GL_RGBA, - GL_UNSIGNED_NORMALIZED, - 4, 4, 4, 4, - 0, 0, 0, 0, 0, - 4, 4, 16 /* 16 bytes per 4x4 block */ - }, - { - MESA_FORMAT_RGBA_FLOAT32, - "MESA_FORMAT_RGBA_FLOAT32", - GL_RGBA, - GL_FLOAT, - 32, 32, 32, 32, - 0, 0, 0, 0, 0, - 1, 1, 16 - }, - { - MESA_FORMAT_RGBA_FLOAT16, - "MESA_FORMAT_RGBA_FLOAT16", - GL_RGBA, - GL_FLOAT, - 16, 16, 16, 16, - 0, 0, 0, 0, 0, - 1, 1, 8 - }, - { - MESA_FORMAT_RGB_FLOAT32, - "MESA_FORMAT_RGB_FLOAT32", - GL_RGB, - GL_FLOAT, - 32, 32, 32, 0, - 0, 0, 0, 0, 0, - 1, 1, 12 - }, - { - MESA_FORMAT_RGB_FLOAT16, - "MESA_FORMAT_RGB_FLOAT16", - GL_RGB, - GL_FLOAT, - 16, 16, 16, 0, - 0, 0, 0, 0, 0, - 1, 1, 6 - }, - { - MESA_FORMAT_ALPHA_FLOAT32, - "MESA_FORMAT_ALPHA_FLOAT32", - GL_ALPHA, - GL_FLOAT, - 0, 0, 0, 32, - 0, 0, 0, 0, 0, - 1, 1, 4 - }, - { - MESA_FORMAT_ALPHA_FLOAT16, - "MESA_FORMAT_ALPHA_FLOAT16", - GL_ALPHA, - GL_FLOAT, - 0, 0, 0, 16, - 0, 0, 0, 0, 0, - 1, 1, 2 - }, - { - MESA_FORMAT_LUMINANCE_FLOAT32, - "MESA_FORMAT_LUMINANCE_FLOAT32", - GL_LUMINANCE, - GL_FLOAT, - 0, 0, 0, 0, - 32, 0, 0, 0, 0, - 1, 1, 4 - }, - { - MESA_FORMAT_LUMINANCE_FLOAT16, - "MESA_FORMAT_LUMINANCE_FLOAT16", - GL_LUMINANCE, - GL_FLOAT, - 0, 0, 0, 0, - 16, 0, 0, 0, 0, - 1, 1, 2 - }, - { - MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32, - "MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32", - GL_LUMINANCE_ALPHA, - GL_FLOAT, - 0, 0, 0, 32, - 32, 0, 0, 0, 0, - 1, 1, 8 - }, - { - MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16, - "MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16", - GL_LUMINANCE_ALPHA, - GL_FLOAT, - 0, 0, 0, 16, - 16, 0, 0, 0, 0, - 1, 1, 4 - }, - { - MESA_FORMAT_INTENSITY_FLOAT32, - "MESA_FORMAT_INTENSITY_FLOAT32", - GL_INTENSITY, - GL_FLOAT, - 0, 0, 0, 0, - 0, 32, 0, 0, 0, - 1, 1, 4 - }, - { - MESA_FORMAT_INTENSITY_FLOAT16, - "MESA_FORMAT_INTENSITY_FLOAT16", - GL_INTENSITY, - GL_FLOAT, - 0, 0, 0, 0, - 0, 16, 0, 0, 0, - 1, 1, 2 - }, - { - MESA_FORMAT_R_FLOAT32, - "MESA_FORMAT_R_FLOAT32", - GL_RED, - GL_FLOAT, - 32, 0, 0, 0, - 0, 0, 0, 0, 0, - 1, 1, 4 - }, - { - MESA_FORMAT_R_FLOAT16, - "MESA_FORMAT_R_FLOAT16", - GL_RED, - GL_FLOAT, - 16, 0, 0, 0, - 0, 0, 0, 0, 0, - 1, 1, 2 - }, - { - MESA_FORMAT_RG_FLOAT32, - "MESA_FORMAT_RG_FLOAT32", - GL_RG, - GL_FLOAT, - 32, 32, 0, 0, - 0, 0, 0, 0, 0, - 1, 1, 8 - }, - { - MESA_FORMAT_RG_FLOAT16, - "MESA_FORMAT_RG_FLOAT16", - GL_RG, - GL_FLOAT, - 16, 16, 0, 0, - 0, 0, 0, 0, 0, - 1, 1, 4 - }, - - /* unnormalized signed int formats */ - { - MESA_FORMAT_RGBA_INT8, - "MESA_FORMAT_RGBA_INT8", - GL_RGBA, - GL_INT, - 8, 8, 8, 8, - 0, 0, 0, 0, 0, - 1, 1, 4 - }, - { - MESA_FORMAT_RGBA_INT16, - "MESA_FORMAT_RGBA_INT16", - GL_RGBA, - GL_INT, - 16, 16, 16, 16, - 0, 0, 0, 0, 0, - 1, 1, 8 - }, - { - MESA_FORMAT_RGBA_INT32, - "MESA_FORMAT_RGBA_INT32", - GL_RGBA, - GL_INT, - 32, 32, 32, 32, - 0, 0, 0, 0, 0, - 1, 1, 16 - }, - - /* unnormalized unsigned int formats */ - { - MESA_FORMAT_RGBA_UINT8, - "MESA_FORMAT_RGBA_UINT8", - GL_RGBA, - GL_UNSIGNED_INT, - 8, 8, 8, 8, - 0, 0, 0, 0, 0, - 1, 1, 4 - }, - { - MESA_FORMAT_RGBA_UINT16, - "MESA_FORMAT_RGBA_UINT16", - GL_RGBA, - GL_UNSIGNED_INT, - 16, 16, 16, 16, - 0, 0, 0, 0, 0, - 1, 1, 8 - }, - { - MESA_FORMAT_RGBA_UINT32, - "MESA_FORMAT_RGBA_UINT32", - GL_RGBA, - GL_UNSIGNED_INT, - 32, 32, 32, 32, - 0, 0, 0, 0, 0, - 1, 1, 16 - }, - - - { - MESA_FORMAT_DUDV8, - "MESA_FORMAT_DUDV8", - GL_DUDV_ATI, - GL_SIGNED_NORMALIZED, - 0, 0, 0, 0, - 0, 0, 0, 0, 0, - 1, 1, 2 - }, - - /* Signed 8 bits / channel */ - { - MESA_FORMAT_SIGNED_R8, /* Name */ - "MESA_FORMAT_SIGNED_R8", /* StrName */ - GL_RED, /* BaseFormat */ - GL_SIGNED_NORMALIZED, /* DataType */ - 8, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 1 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_SIGNED_RG88_REV, - "MESA_FORMAT_SIGNED_RG88_REV", - GL_RG, - GL_SIGNED_NORMALIZED, - 8, 8, 0, 0, - 0, 0, 0, 0, 0, - 1, 1, 2 - }, - { - MESA_FORMAT_SIGNED_RGBX8888, - "MESA_FORMAT_SIGNED_RGBX8888", - GL_RGB, - GL_SIGNED_NORMALIZED, - 8, 8, 8, 0, - 0, 0, 0, 0, 0, - 1, 1, 4 /* 4 bpp, but no alpha */ - }, - { - MESA_FORMAT_SIGNED_RGBA8888, - "MESA_FORMAT_SIGNED_RGBA8888", - GL_RGBA, - GL_SIGNED_NORMALIZED, - 8, 8, 8, 8, - 0, 0, 0, 0, 0, - 1, 1, 4 - }, - { - MESA_FORMAT_SIGNED_RGBA8888_REV, - "MESA_FORMAT_SIGNED_RGBA8888_REV", - GL_RGBA, - GL_SIGNED_NORMALIZED, - 8, 8, 8, 8, - 0, 0, 0, 0, 0, - 1, 1, 4 - }, - - /* Signed 16 bits / channel */ - { - MESA_FORMAT_SIGNED_R16, - "MESA_FORMAT_SIGNED_R16", - GL_RED, - GL_SIGNED_NORMALIZED, - 16, 0, 0, 0, - 0, 0, 0, 0, 0, - 1, 1, 2 - }, - { - MESA_FORMAT_SIGNED_GR1616, - "MESA_FORMAT_SIGNED_GR1616", - GL_RG, - GL_SIGNED_NORMALIZED, - 16, 16, 0, 0, - 0, 0, 0, 0, 0, - 1, 1, 4 - }, - { - MESA_FORMAT_SIGNED_RGB_16, - "MESA_FORMAT_SIGNED_RGB_16", - GL_RGB, - GL_SIGNED_NORMALIZED, - 16, 16, 16, 0, - 0, 0, 0, 0, 0, - 1, 1, 6 - }, - { - MESA_FORMAT_SIGNED_RGBA_16, - "MESA_FORMAT_SIGNED_RGBA_16", - GL_RGBA, - GL_SIGNED_NORMALIZED, - 16, 16, 16, 16, - 0, 0, 0, 0, 0, - 1, 1, 8 - }, - { - MESA_FORMAT_RGBA_16, - "MESA_FORMAT_RGBA_16", - GL_RGBA, - GL_UNSIGNED_NORMALIZED, - 16, 16, 16, 16, - 0, 0, 0, 0, 0, - 1, 1, 8 - }, - { - MESA_FORMAT_RED_RGTC1, - "MESA_FORMAT_RED_RGTC1", - GL_RED, - GL_UNSIGNED_NORMALIZED, - 4, 0, 0, 0, - 0, 0, 0, 0, 0, - 4, 4, 8 /* 8 bytes per 4x4 block */ - }, - { - MESA_FORMAT_SIGNED_RED_RGTC1, - "MESA_FORMAT_SIGNED_RED_RGTC1", - GL_RED, - GL_SIGNED_NORMALIZED, - 4, 0, 0, 0, - 0, 0, 0, 0, 0, - 4, 4, 8 /* 8 bytes per 4x4 block */ - }, - { - MESA_FORMAT_RG_RGTC2, - "MESA_FORMAT_RG_RGTC2", - GL_RG, - GL_UNSIGNED_NORMALIZED, - 4, 4, 0, 0, - 0, 0, 0, 0, 0, - 4, 4, 16 /* 16 bytes per 4x4 block */ - }, - { - MESA_FORMAT_SIGNED_RG_RGTC2, - "MESA_FORMAT_SIGNED_RG_RGTC2", - GL_RG, - GL_SIGNED_NORMALIZED, - 4, 4, 0, 0, - 0, 0, 0, 0, 0, - 4, 4, 16 /* 16 bytes per 4x4 block */ - }, - { - MESA_FORMAT_L_LATC1, - "MESA_FORMAT_L_LATC1", - GL_LUMINANCE, - GL_UNSIGNED_NORMALIZED, - 0, 0, 0, 0, - 4, 0, 0, 0, 0, - 4, 4, 8 /* 8 bytes per 4x4 block */ - }, - { - MESA_FORMAT_SIGNED_L_LATC1, - "MESA_FORMAT_SIGNED_L_LATC1", - GL_LUMINANCE, - GL_SIGNED_NORMALIZED, - 0, 0, 0, 0, - 4, 0, 0, 0, 0, - 4, 4, 8 /* 8 bytes per 4x4 block */ - }, - { - MESA_FORMAT_LA_LATC2, - "MESA_FORMAT_LA_LATC2", - GL_LUMINANCE_ALPHA, - GL_UNSIGNED_NORMALIZED, - 0, 0, 0, 4, - 4, 0, 0, 0, 0, - 4, 4, 16 /* 16 bytes per 4x4 block */ - }, - { - MESA_FORMAT_SIGNED_LA_LATC2, - "MESA_FORMAT_SIGNED_LA_LATC2", - GL_LUMINANCE_ALPHA, - GL_SIGNED_NORMALIZED, - 0, 0, 0, 4, - 4, 0, 0, 0, 0, - 4, 4, 16 /* 16 bytes per 4x4 block */ - }, - - /* Signed formats from EXT_texture_snorm that are not in GL3.1 */ - { - MESA_FORMAT_SIGNED_A8, - "MESA_FORMAT_SIGNED_A8", - GL_ALPHA, - GL_SIGNED_NORMALIZED, - 0, 0, 0, 8, - 0, 0, 0, 0, 0, - 1, 1, 1 - }, - { - MESA_FORMAT_SIGNED_L8, - "MESA_FORMAT_SIGNED_L8", - GL_LUMINANCE, - GL_SIGNED_NORMALIZED, - 0, 0, 0, 0, - 8, 0, 0, 0, 0, - 1, 1, 1 - }, - { - MESA_FORMAT_SIGNED_AL88, - "MESA_FORMAT_SIGNED_AL88", - GL_LUMINANCE_ALPHA, - GL_SIGNED_NORMALIZED, - 0, 0, 0, 8, - 8, 0, 0, 0, 0, - 1, 1, 2 - }, - { - MESA_FORMAT_SIGNED_I8, - "MESA_FORMAT_SIGNED_I8", - GL_INTENSITY, - GL_SIGNED_NORMALIZED, - 0, 0, 0, 0, - 0, 8, 0, 0, 0, - 1, 1, 1 - }, - { - MESA_FORMAT_SIGNED_A16, - "MESA_FORMAT_SIGNED_A16", - GL_ALPHA, - GL_SIGNED_NORMALIZED, - 0, 0, 0, 16, - 0, 0, 0, 0, 0, - 1, 1, 2 - }, - { - MESA_FORMAT_SIGNED_L16, - "MESA_FORMAT_SIGNED_L16", - GL_LUMINANCE, - GL_SIGNED_NORMALIZED, - 0, 0, 0, 0, - 16, 0, 0, 0, 0, - 1, 1, 2 - }, - { - MESA_FORMAT_SIGNED_AL1616, - "MESA_FORMAT_SIGNED_AL1616", - GL_LUMINANCE_ALPHA, - GL_SIGNED_NORMALIZED, - 0, 0, 0, 16, - 16, 0, 0, 0, 0, - 1, 1, 4 - }, - { - MESA_FORMAT_SIGNED_I16, - "MESA_FORMAT_SIGNED_I16", - GL_INTENSITY, - GL_SIGNED_NORMALIZED, - 0, 0, 0, 0, - 0, 16, 0, 0, 0, - 1, 1, 2 - }, - { - MESA_FORMAT_RGB9_E5_FLOAT, - "MESA_FORMAT_RGB9_E5", - GL_RGB, - GL_FLOAT, - 9, 9, 9, 0, - 0, 0, 0, 0, 0, - 1, 1, 4 - }, - { - MESA_FORMAT_R11_G11_B10_FLOAT, - "MESA_FORMAT_R11_G11_B10_FLOAT", - GL_RGB, - GL_FLOAT, - 11, 11, 10, 0, - 0, 0, 0, 0, 0, - 1, 1, 4 - }, - /* ARB_depth_buffer_float */ - { - MESA_FORMAT_Z32_FLOAT, /* Name */ - "MESA_FORMAT_Z32_FLOAT", /* StrName */ - GL_DEPTH_COMPONENT, /* BaseFormat */ - GL_FLOAT, /* DataType */ - 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 32, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 4 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_Z32_FLOAT_X24S8, /* Name */ - "MESA_FORMAT_Z32_FLOAT_X24S8", /* StrName */ - GL_DEPTH_STENCIL, /* BaseFormat */ - GL_NONE /* XXX */, /* DataType */ - 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 32, 8, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 8 /* BlockWidth/Height,Bytes */ - }, -}; - - - -static const struct gl_format_info * -_mesa_get_format_info(gl_format format) -{ - const struct gl_format_info *info = &format_info[format]; - assert(info->Name == format); - return info; -} - - -/** Return string name of format (for debugging) */ -const char * -_mesa_get_format_name(gl_format format) -{ - const struct gl_format_info *info = _mesa_get_format_info(format); - return info->StrName; -} - - - -/** - * Return bytes needed to store a block of pixels in the given format. - * Normally, a block is 1x1 (a single pixel). But for compressed formats - * a block may be 4x4 or 8x4, etc. - * - * Note: not GLuint, so as not to coerce math to unsigned. cf. fdo #37351 - */ -GLint -_mesa_get_format_bytes(gl_format format) -{ - const struct gl_format_info *info = _mesa_get_format_info(format); - ASSERT(info->BytesPerBlock); - return info->BytesPerBlock; -} - - -/** - * Return bits per component for the given format. - * \param format one of MESA_FORMAT_x - * \param pname the component, such as GL_RED_BITS, GL_TEXTURE_BLUE_BITS, etc. - */ -GLint -_mesa_get_format_bits(gl_format format, GLenum pname) -{ - const struct gl_format_info *info = _mesa_get_format_info(format); - - switch (pname) { - case GL_RED_BITS: - case GL_TEXTURE_RED_SIZE: - case GL_RENDERBUFFER_RED_SIZE_EXT: - case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE: - return info->RedBits; - case GL_GREEN_BITS: - case GL_TEXTURE_GREEN_SIZE: - case GL_RENDERBUFFER_GREEN_SIZE_EXT: - case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE: - return info->GreenBits; - case GL_BLUE_BITS: - case GL_TEXTURE_BLUE_SIZE: - case GL_RENDERBUFFER_BLUE_SIZE_EXT: - case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE: - return info->BlueBits; - case GL_ALPHA_BITS: - case GL_TEXTURE_ALPHA_SIZE: - case GL_RENDERBUFFER_ALPHA_SIZE_EXT: - case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE: - return info->AlphaBits; - case GL_TEXTURE_INTENSITY_SIZE: - return info->IntensityBits; - case GL_TEXTURE_LUMINANCE_SIZE: - return info->LuminanceBits; - case GL_INDEX_BITS: - return info->IndexBits; - case GL_DEPTH_BITS: - case GL_TEXTURE_DEPTH_SIZE_ARB: - case GL_RENDERBUFFER_DEPTH_SIZE_EXT: - case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE: - return info->DepthBits; - case GL_STENCIL_BITS: - case GL_TEXTURE_STENCIL_SIZE_EXT: - case GL_RENDERBUFFER_STENCIL_SIZE_EXT: - case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE: - return info->StencilBits; - default: - _mesa_problem(NULL, "bad pname in _mesa_get_format_bits()"); - return 0; - } -} - - -/** - * Return the data type (or more specifically, the data representation) - * for the given format. - * The return value will be one of: - * GL_UNSIGNED_NORMALIZED = unsigned int representing [0,1] - * GL_SIGNED_NORMALIZED = signed int representing [-1, 1] - * GL_UNSIGNED_INT = an ordinary unsigned integer - * GL_INT = an ordinary signed integer - * GL_FLOAT = an ordinary float - */ -GLenum -_mesa_get_format_datatype(gl_format format) -{ - const struct gl_format_info *info = _mesa_get_format_info(format); - return info->DataType; -} - - -/** - * Return the basic format for the given type. The result will be one of - * GL_RGB, GL_RGBA, GL_ALPHA, GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_INTENSITY, - * GL_YCBCR_MESA, GL_DEPTH_COMPONENT, GL_STENCIL_INDEX, GL_DEPTH_STENCIL. - */ -GLenum -_mesa_get_format_base_format(gl_format format) -{ - const struct gl_format_info *info = _mesa_get_format_info(format); - return info->BaseFormat; -} - - -/** - * Return the block size (in pixels) for the given format. Normally - * the block size is 1x1. But compressed formats will have block sizes - * of 4x4 or 8x4 pixels, etc. - * \param bw returns block width in pixels - * \param bh returns block height in pixels - */ -void -_mesa_get_format_block_size(gl_format format, GLuint *bw, GLuint *bh) -{ - const struct gl_format_info *info = _mesa_get_format_info(format); - *bw = info->BlockWidth; - *bh = info->BlockHeight; -} - - -/** Is the given format a compressed format? */ -GLboolean -_mesa_is_format_compressed(gl_format format) -{ - const struct gl_format_info *info = _mesa_get_format_info(format); - return info->BlockWidth > 1 || info->BlockHeight > 1; -} - - -/** - * Determine if the given format represents a packed depth/stencil buffer. - */ -GLboolean -_mesa_is_format_packed_depth_stencil(gl_format format) -{ - const struct gl_format_info *info = _mesa_get_format_info(format); - - return info->BaseFormat == GL_DEPTH_STENCIL; -} - - -/** - * Is the given format a signed/unsigned integer color format? - */ -GLboolean -_mesa_is_format_integer_color(gl_format format) -{ - const struct gl_format_info *info = _mesa_get_format_info(format); - return (info->DataType == GL_INT || info->DataType == GL_UNSIGNED_INT) && - info->BaseFormat != GL_DEPTH_COMPONENT && - info->BaseFormat != GL_DEPTH_STENCIL && - info->BaseFormat != GL_STENCIL_INDEX; -} - - -/** - * Return color encoding for given format. - * \return GL_LINEAR or GL_SRGB - */ -GLenum -_mesa_get_format_color_encoding(gl_format format) -{ - /* XXX this info should be encoded in gl_format_info */ - switch (format) { - case MESA_FORMAT_SRGB8: - case MESA_FORMAT_SRGBA8: - case MESA_FORMAT_SARGB8: - case MESA_FORMAT_SL8: - case MESA_FORMAT_SLA8: - case MESA_FORMAT_SRGB_DXT1: - case MESA_FORMAT_SRGBA_DXT1: - case MESA_FORMAT_SRGBA_DXT3: - case MESA_FORMAT_SRGBA_DXT5: - return GL_SRGB; - default: - return GL_LINEAR; - } -} - - -/** - * For an sRGB format, return the corresponding linear color space format. - * For non-sRGB formats, return the format as-is. - */ -gl_format -_mesa_get_srgb_format_linear(gl_format format) -{ - switch (format) { - case MESA_FORMAT_SRGB8: - format = MESA_FORMAT_RGB888; - break; - case MESA_FORMAT_SRGBA8: - format = MESA_FORMAT_RGBA8888; - break; - case MESA_FORMAT_SARGB8: - format = MESA_FORMAT_ARGB8888; - break; - case MESA_FORMAT_SL8: - format = MESA_FORMAT_L8; - break; - case MESA_FORMAT_SLA8: - format = MESA_FORMAT_AL88; - break; - case MESA_FORMAT_SRGB_DXT1: - format = MESA_FORMAT_RGB_DXT1; - break; - case MESA_FORMAT_SRGBA_DXT1: - format = MESA_FORMAT_RGBA_DXT1; - break; - case MESA_FORMAT_SRGBA_DXT3: - format = MESA_FORMAT_RGBA_DXT3; - break; - case MESA_FORMAT_SRGBA_DXT5: - format = MESA_FORMAT_RGBA_DXT5; - break; - default: - break; - } - return format; -} - - -/** - * If the given format is a compressed format, return a corresponding - * uncompressed format. - */ -gl_format -_mesa_get_uncompressed_format(gl_format format) -{ - switch (format) { - case MESA_FORMAT_RGB_FXT1: - return MESA_FORMAT_RGB888; - case MESA_FORMAT_RGBA_FXT1: - return MESA_FORMAT_RGBA8888; - case MESA_FORMAT_RGB_DXT1: - case MESA_FORMAT_SRGB_DXT1: - return MESA_FORMAT_RGB888; - case MESA_FORMAT_RGBA_DXT1: - case MESA_FORMAT_SRGBA_DXT1: - return MESA_FORMAT_RGBA8888; - case MESA_FORMAT_RGBA_DXT3: - case MESA_FORMAT_SRGBA_DXT3: - return MESA_FORMAT_RGBA8888; - case MESA_FORMAT_RGBA_DXT5: - case MESA_FORMAT_SRGBA_DXT5: - return MESA_FORMAT_RGBA8888; - case MESA_FORMAT_RED_RGTC1: - return MESA_FORMAT_R8; - case MESA_FORMAT_SIGNED_RED_RGTC1: - return MESA_FORMAT_SIGNED_R8; - case MESA_FORMAT_RG_RGTC2: - return MESA_FORMAT_RG88; - case MESA_FORMAT_SIGNED_RG_RGTC2: - return MESA_FORMAT_SIGNED_RG88_REV; - case MESA_FORMAT_L_LATC1: - return MESA_FORMAT_L8; - case MESA_FORMAT_SIGNED_L_LATC1: - return MESA_FORMAT_SIGNED_L8; - case MESA_FORMAT_LA_LATC2: - return MESA_FORMAT_AL88; - case MESA_FORMAT_SIGNED_LA_LATC2: - return MESA_FORMAT_SIGNED_AL88; - default: -#ifdef DEBUG - assert(!_mesa_is_format_compressed(format)); -#endif - return format; - } -} - - -GLuint -_mesa_format_num_components(gl_format format) -{ - const struct gl_format_info *info = _mesa_get_format_info(format); - return ((info->RedBits > 0) + - (info->GreenBits > 0) + - (info->BlueBits > 0) + - (info->AlphaBits > 0) + - (info->LuminanceBits > 0) + - (info->IntensityBits > 0) + - (info->DepthBits > 0) + - (info->StencilBits > 0)); -} - - -/** - * Return number of bytes needed to store an image of the given size - * in the given format. - */ -GLuint -_mesa_format_image_size(gl_format format, GLsizei width, - GLsizei height, GLsizei depth) -{ - const struct gl_format_info *info = _mesa_get_format_info(format); - /* Strictly speaking, a conditional isn't needed here */ - if (info->BlockWidth > 1 || info->BlockHeight > 1) { - /* compressed format (2D only for now) */ - const GLuint bw = info->BlockWidth, bh = info->BlockHeight; - const GLuint wblocks = (width + bw - 1) / bw; - const GLuint hblocks = (height + bh - 1) / bh; - const GLuint sz = wblocks * hblocks * info->BytesPerBlock; - assert(depth == 1); - return sz; - } - else { - /* non-compressed */ - const GLuint sz = width * height * depth * info->BytesPerBlock; - return sz; - } -} - - -/** - * Same as _mesa_format_image_size() but returns a 64-bit value to - * accomodate very large textures. - */ -uint64_t -_mesa_format_image_size64(gl_format format, GLsizei width, - GLsizei height, GLsizei depth) -{ - const struct gl_format_info *info = _mesa_get_format_info(format); - /* Strictly speaking, a conditional isn't needed here */ - if (info->BlockWidth > 1 || info->BlockHeight > 1) { - /* compressed format (2D only for now) */ - const uint64_t bw = info->BlockWidth, bh = info->BlockHeight; - const uint64_t wblocks = (width + bw - 1) / bw; - const uint64_t hblocks = (height + bh - 1) / bh; - const uint64_t sz = wblocks * hblocks * info->BytesPerBlock; - assert(depth == 1); - return sz; - } - else { - /* non-compressed */ - const uint64_t sz = ((uint64_t) width * - (uint64_t) height * - (uint64_t) depth * - info->BytesPerBlock); - return sz; - } -} - - - -GLint -_mesa_format_row_stride(gl_format format, GLsizei width) -{ - const struct gl_format_info *info = _mesa_get_format_info(format); - /* Strictly speaking, a conditional isn't needed here */ - if (info->BlockWidth > 1 || info->BlockHeight > 1) { - /* compressed format */ - const GLuint bw = info->BlockWidth; - const GLuint wblocks = (width + bw - 1) / bw; - const GLint stride = wblocks * info->BytesPerBlock; - return stride; - } - else { - const GLint stride = width * info->BytesPerBlock; - return stride; - } -} - - -/** - * Debug/test: check that all formats are handled in the - * _mesa_format_to_type_and_comps() function. When new pixel formats - * are added to Mesa, that function needs to be updated. - * This is a no-op after the first call. - */ -static void -check_format_to_type_and_comps(void) -{ - gl_format f; - - for (f = MESA_FORMAT_NONE + 1; f < MESA_FORMAT_COUNT; f++) { - GLenum datatype = 0; - GLuint comps = 0; - /* This function will emit a problem/warning if the format is - * not handled. - */ - _mesa_format_to_type_and_comps(f, &datatype, &comps); - } -} - - -/** - * Do sanity checking of the format info table. - */ -void -_mesa_test_formats(void) -{ - GLuint i; - - assert(Elements(format_info) == MESA_FORMAT_COUNT); - - for (i = 0; i < MESA_FORMAT_COUNT; i++) { - const struct gl_format_info *info = _mesa_get_format_info(i); - assert(info); - - assert(info->Name == i); - - if (info->Name == MESA_FORMAT_NONE) - continue; - - if (info->BlockWidth == 1 && info->BlockHeight == 1) { - if (info->RedBits > 0) { - GLuint t = info->RedBits + info->GreenBits - + info->BlueBits + info->AlphaBits; - assert(t / 8 <= info->BytesPerBlock); - (void) t; - } - } - - assert(info->DataType == GL_UNSIGNED_NORMALIZED || - info->DataType == GL_SIGNED_NORMALIZED || - info->DataType == GL_UNSIGNED_INT || - info->DataType == GL_INT || - info->DataType == GL_FLOAT || - /* Z32_FLOAT_X24S8 has DataType of GL_NONE */ - info->DataType == GL_NONE); - - if (info->BaseFormat == GL_RGB) { - assert(info->RedBits > 0); - assert(info->GreenBits > 0); - assert(info->BlueBits > 0); - assert(info->AlphaBits == 0); - assert(info->LuminanceBits == 0); - assert(info->IntensityBits == 0); - } - else if (info->BaseFormat == GL_RGBA) { - assert(info->RedBits > 0); - assert(info->GreenBits > 0); - assert(info->BlueBits > 0); - assert(info->AlphaBits > 0); - assert(info->LuminanceBits == 0); - assert(info->IntensityBits == 0); - } - else if (info->BaseFormat == GL_RG) { - assert(info->RedBits > 0); - assert(info->GreenBits > 0); - assert(info->BlueBits == 0); - assert(info->AlphaBits == 0); - assert(info->LuminanceBits == 0); - assert(info->IntensityBits == 0); - } - else if (info->BaseFormat == GL_RED) { - assert(info->RedBits > 0); - assert(info->GreenBits == 0); - assert(info->BlueBits == 0); - assert(info->AlphaBits == 0); - assert(info->LuminanceBits == 0); - assert(info->IntensityBits == 0); - } - else if (info->BaseFormat == GL_LUMINANCE) { - assert(info->RedBits == 0); - assert(info->GreenBits == 0); - assert(info->BlueBits == 0); - assert(info->AlphaBits == 0); - assert(info->LuminanceBits > 0); - assert(info->IntensityBits == 0); - } - else if (info->BaseFormat == GL_INTENSITY) { - assert(info->RedBits == 0); - assert(info->GreenBits == 0); - assert(info->BlueBits == 0); - assert(info->AlphaBits == 0); - assert(info->LuminanceBits == 0); - assert(info->IntensityBits > 0); - } - } - - check_format_to_type_and_comps(); -} - - - -/** - * Return datatype and number of components per texel for the given gl_format. - * Only used for mipmap generation code. - */ -void -_mesa_format_to_type_and_comps(gl_format format, - GLenum *datatype, GLuint *comps) -{ - switch (format) { - case MESA_FORMAT_RGBA8888: - case MESA_FORMAT_RGBA8888_REV: - case MESA_FORMAT_ARGB8888: - case MESA_FORMAT_ARGB8888_REV: - case MESA_FORMAT_XRGB8888: - case MESA_FORMAT_XRGB8888_REV: - *datatype = GL_UNSIGNED_BYTE; - *comps = 4; - return; - case MESA_FORMAT_RGB888: - case MESA_FORMAT_BGR888: - *datatype = GL_UNSIGNED_BYTE; - *comps = 3; - return; - case MESA_FORMAT_RGB565: - case MESA_FORMAT_RGB565_REV: - *datatype = GL_UNSIGNED_SHORT_5_6_5; - *comps = 3; - return; - - case MESA_FORMAT_ARGB4444: - case MESA_FORMAT_ARGB4444_REV: - *datatype = GL_UNSIGNED_SHORT_4_4_4_4; - *comps = 4; - return; - - case MESA_FORMAT_ARGB1555: - case MESA_FORMAT_ARGB1555_REV: - *datatype = GL_UNSIGNED_SHORT_1_5_5_5_REV; - *comps = 4; - return; - - case MESA_FORMAT_ARGB2101010: - *datatype = GL_UNSIGNED_INT_2_10_10_10_REV; - *comps = 4; - return; - - case MESA_FORMAT_RGBA5551: - *datatype = GL_UNSIGNED_SHORT_5_5_5_1; - *comps = 4; - return; - - case MESA_FORMAT_AL44: - *datatype = MESA_UNSIGNED_BYTE_4_4; - *comps = 2; - return; - - case MESA_FORMAT_AL88: - case MESA_FORMAT_AL88_REV: - case MESA_FORMAT_RG88: - case MESA_FORMAT_RG88_REV: - *datatype = GL_UNSIGNED_BYTE; - *comps = 2; - return; - - case MESA_FORMAT_AL1616: - case MESA_FORMAT_AL1616_REV: - case MESA_FORMAT_RG1616: - case MESA_FORMAT_RG1616_REV: - *datatype = GL_UNSIGNED_SHORT; - *comps = 2; - return; - - case MESA_FORMAT_R16: - case MESA_FORMAT_A16: - case MESA_FORMAT_L16: - case MESA_FORMAT_I16: - *datatype = GL_UNSIGNED_SHORT; - *comps = 1; - return; - - case MESA_FORMAT_RGB332: - *datatype = GL_UNSIGNED_BYTE_3_3_2; - *comps = 3; - return; - - case MESA_FORMAT_A8: - case MESA_FORMAT_L8: - case MESA_FORMAT_I8: - case MESA_FORMAT_R8: - case MESA_FORMAT_S8: - *datatype = GL_UNSIGNED_BYTE; - *comps = 1; - return; - - case MESA_FORMAT_YCBCR: - case MESA_FORMAT_YCBCR_REV: - *datatype = GL_UNSIGNED_SHORT; - *comps = 2; - return; - - case MESA_FORMAT_Z24_S8: - *datatype = GL_UNSIGNED_INT; - *comps = 1; /* XXX OK? */ - return; - - case MESA_FORMAT_S8_Z24: - *datatype = GL_UNSIGNED_INT; - *comps = 1; /* XXX OK? */ - return; - - case MESA_FORMAT_Z16: - *datatype = GL_UNSIGNED_SHORT; - *comps = 1; - return; - - case MESA_FORMAT_X8_Z24: - *datatype = GL_UNSIGNED_INT; - *comps = 1; - return; - - case MESA_FORMAT_Z24_X8: - *datatype = GL_UNSIGNED_INT; - *comps = 1; - return; - - case MESA_FORMAT_Z32: - *datatype = GL_UNSIGNED_INT; - *comps = 1; - return; - - case MESA_FORMAT_Z32_FLOAT: - *datatype = GL_FLOAT; - *comps = 1; - return; - - case MESA_FORMAT_Z32_FLOAT_X24S8: - *datatype = GL_FLOAT_32_UNSIGNED_INT_24_8_REV; - *comps = 1; - return; - - case MESA_FORMAT_DUDV8: - *datatype = GL_BYTE; - *comps = 2; - return; - - case MESA_FORMAT_SIGNED_R8: - case MESA_FORMAT_SIGNED_A8: - case MESA_FORMAT_SIGNED_L8: - case MESA_FORMAT_SIGNED_I8: - *datatype = GL_BYTE; - *comps = 1; - return; - case MESA_FORMAT_SIGNED_RG88_REV: - case MESA_FORMAT_SIGNED_AL88: - *datatype = GL_BYTE; - *comps = 2; - return; - case MESA_FORMAT_SIGNED_RGBA8888: - case MESA_FORMAT_SIGNED_RGBA8888_REV: - case MESA_FORMAT_SIGNED_RGBX8888: - *datatype = GL_BYTE; - *comps = 4; - return; - - case MESA_FORMAT_RGBA_16: - *datatype = GL_UNSIGNED_SHORT; - *comps = 4; - return; - - case MESA_FORMAT_SIGNED_R16: - case MESA_FORMAT_SIGNED_A16: - case MESA_FORMAT_SIGNED_L16: - case MESA_FORMAT_SIGNED_I16: - *datatype = GL_SHORT; - *comps = 1; - return; - case MESA_FORMAT_SIGNED_GR1616: - case MESA_FORMAT_SIGNED_AL1616: - *datatype = GL_SHORT; - *comps = 2; - return; - case MESA_FORMAT_SIGNED_RGB_16: - *datatype = GL_SHORT; - *comps = 3; - return; - case MESA_FORMAT_SIGNED_RGBA_16: - *datatype = GL_SHORT; - *comps = 4; - return; - -#if FEATURE_EXT_texture_sRGB - case MESA_FORMAT_SRGB8: - *datatype = GL_UNSIGNED_BYTE; - *comps = 3; - return; - case MESA_FORMAT_SRGBA8: - case MESA_FORMAT_SARGB8: - *datatype = GL_UNSIGNED_BYTE; - *comps = 4; - return; - case MESA_FORMAT_SL8: - *datatype = GL_UNSIGNED_BYTE; - *comps = 1; - return; - case MESA_FORMAT_SLA8: - *datatype = GL_UNSIGNED_BYTE; - *comps = 2; - return; -#endif - -#if FEATURE_texture_fxt1 - case MESA_FORMAT_RGB_FXT1: - case MESA_FORMAT_RGBA_FXT1: -#endif -#if FEATURE_texture_s3tc - case MESA_FORMAT_RGB_DXT1: - case MESA_FORMAT_RGBA_DXT1: - case MESA_FORMAT_RGBA_DXT3: - case MESA_FORMAT_RGBA_DXT5: -#if FEATURE_EXT_texture_sRGB - case MESA_FORMAT_SRGB_DXT1: - case MESA_FORMAT_SRGBA_DXT1: - case MESA_FORMAT_SRGBA_DXT3: - case MESA_FORMAT_SRGBA_DXT5: -#endif -#endif - case MESA_FORMAT_RED_RGTC1: - case MESA_FORMAT_SIGNED_RED_RGTC1: - case MESA_FORMAT_RG_RGTC2: - case MESA_FORMAT_SIGNED_RG_RGTC2: - case MESA_FORMAT_L_LATC1: - case MESA_FORMAT_SIGNED_L_LATC1: - case MESA_FORMAT_LA_LATC2: - case MESA_FORMAT_SIGNED_LA_LATC2: - /* XXX generate error instead? */ - *datatype = GL_UNSIGNED_BYTE; - *comps = 0; - return; - - case MESA_FORMAT_RGBA_FLOAT32: - *datatype = GL_FLOAT; - *comps = 4; - return; - case MESA_FORMAT_RGBA_FLOAT16: - *datatype = GL_HALF_FLOAT_ARB; - *comps = 4; - return; - case MESA_FORMAT_RGB_FLOAT32: - *datatype = GL_FLOAT; - *comps = 3; - return; - case MESA_FORMAT_RGB_FLOAT16: - *datatype = GL_HALF_FLOAT_ARB; - *comps = 3; - return; - case MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32: - case MESA_FORMAT_RG_FLOAT32: - *datatype = GL_FLOAT; - *comps = 2; - return; - case MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16: - case MESA_FORMAT_RG_FLOAT16: - *datatype = GL_HALF_FLOAT_ARB; - *comps = 2; - return; - case MESA_FORMAT_ALPHA_FLOAT32: - case MESA_FORMAT_LUMINANCE_FLOAT32: - case MESA_FORMAT_INTENSITY_FLOAT32: - case MESA_FORMAT_R_FLOAT32: - *datatype = GL_FLOAT; - *comps = 1; - return; - case MESA_FORMAT_ALPHA_FLOAT16: - case MESA_FORMAT_LUMINANCE_FLOAT16: - case MESA_FORMAT_INTENSITY_FLOAT16: - case MESA_FORMAT_R_FLOAT16: - *datatype = GL_HALF_FLOAT_ARB; - *comps = 1; - return; - - case MESA_FORMAT_RGBA_INT8: - *datatype = GL_BYTE; - *comps = 4; - return; - case MESA_FORMAT_RGBA_INT16: - *datatype = GL_SHORT; - *comps = 4; - return; - case MESA_FORMAT_RGBA_INT32: - *datatype = GL_INT; - *comps = 4; - return; - - /** - * \name Non-normalized unsigned integer formats. - */ - case MESA_FORMAT_RGBA_UINT8: - *datatype = GL_UNSIGNED_BYTE; - *comps = 4; - return; - case MESA_FORMAT_RGBA_UINT16: - *datatype = GL_UNSIGNED_SHORT; - *comps = 4; - return; - case MESA_FORMAT_RGBA_UINT32: - *datatype = GL_UNSIGNED_INT; - *comps = 4; - return; - - case MESA_FORMAT_RGB9_E5_FLOAT: - *datatype = GL_UNSIGNED_INT_5_9_9_9_REV; - *comps = 3; - return; - - case MESA_FORMAT_R11_G11_B10_FLOAT: - *datatype = GL_UNSIGNED_INT_10F_11F_11F_REV; - *comps = 3; - return; - - case MESA_FORMAT_COUNT: - assert(0); - return; - - case MESA_FORMAT_NONE: - /* For debug builds, warn if any formats are not handled */ -#ifdef DEBUG - default: -#endif - _mesa_problem(NULL, "bad format %s in _mesa_format_to_type_and_comps", - _mesa_get_format_name(format)); - *datatype = 0; - *comps = 1; - } -} +/* + * Mesa 3-D graphics library + * Version: 7.7 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (c) 2008-2009 VMware, 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 + * 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 "formats.h" +#include "mfeatures.h" + + +/** + * Information about texture formats. + */ +struct gl_format_info +{ + gl_format Name; + + /** text name for debugging */ + const char *StrName; + + /** + * Base format is one of GL_RED, GL_RG, GL_RGB, GL_RGBA, GL_ALPHA, + * GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_INTENSITY, GL_YCBCR_MESA, + * GL_DEPTH_COMPONENT, GL_STENCIL_INDEX, GL_DEPTH_STENCIL, GL_DUDV_ATI. + */ + GLenum BaseFormat; + + /** + * Logical data type: one of GL_UNSIGNED_NORMALIZED, GL_SIGNED_NORMALIZED, + * GL_UNSIGNED_INT, GL_INT, GL_FLOAT. + */ + GLenum DataType; + + GLubyte RedBits; + GLubyte GreenBits; + GLubyte BlueBits; + GLubyte AlphaBits; + GLubyte LuminanceBits; + GLubyte IntensityBits; + GLubyte IndexBits; + GLubyte DepthBits; + GLubyte StencilBits; + + /** + * To describe compressed formats. If not compressed, Width=Height=1. + */ + GLubyte BlockWidth, BlockHeight; + GLubyte BytesPerBlock; +}; + + +/** + * Info about each format. + * These must be in the same order as the MESA_FORMAT_* enums so that + * we can do lookups without searching. + */ +static struct gl_format_info format_info[MESA_FORMAT_COUNT] = +{ + { + MESA_FORMAT_NONE, /* Name */ + "MESA_FORMAT_NONE", /* StrName */ + GL_NONE, /* BaseFormat */ + GL_NONE, /* DataType */ + 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 0, 0, 0 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_RGBA8888, /* Name */ + "MESA_FORMAT_RGBA8888", /* StrName */ + GL_RGBA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 8, 8, 8, 8, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 4 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_RGBA8888_REV, /* Name */ + "MESA_FORMAT_RGBA8888_REV", /* StrName */ + GL_RGBA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 8, 8, 8, 8, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 4 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_ARGB8888, /* Name */ + "MESA_FORMAT_ARGB8888", /* StrName */ + GL_RGBA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 8, 8, 8, 8, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 4 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_ARGB8888_REV, /* Name */ + "MESA_FORMAT_ARGB8888_REV", /* StrName */ + GL_RGBA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 8, 8, 8, 8, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 4 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_XRGB8888, /* Name */ + "MESA_FORMAT_XRGB8888", /* StrName */ + GL_RGB, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 8, 8, 8, 0, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 4 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_XRGB8888_REV, /* Name */ + "MESA_FORMAT_XRGB8888_REV", /* StrName */ + GL_RGB, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 8, 8, 8, 0, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 4 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_RGB888, /* Name */ + "MESA_FORMAT_RGB888", /* StrName */ + GL_RGB, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 8, 8, 8, 0, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 3 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_BGR888, /* Name */ + "MESA_FORMAT_BGR888", /* StrName */ + GL_RGB, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 8, 8, 8, 0, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 3 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_RGB565, /* Name */ + "MESA_FORMAT_RGB565", /* StrName */ + GL_RGB, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 5, 6, 5, 0, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 2 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_RGB565_REV, /* Name */ + "MESA_FORMAT_RGB565_REV", /* StrName */ + GL_RGB, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 5, 6, 5, 0, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 2 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_ARGB4444, /* Name */ + "MESA_FORMAT_ARGB4444", /* StrName */ + GL_RGBA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 4, 4, 4, 4, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 2 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_ARGB4444_REV, /* Name */ + "MESA_FORMAT_ARGB4444_REV", /* StrName */ + GL_RGBA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 4, 4, 4, 4, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 2 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_RGBA5551, /* Name */ + "MESA_FORMAT_RGBA5551", /* StrName */ + GL_RGBA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 5, 5, 5, 1, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 2 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_ARGB1555, /* Name */ + "MESA_FORMAT_ARGB1555", /* StrName */ + GL_RGBA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 5, 5, 5, 1, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 2 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_ARGB1555_REV, /* Name */ + "MESA_FORMAT_ARGB1555_REV", /* StrName */ + GL_RGBA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 5, 5, 5, 1, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 2 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_AL44, /* Name */ + "MESA_FORMAT_AL44", /* StrName */ + GL_LUMINANCE_ALPHA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 0, 0, 0, 4, /* Red/Green/Blue/AlphaBits */ + 4, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 1 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_AL88, /* Name */ + "MESA_FORMAT_AL88", /* StrName */ + GL_LUMINANCE_ALPHA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 0, 0, 0, 8, /* Red/Green/Blue/AlphaBits */ + 8, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 2 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_AL88_REV, /* Name */ + "MESA_FORMAT_AL88_REV", /* StrName */ + GL_LUMINANCE_ALPHA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 0, 0, 0, 8, /* Red/Green/Blue/AlphaBits */ + 8, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 2 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_AL1616, /* Name */ + "MESA_FORMAT_AL1616", /* StrName */ + GL_LUMINANCE_ALPHA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 0, 0, 0, 16, /* Red/Green/Blue/AlphaBits */ + 16, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 4 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_AL1616_REV, /* Name */ + "MESA_FORMAT_AL1616_REV", /* StrName */ + GL_LUMINANCE_ALPHA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 0, 0, 0, 16, /* Red/Green/Blue/AlphaBits */ + 16, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 4 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_RGB332, /* Name */ + "MESA_FORMAT_RGB332", /* StrName */ + GL_RGB, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 3, 3, 2, 0, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 1 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_A8, /* Name */ + "MESA_FORMAT_A8", /* StrName */ + GL_ALPHA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 0, 0, 0, 8, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 1 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_A16, /* Name */ + "MESA_FORMAT_A16", /* StrName */ + GL_ALPHA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 0, 0, 0, 16, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 2 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_L8, /* Name */ + "MESA_FORMAT_L8", /* StrName */ + GL_LUMINANCE, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ + 8, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 1 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_L16, /* Name */ + "MESA_FORMAT_L16", /* StrName */ + GL_LUMINANCE, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ + 16, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 2 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_I8, /* Name */ + "MESA_FORMAT_I8", /* StrName */ + GL_INTENSITY, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ + 0, 8, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 1 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_I16, /* Name */ + "MESA_FORMAT_I16", /* StrName */ + GL_INTENSITY, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ + 0, 16, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 2 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_YCBCR, /* Name */ + "MESA_FORMAT_YCBCR", /* StrName */ + GL_YCBCR_MESA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 2 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_YCBCR_REV, /* Name */ + "MESA_FORMAT_YCBCR_REV", /* StrName */ + GL_YCBCR_MESA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 2 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_R8, + "MESA_FORMAT_R8", + GL_RED, + GL_UNSIGNED_NORMALIZED, + 8, 0, 0, 0, + 0, 0, 0, 0, 0, + 1, 1, 1 + }, + { + MESA_FORMAT_RG88, + "MESA_FORMAT_RG88", + GL_RG, + GL_UNSIGNED_NORMALIZED, + 8, 8, 0, 0, + 0, 0, 0, 0, 0, + 1, 1, 2 + }, + { + MESA_FORMAT_RG88_REV, + "MESA_FORMAT_RG88_REV", + GL_RG, + GL_UNSIGNED_NORMALIZED, + 8, 8, 0, 0, + 0, 0, 0, 0, 0, + 1, 1, 2 + }, + { + MESA_FORMAT_R16, + "MESA_FORMAT_R16", + GL_RED, + GL_UNSIGNED_NORMALIZED, + 16, 0, 0, 0, + 0, 0, 0, 0, 0, + 1, 1, 2 + }, + { + MESA_FORMAT_RG1616, + "MESA_FORMAT_RG1616", + GL_RG, + GL_UNSIGNED_NORMALIZED, + 16, 16, 0, 0, + 0, 0, 0, 0, 0, + 1, 1, 4 + }, + { + MESA_FORMAT_RG1616_REV, + "MESA_FORMAT_RG1616_REV", + GL_RG, + GL_UNSIGNED_NORMALIZED, + 16, 16, 0, 0, + 0, 0, 0, 0, 0, + 1, 1, 4 + }, + { + MESA_FORMAT_ARGB2101010, + "MESA_FORMAT_ARGB2101010", + GL_RGBA, + GL_UNSIGNED_NORMALIZED, + 10, 10, 10, 2, + 0, 0, 0, 0, 0, + 1, 1, 4 + }, + { + MESA_FORMAT_Z24_S8, /* Name */ + "MESA_FORMAT_Z24_S8", /* StrName */ + GL_DEPTH_STENCIL, /* BaseFormat */ + GL_UNSIGNED_INT, /* DataType */ + 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 24, 8, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 4 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_S8_Z24, /* Name */ + "MESA_FORMAT_S8_Z24", /* StrName */ + GL_DEPTH_STENCIL, /* BaseFormat */ + GL_UNSIGNED_INT, /* DataType */ + 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 24, 8, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 4 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_Z16, /* Name */ + "MESA_FORMAT_Z16", /* StrName */ + GL_DEPTH_COMPONENT, /* BaseFormat */ + GL_UNSIGNED_INT, /* DataType */ + 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 16, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 2 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_X8_Z24, /* Name */ + "MESA_FORMAT_X8_Z24", /* StrName */ + GL_DEPTH_COMPONENT, /* BaseFormat */ + GL_UNSIGNED_INT, /* DataType */ + 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 24, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 4 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_Z24_X8, /* Name */ + "MESA_FORMAT_Z24_X8", /* StrName */ + GL_DEPTH_COMPONENT, /* BaseFormat */ + GL_UNSIGNED_INT, /* DataType */ + 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 24, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 4 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_Z32, /* Name */ + "MESA_FORMAT_Z32", /* StrName */ + GL_DEPTH_COMPONENT, /* BaseFormat */ + GL_UNSIGNED_INT, /* DataType */ + 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 32, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 4 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_S8, /* Name */ + "MESA_FORMAT_S8", /* StrName */ + GL_STENCIL_INDEX, /* BaseFormat */ + GL_UNSIGNED_INT, /* DataType */ + 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 8, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 1 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_SRGB8, + "MESA_FORMAT_SRGB8", + GL_RGB, + GL_UNSIGNED_NORMALIZED, + 8, 8, 8, 0, + 0, 0, 0, 0, 0, + 1, 1, 3 + }, + { + MESA_FORMAT_SRGBA8, + "MESA_FORMAT_SRGBA8", + GL_RGBA, + GL_UNSIGNED_NORMALIZED, + 8, 8, 8, 8, + 0, 0, 0, 0, 0, + 1, 1, 4 + }, + { + MESA_FORMAT_SARGB8, + "MESA_FORMAT_SARGB8", + GL_RGBA, + GL_UNSIGNED_NORMALIZED, + 8, 8, 8, 8, + 0, 0, 0, 0, 0, + 1, 1, 4 + }, + { + MESA_FORMAT_SL8, + "MESA_FORMAT_SL8", + GL_LUMINANCE, + GL_UNSIGNED_NORMALIZED, + 0, 0, 0, 0, + 8, 0, 0, 0, 0, + 1, 1, 1 + }, + { + MESA_FORMAT_SLA8, + "MESA_FORMAT_SLA8", + GL_LUMINANCE_ALPHA, + GL_UNSIGNED_NORMALIZED, + 0, 0, 0, 8, + 8, 0, 0, 0, 0, + 1, 1, 2 + }, + { + MESA_FORMAT_SRGB_DXT1, /* Name */ + "MESA_FORMAT_SRGB_DXT1", /* StrName */ + GL_RGB, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 4, 4, 4, 0, /* approx Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 4, 4, 8 /* 8 bytes per 4x4 block */ + }, + { + MESA_FORMAT_SRGBA_DXT1, + "MESA_FORMAT_SRGBA_DXT1", + GL_RGBA, + GL_UNSIGNED_NORMALIZED, + 4, 4, 4, 4, + 0, 0, 0, 0, 0, + 4, 4, 8 /* 8 bytes per 4x4 block */ + }, + { + MESA_FORMAT_SRGBA_DXT3, + "MESA_FORMAT_SRGBA_DXT3", + GL_RGBA, + GL_UNSIGNED_NORMALIZED, + 4, 4, 4, 4, + 0, 0, 0, 0, 0, + 4, 4, 16 /* 16 bytes per 4x4 block */ + }, + { + MESA_FORMAT_SRGBA_DXT5, + "MESA_FORMAT_SRGBA_DXT5", + GL_RGBA, + GL_UNSIGNED_NORMALIZED, + 4, 4, 4, 4, + 0, 0, 0, 0, 0, + 4, 4, 16 /* 16 bytes per 4x4 block */ + }, + + { + MESA_FORMAT_RGB_FXT1, + "MESA_FORMAT_RGB_FXT1", + GL_RGB, + GL_UNSIGNED_NORMALIZED, + 4, 4, 4, 0, /* approx Red/Green/BlueBits */ + 0, 0, 0, 0, 0, + 8, 4, 16 /* 16 bytes per 8x4 block */ + }, + { + MESA_FORMAT_RGBA_FXT1, + "MESA_FORMAT_RGBA_FXT1", + GL_RGBA, + GL_UNSIGNED_NORMALIZED, + 4, 4, 4, 1, /* approx Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, + 8, 4, 16 /* 16 bytes per 8x4 block */ + }, + + { + MESA_FORMAT_RGB_DXT1, /* Name */ + "MESA_FORMAT_RGB_DXT1", /* StrName */ + GL_RGB, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 4, 4, 4, 0, /* approx Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 4, 4, 8 /* 8 bytes per 4x4 block */ + }, + { + MESA_FORMAT_RGBA_DXT1, + "MESA_FORMAT_RGBA_DXT1", + GL_RGBA, + GL_UNSIGNED_NORMALIZED, + 4, 4, 4, 4, + 0, 0, 0, 0, 0, + 4, 4, 8 /* 8 bytes per 4x4 block */ + }, + { + MESA_FORMAT_RGBA_DXT3, + "MESA_FORMAT_RGBA_DXT3", + GL_RGBA, + GL_UNSIGNED_NORMALIZED, + 4, 4, 4, 4, + 0, 0, 0, 0, 0, + 4, 4, 16 /* 16 bytes per 4x4 block */ + }, + { + MESA_FORMAT_RGBA_DXT5, + "MESA_FORMAT_RGBA_DXT5", + GL_RGBA, + GL_UNSIGNED_NORMALIZED, + 4, 4, 4, 4, + 0, 0, 0, 0, 0, + 4, 4, 16 /* 16 bytes per 4x4 block */ + }, + { + MESA_FORMAT_RGBA_FLOAT32, + "MESA_FORMAT_RGBA_FLOAT32", + GL_RGBA, + GL_FLOAT, + 32, 32, 32, 32, + 0, 0, 0, 0, 0, + 1, 1, 16 + }, + { + MESA_FORMAT_RGBA_FLOAT16, + "MESA_FORMAT_RGBA_FLOAT16", + GL_RGBA, + GL_FLOAT, + 16, 16, 16, 16, + 0, 0, 0, 0, 0, + 1, 1, 8 + }, + { + MESA_FORMAT_RGB_FLOAT32, + "MESA_FORMAT_RGB_FLOAT32", + GL_RGB, + GL_FLOAT, + 32, 32, 32, 0, + 0, 0, 0, 0, 0, + 1, 1, 12 + }, + { + MESA_FORMAT_RGB_FLOAT16, + "MESA_FORMAT_RGB_FLOAT16", + GL_RGB, + GL_FLOAT, + 16, 16, 16, 0, + 0, 0, 0, 0, 0, + 1, 1, 6 + }, + { + MESA_FORMAT_ALPHA_FLOAT32, + "MESA_FORMAT_ALPHA_FLOAT32", + GL_ALPHA, + GL_FLOAT, + 0, 0, 0, 32, + 0, 0, 0, 0, 0, + 1, 1, 4 + }, + { + MESA_FORMAT_ALPHA_FLOAT16, + "MESA_FORMAT_ALPHA_FLOAT16", + GL_ALPHA, + GL_FLOAT, + 0, 0, 0, 16, + 0, 0, 0, 0, 0, + 1, 1, 2 + }, + { + MESA_FORMAT_LUMINANCE_FLOAT32, + "MESA_FORMAT_LUMINANCE_FLOAT32", + GL_LUMINANCE, + GL_FLOAT, + 0, 0, 0, 0, + 32, 0, 0, 0, 0, + 1, 1, 4 + }, + { + MESA_FORMAT_LUMINANCE_FLOAT16, + "MESA_FORMAT_LUMINANCE_FLOAT16", + GL_LUMINANCE, + GL_FLOAT, + 0, 0, 0, 0, + 16, 0, 0, 0, 0, + 1, 1, 2 + }, + { + MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32, + "MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32", + GL_LUMINANCE_ALPHA, + GL_FLOAT, + 0, 0, 0, 32, + 32, 0, 0, 0, 0, + 1, 1, 8 + }, + { + MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16, + "MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16", + GL_LUMINANCE_ALPHA, + GL_FLOAT, + 0, 0, 0, 16, + 16, 0, 0, 0, 0, + 1, 1, 4 + }, + { + MESA_FORMAT_INTENSITY_FLOAT32, + "MESA_FORMAT_INTENSITY_FLOAT32", + GL_INTENSITY, + GL_FLOAT, + 0, 0, 0, 0, + 0, 32, 0, 0, 0, + 1, 1, 4 + }, + { + MESA_FORMAT_INTENSITY_FLOAT16, + "MESA_FORMAT_INTENSITY_FLOAT16", + GL_INTENSITY, + GL_FLOAT, + 0, 0, 0, 0, + 0, 16, 0, 0, 0, + 1, 1, 2 + }, + { + MESA_FORMAT_R_FLOAT32, + "MESA_FORMAT_R_FLOAT32", + GL_RED, + GL_FLOAT, + 32, 0, 0, 0, + 0, 0, 0, 0, 0, + 1, 1, 4 + }, + { + MESA_FORMAT_R_FLOAT16, + "MESA_FORMAT_R_FLOAT16", + GL_RED, + GL_FLOAT, + 16, 0, 0, 0, + 0, 0, 0, 0, 0, + 1, 1, 2 + }, + { + MESA_FORMAT_RG_FLOAT32, + "MESA_FORMAT_RG_FLOAT32", + GL_RG, + GL_FLOAT, + 32, 32, 0, 0, + 0, 0, 0, 0, 0, + 1, 1, 8 + }, + { + MESA_FORMAT_RG_FLOAT16, + "MESA_FORMAT_RG_FLOAT16", + GL_RG, + GL_FLOAT, + 16, 16, 0, 0, + 0, 0, 0, 0, 0, + 1, 1, 4 + }, + + /* unnormalized signed int formats */ + { + MESA_FORMAT_RGBA_INT8, + "MESA_FORMAT_RGBA_INT8", + GL_RGBA, + GL_INT, + 8, 8, 8, 8, + 0, 0, 0, 0, 0, + 1, 1, 4 + }, + { + MESA_FORMAT_RGBA_INT16, + "MESA_FORMAT_RGBA_INT16", + GL_RGBA, + GL_INT, + 16, 16, 16, 16, + 0, 0, 0, 0, 0, + 1, 1, 8 + }, + { + MESA_FORMAT_RGBA_INT32, + "MESA_FORMAT_RGBA_INT32", + GL_RGBA, + GL_INT, + 32, 32, 32, 32, + 0, 0, 0, 0, 0, + 1, 1, 16 + }, + + /* unnormalized unsigned int formats */ + { + MESA_FORMAT_RGBA_UINT8, + "MESA_FORMAT_RGBA_UINT8", + GL_RGBA, + GL_UNSIGNED_INT, + 8, 8, 8, 8, + 0, 0, 0, 0, 0, + 1, 1, 4 + }, + { + MESA_FORMAT_RGBA_UINT16, + "MESA_FORMAT_RGBA_UINT16", + GL_RGBA, + GL_UNSIGNED_INT, + 16, 16, 16, 16, + 0, 0, 0, 0, 0, + 1, 1, 8 + }, + { + MESA_FORMAT_RGBA_UINT32, + "MESA_FORMAT_RGBA_UINT32", + GL_RGBA, + GL_UNSIGNED_INT, + 32, 32, 32, 32, + 0, 0, 0, 0, 0, + 1, 1, 16 + }, + + + { + MESA_FORMAT_DUDV8, + "MESA_FORMAT_DUDV8", + GL_DUDV_ATI, + GL_SIGNED_NORMALIZED, + 0, 0, 0, 0, + 0, 0, 0, 0, 0, + 1, 1, 2 + }, + + /* Signed 8 bits / channel */ + { + MESA_FORMAT_SIGNED_R8, /* Name */ + "MESA_FORMAT_SIGNED_R8", /* StrName */ + GL_RED, /* BaseFormat */ + GL_SIGNED_NORMALIZED, /* DataType */ + 8, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 1 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_SIGNED_RG88_REV, + "MESA_FORMAT_SIGNED_RG88_REV", + GL_RG, + GL_SIGNED_NORMALIZED, + 8, 8, 0, 0, + 0, 0, 0, 0, 0, + 1, 1, 2 + }, + { + MESA_FORMAT_SIGNED_RGBX8888, + "MESA_FORMAT_SIGNED_RGBX8888", + GL_RGB, + GL_SIGNED_NORMALIZED, + 8, 8, 8, 0, + 0, 0, 0, 0, 0, + 1, 1, 4 /* 4 bpp, but no alpha */ + }, + { + MESA_FORMAT_SIGNED_RGBA8888, + "MESA_FORMAT_SIGNED_RGBA8888", + GL_RGBA, + GL_SIGNED_NORMALIZED, + 8, 8, 8, 8, + 0, 0, 0, 0, 0, + 1, 1, 4 + }, + { + MESA_FORMAT_SIGNED_RGBA8888_REV, + "MESA_FORMAT_SIGNED_RGBA8888_REV", + GL_RGBA, + GL_SIGNED_NORMALIZED, + 8, 8, 8, 8, + 0, 0, 0, 0, 0, + 1, 1, 4 + }, + + /* Signed 16 bits / channel */ + { + MESA_FORMAT_SIGNED_R16, + "MESA_FORMAT_SIGNED_R16", + GL_RED, + GL_SIGNED_NORMALIZED, + 16, 0, 0, 0, + 0, 0, 0, 0, 0, + 1, 1, 2 + }, + { + MESA_FORMAT_SIGNED_GR1616, + "MESA_FORMAT_SIGNED_GR1616", + GL_RG, + GL_SIGNED_NORMALIZED, + 16, 16, 0, 0, + 0, 0, 0, 0, 0, + 1, 1, 4 + }, + { + MESA_FORMAT_SIGNED_RGB_16, + "MESA_FORMAT_SIGNED_RGB_16", + GL_RGB, + GL_SIGNED_NORMALIZED, + 16, 16, 16, 0, + 0, 0, 0, 0, 0, + 1, 1, 6 + }, + { + MESA_FORMAT_SIGNED_RGBA_16, + "MESA_FORMAT_SIGNED_RGBA_16", + GL_RGBA, + GL_SIGNED_NORMALIZED, + 16, 16, 16, 16, + 0, 0, 0, 0, 0, + 1, 1, 8 + }, + { + MESA_FORMAT_RGBA_16, + "MESA_FORMAT_RGBA_16", + GL_RGBA, + GL_UNSIGNED_NORMALIZED, + 16, 16, 16, 16, + 0, 0, 0, 0, 0, + 1, 1, 8 + }, + { + MESA_FORMAT_RED_RGTC1, + "MESA_FORMAT_RED_RGTC1", + GL_RED, + GL_UNSIGNED_NORMALIZED, + 4, 0, 0, 0, + 0, 0, 0, 0, 0, + 4, 4, 8 /* 8 bytes per 4x4 block */ + }, + { + MESA_FORMAT_SIGNED_RED_RGTC1, + "MESA_FORMAT_SIGNED_RED_RGTC1", + GL_RED, + GL_SIGNED_NORMALIZED, + 4, 0, 0, 0, + 0, 0, 0, 0, 0, + 4, 4, 8 /* 8 bytes per 4x4 block */ + }, + { + MESA_FORMAT_RG_RGTC2, + "MESA_FORMAT_RG_RGTC2", + GL_RG, + GL_UNSIGNED_NORMALIZED, + 4, 4, 0, 0, + 0, 0, 0, 0, 0, + 4, 4, 16 /* 16 bytes per 4x4 block */ + }, + { + MESA_FORMAT_SIGNED_RG_RGTC2, + "MESA_FORMAT_SIGNED_RG_RGTC2", + GL_RG, + GL_SIGNED_NORMALIZED, + 4, 4, 0, 0, + 0, 0, 0, 0, 0, + 4, 4, 16 /* 16 bytes per 4x4 block */ + }, + { + MESA_FORMAT_L_LATC1, + "MESA_FORMAT_L_LATC1", + GL_LUMINANCE, + GL_UNSIGNED_NORMALIZED, + 0, 0, 0, 0, + 4, 0, 0, 0, 0, + 4, 4, 8 /* 8 bytes per 4x4 block */ + }, + { + MESA_FORMAT_SIGNED_L_LATC1, + "MESA_FORMAT_SIGNED_L_LATC1", + GL_LUMINANCE, + GL_SIGNED_NORMALIZED, + 0, 0, 0, 0, + 4, 0, 0, 0, 0, + 4, 4, 8 /* 8 bytes per 4x4 block */ + }, + { + MESA_FORMAT_LA_LATC2, + "MESA_FORMAT_LA_LATC2", + GL_LUMINANCE_ALPHA, + GL_UNSIGNED_NORMALIZED, + 0, 0, 0, 4, + 4, 0, 0, 0, 0, + 4, 4, 16 /* 16 bytes per 4x4 block */ + }, + { + MESA_FORMAT_SIGNED_LA_LATC2, + "MESA_FORMAT_SIGNED_LA_LATC2", + GL_LUMINANCE_ALPHA, + GL_SIGNED_NORMALIZED, + 0, 0, 0, 4, + 4, 0, 0, 0, 0, + 4, 4, 16 /* 16 bytes per 4x4 block */ + }, + + /* Signed formats from EXT_texture_snorm that are not in GL3.1 */ + { + MESA_FORMAT_SIGNED_A8, + "MESA_FORMAT_SIGNED_A8", + GL_ALPHA, + GL_SIGNED_NORMALIZED, + 0, 0, 0, 8, + 0, 0, 0, 0, 0, + 1, 1, 1 + }, + { + MESA_FORMAT_SIGNED_L8, + "MESA_FORMAT_SIGNED_L8", + GL_LUMINANCE, + GL_SIGNED_NORMALIZED, + 0, 0, 0, 0, + 8, 0, 0, 0, 0, + 1, 1, 1 + }, + { + MESA_FORMAT_SIGNED_AL88, + "MESA_FORMAT_SIGNED_AL88", + GL_LUMINANCE_ALPHA, + GL_SIGNED_NORMALIZED, + 0, 0, 0, 8, + 8, 0, 0, 0, 0, + 1, 1, 2 + }, + { + MESA_FORMAT_SIGNED_I8, + "MESA_FORMAT_SIGNED_I8", + GL_INTENSITY, + GL_SIGNED_NORMALIZED, + 0, 0, 0, 0, + 0, 8, 0, 0, 0, + 1, 1, 1 + }, + { + MESA_FORMAT_SIGNED_A16, + "MESA_FORMAT_SIGNED_A16", + GL_ALPHA, + GL_SIGNED_NORMALIZED, + 0, 0, 0, 16, + 0, 0, 0, 0, 0, + 1, 1, 2 + }, + { + MESA_FORMAT_SIGNED_L16, + "MESA_FORMAT_SIGNED_L16", + GL_LUMINANCE, + GL_SIGNED_NORMALIZED, + 0, 0, 0, 0, + 16, 0, 0, 0, 0, + 1, 1, 2 + }, + { + MESA_FORMAT_SIGNED_AL1616, + "MESA_FORMAT_SIGNED_AL1616", + GL_LUMINANCE_ALPHA, + GL_SIGNED_NORMALIZED, + 0, 0, 0, 16, + 16, 0, 0, 0, 0, + 1, 1, 4 + }, + { + MESA_FORMAT_SIGNED_I16, + "MESA_FORMAT_SIGNED_I16", + GL_INTENSITY, + GL_SIGNED_NORMALIZED, + 0, 0, 0, 0, + 0, 16, 0, 0, 0, + 1, 1, 2 + }, + { + MESA_FORMAT_RGB9_E5_FLOAT, + "MESA_FORMAT_RGB9_E5", + GL_RGB, + GL_FLOAT, + 9, 9, 9, 0, + 0, 0, 0, 0, 0, + 1, 1, 4 + }, + { + MESA_FORMAT_R11_G11_B10_FLOAT, + "MESA_FORMAT_R11_G11_B10_FLOAT", + GL_RGB, + GL_FLOAT, + 11, 11, 10, 0, + 0, 0, 0, 0, 0, + 1, 1, 4 + }, + /* ARB_depth_buffer_float */ + { + MESA_FORMAT_Z32_FLOAT, /* Name */ + "MESA_FORMAT_Z32_FLOAT", /* StrName */ + GL_DEPTH_COMPONENT, /* BaseFormat */ + GL_FLOAT, /* DataType */ + 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 32, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 4 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_Z32_FLOAT_X24S8, /* Name */ + "MESA_FORMAT_Z32_FLOAT_X24S8", /* StrName */ + GL_DEPTH_STENCIL, /* BaseFormat */ + GL_NONE /* XXX */, /* DataType */ + 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 32, 8, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 8 /* BlockWidth/Height,Bytes */ + }, +}; + + + +static const struct gl_format_info * +_mesa_get_format_info(gl_format format) +{ + const struct gl_format_info *info = &format_info[format]; + assert(info->Name == format); + return info; +} + + +/** Return string name of format (for debugging) */ +const char * +_mesa_get_format_name(gl_format format) +{ + const struct gl_format_info *info = _mesa_get_format_info(format); + return info->StrName; +} + + + +/** + * Return bytes needed to store a block of pixels in the given format. + * Normally, a block is 1x1 (a single pixel). But for compressed formats + * a block may be 4x4 or 8x4, etc. + * + * Note: not GLuint, so as not to coerce math to unsigned. cf. fdo #37351 + */ +GLint +_mesa_get_format_bytes(gl_format format) +{ + const struct gl_format_info *info = _mesa_get_format_info(format); + ASSERT(info->BytesPerBlock); + return info->BytesPerBlock; +} + + +/** + * Return bits per component for the given format. + * \param format one of MESA_FORMAT_x + * \param pname the component, such as GL_RED_BITS, GL_TEXTURE_BLUE_BITS, etc. + */ +GLint +_mesa_get_format_bits(gl_format format, GLenum pname) +{ + const struct gl_format_info *info = _mesa_get_format_info(format); + + switch (pname) { + case GL_RED_BITS: + case GL_TEXTURE_RED_SIZE: + case GL_RENDERBUFFER_RED_SIZE_EXT: + case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE: + return info->RedBits; + case GL_GREEN_BITS: + case GL_TEXTURE_GREEN_SIZE: + case GL_RENDERBUFFER_GREEN_SIZE_EXT: + case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE: + return info->GreenBits; + case GL_BLUE_BITS: + case GL_TEXTURE_BLUE_SIZE: + case GL_RENDERBUFFER_BLUE_SIZE_EXT: + case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE: + return info->BlueBits; + case GL_ALPHA_BITS: + case GL_TEXTURE_ALPHA_SIZE: + case GL_RENDERBUFFER_ALPHA_SIZE_EXT: + case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE: + return info->AlphaBits; + case GL_TEXTURE_INTENSITY_SIZE: + return info->IntensityBits; + case GL_TEXTURE_LUMINANCE_SIZE: + return info->LuminanceBits; + case GL_INDEX_BITS: + return info->IndexBits; + case GL_DEPTH_BITS: + case GL_TEXTURE_DEPTH_SIZE_ARB: + case GL_RENDERBUFFER_DEPTH_SIZE_EXT: + case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE: + return info->DepthBits; + case GL_STENCIL_BITS: + case GL_TEXTURE_STENCIL_SIZE_EXT: + case GL_RENDERBUFFER_STENCIL_SIZE_EXT: + case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE: + return info->StencilBits; + default: + _mesa_problem(NULL, "bad pname in _mesa_get_format_bits()"); + return 0; + } +} + + +/** + * Return the data type (or more specifically, the data representation) + * for the given format. + * The return value will be one of: + * GL_UNSIGNED_NORMALIZED = unsigned int representing [0,1] + * GL_SIGNED_NORMALIZED = signed int representing [-1, 1] + * GL_UNSIGNED_INT = an ordinary unsigned integer + * GL_INT = an ordinary signed integer + * GL_FLOAT = an ordinary float + */ +GLenum +_mesa_get_format_datatype(gl_format format) +{ + const struct gl_format_info *info = _mesa_get_format_info(format); + return info->DataType; +} + + +/** + * Return the basic format for the given type. The result will be one of + * GL_RGB, GL_RGBA, GL_ALPHA, GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_INTENSITY, + * GL_YCBCR_MESA, GL_DEPTH_COMPONENT, GL_STENCIL_INDEX, GL_DEPTH_STENCIL. + */ +GLenum +_mesa_get_format_base_format(gl_format format) +{ + const struct gl_format_info *info = _mesa_get_format_info(format); + return info->BaseFormat; +} + + +/** + * Return the block size (in pixels) for the given format. Normally + * the block size is 1x1. But compressed formats will have block sizes + * of 4x4 or 8x4 pixels, etc. + * \param bw returns block width in pixels + * \param bh returns block height in pixels + */ +void +_mesa_get_format_block_size(gl_format format, GLuint *bw, GLuint *bh) +{ + const struct gl_format_info *info = _mesa_get_format_info(format); + *bw = info->BlockWidth; + *bh = info->BlockHeight; +} + + +/** Is the given format a compressed format? */ +GLboolean +_mesa_is_format_compressed(gl_format format) +{ + const struct gl_format_info *info = _mesa_get_format_info(format); + return info->BlockWidth > 1 || info->BlockHeight > 1; +} + + +/** + * Determine if the given format represents a packed depth/stencil buffer. + */ +GLboolean +_mesa_is_format_packed_depth_stencil(gl_format format) +{ + const struct gl_format_info *info = _mesa_get_format_info(format); + + return info->BaseFormat == GL_DEPTH_STENCIL; +} + + +/** + * Is the given format a signed/unsigned integer color format? + */ +GLboolean +_mesa_is_format_integer_color(gl_format format) +{ + const struct gl_format_info *info = _mesa_get_format_info(format); + return (info->DataType == GL_INT || info->DataType == GL_UNSIGNED_INT) && + info->BaseFormat != GL_DEPTH_COMPONENT && + info->BaseFormat != GL_DEPTH_STENCIL && + info->BaseFormat != GL_STENCIL_INDEX; +} + + +/** + * Return color encoding for given format. + * \return GL_LINEAR or GL_SRGB + */ +GLenum +_mesa_get_format_color_encoding(gl_format format) +{ + /* XXX this info should be encoded in gl_format_info */ + switch (format) { + case MESA_FORMAT_SRGB8: + case MESA_FORMAT_SRGBA8: + case MESA_FORMAT_SARGB8: + case MESA_FORMAT_SL8: + case MESA_FORMAT_SLA8: + case MESA_FORMAT_SRGB_DXT1: + case MESA_FORMAT_SRGBA_DXT1: + case MESA_FORMAT_SRGBA_DXT3: + case MESA_FORMAT_SRGBA_DXT5: + return GL_SRGB; + default: + return GL_LINEAR; + } +} + + +/** + * For an sRGB format, return the corresponding linear color space format. + * For non-sRGB formats, return the format as-is. + */ +gl_format +_mesa_get_srgb_format_linear(gl_format format) +{ + switch (format) { + case MESA_FORMAT_SRGB8: + format = MESA_FORMAT_RGB888; + break; + case MESA_FORMAT_SRGBA8: + format = MESA_FORMAT_RGBA8888; + break; + case MESA_FORMAT_SARGB8: + format = MESA_FORMAT_ARGB8888; + break; + case MESA_FORMAT_SL8: + format = MESA_FORMAT_L8; + break; + case MESA_FORMAT_SLA8: + format = MESA_FORMAT_AL88; + break; + case MESA_FORMAT_SRGB_DXT1: + format = MESA_FORMAT_RGB_DXT1; + break; + case MESA_FORMAT_SRGBA_DXT1: + format = MESA_FORMAT_RGBA_DXT1; + break; + case MESA_FORMAT_SRGBA_DXT3: + format = MESA_FORMAT_RGBA_DXT3; + break; + case MESA_FORMAT_SRGBA_DXT5: + format = MESA_FORMAT_RGBA_DXT5; + break; + default: + break; + } + return format; +} + + +/** + * If the given format is a compressed format, return a corresponding + * uncompressed format. + */ +gl_format +_mesa_get_uncompressed_format(gl_format format) +{ + switch (format) { + case MESA_FORMAT_RGB_FXT1: + return MESA_FORMAT_RGB888; + case MESA_FORMAT_RGBA_FXT1: + return MESA_FORMAT_RGBA8888; + case MESA_FORMAT_RGB_DXT1: + case MESA_FORMAT_SRGB_DXT1: + return MESA_FORMAT_RGB888; + case MESA_FORMAT_RGBA_DXT1: + case MESA_FORMAT_SRGBA_DXT1: + return MESA_FORMAT_RGBA8888; + case MESA_FORMAT_RGBA_DXT3: + case MESA_FORMAT_SRGBA_DXT3: + return MESA_FORMAT_RGBA8888; + case MESA_FORMAT_RGBA_DXT5: + case MESA_FORMAT_SRGBA_DXT5: + return MESA_FORMAT_RGBA8888; + case MESA_FORMAT_RED_RGTC1: + return MESA_FORMAT_R8; + case MESA_FORMAT_SIGNED_RED_RGTC1: + return MESA_FORMAT_SIGNED_R8; + case MESA_FORMAT_RG_RGTC2: + return MESA_FORMAT_RG88; + case MESA_FORMAT_SIGNED_RG_RGTC2: + return MESA_FORMAT_SIGNED_RG88_REV; + case MESA_FORMAT_L_LATC1: + return MESA_FORMAT_L8; + case MESA_FORMAT_SIGNED_L_LATC1: + return MESA_FORMAT_SIGNED_L8; + case MESA_FORMAT_LA_LATC2: + return MESA_FORMAT_AL88; + case MESA_FORMAT_SIGNED_LA_LATC2: + return MESA_FORMAT_SIGNED_AL88; + default: +#ifdef DEBUG + assert(!_mesa_is_format_compressed(format)); +#endif + return format; + } +} + + +GLuint +_mesa_format_num_components(gl_format format) +{ + const struct gl_format_info *info = _mesa_get_format_info(format); + return ((info->RedBits > 0) + + (info->GreenBits > 0) + + (info->BlueBits > 0) + + (info->AlphaBits > 0) + + (info->LuminanceBits > 0) + + (info->IntensityBits > 0) + + (info->DepthBits > 0) + + (info->StencilBits > 0)); +} + + +/** + * Return number of bytes needed to store an image of the given size + * in the given format. + */ +GLuint +_mesa_format_image_size(gl_format format, GLsizei width, + GLsizei height, GLsizei depth) +{ + const struct gl_format_info *info = _mesa_get_format_info(format); + /* Strictly speaking, a conditional isn't needed here */ + if (info->BlockWidth > 1 || info->BlockHeight > 1) { + /* compressed format (2D only for now) */ + const GLuint bw = info->BlockWidth, bh = info->BlockHeight; + const GLuint wblocks = (width + bw - 1) / bw; + const GLuint hblocks = (height + bh - 1) / bh; + const GLuint sz = wblocks * hblocks * info->BytesPerBlock; + assert(depth == 1); + return sz; + } + else { + /* non-compressed */ + const GLuint sz = width * height * depth * info->BytesPerBlock; + return sz; + } +} + + +/** + * Same as _mesa_format_image_size() but returns a 64-bit value to + * accomodate very large textures. + */ +uint64_t +_mesa_format_image_size64(gl_format format, GLsizei width, + GLsizei height, GLsizei depth) +{ + const struct gl_format_info *info = _mesa_get_format_info(format); + /* Strictly speaking, a conditional isn't needed here */ + if (info->BlockWidth > 1 || info->BlockHeight > 1) { + /* compressed format (2D only for now) */ + const uint64_t bw = info->BlockWidth, bh = info->BlockHeight; + const uint64_t wblocks = (width + bw - 1) / bw; + const uint64_t hblocks = (height + bh - 1) / bh; + const uint64_t sz = wblocks * hblocks * info->BytesPerBlock; + assert(depth == 1); + return sz; + } + else { + /* non-compressed */ + const uint64_t sz = ((uint64_t) width * + (uint64_t) height * + (uint64_t) depth * + info->BytesPerBlock); + return sz; + } +} + + + +GLint +_mesa_format_row_stride(gl_format format, GLsizei width) +{ + const struct gl_format_info *info = _mesa_get_format_info(format); + /* Strictly speaking, a conditional isn't needed here */ + if (info->BlockWidth > 1 || info->BlockHeight > 1) { + /* compressed format */ + const GLuint bw = info->BlockWidth; + const GLuint wblocks = (width + bw - 1) / bw; + const GLint stride = wblocks * info->BytesPerBlock; + return stride; + } + else { + const GLint stride = width * info->BytesPerBlock; + return stride; + } +} + + +/** + * Debug/test: check that all formats are handled in the + * _mesa_format_to_type_and_comps() function. When new pixel formats + * are added to Mesa, that function needs to be updated. + * This is a no-op after the first call. + */ +static void +check_format_to_type_and_comps(void) +{ + gl_format f; + + for (f = MESA_FORMAT_NONE + 1; f < MESA_FORMAT_COUNT; f++) { + GLenum datatype = 0; + GLuint comps = 0; + /* This function will emit a problem/warning if the format is + * not handled. + */ + _mesa_format_to_type_and_comps(f, &datatype, &comps); + } +} + + +/** + * Do sanity checking of the format info table. + */ +void +_mesa_test_formats(void) +{ + GLuint i; + + assert(Elements(format_info) == MESA_FORMAT_COUNT); + + for (i = 0; i < MESA_FORMAT_COUNT; i++) { + const struct gl_format_info *info = _mesa_get_format_info(i); + assert(info); + + assert(info->Name == i); + + if (info->Name == MESA_FORMAT_NONE) + continue; + + if (info->BlockWidth == 1 && info->BlockHeight == 1) { + if (info->RedBits > 0) { + GLuint t = info->RedBits + info->GreenBits + + info->BlueBits + info->AlphaBits; + assert(t / 8 <= info->BytesPerBlock); + (void) t; + } + } + + assert(info->DataType == GL_UNSIGNED_NORMALIZED || + info->DataType == GL_SIGNED_NORMALIZED || + info->DataType == GL_UNSIGNED_INT || + info->DataType == GL_INT || + info->DataType == GL_FLOAT || + /* Z32_FLOAT_X24S8 has DataType of GL_NONE */ + info->DataType == GL_NONE); + + if (info->BaseFormat == GL_RGB) { + assert(info->RedBits > 0); + assert(info->GreenBits > 0); + assert(info->BlueBits > 0); + assert(info->AlphaBits == 0); + assert(info->LuminanceBits == 0); + assert(info->IntensityBits == 0); + } + else if (info->BaseFormat == GL_RGBA) { + assert(info->RedBits > 0); + assert(info->GreenBits > 0); + assert(info->BlueBits > 0); + assert(info->AlphaBits > 0); + assert(info->LuminanceBits == 0); + assert(info->IntensityBits == 0); + } + else if (info->BaseFormat == GL_RG) { + assert(info->RedBits > 0); + assert(info->GreenBits > 0); + assert(info->BlueBits == 0); + assert(info->AlphaBits == 0); + assert(info->LuminanceBits == 0); + assert(info->IntensityBits == 0); + } + else if (info->BaseFormat == GL_RED) { + assert(info->RedBits > 0); + assert(info->GreenBits == 0); + assert(info->BlueBits == 0); + assert(info->AlphaBits == 0); + assert(info->LuminanceBits == 0); + assert(info->IntensityBits == 0); + } + else if (info->BaseFormat == GL_LUMINANCE) { + assert(info->RedBits == 0); + assert(info->GreenBits == 0); + assert(info->BlueBits == 0); + assert(info->AlphaBits == 0); + assert(info->LuminanceBits > 0); + assert(info->IntensityBits == 0); + } + else if (info->BaseFormat == GL_INTENSITY) { + assert(info->RedBits == 0); + assert(info->GreenBits == 0); + assert(info->BlueBits == 0); + assert(info->AlphaBits == 0); + assert(info->LuminanceBits == 0); + assert(info->IntensityBits > 0); + } + } + + check_format_to_type_and_comps(); +} + + + +/** + * Return datatype and number of components per texel for the given gl_format. + * Only used for mipmap generation code. + */ +void +_mesa_format_to_type_and_comps(gl_format format, + GLenum *datatype, GLuint *comps) +{ + switch (format) { + case MESA_FORMAT_RGBA8888: + case MESA_FORMAT_RGBA8888_REV: + case MESA_FORMAT_ARGB8888: + case MESA_FORMAT_ARGB8888_REV: + case MESA_FORMAT_XRGB8888: + case MESA_FORMAT_XRGB8888_REV: + *datatype = GL_UNSIGNED_BYTE; + *comps = 4; + return; + case MESA_FORMAT_RGB888: + case MESA_FORMAT_BGR888: + *datatype = GL_UNSIGNED_BYTE; + *comps = 3; + return; + case MESA_FORMAT_RGB565: + case MESA_FORMAT_RGB565_REV: + *datatype = GL_UNSIGNED_SHORT_5_6_5; + *comps = 3; + return; + + case MESA_FORMAT_ARGB4444: + case MESA_FORMAT_ARGB4444_REV: + *datatype = GL_UNSIGNED_SHORT_4_4_4_4; + *comps = 4; + return; + + case MESA_FORMAT_ARGB1555: + case MESA_FORMAT_ARGB1555_REV: + *datatype = GL_UNSIGNED_SHORT_1_5_5_5_REV; + *comps = 4; + return; + + case MESA_FORMAT_ARGB2101010: + *datatype = GL_UNSIGNED_INT_2_10_10_10_REV; + *comps = 4; + return; + + case MESA_FORMAT_RGBA5551: + *datatype = GL_UNSIGNED_SHORT_5_5_5_1; + *comps = 4; + return; + + case MESA_FORMAT_AL44: + *datatype = MESA_UNSIGNED_BYTE_4_4; + *comps = 2; + return; + + case MESA_FORMAT_AL88: + case MESA_FORMAT_AL88_REV: + case MESA_FORMAT_RG88: + case MESA_FORMAT_RG88_REV: + *datatype = GL_UNSIGNED_BYTE; + *comps = 2; + return; + + case MESA_FORMAT_AL1616: + case MESA_FORMAT_AL1616_REV: + case MESA_FORMAT_RG1616: + case MESA_FORMAT_RG1616_REV: + *datatype = GL_UNSIGNED_SHORT; + *comps = 2; + return; + + case MESA_FORMAT_R16: + case MESA_FORMAT_A16: + case MESA_FORMAT_L16: + case MESA_FORMAT_I16: + *datatype = GL_UNSIGNED_SHORT; + *comps = 1; + return; + + case MESA_FORMAT_RGB332: + *datatype = GL_UNSIGNED_BYTE_3_3_2; + *comps = 3; + return; + + case MESA_FORMAT_A8: + case MESA_FORMAT_L8: + case MESA_FORMAT_I8: + case MESA_FORMAT_R8: + case MESA_FORMAT_S8: + *datatype = GL_UNSIGNED_BYTE; + *comps = 1; + return; + + case MESA_FORMAT_YCBCR: + case MESA_FORMAT_YCBCR_REV: + *datatype = GL_UNSIGNED_SHORT; + *comps = 2; + return; + + case MESA_FORMAT_Z24_S8: + *datatype = GL_UNSIGNED_INT; + *comps = 1; /* XXX OK? */ + return; + + case MESA_FORMAT_S8_Z24: + *datatype = GL_UNSIGNED_INT; + *comps = 1; /* XXX OK? */ + return; + + case MESA_FORMAT_Z16: + *datatype = GL_UNSIGNED_SHORT; + *comps = 1; + return; + + case MESA_FORMAT_X8_Z24: + *datatype = GL_UNSIGNED_INT; + *comps = 1; + return; + + case MESA_FORMAT_Z24_X8: + *datatype = GL_UNSIGNED_INT; + *comps = 1; + return; + + case MESA_FORMAT_Z32: + *datatype = GL_UNSIGNED_INT; + *comps = 1; + return; + + case MESA_FORMAT_Z32_FLOAT: + *datatype = GL_FLOAT; + *comps = 1; + return; + + case MESA_FORMAT_Z32_FLOAT_X24S8: + *datatype = GL_FLOAT_32_UNSIGNED_INT_24_8_REV; + *comps = 1; + return; + + case MESA_FORMAT_DUDV8: + *datatype = GL_BYTE; + *comps = 2; + return; + + case MESA_FORMAT_SIGNED_R8: + case MESA_FORMAT_SIGNED_A8: + case MESA_FORMAT_SIGNED_L8: + case MESA_FORMAT_SIGNED_I8: + *datatype = GL_BYTE; + *comps = 1; + return; + case MESA_FORMAT_SIGNED_RG88_REV: + case MESA_FORMAT_SIGNED_AL88: + *datatype = GL_BYTE; + *comps = 2; + return; + case MESA_FORMAT_SIGNED_RGBA8888: + case MESA_FORMAT_SIGNED_RGBA8888_REV: + case MESA_FORMAT_SIGNED_RGBX8888: + *datatype = GL_BYTE; + *comps = 4; + return; + + case MESA_FORMAT_RGBA_16: + *datatype = GL_UNSIGNED_SHORT; + *comps = 4; + return; + + case MESA_FORMAT_SIGNED_R16: + case MESA_FORMAT_SIGNED_A16: + case MESA_FORMAT_SIGNED_L16: + case MESA_FORMAT_SIGNED_I16: + *datatype = GL_SHORT; + *comps = 1; + return; + case MESA_FORMAT_SIGNED_GR1616: + case MESA_FORMAT_SIGNED_AL1616: + *datatype = GL_SHORT; + *comps = 2; + return; + case MESA_FORMAT_SIGNED_RGB_16: + *datatype = GL_SHORT; + *comps = 3; + return; + case MESA_FORMAT_SIGNED_RGBA_16: + *datatype = GL_SHORT; + *comps = 4; + return; + +#if FEATURE_EXT_texture_sRGB + case MESA_FORMAT_SRGB8: + *datatype = GL_UNSIGNED_BYTE; + *comps = 3; + return; + case MESA_FORMAT_SRGBA8: + case MESA_FORMAT_SARGB8: + *datatype = GL_UNSIGNED_BYTE; + *comps = 4; + return; + case MESA_FORMAT_SL8: + *datatype = GL_UNSIGNED_BYTE; + *comps = 1; + return; + case MESA_FORMAT_SLA8: + *datatype = GL_UNSIGNED_BYTE; + *comps = 2; + return; +#endif + +#if FEATURE_texture_fxt1 + case MESA_FORMAT_RGB_FXT1: + case MESA_FORMAT_RGBA_FXT1: +#endif +#if FEATURE_texture_s3tc + case MESA_FORMAT_RGB_DXT1: + case MESA_FORMAT_RGBA_DXT1: + case MESA_FORMAT_RGBA_DXT3: + case MESA_FORMAT_RGBA_DXT5: +#if FEATURE_EXT_texture_sRGB + case MESA_FORMAT_SRGB_DXT1: + case MESA_FORMAT_SRGBA_DXT1: + case MESA_FORMAT_SRGBA_DXT3: + case MESA_FORMAT_SRGBA_DXT5: +#endif +#endif + case MESA_FORMAT_RED_RGTC1: + case MESA_FORMAT_SIGNED_RED_RGTC1: + case MESA_FORMAT_RG_RGTC2: + case MESA_FORMAT_SIGNED_RG_RGTC2: + case MESA_FORMAT_L_LATC1: + case MESA_FORMAT_SIGNED_L_LATC1: + case MESA_FORMAT_LA_LATC2: + case MESA_FORMAT_SIGNED_LA_LATC2: + /* XXX generate error instead? */ + *datatype = GL_UNSIGNED_BYTE; + *comps = 0; + return; + + case MESA_FORMAT_RGBA_FLOAT32: + *datatype = GL_FLOAT; + *comps = 4; + return; + case MESA_FORMAT_RGBA_FLOAT16: + *datatype = GL_HALF_FLOAT_ARB; + *comps = 4; + return; + case MESA_FORMAT_RGB_FLOAT32: + *datatype = GL_FLOAT; + *comps = 3; + return; + case MESA_FORMAT_RGB_FLOAT16: + *datatype = GL_HALF_FLOAT_ARB; + *comps = 3; + return; + case MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32: + case MESA_FORMAT_RG_FLOAT32: + *datatype = GL_FLOAT; + *comps = 2; + return; + case MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16: + case MESA_FORMAT_RG_FLOAT16: + *datatype = GL_HALF_FLOAT_ARB; + *comps = 2; + return; + case MESA_FORMAT_ALPHA_FLOAT32: + case MESA_FORMAT_LUMINANCE_FLOAT32: + case MESA_FORMAT_INTENSITY_FLOAT32: + case MESA_FORMAT_R_FLOAT32: + *datatype = GL_FLOAT; + *comps = 1; + return; + case MESA_FORMAT_ALPHA_FLOAT16: + case MESA_FORMAT_LUMINANCE_FLOAT16: + case MESA_FORMAT_INTENSITY_FLOAT16: + case MESA_FORMAT_R_FLOAT16: + *datatype = GL_HALF_FLOAT_ARB; + *comps = 1; + return; + + case MESA_FORMAT_RGBA_INT8: + *datatype = GL_BYTE; + *comps = 4; + return; + case MESA_FORMAT_RGBA_INT16: + *datatype = GL_SHORT; + *comps = 4; + return; + case MESA_FORMAT_RGBA_INT32: + *datatype = GL_INT; + *comps = 4; + return; + + /** + * \name Non-normalized unsigned integer formats. + */ + case MESA_FORMAT_RGBA_UINT8: + *datatype = GL_UNSIGNED_BYTE; + *comps = 4; + return; + case MESA_FORMAT_RGBA_UINT16: + *datatype = GL_UNSIGNED_SHORT; + *comps = 4; + return; + case MESA_FORMAT_RGBA_UINT32: + *datatype = GL_UNSIGNED_INT; + *comps = 4; + return; + + case MESA_FORMAT_RGB9_E5_FLOAT: + *datatype = GL_UNSIGNED_INT_5_9_9_9_REV; + *comps = 3; + return; + + case MESA_FORMAT_R11_G11_B10_FLOAT: + *datatype = GL_UNSIGNED_INT_10F_11F_11F_REV; + *comps = 3; + return; + + case MESA_FORMAT_COUNT: + assert(0); + return; + + case MESA_FORMAT_NONE: + /* For debug builds, warn if any formats are not handled */ +#ifdef DEBUG + default: +#endif + _mesa_problem(NULL, "bad format %s in _mesa_format_to_type_and_comps", + _mesa_get_format_name(format)); + *datatype = 0; + *comps = 1; + } +} diff --git a/mesalib/src/mesa/main/formats.h b/mesalib/src/mesa/main/formats.h index b6b1b687f..610204cb3 100644 --- a/mesalib/src/mesa/main/formats.h +++ b/mesalib/src/mesa/main/formats.h @@ -1,276 +1,276 @@ -/* - * Mesa 3-D graphics library - * Version: 7.7 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (c) 2008-2009 VMware, 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 - * 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. - */ - -/* - * Authors: - * Brian Paul - */ - - -#ifndef FORMATS_H -#define FORMATS_H - - -#include - -/* OpenGL doesn't have GL_UNSIGNED_BYTE_4_4, so we must define our own type - * for GL_LUMINANCE4_ALPHA4. */ -#define MESA_UNSIGNED_BYTE_4_4 (GL_UNSIGNED_BYTE<<1) - - -/** - * Mesa texture/renderbuffer image formats. - */ -typedef enum -{ - MESA_FORMAT_NONE = 0, - - /** - * \name Basic hardware formats - */ - /*@{*/ - /* msb <------ TEXEL BITS -----------> lsb */ - /* ---- ---- ---- ---- ---- ---- ---- ---- */ - MESA_FORMAT_RGBA8888, /* RRRR RRRR GGGG GGGG BBBB BBBB AAAA AAAA */ - MESA_FORMAT_RGBA8888_REV, /* AAAA AAAA BBBB BBBB GGGG GGGG RRRR RRRR */ - MESA_FORMAT_ARGB8888, /* AAAA AAAA RRRR RRRR GGGG GGGG BBBB BBBB */ - MESA_FORMAT_ARGB8888_REV, /* BBBB BBBB GGGG GGGG RRRR RRRR AAAA AAAA */ - MESA_FORMAT_XRGB8888, /* xxxx xxxx RRRR RRRR GGGG GGGG BBBB BBBB */ - MESA_FORMAT_XRGB8888_REV, /* BBBB BBBB GGGG GGGG RRRR RRRR xxxx xxxx */ - MESA_FORMAT_RGB888, /* RRRR RRRR GGGG GGGG BBBB BBBB */ - MESA_FORMAT_BGR888, /* BBBB BBBB GGGG GGGG RRRR RRRR */ - MESA_FORMAT_RGB565, /* RRRR RGGG GGGB BBBB */ - MESA_FORMAT_RGB565_REV, /* GGGB BBBB RRRR RGGG */ - MESA_FORMAT_ARGB4444, /* AAAA RRRR GGGG BBBB */ - MESA_FORMAT_ARGB4444_REV, /* GGGG BBBB AAAA RRRR */ - MESA_FORMAT_RGBA5551, /* RRRR RGGG GGBB BBBA */ - MESA_FORMAT_ARGB1555, /* ARRR RRGG GGGB BBBB */ - MESA_FORMAT_ARGB1555_REV, /* GGGB BBBB ARRR RRGG */ - MESA_FORMAT_AL44, /* AAAA LLLL */ - MESA_FORMAT_AL88, /* AAAA AAAA LLLL LLLL */ - MESA_FORMAT_AL88_REV, /* LLLL LLLL AAAA AAAA */ - MESA_FORMAT_AL1616, /* AAAA AAAA AAAA AAAA LLLL LLLL LLLL LLLL */ - MESA_FORMAT_AL1616_REV, /* LLLL LLLL LLLL LLLL AAAA AAAA AAAA AAAA */ - MESA_FORMAT_RGB332, /* RRRG GGBB */ - MESA_FORMAT_A8, /* AAAA AAAA */ - MESA_FORMAT_A16, /* AAAA AAAA AAAA AAAA */ - MESA_FORMAT_L8, /* LLLL LLLL */ - MESA_FORMAT_L16, /* LLLL LLLL LLLL LLLL */ - MESA_FORMAT_I8, /* IIII IIII */ - MESA_FORMAT_I16, /* IIII IIII IIII IIII */ - MESA_FORMAT_YCBCR, /* YYYY YYYY UorV UorV */ - MESA_FORMAT_YCBCR_REV, /* UorV UorV YYYY YYYY */ - MESA_FORMAT_R8, /* RRRR RRRR */ - MESA_FORMAT_RG88, /* RRRR RRRR GGGG GGGG */ - MESA_FORMAT_RG88_REV, /* GGGG GGGG RRRR RRRR */ - MESA_FORMAT_R16, /* RRRR RRRR RRRR RRRR */ - MESA_FORMAT_RG1616, /* RRRR RRRR RRRR RRRR GGGG GGGG GGGG GGGG */ - MESA_FORMAT_RG1616_REV, /* GGGG GGGG GGGG GGGG RRRR RRRR RRRR RRRR */ - MESA_FORMAT_ARGB2101010, /* AARR RRRR RRRR GGGG GGGG GGBB BBBB BBBB */ - MESA_FORMAT_Z24_S8, /* ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ SSSS SSSS */ - MESA_FORMAT_S8_Z24, /* SSSS SSSS ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ */ - MESA_FORMAT_Z16, /* ZZZZ ZZZZ ZZZZ ZZZZ */ - MESA_FORMAT_X8_Z24, /* xxxx xxxx ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ */ - MESA_FORMAT_Z24_X8, /* ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ xxxx xxxx */ - MESA_FORMAT_Z32, /* ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ */ - MESA_FORMAT_S8, /* SSSS SSSS */ - /*@}*/ - - /** - * \name 8-bit/channel sRGB formats - */ - /*@{*/ - MESA_FORMAT_SRGB8, - MESA_FORMAT_SRGBA8, - MESA_FORMAT_SARGB8, - MESA_FORMAT_SL8, - MESA_FORMAT_SLA8, - MESA_FORMAT_SRGB_DXT1, - MESA_FORMAT_SRGBA_DXT1, - MESA_FORMAT_SRGBA_DXT3, - MESA_FORMAT_SRGBA_DXT5, - /*@}*/ - - /** - * \name Compressed texture formats. - */ - /*@{*/ - MESA_FORMAT_RGB_FXT1, - MESA_FORMAT_RGBA_FXT1, - MESA_FORMAT_RGB_DXT1, - MESA_FORMAT_RGBA_DXT1, - MESA_FORMAT_RGBA_DXT3, - MESA_FORMAT_RGBA_DXT5, - /*@}*/ - - /** - * \name Floating point texture formats. - */ - /*@{*/ - MESA_FORMAT_RGBA_FLOAT32, - MESA_FORMAT_RGBA_FLOAT16, - MESA_FORMAT_RGB_FLOAT32, - MESA_FORMAT_RGB_FLOAT16, - MESA_FORMAT_ALPHA_FLOAT32, - MESA_FORMAT_ALPHA_FLOAT16, - MESA_FORMAT_LUMINANCE_FLOAT32, - MESA_FORMAT_LUMINANCE_FLOAT16, - MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32, - MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16, - MESA_FORMAT_INTENSITY_FLOAT32, - MESA_FORMAT_INTENSITY_FLOAT16, - MESA_FORMAT_R_FLOAT32, - MESA_FORMAT_R_FLOAT16, - MESA_FORMAT_RG_FLOAT32, - MESA_FORMAT_RG_FLOAT16, - /*@}*/ - - /** - * \name Non-normalized signed integer formats. - * XXX Note: these are just stand-ins for some better hardware - * formats TBD such as BGRA or ARGB. - */ - MESA_FORMAT_RGBA_INT8, - MESA_FORMAT_RGBA_INT16, - MESA_FORMAT_RGBA_INT32, - - /** - * \name Non-normalized unsigned integer formats. - */ - MESA_FORMAT_RGBA_UINT8, - MESA_FORMAT_RGBA_UINT16, - MESA_FORMAT_RGBA_UINT32, - - /* msb <------ TEXEL BITS -----------> lsb */ - /* ---- ---- ---- ---- ---- ---- ---- ---- */ - /** - * \name Signed fixed point texture formats. - */ - /*@{*/ - MESA_FORMAT_DUDV8, /* DUDU DUDU DVDV DVDV */ - MESA_FORMAT_SIGNED_R8, /* RRRR RRRR */ - MESA_FORMAT_SIGNED_RG88_REV, /* GGGG GGGG RRRR RRRR */ - MESA_FORMAT_SIGNED_RGBX8888, /* RRRR RRRR GGGG GGGG BBBB BBBB xxxx xxxx */ - MESA_FORMAT_SIGNED_RGBA8888, /* RRRR RRRR GGGG GGGG BBBB BBBB AAAA AAAA */ - MESA_FORMAT_SIGNED_RGBA8888_REV,/*AAAA AAAA BBBB BBBB GGGG GGGG RRRR RRRR */ - MESA_FORMAT_SIGNED_R16, /* RRRR RRRR RRRR RRRR */ - MESA_FORMAT_SIGNED_GR1616, /* GGGG GGGG GGGG GGGG RRRR RRRR RRRR RRRR */ - MESA_FORMAT_SIGNED_RGB_16, /* ushort[0]=R, ushort[1]=G, ushort[2]=B */ - MESA_FORMAT_SIGNED_RGBA_16, /* ... */ - MESA_FORMAT_RGBA_16, /* ... */ - /*@}*/ - - /*@{*/ - MESA_FORMAT_RED_RGTC1, - MESA_FORMAT_SIGNED_RED_RGTC1, - MESA_FORMAT_RG_RGTC2, - MESA_FORMAT_SIGNED_RG_RGTC2, - /*@}*/ - - /*@{*/ - MESA_FORMAT_L_LATC1, - MESA_FORMAT_SIGNED_L_LATC1, - MESA_FORMAT_LA_LATC2, - MESA_FORMAT_SIGNED_LA_LATC2, - /*@}*/ - - MESA_FORMAT_SIGNED_A8, /* AAAA AAAA */ - MESA_FORMAT_SIGNED_L8, /* LLLL LLLL */ - MESA_FORMAT_SIGNED_AL88, /* AAAA AAAA LLLL LLLL */ - MESA_FORMAT_SIGNED_I8, /* IIII IIII */ - MESA_FORMAT_SIGNED_A16, /* AAAA AAAA AAAA AAAA */ - MESA_FORMAT_SIGNED_L16, /* LLLL LLLL LLLL LLLL */ - MESA_FORMAT_SIGNED_AL1616, /* AAAA AAAA AAAA AAAA LLLL LLLL LLLL LLLL */ - MESA_FORMAT_SIGNED_I16, /* IIII IIII IIII IIII */ - - MESA_FORMAT_RGB9_E5_FLOAT, - MESA_FORMAT_R11_G11_B10_FLOAT, - - MESA_FORMAT_Z32_FLOAT, - MESA_FORMAT_Z32_FLOAT_X24S8, - - MESA_FORMAT_COUNT -} gl_format; - - -extern const char * -_mesa_get_format_name(gl_format format); - -extern GLint -_mesa_get_format_bytes(gl_format format); - -extern GLint -_mesa_get_format_bits(gl_format format, GLenum pname); - -extern GLenum -_mesa_get_format_datatype(gl_format format); - -extern GLenum -_mesa_get_format_base_format(gl_format format); - -extern void -_mesa_get_format_block_size(gl_format format, GLuint *bw, GLuint *bh); - -extern GLboolean -_mesa_is_format_compressed(gl_format format); - -extern GLboolean -_mesa_is_format_packed_depth_stencil(gl_format format); - -extern GLboolean -_mesa_is_format_integer_color(gl_format format); - -extern GLenum -_mesa_get_format_color_encoding(gl_format format); - -extern GLuint -_mesa_format_image_size(gl_format format, GLsizei width, - GLsizei height, GLsizei depth); - -extern uint64_t -_mesa_format_image_size64(gl_format format, GLsizei width, - GLsizei height, GLsizei depth); - -extern GLint -_mesa_format_row_stride(gl_format format, GLsizei width); - -extern void -_mesa_format_to_type_and_comps(gl_format format, - GLenum *datatype, GLuint *comps); - -extern void -_mesa_test_formats(void); - -extern gl_format -_mesa_get_srgb_format_linear(gl_format format); - -extern gl_format -_mesa_get_uncompressed_format(gl_format format); - -extern GLuint -_mesa_format_num_components(gl_format format); - - -#endif /* FORMATS_H */ +/* + * Mesa 3-D graphics library + * Version: 7.7 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (c) 2008-2009 VMware, 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 + * 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. + */ + +/* + * Authors: + * Brian Paul + */ + + +#ifndef FORMATS_H +#define FORMATS_H + + +#include + +/* OpenGL doesn't have GL_UNSIGNED_BYTE_4_4, so we must define our own type + * for GL_LUMINANCE4_ALPHA4. */ +#define MESA_UNSIGNED_BYTE_4_4 (GL_UNSIGNED_BYTE<<1) + + +/** + * Mesa texture/renderbuffer image formats. + */ +typedef enum +{ + MESA_FORMAT_NONE = 0, + + /** + * \name Basic hardware formats + */ + /*@{*/ + /* msb <------ TEXEL BITS -----------> lsb */ + /* ---- ---- ---- ---- ---- ---- ---- ---- */ + MESA_FORMAT_RGBA8888, /* RRRR RRRR GGGG GGGG BBBB BBBB AAAA AAAA */ + MESA_FORMAT_RGBA8888_REV, /* AAAA AAAA BBBB BBBB GGGG GGGG RRRR RRRR */ + MESA_FORMAT_ARGB8888, /* AAAA AAAA RRRR RRRR GGGG GGGG BBBB BBBB */ + MESA_FORMAT_ARGB8888_REV, /* BBBB BBBB GGGG GGGG RRRR RRRR AAAA AAAA */ + MESA_FORMAT_XRGB8888, /* xxxx xxxx RRRR RRRR GGGG GGGG BBBB BBBB */ + MESA_FORMAT_XRGB8888_REV, /* BBBB BBBB GGGG GGGG RRRR RRRR xxxx xxxx */ + MESA_FORMAT_RGB888, /* RRRR RRRR GGGG GGGG BBBB BBBB */ + MESA_FORMAT_BGR888, /* BBBB BBBB GGGG GGGG RRRR RRRR */ + MESA_FORMAT_RGB565, /* RRRR RGGG GGGB BBBB */ + MESA_FORMAT_RGB565_REV, /* GGGB BBBB RRRR RGGG */ + MESA_FORMAT_ARGB4444, /* AAAA RRRR GGGG BBBB */ + MESA_FORMAT_ARGB4444_REV, /* GGGG BBBB AAAA RRRR */ + MESA_FORMAT_RGBA5551, /* RRRR RGGG GGBB BBBA */ + MESA_FORMAT_ARGB1555, /* ARRR RRGG GGGB BBBB */ + MESA_FORMAT_ARGB1555_REV, /* GGGB BBBB ARRR RRGG */ + MESA_FORMAT_AL44, /* AAAA LLLL */ + MESA_FORMAT_AL88, /* AAAA AAAA LLLL LLLL */ + MESA_FORMAT_AL88_REV, /* LLLL LLLL AAAA AAAA */ + MESA_FORMAT_AL1616, /* AAAA AAAA AAAA AAAA LLLL LLLL LLLL LLLL */ + MESA_FORMAT_AL1616_REV, /* LLLL LLLL LLLL LLLL AAAA AAAA AAAA AAAA */ + MESA_FORMAT_RGB332, /* RRRG GGBB */ + MESA_FORMAT_A8, /* AAAA AAAA */ + MESA_FORMAT_A16, /* AAAA AAAA AAAA AAAA */ + MESA_FORMAT_L8, /* LLLL LLLL */ + MESA_FORMAT_L16, /* LLLL LLLL LLLL LLLL */ + MESA_FORMAT_I8, /* IIII IIII */ + MESA_FORMAT_I16, /* IIII IIII IIII IIII */ + MESA_FORMAT_YCBCR, /* YYYY YYYY UorV UorV */ + MESA_FORMAT_YCBCR_REV, /* UorV UorV YYYY YYYY */ + MESA_FORMAT_R8, /* RRRR RRRR */ + MESA_FORMAT_RG88, /* RRRR RRRR GGGG GGGG */ + MESA_FORMAT_RG88_REV, /* GGGG GGGG RRRR RRRR */ + MESA_FORMAT_R16, /* RRRR RRRR RRRR RRRR */ + MESA_FORMAT_RG1616, /* RRRR RRRR RRRR RRRR GGGG GGGG GGGG GGGG */ + MESA_FORMAT_RG1616_REV, /* GGGG GGGG GGGG GGGG RRRR RRRR RRRR RRRR */ + MESA_FORMAT_ARGB2101010, /* AARR RRRR RRRR GGGG GGGG GGBB BBBB BBBB */ + MESA_FORMAT_Z24_S8, /* ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ SSSS SSSS */ + MESA_FORMAT_S8_Z24, /* SSSS SSSS ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ */ + MESA_FORMAT_Z16, /* ZZZZ ZZZZ ZZZZ ZZZZ */ + MESA_FORMAT_X8_Z24, /* xxxx xxxx ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ */ + MESA_FORMAT_Z24_X8, /* ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ xxxx xxxx */ + MESA_FORMAT_Z32, /* ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ */ + MESA_FORMAT_S8, /* SSSS SSSS */ + /*@}*/ + + /** + * \name 8-bit/channel sRGB formats + */ + /*@{*/ + MESA_FORMAT_SRGB8, + MESA_FORMAT_SRGBA8, + MESA_FORMAT_SARGB8, + MESA_FORMAT_SL8, + MESA_FORMAT_SLA8, + MESA_FORMAT_SRGB_DXT1, + MESA_FORMAT_SRGBA_DXT1, + MESA_FORMAT_SRGBA_DXT3, + MESA_FORMAT_SRGBA_DXT5, + /*@}*/ + + /** + * \name Compressed texture formats. + */ + /*@{*/ + MESA_FORMAT_RGB_FXT1, + MESA_FORMAT_RGBA_FXT1, + MESA_FORMAT_RGB_DXT1, + MESA_FORMAT_RGBA_DXT1, + MESA_FORMAT_RGBA_DXT3, + MESA_FORMAT_RGBA_DXT5, + /*@}*/ + + /** + * \name Floating point texture formats. + */ + /*@{*/ + MESA_FORMAT_RGBA_FLOAT32, + MESA_FORMAT_RGBA_FLOAT16, + MESA_FORMAT_RGB_FLOAT32, + MESA_FORMAT_RGB_FLOAT16, + MESA_FORMAT_ALPHA_FLOAT32, + MESA_FORMAT_ALPHA_FLOAT16, + MESA_FORMAT_LUMINANCE_FLOAT32, + MESA_FORMAT_LUMINANCE_FLOAT16, + MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32, + MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16, + MESA_FORMAT_INTENSITY_FLOAT32, + MESA_FORMAT_INTENSITY_FLOAT16, + MESA_FORMAT_R_FLOAT32, + MESA_FORMAT_R_FLOAT16, + MESA_FORMAT_RG_FLOAT32, + MESA_FORMAT_RG_FLOAT16, + /*@}*/ + + /** + * \name Non-normalized signed integer formats. + * XXX Note: these are just stand-ins for some better hardware + * formats TBD such as BGRA or ARGB. + */ + MESA_FORMAT_RGBA_INT8, + MESA_FORMAT_RGBA_INT16, + MESA_FORMAT_RGBA_INT32, + + /** + * \name Non-normalized unsigned integer formats. + */ + MESA_FORMAT_RGBA_UINT8, + MESA_FORMAT_RGBA_UINT16, + MESA_FORMAT_RGBA_UINT32, + + /* msb <------ TEXEL BITS -----------> lsb */ + /* ---- ---- ---- ---- ---- ---- ---- ---- */ + /** + * \name Signed fixed point texture formats. + */ + /*@{*/ + MESA_FORMAT_DUDV8, /* DUDU DUDU DVDV DVDV */ + MESA_FORMAT_SIGNED_R8, /* RRRR RRRR */ + MESA_FORMAT_SIGNED_RG88_REV, /* GGGG GGGG RRRR RRRR */ + MESA_FORMAT_SIGNED_RGBX8888, /* RRRR RRRR GGGG GGGG BBBB BBBB xxxx xxxx */ + MESA_FORMAT_SIGNED_RGBA8888, /* RRRR RRRR GGGG GGGG BBBB BBBB AAAA AAAA */ + MESA_FORMAT_SIGNED_RGBA8888_REV,/*AAAA AAAA BBBB BBBB GGGG GGGG RRRR RRRR */ + MESA_FORMAT_SIGNED_R16, /* RRRR RRRR RRRR RRRR */ + MESA_FORMAT_SIGNED_GR1616, /* GGGG GGGG GGGG GGGG RRRR RRRR RRRR RRRR */ + MESA_FORMAT_SIGNED_RGB_16, /* ushort[0]=R, ushort[1]=G, ushort[2]=B */ + MESA_FORMAT_SIGNED_RGBA_16, /* ... */ + MESA_FORMAT_RGBA_16, /* ... */ + /*@}*/ + + /*@{*/ + MESA_FORMAT_RED_RGTC1, + MESA_FORMAT_SIGNED_RED_RGTC1, + MESA_FORMAT_RG_RGTC2, + MESA_FORMAT_SIGNED_RG_RGTC2, + /*@}*/ + + /*@{*/ + MESA_FORMAT_L_LATC1, + MESA_FORMAT_SIGNED_L_LATC1, + MESA_FORMAT_LA_LATC2, + MESA_FORMAT_SIGNED_LA_LATC2, + /*@}*/ + + MESA_FORMAT_SIGNED_A8, /* AAAA AAAA */ + MESA_FORMAT_SIGNED_L8, /* LLLL LLLL */ + MESA_FORMAT_SIGNED_AL88, /* AAAA AAAA LLLL LLLL */ + MESA_FORMAT_SIGNED_I8, /* IIII IIII */ + MESA_FORMAT_SIGNED_A16, /* AAAA AAAA AAAA AAAA */ + MESA_FORMAT_SIGNED_L16, /* LLLL LLLL LLLL LLLL */ + MESA_FORMAT_SIGNED_AL1616, /* AAAA AAAA AAAA AAAA LLLL LLLL LLLL LLLL */ + MESA_FORMAT_SIGNED_I16, /* IIII IIII IIII IIII */ + + MESA_FORMAT_RGB9_E5_FLOAT, + MESA_FORMAT_R11_G11_B10_FLOAT, + + MESA_FORMAT_Z32_FLOAT, + MESA_FORMAT_Z32_FLOAT_X24S8, + + MESA_FORMAT_COUNT +} gl_format; + + +extern const char * +_mesa_get_format_name(gl_format format); + +extern GLint +_mesa_get_format_bytes(gl_format format); + +extern GLint +_mesa_get_format_bits(gl_format format, GLenum pname); + +extern GLenum +_mesa_get_format_datatype(gl_format format); + +extern GLenum +_mesa_get_format_base_format(gl_format format); + +extern void +_mesa_get_format_block_size(gl_format format, GLuint *bw, GLuint *bh); + +extern GLboolean +_mesa_is_format_compressed(gl_format format); + +extern GLboolean +_mesa_is_format_packed_depth_stencil(gl_format format); + +extern GLboolean +_mesa_is_format_integer_color(gl_format format); + +extern GLenum +_mesa_get_format_color_encoding(gl_format format); + +extern GLuint +_mesa_format_image_size(gl_format format, GLsizei width, + GLsizei height, GLsizei depth); + +extern uint64_t +_mesa_format_image_size64(gl_format format, GLsizei width, + GLsizei height, GLsizei depth); + +extern GLint +_mesa_format_row_stride(gl_format format, GLsizei width); + +extern void +_mesa_format_to_type_and_comps(gl_format format, + GLenum *datatype, GLuint *comps); + +extern void +_mesa_test_formats(void); + +extern gl_format +_mesa_get_srgb_format_linear(gl_format format); + +extern gl_format +_mesa_get_uncompressed_format(gl_format format); + +extern GLuint +_mesa_format_num_components(gl_format format); + + +#endif /* FORMATS_H */ diff --git a/mesalib/src/mesa/main/framebuffer.c b/mesalib/src/mesa/main/framebuffer.c index 6c8608a09..42da17678 100644 --- a/mesalib/src/mesa/main/framebuffer.c +++ b/mesalib/src/mesa/main/framebuffer.c @@ -1,1098 +1,1098 @@ -/* - * Mesa 3-D graphics library - * Version: 7.2 - * - * 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. - */ - - -/** - * Functions for allocating/managing framebuffers and renderbuffers. - * Also, routines for reading/writing renderbuffer data as ubytes, - * ushorts, uints, etc. - */ - - -#include "glheader.h" -#include "imports.h" -#include "buffers.h" -#include "context.h" -#include "depthstencil.h" -#include "enums.h" -#include "formats.h" -#include "macros.h" -#include "mtypes.h" -#include "fbobject.h" -#include "framebuffer.h" -#include "renderbuffer.h" -#include "texobj.h" - - - -/** - * Compute/set the _DepthMax field for the given framebuffer. - * This value depends on the Z buffer resolution. - */ -static void -compute_depth_max(struct gl_framebuffer *fb) -{ - if (fb->Visual.depthBits == 0) { - /* Special case. Even if we don't have a depth buffer we need - * good values for DepthMax for Z vertex transformation purposes - * and for per-fragment fog computation. - */ - fb->_DepthMax = (1 << 16) - 1; - } - else if (fb->Visual.depthBits < 32) { - fb->_DepthMax = (1 << fb->Visual.depthBits) - 1; - } - else { - /* Special case since shift values greater than or equal to the - * number of bits in the left hand expression's type are undefined. - */ - fb->_DepthMax = 0xffffffff; - } - fb->_DepthMaxF = (GLfloat) fb->_DepthMax; - - /* Minimum resolvable depth value, for polygon offset */ - fb->_MRD = (GLfloat)1.0 / fb->_DepthMaxF; -} - -/** - * Create and initialize a gl_framebuffer object. - * This is intended for creating _window_system_ framebuffers, not generic - * framebuffer objects ala GL_EXT_framebuffer_object. - * - * \sa _mesa_new_framebuffer - */ -struct gl_framebuffer * -_mesa_create_framebuffer(const struct gl_config *visual) -{ - struct gl_framebuffer *fb = CALLOC_STRUCT(gl_framebuffer); - assert(visual); - if (fb) { - _mesa_initialize_window_framebuffer(fb, visual); - } - return fb; -} - - -/** - * Allocate a new gl_framebuffer object. - * This is the default function for ctx->Driver.NewFramebuffer(). - * This is for allocating user-created framebuffers, not window-system - * framebuffers! - * \sa _mesa_create_framebuffer - */ -struct gl_framebuffer * -_mesa_new_framebuffer(struct gl_context *ctx, GLuint name) -{ - struct gl_framebuffer *fb; - (void) ctx; - assert(name != 0); - fb = CALLOC_STRUCT(gl_framebuffer); - if (fb) { - _mesa_initialize_user_framebuffer(fb, name); - } - return fb; -} - - -/** - * Initialize a gl_framebuffer object. Typically used to initialize - * window system-created framebuffers, not user-created framebuffers. - * \sa _mesa_initialize_user_framebuffer - */ -void -_mesa_initialize_window_framebuffer(struct gl_framebuffer *fb, - const struct gl_config *visual) -{ - assert(fb); - assert(visual); - - memset(fb, 0, sizeof(struct gl_framebuffer)); - - _glthread_INIT_MUTEX(fb->Mutex); - - fb->RefCount = 1; - - /* save the visual */ - fb->Visual = *visual; - - /* Init read/draw renderbuffer state */ - if (visual->doubleBufferMode) { - fb->_NumColorDrawBuffers = 1; - fb->ColorDrawBuffer[0] = GL_BACK; - fb->_ColorDrawBufferIndexes[0] = BUFFER_BACK_LEFT; - fb->ColorReadBuffer = GL_BACK; - fb->_ColorReadBufferIndex = BUFFER_BACK_LEFT; - } - else { - fb->_NumColorDrawBuffers = 1; - fb->ColorDrawBuffer[0] = GL_FRONT; - fb->_ColorDrawBufferIndexes[0] = BUFFER_FRONT_LEFT; - fb->ColorReadBuffer = GL_FRONT; - fb->_ColorReadBufferIndex = BUFFER_FRONT_LEFT; - } - - fb->Delete = _mesa_destroy_framebuffer; - fb->_Status = GL_FRAMEBUFFER_COMPLETE_EXT; - - compute_depth_max(fb); -} - - -/** - * Initialize a user-created gl_framebuffer object. - * \sa _mesa_initialize_window_framebuffer - */ -void -_mesa_initialize_user_framebuffer(struct gl_framebuffer *fb, GLuint name) -{ - assert(fb); - assert(name); - - memset(fb, 0, sizeof(struct gl_framebuffer)); - - fb->Name = name; - fb->RefCount = 1; - fb->_NumColorDrawBuffers = 1; - fb->ColorDrawBuffer[0] = GL_COLOR_ATTACHMENT0_EXT; - fb->_ColorDrawBufferIndexes[0] = BUFFER_COLOR0; - fb->ColorReadBuffer = GL_COLOR_ATTACHMENT0_EXT; - fb->_ColorReadBufferIndex = BUFFER_COLOR0; - fb->Delete = _mesa_destroy_framebuffer; - _glthread_INIT_MUTEX(fb->Mutex); -} - - -/** - * Deallocate buffer and everything attached to it. - * Typically called via the gl_framebuffer->Delete() method. - */ -void -_mesa_destroy_framebuffer(struct gl_framebuffer *fb) -{ - if (fb) { - _mesa_free_framebuffer_data(fb); - free(fb); - } -} - - -/** - * Free all the data hanging off the given gl_framebuffer, but don't free - * the gl_framebuffer object itself. - */ -void -_mesa_free_framebuffer_data(struct gl_framebuffer *fb) -{ - GLuint i; - - assert(fb); - assert(fb->RefCount == 0); - - _glthread_DESTROY_MUTEX(fb->Mutex); - - for (i = 0; i < BUFFER_COUNT; i++) { - struct gl_renderbuffer_attachment *att = &fb->Attachment[i]; - if (att->Renderbuffer) { - _mesa_reference_renderbuffer(&att->Renderbuffer, NULL); - } - if (att->Texture) { - _mesa_reference_texobj(&att->Texture, NULL); - } - ASSERT(!att->Renderbuffer); - ASSERT(!att->Texture); - att->Type = GL_NONE; - } - - /* unbind _Depth/_StencilBuffer to decr ref counts */ - _mesa_reference_renderbuffer(&fb->_DepthBuffer, NULL); - _mesa_reference_renderbuffer(&fb->_StencilBuffer, NULL); -} - - -/** - * Set *ptr to point to fb, with refcounting and locking. - * This is normally only called from the _mesa_reference_framebuffer() macro - * when there's a real pointer change. - */ -void -_mesa_reference_framebuffer_(struct gl_framebuffer **ptr, - struct gl_framebuffer *fb) -{ - if (*ptr) { - /* unreference old renderbuffer */ - GLboolean deleteFlag = GL_FALSE; - struct gl_framebuffer *oldFb = *ptr; - - _glthread_LOCK_MUTEX(oldFb->Mutex); - ASSERT(oldFb->RefCount > 0); - oldFb->RefCount--; - deleteFlag = (oldFb->RefCount == 0); - _glthread_UNLOCK_MUTEX(oldFb->Mutex); - - if (deleteFlag) - oldFb->Delete(oldFb); - - *ptr = NULL; - } - assert(!*ptr); - - if (fb) { - _glthread_LOCK_MUTEX(fb->Mutex); - fb->RefCount++; - _glthread_UNLOCK_MUTEX(fb->Mutex); - *ptr = fb; - } -} - - -/** - * Resize the given framebuffer's renderbuffers to the new width and height. - * This should only be used for window-system framebuffers, not - * user-created renderbuffers (i.e. made with GL_EXT_framebuffer_object). - * This will typically be called via ctx->Driver.ResizeBuffers() or directly - * from a device driver. - * - * \note it's possible for ctx to be null since a window can be resized - * without a currently bound rendering context. - */ -void -_mesa_resize_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb, - GLuint width, GLuint height) -{ - GLuint i; - - /* XXX I think we could check if the size is not changing - * and return early. - */ - - /* For window system framebuffers, Name is zero */ - assert(fb->Name == 0); - - for (i = 0; i < BUFFER_COUNT; i++) { - struct gl_renderbuffer_attachment *att = &fb->Attachment[i]; - if (att->Type == GL_RENDERBUFFER_EXT && att->Renderbuffer) { - struct gl_renderbuffer *rb = att->Renderbuffer; - /* only resize if size is changing */ - if (rb->Width != width || rb->Height != height) { - if (rb->AllocStorage(ctx, rb, rb->InternalFormat, width, height)) { - ASSERT(rb->Width == width); - ASSERT(rb->Height == height); - } - else { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "Resizing framebuffer"); - /* no return */ - } - } - } - } - - if (fb->_DepthBuffer) { - struct gl_renderbuffer *rb = fb->_DepthBuffer; - if (rb->Width != width || rb->Height != height) { - if (!rb->AllocStorage(ctx, rb, rb->InternalFormat, width, height)) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "Resizing framebuffer"); - } - } - } - - if (fb->_StencilBuffer) { - struct gl_renderbuffer *rb = fb->_StencilBuffer; - if (rb->Width != width || rb->Height != height) { - if (!rb->AllocStorage(ctx, rb, rb->InternalFormat, width, height)) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "Resizing framebuffer"); - } - } - } - - fb->Width = width; - fb->Height = height; - - if (ctx) { - /* update scissor / window bounds */ - _mesa_update_draw_buffer_bounds(ctx); - /* Signal new buffer state so that swrast will update its clipping - * info (the CLIP_BIT flag). - */ - ctx->NewState |= _NEW_BUFFERS; - } -} - - - -/** - * XXX THIS IS OBSOLETE - drivers should take care of detecting window - * size changes and act accordingly, likely calling _mesa_resize_framebuffer(). - * - * GL_MESA_resize_buffers extension. - * - * When this function is called, we'll ask the window system how large - * the current window is. If it's a new size, we'll call the driver's - * ResizeBuffers function. The driver will then resize its color buffers - * as needed, and maybe call the swrast's routine for reallocating - * swrast-managed depth/stencil/accum/etc buffers. - * \note This function should only be called through the GL API, not - * from device drivers (as was done in the past). - */ -void -_mesa_resizebuffers( struct gl_context *ctx ) -{ - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH( ctx ); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glResizeBuffersMESA\n"); - - if (!ctx->Driver.GetBufferSize) { - return; - } - - if (ctx->WinSysDrawBuffer) { - GLuint newWidth, newHeight; - struct gl_framebuffer *buffer = ctx->WinSysDrawBuffer; - - assert(buffer->Name == 0); - - /* ask device driver for size of output buffer */ - ctx->Driver.GetBufferSize( buffer, &newWidth, &newHeight ); - - /* see if size of device driver's color buffer (window) has changed */ - if (buffer->Width != newWidth || buffer->Height != newHeight) { - if (ctx->Driver.ResizeBuffers) - ctx->Driver.ResizeBuffers(ctx, buffer, newWidth, newHeight ); - } - } - - if (ctx->WinSysReadBuffer - && ctx->WinSysReadBuffer != ctx->WinSysDrawBuffer) { - GLuint newWidth, newHeight; - struct gl_framebuffer *buffer = ctx->WinSysReadBuffer; - - assert(buffer->Name == 0); - - /* ask device driver for size of read buffer */ - ctx->Driver.GetBufferSize( buffer, &newWidth, &newHeight ); - - /* see if size of device driver's color buffer (window) has changed */ - if (buffer->Width != newWidth || buffer->Height != newHeight) { - if (ctx->Driver.ResizeBuffers) - ctx->Driver.ResizeBuffers(ctx, buffer, newWidth, newHeight ); - } - } - - ctx->NewState |= _NEW_BUFFERS; /* to update scissor / window bounds */ -} - - -/* - * XXX THIS IS OBSOLETE - */ -void GLAPIENTRY -_mesa_ResizeBuffersMESA( void ) -{ - GET_CURRENT_CONTEXT(ctx); - - if (ctx->Extensions.MESA_resize_buffers) - _mesa_resizebuffers( ctx ); -} - - - -/** - * Examine all the framebuffer's renderbuffers to update the Width/Height - * fields of the framebuffer. If we have renderbuffers with different - * sizes, set the framebuffer's width and height to the min size. - * Note: this is only intended for user-created framebuffers, not - * window-system framebuffes. - */ -static void -update_framebuffer_size(struct gl_context *ctx, struct gl_framebuffer *fb) -{ - GLuint minWidth = ~0, minHeight = ~0; - GLuint i; - - /* user-created framebuffers only */ - assert(fb->Name); - - for (i = 0; i < BUFFER_COUNT; i++) { - struct gl_renderbuffer_attachment *att = &fb->Attachment[i]; - const struct gl_renderbuffer *rb = att->Renderbuffer; - if (rb) { - minWidth = MIN2(minWidth, rb->Width); - minHeight = MIN2(minHeight, rb->Height); - } - } - - if (minWidth != ~0) { - fb->Width = minWidth; - fb->Height = minHeight; - } - else { - fb->Width = 0; - fb->Height = 0; - } -} - - -/** - * Update the context's current drawing buffer's Xmin, Xmax, Ymin, Ymax fields. - * These values are computed from the buffer's width and height and - * the scissor box, if it's enabled. - * \param ctx the GL context. - */ -void -_mesa_update_draw_buffer_bounds(struct gl_context *ctx) -{ - struct gl_framebuffer *buffer = ctx->DrawBuffer; - - if (!buffer) - return; - - if (buffer->Name) { - /* user-created framebuffer size depends on the renderbuffers */ - update_framebuffer_size(ctx, buffer); - } - - buffer->_Xmin = 0; - buffer->_Ymin = 0; - buffer->_Xmax = buffer->Width; - buffer->_Ymax = buffer->Height; - - if (ctx->Scissor.Enabled) { - if (ctx->Scissor.X > buffer->_Xmin) { - buffer->_Xmin = ctx->Scissor.X; - } - if (ctx->Scissor.Y > buffer->_Ymin) { - buffer->_Ymin = ctx->Scissor.Y; - } - if (ctx->Scissor.X + ctx->Scissor.Width < buffer->_Xmax) { - buffer->_Xmax = ctx->Scissor.X + ctx->Scissor.Width; - } - if (ctx->Scissor.Y + ctx->Scissor.Height < buffer->_Ymax) { - buffer->_Ymax = ctx->Scissor.Y + ctx->Scissor.Height; - } - /* finally, check for empty region */ - if (buffer->_Xmin > buffer->_Xmax) { - buffer->_Xmin = buffer->_Xmax; - } - if (buffer->_Ymin > buffer->_Ymax) { - buffer->_Ymin = buffer->_Ymax; - } - } - - ASSERT(buffer->_Xmin <= buffer->_Xmax); - ASSERT(buffer->_Ymin <= buffer->_Ymax); -} - - -/** - * The glGet queries of the framebuffer red/green/blue size, stencil size, - * etc. are satisfied by the fields of ctx->DrawBuffer->Visual. These can - * change depending on the renderbuffer bindings. This function updates - * the given framebuffer's Visual from the current renderbuffer bindings. - * - * This may apply to user-created framebuffers or window system framebuffers. - * - * Also note: ctx->DrawBuffer->Visual.depthBits might not equal - * ctx->DrawBuffer->Attachment[BUFFER_DEPTH].Renderbuffer.DepthBits. - * The former one is used to convert floating point depth values into - * integer Z values. - */ -void -_mesa_update_framebuffer_visual(struct gl_context *ctx, - struct gl_framebuffer *fb) -{ - GLuint i; - - memset(&fb->Visual, 0, sizeof(fb->Visual)); - fb->Visual.rgbMode = GL_TRUE; /* assume this */ - -#if 0 /* this _might_ be needed */ - if (fb->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) { - /* leave visual fields zero'd */ - return; - } -#endif - - /* find first RGB renderbuffer */ - for (i = 0; i < BUFFER_COUNT; i++) { - if (fb->Attachment[i].Renderbuffer) { - const struct gl_renderbuffer *rb = fb->Attachment[i].Renderbuffer; - const GLenum baseFormat = _mesa_get_format_base_format(rb->Format); - const gl_format fmt = rb->Format; - - if (_mesa_is_legal_color_format(ctx, baseFormat)) { - fb->Visual.redBits = _mesa_get_format_bits(fmt, GL_RED_BITS); - fb->Visual.greenBits = _mesa_get_format_bits(fmt, GL_GREEN_BITS); - fb->Visual.blueBits = _mesa_get_format_bits(fmt, GL_BLUE_BITS); - fb->Visual.alphaBits = _mesa_get_format_bits(fmt, GL_ALPHA_BITS); - fb->Visual.rgbBits = fb->Visual.redBits - + fb->Visual.greenBits + fb->Visual.blueBits; - fb->Visual.samples = rb->NumSamples; - fb->Visual.sampleBuffers = rb->NumSamples > 0 ? 1 : 0; - if (_mesa_get_format_color_encoding(fmt) == GL_SRGB) - fb->Visual.sRGBCapable = ctx->Const.sRGBCapable; - break; - } - } - } - - fb->Visual.floatMode = GL_FALSE; - for (i = 0; i < BUFFER_COUNT; i++) { - if (fb->Attachment[i].Renderbuffer) { - const struct gl_renderbuffer *rb = fb->Attachment[i].Renderbuffer; - const gl_format fmt = rb->Format; - - if (_mesa_get_format_datatype(fmt) == GL_FLOAT) { - fb->Visual.floatMode = GL_TRUE; - break; - } - } - } - - if (fb->Attachment[BUFFER_DEPTH].Renderbuffer) { - const struct gl_renderbuffer *rb = - fb->Attachment[BUFFER_DEPTH].Renderbuffer; - const gl_format fmt = rb->Format; - fb->Visual.haveDepthBuffer = GL_TRUE; - fb->Visual.depthBits = _mesa_get_format_bits(fmt, GL_DEPTH_BITS); - } - - if (fb->Attachment[BUFFER_STENCIL].Renderbuffer) { - const struct gl_renderbuffer *rb = - fb->Attachment[BUFFER_STENCIL].Renderbuffer; - const gl_format fmt = rb->Format; - fb->Visual.haveStencilBuffer = GL_TRUE; - fb->Visual.stencilBits = _mesa_get_format_bits(fmt, GL_STENCIL_BITS); - } - - if (fb->Attachment[BUFFER_ACCUM].Renderbuffer) { - const struct gl_renderbuffer *rb = - fb->Attachment[BUFFER_ACCUM].Renderbuffer; - const gl_format fmt = rb->Format; - fb->Visual.haveAccumBuffer = GL_TRUE; - fb->Visual.accumRedBits = _mesa_get_format_bits(fmt, GL_RED_BITS); - fb->Visual.accumGreenBits = _mesa_get_format_bits(fmt, GL_GREEN_BITS); - fb->Visual.accumBlueBits = _mesa_get_format_bits(fmt, GL_BLUE_BITS); - fb->Visual.accumAlphaBits = _mesa_get_format_bits(fmt, GL_ALPHA_BITS); - } - - compute_depth_max(fb); -} - - -/** - * Update the framebuffer's _DepthBuffer field using the renderbuffer - * found at the given attachment index. - * - * If that attachment points to a combined GL_DEPTH_STENCIL renderbuffer, - * create and install a depth wrapper/adaptor. - * - * \param fb the framebuffer whose _DepthBuffer field to update - * \param attIndex indicates the renderbuffer to possibly wrap - */ -void -_mesa_update_depth_buffer(struct gl_context *ctx, - struct gl_framebuffer *fb, - GLuint attIndex) -{ - struct gl_renderbuffer *depthRb; - - /* only one possiblity for now */ - ASSERT(attIndex == BUFFER_DEPTH); - - depthRb = fb->Attachment[attIndex].Renderbuffer; - - if (depthRb && _mesa_is_format_packed_depth_stencil(depthRb->Format)) { - /* The attached depth buffer is a GL_DEPTH_STENCIL renderbuffer */ - if (!fb->_DepthBuffer - || fb->_DepthBuffer->Wrapped != depthRb - || _mesa_get_format_base_format(fb->_DepthBuffer->Format) != GL_DEPTH_COMPONENT) { - /* need to update wrapper */ - struct gl_renderbuffer *wrapper; - - if (depthRb->Format == MESA_FORMAT_Z32_FLOAT_X24S8) { - wrapper = _mesa_new_z32f_renderbuffer_wrapper(ctx, depthRb); - } - else { - wrapper = _mesa_new_z24_renderbuffer_wrapper(ctx, depthRb); - } - _mesa_reference_renderbuffer(&fb->_DepthBuffer, wrapper); - ASSERT(fb->_DepthBuffer->Wrapped == depthRb); - } - } - else { - /* depthRb may be null */ - _mesa_reference_renderbuffer(&fb->_DepthBuffer, depthRb); - } -} - - -/** - * Update the framebuffer's _StencilBuffer field using the renderbuffer - * found at the given attachment index. - * - * If that attachment points to a combined GL_DEPTH_STENCIL renderbuffer, - * create and install a stencil wrapper/adaptor. - * - * \param fb the framebuffer whose _StencilBuffer field to update - * \param attIndex indicates the renderbuffer to possibly wrap - */ -void -_mesa_update_stencil_buffer(struct gl_context *ctx, - struct gl_framebuffer *fb, - GLuint attIndex) -{ - struct gl_renderbuffer *stencilRb; - - ASSERT(attIndex == BUFFER_DEPTH || - attIndex == BUFFER_STENCIL); - - stencilRb = fb->Attachment[attIndex].Renderbuffer; - - if (stencilRb && _mesa_is_format_packed_depth_stencil(stencilRb->Format)) { - /* The attached stencil buffer is a GL_DEPTH_STENCIL renderbuffer */ - if (!fb->_StencilBuffer - || fb->_StencilBuffer->Wrapped != stencilRb - || _mesa_get_format_base_format(fb->_StencilBuffer->Format) != GL_STENCIL_INDEX) { - /* need to update wrapper */ - struct gl_renderbuffer *wrapper - = _mesa_new_s8_renderbuffer_wrapper(ctx, stencilRb); - _mesa_reference_renderbuffer(&fb->_StencilBuffer, wrapper); - ASSERT(fb->_StencilBuffer->Wrapped == stencilRb); - } - } - else { - /* stencilRb may be null */ - _mesa_reference_renderbuffer(&fb->_StencilBuffer, stencilRb); - } -} - - -/* - * Example DrawBuffers scenarios: - * - * 1. glDrawBuffer(GL_FRONT_AND_BACK), fixed-func or shader writes to - * "gl_FragColor" or program writes to the "result.color" register: - * - * fragment color output renderbuffer - * --------------------- --------------- - * color[0] Front, Back - * - * - * 2. glDrawBuffers(3, [GL_FRONT, GL_AUX0, GL_AUX1]), shader writes to - * gl_FragData[i] or program writes to result.color[i] registers: - * - * fragment color output renderbuffer - * --------------------- --------------- - * color[0] Front - * color[1] Aux0 - * color[3] Aux1 - * - * - * 3. glDrawBuffers(3, [GL_FRONT, GL_AUX0, GL_AUX1]) and shader writes to - * gl_FragColor, or fixed function: - * - * fragment color output renderbuffer - * --------------------- --------------- - * color[0] Front, Aux0, Aux1 - * - * - * In either case, the list of renderbuffers is stored in the - * framebuffer->_ColorDrawBuffers[] array and - * framebuffer->_NumColorDrawBuffers indicates the number of buffers. - * The renderer (like swrast) has to look at the current fragment shader - * to see if it writes to gl_FragColor vs. gl_FragData[i] to determine - * how to map color outputs to renderbuffers. - * - * Note that these two calls are equivalent (for fixed function fragment - * shading anyway): - * a) glDrawBuffer(GL_FRONT_AND_BACK); (assuming non-stereo framebuffer) - * b) glDrawBuffers(2, [GL_FRONT_LEFT, GL_BACK_LEFT]); - */ - - - - -/** - * Update the (derived) list of color drawing renderbuffer pointers. - * Later, when we're rendering we'll loop from 0 to _NumColorDrawBuffers - * writing colors. - */ -static void -update_color_draw_buffers(struct gl_context *ctx, struct gl_framebuffer *fb) -{ - GLuint output; - - /* set 0th buffer to NULL now in case _NumColorDrawBuffers is zero */ - fb->_ColorDrawBuffers[0] = NULL; - - for (output = 0; output < fb->_NumColorDrawBuffers; output++) { - GLint buf = fb->_ColorDrawBufferIndexes[output]; - if (buf >= 0) { - fb->_ColorDrawBuffers[output] = fb->Attachment[buf].Renderbuffer; - } - else { - fb->_ColorDrawBuffers[output] = NULL; - } - } -} - - -/** - * Update the (derived) color read renderbuffer pointer. - * Unlike the DrawBuffer, we can only read from one (or zero) color buffers. - */ -static void -update_color_read_buffer(struct gl_context *ctx, struct gl_framebuffer *fb) -{ - (void) ctx; - if (fb->_ColorReadBufferIndex == -1 || - fb->DeletePending || - fb->Width == 0 || - fb->Height == 0) { - fb->_ColorReadBuffer = NULL; /* legal! */ - } - else { - ASSERT(fb->_ColorReadBufferIndex >= 0); - ASSERT(fb->_ColorReadBufferIndex < BUFFER_COUNT); - fb->_ColorReadBuffer - = fb->Attachment[fb->_ColorReadBufferIndex].Renderbuffer; - } -} - - -/** - * Update a gl_framebuffer's derived state. - * - * Specifically, update these framebuffer fields: - * _ColorDrawBuffers - * _NumColorDrawBuffers - * _ColorReadBuffer - * _DepthBuffer - * _StencilBuffer - * - * If the framebuffer is user-created, make sure it's complete. - * - * The following functions (at least) can effect framebuffer state: - * glReadBuffer, glDrawBuffer, glDrawBuffersARB, glFramebufferRenderbufferEXT, - * glRenderbufferStorageEXT. - */ -static void -update_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb) -{ - if (fb->Name == 0) { - /* This is a window-system framebuffer */ - /* Need to update the FB's GL_DRAW_BUFFER state to match the - * context state (GL_READ_BUFFER too). - */ - if (fb->ColorDrawBuffer[0] != ctx->Color.DrawBuffer[0]) { - _mesa_drawbuffers(ctx, ctx->Const.MaxDrawBuffers, - ctx->Color.DrawBuffer, NULL); - } - } - else { - /* This is a user-created framebuffer. - * Completeness only matters for user-created framebuffers. - */ - if (fb->_Status != GL_FRAMEBUFFER_COMPLETE) { - _mesa_test_framebuffer_completeness(ctx, fb); - } - } - - /* Strictly speaking, we don't need to update the draw-state - * if this FB is bound as ctx->ReadBuffer (and conversely, the - * read-state if this FB is bound as ctx->DrawBuffer), but no - * harm. - */ - update_color_draw_buffers(ctx, fb); - update_color_read_buffer(ctx, fb); - _mesa_update_depth_buffer(ctx, fb, BUFFER_DEPTH); - _mesa_update_stencil_buffer(ctx, fb, BUFFER_STENCIL); - - compute_depth_max(fb); -} - - -/** - * Update state related to the current draw/read framebuffers. - */ -void -_mesa_update_framebuffer(struct gl_context *ctx) -{ - struct gl_framebuffer *drawFb; - struct gl_framebuffer *readFb; - - assert(ctx); - drawFb = ctx->DrawBuffer; - readFb = ctx->ReadBuffer; - - update_framebuffer(ctx, drawFb); - if (readFb != drawFb) - update_framebuffer(ctx, readFb); -} - - -/** - * Check if the renderbuffer for a read operation (glReadPixels, glCopyPixels, - * glCopyTex[Sub]Image, etc) exists. - * \param format a basic image format such as GL_RGB, GL_RGBA, GL_ALPHA, - * GL_DEPTH_COMPONENT, etc. or GL_COLOR, GL_DEPTH, GL_STENCIL. - * \return GL_TRUE if buffer exists, GL_FALSE otherwise - */ -GLboolean -_mesa_source_buffer_exists(struct gl_context *ctx, GLenum format) -{ - const struct gl_renderbuffer_attachment *att = ctx->ReadBuffer->Attachment; - - /* If we don't know the framebuffer status, update it now */ - if (ctx->ReadBuffer->_Status == 0) { - _mesa_test_framebuffer_completeness(ctx, ctx->ReadBuffer); - } - - if (ctx->ReadBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) { - return GL_FALSE; - } - - switch (format) { - case GL_COLOR: - case GL_RED: - case GL_GREEN: - case GL_BLUE: - case GL_ALPHA: - case GL_LUMINANCE: - case GL_LUMINANCE_ALPHA: - case GL_INTENSITY: - case GL_RG: - case GL_RGB: - case GL_BGR: - case GL_RGBA: - case GL_BGRA: - case GL_ABGR_EXT: - case GL_RED_INTEGER_EXT: - case GL_GREEN_INTEGER_EXT: - case GL_BLUE_INTEGER_EXT: - case GL_ALPHA_INTEGER_EXT: - case GL_RGB_INTEGER_EXT: - case GL_RGBA_INTEGER_EXT: - case GL_BGR_INTEGER_EXT: - case GL_BGRA_INTEGER_EXT: - case GL_LUMINANCE_INTEGER_EXT: - case GL_LUMINANCE_ALPHA_INTEGER_EXT: - if (ctx->ReadBuffer->_ColorReadBuffer == NULL) { - return GL_FALSE; - } - ASSERT(_mesa_get_format_bits(ctx->ReadBuffer->_ColorReadBuffer->Format, GL_RED_BITS) > 0 || - _mesa_get_format_bits(ctx->ReadBuffer->_ColorReadBuffer->Format, GL_ALPHA_BITS) > 0 || - _mesa_get_format_bits(ctx->ReadBuffer->_ColorReadBuffer->Format, GL_TEXTURE_LUMINANCE_SIZE) > 0 || - _mesa_get_format_bits(ctx->ReadBuffer->_ColorReadBuffer->Format, GL_TEXTURE_INTENSITY_SIZE) > 0 || - _mesa_get_format_bits(ctx->ReadBuffer->_ColorReadBuffer->Format, GL_INDEX_BITS) > 0); - break; - case GL_DEPTH: - case GL_DEPTH_COMPONENT: - if (!att[BUFFER_DEPTH].Renderbuffer) { - return GL_FALSE; - } - /*ASSERT(att[BUFFER_DEPTH].Renderbuffer->DepthBits > 0);*/ - break; - case GL_STENCIL: - case GL_STENCIL_INDEX: - if (!att[BUFFER_STENCIL].Renderbuffer) { - return GL_FALSE; - } - /*ASSERT(att[BUFFER_STENCIL].Renderbuffer->StencilBits > 0);*/ - break; - case GL_DEPTH_STENCIL_EXT: - if (!att[BUFFER_DEPTH].Renderbuffer || - !att[BUFFER_STENCIL].Renderbuffer) { - return GL_FALSE; - } - /* - ASSERT(att[BUFFER_DEPTH].Renderbuffer->DepthBits > 0); - ASSERT(att[BUFFER_STENCIL].Renderbuffer->StencilBits > 0); - */ - break; - default: - _mesa_problem(ctx, - "Unexpected format 0x%x in _mesa_source_buffer_exists", - format); - return GL_FALSE; - } - - /* OK */ - return GL_TRUE; -} - - -/** - * As above, but for drawing operations. - * XXX could do some code merging w/ above function. - */ -GLboolean -_mesa_dest_buffer_exists(struct gl_context *ctx, GLenum format) -{ - const struct gl_renderbuffer_attachment *att = ctx->DrawBuffer->Attachment; - - /* If we don't know the framebuffer status, update it now */ - if (ctx->DrawBuffer->_Status == 0) { - _mesa_test_framebuffer_completeness(ctx, ctx->DrawBuffer); - } - - if (ctx->DrawBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) { - return GL_FALSE; - } - - switch (format) { - case GL_COLOR: - case GL_RED: - case GL_GREEN: - case GL_BLUE: - case GL_ALPHA: - case GL_LUMINANCE: - case GL_LUMINANCE_ALPHA: - case GL_INTENSITY: - case GL_RGB: - case GL_BGR: - case GL_RGBA: - case GL_BGRA: - case GL_ABGR_EXT: - case GL_RED_INTEGER_EXT: - case GL_GREEN_INTEGER_EXT: - case GL_BLUE_INTEGER_EXT: - case GL_ALPHA_INTEGER_EXT: - case GL_RGB_INTEGER_EXT: - case GL_RGBA_INTEGER_EXT: - case GL_BGR_INTEGER_EXT: - case GL_BGRA_INTEGER_EXT: - case GL_LUMINANCE_INTEGER_EXT: - case GL_LUMINANCE_ALPHA_INTEGER_EXT: - /* Nothing special since GL_DRAW_BUFFER could be GL_NONE. */ - /* Could assert that colorbuffer has RedBits > 0 */ - break; - case GL_DEPTH: - case GL_DEPTH_COMPONENT: - if (!att[BUFFER_DEPTH].Renderbuffer) { - return GL_FALSE; - } - /*ASSERT(att[BUFFER_DEPTH].Renderbuffer->DepthBits > 0);*/ - break; - case GL_STENCIL: - case GL_STENCIL_INDEX: - if (!att[BUFFER_STENCIL].Renderbuffer) { - return GL_FALSE; - } - /*ASSERT(att[BUFFER_STENCIL].Renderbuffer->StencilBits > 0);*/ - break; - case GL_DEPTH_STENCIL_EXT: - if (!att[BUFFER_DEPTH].Renderbuffer || - !att[BUFFER_STENCIL].Renderbuffer) { - return GL_FALSE; - } - /* - ASSERT(att[BUFFER_DEPTH].Renderbuffer->DepthBits > 0); - ASSERT(att[BUFFER_STENCIL].Renderbuffer->StencilBits > 0); - */ - break; - default: - _mesa_problem(ctx, - "Unexpected format 0x%x in _mesa_dest_buffer_exists", - format); - return GL_FALSE; - } - - /* OK */ - return GL_TRUE; -} - - -/** - * Used to answer the GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES query. - */ -GLenum -_mesa_get_color_read_format(struct gl_context *ctx) -{ - switch (ctx->ReadBuffer->_ColorReadBuffer->Format) { - case MESA_FORMAT_ARGB8888: - return GL_BGRA; - case MESA_FORMAT_RGB565: - return GL_BGR; - default: - return GL_RGBA; - } -} - - -/** - * Used to answer the GL_IMPLEMENTATION_COLOR_READ_TYPE_OES query. - */ -GLenum -_mesa_get_color_read_type(struct gl_context *ctx) -{ - switch (ctx->ReadBuffer->_ColorReadBuffer->Format) { - case MESA_FORMAT_ARGB8888: - return GL_UNSIGNED_BYTE; - case MESA_FORMAT_RGB565: - return GL_UNSIGNED_SHORT_5_6_5_REV; - default: - return GL_UNSIGNED_BYTE; - } -} - - -/** - * Print framebuffer info to stderr, for debugging. - */ -void -_mesa_print_framebuffer(const struct gl_framebuffer *fb) -{ - GLuint i; - - fprintf(stderr, "Mesa Framebuffer %u at %p\n", fb->Name, (void *) fb); - fprintf(stderr, " Size: %u x %u Status: %s\n", fb->Width, fb->Height, - _mesa_lookup_enum_by_nr(fb->_Status)); - fprintf(stderr, " Attachments:\n"); - - for (i = 0; i < BUFFER_COUNT; i++) { - const struct gl_renderbuffer_attachment *att = &fb->Attachment[i]; - if (att->Type == GL_TEXTURE) { - const struct gl_texture_image *texImage = - _mesa_get_attachment_teximage_const(att); - fprintf(stderr, - " %2d: Texture %u, level %u, face %u, slice %u, complete %d\n", - i, att->Texture->Name, att->TextureLevel, att->CubeMapFace, - att->Zoffset, att->Complete); - fprintf(stderr, " Size: %u x %u x %u Format %s\n", - texImage->Width, texImage->Height, texImage->Depth, - _mesa_get_format_name(texImage->TexFormat)); - } - else if (att->Type == GL_RENDERBUFFER) { - fprintf(stderr, " %2d: Renderbuffer %u, complete %d\n", - i, att->Renderbuffer->Name, att->Complete); - fprintf(stderr, " Size: %u x %u Format %s\n", - att->Renderbuffer->Width, att->Renderbuffer->Height, - _mesa_get_format_name(att->Renderbuffer->Format)); - } - else { - fprintf(stderr, " %2d: none\n", i); - } - } -} +/* + * Mesa 3-D graphics library + * Version: 7.2 + * + * 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. + */ + + +/** + * Functions for allocating/managing framebuffers and renderbuffers. + * Also, routines for reading/writing renderbuffer data as ubytes, + * ushorts, uints, etc. + */ + + +#include "glheader.h" +#include "imports.h" +#include "buffers.h" +#include "context.h" +#include "depthstencil.h" +#include "enums.h" +#include "formats.h" +#include "macros.h" +#include "mtypes.h" +#include "fbobject.h" +#include "framebuffer.h" +#include "renderbuffer.h" +#include "texobj.h" + + + +/** + * Compute/set the _DepthMax field for the given framebuffer. + * This value depends on the Z buffer resolution. + */ +static void +compute_depth_max(struct gl_framebuffer *fb) +{ + if (fb->Visual.depthBits == 0) { + /* Special case. Even if we don't have a depth buffer we need + * good values for DepthMax for Z vertex transformation purposes + * and for per-fragment fog computation. + */ + fb->_DepthMax = (1 << 16) - 1; + } + else if (fb->Visual.depthBits < 32) { + fb->_DepthMax = (1 << fb->Visual.depthBits) - 1; + } + else { + /* Special case since shift values greater than or equal to the + * number of bits in the left hand expression's type are undefined. + */ + fb->_DepthMax = 0xffffffff; + } + fb->_DepthMaxF = (GLfloat) fb->_DepthMax; + + /* Minimum resolvable depth value, for polygon offset */ + fb->_MRD = (GLfloat)1.0 / fb->_DepthMaxF; +} + +/** + * Create and initialize a gl_framebuffer object. + * This is intended for creating _window_system_ framebuffers, not generic + * framebuffer objects ala GL_EXT_framebuffer_object. + * + * \sa _mesa_new_framebuffer + */ +struct gl_framebuffer * +_mesa_create_framebuffer(const struct gl_config *visual) +{ + struct gl_framebuffer *fb = CALLOC_STRUCT(gl_framebuffer); + assert(visual); + if (fb) { + _mesa_initialize_window_framebuffer(fb, visual); + } + return fb; +} + + +/** + * Allocate a new gl_framebuffer object. + * This is the default function for ctx->Driver.NewFramebuffer(). + * This is for allocating user-created framebuffers, not window-system + * framebuffers! + * \sa _mesa_create_framebuffer + */ +struct gl_framebuffer * +_mesa_new_framebuffer(struct gl_context *ctx, GLuint name) +{ + struct gl_framebuffer *fb; + (void) ctx; + assert(name != 0); + fb = CALLOC_STRUCT(gl_framebuffer); + if (fb) { + _mesa_initialize_user_framebuffer(fb, name); + } + return fb; +} + + +/** + * Initialize a gl_framebuffer object. Typically used to initialize + * window system-created framebuffers, not user-created framebuffers. + * \sa _mesa_initialize_user_framebuffer + */ +void +_mesa_initialize_window_framebuffer(struct gl_framebuffer *fb, + const struct gl_config *visual) +{ + assert(fb); + assert(visual); + + memset(fb, 0, sizeof(struct gl_framebuffer)); + + _glthread_INIT_MUTEX(fb->Mutex); + + fb->RefCount = 1; + + /* save the visual */ + fb->Visual = *visual; + + /* Init read/draw renderbuffer state */ + if (visual->doubleBufferMode) { + fb->_NumColorDrawBuffers = 1; + fb->ColorDrawBuffer[0] = GL_BACK; + fb->_ColorDrawBufferIndexes[0] = BUFFER_BACK_LEFT; + fb->ColorReadBuffer = GL_BACK; + fb->_ColorReadBufferIndex = BUFFER_BACK_LEFT; + } + else { + fb->_NumColorDrawBuffers = 1; + fb->ColorDrawBuffer[0] = GL_FRONT; + fb->_ColorDrawBufferIndexes[0] = BUFFER_FRONT_LEFT; + fb->ColorReadBuffer = GL_FRONT; + fb->_ColorReadBufferIndex = BUFFER_FRONT_LEFT; + } + + fb->Delete = _mesa_destroy_framebuffer; + fb->_Status = GL_FRAMEBUFFER_COMPLETE_EXT; + + compute_depth_max(fb); +} + + +/** + * Initialize a user-created gl_framebuffer object. + * \sa _mesa_initialize_window_framebuffer + */ +void +_mesa_initialize_user_framebuffer(struct gl_framebuffer *fb, GLuint name) +{ + assert(fb); + assert(name); + + memset(fb, 0, sizeof(struct gl_framebuffer)); + + fb->Name = name; + fb->RefCount = 1; + fb->_NumColorDrawBuffers = 1; + fb->ColorDrawBuffer[0] = GL_COLOR_ATTACHMENT0_EXT; + fb->_ColorDrawBufferIndexes[0] = BUFFER_COLOR0; + fb->ColorReadBuffer = GL_COLOR_ATTACHMENT0_EXT; + fb->_ColorReadBufferIndex = BUFFER_COLOR0; + fb->Delete = _mesa_destroy_framebuffer; + _glthread_INIT_MUTEX(fb->Mutex); +} + + +/** + * Deallocate buffer and everything attached to it. + * Typically called via the gl_framebuffer->Delete() method. + */ +void +_mesa_destroy_framebuffer(struct gl_framebuffer *fb) +{ + if (fb) { + _mesa_free_framebuffer_data(fb); + free(fb); + } +} + + +/** + * Free all the data hanging off the given gl_framebuffer, but don't free + * the gl_framebuffer object itself. + */ +void +_mesa_free_framebuffer_data(struct gl_framebuffer *fb) +{ + GLuint i; + + assert(fb); + assert(fb->RefCount == 0); + + _glthread_DESTROY_MUTEX(fb->Mutex); + + for (i = 0; i < BUFFER_COUNT; i++) { + struct gl_renderbuffer_attachment *att = &fb->Attachment[i]; + if (att->Renderbuffer) { + _mesa_reference_renderbuffer(&att->Renderbuffer, NULL); + } + if (att->Texture) { + _mesa_reference_texobj(&att->Texture, NULL); + } + ASSERT(!att->Renderbuffer); + ASSERT(!att->Texture); + att->Type = GL_NONE; + } + + /* unbind _Depth/_StencilBuffer to decr ref counts */ + _mesa_reference_renderbuffer(&fb->_DepthBuffer, NULL); + _mesa_reference_renderbuffer(&fb->_StencilBuffer, NULL); +} + + +/** + * Set *ptr to point to fb, with refcounting and locking. + * This is normally only called from the _mesa_reference_framebuffer() macro + * when there's a real pointer change. + */ +void +_mesa_reference_framebuffer_(struct gl_framebuffer **ptr, + struct gl_framebuffer *fb) +{ + if (*ptr) { + /* unreference old renderbuffer */ + GLboolean deleteFlag = GL_FALSE; + struct gl_framebuffer *oldFb = *ptr; + + _glthread_LOCK_MUTEX(oldFb->Mutex); + ASSERT(oldFb->RefCount > 0); + oldFb->RefCount--; + deleteFlag = (oldFb->RefCount == 0); + _glthread_UNLOCK_MUTEX(oldFb->Mutex); + + if (deleteFlag) + oldFb->Delete(oldFb); + + *ptr = NULL; + } + assert(!*ptr); + + if (fb) { + _glthread_LOCK_MUTEX(fb->Mutex); + fb->RefCount++; + _glthread_UNLOCK_MUTEX(fb->Mutex); + *ptr = fb; + } +} + + +/** + * Resize the given framebuffer's renderbuffers to the new width and height. + * This should only be used for window-system framebuffers, not + * user-created renderbuffers (i.e. made with GL_EXT_framebuffer_object). + * This will typically be called via ctx->Driver.ResizeBuffers() or directly + * from a device driver. + * + * \note it's possible for ctx to be null since a window can be resized + * without a currently bound rendering context. + */ +void +_mesa_resize_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb, + GLuint width, GLuint height) +{ + GLuint i; + + /* XXX I think we could check if the size is not changing + * and return early. + */ + + /* For window system framebuffers, Name is zero */ + assert(fb->Name == 0); + + for (i = 0; i < BUFFER_COUNT; i++) { + struct gl_renderbuffer_attachment *att = &fb->Attachment[i]; + if (att->Type == GL_RENDERBUFFER_EXT && att->Renderbuffer) { + struct gl_renderbuffer *rb = att->Renderbuffer; + /* only resize if size is changing */ + if (rb->Width != width || rb->Height != height) { + if (rb->AllocStorage(ctx, rb, rb->InternalFormat, width, height)) { + ASSERT(rb->Width == width); + ASSERT(rb->Height == height); + } + else { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "Resizing framebuffer"); + /* no return */ + } + } + } + } + + if (fb->_DepthBuffer) { + struct gl_renderbuffer *rb = fb->_DepthBuffer; + if (rb->Width != width || rb->Height != height) { + if (!rb->AllocStorage(ctx, rb, rb->InternalFormat, width, height)) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "Resizing framebuffer"); + } + } + } + + if (fb->_StencilBuffer) { + struct gl_renderbuffer *rb = fb->_StencilBuffer; + if (rb->Width != width || rb->Height != height) { + if (!rb->AllocStorage(ctx, rb, rb->InternalFormat, width, height)) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "Resizing framebuffer"); + } + } + } + + fb->Width = width; + fb->Height = height; + + if (ctx) { + /* update scissor / window bounds */ + _mesa_update_draw_buffer_bounds(ctx); + /* Signal new buffer state so that swrast will update its clipping + * info (the CLIP_BIT flag). + */ + ctx->NewState |= _NEW_BUFFERS; + } +} + + + +/** + * XXX THIS IS OBSOLETE - drivers should take care of detecting window + * size changes and act accordingly, likely calling _mesa_resize_framebuffer(). + * + * GL_MESA_resize_buffers extension. + * + * When this function is called, we'll ask the window system how large + * the current window is. If it's a new size, we'll call the driver's + * ResizeBuffers function. The driver will then resize its color buffers + * as needed, and maybe call the swrast's routine for reallocating + * swrast-managed depth/stencil/accum/etc buffers. + * \note This function should only be called through the GL API, not + * from device drivers (as was done in the past). + */ +void +_mesa_resizebuffers( struct gl_context *ctx ) +{ + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH( ctx ); + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glResizeBuffersMESA\n"); + + if (!ctx->Driver.GetBufferSize) { + return; + } + + if (ctx->WinSysDrawBuffer) { + GLuint newWidth, newHeight; + struct gl_framebuffer *buffer = ctx->WinSysDrawBuffer; + + assert(buffer->Name == 0); + + /* ask device driver for size of output buffer */ + ctx->Driver.GetBufferSize( buffer, &newWidth, &newHeight ); + + /* see if size of device driver's color buffer (window) has changed */ + if (buffer->Width != newWidth || buffer->Height != newHeight) { + if (ctx->Driver.ResizeBuffers) + ctx->Driver.ResizeBuffers(ctx, buffer, newWidth, newHeight ); + } + } + + if (ctx->WinSysReadBuffer + && ctx->WinSysReadBuffer != ctx->WinSysDrawBuffer) { + GLuint newWidth, newHeight; + struct gl_framebuffer *buffer = ctx->WinSysReadBuffer; + + assert(buffer->Name == 0); + + /* ask device driver for size of read buffer */ + ctx->Driver.GetBufferSize( buffer, &newWidth, &newHeight ); + + /* see if size of device driver's color buffer (window) has changed */ + if (buffer->Width != newWidth || buffer->Height != newHeight) { + if (ctx->Driver.ResizeBuffers) + ctx->Driver.ResizeBuffers(ctx, buffer, newWidth, newHeight ); + } + } + + ctx->NewState |= _NEW_BUFFERS; /* to update scissor / window bounds */ +} + + +/* + * XXX THIS IS OBSOLETE + */ +void GLAPIENTRY +_mesa_ResizeBuffersMESA( void ) +{ + GET_CURRENT_CONTEXT(ctx); + + if (ctx->Extensions.MESA_resize_buffers) + _mesa_resizebuffers( ctx ); +} + + + +/** + * Examine all the framebuffer's renderbuffers to update the Width/Height + * fields of the framebuffer. If we have renderbuffers with different + * sizes, set the framebuffer's width and height to the min size. + * Note: this is only intended for user-created framebuffers, not + * window-system framebuffes. + */ +static void +update_framebuffer_size(struct gl_context *ctx, struct gl_framebuffer *fb) +{ + GLuint minWidth = ~0, minHeight = ~0; + GLuint i; + + /* user-created framebuffers only */ + assert(fb->Name); + + for (i = 0; i < BUFFER_COUNT; i++) { + struct gl_renderbuffer_attachment *att = &fb->Attachment[i]; + const struct gl_renderbuffer *rb = att->Renderbuffer; + if (rb) { + minWidth = MIN2(minWidth, rb->Width); + minHeight = MIN2(minHeight, rb->Height); + } + } + + if (minWidth != ~0) { + fb->Width = minWidth; + fb->Height = minHeight; + } + else { + fb->Width = 0; + fb->Height = 0; + } +} + + +/** + * Update the context's current drawing buffer's Xmin, Xmax, Ymin, Ymax fields. + * These values are computed from the buffer's width and height and + * the scissor box, if it's enabled. + * \param ctx the GL context. + */ +void +_mesa_update_draw_buffer_bounds(struct gl_context *ctx) +{ + struct gl_framebuffer *buffer = ctx->DrawBuffer; + + if (!buffer) + return; + + if (buffer->Name) { + /* user-created framebuffer size depends on the renderbuffers */ + update_framebuffer_size(ctx, buffer); + } + + buffer->_Xmin = 0; + buffer->_Ymin = 0; + buffer->_Xmax = buffer->Width; + buffer->_Ymax = buffer->Height; + + if (ctx->Scissor.Enabled) { + if (ctx->Scissor.X > buffer->_Xmin) { + buffer->_Xmin = ctx->Scissor.X; + } + if (ctx->Scissor.Y > buffer->_Ymin) { + buffer->_Ymin = ctx->Scissor.Y; + } + if (ctx->Scissor.X + ctx->Scissor.Width < buffer->_Xmax) { + buffer->_Xmax = ctx->Scissor.X + ctx->Scissor.Width; + } + if (ctx->Scissor.Y + ctx->Scissor.Height < buffer->_Ymax) { + buffer->_Ymax = ctx->Scissor.Y + ctx->Scissor.Height; + } + /* finally, check for empty region */ + if (buffer->_Xmin > buffer->_Xmax) { + buffer->_Xmin = buffer->_Xmax; + } + if (buffer->_Ymin > buffer->_Ymax) { + buffer->_Ymin = buffer->_Ymax; + } + } + + ASSERT(buffer->_Xmin <= buffer->_Xmax); + ASSERT(buffer->_Ymin <= buffer->_Ymax); +} + + +/** + * The glGet queries of the framebuffer red/green/blue size, stencil size, + * etc. are satisfied by the fields of ctx->DrawBuffer->Visual. These can + * change depending on the renderbuffer bindings. This function updates + * the given framebuffer's Visual from the current renderbuffer bindings. + * + * This may apply to user-created framebuffers or window system framebuffers. + * + * Also note: ctx->DrawBuffer->Visual.depthBits might not equal + * ctx->DrawBuffer->Attachment[BUFFER_DEPTH].Renderbuffer.DepthBits. + * The former one is used to convert floating point depth values into + * integer Z values. + */ +void +_mesa_update_framebuffer_visual(struct gl_context *ctx, + struct gl_framebuffer *fb) +{ + GLuint i; + + memset(&fb->Visual, 0, sizeof(fb->Visual)); + fb->Visual.rgbMode = GL_TRUE; /* assume this */ + +#if 0 /* this _might_ be needed */ + if (fb->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) { + /* leave visual fields zero'd */ + return; + } +#endif + + /* find first RGB renderbuffer */ + for (i = 0; i < BUFFER_COUNT; i++) { + if (fb->Attachment[i].Renderbuffer) { + const struct gl_renderbuffer *rb = fb->Attachment[i].Renderbuffer; + const GLenum baseFormat = _mesa_get_format_base_format(rb->Format); + const gl_format fmt = rb->Format; + + if (_mesa_is_legal_color_format(ctx, baseFormat)) { + fb->Visual.redBits = _mesa_get_format_bits(fmt, GL_RED_BITS); + fb->Visual.greenBits = _mesa_get_format_bits(fmt, GL_GREEN_BITS); + fb->Visual.blueBits = _mesa_get_format_bits(fmt, GL_BLUE_BITS); + fb->Visual.alphaBits = _mesa_get_format_bits(fmt, GL_ALPHA_BITS); + fb->Visual.rgbBits = fb->Visual.redBits + + fb->Visual.greenBits + fb->Visual.blueBits; + fb->Visual.samples = rb->NumSamples; + fb->Visual.sampleBuffers = rb->NumSamples > 0 ? 1 : 0; + if (_mesa_get_format_color_encoding(fmt) == GL_SRGB) + fb->Visual.sRGBCapable = ctx->Const.sRGBCapable; + break; + } + } + } + + fb->Visual.floatMode = GL_FALSE; + for (i = 0; i < BUFFER_COUNT; i++) { + if (fb->Attachment[i].Renderbuffer) { + const struct gl_renderbuffer *rb = fb->Attachment[i].Renderbuffer; + const gl_format fmt = rb->Format; + + if (_mesa_get_format_datatype(fmt) == GL_FLOAT) { + fb->Visual.floatMode = GL_TRUE; + break; + } + } + } + + if (fb->Attachment[BUFFER_DEPTH].Renderbuffer) { + const struct gl_renderbuffer *rb = + fb->Attachment[BUFFER_DEPTH].Renderbuffer; + const gl_format fmt = rb->Format; + fb->Visual.haveDepthBuffer = GL_TRUE; + fb->Visual.depthBits = _mesa_get_format_bits(fmt, GL_DEPTH_BITS); + } + + if (fb->Attachment[BUFFER_STENCIL].Renderbuffer) { + const struct gl_renderbuffer *rb = + fb->Attachment[BUFFER_STENCIL].Renderbuffer; + const gl_format fmt = rb->Format; + fb->Visual.haveStencilBuffer = GL_TRUE; + fb->Visual.stencilBits = _mesa_get_format_bits(fmt, GL_STENCIL_BITS); + } + + if (fb->Attachment[BUFFER_ACCUM].Renderbuffer) { + const struct gl_renderbuffer *rb = + fb->Attachment[BUFFER_ACCUM].Renderbuffer; + const gl_format fmt = rb->Format; + fb->Visual.haveAccumBuffer = GL_TRUE; + fb->Visual.accumRedBits = _mesa_get_format_bits(fmt, GL_RED_BITS); + fb->Visual.accumGreenBits = _mesa_get_format_bits(fmt, GL_GREEN_BITS); + fb->Visual.accumBlueBits = _mesa_get_format_bits(fmt, GL_BLUE_BITS); + fb->Visual.accumAlphaBits = _mesa_get_format_bits(fmt, GL_ALPHA_BITS); + } + + compute_depth_max(fb); +} + + +/** + * Update the framebuffer's _DepthBuffer field using the renderbuffer + * found at the given attachment index. + * + * If that attachment points to a combined GL_DEPTH_STENCIL renderbuffer, + * create and install a depth wrapper/adaptor. + * + * \param fb the framebuffer whose _DepthBuffer field to update + * \param attIndex indicates the renderbuffer to possibly wrap + */ +void +_mesa_update_depth_buffer(struct gl_context *ctx, + struct gl_framebuffer *fb, + GLuint attIndex) +{ + struct gl_renderbuffer *depthRb; + + /* only one possiblity for now */ + ASSERT(attIndex == BUFFER_DEPTH); + + depthRb = fb->Attachment[attIndex].Renderbuffer; + + if (depthRb && _mesa_is_format_packed_depth_stencil(depthRb->Format)) { + /* The attached depth buffer is a GL_DEPTH_STENCIL renderbuffer */ + if (!fb->_DepthBuffer + || fb->_DepthBuffer->Wrapped != depthRb + || _mesa_get_format_base_format(fb->_DepthBuffer->Format) != GL_DEPTH_COMPONENT) { + /* need to update wrapper */ + struct gl_renderbuffer *wrapper; + + if (depthRb->Format == MESA_FORMAT_Z32_FLOAT_X24S8) { + wrapper = _mesa_new_z32f_renderbuffer_wrapper(ctx, depthRb); + } + else { + wrapper = _mesa_new_z24_renderbuffer_wrapper(ctx, depthRb); + } + _mesa_reference_renderbuffer(&fb->_DepthBuffer, wrapper); + ASSERT(fb->_DepthBuffer->Wrapped == depthRb); + } + } + else { + /* depthRb may be null */ + _mesa_reference_renderbuffer(&fb->_DepthBuffer, depthRb); + } +} + + +/** + * Update the framebuffer's _StencilBuffer field using the renderbuffer + * found at the given attachment index. + * + * If that attachment points to a combined GL_DEPTH_STENCIL renderbuffer, + * create and install a stencil wrapper/adaptor. + * + * \param fb the framebuffer whose _StencilBuffer field to update + * \param attIndex indicates the renderbuffer to possibly wrap + */ +void +_mesa_update_stencil_buffer(struct gl_context *ctx, + struct gl_framebuffer *fb, + GLuint attIndex) +{ + struct gl_renderbuffer *stencilRb; + + ASSERT(attIndex == BUFFER_DEPTH || + attIndex == BUFFER_STENCIL); + + stencilRb = fb->Attachment[attIndex].Renderbuffer; + + if (stencilRb && _mesa_is_format_packed_depth_stencil(stencilRb->Format)) { + /* The attached stencil buffer is a GL_DEPTH_STENCIL renderbuffer */ + if (!fb->_StencilBuffer + || fb->_StencilBuffer->Wrapped != stencilRb + || _mesa_get_format_base_format(fb->_StencilBuffer->Format) != GL_STENCIL_INDEX) { + /* need to update wrapper */ + struct gl_renderbuffer *wrapper + = _mesa_new_s8_renderbuffer_wrapper(ctx, stencilRb); + _mesa_reference_renderbuffer(&fb->_StencilBuffer, wrapper); + ASSERT(fb->_StencilBuffer->Wrapped == stencilRb); + } + } + else { + /* stencilRb may be null */ + _mesa_reference_renderbuffer(&fb->_StencilBuffer, stencilRb); + } +} + + +/* + * Example DrawBuffers scenarios: + * + * 1. glDrawBuffer(GL_FRONT_AND_BACK), fixed-func or shader writes to + * "gl_FragColor" or program writes to the "result.color" register: + * + * fragment color output renderbuffer + * --------------------- --------------- + * color[0] Front, Back + * + * + * 2. glDrawBuffers(3, [GL_FRONT, GL_AUX0, GL_AUX1]), shader writes to + * gl_FragData[i] or program writes to result.color[i] registers: + * + * fragment color output renderbuffer + * --------------------- --------------- + * color[0] Front + * color[1] Aux0 + * color[3] Aux1 + * + * + * 3. glDrawBuffers(3, [GL_FRONT, GL_AUX0, GL_AUX1]) and shader writes to + * gl_FragColor, or fixed function: + * + * fragment color output renderbuffer + * --------------------- --------------- + * color[0] Front, Aux0, Aux1 + * + * + * In either case, the list of renderbuffers is stored in the + * framebuffer->_ColorDrawBuffers[] array and + * framebuffer->_NumColorDrawBuffers indicates the number of buffers. + * The renderer (like swrast) has to look at the current fragment shader + * to see if it writes to gl_FragColor vs. gl_FragData[i] to determine + * how to map color outputs to renderbuffers. + * + * Note that these two calls are equivalent (for fixed function fragment + * shading anyway): + * a) glDrawBuffer(GL_FRONT_AND_BACK); (assuming non-stereo framebuffer) + * b) glDrawBuffers(2, [GL_FRONT_LEFT, GL_BACK_LEFT]); + */ + + + + +/** + * Update the (derived) list of color drawing renderbuffer pointers. + * Later, when we're rendering we'll loop from 0 to _NumColorDrawBuffers + * writing colors. + */ +static void +update_color_draw_buffers(struct gl_context *ctx, struct gl_framebuffer *fb) +{ + GLuint output; + + /* set 0th buffer to NULL now in case _NumColorDrawBuffers is zero */ + fb->_ColorDrawBuffers[0] = NULL; + + for (output = 0; output < fb->_NumColorDrawBuffers; output++) { + GLint buf = fb->_ColorDrawBufferIndexes[output]; + if (buf >= 0) { + fb->_ColorDrawBuffers[output] = fb->Attachment[buf].Renderbuffer; + } + else { + fb->_ColorDrawBuffers[output] = NULL; + } + } +} + + +/** + * Update the (derived) color read renderbuffer pointer. + * Unlike the DrawBuffer, we can only read from one (or zero) color buffers. + */ +static void +update_color_read_buffer(struct gl_context *ctx, struct gl_framebuffer *fb) +{ + (void) ctx; + if (fb->_ColorReadBufferIndex == -1 || + fb->DeletePending || + fb->Width == 0 || + fb->Height == 0) { + fb->_ColorReadBuffer = NULL; /* legal! */ + } + else { + ASSERT(fb->_ColorReadBufferIndex >= 0); + ASSERT(fb->_ColorReadBufferIndex < BUFFER_COUNT); + fb->_ColorReadBuffer + = fb->Attachment[fb->_ColorReadBufferIndex].Renderbuffer; + } +} + + +/** + * Update a gl_framebuffer's derived state. + * + * Specifically, update these framebuffer fields: + * _ColorDrawBuffers + * _NumColorDrawBuffers + * _ColorReadBuffer + * _DepthBuffer + * _StencilBuffer + * + * If the framebuffer is user-created, make sure it's complete. + * + * The following functions (at least) can effect framebuffer state: + * glReadBuffer, glDrawBuffer, glDrawBuffersARB, glFramebufferRenderbufferEXT, + * glRenderbufferStorageEXT. + */ +static void +update_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb) +{ + if (fb->Name == 0) { + /* This is a window-system framebuffer */ + /* Need to update the FB's GL_DRAW_BUFFER state to match the + * context state (GL_READ_BUFFER too). + */ + if (fb->ColorDrawBuffer[0] != ctx->Color.DrawBuffer[0]) { + _mesa_drawbuffers(ctx, ctx->Const.MaxDrawBuffers, + ctx->Color.DrawBuffer, NULL); + } + } + else { + /* This is a user-created framebuffer. + * Completeness only matters for user-created framebuffers. + */ + if (fb->_Status != GL_FRAMEBUFFER_COMPLETE) { + _mesa_test_framebuffer_completeness(ctx, fb); + } + } + + /* Strictly speaking, we don't need to update the draw-state + * if this FB is bound as ctx->ReadBuffer (and conversely, the + * read-state if this FB is bound as ctx->DrawBuffer), but no + * harm. + */ + update_color_draw_buffers(ctx, fb); + update_color_read_buffer(ctx, fb); + _mesa_update_depth_buffer(ctx, fb, BUFFER_DEPTH); + _mesa_update_stencil_buffer(ctx, fb, BUFFER_STENCIL); + + compute_depth_max(fb); +} + + +/** + * Update state related to the current draw/read framebuffers. + */ +void +_mesa_update_framebuffer(struct gl_context *ctx) +{ + struct gl_framebuffer *drawFb; + struct gl_framebuffer *readFb; + + assert(ctx); + drawFb = ctx->DrawBuffer; + readFb = ctx->ReadBuffer; + + update_framebuffer(ctx, drawFb); + if (readFb != drawFb) + update_framebuffer(ctx, readFb); +} + + +/** + * Check if the renderbuffer for a read operation (glReadPixels, glCopyPixels, + * glCopyTex[Sub]Image, etc) exists. + * \param format a basic image format such as GL_RGB, GL_RGBA, GL_ALPHA, + * GL_DEPTH_COMPONENT, etc. or GL_COLOR, GL_DEPTH, GL_STENCIL. + * \return GL_TRUE if buffer exists, GL_FALSE otherwise + */ +GLboolean +_mesa_source_buffer_exists(struct gl_context *ctx, GLenum format) +{ + const struct gl_renderbuffer_attachment *att = ctx->ReadBuffer->Attachment; + + /* If we don't know the framebuffer status, update it now */ + if (ctx->ReadBuffer->_Status == 0) { + _mesa_test_framebuffer_completeness(ctx, ctx->ReadBuffer); + } + + if (ctx->ReadBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) { + return GL_FALSE; + } + + switch (format) { + case GL_COLOR: + case GL_RED: + case GL_GREEN: + case GL_BLUE: + case GL_ALPHA: + case GL_LUMINANCE: + case GL_LUMINANCE_ALPHA: + case GL_INTENSITY: + case GL_RG: + case GL_RGB: + case GL_BGR: + case GL_RGBA: + case GL_BGRA: + case GL_ABGR_EXT: + case GL_RED_INTEGER_EXT: + case GL_GREEN_INTEGER_EXT: + case GL_BLUE_INTEGER_EXT: + case GL_ALPHA_INTEGER_EXT: + case GL_RGB_INTEGER_EXT: + case GL_RGBA_INTEGER_EXT: + case GL_BGR_INTEGER_EXT: + case GL_BGRA_INTEGER_EXT: + case GL_LUMINANCE_INTEGER_EXT: + case GL_LUMINANCE_ALPHA_INTEGER_EXT: + if (ctx->ReadBuffer->_ColorReadBuffer == NULL) { + return GL_FALSE; + } + ASSERT(_mesa_get_format_bits(ctx->ReadBuffer->_ColorReadBuffer->Format, GL_RED_BITS) > 0 || + _mesa_get_format_bits(ctx->ReadBuffer->_ColorReadBuffer->Format, GL_ALPHA_BITS) > 0 || + _mesa_get_format_bits(ctx->ReadBuffer->_ColorReadBuffer->Format, GL_TEXTURE_LUMINANCE_SIZE) > 0 || + _mesa_get_format_bits(ctx->ReadBuffer->_ColorReadBuffer->Format, GL_TEXTURE_INTENSITY_SIZE) > 0 || + _mesa_get_format_bits(ctx->ReadBuffer->_ColorReadBuffer->Format, GL_INDEX_BITS) > 0); + break; + case GL_DEPTH: + case GL_DEPTH_COMPONENT: + if (!att[BUFFER_DEPTH].Renderbuffer) { + return GL_FALSE; + } + /*ASSERT(att[BUFFER_DEPTH].Renderbuffer->DepthBits > 0);*/ + break; + case GL_STENCIL: + case GL_STENCIL_INDEX: + if (!att[BUFFER_STENCIL].Renderbuffer) { + return GL_FALSE; + } + /*ASSERT(att[BUFFER_STENCIL].Renderbuffer->StencilBits > 0);*/ + break; + case GL_DEPTH_STENCIL_EXT: + if (!att[BUFFER_DEPTH].Renderbuffer || + !att[BUFFER_STENCIL].Renderbuffer) { + return GL_FALSE; + } + /* + ASSERT(att[BUFFER_DEPTH].Renderbuffer->DepthBits > 0); + ASSERT(att[BUFFER_STENCIL].Renderbuffer->StencilBits > 0); + */ + break; + default: + _mesa_problem(ctx, + "Unexpected format 0x%x in _mesa_source_buffer_exists", + format); + return GL_FALSE; + } + + /* OK */ + return GL_TRUE; +} + + +/** + * As above, but for drawing operations. + * XXX could do some code merging w/ above function. + */ +GLboolean +_mesa_dest_buffer_exists(struct gl_context *ctx, GLenum format) +{ + const struct gl_renderbuffer_attachment *att = ctx->DrawBuffer->Attachment; + + /* If we don't know the framebuffer status, update it now */ + if (ctx->DrawBuffer->_Status == 0) { + _mesa_test_framebuffer_completeness(ctx, ctx->DrawBuffer); + } + + if (ctx->DrawBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) { + return GL_FALSE; + } + + switch (format) { + case GL_COLOR: + case GL_RED: + case GL_GREEN: + case GL_BLUE: + case GL_ALPHA: + case GL_LUMINANCE: + case GL_LUMINANCE_ALPHA: + case GL_INTENSITY: + case GL_RGB: + case GL_BGR: + case GL_RGBA: + case GL_BGRA: + case GL_ABGR_EXT: + case GL_RED_INTEGER_EXT: + case GL_GREEN_INTEGER_EXT: + case GL_BLUE_INTEGER_EXT: + case GL_ALPHA_INTEGER_EXT: + case GL_RGB_INTEGER_EXT: + case GL_RGBA_INTEGER_EXT: + case GL_BGR_INTEGER_EXT: + case GL_BGRA_INTEGER_EXT: + case GL_LUMINANCE_INTEGER_EXT: + case GL_LUMINANCE_ALPHA_INTEGER_EXT: + /* Nothing special since GL_DRAW_BUFFER could be GL_NONE. */ + /* Could assert that colorbuffer has RedBits > 0 */ + break; + case GL_DEPTH: + case GL_DEPTH_COMPONENT: + if (!att[BUFFER_DEPTH].Renderbuffer) { + return GL_FALSE; + } + /*ASSERT(att[BUFFER_DEPTH].Renderbuffer->DepthBits > 0);*/ + break; + case GL_STENCIL: + case GL_STENCIL_INDEX: + if (!att[BUFFER_STENCIL].Renderbuffer) { + return GL_FALSE; + } + /*ASSERT(att[BUFFER_STENCIL].Renderbuffer->StencilBits > 0);*/ + break; + case GL_DEPTH_STENCIL_EXT: + if (!att[BUFFER_DEPTH].Renderbuffer || + !att[BUFFER_STENCIL].Renderbuffer) { + return GL_FALSE; + } + /* + ASSERT(att[BUFFER_DEPTH].Renderbuffer->DepthBits > 0); + ASSERT(att[BUFFER_STENCIL].Renderbuffer->StencilBits > 0); + */ + break; + default: + _mesa_problem(ctx, + "Unexpected format 0x%x in _mesa_dest_buffer_exists", + format); + return GL_FALSE; + } + + /* OK */ + return GL_TRUE; +} + + +/** + * Used to answer the GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES query. + */ +GLenum +_mesa_get_color_read_format(struct gl_context *ctx) +{ + switch (ctx->ReadBuffer->_ColorReadBuffer->Format) { + case MESA_FORMAT_ARGB8888: + return GL_BGRA; + case MESA_FORMAT_RGB565: + return GL_BGR; + default: + return GL_RGBA; + } +} + + +/** + * Used to answer the GL_IMPLEMENTATION_COLOR_READ_TYPE_OES query. + */ +GLenum +_mesa_get_color_read_type(struct gl_context *ctx) +{ + switch (ctx->ReadBuffer->_ColorReadBuffer->Format) { + case MESA_FORMAT_ARGB8888: + return GL_UNSIGNED_BYTE; + case MESA_FORMAT_RGB565: + return GL_UNSIGNED_SHORT_5_6_5_REV; + default: + return GL_UNSIGNED_BYTE; + } +} + + +/** + * Print framebuffer info to stderr, for debugging. + */ +void +_mesa_print_framebuffer(const struct gl_framebuffer *fb) +{ + GLuint i; + + fprintf(stderr, "Mesa Framebuffer %u at %p\n", fb->Name, (void *) fb); + fprintf(stderr, " Size: %u x %u Status: %s\n", fb->Width, fb->Height, + _mesa_lookup_enum_by_nr(fb->_Status)); + fprintf(stderr, " Attachments:\n"); + + for (i = 0; i < BUFFER_COUNT; i++) { + const struct gl_renderbuffer_attachment *att = &fb->Attachment[i]; + if (att->Type == GL_TEXTURE) { + const struct gl_texture_image *texImage = + _mesa_get_attachment_teximage_const(att); + fprintf(stderr, + " %2d: Texture %u, level %u, face %u, slice %u, complete %d\n", + i, att->Texture->Name, att->TextureLevel, att->CubeMapFace, + att->Zoffset, att->Complete); + fprintf(stderr, " Size: %u x %u x %u Format %s\n", + texImage->Width, texImage->Height, texImage->Depth, + _mesa_get_format_name(texImage->TexFormat)); + } + else if (att->Type == GL_RENDERBUFFER) { + fprintf(stderr, " %2d: Renderbuffer %u, complete %d\n", + i, att->Renderbuffer->Name, att->Complete); + fprintf(stderr, " Size: %u x %u Format %s\n", + att->Renderbuffer->Width, att->Renderbuffer->Height, + _mesa_get_format_name(att->Renderbuffer->Format)); + } + else { + fprintf(stderr, " %2d: none\n", i); + } + } +} diff --git a/mesalib/src/mesa/main/get.c b/mesalib/src/mesa/main/get.c index ee241615d..069254b18 100644 --- a/mesalib/src/mesa/main/get.c +++ b/mesalib/src/mesa/main/get.c @@ -1,2619 +1,2619 @@ -/* - * 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 - */ - -#include "glheader.h" -#include "context.h" -#include "enable.h" -#include "enums.h" -#include "extensions.h" -#include "get.h" -#include "macros.h" -#include "mfeatures.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_NEW_FRAG_CLAMP, - 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_new_frag_clamp[] = { - EXTRA_NEW_FRAG_CLAMP, - 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 -}; - -static const int extra_ARB_sampler_objects[] = { - EXT(ARB_sampler_objects), - EXTRA_END -}; - - -EXTRA_EXT(ARB_ES2_compatibility); -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(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); -EXTRA_EXT(EXT_framebuffer_sRGB); -EXTRA_EXT(ARB_texture_buffer_object); - -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.Blend[0].SrcRGB), NO_EXTRA }, - { GL_BLUE_BITS, BUFFER_INT(Visual.blueBits), extra_new_buffers }, - { GL_COLOR_CLEAR_VALUE, LOC_CUSTOM, TYPE_FLOATN_4, 0, extra_new_frag_clamp }, - { 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.Blend[0].SrcRGB), NO_EXTRA }, - { GL_BLEND_DST_RGB_EXT, CONTEXT_ENUM(Color.Blend[0].DstRGB), NO_EXTRA }, - { GL_BLEND_SRC_ALPHA_EXT, CONTEXT_ENUM(Color.Blend[0].SrcA), NO_EXTRA }, - { GL_BLEND_DST_ALPHA_EXT, CONTEXT_ENUM(Color.Blend[0].DstA), 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.Blend[0].EquationRGB), NO_EXTRA }, - { GL_BLEND_EQUATION_ALPHA_EXT, CONTEXT_ENUM(Color.Blend[0].EquationA), 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, LOC_CUSTOM, TYPE_FLOATN, 0, extra_new_frag_clamp }, - { GL_BLEND_DST, CONTEXT_ENUM(Color.Blend[0].DstRGB), 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, LOC_CUSTOM, TYPE_FLOATN_4, 0, extra_new_frag_clamp }, - { 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_BOOL(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_INT, offsetof(struct gl_client_array, Size), NO_EXTRA }, - { GL_TEXTURE_COORD_ARRAY_TYPE, - LOC_CUSTOM, TYPE_ENUM, offsetof(struct gl_client_array, Type), NO_EXTRA }, - { GL_TEXTURE_COORD_ARRAY_STRIDE, - LOC_CUSTOM, TYPE_INT, offsetof(struct gl_client_array, Stride), NO_EXTRA }, - - /* GL_ARB_ES2_compatibility */ - { GL_SHADER_COMPILER, CONST(1), extra_ARB_ES2_compatibility }, - { GL_MAX_VARYING_VECTORS, CONTEXT_INT(Const.MaxVarying), - extra_ARB_ES2_compatibility }, - { GL_MAX_VERTEX_UNIFORM_VECTORS, LOC_CUSTOM, TYPE_INT, 0, - extra_ARB_ES2_compatibility }, - { GL_MAX_FRAGMENT_UNIFORM_VECTORS, LOC_CUSTOM, TYPE_INT, 0, - extra_ARB_ES2_compatibility }, - - /* 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, LOC_CUSTOM, TYPE_FLOATN_4, 0, extra_new_frag_clamp }, - /* 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_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_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_ENUM(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.MaxGeometryTextureImageUnits), - extra_ARB_geometry_shader4 }, - { GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB, - CONTEXT_INT(Const.MaxGeometryOutputVertices), - extra_ARB_geometry_shader4 }, - { GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB, - CONTEXT_INT(Const.MaxGeometryTotalOutputComponents), - extra_ARB_geometry_shader4 }, - { GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB, - CONTEXT_INT(Const.GeometryProgram.MaxUniformComponents), - extra_ARB_geometry_shader4 }, - { GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB, - CONTEXT_INT(Const.MaxGeometryVaryingComponents), - extra_ARB_geometry_shader4 }, - { GL_MAX_VERTEX_VARYING_COMPONENTS_ARB, - CONTEXT_INT(Const.MaxVertexVaryingComponents), - extra_ARB_geometry_shader4 }, - - /* GL_ARB_color_buffer_float */ - { GL_RGBA_FLOAT_MODE_ARB, BUFFER_FIELD(Visual.floatMode, TYPE_BOOLEAN), 0 }, - - /* 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_ARB_texture_buffer_object */ - { GL_MAX_TEXTURE_BUFFER_SIZE_ARB, CONTEXT_INT(Const.MaxTextureBufferSize), - extra_ARB_texture_buffer_object }, - { GL_TEXTURE_BINDING_BUFFER_ARB, LOC_CUSTOM, TYPE_INT, 0, - extra_ARB_texture_buffer_object }, - { GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB, LOC_CUSTOM, TYPE_INT, - TEXTURE_BUFFER_INDEX, extra_ARB_texture_buffer_object }, - { GL_TEXTURE_BUFFER_FORMAT_ARB, LOC_CUSTOM, TYPE_INT, 0, - extra_ARB_texture_buffer_object }, - { GL_TEXTURE_BUFFER_ARB, LOC_CUSTOM, TYPE_INT, 0, - extra_ARB_texture_buffer_object }, - - /* GL_ARB_sampler_objects / GL 3.3 */ - { GL_SAMPLER_BINDING, - LOC_CUSTOM, TYPE_INT, GL_SAMPLER_BINDING, extra_ARB_sampler_objects }, - - /* 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 }, - - /* GL3.0 / GL_EXT_framebuffer_sRGB */ - { GL_FRAMEBUFFER_SRGB_EXT, CONTEXT_BOOL(Color.sRGBEnabled), extra_EXT_framebuffer_sRGB }, - { GL_FRAMEBUFFER_SRGB_CAPABLE_EXT, BUFFER_INT(Visual.sRGBCapable), extra_EXT_framebuffer_sRGB }, - - /* 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 }, - - /* GL_ARB_robustness */ - { GL_RESET_NOTIFICATION_STRATEGY_ARB, CONTEXT_ENUM(Const.ResetStrategy), NO_EXTRA }, -#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); - break; - case GL_COMPRESSED_TEXTURE_FORMATS_ARB: - v->value_int_n.n = - _mesa_get_compressed_formats(ctx, v->value_int_n.ints); - 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_FOG_COLOR: - if(ctx->Color._ClampFragmentColor) - COPY_4FV(v->value_float_4, ctx->Fog.Color); - else - COPY_4FV(v->value_float_4, ctx->Fog.ColorUnclamped); - break; - case GL_COLOR_CLEAR_VALUE: - if(ctx->Color._ClampFragmentColor) - COPY_4FV(v->value_float_4, ctx->Color.ClearColor); - else - COPY_4FV(v->value_float_4, ctx->Color.ClearColorUnclamped); - break; - case GL_BLEND_COLOR_EXT: - if(ctx->Color._ClampFragmentColor) - COPY_4FV(v->value_float_4, ctx->Color.BlendColor); - else - COPY_4FV(v->value_float_4, ctx->Color.BlendColorUnclamped); - break; - case GL_ALPHA_TEST_REF: - if(ctx->Color._ClampFragmentColor) - v->value_float = ctx->Color.AlphaRef; - else - v->value_float = ctx->Color.AlphaRefUnclamped; - 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; - - /* GL_ARB_texture_buffer_object */ - case GL_TEXTURE_BUFFER_ARB: - v->value_int = ctx->Texture.BufferObject->Name; - break; - case GL_TEXTURE_BINDING_BUFFER_ARB: - unit = ctx->Texture.CurrentUnit; - v->value_int = - ctx->Texture.Unit[unit].CurrentTex[TEXTURE_BUFFER_INDEX]->Name; - break; - case GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB: - { - struct gl_buffer_object *buf = - ctx->Texture.Unit[ctx->Texture.CurrentUnit] - .CurrentTex[TEXTURE_BUFFER_INDEX]->BufferObject; - v->value_int = buf ? buf->Name : 0; - } - break; - case GL_TEXTURE_BUFFER_FORMAT_ARB: - v->value_int = ctx->Texture.Unit[ctx->Texture.CurrentUnit] - .CurrentTex[TEXTURE_BUFFER_INDEX]->BufferObjectFormat; - break; - - /* GL_ARB_sampler_objects */ - case GL_SAMPLER_BINDING: - { - struct gl_sampler_object *samp = - ctx->Texture.Unit[ctx->Texture.CurrentUnit].Sampler; - v->value_int = samp ? samp->Name : 0; - } - 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_NEW_FRAG_CLAMP: - if (ctx->NewState & (_NEW_BUFFERS | _NEW_FRAG_CLAMP)) - _mesa_update_state(ctx); - 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_BLEND_SRC: - /* fall-through */ - case GL_BLEND_SRC_RGB: - if (index >= ctx->Const.MaxDrawBuffers) - goto invalid_value; - if (!ctx->Extensions.ARB_draw_buffers_blend) - goto invalid_enum; - v->value_int = ctx->Color.Blend[index].SrcRGB; - return TYPE_INT; - case GL_BLEND_SRC_ALPHA: - if (index >= ctx->Const.MaxDrawBuffers) - goto invalid_value; - if (!ctx->Extensions.ARB_draw_buffers_blend) - goto invalid_enum; - v->value_int = ctx->Color.Blend[index].SrcA; - return TYPE_INT; - case GL_BLEND_DST: - /* fall-through */ - case GL_BLEND_DST_RGB: - if (index >= ctx->Const.MaxDrawBuffers) - goto invalid_value; - if (!ctx->Extensions.ARB_draw_buffers_blend) - goto invalid_enum; - v->value_int = ctx->Color.Blend[index].DstRGB; - return TYPE_INT; - case GL_BLEND_DST_ALPHA: - if (index >= ctx->Const.MaxDrawBuffers) - goto invalid_value; - if (!ctx->Extensions.ARB_draw_buffers_blend) - goto invalid_enum; - v->value_int = ctx->Color.Blend[index].DstA; - return TYPE_INT; - case GL_BLEND_EQUATION_RGB: - if (index >= ctx->Const.MaxDrawBuffers) - goto invalid_value; - if (!ctx->Extensions.ARB_draw_buffers_blend) - goto invalid_enum; - v->value_int = ctx->Color.Blend[index].EquationRGB; - return TYPE_INT; - case GL_BLEND_EQUATION_ALPHA: - if (index >= ctx->Const.MaxDrawBuffers) - goto invalid_value; - if (!ctx->Extensions.ARB_draw_buffers_blend) - goto invalid_enum; - v->value_int = ctx->Color.Blend[index].EquationA; - 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; - enum value_type type = - find_value_indexed("glGetBooleanIndexedv", pname, index, &v); - - switch (type) { - 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: - ; /* nothing - GL error was recorded */ - } -} - -void GLAPIENTRY -_mesa_GetIntegerIndexedv( GLenum pname, GLuint index, GLint *params ) -{ - union value v; - enum value_type type = - find_value_indexed("glGetIntegerIndexedv", pname, index, &v); - - switch (type) { - 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: - ; /* nothing - GL error was recorded */ - } -} - -#if FEATURE_ARB_sync -void GLAPIENTRY -_mesa_GetInteger64Indexedv( GLenum pname, GLuint index, GLint64 *params ) -{ - union value v; - enum value_type type = - find_value_indexed("glGetIntegerIndexedv", pname, index, &v); - - switch (type) { - 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: - ; /* nothing - GL error was recorded */ - } -} -#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 +/* + * 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 + */ + +#include "glheader.h" +#include "context.h" +#include "enable.h" +#include "enums.h" +#include "extensions.h" +#include "get.h" +#include "macros.h" +#include "mfeatures.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_NEW_FRAG_CLAMP, + 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_new_frag_clamp[] = { + EXTRA_NEW_FRAG_CLAMP, + 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 +}; + +static const int extra_ARB_sampler_objects[] = { + EXT(ARB_sampler_objects), + EXTRA_END +}; + + +EXTRA_EXT(ARB_ES2_compatibility); +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(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); +EXTRA_EXT(EXT_framebuffer_sRGB); +EXTRA_EXT(ARB_texture_buffer_object); + +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.Blend[0].SrcRGB), NO_EXTRA }, + { GL_BLUE_BITS, BUFFER_INT(Visual.blueBits), extra_new_buffers }, + { GL_COLOR_CLEAR_VALUE, LOC_CUSTOM, TYPE_FLOATN_4, 0, extra_new_frag_clamp }, + { 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.Blend[0].SrcRGB), NO_EXTRA }, + { GL_BLEND_DST_RGB_EXT, CONTEXT_ENUM(Color.Blend[0].DstRGB), NO_EXTRA }, + { GL_BLEND_SRC_ALPHA_EXT, CONTEXT_ENUM(Color.Blend[0].SrcA), NO_EXTRA }, + { GL_BLEND_DST_ALPHA_EXT, CONTEXT_ENUM(Color.Blend[0].DstA), 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.Blend[0].EquationRGB), NO_EXTRA }, + { GL_BLEND_EQUATION_ALPHA_EXT, CONTEXT_ENUM(Color.Blend[0].EquationA), 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, LOC_CUSTOM, TYPE_FLOATN, 0, extra_new_frag_clamp }, + { GL_BLEND_DST, CONTEXT_ENUM(Color.Blend[0].DstRGB), 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, LOC_CUSTOM, TYPE_FLOATN_4, 0, extra_new_frag_clamp }, + { 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_BOOL(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_INT, offsetof(struct gl_client_array, Size), NO_EXTRA }, + { GL_TEXTURE_COORD_ARRAY_TYPE, + LOC_CUSTOM, TYPE_ENUM, offsetof(struct gl_client_array, Type), NO_EXTRA }, + { GL_TEXTURE_COORD_ARRAY_STRIDE, + LOC_CUSTOM, TYPE_INT, offsetof(struct gl_client_array, Stride), NO_EXTRA }, + + /* GL_ARB_ES2_compatibility */ + { GL_SHADER_COMPILER, CONST(1), extra_ARB_ES2_compatibility }, + { GL_MAX_VARYING_VECTORS, CONTEXT_INT(Const.MaxVarying), + extra_ARB_ES2_compatibility }, + { GL_MAX_VERTEX_UNIFORM_VECTORS, LOC_CUSTOM, TYPE_INT, 0, + extra_ARB_ES2_compatibility }, + { GL_MAX_FRAGMENT_UNIFORM_VECTORS, LOC_CUSTOM, TYPE_INT, 0, + extra_ARB_ES2_compatibility }, + + /* 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, LOC_CUSTOM, TYPE_FLOATN_4, 0, extra_new_frag_clamp }, + /* 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_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_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_ENUM(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.MaxGeometryTextureImageUnits), + extra_ARB_geometry_shader4 }, + { GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB, + CONTEXT_INT(Const.MaxGeometryOutputVertices), + extra_ARB_geometry_shader4 }, + { GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB, + CONTEXT_INT(Const.MaxGeometryTotalOutputComponents), + extra_ARB_geometry_shader4 }, + { GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB, + CONTEXT_INT(Const.GeometryProgram.MaxUniformComponents), + extra_ARB_geometry_shader4 }, + { GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB, + CONTEXT_INT(Const.MaxGeometryVaryingComponents), + extra_ARB_geometry_shader4 }, + { GL_MAX_VERTEX_VARYING_COMPONENTS_ARB, + CONTEXT_INT(Const.MaxVertexVaryingComponents), + extra_ARB_geometry_shader4 }, + + /* GL_ARB_color_buffer_float */ + { GL_RGBA_FLOAT_MODE_ARB, BUFFER_FIELD(Visual.floatMode, TYPE_BOOLEAN), 0 }, + + /* 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_ARB_texture_buffer_object */ + { GL_MAX_TEXTURE_BUFFER_SIZE_ARB, CONTEXT_INT(Const.MaxTextureBufferSize), + extra_ARB_texture_buffer_object }, + { GL_TEXTURE_BINDING_BUFFER_ARB, LOC_CUSTOM, TYPE_INT, 0, + extra_ARB_texture_buffer_object }, + { GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB, LOC_CUSTOM, TYPE_INT, + TEXTURE_BUFFER_INDEX, extra_ARB_texture_buffer_object }, + { GL_TEXTURE_BUFFER_FORMAT_ARB, LOC_CUSTOM, TYPE_INT, 0, + extra_ARB_texture_buffer_object }, + { GL_TEXTURE_BUFFER_ARB, LOC_CUSTOM, TYPE_INT, 0, + extra_ARB_texture_buffer_object }, + + /* GL_ARB_sampler_objects / GL 3.3 */ + { GL_SAMPLER_BINDING, + LOC_CUSTOM, TYPE_INT, GL_SAMPLER_BINDING, extra_ARB_sampler_objects }, + + /* 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 }, + + /* GL3.0 / GL_EXT_framebuffer_sRGB */ + { GL_FRAMEBUFFER_SRGB_EXT, CONTEXT_BOOL(Color.sRGBEnabled), extra_EXT_framebuffer_sRGB }, + { GL_FRAMEBUFFER_SRGB_CAPABLE_EXT, BUFFER_INT(Visual.sRGBCapable), extra_EXT_framebuffer_sRGB }, + + /* 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 }, + + /* GL_ARB_robustness */ + { GL_RESET_NOTIFICATION_STRATEGY_ARB, CONTEXT_ENUM(Const.ResetStrategy), NO_EXTRA }, +#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); + break; + case GL_COMPRESSED_TEXTURE_FORMATS_ARB: + v->value_int_n.n = + _mesa_get_compressed_formats(ctx, v->value_int_n.ints); + 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_FOG_COLOR: + if(ctx->Color._ClampFragmentColor) + COPY_4FV(v->value_float_4, ctx->Fog.Color); + else + COPY_4FV(v->value_float_4, ctx->Fog.ColorUnclamped); + break; + case GL_COLOR_CLEAR_VALUE: + if(ctx->Color._ClampFragmentColor) + COPY_4FV(v->value_float_4, ctx->Color.ClearColor); + else + COPY_4FV(v->value_float_4, ctx->Color.ClearColorUnclamped); + break; + case GL_BLEND_COLOR_EXT: + if(ctx->Color._ClampFragmentColor) + COPY_4FV(v->value_float_4, ctx->Color.BlendColor); + else + COPY_4FV(v->value_float_4, ctx->Color.BlendColorUnclamped); + break; + case GL_ALPHA_TEST_REF: + if(ctx->Color._ClampFragmentColor) + v->value_float = ctx->Color.AlphaRef; + else + v->value_float = ctx->Color.AlphaRefUnclamped; + 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; + + /* GL_ARB_texture_buffer_object */ + case GL_TEXTURE_BUFFER_ARB: + v->value_int = ctx->Texture.BufferObject->Name; + break; + case GL_TEXTURE_BINDING_BUFFER_ARB: + unit = ctx->Texture.CurrentUnit; + v->value_int = + ctx->Texture.Unit[unit].CurrentTex[TEXTURE_BUFFER_INDEX]->Name; + break; + case GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB: + { + struct gl_buffer_object *buf = + ctx->Texture.Unit[ctx->Texture.CurrentUnit] + .CurrentTex[TEXTURE_BUFFER_INDEX]->BufferObject; + v->value_int = buf ? buf->Name : 0; + } + break; + case GL_TEXTURE_BUFFER_FORMAT_ARB: + v->value_int = ctx->Texture.Unit[ctx->Texture.CurrentUnit] + .CurrentTex[TEXTURE_BUFFER_INDEX]->BufferObjectFormat; + break; + + /* GL_ARB_sampler_objects */ + case GL_SAMPLER_BINDING: + { + struct gl_sampler_object *samp = + ctx->Texture.Unit[ctx->Texture.CurrentUnit].Sampler; + v->value_int = samp ? samp->Name : 0; + } + 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_NEW_FRAG_CLAMP: + if (ctx->NewState & (_NEW_BUFFERS | _NEW_FRAG_CLAMP)) + _mesa_update_state(ctx); + 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_BLEND_SRC: + /* fall-through */ + case GL_BLEND_SRC_RGB: + if (index >= ctx->Const.MaxDrawBuffers) + goto invalid_value; + if (!ctx->Extensions.ARB_draw_buffers_blend) + goto invalid_enum; + v->value_int = ctx->Color.Blend[index].SrcRGB; + return TYPE_INT; + case GL_BLEND_SRC_ALPHA: + if (index >= ctx->Const.MaxDrawBuffers) + goto invalid_value; + if (!ctx->Extensions.ARB_draw_buffers_blend) + goto invalid_enum; + v->value_int = ctx->Color.Blend[index].SrcA; + return TYPE_INT; + case GL_BLEND_DST: + /* fall-through */ + case GL_BLEND_DST_RGB: + if (index >= ctx->Const.MaxDrawBuffers) + goto invalid_value; + if (!ctx->Extensions.ARB_draw_buffers_blend) + goto invalid_enum; + v->value_int = ctx->Color.Blend[index].DstRGB; + return TYPE_INT; + case GL_BLEND_DST_ALPHA: + if (index >= ctx->Const.MaxDrawBuffers) + goto invalid_value; + if (!ctx->Extensions.ARB_draw_buffers_blend) + goto invalid_enum; + v->value_int = ctx->Color.Blend[index].DstA; + return TYPE_INT; + case GL_BLEND_EQUATION_RGB: + if (index >= ctx->Const.MaxDrawBuffers) + goto invalid_value; + if (!ctx->Extensions.ARB_draw_buffers_blend) + goto invalid_enum; + v->value_int = ctx->Color.Blend[index].EquationRGB; + return TYPE_INT; + case GL_BLEND_EQUATION_ALPHA: + if (index >= ctx->Const.MaxDrawBuffers) + goto invalid_value; + if (!ctx->Extensions.ARB_draw_buffers_blend) + goto invalid_enum; + v->value_int = ctx->Color.Blend[index].EquationA; + 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; + enum value_type type = + find_value_indexed("glGetBooleanIndexedv", pname, index, &v); + + switch (type) { + 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: + ; /* nothing - GL error was recorded */ + } +} + +void GLAPIENTRY +_mesa_GetIntegerIndexedv( GLenum pname, GLuint index, GLint *params ) +{ + union value v; + enum value_type type = + find_value_indexed("glGetIntegerIndexedv", pname, index, &v); + + switch (type) { + 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: + ; /* nothing - GL error was recorded */ + } +} + +#if FEATURE_ARB_sync +void GLAPIENTRY +_mesa_GetInteger64Indexedv( GLenum pname, GLuint index, GLint64 *params ) +{ + union value v; + enum value_type type = + find_value_indexed("glGetIntegerIndexedv", pname, index, &v); + + switch (type) { + 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: + ; /* nothing - GL error was recorded */ + } +} +#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/mesalib/src/mesa/main/get.h b/mesalib/src/mesa/main/get.h index 3907e176b..9422efec5 100644 --- a/mesalib/src/mesa/main/get.h +++ b/mesalib/src/mesa/main/get.h @@ -1,81 +1,81 @@ -/** - * \file get.h - * State query functions. - */ - -/* - * Mesa 3-D graphics library - * Version: 3.5 - * - * Copyright (C) 1999-2001 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. - */ - - -#ifndef GET_H -#define GET_H - - -#include "glheader.h" - - -extern void GLAPIENTRY -_mesa_GetBooleanv( GLenum pname, GLboolean *params ); - -extern void GLAPIENTRY -_mesa_GetDoublev( GLenum pname, GLdouble *params ); - -extern void GLAPIENTRY -_mesa_GetFloatv( GLenum pname, GLfloat *params ); - -extern void GLAPIENTRY -_mesa_GetIntegerv( GLenum pname, GLint *params ); - -extern void GLAPIENTRY -_mesa_GetInteger64v( GLenum pname, GLint64 *params ); - -extern void GLAPIENTRY -_mesa_GetFixedv(GLenum pname, GLfixed *params); - -extern void GLAPIENTRY -_mesa_GetBooleanIndexedv( GLenum pname, GLuint index, GLboolean *params ); - -extern void GLAPIENTRY -_mesa_GetIntegerIndexedv( GLenum pname, GLuint index, GLint *params ); - -extern void GLAPIENTRY -_mesa_GetInteger64Indexedv( GLenum pname, GLuint index, GLint64 *params ); - -extern void GLAPIENTRY -_mesa_GetPointerv( GLenum pname, GLvoid **params ); - -extern const GLubyte * GLAPIENTRY -_mesa_GetString( GLenum name ); - -extern const GLubyte * GLAPIENTRY -_mesa_GetStringi(GLenum name, GLuint index); - -extern GLenum GLAPIENTRY -_mesa_GetError( void ); - -/* GL_ARB_robustness */ -extern GLenum GLAPIENTRY -_mesa_GetGraphicsResetStatusARB( void ); - -#endif +/** + * \file get.h + * State query functions. + */ + +/* + * Mesa 3-D graphics library + * Version: 3.5 + * + * Copyright (C) 1999-2001 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. + */ + + +#ifndef GET_H +#define GET_H + + +#include "glheader.h" + + +extern void GLAPIENTRY +_mesa_GetBooleanv( GLenum pname, GLboolean *params ); + +extern void GLAPIENTRY +_mesa_GetDoublev( GLenum pname, GLdouble *params ); + +extern void GLAPIENTRY +_mesa_GetFloatv( GLenum pname, GLfloat *params ); + +extern void GLAPIENTRY +_mesa_GetIntegerv( GLenum pname, GLint *params ); + +extern void GLAPIENTRY +_mesa_GetInteger64v( GLenum pname, GLint64 *params ); + +extern void GLAPIENTRY +_mesa_GetFixedv(GLenum pname, GLfixed *params); + +extern void GLAPIENTRY +_mesa_GetBooleanIndexedv( GLenum pname, GLuint index, GLboolean *params ); + +extern void GLAPIENTRY +_mesa_GetIntegerIndexedv( GLenum pname, GLuint index, GLint *params ); + +extern void GLAPIENTRY +_mesa_GetInteger64Indexedv( GLenum pname, GLuint index, GLint64 *params ); + +extern void GLAPIENTRY +_mesa_GetPointerv( GLenum pname, GLvoid **params ); + +extern const GLubyte * GLAPIENTRY +_mesa_GetString( GLenum name ); + +extern const GLubyte * GLAPIENTRY +_mesa_GetStringi(GLenum name, GLuint index); + +extern GLenum GLAPIENTRY +_mesa_GetError( void ); + +/* GL_ARB_robustness */ +extern GLenum GLAPIENTRY +_mesa_GetGraphicsResetStatusARB( void ); + +#endif diff --git a/mesalib/src/mesa/main/getstring.c b/mesalib/src/mesa/main/getstring.c index 2052cbc6c..c381fb2df 100644 --- a/mesalib/src/mesa/main/getstring.c +++ b/mesalib/src/mesa/main/getstring.c @@ -1,270 +1,270 @@ -/* - * 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" -#include "mfeatures.h" -#include "mtypes.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; -} - -/** - * Returns an error code specified by GL_ARB_robustness, or GL_NO_ERROR. - * \return current context status - */ -GLenum GLAPIENTRY -_mesa_GetGraphicsResetStatusARB( void ) -{ - GET_CURRENT_CONTEXT(ctx); - GLenum status = ctx->ResetStatus; - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glGetGraphicsResetStatusARB" - "(always returns GL_NO_ERROR)\n"); - - return status; -} +/* + * 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" +#include "mfeatures.h" +#include "mtypes.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; +} + +/** + * Returns an error code specified by GL_ARB_robustness, or GL_NO_ERROR. + * \return current context status + */ +GLenum GLAPIENTRY +_mesa_GetGraphicsResetStatusARB( void ) +{ + GET_CURRENT_CONTEXT(ctx); + GLenum status = ctx->ResetStatus; + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glGetGraphicsResetStatusARB" + "(always returns GL_NO_ERROR)\n"); + + return status; +} diff --git a/mesalib/src/mesa/main/glheader.h b/mesalib/src/mesa/main/glheader.h index dc78ccbf6..0df811986 100644 --- a/mesalib/src/mesa/main/glheader.h +++ b/mesalib/src/mesa/main/glheader.h @@ -1,167 +1,167 @@ -/* - * Mesa 3-D graphics library - * Version: 7.5 - * - * 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 glheader.h - * Wrapper for GL/gl.h and GL/glext.h - */ - - -#ifndef GLHEADER_H -#define GLHEADER_H - - -#ifdef WGLAPI -#undef WGLAPI -#endif - - -#if !defined(OPENSTEP) && (defined(__WIN32__) && !defined(__CYGWIN__)) && !defined(BUILD_FOR_SNAP) -# if (defined(_MSC_VER) || defined(__MINGW32__)) && defined(BUILD_GL32) /* tag specify we're building mesa as a DLL */ -# define WGLAPI __declspec(dllexport) -# elif (defined(_MSC_VER) || defined(__MINGW32__)) && defined(_DLL) /* tag specifying we're building for DLL runtime support */ -# define WGLAPI __declspec(dllimport) -# else /* for use with static link lib build of Win32 edition only */ -# define WGLAPI __declspec(dllimport) -# endif /* _STATIC_MESA support */ -#endif /* WIN32 / CYGWIN bracket */ - - -#define GL_GLEXT_PROTOTYPES -#include "GL/gl.h" -#include "GL/glext.h" - - -/** - * GL_FIXED is defined in glext.h version 64 but these typedefs aren't (yet). - */ -typedef int GLfixed; -typedef int GLclampx; - - -#ifndef GL_OES_EGL_image -typedef void *GLeglImageOES; -#endif - - -#ifndef GL_OES_point_size_array -#define GL_POINT_SIZE_ARRAY_OES 0x8B9C -#define GL_POINT_SIZE_ARRAY_TYPE_OES 0x898A -#define GL_POINT_SIZE_ARRAY_STRIDE_OES 0x898B -#define GL_POINT_SIZE_ARRAY_POINTER_OES 0x898C -#define GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES 0x8B9F -#endif - - -#ifndef GL_OES_draw_texture -#define GL_TEXTURE_CROP_RECT_OES 0x8B9D -#endif - - -#ifndef GL_PROGRAM_BINARY_LENGTH_OES -#define GL_PROGRAM_BINARY_LENGTH_OES 0x8741 -#endif - -/* GLES 2.0 tokens */ -#ifndef GL_RGB565 -#define GL_RGB565 0x8D62 -#endif - -#ifndef GL_TEXTURE_GEN_STR_OES -#define GL_TEXTURE_GEN_STR_OES 0x8D60 -#endif - -#ifndef GL_OES_compressed_paletted_texture -#define GL_PALETTE4_RGB8_OES 0x8B90 -#define GL_PALETTE4_RGBA8_OES 0x8B91 -#define GL_PALETTE4_R5_G6_B5_OES 0x8B92 -#define GL_PALETTE4_RGBA4_OES 0x8B93 -#define GL_PALETTE4_RGB5_A1_OES 0x8B94 -#define GL_PALETTE8_RGB8_OES 0x8B95 -#define GL_PALETTE8_RGBA8_OES 0x8B96 -#define GL_PALETTE8_R5_G6_B5_OES 0x8B97 -#define GL_PALETTE8_RGBA4_OES 0x8B98 -#define GL_PALETTE8_RGB5_A1_OES 0x8B99 -#endif - -#ifndef GL_OES_matrix_get -#define GL_MODELVIEW_MATRIX_FLOAT_AS_INT_BITS_OES 0x898D -#define GL_PROJECTION_MATRIX_FLOAT_AS_INT_BITS_OES 0x898E -#define GL_TEXTURE_MATRIX_FLOAT_AS_INT_BITS_OES 0x898F -#endif - -#ifndef GL_ES_VERSION_2_0 -#define GL_SHADER_BINARY_FORMATS 0x8DF8 -#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 -#define GL_SHADER_COMPILER 0x8DFA -#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB -#define GL_MAX_VARYING_VECTORS 0x8DFC -#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD -#endif - -#ifndef GL_ATI_texture_compression_3dc -#define GL_ATI_texture_compression_3dc 1 -#define GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI 0x8837 -#endif - - -/** - * Internal token to represent a GLSL shader program (a collection of - * one or more shaders that get linked together). Note that GLSL - * shaders and shader programs share one name space (one hash table) - * so we need a value that's different from any of the - * GL_VERTEX/FRAGMENT/GEOMETRY_PROGRAM tokens. - */ -#define GL_SHADER_PROGRAM_MESA 0x9999 - - -/** - * Internal token for geometry programs. - * Use the value for GL_GEOMETRY_PROGRAM_NV for now. - */ -#define MESA_GEOMETRY_PROGRAM 0x8c26 - -/* Several fields of struct gl_config can take these as values. Since - * GLX header files may not be available everywhere they need to be used, - * redefine them here. - */ -#define GLX_NONE 0x8000 -#define GLX_SLOW_CONFIG 0x8001 -#define GLX_TRUE_COLOR 0x8002 -#define GLX_DIRECT_COLOR 0x8003 -#define GLX_PSEUDO_COLOR 0x8004 -#define GLX_STATIC_COLOR 0x8005 -#define GLX_GRAY_SCALE 0x8006 -#define GLX_STATIC_GRAY 0x8007 -#define GLX_TRANSPARENT_RGB 0x8008 -#define GLX_TRANSPARENT_INDEX 0x8009 -#define GLX_NON_CONFORMANT_CONFIG 0x800D -#define GLX_SWAP_EXCHANGE_OML 0x8061 -#define GLX_SWAP_COPY_OML 0x8062 -#define GLX_SWAP_UNDEFINED_OML 0x8063 - -#define GLX_DONT_CARE 0xFFFFFFFF - -#endif /* GLHEADER_H */ +/* + * Mesa 3-D graphics library + * Version: 7.5 + * + * 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 glheader.h + * Wrapper for GL/gl.h and GL/glext.h + */ + + +#ifndef GLHEADER_H +#define GLHEADER_H + + +#ifdef WGLAPI +#undef WGLAPI +#endif + + +#if !defined(OPENSTEP) && (defined(__WIN32__) && !defined(__CYGWIN__)) && !defined(BUILD_FOR_SNAP) +# if (defined(_MSC_VER) || defined(__MINGW32__)) && defined(BUILD_GL32) /* tag specify we're building mesa as a DLL */ +# define WGLAPI __declspec(dllexport) +# elif (defined(_MSC_VER) || defined(__MINGW32__)) && defined(_DLL) /* tag specifying we're building for DLL runtime support */ +# define WGLAPI __declspec(dllimport) +# else /* for use with static link lib build of Win32 edition only */ +# define WGLAPI __declspec(dllimport) +# endif /* _STATIC_MESA support */ +#endif /* WIN32 / CYGWIN bracket */ + + +#define GL_GLEXT_PROTOTYPES +#include "GL/gl.h" +#include "GL/glext.h" + + +/** + * GL_FIXED is defined in glext.h version 64 but these typedefs aren't (yet). + */ +typedef int GLfixed; +typedef int GLclampx; + + +#ifndef GL_OES_EGL_image +typedef void *GLeglImageOES; +#endif + + +#ifndef GL_OES_point_size_array +#define GL_POINT_SIZE_ARRAY_OES 0x8B9C +#define GL_POINT_SIZE_ARRAY_TYPE_OES 0x898A +#define GL_POINT_SIZE_ARRAY_STRIDE_OES 0x898B +#define GL_POINT_SIZE_ARRAY_POINTER_OES 0x898C +#define GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES 0x8B9F +#endif + + +#ifndef GL_OES_draw_texture +#define GL_TEXTURE_CROP_RECT_OES 0x8B9D +#endif + + +#ifndef GL_PROGRAM_BINARY_LENGTH_OES +#define GL_PROGRAM_BINARY_LENGTH_OES 0x8741 +#endif + +/* GLES 2.0 tokens */ +#ifndef GL_RGB565 +#define GL_RGB565 0x8D62 +#endif + +#ifndef GL_TEXTURE_GEN_STR_OES +#define GL_TEXTURE_GEN_STR_OES 0x8D60 +#endif + +#ifndef GL_OES_compressed_paletted_texture +#define GL_PALETTE4_RGB8_OES 0x8B90 +#define GL_PALETTE4_RGBA8_OES 0x8B91 +#define GL_PALETTE4_R5_G6_B5_OES 0x8B92 +#define GL_PALETTE4_RGBA4_OES 0x8B93 +#define GL_PALETTE4_RGB5_A1_OES 0x8B94 +#define GL_PALETTE8_RGB8_OES 0x8B95 +#define GL_PALETTE8_RGBA8_OES 0x8B96 +#define GL_PALETTE8_R5_G6_B5_OES 0x8B97 +#define GL_PALETTE8_RGBA4_OES 0x8B98 +#define GL_PALETTE8_RGB5_A1_OES 0x8B99 +#endif + +#ifndef GL_OES_matrix_get +#define GL_MODELVIEW_MATRIX_FLOAT_AS_INT_BITS_OES 0x898D +#define GL_PROJECTION_MATRIX_FLOAT_AS_INT_BITS_OES 0x898E +#define GL_TEXTURE_MATRIX_FLOAT_AS_INT_BITS_OES 0x898F +#endif + +#ifndef GL_ES_VERSION_2_0 +#define GL_SHADER_BINARY_FORMATS 0x8DF8 +#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 +#define GL_SHADER_COMPILER 0x8DFA +#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB +#define GL_MAX_VARYING_VECTORS 0x8DFC +#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD +#endif + +#ifndef GL_ATI_texture_compression_3dc +#define GL_ATI_texture_compression_3dc 1 +#define GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI 0x8837 +#endif + + +/** + * Internal token to represent a GLSL shader program (a collection of + * one or more shaders that get linked together). Note that GLSL + * shaders and shader programs share one name space (one hash table) + * so we need a value that's different from any of the + * GL_VERTEX/FRAGMENT/GEOMETRY_PROGRAM tokens. + */ +#define GL_SHADER_PROGRAM_MESA 0x9999 + + +/** + * Internal token for geometry programs. + * Use the value for GL_GEOMETRY_PROGRAM_NV for now. + */ +#define MESA_GEOMETRY_PROGRAM 0x8c26 + +/* Several fields of struct gl_config can take these as values. Since + * GLX header files may not be available everywhere they need to be used, + * redefine them here. + */ +#define GLX_NONE 0x8000 +#define GLX_SLOW_CONFIG 0x8001 +#define GLX_TRUE_COLOR 0x8002 +#define GLX_DIRECT_COLOR 0x8003 +#define GLX_PSEUDO_COLOR 0x8004 +#define GLX_STATIC_COLOR 0x8005 +#define GLX_GRAY_SCALE 0x8006 +#define GLX_STATIC_GRAY 0x8007 +#define GLX_TRANSPARENT_RGB 0x8008 +#define GLX_TRANSPARENT_INDEX 0x8009 +#define GLX_NON_CONFORMANT_CONFIG 0x800D +#define GLX_SWAP_EXCHANGE_OML 0x8061 +#define GLX_SWAP_COPY_OML 0x8062 +#define GLX_SWAP_UNDEFINED_OML 0x8063 + +#define GLX_DONT_CARE 0xFFFFFFFF + +#endif /* GLHEADER_H */ diff --git a/mesalib/src/mesa/main/hint.c b/mesalib/src/mesa/main/hint.c index aea0d7022..ff8d88fff 100644 --- a/mesalib/src/mesa/main/hint.c +++ b/mesalib/src/mesa/main/hint.c @@ -1,147 +1,147 @@ - -/* - * Mesa 3-D graphics library - * Version: 4.1 - * - * Copyright (C) 1999-2002 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 "enums.h" -#include "context.h" -#include "hint.h" -#include "imports.h" -#include "mtypes.h" - - - -void GLAPIENTRY -_mesa_Hint( GLenum target, GLenum mode ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glHint %s %s\n", - _mesa_lookup_enum_by_nr(target), - _mesa_lookup_enum_by_nr(mode)); - - if (mode != GL_NICEST && mode != GL_FASTEST && mode != GL_DONT_CARE) { - _mesa_error(ctx, GL_INVALID_ENUM, "glHint(mode)"); - return; - } - - switch (target) { - case GL_FOG_HINT: - if (ctx->Hint.Fog == mode) - return; - FLUSH_VERTICES(ctx, _NEW_HINT); - ctx->Hint.Fog = mode; - break; - case GL_LINE_SMOOTH_HINT: - if (ctx->Hint.LineSmooth == mode) - return; - FLUSH_VERTICES(ctx, _NEW_HINT); - ctx->Hint.LineSmooth = mode; - break; - case GL_PERSPECTIVE_CORRECTION_HINT: - if (ctx->Hint.PerspectiveCorrection == mode) - return; - FLUSH_VERTICES(ctx, _NEW_HINT); - ctx->Hint.PerspectiveCorrection = mode; - break; - case GL_POINT_SMOOTH_HINT: - if (ctx->Hint.PointSmooth == mode) - return; - FLUSH_VERTICES(ctx, _NEW_HINT); - ctx->Hint.PointSmooth = mode; - break; - case GL_POLYGON_SMOOTH_HINT: - if (ctx->Hint.PolygonSmooth == mode) - return; - FLUSH_VERTICES(ctx, _NEW_HINT); - ctx->Hint.PolygonSmooth = mode; - break; - - /* GL_EXT_clip_volume_hint */ - case GL_CLIP_VOLUME_CLIPPING_HINT_EXT: - if (ctx->Hint.ClipVolumeClipping == mode) - return; - FLUSH_VERTICES(ctx, _NEW_HINT); - ctx->Hint.ClipVolumeClipping = mode; - break; - - /* GL_ARB_texture_compression */ - case GL_TEXTURE_COMPRESSION_HINT_ARB: - if (ctx->Hint.TextureCompression == mode) - return; - FLUSH_VERTICES(ctx, _NEW_HINT); - ctx->Hint.TextureCompression = mode; - break; - - /* GL_SGIS_generate_mipmap */ - case GL_GENERATE_MIPMAP_HINT_SGIS: - if (ctx->Hint.GenerateMipmap == mode) - return; - FLUSH_VERTICES(ctx, _NEW_HINT); - ctx->Hint.GenerateMipmap = mode; - break; - - /* GL_ARB_fragment_shader */ - case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB: - if (!ctx->Extensions.ARB_fragment_shader) { - _mesa_error(ctx, GL_INVALID_ENUM, "glHint(target)"); - return; - } - if (ctx->Hint.FragmentShaderDerivative == mode) - return; - FLUSH_VERTICES(ctx, _NEW_HINT); - ctx->Hint.FragmentShaderDerivative = mode; - break; - - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glHint(target)"); - return; - } - - if (ctx->Driver.Hint) { - (*ctx->Driver.Hint)( ctx, target, mode ); - } -} - - -/**********************************************************************/ -/***** Initialization *****/ -/**********************************************************************/ - -void _mesa_init_hint( struct gl_context * ctx ) -{ - /* Hint group */ - ctx->Hint.PerspectiveCorrection = GL_DONT_CARE; - ctx->Hint.PointSmooth = GL_DONT_CARE; - ctx->Hint.LineSmooth = GL_DONT_CARE; - ctx->Hint.PolygonSmooth = GL_DONT_CARE; - ctx->Hint.Fog = GL_DONT_CARE; - ctx->Hint.ClipVolumeClipping = GL_DONT_CARE; - ctx->Hint.TextureCompression = GL_DONT_CARE; - ctx->Hint.GenerateMipmap = GL_DONT_CARE; - ctx->Hint.FragmentShaderDerivative = GL_DONT_CARE; -} + +/* + * Mesa 3-D graphics library + * Version: 4.1 + * + * Copyright (C) 1999-2002 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 "enums.h" +#include "context.h" +#include "hint.h" +#include "imports.h" +#include "mtypes.h" + + + +void GLAPIENTRY +_mesa_Hint( GLenum target, GLenum mode ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glHint %s %s\n", + _mesa_lookup_enum_by_nr(target), + _mesa_lookup_enum_by_nr(mode)); + + if (mode != GL_NICEST && mode != GL_FASTEST && mode != GL_DONT_CARE) { + _mesa_error(ctx, GL_INVALID_ENUM, "glHint(mode)"); + return; + } + + switch (target) { + case GL_FOG_HINT: + if (ctx->Hint.Fog == mode) + return; + FLUSH_VERTICES(ctx, _NEW_HINT); + ctx->Hint.Fog = mode; + break; + case GL_LINE_SMOOTH_HINT: + if (ctx->Hint.LineSmooth == mode) + return; + FLUSH_VERTICES(ctx, _NEW_HINT); + ctx->Hint.LineSmooth = mode; + break; + case GL_PERSPECTIVE_CORRECTION_HINT: + if (ctx->Hint.PerspectiveCorrection == mode) + return; + FLUSH_VERTICES(ctx, _NEW_HINT); + ctx->Hint.PerspectiveCorrection = mode; + break; + case GL_POINT_SMOOTH_HINT: + if (ctx->Hint.PointSmooth == mode) + return; + FLUSH_VERTICES(ctx, _NEW_HINT); + ctx->Hint.PointSmooth = mode; + break; + case GL_POLYGON_SMOOTH_HINT: + if (ctx->Hint.PolygonSmooth == mode) + return; + FLUSH_VERTICES(ctx, _NEW_HINT); + ctx->Hint.PolygonSmooth = mode; + break; + + /* GL_EXT_clip_volume_hint */ + case GL_CLIP_VOLUME_CLIPPING_HINT_EXT: + if (ctx->Hint.ClipVolumeClipping == mode) + return; + FLUSH_VERTICES(ctx, _NEW_HINT); + ctx->Hint.ClipVolumeClipping = mode; + break; + + /* GL_ARB_texture_compression */ + case GL_TEXTURE_COMPRESSION_HINT_ARB: + if (ctx->Hint.TextureCompression == mode) + return; + FLUSH_VERTICES(ctx, _NEW_HINT); + ctx->Hint.TextureCompression = mode; + break; + + /* GL_SGIS_generate_mipmap */ + case GL_GENERATE_MIPMAP_HINT_SGIS: + if (ctx->Hint.GenerateMipmap == mode) + return; + FLUSH_VERTICES(ctx, _NEW_HINT); + ctx->Hint.GenerateMipmap = mode; + break; + + /* GL_ARB_fragment_shader */ + case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB: + if (!ctx->Extensions.ARB_fragment_shader) { + _mesa_error(ctx, GL_INVALID_ENUM, "glHint(target)"); + return; + } + if (ctx->Hint.FragmentShaderDerivative == mode) + return; + FLUSH_VERTICES(ctx, _NEW_HINT); + ctx->Hint.FragmentShaderDerivative = mode; + break; + + default: + _mesa_error(ctx, GL_INVALID_ENUM, "glHint(target)"); + return; + } + + if (ctx->Driver.Hint) { + (*ctx->Driver.Hint)( ctx, target, mode ); + } +} + + +/**********************************************************************/ +/***** Initialization *****/ +/**********************************************************************/ + +void _mesa_init_hint( struct gl_context * ctx ) +{ + /* Hint group */ + ctx->Hint.PerspectiveCorrection = GL_DONT_CARE; + ctx->Hint.PointSmooth = GL_DONT_CARE; + ctx->Hint.LineSmooth = GL_DONT_CARE; + ctx->Hint.PolygonSmooth = GL_DONT_CARE; + ctx->Hint.Fog = GL_DONT_CARE; + ctx->Hint.ClipVolumeClipping = GL_DONT_CARE; + ctx->Hint.TextureCompression = GL_DONT_CARE; + ctx->Hint.GenerateMipmap = GL_DONT_CARE; + ctx->Hint.FragmentShaderDerivative = GL_DONT_CARE; +} diff --git a/mesalib/src/mesa/main/histogram.c b/mesalib/src/mesa/main/histogram.c index feef59dd0..44fc1325c 100644 --- a/mesalib/src/mesa/main/histogram.c +++ b/mesalib/src/mesa/main/histogram.c @@ -1,173 +1,173 @@ -/* - * 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. - */ - - -#include "glheader.h" -#include "bufferobj.h" -#include "colormac.h" -#include "histogram.h" -#include "macros.h" -#include "mfeatures.h" -#include "main/dispatch.h" - - -#if FEATURE_histogram - -/********************************************************************** - * API functions - */ - - -/* this is defined below */ -static void GLAPIENTRY _mesa_ResetMinmax(GLenum target); - - -static void GLAPIENTRY -_mesa_GetnMinmaxARB(GLenum target, GLboolean reset, GLenum format, - GLenum type, GLsizei bufSize, GLvoid *values) -{ - GET_CURRENT_CONTEXT(ctx); - - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetMinmax"); -} - - -static void GLAPIENTRY -_mesa_GetMinmax(GLenum target, GLboolean reset, GLenum format, GLenum type, - GLvoid *values) -{ - _mesa_GetnMinmaxARB(target, reset, format, type, INT_MAX, values); -} - - -static void GLAPIENTRY -_mesa_GetnHistogramARB(GLenum target, GLboolean reset, GLenum format, - GLenum type, GLsizei bufSize, GLvoid *values) -{ - GET_CURRENT_CONTEXT(ctx); - - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetHistogram"); -} - - -static void GLAPIENTRY -_mesa_GetHistogram(GLenum target, GLboolean reset, GLenum format, GLenum type, - GLvoid *values) -{ - _mesa_GetnHistogramARB(target, reset, format, type, INT_MAX, values); -} - - -static void GLAPIENTRY -_mesa_GetHistogramParameterfv(GLenum target, GLenum pname, GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetHistogramParameterfv"); -} - - -static void GLAPIENTRY -_mesa_GetHistogramParameteriv(GLenum target, GLenum pname, GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetHistogramParameteriv"); -} - - -static void GLAPIENTRY -_mesa_GetMinmaxParameterfv(GLenum target, GLenum pname, GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetMinmaxParameterfv"); -} - - -static void GLAPIENTRY -_mesa_GetMinmaxParameteriv(GLenum target, GLenum pname, GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetMinmaxParameteriv"); -} - - -static void GLAPIENTRY -_mesa_Histogram(GLenum target, GLsizei width, GLenum internalFormat, GLboolean sink) -{ - GET_CURRENT_CONTEXT(ctx); - - _mesa_error(ctx, GL_INVALID_OPERATION, "glHistogram"); -} - - -static void GLAPIENTRY -_mesa_Minmax(GLenum target, GLenum internalFormat, GLboolean sink) -{ - GET_CURRENT_CONTEXT(ctx); - - _mesa_error(ctx, GL_INVALID_OPERATION, "glMinmax"); -} - - -static void GLAPIENTRY -_mesa_ResetHistogram(GLenum target) -{ - GET_CURRENT_CONTEXT(ctx); - - _mesa_error(ctx, GL_INVALID_OPERATION, "glResetHistogram"); -} - - -static void GLAPIENTRY -_mesa_ResetMinmax(GLenum target) -{ - GET_CURRENT_CONTEXT(ctx); - - _mesa_error(ctx, GL_INVALID_OPERATION, "glResetMinmax"); -} - - -void -_mesa_init_histogram_dispatch(struct _glapi_table *disp) -{ - SET_GetHistogram(disp, _mesa_GetHistogram); - SET_GetHistogramParameterfv(disp, _mesa_GetHistogramParameterfv); - SET_GetHistogramParameteriv(disp, _mesa_GetHistogramParameteriv); - SET_GetMinmax(disp, _mesa_GetMinmax); - SET_GetMinmaxParameterfv(disp, _mesa_GetMinmaxParameterfv); - SET_GetMinmaxParameteriv(disp, _mesa_GetMinmaxParameteriv); - SET_Histogram(disp, _mesa_Histogram); - SET_Minmax(disp, _mesa_Minmax); - SET_ResetHistogram(disp, _mesa_ResetHistogram); - SET_ResetMinmax(disp, _mesa_ResetMinmax); - - /* GL_ARB_robustness */ - SET_GetnHistogramARB(disp, _mesa_GetnHistogramARB); - SET_GetnMinmaxARB(disp, _mesa_GetnMinmaxARB); -} - -#endif /* FEATURE_histogram */ +/* + * 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. + */ + + +#include "glheader.h" +#include "bufferobj.h" +#include "colormac.h" +#include "histogram.h" +#include "macros.h" +#include "mfeatures.h" +#include "main/dispatch.h" + + +#if FEATURE_histogram + +/********************************************************************** + * API functions + */ + + +/* this is defined below */ +static void GLAPIENTRY _mesa_ResetMinmax(GLenum target); + + +static void GLAPIENTRY +_mesa_GetnMinmaxARB(GLenum target, GLboolean reset, GLenum format, + GLenum type, GLsizei bufSize, GLvoid *values) +{ + GET_CURRENT_CONTEXT(ctx); + + _mesa_error(ctx, GL_INVALID_OPERATION, "glGetMinmax"); +} + + +static void GLAPIENTRY +_mesa_GetMinmax(GLenum target, GLboolean reset, GLenum format, GLenum type, + GLvoid *values) +{ + _mesa_GetnMinmaxARB(target, reset, format, type, INT_MAX, values); +} + + +static void GLAPIENTRY +_mesa_GetnHistogramARB(GLenum target, GLboolean reset, GLenum format, + GLenum type, GLsizei bufSize, GLvoid *values) +{ + GET_CURRENT_CONTEXT(ctx); + + _mesa_error(ctx, GL_INVALID_OPERATION, "glGetHistogram"); +} + + +static void GLAPIENTRY +_mesa_GetHistogram(GLenum target, GLboolean reset, GLenum format, GLenum type, + GLvoid *values) +{ + _mesa_GetnHistogramARB(target, reset, format, type, INT_MAX, values); +} + + +static void GLAPIENTRY +_mesa_GetHistogramParameterfv(GLenum target, GLenum pname, GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + + _mesa_error(ctx, GL_INVALID_OPERATION, "glGetHistogramParameterfv"); +} + + +static void GLAPIENTRY +_mesa_GetHistogramParameteriv(GLenum target, GLenum pname, GLint *params) +{ + GET_CURRENT_CONTEXT(ctx); + + _mesa_error(ctx, GL_INVALID_OPERATION, "glGetHistogramParameteriv"); +} + + +static void GLAPIENTRY +_mesa_GetMinmaxParameterfv(GLenum target, GLenum pname, GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + + _mesa_error(ctx, GL_INVALID_OPERATION, "glGetMinmaxParameterfv"); +} + + +static void GLAPIENTRY +_mesa_GetMinmaxParameteriv(GLenum target, GLenum pname, GLint *params) +{ + GET_CURRENT_CONTEXT(ctx); + + _mesa_error(ctx, GL_INVALID_OPERATION, "glGetMinmaxParameteriv"); +} + + +static void GLAPIENTRY +_mesa_Histogram(GLenum target, GLsizei width, GLenum internalFormat, GLboolean sink) +{ + GET_CURRENT_CONTEXT(ctx); + + _mesa_error(ctx, GL_INVALID_OPERATION, "glHistogram"); +} + + +static void GLAPIENTRY +_mesa_Minmax(GLenum target, GLenum internalFormat, GLboolean sink) +{ + GET_CURRENT_CONTEXT(ctx); + + _mesa_error(ctx, GL_INVALID_OPERATION, "glMinmax"); +} + + +static void GLAPIENTRY +_mesa_ResetHistogram(GLenum target) +{ + GET_CURRENT_CONTEXT(ctx); + + _mesa_error(ctx, GL_INVALID_OPERATION, "glResetHistogram"); +} + + +static void GLAPIENTRY +_mesa_ResetMinmax(GLenum target) +{ + GET_CURRENT_CONTEXT(ctx); + + _mesa_error(ctx, GL_INVALID_OPERATION, "glResetMinmax"); +} + + +void +_mesa_init_histogram_dispatch(struct _glapi_table *disp) +{ + SET_GetHistogram(disp, _mesa_GetHistogram); + SET_GetHistogramParameterfv(disp, _mesa_GetHistogramParameterfv); + SET_GetHistogramParameteriv(disp, _mesa_GetHistogramParameteriv); + SET_GetMinmax(disp, _mesa_GetMinmax); + SET_GetMinmaxParameterfv(disp, _mesa_GetMinmaxParameterfv); + SET_GetMinmaxParameteriv(disp, _mesa_GetMinmaxParameteriv); + SET_Histogram(disp, _mesa_Histogram); + SET_Minmax(disp, _mesa_Minmax); + SET_ResetHistogram(disp, _mesa_ResetHistogram); + SET_ResetMinmax(disp, _mesa_ResetMinmax); + + /* GL_ARB_robustness */ + SET_GetnHistogramARB(disp, _mesa_GetnHistogramARB); + SET_GetnMinmaxARB(disp, _mesa_GetnMinmaxARB); +} + +#endif /* FEATURE_histogram */ diff --git a/mesalib/src/mesa/main/imports.h b/mesalib/src/mesa/main/imports.h index df145ea6f..70defdc43 100644 --- a/mesalib/src/mesa/main/imports.h +++ b/mesalib/src/mesa/main/imports.h @@ -1,648 +1,648 @@ -/* - * Mesa 3-D graphics library - * Version: 7.5 - * - * 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 imports.h - * Standard C library function wrappers. - * - * This file provides wrappers for all the standard C library functions - * like malloc(), free(), printf(), getenv(), etc. - */ - - -#ifndef IMPORTS_H -#define IMPORTS_H - - -#include "compiler.h" -#include "glheader.h" - - -#ifdef __cplusplus -extern "C" { -#endif - - -/**********************************************************************/ -/** Memory macros */ -/*@{*/ - -/** Allocate \p BYTES bytes */ -#define MALLOC(BYTES) malloc(BYTES) -/** Allocate and zero \p BYTES bytes */ -#define CALLOC(BYTES) calloc(1, BYTES) -/** Allocate a structure of type \p T */ -#define MALLOC_STRUCT(T) (struct T *) malloc(sizeof(struct T)) -/** Allocate and zero a structure of type \p T */ -#define CALLOC_STRUCT(T) (struct T *) calloc(1, sizeof(struct T)) -/** Free memory */ -#define FREE(PTR) free(PTR) - -/*@}*/ - - -/* - * For GL_ARB_vertex_buffer_object we need to treat vertex array pointers - * as offsets into buffer stores. Since the vertex array pointer and - * buffer store pointer are both pointers and we need to add them, we use - * this macro. - * Both pointers/offsets are expressed in bytes. - */ -#define ADD_POINTERS(A, B) ( (GLubyte *) (A) + (uintptr_t) (B) ) - - -/** - * Sometimes we treat GLfloats as GLints. On x86 systems, moving a float - * as a int (thereby using integer registers instead of FP registers) is - * a performance win. Typically, this can be done with ordinary casts. - * But with gcc's -fstrict-aliasing flag (which defaults to on in gcc 3.0) - * these casts generate warnings. - * The following union typedef is used to solve that. - */ -typedef union { GLfloat f; GLint i; } fi_type; - - - -/********************************************************************** - * Math macros - */ - -#define MAX_GLUSHORT 0xffff -#define MAX_GLUINT 0xffffffff - -/* Degrees to radians conversion: */ -#define DEG2RAD (M_PI/180.0) - - -/*** - *** SQRTF: single-precision square root - ***/ -#if 0 /* _mesa_sqrtf() not accurate enough - temporarily disabled */ -# define SQRTF(X) _mesa_sqrtf(X) -#else -# define SQRTF(X) (float) sqrt((float) (X)) -#endif - - -/*** - *** INV_SQRTF: single-precision inverse square root - ***/ -#if 0 -#define INV_SQRTF(X) _mesa_inv_sqrt(X) -#else -#define INV_SQRTF(X) (1.0F / SQRTF(X)) /* this is faster on a P4 */ -#endif - - -/** - * \name Work-arounds for platforms that lack C99 math functions - */ -/*@{*/ -#if (!defined(_XOPEN_SOURCE) || (_XOPEN_SOURCE < 600)) && !defined(_ISOC99_SOURCE) \ - && (!defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L)) \ - && (!defined(_MSC_VER) || (_MSC_VER < 1400)) -#define acosf(f) ((float) acos(f)) -#define asinf(f) ((float) asin(f)) -#define atan2f(x,y) ((float) atan2(x,y)) -#define atanf(f) ((float) atan(f)) -#define cielf(f) ((float) ciel(f)) -#define cosf(f) ((float) cos(f)) -#define coshf(f) ((float) cosh(f)) -#define expf(f) ((float) exp(f)) -#define exp2f(f) ((float) exp2(f)) -#define floorf(f) ((float) floor(f)) -#define logf(f) ((float) log(f)) - -#ifdef ANDROID -#define log2f(f) (logf(f) * (float) (1.0 / M_LN2)) -#else -#define log2f(f) ((float) log2(f)) -#endif - -#define powf(x,y) ((float) pow(x,y)) -#define sinf(f) ((float) sin(f)) -#define sinhf(f) ((float) sinh(f)) -#define sqrtf(f) ((float) sqrt(f)) -#define tanf(f) ((float) tan(f)) -#define tanhf(f) ((float) tanh(f)) -#define acoshf(f) ((float) acosh(f)) -#define asinhf(f) ((float) asinh(f)) -#define atanhf(f) ((float) atanh(f)) -#endif - -#if defined(_MSC_VER) -static INLINE float truncf(float x) { return x < 0.0f ? ceilf(x) : floorf(x); } -static INLINE float exp2f(float x) { return powf(2.0f, x); } -static INLINE float log2f(float x) { return logf(x) * 1.442695041f; } -static INLINE float asinhf(float x) { return logf(x + sqrtf(x * x + 1.0f)); } -static INLINE float acoshf(float x) { return logf(x + sqrtf(x * x - 1.0f)); } -static INLINE float atanhf(float x) { return (logf(1.0f + x) - logf(1.0f - x)) / 2.0f; } -static INLINE int isblank(int ch) { return ch == ' ' || ch == '\t'; } -#define strtoll(p, e, b) _strtoi64(p, e, b) -#endif -/*@}*/ - -/*** - *** LOG2: Log base 2 of float - ***/ -#ifdef USE_IEEE -#if 0 -/* This is pretty fast, but not accurate enough (only 2 fractional bits). - * Based on code from http://www.stereopsis.com/log2.html - */ -static INLINE GLfloat LOG2(GLfloat x) -{ - const GLfloat y = x * x * x * x; - const GLuint ix = *((GLuint *) &y); - const GLuint exp = (ix >> 23) & 0xFF; - const GLint log2 = ((GLint) exp) - 127; - return (GLfloat) log2 * (1.0 / 4.0); /* 4, because of x^4 above */ -} -#endif -/* Pretty fast, and accurate. - * Based on code from http://www.flipcode.com/totd/ - */ -static INLINE GLfloat LOG2(GLfloat val) -{ - fi_type num; - GLint log_2; - num.f = val; - log_2 = ((num.i >> 23) & 255) - 128; - num.i &= ~(255 << 23); - num.i += 127 << 23; - num.f = ((-1.0f/3) * num.f + 2) * num.f - 2.0f/3; - return num.f + log_2; -} -#else -/* - * NOTE: log_base_2(x) = log(x) / log(2) - * NOTE: 1.442695 = 1/log(2). - */ -#define LOG2(x) ((GLfloat) (log(x) * 1.442695F)) -#endif - - -/*** - *** IS_INF_OR_NAN: test if float is infinite or NaN - ***/ -#ifdef USE_IEEE -static INLINE int IS_INF_OR_NAN( float x ) -{ - fi_type tmp; - tmp.f = x; - return !(int)((unsigned int)((tmp.i & 0x7fffffff)-0x7f800000) >> 31); -} -#elif defined(isfinite) -#define IS_INF_OR_NAN(x) (!isfinite(x)) -#elif defined(finite) -#define IS_INF_OR_NAN(x) (!finite(x)) -#elif defined(__VMS) -#define IS_INF_OR_NAN(x) (!finite(x)) -#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L -#define IS_INF_OR_NAN(x) (!isfinite(x)) -#else -#define IS_INF_OR_NAN(x) (!finite(x)) -#endif - - -/*** - *** IS_NEGATIVE: test if float is negative - ***/ -#if defined(USE_IEEE) -static INLINE int GET_FLOAT_BITS( float x ) -{ - fi_type fi; - fi.f = x; - return fi.i; -} -#define IS_NEGATIVE(x) (GET_FLOAT_BITS(x) < 0) -#else -#define IS_NEGATIVE(x) (x < 0.0F) -#endif - - -/*** - *** DIFFERENT_SIGNS: test if two floats have opposite signs - ***/ -#if defined(USE_IEEE) -#define DIFFERENT_SIGNS(x,y) ((GET_FLOAT_BITS(x) ^ GET_FLOAT_BITS(y)) & (1<<31)) -#else -/* Could just use (x*y<0) except for the flatshading requirements. - * Maybe there's a better way? - */ -#define DIFFERENT_SIGNS(x,y) ((x) * (y) <= 0.0F && (x) - (y) != 0.0F) -#endif - - -/*** - *** CEILF: ceiling of float - *** FLOORF: floor of float - *** FABSF: absolute value of float - *** LOGF: the natural logarithm (base e) of the value - *** EXPF: raise e to the value - *** LDEXPF: multiply value by an integral power of two - *** FREXPF: extract mantissa and exponent from value - ***/ -#if defined(__gnu_linux__) -/* C99 functions */ -#define CEILF(x) ceilf(x) -#define FLOORF(x) floorf(x) -#define FABSF(x) fabsf(x) -#define LOGF(x) logf(x) -#define EXPF(x) expf(x) -#define LDEXPF(x,y) ldexpf(x,y) -#define FREXPF(x,y) frexpf(x,y) -#else -#define CEILF(x) ((GLfloat) ceil(x)) -#define FLOORF(x) ((GLfloat) floor(x)) -#define FABSF(x) ((GLfloat) fabs(x)) -#define LOGF(x) ((GLfloat) log(x)) -#define EXPF(x) ((GLfloat) exp(x)) -#define LDEXPF(x,y) ((GLfloat) ldexp(x,y)) -#define FREXPF(x,y) ((GLfloat) frexp(x,y)) -#endif - - -/*** - *** IROUND: return (as an integer) float rounded to nearest integer - ***/ -#if defined(USE_X86_ASM) && defined(__GNUC__) && defined(__i386__) -static INLINE int iround(float f) -{ - int r; - __asm__ ("fistpl %0" : "=m" (r) : "t" (f) : "st"); - return r; -} -#define IROUND(x) iround(x) -#elif defined(USE_X86_ASM) && defined(_MSC_VER) -static INLINE int iround(float f) -{ - int r; - _asm { - fld f - fistp r - } - return r; -} -#define IROUND(x) iround(x) -#elif defined(__WATCOMC__) && defined(__386__) -long iround(float f); -#pragma aux iround = \ - "push eax" \ - "fistp dword ptr [esp]" \ - "pop eax" \ - parm [8087] \ - value [eax] \ - modify exact [eax]; -#define IROUND(x) iround(x) -#else -#define IROUND(f) ((int) (((f) >= 0.0F) ? ((f) + 0.5F) : ((f) - 0.5F))) -#endif - -#define IROUND64(f) ((GLint64) (((f) >= 0.0F) ? ((f) + 0.5F) : ((f) - 0.5F))) - -/*** - *** IROUND_POS: return (as an integer) positive float rounded to nearest int - ***/ -#ifdef DEBUG -#define IROUND_POS(f) (assert((f) >= 0.0F), IROUND(f)) -#else -#define IROUND_POS(f) (IROUND(f)) -#endif - - -/*** - *** IFLOOR: return (as an integer) floor of float - ***/ -#if defined(USE_X86_ASM) && defined(__GNUC__) && defined(__i386__) -/* - * IEEE floor for computers that round to nearest or even. - * 'f' must be between -4194304 and 4194303. - * This floor operation is done by "(iround(f + .5) + iround(f - .5)) >> 1", - * but uses some IEEE specific tricks for better speed. - * Contributed by Josh Vanderhoof - */ -static INLINE int ifloor(float f) -{ - int ai, bi; - double af, bf; - af = (3 << 22) + 0.5 + (double)f; - bf = (3 << 22) + 0.5 - (double)f; - /* GCC generates an extra fstp/fld without this. */ - __asm__ ("fstps %0" : "=m" (ai) : "t" (af) : "st"); - __asm__ ("fstps %0" : "=m" (bi) : "t" (bf) : "st"); - return (ai - bi) >> 1; -} -#define IFLOOR(x) ifloor(x) -#elif defined(USE_IEEE) -static INLINE int ifloor(float f) -{ - int ai, bi; - double af, bf; - fi_type u; - - af = (3 << 22) + 0.5 + (double)f; - bf = (3 << 22) + 0.5 - (double)f; - u.f = (float) af; ai = u.i; - u.f = (float) bf; bi = u.i; - return (ai - bi) >> 1; -} -#define IFLOOR(x) ifloor(x) -#else -static INLINE int ifloor(float f) -{ - int i = IROUND(f); - return (i > f) ? i - 1 : i; -} -#define IFLOOR(x) ifloor(x) -#endif - - -/*** - *** ICEIL: return (as an integer) ceiling of float - ***/ -#if defined(USE_X86_ASM) && defined(__GNUC__) && defined(__i386__) -/* - * IEEE ceil for computers that round to nearest or even. - * 'f' must be between -4194304 and 4194303. - * This ceil operation is done by "(iround(f + .5) + iround(f - .5) + 1) >> 1", - * but uses some IEEE specific tricks for better speed. - * Contributed by Josh Vanderhoof - */ -static INLINE int iceil(float f) -{ - int ai, bi; - double af, bf; - af = (3 << 22) + 0.5 + (double)f; - bf = (3 << 22) + 0.5 - (double)f; - /* GCC generates an extra fstp/fld without this. */ - __asm__ ("fstps %0" : "=m" (ai) : "t" (af) : "st"); - __asm__ ("fstps %0" : "=m" (bi) : "t" (bf) : "st"); - return (ai - bi + 1) >> 1; -} -#define ICEIL(x) iceil(x) -#elif defined(USE_IEEE) -static INLINE int iceil(float f) -{ - int ai, bi; - double af, bf; - fi_type u; - af = (3 << 22) + 0.5 + (double)f; - bf = (3 << 22) + 0.5 - (double)f; - u.f = (float) af; ai = u.i; - u.f = (float) bf; bi = u.i; - return (ai - bi + 1) >> 1; -} -#define ICEIL(x) iceil(x) -#else -static INLINE int iceil(float f) -{ - int i = IROUND(f); - return (i < f) ? i + 1 : i; -} -#define ICEIL(x) iceil(x) -#endif - - -/** - * Is x a power of two? - */ -static INLINE int -_mesa_is_pow_two(int x) -{ - return !(x & (x - 1)); -} - -/** - * Round given integer to next higer power of two - * If X is zero result is undefined. - * - * Source for the fallback implementation is - * Sean Eron Anderson's webpage "Bit Twiddling Hacks" - * http://graphics.stanford.edu/~seander/bithacks.html - * - * When using builtin function have to do some work - * for case when passed values 1 to prevent hiting - * undefined result from __builtin_clz. Undefined - * results would be different depending on optimization - * level used for build. - */ -static INLINE int32_t -_mesa_next_pow_two_32(uint32_t x) -{ -#if defined(__GNUC__) && \ - ((__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || __GNUC__ >= 4) - uint32_t y = (x != 1); - return (1 + y) << ((__builtin_clz(x - y) ^ 31) ); -#else - x--; - x |= x >> 1; - x |= x >> 2; - x |= x >> 4; - x |= x >> 8; - x |= x >> 16; - x++; - return x; -#endif -} - -static INLINE int64_t -_mesa_next_pow_two_64(uint64_t x) -{ -#if defined(__GNUC__) && \ - ((__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || __GNUC__ >= 4) - uint64_t y = (x != 1); - if (sizeof(x) == sizeof(long)) - return (1 + y) << ((__builtin_clzl(x - y) ^ 63)); - else - return (1 + y) << ((__builtin_clzll(x - y) ^ 63)); -#else - x--; - x |= x >> 1; - x |= x >> 2; - x |= x >> 4; - x |= x >> 8; - x |= x >> 16; - x |= x >> 32; - x++; - return x; -#endif -} - - -/* - * Returns the floor form of binary logarithm for a 32-bit integer. - */ -static INLINE GLuint -_mesa_logbase2(GLuint n) -{ -#if defined(__GNUC__) && \ - ((__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || __GNUC__ >= 4) - return (31 - __builtin_clz(n | 1)); -#else - GLuint pos = 0; - if (n >= 1<<16) { n >>= 16; pos += 16; } - if (n >= 1<< 8) { n >>= 8; pos += 8; } - if (n >= 1<< 4) { n >>= 4; pos += 4; } - if (n >= 1<< 2) { n >>= 2; pos += 2; } - if (n >= 1<< 1) { pos += 1; } - return pos; -#endif -} - - -/** - * Return 1 if this is a little endian machine, 0 if big endian. - */ -static INLINE GLboolean -_mesa_little_endian(void) -{ - const GLuint ui = 1; /* intentionally not static */ - return *((const GLubyte *) &ui); -} - - - -/********************************************************************** - * Functions - */ - -extern void * -_mesa_align_malloc( size_t bytes, unsigned long alignment ); - -extern void * -_mesa_align_calloc( size_t bytes, unsigned long alignment ); - -extern void -_mesa_align_free( void *ptr ); - -extern void * -_mesa_align_realloc(void *oldBuffer, size_t oldSize, size_t newSize, - unsigned long alignment); - -extern void * -_mesa_exec_malloc( GLuint size ); - -extern void -_mesa_exec_free( void *addr ); - -extern void * -_mesa_realloc( void *oldBuffer, size_t oldSize, size_t newSize ); - -extern void -_mesa_memset16( unsigned short *dst, unsigned short val, size_t n ); - -extern double -_mesa_sqrtd(double x); - -extern float -_mesa_sqrtf(float x); - -extern float -_mesa_inv_sqrtf(float x); - -extern void -_mesa_init_sqrt_table(void); - -#ifdef __GNUC__ - -#if defined(__MINGW32__) || defined(ANDROID) -#define ffs __builtin_ffs -#define ffsll __builtin_ffsll -#endif - -#define _mesa_ffs(i) ffs(i) -#define _mesa_ffsll(i) ffsll(i) - -#if ((_GNUC__ == 3 && __GNUC_MINOR__ >= 4) || __GNUC__ >= 4) -#define _mesa_bitcount(i) __builtin_popcount(i) -#else -extern unsigned int -_mesa_bitcount(unsigned int n); -#endif - -#else -extern int -_mesa_ffs(int32_t i); - -extern int -_mesa_ffsll(int64_t i); - -extern unsigned int -_mesa_bitcount(unsigned int n); -#endif - -extern GLhalfARB -_mesa_float_to_half(float f); - -extern float -_mesa_half_to_float(GLhalfARB h); - - -extern void * -_mesa_bsearch( const void *key, const void *base, size_t nmemb, size_t size, - int (*compar)(const void *, const void *) ); - -extern char * -_mesa_getenv( const char *var ); - -extern char * -_mesa_strdup( const char *s ); - -extern float -_mesa_strtof( const char *s, char **end ); - -extern unsigned int -_mesa_str_checksum(const char *str); - -extern int -_mesa_snprintf( char *str, size_t size, const char *fmt, ... ) PRINTFLIKE(3, 4); - -struct gl_context; - -extern void -_mesa_warning( struct gl_context *gc, const char *fmtString, ... ) PRINTFLIKE(2, 3); - -extern void -_mesa_problem( const struct gl_context *ctx, const char *fmtString, ... ) PRINTFLIKE(2, 3); - -extern void -_mesa_error( struct gl_context *ctx, GLenum error, const char *fmtString, ... ) PRINTFLIKE(3, 4); - -extern void -_mesa_debug( const struct gl_context *ctx, const char *fmtString, ... ) PRINTFLIKE(2, 3); - - -#if defined(_MSC_VER) && !defined(snprintf) -#define snprintf _snprintf -#endif - - -#ifdef __cplusplus -} -#endif - - -#endif /* IMPORTS_H */ +/* + * Mesa 3-D graphics library + * Version: 7.5 + * + * 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 imports.h + * Standard C library function wrappers. + * + * This file provides wrappers for all the standard C library functions + * like malloc(), free(), printf(), getenv(), etc. + */ + + +#ifndef IMPORTS_H +#define IMPORTS_H + + +#include "compiler.h" +#include "glheader.h" + + +#ifdef __cplusplus +extern "C" { +#endif + + +/**********************************************************************/ +/** Memory macros */ +/*@{*/ + +/** Allocate \p BYTES bytes */ +#define MALLOC(BYTES) malloc(BYTES) +/** Allocate and zero \p BYTES bytes */ +#define CALLOC(BYTES) calloc(1, BYTES) +/** Allocate a structure of type \p T */ +#define MALLOC_STRUCT(T) (struct T *) malloc(sizeof(struct T)) +/** Allocate and zero a structure of type \p T */ +#define CALLOC_STRUCT(T) (struct T *) calloc(1, sizeof(struct T)) +/** Free memory */ +#define FREE(PTR) free(PTR) + +/*@}*/ + + +/* + * For GL_ARB_vertex_buffer_object we need to treat vertex array pointers + * as offsets into buffer stores. Since the vertex array pointer and + * buffer store pointer are both pointers and we need to add them, we use + * this macro. + * Both pointers/offsets are expressed in bytes. + */ +#define ADD_POINTERS(A, B) ( (GLubyte *) (A) + (uintptr_t) (B) ) + + +/** + * Sometimes we treat GLfloats as GLints. On x86 systems, moving a float + * as a int (thereby using integer registers instead of FP registers) is + * a performance win. Typically, this can be done with ordinary casts. + * But with gcc's -fstrict-aliasing flag (which defaults to on in gcc 3.0) + * these casts generate warnings. + * The following union typedef is used to solve that. + */ +typedef union { GLfloat f; GLint i; } fi_type; + + + +/********************************************************************** + * Math macros + */ + +#define MAX_GLUSHORT 0xffff +#define MAX_GLUINT 0xffffffff + +/* Degrees to radians conversion: */ +#define DEG2RAD (M_PI/180.0) + + +/*** + *** SQRTF: single-precision square root + ***/ +#if 0 /* _mesa_sqrtf() not accurate enough - temporarily disabled */ +# define SQRTF(X) _mesa_sqrtf(X) +#else +# define SQRTF(X) (float) sqrt((float) (X)) +#endif + + +/*** + *** INV_SQRTF: single-precision inverse square root + ***/ +#if 0 +#define INV_SQRTF(X) _mesa_inv_sqrt(X) +#else +#define INV_SQRTF(X) (1.0F / SQRTF(X)) /* this is faster on a P4 */ +#endif + + +/** + * \name Work-arounds for platforms that lack C99 math functions + */ +/*@{*/ +#if (!defined(_XOPEN_SOURCE) || (_XOPEN_SOURCE < 600)) && !defined(_ISOC99_SOURCE) \ + && (!defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L)) \ + && (!defined(_MSC_VER) || (_MSC_VER < 1400)) +#define acosf(f) ((float) acos(f)) +#define asinf(f) ((float) asin(f)) +#define atan2f(x,y) ((float) atan2(x,y)) +#define atanf(f) ((float) atan(f)) +#define cielf(f) ((float) ciel(f)) +#define cosf(f) ((float) cos(f)) +#define coshf(f) ((float) cosh(f)) +#define expf(f) ((float) exp(f)) +#define exp2f(f) ((float) exp2(f)) +#define floorf(f) ((float) floor(f)) +#define logf(f) ((float) log(f)) + +#ifdef ANDROID +#define log2f(f) (logf(f) * (float) (1.0 / M_LN2)) +#else +#define log2f(f) ((float) log2(f)) +#endif + +#define powf(x,y) ((float) pow(x,y)) +#define sinf(f) ((float) sin(f)) +#define sinhf(f) ((float) sinh(f)) +#define sqrtf(f) ((float) sqrt(f)) +#define tanf(f) ((float) tan(f)) +#define tanhf(f) ((float) tanh(f)) +#define acoshf(f) ((float) acosh(f)) +#define asinhf(f) ((float) asinh(f)) +#define atanhf(f) ((float) atanh(f)) +#endif + +#if defined(_MSC_VER) +static INLINE float truncf(float x) { return x < 0.0f ? ceilf(x) : floorf(x); } +static INLINE float exp2f(float x) { return powf(2.0f, x); } +static INLINE float log2f(float x) { return logf(x) * 1.442695041f; } +static INLINE float asinhf(float x) { return logf(x + sqrtf(x * x + 1.0f)); } +static INLINE float acoshf(float x) { return logf(x + sqrtf(x * x - 1.0f)); } +static INLINE float atanhf(float x) { return (logf(1.0f + x) - logf(1.0f - x)) / 2.0f; } +static INLINE int isblank(int ch) { return ch == ' ' || ch == '\t'; } +#define strtoll(p, e, b) _strtoi64(p, e, b) +#endif +/*@}*/ + +/*** + *** LOG2: Log base 2 of float + ***/ +#ifdef USE_IEEE +#if 0 +/* This is pretty fast, but not accurate enough (only 2 fractional bits). + * Based on code from http://www.stereopsis.com/log2.html + */ +static INLINE GLfloat LOG2(GLfloat x) +{ + const GLfloat y = x * x * x * x; + const GLuint ix = *((GLuint *) &y); + const GLuint exp = (ix >> 23) & 0xFF; + const GLint log2 = ((GLint) exp) - 127; + return (GLfloat) log2 * (1.0 / 4.0); /* 4, because of x^4 above */ +} +#endif +/* Pretty fast, and accurate. + * Based on code from http://www.flipcode.com/totd/ + */ +static INLINE GLfloat LOG2(GLfloat val) +{ + fi_type num; + GLint log_2; + num.f = val; + log_2 = ((num.i >> 23) & 255) - 128; + num.i &= ~(255 << 23); + num.i += 127 << 23; + num.f = ((-1.0f/3) * num.f + 2) * num.f - 2.0f/3; + return num.f + log_2; +} +#else +/* + * NOTE: log_base_2(x) = log(x) / log(2) + * NOTE: 1.442695 = 1/log(2). + */ +#define LOG2(x) ((GLfloat) (log(x) * 1.442695F)) +#endif + + +/*** + *** IS_INF_OR_NAN: test if float is infinite or NaN + ***/ +#ifdef USE_IEEE +static INLINE int IS_INF_OR_NAN( float x ) +{ + fi_type tmp; + tmp.f = x; + return !(int)((unsigned int)((tmp.i & 0x7fffffff)-0x7f800000) >> 31); +} +#elif defined(isfinite) +#define IS_INF_OR_NAN(x) (!isfinite(x)) +#elif defined(finite) +#define IS_INF_OR_NAN(x) (!finite(x)) +#elif defined(__VMS) +#define IS_INF_OR_NAN(x) (!finite(x)) +#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L +#define IS_INF_OR_NAN(x) (!isfinite(x)) +#else +#define IS_INF_OR_NAN(x) (!finite(x)) +#endif + + +/*** + *** IS_NEGATIVE: test if float is negative + ***/ +#if defined(USE_IEEE) +static INLINE int GET_FLOAT_BITS( float x ) +{ + fi_type fi; + fi.f = x; + return fi.i; +} +#define IS_NEGATIVE(x) (GET_FLOAT_BITS(x) < 0) +#else +#define IS_NEGATIVE(x) (x < 0.0F) +#endif + + +/*** + *** DIFFERENT_SIGNS: test if two floats have opposite signs + ***/ +#if defined(USE_IEEE) +#define DIFFERENT_SIGNS(x,y) ((GET_FLOAT_BITS(x) ^ GET_FLOAT_BITS(y)) & (1<<31)) +#else +/* Could just use (x*y<0) except for the flatshading requirements. + * Maybe there's a better way? + */ +#define DIFFERENT_SIGNS(x,y) ((x) * (y) <= 0.0F && (x) - (y) != 0.0F) +#endif + + +/*** + *** CEILF: ceiling of float + *** FLOORF: floor of float + *** FABSF: absolute value of float + *** LOGF: the natural logarithm (base e) of the value + *** EXPF: raise e to the value + *** LDEXPF: multiply value by an integral power of two + *** FREXPF: extract mantissa and exponent from value + ***/ +#if defined(__gnu_linux__) +/* C99 functions */ +#define CEILF(x) ceilf(x) +#define FLOORF(x) floorf(x) +#define FABSF(x) fabsf(x) +#define LOGF(x) logf(x) +#define EXPF(x) expf(x) +#define LDEXPF(x,y) ldexpf(x,y) +#define FREXPF(x,y) frexpf(x,y) +#else +#define CEILF(x) ((GLfloat) ceil(x)) +#define FLOORF(x) ((GLfloat) floor(x)) +#define FABSF(x) ((GLfloat) fabs(x)) +#define LOGF(x) ((GLfloat) log(x)) +#define EXPF(x) ((GLfloat) exp(x)) +#define LDEXPF(x,y) ((GLfloat) ldexp(x,y)) +#define FREXPF(x,y) ((GLfloat) frexp(x,y)) +#endif + + +/*** + *** IROUND: return (as an integer) float rounded to nearest integer + ***/ +#if defined(USE_X86_ASM) && defined(__GNUC__) && defined(__i386__) +static INLINE int iround(float f) +{ + int r; + __asm__ ("fistpl %0" : "=m" (r) : "t" (f) : "st"); + return r; +} +#define IROUND(x) iround(x) +#elif defined(USE_X86_ASM) && defined(_MSC_VER) +static INLINE int iround(float f) +{ + int r; + _asm { + fld f + fistp r + } + return r; +} +#define IROUND(x) iround(x) +#elif defined(__WATCOMC__) && defined(__386__) +long iround(float f); +#pragma aux iround = \ + "push eax" \ + "fistp dword ptr [esp]" \ + "pop eax" \ + parm [8087] \ + value [eax] \ + modify exact [eax]; +#define IROUND(x) iround(x) +#else +#define IROUND(f) ((int) (((f) >= 0.0F) ? ((f) + 0.5F) : ((f) - 0.5F))) +#endif + +#define IROUND64(f) ((GLint64) (((f) >= 0.0F) ? ((f) + 0.5F) : ((f) - 0.5F))) + +/*** + *** IROUND_POS: return (as an integer) positive float rounded to nearest int + ***/ +#ifdef DEBUG +#define IROUND_POS(f) (assert((f) >= 0.0F), IROUND(f)) +#else +#define IROUND_POS(f) (IROUND(f)) +#endif + + +/*** + *** IFLOOR: return (as an integer) floor of float + ***/ +#if defined(USE_X86_ASM) && defined(__GNUC__) && defined(__i386__) +/* + * IEEE floor for computers that round to nearest or even. + * 'f' must be between -4194304 and 4194303. + * This floor operation is done by "(iround(f + .5) + iround(f - .5)) >> 1", + * but uses some IEEE specific tricks for better speed. + * Contributed by Josh Vanderhoof + */ +static INLINE int ifloor(float f) +{ + int ai, bi; + double af, bf; + af = (3 << 22) + 0.5 + (double)f; + bf = (3 << 22) + 0.5 - (double)f; + /* GCC generates an extra fstp/fld without this. */ + __asm__ ("fstps %0" : "=m" (ai) : "t" (af) : "st"); + __asm__ ("fstps %0" : "=m" (bi) : "t" (bf) : "st"); + return (ai - bi) >> 1; +} +#define IFLOOR(x) ifloor(x) +#elif defined(USE_IEEE) +static INLINE int ifloor(float f) +{ + int ai, bi; + double af, bf; + fi_type u; + + af = (3 << 22) + 0.5 + (double)f; + bf = (3 << 22) + 0.5 - (double)f; + u.f = (float) af; ai = u.i; + u.f = (float) bf; bi = u.i; + return (ai - bi) >> 1; +} +#define IFLOOR(x) ifloor(x) +#else +static INLINE int ifloor(float f) +{ + int i = IROUND(f); + return (i > f) ? i - 1 : i; +} +#define IFLOOR(x) ifloor(x) +#endif + + +/*** + *** ICEIL: return (as an integer) ceiling of float + ***/ +#if defined(USE_X86_ASM) && defined(__GNUC__) && defined(__i386__) +/* + * IEEE ceil for computers that round to nearest or even. + * 'f' must be between -4194304 and 4194303. + * This ceil operation is done by "(iround(f + .5) + iround(f - .5) + 1) >> 1", + * but uses some IEEE specific tricks for better speed. + * Contributed by Josh Vanderhoof + */ +static INLINE int iceil(float f) +{ + int ai, bi; + double af, bf; + af = (3 << 22) + 0.5 + (double)f; + bf = (3 << 22) + 0.5 - (double)f; + /* GCC generates an extra fstp/fld without this. */ + __asm__ ("fstps %0" : "=m" (ai) : "t" (af) : "st"); + __asm__ ("fstps %0" : "=m" (bi) : "t" (bf) : "st"); + return (ai - bi + 1) >> 1; +} +#define ICEIL(x) iceil(x) +#elif defined(USE_IEEE) +static INLINE int iceil(float f) +{ + int ai, bi; + double af, bf; + fi_type u; + af = (3 << 22) + 0.5 + (double)f; + bf = (3 << 22) + 0.5 - (double)f; + u.f = (float) af; ai = u.i; + u.f = (float) bf; bi = u.i; + return (ai - bi + 1) >> 1; +} +#define ICEIL(x) iceil(x) +#else +static INLINE int iceil(float f) +{ + int i = IROUND(f); + return (i < f) ? i + 1 : i; +} +#define ICEIL(x) iceil(x) +#endif + + +/** + * Is x a power of two? + */ +static INLINE int +_mesa_is_pow_two(int x) +{ + return !(x & (x - 1)); +} + +/** + * Round given integer to next higer power of two + * If X is zero result is undefined. + * + * Source for the fallback implementation is + * Sean Eron Anderson's webpage "Bit Twiddling Hacks" + * http://graphics.stanford.edu/~seander/bithacks.html + * + * When using builtin function have to do some work + * for case when passed values 1 to prevent hiting + * undefined result from __builtin_clz. Undefined + * results would be different depending on optimization + * level used for build. + */ +static INLINE int32_t +_mesa_next_pow_two_32(uint32_t x) +{ +#if defined(__GNUC__) && \ + ((__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || __GNUC__ >= 4) + uint32_t y = (x != 1); + return (1 + y) << ((__builtin_clz(x - y) ^ 31) ); +#else + x--; + x |= x >> 1; + x |= x >> 2; + x |= x >> 4; + x |= x >> 8; + x |= x >> 16; + x++; + return x; +#endif +} + +static INLINE int64_t +_mesa_next_pow_two_64(uint64_t x) +{ +#if defined(__GNUC__) && \ + ((__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || __GNUC__ >= 4) + uint64_t y = (x != 1); + if (sizeof(x) == sizeof(long)) + return (1 + y) << ((__builtin_clzl(x - y) ^ 63)); + else + return (1 + y) << ((__builtin_clzll(x - y) ^ 63)); +#else + x--; + x |= x >> 1; + x |= x >> 2; + x |= x >> 4; + x |= x >> 8; + x |= x >> 16; + x |= x >> 32; + x++; + return x; +#endif +} + + +/* + * Returns the floor form of binary logarithm for a 32-bit integer. + */ +static INLINE GLuint +_mesa_logbase2(GLuint n) +{ +#if defined(__GNUC__) && \ + ((__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || __GNUC__ >= 4) + return (31 - __builtin_clz(n | 1)); +#else + GLuint pos = 0; + if (n >= 1<<16) { n >>= 16; pos += 16; } + if (n >= 1<< 8) { n >>= 8; pos += 8; } + if (n >= 1<< 4) { n >>= 4; pos += 4; } + if (n >= 1<< 2) { n >>= 2; pos += 2; } + if (n >= 1<< 1) { pos += 1; } + return pos; +#endif +} + + +/** + * Return 1 if this is a little endian machine, 0 if big endian. + */ +static INLINE GLboolean +_mesa_little_endian(void) +{ + const GLuint ui = 1; /* intentionally not static */ + return *((const GLubyte *) &ui); +} + + + +/********************************************************************** + * Functions + */ + +extern void * +_mesa_align_malloc( size_t bytes, unsigned long alignment ); + +extern void * +_mesa_align_calloc( size_t bytes, unsigned long alignment ); + +extern void +_mesa_align_free( void *ptr ); + +extern void * +_mesa_align_realloc(void *oldBuffer, size_t oldSize, size_t newSize, + unsigned long alignment); + +extern void * +_mesa_exec_malloc( GLuint size ); + +extern void +_mesa_exec_free( void *addr ); + +extern void * +_mesa_realloc( void *oldBuffer, size_t oldSize, size_t newSize ); + +extern void +_mesa_memset16( unsigned short *dst, unsigned short val, size_t n ); + +extern double +_mesa_sqrtd(double x); + +extern float +_mesa_sqrtf(float x); + +extern float +_mesa_inv_sqrtf(float x); + +extern void +_mesa_init_sqrt_table(void); + +#ifdef __GNUC__ + +#if defined(__MINGW32__) || defined(ANDROID) +#define ffs __builtin_ffs +#define ffsll __builtin_ffsll +#endif + +#define _mesa_ffs(i) ffs(i) +#define _mesa_ffsll(i) ffsll(i) + +#if ((_GNUC__ == 3 && __GNUC_MINOR__ >= 4) || __GNUC__ >= 4) +#define _mesa_bitcount(i) __builtin_popcount(i) +#else +extern unsigned int +_mesa_bitcount(unsigned int n); +#endif + +#else +extern int +_mesa_ffs(int32_t i); + +extern int +_mesa_ffsll(int64_t i); + +extern unsigned int +_mesa_bitcount(unsigned int n); +#endif + +extern GLhalfARB +_mesa_float_to_half(float f); + +extern float +_mesa_half_to_float(GLhalfARB h); + + +extern void * +_mesa_bsearch( const void *key, const void *base, size_t nmemb, size_t size, + int (*compar)(const void *, const void *) ); + +extern char * +_mesa_getenv( const char *var ); + +extern char * +_mesa_strdup( const char *s ); + +extern float +_mesa_strtof( const char *s, char **end ); + +extern unsigned int +_mesa_str_checksum(const char *str); + +extern int +_mesa_snprintf( char *str, size_t size, const char *fmt, ... ) PRINTFLIKE(3, 4); + +struct gl_context; + +extern void +_mesa_warning( struct gl_context *gc, const char *fmtString, ... ) PRINTFLIKE(2, 3); + +extern void +_mesa_problem( const struct gl_context *ctx, const char *fmtString, ... ) PRINTFLIKE(2, 3); + +extern void +_mesa_error( struct gl_context *ctx, GLenum error, const char *fmtString, ... ) PRINTFLIKE(3, 4); + +extern void +_mesa_debug( const struct gl_context *ctx, const char *fmtString, ... ) PRINTFLIKE(2, 3); + + +#if defined(_MSC_VER) && !defined(snprintf) +#define snprintf _snprintf +#endif + + +#ifdef __cplusplus +} +#endif + + +#endif /* IMPORTS_H */ diff --git a/mesalib/src/mesa/main/lines.c b/mesalib/src/mesa/main/lines.c index 1df409f45..79bf5679d 100644 --- a/mesalib/src/mesa/main/lines.c +++ b/mesalib/src/mesa/main/lines.c @@ -1,117 +1,117 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5.3 - * - * 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 "context.h" -#include "lines.h" -#include "macros.h" -#include "mtypes.h" - - -/** - * Set the line width. - * - * \param width line width in pixels. - * - * \sa glLineWidth(). - */ -void GLAPIENTRY -_mesa_LineWidth( GLfloat width ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glLineWidth %f\n", width); - - if (width<=0.0) { - _mesa_error( ctx, GL_INVALID_VALUE, "glLineWidth" ); - return; - } - - if (ctx->Line.Width == width) - return; - - FLUSH_VERTICES(ctx, _NEW_LINE); - ctx->Line.Width = width; - - if (ctx->Driver.LineWidth) - ctx->Driver.LineWidth(ctx, width); -} - - -/** - * Set the line stipple pattern. - * - * \param factor pattern scale factor. - * \param pattern bit pattern. - * - * \sa glLineStipple(). - * - * Updates gl_line_attrib::StippleFactor and gl_line_attrib::StipplePattern. On - * change flushes the vertices and notifies the driver via - * the dd_function_table::LineStipple callback. - */ -void GLAPIENTRY -_mesa_LineStipple( GLint factor, GLushort pattern ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glLineStipple %d %u\n", factor, pattern); - - factor = CLAMP( factor, 1, 256 ); - - if (ctx->Line.StippleFactor == factor && - ctx->Line.StipplePattern == pattern) - return; - - FLUSH_VERTICES(ctx, _NEW_LINE); - ctx->Line.StippleFactor = factor; - ctx->Line.StipplePattern = pattern; - - if (ctx->Driver.LineStipple) - ctx->Driver.LineStipple( ctx, factor, pattern ); -} - - -/** - * Initialize the context line state. - * - * \param ctx GL context. - * - * Initializes __struct gl_contextRec::Line and line related constants in - * __struct gl_contextRec::Const. - */ -void GLAPIENTRY -_mesa_init_line( struct gl_context * ctx ) -{ - ctx->Line.SmoothFlag = GL_FALSE; - ctx->Line.StippleFlag = GL_FALSE; - ctx->Line.Width = 1.0; - ctx->Line.StipplePattern = 0xffff; - ctx->Line.StippleFactor = 1; -} +/* + * Mesa 3-D graphics library + * Version: 6.5.3 + * + * 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 "context.h" +#include "lines.h" +#include "macros.h" +#include "mtypes.h" + + +/** + * Set the line width. + * + * \param width line width in pixels. + * + * \sa glLineWidth(). + */ +void GLAPIENTRY +_mesa_LineWidth( GLfloat width ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glLineWidth %f\n", width); + + if (width<=0.0) { + _mesa_error( ctx, GL_INVALID_VALUE, "glLineWidth" ); + return; + } + + if (ctx->Line.Width == width) + return; + + FLUSH_VERTICES(ctx, _NEW_LINE); + ctx->Line.Width = width; + + if (ctx->Driver.LineWidth) + ctx->Driver.LineWidth(ctx, width); +} + + +/** + * Set the line stipple pattern. + * + * \param factor pattern scale factor. + * \param pattern bit pattern. + * + * \sa glLineStipple(). + * + * Updates gl_line_attrib::StippleFactor and gl_line_attrib::StipplePattern. On + * change flushes the vertices and notifies the driver via + * the dd_function_table::LineStipple callback. + */ +void GLAPIENTRY +_mesa_LineStipple( GLint factor, GLushort pattern ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glLineStipple %d %u\n", factor, pattern); + + factor = CLAMP( factor, 1, 256 ); + + if (ctx->Line.StippleFactor == factor && + ctx->Line.StipplePattern == pattern) + return; + + FLUSH_VERTICES(ctx, _NEW_LINE); + ctx->Line.StippleFactor = factor; + ctx->Line.StipplePattern = pattern; + + if (ctx->Driver.LineStipple) + ctx->Driver.LineStipple( ctx, factor, pattern ); +} + + +/** + * Initialize the context line state. + * + * \param ctx GL context. + * + * Initializes __struct gl_contextRec::Line and line related constants in + * __struct gl_contextRec::Const. + */ +void GLAPIENTRY +_mesa_init_line( struct gl_context * ctx ) +{ + ctx->Line.SmoothFlag = GL_FALSE; + ctx->Line.StippleFlag = GL_FALSE; + ctx->Line.Width = 1.0; + ctx->Line.StipplePattern = 0xffff; + ctx->Line.StippleFactor = 1; +} diff --git a/mesalib/src/mesa/main/macros.h b/mesalib/src/mesa/main/macros.h index 1d5d7f346..01e4d20af 100644 --- a/mesalib/src/mesa/main/macros.h +++ b/mesalib/src/mesa/main/macros.h @@ -1,725 +1,725 @@ -/** - * \file macros.h - * A collection of useful macros. - */ - -/* - * Mesa 3-D graphics library - * Version: 6.5.2 - * - * 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. - */ - - -#ifndef MACROS_H -#define MACROS_H - -#include "imports.h" - - -/** - * \name Integer / float conversion for colors, normals, etc. - */ -/*@{*/ - -/** Convert GLubyte in [0,255] to GLfloat in [0.0,1.0] */ -extern GLfloat _mesa_ubyte_to_float_color_tab[256]; -#define UBYTE_TO_FLOAT(u) _mesa_ubyte_to_float_color_tab[(unsigned int)(u)] - -/** Convert GLfloat in [0.0,1.0] to GLubyte in [0,255] */ -#define FLOAT_TO_UBYTE(X) ((GLubyte) (GLint) ((X) * 255.0F)) - - -/** Convert GLbyte in [-128,127] to GLfloat in [-1.0,1.0] */ -#define BYTE_TO_FLOAT(B) ((2.0F * (B) + 1.0F) * (1.0F/255.0F)) - -/** Convert GLfloat in [-1.0,1.0] to GLbyte in [-128,127] */ -#define FLOAT_TO_BYTE(X) ( (((GLint) (255.0F * (X))) - 1) / 2 ) - - -/** Convert GLbyte in [-128,127] to GLfloat in [-1.0,1.0], texture/fb data */ -#define BYTE_TO_FLOAT_TEX(B) ((B) == -128 ? -1.0F : (B) * (1.0F/127.0F)) - -/** Convert GLfloat in [-1.0,1.0] to GLbyte in [-128,127], texture/fb data */ -#define FLOAT_TO_BYTE_TEX(X) CLAMP( (GLint) (127.0F * (X)), -128, 127 ) - -/** Convert GLushort in [0,65535] to GLfloat in [0.0,1.0] */ -#define USHORT_TO_FLOAT(S) ((GLfloat) (S) * (1.0F / 65535.0F)) - -/** Convert GLfloat in [0.0,1.0] to GLushort in [0, 65535] */ -#define FLOAT_TO_USHORT(X) ((GLuint) ((X) * 65535.0F)) - - -/** Convert GLshort in [-32768,32767] to GLfloat in [-1.0,1.0] */ -#define SHORT_TO_FLOAT(S) ((2.0F * (S) + 1.0F) * (1.0F/65535.0F)) - -/** Convert GLfloat in [-1.0,1.0] to GLshort in [-32768,32767] */ -#define FLOAT_TO_SHORT(X) ( (((GLint) (65535.0F * (X))) - 1) / 2 ) - - -/** Convert GLshort in [-32768,32767] to GLfloat in [-1.0,1.0], texture/fb data */ -#define SHORT_TO_FLOAT_TEX(S) ((S) == -32768 ? -1.0F : (S) * (1.0F/32767.0F)) - -/** Convert GLfloat in [-1.0,1.0] to GLshort in [-32768,32767], texture/fb data */ -#define FLOAT_TO_SHORT_TEX(X) ( (GLint) (32767.0F * (X)) ) - - -/** Convert GLuint in [0,4294967295] to GLfloat in [0.0,1.0] */ -#define UINT_TO_FLOAT(U) ((GLfloat) ((U) * (1.0F / 4294967295.0))) - -/** Convert GLfloat in [0.0,1.0] to GLuint in [0,4294967295] */ -#define FLOAT_TO_UINT(X) ((GLuint) ((X) * 4294967295.0)) - - -/** Convert GLint in [-2147483648,2147483647] to GLfloat in [-1.0,1.0] */ -#define INT_TO_FLOAT(I) ((GLfloat) ((2.0F * (I) + 1.0F) * (1.0F/4294967294.0))) - -/** Convert GLfloat in [-1.0,1.0] to GLint in [-2147483648,2147483647] */ -/* causes overflow: -#define FLOAT_TO_INT(X) ( (((GLint) (4294967294.0 * (X))) - 1) / 2 ) -*/ -/* a close approximation: */ -#define FLOAT_TO_INT(X) ( (GLint) (2147483647.0 * (X)) ) - -/** Convert GLfloat in [-1.0,1.0] to GLint64 in [-(1<<63),(1 << 63) -1] */ -#define FLOAT_TO_INT64(X) ( (GLint64) (9223372036854775807.0 * (double)(X)) ) - - -/** Convert GLint in [-2147483648,2147483647] to GLfloat in [-1.0,1.0], texture/fb data */ -#define INT_TO_FLOAT_TEX(I) ((I) == -2147483648 ? -1.0F : (I) * (1.0F/2147483647.0)) - -/** Convert GLfloat in [-1.0,1.0] to GLint in [-2147483648,2147483647], texture/fb data */ -#define FLOAT_TO_INT_TEX(X) ( (GLint) (2147483647.0 * (X)) ) - - -#define BYTE_TO_UBYTE(b) ((GLubyte) ((b) < 0 ? 0 : (GLubyte) (b))) -#define SHORT_TO_UBYTE(s) ((GLubyte) ((s) < 0 ? 0 : (GLubyte) ((s) >> 7))) -#define USHORT_TO_UBYTE(s) ((GLubyte) ((s) >> 8)) -#define INT_TO_UBYTE(i) ((GLubyte) ((i) < 0 ? 0 : (GLubyte) ((i) >> 23))) -#define UINT_TO_UBYTE(i) ((GLubyte) ((i) >> 24)) - - -#define BYTE_TO_USHORT(b) ((b) < 0 ? 0 : ((GLushort) (((b) * 65535) / 255))) -#define UBYTE_TO_USHORT(b) (((GLushort) (b) << 8) | (GLushort) (b)) -#define SHORT_TO_USHORT(s) ((s) < 0 ? 0 : ((GLushort) (((s) * 65535 / 32767)))) -#define INT_TO_USHORT(i) ((i) < 0 ? 0 : ((GLushort) ((i) >> 15))) -#define UINT_TO_USHORT(i) ((i) < 0 ? 0 : ((GLushort) ((i) >> 16))) -#define UNCLAMPED_FLOAT_TO_USHORT(us, f) \ - us = ( (GLushort) IROUND( CLAMP((f), 0.0F, 1.0F) * 65535.0F) ) -#define CLAMPED_FLOAT_TO_USHORT(us, f) \ - us = ( (GLushort) IROUND( (f) * 65535.0F) ) - -#define UNCLAMPED_FLOAT_TO_SHORT(s, f) \ - s = ( (GLshort) IROUND( CLAMP((f), -1.0F, 1.0F) * 32767.0F) ) - -/*** - *** UNCLAMPED_FLOAT_TO_UBYTE: clamp float to [0,1] and map to ubyte in [0,255] - *** CLAMPED_FLOAT_TO_UBYTE: map float known to be in [0,1] to ubyte in [0,255] - ***/ -#if defined(USE_IEEE) && !defined(DEBUG) -#define IEEE_0996 0x3f7f0000 /* 0.996 or so */ -/* This function/macro is sensitive to precision. Test very carefully - * if you change it! - */ -#define UNCLAMPED_FLOAT_TO_UBYTE(UB, F) \ - do { \ - fi_type __tmp; \ - __tmp.f = (F); \ - if (__tmp.i < 0) \ - UB = (GLubyte) 0; \ - else if (__tmp.i >= IEEE_0996) \ - UB = (GLubyte) 255; \ - else { \ - __tmp.f = __tmp.f * (255.0F/256.0F) + 32768.0F; \ - UB = (GLubyte) __tmp.i; \ - } \ - } while (0) -#define CLAMPED_FLOAT_TO_UBYTE(UB, F) \ - do { \ - fi_type __tmp; \ - __tmp.f = (F) * (255.0F/256.0F) + 32768.0F; \ - UB = (GLubyte) __tmp.i; \ - } while (0) -#else -#define UNCLAMPED_FLOAT_TO_UBYTE(ub, f) \ - ub = ((GLubyte) IROUND(CLAMP((f), 0.0F, 1.0F) * 255.0F)) -#define CLAMPED_FLOAT_TO_UBYTE(ub, f) \ - ub = ((GLubyte) IROUND((f) * 255.0F)) -#endif - -/*@}*/ - - -/** Stepping a GLfloat pointer by a byte stride */ -#define STRIDE_F(p, i) (p = (GLfloat *)((GLubyte *)p + i)) -/** Stepping a GLuint pointer by a byte stride */ -#define STRIDE_UI(p, i) (p = (GLuint *)((GLubyte *)p + i)) -/** Stepping a GLubyte[4] pointer by a byte stride */ -#define STRIDE_4UB(p, i) (p = (GLubyte (*)[4])((GLubyte *)p + i)) -/** Stepping a GLfloat[4] pointer by a byte stride */ -#define STRIDE_4F(p, i) (p = (GLfloat (*)[4])((GLubyte *)p + i)) -/** Stepping a GLchan[4] pointer by a byte stride */ -#define STRIDE_4CHAN(p, i) (p = (GLchan (*)[4])((GLubyte *)p + i)) -/** Stepping a GLchan pointer by a byte stride */ -#define STRIDE_CHAN(p, i) (p = (GLchan *)((GLubyte *)p + i)) -/** Stepping a \p t pointer by a byte stride */ -#define STRIDE_T(p, t, i) (p = (t)((GLubyte *)p + i)) - - -/**********************************************************************/ -/** \name 4-element vector operations */ -/*@{*/ - -/** Zero */ -#define ZERO_4V( DST ) (DST)[0] = (DST)[1] = (DST)[2] = (DST)[3] = 0 - -/** Test for equality */ -#define TEST_EQ_4V(a,b) ((a)[0] == (b)[0] && \ - (a)[1] == (b)[1] && \ - (a)[2] == (b)[2] && \ - (a)[3] == (b)[3]) - -/** Test for equality (unsigned bytes) */ -#if defined(__i386__) -#define TEST_EQ_4UBV(DST, SRC) *((GLuint*)(DST)) == *((GLuint*)(SRC)) -#else -#define TEST_EQ_4UBV(DST, SRC) TEST_EQ_4V(DST, SRC) -#endif - -/** Copy a 4-element vector */ -#define COPY_4V( DST, SRC ) \ -do { \ - (DST)[0] = (SRC)[0]; \ - (DST)[1] = (SRC)[1]; \ - (DST)[2] = (SRC)[2]; \ - (DST)[3] = (SRC)[3]; \ -} while (0) - -/** Copy a 4-element vector with cast */ -#define COPY_4V_CAST( DST, SRC, CAST ) \ -do { \ - (DST)[0] = (CAST)(SRC)[0]; \ - (DST)[1] = (CAST)(SRC)[1]; \ - (DST)[2] = (CAST)(SRC)[2]; \ - (DST)[3] = (CAST)(SRC)[3]; \ -} while (0) - -/** Copy a 4-element unsigned byte vector */ -#if defined(__i386__) -#define COPY_4UBV(DST, SRC) \ -do { \ - *((GLuint*)(DST)) = *((GLuint*)(SRC)); \ -} while (0) -#else -/* The GLuint cast might fail if DST or SRC are not dword-aligned (RISC) */ -#define COPY_4UBV(DST, SRC) \ -do { \ - (DST)[0] = (SRC)[0]; \ - (DST)[1] = (SRC)[1]; \ - (DST)[2] = (SRC)[2]; \ - (DST)[3] = (SRC)[3]; \ -} while (0) -#endif - -/** - * Copy a 4-element float vector - * memcpy seems to be most efficient - */ -#define COPY_4FV( DST, SRC ) \ -do { \ - memcpy(DST, SRC, sizeof(GLfloat) * 4); \ -} while (0) - -/** Copy \p SZ elements into a 4-element vector */ -#define COPY_SZ_4V(DST, SZ, SRC) \ -do { \ - switch (SZ) { \ - case 4: (DST)[3] = (SRC)[3]; \ - case 3: (DST)[2] = (SRC)[2]; \ - case 2: (DST)[1] = (SRC)[1]; \ - case 1: (DST)[0] = (SRC)[0]; \ - } \ -} while(0) - -/** Copy \p SZ elements into a homegeneous (4-element) vector, giving - * default values to the remaining */ -#define COPY_CLEAN_4V(DST, SZ, SRC) \ -do { \ - ASSIGN_4V( DST, 0, 0, 0, 1 ); \ - COPY_SZ_4V( DST, SZ, SRC ); \ -} while (0) - -/** Subtraction */ -#define SUB_4V( DST, SRCA, SRCB ) \ -do { \ - (DST)[0] = (SRCA)[0] - (SRCB)[0]; \ - (DST)[1] = (SRCA)[1] - (SRCB)[1]; \ - (DST)[2] = (SRCA)[2] - (SRCB)[2]; \ - (DST)[3] = (SRCA)[3] - (SRCB)[3]; \ -} while (0) - -/** Addition */ -#define ADD_4V( DST, SRCA, SRCB ) \ -do { \ - (DST)[0] = (SRCA)[0] + (SRCB)[0]; \ - (DST)[1] = (SRCA)[1] + (SRCB)[1]; \ - (DST)[2] = (SRCA)[2] + (SRCB)[2]; \ - (DST)[3] = (SRCA)[3] + (SRCB)[3]; \ -} while (0) - -/** Element-wise multiplication */ -#define SCALE_4V( DST, SRCA, SRCB ) \ -do { \ - (DST)[0] = (SRCA)[0] * (SRCB)[0]; \ - (DST)[1] = (SRCA)[1] * (SRCB)[1]; \ - (DST)[2] = (SRCA)[2] * (SRCB)[2]; \ - (DST)[3] = (SRCA)[3] * (SRCB)[3]; \ -} while (0) - -/** In-place addition */ -#define ACC_4V( DST, SRC ) \ -do { \ - (DST)[0] += (SRC)[0]; \ - (DST)[1] += (SRC)[1]; \ - (DST)[2] += (SRC)[2]; \ - (DST)[3] += (SRC)[3]; \ -} while (0) - -/** Element-wise multiplication and addition */ -#define ACC_SCALE_4V( DST, SRCA, SRCB ) \ -do { \ - (DST)[0] += (SRCA)[0] * (SRCB)[0]; \ - (DST)[1] += (SRCA)[1] * (SRCB)[1]; \ - (DST)[2] += (SRCA)[2] * (SRCB)[2]; \ - (DST)[3] += (SRCA)[3] * (SRCB)[3]; \ -} while (0) - -/** In-place scalar multiplication and addition */ -#define ACC_SCALE_SCALAR_4V( DST, S, SRCB ) \ -do { \ - (DST)[0] += S * (SRCB)[0]; \ - (DST)[1] += S * (SRCB)[1]; \ - (DST)[2] += S * (SRCB)[2]; \ - (DST)[3] += S * (SRCB)[3]; \ -} while (0) - -/** Scalar multiplication */ -#define SCALE_SCALAR_4V( DST, S, SRCB ) \ -do { \ - (DST)[0] = S * (SRCB)[0]; \ - (DST)[1] = S * (SRCB)[1]; \ - (DST)[2] = S * (SRCB)[2]; \ - (DST)[3] = S * (SRCB)[3]; \ -} while (0) - -/** In-place scalar multiplication */ -#define SELF_SCALE_SCALAR_4V( DST, S ) \ -do { \ - (DST)[0] *= S; \ - (DST)[1] *= S; \ - (DST)[2] *= S; \ - (DST)[3] *= S; \ -} while (0) - -/** Assignment */ -#define ASSIGN_4V( V, V0, V1, V2, V3 ) \ -do { \ - V[0] = V0; \ - V[1] = V1; \ - V[2] = V2; \ - V[3] = V3; \ -} while(0) - -/*@}*/ - - -/**********************************************************************/ -/** \name 3-element vector operations*/ -/*@{*/ - -/** Zero */ -#define ZERO_3V( DST ) (DST)[0] = (DST)[1] = (DST)[2] = 0 - -/** Test for equality */ -#define TEST_EQ_3V(a,b) \ - ((a)[0] == (b)[0] && \ - (a)[1] == (b)[1] && \ - (a)[2] == (b)[2]) - -/** Copy a 3-element vector */ -#define COPY_3V( DST, SRC ) \ -do { \ - (DST)[0] = (SRC)[0]; \ - (DST)[1] = (SRC)[1]; \ - (DST)[2] = (SRC)[2]; \ -} while (0) - -/** Copy a 3-element vector with cast */ -#define COPY_3V_CAST( DST, SRC, CAST ) \ -do { \ - (DST)[0] = (CAST)(SRC)[0]; \ - (DST)[1] = (CAST)(SRC)[1]; \ - (DST)[2] = (CAST)(SRC)[2]; \ -} while (0) - -/** Copy a 3-element float vector */ -#define COPY_3FV( DST, SRC ) \ -do { \ - const GLfloat *_tmp = (SRC); \ - (DST)[0] = _tmp[0]; \ - (DST)[1] = _tmp[1]; \ - (DST)[2] = _tmp[2]; \ -} while (0) - -/** Subtraction */ -#define SUB_3V( DST, SRCA, SRCB ) \ -do { \ - (DST)[0] = (SRCA)[0] - (SRCB)[0]; \ - (DST)[1] = (SRCA)[1] - (SRCB)[1]; \ - (DST)[2] = (SRCA)[2] - (SRCB)[2]; \ -} while (0) - -/** Addition */ -#define ADD_3V( DST, SRCA, SRCB ) \ -do { \ - (DST)[0] = (SRCA)[0] + (SRCB)[0]; \ - (DST)[1] = (SRCA)[1] + (SRCB)[1]; \ - (DST)[2] = (SRCA)[2] + (SRCB)[2]; \ -} while (0) - -/** In-place scalar multiplication */ -#define SCALE_3V( DST, SRCA, SRCB ) \ -do { \ - (DST)[0] = (SRCA)[0] * (SRCB)[0]; \ - (DST)[1] = (SRCA)[1] * (SRCB)[1]; \ - (DST)[2] = (SRCA)[2] * (SRCB)[2]; \ -} while (0) - -/** In-place element-wise multiplication */ -#define SELF_SCALE_3V( DST, SRC ) \ -do { \ - (DST)[0] *= (SRC)[0]; \ - (DST)[1] *= (SRC)[1]; \ - (DST)[2] *= (SRC)[2]; \ -} while (0) - -/** In-place addition */ -#define ACC_3V( DST, SRC ) \ -do { \ - (DST)[0] += (SRC)[0]; \ - (DST)[1] += (SRC)[1]; \ - (DST)[2] += (SRC)[2]; \ -} while (0) - -/** Element-wise multiplication and addition */ -#define ACC_SCALE_3V( DST, SRCA, SRCB ) \ -do { \ - (DST)[0] += (SRCA)[0] * (SRCB)[0]; \ - (DST)[1] += (SRCA)[1] * (SRCB)[1]; \ - (DST)[2] += (SRCA)[2] * (SRCB)[2]; \ -} while (0) - -/** Scalar multiplication */ -#define SCALE_SCALAR_3V( DST, S, SRCB ) \ -do { \ - (DST)[0] = S * (SRCB)[0]; \ - (DST)[1] = S * (SRCB)[1]; \ - (DST)[2] = S * (SRCB)[2]; \ -} while (0) - -/** In-place scalar multiplication and addition */ -#define ACC_SCALE_SCALAR_3V( DST, S, SRCB ) \ -do { \ - (DST)[0] += S * (SRCB)[0]; \ - (DST)[1] += S * (SRCB)[1]; \ - (DST)[2] += S * (SRCB)[2]; \ -} while (0) - -/** In-place scalar multiplication */ -#define SELF_SCALE_SCALAR_3V( DST, S ) \ -do { \ - (DST)[0] *= S; \ - (DST)[1] *= S; \ - (DST)[2] *= S; \ -} while (0) - -/** In-place scalar addition */ -#define ACC_SCALAR_3V( DST, S ) \ -do { \ - (DST)[0] += S; \ - (DST)[1] += S; \ - (DST)[2] += S; \ -} while (0) - -/** Assignment */ -#define ASSIGN_3V( V, V0, V1, V2 ) \ -do { \ - V[0] = V0; \ - V[1] = V1; \ - V[2] = V2; \ -} while(0) - -/*@}*/ - - -/**********************************************************************/ -/** \name 2-element vector operations*/ -/*@{*/ - -/** Zero */ -#define ZERO_2V( DST ) (DST)[0] = (DST)[1] = 0 - -/** Copy a 2-element vector */ -#define COPY_2V( DST, SRC ) \ -do { \ - (DST)[0] = (SRC)[0]; \ - (DST)[1] = (SRC)[1]; \ -} while (0) - -/** Copy a 2-element vector with cast */ -#define COPY_2V_CAST( DST, SRC, CAST ) \ -do { \ - (DST)[0] = (CAST)(SRC)[0]; \ - (DST)[1] = (CAST)(SRC)[1]; \ -} while (0) - -/** Copy a 2-element float vector */ -#define COPY_2FV( DST, SRC ) \ -do { \ - const GLfloat *_tmp = (SRC); \ - (DST)[0] = _tmp[0]; \ - (DST)[1] = _tmp[1]; \ -} while (0) - -/** Subtraction */ -#define SUB_2V( DST, SRCA, SRCB ) \ -do { \ - (DST)[0] = (SRCA)[0] - (SRCB)[0]; \ - (DST)[1] = (SRCA)[1] - (SRCB)[1]; \ -} while (0) - -/** Addition */ -#define ADD_2V( DST, SRCA, SRCB ) \ -do { \ - (DST)[0] = (SRCA)[0] + (SRCB)[0]; \ - (DST)[1] = (SRCA)[1] + (SRCB)[1]; \ -} while (0) - -/** In-place scalar multiplication */ -#define SCALE_2V( DST, SRCA, SRCB ) \ -do { \ - (DST)[0] = (SRCA)[0] * (SRCB)[0]; \ - (DST)[1] = (SRCA)[1] * (SRCB)[1]; \ -} while (0) - -/** In-place addition */ -#define ACC_2V( DST, SRC ) \ -do { \ - (DST)[0] += (SRC)[0]; \ - (DST)[1] += (SRC)[1]; \ -} while (0) - -/** Element-wise multiplication and addition */ -#define ACC_SCALE_2V( DST, SRCA, SRCB ) \ -do { \ - (DST)[0] += (SRCA)[0] * (SRCB)[0]; \ - (DST)[1] += (SRCA)[1] * (SRCB)[1]; \ -} while (0) - -/** Scalar multiplication */ -#define SCALE_SCALAR_2V( DST, S, SRCB ) \ -do { \ - (DST)[0] = S * (SRCB)[0]; \ - (DST)[1] = S * (SRCB)[1]; \ -} while (0) - -/** In-place scalar multiplication and addition */ -#define ACC_SCALE_SCALAR_2V( DST, S, SRCB ) \ -do { \ - (DST)[0] += S * (SRCB)[0]; \ - (DST)[1] += S * (SRCB)[1]; \ -} while (0) - -/** In-place scalar multiplication */ -#define SELF_SCALE_SCALAR_2V( DST, S ) \ -do { \ - (DST)[0] *= S; \ - (DST)[1] *= S; \ -} while (0) - -/** In-place scalar addition */ -#define ACC_SCALAR_2V( DST, S ) \ -do { \ - (DST)[0] += S; \ - (DST)[1] += S; \ -} while (0) - -/** Assign scalers to short vectors */ -#define ASSIGN_2V( V, V0, V1 ) \ -do { \ - V[0] = V0; \ - V[1] = V1; \ -} while(0) - -/*@}*/ - - -/** \name Linear interpolation macros */ -/*@{*/ - -/** - * Linear interpolation - * - * \note \p OUT argument is evaluated twice! - * \note Be wary of using *coord++ as an argument to any of these macros! - */ -#define LINTERP(T, OUT, IN) ((OUT) + (T) * ((IN) - (OUT))) - -/* Can do better with integer math - */ -#define INTERP_UB( t, dstub, outub, inub ) \ -do { \ - GLfloat inf = UBYTE_TO_FLOAT( inub ); \ - GLfloat outf = UBYTE_TO_FLOAT( outub ); \ - GLfloat dstf = LINTERP( t, outf, inf ); \ - UNCLAMPED_FLOAT_TO_UBYTE( dstub, dstf ); \ -} while (0) - -#define INTERP_CHAN( t, dstc, outc, inc ) \ -do { \ - GLfloat inf = CHAN_TO_FLOAT( inc ); \ - GLfloat outf = CHAN_TO_FLOAT( outc ); \ - GLfloat dstf = LINTERP( t, outf, inf ); \ - UNCLAMPED_FLOAT_TO_CHAN( dstc, dstf ); \ -} while (0) - -#define INTERP_UI( t, dstui, outui, inui ) \ - dstui = (GLuint) (GLint) LINTERP( (t), (GLfloat) (outui), (GLfloat) (inui) ) - -#define INTERP_F( t, dstf, outf, inf ) \ - dstf = LINTERP( t, outf, inf ) - -#define INTERP_4F( t, dst, out, in ) \ -do { \ - dst[0] = LINTERP( (t), (out)[0], (in)[0] ); \ - dst[1] = LINTERP( (t), (out)[1], (in)[1] ); \ - dst[2] = LINTERP( (t), (out)[2], (in)[2] ); \ - dst[3] = LINTERP( (t), (out)[3], (in)[3] ); \ -} while (0) - -#define INTERP_3F( t, dst, out, in ) \ -do { \ - dst[0] = LINTERP( (t), (out)[0], (in)[0] ); \ - dst[1] = LINTERP( (t), (out)[1], (in)[1] ); \ - dst[2] = LINTERP( (t), (out)[2], (in)[2] ); \ -} while (0) - -#define INTERP_4CHAN( t, dst, out, in ) \ -do { \ - INTERP_CHAN( (t), (dst)[0], (out)[0], (in)[0] ); \ - INTERP_CHAN( (t), (dst)[1], (out)[1], (in)[1] ); \ - INTERP_CHAN( (t), (dst)[2], (out)[2], (in)[2] ); \ - INTERP_CHAN( (t), (dst)[3], (out)[3], (in)[3] ); \ -} while (0) - -#define INTERP_3CHAN( t, dst, out, in ) \ -do { \ - INTERP_CHAN( (t), (dst)[0], (out)[0], (in)[0] ); \ - INTERP_CHAN( (t), (dst)[1], (out)[1], (in)[1] ); \ - INTERP_CHAN( (t), (dst)[2], (out)[2], (in)[2] ); \ -} while (0) - -#define INTERP_SZ( t, vec, to, out, in, sz ) \ -do { \ - switch (sz) { \ - case 4: vec[to][3] = LINTERP( (t), (vec)[out][3], (vec)[in][3] ); \ - case 3: vec[to][2] = LINTERP( (t), (vec)[out][2], (vec)[in][2] ); \ - case 2: vec[to][1] = LINTERP( (t), (vec)[out][1], (vec)[in][1] ); \ - case 1: vec[to][0] = LINTERP( (t), (vec)[out][0], (vec)[in][0] ); \ - } \ -} while(0) - -/*@}*/ - - - -/** Clamp X to [MIN,MAX] */ -#define CLAMP( X, MIN, MAX ) ( (X)<(MIN) ? (MIN) : ((X)>(MAX) ? (MAX) : (X)) ) - -/** Minimum of two values: */ -#define MIN2( A, B ) ( (A)<(B) ? (A) : (B) ) - -/** Maximum of two values: */ -#define MAX2( A, B ) ( (A)>(B) ? (A) : (B) ) - -/** Minimum and maximum of three values: */ -#define MIN3( A, B, C ) ((A) < (B) ? MIN2(A, C) : MIN2(B, C)) -#define MAX3( A, B, C ) ((A) > (B) ? MAX2(A, C) : MAX2(B, C)) - -/** Dot product of two 2-element vectors */ -#define DOT2( a, b ) ( (a)[0]*(b)[0] + (a)[1]*(b)[1] ) - -/** Dot product of two 3-element vectors */ -#define DOT3( a, b ) ( (a)[0]*(b)[0] + (a)[1]*(b)[1] + (a)[2]*(b)[2] ) - -/** Dot product of two 4-element vectors */ -#define DOT4( a, b ) ( (a)[0]*(b)[0] + (a)[1]*(b)[1] + \ - (a)[2]*(b)[2] + (a)[3]*(b)[3] ) - -/** Dot product of two 4-element vectors */ -#define DOT4V(v,a,b,c,d) (v[0]*(a) + v[1]*(b) + v[2]*(c) + v[3]*(d)) - - -/** Cross product of two 3-element vectors */ -#define CROSS3(n, u, v) \ -do { \ - (n)[0] = (u)[1]*(v)[2] - (u)[2]*(v)[1]; \ - (n)[1] = (u)[2]*(v)[0] - (u)[0]*(v)[2]; \ - (n)[2] = (u)[0]*(v)[1] - (u)[1]*(v)[0]; \ -} while (0) - - -/* Normalize a 3-element vector to unit length. */ -#define NORMALIZE_3FV( V ) \ -do { \ - GLfloat len = (GLfloat) LEN_SQUARED_3FV(V); \ - if (len) { \ - len = INV_SQRTF(len); \ - (V)[0] = (GLfloat) ((V)[0] * len); \ - (V)[1] = (GLfloat) ((V)[1] * len); \ - (V)[2] = (GLfloat) ((V)[2] * len); \ - } \ -} while(0) - -#define LEN_3FV( V ) (SQRTF((V)[0]*(V)[0]+(V)[1]*(V)[1]+(V)[2]*(V)[2])) -#define LEN_2FV( V ) (SQRTF((V)[0]*(V)[0]+(V)[1]*(V)[1])) - -#define LEN_SQUARED_3FV( V ) ((V)[0]*(V)[0]+(V)[1]*(V)[1]+(V)[2]*(V)[2]) -#define LEN_SQUARED_2FV( V ) ((V)[0]*(V)[0]+(V)[1]*(V)[1]) - - -/** casts to silence warnings with some compilers */ -#define ENUM_TO_INT(E) ((GLint)(E)) -#define ENUM_TO_FLOAT(E) ((GLfloat)(GLint)(E)) -#define ENUM_TO_DOUBLE(E) ((GLdouble)(GLint)(E)) -#define ENUM_TO_BOOLEAN(E) ((E) ? GL_TRUE : GL_FALSE) - - -#endif +/** + * \file macros.h + * A collection of useful macros. + */ + +/* + * Mesa 3-D graphics library + * Version: 6.5.2 + * + * 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. + */ + + +#ifndef MACROS_H +#define MACROS_H + +#include "imports.h" + + +/** + * \name Integer / float conversion for colors, normals, etc. + */ +/*@{*/ + +/** Convert GLubyte in [0,255] to GLfloat in [0.0,1.0] */ +extern GLfloat _mesa_ubyte_to_float_color_tab[256]; +#define UBYTE_TO_FLOAT(u) _mesa_ubyte_to_float_color_tab[(unsigned int)(u)] + +/** Convert GLfloat in [0.0,1.0] to GLubyte in [0,255] */ +#define FLOAT_TO_UBYTE(X) ((GLubyte) (GLint) ((X) * 255.0F)) + + +/** Convert GLbyte in [-128,127] to GLfloat in [-1.0,1.0] */ +#define BYTE_TO_FLOAT(B) ((2.0F * (B) + 1.0F) * (1.0F/255.0F)) + +/** Convert GLfloat in [-1.0,1.0] to GLbyte in [-128,127] */ +#define FLOAT_TO_BYTE(X) ( (((GLint) (255.0F * (X))) - 1) / 2 ) + + +/** Convert GLbyte in [-128,127] to GLfloat in [-1.0,1.0], texture/fb data */ +#define BYTE_TO_FLOAT_TEX(B) ((B) == -128 ? -1.0F : (B) * (1.0F/127.0F)) + +/** Convert GLfloat in [-1.0,1.0] to GLbyte in [-128,127], texture/fb data */ +#define FLOAT_TO_BYTE_TEX(X) CLAMP( (GLint) (127.0F * (X)), -128, 127 ) + +/** Convert GLushort in [0,65535] to GLfloat in [0.0,1.0] */ +#define USHORT_TO_FLOAT(S) ((GLfloat) (S) * (1.0F / 65535.0F)) + +/** Convert GLfloat in [0.0,1.0] to GLushort in [0, 65535] */ +#define FLOAT_TO_USHORT(X) ((GLuint) ((X) * 65535.0F)) + + +/** Convert GLshort in [-32768,32767] to GLfloat in [-1.0,1.0] */ +#define SHORT_TO_FLOAT(S) ((2.0F * (S) + 1.0F) * (1.0F/65535.0F)) + +/** Convert GLfloat in [-1.0,1.0] to GLshort in [-32768,32767] */ +#define FLOAT_TO_SHORT(X) ( (((GLint) (65535.0F * (X))) - 1) / 2 ) + + +/** Convert GLshort in [-32768,32767] to GLfloat in [-1.0,1.0], texture/fb data */ +#define SHORT_TO_FLOAT_TEX(S) ((S) == -32768 ? -1.0F : (S) * (1.0F/32767.0F)) + +/** Convert GLfloat in [-1.0,1.0] to GLshort in [-32768,32767], texture/fb data */ +#define FLOAT_TO_SHORT_TEX(X) ( (GLint) (32767.0F * (X)) ) + + +/** Convert GLuint in [0,4294967295] to GLfloat in [0.0,1.0] */ +#define UINT_TO_FLOAT(U) ((GLfloat) ((U) * (1.0F / 4294967295.0))) + +/** Convert GLfloat in [0.0,1.0] to GLuint in [0,4294967295] */ +#define FLOAT_TO_UINT(X) ((GLuint) ((X) * 4294967295.0)) + + +/** Convert GLint in [-2147483648,2147483647] to GLfloat in [-1.0,1.0] */ +#define INT_TO_FLOAT(I) ((GLfloat) ((2.0F * (I) + 1.0F) * (1.0F/4294967294.0))) + +/** Convert GLfloat in [-1.0,1.0] to GLint in [-2147483648,2147483647] */ +/* causes overflow: +#define FLOAT_TO_INT(X) ( (((GLint) (4294967294.0 * (X))) - 1) / 2 ) +*/ +/* a close approximation: */ +#define FLOAT_TO_INT(X) ( (GLint) (2147483647.0 * (X)) ) + +/** Convert GLfloat in [-1.0,1.0] to GLint64 in [-(1<<63),(1 << 63) -1] */ +#define FLOAT_TO_INT64(X) ( (GLint64) (9223372036854775807.0 * (double)(X)) ) + + +/** Convert GLint in [-2147483648,2147483647] to GLfloat in [-1.0,1.0], texture/fb data */ +#define INT_TO_FLOAT_TEX(I) ((I) == -2147483648 ? -1.0F : (I) * (1.0F/2147483647.0)) + +/** Convert GLfloat in [-1.0,1.0] to GLint in [-2147483648,2147483647], texture/fb data */ +#define FLOAT_TO_INT_TEX(X) ( (GLint) (2147483647.0 * (X)) ) + + +#define BYTE_TO_UBYTE(b) ((GLubyte) ((b) < 0 ? 0 : (GLubyte) (b))) +#define SHORT_TO_UBYTE(s) ((GLubyte) ((s) < 0 ? 0 : (GLubyte) ((s) >> 7))) +#define USHORT_TO_UBYTE(s) ((GLubyte) ((s) >> 8)) +#define INT_TO_UBYTE(i) ((GLubyte) ((i) < 0 ? 0 : (GLubyte) ((i) >> 23))) +#define UINT_TO_UBYTE(i) ((GLubyte) ((i) >> 24)) + + +#define BYTE_TO_USHORT(b) ((b) < 0 ? 0 : ((GLushort) (((b) * 65535) / 255))) +#define UBYTE_TO_USHORT(b) (((GLushort) (b) << 8) | (GLushort) (b)) +#define SHORT_TO_USHORT(s) ((s) < 0 ? 0 : ((GLushort) (((s) * 65535 / 32767)))) +#define INT_TO_USHORT(i) ((i) < 0 ? 0 : ((GLushort) ((i) >> 15))) +#define UINT_TO_USHORT(i) ((i) < 0 ? 0 : ((GLushort) ((i) >> 16))) +#define UNCLAMPED_FLOAT_TO_USHORT(us, f) \ + us = ( (GLushort) IROUND( CLAMP((f), 0.0F, 1.0F) * 65535.0F) ) +#define CLAMPED_FLOAT_TO_USHORT(us, f) \ + us = ( (GLushort) IROUND( (f) * 65535.0F) ) + +#define UNCLAMPED_FLOAT_TO_SHORT(s, f) \ + s = ( (GLshort) IROUND( CLAMP((f), -1.0F, 1.0F) * 32767.0F) ) + +/*** + *** UNCLAMPED_FLOAT_TO_UBYTE: clamp float to [0,1] and map to ubyte in [0,255] + *** CLAMPED_FLOAT_TO_UBYTE: map float known to be in [0,1] to ubyte in [0,255] + ***/ +#if defined(USE_IEEE) && !defined(DEBUG) +#define IEEE_0996 0x3f7f0000 /* 0.996 or so */ +/* This function/macro is sensitive to precision. Test very carefully + * if you change it! + */ +#define UNCLAMPED_FLOAT_TO_UBYTE(UB, F) \ + do { \ + fi_type __tmp; \ + __tmp.f = (F); \ + if (__tmp.i < 0) \ + UB = (GLubyte) 0; \ + else if (__tmp.i >= IEEE_0996) \ + UB = (GLubyte) 255; \ + else { \ + __tmp.f = __tmp.f * (255.0F/256.0F) + 32768.0F; \ + UB = (GLubyte) __tmp.i; \ + } \ + } while (0) +#define CLAMPED_FLOAT_TO_UBYTE(UB, F) \ + do { \ + fi_type __tmp; \ + __tmp.f = (F) * (255.0F/256.0F) + 32768.0F; \ + UB = (GLubyte) __tmp.i; \ + } while (0) +#else +#define UNCLAMPED_FLOAT_TO_UBYTE(ub, f) \ + ub = ((GLubyte) IROUND(CLAMP((f), 0.0F, 1.0F) * 255.0F)) +#define CLAMPED_FLOAT_TO_UBYTE(ub, f) \ + ub = ((GLubyte) IROUND((f) * 255.0F)) +#endif + +/*@}*/ + + +/** Stepping a GLfloat pointer by a byte stride */ +#define STRIDE_F(p, i) (p = (GLfloat *)((GLubyte *)p + i)) +/** Stepping a GLuint pointer by a byte stride */ +#define STRIDE_UI(p, i) (p = (GLuint *)((GLubyte *)p + i)) +/** Stepping a GLubyte[4] pointer by a byte stride */ +#define STRIDE_4UB(p, i) (p = (GLubyte (*)[4])((GLubyte *)p + i)) +/** Stepping a GLfloat[4] pointer by a byte stride */ +#define STRIDE_4F(p, i) (p = (GLfloat (*)[4])((GLubyte *)p + i)) +/** Stepping a GLchan[4] pointer by a byte stride */ +#define STRIDE_4CHAN(p, i) (p = (GLchan (*)[4])((GLubyte *)p + i)) +/** Stepping a GLchan pointer by a byte stride */ +#define STRIDE_CHAN(p, i) (p = (GLchan *)((GLubyte *)p + i)) +/** Stepping a \p t pointer by a byte stride */ +#define STRIDE_T(p, t, i) (p = (t)((GLubyte *)p + i)) + + +/**********************************************************************/ +/** \name 4-element vector operations */ +/*@{*/ + +/** Zero */ +#define ZERO_4V( DST ) (DST)[0] = (DST)[1] = (DST)[2] = (DST)[3] = 0 + +/** Test for equality */ +#define TEST_EQ_4V(a,b) ((a)[0] == (b)[0] && \ + (a)[1] == (b)[1] && \ + (a)[2] == (b)[2] && \ + (a)[3] == (b)[3]) + +/** Test for equality (unsigned bytes) */ +#if defined(__i386__) +#define TEST_EQ_4UBV(DST, SRC) *((GLuint*)(DST)) == *((GLuint*)(SRC)) +#else +#define TEST_EQ_4UBV(DST, SRC) TEST_EQ_4V(DST, SRC) +#endif + +/** Copy a 4-element vector */ +#define COPY_4V( DST, SRC ) \ +do { \ + (DST)[0] = (SRC)[0]; \ + (DST)[1] = (SRC)[1]; \ + (DST)[2] = (SRC)[2]; \ + (DST)[3] = (SRC)[3]; \ +} while (0) + +/** Copy a 4-element vector with cast */ +#define COPY_4V_CAST( DST, SRC, CAST ) \ +do { \ + (DST)[0] = (CAST)(SRC)[0]; \ + (DST)[1] = (CAST)(SRC)[1]; \ + (DST)[2] = (CAST)(SRC)[2]; \ + (DST)[3] = (CAST)(SRC)[3]; \ +} while (0) + +/** Copy a 4-element unsigned byte vector */ +#if defined(__i386__) +#define COPY_4UBV(DST, SRC) \ +do { \ + *((GLuint*)(DST)) = *((GLuint*)(SRC)); \ +} while (0) +#else +/* The GLuint cast might fail if DST or SRC are not dword-aligned (RISC) */ +#define COPY_4UBV(DST, SRC) \ +do { \ + (DST)[0] = (SRC)[0]; \ + (DST)[1] = (SRC)[1]; \ + (DST)[2] = (SRC)[2]; \ + (DST)[3] = (SRC)[3]; \ +} while (0) +#endif + +/** + * Copy a 4-element float vector + * memcpy seems to be most efficient + */ +#define COPY_4FV( DST, SRC ) \ +do { \ + memcpy(DST, SRC, sizeof(GLfloat) * 4); \ +} while (0) + +/** Copy \p SZ elements into a 4-element vector */ +#define COPY_SZ_4V(DST, SZ, SRC) \ +do { \ + switch (SZ) { \ + case 4: (DST)[3] = (SRC)[3]; \ + case 3: (DST)[2] = (SRC)[2]; \ + case 2: (DST)[1] = (SRC)[1]; \ + case 1: (DST)[0] = (SRC)[0]; \ + } \ +} while(0) + +/** Copy \p SZ elements into a homegeneous (4-element) vector, giving + * default values to the remaining */ +#define COPY_CLEAN_4V(DST, SZ, SRC) \ +do { \ + ASSIGN_4V( DST, 0, 0, 0, 1 ); \ + COPY_SZ_4V( DST, SZ, SRC ); \ +} while (0) + +/** Subtraction */ +#define SUB_4V( DST, SRCA, SRCB ) \ +do { \ + (DST)[0] = (SRCA)[0] - (SRCB)[0]; \ + (DST)[1] = (SRCA)[1] - (SRCB)[1]; \ + (DST)[2] = (SRCA)[2] - (SRCB)[2]; \ + (DST)[3] = (SRCA)[3] - (SRCB)[3]; \ +} while (0) + +/** Addition */ +#define ADD_4V( DST, SRCA, SRCB ) \ +do { \ + (DST)[0] = (SRCA)[0] + (SRCB)[0]; \ + (DST)[1] = (SRCA)[1] + (SRCB)[1]; \ + (DST)[2] = (SRCA)[2] + (SRCB)[2]; \ + (DST)[3] = (SRCA)[3] + (SRCB)[3]; \ +} while (0) + +/** Element-wise multiplication */ +#define SCALE_4V( DST, SRCA, SRCB ) \ +do { \ + (DST)[0] = (SRCA)[0] * (SRCB)[0]; \ + (DST)[1] = (SRCA)[1] * (SRCB)[1]; \ + (DST)[2] = (SRCA)[2] * (SRCB)[2]; \ + (DST)[3] = (SRCA)[3] * (SRCB)[3]; \ +} while (0) + +/** In-place addition */ +#define ACC_4V( DST, SRC ) \ +do { \ + (DST)[0] += (SRC)[0]; \ + (DST)[1] += (SRC)[1]; \ + (DST)[2] += (SRC)[2]; \ + (DST)[3] += (SRC)[3]; \ +} while (0) + +/** Element-wise multiplication and addition */ +#define ACC_SCALE_4V( DST, SRCA, SRCB ) \ +do { \ + (DST)[0] += (SRCA)[0] * (SRCB)[0]; \ + (DST)[1] += (SRCA)[1] * (SRCB)[1]; \ + (DST)[2] += (SRCA)[2] * (SRCB)[2]; \ + (DST)[3] += (SRCA)[3] * (SRCB)[3]; \ +} while (0) + +/** In-place scalar multiplication and addition */ +#define ACC_SCALE_SCALAR_4V( DST, S, SRCB ) \ +do { \ + (DST)[0] += S * (SRCB)[0]; \ + (DST)[1] += S * (SRCB)[1]; \ + (DST)[2] += S * (SRCB)[2]; \ + (DST)[3] += S * (SRCB)[3]; \ +} while (0) + +/** Scalar multiplication */ +#define SCALE_SCALAR_4V( DST, S, SRCB ) \ +do { \ + (DST)[0] = S * (SRCB)[0]; \ + (DST)[1] = S * (SRCB)[1]; \ + (DST)[2] = S * (SRCB)[2]; \ + (DST)[3] = S * (SRCB)[3]; \ +} while (0) + +/** In-place scalar multiplication */ +#define SELF_SCALE_SCALAR_4V( DST, S ) \ +do { \ + (DST)[0] *= S; \ + (DST)[1] *= S; \ + (DST)[2] *= S; \ + (DST)[3] *= S; \ +} while (0) + +/** Assignment */ +#define ASSIGN_4V( V, V0, V1, V2, V3 ) \ +do { \ + V[0] = V0; \ + V[1] = V1; \ + V[2] = V2; \ + V[3] = V3; \ +} while(0) + +/*@}*/ + + +/**********************************************************************/ +/** \name 3-element vector operations*/ +/*@{*/ + +/** Zero */ +#define ZERO_3V( DST ) (DST)[0] = (DST)[1] = (DST)[2] = 0 + +/** Test for equality */ +#define TEST_EQ_3V(a,b) \ + ((a)[0] == (b)[0] && \ + (a)[1] == (b)[1] && \ + (a)[2] == (b)[2]) + +/** Copy a 3-element vector */ +#define COPY_3V( DST, SRC ) \ +do { \ + (DST)[0] = (SRC)[0]; \ + (DST)[1] = (SRC)[1]; \ + (DST)[2] = (SRC)[2]; \ +} while (0) + +/** Copy a 3-element vector with cast */ +#define COPY_3V_CAST( DST, SRC, CAST ) \ +do { \ + (DST)[0] = (CAST)(SRC)[0]; \ + (DST)[1] = (CAST)(SRC)[1]; \ + (DST)[2] = (CAST)(SRC)[2]; \ +} while (0) + +/** Copy a 3-element float vector */ +#define COPY_3FV( DST, SRC ) \ +do { \ + const GLfloat *_tmp = (SRC); \ + (DST)[0] = _tmp[0]; \ + (DST)[1] = _tmp[1]; \ + (DST)[2] = _tmp[2]; \ +} while (0) + +/** Subtraction */ +#define SUB_3V( DST, SRCA, SRCB ) \ +do { \ + (DST)[0] = (SRCA)[0] - (SRCB)[0]; \ + (DST)[1] = (SRCA)[1] - (SRCB)[1]; \ + (DST)[2] = (SRCA)[2] - (SRCB)[2]; \ +} while (0) + +/** Addition */ +#define ADD_3V( DST, SRCA, SRCB ) \ +do { \ + (DST)[0] = (SRCA)[0] + (SRCB)[0]; \ + (DST)[1] = (SRCA)[1] + (SRCB)[1]; \ + (DST)[2] = (SRCA)[2] + (SRCB)[2]; \ +} while (0) + +/** In-place scalar multiplication */ +#define SCALE_3V( DST, SRCA, SRCB ) \ +do { \ + (DST)[0] = (SRCA)[0] * (SRCB)[0]; \ + (DST)[1] = (SRCA)[1] * (SRCB)[1]; \ + (DST)[2] = (SRCA)[2] * (SRCB)[2]; \ +} while (0) + +/** In-place element-wise multiplication */ +#define SELF_SCALE_3V( DST, SRC ) \ +do { \ + (DST)[0] *= (SRC)[0]; \ + (DST)[1] *= (SRC)[1]; \ + (DST)[2] *= (SRC)[2]; \ +} while (0) + +/** In-place addition */ +#define ACC_3V( DST, SRC ) \ +do { \ + (DST)[0] += (SRC)[0]; \ + (DST)[1] += (SRC)[1]; \ + (DST)[2] += (SRC)[2]; \ +} while (0) + +/** Element-wise multiplication and addition */ +#define ACC_SCALE_3V( DST, SRCA, SRCB ) \ +do { \ + (DST)[0] += (SRCA)[0] * (SRCB)[0]; \ + (DST)[1] += (SRCA)[1] * (SRCB)[1]; \ + (DST)[2] += (SRCA)[2] * (SRCB)[2]; \ +} while (0) + +/** Scalar multiplication */ +#define SCALE_SCALAR_3V( DST, S, SRCB ) \ +do { \ + (DST)[0] = S * (SRCB)[0]; \ + (DST)[1] = S * (SRCB)[1]; \ + (DST)[2] = S * (SRCB)[2]; \ +} while (0) + +/** In-place scalar multiplication and addition */ +#define ACC_SCALE_SCALAR_3V( DST, S, SRCB ) \ +do { \ + (DST)[0] += S * (SRCB)[0]; \ + (DST)[1] += S * (SRCB)[1]; \ + (DST)[2] += S * (SRCB)[2]; \ +} while (0) + +/** In-place scalar multiplication */ +#define SELF_SCALE_SCALAR_3V( DST, S ) \ +do { \ + (DST)[0] *= S; \ + (DST)[1] *= S; \ + (DST)[2] *= S; \ +} while (0) + +/** In-place scalar addition */ +#define ACC_SCALAR_3V( DST, S ) \ +do { \ + (DST)[0] += S; \ + (DST)[1] += S; \ + (DST)[2] += S; \ +} while (0) + +/** Assignment */ +#define ASSIGN_3V( V, V0, V1, V2 ) \ +do { \ + V[0] = V0; \ + V[1] = V1; \ + V[2] = V2; \ +} while(0) + +/*@}*/ + + +/**********************************************************************/ +/** \name 2-element vector operations*/ +/*@{*/ + +/** Zero */ +#define ZERO_2V( DST ) (DST)[0] = (DST)[1] = 0 + +/** Copy a 2-element vector */ +#define COPY_2V( DST, SRC ) \ +do { \ + (DST)[0] = (SRC)[0]; \ + (DST)[1] = (SRC)[1]; \ +} while (0) + +/** Copy a 2-element vector with cast */ +#define COPY_2V_CAST( DST, SRC, CAST ) \ +do { \ + (DST)[0] = (CAST)(SRC)[0]; \ + (DST)[1] = (CAST)(SRC)[1]; \ +} while (0) + +/** Copy a 2-element float vector */ +#define COPY_2FV( DST, SRC ) \ +do { \ + const GLfloat *_tmp = (SRC); \ + (DST)[0] = _tmp[0]; \ + (DST)[1] = _tmp[1]; \ +} while (0) + +/** Subtraction */ +#define SUB_2V( DST, SRCA, SRCB ) \ +do { \ + (DST)[0] = (SRCA)[0] - (SRCB)[0]; \ + (DST)[1] = (SRCA)[1] - (SRCB)[1]; \ +} while (0) + +/** Addition */ +#define ADD_2V( DST, SRCA, SRCB ) \ +do { \ + (DST)[0] = (SRCA)[0] + (SRCB)[0]; \ + (DST)[1] = (SRCA)[1] + (SRCB)[1]; \ +} while (0) + +/** In-place scalar multiplication */ +#define SCALE_2V( DST, SRCA, SRCB ) \ +do { \ + (DST)[0] = (SRCA)[0] * (SRCB)[0]; \ + (DST)[1] = (SRCA)[1] * (SRCB)[1]; \ +} while (0) + +/** In-place addition */ +#define ACC_2V( DST, SRC ) \ +do { \ + (DST)[0] += (SRC)[0]; \ + (DST)[1] += (SRC)[1]; \ +} while (0) + +/** Element-wise multiplication and addition */ +#define ACC_SCALE_2V( DST, SRCA, SRCB ) \ +do { \ + (DST)[0] += (SRCA)[0] * (SRCB)[0]; \ + (DST)[1] += (SRCA)[1] * (SRCB)[1]; \ +} while (0) + +/** Scalar multiplication */ +#define SCALE_SCALAR_2V( DST, S, SRCB ) \ +do { \ + (DST)[0] = S * (SRCB)[0]; \ + (DST)[1] = S * (SRCB)[1]; \ +} while (0) + +/** In-place scalar multiplication and addition */ +#define ACC_SCALE_SCALAR_2V( DST, S, SRCB ) \ +do { \ + (DST)[0] += S * (SRCB)[0]; \ + (DST)[1] += S * (SRCB)[1]; \ +} while (0) + +/** In-place scalar multiplication */ +#define SELF_SCALE_SCALAR_2V( DST, S ) \ +do { \ + (DST)[0] *= S; \ + (DST)[1] *= S; \ +} while (0) + +/** In-place scalar addition */ +#define ACC_SCALAR_2V( DST, S ) \ +do { \ + (DST)[0] += S; \ + (DST)[1] += S; \ +} while (0) + +/** Assign scalers to short vectors */ +#define ASSIGN_2V( V, V0, V1 ) \ +do { \ + V[0] = V0; \ + V[1] = V1; \ +} while(0) + +/*@}*/ + + +/** \name Linear interpolation macros */ +/*@{*/ + +/** + * Linear interpolation + * + * \note \p OUT argument is evaluated twice! + * \note Be wary of using *coord++ as an argument to any of these macros! + */ +#define LINTERP(T, OUT, IN) ((OUT) + (T) * ((IN) - (OUT))) + +/* Can do better with integer math + */ +#define INTERP_UB( t, dstub, outub, inub ) \ +do { \ + GLfloat inf = UBYTE_TO_FLOAT( inub ); \ + GLfloat outf = UBYTE_TO_FLOAT( outub ); \ + GLfloat dstf = LINTERP( t, outf, inf ); \ + UNCLAMPED_FLOAT_TO_UBYTE( dstub, dstf ); \ +} while (0) + +#define INTERP_CHAN( t, dstc, outc, inc ) \ +do { \ + GLfloat inf = CHAN_TO_FLOAT( inc ); \ + GLfloat outf = CHAN_TO_FLOAT( outc ); \ + GLfloat dstf = LINTERP( t, outf, inf ); \ + UNCLAMPED_FLOAT_TO_CHAN( dstc, dstf ); \ +} while (0) + +#define INTERP_UI( t, dstui, outui, inui ) \ + dstui = (GLuint) (GLint) LINTERP( (t), (GLfloat) (outui), (GLfloat) (inui) ) + +#define INTERP_F( t, dstf, outf, inf ) \ + dstf = LINTERP( t, outf, inf ) + +#define INTERP_4F( t, dst, out, in ) \ +do { \ + dst[0] = LINTERP( (t), (out)[0], (in)[0] ); \ + dst[1] = LINTERP( (t), (out)[1], (in)[1] ); \ + dst[2] = LINTERP( (t), (out)[2], (in)[2] ); \ + dst[3] = LINTERP( (t), (out)[3], (in)[3] ); \ +} while (0) + +#define INTERP_3F( t, dst, out, in ) \ +do { \ + dst[0] = LINTERP( (t), (out)[0], (in)[0] ); \ + dst[1] = LINTERP( (t), (out)[1], (in)[1] ); \ + dst[2] = LINTERP( (t), (out)[2], (in)[2] ); \ +} while (0) + +#define INTERP_4CHAN( t, dst, out, in ) \ +do { \ + INTERP_CHAN( (t), (dst)[0], (out)[0], (in)[0] ); \ + INTERP_CHAN( (t), (dst)[1], (out)[1], (in)[1] ); \ + INTERP_CHAN( (t), (dst)[2], (out)[2], (in)[2] ); \ + INTERP_CHAN( (t), (dst)[3], (out)[3], (in)[3] ); \ +} while (0) + +#define INTERP_3CHAN( t, dst, out, in ) \ +do { \ + INTERP_CHAN( (t), (dst)[0], (out)[0], (in)[0] ); \ + INTERP_CHAN( (t), (dst)[1], (out)[1], (in)[1] ); \ + INTERP_CHAN( (t), (dst)[2], (out)[2], (in)[2] ); \ +} while (0) + +#define INTERP_SZ( t, vec, to, out, in, sz ) \ +do { \ + switch (sz) { \ + case 4: vec[to][3] = LINTERP( (t), (vec)[out][3], (vec)[in][3] ); \ + case 3: vec[to][2] = LINTERP( (t), (vec)[out][2], (vec)[in][2] ); \ + case 2: vec[to][1] = LINTERP( (t), (vec)[out][1], (vec)[in][1] ); \ + case 1: vec[to][0] = LINTERP( (t), (vec)[out][0], (vec)[in][0] ); \ + } \ +} while(0) + +/*@}*/ + + + +/** Clamp X to [MIN,MAX] */ +#define CLAMP( X, MIN, MAX ) ( (X)<(MIN) ? (MIN) : ((X)>(MAX) ? (MAX) : (X)) ) + +/** Minimum of two values: */ +#define MIN2( A, B ) ( (A)<(B) ? (A) : (B) ) + +/** Maximum of two values: */ +#define MAX2( A, B ) ( (A)>(B) ? (A) : (B) ) + +/** Minimum and maximum of three values: */ +#define MIN3( A, B, C ) ((A) < (B) ? MIN2(A, C) : MIN2(B, C)) +#define MAX3( A, B, C ) ((A) > (B) ? MAX2(A, C) : MAX2(B, C)) + +/** Dot product of two 2-element vectors */ +#define DOT2( a, b ) ( (a)[0]*(b)[0] + (a)[1]*(b)[1] ) + +/** Dot product of two 3-element vectors */ +#define DOT3( a, b ) ( (a)[0]*(b)[0] + (a)[1]*(b)[1] + (a)[2]*(b)[2] ) + +/** Dot product of two 4-element vectors */ +#define DOT4( a, b ) ( (a)[0]*(b)[0] + (a)[1]*(b)[1] + \ + (a)[2]*(b)[2] + (a)[3]*(b)[3] ) + +/** Dot product of two 4-element vectors */ +#define DOT4V(v,a,b,c,d) (v[0]*(a) + v[1]*(b) + v[2]*(c) + v[3]*(d)) + + +/** Cross product of two 3-element vectors */ +#define CROSS3(n, u, v) \ +do { \ + (n)[0] = (u)[1]*(v)[2] - (u)[2]*(v)[1]; \ + (n)[1] = (u)[2]*(v)[0] - (u)[0]*(v)[2]; \ + (n)[2] = (u)[0]*(v)[1] - (u)[1]*(v)[0]; \ +} while (0) + + +/* Normalize a 3-element vector to unit length. */ +#define NORMALIZE_3FV( V ) \ +do { \ + GLfloat len = (GLfloat) LEN_SQUARED_3FV(V); \ + if (len) { \ + len = INV_SQRTF(len); \ + (V)[0] = (GLfloat) ((V)[0] * len); \ + (V)[1] = (GLfloat) ((V)[1] * len); \ + (V)[2] = (GLfloat) ((V)[2] * len); \ + } \ +} while(0) + +#define LEN_3FV( V ) (SQRTF((V)[0]*(V)[0]+(V)[1]*(V)[1]+(V)[2]*(V)[2])) +#define LEN_2FV( V ) (SQRTF((V)[0]*(V)[0]+(V)[1]*(V)[1])) + +#define LEN_SQUARED_3FV( V ) ((V)[0]*(V)[0]+(V)[1]*(V)[1]+(V)[2]*(V)[2]) +#define LEN_SQUARED_2FV( V ) ((V)[0]*(V)[0]+(V)[1]*(V)[1]) + + +/** casts to silence warnings with some compilers */ +#define ENUM_TO_INT(E) ((GLint)(E)) +#define ENUM_TO_FLOAT(E) ((GLfloat)(GLint)(E)) +#define ENUM_TO_DOUBLE(E) ((GLdouble)(GLint)(E)) +#define ENUM_TO_BOOLEAN(E) ((E) ? GL_TRUE : GL_FALSE) + + +#endif diff --git a/mesalib/src/mesa/main/mfeatures.h b/mesalib/src/mesa/main/mfeatures.h index cdd6145ad..33db50814 100644 --- a/mesalib/src/mesa/main/mfeatures.h +++ b/mesalib/src/mesa/main/mfeatures.h @@ -1,146 +1,146 @@ -/* - * 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 mfeatures.h - * Flags to enable/disable specific parts of the API. - */ - -#ifndef FEATURES_H -#define FEATURES_H - - -#ifndef _HAVE_FULL_GL -#define _HAVE_FULL_GL 1 -#endif - -/* assert that a feature is disabled and should never be used */ -#define ASSERT_NO_FEATURE() ASSERT(0) - -/** - * A feature can be anything. But most of them share certain characteristics. - * - * When a feature defines vtxfmt entries, they can be initialized and - * installed by - * _MESA_INIT__VTXFMT - * _mesa_install__vtxfmt - * - * When a feature defines dispatch entries, they are initialized by - * _mesa_init__dispatch - * - * When a feature has states, they are initialized and freed by - * _mesa_init_ - * _mesa_free__data - * - * Except for states, the others compile to no-op when a feature is disabled. - * - * The GLAPIENTRYs and helper functions defined by a feature should also - * compile to no-op when it is disabled. But to save typings and to catch - * bugs, some of them may be unavailable, or compile to ASSERT_NO_FEATURE() - * when the feature is disabled. - * - * A feature following the conventions may be used without knowing if it is - * enabled or not. - */ - -#ifndef FEATURE_ES1 -#define FEATURE_ES1 0 -#endif -#ifndef FEATURE_ES2 -#define FEATURE_ES2 0 -#endif - -#define FEATURE_ES (FEATURE_ES1 || FEATURE_ES2) - -#ifndef FEATURE_GL -#define FEATURE_GL !FEATURE_ES -#endif - -#if defined(IN_DRI_DRIVER) || (FEATURE_GL + FEATURE_ES1 + FEATURE_ES2 > 1) -#define FEATURE_remap_table 1 -#else -#define FEATURE_remap_table 0 -#endif - -#define FEATURE_dispatch 1 -#define FEATURE_texgen 1 -#define FEATURE_userclip 1 - -#define FEATURE_accum FEATURE_GL -#define FEATURE_arrayelt FEATURE_GL -#define FEATURE_attrib_stack FEATURE_GL -/* this disables vtxfmt, api_loopback, and api_noop completely */ -#define FEATURE_beginend FEATURE_GL -#define FEATURE_colortable FEATURE_GL -#define FEATURE_convolve FEATURE_GL -#define FEATURE_dlist (FEATURE_GL && FEATURE_arrayelt && FEATURE_beginend) -#define FEATURE_draw_read_buffer FEATURE_GL -#define FEATURE_drawpix FEATURE_GL -#define FEATURE_evaluators FEATURE_GL -#define FEATURE_feedback FEATURE_GL -#define FEATURE_pixel_transfer FEATURE_GL -#define FEATURE_queryobj FEATURE_GL -#define FEATURE_rastpos FEATURE_GL -#define FEATURE_texture_fxt1 FEATURE_GL -#define FEATURE_texture_s3tc FEATURE_GL - -#define FEATURE_extra_context_init FEATURE_ES -#define FEATURE_point_size_array FEATURE_ES - -#define FEATURE_es2_glsl FEATURE_ES2 - -#define FEATURE_ARB_fragment_program 1 -#define FEATURE_ARB_vertex_program 1 -#define FEATURE_ARB_vertex_shader 1 -#define FEATURE_ARB_fragment_shader 1 -#define FEATURE_ARB_shader_objects (FEATURE_ARB_vertex_shader || FEATURE_ARB_fragment_shader) -#define FEATURE_ARB_shading_language_100 FEATURE_ARB_shader_objects -#define FEATURE_ARB_geometry_shader4 FEATURE_ARB_shader_objects - -#define FEATURE_ARB_framebuffer_object (FEATURE_GL && FEATURE_EXT_framebuffer_object) -#define FEATURE_ARB_map_buffer_range FEATURE_GL -#define FEATURE_ARB_pixel_buffer_object (FEATURE_GL && FEATURE_EXT_pixel_buffer_object) -#define FEATURE_ARB_sampler_objects FEATURE_GL -#define FEATURE_ARB_sync FEATURE_GL -#define FEATURE_ARB_vertex_buffer_object 1 - -#define FEATURE_EXT_framebuffer_blit FEATURE_GL -#define FEATURE_EXT_framebuffer_object 1 -#define FEATURE_EXT_pixel_buffer_object 1 -#define FEATURE_EXT_texture_sRGB FEATURE_GL -#define FEATURE_EXT_transform_feedback FEATURE_GL - -#define FEATURE_APPLE_object_purgeable FEATURE_GL -#define FEATURE_ATI_fragment_shader FEATURE_GL -#define FEATURE_NV_fence FEATURE_GL -#define FEATURE_NV_fragment_program FEATURE_GL -#define FEATURE_NV_vertex_program FEATURE_GL - -#define FEATURE_OES_EGL_image 1 -#define FEATURE_OES_draw_texture FEATURE_ES1 -#define FEATURE_OES_framebuffer_object FEATURE_ES -#define FEATURE_OES_mapbuffer FEATURE_ES - -#endif /* FEATURES_H */ +/* + * 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 mfeatures.h + * Flags to enable/disable specific parts of the API. + */ + +#ifndef FEATURES_H +#define FEATURES_H + + +#ifndef _HAVE_FULL_GL +#define _HAVE_FULL_GL 1 +#endif + +/* assert that a feature is disabled and should never be used */ +#define ASSERT_NO_FEATURE() ASSERT(0) + +/** + * A feature can be anything. But most of them share certain characteristics. + * + * When a feature defines vtxfmt entries, they can be initialized and + * installed by + * _MESA_INIT__VTXFMT + * _mesa_install__vtxfmt + * + * When a feature defines dispatch entries, they are initialized by + * _mesa_init__dispatch + * + * When a feature has states, they are initialized and freed by + * _mesa_init_ + * _mesa_free__data + * + * Except for states, the others compile to no-op when a feature is disabled. + * + * The GLAPIENTRYs and helper functions defined by a feature should also + * compile to no-op when it is disabled. But to save typings and to catch + * bugs, some of them may be unavailable, or compile to ASSERT_NO_FEATURE() + * when the feature is disabled. + * + * A feature following the conventions may be used without knowing if it is + * enabled or not. + */ + +#ifndef FEATURE_ES1 +#define FEATURE_ES1 0 +#endif +#ifndef FEATURE_ES2 +#define FEATURE_ES2 0 +#endif + +#define FEATURE_ES (FEATURE_ES1 || FEATURE_ES2) + +#ifndef FEATURE_GL +#define FEATURE_GL !FEATURE_ES +#endif + +#if defined(IN_DRI_DRIVER) || (FEATURE_GL + FEATURE_ES1 + FEATURE_ES2 > 1) +#define FEATURE_remap_table 1 +#else +#define FEATURE_remap_table 0 +#endif + +#define FEATURE_dispatch 1 +#define FEATURE_texgen 1 +#define FEATURE_userclip 1 + +#define FEATURE_accum FEATURE_GL +#define FEATURE_arrayelt FEATURE_GL +#define FEATURE_attrib_stack FEATURE_GL +/* this disables vtxfmt, api_loopback, and api_noop completely */ +#define FEATURE_beginend FEATURE_GL +#define FEATURE_colortable FEATURE_GL +#define FEATURE_convolve FEATURE_GL +#define FEATURE_dlist (FEATURE_GL && FEATURE_arrayelt && FEATURE_beginend) +#define FEATURE_draw_read_buffer FEATURE_GL +#define FEATURE_drawpix FEATURE_GL +#define FEATURE_evaluators FEATURE_GL +#define FEATURE_feedback FEATURE_GL +#define FEATURE_pixel_transfer FEATURE_GL +#define FEATURE_queryobj FEATURE_GL +#define FEATURE_rastpos FEATURE_GL +#define FEATURE_texture_fxt1 FEATURE_GL +#define FEATURE_texture_s3tc FEATURE_GL + +#define FEATURE_extra_context_init FEATURE_ES +#define FEATURE_point_size_array FEATURE_ES + +#define FEATURE_es2_glsl FEATURE_ES2 + +#define FEATURE_ARB_fragment_program 1 +#define FEATURE_ARB_vertex_program 1 +#define FEATURE_ARB_vertex_shader 1 +#define FEATURE_ARB_fragment_shader 1 +#define FEATURE_ARB_shader_objects (FEATURE_ARB_vertex_shader || FEATURE_ARB_fragment_shader) +#define FEATURE_ARB_shading_language_100 FEATURE_ARB_shader_objects +#define FEATURE_ARB_geometry_shader4 FEATURE_ARB_shader_objects + +#define FEATURE_ARB_framebuffer_object (FEATURE_GL && FEATURE_EXT_framebuffer_object) +#define FEATURE_ARB_map_buffer_range FEATURE_GL +#define FEATURE_ARB_pixel_buffer_object (FEATURE_GL && FEATURE_EXT_pixel_buffer_object) +#define FEATURE_ARB_sampler_objects FEATURE_GL +#define FEATURE_ARB_sync FEATURE_GL +#define FEATURE_ARB_vertex_buffer_object 1 + +#define FEATURE_EXT_framebuffer_blit FEATURE_GL +#define FEATURE_EXT_framebuffer_object 1 +#define FEATURE_EXT_pixel_buffer_object 1 +#define FEATURE_EXT_texture_sRGB FEATURE_GL +#define FEATURE_EXT_transform_feedback FEATURE_GL + +#define FEATURE_APPLE_object_purgeable FEATURE_GL +#define FEATURE_ATI_fragment_shader FEATURE_GL +#define FEATURE_NV_fence FEATURE_GL +#define FEATURE_NV_fragment_program FEATURE_GL +#define FEATURE_NV_vertex_program FEATURE_GL + +#define FEATURE_OES_EGL_image 1 +#define FEATURE_OES_draw_texture FEATURE_ES1 +#define FEATURE_OES_framebuffer_object FEATURE_ES +#define FEATURE_OES_mapbuffer FEATURE_ES + +#endif /* FEATURES_H */ diff --git a/mesalib/src/mesa/main/mtypes.h b/mesalib/src/mesa/main/mtypes.h index e77bce8f2..ae500b4c2 100644 --- a/mesalib/src/mesa/main/mtypes.h +++ b/mesalib/src/mesa/main/mtypes.h @@ -1,3449 +1,3449 @@ -/* - * Mesa 3-D graphics library - * Version: 7.7 - * - * Copyright (C) 1999-2008 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. - */ - -/** - * \file mtypes.h - * Main Mesa data structures. - * - * Please try to mark derived values with a leading underscore ('_'). - */ - -#ifndef MTYPES_H -#define MTYPES_H - - -#include "main/glheader.h" -#include "main/config.h" -#include "main/mfeatures.h" -#include "glapi/glapi.h" -#include "math/m_matrix.h" /* GLmatrix */ -#include "main/simple_list.h" /* struct simple_node */ -#include "main/formats.h" /* MESA_FORMAT_COUNT */ - - -/** - * Color channel data type. - */ -#if CHAN_BITS == 8 - typedef GLubyte GLchan; -#define CHAN_MAX 255 -#define CHAN_MAXF 255.0F -#define CHAN_TYPE GL_UNSIGNED_BYTE -#elif CHAN_BITS == 16 - typedef GLushort GLchan; -#define CHAN_MAX 65535 -#define CHAN_MAXF 65535.0F -#define CHAN_TYPE GL_UNSIGNED_SHORT -#elif CHAN_BITS == 32 - typedef GLfloat GLchan; -#define CHAN_MAX 1.0 -#define CHAN_MAXF 1.0F -#define CHAN_TYPE GL_FLOAT -#else -#error "illegal number of color channel bits" -#endif - - -/** - * Stencil buffer data type. - */ -#if STENCIL_BITS==8 - typedef GLubyte GLstencil; -#elif STENCIL_BITS==16 - typedef GLushort GLstencil; -#else -# error "illegal number of stencil bits" -#endif - - -/** - * \name 64-bit extension of GLbitfield. - */ -/*@{*/ -typedef GLuint64 GLbitfield64; - -/** Set a single bit */ -#define BITFIELD64_BIT(b) ((GLbitfield64)1 << (b)) - - -/** - * \name Some forward type declarations - */ -/*@{*/ -struct _mesa_HashTable; -struct gl_attrib_node; -struct gl_list_extensions; -struct gl_meta_state; -struct gl_pixelstore_attrib; -struct gl_program_cache; -struct gl_texture_format; -struct gl_texture_image; -struct gl_texture_object; -struct gl_context; -struct st_context; -/*@}*/ - - -/** Extra draw modes beyond GL_POINTS, GL_TRIANGLE_FAN, etc */ -#define PRIM_OUTSIDE_BEGIN_END (GL_POLYGON+1) -#define PRIM_INSIDE_UNKNOWN_PRIM (GL_POLYGON+2) -#define PRIM_UNKNOWN (GL_POLYGON+3) - - -/** - * Shader stages. Note that these will become 5 with tessellation. - * These MUST have the same values as gallium's PIPE_SHADER_* - */ -typedef enum -{ - MESA_SHADER_VERTEX = 0, - MESA_SHADER_FRAGMENT = 1, - MESA_SHADER_GEOMETRY = 2, - MESA_SHADER_TYPES = 3 -} gl_shader_type; - - - -/** - * Indexes for vertex program attributes. - * GL_NV_vertex_program aliases generic attributes over the conventional - * attributes. In GL_ARB_vertex_program shader the aliasing is optional. - * In GL_ARB_vertex_shader / OpenGL 2.0 the aliasing is disallowed (the - * generic attributes are distinct/separate). - */ -typedef enum -{ - VERT_ATTRIB_POS = 0, - VERT_ATTRIB_WEIGHT = 1, - VERT_ATTRIB_NORMAL = 2, - VERT_ATTRIB_COLOR0 = 3, - VERT_ATTRIB_COLOR1 = 4, - VERT_ATTRIB_FOG = 5, - VERT_ATTRIB_COLOR_INDEX = 6, - VERT_ATTRIB_POINT_SIZE = 6, /*alias*/ - VERT_ATTRIB_EDGEFLAG = 7, - VERT_ATTRIB_TEX0 = 8, - VERT_ATTRIB_TEX1 = 9, - VERT_ATTRIB_TEX2 = 10, - VERT_ATTRIB_TEX3 = 11, - VERT_ATTRIB_TEX4 = 12, - VERT_ATTRIB_TEX5 = 13, - VERT_ATTRIB_TEX6 = 14, - VERT_ATTRIB_TEX7 = 15, - VERT_ATTRIB_GENERIC0 = 16, - VERT_ATTRIB_GENERIC1 = 17, - VERT_ATTRIB_GENERIC2 = 18, - VERT_ATTRIB_GENERIC3 = 19, - VERT_ATTRIB_GENERIC4 = 20, - VERT_ATTRIB_GENERIC5 = 21, - VERT_ATTRIB_GENERIC6 = 22, - VERT_ATTRIB_GENERIC7 = 23, - VERT_ATTRIB_GENERIC8 = 24, - VERT_ATTRIB_GENERIC9 = 25, - VERT_ATTRIB_GENERIC10 = 26, - VERT_ATTRIB_GENERIC11 = 27, - VERT_ATTRIB_GENERIC12 = 28, - VERT_ATTRIB_GENERIC13 = 29, - VERT_ATTRIB_GENERIC14 = 30, - VERT_ATTRIB_GENERIC15 = 31, - VERT_ATTRIB_MAX = 32 -} gl_vert_attrib; - -/** - * Bitflags for vertex attributes. - * These are used in bitfields in many places. - */ -/*@{*/ -#define VERT_BIT_POS (1 << VERT_ATTRIB_POS) -#define VERT_BIT_WEIGHT (1 << VERT_ATTRIB_WEIGHT) -#define VERT_BIT_NORMAL (1 << VERT_ATTRIB_NORMAL) -#define VERT_BIT_COLOR0 (1 << VERT_ATTRIB_COLOR0) -#define VERT_BIT_COLOR1 (1 << VERT_ATTRIB_COLOR1) -#define VERT_BIT_FOG (1 << VERT_ATTRIB_FOG) -#define VERT_BIT_COLOR_INDEX (1 << VERT_ATTRIB_COLOR_INDEX) -#define VERT_BIT_EDGEFLAG (1 << VERT_ATTRIB_EDGEFLAG) -#define VERT_BIT_TEX0 (1 << VERT_ATTRIB_TEX0) -#define VERT_BIT_TEX1 (1 << VERT_ATTRIB_TEX1) -#define VERT_BIT_TEX2 (1 << VERT_ATTRIB_TEX2) -#define VERT_BIT_TEX3 (1 << VERT_ATTRIB_TEX3) -#define VERT_BIT_TEX4 (1 << VERT_ATTRIB_TEX4) -#define VERT_BIT_TEX5 (1 << VERT_ATTRIB_TEX5) -#define VERT_BIT_TEX6 (1 << VERT_ATTRIB_TEX6) -#define VERT_BIT_TEX7 (1 << VERT_ATTRIB_TEX7) -#define VERT_BIT_GENERIC0 (1 << VERT_ATTRIB_GENERIC0) -#define VERT_BIT_GENERIC1 (1 << VERT_ATTRIB_GENERIC1) -#define VERT_BIT_GENERIC2 (1 << VERT_ATTRIB_GENERIC2) -#define VERT_BIT_GENERIC3 (1 << VERT_ATTRIB_GENERIC3) -#define VERT_BIT_GENERIC4 (1 << VERT_ATTRIB_GENERIC4) -#define VERT_BIT_GENERIC5 (1 << VERT_ATTRIB_GENERIC5) -#define VERT_BIT_GENERIC6 (1 << VERT_ATTRIB_GENERIC6) -#define VERT_BIT_GENERIC7 (1 << VERT_ATTRIB_GENERIC7) -#define VERT_BIT_GENERIC8 (1 << VERT_ATTRIB_GENERIC8) -#define VERT_BIT_GENERIC9 (1 << VERT_ATTRIB_GENERIC9) -#define VERT_BIT_GENERIC10 (1 << VERT_ATTRIB_GENERIC10) -#define VERT_BIT_GENERIC11 (1 << VERT_ATTRIB_GENERIC11) -#define VERT_BIT_GENERIC12 (1 << VERT_ATTRIB_GENERIC12) -#define VERT_BIT_GENERIC13 (1 << VERT_ATTRIB_GENERIC13) -#define VERT_BIT_GENERIC14 (1 << VERT_ATTRIB_GENERIC14) -#define VERT_BIT_GENERIC15 (1 << VERT_ATTRIB_GENERIC15) - -#define VERT_BIT_TEX(u) (1 << (VERT_ATTRIB_TEX0 + (u))) -#define VERT_BIT_GENERIC(g) (1 << (VERT_ATTRIB_GENERIC0 + (g))) -/*@}*/ - - -/** - * Indexes for vertex program result attributes. Note that - * _mesa_vert_result_to_frag_attrib() and _mesa_frag_attrib_to_vert_result() make - * assumptions about the layout of this enum. - */ -typedef enum -{ - VERT_RESULT_HPOS = 0, - VERT_RESULT_COL0 = 1, - VERT_RESULT_COL1 = 2, - VERT_RESULT_FOGC = 3, - VERT_RESULT_TEX0 = 4, - VERT_RESULT_TEX1 = 5, - VERT_RESULT_TEX2 = 6, - VERT_RESULT_TEX3 = 7, - VERT_RESULT_TEX4 = 8, - VERT_RESULT_TEX5 = 9, - VERT_RESULT_TEX6 = 10, - VERT_RESULT_TEX7 = 11, - VERT_RESULT_PSIZ = 12, - VERT_RESULT_BFC0 = 13, - VERT_RESULT_BFC1 = 14, - VERT_RESULT_EDGE = 15, - VERT_RESULT_VAR0 = 16, /**< shader varying */ - VERT_RESULT_MAX = (VERT_RESULT_VAR0 + MAX_VARYING) -} gl_vert_result; - - -/*********************************************/ - -/** - * Indexes for geometry program attributes. - */ -typedef enum -{ - GEOM_ATTRIB_POSITION = 0, - GEOM_ATTRIB_COLOR0 = 1, - GEOM_ATTRIB_COLOR1 = 2, - GEOM_ATTRIB_SECONDARY_COLOR0 = 3, - GEOM_ATTRIB_SECONDARY_COLOR1 = 4, - GEOM_ATTRIB_FOG_FRAG_COORD = 5, - GEOM_ATTRIB_POINT_SIZE = 6, - GEOM_ATTRIB_CLIP_VERTEX = 7, - GEOM_ATTRIB_PRIMITIVE_ID = 8, - GEOM_ATTRIB_TEX_COORD = 9, - - GEOM_ATTRIB_VAR0 = 16, - GEOM_ATTRIB_MAX = (GEOM_ATTRIB_VAR0 + MAX_VARYING) -} gl_geom_attrib; - -/** - * Bitflags for geometry attributes. - * These are used in bitfields in many places. - */ -/*@{*/ -#define GEOM_BIT_COLOR0 (1 << GEOM_ATTRIB_COLOR0) -#define GEOM_BIT_COLOR1 (1 << GEOM_ATTRIB_COLOR1) -#define GEOM_BIT_SCOLOR0 (1 << GEOM_ATTRIB_SECONDARY_COLOR0) -#define GEOM_BIT_SCOLOR1 (1 << GEOM_ATTRIB_SECONDARY_COLOR1) -#define GEOM_BIT_TEX_COORD (1 << GEOM_ATTRIB_TEX_COORD) -#define GEOM_BIT_FOG_COORD (1 << GEOM_ATTRIB_FOG_FRAG_COORD) -#define GEOM_BIT_POSITION (1 << GEOM_ATTRIB_POSITION) -#define GEOM_BIT_POINT_SIDE (1 << GEOM_ATTRIB_POINT_SIZE) -#define GEOM_BIT_CLIP_VERTEX (1 << GEOM_ATTRIB_CLIP_VERTEX) -#define GEOM_BIT_PRIM_ID (1 << GEOM_ATTRIB_PRIMITIVE_ID) -#define GEOM_BIT_VAR0 (1 << GEOM_ATTRIB_VAR0) - -#define GEOM_BIT_VAR(g) (1 << (GEOM_BIT_VAR0 + (g))) -/*@}*/ - - -/** - * Indexes for geometry program result attributes - */ -typedef enum -{ - GEOM_RESULT_POS = 0, - GEOM_RESULT_COL0 = 1, - GEOM_RESULT_COL1 = 2, - GEOM_RESULT_SCOL0 = 3, - GEOM_RESULT_SCOL1 = 4, - GEOM_RESULT_FOGC = 5, - GEOM_RESULT_TEX0 = 6, - GEOM_RESULT_TEX1 = 7, - GEOM_RESULT_TEX2 = 8, - GEOM_RESULT_TEX3 = 9, - GEOM_RESULT_TEX4 = 10, - GEOM_RESULT_TEX5 = 11, - GEOM_RESULT_TEX6 = 12, - GEOM_RESULT_TEX7 = 13, - GEOM_RESULT_PSIZ = 14, - GEOM_RESULT_CLPV = 15, - GEOM_RESULT_PRID = 16, - GEOM_RESULT_LAYR = 17, - GEOM_RESULT_VAR0 = 18, /**< shader varying, should really be 16 */ - /* ### we need to -2 because var0 is 18 instead 16 like in the others */ - GEOM_RESULT_MAX = (GEOM_RESULT_VAR0 + MAX_VARYING - 2) -} gl_geom_result; - - -/** - * Indexes for fragment program input attributes. Note that - * _mesa_vert_result_to_frag_attrib() and frag_attrib_to_vert_result() make - * assumptions about the layout of this enum. - */ -typedef enum -{ - FRAG_ATTRIB_WPOS = 0, - FRAG_ATTRIB_COL0 = 1, - FRAG_ATTRIB_COL1 = 2, - FRAG_ATTRIB_FOGC = 3, - FRAG_ATTRIB_TEX0 = 4, - FRAG_ATTRIB_TEX1 = 5, - FRAG_ATTRIB_TEX2 = 6, - FRAG_ATTRIB_TEX3 = 7, - FRAG_ATTRIB_TEX4 = 8, - FRAG_ATTRIB_TEX5 = 9, - FRAG_ATTRIB_TEX6 = 10, - FRAG_ATTRIB_TEX7 = 11, - FRAG_ATTRIB_FACE = 12, /**< front/back face */ - FRAG_ATTRIB_PNTC = 13, /**< sprite/point coord */ - FRAG_ATTRIB_VAR0 = 14, /**< shader varying */ - FRAG_ATTRIB_MAX = (FRAG_ATTRIB_VAR0 + MAX_VARYING) -} gl_frag_attrib; - - -/** - * Convert from a gl_vert_result value to the corresponding gl_frag_attrib. - * - * VERT_RESULT_HPOS is converted to FRAG_ATTRIB_WPOS. - * - * gl_vert_result values which have no corresponding gl_frag_attrib - * (VERT_RESULT_PSIZ, VERT_RESULT_BFC0, VERT_RESULT_BFC1, and - * VERT_RESULT_EDGE) are converted to a value of -1. - */ -static INLINE int -_mesa_vert_result_to_frag_attrib(gl_vert_result vert_result) -{ - if (vert_result >= VERT_RESULT_VAR0) - return vert_result - VERT_RESULT_VAR0 + FRAG_ATTRIB_VAR0; - else if (vert_result <= VERT_RESULT_TEX7) - return vert_result; - else - return -1; -} - - -/** - * Convert from a gl_frag_attrib value to the corresponding gl_vert_result. - * - * FRAG_ATTRIB_WPOS is converted to VERT_RESULT_HPOS. - * - * gl_frag_attrib values which have no corresponding gl_vert_result - * (FRAG_ATTRIB_FACE and FRAG_ATTRIB_PNTC) are converted to a value of -1. - */ -static INLINE int -_mesa_frag_attrib_to_vert_result(gl_frag_attrib frag_attrib) -{ - if (frag_attrib <= FRAG_ATTRIB_TEX7) - return frag_attrib; - else if (frag_attrib >= FRAG_ATTRIB_VAR0) - return frag_attrib - FRAG_ATTRIB_VAR0 + VERT_RESULT_VAR0; - else - return -1; -} - - -/** - * Bitflags for fragment program input attributes. - */ -/*@{*/ -#define FRAG_BIT_WPOS (1 << FRAG_ATTRIB_WPOS) -#define FRAG_BIT_COL0 (1 << FRAG_ATTRIB_COL0) -#define FRAG_BIT_COL1 (1 << FRAG_ATTRIB_COL1) -#define FRAG_BIT_FOGC (1 << FRAG_ATTRIB_FOGC) -#define FRAG_BIT_FACE (1 << FRAG_ATTRIB_FACE) -#define FRAG_BIT_PNTC (1 << FRAG_ATTRIB_PNTC) -#define FRAG_BIT_TEX0 (1 << FRAG_ATTRIB_TEX0) -#define FRAG_BIT_TEX1 (1 << FRAG_ATTRIB_TEX1) -#define FRAG_BIT_TEX2 (1 << FRAG_ATTRIB_TEX2) -#define FRAG_BIT_TEX3 (1 << FRAG_ATTRIB_TEX3) -#define FRAG_BIT_TEX4 (1 << FRAG_ATTRIB_TEX4) -#define FRAG_BIT_TEX5 (1 << FRAG_ATTRIB_TEX5) -#define FRAG_BIT_TEX6 (1 << FRAG_ATTRIB_TEX6) -#define FRAG_BIT_TEX7 (1 << FRAG_ATTRIB_TEX7) -#define FRAG_BIT_VAR0 (1 << FRAG_ATTRIB_VAR0) - -#define FRAG_BIT_TEX(U) (FRAG_BIT_TEX0 << (U)) -#define FRAG_BIT_VAR(V) (FRAG_BIT_VAR0 << (V)) - -#define FRAG_BITS_TEX_ANY (FRAG_BIT_TEX0| \ - FRAG_BIT_TEX1| \ - FRAG_BIT_TEX2| \ - FRAG_BIT_TEX3| \ - FRAG_BIT_TEX4| \ - FRAG_BIT_TEX5| \ - FRAG_BIT_TEX6| \ - FRAG_BIT_TEX7) -/*@}*/ - - -/** - * Fragment program results - */ -typedef enum -{ - FRAG_RESULT_DEPTH = 0, - FRAG_RESULT_STENCIL = 1, - /* If a single color should be written to all render targets, this - * register is written. No FRAG_RESULT_DATAn will be written. - */ - FRAG_RESULT_COLOR = 2, - - /* FRAG_RESULT_DATAn are the per-render-target (GLSL gl_FragData[n] - * or ARB_fragment_program fragment.color[n]) color results. If - * any are written, FRAG_RESULT_COLOR will not be written. - */ - FRAG_RESULT_DATA0 = 3, - FRAG_RESULT_MAX = (FRAG_RESULT_DATA0 + MAX_DRAW_BUFFERS) -} gl_frag_result; - - -/** - * Indexes for all renderbuffers - */ -typedef enum -{ - /* the four standard color buffers */ - BUFFER_FRONT_LEFT, - BUFFER_BACK_LEFT, - BUFFER_FRONT_RIGHT, - BUFFER_BACK_RIGHT, - BUFFER_DEPTH, - BUFFER_STENCIL, - BUFFER_ACCUM, - /* optional aux buffer */ - BUFFER_AUX0, - /* generic renderbuffers */ - BUFFER_COLOR0, - BUFFER_COLOR1, - BUFFER_COLOR2, - BUFFER_COLOR3, - BUFFER_COLOR4, - BUFFER_COLOR5, - BUFFER_COLOR6, - BUFFER_COLOR7, - BUFFER_COUNT -} gl_buffer_index; - -/** - * Bit flags for all renderbuffers - */ -#define BUFFER_BIT_FRONT_LEFT (1 << BUFFER_FRONT_LEFT) -#define BUFFER_BIT_BACK_LEFT (1 << BUFFER_BACK_LEFT) -#define BUFFER_BIT_FRONT_RIGHT (1 << BUFFER_FRONT_RIGHT) -#define BUFFER_BIT_BACK_RIGHT (1 << BUFFER_BACK_RIGHT) -#define BUFFER_BIT_AUX0 (1 << BUFFER_AUX0) -#define BUFFER_BIT_AUX1 (1 << BUFFER_AUX1) -#define BUFFER_BIT_AUX2 (1 << BUFFER_AUX2) -#define BUFFER_BIT_AUX3 (1 << BUFFER_AUX3) -#define BUFFER_BIT_DEPTH (1 << BUFFER_DEPTH) -#define BUFFER_BIT_STENCIL (1 << BUFFER_STENCIL) -#define BUFFER_BIT_ACCUM (1 << BUFFER_ACCUM) -#define BUFFER_BIT_COLOR0 (1 << BUFFER_COLOR0) -#define BUFFER_BIT_COLOR1 (1 << BUFFER_COLOR1) -#define BUFFER_BIT_COLOR2 (1 << BUFFER_COLOR2) -#define BUFFER_BIT_COLOR3 (1 << BUFFER_COLOR3) -#define BUFFER_BIT_COLOR4 (1 << BUFFER_COLOR4) -#define BUFFER_BIT_COLOR5 (1 << BUFFER_COLOR5) -#define BUFFER_BIT_COLOR6 (1 << BUFFER_COLOR6) -#define BUFFER_BIT_COLOR7 (1 << BUFFER_COLOR7) - -/** - * Mask of all the color buffer bits (but not accum). - */ -#define BUFFER_BITS_COLOR (BUFFER_BIT_FRONT_LEFT | \ - BUFFER_BIT_BACK_LEFT | \ - BUFFER_BIT_FRONT_RIGHT | \ - BUFFER_BIT_BACK_RIGHT | \ - BUFFER_BIT_AUX0 | \ - BUFFER_BIT_COLOR0 | \ - BUFFER_BIT_COLOR1 | \ - BUFFER_BIT_COLOR2 | \ - BUFFER_BIT_COLOR3 | \ - BUFFER_BIT_COLOR4 | \ - BUFFER_BIT_COLOR5 | \ - BUFFER_BIT_COLOR6 | \ - BUFFER_BIT_COLOR7) - - -/** - * Framebuffer configuration (aka visual / pixelformat) - * Note: some of these fields should be boolean, but it appears that - * code in drivers/dri/common/util.c requires int-sized fields. - */ -struct gl_config -{ - GLboolean rgbMode; - GLboolean floatMode; - GLboolean colorIndexMode; /* XXX is this used anywhere? */ - GLuint doubleBufferMode; - GLuint stereoMode; - - GLboolean haveAccumBuffer; - GLboolean haveDepthBuffer; - GLboolean haveStencilBuffer; - - GLint redBits, greenBits, blueBits, alphaBits; /* bits per comp */ - GLuint redMask, greenMask, blueMask, alphaMask; - GLint rgbBits; /* total bits for rgb */ - GLint indexBits; /* total bits for colorindex */ - - GLint accumRedBits, accumGreenBits, accumBlueBits, accumAlphaBits; - GLint depthBits; - GLint stencilBits; - - GLint numAuxBuffers; - - GLint level; - - /* EXT_visual_rating / GLX 1.2 */ - GLint visualRating; - - /* EXT_visual_info / GLX 1.2 */ - GLint transparentPixel; - /* colors are floats scaled to ints */ - GLint transparentRed, transparentGreen, transparentBlue, transparentAlpha; - GLint transparentIndex; - - /* ARB_multisample / SGIS_multisample */ - GLint sampleBuffers; - GLint samples; - - /* SGIX_pbuffer / GLX 1.3 */ - GLint maxPbufferWidth; - GLint maxPbufferHeight; - GLint maxPbufferPixels; - GLint optimalPbufferWidth; /* Only for SGIX_pbuffer. */ - GLint optimalPbufferHeight; /* Only for SGIX_pbuffer. */ - - /* OML_swap_method */ - GLint swapMethod; - - /* EXT_texture_from_pixmap */ - GLint bindToTextureRgb; - GLint bindToTextureRgba; - GLint bindToMipmapTexture; - GLint bindToTextureTargets; - GLint yInverted; - - /* EXT_framebuffer_sRGB */ - GLint sRGBCapable; -}; - - -/** - * \name Bit flags used for updating material values. - */ -/*@{*/ -#define MAT_ATTRIB_FRONT_AMBIENT 0 -#define MAT_ATTRIB_BACK_AMBIENT 1 -#define MAT_ATTRIB_FRONT_DIFFUSE 2 -#define MAT_ATTRIB_BACK_DIFFUSE 3 -#define MAT_ATTRIB_FRONT_SPECULAR 4 -#define MAT_ATTRIB_BACK_SPECULAR 5 -#define MAT_ATTRIB_FRONT_EMISSION 6 -#define MAT_ATTRIB_BACK_EMISSION 7 -#define MAT_ATTRIB_FRONT_SHININESS 8 -#define MAT_ATTRIB_BACK_SHININESS 9 -#define MAT_ATTRIB_FRONT_INDEXES 10 -#define MAT_ATTRIB_BACK_INDEXES 11 -#define MAT_ATTRIB_MAX 12 - -#define MAT_ATTRIB_AMBIENT(f) (MAT_ATTRIB_FRONT_AMBIENT+(f)) -#define MAT_ATTRIB_DIFFUSE(f) (MAT_ATTRIB_FRONT_DIFFUSE+(f)) -#define MAT_ATTRIB_SPECULAR(f) (MAT_ATTRIB_FRONT_SPECULAR+(f)) -#define MAT_ATTRIB_EMISSION(f) (MAT_ATTRIB_FRONT_EMISSION+(f)) -#define MAT_ATTRIB_SHININESS(f)(MAT_ATTRIB_FRONT_SHININESS+(f)) -#define MAT_ATTRIB_INDEXES(f) (MAT_ATTRIB_FRONT_INDEXES+(f)) - -#define MAT_INDEX_AMBIENT 0 -#define MAT_INDEX_DIFFUSE 1 -#define MAT_INDEX_SPECULAR 2 - -#define MAT_BIT_FRONT_AMBIENT (1< ) */ - GLfloat _NormSpotDirection[4]; /**< normalized spotlight direction */ - GLfloat _VP_inf_spot_attenuation; - - GLfloat _SpotExpTable[EXP_TABLE_SIZE][2]; /**< to replace a pow() call */ - GLfloat _MatAmbient[2][3]; /**< material ambient * light ambient */ - GLfloat _MatDiffuse[2][3]; /**< material diffuse * light diffuse */ - GLfloat _MatSpecular[2][3]; /**< material spec * light specular */ - GLfloat _dli; /**< CI diffuse light intensity */ - GLfloat _sli; /**< CI specular light intensity */ - /*@}*/ -}; - - -/** - * Light model state. - */ -struct gl_lightmodel -{ - GLfloat Ambient[4]; /**< ambient color */ - GLboolean LocalViewer; /**< Local (or infinite) view point? */ - GLboolean TwoSide; /**< Two (or one) sided lighting? */ - GLenum ColorControl; /**< either GL_SINGLE_COLOR - * or GL_SEPARATE_SPECULAR_COLOR */ -}; - - -/** - * Material state. - */ -struct gl_material -{ - GLfloat Attrib[MAT_ATTRIB_MAX][4]; -}; - - -/** - * Accumulation buffer attribute group (GL_ACCUM_BUFFER_BIT) - */ -struct gl_accum_attrib -{ - GLfloat ClearColor[4]; /**< Accumulation buffer clear color */ -}; - - -/** - * Color buffer attribute group (GL_COLOR_BUFFER_BIT). - */ -struct gl_colorbuffer_attrib -{ - GLuint ClearIndex; /**< Index to use for glClear */ - GLfloat ClearColorUnclamped[4]; /**< Color to use for glClear*/ - GLclampf ClearColor[4]; /**< Color to use for glClear */ - - GLuint IndexMask; /**< Color index write mask */ - GLubyte ColorMask[MAX_DRAW_BUFFERS][4];/**< Each flag is 0xff or 0x0 */ - - GLenum DrawBuffer[MAX_DRAW_BUFFERS]; /**< Which buffer to draw into */ - - /** - * \name alpha testing - */ - /*@{*/ - GLboolean AlphaEnabled; /**< Alpha test enabled flag */ - GLenum AlphaFunc; /**< Alpha test function */ - GLfloat AlphaRefUnclamped; - GLclampf AlphaRef; /**< Alpha reference value */ - /*@}*/ - - /** - * \name Blending - */ - /*@{*/ - GLbitfield BlendEnabled; /**< Per-buffer blend enable flags */ - - /* NOTE: this does _not_ depend on fragment clamping or any other clamping control, - * only on the fixed-pointness of the render target. - * The query does however depend on fragment color clamping. - */ - GLfloat BlendColorUnclamped[4]; /**< Blending color */ - GLfloat BlendColor[4]; /**< Blending color */ - - struct - { - GLenum SrcRGB; /**< RGB blend source term */ - GLenum DstRGB; /**< RGB blend dest term */ - GLenum SrcA; /**< Alpha blend source term */ - GLenum DstA; /**< Alpha blend dest term */ - GLenum EquationRGB; /**< GL_ADD, GL_SUBTRACT, etc. */ - GLenum EquationA; /**< GL_ADD, GL_SUBTRACT, etc. */ - } Blend[MAX_DRAW_BUFFERS]; - /** Are the blend func terms currently different for each buffer/target? */ - GLboolean _BlendFuncPerBuffer; - /** Are the blend equations currently different for each buffer/target? */ - GLboolean _BlendEquationPerBuffer; - /*@}*/ - - /** - * \name Logic op - */ - /*@{*/ - GLenum LogicOp; /**< Logic operator */ - GLboolean IndexLogicOpEnabled; /**< Color index logic op enabled flag */ - GLboolean ColorLogicOpEnabled; /**< RGBA logic op enabled flag */ - GLboolean _LogicOpEnabled; /**< RGBA logic op + EXT_blend_logic_op enabled flag */ - /*@}*/ - - GLboolean DitherFlag; /**< Dither enable flag */ - - GLenum ClampFragmentColor; /**< GL_TRUE, GL_FALSE or GL_FIXED_ONLY_ARB */ - GLboolean _ClampFragmentColor; /** < with GL_FIXED_ONLY_ARB resolved */ - GLenum ClampReadColor; /**< GL_TRUE, GL_FALSE or GL_FIXED_ONLY_ARB */ - GLboolean _ClampReadColor; /** < with GL_FIXED_ONLY_ARB resolved */ - - GLboolean sRGBEnabled; /**< Framebuffer sRGB blending/updating requested */ -}; - - -/** - * Current attribute group (GL_CURRENT_BIT). - */ -struct gl_current_attrib -{ - /** - * \name Current vertex attributes. - * \note Values are valid only after FLUSH_VERTICES has been called. - * \note Index and Edgeflag current values are stored as floats in the - * SIX and SEVEN attribute slots. - */ - GLfloat Attrib[VERT_ATTRIB_MAX][4]; /**< Position, color, texcoords, etc */ - - /** - * \name Current raster position attributes (always valid). - * \note This set of attributes is very similar to the SWvertex struct. - */ - /*@{*/ - GLfloat RasterPos[4]; - GLfloat RasterDistance; - GLfloat RasterColor[4]; - GLfloat RasterSecondaryColor[4]; - GLfloat RasterTexCoords[MAX_TEXTURE_COORD_UNITS][4]; - GLboolean RasterPosValid; - /*@}*/ -}; - - -/** - * Depth buffer attribute group (GL_DEPTH_BUFFER_BIT). - */ -struct gl_depthbuffer_attrib -{ - GLenum Func; /**< Function for depth buffer compare */ - GLclampd Clear; /**< Value to clear depth buffer to */ - GLboolean Test; /**< Depth buffering enabled flag */ - GLboolean Mask; /**< Depth buffer writable? */ - GLboolean BoundsTest; /**< GL_EXT_depth_bounds_test */ - GLfloat BoundsMin, BoundsMax;/**< GL_EXT_depth_bounds_test */ -}; - - -/** - * Evaluator attribute group (GL_EVAL_BIT). - */ -struct gl_eval_attrib -{ - /** - * \name Enable bits - */ - /*@{*/ - GLboolean Map1Color4; - GLboolean Map1Index; - GLboolean Map1Normal; - GLboolean Map1TextureCoord1; - GLboolean Map1TextureCoord2; - GLboolean Map1TextureCoord3; - GLboolean Map1TextureCoord4; - GLboolean Map1Vertex3; - GLboolean Map1Vertex4; - GLboolean Map1Attrib[16]; /* GL_NV_vertex_program */ - GLboolean Map2Color4; - GLboolean Map2Index; - GLboolean Map2Normal; - GLboolean Map2TextureCoord1; - GLboolean Map2TextureCoord2; - GLboolean Map2TextureCoord3; - GLboolean Map2TextureCoord4; - GLboolean Map2Vertex3; - GLboolean Map2Vertex4; - GLboolean Map2Attrib[16]; /* GL_NV_vertex_program */ - GLboolean AutoNormal; - /*@}*/ - - /** - * \name Map Grid endpoints and divisions and calculated du values - */ - /*@{*/ - GLint MapGrid1un; - GLfloat MapGrid1u1, MapGrid1u2, MapGrid1du; - GLint MapGrid2un, MapGrid2vn; - GLfloat MapGrid2u1, MapGrid2u2, MapGrid2du; - GLfloat MapGrid2v1, MapGrid2v2, MapGrid2dv; - /*@}*/ -}; - - -/** - * Fog attribute group (GL_FOG_BIT). - */ -struct gl_fog_attrib -{ - GLboolean Enabled; /**< Fog enabled flag */ - GLfloat ColorUnclamped[4]; /**< Fog color */ - GLfloat Color[4]; /**< Fog color */ - GLfloat Density; /**< Density >= 0.0 */ - GLfloat Start; /**< Start distance in eye coords */ - GLfloat End; /**< End distance in eye coords */ - GLfloat Index; /**< Fog index */ - GLenum Mode; /**< Fog mode */ - GLboolean ColorSumEnabled; - GLenum FogCoordinateSource; /**< GL_EXT_fog_coord */ - GLfloat _Scale; /**< (End == Start) ? 1.0 : 1.0 / (End - Start) */ -}; - - -/** - * \brief Layout qualifiers for gl_FragDepth. - * - * Extension AMD_conservative_depth allows gl_FragDepth to be redeclared with - * a layout qualifier. - * - * \see enum ir_depth_layout - */ -enum gl_frag_depth_layout { - FRAG_DEPTH_LAYOUT_NONE, /**< No layout is specified. */ - FRAG_DEPTH_LAYOUT_ANY, - FRAG_DEPTH_LAYOUT_GREATER, - FRAG_DEPTH_LAYOUT_LESS, - FRAG_DEPTH_LAYOUT_UNCHANGED -}; - - -/** - * Hint attribute group (GL_HINT_BIT). - * - * Values are always one of GL_FASTEST, GL_NICEST, or GL_DONT_CARE. - */ -struct gl_hint_attrib -{ - GLenum PerspectiveCorrection; - GLenum PointSmooth; - GLenum LineSmooth; - GLenum PolygonSmooth; - GLenum Fog; - GLenum ClipVolumeClipping; /**< GL_EXT_clip_volume_hint */ - GLenum TextureCompression; /**< GL_ARB_texture_compression */ - GLenum GenerateMipmap; /**< GL_SGIS_generate_mipmap */ - GLenum FragmentShaderDerivative; /**< GL_ARB_fragment_shader */ -}; - -/** - * Light state flags. - */ -/*@{*/ -#define LIGHT_SPOT 0x1 -#define LIGHT_LOCAL_VIEWER 0x2 -#define LIGHT_POSITIONAL 0x4 -#define LIGHT_NEED_VERTICES (LIGHT_POSITIONAL|LIGHT_LOCAL_VIEWER) -/*@}*/ - - -/** - * Lighting attribute group (GL_LIGHT_BIT). - */ -struct gl_light_attrib -{ - struct gl_light Light[MAX_LIGHTS]; /**< Array of light sources */ - struct gl_lightmodel Model; /**< Lighting model */ - - /** - * Must flush FLUSH_VERTICES before referencing: - */ - /*@{*/ - struct gl_material Material; /**< Includes front & back values */ - /*@}*/ - - GLboolean Enabled; /**< Lighting enabled flag */ - GLenum ShadeModel; /**< GL_FLAT or GL_SMOOTH */ - GLenum ProvokingVertex; /**< GL_EXT_provoking_vertex */ - GLenum ColorMaterialFace; /**< GL_FRONT, BACK or FRONT_AND_BACK */ - GLenum ColorMaterialMode; /**< GL_AMBIENT, GL_DIFFUSE, etc */ - GLbitfield ColorMaterialBitmask; /**< bitmask formed from Face and Mode */ - GLboolean ColorMaterialEnabled; - GLenum ClampVertexColor; - GLboolean _ClampVertexColor; - - struct gl_light EnabledList; /**< List sentinel */ - - /** - * Derived state for optimizations: - */ - /*@{*/ - GLboolean _NeedEyeCoords; - GLboolean _NeedVertices; /**< Use fast shader? */ - GLbitfield _Flags; /**< LIGHT_* flags, see above */ - GLfloat _BaseColor[2][3]; - /*@}*/ -}; - - -/** - * Line attribute group (GL_LINE_BIT). - */ -struct gl_line_attrib -{ - GLboolean SmoothFlag; /**< GL_LINE_SMOOTH enabled? */ - GLboolean StippleFlag; /**< GL_LINE_STIPPLE enabled? */ - GLushort StipplePattern; /**< Stipple pattern */ - GLint StippleFactor; /**< Stipple repeat factor */ - GLfloat Width; /**< Line width */ -}; - - -/** - * Display list attribute group (GL_LIST_BIT). - */ -struct gl_list_attrib -{ - GLuint ListBase; -}; - - -/** - * Multisample attribute group (GL_MULTISAMPLE_BIT). - */ -struct gl_multisample_attrib -{ - GLboolean Enabled; - GLboolean _Enabled; /**< true if Enabled and multisample buffer */ - GLboolean SampleAlphaToCoverage; - GLboolean SampleAlphaToOne; - GLboolean SampleCoverage; - GLfloat SampleCoverageValue; - GLboolean SampleCoverageInvert; -}; - - -/** - * A pixelmap (see glPixelMap) - */ -struct gl_pixelmap -{ - GLint Size; - GLfloat Map[MAX_PIXEL_MAP_TABLE]; - GLubyte Map8[MAX_PIXEL_MAP_TABLE]; /**< converted to 8-bit color */ -}; - - -/** - * Collection of all pixelmaps - */ -struct gl_pixelmaps -{ - struct gl_pixelmap RtoR; /**< i.e. GL_PIXEL_MAP_R_TO_R */ - struct gl_pixelmap GtoG; - struct gl_pixelmap BtoB; - struct gl_pixelmap AtoA; - struct gl_pixelmap ItoR; - struct gl_pixelmap ItoG; - struct gl_pixelmap ItoB; - struct gl_pixelmap ItoA; - struct gl_pixelmap ItoI; - struct gl_pixelmap StoS; -}; - - -/** - * Pixel attribute group (GL_PIXEL_MODE_BIT). - */ -struct gl_pixel_attrib -{ - GLenum ReadBuffer; /**< source buffer for glRead/CopyPixels() */ - - /*--- Begin Pixel Transfer State ---*/ - /* Fields are in the order in which they're applied... */ - - /** Scale & Bias (index shift, offset) */ - /*@{*/ - GLfloat RedBias, RedScale; - GLfloat GreenBias, GreenScale; - GLfloat BlueBias, BlueScale; - GLfloat AlphaBias, AlphaScale; - GLfloat DepthBias, DepthScale; - GLint IndexShift, IndexOffset; - /*@}*/ - - /* Pixel Maps */ - /* Note: actual pixel maps are not part of this attrib group */ - GLboolean MapColorFlag; - GLboolean MapStencilFlag; - - /*--- End Pixel Transfer State ---*/ - - /** glPixelZoom */ - GLfloat ZoomX, ZoomY; -}; - - -/** - * Point attribute group (GL_POINT_BIT). - */ -struct gl_point_attrib -{ - GLboolean SmoothFlag; /**< True if GL_POINT_SMOOTH is enabled */ - GLfloat Size; /**< User-specified point size */ - GLfloat Params[3]; /**< GL_EXT_point_parameters */ - GLfloat MinSize, MaxSize; /**< GL_EXT_point_parameters */ - GLfloat Threshold; /**< GL_EXT_point_parameters */ - GLboolean _Attenuated; /**< True if Params != [1, 0, 0] */ - GLboolean PointSprite; /**< GL_NV/ARB_point_sprite */ - GLboolean CoordReplace[MAX_TEXTURE_COORD_UNITS]; /**< GL_ARB_point_sprite*/ - GLenum SpriteRMode; /**< GL_NV_point_sprite (only!) */ - GLenum SpriteOrigin; /**< GL_ARB_point_sprite */ -}; - - -/** - * Polygon attribute group (GL_POLYGON_BIT). - */ -struct gl_polygon_attrib -{ - GLenum FrontFace; /**< Either GL_CW or GL_CCW */ - GLenum FrontMode; /**< Either GL_POINT, GL_LINE or GL_FILL */ - GLenum BackMode; /**< Either GL_POINT, GL_LINE or GL_FILL */ - GLboolean _FrontBit; /**< 0=GL_CCW, 1=GL_CW */ - GLboolean CullFlag; /**< Culling on/off flag */ - GLboolean SmoothFlag; /**< True if GL_POLYGON_SMOOTH is enabled */ - GLboolean StippleFlag; /**< True if GL_POLYGON_STIPPLE is enabled */ - GLenum CullFaceMode; /**< Culling mode GL_FRONT or GL_BACK */ - GLfloat OffsetFactor; /**< Polygon offset factor, from user */ - GLfloat OffsetUnits; /**< Polygon offset units, from user */ - GLboolean OffsetPoint; /**< Offset in GL_POINT mode */ - GLboolean OffsetLine; /**< Offset in GL_LINE mode */ - GLboolean OffsetFill; /**< Offset in GL_FILL mode */ -}; - - -/** - * Scissor attributes (GL_SCISSOR_BIT). - */ -struct gl_scissor_attrib -{ - GLboolean Enabled; /**< Scissor test enabled? */ - GLint X, Y; /**< Lower left corner of box */ - GLsizei Width, Height; /**< Size of box */ -}; - - -/** - * Stencil attribute group (GL_STENCIL_BUFFER_BIT). - * - * Three sets of stencil data are tracked so that OpenGL 2.0, - * GL_EXT_stencil_two_side, and GL_ATI_separate_stencil can all be supported - * simultaneously. In each of the stencil state arrays, element 0 corresponds - * to GL_FRONT. Element 1 corresponds to the OpenGL 2.0 / - * GL_ATI_separate_stencil GL_BACK state. Element 2 corresponds to the - * GL_EXT_stencil_two_side GL_BACK state. - * - * The derived value \c _BackFace is either 1 or 2 depending on whether or - * not GL_STENCIL_TEST_TWO_SIDE_EXT is enabled. - * - * The derived value \c _TestTwoSide is set when the front-face and back-face - * stencil state are different. - */ -struct gl_stencil_attrib -{ - GLboolean Enabled; /**< Enabled flag */ - GLboolean TestTwoSide; /**< GL_EXT_stencil_two_side */ - GLubyte ActiveFace; /**< GL_EXT_stencil_two_side (0 or 2) */ - GLboolean _Enabled; /**< Enabled and stencil buffer present */ - GLboolean _TestTwoSide; - GLubyte _BackFace; /**< Current back stencil state (1 or 2) */ - GLenum Function[3]; /**< Stencil function */ - GLenum FailFunc[3]; /**< Fail function */ - GLenum ZPassFunc[3]; /**< Depth buffer pass function */ - GLenum ZFailFunc[3]; /**< Depth buffer fail function */ - GLint Ref[3]; /**< Reference value */ - GLuint ValueMask[3]; /**< Value mask */ - GLuint WriteMask[3]; /**< Write mask */ - GLuint Clear; /**< Clear value */ -}; - - -/** - * An index for each type of texture object. These correspond to the GL - * texture target enums, such as GL_TEXTURE_2D, GL_TEXTURE_CUBE_MAP, etc. - * Note: the order is from highest priority to lowest priority. - */ -typedef enum -{ - TEXTURE_BUFFER_INDEX, - TEXTURE_2D_ARRAY_INDEX, - TEXTURE_1D_ARRAY_INDEX, - TEXTURE_CUBE_INDEX, - TEXTURE_3D_INDEX, - TEXTURE_RECT_INDEX, - TEXTURE_2D_INDEX, - TEXTURE_1D_INDEX, - NUM_TEXTURE_TARGETS -} gl_texture_index; - - -/** - * Bit flags for each type of texture object - * Used for Texture.Unit[]._ReallyEnabled flags. - */ -/*@{*/ -#define TEXTURE_BUFFER_BIT (1 << TEXTURE_BUFFER_INDEX) -#define TEXTURE_2D_ARRAY_BIT (1 << TEXTURE_2D_ARRAY_INDEX) -#define TEXTURE_1D_ARRAY_BIT (1 << TEXTURE_1D_ARRAY_INDEX) -#define TEXTURE_CUBE_BIT (1 << TEXTURE_CUBE_INDEX) -#define TEXTURE_3D_BIT (1 << TEXTURE_3D_INDEX) -#define TEXTURE_RECT_BIT (1 << TEXTURE_RECT_INDEX) -#define TEXTURE_2D_BIT (1 << TEXTURE_2D_INDEX) -#define TEXTURE_1D_BIT (1 << TEXTURE_1D_INDEX) -/*@}*/ - - -/** - * TexGenEnabled flags. - */ -/*@{*/ -#define S_BIT 1 -#define T_BIT 2 -#define R_BIT 4 -#define Q_BIT 8 -#define STR_BITS (S_BIT | T_BIT | R_BIT) -/*@}*/ - - -/** - * Bit flag versions of the corresponding GL_ constants. - */ -/*@{*/ -#define TEXGEN_SPHERE_MAP 0x1 -#define TEXGEN_OBJ_LINEAR 0x2 -#define TEXGEN_EYE_LINEAR 0x4 -#define TEXGEN_REFLECTION_MAP_NV 0x8 -#define TEXGEN_NORMAL_MAP_NV 0x10 - -#define TEXGEN_NEED_NORMALS (TEXGEN_SPHERE_MAP | \ - TEXGEN_REFLECTION_MAP_NV | \ - TEXGEN_NORMAL_MAP_NV) -#define TEXGEN_NEED_EYE_COORD (TEXGEN_SPHERE_MAP | \ - TEXGEN_REFLECTION_MAP_NV | \ - TEXGEN_NORMAL_MAP_NV | \ - TEXGEN_EYE_LINEAR) -/*@}*/ - - - -/** Tex-gen enabled for texture unit? */ -#define ENABLE_TEXGEN(unit) (1 << (unit)) - -/** Non-identity texture matrix for texture unit? */ -#define ENABLE_TEXMAT(unit) (1 << (unit)) - - -/** - * Texel fetch function prototype. We use texel fetch functions to - * extract RGBA, color indexes and depth components out of 1D, 2D and 3D - * texture images. These functions help to isolate us from the gritty - * details of all the various texture image encodings. - * - * \param texImage texture image. - * \param col texel column. - * \param row texel row. - * \param img texel image level/layer. - * \param texelOut output texel (up to 4 GLchans) - */ -typedef void (*FetchTexelFuncC)( const struct gl_texture_image *texImage, - GLint col, GLint row, GLint img, - GLchan *texelOut ); - -/** - * As above, but returns floats. - * Used for depth component images and for upcoming signed/float - * texture images. - */ -typedef void (*FetchTexelFuncF)( const struct gl_texture_image *texImage, - GLint col, GLint row, GLint img, - GLfloat *texelOut ); - - -typedef void (*StoreTexelFunc)(struct gl_texture_image *texImage, - GLint col, GLint row, GLint img, - const void *texel); - - -/** - * Texture image state. Describes the dimensions of a texture image, - * the texel format and pointers to Texel Fetch functions. - */ -struct gl_texture_image -{ - GLint InternalFormat; /**< Internal format as given by the user */ - GLenum _BaseFormat; /**< Either GL_RGB, GL_RGBA, GL_ALPHA, - * GL_LUMINANCE, GL_LUMINANCE_ALPHA, - * GL_INTENSITY, GL_DEPTH_COMPONENT or - * GL_DEPTH_STENCIL_EXT only. Used for - * choosing TexEnv arithmetic. - */ - gl_format TexFormat; /**< The actual texture memory format */ - - GLuint Border; /**< 0 or 1 */ - GLuint Width; /**< = 2^WidthLog2 + 2*Border */ - GLuint Height; /**< = 2^HeightLog2 + 2*Border */ - GLuint Depth; /**< = 2^DepthLog2 + 2*Border */ - GLuint Width2; /**< = Width - 2*Border */ - GLuint Height2; /**< = Height - 2*Border */ - GLuint Depth2; /**< = Depth - 2*Border */ - GLuint WidthLog2; /**< = log2(Width2) */ - GLuint HeightLog2; /**< = log2(Height2) */ - GLuint DepthLog2; /**< = log2(Depth2) */ - GLuint MaxLog2; /**< = MAX(WidthLog2, HeightLog2) */ - GLfloat WidthScale; /**< used for mipmap LOD computation */ - GLfloat HeightScale; /**< used for mipmap LOD computation */ - GLfloat DepthScale; /**< used for mipmap LOD computation */ - GLboolean IsClientData; /**< Data owned by client? */ - GLboolean _IsPowerOfTwo; /**< Are all dimensions powers of two? */ - - struct gl_texture_object *TexObject; /**< Pointer back to parent object */ - GLuint Level; /**< Which mipmap level am I? */ - /** Cube map face: index into gl_texture_object::Image[] array */ - GLuint Face; - - FetchTexelFuncC FetchTexelc; /**< GLchan texel fetch function pointer */ - FetchTexelFuncF FetchTexelf; /**< Float texel fetch function pointer */ - - GLuint RowStride; /**< Padded width in units of texels */ - GLuint *ImageOffsets; /**< if 3D texture: array [Depth] of offsets to - each 2D slice in 'Data', in texels */ - GLvoid *Data; /**< Image data, accessed via FetchTexel() */ - - /** - * \name For device driver: - */ - /*@{*/ - void *DriverData; /**< Arbitrary device driver data */ - /*@}*/ -}; - - -/** - * Indexes for cube map faces. - */ -typedef enum -{ - FACE_POS_X = 0, - FACE_NEG_X = 1, - FACE_POS_Y = 2, - FACE_NEG_Y = 3, - FACE_POS_Z = 4, - FACE_NEG_Z = 5, - MAX_FACES = 6 -} gl_face_index; - - -/** - * Sampler object state. These objects are new with GL_ARB_sampler_objects - * and OpenGL 3.3. Legacy texture objects also contain a sampler object. - */ -struct gl_sampler_object -{ - GLuint Name; - GLint RefCount; - - GLenum WrapS; /**< S-axis texture image wrap mode */ - GLenum WrapT; /**< T-axis texture image wrap mode */ - GLenum WrapR; /**< R-axis texture image wrap mode */ - GLenum MinFilter; /**< minification filter */ - GLenum MagFilter; /**< magnification filter */ - union { - GLfloat f[4]; - GLuint ui[4]; - GLint i[4]; - } BorderColor; /**< Interpreted according to texture format */ - GLfloat MinLod; /**< min lambda, OpenGL 1.2 */ - GLfloat MaxLod; /**< max lambda, OpenGL 1.2 */ - GLfloat LodBias; /**< OpenGL 1.4 */ - GLfloat MaxAnisotropy; /**< GL_EXT_texture_filter_anisotropic */ - GLenum CompareMode; /**< GL_ARB_shadow */ - GLenum CompareFunc; /**< GL_ARB_shadow */ - GLfloat CompareFailValue; /**< GL_ARB_shadow_ambient */ - GLenum sRGBDecode; /**< GL_DECODE_EXT or GL_SKIP_DECODE_EXT */ - GLboolean CubeMapSeamless; /**< GL_AMD_seamless_cubemap_per_texture */ - - /* deprecated sampler state */ - GLenum DepthMode; /**< GL_ARB_depth_texture */ - - /** Is the texture object complete with respect to this sampler? */ - GLboolean _CompleteTexture; -}; - - -/** - * Texture object state. Contains the array of mipmap images, border color, - * wrap modes, filter modes, and shadow/texcompare state. - */ -struct gl_texture_object -{ - _glthread_Mutex Mutex; /**< for thread safety */ - GLint RefCount; /**< reference count */ - GLuint Name; /**< the user-visible texture object ID */ - GLenum Target; /**< GL_TEXTURE_1D, GL_TEXTURE_2D, etc. */ - - struct gl_sampler_object Sampler; - - GLfloat Priority; /**< in [0,1] */ - GLint BaseLevel; /**< min mipmap level, OpenGL 1.2 */ - GLint MaxLevel; /**< max mipmap level, OpenGL 1.2 */ - GLint _MaxLevel; /**< actual max mipmap level (q in the spec) */ - GLfloat _MaxLambda; /**< = _MaxLevel - BaseLevel (q - b in spec) */ - GLint CropRect[4]; /**< GL_OES_draw_texture */ - GLenum Swizzle[4]; /**< GL_EXT_texture_swizzle */ - GLuint _Swizzle; /**< same as Swizzle, but SWIZZLE_* format */ - GLboolean GenerateMipmap; /**< GL_SGIS_generate_mipmap */ - GLboolean _Complete; /**< Is texture object complete? */ - GLboolean _RenderToTexture; /**< Any rendering to this texture? */ - GLboolean Purgeable; /**< Is the buffer purgeable under memory pressure? */ - - /** Actual texture images, indexed by [cube face] and [mipmap level] */ - struct gl_texture_image *Image[MAX_FACES][MAX_TEXTURE_LEVELS]; - - /** GL_ARB_texture_buffer_object */ - struct gl_buffer_object *BufferObject; - GLenum BufferObjectFormat; - - /** - * \name For device driver. - * Note: instead of attaching driver data to this pointer, it's preferable - * to instead use this struct as a base class for your own texture object - * class. Driver->NewTextureObject() can be used to implement the - * allocation. - */ - void *DriverData; /**< Arbitrary device driver data */ -}; - - -/** Up to four combiner sources are possible with GL_NV_texture_env_combine4 */ -#define MAX_COMBINER_TERMS 4 - - -/** - * Texture combine environment state. - */ -struct gl_tex_env_combine_state -{ - GLenum ModeRGB; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */ - GLenum ModeA; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */ - /** Source terms: GL_PRIMARY_COLOR, GL_TEXTURE, etc */ - GLenum SourceRGB[MAX_COMBINER_TERMS]; - GLenum SourceA[MAX_COMBINER_TERMS]; - /** Source operands: GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR, etc */ - GLenum OperandRGB[MAX_COMBINER_TERMS]; - GLenum OperandA[MAX_COMBINER_TERMS]; - GLuint ScaleShiftRGB; /**< 0, 1 or 2 */ - GLuint ScaleShiftA; /**< 0, 1 or 2 */ - GLuint _NumArgsRGB; /**< Number of inputs used for the RGB combiner */ - GLuint _NumArgsA; /**< Number of inputs used for the A combiner */ -}; - - -/** - * Texture coord generation state. - */ -struct gl_texgen -{ - GLenum Mode; /**< GL_EYE_LINEAR, GL_SPHERE_MAP, etc */ - GLbitfield _ModeBit; /**< TEXGEN_x bit corresponding to Mode */ - GLfloat ObjectPlane[4]; - GLfloat EyePlane[4]; -}; - - -/** - * Texture unit state. Contains enable flags, texture environment/function/ - * combiners, texgen state, and pointers to current texture objects. - */ -struct gl_texture_unit -{ - GLbitfield Enabled; /**< bitmask of TEXTURE_*_BIT flags */ - GLbitfield _ReallyEnabled; /**< 0 or exactly one of TEXTURE_*_BIT flags */ - - GLenum EnvMode; /**< GL_MODULATE, GL_DECAL, GL_BLEND, etc. */ - GLclampf EnvColor[4]; - GLfloat EnvColorUnclamped[4]; - - struct gl_texgen GenS; - struct gl_texgen GenT; - struct gl_texgen GenR; - struct gl_texgen GenQ; - GLbitfield TexGenEnabled; /**< Bitwise-OR of [STRQ]_BIT values */ - GLbitfield _GenFlags; /**< Bitwise-OR of Gen[STRQ]._ModeBit */ - - GLfloat LodBias; /**< for biasing mipmap levels */ - GLenum BumpTarget; - GLfloat RotMatrix[4]; /* 2x2 matrix */ - - /** Current sampler object (GL_ARB_sampler_objects) */ - struct gl_sampler_object *Sampler; - - /** - * \name GL_EXT_texture_env_combine - */ - struct gl_tex_env_combine_state Combine; - - /** - * Derived state based on \c EnvMode and the \c BaseFormat of the - * currently enabled texture. - */ - struct gl_tex_env_combine_state _EnvMode; - - /** - * Currently enabled combiner state. This will point to either - * \c Combine or \c _EnvMode. - */ - struct gl_tex_env_combine_state *_CurrentCombine; - - /** Current texture object pointers */ - struct gl_texture_object *CurrentTex[NUM_TEXTURE_TARGETS]; - - /** Points to highest priority, complete and enabled texture object */ - struct gl_texture_object *_Current; -}; - - -/** - * Texture attribute group (GL_TEXTURE_BIT). - */ -struct gl_texture_attrib -{ - GLuint CurrentUnit; /**< GL_ACTIVE_TEXTURE */ - struct gl_texture_unit Unit[MAX_COMBINED_TEXTURE_IMAGE_UNITS]; - - struct gl_texture_object *ProxyTex[NUM_TEXTURE_TARGETS]; - - /** GL_ARB_texture_buffer_object */ - struct gl_buffer_object *BufferObject; - - /** GL_ARB_seamless_cubemap */ - GLboolean CubeMapSeamless; - - /** Texture units/samplers used by vertex or fragment texturing */ - GLbitfield _EnabledUnits; - - /** Texture coord units/sets used for fragment texturing */ - GLbitfield _EnabledCoordUnits; - - /** Texture coord units that have texgen enabled */ - GLbitfield _TexGenEnabled; - - /** Texture coord units that have non-identity matrices */ - GLbitfield _TexMatEnabled; - - /** Bitwise-OR of all Texture.Unit[i]._GenFlags */ - GLbitfield _GenFlags; -}; - - -/** - * Transformation attribute group (GL_TRANSFORM_BIT). - */ -struct gl_transform_attrib -{ - GLenum MatrixMode; /**< Matrix mode */ - GLfloat EyeUserPlane[MAX_CLIP_PLANES][4]; /**< User clip planes */ - GLfloat _ClipUserPlane[MAX_CLIP_PLANES][4]; /**< derived */ - GLbitfield ClipPlanesEnabled; /**< on/off bitmask */ - GLboolean Normalize; /**< Normalize all normals? */ - GLboolean RescaleNormals; /**< GL_EXT_rescale_normal */ - GLboolean RasterPositionUnclipped; /**< GL_IBM_rasterpos_clip */ - GLboolean DepthClamp; /**< GL_ARB_depth_clamp */ - - GLfloat CullEyePos[4]; - GLfloat CullObjPos[4]; -}; - - -/** - * Viewport attribute group (GL_VIEWPORT_BIT). - */ -struct gl_viewport_attrib -{ - GLint X, Y; /**< position */ - GLsizei Width, Height; /**< size */ - GLfloat Near, Far; /**< Depth buffer range */ - GLmatrix _WindowMap; /**< Mapping transformation as a matrix. */ -}; - - -/** - * GL_ARB_vertex/pixel_buffer_object buffer object - */ -struct gl_buffer_object -{ - _glthread_Mutex Mutex; - GLint RefCount; - GLuint Name; - GLenum Usage; /**< GL_STREAM_DRAW_ARB, GL_STREAM_READ_ARB, etc. */ - GLsizeiptrARB Size; /**< Size of buffer storage in bytes */ - GLubyte *Data; /**< Location of storage either in RAM or VRAM. */ - /** Fields describing a mapped buffer */ - /*@{*/ - GLbitfield AccessFlags; /**< Mask of GL_MAP_x_BIT flags */ - GLvoid *Pointer; /**< User-space address of mapping */ - GLintptr Offset; /**< Mapped offset */ - GLsizeiptr Length; /**< Mapped length */ - /*@}*/ - GLboolean Written; /**< Ever written to? (for debugging) */ - GLboolean Purgeable; /**< Is the buffer purgeable under memory pressure? */ -}; - - -/** - * Client pixel packing/unpacking attributes - */ -struct gl_pixelstore_attrib -{ - GLint Alignment; - GLint RowLength; - GLint SkipPixels; - GLint SkipRows; - GLint ImageHeight; - GLint SkipImages; - GLboolean SwapBytes; - GLboolean LsbFirst; - GLboolean ClientStorage; /**< GL_APPLE_client_storage */ - GLboolean Invert; /**< GL_MESA_pack_invert */ - struct gl_buffer_object *BufferObj; /**< GL_ARB_pixel_buffer_object */ -}; - - -/** - * Client vertex array attributes - */ -struct gl_client_array -{ - GLint Size; /**< components per element (1,2,3,4) */ - GLenum Type; /**< datatype: GL_FLOAT, GL_INT, etc */ - GLenum Format; /**< default: GL_RGBA, but may be GL_BGRA */ - GLsizei Stride; /**< user-specified stride */ - GLsizei StrideB; /**< actual stride in bytes */ - const GLubyte *Ptr; /**< Points to array data */ - GLboolean Enabled; /**< Enabled flag is a boolean */ - GLboolean Normalized; /**< GL_ARB_vertex_program */ - GLboolean Integer; /**< Integer-valued? */ - GLuint InstanceDivisor; /**< GL_ARB_instanced_arrays */ - GLuint _ElementSize; /**< size of each element in bytes */ - - struct gl_buffer_object *BufferObj;/**< GL_ARB_vertex_buffer_object */ - GLuint _MaxElement; /**< max element index into array buffer + 1 */ -}; - - -/** - * Collection of vertex arrays. Defined by the GL_APPLE_vertex_array_object - * extension, but a nice encapsulation in any case. - */ -struct gl_array_object -{ - /** Name of the array object as received from glGenVertexArrayAPPLE. */ - GLuint Name; - - GLint RefCount; - _glthread_Mutex Mutex; - GLboolean VBOonly; /**< require all arrays to live in VBOs? */ - - /** Conventional vertex arrays */ - /*@{*/ - struct gl_client_array Vertex; - struct gl_client_array Weight; - struct gl_client_array Normal; - struct gl_client_array Color; - struct gl_client_array SecondaryColor; - struct gl_client_array FogCoord; - struct gl_client_array Index; - struct gl_client_array EdgeFlag; - struct gl_client_array TexCoord[MAX_TEXTURE_COORD_UNITS]; - struct gl_client_array PointSize; - /*@}*/ - - /** - * Generic arrays for vertex programs/shaders. - * For NV vertex programs, these attributes alias and take priority - * over the conventional attribs above. For ARB vertex programs and - * GLSL vertex shaders, these attributes are separate. - */ - struct gl_client_array VertexAttrib[MAX_VERTEX_GENERIC_ATTRIBS]; - - /** Mask of _NEW_ARRAY_* values indicating which arrays are enabled */ - GLbitfield _Enabled; - - /** - * Min of all enabled arrays' _MaxElement. When arrays reside inside VBOs - * we can determine the max legal (in bounds) glDrawElements array index. - */ - GLuint _MaxElement; -}; - - -/** - * Vertex array state - */ -struct gl_array_attrib -{ - /** Currently bound array object. See _mesa_BindVertexArrayAPPLE() */ - struct gl_array_object *ArrayObj; - - /** The default vertex array object */ - struct gl_array_object *DefaultArrayObj; - - /** Array objects (GL_ARB/APPLE_vertex_array_object) */ - struct _mesa_HashTable *Objects; - - GLint ActiveTexture; /**< Client Active Texture */ - GLuint LockFirst; /**< GL_EXT_compiled_vertex_array */ - GLuint LockCount; /**< GL_EXT_compiled_vertex_array */ - - /** GL 3.1 (slightly different from GL_NV_primitive_restart) */ - GLboolean PrimitiveRestart; - GLuint RestartIndex; - - GLbitfield NewState; /**< mask of _NEW_ARRAY_* values */ - GLboolean RebindArrays; /**< whether the VBO module should rebind arrays */ - - /* GL_ARB_vertex_buffer_object */ - struct gl_buffer_object *ArrayBufferObj; - struct gl_buffer_object *ElementArrayBufferObj; -}; - - -/** - * Feedback buffer state - */ -struct gl_feedback -{ - GLenum Type; - GLbitfield _Mask; /**< FB_* bits */ - GLfloat *Buffer; - GLuint BufferSize; - GLuint Count; -}; - - -/** - * Selection buffer state - */ -struct gl_selection -{ - GLuint *Buffer; /**< selection buffer */ - GLuint BufferSize; /**< size of the selection buffer */ - GLuint BufferCount; /**< number of values in the selection buffer */ - GLuint Hits; /**< number of records in the selection buffer */ - GLuint NameStackDepth; /**< name stack depth */ - GLuint NameStack[MAX_NAME_STACK_DEPTH]; /**< name stack */ - GLboolean HitFlag; /**< hit flag */ - GLfloat HitMinZ; /**< minimum hit depth */ - GLfloat HitMaxZ; /**< maximum hit depth */ -}; - - -/** - * 1-D Evaluator control points - */ -struct gl_1d_map -{ - GLuint Order; /**< Number of control points */ - GLfloat u1, u2, du; /**< u1, u2, 1.0/(u2-u1) */ - GLfloat *Points; /**< Points to contiguous control points */ -}; - - -/** - * 2-D Evaluator control points - */ -struct gl_2d_map -{ - GLuint Uorder; /**< Number of control points in U dimension */ - GLuint Vorder; /**< Number of control points in V dimension */ - GLfloat u1, u2, du; - GLfloat v1, v2, dv; - GLfloat *Points; /**< Points to contiguous control points */ -}; - - -/** - * All evaluator control point state - */ -struct gl_evaluators -{ - /** - * \name 1-D maps - */ - /*@{*/ - struct gl_1d_map Map1Vertex3; - struct gl_1d_map Map1Vertex4; - struct gl_1d_map Map1Index; - struct gl_1d_map Map1Color4; - struct gl_1d_map Map1Normal; - struct gl_1d_map Map1Texture1; - struct gl_1d_map Map1Texture2; - struct gl_1d_map Map1Texture3; - struct gl_1d_map Map1Texture4; - struct gl_1d_map Map1Attrib[16]; /**< GL_NV_vertex_program */ - /*@}*/ - - /** - * \name 2-D maps - */ - /*@{*/ - struct gl_2d_map Map2Vertex3; - struct gl_2d_map Map2Vertex4; - struct gl_2d_map Map2Index; - struct gl_2d_map Map2Color4; - struct gl_2d_map Map2Normal; - struct gl_2d_map Map2Texture1; - struct gl_2d_map Map2Texture2; - struct gl_2d_map Map2Texture3; - struct gl_2d_map Map2Texture4; - struct gl_2d_map Map2Attrib[16]; /**< GL_NV_vertex_program */ - /*@}*/ -}; - - -/** - * Names of the various vertex/fragment program register files, etc. - * - * NOTE: first four tokens must fit into 2 bits (see t_vb_arbprogram.c) - * All values should fit in a 4-bit field. - * - * NOTE: PROGRAM_ENV_PARAM, PROGRAM_STATE_VAR, PROGRAM_NAMED_PARAM, - * PROGRAM_CONSTANT, and PROGRAM_UNIFORM can all be considered to - * be "uniform" variables since they can only be set outside glBegin/End. - * They're also all stored in the same Parameters array. - */ -typedef enum -{ - PROGRAM_TEMPORARY, /**< machine->Temporary[] */ - PROGRAM_INPUT, /**< machine->Inputs[] */ - PROGRAM_OUTPUT, /**< machine->Outputs[] */ - PROGRAM_VARYING, /**< machine->Inputs[]/Outputs[] */ - PROGRAM_LOCAL_PARAM, /**< gl_program->LocalParams[] */ - PROGRAM_ENV_PARAM, /**< gl_program->Parameters[] */ - PROGRAM_STATE_VAR, /**< gl_program->Parameters[] */ - PROGRAM_NAMED_PARAM, /**< gl_program->Parameters[] */ - PROGRAM_CONSTANT, /**< gl_program->Parameters[] */ - PROGRAM_UNIFORM, /**< gl_program->Parameters[] */ - PROGRAM_WRITE_ONLY, /**< A dummy, write-only register */ - PROGRAM_ADDRESS, /**< machine->AddressReg */ - PROGRAM_SAMPLER, /**< for shader samplers, compile-time only */ - PROGRAM_SYSTEM_VALUE,/**< InstanceId, PrimitiveID, etc. */ - PROGRAM_UNDEFINED, /**< Invalid/TBD value */ - PROGRAM_FILE_MAX -} gl_register_file; - - -/** - * If the register file is PROGRAM_SYSTEM_VALUE, the register index will be - * one of these values. - */ -typedef enum -{ - SYSTEM_VALUE_FRONT_FACE, /**< Fragment shader only (not done yet) */ - SYSTEM_VALUE_INSTANCE_ID, /**< Vertex shader only */ - SYSTEM_VALUE_MAX /**< Number of values */ -} gl_system_value; - - -/** Vertex and fragment instructions */ -struct prog_instruction; -struct gl_program_parameter_list; -struct gl_uniform_list; - - -/** - * Base class for any kind of program object - */ -struct gl_program -{ - GLuint Id; - GLubyte *String; /**< Null-terminated program text */ - GLint RefCount; - GLenum Target; /**< GL_VERTEX/FRAGMENT_PROGRAM_ARB, GL_FRAGMENT_PROGRAM_NV */ - GLenum Format; /**< String encoding format */ - GLboolean Resident; - - struct prog_instruction *Instructions; - - GLbitfield InputsRead; /**< Bitmask of which input regs are read */ - GLbitfield64 OutputsWritten; /**< Bitmask of which output regs are written */ - GLbitfield SystemValuesRead; /**< Bitmask of SYSTEM_VALUE_x inputs used */ - GLbitfield InputFlags[MAX_PROGRAM_INPUTS]; /**< PROG_PARAM_BIT_x flags */ - GLbitfield OutputFlags[MAX_PROGRAM_OUTPUTS]; /**< PROG_PARAM_BIT_x flags */ - GLbitfield TexturesUsed[MAX_COMBINED_TEXTURE_IMAGE_UNITS]; /**< TEXTURE_x_BIT bitmask */ - GLbitfield SamplersUsed; /**< Bitfield of which samplers are used */ - GLbitfield ShadowSamplers; /**< Texture units used for shadow sampling. */ - - - /** Named parameters, constants, etc. from program text */ - struct gl_program_parameter_list *Parameters; - /** Numbered local parameters */ - GLfloat LocalParams[MAX_PROGRAM_LOCAL_PARAMS][4]; - - /** Vertex/fragment shader varying vars */ - struct gl_program_parameter_list *Varying; - /** Vertex program user-defined attributes */ - struct gl_program_parameter_list *Attributes; - - /** Map from sampler unit to texture unit (set by glUniform1i()) */ - GLubyte SamplerUnits[MAX_SAMPLERS]; - /** Which texture target is being sampled (TEXTURE_1D/2D/3D/etc_INDEX) */ - gl_texture_index SamplerTargets[MAX_SAMPLERS]; - - /** Bitmask of which register files are read/written with indirect - * addressing. Mask of (1 << PROGRAM_x) bits. - */ - GLbitfield IndirectRegisterFiles; - - /** Logical counts */ - /*@{*/ - GLuint NumInstructions; - GLuint NumTemporaries; - GLuint NumParameters; - GLuint NumAttributes; - GLuint NumAddressRegs; - GLuint NumAluInstructions; - GLuint NumTexInstructions; - GLuint NumTexIndirections; - /*@}*/ - /** Native, actual h/w counts */ - /*@{*/ - GLuint NumNativeInstructions; - GLuint NumNativeTemporaries; - GLuint NumNativeParameters; - GLuint NumNativeAttributes; - GLuint NumNativeAddressRegs; - GLuint NumNativeAluInstructions; - GLuint NumNativeTexInstructions; - GLuint NumNativeTexIndirections; - /*@}*/ -}; - - -/** Vertex program object */ -struct gl_vertex_program -{ - struct gl_program Base; /**< base class */ - GLboolean IsNVProgram; /**< is this a GL_NV_vertex_program program? */ - GLboolean IsPositionInvariant; -}; - - -/** Geometry program object */ -struct gl_geometry_program -{ - struct gl_program Base; /**< base class */ - - GLint VerticesOut; - GLenum InputType; /**< GL_POINTS, GL_LINES, GL_LINES_ADJACENCY_ARB, - GL_TRIANGLES, or GL_TRIANGLES_ADJACENCY_ARB */ - GLenum OutputType; /**< GL_POINTS, GL_LINE_STRIP or GL_TRIANGLE_STRIP */ -}; - - -/** Fragment program object */ -struct gl_fragment_program -{ - struct gl_program Base; /**< base class */ - GLboolean UsesKill; /**< shader uses KIL instruction */ - GLboolean OriginUpperLeft; - GLboolean PixelCenterInteger; - enum gl_frag_depth_layout FragDepthLayout; -}; - - -/** - * State common to vertex and fragment programs. - */ -struct gl_program_state -{ - GLint ErrorPos; /* GL_PROGRAM_ERROR_POSITION_ARB/NV */ - const char *ErrorString; /* GL_PROGRAM_ERROR_STRING_ARB/NV */ -}; - - -/** - * Context state for vertex programs. - */ -struct gl_vertex_program_state -{ - GLboolean Enabled; /**< User-set GL_VERTEX_PROGRAM_ARB/NV flag */ - GLboolean _Enabled; /**< Enabled and _valid_ user program? */ - GLboolean PointSizeEnabled; /**< GL_VERTEX_PROGRAM_POINT_SIZE_ARB/NV */ - GLboolean TwoSideEnabled; /**< GL_VERTEX_PROGRAM_TWO_SIDE_ARB/NV */ - struct gl_vertex_program *Current; /**< User-bound vertex program */ - - /** Currently enabled and valid vertex program (including internal - * programs, user-defined vertex programs and GLSL vertex shaders). - * This is the program we must use when rendering. - */ - struct gl_vertex_program *_Current; - - GLfloat Parameters[MAX_PROGRAM_ENV_PARAMS][4]; /**< Env params */ - - /* For GL_NV_vertex_program only: */ - GLenum TrackMatrix[MAX_PROGRAM_ENV_PARAMS / 4]; - GLenum TrackMatrixTransform[MAX_PROGRAM_ENV_PARAMS / 4]; - - /** Should fixed-function T&L be implemented with a vertex prog? */ - GLboolean _MaintainTnlProgram; - - /** Program to emulate fixed-function T&L (see above) */ - struct gl_vertex_program *_TnlProgram; - - /** Cache of fixed-function programs */ - struct gl_program_cache *Cache; - - GLboolean _Overriden; -}; - - -/** - * Context state for geometry programs. - */ -struct gl_geometry_program_state -{ - GLboolean Enabled; /**< GL_ARB_GEOMETRY_SHADER4 */ - GLboolean _Enabled; /**< Enabled and valid program? */ - struct gl_geometry_program *Current; /**< user-bound geometry program */ - - /** Currently enabled and valid program (including internal programs - * and compiled shader programs). - */ - struct gl_geometry_program *_Current; - - GLfloat Parameters[MAX_PROGRAM_ENV_PARAMS][4]; /**< Env params */ - - /** Cache of fixed-function programs */ - struct gl_program_cache *Cache; -}; - -/** - * Context state for fragment programs. - */ -struct gl_fragment_program_state -{ - GLboolean Enabled; /**< User-set fragment program enable flag */ - GLboolean _Enabled; /**< Enabled and _valid_ user program? */ - struct gl_fragment_program *Current; /**< User-bound fragment program */ - - /** Currently enabled and valid fragment program (including internal - * programs, user-defined fragment programs and GLSL fragment shaders). - * This is the program we must use when rendering. - */ - struct gl_fragment_program *_Current; - - GLfloat Parameters[MAX_PROGRAM_ENV_PARAMS][4]; /**< Env params */ - - /** Should fixed-function texturing be implemented with a fragment prog? */ - GLboolean _MaintainTexEnvProgram; - - /** Program to emulate fixed-function texture env/combine (see above) */ - struct gl_fragment_program *_TexEnvProgram; - - /** Cache of fixed-function programs */ - struct gl_program_cache *Cache; -}; - - -/** - * ATI_fragment_shader runtime state - */ -#define ATI_FS_INPUT_PRIMARY 0 -#define ATI_FS_INPUT_SECONDARY 1 - -struct atifs_instruction; -struct atifs_setupinst; - -/** - * ATI fragment shader - */ -struct ati_fragment_shader -{ - GLuint Id; - GLint RefCount; - struct atifs_instruction *Instructions[2]; - struct atifs_setupinst *SetupInst[2]; - GLfloat Constants[8][4]; - GLbitfield LocalConstDef; /**< Indicates which constants have been set */ - GLubyte numArithInstr[2]; - GLubyte regsAssigned[2]; - GLubyte NumPasses; /**< 1 or 2 */ - GLubyte cur_pass; - GLubyte last_optype; - GLboolean interpinp1; - GLboolean isValid; - GLuint swizzlerq; -}; - -/** - * Context state for GL_ATI_fragment_shader - */ -struct gl_ati_fragment_shader_state -{ - GLboolean Enabled; - GLboolean _Enabled; /**< enabled and valid shader? */ - GLboolean Compiling; - GLfloat GlobalConstants[8][4]; - struct ati_fragment_shader *Current; -}; - - -/** - * Occlusion/timer query object. - */ -struct gl_query_object -{ - GLenum Target; /**< The query target, when active */ - GLuint Id; /**< hash table ID/name */ - GLuint64EXT Result; /**< the counter */ - GLboolean Active; /**< inside Begin/EndQuery */ - GLboolean Ready; /**< result is ready? */ -}; - - -/** - * Context state for query objects. - */ -struct gl_query_state -{ - struct _mesa_HashTable *QueryObjects; - struct gl_query_object *CurrentOcclusionObject; /* GL_ARB_occlusion_query */ - struct gl_query_object *CurrentTimerObject; /* GL_EXT_timer_query */ - - /** GL_NV_conditional_render */ - struct gl_query_object *CondRenderQuery; - - /** GL_EXT_transform_feedback */ - struct gl_query_object *PrimitivesGenerated; - struct gl_query_object *PrimitivesWritten; - - /** GL_ARB_timer_query */ - struct gl_query_object *TimeElapsed; - - GLenum CondRenderMode; -}; - - -/** Sync object state */ -struct gl_sync_object { - struct simple_node link; - GLenum Type; /**< GL_SYNC_FENCE */ - GLuint Name; /**< Fence name */ - GLint RefCount; /**< Reference count */ - GLboolean DeletePending; /**< Object was deleted while there were still - * live references (e.g., sync not yet finished) - */ - GLenum SyncCondition; - GLbitfield Flags; /**< Flags passed to glFenceSync */ - GLuint StatusFlag:1; /**< Has the sync object been signaled? */ -}; - - -/** Set by #pragma directives */ -struct gl_sl_pragmas -{ - GLboolean IgnoreOptimize; /**< ignore #pragma optimize(on/off) ? */ - GLboolean IgnoreDebug; /**< ignore #pragma debug(on/off) ? */ - GLboolean Optimize; /**< defaults on */ - GLboolean Debug; /**< defaults off */ -}; - - -/** - * A GLSL vertex or fragment shader object. - */ -struct gl_shader -{ - GLenum Type; /**< GL_FRAGMENT_SHADER || GL_VERTEX_SHADER || GL_GEOMETRY_SHADER_ARB (first field!) */ - GLuint Name; /**< AKA the handle */ - GLint RefCount; /**< Reference count */ - GLboolean DeletePending; - GLboolean CompileStatus; - const GLchar *Source; /**< Source code string */ - GLuint SourceChecksum; /**< for debug/logging purposes */ - struct gl_program *Program; /**< Post-compile assembly code */ - GLchar *InfoLog; - struct gl_sl_pragmas Pragmas; - - unsigned Version; /**< GLSL version used for linking */ - - struct exec_list *ir; - struct glsl_symbol_table *symbols; - - /** Shaders containing built-in functions that are used for linking. */ - struct gl_shader *builtins_to_link[16]; - unsigned num_builtins_to_link; -}; - - -/** - * A GLSL program object. - * Basically a linked collection of vertex and fragment shaders. - */ -struct gl_shader_program -{ - GLenum Type; /**< Always GL_SHADER_PROGRAM (internal token) */ - GLuint Name; /**< aka handle or ID */ - GLint RefCount; /**< Reference count */ - GLboolean DeletePending; - - GLuint NumShaders; /**< number of attached shaders */ - struct gl_shader **Shaders; /**< List of attached the shaders */ - - /** User-defined attribute bindings (glBindAttribLocation) */ - struct gl_program_parameter_list *Attributes; - - /** Transform feedback varyings */ - struct { - GLenum BufferMode; - GLuint NumVarying; - GLchar **VaryingNames; /**< Array [NumVarying] of char * */ - } TransformFeedback; - - /** Geometry shader state - copied into gl_geometry_program at link time */ - struct { - GLint VerticesOut; - GLenum InputType; /**< GL_POINTS, GL_LINES, GL_LINES_ADJACENCY_ARB, - GL_TRIANGLES, or GL_TRIANGLES_ADJACENCY_ARB */ - GLenum OutputType; /**< GL_POINTS, GL_LINE_STRIP or GL_TRIANGLE_STRIP */ - } Geom; - - /* post-link info: */ - struct gl_vertex_program *VertexProgram; /**< Linked vertex program */ - struct gl_fragment_program *FragmentProgram; /**< Linked fragment prog */ - struct gl_geometry_program *GeometryProgram; /**< Linked geometry prog */ - struct gl_uniform_list *Uniforms; - struct gl_program_parameter_list *Varying; - GLboolean LinkStatus; /**< GL_LINK_STATUS */ - GLboolean Validated; - GLboolean _Used; /**< Ever used for drawing? */ - GLchar *InfoLog; - - unsigned Version; /**< GLSL version used for linking */ - - /** - * Per-stage shaders resulting from the first stage of linking. - * - * Set of linked shaders for this program. The array is accessed using the - * \c MESA_SHADER_* defines. Entries for non-existent stages will be - * \c NULL. - */ - struct gl_shader *_LinkedShaders[MESA_SHADER_TYPES]; -}; - - -#define GLSL_DUMP 0x1 /**< Dump shaders to stdout */ -#define GLSL_LOG 0x2 /**< Write shaders to files */ -#define GLSL_OPT 0x4 /**< Force optimizations (override pragmas) */ -#define GLSL_NO_OPT 0x8 /**< Force no optimizations (override pragmas) */ -#define GLSL_UNIFORMS 0x10 /**< Print glUniform calls */ -#define GLSL_NOP_VERT 0x20 /**< Force no-op vertex shaders */ -#define GLSL_NOP_FRAG 0x40 /**< Force no-op fragment shaders */ -#define GLSL_USE_PROG 0x80 /**< Log glUseProgram calls */ - - -/** - * Context state for GLSL vertex/fragment shaders. - */ -struct gl_shader_state -{ - /** - * Programs used for rendering - * - * There is a separate program set for each shader stage. If - * GL_EXT_separate_shader_objects is not supported, each of these must point - * to \c NULL or to the same program. - */ - struct gl_shader_program *CurrentVertexProgram; - struct gl_shader_program *CurrentGeometryProgram; - struct gl_shader_program *CurrentFragmentProgram; - - /** - * Program used by glUniform calls. - * - * Explicitly set by \c glUseProgram and \c glActiveProgramEXT. - */ - struct gl_shader_program *ActiveProgram; - - GLbitfield Flags; /**< Mask of GLSL_x flags */ -}; - -/** - * Compiler options for a single GLSL shaders type - */ -struct gl_shader_compiler_options -{ - /** Driver-selectable options: */ - GLboolean EmitCondCodes; /**< Use condition codes? */ - GLboolean EmitNVTempInitialization; /**< 0-fill NV temp registers */ - GLboolean EmitNoLoops; - GLboolean EmitNoFunctions; - GLboolean EmitNoCont; /**< Emit CONT opcode? */ - GLboolean EmitNoMainReturn; /**< Emit CONT/RET opcodes? */ - GLboolean EmitNoNoise; /**< Emit NOISE opcodes? */ - GLboolean EmitNoPow; /**< Emit POW opcodes? */ - - /** - * \name Forms of indirect addressing the driver cannot do. - */ - /*@{*/ - GLboolean EmitNoIndirectInput; /**< No indirect addressing of inputs */ - GLboolean EmitNoIndirectOutput; /**< No indirect addressing of outputs */ - GLboolean EmitNoIndirectTemp; /**< No indirect addressing of temps */ - GLboolean EmitNoIndirectUniform; /**< No indirect addressing of constants */ - /*@}*/ - - GLuint MaxIfDepth; /**< Maximum nested IF blocks */ - GLuint MaxUnrollIterations; - - struct gl_sl_pragmas DefaultPragmas; /**< Default #pragma settings */ -}; - -/** - * Transform feedback object state - */ -struct gl_transform_feedback_object -{ - GLuint Name; /**< AKA the object ID */ - GLint RefCount; - GLboolean Active; /**< Is transform feedback enabled? */ - GLboolean Paused; /**< Is transform feedback paused? */ - - /** The feedback buffers */ - GLuint BufferNames[MAX_FEEDBACK_ATTRIBS]; - struct gl_buffer_object *Buffers[MAX_FEEDBACK_ATTRIBS]; - - /** Start of feedback data in dest buffer */ - GLintptr Offset[MAX_FEEDBACK_ATTRIBS]; - /** Max data to put into dest buffer (in bytes) */ - GLsizeiptr Size[MAX_FEEDBACK_ATTRIBS]; -}; - - -/** - * Context state for transform feedback. - */ -struct gl_transform_feedback -{ - GLenum Mode; /**< GL_POINTS, GL_LINES or GL_TRIANGLES */ - - GLboolean RasterDiscard; /**< GL_RASTERIZER_DISCARD */ - - /** The general binding point (GL_TRANSFORM_FEEDBACK_BUFFER) */ - struct gl_buffer_object *CurrentBuffer; - - /** The table of all transform feedback objects */ - struct _mesa_HashTable *Objects; - - /** The current xform-fb object (GL_TRANSFORM_FEEDBACK_BINDING) */ - struct gl_transform_feedback_object *CurrentObject; - - /** The default xform-fb object (Name==0) */ - struct gl_transform_feedback_object *DefaultObject; -}; - - - -/** - * State which can be shared by multiple contexts: - */ -struct gl_shared_state -{ - _glthread_Mutex Mutex; /**< for thread safety */ - GLint RefCount; /**< Reference count */ - struct _mesa_HashTable *DisplayList; /**< Display lists hash table */ - struct _mesa_HashTable *TexObjects; /**< Texture objects hash table */ - - /** Default texture objects (shared by all texture units) */ - struct gl_texture_object *DefaultTex[NUM_TEXTURE_TARGETS]; - - /** Fallback texture used when a bound texture is incomplete */ - struct gl_texture_object *FallbackTex; - - /** - * \name Thread safety and statechange notification for texture - * objects. - * - * \todo Improve the granularity of locking. - */ - /*@{*/ - _glthread_Mutex TexMutex; /**< texobj thread safety */ - GLuint TextureStateStamp; /**< state notification for shared tex */ - /*@}*/ - - /** Default buffer object for vertex arrays that aren't in VBOs */ - struct gl_buffer_object *NullBufferObj; - - /** - * \name Vertex/geometry/fragment programs - */ - /*@{*/ - struct _mesa_HashTable *Programs; /**< All vertex/fragment programs */ - struct gl_vertex_program *DefaultVertexProgram; - struct gl_fragment_program *DefaultFragmentProgram; - struct gl_geometry_program *DefaultGeometryProgram; - /*@}*/ - - /* GL_ATI_fragment_shader */ - struct _mesa_HashTable *ATIShaders; - struct ati_fragment_shader *DefaultFragmentShader; - - struct _mesa_HashTable *BufferObjects; - - /** Table of both gl_shader and gl_shader_program objects */ - struct _mesa_HashTable *ShaderObjects; - - /* GL_EXT_framebuffer_object */ - struct _mesa_HashTable *RenderBuffers; - struct _mesa_HashTable *FrameBuffers; - - /* GL_ARB_sync */ - struct simple_node SyncObjects; - - /** GL_ARB_sampler_objects */ - struct _mesa_HashTable *SamplerObjects; - - void *DriverData; /**< Device driver shared state */ -}; - - - - -/** - * A renderbuffer stores colors or depth values or stencil values. - * A framebuffer object will have a collection of these. - * Data are read/written to the buffer with a handful of Get/Put functions. - * - * Instances of this object are allocated with the Driver's NewRenderbuffer - * hook. Drivers will likely wrap this class inside a driver-specific - * class to simulate inheritance. - */ -struct gl_renderbuffer -{ - _glthread_Mutex Mutex; /**< for thread safety */ - GLuint ClassID; /**< Useful for drivers */ - GLuint Name; - GLint RefCount; - GLuint Width, Height; - GLint RowStride; /**< Padded width in units of pixels */ - GLboolean Purgeable; /**< Is the buffer purgeable under memory pressure? */ - - GLboolean AttachedAnytime; /**< TRUE if it was attached to a framebuffer */ - - GLubyte NumSamples; - - GLenum InternalFormat; /**< The user-specified format */ - GLenum _BaseFormat; /**< Either GL_RGB, GL_RGBA, GL_DEPTH_COMPONENT or - GL_STENCIL_INDEX. */ - gl_format Format; /**< The actual renderbuffer memory format */ - - GLenum DataType; /**< Type of values passed to the Get/Put functions */ - GLvoid *Data; /**< This may not be used by some kinds of RBs */ - - /* Used to wrap one renderbuffer around another: */ - struct gl_renderbuffer *Wrapped; - - /* Delete this renderbuffer */ - void (*Delete)(struct gl_renderbuffer *rb); - - /* Allocate new storage for this renderbuffer */ - GLboolean (*AllocStorage)(struct gl_context *ctx, struct gl_renderbuffer *rb, - GLenum internalFormat, - GLuint width, GLuint height); - - /* Lock/Unlock are called before/after calling the Get/Put functions. - * Not sure this is the right place for these yet. - void (*Lock)(struct gl_context *ctx, struct gl_renderbuffer *rb); - void (*Unlock)(struct gl_context *ctx, struct gl_renderbuffer *rb); - */ - - /* Return a pointer to the element/pixel at (x,y). - * Should return NULL if the buffer memory can't be directly addressed. - */ - void *(*GetPointer)(struct gl_context *ctx, struct gl_renderbuffer *rb, - GLint x, GLint y); - - /* Get/Read a row of values. - * The values will be of format _BaseFormat and type DataType. - */ - void (*GetRow)(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, void *values); - - /* Get/Read values at arbitrary locations. - * The values will be of format _BaseFormat and type DataType. - */ - void (*GetValues)(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - const GLint x[], const GLint y[], void *values); - - /* Put/Write a row of values. - * The values will be of format _BaseFormat and type DataType. - */ - void (*PutRow)(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, const void *values, const GLubyte *mask); - - /* Put/Write a row of RGB values. This is a special-case routine that's - * only used for RGBA renderbuffers when the source data is GL_RGB. That's - * a common case for glDrawPixels and some triangle routines. - * The values will be of format GL_RGB and type DataType. - */ - void (*PutRowRGB)(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, const void *values, const GLubyte *mask); - - - /* Put/Write a row of identical values. - * The values will be of format _BaseFormat and type DataType. - */ - void (*PutMonoRow)(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, const void *value, const GLubyte *mask); - - /* Put/Write values at arbitrary locations. - * The values will be of format _BaseFormat and type DataType. - */ - void (*PutValues)(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - const GLint x[], const GLint y[], const void *values, - const GLubyte *mask); - /* Put/Write identical values at arbitrary locations. - * The values will be of format _BaseFormat and type DataType. - */ - void (*PutMonoValues)(struct gl_context *ctx, struct gl_renderbuffer *rb, - GLuint count, const GLint x[], const GLint y[], - const void *value, const GLubyte *mask); -}; - - -/** - * A renderbuffer attachment points to either a texture object (and specifies - * a mipmap level, cube face or 3D texture slice) or points to a renderbuffer. - */ -struct gl_renderbuffer_attachment -{ - GLenum Type; /**< \c GL_NONE or \c GL_TEXTURE or \c GL_RENDERBUFFER_EXT */ - GLboolean Complete; - - /** - * If \c Type is \c GL_RENDERBUFFER_EXT, this stores a pointer to the - * application supplied renderbuffer object. - */ - struct gl_renderbuffer *Renderbuffer; - - /** - * If \c Type is \c GL_TEXTURE, this stores a pointer to the application - * supplied texture object. - */ - struct gl_texture_object *Texture; - GLuint TextureLevel; /**< Attached mipmap level. */ - GLuint CubeMapFace; /**< 0 .. 5, for cube map textures. */ - GLuint Zoffset; /**< Slice for 3D textures, or layer for both 1D - * and 2D array textures */ -}; - - -/** - * A framebuffer is a collection of renderbuffers (color, depth, stencil, etc). - * In C++ terms, think of this as a base class from which device drivers - * will make derived classes. - */ -struct gl_framebuffer -{ - _glthread_Mutex Mutex; /**< for thread safety */ - /** - * If zero, this is a window system framebuffer. If non-zero, this - * is a FBO framebuffer; note that for some devices (i.e. those with - * a natural pixel coordinate system for FBOs that differs from the - * OpenGL/Mesa coordinate system), this means that the viewport, - * polygon face orientation, and polygon stipple will have to be inverted. - */ - GLuint Name; - - GLint RefCount; - GLboolean DeletePending; - - /** - * The framebuffer's visual. Immutable if this is a window system buffer. - * Computed from attachments if user-made FBO. - */ - struct gl_config Visual; - - GLboolean Initialized; - - GLuint Width, Height; /**< size of frame buffer in pixels */ - - /** \name Drawing bounds (Intersection of buffer size and scissor box) */ - /*@{*/ - GLint _Xmin, _Xmax; /**< inclusive */ - GLint _Ymin, _Ymax; /**< exclusive */ - /*@}*/ - - /** \name Derived Z buffer stuff */ - /*@{*/ - GLuint _DepthMax; /**< Max depth buffer value */ - GLfloat _DepthMaxF; /**< Float max depth buffer value */ - GLfloat _MRD; /**< minimum resolvable difference in Z values */ - /*@}*/ - - /** One of the GL_FRAMEBUFFER_(IN)COMPLETE_* tokens */ - GLenum _Status; - - /** Integer color values */ - GLboolean _IntegerColor; - - /** Array of all renderbuffer attachments, indexed by BUFFER_* tokens. */ - struct gl_renderbuffer_attachment Attachment[BUFFER_COUNT]; - - /* In unextended OpenGL these vars are part of the GL_COLOR_BUFFER - * attribute group and GL_PIXEL attribute group, respectively. - */ - GLenum ColorDrawBuffer[MAX_DRAW_BUFFERS]; - GLenum ColorReadBuffer; - - /** Computed from ColorDraw/ReadBuffer above */ - GLuint _NumColorDrawBuffers; - GLint _ColorDrawBufferIndexes[MAX_DRAW_BUFFERS]; /**< BUFFER_x or -1 */ - GLint _ColorReadBufferIndex; /* -1 = None */ - struct gl_renderbuffer *_ColorDrawBuffers[MAX_DRAW_BUFFERS]; - struct gl_renderbuffer *_ColorReadBuffer; - - /** The Actual depth/stencil buffers to use. May be wrappers around the - * depth/stencil buffers attached above. */ - struct gl_renderbuffer *_DepthBuffer; - struct gl_renderbuffer *_StencilBuffer; - - /** Delete this framebuffer */ - void (*Delete)(struct gl_framebuffer *fb); -}; - - -/** - * Precision info for shader datatypes. See glGetShaderPrecisionFormat(). - */ -struct gl_precision -{ - GLushort RangeMin; /**< min value exponent */ - GLushort RangeMax; /**< max value exponent */ - GLushort Precision; /**< number of mantissa bits */ -}; - - -/** - * Limits for vertex, geometry and fragment programs/shaders. - */ -struct gl_program_constants -{ - /* logical limits */ - GLuint MaxInstructions; - GLuint MaxAluInstructions; - GLuint MaxTexInstructions; - GLuint MaxTexIndirections; - GLuint MaxAttribs; - GLuint MaxTemps; - GLuint MaxAddressRegs; - GLuint MaxAddressOffset; /**< [-MaxAddressOffset, MaxAddressOffset-1] */ - GLuint MaxParameters; - GLuint MaxLocalParams; - GLuint MaxEnvParams; - /* native/hardware limits */ - GLuint MaxNativeInstructions; - GLuint MaxNativeAluInstructions; - GLuint MaxNativeTexInstructions; - GLuint MaxNativeTexIndirections; - GLuint MaxNativeAttribs; - GLuint MaxNativeTemps; - GLuint MaxNativeAddressRegs; - GLuint MaxNativeParameters; - /* For shaders */ - GLuint MaxUniformComponents; /**< Usually == MaxParameters * 4 */ - /* ES 2.0 and GL_ARB_ES2_compatibility */ - struct gl_precision LowFloat, MediumFloat, HighFloat; - struct gl_precision LowInt, MediumInt, HighInt; -}; - - -/** - * Constants which may be overridden by device driver during context creation - * but are never changed after that. - */ -struct gl_constants -{ - GLint MaxTextureMbytes; /**< Max memory per image, in MB */ - GLint MaxTextureLevels; /**< Max mipmap levels. */ - GLint Max3DTextureLevels; /**< Max mipmap levels for 3D textures */ - GLint MaxCubeTextureLevels; /**< Max mipmap levels for cube textures */ - GLint MaxArrayTextureLayers; /**< Max layers in array textures */ - GLint MaxTextureRectSize; /**< Max rectangle texture size, in pixes */ - GLuint MaxTextureCoordUnits; - GLuint MaxTextureImageUnits; - GLuint MaxVertexTextureImageUnits; - GLuint MaxCombinedTextureImageUnits; - GLuint MaxGeometryTextureImageUnits; - GLuint MaxTextureUnits; /**< = MIN(CoordUnits, ImageUnits) */ - GLfloat MaxTextureMaxAnisotropy; /**< GL_EXT_texture_filter_anisotropic */ - GLfloat MaxTextureLodBias; /**< GL_EXT_texture_lod_bias */ - GLuint MaxTextureBufferSize; /**< GL_ARB_texture_buffer_object */ - - GLuint MaxArrayLockSize; - - GLint SubPixelBits; - - GLfloat MinPointSize, MaxPointSize; /**< aliased */ - GLfloat MinPointSizeAA, MaxPointSizeAA; /**< antialiased */ - GLfloat PointSizeGranularity; - GLfloat MinLineWidth, MaxLineWidth; /**< aliased */ - GLfloat MinLineWidthAA, MaxLineWidthAA; /**< antialiased */ - GLfloat LineWidthGranularity; - - GLuint MaxColorTableSize; - - GLuint MaxClipPlanes; - GLuint MaxLights; - GLfloat MaxShininess; /**< GL_NV_light_max_exponent */ - GLfloat MaxSpotExponent; /**< GL_NV_light_max_exponent */ - - GLuint MaxViewportWidth, MaxViewportHeight; - - struct gl_program_constants VertexProgram; /**< GL_ARB_vertex_program */ - struct gl_program_constants FragmentProgram; /**< GL_ARB_fragment_program */ - struct gl_program_constants GeometryProgram; /**< GL_ARB_geometry_shader4 */ - GLuint MaxProgramMatrices; - GLuint MaxProgramMatrixStackDepth; - - /** vertex array / buffer object bounds checking */ - GLboolean CheckArrayBounds; - - GLuint MaxDrawBuffers; /**< GL_ARB_draw_buffers */ - - GLuint MaxColorAttachments; /**< GL_EXT_framebuffer_object */ - GLuint MaxRenderbufferSize; /**< GL_EXT_framebuffer_object */ - GLuint MaxSamples; /**< GL_ARB_framebuffer_object */ - - /** Number of varying vectors between vertex and fragment shaders */ - GLuint MaxVarying; - GLuint MaxVertexVaryingComponents; /**< Between vert and geom shader */ - GLuint MaxGeometryVaryingComponents; /**< Between geom and frag shader */ - - /** GL_ARB_geometry_shader4 */ - GLuint MaxGeometryOutputVertices; - GLuint MaxGeometryTotalOutputComponents; - - GLuint GLSLVersion; /**< GLSL version supported (ex: 120 = 1.20) */ - - /** - * Does the driver support real 32-bit integers? (Otherwise, integers are - * simulated via floats.) - */ - GLboolean NativeIntegers; - - /** - * If the driver supports real 32-bit integers, what integer value should be - * used for boolean true in uniform uploads? (Usually 1 or ~0.) - */ - GLuint UniformBooleanTrue; - - /** Which texture units support GL_ATI_envmap_bumpmap as targets */ - GLbitfield SupportedBumpUnits; - - /** - * Maximum amount of time, measured in nanseconds, that the server can wait. - */ - GLuint64 MaxServerWaitTimeout; - - /** GL_EXT_provoking_vertex */ - GLboolean QuadsFollowProvokingVertexConvention; - - /** OpenGL version 3.0 */ - GLbitfield ContextFlags; /**< Ex: GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT */ - - /** OpenGL version 3.2 */ - GLbitfield ProfileMask; /**< Mask of CONTEXT_x_PROFILE_BIT */ - - /** GL_EXT_transform_feedback */ - GLuint MaxTransformFeedbackSeparateAttribs; - GLuint MaxTransformFeedbackSeparateComponents; - GLuint MaxTransformFeedbackInterleavedComponents; - - /** GL_EXT_gpu_shader4 */ - GLint MinProgramTexelOffset, MaxProgramTexelOffset; - - /* GL_EXT_framebuffer_sRGB */ - GLboolean sRGBCapable; /* can enable sRGB blend/update on FBOs */ - - /* GL_ARB_robustness */ - GLenum ResetStrategy; -}; - - -/** - * Enable flag for each OpenGL extension. Different device drivers will - * enable different extensions at runtime. - */ -struct gl_extensions -{ - GLboolean dummy; /* don't remove this! */ - GLboolean dummy_true; /* Set true by _mesa_init_extensions(). */ - GLboolean dummy_false; /* Set false by _mesa_init_extensions(). */ - GLboolean ARB_ES2_compatibility; - GLboolean ARB_blend_func_extended; - GLboolean ARB_color_buffer_float; - GLboolean ARB_copy_buffer; - GLboolean ARB_depth_buffer_float; - GLboolean ARB_depth_clamp; - GLboolean ARB_depth_texture; - GLboolean ARB_draw_buffers; - GLboolean ARB_draw_buffers_blend; - GLboolean ARB_draw_elements_base_vertex; - GLboolean ARB_draw_instanced; - GLboolean ARB_fragment_coord_conventions; - GLboolean ARB_fragment_program; - GLboolean ARB_fragment_program_shadow; - GLboolean ARB_fragment_shader; - GLboolean ARB_framebuffer_object; - GLboolean ARB_explicit_attrib_location; - GLboolean ARB_geometry_shader4; - GLboolean ARB_half_float_pixel; - GLboolean ARB_half_float_vertex; - GLboolean ARB_instanced_arrays; - GLboolean ARB_map_buffer_range; - GLboolean ARB_multisample; - GLboolean ARB_multitexture; - GLboolean ARB_occlusion_query; - GLboolean ARB_occlusion_query2; - GLboolean ARB_point_sprite; - GLboolean ARB_sampler_objects; - GLboolean ARB_seamless_cube_map; - GLboolean ARB_shader_objects; - GLboolean ARB_shader_stencil_export; - GLboolean ARB_shader_texture_lod; - GLboolean ARB_shading_language_100; - GLboolean ARB_shadow; - GLboolean ARB_shadow_ambient; - GLboolean ARB_sync; - GLboolean ARB_texture_border_clamp; - GLboolean ARB_texture_buffer_object; - GLboolean ARB_texture_compression; - GLboolean ARB_texture_compression_rgtc; - GLboolean ARB_texture_cube_map; - GLboolean ARB_texture_env_combine; - GLboolean ARB_texture_env_crossbar; - GLboolean ARB_texture_env_dot3; - GLboolean ARB_texture_float; - GLboolean ARB_texture_mirrored_repeat; - GLboolean ARB_texture_multisample; - GLboolean ARB_texture_non_power_of_two; - GLboolean ARB_texture_rg; - GLboolean ARB_texture_rgb10_a2ui; - GLboolean ARB_timer_query; - GLboolean ARB_transform_feedback2; - GLboolean ARB_transpose_matrix; - GLboolean ARB_uniform_buffer_object; - GLboolean ARB_vertex_array_object; - GLboolean ARB_vertex_buffer_object; - GLboolean ARB_vertex_program; - GLboolean ARB_vertex_shader; - GLboolean ARB_vertex_type_2_10_10_10_rev; - GLboolean ARB_window_pos; - GLboolean EXT_abgr; - GLboolean EXT_bgra; - GLboolean EXT_blend_color; - GLboolean EXT_blend_equation_separate; - GLboolean EXT_blend_func_separate; - GLboolean EXT_blend_logic_op; - GLboolean EXT_blend_minmax; - GLboolean EXT_blend_subtract; - GLboolean EXT_clip_volume_hint; - GLboolean EXT_compiled_vertex_array; - GLboolean EXT_copy_texture; - GLboolean EXT_depth_bounds_test; - GLboolean EXT_draw_buffers2; - GLboolean EXT_draw_range_elements; - GLboolean EXT_fog_coord; - GLboolean EXT_framebuffer_blit; - GLboolean EXT_framebuffer_multisample; - GLboolean EXT_framebuffer_object; - GLboolean EXT_framebuffer_sRGB; - GLboolean EXT_gpu_program_parameters; - GLboolean EXT_gpu_shader4; - GLboolean EXT_multi_draw_arrays; - GLboolean EXT_packed_depth_stencil; - GLboolean EXT_packed_float; - GLboolean EXT_packed_pixels; - GLboolean EXT_pixel_buffer_object; - GLboolean EXT_point_parameters; - GLboolean EXT_polygon_offset; - GLboolean EXT_provoking_vertex; - GLboolean EXT_rescale_normal; - GLboolean EXT_shadow_funcs; - GLboolean EXT_secondary_color; - GLboolean EXT_separate_shader_objects; - GLboolean EXT_separate_specular_color; - GLboolean EXT_stencil_wrap; - GLboolean EXT_stencil_two_side; - GLboolean EXT_subtexture; - GLboolean EXT_texture; - GLboolean EXT_texture_object; - GLboolean EXT_texture3D; - GLboolean EXT_texture_array; - GLboolean EXT_texture_compression_latc; - GLboolean EXT_texture_compression_s3tc; - GLboolean EXT_texture_env_add; - GLboolean EXT_texture_env_combine; - GLboolean EXT_texture_env_dot3; - GLboolean EXT_texture_filter_anisotropic; - GLboolean EXT_texture_integer; - GLboolean EXT_texture_lod_bias; - GLboolean EXT_texture_mirror_clamp; - GLboolean EXT_texture_shared_exponent; - GLboolean EXT_texture_snorm; - GLboolean EXT_texture_sRGB; - GLboolean EXT_texture_sRGB_decode; - GLboolean EXT_texture_swizzle; - GLboolean EXT_transform_feedback; - GLboolean EXT_timer_query; - GLboolean EXT_vertex_array; - GLboolean EXT_vertex_array_bgra; - GLboolean EXT_vertex_array_set; - GLboolean OES_standard_derivatives; - /* vendor extensions */ - GLboolean AMD_conservative_depth; - GLboolean AMD_seamless_cubemap_per_texture; - GLboolean APPLE_client_storage; - GLboolean APPLE_packed_pixels; - GLboolean APPLE_vertex_array_object; - GLboolean APPLE_object_purgeable; - GLboolean ATI_envmap_bumpmap; - GLboolean ATI_texture_compression_3dc; - GLboolean ATI_texture_mirror_once; - GLboolean ATI_texture_env_combine3; - GLboolean ATI_fragment_shader; - GLboolean ATI_separate_stencil; - GLboolean IBM_rasterpos_clip; - GLboolean IBM_multimode_draw_arrays; - GLboolean MESA_pack_invert; - GLboolean MESA_resize_buffers; - GLboolean MESA_ycbcr_texture; - GLboolean MESA_texture_array; - GLboolean NV_blend_square; - GLboolean NV_conditional_render; - GLboolean NV_fragment_program; - GLboolean NV_fragment_program_option; - GLboolean NV_light_max_exponent; - GLboolean NV_point_sprite; - GLboolean NV_primitive_restart; - GLboolean NV_texture_barrier; - GLboolean NV_texgen_reflection; - GLboolean NV_texture_env_combine4; - GLboolean NV_texture_rectangle; - GLboolean NV_vertex_program; - GLboolean NV_vertex_program1_1; - GLboolean OES_read_format; - GLboolean SGIS_generate_mipmap; - GLboolean SGIS_texture_edge_clamp; - GLboolean SGIS_texture_lod; - GLboolean TDFX_texture_compression_FXT1; - GLboolean S3_s3tc; - GLboolean OES_EGL_image; - GLboolean OES_draw_texture; - GLboolean EXT_texture_format_BGRA8888; - GLboolean extension_sentinel; - /** The extension string */ - const GLubyte *String; - /** Number of supported extensions */ - GLuint Count; -}; - - -/** - * A stack of matrices (projection, modelview, color, texture, etc). - */ -struct gl_matrix_stack -{ - GLmatrix *Top; /**< points into Stack */ - GLmatrix *Stack; /**< array [MaxDepth] of GLmatrix */ - GLuint Depth; /**< 0 <= Depth < MaxDepth */ - GLuint MaxDepth; /**< size of Stack[] array */ - GLuint DirtyFlag; /**< _NEW_MODELVIEW or _NEW_PROJECTION, for example */ -}; - - -/** - * \name Bits for image transfer operations - * \sa __struct gl_contextRec::ImageTransferState. - */ -/*@{*/ -#define IMAGE_SCALE_BIAS_BIT 0x1 -#define IMAGE_SHIFT_OFFSET_BIT 0x2 -#define IMAGE_MAP_COLOR_BIT 0x4 -#define IMAGE_CLAMP_BIT 0x800 - - -/** Pixel Transfer ops */ -#define IMAGE_BITS (IMAGE_SCALE_BIAS_BIT | \ - IMAGE_SHIFT_OFFSET_BIT | \ - IMAGE_MAP_COLOR_BIT) - -/** - * \name Bits to indicate what state has changed. - */ -/*@{*/ -#define _NEW_MODELVIEW (1 << 0) /**< gl_context::ModelView */ -#define _NEW_PROJECTION (1 << 1) /**< gl_context::Projection */ -#define _NEW_TEXTURE_MATRIX (1 << 2) /**< gl_context::TextureMatrix */ -#define _NEW_COLOR (1 << 3) /**< gl_context::Color */ -#define _NEW_DEPTH (1 << 4) /**< gl_context::Depth */ -#define _NEW_EVAL (1 << 5) /**< gl_context::Eval, EvalMap */ -#define _NEW_FOG (1 << 6) /**< gl_context::Fog */ -#define _NEW_HINT (1 << 7) /**< gl_context::Hint */ -#define _NEW_LIGHT (1 << 8) /**< gl_context::Light */ -#define _NEW_LINE (1 << 9) /**< gl_context::Line */ -#define _NEW_PIXEL (1 << 10) /**< gl_context::Pixel */ -#define _NEW_POINT (1 << 11) /**< gl_context::Point */ -#define _NEW_POLYGON (1 << 12) /**< gl_context::Polygon */ -#define _NEW_POLYGONSTIPPLE (1 << 13) /**< gl_context::PolygonStipple */ -#define _NEW_SCISSOR (1 << 14) /**< gl_context::Scissor */ -#define _NEW_STENCIL (1 << 15) /**< gl_context::Stencil */ -#define _NEW_TEXTURE (1 << 16) /**< gl_context::Texture */ -#define _NEW_TRANSFORM (1 << 17) /**< gl_context::Transform */ -#define _NEW_VIEWPORT (1 << 18) /**< gl_context::Viewport */ -#define _NEW_PACKUNPACK (1 << 19) /**< gl_context::Pack, Unpack */ -#define _NEW_ARRAY (1 << 20) /**< gl_context::Array */ -#define _NEW_RENDERMODE (1 << 21) /**< gl_context::RenderMode, etc */ -#define _NEW_BUFFERS (1 << 22) /**< gl_context::Visual, DrawBuffer, */ -#define _NEW_CURRENT_ATTRIB (1 << 23) /**< gl_context::Current */ -#define _NEW_MULTISAMPLE (1 << 24) /**< gl_context::Multisample */ -#define _NEW_TRACK_MATRIX (1 << 25) /**< gl_context::VertexProgram */ -#define _NEW_PROGRAM (1 << 26) /**< New program/shader state */ -#define _NEW_PROGRAM_CONSTANTS (1 << 27) -#define _NEW_BUFFER_OBJECT (1 << 28) -#define _NEW_FRAG_CLAMP (1 << 29) -#define _NEW_ALL ~0 -/*@}*/ - - -/** - * \name Bits to track array state changes - * - * Also used to summarize array enabled. - */ -/*@{*/ -#define _NEW_ARRAY_VERTEX VERT_BIT_POS -#define _NEW_ARRAY_WEIGHT VERT_BIT_WEIGHT -#define _NEW_ARRAY_NORMAL VERT_BIT_NORMAL -#define _NEW_ARRAY_COLOR0 VERT_BIT_COLOR0 -#define _NEW_ARRAY_COLOR1 VERT_BIT_COLOR1 -#define _NEW_ARRAY_FOGCOORD VERT_BIT_FOG -#define _NEW_ARRAY_INDEX VERT_BIT_COLOR_INDEX -#define _NEW_ARRAY_EDGEFLAG VERT_BIT_EDGEFLAG -#define _NEW_ARRAY_POINT_SIZE VERT_BIT_COLOR_INDEX /* aliased */ -#define _NEW_ARRAY_TEXCOORD_0 VERT_BIT_TEX0 -#define _NEW_ARRAY_TEXCOORD_1 VERT_BIT_TEX1 -#define _NEW_ARRAY_TEXCOORD_2 VERT_BIT_TEX2 -#define _NEW_ARRAY_TEXCOORD_3 VERT_BIT_TEX3 -#define _NEW_ARRAY_TEXCOORD_4 VERT_BIT_TEX4 -#define _NEW_ARRAY_TEXCOORD_5 VERT_BIT_TEX5 -#define _NEW_ARRAY_TEXCOORD_6 VERT_BIT_TEX6 -#define _NEW_ARRAY_TEXCOORD_7 VERT_BIT_TEX7 -#define _NEW_ARRAY_ATTRIB_0 VERT_BIT_GENERIC0 /* start at bit 16 */ -#define _NEW_ARRAY_ALL 0xffffffff - - -#define _NEW_ARRAY_TEXCOORD(i) (_NEW_ARRAY_TEXCOORD_0 << (i)) -#define _NEW_ARRAY_ATTRIB(i) (_NEW_ARRAY_ATTRIB_0 << (i)) -/*@}*/ - - - -/** - * \name A bunch of flags that we think might be useful to drivers. - * - * Set in the __struct gl_contextRec::_TriangleCaps bitfield. - */ -/*@{*/ -#define DD_FLATSHADE 0x1 -#define DD_SEPARATE_SPECULAR 0x2 -#define DD_TRI_CULL_FRONT_BACK 0x4 /* special case on some hw */ -#define DD_TRI_LIGHT_TWOSIDE 0x8 -#define DD_TRI_UNFILLED 0x10 -#define DD_TRI_SMOOTH 0x20 -#define DD_TRI_STIPPLE 0x40 -#define DD_TRI_OFFSET 0x80 -#define DD_LINE_SMOOTH 0x100 -#define DD_LINE_STIPPLE 0x200 -#define DD_POINT_SMOOTH 0x400 -#define DD_POINT_ATTEN 0x800 -#define DD_TRI_TWOSTENCIL 0x1000 -/*@}*/ - - -/** - * \name Define the state changes under which each of these bits might change - */ -/*@{*/ -#define _DD_NEW_FLATSHADE _NEW_LIGHT -#define _DD_NEW_SEPARATE_SPECULAR (_NEW_LIGHT | _NEW_FOG | _NEW_PROGRAM) -#define _DD_NEW_TRI_CULL_FRONT_BACK _NEW_POLYGON -#define _DD_NEW_TRI_LIGHT_TWOSIDE _NEW_LIGHT -#define _DD_NEW_TRI_UNFILLED _NEW_POLYGON -#define _DD_NEW_TRI_SMOOTH _NEW_POLYGON -#define _DD_NEW_TRI_STIPPLE _NEW_POLYGON -#define _DD_NEW_TRI_OFFSET _NEW_POLYGON -#define _DD_NEW_LINE_SMOOTH _NEW_LINE -#define _DD_NEW_LINE_STIPPLE _NEW_LINE -#define _DD_NEW_LINE_WIDTH _NEW_LINE -#define _DD_NEW_POINT_SMOOTH _NEW_POINT -#define _DD_NEW_POINT_SIZE _NEW_POINT -#define _DD_NEW_POINT_ATTEN _NEW_POINT -/*@}*/ - - -/** - * Composite state flags - */ -/*@{*/ -#define _MESA_NEW_NEED_EYE_COORDS (_NEW_LIGHT | \ - _NEW_TEXTURE | \ - _NEW_POINT | \ - _NEW_PROGRAM | \ - _NEW_MODELVIEW) -/*@}*/ - - - - -/* This has to be included here. */ -#include "dd.h" - - -/** - * Display list flags. - * Strictly this is a tnl-private concept, but it doesn't seem - * worthwhile adding a tnl private structure just to hold this one bit - * of information: - */ -#define DLIST_DANGLING_REFS 0x1 - - -/** Opaque declaration of display list payload data type */ -union gl_dlist_node; - - -/** - * Provide a location where information about a display list can be - * collected. Could be extended with driverPrivate structures, - * etc. in the future. - */ -struct gl_display_list -{ - GLuint Name; - GLbitfield Flags; /**< DLIST_x flags */ - /** The dlist commands are in a linked list of nodes */ - union gl_dlist_node *Head; -}; - - -/** - * State used during display list compilation and execution. - */ -struct gl_dlist_state -{ - GLuint CallDepth; /**< Current recursion calling depth */ - - struct gl_display_list *CurrentList; /**< List currently being compiled */ - union gl_dlist_node *CurrentBlock; /**< Pointer to current block of nodes */ - GLuint CurrentPos; /**< Index into current block of nodes */ - - GLvertexformat ListVtxfmt; - - GLubyte ActiveAttribSize[VERT_ATTRIB_MAX]; - GLfloat CurrentAttrib[VERT_ATTRIB_MAX][4]; - - GLubyte ActiveMaterialSize[MAT_ATTRIB_MAX]; - GLfloat CurrentMaterial[MAT_ATTRIB_MAX][4]; - - GLubyte ActiveIndex; - GLfloat CurrentIndex; - - GLubyte ActiveEdgeFlag; - GLboolean CurrentEdgeFlag; - - struct { - /* State known to have been set by the currently-compiling display - * list. Used to eliminate some redundant state changes. - */ - GLenum ShadeModel; - } Current; -}; - - -/** - * Enum for the OpenGL APIs we know about and may support. - */ -typedef enum -{ - API_OPENGL, - API_OPENGLES, - API_OPENGLES2 -} gl_api; - - -/** - * Mesa rendering context. - * - * This is the central context data structure for Mesa. Almost all - * OpenGL state is contained in this structure. - * Think of this as a base class from which device drivers will derive - * sub classes. - * - * The struct gl_context typedef names this structure. - */ -struct gl_context -{ - /** State possibly shared with other contexts in the address space */ - struct gl_shared_state *Shared; - - /** \name API function pointer tables */ - /*@{*/ - gl_api API; - struct _glapi_table *Save; /**< Display list save functions */ - struct _glapi_table *Exec; /**< Execute functions */ - struct _glapi_table *CurrentDispatch; /**< == Save or Exec !! */ - /*@}*/ - - struct gl_config Visual; - struct gl_framebuffer *DrawBuffer; /**< buffer for writing */ - struct gl_framebuffer *ReadBuffer; /**< buffer for reading */ - struct gl_framebuffer *WinSysDrawBuffer; /**< set with MakeCurrent */ - struct gl_framebuffer *WinSysReadBuffer; /**< set with MakeCurrent */ - - /** - * Device driver function pointer table - */ - struct dd_function_table Driver; - - void *DriverCtx; /**< Points to device driver context/state */ - - /** Core/Driver constants */ - struct gl_constants Const; - - /** \name The various 4x4 matrix stacks */ - /*@{*/ - struct gl_matrix_stack ModelviewMatrixStack; - struct gl_matrix_stack ProjectionMatrixStack; - struct gl_matrix_stack TextureMatrixStack[MAX_TEXTURE_UNITS]; - struct gl_matrix_stack ProgramMatrixStack[MAX_PROGRAM_MATRICES]; - struct gl_matrix_stack *CurrentStack; /**< Points to one of the above stacks */ - /*@}*/ - - /** Combined modelview and projection matrix */ - GLmatrix _ModelProjectMatrix; - - /** \name Display lists */ - struct gl_dlist_state ListState; - - GLboolean ExecuteFlag; /**< Execute GL commands? */ - GLboolean CompileFlag; /**< Compile GL commands into display list? */ - - /** Extension information */ - struct gl_extensions Extensions; - - /** Version info */ - GLuint VersionMajor, VersionMinor; - char *VersionString; - - /** \name State attribute stack (for glPush/PopAttrib) */ - /*@{*/ - GLuint AttribStackDepth; - struct gl_attrib_node *AttribStack[MAX_ATTRIB_STACK_DEPTH]; - /*@}*/ - - /** \name Renderer attribute groups - * - * We define a struct for each attribute group to make pushing and popping - * attributes easy. Also it's a good organization. - */ - /*@{*/ - struct gl_accum_attrib Accum; /**< Accum buffer attributes */ - struct gl_colorbuffer_attrib Color; /**< Color buffer attributes */ - struct gl_current_attrib Current; /**< Current attributes */ - struct gl_depthbuffer_attrib Depth; /**< Depth buffer attributes */ - struct gl_eval_attrib Eval; /**< Eval attributes */ - struct gl_fog_attrib Fog; /**< Fog attributes */ - struct gl_hint_attrib Hint; /**< Hint attributes */ - struct gl_light_attrib Light; /**< Light attributes */ - struct gl_line_attrib Line; /**< Line attributes */ - struct gl_list_attrib List; /**< List attributes */ - struct gl_multisample_attrib Multisample; - struct gl_pixel_attrib Pixel; /**< Pixel attributes */ - struct gl_point_attrib Point; /**< Point attributes */ - struct gl_polygon_attrib Polygon; /**< Polygon attributes */ - GLuint PolygonStipple[32]; /**< Polygon stipple */ - struct gl_scissor_attrib Scissor; /**< Scissor attributes */ - struct gl_stencil_attrib Stencil; /**< Stencil buffer attributes */ - struct gl_texture_attrib Texture; /**< Texture attributes */ - struct gl_transform_attrib Transform; /**< Transformation attributes */ - struct gl_viewport_attrib Viewport; /**< Viewport attributes */ - /*@}*/ - - /** \name Client attribute stack */ - /*@{*/ - GLuint ClientAttribStackDepth; - struct gl_attrib_node *ClientAttribStack[MAX_CLIENT_ATTRIB_STACK_DEPTH]; - /*@}*/ - - /** \name Client attribute groups */ - /*@{*/ - struct gl_array_attrib Array; /**< Vertex arrays */ - struct gl_pixelstore_attrib Pack; /**< Pixel packing */ - struct gl_pixelstore_attrib Unpack; /**< Pixel unpacking */ - struct gl_pixelstore_attrib DefaultPacking; /**< Default params */ - /*@}*/ - - /** \name Other assorted state (not pushed/popped on attribute stack) */ - /*@{*/ - struct gl_pixelmaps PixelMaps; - - struct gl_evaluators EvalMap; /**< All evaluators */ - struct gl_feedback Feedback; /**< Feedback */ - struct gl_selection Select; /**< Selection */ - - struct gl_program_state Program; /**< general program state */ - struct gl_vertex_program_state VertexProgram; - struct gl_fragment_program_state FragmentProgram; - struct gl_geometry_program_state GeometryProgram; - struct gl_ati_fragment_shader_state ATIFragmentShader; - - struct gl_shader_state Shader; /**< GLSL shader object state */ - struct gl_shader_compiler_options ShaderCompilerOptions[MESA_SHADER_TYPES]; - - struct gl_query_state Query; /**< occlusion, timer queries */ - - struct gl_transform_feedback TransformFeedback; - - struct gl_buffer_object *CopyReadBuffer; /**< GL_ARB_copy_buffer */ - struct gl_buffer_object *CopyWriteBuffer; /**< GL_ARB_copy_buffer */ - /*@}*/ - - struct gl_meta_state *Meta; /**< for "meta" operations */ - - /* GL_EXT_framebuffer_object */ - struct gl_renderbuffer *CurrentRenderbuffer; - - GLenum ErrorValue; /**< Last error code */ - - /* GL_ARB_robustness */ - GLenum ResetStatus; - - /** - * Recognize and silence repeated error debug messages in buggy apps. - */ - const char *ErrorDebugFmtString; - GLuint ErrorDebugCount; - - GLenum RenderMode; /**< either GL_RENDER, GL_SELECT, GL_FEEDBACK */ - GLbitfield NewState; /**< bitwise-or of _NEW_* flags */ - - GLboolean ViewportInitialized; /**< has viewport size been initialized? */ - - GLbitfield varying_vp_inputs; /**< mask of VERT_BIT_* flags */ - - /** \name Derived state */ - /*@{*/ - /** Bitwise-or of DD_* flags. Note that this bitfield may be used before - * state validation so they need to always be current. - */ - GLbitfield _TriangleCaps; - GLbitfield _ImageTransferState;/**< bitwise-or of IMAGE_*_BIT flags */ - GLfloat _EyeZDir[3]; - GLfloat _ModelViewInvScale; - GLboolean _NeedEyeCoords; - GLboolean _ForceEyeCoords; - - GLuint TextureStateTimestamp; /**< detect changes to shared state */ - - struct gl_shine_tab *_ShineTable[2]; /**< Active shine tables */ - struct gl_shine_tab *_ShineTabList; /**< MRU list of inactive shine tables */ - /**@}*/ - - struct gl_list_extensions *ListExt; /**< driver dlist extensions */ - - /** \name For debugging/development only */ - /*@{*/ - GLboolean FirstTimeCurrent; - /*@}*/ - - /** software compression/decompression supported or not */ - GLboolean Mesa_DXTn; - - GLboolean TextureFormatSupported[MESA_FORMAT_COUNT]; - - /** - * Use dp4 (rather than mul/mad) instructions for position - * transformation? - */ - GLboolean mvp_with_dp4; - - /** - * \name Hooks for module contexts. - * - * These will eventually live in the driver or elsewhere. - */ - /*@{*/ - void *swrast_context; - void *swsetup_context; - void *swtnl_context; - void *swtnl_im; - struct st_context *st; - void *aelt_context; - /*@}*/ -}; - - -#ifdef DEBUG -extern int MESA_VERBOSE; -extern int MESA_DEBUG_FLAGS; -# define MESA_FUNCTION __FUNCTION__ -#else -# define MESA_VERBOSE 0 -# define MESA_DEBUG_FLAGS 0 -# define MESA_FUNCTION "a function" -# ifndef NDEBUG -# define NDEBUG -# endif -#endif - - -/** The MESA_VERBOSE var is a bitmask of these flags */ -enum _verbose -{ - VERBOSE_VARRAY = 0x0001, - VERBOSE_TEXTURE = 0x0002, - VERBOSE_MATERIAL = 0x0004, - VERBOSE_PIPELINE = 0x0008, - VERBOSE_DRIVER = 0x0010, - VERBOSE_STATE = 0x0020, - VERBOSE_API = 0x0040, - VERBOSE_DISPLAY_LIST = 0x0100, - VERBOSE_LIGHTING = 0x0200, - VERBOSE_PRIMS = 0x0400, - VERBOSE_VERTS = 0x0800, - VERBOSE_DISASSEM = 0x1000, - VERBOSE_DRAW = 0x2000, - VERBOSE_SWAPBUFFERS = 0x4000 -}; - - -/** The MESA_DEBUG_FLAGS var is a bitmask of these flags */ -enum _debug -{ - DEBUG_ALWAYS_FLUSH = 0x1 -}; - - - -#endif /* MTYPES_H */ +/* + * Mesa 3-D graphics library + * Version: 7.7 + * + * Copyright (C) 1999-2008 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. + */ + +/** + * \file mtypes.h + * Main Mesa data structures. + * + * Please try to mark derived values with a leading underscore ('_'). + */ + +#ifndef MTYPES_H +#define MTYPES_H + + +#include "main/glheader.h" +#include "main/config.h" +#include "main/mfeatures.h" +#include "glapi/glapi.h" +#include "math/m_matrix.h" /* GLmatrix */ +#include "main/simple_list.h" /* struct simple_node */ +#include "main/formats.h" /* MESA_FORMAT_COUNT */ + + +/** + * Color channel data type. + */ +#if CHAN_BITS == 8 + typedef GLubyte GLchan; +#define CHAN_MAX 255 +#define CHAN_MAXF 255.0F +#define CHAN_TYPE GL_UNSIGNED_BYTE +#elif CHAN_BITS == 16 + typedef GLushort GLchan; +#define CHAN_MAX 65535 +#define CHAN_MAXF 65535.0F +#define CHAN_TYPE GL_UNSIGNED_SHORT +#elif CHAN_BITS == 32 + typedef GLfloat GLchan; +#define CHAN_MAX 1.0 +#define CHAN_MAXF 1.0F +#define CHAN_TYPE GL_FLOAT +#else +#error "illegal number of color channel bits" +#endif + + +/** + * Stencil buffer data type. + */ +#if STENCIL_BITS==8 + typedef GLubyte GLstencil; +#elif STENCIL_BITS==16 + typedef GLushort GLstencil; +#else +# error "illegal number of stencil bits" +#endif + + +/** + * \name 64-bit extension of GLbitfield. + */ +/*@{*/ +typedef GLuint64 GLbitfield64; + +/** Set a single bit */ +#define BITFIELD64_BIT(b) ((GLbitfield64)1 << (b)) + + +/** + * \name Some forward type declarations + */ +/*@{*/ +struct _mesa_HashTable; +struct gl_attrib_node; +struct gl_list_extensions; +struct gl_meta_state; +struct gl_pixelstore_attrib; +struct gl_program_cache; +struct gl_texture_format; +struct gl_texture_image; +struct gl_texture_object; +struct gl_context; +struct st_context; +/*@}*/ + + +/** Extra draw modes beyond GL_POINTS, GL_TRIANGLE_FAN, etc */ +#define PRIM_OUTSIDE_BEGIN_END (GL_POLYGON+1) +#define PRIM_INSIDE_UNKNOWN_PRIM (GL_POLYGON+2) +#define PRIM_UNKNOWN (GL_POLYGON+3) + + +/** + * Shader stages. Note that these will become 5 with tessellation. + * These MUST have the same values as gallium's PIPE_SHADER_* + */ +typedef enum +{ + MESA_SHADER_VERTEX = 0, + MESA_SHADER_FRAGMENT = 1, + MESA_SHADER_GEOMETRY = 2, + MESA_SHADER_TYPES = 3 +} gl_shader_type; + + + +/** + * Indexes for vertex program attributes. + * GL_NV_vertex_program aliases generic attributes over the conventional + * attributes. In GL_ARB_vertex_program shader the aliasing is optional. + * In GL_ARB_vertex_shader / OpenGL 2.0 the aliasing is disallowed (the + * generic attributes are distinct/separate). + */ +typedef enum +{ + VERT_ATTRIB_POS = 0, + VERT_ATTRIB_WEIGHT = 1, + VERT_ATTRIB_NORMAL = 2, + VERT_ATTRIB_COLOR0 = 3, + VERT_ATTRIB_COLOR1 = 4, + VERT_ATTRIB_FOG = 5, + VERT_ATTRIB_COLOR_INDEX = 6, + VERT_ATTRIB_POINT_SIZE = 6, /*alias*/ + VERT_ATTRIB_EDGEFLAG = 7, + VERT_ATTRIB_TEX0 = 8, + VERT_ATTRIB_TEX1 = 9, + VERT_ATTRIB_TEX2 = 10, + VERT_ATTRIB_TEX3 = 11, + VERT_ATTRIB_TEX4 = 12, + VERT_ATTRIB_TEX5 = 13, + VERT_ATTRIB_TEX6 = 14, + VERT_ATTRIB_TEX7 = 15, + VERT_ATTRIB_GENERIC0 = 16, + VERT_ATTRIB_GENERIC1 = 17, + VERT_ATTRIB_GENERIC2 = 18, + VERT_ATTRIB_GENERIC3 = 19, + VERT_ATTRIB_GENERIC4 = 20, + VERT_ATTRIB_GENERIC5 = 21, + VERT_ATTRIB_GENERIC6 = 22, + VERT_ATTRIB_GENERIC7 = 23, + VERT_ATTRIB_GENERIC8 = 24, + VERT_ATTRIB_GENERIC9 = 25, + VERT_ATTRIB_GENERIC10 = 26, + VERT_ATTRIB_GENERIC11 = 27, + VERT_ATTRIB_GENERIC12 = 28, + VERT_ATTRIB_GENERIC13 = 29, + VERT_ATTRIB_GENERIC14 = 30, + VERT_ATTRIB_GENERIC15 = 31, + VERT_ATTRIB_MAX = 32 +} gl_vert_attrib; + +/** + * Bitflags for vertex attributes. + * These are used in bitfields in many places. + */ +/*@{*/ +#define VERT_BIT_POS (1 << VERT_ATTRIB_POS) +#define VERT_BIT_WEIGHT (1 << VERT_ATTRIB_WEIGHT) +#define VERT_BIT_NORMAL (1 << VERT_ATTRIB_NORMAL) +#define VERT_BIT_COLOR0 (1 << VERT_ATTRIB_COLOR0) +#define VERT_BIT_COLOR1 (1 << VERT_ATTRIB_COLOR1) +#define VERT_BIT_FOG (1 << VERT_ATTRIB_FOG) +#define VERT_BIT_COLOR_INDEX (1 << VERT_ATTRIB_COLOR_INDEX) +#define VERT_BIT_EDGEFLAG (1 << VERT_ATTRIB_EDGEFLAG) +#define VERT_BIT_TEX0 (1 << VERT_ATTRIB_TEX0) +#define VERT_BIT_TEX1 (1 << VERT_ATTRIB_TEX1) +#define VERT_BIT_TEX2 (1 << VERT_ATTRIB_TEX2) +#define VERT_BIT_TEX3 (1 << VERT_ATTRIB_TEX3) +#define VERT_BIT_TEX4 (1 << VERT_ATTRIB_TEX4) +#define VERT_BIT_TEX5 (1 << VERT_ATTRIB_TEX5) +#define VERT_BIT_TEX6 (1 << VERT_ATTRIB_TEX6) +#define VERT_BIT_TEX7 (1 << VERT_ATTRIB_TEX7) +#define VERT_BIT_GENERIC0 (1 << VERT_ATTRIB_GENERIC0) +#define VERT_BIT_GENERIC1 (1 << VERT_ATTRIB_GENERIC1) +#define VERT_BIT_GENERIC2 (1 << VERT_ATTRIB_GENERIC2) +#define VERT_BIT_GENERIC3 (1 << VERT_ATTRIB_GENERIC3) +#define VERT_BIT_GENERIC4 (1 << VERT_ATTRIB_GENERIC4) +#define VERT_BIT_GENERIC5 (1 << VERT_ATTRIB_GENERIC5) +#define VERT_BIT_GENERIC6 (1 << VERT_ATTRIB_GENERIC6) +#define VERT_BIT_GENERIC7 (1 << VERT_ATTRIB_GENERIC7) +#define VERT_BIT_GENERIC8 (1 << VERT_ATTRIB_GENERIC8) +#define VERT_BIT_GENERIC9 (1 << VERT_ATTRIB_GENERIC9) +#define VERT_BIT_GENERIC10 (1 << VERT_ATTRIB_GENERIC10) +#define VERT_BIT_GENERIC11 (1 << VERT_ATTRIB_GENERIC11) +#define VERT_BIT_GENERIC12 (1 << VERT_ATTRIB_GENERIC12) +#define VERT_BIT_GENERIC13 (1 << VERT_ATTRIB_GENERIC13) +#define VERT_BIT_GENERIC14 (1 << VERT_ATTRIB_GENERIC14) +#define VERT_BIT_GENERIC15 (1 << VERT_ATTRIB_GENERIC15) + +#define VERT_BIT_TEX(u) (1 << (VERT_ATTRIB_TEX0 + (u))) +#define VERT_BIT_GENERIC(g) (1 << (VERT_ATTRIB_GENERIC0 + (g))) +/*@}*/ + + +/** + * Indexes for vertex program result attributes. Note that + * _mesa_vert_result_to_frag_attrib() and _mesa_frag_attrib_to_vert_result() make + * assumptions about the layout of this enum. + */ +typedef enum +{ + VERT_RESULT_HPOS = 0, + VERT_RESULT_COL0 = 1, + VERT_RESULT_COL1 = 2, + VERT_RESULT_FOGC = 3, + VERT_RESULT_TEX0 = 4, + VERT_RESULT_TEX1 = 5, + VERT_RESULT_TEX2 = 6, + VERT_RESULT_TEX3 = 7, + VERT_RESULT_TEX4 = 8, + VERT_RESULT_TEX5 = 9, + VERT_RESULT_TEX6 = 10, + VERT_RESULT_TEX7 = 11, + VERT_RESULT_PSIZ = 12, + VERT_RESULT_BFC0 = 13, + VERT_RESULT_BFC1 = 14, + VERT_RESULT_EDGE = 15, + VERT_RESULT_VAR0 = 16, /**< shader varying */ + VERT_RESULT_MAX = (VERT_RESULT_VAR0 + MAX_VARYING) +} gl_vert_result; + + +/*********************************************/ + +/** + * Indexes for geometry program attributes. + */ +typedef enum +{ + GEOM_ATTRIB_POSITION = 0, + GEOM_ATTRIB_COLOR0 = 1, + GEOM_ATTRIB_COLOR1 = 2, + GEOM_ATTRIB_SECONDARY_COLOR0 = 3, + GEOM_ATTRIB_SECONDARY_COLOR1 = 4, + GEOM_ATTRIB_FOG_FRAG_COORD = 5, + GEOM_ATTRIB_POINT_SIZE = 6, + GEOM_ATTRIB_CLIP_VERTEX = 7, + GEOM_ATTRIB_PRIMITIVE_ID = 8, + GEOM_ATTRIB_TEX_COORD = 9, + + GEOM_ATTRIB_VAR0 = 16, + GEOM_ATTRIB_MAX = (GEOM_ATTRIB_VAR0 + MAX_VARYING) +} gl_geom_attrib; + +/** + * Bitflags for geometry attributes. + * These are used in bitfields in many places. + */ +/*@{*/ +#define GEOM_BIT_COLOR0 (1 << GEOM_ATTRIB_COLOR0) +#define GEOM_BIT_COLOR1 (1 << GEOM_ATTRIB_COLOR1) +#define GEOM_BIT_SCOLOR0 (1 << GEOM_ATTRIB_SECONDARY_COLOR0) +#define GEOM_BIT_SCOLOR1 (1 << GEOM_ATTRIB_SECONDARY_COLOR1) +#define GEOM_BIT_TEX_COORD (1 << GEOM_ATTRIB_TEX_COORD) +#define GEOM_BIT_FOG_COORD (1 << GEOM_ATTRIB_FOG_FRAG_COORD) +#define GEOM_BIT_POSITION (1 << GEOM_ATTRIB_POSITION) +#define GEOM_BIT_POINT_SIDE (1 << GEOM_ATTRIB_POINT_SIZE) +#define GEOM_BIT_CLIP_VERTEX (1 << GEOM_ATTRIB_CLIP_VERTEX) +#define GEOM_BIT_PRIM_ID (1 << GEOM_ATTRIB_PRIMITIVE_ID) +#define GEOM_BIT_VAR0 (1 << GEOM_ATTRIB_VAR0) + +#define GEOM_BIT_VAR(g) (1 << (GEOM_BIT_VAR0 + (g))) +/*@}*/ + + +/** + * Indexes for geometry program result attributes + */ +typedef enum +{ + GEOM_RESULT_POS = 0, + GEOM_RESULT_COL0 = 1, + GEOM_RESULT_COL1 = 2, + GEOM_RESULT_SCOL0 = 3, + GEOM_RESULT_SCOL1 = 4, + GEOM_RESULT_FOGC = 5, + GEOM_RESULT_TEX0 = 6, + GEOM_RESULT_TEX1 = 7, + GEOM_RESULT_TEX2 = 8, + GEOM_RESULT_TEX3 = 9, + GEOM_RESULT_TEX4 = 10, + GEOM_RESULT_TEX5 = 11, + GEOM_RESULT_TEX6 = 12, + GEOM_RESULT_TEX7 = 13, + GEOM_RESULT_PSIZ = 14, + GEOM_RESULT_CLPV = 15, + GEOM_RESULT_PRID = 16, + GEOM_RESULT_LAYR = 17, + GEOM_RESULT_VAR0 = 18, /**< shader varying, should really be 16 */ + /* ### we need to -2 because var0 is 18 instead 16 like in the others */ + GEOM_RESULT_MAX = (GEOM_RESULT_VAR0 + MAX_VARYING - 2) +} gl_geom_result; + + +/** + * Indexes for fragment program input attributes. Note that + * _mesa_vert_result_to_frag_attrib() and frag_attrib_to_vert_result() make + * assumptions about the layout of this enum. + */ +typedef enum +{ + FRAG_ATTRIB_WPOS = 0, + FRAG_ATTRIB_COL0 = 1, + FRAG_ATTRIB_COL1 = 2, + FRAG_ATTRIB_FOGC = 3, + FRAG_ATTRIB_TEX0 = 4, + FRAG_ATTRIB_TEX1 = 5, + FRAG_ATTRIB_TEX2 = 6, + FRAG_ATTRIB_TEX3 = 7, + FRAG_ATTRIB_TEX4 = 8, + FRAG_ATTRIB_TEX5 = 9, + FRAG_ATTRIB_TEX6 = 10, + FRAG_ATTRIB_TEX7 = 11, + FRAG_ATTRIB_FACE = 12, /**< front/back face */ + FRAG_ATTRIB_PNTC = 13, /**< sprite/point coord */ + FRAG_ATTRIB_VAR0 = 14, /**< shader varying */ + FRAG_ATTRIB_MAX = (FRAG_ATTRIB_VAR0 + MAX_VARYING) +} gl_frag_attrib; + + +/** + * Convert from a gl_vert_result value to the corresponding gl_frag_attrib. + * + * VERT_RESULT_HPOS is converted to FRAG_ATTRIB_WPOS. + * + * gl_vert_result values which have no corresponding gl_frag_attrib + * (VERT_RESULT_PSIZ, VERT_RESULT_BFC0, VERT_RESULT_BFC1, and + * VERT_RESULT_EDGE) are converted to a value of -1. + */ +static INLINE int +_mesa_vert_result_to_frag_attrib(gl_vert_result vert_result) +{ + if (vert_result >= VERT_RESULT_VAR0) + return vert_result - VERT_RESULT_VAR0 + FRAG_ATTRIB_VAR0; + else if (vert_result <= VERT_RESULT_TEX7) + return vert_result; + else + return -1; +} + + +/** + * Convert from a gl_frag_attrib value to the corresponding gl_vert_result. + * + * FRAG_ATTRIB_WPOS is converted to VERT_RESULT_HPOS. + * + * gl_frag_attrib values which have no corresponding gl_vert_result + * (FRAG_ATTRIB_FACE and FRAG_ATTRIB_PNTC) are converted to a value of -1. + */ +static INLINE int +_mesa_frag_attrib_to_vert_result(gl_frag_attrib frag_attrib) +{ + if (frag_attrib <= FRAG_ATTRIB_TEX7) + return frag_attrib; + else if (frag_attrib >= FRAG_ATTRIB_VAR0) + return frag_attrib - FRAG_ATTRIB_VAR0 + VERT_RESULT_VAR0; + else + return -1; +} + + +/** + * Bitflags for fragment program input attributes. + */ +/*@{*/ +#define FRAG_BIT_WPOS (1 << FRAG_ATTRIB_WPOS) +#define FRAG_BIT_COL0 (1 << FRAG_ATTRIB_COL0) +#define FRAG_BIT_COL1 (1 << FRAG_ATTRIB_COL1) +#define FRAG_BIT_FOGC (1 << FRAG_ATTRIB_FOGC) +#define FRAG_BIT_FACE (1 << FRAG_ATTRIB_FACE) +#define FRAG_BIT_PNTC (1 << FRAG_ATTRIB_PNTC) +#define FRAG_BIT_TEX0 (1 << FRAG_ATTRIB_TEX0) +#define FRAG_BIT_TEX1 (1 << FRAG_ATTRIB_TEX1) +#define FRAG_BIT_TEX2 (1 << FRAG_ATTRIB_TEX2) +#define FRAG_BIT_TEX3 (1 << FRAG_ATTRIB_TEX3) +#define FRAG_BIT_TEX4 (1 << FRAG_ATTRIB_TEX4) +#define FRAG_BIT_TEX5 (1 << FRAG_ATTRIB_TEX5) +#define FRAG_BIT_TEX6 (1 << FRAG_ATTRIB_TEX6) +#define FRAG_BIT_TEX7 (1 << FRAG_ATTRIB_TEX7) +#define FRAG_BIT_VAR0 (1 << FRAG_ATTRIB_VAR0) + +#define FRAG_BIT_TEX(U) (FRAG_BIT_TEX0 << (U)) +#define FRAG_BIT_VAR(V) (FRAG_BIT_VAR0 << (V)) + +#define FRAG_BITS_TEX_ANY (FRAG_BIT_TEX0| \ + FRAG_BIT_TEX1| \ + FRAG_BIT_TEX2| \ + FRAG_BIT_TEX3| \ + FRAG_BIT_TEX4| \ + FRAG_BIT_TEX5| \ + FRAG_BIT_TEX6| \ + FRAG_BIT_TEX7) +/*@}*/ + + +/** + * Fragment program results + */ +typedef enum +{ + FRAG_RESULT_DEPTH = 0, + FRAG_RESULT_STENCIL = 1, + /* If a single color should be written to all render targets, this + * register is written. No FRAG_RESULT_DATAn will be written. + */ + FRAG_RESULT_COLOR = 2, + + /* FRAG_RESULT_DATAn are the per-render-target (GLSL gl_FragData[n] + * or ARB_fragment_program fragment.color[n]) color results. If + * any are written, FRAG_RESULT_COLOR will not be written. + */ + FRAG_RESULT_DATA0 = 3, + FRAG_RESULT_MAX = (FRAG_RESULT_DATA0 + MAX_DRAW_BUFFERS) +} gl_frag_result; + + +/** + * Indexes for all renderbuffers + */ +typedef enum +{ + /* the four standard color buffers */ + BUFFER_FRONT_LEFT, + BUFFER_BACK_LEFT, + BUFFER_FRONT_RIGHT, + BUFFER_BACK_RIGHT, + BUFFER_DEPTH, + BUFFER_STENCIL, + BUFFER_ACCUM, + /* optional aux buffer */ + BUFFER_AUX0, + /* generic renderbuffers */ + BUFFER_COLOR0, + BUFFER_COLOR1, + BUFFER_COLOR2, + BUFFER_COLOR3, + BUFFER_COLOR4, + BUFFER_COLOR5, + BUFFER_COLOR6, + BUFFER_COLOR7, + BUFFER_COUNT +} gl_buffer_index; + +/** + * Bit flags for all renderbuffers + */ +#define BUFFER_BIT_FRONT_LEFT (1 << BUFFER_FRONT_LEFT) +#define BUFFER_BIT_BACK_LEFT (1 << BUFFER_BACK_LEFT) +#define BUFFER_BIT_FRONT_RIGHT (1 << BUFFER_FRONT_RIGHT) +#define BUFFER_BIT_BACK_RIGHT (1 << BUFFER_BACK_RIGHT) +#define BUFFER_BIT_AUX0 (1 << BUFFER_AUX0) +#define BUFFER_BIT_AUX1 (1 << BUFFER_AUX1) +#define BUFFER_BIT_AUX2 (1 << BUFFER_AUX2) +#define BUFFER_BIT_AUX3 (1 << BUFFER_AUX3) +#define BUFFER_BIT_DEPTH (1 << BUFFER_DEPTH) +#define BUFFER_BIT_STENCIL (1 << BUFFER_STENCIL) +#define BUFFER_BIT_ACCUM (1 << BUFFER_ACCUM) +#define BUFFER_BIT_COLOR0 (1 << BUFFER_COLOR0) +#define BUFFER_BIT_COLOR1 (1 << BUFFER_COLOR1) +#define BUFFER_BIT_COLOR2 (1 << BUFFER_COLOR2) +#define BUFFER_BIT_COLOR3 (1 << BUFFER_COLOR3) +#define BUFFER_BIT_COLOR4 (1 << BUFFER_COLOR4) +#define BUFFER_BIT_COLOR5 (1 << BUFFER_COLOR5) +#define BUFFER_BIT_COLOR6 (1 << BUFFER_COLOR6) +#define BUFFER_BIT_COLOR7 (1 << BUFFER_COLOR7) + +/** + * Mask of all the color buffer bits (but not accum). + */ +#define BUFFER_BITS_COLOR (BUFFER_BIT_FRONT_LEFT | \ + BUFFER_BIT_BACK_LEFT | \ + BUFFER_BIT_FRONT_RIGHT | \ + BUFFER_BIT_BACK_RIGHT | \ + BUFFER_BIT_AUX0 | \ + BUFFER_BIT_COLOR0 | \ + BUFFER_BIT_COLOR1 | \ + BUFFER_BIT_COLOR2 | \ + BUFFER_BIT_COLOR3 | \ + BUFFER_BIT_COLOR4 | \ + BUFFER_BIT_COLOR5 | \ + BUFFER_BIT_COLOR6 | \ + BUFFER_BIT_COLOR7) + + +/** + * Framebuffer configuration (aka visual / pixelformat) + * Note: some of these fields should be boolean, but it appears that + * code in drivers/dri/common/util.c requires int-sized fields. + */ +struct gl_config +{ + GLboolean rgbMode; + GLboolean floatMode; + GLboolean colorIndexMode; /* XXX is this used anywhere? */ + GLuint doubleBufferMode; + GLuint stereoMode; + + GLboolean haveAccumBuffer; + GLboolean haveDepthBuffer; + GLboolean haveStencilBuffer; + + GLint redBits, greenBits, blueBits, alphaBits; /* bits per comp */ + GLuint redMask, greenMask, blueMask, alphaMask; + GLint rgbBits; /* total bits for rgb */ + GLint indexBits; /* total bits for colorindex */ + + GLint accumRedBits, accumGreenBits, accumBlueBits, accumAlphaBits; + GLint depthBits; + GLint stencilBits; + + GLint numAuxBuffers; + + GLint level; + + /* EXT_visual_rating / GLX 1.2 */ + GLint visualRating; + + /* EXT_visual_info / GLX 1.2 */ + GLint transparentPixel; + /* colors are floats scaled to ints */ + GLint transparentRed, transparentGreen, transparentBlue, transparentAlpha; + GLint transparentIndex; + + /* ARB_multisample / SGIS_multisample */ + GLint sampleBuffers; + GLint samples; + + /* SGIX_pbuffer / GLX 1.3 */ + GLint maxPbufferWidth; + GLint maxPbufferHeight; + GLint maxPbufferPixels; + GLint optimalPbufferWidth; /* Only for SGIX_pbuffer. */ + GLint optimalPbufferHeight; /* Only for SGIX_pbuffer. */ + + /* OML_swap_method */ + GLint swapMethod; + + /* EXT_texture_from_pixmap */ + GLint bindToTextureRgb; + GLint bindToTextureRgba; + GLint bindToMipmapTexture; + GLint bindToTextureTargets; + GLint yInverted; + + /* EXT_framebuffer_sRGB */ + GLint sRGBCapable; +}; + + +/** + * \name Bit flags used for updating material values. + */ +/*@{*/ +#define MAT_ATTRIB_FRONT_AMBIENT 0 +#define MAT_ATTRIB_BACK_AMBIENT 1 +#define MAT_ATTRIB_FRONT_DIFFUSE 2 +#define MAT_ATTRIB_BACK_DIFFUSE 3 +#define MAT_ATTRIB_FRONT_SPECULAR 4 +#define MAT_ATTRIB_BACK_SPECULAR 5 +#define MAT_ATTRIB_FRONT_EMISSION 6 +#define MAT_ATTRIB_BACK_EMISSION 7 +#define MAT_ATTRIB_FRONT_SHININESS 8 +#define MAT_ATTRIB_BACK_SHININESS 9 +#define MAT_ATTRIB_FRONT_INDEXES 10 +#define MAT_ATTRIB_BACK_INDEXES 11 +#define MAT_ATTRIB_MAX 12 + +#define MAT_ATTRIB_AMBIENT(f) (MAT_ATTRIB_FRONT_AMBIENT+(f)) +#define MAT_ATTRIB_DIFFUSE(f) (MAT_ATTRIB_FRONT_DIFFUSE+(f)) +#define MAT_ATTRIB_SPECULAR(f) (MAT_ATTRIB_FRONT_SPECULAR+(f)) +#define MAT_ATTRIB_EMISSION(f) (MAT_ATTRIB_FRONT_EMISSION+(f)) +#define MAT_ATTRIB_SHININESS(f)(MAT_ATTRIB_FRONT_SHININESS+(f)) +#define MAT_ATTRIB_INDEXES(f) (MAT_ATTRIB_FRONT_INDEXES+(f)) + +#define MAT_INDEX_AMBIENT 0 +#define MAT_INDEX_DIFFUSE 1 +#define MAT_INDEX_SPECULAR 2 + +#define MAT_BIT_FRONT_AMBIENT (1< ) */ + GLfloat _NormSpotDirection[4]; /**< normalized spotlight direction */ + GLfloat _VP_inf_spot_attenuation; + + GLfloat _SpotExpTable[EXP_TABLE_SIZE][2]; /**< to replace a pow() call */ + GLfloat _MatAmbient[2][3]; /**< material ambient * light ambient */ + GLfloat _MatDiffuse[2][3]; /**< material diffuse * light diffuse */ + GLfloat _MatSpecular[2][3]; /**< material spec * light specular */ + GLfloat _dli; /**< CI diffuse light intensity */ + GLfloat _sli; /**< CI specular light intensity */ + /*@}*/ +}; + + +/** + * Light model state. + */ +struct gl_lightmodel +{ + GLfloat Ambient[4]; /**< ambient color */ + GLboolean LocalViewer; /**< Local (or infinite) view point? */ + GLboolean TwoSide; /**< Two (or one) sided lighting? */ + GLenum ColorControl; /**< either GL_SINGLE_COLOR + * or GL_SEPARATE_SPECULAR_COLOR */ +}; + + +/** + * Material state. + */ +struct gl_material +{ + GLfloat Attrib[MAT_ATTRIB_MAX][4]; +}; + + +/** + * Accumulation buffer attribute group (GL_ACCUM_BUFFER_BIT) + */ +struct gl_accum_attrib +{ + GLfloat ClearColor[4]; /**< Accumulation buffer clear color */ +}; + + +/** + * Color buffer attribute group (GL_COLOR_BUFFER_BIT). + */ +struct gl_colorbuffer_attrib +{ + GLuint ClearIndex; /**< Index to use for glClear */ + GLfloat ClearColorUnclamped[4]; /**< Color to use for glClear*/ + GLclampf ClearColor[4]; /**< Color to use for glClear */ + + GLuint IndexMask; /**< Color index write mask */ + GLubyte ColorMask[MAX_DRAW_BUFFERS][4];/**< Each flag is 0xff or 0x0 */ + + GLenum DrawBuffer[MAX_DRAW_BUFFERS]; /**< Which buffer to draw into */ + + /** + * \name alpha testing + */ + /*@{*/ + GLboolean AlphaEnabled; /**< Alpha test enabled flag */ + GLenum AlphaFunc; /**< Alpha test function */ + GLfloat AlphaRefUnclamped; + GLclampf AlphaRef; /**< Alpha reference value */ + /*@}*/ + + /** + * \name Blending + */ + /*@{*/ + GLbitfield BlendEnabled; /**< Per-buffer blend enable flags */ + + /* NOTE: this does _not_ depend on fragment clamping or any other clamping control, + * only on the fixed-pointness of the render target. + * The query does however depend on fragment color clamping. + */ + GLfloat BlendColorUnclamped[4]; /**< Blending color */ + GLfloat BlendColor[4]; /**< Blending color */ + + struct + { + GLenum SrcRGB; /**< RGB blend source term */ + GLenum DstRGB; /**< RGB blend dest term */ + GLenum SrcA; /**< Alpha blend source term */ + GLenum DstA; /**< Alpha blend dest term */ + GLenum EquationRGB; /**< GL_ADD, GL_SUBTRACT, etc. */ + GLenum EquationA; /**< GL_ADD, GL_SUBTRACT, etc. */ + } Blend[MAX_DRAW_BUFFERS]; + /** Are the blend func terms currently different for each buffer/target? */ + GLboolean _BlendFuncPerBuffer; + /** Are the blend equations currently different for each buffer/target? */ + GLboolean _BlendEquationPerBuffer; + /*@}*/ + + /** + * \name Logic op + */ + /*@{*/ + GLenum LogicOp; /**< Logic operator */ + GLboolean IndexLogicOpEnabled; /**< Color index logic op enabled flag */ + GLboolean ColorLogicOpEnabled; /**< RGBA logic op enabled flag */ + GLboolean _LogicOpEnabled; /**< RGBA logic op + EXT_blend_logic_op enabled flag */ + /*@}*/ + + GLboolean DitherFlag; /**< Dither enable flag */ + + GLenum ClampFragmentColor; /**< GL_TRUE, GL_FALSE or GL_FIXED_ONLY_ARB */ + GLboolean _ClampFragmentColor; /** < with GL_FIXED_ONLY_ARB resolved */ + GLenum ClampReadColor; /**< GL_TRUE, GL_FALSE or GL_FIXED_ONLY_ARB */ + GLboolean _ClampReadColor; /** < with GL_FIXED_ONLY_ARB resolved */ + + GLboolean sRGBEnabled; /**< Framebuffer sRGB blending/updating requested */ +}; + + +/** + * Current attribute group (GL_CURRENT_BIT). + */ +struct gl_current_attrib +{ + /** + * \name Current vertex attributes. + * \note Values are valid only after FLUSH_VERTICES has been called. + * \note Index and Edgeflag current values are stored as floats in the + * SIX and SEVEN attribute slots. + */ + GLfloat Attrib[VERT_ATTRIB_MAX][4]; /**< Position, color, texcoords, etc */ + + /** + * \name Current raster position attributes (always valid). + * \note This set of attributes is very similar to the SWvertex struct. + */ + /*@{*/ + GLfloat RasterPos[4]; + GLfloat RasterDistance; + GLfloat RasterColor[4]; + GLfloat RasterSecondaryColor[4]; + GLfloat RasterTexCoords[MAX_TEXTURE_COORD_UNITS][4]; + GLboolean RasterPosValid; + /*@}*/ +}; + + +/** + * Depth buffer attribute group (GL_DEPTH_BUFFER_BIT). + */ +struct gl_depthbuffer_attrib +{ + GLenum Func; /**< Function for depth buffer compare */ + GLclampd Clear; /**< Value to clear depth buffer to */ + GLboolean Test; /**< Depth buffering enabled flag */ + GLboolean Mask; /**< Depth buffer writable? */ + GLboolean BoundsTest; /**< GL_EXT_depth_bounds_test */ + GLfloat BoundsMin, BoundsMax;/**< GL_EXT_depth_bounds_test */ +}; + + +/** + * Evaluator attribute group (GL_EVAL_BIT). + */ +struct gl_eval_attrib +{ + /** + * \name Enable bits + */ + /*@{*/ + GLboolean Map1Color4; + GLboolean Map1Index; + GLboolean Map1Normal; + GLboolean Map1TextureCoord1; + GLboolean Map1TextureCoord2; + GLboolean Map1TextureCoord3; + GLboolean Map1TextureCoord4; + GLboolean Map1Vertex3; + GLboolean Map1Vertex4; + GLboolean Map1Attrib[16]; /* GL_NV_vertex_program */ + GLboolean Map2Color4; + GLboolean Map2Index; + GLboolean Map2Normal; + GLboolean Map2TextureCoord1; + GLboolean Map2TextureCoord2; + GLboolean Map2TextureCoord3; + GLboolean Map2TextureCoord4; + GLboolean Map2Vertex3; + GLboolean Map2Vertex4; + GLboolean Map2Attrib[16]; /* GL_NV_vertex_program */ + GLboolean AutoNormal; + /*@}*/ + + /** + * \name Map Grid endpoints and divisions and calculated du values + */ + /*@{*/ + GLint MapGrid1un; + GLfloat MapGrid1u1, MapGrid1u2, MapGrid1du; + GLint MapGrid2un, MapGrid2vn; + GLfloat MapGrid2u1, MapGrid2u2, MapGrid2du; + GLfloat MapGrid2v1, MapGrid2v2, MapGrid2dv; + /*@}*/ +}; + + +/** + * Fog attribute group (GL_FOG_BIT). + */ +struct gl_fog_attrib +{ + GLboolean Enabled; /**< Fog enabled flag */ + GLfloat ColorUnclamped[4]; /**< Fog color */ + GLfloat Color[4]; /**< Fog color */ + GLfloat Density; /**< Density >= 0.0 */ + GLfloat Start; /**< Start distance in eye coords */ + GLfloat End; /**< End distance in eye coords */ + GLfloat Index; /**< Fog index */ + GLenum Mode; /**< Fog mode */ + GLboolean ColorSumEnabled; + GLenum FogCoordinateSource; /**< GL_EXT_fog_coord */ + GLfloat _Scale; /**< (End == Start) ? 1.0 : 1.0 / (End - Start) */ +}; + + +/** + * \brief Layout qualifiers for gl_FragDepth. + * + * Extension AMD_conservative_depth allows gl_FragDepth to be redeclared with + * a layout qualifier. + * + * \see enum ir_depth_layout + */ +enum gl_frag_depth_layout { + FRAG_DEPTH_LAYOUT_NONE, /**< No layout is specified. */ + FRAG_DEPTH_LAYOUT_ANY, + FRAG_DEPTH_LAYOUT_GREATER, + FRAG_DEPTH_LAYOUT_LESS, + FRAG_DEPTH_LAYOUT_UNCHANGED +}; + + +/** + * Hint attribute group (GL_HINT_BIT). + * + * Values are always one of GL_FASTEST, GL_NICEST, or GL_DONT_CARE. + */ +struct gl_hint_attrib +{ + GLenum PerspectiveCorrection; + GLenum PointSmooth; + GLenum LineSmooth; + GLenum PolygonSmooth; + GLenum Fog; + GLenum ClipVolumeClipping; /**< GL_EXT_clip_volume_hint */ + GLenum TextureCompression; /**< GL_ARB_texture_compression */ + GLenum GenerateMipmap; /**< GL_SGIS_generate_mipmap */ + GLenum FragmentShaderDerivative; /**< GL_ARB_fragment_shader */ +}; + +/** + * Light state flags. + */ +/*@{*/ +#define LIGHT_SPOT 0x1 +#define LIGHT_LOCAL_VIEWER 0x2 +#define LIGHT_POSITIONAL 0x4 +#define LIGHT_NEED_VERTICES (LIGHT_POSITIONAL|LIGHT_LOCAL_VIEWER) +/*@}*/ + + +/** + * Lighting attribute group (GL_LIGHT_BIT). + */ +struct gl_light_attrib +{ + struct gl_light Light[MAX_LIGHTS]; /**< Array of light sources */ + struct gl_lightmodel Model; /**< Lighting model */ + + /** + * Must flush FLUSH_VERTICES before referencing: + */ + /*@{*/ + struct gl_material Material; /**< Includes front & back values */ + /*@}*/ + + GLboolean Enabled; /**< Lighting enabled flag */ + GLenum ShadeModel; /**< GL_FLAT or GL_SMOOTH */ + GLenum ProvokingVertex; /**< GL_EXT_provoking_vertex */ + GLenum ColorMaterialFace; /**< GL_FRONT, BACK or FRONT_AND_BACK */ + GLenum ColorMaterialMode; /**< GL_AMBIENT, GL_DIFFUSE, etc */ + GLbitfield ColorMaterialBitmask; /**< bitmask formed from Face and Mode */ + GLboolean ColorMaterialEnabled; + GLenum ClampVertexColor; + GLboolean _ClampVertexColor; + + struct gl_light EnabledList; /**< List sentinel */ + + /** + * Derived state for optimizations: + */ + /*@{*/ + GLboolean _NeedEyeCoords; + GLboolean _NeedVertices; /**< Use fast shader? */ + GLbitfield _Flags; /**< LIGHT_* flags, see above */ + GLfloat _BaseColor[2][3]; + /*@}*/ +}; + + +/** + * Line attribute group (GL_LINE_BIT). + */ +struct gl_line_attrib +{ + GLboolean SmoothFlag; /**< GL_LINE_SMOOTH enabled? */ + GLboolean StippleFlag; /**< GL_LINE_STIPPLE enabled? */ + GLushort StipplePattern; /**< Stipple pattern */ + GLint StippleFactor; /**< Stipple repeat factor */ + GLfloat Width; /**< Line width */ +}; + + +/** + * Display list attribute group (GL_LIST_BIT). + */ +struct gl_list_attrib +{ + GLuint ListBase; +}; + + +/** + * Multisample attribute group (GL_MULTISAMPLE_BIT). + */ +struct gl_multisample_attrib +{ + GLboolean Enabled; + GLboolean _Enabled; /**< true if Enabled and multisample buffer */ + GLboolean SampleAlphaToCoverage; + GLboolean SampleAlphaToOne; + GLboolean SampleCoverage; + GLfloat SampleCoverageValue; + GLboolean SampleCoverageInvert; +}; + + +/** + * A pixelmap (see glPixelMap) + */ +struct gl_pixelmap +{ + GLint Size; + GLfloat Map[MAX_PIXEL_MAP_TABLE]; + GLubyte Map8[MAX_PIXEL_MAP_TABLE]; /**< converted to 8-bit color */ +}; + + +/** + * Collection of all pixelmaps + */ +struct gl_pixelmaps +{ + struct gl_pixelmap RtoR; /**< i.e. GL_PIXEL_MAP_R_TO_R */ + struct gl_pixelmap GtoG; + struct gl_pixelmap BtoB; + struct gl_pixelmap AtoA; + struct gl_pixelmap ItoR; + struct gl_pixelmap ItoG; + struct gl_pixelmap ItoB; + struct gl_pixelmap ItoA; + struct gl_pixelmap ItoI; + struct gl_pixelmap StoS; +}; + + +/** + * Pixel attribute group (GL_PIXEL_MODE_BIT). + */ +struct gl_pixel_attrib +{ + GLenum ReadBuffer; /**< source buffer for glRead/CopyPixels() */ + + /*--- Begin Pixel Transfer State ---*/ + /* Fields are in the order in which they're applied... */ + + /** Scale & Bias (index shift, offset) */ + /*@{*/ + GLfloat RedBias, RedScale; + GLfloat GreenBias, GreenScale; + GLfloat BlueBias, BlueScale; + GLfloat AlphaBias, AlphaScale; + GLfloat DepthBias, DepthScale; + GLint IndexShift, IndexOffset; + /*@}*/ + + /* Pixel Maps */ + /* Note: actual pixel maps are not part of this attrib group */ + GLboolean MapColorFlag; + GLboolean MapStencilFlag; + + /*--- End Pixel Transfer State ---*/ + + /** glPixelZoom */ + GLfloat ZoomX, ZoomY; +}; + + +/** + * Point attribute group (GL_POINT_BIT). + */ +struct gl_point_attrib +{ + GLboolean SmoothFlag; /**< True if GL_POINT_SMOOTH is enabled */ + GLfloat Size; /**< User-specified point size */ + GLfloat Params[3]; /**< GL_EXT_point_parameters */ + GLfloat MinSize, MaxSize; /**< GL_EXT_point_parameters */ + GLfloat Threshold; /**< GL_EXT_point_parameters */ + GLboolean _Attenuated; /**< True if Params != [1, 0, 0] */ + GLboolean PointSprite; /**< GL_NV/ARB_point_sprite */ + GLboolean CoordReplace[MAX_TEXTURE_COORD_UNITS]; /**< GL_ARB_point_sprite*/ + GLenum SpriteRMode; /**< GL_NV_point_sprite (only!) */ + GLenum SpriteOrigin; /**< GL_ARB_point_sprite */ +}; + + +/** + * Polygon attribute group (GL_POLYGON_BIT). + */ +struct gl_polygon_attrib +{ + GLenum FrontFace; /**< Either GL_CW or GL_CCW */ + GLenum FrontMode; /**< Either GL_POINT, GL_LINE or GL_FILL */ + GLenum BackMode; /**< Either GL_POINT, GL_LINE or GL_FILL */ + GLboolean _FrontBit; /**< 0=GL_CCW, 1=GL_CW */ + GLboolean CullFlag; /**< Culling on/off flag */ + GLboolean SmoothFlag; /**< True if GL_POLYGON_SMOOTH is enabled */ + GLboolean StippleFlag; /**< True if GL_POLYGON_STIPPLE is enabled */ + GLenum CullFaceMode; /**< Culling mode GL_FRONT or GL_BACK */ + GLfloat OffsetFactor; /**< Polygon offset factor, from user */ + GLfloat OffsetUnits; /**< Polygon offset units, from user */ + GLboolean OffsetPoint; /**< Offset in GL_POINT mode */ + GLboolean OffsetLine; /**< Offset in GL_LINE mode */ + GLboolean OffsetFill; /**< Offset in GL_FILL mode */ +}; + + +/** + * Scissor attributes (GL_SCISSOR_BIT). + */ +struct gl_scissor_attrib +{ + GLboolean Enabled; /**< Scissor test enabled? */ + GLint X, Y; /**< Lower left corner of box */ + GLsizei Width, Height; /**< Size of box */ +}; + + +/** + * Stencil attribute group (GL_STENCIL_BUFFER_BIT). + * + * Three sets of stencil data are tracked so that OpenGL 2.0, + * GL_EXT_stencil_two_side, and GL_ATI_separate_stencil can all be supported + * simultaneously. In each of the stencil state arrays, element 0 corresponds + * to GL_FRONT. Element 1 corresponds to the OpenGL 2.0 / + * GL_ATI_separate_stencil GL_BACK state. Element 2 corresponds to the + * GL_EXT_stencil_two_side GL_BACK state. + * + * The derived value \c _BackFace is either 1 or 2 depending on whether or + * not GL_STENCIL_TEST_TWO_SIDE_EXT is enabled. + * + * The derived value \c _TestTwoSide is set when the front-face and back-face + * stencil state are different. + */ +struct gl_stencil_attrib +{ + GLboolean Enabled; /**< Enabled flag */ + GLboolean TestTwoSide; /**< GL_EXT_stencil_two_side */ + GLubyte ActiveFace; /**< GL_EXT_stencil_two_side (0 or 2) */ + GLboolean _Enabled; /**< Enabled and stencil buffer present */ + GLboolean _TestTwoSide; + GLubyte _BackFace; /**< Current back stencil state (1 or 2) */ + GLenum Function[3]; /**< Stencil function */ + GLenum FailFunc[3]; /**< Fail function */ + GLenum ZPassFunc[3]; /**< Depth buffer pass function */ + GLenum ZFailFunc[3]; /**< Depth buffer fail function */ + GLint Ref[3]; /**< Reference value */ + GLuint ValueMask[3]; /**< Value mask */ + GLuint WriteMask[3]; /**< Write mask */ + GLuint Clear; /**< Clear value */ +}; + + +/** + * An index for each type of texture object. These correspond to the GL + * texture target enums, such as GL_TEXTURE_2D, GL_TEXTURE_CUBE_MAP, etc. + * Note: the order is from highest priority to lowest priority. + */ +typedef enum +{ + TEXTURE_BUFFER_INDEX, + TEXTURE_2D_ARRAY_INDEX, + TEXTURE_1D_ARRAY_INDEX, + TEXTURE_CUBE_INDEX, + TEXTURE_3D_INDEX, + TEXTURE_RECT_INDEX, + TEXTURE_2D_INDEX, + TEXTURE_1D_INDEX, + NUM_TEXTURE_TARGETS +} gl_texture_index; + + +/** + * Bit flags for each type of texture object + * Used for Texture.Unit[]._ReallyEnabled flags. + */ +/*@{*/ +#define TEXTURE_BUFFER_BIT (1 << TEXTURE_BUFFER_INDEX) +#define TEXTURE_2D_ARRAY_BIT (1 << TEXTURE_2D_ARRAY_INDEX) +#define TEXTURE_1D_ARRAY_BIT (1 << TEXTURE_1D_ARRAY_INDEX) +#define TEXTURE_CUBE_BIT (1 << TEXTURE_CUBE_INDEX) +#define TEXTURE_3D_BIT (1 << TEXTURE_3D_INDEX) +#define TEXTURE_RECT_BIT (1 << TEXTURE_RECT_INDEX) +#define TEXTURE_2D_BIT (1 << TEXTURE_2D_INDEX) +#define TEXTURE_1D_BIT (1 << TEXTURE_1D_INDEX) +/*@}*/ + + +/** + * TexGenEnabled flags. + */ +/*@{*/ +#define S_BIT 1 +#define T_BIT 2 +#define R_BIT 4 +#define Q_BIT 8 +#define STR_BITS (S_BIT | T_BIT | R_BIT) +/*@}*/ + + +/** + * Bit flag versions of the corresponding GL_ constants. + */ +/*@{*/ +#define TEXGEN_SPHERE_MAP 0x1 +#define TEXGEN_OBJ_LINEAR 0x2 +#define TEXGEN_EYE_LINEAR 0x4 +#define TEXGEN_REFLECTION_MAP_NV 0x8 +#define TEXGEN_NORMAL_MAP_NV 0x10 + +#define TEXGEN_NEED_NORMALS (TEXGEN_SPHERE_MAP | \ + TEXGEN_REFLECTION_MAP_NV | \ + TEXGEN_NORMAL_MAP_NV) +#define TEXGEN_NEED_EYE_COORD (TEXGEN_SPHERE_MAP | \ + TEXGEN_REFLECTION_MAP_NV | \ + TEXGEN_NORMAL_MAP_NV | \ + TEXGEN_EYE_LINEAR) +/*@}*/ + + + +/** Tex-gen enabled for texture unit? */ +#define ENABLE_TEXGEN(unit) (1 << (unit)) + +/** Non-identity texture matrix for texture unit? */ +#define ENABLE_TEXMAT(unit) (1 << (unit)) + + +/** + * Texel fetch function prototype. We use texel fetch functions to + * extract RGBA, color indexes and depth components out of 1D, 2D and 3D + * texture images. These functions help to isolate us from the gritty + * details of all the various texture image encodings. + * + * \param texImage texture image. + * \param col texel column. + * \param row texel row. + * \param img texel image level/layer. + * \param texelOut output texel (up to 4 GLchans) + */ +typedef void (*FetchTexelFuncC)( const struct gl_texture_image *texImage, + GLint col, GLint row, GLint img, + GLchan *texelOut ); + +/** + * As above, but returns floats. + * Used for depth component images and for upcoming signed/float + * texture images. + */ +typedef void (*FetchTexelFuncF)( const struct gl_texture_image *texImage, + GLint col, GLint row, GLint img, + GLfloat *texelOut ); + + +typedef void (*StoreTexelFunc)(struct gl_texture_image *texImage, + GLint col, GLint row, GLint img, + const void *texel); + + +/** + * Texture image state. Describes the dimensions of a texture image, + * the texel format and pointers to Texel Fetch functions. + */ +struct gl_texture_image +{ + GLint InternalFormat; /**< Internal format as given by the user */ + GLenum _BaseFormat; /**< Either GL_RGB, GL_RGBA, GL_ALPHA, + * GL_LUMINANCE, GL_LUMINANCE_ALPHA, + * GL_INTENSITY, GL_DEPTH_COMPONENT or + * GL_DEPTH_STENCIL_EXT only. Used for + * choosing TexEnv arithmetic. + */ + gl_format TexFormat; /**< The actual texture memory format */ + + GLuint Border; /**< 0 or 1 */ + GLuint Width; /**< = 2^WidthLog2 + 2*Border */ + GLuint Height; /**< = 2^HeightLog2 + 2*Border */ + GLuint Depth; /**< = 2^DepthLog2 + 2*Border */ + GLuint Width2; /**< = Width - 2*Border */ + GLuint Height2; /**< = Height - 2*Border */ + GLuint Depth2; /**< = Depth - 2*Border */ + GLuint WidthLog2; /**< = log2(Width2) */ + GLuint HeightLog2; /**< = log2(Height2) */ + GLuint DepthLog2; /**< = log2(Depth2) */ + GLuint MaxLog2; /**< = MAX(WidthLog2, HeightLog2) */ + GLfloat WidthScale; /**< used for mipmap LOD computation */ + GLfloat HeightScale; /**< used for mipmap LOD computation */ + GLfloat DepthScale; /**< used for mipmap LOD computation */ + GLboolean IsClientData; /**< Data owned by client? */ + GLboolean _IsPowerOfTwo; /**< Are all dimensions powers of two? */ + + struct gl_texture_object *TexObject; /**< Pointer back to parent object */ + GLuint Level; /**< Which mipmap level am I? */ + /** Cube map face: index into gl_texture_object::Image[] array */ + GLuint Face; + + FetchTexelFuncC FetchTexelc; /**< GLchan texel fetch function pointer */ + FetchTexelFuncF FetchTexelf; /**< Float texel fetch function pointer */ + + GLuint RowStride; /**< Padded width in units of texels */ + GLuint *ImageOffsets; /**< if 3D texture: array [Depth] of offsets to + each 2D slice in 'Data', in texels */ + GLvoid *Data; /**< Image data, accessed via FetchTexel() */ + + /** + * \name For device driver: + */ + /*@{*/ + void *DriverData; /**< Arbitrary device driver data */ + /*@}*/ +}; + + +/** + * Indexes for cube map faces. + */ +typedef enum +{ + FACE_POS_X = 0, + FACE_NEG_X = 1, + FACE_POS_Y = 2, + FACE_NEG_Y = 3, + FACE_POS_Z = 4, + FACE_NEG_Z = 5, + MAX_FACES = 6 +} gl_face_index; + + +/** + * Sampler object state. These objects are new with GL_ARB_sampler_objects + * and OpenGL 3.3. Legacy texture objects also contain a sampler object. + */ +struct gl_sampler_object +{ + GLuint Name; + GLint RefCount; + + GLenum WrapS; /**< S-axis texture image wrap mode */ + GLenum WrapT; /**< T-axis texture image wrap mode */ + GLenum WrapR; /**< R-axis texture image wrap mode */ + GLenum MinFilter; /**< minification filter */ + GLenum MagFilter; /**< magnification filter */ + union { + GLfloat f[4]; + GLuint ui[4]; + GLint i[4]; + } BorderColor; /**< Interpreted according to texture format */ + GLfloat MinLod; /**< min lambda, OpenGL 1.2 */ + GLfloat MaxLod; /**< max lambda, OpenGL 1.2 */ + GLfloat LodBias; /**< OpenGL 1.4 */ + GLfloat MaxAnisotropy; /**< GL_EXT_texture_filter_anisotropic */ + GLenum CompareMode; /**< GL_ARB_shadow */ + GLenum CompareFunc; /**< GL_ARB_shadow */ + GLfloat CompareFailValue; /**< GL_ARB_shadow_ambient */ + GLenum sRGBDecode; /**< GL_DECODE_EXT or GL_SKIP_DECODE_EXT */ + GLboolean CubeMapSeamless; /**< GL_AMD_seamless_cubemap_per_texture */ + + /* deprecated sampler state */ + GLenum DepthMode; /**< GL_ARB_depth_texture */ + + /** Is the texture object complete with respect to this sampler? */ + GLboolean _CompleteTexture; +}; + + +/** + * Texture object state. Contains the array of mipmap images, border color, + * wrap modes, filter modes, and shadow/texcompare state. + */ +struct gl_texture_object +{ + _glthread_Mutex Mutex; /**< for thread safety */ + GLint RefCount; /**< reference count */ + GLuint Name; /**< the user-visible texture object ID */ + GLenum Target; /**< GL_TEXTURE_1D, GL_TEXTURE_2D, etc. */ + + struct gl_sampler_object Sampler; + + GLfloat Priority; /**< in [0,1] */ + GLint BaseLevel; /**< min mipmap level, OpenGL 1.2 */ + GLint MaxLevel; /**< max mipmap level, OpenGL 1.2 */ + GLint _MaxLevel; /**< actual max mipmap level (q in the spec) */ + GLfloat _MaxLambda; /**< = _MaxLevel - BaseLevel (q - b in spec) */ + GLint CropRect[4]; /**< GL_OES_draw_texture */ + GLenum Swizzle[4]; /**< GL_EXT_texture_swizzle */ + GLuint _Swizzle; /**< same as Swizzle, but SWIZZLE_* format */ + GLboolean GenerateMipmap; /**< GL_SGIS_generate_mipmap */ + GLboolean _Complete; /**< Is texture object complete? */ + GLboolean _RenderToTexture; /**< Any rendering to this texture? */ + GLboolean Purgeable; /**< Is the buffer purgeable under memory pressure? */ + + /** Actual texture images, indexed by [cube face] and [mipmap level] */ + struct gl_texture_image *Image[MAX_FACES][MAX_TEXTURE_LEVELS]; + + /** GL_ARB_texture_buffer_object */ + struct gl_buffer_object *BufferObject; + GLenum BufferObjectFormat; + + /** + * \name For device driver. + * Note: instead of attaching driver data to this pointer, it's preferable + * to instead use this struct as a base class for your own texture object + * class. Driver->NewTextureObject() can be used to implement the + * allocation. + */ + void *DriverData; /**< Arbitrary device driver data */ +}; + + +/** Up to four combiner sources are possible with GL_NV_texture_env_combine4 */ +#define MAX_COMBINER_TERMS 4 + + +/** + * Texture combine environment state. + */ +struct gl_tex_env_combine_state +{ + GLenum ModeRGB; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */ + GLenum ModeA; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */ + /** Source terms: GL_PRIMARY_COLOR, GL_TEXTURE, etc */ + GLenum SourceRGB[MAX_COMBINER_TERMS]; + GLenum SourceA[MAX_COMBINER_TERMS]; + /** Source operands: GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR, etc */ + GLenum OperandRGB[MAX_COMBINER_TERMS]; + GLenum OperandA[MAX_COMBINER_TERMS]; + GLuint ScaleShiftRGB; /**< 0, 1 or 2 */ + GLuint ScaleShiftA; /**< 0, 1 or 2 */ + GLuint _NumArgsRGB; /**< Number of inputs used for the RGB combiner */ + GLuint _NumArgsA; /**< Number of inputs used for the A combiner */ +}; + + +/** + * Texture coord generation state. + */ +struct gl_texgen +{ + GLenum Mode; /**< GL_EYE_LINEAR, GL_SPHERE_MAP, etc */ + GLbitfield _ModeBit; /**< TEXGEN_x bit corresponding to Mode */ + GLfloat ObjectPlane[4]; + GLfloat EyePlane[4]; +}; + + +/** + * Texture unit state. Contains enable flags, texture environment/function/ + * combiners, texgen state, and pointers to current texture objects. + */ +struct gl_texture_unit +{ + GLbitfield Enabled; /**< bitmask of TEXTURE_*_BIT flags */ + GLbitfield _ReallyEnabled; /**< 0 or exactly one of TEXTURE_*_BIT flags */ + + GLenum EnvMode; /**< GL_MODULATE, GL_DECAL, GL_BLEND, etc. */ + GLclampf EnvColor[4]; + GLfloat EnvColorUnclamped[4]; + + struct gl_texgen GenS; + struct gl_texgen GenT; + struct gl_texgen GenR; + struct gl_texgen GenQ; + GLbitfield TexGenEnabled; /**< Bitwise-OR of [STRQ]_BIT values */ + GLbitfield _GenFlags; /**< Bitwise-OR of Gen[STRQ]._ModeBit */ + + GLfloat LodBias; /**< for biasing mipmap levels */ + GLenum BumpTarget; + GLfloat RotMatrix[4]; /* 2x2 matrix */ + + /** Current sampler object (GL_ARB_sampler_objects) */ + struct gl_sampler_object *Sampler; + + /** + * \name GL_EXT_texture_env_combine + */ + struct gl_tex_env_combine_state Combine; + + /** + * Derived state based on \c EnvMode and the \c BaseFormat of the + * currently enabled texture. + */ + struct gl_tex_env_combine_state _EnvMode; + + /** + * Currently enabled combiner state. This will point to either + * \c Combine or \c _EnvMode. + */ + struct gl_tex_env_combine_state *_CurrentCombine; + + /** Current texture object pointers */ + struct gl_texture_object *CurrentTex[NUM_TEXTURE_TARGETS]; + + /** Points to highest priority, complete and enabled texture object */ + struct gl_texture_object *_Current; +}; + + +/** + * Texture attribute group (GL_TEXTURE_BIT). + */ +struct gl_texture_attrib +{ + GLuint CurrentUnit; /**< GL_ACTIVE_TEXTURE */ + struct gl_texture_unit Unit[MAX_COMBINED_TEXTURE_IMAGE_UNITS]; + + struct gl_texture_object *ProxyTex[NUM_TEXTURE_TARGETS]; + + /** GL_ARB_texture_buffer_object */ + struct gl_buffer_object *BufferObject; + + /** GL_ARB_seamless_cubemap */ + GLboolean CubeMapSeamless; + + /** Texture units/samplers used by vertex or fragment texturing */ + GLbitfield _EnabledUnits; + + /** Texture coord units/sets used for fragment texturing */ + GLbitfield _EnabledCoordUnits; + + /** Texture coord units that have texgen enabled */ + GLbitfield _TexGenEnabled; + + /** Texture coord units that have non-identity matrices */ + GLbitfield _TexMatEnabled; + + /** Bitwise-OR of all Texture.Unit[i]._GenFlags */ + GLbitfield _GenFlags; +}; + + +/** + * Transformation attribute group (GL_TRANSFORM_BIT). + */ +struct gl_transform_attrib +{ + GLenum MatrixMode; /**< Matrix mode */ + GLfloat EyeUserPlane[MAX_CLIP_PLANES][4]; /**< User clip planes */ + GLfloat _ClipUserPlane[MAX_CLIP_PLANES][4]; /**< derived */ + GLbitfield ClipPlanesEnabled; /**< on/off bitmask */ + GLboolean Normalize; /**< Normalize all normals? */ + GLboolean RescaleNormals; /**< GL_EXT_rescale_normal */ + GLboolean RasterPositionUnclipped; /**< GL_IBM_rasterpos_clip */ + GLboolean DepthClamp; /**< GL_ARB_depth_clamp */ + + GLfloat CullEyePos[4]; + GLfloat CullObjPos[4]; +}; + + +/** + * Viewport attribute group (GL_VIEWPORT_BIT). + */ +struct gl_viewport_attrib +{ + GLint X, Y; /**< position */ + GLsizei Width, Height; /**< size */ + GLfloat Near, Far; /**< Depth buffer range */ + GLmatrix _WindowMap; /**< Mapping transformation as a matrix. */ +}; + + +/** + * GL_ARB_vertex/pixel_buffer_object buffer object + */ +struct gl_buffer_object +{ + _glthread_Mutex Mutex; + GLint RefCount; + GLuint Name; + GLenum Usage; /**< GL_STREAM_DRAW_ARB, GL_STREAM_READ_ARB, etc. */ + GLsizeiptrARB Size; /**< Size of buffer storage in bytes */ + GLubyte *Data; /**< Location of storage either in RAM or VRAM. */ + /** Fields describing a mapped buffer */ + /*@{*/ + GLbitfield AccessFlags; /**< Mask of GL_MAP_x_BIT flags */ + GLvoid *Pointer; /**< User-space address of mapping */ + GLintptr Offset; /**< Mapped offset */ + GLsizeiptr Length; /**< Mapped length */ + /*@}*/ + GLboolean Written; /**< Ever written to? (for debugging) */ + GLboolean Purgeable; /**< Is the buffer purgeable under memory pressure? */ +}; + + +/** + * Client pixel packing/unpacking attributes + */ +struct gl_pixelstore_attrib +{ + GLint Alignment; + GLint RowLength; + GLint SkipPixels; + GLint SkipRows; + GLint ImageHeight; + GLint SkipImages; + GLboolean SwapBytes; + GLboolean LsbFirst; + GLboolean ClientStorage; /**< GL_APPLE_client_storage */ + GLboolean Invert; /**< GL_MESA_pack_invert */ + struct gl_buffer_object *BufferObj; /**< GL_ARB_pixel_buffer_object */ +}; + + +/** + * Client vertex array attributes + */ +struct gl_client_array +{ + GLint Size; /**< components per element (1,2,3,4) */ + GLenum Type; /**< datatype: GL_FLOAT, GL_INT, etc */ + GLenum Format; /**< default: GL_RGBA, but may be GL_BGRA */ + GLsizei Stride; /**< user-specified stride */ + GLsizei StrideB; /**< actual stride in bytes */ + const GLubyte *Ptr; /**< Points to array data */ + GLboolean Enabled; /**< Enabled flag is a boolean */ + GLboolean Normalized; /**< GL_ARB_vertex_program */ + GLboolean Integer; /**< Integer-valued? */ + GLuint InstanceDivisor; /**< GL_ARB_instanced_arrays */ + GLuint _ElementSize; /**< size of each element in bytes */ + + struct gl_buffer_object *BufferObj;/**< GL_ARB_vertex_buffer_object */ + GLuint _MaxElement; /**< max element index into array buffer + 1 */ +}; + + +/** + * Collection of vertex arrays. Defined by the GL_APPLE_vertex_array_object + * extension, but a nice encapsulation in any case. + */ +struct gl_array_object +{ + /** Name of the array object as received from glGenVertexArrayAPPLE. */ + GLuint Name; + + GLint RefCount; + _glthread_Mutex Mutex; + GLboolean VBOonly; /**< require all arrays to live in VBOs? */ + + /** Conventional vertex arrays */ + /*@{*/ + struct gl_client_array Vertex; + struct gl_client_array Weight; + struct gl_client_array Normal; + struct gl_client_array Color; + struct gl_client_array SecondaryColor; + struct gl_client_array FogCoord; + struct gl_client_array Index; + struct gl_client_array EdgeFlag; + struct gl_client_array TexCoord[MAX_TEXTURE_COORD_UNITS]; + struct gl_client_array PointSize; + /*@}*/ + + /** + * Generic arrays for vertex programs/shaders. + * For NV vertex programs, these attributes alias and take priority + * over the conventional attribs above. For ARB vertex programs and + * GLSL vertex shaders, these attributes are separate. + */ + struct gl_client_array VertexAttrib[MAX_VERTEX_GENERIC_ATTRIBS]; + + /** Mask of _NEW_ARRAY_* values indicating which arrays are enabled */ + GLbitfield _Enabled; + + /** + * Min of all enabled arrays' _MaxElement. When arrays reside inside VBOs + * we can determine the max legal (in bounds) glDrawElements array index. + */ + GLuint _MaxElement; +}; + + +/** + * Vertex array state + */ +struct gl_array_attrib +{ + /** Currently bound array object. See _mesa_BindVertexArrayAPPLE() */ + struct gl_array_object *ArrayObj; + + /** The default vertex array object */ + struct gl_array_object *DefaultArrayObj; + + /** Array objects (GL_ARB/APPLE_vertex_array_object) */ + struct _mesa_HashTable *Objects; + + GLint ActiveTexture; /**< Client Active Texture */ + GLuint LockFirst; /**< GL_EXT_compiled_vertex_array */ + GLuint LockCount; /**< GL_EXT_compiled_vertex_array */ + + /** GL 3.1 (slightly different from GL_NV_primitive_restart) */ + GLboolean PrimitiveRestart; + GLuint RestartIndex; + + GLbitfield NewState; /**< mask of _NEW_ARRAY_* values */ + GLboolean RebindArrays; /**< whether the VBO module should rebind arrays */ + + /* GL_ARB_vertex_buffer_object */ + struct gl_buffer_object *ArrayBufferObj; + struct gl_buffer_object *ElementArrayBufferObj; +}; + + +/** + * Feedback buffer state + */ +struct gl_feedback +{ + GLenum Type; + GLbitfield _Mask; /**< FB_* bits */ + GLfloat *Buffer; + GLuint BufferSize; + GLuint Count; +}; + + +/** + * Selection buffer state + */ +struct gl_selection +{ + GLuint *Buffer; /**< selection buffer */ + GLuint BufferSize; /**< size of the selection buffer */ + GLuint BufferCount; /**< number of values in the selection buffer */ + GLuint Hits; /**< number of records in the selection buffer */ + GLuint NameStackDepth; /**< name stack depth */ + GLuint NameStack[MAX_NAME_STACK_DEPTH]; /**< name stack */ + GLboolean HitFlag; /**< hit flag */ + GLfloat HitMinZ; /**< minimum hit depth */ + GLfloat HitMaxZ; /**< maximum hit depth */ +}; + + +/** + * 1-D Evaluator control points + */ +struct gl_1d_map +{ + GLuint Order; /**< Number of control points */ + GLfloat u1, u2, du; /**< u1, u2, 1.0/(u2-u1) */ + GLfloat *Points; /**< Points to contiguous control points */ +}; + + +/** + * 2-D Evaluator control points + */ +struct gl_2d_map +{ + GLuint Uorder; /**< Number of control points in U dimension */ + GLuint Vorder; /**< Number of control points in V dimension */ + GLfloat u1, u2, du; + GLfloat v1, v2, dv; + GLfloat *Points; /**< Points to contiguous control points */ +}; + + +/** + * All evaluator control point state + */ +struct gl_evaluators +{ + /** + * \name 1-D maps + */ + /*@{*/ + struct gl_1d_map Map1Vertex3; + struct gl_1d_map Map1Vertex4; + struct gl_1d_map Map1Index; + struct gl_1d_map Map1Color4; + struct gl_1d_map Map1Normal; + struct gl_1d_map Map1Texture1; + struct gl_1d_map Map1Texture2; + struct gl_1d_map Map1Texture3; + struct gl_1d_map Map1Texture4; + struct gl_1d_map Map1Attrib[16]; /**< GL_NV_vertex_program */ + /*@}*/ + + /** + * \name 2-D maps + */ + /*@{*/ + struct gl_2d_map Map2Vertex3; + struct gl_2d_map Map2Vertex4; + struct gl_2d_map Map2Index; + struct gl_2d_map Map2Color4; + struct gl_2d_map Map2Normal; + struct gl_2d_map Map2Texture1; + struct gl_2d_map Map2Texture2; + struct gl_2d_map Map2Texture3; + struct gl_2d_map Map2Texture4; + struct gl_2d_map Map2Attrib[16]; /**< GL_NV_vertex_program */ + /*@}*/ +}; + + +/** + * Names of the various vertex/fragment program register files, etc. + * + * NOTE: first four tokens must fit into 2 bits (see t_vb_arbprogram.c) + * All values should fit in a 4-bit field. + * + * NOTE: PROGRAM_ENV_PARAM, PROGRAM_STATE_VAR, PROGRAM_NAMED_PARAM, + * PROGRAM_CONSTANT, and PROGRAM_UNIFORM can all be considered to + * be "uniform" variables since they can only be set outside glBegin/End. + * They're also all stored in the same Parameters array. + */ +typedef enum +{ + PROGRAM_TEMPORARY, /**< machine->Temporary[] */ + PROGRAM_INPUT, /**< machine->Inputs[] */ + PROGRAM_OUTPUT, /**< machine->Outputs[] */ + PROGRAM_VARYING, /**< machine->Inputs[]/Outputs[] */ + PROGRAM_LOCAL_PARAM, /**< gl_program->LocalParams[] */ + PROGRAM_ENV_PARAM, /**< gl_program->Parameters[] */ + PROGRAM_STATE_VAR, /**< gl_program->Parameters[] */ + PROGRAM_NAMED_PARAM, /**< gl_program->Parameters[] */ + PROGRAM_CONSTANT, /**< gl_program->Parameters[] */ + PROGRAM_UNIFORM, /**< gl_program->Parameters[] */ + PROGRAM_WRITE_ONLY, /**< A dummy, write-only register */ + PROGRAM_ADDRESS, /**< machine->AddressReg */ + PROGRAM_SAMPLER, /**< for shader samplers, compile-time only */ + PROGRAM_SYSTEM_VALUE,/**< InstanceId, PrimitiveID, etc. */ + PROGRAM_UNDEFINED, /**< Invalid/TBD value */ + PROGRAM_FILE_MAX +} gl_register_file; + + +/** + * If the register file is PROGRAM_SYSTEM_VALUE, the register index will be + * one of these values. + */ +typedef enum +{ + SYSTEM_VALUE_FRONT_FACE, /**< Fragment shader only (not done yet) */ + SYSTEM_VALUE_INSTANCE_ID, /**< Vertex shader only */ + SYSTEM_VALUE_MAX /**< Number of values */ +} gl_system_value; + + +/** Vertex and fragment instructions */ +struct prog_instruction; +struct gl_program_parameter_list; +struct gl_uniform_list; + + +/** + * Base class for any kind of program object + */ +struct gl_program +{ + GLuint Id; + GLubyte *String; /**< Null-terminated program text */ + GLint RefCount; + GLenum Target; /**< GL_VERTEX/FRAGMENT_PROGRAM_ARB, GL_FRAGMENT_PROGRAM_NV */ + GLenum Format; /**< String encoding format */ + GLboolean Resident; + + struct prog_instruction *Instructions; + + GLbitfield InputsRead; /**< Bitmask of which input regs are read */ + GLbitfield64 OutputsWritten; /**< Bitmask of which output regs are written */ + GLbitfield SystemValuesRead; /**< Bitmask of SYSTEM_VALUE_x inputs used */ + GLbitfield InputFlags[MAX_PROGRAM_INPUTS]; /**< PROG_PARAM_BIT_x flags */ + GLbitfield OutputFlags[MAX_PROGRAM_OUTPUTS]; /**< PROG_PARAM_BIT_x flags */ + GLbitfield TexturesUsed[MAX_COMBINED_TEXTURE_IMAGE_UNITS]; /**< TEXTURE_x_BIT bitmask */ + GLbitfield SamplersUsed; /**< Bitfield of which samplers are used */ + GLbitfield ShadowSamplers; /**< Texture units used for shadow sampling. */ + + + /** Named parameters, constants, etc. from program text */ + struct gl_program_parameter_list *Parameters; + /** Numbered local parameters */ + GLfloat LocalParams[MAX_PROGRAM_LOCAL_PARAMS][4]; + + /** Vertex/fragment shader varying vars */ + struct gl_program_parameter_list *Varying; + /** Vertex program user-defined attributes */ + struct gl_program_parameter_list *Attributes; + + /** Map from sampler unit to texture unit (set by glUniform1i()) */ + GLubyte SamplerUnits[MAX_SAMPLERS]; + /** Which texture target is being sampled (TEXTURE_1D/2D/3D/etc_INDEX) */ + gl_texture_index SamplerTargets[MAX_SAMPLERS]; + + /** Bitmask of which register files are read/written with indirect + * addressing. Mask of (1 << PROGRAM_x) bits. + */ + GLbitfield IndirectRegisterFiles; + + /** Logical counts */ + /*@{*/ + GLuint NumInstructions; + GLuint NumTemporaries; + GLuint NumParameters; + GLuint NumAttributes; + GLuint NumAddressRegs; + GLuint NumAluInstructions; + GLuint NumTexInstructions; + GLuint NumTexIndirections; + /*@}*/ + /** Native, actual h/w counts */ + /*@{*/ + GLuint NumNativeInstructions; + GLuint NumNativeTemporaries; + GLuint NumNativeParameters; + GLuint NumNativeAttributes; + GLuint NumNativeAddressRegs; + GLuint NumNativeAluInstructions; + GLuint NumNativeTexInstructions; + GLuint NumNativeTexIndirections; + /*@}*/ +}; + + +/** Vertex program object */ +struct gl_vertex_program +{ + struct gl_program Base; /**< base class */ + GLboolean IsNVProgram; /**< is this a GL_NV_vertex_program program? */ + GLboolean IsPositionInvariant; +}; + + +/** Geometry program object */ +struct gl_geometry_program +{ + struct gl_program Base; /**< base class */ + + GLint VerticesOut; + GLenum InputType; /**< GL_POINTS, GL_LINES, GL_LINES_ADJACENCY_ARB, + GL_TRIANGLES, or GL_TRIANGLES_ADJACENCY_ARB */ + GLenum OutputType; /**< GL_POINTS, GL_LINE_STRIP or GL_TRIANGLE_STRIP */ +}; + + +/** Fragment program object */ +struct gl_fragment_program +{ + struct gl_program Base; /**< base class */ + GLboolean UsesKill; /**< shader uses KIL instruction */ + GLboolean OriginUpperLeft; + GLboolean PixelCenterInteger; + enum gl_frag_depth_layout FragDepthLayout; +}; + + +/** + * State common to vertex and fragment programs. + */ +struct gl_program_state +{ + GLint ErrorPos; /* GL_PROGRAM_ERROR_POSITION_ARB/NV */ + const char *ErrorString; /* GL_PROGRAM_ERROR_STRING_ARB/NV */ +}; + + +/** + * Context state for vertex programs. + */ +struct gl_vertex_program_state +{ + GLboolean Enabled; /**< User-set GL_VERTEX_PROGRAM_ARB/NV flag */ + GLboolean _Enabled; /**< Enabled and _valid_ user program? */ + GLboolean PointSizeEnabled; /**< GL_VERTEX_PROGRAM_POINT_SIZE_ARB/NV */ + GLboolean TwoSideEnabled; /**< GL_VERTEX_PROGRAM_TWO_SIDE_ARB/NV */ + struct gl_vertex_program *Current; /**< User-bound vertex program */ + + /** Currently enabled and valid vertex program (including internal + * programs, user-defined vertex programs and GLSL vertex shaders). + * This is the program we must use when rendering. + */ + struct gl_vertex_program *_Current; + + GLfloat Parameters[MAX_PROGRAM_ENV_PARAMS][4]; /**< Env params */ + + /* For GL_NV_vertex_program only: */ + GLenum TrackMatrix[MAX_PROGRAM_ENV_PARAMS / 4]; + GLenum TrackMatrixTransform[MAX_PROGRAM_ENV_PARAMS / 4]; + + /** Should fixed-function T&L be implemented with a vertex prog? */ + GLboolean _MaintainTnlProgram; + + /** Program to emulate fixed-function T&L (see above) */ + struct gl_vertex_program *_TnlProgram; + + /** Cache of fixed-function programs */ + struct gl_program_cache *Cache; + + GLboolean _Overriden; +}; + + +/** + * Context state for geometry programs. + */ +struct gl_geometry_program_state +{ + GLboolean Enabled; /**< GL_ARB_GEOMETRY_SHADER4 */ + GLboolean _Enabled; /**< Enabled and valid program? */ + struct gl_geometry_program *Current; /**< user-bound geometry program */ + + /** Currently enabled and valid program (including internal programs + * and compiled shader programs). + */ + struct gl_geometry_program *_Current; + + GLfloat Parameters[MAX_PROGRAM_ENV_PARAMS][4]; /**< Env params */ + + /** Cache of fixed-function programs */ + struct gl_program_cache *Cache; +}; + +/** + * Context state for fragment programs. + */ +struct gl_fragment_program_state +{ + GLboolean Enabled; /**< User-set fragment program enable flag */ + GLboolean _Enabled; /**< Enabled and _valid_ user program? */ + struct gl_fragment_program *Current; /**< User-bound fragment program */ + + /** Currently enabled and valid fragment program (including internal + * programs, user-defined fragment programs and GLSL fragment shaders). + * This is the program we must use when rendering. + */ + struct gl_fragment_program *_Current; + + GLfloat Parameters[MAX_PROGRAM_ENV_PARAMS][4]; /**< Env params */ + + /** Should fixed-function texturing be implemented with a fragment prog? */ + GLboolean _MaintainTexEnvProgram; + + /** Program to emulate fixed-function texture env/combine (see above) */ + struct gl_fragment_program *_TexEnvProgram; + + /** Cache of fixed-function programs */ + struct gl_program_cache *Cache; +}; + + +/** + * ATI_fragment_shader runtime state + */ +#define ATI_FS_INPUT_PRIMARY 0 +#define ATI_FS_INPUT_SECONDARY 1 + +struct atifs_instruction; +struct atifs_setupinst; + +/** + * ATI fragment shader + */ +struct ati_fragment_shader +{ + GLuint Id; + GLint RefCount; + struct atifs_instruction *Instructions[2]; + struct atifs_setupinst *SetupInst[2]; + GLfloat Constants[8][4]; + GLbitfield LocalConstDef; /**< Indicates which constants have been set */ + GLubyte numArithInstr[2]; + GLubyte regsAssigned[2]; + GLubyte NumPasses; /**< 1 or 2 */ + GLubyte cur_pass; + GLubyte last_optype; + GLboolean interpinp1; + GLboolean isValid; + GLuint swizzlerq; +}; + +/** + * Context state for GL_ATI_fragment_shader + */ +struct gl_ati_fragment_shader_state +{ + GLboolean Enabled; + GLboolean _Enabled; /**< enabled and valid shader? */ + GLboolean Compiling; + GLfloat GlobalConstants[8][4]; + struct ati_fragment_shader *Current; +}; + + +/** + * Occlusion/timer query object. + */ +struct gl_query_object +{ + GLenum Target; /**< The query target, when active */ + GLuint Id; /**< hash table ID/name */ + GLuint64EXT Result; /**< the counter */ + GLboolean Active; /**< inside Begin/EndQuery */ + GLboolean Ready; /**< result is ready? */ +}; + + +/** + * Context state for query objects. + */ +struct gl_query_state +{ + struct _mesa_HashTable *QueryObjects; + struct gl_query_object *CurrentOcclusionObject; /* GL_ARB_occlusion_query */ + struct gl_query_object *CurrentTimerObject; /* GL_EXT_timer_query */ + + /** GL_NV_conditional_render */ + struct gl_query_object *CondRenderQuery; + + /** GL_EXT_transform_feedback */ + struct gl_query_object *PrimitivesGenerated; + struct gl_query_object *PrimitivesWritten; + + /** GL_ARB_timer_query */ + struct gl_query_object *TimeElapsed; + + GLenum CondRenderMode; +}; + + +/** Sync object state */ +struct gl_sync_object { + struct simple_node link; + GLenum Type; /**< GL_SYNC_FENCE */ + GLuint Name; /**< Fence name */ + GLint RefCount; /**< Reference count */ + GLboolean DeletePending; /**< Object was deleted while there were still + * live references (e.g., sync not yet finished) + */ + GLenum SyncCondition; + GLbitfield Flags; /**< Flags passed to glFenceSync */ + GLuint StatusFlag:1; /**< Has the sync object been signaled? */ +}; + + +/** Set by #pragma directives */ +struct gl_sl_pragmas +{ + GLboolean IgnoreOptimize; /**< ignore #pragma optimize(on/off) ? */ + GLboolean IgnoreDebug; /**< ignore #pragma debug(on/off) ? */ + GLboolean Optimize; /**< defaults on */ + GLboolean Debug; /**< defaults off */ +}; + + +/** + * A GLSL vertex or fragment shader object. + */ +struct gl_shader +{ + GLenum Type; /**< GL_FRAGMENT_SHADER || GL_VERTEX_SHADER || GL_GEOMETRY_SHADER_ARB (first field!) */ + GLuint Name; /**< AKA the handle */ + GLint RefCount; /**< Reference count */ + GLboolean DeletePending; + GLboolean CompileStatus; + const GLchar *Source; /**< Source code string */ + GLuint SourceChecksum; /**< for debug/logging purposes */ + struct gl_program *Program; /**< Post-compile assembly code */ + GLchar *InfoLog; + struct gl_sl_pragmas Pragmas; + + unsigned Version; /**< GLSL version used for linking */ + + struct exec_list *ir; + struct glsl_symbol_table *symbols; + + /** Shaders containing built-in functions that are used for linking. */ + struct gl_shader *builtins_to_link[16]; + unsigned num_builtins_to_link; +}; + + +/** + * A GLSL program object. + * Basically a linked collection of vertex and fragment shaders. + */ +struct gl_shader_program +{ + GLenum Type; /**< Always GL_SHADER_PROGRAM (internal token) */ + GLuint Name; /**< aka handle or ID */ + GLint RefCount; /**< Reference count */ + GLboolean DeletePending; + + GLuint NumShaders; /**< number of attached shaders */ + struct gl_shader **Shaders; /**< List of attached the shaders */ + + /** User-defined attribute bindings (glBindAttribLocation) */ + struct gl_program_parameter_list *Attributes; + + /** Transform feedback varyings */ + struct { + GLenum BufferMode; + GLuint NumVarying; + GLchar **VaryingNames; /**< Array [NumVarying] of char * */ + } TransformFeedback; + + /** Geometry shader state - copied into gl_geometry_program at link time */ + struct { + GLint VerticesOut; + GLenum InputType; /**< GL_POINTS, GL_LINES, GL_LINES_ADJACENCY_ARB, + GL_TRIANGLES, or GL_TRIANGLES_ADJACENCY_ARB */ + GLenum OutputType; /**< GL_POINTS, GL_LINE_STRIP or GL_TRIANGLE_STRIP */ + } Geom; + + /* post-link info: */ + struct gl_vertex_program *VertexProgram; /**< Linked vertex program */ + struct gl_fragment_program *FragmentProgram; /**< Linked fragment prog */ + struct gl_geometry_program *GeometryProgram; /**< Linked geometry prog */ + struct gl_uniform_list *Uniforms; + struct gl_program_parameter_list *Varying; + GLboolean LinkStatus; /**< GL_LINK_STATUS */ + GLboolean Validated; + GLboolean _Used; /**< Ever used for drawing? */ + GLchar *InfoLog; + + unsigned Version; /**< GLSL version used for linking */ + + /** + * Per-stage shaders resulting from the first stage of linking. + * + * Set of linked shaders for this program. The array is accessed using the + * \c MESA_SHADER_* defines. Entries for non-existent stages will be + * \c NULL. + */ + struct gl_shader *_LinkedShaders[MESA_SHADER_TYPES]; +}; + + +#define GLSL_DUMP 0x1 /**< Dump shaders to stdout */ +#define GLSL_LOG 0x2 /**< Write shaders to files */ +#define GLSL_OPT 0x4 /**< Force optimizations (override pragmas) */ +#define GLSL_NO_OPT 0x8 /**< Force no optimizations (override pragmas) */ +#define GLSL_UNIFORMS 0x10 /**< Print glUniform calls */ +#define GLSL_NOP_VERT 0x20 /**< Force no-op vertex shaders */ +#define GLSL_NOP_FRAG 0x40 /**< Force no-op fragment shaders */ +#define GLSL_USE_PROG 0x80 /**< Log glUseProgram calls */ + + +/** + * Context state for GLSL vertex/fragment shaders. + */ +struct gl_shader_state +{ + /** + * Programs used for rendering + * + * There is a separate program set for each shader stage. If + * GL_EXT_separate_shader_objects is not supported, each of these must point + * to \c NULL or to the same program. + */ + struct gl_shader_program *CurrentVertexProgram; + struct gl_shader_program *CurrentGeometryProgram; + struct gl_shader_program *CurrentFragmentProgram; + + /** + * Program used by glUniform calls. + * + * Explicitly set by \c glUseProgram and \c glActiveProgramEXT. + */ + struct gl_shader_program *ActiveProgram; + + GLbitfield Flags; /**< Mask of GLSL_x flags */ +}; + +/** + * Compiler options for a single GLSL shaders type + */ +struct gl_shader_compiler_options +{ + /** Driver-selectable options: */ + GLboolean EmitCondCodes; /**< Use condition codes? */ + GLboolean EmitNVTempInitialization; /**< 0-fill NV temp registers */ + GLboolean EmitNoLoops; + GLboolean EmitNoFunctions; + GLboolean EmitNoCont; /**< Emit CONT opcode? */ + GLboolean EmitNoMainReturn; /**< Emit CONT/RET opcodes? */ + GLboolean EmitNoNoise; /**< Emit NOISE opcodes? */ + GLboolean EmitNoPow; /**< Emit POW opcodes? */ + + /** + * \name Forms of indirect addressing the driver cannot do. + */ + /*@{*/ + GLboolean EmitNoIndirectInput; /**< No indirect addressing of inputs */ + GLboolean EmitNoIndirectOutput; /**< No indirect addressing of outputs */ + GLboolean EmitNoIndirectTemp; /**< No indirect addressing of temps */ + GLboolean EmitNoIndirectUniform; /**< No indirect addressing of constants */ + /*@}*/ + + GLuint MaxIfDepth; /**< Maximum nested IF blocks */ + GLuint MaxUnrollIterations; + + struct gl_sl_pragmas DefaultPragmas; /**< Default #pragma settings */ +}; + +/** + * Transform feedback object state + */ +struct gl_transform_feedback_object +{ + GLuint Name; /**< AKA the object ID */ + GLint RefCount; + GLboolean Active; /**< Is transform feedback enabled? */ + GLboolean Paused; /**< Is transform feedback paused? */ + + /** The feedback buffers */ + GLuint BufferNames[MAX_FEEDBACK_ATTRIBS]; + struct gl_buffer_object *Buffers[MAX_FEEDBACK_ATTRIBS]; + + /** Start of feedback data in dest buffer */ + GLintptr Offset[MAX_FEEDBACK_ATTRIBS]; + /** Max data to put into dest buffer (in bytes) */ + GLsizeiptr Size[MAX_FEEDBACK_ATTRIBS]; +}; + + +/** + * Context state for transform feedback. + */ +struct gl_transform_feedback +{ + GLenum Mode; /**< GL_POINTS, GL_LINES or GL_TRIANGLES */ + + GLboolean RasterDiscard; /**< GL_RASTERIZER_DISCARD */ + + /** The general binding point (GL_TRANSFORM_FEEDBACK_BUFFER) */ + struct gl_buffer_object *CurrentBuffer; + + /** The table of all transform feedback objects */ + struct _mesa_HashTable *Objects; + + /** The current xform-fb object (GL_TRANSFORM_FEEDBACK_BINDING) */ + struct gl_transform_feedback_object *CurrentObject; + + /** The default xform-fb object (Name==0) */ + struct gl_transform_feedback_object *DefaultObject; +}; + + + +/** + * State which can be shared by multiple contexts: + */ +struct gl_shared_state +{ + _glthread_Mutex Mutex; /**< for thread safety */ + GLint RefCount; /**< Reference count */ + struct _mesa_HashTable *DisplayList; /**< Display lists hash table */ + struct _mesa_HashTable *TexObjects; /**< Texture objects hash table */ + + /** Default texture objects (shared by all texture units) */ + struct gl_texture_object *DefaultTex[NUM_TEXTURE_TARGETS]; + + /** Fallback texture used when a bound texture is incomplete */ + struct gl_texture_object *FallbackTex; + + /** + * \name Thread safety and statechange notification for texture + * objects. + * + * \todo Improve the granularity of locking. + */ + /*@{*/ + _glthread_Mutex TexMutex; /**< texobj thread safety */ + GLuint TextureStateStamp; /**< state notification for shared tex */ + /*@}*/ + + /** Default buffer object for vertex arrays that aren't in VBOs */ + struct gl_buffer_object *NullBufferObj; + + /** + * \name Vertex/geometry/fragment programs + */ + /*@{*/ + struct _mesa_HashTable *Programs; /**< All vertex/fragment programs */ + struct gl_vertex_program *DefaultVertexProgram; + struct gl_fragment_program *DefaultFragmentProgram; + struct gl_geometry_program *DefaultGeometryProgram; + /*@}*/ + + /* GL_ATI_fragment_shader */ + struct _mesa_HashTable *ATIShaders; + struct ati_fragment_shader *DefaultFragmentShader; + + struct _mesa_HashTable *BufferObjects; + + /** Table of both gl_shader and gl_shader_program objects */ + struct _mesa_HashTable *ShaderObjects; + + /* GL_EXT_framebuffer_object */ + struct _mesa_HashTable *RenderBuffers; + struct _mesa_HashTable *FrameBuffers; + + /* GL_ARB_sync */ + struct simple_node SyncObjects; + + /** GL_ARB_sampler_objects */ + struct _mesa_HashTable *SamplerObjects; + + void *DriverData; /**< Device driver shared state */ +}; + + + + +/** + * A renderbuffer stores colors or depth values or stencil values. + * A framebuffer object will have a collection of these. + * Data are read/written to the buffer with a handful of Get/Put functions. + * + * Instances of this object are allocated with the Driver's NewRenderbuffer + * hook. Drivers will likely wrap this class inside a driver-specific + * class to simulate inheritance. + */ +struct gl_renderbuffer +{ + _glthread_Mutex Mutex; /**< for thread safety */ + GLuint ClassID; /**< Useful for drivers */ + GLuint Name; + GLint RefCount; + GLuint Width, Height; + GLint RowStride; /**< Padded width in units of pixels */ + GLboolean Purgeable; /**< Is the buffer purgeable under memory pressure? */ + + GLboolean AttachedAnytime; /**< TRUE if it was attached to a framebuffer */ + + GLubyte NumSamples; + + GLenum InternalFormat; /**< The user-specified format */ + GLenum _BaseFormat; /**< Either GL_RGB, GL_RGBA, GL_DEPTH_COMPONENT or + GL_STENCIL_INDEX. */ + gl_format Format; /**< The actual renderbuffer memory format */ + + GLenum DataType; /**< Type of values passed to the Get/Put functions */ + GLvoid *Data; /**< This may not be used by some kinds of RBs */ + + /* Used to wrap one renderbuffer around another: */ + struct gl_renderbuffer *Wrapped; + + /* Delete this renderbuffer */ + void (*Delete)(struct gl_renderbuffer *rb); + + /* Allocate new storage for this renderbuffer */ + GLboolean (*AllocStorage)(struct gl_context *ctx, struct gl_renderbuffer *rb, + GLenum internalFormat, + GLuint width, GLuint height); + + /* Lock/Unlock are called before/after calling the Get/Put functions. + * Not sure this is the right place for these yet. + void (*Lock)(struct gl_context *ctx, struct gl_renderbuffer *rb); + void (*Unlock)(struct gl_context *ctx, struct gl_renderbuffer *rb); + */ + + /* Return a pointer to the element/pixel at (x,y). + * Should return NULL if the buffer memory can't be directly addressed. + */ + void *(*GetPointer)(struct gl_context *ctx, struct gl_renderbuffer *rb, + GLint x, GLint y); + + /* Get/Read a row of values. + * The values will be of format _BaseFormat and type DataType. + */ + void (*GetRow)(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + GLint x, GLint y, void *values); + + /* Get/Read values at arbitrary locations. + * The values will be of format _BaseFormat and type DataType. + */ + void (*GetValues)(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + const GLint x[], const GLint y[], void *values); + + /* Put/Write a row of values. + * The values will be of format _BaseFormat and type DataType. + */ + void (*PutRow)(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + GLint x, GLint y, const void *values, const GLubyte *mask); + + /* Put/Write a row of RGB values. This is a special-case routine that's + * only used for RGBA renderbuffers when the source data is GL_RGB. That's + * a common case for glDrawPixels and some triangle routines. + * The values will be of format GL_RGB and type DataType. + */ + void (*PutRowRGB)(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + GLint x, GLint y, const void *values, const GLubyte *mask); + + + /* Put/Write a row of identical values. + * The values will be of format _BaseFormat and type DataType. + */ + void (*PutMonoRow)(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + GLint x, GLint y, const void *value, const GLubyte *mask); + + /* Put/Write values at arbitrary locations. + * The values will be of format _BaseFormat and type DataType. + */ + void (*PutValues)(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + const GLint x[], const GLint y[], const void *values, + const GLubyte *mask); + /* Put/Write identical values at arbitrary locations. + * The values will be of format _BaseFormat and type DataType. + */ + void (*PutMonoValues)(struct gl_context *ctx, struct gl_renderbuffer *rb, + GLuint count, const GLint x[], const GLint y[], + const void *value, const GLubyte *mask); +}; + + +/** + * A renderbuffer attachment points to either a texture object (and specifies + * a mipmap level, cube face or 3D texture slice) or points to a renderbuffer. + */ +struct gl_renderbuffer_attachment +{ + GLenum Type; /**< \c GL_NONE or \c GL_TEXTURE or \c GL_RENDERBUFFER_EXT */ + GLboolean Complete; + + /** + * If \c Type is \c GL_RENDERBUFFER_EXT, this stores a pointer to the + * application supplied renderbuffer object. + */ + struct gl_renderbuffer *Renderbuffer; + + /** + * If \c Type is \c GL_TEXTURE, this stores a pointer to the application + * supplied texture object. + */ + struct gl_texture_object *Texture; + GLuint TextureLevel; /**< Attached mipmap level. */ + GLuint CubeMapFace; /**< 0 .. 5, for cube map textures. */ + GLuint Zoffset; /**< Slice for 3D textures, or layer for both 1D + * and 2D array textures */ +}; + + +/** + * A framebuffer is a collection of renderbuffers (color, depth, stencil, etc). + * In C++ terms, think of this as a base class from which device drivers + * will make derived classes. + */ +struct gl_framebuffer +{ + _glthread_Mutex Mutex; /**< for thread safety */ + /** + * If zero, this is a window system framebuffer. If non-zero, this + * is a FBO framebuffer; note that for some devices (i.e. those with + * a natural pixel coordinate system for FBOs that differs from the + * OpenGL/Mesa coordinate system), this means that the viewport, + * polygon face orientation, and polygon stipple will have to be inverted. + */ + GLuint Name; + + GLint RefCount; + GLboolean DeletePending; + + /** + * The framebuffer's visual. Immutable if this is a window system buffer. + * Computed from attachments if user-made FBO. + */ + struct gl_config Visual; + + GLboolean Initialized; + + GLuint Width, Height; /**< size of frame buffer in pixels */ + + /** \name Drawing bounds (Intersection of buffer size and scissor box) */ + /*@{*/ + GLint _Xmin, _Xmax; /**< inclusive */ + GLint _Ymin, _Ymax; /**< exclusive */ + /*@}*/ + + /** \name Derived Z buffer stuff */ + /*@{*/ + GLuint _DepthMax; /**< Max depth buffer value */ + GLfloat _DepthMaxF; /**< Float max depth buffer value */ + GLfloat _MRD; /**< minimum resolvable difference in Z values */ + /*@}*/ + + /** One of the GL_FRAMEBUFFER_(IN)COMPLETE_* tokens */ + GLenum _Status; + + /** Integer color values */ + GLboolean _IntegerColor; + + /** Array of all renderbuffer attachments, indexed by BUFFER_* tokens. */ + struct gl_renderbuffer_attachment Attachment[BUFFER_COUNT]; + + /* In unextended OpenGL these vars are part of the GL_COLOR_BUFFER + * attribute group and GL_PIXEL attribute group, respectively. + */ + GLenum ColorDrawBuffer[MAX_DRAW_BUFFERS]; + GLenum ColorReadBuffer; + + /** Computed from ColorDraw/ReadBuffer above */ + GLuint _NumColorDrawBuffers; + GLint _ColorDrawBufferIndexes[MAX_DRAW_BUFFERS]; /**< BUFFER_x or -1 */ + GLint _ColorReadBufferIndex; /* -1 = None */ + struct gl_renderbuffer *_ColorDrawBuffers[MAX_DRAW_BUFFERS]; + struct gl_renderbuffer *_ColorReadBuffer; + + /** The Actual depth/stencil buffers to use. May be wrappers around the + * depth/stencil buffers attached above. */ + struct gl_renderbuffer *_DepthBuffer; + struct gl_renderbuffer *_StencilBuffer; + + /** Delete this framebuffer */ + void (*Delete)(struct gl_framebuffer *fb); +}; + + +/** + * Precision info for shader datatypes. See glGetShaderPrecisionFormat(). + */ +struct gl_precision +{ + GLushort RangeMin; /**< min value exponent */ + GLushort RangeMax; /**< max value exponent */ + GLushort Precision; /**< number of mantissa bits */ +}; + + +/** + * Limits for vertex, geometry and fragment programs/shaders. + */ +struct gl_program_constants +{ + /* logical limits */ + GLuint MaxInstructions; + GLuint MaxAluInstructions; + GLuint MaxTexInstructions; + GLuint MaxTexIndirections; + GLuint MaxAttribs; + GLuint MaxTemps; + GLuint MaxAddressRegs; + GLuint MaxAddressOffset; /**< [-MaxAddressOffset, MaxAddressOffset-1] */ + GLuint MaxParameters; + GLuint MaxLocalParams; + GLuint MaxEnvParams; + /* native/hardware limits */ + GLuint MaxNativeInstructions; + GLuint MaxNativeAluInstructions; + GLuint MaxNativeTexInstructions; + GLuint MaxNativeTexIndirections; + GLuint MaxNativeAttribs; + GLuint MaxNativeTemps; + GLuint MaxNativeAddressRegs; + GLuint MaxNativeParameters; + /* For shaders */ + GLuint MaxUniformComponents; /**< Usually == MaxParameters * 4 */ + /* ES 2.0 and GL_ARB_ES2_compatibility */ + struct gl_precision LowFloat, MediumFloat, HighFloat; + struct gl_precision LowInt, MediumInt, HighInt; +}; + + +/** + * Constants which may be overridden by device driver during context creation + * but are never changed after that. + */ +struct gl_constants +{ + GLint MaxTextureMbytes; /**< Max memory per image, in MB */ + GLint MaxTextureLevels; /**< Max mipmap levels. */ + GLint Max3DTextureLevels; /**< Max mipmap levels for 3D textures */ + GLint MaxCubeTextureLevels; /**< Max mipmap levels for cube textures */ + GLint MaxArrayTextureLayers; /**< Max layers in array textures */ + GLint MaxTextureRectSize; /**< Max rectangle texture size, in pixes */ + GLuint MaxTextureCoordUnits; + GLuint MaxTextureImageUnits; + GLuint MaxVertexTextureImageUnits; + GLuint MaxCombinedTextureImageUnits; + GLuint MaxGeometryTextureImageUnits; + GLuint MaxTextureUnits; /**< = MIN(CoordUnits, ImageUnits) */ + GLfloat MaxTextureMaxAnisotropy; /**< GL_EXT_texture_filter_anisotropic */ + GLfloat MaxTextureLodBias; /**< GL_EXT_texture_lod_bias */ + GLuint MaxTextureBufferSize; /**< GL_ARB_texture_buffer_object */ + + GLuint MaxArrayLockSize; + + GLint SubPixelBits; + + GLfloat MinPointSize, MaxPointSize; /**< aliased */ + GLfloat MinPointSizeAA, MaxPointSizeAA; /**< antialiased */ + GLfloat PointSizeGranularity; + GLfloat MinLineWidth, MaxLineWidth; /**< aliased */ + GLfloat MinLineWidthAA, MaxLineWidthAA; /**< antialiased */ + GLfloat LineWidthGranularity; + + GLuint MaxColorTableSize; + + GLuint MaxClipPlanes; + GLuint MaxLights; + GLfloat MaxShininess; /**< GL_NV_light_max_exponent */ + GLfloat MaxSpotExponent; /**< GL_NV_light_max_exponent */ + + GLuint MaxViewportWidth, MaxViewportHeight; + + struct gl_program_constants VertexProgram; /**< GL_ARB_vertex_program */ + struct gl_program_constants FragmentProgram; /**< GL_ARB_fragment_program */ + struct gl_program_constants GeometryProgram; /**< GL_ARB_geometry_shader4 */ + GLuint MaxProgramMatrices; + GLuint MaxProgramMatrixStackDepth; + + /** vertex array / buffer object bounds checking */ + GLboolean CheckArrayBounds; + + GLuint MaxDrawBuffers; /**< GL_ARB_draw_buffers */ + + GLuint MaxColorAttachments; /**< GL_EXT_framebuffer_object */ + GLuint MaxRenderbufferSize; /**< GL_EXT_framebuffer_object */ + GLuint MaxSamples; /**< GL_ARB_framebuffer_object */ + + /** Number of varying vectors between vertex and fragment shaders */ + GLuint MaxVarying; + GLuint MaxVertexVaryingComponents; /**< Between vert and geom shader */ + GLuint MaxGeometryVaryingComponents; /**< Between geom and frag shader */ + + /** GL_ARB_geometry_shader4 */ + GLuint MaxGeometryOutputVertices; + GLuint MaxGeometryTotalOutputComponents; + + GLuint GLSLVersion; /**< GLSL version supported (ex: 120 = 1.20) */ + + /** + * Does the driver support real 32-bit integers? (Otherwise, integers are + * simulated via floats.) + */ + GLboolean NativeIntegers; + + /** + * If the driver supports real 32-bit integers, what integer value should be + * used for boolean true in uniform uploads? (Usually 1 or ~0.) + */ + GLuint UniformBooleanTrue; + + /** Which texture units support GL_ATI_envmap_bumpmap as targets */ + GLbitfield SupportedBumpUnits; + + /** + * Maximum amount of time, measured in nanseconds, that the server can wait. + */ + GLuint64 MaxServerWaitTimeout; + + /** GL_EXT_provoking_vertex */ + GLboolean QuadsFollowProvokingVertexConvention; + + /** OpenGL version 3.0 */ + GLbitfield ContextFlags; /**< Ex: GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT */ + + /** OpenGL version 3.2 */ + GLbitfield ProfileMask; /**< Mask of CONTEXT_x_PROFILE_BIT */ + + /** GL_EXT_transform_feedback */ + GLuint MaxTransformFeedbackSeparateAttribs; + GLuint MaxTransformFeedbackSeparateComponents; + GLuint MaxTransformFeedbackInterleavedComponents; + + /** GL_EXT_gpu_shader4 */ + GLint MinProgramTexelOffset, MaxProgramTexelOffset; + + /* GL_EXT_framebuffer_sRGB */ + GLboolean sRGBCapable; /* can enable sRGB blend/update on FBOs */ + + /* GL_ARB_robustness */ + GLenum ResetStrategy; +}; + + +/** + * Enable flag for each OpenGL extension. Different device drivers will + * enable different extensions at runtime. + */ +struct gl_extensions +{ + GLboolean dummy; /* don't remove this! */ + GLboolean dummy_true; /* Set true by _mesa_init_extensions(). */ + GLboolean dummy_false; /* Set false by _mesa_init_extensions(). */ + GLboolean ARB_ES2_compatibility; + GLboolean ARB_blend_func_extended; + GLboolean ARB_color_buffer_float; + GLboolean ARB_copy_buffer; + GLboolean ARB_depth_buffer_float; + GLboolean ARB_depth_clamp; + GLboolean ARB_depth_texture; + GLboolean ARB_draw_buffers; + GLboolean ARB_draw_buffers_blend; + GLboolean ARB_draw_elements_base_vertex; + GLboolean ARB_draw_instanced; + GLboolean ARB_fragment_coord_conventions; + GLboolean ARB_fragment_program; + GLboolean ARB_fragment_program_shadow; + GLboolean ARB_fragment_shader; + GLboolean ARB_framebuffer_object; + GLboolean ARB_explicit_attrib_location; + GLboolean ARB_geometry_shader4; + GLboolean ARB_half_float_pixel; + GLboolean ARB_half_float_vertex; + GLboolean ARB_instanced_arrays; + GLboolean ARB_map_buffer_range; + GLboolean ARB_multisample; + GLboolean ARB_multitexture; + GLboolean ARB_occlusion_query; + GLboolean ARB_occlusion_query2; + GLboolean ARB_point_sprite; + GLboolean ARB_sampler_objects; + GLboolean ARB_seamless_cube_map; + GLboolean ARB_shader_objects; + GLboolean ARB_shader_stencil_export; + GLboolean ARB_shader_texture_lod; + GLboolean ARB_shading_language_100; + GLboolean ARB_shadow; + GLboolean ARB_shadow_ambient; + GLboolean ARB_sync; + GLboolean ARB_texture_border_clamp; + GLboolean ARB_texture_buffer_object; + GLboolean ARB_texture_compression; + GLboolean ARB_texture_compression_rgtc; + GLboolean ARB_texture_cube_map; + GLboolean ARB_texture_env_combine; + GLboolean ARB_texture_env_crossbar; + GLboolean ARB_texture_env_dot3; + GLboolean ARB_texture_float; + GLboolean ARB_texture_mirrored_repeat; + GLboolean ARB_texture_multisample; + GLboolean ARB_texture_non_power_of_two; + GLboolean ARB_texture_rg; + GLboolean ARB_texture_rgb10_a2ui; + GLboolean ARB_timer_query; + GLboolean ARB_transform_feedback2; + GLboolean ARB_transpose_matrix; + GLboolean ARB_uniform_buffer_object; + GLboolean ARB_vertex_array_object; + GLboolean ARB_vertex_buffer_object; + GLboolean ARB_vertex_program; + GLboolean ARB_vertex_shader; + GLboolean ARB_vertex_type_2_10_10_10_rev; + GLboolean ARB_window_pos; + GLboolean EXT_abgr; + GLboolean EXT_bgra; + GLboolean EXT_blend_color; + GLboolean EXT_blend_equation_separate; + GLboolean EXT_blend_func_separate; + GLboolean EXT_blend_logic_op; + GLboolean EXT_blend_minmax; + GLboolean EXT_blend_subtract; + GLboolean EXT_clip_volume_hint; + GLboolean EXT_compiled_vertex_array; + GLboolean EXT_copy_texture; + GLboolean EXT_depth_bounds_test; + GLboolean EXT_draw_buffers2; + GLboolean EXT_draw_range_elements; + GLboolean EXT_fog_coord; + GLboolean EXT_framebuffer_blit; + GLboolean EXT_framebuffer_multisample; + GLboolean EXT_framebuffer_object; + GLboolean EXT_framebuffer_sRGB; + GLboolean EXT_gpu_program_parameters; + GLboolean EXT_gpu_shader4; + GLboolean EXT_multi_draw_arrays; + GLboolean EXT_packed_depth_stencil; + GLboolean EXT_packed_float; + GLboolean EXT_packed_pixels; + GLboolean EXT_pixel_buffer_object; + GLboolean EXT_point_parameters; + GLboolean EXT_polygon_offset; + GLboolean EXT_provoking_vertex; + GLboolean EXT_rescale_normal; + GLboolean EXT_shadow_funcs; + GLboolean EXT_secondary_color; + GLboolean EXT_separate_shader_objects; + GLboolean EXT_separate_specular_color; + GLboolean EXT_stencil_wrap; + GLboolean EXT_stencil_two_side; + GLboolean EXT_subtexture; + GLboolean EXT_texture; + GLboolean EXT_texture_object; + GLboolean EXT_texture3D; + GLboolean EXT_texture_array; + GLboolean EXT_texture_compression_latc; + GLboolean EXT_texture_compression_s3tc; + GLboolean EXT_texture_env_add; + GLboolean EXT_texture_env_combine; + GLboolean EXT_texture_env_dot3; + GLboolean EXT_texture_filter_anisotropic; + GLboolean EXT_texture_integer; + GLboolean EXT_texture_lod_bias; + GLboolean EXT_texture_mirror_clamp; + GLboolean EXT_texture_shared_exponent; + GLboolean EXT_texture_snorm; + GLboolean EXT_texture_sRGB; + GLboolean EXT_texture_sRGB_decode; + GLboolean EXT_texture_swizzle; + GLboolean EXT_transform_feedback; + GLboolean EXT_timer_query; + GLboolean EXT_vertex_array; + GLboolean EXT_vertex_array_bgra; + GLboolean EXT_vertex_array_set; + GLboolean OES_standard_derivatives; + /* vendor extensions */ + GLboolean AMD_conservative_depth; + GLboolean AMD_seamless_cubemap_per_texture; + GLboolean APPLE_client_storage; + GLboolean APPLE_packed_pixels; + GLboolean APPLE_vertex_array_object; + GLboolean APPLE_object_purgeable; + GLboolean ATI_envmap_bumpmap; + GLboolean ATI_texture_compression_3dc; + GLboolean ATI_texture_mirror_once; + GLboolean ATI_texture_env_combine3; + GLboolean ATI_fragment_shader; + GLboolean ATI_separate_stencil; + GLboolean IBM_rasterpos_clip; + GLboolean IBM_multimode_draw_arrays; + GLboolean MESA_pack_invert; + GLboolean MESA_resize_buffers; + GLboolean MESA_ycbcr_texture; + GLboolean MESA_texture_array; + GLboolean NV_blend_square; + GLboolean NV_conditional_render; + GLboolean NV_fragment_program; + GLboolean NV_fragment_program_option; + GLboolean NV_light_max_exponent; + GLboolean NV_point_sprite; + GLboolean NV_primitive_restart; + GLboolean NV_texture_barrier; + GLboolean NV_texgen_reflection; + GLboolean NV_texture_env_combine4; + GLboolean NV_texture_rectangle; + GLboolean NV_vertex_program; + GLboolean NV_vertex_program1_1; + GLboolean OES_read_format; + GLboolean SGIS_generate_mipmap; + GLboolean SGIS_texture_edge_clamp; + GLboolean SGIS_texture_lod; + GLboolean TDFX_texture_compression_FXT1; + GLboolean S3_s3tc; + GLboolean OES_EGL_image; + GLboolean OES_draw_texture; + GLboolean EXT_texture_format_BGRA8888; + GLboolean extension_sentinel; + /** The extension string */ + const GLubyte *String; + /** Number of supported extensions */ + GLuint Count; +}; + + +/** + * A stack of matrices (projection, modelview, color, texture, etc). + */ +struct gl_matrix_stack +{ + GLmatrix *Top; /**< points into Stack */ + GLmatrix *Stack; /**< array [MaxDepth] of GLmatrix */ + GLuint Depth; /**< 0 <= Depth < MaxDepth */ + GLuint MaxDepth; /**< size of Stack[] array */ + GLuint DirtyFlag; /**< _NEW_MODELVIEW or _NEW_PROJECTION, for example */ +}; + + +/** + * \name Bits for image transfer operations + * \sa __struct gl_contextRec::ImageTransferState. + */ +/*@{*/ +#define IMAGE_SCALE_BIAS_BIT 0x1 +#define IMAGE_SHIFT_OFFSET_BIT 0x2 +#define IMAGE_MAP_COLOR_BIT 0x4 +#define IMAGE_CLAMP_BIT 0x800 + + +/** Pixel Transfer ops */ +#define IMAGE_BITS (IMAGE_SCALE_BIAS_BIT | \ + IMAGE_SHIFT_OFFSET_BIT | \ + IMAGE_MAP_COLOR_BIT) + +/** + * \name Bits to indicate what state has changed. + */ +/*@{*/ +#define _NEW_MODELVIEW (1 << 0) /**< gl_context::ModelView */ +#define _NEW_PROJECTION (1 << 1) /**< gl_context::Projection */ +#define _NEW_TEXTURE_MATRIX (1 << 2) /**< gl_context::TextureMatrix */ +#define _NEW_COLOR (1 << 3) /**< gl_context::Color */ +#define _NEW_DEPTH (1 << 4) /**< gl_context::Depth */ +#define _NEW_EVAL (1 << 5) /**< gl_context::Eval, EvalMap */ +#define _NEW_FOG (1 << 6) /**< gl_context::Fog */ +#define _NEW_HINT (1 << 7) /**< gl_context::Hint */ +#define _NEW_LIGHT (1 << 8) /**< gl_context::Light */ +#define _NEW_LINE (1 << 9) /**< gl_context::Line */ +#define _NEW_PIXEL (1 << 10) /**< gl_context::Pixel */ +#define _NEW_POINT (1 << 11) /**< gl_context::Point */ +#define _NEW_POLYGON (1 << 12) /**< gl_context::Polygon */ +#define _NEW_POLYGONSTIPPLE (1 << 13) /**< gl_context::PolygonStipple */ +#define _NEW_SCISSOR (1 << 14) /**< gl_context::Scissor */ +#define _NEW_STENCIL (1 << 15) /**< gl_context::Stencil */ +#define _NEW_TEXTURE (1 << 16) /**< gl_context::Texture */ +#define _NEW_TRANSFORM (1 << 17) /**< gl_context::Transform */ +#define _NEW_VIEWPORT (1 << 18) /**< gl_context::Viewport */ +#define _NEW_PACKUNPACK (1 << 19) /**< gl_context::Pack, Unpack */ +#define _NEW_ARRAY (1 << 20) /**< gl_context::Array */ +#define _NEW_RENDERMODE (1 << 21) /**< gl_context::RenderMode, etc */ +#define _NEW_BUFFERS (1 << 22) /**< gl_context::Visual, DrawBuffer, */ +#define _NEW_CURRENT_ATTRIB (1 << 23) /**< gl_context::Current */ +#define _NEW_MULTISAMPLE (1 << 24) /**< gl_context::Multisample */ +#define _NEW_TRACK_MATRIX (1 << 25) /**< gl_context::VertexProgram */ +#define _NEW_PROGRAM (1 << 26) /**< New program/shader state */ +#define _NEW_PROGRAM_CONSTANTS (1 << 27) +#define _NEW_BUFFER_OBJECT (1 << 28) +#define _NEW_FRAG_CLAMP (1 << 29) +#define _NEW_ALL ~0 +/*@}*/ + + +/** + * \name Bits to track array state changes + * + * Also used to summarize array enabled. + */ +/*@{*/ +#define _NEW_ARRAY_VERTEX VERT_BIT_POS +#define _NEW_ARRAY_WEIGHT VERT_BIT_WEIGHT +#define _NEW_ARRAY_NORMAL VERT_BIT_NORMAL +#define _NEW_ARRAY_COLOR0 VERT_BIT_COLOR0 +#define _NEW_ARRAY_COLOR1 VERT_BIT_COLOR1 +#define _NEW_ARRAY_FOGCOORD VERT_BIT_FOG +#define _NEW_ARRAY_INDEX VERT_BIT_COLOR_INDEX +#define _NEW_ARRAY_EDGEFLAG VERT_BIT_EDGEFLAG +#define _NEW_ARRAY_POINT_SIZE VERT_BIT_COLOR_INDEX /* aliased */ +#define _NEW_ARRAY_TEXCOORD_0 VERT_BIT_TEX0 +#define _NEW_ARRAY_TEXCOORD_1 VERT_BIT_TEX1 +#define _NEW_ARRAY_TEXCOORD_2 VERT_BIT_TEX2 +#define _NEW_ARRAY_TEXCOORD_3 VERT_BIT_TEX3 +#define _NEW_ARRAY_TEXCOORD_4 VERT_BIT_TEX4 +#define _NEW_ARRAY_TEXCOORD_5 VERT_BIT_TEX5 +#define _NEW_ARRAY_TEXCOORD_6 VERT_BIT_TEX6 +#define _NEW_ARRAY_TEXCOORD_7 VERT_BIT_TEX7 +#define _NEW_ARRAY_ATTRIB_0 VERT_BIT_GENERIC0 /* start at bit 16 */ +#define _NEW_ARRAY_ALL 0xffffffff + + +#define _NEW_ARRAY_TEXCOORD(i) (_NEW_ARRAY_TEXCOORD_0 << (i)) +#define _NEW_ARRAY_ATTRIB(i) (_NEW_ARRAY_ATTRIB_0 << (i)) +/*@}*/ + + + +/** + * \name A bunch of flags that we think might be useful to drivers. + * + * Set in the __struct gl_contextRec::_TriangleCaps bitfield. + */ +/*@{*/ +#define DD_FLATSHADE 0x1 +#define DD_SEPARATE_SPECULAR 0x2 +#define DD_TRI_CULL_FRONT_BACK 0x4 /* special case on some hw */ +#define DD_TRI_LIGHT_TWOSIDE 0x8 +#define DD_TRI_UNFILLED 0x10 +#define DD_TRI_SMOOTH 0x20 +#define DD_TRI_STIPPLE 0x40 +#define DD_TRI_OFFSET 0x80 +#define DD_LINE_SMOOTH 0x100 +#define DD_LINE_STIPPLE 0x200 +#define DD_POINT_SMOOTH 0x400 +#define DD_POINT_ATTEN 0x800 +#define DD_TRI_TWOSTENCIL 0x1000 +/*@}*/ + + +/** + * \name Define the state changes under which each of these bits might change + */ +/*@{*/ +#define _DD_NEW_FLATSHADE _NEW_LIGHT +#define _DD_NEW_SEPARATE_SPECULAR (_NEW_LIGHT | _NEW_FOG | _NEW_PROGRAM) +#define _DD_NEW_TRI_CULL_FRONT_BACK _NEW_POLYGON +#define _DD_NEW_TRI_LIGHT_TWOSIDE _NEW_LIGHT +#define _DD_NEW_TRI_UNFILLED _NEW_POLYGON +#define _DD_NEW_TRI_SMOOTH _NEW_POLYGON +#define _DD_NEW_TRI_STIPPLE _NEW_POLYGON +#define _DD_NEW_TRI_OFFSET _NEW_POLYGON +#define _DD_NEW_LINE_SMOOTH _NEW_LINE +#define _DD_NEW_LINE_STIPPLE _NEW_LINE +#define _DD_NEW_LINE_WIDTH _NEW_LINE +#define _DD_NEW_POINT_SMOOTH _NEW_POINT +#define _DD_NEW_POINT_SIZE _NEW_POINT +#define _DD_NEW_POINT_ATTEN _NEW_POINT +/*@}*/ + + +/** + * Composite state flags + */ +/*@{*/ +#define _MESA_NEW_NEED_EYE_COORDS (_NEW_LIGHT | \ + _NEW_TEXTURE | \ + _NEW_POINT | \ + _NEW_PROGRAM | \ + _NEW_MODELVIEW) +/*@}*/ + + + + +/* This has to be included here. */ +#include "dd.h" + + +/** + * Display list flags. + * Strictly this is a tnl-private concept, but it doesn't seem + * worthwhile adding a tnl private structure just to hold this one bit + * of information: + */ +#define DLIST_DANGLING_REFS 0x1 + + +/** Opaque declaration of display list payload data type */ +union gl_dlist_node; + + +/** + * Provide a location where information about a display list can be + * collected. Could be extended with driverPrivate structures, + * etc. in the future. + */ +struct gl_display_list +{ + GLuint Name; + GLbitfield Flags; /**< DLIST_x flags */ + /** The dlist commands are in a linked list of nodes */ + union gl_dlist_node *Head; +}; + + +/** + * State used during display list compilation and execution. + */ +struct gl_dlist_state +{ + GLuint CallDepth; /**< Current recursion calling depth */ + + struct gl_display_list *CurrentList; /**< List currently being compiled */ + union gl_dlist_node *CurrentBlock; /**< Pointer to current block of nodes */ + GLuint CurrentPos; /**< Index into current block of nodes */ + + GLvertexformat ListVtxfmt; + + GLubyte ActiveAttribSize[VERT_ATTRIB_MAX]; + GLfloat CurrentAttrib[VERT_ATTRIB_MAX][4]; + + GLubyte ActiveMaterialSize[MAT_ATTRIB_MAX]; + GLfloat CurrentMaterial[MAT_ATTRIB_MAX][4]; + + GLubyte ActiveIndex; + GLfloat CurrentIndex; + + GLubyte ActiveEdgeFlag; + GLboolean CurrentEdgeFlag; + + struct { + /* State known to have been set by the currently-compiling display + * list. Used to eliminate some redundant state changes. + */ + GLenum ShadeModel; + } Current; +}; + + +/** + * Enum for the OpenGL APIs we know about and may support. + */ +typedef enum +{ + API_OPENGL, + API_OPENGLES, + API_OPENGLES2 +} gl_api; + + +/** + * Mesa rendering context. + * + * This is the central context data structure for Mesa. Almost all + * OpenGL state is contained in this structure. + * Think of this as a base class from which device drivers will derive + * sub classes. + * + * The struct gl_context typedef names this structure. + */ +struct gl_context +{ + /** State possibly shared with other contexts in the address space */ + struct gl_shared_state *Shared; + + /** \name API function pointer tables */ + /*@{*/ + gl_api API; + struct _glapi_table *Save; /**< Display list save functions */ + struct _glapi_table *Exec; /**< Execute functions */ + struct _glapi_table *CurrentDispatch; /**< == Save or Exec !! */ + /*@}*/ + + struct gl_config Visual; + struct gl_framebuffer *DrawBuffer; /**< buffer for writing */ + struct gl_framebuffer *ReadBuffer; /**< buffer for reading */ + struct gl_framebuffer *WinSysDrawBuffer; /**< set with MakeCurrent */ + struct gl_framebuffer *WinSysReadBuffer; /**< set with MakeCurrent */ + + /** + * Device driver function pointer table + */ + struct dd_function_table Driver; + + void *DriverCtx; /**< Points to device driver context/state */ + + /** Core/Driver constants */ + struct gl_constants Const; + + /** \name The various 4x4 matrix stacks */ + /*@{*/ + struct gl_matrix_stack ModelviewMatrixStack; + struct gl_matrix_stack ProjectionMatrixStack; + struct gl_matrix_stack TextureMatrixStack[MAX_TEXTURE_UNITS]; + struct gl_matrix_stack ProgramMatrixStack[MAX_PROGRAM_MATRICES]; + struct gl_matrix_stack *CurrentStack; /**< Points to one of the above stacks */ + /*@}*/ + + /** Combined modelview and projection matrix */ + GLmatrix _ModelProjectMatrix; + + /** \name Display lists */ + struct gl_dlist_state ListState; + + GLboolean ExecuteFlag; /**< Execute GL commands? */ + GLboolean CompileFlag; /**< Compile GL commands into display list? */ + + /** Extension information */ + struct gl_extensions Extensions; + + /** Version info */ + GLuint VersionMajor, VersionMinor; + char *VersionString; + + /** \name State attribute stack (for glPush/PopAttrib) */ + /*@{*/ + GLuint AttribStackDepth; + struct gl_attrib_node *AttribStack[MAX_ATTRIB_STACK_DEPTH]; + /*@}*/ + + /** \name Renderer attribute groups + * + * We define a struct for each attribute group to make pushing and popping + * attributes easy. Also it's a good organization. + */ + /*@{*/ + struct gl_accum_attrib Accum; /**< Accum buffer attributes */ + struct gl_colorbuffer_attrib Color; /**< Color buffer attributes */ + struct gl_current_attrib Current; /**< Current attributes */ + struct gl_depthbuffer_attrib Depth; /**< Depth buffer attributes */ + struct gl_eval_attrib Eval; /**< Eval attributes */ + struct gl_fog_attrib Fog; /**< Fog attributes */ + struct gl_hint_attrib Hint; /**< Hint attributes */ + struct gl_light_attrib Light; /**< Light attributes */ + struct gl_line_attrib Line; /**< Line attributes */ + struct gl_list_attrib List; /**< List attributes */ + struct gl_multisample_attrib Multisample; + struct gl_pixel_attrib Pixel; /**< Pixel attributes */ + struct gl_point_attrib Point; /**< Point attributes */ + struct gl_polygon_attrib Polygon; /**< Polygon attributes */ + GLuint PolygonStipple[32]; /**< Polygon stipple */ + struct gl_scissor_attrib Scissor; /**< Scissor attributes */ + struct gl_stencil_attrib Stencil; /**< Stencil buffer attributes */ + struct gl_texture_attrib Texture; /**< Texture attributes */ + struct gl_transform_attrib Transform; /**< Transformation attributes */ + struct gl_viewport_attrib Viewport; /**< Viewport attributes */ + /*@}*/ + + /** \name Client attribute stack */ + /*@{*/ + GLuint ClientAttribStackDepth; + struct gl_attrib_node *ClientAttribStack[MAX_CLIENT_ATTRIB_STACK_DEPTH]; + /*@}*/ + + /** \name Client attribute groups */ + /*@{*/ + struct gl_array_attrib Array; /**< Vertex arrays */ + struct gl_pixelstore_attrib Pack; /**< Pixel packing */ + struct gl_pixelstore_attrib Unpack; /**< Pixel unpacking */ + struct gl_pixelstore_attrib DefaultPacking; /**< Default params */ + /*@}*/ + + /** \name Other assorted state (not pushed/popped on attribute stack) */ + /*@{*/ + struct gl_pixelmaps PixelMaps; + + struct gl_evaluators EvalMap; /**< All evaluators */ + struct gl_feedback Feedback; /**< Feedback */ + struct gl_selection Select; /**< Selection */ + + struct gl_program_state Program; /**< general program state */ + struct gl_vertex_program_state VertexProgram; + struct gl_fragment_program_state FragmentProgram; + struct gl_geometry_program_state GeometryProgram; + struct gl_ati_fragment_shader_state ATIFragmentShader; + + struct gl_shader_state Shader; /**< GLSL shader object state */ + struct gl_shader_compiler_options ShaderCompilerOptions[MESA_SHADER_TYPES]; + + struct gl_query_state Query; /**< occlusion, timer queries */ + + struct gl_transform_feedback TransformFeedback; + + struct gl_buffer_object *CopyReadBuffer; /**< GL_ARB_copy_buffer */ + struct gl_buffer_object *CopyWriteBuffer; /**< GL_ARB_copy_buffer */ + /*@}*/ + + struct gl_meta_state *Meta; /**< for "meta" operations */ + + /* GL_EXT_framebuffer_object */ + struct gl_renderbuffer *CurrentRenderbuffer; + + GLenum ErrorValue; /**< Last error code */ + + /* GL_ARB_robustness */ + GLenum ResetStatus; + + /** + * Recognize and silence repeated error debug messages in buggy apps. + */ + const char *ErrorDebugFmtString; + GLuint ErrorDebugCount; + + GLenum RenderMode; /**< either GL_RENDER, GL_SELECT, GL_FEEDBACK */ + GLbitfield NewState; /**< bitwise-or of _NEW_* flags */ + + GLboolean ViewportInitialized; /**< has viewport size been initialized? */ + + GLbitfield varying_vp_inputs; /**< mask of VERT_BIT_* flags */ + + /** \name Derived state */ + /*@{*/ + /** Bitwise-or of DD_* flags. Note that this bitfield may be used before + * state validation so they need to always be current. + */ + GLbitfield _TriangleCaps; + GLbitfield _ImageTransferState;/**< bitwise-or of IMAGE_*_BIT flags */ + GLfloat _EyeZDir[3]; + GLfloat _ModelViewInvScale; + GLboolean _NeedEyeCoords; + GLboolean _ForceEyeCoords; + + GLuint TextureStateTimestamp; /**< detect changes to shared state */ + + struct gl_shine_tab *_ShineTable[2]; /**< Active shine tables */ + struct gl_shine_tab *_ShineTabList; /**< MRU list of inactive shine tables */ + /**@}*/ + + struct gl_list_extensions *ListExt; /**< driver dlist extensions */ + + /** \name For debugging/development only */ + /*@{*/ + GLboolean FirstTimeCurrent; + /*@}*/ + + /** software compression/decompression supported or not */ + GLboolean Mesa_DXTn; + + GLboolean TextureFormatSupported[MESA_FORMAT_COUNT]; + + /** + * Use dp4 (rather than mul/mad) instructions for position + * transformation? + */ + GLboolean mvp_with_dp4; + + /** + * \name Hooks for module contexts. + * + * These will eventually live in the driver or elsewhere. + */ + /*@{*/ + void *swrast_context; + void *swsetup_context; + void *swtnl_context; + void *swtnl_im; + struct st_context *st; + void *aelt_context; + /*@}*/ +}; + + +#ifdef DEBUG +extern int MESA_VERBOSE; +extern int MESA_DEBUG_FLAGS; +# define MESA_FUNCTION __FUNCTION__ +#else +# define MESA_VERBOSE 0 +# define MESA_DEBUG_FLAGS 0 +# define MESA_FUNCTION "a function" +# ifndef NDEBUG +# define NDEBUG +# endif +#endif + + +/** The MESA_VERBOSE var is a bitmask of these flags */ +enum _verbose +{ + VERBOSE_VARRAY = 0x0001, + VERBOSE_TEXTURE = 0x0002, + VERBOSE_MATERIAL = 0x0004, + VERBOSE_PIPELINE = 0x0008, + VERBOSE_DRIVER = 0x0010, + VERBOSE_STATE = 0x0020, + VERBOSE_API = 0x0040, + VERBOSE_DISPLAY_LIST = 0x0100, + VERBOSE_LIGHTING = 0x0200, + VERBOSE_PRIMS = 0x0400, + VERBOSE_VERTS = 0x0800, + VERBOSE_DISASSEM = 0x1000, + VERBOSE_DRAW = 0x2000, + VERBOSE_SWAPBUFFERS = 0x4000 +}; + + +/** The MESA_DEBUG_FLAGS var is a bitmask of these flags */ +enum _debug +{ + DEBUG_ALWAYS_FLUSH = 0x1 +}; + + + +#endif /* MTYPES_H */ diff --git a/mesalib/src/mesa/main/pack.c b/mesalib/src/mesa/main/pack.c index 1f9df52c4..fd3f89d82 100644 --- a/mesalib/src/mesa/main/pack.c +++ b/mesalib/src/mesa/main/pack.c @@ -1,5229 +1,5229 @@ -/* - * Mesa 3-D graphics library - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (C) 2009-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 - * THEA 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. - */ - - -/** - * \file pack.c - * Image and pixel span packing and unpacking. - */ - - -#include "glheader.h" -#include "colormac.h" -#include "enums.h" -#include "image.h" -#include "imports.h" -#include "mtypes.h" -#include "pack.h" -#include "pixeltransfer.h" -#include "imports.h" -#include "../../gallium/auxiliary/util/u_format_rgb9e5.h" -#include "../../gallium/auxiliary/util/u_format_r11g11b10f.h" - - -/** - * NOTE: - * Normally, BYTE_TO_FLOAT(0) returns 0.00392 That causes problems when - * we later convert the float to a packed integer value (such as for - * GL_RGB5_A1) because we'll wind up with a non-zero value. - * - * We redefine the macros here so zero is handled correctly. - */ -#undef BYTE_TO_FLOAT -#define BYTE_TO_FLOAT(B) ((B) == 0 ? 0.0F : ((2.0F * (B) + 1.0F) * (1.0F/255.0F))) - -#undef SHORT_TO_FLOAT -#define SHORT_TO_FLOAT(S) ((S) == 0 ? 0.0F : ((2.0F * (S) + 1.0F) * (1.0F/65535.0F))) - - - -/** Compute ceiling of integer quotient of A divided by B. */ -#define CEILING( A, B ) ( (A) % (B) == 0 ? (A)/(B) : (A)/(B)+1 ) - - -/** - * Flip the 8 bits in each byte of the given array. - * - * \param p array. - * \param n number of bytes. - * - * \todo try this trick to flip bytes someday: - * \code - * v = ((v & 0x55555555) << 1) | ((v >> 1) & 0x55555555); - * v = ((v & 0x33333333) << 2) | ((v >> 2) & 0x33333333); - * v = ((v & 0x0f0f0f0f) << 4) | ((v >> 4) & 0x0f0f0f0f); - * \endcode - */ -static void -flip_bytes( GLubyte *p, GLuint n ) -{ - GLuint i, a, b; - for (i = 0; i < n; i++) { - b = (GLuint) p[i]; /* words are often faster than bytes */ - a = ((b & 0x01) << 7) | - ((b & 0x02) << 5) | - ((b & 0x04) << 3) | - ((b & 0x08) << 1) | - ((b & 0x10) >> 1) | - ((b & 0x20) >> 3) | - ((b & 0x40) >> 5) | - ((b & 0x80) >> 7); - p[i] = (GLubyte) a; - } -} - - - -/* - * Unpack a 32x32 pixel polygon stipple from user memory using the - * current pixel unpack settings. - */ -void -_mesa_unpack_polygon_stipple( const GLubyte *pattern, GLuint dest[32], - const struct gl_pixelstore_attrib *unpacking ) -{ - GLubyte *ptrn = (GLubyte *) _mesa_unpack_bitmap(32, 32, pattern, unpacking); - if (ptrn) { - /* Convert pattern from GLubytes to GLuints and handle big/little - * endian differences - */ - GLubyte *p = ptrn; - GLint i; - for (i = 0; i < 32; i++) { - dest[i] = (p[0] << 24) - | (p[1] << 16) - | (p[2] << 8) - | (p[3] ); - p += 4; - } - free(ptrn); - } -} - - -/* - * Pack polygon stipple into user memory given current pixel packing - * settings. - */ -void -_mesa_pack_polygon_stipple( const GLuint pattern[32], GLubyte *dest, - const struct gl_pixelstore_attrib *packing ) -{ - /* Convert pattern from GLuints to GLubytes to handle big/little - * endian differences. - */ - GLubyte ptrn[32*4]; - GLint i; - for (i = 0; i < 32; i++) { - ptrn[i * 4 + 0] = (GLubyte) ((pattern[i] >> 24) & 0xff); - ptrn[i * 4 + 1] = (GLubyte) ((pattern[i] >> 16) & 0xff); - ptrn[i * 4 + 2] = (GLubyte) ((pattern[i] >> 8 ) & 0xff); - ptrn[i * 4 + 3] = (GLubyte) ((pattern[i] ) & 0xff); - } - - _mesa_pack_bitmap(32, 32, ptrn, dest, packing); -} - - -/* - * Unpack bitmap data. Resulting data will be in most-significant-bit-first - * order with row alignment = 1 byte. - */ -GLvoid * -_mesa_unpack_bitmap( GLint width, GLint height, const GLubyte *pixels, - const struct gl_pixelstore_attrib *packing ) -{ - GLint bytes, row, width_in_bytes; - GLubyte *buffer, *dst; - - if (!pixels) - return NULL; - - /* Alloc dest storage */ - bytes = ((width + 7) / 8 * height); - buffer = (GLubyte *) malloc( bytes ); - if (!buffer) - return NULL; - - width_in_bytes = CEILING( width, 8 ); - dst = buffer; - for (row = 0; row < height; row++) { - const GLubyte *src = (const GLubyte *) - _mesa_image_address2d(packing, pixels, width, height, - GL_COLOR_INDEX, GL_BITMAP, row, 0); - if (!src) { - free(buffer); - return NULL; - } - - if ((packing->SkipPixels & 7) == 0) { - memcpy( dst, src, width_in_bytes ); - if (packing->LsbFirst) { - flip_bytes( dst, width_in_bytes ); - } - } - else { - /* handling SkipPixels is a bit tricky (no pun intended!) */ - GLint i; - if (packing->LsbFirst) { - GLubyte srcMask = 1 << (packing->SkipPixels & 0x7); - GLubyte dstMask = 128; - const GLubyte *s = src; - GLubyte *d = dst; - *d = 0; - for (i = 0; i < width; i++) { - if (*s & srcMask) { - *d |= dstMask; - } - if (srcMask == 128) { - srcMask = 1; - s++; - } - else { - srcMask = srcMask << 1; - } - if (dstMask == 1) { - dstMask = 128; - d++; - *d = 0; - } - else { - dstMask = dstMask >> 1; - } - } - } - else { - GLubyte srcMask = 128 >> (packing->SkipPixels & 0x7); - GLubyte dstMask = 128; - const GLubyte *s = src; - GLubyte *d = dst; - *d = 0; - for (i = 0; i < width; i++) { - if (*s & srcMask) { - *d |= dstMask; - } - if (srcMask == 1) { - srcMask = 128; - s++; - } - else { - srcMask = srcMask >> 1; - } - if (dstMask == 1) { - dstMask = 128; - d++; - *d = 0; - } - else { - dstMask = dstMask >> 1; - } - } - } - } - dst += width_in_bytes; - } - - return buffer; -} - - -/* - * Pack bitmap data. - */ -void -_mesa_pack_bitmap( GLint width, GLint height, const GLubyte *source, - GLubyte *dest, const struct gl_pixelstore_attrib *packing ) -{ - GLint row, width_in_bytes; - const GLubyte *src; - - if (!source) - return; - - width_in_bytes = CEILING( width, 8 ); - src = source; - for (row = 0; row < height; row++) { - GLubyte *dst = (GLubyte *) _mesa_image_address2d(packing, dest, - width, height, GL_COLOR_INDEX, GL_BITMAP, row, 0); - if (!dst) - return; - - if ((packing->SkipPixels & 7) == 0) { - memcpy( dst, src, width_in_bytes ); - if (packing->LsbFirst) { - flip_bytes( dst, width_in_bytes ); - } - } - else { - /* handling SkipPixels is a bit tricky (no pun intended!) */ - GLint i; - if (packing->LsbFirst) { - GLubyte srcMask = 128; - GLubyte dstMask = 1 << (packing->SkipPixels & 0x7); - const GLubyte *s = src; - GLubyte *d = dst; - *d = 0; - for (i = 0; i < width; i++) { - if (*s & srcMask) { - *d |= dstMask; - } - if (srcMask == 1) { - srcMask = 128; - s++; - } - else { - srcMask = srcMask >> 1; - } - if (dstMask == 128) { - dstMask = 1; - d++; - *d = 0; - } - else { - dstMask = dstMask << 1; - } - } - } - else { - GLubyte srcMask = 128; - GLubyte dstMask = 128 >> (packing->SkipPixels & 0x7); - const GLubyte *s = src; - GLubyte *d = dst; - *d = 0; - for (i = 0; i < width; i++) { - if (*s & srcMask) { - *d |= dstMask; - } - if (srcMask == 1) { - srcMask = 128; - s++; - } - else { - srcMask = srcMask >> 1; - } - if (dstMask == 1) { - dstMask = 128; - d++; - *d = 0; - } - else { - dstMask = dstMask >> 1; - } - } - } - } - src += width_in_bytes; - } -} - - -/** - * Get indexes of color components for a basic color format, such as - * GL_RGBA, GL_RED, GL_LUMINANCE_ALPHA, etc. Return -1 for indexes - * that do not apply. - */ -static void -get_component_indexes(GLenum format, - GLint *redIndex, - GLint *greenIndex, - GLint *blueIndex, - GLint *alphaIndex, - GLint *luminanceIndex, - GLint *intensityIndex) -{ - *redIndex = -1; - *greenIndex = -1; - *blueIndex = -1; - *alphaIndex = -1; - *luminanceIndex = -1; - *intensityIndex = -1; - - switch (format) { - case GL_LUMINANCE: - case GL_LUMINANCE_INTEGER_EXT: - *luminanceIndex = 0; - break; - case GL_LUMINANCE_ALPHA: - case GL_LUMINANCE_ALPHA_INTEGER_EXT: - *luminanceIndex = 0; - *alphaIndex = 1; - break; - case GL_INTENSITY: - *intensityIndex = 0; - break; - case GL_RED: - case GL_RED_INTEGER_EXT: - *redIndex = 0; - break; - case GL_GREEN: - case GL_GREEN_INTEGER_EXT: - *greenIndex = 0; - break; - case GL_BLUE: - case GL_BLUE_INTEGER_EXT: - *blueIndex = 0; - break; - case GL_ALPHA: - case GL_ALPHA_INTEGER_EXT: - *alphaIndex = 0; - break; - case GL_RG: - case GL_RG_INTEGER: - *redIndex = 0; - *greenIndex = 1; - break; - case GL_RGB: - case GL_RGB_INTEGER_EXT: - *redIndex = 0; - *greenIndex = 1; - *blueIndex = 2; - break; - case GL_BGR: - case GL_BGR_INTEGER_EXT: - *blueIndex = 0; - *greenIndex = 1; - *redIndex = 2; - break; - case GL_RGBA: - case GL_RGBA_INTEGER_EXT: - *redIndex = 0; - *greenIndex = 1; - *blueIndex = 2; - *alphaIndex = 3; - break; - case GL_BGRA: - case GL_BGRA_INTEGER: - *redIndex = 2; - *greenIndex = 1; - *blueIndex = 0; - *alphaIndex = 3; - break; - case GL_ABGR_EXT: - *redIndex = 3; - *greenIndex = 2; - *blueIndex = 1; - *alphaIndex = 0; - break; - case GL_DU8DV8_ATI: - case GL_DUDV_ATI: - *redIndex = 0; - *greenIndex = 1; - break; - default: - assert(0 && "bad format in get_component_indexes()"); - } -} - - - -/** - * For small integer types, return the min and max possible values. - * Used for clamping floats to unscaled integer types. - * \return GL_TRUE if type is handled, GL_FALSE otherwise. - */ -static GLboolean -get_type_min_max(GLenum type, GLfloat *min, GLfloat *max) -{ - switch (type) { - case GL_BYTE: - *min = -128.0; - *max = 127.0; - return GL_TRUE; - case GL_UNSIGNED_BYTE: - *min = 0.0; - *max = 255.0; - return GL_TRUE; - case GL_SHORT: - *min = -32768.0; - *max = 32767.0; - return GL_TRUE; - case GL_UNSIGNED_SHORT: - *min = 0.0; - *max = 65535.0; - return GL_TRUE; - default: - return GL_FALSE; - } -} - - - -/** - * Used to pack an array [][4] of RGBA float colors as specified - * by the dstFormat, dstType and dstPacking. Used by glReadPixels. - * Historically, the RGBA values were in [0,1] and rescaled to fit - * into GLubytes, etc. But with new integer formats, the RGBA values - * may have any value and we don't always rescale when converting to - * integers. - * - * Note: the rgba values will be modified by this function when any pixel - * transfer ops are enabled. - */ -void -_mesa_pack_rgba_span_float(struct gl_context *ctx, GLuint n, GLfloat rgba[][4], - GLenum dstFormat, GLenum dstType, - GLvoid *dstAddr, - const struct gl_pixelstore_attrib *dstPacking, - GLbitfield transferOps) -{ - GLfloat *luminance; - const GLint comps = _mesa_components_in_format(dstFormat); - const GLboolean intDstFormat = _mesa_is_integer_format(dstFormat); - GLuint i; - - if (dstFormat == GL_LUMINANCE || - dstFormat == GL_LUMINANCE_ALPHA || - dstFormat == GL_LUMINANCE_INTEGER_EXT || - dstFormat == GL_LUMINANCE_ALPHA_INTEGER_EXT) { - luminance = (GLfloat *) malloc(n * sizeof(GLfloat)); - if (!luminance) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "pixel packing"); - return; - } - } - else { - luminance = NULL; - } - - if (transferOps) { - _mesa_apply_rgba_transfer_ops(ctx, transferOps, n, rgba); - } - - /* - * Component clamping (besides clamping to [0,1] in - * _mesa_apply_rgba_transfer_ops()). - */ - if (intDstFormat) { - /* clamping to dest type's min/max values */ - GLfloat min, max; - if (get_type_min_max(dstType, &min, &max)) { - for (i = 0; i < n; i++) { - rgba[i][RCOMP] = CLAMP(rgba[i][RCOMP], min, max); - rgba[i][GCOMP] = CLAMP(rgba[i][GCOMP], min, max); - rgba[i][BCOMP] = CLAMP(rgba[i][BCOMP], min, max); - rgba[i][ACOMP] = CLAMP(rgba[i][ACOMP], min, max); - } - } - } - else if (dstFormat == GL_LUMINANCE || dstFormat == GL_LUMINANCE_ALPHA) { - /* compute luminance values */ - if (transferOps & IMAGE_CLAMP_BIT) { - for (i = 0; i < n; i++) { - GLfloat sum = rgba[i][RCOMP] + rgba[i][GCOMP] + rgba[i][BCOMP]; - luminance[i] = CLAMP(sum, 0.0F, 1.0F); - } - } - else { - for (i = 0; i < n; i++) { - luminance[i] = rgba[i][RCOMP] + rgba[i][GCOMP] + rgba[i][BCOMP]; - } - } - } - - /* - * Pack/store the pixels. Ugh! Lots of cases!!! - */ - switch (dstType) { - case GL_UNSIGNED_BYTE: - { - GLubyte *dst = (GLubyte *) dstAddr; - switch (dstFormat) { - case GL_RED: - for (i=0;iSwapBytes) { - GLint swapSize = _mesa_sizeof_packed_type(dstType); - if (swapSize == 2) { - if (dstPacking->SwapBytes) { - _mesa_swap2((GLushort *) dstAddr, n * comps); - } - } - else if (swapSize == 4) { - if (dstPacking->SwapBytes) { - _mesa_swap4((GLuint *) dstAddr, n * comps); - } - } - } - - free(luminance); -} - - - -#define SWAP2BYTE(VALUE) \ - { \ - GLubyte *bytes = (GLubyte *) &(VALUE); \ - GLubyte tmp = bytes[0]; \ - bytes[0] = bytes[1]; \ - bytes[1] = tmp; \ - } - -#define SWAP4BYTE(VALUE) \ - { \ - GLubyte *bytes = (GLubyte *) &(VALUE); \ - GLubyte tmp = bytes[0]; \ - bytes[0] = bytes[3]; \ - bytes[3] = tmp; \ - tmp = bytes[1]; \ - bytes[1] = bytes[2]; \ - bytes[2] = tmp; \ - } - - -static void -extract_uint_indexes(GLuint n, GLuint indexes[], - GLenum srcFormat, GLenum srcType, const GLvoid *src, - const struct gl_pixelstore_attrib *unpack ) -{ - ASSERT(srcFormat == GL_COLOR_INDEX || srcFormat == GL_STENCIL_INDEX); - - ASSERT(srcType == GL_BITMAP || - srcType == GL_UNSIGNED_BYTE || - srcType == GL_BYTE || - srcType == GL_UNSIGNED_SHORT || - srcType == GL_SHORT || - srcType == GL_UNSIGNED_INT || - srcType == GL_INT || - srcType == GL_UNSIGNED_INT_24_8_EXT || - srcType == GL_HALF_FLOAT_ARB || - srcType == GL_FLOAT || - srcType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV); - - switch (srcType) { - case GL_BITMAP: - { - GLubyte *ubsrc = (GLubyte *) src; - if (unpack->LsbFirst) { - GLubyte mask = 1 << (unpack->SkipPixels & 0x7); - GLuint i; - for (i = 0; i < n; i++) { - indexes[i] = (*ubsrc & mask) ? 1 : 0; - if (mask == 128) { - mask = 1; - ubsrc++; - } - else { - mask = mask << 1; - } - } - } - else { - GLubyte mask = 128 >> (unpack->SkipPixels & 0x7); - GLuint i; - for (i = 0; i < n; i++) { - indexes[i] = (*ubsrc & mask) ? 1 : 0; - if (mask == 1) { - mask = 128; - ubsrc++; - } - else { - mask = mask >> 1; - } - } - } - } - break; - case GL_UNSIGNED_BYTE: - { - GLuint i; - const GLubyte *s = (const GLubyte *) src; - for (i = 0; i < n; i++) - indexes[i] = s[i]; - } - break; - case GL_BYTE: - { - GLuint i; - const GLbyte *s = (const GLbyte *) src; - for (i = 0; i < n; i++) - indexes[i] = s[i]; - } - break; - case GL_UNSIGNED_SHORT: - { - GLuint i; - const GLushort *s = (const GLushort *) src; - if (unpack->SwapBytes) { - for (i = 0; i < n; i++) { - GLushort value = s[i]; - SWAP2BYTE(value); - indexes[i] = value; - } - } - else { - for (i = 0; i < n; i++) - indexes[i] = s[i]; - } - } - break; - case GL_SHORT: - { - GLuint i; - const GLshort *s = (const GLshort *) src; - if (unpack->SwapBytes) { - for (i = 0; i < n; i++) { - GLshort value = s[i]; - SWAP2BYTE(value); - indexes[i] = value; - } - } - else { - for (i = 0; i < n; i++) - indexes[i] = s[i]; - } - } - break; - case GL_UNSIGNED_INT: - { - GLuint i; - const GLuint *s = (const GLuint *) src; - if (unpack->SwapBytes) { - for (i = 0; i < n; i++) { - GLuint value = s[i]; - SWAP4BYTE(value); - indexes[i] = value; - } - } - else { - for (i = 0; i < n; i++) - indexes[i] = s[i]; - } - } - break; - case GL_INT: - { - GLuint i; - const GLint *s = (const GLint *) src; - if (unpack->SwapBytes) { - for (i = 0; i < n; i++) { - GLint value = s[i]; - SWAP4BYTE(value); - indexes[i] = value; - } - } - else { - for (i = 0; i < n; i++) - indexes[i] = s[i]; - } - } - break; - case GL_FLOAT: - { - GLuint i; - const GLfloat *s = (const GLfloat *) src; - if (unpack->SwapBytes) { - for (i = 0; i < n; i++) { - GLfloat value = s[i]; - SWAP4BYTE(value); - indexes[i] = (GLuint) value; - } - } - else { - for (i = 0; i < n; i++) - indexes[i] = (GLuint) s[i]; - } - } - break; - case GL_HALF_FLOAT_ARB: - { - GLuint i; - const GLhalfARB *s = (const GLhalfARB *) src; - if (unpack->SwapBytes) { - for (i = 0; i < n; i++) { - GLhalfARB value = s[i]; - SWAP2BYTE(value); - indexes[i] = (GLuint) _mesa_half_to_float(value); - } - } - else { - for (i = 0; i < n; i++) - indexes[i] = (GLuint) _mesa_half_to_float(s[i]); - } - } - break; - case GL_UNSIGNED_INT_24_8_EXT: - { - GLuint i; - const GLuint *s = (const GLuint *) src; - if (unpack->SwapBytes) { - for (i = 0; i < n; i++) { - GLuint value = s[i]; - SWAP4BYTE(value); - indexes[i] = value & 0xff; /* lower 8 bits */ - } - } - else { - for (i = 0; i < n; i++) - indexes[i] = s[i] & 0xff; /* lower 8 bits */ - } - } - break; - case GL_FLOAT_32_UNSIGNED_INT_24_8_REV: - { - GLuint i; - const GLuint *s = (const GLuint *) src; - if (unpack->SwapBytes) { - for (i = 0; i < n; i++) { - GLuint value = s[i*2+1]; - SWAP4BYTE(value); - indexes[i] = value & 0xff; /* lower 8 bits */ - } - } - else { - for (i = 0; i < n; i++) - indexes[i] = s[i*2+1] & 0xff; /* lower 8 bits */ - } - } - break; - - default: - _mesa_problem(NULL, "bad srcType in extract_uint_indexes"); - return; - } -} - - -/** - * Return source/dest RGBA indexes for unpacking pixels. - */ -static void -get_component_mapping(GLenum format, - GLint *rSrc, - GLint *gSrc, - GLint *bSrc, - GLint *aSrc, - GLint *rDst, - GLint *gDst, - GLint *bDst, - GLint *aDst) -{ - switch (format) { - case GL_RED: - case GL_RED_INTEGER_EXT: - *rSrc = 0; - *gSrc = *bSrc = *aSrc = -1; - break; - case GL_GREEN: - case GL_GREEN_INTEGER_EXT: - *gSrc = 0; - *rSrc = *bSrc = *aSrc = -1; - break; - case GL_BLUE: - case GL_BLUE_INTEGER_EXT: - *bSrc = 0; - *rSrc = *gSrc = *aSrc = -1; - break; - case GL_ALPHA: - case GL_ALPHA_INTEGER_EXT: - *rSrc = *gSrc = *bSrc = -1; - *aSrc = 0; - break; - case GL_LUMINANCE: - case GL_LUMINANCE_INTEGER_EXT: - *rSrc = *gSrc = *bSrc = 0; - *aSrc = -1; - break; - case GL_LUMINANCE_ALPHA: - case GL_LUMINANCE_ALPHA_INTEGER_EXT: - *rSrc = *gSrc = *bSrc = 0; - *aSrc = 1; - break; - case GL_INTENSITY: - *rSrc = *gSrc = *bSrc = *aSrc = 0; - break; - case GL_RG: - case GL_RG_INTEGER: - *rSrc = 0; - *gSrc = 1; - *bSrc = -1; - *aSrc = -1; - *rDst = 0; - *gDst = 1; - *bDst = 2; - *aDst = 3; - break; - case GL_RGB: - case GL_RGB_INTEGER: - *rSrc = 0; - *gSrc = 1; - *bSrc = 2; - *aSrc = -1; - *rDst = 0; - *gDst = 1; - *bDst = 2; - *aDst = 3; - break; - case GL_BGR: - *rSrc = 2; - *gSrc = 1; - *bSrc = 0; - *aSrc = -1; - *rDst = 2; - *gDst = 1; - *bDst = 0; - *aDst = 3; - break; - case GL_RGBA: - case GL_RGBA_INTEGER: - *rSrc = 0; - *gSrc = 1; - *bSrc = 2; - *aSrc = 3; - *rDst = 0; - *gDst = 1; - *bDst = 2; - *aDst = 3; - break; - case GL_BGRA: - *rSrc = 2; - *gSrc = 1; - *bSrc = 0; - *aSrc = 3; - *rDst = 2; - *gDst = 1; - *bDst = 0; - *aDst = 3; - break; - case GL_ABGR_EXT: - *rSrc = 3; - *gSrc = 2; - *bSrc = 1; - *aSrc = 0; - *rDst = 3; - *gDst = 2; - *bDst = 1; - *aDst = 0; - break; - case GL_DU8DV8_ATI: - case GL_DUDV_ATI: - *rSrc = 0; - *gSrc = 1; - *bSrc = -1; - *aSrc = -1; - break; - default: - _mesa_problem(NULL, "bad srcFormat %s in get_component_mapping", - _mesa_lookup_enum_by_nr(format)); - return; - } -} - - - -/* - * This function extracts floating point RGBA values from arbitrary - * image data. srcFormat and srcType are the format and type parameters - * passed to glDrawPixels, glTexImage[123]D, glTexSubImage[123]D, etc. - * - * Refering to section 3.6.4 of the OpenGL 1.2 spec, this function - * implements the "Conversion to floating point", "Conversion to RGB", - * and "Final Expansion to RGBA" operations. - * - * Args: n - number of pixels - * rgba - output colors - * srcFormat - format of incoming data - * srcType - data type of incoming data - * src - source data pointer - * swapBytes - perform byteswapping of incoming data? - */ -static void -extract_float_rgba(GLuint n, GLfloat rgba[][4], - GLenum srcFormat, GLenum srcType, const GLvoid *src, - GLboolean swapBytes) -{ - GLint rSrc, gSrc, bSrc, aSrc; - GLint stride; - GLint rDst, bDst, gDst, aDst; - GLboolean intFormat; - GLfloat rs = 1.0f, gs = 1.0f, bs = 1.0f, as = 1.0f; /* scale factors */ - - ASSERT(srcFormat == GL_RED || - srcFormat == GL_GREEN || - srcFormat == GL_BLUE || - srcFormat == GL_ALPHA || - srcFormat == GL_LUMINANCE || - srcFormat == GL_LUMINANCE_ALPHA || - srcFormat == GL_INTENSITY || - srcFormat == GL_RG || - srcFormat == GL_RGB || - srcFormat == GL_BGR || - srcFormat == GL_RGBA || - srcFormat == GL_BGRA || - srcFormat == GL_ABGR_EXT || - srcFormat == GL_DU8DV8_ATI || - srcFormat == GL_DUDV_ATI || - srcFormat == GL_RED_INTEGER_EXT || - srcFormat == GL_GREEN_INTEGER_EXT || - srcFormat == GL_BLUE_INTEGER_EXT || - srcFormat == GL_ALPHA_INTEGER_EXT || - srcFormat == GL_RGB_INTEGER_EXT || - srcFormat == GL_RGBA_INTEGER_EXT || - srcFormat == GL_BGR_INTEGER_EXT || - srcFormat == GL_BGRA_INTEGER_EXT || - srcFormat == GL_LUMINANCE_INTEGER_EXT || - srcFormat == GL_LUMINANCE_ALPHA_INTEGER_EXT); - - ASSERT(srcType == GL_UNSIGNED_BYTE || - srcType == GL_BYTE || - srcType == GL_UNSIGNED_SHORT || - srcType == GL_SHORT || - srcType == GL_UNSIGNED_INT || - srcType == GL_INT || - srcType == GL_HALF_FLOAT_ARB || - srcType == GL_FLOAT || - srcType == GL_UNSIGNED_BYTE_3_3_2 || - srcType == GL_UNSIGNED_BYTE_2_3_3_REV || - srcType == GL_UNSIGNED_SHORT_5_6_5 || - srcType == GL_UNSIGNED_SHORT_5_6_5_REV || - srcType == GL_UNSIGNED_SHORT_4_4_4_4 || - srcType == GL_UNSIGNED_SHORT_4_4_4_4_REV || - srcType == GL_UNSIGNED_SHORT_5_5_5_1 || - srcType == GL_UNSIGNED_SHORT_1_5_5_5_REV || - srcType == GL_UNSIGNED_INT_8_8_8_8 || - srcType == GL_UNSIGNED_INT_8_8_8_8_REV || - srcType == GL_UNSIGNED_INT_10_10_10_2 || - srcType == GL_UNSIGNED_INT_2_10_10_10_REV || - srcType == GL_UNSIGNED_INT_5_9_9_9_REV || - srcType == GL_UNSIGNED_INT_10F_11F_11F_REV); - - get_component_mapping(srcFormat, - &rSrc, &gSrc, &bSrc, &aSrc, - &rDst, &gDst, &bDst, &aDst); - - stride = _mesa_components_in_format(srcFormat); - - intFormat = _mesa_is_integer_format(srcFormat); - -#define PROCESS(SRC_INDEX, DST_INDEX, DEFAULT_FLT, DEFAULT_INT, TYPE, CONVERSION) \ - if ((SRC_INDEX) < 0) { \ - GLuint i; \ - if (intFormat) { \ - for (i = 0; i < n; i++) { \ - rgba[i][DST_INDEX] = DEFAULT_INT; \ - } \ - } \ - else { \ - for (i = 0; i < n; i++) { \ - rgba[i][DST_INDEX] = DEFAULT_FLT; \ - } \ - } \ - } \ - else if (swapBytes) { \ - const TYPE *s = (const TYPE *) src; \ - GLuint i; \ - for (i = 0; i < n; i++) { \ - TYPE value = s[SRC_INDEX]; \ - if (sizeof(TYPE) == 2) { \ - SWAP2BYTE(value); \ - } \ - else if (sizeof(TYPE) == 4) { \ - SWAP4BYTE(value); \ - } \ - if (intFormat) \ - rgba[i][DST_INDEX] = (GLfloat) value; \ - else \ - rgba[i][DST_INDEX] = (GLfloat) CONVERSION(value); \ - s += stride; \ - } \ - } \ - else { \ - const TYPE *s = (const TYPE *) src; \ - GLuint i; \ - if (intFormat) { \ - for (i = 0; i < n; i++) { \ - rgba[i][DST_INDEX] = (GLfloat) s[SRC_INDEX]; \ - s += stride; \ - } \ - } \ - else { \ - for (i = 0; i < n; i++) { \ - rgba[i][DST_INDEX] = (GLfloat) CONVERSION(s[SRC_INDEX]); \ - s += stride; \ - } \ - } \ - } - - switch (srcType) { - case GL_UNSIGNED_BYTE: - PROCESS(rSrc, RCOMP, 0.0F, 0, GLubyte, UBYTE_TO_FLOAT); - PROCESS(gSrc, GCOMP, 0.0F, 0, GLubyte, UBYTE_TO_FLOAT); - PROCESS(bSrc, BCOMP, 0.0F, 0, GLubyte, UBYTE_TO_FLOAT); - PROCESS(aSrc, ACOMP, 1.0F, 255, GLubyte, UBYTE_TO_FLOAT); - break; - case GL_BYTE: - PROCESS(rSrc, RCOMP, 0.0F, 0, GLbyte, BYTE_TO_FLOAT); - PROCESS(gSrc, GCOMP, 0.0F, 0, GLbyte, BYTE_TO_FLOAT); - PROCESS(bSrc, BCOMP, 0.0F, 0, GLbyte, BYTE_TO_FLOAT); - PROCESS(aSrc, ACOMP, 1.0F, 127, GLbyte, BYTE_TO_FLOAT); - break; - case GL_UNSIGNED_SHORT: - PROCESS(rSrc, RCOMP, 0.0F, 0, GLushort, USHORT_TO_FLOAT); - PROCESS(gSrc, GCOMP, 0.0F, 0, GLushort, USHORT_TO_FLOAT); - PROCESS(bSrc, BCOMP, 0.0F, 0, GLushort, USHORT_TO_FLOAT); - PROCESS(aSrc, ACOMP, 1.0F, 0xffff, GLushort, USHORT_TO_FLOAT); - break; - case GL_SHORT: - PROCESS(rSrc, RCOMP, 0.0F, 0, GLshort, SHORT_TO_FLOAT); - PROCESS(gSrc, GCOMP, 0.0F, 0, GLshort, SHORT_TO_FLOAT); - PROCESS(bSrc, BCOMP, 0.0F, 0, GLshort, SHORT_TO_FLOAT); - PROCESS(aSrc, ACOMP, 1.0F, 32767, GLshort, SHORT_TO_FLOAT); - break; - case GL_UNSIGNED_INT: - PROCESS(rSrc, RCOMP, 0.0F, 0, GLuint, UINT_TO_FLOAT); - PROCESS(gSrc, GCOMP, 0.0F, 0, GLuint, UINT_TO_FLOAT); - PROCESS(bSrc, BCOMP, 0.0F, 0, GLuint, UINT_TO_FLOAT); - PROCESS(aSrc, ACOMP, 1.0F, 0xffffffff, GLuint, UINT_TO_FLOAT); - break; - case GL_INT: - PROCESS(rSrc, RCOMP, 0.0F, 0, GLint, INT_TO_FLOAT); - PROCESS(gSrc, GCOMP, 0.0F, 0, GLint, INT_TO_FLOAT); - PROCESS(bSrc, BCOMP, 0.0F, 0, GLint, INT_TO_FLOAT); - PROCESS(aSrc, ACOMP, 1.0F, 2147483647, GLint, INT_TO_FLOAT); - break; - case GL_FLOAT: - PROCESS(rSrc, RCOMP, 0.0F, 0.0F, GLfloat, (GLfloat)); - PROCESS(gSrc, GCOMP, 0.0F, 0.0F, GLfloat, (GLfloat)); - PROCESS(bSrc, BCOMP, 0.0F, 0.0F, GLfloat, (GLfloat)); - PROCESS(aSrc, ACOMP, 1.0F, 1.0F, GLfloat, (GLfloat)); - break; - case GL_HALF_FLOAT_ARB: - PROCESS(rSrc, RCOMP, 0.0F, 0.0F, GLhalfARB, _mesa_half_to_float); - PROCESS(gSrc, GCOMP, 0.0F, 0.0F, GLhalfARB, _mesa_half_to_float); - PROCESS(bSrc, BCOMP, 0.0F, 0.0F, GLhalfARB, _mesa_half_to_float); - PROCESS(aSrc, ACOMP, 1.0F, 1.0F, GLhalfARB, _mesa_half_to_float); - break; - case GL_UNSIGNED_BYTE_3_3_2: - { - const GLubyte *ubsrc = (const GLubyte *) src; - GLuint i; - if (!intFormat) { - rs = 1.0F / 7.0F; - gs = 1.0F / 7.0F; - bs = 1.0F / 3.0F; - } - for (i = 0; i < n; i ++) { - GLubyte p = ubsrc[i]; - rgba[i][rDst] = ((p >> 5) ) * rs; - rgba[i][gDst] = ((p >> 2) & 0x7) * gs; - rgba[i][bDst] = ((p ) & 0x3) * bs; - rgba[i][aDst] = 1.0F; - } - } - break; - case GL_UNSIGNED_BYTE_2_3_3_REV: - { - const GLubyte *ubsrc = (const GLubyte *) src; - GLuint i; - if (!intFormat) { - rs = 1.0F / 7.0F; - gs = 1.0F / 7.0F; - bs = 1.0F / 3.0F; - } - for (i = 0; i < n; i ++) { - GLubyte p = ubsrc[i]; - rgba[i][rDst] = ((p ) & 0x7) * rs; - rgba[i][gDst] = ((p >> 3) & 0x7) * gs; - rgba[i][bDst] = ((p >> 6) ) * bs; - rgba[i][aDst] = 1.0F; - } - } - break; - case GL_UNSIGNED_SHORT_5_6_5: - if (!intFormat) { - rs = 1.0F / 31.0F; - gs = 1.0F / 63.0F; - bs = 1.0F / 31.0F; - } - if (swapBytes) { - const GLushort *ussrc = (const GLushort *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLushort p = ussrc[i]; - SWAP2BYTE(p); - rgba[i][rDst] = ((p >> 11) ) * rs; - rgba[i][gDst] = ((p >> 5) & 0x3f) * gs; - rgba[i][bDst] = ((p ) & 0x1f) * bs; - rgba[i][aDst] = 1.0F; - } - } - else { - const GLushort *ussrc = (const GLushort *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLushort p = ussrc[i]; - rgba[i][rDst] = ((p >> 11) ) * rs; - rgba[i][gDst] = ((p >> 5) & 0x3f) * gs; - rgba[i][bDst] = ((p ) & 0x1f) * bs; - rgba[i][aDst] = 1.0F; - } - } - break; - case GL_UNSIGNED_SHORT_5_6_5_REV: - if (!intFormat) { - rs = 1.0F / 31.0F; - gs = 1.0F / 63.0F; - bs = 1.0F / 31.0F; - } - if (swapBytes) { - const GLushort *ussrc = (const GLushort *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLushort p = ussrc[i]; - SWAP2BYTE(p); - rgba[i][rDst] = ((p ) & 0x1f) * rs; - rgba[i][gDst] = ((p >> 5) & 0x3f) * gs; - rgba[i][bDst] = ((p >> 11) ) * bs; - rgba[i][aDst] = 1.0F; - } - } - else { - const GLushort *ussrc = (const GLushort *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLushort p = ussrc[i]; - rgba[i][rDst] = ((p ) & 0x1f) * rs; - rgba[i][gDst] = ((p >> 5) & 0x3f) * gs; - rgba[i][bDst] = ((p >> 11) ) * bs; - rgba[i][aDst] = 1.0F; - } - } - break; - case GL_UNSIGNED_SHORT_4_4_4_4: - if (!intFormat) { - rs = gs = bs = as = 1.0F / 15.0F; - } - if (swapBytes) { - const GLushort *ussrc = (const GLushort *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLushort p = ussrc[i]; - SWAP2BYTE(p); - rgba[i][rDst] = ((p >> 12) ) * rs; - rgba[i][gDst] = ((p >> 8) & 0xf) * gs; - rgba[i][bDst] = ((p >> 4) & 0xf) * bs; - rgba[i][aDst] = ((p ) & 0xf) * as; - } - } - else { - const GLushort *ussrc = (const GLushort *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLushort p = ussrc[i]; - rgba[i][rDst] = ((p >> 12) ) * rs; - rgba[i][gDst] = ((p >> 8) & 0xf) * gs; - rgba[i][bDst] = ((p >> 4) & 0xf) * bs; - rgba[i][aDst] = ((p ) & 0xf) * as; - } - } - break; - case GL_UNSIGNED_SHORT_4_4_4_4_REV: - if (!intFormat) { - rs = gs = bs = as = 1.0F / 15.0F; - } - if (swapBytes) { - const GLushort *ussrc = (const GLushort *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLushort p = ussrc[i]; - SWAP2BYTE(p); - rgba[i][rDst] = ((p ) & 0xf) * rs; - rgba[i][gDst] = ((p >> 4) & 0xf) * gs; - rgba[i][bDst] = ((p >> 8) & 0xf) * bs; - rgba[i][aDst] = ((p >> 12) ) * as; - } - } - else { - const GLushort *ussrc = (const GLushort *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLushort p = ussrc[i]; - rgba[i][rDst] = ((p ) & 0xf) * rs; - rgba[i][gDst] = ((p >> 4) & 0xf) * gs; - rgba[i][bDst] = ((p >> 8) & 0xf) * bs; - rgba[i][aDst] = ((p >> 12) ) * as; - } - } - break; - case GL_UNSIGNED_SHORT_5_5_5_1: - if (!intFormat) { - rs = gs = bs = 1.0F / 31.0F; - } - if (swapBytes) { - const GLushort *ussrc = (const GLushort *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLushort p = ussrc[i]; - SWAP2BYTE(p); - rgba[i][rDst] = ((p >> 11) ) * rs; - rgba[i][gDst] = ((p >> 6) & 0x1f) * gs; - rgba[i][bDst] = ((p >> 1) & 0x1f) * bs; - rgba[i][aDst] = ((p ) & 0x1) * as; - } - } - else { - const GLushort *ussrc = (const GLushort *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLushort p = ussrc[i]; - rgba[i][rDst] = ((p >> 11) ) * rs; - rgba[i][gDst] = ((p >> 6) & 0x1f) * gs; - rgba[i][bDst] = ((p >> 1) & 0x1f) * bs; - rgba[i][aDst] = ((p ) & 0x1) * as; - } - } - break; - case GL_UNSIGNED_SHORT_1_5_5_5_REV: - if (!intFormat) { - rs = gs = bs = 1.0F / 31.0F; - } - if (swapBytes) { - const GLushort *ussrc = (const GLushort *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLushort p = ussrc[i]; - SWAP2BYTE(p); - rgba[i][rDst] = ((p ) & 0x1f) * rs; - rgba[i][gDst] = ((p >> 5) & 0x1f) * gs; - rgba[i][bDst] = ((p >> 10) & 0x1f) * bs; - rgba[i][aDst] = ((p >> 15) ) * as; - } - } - else { - const GLushort *ussrc = (const GLushort *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLushort p = ussrc[i]; - rgba[i][rDst] = ((p ) & 0x1f) * rs; - rgba[i][gDst] = ((p >> 5) & 0x1f) * gs; - rgba[i][bDst] = ((p >> 10) & 0x1f) * bs; - rgba[i][aDst] = ((p >> 15) ) * as; - } - } - break; - case GL_UNSIGNED_INT_8_8_8_8: - if (swapBytes) { - const GLuint *uisrc = (const GLuint *) src; - GLuint i; - if (intFormat) { - for (i = 0; i < n; i ++) { - GLuint p = uisrc[i]; - rgba[i][rDst] = (GLfloat) ((p ) & 0xff); - rgba[i][gDst] = (GLfloat) ((p >> 8) & 0xff); - rgba[i][bDst] = (GLfloat) ((p >> 16) & 0xff); - rgba[i][aDst] = (GLfloat) ((p >> 24) ); - } - } - else { - for (i = 0; i < n; i ++) { - GLuint p = uisrc[i]; - rgba[i][rDst] = UBYTE_TO_FLOAT((p ) & 0xff); - rgba[i][gDst] = UBYTE_TO_FLOAT((p >> 8) & 0xff); - rgba[i][bDst] = UBYTE_TO_FLOAT((p >> 16) & 0xff); - rgba[i][aDst] = UBYTE_TO_FLOAT((p >> 24) ); - } - } - } - else { - const GLuint *uisrc = (const GLuint *) src; - GLuint i; - if (intFormat) { - for (i = 0; i < n; i ++) { - GLuint p = uisrc[i]; - rgba[i][rDst] = (GLfloat) ((p >> 24) ); - rgba[i][gDst] = (GLfloat) ((p >> 16) & 0xff); - rgba[i][bDst] = (GLfloat) ((p >> 8) & 0xff); - rgba[i][aDst] = (GLfloat) ((p ) & 0xff); - } - } - else { - for (i = 0; i < n; i ++) { - GLuint p = uisrc[i]; - rgba[i][rDst] = UBYTE_TO_FLOAT((p >> 24) ); - rgba[i][gDst] = UBYTE_TO_FLOAT((p >> 16) & 0xff); - rgba[i][bDst] = UBYTE_TO_FLOAT((p >> 8) & 0xff); - rgba[i][aDst] = UBYTE_TO_FLOAT((p ) & 0xff); - } - } - } - break; - case GL_UNSIGNED_INT_8_8_8_8_REV: - if (swapBytes) { - const GLuint *uisrc = (const GLuint *) src; - GLuint i; - if (intFormat) { - for (i = 0; i < n; i ++) { - GLuint p = uisrc[i]; - rgba[i][rDst] = (GLfloat) ((p >> 24) ); - rgba[i][gDst] = (GLfloat) ((p >> 16) & 0xff); - rgba[i][bDst] = (GLfloat) ((p >> 8) & 0xff); - rgba[i][aDst] = (GLfloat) ((p ) & 0xff); - } - } - else { - for (i = 0; i < n; i ++) { - GLuint p = uisrc[i]; - rgba[i][rDst] = UBYTE_TO_FLOAT((p >> 24) ); - rgba[i][gDst] = UBYTE_TO_FLOAT((p >> 16) & 0xff); - rgba[i][bDst] = UBYTE_TO_FLOAT((p >> 8) & 0xff); - rgba[i][aDst] = UBYTE_TO_FLOAT((p ) & 0xff); - } - } - } - else { - const GLuint *uisrc = (const GLuint *) src; - GLuint i; - if (intFormat) { - for (i = 0; i < n; i ++) { - GLuint p = uisrc[i]; - rgba[i][rDst] = (GLfloat) ((p ) & 0xff); - rgba[i][gDst] = (GLfloat) ((p >> 8) & 0xff); - rgba[i][bDst] = (GLfloat) ((p >> 16) & 0xff); - rgba[i][aDst] = (GLfloat) ((p >> 24) ); - } - } - else { - for (i = 0; i < n; i ++) { - GLuint p = uisrc[i]; - rgba[i][rDst] = UBYTE_TO_FLOAT((p ) & 0xff); - rgba[i][gDst] = UBYTE_TO_FLOAT((p >> 8) & 0xff); - rgba[i][bDst] = UBYTE_TO_FLOAT((p >> 16) & 0xff); - rgba[i][aDst] = UBYTE_TO_FLOAT((p >> 24) ); - } - } - } - break; - case GL_UNSIGNED_INT_10_10_10_2: - if (!intFormat) { - rs = 1.0F / 1023.0F; - gs = 1.0F / 1023.0F; - bs = 1.0F / 1023.0F; - as = 1.0F / 3.0F; - } - if (swapBytes) { - const GLuint *uisrc = (const GLuint *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLuint p = uisrc[i]; - SWAP4BYTE(p); - rgba[i][rDst] = ((p >> 22) ) * rs; - rgba[i][gDst] = ((p >> 12) & 0x3ff) * gs; - rgba[i][bDst] = ((p >> 2) & 0x3ff) * bs; - rgba[i][aDst] = ((p ) & 0x3 ) * as; - } - } - else { - const GLuint *uisrc = (const GLuint *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLuint p = uisrc[i]; - rgba[i][rDst] = ((p >> 22) ) * rs; - rgba[i][gDst] = ((p >> 12) & 0x3ff) * gs; - rgba[i][bDst] = ((p >> 2) & 0x3ff) * bs; - rgba[i][aDst] = ((p ) & 0x3 ) * as; - } - } - break; - case GL_UNSIGNED_INT_2_10_10_10_REV: - if (!intFormat) { - rs = 1.0F / 1023.0F; - gs = 1.0F / 1023.0F; - bs = 1.0F / 1023.0F; - as = 1.0F / 3.0F; - } - if (swapBytes) { - const GLuint *uisrc = (const GLuint *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLuint p = uisrc[i]; - SWAP4BYTE(p); - rgba[i][rDst] = ((p ) & 0x3ff) * rs; - rgba[i][gDst] = ((p >> 10) & 0x3ff) * gs; - rgba[i][bDst] = ((p >> 20) & 0x3ff) * bs; - rgba[i][aDst] = ((p >> 30) ) * as; - } - } - else { - const GLuint *uisrc = (const GLuint *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLuint p = uisrc[i]; - rgba[i][rDst] = ((p ) & 0x3ff) * rs; - rgba[i][gDst] = ((p >> 10) & 0x3ff) * gs; - rgba[i][bDst] = ((p >> 20) & 0x3ff) * bs; - rgba[i][aDst] = ((p >> 30) ) * as; - } - } - break; - case GL_UNSIGNED_INT_5_9_9_9_REV: - if (swapBytes) { - const GLuint *uisrc = (const GLuint *) src; - GLuint i; - GLfloat f[3]; - for (i = 0; i < n; i ++) { - GLuint p = uisrc[i]; - SWAP4BYTE(p); - rgb9e5_to_float3(p, f); - rgba[i][rDst] = f[0]; - rgba[i][gDst] = f[1]; - rgba[i][bDst] = f[2]; - rgba[i][aDst] = 1.0F; - } - } - else { - const GLuint *uisrc = (const GLuint *) src; - GLuint i; - GLfloat f[3]; - for (i = 0; i < n; i ++) { - rgb9e5_to_float3(uisrc[i], f); - rgba[i][rDst] = f[0]; - rgba[i][gDst] = f[1]; - rgba[i][bDst] = f[2]; - rgba[i][aDst] = 1.0F; - } - } - break; - case GL_UNSIGNED_INT_10F_11F_11F_REV: - if (swapBytes) { - const GLuint *uisrc = (const GLuint *) src; - GLuint i; - GLfloat f[3]; - for (i = 0; i < n; i ++) { - GLuint p = uisrc[i]; - SWAP4BYTE(p); - r11g11b10f_to_float3(p, f); - rgba[i][rDst] = f[0]; - rgba[i][gDst] = f[1]; - rgba[i][bDst] = f[2]; - rgba[i][aDst] = 1.0F; - } - } - else { - const GLuint *uisrc = (const GLuint *) src; - GLuint i; - GLfloat f[3]; - for (i = 0; i < n; i ++) { - r11g11b10f_to_float3(uisrc[i], f); - rgba[i][rDst] = f[0]; - rgba[i][gDst] = f[1]; - rgba[i][bDst] = f[2]; - rgba[i][aDst] = 1.0F; - } - } - break; - default: - _mesa_problem(NULL, "bad srcType in extract float data"); - break; - } -#undef PROCESS -} - - -static INLINE GLuint -clamp_byte_to_uint(GLbyte b) -{ - return b < 0 ? 0 : b; -} - - -static INLINE GLuint -clamp_short_to_uint(GLshort s) -{ - return s < 0 ? 0 : s; -} - - -static INLINE GLuint -clamp_int_to_uint(GLint i) -{ - return i < 0 ? 0 : i; -} - - -static INLINE GLuint -clamp_float_to_uint(GLfloat f) -{ - return f < 0.0F ? 0 : IROUND(f); -} - - -static INLINE GLuint -clamp_half_to_uint(GLhalfARB h) -{ - GLfloat f = _mesa_half_to_float(h); - return f < 0.0F ? 0 : IROUND(f); -} - - -/** - * \sa extract_float_rgba() - */ -static void -extract_uint_rgba(GLuint n, GLuint rgba[][4], - GLenum srcFormat, GLenum srcType, const GLvoid *src, - GLboolean swapBytes) -{ - GLint rSrc, gSrc, bSrc, aSrc; - GLint stride; - GLint rDst, bDst, gDst, aDst; - - ASSERT(srcFormat == GL_RED || - srcFormat == GL_GREEN || - srcFormat == GL_BLUE || - srcFormat == GL_ALPHA || - srcFormat == GL_LUMINANCE || - srcFormat == GL_LUMINANCE_ALPHA || - srcFormat == GL_INTENSITY || - srcFormat == GL_RG || - srcFormat == GL_RGB || - srcFormat == GL_BGR || - srcFormat == GL_RGBA || - srcFormat == GL_BGRA || - srcFormat == GL_ABGR_EXT || - srcFormat == GL_DU8DV8_ATI || - srcFormat == GL_DUDV_ATI || - srcFormat == GL_RED_INTEGER_EXT || - srcFormat == GL_GREEN_INTEGER_EXT || - srcFormat == GL_BLUE_INTEGER_EXT || - srcFormat == GL_ALPHA_INTEGER_EXT || - srcFormat == GL_RGB_INTEGER_EXT || - srcFormat == GL_RGBA_INTEGER_EXT || - srcFormat == GL_BGR_INTEGER_EXT || - srcFormat == GL_BGRA_INTEGER_EXT || - srcFormat == GL_LUMINANCE_INTEGER_EXT || - srcFormat == GL_LUMINANCE_ALPHA_INTEGER_EXT); - - ASSERT(srcType == GL_UNSIGNED_BYTE || - srcType == GL_BYTE || - srcType == GL_UNSIGNED_SHORT || - srcType == GL_SHORT || - srcType == GL_UNSIGNED_INT || - srcType == GL_INT || - srcType == GL_HALF_FLOAT_ARB || - srcType == GL_FLOAT || - srcType == GL_UNSIGNED_BYTE_3_3_2 || - srcType == GL_UNSIGNED_BYTE_2_3_3_REV || - srcType == GL_UNSIGNED_SHORT_5_6_5 || - srcType == GL_UNSIGNED_SHORT_5_6_5_REV || - srcType == GL_UNSIGNED_SHORT_4_4_4_4 || - srcType == GL_UNSIGNED_SHORT_4_4_4_4_REV || - srcType == GL_UNSIGNED_SHORT_5_5_5_1 || - srcType == GL_UNSIGNED_SHORT_1_5_5_5_REV || - srcType == GL_UNSIGNED_INT_8_8_8_8 || - srcType == GL_UNSIGNED_INT_8_8_8_8_REV || - srcType == GL_UNSIGNED_INT_10_10_10_2 || - srcType == GL_UNSIGNED_INT_2_10_10_10_REV || - srcType == GL_UNSIGNED_INT_5_9_9_9_REV || - srcType == GL_UNSIGNED_INT_10F_11F_11F_REV); - - get_component_mapping(srcFormat, - &rSrc, &gSrc, &bSrc, &aSrc, - &rDst, &gDst, &bDst, &aDst); - - stride = _mesa_components_in_format(srcFormat); - -#define PROCESS(SRC_INDEX, DST_INDEX, DEFAULT, TYPE, CONVERSION) \ - if ((SRC_INDEX) < 0) { \ - GLuint i; \ - for (i = 0; i < n; i++) { \ - rgba[i][DST_INDEX] = DEFAULT; \ - } \ - } \ - else if (swapBytes) { \ - const TYPE *s = (const TYPE *) src; \ - GLuint i; \ - for (i = 0; i < n; i++) { \ - TYPE value = s[SRC_INDEX]; \ - if (sizeof(TYPE) == 2) { \ - SWAP2BYTE(value); \ - } \ - else if (sizeof(TYPE) == 4) { \ - SWAP4BYTE(value); \ - } \ - rgba[i][DST_INDEX] = CONVERSION(value); \ - s += stride; \ - } \ - } \ - else { \ - const TYPE *s = (const TYPE *) src; \ - GLuint i; \ - for (i = 0; i < n; i++) { \ - rgba[i][DST_INDEX] = CONVERSION(s[SRC_INDEX]); \ - s += stride; \ - } \ - } - - switch (srcType) { - case GL_UNSIGNED_BYTE: - PROCESS(rSrc, RCOMP, 0, GLubyte, (GLuint)); - PROCESS(gSrc, GCOMP, 0, GLubyte, (GLuint)); - PROCESS(bSrc, BCOMP, 0, GLubyte, (GLuint)); - PROCESS(aSrc, ACOMP, 1, GLubyte, (GLuint)); - break; - case GL_BYTE: - PROCESS(rSrc, RCOMP, 0, GLbyte, clamp_byte_to_uint); - PROCESS(gSrc, GCOMP, 0, GLbyte, clamp_byte_to_uint); - PROCESS(bSrc, BCOMP, 0, GLbyte, clamp_byte_to_uint); - PROCESS(aSrc, ACOMP, 1, GLbyte, clamp_byte_to_uint); - break; - case GL_UNSIGNED_SHORT: - PROCESS(rSrc, RCOMP, 0, GLushort, (GLuint)); - PROCESS(gSrc, GCOMP, 0, GLushort, (GLuint)); - PROCESS(bSrc, BCOMP, 0, GLushort, (GLuint)); - PROCESS(aSrc, ACOMP, 1, GLushort, (GLuint)); - break; - case GL_SHORT: - PROCESS(rSrc, RCOMP, 0, GLshort, clamp_short_to_uint); - PROCESS(gSrc, GCOMP, 0, GLshort, clamp_short_to_uint); - PROCESS(bSrc, BCOMP, 0, GLshort, clamp_short_to_uint); - PROCESS(aSrc, ACOMP, 1, GLshort, clamp_short_to_uint); - break; - case GL_UNSIGNED_INT: - PROCESS(rSrc, RCOMP, 0, GLuint, (GLuint)); - PROCESS(gSrc, GCOMP, 0, GLuint, (GLuint)); - PROCESS(bSrc, BCOMP, 0, GLuint, (GLuint)); - PROCESS(aSrc, ACOMP, 1, GLuint, (GLuint)); - break; - case GL_INT: - PROCESS(rSrc, RCOMP, 0, GLint, clamp_int_to_uint); - PROCESS(gSrc, GCOMP, 0, GLint, clamp_int_to_uint); - PROCESS(bSrc, BCOMP, 0, GLint, clamp_int_to_uint); - PROCESS(aSrc, ACOMP, 1, GLint, clamp_int_to_uint); - break; - case GL_FLOAT: - PROCESS(rSrc, RCOMP, 0, GLfloat, clamp_float_to_uint); - PROCESS(gSrc, GCOMP, 0, GLfloat, clamp_float_to_uint); - PROCESS(bSrc, BCOMP, 0, GLfloat, clamp_float_to_uint); - PROCESS(aSrc, ACOMP, 1, GLfloat, clamp_float_to_uint); - break; - case GL_HALF_FLOAT_ARB: - PROCESS(rSrc, RCOMP, 0, GLhalfARB, clamp_half_to_uint); - PROCESS(gSrc, GCOMP, 0, GLhalfARB, clamp_half_to_uint); - PROCESS(bSrc, BCOMP, 0, GLhalfARB, clamp_half_to_uint); - PROCESS(aSrc, ACOMP, 1, GLhalfARB, clamp_half_to_uint); - break; - case GL_UNSIGNED_BYTE_3_3_2: - { - const GLubyte *ubsrc = (const GLubyte *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLubyte p = ubsrc[i]; - rgba[i][rDst] = ((p >> 5) ); - rgba[i][gDst] = ((p >> 2) & 0x7); - rgba[i][bDst] = ((p ) & 0x3); - rgba[i][aDst] = 1; - } - } - break; - case GL_UNSIGNED_BYTE_2_3_3_REV: - { - const GLubyte *ubsrc = (const GLubyte *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLubyte p = ubsrc[i]; - rgba[i][rDst] = ((p ) & 0x7); - rgba[i][gDst] = ((p >> 3) & 0x7); - rgba[i][bDst] = ((p >> 6) ); - rgba[i][aDst] = 1; - } - } - break; - case GL_UNSIGNED_SHORT_5_6_5: - if (swapBytes) { - const GLushort *ussrc = (const GLushort *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLushort p = ussrc[i]; - SWAP2BYTE(p); - rgba[i][rDst] = ((p >> 11) ); - rgba[i][gDst] = ((p >> 5) & 0x3f); - rgba[i][bDst] = ((p ) & 0x1f); - rgba[i][aDst] = 1; - } - } - else { - const GLushort *ussrc = (const GLushort *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLushort p = ussrc[i]; - rgba[i][rDst] = ((p >> 11) ); - rgba[i][gDst] = ((p >> 5) & 0x3f); - rgba[i][bDst] = ((p ) & 0x1f); - rgba[i][aDst] = 1; - } - } - break; - case GL_UNSIGNED_SHORT_5_6_5_REV: - if (swapBytes) { - const GLushort *ussrc = (const GLushort *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLushort p = ussrc[i]; - SWAP2BYTE(p); - rgba[i][rDst] = ((p ) & 0x1f); - rgba[i][gDst] = ((p >> 5) & 0x3f); - rgba[i][bDst] = ((p >> 11) ); - rgba[i][aDst] = 1; - } - } - else { - const GLushort *ussrc = (const GLushort *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLushort p = ussrc[i]; - rgba[i][rDst] = ((p ) & 0x1f); - rgba[i][gDst] = ((p >> 5) & 0x3f); - rgba[i][bDst] = ((p >> 11) ); - rgba[i][aDst] = 1; - } - } - break; - case GL_UNSIGNED_SHORT_4_4_4_4: - if (swapBytes) { - const GLushort *ussrc = (const GLushort *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLushort p = ussrc[i]; - SWAP2BYTE(p); - rgba[i][rDst] = ((p >> 12) ); - rgba[i][gDst] = ((p >> 8) & 0xf); - rgba[i][bDst] = ((p >> 4) & 0xf); - rgba[i][aDst] = ((p ) & 0xf); - } - } - else { - const GLushort *ussrc = (const GLushort *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLushort p = ussrc[i]; - rgba[i][rDst] = ((p >> 12) ); - rgba[i][gDst] = ((p >> 8) & 0xf); - rgba[i][bDst] = ((p >> 4) & 0xf); - rgba[i][aDst] = ((p ) & 0xf); - } - } - break; - case GL_UNSIGNED_SHORT_4_4_4_4_REV: - if (swapBytes) { - const GLushort *ussrc = (const GLushort *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLushort p = ussrc[i]; - SWAP2BYTE(p); - rgba[i][rDst] = ((p ) & 0xf); - rgba[i][gDst] = ((p >> 4) & 0xf); - rgba[i][bDst] = ((p >> 8) & 0xf); - rgba[i][aDst] = ((p >> 12) ); - } - } - else { - const GLushort *ussrc = (const GLushort *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLushort p = ussrc[i]; - rgba[i][rDst] = ((p ) & 0xf); - rgba[i][gDst] = ((p >> 4) & 0xf); - rgba[i][bDst] = ((p >> 8) & 0xf); - rgba[i][aDst] = ((p >> 12) ); - } - } - break; - case GL_UNSIGNED_SHORT_5_5_5_1: - if (swapBytes) { - const GLushort *ussrc = (const GLushort *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLushort p = ussrc[i]; - SWAP2BYTE(p); - rgba[i][rDst] = ((p >> 11) ); - rgba[i][gDst] = ((p >> 6) & 0x1f); - rgba[i][bDst] = ((p >> 1) & 0x1f); - rgba[i][aDst] = ((p ) & 0x1 ); - } - } - else { - const GLushort *ussrc = (const GLushort *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLushort p = ussrc[i]; - rgba[i][rDst] = ((p >> 11) ); - rgba[i][gDst] = ((p >> 6) & 0x1f); - rgba[i][bDst] = ((p >> 1) & 0x1f); - rgba[i][aDst] = ((p ) & 0x1 ); - } - } - break; - case GL_UNSIGNED_SHORT_1_5_5_5_REV: - if (swapBytes) { - const GLushort *ussrc = (const GLushort *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLushort p = ussrc[i]; - SWAP2BYTE(p); - rgba[i][rDst] = ((p ) & 0x1f); - rgba[i][gDst] = ((p >> 5) & 0x1f); - rgba[i][bDst] = ((p >> 10) & 0x1f); - rgba[i][aDst] = ((p >> 15) ); - } - } - else { - const GLushort *ussrc = (const GLushort *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLushort p = ussrc[i]; - rgba[i][rDst] = ((p ) & 0x1f); - rgba[i][gDst] = ((p >> 5) & 0x1f); - rgba[i][bDst] = ((p >> 10) & 0x1f); - rgba[i][aDst] = ((p >> 15) ); - } - } - break; - case GL_UNSIGNED_INT_8_8_8_8: - if (swapBytes) { - const GLuint *uisrc = (const GLuint *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLuint p = uisrc[i]; - rgba[i][rDst] = ((p ) & 0xff); - rgba[i][gDst] = ((p >> 8) & 0xff); - rgba[i][bDst] = ((p >> 16) & 0xff); - rgba[i][aDst] = ((p >> 24) ); - } - } - else { - const GLuint *uisrc = (const GLuint *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLuint p = uisrc[i]; - rgba[i][rDst] = ((p >> 24) ); - rgba[i][gDst] = ((p >> 16) & 0xff); - rgba[i][bDst] = ((p >> 8) & 0xff); - rgba[i][aDst] = ((p ) & 0xff); - } - } - break; - case GL_UNSIGNED_INT_8_8_8_8_REV: - if (swapBytes) { - const GLuint *uisrc = (const GLuint *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLuint p = uisrc[i]; - rgba[i][rDst] = ((p >> 24) ); - rgba[i][gDst] = ((p >> 16) & 0xff); - rgba[i][bDst] = ((p >> 8) & 0xff); - rgba[i][aDst] = ((p ) & 0xff); - } - } - else { - const GLuint *uisrc = (const GLuint *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLuint p = uisrc[i]; - rgba[i][rDst] = ((p ) & 0xff); - rgba[i][gDst] = ((p >> 8) & 0xff); - rgba[i][bDst] = ((p >> 16) & 0xff); - rgba[i][aDst] = ((p >> 24) ); - } - } - break; - case GL_UNSIGNED_INT_10_10_10_2: - if (swapBytes) { - const GLuint *uisrc = (const GLuint *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLuint p = uisrc[i]; - SWAP4BYTE(p); - rgba[i][rDst] = ((p >> 22) ); - rgba[i][gDst] = ((p >> 12) & 0x3ff); - rgba[i][bDst] = ((p >> 2) & 0x3ff); - rgba[i][aDst] = ((p ) & 0x3 ); - } - } - else { - const GLuint *uisrc = (const GLuint *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLuint p = uisrc[i]; - rgba[i][rDst] = ((p >> 22) ); - rgba[i][gDst] = ((p >> 12) & 0x3ff); - rgba[i][bDst] = ((p >> 2) & 0x3ff); - rgba[i][aDst] = ((p ) & 0x3 ); - } - } - break; - case GL_UNSIGNED_INT_2_10_10_10_REV: - if (swapBytes) { - const GLuint *uisrc = (const GLuint *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLuint p = uisrc[i]; - SWAP4BYTE(p); - rgba[i][rDst] = ((p ) & 0x3ff); - rgba[i][gDst] = ((p >> 10) & 0x3ff); - rgba[i][bDst] = ((p >> 20) & 0x3ff); - rgba[i][aDst] = ((p >> 30) ); - } - } - else { - const GLuint *uisrc = (const GLuint *) src; - GLuint i; - for (i = 0; i < n; i ++) { - GLuint p = uisrc[i]; - rgba[i][rDst] = ((p ) & 0x3ff); - rgba[i][gDst] = ((p >> 10) & 0x3ff); - rgba[i][bDst] = ((p >> 20) & 0x3ff); - rgba[i][aDst] = ((p >> 30) ); - } - } - break; - case GL_UNSIGNED_INT_5_9_9_9_REV: - if (swapBytes) { - const GLuint *uisrc = (const GLuint *) src; - GLuint i; - float f[3]; - for (i = 0; i < n; i ++) { - GLuint p = uisrc[i]; - SWAP4BYTE(p); - rgb9e5_to_float3(p, f); - rgba[i][rDst] = clamp_float_to_uint(f[0]); - rgba[i][gDst] = clamp_float_to_uint(f[1]); - rgba[i][bDst] = clamp_float_to_uint(f[2]); - rgba[i][aDst] = 1; - } - } - else { - const GLuint *uisrc = (const GLuint *) src; - GLuint i; - float f[3]; - for (i = 0; i < n; i ++) { - GLuint p = uisrc[i]; - rgb9e5_to_float3(p, f); - rgba[i][rDst] = clamp_float_to_uint(f[0]); - rgba[i][gDst] = clamp_float_to_uint(f[1]); - rgba[i][bDst] = clamp_float_to_uint(f[2]); - rgba[i][aDst] = 1; - } - } - break; - case GL_UNSIGNED_INT_10F_11F_11F_REV: - if (swapBytes) { - const GLuint *uisrc = (const GLuint *) src; - GLuint i; - float f[3]; - for (i = 0; i < n; i ++) { - GLuint p = uisrc[i]; - SWAP4BYTE(p); - r11g11b10f_to_float3(p, f); - rgba[i][rDst] = clamp_float_to_uint(f[0]); - rgba[i][gDst] = clamp_float_to_uint(f[1]); - rgba[i][bDst] = clamp_float_to_uint(f[2]); - rgba[i][aDst] = 1; - } - } - else { - const GLuint *uisrc = (const GLuint *) src; - GLuint i; - float f[3]; - for (i = 0; i < n; i ++) { - GLuint p = uisrc[i]; - r11g11b10f_to_float3(p, f); - rgba[i][rDst] = clamp_float_to_uint(f[0]); - rgba[i][gDst] = clamp_float_to_uint(f[1]); - rgba[i][bDst] = clamp_float_to_uint(f[2]); - rgba[i][aDst] = 1; - } - } - break; - default: - _mesa_problem(NULL, "bad srcType in extract uint data"); - break; - } -#undef PROCESS -} - - - -/* - * Unpack a row of color image data from a client buffer according to - * the pixel unpacking parameters. - * Return GLchan values in the specified dest image format. - * This is used by glDrawPixels and glTexImage?D(). - * \param ctx - the context - * n - number of pixels in the span - * dstFormat - format of destination color array - * dest - the destination color array - * srcFormat - source image format - * srcType - source image data type - * source - source image pointer - * srcPacking - pixel unpacking parameters - * transferOps - bitmask of IMAGE_*_BIT values of operations to apply - * - * XXX perhaps expand this to process whole images someday. - */ -void -_mesa_unpack_color_span_chan( struct gl_context *ctx, - GLuint n, GLenum dstFormat, GLchan dest[], - GLenum srcFormat, GLenum srcType, - const GLvoid *source, - const struct gl_pixelstore_attrib *srcPacking, - GLbitfield transferOps ) -{ - ASSERT(dstFormat == GL_ALPHA || - dstFormat == GL_LUMINANCE || - dstFormat == GL_LUMINANCE_ALPHA || - dstFormat == GL_INTENSITY || - dstFormat == GL_RED || - dstFormat == GL_RG || - dstFormat == GL_RGB || - dstFormat == GL_RGBA); - - ASSERT(srcFormat == GL_RED || - srcFormat == GL_GREEN || - srcFormat == GL_BLUE || - srcFormat == GL_ALPHA || - srcFormat == GL_LUMINANCE || - srcFormat == GL_LUMINANCE_ALPHA || - srcFormat == GL_INTENSITY || - srcFormat == GL_RG || - srcFormat == GL_RGB || - srcFormat == GL_BGR || - srcFormat == GL_RGBA || - srcFormat == GL_BGRA || - srcFormat == GL_ABGR_EXT || - srcFormat == GL_COLOR_INDEX); - - ASSERT(srcType == GL_BITMAP || - srcType == GL_UNSIGNED_BYTE || - srcType == GL_BYTE || - srcType == GL_UNSIGNED_SHORT || - srcType == GL_SHORT || - srcType == GL_UNSIGNED_INT || - srcType == GL_INT || - srcType == GL_HALF_FLOAT_ARB || - srcType == GL_FLOAT || - srcType == GL_UNSIGNED_BYTE_3_3_2 || - srcType == GL_UNSIGNED_BYTE_2_3_3_REV || - srcType == GL_UNSIGNED_SHORT_5_6_5 || - srcType == GL_UNSIGNED_SHORT_5_6_5_REV || - srcType == GL_UNSIGNED_SHORT_4_4_4_4 || - srcType == GL_UNSIGNED_SHORT_4_4_4_4_REV || - srcType == GL_UNSIGNED_SHORT_5_5_5_1 || - srcType == GL_UNSIGNED_SHORT_1_5_5_5_REV || - srcType == GL_UNSIGNED_INT_8_8_8_8 || - srcType == GL_UNSIGNED_INT_8_8_8_8_REV || - srcType == GL_UNSIGNED_INT_10_10_10_2 || - srcType == GL_UNSIGNED_INT_2_10_10_10_REV || - srcType == GL_UNSIGNED_INT_5_9_9_9_REV || - srcType == GL_UNSIGNED_INT_10F_11F_11F_REV); - - /* Try simple cases first */ - if (transferOps == 0) { - if (srcType == CHAN_TYPE) { - if (dstFormat == GL_RGBA) { - if (srcFormat == GL_RGBA) { - memcpy( dest, source, n * 4 * sizeof(GLchan) ); - return; - } - else if (srcFormat == GL_RGB) { - GLuint i; - const GLchan *src = (const GLchan *) source; - GLchan *dst = dest; - for (i = 0; i < n; i++) { - dst[0] = src[0]; - dst[1] = src[1]; - dst[2] = src[2]; - dst[3] = CHAN_MAX; - src += 3; - dst += 4; - } - return; - } - } - else if (dstFormat == GL_RGB) { - if (srcFormat == GL_RGB) { - memcpy( dest, source, n * 3 * sizeof(GLchan) ); - return; - } - else if (srcFormat == GL_RGBA) { - GLuint i; - const GLchan *src = (const GLchan *) source; - GLchan *dst = dest; - for (i = 0; i < n; i++) { - dst[0] = src[0]; - dst[1] = src[1]; - dst[2] = src[2]; - src += 4; - dst += 3; - } - return; - } - } - else if (dstFormat == srcFormat) { - GLint comps = _mesa_components_in_format(srcFormat); - assert(comps > 0); - memcpy( dest, source, n * comps * sizeof(GLchan) ); - return; - } - } - /* - * Common situation, loading 8bit RGBA/RGB source images - * into 16/32 bit destination. (OSMesa16/32) - */ - else if (srcType == GL_UNSIGNED_BYTE) { - if (dstFormat == GL_RGBA) { - if (srcFormat == GL_RGB) { - GLuint i; - const GLubyte *src = (const GLubyte *) source; - GLchan *dst = dest; - for (i = 0; i < n; i++) { - dst[0] = UBYTE_TO_CHAN(src[0]); - dst[1] = UBYTE_TO_CHAN(src[1]); - dst[2] = UBYTE_TO_CHAN(src[2]); - dst[3] = CHAN_MAX; - src += 3; - dst += 4; - } - return; - } - else if (srcFormat == GL_RGBA) { - GLuint i; - const GLubyte *src = (const GLubyte *) source; - GLchan *dst = dest; - for (i = 0; i < n; i++) { - dst[0] = UBYTE_TO_CHAN(src[0]); - dst[1] = UBYTE_TO_CHAN(src[1]); - dst[2] = UBYTE_TO_CHAN(src[2]); - dst[3] = UBYTE_TO_CHAN(src[3]); - src += 4; - dst += 4; - } - return; - } - } - else if (dstFormat == GL_RGB) { - if (srcFormat == GL_RGB) { - GLuint i; - const GLubyte *src = (const GLubyte *) source; - GLchan *dst = dest; - for (i = 0; i < n; i++) { - dst[0] = UBYTE_TO_CHAN(src[0]); - dst[1] = UBYTE_TO_CHAN(src[1]); - dst[2] = UBYTE_TO_CHAN(src[2]); - src += 3; - dst += 3; - } - return; - } - else if (srcFormat == GL_RGBA) { - GLuint i; - const GLubyte *src = (const GLubyte *) source; - GLchan *dst = dest; - for (i = 0; i < n; i++) { - dst[0] = UBYTE_TO_CHAN(src[0]); - dst[1] = UBYTE_TO_CHAN(src[1]); - dst[2] = UBYTE_TO_CHAN(src[2]); - src += 4; - dst += 3; - } - return; - } - } - } - } - - - /* general solution begins here */ - { - GLint dstComponents; - GLint rDst, gDst, bDst, aDst, lDst, iDst; - GLfloat (*rgba)[4] = (GLfloat (*)[4]) malloc(4 * n * sizeof(GLfloat)); - - if (!rgba) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "pixel unpacking"); - return; - } - - dstComponents = _mesa_components_in_format( dstFormat ); - /* source & dest image formats should have been error checked by now */ - assert(dstComponents > 0); - - /* - * Extract image data and convert to RGBA floats - */ - if (srcFormat == GL_COLOR_INDEX) { - GLuint *indexes = (GLuint *) malloc(n * sizeof(GLuint)); - - if (!indexes) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "pixel unpacking"); - return; - } - - extract_uint_indexes(n, indexes, srcFormat, srcType, source, - srcPacking); - - /* Convert indexes to RGBA */ - if (transferOps & IMAGE_SHIFT_OFFSET_BIT) { - _mesa_shift_and_offset_ci(ctx, n, indexes); - } - _mesa_map_ci_to_rgba(ctx, n, indexes, rgba); - - /* Don't do RGBA scale/bias or RGBA->RGBA mapping if starting - * with color indexes. - */ - transferOps &= ~(IMAGE_SCALE_BIAS_BIT | IMAGE_MAP_COLOR_BIT); - - free(indexes); - } - else { - /* non-color index data */ - extract_float_rgba(n, rgba, srcFormat, srcType, source, - srcPacking->SwapBytes); - } - - /* Need to clamp if returning GLubytes or GLushorts */ -#if CHAN_TYPE != GL_FLOAT - transferOps |= IMAGE_CLAMP_BIT; -#endif - - if (transferOps) { - _mesa_apply_rgba_transfer_ops(ctx, transferOps, n, rgba); - } - - get_component_indexes(dstFormat, - &rDst, &gDst, &bDst, &aDst, &lDst, &iDst); - - /* Now return the GLchan data in the requested dstFormat */ - if (rDst >= 0) { - GLchan *dst = dest; - GLuint i; - for (i = 0; i < n; i++) { - CLAMPED_FLOAT_TO_CHAN(dst[rDst], rgba[i][RCOMP]); - dst += dstComponents; - } - } - - if (gDst >= 0) { - GLchan *dst = dest; - GLuint i; - for (i = 0; i < n; i++) { - CLAMPED_FLOAT_TO_CHAN(dst[gDst], rgba[i][GCOMP]); - dst += dstComponents; - } - } - - if (bDst >= 0) { - GLchan *dst = dest; - GLuint i; - for (i = 0; i < n; i++) { - CLAMPED_FLOAT_TO_CHAN(dst[bDst], rgba[i][BCOMP]); - dst += dstComponents; - } - } - - if (aDst >= 0) { - GLchan *dst = dest; - GLuint i; - for (i = 0; i < n; i++) { - CLAMPED_FLOAT_TO_CHAN(dst[aDst], rgba[i][ACOMP]); - dst += dstComponents; - } - } - - if (iDst >= 0) { - GLchan *dst = dest; - GLuint i; - assert(iDst == 0); - assert(dstComponents == 1); - for (i = 0; i < n; i++) { - /* Intensity comes from red channel */ - CLAMPED_FLOAT_TO_CHAN(dst[i], rgba[i][RCOMP]); - } - } - - if (lDst >= 0) { - GLchan *dst = dest; - GLuint i; - assert(lDst == 0); - for (i = 0; i < n; i++) { - /* Luminance comes from red channel */ - CLAMPED_FLOAT_TO_CHAN(dst[0], rgba[i][RCOMP]); - dst += dstComponents; - } - } - - free(rgba); - } -} - - -/** - * Same as _mesa_unpack_color_span_chan(), but return GLfloat data - * instead of GLchan. - */ -void -_mesa_unpack_color_span_float( struct gl_context *ctx, - GLuint n, GLenum dstFormat, GLfloat dest[], - GLenum srcFormat, GLenum srcType, - const GLvoid *source, - const struct gl_pixelstore_attrib *srcPacking, - GLbitfield transferOps ) -{ - ASSERT(dstFormat == GL_ALPHA || - dstFormat == GL_LUMINANCE || - dstFormat == GL_LUMINANCE_ALPHA || - dstFormat == GL_INTENSITY || - dstFormat == GL_RED || - dstFormat == GL_RG || - dstFormat == GL_RGB || - dstFormat == GL_RGBA); - - ASSERT(srcFormat == GL_RED || - srcFormat == GL_GREEN || - srcFormat == GL_BLUE || - srcFormat == GL_ALPHA || - srcFormat == GL_LUMINANCE || - srcFormat == GL_LUMINANCE_ALPHA || - srcFormat == GL_INTENSITY || - srcFormat == GL_RG || - srcFormat == GL_RGB || - srcFormat == GL_BGR || - srcFormat == GL_RGBA || - srcFormat == GL_BGRA || - srcFormat == GL_ABGR_EXT || - srcFormat == GL_RED_INTEGER_EXT || - srcFormat == GL_GREEN_INTEGER_EXT || - srcFormat == GL_BLUE_INTEGER_EXT || - srcFormat == GL_ALPHA_INTEGER_EXT || - srcFormat == GL_RGB_INTEGER_EXT || - srcFormat == GL_RGBA_INTEGER_EXT || - srcFormat == GL_BGR_INTEGER_EXT || - srcFormat == GL_BGRA_INTEGER_EXT || - srcFormat == GL_LUMINANCE_INTEGER_EXT || - srcFormat == GL_LUMINANCE_ALPHA_INTEGER_EXT || - srcFormat == GL_COLOR_INDEX); - - ASSERT(srcType == GL_BITMAP || - srcType == GL_UNSIGNED_BYTE || - srcType == GL_BYTE || - srcType == GL_UNSIGNED_SHORT || - srcType == GL_SHORT || - srcType == GL_UNSIGNED_INT || - srcType == GL_INT || - srcType == GL_HALF_FLOAT_ARB || - srcType == GL_FLOAT || - srcType == GL_UNSIGNED_BYTE_3_3_2 || - srcType == GL_UNSIGNED_BYTE_2_3_3_REV || - srcType == GL_UNSIGNED_SHORT_5_6_5 || - srcType == GL_UNSIGNED_SHORT_5_6_5_REV || - srcType == GL_UNSIGNED_SHORT_4_4_4_4 || - srcType == GL_UNSIGNED_SHORT_4_4_4_4_REV || - srcType == GL_UNSIGNED_SHORT_5_5_5_1 || - srcType == GL_UNSIGNED_SHORT_1_5_5_5_REV || - srcType == GL_UNSIGNED_INT_8_8_8_8 || - srcType == GL_UNSIGNED_INT_8_8_8_8_REV || - srcType == GL_UNSIGNED_INT_10_10_10_2 || - srcType == GL_UNSIGNED_INT_2_10_10_10_REV || - srcType == GL_UNSIGNED_INT_5_9_9_9_REV || - srcType == GL_UNSIGNED_INT_10F_11F_11F_REV); - - /* general solution, no special cases, yet */ - { - GLint dstComponents; - GLint rDst, gDst, bDst, aDst, lDst, iDst; - GLfloat (*rgba)[4] = (GLfloat (*)[4]) malloc(4 * n * sizeof(GLfloat)); - - if (!rgba) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "pixel unpacking"); - return; - } - - dstComponents = _mesa_components_in_format( dstFormat ); - /* source & dest image formats should have been error checked by now */ - assert(dstComponents > 0); - - /* - * Extract image data and convert to RGBA floats - */ - if (srcFormat == GL_COLOR_INDEX) { - GLuint *indexes = (GLuint *) malloc(n * sizeof(GLuint)); - - if (!indexes) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "pixel unpacking"); - free(rgba); - return; - } - - extract_uint_indexes(n, indexes, srcFormat, srcType, source, - srcPacking); - - /* Convert indexes to RGBA */ - if (transferOps & IMAGE_SHIFT_OFFSET_BIT) { - _mesa_shift_and_offset_ci(ctx, n, indexes); - } - _mesa_map_ci_to_rgba(ctx, n, indexes, rgba); - - /* Don't do RGBA scale/bias or RGBA->RGBA mapping if starting - * with color indexes. - */ - transferOps &= ~(IMAGE_SCALE_BIAS_BIT | IMAGE_MAP_COLOR_BIT); - - free(indexes); - } - else { - /* non-color index data */ - extract_float_rgba(n, rgba, srcFormat, srcType, source, - srcPacking->SwapBytes); - } - - if (transferOps) { - _mesa_apply_rgba_transfer_ops(ctx, transferOps, n, rgba); - } - - get_component_indexes(dstFormat, - &rDst, &gDst, &bDst, &aDst, &lDst, &iDst); - - /* Now pack results in the requested dstFormat */ - if (rDst >= 0) { - GLfloat *dst = dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[rDst] = rgba[i][RCOMP]; - dst += dstComponents; - } - } - - if (gDst >= 0) { - GLfloat *dst = dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[gDst] = rgba[i][GCOMP]; - dst += dstComponents; - } - } - - if (bDst >= 0) { - GLfloat *dst = dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[bDst] = rgba[i][BCOMP]; - dst += dstComponents; - } - } - - if (aDst >= 0) { - GLfloat *dst = dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[aDst] = rgba[i][ACOMP]; - dst += dstComponents; - } - } - - if (iDst >= 0) { - GLfloat *dst = dest; - GLuint i; - assert(iDst == 0); - assert(dstComponents == 1); - for (i = 0; i < n; i++) { - /* Intensity comes from red channel */ - dst[i] = rgba[i][RCOMP]; - } - } - - if (lDst >= 0) { - GLfloat *dst = dest; - GLuint i; - assert(lDst == 0); - for (i = 0; i < n; i++) { - /* Luminance comes from red channel */ - dst[0] = rgba[i][RCOMP]; - dst += dstComponents; - } - } - - free(rgba); - } -} - - -/** - * Same as _mesa_unpack_color_span_chan(), but return GLuint data - * instead of GLchan. - * No pixel transfer ops are applied. - */ -void -_mesa_unpack_color_span_uint(struct gl_context *ctx, - GLuint n, GLenum dstFormat, GLuint *dest, - GLenum srcFormat, GLenum srcType, - const GLvoid *source, - const struct gl_pixelstore_attrib *srcPacking) -{ - GLuint (*rgba)[4] = (GLuint (*)[4]) malloc(n * 4 * sizeof(GLfloat)); - - if (!rgba) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "pixel unpacking"); - return; - } - - ASSERT(dstFormat == GL_ALPHA || - dstFormat == GL_LUMINANCE || - dstFormat == GL_LUMINANCE_ALPHA || - dstFormat == GL_INTENSITY || - dstFormat == GL_RED || - dstFormat == GL_RG || - dstFormat == GL_RGB || - dstFormat == GL_RGBA); - - ASSERT(srcFormat == GL_RED || - srcFormat == GL_GREEN || - srcFormat == GL_BLUE || - srcFormat == GL_ALPHA || - srcFormat == GL_LUMINANCE || - srcFormat == GL_LUMINANCE_ALPHA || - srcFormat == GL_INTENSITY || - srcFormat == GL_RG || - srcFormat == GL_RGB || - srcFormat == GL_BGR || - srcFormat == GL_RGBA || - srcFormat == GL_BGRA || - srcFormat == GL_ABGR_EXT || - srcFormat == GL_RED_INTEGER_EXT || - srcFormat == GL_GREEN_INTEGER_EXT || - srcFormat == GL_BLUE_INTEGER_EXT || - srcFormat == GL_ALPHA_INTEGER_EXT || - srcFormat == GL_RGB_INTEGER_EXT || - srcFormat == GL_RGBA_INTEGER_EXT || - srcFormat == GL_BGR_INTEGER_EXT || - srcFormat == GL_BGRA_INTEGER_EXT || - srcFormat == GL_LUMINANCE_INTEGER_EXT || - srcFormat == GL_LUMINANCE_ALPHA_INTEGER_EXT); - - ASSERT(srcType == GL_UNSIGNED_BYTE || - srcType == GL_BYTE || - srcType == GL_UNSIGNED_SHORT || - srcType == GL_SHORT || - srcType == GL_UNSIGNED_INT || - srcType == GL_INT || - srcType == GL_HALF_FLOAT_ARB || - srcType == GL_FLOAT || - srcType == GL_UNSIGNED_BYTE_3_3_2 || - srcType == GL_UNSIGNED_BYTE_2_3_3_REV || - srcType == GL_UNSIGNED_SHORT_5_6_5 || - srcType == GL_UNSIGNED_SHORT_5_6_5_REV || - srcType == GL_UNSIGNED_SHORT_4_4_4_4 || - srcType == GL_UNSIGNED_SHORT_4_4_4_4_REV || - srcType == GL_UNSIGNED_SHORT_5_5_5_1 || - srcType == GL_UNSIGNED_SHORT_1_5_5_5_REV || - srcType == GL_UNSIGNED_INT_8_8_8_8 || - srcType == GL_UNSIGNED_INT_8_8_8_8_REV || - srcType == GL_UNSIGNED_INT_10_10_10_2 || - srcType == GL_UNSIGNED_INT_2_10_10_10_REV || - srcType == GL_UNSIGNED_INT_5_9_9_9_REV || - srcType == GL_UNSIGNED_INT_10F_11F_11F_REV); - - - /* Extract image data as uint[4] pixels */ - extract_uint_rgba(n, rgba, srcFormat, srcType, source, - srcPacking->SwapBytes); - - if (dstFormat == GL_RGBA) { - /* simple case */ - memcpy(dest, rgba, 4 * sizeof(GLuint) * n); - } - else { - /* general case */ - GLint rDst, gDst, bDst, aDst, lDst, iDst; - GLint dstComponents = _mesa_components_in_format( dstFormat ); - - assert(dstComponents > 0); - - get_component_indexes(dstFormat, - &rDst, &gDst, &bDst, &aDst, &lDst, &iDst); - - /* Now pack values in the requested dest format */ - if (rDst >= 0) { - GLuint *dst = dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[rDst] = rgba[i][RCOMP]; - dst += dstComponents; - } - } - - if (gDst >= 0) { - GLuint *dst = dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[gDst] = rgba[i][GCOMP]; - dst += dstComponents; - } - } - - if (bDst >= 0) { - GLuint *dst = dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[bDst] = rgba[i][BCOMP]; - dst += dstComponents; - } - } - - if (aDst >= 0) { - GLuint *dst = dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[aDst] = rgba[i][ACOMP]; - dst += dstComponents; - } - } - - if (iDst >= 0) { - GLuint *dst = dest; - GLuint i; - assert(iDst == 0); - assert(dstComponents == 1); - for (i = 0; i < n; i++) { - /* Intensity comes from red channel */ - dst[i] = rgba[i][RCOMP]; - } - } - - if (lDst >= 0) { - GLuint *dst = dest; - GLuint i; - assert(lDst == 0); - for (i = 0; i < n; i++) { - /* Luminance comes from red channel */ - dst[0] = rgba[i][RCOMP]; - dst += dstComponents; - } - } - } - - free(rgba); -} - - - -/** - * Similar to _mesa_unpack_color_span_float(), but for dudv data instead of rgba, - * directly return GLbyte data, no transfer ops apply. - */ -void -_mesa_unpack_dudv_span_byte( struct gl_context *ctx, - GLuint n, GLenum dstFormat, GLbyte dest[], - GLenum srcFormat, GLenum srcType, - const GLvoid *source, - const struct gl_pixelstore_attrib *srcPacking, - GLbitfield transferOps ) -{ - ASSERT(dstFormat == GL_DUDV_ATI); - ASSERT(srcFormat == GL_DUDV_ATI || - srcFormat == GL_DU8DV8_ATI); - - ASSERT(srcType == GL_UNSIGNED_BYTE || - srcType == GL_BYTE || - srcType == GL_UNSIGNED_SHORT || - srcType == GL_SHORT || - srcType == GL_UNSIGNED_INT || - srcType == GL_INT || - srcType == GL_HALF_FLOAT_ARB || - srcType == GL_FLOAT); - - /* general solution */ - { - GLint dstComponents; - GLbyte *dst = dest; - GLuint i; - GLfloat (*rgba)[4] = (GLfloat (*)[4]) malloc(4 * n * sizeof(GLfloat)); - - if (!rgba) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "pixel unpacking"); - return; - } - - dstComponents = _mesa_components_in_format( dstFormat ); - /* source & dest image formats should have been error checked by now */ - assert(dstComponents > 0); - - /* - * Extract image data and convert to RGBA floats - */ - extract_float_rgba(n, rgba, srcFormat, srcType, source, - srcPacking->SwapBytes); - - - /* Now determine which color channels we need to produce. - * And determine the dest index (offset) within each color tuple. - */ - - /* Now pack results in the requested dstFormat */ - for (i = 0; i < n; i++) { - /* not sure - need clamp[-1,1] here? */ - dst[0] = FLOAT_TO_BYTE(rgba[i][RCOMP]); - dst[1] = FLOAT_TO_BYTE(rgba[i][GCOMP]); - dst += dstComponents; - } - - free(rgba); - } -} - -/* - * Unpack a row of color index data from a client buffer according to - * the pixel unpacking parameters. - * This is (or will be) used by glDrawPixels, glTexImage[123]D, etc. - * - * Args: ctx - the context - * n - number of pixels - * dstType - destination data type - * dest - destination array - * srcType - source pixel type - * source - source data pointer - * srcPacking - pixel unpacking parameters - * transferOps - the pixel transfer operations to apply - */ -void -_mesa_unpack_index_span( struct gl_context *ctx, GLuint n, - GLenum dstType, GLvoid *dest, - GLenum srcType, const GLvoid *source, - const struct gl_pixelstore_attrib *srcPacking, - GLbitfield transferOps ) -{ - ASSERT(srcType == GL_BITMAP || - srcType == GL_UNSIGNED_BYTE || - srcType == GL_BYTE || - srcType == GL_UNSIGNED_SHORT || - srcType == GL_SHORT || - srcType == GL_UNSIGNED_INT || - srcType == GL_INT || - srcType == GL_HALF_FLOAT_ARB || - srcType == GL_FLOAT); - - ASSERT(dstType == GL_UNSIGNED_BYTE || - dstType == GL_UNSIGNED_SHORT || - dstType == GL_UNSIGNED_INT); - - - transferOps &= (IMAGE_MAP_COLOR_BIT | IMAGE_SHIFT_OFFSET_BIT); - - /* - * Try simple cases first - */ - if (transferOps == 0 && srcType == GL_UNSIGNED_BYTE - && dstType == GL_UNSIGNED_BYTE) { - memcpy(dest, source, n * sizeof(GLubyte)); - } - else if (transferOps == 0 && srcType == GL_UNSIGNED_INT - && dstType == GL_UNSIGNED_INT && !srcPacking->SwapBytes) { - memcpy(dest, source, n * sizeof(GLuint)); - } - else { - /* - * general solution - */ - GLuint *indexes = (GLuint *) malloc(n * sizeof(GLuint)); - - if (!indexes) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "pixel unpacking"); - return; - } - - extract_uint_indexes(n, indexes, GL_COLOR_INDEX, srcType, source, - srcPacking); - - if (transferOps) - _mesa_apply_ci_transfer_ops(ctx, transferOps, n, indexes); - - /* convert to dest type */ - switch (dstType) { - case GL_UNSIGNED_BYTE: - { - GLubyte *dst = (GLubyte *) dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = (GLubyte) (indexes[i] & 0xff); - } - } - break; - case GL_UNSIGNED_SHORT: - { - GLuint *dst = (GLuint *) dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = (GLushort) (indexes[i] & 0xffff); - } - } - break; - case GL_UNSIGNED_INT: - memcpy(dest, indexes, n * sizeof(GLuint)); - break; - default: - _mesa_problem(ctx, "bad dstType in _mesa_unpack_index_span"); - } - - free(indexes); - } -} - - -void -_mesa_pack_index_span( struct gl_context *ctx, GLuint n, - GLenum dstType, GLvoid *dest, const GLuint *source, - const struct gl_pixelstore_attrib *dstPacking, - GLbitfield transferOps ) -{ - GLuint *indexes = (GLuint *) malloc(n * sizeof(GLuint)); - - if (!indexes) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "pixel packing"); - return; - } - - transferOps &= (IMAGE_MAP_COLOR_BIT | IMAGE_SHIFT_OFFSET_BIT); - - if (transferOps & (IMAGE_MAP_COLOR_BIT | IMAGE_SHIFT_OFFSET_BIT)) { - /* make a copy of input */ - memcpy(indexes, source, n * sizeof(GLuint)); - _mesa_apply_ci_transfer_ops(ctx, transferOps, n, indexes); - source = indexes; - } - - switch (dstType) { - case GL_UNSIGNED_BYTE: - { - GLubyte *dst = (GLubyte *) dest; - GLuint i; - for (i = 0; i < n; i++) { - *dst++ = (GLubyte) source[i]; - } - } - break; - case GL_BYTE: - { - GLbyte *dst = (GLbyte *) dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = (GLbyte) source[i]; - } - } - break; - case GL_UNSIGNED_SHORT: - { - GLushort *dst = (GLushort *) dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = (GLushort) source[i]; - } - if (dstPacking->SwapBytes) { - _mesa_swap2( (GLushort *) dst, n ); - } - } - break; - case GL_SHORT: - { - GLshort *dst = (GLshort *) dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = (GLshort) source[i]; - } - if (dstPacking->SwapBytes) { - _mesa_swap2( (GLushort *) dst, n ); - } - } - break; - case GL_UNSIGNED_INT: - { - GLuint *dst = (GLuint *) dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = (GLuint) source[i]; - } - if (dstPacking->SwapBytes) { - _mesa_swap4( (GLuint *) dst, n ); - } - } - break; - case GL_INT: - { - GLint *dst = (GLint *) dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = (GLint) source[i]; - } - if (dstPacking->SwapBytes) { - _mesa_swap4( (GLuint *) dst, n ); - } - } - break; - case GL_FLOAT: - { - GLfloat *dst = (GLfloat *) dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = (GLfloat) source[i]; - } - if (dstPacking->SwapBytes) { - _mesa_swap4( (GLuint *) dst, n ); - } - } - break; - case GL_HALF_FLOAT_ARB: - { - GLhalfARB *dst = (GLhalfARB *) dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = _mesa_float_to_half((GLfloat) source[i]); - } - if (dstPacking->SwapBytes) { - _mesa_swap2( (GLushort *) dst, n ); - } - } - break; - default: - _mesa_problem(ctx, "bad type in _mesa_pack_index_span"); - } - - free(indexes); -} - - -/* - * Unpack a row of stencil data from a client buffer according to - * the pixel unpacking parameters. - * This is (or will be) used by glDrawPixels - * - * Args: ctx - the context - * n - number of pixels - * dstType - destination data type - * dest - destination array - * srcType - source pixel type - * source - source data pointer - * srcPacking - pixel unpacking parameters - * transferOps - apply offset/bias/lookup ops? - */ -void -_mesa_unpack_stencil_span( struct gl_context *ctx, GLuint n, - GLenum dstType, GLvoid *dest, - GLenum srcType, const GLvoid *source, - const struct gl_pixelstore_attrib *srcPacking, - GLbitfield transferOps ) -{ - ASSERT(srcType == GL_BITMAP || - srcType == GL_UNSIGNED_BYTE || - srcType == GL_BYTE || - srcType == GL_UNSIGNED_SHORT || - srcType == GL_SHORT || - srcType == GL_UNSIGNED_INT || - srcType == GL_INT || - srcType == GL_UNSIGNED_INT_24_8_EXT || - srcType == GL_HALF_FLOAT_ARB || - srcType == GL_FLOAT || - srcType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV); - - ASSERT(dstType == GL_UNSIGNED_BYTE || - dstType == GL_UNSIGNED_SHORT || - dstType == GL_UNSIGNED_INT || - dstType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV); - - /* only shift and offset apply to stencil */ - transferOps &= IMAGE_SHIFT_OFFSET_BIT; - - /* - * Try simple cases first - */ - if (transferOps == 0 && - !ctx->Pixel.MapStencilFlag && - srcType == GL_UNSIGNED_BYTE && - dstType == GL_UNSIGNED_BYTE) { - memcpy(dest, source, n * sizeof(GLubyte)); - } - else if (transferOps == 0 && - !ctx->Pixel.MapStencilFlag && - srcType == GL_UNSIGNED_INT && - dstType == GL_UNSIGNED_INT && - !srcPacking->SwapBytes) { - memcpy(dest, source, n * sizeof(GLuint)); - } - else { - /* - * general solution - */ - GLuint *indexes = (GLuint *) malloc(n * sizeof(GLuint)); - - if (!indexes) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "stencil unpacking"); - return; - } - - extract_uint_indexes(n, indexes, GL_STENCIL_INDEX, srcType, source, - srcPacking); - - if (transferOps & IMAGE_SHIFT_OFFSET_BIT) { - /* shift and offset indexes */ - _mesa_shift_and_offset_ci(ctx, n, indexes); - } - - if (ctx->Pixel.MapStencilFlag) { - /* Apply stencil lookup table */ - const GLuint mask = ctx->PixelMaps.StoS.Size - 1; - GLuint i; - for (i = 0; i < n; i++) { - indexes[i] = (GLuint)ctx->PixelMaps.StoS.Map[ indexes[i] & mask ]; - } - } - - /* convert to dest type */ - switch (dstType) { - case GL_UNSIGNED_BYTE: - { - GLubyte *dst = (GLubyte *) dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = (GLubyte) (indexes[i] & 0xff); - } - } - break; - case GL_UNSIGNED_SHORT: - { - GLuint *dst = (GLuint *) dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = (GLushort) (indexes[i] & 0xffff); - } - } - break; - case GL_UNSIGNED_INT: - memcpy(dest, indexes, n * sizeof(GLuint)); - break; - case GL_FLOAT_32_UNSIGNED_INT_24_8_REV: - { - GLuint *dst = (GLuint *) dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[i*2+1] = indexes[i] & 0xff; /* lower 8 bits */ - } - } - break; - default: - _mesa_problem(ctx, "bad dstType in _mesa_unpack_stencil_span"); - } - - free(indexes); - } -} - - -void -_mesa_pack_stencil_span( struct gl_context *ctx, GLuint n, - GLenum dstType, GLvoid *dest, const GLstencil *source, - const struct gl_pixelstore_attrib *dstPacking ) -{ - GLstencil *stencil = (GLstencil *) malloc(n * sizeof(GLstencil)); - - if (!stencil) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "stencil packing"); - return; - } - - if (ctx->Pixel.IndexShift || ctx->Pixel.IndexOffset || - ctx->Pixel.MapStencilFlag) { - /* make a copy of input */ - memcpy(stencil, source, n * sizeof(GLstencil)); - _mesa_apply_stencil_transfer_ops(ctx, n, stencil); - source = stencil; - } - - switch (dstType) { - case GL_UNSIGNED_BYTE: - if (sizeof(GLstencil) == 1) { - memcpy( dest, source, n ); - } - else { - GLubyte *dst = (GLubyte *) dest; - GLuint i; - for (i=0;iSwapBytes) { - _mesa_swap2( (GLushort *) dst, n ); - } - } - break; - case GL_SHORT: - { - GLshort *dst = (GLshort *) dest; - GLuint i; - for (i=0;iSwapBytes) { - _mesa_swap2( (GLushort *) dst, n ); - } - } - break; - case GL_UNSIGNED_INT: - { - GLuint *dst = (GLuint *) dest; - GLuint i; - for (i=0;iSwapBytes) { - _mesa_swap4( (GLuint *) dst, n ); - } - } - break; - case GL_INT: - { - GLint *dst = (GLint *) dest; - GLuint i; - for (i=0;iSwapBytes) { - _mesa_swap4( (GLuint *) dst, n ); - } - } - break; - case GL_FLOAT: - { - GLfloat *dst = (GLfloat *) dest; - GLuint i; - for (i=0;iSwapBytes) { - _mesa_swap4( (GLuint *) dst, n ); - } - } - break; - case GL_HALF_FLOAT_ARB: - { - GLhalfARB *dst = (GLhalfARB *) dest; - GLuint i; - for (i=0;iSwapBytes) { - _mesa_swap2( (GLushort *) dst, n ); - } - } - break; - case GL_BITMAP: - if (dstPacking->LsbFirst) { - GLubyte *dst = (GLubyte *) dest; - GLint shift = 0; - GLuint i; - for (i = 0; i < n; i++) { - if (shift == 0) - *dst = 0; - *dst |= ((source[i] != 0) << shift); - shift++; - if (shift == 8) { - shift = 0; - dst++; - } - } - } - else { - GLubyte *dst = (GLubyte *) dest; - GLint shift = 7; - GLuint i; - for (i = 0; i < n; i++) { - if (shift == 7) - *dst = 0; - *dst |= ((source[i] != 0) << shift); - shift--; - if (shift < 0) { - shift = 7; - dst++; - } - } - } - break; - default: - _mesa_problem(ctx, "bad type in _mesa_pack_index_span"); - } - - free(stencil); -} - -#define DEPTH_VALUES(GLTYPE, GLTYPE2FLOAT) \ - do { \ - GLuint i; \ - const GLTYPE *src = (const GLTYPE *)source; \ - for (i = 0; i < n; i++) { \ - GLTYPE value = src[i]; \ - if (srcPacking->SwapBytes) { \ - if (sizeof(GLTYPE) == 2) { \ - SWAP2BYTE(value); \ - } else if (sizeof(GLTYPE) == 4) { \ - SWAP4BYTE(value); \ - } \ - } \ - depthValues[i] = GLTYPE2FLOAT(value); \ - } \ - } while (0) - - -/** - * Unpack a row of depth/z values from memory, returning GLushort, GLuint - * or GLfloat values. - * The glPixelTransfer (scale/bias) params will be applied. - * - * \param dstType one of GL_UNSIGNED_SHORT, GL_UNSIGNED_INT, GL_FLOAT - * \param depthMax max value for returned GLushort or GLuint values - * (ignored for GLfloat). - */ -void -_mesa_unpack_depth_span( struct gl_context *ctx, GLuint n, - GLenum dstType, GLvoid *dest, GLuint depthMax, - GLenum srcType, const GLvoid *source, - const struct gl_pixelstore_attrib *srcPacking ) -{ - GLfloat *depthTemp = NULL, *depthValues; - GLboolean needClamp = GL_FALSE; - - /* Look for special cases first. - * Not only are these faster, they're less prone to numeric conversion - * problems. Otherwise, converting from an int type to a float then - * back to an int type can introduce errors that will show up as - * artifacts in things like depth peeling which uses glCopyTexImage. - */ - if (ctx->Pixel.DepthScale == 1.0 && ctx->Pixel.DepthBias == 0.0) { - if (srcType == GL_UNSIGNED_INT && dstType == GL_UNSIGNED_SHORT) { - const GLuint *src = (const GLuint *) source; - GLushort *dst = (GLushort *) dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = src[i] >> 16; - } - return; - } - if (srcType == GL_UNSIGNED_SHORT - && dstType == GL_UNSIGNED_INT - && depthMax == 0xffffffff) { - const GLushort *src = (const GLushort *) source; - GLuint *dst = (GLuint *) dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = src[i] | (src[i] << 16); - } - return; - } - if (srcType == GL_UNSIGNED_INT_24_8 - && dstType == GL_UNSIGNED_INT - && depthMax == 0xffffff) { - const GLuint *src = (const GLuint *) source; - GLuint *dst = (GLuint *) dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = src[i] >> 8; - } - return; - } - /* XXX may want to add additional cases here someday */ - } - - /* general case path follows */ - - if (dstType == GL_FLOAT) { - depthValues = (GLfloat *) dest; - } - else { - depthTemp = (GLfloat *) malloc(n * sizeof(GLfloat)); - if (!depthTemp) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "pixel unpacking"); - return; - } - - depthValues = depthTemp; - } - - /* Convert incoming values to GLfloat. Some conversions will require - * clamping, below. - */ - switch (srcType) { - case GL_BYTE: - DEPTH_VALUES(GLbyte, BYTE_TO_FLOAT); - needClamp = GL_TRUE; - break; - case GL_UNSIGNED_BYTE: - DEPTH_VALUES(GLubyte, UBYTE_TO_FLOAT); - break; - case GL_SHORT: - DEPTH_VALUES(GLshort, SHORT_TO_FLOAT); - needClamp = GL_TRUE; - break; - case GL_UNSIGNED_SHORT: - DEPTH_VALUES(GLushort, USHORT_TO_FLOAT); - break; - case GL_INT: - DEPTH_VALUES(GLint, INT_TO_FLOAT); - needClamp = GL_TRUE; - break; - case GL_UNSIGNED_INT: - DEPTH_VALUES(GLuint, UINT_TO_FLOAT); - break; - case GL_UNSIGNED_INT_24_8_EXT: /* GL_EXT_packed_depth_stencil */ - if (dstType == GL_UNSIGNED_INT_24_8_EXT && - depthMax == 0xffffff && - ctx->Pixel.DepthScale == 1.0 && - ctx->Pixel.DepthBias == 0.0) { - const GLuint *src = (const GLuint *) source; - GLuint *zValues = (GLuint *) dest; - GLuint i; - for (i = 0; i < n; i++) { - GLuint value = src[i]; - if (srcPacking->SwapBytes) { - SWAP4BYTE(value); - } - zValues[i] = value & 0xffffff00; - } - free(depthTemp); - return; - } - else { - const GLuint *src = (const GLuint *) source; - const GLfloat scale = 1.0f / 0xffffff; - GLuint i; - for (i = 0; i < n; i++) { - GLuint value = src[i]; - if (srcPacking->SwapBytes) { - SWAP4BYTE(value); - } - depthValues[i] = (value >> 8) * scale; - } - } - break; - case GL_FLOAT_32_UNSIGNED_INT_24_8_REV: - { - GLuint i; - const GLfloat *src = (const GLfloat *)source; - for (i = 0; i < n; i++) { - GLfloat value = src[i * 2]; - if (srcPacking->SwapBytes) { - SWAP4BYTE(value); - } - depthValues[i] = value; - } - needClamp = GL_TRUE; - } - break; - case GL_FLOAT: - DEPTH_VALUES(GLfloat, 1*); - needClamp = GL_TRUE; - break; - case GL_HALF_FLOAT_ARB: - { - GLuint i; - const GLhalfARB *src = (const GLhalfARB *) source; - for (i = 0; i < n; i++) { - GLhalfARB value = src[i]; - if (srcPacking->SwapBytes) { - SWAP2BYTE(value); - } - depthValues[i] = _mesa_half_to_float(value); - } - needClamp = GL_TRUE; - } - break; - default: - _mesa_problem(NULL, "bad type in _mesa_unpack_depth_span()"); - free(depthTemp); - return; - } - - /* apply depth scale and bias */ - { - const GLfloat scale = ctx->Pixel.DepthScale; - const GLfloat bias = ctx->Pixel.DepthBias; - if (scale != 1.0 || bias != 0.0) { - GLuint i; - for (i = 0; i < n; i++) { - depthValues[i] = depthValues[i] * scale + bias; - } - needClamp = GL_TRUE; - } - } - - /* clamp to [0, 1] */ - if (needClamp) { - GLuint i; - for (i = 0; i < n; i++) { - depthValues[i] = (GLfloat)CLAMP(depthValues[i], 0.0, 1.0); - } - } - - /* - * Convert values to dstType - */ - if (dstType == GL_UNSIGNED_INT) { - GLuint *zValues = (GLuint *) dest; - GLuint i; - if (depthMax <= 0xffffff) { - /* no overflow worries */ - for (i = 0; i < n; i++) { - zValues[i] = (GLuint) (depthValues[i] * (GLfloat) depthMax); - } - } - else { - /* need to use double precision to prevent overflow problems */ - for (i = 0; i < n; i++) { - GLdouble z = depthValues[i] * (GLfloat) depthMax; - if (z >= (GLdouble) 0xffffffff) - zValues[i] = 0xffffffff; - else - zValues[i] = (GLuint) z; - } - } - } - else if (dstType == GL_UNSIGNED_SHORT) { - GLushort *zValues = (GLushort *) dest; - GLuint i; - ASSERT(depthMax <= 0xffff); - for (i = 0; i < n; i++) { - zValues[i] = (GLushort) (depthValues[i] * (GLfloat) depthMax); - } - } - else if (dstType == GL_FLOAT) { - /* Nothing to do. depthValues is pointing to dest. */ - } - else if (dstType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV) { - GLfloat *zValues = (GLfloat*) dest; - GLuint i; - for (i = 0; i < n; i++) { - zValues[i*2] = depthValues[i]; - } - } - else { - ASSERT(0); - } - - free(depthTemp); -} - - -/* - * Pack an array of depth values. The values are floats in [0,1]. - */ -void -_mesa_pack_depth_span( struct gl_context *ctx, GLuint n, GLvoid *dest, - GLenum dstType, const GLfloat *depthSpan, - const struct gl_pixelstore_attrib *dstPacking ) -{ - GLfloat *depthCopy = (GLfloat *) malloc(n * sizeof(GLfloat)); - if (!depthCopy) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "pixel packing"); - return; - } - - if (ctx->Pixel.DepthScale != 1.0 || ctx->Pixel.DepthBias != 0.0) { - memcpy(depthCopy, depthSpan, n * sizeof(GLfloat)); - _mesa_scale_and_bias_depth(ctx, n, depthCopy); - depthSpan = depthCopy; - } - - switch (dstType) { - case GL_UNSIGNED_BYTE: - { - GLubyte *dst = (GLubyte *) dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = FLOAT_TO_UBYTE( depthSpan[i] ); - } - } - break; - case GL_BYTE: - { - GLbyte *dst = (GLbyte *) dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = FLOAT_TO_BYTE( depthSpan[i] ); - } - } - break; - case GL_UNSIGNED_SHORT: - { - GLushort *dst = (GLushort *) dest; - GLuint i; - for (i = 0; i < n; i++) { - CLAMPED_FLOAT_TO_USHORT(dst[i], depthSpan[i]); - } - if (dstPacking->SwapBytes) { - _mesa_swap2( (GLushort *) dst, n ); - } - } - break; - case GL_SHORT: - { - GLshort *dst = (GLshort *) dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = FLOAT_TO_SHORT( depthSpan[i] ); - } - if (dstPacking->SwapBytes) { - _mesa_swap2( (GLushort *) dst, n ); - } - } - break; - case GL_UNSIGNED_INT: - { - GLuint *dst = (GLuint *) dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = FLOAT_TO_UINT( depthSpan[i] ); - } - if (dstPacking->SwapBytes) { - _mesa_swap4( (GLuint *) dst, n ); - } - } - break; - case GL_INT: - { - GLint *dst = (GLint *) dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = FLOAT_TO_INT( depthSpan[i] ); - } - if (dstPacking->SwapBytes) { - _mesa_swap4( (GLuint *) dst, n ); - } - } - break; - case GL_FLOAT: - { - GLfloat *dst = (GLfloat *) dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = depthSpan[i]; - } - if (dstPacking->SwapBytes) { - _mesa_swap4( (GLuint *) dst, n ); - } - } - break; - case GL_HALF_FLOAT_ARB: - { - GLhalfARB *dst = (GLhalfARB *) dest; - GLuint i; - for (i = 0; i < n; i++) { - dst[i] = _mesa_float_to_half(depthSpan[i]); - } - if (dstPacking->SwapBytes) { - _mesa_swap2( (GLushort *) dst, n ); - } - } - break; - default: - _mesa_problem(ctx, "bad type in _mesa_pack_depth_span"); - } - - free(depthCopy); -} - - - -/** - * Pack depth and stencil values as GL_DEPTH_STENCIL (GL_UNSIGNED_INT_24_8 etc) - */ -void -_mesa_pack_depth_stencil_span(struct gl_context *ctx,GLuint n, - GLenum dstType, GLuint *dest, - const GLfloat *depthVals, - const GLstencil *stencilVals, - const struct gl_pixelstore_attrib *dstPacking) -{ - GLfloat *depthCopy = (GLfloat *) malloc(n * sizeof(GLfloat)); - GLstencil *stencilCopy = (GLstencil *) malloc(n * sizeof(GLstencil)); - GLuint i; - - if (!depthCopy || !stencilCopy) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "pixel packing"); - free(depthCopy); - free(stencilCopy); - return; - } - - if (ctx->Pixel.DepthScale != 1.0 || ctx->Pixel.DepthBias != 0.0) { - memcpy(depthCopy, depthVals, n * sizeof(GLfloat)); - _mesa_scale_and_bias_depth(ctx, n, depthCopy); - depthVals = depthCopy; - } - - if (ctx->Pixel.IndexShift || - ctx->Pixel.IndexOffset || - ctx->Pixel.MapStencilFlag) { - memcpy(stencilCopy, stencilVals, n * sizeof(GLstencil)); - _mesa_apply_stencil_transfer_ops(ctx, n, stencilCopy); - stencilVals = stencilCopy; - } - - switch (dstType) { - case GL_UNSIGNED_INT_24_8: - for (i = 0; i < n; i++) { - GLuint z = (GLuint) (depthVals[i] * 0xffffff); - dest[i] = (z << 8) | (stencilVals[i] & 0xff); - } - break; - case GL_FLOAT_32_UNSIGNED_INT_24_8_REV: - for (i = 0; i < n; i++) { - ((GLfloat*)dest)[i*2] = depthVals[i]; - dest[i*2+1] = stencilVals[i] & 0xff; - } - break; - } - - if (dstPacking->SwapBytes) { - _mesa_swap4(dest, n); - } - - free(depthCopy); - free(stencilCopy); -} - - - - -/** - * Unpack image data. Apply byte swapping, byte flipping (bitmap). - * Return all image data in a contiguous block. This is used when we - * compile glDrawPixels, glTexImage, etc into a display list. We - * need a copy of the data in a standard format. - */ -void * -_mesa_unpack_image( GLuint dimensions, - GLsizei width, GLsizei height, GLsizei depth, - GLenum format, GLenum type, const GLvoid *pixels, - const struct gl_pixelstore_attrib *unpack ) -{ - GLint bytesPerRow, compsPerRow; - GLboolean flipBytes, swap2, swap4; - - if (!pixels) - return NULL; /* not necessarily an error */ - - if (width <= 0 || height <= 0 || depth <= 0) - return NULL; /* generate error later */ - - if (type == GL_BITMAP) { - bytesPerRow = (width + 7) >> 3; - flipBytes = unpack->LsbFirst; - swap2 = swap4 = GL_FALSE; - compsPerRow = 0; - } - else { - const GLint bytesPerPixel = _mesa_bytes_per_pixel(format, type); - GLint components = _mesa_components_in_format(format); - GLint bytesPerComp; - - if (_mesa_type_is_packed(type)) - components = 1; - - if (bytesPerPixel <= 0 || components <= 0) - return NULL; /* bad format or type. generate error later */ - bytesPerRow = bytesPerPixel * width; - bytesPerComp = bytesPerPixel / components; - flipBytes = GL_FALSE; - swap2 = (bytesPerComp == 2) && unpack->SwapBytes; - swap4 = (bytesPerComp == 4) && unpack->SwapBytes; - compsPerRow = components * width; - assert(compsPerRow >= width); - } - - { - GLubyte *destBuffer - = (GLubyte *) malloc(bytesPerRow * height * depth); - GLubyte *dst; - GLint img, row; - if (!destBuffer) - return NULL; /* generate GL_OUT_OF_MEMORY later */ - - dst = destBuffer; - for (img = 0; img < depth; img++) { - for (row = 0; row < height; row++) { - const GLvoid *src = _mesa_image_address(dimensions, unpack, pixels, - width, height, format, type, img, row, 0); - - if ((type == GL_BITMAP) && (unpack->SkipPixels & 0x7)) { - GLint i; - flipBytes = GL_FALSE; - if (unpack->LsbFirst) { - GLubyte srcMask = 1 << (unpack->SkipPixels & 0x7); - GLubyte dstMask = 128; - const GLubyte *s = src; - GLubyte *d = dst; - *d = 0; - for (i = 0; i < width; i++) { - if (*s & srcMask) { - *d |= dstMask; - } - if (srcMask == 128) { - srcMask = 1; - s++; - } - else { - srcMask = srcMask << 1; - } - if (dstMask == 1) { - dstMask = 128; - d++; - *d = 0; - } - else { - dstMask = dstMask >> 1; - } - } - } - else { - GLubyte srcMask = 128 >> (unpack->SkipPixels & 0x7); - GLubyte dstMask = 128; - const GLubyte *s = src; - GLubyte *d = dst; - *d = 0; - for (i = 0; i < width; i++) { - if (*s & srcMask) { - *d |= dstMask; - } - if (srcMask == 1) { - srcMask = 128; - s++; - } - else { - srcMask = srcMask >> 1; - } - if (dstMask == 1) { - dstMask = 128; - d++; - *d = 0; - } - else { - dstMask = dstMask >> 1; - } - } - } - } - else { - memcpy(dst, src, bytesPerRow); - } - - /* byte flipping/swapping */ - if (flipBytes) { - flip_bytes((GLubyte *) dst, bytesPerRow); - } - else if (swap2) { - _mesa_swap2((GLushort*) dst, compsPerRow); - } - else if (swap4) { - _mesa_swap4((GLuint*) dst, compsPerRow); - } - dst += bytesPerRow; - } - } - return destBuffer; - } -} - +/* + * Mesa 3-D graphics library + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (C) 2009-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 + * THEA 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. + */ + + +/** + * \file pack.c + * Image and pixel span packing and unpacking. + */ + + +#include "glheader.h" +#include "colormac.h" +#include "enums.h" +#include "image.h" +#include "imports.h" +#include "mtypes.h" +#include "pack.h" +#include "pixeltransfer.h" +#include "imports.h" +#include "../../gallium/auxiliary/util/u_format_rgb9e5.h" +#include "../../gallium/auxiliary/util/u_format_r11g11b10f.h" + + +/** + * NOTE: + * Normally, BYTE_TO_FLOAT(0) returns 0.00392 That causes problems when + * we later convert the float to a packed integer value (such as for + * GL_RGB5_A1) because we'll wind up with a non-zero value. + * + * We redefine the macros here so zero is handled correctly. + */ +#undef BYTE_TO_FLOAT +#define BYTE_TO_FLOAT(B) ((B) == 0 ? 0.0F : ((2.0F * (B) + 1.0F) * (1.0F/255.0F))) + +#undef SHORT_TO_FLOAT +#define SHORT_TO_FLOAT(S) ((S) == 0 ? 0.0F : ((2.0F * (S) + 1.0F) * (1.0F/65535.0F))) + + + +/** Compute ceiling of integer quotient of A divided by B. */ +#define CEILING( A, B ) ( (A) % (B) == 0 ? (A)/(B) : (A)/(B)+1 ) + + +/** + * Flip the 8 bits in each byte of the given array. + * + * \param p array. + * \param n number of bytes. + * + * \todo try this trick to flip bytes someday: + * \code + * v = ((v & 0x55555555) << 1) | ((v >> 1) & 0x55555555); + * v = ((v & 0x33333333) << 2) | ((v >> 2) & 0x33333333); + * v = ((v & 0x0f0f0f0f) << 4) | ((v >> 4) & 0x0f0f0f0f); + * \endcode + */ +static void +flip_bytes( GLubyte *p, GLuint n ) +{ + GLuint i, a, b; + for (i = 0; i < n; i++) { + b = (GLuint) p[i]; /* words are often faster than bytes */ + a = ((b & 0x01) << 7) | + ((b & 0x02) << 5) | + ((b & 0x04) << 3) | + ((b & 0x08) << 1) | + ((b & 0x10) >> 1) | + ((b & 0x20) >> 3) | + ((b & 0x40) >> 5) | + ((b & 0x80) >> 7); + p[i] = (GLubyte) a; + } +} + + + +/* + * Unpack a 32x32 pixel polygon stipple from user memory using the + * current pixel unpack settings. + */ +void +_mesa_unpack_polygon_stipple( const GLubyte *pattern, GLuint dest[32], + const struct gl_pixelstore_attrib *unpacking ) +{ + GLubyte *ptrn = (GLubyte *) _mesa_unpack_bitmap(32, 32, pattern, unpacking); + if (ptrn) { + /* Convert pattern from GLubytes to GLuints and handle big/little + * endian differences + */ + GLubyte *p = ptrn; + GLint i; + for (i = 0; i < 32; i++) { + dest[i] = (p[0] << 24) + | (p[1] << 16) + | (p[2] << 8) + | (p[3] ); + p += 4; + } + free(ptrn); + } +} + + +/* + * Pack polygon stipple into user memory given current pixel packing + * settings. + */ +void +_mesa_pack_polygon_stipple( const GLuint pattern[32], GLubyte *dest, + const struct gl_pixelstore_attrib *packing ) +{ + /* Convert pattern from GLuints to GLubytes to handle big/little + * endian differences. + */ + GLubyte ptrn[32*4]; + GLint i; + for (i = 0; i < 32; i++) { + ptrn[i * 4 + 0] = (GLubyte) ((pattern[i] >> 24) & 0xff); + ptrn[i * 4 + 1] = (GLubyte) ((pattern[i] >> 16) & 0xff); + ptrn[i * 4 + 2] = (GLubyte) ((pattern[i] >> 8 ) & 0xff); + ptrn[i * 4 + 3] = (GLubyte) ((pattern[i] ) & 0xff); + } + + _mesa_pack_bitmap(32, 32, ptrn, dest, packing); +} + + +/* + * Unpack bitmap data. Resulting data will be in most-significant-bit-first + * order with row alignment = 1 byte. + */ +GLvoid * +_mesa_unpack_bitmap( GLint width, GLint height, const GLubyte *pixels, + const struct gl_pixelstore_attrib *packing ) +{ + GLint bytes, row, width_in_bytes; + GLubyte *buffer, *dst; + + if (!pixels) + return NULL; + + /* Alloc dest storage */ + bytes = ((width + 7) / 8 * height); + buffer = (GLubyte *) malloc( bytes ); + if (!buffer) + return NULL; + + width_in_bytes = CEILING( width, 8 ); + dst = buffer; + for (row = 0; row < height; row++) { + const GLubyte *src = (const GLubyte *) + _mesa_image_address2d(packing, pixels, width, height, + GL_COLOR_INDEX, GL_BITMAP, row, 0); + if (!src) { + free(buffer); + return NULL; + } + + if ((packing->SkipPixels & 7) == 0) { + memcpy( dst, src, width_in_bytes ); + if (packing->LsbFirst) { + flip_bytes( dst, width_in_bytes ); + } + } + else { + /* handling SkipPixels is a bit tricky (no pun intended!) */ + GLint i; + if (packing->LsbFirst) { + GLubyte srcMask = 1 << (packing->SkipPixels & 0x7); + GLubyte dstMask = 128; + const GLubyte *s = src; + GLubyte *d = dst; + *d = 0; + for (i = 0; i < width; i++) { + if (*s & srcMask) { + *d |= dstMask; + } + if (srcMask == 128) { + srcMask = 1; + s++; + } + else { + srcMask = srcMask << 1; + } + if (dstMask == 1) { + dstMask = 128; + d++; + *d = 0; + } + else { + dstMask = dstMask >> 1; + } + } + } + else { + GLubyte srcMask = 128 >> (packing->SkipPixels & 0x7); + GLubyte dstMask = 128; + const GLubyte *s = src; + GLubyte *d = dst; + *d = 0; + for (i = 0; i < width; i++) { + if (*s & srcMask) { + *d |= dstMask; + } + if (srcMask == 1) { + srcMask = 128; + s++; + } + else { + srcMask = srcMask >> 1; + } + if (dstMask == 1) { + dstMask = 128; + d++; + *d = 0; + } + else { + dstMask = dstMask >> 1; + } + } + } + } + dst += width_in_bytes; + } + + return buffer; +} + + +/* + * Pack bitmap data. + */ +void +_mesa_pack_bitmap( GLint width, GLint height, const GLubyte *source, + GLubyte *dest, const struct gl_pixelstore_attrib *packing ) +{ + GLint row, width_in_bytes; + const GLubyte *src; + + if (!source) + return; + + width_in_bytes = CEILING( width, 8 ); + src = source; + for (row = 0; row < height; row++) { + GLubyte *dst = (GLubyte *) _mesa_image_address2d(packing, dest, + width, height, GL_COLOR_INDEX, GL_BITMAP, row, 0); + if (!dst) + return; + + if ((packing->SkipPixels & 7) == 0) { + memcpy( dst, src, width_in_bytes ); + if (packing->LsbFirst) { + flip_bytes( dst, width_in_bytes ); + } + } + else { + /* handling SkipPixels is a bit tricky (no pun intended!) */ + GLint i; + if (packing->LsbFirst) { + GLubyte srcMask = 128; + GLubyte dstMask = 1 << (packing->SkipPixels & 0x7); + const GLubyte *s = src; + GLubyte *d = dst; + *d = 0; + for (i = 0; i < width; i++) { + if (*s & srcMask) { + *d |= dstMask; + } + if (srcMask == 1) { + srcMask = 128; + s++; + } + else { + srcMask = srcMask >> 1; + } + if (dstMask == 128) { + dstMask = 1; + d++; + *d = 0; + } + else { + dstMask = dstMask << 1; + } + } + } + else { + GLubyte srcMask = 128; + GLubyte dstMask = 128 >> (packing->SkipPixels & 0x7); + const GLubyte *s = src; + GLubyte *d = dst; + *d = 0; + for (i = 0; i < width; i++) { + if (*s & srcMask) { + *d |= dstMask; + } + if (srcMask == 1) { + srcMask = 128; + s++; + } + else { + srcMask = srcMask >> 1; + } + if (dstMask == 1) { + dstMask = 128; + d++; + *d = 0; + } + else { + dstMask = dstMask >> 1; + } + } + } + } + src += width_in_bytes; + } +} + + +/** + * Get indexes of color components for a basic color format, such as + * GL_RGBA, GL_RED, GL_LUMINANCE_ALPHA, etc. Return -1 for indexes + * that do not apply. + */ +static void +get_component_indexes(GLenum format, + GLint *redIndex, + GLint *greenIndex, + GLint *blueIndex, + GLint *alphaIndex, + GLint *luminanceIndex, + GLint *intensityIndex) +{ + *redIndex = -1; + *greenIndex = -1; + *blueIndex = -1; + *alphaIndex = -1; + *luminanceIndex = -1; + *intensityIndex = -1; + + switch (format) { + case GL_LUMINANCE: + case GL_LUMINANCE_INTEGER_EXT: + *luminanceIndex = 0; + break; + case GL_LUMINANCE_ALPHA: + case GL_LUMINANCE_ALPHA_INTEGER_EXT: + *luminanceIndex = 0; + *alphaIndex = 1; + break; + case GL_INTENSITY: + *intensityIndex = 0; + break; + case GL_RED: + case GL_RED_INTEGER_EXT: + *redIndex = 0; + break; + case GL_GREEN: + case GL_GREEN_INTEGER_EXT: + *greenIndex = 0; + break; + case GL_BLUE: + case GL_BLUE_INTEGER_EXT: + *blueIndex = 0; + break; + case GL_ALPHA: + case GL_ALPHA_INTEGER_EXT: + *alphaIndex = 0; + break; + case GL_RG: + case GL_RG_INTEGER: + *redIndex = 0; + *greenIndex = 1; + break; + case GL_RGB: + case GL_RGB_INTEGER_EXT: + *redIndex = 0; + *greenIndex = 1; + *blueIndex = 2; + break; + case GL_BGR: + case GL_BGR_INTEGER_EXT: + *blueIndex = 0; + *greenIndex = 1; + *redIndex = 2; + break; + case GL_RGBA: + case GL_RGBA_INTEGER_EXT: + *redIndex = 0; + *greenIndex = 1; + *blueIndex = 2; + *alphaIndex = 3; + break; + case GL_BGRA: + case GL_BGRA_INTEGER: + *redIndex = 2; + *greenIndex = 1; + *blueIndex = 0; + *alphaIndex = 3; + break; + case GL_ABGR_EXT: + *redIndex = 3; + *greenIndex = 2; + *blueIndex = 1; + *alphaIndex = 0; + break; + case GL_DU8DV8_ATI: + case GL_DUDV_ATI: + *redIndex = 0; + *greenIndex = 1; + break; + default: + assert(0 && "bad format in get_component_indexes()"); + } +} + + + +/** + * For small integer types, return the min and max possible values. + * Used for clamping floats to unscaled integer types. + * \return GL_TRUE if type is handled, GL_FALSE otherwise. + */ +static GLboolean +get_type_min_max(GLenum type, GLfloat *min, GLfloat *max) +{ + switch (type) { + case GL_BYTE: + *min = -128.0; + *max = 127.0; + return GL_TRUE; + case GL_UNSIGNED_BYTE: + *min = 0.0; + *max = 255.0; + return GL_TRUE; + case GL_SHORT: + *min = -32768.0; + *max = 32767.0; + return GL_TRUE; + case GL_UNSIGNED_SHORT: + *min = 0.0; + *max = 65535.0; + return GL_TRUE; + default: + return GL_FALSE; + } +} + + + +/** + * Used to pack an array [][4] of RGBA float colors as specified + * by the dstFormat, dstType and dstPacking. Used by glReadPixels. + * Historically, the RGBA values were in [0,1] and rescaled to fit + * into GLubytes, etc. But with new integer formats, the RGBA values + * may have any value and we don't always rescale when converting to + * integers. + * + * Note: the rgba values will be modified by this function when any pixel + * transfer ops are enabled. + */ +void +_mesa_pack_rgba_span_float(struct gl_context *ctx, GLuint n, GLfloat rgba[][4], + GLenum dstFormat, GLenum dstType, + GLvoid *dstAddr, + const struct gl_pixelstore_attrib *dstPacking, + GLbitfield transferOps) +{ + GLfloat *luminance; + const GLint comps = _mesa_components_in_format(dstFormat); + const GLboolean intDstFormat = _mesa_is_integer_format(dstFormat); + GLuint i; + + if (dstFormat == GL_LUMINANCE || + dstFormat == GL_LUMINANCE_ALPHA || + dstFormat == GL_LUMINANCE_INTEGER_EXT || + dstFormat == GL_LUMINANCE_ALPHA_INTEGER_EXT) { + luminance = (GLfloat *) malloc(n * sizeof(GLfloat)); + if (!luminance) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "pixel packing"); + return; + } + } + else { + luminance = NULL; + } + + if (transferOps) { + _mesa_apply_rgba_transfer_ops(ctx, transferOps, n, rgba); + } + + /* + * Component clamping (besides clamping to [0,1] in + * _mesa_apply_rgba_transfer_ops()). + */ + if (intDstFormat) { + /* clamping to dest type's min/max values */ + GLfloat min, max; + if (get_type_min_max(dstType, &min, &max)) { + for (i = 0; i < n; i++) { + rgba[i][RCOMP] = CLAMP(rgba[i][RCOMP], min, max); + rgba[i][GCOMP] = CLAMP(rgba[i][GCOMP], min, max); + rgba[i][BCOMP] = CLAMP(rgba[i][BCOMP], min, max); + rgba[i][ACOMP] = CLAMP(rgba[i][ACOMP], min, max); + } + } + } + else if (dstFormat == GL_LUMINANCE || dstFormat == GL_LUMINANCE_ALPHA) { + /* compute luminance values */ + if (transferOps & IMAGE_CLAMP_BIT) { + for (i = 0; i < n; i++) { + GLfloat sum = rgba[i][RCOMP] + rgba[i][GCOMP] + rgba[i][BCOMP]; + luminance[i] = CLAMP(sum, 0.0F, 1.0F); + } + } + else { + for (i = 0; i < n; i++) { + luminance[i] = rgba[i][RCOMP] + rgba[i][GCOMP] + rgba[i][BCOMP]; + } + } + } + + /* + * Pack/store the pixels. Ugh! Lots of cases!!! + */ + switch (dstType) { + case GL_UNSIGNED_BYTE: + { + GLubyte *dst = (GLubyte *) dstAddr; + switch (dstFormat) { + case GL_RED: + for (i=0;iSwapBytes) { + GLint swapSize = _mesa_sizeof_packed_type(dstType); + if (swapSize == 2) { + if (dstPacking->SwapBytes) { + _mesa_swap2((GLushort *) dstAddr, n * comps); + } + } + else if (swapSize == 4) { + if (dstPacking->SwapBytes) { + _mesa_swap4((GLuint *) dstAddr, n * comps); + } + } + } + + free(luminance); +} + + + +#define SWAP2BYTE(VALUE) \ + { \ + GLubyte *bytes = (GLubyte *) &(VALUE); \ + GLubyte tmp = bytes[0]; \ + bytes[0] = bytes[1]; \ + bytes[1] = tmp; \ + } + +#define SWAP4BYTE(VALUE) \ + { \ + GLubyte *bytes = (GLubyte *) &(VALUE); \ + GLubyte tmp = bytes[0]; \ + bytes[0] = bytes[3]; \ + bytes[3] = tmp; \ + tmp = bytes[1]; \ + bytes[1] = bytes[2]; \ + bytes[2] = tmp; \ + } + + +static void +extract_uint_indexes(GLuint n, GLuint indexes[], + GLenum srcFormat, GLenum srcType, const GLvoid *src, + const struct gl_pixelstore_attrib *unpack ) +{ + ASSERT(srcFormat == GL_COLOR_INDEX || srcFormat == GL_STENCIL_INDEX); + + ASSERT(srcType == GL_BITMAP || + srcType == GL_UNSIGNED_BYTE || + srcType == GL_BYTE || + srcType == GL_UNSIGNED_SHORT || + srcType == GL_SHORT || + srcType == GL_UNSIGNED_INT || + srcType == GL_INT || + srcType == GL_UNSIGNED_INT_24_8_EXT || + srcType == GL_HALF_FLOAT_ARB || + srcType == GL_FLOAT || + srcType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV); + + switch (srcType) { + case GL_BITMAP: + { + GLubyte *ubsrc = (GLubyte *) src; + if (unpack->LsbFirst) { + GLubyte mask = 1 << (unpack->SkipPixels & 0x7); + GLuint i; + for (i = 0; i < n; i++) { + indexes[i] = (*ubsrc & mask) ? 1 : 0; + if (mask == 128) { + mask = 1; + ubsrc++; + } + else { + mask = mask << 1; + } + } + } + else { + GLubyte mask = 128 >> (unpack->SkipPixels & 0x7); + GLuint i; + for (i = 0; i < n; i++) { + indexes[i] = (*ubsrc & mask) ? 1 : 0; + if (mask == 1) { + mask = 128; + ubsrc++; + } + else { + mask = mask >> 1; + } + } + } + } + break; + case GL_UNSIGNED_BYTE: + { + GLuint i; + const GLubyte *s = (const GLubyte *) src; + for (i = 0; i < n; i++) + indexes[i] = s[i]; + } + break; + case GL_BYTE: + { + GLuint i; + const GLbyte *s = (const GLbyte *) src; + for (i = 0; i < n; i++) + indexes[i] = s[i]; + } + break; + case GL_UNSIGNED_SHORT: + { + GLuint i; + const GLushort *s = (const GLushort *) src; + if (unpack->SwapBytes) { + for (i = 0; i < n; i++) { + GLushort value = s[i]; + SWAP2BYTE(value); + indexes[i] = value; + } + } + else { + for (i = 0; i < n; i++) + indexes[i] = s[i]; + } + } + break; + case GL_SHORT: + { + GLuint i; + const GLshort *s = (const GLshort *) src; + if (unpack->SwapBytes) { + for (i = 0; i < n; i++) { + GLshort value = s[i]; + SWAP2BYTE(value); + indexes[i] = value; + } + } + else { + for (i = 0; i < n; i++) + indexes[i] = s[i]; + } + } + break; + case GL_UNSIGNED_INT: + { + GLuint i; + const GLuint *s = (const GLuint *) src; + if (unpack->SwapBytes) { + for (i = 0; i < n; i++) { + GLuint value = s[i]; + SWAP4BYTE(value); + indexes[i] = value; + } + } + else { + for (i = 0; i < n; i++) + indexes[i] = s[i]; + } + } + break; + case GL_INT: + { + GLuint i; + const GLint *s = (const GLint *) src; + if (unpack->SwapBytes) { + for (i = 0; i < n; i++) { + GLint value = s[i]; + SWAP4BYTE(value); + indexes[i] = value; + } + } + else { + for (i = 0; i < n; i++) + indexes[i] = s[i]; + } + } + break; + case GL_FLOAT: + { + GLuint i; + const GLfloat *s = (const GLfloat *) src; + if (unpack->SwapBytes) { + for (i = 0; i < n; i++) { + GLfloat value = s[i]; + SWAP4BYTE(value); + indexes[i] = (GLuint) value; + } + } + else { + for (i = 0; i < n; i++) + indexes[i] = (GLuint) s[i]; + } + } + break; + case GL_HALF_FLOAT_ARB: + { + GLuint i; + const GLhalfARB *s = (const GLhalfARB *) src; + if (unpack->SwapBytes) { + for (i = 0; i < n; i++) { + GLhalfARB value = s[i]; + SWAP2BYTE(value); + indexes[i] = (GLuint) _mesa_half_to_float(value); + } + } + else { + for (i = 0; i < n; i++) + indexes[i] = (GLuint) _mesa_half_to_float(s[i]); + } + } + break; + case GL_UNSIGNED_INT_24_8_EXT: + { + GLuint i; + const GLuint *s = (const GLuint *) src; + if (unpack->SwapBytes) { + for (i = 0; i < n; i++) { + GLuint value = s[i]; + SWAP4BYTE(value); + indexes[i] = value & 0xff; /* lower 8 bits */ + } + } + else { + for (i = 0; i < n; i++) + indexes[i] = s[i] & 0xff; /* lower 8 bits */ + } + } + break; + case GL_FLOAT_32_UNSIGNED_INT_24_8_REV: + { + GLuint i; + const GLuint *s = (const GLuint *) src; + if (unpack->SwapBytes) { + for (i = 0; i < n; i++) { + GLuint value = s[i*2+1]; + SWAP4BYTE(value); + indexes[i] = value & 0xff; /* lower 8 bits */ + } + } + else { + for (i = 0; i < n; i++) + indexes[i] = s[i*2+1] & 0xff; /* lower 8 bits */ + } + } + break; + + default: + _mesa_problem(NULL, "bad srcType in extract_uint_indexes"); + return; + } +} + + +/** + * Return source/dest RGBA indexes for unpacking pixels. + */ +static void +get_component_mapping(GLenum format, + GLint *rSrc, + GLint *gSrc, + GLint *bSrc, + GLint *aSrc, + GLint *rDst, + GLint *gDst, + GLint *bDst, + GLint *aDst) +{ + switch (format) { + case GL_RED: + case GL_RED_INTEGER_EXT: + *rSrc = 0; + *gSrc = *bSrc = *aSrc = -1; + break; + case GL_GREEN: + case GL_GREEN_INTEGER_EXT: + *gSrc = 0; + *rSrc = *bSrc = *aSrc = -1; + break; + case GL_BLUE: + case GL_BLUE_INTEGER_EXT: + *bSrc = 0; + *rSrc = *gSrc = *aSrc = -1; + break; + case GL_ALPHA: + case GL_ALPHA_INTEGER_EXT: + *rSrc = *gSrc = *bSrc = -1; + *aSrc = 0; + break; + case GL_LUMINANCE: + case GL_LUMINANCE_INTEGER_EXT: + *rSrc = *gSrc = *bSrc = 0; + *aSrc = -1; + break; + case GL_LUMINANCE_ALPHA: + case GL_LUMINANCE_ALPHA_INTEGER_EXT: + *rSrc = *gSrc = *bSrc = 0; + *aSrc = 1; + break; + case GL_INTENSITY: + *rSrc = *gSrc = *bSrc = *aSrc = 0; + break; + case GL_RG: + case GL_RG_INTEGER: + *rSrc = 0; + *gSrc = 1; + *bSrc = -1; + *aSrc = -1; + *rDst = 0; + *gDst = 1; + *bDst = 2; + *aDst = 3; + break; + case GL_RGB: + case GL_RGB_INTEGER: + *rSrc = 0; + *gSrc = 1; + *bSrc = 2; + *aSrc = -1; + *rDst = 0; + *gDst = 1; + *bDst = 2; + *aDst = 3; + break; + case GL_BGR: + *rSrc = 2; + *gSrc = 1; + *bSrc = 0; + *aSrc = -1; + *rDst = 2; + *gDst = 1; + *bDst = 0; + *aDst = 3; + break; + case GL_RGBA: + case GL_RGBA_INTEGER: + *rSrc = 0; + *gSrc = 1; + *bSrc = 2; + *aSrc = 3; + *rDst = 0; + *gDst = 1; + *bDst = 2; + *aDst = 3; + break; + case GL_BGRA: + *rSrc = 2; + *gSrc = 1; + *bSrc = 0; + *aSrc = 3; + *rDst = 2; + *gDst = 1; + *bDst = 0; + *aDst = 3; + break; + case GL_ABGR_EXT: + *rSrc = 3; + *gSrc = 2; + *bSrc = 1; + *aSrc = 0; + *rDst = 3; + *gDst = 2; + *bDst = 1; + *aDst = 0; + break; + case GL_DU8DV8_ATI: + case GL_DUDV_ATI: + *rSrc = 0; + *gSrc = 1; + *bSrc = -1; + *aSrc = -1; + break; + default: + _mesa_problem(NULL, "bad srcFormat %s in get_component_mapping", + _mesa_lookup_enum_by_nr(format)); + return; + } +} + + + +/* + * This function extracts floating point RGBA values from arbitrary + * image data. srcFormat and srcType are the format and type parameters + * passed to glDrawPixels, glTexImage[123]D, glTexSubImage[123]D, etc. + * + * Refering to section 3.6.4 of the OpenGL 1.2 spec, this function + * implements the "Conversion to floating point", "Conversion to RGB", + * and "Final Expansion to RGBA" operations. + * + * Args: n - number of pixels + * rgba - output colors + * srcFormat - format of incoming data + * srcType - data type of incoming data + * src - source data pointer + * swapBytes - perform byteswapping of incoming data? + */ +static void +extract_float_rgba(GLuint n, GLfloat rgba[][4], + GLenum srcFormat, GLenum srcType, const GLvoid *src, + GLboolean swapBytes) +{ + GLint rSrc, gSrc, bSrc, aSrc; + GLint stride; + GLint rDst, bDst, gDst, aDst; + GLboolean intFormat; + GLfloat rs = 1.0f, gs = 1.0f, bs = 1.0f, as = 1.0f; /* scale factors */ + + ASSERT(srcFormat == GL_RED || + srcFormat == GL_GREEN || + srcFormat == GL_BLUE || + srcFormat == GL_ALPHA || + srcFormat == GL_LUMINANCE || + srcFormat == GL_LUMINANCE_ALPHA || + srcFormat == GL_INTENSITY || + srcFormat == GL_RG || + srcFormat == GL_RGB || + srcFormat == GL_BGR || + srcFormat == GL_RGBA || + srcFormat == GL_BGRA || + srcFormat == GL_ABGR_EXT || + srcFormat == GL_DU8DV8_ATI || + srcFormat == GL_DUDV_ATI || + srcFormat == GL_RED_INTEGER_EXT || + srcFormat == GL_GREEN_INTEGER_EXT || + srcFormat == GL_BLUE_INTEGER_EXT || + srcFormat == GL_ALPHA_INTEGER_EXT || + srcFormat == GL_RGB_INTEGER_EXT || + srcFormat == GL_RGBA_INTEGER_EXT || + srcFormat == GL_BGR_INTEGER_EXT || + srcFormat == GL_BGRA_INTEGER_EXT || + srcFormat == GL_LUMINANCE_INTEGER_EXT || + srcFormat == GL_LUMINANCE_ALPHA_INTEGER_EXT); + + ASSERT(srcType == GL_UNSIGNED_BYTE || + srcType == GL_BYTE || + srcType == GL_UNSIGNED_SHORT || + srcType == GL_SHORT || + srcType == GL_UNSIGNED_INT || + srcType == GL_INT || + srcType == GL_HALF_FLOAT_ARB || + srcType == GL_FLOAT || + srcType == GL_UNSIGNED_BYTE_3_3_2 || + srcType == GL_UNSIGNED_BYTE_2_3_3_REV || + srcType == GL_UNSIGNED_SHORT_5_6_5 || + srcType == GL_UNSIGNED_SHORT_5_6_5_REV || + srcType == GL_UNSIGNED_SHORT_4_4_4_4 || + srcType == GL_UNSIGNED_SHORT_4_4_4_4_REV || + srcType == GL_UNSIGNED_SHORT_5_5_5_1 || + srcType == GL_UNSIGNED_SHORT_1_5_5_5_REV || + srcType == GL_UNSIGNED_INT_8_8_8_8 || + srcType == GL_UNSIGNED_INT_8_8_8_8_REV || + srcType == GL_UNSIGNED_INT_10_10_10_2 || + srcType == GL_UNSIGNED_INT_2_10_10_10_REV || + srcType == GL_UNSIGNED_INT_5_9_9_9_REV || + srcType == GL_UNSIGNED_INT_10F_11F_11F_REV); + + get_component_mapping(srcFormat, + &rSrc, &gSrc, &bSrc, &aSrc, + &rDst, &gDst, &bDst, &aDst); + + stride = _mesa_components_in_format(srcFormat); + + intFormat = _mesa_is_integer_format(srcFormat); + +#define PROCESS(SRC_INDEX, DST_INDEX, DEFAULT_FLT, DEFAULT_INT, TYPE, CONVERSION) \ + if ((SRC_INDEX) < 0) { \ + GLuint i; \ + if (intFormat) { \ + for (i = 0; i < n; i++) { \ + rgba[i][DST_INDEX] = DEFAULT_INT; \ + } \ + } \ + else { \ + for (i = 0; i < n; i++) { \ + rgba[i][DST_INDEX] = DEFAULT_FLT; \ + } \ + } \ + } \ + else if (swapBytes) { \ + const TYPE *s = (const TYPE *) src; \ + GLuint i; \ + for (i = 0; i < n; i++) { \ + TYPE value = s[SRC_INDEX]; \ + if (sizeof(TYPE) == 2) { \ + SWAP2BYTE(value); \ + } \ + else if (sizeof(TYPE) == 4) { \ + SWAP4BYTE(value); \ + } \ + if (intFormat) \ + rgba[i][DST_INDEX] = (GLfloat) value; \ + else \ + rgba[i][DST_INDEX] = (GLfloat) CONVERSION(value); \ + s += stride; \ + } \ + } \ + else { \ + const TYPE *s = (const TYPE *) src; \ + GLuint i; \ + if (intFormat) { \ + for (i = 0; i < n; i++) { \ + rgba[i][DST_INDEX] = (GLfloat) s[SRC_INDEX]; \ + s += stride; \ + } \ + } \ + else { \ + for (i = 0; i < n; i++) { \ + rgba[i][DST_INDEX] = (GLfloat) CONVERSION(s[SRC_INDEX]); \ + s += stride; \ + } \ + } \ + } + + switch (srcType) { + case GL_UNSIGNED_BYTE: + PROCESS(rSrc, RCOMP, 0.0F, 0, GLubyte, UBYTE_TO_FLOAT); + PROCESS(gSrc, GCOMP, 0.0F, 0, GLubyte, UBYTE_TO_FLOAT); + PROCESS(bSrc, BCOMP, 0.0F, 0, GLubyte, UBYTE_TO_FLOAT); + PROCESS(aSrc, ACOMP, 1.0F, 255, GLubyte, UBYTE_TO_FLOAT); + break; + case GL_BYTE: + PROCESS(rSrc, RCOMP, 0.0F, 0, GLbyte, BYTE_TO_FLOAT); + PROCESS(gSrc, GCOMP, 0.0F, 0, GLbyte, BYTE_TO_FLOAT); + PROCESS(bSrc, BCOMP, 0.0F, 0, GLbyte, BYTE_TO_FLOAT); + PROCESS(aSrc, ACOMP, 1.0F, 127, GLbyte, BYTE_TO_FLOAT); + break; + case GL_UNSIGNED_SHORT: + PROCESS(rSrc, RCOMP, 0.0F, 0, GLushort, USHORT_TO_FLOAT); + PROCESS(gSrc, GCOMP, 0.0F, 0, GLushort, USHORT_TO_FLOAT); + PROCESS(bSrc, BCOMP, 0.0F, 0, GLushort, USHORT_TO_FLOAT); + PROCESS(aSrc, ACOMP, 1.0F, 0xffff, GLushort, USHORT_TO_FLOAT); + break; + case GL_SHORT: + PROCESS(rSrc, RCOMP, 0.0F, 0, GLshort, SHORT_TO_FLOAT); + PROCESS(gSrc, GCOMP, 0.0F, 0, GLshort, SHORT_TO_FLOAT); + PROCESS(bSrc, BCOMP, 0.0F, 0, GLshort, SHORT_TO_FLOAT); + PROCESS(aSrc, ACOMP, 1.0F, 32767, GLshort, SHORT_TO_FLOAT); + break; + case GL_UNSIGNED_INT: + PROCESS(rSrc, RCOMP, 0.0F, 0, GLuint, UINT_TO_FLOAT); + PROCESS(gSrc, GCOMP, 0.0F, 0, GLuint, UINT_TO_FLOAT); + PROCESS(bSrc, BCOMP, 0.0F, 0, GLuint, UINT_TO_FLOAT); + PROCESS(aSrc, ACOMP, 1.0F, 0xffffffff, GLuint, UINT_TO_FLOAT); + break; + case GL_INT: + PROCESS(rSrc, RCOMP, 0.0F, 0, GLint, INT_TO_FLOAT); + PROCESS(gSrc, GCOMP, 0.0F, 0, GLint, INT_TO_FLOAT); + PROCESS(bSrc, BCOMP, 0.0F, 0, GLint, INT_TO_FLOAT); + PROCESS(aSrc, ACOMP, 1.0F, 2147483647, GLint, INT_TO_FLOAT); + break; + case GL_FLOAT: + PROCESS(rSrc, RCOMP, 0.0F, 0.0F, GLfloat, (GLfloat)); + PROCESS(gSrc, GCOMP, 0.0F, 0.0F, GLfloat, (GLfloat)); + PROCESS(bSrc, BCOMP, 0.0F, 0.0F, GLfloat, (GLfloat)); + PROCESS(aSrc, ACOMP, 1.0F, 1.0F, GLfloat, (GLfloat)); + break; + case GL_HALF_FLOAT_ARB: + PROCESS(rSrc, RCOMP, 0.0F, 0.0F, GLhalfARB, _mesa_half_to_float); + PROCESS(gSrc, GCOMP, 0.0F, 0.0F, GLhalfARB, _mesa_half_to_float); + PROCESS(bSrc, BCOMP, 0.0F, 0.0F, GLhalfARB, _mesa_half_to_float); + PROCESS(aSrc, ACOMP, 1.0F, 1.0F, GLhalfARB, _mesa_half_to_float); + break; + case GL_UNSIGNED_BYTE_3_3_2: + { + const GLubyte *ubsrc = (const GLubyte *) src; + GLuint i; + if (!intFormat) { + rs = 1.0F / 7.0F; + gs = 1.0F / 7.0F; + bs = 1.0F / 3.0F; + } + for (i = 0; i < n; i ++) { + GLubyte p = ubsrc[i]; + rgba[i][rDst] = ((p >> 5) ) * rs; + rgba[i][gDst] = ((p >> 2) & 0x7) * gs; + rgba[i][bDst] = ((p ) & 0x3) * bs; + rgba[i][aDst] = 1.0F; + } + } + break; + case GL_UNSIGNED_BYTE_2_3_3_REV: + { + const GLubyte *ubsrc = (const GLubyte *) src; + GLuint i; + if (!intFormat) { + rs = 1.0F / 7.0F; + gs = 1.0F / 7.0F; + bs = 1.0F / 3.0F; + } + for (i = 0; i < n; i ++) { + GLubyte p = ubsrc[i]; + rgba[i][rDst] = ((p ) & 0x7) * rs; + rgba[i][gDst] = ((p >> 3) & 0x7) * gs; + rgba[i][bDst] = ((p >> 6) ) * bs; + rgba[i][aDst] = 1.0F; + } + } + break; + case GL_UNSIGNED_SHORT_5_6_5: + if (!intFormat) { + rs = 1.0F / 31.0F; + gs = 1.0F / 63.0F; + bs = 1.0F / 31.0F; + } + if (swapBytes) { + const GLushort *ussrc = (const GLushort *) src; + GLuint i; + for (i = 0; i < n; i ++) { + GLushort p = ussrc[i]; + SWAP2BYTE(p); + rgba[i][rDst] = ((p >> 11) ) * rs; + rgba[i][gDst] = ((p >> 5) & 0x3f) * gs; + rgba[i][bDst] = ((p ) & 0x1f) * bs; + rgba[i][aDst] = 1.0F; + } + } + else { + const GLushort *ussrc = (const GLushort *) src; + GLuint i; + for (i = 0; i < n; i ++) { + GLushort p = ussrc[i]; + rgba[i][rDst] = ((p >> 11) ) * rs; + rgba[i][gDst] = ((p >> 5) & 0x3f) * gs; + rgba[i][bDst] = ((p ) & 0x1f) * bs; + rgba[i][aDst] = 1.0F; + } + } + break; + case GL_UNSIGNED_SHORT_5_6_5_REV: + if (!intFormat) { + rs = 1.0F / 31.0F; + gs = 1.0F / 63.0F; + bs = 1.0F / 31.0F; + } + if (swapBytes) { + const GLushort *ussrc = (const GLushort *) src; + GLuint i; + for (i = 0; i < n; i ++) { + GLushort p = ussrc[i]; + SWAP2BYTE(p); + rgba[i][rDst] = ((p ) & 0x1f) * rs; + rgba[i][gDst] = ((p >> 5) & 0x3f) * gs; + rgba[i][bDst] = ((p >> 11) ) * bs; + rgba[i][aDst] = 1.0F; + } + } + else { + const GLushort *ussrc = (const GLushort *) src; + GLuint i; + for (i = 0; i < n; i ++) { + GLushort p = ussrc[i]; + rgba[i][rDst] = ((p ) & 0x1f) * rs; + rgba[i][gDst] = ((p >> 5) & 0x3f) * gs; + rgba[i][bDst] = ((p >> 11) ) * bs; + rgba[i][aDst] = 1.0F; + } + } + break; + case GL_UNSIGNED_SHORT_4_4_4_4: + if (!intFormat) { + rs = gs = bs = as = 1.0F / 15.0F; + } + if (swapBytes) { + const GLushort *ussrc = (const GLushort *) src; + GLuint i; + for (i = 0; i < n; i ++) { + GLushort p = ussrc[i]; + SWAP2BYTE(p); + rgba[i][rDst] = ((p >> 12) ) * rs; + rgba[i][gDst] = ((p >> 8) & 0xf) * gs; + rgba[i][bDst] = ((p >> 4) & 0xf) * bs; + rgba[i][aDst] = ((p ) & 0xf) * as; + } + } + else { + const GLushort *ussrc = (const GLushort *) src; + GLuint i; + for (i = 0; i < n; i ++) { + GLushort p = ussrc[i]; + rgba[i][rDst] = ((p >> 12) ) * rs; + rgba[i][gDst] = ((p >> 8) & 0xf) * gs; + rgba[i][bDst] = ((p >> 4) & 0xf) * bs; + rgba[i][aDst] = ((p ) & 0xf) * as; + } + } + break; + case GL_UNSIGNED_SHORT_4_4_4_4_REV: + if (!intFormat) { + rs = gs = bs = as = 1.0F / 15.0F; + } + if (swapBytes) { + const GLushort *ussrc = (const GLushort *) src; + GLuint i; + for (i = 0; i < n; i ++) { + GLushort p = ussrc[i]; + SWAP2BYTE(p); + rgba[i][rDst] = ((p ) & 0xf) * rs; + rgba[i][gDst] = ((p >> 4) & 0xf) * gs; + rgba[i][bDst] = ((p >> 8) & 0xf) * bs; + rgba[i][aDst] = ((p >> 12) ) * as; + } + } + else { + const GLushort *ussrc = (const GLushort *) src; + GLuint i; + for (i = 0; i < n; i ++) { + GLushort p = ussrc[i]; + rgba[i][rDst] = ((p ) & 0xf) * rs; + rgba[i][gDst] = ((p >> 4) & 0xf) * gs; + rgba[i][bDst] = ((p >> 8) & 0xf) * bs; + rgba[i][aDst] = ((p >> 12) ) * as; + } + } + break; + case GL_UNSIGNED_SHORT_5_5_5_1: + if (!intFormat) { + rs = gs = bs = 1.0F / 31.0F; + } + if (swapBytes) { + const GLushort *ussrc = (const GLushort *) src; + GLuint i; + for (i = 0; i < n; i ++) { + GLushort p = ussrc[i]; + SWAP2BYTE(p); + rgba[i][rDst] = ((p >> 11) ) * rs; + rgba[i][gDst] = ((p >> 6) & 0x1f) * gs; + rgba[i][bDst] = ((p >> 1) & 0x1f) * bs; + rgba[i][aDst] = ((p ) & 0x1) * as; + } + } + else { + const GLushort *ussrc = (const GLushort *) src; + GLuint i; + for (i = 0; i < n; i ++) { + GLushort p = ussrc[i]; + rgba[i][rDst] = ((p >> 11) ) * rs; + rgba[i][gDst] = ((p >> 6) & 0x1f) * gs; + rgba[i][bDst] = ((p >> 1) & 0x1f) * bs; + rgba[i][aDst] = ((p ) & 0x1) * as; + } + } + break; + case GL_UNSIGNED_SHORT_1_5_5_5_REV: + if (!intFormat) { + rs = gs = bs = 1.0F / 31.0F; + } + if (swapBytes) { + const GLushort *ussrc = (const GLushort *) src; + GLuint i; + for (i = 0; i < n; i ++) { + GLushort p = ussrc[i]; + SWAP2BYTE(p); + rgba[i][rDst] = ((p ) & 0x1f) * rs; + rgba[i][gDst] = ((p >> 5) & 0x1f) * gs; + rgba[i][bDst] = ((p >> 10) & 0x1f) * bs; + rgba[i][aDst] = ((p >> 15) ) * as; + } + } + else { + const GLushort *ussrc = (const GLushort *) src; + GLuint i; + for (i = 0; i < n; i ++) { + GLushort p = ussrc[i]; + rgba[i][rDst] = ((p ) & 0x1f) * rs; + rgba[i][gDst] = ((p >> 5) & 0x1f) * gs; + rgba[i][bDst] = ((p >> 10) & 0x1f) * bs; + rgba[i][aDst] = ((p >> 15) ) * as; + } + } + break; + case GL_UNSIGNED_INT_8_8_8_8: + if (swapBytes) { + const GLuint *uisrc = (const GLuint *) src; + GLuint i; + if (intFormat) { + for (i = 0; i < n; i ++) { + GLuint p = uisrc[i]; + rgba[i][rDst] = (GLfloat) ((p ) & 0xff); + rgba[i][gDst] = (GLfloat) ((p >> 8) & 0xff); + rgba[i][bDst] = (GLfloat) ((p >> 16) & 0xff); + rgba[i][aDst] = (GLfloat) ((p >> 24) ); + } + } + else { + for (i = 0; i < n; i ++) { + GLuint p = uisrc[i]; + rgba[i][rDst] = UBYTE_TO_FLOAT((p ) & 0xff); + rgba[i][gDst] = UBYTE_TO_FLOAT((p >> 8) & 0xff); + rgba[i][bDst] = UBYTE_TO_FLOAT((p >> 16) & 0xff); + rgba[i][aDst] = UBYTE_TO_FLOAT((p >> 24) ); + } + } + } + else { + const GLuint *uisrc = (const GLuint *) src; + GLuint i; + if (intFormat) { + for (i = 0; i < n; i ++) { + GLuint p = uisrc[i]; + rgba[i][rDst] = (GLfloat) ((p >> 24) ); + rgba[i][gDst] = (GLfloat) ((p >> 16) & 0xff); + rgba[i][bDst] = (GLfloat) ((p >> 8) & 0xff); + rgba[i][aDst] = (GLfloat) ((p ) & 0xff); + } + } + else { + for (i = 0; i < n; i ++) { + GLuint p = uisrc[i]; + rgba[i][rDst] = UBYTE_TO_FLOAT((p >> 24) ); + rgba[i][gDst] = UBYTE_TO_FLOAT((p >> 16) & 0xff); + rgba[i][bDst] = UBYTE_TO_FLOAT((p >> 8) & 0xff); + rgba[i][aDst] = UBYTE_TO_FLOAT((p ) & 0xff); + } + } + } + break; + case GL_UNSIGNED_INT_8_8_8_8_REV: + if (swapBytes) { + const GLuint *uisrc = (const GLuint *) src; + GLuint i; + if (intFormat) { + for (i = 0; i < n; i ++) { + GLuint p = uisrc[i]; + rgba[i][rDst] = (GLfloat) ((p >> 24) ); + rgba[i][gDst] = (GLfloat) ((p >> 16) & 0xff); + rgba[i][bDst] = (GLfloat) ((p >> 8) & 0xff); + rgba[i][aDst] = (GLfloat) ((p ) & 0xff); + } + } + else { + for (i = 0; i < n; i ++) { + GLuint p = uisrc[i]; + rgba[i][rDst] = UBYTE_TO_FLOAT((p >> 24) ); + rgba[i][gDst] = UBYTE_TO_FLOAT((p >> 16) & 0xff); + rgba[i][bDst] = UBYTE_TO_FLOAT((p >> 8) & 0xff); + rgba[i][aDst] = UBYTE_TO_FLOAT((p ) & 0xff); + } + } + } + else { + const GLuint *uisrc = (const GLuint *) src; + GLuint i; + if (intFormat) { + for (i = 0; i < n; i ++) { + GLuint p = uisrc[i]; + rgba[i][rDst] = (GLfloat) ((p ) & 0xff); + rgba[i][gDst] = (GLfloat) ((p >> 8) & 0xff); + rgba[i][bDst] = (GLfloat) ((p >> 16) & 0xff); + rgba[i][aDst] = (GLfloat) ((p >> 24) ); + } + } + else { + for (i = 0; i < n; i ++) { + GLuint p = uisrc[i]; + rgba[i][rDst] = UBYTE_TO_FLOAT((p ) & 0xff); + rgba[i][gDst] = UBYTE_TO_FLOAT((p >> 8) & 0xff); + rgba[i][bDst] = UBYTE_TO_FLOAT((p >> 16) & 0xff); + rgba[i][aDst] = UBYTE_TO_FLOAT((p >> 24) ); + } + } + } + break; + case GL_UNSIGNED_INT_10_10_10_2: + if (!intFormat) { + rs = 1.0F / 1023.0F; + gs = 1.0F / 1023.0F; + bs = 1.0F / 1023.0F; + as = 1.0F / 3.0F; + } + if (swapBytes) { + const GLuint *uisrc = (const GLuint *) src; + GLuint i; + for (i = 0; i < n; i ++) { + GLuint p = uisrc[i]; + SWAP4BYTE(p); + rgba[i][rDst] = ((p >> 22) ) * rs; + rgba[i][gDst] = ((p >> 12) & 0x3ff) * gs; + rgba[i][bDst] = ((p >> 2) & 0x3ff) * bs; + rgba[i][aDst] = ((p ) & 0x3 ) * as; + } + } + else { + const GLuint *uisrc = (const GLuint *) src; + GLuint i; + for (i = 0; i < n; i ++) { + GLuint p = uisrc[i]; + rgba[i][rDst] = ((p >> 22) ) * rs; + rgba[i][gDst] = ((p >> 12) & 0x3ff) * gs; + rgba[i][bDst] = ((p >> 2) & 0x3ff) * bs; + rgba[i][aDst] = ((p ) & 0x3 ) * as; + } + } + break; + case GL_UNSIGNED_INT_2_10_10_10_REV: + if (!intFormat) { + rs = 1.0F / 1023.0F; + gs = 1.0F / 1023.0F; + bs = 1.0F / 1023.0F; + as = 1.0F / 3.0F; + } + if (swapBytes) { + const GLuint *uisrc = (const GLuint *) src; + GLuint i; + for (i = 0; i < n; i ++) { + GLuint p = uisrc[i]; + SWAP4BYTE(p); + rgba[i][rDst] = ((p ) & 0x3ff) * rs; + rgba[i][gDst] = ((p >> 10) & 0x3ff) * gs; + rgba[i][bDst] = ((p >> 20) & 0x3ff) * bs; + rgba[i][aDst] = ((p >> 30) ) * as; + } + } + else { + const GLuint *uisrc = (const GLuint *) src; + GLuint i; + for (i = 0; i < n; i ++) { + GLuint p = uisrc[i]; + rgba[i][rDst] = ((p ) & 0x3ff) * rs; + rgba[i][gDst] = ((p >> 10) & 0x3ff) * gs; + rgba[i][bDst] = ((p >> 20) & 0x3ff) * bs; + rgba[i][aDst] = ((p >> 30) ) * as; + } + } + break; + case GL_UNSIGNED_INT_5_9_9_9_REV: + if (swapBytes) { + const GLuint *uisrc = (const GLuint *) src; + GLuint i; + GLfloat f[3]; + for (i = 0; i < n; i ++) { + GLuint p = uisrc[i]; + SWAP4BYTE(p); + rgb9e5_to_float3(p, f); + rgba[i][rDst] = f[0]; + rgba[i][gDst] = f[1]; + rgba[i][bDst] = f[2]; + rgba[i][aDst] = 1.0F; + } + } + else { + const GLuint *uisrc = (const GLuint *) src; + GLuint i; + GLfloat f[3]; + for (i = 0; i < n; i ++) { + rgb9e5_to_float3(uisrc[i], f); + rgba[i][rDst] = f[0]; + rgba[i][gDst] = f[1]; + rgba[i][bDst] = f[2]; + rgba[i][aDst] = 1.0F; + } + } + break; + case GL_UNSIGNED_INT_10F_11F_11F_REV: + if (swapBytes) { + const GLuint *uisrc = (const GLuint *) src; + GLuint i; + GLfloat f[3]; + for (i = 0; i < n; i ++) { + GLuint p = uisrc[i]; + SWAP4BYTE(p); + r11g11b10f_to_float3(p, f); + rgba[i][rDst] = f[0]; + rgba[i][gDst] = f[1]; + rgba[i][bDst] = f[2]; + rgba[i][aDst] = 1.0F; + } + } + else { + const GLuint *uisrc = (const GLuint *) src; + GLuint i; + GLfloat f[3]; + for (i = 0; i < n; i ++) { + r11g11b10f_to_float3(uisrc[i], f); + rgba[i][rDst] = f[0]; + rgba[i][gDst] = f[1]; + rgba[i][bDst] = f[2]; + rgba[i][aDst] = 1.0F; + } + } + break; + default: + _mesa_problem(NULL, "bad srcType in extract float data"); + break; + } +#undef PROCESS +} + + +static INLINE GLuint +clamp_byte_to_uint(GLbyte b) +{ + return b < 0 ? 0 : b; +} + + +static INLINE GLuint +clamp_short_to_uint(GLshort s) +{ + return s < 0 ? 0 : s; +} + + +static INLINE GLuint +clamp_int_to_uint(GLint i) +{ + return i < 0 ? 0 : i; +} + + +static INLINE GLuint +clamp_float_to_uint(GLfloat f) +{ + return f < 0.0F ? 0 : IROUND(f); +} + + +static INLINE GLuint +clamp_half_to_uint(GLhalfARB h) +{ + GLfloat f = _mesa_half_to_float(h); + return f < 0.0F ? 0 : IROUND(f); +} + + +/** + * \sa extract_float_rgba() + */ +static void +extract_uint_rgba(GLuint n, GLuint rgba[][4], + GLenum srcFormat, GLenum srcType, const GLvoid *src, + GLboolean swapBytes) +{ + GLint rSrc, gSrc, bSrc, aSrc; + GLint stride; + GLint rDst, bDst, gDst, aDst; + + ASSERT(srcFormat == GL_RED || + srcFormat == GL_GREEN || + srcFormat == GL_BLUE || + srcFormat == GL_ALPHA || + srcFormat == GL_LUMINANCE || + srcFormat == GL_LUMINANCE_ALPHA || + srcFormat == GL_INTENSITY || + srcFormat == GL_RG || + srcFormat == GL_RGB || + srcFormat == GL_BGR || + srcFormat == GL_RGBA || + srcFormat == GL_BGRA || + srcFormat == GL_ABGR_EXT || + srcFormat == GL_DU8DV8_ATI || + srcFormat == GL_DUDV_ATI || + srcFormat == GL_RED_INTEGER_EXT || + srcFormat == GL_GREEN_INTEGER_EXT || + srcFormat == GL_BLUE_INTEGER_EXT || + srcFormat == GL_ALPHA_INTEGER_EXT || + srcFormat == GL_RGB_INTEGER_EXT || + srcFormat == GL_RGBA_INTEGER_EXT || + srcFormat == GL_BGR_INTEGER_EXT || + srcFormat == GL_BGRA_INTEGER_EXT || + srcFormat == GL_LUMINANCE_INTEGER_EXT || + srcFormat == GL_LUMINANCE_ALPHA_INTEGER_EXT); + + ASSERT(srcType == GL_UNSIGNED_BYTE || + srcType == GL_BYTE || + srcType == GL_UNSIGNED_SHORT || + srcType == GL_SHORT || + srcType == GL_UNSIGNED_INT || + srcType == GL_INT || + srcType == GL_HALF_FLOAT_ARB || + srcType == GL_FLOAT || + srcType == GL_UNSIGNED_BYTE_3_3_2 || + srcType == GL_UNSIGNED_BYTE_2_3_3_REV || + srcType == GL_UNSIGNED_SHORT_5_6_5 || + srcType == GL_UNSIGNED_SHORT_5_6_5_REV || + srcType == GL_UNSIGNED_SHORT_4_4_4_4 || + srcType == GL_UNSIGNED_SHORT_4_4_4_4_REV || + srcType == GL_UNSIGNED_SHORT_5_5_5_1 || + srcType == GL_UNSIGNED_SHORT_1_5_5_5_REV || + srcType == GL_UNSIGNED_INT_8_8_8_8 || + srcType == GL_UNSIGNED_INT_8_8_8_8_REV || + srcType == GL_UNSIGNED_INT_10_10_10_2 || + srcType == GL_UNSIGNED_INT_2_10_10_10_REV || + srcType == GL_UNSIGNED_INT_5_9_9_9_REV || + srcType == GL_UNSIGNED_INT_10F_11F_11F_REV); + + get_component_mapping(srcFormat, + &rSrc, &gSrc, &bSrc, &aSrc, + &rDst, &gDst, &bDst, &aDst); + + stride = _mesa_components_in_format(srcFormat); + +#define PROCESS(SRC_INDEX, DST_INDEX, DEFAULT, TYPE, CONVERSION) \ + if ((SRC_INDEX) < 0) { \ + GLuint i; \ + for (i = 0; i < n; i++) { \ + rgba[i][DST_INDEX] = DEFAULT; \ + } \ + } \ + else if (swapBytes) { \ + const TYPE *s = (const TYPE *) src; \ + GLuint i; \ + for (i = 0; i < n; i++) { \ + TYPE value = s[SRC_INDEX]; \ + if (sizeof(TYPE) == 2) { \ + SWAP2BYTE(value); \ + } \ + else if (sizeof(TYPE) == 4) { \ + SWAP4BYTE(value); \ + } \ + rgba[i][DST_INDEX] = CONVERSION(value); \ + s += stride; \ + } \ + } \ + else { \ + const TYPE *s = (const TYPE *) src; \ + GLuint i; \ + for (i = 0; i < n; i++) { \ + rgba[i][DST_INDEX] = CONVERSION(s[SRC_INDEX]); \ + s += stride; \ + } \ + } + + switch (srcType) { + case GL_UNSIGNED_BYTE: + PROCESS(rSrc, RCOMP, 0, GLubyte, (GLuint)); + PROCESS(gSrc, GCOMP, 0, GLubyte, (GLuint)); + PROCESS(bSrc, BCOMP, 0, GLubyte, (GLuint)); + PROCESS(aSrc, ACOMP, 1, GLubyte, (GLuint)); + break; + case GL_BYTE: + PROCESS(rSrc, RCOMP, 0, GLbyte, clamp_byte_to_uint); + PROCESS(gSrc, GCOMP, 0, GLbyte, clamp_byte_to_uint); + PROCESS(bSrc, BCOMP, 0, GLbyte, clamp_byte_to_uint); + PROCESS(aSrc, ACOMP, 1, GLbyte, clamp_byte_to_uint); + break; + case GL_UNSIGNED_SHORT: + PROCESS(rSrc, RCOMP, 0, GLushort, (GLuint)); + PROCESS(gSrc, GCOMP, 0, GLushort, (GLuint)); + PROCESS(bSrc, BCOMP, 0, GLushort, (GLuint)); + PROCESS(aSrc, ACOMP, 1, GLushort, (GLuint)); + break; + case GL_SHORT: + PROCESS(rSrc, RCOMP, 0, GLshort, clamp_short_to_uint); + PROCESS(gSrc, GCOMP, 0, GLshort, clamp_short_to_uint); + PROCESS(bSrc, BCOMP, 0, GLshort, clamp_short_to_uint); + PROCESS(aSrc, ACOMP, 1, GLshort, clamp_short_to_uint); + break; + case GL_UNSIGNED_INT: + PROCESS(rSrc, RCOMP, 0, GLuint, (GLuint)); + PROCESS(gSrc, GCOMP, 0, GLuint, (GLuint)); + PROCESS(bSrc, BCOMP, 0, GLuint, (GLuint)); + PROCESS(aSrc, ACOMP, 1, GLuint, (GLuint)); + break; + case GL_INT: + PROCESS(rSrc, RCOMP, 0, GLint, clamp_int_to_uint); + PROCESS(gSrc, GCOMP, 0, GLint, clamp_int_to_uint); + PROCESS(bSrc, BCOMP, 0, GLint, clamp_int_to_uint); + PROCESS(aSrc, ACOMP, 1, GLint, clamp_int_to_uint); + break; + case GL_FLOAT: + PROCESS(rSrc, RCOMP, 0, GLfloat, clamp_float_to_uint); + PROCESS(gSrc, GCOMP, 0, GLfloat, clamp_float_to_uint); + PROCESS(bSrc, BCOMP, 0, GLfloat, clamp_float_to_uint); + PROCESS(aSrc, ACOMP, 1, GLfloat, clamp_float_to_uint); + break; + case GL_HALF_FLOAT_ARB: + PROCESS(rSrc, RCOMP, 0, GLhalfARB, clamp_half_to_uint); + PROCESS(gSrc, GCOMP, 0, GLhalfARB, clamp_half_to_uint); + PROCESS(bSrc, BCOMP, 0, GLhalfARB, clamp_half_to_uint); + PROCESS(aSrc, ACOMP, 1, GLhalfARB, clamp_half_to_uint); + break; + case GL_UNSIGNED_BYTE_3_3_2: + { + const GLubyte *ubsrc = (const GLubyte *) src; + GLuint i; + for (i = 0; i < n; i ++) { + GLubyte p = ubsrc[i]; + rgba[i][rDst] = ((p >> 5) ); + rgba[i][gDst] = ((p >> 2) & 0x7); + rgba[i][bDst] = ((p ) & 0x3); + rgba[i][aDst] = 1; + } + } + break; + case GL_UNSIGNED_BYTE_2_3_3_REV: + { + const GLubyte *ubsrc = (const GLubyte *) src; + GLuint i; + for (i = 0; i < n; i ++) { + GLubyte p = ubsrc[i]; + rgba[i][rDst] = ((p ) & 0x7); + rgba[i][gDst] = ((p >> 3) & 0x7); + rgba[i][bDst] = ((p >> 6) ); + rgba[i][aDst] = 1; + } + } + break; + case GL_UNSIGNED_SHORT_5_6_5: + if (swapBytes) { + const GLushort *ussrc = (const GLushort *) src; + GLuint i; + for (i = 0; i < n; i ++) { + GLushort p = ussrc[i]; + SWAP2BYTE(p); + rgba[i][rDst] = ((p >> 11) ); + rgba[i][gDst] = ((p >> 5) & 0x3f); + rgba[i][bDst] = ((p ) & 0x1f); + rgba[i][aDst] = 1; + } + } + else { + const GLushort *ussrc = (const GLushort *) src; + GLuint i; + for (i = 0; i < n; i ++) { + GLushort p = ussrc[i]; + rgba[i][rDst] = ((p >> 11) ); + rgba[i][gDst] = ((p >> 5) & 0x3f); + rgba[i][bDst] = ((p ) & 0x1f); + rgba[i][aDst] = 1; + } + } + break; + case GL_UNSIGNED_SHORT_5_6_5_REV: + if (swapBytes) { + const GLushort *ussrc = (const GLushort *) src; + GLuint i; + for (i = 0; i < n; i ++) { + GLushort p = ussrc[i]; + SWAP2BYTE(p); + rgba[i][rDst] = ((p ) & 0x1f); + rgba[i][gDst] = ((p >> 5) & 0x3f); + rgba[i][bDst] = ((p >> 11) ); + rgba[i][aDst] = 1; + } + } + else { + const GLushort *ussrc = (const GLushort *) src; + GLuint i; + for (i = 0; i < n; i ++) { + GLushort p = ussrc[i]; + rgba[i][rDst] = ((p ) & 0x1f); + rgba[i][gDst] = ((p >> 5) & 0x3f); + rgba[i][bDst] = ((p >> 11) ); + rgba[i][aDst] = 1; + } + } + break; + case GL_UNSIGNED_SHORT_4_4_4_4: + if (swapBytes) { + const GLushort *ussrc = (const GLushort *) src; + GLuint i; + for (i = 0; i < n; i ++) { + GLushort p = ussrc[i]; + SWAP2BYTE(p); + rgba[i][rDst] = ((p >> 12) ); + rgba[i][gDst] = ((p >> 8) & 0xf); + rgba[i][bDst] = ((p >> 4) & 0xf); + rgba[i][aDst] = ((p ) & 0xf); + } + } + else { + const GLushort *ussrc = (const GLushort *) src; + GLuint i; + for (i = 0; i < n; i ++) { + GLushort p = ussrc[i]; + rgba[i][rDst] = ((p >> 12) ); + rgba[i][gDst] = ((p >> 8) & 0xf); + rgba[i][bDst] = ((p >> 4) & 0xf); + rgba[i][aDst] = ((p ) & 0xf); + } + } + break; + case GL_UNSIGNED_SHORT_4_4_4_4_REV: + if (swapBytes) { + const GLushort *ussrc = (const GLushort *) src; + GLuint i; + for (i = 0; i < n; i ++) { + GLushort p = ussrc[i]; + SWAP2BYTE(p); + rgba[i][rDst] = ((p ) & 0xf); + rgba[i][gDst] = ((p >> 4) & 0xf); + rgba[i][bDst] = ((p >> 8) & 0xf); + rgba[i][aDst] = ((p >> 12) ); + } + } + else { + const GLushort *ussrc = (const GLushort *) src; + GLuint i; + for (i = 0; i < n; i ++) { + GLushort p = ussrc[i]; + rgba[i][rDst] = ((p ) & 0xf); + rgba[i][gDst] = ((p >> 4) & 0xf); + rgba[i][bDst] = ((p >> 8) & 0xf); + rgba[i][aDst] = ((p >> 12) ); + } + } + break; + case GL_UNSIGNED_SHORT_5_5_5_1: + if (swapBytes) { + const GLushort *ussrc = (const GLushort *) src; + GLuint i; + for (i = 0; i < n; i ++) { + GLushort p = ussrc[i]; + SWAP2BYTE(p); + rgba[i][rDst] = ((p >> 11) ); + rgba[i][gDst] = ((p >> 6) & 0x1f); + rgba[i][bDst] = ((p >> 1) & 0x1f); + rgba[i][aDst] = ((p ) & 0x1 ); + } + } + else { + const GLushort *ussrc = (const GLushort *) src; + GLuint i; + for (i = 0; i < n; i ++) { + GLushort p = ussrc[i]; + rgba[i][rDst] = ((p >> 11) ); + rgba[i][gDst] = ((p >> 6) & 0x1f); + rgba[i][bDst] = ((p >> 1) & 0x1f); + rgba[i][aDst] = ((p ) & 0x1 ); + } + } + break; + case GL_UNSIGNED_SHORT_1_5_5_5_REV: + if (swapBytes) { + const GLushort *ussrc = (const GLushort *) src; + GLuint i; + for (i = 0; i < n; i ++) { + GLushort p = ussrc[i]; + SWAP2BYTE(p); + rgba[i][rDst] = ((p ) & 0x1f); + rgba[i][gDst] = ((p >> 5) & 0x1f); + rgba[i][bDst] = ((p >> 10) & 0x1f); + rgba[i][aDst] = ((p >> 15) ); + } + } + else { + const GLushort *ussrc = (const GLushort *) src; + GLuint i; + for (i = 0; i < n; i ++) { + GLushort p = ussrc[i]; + rgba[i][rDst] = ((p ) & 0x1f); + rgba[i][gDst] = ((p >> 5) & 0x1f); + rgba[i][bDst] = ((p >> 10) & 0x1f); + rgba[i][aDst] = ((p >> 15) ); + } + } + break; + case GL_UNSIGNED_INT_8_8_8_8: + if (swapBytes) { + const GLuint *uisrc = (const GLuint *) src; + GLuint i; + for (i = 0; i < n; i ++) { + GLuint p = uisrc[i]; + rgba[i][rDst] = ((p ) & 0xff); + rgba[i][gDst] = ((p >> 8) & 0xff); + rgba[i][bDst] = ((p >> 16) & 0xff); + rgba[i][aDst] = ((p >> 24) ); + } + } + else { + const GLuint *uisrc = (const GLuint *) src; + GLuint i; + for (i = 0; i < n; i ++) { + GLuint p = uisrc[i]; + rgba[i][rDst] = ((p >> 24) ); + rgba[i][gDst] = ((p >> 16) & 0xff); + rgba[i][bDst] = ((p >> 8) & 0xff); + rgba[i][aDst] = ((p ) & 0xff); + } + } + break; + case GL_UNSIGNED_INT_8_8_8_8_REV: + if (swapBytes) { + const GLuint *uisrc = (const GLuint *) src; + GLuint i; + for (i = 0; i < n; i ++) { + GLuint p = uisrc[i]; + rgba[i][rDst] = ((p >> 24) ); + rgba[i][gDst] = ((p >> 16) & 0xff); + rgba[i][bDst] = ((p >> 8) & 0xff); + rgba[i][aDst] = ((p ) & 0xff); + } + } + else { + const GLuint *uisrc = (const GLuint *) src; + GLuint i; + for (i = 0; i < n; i ++) { + GLuint p = uisrc[i]; + rgba[i][rDst] = ((p ) & 0xff); + rgba[i][gDst] = ((p >> 8) & 0xff); + rgba[i][bDst] = ((p >> 16) & 0xff); + rgba[i][aDst] = ((p >> 24) ); + } + } + break; + case GL_UNSIGNED_INT_10_10_10_2: + if (swapBytes) { + const GLuint *uisrc = (const GLuint *) src; + GLuint i; + for (i = 0; i < n; i ++) { + GLuint p = uisrc[i]; + SWAP4BYTE(p); + rgba[i][rDst] = ((p >> 22) ); + rgba[i][gDst] = ((p >> 12) & 0x3ff); + rgba[i][bDst] = ((p >> 2) & 0x3ff); + rgba[i][aDst] = ((p ) & 0x3 ); + } + } + else { + const GLuint *uisrc = (const GLuint *) src; + GLuint i; + for (i = 0; i < n; i ++) { + GLuint p = uisrc[i]; + rgba[i][rDst] = ((p >> 22) ); + rgba[i][gDst] = ((p >> 12) & 0x3ff); + rgba[i][bDst] = ((p >> 2) & 0x3ff); + rgba[i][aDst] = ((p ) & 0x3 ); + } + } + break; + case GL_UNSIGNED_INT_2_10_10_10_REV: + if (swapBytes) { + const GLuint *uisrc = (const GLuint *) src; + GLuint i; + for (i = 0; i < n; i ++) { + GLuint p = uisrc[i]; + SWAP4BYTE(p); + rgba[i][rDst] = ((p ) & 0x3ff); + rgba[i][gDst] = ((p >> 10) & 0x3ff); + rgba[i][bDst] = ((p >> 20) & 0x3ff); + rgba[i][aDst] = ((p >> 30) ); + } + } + else { + const GLuint *uisrc = (const GLuint *) src; + GLuint i; + for (i = 0; i < n; i ++) { + GLuint p = uisrc[i]; + rgba[i][rDst] = ((p ) & 0x3ff); + rgba[i][gDst] = ((p >> 10) & 0x3ff); + rgba[i][bDst] = ((p >> 20) & 0x3ff); + rgba[i][aDst] = ((p >> 30) ); + } + } + break; + case GL_UNSIGNED_INT_5_9_9_9_REV: + if (swapBytes) { + const GLuint *uisrc = (const GLuint *) src; + GLuint i; + float f[3]; + for (i = 0; i < n; i ++) { + GLuint p = uisrc[i]; + SWAP4BYTE(p); + rgb9e5_to_float3(p, f); + rgba[i][rDst] = clamp_float_to_uint(f[0]); + rgba[i][gDst] = clamp_float_to_uint(f[1]); + rgba[i][bDst] = clamp_float_to_uint(f[2]); + rgba[i][aDst] = 1; + } + } + else { + const GLuint *uisrc = (const GLuint *) src; + GLuint i; + float f[3]; + for (i = 0; i < n; i ++) { + GLuint p = uisrc[i]; + rgb9e5_to_float3(p, f); + rgba[i][rDst] = clamp_float_to_uint(f[0]); + rgba[i][gDst] = clamp_float_to_uint(f[1]); + rgba[i][bDst] = clamp_float_to_uint(f[2]); + rgba[i][aDst] = 1; + } + } + break; + case GL_UNSIGNED_INT_10F_11F_11F_REV: + if (swapBytes) { + const GLuint *uisrc = (const GLuint *) src; + GLuint i; + float f[3]; + for (i = 0; i < n; i ++) { + GLuint p = uisrc[i]; + SWAP4BYTE(p); + r11g11b10f_to_float3(p, f); + rgba[i][rDst] = clamp_float_to_uint(f[0]); + rgba[i][gDst] = clamp_float_to_uint(f[1]); + rgba[i][bDst] = clamp_float_to_uint(f[2]); + rgba[i][aDst] = 1; + } + } + else { + const GLuint *uisrc = (const GLuint *) src; + GLuint i; + float f[3]; + for (i = 0; i < n; i ++) { + GLuint p = uisrc[i]; + r11g11b10f_to_float3(p, f); + rgba[i][rDst] = clamp_float_to_uint(f[0]); + rgba[i][gDst] = clamp_float_to_uint(f[1]); + rgba[i][bDst] = clamp_float_to_uint(f[2]); + rgba[i][aDst] = 1; + } + } + break; + default: + _mesa_problem(NULL, "bad srcType in extract uint data"); + break; + } +#undef PROCESS +} + + + +/* + * Unpack a row of color image data from a client buffer according to + * the pixel unpacking parameters. + * Return GLchan values in the specified dest image format. + * This is used by glDrawPixels and glTexImage?D(). + * \param ctx - the context + * n - number of pixels in the span + * dstFormat - format of destination color array + * dest - the destination color array + * srcFormat - source image format + * srcType - source image data type + * source - source image pointer + * srcPacking - pixel unpacking parameters + * transferOps - bitmask of IMAGE_*_BIT values of operations to apply + * + * XXX perhaps expand this to process whole images someday. + */ +void +_mesa_unpack_color_span_chan( struct gl_context *ctx, + GLuint n, GLenum dstFormat, GLchan dest[], + GLenum srcFormat, GLenum srcType, + const GLvoid *source, + const struct gl_pixelstore_attrib *srcPacking, + GLbitfield transferOps ) +{ + ASSERT(dstFormat == GL_ALPHA || + dstFormat == GL_LUMINANCE || + dstFormat == GL_LUMINANCE_ALPHA || + dstFormat == GL_INTENSITY || + dstFormat == GL_RED || + dstFormat == GL_RG || + dstFormat == GL_RGB || + dstFormat == GL_RGBA); + + ASSERT(srcFormat == GL_RED || + srcFormat == GL_GREEN || + srcFormat == GL_BLUE || + srcFormat == GL_ALPHA || + srcFormat == GL_LUMINANCE || + srcFormat == GL_LUMINANCE_ALPHA || + srcFormat == GL_INTENSITY || + srcFormat == GL_RG || + srcFormat == GL_RGB || + srcFormat == GL_BGR || + srcFormat == GL_RGBA || + srcFormat == GL_BGRA || + srcFormat == GL_ABGR_EXT || + srcFormat == GL_COLOR_INDEX); + + ASSERT(srcType == GL_BITMAP || + srcType == GL_UNSIGNED_BYTE || + srcType == GL_BYTE || + srcType == GL_UNSIGNED_SHORT || + srcType == GL_SHORT || + srcType == GL_UNSIGNED_INT || + srcType == GL_INT || + srcType == GL_HALF_FLOAT_ARB || + srcType == GL_FLOAT || + srcType == GL_UNSIGNED_BYTE_3_3_2 || + srcType == GL_UNSIGNED_BYTE_2_3_3_REV || + srcType == GL_UNSIGNED_SHORT_5_6_5 || + srcType == GL_UNSIGNED_SHORT_5_6_5_REV || + srcType == GL_UNSIGNED_SHORT_4_4_4_4 || + srcType == GL_UNSIGNED_SHORT_4_4_4_4_REV || + srcType == GL_UNSIGNED_SHORT_5_5_5_1 || + srcType == GL_UNSIGNED_SHORT_1_5_5_5_REV || + srcType == GL_UNSIGNED_INT_8_8_8_8 || + srcType == GL_UNSIGNED_INT_8_8_8_8_REV || + srcType == GL_UNSIGNED_INT_10_10_10_2 || + srcType == GL_UNSIGNED_INT_2_10_10_10_REV || + srcType == GL_UNSIGNED_INT_5_9_9_9_REV || + srcType == GL_UNSIGNED_INT_10F_11F_11F_REV); + + /* Try simple cases first */ + if (transferOps == 0) { + if (srcType == CHAN_TYPE) { + if (dstFormat == GL_RGBA) { + if (srcFormat == GL_RGBA) { + memcpy( dest, source, n * 4 * sizeof(GLchan) ); + return; + } + else if (srcFormat == GL_RGB) { + GLuint i; + const GLchan *src = (const GLchan *) source; + GLchan *dst = dest; + for (i = 0; i < n; i++) { + dst[0] = src[0]; + dst[1] = src[1]; + dst[2] = src[2]; + dst[3] = CHAN_MAX; + src += 3; + dst += 4; + } + return; + } + } + else if (dstFormat == GL_RGB) { + if (srcFormat == GL_RGB) { + memcpy( dest, source, n * 3 * sizeof(GLchan) ); + return; + } + else if (srcFormat == GL_RGBA) { + GLuint i; + const GLchan *src = (const GLchan *) source; + GLchan *dst = dest; + for (i = 0; i < n; i++) { + dst[0] = src[0]; + dst[1] = src[1]; + dst[2] = src[2]; + src += 4; + dst += 3; + } + return; + } + } + else if (dstFormat == srcFormat) { + GLint comps = _mesa_components_in_format(srcFormat); + assert(comps > 0); + memcpy( dest, source, n * comps * sizeof(GLchan) ); + return; + } + } + /* + * Common situation, loading 8bit RGBA/RGB source images + * into 16/32 bit destination. (OSMesa16/32) + */ + else if (srcType == GL_UNSIGNED_BYTE) { + if (dstFormat == GL_RGBA) { + if (srcFormat == GL_RGB) { + GLuint i; + const GLubyte *src = (const GLubyte *) source; + GLchan *dst = dest; + for (i = 0; i < n; i++) { + dst[0] = UBYTE_TO_CHAN(src[0]); + dst[1] = UBYTE_TO_CHAN(src[1]); + dst[2] = UBYTE_TO_CHAN(src[2]); + dst[3] = CHAN_MAX; + src += 3; + dst += 4; + } + return; + } + else if (srcFormat == GL_RGBA) { + GLuint i; + const GLubyte *src = (const GLubyte *) source; + GLchan *dst = dest; + for (i = 0; i < n; i++) { + dst[0] = UBYTE_TO_CHAN(src[0]); + dst[1] = UBYTE_TO_CHAN(src[1]); + dst[2] = UBYTE_TO_CHAN(src[2]); + dst[3] = UBYTE_TO_CHAN(src[3]); + src += 4; + dst += 4; + } + return; + } + } + else if (dstFormat == GL_RGB) { + if (srcFormat == GL_RGB) { + GLuint i; + const GLubyte *src = (const GLubyte *) source; + GLchan *dst = dest; + for (i = 0; i < n; i++) { + dst[0] = UBYTE_TO_CHAN(src[0]); + dst[1] = UBYTE_TO_CHAN(src[1]); + dst[2] = UBYTE_TO_CHAN(src[2]); + src += 3; + dst += 3; + } + return; + } + else if (srcFormat == GL_RGBA) { + GLuint i; + const GLubyte *src = (const GLubyte *) source; + GLchan *dst = dest; + for (i = 0; i < n; i++) { + dst[0] = UBYTE_TO_CHAN(src[0]); + dst[1] = UBYTE_TO_CHAN(src[1]); + dst[2] = UBYTE_TO_CHAN(src[2]); + src += 4; + dst += 3; + } + return; + } + } + } + } + + + /* general solution begins here */ + { + GLint dstComponents; + GLint rDst, gDst, bDst, aDst, lDst, iDst; + GLfloat (*rgba)[4] = (GLfloat (*)[4]) malloc(4 * n * sizeof(GLfloat)); + + if (!rgba) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "pixel unpacking"); + return; + } + + dstComponents = _mesa_components_in_format( dstFormat ); + /* source & dest image formats should have been error checked by now */ + assert(dstComponents > 0); + + /* + * Extract image data and convert to RGBA floats + */ + if (srcFormat == GL_COLOR_INDEX) { + GLuint *indexes = (GLuint *) malloc(n * sizeof(GLuint)); + + if (!indexes) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "pixel unpacking"); + return; + } + + extract_uint_indexes(n, indexes, srcFormat, srcType, source, + srcPacking); + + /* Convert indexes to RGBA */ + if (transferOps & IMAGE_SHIFT_OFFSET_BIT) { + _mesa_shift_and_offset_ci(ctx, n, indexes); + } + _mesa_map_ci_to_rgba(ctx, n, indexes, rgba); + + /* Don't do RGBA scale/bias or RGBA->RGBA mapping if starting + * with color indexes. + */ + transferOps &= ~(IMAGE_SCALE_BIAS_BIT | IMAGE_MAP_COLOR_BIT); + + free(indexes); + } + else { + /* non-color index data */ + extract_float_rgba(n, rgba, srcFormat, srcType, source, + srcPacking->SwapBytes); + } + + /* Need to clamp if returning GLubytes or GLushorts */ +#if CHAN_TYPE != GL_FLOAT + transferOps |= IMAGE_CLAMP_BIT; +#endif + + if (transferOps) { + _mesa_apply_rgba_transfer_ops(ctx, transferOps, n, rgba); + } + + get_component_indexes(dstFormat, + &rDst, &gDst, &bDst, &aDst, &lDst, &iDst); + + /* Now return the GLchan data in the requested dstFormat */ + if (rDst >= 0) { + GLchan *dst = dest; + GLuint i; + for (i = 0; i < n; i++) { + CLAMPED_FLOAT_TO_CHAN(dst[rDst], rgba[i][RCOMP]); + dst += dstComponents; + } + } + + if (gDst >= 0) { + GLchan *dst = dest; + GLuint i; + for (i = 0; i < n; i++) { + CLAMPED_FLOAT_TO_CHAN(dst[gDst], rgba[i][GCOMP]); + dst += dstComponents; + } + } + + if (bDst >= 0) { + GLchan *dst = dest; + GLuint i; + for (i = 0; i < n; i++) { + CLAMPED_FLOAT_TO_CHAN(dst[bDst], rgba[i][BCOMP]); + dst += dstComponents; + } + } + + if (aDst >= 0) { + GLchan *dst = dest; + GLuint i; + for (i = 0; i < n; i++) { + CLAMPED_FLOAT_TO_CHAN(dst[aDst], rgba[i][ACOMP]); + dst += dstComponents; + } + } + + if (iDst >= 0) { + GLchan *dst = dest; + GLuint i; + assert(iDst == 0); + assert(dstComponents == 1); + for (i = 0; i < n; i++) { + /* Intensity comes from red channel */ + CLAMPED_FLOAT_TO_CHAN(dst[i], rgba[i][RCOMP]); + } + } + + if (lDst >= 0) { + GLchan *dst = dest; + GLuint i; + assert(lDst == 0); + for (i = 0; i < n; i++) { + /* Luminance comes from red channel */ + CLAMPED_FLOAT_TO_CHAN(dst[0], rgba[i][RCOMP]); + dst += dstComponents; + } + } + + free(rgba); + } +} + + +/** + * Same as _mesa_unpack_color_span_chan(), but return GLfloat data + * instead of GLchan. + */ +void +_mesa_unpack_color_span_float( struct gl_context *ctx, + GLuint n, GLenum dstFormat, GLfloat dest[], + GLenum srcFormat, GLenum srcType, + const GLvoid *source, + const struct gl_pixelstore_attrib *srcPacking, + GLbitfield transferOps ) +{ + ASSERT(dstFormat == GL_ALPHA || + dstFormat == GL_LUMINANCE || + dstFormat == GL_LUMINANCE_ALPHA || + dstFormat == GL_INTENSITY || + dstFormat == GL_RED || + dstFormat == GL_RG || + dstFormat == GL_RGB || + dstFormat == GL_RGBA); + + ASSERT(srcFormat == GL_RED || + srcFormat == GL_GREEN || + srcFormat == GL_BLUE || + srcFormat == GL_ALPHA || + srcFormat == GL_LUMINANCE || + srcFormat == GL_LUMINANCE_ALPHA || + srcFormat == GL_INTENSITY || + srcFormat == GL_RG || + srcFormat == GL_RGB || + srcFormat == GL_BGR || + srcFormat == GL_RGBA || + srcFormat == GL_BGRA || + srcFormat == GL_ABGR_EXT || + srcFormat == GL_RED_INTEGER_EXT || + srcFormat == GL_GREEN_INTEGER_EXT || + srcFormat == GL_BLUE_INTEGER_EXT || + srcFormat == GL_ALPHA_INTEGER_EXT || + srcFormat == GL_RGB_INTEGER_EXT || + srcFormat == GL_RGBA_INTEGER_EXT || + srcFormat == GL_BGR_INTEGER_EXT || + srcFormat == GL_BGRA_INTEGER_EXT || + srcFormat == GL_LUMINANCE_INTEGER_EXT || + srcFormat == GL_LUMINANCE_ALPHA_INTEGER_EXT || + srcFormat == GL_COLOR_INDEX); + + ASSERT(srcType == GL_BITMAP || + srcType == GL_UNSIGNED_BYTE || + srcType == GL_BYTE || + srcType == GL_UNSIGNED_SHORT || + srcType == GL_SHORT || + srcType == GL_UNSIGNED_INT || + srcType == GL_INT || + srcType == GL_HALF_FLOAT_ARB || + srcType == GL_FLOAT || + srcType == GL_UNSIGNED_BYTE_3_3_2 || + srcType == GL_UNSIGNED_BYTE_2_3_3_REV || + srcType == GL_UNSIGNED_SHORT_5_6_5 || + srcType == GL_UNSIGNED_SHORT_5_6_5_REV || + srcType == GL_UNSIGNED_SHORT_4_4_4_4 || + srcType == GL_UNSIGNED_SHORT_4_4_4_4_REV || + srcType == GL_UNSIGNED_SHORT_5_5_5_1 || + srcType == GL_UNSIGNED_SHORT_1_5_5_5_REV || + srcType == GL_UNSIGNED_INT_8_8_8_8 || + srcType == GL_UNSIGNED_INT_8_8_8_8_REV || + srcType == GL_UNSIGNED_INT_10_10_10_2 || + srcType == GL_UNSIGNED_INT_2_10_10_10_REV || + srcType == GL_UNSIGNED_INT_5_9_9_9_REV || + srcType == GL_UNSIGNED_INT_10F_11F_11F_REV); + + /* general solution, no special cases, yet */ + { + GLint dstComponents; + GLint rDst, gDst, bDst, aDst, lDst, iDst; + GLfloat (*rgba)[4] = (GLfloat (*)[4]) malloc(4 * n * sizeof(GLfloat)); + + if (!rgba) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "pixel unpacking"); + return; + } + + dstComponents = _mesa_components_in_format( dstFormat ); + /* source & dest image formats should have been error checked by now */ + assert(dstComponents > 0); + + /* + * Extract image data and convert to RGBA floats + */ + if (srcFormat == GL_COLOR_INDEX) { + GLuint *indexes = (GLuint *) malloc(n * sizeof(GLuint)); + + if (!indexes) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "pixel unpacking"); + free(rgba); + return; + } + + extract_uint_indexes(n, indexes, srcFormat, srcType, source, + srcPacking); + + /* Convert indexes to RGBA */ + if (transferOps & IMAGE_SHIFT_OFFSET_BIT) { + _mesa_shift_and_offset_ci(ctx, n, indexes); + } + _mesa_map_ci_to_rgba(ctx, n, indexes, rgba); + + /* Don't do RGBA scale/bias or RGBA->RGBA mapping if starting + * with color indexes. + */ + transferOps &= ~(IMAGE_SCALE_BIAS_BIT | IMAGE_MAP_COLOR_BIT); + + free(indexes); + } + else { + /* non-color index data */ + extract_float_rgba(n, rgba, srcFormat, srcType, source, + srcPacking->SwapBytes); + } + + if (transferOps) { + _mesa_apply_rgba_transfer_ops(ctx, transferOps, n, rgba); + } + + get_component_indexes(dstFormat, + &rDst, &gDst, &bDst, &aDst, &lDst, &iDst); + + /* Now pack results in the requested dstFormat */ + if (rDst >= 0) { + GLfloat *dst = dest; + GLuint i; + for (i = 0; i < n; i++) { + dst[rDst] = rgba[i][RCOMP]; + dst += dstComponents; + } + } + + if (gDst >= 0) { + GLfloat *dst = dest; + GLuint i; + for (i = 0; i < n; i++) { + dst[gDst] = rgba[i][GCOMP]; + dst += dstComponents; + } + } + + if (bDst >= 0) { + GLfloat *dst = dest; + GLuint i; + for (i = 0; i < n; i++) { + dst[bDst] = rgba[i][BCOMP]; + dst += dstComponents; + } + } + + if (aDst >= 0) { + GLfloat *dst = dest; + GLuint i; + for (i = 0; i < n; i++) { + dst[aDst] = rgba[i][ACOMP]; + dst += dstComponents; + } + } + + if (iDst >= 0) { + GLfloat *dst = dest; + GLuint i; + assert(iDst == 0); + assert(dstComponents == 1); + for (i = 0; i < n; i++) { + /* Intensity comes from red channel */ + dst[i] = rgba[i][RCOMP]; + } + } + + if (lDst >= 0) { + GLfloat *dst = dest; + GLuint i; + assert(lDst == 0); + for (i = 0; i < n; i++) { + /* Luminance comes from red channel */ + dst[0] = rgba[i][RCOMP]; + dst += dstComponents; + } + } + + free(rgba); + } +} + + +/** + * Same as _mesa_unpack_color_span_chan(), but return GLuint data + * instead of GLchan. + * No pixel transfer ops are applied. + */ +void +_mesa_unpack_color_span_uint(struct gl_context *ctx, + GLuint n, GLenum dstFormat, GLuint *dest, + GLenum srcFormat, GLenum srcType, + const GLvoid *source, + const struct gl_pixelstore_attrib *srcPacking) +{ + GLuint (*rgba)[4] = (GLuint (*)[4]) malloc(n * 4 * sizeof(GLfloat)); + + if (!rgba) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "pixel unpacking"); + return; + } + + ASSERT(dstFormat == GL_ALPHA || + dstFormat == GL_LUMINANCE || + dstFormat == GL_LUMINANCE_ALPHA || + dstFormat == GL_INTENSITY || + dstFormat == GL_RED || + dstFormat == GL_RG || + dstFormat == GL_RGB || + dstFormat == GL_RGBA); + + ASSERT(srcFormat == GL_RED || + srcFormat == GL_GREEN || + srcFormat == GL_BLUE || + srcFormat == GL_ALPHA || + srcFormat == GL_LUMINANCE || + srcFormat == GL_LUMINANCE_ALPHA || + srcFormat == GL_INTENSITY || + srcFormat == GL_RG || + srcFormat == GL_RGB || + srcFormat == GL_BGR || + srcFormat == GL_RGBA || + srcFormat == GL_BGRA || + srcFormat == GL_ABGR_EXT || + srcFormat == GL_RED_INTEGER_EXT || + srcFormat == GL_GREEN_INTEGER_EXT || + srcFormat == GL_BLUE_INTEGER_EXT || + srcFormat == GL_ALPHA_INTEGER_EXT || + srcFormat == GL_RGB_INTEGER_EXT || + srcFormat == GL_RGBA_INTEGER_EXT || + srcFormat == GL_BGR_INTEGER_EXT || + srcFormat == GL_BGRA_INTEGER_EXT || + srcFormat == GL_LUMINANCE_INTEGER_EXT || + srcFormat == GL_LUMINANCE_ALPHA_INTEGER_EXT); + + ASSERT(srcType == GL_UNSIGNED_BYTE || + srcType == GL_BYTE || + srcType == GL_UNSIGNED_SHORT || + srcType == GL_SHORT || + srcType == GL_UNSIGNED_INT || + srcType == GL_INT || + srcType == GL_HALF_FLOAT_ARB || + srcType == GL_FLOAT || + srcType == GL_UNSIGNED_BYTE_3_3_2 || + srcType == GL_UNSIGNED_BYTE_2_3_3_REV || + srcType == GL_UNSIGNED_SHORT_5_6_5 || + srcType == GL_UNSIGNED_SHORT_5_6_5_REV || + srcType == GL_UNSIGNED_SHORT_4_4_4_4 || + srcType == GL_UNSIGNED_SHORT_4_4_4_4_REV || + srcType == GL_UNSIGNED_SHORT_5_5_5_1 || + srcType == GL_UNSIGNED_SHORT_1_5_5_5_REV || + srcType == GL_UNSIGNED_INT_8_8_8_8 || + srcType == GL_UNSIGNED_INT_8_8_8_8_REV || + srcType == GL_UNSIGNED_INT_10_10_10_2 || + srcType == GL_UNSIGNED_INT_2_10_10_10_REV || + srcType == GL_UNSIGNED_INT_5_9_9_9_REV || + srcType == GL_UNSIGNED_INT_10F_11F_11F_REV); + + + /* Extract image data as uint[4] pixels */ + extract_uint_rgba(n, rgba, srcFormat, srcType, source, + srcPacking->SwapBytes); + + if (dstFormat == GL_RGBA) { + /* simple case */ + memcpy(dest, rgba, 4 * sizeof(GLuint) * n); + } + else { + /* general case */ + GLint rDst, gDst, bDst, aDst, lDst, iDst; + GLint dstComponents = _mesa_components_in_format( dstFormat ); + + assert(dstComponents > 0); + + get_component_indexes(dstFormat, + &rDst, &gDst, &bDst, &aDst, &lDst, &iDst); + + /* Now pack values in the requested dest format */ + if (rDst >= 0) { + GLuint *dst = dest; + GLuint i; + for (i = 0; i < n; i++) { + dst[rDst] = rgba[i][RCOMP]; + dst += dstComponents; + } + } + + if (gDst >= 0) { + GLuint *dst = dest; + GLuint i; + for (i = 0; i < n; i++) { + dst[gDst] = rgba[i][GCOMP]; + dst += dstComponents; + } + } + + if (bDst >= 0) { + GLuint *dst = dest; + GLuint i; + for (i = 0; i < n; i++) { + dst[bDst] = rgba[i][BCOMP]; + dst += dstComponents; + } + } + + if (aDst >= 0) { + GLuint *dst = dest; + GLuint i; + for (i = 0; i < n; i++) { + dst[aDst] = rgba[i][ACOMP]; + dst += dstComponents; + } + } + + if (iDst >= 0) { + GLuint *dst = dest; + GLuint i; + assert(iDst == 0); + assert(dstComponents == 1); + for (i = 0; i < n; i++) { + /* Intensity comes from red channel */ + dst[i] = rgba[i][RCOMP]; + } + } + + if (lDst >= 0) { + GLuint *dst = dest; + GLuint i; + assert(lDst == 0); + for (i = 0; i < n; i++) { + /* Luminance comes from red channel */ + dst[0] = rgba[i][RCOMP]; + dst += dstComponents; + } + } + } + + free(rgba); +} + + + +/** + * Similar to _mesa_unpack_color_span_float(), but for dudv data instead of rgba, + * directly return GLbyte data, no transfer ops apply. + */ +void +_mesa_unpack_dudv_span_byte( struct gl_context *ctx, + GLuint n, GLenum dstFormat, GLbyte dest[], + GLenum srcFormat, GLenum srcType, + const GLvoid *source, + const struct gl_pixelstore_attrib *srcPacking, + GLbitfield transferOps ) +{ + ASSERT(dstFormat == GL_DUDV_ATI); + ASSERT(srcFormat == GL_DUDV_ATI || + srcFormat == GL_DU8DV8_ATI); + + ASSERT(srcType == GL_UNSIGNED_BYTE || + srcType == GL_BYTE || + srcType == GL_UNSIGNED_SHORT || + srcType == GL_SHORT || + srcType == GL_UNSIGNED_INT || + srcType == GL_INT || + srcType == GL_HALF_FLOAT_ARB || + srcType == GL_FLOAT); + + /* general solution */ + { + GLint dstComponents; + GLbyte *dst = dest; + GLuint i; + GLfloat (*rgba)[4] = (GLfloat (*)[4]) malloc(4 * n * sizeof(GLfloat)); + + if (!rgba) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "pixel unpacking"); + return; + } + + dstComponents = _mesa_components_in_format( dstFormat ); + /* source & dest image formats should have been error checked by now */ + assert(dstComponents > 0); + + /* + * Extract image data and convert to RGBA floats + */ + extract_float_rgba(n, rgba, srcFormat, srcType, source, + srcPacking->SwapBytes); + + + /* Now determine which color channels we need to produce. + * And determine the dest index (offset) within each color tuple. + */ + + /* Now pack results in the requested dstFormat */ + for (i = 0; i < n; i++) { + /* not sure - need clamp[-1,1] here? */ + dst[0] = FLOAT_TO_BYTE(rgba[i][RCOMP]); + dst[1] = FLOAT_TO_BYTE(rgba[i][GCOMP]); + dst += dstComponents; + } + + free(rgba); + } +} + +/* + * Unpack a row of color index data from a client buffer according to + * the pixel unpacking parameters. + * This is (or will be) used by glDrawPixels, glTexImage[123]D, etc. + * + * Args: ctx - the context + * n - number of pixels + * dstType - destination data type + * dest - destination array + * srcType - source pixel type + * source - source data pointer + * srcPacking - pixel unpacking parameters + * transferOps - the pixel transfer operations to apply + */ +void +_mesa_unpack_index_span( struct gl_context *ctx, GLuint n, + GLenum dstType, GLvoid *dest, + GLenum srcType, const GLvoid *source, + const struct gl_pixelstore_attrib *srcPacking, + GLbitfield transferOps ) +{ + ASSERT(srcType == GL_BITMAP || + srcType == GL_UNSIGNED_BYTE || + srcType == GL_BYTE || + srcType == GL_UNSIGNED_SHORT || + srcType == GL_SHORT || + srcType == GL_UNSIGNED_INT || + srcType == GL_INT || + srcType == GL_HALF_FLOAT_ARB || + srcType == GL_FLOAT); + + ASSERT(dstType == GL_UNSIGNED_BYTE || + dstType == GL_UNSIGNED_SHORT || + dstType == GL_UNSIGNED_INT); + + + transferOps &= (IMAGE_MAP_COLOR_BIT | IMAGE_SHIFT_OFFSET_BIT); + + /* + * Try simple cases first + */ + if (transferOps == 0 && srcType == GL_UNSIGNED_BYTE + && dstType == GL_UNSIGNED_BYTE) { + memcpy(dest, source, n * sizeof(GLubyte)); + } + else if (transferOps == 0 && srcType == GL_UNSIGNED_INT + && dstType == GL_UNSIGNED_INT && !srcPacking->SwapBytes) { + memcpy(dest, source, n * sizeof(GLuint)); + } + else { + /* + * general solution + */ + GLuint *indexes = (GLuint *) malloc(n * sizeof(GLuint)); + + if (!indexes) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "pixel unpacking"); + return; + } + + extract_uint_indexes(n, indexes, GL_COLOR_INDEX, srcType, source, + srcPacking); + + if (transferOps) + _mesa_apply_ci_transfer_ops(ctx, transferOps, n, indexes); + + /* convert to dest type */ + switch (dstType) { + case GL_UNSIGNED_BYTE: + { + GLubyte *dst = (GLubyte *) dest; + GLuint i; + for (i = 0; i < n; i++) { + dst[i] = (GLubyte) (indexes[i] & 0xff); + } + } + break; + case GL_UNSIGNED_SHORT: + { + GLuint *dst = (GLuint *) dest; + GLuint i; + for (i = 0; i < n; i++) { + dst[i] = (GLushort) (indexes[i] & 0xffff); + } + } + break; + case GL_UNSIGNED_INT: + memcpy(dest, indexes, n * sizeof(GLuint)); + break; + default: + _mesa_problem(ctx, "bad dstType in _mesa_unpack_index_span"); + } + + free(indexes); + } +} + + +void +_mesa_pack_index_span( struct gl_context *ctx, GLuint n, + GLenum dstType, GLvoid *dest, const GLuint *source, + const struct gl_pixelstore_attrib *dstPacking, + GLbitfield transferOps ) +{ + GLuint *indexes = (GLuint *) malloc(n * sizeof(GLuint)); + + if (!indexes) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "pixel packing"); + return; + } + + transferOps &= (IMAGE_MAP_COLOR_BIT | IMAGE_SHIFT_OFFSET_BIT); + + if (transferOps & (IMAGE_MAP_COLOR_BIT | IMAGE_SHIFT_OFFSET_BIT)) { + /* make a copy of input */ + memcpy(indexes, source, n * sizeof(GLuint)); + _mesa_apply_ci_transfer_ops(ctx, transferOps, n, indexes); + source = indexes; + } + + switch (dstType) { + case GL_UNSIGNED_BYTE: + { + GLubyte *dst = (GLubyte *) dest; + GLuint i; + for (i = 0; i < n; i++) { + *dst++ = (GLubyte) source[i]; + } + } + break; + case GL_BYTE: + { + GLbyte *dst = (GLbyte *) dest; + GLuint i; + for (i = 0; i < n; i++) { + dst[i] = (GLbyte) source[i]; + } + } + break; + case GL_UNSIGNED_SHORT: + { + GLushort *dst = (GLushort *) dest; + GLuint i; + for (i = 0; i < n; i++) { + dst[i] = (GLushort) source[i]; + } + if (dstPacking->SwapBytes) { + _mesa_swap2( (GLushort *) dst, n ); + } + } + break; + case GL_SHORT: + { + GLshort *dst = (GLshort *) dest; + GLuint i; + for (i = 0; i < n; i++) { + dst[i] = (GLshort) source[i]; + } + if (dstPacking->SwapBytes) { + _mesa_swap2( (GLushort *) dst, n ); + } + } + break; + case GL_UNSIGNED_INT: + { + GLuint *dst = (GLuint *) dest; + GLuint i; + for (i = 0; i < n; i++) { + dst[i] = (GLuint) source[i]; + } + if (dstPacking->SwapBytes) { + _mesa_swap4( (GLuint *) dst, n ); + } + } + break; + case GL_INT: + { + GLint *dst = (GLint *) dest; + GLuint i; + for (i = 0; i < n; i++) { + dst[i] = (GLint) source[i]; + } + if (dstPacking->SwapBytes) { + _mesa_swap4( (GLuint *) dst, n ); + } + } + break; + case GL_FLOAT: + { + GLfloat *dst = (GLfloat *) dest; + GLuint i; + for (i = 0; i < n; i++) { + dst[i] = (GLfloat) source[i]; + } + if (dstPacking->SwapBytes) { + _mesa_swap4( (GLuint *) dst, n ); + } + } + break; + case GL_HALF_FLOAT_ARB: + { + GLhalfARB *dst = (GLhalfARB *) dest; + GLuint i; + for (i = 0; i < n; i++) { + dst[i] = _mesa_float_to_half((GLfloat) source[i]); + } + if (dstPacking->SwapBytes) { + _mesa_swap2( (GLushort *) dst, n ); + } + } + break; + default: + _mesa_problem(ctx, "bad type in _mesa_pack_index_span"); + } + + free(indexes); +} + + +/* + * Unpack a row of stencil data from a client buffer according to + * the pixel unpacking parameters. + * This is (or will be) used by glDrawPixels + * + * Args: ctx - the context + * n - number of pixels + * dstType - destination data type + * dest - destination array + * srcType - source pixel type + * source - source data pointer + * srcPacking - pixel unpacking parameters + * transferOps - apply offset/bias/lookup ops? + */ +void +_mesa_unpack_stencil_span( struct gl_context *ctx, GLuint n, + GLenum dstType, GLvoid *dest, + GLenum srcType, const GLvoid *source, + const struct gl_pixelstore_attrib *srcPacking, + GLbitfield transferOps ) +{ + ASSERT(srcType == GL_BITMAP || + srcType == GL_UNSIGNED_BYTE || + srcType == GL_BYTE || + srcType == GL_UNSIGNED_SHORT || + srcType == GL_SHORT || + srcType == GL_UNSIGNED_INT || + srcType == GL_INT || + srcType == GL_UNSIGNED_INT_24_8_EXT || + srcType == GL_HALF_FLOAT_ARB || + srcType == GL_FLOAT || + srcType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV); + + ASSERT(dstType == GL_UNSIGNED_BYTE || + dstType == GL_UNSIGNED_SHORT || + dstType == GL_UNSIGNED_INT || + dstType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV); + + /* only shift and offset apply to stencil */ + transferOps &= IMAGE_SHIFT_OFFSET_BIT; + + /* + * Try simple cases first + */ + if (transferOps == 0 && + !ctx->Pixel.MapStencilFlag && + srcType == GL_UNSIGNED_BYTE && + dstType == GL_UNSIGNED_BYTE) { + memcpy(dest, source, n * sizeof(GLubyte)); + } + else if (transferOps == 0 && + !ctx->Pixel.MapStencilFlag && + srcType == GL_UNSIGNED_INT && + dstType == GL_UNSIGNED_INT && + !srcPacking->SwapBytes) { + memcpy(dest, source, n * sizeof(GLuint)); + } + else { + /* + * general solution + */ + GLuint *indexes = (GLuint *) malloc(n * sizeof(GLuint)); + + if (!indexes) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "stencil unpacking"); + return; + } + + extract_uint_indexes(n, indexes, GL_STENCIL_INDEX, srcType, source, + srcPacking); + + if (transferOps & IMAGE_SHIFT_OFFSET_BIT) { + /* shift and offset indexes */ + _mesa_shift_and_offset_ci(ctx, n, indexes); + } + + if (ctx->Pixel.MapStencilFlag) { + /* Apply stencil lookup table */ + const GLuint mask = ctx->PixelMaps.StoS.Size - 1; + GLuint i; + for (i = 0; i < n; i++) { + indexes[i] = (GLuint)ctx->PixelMaps.StoS.Map[ indexes[i] & mask ]; + } + } + + /* convert to dest type */ + switch (dstType) { + case GL_UNSIGNED_BYTE: + { + GLubyte *dst = (GLubyte *) dest; + GLuint i; + for (i = 0; i < n; i++) { + dst[i] = (GLubyte) (indexes[i] & 0xff); + } + } + break; + case GL_UNSIGNED_SHORT: + { + GLuint *dst = (GLuint *) dest; + GLuint i; + for (i = 0; i < n; i++) { + dst[i] = (GLushort) (indexes[i] & 0xffff); + } + } + break; + case GL_UNSIGNED_INT: + memcpy(dest, indexes, n * sizeof(GLuint)); + break; + case GL_FLOAT_32_UNSIGNED_INT_24_8_REV: + { + GLuint *dst = (GLuint *) dest; + GLuint i; + for (i = 0; i < n; i++) { + dst[i*2+1] = indexes[i] & 0xff; /* lower 8 bits */ + } + } + break; + default: + _mesa_problem(ctx, "bad dstType in _mesa_unpack_stencil_span"); + } + + free(indexes); + } +} + + +void +_mesa_pack_stencil_span( struct gl_context *ctx, GLuint n, + GLenum dstType, GLvoid *dest, const GLstencil *source, + const struct gl_pixelstore_attrib *dstPacking ) +{ + GLstencil *stencil = (GLstencil *) malloc(n * sizeof(GLstencil)); + + if (!stencil) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "stencil packing"); + return; + } + + if (ctx->Pixel.IndexShift || ctx->Pixel.IndexOffset || + ctx->Pixel.MapStencilFlag) { + /* make a copy of input */ + memcpy(stencil, source, n * sizeof(GLstencil)); + _mesa_apply_stencil_transfer_ops(ctx, n, stencil); + source = stencil; + } + + switch (dstType) { + case GL_UNSIGNED_BYTE: + if (sizeof(GLstencil) == 1) { + memcpy( dest, source, n ); + } + else { + GLubyte *dst = (GLubyte *) dest; + GLuint i; + for (i=0;iSwapBytes) { + _mesa_swap2( (GLushort *) dst, n ); + } + } + break; + case GL_SHORT: + { + GLshort *dst = (GLshort *) dest; + GLuint i; + for (i=0;iSwapBytes) { + _mesa_swap2( (GLushort *) dst, n ); + } + } + break; + case GL_UNSIGNED_INT: + { + GLuint *dst = (GLuint *) dest; + GLuint i; + for (i=0;iSwapBytes) { + _mesa_swap4( (GLuint *) dst, n ); + } + } + break; + case GL_INT: + { + GLint *dst = (GLint *) dest; + GLuint i; + for (i=0;iSwapBytes) { + _mesa_swap4( (GLuint *) dst, n ); + } + } + break; + case GL_FLOAT: + { + GLfloat *dst = (GLfloat *) dest; + GLuint i; + for (i=0;iSwapBytes) { + _mesa_swap4( (GLuint *) dst, n ); + } + } + break; + case GL_HALF_FLOAT_ARB: + { + GLhalfARB *dst = (GLhalfARB *) dest; + GLuint i; + for (i=0;iSwapBytes) { + _mesa_swap2( (GLushort *) dst, n ); + } + } + break; + case GL_BITMAP: + if (dstPacking->LsbFirst) { + GLubyte *dst = (GLubyte *) dest; + GLint shift = 0; + GLuint i; + for (i = 0; i < n; i++) { + if (shift == 0) + *dst = 0; + *dst |= ((source[i] != 0) << shift); + shift++; + if (shift == 8) { + shift = 0; + dst++; + } + } + } + else { + GLubyte *dst = (GLubyte *) dest; + GLint shift = 7; + GLuint i; + for (i = 0; i < n; i++) { + if (shift == 7) + *dst = 0; + *dst |= ((source[i] != 0) << shift); + shift--; + if (shift < 0) { + shift = 7; + dst++; + } + } + } + break; + default: + _mesa_problem(ctx, "bad type in _mesa_pack_index_span"); + } + + free(stencil); +} + +#define DEPTH_VALUES(GLTYPE, GLTYPE2FLOAT) \ + do { \ + GLuint i; \ + const GLTYPE *src = (const GLTYPE *)source; \ + for (i = 0; i < n; i++) { \ + GLTYPE value = src[i]; \ + if (srcPacking->SwapBytes) { \ + if (sizeof(GLTYPE) == 2) { \ + SWAP2BYTE(value); \ + } else if (sizeof(GLTYPE) == 4) { \ + SWAP4BYTE(value); \ + } \ + } \ + depthValues[i] = GLTYPE2FLOAT(value); \ + } \ + } while (0) + + +/** + * Unpack a row of depth/z values from memory, returning GLushort, GLuint + * or GLfloat values. + * The glPixelTransfer (scale/bias) params will be applied. + * + * \param dstType one of GL_UNSIGNED_SHORT, GL_UNSIGNED_INT, GL_FLOAT + * \param depthMax max value for returned GLushort or GLuint values + * (ignored for GLfloat). + */ +void +_mesa_unpack_depth_span( struct gl_context *ctx, GLuint n, + GLenum dstType, GLvoid *dest, GLuint depthMax, + GLenum srcType, const GLvoid *source, + const struct gl_pixelstore_attrib *srcPacking ) +{ + GLfloat *depthTemp = NULL, *depthValues; + GLboolean needClamp = GL_FALSE; + + /* Look for special cases first. + * Not only are these faster, they're less prone to numeric conversion + * problems. Otherwise, converting from an int type to a float then + * back to an int type can introduce errors that will show up as + * artifacts in things like depth peeling which uses glCopyTexImage. + */ + if (ctx->Pixel.DepthScale == 1.0 && ctx->Pixel.DepthBias == 0.0) { + if (srcType == GL_UNSIGNED_INT && dstType == GL_UNSIGNED_SHORT) { + const GLuint *src = (const GLuint *) source; + GLushort *dst = (GLushort *) dest; + GLuint i; + for (i = 0; i < n; i++) { + dst[i] = src[i] >> 16; + } + return; + } + if (srcType == GL_UNSIGNED_SHORT + && dstType == GL_UNSIGNED_INT + && depthMax == 0xffffffff) { + const GLushort *src = (const GLushort *) source; + GLuint *dst = (GLuint *) dest; + GLuint i; + for (i = 0; i < n; i++) { + dst[i] = src[i] | (src[i] << 16); + } + return; + } + if (srcType == GL_UNSIGNED_INT_24_8 + && dstType == GL_UNSIGNED_INT + && depthMax == 0xffffff) { + const GLuint *src = (const GLuint *) source; + GLuint *dst = (GLuint *) dest; + GLuint i; + for (i = 0; i < n; i++) { + dst[i] = src[i] >> 8; + } + return; + } + /* XXX may want to add additional cases here someday */ + } + + /* general case path follows */ + + if (dstType == GL_FLOAT) { + depthValues = (GLfloat *) dest; + } + else { + depthTemp = (GLfloat *) malloc(n * sizeof(GLfloat)); + if (!depthTemp) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "pixel unpacking"); + return; + } + + depthValues = depthTemp; + } + + /* Convert incoming values to GLfloat. Some conversions will require + * clamping, below. + */ + switch (srcType) { + case GL_BYTE: + DEPTH_VALUES(GLbyte, BYTE_TO_FLOAT); + needClamp = GL_TRUE; + break; + case GL_UNSIGNED_BYTE: + DEPTH_VALUES(GLubyte, UBYTE_TO_FLOAT); + break; + case GL_SHORT: + DEPTH_VALUES(GLshort, SHORT_TO_FLOAT); + needClamp = GL_TRUE; + break; + case GL_UNSIGNED_SHORT: + DEPTH_VALUES(GLushort, USHORT_TO_FLOAT); + break; + case GL_INT: + DEPTH_VALUES(GLint, INT_TO_FLOAT); + needClamp = GL_TRUE; + break; + case GL_UNSIGNED_INT: + DEPTH_VALUES(GLuint, UINT_TO_FLOAT); + break; + case GL_UNSIGNED_INT_24_8_EXT: /* GL_EXT_packed_depth_stencil */ + if (dstType == GL_UNSIGNED_INT_24_8_EXT && + depthMax == 0xffffff && + ctx->Pixel.DepthScale == 1.0 && + ctx->Pixel.DepthBias == 0.0) { + const GLuint *src = (const GLuint *) source; + GLuint *zValues = (GLuint *) dest; + GLuint i; + for (i = 0; i < n; i++) { + GLuint value = src[i]; + if (srcPacking->SwapBytes) { + SWAP4BYTE(value); + } + zValues[i] = value & 0xffffff00; + } + free(depthTemp); + return; + } + else { + const GLuint *src = (const GLuint *) source; + const GLfloat scale = 1.0f / 0xffffff; + GLuint i; + for (i = 0; i < n; i++) { + GLuint value = src[i]; + if (srcPacking->SwapBytes) { + SWAP4BYTE(value); + } + depthValues[i] = (value >> 8) * scale; + } + } + break; + case GL_FLOAT_32_UNSIGNED_INT_24_8_REV: + { + GLuint i; + const GLfloat *src = (const GLfloat *)source; + for (i = 0; i < n; i++) { + GLfloat value = src[i * 2]; + if (srcPacking->SwapBytes) { + SWAP4BYTE(value); + } + depthValues[i] = value; + } + needClamp = GL_TRUE; + } + break; + case GL_FLOAT: + DEPTH_VALUES(GLfloat, 1*); + needClamp = GL_TRUE; + break; + case GL_HALF_FLOAT_ARB: + { + GLuint i; + const GLhalfARB *src = (const GLhalfARB *) source; + for (i = 0; i < n; i++) { + GLhalfARB value = src[i]; + if (srcPacking->SwapBytes) { + SWAP2BYTE(value); + } + depthValues[i] = _mesa_half_to_float(value); + } + needClamp = GL_TRUE; + } + break; + default: + _mesa_problem(NULL, "bad type in _mesa_unpack_depth_span()"); + free(depthTemp); + return; + } + + /* apply depth scale and bias */ + { + const GLfloat scale = ctx->Pixel.DepthScale; + const GLfloat bias = ctx->Pixel.DepthBias; + if (scale != 1.0 || bias != 0.0) { + GLuint i; + for (i = 0; i < n; i++) { + depthValues[i] = depthValues[i] * scale + bias; + } + needClamp = GL_TRUE; + } + } + + /* clamp to [0, 1] */ + if (needClamp) { + GLuint i; + for (i = 0; i < n; i++) { + depthValues[i] = (GLfloat)CLAMP(depthValues[i], 0.0, 1.0); + } + } + + /* + * Convert values to dstType + */ + if (dstType == GL_UNSIGNED_INT) { + GLuint *zValues = (GLuint *) dest; + GLuint i; + if (depthMax <= 0xffffff) { + /* no overflow worries */ + for (i = 0; i < n; i++) { + zValues[i] = (GLuint) (depthValues[i] * (GLfloat) depthMax); + } + } + else { + /* need to use double precision to prevent overflow problems */ + for (i = 0; i < n; i++) { + GLdouble z = depthValues[i] * (GLfloat) depthMax; + if (z >= (GLdouble) 0xffffffff) + zValues[i] = 0xffffffff; + else + zValues[i] = (GLuint) z; + } + } + } + else if (dstType == GL_UNSIGNED_SHORT) { + GLushort *zValues = (GLushort *) dest; + GLuint i; + ASSERT(depthMax <= 0xffff); + for (i = 0; i < n; i++) { + zValues[i] = (GLushort) (depthValues[i] * (GLfloat) depthMax); + } + } + else if (dstType == GL_FLOAT) { + /* Nothing to do. depthValues is pointing to dest. */ + } + else if (dstType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV) { + GLfloat *zValues = (GLfloat*) dest; + GLuint i; + for (i = 0; i < n; i++) { + zValues[i*2] = depthValues[i]; + } + } + else { + ASSERT(0); + } + + free(depthTemp); +} + + +/* + * Pack an array of depth values. The values are floats in [0,1]. + */ +void +_mesa_pack_depth_span( struct gl_context *ctx, GLuint n, GLvoid *dest, + GLenum dstType, const GLfloat *depthSpan, + const struct gl_pixelstore_attrib *dstPacking ) +{ + GLfloat *depthCopy = (GLfloat *) malloc(n * sizeof(GLfloat)); + if (!depthCopy) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "pixel packing"); + return; + } + + if (ctx->Pixel.DepthScale != 1.0 || ctx->Pixel.DepthBias != 0.0) { + memcpy(depthCopy, depthSpan, n * sizeof(GLfloat)); + _mesa_scale_and_bias_depth(ctx, n, depthCopy); + depthSpan = depthCopy; + } + + switch (dstType) { + case GL_UNSIGNED_BYTE: + { + GLubyte *dst = (GLubyte *) dest; + GLuint i; + for (i = 0; i < n; i++) { + dst[i] = FLOAT_TO_UBYTE( depthSpan[i] ); + } + } + break; + case GL_BYTE: + { + GLbyte *dst = (GLbyte *) dest; + GLuint i; + for (i = 0; i < n; i++) { + dst[i] = FLOAT_TO_BYTE( depthSpan[i] ); + } + } + break; + case GL_UNSIGNED_SHORT: + { + GLushort *dst = (GLushort *) dest; + GLuint i; + for (i = 0; i < n; i++) { + CLAMPED_FLOAT_TO_USHORT(dst[i], depthSpan[i]); + } + if (dstPacking->SwapBytes) { + _mesa_swap2( (GLushort *) dst, n ); + } + } + break; + case GL_SHORT: + { + GLshort *dst = (GLshort *) dest; + GLuint i; + for (i = 0; i < n; i++) { + dst[i] = FLOAT_TO_SHORT( depthSpan[i] ); + } + if (dstPacking->SwapBytes) { + _mesa_swap2( (GLushort *) dst, n ); + } + } + break; + case GL_UNSIGNED_INT: + { + GLuint *dst = (GLuint *) dest; + GLuint i; + for (i = 0; i < n; i++) { + dst[i] = FLOAT_TO_UINT( depthSpan[i] ); + } + if (dstPacking->SwapBytes) { + _mesa_swap4( (GLuint *) dst, n ); + } + } + break; + case GL_INT: + { + GLint *dst = (GLint *) dest; + GLuint i; + for (i = 0; i < n; i++) { + dst[i] = FLOAT_TO_INT( depthSpan[i] ); + } + if (dstPacking->SwapBytes) { + _mesa_swap4( (GLuint *) dst, n ); + } + } + break; + case GL_FLOAT: + { + GLfloat *dst = (GLfloat *) dest; + GLuint i; + for (i = 0; i < n; i++) { + dst[i] = depthSpan[i]; + } + if (dstPacking->SwapBytes) { + _mesa_swap4( (GLuint *) dst, n ); + } + } + break; + case GL_HALF_FLOAT_ARB: + { + GLhalfARB *dst = (GLhalfARB *) dest; + GLuint i; + for (i = 0; i < n; i++) { + dst[i] = _mesa_float_to_half(depthSpan[i]); + } + if (dstPacking->SwapBytes) { + _mesa_swap2( (GLushort *) dst, n ); + } + } + break; + default: + _mesa_problem(ctx, "bad type in _mesa_pack_depth_span"); + } + + free(depthCopy); +} + + + +/** + * Pack depth and stencil values as GL_DEPTH_STENCIL (GL_UNSIGNED_INT_24_8 etc) + */ +void +_mesa_pack_depth_stencil_span(struct gl_context *ctx,GLuint n, + GLenum dstType, GLuint *dest, + const GLfloat *depthVals, + const GLstencil *stencilVals, + const struct gl_pixelstore_attrib *dstPacking) +{ + GLfloat *depthCopy = (GLfloat *) malloc(n * sizeof(GLfloat)); + GLstencil *stencilCopy = (GLstencil *) malloc(n * sizeof(GLstencil)); + GLuint i; + + if (!depthCopy || !stencilCopy) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "pixel packing"); + free(depthCopy); + free(stencilCopy); + return; + } + + if (ctx->Pixel.DepthScale != 1.0 || ctx->Pixel.DepthBias != 0.0) { + memcpy(depthCopy, depthVals, n * sizeof(GLfloat)); + _mesa_scale_and_bias_depth(ctx, n, depthCopy); + depthVals = depthCopy; + } + + if (ctx->Pixel.IndexShift || + ctx->Pixel.IndexOffset || + ctx->Pixel.MapStencilFlag) { + memcpy(stencilCopy, stencilVals, n * sizeof(GLstencil)); + _mesa_apply_stencil_transfer_ops(ctx, n, stencilCopy); + stencilVals = stencilCopy; + } + + switch (dstType) { + case GL_UNSIGNED_INT_24_8: + for (i = 0; i < n; i++) { + GLuint z = (GLuint) (depthVals[i] * 0xffffff); + dest[i] = (z << 8) | (stencilVals[i] & 0xff); + } + break; + case GL_FLOAT_32_UNSIGNED_INT_24_8_REV: + for (i = 0; i < n; i++) { + ((GLfloat*)dest)[i*2] = depthVals[i]; + dest[i*2+1] = stencilVals[i] & 0xff; + } + break; + } + + if (dstPacking->SwapBytes) { + _mesa_swap4(dest, n); + } + + free(depthCopy); + free(stencilCopy); +} + + + + +/** + * Unpack image data. Apply byte swapping, byte flipping (bitmap). + * Return all image data in a contiguous block. This is used when we + * compile glDrawPixels, glTexImage, etc into a display list. We + * need a copy of the data in a standard format. + */ +void * +_mesa_unpack_image( GLuint dimensions, + GLsizei width, GLsizei height, GLsizei depth, + GLenum format, GLenum type, const GLvoid *pixels, + const struct gl_pixelstore_attrib *unpack ) +{ + GLint bytesPerRow, compsPerRow; + GLboolean flipBytes, swap2, swap4; + + if (!pixels) + return NULL; /* not necessarily an error */ + + if (width <= 0 || height <= 0 || depth <= 0) + return NULL; /* generate error later */ + + if (type == GL_BITMAP) { + bytesPerRow = (width + 7) >> 3; + flipBytes = unpack->LsbFirst; + swap2 = swap4 = GL_FALSE; + compsPerRow = 0; + } + else { + const GLint bytesPerPixel = _mesa_bytes_per_pixel(format, type); + GLint components = _mesa_components_in_format(format); + GLint bytesPerComp; + + if (_mesa_type_is_packed(type)) + components = 1; + + if (bytesPerPixel <= 0 || components <= 0) + return NULL; /* bad format or type. generate error later */ + bytesPerRow = bytesPerPixel * width; + bytesPerComp = bytesPerPixel / components; + flipBytes = GL_FALSE; + swap2 = (bytesPerComp == 2) && unpack->SwapBytes; + swap4 = (bytesPerComp == 4) && unpack->SwapBytes; + compsPerRow = components * width; + assert(compsPerRow >= width); + } + + { + GLubyte *destBuffer + = (GLubyte *) malloc(bytesPerRow * height * depth); + GLubyte *dst; + GLint img, row; + if (!destBuffer) + return NULL; /* generate GL_OUT_OF_MEMORY later */ + + dst = destBuffer; + for (img = 0; img < depth; img++) { + for (row = 0; row < height; row++) { + const GLvoid *src = _mesa_image_address(dimensions, unpack, pixels, + width, height, format, type, img, row, 0); + + if ((type == GL_BITMAP) && (unpack->SkipPixels & 0x7)) { + GLint i; + flipBytes = GL_FALSE; + if (unpack->LsbFirst) { + GLubyte srcMask = 1 << (unpack->SkipPixels & 0x7); + GLubyte dstMask = 128; + const GLubyte *s = src; + GLubyte *d = dst; + *d = 0; + for (i = 0; i < width; i++) { + if (*s & srcMask) { + *d |= dstMask; + } + if (srcMask == 128) { + srcMask = 1; + s++; + } + else { + srcMask = srcMask << 1; + } + if (dstMask == 1) { + dstMask = 128; + d++; + *d = 0; + } + else { + dstMask = dstMask >> 1; + } + } + } + else { + GLubyte srcMask = 128 >> (unpack->SkipPixels & 0x7); + GLubyte dstMask = 128; + const GLubyte *s = src; + GLubyte *d = dst; + *d = 0; + for (i = 0; i < width; i++) { + if (*s & srcMask) { + *d |= dstMask; + } + if (srcMask == 1) { + srcMask = 128; + s++; + } + else { + srcMask = srcMask >> 1; + } + if (dstMask == 1) { + dstMask = 128; + d++; + *d = 0; + } + else { + dstMask = dstMask >> 1; + } + } + } + } + else { + memcpy(dst, src, bytesPerRow); + } + + /* byte flipping/swapping */ + if (flipBytes) { + flip_bytes((GLubyte *) dst, bytesPerRow); + } + else if (swap2) { + _mesa_swap2((GLushort*) dst, compsPerRow); + } + else if (swap4) { + _mesa_swap4((GLuint*) dst, compsPerRow); + } + dst += bytesPerRow; + } + } + return destBuffer; + } +} + diff --git a/mesalib/src/mesa/main/pbo.c b/mesalib/src/mesa/main/pbo.c index 1b1fdaf3d..4e7e6f925 100644 --- a/mesalib/src/mesa/main/pbo.c +++ b/mesalib/src/mesa/main/pbo.c @@ -1,395 +1,395 @@ -/* - * Mesa 3-D graphics library - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (C) 2009-2011 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. - */ - - -/** - * \file pbo.c - * \brief Functions related to Pixel Buffer Objects. - */ - - - -#include "glheader.h" -#include "bufferobj.h" -#include "image.h" -#include "imports.h" -#include "mtypes.h" -#include "pbo.h" - - - -/** - * When we're about to read pixel data out of a PBO (via glDrawPixels, - * glTexImage, etc) or write data into a PBO (via glReadPixels, - * glGetTexImage, etc) we call this function to check that we're not - * going to read/write out of bounds. - * - * XXX This would also be a convenient time to check that the PBO isn't - * currently mapped. Whoever calls this function should check for that. - * Remember, we can't use a PBO when it's mapped! - * - * If we're not using a PBO, this is a no-op. - * - * \param width width of image to read/write - * \param height height of image to read/write - * \param depth depth of image to read/write - * \param format format of image to read/write - * \param type datatype of image to read/write - * \param clientMemSize the maximum number of bytes to read/write - * \param ptr the user-provided pointer/offset - * \return GL_TRUE if the buffer access is OK, GL_FALSE if the access would - * go out of bounds. - */ -GLboolean -_mesa_validate_pbo_access(GLuint dimensions, - const struct gl_pixelstore_attrib *pack, - GLsizei width, GLsizei height, GLsizei depth, - GLenum format, GLenum type, GLsizei clientMemSize, - const GLvoid *ptr) -{ - const GLvoid *start, *end, *offset; - const GLubyte *sizeAddr; /* buffer size, cast to a pointer */ - - /* If no PBO is bound, 'ptr' is a pointer to client memory containing - 'clientMemSize' bytes. - If a PBO is bound, 'ptr' is an offset into the bound PBO. - In that case 'clientMemSize' is ignored: we just use the PBO's size. - */ - if (!_mesa_is_bufferobj(pack->BufferObj)) { - offset = 0; - sizeAddr = ((const GLubyte *) 0) + clientMemSize; - } else { - offset = ptr; - sizeAddr = ((const GLubyte *) 0) + pack->BufferObj->Size; - } - - if (sizeAddr == 0) - /* no buffer! */ - return GL_FALSE; - - /* get the offset to the first pixel we'll read/write */ - start = _mesa_image_address(dimensions, pack, offset, width, height, - format, type, 0, 0, 0); - - /* get the offset to just past the last pixel we'll read/write */ - end = _mesa_image_address(dimensions, pack, offset, width, height, - format, type, depth-1, height-1, width); - - if ((const GLubyte *) start > sizeAddr) { - /* This will catch negative values / wrap-around */ - return GL_FALSE; - } - if ((const GLubyte *) end > sizeAddr) { - /* Image read/write goes beyond end of buffer */ - return GL_FALSE; - } - - /* OK! */ - return GL_TRUE; -} - - -/** - * For commands that read from a PBO (glDrawPixels, glTexImage, - * glPolygonStipple, etc), if we're reading from a PBO, map it read-only - * and return the pointer into the PBO. If we're not reading from a - * PBO, return \p src as-is. - * If non-null return, must call _mesa_unmap_pbo_source() when done. - * - * \return NULL if error, else pointer to start of data - */ -const GLvoid * -_mesa_map_pbo_source(struct gl_context *ctx, - const struct gl_pixelstore_attrib *unpack, - const GLvoid *src) -{ - const GLubyte *buf; - - if (_mesa_is_bufferobj(unpack->BufferObj)) { - /* unpack from PBO */ - buf = (GLubyte *) ctx->Driver.MapBufferRange(ctx, 0, - unpack->BufferObj->Size, - GL_MAP_READ_BIT, - unpack->BufferObj); - if (!buf) - return NULL; - - buf = ADD_POINTERS(buf, src); - } - else { - /* unpack from normal memory */ - buf = src; - } - - return buf; -} - - -/** - * Combine PBO-read validation and mapping. - * If any GL errors are detected, they'll be recorded and NULL returned. - * \sa _mesa_validate_pbo_access - * \sa _mesa_map_pbo_source - * A call to this function should have a matching call to - * _mesa_unmap_pbo_source(). - */ -const GLvoid * -_mesa_map_validate_pbo_source(struct gl_context *ctx, - GLuint dimensions, - const struct gl_pixelstore_attrib *unpack, - GLsizei width, GLsizei height, GLsizei depth, - GLenum format, GLenum type, GLsizei clientMemSize, - const GLvoid *ptr, const char *where) -{ - ASSERT(dimensions == 1 || dimensions == 2 || dimensions == 3); - - if (!_mesa_validate_pbo_access(dimensions, unpack, width, height, depth, - format, type, clientMemSize, ptr)) { - if (_mesa_is_bufferobj(unpack->BufferObj)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "%s(out of bounds PBO access)", where); - } else { - _mesa_error(ctx, GL_INVALID_OPERATION, - "%s(out of bounds access: bufSize (%d) is too small)", - where, clientMemSize); - } - return NULL; - } - - if (!_mesa_is_bufferobj(unpack->BufferObj)) { - /* non-PBO access: no further validation to be done */ - return ptr; - } - - if (_mesa_bufferobj_mapped(unpack->BufferObj)) { - /* buffer is already mapped - that's an error */ - _mesa_error(ctx, GL_INVALID_OPERATION, "%s(PBO is mapped)", where); - return NULL; - } - - ptr = _mesa_map_pbo_source(ctx, unpack, ptr); - return ptr; -} - - -/** - * Counterpart to _mesa_map_pbo_source() - */ -void -_mesa_unmap_pbo_source(struct gl_context *ctx, - const struct gl_pixelstore_attrib *unpack) -{ - ASSERT(unpack != &ctx->Pack); /* catch pack/unpack mismatch */ - if (_mesa_is_bufferobj(unpack->BufferObj)) { - ctx->Driver.UnmapBuffer(ctx, unpack->BufferObj); - } -} - - -/** - * For commands that write to a PBO (glReadPixels, glGetColorTable, etc), - * if we're writing to a PBO, map it write-only and return the pointer - * into the PBO. If we're not writing to a PBO, return \p dst as-is. - * If non-null return, must call _mesa_unmap_pbo_dest() when done. - * - * \return NULL if error, else pointer to start of data - */ -void * -_mesa_map_pbo_dest(struct gl_context *ctx, - const struct gl_pixelstore_attrib *pack, - GLvoid *dest) -{ - void *buf; - - if (_mesa_is_bufferobj(pack->BufferObj)) { - /* pack into PBO */ - buf = (GLubyte *) ctx->Driver.MapBufferRange(ctx, 0, - pack->BufferObj->Size, - GL_MAP_WRITE_BIT, - pack->BufferObj); - if (!buf) - return NULL; - - buf = ADD_POINTERS(buf, dest); - } - else { - /* pack to normal memory */ - buf = dest; - } - - return buf; -} - - -/** - * Combine PBO-write validation and mapping. - * If any GL errors are detected, they'll be recorded and NULL returned. - * \sa _mesa_validate_pbo_access - * \sa _mesa_map_pbo_dest - * A call to this function should have a matching call to - * _mesa_unmap_pbo_dest(). - */ -GLvoid * -_mesa_map_validate_pbo_dest(struct gl_context *ctx, - GLuint dimensions, - const struct gl_pixelstore_attrib *unpack, - GLsizei width, GLsizei height, GLsizei depth, - GLenum format, GLenum type, GLsizei clientMemSize, - GLvoid *ptr, const char *where) -{ - ASSERT(dimensions == 1 || dimensions == 2 || dimensions == 3); - - if (!_mesa_validate_pbo_access(dimensions, unpack, width, height, depth, - format, type, clientMemSize, ptr)) { - if (_mesa_is_bufferobj(unpack->BufferObj)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "%s(out of bounds PBO access)", where); - } else { - _mesa_error(ctx, GL_INVALID_OPERATION, - "%s(out of bounds access: bufSize (%d) is too small)", - where, clientMemSize); - } - return NULL; - } - - if (!_mesa_is_bufferobj(unpack->BufferObj)) { - /* non-PBO access: no further validation to be done */ - return ptr; - } - - if (_mesa_bufferobj_mapped(unpack->BufferObj)) { - /* buffer is already mapped - that's an error */ - _mesa_error(ctx, GL_INVALID_OPERATION, "%s(PBO is mapped)", where); - return NULL; - } - - ptr = _mesa_map_pbo_dest(ctx, unpack, ptr); - return ptr; -} - - -/** - * Counterpart to _mesa_map_pbo_dest() - */ -void -_mesa_unmap_pbo_dest(struct gl_context *ctx, - const struct gl_pixelstore_attrib *pack) -{ - ASSERT(pack != &ctx->Unpack); /* catch pack/unpack mismatch */ - if (_mesa_is_bufferobj(pack->BufferObj)) { - ctx->Driver.UnmapBuffer(ctx, pack->BufferObj); - } -} - - -/** - * Check if an unpack PBO is active prior to fetching a texture image. - * If so, do bounds checking and map the buffer into main memory. - * Any errors detected will be recorded. - * The caller _must_ call _mesa_unmap_teximage_pbo() too! - */ -const GLvoid * -_mesa_validate_pbo_teximage(struct gl_context *ctx, GLuint dimensions, - GLsizei width, GLsizei height, GLsizei depth, - GLenum format, GLenum type, const GLvoid *pixels, - const struct gl_pixelstore_attrib *unpack, - const char *funcName) -{ - GLubyte *buf; - - if (!_mesa_is_bufferobj(unpack->BufferObj)) { - /* no PBO */ - return pixels; - } - if (!_mesa_validate_pbo_access(dimensions, unpack, width, height, depth, - format, type, INT_MAX, pixels)) { - _mesa_error(ctx, GL_INVALID_OPERATION, funcName, "(invalid PBO access)"); - return NULL; - } - - buf = (GLubyte *) ctx->Driver.MapBufferRange(ctx, 0, unpack->BufferObj->Size, - GL_MAP_READ_BIT, - unpack->BufferObj); - if (!buf) { - _mesa_error(ctx, GL_INVALID_OPERATION, funcName, "(PBO is mapped)"); - return NULL; - } - - return ADD_POINTERS(buf, pixels); -} - - -/** - * Check if an unpack PBO is active prior to fetching a compressed texture - * image. - * If so, do bounds checking and map the buffer into main memory. - * Any errors detected will be recorded. - * The caller _must_ call _mesa_unmap_teximage_pbo() too! - */ -const GLvoid * -_mesa_validate_pbo_compressed_teximage(struct gl_context *ctx, - GLsizei imageSize, const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing, - const char *funcName) -{ - GLubyte *buf; - - if (!_mesa_is_bufferobj(packing->BufferObj)) { - /* not using a PBO - return pointer unchanged */ - return pixels; - } - if ((const GLubyte *) pixels + imageSize > - ((const GLubyte *) 0) + packing->BufferObj->Size) { - /* out of bounds read! */ - _mesa_error(ctx, GL_INVALID_OPERATION, funcName, "(invalid PBO access)"); - return NULL; - } - - buf = (GLubyte*) ctx->Driver.MapBufferRange(ctx, 0, - packing->BufferObj->Size, - GL_MAP_READ_BIT, - packing->BufferObj); - if (!buf) { - _mesa_error(ctx, GL_INVALID_OPERATION, funcName, "(PBO is mapped"); - return NULL; - } - - return ADD_POINTERS(buf, pixels); -} - - -/** - * This function must be called after either of the validate_pbo_*_teximage() - * functions. It unmaps the PBO buffer if it was mapped earlier. - */ -void -_mesa_unmap_teximage_pbo(struct gl_context *ctx, - const struct gl_pixelstore_attrib *unpack) -{ - if (_mesa_is_bufferobj(unpack->BufferObj)) { - ctx->Driver.UnmapBuffer(ctx, unpack->BufferObj); - } -} - - +/* + * Mesa 3-D graphics library + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (C) 2009-2011 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. + */ + + +/** + * \file pbo.c + * \brief Functions related to Pixel Buffer Objects. + */ + + + +#include "glheader.h" +#include "bufferobj.h" +#include "image.h" +#include "imports.h" +#include "mtypes.h" +#include "pbo.h" + + + +/** + * When we're about to read pixel data out of a PBO (via glDrawPixels, + * glTexImage, etc) or write data into a PBO (via glReadPixels, + * glGetTexImage, etc) we call this function to check that we're not + * going to read/write out of bounds. + * + * XXX This would also be a convenient time to check that the PBO isn't + * currently mapped. Whoever calls this function should check for that. + * Remember, we can't use a PBO when it's mapped! + * + * If we're not using a PBO, this is a no-op. + * + * \param width width of image to read/write + * \param height height of image to read/write + * \param depth depth of image to read/write + * \param format format of image to read/write + * \param type datatype of image to read/write + * \param clientMemSize the maximum number of bytes to read/write + * \param ptr the user-provided pointer/offset + * \return GL_TRUE if the buffer access is OK, GL_FALSE if the access would + * go out of bounds. + */ +GLboolean +_mesa_validate_pbo_access(GLuint dimensions, + const struct gl_pixelstore_attrib *pack, + GLsizei width, GLsizei height, GLsizei depth, + GLenum format, GLenum type, GLsizei clientMemSize, + const GLvoid *ptr) +{ + const GLvoid *start, *end, *offset; + const GLubyte *sizeAddr; /* buffer size, cast to a pointer */ + + /* If no PBO is bound, 'ptr' is a pointer to client memory containing + 'clientMemSize' bytes. + If a PBO is bound, 'ptr' is an offset into the bound PBO. + In that case 'clientMemSize' is ignored: we just use the PBO's size. + */ + if (!_mesa_is_bufferobj(pack->BufferObj)) { + offset = 0; + sizeAddr = ((const GLubyte *) 0) + clientMemSize; + } else { + offset = ptr; + sizeAddr = ((const GLubyte *) 0) + pack->BufferObj->Size; + } + + if (sizeAddr == 0) + /* no buffer! */ + return GL_FALSE; + + /* get the offset to the first pixel we'll read/write */ + start = _mesa_image_address(dimensions, pack, offset, width, height, + format, type, 0, 0, 0); + + /* get the offset to just past the last pixel we'll read/write */ + end = _mesa_image_address(dimensions, pack, offset, width, height, + format, type, depth-1, height-1, width); + + if ((const GLubyte *) start > sizeAddr) { + /* This will catch negative values / wrap-around */ + return GL_FALSE; + } + if ((const GLubyte *) end > sizeAddr) { + /* Image read/write goes beyond end of buffer */ + return GL_FALSE; + } + + /* OK! */ + return GL_TRUE; +} + + +/** + * For commands that read from a PBO (glDrawPixels, glTexImage, + * glPolygonStipple, etc), if we're reading from a PBO, map it read-only + * and return the pointer into the PBO. If we're not reading from a + * PBO, return \p src as-is. + * If non-null return, must call _mesa_unmap_pbo_source() when done. + * + * \return NULL if error, else pointer to start of data + */ +const GLvoid * +_mesa_map_pbo_source(struct gl_context *ctx, + const struct gl_pixelstore_attrib *unpack, + const GLvoid *src) +{ + const GLubyte *buf; + + if (_mesa_is_bufferobj(unpack->BufferObj)) { + /* unpack from PBO */ + buf = (GLubyte *) ctx->Driver.MapBufferRange(ctx, 0, + unpack->BufferObj->Size, + GL_MAP_READ_BIT, + unpack->BufferObj); + if (!buf) + return NULL; + + buf = ADD_POINTERS(buf, src); + } + else { + /* unpack from normal memory */ + buf = src; + } + + return buf; +} + + +/** + * Combine PBO-read validation and mapping. + * If any GL errors are detected, they'll be recorded and NULL returned. + * \sa _mesa_validate_pbo_access + * \sa _mesa_map_pbo_source + * A call to this function should have a matching call to + * _mesa_unmap_pbo_source(). + */ +const GLvoid * +_mesa_map_validate_pbo_source(struct gl_context *ctx, + GLuint dimensions, + const struct gl_pixelstore_attrib *unpack, + GLsizei width, GLsizei height, GLsizei depth, + GLenum format, GLenum type, GLsizei clientMemSize, + const GLvoid *ptr, const char *where) +{ + ASSERT(dimensions == 1 || dimensions == 2 || dimensions == 3); + + if (!_mesa_validate_pbo_access(dimensions, unpack, width, height, depth, + format, type, clientMemSize, ptr)) { + if (_mesa_is_bufferobj(unpack->BufferObj)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "%s(out of bounds PBO access)", where); + } else { + _mesa_error(ctx, GL_INVALID_OPERATION, + "%s(out of bounds access: bufSize (%d) is too small)", + where, clientMemSize); + } + return NULL; + } + + if (!_mesa_is_bufferobj(unpack->BufferObj)) { + /* non-PBO access: no further validation to be done */ + return ptr; + } + + if (_mesa_bufferobj_mapped(unpack->BufferObj)) { + /* buffer is already mapped - that's an error */ + _mesa_error(ctx, GL_INVALID_OPERATION, "%s(PBO is mapped)", where); + return NULL; + } + + ptr = _mesa_map_pbo_source(ctx, unpack, ptr); + return ptr; +} + + +/** + * Counterpart to _mesa_map_pbo_source() + */ +void +_mesa_unmap_pbo_source(struct gl_context *ctx, + const struct gl_pixelstore_attrib *unpack) +{ + ASSERT(unpack != &ctx->Pack); /* catch pack/unpack mismatch */ + if (_mesa_is_bufferobj(unpack->BufferObj)) { + ctx->Driver.UnmapBuffer(ctx, unpack->BufferObj); + } +} + + +/** + * For commands that write to a PBO (glReadPixels, glGetColorTable, etc), + * if we're writing to a PBO, map it write-only and return the pointer + * into the PBO. If we're not writing to a PBO, return \p dst as-is. + * If non-null return, must call _mesa_unmap_pbo_dest() when done. + * + * \return NULL if error, else pointer to start of data + */ +void * +_mesa_map_pbo_dest(struct gl_context *ctx, + const struct gl_pixelstore_attrib *pack, + GLvoid *dest) +{ + void *buf; + + if (_mesa_is_bufferobj(pack->BufferObj)) { + /* pack into PBO */ + buf = (GLubyte *) ctx->Driver.MapBufferRange(ctx, 0, + pack->BufferObj->Size, + GL_MAP_WRITE_BIT, + pack->BufferObj); + if (!buf) + return NULL; + + buf = ADD_POINTERS(buf, dest); + } + else { + /* pack to normal memory */ + buf = dest; + } + + return buf; +} + + +/** + * Combine PBO-write validation and mapping. + * If any GL errors are detected, they'll be recorded and NULL returned. + * \sa _mesa_validate_pbo_access + * \sa _mesa_map_pbo_dest + * A call to this function should have a matching call to + * _mesa_unmap_pbo_dest(). + */ +GLvoid * +_mesa_map_validate_pbo_dest(struct gl_context *ctx, + GLuint dimensions, + const struct gl_pixelstore_attrib *unpack, + GLsizei width, GLsizei height, GLsizei depth, + GLenum format, GLenum type, GLsizei clientMemSize, + GLvoid *ptr, const char *where) +{ + ASSERT(dimensions == 1 || dimensions == 2 || dimensions == 3); + + if (!_mesa_validate_pbo_access(dimensions, unpack, width, height, depth, + format, type, clientMemSize, ptr)) { + if (_mesa_is_bufferobj(unpack->BufferObj)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "%s(out of bounds PBO access)", where); + } else { + _mesa_error(ctx, GL_INVALID_OPERATION, + "%s(out of bounds access: bufSize (%d) is too small)", + where, clientMemSize); + } + return NULL; + } + + if (!_mesa_is_bufferobj(unpack->BufferObj)) { + /* non-PBO access: no further validation to be done */ + return ptr; + } + + if (_mesa_bufferobj_mapped(unpack->BufferObj)) { + /* buffer is already mapped - that's an error */ + _mesa_error(ctx, GL_INVALID_OPERATION, "%s(PBO is mapped)", where); + return NULL; + } + + ptr = _mesa_map_pbo_dest(ctx, unpack, ptr); + return ptr; +} + + +/** + * Counterpart to _mesa_map_pbo_dest() + */ +void +_mesa_unmap_pbo_dest(struct gl_context *ctx, + const struct gl_pixelstore_attrib *pack) +{ + ASSERT(pack != &ctx->Unpack); /* catch pack/unpack mismatch */ + if (_mesa_is_bufferobj(pack->BufferObj)) { + ctx->Driver.UnmapBuffer(ctx, pack->BufferObj); + } +} + + +/** + * Check if an unpack PBO is active prior to fetching a texture image. + * If so, do bounds checking and map the buffer into main memory. + * Any errors detected will be recorded. + * The caller _must_ call _mesa_unmap_teximage_pbo() too! + */ +const GLvoid * +_mesa_validate_pbo_teximage(struct gl_context *ctx, GLuint dimensions, + GLsizei width, GLsizei height, GLsizei depth, + GLenum format, GLenum type, const GLvoid *pixels, + const struct gl_pixelstore_attrib *unpack, + const char *funcName) +{ + GLubyte *buf; + + if (!_mesa_is_bufferobj(unpack->BufferObj)) { + /* no PBO */ + return pixels; + } + if (!_mesa_validate_pbo_access(dimensions, unpack, width, height, depth, + format, type, INT_MAX, pixels)) { + _mesa_error(ctx, GL_INVALID_OPERATION, funcName, "(invalid PBO access)"); + return NULL; + } + + buf = (GLubyte *) ctx->Driver.MapBufferRange(ctx, 0, unpack->BufferObj->Size, + GL_MAP_READ_BIT, + unpack->BufferObj); + if (!buf) { + _mesa_error(ctx, GL_INVALID_OPERATION, funcName, "(PBO is mapped)"); + return NULL; + } + + return ADD_POINTERS(buf, pixels); +} + + +/** + * Check if an unpack PBO is active prior to fetching a compressed texture + * image. + * If so, do bounds checking and map the buffer into main memory. + * Any errors detected will be recorded. + * The caller _must_ call _mesa_unmap_teximage_pbo() too! + */ +const GLvoid * +_mesa_validate_pbo_compressed_teximage(struct gl_context *ctx, + GLsizei imageSize, const GLvoid *pixels, + const struct gl_pixelstore_attrib *packing, + const char *funcName) +{ + GLubyte *buf; + + if (!_mesa_is_bufferobj(packing->BufferObj)) { + /* not using a PBO - return pointer unchanged */ + return pixels; + } + if ((const GLubyte *) pixels + imageSize > + ((const GLubyte *) 0) + packing->BufferObj->Size) { + /* out of bounds read! */ + _mesa_error(ctx, GL_INVALID_OPERATION, funcName, "(invalid PBO access)"); + return NULL; + } + + buf = (GLubyte*) ctx->Driver.MapBufferRange(ctx, 0, + packing->BufferObj->Size, + GL_MAP_READ_BIT, + packing->BufferObj); + if (!buf) { + _mesa_error(ctx, GL_INVALID_OPERATION, funcName, "(PBO is mapped"); + return NULL; + } + + return ADD_POINTERS(buf, pixels); +} + + +/** + * This function must be called after either of the validate_pbo_*_teximage() + * functions. It unmaps the PBO buffer if it was mapped earlier. + */ +void +_mesa_unmap_teximage_pbo(struct gl_context *ctx, + const struct gl_pixelstore_attrib *unpack) +{ + if (_mesa_is_bufferobj(unpack->BufferObj)) { + ctx->Driver.UnmapBuffer(ctx, unpack->BufferObj); + } +} + + diff --git a/mesalib/src/mesa/main/pbo.h b/mesalib/src/mesa/main/pbo.h index 605a9a8b5..00a6e617f 100644 --- a/mesalib/src/mesa/main/pbo.h +++ b/mesalib/src/mesa/main/pbo.h @@ -1,93 +1,93 @@ -/* - * Mesa 3-D graphics library - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (C) 2009-2011 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. - */ - - -#ifndef PBO_H -#define PBO_H - - -#include "mtypes.h" - - -extern GLboolean -_mesa_validate_pbo_access(GLuint dimensions, - const struct gl_pixelstore_attrib *pack, - GLsizei width, GLsizei height, GLsizei depth, - GLenum format, GLenum type, GLsizei clientMemSize, - const GLvoid *ptr); - -extern const GLvoid * -_mesa_map_pbo_source(struct gl_context *ctx, - const struct gl_pixelstore_attrib *unpack, - const GLvoid *src); - -extern const GLvoid * -_mesa_map_validate_pbo_source(struct gl_context *ctx, - GLuint dimensions, - const struct gl_pixelstore_attrib *unpack, - GLsizei width, GLsizei height, GLsizei depth, - GLenum format, GLenum type, GLsizei clientMemSize, - const GLvoid *ptr, const char *where); - -extern void -_mesa_unmap_pbo_source(struct gl_context *ctx, - const struct gl_pixelstore_attrib *unpack); - -extern void * -_mesa_map_pbo_dest(struct gl_context *ctx, - const struct gl_pixelstore_attrib *pack, - GLvoid *dest); - -extern GLvoid * -_mesa_map_validate_pbo_dest(struct gl_context *ctx, - GLuint dimensions, - const struct gl_pixelstore_attrib *unpack, - GLsizei width, GLsizei height, GLsizei depth, - GLenum format, GLenum type, GLsizei clientMemSize, - GLvoid *ptr, const char *where); - -extern void -_mesa_unmap_pbo_dest(struct gl_context *ctx, - const struct gl_pixelstore_attrib *pack); - - -extern const GLvoid * -_mesa_validate_pbo_teximage(struct gl_context *ctx, GLuint dimensions, - GLsizei width, GLsizei height, GLsizei depth, - GLenum format, GLenum type, const GLvoid *pixels, - const struct gl_pixelstore_attrib *unpack, - const char *funcName); - -extern const GLvoid * -_mesa_validate_pbo_compressed_teximage(struct gl_context *ctx, - GLsizei imageSize, const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing, - const char *funcName); - -extern void -_mesa_unmap_teximage_pbo(struct gl_context *ctx, - const struct gl_pixelstore_attrib *unpack); - - -#endif +/* + * Mesa 3-D graphics library + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (C) 2009-2011 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. + */ + + +#ifndef PBO_H +#define PBO_H + + +#include "mtypes.h" + + +extern GLboolean +_mesa_validate_pbo_access(GLuint dimensions, + const struct gl_pixelstore_attrib *pack, + GLsizei width, GLsizei height, GLsizei depth, + GLenum format, GLenum type, GLsizei clientMemSize, + const GLvoid *ptr); + +extern const GLvoid * +_mesa_map_pbo_source(struct gl_context *ctx, + const struct gl_pixelstore_attrib *unpack, + const GLvoid *src); + +extern const GLvoid * +_mesa_map_validate_pbo_source(struct gl_context *ctx, + GLuint dimensions, + const struct gl_pixelstore_attrib *unpack, + GLsizei width, GLsizei height, GLsizei depth, + GLenum format, GLenum type, GLsizei clientMemSize, + const GLvoid *ptr, const char *where); + +extern void +_mesa_unmap_pbo_source(struct gl_context *ctx, + const struct gl_pixelstore_attrib *unpack); + +extern void * +_mesa_map_pbo_dest(struct gl_context *ctx, + const struct gl_pixelstore_attrib *pack, + GLvoid *dest); + +extern GLvoid * +_mesa_map_validate_pbo_dest(struct gl_context *ctx, + GLuint dimensions, + const struct gl_pixelstore_attrib *unpack, + GLsizei width, GLsizei height, GLsizei depth, + GLenum format, GLenum type, GLsizei clientMemSize, + GLvoid *ptr, const char *where); + +extern void +_mesa_unmap_pbo_dest(struct gl_context *ctx, + const struct gl_pixelstore_attrib *pack); + + +extern const GLvoid * +_mesa_validate_pbo_teximage(struct gl_context *ctx, GLuint dimensions, + GLsizei width, GLsizei height, GLsizei depth, + GLenum format, GLenum type, const GLvoid *pixels, + const struct gl_pixelstore_attrib *unpack, + const char *funcName); + +extern const GLvoid * +_mesa_validate_pbo_compressed_teximage(struct gl_context *ctx, + GLsizei imageSize, const GLvoid *pixels, + const struct gl_pixelstore_attrib *packing, + const char *funcName); + +extern void +_mesa_unmap_teximage_pbo(struct gl_context *ctx, + const struct gl_pixelstore_attrib *unpack); + + +#endif diff --git a/mesalib/src/mesa/main/pixel.c b/mesalib/src/mesa/main/pixel.c index 26fb71508..775746270 100644 --- a/mesalib/src/mesa/main/pixel.c +++ b/mesalib/src/mesa/main/pixel.c @@ -1,731 +1,731 @@ -/* - * 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 pixel.c - * Pixel transfer functions (glPixelZoom, glPixelMap, glPixelTransfer) - */ - -#include "glheader.h" -#include "bufferobj.h" -#include "colormac.h" -#include "context.h" -#include "macros.h" -#include "mfeatures.h" -#include "pixel.h" -#include "pbo.h" -#include "mtypes.h" -#include "main/dispatch.h" - - -#if FEATURE_pixel_transfer - - -/**********************************************************************/ -/***** glPixelZoom *****/ -/**********************************************************************/ - -static void GLAPIENTRY -_mesa_PixelZoom( GLfloat xfactor, GLfloat yfactor ) -{ - GET_CURRENT_CONTEXT(ctx); - - if (ctx->Pixel.ZoomX == xfactor && - ctx->Pixel.ZoomY == yfactor) - return; - - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.ZoomX = xfactor; - ctx->Pixel.ZoomY = yfactor; -} - - - -/**********************************************************************/ -/***** glPixelMap *****/ -/**********************************************************************/ - -/** - * Return pointer to a pixelmap by name. - */ -static struct gl_pixelmap * -get_pixelmap(struct gl_context *ctx, GLenum map) -{ - switch (map) { - case GL_PIXEL_MAP_I_TO_I: - return &ctx->PixelMaps.ItoI; - case GL_PIXEL_MAP_S_TO_S: - return &ctx->PixelMaps.StoS; - case GL_PIXEL_MAP_I_TO_R: - return &ctx->PixelMaps.ItoR; - case GL_PIXEL_MAP_I_TO_G: - return &ctx->PixelMaps.ItoG; - case GL_PIXEL_MAP_I_TO_B: - return &ctx->PixelMaps.ItoB; - case GL_PIXEL_MAP_I_TO_A: - return &ctx->PixelMaps.ItoA; - case GL_PIXEL_MAP_R_TO_R: - return &ctx->PixelMaps.RtoR; - case GL_PIXEL_MAP_G_TO_G: - return &ctx->PixelMaps.GtoG; - case GL_PIXEL_MAP_B_TO_B: - return &ctx->PixelMaps.BtoB; - case GL_PIXEL_MAP_A_TO_A: - return &ctx->PixelMaps.AtoA; - default: - return NULL; - } -} - - -/** - * Helper routine used by the other _mesa_PixelMap() functions. - */ -static void -store_pixelmap(struct gl_context *ctx, GLenum map, GLsizei mapsize, - const GLfloat *values) -{ - GLint i; - struct gl_pixelmap *pm = get_pixelmap(ctx, map); - if (!pm) { - _mesa_error(ctx, GL_INVALID_ENUM, "glPixelMap(map)"); - return; - } - - switch (map) { - case GL_PIXEL_MAP_S_TO_S: - /* special case */ - ctx->PixelMaps.StoS.Size = mapsize; - for (i = 0; i < mapsize; i++) { - ctx->PixelMaps.StoS.Map[i] = (GLfloat)IROUND(values[i]); - } - break; - case GL_PIXEL_MAP_I_TO_I: - /* special case */ - ctx->PixelMaps.ItoI.Size = mapsize; - for (i = 0; i < mapsize; i++) { - ctx->PixelMaps.ItoI.Map[i] = values[i]; - } - break; - default: - /* general case */ - pm->Size = mapsize; - for (i = 0; i < mapsize; i++) { - GLfloat val = CLAMP(values[i], 0.0F, 1.0F); - pm->Map[i] = val; - pm->Map8[i] = (GLint) (val * 255.0F); - } - } -} - - -/** - * Convenience wrapper for _mesa_validate_pbo_access() for gl[Get]PixelMap(). - */ -static GLboolean -validate_pbo_access(struct gl_context *ctx, - struct gl_pixelstore_attrib *pack, GLsizei mapsize, - GLenum format, GLenum type, GLsizei clientMemSize, - const GLvoid *ptr) -{ - GLboolean ok; - - /* Note, need to use DefaultPacking and Unpack's buffer object */ - _mesa_reference_buffer_object(ctx, - &ctx->DefaultPacking.BufferObj, - pack->BufferObj); - - ok = _mesa_validate_pbo_access(1, &ctx->DefaultPacking, mapsize, 1, 1, - format, type, clientMemSize, ptr); - - /* restore */ - _mesa_reference_buffer_object(ctx, - &ctx->DefaultPacking.BufferObj, - ctx->Shared->NullBufferObj); - - if (!ok) { - if (_mesa_is_bufferobj(pack->BufferObj)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "gl[Get]PixelMap*v(out of bounds PBO access)"); - } else { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetnPixelMap*vARB(out of bounds access:" - " bufSize (%d) is too small)", clientMemSize); - } - } - return ok; -} - - -static void GLAPIENTRY -_mesa_PixelMapfv( GLenum map, GLsizei mapsize, const GLfloat *values ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - /* XXX someday, test against ctx->Const.MaxPixelMapTableSize */ - if (mapsize < 1 || mapsize > MAX_PIXEL_MAP_TABLE) { - _mesa_error( ctx, GL_INVALID_VALUE, "glPixelMapfv(mapsize)" ); - return; - } - - if (map >= GL_PIXEL_MAP_S_TO_S && map <= GL_PIXEL_MAP_I_TO_A) { - /* test that mapsize is a power of two */ - if (!_mesa_is_pow_two(mapsize)) { - _mesa_error( ctx, GL_INVALID_VALUE, "glPixelMapfv(mapsize)" ); - return; - } - } - - FLUSH_VERTICES(ctx, _NEW_PIXEL); - - if (!validate_pbo_access(ctx, &ctx->Unpack, mapsize, GL_INTENSITY, - GL_FLOAT, INT_MAX, values)) { - return; - } - - values = (const GLfloat *) _mesa_map_pbo_source(ctx, &ctx->Unpack, values); - if (!values) { - if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glPixelMapfv(PBO is mapped)"); - } - return; - } - - store_pixelmap(ctx, map, mapsize, values); - - _mesa_unmap_pbo_source(ctx, &ctx->Unpack); -} - - -static void GLAPIENTRY -_mesa_PixelMapuiv(GLenum map, GLsizei mapsize, const GLuint *values ) -{ - GLfloat fvalues[MAX_PIXEL_MAP_TABLE]; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (mapsize < 1 || mapsize > MAX_PIXEL_MAP_TABLE) { - _mesa_error( ctx, GL_INVALID_VALUE, "glPixelMapuiv(mapsize)" ); - return; - } - - if (map >= GL_PIXEL_MAP_S_TO_S && map <= GL_PIXEL_MAP_I_TO_A) { - /* test that mapsize is a power of two */ - if (!_mesa_is_pow_two(mapsize)) { - _mesa_error( ctx, GL_INVALID_VALUE, "glPixelMapuiv(mapsize)" ); - return; - } - } - - FLUSH_VERTICES(ctx, _NEW_PIXEL); - - if (!validate_pbo_access(ctx, &ctx->Unpack, mapsize, GL_INTENSITY, - GL_UNSIGNED_INT, INT_MAX, values)) { - return; - } - - values = (const GLuint *) _mesa_map_pbo_source(ctx, &ctx->Unpack, values); - if (!values) { - if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glPixelMapuiv(PBO is mapped)"); - } - return; - } - - /* convert to floats */ - if (map == GL_PIXEL_MAP_I_TO_I || map == GL_PIXEL_MAP_S_TO_S) { - GLint i; - for (i = 0; i < mapsize; i++) { - fvalues[i] = (GLfloat) values[i]; - } - } - else { - GLint i; - for (i = 0; i < mapsize; i++) { - fvalues[i] = UINT_TO_FLOAT( values[i] ); - } - } - - _mesa_unmap_pbo_source(ctx, &ctx->Unpack); - - store_pixelmap(ctx, map, mapsize, fvalues); -} - - -static void GLAPIENTRY -_mesa_PixelMapusv(GLenum map, GLsizei mapsize, const GLushort *values ) -{ - GLfloat fvalues[MAX_PIXEL_MAP_TABLE]; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (mapsize < 1 || mapsize > MAX_PIXEL_MAP_TABLE) { - _mesa_error( ctx, GL_INVALID_VALUE, "glPixelMapusv(mapsize)" ); - return; - } - - if (map >= GL_PIXEL_MAP_S_TO_S && map <= GL_PIXEL_MAP_I_TO_A) { - /* test that mapsize is a power of two */ - if (!_mesa_is_pow_two(mapsize)) { - _mesa_error( ctx, GL_INVALID_VALUE, "glPixelMapuiv(mapsize)" ); - return; - } - } - - FLUSH_VERTICES(ctx, _NEW_PIXEL); - - if (!validate_pbo_access(ctx, &ctx->Unpack, mapsize, GL_INTENSITY, - GL_UNSIGNED_SHORT, INT_MAX, values)) { - return; - } - - values = (const GLushort *) _mesa_map_pbo_source(ctx, &ctx->Unpack, values); - if (!values) { - if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glPixelMapusv(PBO is mapped)"); - } - return; - } - - /* convert to floats */ - if (map == GL_PIXEL_MAP_I_TO_I || map == GL_PIXEL_MAP_S_TO_S) { - GLint i; - for (i = 0; i < mapsize; i++) { - fvalues[i] = (GLfloat) values[i]; - } - } - else { - GLint i; - for (i = 0; i < mapsize; i++) { - fvalues[i] = USHORT_TO_FLOAT( values[i] ); - } - } - - _mesa_unmap_pbo_source(ctx, &ctx->Unpack); - - store_pixelmap(ctx, map, mapsize, fvalues); -} - - -static void GLAPIENTRY -_mesa_GetnPixelMapfvARB( GLenum map, GLsizei bufSize, GLfloat *values ) -{ - GET_CURRENT_CONTEXT(ctx); - GLint mapsize, i; - const struct gl_pixelmap *pm; - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - pm = get_pixelmap(ctx, map); - if (!pm) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetPixelMapfv(map)"); - return; - } - - mapsize = pm->Size; - - if (!validate_pbo_access(ctx, &ctx->Pack, mapsize, GL_INTENSITY, - GL_FLOAT, bufSize, values)) { - return; - } - - values = (GLfloat *) _mesa_map_pbo_dest(ctx, &ctx->Pack, values); - if (!values) { - if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetPixelMapfv(PBO is mapped)"); - } - return; - } - - if (map == GL_PIXEL_MAP_S_TO_S) { - /* special case */ - for (i = 0; i < mapsize; i++) { - values[i] = (GLfloat) ctx->PixelMaps.StoS.Map[i]; - } - } - else { - memcpy(values, pm->Map, mapsize * sizeof(GLfloat)); - } - - _mesa_unmap_pbo_dest(ctx, &ctx->Pack); -} - - -static void GLAPIENTRY -_mesa_GetPixelMapfv( GLenum map, GLfloat *values ) -{ - _mesa_GetnPixelMapfvARB(map, INT_MAX, values); -} - -static void GLAPIENTRY -_mesa_GetnPixelMapuivARB( GLenum map, GLsizei bufSize, GLuint *values ) -{ - GET_CURRENT_CONTEXT(ctx); - GLint mapsize, i; - const struct gl_pixelmap *pm; - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - pm = get_pixelmap(ctx, map); - if (!pm) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetPixelMapuiv(map)"); - return; - } - - mapsize = pm->Size; - - if (!validate_pbo_access(ctx, &ctx->Pack, mapsize, GL_INTENSITY, - GL_UNSIGNED_INT, bufSize, values)) { - return; - } - - values = (GLuint *) _mesa_map_pbo_dest(ctx, &ctx->Pack, values); - if (!values) { - if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetPixelMapuiv(PBO is mapped)"); - } - return; - } - - if (map == GL_PIXEL_MAP_S_TO_S) { - /* special case */ - memcpy(values, ctx->PixelMaps.StoS.Map, mapsize * sizeof(GLint)); - } - else { - for (i = 0; i < mapsize; i++) { - values[i] = FLOAT_TO_UINT( pm->Map[i] ); - } - } - - _mesa_unmap_pbo_dest(ctx, &ctx->Pack); -} - - -static void GLAPIENTRY -_mesa_GetPixelMapuiv( GLenum map, GLuint *values ) -{ - _mesa_GetnPixelMapuivARB(map, INT_MAX, values); -} - -static void GLAPIENTRY -_mesa_GetnPixelMapusvARB( GLenum map, GLsizei bufSize, GLushort *values ) -{ - GET_CURRENT_CONTEXT(ctx); - GLint mapsize, i; - const struct gl_pixelmap *pm; - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - pm = get_pixelmap(ctx, map); - if (!pm) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetPixelMapusv(map)"); - return; - } - - mapsize = pm->Size; - - if (!validate_pbo_access(ctx, &ctx->Pack, mapsize, GL_INTENSITY, - GL_UNSIGNED_SHORT, bufSize, values)) { - return; - } - - values = (GLushort *) _mesa_map_pbo_dest(ctx, &ctx->Pack, values); - if (!values) { - if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetPixelMapusv(PBO is mapped)"); - } - return; - } - - switch (map) { - /* special cases */ - case GL_PIXEL_MAP_I_TO_I: - for (i = 0; i < mapsize; i++) { - values[i] = (GLushort) CLAMP(ctx->PixelMaps.ItoI.Map[i], 0.0, 65535.); - } - break; - case GL_PIXEL_MAP_S_TO_S: - for (i = 0; i < mapsize; i++) { - values[i] = (GLushort) CLAMP(ctx->PixelMaps.StoS.Map[i], 0.0, 65535.); - } - break; - default: - for (i = 0; i < mapsize; i++) { - CLAMPED_FLOAT_TO_USHORT(values[i], pm->Map[i] ); - } - } - - _mesa_unmap_pbo_dest(ctx, &ctx->Pack); -} - - -static void GLAPIENTRY -_mesa_GetPixelMapusv( GLenum map, GLushort *values ) -{ - _mesa_GetnPixelMapusvARB(map, INT_MAX, values); -} - - -/**********************************************************************/ -/***** glPixelTransfer *****/ -/**********************************************************************/ - - -/* - * Implements glPixelTransfer[fi] whether called immediately or from a - * display list. - */ -static void GLAPIENTRY -_mesa_PixelTransferf( GLenum pname, GLfloat param ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - switch (pname) { - case GL_MAP_COLOR: - if (ctx->Pixel.MapColorFlag == (param ? GL_TRUE : GL_FALSE)) - return; - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.MapColorFlag = param ? GL_TRUE : GL_FALSE; - break; - case GL_MAP_STENCIL: - if (ctx->Pixel.MapStencilFlag == (param ? GL_TRUE : GL_FALSE)) - return; - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.MapStencilFlag = param ? GL_TRUE : GL_FALSE; - break; - case GL_INDEX_SHIFT: - if (ctx->Pixel.IndexShift == (GLint) param) - return; - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.IndexShift = (GLint) param; - break; - case GL_INDEX_OFFSET: - if (ctx->Pixel.IndexOffset == (GLint) param) - return; - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.IndexOffset = (GLint) param; - break; - case GL_RED_SCALE: - if (ctx->Pixel.RedScale == param) - return; - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.RedScale = param; - break; - case GL_RED_BIAS: - if (ctx->Pixel.RedBias == param) - return; - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.RedBias = param; - break; - case GL_GREEN_SCALE: - if (ctx->Pixel.GreenScale == param) - return; - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.GreenScale = param; - break; - case GL_GREEN_BIAS: - if (ctx->Pixel.GreenBias == param) - return; - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.GreenBias = param; - break; - case GL_BLUE_SCALE: - if (ctx->Pixel.BlueScale == param) - return; - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.BlueScale = param; - break; - case GL_BLUE_BIAS: - if (ctx->Pixel.BlueBias == param) - return; - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.BlueBias = param; - break; - case GL_ALPHA_SCALE: - if (ctx->Pixel.AlphaScale == param) - return; - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.AlphaScale = param; - break; - case GL_ALPHA_BIAS: - if (ctx->Pixel.AlphaBias == param) - return; - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.AlphaBias = param; - break; - case GL_DEPTH_SCALE: - if (ctx->Pixel.DepthScale == param) - return; - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.DepthScale = param; - break; - case GL_DEPTH_BIAS: - if (ctx->Pixel.DepthBias == param) - return; - FLUSH_VERTICES(ctx, _NEW_PIXEL); - ctx->Pixel.DepthBias = param; - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glPixelTransfer(pname)" ); - return; - } -} - - -static void GLAPIENTRY -_mesa_PixelTransferi( GLenum pname, GLint param ) -{ - _mesa_PixelTransferf( pname, (GLfloat) param ); -} - - - -/**********************************************************************/ -/***** State Management *****/ -/**********************************************************************/ - -/* - * Return a bitmask of IMAGE_*_BIT flags which to indicate which - * pixel transfer operations are enabled. - */ -static void -update_image_transfer_state(struct gl_context *ctx) -{ - GLuint mask = 0; - - if (ctx->Pixel.RedScale != 1.0F || ctx->Pixel.RedBias != 0.0F || - ctx->Pixel.GreenScale != 1.0F || ctx->Pixel.GreenBias != 0.0F || - ctx->Pixel.BlueScale != 1.0F || ctx->Pixel.BlueBias != 0.0F || - ctx->Pixel.AlphaScale != 1.0F || ctx->Pixel.AlphaBias != 0.0F) - mask |= IMAGE_SCALE_BIAS_BIT; - - if (ctx->Pixel.IndexShift || ctx->Pixel.IndexOffset) - mask |= IMAGE_SHIFT_OFFSET_BIT; - - if (ctx->Pixel.MapColorFlag) - mask |= IMAGE_MAP_COLOR_BIT; - - ctx->_ImageTransferState = mask; -} - - -/** - * Update mesa pixel transfer derived state. - */ -void _mesa_update_pixel( struct gl_context *ctx, GLuint new_state ) -{ - if (new_state & _NEW_PIXEL) - update_image_transfer_state(ctx); -} - - -void -_mesa_init_pixel_dispatch(struct _glapi_table *disp) -{ - SET_GetPixelMapfv(disp, _mesa_GetPixelMapfv); - SET_GetPixelMapuiv(disp, _mesa_GetPixelMapuiv); - SET_GetPixelMapusv(disp, _mesa_GetPixelMapusv); - SET_PixelMapfv(disp, _mesa_PixelMapfv); - SET_PixelMapuiv(disp, _mesa_PixelMapuiv); - SET_PixelMapusv(disp, _mesa_PixelMapusv); - SET_PixelTransferf(disp, _mesa_PixelTransferf); - SET_PixelTransferi(disp, _mesa_PixelTransferi); - SET_PixelZoom(disp, _mesa_PixelZoom); - - /* GL_ARB_robustness */ - SET_GetnPixelMapfvARB(disp, _mesa_GetnPixelMapfvARB); - SET_GetnPixelMapuivARB(disp, _mesa_GetnPixelMapuivARB); - SET_GetnPixelMapusvARB(disp, _mesa_GetnPixelMapusvARB); -} - - -#endif /* FEATURE_pixel_transfer */ - - -/**********************************************************************/ -/***** Initialization *****/ -/**********************************************************************/ - -static void -init_pixelmap(struct gl_pixelmap *map) -{ - map->Size = 1; - map->Map[0] = 0.0; - map->Map8[0] = 0; -} - - -/** - * Initialize the context's PIXEL attribute group. - */ -void -_mesa_init_pixel( struct gl_context *ctx ) -{ - /* Pixel group */ - ctx->Pixel.RedBias = 0.0; - ctx->Pixel.RedScale = 1.0; - ctx->Pixel.GreenBias = 0.0; - ctx->Pixel.GreenScale = 1.0; - ctx->Pixel.BlueBias = 0.0; - ctx->Pixel.BlueScale = 1.0; - ctx->Pixel.AlphaBias = 0.0; - ctx->Pixel.AlphaScale = 1.0; - ctx->Pixel.DepthBias = 0.0; - ctx->Pixel.DepthScale = 1.0; - ctx->Pixel.IndexOffset = 0; - ctx->Pixel.IndexShift = 0; - ctx->Pixel.ZoomX = 1.0; - ctx->Pixel.ZoomY = 1.0; - ctx->Pixel.MapColorFlag = GL_FALSE; - ctx->Pixel.MapStencilFlag = GL_FALSE; - init_pixelmap(&ctx->PixelMaps.StoS); - init_pixelmap(&ctx->PixelMaps.ItoI); - init_pixelmap(&ctx->PixelMaps.ItoR); - init_pixelmap(&ctx->PixelMaps.ItoG); - init_pixelmap(&ctx->PixelMaps.ItoB); - init_pixelmap(&ctx->PixelMaps.ItoA); - init_pixelmap(&ctx->PixelMaps.RtoR); - init_pixelmap(&ctx->PixelMaps.GtoG); - init_pixelmap(&ctx->PixelMaps.BtoB); - init_pixelmap(&ctx->PixelMaps.AtoA); - - if (ctx->Visual.doubleBufferMode) { - ctx->Pixel.ReadBuffer = GL_BACK; - } - else { - ctx->Pixel.ReadBuffer = GL_FRONT; - } - - /* Miscellaneous */ - ctx->_ImageTransferState = 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 pixel.c + * Pixel transfer functions (glPixelZoom, glPixelMap, glPixelTransfer) + */ + +#include "glheader.h" +#include "bufferobj.h" +#include "colormac.h" +#include "context.h" +#include "macros.h" +#include "mfeatures.h" +#include "pixel.h" +#include "pbo.h" +#include "mtypes.h" +#include "main/dispatch.h" + + +#if FEATURE_pixel_transfer + + +/**********************************************************************/ +/***** glPixelZoom *****/ +/**********************************************************************/ + +static void GLAPIENTRY +_mesa_PixelZoom( GLfloat xfactor, GLfloat yfactor ) +{ + GET_CURRENT_CONTEXT(ctx); + + if (ctx->Pixel.ZoomX == xfactor && + ctx->Pixel.ZoomY == yfactor) + return; + + FLUSH_VERTICES(ctx, _NEW_PIXEL); + ctx->Pixel.ZoomX = xfactor; + ctx->Pixel.ZoomY = yfactor; +} + + + +/**********************************************************************/ +/***** glPixelMap *****/ +/**********************************************************************/ + +/** + * Return pointer to a pixelmap by name. + */ +static struct gl_pixelmap * +get_pixelmap(struct gl_context *ctx, GLenum map) +{ + switch (map) { + case GL_PIXEL_MAP_I_TO_I: + return &ctx->PixelMaps.ItoI; + case GL_PIXEL_MAP_S_TO_S: + return &ctx->PixelMaps.StoS; + case GL_PIXEL_MAP_I_TO_R: + return &ctx->PixelMaps.ItoR; + case GL_PIXEL_MAP_I_TO_G: + return &ctx->PixelMaps.ItoG; + case GL_PIXEL_MAP_I_TO_B: + return &ctx->PixelMaps.ItoB; + case GL_PIXEL_MAP_I_TO_A: + return &ctx->PixelMaps.ItoA; + case GL_PIXEL_MAP_R_TO_R: + return &ctx->PixelMaps.RtoR; + case GL_PIXEL_MAP_G_TO_G: + return &ctx->PixelMaps.GtoG; + case GL_PIXEL_MAP_B_TO_B: + return &ctx->PixelMaps.BtoB; + case GL_PIXEL_MAP_A_TO_A: + return &ctx->PixelMaps.AtoA; + default: + return NULL; + } +} + + +/** + * Helper routine used by the other _mesa_PixelMap() functions. + */ +static void +store_pixelmap(struct gl_context *ctx, GLenum map, GLsizei mapsize, + const GLfloat *values) +{ + GLint i; + struct gl_pixelmap *pm = get_pixelmap(ctx, map); + if (!pm) { + _mesa_error(ctx, GL_INVALID_ENUM, "glPixelMap(map)"); + return; + } + + switch (map) { + case GL_PIXEL_MAP_S_TO_S: + /* special case */ + ctx->PixelMaps.StoS.Size = mapsize; + for (i = 0; i < mapsize; i++) { + ctx->PixelMaps.StoS.Map[i] = (GLfloat)IROUND(values[i]); + } + break; + case GL_PIXEL_MAP_I_TO_I: + /* special case */ + ctx->PixelMaps.ItoI.Size = mapsize; + for (i = 0; i < mapsize; i++) { + ctx->PixelMaps.ItoI.Map[i] = values[i]; + } + break; + default: + /* general case */ + pm->Size = mapsize; + for (i = 0; i < mapsize; i++) { + GLfloat val = CLAMP(values[i], 0.0F, 1.0F); + pm->Map[i] = val; + pm->Map8[i] = (GLint) (val * 255.0F); + } + } +} + + +/** + * Convenience wrapper for _mesa_validate_pbo_access() for gl[Get]PixelMap(). + */ +static GLboolean +validate_pbo_access(struct gl_context *ctx, + struct gl_pixelstore_attrib *pack, GLsizei mapsize, + GLenum format, GLenum type, GLsizei clientMemSize, + const GLvoid *ptr) +{ + GLboolean ok; + + /* Note, need to use DefaultPacking and Unpack's buffer object */ + _mesa_reference_buffer_object(ctx, + &ctx->DefaultPacking.BufferObj, + pack->BufferObj); + + ok = _mesa_validate_pbo_access(1, &ctx->DefaultPacking, mapsize, 1, 1, + format, type, clientMemSize, ptr); + + /* restore */ + _mesa_reference_buffer_object(ctx, + &ctx->DefaultPacking.BufferObj, + ctx->Shared->NullBufferObj); + + if (!ok) { + if (_mesa_is_bufferobj(pack->BufferObj)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "gl[Get]PixelMap*v(out of bounds PBO access)"); + } else { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glGetnPixelMap*vARB(out of bounds access:" + " bufSize (%d) is too small)", clientMemSize); + } + } + return ok; +} + + +static void GLAPIENTRY +_mesa_PixelMapfv( GLenum map, GLsizei mapsize, const GLfloat *values ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + /* XXX someday, test against ctx->Const.MaxPixelMapTableSize */ + if (mapsize < 1 || mapsize > MAX_PIXEL_MAP_TABLE) { + _mesa_error( ctx, GL_INVALID_VALUE, "glPixelMapfv(mapsize)" ); + return; + } + + if (map >= GL_PIXEL_MAP_S_TO_S && map <= GL_PIXEL_MAP_I_TO_A) { + /* test that mapsize is a power of two */ + if (!_mesa_is_pow_two(mapsize)) { + _mesa_error( ctx, GL_INVALID_VALUE, "glPixelMapfv(mapsize)" ); + return; + } + } + + FLUSH_VERTICES(ctx, _NEW_PIXEL); + + if (!validate_pbo_access(ctx, &ctx->Unpack, mapsize, GL_INTENSITY, + GL_FLOAT, INT_MAX, values)) { + return; + } + + values = (const GLfloat *) _mesa_map_pbo_source(ctx, &ctx->Unpack, values); + if (!values) { + if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glPixelMapfv(PBO is mapped)"); + } + return; + } + + store_pixelmap(ctx, map, mapsize, values); + + _mesa_unmap_pbo_source(ctx, &ctx->Unpack); +} + + +static void GLAPIENTRY +_mesa_PixelMapuiv(GLenum map, GLsizei mapsize, const GLuint *values ) +{ + GLfloat fvalues[MAX_PIXEL_MAP_TABLE]; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (mapsize < 1 || mapsize > MAX_PIXEL_MAP_TABLE) { + _mesa_error( ctx, GL_INVALID_VALUE, "glPixelMapuiv(mapsize)" ); + return; + } + + if (map >= GL_PIXEL_MAP_S_TO_S && map <= GL_PIXEL_MAP_I_TO_A) { + /* test that mapsize is a power of two */ + if (!_mesa_is_pow_two(mapsize)) { + _mesa_error( ctx, GL_INVALID_VALUE, "glPixelMapuiv(mapsize)" ); + return; + } + } + + FLUSH_VERTICES(ctx, _NEW_PIXEL); + + if (!validate_pbo_access(ctx, &ctx->Unpack, mapsize, GL_INTENSITY, + GL_UNSIGNED_INT, INT_MAX, values)) { + return; + } + + values = (const GLuint *) _mesa_map_pbo_source(ctx, &ctx->Unpack, values); + if (!values) { + if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glPixelMapuiv(PBO is mapped)"); + } + return; + } + + /* convert to floats */ + if (map == GL_PIXEL_MAP_I_TO_I || map == GL_PIXEL_MAP_S_TO_S) { + GLint i; + for (i = 0; i < mapsize; i++) { + fvalues[i] = (GLfloat) values[i]; + } + } + else { + GLint i; + for (i = 0; i < mapsize; i++) { + fvalues[i] = UINT_TO_FLOAT( values[i] ); + } + } + + _mesa_unmap_pbo_source(ctx, &ctx->Unpack); + + store_pixelmap(ctx, map, mapsize, fvalues); +} + + +static void GLAPIENTRY +_mesa_PixelMapusv(GLenum map, GLsizei mapsize, const GLushort *values ) +{ + GLfloat fvalues[MAX_PIXEL_MAP_TABLE]; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (mapsize < 1 || mapsize > MAX_PIXEL_MAP_TABLE) { + _mesa_error( ctx, GL_INVALID_VALUE, "glPixelMapusv(mapsize)" ); + return; + } + + if (map >= GL_PIXEL_MAP_S_TO_S && map <= GL_PIXEL_MAP_I_TO_A) { + /* test that mapsize is a power of two */ + if (!_mesa_is_pow_two(mapsize)) { + _mesa_error( ctx, GL_INVALID_VALUE, "glPixelMapuiv(mapsize)" ); + return; + } + } + + FLUSH_VERTICES(ctx, _NEW_PIXEL); + + if (!validate_pbo_access(ctx, &ctx->Unpack, mapsize, GL_INTENSITY, + GL_UNSIGNED_SHORT, INT_MAX, values)) { + return; + } + + values = (const GLushort *) _mesa_map_pbo_source(ctx, &ctx->Unpack, values); + if (!values) { + if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glPixelMapusv(PBO is mapped)"); + } + return; + } + + /* convert to floats */ + if (map == GL_PIXEL_MAP_I_TO_I || map == GL_PIXEL_MAP_S_TO_S) { + GLint i; + for (i = 0; i < mapsize; i++) { + fvalues[i] = (GLfloat) values[i]; + } + } + else { + GLint i; + for (i = 0; i < mapsize; i++) { + fvalues[i] = USHORT_TO_FLOAT( values[i] ); + } + } + + _mesa_unmap_pbo_source(ctx, &ctx->Unpack); + + store_pixelmap(ctx, map, mapsize, fvalues); +} + + +static void GLAPIENTRY +_mesa_GetnPixelMapfvARB( GLenum map, GLsizei bufSize, GLfloat *values ) +{ + GET_CURRENT_CONTEXT(ctx); + GLint mapsize, i; + const struct gl_pixelmap *pm; + + ASSERT_OUTSIDE_BEGIN_END(ctx); + + pm = get_pixelmap(ctx, map); + if (!pm) { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetPixelMapfv(map)"); + return; + } + + mapsize = pm->Size; + + if (!validate_pbo_access(ctx, &ctx->Pack, mapsize, GL_INTENSITY, + GL_FLOAT, bufSize, values)) { + return; + } + + values = (GLfloat *) _mesa_map_pbo_dest(ctx, &ctx->Pack, values); + if (!values) { + if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glGetPixelMapfv(PBO is mapped)"); + } + return; + } + + if (map == GL_PIXEL_MAP_S_TO_S) { + /* special case */ + for (i = 0; i < mapsize; i++) { + values[i] = (GLfloat) ctx->PixelMaps.StoS.Map[i]; + } + } + else { + memcpy(values, pm->Map, mapsize * sizeof(GLfloat)); + } + + _mesa_unmap_pbo_dest(ctx, &ctx->Pack); +} + + +static void GLAPIENTRY +_mesa_GetPixelMapfv( GLenum map, GLfloat *values ) +{ + _mesa_GetnPixelMapfvARB(map, INT_MAX, values); +} + +static void GLAPIENTRY +_mesa_GetnPixelMapuivARB( GLenum map, GLsizei bufSize, GLuint *values ) +{ + GET_CURRENT_CONTEXT(ctx); + GLint mapsize, i; + const struct gl_pixelmap *pm; + + ASSERT_OUTSIDE_BEGIN_END(ctx); + + pm = get_pixelmap(ctx, map); + if (!pm) { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetPixelMapuiv(map)"); + return; + } + + mapsize = pm->Size; + + if (!validate_pbo_access(ctx, &ctx->Pack, mapsize, GL_INTENSITY, + GL_UNSIGNED_INT, bufSize, values)) { + return; + } + + values = (GLuint *) _mesa_map_pbo_dest(ctx, &ctx->Pack, values); + if (!values) { + if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glGetPixelMapuiv(PBO is mapped)"); + } + return; + } + + if (map == GL_PIXEL_MAP_S_TO_S) { + /* special case */ + memcpy(values, ctx->PixelMaps.StoS.Map, mapsize * sizeof(GLint)); + } + else { + for (i = 0; i < mapsize; i++) { + values[i] = FLOAT_TO_UINT( pm->Map[i] ); + } + } + + _mesa_unmap_pbo_dest(ctx, &ctx->Pack); +} + + +static void GLAPIENTRY +_mesa_GetPixelMapuiv( GLenum map, GLuint *values ) +{ + _mesa_GetnPixelMapuivARB(map, INT_MAX, values); +} + +static void GLAPIENTRY +_mesa_GetnPixelMapusvARB( GLenum map, GLsizei bufSize, GLushort *values ) +{ + GET_CURRENT_CONTEXT(ctx); + GLint mapsize, i; + const struct gl_pixelmap *pm; + + ASSERT_OUTSIDE_BEGIN_END(ctx); + + pm = get_pixelmap(ctx, map); + if (!pm) { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetPixelMapusv(map)"); + return; + } + + mapsize = pm->Size; + + if (!validate_pbo_access(ctx, &ctx->Pack, mapsize, GL_INTENSITY, + GL_UNSIGNED_SHORT, bufSize, values)) { + return; + } + + values = (GLushort *) _mesa_map_pbo_dest(ctx, &ctx->Pack, values); + if (!values) { + if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glGetPixelMapusv(PBO is mapped)"); + } + return; + } + + switch (map) { + /* special cases */ + case GL_PIXEL_MAP_I_TO_I: + for (i = 0; i < mapsize; i++) { + values[i] = (GLushort) CLAMP(ctx->PixelMaps.ItoI.Map[i], 0.0, 65535.); + } + break; + case GL_PIXEL_MAP_S_TO_S: + for (i = 0; i < mapsize; i++) { + values[i] = (GLushort) CLAMP(ctx->PixelMaps.StoS.Map[i], 0.0, 65535.); + } + break; + default: + for (i = 0; i < mapsize; i++) { + CLAMPED_FLOAT_TO_USHORT(values[i], pm->Map[i] ); + } + } + + _mesa_unmap_pbo_dest(ctx, &ctx->Pack); +} + + +static void GLAPIENTRY +_mesa_GetPixelMapusv( GLenum map, GLushort *values ) +{ + _mesa_GetnPixelMapusvARB(map, INT_MAX, values); +} + + +/**********************************************************************/ +/***** glPixelTransfer *****/ +/**********************************************************************/ + + +/* + * Implements glPixelTransfer[fi] whether called immediately or from a + * display list. + */ +static void GLAPIENTRY +_mesa_PixelTransferf( GLenum pname, GLfloat param ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + switch (pname) { + case GL_MAP_COLOR: + if (ctx->Pixel.MapColorFlag == (param ? GL_TRUE : GL_FALSE)) + return; + FLUSH_VERTICES(ctx, _NEW_PIXEL); + ctx->Pixel.MapColorFlag = param ? GL_TRUE : GL_FALSE; + break; + case GL_MAP_STENCIL: + if (ctx->Pixel.MapStencilFlag == (param ? GL_TRUE : GL_FALSE)) + return; + FLUSH_VERTICES(ctx, _NEW_PIXEL); + ctx->Pixel.MapStencilFlag = param ? GL_TRUE : GL_FALSE; + break; + case GL_INDEX_SHIFT: + if (ctx->Pixel.IndexShift == (GLint) param) + return; + FLUSH_VERTICES(ctx, _NEW_PIXEL); + ctx->Pixel.IndexShift = (GLint) param; + break; + case GL_INDEX_OFFSET: + if (ctx->Pixel.IndexOffset == (GLint) param) + return; + FLUSH_VERTICES(ctx, _NEW_PIXEL); + ctx->Pixel.IndexOffset = (GLint) param; + break; + case GL_RED_SCALE: + if (ctx->Pixel.RedScale == param) + return; + FLUSH_VERTICES(ctx, _NEW_PIXEL); + ctx->Pixel.RedScale = param; + break; + case GL_RED_BIAS: + if (ctx->Pixel.RedBias == param) + return; + FLUSH_VERTICES(ctx, _NEW_PIXEL); + ctx->Pixel.RedBias = param; + break; + case GL_GREEN_SCALE: + if (ctx->Pixel.GreenScale == param) + return; + FLUSH_VERTICES(ctx, _NEW_PIXEL); + ctx->Pixel.GreenScale = param; + break; + case GL_GREEN_BIAS: + if (ctx->Pixel.GreenBias == param) + return; + FLUSH_VERTICES(ctx, _NEW_PIXEL); + ctx->Pixel.GreenBias = param; + break; + case GL_BLUE_SCALE: + if (ctx->Pixel.BlueScale == param) + return; + FLUSH_VERTICES(ctx, _NEW_PIXEL); + ctx->Pixel.BlueScale = param; + break; + case GL_BLUE_BIAS: + if (ctx->Pixel.BlueBias == param) + return; + FLUSH_VERTICES(ctx, _NEW_PIXEL); + ctx->Pixel.BlueBias = param; + break; + case GL_ALPHA_SCALE: + if (ctx->Pixel.AlphaScale == param) + return; + FLUSH_VERTICES(ctx, _NEW_PIXEL); + ctx->Pixel.AlphaScale = param; + break; + case GL_ALPHA_BIAS: + if (ctx->Pixel.AlphaBias == param) + return; + FLUSH_VERTICES(ctx, _NEW_PIXEL); + ctx->Pixel.AlphaBias = param; + break; + case GL_DEPTH_SCALE: + if (ctx->Pixel.DepthScale == param) + return; + FLUSH_VERTICES(ctx, _NEW_PIXEL); + ctx->Pixel.DepthScale = param; + break; + case GL_DEPTH_BIAS: + if (ctx->Pixel.DepthBias == param) + return; + FLUSH_VERTICES(ctx, _NEW_PIXEL); + ctx->Pixel.DepthBias = param; + break; + default: + _mesa_error( ctx, GL_INVALID_ENUM, "glPixelTransfer(pname)" ); + return; + } +} + + +static void GLAPIENTRY +_mesa_PixelTransferi( GLenum pname, GLint param ) +{ + _mesa_PixelTransferf( pname, (GLfloat) param ); +} + + + +/**********************************************************************/ +/***** State Management *****/ +/**********************************************************************/ + +/* + * Return a bitmask of IMAGE_*_BIT flags which to indicate which + * pixel transfer operations are enabled. + */ +static void +update_image_transfer_state(struct gl_context *ctx) +{ + GLuint mask = 0; + + if (ctx->Pixel.RedScale != 1.0F || ctx->Pixel.RedBias != 0.0F || + ctx->Pixel.GreenScale != 1.0F || ctx->Pixel.GreenBias != 0.0F || + ctx->Pixel.BlueScale != 1.0F || ctx->Pixel.BlueBias != 0.0F || + ctx->Pixel.AlphaScale != 1.0F || ctx->Pixel.AlphaBias != 0.0F) + mask |= IMAGE_SCALE_BIAS_BIT; + + if (ctx->Pixel.IndexShift || ctx->Pixel.IndexOffset) + mask |= IMAGE_SHIFT_OFFSET_BIT; + + if (ctx->Pixel.MapColorFlag) + mask |= IMAGE_MAP_COLOR_BIT; + + ctx->_ImageTransferState = mask; +} + + +/** + * Update mesa pixel transfer derived state. + */ +void _mesa_update_pixel( struct gl_context *ctx, GLuint new_state ) +{ + if (new_state & _NEW_PIXEL) + update_image_transfer_state(ctx); +} + + +void +_mesa_init_pixel_dispatch(struct _glapi_table *disp) +{ + SET_GetPixelMapfv(disp, _mesa_GetPixelMapfv); + SET_GetPixelMapuiv(disp, _mesa_GetPixelMapuiv); + SET_GetPixelMapusv(disp, _mesa_GetPixelMapusv); + SET_PixelMapfv(disp, _mesa_PixelMapfv); + SET_PixelMapuiv(disp, _mesa_PixelMapuiv); + SET_PixelMapusv(disp, _mesa_PixelMapusv); + SET_PixelTransferf(disp, _mesa_PixelTransferf); + SET_PixelTransferi(disp, _mesa_PixelTransferi); + SET_PixelZoom(disp, _mesa_PixelZoom); + + /* GL_ARB_robustness */ + SET_GetnPixelMapfvARB(disp, _mesa_GetnPixelMapfvARB); + SET_GetnPixelMapuivARB(disp, _mesa_GetnPixelMapuivARB); + SET_GetnPixelMapusvARB(disp, _mesa_GetnPixelMapusvARB); +} + + +#endif /* FEATURE_pixel_transfer */ + + +/**********************************************************************/ +/***** Initialization *****/ +/**********************************************************************/ + +static void +init_pixelmap(struct gl_pixelmap *map) +{ + map->Size = 1; + map->Map[0] = 0.0; + map->Map8[0] = 0; +} + + +/** + * Initialize the context's PIXEL attribute group. + */ +void +_mesa_init_pixel( struct gl_context *ctx ) +{ + /* Pixel group */ + ctx->Pixel.RedBias = 0.0; + ctx->Pixel.RedScale = 1.0; + ctx->Pixel.GreenBias = 0.0; + ctx->Pixel.GreenScale = 1.0; + ctx->Pixel.BlueBias = 0.0; + ctx->Pixel.BlueScale = 1.0; + ctx->Pixel.AlphaBias = 0.0; + ctx->Pixel.AlphaScale = 1.0; + ctx->Pixel.DepthBias = 0.0; + ctx->Pixel.DepthScale = 1.0; + ctx->Pixel.IndexOffset = 0; + ctx->Pixel.IndexShift = 0; + ctx->Pixel.ZoomX = 1.0; + ctx->Pixel.ZoomY = 1.0; + ctx->Pixel.MapColorFlag = GL_FALSE; + ctx->Pixel.MapStencilFlag = GL_FALSE; + init_pixelmap(&ctx->PixelMaps.StoS); + init_pixelmap(&ctx->PixelMaps.ItoI); + init_pixelmap(&ctx->PixelMaps.ItoR); + init_pixelmap(&ctx->PixelMaps.ItoG); + init_pixelmap(&ctx->PixelMaps.ItoB); + init_pixelmap(&ctx->PixelMaps.ItoA); + init_pixelmap(&ctx->PixelMaps.RtoR); + init_pixelmap(&ctx->PixelMaps.GtoG); + init_pixelmap(&ctx->PixelMaps.BtoB); + init_pixelmap(&ctx->PixelMaps.AtoA); + + if (ctx->Visual.doubleBufferMode) { + ctx->Pixel.ReadBuffer = GL_BACK; + } + else { + ctx->Pixel.ReadBuffer = GL_FRONT; + } + + /* Miscellaneous */ + ctx->_ImageTransferState = 0; +} diff --git a/mesalib/src/mesa/main/polygon.c b/mesalib/src/mesa/main/polygon.c index fc64cf4a0..addca0228 100644 --- a/mesalib/src/mesa/main/polygon.c +++ b/mesalib/src/mesa/main/polygon.c @@ -1,330 +1,330 @@ -/** - * \file polygon.c - * Polygon operations. - */ - -/* - * 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 "context.h" -#include "image.h" -#include "enums.h" -#include "pack.h" -#include "pbo.h" -#include "polygon.h" -#include "mtypes.h" - - -/** - * Specify whether to cull front- or back-facing facets. - * - * \param mode culling mode. - * - * \sa glCullFace(). - * - * Verifies the parameter and updates gl_polygon_attrib::CullFaceMode. On - * change, flushes the vertices and notifies the driver via - * the dd_function_table::CullFace callback. - */ -void GLAPIENTRY -_mesa_CullFace( GLenum mode ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE&VERBOSE_API) - _mesa_debug(ctx, "glCullFace %s\n", _mesa_lookup_enum_by_nr(mode)); - - if (mode!=GL_FRONT && mode!=GL_BACK && mode!=GL_FRONT_AND_BACK) { - _mesa_error( ctx, GL_INVALID_ENUM, "glCullFace" ); - return; - } - - if (ctx->Polygon.CullFaceMode == mode) - return; - - FLUSH_VERTICES(ctx, _NEW_POLYGON); - ctx->Polygon.CullFaceMode = mode; - - if (ctx->Driver.CullFace) - ctx->Driver.CullFace( ctx, mode ); -} - - -/** - * Define front- and back-facing - * - * \param mode orientation of front-facing polygons. - * - * \sa glFrontFace(). - * - * Verifies the parameter and updates gl_polygon_attrib::FrontFace. On change - * flushes the vertices and notifies the driver via - * the dd_function_table::FrontFace callback. - */ -void GLAPIENTRY -_mesa_FrontFace( GLenum mode ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE&VERBOSE_API) - _mesa_debug(ctx, "glFrontFace %s\n", _mesa_lookup_enum_by_nr(mode)); - - if (mode!=GL_CW && mode!=GL_CCW) { - _mesa_error( ctx, GL_INVALID_ENUM, "glFrontFace" ); - return; - } - - if (ctx->Polygon.FrontFace == mode) - return; - - FLUSH_VERTICES(ctx, _NEW_POLYGON); - ctx->Polygon.FrontFace = mode; - - ctx->Polygon._FrontBit = (GLboolean) (mode == GL_CW); - - if (ctx->Driver.FrontFace) - ctx->Driver.FrontFace( ctx, mode ); -} - - -/** - * Set the polygon rasterization mode. - * - * \param face the polygons which \p mode applies to. - * \param mode how polygons should be rasterized. - * - * \sa glPolygonMode(). - * - * Verifies the parameters and updates gl_polygon_attrib::FrontMode and - * gl_polygon_attrib::BackMode. On change flushes the vertices and notifies the - * driver via the dd_function_table::PolygonMode callback. - */ -void GLAPIENTRY -_mesa_PolygonMode( GLenum face, GLenum mode ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE&VERBOSE_API) - _mesa_debug(ctx, "glPolygonMode %s %s\n", - _mesa_lookup_enum_by_nr(face), - _mesa_lookup_enum_by_nr(mode)); - - if (mode!=GL_POINT && mode!=GL_LINE && mode!=GL_FILL) { - _mesa_error( ctx, GL_INVALID_ENUM, "glPolygonMode(mode)" ); - return; - } - - switch (face) { - case GL_FRONT: - if (ctx->Polygon.FrontMode == mode) - return; - FLUSH_VERTICES(ctx, _NEW_POLYGON); - ctx->Polygon.FrontMode = mode; - break; - case GL_FRONT_AND_BACK: - if (ctx->Polygon.FrontMode == mode && - ctx->Polygon.BackMode == mode) - return; - FLUSH_VERTICES(ctx, _NEW_POLYGON); - ctx->Polygon.FrontMode = mode; - ctx->Polygon.BackMode = mode; - break; - case GL_BACK: - if (ctx->Polygon.BackMode == mode) - return; - FLUSH_VERTICES(ctx, _NEW_POLYGON); - ctx->Polygon.BackMode = mode; - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glPolygonMode(face)" ); - return; - } - - if (ctx->Polygon.FrontMode == GL_FILL && ctx->Polygon.BackMode == GL_FILL) - ctx->_TriangleCaps &= ~DD_TRI_UNFILLED; - else - ctx->_TriangleCaps |= DD_TRI_UNFILLED; - - if (ctx->Driver.PolygonMode) - ctx->Driver.PolygonMode(ctx, face, mode); -} - -#if _HAVE_FULL_GL - - -/** - * This routine updates the ctx->Polygon.Stipple state. - * If we're getting the stipple data from a PBO, we map the buffer - * in order to access the data. - * In any case, we obey the current pixel unpacking parameters when fetching - * the stipple data. - * - * In the future, this routine should be used as a fallback, called via - * ctx->Driver.PolygonStipple(). We'll have to update all the DRI drivers - * too. - */ -void -_mesa_polygon_stipple(struct gl_context *ctx, const GLubyte *pattern) -{ - pattern = _mesa_map_validate_pbo_source(ctx, 2, - &ctx->Unpack, 32, 32, 1, - GL_COLOR_INDEX, GL_BITMAP, - INT_MAX, pattern, - "glPolygonStipple"); - if (!pattern) - return; - - _mesa_unpack_polygon_stipple(pattern, ctx->PolygonStipple, &ctx->Unpack); - - _mesa_unmap_pbo_source(ctx, &ctx->Unpack); -} - - -/** - * Called by glPolygonStipple. - */ -void GLAPIENTRY -_mesa_PolygonStipple( const GLubyte *pattern ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE&VERBOSE_API) - _mesa_debug(ctx, "glPolygonStipple\n"); - - FLUSH_VERTICES(ctx, _NEW_POLYGONSTIPPLE); - - _mesa_polygon_stipple(ctx, pattern); - - if (ctx->Driver.PolygonStipple) - ctx->Driver.PolygonStipple(ctx, pattern); -} - - -/** - * Called by glPolygonStipple. - */ -void GLAPIENTRY -_mesa_GetnPolygonStippleARB( GLsizei bufSize, GLubyte *dest ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE&VERBOSE_API) - _mesa_debug(ctx, "glGetPolygonStipple\n"); - - dest = _mesa_map_validate_pbo_dest(ctx, 2, - &ctx->Pack, 32, 32, 1, - GL_COLOR_INDEX, GL_BITMAP, - bufSize, dest, "glGetPolygonStipple"); - if (!dest) - return; - - _mesa_pack_polygon_stipple(ctx->PolygonStipple, dest, &ctx->Pack); - - _mesa_unmap_pbo_dest(ctx, &ctx->Pack); -} - - -void GLAPIENTRY -_mesa_GetPolygonStipple( GLubyte *dest ) -{ - _mesa_GetnPolygonStippleARB(INT_MAX, dest); -} - - -void GLAPIENTRY -_mesa_PolygonOffset( GLfloat factor, GLfloat units ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE&VERBOSE_API) - _mesa_debug(ctx, "glPolygonOffset %f %f\n", factor, units); - - if (ctx->Polygon.OffsetFactor == factor && - ctx->Polygon.OffsetUnits == units) - return; - - FLUSH_VERTICES(ctx, _NEW_POLYGON); - ctx->Polygon.OffsetFactor = factor; - ctx->Polygon.OffsetUnits = units; - - if (ctx->Driver.PolygonOffset) - ctx->Driver.PolygonOffset( ctx, factor, units ); -} - - -void GLAPIENTRY -_mesa_PolygonOffsetEXT( GLfloat factor, GLfloat bias ) -{ - GET_CURRENT_CONTEXT(ctx); - /* XXX mult by DepthMaxF here??? */ - _mesa_PolygonOffset(factor, bias * ctx->DrawBuffer->_DepthMaxF ); -} - -#endif - - -/**********************************************************************/ -/** \name Initialization */ -/*@{*/ - -/** - * Initialize the context polygon state. - * - * \param ctx GL context. - * - * Initializes __struct gl_contextRec::Polygon and __struct gl_contextRec::PolygonStipple - * attribute groups. - */ -void _mesa_init_polygon( struct gl_context * ctx ) -{ - /* Polygon group */ - ctx->Polygon.CullFlag = GL_FALSE; - ctx->Polygon.CullFaceMode = GL_BACK; - ctx->Polygon.FrontFace = GL_CCW; - ctx->Polygon._FrontBit = 0; - ctx->Polygon.FrontMode = GL_FILL; - ctx->Polygon.BackMode = GL_FILL; - ctx->Polygon.SmoothFlag = GL_FALSE; - ctx->Polygon.StippleFlag = GL_FALSE; - ctx->Polygon.OffsetFactor = 0.0F; - ctx->Polygon.OffsetUnits = 0.0F; - ctx->Polygon.OffsetPoint = GL_FALSE; - ctx->Polygon.OffsetLine = GL_FALSE; - ctx->Polygon.OffsetFill = GL_FALSE; - - - /* Polygon Stipple group */ - memset( ctx->PolygonStipple, 0xff, 32*sizeof(GLuint) ); -} - -/*@}*/ +/** + * \file polygon.c + * Polygon operations. + */ + +/* + * 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 "context.h" +#include "image.h" +#include "enums.h" +#include "pack.h" +#include "pbo.h" +#include "polygon.h" +#include "mtypes.h" + + +/** + * Specify whether to cull front- or back-facing facets. + * + * \param mode culling mode. + * + * \sa glCullFace(). + * + * Verifies the parameter and updates gl_polygon_attrib::CullFaceMode. On + * change, flushes the vertices and notifies the driver via + * the dd_function_table::CullFace callback. + */ +void GLAPIENTRY +_mesa_CullFace( GLenum mode ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (MESA_VERBOSE&VERBOSE_API) + _mesa_debug(ctx, "glCullFace %s\n", _mesa_lookup_enum_by_nr(mode)); + + if (mode!=GL_FRONT && mode!=GL_BACK && mode!=GL_FRONT_AND_BACK) { + _mesa_error( ctx, GL_INVALID_ENUM, "glCullFace" ); + return; + } + + if (ctx->Polygon.CullFaceMode == mode) + return; + + FLUSH_VERTICES(ctx, _NEW_POLYGON); + ctx->Polygon.CullFaceMode = mode; + + if (ctx->Driver.CullFace) + ctx->Driver.CullFace( ctx, mode ); +} + + +/** + * Define front- and back-facing + * + * \param mode orientation of front-facing polygons. + * + * \sa glFrontFace(). + * + * Verifies the parameter and updates gl_polygon_attrib::FrontFace. On change + * flushes the vertices and notifies the driver via + * the dd_function_table::FrontFace callback. + */ +void GLAPIENTRY +_mesa_FrontFace( GLenum mode ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (MESA_VERBOSE&VERBOSE_API) + _mesa_debug(ctx, "glFrontFace %s\n", _mesa_lookup_enum_by_nr(mode)); + + if (mode!=GL_CW && mode!=GL_CCW) { + _mesa_error( ctx, GL_INVALID_ENUM, "glFrontFace" ); + return; + } + + if (ctx->Polygon.FrontFace == mode) + return; + + FLUSH_VERTICES(ctx, _NEW_POLYGON); + ctx->Polygon.FrontFace = mode; + + ctx->Polygon._FrontBit = (GLboolean) (mode == GL_CW); + + if (ctx->Driver.FrontFace) + ctx->Driver.FrontFace( ctx, mode ); +} + + +/** + * Set the polygon rasterization mode. + * + * \param face the polygons which \p mode applies to. + * \param mode how polygons should be rasterized. + * + * \sa glPolygonMode(). + * + * Verifies the parameters and updates gl_polygon_attrib::FrontMode and + * gl_polygon_attrib::BackMode. On change flushes the vertices and notifies the + * driver via the dd_function_table::PolygonMode callback. + */ +void GLAPIENTRY +_mesa_PolygonMode( GLenum face, GLenum mode ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (MESA_VERBOSE&VERBOSE_API) + _mesa_debug(ctx, "glPolygonMode %s %s\n", + _mesa_lookup_enum_by_nr(face), + _mesa_lookup_enum_by_nr(mode)); + + if (mode!=GL_POINT && mode!=GL_LINE && mode!=GL_FILL) { + _mesa_error( ctx, GL_INVALID_ENUM, "glPolygonMode(mode)" ); + return; + } + + switch (face) { + case GL_FRONT: + if (ctx->Polygon.FrontMode == mode) + return; + FLUSH_VERTICES(ctx, _NEW_POLYGON); + ctx->Polygon.FrontMode = mode; + break; + case GL_FRONT_AND_BACK: + if (ctx->Polygon.FrontMode == mode && + ctx->Polygon.BackMode == mode) + return; + FLUSH_VERTICES(ctx, _NEW_POLYGON); + ctx->Polygon.FrontMode = mode; + ctx->Polygon.BackMode = mode; + break; + case GL_BACK: + if (ctx->Polygon.BackMode == mode) + return; + FLUSH_VERTICES(ctx, _NEW_POLYGON); + ctx->Polygon.BackMode = mode; + break; + default: + _mesa_error( ctx, GL_INVALID_ENUM, "glPolygonMode(face)" ); + return; + } + + if (ctx->Polygon.FrontMode == GL_FILL && ctx->Polygon.BackMode == GL_FILL) + ctx->_TriangleCaps &= ~DD_TRI_UNFILLED; + else + ctx->_TriangleCaps |= DD_TRI_UNFILLED; + + if (ctx->Driver.PolygonMode) + ctx->Driver.PolygonMode(ctx, face, mode); +} + +#if _HAVE_FULL_GL + + +/** + * This routine updates the ctx->Polygon.Stipple state. + * If we're getting the stipple data from a PBO, we map the buffer + * in order to access the data. + * In any case, we obey the current pixel unpacking parameters when fetching + * the stipple data. + * + * In the future, this routine should be used as a fallback, called via + * ctx->Driver.PolygonStipple(). We'll have to update all the DRI drivers + * too. + */ +void +_mesa_polygon_stipple(struct gl_context *ctx, const GLubyte *pattern) +{ + pattern = _mesa_map_validate_pbo_source(ctx, 2, + &ctx->Unpack, 32, 32, 1, + GL_COLOR_INDEX, GL_BITMAP, + INT_MAX, pattern, + "glPolygonStipple"); + if (!pattern) + return; + + _mesa_unpack_polygon_stipple(pattern, ctx->PolygonStipple, &ctx->Unpack); + + _mesa_unmap_pbo_source(ctx, &ctx->Unpack); +} + + +/** + * Called by glPolygonStipple. + */ +void GLAPIENTRY +_mesa_PolygonStipple( const GLubyte *pattern ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (MESA_VERBOSE&VERBOSE_API) + _mesa_debug(ctx, "glPolygonStipple\n"); + + FLUSH_VERTICES(ctx, _NEW_POLYGONSTIPPLE); + + _mesa_polygon_stipple(ctx, pattern); + + if (ctx->Driver.PolygonStipple) + ctx->Driver.PolygonStipple(ctx, pattern); +} + + +/** + * Called by glPolygonStipple. + */ +void GLAPIENTRY +_mesa_GetnPolygonStippleARB( GLsizei bufSize, GLubyte *dest ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (MESA_VERBOSE&VERBOSE_API) + _mesa_debug(ctx, "glGetPolygonStipple\n"); + + dest = _mesa_map_validate_pbo_dest(ctx, 2, + &ctx->Pack, 32, 32, 1, + GL_COLOR_INDEX, GL_BITMAP, + bufSize, dest, "glGetPolygonStipple"); + if (!dest) + return; + + _mesa_pack_polygon_stipple(ctx->PolygonStipple, dest, &ctx->Pack); + + _mesa_unmap_pbo_dest(ctx, &ctx->Pack); +} + + +void GLAPIENTRY +_mesa_GetPolygonStipple( GLubyte *dest ) +{ + _mesa_GetnPolygonStippleARB(INT_MAX, dest); +} + + +void GLAPIENTRY +_mesa_PolygonOffset( GLfloat factor, GLfloat units ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (MESA_VERBOSE&VERBOSE_API) + _mesa_debug(ctx, "glPolygonOffset %f %f\n", factor, units); + + if (ctx->Polygon.OffsetFactor == factor && + ctx->Polygon.OffsetUnits == units) + return; + + FLUSH_VERTICES(ctx, _NEW_POLYGON); + ctx->Polygon.OffsetFactor = factor; + ctx->Polygon.OffsetUnits = units; + + if (ctx->Driver.PolygonOffset) + ctx->Driver.PolygonOffset( ctx, factor, units ); +} + + +void GLAPIENTRY +_mesa_PolygonOffsetEXT( GLfloat factor, GLfloat bias ) +{ + GET_CURRENT_CONTEXT(ctx); + /* XXX mult by DepthMaxF here??? */ + _mesa_PolygonOffset(factor, bias * ctx->DrawBuffer->_DepthMaxF ); +} + +#endif + + +/**********************************************************************/ +/** \name Initialization */ +/*@{*/ + +/** + * Initialize the context polygon state. + * + * \param ctx GL context. + * + * Initializes __struct gl_contextRec::Polygon and __struct gl_contextRec::PolygonStipple + * attribute groups. + */ +void _mesa_init_polygon( struct gl_context * ctx ) +{ + /* Polygon group */ + ctx->Polygon.CullFlag = GL_FALSE; + ctx->Polygon.CullFaceMode = GL_BACK; + ctx->Polygon.FrontFace = GL_CCW; + ctx->Polygon._FrontBit = 0; + ctx->Polygon.FrontMode = GL_FILL; + ctx->Polygon.BackMode = GL_FILL; + ctx->Polygon.SmoothFlag = GL_FALSE; + ctx->Polygon.StippleFlag = GL_FALSE; + ctx->Polygon.OffsetFactor = 0.0F; + ctx->Polygon.OffsetUnits = 0.0F; + ctx->Polygon.OffsetPoint = GL_FALSE; + ctx->Polygon.OffsetLine = GL_FALSE; + ctx->Polygon.OffsetFill = GL_FALSE; + + + /* Polygon Stipple group */ + memset( ctx->PolygonStipple, 0xff, 32*sizeof(GLuint) ); +} + +/*@}*/ diff --git a/mesalib/src/mesa/main/polygon.h b/mesalib/src/mesa/main/polygon.h index 7f6a94bad..35f222f26 100644 --- a/mesalib/src/mesa/main/polygon.h +++ b/mesalib/src/mesa/main/polygon.h @@ -1,70 +1,70 @@ -/** - * \file polygon.h - * Polygon operations. - */ - -/* - * 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. - */ - - -#ifndef POLYGON_H -#define POLYGON_H - - -#include "glheader.h" - -struct gl_context; - -extern void GLAPIENTRY -_mesa_GetnPolygonStippleARB( GLsizei bufSize, GLubyte *dest ); - -extern void -_mesa_polygon_stipple(struct gl_context *ctx, const GLubyte *pattern); - - -extern void GLAPIENTRY -_mesa_CullFace( GLenum mode ); - -extern void GLAPIENTRY -_mesa_FrontFace( GLenum mode ); - -extern void GLAPIENTRY -_mesa_PolygonMode( GLenum face, GLenum mode ); - -extern void GLAPIENTRY -_mesa_PolygonOffset( GLfloat factor, GLfloat units ); - -extern void GLAPIENTRY -_mesa_PolygonOffsetEXT( GLfloat factor, GLfloat bias ); - -extern void GLAPIENTRY -_mesa_PolygonStipple( const GLubyte *mask ); - -extern void GLAPIENTRY -_mesa_GetPolygonStipple( GLubyte *mask ); - -extern void -_mesa_init_polygon( struct gl_context * ctx ); - -#endif +/** + * \file polygon.h + * Polygon operations. + */ + +/* + * 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. + */ + + +#ifndef POLYGON_H +#define POLYGON_H + + +#include "glheader.h" + +struct gl_context; + +extern void GLAPIENTRY +_mesa_GetnPolygonStippleARB( GLsizei bufSize, GLubyte *dest ); + +extern void +_mesa_polygon_stipple(struct gl_context *ctx, const GLubyte *pattern); + + +extern void GLAPIENTRY +_mesa_CullFace( GLenum mode ); + +extern void GLAPIENTRY +_mesa_FrontFace( GLenum mode ); + +extern void GLAPIENTRY +_mesa_PolygonMode( GLenum face, GLenum mode ); + +extern void GLAPIENTRY +_mesa_PolygonOffset( GLfloat factor, GLfloat units ); + +extern void GLAPIENTRY +_mesa_PolygonOffsetEXT( GLfloat factor, GLfloat bias ); + +extern void GLAPIENTRY +_mesa_PolygonStipple( const GLubyte *mask ); + +extern void GLAPIENTRY +_mesa_GetPolygonStipple( GLubyte *mask ); + +extern void +_mesa_init_polygon( struct gl_context * ctx ); + +#endif diff --git a/mesalib/src/mesa/main/queryobj.c b/mesalib/src/mesa/main/queryobj.c index 33be9232e..bae5dad1e 100644 --- a/mesalib/src/mesa/main/queryobj.c +++ b/mesalib/src/mesa/main/queryobj.c @@ -1,624 +1,624 @@ -/* - * 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 "glheader.h" -#include "context.h" -#include "enums.h" -#include "hash.h" -#include "imports.h" -#include "queryobj.h" -#include "mfeatures.h" -#include "mtypes.h" -#include "main/dispatch.h" - - -#if FEATURE_queryobj - - -/** - * Allocate a new query object. This is a fallback routine called via - * ctx->Driver.NewQueryObject(). - * \param ctx - rendering context - * \param id - the new object's ID - * \return pointer to new query_object object or NULL if out of memory. - */ -struct gl_query_object * -_mesa_new_query_object(struct gl_context *ctx, GLuint id) -{ - struct gl_query_object *q = MALLOC_STRUCT(gl_query_object); - (void) ctx; - if (q) { - q->Id = id; - q->Result = 0; - q->Active = GL_FALSE; - q->Ready = GL_TRUE; /* correct, see spec */ - } - return q; -} - - -/** - * Begin a query. Software driver fallback. - * Called via ctx->Driver.BeginQuery(). - */ -void -_mesa_begin_query(struct gl_context *ctx, struct gl_query_object *q) -{ - /* no-op */ -} - - -/** - * End a query. Software driver fallback. - * Called via ctx->Driver.EndQuery(). - */ -void -_mesa_end_query(struct gl_context *ctx, struct gl_query_object *q) -{ - q->Ready = GL_TRUE; -} - - -/** - * Wait for query to complete. Software driver fallback. - * Called via ctx->Driver.WaitQuery(). - */ -void -_mesa_wait_query(struct gl_context *ctx, struct gl_query_object *q) -{ - /* For software drivers, _mesa_end_query() should have completed the query. - * For real hardware, implement a proper WaitQuery() driver function, - * which may require issuing a flush. - */ - assert(q->Ready); -} - - -/** - * Check if a query results are ready. Software driver fallback. - * Called via ctx->Driver.CheckQuery(). - */ -static void -_mesa_check_query(struct gl_context *ctx, struct gl_query_object *q) -{ - /* No-op for sw rendering. - * HW drivers may need to flush at this time. - */ -} - - -/** - * Delete a query object. Called via ctx->Driver.DeleteQuery(). - * Not removed from hash table here. - */ -void -_mesa_delete_query(struct gl_context *ctx, struct gl_query_object *q) -{ - free(q); -} - - -void -_mesa_init_query_object_functions(struct dd_function_table *driver) -{ - driver->NewQueryObject = _mesa_new_query_object; - driver->DeleteQuery = _mesa_delete_query; - driver->BeginQuery = _mesa_begin_query; - driver->EndQuery = _mesa_end_query; - driver->WaitQuery = _mesa_wait_query; - driver->CheckQuery = _mesa_check_query; -} - - -/** - * Return pointer to the query object binding point for the given target. - * \return NULL if invalid target, else the address of binding point - */ -static struct gl_query_object ** -get_query_binding_point(struct gl_context *ctx, GLenum target) -{ - switch (target) { - case GL_SAMPLES_PASSED_ARB: - if (ctx->Extensions.ARB_occlusion_query) - return &ctx->Query.CurrentOcclusionObject; - else - return NULL; - case GL_ANY_SAMPLES_PASSED: - if (ctx->Extensions.ARB_occlusion_query2) - return &ctx->Query.CurrentOcclusionObject; - else - return NULL; - case GL_TIME_ELAPSED_EXT: - if (ctx->Extensions.EXT_timer_query) - return &ctx->Query.CurrentTimerObject; - else - return NULL; -#if FEATURE_EXT_transform_feedback - case GL_PRIMITIVES_GENERATED: - if (ctx->Extensions.EXT_transform_feedback) - return &ctx->Query.PrimitivesGenerated; - else - return NULL; - case GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN: - if (ctx->Extensions.EXT_transform_feedback) - return &ctx->Query.PrimitivesWritten; - else - return NULL; -#endif - default: - return NULL; - } -} - - -static void GLAPIENTRY -_mesa_GenQueriesARB(GLsizei n, GLuint *ids) -{ - GLuint first; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glGenQueries(%d)\n", n); - - if (n < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glGenQueriesARB(n < 0)"); - return; - } - - /* No query objects can be active at this time! */ - if (ctx->Query.CurrentOcclusionObject || - ctx->Query.CurrentTimerObject) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGenQueriesARB"); - return; - } - - first = _mesa_HashFindFreeKeyBlock(ctx->Query.QueryObjects, n); - if (first) { - GLsizei i; - for (i = 0; i < n; i++) { - struct gl_query_object *q - = ctx->Driver.NewQueryObject(ctx, first + i); - if (!q) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGenQueriesARB"); - return; - } - ids[i] = first + i; - _mesa_HashInsert(ctx->Query.QueryObjects, first + i, q); - } - } -} - - -static void GLAPIENTRY -_mesa_DeleteQueriesARB(GLsizei n, const GLuint *ids) -{ - GLint i; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - FLUSH_VERTICES(ctx, 0); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glDeleeteQueries(%d)\n", n); - - if (n < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glDeleteQueriesARB(n < 0)"); - return; - } - - /* No query objects can be active at this time! */ - if (ctx->Query.CurrentOcclusionObject || - ctx->Query.CurrentTimerObject) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glDeleteQueriesARB"); - return; - } - - for (i = 0; i < n; i++) { - if (ids[i] > 0) { - struct gl_query_object *q = _mesa_lookup_query_object(ctx, ids[i]); - if (q) { - ASSERT(!q->Active); /* should be caught earlier */ - _mesa_HashRemove(ctx->Query.QueryObjects, ids[i]); - ctx->Driver.DeleteQuery(ctx, q); - } - } - } -} - - -static GLboolean GLAPIENTRY -_mesa_IsQueryARB(GLuint id) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glIsQuery(%u)\n", id); - - if (id && _mesa_lookup_query_object(ctx, id)) - return GL_TRUE; - else - return GL_FALSE; -} - - -static void GLAPIENTRY -_mesa_BeginQueryARB(GLenum target, GLuint id) -{ - struct gl_query_object *q, **bindpt; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glBeginQuery(%s, %u)\n", - _mesa_lookup_enum_by_nr(target), id); - - FLUSH_VERTICES(ctx, _NEW_DEPTH); - - bindpt = get_query_binding_point(ctx, target); - if (!bindpt) { - _mesa_error(ctx, GL_INVALID_ENUM, "glBeginQueryARB(target)"); - return; - } - - if (id == 0) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glBeginQueryARB(id==0)"); - return; - } - - q = _mesa_lookup_query_object(ctx, id); - if (!q) { - /* create new object */ - q = ctx->Driver.NewQueryObject(ctx, id); - if (!q) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBeginQueryARB"); - return; - } - _mesa_HashInsert(ctx->Query.QueryObjects, id, q); - } - else { - /* pre-existing object */ - if (q->Active) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glBeginQueryARB(query already active)"); - return; - } - } - - q->Target = target; - q->Active = GL_TRUE; - q->Result = 0; - q->Ready = GL_FALSE; - - /* XXX should probably refcount query objects */ - *bindpt = q; - - ctx->Driver.BeginQuery(ctx, q); -} - - -static void GLAPIENTRY -_mesa_EndQueryARB(GLenum target) -{ - struct gl_query_object *q, **bindpt; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glEndQuery(%s)\n", _mesa_lookup_enum_by_nr(target)); - - FLUSH_VERTICES(ctx, _NEW_DEPTH); - - bindpt = get_query_binding_point(ctx, target); - if (!bindpt) { - _mesa_error(ctx, GL_INVALID_ENUM, "glEndQueryARB(target)"); - return; - } - - /* XXX should probably refcount query objects */ - q = *bindpt; - *bindpt = NULL; - - if (!q || !q->Active) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glEndQueryARB(no matching glBeginQueryARB)"); - return; - } - - q->Active = GL_FALSE; - ctx->Driver.EndQuery(ctx, q); -} - - -static void GLAPIENTRY -_mesa_GetQueryivARB(GLenum target, GLenum pname, GLint *params) -{ - struct gl_query_object *q, **bindpt; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glGetQueryiv(%s, %s)\n", - _mesa_lookup_enum_by_nr(target), - _mesa_lookup_enum_by_nr(pname)); - - bindpt = get_query_binding_point(ctx, target); - if (!bindpt) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetQueryARB(target)"); - return; - } - - q = *bindpt; - - switch (pname) { - case GL_QUERY_COUNTER_BITS_ARB: - *params = 8 * sizeof(q->Result); - break; - case GL_CURRENT_QUERY_ARB: - *params = q ? q->Id : 0; - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glGetQueryivARB(pname)"); - return; - } -} - - -static void GLAPIENTRY -_mesa_GetQueryObjectivARB(GLuint id, GLenum pname, GLint *params) -{ - struct gl_query_object *q = NULL; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glGetQueryObjectiv(%u, %s)\n", id, - _mesa_lookup_enum_by_nr(pname)); - - if (id) - q = _mesa_lookup_query_object(ctx, id); - - if (!q || q->Active) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetQueryObjectivARB(id=%d is invalid or active)", id); - return; - } - - switch (pname) { - case GL_QUERY_RESULT_ARB: - if (!q->Ready) - ctx->Driver.WaitQuery(ctx, q); - /* if result is too large for returned type, clamp to max value */ - if (q->Target == GL_ANY_SAMPLES_PASSED) { - if (q->Result) - *params = GL_TRUE; - else - *params = GL_FALSE; - } else { - if (q->Result > 0x7fffffff) { - *params = 0x7fffffff; - } - else { - *params = (GLint)q->Result; - } - } - break; - case GL_QUERY_RESULT_AVAILABLE_ARB: - if (!q->Ready) - ctx->Driver.CheckQuery( ctx, q ); - *params = q->Ready; - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glGetQueryObjectivARB(pname)"); - return; - } -} - - -static void GLAPIENTRY -_mesa_GetQueryObjectuivARB(GLuint id, GLenum pname, GLuint *params) -{ - struct gl_query_object *q = NULL; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glGetQueryObjectuiv(%u, %s)\n", id, - _mesa_lookup_enum_by_nr(pname)); - - if (id) - q = _mesa_lookup_query_object(ctx, id); - - if (!q || q->Active) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetQueryObjectuivARB(id=%d is invalid or active)", id); - return; - } - - switch (pname) { - case GL_QUERY_RESULT_ARB: - if (!q->Ready) - ctx->Driver.WaitQuery(ctx, q); - /* if result is too large for returned type, clamp to max value */ - if (q->Target == GL_ANY_SAMPLES_PASSED) { - if (q->Result) - *params = GL_TRUE; - else - *params = GL_FALSE; - } else { - if (q->Result > 0xffffffff) { - *params = 0xffffffff; - } - else { - *params = (GLuint)q->Result; - } - } - break; - case GL_QUERY_RESULT_AVAILABLE_ARB: - if (!q->Ready) - ctx->Driver.CheckQuery( ctx, q ); - *params = q->Ready; - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glGetQueryObjectuivARB(pname)"); - return; - } -} - - -/** - * New with GL_EXT_timer_query - */ -static void GLAPIENTRY -_mesa_GetQueryObjecti64vEXT(GLuint id, GLenum pname, GLint64EXT *params) -{ - struct gl_query_object *q = NULL; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glGetQueryObjecti64v(%u, %s)\n", id, - _mesa_lookup_enum_by_nr(pname)); - - if (id) - q = _mesa_lookup_query_object(ctx, id); - - if (!q || q->Active) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetQueryObjectui64vARB(id=%d is invalid or active)", id); - return; - } - - switch (pname) { - case GL_QUERY_RESULT_ARB: - if (!q->Ready) - ctx->Driver.WaitQuery(ctx, q); - *params = q->Result; - break; - case GL_QUERY_RESULT_AVAILABLE_ARB: - if (!q->Ready) - ctx->Driver.CheckQuery( ctx, q ); - *params = q->Ready; - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glGetQueryObjecti64vARB(pname)"); - return; - } -} - - -/** - * New with GL_EXT_timer_query - */ -static void GLAPIENTRY -_mesa_GetQueryObjectui64vEXT(GLuint id, GLenum pname, GLuint64EXT *params) -{ - struct gl_query_object *q = NULL; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glGetQueryObjectui64v(%u, %s)\n", id, - _mesa_lookup_enum_by_nr(pname)); - - if (id) - q = _mesa_lookup_query_object(ctx, id); - - if (!q || q->Active) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetQueryObjectuui64vARB(id=%d is invalid or active)", id); - return; - } - - switch (pname) { - case GL_QUERY_RESULT_ARB: - if (!q->Ready) - ctx->Driver.WaitQuery(ctx, q); - *params = q->Result; - break; - case GL_QUERY_RESULT_AVAILABLE_ARB: - if (!q->Ready) - ctx->Driver.CheckQuery( ctx, q ); - *params = q->Ready; - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glGetQueryObjectui64vARB(pname)"); - return; - } -} - - -void -_mesa_init_queryobj_dispatch(struct _glapi_table *disp) -{ - SET_GenQueriesARB(disp, _mesa_GenQueriesARB); - SET_DeleteQueriesARB(disp, _mesa_DeleteQueriesARB); - SET_IsQueryARB(disp, _mesa_IsQueryARB); - SET_BeginQueryARB(disp, _mesa_BeginQueryARB); - SET_EndQueryARB(disp, _mesa_EndQueryARB); - SET_GetQueryivARB(disp, _mesa_GetQueryivARB); - SET_GetQueryObjectivARB(disp, _mesa_GetQueryObjectivARB); - SET_GetQueryObjectuivARB(disp, _mesa_GetQueryObjectuivARB); - - SET_GetQueryObjecti64vEXT(disp, _mesa_GetQueryObjecti64vEXT); - SET_GetQueryObjectui64vEXT(disp, _mesa_GetQueryObjectui64vEXT); -} - - -#endif /* FEATURE_queryobj */ - - -/** - * Allocate/init the context state related to query objects. - */ -void -_mesa_init_queryobj(struct gl_context *ctx) -{ - ctx->Query.QueryObjects = _mesa_NewHashTable(); - ctx->Query.CurrentOcclusionObject = NULL; -} - - -/** - * Callback for deleting a query object. Called by _mesa_HashDeleteAll(). - */ -static void -delete_queryobj_cb(GLuint id, void *data, void *userData) -{ - struct gl_query_object *q= (struct gl_query_object *) data; - struct gl_context *ctx = (struct gl_context *)userData; - ctx->Driver.DeleteQuery(ctx, q); -} - - -/** - * Free the context state related to query objects. - */ -void -_mesa_free_queryobj_data(struct gl_context *ctx) -{ - _mesa_HashDeleteAll(ctx->Query.QueryObjects, delete_queryobj_cb, ctx); - _mesa_DeleteHashTable(ctx->Query.QueryObjects); -} +/* + * 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 "glheader.h" +#include "context.h" +#include "enums.h" +#include "hash.h" +#include "imports.h" +#include "queryobj.h" +#include "mfeatures.h" +#include "mtypes.h" +#include "main/dispatch.h" + + +#if FEATURE_queryobj + + +/** + * Allocate a new query object. This is a fallback routine called via + * ctx->Driver.NewQueryObject(). + * \param ctx - rendering context + * \param id - the new object's ID + * \return pointer to new query_object object or NULL if out of memory. + */ +struct gl_query_object * +_mesa_new_query_object(struct gl_context *ctx, GLuint id) +{ + struct gl_query_object *q = MALLOC_STRUCT(gl_query_object); + (void) ctx; + if (q) { + q->Id = id; + q->Result = 0; + q->Active = GL_FALSE; + q->Ready = GL_TRUE; /* correct, see spec */ + } + return q; +} + + +/** + * Begin a query. Software driver fallback. + * Called via ctx->Driver.BeginQuery(). + */ +void +_mesa_begin_query(struct gl_context *ctx, struct gl_query_object *q) +{ + /* no-op */ +} + + +/** + * End a query. Software driver fallback. + * Called via ctx->Driver.EndQuery(). + */ +void +_mesa_end_query(struct gl_context *ctx, struct gl_query_object *q) +{ + q->Ready = GL_TRUE; +} + + +/** + * Wait for query to complete. Software driver fallback. + * Called via ctx->Driver.WaitQuery(). + */ +void +_mesa_wait_query(struct gl_context *ctx, struct gl_query_object *q) +{ + /* For software drivers, _mesa_end_query() should have completed the query. + * For real hardware, implement a proper WaitQuery() driver function, + * which may require issuing a flush. + */ + assert(q->Ready); +} + + +/** + * Check if a query results are ready. Software driver fallback. + * Called via ctx->Driver.CheckQuery(). + */ +static void +_mesa_check_query(struct gl_context *ctx, struct gl_query_object *q) +{ + /* No-op for sw rendering. + * HW drivers may need to flush at this time. + */ +} + + +/** + * Delete a query object. Called via ctx->Driver.DeleteQuery(). + * Not removed from hash table here. + */ +void +_mesa_delete_query(struct gl_context *ctx, struct gl_query_object *q) +{ + free(q); +} + + +void +_mesa_init_query_object_functions(struct dd_function_table *driver) +{ + driver->NewQueryObject = _mesa_new_query_object; + driver->DeleteQuery = _mesa_delete_query; + driver->BeginQuery = _mesa_begin_query; + driver->EndQuery = _mesa_end_query; + driver->WaitQuery = _mesa_wait_query; + driver->CheckQuery = _mesa_check_query; +} + + +/** + * Return pointer to the query object binding point for the given target. + * \return NULL if invalid target, else the address of binding point + */ +static struct gl_query_object ** +get_query_binding_point(struct gl_context *ctx, GLenum target) +{ + switch (target) { + case GL_SAMPLES_PASSED_ARB: + if (ctx->Extensions.ARB_occlusion_query) + return &ctx->Query.CurrentOcclusionObject; + else + return NULL; + case GL_ANY_SAMPLES_PASSED: + if (ctx->Extensions.ARB_occlusion_query2) + return &ctx->Query.CurrentOcclusionObject; + else + return NULL; + case GL_TIME_ELAPSED_EXT: + if (ctx->Extensions.EXT_timer_query) + return &ctx->Query.CurrentTimerObject; + else + return NULL; +#if FEATURE_EXT_transform_feedback + case GL_PRIMITIVES_GENERATED: + if (ctx->Extensions.EXT_transform_feedback) + return &ctx->Query.PrimitivesGenerated; + else + return NULL; + case GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN: + if (ctx->Extensions.EXT_transform_feedback) + return &ctx->Query.PrimitivesWritten; + else + return NULL; +#endif + default: + return NULL; + } +} + + +static void GLAPIENTRY +_mesa_GenQueriesARB(GLsizei n, GLuint *ids) +{ + GLuint first; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glGenQueries(%d)\n", n); + + if (n < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glGenQueriesARB(n < 0)"); + return; + } + + /* No query objects can be active at this time! */ + if (ctx->Query.CurrentOcclusionObject || + ctx->Query.CurrentTimerObject) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glGenQueriesARB"); + return; + } + + first = _mesa_HashFindFreeKeyBlock(ctx->Query.QueryObjects, n); + if (first) { + GLsizei i; + for (i = 0; i < n; i++) { + struct gl_query_object *q + = ctx->Driver.NewQueryObject(ctx, first + i); + if (!q) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGenQueriesARB"); + return; + } + ids[i] = first + i; + _mesa_HashInsert(ctx->Query.QueryObjects, first + i, q); + } + } +} + + +static void GLAPIENTRY +_mesa_DeleteQueriesARB(GLsizei n, const GLuint *ids) +{ + GLint i; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + FLUSH_VERTICES(ctx, 0); + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glDeleeteQueries(%d)\n", n); + + if (n < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glDeleteQueriesARB(n < 0)"); + return; + } + + /* No query objects can be active at this time! */ + if (ctx->Query.CurrentOcclusionObject || + ctx->Query.CurrentTimerObject) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glDeleteQueriesARB"); + return; + } + + for (i = 0; i < n; i++) { + if (ids[i] > 0) { + struct gl_query_object *q = _mesa_lookup_query_object(ctx, ids[i]); + if (q) { + ASSERT(!q->Active); /* should be caught earlier */ + _mesa_HashRemove(ctx->Query.QueryObjects, ids[i]); + ctx->Driver.DeleteQuery(ctx, q); + } + } + } +} + + +static GLboolean GLAPIENTRY +_mesa_IsQueryARB(GLuint id) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glIsQuery(%u)\n", id); + + if (id && _mesa_lookup_query_object(ctx, id)) + return GL_TRUE; + else + return GL_FALSE; +} + + +static void GLAPIENTRY +_mesa_BeginQueryARB(GLenum target, GLuint id) +{ + struct gl_query_object *q, **bindpt; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glBeginQuery(%s, %u)\n", + _mesa_lookup_enum_by_nr(target), id); + + FLUSH_VERTICES(ctx, _NEW_DEPTH); + + bindpt = get_query_binding_point(ctx, target); + if (!bindpt) { + _mesa_error(ctx, GL_INVALID_ENUM, "glBeginQueryARB(target)"); + return; + } + + if (id == 0) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glBeginQueryARB(id==0)"); + return; + } + + q = _mesa_lookup_query_object(ctx, id); + if (!q) { + /* create new object */ + q = ctx->Driver.NewQueryObject(ctx, id); + if (!q) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBeginQueryARB"); + return; + } + _mesa_HashInsert(ctx->Query.QueryObjects, id, q); + } + else { + /* pre-existing object */ + if (q->Active) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glBeginQueryARB(query already active)"); + return; + } + } + + q->Target = target; + q->Active = GL_TRUE; + q->Result = 0; + q->Ready = GL_FALSE; + + /* XXX should probably refcount query objects */ + *bindpt = q; + + ctx->Driver.BeginQuery(ctx, q); +} + + +static void GLAPIENTRY +_mesa_EndQueryARB(GLenum target) +{ + struct gl_query_object *q, **bindpt; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glEndQuery(%s)\n", _mesa_lookup_enum_by_nr(target)); + + FLUSH_VERTICES(ctx, _NEW_DEPTH); + + bindpt = get_query_binding_point(ctx, target); + if (!bindpt) { + _mesa_error(ctx, GL_INVALID_ENUM, "glEndQueryARB(target)"); + return; + } + + /* XXX should probably refcount query objects */ + q = *bindpt; + *bindpt = NULL; + + if (!q || !q->Active) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glEndQueryARB(no matching glBeginQueryARB)"); + return; + } + + q->Active = GL_FALSE; + ctx->Driver.EndQuery(ctx, q); +} + + +static void GLAPIENTRY +_mesa_GetQueryivARB(GLenum target, GLenum pname, GLint *params) +{ + struct gl_query_object *q, **bindpt; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glGetQueryiv(%s, %s)\n", + _mesa_lookup_enum_by_nr(target), + _mesa_lookup_enum_by_nr(pname)); + + bindpt = get_query_binding_point(ctx, target); + if (!bindpt) { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetQueryARB(target)"); + return; + } + + q = *bindpt; + + switch (pname) { + case GL_QUERY_COUNTER_BITS_ARB: + *params = 8 * sizeof(q->Result); + break; + case GL_CURRENT_QUERY_ARB: + *params = q ? q->Id : 0; + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, "glGetQueryivARB(pname)"); + return; + } +} + + +static void GLAPIENTRY +_mesa_GetQueryObjectivARB(GLuint id, GLenum pname, GLint *params) +{ + struct gl_query_object *q = NULL; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glGetQueryObjectiv(%u, %s)\n", id, + _mesa_lookup_enum_by_nr(pname)); + + if (id) + q = _mesa_lookup_query_object(ctx, id); + + if (!q || q->Active) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glGetQueryObjectivARB(id=%d is invalid or active)", id); + return; + } + + switch (pname) { + case GL_QUERY_RESULT_ARB: + if (!q->Ready) + ctx->Driver.WaitQuery(ctx, q); + /* if result is too large for returned type, clamp to max value */ + if (q->Target == GL_ANY_SAMPLES_PASSED) { + if (q->Result) + *params = GL_TRUE; + else + *params = GL_FALSE; + } else { + if (q->Result > 0x7fffffff) { + *params = 0x7fffffff; + } + else { + *params = (GLint)q->Result; + } + } + break; + case GL_QUERY_RESULT_AVAILABLE_ARB: + if (!q->Ready) + ctx->Driver.CheckQuery( ctx, q ); + *params = q->Ready; + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, "glGetQueryObjectivARB(pname)"); + return; + } +} + + +static void GLAPIENTRY +_mesa_GetQueryObjectuivARB(GLuint id, GLenum pname, GLuint *params) +{ + struct gl_query_object *q = NULL; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glGetQueryObjectuiv(%u, %s)\n", id, + _mesa_lookup_enum_by_nr(pname)); + + if (id) + q = _mesa_lookup_query_object(ctx, id); + + if (!q || q->Active) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glGetQueryObjectuivARB(id=%d is invalid or active)", id); + return; + } + + switch (pname) { + case GL_QUERY_RESULT_ARB: + if (!q->Ready) + ctx->Driver.WaitQuery(ctx, q); + /* if result is too large for returned type, clamp to max value */ + if (q->Target == GL_ANY_SAMPLES_PASSED) { + if (q->Result) + *params = GL_TRUE; + else + *params = GL_FALSE; + } else { + if (q->Result > 0xffffffff) { + *params = 0xffffffff; + } + else { + *params = (GLuint)q->Result; + } + } + break; + case GL_QUERY_RESULT_AVAILABLE_ARB: + if (!q->Ready) + ctx->Driver.CheckQuery( ctx, q ); + *params = q->Ready; + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, "glGetQueryObjectuivARB(pname)"); + return; + } +} + + +/** + * New with GL_EXT_timer_query + */ +static void GLAPIENTRY +_mesa_GetQueryObjecti64vEXT(GLuint id, GLenum pname, GLint64EXT *params) +{ + struct gl_query_object *q = NULL; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glGetQueryObjecti64v(%u, %s)\n", id, + _mesa_lookup_enum_by_nr(pname)); + + if (id) + q = _mesa_lookup_query_object(ctx, id); + + if (!q || q->Active) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glGetQueryObjectui64vARB(id=%d is invalid or active)", id); + return; + } + + switch (pname) { + case GL_QUERY_RESULT_ARB: + if (!q->Ready) + ctx->Driver.WaitQuery(ctx, q); + *params = q->Result; + break; + case GL_QUERY_RESULT_AVAILABLE_ARB: + if (!q->Ready) + ctx->Driver.CheckQuery( ctx, q ); + *params = q->Ready; + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, "glGetQueryObjecti64vARB(pname)"); + return; + } +} + + +/** + * New with GL_EXT_timer_query + */ +static void GLAPIENTRY +_mesa_GetQueryObjectui64vEXT(GLuint id, GLenum pname, GLuint64EXT *params) +{ + struct gl_query_object *q = NULL; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glGetQueryObjectui64v(%u, %s)\n", id, + _mesa_lookup_enum_by_nr(pname)); + + if (id) + q = _mesa_lookup_query_object(ctx, id); + + if (!q || q->Active) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glGetQueryObjectuui64vARB(id=%d is invalid or active)", id); + return; + } + + switch (pname) { + case GL_QUERY_RESULT_ARB: + if (!q->Ready) + ctx->Driver.WaitQuery(ctx, q); + *params = q->Result; + break; + case GL_QUERY_RESULT_AVAILABLE_ARB: + if (!q->Ready) + ctx->Driver.CheckQuery( ctx, q ); + *params = q->Ready; + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, "glGetQueryObjectui64vARB(pname)"); + return; + } +} + + +void +_mesa_init_queryobj_dispatch(struct _glapi_table *disp) +{ + SET_GenQueriesARB(disp, _mesa_GenQueriesARB); + SET_DeleteQueriesARB(disp, _mesa_DeleteQueriesARB); + SET_IsQueryARB(disp, _mesa_IsQueryARB); + SET_BeginQueryARB(disp, _mesa_BeginQueryARB); + SET_EndQueryARB(disp, _mesa_EndQueryARB); + SET_GetQueryivARB(disp, _mesa_GetQueryivARB); + SET_GetQueryObjectivARB(disp, _mesa_GetQueryObjectivARB); + SET_GetQueryObjectuivARB(disp, _mesa_GetQueryObjectuivARB); + + SET_GetQueryObjecti64vEXT(disp, _mesa_GetQueryObjecti64vEXT); + SET_GetQueryObjectui64vEXT(disp, _mesa_GetQueryObjectui64vEXT); +} + + +#endif /* FEATURE_queryobj */ + + +/** + * Allocate/init the context state related to query objects. + */ +void +_mesa_init_queryobj(struct gl_context *ctx) +{ + ctx->Query.QueryObjects = _mesa_NewHashTable(); + ctx->Query.CurrentOcclusionObject = NULL; +} + + +/** + * Callback for deleting a query object. Called by _mesa_HashDeleteAll(). + */ +static void +delete_queryobj_cb(GLuint id, void *data, void *userData) +{ + struct gl_query_object *q= (struct gl_query_object *) data; + struct gl_context *ctx = (struct gl_context *)userData; + ctx->Driver.DeleteQuery(ctx, q); +} + + +/** + * Free the context state related to query objects. + */ +void +_mesa_free_queryobj_data(struct gl_context *ctx) +{ + _mesa_HashDeleteAll(ctx->Query.QueryObjects, delete_queryobj_cb, ctx); + _mesa_DeleteHashTable(ctx->Query.QueryObjects); +} diff --git a/mesalib/src/mesa/main/readpix.c b/mesalib/src/mesa/main/readpix.c index ecd9ba1f7..84c5b2228 100644 --- a/mesalib/src/mesa/main/readpix.c +++ b/mesalib/src/mesa/main/readpix.c @@ -1,278 +1,278 @@ -/* - * 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 "imports.h" -#include "bufferobj.h" -#include "context.h" -#include "enums.h" -#include "readpix.h" -#include "framebuffer.h" -#include "formats.h" -#include "image.h" -#include "mtypes.h" -#include "pbo.h" -#include "state.h" - - -/** - * Do error checking of the format/type parameters to glReadPixels and - * glDrawPixels. - * \param drawing if GL_TRUE do checking for DrawPixels, else do checking - * for ReadPixels. - * \return GL_TRUE if error detected, GL_FALSE if no errors - */ -GLboolean -_mesa_error_check_format_type(struct gl_context *ctx, GLenum format, - GLenum type, GLboolean drawing) -{ - const char *readDraw = drawing ? "Draw" : "Read"; - const GLboolean reading = !drawing; - - /* state validation should have already been done */ - ASSERT(ctx->NewState == 0x0); - - if (ctx->Extensions.EXT_packed_depth_stencil - && type == GL_UNSIGNED_INT_24_8_EXT - && format != GL_DEPTH_STENCIL_EXT) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "gl%sPixels(format is not GL_DEPTH_STENCIL_EXT)", readDraw); - return GL_TRUE; - } - - if (ctx->Extensions.ARB_depth_buffer_float - && type == GL_FLOAT_32_UNSIGNED_INT_24_8_REV - && format != GL_DEPTH_STENCIL_EXT) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "gl%sPixels(format is not GL_DEPTH_STENCIL_EXT)", readDraw); - return GL_TRUE; - } - - /* basic combinations test */ - if (!_mesa_is_legal_format_and_type(ctx, format, type)) { - _mesa_error(ctx, GL_INVALID_ENUM, - "gl%sPixels(format or type)", readDraw); - return GL_TRUE; - } - - /* additional checks */ - switch (format) { - case GL_RG: - case GL_RED: - case GL_GREEN: - case GL_BLUE: - case GL_ALPHA: - case GL_LUMINANCE: - case GL_LUMINANCE_ALPHA: - case GL_RGB: - case GL_BGR: - case GL_RGBA: - case GL_BGRA: - case GL_ABGR_EXT: - case GL_RED_INTEGER_EXT: - case GL_GREEN_INTEGER_EXT: - case GL_BLUE_INTEGER_EXT: - case GL_ALPHA_INTEGER_EXT: - case GL_RGB_INTEGER_EXT: - case GL_RGBA_INTEGER_EXT: - case GL_BGR_INTEGER_EXT: - case GL_BGRA_INTEGER_EXT: - case GL_LUMINANCE_INTEGER_EXT: - case GL_LUMINANCE_ALPHA_INTEGER_EXT: - if (!drawing) { - /* reading */ - if (!_mesa_source_buffer_exists(ctx, GL_COLOR)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glReadPixels(no color buffer)"); - return GL_TRUE; - } - } - break; - case GL_COLOR_INDEX: - if (drawing) { - if (ctx->PixelMaps.ItoR.Size == 0 || - ctx->PixelMaps.ItoG.Size == 0 || - ctx->PixelMaps.ItoB.Size == 0) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glDrawPixels(drawing color index pixels into RGB buffer)"); - return GL_TRUE; - } - } - else { - /* reading */ - if (!_mesa_source_buffer_exists(ctx, GL_COLOR)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glReadPixels(no color buffer)"); - return GL_TRUE; - } - /* We no longer support CI-mode color buffers so trying to read - * GL_COLOR_INDEX pixels is always an error. - */ - _mesa_error(ctx, GL_INVALID_OPERATION, - "glReadPixels(color buffer is RGB)"); - return GL_TRUE; - } - break; - case GL_STENCIL_INDEX: - if ((drawing && !_mesa_dest_buffer_exists(ctx, format)) || - (reading && !_mesa_source_buffer_exists(ctx, format))) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "gl%sPixels(no stencil buffer)", readDraw); - return GL_TRUE; - } - break; - case GL_DEPTH_COMPONENT: - if ((drawing && !_mesa_dest_buffer_exists(ctx, format))) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "gl%sPixels(no depth buffer)", readDraw); - return GL_TRUE; - } - break; - case GL_DEPTH_STENCIL_EXT: - /* Check validity of the type first. */ - switch (type) { - case GL_UNSIGNED_INT_24_8_EXT: - if (!ctx->Extensions.EXT_packed_depth_stencil) { - _mesa_error(ctx, GL_INVALID_ENUM, "gl%sPixels(type)", readDraw); - return GL_TRUE; - } - break; - case GL_FLOAT_32_UNSIGNED_INT_24_8_REV: - if (!ctx->Extensions.ARB_depth_buffer_float) { - _mesa_error(ctx, GL_INVALID_ENUM, "gl%sPixels(type)", readDraw); - return GL_TRUE; - } - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "gl%sPixels(type)", readDraw); - return GL_TRUE; - } - if ((drawing && !_mesa_dest_buffer_exists(ctx, format)) || - (reading && !_mesa_source_buffer_exists(ctx, format))) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "gl%sPixels(no depth or stencil buffer)", readDraw); - return GL_TRUE; - } - break; - default: - /* this should have been caught in _mesa_is_legal_format_type() */ - _mesa_problem(ctx, "unexpected format in _mesa_%sPixels", readDraw); - return GL_TRUE; - } - - /* no errors */ - return GL_FALSE; -} - - - -void GLAPIENTRY -_mesa_ReadnPixelsARB( GLint x, GLint y, GLsizei width, GLsizei height, - GLenum format, GLenum type, GLsizei bufSize, - GLvoid *pixels ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - FLUSH_CURRENT(ctx, 0); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glReadPixels(%d, %d, %s, %s, %p)\n", - width, height, - _mesa_lookup_enum_by_nr(format), - _mesa_lookup_enum_by_nr(type), - pixels); - - if (width < 0 || height < 0) { - _mesa_error( ctx, GL_INVALID_VALUE, - "glReadPixels(width=%d height=%d)", width, height ); - return; - } - - if (ctx->NewState) - _mesa_update_state(ctx); - - if (_mesa_error_check_format_type(ctx, format, type, GL_FALSE)) { - /* found an error */ - return; - } - - /* Check that the destination format and source buffer are both - * integer-valued or both non-integer-valued. - */ - if (ctx->Extensions.EXT_texture_integer && _mesa_is_color_format(format)) { - const struct gl_renderbuffer *rb = ctx->ReadBuffer->_ColorReadBuffer; - const GLboolean srcInteger = _mesa_is_format_integer_color(rb->Format); - const GLboolean dstInteger = _mesa_is_integer_format(format); - if (dstInteger != srcInteger) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glReadPixels(integer / non-integer format mismatch"); - return; - } - } - - if (ctx->ReadBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) { - _mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION_EXT, - "glReadPixels(incomplete framebuffer)" ); - return; - } - - if (!_mesa_source_buffer_exists(ctx, format)) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glReadPixels(no readbuffer)"); - return; - } - - if (width == 0 || height == 0) - return; /* nothing to do */ - - if (!_mesa_validate_pbo_access(2, &ctx->Pack, width, height, 1, - format, type, bufSize, pixels)) { - if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glReadPixels(out of bounds PBO access)"); - } else { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glReadnPixelsARB(out of bounds access:" - " bufSize (%d) is too small)", bufSize); - } - return; - } - - if (_mesa_is_bufferobj(ctx->Pack.BufferObj) && - _mesa_bufferobj_mapped(ctx->Pack.BufferObj)) { - /* buffer is mapped - that's an error */ - _mesa_error(ctx, GL_INVALID_OPERATION, "glReadPixels(PBO is mapped)"); - return; - } - - ctx->Driver.ReadPixels(ctx, x, y, width, height, - format, type, &ctx->Pack, pixels); -} - -void GLAPIENTRY -_mesa_ReadPixels( GLint x, GLint y, GLsizei width, GLsizei height, - GLenum format, GLenum type, GLvoid *pixels ) -{ - _mesa_ReadnPixelsARB(x, y, width, height, format, type, INT_MAX, pixels); -} +/* + * 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 "imports.h" +#include "bufferobj.h" +#include "context.h" +#include "enums.h" +#include "readpix.h" +#include "framebuffer.h" +#include "formats.h" +#include "image.h" +#include "mtypes.h" +#include "pbo.h" +#include "state.h" + + +/** + * Do error checking of the format/type parameters to glReadPixels and + * glDrawPixels. + * \param drawing if GL_TRUE do checking for DrawPixels, else do checking + * for ReadPixels. + * \return GL_TRUE if error detected, GL_FALSE if no errors + */ +GLboolean +_mesa_error_check_format_type(struct gl_context *ctx, GLenum format, + GLenum type, GLboolean drawing) +{ + const char *readDraw = drawing ? "Draw" : "Read"; + const GLboolean reading = !drawing; + + /* state validation should have already been done */ + ASSERT(ctx->NewState == 0x0); + + if (ctx->Extensions.EXT_packed_depth_stencil + && type == GL_UNSIGNED_INT_24_8_EXT + && format != GL_DEPTH_STENCIL_EXT) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "gl%sPixels(format is not GL_DEPTH_STENCIL_EXT)", readDraw); + return GL_TRUE; + } + + if (ctx->Extensions.ARB_depth_buffer_float + && type == GL_FLOAT_32_UNSIGNED_INT_24_8_REV + && format != GL_DEPTH_STENCIL_EXT) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "gl%sPixels(format is not GL_DEPTH_STENCIL_EXT)", readDraw); + return GL_TRUE; + } + + /* basic combinations test */ + if (!_mesa_is_legal_format_and_type(ctx, format, type)) { + _mesa_error(ctx, GL_INVALID_ENUM, + "gl%sPixels(format or type)", readDraw); + return GL_TRUE; + } + + /* additional checks */ + switch (format) { + case GL_RG: + case GL_RED: + case GL_GREEN: + case GL_BLUE: + case GL_ALPHA: + case GL_LUMINANCE: + case GL_LUMINANCE_ALPHA: + case GL_RGB: + case GL_BGR: + case GL_RGBA: + case GL_BGRA: + case GL_ABGR_EXT: + case GL_RED_INTEGER_EXT: + case GL_GREEN_INTEGER_EXT: + case GL_BLUE_INTEGER_EXT: + case GL_ALPHA_INTEGER_EXT: + case GL_RGB_INTEGER_EXT: + case GL_RGBA_INTEGER_EXT: + case GL_BGR_INTEGER_EXT: + case GL_BGRA_INTEGER_EXT: + case GL_LUMINANCE_INTEGER_EXT: + case GL_LUMINANCE_ALPHA_INTEGER_EXT: + if (!drawing) { + /* reading */ + if (!_mesa_source_buffer_exists(ctx, GL_COLOR)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glReadPixels(no color buffer)"); + return GL_TRUE; + } + } + break; + case GL_COLOR_INDEX: + if (drawing) { + if (ctx->PixelMaps.ItoR.Size == 0 || + ctx->PixelMaps.ItoG.Size == 0 || + ctx->PixelMaps.ItoB.Size == 0) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glDrawPixels(drawing color index pixels into RGB buffer)"); + return GL_TRUE; + } + } + else { + /* reading */ + if (!_mesa_source_buffer_exists(ctx, GL_COLOR)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glReadPixels(no color buffer)"); + return GL_TRUE; + } + /* We no longer support CI-mode color buffers so trying to read + * GL_COLOR_INDEX pixels is always an error. + */ + _mesa_error(ctx, GL_INVALID_OPERATION, + "glReadPixels(color buffer is RGB)"); + return GL_TRUE; + } + break; + case GL_STENCIL_INDEX: + if ((drawing && !_mesa_dest_buffer_exists(ctx, format)) || + (reading && !_mesa_source_buffer_exists(ctx, format))) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "gl%sPixels(no stencil buffer)", readDraw); + return GL_TRUE; + } + break; + case GL_DEPTH_COMPONENT: + if ((drawing && !_mesa_dest_buffer_exists(ctx, format))) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "gl%sPixels(no depth buffer)", readDraw); + return GL_TRUE; + } + break; + case GL_DEPTH_STENCIL_EXT: + /* Check validity of the type first. */ + switch (type) { + case GL_UNSIGNED_INT_24_8_EXT: + if (!ctx->Extensions.EXT_packed_depth_stencil) { + _mesa_error(ctx, GL_INVALID_ENUM, "gl%sPixels(type)", readDraw); + return GL_TRUE; + } + break; + case GL_FLOAT_32_UNSIGNED_INT_24_8_REV: + if (!ctx->Extensions.ARB_depth_buffer_float) { + _mesa_error(ctx, GL_INVALID_ENUM, "gl%sPixels(type)", readDraw); + return GL_TRUE; + } + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, "gl%sPixels(type)", readDraw); + return GL_TRUE; + } + if ((drawing && !_mesa_dest_buffer_exists(ctx, format)) || + (reading && !_mesa_source_buffer_exists(ctx, format))) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "gl%sPixels(no depth or stencil buffer)", readDraw); + return GL_TRUE; + } + break; + default: + /* this should have been caught in _mesa_is_legal_format_type() */ + _mesa_problem(ctx, "unexpected format in _mesa_%sPixels", readDraw); + return GL_TRUE; + } + + /* no errors */ + return GL_FALSE; +} + + + +void GLAPIENTRY +_mesa_ReadnPixelsARB( GLint x, GLint y, GLsizei width, GLsizei height, + GLenum format, GLenum type, GLsizei bufSize, + GLvoid *pixels ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + FLUSH_CURRENT(ctx, 0); + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glReadPixels(%d, %d, %s, %s, %p)\n", + width, height, + _mesa_lookup_enum_by_nr(format), + _mesa_lookup_enum_by_nr(type), + pixels); + + if (width < 0 || height < 0) { + _mesa_error( ctx, GL_INVALID_VALUE, + "glReadPixels(width=%d height=%d)", width, height ); + return; + } + + if (ctx->NewState) + _mesa_update_state(ctx); + + if (_mesa_error_check_format_type(ctx, format, type, GL_FALSE)) { + /* found an error */ + return; + } + + /* Check that the destination format and source buffer are both + * integer-valued or both non-integer-valued. + */ + if (ctx->Extensions.EXT_texture_integer && _mesa_is_color_format(format)) { + const struct gl_renderbuffer *rb = ctx->ReadBuffer->_ColorReadBuffer; + const GLboolean srcInteger = _mesa_is_format_integer_color(rb->Format); + const GLboolean dstInteger = _mesa_is_integer_format(format); + if (dstInteger != srcInteger) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glReadPixels(integer / non-integer format mismatch"); + return; + } + } + + if (ctx->ReadBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) { + _mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION_EXT, + "glReadPixels(incomplete framebuffer)" ); + return; + } + + if (!_mesa_source_buffer_exists(ctx, format)) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glReadPixels(no readbuffer)"); + return; + } + + if (width == 0 || height == 0) + return; /* nothing to do */ + + if (!_mesa_validate_pbo_access(2, &ctx->Pack, width, height, 1, + format, type, bufSize, pixels)) { + if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glReadPixels(out of bounds PBO access)"); + } else { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glReadnPixelsARB(out of bounds access:" + " bufSize (%d) is too small)", bufSize); + } + return; + } + + if (_mesa_is_bufferobj(ctx->Pack.BufferObj) && + _mesa_bufferobj_mapped(ctx->Pack.BufferObj)) { + /* buffer is mapped - that's an error */ + _mesa_error(ctx, GL_INVALID_OPERATION, "glReadPixels(PBO is mapped)"); + return; + } + + ctx->Driver.ReadPixels(ctx, x, y, width, height, + format, type, &ctx->Pack, pixels); +} + +void GLAPIENTRY +_mesa_ReadPixels( GLint x, GLint y, GLsizei width, GLsizei height, + GLenum format, GLenum type, GLvoid *pixels ) +{ + _mesa_ReadnPixelsARB(x, y, width, height, format, type, INT_MAX, pixels); +} diff --git a/mesalib/src/mesa/main/readpix.h b/mesalib/src/mesa/main/readpix.h index dceac7c6e..f6bb3d6e2 100644 --- a/mesalib/src/mesa/main/readpix.h +++ b/mesalib/src/mesa/main/readpix.h @@ -1,47 +1,47 @@ -/* - * 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. - */ - - -#ifndef READPIXELS_H -#define READPIXELS_H - - -#include "glheader.h" - -struct gl_context; - -extern GLboolean -_mesa_error_check_format_type(struct gl_context *ctx, GLenum format, GLenum type, - GLboolean drawing); - -extern void GLAPIENTRY -_mesa_ReadPixels( GLint x, GLint y, GLsizei width, GLsizei height, - GLenum format, GLenum type, GLvoid *pixels ); - -extern void GLAPIENTRY -_mesa_ReadnPixelsARB( GLint x, GLint y, GLsizei width, GLsizei height, - GLenum format, GLenum type, GLsizei bufSize, - GLvoid *pixels ); - -#endif +/* + * 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. + */ + + +#ifndef READPIXELS_H +#define READPIXELS_H + + +#include "glheader.h" + +struct gl_context; + +extern GLboolean +_mesa_error_check_format_type(struct gl_context *ctx, GLenum format, GLenum type, + GLboolean drawing); + +extern void GLAPIENTRY +_mesa_ReadPixels( GLint x, GLint y, GLsizei width, GLsizei height, + GLenum format, GLenum type, GLvoid *pixels ); + +extern void GLAPIENTRY +_mesa_ReadnPixelsARB( GLint x, GLint y, GLsizei width, GLsizei height, + GLenum format, GLenum type, GLsizei bufSize, + GLvoid *pixels ); + +#endif diff --git a/mesalib/src/mesa/main/remap_helper.h b/mesalib/src/mesa/main/remap_helper.h index 5f0023767..9460bf9d8 100644 --- a/mesalib/src/mesa/main/remap_helper.h +++ b/mesalib/src/mesa/main/remap_helper.h @@ -1,7004 +1,7004 @@ -/* DO NOT EDIT - This file generated automatically by remap_helper.py (from Mesa) script */ - -/* - * Copyright (C) 2009 Chia-I Wu - * 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, sub license, - * 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 (including the next - * paragraph) 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 NON-INFRINGEMENT. IN NO EVENT SHALL - * Chia-I Wu, - * AND/OR THEIR SUPPLIERS 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 "main/dispatch.h" -#include "main/remap.h" - -/* this is internal to remap.c */ -#ifdef need_MESA_remap_table - -static const char _mesa_function_pool[] = - /* _mesa_function_pool[0]: MapGrid1d (offset 224) */ - "idd\0" - "glMapGrid1d\0" - "\0" - /* _mesa_function_pool[17]: UniformMatrix3fvARB (will be remapped) */ - "iiip\0" - "glUniformMatrix3fv\0" - "glUniformMatrix3fvARB\0" - "\0" - /* _mesa_function_pool[64]: MapGrid1f (offset 225) */ - "iff\0" - "glMapGrid1f\0" - "\0" - /* _mesa_function_pool[81]: VertexAttribI2iEXT (will be remapped) */ - "iii\0" - "glVertexAttribI2iEXT\0" - "glVertexAttribI2i\0" - "\0" - /* _mesa_function_pool[125]: RasterPos4i (offset 82) */ - "iiii\0" - "glRasterPos4i\0" - "\0" - /* _mesa_function_pool[145]: RasterPos4d (offset 78) */ - "dddd\0" - "glRasterPos4d\0" - "\0" - /* _mesa_function_pool[165]: NewList (dynamic) */ - "ii\0" - "glNewList\0" - "\0" - /* _mesa_function_pool[179]: RasterPos4f (offset 80) */ - "ffff\0" - "glRasterPos4f\0" - "\0" - /* _mesa_function_pool[199]: LoadIdentity (offset 290) */ - "\0" - "glLoadIdentity\0" - "\0" - /* _mesa_function_pool[216]: GetCombinerOutputParameterfvNV (will be remapped) */ - "iiip\0" - "glGetCombinerOutputParameterfvNV\0" - "\0" - /* _mesa_function_pool[255]: SampleCoverageARB (will be remapped) */ - "fi\0" - "glSampleCoverage\0" - "glSampleCoverageARB\0" - "\0" - /* _mesa_function_pool[296]: ConvolutionFilter1D (offset 348) */ - "iiiiip\0" - "glConvolutionFilter1D\0" - "glConvolutionFilter1DEXT\0" - "\0" - /* _mesa_function_pool[351]: BeginQueryARB (will be remapped) */ - "ii\0" - "glBeginQuery\0" - "glBeginQueryARB\0" - "\0" - /* _mesa_function_pool[384]: RasterPos3dv (offset 71) */ - "p\0" - "glRasterPos3dv\0" - "\0" - /* _mesa_function_pool[402]: PointParameteriNV (will be remapped) */ - "ii\0" - "glPointParameteri\0" - "glPointParameteriNV\0" - "\0" - /* _mesa_function_pool[444]: GetProgramiv (will be remapped) */ - "iip\0" - "glGetProgramiv\0" - "\0" - /* _mesa_function_pool[464]: MultiTexCoord3sARB (offset 398) */ - "iiii\0" - "glMultiTexCoord3s\0" - "glMultiTexCoord3sARB\0" - "\0" - /* _mesa_function_pool[509]: SecondaryColor3iEXT (will be remapped) */ - "iii\0" - "glSecondaryColor3i\0" - "glSecondaryColor3iEXT\0" - "\0" - /* _mesa_function_pool[555]: WindowPos3fMESA (will be remapped) */ - "fff\0" - "glWindowPos3f\0" - "glWindowPos3fARB\0" - "glWindowPos3fMESA\0" - "\0" - /* _mesa_function_pool[609]: TexCoord1iv (offset 99) */ - "p\0" - "glTexCoord1iv\0" - "\0" - /* _mesa_function_pool[626]: TexCoord4sv (offset 125) */ - "p\0" - "glTexCoord4sv\0" - "\0" - /* _mesa_function_pool[643]: RasterPos4s (offset 84) */ - "iiii\0" - "glRasterPos4s\0" - "\0" - /* _mesa_function_pool[663]: PixelTexGenParameterfvSGIS (will be remapped) */ - "ip\0" - "glPixelTexGenParameterfvSGIS\0" - "\0" - /* _mesa_function_pool[696]: ActiveTextureARB (offset 374) */ - "i\0" - "glActiveTexture\0" - "glActiveTextureARB\0" - "\0" - /* _mesa_function_pool[734]: BlitFramebufferEXT (will be remapped) */ - "iiiiiiiiii\0" - "glBlitFramebuffer\0" - "glBlitFramebufferEXT\0" - "\0" - /* _mesa_function_pool[785]: TexCoord1f (offset 96) */ - "f\0" - "glTexCoord1f\0" - "\0" - /* _mesa_function_pool[801]: TexCoord1d (offset 94) */ - "d\0" - "glTexCoord1d\0" - "\0" - /* _mesa_function_pool[817]: VertexAttrib4ubvNV (will be remapped) */ - "ip\0" - "glVertexAttrib4ubvNV\0" - "\0" - /* _mesa_function_pool[842]: TexCoord1i (offset 98) */ - "i\0" - "glTexCoord1i\0" - "\0" - /* _mesa_function_pool[858]: GetProgramNamedParameterdvNV (will be remapped) */ - "iipp\0" - "glGetProgramNamedParameterdvNV\0" - "\0" - /* _mesa_function_pool[895]: Histogram (offset 367) */ - "iiii\0" - "glHistogram\0" - "glHistogramEXT\0" - "\0" - /* _mesa_function_pool[928]: TexCoord1s (offset 100) */ - "i\0" - "glTexCoord1s\0" - "\0" - /* _mesa_function_pool[944]: GetMapfv (offset 267) */ - "iip\0" - "glGetMapfv\0" - "\0" - /* _mesa_function_pool[960]: EvalCoord1f (offset 230) */ - "f\0" - "glEvalCoord1f\0" - "\0" - /* _mesa_function_pool[977]: FramebufferTexture (will be remapped) */ - "iiii\0" - "glFramebufferTexture\0" - "\0" - /* _mesa_function_pool[1004]: GetGraphicsResetStatusARB (will be remapped) */ - "\0" - "glGetGraphicsResetStatusARB\0" - "\0" - /* _mesa_function_pool[1034]: TexImage4DSGIS (dynamic) */ - "iiiiiiiiiip\0" - "glTexImage4DSGIS\0" - "\0" - /* _mesa_function_pool[1064]: PolygonStipple (offset 175) */ - "p\0" - "glPolygonStipple\0" - "\0" - /* _mesa_function_pool[1084]: WindowPos2dvMESA (will be remapped) */ - "p\0" - "glWindowPos2dv\0" - "glWindowPos2dvARB\0" - "glWindowPos2dvMESA\0" - "\0" - /* _mesa_function_pool[1139]: ReplacementCodeuiColor3fVertex3fvSUN (dynamic) */ - "ppp\0" - "glReplacementCodeuiColor3fVertex3fvSUN\0" - "\0" - /* _mesa_function_pool[1183]: BlendEquationSeparateEXT (will be remapped) */ - "ii\0" - "glBlendEquationSeparate\0" - "glBlendEquationSeparateEXT\0" - "glBlendEquationSeparateATI\0" - "\0" - /* _mesa_function_pool[1265]: ListParameterfSGIX (dynamic) */ - "iif\0" - "glListParameterfSGIX\0" - "\0" - /* _mesa_function_pool[1291]: SecondaryColor3bEXT (will be remapped) */ - "iii\0" - "glSecondaryColor3b\0" - "glSecondaryColor3bEXT\0" - "\0" - /* _mesa_function_pool[1337]: TexCoord4fColor4fNormal3fVertex4fvSUN (dynamic) */ - "pppp\0" - "glTexCoord4fColor4fNormal3fVertex4fvSUN\0" - "\0" - /* _mesa_function_pool[1383]: GetnPolygonStippleARB (will be remapped) */ - "ip\0" - "glGetnPolygonStippleARB\0" - "\0" - /* _mesa_function_pool[1411]: GetPixelMapfv (offset 271) */ - "ip\0" - "glGetPixelMapfv\0" - "\0" - /* _mesa_function_pool[1431]: Color3uiv (offset 22) */ - "p\0" - "glColor3uiv\0" - "\0" - /* _mesa_function_pool[1446]: IsEnabled (offset 286) */ - "i\0" - "glIsEnabled\0" - "\0" - /* _mesa_function_pool[1461]: VertexAttrib4svNV (will be remapped) */ - "ip\0" - "glVertexAttrib4svNV\0" - "\0" - /* _mesa_function_pool[1485]: EvalCoord2fv (offset 235) */ - "p\0" - "glEvalCoord2fv\0" - "\0" - /* _mesa_function_pool[1503]: GetBufferSubDataARB (will be remapped) */ - "iiip\0" - "glGetBufferSubData\0" - "glGetBufferSubDataARB\0" - "\0" - /* _mesa_function_pool[1550]: BufferSubDataARB (will be remapped) */ - "iiip\0" - "glBufferSubData\0" - "glBufferSubDataARB\0" - "\0" - /* _mesa_function_pool[1591]: TexCoord2fColor4ubVertex3fvSUN (dynamic) */ - "ppp\0" - "glTexCoord2fColor4ubVertex3fvSUN\0" - "\0" - /* _mesa_function_pool[1629]: AttachShader (will be remapped) */ - "ii\0" - "glAttachShader\0" - "\0" - /* _mesa_function_pool[1648]: GetCombinerInputParameterfvNV (will be remapped) */ - "iiiip\0" - "glGetCombinerInputParameterfvNV\0" - "\0" - /* _mesa_function_pool[1687]: MultiTexCoordP2ui (will be remapped) */ - "iii\0" - "glMultiTexCoordP2ui\0" - "\0" - /* _mesa_function_pool[1712]: VertexAttrib2fARB (will be remapped) */ - "iff\0" - "glVertexAttrib2f\0" - "glVertexAttrib2fARB\0" - "\0" - /* _mesa_function_pool[1754]: GetDebugLogLengthMESA (dynamic) */ - "iii\0" - "glGetDebugLogLengthMESA\0" - "\0" - /* _mesa_function_pool[1783]: GetMapiv (offset 268) */ - "iip\0" - "glGetMapiv\0" - "\0" - /* _mesa_function_pool[1799]: VertexAttrib3fARB (will be remapped) */ - "ifff\0" - "glVertexAttrib3f\0" - "glVertexAttrib3fARB\0" - "\0" - /* _mesa_function_pool[1842]: Indexubv (offset 316) */ - "p\0" - "glIndexubv\0" - "\0" - /* _mesa_function_pool[1856]: GetQueryivARB (will be remapped) */ - "iip\0" - "glGetQueryiv\0" - "glGetQueryivARB\0" - "\0" - /* _mesa_function_pool[1890]: TexImage3D (offset 371) */ - "iiiiiiiiip\0" - "glTexImage3D\0" - "glTexImage3DEXT\0" - "\0" - /* _mesa_function_pool[1931]: BindFragDataLocationEXT (will be remapped) */ - "iip\0" - "glBindFragDataLocationEXT\0" - "glBindFragDataLocation\0" - "\0" - /* _mesa_function_pool[1985]: TexCoordP4ui (will be remapped) */ - "ii\0" - "glTexCoordP4ui\0" - "\0" - /* _mesa_function_pool[2004]: ReplacementCodeuiVertex3fvSUN (dynamic) */ - "pp\0" - "glReplacementCodeuiVertex3fvSUN\0" - "\0" - /* _mesa_function_pool[2040]: EdgeFlagPointer (offset 312) */ - "ip\0" - "glEdgeFlagPointer\0" - "\0" - /* _mesa_function_pool[2062]: Color3ubv (offset 20) */ - "p\0" - "glColor3ubv\0" - "\0" - /* _mesa_function_pool[2077]: GetQueryObjectivARB (will be remapped) */ - "iip\0" - "glGetQueryObjectiv\0" - "glGetQueryObjectivARB\0" - "\0" - /* _mesa_function_pool[2123]: Vertex3dv (offset 135) */ - "p\0" - "glVertex3dv\0" - "\0" - /* _mesa_function_pool[2138]: ReplacementCodeuiTexCoord2fVertex3fvSUN (dynamic) */ - "ppp\0" - "glReplacementCodeuiTexCoord2fVertex3fvSUN\0" - "\0" - /* _mesa_function_pool[2185]: CompressedTexSubImage2DARB (will be remapped) */ - "iiiiiiiip\0" - "glCompressedTexSubImage2D\0" - "glCompressedTexSubImage2DARB\0" - "\0" - /* _mesa_function_pool[2251]: CombinerOutputNV (will be remapped) */ - "iiiiiiiiii\0" - "glCombinerOutputNV\0" - "\0" - /* _mesa_function_pool[2282]: VertexAttribs3fvNV (will be remapped) */ - "iip\0" - "glVertexAttribs3fvNV\0" - "\0" - /* _mesa_function_pool[2308]: GetnMapivARB (will be remapped) */ - "iiip\0" - "glGetnMapivARB\0" - "\0" - /* _mesa_function_pool[2329]: Uniform2fARB (will be remapped) */ - "iff\0" - "glUniform2f\0" - "glUniform2fARB\0" - "\0" - /* _mesa_function_pool[2361]: LightModeliv (offset 166) */ - "ip\0" - "glLightModeliv\0" - "\0" - /* _mesa_function_pool[2380]: VertexAttrib1svARB (will be remapped) */ - "ip\0" - "glVertexAttrib1sv\0" - "glVertexAttrib1svARB\0" - "\0" - /* _mesa_function_pool[2423]: VertexAttribs1dvNV (will be remapped) */ - "iip\0" - "glVertexAttribs1dvNV\0" - "\0" - /* _mesa_function_pool[2449]: VertexP3ui (will be remapped) */ - "ii\0" - "glVertexP3ui\0" - "\0" - /* _mesa_function_pool[2466]: Uniform2ivARB (will be remapped) */ - "iip\0" - "glUniform2iv\0" - "glUniform2ivARB\0" - "\0" - /* _mesa_function_pool[2500]: GetImageTransformParameterfvHP (dynamic) */ - "iip\0" - "glGetImageTransformParameterfvHP\0" - "\0" - /* _mesa_function_pool[2538]: Normal3bv (offset 53) */ - "p\0" - "glNormal3bv\0" - "\0" - /* _mesa_function_pool[2553]: TexGeniv (offset 193) */ - "iip\0" - "glTexGeniv\0" - "\0" - /* _mesa_function_pool[2569]: TexCoordP1uiv (will be remapped) */ - "ip\0" - "glTexCoordP1uiv\0" - "\0" - /* _mesa_function_pool[2589]: WeightubvARB (dynamic) */ - "ip\0" - "glWeightubvARB\0" - "\0" - /* _mesa_function_pool[2608]: VertexAttrib1fvNV (will be remapped) */ - "ip\0" - "glVertexAttrib1fvNV\0" - "\0" - /* _mesa_function_pool[2632]: Vertex3iv (offset 139) */ - "p\0" - "glVertex3iv\0" - "\0" - /* _mesa_function_pool[2647]: CopyConvolutionFilter1D (offset 354) */ - "iiiii\0" - "glCopyConvolutionFilter1D\0" - "glCopyConvolutionFilter1DEXT\0" - "\0" - /* _mesa_function_pool[2709]: VertexAttribI1uiEXT (will be remapped) */ - "ii\0" - "glVertexAttribI1uiEXT\0" - "glVertexAttribI1ui\0" - "\0" - /* _mesa_function_pool[2754]: ReplacementCodeuiNormal3fVertex3fSUN (dynamic) */ - "iffffff\0" - "glReplacementCodeuiNormal3fVertex3fSUN\0" - "\0" - /* _mesa_function_pool[2802]: TexCoordP1ui (will be remapped) */ - "ii\0" - "glTexCoordP1ui\0" - "\0" - /* _mesa_function_pool[2821]: DeleteSync (will be remapped) */ - "i\0" - "glDeleteSync\0" - "\0" - /* _mesa_function_pool[2837]: FragmentMaterialfvSGIX (dynamic) */ - "iip\0" - "glFragmentMaterialfvSGIX\0" - "\0" - /* _mesa_function_pool[2867]: BlendColor (offset 336) */ - "ffff\0" - "glBlendColor\0" - "glBlendColorEXT\0" - "\0" - /* _mesa_function_pool[2902]: UniformMatrix4fvARB (will be remapped) */ - "iiip\0" - "glUniformMatrix4fv\0" - "glUniformMatrix4fvARB\0" - "\0" - /* _mesa_function_pool[2949]: DeleteVertexArraysAPPLE (will be remapped) */ - "ip\0" - "glDeleteVertexArrays\0" - "glDeleteVertexArraysAPPLE\0" - "\0" - /* _mesa_function_pool[3000]: TexBuffer (will be remapped) */ - "iii\0" - "glTexBuffer\0" - "\0" - /* _mesa_function_pool[3017]: ReadInstrumentsSGIX (dynamic) */ - "i\0" - "glReadInstrumentsSGIX\0" - "\0" - /* _mesa_function_pool[3042]: CallLists (offset 3) */ - "iip\0" - "glCallLists\0" - "\0" - /* _mesa_function_pool[3059]: DeformationMap3dSGIX (dynamic) */ - "iddiiddiiddiip\0" - "glDeformationMap3dSGIX\0" - "\0" - /* _mesa_function_pool[3098]: UniformMatrix2x4fv (will be remapped) */ - "iiip\0" - "glUniformMatrix2x4fv\0" - "\0" - /* _mesa_function_pool[3125]: ReadnPixelsARB (will be remapped) */ - "iiiiiiip\0" - "glReadnPixelsARB\0" - "\0" - /* _mesa_function_pool[3152]: Color4ubVertex3fvSUN (dynamic) */ - "pp\0" - "glColor4ubVertex3fvSUN\0" - "\0" - /* _mesa_function_pool[3179]: Normal3iv (offset 59) */ - "p\0" - "glNormal3iv\0" - "\0" - /* _mesa_function_pool[3194]: PassThrough (offset 199) */ - "f\0" - "glPassThrough\0" - "\0" - /* _mesa_function_pool[3211]: GetnPixelMapusvARB (will be remapped) */ - "iip\0" - "glGetnPixelMapusvARB\0" - "\0" - /* _mesa_function_pool[3237]: TexParameterIivEXT (will be remapped) */ - "iip\0" - "glTexParameterIivEXT\0" - "glTexParameterIiv\0" - "\0" - /* _mesa_function_pool[3281]: FramebufferTextureLayerEXT (will be remapped) */ - "iiiii\0" - "glFramebufferTextureLayer\0" - "glFramebufferTextureLayerARB\0" - "glFramebufferTextureLayerEXT\0" - "\0" - /* _mesa_function_pool[3372]: GetListParameterfvSGIX (dynamic) */ - "iip\0" - "glGetListParameterfvSGIX\0" - "\0" - /* _mesa_function_pool[3402]: Viewport (offset 305) */ - "iiii\0" - "glViewport\0" - "\0" - /* _mesa_function_pool[3419]: VertexAttrib4NusvARB (will be remapped) */ - "ip\0" - "glVertexAttrib4Nusv\0" - "glVertexAttrib4NusvARB\0" - "\0" - /* _mesa_function_pool[3466]: VertexP4uiv (will be remapped) */ - "ip\0" - "glVertexP4uiv\0" - "\0" - /* _mesa_function_pool[3484]: VertexAttribP3ui (will be remapped) */ - "iiii\0" - "glVertexAttribP3ui\0" - "\0" - /* _mesa_function_pool[3509]: WindowPos4svMESA (will be remapped) */ - "p\0" - "glWindowPos4svMESA\0" - "\0" - /* _mesa_function_pool[3531]: CreateProgramObjectARB (will be remapped) */ - "\0" - "glCreateProgramObjectARB\0" - "\0" - /* _mesa_function_pool[3558]: DeleteTransformFeedbacks (will be remapped) */ - "ip\0" - "glDeleteTransformFeedbacks\0" - "\0" - /* _mesa_function_pool[3589]: UniformMatrix4x3fv (will be remapped) */ - "iiip\0" - "glUniformMatrix4x3fv\0" - "\0" - /* _mesa_function_pool[3616]: PrioritizeTextures (offset 331) */ - "ipp\0" - "glPrioritizeTextures\0" - "glPrioritizeTexturesEXT\0" - "\0" - /* _mesa_function_pool[3666]: VertexAttribI3uiEXT (will be remapped) */ - "iiii\0" - "glVertexAttribI3uiEXT\0" - "glVertexAttribI3ui\0" - "\0" - /* _mesa_function_pool[3713]: AsyncMarkerSGIX (dynamic) */ - "i\0" - "glAsyncMarkerSGIX\0" - "\0" - /* _mesa_function_pool[3734]: GlobalAlphaFactorubSUN (dynamic) */ - "i\0" - "glGlobalAlphaFactorubSUN\0" - "\0" - /* _mesa_function_pool[3762]: ClearColorIuiEXT (will be remapped) */ - "iiii\0" - "glClearColorIuiEXT\0" - "\0" - /* _mesa_function_pool[3787]: ClearDebugLogMESA (dynamic) */ - "iii\0" - "glClearDebugLogMESA\0" - "\0" - /* _mesa_function_pool[3812]: Uniform4uiEXT (will be remapped) */ - "iiiii\0" - "glUniform4uiEXT\0" - "glUniform4ui\0" - "\0" - /* _mesa_function_pool[3848]: ResetHistogram (offset 369) */ - "i\0" - "glResetHistogram\0" - "glResetHistogramEXT\0" - "\0" - /* _mesa_function_pool[3888]: GetProgramNamedParameterfvNV (will be remapped) */ - "iipp\0" - "glGetProgramNamedParameterfvNV\0" - "\0" - /* _mesa_function_pool[3925]: PointParameterfEXT (will be remapped) */ - "if\0" - "glPointParameterf\0" - "glPointParameterfARB\0" - "glPointParameterfEXT\0" - "glPointParameterfSGIS\0" - "\0" - /* _mesa_function_pool[4011]: MultiTexCoordP4uiv (will be remapped) */ - "iip\0" - "glMultiTexCoordP4uiv\0" - "\0" - /* _mesa_function_pool[4037]: LoadIdentityDeformationMapSGIX (dynamic) */ - "i\0" - "glLoadIdentityDeformationMapSGIX\0" - "\0" - /* _mesa_function_pool[4073]: GenFencesNV (will be remapped) */ - "ip\0" - "glGenFencesNV\0" - "\0" - /* _mesa_function_pool[4091]: ImageTransformParameterfHP (dynamic) */ - "iif\0" - "glImageTransformParameterfHP\0" - "\0" - /* _mesa_function_pool[4125]: MatrixIndexusvARB (dynamic) */ - "ip\0" - "glMatrixIndexusvARB\0" - "\0" - /* _mesa_function_pool[4149]: DrawElementsBaseVertex (will be remapped) */ - "iiipi\0" - "glDrawElementsBaseVertex\0" - "\0" - /* _mesa_function_pool[4181]: DisableVertexAttribArrayARB (will be remapped) */ - "i\0" - "glDisableVertexAttribArray\0" - "glDisableVertexAttribArrayARB\0" - "\0" - /* _mesa_function_pool[4241]: VertexAttribI4ubvEXT (will be remapped) */ - "ip\0" - "glVertexAttribI4ubvEXT\0" - "glVertexAttribI4ubv\0" - "\0" - /* _mesa_function_pool[4288]: GetnConvolutionFilterARB (will be remapped) */ - "iiiip\0" - "glGetnConvolutionFilterARB\0" - "\0" - /* _mesa_function_pool[4322]: TexCoord2sv (offset 109) */ - "p\0" - "glTexCoord2sv\0" - "\0" - /* _mesa_function_pool[4339]: ColorP4uiv (will be remapped) */ - "ip\0" - "glColorP4uiv\0" - "\0" - /* _mesa_function_pool[4356]: Vertex4dv (offset 143) */ - "p\0" - "glVertex4dv\0" - "\0" - /* _mesa_function_pool[4371]: StencilMaskSeparate (will be remapped) */ - "ii\0" - "glStencilMaskSeparate\0" - "\0" - /* _mesa_function_pool[4397]: ProgramLocalParameter4dARB (will be remapped) */ - "iidddd\0" - "glProgramLocalParameter4dARB\0" - "\0" - /* _mesa_function_pool[4434]: CompressedTexImage3DARB (will be remapped) */ - "iiiiiiiip\0" - "glCompressedTexImage3D\0" - "glCompressedTexImage3DARB\0" - "\0" - /* _mesa_function_pool[4494]: Color3sv (offset 18) */ - "p\0" - "glColor3sv\0" - "\0" - /* _mesa_function_pool[4508]: GetConvolutionParameteriv (offset 358) */ - "iip\0" - "glGetConvolutionParameteriv\0" - "glGetConvolutionParameterivEXT\0" - "\0" - /* _mesa_function_pool[4572]: DeleteSamplers (will be remapped) */ - "ip\0" - "glDeleteSamplers\0" - "\0" - /* _mesa_function_pool[4593]: VertexAttrib1fARB (will be remapped) */ - "if\0" - "glVertexAttrib1f\0" - "glVertexAttrib1fARB\0" - "\0" - /* _mesa_function_pool[4634]: Vertex2dv (offset 127) */ - "p\0" - "glVertex2dv\0" - "\0" - /* _mesa_function_pool[4649]: TestFenceNV (will be remapped) */ - "i\0" - "glTestFenceNV\0" - "\0" - /* _mesa_function_pool[4666]: MultiTexCoord1fvARB (offset 379) */ - "ip\0" - "glMultiTexCoord1fv\0" - "glMultiTexCoord1fvARB\0" - "\0" - /* _mesa_function_pool[4711]: TexCoord3iv (offset 115) */ - "p\0" - "glTexCoord3iv\0" - "\0" - /* _mesa_function_pool[4728]: Uniform2uivEXT (will be remapped) */ - "iip\0" - "glUniform2uivEXT\0" - "glUniform2uiv\0" - "\0" - /* _mesa_function_pool[4764]: ColorFragmentOp2ATI (will be remapped) */ - "iiiiiiiiii\0" - "glColorFragmentOp2ATI\0" - "\0" - /* _mesa_function_pool[4798]: SecondaryColorPointerListIBM (dynamic) */ - "iiipi\0" - "glSecondaryColorPointerListIBM\0" - "\0" - /* _mesa_function_pool[4836]: GetPixelTexGenParameterivSGIS (will be remapped) */ - "ip\0" - "glGetPixelTexGenParameterivSGIS\0" - "\0" - /* _mesa_function_pool[4872]: Color3fv (offset 14) */ - "p\0" - "glColor3fv\0" - "\0" - /* _mesa_function_pool[4886]: GetnPixelMapfvARB (will be remapped) */ - "iip\0" - "glGetnPixelMapfvARB\0" - "\0" - /* _mesa_function_pool[4911]: ReplacementCodeubSUN (dynamic) */ - "i\0" - "glReplacementCodeubSUN\0" - "\0" - /* _mesa_function_pool[4937]: FinishAsyncSGIX (dynamic) */ - "p\0" - "glFinishAsyncSGIX\0" - "\0" - /* _mesa_function_pool[4958]: GetnUniformfvARB (will be remapped) */ - "iiip\0" - "glGetnUniformfvARB\0" - "\0" - /* _mesa_function_pool[4983]: GetDebugLogMESA (dynamic) */ - "iiiipp\0" - "glGetDebugLogMESA\0" - "\0" - /* _mesa_function_pool[5009]: FogCoorddEXT (will be remapped) */ - "d\0" - "glFogCoordd\0" - "glFogCoorddEXT\0" - "\0" - /* _mesa_function_pool[5039]: BeginConditionalRenderNV (will be remapped) */ - "ii\0" - "glBeginConditionalRenderNV\0" - "glBeginConditionalRender\0" - "\0" - /* _mesa_function_pool[5095]: Color4ubVertex3fSUN (dynamic) */ - "iiiifff\0" - "glColor4ubVertex3fSUN\0" - "\0" - /* _mesa_function_pool[5126]: FogCoordfEXT (will be remapped) */ - "f\0" - "glFogCoordf\0" - "glFogCoordfEXT\0" - "\0" - /* _mesa_function_pool[5156]: PointSize (offset 173) */ - "f\0" - "glPointSize\0" - "\0" - /* _mesa_function_pool[5171]: VertexAttribI2uivEXT (will be remapped) */ - "ip\0" - "glVertexAttribI2uivEXT\0" - "glVertexAttribI2uiv\0" - "\0" - /* _mesa_function_pool[5218]: TexCoord2fVertex3fSUN (dynamic) */ - "fffff\0" - "glTexCoord2fVertex3fSUN\0" - "\0" - /* _mesa_function_pool[5249]: PopName (offset 200) */ - "\0" - "glPopName\0" - "\0" - /* _mesa_function_pool[5261]: GetSamplerParameterfv (will be remapped) */ - "iip\0" - "glGetSamplerParameterfv\0" - "\0" - /* _mesa_function_pool[5290]: GlobalAlphaFactoriSUN (dynamic) */ - "i\0" - "glGlobalAlphaFactoriSUN\0" - "\0" - /* _mesa_function_pool[5317]: VertexAttrib2dNV (will be remapped) */ - "idd\0" - "glVertexAttrib2dNV\0" - "\0" - /* _mesa_function_pool[5341]: GetProgramInfoLog (will be remapped) */ - "iipp\0" - "glGetProgramInfoLog\0" - "\0" - /* _mesa_function_pool[5367]: VertexP2ui (will be remapped) */ - "ii\0" - "glVertexP2ui\0" - "\0" - /* _mesa_function_pool[5384]: VertexAttrib4NbvARB (will be remapped) */ - "ip\0" - "glVertexAttrib4Nbv\0" - "glVertexAttrib4NbvARB\0" - "\0" - /* _mesa_function_pool[5429]: GetActiveAttribARB (will be remapped) */ - "iiipppp\0" - "glGetActiveAttrib\0" - "glGetActiveAttribARB\0" - "\0" - /* _mesa_function_pool[5477]: Vertex4sv (offset 149) */ - "p\0" - "glVertex4sv\0" - "\0" - /* _mesa_function_pool[5492]: VertexAttrib4ubNV (will be remapped) */ - "iiiii\0" - "glVertexAttrib4ubNV\0" - "\0" - /* _mesa_function_pool[5519]: VertexAttribI1ivEXT (will be remapped) */ - "ip\0" - "glVertexAttribI1ivEXT\0" - "glVertexAttribI1iv\0" - "\0" - /* _mesa_function_pool[5564]: ClampColor (will be remapped) */ - "ii\0" - "glClampColor\0" - "\0" - /* _mesa_function_pool[5581]: TextureRangeAPPLE (will be remapped) */ - "iip\0" - "glTextureRangeAPPLE\0" - "\0" - /* _mesa_function_pool[5606]: GetTexEnvfv (offset 276) */ - "iip\0" - "glGetTexEnvfv\0" - "\0" - /* _mesa_function_pool[5625]: VertexAttribP2uiv (will be remapped) */ - "iiip\0" - "glVertexAttribP2uiv\0" - "\0" - /* _mesa_function_pool[5651]: BindTransformFeedback (will be remapped) */ - "ii\0" - "glBindTransformFeedback\0" - "\0" - /* _mesa_function_pool[5679]: TexCoord2fColor4fNormal3fVertex3fSUN (dynamic) */ - "ffffffffffff\0" - "glTexCoord2fColor4fNormal3fVertex3fSUN\0" - "\0" - /* _mesa_function_pool[5732]: Indexub (offset 315) */ - "i\0" - "glIndexub\0" - "\0" - /* _mesa_function_pool[5745]: VertexAttrib4fNV (will be remapped) */ - "iffff\0" - "glVertexAttrib4fNV\0" - "\0" - /* _mesa_function_pool[5771]: TexEnvi (offset 186) */ - "iii\0" - "glTexEnvi\0" - "\0" - /* _mesa_function_pool[5786]: GetClipPlane (offset 259) */ - "ip\0" - "glGetClipPlane\0" - "\0" - /* _mesa_function_pool[5805]: CombinerParameterfvNV (will be remapped) */ - "ip\0" - "glCombinerParameterfvNV\0" - "\0" - /* _mesa_function_pool[5833]: TexCoordP4uiv (will be remapped) */ - "ip\0" - "glTexCoordP4uiv\0" - "\0" - /* _mesa_function_pool[5853]: VertexAttribs3dvNV (will be remapped) */ - "iip\0" - "glVertexAttribs3dvNV\0" - "\0" - /* _mesa_function_pool[5879]: VertexAttribI2uiEXT (will be remapped) */ - "iii\0" - "glVertexAttribI2uiEXT\0" - "glVertexAttribI2ui\0" - "\0" - /* _mesa_function_pool[5925]: VertexAttribs4fvNV (will be remapped) */ - "iip\0" - "glVertexAttribs4fvNV\0" - "\0" - /* _mesa_function_pool[5951]: VertexArrayRangeNV (will be remapped) */ - "ip\0" - "glVertexArrayRangeNV\0" - "\0" - /* _mesa_function_pool[5976]: FragmentLightiSGIX (dynamic) */ - "iii\0" - "glFragmentLightiSGIX\0" - "\0" - /* _mesa_function_pool[6002]: PolygonOffsetEXT (will be remapped) */ - "ff\0" - "glPolygonOffsetEXT\0" - "\0" - /* _mesa_function_pool[6025]: VertexAttribI4uivEXT (will be remapped) */ - "ip\0" - "glVertexAttribI4uivEXT\0" - "glVertexAttribI4uiv\0" - "\0" - /* _mesa_function_pool[6072]: PollAsyncSGIX (dynamic) */ - "p\0" - "glPollAsyncSGIX\0" - "\0" - /* _mesa_function_pool[6091]: DeleteFragmentShaderATI (will be remapped) */ - "i\0" - "glDeleteFragmentShaderATI\0" - "\0" - /* _mesa_function_pool[6120]: Scaled (offset 301) */ - "ddd\0" - "glScaled\0" - "\0" - /* _mesa_function_pool[6134]: ResumeTransformFeedback (will be remapped) */ - "\0" - "glResumeTransformFeedback\0" - "\0" - /* _mesa_function_pool[6162]: Scalef (offset 302) */ - "fff\0" - "glScalef\0" - "\0" - /* _mesa_function_pool[6176]: TexCoord2fNormal3fVertex3fvSUN (dynamic) */ - "ppp\0" - "glTexCoord2fNormal3fVertex3fvSUN\0" - "\0" - /* _mesa_function_pool[6214]: ProgramEnvParameters4fvEXT (will be remapped) */ - "iiip\0" - "glProgramEnvParameters4fvEXT\0" - "\0" - /* _mesa_function_pool[6249]: MultTransposeMatrixdARB (will be remapped) */ - "p\0" - "glMultTransposeMatrixd\0" - "glMultTransposeMatrixdARB\0" - "\0" - /* _mesa_function_pool[6301]: ObjectUnpurgeableAPPLE (will be remapped) */ - "iii\0" - "glObjectUnpurgeableAPPLE\0" - "\0" - /* _mesa_function_pool[6331]: TexCoordP3ui (will be remapped) */ - "ii\0" - "glTexCoordP3ui\0" - "\0" - /* _mesa_function_pool[6350]: AlphaFunc (offset 240) */ - "if\0" - "glAlphaFunc\0" - "\0" - /* _mesa_function_pool[6366]: WindowPos2svMESA (will be remapped) */ - "p\0" - "glWindowPos2sv\0" - "glWindowPos2svARB\0" - "glWindowPos2svMESA\0" - "\0" - /* _mesa_function_pool[6421]: EdgeFlag (offset 41) */ - "i\0" - "glEdgeFlag\0" - "\0" - /* _mesa_function_pool[6435]: TexCoord2iv (offset 107) */ - "p\0" - "glTexCoord2iv\0" - "\0" - /* _mesa_function_pool[6452]: CompressedTexImage1DARB (will be remapped) */ - "iiiiiip\0" - "glCompressedTexImage1D\0" - "glCompressedTexImage1DARB\0" - "\0" - /* _mesa_function_pool[6510]: Rotated (offset 299) */ - "dddd\0" - "glRotated\0" - "\0" - /* _mesa_function_pool[6526]: GetTexParameterIuivEXT (will be remapped) */ - "iip\0" - "glGetTexParameterIuivEXT\0" - "glGetTexParameterIuiv\0" - "\0" - /* _mesa_function_pool[6578]: VertexAttrib2sNV (will be remapped) */ - "iii\0" - "glVertexAttrib2sNV\0" - "\0" - /* _mesa_function_pool[6602]: ReadPixels (offset 256) */ - "iiiiiip\0" - "glReadPixels\0" - "\0" - /* _mesa_function_pool[6624]: VertexAttribDivisorARB (will be remapped) */ - "ii\0" - "glVertexAttribDivisorARB\0" - "\0" - /* _mesa_function_pool[6653]: EdgeFlagv (offset 42) */ - "p\0" - "glEdgeFlagv\0" - "\0" - /* _mesa_function_pool[6668]: NormalPointerListIBM (dynamic) */ - "iipi\0" - "glNormalPointerListIBM\0" - "\0" - /* _mesa_function_pool[6697]: IndexPointerEXT (will be remapped) */ - "iiip\0" - "glIndexPointerEXT\0" - "\0" - /* _mesa_function_pool[6721]: Color4iv (offset 32) */ - "p\0" - "glColor4iv\0" - "\0" - /* _mesa_function_pool[6735]: TexParameterf (offset 178) */ - "iif\0" - "glTexParameterf\0" - "\0" - /* _mesa_function_pool[6756]: TexParameteri (offset 180) */ - "iii\0" - "glTexParameteri\0" - "\0" - /* _mesa_function_pool[6777]: NormalPointerEXT (will be remapped) */ - "iiip\0" - "glNormalPointerEXT\0" - "\0" - /* _mesa_function_pool[6802]: MultiTexCoord3dARB (offset 392) */ - "iddd\0" - "glMultiTexCoord3d\0" - "glMultiTexCoord3dARB\0" - "\0" - /* _mesa_function_pool[6847]: MultiTexCoord2iARB (offset 388) */ - "iii\0" - "glMultiTexCoord2i\0" - "glMultiTexCoord2iARB\0" - "\0" - /* _mesa_function_pool[6891]: DrawPixels (offset 257) */ - "iiiip\0" - "glDrawPixels\0" - "\0" - /* _mesa_function_pool[6911]: ReplacementCodeuiTexCoord2fNormal3fVertex3fSUN (dynamic) */ - "iffffffff\0" - "glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN\0" - "\0" - /* _mesa_function_pool[6971]: MultiTexCoord2svARB (offset 391) */ - "ip\0" - "glMultiTexCoord2sv\0" - "glMultiTexCoord2svARB\0" - "\0" - /* _mesa_function_pool[7016]: ReplacementCodeubvSUN (dynamic) */ - "p\0" - "glReplacementCodeubvSUN\0" - "\0" - /* _mesa_function_pool[7043]: Uniform3iARB (will be remapped) */ - "iiii\0" - "glUniform3i\0" - "glUniform3iARB\0" - "\0" - /* _mesa_function_pool[7076]: DrawTransformFeedback (will be remapped) */ - "ii\0" - "glDrawTransformFeedback\0" - "\0" - /* _mesa_function_pool[7104]: DrawElementsInstancedARB (will be remapped) */ - "iiipi\0" - "glDrawElementsInstancedARB\0" - "glDrawElementsInstancedEXT\0" - "glDrawElementsInstanced\0" - "\0" - /* _mesa_function_pool[7189]: GetShaderInfoLog (will be remapped) */ - "iipp\0" - "glGetShaderInfoLog\0" - "\0" - /* _mesa_function_pool[7214]: WeightivARB (dynamic) */ - "ip\0" - "glWeightivARB\0" - "\0" - /* _mesa_function_pool[7232]: PollInstrumentsSGIX (dynamic) */ - "p\0" - "glPollInstrumentsSGIX\0" - "\0" - /* _mesa_function_pool[7257]: GlobalAlphaFactordSUN (dynamic) */ - "d\0" - "glGlobalAlphaFactordSUN\0" - "\0" - /* _mesa_function_pool[7284]: GetFinalCombinerInputParameterfvNV (will be remapped) */ - "iip\0" - "glGetFinalCombinerInputParameterfvNV\0" - "\0" - /* _mesa_function_pool[7326]: GenerateMipmapEXT (will be remapped) */ - "i\0" - "glGenerateMipmap\0" - "glGenerateMipmapEXT\0" - "\0" - /* _mesa_function_pool[7366]: GenLists (offset 5) */ - "i\0" - "glGenLists\0" - "\0" - /* _mesa_function_pool[7380]: DepthRangef (will be remapped) */ - "ff\0" - "glDepthRangef\0" - "\0" - /* _mesa_function_pool[7398]: GetMapAttribParameterivNV (dynamic) */ - "iiip\0" - "glGetMapAttribParameterivNV\0" - "\0" - /* _mesa_function_pool[7432]: CreateShaderObjectARB (will be remapped) */ - "i\0" - "glCreateShaderObjectARB\0" - "\0" - /* _mesa_function_pool[7459]: GetSharpenTexFuncSGIS (dynamic) */ - "ip\0" - "glGetSharpenTexFuncSGIS\0" - "\0" - /* _mesa_function_pool[7487]: BufferDataARB (will be remapped) */ - "iipi\0" - "glBufferData\0" - "glBufferDataARB\0" - "\0" - /* _mesa_function_pool[7522]: FlushVertexArrayRangeNV (will be remapped) */ - "\0" - "glFlushVertexArrayRangeNV\0" - "\0" - /* _mesa_function_pool[7550]: MapGrid2d (offset 226) */ - "iddidd\0" - "glMapGrid2d\0" - "\0" - /* _mesa_function_pool[7570]: MapGrid2f (offset 227) */ - "iffiff\0" - "glMapGrid2f\0" - "\0" - /* _mesa_function_pool[7590]: SampleMapATI (will be remapped) */ - "iii\0" - "glSampleMapATI\0" - "\0" - /* _mesa_function_pool[7610]: VertexPointerEXT (will be remapped) */ - "iiiip\0" - "glVertexPointerEXT\0" - "\0" - /* _mesa_function_pool[7636]: GetTexFilterFuncSGIS (dynamic) */ - "iip\0" - "glGetTexFilterFuncSGIS\0" - "\0" - /* _mesa_function_pool[7664]: Scissor (offset 176) */ - "iiii\0" - "glScissor\0" - "\0" - /* _mesa_function_pool[7680]: Fogf (offset 153) */ - "if\0" - "glFogf\0" - "\0" - /* _mesa_function_pool[7691]: ReplacementCodeuiColor4ubVertex3fvSUN (dynamic) */ - "ppp\0" - "glReplacementCodeuiColor4ubVertex3fvSUN\0" - "\0" - /* _mesa_function_pool[7736]: TexSubImage1D (offset 332) */ - "iiiiiip\0" - "glTexSubImage1D\0" - "glTexSubImage1DEXT\0" - "\0" - /* _mesa_function_pool[7780]: VertexAttrib1sARB (will be remapped) */ - "ii\0" - "glVertexAttrib1s\0" - "glVertexAttrib1sARB\0" - "\0" - /* _mesa_function_pool[7821]: FenceSync (will be remapped) */ - "ii\0" - "glFenceSync\0" - "\0" - /* _mesa_function_pool[7837]: Color4usv (offset 40) */ - "p\0" - "glColor4usv\0" - "\0" - /* _mesa_function_pool[7852]: Fogi (offset 155) */ - "ii\0" - "glFogi\0" - "\0" - /* _mesa_function_pool[7863]: DepthRange (offset 288) */ - "dd\0" - "glDepthRange\0" - "\0" - /* _mesa_function_pool[7880]: RasterPos3iv (offset 75) */ - "p\0" - "glRasterPos3iv\0" - "\0" - /* _mesa_function_pool[7898]: FinalCombinerInputNV (will be remapped) */ - "iiii\0" - "glFinalCombinerInputNV\0" - "\0" - /* _mesa_function_pool[7927]: TexCoord2i (offset 106) */ - "ii\0" - "glTexCoord2i\0" - "\0" - /* _mesa_function_pool[7944]: PixelMapfv (offset 251) */ - "iip\0" - "glPixelMapfv\0" - "\0" - /* _mesa_function_pool[7962]: Color4ui (offset 37) */ - "iiii\0" - "glColor4ui\0" - "\0" - /* _mesa_function_pool[7979]: RasterPos3s (offset 76) */ - "iii\0" - "glRasterPos3s\0" - "\0" - /* _mesa_function_pool[7998]: Color3usv (offset 24) */ - "p\0" - "glColor3usv\0" - "\0" - /* _mesa_function_pool[8013]: FlushRasterSGIX (dynamic) */ - "\0" - "glFlushRasterSGIX\0" - "\0" - /* _mesa_function_pool[8033]: TexCoord2f (offset 104) */ - "ff\0" - "glTexCoord2f\0" - "\0" - /* _mesa_function_pool[8050]: ReplacementCodeuiTexCoord2fVertex3fSUN (dynamic) */ - "ifffff\0" - "glReplacementCodeuiTexCoord2fVertex3fSUN\0" - "\0" - /* _mesa_function_pool[8099]: TexCoord2d (offset 102) */ - "dd\0" - "glTexCoord2d\0" - "\0" - /* _mesa_function_pool[8116]: RasterPos3d (offset 70) */ - "ddd\0" - "glRasterPos3d\0" - "\0" - /* _mesa_function_pool[8135]: RasterPos3f (offset 72) */ - "fff\0" - "glRasterPos3f\0" - "\0" - /* _mesa_function_pool[8154]: Uniform1fARB (will be remapped) */ - "if\0" - "glUniform1f\0" - "glUniform1fARB\0" - "\0" - /* _mesa_function_pool[8185]: AreTexturesResident (offset 322) */ - "ipp\0" - "glAreTexturesResident\0" - "glAreTexturesResidentEXT\0" - "\0" - /* _mesa_function_pool[8237]: TexCoord2s (offset 108) */ - "ii\0" - "glTexCoord2s\0" - "\0" - /* _mesa_function_pool[8254]: StencilOpSeparate (will be remapped) */ - "iiii\0" - "glStencilOpSeparate\0" - "glStencilOpSeparateATI\0" - "\0" - /* _mesa_function_pool[8303]: ColorTableParameteriv (offset 341) */ - "iip\0" - "glColorTableParameteriv\0" - "glColorTableParameterivSGI\0" - "\0" - /* _mesa_function_pool[8359]: FogCoordPointerListIBM (dynamic) */ - "iipi\0" - "glFogCoordPointerListIBM\0" - "\0" - /* _mesa_function_pool[8390]: WindowPos3dMESA (will be remapped) */ - "ddd\0" - "glWindowPos3d\0" - "glWindowPos3dARB\0" - "glWindowPos3dMESA\0" - "\0" - /* _mesa_function_pool[8444]: Color4us (offset 39) */ - "iiii\0" - "glColor4us\0" - "\0" - /* _mesa_function_pool[8461]: PointParameterfvEXT (will be remapped) */ - "ip\0" - "glPointParameterfv\0" - "glPointParameterfvARB\0" - "glPointParameterfvEXT\0" - "glPointParameterfvSGIS\0" - "\0" - /* _mesa_function_pool[8551]: Color3bv (offset 10) */ - "p\0" - "glColor3bv\0" - "\0" - /* _mesa_function_pool[8565]: GetnCompressedTexImageARB (will be remapped) */ - "iiip\0" - "glGetnCompressedTexImageARB\0" - "\0" - /* _mesa_function_pool[8599]: WindowPos2fvMESA (will be remapped) */ - "p\0" - "glWindowPos2fv\0" - "glWindowPos2fvARB\0" - "glWindowPos2fvMESA\0" - "\0" - /* _mesa_function_pool[8654]: SecondaryColor3bvEXT (will be remapped) */ - "p\0" - "glSecondaryColor3bv\0" - "glSecondaryColor3bvEXT\0" - "\0" - /* _mesa_function_pool[8700]: VertexPointerListIBM (dynamic) */ - "iiipi\0" - "glVertexPointerListIBM\0" - "\0" - /* _mesa_function_pool[8730]: GetProgramLocalParameterfvARB (will be remapped) */ - "iip\0" - "glGetProgramLocalParameterfvARB\0" - "\0" - /* _mesa_function_pool[8767]: FragmentMaterialfSGIX (dynamic) */ - "iif\0" - "glFragmentMaterialfSGIX\0" - "\0" - /* _mesa_function_pool[8796]: BindSampler (will be remapped) */ - "ii\0" - "glBindSampler\0" - "\0" - /* _mesa_function_pool[8814]: RenderbufferStorageEXT (will be remapped) */ - "iiii\0" - "glRenderbufferStorage\0" - "glRenderbufferStorageEXT\0" - "\0" - /* _mesa_function_pool[8867]: IsFenceNV (will be remapped) */ - "i\0" - "glIsFenceNV\0" - "\0" - /* _mesa_function_pool[8882]: AttachObjectARB (will be remapped) */ - "ii\0" - "glAttachObjectARB\0" - "\0" - /* _mesa_function_pool[8904]: GetFragmentLightivSGIX (dynamic) */ - "iip\0" - "glGetFragmentLightivSGIX\0" - "\0" - /* _mesa_function_pool[8934]: UniformMatrix2fvARB (will be remapped) */ - "iiip\0" - "glUniformMatrix2fv\0" - "glUniformMatrix2fvARB\0" - "\0" - /* _mesa_function_pool[8981]: MultiTexCoord2fARB (offset 386) */ - "iff\0" - "glMultiTexCoord2f\0" - "glMultiTexCoord2fARB\0" - "\0" - /* _mesa_function_pool[9025]: ColorTable (offset 339) */ - "iiiiip\0" - "glColorTable\0" - "glColorTableSGI\0" - "glColorTableEXT\0" - "\0" - /* _mesa_function_pool[9078]: IndexPointer (offset 314) */ - "iip\0" - "glIndexPointer\0" - "\0" - /* _mesa_function_pool[9098]: Accum (offset 213) */ - "if\0" - "glAccum\0" - "\0" - /* _mesa_function_pool[9110]: GetTexImage (offset 281) */ - "iiiip\0" - "glGetTexImage\0" - "\0" - /* _mesa_function_pool[9131]: MapControlPointsNV (dynamic) */ - "iiiiiiiip\0" - "glMapControlPointsNV\0" - "\0" - /* _mesa_function_pool[9163]: ConvolutionFilter2D (offset 349) */ - "iiiiiip\0" - "glConvolutionFilter2D\0" - "glConvolutionFilter2DEXT\0" - "\0" - /* _mesa_function_pool[9219]: Finish (offset 216) */ - "\0" - "glFinish\0" - "\0" - /* _mesa_function_pool[9230]: MapParameterfvNV (dynamic) */ - "iip\0" - "glMapParameterfvNV\0" - "\0" - /* _mesa_function_pool[9254]: ClearStencil (offset 207) */ - "i\0" - "glClearStencil\0" - "\0" - /* _mesa_function_pool[9272]: VertexAttrib3dvARB (will be remapped) */ - "ip\0" - "glVertexAttrib3dv\0" - "glVertexAttrib3dvARB\0" - "\0" - /* _mesa_function_pool[9315]: Uniform4uivEXT (will be remapped) */ - "iip\0" - "glUniform4uivEXT\0" - "glUniform4uiv\0" - "\0" - /* _mesa_function_pool[9351]: HintPGI (dynamic) */ - "ii\0" - "glHintPGI\0" - "\0" - /* _mesa_function_pool[9365]: ConvolutionParameteriv (offset 353) */ - "iip\0" - "glConvolutionParameteriv\0" - "glConvolutionParameterivEXT\0" - "\0" - /* _mesa_function_pool[9423]: Color4s (offset 33) */ - "iiii\0" - "glColor4s\0" - "\0" - /* _mesa_function_pool[9439]: InterleavedArrays (offset 317) */ - "iip\0" - "glInterleavedArrays\0" - "\0" - /* _mesa_function_pool[9464]: RasterPos2fv (offset 65) */ - "p\0" - "glRasterPos2fv\0" - "\0" - /* _mesa_function_pool[9482]: TexCoord1fv (offset 97) */ - "p\0" - "glTexCoord1fv\0" - "\0" - /* _mesa_function_pool[9499]: Vertex2d (offset 126) */ - "dd\0" - "glVertex2d\0" - "\0" - /* _mesa_function_pool[9514]: CullParameterdvEXT (dynamic) */ - "ip\0" - "glCullParameterdvEXT\0" - "\0" - /* _mesa_function_pool[9539]: ProgramNamedParameter4fNV (will be remapped) */ - "iipffff\0" - "glProgramNamedParameter4fNV\0" - "\0" - /* _mesa_function_pool[9576]: Color3fVertex3fSUN (dynamic) */ - "ffffff\0" - "glColor3fVertex3fSUN\0" - "\0" - /* _mesa_function_pool[9605]: ProgramEnvParameter4fvARB (will be remapped) */ - "iip\0" - "glProgramEnvParameter4fvARB\0" - "glProgramParameter4fvNV\0" - "\0" - /* _mesa_function_pool[9662]: Color4i (offset 31) */ - "iiii\0" - "glColor4i\0" - "\0" - /* _mesa_function_pool[9678]: Color4f (offset 29) */ - "ffff\0" - "glColor4f\0" - "\0" - /* _mesa_function_pool[9694]: RasterPos4fv (offset 81) */ - "p\0" - "glRasterPos4fv\0" - "\0" - /* _mesa_function_pool[9712]: Color4d (offset 27) */ - "dddd\0" - "glColor4d\0" - "\0" - /* _mesa_function_pool[9728]: ClearIndex (offset 205) */ - "f\0" - "glClearIndex\0" - "\0" - /* _mesa_function_pool[9744]: Color4b (offset 25) */ - "iiii\0" - "glColor4b\0" - "\0" - /* _mesa_function_pool[9760]: LoadMatrixd (offset 292) */ - "p\0" - "glLoadMatrixd\0" - "\0" - /* _mesa_function_pool[9777]: FragmentLightModeliSGIX (dynamic) */ - "ii\0" - "glFragmentLightModeliSGIX\0" - "\0" - /* _mesa_function_pool[9807]: RasterPos2dv (offset 63) */ - "p\0" - "glRasterPos2dv\0" - "\0" - /* _mesa_function_pool[9825]: ConvolutionParameterfv (offset 351) */ - "iip\0" - "glConvolutionParameterfv\0" - "glConvolutionParameterfvEXT\0" - "\0" - /* _mesa_function_pool[9883]: TbufferMask3DFX (dynamic) */ - "i\0" - "glTbufferMask3DFX\0" - "\0" - /* _mesa_function_pool[9904]: GetTexGendv (offset 278) */ - "iip\0" - "glGetTexGendv\0" - "\0" - /* _mesa_function_pool[9923]: GetVertexAttribfvNV (will be remapped) */ - "iip\0" - "glGetVertexAttribfvNV\0" - "\0" - /* _mesa_function_pool[9950]: BeginTransformFeedbackEXT (will be remapped) */ - "i\0" - "glBeginTransformFeedbackEXT\0" - "glBeginTransformFeedback\0" - "\0" - /* _mesa_function_pool[10006]: LoadProgramNV (will be remapped) */ - "iiip\0" - "glLoadProgramNV\0" - "\0" - /* _mesa_function_pool[10028]: WaitSync (will be remapped) */ - "iii\0" - "glWaitSync\0" - "\0" - /* _mesa_function_pool[10044]: EndList (offset 1) */ - "\0" - "glEndList\0" - "\0" - /* _mesa_function_pool[10056]: VertexP4ui (will be remapped) */ - "ii\0" - "glVertexP4ui\0" - "\0" - /* _mesa_function_pool[10073]: VertexAttrib4fvNV (will be remapped) */ - "ip\0" - "glVertexAttrib4fvNV\0" - "\0" - /* _mesa_function_pool[10097]: GetAttachedObjectsARB (will be remapped) */ - "iipp\0" - "glGetAttachedObjectsARB\0" - "\0" - /* _mesa_function_pool[10127]: Uniform3fvARB (will be remapped) */ - "iip\0" - "glUniform3fv\0" - "glUniform3fvARB\0" - "\0" - /* _mesa_function_pool[10161]: EvalCoord1fv (offset 231) */ - "p\0" - "glEvalCoord1fv\0" - "\0" - /* _mesa_function_pool[10179]: DrawRangeElements (offset 338) */ - "iiiiip\0" - "glDrawRangeElements\0" - "glDrawRangeElementsEXT\0" - "\0" - /* _mesa_function_pool[10230]: EvalMesh2 (offset 238) */ - "iiiii\0" - "glEvalMesh2\0" - "\0" - /* _mesa_function_pool[10249]: Vertex4fv (offset 145) */ - "p\0" - "glVertex4fv\0" - "\0" - /* _mesa_function_pool[10264]: GenTransformFeedbacks (will be remapped) */ - "ip\0" - "glGenTransformFeedbacks\0" - "\0" - /* _mesa_function_pool[10292]: SpriteParameterfvSGIX (dynamic) */ - "ip\0" - "glSpriteParameterfvSGIX\0" - "\0" - /* _mesa_function_pool[10320]: CheckFramebufferStatusEXT (will be remapped) */ - "i\0" - "glCheckFramebufferStatus\0" - "glCheckFramebufferStatusEXT\0" - "\0" - /* _mesa_function_pool[10376]: GlobalAlphaFactoruiSUN (dynamic) */ - "i\0" - "glGlobalAlphaFactoruiSUN\0" - "\0" - /* _mesa_function_pool[10404]: GetHandleARB (will be remapped) */ - "i\0" - "glGetHandleARB\0" - "\0" - /* _mesa_function_pool[10422]: GetVertexAttribivARB (will be remapped) */ - "iip\0" - "glGetVertexAttribiv\0" - "glGetVertexAttribivARB\0" - "\0" - /* _mesa_function_pool[10470]: BlendFunciARB (will be remapped) */ - "iii\0" - "glBlendFunciARB\0" - "glBlendFuncIndexedAMD\0" - "\0" - /* _mesa_function_pool[10513]: VertexAttribP1ui (will be remapped) */ - "iiii\0" - "glVertexAttribP1ui\0" - "\0" - /* _mesa_function_pool[10538]: GetnUniformivARB (will be remapped) */ - "iiip\0" - "glGetnUniformivARB\0" - "\0" - /* _mesa_function_pool[10563]: GetTexParameterIivEXT (will be remapped) */ - "iip\0" - "glGetTexParameterIivEXT\0" - "glGetTexParameterIiv\0" - "\0" - /* _mesa_function_pool[10613]: CreateProgram (will be remapped) */ - "\0" - "glCreateProgram\0" - "\0" - /* _mesa_function_pool[10631]: LoadTransposeMatrixdARB (will be remapped) */ - "p\0" - "glLoadTransposeMatrixd\0" - "glLoadTransposeMatrixdARB\0" - "\0" - /* _mesa_function_pool[10683]: ReleaseShaderCompiler (will be remapped) */ - "\0" - "glReleaseShaderCompiler\0" - "\0" - /* _mesa_function_pool[10709]: GetMinmax (offset 364) */ - "iiiip\0" - "glGetMinmax\0" - "glGetMinmaxEXT\0" - "\0" - /* _mesa_function_pool[10743]: StencilFuncSeparate (will be remapped) */ - "iiii\0" - "glStencilFuncSeparate\0" - "\0" - /* _mesa_function_pool[10771]: SecondaryColor3sEXT (will be remapped) */ - "iii\0" - "glSecondaryColor3s\0" - "glSecondaryColor3sEXT\0" - "\0" - /* _mesa_function_pool[10817]: Color3fVertex3fvSUN (dynamic) */ - "pp\0" - "glColor3fVertex3fvSUN\0" - "\0" - /* _mesa_function_pool[10843]: GetInteger64i_v (will be remapped) */ - "iip\0" - "glGetInteger64i_v\0" - "\0" - /* _mesa_function_pool[10866]: GetVertexAttribdvNV (will be remapped) */ - "iip\0" - "glGetVertexAttribdvNV\0" - "\0" - /* _mesa_function_pool[10893]: Normal3fv (offset 57) */ - "p\0" - "glNormal3fv\0" - "\0" - /* _mesa_function_pool[10908]: GlobalAlphaFactorbSUN (dynamic) */ - "i\0" - "glGlobalAlphaFactorbSUN\0" - "\0" - /* _mesa_function_pool[10935]: Color3us (offset 23) */ - "iii\0" - "glColor3us\0" - "\0" - /* _mesa_function_pool[10951]: ImageTransformParameterfvHP (dynamic) */ - "iip\0" - "glImageTransformParameterfvHP\0" - "\0" - /* _mesa_function_pool[10986]: VertexAttrib4ivARB (will be remapped) */ - "ip\0" - "glVertexAttrib4iv\0" - "glVertexAttrib4ivARB\0" - "\0" - /* _mesa_function_pool[11029]: End (offset 43) */ - "\0" - "glEnd\0" - "\0" - /* _mesa_function_pool[11037]: VertexAttrib3fNV (will be remapped) */ - "ifff\0" - "glVertexAttrib3fNV\0" - "\0" - /* _mesa_function_pool[11062]: MultiTexCoordP3uiv (will be remapped) */ - "iip\0" - "glMultiTexCoordP3uiv\0" - "\0" - /* _mesa_function_pool[11088]: VertexAttribs2dvNV (will be remapped) */ - "iip\0" - "glVertexAttribs2dvNV\0" - "\0" - /* _mesa_function_pool[11114]: GetQueryObjectui64vEXT (will be remapped) */ - "iip\0" - "glGetQueryObjectui64vEXT\0" - "\0" - /* _mesa_function_pool[11144]: MultiTexCoord3fvARB (offset 395) */ - "ip\0" - "glMultiTexCoord3fv\0" - "glMultiTexCoord3fvARB\0" - "\0" - /* _mesa_function_pool[11189]: SecondaryColor3dEXT (will be remapped) */ - "ddd\0" - "glSecondaryColor3d\0" - "glSecondaryColor3dEXT\0" - "\0" - /* _mesa_function_pool[11235]: Color3ub (offset 19) */ - "iii\0" - "glColor3ub\0" - "\0" - /* _mesa_function_pool[11251]: GetProgramParameterfvNV (will be remapped) */ - "iiip\0" - "glGetProgramParameterfvNV\0" - "\0" - /* _mesa_function_pool[11283]: TangentPointerEXT (dynamic) */ - "iip\0" - "glTangentPointerEXT\0" - "\0" - /* _mesa_function_pool[11308]: Color4fNormal3fVertex3fvSUN (dynamic) */ - "ppp\0" - "glColor4fNormal3fVertex3fvSUN\0" - "\0" - /* _mesa_function_pool[11343]: GetInstrumentsSGIX (dynamic) */ - "\0" - "glGetInstrumentsSGIX\0" - "\0" - /* _mesa_function_pool[11366]: GetUniformuivEXT (will be remapped) */ - "iip\0" - "glGetUniformuivEXT\0" - "glGetUniformuiv\0" - "\0" - /* _mesa_function_pool[11406]: Color3ui (offset 21) */ - "iii\0" - "glColor3ui\0" - "\0" - /* _mesa_function_pool[11422]: EvalMapsNV (dynamic) */ - "ii\0" - "glEvalMapsNV\0" - "\0" - /* _mesa_function_pool[11439]: TexSubImage2D (offset 333) */ - "iiiiiiiip\0" - "glTexSubImage2D\0" - "glTexSubImage2DEXT\0" - "\0" - /* _mesa_function_pool[11485]: FragmentLightivSGIX (dynamic) */ - "iip\0" - "glFragmentLightivSGIX\0" - "\0" - /* _mesa_function_pool[11512]: GetTexParameterPointervAPPLE (will be remapped) */ - "iip\0" - "glGetTexParameterPointervAPPLE\0" - "\0" - /* _mesa_function_pool[11548]: TexGenfv (offset 191) */ - "iip\0" - "glTexGenfv\0" - "\0" - /* _mesa_function_pool[11564]: GetTransformFeedbackVaryingEXT (will be remapped) */ - "iiipppp\0" - "glGetTransformFeedbackVaryingEXT\0" - "glGetTransformFeedbackVarying\0" - "\0" - /* _mesa_function_pool[11636]: VertexAttrib4bvARB (will be remapped) */ - "ip\0" - "glVertexAttrib4bv\0" - "glVertexAttrib4bvARB\0" - "\0" - /* _mesa_function_pool[11679]: ShaderBinary (will be remapped) */ - "ipipi\0" - "glShaderBinary\0" - "\0" - /* _mesa_function_pool[11701]: GetIntegerIndexedvEXT (will be remapped) */ - "iip\0" - "glGetIntegerIndexedvEXT\0" - "glGetIntegeri_v\0" - "\0" - /* _mesa_function_pool[11746]: MultiTexCoord4sARB (offset 406) */ - "iiiii\0" - "glMultiTexCoord4s\0" - "glMultiTexCoord4sARB\0" - "\0" - /* _mesa_function_pool[11792]: GetFragmentMaterialivSGIX (dynamic) */ - "iip\0" - "glGetFragmentMaterialivSGIX\0" - "\0" - /* _mesa_function_pool[11825]: WindowPos4dMESA (will be remapped) */ - "dddd\0" - "glWindowPos4dMESA\0" - "\0" - /* _mesa_function_pool[11849]: WeightPointerARB (dynamic) */ - "iiip\0" - "glWeightPointerARB\0" - "\0" - /* _mesa_function_pool[11874]: WindowPos2dMESA (will be remapped) */ - "dd\0" - "glWindowPos2d\0" - "glWindowPos2dARB\0" - "glWindowPos2dMESA\0" - "\0" - /* _mesa_function_pool[11927]: FramebufferTexture3DEXT (will be remapped) */ - "iiiiii\0" - "glFramebufferTexture3D\0" - "glFramebufferTexture3DEXT\0" - "\0" - /* _mesa_function_pool[11984]: BlendEquation (offset 337) */ - "i\0" - "glBlendEquation\0" - "glBlendEquationEXT\0" - "\0" - /* _mesa_function_pool[12022]: VertexAttrib3dNV (will be remapped) */ - "iddd\0" - "glVertexAttrib3dNV\0" - "\0" - /* _mesa_function_pool[12047]: VertexAttrib3dARB (will be remapped) */ - "iddd\0" - "glVertexAttrib3d\0" - "glVertexAttrib3dARB\0" - "\0" - /* _mesa_function_pool[12090]: VertexAttribI4usvEXT (will be remapped) */ - "ip\0" - "glVertexAttribI4usvEXT\0" - "glVertexAttribI4usv\0" - "\0" - /* _mesa_function_pool[12137]: ReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN (dynamic) */ - "ppppp\0" - "glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN\0" - "\0" - /* _mesa_function_pool[12201]: VertexAttrib4fARB (will be remapped) */ - "iffff\0" - "glVertexAttrib4f\0" - "glVertexAttrib4fARB\0" - "\0" - /* _mesa_function_pool[12245]: GetError (offset 261) */ - "\0" - "glGetError\0" - "\0" - /* _mesa_function_pool[12258]: IndexFuncEXT (dynamic) */ - "if\0" - "glIndexFuncEXT\0" - "\0" - /* _mesa_function_pool[12277]: TexCoord3dv (offset 111) */ - "p\0" - "glTexCoord3dv\0" - "\0" - /* _mesa_function_pool[12294]: Indexdv (offset 45) */ - "p\0" - "glIndexdv\0" - "\0" - /* _mesa_function_pool[12307]: FramebufferTexture2DEXT (will be remapped) */ - "iiiii\0" - "glFramebufferTexture2D\0" - "glFramebufferTexture2DEXT\0" - "\0" - /* _mesa_function_pool[12363]: Normal3s (offset 60) */ - "iii\0" - "glNormal3s\0" - "\0" - /* _mesa_function_pool[12379]: GetObjectParameterivAPPLE (will be remapped) */ - "iiip\0" - "glGetObjectParameterivAPPLE\0" - "\0" - /* _mesa_function_pool[12413]: PushName (offset 201) */ - "i\0" - "glPushName\0" - "\0" - /* _mesa_function_pool[12427]: MultiTexCoord2dvARB (offset 385) */ - "ip\0" - "glMultiTexCoord2dv\0" - "glMultiTexCoord2dvARB\0" - "\0" - /* _mesa_function_pool[12472]: CullParameterfvEXT (dynamic) */ - "ip\0" - "glCullParameterfvEXT\0" - "\0" - /* _mesa_function_pool[12497]: Normal3i (offset 58) */ - "iii\0" - "glNormal3i\0" - "\0" - /* _mesa_function_pool[12513]: ProgramNamedParameter4fvNV (will be remapped) */ - "iipp\0" - "glProgramNamedParameter4fvNV\0" - "\0" - /* _mesa_function_pool[12548]: SecondaryColorPointerEXT (will be remapped) */ - "iiip\0" - "glSecondaryColorPointer\0" - "glSecondaryColorPointerEXT\0" - "\0" - /* _mesa_function_pool[12605]: VertexAttrib4fvARB (will be remapped) */ - "ip\0" - "glVertexAttrib4fv\0" - "glVertexAttrib4fvARB\0" - "\0" - /* _mesa_function_pool[12648]: PixelTexGenSGIX (will be remapped) */ - "i\0" - "glPixelTexGenSGIX\0" - "\0" - /* _mesa_function_pool[12669]: GetActiveUniformARB (will be remapped) */ - "iiipppp\0" - "glGetActiveUniform\0" - "glGetActiveUniformARB\0" - "\0" - /* _mesa_function_pool[12719]: ImageTransformParameteriHP (dynamic) */ - "iii\0" - "glImageTransformParameteriHP\0" - "\0" - /* _mesa_function_pool[12753]: Normal3b (offset 52) */ - "iii\0" - "glNormal3b\0" - "\0" - /* _mesa_function_pool[12769]: Normal3d (offset 54) */ - "ddd\0" - "glNormal3d\0" - "\0" - /* _mesa_function_pool[12785]: Uniform1uiEXT (will be remapped) */ - "ii\0" - "glUniform1uiEXT\0" - "glUniform1ui\0" - "\0" - /* _mesa_function_pool[12818]: Normal3f (offset 56) */ - "fff\0" - "glNormal3f\0" - "\0" - /* _mesa_function_pool[12834]: MultiTexCoord1svARB (offset 383) */ - "ip\0" - "glMultiTexCoord1sv\0" - "glMultiTexCoord1svARB\0" - "\0" - /* _mesa_function_pool[12879]: Indexi (offset 48) */ - "i\0" - "glIndexi\0" - "\0" - /* _mesa_function_pool[12891]: EGLImageTargetTexture2DOES (will be remapped) */ - "ip\0" - "glEGLImageTargetTexture2DOES\0" - "\0" - /* _mesa_function_pool[12924]: EndQueryARB (will be remapped) */ - "i\0" - "glEndQuery\0" - "glEndQueryARB\0" - "\0" - /* _mesa_function_pool[12952]: DeleteFencesNV (will be remapped) */ - "ip\0" - "glDeleteFencesNV\0" - "\0" - /* _mesa_function_pool[12973]: ColorPointerListIBM (dynamic) */ - "iiipi\0" - "glColorPointerListIBM\0" - "\0" - /* _mesa_function_pool[13002]: BindBufferRangeEXT (will be remapped) */ - "iiiii\0" - "glBindBufferRangeEXT\0" - "glBindBufferRange\0" - "\0" - /* _mesa_function_pool[13048]: DepthMask (offset 211) */ - "i\0" - "glDepthMask\0" - "\0" - /* _mesa_function_pool[13063]: IsShader (will be remapped) */ - "i\0" - "glIsShader\0" - "\0" - /* _mesa_function_pool[13077]: Indexf (offset 46) */ - "f\0" - "glIndexf\0" - "\0" - /* _mesa_function_pool[13089]: GetImageTransformParameterivHP (dynamic) */ - "iip\0" - "glGetImageTransformParameterivHP\0" - "\0" - /* _mesa_function_pool[13127]: Indexd (offset 44) */ - "d\0" - "glIndexd\0" - "\0" - /* _mesa_function_pool[13139]: GetMaterialiv (offset 270) */ - "iip\0" - "glGetMaterialiv\0" - "\0" - /* _mesa_function_pool[13160]: StencilOp (offset 244) */ - "iii\0" - "glStencilOp\0" - "\0" - /* _mesa_function_pool[13177]: WindowPos4ivMESA (will be remapped) */ - "p\0" - "glWindowPos4ivMESA\0" - "\0" - /* _mesa_function_pool[13199]: MultiTexCoord3svARB (offset 399) */ - "ip\0" - "glMultiTexCoord3sv\0" - "glMultiTexCoord3svARB\0" - "\0" - /* _mesa_function_pool[13244]: TexEnvfv (offset 185) */ - "iip\0" - "glTexEnvfv\0" - "\0" - /* _mesa_function_pool[13260]: MultiTexCoord4iARB (offset 404) */ - "iiiii\0" - "glMultiTexCoord4i\0" - "glMultiTexCoord4iARB\0" - "\0" - /* _mesa_function_pool[13306]: Indexs (offset 50) */ - "i\0" - "glIndexs\0" - "\0" - /* _mesa_function_pool[13318]: Binormal3ivEXT (dynamic) */ - "p\0" - "glBinormal3ivEXT\0" - "\0" - /* _mesa_function_pool[13338]: ResizeBuffersMESA (will be remapped) */ - "\0" - "glResizeBuffersMESA\0" - "\0" - /* _mesa_function_pool[13360]: MultiTexCoordP1uiv (will be remapped) */ - "iip\0" - "glMultiTexCoordP1uiv\0" - "\0" - /* _mesa_function_pool[13386]: BlendFuncSeparateiARB (will be remapped) */ - "iiiii\0" - "glBlendFuncSeparateiARB\0" - "glBlendFuncSeparateIndexedAMD\0" - "\0" - /* _mesa_function_pool[13447]: GetUniformivARB (will be remapped) */ - "iip\0" - "glGetUniformiv\0" - "glGetUniformivARB\0" - "\0" - /* _mesa_function_pool[13485]: PixelTexGenParameteriSGIS (will be remapped) */ - "ii\0" - "glPixelTexGenParameteriSGIS\0" - "\0" - /* _mesa_function_pool[13517]: VertexPointervINTEL (dynamic) */ - "iip\0" - "glVertexPointervINTEL\0" - "\0" - /* _mesa_function_pool[13544]: Vertex2i (offset 130) */ - "ii\0" - "glVertex2i\0" - "\0" - /* _mesa_function_pool[13559]: LoadMatrixf (offset 291) */ - "p\0" - "glLoadMatrixf\0" - "\0" - /* _mesa_function_pool[13576]: VertexAttribI1uivEXT (will be remapped) */ - "ip\0" - "glVertexAttribI1uivEXT\0" - "glVertexAttribI1uiv\0" - "\0" - /* _mesa_function_pool[13623]: Vertex2f (offset 128) */ - "ff\0" - "glVertex2f\0" - "\0" - /* _mesa_function_pool[13638]: ReplacementCodeuiColor4fNormal3fVertex3fvSUN (dynamic) */ - "pppp\0" - "glReplacementCodeuiColor4fNormal3fVertex3fvSUN\0" - "\0" - /* _mesa_function_pool[13691]: Color4bv (offset 26) */ - "p\0" - "glColor4bv\0" - "\0" - /* _mesa_function_pool[13705]: VertexPointer (offset 321) */ - "iiip\0" - "glVertexPointer\0" - "\0" - /* _mesa_function_pool[13727]: SecondaryColor3uiEXT (will be remapped) */ - "iii\0" - "glSecondaryColor3ui\0" - "glSecondaryColor3uiEXT\0" - "\0" - /* _mesa_function_pool[13775]: StartInstrumentsSGIX (dynamic) */ - "\0" - "glStartInstrumentsSGIX\0" - "\0" - /* _mesa_function_pool[13800]: SecondaryColor3usvEXT (will be remapped) */ - "p\0" - "glSecondaryColor3usv\0" - "glSecondaryColor3usvEXT\0" - "\0" - /* _mesa_function_pool[13848]: VertexAttrib2fvNV (will be remapped) */ - "ip\0" - "glVertexAttrib2fvNV\0" - "\0" - /* _mesa_function_pool[13872]: ProgramLocalParameter4dvARB (will be remapped) */ - "iip\0" - "glProgramLocalParameter4dvARB\0" - "\0" - /* _mesa_function_pool[13907]: DeleteLists (offset 4) */ - "ii\0" - "glDeleteLists\0" - "\0" - /* _mesa_function_pool[13925]: LogicOp (offset 242) */ - "i\0" - "glLogicOp\0" - "\0" - /* _mesa_function_pool[13938]: MatrixIndexuivARB (dynamic) */ - "ip\0" - "glMatrixIndexuivARB\0" - "\0" - /* _mesa_function_pool[13962]: Vertex2s (offset 132) */ - "ii\0" - "glVertex2s\0" - "\0" - /* _mesa_function_pool[13977]: RenderbufferStorageMultisample (will be remapped) */ - "iiiii\0" - "glRenderbufferStorageMultisample\0" - "glRenderbufferStorageMultisampleEXT\0" - "\0" - /* _mesa_function_pool[14053]: TexCoord4fv (offset 121) */ - "p\0" - "glTexCoord4fv\0" - "\0" - /* _mesa_function_pool[14070]: Tangent3sEXT (dynamic) */ - "iii\0" - "glTangent3sEXT\0" - "\0" - /* _mesa_function_pool[14090]: GlobalAlphaFactorfSUN (dynamic) */ - "f\0" - "glGlobalAlphaFactorfSUN\0" - "\0" - /* _mesa_function_pool[14117]: MultiTexCoord3iARB (offset 396) */ - "iiii\0" - "glMultiTexCoord3i\0" - "glMultiTexCoord3iARB\0" - "\0" - /* _mesa_function_pool[14162]: IsProgram (will be remapped) */ - "i\0" - "glIsProgram\0" - "\0" - /* _mesa_function_pool[14177]: TexCoordPointerListIBM (dynamic) */ - "iiipi\0" - "glTexCoordPointerListIBM\0" - "\0" - /* _mesa_function_pool[14209]: VertexAttribI4svEXT (will be remapped) */ - "ip\0" - "glVertexAttribI4svEXT\0" - "glVertexAttribI4sv\0" - "\0" - /* _mesa_function_pool[14254]: GlobalAlphaFactorusSUN (dynamic) */ - "i\0" - "glGlobalAlphaFactorusSUN\0" - "\0" - /* _mesa_function_pool[14282]: VertexAttrib2dvNV (will be remapped) */ - "ip\0" - "glVertexAttrib2dvNV\0" - "\0" - /* _mesa_function_pool[14306]: FramebufferRenderbufferEXT (will be remapped) */ - "iiii\0" - "glFramebufferRenderbuffer\0" - "glFramebufferRenderbufferEXT\0" - "\0" - /* _mesa_function_pool[14367]: ClearBufferuiv (will be remapped) */ - "iip\0" - "glClearBufferuiv\0" - "\0" - /* _mesa_function_pool[14389]: VertexAttrib1dvNV (will be remapped) */ - "ip\0" - "glVertexAttrib1dvNV\0" - "\0" - /* _mesa_function_pool[14413]: GenTextures (offset 328) */ - "ip\0" - "glGenTextures\0" - "glGenTexturesEXT\0" - "\0" - /* _mesa_function_pool[14448]: FramebufferTextureARB (will be remapped) */ - "iiii\0" - "glFramebufferTextureARB\0" - "\0" - /* _mesa_function_pool[14478]: SetFenceNV (will be remapped) */ - "ii\0" - "glSetFenceNV\0" - "\0" - /* _mesa_function_pool[14495]: FramebufferTexture1DEXT (will be remapped) */ - "iiiii\0" - "glFramebufferTexture1D\0" - "glFramebufferTexture1DEXT\0" - "\0" - /* _mesa_function_pool[14551]: GetCombinerOutputParameterivNV (will be remapped) */ - "iiip\0" - "glGetCombinerOutputParameterivNV\0" - "\0" - /* _mesa_function_pool[14590]: PixelTexGenParameterivSGIS (will be remapped) */ - "ip\0" - "glPixelTexGenParameterivSGIS\0" - "\0" - /* _mesa_function_pool[14623]: TextureNormalEXT (dynamic) */ - "i\0" - "glTextureNormalEXT\0" - "\0" - /* _mesa_function_pool[14645]: IndexPointerListIBM (dynamic) */ - "iipi\0" - "glIndexPointerListIBM\0" - "\0" - /* _mesa_function_pool[14673]: WeightfvARB (dynamic) */ - "ip\0" - "glWeightfvARB\0" - "\0" - /* _mesa_function_pool[14691]: MultiTexCoordP3ui (will be remapped) */ - "iii\0" - "glMultiTexCoordP3ui\0" - "\0" - /* _mesa_function_pool[14716]: RasterPos2sv (offset 69) */ - "p\0" - "glRasterPos2sv\0" - "\0" - /* _mesa_function_pool[14734]: Color4ubv (offset 36) */ - "p\0" - "glColor4ubv\0" - "\0" - /* _mesa_function_pool[14749]: DrawBuffer (offset 202) */ - "i\0" - "glDrawBuffer\0" - "\0" - /* _mesa_function_pool[14765]: TexCoord2fv (offset 105) */ - "p\0" - "glTexCoord2fv\0" - "\0" - /* _mesa_function_pool[14782]: WindowPos4fMESA (will be remapped) */ - "ffff\0" - "glWindowPos4fMESA\0" - "\0" - /* _mesa_function_pool[14806]: TexCoord1sv (offset 101) */ - "p\0" - "glTexCoord1sv\0" - "\0" - /* _mesa_function_pool[14823]: WindowPos3dvMESA (will be remapped) */ - "p\0" - "glWindowPos3dv\0" - "glWindowPos3dvARB\0" - "glWindowPos3dvMESA\0" - "\0" - /* _mesa_function_pool[14878]: VertexAttribP1uiv (will be remapped) */ - "iiip\0" - "glVertexAttribP1uiv\0" - "\0" - /* _mesa_function_pool[14904]: VertexAttribP4ui (will be remapped) */ - "iiii\0" - "glVertexAttribP4ui\0" - "\0" - /* _mesa_function_pool[14929]: DepthFunc (offset 245) */ - "i\0" - "glDepthFunc\0" - "\0" - /* _mesa_function_pool[14944]: PixelMapusv (offset 253) */ - "iip\0" - "glPixelMapusv\0" - "\0" - /* _mesa_function_pool[14963]: GetQueryObjecti64vEXT (will be remapped) */ - "iip\0" - "glGetQueryObjecti64vEXT\0" - "\0" - /* _mesa_function_pool[14992]: MultiTexCoord1dARB (offset 376) */ - "id\0" - "glMultiTexCoord1d\0" - "glMultiTexCoord1dARB\0" - "\0" - /* _mesa_function_pool[15035]: PointParameterivNV (will be remapped) */ - "ip\0" - "glPointParameteriv\0" - "glPointParameterivNV\0" - "\0" - /* _mesa_function_pool[15079]: IsSampler (will be remapped) */ - "i\0" - "glIsSampler\0" - "\0" - /* _mesa_function_pool[15094]: BlendFunc (offset 241) */ - "ii\0" - "glBlendFunc\0" - "\0" - /* _mesa_function_pool[15110]: EndTransformFeedbackEXT (will be remapped) */ - "\0" - "glEndTransformFeedbackEXT\0" - "glEndTransformFeedback\0" - "\0" - /* _mesa_function_pool[15161]: Uniform2fvARB (will be remapped) */ - "iip\0" - "glUniform2fv\0" - "glUniform2fvARB\0" - "\0" - /* _mesa_function_pool[15195]: BufferParameteriAPPLE (will be remapped) */ - "iii\0" - "glBufferParameteriAPPLE\0" - "\0" - /* _mesa_function_pool[15224]: MultiTexCoord3dvARB (offset 393) */ - "ip\0" - "glMultiTexCoord3dv\0" - "glMultiTexCoord3dvARB\0" - "\0" - /* _mesa_function_pool[15269]: ReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN (dynamic) */ - "pppp\0" - "glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN\0" - "\0" - /* _mesa_function_pool[15325]: DeleteObjectARB (will be remapped) */ - "i\0" - "glDeleteObjectARB\0" - "\0" - /* _mesa_function_pool[15346]: GetShaderPrecisionFormat (will be remapped) */ - "iipp\0" - "glGetShaderPrecisionFormat\0" - "\0" - /* _mesa_function_pool[15379]: MatrixIndexPointerARB (dynamic) */ - "iiip\0" - "glMatrixIndexPointerARB\0" - "\0" - /* _mesa_function_pool[15409]: ProgramNamedParameter4dvNV (will be remapped) */ - "iipp\0" - "glProgramNamedParameter4dvNV\0" - "\0" - /* _mesa_function_pool[15444]: Tangent3fvEXT (dynamic) */ - "p\0" - "glTangent3fvEXT\0" - "\0" - /* _mesa_function_pool[15463]: Flush (offset 217) */ - "\0" - "glFlush\0" - "\0" - /* _mesa_function_pool[15473]: Color4uiv (offset 38) */ - "p\0" - "glColor4uiv\0" - "\0" - /* _mesa_function_pool[15488]: VertexAttribI4iEXT (will be remapped) */ - "iiiii\0" - "glVertexAttribI4iEXT\0" - "glVertexAttribI4i\0" - "\0" - /* _mesa_function_pool[15534]: GenVertexArrays (will be remapped) */ - "ip\0" - "glGenVertexArrays\0" - "\0" - /* _mesa_function_pool[15556]: Uniform3uivEXT (will be remapped) */ - "iip\0" - "glUniform3uivEXT\0" - "glUniform3uiv\0" - "\0" - /* _mesa_function_pool[15592]: RasterPos3sv (offset 77) */ - "p\0" - "glRasterPos3sv\0" - "\0" - /* _mesa_function_pool[15610]: TexCoordP2ui (will be remapped) */ - "ii\0" - "glTexCoordP2ui\0" - "\0" - /* _mesa_function_pool[15629]: BindFramebufferEXT (will be remapped) */ - "ii\0" - "glBindFramebuffer\0" - "glBindFramebufferEXT\0" - "\0" - /* _mesa_function_pool[15672]: ReferencePlaneSGIX (dynamic) */ - "p\0" - "glReferencePlaneSGIX\0" - "\0" - /* _mesa_function_pool[15696]: PushAttrib (offset 219) */ - "i\0" - "glPushAttrib\0" - "\0" - /* _mesa_function_pool[15712]: RasterPos2i (offset 66) */ - "ii\0" - "glRasterPos2i\0" - "\0" - /* _mesa_function_pool[15730]: ValidateProgramARB (will be remapped) */ - "i\0" - "glValidateProgram\0" - "glValidateProgramARB\0" - "\0" - /* _mesa_function_pool[15772]: TexParameteriv (offset 181) */ - "iip\0" - "glTexParameteriv\0" - "\0" - /* _mesa_function_pool[15794]: UnlockArraysEXT (will be remapped) */ - "\0" - "glUnlockArraysEXT\0" - "\0" - /* _mesa_function_pool[15814]: TexCoord2fColor3fVertex3fSUN (dynamic) */ - "ffffffff\0" - "glTexCoord2fColor3fVertex3fSUN\0" - "\0" - /* _mesa_function_pool[15855]: WindowPos3fvMESA (will be remapped) */ - "p\0" - "glWindowPos3fv\0" - "glWindowPos3fvARB\0" - "glWindowPos3fvMESA\0" - "\0" - /* _mesa_function_pool[15910]: RasterPos2f (offset 64) */ - "ff\0" - "glRasterPos2f\0" - "\0" - /* _mesa_function_pool[15928]: VertexAttrib1svNV (will be remapped) */ - "ip\0" - "glVertexAttrib1svNV\0" - "\0" - /* _mesa_function_pool[15952]: RasterPos2d (offset 62) */ - "dd\0" - "glRasterPos2d\0" - "\0" - /* _mesa_function_pool[15970]: RasterPos3fv (offset 73) */ - "p\0" - "glRasterPos3fv\0" - "\0" - /* _mesa_function_pool[15988]: CopyTexSubImage3D (offset 373) */ - "iiiiiiiii\0" - "glCopyTexSubImage3D\0" - "glCopyTexSubImage3DEXT\0" - "\0" - /* _mesa_function_pool[16042]: VertexAttrib2dARB (will be remapped) */ - "idd\0" - "glVertexAttrib2d\0" - "glVertexAttrib2dARB\0" - "\0" - /* _mesa_function_pool[16084]: Color4ub (offset 35) */ - "iiii\0" - "glColor4ub\0" - "\0" - /* _mesa_function_pool[16101]: GetInteger64v (will be remapped) */ - "ip\0" - "glGetInteger64v\0" - "\0" - /* _mesa_function_pool[16121]: TextureColorMaskSGIS (dynamic) */ - "iiii\0" - "glTextureColorMaskSGIS\0" - "\0" - /* _mesa_function_pool[16150]: RasterPos2s (offset 68) */ - "ii\0" - "glRasterPos2s\0" - "\0" - /* _mesa_function_pool[16168]: GetColorTable (offset 343) */ - "iiip\0" - "glGetColorTable\0" - "glGetColorTableSGI\0" - "glGetColorTableEXT\0" - "\0" - /* _mesa_function_pool[16228]: SelectBuffer (offset 195) */ - "ip\0" - "glSelectBuffer\0" - "\0" - /* _mesa_function_pool[16247]: Indexiv (offset 49) */ - "p\0" - "glIndexiv\0" - "\0" - /* _mesa_function_pool[16260]: TexCoord3i (offset 114) */ - "iii\0" - "glTexCoord3i\0" - "\0" - /* _mesa_function_pool[16278]: CopyColorTable (offset 342) */ - "iiiii\0" - "glCopyColorTable\0" - "glCopyColorTableSGI\0" - "\0" - /* _mesa_function_pool[16322]: GetHistogramParameterfv (offset 362) */ - "iip\0" - "glGetHistogramParameterfv\0" - "glGetHistogramParameterfvEXT\0" - "\0" - /* _mesa_function_pool[16382]: Frustum (offset 289) */ - "dddddd\0" - "glFrustum\0" - "\0" - /* _mesa_function_pool[16400]: GetString (offset 275) */ - "i\0" - "glGetString\0" - "\0" - /* _mesa_function_pool[16415]: ColorPointervINTEL (dynamic) */ - "iip\0" - "glColorPointervINTEL\0" - "\0" - /* _mesa_function_pool[16441]: TexEnvf (offset 184) */ - "iif\0" - "glTexEnvf\0" - "\0" - /* _mesa_function_pool[16456]: VertexP2uiv (will be remapped) */ - "ip\0" - "glVertexP2uiv\0" - "\0" - /* _mesa_function_pool[16474]: TexCoord3d (offset 110) */ - "ddd\0" - "glTexCoord3d\0" - "\0" - /* _mesa_function_pool[16492]: AlphaFragmentOp1ATI (will be remapped) */ - "iiiiii\0" - "glAlphaFragmentOp1ATI\0" - "\0" - /* _mesa_function_pool[16522]: TexCoord3f (offset 112) */ - "fff\0" - "glTexCoord3f\0" - "\0" - /* _mesa_function_pool[16540]: MultiTexCoord3ivARB (offset 397) */ - "ip\0" - "glMultiTexCoord3iv\0" - "glMultiTexCoord3ivARB\0" - "\0" - /* _mesa_function_pool[16585]: MultiTexCoord2sARB (offset 390) */ - "iii\0" - "glMultiTexCoord2s\0" - "glMultiTexCoord2sARB\0" - "\0" - /* _mesa_function_pool[16629]: VertexAttrib1dvARB (will be remapped) */ - "ip\0" - "glVertexAttrib1dv\0" - "glVertexAttrib1dvARB\0" - "\0" - /* _mesa_function_pool[16672]: GetnHistogramARB (will be remapped) */ - "iiiiip\0" - "glGetnHistogramARB\0" - "\0" - /* _mesa_function_pool[16699]: DeleteTextures (offset 327) */ - "ip\0" - "glDeleteTextures\0" - "glDeleteTexturesEXT\0" - "\0" - /* _mesa_function_pool[16740]: TexCoordPointerEXT (will be remapped) */ - "iiiip\0" - "glTexCoordPointerEXT\0" - "\0" - /* _mesa_function_pool[16768]: TexSubImage4DSGIS (dynamic) */ - "iiiiiiiiiiiip\0" - "glTexSubImage4DSGIS\0" - "\0" - /* _mesa_function_pool[16803]: TexCoord3s (offset 116) */ - "iii\0" - "glTexCoord3s\0" - "\0" - /* _mesa_function_pool[16821]: GetTexLevelParameteriv (offset 285) */ - "iiip\0" - "glGetTexLevelParameteriv\0" - "\0" - /* _mesa_function_pool[16852]: CombinerStageParameterfvNV (dynamic) */ - "iip\0" - "glCombinerStageParameterfvNV\0" - "\0" - /* _mesa_function_pool[16886]: VertexAttribP4uiv (will be remapped) */ - "iiip\0" - "glVertexAttribP4uiv\0" - "\0" - /* _mesa_function_pool[16912]: StopInstrumentsSGIX (dynamic) */ - "i\0" - "glStopInstrumentsSGIX\0" - "\0" - /* _mesa_function_pool[16937]: TexCoord4fColor4fNormal3fVertex4fSUN (dynamic) */ - "fffffffffffffff\0" - "glTexCoord4fColor4fNormal3fVertex4fSUN\0" - "\0" - /* _mesa_function_pool[16993]: ClearAccum (offset 204) */ - "ffff\0" - "glClearAccum\0" - "\0" - /* _mesa_function_pool[17012]: DeformSGIX (dynamic) */ - "i\0" - "glDeformSGIX\0" - "\0" - /* _mesa_function_pool[17028]: GetVertexAttribfvARB (will be remapped) */ - "iip\0" - "glGetVertexAttribfv\0" - "glGetVertexAttribfvARB\0" - "\0" - /* _mesa_function_pool[17076]: SecondaryColor3ivEXT (will be remapped) */ - "p\0" - "glSecondaryColor3iv\0" - "glSecondaryColor3ivEXT\0" - "\0" - /* _mesa_function_pool[17122]: TexCoord4iv (offset 123) */ - "p\0" - "glTexCoord4iv\0" - "\0" - /* _mesa_function_pool[17139]: VertexAttribI4uiEXT (will be remapped) */ - "iiiii\0" - "glVertexAttribI4uiEXT\0" - "glVertexAttribI4ui\0" - "\0" - /* _mesa_function_pool[17187]: GetFragmentMaterialfvSGIX (dynamic) */ - "iip\0" - "glGetFragmentMaterialfvSGIX\0" - "\0" - /* _mesa_function_pool[17220]: UniformMatrix4x2fv (will be remapped) */ - "iiip\0" - "glUniformMatrix4x2fv\0" - "\0" - /* _mesa_function_pool[17247]: GetDetailTexFuncSGIS (dynamic) */ - "ip\0" - "glGetDetailTexFuncSGIS\0" - "\0" - /* _mesa_function_pool[17274]: GetCombinerStageParameterfvNV (dynamic) */ - "iip\0" - "glGetCombinerStageParameterfvNV\0" - "\0" - /* _mesa_function_pool[17311]: SamplerParameterIiv (will be remapped) */ - "iip\0" - "glSamplerParameterIiv\0" - "\0" - /* _mesa_function_pool[17338]: PolygonOffset (offset 319) */ - "ff\0" - "glPolygonOffset\0" - "\0" - /* _mesa_function_pool[17358]: BindVertexArray (will be remapped) */ - "i\0" - "glBindVertexArray\0" - "\0" - /* _mesa_function_pool[17379]: Color4ubVertex2fvSUN (dynamic) */ - "pp\0" - "glColor4ubVertex2fvSUN\0" - "\0" - /* _mesa_function_pool[17406]: VertexP3uiv (will be remapped) */ - "ip\0" - "glVertexP3uiv\0" - "\0" - /* _mesa_function_pool[17424]: Rectd (offset 86) */ - "dddd\0" - "glRectd\0" - "\0" - /* _mesa_function_pool[17438]: TexFilterFuncSGIS (dynamic) */ - "iiip\0" - "glTexFilterFuncSGIS\0" - "\0" - /* _mesa_function_pool[17464]: TextureBarrierNV (will be remapped) */ - "\0" - "glTextureBarrierNV\0" - "\0" - /* _mesa_function_pool[17485]: SamplerParameterfv (will be remapped) */ - "iip\0" - "glSamplerParameterfv\0" - "\0" - /* _mesa_function_pool[17511]: ColorMaskIndexedEXT (will be remapped) */ - "iiiii\0" - "glColorMaskIndexedEXT\0" - "glColorMaski\0" - "\0" - /* _mesa_function_pool[17553]: GetAttribLocationARB (will be remapped) */ - "ip\0" - "glGetAttribLocation\0" - "glGetAttribLocationARB\0" - "\0" - /* _mesa_function_pool[17600]: RasterPos3i (offset 74) */ - "iii\0" - "glRasterPos3i\0" - "\0" - /* _mesa_function_pool[17619]: VertexAttrib4ubvARB (will be remapped) */ - "ip\0" - "glVertexAttrib4ubv\0" - "glVertexAttrib4ubvARB\0" - "\0" - /* _mesa_function_pool[17664]: DetailTexFuncSGIS (dynamic) */ - "iip\0" - "glDetailTexFuncSGIS\0" - "\0" - /* _mesa_function_pool[17689]: Normal3fVertex3fSUN (dynamic) */ - "ffffff\0" - "glNormal3fVertex3fSUN\0" - "\0" - /* _mesa_function_pool[17719]: CopyTexImage2D (offset 324) */ - "iiiiiiii\0" - "glCopyTexImage2D\0" - "glCopyTexImage2DEXT\0" - "\0" - /* _mesa_function_pool[17766]: GetBufferPointervARB (will be remapped) */ - "iip\0" - "glGetBufferPointerv\0" - "glGetBufferPointervARB\0" - "\0" - /* _mesa_function_pool[17814]: ProgramEnvParameter4fARB (will be remapped) */ - "iiffff\0" - "glProgramEnvParameter4fARB\0" - "glProgramParameter4fNV\0" - "\0" - /* _mesa_function_pool[17872]: Uniform3ivARB (will be remapped) */ - "iip\0" - "glUniform3iv\0" - "glUniform3ivARB\0" - "\0" - /* _mesa_function_pool[17906]: Lightfv (offset 160) */ - "iip\0" - "glLightfv\0" - "\0" - /* _mesa_function_pool[17921]: PrimitiveRestartIndexNV (will be remapped) */ - "i\0" - "glPrimitiveRestartIndexNV\0" - "glPrimitiveRestartIndex\0" - "\0" - /* _mesa_function_pool[17974]: ClearDepth (offset 208) */ - "d\0" - "glClearDepth\0" - "\0" - /* _mesa_function_pool[17990]: GetFenceivNV (will be remapped) */ - "iip\0" - "glGetFenceivNV\0" - "\0" - /* _mesa_function_pool[18010]: WindowPos4dvMESA (will be remapped) */ - "p\0" - "glWindowPos4dvMESA\0" - "\0" - /* _mesa_function_pool[18032]: ColorSubTable (offset 346) */ - "iiiiip\0" - "glColorSubTable\0" - "glColorSubTableEXT\0" - "\0" - /* _mesa_function_pool[18075]: Color4fv (offset 30) */ - "p\0" - "glColor4fv\0" - "\0" - /* _mesa_function_pool[18089]: MultiTexCoord4ivARB (offset 405) */ - "ip\0" - "glMultiTexCoord4iv\0" - "glMultiTexCoord4ivARB\0" - "\0" - /* _mesa_function_pool[18134]: GetnMinmaxARB (will be remapped) */ - "iiiiip\0" - "glGetnMinmaxARB\0" - "\0" - /* _mesa_function_pool[18158]: ProgramLocalParameters4fvEXT (will be remapped) */ - "iiip\0" - "glProgramLocalParameters4fvEXT\0" - "\0" - /* _mesa_function_pool[18195]: ColorPointer (offset 308) */ - "iiip\0" - "glColorPointer\0" - "\0" - /* _mesa_function_pool[18216]: Rects (offset 92) */ - "iiii\0" - "glRects\0" - "\0" - /* _mesa_function_pool[18230]: GetMapAttribParameterfvNV (dynamic) */ - "iiip\0" - "glGetMapAttribParameterfvNV\0" - "\0" - /* _mesa_function_pool[18264]: CreateShaderProgramEXT (will be remapped) */ - "ip\0" - "glCreateShaderProgramEXT\0" - "\0" - /* _mesa_function_pool[18293]: ActiveProgramEXT (will be remapped) */ - "i\0" - "glActiveProgramEXT\0" - "\0" - /* _mesa_function_pool[18315]: Lightiv (offset 162) */ - "iip\0" - "glLightiv\0" - "\0" - /* _mesa_function_pool[18330]: VertexAttrib4sARB (will be remapped) */ - "iiiii\0" - "glVertexAttrib4s\0" - "glVertexAttrib4sARB\0" - "\0" - /* _mesa_function_pool[18374]: GetQueryObjectuivARB (will be remapped) */ - "iip\0" - "glGetQueryObjectuiv\0" - "glGetQueryObjectuivARB\0" - "\0" - /* _mesa_function_pool[18422]: GetTexParameteriv (offset 283) */ - "iip\0" - "glGetTexParameteriv\0" - "\0" - /* _mesa_function_pool[18447]: MapParameterivNV (dynamic) */ - "iip\0" - "glMapParameterivNV\0" - "\0" - /* _mesa_function_pool[18471]: GenRenderbuffersEXT (will be remapped) */ - "ip\0" - "glGenRenderbuffers\0" - "glGenRenderbuffersEXT\0" - "\0" - /* _mesa_function_pool[18516]: ClearBufferfv (will be remapped) */ - "iip\0" - "glClearBufferfv\0" - "\0" - /* _mesa_function_pool[18537]: VertexAttrib2dvARB (will be remapped) */ - "ip\0" - "glVertexAttrib2dv\0" - "glVertexAttrib2dvARB\0" - "\0" - /* _mesa_function_pool[18580]: EdgeFlagPointerEXT (will be remapped) */ - "iip\0" - "glEdgeFlagPointerEXT\0" - "\0" - /* _mesa_function_pool[18606]: VertexAttribs2svNV (will be remapped) */ - "iip\0" - "glVertexAttribs2svNV\0" - "\0" - /* _mesa_function_pool[18632]: WeightbvARB (dynamic) */ - "ip\0" - "glWeightbvARB\0" - "\0" - /* _mesa_function_pool[18650]: VertexAttrib2fvARB (will be remapped) */ - "ip\0" - "glVertexAttrib2fv\0" - "glVertexAttrib2fvARB\0" - "\0" - /* _mesa_function_pool[18693]: GetBufferParameterivARB (will be remapped) */ - "iip\0" - "glGetBufferParameteriv\0" - "glGetBufferParameterivARB\0" - "\0" - /* _mesa_function_pool[18747]: Rectdv (offset 87) */ - "pp\0" - "glRectdv\0" - "\0" - /* _mesa_function_pool[18760]: ListParameteriSGIX (dynamic) */ - "iii\0" - "glListParameteriSGIX\0" - "\0" - /* _mesa_function_pool[18786]: BlendEquationiARB (will be remapped) */ - "ii\0" - "glBlendEquationiARB\0" - "glBlendEquationIndexedAMD\0" - "\0" - /* _mesa_function_pool[18836]: ReplacementCodeuiColor4fNormal3fVertex3fSUN (dynamic) */ - "iffffffffff\0" - "glReplacementCodeuiColor4fNormal3fVertex3fSUN\0" - "\0" - /* _mesa_function_pool[18895]: InstrumentsBufferSGIX (dynamic) */ - "ip\0" - "glInstrumentsBufferSGIX\0" - "\0" - /* _mesa_function_pool[18923]: VertexAttrib4NivARB (will be remapped) */ - "ip\0" - "glVertexAttrib4Niv\0" - "glVertexAttrib4NivARB\0" - "\0" - /* _mesa_function_pool[18968]: DrawArraysInstancedARB (will be remapped) */ - "iiii\0" - "glDrawArraysInstancedARB\0" - "glDrawArraysInstancedEXT\0" - "glDrawArraysInstanced\0" - "\0" - /* _mesa_function_pool[19046]: GetAttachedShaders (will be remapped) */ - "iipp\0" - "glGetAttachedShaders\0" - "\0" - /* _mesa_function_pool[19073]: GenVertexArraysAPPLE (will be remapped) */ - "ip\0" - "glGenVertexArraysAPPLE\0" - "\0" - /* _mesa_function_pool[19100]: ClearBufferfi (will be remapped) */ - "iifi\0" - "glClearBufferfi\0" - "\0" - /* _mesa_function_pool[19122]: Materialiv (offset 172) */ - "iip\0" - "glMaterialiv\0" - "\0" - /* _mesa_function_pool[19140]: PushClientAttrib (offset 335) */ - "i\0" - "glPushClientAttrib\0" - "\0" - /* _mesa_function_pool[19162]: SamplerParameteriv (will be remapped) */ - "iip\0" - "glSamplerParameteriv\0" - "\0" - /* _mesa_function_pool[19188]: TexCoord2fColor4fNormal3fVertex3fvSUN (dynamic) */ - "pppp\0" - "glTexCoord2fColor4fNormal3fVertex3fvSUN\0" - "\0" - /* _mesa_function_pool[19234]: WindowPos2iMESA (will be remapped) */ - "ii\0" - "glWindowPos2i\0" - "glWindowPos2iARB\0" - "glWindowPos2iMESA\0" - "\0" - /* _mesa_function_pool[19287]: SampleMaskSGIS (will be remapped) */ - "fi\0" - "glSampleMaskSGIS\0" - "glSampleMaskEXT\0" - "\0" - /* _mesa_function_pool[19324]: SecondaryColor3fvEXT (will be remapped) */ - "p\0" - "glSecondaryColor3fv\0" - "glSecondaryColor3fvEXT\0" - "\0" - /* _mesa_function_pool[19370]: PolygonMode (offset 174) */ - "ii\0" - "glPolygonMode\0" - "\0" - /* _mesa_function_pool[19388]: CompressedTexSubImage1DARB (will be remapped) */ - "iiiiiip\0" - "glCompressedTexSubImage1D\0" - "glCompressedTexSubImage1DARB\0" - "\0" - /* _mesa_function_pool[19452]: VertexAttribI1iEXT (will be remapped) */ - "ii\0" - "glVertexAttribI1iEXT\0" - "glVertexAttribI1i\0" - "\0" - /* _mesa_function_pool[19495]: TexCoord2fNormal3fVertex3fSUN (dynamic) */ - "ffffffff\0" - "glTexCoord2fNormal3fVertex3fSUN\0" - "\0" - /* _mesa_function_pool[19537]: GetVertexAttribivNV (will be remapped) */ - "iip\0" - "glGetVertexAttribivNV\0" - "\0" - /* _mesa_function_pool[19564]: GetProgramStringARB (will be remapped) */ - "iip\0" - "glGetProgramStringARB\0" - "\0" - /* _mesa_function_pool[19591]: GetnUniformdvARB (will be remapped) */ - "iiip\0" - "glGetnUniformdvARB\0" - "\0" - /* _mesa_function_pool[19616]: DrawElementsInstancedBaseVertex (will be remapped) */ - "iiipii\0" - "glDrawElementsInstancedBaseVertex\0" - "\0" - /* _mesa_function_pool[19658]: VertexAttribIPointerEXT (will be remapped) */ - "iiiip\0" - "glVertexAttribIPointerEXT\0" - "glVertexAttribIPointer\0" - "\0" - /* _mesa_function_pool[19714]: TexBumpParameterfvATI (will be remapped) */ - "ip\0" - "glTexBumpParameterfvATI\0" - "\0" - /* _mesa_function_pool[19742]: Tangent3ivEXT (dynamic) */ - "p\0" - "glTangent3ivEXT\0" - "\0" - /* _mesa_function_pool[19761]: CompileShaderARB (will be remapped) */ - "i\0" - "glCompileShader\0" - "glCompileShaderARB\0" - "\0" - /* _mesa_function_pool[19799]: DeleteShader (will be remapped) */ - "i\0" - "glDeleteShader\0" - "\0" - /* _mesa_function_pool[19817]: DisableClientState (offset 309) */ - "i\0" - "glDisableClientState\0" - "\0" - /* _mesa_function_pool[19841]: TexGeni (offset 192) */ - "iii\0" - "glTexGeni\0" - "\0" - /* _mesa_function_pool[19856]: TexGenf (offset 190) */ - "iif\0" - "glTexGenf\0" - "\0" - /* _mesa_function_pool[19871]: Uniform3fARB (will be remapped) */ - "ifff\0" - "glUniform3f\0" - "glUniform3fARB\0" - "\0" - /* _mesa_function_pool[19904]: TexGend (offset 188) */ - "iid\0" - "glTexGend\0" - "\0" - /* _mesa_function_pool[19919]: ListParameterfvSGIX (dynamic) */ - "iip\0" - "glListParameterfvSGIX\0" - "\0" - /* _mesa_function_pool[19946]: GetPolygonStipple (offset 274) */ - "p\0" - "glGetPolygonStipple\0" - "\0" - /* _mesa_function_pool[19969]: ColorP3ui (will be remapped) */ - "ii\0" - "glColorP3ui\0" - "\0" - /* _mesa_function_pool[19985]: Tangent3dvEXT (dynamic) */ - "p\0" - "glTangent3dvEXT\0" - "\0" - /* _mesa_function_pool[20004]: BindBufferOffsetEXT (will be remapped) */ - "iiii\0" - "glBindBufferOffsetEXT\0" - "\0" - /* _mesa_function_pool[20032]: WindowPos3sMESA (will be remapped) */ - "iii\0" - "glWindowPos3s\0" - "glWindowPos3sARB\0" - "glWindowPos3sMESA\0" - "\0" - /* _mesa_function_pool[20086]: VertexAttrib2svNV (will be remapped) */ - "ip\0" - "glVertexAttrib2svNV\0" - "\0" - /* _mesa_function_pool[20110]: DisableIndexedEXT (will be remapped) */ - "ii\0" - "glDisableIndexedEXT\0" - "glDisablei\0" - "\0" - /* _mesa_function_pool[20145]: NormalP3uiv (will be remapped) */ - "ip\0" - "glNormalP3uiv\0" - "\0" - /* _mesa_function_pool[20163]: SecondaryColorP3uiv (will be remapped) */ - "ip\0" - "glSecondaryColorP3uiv\0" - "\0" - /* _mesa_function_pool[20189]: BindBufferBaseEXT (will be remapped) */ - "iii\0" - "glBindBufferBaseEXT\0" - "glBindBufferBase\0" - "\0" - /* _mesa_function_pool[20231]: TexCoord2fVertex3fvSUN (dynamic) */ - "pp\0" - "glTexCoord2fVertex3fvSUN\0" - "\0" - /* _mesa_function_pool[20260]: WindowPos4sMESA (will be remapped) */ - "iiii\0" - "glWindowPos4sMESA\0" - "\0" - /* _mesa_function_pool[20284]: GetnPixelMapuivARB (will be remapped) */ - "iip\0" - "glGetnPixelMapuivARB\0" - "\0" - /* _mesa_function_pool[20310]: VertexAttrib4NuivARB (will be remapped) */ - "ip\0" - "glVertexAttrib4Nuiv\0" - "glVertexAttrib4NuivARB\0" - "\0" - /* _mesa_function_pool[20357]: ClientActiveTextureARB (offset 375) */ - "i\0" - "glClientActiveTexture\0" - "glClientActiveTextureARB\0" - "\0" - /* _mesa_function_pool[20407]: GetSamplerParameterIuiv (will be remapped) */ - "iip\0" - "glGetSamplerParameterIuiv\0" - "\0" - /* _mesa_function_pool[20438]: ReplacementCodeusvSUN (dynamic) */ - "p\0" - "glReplacementCodeusvSUN\0" - "\0" - /* _mesa_function_pool[20465]: Uniform4fARB (will be remapped) */ - "iffff\0" - "glUniform4f\0" - "glUniform4fARB\0" - "\0" - /* _mesa_function_pool[20499]: Color4sv (offset 34) */ - "p\0" - "glColor4sv\0" - "\0" - /* _mesa_function_pool[20513]: FlushMappedBufferRange (will be remapped) */ - "iii\0" - "glFlushMappedBufferRange\0" - "\0" - /* _mesa_function_pool[20543]: IsProgramNV (will be remapped) */ - "i\0" - "glIsProgramARB\0" - "glIsProgramNV\0" - "\0" - /* _mesa_function_pool[20575]: FlushMappedBufferRangeAPPLE (will be remapped) */ - "iii\0" - "glFlushMappedBufferRangeAPPLE\0" - "\0" - /* _mesa_function_pool[20610]: PixelZoom (offset 246) */ - "ff\0" - "glPixelZoom\0" - "\0" - /* _mesa_function_pool[20626]: ReplacementCodePointerSUN (dynamic) */ - "iip\0" - "glReplacementCodePointerSUN\0" - "\0" - /* _mesa_function_pool[20659]: ProgramEnvParameter4dARB (will be remapped) */ - "iidddd\0" - "glProgramEnvParameter4dARB\0" - "glProgramParameter4dNV\0" - "\0" - /* _mesa_function_pool[20717]: ColorTableParameterfv (offset 340) */ - "iip\0" - "glColorTableParameterfv\0" - "glColorTableParameterfvSGI\0" - "\0" - /* _mesa_function_pool[20773]: FragmentLightModelfSGIX (dynamic) */ - "if\0" - "glFragmentLightModelfSGIX\0" - "\0" - /* _mesa_function_pool[20803]: Binormal3bvEXT (dynamic) */ - "p\0" - "glBinormal3bvEXT\0" - "\0" - /* _mesa_function_pool[20823]: PixelMapuiv (offset 252) */ - "iip\0" - "glPixelMapuiv\0" - "\0" - /* _mesa_function_pool[20842]: Color3dv (offset 12) */ - "p\0" - "glColor3dv\0" - "\0" - /* _mesa_function_pool[20856]: IsTexture (offset 330) */ - "i\0" - "glIsTexture\0" - "glIsTextureEXT\0" - "\0" - /* _mesa_function_pool[20886]: GenSamplers (will be remapped) */ - "ip\0" - "glGenSamplers\0" - "\0" - /* _mesa_function_pool[20904]: VertexAttribP3uiv (will be remapped) */ - "iiip\0" - "glVertexAttribP3uiv\0" - "\0" - /* _mesa_function_pool[20930]: VertexWeightfvEXT (dynamic) */ - "p\0" - "glVertexWeightfvEXT\0" - "\0" - /* _mesa_function_pool[20953]: VertexAttrib1dARB (will be remapped) */ - "id\0" - "glVertexAttrib1d\0" - "glVertexAttrib1dARB\0" - "\0" - /* _mesa_function_pool[20994]: ImageTransformParameterivHP (dynamic) */ - "iip\0" - "glImageTransformParameterivHP\0" - "\0" - /* _mesa_function_pool[21029]: TexCoord4i (offset 122) */ - "iiii\0" - "glTexCoord4i\0" - "\0" - /* _mesa_function_pool[21048]: DeleteQueriesARB (will be remapped) */ - "ip\0" - "glDeleteQueries\0" - "glDeleteQueriesARB\0" - "\0" - /* _mesa_function_pool[21087]: Color4ubVertex2fSUN (dynamic) */ - "iiiiff\0" - "glColor4ubVertex2fSUN\0" - "\0" - /* _mesa_function_pool[21117]: FragmentColorMaterialSGIX (dynamic) */ - "ii\0" - "glFragmentColorMaterialSGIX\0" - "\0" - /* _mesa_function_pool[21149]: CurrentPaletteMatrixARB (dynamic) */ - "i\0" - "glCurrentPaletteMatrixARB\0" - "\0" - /* _mesa_function_pool[21178]: GetMapdv (offset 266) */ - "iip\0" - "glGetMapdv\0" - "\0" - /* _mesa_function_pool[21194]: ObjectPurgeableAPPLE (will be remapped) */ - "iii\0" - "glObjectPurgeableAPPLE\0" - "\0" - /* _mesa_function_pool[21222]: GetStringi (will be remapped) */ - "ii\0" - "glGetStringi\0" - "\0" - /* _mesa_function_pool[21239]: SamplePatternSGIS (will be remapped) */ - "i\0" - "glSamplePatternSGIS\0" - "glSamplePatternEXT\0" - "\0" - /* _mesa_function_pool[21281]: PixelStoref (offset 249) */ - "if\0" - "glPixelStoref\0" - "\0" - /* _mesa_function_pool[21299]: IsQueryARB (will be remapped) */ - "i\0" - "glIsQuery\0" - "glIsQueryARB\0" - "\0" - /* _mesa_function_pool[21325]: ReplacementCodeuiColor4ubVertex3fSUN (dynamic) */ - "iiiiifff\0" - "glReplacementCodeuiColor4ubVertex3fSUN\0" - "\0" - /* _mesa_function_pool[21374]: PixelStorei (offset 250) */ - "ii\0" - "glPixelStorei\0" - "\0" - /* _mesa_function_pool[21392]: VertexAttrib4usvARB (will be remapped) */ - "ip\0" - "glVertexAttrib4usv\0" - "glVertexAttrib4usvARB\0" - "\0" - /* _mesa_function_pool[21437]: LinkProgramARB (will be remapped) */ - "i\0" - "glLinkProgram\0" - "glLinkProgramARB\0" - "\0" - /* _mesa_function_pool[21471]: VertexAttrib2fNV (will be remapped) */ - "iff\0" - "glVertexAttrib2fNV\0" - "\0" - /* _mesa_function_pool[21495]: ShaderSourceARB (will be remapped) */ - "iipp\0" - "glShaderSource\0" - "glShaderSourceARB\0" - "\0" - /* _mesa_function_pool[21534]: FragmentMaterialiSGIX (dynamic) */ - "iii\0" - "glFragmentMaterialiSGIX\0" - "\0" - /* _mesa_function_pool[21563]: EvalCoord2dv (offset 233) */ - "p\0" - "glEvalCoord2dv\0" - "\0" - /* _mesa_function_pool[21581]: VertexAttrib3svARB (will be remapped) */ - "ip\0" - "glVertexAttrib3sv\0" - "glVertexAttrib3svARB\0" - "\0" - /* _mesa_function_pool[21624]: ColorMaterial (offset 151) */ - "ii\0" - "glColorMaterial\0" - "\0" - /* _mesa_function_pool[21644]: CompressedTexSubImage3DARB (will be remapped) */ - "iiiiiiiiiip\0" - "glCompressedTexSubImage3D\0" - "glCompressedTexSubImage3DARB\0" - "\0" - /* _mesa_function_pool[21712]: WindowPos2ivMESA (will be remapped) */ - "p\0" - "glWindowPos2iv\0" - "glWindowPos2ivARB\0" - "glWindowPos2ivMESA\0" - "\0" - /* _mesa_function_pool[21767]: IsFramebufferEXT (will be remapped) */ - "i\0" - "glIsFramebuffer\0" - "glIsFramebufferEXT\0" - "\0" - /* _mesa_function_pool[21805]: Uniform4ivARB (will be remapped) */ - "iip\0" - "glUniform4iv\0" - "glUniform4ivARB\0" - "\0" - /* _mesa_function_pool[21839]: GetVertexAttribdvARB (will be remapped) */ - "iip\0" - "glGetVertexAttribdv\0" - "glGetVertexAttribdvARB\0" - "\0" - /* _mesa_function_pool[21887]: TexBumpParameterivATI (will be remapped) */ - "ip\0" - "glTexBumpParameterivATI\0" - "\0" - /* _mesa_function_pool[21915]: GetSeparableFilter (offset 359) */ - "iiippp\0" - "glGetSeparableFilter\0" - "glGetSeparableFilterEXT\0" - "\0" - /* _mesa_function_pool[21968]: Binormal3dEXT (dynamic) */ - "ddd\0" - "glBinormal3dEXT\0" - "\0" - /* _mesa_function_pool[21989]: SpriteParameteriSGIX (dynamic) */ - "ii\0" - "glSpriteParameteriSGIX\0" - "\0" - /* _mesa_function_pool[22016]: RequestResidentProgramsNV (will be remapped) */ - "ip\0" - "glRequestResidentProgramsNV\0" - "\0" - /* _mesa_function_pool[22048]: TagSampleBufferSGIX (dynamic) */ - "\0" - "glTagSampleBufferSGIX\0" - "\0" - /* _mesa_function_pool[22072]: TransformFeedbackVaryingsEXT (will be remapped) */ - "iipi\0" - "glTransformFeedbackVaryingsEXT\0" - "glTransformFeedbackVaryings\0" - "\0" - /* _mesa_function_pool[22137]: FeedbackBuffer (offset 194) */ - "iip\0" - "glFeedbackBuffer\0" - "\0" - /* _mesa_function_pool[22159]: RasterPos2iv (offset 67) */ - "p\0" - "glRasterPos2iv\0" - "\0" - /* _mesa_function_pool[22177]: TexImage1D (offset 182) */ - "iiiiiiip\0" - "glTexImage1D\0" - "\0" - /* _mesa_function_pool[22200]: ListParameterivSGIX (dynamic) */ - "iip\0" - "glListParameterivSGIX\0" - "\0" - /* _mesa_function_pool[22227]: MultiDrawElementsEXT (will be remapped) */ - "ipipi\0" - "glMultiDrawElements\0" - "glMultiDrawElementsEXT\0" - "\0" - /* _mesa_function_pool[22277]: Color3s (offset 17) */ - "iii\0" - "glColor3s\0" - "\0" - /* _mesa_function_pool[22292]: Uniform1ivARB (will be remapped) */ - "iip\0" - "glUniform1iv\0" - "glUniform1ivARB\0" - "\0" - /* _mesa_function_pool[22326]: WindowPos2sMESA (will be remapped) */ - "ii\0" - "glWindowPos2s\0" - "glWindowPos2sARB\0" - "glWindowPos2sMESA\0" - "\0" - /* _mesa_function_pool[22379]: WeightusvARB (dynamic) */ - "ip\0" - "glWeightusvARB\0" - "\0" - /* _mesa_function_pool[22398]: ColorP4ui (will be remapped) */ - "ii\0" - "glColorP4ui\0" - "\0" - /* _mesa_function_pool[22414]: TexCoordPointer (offset 320) */ - "iiip\0" - "glTexCoordPointer\0" - "\0" - /* _mesa_function_pool[22438]: FogCoordPointerEXT (will be remapped) */ - "iip\0" - "glFogCoordPointer\0" - "glFogCoordPointerEXT\0" - "\0" - /* _mesa_function_pool[22482]: GetnSeparableFilterARB (will be remapped) */ - "iiiipipp\0" - "glGetnSeparableFilterARB\0" - "\0" - /* _mesa_function_pool[22517]: IndexMaterialEXT (dynamic) */ - "ii\0" - "glIndexMaterialEXT\0" - "\0" - /* _mesa_function_pool[22540]: Color3i (offset 15) */ - "iii\0" - "glColor3i\0" - "\0" - /* _mesa_function_pool[22555]: FrontFace (offset 157) */ - "i\0" - "glFrontFace\0" - "\0" - /* _mesa_function_pool[22570]: EvalCoord2d (offset 232) */ - "dd\0" - "glEvalCoord2d\0" - "\0" - /* _mesa_function_pool[22588]: SecondaryColor3ubvEXT (will be remapped) */ - "p\0" - "glSecondaryColor3ubv\0" - "glSecondaryColor3ubvEXT\0" - "\0" - /* _mesa_function_pool[22636]: EvalCoord2f (offset 234) */ - "ff\0" - "glEvalCoord2f\0" - "\0" - /* _mesa_function_pool[22654]: VertexAttrib4dvARB (will be remapped) */ - "ip\0" - "glVertexAttrib4dv\0" - "glVertexAttrib4dvARB\0" - "\0" - /* _mesa_function_pool[22697]: BindAttribLocationARB (will be remapped) */ - "iip\0" - "glBindAttribLocation\0" - "glBindAttribLocationARB\0" - "\0" - /* _mesa_function_pool[22747]: Color3b (offset 9) */ - "iii\0" - "glColor3b\0" - "\0" - /* _mesa_function_pool[22762]: MultiTexCoord2dARB (offset 384) */ - "idd\0" - "glMultiTexCoord2d\0" - "glMultiTexCoord2dARB\0" - "\0" - /* _mesa_function_pool[22806]: ExecuteProgramNV (will be remapped) */ - "iip\0" - "glExecuteProgramNV\0" - "\0" - /* _mesa_function_pool[22830]: Color3f (offset 13) */ - "fff\0" - "glColor3f\0" - "\0" - /* _mesa_function_pool[22845]: LightEnviSGIX (dynamic) */ - "ii\0" - "glLightEnviSGIX\0" - "\0" - /* _mesa_function_pool[22865]: Color3d (offset 11) */ - "ddd\0" - "glColor3d\0" - "\0" - /* _mesa_function_pool[22880]: Normal3dv (offset 55) */ - "p\0" - "glNormal3dv\0" - "\0" - /* _mesa_function_pool[22895]: Lightf (offset 159) */ - "iif\0" - "glLightf\0" - "\0" - /* _mesa_function_pool[22909]: ReplacementCodeuiSUN (dynamic) */ - "i\0" - "glReplacementCodeuiSUN\0" - "\0" - /* _mesa_function_pool[22935]: MatrixMode (offset 293) */ - "i\0" - "glMatrixMode\0" - "\0" - /* _mesa_function_pool[22951]: GetPixelMapusv (offset 273) */ - "ip\0" - "glGetPixelMapusv\0" - "\0" - /* _mesa_function_pool[22972]: Lighti (offset 161) */ - "iii\0" - "glLighti\0" - "\0" - /* _mesa_function_pool[22986]: VertexAttribPointerNV (will be remapped) */ - "iiiip\0" - "glVertexAttribPointerNV\0" - "\0" - /* _mesa_function_pool[23017]: ClearDepthf (will be remapped) */ - "f\0" - "glClearDepthf\0" - "\0" - /* _mesa_function_pool[23034]: GetBooleanIndexedvEXT (will be remapped) */ - "iip\0" - "glGetBooleanIndexedvEXT\0" - "glGetBooleani_v\0" - "\0" - /* _mesa_function_pool[23079]: GetFramebufferAttachmentParameterivEXT (will be remapped) */ - "iiip\0" - "glGetFramebufferAttachmentParameteriv\0" - "glGetFramebufferAttachmentParameterivEXT\0" - "\0" - /* _mesa_function_pool[23164]: PixelTransformParameterfEXT (dynamic) */ - "iif\0" - "glPixelTransformParameterfEXT\0" - "\0" - /* _mesa_function_pool[23199]: MultiTexCoord4dvARB (offset 401) */ - "ip\0" - "glMultiTexCoord4dv\0" - "glMultiTexCoord4dvARB\0" - "\0" - /* _mesa_function_pool[23244]: PixelTransformParameteriEXT (dynamic) */ - "iii\0" - "glPixelTransformParameteriEXT\0" - "\0" - /* _mesa_function_pool[23279]: GetDoublev (offset 260) */ - "ip\0" - "glGetDoublev\0" - "\0" - /* _mesa_function_pool[23296]: MultiTexCoordP4ui (will be remapped) */ - "iii\0" - "glMultiTexCoordP4ui\0" - "\0" - /* _mesa_function_pool[23321]: TexCoordP2uiv (will be remapped) */ - "ip\0" - "glTexCoordP2uiv\0" - "\0" - /* _mesa_function_pool[23341]: MultMatrixd (offset 295) */ - "p\0" - "glMultMatrixd\0" - "\0" - /* _mesa_function_pool[23358]: MultMatrixf (offset 294) */ - "p\0" - "glMultMatrixf\0" - "\0" - /* _mesa_function_pool[23375]: VertexAttribI4bvEXT (will be remapped) */ - "ip\0" - "glVertexAttribI4bvEXT\0" - "glVertexAttribI4bv\0" - "\0" - /* _mesa_function_pool[23420]: TexCoord2fColor4ubVertex3fSUN (dynamic) */ - "ffiiiifff\0" - "glTexCoord2fColor4ubVertex3fSUN\0" - "\0" - /* _mesa_function_pool[23463]: Uniform1iARB (will be remapped) */ - "ii\0" - "glUniform1i\0" - "glUniform1iARB\0" - "\0" - /* _mesa_function_pool[23494]: GetnMapfvARB (will be remapped) */ - "iiip\0" - "glGetnMapfvARB\0" - "\0" - /* _mesa_function_pool[23515]: VertexAttribPointerARB (will be remapped) */ - "iiiiip\0" - "glVertexAttribPointer\0" - "glVertexAttribPointerARB\0" - "\0" - /* _mesa_function_pool[23570]: VertexAttrib3sNV (will be remapped) */ - "iiii\0" - "glVertexAttrib3sNV\0" - "\0" - /* _mesa_function_pool[23595]: SharpenTexFuncSGIS (dynamic) */ - "iip\0" - "glSharpenTexFuncSGIS\0" - "\0" - /* _mesa_function_pool[23621]: MultiTexCoord4fvARB (offset 403) */ - "ip\0" - "glMultiTexCoord4fv\0" - "glMultiTexCoord4fvARB\0" - "\0" - /* _mesa_function_pool[23666]: Uniform2uiEXT (will be remapped) */ - "iii\0" - "glUniform2uiEXT\0" - "glUniform2ui\0" - "\0" - /* _mesa_function_pool[23700]: TexCoordP3uiv (will be remapped) */ - "ip\0" - "glTexCoordP3uiv\0" - "\0" - /* _mesa_function_pool[23720]: UniformMatrix2x3fv (will be remapped) */ - "iiip\0" - "glUniformMatrix2x3fv\0" - "\0" - /* _mesa_function_pool[23747]: SamplerParameteri (will be remapped) */ - "iii\0" - "glSamplerParameteri\0" - "\0" - /* _mesa_function_pool[23772]: SamplerParameterf (will be remapped) */ - "iif\0" - "glSamplerParameterf\0" - "\0" - /* _mesa_function_pool[23797]: CombinerParameteriNV (will be remapped) */ - "ii\0" - "glCombinerParameteriNV\0" - "\0" - /* _mesa_function_pool[23824]: DeleteAsyncMarkersSGIX (dynamic) */ - "ii\0" - "glDeleteAsyncMarkersSGIX\0" - "\0" - /* _mesa_function_pool[23853]: ReplacementCodeusSUN (dynamic) */ - "i\0" - "glReplacementCodeusSUN\0" - "\0" - /* _mesa_function_pool[23879]: IsAsyncMarkerSGIX (dynamic) */ - "i\0" - "glIsAsyncMarkerSGIX\0" - "\0" - /* _mesa_function_pool[23902]: FrameZoomSGIX (dynamic) */ - "i\0" - "glFrameZoomSGIX\0" - "\0" - /* _mesa_function_pool[23921]: Normal3fVertex3fvSUN (dynamic) */ - "pp\0" - "glNormal3fVertex3fvSUN\0" - "\0" - /* _mesa_function_pool[23948]: GetnUniformuivARB (will be remapped) */ - "iiip\0" - "glGetnUniformuivARB\0" - "\0" - /* _mesa_function_pool[23974]: RasterPos4sv (offset 85) */ - "p\0" - "glRasterPos4sv\0" - "\0" - /* _mesa_function_pool[23992]: VertexAttrib4NsvARB (will be remapped) */ - "ip\0" - "glVertexAttrib4Nsv\0" - "glVertexAttrib4NsvARB\0" - "\0" - /* _mesa_function_pool[24037]: VertexAttrib3fvARB (will be remapped) */ - "ip\0" - "glVertexAttrib3fv\0" - "glVertexAttrib3fvARB\0" - "\0" - /* _mesa_function_pool[24080]: ClearColor (offset 206) */ - "ffff\0" - "glClearColor\0" - "\0" - /* _mesa_function_pool[24099]: GetSynciv (will be remapped) */ - "iiipp\0" - "glGetSynciv\0" - "\0" - /* _mesa_function_pool[24118]: ClearColorIiEXT (will be remapped) */ - "iiii\0" - "glClearColorIiEXT\0" - "\0" - /* _mesa_function_pool[24142]: DeleteFramebuffersEXT (will be remapped) */ - "ip\0" - "glDeleteFramebuffers\0" - "glDeleteFramebuffersEXT\0" - "\0" - /* _mesa_function_pool[24191]: GlobalAlphaFactorsSUN (dynamic) */ - "i\0" - "glGlobalAlphaFactorsSUN\0" - "\0" - /* _mesa_function_pool[24218]: IsEnabledIndexedEXT (will be remapped) */ - "ii\0" - "glIsEnabledIndexedEXT\0" - "glIsEnabledi\0" - "\0" - /* _mesa_function_pool[24257]: TexEnviv (offset 187) */ - "iip\0" - "glTexEnviv\0" - "\0" - /* _mesa_function_pool[24273]: TexSubImage3D (offset 372) */ - "iiiiiiiiiip\0" - "glTexSubImage3D\0" - "glTexSubImage3DEXT\0" - "\0" - /* _mesa_function_pool[24321]: Tangent3fEXT (dynamic) */ - "fff\0" - "glTangent3fEXT\0" - "\0" - /* _mesa_function_pool[24341]: SecondaryColor3uivEXT (will be remapped) */ - "p\0" - "glSecondaryColor3uiv\0" - "glSecondaryColor3uivEXT\0" - "\0" - /* _mesa_function_pool[24389]: MatrixIndexubvARB (dynamic) */ - "ip\0" - "glMatrixIndexubvARB\0" - "\0" - /* _mesa_function_pool[24413]: Color4fNormal3fVertex3fSUN (dynamic) */ - "ffffffffff\0" - "glColor4fNormal3fVertex3fSUN\0" - "\0" - /* _mesa_function_pool[24454]: PixelTexGenParameterfSGIS (will be remapped) */ - "if\0" - "glPixelTexGenParameterfSGIS\0" - "\0" - /* _mesa_function_pool[24486]: CreateShader (will be remapped) */ - "i\0" - "glCreateShader\0" - "\0" - /* _mesa_function_pool[24504]: GetColorTableParameterfv (offset 344) */ - "iip\0" - "glGetColorTableParameterfv\0" - "glGetColorTableParameterfvSGI\0" - "glGetColorTableParameterfvEXT\0" - "\0" - /* _mesa_function_pool[24596]: FragmentLightModelfvSGIX (dynamic) */ - "ip\0" - "glFragmentLightModelfvSGIX\0" - "\0" - /* _mesa_function_pool[24627]: Bitmap (offset 8) */ - "iiffffp\0" - "glBitmap\0" - "\0" - /* _mesa_function_pool[24645]: MultiTexCoord3fARB (offset 394) */ - "ifff\0" - "glMultiTexCoord3f\0" - "glMultiTexCoord3fARB\0" - "\0" - /* _mesa_function_pool[24690]: GetTexLevelParameterfv (offset 284) */ - "iiip\0" - "glGetTexLevelParameterfv\0" - "\0" - /* _mesa_function_pool[24721]: GetPixelTexGenParameterfvSGIS (will be remapped) */ - "ip\0" - "glGetPixelTexGenParameterfvSGIS\0" - "\0" - /* _mesa_function_pool[24757]: GenFramebuffersEXT (will be remapped) */ - "ip\0" - "glGenFramebuffers\0" - "glGenFramebuffersEXT\0" - "\0" - /* _mesa_function_pool[24800]: VertexAttribDivisor (will be remapped) */ - "ii\0" - "glVertexAttribDivisor\0" - "\0" - /* _mesa_function_pool[24826]: GetProgramParameterdvNV (will be remapped) */ - "iiip\0" - "glGetProgramParameterdvNV\0" - "\0" - /* _mesa_function_pool[24858]: Vertex2sv (offset 133) */ - "p\0" - "glVertex2sv\0" - "\0" - /* _mesa_function_pool[24873]: GetIntegerv (offset 263) */ - "ip\0" - "glGetIntegerv\0" - "\0" - /* _mesa_function_pool[24891]: IsVertexArrayAPPLE (will be remapped) */ - "i\0" - "glIsVertexArray\0" - "glIsVertexArrayAPPLE\0" - "\0" - /* _mesa_function_pool[24931]: FragmentLightfvSGIX (dynamic) */ - "iip\0" - "glFragmentLightfvSGIX\0" - "\0" - /* _mesa_function_pool[24958]: GetnMapdvARB (will be remapped) */ - "iiip\0" - "glGetnMapdvARB\0" - "\0" - /* _mesa_function_pool[24979]: DetachShader (will be remapped) */ - "ii\0" - "glDetachShader\0" - "\0" - /* _mesa_function_pool[24998]: VertexAttrib4NubARB (will be remapped) */ - "iiiii\0" - "glVertexAttrib4Nub\0" - "glVertexAttrib4NubARB\0" - "\0" - /* _mesa_function_pool[25046]: GetProgramEnvParameterfvARB (will be remapped) */ - "iip\0" - "glGetProgramEnvParameterfvARB\0" - "\0" - /* _mesa_function_pool[25081]: GetTrackMatrixivNV (will be remapped) */ - "iiip\0" - "glGetTrackMatrixivNV\0" - "\0" - /* _mesa_function_pool[25108]: VertexAttrib3svNV (will be remapped) */ - "ip\0" - "glVertexAttrib3svNV\0" - "\0" - /* _mesa_function_pool[25132]: Uniform4fvARB (will be remapped) */ - "iip\0" - "glUniform4fv\0" - "glUniform4fvARB\0" - "\0" - /* _mesa_function_pool[25166]: MultTransposeMatrixfARB (will be remapped) */ - "p\0" - "glMultTransposeMatrixf\0" - "glMultTransposeMatrixfARB\0" - "\0" - /* _mesa_function_pool[25218]: GetTexEnviv (offset 277) */ - "iip\0" - "glGetTexEnviv\0" - "\0" - /* _mesa_function_pool[25237]: ColorFragmentOp1ATI (will be remapped) */ - "iiiiiii\0" - "glColorFragmentOp1ATI\0" - "\0" - /* _mesa_function_pool[25268]: GetUniformfvARB (will be remapped) */ - "iip\0" - "glGetUniformfv\0" - "glGetUniformfvARB\0" - "\0" - /* _mesa_function_pool[25306]: EGLImageTargetRenderbufferStorageOES (will be remapped) */ - "ip\0" - "glEGLImageTargetRenderbufferStorageOES\0" - "\0" - /* _mesa_function_pool[25349]: VertexAttribI2ivEXT (will be remapped) */ - "ip\0" - "glVertexAttribI2ivEXT\0" - "glVertexAttribI2iv\0" - "\0" - /* _mesa_function_pool[25394]: PopClientAttrib (offset 334) */ - "\0" - "glPopClientAttrib\0" - "\0" - /* _mesa_function_pool[25414]: ReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN (dynamic) */ - "iffffffffffff\0" - "glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN\0" - "\0" - /* _mesa_function_pool[25485]: DetachObjectARB (will be remapped) */ - "ii\0" - "glDetachObjectARB\0" - "\0" - /* _mesa_function_pool[25507]: VertexBlendARB (dynamic) */ - "i\0" - "glVertexBlendARB\0" - "\0" - /* _mesa_function_pool[25527]: WindowPos3iMESA (will be remapped) */ - "iii\0" - "glWindowPos3i\0" - "glWindowPos3iARB\0" - "glWindowPos3iMESA\0" - "\0" - /* _mesa_function_pool[25581]: SeparableFilter2D (offset 360) */ - "iiiiiipp\0" - "glSeparableFilter2D\0" - "glSeparableFilter2DEXT\0" - "\0" - /* _mesa_function_pool[25634]: ProgramParameteriARB (will be remapped) */ - "iii\0" - "glProgramParameteriARB\0" - "\0" - /* _mesa_function_pool[25662]: Map1d (offset 220) */ - "iddiip\0" - "glMap1d\0" - "\0" - /* _mesa_function_pool[25678]: Map1f (offset 221) */ - "iffiip\0" - "glMap1f\0" - "\0" - /* _mesa_function_pool[25694]: CompressedTexImage2DARB (will be remapped) */ - "iiiiiiip\0" - "glCompressedTexImage2D\0" - "glCompressedTexImage2DARB\0" - "\0" - /* _mesa_function_pool[25753]: ArrayElement (offset 306) */ - "i\0" - "glArrayElement\0" - "glArrayElementEXT\0" - "\0" - /* _mesa_function_pool[25789]: TexImage2D (offset 183) */ - "iiiiiiiip\0" - "glTexImage2D\0" - "\0" - /* _mesa_function_pool[25813]: DepthBoundsEXT (will be remapped) */ - "dd\0" - "glDepthBoundsEXT\0" - "\0" - /* _mesa_function_pool[25834]: ProgramParameters4fvNV (will be remapped) */ - "iiip\0" - "glProgramParameters4fvNV\0" - "\0" - /* _mesa_function_pool[25865]: DeformationMap3fSGIX (dynamic) */ - "iffiiffiiffiip\0" - "glDeformationMap3fSGIX\0" - "\0" - /* _mesa_function_pool[25904]: GetProgramivNV (will be remapped) */ - "iip\0" - "glGetProgramivNV\0" - "\0" - /* _mesa_function_pool[25926]: GetFragDataLocationEXT (will be remapped) */ - "ip\0" - "glGetFragDataLocationEXT\0" - "glGetFragDataLocation\0" - "\0" - /* _mesa_function_pool[25977]: GetMinmaxParameteriv (offset 366) */ - "iip\0" - "glGetMinmaxParameteriv\0" - "glGetMinmaxParameterivEXT\0" - "\0" - /* _mesa_function_pool[26031]: PixelTransferf (offset 247) */ - "if\0" - "glPixelTransferf\0" - "\0" - /* _mesa_function_pool[26052]: CopyTexImage1D (offset 323) */ - "iiiiiii\0" - "glCopyTexImage1D\0" - "glCopyTexImage1DEXT\0" - "\0" - /* _mesa_function_pool[26098]: PushMatrix (offset 298) */ - "\0" - "glPushMatrix\0" - "\0" - /* _mesa_function_pool[26113]: Fogiv (offset 156) */ - "ip\0" - "glFogiv\0" - "\0" - /* _mesa_function_pool[26125]: TexCoord1dv (offset 95) */ - "p\0" - "glTexCoord1dv\0" - "\0" - /* _mesa_function_pool[26142]: AlphaFragmentOp3ATI (will be remapped) */ - "iiiiiiiiiiii\0" - "glAlphaFragmentOp3ATI\0" - "\0" - /* _mesa_function_pool[26178]: PixelTransferi (offset 248) */ - "ii\0" - "glPixelTransferi\0" - "\0" - /* _mesa_function_pool[26199]: GetnColorTableARB (will be remapped) */ - "iiiip\0" - "glGetnColorTableARB\0" - "\0" - /* _mesa_function_pool[26226]: VertexAttrib3fvNV (will be remapped) */ - "ip\0" - "glVertexAttrib3fvNV\0" - "\0" - /* _mesa_function_pool[26250]: Rotatef (offset 300) */ - "ffff\0" - "glRotatef\0" - "\0" - /* _mesa_function_pool[26266]: GetFinalCombinerInputParameterivNV (will be remapped) */ - "iip\0" - "glGetFinalCombinerInputParameterivNV\0" - "\0" - /* _mesa_function_pool[26308]: Vertex3i (offset 138) */ - "iii\0" - "glVertex3i\0" - "\0" - /* _mesa_function_pool[26324]: SecondaryColorP3ui (will be remapped) */ - "ii\0" - "glSecondaryColorP3ui\0" - "\0" - /* _mesa_function_pool[26349]: Vertex3f (offset 136) */ - "fff\0" - "glVertex3f\0" - "\0" - /* _mesa_function_pool[26365]: Clear (offset 203) */ - "i\0" - "glClear\0" - "\0" - /* _mesa_function_pool[26376]: Vertex3d (offset 134) */ - "ddd\0" - "glVertex3d\0" - "\0" - /* _mesa_function_pool[26392]: GetMapParameterivNV (dynamic) */ - "iip\0" - "glGetMapParameterivNV\0" - "\0" - /* _mesa_function_pool[26419]: Uniform4iARB (will be remapped) */ - "iiiii\0" - "glUniform4i\0" - "glUniform4iARB\0" - "\0" - /* _mesa_function_pool[26453]: ReadBuffer (offset 254) */ - "i\0" - "glReadBuffer\0" - "\0" - /* _mesa_function_pool[26469]: ConvolutionParameteri (offset 352) */ - "iii\0" - "glConvolutionParameteri\0" - "glConvolutionParameteriEXT\0" - "\0" - /* _mesa_function_pool[26525]: Ortho (offset 296) */ - "dddddd\0" - "glOrtho\0" - "\0" - /* _mesa_function_pool[26541]: Binormal3sEXT (dynamic) */ - "iii\0" - "glBinormal3sEXT\0" - "\0" - /* _mesa_function_pool[26562]: ListBase (offset 6) */ - "i\0" - "glListBase\0" - "\0" - /* _mesa_function_pool[26576]: VertexAttribI3ivEXT (will be remapped) */ - "ip\0" - "glVertexAttribI3ivEXT\0" - "glVertexAttribI3iv\0" - "\0" - /* _mesa_function_pool[26621]: MultiTexCoordP1ui (will be remapped) */ - "iii\0" - "glMultiTexCoordP1ui\0" - "\0" - /* _mesa_function_pool[26646]: Vertex3s (offset 140) */ - "iii\0" - "glVertex3s\0" - "\0" - /* _mesa_function_pool[26662]: ConvolutionParameterf (offset 350) */ - "iif\0" - "glConvolutionParameterf\0" - "glConvolutionParameterfEXT\0" - "\0" - /* _mesa_function_pool[26718]: GetColorTableParameteriv (offset 345) */ - "iip\0" - "glGetColorTableParameteriv\0" - "glGetColorTableParameterivSGI\0" - "glGetColorTableParameterivEXT\0" - "\0" - /* _mesa_function_pool[26810]: ProgramEnvParameter4dvARB (will be remapped) */ - "iip\0" - "glProgramEnvParameter4dvARB\0" - "glProgramParameter4dvNV\0" - "\0" - /* _mesa_function_pool[26867]: ShadeModel (offset 177) */ - "i\0" - "glShadeModel\0" - "\0" - /* _mesa_function_pool[26883]: VertexAttribs2fvNV (will be remapped) */ - "iip\0" - "glVertexAttribs2fvNV\0" - "\0" - /* _mesa_function_pool[26909]: Rectiv (offset 91) */ - "pp\0" - "glRectiv\0" - "\0" - /* _mesa_function_pool[26922]: UseProgramObjectARB (will be remapped) */ - "i\0" - "glUseProgram\0" - "glUseProgramObjectARB\0" - "\0" - /* _mesa_function_pool[26960]: GetMapParameterfvNV (dynamic) */ - "iip\0" - "glGetMapParameterfvNV\0" - "\0" - /* _mesa_function_pool[26987]: EndConditionalRenderNV (will be remapped) */ - "\0" - "glEndConditionalRenderNV\0" - "glEndConditionalRender\0" - "\0" - /* _mesa_function_pool[27037]: PassTexCoordATI (will be remapped) */ - "iii\0" - "glPassTexCoordATI\0" - "\0" - /* _mesa_function_pool[27060]: DeleteProgram (will be remapped) */ - "i\0" - "glDeleteProgram\0" - "\0" - /* _mesa_function_pool[27079]: GetSamplerParameteriv (will be remapped) */ - "iip\0" - "glGetSamplerParameteriv\0" - "\0" - /* _mesa_function_pool[27108]: Tangent3dEXT (dynamic) */ - "ddd\0" - "glTangent3dEXT\0" - "\0" - /* _mesa_function_pool[27128]: SecondaryColor3dvEXT (will be remapped) */ - "p\0" - "glSecondaryColor3dv\0" - "glSecondaryColor3dvEXT\0" - "\0" - /* _mesa_function_pool[27174]: AlphaFragmentOp2ATI (will be remapped) */ - "iiiiiiiii\0" - "glAlphaFragmentOp2ATI\0" - "\0" - /* _mesa_function_pool[27207]: Vertex2fv (offset 129) */ - "p\0" - "glVertex2fv\0" - "\0" - /* _mesa_function_pool[27222]: MultiDrawArraysEXT (will be remapped) */ - "ippi\0" - "glMultiDrawArrays\0" - "glMultiDrawArraysEXT\0" - "\0" - /* _mesa_function_pool[27267]: BindRenderbufferEXT (will be remapped) */ - "ii\0" - "glBindRenderbuffer\0" - "glBindRenderbufferEXT\0" - "\0" - /* _mesa_function_pool[27312]: MultiTexCoord4dARB (offset 400) */ - "idddd\0" - "glMultiTexCoord4d\0" - "glMultiTexCoord4dARB\0" - "\0" - /* _mesa_function_pool[27358]: FramebufferTextureFaceARB (will be remapped) */ - "iiiii\0" - "glFramebufferTextureFaceARB\0" - "\0" - /* _mesa_function_pool[27393]: Vertex3sv (offset 141) */ - "p\0" - "glVertex3sv\0" - "\0" - /* _mesa_function_pool[27408]: SecondaryColor3usEXT (will be remapped) */ - "iii\0" - "glSecondaryColor3us\0" - "glSecondaryColor3usEXT\0" - "\0" - /* _mesa_function_pool[27456]: ProgramLocalParameter4fvARB (will be remapped) */ - "iip\0" - "glProgramLocalParameter4fvARB\0" - "\0" - /* _mesa_function_pool[27491]: DeleteProgramsNV (will be remapped) */ - "ip\0" - "glDeleteProgramsARB\0" - "glDeleteProgramsNV\0" - "\0" - /* _mesa_function_pool[27534]: EvalMesh1 (offset 236) */ - "iii\0" - "glEvalMesh1\0" - "\0" - /* _mesa_function_pool[27551]: PauseTransformFeedback (will be remapped) */ - "\0" - "glPauseTransformFeedback\0" - "\0" - /* _mesa_function_pool[27578]: MultiTexCoord1sARB (offset 382) */ - "ii\0" - "glMultiTexCoord1s\0" - "glMultiTexCoord1sARB\0" - "\0" - /* _mesa_function_pool[27621]: ReplacementCodeuiColor3fVertex3fSUN (dynamic) */ - "iffffff\0" - "glReplacementCodeuiColor3fVertex3fSUN\0" - "\0" - /* _mesa_function_pool[27668]: GetVertexAttribPointervNV (will be remapped) */ - "iip\0" - "glGetVertexAttribPointerv\0" - "glGetVertexAttribPointervARB\0" - "glGetVertexAttribPointervNV\0" - "\0" - /* _mesa_function_pool[27756]: VertexAttribs1fvNV (will be remapped) */ - "iip\0" - "glVertexAttribs1fvNV\0" - "\0" - /* _mesa_function_pool[27782]: MultiTexCoord1dvARB (offset 377) */ - "ip\0" - "glMultiTexCoord1dv\0" - "glMultiTexCoord1dvARB\0" - "\0" - /* _mesa_function_pool[27827]: Uniform2iARB (will be remapped) */ - "iii\0" - "glUniform2i\0" - "glUniform2iARB\0" - "\0" - /* _mesa_function_pool[27859]: Vertex2iv (offset 131) */ - "p\0" - "glVertex2iv\0" - "\0" - /* _mesa_function_pool[27874]: GetProgramStringNV (will be remapped) */ - "iip\0" - "glGetProgramStringNV\0" - "\0" - /* _mesa_function_pool[27900]: ColorPointerEXT (will be remapped) */ - "iiiip\0" - "glColorPointerEXT\0" - "\0" - /* _mesa_function_pool[27925]: LineWidth (offset 168) */ - "f\0" - "glLineWidth\0" - "\0" - /* _mesa_function_pool[27940]: MapBufferARB (will be remapped) */ - "ii\0" - "glMapBuffer\0" - "glMapBufferARB\0" - "\0" - /* _mesa_function_pool[27971]: MultiDrawElementsBaseVertex (will be remapped) */ - "ipipip\0" - "glMultiDrawElementsBaseVertex\0" - "\0" - /* _mesa_function_pool[28009]: TexParameterIuivEXT (will be remapped) */ - "iip\0" - "glTexParameterIuivEXT\0" - "glTexParameterIuiv\0" - "\0" - /* _mesa_function_pool[28055]: Binormal3svEXT (dynamic) */ - "p\0" - "glBinormal3svEXT\0" - "\0" - /* _mesa_function_pool[28075]: ApplyTextureEXT (dynamic) */ - "i\0" - "glApplyTextureEXT\0" - "\0" - /* _mesa_function_pool[28096]: GetBufferParameteri64v (will be remapped) */ - "iip\0" - "glGetBufferParameteri64v\0" - "\0" - /* _mesa_function_pool[28126]: TexGendv (offset 189) */ - "iip\0" - "glTexGendv\0" - "\0" - /* _mesa_function_pool[28142]: VertexAttribI3iEXT (will be remapped) */ - "iiii\0" - "glVertexAttribI3iEXT\0" - "glVertexAttribI3i\0" - "\0" - /* _mesa_function_pool[28187]: EnableIndexedEXT (will be remapped) */ - "ii\0" - "glEnableIndexedEXT\0" - "glEnablei\0" - "\0" - /* _mesa_function_pool[28220]: TextureMaterialEXT (dynamic) */ - "ii\0" - "glTextureMaterialEXT\0" - "\0" - /* _mesa_function_pool[28245]: TextureLightEXT (dynamic) */ - "i\0" - "glTextureLightEXT\0" - "\0" - /* _mesa_function_pool[28266]: ResetMinmax (offset 370) */ - "i\0" - "glResetMinmax\0" - "glResetMinmaxEXT\0" - "\0" - /* _mesa_function_pool[28300]: SpriteParameterfSGIX (dynamic) */ - "if\0" - "glSpriteParameterfSGIX\0" - "\0" - /* _mesa_function_pool[28327]: EnableClientState (offset 313) */ - "i\0" - "glEnableClientState\0" - "\0" - /* _mesa_function_pool[28350]: VertexAttrib4sNV (will be remapped) */ - "iiiii\0" - "glVertexAttrib4sNV\0" - "\0" - /* _mesa_function_pool[28376]: GetConvolutionParameterfv (offset 357) */ - "iip\0" - "glGetConvolutionParameterfv\0" - "glGetConvolutionParameterfvEXT\0" - "\0" - /* _mesa_function_pool[28440]: VertexAttribs4dvNV (will be remapped) */ - "iip\0" - "glVertexAttribs4dvNV\0" - "\0" - /* _mesa_function_pool[28466]: MultiModeDrawArraysIBM (will be remapped) */ - "pppii\0" - "glMultiModeDrawArraysIBM\0" - "\0" - /* _mesa_function_pool[28498]: VertexAttrib4dARB (will be remapped) */ - "idddd\0" - "glVertexAttrib4d\0" - "glVertexAttrib4dARB\0" - "\0" - /* _mesa_function_pool[28542]: GetTexBumpParameterfvATI (will be remapped) */ - "ip\0" - "glGetTexBumpParameterfvATI\0" - "\0" - /* _mesa_function_pool[28573]: ProgramNamedParameter4dNV (will be remapped) */ - "iipdddd\0" - "glProgramNamedParameter4dNV\0" - "\0" - /* _mesa_function_pool[28610]: GetMaterialfv (offset 269) */ - "iip\0" - "glGetMaterialfv\0" - "\0" - /* _mesa_function_pool[28631]: VertexWeightfEXT (dynamic) */ - "f\0" - "glVertexWeightfEXT\0" - "\0" - /* _mesa_function_pool[28653]: SetFragmentShaderConstantATI (will be remapped) */ - "ip\0" - "glSetFragmentShaderConstantATI\0" - "\0" - /* _mesa_function_pool[28688]: Binormal3fEXT (dynamic) */ - "fff\0" - "glBinormal3fEXT\0" - "\0" - /* _mesa_function_pool[28709]: CallList (offset 2) */ - "i\0" - "glCallList\0" - "\0" - /* _mesa_function_pool[28723]: Materialfv (offset 170) */ - "iip\0" - "glMaterialfv\0" - "\0" - /* _mesa_function_pool[28741]: TexCoord3fv (offset 113) */ - "p\0" - "glTexCoord3fv\0" - "\0" - /* _mesa_function_pool[28758]: FogCoordfvEXT (will be remapped) */ - "p\0" - "glFogCoordfv\0" - "glFogCoordfvEXT\0" - "\0" - /* _mesa_function_pool[28790]: MultiTexCoord1ivARB (offset 381) */ - "ip\0" - "glMultiTexCoord1iv\0" - "glMultiTexCoord1ivARB\0" - "\0" - /* _mesa_function_pool[28835]: SecondaryColor3ubEXT (will be remapped) */ - "iii\0" - "glSecondaryColor3ub\0" - "glSecondaryColor3ubEXT\0" - "\0" - /* _mesa_function_pool[28883]: MultiTexCoord2ivARB (offset 389) */ - "ip\0" - "glMultiTexCoord2iv\0" - "glMultiTexCoord2ivARB\0" - "\0" - /* _mesa_function_pool[28928]: FogFuncSGIS (dynamic) */ - "ip\0" - "glFogFuncSGIS\0" - "\0" - /* _mesa_function_pool[28946]: CopyTexSubImage2D (offset 326) */ - "iiiiiiii\0" - "glCopyTexSubImage2D\0" - "glCopyTexSubImage2DEXT\0" - "\0" - /* _mesa_function_pool[28999]: GetObjectParameterivARB (will be remapped) */ - "iip\0" - "glGetObjectParameterivARB\0" - "\0" - /* _mesa_function_pool[29030]: Color3iv (offset 16) */ - "p\0" - "glColor3iv\0" - "\0" - /* _mesa_function_pool[29044]: TexCoord4fVertex4fSUN (dynamic) */ - "ffffffff\0" - "glTexCoord4fVertex4fSUN\0" - "\0" - /* _mesa_function_pool[29078]: DrawElements (offset 311) */ - "iiip\0" - "glDrawElements\0" - "\0" - /* _mesa_function_pool[29099]: BindVertexArrayAPPLE (will be remapped) */ - "i\0" - "glBindVertexArrayAPPLE\0" - "\0" - /* _mesa_function_pool[29125]: GetProgramLocalParameterdvARB (will be remapped) */ - "iip\0" - "glGetProgramLocalParameterdvARB\0" - "\0" - /* _mesa_function_pool[29162]: GetHistogramParameteriv (offset 363) */ - "iip\0" - "glGetHistogramParameteriv\0" - "glGetHistogramParameterivEXT\0" - "\0" - /* _mesa_function_pool[29222]: MultiTexCoord1iARB (offset 380) */ - "ii\0" - "glMultiTexCoord1i\0" - "glMultiTexCoord1iARB\0" - "\0" - /* _mesa_function_pool[29265]: GetConvolutionFilter (offset 356) */ - "iiip\0" - "glGetConvolutionFilter\0" - "glGetConvolutionFilterEXT\0" - "\0" - /* _mesa_function_pool[29320]: GetProgramivARB (will be remapped) */ - "iip\0" - "glGetProgramivARB\0" - "\0" - /* _mesa_function_pool[29343]: TexBufferARB (will be remapped) */ - "iii\0" - "glTexBufferARB\0" - "\0" - /* _mesa_function_pool[29363]: BlendFuncSeparateEXT (will be remapped) */ - "iiii\0" - "glBlendFuncSeparate\0" - "glBlendFuncSeparateEXT\0" - "glBlendFuncSeparateINGR\0" - "\0" - /* _mesa_function_pool[29436]: MapBufferRange (will be remapped) */ - "iiii\0" - "glMapBufferRange\0" - "\0" - /* _mesa_function_pool[29459]: ProgramParameters4dvNV (will be remapped) */ - "iiip\0" - "glProgramParameters4dvNV\0" - "\0" - /* _mesa_function_pool[29490]: TexCoord2fColor3fVertex3fvSUN (dynamic) */ - "ppp\0" - "glTexCoord2fColor3fVertex3fvSUN\0" - "\0" - /* _mesa_function_pool[29527]: EvalPoint2 (offset 239) */ - "ii\0" - "glEvalPoint2\0" - "\0" - /* _mesa_function_pool[29544]: Uniform1uivEXT (will be remapped) */ - "iip\0" - "glUniform1uivEXT\0" - "glUniform1uiv\0" - "\0" - /* _mesa_function_pool[29580]: EvalPoint1 (offset 237) */ - "i\0" - "glEvalPoint1\0" - "\0" - /* _mesa_function_pool[29596]: Binormal3dvEXT (dynamic) */ - "p\0" - "glBinormal3dvEXT\0" - "\0" - /* _mesa_function_pool[29616]: PopMatrix (offset 297) */ - "\0" - "glPopMatrix\0" - "\0" - /* _mesa_function_pool[29630]: GetVertexAttribIuivEXT (will be remapped) */ - "iip\0" - "glGetVertexAttribIuivEXT\0" - "glGetVertexAttribIuiv\0" - "\0" - /* _mesa_function_pool[29682]: FinishFenceNV (will be remapped) */ - "i\0" - "glFinishFenceNV\0" - "\0" - /* _mesa_function_pool[29701]: GetFogFuncSGIS (dynamic) */ - "p\0" - "glGetFogFuncSGIS\0" - "\0" - /* _mesa_function_pool[29721]: GetUniformLocationARB (will be remapped) */ - "ip\0" - "glGetUniformLocation\0" - "glGetUniformLocationARB\0" - "\0" - /* _mesa_function_pool[29770]: SecondaryColor3fEXT (will be remapped) */ - "fff\0" - "glSecondaryColor3f\0" - "glSecondaryColor3fEXT\0" - "\0" - /* _mesa_function_pool[29816]: GetTexGeniv (offset 280) */ - "iip\0" - "glGetTexGeniv\0" - "\0" - /* _mesa_function_pool[29835]: CombinerInputNV (will be remapped) */ - "iiiiii\0" - "glCombinerInputNV\0" - "\0" - /* _mesa_function_pool[29861]: VertexAttrib3sARB (will be remapped) */ - "iiii\0" - "glVertexAttrib3s\0" - "glVertexAttrib3sARB\0" - "\0" - /* _mesa_function_pool[29904]: IsTransformFeedback (will be remapped) */ - "i\0" - "glIsTransformFeedback\0" - "\0" - /* _mesa_function_pool[29929]: ReplacementCodeuiNormal3fVertex3fvSUN (dynamic) */ - "ppp\0" - "glReplacementCodeuiNormal3fVertex3fvSUN\0" - "\0" - /* _mesa_function_pool[29974]: Map2d (offset 222) */ - "iddiiddiip\0" - "glMap2d\0" - "\0" - /* _mesa_function_pool[29994]: Map2f (offset 223) */ - "iffiiffiip\0" - "glMap2f\0" - "\0" - /* _mesa_function_pool[30014]: ProgramStringARB (will be remapped) */ - "iiip\0" - "glProgramStringARB\0" - "\0" - /* _mesa_function_pool[30039]: Vertex4s (offset 148) */ - "iiii\0" - "glVertex4s\0" - "\0" - /* _mesa_function_pool[30056]: TexCoord4fVertex4fvSUN (dynamic) */ - "pp\0" - "glTexCoord4fVertex4fvSUN\0" - "\0" - /* _mesa_function_pool[30085]: FragmentLightModelivSGIX (dynamic) */ - "ip\0" - "glFragmentLightModelivSGIX\0" - "\0" - /* _mesa_function_pool[30116]: VertexAttrib1fNV (will be remapped) */ - "if\0" - "glVertexAttrib1fNV\0" - "\0" - /* _mesa_function_pool[30139]: Vertex4f (offset 144) */ - "ffff\0" - "glVertex4f\0" - "\0" - /* _mesa_function_pool[30156]: EvalCoord1d (offset 228) */ - "d\0" - "glEvalCoord1d\0" - "\0" - /* _mesa_function_pool[30173]: Vertex4d (offset 142) */ - "dddd\0" - "glVertex4d\0" - "\0" - /* _mesa_function_pool[30190]: RasterPos4dv (offset 79) */ - "p\0" - "glRasterPos4dv\0" - "\0" - /* _mesa_function_pool[30208]: UseShaderProgramEXT (will be remapped) */ - "ii\0" - "glUseShaderProgramEXT\0" - "\0" - /* _mesa_function_pool[30234]: FragmentLightfSGIX (dynamic) */ - "iif\0" - "glFragmentLightfSGIX\0" - "\0" - /* _mesa_function_pool[30260]: GetCompressedTexImageARB (will be remapped) */ - "iip\0" - "glGetCompressedTexImage\0" - "glGetCompressedTexImageARB\0" - "\0" - /* _mesa_function_pool[30316]: GetTexGenfv (offset 279) */ - "iip\0" - "glGetTexGenfv\0" - "\0" - /* _mesa_function_pool[30335]: Vertex4i (offset 146) */ - "iiii\0" - "glVertex4i\0" - "\0" - /* _mesa_function_pool[30352]: VertexWeightPointerEXT (dynamic) */ - "iiip\0" - "glVertexWeightPointerEXT\0" - "\0" - /* _mesa_function_pool[30383]: GetHistogram (offset 361) */ - "iiiip\0" - "glGetHistogram\0" - "glGetHistogramEXT\0" - "\0" - /* _mesa_function_pool[30423]: ActiveStencilFaceEXT (will be remapped) */ - "i\0" - "glActiveStencilFaceEXT\0" - "\0" - /* _mesa_function_pool[30449]: StencilFuncSeparateATI (will be remapped) */ - "iiii\0" - "glStencilFuncSeparateATI\0" - "\0" - /* _mesa_function_pool[30480]: Materialf (offset 169) */ - "iif\0" - "glMaterialf\0" - "\0" - /* _mesa_function_pool[30497]: GetShaderSourceARB (will be remapped) */ - "iipp\0" - "glGetShaderSource\0" - "glGetShaderSourceARB\0" - "\0" - /* _mesa_function_pool[30542]: IglooInterfaceSGIX (dynamic) */ - "ip\0" - "glIglooInterfaceSGIX\0" - "\0" - /* _mesa_function_pool[30567]: Materiali (offset 171) */ - "iii\0" - "glMateriali\0" - "\0" - /* _mesa_function_pool[30584]: VertexAttrib4dNV (will be remapped) */ - "idddd\0" - "glVertexAttrib4dNV\0" - "\0" - /* _mesa_function_pool[30610]: MultiModeDrawElementsIBM (will be remapped) */ - "ppipii\0" - "glMultiModeDrawElementsIBM\0" - "\0" - /* _mesa_function_pool[30645]: Indexsv (offset 51) */ - "p\0" - "glIndexsv\0" - "\0" - /* _mesa_function_pool[30658]: MultiTexCoord4svARB (offset 407) */ - "ip\0" - "glMultiTexCoord4sv\0" - "glMultiTexCoord4svARB\0" - "\0" - /* _mesa_function_pool[30703]: LightModelfv (offset 164) */ - "ip\0" - "glLightModelfv\0" - "\0" - /* _mesa_function_pool[30722]: TexCoord2dv (offset 103) */ - "p\0" - "glTexCoord2dv\0" - "\0" - /* _mesa_function_pool[30739]: GenQueriesARB (will be remapped) */ - "ip\0" - "glGenQueries\0" - "glGenQueriesARB\0" - "\0" - /* _mesa_function_pool[30772]: EvalCoord1dv (offset 229) */ - "p\0" - "glEvalCoord1dv\0" - "\0" - /* _mesa_function_pool[30790]: ReplacementCodeuiVertex3fSUN (dynamic) */ - "ifff\0" - "glReplacementCodeuiVertex3fSUN\0" - "\0" - /* _mesa_function_pool[30827]: Translated (offset 303) */ - "ddd\0" - "glTranslated\0" - "\0" - /* _mesa_function_pool[30845]: Translatef (offset 304) */ - "fff\0" - "glTranslatef\0" - "\0" - /* _mesa_function_pool[30863]: Uniform3uiEXT (will be remapped) */ - "iiii\0" - "glUniform3uiEXT\0" - "glUniform3ui\0" - "\0" - /* _mesa_function_pool[30898]: StencilMask (offset 209) */ - "i\0" - "glStencilMask\0" - "\0" - /* _mesa_function_pool[30915]: Tangent3iEXT (dynamic) */ - "iii\0" - "glTangent3iEXT\0" - "\0" - /* _mesa_function_pool[30935]: ClampColorARB (will be remapped) */ - "ii\0" - "glClampColorARB\0" - "\0" - /* _mesa_function_pool[30955]: GetLightiv (offset 265) */ - "iip\0" - "glGetLightiv\0" - "\0" - /* _mesa_function_pool[30973]: GetSamplerParameterIiv (will be remapped) */ - "iip\0" - "glGetSamplerParameterIiv\0" - "\0" - /* _mesa_function_pool[31003]: DrawMeshArraysSUN (dynamic) */ - "iiii\0" - "glDrawMeshArraysSUN\0" - "\0" - /* _mesa_function_pool[31029]: IsList (offset 287) */ - "i\0" - "glIsList\0" - "\0" - /* _mesa_function_pool[31041]: IsSync (will be remapped) */ - "i\0" - "glIsSync\0" - "\0" - /* _mesa_function_pool[31053]: RenderMode (offset 196) */ - "i\0" - "glRenderMode\0" - "\0" - /* _mesa_function_pool[31069]: GetMapControlPointsNV (dynamic) */ - "iiiiiip\0" - "glGetMapControlPointsNV\0" - "\0" - /* _mesa_function_pool[31102]: DrawBuffersARB (will be remapped) */ - "ip\0" - "glDrawBuffers\0" - "glDrawBuffersARB\0" - "glDrawBuffersATI\0" - "\0" - /* _mesa_function_pool[31154]: ClearBufferiv (will be remapped) */ - "iip\0" - "glClearBufferiv\0" - "\0" - /* _mesa_function_pool[31175]: ProgramLocalParameter4fARB (will be remapped) */ - "iiffff\0" - "glProgramLocalParameter4fARB\0" - "\0" - /* _mesa_function_pool[31212]: SpriteParameterivSGIX (dynamic) */ - "ip\0" - "glSpriteParameterivSGIX\0" - "\0" - /* _mesa_function_pool[31240]: ProvokingVertexEXT (will be remapped) */ - "i\0" - "glProvokingVertexEXT\0" - "glProvokingVertex\0" - "\0" - /* _mesa_function_pool[31282]: MultiTexCoord1fARB (offset 378) */ - "if\0" - "glMultiTexCoord1f\0" - "glMultiTexCoord1fARB\0" - "\0" - /* _mesa_function_pool[31325]: LoadName (offset 198) */ - "i\0" - "glLoadName\0" - "\0" - /* _mesa_function_pool[31339]: VertexAttribs4ubvNV (will be remapped) */ - "iip\0" - "glVertexAttribs4ubvNV\0" - "\0" - /* _mesa_function_pool[31366]: WeightsvARB (dynamic) */ - "ip\0" - "glWeightsvARB\0" - "\0" - /* _mesa_function_pool[31384]: NormalP3ui (will be remapped) */ - "ii\0" - "glNormalP3ui\0" - "\0" - /* _mesa_function_pool[31401]: Uniform1fvARB (will be remapped) */ - "iip\0" - "glUniform1fv\0" - "glUniform1fvARB\0" - "\0" - /* _mesa_function_pool[31435]: CopyTexSubImage1D (offset 325) */ - "iiiiii\0" - "glCopyTexSubImage1D\0" - "glCopyTexSubImage1DEXT\0" - "\0" - /* _mesa_function_pool[31486]: CullFace (offset 152) */ - "i\0" - "glCullFace\0" - "\0" - /* _mesa_function_pool[31500]: BindTexture (offset 307) */ - "ii\0" - "glBindTexture\0" - "glBindTextureEXT\0" - "\0" - /* _mesa_function_pool[31535]: BeginFragmentShaderATI (will be remapped) */ - "\0" - "glBeginFragmentShaderATI\0" - "\0" - /* _mesa_function_pool[31562]: MultiTexCoord4fARB (offset 402) */ - "iffff\0" - "glMultiTexCoord4f\0" - "glMultiTexCoord4fARB\0" - "\0" - /* _mesa_function_pool[31608]: VertexAttribs3svNV (will be remapped) */ - "iip\0" - "glVertexAttribs3svNV\0" - "\0" - /* _mesa_function_pool[31634]: StencilFunc (offset 243) */ - "iii\0" - "glStencilFunc\0" - "\0" - /* _mesa_function_pool[31653]: CopyPixels (offset 255) */ - "iiiii\0" - "glCopyPixels\0" - "\0" - /* _mesa_function_pool[31673]: Rectsv (offset 93) */ - "pp\0" - "glRectsv\0" - "\0" - /* _mesa_function_pool[31686]: ReplacementCodeuivSUN (dynamic) */ - "p\0" - "glReplacementCodeuivSUN\0" - "\0" - /* _mesa_function_pool[31713]: MultiTexCoordP2uiv (will be remapped) */ - "iip\0" - "glMultiTexCoordP2uiv\0" - "\0" - /* _mesa_function_pool[31739]: EnableVertexAttribArrayARB (will be remapped) */ - "i\0" - "glEnableVertexAttribArray\0" - "glEnableVertexAttribArrayARB\0" - "\0" - /* _mesa_function_pool[31797]: NormalPointervINTEL (dynamic) */ - "ip\0" - "glNormalPointervINTEL\0" - "\0" - /* _mesa_function_pool[31823]: CopyConvolutionFilter2D (offset 355) */ - "iiiiii\0" - "glCopyConvolutionFilter2D\0" - "glCopyConvolutionFilter2DEXT\0" - "\0" - /* _mesa_function_pool[31886]: WindowPos3ivMESA (will be remapped) */ - "p\0" - "glWindowPos3iv\0" - "glWindowPos3ivARB\0" - "glWindowPos3ivMESA\0" - "\0" - /* _mesa_function_pool[31941]: CopyBufferSubData (will be remapped) */ - "iiiii\0" - "glCopyBufferSubData\0" - "\0" - /* _mesa_function_pool[31968]: NormalPointer (offset 318) */ - "iip\0" - "glNormalPointer\0" - "\0" - /* _mesa_function_pool[31989]: TexParameterfv (offset 179) */ - "iip\0" - "glTexParameterfv\0" - "\0" - /* _mesa_function_pool[32011]: IsBufferARB (will be remapped) */ - "i\0" - "glIsBuffer\0" - "glIsBufferARB\0" - "\0" - /* _mesa_function_pool[32039]: WindowPos4iMESA (will be remapped) */ - "iiii\0" - "glWindowPos4iMESA\0" - "\0" - /* _mesa_function_pool[32063]: VertexAttrib4uivARB (will be remapped) */ - "ip\0" - "glVertexAttrib4uiv\0" - "glVertexAttrib4uivARB\0" - "\0" - /* _mesa_function_pool[32108]: Tangent3bvEXT (dynamic) */ - "p\0" - "glTangent3bvEXT\0" - "\0" - /* _mesa_function_pool[32127]: VertexAttribI3uivEXT (will be remapped) */ - "ip\0" - "glVertexAttribI3uivEXT\0" - "glVertexAttribI3uiv\0" - "\0" - /* _mesa_function_pool[32174]: UniformMatrix3x4fv (will be remapped) */ - "iiip\0" - "glUniformMatrix3x4fv\0" - "\0" - /* _mesa_function_pool[32201]: ClipPlane (offset 150) */ - "ip\0" - "glClipPlane\0" - "\0" - /* _mesa_function_pool[32217]: Recti (offset 90) */ - "iiii\0" - "glRecti\0" - "\0" - /* _mesa_function_pool[32231]: TrackMatrixNV (will be remapped) */ - "iiii\0" - "glTrackMatrixNV\0" - "\0" - /* _mesa_function_pool[32253]: DrawRangeElementsBaseVertex (will be remapped) */ - "iiiiipi\0" - "glDrawRangeElementsBaseVertex\0" - "\0" - /* _mesa_function_pool[32292]: SamplerParameterIuiv (will be remapped) */ - "iip\0" - "glSamplerParameterIuiv\0" - "\0" - /* _mesa_function_pool[32320]: TexCoordPointervINTEL (dynamic) */ - "iip\0" - "glTexCoordPointervINTEL\0" - "\0" - /* _mesa_function_pool[32349]: DeleteBuffersARB (will be remapped) */ - "ip\0" - "glDeleteBuffers\0" - "glDeleteBuffersARB\0" - "\0" - /* _mesa_function_pool[32388]: PixelTransformParameterfvEXT (dynamic) */ - "iip\0" - "glPixelTransformParameterfvEXT\0" - "\0" - /* _mesa_function_pool[32424]: PrimitiveRestartNV (will be remapped) */ - "\0" - "glPrimitiveRestartNV\0" - "\0" - /* _mesa_function_pool[32447]: WindowPos4fvMESA (will be remapped) */ - "p\0" - "glWindowPos4fvMESA\0" - "\0" - /* _mesa_function_pool[32469]: GetPixelMapuiv (offset 272) */ - "ip\0" - "glGetPixelMapuiv\0" - "\0" - /* _mesa_function_pool[32490]: Rectf (offset 88) */ - "ffff\0" - "glRectf\0" - "\0" - /* _mesa_function_pool[32504]: VertexAttrib1sNV (will be remapped) */ - "ii\0" - "glVertexAttrib1sNV\0" - "\0" - /* _mesa_function_pool[32527]: Indexfv (offset 47) */ - "p\0" - "glIndexfv\0" - "\0" - /* _mesa_function_pool[32540]: ColorP3uiv (will be remapped) */ - "ip\0" - "glColorP3uiv\0" - "\0" - /* _mesa_function_pool[32557]: SecondaryColor3svEXT (will be remapped) */ - "p\0" - "glSecondaryColor3sv\0" - "glSecondaryColor3svEXT\0" - "\0" - /* _mesa_function_pool[32603]: LoadTransposeMatrixfARB (will be remapped) */ - "p\0" - "glLoadTransposeMatrixf\0" - "glLoadTransposeMatrixfARB\0" - "\0" - /* _mesa_function_pool[32655]: GetPointerv (offset 329) */ - "ip\0" - "glGetPointerv\0" - "glGetPointervEXT\0" - "\0" - /* _mesa_function_pool[32690]: Tangent3bEXT (dynamic) */ - "iii\0" - "glTangent3bEXT\0" - "\0" - /* _mesa_function_pool[32710]: CombinerParameterfNV (will be remapped) */ - "if\0" - "glCombinerParameterfNV\0" - "\0" - /* _mesa_function_pool[32737]: IndexMask (offset 212) */ - "i\0" - "glIndexMask\0" - "\0" - /* _mesa_function_pool[32752]: BindProgramNV (will be remapped) */ - "ii\0" - "glBindProgramARB\0" - "glBindProgramNV\0" - "\0" - /* _mesa_function_pool[32789]: VertexAttrib4svARB (will be remapped) */ - "ip\0" - "glVertexAttrib4sv\0" - "glVertexAttrib4svARB\0" - "\0" - /* _mesa_function_pool[32832]: GetFloatv (offset 262) */ - "ip\0" - "glGetFloatv\0" - "\0" - /* _mesa_function_pool[32848]: CreateDebugObjectMESA (dynamic) */ - "\0" - "glCreateDebugObjectMESA\0" - "\0" - /* _mesa_function_pool[32874]: GetShaderiv (will be remapped) */ - "iip\0" - "glGetShaderiv\0" - "\0" - /* _mesa_function_pool[32893]: ClientWaitSync (will be remapped) */ - "iii\0" - "glClientWaitSync\0" - "\0" - /* _mesa_function_pool[32915]: TexCoord4s (offset 124) */ - "iiii\0" - "glTexCoord4s\0" - "\0" - /* _mesa_function_pool[32934]: TexCoord3sv (offset 117) */ - "p\0" - "glTexCoord3sv\0" - "\0" - /* _mesa_function_pool[32951]: BindFragmentShaderATI (will be remapped) */ - "i\0" - "glBindFragmentShaderATI\0" - "\0" - /* _mesa_function_pool[32978]: PopAttrib (offset 218) */ - "\0" - "glPopAttrib\0" - "\0" - /* _mesa_function_pool[32992]: Fogfv (offset 154) */ - "ip\0" - "glFogfv\0" - "\0" - /* _mesa_function_pool[33004]: UnmapBufferARB (will be remapped) */ - "i\0" - "glUnmapBuffer\0" - "glUnmapBufferARB\0" - "\0" - /* _mesa_function_pool[33038]: InitNames (offset 197) */ - "\0" - "glInitNames\0" - "\0" - /* _mesa_function_pool[33052]: Normal3sv (offset 61) */ - "p\0" - "glNormal3sv\0" - "\0" - /* _mesa_function_pool[33067]: Minmax (offset 368) */ - "iii\0" - "glMinmax\0" - "glMinmaxEXT\0" - "\0" - /* _mesa_function_pool[33093]: TexCoord4d (offset 118) */ - "dddd\0" - "glTexCoord4d\0" - "\0" - /* _mesa_function_pool[33112]: TexCoord4f (offset 120) */ - "ffff\0" - "glTexCoord4f\0" - "\0" - /* _mesa_function_pool[33131]: FogCoorddvEXT (will be remapped) */ - "p\0" - "glFogCoorddv\0" - "glFogCoorddvEXT\0" - "\0" - /* _mesa_function_pool[33163]: FinishTextureSUNX (dynamic) */ - "\0" - "glFinishTextureSUNX\0" - "\0" - /* _mesa_function_pool[33185]: GetFragmentLightfvSGIX (dynamic) */ - "iip\0" - "glGetFragmentLightfvSGIX\0" - "\0" - /* _mesa_function_pool[33215]: Binormal3fvEXT (dynamic) */ - "p\0" - "glBinormal3fvEXT\0" - "\0" - /* _mesa_function_pool[33235]: GetBooleanv (offset 258) */ - "ip\0" - "glGetBooleanv\0" - "\0" - /* _mesa_function_pool[33253]: ColorFragmentOp3ATI (will be remapped) */ - "iiiiiiiiiiiii\0" - "glColorFragmentOp3ATI\0" - "\0" - /* _mesa_function_pool[33290]: Hint (offset 158) */ - "ii\0" - "glHint\0" - "\0" - /* _mesa_function_pool[33301]: Color4dv (offset 28) */ - "p\0" - "glColor4dv\0" - "\0" - /* _mesa_function_pool[33315]: VertexAttrib2svARB (will be remapped) */ - "ip\0" - "glVertexAttrib2sv\0" - "glVertexAttrib2svARB\0" - "\0" - /* _mesa_function_pool[33358]: AreProgramsResidentNV (will be remapped) */ - "ipp\0" - "glAreProgramsResidentNV\0" - "\0" - /* _mesa_function_pool[33387]: WindowPos3svMESA (will be remapped) */ - "p\0" - "glWindowPos3sv\0" - "glWindowPos3svARB\0" - "glWindowPos3svMESA\0" - "\0" - /* _mesa_function_pool[33442]: CopyColorSubTable (offset 347) */ - "iiiii\0" - "glCopyColorSubTable\0" - "glCopyColorSubTableEXT\0" - "\0" - /* _mesa_function_pool[33492]: WeightdvARB (dynamic) */ - "ip\0" - "glWeightdvARB\0" - "\0" - /* _mesa_function_pool[33510]: DeleteRenderbuffersEXT (will be remapped) */ - "ip\0" - "glDeleteRenderbuffers\0" - "glDeleteRenderbuffersEXT\0" - "\0" - /* _mesa_function_pool[33561]: VertexAttrib4NubvARB (will be remapped) */ - "ip\0" - "glVertexAttrib4Nubv\0" - "glVertexAttrib4NubvARB\0" - "\0" - /* _mesa_function_pool[33608]: VertexAttrib3dvNV (will be remapped) */ - "ip\0" - "glVertexAttrib3dvNV\0" - "\0" - /* _mesa_function_pool[33632]: GetObjectParameterfvARB (will be remapped) */ - "iip\0" - "glGetObjectParameterfvARB\0" - "\0" - /* _mesa_function_pool[33663]: Vertex4iv (offset 147) */ - "p\0" - "glVertex4iv\0" - "\0" - /* _mesa_function_pool[33678]: GetProgramEnvParameterdvARB (will be remapped) */ - "iip\0" - "glGetProgramEnvParameterdvARB\0" - "\0" - /* _mesa_function_pool[33713]: TexCoord4dv (offset 119) */ - "p\0" - "glTexCoord4dv\0" - "\0" - /* _mesa_function_pool[33730]: LockArraysEXT (will be remapped) */ - "ii\0" - "glLockArraysEXT\0" - "\0" - /* _mesa_function_pool[33750]: Begin (offset 7) */ - "i\0" - "glBegin\0" - "\0" - /* _mesa_function_pool[33761]: LightModeli (offset 165) */ - "ii\0" - "glLightModeli\0" - "\0" - /* _mesa_function_pool[33779]: VertexAttribI4ivEXT (will be remapped) */ - "ip\0" - "glVertexAttribI4ivEXT\0" - "glVertexAttribI4iv\0" - "\0" - /* _mesa_function_pool[33824]: Rectfv (offset 89) */ - "pp\0" - "glRectfv\0" - "\0" - /* _mesa_function_pool[33837]: BlendEquationSeparateiARB (will be remapped) */ - "iii\0" - "glBlendEquationSeparateiARB\0" - "glBlendEquationSeparateIndexedAMD\0" - "\0" - /* _mesa_function_pool[33904]: LightModelf (offset 163) */ - "if\0" - "glLightModelf\0" - "\0" - /* _mesa_function_pool[33922]: GetTexParameterfv (offset 282) */ - "iip\0" - "glGetTexParameterfv\0" - "\0" - /* _mesa_function_pool[33947]: GetLightfv (offset 264) */ - "iip\0" - "glGetLightfv\0" - "\0" - /* _mesa_function_pool[33965]: PixelTransformParameterivEXT (dynamic) */ - "iip\0" - "glPixelTransformParameterivEXT\0" - "\0" - /* _mesa_function_pool[34001]: BinormalPointerEXT (dynamic) */ - "iip\0" - "glBinormalPointerEXT\0" - "\0" - /* _mesa_function_pool[34027]: VertexAttrib1dNV (will be remapped) */ - "id\0" - "glVertexAttrib1dNV\0" - "\0" - /* _mesa_function_pool[34050]: GetCombinerInputParameterivNV (will be remapped) */ - "iiiip\0" - "glGetCombinerInputParameterivNV\0" - "\0" - /* _mesa_function_pool[34089]: Disable (offset 214) */ - "i\0" - "glDisable\0" - "\0" - /* _mesa_function_pool[34102]: MultiTexCoord2fvARB (offset 387) */ - "ip\0" - "glMultiTexCoord2fv\0" - "glMultiTexCoord2fvARB\0" - "\0" - /* _mesa_function_pool[34147]: GetRenderbufferParameterivEXT (will be remapped) */ - "iip\0" - "glGetRenderbufferParameteriv\0" - "glGetRenderbufferParameterivEXT\0" - "\0" - /* _mesa_function_pool[34213]: CombinerParameterivNV (will be remapped) */ - "ip\0" - "glCombinerParameterivNV\0" - "\0" - /* _mesa_function_pool[34241]: GenFragmentShadersATI (will be remapped) */ - "i\0" - "glGenFragmentShadersATI\0" - "\0" - /* _mesa_function_pool[34268]: DrawArrays (offset 310) */ - "iii\0" - "glDrawArrays\0" - "glDrawArraysEXT\0" - "\0" - /* _mesa_function_pool[34302]: WeightuivARB (dynamic) */ - "ip\0" - "glWeightuivARB\0" - "\0" - /* _mesa_function_pool[34321]: GetVertexAttribIivEXT (will be remapped) */ - "iip\0" - "glGetVertexAttribIivEXT\0" - "glGetVertexAttribIiv\0" - "\0" - /* _mesa_function_pool[34371]: VertexAttrib2sARB (will be remapped) */ - "iii\0" - "glVertexAttrib2s\0" - "glVertexAttrib2sARB\0" - "\0" - /* _mesa_function_pool[34413]: GetnTexImageARB (will be remapped) */ - "iiiiip\0" - "glGetnTexImageARB\0" - "\0" - /* _mesa_function_pool[34439]: ColorMask (offset 210) */ - "iiii\0" - "glColorMask\0" - "\0" - /* _mesa_function_pool[34457]: GenAsyncMarkersSGIX (dynamic) */ - "i\0" - "glGenAsyncMarkersSGIX\0" - "\0" - /* _mesa_function_pool[34482]: Tangent3svEXT (dynamic) */ - "p\0" - "glTangent3svEXT\0" - "\0" - /* _mesa_function_pool[34501]: GetListParameterivSGIX (dynamic) */ - "iip\0" - "glGetListParameterivSGIX\0" - "\0" - /* _mesa_function_pool[34531]: BindBufferARB (will be remapped) */ - "ii\0" - "glBindBuffer\0" - "glBindBufferARB\0" - "\0" - /* _mesa_function_pool[34564]: GetInfoLogARB (will be remapped) */ - "iipp\0" - "glGetInfoLogARB\0" - "\0" - /* _mesa_function_pool[34586]: RasterPos4iv (offset 83) */ - "p\0" - "glRasterPos4iv\0" - "\0" - /* _mesa_function_pool[34604]: Enable (offset 215) */ - "i\0" - "glEnable\0" - "\0" - /* _mesa_function_pool[34616]: LineStipple (offset 167) */ - "ii\0" - "glLineStipple\0" - "\0" - /* _mesa_function_pool[34634]: VertexAttribP2ui (will be remapped) */ - "iiii\0" - "glVertexAttribP2ui\0" - "\0" - /* _mesa_function_pool[34659]: VertexAttribs4svNV (will be remapped) */ - "iip\0" - "glVertexAttribs4svNV\0" - "\0" - /* _mesa_function_pool[34685]: EdgeFlagPointerListIBM (dynamic) */ - "ipi\0" - "glEdgeFlagPointerListIBM\0" - "\0" - /* _mesa_function_pool[34715]: UniformMatrix3x2fv (will be remapped) */ - "iiip\0" - "glUniformMatrix3x2fv\0" - "\0" - /* _mesa_function_pool[34742]: GetMinmaxParameterfv (offset 365) */ - "iip\0" - "glGetMinmaxParameterfv\0" - "glGetMinmaxParameterfvEXT\0" - "\0" - /* _mesa_function_pool[34796]: VertexAttrib1fvARB (will be remapped) */ - "ip\0" - "glVertexAttrib1fv\0" - "glVertexAttrib1fvARB\0" - "\0" - /* _mesa_function_pool[34839]: GenBuffersARB (will be remapped) */ - "ip\0" - "glGenBuffers\0" - "glGenBuffersARB\0" - "\0" - /* _mesa_function_pool[34872]: VertexAttribs1svNV (will be remapped) */ - "iip\0" - "glVertexAttribs1svNV\0" - "\0" - /* _mesa_function_pool[34898]: Vertex3fv (offset 137) */ - "p\0" - "glVertex3fv\0" - "\0" - /* _mesa_function_pool[34913]: GetTexBumpParameterivATI (will be remapped) */ - "ip\0" - "glGetTexBumpParameterivATI\0" - "\0" - /* _mesa_function_pool[34944]: Binormal3bEXT (dynamic) */ - "iii\0" - "glBinormal3bEXT\0" - "\0" - /* _mesa_function_pool[34965]: FragmentMaterialivSGIX (dynamic) */ - "iip\0" - "glFragmentMaterialivSGIX\0" - "\0" - /* _mesa_function_pool[34995]: IsRenderbufferEXT (will be remapped) */ - "i\0" - "glIsRenderbuffer\0" - "glIsRenderbufferEXT\0" - "\0" - /* _mesa_function_pool[35035]: GenProgramsNV (will be remapped) */ - "ip\0" - "glGenProgramsARB\0" - "glGenProgramsNV\0" - "\0" - /* _mesa_function_pool[35072]: VertexAttrib4dvNV (will be remapped) */ - "ip\0" - "glVertexAttrib4dvNV\0" - "\0" - /* _mesa_function_pool[35096]: EndFragmentShaderATI (will be remapped) */ - "\0" - "glEndFragmentShaderATI\0" - "\0" - /* _mesa_function_pool[35121]: Binormal3iEXT (dynamic) */ - "iii\0" - "glBinormal3iEXT\0" - "\0" - /* _mesa_function_pool[35142]: WindowPos2fMESA (will be remapped) */ - "ff\0" - "glWindowPos2f\0" - "glWindowPos2fARB\0" - "glWindowPos2fMESA\0" - "\0" - ; - -/* these functions need to be remapped */ -static const struct gl_function_pool_remap MESA_remap_table_functions[] = { - { 1629, AttachShader_remap_index }, - { 10613, CreateProgram_remap_index }, - { 24486, CreateShader_remap_index }, - { 27060, DeleteProgram_remap_index }, - { 19799, DeleteShader_remap_index }, - { 24979, DetachShader_remap_index }, - { 19046, GetAttachedShaders_remap_index }, - { 5341, GetProgramInfoLog_remap_index }, - { 444, GetProgramiv_remap_index }, - { 7189, GetShaderInfoLog_remap_index }, - { 32874, GetShaderiv_remap_index }, - { 14162, IsProgram_remap_index }, - { 13063, IsShader_remap_index }, - { 10743, StencilFuncSeparate_remap_index }, - { 4371, StencilMaskSeparate_remap_index }, - { 8254, StencilOpSeparate_remap_index }, - { 23720, UniformMatrix2x3fv_remap_index }, - { 3098, UniformMatrix2x4fv_remap_index }, - { 34715, UniformMatrix3x2fv_remap_index }, - { 32174, UniformMatrix3x4fv_remap_index }, - { 17220, UniformMatrix4x2fv_remap_index }, - { 3589, UniformMatrix4x3fv_remap_index }, - { 5564, ClampColor_remap_index }, - { 19100, ClearBufferfi_remap_index }, - { 18516, ClearBufferfv_remap_index }, - { 31154, ClearBufferiv_remap_index }, - { 14367, ClearBufferuiv_remap_index }, - { 21222, GetStringi_remap_index }, - { 3000, TexBuffer_remap_index }, - { 977, FramebufferTexture_remap_index }, - { 28096, GetBufferParameteri64v_remap_index }, - { 10843, GetInteger64i_v_remap_index }, - { 24800, VertexAttribDivisor_remap_index }, - { 10631, LoadTransposeMatrixdARB_remap_index }, - { 32603, LoadTransposeMatrixfARB_remap_index }, - { 6249, MultTransposeMatrixdARB_remap_index }, - { 25166, MultTransposeMatrixfARB_remap_index }, - { 255, SampleCoverageARB_remap_index }, - { 6452, CompressedTexImage1DARB_remap_index }, - { 25694, CompressedTexImage2DARB_remap_index }, - { 4434, CompressedTexImage3DARB_remap_index }, - { 19388, CompressedTexSubImage1DARB_remap_index }, - { 2185, CompressedTexSubImage2DARB_remap_index }, - { 21644, CompressedTexSubImage3DARB_remap_index }, - { 30260, GetCompressedTexImageARB_remap_index }, - { 4181, DisableVertexAttribArrayARB_remap_index }, - { 31739, EnableVertexAttribArrayARB_remap_index }, - { 33678, GetProgramEnvParameterdvARB_remap_index }, - { 25046, GetProgramEnvParameterfvARB_remap_index }, - { 29125, GetProgramLocalParameterdvARB_remap_index }, - { 8730, GetProgramLocalParameterfvARB_remap_index }, - { 19564, GetProgramStringARB_remap_index }, - { 29320, GetProgramivARB_remap_index }, - { 21839, GetVertexAttribdvARB_remap_index }, - { 17028, GetVertexAttribfvARB_remap_index }, - { 10422, GetVertexAttribivARB_remap_index }, - { 20659, ProgramEnvParameter4dARB_remap_index }, - { 26810, ProgramEnvParameter4dvARB_remap_index }, - { 17814, ProgramEnvParameter4fARB_remap_index }, - { 9605, ProgramEnvParameter4fvARB_remap_index }, - { 4397, ProgramLocalParameter4dARB_remap_index }, - { 13872, ProgramLocalParameter4dvARB_remap_index }, - { 31175, ProgramLocalParameter4fARB_remap_index }, - { 27456, ProgramLocalParameter4fvARB_remap_index }, - { 30014, ProgramStringARB_remap_index }, - { 20953, VertexAttrib1dARB_remap_index }, - { 16629, VertexAttrib1dvARB_remap_index }, - { 4593, VertexAttrib1fARB_remap_index }, - { 34796, VertexAttrib1fvARB_remap_index }, - { 7780, VertexAttrib1sARB_remap_index }, - { 2380, VertexAttrib1svARB_remap_index }, - { 16042, VertexAttrib2dARB_remap_index }, - { 18537, VertexAttrib2dvARB_remap_index }, - { 1712, VertexAttrib2fARB_remap_index }, - { 18650, VertexAttrib2fvARB_remap_index }, - { 34371, VertexAttrib2sARB_remap_index }, - { 33315, VertexAttrib2svARB_remap_index }, - { 12047, VertexAttrib3dARB_remap_index }, - { 9272, VertexAttrib3dvARB_remap_index }, - { 1799, VertexAttrib3fARB_remap_index }, - { 24037, VertexAttrib3fvARB_remap_index }, - { 29861, VertexAttrib3sARB_remap_index }, - { 21581, VertexAttrib3svARB_remap_index }, - { 5384, VertexAttrib4NbvARB_remap_index }, - { 18923, VertexAttrib4NivARB_remap_index }, - { 23992, VertexAttrib4NsvARB_remap_index }, - { 24998, VertexAttrib4NubARB_remap_index }, - { 33561, VertexAttrib4NubvARB_remap_index }, - { 20310, VertexAttrib4NuivARB_remap_index }, - { 3419, VertexAttrib4NusvARB_remap_index }, - { 11636, VertexAttrib4bvARB_remap_index }, - { 28498, VertexAttrib4dARB_remap_index }, - { 22654, VertexAttrib4dvARB_remap_index }, - { 12201, VertexAttrib4fARB_remap_index }, - { 12605, VertexAttrib4fvARB_remap_index }, - { 10986, VertexAttrib4ivARB_remap_index }, - { 18330, VertexAttrib4sARB_remap_index }, - { 32789, VertexAttrib4svARB_remap_index }, - { 17619, VertexAttrib4ubvARB_remap_index }, - { 32063, VertexAttrib4uivARB_remap_index }, - { 21392, VertexAttrib4usvARB_remap_index }, - { 23515, VertexAttribPointerARB_remap_index }, - { 34531, BindBufferARB_remap_index }, - { 7487, BufferDataARB_remap_index }, - { 1550, BufferSubDataARB_remap_index }, - { 32349, DeleteBuffersARB_remap_index }, - { 34839, GenBuffersARB_remap_index }, - { 18693, GetBufferParameterivARB_remap_index }, - { 17766, GetBufferPointervARB_remap_index }, - { 1503, GetBufferSubDataARB_remap_index }, - { 32011, IsBufferARB_remap_index }, - { 27940, MapBufferARB_remap_index }, - { 33004, UnmapBufferARB_remap_index }, - { 351, BeginQueryARB_remap_index }, - { 21048, DeleteQueriesARB_remap_index }, - { 12924, EndQueryARB_remap_index }, - { 30739, GenQueriesARB_remap_index }, - { 2077, GetQueryObjectivARB_remap_index }, - { 18374, GetQueryObjectuivARB_remap_index }, - { 1856, GetQueryivARB_remap_index }, - { 21299, IsQueryARB_remap_index }, - { 8882, AttachObjectARB_remap_index }, - { 19761, CompileShaderARB_remap_index }, - { 3531, CreateProgramObjectARB_remap_index }, - { 7432, CreateShaderObjectARB_remap_index }, - { 15325, DeleteObjectARB_remap_index }, - { 25485, DetachObjectARB_remap_index }, - { 12669, GetActiveUniformARB_remap_index }, - { 10097, GetAttachedObjectsARB_remap_index }, - { 10404, GetHandleARB_remap_index }, - { 34564, GetInfoLogARB_remap_index }, - { 33632, GetObjectParameterfvARB_remap_index }, - { 28999, GetObjectParameterivARB_remap_index }, - { 30497, GetShaderSourceARB_remap_index }, - { 29721, GetUniformLocationARB_remap_index }, - { 25268, GetUniformfvARB_remap_index }, - { 13447, GetUniformivARB_remap_index }, - { 21437, LinkProgramARB_remap_index }, - { 21495, ShaderSourceARB_remap_index }, - { 8154, Uniform1fARB_remap_index }, - { 31401, Uniform1fvARB_remap_index }, - { 23463, Uniform1iARB_remap_index }, - { 22292, Uniform1ivARB_remap_index }, - { 2329, Uniform2fARB_remap_index }, - { 15161, Uniform2fvARB_remap_index }, - { 27827, Uniform2iARB_remap_index }, - { 2466, Uniform2ivARB_remap_index }, - { 19871, Uniform3fARB_remap_index }, - { 10127, Uniform3fvARB_remap_index }, - { 7043, Uniform3iARB_remap_index }, - { 17872, Uniform3ivARB_remap_index }, - { 20465, Uniform4fARB_remap_index }, - { 25132, Uniform4fvARB_remap_index }, - { 26419, Uniform4iARB_remap_index }, - { 21805, Uniform4ivARB_remap_index }, - { 8934, UniformMatrix2fvARB_remap_index }, - { 17, UniformMatrix3fvARB_remap_index }, - { 2902, UniformMatrix4fvARB_remap_index }, - { 26922, UseProgramObjectARB_remap_index }, - { 15730, ValidateProgramARB_remap_index }, - { 22697, BindAttribLocationARB_remap_index }, - { 5429, GetActiveAttribARB_remap_index }, - { 17553, GetAttribLocationARB_remap_index }, - { 31102, DrawBuffersARB_remap_index }, - { 30935, ClampColorARB_remap_index }, - { 18968, DrawArraysInstancedARB_remap_index }, - { 7104, DrawElementsInstancedARB_remap_index }, - { 13977, RenderbufferStorageMultisample_remap_index }, - { 14448, FramebufferTextureARB_remap_index }, - { 27358, FramebufferTextureFaceARB_remap_index }, - { 25634, ProgramParameteriARB_remap_index }, - { 6624, VertexAttribDivisorARB_remap_index }, - { 20513, FlushMappedBufferRange_remap_index }, - { 29436, MapBufferRange_remap_index }, - { 29343, TexBufferARB_remap_index }, - { 17358, BindVertexArray_remap_index }, - { 15534, GenVertexArrays_remap_index }, - { 31941, CopyBufferSubData_remap_index }, - { 32893, ClientWaitSync_remap_index }, - { 2821, DeleteSync_remap_index }, - { 7821, FenceSync_remap_index }, - { 16101, GetInteger64v_remap_index }, - { 24099, GetSynciv_remap_index }, - { 31041, IsSync_remap_index }, - { 10028, WaitSync_remap_index }, - { 4149, DrawElementsBaseVertex_remap_index }, - { 19616, DrawElementsInstancedBaseVertex_remap_index }, - { 32253, DrawRangeElementsBaseVertex_remap_index }, - { 27971, MultiDrawElementsBaseVertex_remap_index }, - { 33837, BlendEquationSeparateiARB_remap_index }, - { 18786, BlendEquationiARB_remap_index }, - { 13386, BlendFuncSeparateiARB_remap_index }, - { 10470, BlendFunciARB_remap_index }, - { 8796, BindSampler_remap_index }, - { 4572, DeleteSamplers_remap_index }, - { 20886, GenSamplers_remap_index }, - { 30973, GetSamplerParameterIiv_remap_index }, - { 20407, GetSamplerParameterIuiv_remap_index }, - { 5261, GetSamplerParameterfv_remap_index }, - { 27079, GetSamplerParameteriv_remap_index }, - { 15079, IsSampler_remap_index }, - { 17311, SamplerParameterIiv_remap_index }, - { 32292, SamplerParameterIuiv_remap_index }, - { 23772, SamplerParameterf_remap_index }, - { 17485, SamplerParameterfv_remap_index }, - { 23747, SamplerParameteri_remap_index }, - { 19162, SamplerParameteriv_remap_index }, - { 19969, ColorP3ui_remap_index }, - { 32540, ColorP3uiv_remap_index }, - { 22398, ColorP4ui_remap_index }, - { 4339, ColorP4uiv_remap_index }, - { 26621, MultiTexCoordP1ui_remap_index }, - { 13360, MultiTexCoordP1uiv_remap_index }, - { 1687, MultiTexCoordP2ui_remap_index }, - { 31713, MultiTexCoordP2uiv_remap_index }, - { 14691, MultiTexCoordP3ui_remap_index }, - { 11062, MultiTexCoordP3uiv_remap_index }, - { 23296, MultiTexCoordP4ui_remap_index }, - { 4011, MultiTexCoordP4uiv_remap_index }, - { 31384, NormalP3ui_remap_index }, - { 20145, NormalP3uiv_remap_index }, - { 26324, SecondaryColorP3ui_remap_index }, - { 20163, SecondaryColorP3uiv_remap_index }, - { 2802, TexCoordP1ui_remap_index }, - { 2569, TexCoordP1uiv_remap_index }, - { 15610, TexCoordP2ui_remap_index }, - { 23321, TexCoordP2uiv_remap_index }, - { 6331, TexCoordP3ui_remap_index }, - { 23700, TexCoordP3uiv_remap_index }, - { 1985, TexCoordP4ui_remap_index }, - { 5833, TexCoordP4uiv_remap_index }, - { 10513, VertexAttribP1ui_remap_index }, - { 14878, VertexAttribP1uiv_remap_index }, - { 34634, VertexAttribP2ui_remap_index }, - { 5625, VertexAttribP2uiv_remap_index }, - { 3484, VertexAttribP3ui_remap_index }, - { 20904, VertexAttribP3uiv_remap_index }, - { 14904, VertexAttribP4ui_remap_index }, - { 16886, VertexAttribP4uiv_remap_index }, - { 5367, VertexP2ui_remap_index }, - { 16456, VertexP2uiv_remap_index }, - { 2449, VertexP3ui_remap_index }, - { 17406, VertexP3uiv_remap_index }, - { 10056, VertexP4ui_remap_index }, - { 3466, VertexP4uiv_remap_index }, - { 5651, BindTransformFeedback_remap_index }, - { 3558, DeleteTransformFeedbacks_remap_index }, - { 7076, DrawTransformFeedback_remap_index }, - { 10264, GenTransformFeedbacks_remap_index }, - { 29904, IsTransformFeedback_remap_index }, - { 27551, PauseTransformFeedback_remap_index }, - { 6134, ResumeTransformFeedback_remap_index }, - { 23017, ClearDepthf_remap_index }, - { 7380, DepthRangef_remap_index }, - { 15346, GetShaderPrecisionFormat_remap_index }, - { 10683, ReleaseShaderCompiler_remap_index }, - { 11679, ShaderBinary_remap_index }, - { 1004, GetGraphicsResetStatusARB_remap_index }, - { 26199, GetnColorTableARB_remap_index }, - { 8565, GetnCompressedTexImageARB_remap_index }, - { 4288, GetnConvolutionFilterARB_remap_index }, - { 16672, GetnHistogramARB_remap_index }, - { 24958, GetnMapdvARB_remap_index }, - { 23494, GetnMapfvARB_remap_index }, - { 2308, GetnMapivARB_remap_index }, - { 18134, GetnMinmaxARB_remap_index }, - { 4886, GetnPixelMapfvARB_remap_index }, - { 20284, GetnPixelMapuivARB_remap_index }, - { 3211, GetnPixelMapusvARB_remap_index }, - { 1383, GetnPolygonStippleARB_remap_index }, - { 22482, GetnSeparableFilterARB_remap_index }, - { 34413, GetnTexImageARB_remap_index }, - { 19591, GetnUniformdvARB_remap_index }, - { 4958, GetnUniformfvARB_remap_index }, - { 10538, GetnUniformivARB_remap_index }, - { 23948, GetnUniformuivARB_remap_index }, - { 3125, ReadnPixelsARB_remap_index }, - { 6002, PolygonOffsetEXT_remap_index }, - { 24721, GetPixelTexGenParameterfvSGIS_remap_index }, - { 4836, GetPixelTexGenParameterivSGIS_remap_index }, - { 24454, PixelTexGenParameterfSGIS_remap_index }, - { 663, PixelTexGenParameterfvSGIS_remap_index }, - { 13485, PixelTexGenParameteriSGIS_remap_index }, - { 14590, PixelTexGenParameterivSGIS_remap_index }, - { 19287, SampleMaskSGIS_remap_index }, - { 21239, SamplePatternSGIS_remap_index }, - { 27900, ColorPointerEXT_remap_index }, - { 18580, EdgeFlagPointerEXT_remap_index }, - { 6697, IndexPointerEXT_remap_index }, - { 6777, NormalPointerEXT_remap_index }, - { 16740, TexCoordPointerEXT_remap_index }, - { 7610, VertexPointerEXT_remap_index }, - { 3925, PointParameterfEXT_remap_index }, - { 8461, PointParameterfvEXT_remap_index }, - { 33730, LockArraysEXT_remap_index }, - { 15794, UnlockArraysEXT_remap_index }, - { 1291, SecondaryColor3bEXT_remap_index }, - { 8654, SecondaryColor3bvEXT_remap_index }, - { 11189, SecondaryColor3dEXT_remap_index }, - { 27128, SecondaryColor3dvEXT_remap_index }, - { 29770, SecondaryColor3fEXT_remap_index }, - { 19324, SecondaryColor3fvEXT_remap_index }, - { 509, SecondaryColor3iEXT_remap_index }, - { 17076, SecondaryColor3ivEXT_remap_index }, - { 10771, SecondaryColor3sEXT_remap_index }, - { 32557, SecondaryColor3svEXT_remap_index }, - { 28835, SecondaryColor3ubEXT_remap_index }, - { 22588, SecondaryColor3ubvEXT_remap_index }, - { 13727, SecondaryColor3uiEXT_remap_index }, - { 24341, SecondaryColor3uivEXT_remap_index }, - { 27408, SecondaryColor3usEXT_remap_index }, - { 13800, SecondaryColor3usvEXT_remap_index }, - { 12548, SecondaryColorPointerEXT_remap_index }, - { 27222, MultiDrawArraysEXT_remap_index }, - { 22227, MultiDrawElementsEXT_remap_index }, - { 22438, FogCoordPointerEXT_remap_index }, - { 5009, FogCoorddEXT_remap_index }, - { 33131, FogCoorddvEXT_remap_index }, - { 5126, FogCoordfEXT_remap_index }, - { 28758, FogCoordfvEXT_remap_index }, - { 12648, PixelTexGenSGIX_remap_index }, - { 29363, BlendFuncSeparateEXT_remap_index }, - { 7522, FlushVertexArrayRangeNV_remap_index }, - { 5951, VertexArrayRangeNV_remap_index }, - { 29835, CombinerInputNV_remap_index }, - { 2251, CombinerOutputNV_remap_index }, - { 32710, CombinerParameterfNV_remap_index }, - { 5805, CombinerParameterfvNV_remap_index }, - { 23797, CombinerParameteriNV_remap_index }, - { 34213, CombinerParameterivNV_remap_index }, - { 7898, FinalCombinerInputNV_remap_index }, - { 1648, GetCombinerInputParameterfvNV_remap_index }, - { 34050, GetCombinerInputParameterivNV_remap_index }, - { 216, GetCombinerOutputParameterfvNV_remap_index }, - { 14551, GetCombinerOutputParameterivNV_remap_index }, - { 7284, GetFinalCombinerInputParameterfvNV_remap_index }, - { 26266, GetFinalCombinerInputParameterivNV_remap_index }, - { 13338, ResizeBuffersMESA_remap_index }, - { 11874, WindowPos2dMESA_remap_index }, - { 1084, WindowPos2dvMESA_remap_index }, - { 35142, WindowPos2fMESA_remap_index }, - { 8599, WindowPos2fvMESA_remap_index }, - { 19234, WindowPos2iMESA_remap_index }, - { 21712, WindowPos2ivMESA_remap_index }, - { 22326, WindowPos2sMESA_remap_index }, - { 6366, WindowPos2svMESA_remap_index }, - { 8390, WindowPos3dMESA_remap_index }, - { 14823, WindowPos3dvMESA_remap_index }, - { 555, WindowPos3fMESA_remap_index }, - { 15855, WindowPos3fvMESA_remap_index }, - { 25527, WindowPos3iMESA_remap_index }, - { 31886, WindowPos3ivMESA_remap_index }, - { 20032, WindowPos3sMESA_remap_index }, - { 33387, WindowPos3svMESA_remap_index }, - { 11825, WindowPos4dMESA_remap_index }, - { 18010, WindowPos4dvMESA_remap_index }, - { 14782, WindowPos4fMESA_remap_index }, - { 32447, WindowPos4fvMESA_remap_index }, - { 32039, WindowPos4iMESA_remap_index }, - { 13177, WindowPos4ivMESA_remap_index }, - { 20260, WindowPos4sMESA_remap_index }, - { 3509, WindowPos4svMESA_remap_index }, - { 28466, MultiModeDrawArraysIBM_remap_index }, - { 30610, MultiModeDrawElementsIBM_remap_index }, - { 12952, DeleteFencesNV_remap_index }, - { 29682, FinishFenceNV_remap_index }, - { 4073, GenFencesNV_remap_index }, - { 17990, GetFenceivNV_remap_index }, - { 8867, IsFenceNV_remap_index }, - { 14478, SetFenceNV_remap_index }, - { 4649, TestFenceNV_remap_index }, - { 33358, AreProgramsResidentNV_remap_index }, - { 32752, BindProgramNV_remap_index }, - { 27491, DeleteProgramsNV_remap_index }, - { 22806, ExecuteProgramNV_remap_index }, - { 35035, GenProgramsNV_remap_index }, - { 24826, GetProgramParameterdvNV_remap_index }, - { 11251, GetProgramParameterfvNV_remap_index }, - { 27874, GetProgramStringNV_remap_index }, - { 25904, GetProgramivNV_remap_index }, - { 25081, GetTrackMatrixivNV_remap_index }, - { 27668, GetVertexAttribPointervNV_remap_index }, - { 10866, GetVertexAttribdvNV_remap_index }, - { 9923, GetVertexAttribfvNV_remap_index }, - { 19537, GetVertexAttribivNV_remap_index }, - { 20543, IsProgramNV_remap_index }, - { 10006, LoadProgramNV_remap_index }, - { 29459, ProgramParameters4dvNV_remap_index }, - { 25834, ProgramParameters4fvNV_remap_index }, - { 22016, RequestResidentProgramsNV_remap_index }, - { 32231, TrackMatrixNV_remap_index }, - { 34027, VertexAttrib1dNV_remap_index }, - { 14389, VertexAttrib1dvNV_remap_index }, - { 30116, VertexAttrib1fNV_remap_index }, - { 2608, VertexAttrib1fvNV_remap_index }, - { 32504, VertexAttrib1sNV_remap_index }, - { 15928, VertexAttrib1svNV_remap_index }, - { 5317, VertexAttrib2dNV_remap_index }, - { 14282, VertexAttrib2dvNV_remap_index }, - { 21471, VertexAttrib2fNV_remap_index }, - { 13848, VertexAttrib2fvNV_remap_index }, - { 6578, VertexAttrib2sNV_remap_index }, - { 20086, VertexAttrib2svNV_remap_index }, - { 12022, VertexAttrib3dNV_remap_index }, - { 33608, VertexAttrib3dvNV_remap_index }, - { 11037, VertexAttrib3fNV_remap_index }, - { 26226, VertexAttrib3fvNV_remap_index }, - { 23570, VertexAttrib3sNV_remap_index }, - { 25108, VertexAttrib3svNV_remap_index }, - { 30584, VertexAttrib4dNV_remap_index }, - { 35072, VertexAttrib4dvNV_remap_index }, - { 5745, VertexAttrib4fNV_remap_index }, - { 10073, VertexAttrib4fvNV_remap_index }, - { 28350, VertexAttrib4sNV_remap_index }, - { 1461, VertexAttrib4svNV_remap_index }, - { 5492, VertexAttrib4ubNV_remap_index }, - { 817, VertexAttrib4ubvNV_remap_index }, - { 22986, VertexAttribPointerNV_remap_index }, - { 2423, VertexAttribs1dvNV_remap_index }, - { 27756, VertexAttribs1fvNV_remap_index }, - { 34872, VertexAttribs1svNV_remap_index }, - { 11088, VertexAttribs2dvNV_remap_index }, - { 26883, VertexAttribs2fvNV_remap_index }, - { 18606, VertexAttribs2svNV_remap_index }, - { 5853, VertexAttribs3dvNV_remap_index }, - { 2282, VertexAttribs3fvNV_remap_index }, - { 31608, VertexAttribs3svNV_remap_index }, - { 28440, VertexAttribs4dvNV_remap_index }, - { 5925, VertexAttribs4fvNV_remap_index }, - { 34659, VertexAttribs4svNV_remap_index }, - { 31339, VertexAttribs4ubvNV_remap_index }, - { 28542, GetTexBumpParameterfvATI_remap_index }, - { 34913, GetTexBumpParameterivATI_remap_index }, - { 19714, TexBumpParameterfvATI_remap_index }, - { 21887, TexBumpParameterivATI_remap_index }, - { 16492, AlphaFragmentOp1ATI_remap_index }, - { 27174, AlphaFragmentOp2ATI_remap_index }, - { 26142, AlphaFragmentOp3ATI_remap_index }, - { 31535, BeginFragmentShaderATI_remap_index }, - { 32951, BindFragmentShaderATI_remap_index }, - { 25237, ColorFragmentOp1ATI_remap_index }, - { 4764, ColorFragmentOp2ATI_remap_index }, - { 33253, ColorFragmentOp3ATI_remap_index }, - { 6091, DeleteFragmentShaderATI_remap_index }, - { 35096, EndFragmentShaderATI_remap_index }, - { 34241, GenFragmentShadersATI_remap_index }, - { 27037, PassTexCoordATI_remap_index }, - { 7590, SampleMapATI_remap_index }, - { 28653, SetFragmentShaderConstantATI_remap_index }, - { 402, PointParameteriNV_remap_index }, - { 15035, PointParameterivNV_remap_index }, - { 30423, ActiveStencilFaceEXT_remap_index }, - { 29099, BindVertexArrayAPPLE_remap_index }, - { 2949, DeleteVertexArraysAPPLE_remap_index }, - { 19073, GenVertexArraysAPPLE_remap_index }, - { 24891, IsVertexArrayAPPLE_remap_index }, - { 858, GetProgramNamedParameterdvNV_remap_index }, - { 3888, GetProgramNamedParameterfvNV_remap_index }, - { 28573, ProgramNamedParameter4dNV_remap_index }, - { 15409, ProgramNamedParameter4dvNV_remap_index }, - { 9539, ProgramNamedParameter4fNV_remap_index }, - { 12513, ProgramNamedParameter4fvNV_remap_index }, - { 17921, PrimitiveRestartIndexNV_remap_index }, - { 32424, PrimitiveRestartNV_remap_index }, - { 25813, DepthBoundsEXT_remap_index }, - { 1183, BlendEquationSeparateEXT_remap_index }, - { 15629, BindFramebufferEXT_remap_index }, - { 27267, BindRenderbufferEXT_remap_index }, - { 10320, CheckFramebufferStatusEXT_remap_index }, - { 24142, DeleteFramebuffersEXT_remap_index }, - { 33510, DeleteRenderbuffersEXT_remap_index }, - { 14306, FramebufferRenderbufferEXT_remap_index }, - { 14495, FramebufferTexture1DEXT_remap_index }, - { 12307, FramebufferTexture2DEXT_remap_index }, - { 11927, FramebufferTexture3DEXT_remap_index }, - { 24757, GenFramebuffersEXT_remap_index }, - { 18471, GenRenderbuffersEXT_remap_index }, - { 7326, GenerateMipmapEXT_remap_index }, - { 23079, GetFramebufferAttachmentParameterivEXT_remap_index }, - { 34147, GetRenderbufferParameterivEXT_remap_index }, - { 21767, IsFramebufferEXT_remap_index }, - { 34995, IsRenderbufferEXT_remap_index }, - { 8814, RenderbufferStorageEXT_remap_index }, - { 734, BlitFramebufferEXT_remap_index }, - { 15195, BufferParameteriAPPLE_remap_index }, - { 20575, FlushMappedBufferRangeAPPLE_remap_index }, - { 1931, BindFragDataLocationEXT_remap_index }, - { 25926, GetFragDataLocationEXT_remap_index }, - { 11366, GetUniformuivEXT_remap_index }, - { 34321, GetVertexAttribIivEXT_remap_index }, - { 29630, GetVertexAttribIuivEXT_remap_index }, - { 12785, Uniform1uiEXT_remap_index }, - { 29544, Uniform1uivEXT_remap_index }, - { 23666, Uniform2uiEXT_remap_index }, - { 4728, Uniform2uivEXT_remap_index }, - { 30863, Uniform3uiEXT_remap_index }, - { 15556, Uniform3uivEXT_remap_index }, - { 3812, Uniform4uiEXT_remap_index }, - { 9315, Uniform4uivEXT_remap_index }, - { 19452, VertexAttribI1iEXT_remap_index }, - { 5519, VertexAttribI1ivEXT_remap_index }, - { 2709, VertexAttribI1uiEXT_remap_index }, - { 13576, VertexAttribI1uivEXT_remap_index }, - { 81, VertexAttribI2iEXT_remap_index }, - { 25349, VertexAttribI2ivEXT_remap_index }, - { 5879, VertexAttribI2uiEXT_remap_index }, - { 5171, VertexAttribI2uivEXT_remap_index }, - { 28142, VertexAttribI3iEXT_remap_index }, - { 26576, VertexAttribI3ivEXT_remap_index }, - { 3666, VertexAttribI3uiEXT_remap_index }, - { 32127, VertexAttribI3uivEXT_remap_index }, - { 23375, VertexAttribI4bvEXT_remap_index }, - { 15488, VertexAttribI4iEXT_remap_index }, - { 33779, VertexAttribI4ivEXT_remap_index }, - { 14209, VertexAttribI4svEXT_remap_index }, - { 4241, VertexAttribI4ubvEXT_remap_index }, - { 17139, VertexAttribI4uiEXT_remap_index }, - { 6025, VertexAttribI4uivEXT_remap_index }, - { 12090, VertexAttribI4usvEXT_remap_index }, - { 19658, VertexAttribIPointerEXT_remap_index }, - { 3281, FramebufferTextureLayerEXT_remap_index }, - { 17511, ColorMaskIndexedEXT_remap_index }, - { 20110, DisableIndexedEXT_remap_index }, - { 28187, EnableIndexedEXT_remap_index }, - { 23034, GetBooleanIndexedvEXT_remap_index }, - { 11701, GetIntegerIndexedvEXT_remap_index }, - { 24218, IsEnabledIndexedEXT_remap_index }, - { 24118, ClearColorIiEXT_remap_index }, - { 3762, ClearColorIuiEXT_remap_index }, - { 10563, GetTexParameterIivEXT_remap_index }, - { 6526, GetTexParameterIuivEXT_remap_index }, - { 3237, TexParameterIivEXT_remap_index }, - { 28009, TexParameterIuivEXT_remap_index }, - { 5039, BeginConditionalRenderNV_remap_index }, - { 26987, EndConditionalRenderNV_remap_index }, - { 9950, BeginTransformFeedbackEXT_remap_index }, - { 20189, BindBufferBaseEXT_remap_index }, - { 20004, BindBufferOffsetEXT_remap_index }, - { 13002, BindBufferRangeEXT_remap_index }, - { 15110, EndTransformFeedbackEXT_remap_index }, - { 11564, GetTransformFeedbackVaryingEXT_remap_index }, - { 22072, TransformFeedbackVaryingsEXT_remap_index }, - { 31240, ProvokingVertexEXT_remap_index }, - { 11512, GetTexParameterPointervAPPLE_remap_index }, - { 5581, TextureRangeAPPLE_remap_index }, - { 12379, GetObjectParameterivAPPLE_remap_index }, - { 21194, ObjectPurgeableAPPLE_remap_index }, - { 6301, ObjectUnpurgeableAPPLE_remap_index }, - { 18293, ActiveProgramEXT_remap_index }, - { 18264, CreateShaderProgramEXT_remap_index }, - { 30208, UseShaderProgramEXT_remap_index }, - { 17464, TextureBarrierNV_remap_index }, - { 30449, StencilFuncSeparateATI_remap_index }, - { 6214, ProgramEnvParameters4fvEXT_remap_index }, - { 18158, ProgramLocalParameters4fvEXT_remap_index }, - { 14963, GetQueryObjecti64vEXT_remap_index }, - { 11114, GetQueryObjectui64vEXT_remap_index }, - { 25306, EGLImageTargetRenderbufferStorageOES_remap_index }, - { 12891, EGLImageTargetTexture2DOES_remap_index }, - { -1, -1 } -}; - -/* these functions are in the ABI, but have alternative names */ -static const struct gl_function_remap MESA_alt_functions[] = { - /* from GL_EXT_blend_color */ - { 2867, _gloffset_BlendColor }, - /* from GL_EXT_blend_minmax */ - { 11984, _gloffset_BlendEquation }, - /* from GL_EXT_color_subtable */ - { 18032, _gloffset_ColorSubTable }, - { 33442, _gloffset_CopyColorSubTable }, - /* from GL_EXT_convolution */ - { 296, _gloffset_ConvolutionFilter1D }, - { 2647, _gloffset_CopyConvolutionFilter1D }, - { 4508, _gloffset_GetConvolutionParameteriv }, - { 9163, _gloffset_ConvolutionFilter2D }, - { 9365, _gloffset_ConvolutionParameteriv }, - { 9825, _gloffset_ConvolutionParameterfv }, - { 21915, _gloffset_GetSeparableFilter }, - { 25581, _gloffset_SeparableFilter2D }, - { 26469, _gloffset_ConvolutionParameteri }, - { 26662, _gloffset_ConvolutionParameterf }, - { 28376, _gloffset_GetConvolutionParameterfv }, - { 29265, _gloffset_GetConvolutionFilter }, - { 31823, _gloffset_CopyConvolutionFilter2D }, - /* from GL_EXT_copy_texture */ - { 15988, _gloffset_CopyTexSubImage3D }, - { 17719, _gloffset_CopyTexImage2D }, - { 26052, _gloffset_CopyTexImage1D }, - { 28946, _gloffset_CopyTexSubImage2D }, - { 31435, _gloffset_CopyTexSubImage1D }, - /* from GL_EXT_draw_range_elements */ - { 10179, _gloffset_DrawRangeElements }, - /* from GL_EXT_histogram */ - { 895, _gloffset_Histogram }, - { 3848, _gloffset_ResetHistogram }, - { 10709, _gloffset_GetMinmax }, - { 16322, _gloffset_GetHistogramParameterfv }, - { 25977, _gloffset_GetMinmaxParameteriv }, - { 28266, _gloffset_ResetMinmax }, - { 29162, _gloffset_GetHistogramParameteriv }, - { 30383, _gloffset_GetHistogram }, - { 33067, _gloffset_Minmax }, - { 34742, _gloffset_GetMinmaxParameterfv }, - /* from GL_EXT_paletted_texture */ - { 9025, _gloffset_ColorTable }, - { 16168, _gloffset_GetColorTable }, - { 24504, _gloffset_GetColorTableParameterfv }, - { 26718, _gloffset_GetColorTableParameteriv }, - /* from GL_EXT_subtexture */ - { 7736, _gloffset_TexSubImage1D }, - { 11439, _gloffset_TexSubImage2D }, - /* from GL_EXT_texture3D */ - { 1890, _gloffset_TexImage3D }, - { 24273, _gloffset_TexSubImage3D }, - /* from GL_EXT_texture_object */ - { 3616, _gloffset_PrioritizeTextures }, - { 8185, _gloffset_AreTexturesResident }, - { 14413, _gloffset_GenTextures }, - { 16699, _gloffset_DeleteTextures }, - { 20856, _gloffset_IsTexture }, - { 31500, _gloffset_BindTexture }, - /* from GL_EXT_vertex_array */ - { 25753, _gloffset_ArrayElement }, - { 32655, _gloffset_GetPointerv }, - { 34268, _gloffset_DrawArrays }, - /* from GL_SGI_color_table */ - { 8303, _gloffset_ColorTableParameteriv }, - { 9025, _gloffset_ColorTable }, - { 16168, _gloffset_GetColorTable }, - { 16278, _gloffset_CopyColorTable }, - { 20717, _gloffset_ColorTableParameterfv }, - { 24504, _gloffset_GetColorTableParameterfv }, - { 26718, _gloffset_GetColorTableParameteriv }, - /* from GL_VERSION_1_3 */ - { 464, _gloffset_MultiTexCoord3sARB }, - { 696, _gloffset_ActiveTextureARB }, - { 4666, _gloffset_MultiTexCoord1fvARB }, - { 6802, _gloffset_MultiTexCoord3dARB }, - { 6847, _gloffset_MultiTexCoord2iARB }, - { 6971, _gloffset_MultiTexCoord2svARB }, - { 8981, _gloffset_MultiTexCoord2fARB }, - { 11144, _gloffset_MultiTexCoord3fvARB }, - { 11746, _gloffset_MultiTexCoord4sARB }, - { 12427, _gloffset_MultiTexCoord2dvARB }, - { 12834, _gloffset_MultiTexCoord1svARB }, - { 13199, _gloffset_MultiTexCoord3svARB }, - { 13260, _gloffset_MultiTexCoord4iARB }, - { 14117, _gloffset_MultiTexCoord3iARB }, - { 14992, _gloffset_MultiTexCoord1dARB }, - { 15224, _gloffset_MultiTexCoord3dvARB }, - { 16540, _gloffset_MultiTexCoord3ivARB }, - { 16585, _gloffset_MultiTexCoord2sARB }, - { 18089, _gloffset_MultiTexCoord4ivARB }, - { 20357, _gloffset_ClientActiveTextureARB }, - { 22762, _gloffset_MultiTexCoord2dARB }, - { 23199, _gloffset_MultiTexCoord4dvARB }, - { 23621, _gloffset_MultiTexCoord4fvARB }, - { 24645, _gloffset_MultiTexCoord3fARB }, - { 27312, _gloffset_MultiTexCoord4dARB }, - { 27578, _gloffset_MultiTexCoord1sARB }, - { 27782, _gloffset_MultiTexCoord1dvARB }, - { 28790, _gloffset_MultiTexCoord1ivARB }, - { 28883, _gloffset_MultiTexCoord2ivARB }, - { 29222, _gloffset_MultiTexCoord1iARB }, - { 30658, _gloffset_MultiTexCoord4svARB }, - { 31282, _gloffset_MultiTexCoord1fARB }, - { 31562, _gloffset_MultiTexCoord4fARB }, - { 34102, _gloffset_MultiTexCoord2fvARB }, - { -1, -1 } -}; - -#endif /* need_MESA_remap_table */ - -#if defined(need_GL_3DFX_tbuffer) -static const struct gl_function_remap GL_3DFX_tbuffer_functions[] = { - { 9883, -1 }, /* TbufferMask3DFX */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_AMD_draw_buffers_blend) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_AMD_draw_buffers_blend_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_APPLE_flush_buffer_range) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_APPLE_flush_buffer_range_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_APPLE_object_purgeable) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_APPLE_object_purgeable_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_APPLE_texture_range) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_APPLE_texture_range_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_APPLE_vertex_array_object) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_APPLE_vertex_array_object_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_ARB_ES2_compatibility) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_ARB_ES2_compatibility_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_ARB_color_buffer_float) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_ARB_color_buffer_float_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_ARB_copy_buffer) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_ARB_copy_buffer_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_ARB_draw_buffers) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_ARB_draw_buffers_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_ARB_draw_buffers_blend) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_ARB_draw_buffers_blend_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_ARB_draw_elements_base_vertex) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_ARB_draw_elements_base_vertex_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_ARB_draw_instanced) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_ARB_draw_instanced_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_ARB_framebuffer_object) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_ARB_framebuffer_object_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_ARB_geometry_shader4) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_ARB_geometry_shader4_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_ARB_instanced_arrays) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_ARB_instanced_arrays_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_ARB_map_buffer_range) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_ARB_map_buffer_range_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_ARB_matrix_palette) -static const struct gl_function_remap GL_ARB_matrix_palette_functions[] = { - { 4125, -1 }, /* MatrixIndexusvARB */ - { 13938, -1 }, /* MatrixIndexuivARB */ - { 15379, -1 }, /* MatrixIndexPointerARB */ - { 21149, -1 }, /* CurrentPaletteMatrixARB */ - { 24389, -1 }, /* MatrixIndexubvARB */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_ARB_multisample) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_ARB_multisample_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_ARB_occlusion_query) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_ARB_occlusion_query_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_ARB_point_parameters) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_ARB_point_parameters_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_ARB_provoking_vertex) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_ARB_provoking_vertex_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_ARB_robustness) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_ARB_robustness_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_ARB_sampler_objects) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_ARB_sampler_objects_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_ARB_shader_objects) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_ARB_shader_objects_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_ARB_sync) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_ARB_sync_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_ARB_texture_buffer_object) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_ARB_texture_buffer_object_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_ARB_texture_compression) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_ARB_texture_compression_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_ARB_transform_feedback2) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_ARB_transform_feedback2_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_ARB_transpose_matrix) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_ARB_transpose_matrix_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_ARB_vertex_array_object) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_ARB_vertex_array_object_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_ARB_vertex_blend) -static const struct gl_function_remap GL_ARB_vertex_blend_functions[] = { - { 2589, -1 }, /* WeightubvARB */ - { 7214, -1 }, /* WeightivARB */ - { 11849, -1 }, /* WeightPointerARB */ - { 14673, -1 }, /* WeightfvARB */ - { 18632, -1 }, /* WeightbvARB */ - { 22379, -1 }, /* WeightusvARB */ - { 25507, -1 }, /* VertexBlendARB */ - { 31366, -1 }, /* WeightsvARB */ - { 33492, -1 }, /* WeightdvARB */ - { 34302, -1 }, /* WeightuivARB */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_ARB_vertex_buffer_object) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_ARB_vertex_buffer_object_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_ARB_vertex_program) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_ARB_vertex_program_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_ARB_vertex_shader) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_ARB_vertex_shader_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_ARB_vertex_type_2_10_10_10_rev) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_ARB_vertex_type_2_10_10_10_rev_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_ARB_window_pos) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_ARB_window_pos_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_ATI_blend_equation_separate) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_ATI_blend_equation_separate_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_ATI_draw_buffers) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_ATI_draw_buffers_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_ATI_envmap_bumpmap) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_ATI_envmap_bumpmap_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_ATI_fragment_shader) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_ATI_fragment_shader_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_ATI_separate_stencil) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_ATI_separate_stencil_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_blend_color) -static const struct gl_function_remap GL_EXT_blend_color_functions[] = { - { 2867, _gloffset_BlendColor }, - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_blend_equation_separate) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_EXT_blend_equation_separate_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_blend_func_separate) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_EXT_blend_func_separate_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_blend_minmax) -static const struct gl_function_remap GL_EXT_blend_minmax_functions[] = { - { 11984, _gloffset_BlendEquation }, - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_color_subtable) -static const struct gl_function_remap GL_EXT_color_subtable_functions[] = { - { 18032, _gloffset_ColorSubTable }, - { 33442, _gloffset_CopyColorSubTable }, - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_compiled_vertex_array) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_EXT_compiled_vertex_array_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_convolution) -static const struct gl_function_remap GL_EXT_convolution_functions[] = { - { 296, _gloffset_ConvolutionFilter1D }, - { 2647, _gloffset_CopyConvolutionFilter1D }, - { 4508, _gloffset_GetConvolutionParameteriv }, - { 9163, _gloffset_ConvolutionFilter2D }, - { 9365, _gloffset_ConvolutionParameteriv }, - { 9825, _gloffset_ConvolutionParameterfv }, - { 21915, _gloffset_GetSeparableFilter }, - { 25581, _gloffset_SeparableFilter2D }, - { 26469, _gloffset_ConvolutionParameteri }, - { 26662, _gloffset_ConvolutionParameterf }, - { 28376, _gloffset_GetConvolutionParameterfv }, - { 29265, _gloffset_GetConvolutionFilter }, - { 31823, _gloffset_CopyConvolutionFilter2D }, - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_coordinate_frame) -static const struct gl_function_remap GL_EXT_coordinate_frame_functions[] = { - { 11283, -1 }, /* TangentPointerEXT */ - { 13318, -1 }, /* Binormal3ivEXT */ - { 14070, -1 }, /* Tangent3sEXT */ - { 15444, -1 }, /* Tangent3fvEXT */ - { 19742, -1 }, /* Tangent3ivEXT */ - { 19985, -1 }, /* Tangent3dvEXT */ - { 20803, -1 }, /* Binormal3bvEXT */ - { 21968, -1 }, /* Binormal3dEXT */ - { 24321, -1 }, /* Tangent3fEXT */ - { 26541, -1 }, /* Binormal3sEXT */ - { 27108, -1 }, /* Tangent3dEXT */ - { 28055, -1 }, /* Binormal3svEXT */ - { 28688, -1 }, /* Binormal3fEXT */ - { 29596, -1 }, /* Binormal3dvEXT */ - { 30915, -1 }, /* Tangent3iEXT */ - { 32108, -1 }, /* Tangent3bvEXT */ - { 32690, -1 }, /* Tangent3bEXT */ - { 33215, -1 }, /* Binormal3fvEXT */ - { 34001, -1 }, /* BinormalPointerEXT */ - { 34482, -1 }, /* Tangent3svEXT */ - { 34944, -1 }, /* Binormal3bEXT */ - { 35121, -1 }, /* Binormal3iEXT */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_copy_texture) -static const struct gl_function_remap GL_EXT_copy_texture_functions[] = { - { 15988, _gloffset_CopyTexSubImage3D }, - { 17719, _gloffset_CopyTexImage2D }, - { 26052, _gloffset_CopyTexImage1D }, - { 28946, _gloffset_CopyTexSubImage2D }, - { 31435, _gloffset_CopyTexSubImage1D }, - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_cull_vertex) -static const struct gl_function_remap GL_EXT_cull_vertex_functions[] = { - { 9514, -1 }, /* CullParameterdvEXT */ - { 12472, -1 }, /* CullParameterfvEXT */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_depth_bounds_test) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_EXT_depth_bounds_test_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_draw_buffers2) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_EXT_draw_buffers2_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_draw_instanced) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_EXT_draw_instanced_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_draw_range_elements) -static const struct gl_function_remap GL_EXT_draw_range_elements_functions[] = { - { 10179, _gloffset_DrawRangeElements }, - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_fog_coord) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_EXT_fog_coord_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_framebuffer_blit) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_EXT_framebuffer_blit_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_framebuffer_multisample) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_EXT_framebuffer_multisample_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_framebuffer_object) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_EXT_framebuffer_object_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_gpu_program_parameters) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_EXT_gpu_program_parameters_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_gpu_shader4) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_EXT_gpu_shader4_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_histogram) -static const struct gl_function_remap GL_EXT_histogram_functions[] = { - { 895, _gloffset_Histogram }, - { 3848, _gloffset_ResetHistogram }, - { 10709, _gloffset_GetMinmax }, - { 16322, _gloffset_GetHistogramParameterfv }, - { 25977, _gloffset_GetMinmaxParameteriv }, - { 28266, _gloffset_ResetMinmax }, - { 29162, _gloffset_GetHistogramParameteriv }, - { 30383, _gloffset_GetHistogram }, - { 33067, _gloffset_Minmax }, - { 34742, _gloffset_GetMinmaxParameterfv }, - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_index_func) -static const struct gl_function_remap GL_EXT_index_func_functions[] = { - { 12258, -1 }, /* IndexFuncEXT */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_index_material) -static const struct gl_function_remap GL_EXT_index_material_functions[] = { - { 22517, -1 }, /* IndexMaterialEXT */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_light_texture) -static const struct gl_function_remap GL_EXT_light_texture_functions[] = { - { 28075, -1 }, /* ApplyTextureEXT */ - { 28220, -1 }, /* TextureMaterialEXT */ - { 28245, -1 }, /* TextureLightEXT */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_multi_draw_arrays) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_EXT_multi_draw_arrays_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_multisample) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_EXT_multisample_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_paletted_texture) -static const struct gl_function_remap GL_EXT_paletted_texture_functions[] = { - { 9025, _gloffset_ColorTable }, - { 16168, _gloffset_GetColorTable }, - { 24504, _gloffset_GetColorTableParameterfv }, - { 26718, _gloffset_GetColorTableParameteriv }, - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_pixel_transform) -static const struct gl_function_remap GL_EXT_pixel_transform_functions[] = { - { 23164, -1 }, /* PixelTransformParameterfEXT */ - { 23244, -1 }, /* PixelTransformParameteriEXT */ - { 32388, -1 }, /* PixelTransformParameterfvEXT */ - { 33965, -1 }, /* PixelTransformParameterivEXT */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_point_parameters) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_EXT_point_parameters_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_polygon_offset) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_EXT_polygon_offset_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_provoking_vertex) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_EXT_provoking_vertex_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_secondary_color) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_EXT_secondary_color_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_separate_shader_objects) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_EXT_separate_shader_objects_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_stencil_two_side) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_EXT_stencil_two_side_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_subtexture) -static const struct gl_function_remap GL_EXT_subtexture_functions[] = { - { 7736, _gloffset_TexSubImage1D }, - { 11439, _gloffset_TexSubImage2D }, - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_texture3D) -static const struct gl_function_remap GL_EXT_texture3D_functions[] = { - { 1890, _gloffset_TexImage3D }, - { 24273, _gloffset_TexSubImage3D }, - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_texture_array) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_EXT_texture_array_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_texture_integer) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_EXT_texture_integer_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_texture_object) -static const struct gl_function_remap GL_EXT_texture_object_functions[] = { - { 3616, _gloffset_PrioritizeTextures }, - { 8185, _gloffset_AreTexturesResident }, - { 14413, _gloffset_GenTextures }, - { 16699, _gloffset_DeleteTextures }, - { 20856, _gloffset_IsTexture }, - { 31500, _gloffset_BindTexture }, - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_texture_perturb_normal) -static const struct gl_function_remap GL_EXT_texture_perturb_normal_functions[] = { - { 14623, -1 }, /* TextureNormalEXT */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_timer_query) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_EXT_timer_query_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_transform_feedback) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_EXT_transform_feedback_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_vertex_array) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_EXT_vertex_array_functions[] = { - { 25753, _gloffset_ArrayElement }, - { 32655, _gloffset_GetPointerv }, - { 34268, _gloffset_DrawArrays }, - { -1, -1 } -}; -#endif - -#if defined(need_GL_EXT_vertex_weighting) -static const struct gl_function_remap GL_EXT_vertex_weighting_functions[] = { - { 20930, -1 }, /* VertexWeightfvEXT */ - { 28631, -1 }, /* VertexWeightfEXT */ - { 30352, -1 }, /* VertexWeightPointerEXT */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_HP_image_transform) -static const struct gl_function_remap GL_HP_image_transform_functions[] = { - { 2500, -1 }, /* GetImageTransformParameterfvHP */ - { 4091, -1 }, /* ImageTransformParameterfHP */ - { 10951, -1 }, /* ImageTransformParameterfvHP */ - { 12719, -1 }, /* ImageTransformParameteriHP */ - { 13089, -1 }, /* GetImageTransformParameterivHP */ - { 20994, -1 }, /* ImageTransformParameterivHP */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_IBM_multimode_draw_arrays) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_IBM_multimode_draw_arrays_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_IBM_vertex_array_lists) -static const struct gl_function_remap GL_IBM_vertex_array_lists_functions[] = { - { 4798, -1 }, /* SecondaryColorPointerListIBM */ - { 6668, -1 }, /* NormalPointerListIBM */ - { 8359, -1 }, /* FogCoordPointerListIBM */ - { 8700, -1 }, /* VertexPointerListIBM */ - { 12973, -1 }, /* ColorPointerListIBM */ - { 14177, -1 }, /* TexCoordPointerListIBM */ - { 14645, -1 }, /* IndexPointerListIBM */ - { 34685, -1 }, /* EdgeFlagPointerListIBM */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_INGR_blend_func_separate) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_INGR_blend_func_separate_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_INTEL_parallel_arrays) -static const struct gl_function_remap GL_INTEL_parallel_arrays_functions[] = { - { 13517, -1 }, /* VertexPointervINTEL */ - { 16415, -1 }, /* ColorPointervINTEL */ - { 31797, -1 }, /* NormalPointervINTEL */ - { 32320, -1 }, /* TexCoordPointervINTEL */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_MESA_resize_buffers) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_MESA_resize_buffers_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_MESA_shader_debug) -static const struct gl_function_remap GL_MESA_shader_debug_functions[] = { - { 1754, -1 }, /* GetDebugLogLengthMESA */ - { 3787, -1 }, /* ClearDebugLogMESA */ - { 4983, -1 }, /* GetDebugLogMESA */ - { 32848, -1 }, /* CreateDebugObjectMESA */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_MESA_window_pos) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_MESA_window_pos_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_NV_condtitional_render) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_NV_condtitional_render_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_NV_evaluators) -static const struct gl_function_remap GL_NV_evaluators_functions[] = { - { 7398, -1 }, /* GetMapAttribParameterivNV */ - { 9131, -1 }, /* MapControlPointsNV */ - { 9230, -1 }, /* MapParameterfvNV */ - { 11422, -1 }, /* EvalMapsNV */ - { 18230, -1 }, /* GetMapAttribParameterfvNV */ - { 18447, -1 }, /* MapParameterivNV */ - { 26392, -1 }, /* GetMapParameterivNV */ - { 26960, -1 }, /* GetMapParameterfvNV */ - { 31069, -1 }, /* GetMapControlPointsNV */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_NV_fence) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_NV_fence_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_NV_fragment_program) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_NV_fragment_program_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_NV_point_sprite) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_NV_point_sprite_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_NV_primitive_restart) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_NV_primitive_restart_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_NV_register_combiners) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_NV_register_combiners_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_NV_register_combiners2) -static const struct gl_function_remap GL_NV_register_combiners2_functions[] = { - { 16852, -1 }, /* CombinerStageParameterfvNV */ - { 17274, -1 }, /* GetCombinerStageParameterfvNV */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_NV_texture_barrier) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_NV_texture_barrier_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_NV_vertex_array_range) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_NV_vertex_array_range_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_NV_vertex_program) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_NV_vertex_program_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_OES_EGL_image) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_OES_EGL_image_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_PGI_misc_hints) -static const struct gl_function_remap GL_PGI_misc_hints_functions[] = { - { 9351, -1 }, /* HintPGI */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_SGIS_detail_texture) -static const struct gl_function_remap GL_SGIS_detail_texture_functions[] = { - { 17247, -1 }, /* GetDetailTexFuncSGIS */ - { 17664, -1 }, /* DetailTexFuncSGIS */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_SGIS_fog_function) -static const struct gl_function_remap GL_SGIS_fog_function_functions[] = { - { 28928, -1 }, /* FogFuncSGIS */ - { 29701, -1 }, /* GetFogFuncSGIS */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_SGIS_multisample) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_SGIS_multisample_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_SGIS_pixel_texture) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_SGIS_pixel_texture_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_SGIS_point_parameters) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_SGIS_point_parameters_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_SGIS_sharpen_texture) -static const struct gl_function_remap GL_SGIS_sharpen_texture_functions[] = { - { 7459, -1 }, /* GetSharpenTexFuncSGIS */ - { 23595, -1 }, /* SharpenTexFuncSGIS */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_SGIS_texture4D) -static const struct gl_function_remap GL_SGIS_texture4D_functions[] = { - { 1034, -1 }, /* TexImage4DSGIS */ - { 16768, -1 }, /* TexSubImage4DSGIS */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_SGIS_texture_color_mask) -static const struct gl_function_remap GL_SGIS_texture_color_mask_functions[] = { - { 16121, -1 }, /* TextureColorMaskSGIS */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_SGIS_texture_filter4) -static const struct gl_function_remap GL_SGIS_texture_filter4_functions[] = { - { 7636, -1 }, /* GetTexFilterFuncSGIS */ - { 17438, -1 }, /* TexFilterFuncSGIS */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_SGIX_async) -static const struct gl_function_remap GL_SGIX_async_functions[] = { - { 3713, -1 }, /* AsyncMarkerSGIX */ - { 4937, -1 }, /* FinishAsyncSGIX */ - { 6072, -1 }, /* PollAsyncSGIX */ - { 23824, -1 }, /* DeleteAsyncMarkersSGIX */ - { 23879, -1 }, /* IsAsyncMarkerSGIX */ - { 34457, -1 }, /* GenAsyncMarkersSGIX */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_SGIX_flush_raster) -static const struct gl_function_remap GL_SGIX_flush_raster_functions[] = { - { 8013, -1 }, /* FlushRasterSGIX */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_SGIX_fragment_lighting) -static const struct gl_function_remap GL_SGIX_fragment_lighting_functions[] = { - { 2837, -1 }, /* FragmentMaterialfvSGIX */ - { 5976, -1 }, /* FragmentLightiSGIX */ - { 8767, -1 }, /* FragmentMaterialfSGIX */ - { 8904, -1 }, /* GetFragmentLightivSGIX */ - { 9777, -1 }, /* FragmentLightModeliSGIX */ - { 11485, -1 }, /* FragmentLightivSGIX */ - { 11792, -1 }, /* GetFragmentMaterialivSGIX */ - { 17187, -1 }, /* GetFragmentMaterialfvSGIX */ - { 20773, -1 }, /* FragmentLightModelfSGIX */ - { 21117, -1 }, /* FragmentColorMaterialSGIX */ - { 21534, -1 }, /* FragmentMaterialiSGIX */ - { 22845, -1 }, /* LightEnviSGIX */ - { 24596, -1 }, /* FragmentLightModelfvSGIX */ - { 24931, -1 }, /* FragmentLightfvSGIX */ - { 30085, -1 }, /* FragmentLightModelivSGIX */ - { 30234, -1 }, /* FragmentLightfSGIX */ - { 33185, -1 }, /* GetFragmentLightfvSGIX */ - { 34965, -1 }, /* FragmentMaterialivSGIX */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_SGIX_framezoom) -static const struct gl_function_remap GL_SGIX_framezoom_functions[] = { - { 23902, -1 }, /* FrameZoomSGIX */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_SGIX_igloo_interface) -static const struct gl_function_remap GL_SGIX_igloo_interface_functions[] = { - { 30542, -1 }, /* IglooInterfaceSGIX */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_SGIX_instruments) -static const struct gl_function_remap GL_SGIX_instruments_functions[] = { - { 3017, -1 }, /* ReadInstrumentsSGIX */ - { 7232, -1 }, /* PollInstrumentsSGIX */ - { 11343, -1 }, /* GetInstrumentsSGIX */ - { 13775, -1 }, /* StartInstrumentsSGIX */ - { 16912, -1 }, /* StopInstrumentsSGIX */ - { 18895, -1 }, /* InstrumentsBufferSGIX */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_SGIX_list_priority) -static const struct gl_function_remap GL_SGIX_list_priority_functions[] = { - { 1265, -1 }, /* ListParameterfSGIX */ - { 3372, -1 }, /* GetListParameterfvSGIX */ - { 18760, -1 }, /* ListParameteriSGIX */ - { 19919, -1 }, /* ListParameterfvSGIX */ - { 22200, -1 }, /* ListParameterivSGIX */ - { 34501, -1 }, /* GetListParameterivSGIX */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_SGIX_pixel_texture) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_SGIX_pixel_texture_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_SGIX_polynomial_ffd) -static const struct gl_function_remap GL_SGIX_polynomial_ffd_functions[] = { - { 3059, -1 }, /* DeformationMap3dSGIX */ - { 4037, -1 }, /* LoadIdentityDeformationMapSGIX */ - { 17012, -1 }, /* DeformSGIX */ - { 25865, -1 }, /* DeformationMap3fSGIX */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_SGIX_reference_plane) -static const struct gl_function_remap GL_SGIX_reference_plane_functions[] = { - { 15672, -1 }, /* ReferencePlaneSGIX */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_SGIX_sprite) -static const struct gl_function_remap GL_SGIX_sprite_functions[] = { - { 10292, -1 }, /* SpriteParameterfvSGIX */ - { 21989, -1 }, /* SpriteParameteriSGIX */ - { 28300, -1 }, /* SpriteParameterfSGIX */ - { 31212, -1 }, /* SpriteParameterivSGIX */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_SGIX_tag_sample_buffer) -static const struct gl_function_remap GL_SGIX_tag_sample_buffer_functions[] = { - { 22048, -1 }, /* TagSampleBufferSGIX */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_SGI_color_table) -static const struct gl_function_remap GL_SGI_color_table_functions[] = { - { 8303, _gloffset_ColorTableParameteriv }, - { 9025, _gloffset_ColorTable }, - { 16168, _gloffset_GetColorTable }, - { 16278, _gloffset_CopyColorTable }, - { 20717, _gloffset_ColorTableParameterfv }, - { 24504, _gloffset_GetColorTableParameterfv }, - { 26718, _gloffset_GetColorTableParameteriv }, - { -1, -1 } -}; -#endif - -#if defined(need_GL_SUNX_constant_data) -static const struct gl_function_remap GL_SUNX_constant_data_functions[] = { - { 33163, -1 }, /* FinishTextureSUNX */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_SUN_global_alpha) -static const struct gl_function_remap GL_SUN_global_alpha_functions[] = { - { 3734, -1 }, /* GlobalAlphaFactorubSUN */ - { 5290, -1 }, /* GlobalAlphaFactoriSUN */ - { 7257, -1 }, /* GlobalAlphaFactordSUN */ - { 10376, -1 }, /* GlobalAlphaFactoruiSUN */ - { 10908, -1 }, /* GlobalAlphaFactorbSUN */ - { 14090, -1 }, /* GlobalAlphaFactorfSUN */ - { 14254, -1 }, /* GlobalAlphaFactorusSUN */ - { 24191, -1 }, /* GlobalAlphaFactorsSUN */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_SUN_mesh_array) -static const struct gl_function_remap GL_SUN_mesh_array_functions[] = { - { 31003, -1 }, /* DrawMeshArraysSUN */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_SUN_triangle_list) -static const struct gl_function_remap GL_SUN_triangle_list_functions[] = { - { 4911, -1 }, /* ReplacementCodeubSUN */ - { 7016, -1 }, /* ReplacementCodeubvSUN */ - { 20438, -1 }, /* ReplacementCodeusvSUN */ - { 20626, -1 }, /* ReplacementCodePointerSUN */ - { 22909, -1 }, /* ReplacementCodeuiSUN */ - { 23853, -1 }, /* ReplacementCodeusSUN */ - { 31686, -1 }, /* ReplacementCodeuivSUN */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_SUN_vertex) -static const struct gl_function_remap GL_SUN_vertex_functions[] = { - { 1139, -1 }, /* ReplacementCodeuiColor3fVertex3fvSUN */ - { 1337, -1 }, /* TexCoord4fColor4fNormal3fVertex4fvSUN */ - { 1591, -1 }, /* TexCoord2fColor4ubVertex3fvSUN */ - { 2004, -1 }, /* ReplacementCodeuiVertex3fvSUN */ - { 2138, -1 }, /* ReplacementCodeuiTexCoord2fVertex3fvSUN */ - { 2754, -1 }, /* ReplacementCodeuiNormal3fVertex3fSUN */ - { 3152, -1 }, /* Color4ubVertex3fvSUN */ - { 5095, -1 }, /* Color4ubVertex3fSUN */ - { 5218, -1 }, /* TexCoord2fVertex3fSUN */ - { 5679, -1 }, /* TexCoord2fColor4fNormal3fVertex3fSUN */ - { 6176, -1 }, /* TexCoord2fNormal3fVertex3fvSUN */ - { 6911, -1 }, /* ReplacementCodeuiTexCoord2fNormal3fVertex3fSUN */ - { 7691, -1 }, /* ReplacementCodeuiColor4ubVertex3fvSUN */ - { 8050, -1 }, /* ReplacementCodeuiTexCoord2fVertex3fSUN */ - { 9576, -1 }, /* Color3fVertex3fSUN */ - { 10817, -1 }, /* Color3fVertex3fvSUN */ - { 11308, -1 }, /* Color4fNormal3fVertex3fvSUN */ - { 12137, -1 }, /* ReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN */ - { 13638, -1 }, /* ReplacementCodeuiColor4fNormal3fVertex3fvSUN */ - { 15269, -1 }, /* ReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN */ - { 15814, -1 }, /* TexCoord2fColor3fVertex3fSUN */ - { 16937, -1 }, /* TexCoord4fColor4fNormal3fVertex4fSUN */ - { 17379, -1 }, /* Color4ubVertex2fvSUN */ - { 17689, -1 }, /* Normal3fVertex3fSUN */ - { 18836, -1 }, /* ReplacementCodeuiColor4fNormal3fVertex3fSUN */ - { 19188, -1 }, /* TexCoord2fColor4fNormal3fVertex3fvSUN */ - { 19495, -1 }, /* TexCoord2fNormal3fVertex3fSUN */ - { 20231, -1 }, /* TexCoord2fVertex3fvSUN */ - { 21087, -1 }, /* Color4ubVertex2fSUN */ - { 21325, -1 }, /* ReplacementCodeuiColor4ubVertex3fSUN */ - { 23420, -1 }, /* TexCoord2fColor4ubVertex3fSUN */ - { 23921, -1 }, /* Normal3fVertex3fvSUN */ - { 24413, -1 }, /* Color4fNormal3fVertex3fSUN */ - { 25414, -1 }, /* ReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN */ - { 27621, -1 }, /* ReplacementCodeuiColor3fVertex3fSUN */ - { 29044, -1 }, /* TexCoord4fVertex4fSUN */ - { 29490, -1 }, /* TexCoord2fColor3fVertex3fvSUN */ - { 29929, -1 }, /* ReplacementCodeuiNormal3fVertex3fvSUN */ - { 30056, -1 }, /* TexCoord4fVertex4fvSUN */ - { 30790, -1 }, /* ReplacementCodeuiVertex3fSUN */ - { -1, -1 } -}; -#endif - -#if defined(need_GL_VERSION_1_3) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_VERSION_1_3_functions[] = { - { 464, _gloffset_MultiTexCoord3sARB }, - { 696, _gloffset_ActiveTextureARB }, - { 4666, _gloffset_MultiTexCoord1fvARB }, - { 6802, _gloffset_MultiTexCoord3dARB }, - { 6847, _gloffset_MultiTexCoord2iARB }, - { 6971, _gloffset_MultiTexCoord2svARB }, - { 8981, _gloffset_MultiTexCoord2fARB }, - { 11144, _gloffset_MultiTexCoord3fvARB }, - { 11746, _gloffset_MultiTexCoord4sARB }, - { 12427, _gloffset_MultiTexCoord2dvARB }, - { 12834, _gloffset_MultiTexCoord1svARB }, - { 13199, _gloffset_MultiTexCoord3svARB }, - { 13260, _gloffset_MultiTexCoord4iARB }, - { 14117, _gloffset_MultiTexCoord3iARB }, - { 14992, _gloffset_MultiTexCoord1dARB }, - { 15224, _gloffset_MultiTexCoord3dvARB }, - { 16540, _gloffset_MultiTexCoord3ivARB }, - { 16585, _gloffset_MultiTexCoord2sARB }, - { 18089, _gloffset_MultiTexCoord4ivARB }, - { 20357, _gloffset_ClientActiveTextureARB }, - { 22762, _gloffset_MultiTexCoord2dARB }, - { 23199, _gloffset_MultiTexCoord4dvARB }, - { 23621, _gloffset_MultiTexCoord4fvARB }, - { 24645, _gloffset_MultiTexCoord3fARB }, - { 27312, _gloffset_MultiTexCoord4dARB }, - { 27578, _gloffset_MultiTexCoord1sARB }, - { 27782, _gloffset_MultiTexCoord1dvARB }, - { 28790, _gloffset_MultiTexCoord1ivARB }, - { 28883, _gloffset_MultiTexCoord2ivARB }, - { 29222, _gloffset_MultiTexCoord1iARB }, - { 30658, _gloffset_MultiTexCoord4svARB }, - { 31282, _gloffset_MultiTexCoord1fARB }, - { 31562, _gloffset_MultiTexCoord4fARB }, - { 34102, _gloffset_MultiTexCoord2fvARB }, - { -1, -1 } -}; -#endif - -#if defined(need_GL_VERSION_1_4) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_VERSION_1_4_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_VERSION_1_5) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_VERSION_1_5_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_VERSION_2_0) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_VERSION_2_0_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_VERSION_2_1) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_VERSION_2_1_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_VERSION_3_0) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_VERSION_3_0_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_VERSION_3_1) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_VERSION_3_1_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_VERSION_3_2) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_VERSION_3_2_functions[] = { - { -1, -1 } -}; -#endif - -#if defined(need_GL_VERSION_3_3) -/* functions defined in MESA_remap_table_functions are excluded */ -static const struct gl_function_remap GL_VERSION_3_3_functions[] = { - { -1, -1 } -}; -#endif - +/* DO NOT EDIT - This file generated automatically by remap_helper.py (from Mesa) script */ + +/* + * Copyright (C) 2009 Chia-I Wu + * 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, sub license, + * 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 (including the next + * paragraph) 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 NON-INFRINGEMENT. IN NO EVENT SHALL + * Chia-I Wu, + * AND/OR THEIR SUPPLIERS 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 "main/dispatch.h" +#include "main/remap.h" + +/* this is internal to remap.c */ +#ifdef need_MESA_remap_table + +static const char _mesa_function_pool[] = + /* _mesa_function_pool[0]: MapGrid1d (offset 224) */ + "idd\0" + "glMapGrid1d\0" + "\0" + /* _mesa_function_pool[17]: UniformMatrix3fvARB (will be remapped) */ + "iiip\0" + "glUniformMatrix3fv\0" + "glUniformMatrix3fvARB\0" + "\0" + /* _mesa_function_pool[64]: MapGrid1f (offset 225) */ + "iff\0" + "glMapGrid1f\0" + "\0" + /* _mesa_function_pool[81]: VertexAttribI2iEXT (will be remapped) */ + "iii\0" + "glVertexAttribI2iEXT\0" + "glVertexAttribI2i\0" + "\0" + /* _mesa_function_pool[125]: RasterPos4i (offset 82) */ + "iiii\0" + "glRasterPos4i\0" + "\0" + /* _mesa_function_pool[145]: RasterPos4d (offset 78) */ + "dddd\0" + "glRasterPos4d\0" + "\0" + /* _mesa_function_pool[165]: NewList (dynamic) */ + "ii\0" + "glNewList\0" + "\0" + /* _mesa_function_pool[179]: RasterPos4f (offset 80) */ + "ffff\0" + "glRasterPos4f\0" + "\0" + /* _mesa_function_pool[199]: LoadIdentity (offset 290) */ + "\0" + "glLoadIdentity\0" + "\0" + /* _mesa_function_pool[216]: GetCombinerOutputParameterfvNV (will be remapped) */ + "iiip\0" + "glGetCombinerOutputParameterfvNV\0" + "\0" + /* _mesa_function_pool[255]: SampleCoverageARB (will be remapped) */ + "fi\0" + "glSampleCoverage\0" + "glSampleCoverageARB\0" + "\0" + /* _mesa_function_pool[296]: ConvolutionFilter1D (offset 348) */ + "iiiiip\0" + "glConvolutionFilter1D\0" + "glConvolutionFilter1DEXT\0" + "\0" + /* _mesa_function_pool[351]: BeginQueryARB (will be remapped) */ + "ii\0" + "glBeginQuery\0" + "glBeginQueryARB\0" + "\0" + /* _mesa_function_pool[384]: RasterPos3dv (offset 71) */ + "p\0" + "glRasterPos3dv\0" + "\0" + /* _mesa_function_pool[402]: PointParameteriNV (will be remapped) */ + "ii\0" + "glPointParameteri\0" + "glPointParameteriNV\0" + "\0" + /* _mesa_function_pool[444]: GetProgramiv (will be remapped) */ + "iip\0" + "glGetProgramiv\0" + "\0" + /* _mesa_function_pool[464]: MultiTexCoord3sARB (offset 398) */ + "iiii\0" + "glMultiTexCoord3s\0" + "glMultiTexCoord3sARB\0" + "\0" + /* _mesa_function_pool[509]: SecondaryColor3iEXT (will be remapped) */ + "iii\0" + "glSecondaryColor3i\0" + "glSecondaryColor3iEXT\0" + "\0" + /* _mesa_function_pool[555]: WindowPos3fMESA (will be remapped) */ + "fff\0" + "glWindowPos3f\0" + "glWindowPos3fARB\0" + "glWindowPos3fMESA\0" + "\0" + /* _mesa_function_pool[609]: TexCoord1iv (offset 99) */ + "p\0" + "glTexCoord1iv\0" + "\0" + /* _mesa_function_pool[626]: TexCoord4sv (offset 125) */ + "p\0" + "glTexCoord4sv\0" + "\0" + /* _mesa_function_pool[643]: RasterPos4s (offset 84) */ + "iiii\0" + "glRasterPos4s\0" + "\0" + /* _mesa_function_pool[663]: PixelTexGenParameterfvSGIS (will be remapped) */ + "ip\0" + "glPixelTexGenParameterfvSGIS\0" + "\0" + /* _mesa_function_pool[696]: ActiveTextureARB (offset 374) */ + "i\0" + "glActiveTexture\0" + "glActiveTextureARB\0" + "\0" + /* _mesa_function_pool[734]: BlitFramebufferEXT (will be remapped) */ + "iiiiiiiiii\0" + "glBlitFramebuffer\0" + "glBlitFramebufferEXT\0" + "\0" + /* _mesa_function_pool[785]: TexCoord1f (offset 96) */ + "f\0" + "glTexCoord1f\0" + "\0" + /* _mesa_function_pool[801]: TexCoord1d (offset 94) */ + "d\0" + "glTexCoord1d\0" + "\0" + /* _mesa_function_pool[817]: VertexAttrib4ubvNV (will be remapped) */ + "ip\0" + "glVertexAttrib4ubvNV\0" + "\0" + /* _mesa_function_pool[842]: TexCoord1i (offset 98) */ + "i\0" + "glTexCoord1i\0" + "\0" + /* _mesa_function_pool[858]: GetProgramNamedParameterdvNV (will be remapped) */ + "iipp\0" + "glGetProgramNamedParameterdvNV\0" + "\0" + /* _mesa_function_pool[895]: Histogram (offset 367) */ + "iiii\0" + "glHistogram\0" + "glHistogramEXT\0" + "\0" + /* _mesa_function_pool[928]: TexCoord1s (offset 100) */ + "i\0" + "glTexCoord1s\0" + "\0" + /* _mesa_function_pool[944]: GetMapfv (offset 267) */ + "iip\0" + "glGetMapfv\0" + "\0" + /* _mesa_function_pool[960]: EvalCoord1f (offset 230) */ + "f\0" + "glEvalCoord1f\0" + "\0" + /* _mesa_function_pool[977]: FramebufferTexture (will be remapped) */ + "iiii\0" + "glFramebufferTexture\0" + "\0" + /* _mesa_function_pool[1004]: GetGraphicsResetStatusARB (will be remapped) */ + "\0" + "glGetGraphicsResetStatusARB\0" + "\0" + /* _mesa_function_pool[1034]: TexImage4DSGIS (dynamic) */ + "iiiiiiiiiip\0" + "glTexImage4DSGIS\0" + "\0" + /* _mesa_function_pool[1064]: PolygonStipple (offset 175) */ + "p\0" + "glPolygonStipple\0" + "\0" + /* _mesa_function_pool[1084]: WindowPos2dvMESA (will be remapped) */ + "p\0" + "glWindowPos2dv\0" + "glWindowPos2dvARB\0" + "glWindowPos2dvMESA\0" + "\0" + /* _mesa_function_pool[1139]: ReplacementCodeuiColor3fVertex3fvSUN (dynamic) */ + "ppp\0" + "glReplacementCodeuiColor3fVertex3fvSUN\0" + "\0" + /* _mesa_function_pool[1183]: BlendEquationSeparateEXT (will be remapped) */ + "ii\0" + "glBlendEquationSeparate\0" + "glBlendEquationSeparateEXT\0" + "glBlendEquationSeparateATI\0" + "\0" + /* _mesa_function_pool[1265]: ListParameterfSGIX (dynamic) */ + "iif\0" + "glListParameterfSGIX\0" + "\0" + /* _mesa_function_pool[1291]: SecondaryColor3bEXT (will be remapped) */ + "iii\0" + "glSecondaryColor3b\0" + "glSecondaryColor3bEXT\0" + "\0" + /* _mesa_function_pool[1337]: TexCoord4fColor4fNormal3fVertex4fvSUN (dynamic) */ + "pppp\0" + "glTexCoord4fColor4fNormal3fVertex4fvSUN\0" + "\0" + /* _mesa_function_pool[1383]: GetnPolygonStippleARB (will be remapped) */ + "ip\0" + "glGetnPolygonStippleARB\0" + "\0" + /* _mesa_function_pool[1411]: GetPixelMapfv (offset 271) */ + "ip\0" + "glGetPixelMapfv\0" + "\0" + /* _mesa_function_pool[1431]: Color3uiv (offset 22) */ + "p\0" + "glColor3uiv\0" + "\0" + /* _mesa_function_pool[1446]: IsEnabled (offset 286) */ + "i\0" + "glIsEnabled\0" + "\0" + /* _mesa_function_pool[1461]: VertexAttrib4svNV (will be remapped) */ + "ip\0" + "glVertexAttrib4svNV\0" + "\0" + /* _mesa_function_pool[1485]: EvalCoord2fv (offset 235) */ + "p\0" + "glEvalCoord2fv\0" + "\0" + /* _mesa_function_pool[1503]: GetBufferSubDataARB (will be remapped) */ + "iiip\0" + "glGetBufferSubData\0" + "glGetBufferSubDataARB\0" + "\0" + /* _mesa_function_pool[1550]: BufferSubDataARB (will be remapped) */ + "iiip\0" + "glBufferSubData\0" + "glBufferSubDataARB\0" + "\0" + /* _mesa_function_pool[1591]: TexCoord2fColor4ubVertex3fvSUN (dynamic) */ + "ppp\0" + "glTexCoord2fColor4ubVertex3fvSUN\0" + "\0" + /* _mesa_function_pool[1629]: AttachShader (will be remapped) */ + "ii\0" + "glAttachShader\0" + "\0" + /* _mesa_function_pool[1648]: GetCombinerInputParameterfvNV (will be remapped) */ + "iiiip\0" + "glGetCombinerInputParameterfvNV\0" + "\0" + /* _mesa_function_pool[1687]: MultiTexCoordP2ui (will be remapped) */ + "iii\0" + "glMultiTexCoordP2ui\0" + "\0" + /* _mesa_function_pool[1712]: VertexAttrib2fARB (will be remapped) */ + "iff\0" + "glVertexAttrib2f\0" + "glVertexAttrib2fARB\0" + "\0" + /* _mesa_function_pool[1754]: GetDebugLogLengthMESA (dynamic) */ + "iii\0" + "glGetDebugLogLengthMESA\0" + "\0" + /* _mesa_function_pool[1783]: GetMapiv (offset 268) */ + "iip\0" + "glGetMapiv\0" + "\0" + /* _mesa_function_pool[1799]: VertexAttrib3fARB (will be remapped) */ + "ifff\0" + "glVertexAttrib3f\0" + "glVertexAttrib3fARB\0" + "\0" + /* _mesa_function_pool[1842]: Indexubv (offset 316) */ + "p\0" + "glIndexubv\0" + "\0" + /* _mesa_function_pool[1856]: GetQueryivARB (will be remapped) */ + "iip\0" + "glGetQueryiv\0" + "glGetQueryivARB\0" + "\0" + /* _mesa_function_pool[1890]: TexImage3D (offset 371) */ + "iiiiiiiiip\0" + "glTexImage3D\0" + "glTexImage3DEXT\0" + "\0" + /* _mesa_function_pool[1931]: BindFragDataLocationEXT (will be remapped) */ + "iip\0" + "glBindFragDataLocationEXT\0" + "glBindFragDataLocation\0" + "\0" + /* _mesa_function_pool[1985]: TexCoordP4ui (will be remapped) */ + "ii\0" + "glTexCoordP4ui\0" + "\0" + /* _mesa_function_pool[2004]: ReplacementCodeuiVertex3fvSUN (dynamic) */ + "pp\0" + "glReplacementCodeuiVertex3fvSUN\0" + "\0" + /* _mesa_function_pool[2040]: EdgeFlagPointer (offset 312) */ + "ip\0" + "glEdgeFlagPointer\0" + "\0" + /* _mesa_function_pool[2062]: Color3ubv (offset 20) */ + "p\0" + "glColor3ubv\0" + "\0" + /* _mesa_function_pool[2077]: GetQueryObjectivARB (will be remapped) */ + "iip\0" + "glGetQueryObjectiv\0" + "glGetQueryObjectivARB\0" + "\0" + /* _mesa_function_pool[2123]: Vertex3dv (offset 135) */ + "p\0" + "glVertex3dv\0" + "\0" + /* _mesa_function_pool[2138]: ReplacementCodeuiTexCoord2fVertex3fvSUN (dynamic) */ + "ppp\0" + "glReplacementCodeuiTexCoord2fVertex3fvSUN\0" + "\0" + /* _mesa_function_pool[2185]: CompressedTexSubImage2DARB (will be remapped) */ + "iiiiiiiip\0" + "glCompressedTexSubImage2D\0" + "glCompressedTexSubImage2DARB\0" + "\0" + /* _mesa_function_pool[2251]: CombinerOutputNV (will be remapped) */ + "iiiiiiiiii\0" + "glCombinerOutputNV\0" + "\0" + /* _mesa_function_pool[2282]: VertexAttribs3fvNV (will be remapped) */ + "iip\0" + "glVertexAttribs3fvNV\0" + "\0" + /* _mesa_function_pool[2308]: GetnMapivARB (will be remapped) */ + "iiip\0" + "glGetnMapivARB\0" + "\0" + /* _mesa_function_pool[2329]: Uniform2fARB (will be remapped) */ + "iff\0" + "glUniform2f\0" + "glUniform2fARB\0" + "\0" + /* _mesa_function_pool[2361]: LightModeliv (offset 166) */ + "ip\0" + "glLightModeliv\0" + "\0" + /* _mesa_function_pool[2380]: VertexAttrib1svARB (will be remapped) */ + "ip\0" + "glVertexAttrib1sv\0" + "glVertexAttrib1svARB\0" + "\0" + /* _mesa_function_pool[2423]: VertexAttribs1dvNV (will be remapped) */ + "iip\0" + "glVertexAttribs1dvNV\0" + "\0" + /* _mesa_function_pool[2449]: VertexP3ui (will be remapped) */ + "ii\0" + "glVertexP3ui\0" + "\0" + /* _mesa_function_pool[2466]: Uniform2ivARB (will be remapped) */ + "iip\0" + "glUniform2iv\0" + "glUniform2ivARB\0" + "\0" + /* _mesa_function_pool[2500]: GetImageTransformParameterfvHP (dynamic) */ + "iip\0" + "glGetImageTransformParameterfvHP\0" + "\0" + /* _mesa_function_pool[2538]: Normal3bv (offset 53) */ + "p\0" + "glNormal3bv\0" + "\0" + /* _mesa_function_pool[2553]: TexGeniv (offset 193) */ + "iip\0" + "glTexGeniv\0" + "\0" + /* _mesa_function_pool[2569]: TexCoordP1uiv (will be remapped) */ + "ip\0" + "glTexCoordP1uiv\0" + "\0" + /* _mesa_function_pool[2589]: WeightubvARB (dynamic) */ + "ip\0" + "glWeightubvARB\0" + "\0" + /* _mesa_function_pool[2608]: VertexAttrib1fvNV (will be remapped) */ + "ip\0" + "glVertexAttrib1fvNV\0" + "\0" + /* _mesa_function_pool[2632]: Vertex3iv (offset 139) */ + "p\0" + "glVertex3iv\0" + "\0" + /* _mesa_function_pool[2647]: CopyConvolutionFilter1D (offset 354) */ + "iiiii\0" + "glCopyConvolutionFilter1D\0" + "glCopyConvolutionFilter1DEXT\0" + "\0" + /* _mesa_function_pool[2709]: VertexAttribI1uiEXT (will be remapped) */ + "ii\0" + "glVertexAttribI1uiEXT\0" + "glVertexAttribI1ui\0" + "\0" + /* _mesa_function_pool[2754]: ReplacementCodeuiNormal3fVertex3fSUN (dynamic) */ + "iffffff\0" + "glReplacementCodeuiNormal3fVertex3fSUN\0" + "\0" + /* _mesa_function_pool[2802]: TexCoordP1ui (will be remapped) */ + "ii\0" + "glTexCoordP1ui\0" + "\0" + /* _mesa_function_pool[2821]: DeleteSync (will be remapped) */ + "i\0" + "glDeleteSync\0" + "\0" + /* _mesa_function_pool[2837]: FragmentMaterialfvSGIX (dynamic) */ + "iip\0" + "glFragmentMaterialfvSGIX\0" + "\0" + /* _mesa_function_pool[2867]: BlendColor (offset 336) */ + "ffff\0" + "glBlendColor\0" + "glBlendColorEXT\0" + "\0" + /* _mesa_function_pool[2902]: UniformMatrix4fvARB (will be remapped) */ + "iiip\0" + "glUniformMatrix4fv\0" + "glUniformMatrix4fvARB\0" + "\0" + /* _mesa_function_pool[2949]: DeleteVertexArraysAPPLE (will be remapped) */ + "ip\0" + "glDeleteVertexArrays\0" + "glDeleteVertexArraysAPPLE\0" + "\0" + /* _mesa_function_pool[3000]: TexBuffer (will be remapped) */ + "iii\0" + "glTexBuffer\0" + "\0" + /* _mesa_function_pool[3017]: ReadInstrumentsSGIX (dynamic) */ + "i\0" + "glReadInstrumentsSGIX\0" + "\0" + /* _mesa_function_pool[3042]: CallLists (offset 3) */ + "iip\0" + "glCallLists\0" + "\0" + /* _mesa_function_pool[3059]: DeformationMap3dSGIX (dynamic) */ + "iddiiddiiddiip\0" + "glDeformationMap3dSGIX\0" + "\0" + /* _mesa_function_pool[3098]: UniformMatrix2x4fv (will be remapped) */ + "iiip\0" + "glUniformMatrix2x4fv\0" + "\0" + /* _mesa_function_pool[3125]: ReadnPixelsARB (will be remapped) */ + "iiiiiiip\0" + "glReadnPixelsARB\0" + "\0" + /* _mesa_function_pool[3152]: Color4ubVertex3fvSUN (dynamic) */ + "pp\0" + "glColor4ubVertex3fvSUN\0" + "\0" + /* _mesa_function_pool[3179]: Normal3iv (offset 59) */ + "p\0" + "glNormal3iv\0" + "\0" + /* _mesa_function_pool[3194]: PassThrough (offset 199) */ + "f\0" + "glPassThrough\0" + "\0" + /* _mesa_function_pool[3211]: GetnPixelMapusvARB (will be remapped) */ + "iip\0" + "glGetnPixelMapusvARB\0" + "\0" + /* _mesa_function_pool[3237]: TexParameterIivEXT (will be remapped) */ + "iip\0" + "glTexParameterIivEXT\0" + "glTexParameterIiv\0" + "\0" + /* _mesa_function_pool[3281]: FramebufferTextureLayerEXT (will be remapped) */ + "iiiii\0" + "glFramebufferTextureLayer\0" + "glFramebufferTextureLayerARB\0" + "glFramebufferTextureLayerEXT\0" + "\0" + /* _mesa_function_pool[3372]: GetListParameterfvSGIX (dynamic) */ + "iip\0" + "glGetListParameterfvSGIX\0" + "\0" + /* _mesa_function_pool[3402]: Viewport (offset 305) */ + "iiii\0" + "glViewport\0" + "\0" + /* _mesa_function_pool[3419]: VertexAttrib4NusvARB (will be remapped) */ + "ip\0" + "glVertexAttrib4Nusv\0" + "glVertexAttrib4NusvARB\0" + "\0" + /* _mesa_function_pool[3466]: VertexP4uiv (will be remapped) */ + "ip\0" + "glVertexP4uiv\0" + "\0" + /* _mesa_function_pool[3484]: VertexAttribP3ui (will be remapped) */ + "iiii\0" + "glVertexAttribP3ui\0" + "\0" + /* _mesa_function_pool[3509]: WindowPos4svMESA (will be remapped) */ + "p\0" + "glWindowPos4svMESA\0" + "\0" + /* _mesa_function_pool[3531]: CreateProgramObjectARB (will be remapped) */ + "\0" + "glCreateProgramObjectARB\0" + "\0" + /* _mesa_function_pool[3558]: DeleteTransformFeedbacks (will be remapped) */ + "ip\0" + "glDeleteTransformFeedbacks\0" + "\0" + /* _mesa_function_pool[3589]: UniformMatrix4x3fv (will be remapped) */ + "iiip\0" + "glUniformMatrix4x3fv\0" + "\0" + /* _mesa_function_pool[3616]: PrioritizeTextures (offset 331) */ + "ipp\0" + "glPrioritizeTextures\0" + "glPrioritizeTexturesEXT\0" + "\0" + /* _mesa_function_pool[3666]: VertexAttribI3uiEXT (will be remapped) */ + "iiii\0" + "glVertexAttribI3uiEXT\0" + "glVertexAttribI3ui\0" + "\0" + /* _mesa_function_pool[3713]: AsyncMarkerSGIX (dynamic) */ + "i\0" + "glAsyncMarkerSGIX\0" + "\0" + /* _mesa_function_pool[3734]: GlobalAlphaFactorubSUN (dynamic) */ + "i\0" + "glGlobalAlphaFactorubSUN\0" + "\0" + /* _mesa_function_pool[3762]: ClearColorIuiEXT (will be remapped) */ + "iiii\0" + "glClearColorIuiEXT\0" + "\0" + /* _mesa_function_pool[3787]: ClearDebugLogMESA (dynamic) */ + "iii\0" + "glClearDebugLogMESA\0" + "\0" + /* _mesa_function_pool[3812]: Uniform4uiEXT (will be remapped) */ + "iiiii\0" + "glUniform4uiEXT\0" + "glUniform4ui\0" + "\0" + /* _mesa_function_pool[3848]: ResetHistogram (offset 369) */ + "i\0" + "glResetHistogram\0" + "glResetHistogramEXT\0" + "\0" + /* _mesa_function_pool[3888]: GetProgramNamedParameterfvNV (will be remapped) */ + "iipp\0" + "glGetProgramNamedParameterfvNV\0" + "\0" + /* _mesa_function_pool[3925]: PointParameterfEXT (will be remapped) */ + "if\0" + "glPointParameterf\0" + "glPointParameterfARB\0" + "glPointParameterfEXT\0" + "glPointParameterfSGIS\0" + "\0" + /* _mesa_function_pool[4011]: MultiTexCoordP4uiv (will be remapped) */ + "iip\0" + "glMultiTexCoordP4uiv\0" + "\0" + /* _mesa_function_pool[4037]: LoadIdentityDeformationMapSGIX (dynamic) */ + "i\0" + "glLoadIdentityDeformationMapSGIX\0" + "\0" + /* _mesa_function_pool[4073]: GenFencesNV (will be remapped) */ + "ip\0" + "glGenFencesNV\0" + "\0" + /* _mesa_function_pool[4091]: ImageTransformParameterfHP (dynamic) */ + "iif\0" + "glImageTransformParameterfHP\0" + "\0" + /* _mesa_function_pool[4125]: MatrixIndexusvARB (dynamic) */ + "ip\0" + "glMatrixIndexusvARB\0" + "\0" + /* _mesa_function_pool[4149]: DrawElementsBaseVertex (will be remapped) */ + "iiipi\0" + "glDrawElementsBaseVertex\0" + "\0" + /* _mesa_function_pool[4181]: DisableVertexAttribArrayARB (will be remapped) */ + "i\0" + "glDisableVertexAttribArray\0" + "glDisableVertexAttribArrayARB\0" + "\0" + /* _mesa_function_pool[4241]: VertexAttribI4ubvEXT (will be remapped) */ + "ip\0" + "glVertexAttribI4ubvEXT\0" + "glVertexAttribI4ubv\0" + "\0" + /* _mesa_function_pool[4288]: GetnConvolutionFilterARB (will be remapped) */ + "iiiip\0" + "glGetnConvolutionFilterARB\0" + "\0" + /* _mesa_function_pool[4322]: TexCoord2sv (offset 109) */ + "p\0" + "glTexCoord2sv\0" + "\0" + /* _mesa_function_pool[4339]: ColorP4uiv (will be remapped) */ + "ip\0" + "glColorP4uiv\0" + "\0" + /* _mesa_function_pool[4356]: Vertex4dv (offset 143) */ + "p\0" + "glVertex4dv\0" + "\0" + /* _mesa_function_pool[4371]: StencilMaskSeparate (will be remapped) */ + "ii\0" + "glStencilMaskSeparate\0" + "\0" + /* _mesa_function_pool[4397]: ProgramLocalParameter4dARB (will be remapped) */ + "iidddd\0" + "glProgramLocalParameter4dARB\0" + "\0" + /* _mesa_function_pool[4434]: CompressedTexImage3DARB (will be remapped) */ + "iiiiiiiip\0" + "glCompressedTexImage3D\0" + "glCompressedTexImage3DARB\0" + "\0" + /* _mesa_function_pool[4494]: Color3sv (offset 18) */ + "p\0" + "glColor3sv\0" + "\0" + /* _mesa_function_pool[4508]: GetConvolutionParameteriv (offset 358) */ + "iip\0" + "glGetConvolutionParameteriv\0" + "glGetConvolutionParameterivEXT\0" + "\0" + /* _mesa_function_pool[4572]: DeleteSamplers (will be remapped) */ + "ip\0" + "glDeleteSamplers\0" + "\0" + /* _mesa_function_pool[4593]: VertexAttrib1fARB (will be remapped) */ + "if\0" + "glVertexAttrib1f\0" + "glVertexAttrib1fARB\0" + "\0" + /* _mesa_function_pool[4634]: Vertex2dv (offset 127) */ + "p\0" + "glVertex2dv\0" + "\0" + /* _mesa_function_pool[4649]: TestFenceNV (will be remapped) */ + "i\0" + "glTestFenceNV\0" + "\0" + /* _mesa_function_pool[4666]: MultiTexCoord1fvARB (offset 379) */ + "ip\0" + "glMultiTexCoord1fv\0" + "glMultiTexCoord1fvARB\0" + "\0" + /* _mesa_function_pool[4711]: TexCoord3iv (offset 115) */ + "p\0" + "glTexCoord3iv\0" + "\0" + /* _mesa_function_pool[4728]: Uniform2uivEXT (will be remapped) */ + "iip\0" + "glUniform2uivEXT\0" + "glUniform2uiv\0" + "\0" + /* _mesa_function_pool[4764]: ColorFragmentOp2ATI (will be remapped) */ + "iiiiiiiiii\0" + "glColorFragmentOp2ATI\0" + "\0" + /* _mesa_function_pool[4798]: SecondaryColorPointerListIBM (dynamic) */ + "iiipi\0" + "glSecondaryColorPointerListIBM\0" + "\0" + /* _mesa_function_pool[4836]: GetPixelTexGenParameterivSGIS (will be remapped) */ + "ip\0" + "glGetPixelTexGenParameterivSGIS\0" + "\0" + /* _mesa_function_pool[4872]: Color3fv (offset 14) */ + "p\0" + "glColor3fv\0" + "\0" + /* _mesa_function_pool[4886]: GetnPixelMapfvARB (will be remapped) */ + "iip\0" + "glGetnPixelMapfvARB\0" + "\0" + /* _mesa_function_pool[4911]: ReplacementCodeubSUN (dynamic) */ + "i\0" + "glReplacementCodeubSUN\0" + "\0" + /* _mesa_function_pool[4937]: FinishAsyncSGIX (dynamic) */ + "p\0" + "glFinishAsyncSGIX\0" + "\0" + /* _mesa_function_pool[4958]: GetnUniformfvARB (will be remapped) */ + "iiip\0" + "glGetnUniformfvARB\0" + "\0" + /* _mesa_function_pool[4983]: GetDebugLogMESA (dynamic) */ + "iiiipp\0" + "glGetDebugLogMESA\0" + "\0" + /* _mesa_function_pool[5009]: FogCoorddEXT (will be remapped) */ + "d\0" + "glFogCoordd\0" + "glFogCoorddEXT\0" + "\0" + /* _mesa_function_pool[5039]: BeginConditionalRenderNV (will be remapped) */ + "ii\0" + "glBeginConditionalRenderNV\0" + "glBeginConditionalRender\0" + "\0" + /* _mesa_function_pool[5095]: Color4ubVertex3fSUN (dynamic) */ + "iiiifff\0" + "glColor4ubVertex3fSUN\0" + "\0" + /* _mesa_function_pool[5126]: FogCoordfEXT (will be remapped) */ + "f\0" + "glFogCoordf\0" + "glFogCoordfEXT\0" + "\0" + /* _mesa_function_pool[5156]: PointSize (offset 173) */ + "f\0" + "glPointSize\0" + "\0" + /* _mesa_function_pool[5171]: VertexAttribI2uivEXT (will be remapped) */ + "ip\0" + "glVertexAttribI2uivEXT\0" + "glVertexAttribI2uiv\0" + "\0" + /* _mesa_function_pool[5218]: TexCoord2fVertex3fSUN (dynamic) */ + "fffff\0" + "glTexCoord2fVertex3fSUN\0" + "\0" + /* _mesa_function_pool[5249]: PopName (offset 200) */ + "\0" + "glPopName\0" + "\0" + /* _mesa_function_pool[5261]: GetSamplerParameterfv (will be remapped) */ + "iip\0" + "glGetSamplerParameterfv\0" + "\0" + /* _mesa_function_pool[5290]: GlobalAlphaFactoriSUN (dynamic) */ + "i\0" + "glGlobalAlphaFactoriSUN\0" + "\0" + /* _mesa_function_pool[5317]: VertexAttrib2dNV (will be remapped) */ + "idd\0" + "glVertexAttrib2dNV\0" + "\0" + /* _mesa_function_pool[5341]: GetProgramInfoLog (will be remapped) */ + "iipp\0" + "glGetProgramInfoLog\0" + "\0" + /* _mesa_function_pool[5367]: VertexP2ui (will be remapped) */ + "ii\0" + "glVertexP2ui\0" + "\0" + /* _mesa_function_pool[5384]: VertexAttrib4NbvARB (will be remapped) */ + "ip\0" + "glVertexAttrib4Nbv\0" + "glVertexAttrib4NbvARB\0" + "\0" + /* _mesa_function_pool[5429]: GetActiveAttribARB (will be remapped) */ + "iiipppp\0" + "glGetActiveAttrib\0" + "glGetActiveAttribARB\0" + "\0" + /* _mesa_function_pool[5477]: Vertex4sv (offset 149) */ + "p\0" + "glVertex4sv\0" + "\0" + /* _mesa_function_pool[5492]: VertexAttrib4ubNV (will be remapped) */ + "iiiii\0" + "glVertexAttrib4ubNV\0" + "\0" + /* _mesa_function_pool[5519]: VertexAttribI1ivEXT (will be remapped) */ + "ip\0" + "glVertexAttribI1ivEXT\0" + "glVertexAttribI1iv\0" + "\0" + /* _mesa_function_pool[5564]: ClampColor (will be remapped) */ + "ii\0" + "glClampColor\0" + "\0" + /* _mesa_function_pool[5581]: TextureRangeAPPLE (will be remapped) */ + "iip\0" + "glTextureRangeAPPLE\0" + "\0" + /* _mesa_function_pool[5606]: GetTexEnvfv (offset 276) */ + "iip\0" + "glGetTexEnvfv\0" + "\0" + /* _mesa_function_pool[5625]: VertexAttribP2uiv (will be remapped) */ + "iiip\0" + "glVertexAttribP2uiv\0" + "\0" + /* _mesa_function_pool[5651]: BindTransformFeedback (will be remapped) */ + "ii\0" + "glBindTransformFeedback\0" + "\0" + /* _mesa_function_pool[5679]: TexCoord2fColor4fNormal3fVertex3fSUN (dynamic) */ + "ffffffffffff\0" + "glTexCoord2fColor4fNormal3fVertex3fSUN\0" + "\0" + /* _mesa_function_pool[5732]: Indexub (offset 315) */ + "i\0" + "glIndexub\0" + "\0" + /* _mesa_function_pool[5745]: VertexAttrib4fNV (will be remapped) */ + "iffff\0" + "glVertexAttrib4fNV\0" + "\0" + /* _mesa_function_pool[5771]: TexEnvi (offset 186) */ + "iii\0" + "glTexEnvi\0" + "\0" + /* _mesa_function_pool[5786]: GetClipPlane (offset 259) */ + "ip\0" + "glGetClipPlane\0" + "\0" + /* _mesa_function_pool[5805]: CombinerParameterfvNV (will be remapped) */ + "ip\0" + "glCombinerParameterfvNV\0" + "\0" + /* _mesa_function_pool[5833]: TexCoordP4uiv (will be remapped) */ + "ip\0" + "glTexCoordP4uiv\0" + "\0" + /* _mesa_function_pool[5853]: VertexAttribs3dvNV (will be remapped) */ + "iip\0" + "glVertexAttribs3dvNV\0" + "\0" + /* _mesa_function_pool[5879]: VertexAttribI2uiEXT (will be remapped) */ + "iii\0" + "glVertexAttribI2uiEXT\0" + "glVertexAttribI2ui\0" + "\0" + /* _mesa_function_pool[5925]: VertexAttribs4fvNV (will be remapped) */ + "iip\0" + "glVertexAttribs4fvNV\0" + "\0" + /* _mesa_function_pool[5951]: VertexArrayRangeNV (will be remapped) */ + "ip\0" + "glVertexArrayRangeNV\0" + "\0" + /* _mesa_function_pool[5976]: FragmentLightiSGIX (dynamic) */ + "iii\0" + "glFragmentLightiSGIX\0" + "\0" + /* _mesa_function_pool[6002]: PolygonOffsetEXT (will be remapped) */ + "ff\0" + "glPolygonOffsetEXT\0" + "\0" + /* _mesa_function_pool[6025]: VertexAttribI4uivEXT (will be remapped) */ + "ip\0" + "glVertexAttribI4uivEXT\0" + "glVertexAttribI4uiv\0" + "\0" + /* _mesa_function_pool[6072]: PollAsyncSGIX (dynamic) */ + "p\0" + "glPollAsyncSGIX\0" + "\0" + /* _mesa_function_pool[6091]: DeleteFragmentShaderATI (will be remapped) */ + "i\0" + "glDeleteFragmentShaderATI\0" + "\0" + /* _mesa_function_pool[6120]: Scaled (offset 301) */ + "ddd\0" + "glScaled\0" + "\0" + /* _mesa_function_pool[6134]: ResumeTransformFeedback (will be remapped) */ + "\0" + "glResumeTransformFeedback\0" + "\0" + /* _mesa_function_pool[6162]: Scalef (offset 302) */ + "fff\0" + "glScalef\0" + "\0" + /* _mesa_function_pool[6176]: TexCoord2fNormal3fVertex3fvSUN (dynamic) */ + "ppp\0" + "glTexCoord2fNormal3fVertex3fvSUN\0" + "\0" + /* _mesa_function_pool[6214]: ProgramEnvParameters4fvEXT (will be remapped) */ + "iiip\0" + "glProgramEnvParameters4fvEXT\0" + "\0" + /* _mesa_function_pool[6249]: MultTransposeMatrixdARB (will be remapped) */ + "p\0" + "glMultTransposeMatrixd\0" + "glMultTransposeMatrixdARB\0" + "\0" + /* _mesa_function_pool[6301]: ObjectUnpurgeableAPPLE (will be remapped) */ + "iii\0" + "glObjectUnpurgeableAPPLE\0" + "\0" + /* _mesa_function_pool[6331]: TexCoordP3ui (will be remapped) */ + "ii\0" + "glTexCoordP3ui\0" + "\0" + /* _mesa_function_pool[6350]: AlphaFunc (offset 240) */ + "if\0" + "glAlphaFunc\0" + "\0" + /* _mesa_function_pool[6366]: WindowPos2svMESA (will be remapped) */ + "p\0" + "glWindowPos2sv\0" + "glWindowPos2svARB\0" + "glWindowPos2svMESA\0" + "\0" + /* _mesa_function_pool[6421]: EdgeFlag (offset 41) */ + "i\0" + "glEdgeFlag\0" + "\0" + /* _mesa_function_pool[6435]: TexCoord2iv (offset 107) */ + "p\0" + "glTexCoord2iv\0" + "\0" + /* _mesa_function_pool[6452]: CompressedTexImage1DARB (will be remapped) */ + "iiiiiip\0" + "glCompressedTexImage1D\0" + "glCompressedTexImage1DARB\0" + "\0" + /* _mesa_function_pool[6510]: Rotated (offset 299) */ + "dddd\0" + "glRotated\0" + "\0" + /* _mesa_function_pool[6526]: GetTexParameterIuivEXT (will be remapped) */ + "iip\0" + "glGetTexParameterIuivEXT\0" + "glGetTexParameterIuiv\0" + "\0" + /* _mesa_function_pool[6578]: VertexAttrib2sNV (will be remapped) */ + "iii\0" + "glVertexAttrib2sNV\0" + "\0" + /* _mesa_function_pool[6602]: ReadPixels (offset 256) */ + "iiiiiip\0" + "glReadPixels\0" + "\0" + /* _mesa_function_pool[6624]: VertexAttribDivisorARB (will be remapped) */ + "ii\0" + "glVertexAttribDivisorARB\0" + "\0" + /* _mesa_function_pool[6653]: EdgeFlagv (offset 42) */ + "p\0" + "glEdgeFlagv\0" + "\0" + /* _mesa_function_pool[6668]: NormalPointerListIBM (dynamic) */ + "iipi\0" + "glNormalPointerListIBM\0" + "\0" + /* _mesa_function_pool[6697]: IndexPointerEXT (will be remapped) */ + "iiip\0" + "glIndexPointerEXT\0" + "\0" + /* _mesa_function_pool[6721]: Color4iv (offset 32) */ + "p\0" + "glColor4iv\0" + "\0" + /* _mesa_function_pool[6735]: TexParameterf (offset 178) */ + "iif\0" + "glTexParameterf\0" + "\0" + /* _mesa_function_pool[6756]: TexParameteri (offset 180) */ + "iii\0" + "glTexParameteri\0" + "\0" + /* _mesa_function_pool[6777]: NormalPointerEXT (will be remapped) */ + "iiip\0" + "glNormalPointerEXT\0" + "\0" + /* _mesa_function_pool[6802]: MultiTexCoord3dARB (offset 392) */ + "iddd\0" + "glMultiTexCoord3d\0" + "glMultiTexCoord3dARB\0" + "\0" + /* _mesa_function_pool[6847]: MultiTexCoord2iARB (offset 388) */ + "iii\0" + "glMultiTexCoord2i\0" + "glMultiTexCoord2iARB\0" + "\0" + /* _mesa_function_pool[6891]: DrawPixels (offset 257) */ + "iiiip\0" + "glDrawPixels\0" + "\0" + /* _mesa_function_pool[6911]: ReplacementCodeuiTexCoord2fNormal3fVertex3fSUN (dynamic) */ + "iffffffff\0" + "glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN\0" + "\0" + /* _mesa_function_pool[6971]: MultiTexCoord2svARB (offset 391) */ + "ip\0" + "glMultiTexCoord2sv\0" + "glMultiTexCoord2svARB\0" + "\0" + /* _mesa_function_pool[7016]: ReplacementCodeubvSUN (dynamic) */ + "p\0" + "glReplacementCodeubvSUN\0" + "\0" + /* _mesa_function_pool[7043]: Uniform3iARB (will be remapped) */ + "iiii\0" + "glUniform3i\0" + "glUniform3iARB\0" + "\0" + /* _mesa_function_pool[7076]: DrawTransformFeedback (will be remapped) */ + "ii\0" + "glDrawTransformFeedback\0" + "\0" + /* _mesa_function_pool[7104]: DrawElementsInstancedARB (will be remapped) */ + "iiipi\0" + "glDrawElementsInstancedARB\0" + "glDrawElementsInstancedEXT\0" + "glDrawElementsInstanced\0" + "\0" + /* _mesa_function_pool[7189]: GetShaderInfoLog (will be remapped) */ + "iipp\0" + "glGetShaderInfoLog\0" + "\0" + /* _mesa_function_pool[7214]: WeightivARB (dynamic) */ + "ip\0" + "glWeightivARB\0" + "\0" + /* _mesa_function_pool[7232]: PollInstrumentsSGIX (dynamic) */ + "p\0" + "glPollInstrumentsSGIX\0" + "\0" + /* _mesa_function_pool[7257]: GlobalAlphaFactordSUN (dynamic) */ + "d\0" + "glGlobalAlphaFactordSUN\0" + "\0" + /* _mesa_function_pool[7284]: GetFinalCombinerInputParameterfvNV (will be remapped) */ + "iip\0" + "glGetFinalCombinerInputParameterfvNV\0" + "\0" + /* _mesa_function_pool[7326]: GenerateMipmapEXT (will be remapped) */ + "i\0" + "glGenerateMipmap\0" + "glGenerateMipmapEXT\0" + "\0" + /* _mesa_function_pool[7366]: GenLists (offset 5) */ + "i\0" + "glGenLists\0" + "\0" + /* _mesa_function_pool[7380]: DepthRangef (will be remapped) */ + "ff\0" + "glDepthRangef\0" + "\0" + /* _mesa_function_pool[7398]: GetMapAttribParameterivNV (dynamic) */ + "iiip\0" + "glGetMapAttribParameterivNV\0" + "\0" + /* _mesa_function_pool[7432]: CreateShaderObjectARB (will be remapped) */ + "i\0" + "glCreateShaderObjectARB\0" + "\0" + /* _mesa_function_pool[7459]: GetSharpenTexFuncSGIS (dynamic) */ + "ip\0" + "glGetSharpenTexFuncSGIS\0" + "\0" + /* _mesa_function_pool[7487]: BufferDataARB (will be remapped) */ + "iipi\0" + "glBufferData\0" + "glBufferDataARB\0" + "\0" + /* _mesa_function_pool[7522]: FlushVertexArrayRangeNV (will be remapped) */ + "\0" + "glFlushVertexArrayRangeNV\0" + "\0" + /* _mesa_function_pool[7550]: MapGrid2d (offset 226) */ + "iddidd\0" + "glMapGrid2d\0" + "\0" + /* _mesa_function_pool[7570]: MapGrid2f (offset 227) */ + "iffiff\0" + "glMapGrid2f\0" + "\0" + /* _mesa_function_pool[7590]: SampleMapATI (will be remapped) */ + "iii\0" + "glSampleMapATI\0" + "\0" + /* _mesa_function_pool[7610]: VertexPointerEXT (will be remapped) */ + "iiiip\0" + "glVertexPointerEXT\0" + "\0" + /* _mesa_function_pool[7636]: GetTexFilterFuncSGIS (dynamic) */ + "iip\0" + "glGetTexFilterFuncSGIS\0" + "\0" + /* _mesa_function_pool[7664]: Scissor (offset 176) */ + "iiii\0" + "glScissor\0" + "\0" + /* _mesa_function_pool[7680]: Fogf (offset 153) */ + "if\0" + "glFogf\0" + "\0" + /* _mesa_function_pool[7691]: ReplacementCodeuiColor4ubVertex3fvSUN (dynamic) */ + "ppp\0" + "glReplacementCodeuiColor4ubVertex3fvSUN\0" + "\0" + /* _mesa_function_pool[7736]: TexSubImage1D (offset 332) */ + "iiiiiip\0" + "glTexSubImage1D\0" + "glTexSubImage1DEXT\0" + "\0" + /* _mesa_function_pool[7780]: VertexAttrib1sARB (will be remapped) */ + "ii\0" + "glVertexAttrib1s\0" + "glVertexAttrib1sARB\0" + "\0" + /* _mesa_function_pool[7821]: FenceSync (will be remapped) */ + "ii\0" + "glFenceSync\0" + "\0" + /* _mesa_function_pool[7837]: Color4usv (offset 40) */ + "p\0" + "glColor4usv\0" + "\0" + /* _mesa_function_pool[7852]: Fogi (offset 155) */ + "ii\0" + "glFogi\0" + "\0" + /* _mesa_function_pool[7863]: DepthRange (offset 288) */ + "dd\0" + "glDepthRange\0" + "\0" + /* _mesa_function_pool[7880]: RasterPos3iv (offset 75) */ + "p\0" + "glRasterPos3iv\0" + "\0" + /* _mesa_function_pool[7898]: FinalCombinerInputNV (will be remapped) */ + "iiii\0" + "glFinalCombinerInputNV\0" + "\0" + /* _mesa_function_pool[7927]: TexCoord2i (offset 106) */ + "ii\0" + "glTexCoord2i\0" + "\0" + /* _mesa_function_pool[7944]: PixelMapfv (offset 251) */ + "iip\0" + "glPixelMapfv\0" + "\0" + /* _mesa_function_pool[7962]: Color4ui (offset 37) */ + "iiii\0" + "glColor4ui\0" + "\0" + /* _mesa_function_pool[7979]: RasterPos3s (offset 76) */ + "iii\0" + "glRasterPos3s\0" + "\0" + /* _mesa_function_pool[7998]: Color3usv (offset 24) */ + "p\0" + "glColor3usv\0" + "\0" + /* _mesa_function_pool[8013]: FlushRasterSGIX (dynamic) */ + "\0" + "glFlushRasterSGIX\0" + "\0" + /* _mesa_function_pool[8033]: TexCoord2f (offset 104) */ + "ff\0" + "glTexCoord2f\0" + "\0" + /* _mesa_function_pool[8050]: ReplacementCodeuiTexCoord2fVertex3fSUN (dynamic) */ + "ifffff\0" + "glReplacementCodeuiTexCoord2fVertex3fSUN\0" + "\0" + /* _mesa_function_pool[8099]: TexCoord2d (offset 102) */ + "dd\0" + "glTexCoord2d\0" + "\0" + /* _mesa_function_pool[8116]: RasterPos3d (offset 70) */ + "ddd\0" + "glRasterPos3d\0" + "\0" + /* _mesa_function_pool[8135]: RasterPos3f (offset 72) */ + "fff\0" + "glRasterPos3f\0" + "\0" + /* _mesa_function_pool[8154]: Uniform1fARB (will be remapped) */ + "if\0" + "glUniform1f\0" + "glUniform1fARB\0" + "\0" + /* _mesa_function_pool[8185]: AreTexturesResident (offset 322) */ + "ipp\0" + "glAreTexturesResident\0" + "glAreTexturesResidentEXT\0" + "\0" + /* _mesa_function_pool[8237]: TexCoord2s (offset 108) */ + "ii\0" + "glTexCoord2s\0" + "\0" + /* _mesa_function_pool[8254]: StencilOpSeparate (will be remapped) */ + "iiii\0" + "glStencilOpSeparate\0" + "glStencilOpSeparateATI\0" + "\0" + /* _mesa_function_pool[8303]: ColorTableParameteriv (offset 341) */ + "iip\0" + "glColorTableParameteriv\0" + "glColorTableParameterivSGI\0" + "\0" + /* _mesa_function_pool[8359]: FogCoordPointerListIBM (dynamic) */ + "iipi\0" + "glFogCoordPointerListIBM\0" + "\0" + /* _mesa_function_pool[8390]: WindowPos3dMESA (will be remapped) */ + "ddd\0" + "glWindowPos3d\0" + "glWindowPos3dARB\0" + "glWindowPos3dMESA\0" + "\0" + /* _mesa_function_pool[8444]: Color4us (offset 39) */ + "iiii\0" + "glColor4us\0" + "\0" + /* _mesa_function_pool[8461]: PointParameterfvEXT (will be remapped) */ + "ip\0" + "glPointParameterfv\0" + "glPointParameterfvARB\0" + "glPointParameterfvEXT\0" + "glPointParameterfvSGIS\0" + "\0" + /* _mesa_function_pool[8551]: Color3bv (offset 10) */ + "p\0" + "glColor3bv\0" + "\0" + /* _mesa_function_pool[8565]: GetnCompressedTexImageARB (will be remapped) */ + "iiip\0" + "glGetnCompressedTexImageARB\0" + "\0" + /* _mesa_function_pool[8599]: WindowPos2fvMESA (will be remapped) */ + "p\0" + "glWindowPos2fv\0" + "glWindowPos2fvARB\0" + "glWindowPos2fvMESA\0" + "\0" + /* _mesa_function_pool[8654]: SecondaryColor3bvEXT (will be remapped) */ + "p\0" + "glSecondaryColor3bv\0" + "glSecondaryColor3bvEXT\0" + "\0" + /* _mesa_function_pool[8700]: VertexPointerListIBM (dynamic) */ + "iiipi\0" + "glVertexPointerListIBM\0" + "\0" + /* _mesa_function_pool[8730]: GetProgramLocalParameterfvARB (will be remapped) */ + "iip\0" + "glGetProgramLocalParameterfvARB\0" + "\0" + /* _mesa_function_pool[8767]: FragmentMaterialfSGIX (dynamic) */ + "iif\0" + "glFragmentMaterialfSGIX\0" + "\0" + /* _mesa_function_pool[8796]: BindSampler (will be remapped) */ + "ii\0" + "glBindSampler\0" + "\0" + /* _mesa_function_pool[8814]: RenderbufferStorageEXT (will be remapped) */ + "iiii\0" + "glRenderbufferStorage\0" + "glRenderbufferStorageEXT\0" + "\0" + /* _mesa_function_pool[8867]: IsFenceNV (will be remapped) */ + "i\0" + "glIsFenceNV\0" + "\0" + /* _mesa_function_pool[8882]: AttachObjectARB (will be remapped) */ + "ii\0" + "glAttachObjectARB\0" + "\0" + /* _mesa_function_pool[8904]: GetFragmentLightivSGIX (dynamic) */ + "iip\0" + "glGetFragmentLightivSGIX\0" + "\0" + /* _mesa_function_pool[8934]: UniformMatrix2fvARB (will be remapped) */ + "iiip\0" + "glUniformMatrix2fv\0" + "glUniformMatrix2fvARB\0" + "\0" + /* _mesa_function_pool[8981]: MultiTexCoord2fARB (offset 386) */ + "iff\0" + "glMultiTexCoord2f\0" + "glMultiTexCoord2fARB\0" + "\0" + /* _mesa_function_pool[9025]: ColorTable (offset 339) */ + "iiiiip\0" + "glColorTable\0" + "glColorTableSGI\0" + "glColorTableEXT\0" + "\0" + /* _mesa_function_pool[9078]: IndexPointer (offset 314) */ + "iip\0" + "glIndexPointer\0" + "\0" + /* _mesa_function_pool[9098]: Accum (offset 213) */ + "if\0" + "glAccum\0" + "\0" + /* _mesa_function_pool[9110]: GetTexImage (offset 281) */ + "iiiip\0" + "glGetTexImage\0" + "\0" + /* _mesa_function_pool[9131]: MapControlPointsNV (dynamic) */ + "iiiiiiiip\0" + "glMapControlPointsNV\0" + "\0" + /* _mesa_function_pool[9163]: ConvolutionFilter2D (offset 349) */ + "iiiiiip\0" + "glConvolutionFilter2D\0" + "glConvolutionFilter2DEXT\0" + "\0" + /* _mesa_function_pool[9219]: Finish (offset 216) */ + "\0" + "glFinish\0" + "\0" + /* _mesa_function_pool[9230]: MapParameterfvNV (dynamic) */ + "iip\0" + "glMapParameterfvNV\0" + "\0" + /* _mesa_function_pool[9254]: ClearStencil (offset 207) */ + "i\0" + "glClearStencil\0" + "\0" + /* _mesa_function_pool[9272]: VertexAttrib3dvARB (will be remapped) */ + "ip\0" + "glVertexAttrib3dv\0" + "glVertexAttrib3dvARB\0" + "\0" + /* _mesa_function_pool[9315]: Uniform4uivEXT (will be remapped) */ + "iip\0" + "glUniform4uivEXT\0" + "glUniform4uiv\0" + "\0" + /* _mesa_function_pool[9351]: HintPGI (dynamic) */ + "ii\0" + "glHintPGI\0" + "\0" + /* _mesa_function_pool[9365]: ConvolutionParameteriv (offset 353) */ + "iip\0" + "glConvolutionParameteriv\0" + "glConvolutionParameterivEXT\0" + "\0" + /* _mesa_function_pool[9423]: Color4s (offset 33) */ + "iiii\0" + "glColor4s\0" + "\0" + /* _mesa_function_pool[9439]: InterleavedArrays (offset 317) */ + "iip\0" + "glInterleavedArrays\0" + "\0" + /* _mesa_function_pool[9464]: RasterPos2fv (offset 65) */ + "p\0" + "glRasterPos2fv\0" + "\0" + /* _mesa_function_pool[9482]: TexCoord1fv (offset 97) */ + "p\0" + "glTexCoord1fv\0" + "\0" + /* _mesa_function_pool[9499]: Vertex2d (offset 126) */ + "dd\0" + "glVertex2d\0" + "\0" + /* _mesa_function_pool[9514]: CullParameterdvEXT (dynamic) */ + "ip\0" + "glCullParameterdvEXT\0" + "\0" + /* _mesa_function_pool[9539]: ProgramNamedParameter4fNV (will be remapped) */ + "iipffff\0" + "glProgramNamedParameter4fNV\0" + "\0" + /* _mesa_function_pool[9576]: Color3fVertex3fSUN (dynamic) */ + "ffffff\0" + "glColor3fVertex3fSUN\0" + "\0" + /* _mesa_function_pool[9605]: ProgramEnvParameter4fvARB (will be remapped) */ + "iip\0" + "glProgramEnvParameter4fvARB\0" + "glProgramParameter4fvNV\0" + "\0" + /* _mesa_function_pool[9662]: Color4i (offset 31) */ + "iiii\0" + "glColor4i\0" + "\0" + /* _mesa_function_pool[9678]: Color4f (offset 29) */ + "ffff\0" + "glColor4f\0" + "\0" + /* _mesa_function_pool[9694]: RasterPos4fv (offset 81) */ + "p\0" + "glRasterPos4fv\0" + "\0" + /* _mesa_function_pool[9712]: Color4d (offset 27) */ + "dddd\0" + "glColor4d\0" + "\0" + /* _mesa_function_pool[9728]: ClearIndex (offset 205) */ + "f\0" + "glClearIndex\0" + "\0" + /* _mesa_function_pool[9744]: Color4b (offset 25) */ + "iiii\0" + "glColor4b\0" + "\0" + /* _mesa_function_pool[9760]: LoadMatrixd (offset 292) */ + "p\0" + "glLoadMatrixd\0" + "\0" + /* _mesa_function_pool[9777]: FragmentLightModeliSGIX (dynamic) */ + "ii\0" + "glFragmentLightModeliSGIX\0" + "\0" + /* _mesa_function_pool[9807]: RasterPos2dv (offset 63) */ + "p\0" + "glRasterPos2dv\0" + "\0" + /* _mesa_function_pool[9825]: ConvolutionParameterfv (offset 351) */ + "iip\0" + "glConvolutionParameterfv\0" + "glConvolutionParameterfvEXT\0" + "\0" + /* _mesa_function_pool[9883]: TbufferMask3DFX (dynamic) */ + "i\0" + "glTbufferMask3DFX\0" + "\0" + /* _mesa_function_pool[9904]: GetTexGendv (offset 278) */ + "iip\0" + "glGetTexGendv\0" + "\0" + /* _mesa_function_pool[9923]: GetVertexAttribfvNV (will be remapped) */ + "iip\0" + "glGetVertexAttribfvNV\0" + "\0" + /* _mesa_function_pool[9950]: BeginTransformFeedbackEXT (will be remapped) */ + "i\0" + "glBeginTransformFeedbackEXT\0" + "glBeginTransformFeedback\0" + "\0" + /* _mesa_function_pool[10006]: LoadProgramNV (will be remapped) */ + "iiip\0" + "glLoadProgramNV\0" + "\0" + /* _mesa_function_pool[10028]: WaitSync (will be remapped) */ + "iii\0" + "glWaitSync\0" + "\0" + /* _mesa_function_pool[10044]: EndList (offset 1) */ + "\0" + "glEndList\0" + "\0" + /* _mesa_function_pool[10056]: VertexP4ui (will be remapped) */ + "ii\0" + "glVertexP4ui\0" + "\0" + /* _mesa_function_pool[10073]: VertexAttrib4fvNV (will be remapped) */ + "ip\0" + "glVertexAttrib4fvNV\0" + "\0" + /* _mesa_function_pool[10097]: GetAttachedObjectsARB (will be remapped) */ + "iipp\0" + "glGetAttachedObjectsARB\0" + "\0" + /* _mesa_function_pool[10127]: Uniform3fvARB (will be remapped) */ + "iip\0" + "glUniform3fv\0" + "glUniform3fvARB\0" + "\0" + /* _mesa_function_pool[10161]: EvalCoord1fv (offset 231) */ + "p\0" + "glEvalCoord1fv\0" + "\0" + /* _mesa_function_pool[10179]: DrawRangeElements (offset 338) */ + "iiiiip\0" + "glDrawRangeElements\0" + "glDrawRangeElementsEXT\0" + "\0" + /* _mesa_function_pool[10230]: EvalMesh2 (offset 238) */ + "iiiii\0" + "glEvalMesh2\0" + "\0" + /* _mesa_function_pool[10249]: Vertex4fv (offset 145) */ + "p\0" + "glVertex4fv\0" + "\0" + /* _mesa_function_pool[10264]: GenTransformFeedbacks (will be remapped) */ + "ip\0" + "glGenTransformFeedbacks\0" + "\0" + /* _mesa_function_pool[10292]: SpriteParameterfvSGIX (dynamic) */ + "ip\0" + "glSpriteParameterfvSGIX\0" + "\0" + /* _mesa_function_pool[10320]: CheckFramebufferStatusEXT (will be remapped) */ + "i\0" + "glCheckFramebufferStatus\0" + "glCheckFramebufferStatusEXT\0" + "\0" + /* _mesa_function_pool[10376]: GlobalAlphaFactoruiSUN (dynamic) */ + "i\0" + "glGlobalAlphaFactoruiSUN\0" + "\0" + /* _mesa_function_pool[10404]: GetHandleARB (will be remapped) */ + "i\0" + "glGetHandleARB\0" + "\0" + /* _mesa_function_pool[10422]: GetVertexAttribivARB (will be remapped) */ + "iip\0" + "glGetVertexAttribiv\0" + "glGetVertexAttribivARB\0" + "\0" + /* _mesa_function_pool[10470]: BlendFunciARB (will be remapped) */ + "iii\0" + "glBlendFunciARB\0" + "glBlendFuncIndexedAMD\0" + "\0" + /* _mesa_function_pool[10513]: VertexAttribP1ui (will be remapped) */ + "iiii\0" + "glVertexAttribP1ui\0" + "\0" + /* _mesa_function_pool[10538]: GetnUniformivARB (will be remapped) */ + "iiip\0" + "glGetnUniformivARB\0" + "\0" + /* _mesa_function_pool[10563]: GetTexParameterIivEXT (will be remapped) */ + "iip\0" + "glGetTexParameterIivEXT\0" + "glGetTexParameterIiv\0" + "\0" + /* _mesa_function_pool[10613]: CreateProgram (will be remapped) */ + "\0" + "glCreateProgram\0" + "\0" + /* _mesa_function_pool[10631]: LoadTransposeMatrixdARB (will be remapped) */ + "p\0" + "glLoadTransposeMatrixd\0" + "glLoadTransposeMatrixdARB\0" + "\0" + /* _mesa_function_pool[10683]: ReleaseShaderCompiler (will be remapped) */ + "\0" + "glReleaseShaderCompiler\0" + "\0" + /* _mesa_function_pool[10709]: GetMinmax (offset 364) */ + "iiiip\0" + "glGetMinmax\0" + "glGetMinmaxEXT\0" + "\0" + /* _mesa_function_pool[10743]: StencilFuncSeparate (will be remapped) */ + "iiii\0" + "glStencilFuncSeparate\0" + "\0" + /* _mesa_function_pool[10771]: SecondaryColor3sEXT (will be remapped) */ + "iii\0" + "glSecondaryColor3s\0" + "glSecondaryColor3sEXT\0" + "\0" + /* _mesa_function_pool[10817]: Color3fVertex3fvSUN (dynamic) */ + "pp\0" + "glColor3fVertex3fvSUN\0" + "\0" + /* _mesa_function_pool[10843]: GetInteger64i_v (will be remapped) */ + "iip\0" + "glGetInteger64i_v\0" + "\0" + /* _mesa_function_pool[10866]: GetVertexAttribdvNV (will be remapped) */ + "iip\0" + "glGetVertexAttribdvNV\0" + "\0" + /* _mesa_function_pool[10893]: Normal3fv (offset 57) */ + "p\0" + "glNormal3fv\0" + "\0" + /* _mesa_function_pool[10908]: GlobalAlphaFactorbSUN (dynamic) */ + "i\0" + "glGlobalAlphaFactorbSUN\0" + "\0" + /* _mesa_function_pool[10935]: Color3us (offset 23) */ + "iii\0" + "glColor3us\0" + "\0" + /* _mesa_function_pool[10951]: ImageTransformParameterfvHP (dynamic) */ + "iip\0" + "glImageTransformParameterfvHP\0" + "\0" + /* _mesa_function_pool[10986]: VertexAttrib4ivARB (will be remapped) */ + "ip\0" + "glVertexAttrib4iv\0" + "glVertexAttrib4ivARB\0" + "\0" + /* _mesa_function_pool[11029]: End (offset 43) */ + "\0" + "glEnd\0" + "\0" + /* _mesa_function_pool[11037]: VertexAttrib3fNV (will be remapped) */ + "ifff\0" + "glVertexAttrib3fNV\0" + "\0" + /* _mesa_function_pool[11062]: MultiTexCoordP3uiv (will be remapped) */ + "iip\0" + "glMultiTexCoordP3uiv\0" + "\0" + /* _mesa_function_pool[11088]: VertexAttribs2dvNV (will be remapped) */ + "iip\0" + "glVertexAttribs2dvNV\0" + "\0" + /* _mesa_function_pool[11114]: GetQueryObjectui64vEXT (will be remapped) */ + "iip\0" + "glGetQueryObjectui64vEXT\0" + "\0" + /* _mesa_function_pool[11144]: MultiTexCoord3fvARB (offset 395) */ + "ip\0" + "glMultiTexCoord3fv\0" + "glMultiTexCoord3fvARB\0" + "\0" + /* _mesa_function_pool[11189]: SecondaryColor3dEXT (will be remapped) */ + "ddd\0" + "glSecondaryColor3d\0" + "glSecondaryColor3dEXT\0" + "\0" + /* _mesa_function_pool[11235]: Color3ub (offset 19) */ + "iii\0" + "glColor3ub\0" + "\0" + /* _mesa_function_pool[11251]: GetProgramParameterfvNV (will be remapped) */ + "iiip\0" + "glGetProgramParameterfvNV\0" + "\0" + /* _mesa_function_pool[11283]: TangentPointerEXT (dynamic) */ + "iip\0" + "glTangentPointerEXT\0" + "\0" + /* _mesa_function_pool[11308]: Color4fNormal3fVertex3fvSUN (dynamic) */ + "ppp\0" + "glColor4fNormal3fVertex3fvSUN\0" + "\0" + /* _mesa_function_pool[11343]: GetInstrumentsSGIX (dynamic) */ + "\0" + "glGetInstrumentsSGIX\0" + "\0" + /* _mesa_function_pool[11366]: GetUniformuivEXT (will be remapped) */ + "iip\0" + "glGetUniformuivEXT\0" + "glGetUniformuiv\0" + "\0" + /* _mesa_function_pool[11406]: Color3ui (offset 21) */ + "iii\0" + "glColor3ui\0" + "\0" + /* _mesa_function_pool[11422]: EvalMapsNV (dynamic) */ + "ii\0" + "glEvalMapsNV\0" + "\0" + /* _mesa_function_pool[11439]: TexSubImage2D (offset 333) */ + "iiiiiiiip\0" + "glTexSubImage2D\0" + "glTexSubImage2DEXT\0" + "\0" + /* _mesa_function_pool[11485]: FragmentLightivSGIX (dynamic) */ + "iip\0" + "glFragmentLightivSGIX\0" + "\0" + /* _mesa_function_pool[11512]: GetTexParameterPointervAPPLE (will be remapped) */ + "iip\0" + "glGetTexParameterPointervAPPLE\0" + "\0" + /* _mesa_function_pool[11548]: TexGenfv (offset 191) */ + "iip\0" + "glTexGenfv\0" + "\0" + /* _mesa_function_pool[11564]: GetTransformFeedbackVaryingEXT (will be remapped) */ + "iiipppp\0" + "glGetTransformFeedbackVaryingEXT\0" + "glGetTransformFeedbackVarying\0" + "\0" + /* _mesa_function_pool[11636]: VertexAttrib4bvARB (will be remapped) */ + "ip\0" + "glVertexAttrib4bv\0" + "glVertexAttrib4bvARB\0" + "\0" + /* _mesa_function_pool[11679]: ShaderBinary (will be remapped) */ + "ipipi\0" + "glShaderBinary\0" + "\0" + /* _mesa_function_pool[11701]: GetIntegerIndexedvEXT (will be remapped) */ + "iip\0" + "glGetIntegerIndexedvEXT\0" + "glGetIntegeri_v\0" + "\0" + /* _mesa_function_pool[11746]: MultiTexCoord4sARB (offset 406) */ + "iiiii\0" + "glMultiTexCoord4s\0" + "glMultiTexCoord4sARB\0" + "\0" + /* _mesa_function_pool[11792]: GetFragmentMaterialivSGIX (dynamic) */ + "iip\0" + "glGetFragmentMaterialivSGIX\0" + "\0" + /* _mesa_function_pool[11825]: WindowPos4dMESA (will be remapped) */ + "dddd\0" + "glWindowPos4dMESA\0" + "\0" + /* _mesa_function_pool[11849]: WeightPointerARB (dynamic) */ + "iiip\0" + "glWeightPointerARB\0" + "\0" + /* _mesa_function_pool[11874]: WindowPos2dMESA (will be remapped) */ + "dd\0" + "glWindowPos2d\0" + "glWindowPos2dARB\0" + "glWindowPos2dMESA\0" + "\0" + /* _mesa_function_pool[11927]: FramebufferTexture3DEXT (will be remapped) */ + "iiiiii\0" + "glFramebufferTexture3D\0" + "glFramebufferTexture3DEXT\0" + "\0" + /* _mesa_function_pool[11984]: BlendEquation (offset 337) */ + "i\0" + "glBlendEquation\0" + "glBlendEquationEXT\0" + "\0" + /* _mesa_function_pool[12022]: VertexAttrib3dNV (will be remapped) */ + "iddd\0" + "glVertexAttrib3dNV\0" + "\0" + /* _mesa_function_pool[12047]: VertexAttrib3dARB (will be remapped) */ + "iddd\0" + "glVertexAttrib3d\0" + "glVertexAttrib3dARB\0" + "\0" + /* _mesa_function_pool[12090]: VertexAttribI4usvEXT (will be remapped) */ + "ip\0" + "glVertexAttribI4usvEXT\0" + "glVertexAttribI4usv\0" + "\0" + /* _mesa_function_pool[12137]: ReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN (dynamic) */ + "ppppp\0" + "glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN\0" + "\0" + /* _mesa_function_pool[12201]: VertexAttrib4fARB (will be remapped) */ + "iffff\0" + "glVertexAttrib4f\0" + "glVertexAttrib4fARB\0" + "\0" + /* _mesa_function_pool[12245]: GetError (offset 261) */ + "\0" + "glGetError\0" + "\0" + /* _mesa_function_pool[12258]: IndexFuncEXT (dynamic) */ + "if\0" + "glIndexFuncEXT\0" + "\0" + /* _mesa_function_pool[12277]: TexCoord3dv (offset 111) */ + "p\0" + "glTexCoord3dv\0" + "\0" + /* _mesa_function_pool[12294]: Indexdv (offset 45) */ + "p\0" + "glIndexdv\0" + "\0" + /* _mesa_function_pool[12307]: FramebufferTexture2DEXT (will be remapped) */ + "iiiii\0" + "glFramebufferTexture2D\0" + "glFramebufferTexture2DEXT\0" + "\0" + /* _mesa_function_pool[12363]: Normal3s (offset 60) */ + "iii\0" + "glNormal3s\0" + "\0" + /* _mesa_function_pool[12379]: GetObjectParameterivAPPLE (will be remapped) */ + "iiip\0" + "glGetObjectParameterivAPPLE\0" + "\0" + /* _mesa_function_pool[12413]: PushName (offset 201) */ + "i\0" + "glPushName\0" + "\0" + /* _mesa_function_pool[12427]: MultiTexCoord2dvARB (offset 385) */ + "ip\0" + "glMultiTexCoord2dv\0" + "glMultiTexCoord2dvARB\0" + "\0" + /* _mesa_function_pool[12472]: CullParameterfvEXT (dynamic) */ + "ip\0" + "glCullParameterfvEXT\0" + "\0" + /* _mesa_function_pool[12497]: Normal3i (offset 58) */ + "iii\0" + "glNormal3i\0" + "\0" + /* _mesa_function_pool[12513]: ProgramNamedParameter4fvNV (will be remapped) */ + "iipp\0" + "glProgramNamedParameter4fvNV\0" + "\0" + /* _mesa_function_pool[12548]: SecondaryColorPointerEXT (will be remapped) */ + "iiip\0" + "glSecondaryColorPointer\0" + "glSecondaryColorPointerEXT\0" + "\0" + /* _mesa_function_pool[12605]: VertexAttrib4fvARB (will be remapped) */ + "ip\0" + "glVertexAttrib4fv\0" + "glVertexAttrib4fvARB\0" + "\0" + /* _mesa_function_pool[12648]: PixelTexGenSGIX (will be remapped) */ + "i\0" + "glPixelTexGenSGIX\0" + "\0" + /* _mesa_function_pool[12669]: GetActiveUniformARB (will be remapped) */ + "iiipppp\0" + "glGetActiveUniform\0" + "glGetActiveUniformARB\0" + "\0" + /* _mesa_function_pool[12719]: ImageTransformParameteriHP (dynamic) */ + "iii\0" + "glImageTransformParameteriHP\0" + "\0" + /* _mesa_function_pool[12753]: Normal3b (offset 52) */ + "iii\0" + "glNormal3b\0" + "\0" + /* _mesa_function_pool[12769]: Normal3d (offset 54) */ + "ddd\0" + "glNormal3d\0" + "\0" + /* _mesa_function_pool[12785]: Uniform1uiEXT (will be remapped) */ + "ii\0" + "glUniform1uiEXT\0" + "glUniform1ui\0" + "\0" + /* _mesa_function_pool[12818]: Normal3f (offset 56) */ + "fff\0" + "glNormal3f\0" + "\0" + /* _mesa_function_pool[12834]: MultiTexCoord1svARB (offset 383) */ + "ip\0" + "glMultiTexCoord1sv\0" + "glMultiTexCoord1svARB\0" + "\0" + /* _mesa_function_pool[12879]: Indexi (offset 48) */ + "i\0" + "glIndexi\0" + "\0" + /* _mesa_function_pool[12891]: EGLImageTargetTexture2DOES (will be remapped) */ + "ip\0" + "glEGLImageTargetTexture2DOES\0" + "\0" + /* _mesa_function_pool[12924]: EndQueryARB (will be remapped) */ + "i\0" + "glEndQuery\0" + "glEndQueryARB\0" + "\0" + /* _mesa_function_pool[12952]: DeleteFencesNV (will be remapped) */ + "ip\0" + "glDeleteFencesNV\0" + "\0" + /* _mesa_function_pool[12973]: ColorPointerListIBM (dynamic) */ + "iiipi\0" + "glColorPointerListIBM\0" + "\0" + /* _mesa_function_pool[13002]: BindBufferRangeEXT (will be remapped) */ + "iiiii\0" + "glBindBufferRangeEXT\0" + "glBindBufferRange\0" + "\0" + /* _mesa_function_pool[13048]: DepthMask (offset 211) */ + "i\0" + "glDepthMask\0" + "\0" + /* _mesa_function_pool[13063]: IsShader (will be remapped) */ + "i\0" + "glIsShader\0" + "\0" + /* _mesa_function_pool[13077]: Indexf (offset 46) */ + "f\0" + "glIndexf\0" + "\0" + /* _mesa_function_pool[13089]: GetImageTransformParameterivHP (dynamic) */ + "iip\0" + "glGetImageTransformParameterivHP\0" + "\0" + /* _mesa_function_pool[13127]: Indexd (offset 44) */ + "d\0" + "glIndexd\0" + "\0" + /* _mesa_function_pool[13139]: GetMaterialiv (offset 270) */ + "iip\0" + "glGetMaterialiv\0" + "\0" + /* _mesa_function_pool[13160]: StencilOp (offset 244) */ + "iii\0" + "glStencilOp\0" + "\0" + /* _mesa_function_pool[13177]: WindowPos4ivMESA (will be remapped) */ + "p\0" + "glWindowPos4ivMESA\0" + "\0" + /* _mesa_function_pool[13199]: MultiTexCoord3svARB (offset 399) */ + "ip\0" + "glMultiTexCoord3sv\0" + "glMultiTexCoord3svARB\0" + "\0" + /* _mesa_function_pool[13244]: TexEnvfv (offset 185) */ + "iip\0" + "glTexEnvfv\0" + "\0" + /* _mesa_function_pool[13260]: MultiTexCoord4iARB (offset 404) */ + "iiiii\0" + "glMultiTexCoord4i\0" + "glMultiTexCoord4iARB\0" + "\0" + /* _mesa_function_pool[13306]: Indexs (offset 50) */ + "i\0" + "glIndexs\0" + "\0" + /* _mesa_function_pool[13318]: Binormal3ivEXT (dynamic) */ + "p\0" + "glBinormal3ivEXT\0" + "\0" + /* _mesa_function_pool[13338]: ResizeBuffersMESA (will be remapped) */ + "\0" + "glResizeBuffersMESA\0" + "\0" + /* _mesa_function_pool[13360]: MultiTexCoordP1uiv (will be remapped) */ + "iip\0" + "glMultiTexCoordP1uiv\0" + "\0" + /* _mesa_function_pool[13386]: BlendFuncSeparateiARB (will be remapped) */ + "iiiii\0" + "glBlendFuncSeparateiARB\0" + "glBlendFuncSeparateIndexedAMD\0" + "\0" + /* _mesa_function_pool[13447]: GetUniformivARB (will be remapped) */ + "iip\0" + "glGetUniformiv\0" + "glGetUniformivARB\0" + "\0" + /* _mesa_function_pool[13485]: PixelTexGenParameteriSGIS (will be remapped) */ + "ii\0" + "glPixelTexGenParameteriSGIS\0" + "\0" + /* _mesa_function_pool[13517]: VertexPointervINTEL (dynamic) */ + "iip\0" + "glVertexPointervINTEL\0" + "\0" + /* _mesa_function_pool[13544]: Vertex2i (offset 130) */ + "ii\0" + "glVertex2i\0" + "\0" + /* _mesa_function_pool[13559]: LoadMatrixf (offset 291) */ + "p\0" + "glLoadMatrixf\0" + "\0" + /* _mesa_function_pool[13576]: VertexAttribI1uivEXT (will be remapped) */ + "ip\0" + "glVertexAttribI1uivEXT\0" + "glVertexAttribI1uiv\0" + "\0" + /* _mesa_function_pool[13623]: Vertex2f (offset 128) */ + "ff\0" + "glVertex2f\0" + "\0" + /* _mesa_function_pool[13638]: ReplacementCodeuiColor4fNormal3fVertex3fvSUN (dynamic) */ + "pppp\0" + "glReplacementCodeuiColor4fNormal3fVertex3fvSUN\0" + "\0" + /* _mesa_function_pool[13691]: Color4bv (offset 26) */ + "p\0" + "glColor4bv\0" + "\0" + /* _mesa_function_pool[13705]: VertexPointer (offset 321) */ + "iiip\0" + "glVertexPointer\0" + "\0" + /* _mesa_function_pool[13727]: SecondaryColor3uiEXT (will be remapped) */ + "iii\0" + "glSecondaryColor3ui\0" + "glSecondaryColor3uiEXT\0" + "\0" + /* _mesa_function_pool[13775]: StartInstrumentsSGIX (dynamic) */ + "\0" + "glStartInstrumentsSGIX\0" + "\0" + /* _mesa_function_pool[13800]: SecondaryColor3usvEXT (will be remapped) */ + "p\0" + "glSecondaryColor3usv\0" + "glSecondaryColor3usvEXT\0" + "\0" + /* _mesa_function_pool[13848]: VertexAttrib2fvNV (will be remapped) */ + "ip\0" + "glVertexAttrib2fvNV\0" + "\0" + /* _mesa_function_pool[13872]: ProgramLocalParameter4dvARB (will be remapped) */ + "iip\0" + "glProgramLocalParameter4dvARB\0" + "\0" + /* _mesa_function_pool[13907]: DeleteLists (offset 4) */ + "ii\0" + "glDeleteLists\0" + "\0" + /* _mesa_function_pool[13925]: LogicOp (offset 242) */ + "i\0" + "glLogicOp\0" + "\0" + /* _mesa_function_pool[13938]: MatrixIndexuivARB (dynamic) */ + "ip\0" + "glMatrixIndexuivARB\0" + "\0" + /* _mesa_function_pool[13962]: Vertex2s (offset 132) */ + "ii\0" + "glVertex2s\0" + "\0" + /* _mesa_function_pool[13977]: RenderbufferStorageMultisample (will be remapped) */ + "iiiii\0" + "glRenderbufferStorageMultisample\0" + "glRenderbufferStorageMultisampleEXT\0" + "\0" + /* _mesa_function_pool[14053]: TexCoord4fv (offset 121) */ + "p\0" + "glTexCoord4fv\0" + "\0" + /* _mesa_function_pool[14070]: Tangent3sEXT (dynamic) */ + "iii\0" + "glTangent3sEXT\0" + "\0" + /* _mesa_function_pool[14090]: GlobalAlphaFactorfSUN (dynamic) */ + "f\0" + "glGlobalAlphaFactorfSUN\0" + "\0" + /* _mesa_function_pool[14117]: MultiTexCoord3iARB (offset 396) */ + "iiii\0" + "glMultiTexCoord3i\0" + "glMultiTexCoord3iARB\0" + "\0" + /* _mesa_function_pool[14162]: IsProgram (will be remapped) */ + "i\0" + "glIsProgram\0" + "\0" + /* _mesa_function_pool[14177]: TexCoordPointerListIBM (dynamic) */ + "iiipi\0" + "glTexCoordPointerListIBM\0" + "\0" + /* _mesa_function_pool[14209]: VertexAttribI4svEXT (will be remapped) */ + "ip\0" + "glVertexAttribI4svEXT\0" + "glVertexAttribI4sv\0" + "\0" + /* _mesa_function_pool[14254]: GlobalAlphaFactorusSUN (dynamic) */ + "i\0" + "glGlobalAlphaFactorusSUN\0" + "\0" + /* _mesa_function_pool[14282]: VertexAttrib2dvNV (will be remapped) */ + "ip\0" + "glVertexAttrib2dvNV\0" + "\0" + /* _mesa_function_pool[14306]: FramebufferRenderbufferEXT (will be remapped) */ + "iiii\0" + "glFramebufferRenderbuffer\0" + "glFramebufferRenderbufferEXT\0" + "\0" + /* _mesa_function_pool[14367]: ClearBufferuiv (will be remapped) */ + "iip\0" + "glClearBufferuiv\0" + "\0" + /* _mesa_function_pool[14389]: VertexAttrib1dvNV (will be remapped) */ + "ip\0" + "glVertexAttrib1dvNV\0" + "\0" + /* _mesa_function_pool[14413]: GenTextures (offset 328) */ + "ip\0" + "glGenTextures\0" + "glGenTexturesEXT\0" + "\0" + /* _mesa_function_pool[14448]: FramebufferTextureARB (will be remapped) */ + "iiii\0" + "glFramebufferTextureARB\0" + "\0" + /* _mesa_function_pool[14478]: SetFenceNV (will be remapped) */ + "ii\0" + "glSetFenceNV\0" + "\0" + /* _mesa_function_pool[14495]: FramebufferTexture1DEXT (will be remapped) */ + "iiiii\0" + "glFramebufferTexture1D\0" + "glFramebufferTexture1DEXT\0" + "\0" + /* _mesa_function_pool[14551]: GetCombinerOutputParameterivNV (will be remapped) */ + "iiip\0" + "glGetCombinerOutputParameterivNV\0" + "\0" + /* _mesa_function_pool[14590]: PixelTexGenParameterivSGIS (will be remapped) */ + "ip\0" + "glPixelTexGenParameterivSGIS\0" + "\0" + /* _mesa_function_pool[14623]: TextureNormalEXT (dynamic) */ + "i\0" + "glTextureNormalEXT\0" + "\0" + /* _mesa_function_pool[14645]: IndexPointerListIBM (dynamic) */ + "iipi\0" + "glIndexPointerListIBM\0" + "\0" + /* _mesa_function_pool[14673]: WeightfvARB (dynamic) */ + "ip\0" + "glWeightfvARB\0" + "\0" + /* _mesa_function_pool[14691]: MultiTexCoordP3ui (will be remapped) */ + "iii\0" + "glMultiTexCoordP3ui\0" + "\0" + /* _mesa_function_pool[14716]: RasterPos2sv (offset 69) */ + "p\0" + "glRasterPos2sv\0" + "\0" + /* _mesa_function_pool[14734]: Color4ubv (offset 36) */ + "p\0" + "glColor4ubv\0" + "\0" + /* _mesa_function_pool[14749]: DrawBuffer (offset 202) */ + "i\0" + "glDrawBuffer\0" + "\0" + /* _mesa_function_pool[14765]: TexCoord2fv (offset 105) */ + "p\0" + "glTexCoord2fv\0" + "\0" + /* _mesa_function_pool[14782]: WindowPos4fMESA (will be remapped) */ + "ffff\0" + "glWindowPos4fMESA\0" + "\0" + /* _mesa_function_pool[14806]: TexCoord1sv (offset 101) */ + "p\0" + "glTexCoord1sv\0" + "\0" + /* _mesa_function_pool[14823]: WindowPos3dvMESA (will be remapped) */ + "p\0" + "glWindowPos3dv\0" + "glWindowPos3dvARB\0" + "glWindowPos3dvMESA\0" + "\0" + /* _mesa_function_pool[14878]: VertexAttribP1uiv (will be remapped) */ + "iiip\0" + "glVertexAttribP1uiv\0" + "\0" + /* _mesa_function_pool[14904]: VertexAttribP4ui (will be remapped) */ + "iiii\0" + "glVertexAttribP4ui\0" + "\0" + /* _mesa_function_pool[14929]: DepthFunc (offset 245) */ + "i\0" + "glDepthFunc\0" + "\0" + /* _mesa_function_pool[14944]: PixelMapusv (offset 253) */ + "iip\0" + "glPixelMapusv\0" + "\0" + /* _mesa_function_pool[14963]: GetQueryObjecti64vEXT (will be remapped) */ + "iip\0" + "glGetQueryObjecti64vEXT\0" + "\0" + /* _mesa_function_pool[14992]: MultiTexCoord1dARB (offset 376) */ + "id\0" + "glMultiTexCoord1d\0" + "glMultiTexCoord1dARB\0" + "\0" + /* _mesa_function_pool[15035]: PointParameterivNV (will be remapped) */ + "ip\0" + "glPointParameteriv\0" + "glPointParameterivNV\0" + "\0" + /* _mesa_function_pool[15079]: IsSampler (will be remapped) */ + "i\0" + "glIsSampler\0" + "\0" + /* _mesa_function_pool[15094]: BlendFunc (offset 241) */ + "ii\0" + "glBlendFunc\0" + "\0" + /* _mesa_function_pool[15110]: EndTransformFeedbackEXT (will be remapped) */ + "\0" + "glEndTransformFeedbackEXT\0" + "glEndTransformFeedback\0" + "\0" + /* _mesa_function_pool[15161]: Uniform2fvARB (will be remapped) */ + "iip\0" + "glUniform2fv\0" + "glUniform2fvARB\0" + "\0" + /* _mesa_function_pool[15195]: BufferParameteriAPPLE (will be remapped) */ + "iii\0" + "glBufferParameteriAPPLE\0" + "\0" + /* _mesa_function_pool[15224]: MultiTexCoord3dvARB (offset 393) */ + "ip\0" + "glMultiTexCoord3dv\0" + "glMultiTexCoord3dvARB\0" + "\0" + /* _mesa_function_pool[15269]: ReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN (dynamic) */ + "pppp\0" + "glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN\0" + "\0" + /* _mesa_function_pool[15325]: DeleteObjectARB (will be remapped) */ + "i\0" + "glDeleteObjectARB\0" + "\0" + /* _mesa_function_pool[15346]: GetShaderPrecisionFormat (will be remapped) */ + "iipp\0" + "glGetShaderPrecisionFormat\0" + "\0" + /* _mesa_function_pool[15379]: MatrixIndexPointerARB (dynamic) */ + "iiip\0" + "glMatrixIndexPointerARB\0" + "\0" + /* _mesa_function_pool[15409]: ProgramNamedParameter4dvNV (will be remapped) */ + "iipp\0" + "glProgramNamedParameter4dvNV\0" + "\0" + /* _mesa_function_pool[15444]: Tangent3fvEXT (dynamic) */ + "p\0" + "glTangent3fvEXT\0" + "\0" + /* _mesa_function_pool[15463]: Flush (offset 217) */ + "\0" + "glFlush\0" + "\0" + /* _mesa_function_pool[15473]: Color4uiv (offset 38) */ + "p\0" + "glColor4uiv\0" + "\0" + /* _mesa_function_pool[15488]: VertexAttribI4iEXT (will be remapped) */ + "iiiii\0" + "glVertexAttribI4iEXT\0" + "glVertexAttribI4i\0" + "\0" + /* _mesa_function_pool[15534]: GenVertexArrays (will be remapped) */ + "ip\0" + "glGenVertexArrays\0" + "\0" + /* _mesa_function_pool[15556]: Uniform3uivEXT (will be remapped) */ + "iip\0" + "glUniform3uivEXT\0" + "glUniform3uiv\0" + "\0" + /* _mesa_function_pool[15592]: RasterPos3sv (offset 77) */ + "p\0" + "glRasterPos3sv\0" + "\0" + /* _mesa_function_pool[15610]: TexCoordP2ui (will be remapped) */ + "ii\0" + "glTexCoordP2ui\0" + "\0" + /* _mesa_function_pool[15629]: BindFramebufferEXT (will be remapped) */ + "ii\0" + "glBindFramebuffer\0" + "glBindFramebufferEXT\0" + "\0" + /* _mesa_function_pool[15672]: ReferencePlaneSGIX (dynamic) */ + "p\0" + "glReferencePlaneSGIX\0" + "\0" + /* _mesa_function_pool[15696]: PushAttrib (offset 219) */ + "i\0" + "glPushAttrib\0" + "\0" + /* _mesa_function_pool[15712]: RasterPos2i (offset 66) */ + "ii\0" + "glRasterPos2i\0" + "\0" + /* _mesa_function_pool[15730]: ValidateProgramARB (will be remapped) */ + "i\0" + "glValidateProgram\0" + "glValidateProgramARB\0" + "\0" + /* _mesa_function_pool[15772]: TexParameteriv (offset 181) */ + "iip\0" + "glTexParameteriv\0" + "\0" + /* _mesa_function_pool[15794]: UnlockArraysEXT (will be remapped) */ + "\0" + "glUnlockArraysEXT\0" + "\0" + /* _mesa_function_pool[15814]: TexCoord2fColor3fVertex3fSUN (dynamic) */ + "ffffffff\0" + "glTexCoord2fColor3fVertex3fSUN\0" + "\0" + /* _mesa_function_pool[15855]: WindowPos3fvMESA (will be remapped) */ + "p\0" + "glWindowPos3fv\0" + "glWindowPos3fvARB\0" + "glWindowPos3fvMESA\0" + "\0" + /* _mesa_function_pool[15910]: RasterPos2f (offset 64) */ + "ff\0" + "glRasterPos2f\0" + "\0" + /* _mesa_function_pool[15928]: VertexAttrib1svNV (will be remapped) */ + "ip\0" + "glVertexAttrib1svNV\0" + "\0" + /* _mesa_function_pool[15952]: RasterPos2d (offset 62) */ + "dd\0" + "glRasterPos2d\0" + "\0" + /* _mesa_function_pool[15970]: RasterPos3fv (offset 73) */ + "p\0" + "glRasterPos3fv\0" + "\0" + /* _mesa_function_pool[15988]: CopyTexSubImage3D (offset 373) */ + "iiiiiiiii\0" + "glCopyTexSubImage3D\0" + "glCopyTexSubImage3DEXT\0" + "\0" + /* _mesa_function_pool[16042]: VertexAttrib2dARB (will be remapped) */ + "idd\0" + "glVertexAttrib2d\0" + "glVertexAttrib2dARB\0" + "\0" + /* _mesa_function_pool[16084]: Color4ub (offset 35) */ + "iiii\0" + "glColor4ub\0" + "\0" + /* _mesa_function_pool[16101]: GetInteger64v (will be remapped) */ + "ip\0" + "glGetInteger64v\0" + "\0" + /* _mesa_function_pool[16121]: TextureColorMaskSGIS (dynamic) */ + "iiii\0" + "glTextureColorMaskSGIS\0" + "\0" + /* _mesa_function_pool[16150]: RasterPos2s (offset 68) */ + "ii\0" + "glRasterPos2s\0" + "\0" + /* _mesa_function_pool[16168]: GetColorTable (offset 343) */ + "iiip\0" + "glGetColorTable\0" + "glGetColorTableSGI\0" + "glGetColorTableEXT\0" + "\0" + /* _mesa_function_pool[16228]: SelectBuffer (offset 195) */ + "ip\0" + "glSelectBuffer\0" + "\0" + /* _mesa_function_pool[16247]: Indexiv (offset 49) */ + "p\0" + "glIndexiv\0" + "\0" + /* _mesa_function_pool[16260]: TexCoord3i (offset 114) */ + "iii\0" + "glTexCoord3i\0" + "\0" + /* _mesa_function_pool[16278]: CopyColorTable (offset 342) */ + "iiiii\0" + "glCopyColorTable\0" + "glCopyColorTableSGI\0" + "\0" + /* _mesa_function_pool[16322]: GetHistogramParameterfv (offset 362) */ + "iip\0" + "glGetHistogramParameterfv\0" + "glGetHistogramParameterfvEXT\0" + "\0" + /* _mesa_function_pool[16382]: Frustum (offset 289) */ + "dddddd\0" + "glFrustum\0" + "\0" + /* _mesa_function_pool[16400]: GetString (offset 275) */ + "i\0" + "glGetString\0" + "\0" + /* _mesa_function_pool[16415]: ColorPointervINTEL (dynamic) */ + "iip\0" + "glColorPointervINTEL\0" + "\0" + /* _mesa_function_pool[16441]: TexEnvf (offset 184) */ + "iif\0" + "glTexEnvf\0" + "\0" + /* _mesa_function_pool[16456]: VertexP2uiv (will be remapped) */ + "ip\0" + "glVertexP2uiv\0" + "\0" + /* _mesa_function_pool[16474]: TexCoord3d (offset 110) */ + "ddd\0" + "glTexCoord3d\0" + "\0" + /* _mesa_function_pool[16492]: AlphaFragmentOp1ATI (will be remapped) */ + "iiiiii\0" + "glAlphaFragmentOp1ATI\0" + "\0" + /* _mesa_function_pool[16522]: TexCoord3f (offset 112) */ + "fff\0" + "glTexCoord3f\0" + "\0" + /* _mesa_function_pool[16540]: MultiTexCoord3ivARB (offset 397) */ + "ip\0" + "glMultiTexCoord3iv\0" + "glMultiTexCoord3ivARB\0" + "\0" + /* _mesa_function_pool[16585]: MultiTexCoord2sARB (offset 390) */ + "iii\0" + "glMultiTexCoord2s\0" + "glMultiTexCoord2sARB\0" + "\0" + /* _mesa_function_pool[16629]: VertexAttrib1dvARB (will be remapped) */ + "ip\0" + "glVertexAttrib1dv\0" + "glVertexAttrib1dvARB\0" + "\0" + /* _mesa_function_pool[16672]: GetnHistogramARB (will be remapped) */ + "iiiiip\0" + "glGetnHistogramARB\0" + "\0" + /* _mesa_function_pool[16699]: DeleteTextures (offset 327) */ + "ip\0" + "glDeleteTextures\0" + "glDeleteTexturesEXT\0" + "\0" + /* _mesa_function_pool[16740]: TexCoordPointerEXT (will be remapped) */ + "iiiip\0" + "glTexCoordPointerEXT\0" + "\0" + /* _mesa_function_pool[16768]: TexSubImage4DSGIS (dynamic) */ + "iiiiiiiiiiiip\0" + "glTexSubImage4DSGIS\0" + "\0" + /* _mesa_function_pool[16803]: TexCoord3s (offset 116) */ + "iii\0" + "glTexCoord3s\0" + "\0" + /* _mesa_function_pool[16821]: GetTexLevelParameteriv (offset 285) */ + "iiip\0" + "glGetTexLevelParameteriv\0" + "\0" + /* _mesa_function_pool[16852]: CombinerStageParameterfvNV (dynamic) */ + "iip\0" + "glCombinerStageParameterfvNV\0" + "\0" + /* _mesa_function_pool[16886]: VertexAttribP4uiv (will be remapped) */ + "iiip\0" + "glVertexAttribP4uiv\0" + "\0" + /* _mesa_function_pool[16912]: StopInstrumentsSGIX (dynamic) */ + "i\0" + "glStopInstrumentsSGIX\0" + "\0" + /* _mesa_function_pool[16937]: TexCoord4fColor4fNormal3fVertex4fSUN (dynamic) */ + "fffffffffffffff\0" + "glTexCoord4fColor4fNormal3fVertex4fSUN\0" + "\0" + /* _mesa_function_pool[16993]: ClearAccum (offset 204) */ + "ffff\0" + "glClearAccum\0" + "\0" + /* _mesa_function_pool[17012]: DeformSGIX (dynamic) */ + "i\0" + "glDeformSGIX\0" + "\0" + /* _mesa_function_pool[17028]: GetVertexAttribfvARB (will be remapped) */ + "iip\0" + "glGetVertexAttribfv\0" + "glGetVertexAttribfvARB\0" + "\0" + /* _mesa_function_pool[17076]: SecondaryColor3ivEXT (will be remapped) */ + "p\0" + "glSecondaryColor3iv\0" + "glSecondaryColor3ivEXT\0" + "\0" + /* _mesa_function_pool[17122]: TexCoord4iv (offset 123) */ + "p\0" + "glTexCoord4iv\0" + "\0" + /* _mesa_function_pool[17139]: VertexAttribI4uiEXT (will be remapped) */ + "iiiii\0" + "glVertexAttribI4uiEXT\0" + "glVertexAttribI4ui\0" + "\0" + /* _mesa_function_pool[17187]: GetFragmentMaterialfvSGIX (dynamic) */ + "iip\0" + "glGetFragmentMaterialfvSGIX\0" + "\0" + /* _mesa_function_pool[17220]: UniformMatrix4x2fv (will be remapped) */ + "iiip\0" + "glUniformMatrix4x2fv\0" + "\0" + /* _mesa_function_pool[17247]: GetDetailTexFuncSGIS (dynamic) */ + "ip\0" + "glGetDetailTexFuncSGIS\0" + "\0" + /* _mesa_function_pool[17274]: GetCombinerStageParameterfvNV (dynamic) */ + "iip\0" + "glGetCombinerStageParameterfvNV\0" + "\0" + /* _mesa_function_pool[17311]: SamplerParameterIiv (will be remapped) */ + "iip\0" + "glSamplerParameterIiv\0" + "\0" + /* _mesa_function_pool[17338]: PolygonOffset (offset 319) */ + "ff\0" + "glPolygonOffset\0" + "\0" + /* _mesa_function_pool[17358]: BindVertexArray (will be remapped) */ + "i\0" + "glBindVertexArray\0" + "\0" + /* _mesa_function_pool[17379]: Color4ubVertex2fvSUN (dynamic) */ + "pp\0" + "glColor4ubVertex2fvSUN\0" + "\0" + /* _mesa_function_pool[17406]: VertexP3uiv (will be remapped) */ + "ip\0" + "glVertexP3uiv\0" + "\0" + /* _mesa_function_pool[17424]: Rectd (offset 86) */ + "dddd\0" + "glRectd\0" + "\0" + /* _mesa_function_pool[17438]: TexFilterFuncSGIS (dynamic) */ + "iiip\0" + "glTexFilterFuncSGIS\0" + "\0" + /* _mesa_function_pool[17464]: TextureBarrierNV (will be remapped) */ + "\0" + "glTextureBarrierNV\0" + "\0" + /* _mesa_function_pool[17485]: SamplerParameterfv (will be remapped) */ + "iip\0" + "glSamplerParameterfv\0" + "\0" + /* _mesa_function_pool[17511]: ColorMaskIndexedEXT (will be remapped) */ + "iiiii\0" + "glColorMaskIndexedEXT\0" + "glColorMaski\0" + "\0" + /* _mesa_function_pool[17553]: GetAttribLocationARB (will be remapped) */ + "ip\0" + "glGetAttribLocation\0" + "glGetAttribLocationARB\0" + "\0" + /* _mesa_function_pool[17600]: RasterPos3i (offset 74) */ + "iii\0" + "glRasterPos3i\0" + "\0" + /* _mesa_function_pool[17619]: VertexAttrib4ubvARB (will be remapped) */ + "ip\0" + "glVertexAttrib4ubv\0" + "glVertexAttrib4ubvARB\0" + "\0" + /* _mesa_function_pool[17664]: DetailTexFuncSGIS (dynamic) */ + "iip\0" + "glDetailTexFuncSGIS\0" + "\0" + /* _mesa_function_pool[17689]: Normal3fVertex3fSUN (dynamic) */ + "ffffff\0" + "glNormal3fVertex3fSUN\0" + "\0" + /* _mesa_function_pool[17719]: CopyTexImage2D (offset 324) */ + "iiiiiiii\0" + "glCopyTexImage2D\0" + "glCopyTexImage2DEXT\0" + "\0" + /* _mesa_function_pool[17766]: GetBufferPointervARB (will be remapped) */ + "iip\0" + "glGetBufferPointerv\0" + "glGetBufferPointervARB\0" + "\0" + /* _mesa_function_pool[17814]: ProgramEnvParameter4fARB (will be remapped) */ + "iiffff\0" + "glProgramEnvParameter4fARB\0" + "glProgramParameter4fNV\0" + "\0" + /* _mesa_function_pool[17872]: Uniform3ivARB (will be remapped) */ + "iip\0" + "glUniform3iv\0" + "glUniform3ivARB\0" + "\0" + /* _mesa_function_pool[17906]: Lightfv (offset 160) */ + "iip\0" + "glLightfv\0" + "\0" + /* _mesa_function_pool[17921]: PrimitiveRestartIndexNV (will be remapped) */ + "i\0" + "glPrimitiveRestartIndexNV\0" + "glPrimitiveRestartIndex\0" + "\0" + /* _mesa_function_pool[17974]: ClearDepth (offset 208) */ + "d\0" + "glClearDepth\0" + "\0" + /* _mesa_function_pool[17990]: GetFenceivNV (will be remapped) */ + "iip\0" + "glGetFenceivNV\0" + "\0" + /* _mesa_function_pool[18010]: WindowPos4dvMESA (will be remapped) */ + "p\0" + "glWindowPos4dvMESA\0" + "\0" + /* _mesa_function_pool[18032]: ColorSubTable (offset 346) */ + "iiiiip\0" + "glColorSubTable\0" + "glColorSubTableEXT\0" + "\0" + /* _mesa_function_pool[18075]: Color4fv (offset 30) */ + "p\0" + "glColor4fv\0" + "\0" + /* _mesa_function_pool[18089]: MultiTexCoord4ivARB (offset 405) */ + "ip\0" + "glMultiTexCoord4iv\0" + "glMultiTexCoord4ivARB\0" + "\0" + /* _mesa_function_pool[18134]: GetnMinmaxARB (will be remapped) */ + "iiiiip\0" + "glGetnMinmaxARB\0" + "\0" + /* _mesa_function_pool[18158]: ProgramLocalParameters4fvEXT (will be remapped) */ + "iiip\0" + "glProgramLocalParameters4fvEXT\0" + "\0" + /* _mesa_function_pool[18195]: ColorPointer (offset 308) */ + "iiip\0" + "glColorPointer\0" + "\0" + /* _mesa_function_pool[18216]: Rects (offset 92) */ + "iiii\0" + "glRects\0" + "\0" + /* _mesa_function_pool[18230]: GetMapAttribParameterfvNV (dynamic) */ + "iiip\0" + "glGetMapAttribParameterfvNV\0" + "\0" + /* _mesa_function_pool[18264]: CreateShaderProgramEXT (will be remapped) */ + "ip\0" + "glCreateShaderProgramEXT\0" + "\0" + /* _mesa_function_pool[18293]: ActiveProgramEXT (will be remapped) */ + "i\0" + "glActiveProgramEXT\0" + "\0" + /* _mesa_function_pool[18315]: Lightiv (offset 162) */ + "iip\0" + "glLightiv\0" + "\0" + /* _mesa_function_pool[18330]: VertexAttrib4sARB (will be remapped) */ + "iiiii\0" + "glVertexAttrib4s\0" + "glVertexAttrib4sARB\0" + "\0" + /* _mesa_function_pool[18374]: GetQueryObjectuivARB (will be remapped) */ + "iip\0" + "glGetQueryObjectuiv\0" + "glGetQueryObjectuivARB\0" + "\0" + /* _mesa_function_pool[18422]: GetTexParameteriv (offset 283) */ + "iip\0" + "glGetTexParameteriv\0" + "\0" + /* _mesa_function_pool[18447]: MapParameterivNV (dynamic) */ + "iip\0" + "glMapParameterivNV\0" + "\0" + /* _mesa_function_pool[18471]: GenRenderbuffersEXT (will be remapped) */ + "ip\0" + "glGenRenderbuffers\0" + "glGenRenderbuffersEXT\0" + "\0" + /* _mesa_function_pool[18516]: ClearBufferfv (will be remapped) */ + "iip\0" + "glClearBufferfv\0" + "\0" + /* _mesa_function_pool[18537]: VertexAttrib2dvARB (will be remapped) */ + "ip\0" + "glVertexAttrib2dv\0" + "glVertexAttrib2dvARB\0" + "\0" + /* _mesa_function_pool[18580]: EdgeFlagPointerEXT (will be remapped) */ + "iip\0" + "glEdgeFlagPointerEXT\0" + "\0" + /* _mesa_function_pool[18606]: VertexAttribs2svNV (will be remapped) */ + "iip\0" + "glVertexAttribs2svNV\0" + "\0" + /* _mesa_function_pool[18632]: WeightbvARB (dynamic) */ + "ip\0" + "glWeightbvARB\0" + "\0" + /* _mesa_function_pool[18650]: VertexAttrib2fvARB (will be remapped) */ + "ip\0" + "glVertexAttrib2fv\0" + "glVertexAttrib2fvARB\0" + "\0" + /* _mesa_function_pool[18693]: GetBufferParameterivARB (will be remapped) */ + "iip\0" + "glGetBufferParameteriv\0" + "glGetBufferParameterivARB\0" + "\0" + /* _mesa_function_pool[18747]: Rectdv (offset 87) */ + "pp\0" + "glRectdv\0" + "\0" + /* _mesa_function_pool[18760]: ListParameteriSGIX (dynamic) */ + "iii\0" + "glListParameteriSGIX\0" + "\0" + /* _mesa_function_pool[18786]: BlendEquationiARB (will be remapped) */ + "ii\0" + "glBlendEquationiARB\0" + "glBlendEquationIndexedAMD\0" + "\0" + /* _mesa_function_pool[18836]: ReplacementCodeuiColor4fNormal3fVertex3fSUN (dynamic) */ + "iffffffffff\0" + "glReplacementCodeuiColor4fNormal3fVertex3fSUN\0" + "\0" + /* _mesa_function_pool[18895]: InstrumentsBufferSGIX (dynamic) */ + "ip\0" + "glInstrumentsBufferSGIX\0" + "\0" + /* _mesa_function_pool[18923]: VertexAttrib4NivARB (will be remapped) */ + "ip\0" + "glVertexAttrib4Niv\0" + "glVertexAttrib4NivARB\0" + "\0" + /* _mesa_function_pool[18968]: DrawArraysInstancedARB (will be remapped) */ + "iiii\0" + "glDrawArraysInstancedARB\0" + "glDrawArraysInstancedEXT\0" + "glDrawArraysInstanced\0" + "\0" + /* _mesa_function_pool[19046]: GetAttachedShaders (will be remapped) */ + "iipp\0" + "glGetAttachedShaders\0" + "\0" + /* _mesa_function_pool[19073]: GenVertexArraysAPPLE (will be remapped) */ + "ip\0" + "glGenVertexArraysAPPLE\0" + "\0" + /* _mesa_function_pool[19100]: ClearBufferfi (will be remapped) */ + "iifi\0" + "glClearBufferfi\0" + "\0" + /* _mesa_function_pool[19122]: Materialiv (offset 172) */ + "iip\0" + "glMaterialiv\0" + "\0" + /* _mesa_function_pool[19140]: PushClientAttrib (offset 335) */ + "i\0" + "glPushClientAttrib\0" + "\0" + /* _mesa_function_pool[19162]: SamplerParameteriv (will be remapped) */ + "iip\0" + "glSamplerParameteriv\0" + "\0" + /* _mesa_function_pool[19188]: TexCoord2fColor4fNormal3fVertex3fvSUN (dynamic) */ + "pppp\0" + "glTexCoord2fColor4fNormal3fVertex3fvSUN\0" + "\0" + /* _mesa_function_pool[19234]: WindowPos2iMESA (will be remapped) */ + "ii\0" + "glWindowPos2i\0" + "glWindowPos2iARB\0" + "glWindowPos2iMESA\0" + "\0" + /* _mesa_function_pool[19287]: SampleMaskSGIS (will be remapped) */ + "fi\0" + "glSampleMaskSGIS\0" + "glSampleMaskEXT\0" + "\0" + /* _mesa_function_pool[19324]: SecondaryColor3fvEXT (will be remapped) */ + "p\0" + "glSecondaryColor3fv\0" + "glSecondaryColor3fvEXT\0" + "\0" + /* _mesa_function_pool[19370]: PolygonMode (offset 174) */ + "ii\0" + "glPolygonMode\0" + "\0" + /* _mesa_function_pool[19388]: CompressedTexSubImage1DARB (will be remapped) */ + "iiiiiip\0" + "glCompressedTexSubImage1D\0" + "glCompressedTexSubImage1DARB\0" + "\0" + /* _mesa_function_pool[19452]: VertexAttribI1iEXT (will be remapped) */ + "ii\0" + "glVertexAttribI1iEXT\0" + "glVertexAttribI1i\0" + "\0" + /* _mesa_function_pool[19495]: TexCoord2fNormal3fVertex3fSUN (dynamic) */ + "ffffffff\0" + "glTexCoord2fNormal3fVertex3fSUN\0" + "\0" + /* _mesa_function_pool[19537]: GetVertexAttribivNV (will be remapped) */ + "iip\0" + "glGetVertexAttribivNV\0" + "\0" + /* _mesa_function_pool[19564]: GetProgramStringARB (will be remapped) */ + "iip\0" + "glGetProgramStringARB\0" + "\0" + /* _mesa_function_pool[19591]: GetnUniformdvARB (will be remapped) */ + "iiip\0" + "glGetnUniformdvARB\0" + "\0" + /* _mesa_function_pool[19616]: DrawElementsInstancedBaseVertex (will be remapped) */ + "iiipii\0" + "glDrawElementsInstancedBaseVertex\0" + "\0" + /* _mesa_function_pool[19658]: VertexAttribIPointerEXT (will be remapped) */ + "iiiip\0" + "glVertexAttribIPointerEXT\0" + "glVertexAttribIPointer\0" + "\0" + /* _mesa_function_pool[19714]: TexBumpParameterfvATI (will be remapped) */ + "ip\0" + "glTexBumpParameterfvATI\0" + "\0" + /* _mesa_function_pool[19742]: Tangent3ivEXT (dynamic) */ + "p\0" + "glTangent3ivEXT\0" + "\0" + /* _mesa_function_pool[19761]: CompileShaderARB (will be remapped) */ + "i\0" + "glCompileShader\0" + "glCompileShaderARB\0" + "\0" + /* _mesa_function_pool[19799]: DeleteShader (will be remapped) */ + "i\0" + "glDeleteShader\0" + "\0" + /* _mesa_function_pool[19817]: DisableClientState (offset 309) */ + "i\0" + "glDisableClientState\0" + "\0" + /* _mesa_function_pool[19841]: TexGeni (offset 192) */ + "iii\0" + "glTexGeni\0" + "\0" + /* _mesa_function_pool[19856]: TexGenf (offset 190) */ + "iif\0" + "glTexGenf\0" + "\0" + /* _mesa_function_pool[19871]: Uniform3fARB (will be remapped) */ + "ifff\0" + "glUniform3f\0" + "glUniform3fARB\0" + "\0" + /* _mesa_function_pool[19904]: TexGend (offset 188) */ + "iid\0" + "glTexGend\0" + "\0" + /* _mesa_function_pool[19919]: ListParameterfvSGIX (dynamic) */ + "iip\0" + "glListParameterfvSGIX\0" + "\0" + /* _mesa_function_pool[19946]: GetPolygonStipple (offset 274) */ + "p\0" + "glGetPolygonStipple\0" + "\0" + /* _mesa_function_pool[19969]: ColorP3ui (will be remapped) */ + "ii\0" + "glColorP3ui\0" + "\0" + /* _mesa_function_pool[19985]: Tangent3dvEXT (dynamic) */ + "p\0" + "glTangent3dvEXT\0" + "\0" + /* _mesa_function_pool[20004]: BindBufferOffsetEXT (will be remapped) */ + "iiii\0" + "glBindBufferOffsetEXT\0" + "\0" + /* _mesa_function_pool[20032]: WindowPos3sMESA (will be remapped) */ + "iii\0" + "glWindowPos3s\0" + "glWindowPos3sARB\0" + "glWindowPos3sMESA\0" + "\0" + /* _mesa_function_pool[20086]: VertexAttrib2svNV (will be remapped) */ + "ip\0" + "glVertexAttrib2svNV\0" + "\0" + /* _mesa_function_pool[20110]: DisableIndexedEXT (will be remapped) */ + "ii\0" + "glDisableIndexedEXT\0" + "glDisablei\0" + "\0" + /* _mesa_function_pool[20145]: NormalP3uiv (will be remapped) */ + "ip\0" + "glNormalP3uiv\0" + "\0" + /* _mesa_function_pool[20163]: SecondaryColorP3uiv (will be remapped) */ + "ip\0" + "glSecondaryColorP3uiv\0" + "\0" + /* _mesa_function_pool[20189]: BindBufferBaseEXT (will be remapped) */ + "iii\0" + "glBindBufferBaseEXT\0" + "glBindBufferBase\0" + "\0" + /* _mesa_function_pool[20231]: TexCoord2fVertex3fvSUN (dynamic) */ + "pp\0" + "glTexCoord2fVertex3fvSUN\0" + "\0" + /* _mesa_function_pool[20260]: WindowPos4sMESA (will be remapped) */ + "iiii\0" + "glWindowPos4sMESA\0" + "\0" + /* _mesa_function_pool[20284]: GetnPixelMapuivARB (will be remapped) */ + "iip\0" + "glGetnPixelMapuivARB\0" + "\0" + /* _mesa_function_pool[20310]: VertexAttrib4NuivARB (will be remapped) */ + "ip\0" + "glVertexAttrib4Nuiv\0" + "glVertexAttrib4NuivARB\0" + "\0" + /* _mesa_function_pool[20357]: ClientActiveTextureARB (offset 375) */ + "i\0" + "glClientActiveTexture\0" + "glClientActiveTextureARB\0" + "\0" + /* _mesa_function_pool[20407]: GetSamplerParameterIuiv (will be remapped) */ + "iip\0" + "glGetSamplerParameterIuiv\0" + "\0" + /* _mesa_function_pool[20438]: ReplacementCodeusvSUN (dynamic) */ + "p\0" + "glReplacementCodeusvSUN\0" + "\0" + /* _mesa_function_pool[20465]: Uniform4fARB (will be remapped) */ + "iffff\0" + "glUniform4f\0" + "glUniform4fARB\0" + "\0" + /* _mesa_function_pool[20499]: Color4sv (offset 34) */ + "p\0" + "glColor4sv\0" + "\0" + /* _mesa_function_pool[20513]: FlushMappedBufferRange (will be remapped) */ + "iii\0" + "glFlushMappedBufferRange\0" + "\0" + /* _mesa_function_pool[20543]: IsProgramNV (will be remapped) */ + "i\0" + "glIsProgramARB\0" + "glIsProgramNV\0" + "\0" + /* _mesa_function_pool[20575]: FlushMappedBufferRangeAPPLE (will be remapped) */ + "iii\0" + "glFlushMappedBufferRangeAPPLE\0" + "\0" + /* _mesa_function_pool[20610]: PixelZoom (offset 246) */ + "ff\0" + "glPixelZoom\0" + "\0" + /* _mesa_function_pool[20626]: ReplacementCodePointerSUN (dynamic) */ + "iip\0" + "glReplacementCodePointerSUN\0" + "\0" + /* _mesa_function_pool[20659]: ProgramEnvParameter4dARB (will be remapped) */ + "iidddd\0" + "glProgramEnvParameter4dARB\0" + "glProgramParameter4dNV\0" + "\0" + /* _mesa_function_pool[20717]: ColorTableParameterfv (offset 340) */ + "iip\0" + "glColorTableParameterfv\0" + "glColorTableParameterfvSGI\0" + "\0" + /* _mesa_function_pool[20773]: FragmentLightModelfSGIX (dynamic) */ + "if\0" + "glFragmentLightModelfSGIX\0" + "\0" + /* _mesa_function_pool[20803]: Binormal3bvEXT (dynamic) */ + "p\0" + "glBinormal3bvEXT\0" + "\0" + /* _mesa_function_pool[20823]: PixelMapuiv (offset 252) */ + "iip\0" + "glPixelMapuiv\0" + "\0" + /* _mesa_function_pool[20842]: Color3dv (offset 12) */ + "p\0" + "glColor3dv\0" + "\0" + /* _mesa_function_pool[20856]: IsTexture (offset 330) */ + "i\0" + "glIsTexture\0" + "glIsTextureEXT\0" + "\0" + /* _mesa_function_pool[20886]: GenSamplers (will be remapped) */ + "ip\0" + "glGenSamplers\0" + "\0" + /* _mesa_function_pool[20904]: VertexAttribP3uiv (will be remapped) */ + "iiip\0" + "glVertexAttribP3uiv\0" + "\0" + /* _mesa_function_pool[20930]: VertexWeightfvEXT (dynamic) */ + "p\0" + "glVertexWeightfvEXT\0" + "\0" + /* _mesa_function_pool[20953]: VertexAttrib1dARB (will be remapped) */ + "id\0" + "glVertexAttrib1d\0" + "glVertexAttrib1dARB\0" + "\0" + /* _mesa_function_pool[20994]: ImageTransformParameterivHP (dynamic) */ + "iip\0" + "glImageTransformParameterivHP\0" + "\0" + /* _mesa_function_pool[21029]: TexCoord4i (offset 122) */ + "iiii\0" + "glTexCoord4i\0" + "\0" + /* _mesa_function_pool[21048]: DeleteQueriesARB (will be remapped) */ + "ip\0" + "glDeleteQueries\0" + "glDeleteQueriesARB\0" + "\0" + /* _mesa_function_pool[21087]: Color4ubVertex2fSUN (dynamic) */ + "iiiiff\0" + "glColor4ubVertex2fSUN\0" + "\0" + /* _mesa_function_pool[21117]: FragmentColorMaterialSGIX (dynamic) */ + "ii\0" + "glFragmentColorMaterialSGIX\0" + "\0" + /* _mesa_function_pool[21149]: CurrentPaletteMatrixARB (dynamic) */ + "i\0" + "glCurrentPaletteMatrixARB\0" + "\0" + /* _mesa_function_pool[21178]: GetMapdv (offset 266) */ + "iip\0" + "glGetMapdv\0" + "\0" + /* _mesa_function_pool[21194]: ObjectPurgeableAPPLE (will be remapped) */ + "iii\0" + "glObjectPurgeableAPPLE\0" + "\0" + /* _mesa_function_pool[21222]: GetStringi (will be remapped) */ + "ii\0" + "glGetStringi\0" + "\0" + /* _mesa_function_pool[21239]: SamplePatternSGIS (will be remapped) */ + "i\0" + "glSamplePatternSGIS\0" + "glSamplePatternEXT\0" + "\0" + /* _mesa_function_pool[21281]: PixelStoref (offset 249) */ + "if\0" + "glPixelStoref\0" + "\0" + /* _mesa_function_pool[21299]: IsQueryARB (will be remapped) */ + "i\0" + "glIsQuery\0" + "glIsQueryARB\0" + "\0" + /* _mesa_function_pool[21325]: ReplacementCodeuiColor4ubVertex3fSUN (dynamic) */ + "iiiiifff\0" + "glReplacementCodeuiColor4ubVertex3fSUN\0" + "\0" + /* _mesa_function_pool[21374]: PixelStorei (offset 250) */ + "ii\0" + "glPixelStorei\0" + "\0" + /* _mesa_function_pool[21392]: VertexAttrib4usvARB (will be remapped) */ + "ip\0" + "glVertexAttrib4usv\0" + "glVertexAttrib4usvARB\0" + "\0" + /* _mesa_function_pool[21437]: LinkProgramARB (will be remapped) */ + "i\0" + "glLinkProgram\0" + "glLinkProgramARB\0" + "\0" + /* _mesa_function_pool[21471]: VertexAttrib2fNV (will be remapped) */ + "iff\0" + "glVertexAttrib2fNV\0" + "\0" + /* _mesa_function_pool[21495]: ShaderSourceARB (will be remapped) */ + "iipp\0" + "glShaderSource\0" + "glShaderSourceARB\0" + "\0" + /* _mesa_function_pool[21534]: FragmentMaterialiSGIX (dynamic) */ + "iii\0" + "glFragmentMaterialiSGIX\0" + "\0" + /* _mesa_function_pool[21563]: EvalCoord2dv (offset 233) */ + "p\0" + "glEvalCoord2dv\0" + "\0" + /* _mesa_function_pool[21581]: VertexAttrib3svARB (will be remapped) */ + "ip\0" + "glVertexAttrib3sv\0" + "glVertexAttrib3svARB\0" + "\0" + /* _mesa_function_pool[21624]: ColorMaterial (offset 151) */ + "ii\0" + "glColorMaterial\0" + "\0" + /* _mesa_function_pool[21644]: CompressedTexSubImage3DARB (will be remapped) */ + "iiiiiiiiiip\0" + "glCompressedTexSubImage3D\0" + "glCompressedTexSubImage3DARB\0" + "\0" + /* _mesa_function_pool[21712]: WindowPos2ivMESA (will be remapped) */ + "p\0" + "glWindowPos2iv\0" + "glWindowPos2ivARB\0" + "glWindowPos2ivMESA\0" + "\0" + /* _mesa_function_pool[21767]: IsFramebufferEXT (will be remapped) */ + "i\0" + "glIsFramebuffer\0" + "glIsFramebufferEXT\0" + "\0" + /* _mesa_function_pool[21805]: Uniform4ivARB (will be remapped) */ + "iip\0" + "glUniform4iv\0" + "glUniform4ivARB\0" + "\0" + /* _mesa_function_pool[21839]: GetVertexAttribdvARB (will be remapped) */ + "iip\0" + "glGetVertexAttribdv\0" + "glGetVertexAttribdvARB\0" + "\0" + /* _mesa_function_pool[21887]: TexBumpParameterivATI (will be remapped) */ + "ip\0" + "glTexBumpParameterivATI\0" + "\0" + /* _mesa_function_pool[21915]: GetSeparableFilter (offset 359) */ + "iiippp\0" + "glGetSeparableFilter\0" + "glGetSeparableFilterEXT\0" + "\0" + /* _mesa_function_pool[21968]: Binormal3dEXT (dynamic) */ + "ddd\0" + "glBinormal3dEXT\0" + "\0" + /* _mesa_function_pool[21989]: SpriteParameteriSGIX (dynamic) */ + "ii\0" + "glSpriteParameteriSGIX\0" + "\0" + /* _mesa_function_pool[22016]: RequestResidentProgramsNV (will be remapped) */ + "ip\0" + "glRequestResidentProgramsNV\0" + "\0" + /* _mesa_function_pool[22048]: TagSampleBufferSGIX (dynamic) */ + "\0" + "glTagSampleBufferSGIX\0" + "\0" + /* _mesa_function_pool[22072]: TransformFeedbackVaryingsEXT (will be remapped) */ + "iipi\0" + "glTransformFeedbackVaryingsEXT\0" + "glTransformFeedbackVaryings\0" + "\0" + /* _mesa_function_pool[22137]: FeedbackBuffer (offset 194) */ + "iip\0" + "glFeedbackBuffer\0" + "\0" + /* _mesa_function_pool[22159]: RasterPos2iv (offset 67) */ + "p\0" + "glRasterPos2iv\0" + "\0" + /* _mesa_function_pool[22177]: TexImage1D (offset 182) */ + "iiiiiiip\0" + "glTexImage1D\0" + "\0" + /* _mesa_function_pool[22200]: ListParameterivSGIX (dynamic) */ + "iip\0" + "glListParameterivSGIX\0" + "\0" + /* _mesa_function_pool[22227]: MultiDrawElementsEXT (will be remapped) */ + "ipipi\0" + "glMultiDrawElements\0" + "glMultiDrawElementsEXT\0" + "\0" + /* _mesa_function_pool[22277]: Color3s (offset 17) */ + "iii\0" + "glColor3s\0" + "\0" + /* _mesa_function_pool[22292]: Uniform1ivARB (will be remapped) */ + "iip\0" + "glUniform1iv\0" + "glUniform1ivARB\0" + "\0" + /* _mesa_function_pool[22326]: WindowPos2sMESA (will be remapped) */ + "ii\0" + "glWindowPos2s\0" + "glWindowPos2sARB\0" + "glWindowPos2sMESA\0" + "\0" + /* _mesa_function_pool[22379]: WeightusvARB (dynamic) */ + "ip\0" + "glWeightusvARB\0" + "\0" + /* _mesa_function_pool[22398]: ColorP4ui (will be remapped) */ + "ii\0" + "glColorP4ui\0" + "\0" + /* _mesa_function_pool[22414]: TexCoordPointer (offset 320) */ + "iiip\0" + "glTexCoordPointer\0" + "\0" + /* _mesa_function_pool[22438]: FogCoordPointerEXT (will be remapped) */ + "iip\0" + "glFogCoordPointer\0" + "glFogCoordPointerEXT\0" + "\0" + /* _mesa_function_pool[22482]: GetnSeparableFilterARB (will be remapped) */ + "iiiipipp\0" + "glGetnSeparableFilterARB\0" + "\0" + /* _mesa_function_pool[22517]: IndexMaterialEXT (dynamic) */ + "ii\0" + "glIndexMaterialEXT\0" + "\0" + /* _mesa_function_pool[22540]: Color3i (offset 15) */ + "iii\0" + "glColor3i\0" + "\0" + /* _mesa_function_pool[22555]: FrontFace (offset 157) */ + "i\0" + "glFrontFace\0" + "\0" + /* _mesa_function_pool[22570]: EvalCoord2d (offset 232) */ + "dd\0" + "glEvalCoord2d\0" + "\0" + /* _mesa_function_pool[22588]: SecondaryColor3ubvEXT (will be remapped) */ + "p\0" + "glSecondaryColor3ubv\0" + "glSecondaryColor3ubvEXT\0" + "\0" + /* _mesa_function_pool[22636]: EvalCoord2f (offset 234) */ + "ff\0" + "glEvalCoord2f\0" + "\0" + /* _mesa_function_pool[22654]: VertexAttrib4dvARB (will be remapped) */ + "ip\0" + "glVertexAttrib4dv\0" + "glVertexAttrib4dvARB\0" + "\0" + /* _mesa_function_pool[22697]: BindAttribLocationARB (will be remapped) */ + "iip\0" + "glBindAttribLocation\0" + "glBindAttribLocationARB\0" + "\0" + /* _mesa_function_pool[22747]: Color3b (offset 9) */ + "iii\0" + "glColor3b\0" + "\0" + /* _mesa_function_pool[22762]: MultiTexCoord2dARB (offset 384) */ + "idd\0" + "glMultiTexCoord2d\0" + "glMultiTexCoord2dARB\0" + "\0" + /* _mesa_function_pool[22806]: ExecuteProgramNV (will be remapped) */ + "iip\0" + "glExecuteProgramNV\0" + "\0" + /* _mesa_function_pool[22830]: Color3f (offset 13) */ + "fff\0" + "glColor3f\0" + "\0" + /* _mesa_function_pool[22845]: LightEnviSGIX (dynamic) */ + "ii\0" + "glLightEnviSGIX\0" + "\0" + /* _mesa_function_pool[22865]: Color3d (offset 11) */ + "ddd\0" + "glColor3d\0" + "\0" + /* _mesa_function_pool[22880]: Normal3dv (offset 55) */ + "p\0" + "glNormal3dv\0" + "\0" + /* _mesa_function_pool[22895]: Lightf (offset 159) */ + "iif\0" + "glLightf\0" + "\0" + /* _mesa_function_pool[22909]: ReplacementCodeuiSUN (dynamic) */ + "i\0" + "glReplacementCodeuiSUN\0" + "\0" + /* _mesa_function_pool[22935]: MatrixMode (offset 293) */ + "i\0" + "glMatrixMode\0" + "\0" + /* _mesa_function_pool[22951]: GetPixelMapusv (offset 273) */ + "ip\0" + "glGetPixelMapusv\0" + "\0" + /* _mesa_function_pool[22972]: Lighti (offset 161) */ + "iii\0" + "glLighti\0" + "\0" + /* _mesa_function_pool[22986]: VertexAttribPointerNV (will be remapped) */ + "iiiip\0" + "glVertexAttribPointerNV\0" + "\0" + /* _mesa_function_pool[23017]: ClearDepthf (will be remapped) */ + "f\0" + "glClearDepthf\0" + "\0" + /* _mesa_function_pool[23034]: GetBooleanIndexedvEXT (will be remapped) */ + "iip\0" + "glGetBooleanIndexedvEXT\0" + "glGetBooleani_v\0" + "\0" + /* _mesa_function_pool[23079]: GetFramebufferAttachmentParameterivEXT (will be remapped) */ + "iiip\0" + "glGetFramebufferAttachmentParameteriv\0" + "glGetFramebufferAttachmentParameterivEXT\0" + "\0" + /* _mesa_function_pool[23164]: PixelTransformParameterfEXT (dynamic) */ + "iif\0" + "glPixelTransformParameterfEXT\0" + "\0" + /* _mesa_function_pool[23199]: MultiTexCoord4dvARB (offset 401) */ + "ip\0" + "glMultiTexCoord4dv\0" + "glMultiTexCoord4dvARB\0" + "\0" + /* _mesa_function_pool[23244]: PixelTransformParameteriEXT (dynamic) */ + "iii\0" + "glPixelTransformParameteriEXT\0" + "\0" + /* _mesa_function_pool[23279]: GetDoublev (offset 260) */ + "ip\0" + "glGetDoublev\0" + "\0" + /* _mesa_function_pool[23296]: MultiTexCoordP4ui (will be remapped) */ + "iii\0" + "glMultiTexCoordP4ui\0" + "\0" + /* _mesa_function_pool[23321]: TexCoordP2uiv (will be remapped) */ + "ip\0" + "glTexCoordP2uiv\0" + "\0" + /* _mesa_function_pool[23341]: MultMatrixd (offset 295) */ + "p\0" + "glMultMatrixd\0" + "\0" + /* _mesa_function_pool[23358]: MultMatrixf (offset 294) */ + "p\0" + "glMultMatrixf\0" + "\0" + /* _mesa_function_pool[23375]: VertexAttribI4bvEXT (will be remapped) */ + "ip\0" + "glVertexAttribI4bvEXT\0" + "glVertexAttribI4bv\0" + "\0" + /* _mesa_function_pool[23420]: TexCoord2fColor4ubVertex3fSUN (dynamic) */ + "ffiiiifff\0" + "glTexCoord2fColor4ubVertex3fSUN\0" + "\0" + /* _mesa_function_pool[23463]: Uniform1iARB (will be remapped) */ + "ii\0" + "glUniform1i\0" + "glUniform1iARB\0" + "\0" + /* _mesa_function_pool[23494]: GetnMapfvARB (will be remapped) */ + "iiip\0" + "glGetnMapfvARB\0" + "\0" + /* _mesa_function_pool[23515]: VertexAttribPointerARB (will be remapped) */ + "iiiiip\0" + "glVertexAttribPointer\0" + "glVertexAttribPointerARB\0" + "\0" + /* _mesa_function_pool[23570]: VertexAttrib3sNV (will be remapped) */ + "iiii\0" + "glVertexAttrib3sNV\0" + "\0" + /* _mesa_function_pool[23595]: SharpenTexFuncSGIS (dynamic) */ + "iip\0" + "glSharpenTexFuncSGIS\0" + "\0" + /* _mesa_function_pool[23621]: MultiTexCoord4fvARB (offset 403) */ + "ip\0" + "glMultiTexCoord4fv\0" + "glMultiTexCoord4fvARB\0" + "\0" + /* _mesa_function_pool[23666]: Uniform2uiEXT (will be remapped) */ + "iii\0" + "glUniform2uiEXT\0" + "glUniform2ui\0" + "\0" + /* _mesa_function_pool[23700]: TexCoordP3uiv (will be remapped) */ + "ip\0" + "glTexCoordP3uiv\0" + "\0" + /* _mesa_function_pool[23720]: UniformMatrix2x3fv (will be remapped) */ + "iiip\0" + "glUniformMatrix2x3fv\0" + "\0" + /* _mesa_function_pool[23747]: SamplerParameteri (will be remapped) */ + "iii\0" + "glSamplerParameteri\0" + "\0" + /* _mesa_function_pool[23772]: SamplerParameterf (will be remapped) */ + "iif\0" + "glSamplerParameterf\0" + "\0" + /* _mesa_function_pool[23797]: CombinerParameteriNV (will be remapped) */ + "ii\0" + "glCombinerParameteriNV\0" + "\0" + /* _mesa_function_pool[23824]: DeleteAsyncMarkersSGIX (dynamic) */ + "ii\0" + "glDeleteAsyncMarkersSGIX\0" + "\0" + /* _mesa_function_pool[23853]: ReplacementCodeusSUN (dynamic) */ + "i\0" + "glReplacementCodeusSUN\0" + "\0" + /* _mesa_function_pool[23879]: IsAsyncMarkerSGIX (dynamic) */ + "i\0" + "glIsAsyncMarkerSGIX\0" + "\0" + /* _mesa_function_pool[23902]: FrameZoomSGIX (dynamic) */ + "i\0" + "glFrameZoomSGIX\0" + "\0" + /* _mesa_function_pool[23921]: Normal3fVertex3fvSUN (dynamic) */ + "pp\0" + "glNormal3fVertex3fvSUN\0" + "\0" + /* _mesa_function_pool[23948]: GetnUniformuivARB (will be remapped) */ + "iiip\0" + "glGetnUniformuivARB\0" + "\0" + /* _mesa_function_pool[23974]: RasterPos4sv (offset 85) */ + "p\0" + "glRasterPos4sv\0" + "\0" + /* _mesa_function_pool[23992]: VertexAttrib4NsvARB (will be remapped) */ + "ip\0" + "glVertexAttrib4Nsv\0" + "glVertexAttrib4NsvARB\0" + "\0" + /* _mesa_function_pool[24037]: VertexAttrib3fvARB (will be remapped) */ + "ip\0" + "glVertexAttrib3fv\0" + "glVertexAttrib3fvARB\0" + "\0" + /* _mesa_function_pool[24080]: ClearColor (offset 206) */ + "ffff\0" + "glClearColor\0" + "\0" + /* _mesa_function_pool[24099]: GetSynciv (will be remapped) */ + "iiipp\0" + "glGetSynciv\0" + "\0" + /* _mesa_function_pool[24118]: ClearColorIiEXT (will be remapped) */ + "iiii\0" + "glClearColorIiEXT\0" + "\0" + /* _mesa_function_pool[24142]: DeleteFramebuffersEXT (will be remapped) */ + "ip\0" + "glDeleteFramebuffers\0" + "glDeleteFramebuffersEXT\0" + "\0" + /* _mesa_function_pool[24191]: GlobalAlphaFactorsSUN (dynamic) */ + "i\0" + "glGlobalAlphaFactorsSUN\0" + "\0" + /* _mesa_function_pool[24218]: IsEnabledIndexedEXT (will be remapped) */ + "ii\0" + "glIsEnabledIndexedEXT\0" + "glIsEnabledi\0" + "\0" + /* _mesa_function_pool[24257]: TexEnviv (offset 187) */ + "iip\0" + "glTexEnviv\0" + "\0" + /* _mesa_function_pool[24273]: TexSubImage3D (offset 372) */ + "iiiiiiiiiip\0" + "glTexSubImage3D\0" + "glTexSubImage3DEXT\0" + "\0" + /* _mesa_function_pool[24321]: Tangent3fEXT (dynamic) */ + "fff\0" + "glTangent3fEXT\0" + "\0" + /* _mesa_function_pool[24341]: SecondaryColor3uivEXT (will be remapped) */ + "p\0" + "glSecondaryColor3uiv\0" + "glSecondaryColor3uivEXT\0" + "\0" + /* _mesa_function_pool[24389]: MatrixIndexubvARB (dynamic) */ + "ip\0" + "glMatrixIndexubvARB\0" + "\0" + /* _mesa_function_pool[24413]: Color4fNormal3fVertex3fSUN (dynamic) */ + "ffffffffff\0" + "glColor4fNormal3fVertex3fSUN\0" + "\0" + /* _mesa_function_pool[24454]: PixelTexGenParameterfSGIS (will be remapped) */ + "if\0" + "glPixelTexGenParameterfSGIS\0" + "\0" + /* _mesa_function_pool[24486]: CreateShader (will be remapped) */ + "i\0" + "glCreateShader\0" + "\0" + /* _mesa_function_pool[24504]: GetColorTableParameterfv (offset 344) */ + "iip\0" + "glGetColorTableParameterfv\0" + "glGetColorTableParameterfvSGI\0" + "glGetColorTableParameterfvEXT\0" + "\0" + /* _mesa_function_pool[24596]: FragmentLightModelfvSGIX (dynamic) */ + "ip\0" + "glFragmentLightModelfvSGIX\0" + "\0" + /* _mesa_function_pool[24627]: Bitmap (offset 8) */ + "iiffffp\0" + "glBitmap\0" + "\0" + /* _mesa_function_pool[24645]: MultiTexCoord3fARB (offset 394) */ + "ifff\0" + "glMultiTexCoord3f\0" + "glMultiTexCoord3fARB\0" + "\0" + /* _mesa_function_pool[24690]: GetTexLevelParameterfv (offset 284) */ + "iiip\0" + "glGetTexLevelParameterfv\0" + "\0" + /* _mesa_function_pool[24721]: GetPixelTexGenParameterfvSGIS (will be remapped) */ + "ip\0" + "glGetPixelTexGenParameterfvSGIS\0" + "\0" + /* _mesa_function_pool[24757]: GenFramebuffersEXT (will be remapped) */ + "ip\0" + "glGenFramebuffers\0" + "glGenFramebuffersEXT\0" + "\0" + /* _mesa_function_pool[24800]: VertexAttribDivisor (will be remapped) */ + "ii\0" + "glVertexAttribDivisor\0" + "\0" + /* _mesa_function_pool[24826]: GetProgramParameterdvNV (will be remapped) */ + "iiip\0" + "glGetProgramParameterdvNV\0" + "\0" + /* _mesa_function_pool[24858]: Vertex2sv (offset 133) */ + "p\0" + "glVertex2sv\0" + "\0" + /* _mesa_function_pool[24873]: GetIntegerv (offset 263) */ + "ip\0" + "glGetIntegerv\0" + "\0" + /* _mesa_function_pool[24891]: IsVertexArrayAPPLE (will be remapped) */ + "i\0" + "glIsVertexArray\0" + "glIsVertexArrayAPPLE\0" + "\0" + /* _mesa_function_pool[24931]: FragmentLightfvSGIX (dynamic) */ + "iip\0" + "glFragmentLightfvSGIX\0" + "\0" + /* _mesa_function_pool[24958]: GetnMapdvARB (will be remapped) */ + "iiip\0" + "glGetnMapdvARB\0" + "\0" + /* _mesa_function_pool[24979]: DetachShader (will be remapped) */ + "ii\0" + "glDetachShader\0" + "\0" + /* _mesa_function_pool[24998]: VertexAttrib4NubARB (will be remapped) */ + "iiiii\0" + "glVertexAttrib4Nub\0" + "glVertexAttrib4NubARB\0" + "\0" + /* _mesa_function_pool[25046]: GetProgramEnvParameterfvARB (will be remapped) */ + "iip\0" + "glGetProgramEnvParameterfvARB\0" + "\0" + /* _mesa_function_pool[25081]: GetTrackMatrixivNV (will be remapped) */ + "iiip\0" + "glGetTrackMatrixivNV\0" + "\0" + /* _mesa_function_pool[25108]: VertexAttrib3svNV (will be remapped) */ + "ip\0" + "glVertexAttrib3svNV\0" + "\0" + /* _mesa_function_pool[25132]: Uniform4fvARB (will be remapped) */ + "iip\0" + "glUniform4fv\0" + "glUniform4fvARB\0" + "\0" + /* _mesa_function_pool[25166]: MultTransposeMatrixfARB (will be remapped) */ + "p\0" + "glMultTransposeMatrixf\0" + "glMultTransposeMatrixfARB\0" + "\0" + /* _mesa_function_pool[25218]: GetTexEnviv (offset 277) */ + "iip\0" + "glGetTexEnviv\0" + "\0" + /* _mesa_function_pool[25237]: ColorFragmentOp1ATI (will be remapped) */ + "iiiiiii\0" + "glColorFragmentOp1ATI\0" + "\0" + /* _mesa_function_pool[25268]: GetUniformfvARB (will be remapped) */ + "iip\0" + "glGetUniformfv\0" + "glGetUniformfvARB\0" + "\0" + /* _mesa_function_pool[25306]: EGLImageTargetRenderbufferStorageOES (will be remapped) */ + "ip\0" + "glEGLImageTargetRenderbufferStorageOES\0" + "\0" + /* _mesa_function_pool[25349]: VertexAttribI2ivEXT (will be remapped) */ + "ip\0" + "glVertexAttribI2ivEXT\0" + "glVertexAttribI2iv\0" + "\0" + /* _mesa_function_pool[25394]: PopClientAttrib (offset 334) */ + "\0" + "glPopClientAttrib\0" + "\0" + /* _mesa_function_pool[25414]: ReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN (dynamic) */ + "iffffffffffff\0" + "glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN\0" + "\0" + /* _mesa_function_pool[25485]: DetachObjectARB (will be remapped) */ + "ii\0" + "glDetachObjectARB\0" + "\0" + /* _mesa_function_pool[25507]: VertexBlendARB (dynamic) */ + "i\0" + "glVertexBlendARB\0" + "\0" + /* _mesa_function_pool[25527]: WindowPos3iMESA (will be remapped) */ + "iii\0" + "glWindowPos3i\0" + "glWindowPos3iARB\0" + "glWindowPos3iMESA\0" + "\0" + /* _mesa_function_pool[25581]: SeparableFilter2D (offset 360) */ + "iiiiiipp\0" + "glSeparableFilter2D\0" + "glSeparableFilter2DEXT\0" + "\0" + /* _mesa_function_pool[25634]: ProgramParameteriARB (will be remapped) */ + "iii\0" + "glProgramParameteriARB\0" + "\0" + /* _mesa_function_pool[25662]: Map1d (offset 220) */ + "iddiip\0" + "glMap1d\0" + "\0" + /* _mesa_function_pool[25678]: Map1f (offset 221) */ + "iffiip\0" + "glMap1f\0" + "\0" + /* _mesa_function_pool[25694]: CompressedTexImage2DARB (will be remapped) */ + "iiiiiiip\0" + "glCompressedTexImage2D\0" + "glCompressedTexImage2DARB\0" + "\0" + /* _mesa_function_pool[25753]: ArrayElement (offset 306) */ + "i\0" + "glArrayElement\0" + "glArrayElementEXT\0" + "\0" + /* _mesa_function_pool[25789]: TexImage2D (offset 183) */ + "iiiiiiiip\0" + "glTexImage2D\0" + "\0" + /* _mesa_function_pool[25813]: DepthBoundsEXT (will be remapped) */ + "dd\0" + "glDepthBoundsEXT\0" + "\0" + /* _mesa_function_pool[25834]: ProgramParameters4fvNV (will be remapped) */ + "iiip\0" + "glProgramParameters4fvNV\0" + "\0" + /* _mesa_function_pool[25865]: DeformationMap3fSGIX (dynamic) */ + "iffiiffiiffiip\0" + "glDeformationMap3fSGIX\0" + "\0" + /* _mesa_function_pool[25904]: GetProgramivNV (will be remapped) */ + "iip\0" + "glGetProgramivNV\0" + "\0" + /* _mesa_function_pool[25926]: GetFragDataLocationEXT (will be remapped) */ + "ip\0" + "glGetFragDataLocationEXT\0" + "glGetFragDataLocation\0" + "\0" + /* _mesa_function_pool[25977]: GetMinmaxParameteriv (offset 366) */ + "iip\0" + "glGetMinmaxParameteriv\0" + "glGetMinmaxParameterivEXT\0" + "\0" + /* _mesa_function_pool[26031]: PixelTransferf (offset 247) */ + "if\0" + "glPixelTransferf\0" + "\0" + /* _mesa_function_pool[26052]: CopyTexImage1D (offset 323) */ + "iiiiiii\0" + "glCopyTexImage1D\0" + "glCopyTexImage1DEXT\0" + "\0" + /* _mesa_function_pool[26098]: PushMatrix (offset 298) */ + "\0" + "glPushMatrix\0" + "\0" + /* _mesa_function_pool[26113]: Fogiv (offset 156) */ + "ip\0" + "glFogiv\0" + "\0" + /* _mesa_function_pool[26125]: TexCoord1dv (offset 95) */ + "p\0" + "glTexCoord1dv\0" + "\0" + /* _mesa_function_pool[26142]: AlphaFragmentOp3ATI (will be remapped) */ + "iiiiiiiiiiii\0" + "glAlphaFragmentOp3ATI\0" + "\0" + /* _mesa_function_pool[26178]: PixelTransferi (offset 248) */ + "ii\0" + "glPixelTransferi\0" + "\0" + /* _mesa_function_pool[26199]: GetnColorTableARB (will be remapped) */ + "iiiip\0" + "glGetnColorTableARB\0" + "\0" + /* _mesa_function_pool[26226]: VertexAttrib3fvNV (will be remapped) */ + "ip\0" + "glVertexAttrib3fvNV\0" + "\0" + /* _mesa_function_pool[26250]: Rotatef (offset 300) */ + "ffff\0" + "glRotatef\0" + "\0" + /* _mesa_function_pool[26266]: GetFinalCombinerInputParameterivNV (will be remapped) */ + "iip\0" + "glGetFinalCombinerInputParameterivNV\0" + "\0" + /* _mesa_function_pool[26308]: Vertex3i (offset 138) */ + "iii\0" + "glVertex3i\0" + "\0" + /* _mesa_function_pool[26324]: SecondaryColorP3ui (will be remapped) */ + "ii\0" + "glSecondaryColorP3ui\0" + "\0" + /* _mesa_function_pool[26349]: Vertex3f (offset 136) */ + "fff\0" + "glVertex3f\0" + "\0" + /* _mesa_function_pool[26365]: Clear (offset 203) */ + "i\0" + "glClear\0" + "\0" + /* _mesa_function_pool[26376]: Vertex3d (offset 134) */ + "ddd\0" + "glVertex3d\0" + "\0" + /* _mesa_function_pool[26392]: GetMapParameterivNV (dynamic) */ + "iip\0" + "glGetMapParameterivNV\0" + "\0" + /* _mesa_function_pool[26419]: Uniform4iARB (will be remapped) */ + "iiiii\0" + "glUniform4i\0" + "glUniform4iARB\0" + "\0" + /* _mesa_function_pool[26453]: ReadBuffer (offset 254) */ + "i\0" + "glReadBuffer\0" + "\0" + /* _mesa_function_pool[26469]: ConvolutionParameteri (offset 352) */ + "iii\0" + "glConvolutionParameteri\0" + "glConvolutionParameteriEXT\0" + "\0" + /* _mesa_function_pool[26525]: Ortho (offset 296) */ + "dddddd\0" + "glOrtho\0" + "\0" + /* _mesa_function_pool[26541]: Binormal3sEXT (dynamic) */ + "iii\0" + "glBinormal3sEXT\0" + "\0" + /* _mesa_function_pool[26562]: ListBase (offset 6) */ + "i\0" + "glListBase\0" + "\0" + /* _mesa_function_pool[26576]: VertexAttribI3ivEXT (will be remapped) */ + "ip\0" + "glVertexAttribI3ivEXT\0" + "glVertexAttribI3iv\0" + "\0" + /* _mesa_function_pool[26621]: MultiTexCoordP1ui (will be remapped) */ + "iii\0" + "glMultiTexCoordP1ui\0" + "\0" + /* _mesa_function_pool[26646]: Vertex3s (offset 140) */ + "iii\0" + "glVertex3s\0" + "\0" + /* _mesa_function_pool[26662]: ConvolutionParameterf (offset 350) */ + "iif\0" + "glConvolutionParameterf\0" + "glConvolutionParameterfEXT\0" + "\0" + /* _mesa_function_pool[26718]: GetColorTableParameteriv (offset 345) */ + "iip\0" + "glGetColorTableParameteriv\0" + "glGetColorTableParameterivSGI\0" + "glGetColorTableParameterivEXT\0" + "\0" + /* _mesa_function_pool[26810]: ProgramEnvParameter4dvARB (will be remapped) */ + "iip\0" + "glProgramEnvParameter4dvARB\0" + "glProgramParameter4dvNV\0" + "\0" + /* _mesa_function_pool[26867]: ShadeModel (offset 177) */ + "i\0" + "glShadeModel\0" + "\0" + /* _mesa_function_pool[26883]: VertexAttribs2fvNV (will be remapped) */ + "iip\0" + "glVertexAttribs2fvNV\0" + "\0" + /* _mesa_function_pool[26909]: Rectiv (offset 91) */ + "pp\0" + "glRectiv\0" + "\0" + /* _mesa_function_pool[26922]: UseProgramObjectARB (will be remapped) */ + "i\0" + "glUseProgram\0" + "glUseProgramObjectARB\0" + "\0" + /* _mesa_function_pool[26960]: GetMapParameterfvNV (dynamic) */ + "iip\0" + "glGetMapParameterfvNV\0" + "\0" + /* _mesa_function_pool[26987]: EndConditionalRenderNV (will be remapped) */ + "\0" + "glEndConditionalRenderNV\0" + "glEndConditionalRender\0" + "\0" + /* _mesa_function_pool[27037]: PassTexCoordATI (will be remapped) */ + "iii\0" + "glPassTexCoordATI\0" + "\0" + /* _mesa_function_pool[27060]: DeleteProgram (will be remapped) */ + "i\0" + "glDeleteProgram\0" + "\0" + /* _mesa_function_pool[27079]: GetSamplerParameteriv (will be remapped) */ + "iip\0" + "glGetSamplerParameteriv\0" + "\0" + /* _mesa_function_pool[27108]: Tangent3dEXT (dynamic) */ + "ddd\0" + "glTangent3dEXT\0" + "\0" + /* _mesa_function_pool[27128]: SecondaryColor3dvEXT (will be remapped) */ + "p\0" + "glSecondaryColor3dv\0" + "glSecondaryColor3dvEXT\0" + "\0" + /* _mesa_function_pool[27174]: AlphaFragmentOp2ATI (will be remapped) */ + "iiiiiiiii\0" + "glAlphaFragmentOp2ATI\0" + "\0" + /* _mesa_function_pool[27207]: Vertex2fv (offset 129) */ + "p\0" + "glVertex2fv\0" + "\0" + /* _mesa_function_pool[27222]: MultiDrawArraysEXT (will be remapped) */ + "ippi\0" + "glMultiDrawArrays\0" + "glMultiDrawArraysEXT\0" + "\0" + /* _mesa_function_pool[27267]: BindRenderbufferEXT (will be remapped) */ + "ii\0" + "glBindRenderbuffer\0" + "glBindRenderbufferEXT\0" + "\0" + /* _mesa_function_pool[27312]: MultiTexCoord4dARB (offset 400) */ + "idddd\0" + "glMultiTexCoord4d\0" + "glMultiTexCoord4dARB\0" + "\0" + /* _mesa_function_pool[27358]: FramebufferTextureFaceARB (will be remapped) */ + "iiiii\0" + "glFramebufferTextureFaceARB\0" + "\0" + /* _mesa_function_pool[27393]: Vertex3sv (offset 141) */ + "p\0" + "glVertex3sv\0" + "\0" + /* _mesa_function_pool[27408]: SecondaryColor3usEXT (will be remapped) */ + "iii\0" + "glSecondaryColor3us\0" + "glSecondaryColor3usEXT\0" + "\0" + /* _mesa_function_pool[27456]: ProgramLocalParameter4fvARB (will be remapped) */ + "iip\0" + "glProgramLocalParameter4fvARB\0" + "\0" + /* _mesa_function_pool[27491]: DeleteProgramsNV (will be remapped) */ + "ip\0" + "glDeleteProgramsARB\0" + "glDeleteProgramsNV\0" + "\0" + /* _mesa_function_pool[27534]: EvalMesh1 (offset 236) */ + "iii\0" + "glEvalMesh1\0" + "\0" + /* _mesa_function_pool[27551]: PauseTransformFeedback (will be remapped) */ + "\0" + "glPauseTransformFeedback\0" + "\0" + /* _mesa_function_pool[27578]: MultiTexCoord1sARB (offset 382) */ + "ii\0" + "glMultiTexCoord1s\0" + "glMultiTexCoord1sARB\0" + "\0" + /* _mesa_function_pool[27621]: ReplacementCodeuiColor3fVertex3fSUN (dynamic) */ + "iffffff\0" + "glReplacementCodeuiColor3fVertex3fSUN\0" + "\0" + /* _mesa_function_pool[27668]: GetVertexAttribPointervNV (will be remapped) */ + "iip\0" + "glGetVertexAttribPointerv\0" + "glGetVertexAttribPointervARB\0" + "glGetVertexAttribPointervNV\0" + "\0" + /* _mesa_function_pool[27756]: VertexAttribs1fvNV (will be remapped) */ + "iip\0" + "glVertexAttribs1fvNV\0" + "\0" + /* _mesa_function_pool[27782]: MultiTexCoord1dvARB (offset 377) */ + "ip\0" + "glMultiTexCoord1dv\0" + "glMultiTexCoord1dvARB\0" + "\0" + /* _mesa_function_pool[27827]: Uniform2iARB (will be remapped) */ + "iii\0" + "glUniform2i\0" + "glUniform2iARB\0" + "\0" + /* _mesa_function_pool[27859]: Vertex2iv (offset 131) */ + "p\0" + "glVertex2iv\0" + "\0" + /* _mesa_function_pool[27874]: GetProgramStringNV (will be remapped) */ + "iip\0" + "glGetProgramStringNV\0" + "\0" + /* _mesa_function_pool[27900]: ColorPointerEXT (will be remapped) */ + "iiiip\0" + "glColorPointerEXT\0" + "\0" + /* _mesa_function_pool[27925]: LineWidth (offset 168) */ + "f\0" + "glLineWidth\0" + "\0" + /* _mesa_function_pool[27940]: MapBufferARB (will be remapped) */ + "ii\0" + "glMapBuffer\0" + "glMapBufferARB\0" + "\0" + /* _mesa_function_pool[27971]: MultiDrawElementsBaseVertex (will be remapped) */ + "ipipip\0" + "glMultiDrawElementsBaseVertex\0" + "\0" + /* _mesa_function_pool[28009]: TexParameterIuivEXT (will be remapped) */ + "iip\0" + "glTexParameterIuivEXT\0" + "glTexParameterIuiv\0" + "\0" + /* _mesa_function_pool[28055]: Binormal3svEXT (dynamic) */ + "p\0" + "glBinormal3svEXT\0" + "\0" + /* _mesa_function_pool[28075]: ApplyTextureEXT (dynamic) */ + "i\0" + "glApplyTextureEXT\0" + "\0" + /* _mesa_function_pool[28096]: GetBufferParameteri64v (will be remapped) */ + "iip\0" + "glGetBufferParameteri64v\0" + "\0" + /* _mesa_function_pool[28126]: TexGendv (offset 189) */ + "iip\0" + "glTexGendv\0" + "\0" + /* _mesa_function_pool[28142]: VertexAttribI3iEXT (will be remapped) */ + "iiii\0" + "glVertexAttribI3iEXT\0" + "glVertexAttribI3i\0" + "\0" + /* _mesa_function_pool[28187]: EnableIndexedEXT (will be remapped) */ + "ii\0" + "glEnableIndexedEXT\0" + "glEnablei\0" + "\0" + /* _mesa_function_pool[28220]: TextureMaterialEXT (dynamic) */ + "ii\0" + "glTextureMaterialEXT\0" + "\0" + /* _mesa_function_pool[28245]: TextureLightEXT (dynamic) */ + "i\0" + "glTextureLightEXT\0" + "\0" + /* _mesa_function_pool[28266]: ResetMinmax (offset 370) */ + "i\0" + "glResetMinmax\0" + "glResetMinmaxEXT\0" + "\0" + /* _mesa_function_pool[28300]: SpriteParameterfSGIX (dynamic) */ + "if\0" + "glSpriteParameterfSGIX\0" + "\0" + /* _mesa_function_pool[28327]: EnableClientState (offset 313) */ + "i\0" + "glEnableClientState\0" + "\0" + /* _mesa_function_pool[28350]: VertexAttrib4sNV (will be remapped) */ + "iiiii\0" + "glVertexAttrib4sNV\0" + "\0" + /* _mesa_function_pool[28376]: GetConvolutionParameterfv (offset 357) */ + "iip\0" + "glGetConvolutionParameterfv\0" + "glGetConvolutionParameterfvEXT\0" + "\0" + /* _mesa_function_pool[28440]: VertexAttribs4dvNV (will be remapped) */ + "iip\0" + "glVertexAttribs4dvNV\0" + "\0" + /* _mesa_function_pool[28466]: MultiModeDrawArraysIBM (will be remapped) */ + "pppii\0" + "glMultiModeDrawArraysIBM\0" + "\0" + /* _mesa_function_pool[28498]: VertexAttrib4dARB (will be remapped) */ + "idddd\0" + "glVertexAttrib4d\0" + "glVertexAttrib4dARB\0" + "\0" + /* _mesa_function_pool[28542]: GetTexBumpParameterfvATI (will be remapped) */ + "ip\0" + "glGetTexBumpParameterfvATI\0" + "\0" + /* _mesa_function_pool[28573]: ProgramNamedParameter4dNV (will be remapped) */ + "iipdddd\0" + "glProgramNamedParameter4dNV\0" + "\0" + /* _mesa_function_pool[28610]: GetMaterialfv (offset 269) */ + "iip\0" + "glGetMaterialfv\0" + "\0" + /* _mesa_function_pool[28631]: VertexWeightfEXT (dynamic) */ + "f\0" + "glVertexWeightfEXT\0" + "\0" + /* _mesa_function_pool[28653]: SetFragmentShaderConstantATI (will be remapped) */ + "ip\0" + "glSetFragmentShaderConstantATI\0" + "\0" + /* _mesa_function_pool[28688]: Binormal3fEXT (dynamic) */ + "fff\0" + "glBinormal3fEXT\0" + "\0" + /* _mesa_function_pool[28709]: CallList (offset 2) */ + "i\0" + "glCallList\0" + "\0" + /* _mesa_function_pool[28723]: Materialfv (offset 170) */ + "iip\0" + "glMaterialfv\0" + "\0" + /* _mesa_function_pool[28741]: TexCoord3fv (offset 113) */ + "p\0" + "glTexCoord3fv\0" + "\0" + /* _mesa_function_pool[28758]: FogCoordfvEXT (will be remapped) */ + "p\0" + "glFogCoordfv\0" + "glFogCoordfvEXT\0" + "\0" + /* _mesa_function_pool[28790]: MultiTexCoord1ivARB (offset 381) */ + "ip\0" + "glMultiTexCoord1iv\0" + "glMultiTexCoord1ivARB\0" + "\0" + /* _mesa_function_pool[28835]: SecondaryColor3ubEXT (will be remapped) */ + "iii\0" + "glSecondaryColor3ub\0" + "glSecondaryColor3ubEXT\0" + "\0" + /* _mesa_function_pool[28883]: MultiTexCoord2ivARB (offset 389) */ + "ip\0" + "glMultiTexCoord2iv\0" + "glMultiTexCoord2ivARB\0" + "\0" + /* _mesa_function_pool[28928]: FogFuncSGIS (dynamic) */ + "ip\0" + "glFogFuncSGIS\0" + "\0" + /* _mesa_function_pool[28946]: CopyTexSubImage2D (offset 326) */ + "iiiiiiii\0" + "glCopyTexSubImage2D\0" + "glCopyTexSubImage2DEXT\0" + "\0" + /* _mesa_function_pool[28999]: GetObjectParameterivARB (will be remapped) */ + "iip\0" + "glGetObjectParameterivARB\0" + "\0" + /* _mesa_function_pool[29030]: Color3iv (offset 16) */ + "p\0" + "glColor3iv\0" + "\0" + /* _mesa_function_pool[29044]: TexCoord4fVertex4fSUN (dynamic) */ + "ffffffff\0" + "glTexCoord4fVertex4fSUN\0" + "\0" + /* _mesa_function_pool[29078]: DrawElements (offset 311) */ + "iiip\0" + "glDrawElements\0" + "\0" + /* _mesa_function_pool[29099]: BindVertexArrayAPPLE (will be remapped) */ + "i\0" + "glBindVertexArrayAPPLE\0" + "\0" + /* _mesa_function_pool[29125]: GetProgramLocalParameterdvARB (will be remapped) */ + "iip\0" + "glGetProgramLocalParameterdvARB\0" + "\0" + /* _mesa_function_pool[29162]: GetHistogramParameteriv (offset 363) */ + "iip\0" + "glGetHistogramParameteriv\0" + "glGetHistogramParameterivEXT\0" + "\0" + /* _mesa_function_pool[29222]: MultiTexCoord1iARB (offset 380) */ + "ii\0" + "glMultiTexCoord1i\0" + "glMultiTexCoord1iARB\0" + "\0" + /* _mesa_function_pool[29265]: GetConvolutionFilter (offset 356) */ + "iiip\0" + "glGetConvolutionFilter\0" + "glGetConvolutionFilterEXT\0" + "\0" + /* _mesa_function_pool[29320]: GetProgramivARB (will be remapped) */ + "iip\0" + "glGetProgramivARB\0" + "\0" + /* _mesa_function_pool[29343]: TexBufferARB (will be remapped) */ + "iii\0" + "glTexBufferARB\0" + "\0" + /* _mesa_function_pool[29363]: BlendFuncSeparateEXT (will be remapped) */ + "iiii\0" + "glBlendFuncSeparate\0" + "glBlendFuncSeparateEXT\0" + "glBlendFuncSeparateINGR\0" + "\0" + /* _mesa_function_pool[29436]: MapBufferRange (will be remapped) */ + "iiii\0" + "glMapBufferRange\0" + "\0" + /* _mesa_function_pool[29459]: ProgramParameters4dvNV (will be remapped) */ + "iiip\0" + "glProgramParameters4dvNV\0" + "\0" + /* _mesa_function_pool[29490]: TexCoord2fColor3fVertex3fvSUN (dynamic) */ + "ppp\0" + "glTexCoord2fColor3fVertex3fvSUN\0" + "\0" + /* _mesa_function_pool[29527]: EvalPoint2 (offset 239) */ + "ii\0" + "glEvalPoint2\0" + "\0" + /* _mesa_function_pool[29544]: Uniform1uivEXT (will be remapped) */ + "iip\0" + "glUniform1uivEXT\0" + "glUniform1uiv\0" + "\0" + /* _mesa_function_pool[29580]: EvalPoint1 (offset 237) */ + "i\0" + "glEvalPoint1\0" + "\0" + /* _mesa_function_pool[29596]: Binormal3dvEXT (dynamic) */ + "p\0" + "glBinormal3dvEXT\0" + "\0" + /* _mesa_function_pool[29616]: PopMatrix (offset 297) */ + "\0" + "glPopMatrix\0" + "\0" + /* _mesa_function_pool[29630]: GetVertexAttribIuivEXT (will be remapped) */ + "iip\0" + "glGetVertexAttribIuivEXT\0" + "glGetVertexAttribIuiv\0" + "\0" + /* _mesa_function_pool[29682]: FinishFenceNV (will be remapped) */ + "i\0" + "glFinishFenceNV\0" + "\0" + /* _mesa_function_pool[29701]: GetFogFuncSGIS (dynamic) */ + "p\0" + "glGetFogFuncSGIS\0" + "\0" + /* _mesa_function_pool[29721]: GetUniformLocationARB (will be remapped) */ + "ip\0" + "glGetUniformLocation\0" + "glGetUniformLocationARB\0" + "\0" + /* _mesa_function_pool[29770]: SecondaryColor3fEXT (will be remapped) */ + "fff\0" + "glSecondaryColor3f\0" + "glSecondaryColor3fEXT\0" + "\0" + /* _mesa_function_pool[29816]: GetTexGeniv (offset 280) */ + "iip\0" + "glGetTexGeniv\0" + "\0" + /* _mesa_function_pool[29835]: CombinerInputNV (will be remapped) */ + "iiiiii\0" + "glCombinerInputNV\0" + "\0" + /* _mesa_function_pool[29861]: VertexAttrib3sARB (will be remapped) */ + "iiii\0" + "glVertexAttrib3s\0" + "glVertexAttrib3sARB\0" + "\0" + /* _mesa_function_pool[29904]: IsTransformFeedback (will be remapped) */ + "i\0" + "glIsTransformFeedback\0" + "\0" + /* _mesa_function_pool[29929]: ReplacementCodeuiNormal3fVertex3fvSUN (dynamic) */ + "ppp\0" + "glReplacementCodeuiNormal3fVertex3fvSUN\0" + "\0" + /* _mesa_function_pool[29974]: Map2d (offset 222) */ + "iddiiddiip\0" + "glMap2d\0" + "\0" + /* _mesa_function_pool[29994]: Map2f (offset 223) */ + "iffiiffiip\0" + "glMap2f\0" + "\0" + /* _mesa_function_pool[30014]: ProgramStringARB (will be remapped) */ + "iiip\0" + "glProgramStringARB\0" + "\0" + /* _mesa_function_pool[30039]: Vertex4s (offset 148) */ + "iiii\0" + "glVertex4s\0" + "\0" + /* _mesa_function_pool[30056]: TexCoord4fVertex4fvSUN (dynamic) */ + "pp\0" + "glTexCoord4fVertex4fvSUN\0" + "\0" + /* _mesa_function_pool[30085]: FragmentLightModelivSGIX (dynamic) */ + "ip\0" + "glFragmentLightModelivSGIX\0" + "\0" + /* _mesa_function_pool[30116]: VertexAttrib1fNV (will be remapped) */ + "if\0" + "glVertexAttrib1fNV\0" + "\0" + /* _mesa_function_pool[30139]: Vertex4f (offset 144) */ + "ffff\0" + "glVertex4f\0" + "\0" + /* _mesa_function_pool[30156]: EvalCoord1d (offset 228) */ + "d\0" + "glEvalCoord1d\0" + "\0" + /* _mesa_function_pool[30173]: Vertex4d (offset 142) */ + "dddd\0" + "glVertex4d\0" + "\0" + /* _mesa_function_pool[30190]: RasterPos4dv (offset 79) */ + "p\0" + "glRasterPos4dv\0" + "\0" + /* _mesa_function_pool[30208]: UseShaderProgramEXT (will be remapped) */ + "ii\0" + "glUseShaderProgramEXT\0" + "\0" + /* _mesa_function_pool[30234]: FragmentLightfSGIX (dynamic) */ + "iif\0" + "glFragmentLightfSGIX\0" + "\0" + /* _mesa_function_pool[30260]: GetCompressedTexImageARB (will be remapped) */ + "iip\0" + "glGetCompressedTexImage\0" + "glGetCompressedTexImageARB\0" + "\0" + /* _mesa_function_pool[30316]: GetTexGenfv (offset 279) */ + "iip\0" + "glGetTexGenfv\0" + "\0" + /* _mesa_function_pool[30335]: Vertex4i (offset 146) */ + "iiii\0" + "glVertex4i\0" + "\0" + /* _mesa_function_pool[30352]: VertexWeightPointerEXT (dynamic) */ + "iiip\0" + "glVertexWeightPointerEXT\0" + "\0" + /* _mesa_function_pool[30383]: GetHistogram (offset 361) */ + "iiiip\0" + "glGetHistogram\0" + "glGetHistogramEXT\0" + "\0" + /* _mesa_function_pool[30423]: ActiveStencilFaceEXT (will be remapped) */ + "i\0" + "glActiveStencilFaceEXT\0" + "\0" + /* _mesa_function_pool[30449]: StencilFuncSeparateATI (will be remapped) */ + "iiii\0" + "glStencilFuncSeparateATI\0" + "\0" + /* _mesa_function_pool[30480]: Materialf (offset 169) */ + "iif\0" + "glMaterialf\0" + "\0" + /* _mesa_function_pool[30497]: GetShaderSourceARB (will be remapped) */ + "iipp\0" + "glGetShaderSource\0" + "glGetShaderSourceARB\0" + "\0" + /* _mesa_function_pool[30542]: IglooInterfaceSGIX (dynamic) */ + "ip\0" + "glIglooInterfaceSGIX\0" + "\0" + /* _mesa_function_pool[30567]: Materiali (offset 171) */ + "iii\0" + "glMateriali\0" + "\0" + /* _mesa_function_pool[30584]: VertexAttrib4dNV (will be remapped) */ + "idddd\0" + "glVertexAttrib4dNV\0" + "\0" + /* _mesa_function_pool[30610]: MultiModeDrawElementsIBM (will be remapped) */ + "ppipii\0" + "glMultiModeDrawElementsIBM\0" + "\0" + /* _mesa_function_pool[30645]: Indexsv (offset 51) */ + "p\0" + "glIndexsv\0" + "\0" + /* _mesa_function_pool[30658]: MultiTexCoord4svARB (offset 407) */ + "ip\0" + "glMultiTexCoord4sv\0" + "glMultiTexCoord4svARB\0" + "\0" + /* _mesa_function_pool[30703]: LightModelfv (offset 164) */ + "ip\0" + "glLightModelfv\0" + "\0" + /* _mesa_function_pool[30722]: TexCoord2dv (offset 103) */ + "p\0" + "glTexCoord2dv\0" + "\0" + /* _mesa_function_pool[30739]: GenQueriesARB (will be remapped) */ + "ip\0" + "glGenQueries\0" + "glGenQueriesARB\0" + "\0" + /* _mesa_function_pool[30772]: EvalCoord1dv (offset 229) */ + "p\0" + "glEvalCoord1dv\0" + "\0" + /* _mesa_function_pool[30790]: ReplacementCodeuiVertex3fSUN (dynamic) */ + "ifff\0" + "glReplacementCodeuiVertex3fSUN\0" + "\0" + /* _mesa_function_pool[30827]: Translated (offset 303) */ + "ddd\0" + "glTranslated\0" + "\0" + /* _mesa_function_pool[30845]: Translatef (offset 304) */ + "fff\0" + "glTranslatef\0" + "\0" + /* _mesa_function_pool[30863]: Uniform3uiEXT (will be remapped) */ + "iiii\0" + "glUniform3uiEXT\0" + "glUniform3ui\0" + "\0" + /* _mesa_function_pool[30898]: StencilMask (offset 209) */ + "i\0" + "glStencilMask\0" + "\0" + /* _mesa_function_pool[30915]: Tangent3iEXT (dynamic) */ + "iii\0" + "glTangent3iEXT\0" + "\0" + /* _mesa_function_pool[30935]: ClampColorARB (will be remapped) */ + "ii\0" + "glClampColorARB\0" + "\0" + /* _mesa_function_pool[30955]: GetLightiv (offset 265) */ + "iip\0" + "glGetLightiv\0" + "\0" + /* _mesa_function_pool[30973]: GetSamplerParameterIiv (will be remapped) */ + "iip\0" + "glGetSamplerParameterIiv\0" + "\0" + /* _mesa_function_pool[31003]: DrawMeshArraysSUN (dynamic) */ + "iiii\0" + "glDrawMeshArraysSUN\0" + "\0" + /* _mesa_function_pool[31029]: IsList (offset 287) */ + "i\0" + "glIsList\0" + "\0" + /* _mesa_function_pool[31041]: IsSync (will be remapped) */ + "i\0" + "glIsSync\0" + "\0" + /* _mesa_function_pool[31053]: RenderMode (offset 196) */ + "i\0" + "glRenderMode\0" + "\0" + /* _mesa_function_pool[31069]: GetMapControlPointsNV (dynamic) */ + "iiiiiip\0" + "glGetMapControlPointsNV\0" + "\0" + /* _mesa_function_pool[31102]: DrawBuffersARB (will be remapped) */ + "ip\0" + "glDrawBuffers\0" + "glDrawBuffersARB\0" + "glDrawBuffersATI\0" + "\0" + /* _mesa_function_pool[31154]: ClearBufferiv (will be remapped) */ + "iip\0" + "glClearBufferiv\0" + "\0" + /* _mesa_function_pool[31175]: ProgramLocalParameter4fARB (will be remapped) */ + "iiffff\0" + "glProgramLocalParameter4fARB\0" + "\0" + /* _mesa_function_pool[31212]: SpriteParameterivSGIX (dynamic) */ + "ip\0" + "glSpriteParameterivSGIX\0" + "\0" + /* _mesa_function_pool[31240]: ProvokingVertexEXT (will be remapped) */ + "i\0" + "glProvokingVertexEXT\0" + "glProvokingVertex\0" + "\0" + /* _mesa_function_pool[31282]: MultiTexCoord1fARB (offset 378) */ + "if\0" + "glMultiTexCoord1f\0" + "glMultiTexCoord1fARB\0" + "\0" + /* _mesa_function_pool[31325]: LoadName (offset 198) */ + "i\0" + "glLoadName\0" + "\0" + /* _mesa_function_pool[31339]: VertexAttribs4ubvNV (will be remapped) */ + "iip\0" + "glVertexAttribs4ubvNV\0" + "\0" + /* _mesa_function_pool[31366]: WeightsvARB (dynamic) */ + "ip\0" + "glWeightsvARB\0" + "\0" + /* _mesa_function_pool[31384]: NormalP3ui (will be remapped) */ + "ii\0" + "glNormalP3ui\0" + "\0" + /* _mesa_function_pool[31401]: Uniform1fvARB (will be remapped) */ + "iip\0" + "glUniform1fv\0" + "glUniform1fvARB\0" + "\0" + /* _mesa_function_pool[31435]: CopyTexSubImage1D (offset 325) */ + "iiiiii\0" + "glCopyTexSubImage1D\0" + "glCopyTexSubImage1DEXT\0" + "\0" + /* _mesa_function_pool[31486]: CullFace (offset 152) */ + "i\0" + "glCullFace\0" + "\0" + /* _mesa_function_pool[31500]: BindTexture (offset 307) */ + "ii\0" + "glBindTexture\0" + "glBindTextureEXT\0" + "\0" + /* _mesa_function_pool[31535]: BeginFragmentShaderATI (will be remapped) */ + "\0" + "glBeginFragmentShaderATI\0" + "\0" + /* _mesa_function_pool[31562]: MultiTexCoord4fARB (offset 402) */ + "iffff\0" + "glMultiTexCoord4f\0" + "glMultiTexCoord4fARB\0" + "\0" + /* _mesa_function_pool[31608]: VertexAttribs3svNV (will be remapped) */ + "iip\0" + "glVertexAttribs3svNV\0" + "\0" + /* _mesa_function_pool[31634]: StencilFunc (offset 243) */ + "iii\0" + "glStencilFunc\0" + "\0" + /* _mesa_function_pool[31653]: CopyPixels (offset 255) */ + "iiiii\0" + "glCopyPixels\0" + "\0" + /* _mesa_function_pool[31673]: Rectsv (offset 93) */ + "pp\0" + "glRectsv\0" + "\0" + /* _mesa_function_pool[31686]: ReplacementCodeuivSUN (dynamic) */ + "p\0" + "glReplacementCodeuivSUN\0" + "\0" + /* _mesa_function_pool[31713]: MultiTexCoordP2uiv (will be remapped) */ + "iip\0" + "glMultiTexCoordP2uiv\0" + "\0" + /* _mesa_function_pool[31739]: EnableVertexAttribArrayARB (will be remapped) */ + "i\0" + "glEnableVertexAttribArray\0" + "glEnableVertexAttribArrayARB\0" + "\0" + /* _mesa_function_pool[31797]: NormalPointervINTEL (dynamic) */ + "ip\0" + "glNormalPointervINTEL\0" + "\0" + /* _mesa_function_pool[31823]: CopyConvolutionFilter2D (offset 355) */ + "iiiiii\0" + "glCopyConvolutionFilter2D\0" + "glCopyConvolutionFilter2DEXT\0" + "\0" + /* _mesa_function_pool[31886]: WindowPos3ivMESA (will be remapped) */ + "p\0" + "glWindowPos3iv\0" + "glWindowPos3ivARB\0" + "glWindowPos3ivMESA\0" + "\0" + /* _mesa_function_pool[31941]: CopyBufferSubData (will be remapped) */ + "iiiii\0" + "glCopyBufferSubData\0" + "\0" + /* _mesa_function_pool[31968]: NormalPointer (offset 318) */ + "iip\0" + "glNormalPointer\0" + "\0" + /* _mesa_function_pool[31989]: TexParameterfv (offset 179) */ + "iip\0" + "glTexParameterfv\0" + "\0" + /* _mesa_function_pool[32011]: IsBufferARB (will be remapped) */ + "i\0" + "glIsBuffer\0" + "glIsBufferARB\0" + "\0" + /* _mesa_function_pool[32039]: WindowPos4iMESA (will be remapped) */ + "iiii\0" + "glWindowPos4iMESA\0" + "\0" + /* _mesa_function_pool[32063]: VertexAttrib4uivARB (will be remapped) */ + "ip\0" + "glVertexAttrib4uiv\0" + "glVertexAttrib4uivARB\0" + "\0" + /* _mesa_function_pool[32108]: Tangent3bvEXT (dynamic) */ + "p\0" + "glTangent3bvEXT\0" + "\0" + /* _mesa_function_pool[32127]: VertexAttribI3uivEXT (will be remapped) */ + "ip\0" + "glVertexAttribI3uivEXT\0" + "glVertexAttribI3uiv\0" + "\0" + /* _mesa_function_pool[32174]: UniformMatrix3x4fv (will be remapped) */ + "iiip\0" + "glUniformMatrix3x4fv\0" + "\0" + /* _mesa_function_pool[32201]: ClipPlane (offset 150) */ + "ip\0" + "glClipPlane\0" + "\0" + /* _mesa_function_pool[32217]: Recti (offset 90) */ + "iiii\0" + "glRecti\0" + "\0" + /* _mesa_function_pool[32231]: TrackMatrixNV (will be remapped) */ + "iiii\0" + "glTrackMatrixNV\0" + "\0" + /* _mesa_function_pool[32253]: DrawRangeElementsBaseVertex (will be remapped) */ + "iiiiipi\0" + "glDrawRangeElementsBaseVertex\0" + "\0" + /* _mesa_function_pool[32292]: SamplerParameterIuiv (will be remapped) */ + "iip\0" + "glSamplerParameterIuiv\0" + "\0" + /* _mesa_function_pool[32320]: TexCoordPointervINTEL (dynamic) */ + "iip\0" + "glTexCoordPointervINTEL\0" + "\0" + /* _mesa_function_pool[32349]: DeleteBuffersARB (will be remapped) */ + "ip\0" + "glDeleteBuffers\0" + "glDeleteBuffersARB\0" + "\0" + /* _mesa_function_pool[32388]: PixelTransformParameterfvEXT (dynamic) */ + "iip\0" + "glPixelTransformParameterfvEXT\0" + "\0" + /* _mesa_function_pool[32424]: PrimitiveRestartNV (will be remapped) */ + "\0" + "glPrimitiveRestartNV\0" + "\0" + /* _mesa_function_pool[32447]: WindowPos4fvMESA (will be remapped) */ + "p\0" + "glWindowPos4fvMESA\0" + "\0" + /* _mesa_function_pool[32469]: GetPixelMapuiv (offset 272) */ + "ip\0" + "glGetPixelMapuiv\0" + "\0" + /* _mesa_function_pool[32490]: Rectf (offset 88) */ + "ffff\0" + "glRectf\0" + "\0" + /* _mesa_function_pool[32504]: VertexAttrib1sNV (will be remapped) */ + "ii\0" + "glVertexAttrib1sNV\0" + "\0" + /* _mesa_function_pool[32527]: Indexfv (offset 47) */ + "p\0" + "glIndexfv\0" + "\0" + /* _mesa_function_pool[32540]: ColorP3uiv (will be remapped) */ + "ip\0" + "glColorP3uiv\0" + "\0" + /* _mesa_function_pool[32557]: SecondaryColor3svEXT (will be remapped) */ + "p\0" + "glSecondaryColor3sv\0" + "glSecondaryColor3svEXT\0" + "\0" + /* _mesa_function_pool[32603]: LoadTransposeMatrixfARB (will be remapped) */ + "p\0" + "glLoadTransposeMatrixf\0" + "glLoadTransposeMatrixfARB\0" + "\0" + /* _mesa_function_pool[32655]: GetPointerv (offset 329) */ + "ip\0" + "glGetPointerv\0" + "glGetPointervEXT\0" + "\0" + /* _mesa_function_pool[32690]: Tangent3bEXT (dynamic) */ + "iii\0" + "glTangent3bEXT\0" + "\0" + /* _mesa_function_pool[32710]: CombinerParameterfNV (will be remapped) */ + "if\0" + "glCombinerParameterfNV\0" + "\0" + /* _mesa_function_pool[32737]: IndexMask (offset 212) */ + "i\0" + "glIndexMask\0" + "\0" + /* _mesa_function_pool[32752]: BindProgramNV (will be remapped) */ + "ii\0" + "glBindProgramARB\0" + "glBindProgramNV\0" + "\0" + /* _mesa_function_pool[32789]: VertexAttrib4svARB (will be remapped) */ + "ip\0" + "glVertexAttrib4sv\0" + "glVertexAttrib4svARB\0" + "\0" + /* _mesa_function_pool[32832]: GetFloatv (offset 262) */ + "ip\0" + "glGetFloatv\0" + "\0" + /* _mesa_function_pool[32848]: CreateDebugObjectMESA (dynamic) */ + "\0" + "glCreateDebugObjectMESA\0" + "\0" + /* _mesa_function_pool[32874]: GetShaderiv (will be remapped) */ + "iip\0" + "glGetShaderiv\0" + "\0" + /* _mesa_function_pool[32893]: ClientWaitSync (will be remapped) */ + "iii\0" + "glClientWaitSync\0" + "\0" + /* _mesa_function_pool[32915]: TexCoord4s (offset 124) */ + "iiii\0" + "glTexCoord4s\0" + "\0" + /* _mesa_function_pool[32934]: TexCoord3sv (offset 117) */ + "p\0" + "glTexCoord3sv\0" + "\0" + /* _mesa_function_pool[32951]: BindFragmentShaderATI (will be remapped) */ + "i\0" + "glBindFragmentShaderATI\0" + "\0" + /* _mesa_function_pool[32978]: PopAttrib (offset 218) */ + "\0" + "glPopAttrib\0" + "\0" + /* _mesa_function_pool[32992]: Fogfv (offset 154) */ + "ip\0" + "glFogfv\0" + "\0" + /* _mesa_function_pool[33004]: UnmapBufferARB (will be remapped) */ + "i\0" + "glUnmapBuffer\0" + "glUnmapBufferARB\0" + "\0" + /* _mesa_function_pool[33038]: InitNames (offset 197) */ + "\0" + "glInitNames\0" + "\0" + /* _mesa_function_pool[33052]: Normal3sv (offset 61) */ + "p\0" + "glNormal3sv\0" + "\0" + /* _mesa_function_pool[33067]: Minmax (offset 368) */ + "iii\0" + "glMinmax\0" + "glMinmaxEXT\0" + "\0" + /* _mesa_function_pool[33093]: TexCoord4d (offset 118) */ + "dddd\0" + "glTexCoord4d\0" + "\0" + /* _mesa_function_pool[33112]: TexCoord4f (offset 120) */ + "ffff\0" + "glTexCoord4f\0" + "\0" + /* _mesa_function_pool[33131]: FogCoorddvEXT (will be remapped) */ + "p\0" + "glFogCoorddv\0" + "glFogCoorddvEXT\0" + "\0" + /* _mesa_function_pool[33163]: FinishTextureSUNX (dynamic) */ + "\0" + "glFinishTextureSUNX\0" + "\0" + /* _mesa_function_pool[33185]: GetFragmentLightfvSGIX (dynamic) */ + "iip\0" + "glGetFragmentLightfvSGIX\0" + "\0" + /* _mesa_function_pool[33215]: Binormal3fvEXT (dynamic) */ + "p\0" + "glBinormal3fvEXT\0" + "\0" + /* _mesa_function_pool[33235]: GetBooleanv (offset 258) */ + "ip\0" + "glGetBooleanv\0" + "\0" + /* _mesa_function_pool[33253]: ColorFragmentOp3ATI (will be remapped) */ + "iiiiiiiiiiiii\0" + "glColorFragmentOp3ATI\0" + "\0" + /* _mesa_function_pool[33290]: Hint (offset 158) */ + "ii\0" + "glHint\0" + "\0" + /* _mesa_function_pool[33301]: Color4dv (offset 28) */ + "p\0" + "glColor4dv\0" + "\0" + /* _mesa_function_pool[33315]: VertexAttrib2svARB (will be remapped) */ + "ip\0" + "glVertexAttrib2sv\0" + "glVertexAttrib2svARB\0" + "\0" + /* _mesa_function_pool[33358]: AreProgramsResidentNV (will be remapped) */ + "ipp\0" + "glAreProgramsResidentNV\0" + "\0" + /* _mesa_function_pool[33387]: WindowPos3svMESA (will be remapped) */ + "p\0" + "glWindowPos3sv\0" + "glWindowPos3svARB\0" + "glWindowPos3svMESA\0" + "\0" + /* _mesa_function_pool[33442]: CopyColorSubTable (offset 347) */ + "iiiii\0" + "glCopyColorSubTable\0" + "glCopyColorSubTableEXT\0" + "\0" + /* _mesa_function_pool[33492]: WeightdvARB (dynamic) */ + "ip\0" + "glWeightdvARB\0" + "\0" + /* _mesa_function_pool[33510]: DeleteRenderbuffersEXT (will be remapped) */ + "ip\0" + "glDeleteRenderbuffers\0" + "glDeleteRenderbuffersEXT\0" + "\0" + /* _mesa_function_pool[33561]: VertexAttrib4NubvARB (will be remapped) */ + "ip\0" + "glVertexAttrib4Nubv\0" + "glVertexAttrib4NubvARB\0" + "\0" + /* _mesa_function_pool[33608]: VertexAttrib3dvNV (will be remapped) */ + "ip\0" + "glVertexAttrib3dvNV\0" + "\0" + /* _mesa_function_pool[33632]: GetObjectParameterfvARB (will be remapped) */ + "iip\0" + "glGetObjectParameterfvARB\0" + "\0" + /* _mesa_function_pool[33663]: Vertex4iv (offset 147) */ + "p\0" + "glVertex4iv\0" + "\0" + /* _mesa_function_pool[33678]: GetProgramEnvParameterdvARB (will be remapped) */ + "iip\0" + "glGetProgramEnvParameterdvARB\0" + "\0" + /* _mesa_function_pool[33713]: TexCoord4dv (offset 119) */ + "p\0" + "glTexCoord4dv\0" + "\0" + /* _mesa_function_pool[33730]: LockArraysEXT (will be remapped) */ + "ii\0" + "glLockArraysEXT\0" + "\0" + /* _mesa_function_pool[33750]: Begin (offset 7) */ + "i\0" + "glBegin\0" + "\0" + /* _mesa_function_pool[33761]: LightModeli (offset 165) */ + "ii\0" + "glLightModeli\0" + "\0" + /* _mesa_function_pool[33779]: VertexAttribI4ivEXT (will be remapped) */ + "ip\0" + "glVertexAttribI4ivEXT\0" + "glVertexAttribI4iv\0" + "\0" + /* _mesa_function_pool[33824]: Rectfv (offset 89) */ + "pp\0" + "glRectfv\0" + "\0" + /* _mesa_function_pool[33837]: BlendEquationSeparateiARB (will be remapped) */ + "iii\0" + "glBlendEquationSeparateiARB\0" + "glBlendEquationSeparateIndexedAMD\0" + "\0" + /* _mesa_function_pool[33904]: LightModelf (offset 163) */ + "if\0" + "glLightModelf\0" + "\0" + /* _mesa_function_pool[33922]: GetTexParameterfv (offset 282) */ + "iip\0" + "glGetTexParameterfv\0" + "\0" + /* _mesa_function_pool[33947]: GetLightfv (offset 264) */ + "iip\0" + "glGetLightfv\0" + "\0" + /* _mesa_function_pool[33965]: PixelTransformParameterivEXT (dynamic) */ + "iip\0" + "glPixelTransformParameterivEXT\0" + "\0" + /* _mesa_function_pool[34001]: BinormalPointerEXT (dynamic) */ + "iip\0" + "glBinormalPointerEXT\0" + "\0" + /* _mesa_function_pool[34027]: VertexAttrib1dNV (will be remapped) */ + "id\0" + "glVertexAttrib1dNV\0" + "\0" + /* _mesa_function_pool[34050]: GetCombinerInputParameterivNV (will be remapped) */ + "iiiip\0" + "glGetCombinerInputParameterivNV\0" + "\0" + /* _mesa_function_pool[34089]: Disable (offset 214) */ + "i\0" + "glDisable\0" + "\0" + /* _mesa_function_pool[34102]: MultiTexCoord2fvARB (offset 387) */ + "ip\0" + "glMultiTexCoord2fv\0" + "glMultiTexCoord2fvARB\0" + "\0" + /* _mesa_function_pool[34147]: GetRenderbufferParameterivEXT (will be remapped) */ + "iip\0" + "glGetRenderbufferParameteriv\0" + "glGetRenderbufferParameterivEXT\0" + "\0" + /* _mesa_function_pool[34213]: CombinerParameterivNV (will be remapped) */ + "ip\0" + "glCombinerParameterivNV\0" + "\0" + /* _mesa_function_pool[34241]: GenFragmentShadersATI (will be remapped) */ + "i\0" + "glGenFragmentShadersATI\0" + "\0" + /* _mesa_function_pool[34268]: DrawArrays (offset 310) */ + "iii\0" + "glDrawArrays\0" + "glDrawArraysEXT\0" + "\0" + /* _mesa_function_pool[34302]: WeightuivARB (dynamic) */ + "ip\0" + "glWeightuivARB\0" + "\0" + /* _mesa_function_pool[34321]: GetVertexAttribIivEXT (will be remapped) */ + "iip\0" + "glGetVertexAttribIivEXT\0" + "glGetVertexAttribIiv\0" + "\0" + /* _mesa_function_pool[34371]: VertexAttrib2sARB (will be remapped) */ + "iii\0" + "glVertexAttrib2s\0" + "glVertexAttrib2sARB\0" + "\0" + /* _mesa_function_pool[34413]: GetnTexImageARB (will be remapped) */ + "iiiiip\0" + "glGetnTexImageARB\0" + "\0" + /* _mesa_function_pool[34439]: ColorMask (offset 210) */ + "iiii\0" + "glColorMask\0" + "\0" + /* _mesa_function_pool[34457]: GenAsyncMarkersSGIX (dynamic) */ + "i\0" + "glGenAsyncMarkersSGIX\0" + "\0" + /* _mesa_function_pool[34482]: Tangent3svEXT (dynamic) */ + "p\0" + "glTangent3svEXT\0" + "\0" + /* _mesa_function_pool[34501]: GetListParameterivSGIX (dynamic) */ + "iip\0" + "glGetListParameterivSGIX\0" + "\0" + /* _mesa_function_pool[34531]: BindBufferARB (will be remapped) */ + "ii\0" + "glBindBuffer\0" + "glBindBufferARB\0" + "\0" + /* _mesa_function_pool[34564]: GetInfoLogARB (will be remapped) */ + "iipp\0" + "glGetInfoLogARB\0" + "\0" + /* _mesa_function_pool[34586]: RasterPos4iv (offset 83) */ + "p\0" + "glRasterPos4iv\0" + "\0" + /* _mesa_function_pool[34604]: Enable (offset 215) */ + "i\0" + "glEnable\0" + "\0" + /* _mesa_function_pool[34616]: LineStipple (offset 167) */ + "ii\0" + "glLineStipple\0" + "\0" + /* _mesa_function_pool[34634]: VertexAttribP2ui (will be remapped) */ + "iiii\0" + "glVertexAttribP2ui\0" + "\0" + /* _mesa_function_pool[34659]: VertexAttribs4svNV (will be remapped) */ + "iip\0" + "glVertexAttribs4svNV\0" + "\0" + /* _mesa_function_pool[34685]: EdgeFlagPointerListIBM (dynamic) */ + "ipi\0" + "glEdgeFlagPointerListIBM\0" + "\0" + /* _mesa_function_pool[34715]: UniformMatrix3x2fv (will be remapped) */ + "iiip\0" + "glUniformMatrix3x2fv\0" + "\0" + /* _mesa_function_pool[34742]: GetMinmaxParameterfv (offset 365) */ + "iip\0" + "glGetMinmaxParameterfv\0" + "glGetMinmaxParameterfvEXT\0" + "\0" + /* _mesa_function_pool[34796]: VertexAttrib1fvARB (will be remapped) */ + "ip\0" + "glVertexAttrib1fv\0" + "glVertexAttrib1fvARB\0" + "\0" + /* _mesa_function_pool[34839]: GenBuffersARB (will be remapped) */ + "ip\0" + "glGenBuffers\0" + "glGenBuffersARB\0" + "\0" + /* _mesa_function_pool[34872]: VertexAttribs1svNV (will be remapped) */ + "iip\0" + "glVertexAttribs1svNV\0" + "\0" + /* _mesa_function_pool[34898]: Vertex3fv (offset 137) */ + "p\0" + "glVertex3fv\0" + "\0" + /* _mesa_function_pool[34913]: GetTexBumpParameterivATI (will be remapped) */ + "ip\0" + "glGetTexBumpParameterivATI\0" + "\0" + /* _mesa_function_pool[34944]: Binormal3bEXT (dynamic) */ + "iii\0" + "glBinormal3bEXT\0" + "\0" + /* _mesa_function_pool[34965]: FragmentMaterialivSGIX (dynamic) */ + "iip\0" + "glFragmentMaterialivSGIX\0" + "\0" + /* _mesa_function_pool[34995]: IsRenderbufferEXT (will be remapped) */ + "i\0" + "glIsRenderbuffer\0" + "glIsRenderbufferEXT\0" + "\0" + /* _mesa_function_pool[35035]: GenProgramsNV (will be remapped) */ + "ip\0" + "glGenProgramsARB\0" + "glGenProgramsNV\0" + "\0" + /* _mesa_function_pool[35072]: VertexAttrib4dvNV (will be remapped) */ + "ip\0" + "glVertexAttrib4dvNV\0" + "\0" + /* _mesa_function_pool[35096]: EndFragmentShaderATI (will be remapped) */ + "\0" + "glEndFragmentShaderATI\0" + "\0" + /* _mesa_function_pool[35121]: Binormal3iEXT (dynamic) */ + "iii\0" + "glBinormal3iEXT\0" + "\0" + /* _mesa_function_pool[35142]: WindowPos2fMESA (will be remapped) */ + "ff\0" + "glWindowPos2f\0" + "glWindowPos2fARB\0" + "glWindowPos2fMESA\0" + "\0" + ; + +/* these functions need to be remapped */ +static const struct gl_function_pool_remap MESA_remap_table_functions[] = { + { 1629, AttachShader_remap_index }, + { 10613, CreateProgram_remap_index }, + { 24486, CreateShader_remap_index }, + { 27060, DeleteProgram_remap_index }, + { 19799, DeleteShader_remap_index }, + { 24979, DetachShader_remap_index }, + { 19046, GetAttachedShaders_remap_index }, + { 5341, GetProgramInfoLog_remap_index }, + { 444, GetProgramiv_remap_index }, + { 7189, GetShaderInfoLog_remap_index }, + { 32874, GetShaderiv_remap_index }, + { 14162, IsProgram_remap_index }, + { 13063, IsShader_remap_index }, + { 10743, StencilFuncSeparate_remap_index }, + { 4371, StencilMaskSeparate_remap_index }, + { 8254, StencilOpSeparate_remap_index }, + { 23720, UniformMatrix2x3fv_remap_index }, + { 3098, UniformMatrix2x4fv_remap_index }, + { 34715, UniformMatrix3x2fv_remap_index }, + { 32174, UniformMatrix3x4fv_remap_index }, + { 17220, UniformMatrix4x2fv_remap_index }, + { 3589, UniformMatrix4x3fv_remap_index }, + { 5564, ClampColor_remap_index }, + { 19100, ClearBufferfi_remap_index }, + { 18516, ClearBufferfv_remap_index }, + { 31154, ClearBufferiv_remap_index }, + { 14367, ClearBufferuiv_remap_index }, + { 21222, GetStringi_remap_index }, + { 3000, TexBuffer_remap_index }, + { 977, FramebufferTexture_remap_index }, + { 28096, GetBufferParameteri64v_remap_index }, + { 10843, GetInteger64i_v_remap_index }, + { 24800, VertexAttribDivisor_remap_index }, + { 10631, LoadTransposeMatrixdARB_remap_index }, + { 32603, LoadTransposeMatrixfARB_remap_index }, + { 6249, MultTransposeMatrixdARB_remap_index }, + { 25166, MultTransposeMatrixfARB_remap_index }, + { 255, SampleCoverageARB_remap_index }, + { 6452, CompressedTexImage1DARB_remap_index }, + { 25694, CompressedTexImage2DARB_remap_index }, + { 4434, CompressedTexImage3DARB_remap_index }, + { 19388, CompressedTexSubImage1DARB_remap_index }, + { 2185, CompressedTexSubImage2DARB_remap_index }, + { 21644, CompressedTexSubImage3DARB_remap_index }, + { 30260, GetCompressedTexImageARB_remap_index }, + { 4181, DisableVertexAttribArrayARB_remap_index }, + { 31739, EnableVertexAttribArrayARB_remap_index }, + { 33678, GetProgramEnvParameterdvARB_remap_index }, + { 25046, GetProgramEnvParameterfvARB_remap_index }, + { 29125, GetProgramLocalParameterdvARB_remap_index }, + { 8730, GetProgramLocalParameterfvARB_remap_index }, + { 19564, GetProgramStringARB_remap_index }, + { 29320, GetProgramivARB_remap_index }, + { 21839, GetVertexAttribdvARB_remap_index }, + { 17028, GetVertexAttribfvARB_remap_index }, + { 10422, GetVertexAttribivARB_remap_index }, + { 20659, ProgramEnvParameter4dARB_remap_index }, + { 26810, ProgramEnvParameter4dvARB_remap_index }, + { 17814, ProgramEnvParameter4fARB_remap_index }, + { 9605, ProgramEnvParameter4fvARB_remap_index }, + { 4397, ProgramLocalParameter4dARB_remap_index }, + { 13872, ProgramLocalParameter4dvARB_remap_index }, + { 31175, ProgramLocalParameter4fARB_remap_index }, + { 27456, ProgramLocalParameter4fvARB_remap_index }, + { 30014, ProgramStringARB_remap_index }, + { 20953, VertexAttrib1dARB_remap_index }, + { 16629, VertexAttrib1dvARB_remap_index }, + { 4593, VertexAttrib1fARB_remap_index }, + { 34796, VertexAttrib1fvARB_remap_index }, + { 7780, VertexAttrib1sARB_remap_index }, + { 2380, VertexAttrib1svARB_remap_index }, + { 16042, VertexAttrib2dARB_remap_index }, + { 18537, VertexAttrib2dvARB_remap_index }, + { 1712, VertexAttrib2fARB_remap_index }, + { 18650, VertexAttrib2fvARB_remap_index }, + { 34371, VertexAttrib2sARB_remap_index }, + { 33315, VertexAttrib2svARB_remap_index }, + { 12047, VertexAttrib3dARB_remap_index }, + { 9272, VertexAttrib3dvARB_remap_index }, + { 1799, VertexAttrib3fARB_remap_index }, + { 24037, VertexAttrib3fvARB_remap_index }, + { 29861, VertexAttrib3sARB_remap_index }, + { 21581, VertexAttrib3svARB_remap_index }, + { 5384, VertexAttrib4NbvARB_remap_index }, + { 18923, VertexAttrib4NivARB_remap_index }, + { 23992, VertexAttrib4NsvARB_remap_index }, + { 24998, VertexAttrib4NubARB_remap_index }, + { 33561, VertexAttrib4NubvARB_remap_index }, + { 20310, VertexAttrib4NuivARB_remap_index }, + { 3419, VertexAttrib4NusvARB_remap_index }, + { 11636, VertexAttrib4bvARB_remap_index }, + { 28498, VertexAttrib4dARB_remap_index }, + { 22654, VertexAttrib4dvARB_remap_index }, + { 12201, VertexAttrib4fARB_remap_index }, + { 12605, VertexAttrib4fvARB_remap_index }, + { 10986, VertexAttrib4ivARB_remap_index }, + { 18330, VertexAttrib4sARB_remap_index }, + { 32789, VertexAttrib4svARB_remap_index }, + { 17619, VertexAttrib4ubvARB_remap_index }, + { 32063, VertexAttrib4uivARB_remap_index }, + { 21392, VertexAttrib4usvARB_remap_index }, + { 23515, VertexAttribPointerARB_remap_index }, + { 34531, BindBufferARB_remap_index }, + { 7487, BufferDataARB_remap_index }, + { 1550, BufferSubDataARB_remap_index }, + { 32349, DeleteBuffersARB_remap_index }, + { 34839, GenBuffersARB_remap_index }, + { 18693, GetBufferParameterivARB_remap_index }, + { 17766, GetBufferPointervARB_remap_index }, + { 1503, GetBufferSubDataARB_remap_index }, + { 32011, IsBufferARB_remap_index }, + { 27940, MapBufferARB_remap_index }, + { 33004, UnmapBufferARB_remap_index }, + { 351, BeginQueryARB_remap_index }, + { 21048, DeleteQueriesARB_remap_index }, + { 12924, EndQueryARB_remap_index }, + { 30739, GenQueriesARB_remap_index }, + { 2077, GetQueryObjectivARB_remap_index }, + { 18374, GetQueryObjectuivARB_remap_index }, + { 1856, GetQueryivARB_remap_index }, + { 21299, IsQueryARB_remap_index }, + { 8882, AttachObjectARB_remap_index }, + { 19761, CompileShaderARB_remap_index }, + { 3531, CreateProgramObjectARB_remap_index }, + { 7432, CreateShaderObjectARB_remap_index }, + { 15325, DeleteObjectARB_remap_index }, + { 25485, DetachObjectARB_remap_index }, + { 12669, GetActiveUniformARB_remap_index }, + { 10097, GetAttachedObjectsARB_remap_index }, + { 10404, GetHandleARB_remap_index }, + { 34564, GetInfoLogARB_remap_index }, + { 33632, GetObjectParameterfvARB_remap_index }, + { 28999, GetObjectParameterivARB_remap_index }, + { 30497, GetShaderSourceARB_remap_index }, + { 29721, GetUniformLocationARB_remap_index }, + { 25268, GetUniformfvARB_remap_index }, + { 13447, GetUniformivARB_remap_index }, + { 21437, LinkProgramARB_remap_index }, + { 21495, ShaderSourceARB_remap_index }, + { 8154, Uniform1fARB_remap_index }, + { 31401, Uniform1fvARB_remap_index }, + { 23463, Uniform1iARB_remap_index }, + { 22292, Uniform1ivARB_remap_index }, + { 2329, Uniform2fARB_remap_index }, + { 15161, Uniform2fvARB_remap_index }, + { 27827, Uniform2iARB_remap_index }, + { 2466, Uniform2ivARB_remap_index }, + { 19871, Uniform3fARB_remap_index }, + { 10127, Uniform3fvARB_remap_index }, + { 7043, Uniform3iARB_remap_index }, + { 17872, Uniform3ivARB_remap_index }, + { 20465, Uniform4fARB_remap_index }, + { 25132, Uniform4fvARB_remap_index }, + { 26419, Uniform4iARB_remap_index }, + { 21805, Uniform4ivARB_remap_index }, + { 8934, UniformMatrix2fvARB_remap_index }, + { 17, UniformMatrix3fvARB_remap_index }, + { 2902, UniformMatrix4fvARB_remap_index }, + { 26922, UseProgramObjectARB_remap_index }, + { 15730, ValidateProgramARB_remap_index }, + { 22697, BindAttribLocationARB_remap_index }, + { 5429, GetActiveAttribARB_remap_index }, + { 17553, GetAttribLocationARB_remap_index }, + { 31102, DrawBuffersARB_remap_index }, + { 30935, ClampColorARB_remap_index }, + { 18968, DrawArraysInstancedARB_remap_index }, + { 7104, DrawElementsInstancedARB_remap_index }, + { 13977, RenderbufferStorageMultisample_remap_index }, + { 14448, FramebufferTextureARB_remap_index }, + { 27358, FramebufferTextureFaceARB_remap_index }, + { 25634, ProgramParameteriARB_remap_index }, + { 6624, VertexAttribDivisorARB_remap_index }, + { 20513, FlushMappedBufferRange_remap_index }, + { 29436, MapBufferRange_remap_index }, + { 29343, TexBufferARB_remap_index }, + { 17358, BindVertexArray_remap_index }, + { 15534, GenVertexArrays_remap_index }, + { 31941, CopyBufferSubData_remap_index }, + { 32893, ClientWaitSync_remap_index }, + { 2821, DeleteSync_remap_index }, + { 7821, FenceSync_remap_index }, + { 16101, GetInteger64v_remap_index }, + { 24099, GetSynciv_remap_index }, + { 31041, IsSync_remap_index }, + { 10028, WaitSync_remap_index }, + { 4149, DrawElementsBaseVertex_remap_index }, + { 19616, DrawElementsInstancedBaseVertex_remap_index }, + { 32253, DrawRangeElementsBaseVertex_remap_index }, + { 27971, MultiDrawElementsBaseVertex_remap_index }, + { 33837, BlendEquationSeparateiARB_remap_index }, + { 18786, BlendEquationiARB_remap_index }, + { 13386, BlendFuncSeparateiARB_remap_index }, + { 10470, BlendFunciARB_remap_index }, + { 8796, BindSampler_remap_index }, + { 4572, DeleteSamplers_remap_index }, + { 20886, GenSamplers_remap_index }, + { 30973, GetSamplerParameterIiv_remap_index }, + { 20407, GetSamplerParameterIuiv_remap_index }, + { 5261, GetSamplerParameterfv_remap_index }, + { 27079, GetSamplerParameteriv_remap_index }, + { 15079, IsSampler_remap_index }, + { 17311, SamplerParameterIiv_remap_index }, + { 32292, SamplerParameterIuiv_remap_index }, + { 23772, SamplerParameterf_remap_index }, + { 17485, SamplerParameterfv_remap_index }, + { 23747, SamplerParameteri_remap_index }, + { 19162, SamplerParameteriv_remap_index }, + { 19969, ColorP3ui_remap_index }, + { 32540, ColorP3uiv_remap_index }, + { 22398, ColorP4ui_remap_index }, + { 4339, ColorP4uiv_remap_index }, + { 26621, MultiTexCoordP1ui_remap_index }, + { 13360, MultiTexCoordP1uiv_remap_index }, + { 1687, MultiTexCoordP2ui_remap_index }, + { 31713, MultiTexCoordP2uiv_remap_index }, + { 14691, MultiTexCoordP3ui_remap_index }, + { 11062, MultiTexCoordP3uiv_remap_index }, + { 23296, MultiTexCoordP4ui_remap_index }, + { 4011, MultiTexCoordP4uiv_remap_index }, + { 31384, NormalP3ui_remap_index }, + { 20145, NormalP3uiv_remap_index }, + { 26324, SecondaryColorP3ui_remap_index }, + { 20163, SecondaryColorP3uiv_remap_index }, + { 2802, TexCoordP1ui_remap_index }, + { 2569, TexCoordP1uiv_remap_index }, + { 15610, TexCoordP2ui_remap_index }, + { 23321, TexCoordP2uiv_remap_index }, + { 6331, TexCoordP3ui_remap_index }, + { 23700, TexCoordP3uiv_remap_index }, + { 1985, TexCoordP4ui_remap_index }, + { 5833, TexCoordP4uiv_remap_index }, + { 10513, VertexAttribP1ui_remap_index }, + { 14878, VertexAttribP1uiv_remap_index }, + { 34634, VertexAttribP2ui_remap_index }, + { 5625, VertexAttribP2uiv_remap_index }, + { 3484, VertexAttribP3ui_remap_index }, + { 20904, VertexAttribP3uiv_remap_index }, + { 14904, VertexAttribP4ui_remap_index }, + { 16886, VertexAttribP4uiv_remap_index }, + { 5367, VertexP2ui_remap_index }, + { 16456, VertexP2uiv_remap_index }, + { 2449, VertexP3ui_remap_index }, + { 17406, VertexP3uiv_remap_index }, + { 10056, VertexP4ui_remap_index }, + { 3466, VertexP4uiv_remap_index }, + { 5651, BindTransformFeedback_remap_index }, + { 3558, DeleteTransformFeedbacks_remap_index }, + { 7076, DrawTransformFeedback_remap_index }, + { 10264, GenTransformFeedbacks_remap_index }, + { 29904, IsTransformFeedback_remap_index }, + { 27551, PauseTransformFeedback_remap_index }, + { 6134, ResumeTransformFeedback_remap_index }, + { 23017, ClearDepthf_remap_index }, + { 7380, DepthRangef_remap_index }, + { 15346, GetShaderPrecisionFormat_remap_index }, + { 10683, ReleaseShaderCompiler_remap_index }, + { 11679, ShaderBinary_remap_index }, + { 1004, GetGraphicsResetStatusARB_remap_index }, + { 26199, GetnColorTableARB_remap_index }, + { 8565, GetnCompressedTexImageARB_remap_index }, + { 4288, GetnConvolutionFilterARB_remap_index }, + { 16672, GetnHistogramARB_remap_index }, + { 24958, GetnMapdvARB_remap_index }, + { 23494, GetnMapfvARB_remap_index }, + { 2308, GetnMapivARB_remap_index }, + { 18134, GetnMinmaxARB_remap_index }, + { 4886, GetnPixelMapfvARB_remap_index }, + { 20284, GetnPixelMapuivARB_remap_index }, + { 3211, GetnPixelMapusvARB_remap_index }, + { 1383, GetnPolygonStippleARB_remap_index }, + { 22482, GetnSeparableFilterARB_remap_index }, + { 34413, GetnTexImageARB_remap_index }, + { 19591, GetnUniformdvARB_remap_index }, + { 4958, GetnUniformfvARB_remap_index }, + { 10538, GetnUniformivARB_remap_index }, + { 23948, GetnUniformuivARB_remap_index }, + { 3125, ReadnPixelsARB_remap_index }, + { 6002, PolygonOffsetEXT_remap_index }, + { 24721, GetPixelTexGenParameterfvSGIS_remap_index }, + { 4836, GetPixelTexGenParameterivSGIS_remap_index }, + { 24454, PixelTexGenParameterfSGIS_remap_index }, + { 663, PixelTexGenParameterfvSGIS_remap_index }, + { 13485, PixelTexGenParameteriSGIS_remap_index }, + { 14590, PixelTexGenParameterivSGIS_remap_index }, + { 19287, SampleMaskSGIS_remap_index }, + { 21239, SamplePatternSGIS_remap_index }, + { 27900, ColorPointerEXT_remap_index }, + { 18580, EdgeFlagPointerEXT_remap_index }, + { 6697, IndexPointerEXT_remap_index }, + { 6777, NormalPointerEXT_remap_index }, + { 16740, TexCoordPointerEXT_remap_index }, + { 7610, VertexPointerEXT_remap_index }, + { 3925, PointParameterfEXT_remap_index }, + { 8461, PointParameterfvEXT_remap_index }, + { 33730, LockArraysEXT_remap_index }, + { 15794, UnlockArraysEXT_remap_index }, + { 1291, SecondaryColor3bEXT_remap_index }, + { 8654, SecondaryColor3bvEXT_remap_index }, + { 11189, SecondaryColor3dEXT_remap_index }, + { 27128, SecondaryColor3dvEXT_remap_index }, + { 29770, SecondaryColor3fEXT_remap_index }, + { 19324, SecondaryColor3fvEXT_remap_index }, + { 509, SecondaryColor3iEXT_remap_index }, + { 17076, SecondaryColor3ivEXT_remap_index }, + { 10771, SecondaryColor3sEXT_remap_index }, + { 32557, SecondaryColor3svEXT_remap_index }, + { 28835, SecondaryColor3ubEXT_remap_index }, + { 22588, SecondaryColor3ubvEXT_remap_index }, + { 13727, SecondaryColor3uiEXT_remap_index }, + { 24341, SecondaryColor3uivEXT_remap_index }, + { 27408, SecondaryColor3usEXT_remap_index }, + { 13800, SecondaryColor3usvEXT_remap_index }, + { 12548, SecondaryColorPointerEXT_remap_index }, + { 27222, MultiDrawArraysEXT_remap_index }, + { 22227, MultiDrawElementsEXT_remap_index }, + { 22438, FogCoordPointerEXT_remap_index }, + { 5009, FogCoorddEXT_remap_index }, + { 33131, FogCoorddvEXT_remap_index }, + { 5126, FogCoordfEXT_remap_index }, + { 28758, FogCoordfvEXT_remap_index }, + { 12648, PixelTexGenSGIX_remap_index }, + { 29363, BlendFuncSeparateEXT_remap_index }, + { 7522, FlushVertexArrayRangeNV_remap_index }, + { 5951, VertexArrayRangeNV_remap_index }, + { 29835, CombinerInputNV_remap_index }, + { 2251, CombinerOutputNV_remap_index }, + { 32710, CombinerParameterfNV_remap_index }, + { 5805, CombinerParameterfvNV_remap_index }, + { 23797, CombinerParameteriNV_remap_index }, + { 34213, CombinerParameterivNV_remap_index }, + { 7898, FinalCombinerInputNV_remap_index }, + { 1648, GetCombinerInputParameterfvNV_remap_index }, + { 34050, GetCombinerInputParameterivNV_remap_index }, + { 216, GetCombinerOutputParameterfvNV_remap_index }, + { 14551, GetCombinerOutputParameterivNV_remap_index }, + { 7284, GetFinalCombinerInputParameterfvNV_remap_index }, + { 26266, GetFinalCombinerInputParameterivNV_remap_index }, + { 13338, ResizeBuffersMESA_remap_index }, + { 11874, WindowPos2dMESA_remap_index }, + { 1084, WindowPos2dvMESA_remap_index }, + { 35142, WindowPos2fMESA_remap_index }, + { 8599, WindowPos2fvMESA_remap_index }, + { 19234, WindowPos2iMESA_remap_index }, + { 21712, WindowPos2ivMESA_remap_index }, + { 22326, WindowPos2sMESA_remap_index }, + { 6366, WindowPos2svMESA_remap_index }, + { 8390, WindowPos3dMESA_remap_index }, + { 14823, WindowPos3dvMESA_remap_index }, + { 555, WindowPos3fMESA_remap_index }, + { 15855, WindowPos3fvMESA_remap_index }, + { 25527, WindowPos3iMESA_remap_index }, + { 31886, WindowPos3ivMESA_remap_index }, + { 20032, WindowPos3sMESA_remap_index }, + { 33387, WindowPos3svMESA_remap_index }, + { 11825, WindowPos4dMESA_remap_index }, + { 18010, WindowPos4dvMESA_remap_index }, + { 14782, WindowPos4fMESA_remap_index }, + { 32447, WindowPos4fvMESA_remap_index }, + { 32039, WindowPos4iMESA_remap_index }, + { 13177, WindowPos4ivMESA_remap_index }, + { 20260, WindowPos4sMESA_remap_index }, + { 3509, WindowPos4svMESA_remap_index }, + { 28466, MultiModeDrawArraysIBM_remap_index }, + { 30610, MultiModeDrawElementsIBM_remap_index }, + { 12952, DeleteFencesNV_remap_index }, + { 29682, FinishFenceNV_remap_index }, + { 4073, GenFencesNV_remap_index }, + { 17990, GetFenceivNV_remap_index }, + { 8867, IsFenceNV_remap_index }, + { 14478, SetFenceNV_remap_index }, + { 4649, TestFenceNV_remap_index }, + { 33358, AreProgramsResidentNV_remap_index }, + { 32752, BindProgramNV_remap_index }, + { 27491, DeleteProgramsNV_remap_index }, + { 22806, ExecuteProgramNV_remap_index }, + { 35035, GenProgramsNV_remap_index }, + { 24826, GetProgramParameterdvNV_remap_index }, + { 11251, GetProgramParameterfvNV_remap_index }, + { 27874, GetProgramStringNV_remap_index }, + { 25904, GetProgramivNV_remap_index }, + { 25081, GetTrackMatrixivNV_remap_index }, + { 27668, GetVertexAttribPointervNV_remap_index }, + { 10866, GetVertexAttribdvNV_remap_index }, + { 9923, GetVertexAttribfvNV_remap_index }, + { 19537, GetVertexAttribivNV_remap_index }, + { 20543, IsProgramNV_remap_index }, + { 10006, LoadProgramNV_remap_index }, + { 29459, ProgramParameters4dvNV_remap_index }, + { 25834, ProgramParameters4fvNV_remap_index }, + { 22016, RequestResidentProgramsNV_remap_index }, + { 32231, TrackMatrixNV_remap_index }, + { 34027, VertexAttrib1dNV_remap_index }, + { 14389, VertexAttrib1dvNV_remap_index }, + { 30116, VertexAttrib1fNV_remap_index }, + { 2608, VertexAttrib1fvNV_remap_index }, + { 32504, VertexAttrib1sNV_remap_index }, + { 15928, VertexAttrib1svNV_remap_index }, + { 5317, VertexAttrib2dNV_remap_index }, + { 14282, VertexAttrib2dvNV_remap_index }, + { 21471, VertexAttrib2fNV_remap_index }, + { 13848, VertexAttrib2fvNV_remap_index }, + { 6578, VertexAttrib2sNV_remap_index }, + { 20086, VertexAttrib2svNV_remap_index }, + { 12022, VertexAttrib3dNV_remap_index }, + { 33608, VertexAttrib3dvNV_remap_index }, + { 11037, VertexAttrib3fNV_remap_index }, + { 26226, VertexAttrib3fvNV_remap_index }, + { 23570, VertexAttrib3sNV_remap_index }, + { 25108, VertexAttrib3svNV_remap_index }, + { 30584, VertexAttrib4dNV_remap_index }, + { 35072, VertexAttrib4dvNV_remap_index }, + { 5745, VertexAttrib4fNV_remap_index }, + { 10073, VertexAttrib4fvNV_remap_index }, + { 28350, VertexAttrib4sNV_remap_index }, + { 1461, VertexAttrib4svNV_remap_index }, + { 5492, VertexAttrib4ubNV_remap_index }, + { 817, VertexAttrib4ubvNV_remap_index }, + { 22986, VertexAttribPointerNV_remap_index }, + { 2423, VertexAttribs1dvNV_remap_index }, + { 27756, VertexAttribs1fvNV_remap_index }, + { 34872, VertexAttribs1svNV_remap_index }, + { 11088, VertexAttribs2dvNV_remap_index }, + { 26883, VertexAttribs2fvNV_remap_index }, + { 18606, VertexAttribs2svNV_remap_index }, + { 5853, VertexAttribs3dvNV_remap_index }, + { 2282, VertexAttribs3fvNV_remap_index }, + { 31608, VertexAttribs3svNV_remap_index }, + { 28440, VertexAttribs4dvNV_remap_index }, + { 5925, VertexAttribs4fvNV_remap_index }, + { 34659, VertexAttribs4svNV_remap_index }, + { 31339, VertexAttribs4ubvNV_remap_index }, + { 28542, GetTexBumpParameterfvATI_remap_index }, + { 34913, GetTexBumpParameterivATI_remap_index }, + { 19714, TexBumpParameterfvATI_remap_index }, + { 21887, TexBumpParameterivATI_remap_index }, + { 16492, AlphaFragmentOp1ATI_remap_index }, + { 27174, AlphaFragmentOp2ATI_remap_index }, + { 26142, AlphaFragmentOp3ATI_remap_index }, + { 31535, BeginFragmentShaderATI_remap_index }, + { 32951, BindFragmentShaderATI_remap_index }, + { 25237, ColorFragmentOp1ATI_remap_index }, + { 4764, ColorFragmentOp2ATI_remap_index }, + { 33253, ColorFragmentOp3ATI_remap_index }, + { 6091, DeleteFragmentShaderATI_remap_index }, + { 35096, EndFragmentShaderATI_remap_index }, + { 34241, GenFragmentShadersATI_remap_index }, + { 27037, PassTexCoordATI_remap_index }, + { 7590, SampleMapATI_remap_index }, + { 28653, SetFragmentShaderConstantATI_remap_index }, + { 402, PointParameteriNV_remap_index }, + { 15035, PointParameterivNV_remap_index }, + { 30423, ActiveStencilFaceEXT_remap_index }, + { 29099, BindVertexArrayAPPLE_remap_index }, + { 2949, DeleteVertexArraysAPPLE_remap_index }, + { 19073, GenVertexArraysAPPLE_remap_index }, + { 24891, IsVertexArrayAPPLE_remap_index }, + { 858, GetProgramNamedParameterdvNV_remap_index }, + { 3888, GetProgramNamedParameterfvNV_remap_index }, + { 28573, ProgramNamedParameter4dNV_remap_index }, + { 15409, ProgramNamedParameter4dvNV_remap_index }, + { 9539, ProgramNamedParameter4fNV_remap_index }, + { 12513, ProgramNamedParameter4fvNV_remap_index }, + { 17921, PrimitiveRestartIndexNV_remap_index }, + { 32424, PrimitiveRestartNV_remap_index }, + { 25813, DepthBoundsEXT_remap_index }, + { 1183, BlendEquationSeparateEXT_remap_index }, + { 15629, BindFramebufferEXT_remap_index }, + { 27267, BindRenderbufferEXT_remap_index }, + { 10320, CheckFramebufferStatusEXT_remap_index }, + { 24142, DeleteFramebuffersEXT_remap_index }, + { 33510, DeleteRenderbuffersEXT_remap_index }, + { 14306, FramebufferRenderbufferEXT_remap_index }, + { 14495, FramebufferTexture1DEXT_remap_index }, + { 12307, FramebufferTexture2DEXT_remap_index }, + { 11927, FramebufferTexture3DEXT_remap_index }, + { 24757, GenFramebuffersEXT_remap_index }, + { 18471, GenRenderbuffersEXT_remap_index }, + { 7326, GenerateMipmapEXT_remap_index }, + { 23079, GetFramebufferAttachmentParameterivEXT_remap_index }, + { 34147, GetRenderbufferParameterivEXT_remap_index }, + { 21767, IsFramebufferEXT_remap_index }, + { 34995, IsRenderbufferEXT_remap_index }, + { 8814, RenderbufferStorageEXT_remap_index }, + { 734, BlitFramebufferEXT_remap_index }, + { 15195, BufferParameteriAPPLE_remap_index }, + { 20575, FlushMappedBufferRangeAPPLE_remap_index }, + { 1931, BindFragDataLocationEXT_remap_index }, + { 25926, GetFragDataLocationEXT_remap_index }, + { 11366, GetUniformuivEXT_remap_index }, + { 34321, GetVertexAttribIivEXT_remap_index }, + { 29630, GetVertexAttribIuivEXT_remap_index }, + { 12785, Uniform1uiEXT_remap_index }, + { 29544, Uniform1uivEXT_remap_index }, + { 23666, Uniform2uiEXT_remap_index }, + { 4728, Uniform2uivEXT_remap_index }, + { 30863, Uniform3uiEXT_remap_index }, + { 15556, Uniform3uivEXT_remap_index }, + { 3812, Uniform4uiEXT_remap_index }, + { 9315, Uniform4uivEXT_remap_index }, + { 19452, VertexAttribI1iEXT_remap_index }, + { 5519, VertexAttribI1ivEXT_remap_index }, + { 2709, VertexAttribI1uiEXT_remap_index }, + { 13576, VertexAttribI1uivEXT_remap_index }, + { 81, VertexAttribI2iEXT_remap_index }, + { 25349, VertexAttribI2ivEXT_remap_index }, + { 5879, VertexAttribI2uiEXT_remap_index }, + { 5171, VertexAttribI2uivEXT_remap_index }, + { 28142, VertexAttribI3iEXT_remap_index }, + { 26576, VertexAttribI3ivEXT_remap_index }, + { 3666, VertexAttribI3uiEXT_remap_index }, + { 32127, VertexAttribI3uivEXT_remap_index }, + { 23375, VertexAttribI4bvEXT_remap_index }, + { 15488, VertexAttribI4iEXT_remap_index }, + { 33779, VertexAttribI4ivEXT_remap_index }, + { 14209, VertexAttribI4svEXT_remap_index }, + { 4241, VertexAttribI4ubvEXT_remap_index }, + { 17139, VertexAttribI4uiEXT_remap_index }, + { 6025, VertexAttribI4uivEXT_remap_index }, + { 12090, VertexAttribI4usvEXT_remap_index }, + { 19658, VertexAttribIPointerEXT_remap_index }, + { 3281, FramebufferTextureLayerEXT_remap_index }, + { 17511, ColorMaskIndexedEXT_remap_index }, + { 20110, DisableIndexedEXT_remap_index }, + { 28187, EnableIndexedEXT_remap_index }, + { 23034, GetBooleanIndexedvEXT_remap_index }, + { 11701, GetIntegerIndexedvEXT_remap_index }, + { 24218, IsEnabledIndexedEXT_remap_index }, + { 24118, ClearColorIiEXT_remap_index }, + { 3762, ClearColorIuiEXT_remap_index }, + { 10563, GetTexParameterIivEXT_remap_index }, + { 6526, GetTexParameterIuivEXT_remap_index }, + { 3237, TexParameterIivEXT_remap_index }, + { 28009, TexParameterIuivEXT_remap_index }, + { 5039, BeginConditionalRenderNV_remap_index }, + { 26987, EndConditionalRenderNV_remap_index }, + { 9950, BeginTransformFeedbackEXT_remap_index }, + { 20189, BindBufferBaseEXT_remap_index }, + { 20004, BindBufferOffsetEXT_remap_index }, + { 13002, BindBufferRangeEXT_remap_index }, + { 15110, EndTransformFeedbackEXT_remap_index }, + { 11564, GetTransformFeedbackVaryingEXT_remap_index }, + { 22072, TransformFeedbackVaryingsEXT_remap_index }, + { 31240, ProvokingVertexEXT_remap_index }, + { 11512, GetTexParameterPointervAPPLE_remap_index }, + { 5581, TextureRangeAPPLE_remap_index }, + { 12379, GetObjectParameterivAPPLE_remap_index }, + { 21194, ObjectPurgeableAPPLE_remap_index }, + { 6301, ObjectUnpurgeableAPPLE_remap_index }, + { 18293, ActiveProgramEXT_remap_index }, + { 18264, CreateShaderProgramEXT_remap_index }, + { 30208, UseShaderProgramEXT_remap_index }, + { 17464, TextureBarrierNV_remap_index }, + { 30449, StencilFuncSeparateATI_remap_index }, + { 6214, ProgramEnvParameters4fvEXT_remap_index }, + { 18158, ProgramLocalParameters4fvEXT_remap_index }, + { 14963, GetQueryObjecti64vEXT_remap_index }, + { 11114, GetQueryObjectui64vEXT_remap_index }, + { 25306, EGLImageTargetRenderbufferStorageOES_remap_index }, + { 12891, EGLImageTargetTexture2DOES_remap_index }, + { -1, -1 } +}; + +/* these functions are in the ABI, but have alternative names */ +static const struct gl_function_remap MESA_alt_functions[] = { + /* from GL_EXT_blend_color */ + { 2867, _gloffset_BlendColor }, + /* from GL_EXT_blend_minmax */ + { 11984, _gloffset_BlendEquation }, + /* from GL_EXT_color_subtable */ + { 18032, _gloffset_ColorSubTable }, + { 33442, _gloffset_CopyColorSubTable }, + /* from GL_EXT_convolution */ + { 296, _gloffset_ConvolutionFilter1D }, + { 2647, _gloffset_CopyConvolutionFilter1D }, + { 4508, _gloffset_GetConvolutionParameteriv }, + { 9163, _gloffset_ConvolutionFilter2D }, + { 9365, _gloffset_ConvolutionParameteriv }, + { 9825, _gloffset_ConvolutionParameterfv }, + { 21915, _gloffset_GetSeparableFilter }, + { 25581, _gloffset_SeparableFilter2D }, + { 26469, _gloffset_ConvolutionParameteri }, + { 26662, _gloffset_ConvolutionParameterf }, + { 28376, _gloffset_GetConvolutionParameterfv }, + { 29265, _gloffset_GetConvolutionFilter }, + { 31823, _gloffset_CopyConvolutionFilter2D }, + /* from GL_EXT_copy_texture */ + { 15988, _gloffset_CopyTexSubImage3D }, + { 17719, _gloffset_CopyTexImage2D }, + { 26052, _gloffset_CopyTexImage1D }, + { 28946, _gloffset_CopyTexSubImage2D }, + { 31435, _gloffset_CopyTexSubImage1D }, + /* from GL_EXT_draw_range_elements */ + { 10179, _gloffset_DrawRangeElements }, + /* from GL_EXT_histogram */ + { 895, _gloffset_Histogram }, + { 3848, _gloffset_ResetHistogram }, + { 10709, _gloffset_GetMinmax }, + { 16322, _gloffset_GetHistogramParameterfv }, + { 25977, _gloffset_GetMinmaxParameteriv }, + { 28266, _gloffset_ResetMinmax }, + { 29162, _gloffset_GetHistogramParameteriv }, + { 30383, _gloffset_GetHistogram }, + { 33067, _gloffset_Minmax }, + { 34742, _gloffset_GetMinmaxParameterfv }, + /* from GL_EXT_paletted_texture */ + { 9025, _gloffset_ColorTable }, + { 16168, _gloffset_GetColorTable }, + { 24504, _gloffset_GetColorTableParameterfv }, + { 26718, _gloffset_GetColorTableParameteriv }, + /* from GL_EXT_subtexture */ + { 7736, _gloffset_TexSubImage1D }, + { 11439, _gloffset_TexSubImage2D }, + /* from GL_EXT_texture3D */ + { 1890, _gloffset_TexImage3D }, + { 24273, _gloffset_TexSubImage3D }, + /* from GL_EXT_texture_object */ + { 3616, _gloffset_PrioritizeTextures }, + { 8185, _gloffset_AreTexturesResident }, + { 14413, _gloffset_GenTextures }, + { 16699, _gloffset_DeleteTextures }, + { 20856, _gloffset_IsTexture }, + { 31500, _gloffset_BindTexture }, + /* from GL_EXT_vertex_array */ + { 25753, _gloffset_ArrayElement }, + { 32655, _gloffset_GetPointerv }, + { 34268, _gloffset_DrawArrays }, + /* from GL_SGI_color_table */ + { 8303, _gloffset_ColorTableParameteriv }, + { 9025, _gloffset_ColorTable }, + { 16168, _gloffset_GetColorTable }, + { 16278, _gloffset_CopyColorTable }, + { 20717, _gloffset_ColorTableParameterfv }, + { 24504, _gloffset_GetColorTableParameterfv }, + { 26718, _gloffset_GetColorTableParameteriv }, + /* from GL_VERSION_1_3 */ + { 464, _gloffset_MultiTexCoord3sARB }, + { 696, _gloffset_ActiveTextureARB }, + { 4666, _gloffset_MultiTexCoord1fvARB }, + { 6802, _gloffset_MultiTexCoord3dARB }, + { 6847, _gloffset_MultiTexCoord2iARB }, + { 6971, _gloffset_MultiTexCoord2svARB }, + { 8981, _gloffset_MultiTexCoord2fARB }, + { 11144, _gloffset_MultiTexCoord3fvARB }, + { 11746, _gloffset_MultiTexCoord4sARB }, + { 12427, _gloffset_MultiTexCoord2dvARB }, + { 12834, _gloffset_MultiTexCoord1svARB }, + { 13199, _gloffset_MultiTexCoord3svARB }, + { 13260, _gloffset_MultiTexCoord4iARB }, + { 14117, _gloffset_MultiTexCoord3iARB }, + { 14992, _gloffset_MultiTexCoord1dARB }, + { 15224, _gloffset_MultiTexCoord3dvARB }, + { 16540, _gloffset_MultiTexCoord3ivARB }, + { 16585, _gloffset_MultiTexCoord2sARB }, + { 18089, _gloffset_MultiTexCoord4ivARB }, + { 20357, _gloffset_ClientActiveTextureARB }, + { 22762, _gloffset_MultiTexCoord2dARB }, + { 23199, _gloffset_MultiTexCoord4dvARB }, + { 23621, _gloffset_MultiTexCoord4fvARB }, + { 24645, _gloffset_MultiTexCoord3fARB }, + { 27312, _gloffset_MultiTexCoord4dARB }, + { 27578, _gloffset_MultiTexCoord1sARB }, + { 27782, _gloffset_MultiTexCoord1dvARB }, + { 28790, _gloffset_MultiTexCoord1ivARB }, + { 28883, _gloffset_MultiTexCoord2ivARB }, + { 29222, _gloffset_MultiTexCoord1iARB }, + { 30658, _gloffset_MultiTexCoord4svARB }, + { 31282, _gloffset_MultiTexCoord1fARB }, + { 31562, _gloffset_MultiTexCoord4fARB }, + { 34102, _gloffset_MultiTexCoord2fvARB }, + { -1, -1 } +}; + +#endif /* need_MESA_remap_table */ + +#if defined(need_GL_3DFX_tbuffer) +static const struct gl_function_remap GL_3DFX_tbuffer_functions[] = { + { 9883, -1 }, /* TbufferMask3DFX */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_AMD_draw_buffers_blend) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_AMD_draw_buffers_blend_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_APPLE_flush_buffer_range) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_APPLE_flush_buffer_range_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_APPLE_object_purgeable) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_APPLE_object_purgeable_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_APPLE_texture_range) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_APPLE_texture_range_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_APPLE_vertex_array_object) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_APPLE_vertex_array_object_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_ARB_ES2_compatibility) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_ARB_ES2_compatibility_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_ARB_color_buffer_float) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_ARB_color_buffer_float_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_ARB_copy_buffer) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_ARB_copy_buffer_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_ARB_draw_buffers) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_ARB_draw_buffers_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_ARB_draw_buffers_blend) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_ARB_draw_buffers_blend_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_ARB_draw_elements_base_vertex) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_ARB_draw_elements_base_vertex_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_ARB_draw_instanced) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_ARB_draw_instanced_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_ARB_framebuffer_object) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_ARB_framebuffer_object_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_ARB_geometry_shader4) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_ARB_geometry_shader4_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_ARB_instanced_arrays) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_ARB_instanced_arrays_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_ARB_map_buffer_range) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_ARB_map_buffer_range_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_ARB_matrix_palette) +static const struct gl_function_remap GL_ARB_matrix_palette_functions[] = { + { 4125, -1 }, /* MatrixIndexusvARB */ + { 13938, -1 }, /* MatrixIndexuivARB */ + { 15379, -1 }, /* MatrixIndexPointerARB */ + { 21149, -1 }, /* CurrentPaletteMatrixARB */ + { 24389, -1 }, /* MatrixIndexubvARB */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_ARB_multisample) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_ARB_multisample_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_ARB_occlusion_query) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_ARB_occlusion_query_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_ARB_point_parameters) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_ARB_point_parameters_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_ARB_provoking_vertex) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_ARB_provoking_vertex_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_ARB_robustness) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_ARB_robustness_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_ARB_sampler_objects) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_ARB_sampler_objects_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_ARB_shader_objects) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_ARB_shader_objects_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_ARB_sync) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_ARB_sync_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_ARB_texture_buffer_object) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_ARB_texture_buffer_object_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_ARB_texture_compression) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_ARB_texture_compression_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_ARB_transform_feedback2) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_ARB_transform_feedback2_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_ARB_transpose_matrix) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_ARB_transpose_matrix_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_ARB_vertex_array_object) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_ARB_vertex_array_object_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_ARB_vertex_blend) +static const struct gl_function_remap GL_ARB_vertex_blend_functions[] = { + { 2589, -1 }, /* WeightubvARB */ + { 7214, -1 }, /* WeightivARB */ + { 11849, -1 }, /* WeightPointerARB */ + { 14673, -1 }, /* WeightfvARB */ + { 18632, -1 }, /* WeightbvARB */ + { 22379, -1 }, /* WeightusvARB */ + { 25507, -1 }, /* VertexBlendARB */ + { 31366, -1 }, /* WeightsvARB */ + { 33492, -1 }, /* WeightdvARB */ + { 34302, -1 }, /* WeightuivARB */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_ARB_vertex_buffer_object) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_ARB_vertex_buffer_object_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_ARB_vertex_program) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_ARB_vertex_program_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_ARB_vertex_shader) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_ARB_vertex_shader_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_ARB_vertex_type_2_10_10_10_rev) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_ARB_vertex_type_2_10_10_10_rev_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_ARB_window_pos) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_ARB_window_pos_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_ATI_blend_equation_separate) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_ATI_blend_equation_separate_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_ATI_draw_buffers) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_ATI_draw_buffers_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_ATI_envmap_bumpmap) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_ATI_envmap_bumpmap_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_ATI_fragment_shader) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_ATI_fragment_shader_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_ATI_separate_stencil) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_ATI_separate_stencil_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_blend_color) +static const struct gl_function_remap GL_EXT_blend_color_functions[] = { + { 2867, _gloffset_BlendColor }, + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_blend_equation_separate) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_EXT_blend_equation_separate_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_blend_func_separate) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_EXT_blend_func_separate_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_blend_minmax) +static const struct gl_function_remap GL_EXT_blend_minmax_functions[] = { + { 11984, _gloffset_BlendEquation }, + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_color_subtable) +static const struct gl_function_remap GL_EXT_color_subtable_functions[] = { + { 18032, _gloffset_ColorSubTable }, + { 33442, _gloffset_CopyColorSubTable }, + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_compiled_vertex_array) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_EXT_compiled_vertex_array_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_convolution) +static const struct gl_function_remap GL_EXT_convolution_functions[] = { + { 296, _gloffset_ConvolutionFilter1D }, + { 2647, _gloffset_CopyConvolutionFilter1D }, + { 4508, _gloffset_GetConvolutionParameteriv }, + { 9163, _gloffset_ConvolutionFilter2D }, + { 9365, _gloffset_ConvolutionParameteriv }, + { 9825, _gloffset_ConvolutionParameterfv }, + { 21915, _gloffset_GetSeparableFilter }, + { 25581, _gloffset_SeparableFilter2D }, + { 26469, _gloffset_ConvolutionParameteri }, + { 26662, _gloffset_ConvolutionParameterf }, + { 28376, _gloffset_GetConvolutionParameterfv }, + { 29265, _gloffset_GetConvolutionFilter }, + { 31823, _gloffset_CopyConvolutionFilter2D }, + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_coordinate_frame) +static const struct gl_function_remap GL_EXT_coordinate_frame_functions[] = { + { 11283, -1 }, /* TangentPointerEXT */ + { 13318, -1 }, /* Binormal3ivEXT */ + { 14070, -1 }, /* Tangent3sEXT */ + { 15444, -1 }, /* Tangent3fvEXT */ + { 19742, -1 }, /* Tangent3ivEXT */ + { 19985, -1 }, /* Tangent3dvEXT */ + { 20803, -1 }, /* Binormal3bvEXT */ + { 21968, -1 }, /* Binormal3dEXT */ + { 24321, -1 }, /* Tangent3fEXT */ + { 26541, -1 }, /* Binormal3sEXT */ + { 27108, -1 }, /* Tangent3dEXT */ + { 28055, -1 }, /* Binormal3svEXT */ + { 28688, -1 }, /* Binormal3fEXT */ + { 29596, -1 }, /* Binormal3dvEXT */ + { 30915, -1 }, /* Tangent3iEXT */ + { 32108, -1 }, /* Tangent3bvEXT */ + { 32690, -1 }, /* Tangent3bEXT */ + { 33215, -1 }, /* Binormal3fvEXT */ + { 34001, -1 }, /* BinormalPointerEXT */ + { 34482, -1 }, /* Tangent3svEXT */ + { 34944, -1 }, /* Binormal3bEXT */ + { 35121, -1 }, /* Binormal3iEXT */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_copy_texture) +static const struct gl_function_remap GL_EXT_copy_texture_functions[] = { + { 15988, _gloffset_CopyTexSubImage3D }, + { 17719, _gloffset_CopyTexImage2D }, + { 26052, _gloffset_CopyTexImage1D }, + { 28946, _gloffset_CopyTexSubImage2D }, + { 31435, _gloffset_CopyTexSubImage1D }, + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_cull_vertex) +static const struct gl_function_remap GL_EXT_cull_vertex_functions[] = { + { 9514, -1 }, /* CullParameterdvEXT */ + { 12472, -1 }, /* CullParameterfvEXT */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_depth_bounds_test) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_EXT_depth_bounds_test_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_draw_buffers2) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_EXT_draw_buffers2_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_draw_instanced) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_EXT_draw_instanced_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_draw_range_elements) +static const struct gl_function_remap GL_EXT_draw_range_elements_functions[] = { + { 10179, _gloffset_DrawRangeElements }, + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_fog_coord) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_EXT_fog_coord_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_framebuffer_blit) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_EXT_framebuffer_blit_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_framebuffer_multisample) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_EXT_framebuffer_multisample_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_framebuffer_object) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_EXT_framebuffer_object_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_gpu_program_parameters) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_EXT_gpu_program_parameters_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_gpu_shader4) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_EXT_gpu_shader4_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_histogram) +static const struct gl_function_remap GL_EXT_histogram_functions[] = { + { 895, _gloffset_Histogram }, + { 3848, _gloffset_ResetHistogram }, + { 10709, _gloffset_GetMinmax }, + { 16322, _gloffset_GetHistogramParameterfv }, + { 25977, _gloffset_GetMinmaxParameteriv }, + { 28266, _gloffset_ResetMinmax }, + { 29162, _gloffset_GetHistogramParameteriv }, + { 30383, _gloffset_GetHistogram }, + { 33067, _gloffset_Minmax }, + { 34742, _gloffset_GetMinmaxParameterfv }, + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_index_func) +static const struct gl_function_remap GL_EXT_index_func_functions[] = { + { 12258, -1 }, /* IndexFuncEXT */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_index_material) +static const struct gl_function_remap GL_EXT_index_material_functions[] = { + { 22517, -1 }, /* IndexMaterialEXT */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_light_texture) +static const struct gl_function_remap GL_EXT_light_texture_functions[] = { + { 28075, -1 }, /* ApplyTextureEXT */ + { 28220, -1 }, /* TextureMaterialEXT */ + { 28245, -1 }, /* TextureLightEXT */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_multi_draw_arrays) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_EXT_multi_draw_arrays_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_multisample) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_EXT_multisample_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_paletted_texture) +static const struct gl_function_remap GL_EXT_paletted_texture_functions[] = { + { 9025, _gloffset_ColorTable }, + { 16168, _gloffset_GetColorTable }, + { 24504, _gloffset_GetColorTableParameterfv }, + { 26718, _gloffset_GetColorTableParameteriv }, + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_pixel_transform) +static const struct gl_function_remap GL_EXT_pixel_transform_functions[] = { + { 23164, -1 }, /* PixelTransformParameterfEXT */ + { 23244, -1 }, /* PixelTransformParameteriEXT */ + { 32388, -1 }, /* PixelTransformParameterfvEXT */ + { 33965, -1 }, /* PixelTransformParameterivEXT */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_point_parameters) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_EXT_point_parameters_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_polygon_offset) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_EXT_polygon_offset_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_provoking_vertex) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_EXT_provoking_vertex_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_secondary_color) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_EXT_secondary_color_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_separate_shader_objects) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_EXT_separate_shader_objects_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_stencil_two_side) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_EXT_stencil_two_side_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_subtexture) +static const struct gl_function_remap GL_EXT_subtexture_functions[] = { + { 7736, _gloffset_TexSubImage1D }, + { 11439, _gloffset_TexSubImage2D }, + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_texture3D) +static const struct gl_function_remap GL_EXT_texture3D_functions[] = { + { 1890, _gloffset_TexImage3D }, + { 24273, _gloffset_TexSubImage3D }, + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_texture_array) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_EXT_texture_array_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_texture_integer) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_EXT_texture_integer_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_texture_object) +static const struct gl_function_remap GL_EXT_texture_object_functions[] = { + { 3616, _gloffset_PrioritizeTextures }, + { 8185, _gloffset_AreTexturesResident }, + { 14413, _gloffset_GenTextures }, + { 16699, _gloffset_DeleteTextures }, + { 20856, _gloffset_IsTexture }, + { 31500, _gloffset_BindTexture }, + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_texture_perturb_normal) +static const struct gl_function_remap GL_EXT_texture_perturb_normal_functions[] = { + { 14623, -1 }, /* TextureNormalEXT */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_timer_query) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_EXT_timer_query_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_transform_feedback) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_EXT_transform_feedback_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_vertex_array) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_EXT_vertex_array_functions[] = { + { 25753, _gloffset_ArrayElement }, + { 32655, _gloffset_GetPointerv }, + { 34268, _gloffset_DrawArrays }, + { -1, -1 } +}; +#endif + +#if defined(need_GL_EXT_vertex_weighting) +static const struct gl_function_remap GL_EXT_vertex_weighting_functions[] = { + { 20930, -1 }, /* VertexWeightfvEXT */ + { 28631, -1 }, /* VertexWeightfEXT */ + { 30352, -1 }, /* VertexWeightPointerEXT */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_HP_image_transform) +static const struct gl_function_remap GL_HP_image_transform_functions[] = { + { 2500, -1 }, /* GetImageTransformParameterfvHP */ + { 4091, -1 }, /* ImageTransformParameterfHP */ + { 10951, -1 }, /* ImageTransformParameterfvHP */ + { 12719, -1 }, /* ImageTransformParameteriHP */ + { 13089, -1 }, /* GetImageTransformParameterivHP */ + { 20994, -1 }, /* ImageTransformParameterivHP */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_IBM_multimode_draw_arrays) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_IBM_multimode_draw_arrays_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_IBM_vertex_array_lists) +static const struct gl_function_remap GL_IBM_vertex_array_lists_functions[] = { + { 4798, -1 }, /* SecondaryColorPointerListIBM */ + { 6668, -1 }, /* NormalPointerListIBM */ + { 8359, -1 }, /* FogCoordPointerListIBM */ + { 8700, -1 }, /* VertexPointerListIBM */ + { 12973, -1 }, /* ColorPointerListIBM */ + { 14177, -1 }, /* TexCoordPointerListIBM */ + { 14645, -1 }, /* IndexPointerListIBM */ + { 34685, -1 }, /* EdgeFlagPointerListIBM */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_INGR_blend_func_separate) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_INGR_blend_func_separate_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_INTEL_parallel_arrays) +static const struct gl_function_remap GL_INTEL_parallel_arrays_functions[] = { + { 13517, -1 }, /* VertexPointervINTEL */ + { 16415, -1 }, /* ColorPointervINTEL */ + { 31797, -1 }, /* NormalPointervINTEL */ + { 32320, -1 }, /* TexCoordPointervINTEL */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_MESA_resize_buffers) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_MESA_resize_buffers_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_MESA_shader_debug) +static const struct gl_function_remap GL_MESA_shader_debug_functions[] = { + { 1754, -1 }, /* GetDebugLogLengthMESA */ + { 3787, -1 }, /* ClearDebugLogMESA */ + { 4983, -1 }, /* GetDebugLogMESA */ + { 32848, -1 }, /* CreateDebugObjectMESA */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_MESA_window_pos) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_MESA_window_pos_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_NV_condtitional_render) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_NV_condtitional_render_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_NV_evaluators) +static const struct gl_function_remap GL_NV_evaluators_functions[] = { + { 7398, -1 }, /* GetMapAttribParameterivNV */ + { 9131, -1 }, /* MapControlPointsNV */ + { 9230, -1 }, /* MapParameterfvNV */ + { 11422, -1 }, /* EvalMapsNV */ + { 18230, -1 }, /* GetMapAttribParameterfvNV */ + { 18447, -1 }, /* MapParameterivNV */ + { 26392, -1 }, /* GetMapParameterivNV */ + { 26960, -1 }, /* GetMapParameterfvNV */ + { 31069, -1 }, /* GetMapControlPointsNV */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_NV_fence) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_NV_fence_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_NV_fragment_program) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_NV_fragment_program_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_NV_point_sprite) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_NV_point_sprite_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_NV_primitive_restart) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_NV_primitive_restart_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_NV_register_combiners) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_NV_register_combiners_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_NV_register_combiners2) +static const struct gl_function_remap GL_NV_register_combiners2_functions[] = { + { 16852, -1 }, /* CombinerStageParameterfvNV */ + { 17274, -1 }, /* GetCombinerStageParameterfvNV */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_NV_texture_barrier) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_NV_texture_barrier_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_NV_vertex_array_range) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_NV_vertex_array_range_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_NV_vertex_program) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_NV_vertex_program_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_OES_EGL_image) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_OES_EGL_image_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_PGI_misc_hints) +static const struct gl_function_remap GL_PGI_misc_hints_functions[] = { + { 9351, -1 }, /* HintPGI */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_SGIS_detail_texture) +static const struct gl_function_remap GL_SGIS_detail_texture_functions[] = { + { 17247, -1 }, /* GetDetailTexFuncSGIS */ + { 17664, -1 }, /* DetailTexFuncSGIS */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_SGIS_fog_function) +static const struct gl_function_remap GL_SGIS_fog_function_functions[] = { + { 28928, -1 }, /* FogFuncSGIS */ + { 29701, -1 }, /* GetFogFuncSGIS */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_SGIS_multisample) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_SGIS_multisample_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_SGIS_pixel_texture) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_SGIS_pixel_texture_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_SGIS_point_parameters) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_SGIS_point_parameters_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_SGIS_sharpen_texture) +static const struct gl_function_remap GL_SGIS_sharpen_texture_functions[] = { + { 7459, -1 }, /* GetSharpenTexFuncSGIS */ + { 23595, -1 }, /* SharpenTexFuncSGIS */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_SGIS_texture4D) +static const struct gl_function_remap GL_SGIS_texture4D_functions[] = { + { 1034, -1 }, /* TexImage4DSGIS */ + { 16768, -1 }, /* TexSubImage4DSGIS */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_SGIS_texture_color_mask) +static const struct gl_function_remap GL_SGIS_texture_color_mask_functions[] = { + { 16121, -1 }, /* TextureColorMaskSGIS */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_SGIS_texture_filter4) +static const struct gl_function_remap GL_SGIS_texture_filter4_functions[] = { + { 7636, -1 }, /* GetTexFilterFuncSGIS */ + { 17438, -1 }, /* TexFilterFuncSGIS */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_SGIX_async) +static const struct gl_function_remap GL_SGIX_async_functions[] = { + { 3713, -1 }, /* AsyncMarkerSGIX */ + { 4937, -1 }, /* FinishAsyncSGIX */ + { 6072, -1 }, /* PollAsyncSGIX */ + { 23824, -1 }, /* DeleteAsyncMarkersSGIX */ + { 23879, -1 }, /* IsAsyncMarkerSGIX */ + { 34457, -1 }, /* GenAsyncMarkersSGIX */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_SGIX_flush_raster) +static const struct gl_function_remap GL_SGIX_flush_raster_functions[] = { + { 8013, -1 }, /* FlushRasterSGIX */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_SGIX_fragment_lighting) +static const struct gl_function_remap GL_SGIX_fragment_lighting_functions[] = { + { 2837, -1 }, /* FragmentMaterialfvSGIX */ + { 5976, -1 }, /* FragmentLightiSGIX */ + { 8767, -1 }, /* FragmentMaterialfSGIX */ + { 8904, -1 }, /* GetFragmentLightivSGIX */ + { 9777, -1 }, /* FragmentLightModeliSGIX */ + { 11485, -1 }, /* FragmentLightivSGIX */ + { 11792, -1 }, /* GetFragmentMaterialivSGIX */ + { 17187, -1 }, /* GetFragmentMaterialfvSGIX */ + { 20773, -1 }, /* FragmentLightModelfSGIX */ + { 21117, -1 }, /* FragmentColorMaterialSGIX */ + { 21534, -1 }, /* FragmentMaterialiSGIX */ + { 22845, -1 }, /* LightEnviSGIX */ + { 24596, -1 }, /* FragmentLightModelfvSGIX */ + { 24931, -1 }, /* FragmentLightfvSGIX */ + { 30085, -1 }, /* FragmentLightModelivSGIX */ + { 30234, -1 }, /* FragmentLightfSGIX */ + { 33185, -1 }, /* GetFragmentLightfvSGIX */ + { 34965, -1 }, /* FragmentMaterialivSGIX */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_SGIX_framezoom) +static const struct gl_function_remap GL_SGIX_framezoom_functions[] = { + { 23902, -1 }, /* FrameZoomSGIX */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_SGIX_igloo_interface) +static const struct gl_function_remap GL_SGIX_igloo_interface_functions[] = { + { 30542, -1 }, /* IglooInterfaceSGIX */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_SGIX_instruments) +static const struct gl_function_remap GL_SGIX_instruments_functions[] = { + { 3017, -1 }, /* ReadInstrumentsSGIX */ + { 7232, -1 }, /* PollInstrumentsSGIX */ + { 11343, -1 }, /* GetInstrumentsSGIX */ + { 13775, -1 }, /* StartInstrumentsSGIX */ + { 16912, -1 }, /* StopInstrumentsSGIX */ + { 18895, -1 }, /* InstrumentsBufferSGIX */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_SGIX_list_priority) +static const struct gl_function_remap GL_SGIX_list_priority_functions[] = { + { 1265, -1 }, /* ListParameterfSGIX */ + { 3372, -1 }, /* GetListParameterfvSGIX */ + { 18760, -1 }, /* ListParameteriSGIX */ + { 19919, -1 }, /* ListParameterfvSGIX */ + { 22200, -1 }, /* ListParameterivSGIX */ + { 34501, -1 }, /* GetListParameterivSGIX */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_SGIX_pixel_texture) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_SGIX_pixel_texture_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_SGIX_polynomial_ffd) +static const struct gl_function_remap GL_SGIX_polynomial_ffd_functions[] = { + { 3059, -1 }, /* DeformationMap3dSGIX */ + { 4037, -1 }, /* LoadIdentityDeformationMapSGIX */ + { 17012, -1 }, /* DeformSGIX */ + { 25865, -1 }, /* DeformationMap3fSGIX */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_SGIX_reference_plane) +static const struct gl_function_remap GL_SGIX_reference_plane_functions[] = { + { 15672, -1 }, /* ReferencePlaneSGIX */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_SGIX_sprite) +static const struct gl_function_remap GL_SGIX_sprite_functions[] = { + { 10292, -1 }, /* SpriteParameterfvSGIX */ + { 21989, -1 }, /* SpriteParameteriSGIX */ + { 28300, -1 }, /* SpriteParameterfSGIX */ + { 31212, -1 }, /* SpriteParameterivSGIX */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_SGIX_tag_sample_buffer) +static const struct gl_function_remap GL_SGIX_tag_sample_buffer_functions[] = { + { 22048, -1 }, /* TagSampleBufferSGIX */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_SGI_color_table) +static const struct gl_function_remap GL_SGI_color_table_functions[] = { + { 8303, _gloffset_ColorTableParameteriv }, + { 9025, _gloffset_ColorTable }, + { 16168, _gloffset_GetColorTable }, + { 16278, _gloffset_CopyColorTable }, + { 20717, _gloffset_ColorTableParameterfv }, + { 24504, _gloffset_GetColorTableParameterfv }, + { 26718, _gloffset_GetColorTableParameteriv }, + { -1, -1 } +}; +#endif + +#if defined(need_GL_SUNX_constant_data) +static const struct gl_function_remap GL_SUNX_constant_data_functions[] = { + { 33163, -1 }, /* FinishTextureSUNX */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_SUN_global_alpha) +static const struct gl_function_remap GL_SUN_global_alpha_functions[] = { + { 3734, -1 }, /* GlobalAlphaFactorubSUN */ + { 5290, -1 }, /* GlobalAlphaFactoriSUN */ + { 7257, -1 }, /* GlobalAlphaFactordSUN */ + { 10376, -1 }, /* GlobalAlphaFactoruiSUN */ + { 10908, -1 }, /* GlobalAlphaFactorbSUN */ + { 14090, -1 }, /* GlobalAlphaFactorfSUN */ + { 14254, -1 }, /* GlobalAlphaFactorusSUN */ + { 24191, -1 }, /* GlobalAlphaFactorsSUN */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_SUN_mesh_array) +static const struct gl_function_remap GL_SUN_mesh_array_functions[] = { + { 31003, -1 }, /* DrawMeshArraysSUN */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_SUN_triangle_list) +static const struct gl_function_remap GL_SUN_triangle_list_functions[] = { + { 4911, -1 }, /* ReplacementCodeubSUN */ + { 7016, -1 }, /* ReplacementCodeubvSUN */ + { 20438, -1 }, /* ReplacementCodeusvSUN */ + { 20626, -1 }, /* ReplacementCodePointerSUN */ + { 22909, -1 }, /* ReplacementCodeuiSUN */ + { 23853, -1 }, /* ReplacementCodeusSUN */ + { 31686, -1 }, /* ReplacementCodeuivSUN */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_SUN_vertex) +static const struct gl_function_remap GL_SUN_vertex_functions[] = { + { 1139, -1 }, /* ReplacementCodeuiColor3fVertex3fvSUN */ + { 1337, -1 }, /* TexCoord4fColor4fNormal3fVertex4fvSUN */ + { 1591, -1 }, /* TexCoord2fColor4ubVertex3fvSUN */ + { 2004, -1 }, /* ReplacementCodeuiVertex3fvSUN */ + { 2138, -1 }, /* ReplacementCodeuiTexCoord2fVertex3fvSUN */ + { 2754, -1 }, /* ReplacementCodeuiNormal3fVertex3fSUN */ + { 3152, -1 }, /* Color4ubVertex3fvSUN */ + { 5095, -1 }, /* Color4ubVertex3fSUN */ + { 5218, -1 }, /* TexCoord2fVertex3fSUN */ + { 5679, -1 }, /* TexCoord2fColor4fNormal3fVertex3fSUN */ + { 6176, -1 }, /* TexCoord2fNormal3fVertex3fvSUN */ + { 6911, -1 }, /* ReplacementCodeuiTexCoord2fNormal3fVertex3fSUN */ + { 7691, -1 }, /* ReplacementCodeuiColor4ubVertex3fvSUN */ + { 8050, -1 }, /* ReplacementCodeuiTexCoord2fVertex3fSUN */ + { 9576, -1 }, /* Color3fVertex3fSUN */ + { 10817, -1 }, /* Color3fVertex3fvSUN */ + { 11308, -1 }, /* Color4fNormal3fVertex3fvSUN */ + { 12137, -1 }, /* ReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN */ + { 13638, -1 }, /* ReplacementCodeuiColor4fNormal3fVertex3fvSUN */ + { 15269, -1 }, /* ReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN */ + { 15814, -1 }, /* TexCoord2fColor3fVertex3fSUN */ + { 16937, -1 }, /* TexCoord4fColor4fNormal3fVertex4fSUN */ + { 17379, -1 }, /* Color4ubVertex2fvSUN */ + { 17689, -1 }, /* Normal3fVertex3fSUN */ + { 18836, -1 }, /* ReplacementCodeuiColor4fNormal3fVertex3fSUN */ + { 19188, -1 }, /* TexCoord2fColor4fNormal3fVertex3fvSUN */ + { 19495, -1 }, /* TexCoord2fNormal3fVertex3fSUN */ + { 20231, -1 }, /* TexCoord2fVertex3fvSUN */ + { 21087, -1 }, /* Color4ubVertex2fSUN */ + { 21325, -1 }, /* ReplacementCodeuiColor4ubVertex3fSUN */ + { 23420, -1 }, /* TexCoord2fColor4ubVertex3fSUN */ + { 23921, -1 }, /* Normal3fVertex3fvSUN */ + { 24413, -1 }, /* Color4fNormal3fVertex3fSUN */ + { 25414, -1 }, /* ReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN */ + { 27621, -1 }, /* ReplacementCodeuiColor3fVertex3fSUN */ + { 29044, -1 }, /* TexCoord4fVertex4fSUN */ + { 29490, -1 }, /* TexCoord2fColor3fVertex3fvSUN */ + { 29929, -1 }, /* ReplacementCodeuiNormal3fVertex3fvSUN */ + { 30056, -1 }, /* TexCoord4fVertex4fvSUN */ + { 30790, -1 }, /* ReplacementCodeuiVertex3fSUN */ + { -1, -1 } +}; +#endif + +#if defined(need_GL_VERSION_1_3) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_VERSION_1_3_functions[] = { + { 464, _gloffset_MultiTexCoord3sARB }, + { 696, _gloffset_ActiveTextureARB }, + { 4666, _gloffset_MultiTexCoord1fvARB }, + { 6802, _gloffset_MultiTexCoord3dARB }, + { 6847, _gloffset_MultiTexCoord2iARB }, + { 6971, _gloffset_MultiTexCoord2svARB }, + { 8981, _gloffset_MultiTexCoord2fARB }, + { 11144, _gloffset_MultiTexCoord3fvARB }, + { 11746, _gloffset_MultiTexCoord4sARB }, + { 12427, _gloffset_MultiTexCoord2dvARB }, + { 12834, _gloffset_MultiTexCoord1svARB }, + { 13199, _gloffset_MultiTexCoord3svARB }, + { 13260, _gloffset_MultiTexCoord4iARB }, + { 14117, _gloffset_MultiTexCoord3iARB }, + { 14992, _gloffset_MultiTexCoord1dARB }, + { 15224, _gloffset_MultiTexCoord3dvARB }, + { 16540, _gloffset_MultiTexCoord3ivARB }, + { 16585, _gloffset_MultiTexCoord2sARB }, + { 18089, _gloffset_MultiTexCoord4ivARB }, + { 20357, _gloffset_ClientActiveTextureARB }, + { 22762, _gloffset_MultiTexCoord2dARB }, + { 23199, _gloffset_MultiTexCoord4dvARB }, + { 23621, _gloffset_MultiTexCoord4fvARB }, + { 24645, _gloffset_MultiTexCoord3fARB }, + { 27312, _gloffset_MultiTexCoord4dARB }, + { 27578, _gloffset_MultiTexCoord1sARB }, + { 27782, _gloffset_MultiTexCoord1dvARB }, + { 28790, _gloffset_MultiTexCoord1ivARB }, + { 28883, _gloffset_MultiTexCoord2ivARB }, + { 29222, _gloffset_MultiTexCoord1iARB }, + { 30658, _gloffset_MultiTexCoord4svARB }, + { 31282, _gloffset_MultiTexCoord1fARB }, + { 31562, _gloffset_MultiTexCoord4fARB }, + { 34102, _gloffset_MultiTexCoord2fvARB }, + { -1, -1 } +}; +#endif + +#if defined(need_GL_VERSION_1_4) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_VERSION_1_4_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_VERSION_1_5) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_VERSION_1_5_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_VERSION_2_0) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_VERSION_2_0_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_VERSION_2_1) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_VERSION_2_1_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_VERSION_3_0) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_VERSION_3_0_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_VERSION_3_1) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_VERSION_3_1_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_VERSION_3_2) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_VERSION_3_2_functions[] = { + { -1, -1 } +}; +#endif + +#if defined(need_GL_VERSION_3_3) +/* functions defined in MESA_remap_table_functions are excluded */ +static const struct gl_function_remap GL_VERSION_3_3_functions[] = { + { -1, -1 } +}; +#endif + diff --git a/mesalib/src/mesa/main/renderbuffer.c b/mesalib/src/mesa/main/renderbuffer.c index 08bb23cb3..70011e6b2 100644 --- a/mesalib/src/mesa/main/renderbuffer.c +++ b/mesalib/src/mesa/main/renderbuffer.c @@ -1,2568 +1,2568 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5 - * - * 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. - */ - - -/** - * Functions for allocating/managing renderbuffers. - * Also, routines for reading/writing software-based renderbuffer data as - * ubytes, ushorts, uints, etc. - * - * The 'alpha8' renderbuffer is interesting. It's used to add a software-based - * alpha channel to RGB renderbuffers. This is done by wrapping the RGB - * renderbuffer with the alpha renderbuffer. We can do this because of the - * OO-nature of renderbuffers. - * - * Down the road we'll use this for run-time support of 8, 16 and 32-bit - * color channels. For example, Mesa may use 32-bit/float color channels - * internally (swrast) and use wrapper renderbuffers to convert 32-bit - * values down to 16 or 8-bit values for whatever kind of framebuffer we have. - */ - - -#include "glheader.h" -#include "imports.h" -#include "context.h" -#include "fbobject.h" -#include "formats.h" -#include "mtypes.h" -#include "renderbuffer.h" - - -/* - * Routines for get/put values in common buffer formats follow. - */ - -/* Returns a bytes per pixel of the DataType in the get/put span - * functions for at least a subset of the available combinations a - * renderbuffer can have. - * - * It would be nice to see gl_renderbuffer start talking about a - * gl_format instead of a GLenum DataType. - */ -static int -get_datatype_bytes(struct gl_renderbuffer *rb) -{ - int component_size; - - switch (rb->DataType) { - case GL_FLOAT_32_UNSIGNED_INT_24_8_REV: - component_size = 8; - break; - case GL_FLOAT: - case GL_UNSIGNED_INT: - case GL_UNSIGNED_INT_24_8_EXT: - component_size = 4; - break; - case GL_UNSIGNED_SHORT: - component_size = 2; - break; - case GL_UNSIGNED_BYTE: - component_size = 1; - break; - default: - component_size = 1; - assert(0); - } - - switch (rb->_BaseFormat) { - case GL_DEPTH_COMPONENT: - case GL_DEPTH_STENCIL: - return component_size; - default: - return 4 * component_size; - } -} - -/* This is commonly used by most of the accessors. */ -static void * -get_pointer_generic(struct gl_context *ctx, struct gl_renderbuffer *rb, - GLint x, GLint y) -{ - if (!rb->Data) - return NULL; - - return ((char *) rb->Data + - (y * rb->RowStride + x) * _mesa_get_format_bytes(rb->Format)); -} - -/* GetRow() implementation for formats where DataType matches the rb->Format. - */ -static void -get_row_generic(struct gl_context *ctx, struct gl_renderbuffer *rb, - GLuint count, GLint x, GLint y, void *values) -{ - void *src = rb->GetPointer(ctx, rb, x, y); - memcpy(values, src, count * _mesa_get_format_bytes(rb->Format)); -} - -/* Only used for float textures currently, but might also be used for - * RGBA8888, RGBA16, etc. - */ -static void -get_values_generic(struct gl_context *ctx, struct gl_renderbuffer *rb, - GLuint count, const GLint x[], const GLint y[], void *values) -{ - int format_bytes = _mesa_get_format_bytes(rb->Format) / sizeof(GLfloat); - GLuint i; - - for (i = 0; i < count; i++) { - const void *src = rb->GetPointer(ctx, rb, x[i], y[i]); - char *dst = (char *) values + i * format_bytes; - memcpy(dst, src, format_bytes); - } -} - -/* For the GL_RED/GL_RG/GL_RGB format/DataType combinations (and - * GL_LUMINANCE/GL_INTENSITY?), the Put functions are a matter of - * storing those initial components of the value per pixel into the - * destination. - */ -static void -put_row_generic(struct gl_context *ctx, struct gl_renderbuffer *rb, - GLuint count, GLint x, GLint y, - const void *values, const GLubyte *mask) -{ - void *row = rb->GetPointer(ctx, rb, x, y); - int format_bytes = _mesa_get_format_bytes(rb->Format) / sizeof(GLfloat); - int datatype_bytes = get_datatype_bytes(rb); - unsigned int i; - - if (mask) { - for (i = 0; i < count; i++) { - char *dst = (char *) row + i * format_bytes; - const char *src = (const char *) values + i * datatype_bytes; - - if (mask[i]) { - memcpy(dst, src, format_bytes); - } - } - } - else { - for (i = 0; i < count; i++) { - char *dst = (char *) row + i * format_bytes; - const char *src = (const char *) values + i * datatype_bytes; - memcpy(dst, src, format_bytes); - } - } -} - -static void -put_mono_row_generic(struct gl_context *ctx, struct gl_renderbuffer *rb, - GLuint count, GLint x, GLint y, - const void *value, const GLubyte *mask) -{ - void *row = rb->GetPointer(ctx, rb, x, y); - int format_bytes = _mesa_get_format_bytes(rb->Format) / sizeof(GLfloat); - unsigned int i; - - if (mask) { - for (i = 0; i < count; i++) { - char *dst = (char *) row + i * format_bytes; - if (mask[i]) { - memcpy(dst, value, format_bytes); - } - } - } - else { - for (i = 0; i < count; i++) { - char *dst = (char *) row + i * format_bytes; - memcpy(dst, value, format_bytes); - } - } -} - - -static void -put_values_generic(struct gl_context *ctx, struct gl_renderbuffer *rb, - GLuint count, const GLint x[], const GLint y[], - const void *values, const GLubyte *mask) -{ - int format_bytes = _mesa_get_format_bytes(rb->Format) / sizeof(GLfloat); - int datatype_bytes = get_datatype_bytes(rb); - unsigned int i; - - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - void *dst = rb->GetPointer(ctx, rb, x[i], y[i]); - const char *src = (const char *) values + i * datatype_bytes; - memcpy(dst, src, format_bytes); - } - } -} - - -static void -put_mono_values_generic(struct gl_context *ctx, - struct gl_renderbuffer *rb, - GLuint count, const GLint x[], const GLint y[], - const void *value, const GLubyte *mask) -{ - int format_bytes = _mesa_get_format_bytes(rb->Format) / sizeof(GLfloat); - unsigned int i; - - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - void *dst = rb->GetPointer(ctx, rb, x[i], y[i]); - memcpy(dst, value, format_bytes); - } - } -} - -/********************************************************************** - * Functions for buffers of 1 X GLubyte values. - * Typically stencil. - */ - -static void -get_values_ubyte(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - const GLint x[], const GLint y[], void *values) -{ - GLubyte *dst = (GLubyte *) values; - GLuint i; - ASSERT(rb->DataType == GL_UNSIGNED_BYTE); - for (i = 0; i < count; i++) { - const GLubyte *src = (GLubyte *) rb->Data + y[i] * rb->RowStride + x[i]; - dst[i] = *src; - } -} - - -static void -put_row_ubyte(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, const void *values, const GLubyte *mask) -{ - const GLubyte *src = (const GLubyte *) values; - GLubyte *dst = (GLubyte *) rb->Data + y * rb->RowStride + x; - ASSERT(rb->DataType == GL_UNSIGNED_BYTE); - if (mask) { - GLuint i; - for (i = 0; i < count; i++) { - if (mask[i]) { - dst[i] = src[i]; - } - } - } - else { - memcpy(dst, values, count * sizeof(GLubyte)); - } -} - - -static void -put_mono_row_ubyte(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, const void *value, const GLubyte *mask) -{ - const GLubyte val = *((const GLubyte *) value); - GLubyte *dst = (GLubyte *) rb->Data + y * rb->RowStride + x; - ASSERT(rb->DataType == GL_UNSIGNED_BYTE); - if (mask) { - GLuint i; - for (i = 0; i < count; i++) { - if (mask[i]) { - dst[i] = val; - } - } - } - else { - GLuint i; - for (i = 0; i < count; i++) { - dst[i] = val; - } - } -} - - -static void -put_values_ubyte(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - const GLint x[], const GLint y[], - const void *values, const GLubyte *mask) -{ - const GLubyte *src = (const GLubyte *) values; - GLuint i; - ASSERT(rb->DataType == GL_UNSIGNED_BYTE); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - GLubyte *dst = (GLubyte *) rb->Data + y[i] * rb->RowStride + x[i]; - *dst = src[i]; - } - } -} - - -static void -put_mono_values_ubyte(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - const GLint x[], const GLint y[], - const void *value, const GLubyte *mask) -{ - const GLubyte val = *((const GLubyte *) value); - GLuint i; - ASSERT(rb->DataType == GL_UNSIGNED_BYTE); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - GLubyte *dst = (GLubyte *) rb->Data + y[i] * rb->RowStride + x[i]; - *dst = val; - } - } -} - - -/********************************************************************** - * Functions for buffers of 1 X GLushort values. - * Typically depth/Z. - */ - -static void -get_values_ushort(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - const GLint x[], const GLint y[], void *values) -{ - GLushort *dst = (GLushort *) values; - GLuint i; - ASSERT(rb->DataType == GL_UNSIGNED_SHORT); - for (i = 0; i < count; i++) { - const GLushort *src = (GLushort *) rb->Data + y[i] * rb->RowStride + x[i]; - dst[i] = *src; - } -} - - -static void -put_row_ushort(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, const void *values, const GLubyte *mask) -{ - const GLushort *src = (const GLushort *) values; - GLushort *dst = (GLushort *) rb->Data + y * rb->RowStride + x; - ASSERT(rb->DataType == GL_UNSIGNED_SHORT); - if (mask) { - GLuint i; - for (i = 0; i < count; i++) { - if (mask[i]) { - dst[i] = src[i]; - } - } - } - else { - memcpy(dst, src, count * sizeof(GLushort)); - } -} - - -static void -put_mono_row_ushort(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, const void *value, const GLubyte *mask) -{ - const GLushort val = *((const GLushort *) value); - GLushort *dst = (GLushort *) rb->Data + y * rb->RowStride + x; - ASSERT(rb->DataType == GL_UNSIGNED_SHORT); - if (mask) { - GLuint i; - for (i = 0; i < count; i++) { - if (mask[i]) { - dst[i] = val; - } - } - } - else { - GLuint i; - for (i = 0; i < count; i++) { - dst[i] = val; - } - } -} - - -static void -put_values_ushort(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - const GLint x[], const GLint y[], const void *values, - const GLubyte *mask) -{ - const GLushort *src = (const GLushort *) values; - GLuint i; - ASSERT(rb->DataType == GL_UNSIGNED_SHORT); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - GLushort *dst = (GLushort *) rb->Data + y[i] * rb->RowStride + x[i]; - *dst = src[i]; - } - } -} - - -static void -put_mono_values_ushort(struct gl_context *ctx, struct gl_renderbuffer *rb, - GLuint count, const GLint x[], const GLint y[], - const void *value, const GLubyte *mask) -{ - const GLushort val = *((const GLushort *) value); - ASSERT(rb->DataType == GL_UNSIGNED_SHORT); - if (mask) { - GLuint i; - for (i = 0; i < count; i++) { - if (mask[i]) { - GLushort *dst = (GLushort *) rb->Data + y[i] * rb->RowStride + x[i]; - *dst = val; - } - } - } - else { - GLuint i; - for (i = 0; i < count; i++) { - GLushort *dst = (GLushort *) rb->Data + y[i] * rb->RowStride + x[i]; - *dst = val; - } - } -} - - -/********************************************************************** - * Functions for buffers of 1 X GLuint values. - * Typically depth/Z or color index. - */ - -static void -get_values_uint(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - const GLint x[], const GLint y[], void *values) -{ - GLuint *dst = (GLuint *) values; - GLuint i; - ASSERT(rb->DataType == GL_UNSIGNED_INT || - rb->DataType == GL_UNSIGNED_INT_24_8_EXT); - for (i = 0; i < count; i++) { - const GLuint *src = (GLuint *) rb->Data + y[i] * rb->RowStride + x[i]; - dst[i] = *src; - } -} - - -static void -put_row_uint(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, const void *values, const GLubyte *mask) -{ - const GLuint *src = (const GLuint *) values; - GLuint *dst = (GLuint *) rb->Data + y * rb->RowStride + x; - ASSERT(rb->DataType == GL_UNSIGNED_INT || - rb->DataType == GL_UNSIGNED_INT_24_8_EXT); - if (mask) { - GLuint i; - for (i = 0; i < count; i++) { - if (mask[i]) { - dst[i] = src[i]; - } - } - } - else { - memcpy(dst, src, count * sizeof(GLuint)); - } -} - - -static void -put_mono_row_uint(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, const void *value, const GLubyte *mask) -{ - const GLuint val = *((const GLuint *) value); - GLuint *dst = (GLuint *) rb->Data + y * rb->RowStride + x; - ASSERT(rb->DataType == GL_UNSIGNED_INT || - rb->DataType == GL_UNSIGNED_INT_24_8_EXT); - if (mask) { - GLuint i; - for (i = 0; i < count; i++) { - if (mask[i]) { - dst[i] = val; - } - } - } - else { - GLuint i; - for (i = 0; i < count; i++) { - dst[i] = val; - } - } -} - - -static void -put_values_uint(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - const GLint x[], const GLint y[], const void *values, - const GLubyte *mask) -{ - const GLuint *src = (const GLuint *) values; - GLuint i; - ASSERT(rb->DataType == GL_UNSIGNED_INT || - rb->DataType == GL_UNSIGNED_INT_24_8_EXT); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - GLuint *dst = (GLuint *) rb->Data + y[i] * rb->RowStride + x[i]; - *dst = src[i]; - } - } -} - - -static void -put_mono_values_uint(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - const GLint x[], const GLint y[], const void *value, - const GLubyte *mask) -{ - const GLuint val = *((const GLuint *) value); - GLuint i; - ASSERT(rb->DataType == GL_UNSIGNED_INT || - rb->DataType == GL_UNSIGNED_INT_24_8_EXT); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - GLuint *dst = (GLuint *) rb->Data + y[i] * rb->RowStride + x[i]; - *dst = val; - } - } -} - - -/********************************************************************** - * Functions for buffers of 3 X GLubyte (or GLbyte) values. - * Typically color buffers. - * NOTE: the incoming and outgoing colors are RGBA! We ignore incoming - * alpha values and return 255 for outgoing alpha values. - */ - -static void * -get_pointer_ubyte3(struct gl_context *ctx, struct gl_renderbuffer *rb, - GLint x, GLint y) -{ - ASSERT(rb->Format == MESA_FORMAT_RGB888); - /* No direct access since this buffer is RGB but caller will be - * treating it as if it were RGBA. - */ - return NULL; -} - - -static void -get_row_ubyte3(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, void *values) -{ - const GLubyte *src = ((const GLubyte *) rb->Data) + - 3 * (y * rb->RowStride + x); - GLubyte *dst = (GLubyte *) values; - GLuint i; - ASSERT(rb->Format == MESA_FORMAT_RGB888); - ASSERT(rb->DataType == GL_UNSIGNED_BYTE); - for (i = 0; i < count; i++) { - dst[i * 4 + 0] = src[i * 3 + 0]; - dst[i * 4 + 1] = src[i * 3 + 1]; - dst[i * 4 + 2] = src[i * 3 + 2]; - dst[i * 4 + 3] = 255; - } -} - - -static void -get_values_ubyte3(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - const GLint x[], const GLint y[], void *values) -{ - GLubyte *dst = (GLubyte *) values; - GLuint i; - ASSERT(rb->Format == MESA_FORMAT_RGB888); - ASSERT(rb->DataType == GL_UNSIGNED_BYTE); - for (i = 0; i < count; i++) { - const GLubyte *src - = (GLubyte *) rb->Data + 3 * (y[i] * rb->RowStride + x[i]); - dst[i * 4 + 0] = src[0]; - dst[i * 4 + 1] = src[1]; - dst[i * 4 + 2] = src[2]; - dst[i * 4 + 3] = 255; - } -} - - -static void -put_row_ubyte3(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, const void *values, const GLubyte *mask) -{ - /* note: incoming values are RGB+A! */ - const GLubyte *src = (const GLubyte *) values; - GLubyte *dst = (GLubyte *) rb->Data + 3 * (y * rb->RowStride + x); - GLuint i; - ASSERT(rb->Format == MESA_FORMAT_RGB888); - ASSERT(rb->DataType == GL_UNSIGNED_BYTE); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - dst[i * 3 + 0] = src[i * 4 + 0]; - dst[i * 3 + 1] = src[i * 4 + 1]; - dst[i * 3 + 2] = src[i * 4 + 2]; - } - } -} - - -static void -put_row_rgb_ubyte3(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, const void *values, const GLubyte *mask) -{ - /* note: incoming values are RGB+A! */ - const GLubyte *src = (const GLubyte *) values; - GLubyte *dst = (GLubyte *) rb->Data + 3 * (y * rb->RowStride + x); - GLuint i; - ASSERT(rb->Format == MESA_FORMAT_RGB888); - ASSERT(rb->DataType == GL_UNSIGNED_BYTE); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - dst[i * 3 + 0] = src[i * 3 + 0]; - dst[i * 3 + 1] = src[i * 3 + 1]; - dst[i * 3 + 2] = src[i * 3 + 2]; - } - } -} - - -static void -put_mono_row_ubyte3(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, const void *value, const GLubyte *mask) -{ - /* note: incoming value is RGB+A! */ - const GLubyte val0 = ((const GLubyte *) value)[0]; - const GLubyte val1 = ((const GLubyte *) value)[1]; - const GLubyte val2 = ((const GLubyte *) value)[2]; - GLubyte *dst = (GLubyte *) rb->Data + 3 * (y * rb->RowStride + x); - ASSERT(rb->Format == MESA_FORMAT_RGB888); - ASSERT(rb->DataType == GL_UNSIGNED_BYTE); - if (!mask && val0 == val1 && val1 == val2) { - /* optimized case */ - memset(dst, val0, 3 * count); - } - else { - GLuint i; - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - dst[i * 3 + 0] = val0; - dst[i * 3 + 1] = val1; - dst[i * 3 + 2] = val2; - } - } - } -} - - -static void -put_values_ubyte3(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - const GLint x[], const GLint y[], const void *values, - const GLubyte *mask) -{ - /* note: incoming values are RGB+A! */ - const GLubyte *src = (const GLubyte *) values; - GLuint i; - ASSERT(rb->Format == MESA_FORMAT_RGB888); - ASSERT(rb->DataType == GL_UNSIGNED_BYTE); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - GLubyte *dst = (GLubyte *) rb->Data + 3 * (y[i] * rb->RowStride + x[i]); - dst[0] = src[i * 4 + 0]; - dst[1] = src[i * 4 + 1]; - dst[2] = src[i * 4 + 2]; - } - } -} - - -static void -put_mono_values_ubyte3(struct gl_context *ctx, struct gl_renderbuffer *rb, - GLuint count, const GLint x[], const GLint y[], - const void *value, const GLubyte *mask) -{ - /* note: incoming value is RGB+A! */ - const GLubyte val0 = ((const GLubyte *) value)[0]; - const GLubyte val1 = ((const GLubyte *) value)[1]; - const GLubyte val2 = ((const GLubyte *) value)[2]; - GLuint i; - ASSERT(rb->Format == MESA_FORMAT_RGB888); - ASSERT(rb->DataType == GL_UNSIGNED_BYTE); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - GLubyte *dst = ((GLubyte *) rb->Data) + - 3 * (y[i] * rb->RowStride + x[i]); - dst[0] = val0; - dst[1] = val1; - dst[2] = val2; - } - } -} - - -/********************************************************************** - * Functions for buffers of 4 X GLubyte (or GLbyte) values. - * Typically color buffers. - */ - -static void -get_values_ubyte4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - const GLint x[], const GLint y[], void *values) -{ - /* treat 4*GLubyte as 1*GLuint */ - GLuint *dst = (GLuint *) values; - GLuint i; - ASSERT(rb->DataType == GL_UNSIGNED_BYTE); - ASSERT(rb->Format == MESA_FORMAT_RGBA8888); - for (i = 0; i < count; i++) { - const GLuint *src = (GLuint *) rb->Data + (y[i] * rb->RowStride + x[i]); - dst[i] = *src; - } -} - - -static void -put_row_ubyte4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, const void *values, const GLubyte *mask) -{ - /* treat 4*GLubyte as 1*GLuint */ - const GLuint *src = (const GLuint *) values; - GLuint *dst = (GLuint *) rb->Data + (y * rb->RowStride + x); - ASSERT(rb->DataType == GL_UNSIGNED_BYTE); - ASSERT(rb->Format == MESA_FORMAT_RGBA8888); - if (mask) { - GLuint i; - for (i = 0; i < count; i++) { - if (mask[i]) { - dst[i] = src[i]; - } - } - } - else { - memcpy(dst, src, 4 * count * sizeof(GLubyte)); - } -} - - -static void -put_row_rgb_ubyte4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, const void *values, const GLubyte *mask) -{ - /* Store RGB values in RGBA buffer */ - const GLubyte *src = (const GLubyte *) values; - GLubyte *dst = (GLubyte *) rb->Data + 4 * (y * rb->RowStride + x); - GLuint i; - ASSERT(rb->DataType == GL_UNSIGNED_BYTE); - ASSERT(rb->Format == MESA_FORMAT_RGBA8888); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - dst[i * 4 + 0] = src[i * 3 + 0]; - dst[i * 4 + 1] = src[i * 3 + 1]; - dst[i * 4 + 2] = src[i * 3 + 2]; - dst[i * 4 + 3] = 0xff; - } - } -} - - -static void -put_mono_row_ubyte4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, const void *value, const GLubyte *mask) -{ - /* treat 4*GLubyte as 1*GLuint */ - const GLuint val = *((const GLuint *) value); - GLuint *dst = (GLuint *) rb->Data + (y * rb->RowStride + x); - ASSERT(rb->DataType == GL_UNSIGNED_BYTE); - ASSERT(rb->Format == MESA_FORMAT_RGBA8888); - if (!mask && val == 0) { - /* common case */ - memset(dst, 0, count * 4 * sizeof(GLubyte)); - } - else { - /* general case */ - if (mask) { - GLuint i; - for (i = 0; i < count; i++) { - if (mask[i]) { - dst[i] = val; - } - } - } - else { - GLuint i; - for (i = 0; i < count; i++) { - dst[i] = val; - } - } - } -} - - -static void -put_values_ubyte4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - const GLint x[], const GLint y[], const void *values, - const GLubyte *mask) -{ - /* treat 4*GLubyte as 1*GLuint */ - const GLuint *src = (const GLuint *) values; - GLuint i; - ASSERT(rb->DataType == GL_UNSIGNED_BYTE); - ASSERT(rb->Format == MESA_FORMAT_RGBA8888); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - GLuint *dst = (GLuint *) rb->Data + (y[i] * rb->RowStride + x[i]); - *dst = src[i]; - } - } -} - - -static void -put_mono_values_ubyte4(struct gl_context *ctx, struct gl_renderbuffer *rb, - GLuint count, const GLint x[], const GLint y[], - const void *value, const GLubyte *mask) -{ - /* treat 4*GLubyte as 1*GLuint */ - const GLuint val = *((const GLuint *) value); - GLuint i; - ASSERT(rb->DataType == GL_UNSIGNED_BYTE); - ASSERT(rb->Format == MESA_FORMAT_RGBA8888); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - GLuint *dst = (GLuint *) rb->Data + (y[i] * rb->RowStride + x[i]); - *dst = val; - } - } -} - - -/********************************************************************** - * Functions for buffers of 4 X GLushort (or GLshort) values. - * Typically accum buffer. - */ - -static void -get_values_ushort4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - const GLint x[], const GLint y[], void *values) -{ - GLushort *dst = (GLushort *) values; - GLuint i; - ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT); - for (i = 0; i < count; i++) { - const GLushort *src - = (GLushort *) rb->Data + 4 * (y[i] * rb->RowStride + x[i]); - dst[i] = *src; - } -} - - -static void -put_row_ushort4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, const void *values, const GLubyte *mask) -{ - const GLushort *src = (const GLushort *) values; - GLushort *dst = (GLushort *) rb->Data + 4 * (y * rb->RowStride + x); - ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT); - if (mask) { - GLuint i; - for (i = 0; i < count; i++) { - if (mask[i]) { - dst[i * 4 + 0] = src[i * 4 + 0]; - dst[i * 4 + 1] = src[i * 4 + 1]; - dst[i * 4 + 2] = src[i * 4 + 2]; - dst[i * 4 + 3] = src[i * 4 + 3]; - } - } - } - else { - memcpy(dst, src, 4 * count * sizeof(GLushort)); - } -} - - -static void -put_row_rgb_ushort4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, const void *values, const GLubyte *mask) -{ - /* Put RGB values in RGBA buffer */ - const GLushort *src = (const GLushort *) values; - GLushort *dst = (GLushort *) rb->Data + 4 * (y * rb->RowStride + x); - ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT); - if (mask) { - GLuint i; - for (i = 0; i < count; i++) { - if (mask[i]) { - dst[i * 4 + 0] = src[i * 3 + 0]; - dst[i * 4 + 1] = src[i * 3 + 1]; - dst[i * 4 + 2] = src[i * 3 + 2]; - dst[i * 4 + 3] = 0xffff; - } - } - } - else { - memcpy(dst, src, 4 * count * sizeof(GLushort)); - } -} - - -static void -put_mono_row_ushort4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, const void *value, const GLubyte *mask) -{ - const GLushort val0 = ((const GLushort *) value)[0]; - const GLushort val1 = ((const GLushort *) value)[1]; - const GLushort val2 = ((const GLushort *) value)[2]; - const GLushort val3 = ((const GLushort *) value)[3]; - GLushort *dst = (GLushort *) rb->Data + 4 * (y * rb->RowStride + x); - ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT); - if (!mask && val0 == 0 && val1 == 0 && val2 == 0 && val3 == 0) { - /* common case for clearing accum buffer */ - memset(dst, 0, count * 4 * sizeof(GLushort)); - } - else { - GLuint i; - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - dst[i * 4 + 0] = val0; - dst[i * 4 + 1] = val1; - dst[i * 4 + 2] = val2; - dst[i * 4 + 3] = val3; - } - } - } -} - - -static void -put_values_ushort4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - const GLint x[], const GLint y[], const void *values, - const GLubyte *mask) -{ - const GLushort *src = (const GLushort *) values; - GLuint i; - ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - GLushort *dst = - ((GLushort *) rb->Data) + 4 * (y[i] * rb->RowStride + x[i]); - dst[0] = src[i * 4 + 0]; - dst[1] = src[i * 4 + 1]; - dst[2] = src[i * 4 + 2]; - dst[3] = src[i * 4 + 3]; - } - } -} - - -static void -put_mono_values_ushort4(struct gl_context *ctx, struct gl_renderbuffer *rb, - GLuint count, const GLint x[], const GLint y[], - const void *value, const GLubyte *mask) -{ - const GLushort val0 = ((const GLushort *) value)[0]; - const GLushort val1 = ((const GLushort *) value)[1]; - const GLushort val2 = ((const GLushort *) value)[2]; - const GLushort val3 = ((const GLushort *) value)[3]; - GLuint i; - ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - GLushort *dst = ((GLushort *) rb->Data) + - 4 * (y[i] * rb->RowStride + x[i]); - dst[0] = val0; - dst[1] = val1; - dst[2] = val2; - dst[3] = val3; - } - } -} - -/********************************************************************** - * Functions for MESA_FORMAT_R8. - */ -static void -get_row_r8(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, void *values) -{ - const GLubyte *src = rb->GetPointer(ctx, rb, x, y); - GLuint *dst = values; - GLuint i; - - for (i = 0; i < count; i++) { - dst[i] = 0xff000000 | src[i]; - } -} - -static void -get_values_r8(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - const GLint x[], const GLint y[], void *values) -{ - GLuint *dst = (GLuint *) values; - GLuint i; - - for (i = 0; i < count; i++) { - const GLubyte *src = rb->GetPointer(ctx, rb, x[i], y[i]); - dst[i] = 0xff000000 | *src; - } -} - -/********************************************************************** - * Functions for MESA_FORMAT_RG88. - */ -static void -get_row_rg88(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, void *values) -{ - const GLushort *src = rb->GetPointer(ctx, rb, x, y); - GLuint *dst = values; - GLuint i; - - for (i = 0; i < count; i++) { - dst[i] = 0xff000000 | src[i]; - } -} - -static void -get_values_rg88(struct gl_context *ctx, struct gl_renderbuffer *rb, - GLuint count, const GLint x[], const GLint y[], void *values) -{ - GLuint *dst = (GLuint *) values; - GLuint i; - - for (i = 0; i < count; i++) { - const GLshort *src = rb->GetPointer(ctx, rb, x[i], y[i]); - dst[i] = 0xff000000 | *src; - } -} - -/********************************************************************** - * Functions for MESA_FORMAT_R16. - */ -static void -get_row_r16(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, void *values) -{ - const GLushort *src = rb->GetPointer(ctx, rb, x, y); - GLushort *dst = values; - GLuint i; - - for (i = 0; i < count; i++) { - dst[i * 4 + RCOMP] = src[i]; - dst[i * 4 + GCOMP] = 0; - dst[i * 4 + BCOMP] = 0; - dst[i * 4 + ACOMP] = 0xffff; - } -} - -static void -get_values_r16(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - const GLint x[], const GLint y[], void *values) -{ - GLushort *dst = values; - GLuint i; - - for (i = 0; i < count; i++) { - const GLushort *src = rb->GetPointer(ctx, rb, x[i], y[i]); - dst[i * 4 + RCOMP] = *src; - dst[i * 4 + GCOMP] = 0; - dst[i * 4 + BCOMP] = 0; - dst[i * 4 + ACOMP] = 0xffff; - } -} - -/********************************************************************** - * Functions for MESA_FORMAT_RG1616. - */ -static void -get_row_rg1616(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, void *values) -{ - const GLushort *src = rb->GetPointer(ctx, rb, x, y); - GLushort *dst = values; - GLuint i; - - for (i = 0; i < count; i++) { - dst[i * 4 + RCOMP] = src[i * 2]; - dst[i * 4 + GCOMP] = src[i * 2 + 1]; - dst[i * 4 + BCOMP] = 0; - dst[i * 4 + ACOMP] = 0xffff; - } -} - -static void -get_values_rg1616(struct gl_context *ctx, struct gl_renderbuffer *rb, - GLuint count, const GLint x[], const GLint y[], void *values) -{ - GLushort *dst = values; - GLuint i; - - for (i = 0; i < count; i++) { - const GLshort *src = rb->GetPointer(ctx, rb, x[i], y[i]); - dst[i * 4 + RCOMP] = src[0]; - dst[i * 4 + GCOMP] = src[1]; - dst[i * 4 + BCOMP] = 0; - dst[i * 4 + ACOMP] = 0xffff; - } -} - -/********************************************************************** - * Functions for MESA_FORMAT_INTENSITY_FLOAT32. - */ -static void -get_row_i_float32(struct gl_context *ctx, struct gl_renderbuffer *rb, - GLuint count, GLint x, GLint y, void *values) -{ - const GLfloat *src = rb->GetPointer(ctx, rb, x, y); - GLfloat *dst = values; - GLuint i; - - for (i = 0; i < count; i++) { - dst[i * 4 + RCOMP] = - dst[i * 4 + GCOMP] = - dst[i * 4 + BCOMP] = - dst[i * 4 + ACOMP] = src[i]; - } -} - -static void -get_values_i_float32(struct gl_context *ctx, struct gl_renderbuffer *rb, - GLuint count, const GLint x[], const GLint y[], - void *values) -{ - GLfloat *dst = values; - GLuint i; - - for (i = 0; i < count; i++) { - const GLfloat *src = rb->GetPointer(ctx, rb, x[i], y[i]); - dst[i * 4 + RCOMP] = - dst[i * 4 + GCOMP] = - dst[i * 4 + BCOMP] = - dst[i * 4 + ACOMP] = src[0]; - } -} - -/********************************************************************** - * Functions for MESA_FORMAT_LUMINANCE_FLOAT32. - */ -static void -get_row_l_float32(struct gl_context *ctx, struct gl_renderbuffer *rb, - GLuint count, GLint x, GLint y, void *values) -{ - const GLfloat *src = rb->GetPointer(ctx, rb, x, y); - GLfloat *dst = values; - GLuint i; - - for (i = 0; i < count; i++) { - dst[i * 4 + RCOMP] = - dst[i * 4 + GCOMP] = - dst[i * 4 + BCOMP] = src[i]; - dst[i * 4 + ACOMP] = 1.0; - } -} - -static void -get_values_l_float32(struct gl_context *ctx, struct gl_renderbuffer *rb, - GLuint count, const GLint x[], const GLint y[], - void *values) -{ - GLfloat *dst = values; - GLuint i; - - for (i = 0; i < count; i++) { - const GLfloat *src = rb->GetPointer(ctx, rb, x[i], y[i]); - dst[i * 4 + RCOMP] = - dst[i * 4 + GCOMP] = - dst[i * 4 + BCOMP] = src[0]; - dst[i * 4 + ACOMP] = 1.0; - } -} - -/********************************************************************** - * Functions for MESA_FORMAT_ALPHA_FLOAT32. - */ -static void -get_row_a_float32(struct gl_context *ctx, struct gl_renderbuffer *rb, - GLuint count, GLint x, GLint y, void *values) -{ - const GLfloat *src = rb->GetPointer(ctx, rb, x, y); - GLfloat *dst = values; - GLuint i; - - for (i = 0; i < count; i++) { - dst[i * 4 + RCOMP] = 0.0; - dst[i * 4 + GCOMP] = 0.0; - dst[i * 4 + BCOMP] = 0.0; - dst[i * 4 + ACOMP] = src[i]; - } -} - -static void -get_values_a_float32(struct gl_context *ctx, struct gl_renderbuffer *rb, - GLuint count, const GLint x[], const GLint y[], - void *values) -{ - GLfloat *dst = values; - GLuint i; - - for (i = 0; i < count; i++) { - const GLfloat *src = rb->GetPointer(ctx, rb, x[i], y[i]); - dst[i * 4 + RCOMP] = 0.0; - dst[i * 4 + GCOMP] = 0.0; - dst[i * 4 + BCOMP] = 0.0; - dst[i * 4 + ACOMP] = src[0]; - } -} - -static void -put_row_a_float32(struct gl_context *ctx, struct gl_renderbuffer *rb, - GLuint count, GLint x, GLint y, - const void *values, const GLubyte *mask) -{ - float *dst = rb->GetPointer(ctx, rb, x, y); - const float *src = values; - unsigned int i; - - if (mask) { - for (i = 0; i < count; i++) { - if (mask[i]) { - dst[i] = src[i * 4 + ACOMP]; - } - } - } - else { - for (i = 0; i < count; i++) { - dst[i] = src[i * 4 + ACOMP]; - } - } -} - -static void -put_mono_row_a_float32(struct gl_context *ctx, struct gl_renderbuffer *rb, - GLuint count, GLint x, GLint y, - const void *value, const GLubyte *mask) -{ - float *dst = rb->GetPointer(ctx, rb, x, y); - const float *src = value; - unsigned int i; - - if (mask) { - for (i = 0; i < count; i++) { - if (mask[i]) { - dst[i] = src[ACOMP]; - } - } - } - else { - for (i = 0; i < count; i++) { - dst[i] = src[ACOMP]; - } - } -} - -static void -put_values_a_float32(struct gl_context *ctx, struct gl_renderbuffer *rb, - GLuint count, const GLint x[], const GLint y[], - const void *values, const GLubyte *mask) -{ - const float *src = values; - unsigned int i; - - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - float *dst = rb->GetPointer(ctx, rb, x[i], y[i]); - - *dst = src[i * 4 + ACOMP]; - } - } -} - -static void -put_mono_values_a_float32(struct gl_context *ctx, - struct gl_renderbuffer *rb, - GLuint count, const GLint x[], const GLint y[], - const void *value, const GLubyte *mask) -{ - const float *src = value; - unsigned int i; - - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - float *dst = rb->GetPointer(ctx, rb, x[i], y[i]); - *dst = src[ACOMP]; - } - } -} - -/********************************************************************** - * Functions for MESA_FORMAT_R_FLOAT32. - */ -static void -get_row_r_float32(struct gl_context *ctx, struct gl_renderbuffer *rb, - GLuint count, GLint x, GLint y, void *values) -{ - const GLfloat *src = rb->GetPointer(ctx, rb, x, y); - GLfloat *dst = values; - GLuint i; - - for (i = 0; i < count; i++) { - dst[i * 4 + RCOMP] = src[i]; - dst[i * 4 + GCOMP] = 0.0; - dst[i * 4 + BCOMP] = 0.0; - dst[i * 4 + ACOMP] = 1.0; - } -} - -static void -get_values_r_float32(struct gl_context *ctx, struct gl_renderbuffer *rb, - GLuint count, const GLint x[], const GLint y[], - void *values) -{ - GLfloat *dst = values; - GLuint i; - - for (i = 0; i < count; i++) { - const GLfloat *src = rb->GetPointer(ctx, rb, x[i], y[i]); - dst[i * 4 + RCOMP] = src[0]; - dst[i * 4 + GCOMP] = 0.0; - dst[i * 4 + BCOMP] = 0.0; - dst[i * 4 + ACOMP] = 1.0; - } -} - -/********************************************************************** - * Functions for MESA_FORMAT_RG_FLOAT32. - */ -static void -get_row_rg_float32(struct gl_context *ctx, struct gl_renderbuffer *rb, - GLuint count, GLint x, GLint y, void *values) -{ - const GLfloat *src = rb->GetPointer(ctx, rb, x, y); - GLfloat *dst = values; - GLuint i; - - for (i = 0; i < count; i++) { - dst[i * 4 + RCOMP] = src[i * 2 + 0]; - dst[i * 4 + GCOMP] = src[i * 2 + 1]; - dst[i * 4 + BCOMP] = 0.0; - dst[i * 4 + ACOMP] = 1.0; - } -} - -static void -get_values_rg_float32(struct gl_context *ctx, struct gl_renderbuffer *rb, - GLuint count, const GLint x[], const GLint y[], - void *values) -{ - GLfloat *dst = values; - GLuint i; - - for (i = 0; i < count; i++) { - const GLfloat *src = rb->GetPointer(ctx, rb, x[i], y[i]); - dst[i * 4 + RCOMP] = src[0]; - dst[i * 4 + GCOMP] = src[1]; - dst[i * 4 + BCOMP] = 0.0; - dst[i * 4 + ACOMP] = 1.0; - } -} - -/** - * This is the default software fallback for gl_renderbuffer's span - * access functions. - * - * The assumptions are that rb->Data will be a pointer to (0,0), that pixels - * are packed in the type of rb->Format, and that subsequent rows appear - * rb->RowStride pixels later. - */ -void -_mesa_set_renderbuffer_accessors(struct gl_renderbuffer *rb) -{ - rb->GetPointer = get_pointer_generic; - rb->GetRow = get_row_generic; - - switch (rb->Format) { - case MESA_FORMAT_RGB888: - rb->DataType = GL_UNSIGNED_BYTE; - rb->GetPointer = get_pointer_ubyte3; - rb->GetRow = get_row_ubyte3; - rb->GetValues = get_values_ubyte3; - rb->PutRow = put_row_ubyte3; - rb->PutRowRGB = put_row_rgb_ubyte3; - rb->PutMonoRow = put_mono_row_ubyte3; - rb->PutValues = put_values_ubyte3; - rb->PutMonoValues = put_mono_values_ubyte3; - break; - - case MESA_FORMAT_RGBA8888: - rb->DataType = GL_UNSIGNED_BYTE; - rb->GetValues = get_values_ubyte4; - rb->PutRow = put_row_ubyte4; - rb->PutRowRGB = put_row_rgb_ubyte4; - rb->PutMonoRow = put_mono_row_ubyte4; - rb->PutValues = put_values_ubyte4; - rb->PutMonoValues = put_mono_values_ubyte4; - break; - - case MESA_FORMAT_R8: - rb->DataType = GL_UNSIGNED_BYTE; - rb->GetValues = get_values_r8; - rb->GetRow = get_row_r8; - rb->PutRow = put_row_generic; - rb->PutRowRGB = put_row_generic; - rb->PutMonoRow = put_mono_row_generic; - rb->PutValues = put_values_generic; - rb->PutMonoValues = put_mono_values_generic; - break; - - case MESA_FORMAT_RG88: - rb->DataType = GL_UNSIGNED_BYTE; - rb->GetValues = get_values_rg88; - rb->GetRow = get_row_rg88; - rb->PutRow = put_row_generic; - rb->PutRowRGB = put_row_generic; - rb->PutMonoRow = put_mono_row_generic; - rb->PutValues = put_values_generic; - rb->PutMonoValues = put_mono_values_generic; - break; - - case MESA_FORMAT_R16: - rb->DataType = GL_UNSIGNED_SHORT; - rb->GetValues = get_values_r16; - rb->GetRow = get_row_r16; - rb->PutRow = put_row_generic; - rb->PutRowRGB = put_row_generic; - rb->PutMonoRow = put_mono_row_generic; - rb->PutValues = put_values_generic; - rb->PutMonoValues = put_mono_values_generic; - break; - - case MESA_FORMAT_RG1616: - rb->DataType = GL_UNSIGNED_SHORT; - rb->GetValues = get_values_rg1616; - rb->GetRow = get_row_rg1616; - rb->PutRow = put_row_generic; - rb->PutRowRGB = put_row_generic; - rb->PutMonoRow = put_mono_row_generic; - rb->PutValues = put_values_generic; - rb->PutMonoValues = put_mono_values_generic; - break; - - case MESA_FORMAT_SIGNED_RGBA_16: - rb->DataType = GL_SHORT; - rb->GetValues = get_values_ushort4; - rb->PutRow = put_row_ushort4; - rb->PutRowRGB = put_row_rgb_ushort4; - rb->PutMonoRow = put_mono_row_ushort4; - rb->PutValues = put_values_ushort4; - rb->PutMonoValues = put_mono_values_ushort4; - break; - -#if 0 - case MESA_FORMAT_A8: - rb->DataType = GL_UNSIGNED_BYTE; - rb->GetValues = get_values_alpha8; - rb->PutRow = put_row_alpha8; - rb->PutRowRGB = NULL; - rb->PutMonoRow = put_mono_row_alpha8; - rb->PutValues = put_values_alpha8; - rb->PutMonoValues = put_mono_values_alpha8; - break; -#endif - - case MESA_FORMAT_S8: - rb->DataType = GL_UNSIGNED_BYTE; - rb->GetValues = get_values_ubyte; - rb->PutRow = put_row_ubyte; - rb->PutRowRGB = NULL; - rb->PutMonoRow = put_mono_row_ubyte; - rb->PutValues = put_values_ubyte; - rb->PutMonoValues = put_mono_values_ubyte; - break; - - case MESA_FORMAT_Z16: - rb->DataType = GL_UNSIGNED_SHORT; - rb->GetValues = get_values_ushort; - rb->PutRow = put_row_ushort; - rb->PutRowRGB = NULL; - rb->PutMonoRow = put_mono_row_ushort; - rb->PutValues = put_values_ushort; - rb->PutMonoValues = put_mono_values_ushort; - break; - - case MESA_FORMAT_Z32: - case MESA_FORMAT_X8_Z24: - case MESA_FORMAT_Z24_X8: - rb->DataType = GL_UNSIGNED_INT; - rb->GetValues = get_values_uint; - rb->PutRow = put_row_uint; - rb->PutRowRGB = NULL; - rb->PutMonoRow = put_mono_row_uint; - rb->PutValues = put_values_uint; - rb->PutMonoValues = put_mono_values_uint; - break; - - case MESA_FORMAT_Z24_S8: - case MESA_FORMAT_S8_Z24: - rb->DataType = GL_UNSIGNED_INT_24_8_EXT; - rb->GetValues = get_values_uint; - rb->PutRow = put_row_uint; - rb->PutRowRGB = NULL; - rb->PutMonoRow = put_mono_row_uint; - rb->PutValues = put_values_uint; - rb->PutMonoValues = put_mono_values_uint; - break; - - case MESA_FORMAT_RGBA_FLOAT32: - rb->GetRow = get_row_generic; - rb->GetValues = get_values_generic; - rb->PutRow = put_row_generic; - rb->PutRowRGB = NULL; - rb->PutMonoRow = put_mono_row_generic; - rb->PutValues = put_values_generic; - rb->PutMonoValues = put_mono_values_generic; - break; - - case MESA_FORMAT_INTENSITY_FLOAT32: - rb->GetRow = get_row_i_float32; - rb->GetValues = get_values_i_float32; - rb->PutRow = put_row_generic; - rb->PutRowRGB = NULL; - rb->PutMonoRow = put_mono_row_generic; - rb->PutValues = put_values_generic; - rb->PutMonoValues = put_mono_values_generic; - break; - - case MESA_FORMAT_LUMINANCE_FLOAT32: - rb->GetRow = get_row_l_float32; - rb->GetValues = get_values_l_float32; - rb->PutRow = put_row_generic; - rb->PutRowRGB = NULL; - rb->PutMonoRow = put_mono_row_generic; - rb->PutValues = put_values_generic; - rb->PutMonoValues = put_mono_values_generic; - break; - - case MESA_FORMAT_ALPHA_FLOAT32: - rb->GetRow = get_row_a_float32; - rb->GetValues = get_values_a_float32; - rb->PutRow = put_row_a_float32; - rb->PutRowRGB = NULL; - rb->PutMonoRow = put_mono_row_a_float32; - rb->PutValues = put_values_a_float32; - rb->PutMonoValues = put_mono_values_a_float32; - break; - - case MESA_FORMAT_RG_FLOAT32: - rb->GetRow = get_row_rg_float32; - rb->GetValues = get_values_rg_float32; - rb->PutRow = put_row_generic; - rb->PutRowRGB = NULL; - rb->PutMonoRow = put_mono_row_generic; - rb->PutValues = put_values_generic; - rb->PutMonoValues = put_mono_values_generic; - break; - - case MESA_FORMAT_R_FLOAT32: - rb->GetRow = get_row_r_float32; - rb->GetValues = get_values_r_float32; - rb->PutRow = put_row_generic; - rb->PutRowRGB = NULL; - rb->PutMonoRow = put_mono_row_generic; - rb->PutValues = put_values_generic; - rb->PutMonoValues = put_mono_values_generic; - break; - - default: - break; - } -} - -/** - * This is a software fallback for the gl_renderbuffer->AllocStorage - * function. - * Device drivers will typically override this function for the buffers - * which it manages (typically color buffers, Z and stencil). - * Other buffers (like software accumulation and aux buffers) which the driver - * doesn't manage can be handled with this function. - * - * This one multi-purpose function can allocate stencil, depth, accum, color - * or color-index buffers! - * - * This function also plugs in the appropriate GetPointer, Get/PutRow and - * Get/PutValues functions. - */ -GLboolean -_mesa_soft_renderbuffer_storage(struct gl_context *ctx, struct gl_renderbuffer *rb, - GLenum internalFormat, - GLuint width, GLuint height) -{ - switch (internalFormat) { - case GL_RGB: - case GL_R3_G3_B2: - case GL_RGB4: - case GL_RGB5: - case GL_RGB8: - case GL_RGB10: - case GL_RGB12: - case GL_RGB16: - rb->Format = MESA_FORMAT_RGB888; - break; - case GL_RGBA: - case GL_RGBA2: - case GL_RGBA4: - case GL_RGB5_A1: - case GL_RGBA8: -#if 1 - case GL_RGB10_A2: - case GL_RGBA12: -#endif - rb->Format = MESA_FORMAT_RGBA8888; - break; - case GL_RGBA16: - case GL_RGBA16_SNORM: - /* for accum buffer */ - rb->Format = MESA_FORMAT_SIGNED_RGBA_16; - break; -#if 0 - case GL_ALPHA8: - rb->Format = MESA_FORMAT_A8; - break; -#endif - case GL_STENCIL_INDEX: - case GL_STENCIL_INDEX1_EXT: - case GL_STENCIL_INDEX4_EXT: - case GL_STENCIL_INDEX8_EXT: - case GL_STENCIL_INDEX16_EXT: - rb->Format = MESA_FORMAT_S8; - break; - case GL_DEPTH_COMPONENT: - case GL_DEPTH_COMPONENT16: - rb->Format = MESA_FORMAT_Z16; - break; - case GL_DEPTH_COMPONENT24: - rb->Format = MESA_FORMAT_X8_Z24; - break; - case GL_DEPTH_COMPONENT32: - rb->Format = MESA_FORMAT_Z32; - break; - case GL_DEPTH_STENCIL_EXT: - case GL_DEPTH24_STENCIL8_EXT: - rb->Format = MESA_FORMAT_Z24_S8; - break; - default: - /* unsupported format */ - return GL_FALSE; - } - - _mesa_set_renderbuffer_accessors(rb); - - ASSERT(rb->DataType); - ASSERT(rb->GetPointer); - ASSERT(rb->GetRow); - ASSERT(rb->GetValues); - ASSERT(rb->PutRow); - ASSERT(rb->PutMonoRow); - ASSERT(rb->PutValues); - ASSERT(rb->PutMonoValues); - - /* free old buffer storage */ - if (rb->Data) { - free(rb->Data); - rb->Data = NULL; - } - - rb->RowStride = width; - - if (width > 0 && height > 0) { - /* allocate new buffer storage */ - rb->Data = malloc(width * height * _mesa_get_format_bytes(rb->Format)); - - if (rb->Data == NULL) { - rb->Width = 0; - rb->Height = 0; - rb->RowStride = 0; - _mesa_error(ctx, GL_OUT_OF_MEMORY, - "software renderbuffer allocation (%d x %d x %d)", - width, height, _mesa_get_format_bytes(rb->Format)); - return GL_FALSE; - } - } - - rb->Width = width; - rb->Height = height; - rb->_BaseFormat = _mesa_base_fbo_format(ctx, internalFormat); - - if (rb->Name == 0 && - internalFormat == GL_RGBA16_SNORM && - rb->_BaseFormat == 0) { - /* NOTE: This is a special case just for accumulation buffers. - * This is a very limited use case- there's no snorm texturing or - * rendering going on. - */ - rb->_BaseFormat = GL_RGBA; - } - else { - /* the internalFormat should have been error checked long ago */ - ASSERT(rb->_BaseFormat); - } - - return GL_TRUE; -} - - - -/**********************************************************************/ -/**********************************************************************/ -/**********************************************************************/ - - -/** - * Here we utilize the gl_renderbuffer->Wrapper field to put an alpha - * buffer wrapper around an existing RGB renderbuffer (hw or sw). - * - * When PutRow is called (for example), we store the alpha values in - * this buffer, then pass on the PutRow call to the wrapped RGB - * buffer. - */ - - -static GLboolean -alloc_storage_alpha8(struct gl_context *ctx, struct gl_renderbuffer *arb, - GLenum internalFormat, GLuint width, GLuint height) -{ - ASSERT(arb != arb->Wrapped); - ASSERT(arb->Format == MESA_FORMAT_A8); - - /* first, pass the call to the wrapped RGB buffer */ - if (!arb->Wrapped->AllocStorage(ctx, arb->Wrapped, internalFormat, - width, height)) { - return GL_FALSE; - } - - /* next, resize my alpha buffer */ - if (arb->Data) { - free(arb->Data); - } - - arb->Data = malloc(width * height * sizeof(GLubyte)); - if (arb->Data == NULL) { - arb->Width = 0; - arb->Height = 0; - _mesa_error(ctx, GL_OUT_OF_MEMORY, "software alpha buffer allocation"); - return GL_FALSE; - } - - arb->Width = width; - arb->Height = height; - arb->RowStride = width; - - return GL_TRUE; -} - - -/** - * Delete an alpha_renderbuffer object, as well as the wrapped RGB buffer. - */ -static void -delete_renderbuffer_alpha8(struct gl_renderbuffer *arb) -{ - if (arb->Data) { - free(arb->Data); - } - ASSERT(arb->Wrapped); - ASSERT(arb != arb->Wrapped); - arb->Wrapped->Delete(arb->Wrapped); - arb->Wrapped = NULL; - free(arb); -} - - -static void * -get_pointer_alpha8(struct gl_context *ctx, struct gl_renderbuffer *arb, - GLint x, GLint y) -{ - return NULL; /* don't allow direct access! */ -} - - -static void -get_row_alpha8(struct gl_context *ctx, struct gl_renderbuffer *arb, GLuint count, - GLint x, GLint y, void *values) -{ - /* NOTE: 'values' is RGBA format! */ - const GLubyte *src = (const GLubyte *) arb->Data + y * arb->RowStride + x; - GLubyte *dst = (GLubyte *) values; - GLuint i; - ASSERT(arb != arb->Wrapped); - ASSERT(arb->DataType == GL_UNSIGNED_BYTE); - /* first, pass the call to the wrapped RGB buffer */ - arb->Wrapped->GetRow(ctx, arb->Wrapped, count, x, y, values); - /* second, fill in alpha values from this buffer! */ - for (i = 0; i < count; i++) { - dst[i * 4 + 3] = src[i]; - } -} - - -static void -get_values_alpha8(struct gl_context *ctx, struct gl_renderbuffer *arb, GLuint count, - const GLint x[], const GLint y[], void *values) -{ - GLubyte *dst = (GLubyte *) values; - GLuint i; - ASSERT(arb != arb->Wrapped); - ASSERT(arb->DataType == GL_UNSIGNED_BYTE); - /* first, pass the call to the wrapped RGB buffer */ - arb->Wrapped->GetValues(ctx, arb->Wrapped, count, x, y, values); - /* second, fill in alpha values from this buffer! */ - for (i = 0; i < count; i++) { - const GLubyte *src = (GLubyte *) arb->Data + y[i] * arb->RowStride + x[i]; - dst[i * 4 + 3] = *src; - } -} - - -static void -put_row_alpha8(struct gl_context *ctx, struct gl_renderbuffer *arb, GLuint count, - GLint x, GLint y, const void *values, const GLubyte *mask) -{ - const GLubyte *src = (const GLubyte *) values; - GLubyte *dst = (GLubyte *) arb->Data + y * arb->RowStride + x; - GLuint i; - ASSERT(arb != arb->Wrapped); - ASSERT(arb->DataType == GL_UNSIGNED_BYTE); - /* first, pass the call to the wrapped RGB buffer */ - arb->Wrapped->PutRow(ctx, arb->Wrapped, count, x, y, values, mask); - /* second, store alpha in our buffer */ - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - dst[i] = src[i * 4 + 3]; - } - } -} - - -static void -put_row_rgb_alpha8(struct gl_context *ctx, struct gl_renderbuffer *arb, GLuint count, - GLint x, GLint y, const void *values, const GLubyte *mask) -{ - const GLubyte *src = (const GLubyte *) values; - GLubyte *dst = (GLubyte *) arb->Data + y * arb->RowStride + x; - GLuint i; - ASSERT(arb != arb->Wrapped); - ASSERT(arb->DataType == GL_UNSIGNED_BYTE); - /* first, pass the call to the wrapped RGB buffer */ - arb->Wrapped->PutRowRGB(ctx, arb->Wrapped, count, x, y, values, mask); - /* second, store alpha in our buffer */ - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - dst[i] = src[i * 4 + 3]; - } - } -} - - -static void -put_mono_row_alpha8(struct gl_context *ctx, struct gl_renderbuffer *arb, GLuint count, - GLint x, GLint y, const void *value, const GLubyte *mask) -{ - const GLubyte val = ((const GLubyte *) value)[3]; - GLubyte *dst = (GLubyte *) arb->Data + y * arb->RowStride + x; - ASSERT(arb != arb->Wrapped); - ASSERT(arb->DataType == GL_UNSIGNED_BYTE); - /* first, pass the call to the wrapped RGB buffer */ - arb->Wrapped->PutMonoRow(ctx, arb->Wrapped, count, x, y, value, mask); - /* second, store alpha in our buffer */ - if (mask) { - GLuint i; - for (i = 0; i < count; i++) { - if (mask[i]) { - dst[i] = val; - } - } - } - else { - memset(dst, val, count); - } -} - - -static void -put_values_alpha8(struct gl_context *ctx, struct gl_renderbuffer *arb, GLuint count, - const GLint x[], const GLint y[], - const void *values, const GLubyte *mask) -{ - const GLubyte *src = (const GLubyte *) values; - GLuint i; - ASSERT(arb != arb->Wrapped); - ASSERT(arb->DataType == GL_UNSIGNED_BYTE); - /* first, pass the call to the wrapped RGB buffer */ - arb->Wrapped->PutValues(ctx, arb->Wrapped, count, x, y, values, mask); - /* second, store alpha in our buffer */ - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - GLubyte *dst = (GLubyte *) arb->Data + y[i] * arb->RowStride + x[i]; - *dst = src[i * 4 + 3]; - } - } -} - - -static void -put_mono_values_alpha8(struct gl_context *ctx, struct gl_renderbuffer *arb, - GLuint count, const GLint x[], const GLint y[], - const void *value, const GLubyte *mask) -{ - const GLubyte val = ((const GLubyte *) value)[3]; - GLuint i; - ASSERT(arb != arb->Wrapped); - ASSERT(arb->DataType == GL_UNSIGNED_BYTE); - /* first, pass the call to the wrapped RGB buffer */ - arb->Wrapped->PutValues(ctx, arb->Wrapped, count, x, y, value, mask); - /* second, store alpha in our buffer */ - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - GLubyte *dst = (GLubyte *) arb->Data + y[i] * arb->RowStride + x[i]; - *dst = val; - } - } -} - - -static void -copy_buffer_alpha8(struct gl_renderbuffer* dst, struct gl_renderbuffer* src) -{ - ASSERT(dst->Format == MESA_FORMAT_A8); - ASSERT(src->Format == MESA_FORMAT_A8); - ASSERT(dst->Width == src->Width); - ASSERT(dst->Height == src->Height); - ASSERT(dst->RowStride == src->RowStride); - - memcpy(dst->Data, src->Data, dst->RowStride * dst->Height * sizeof(GLubyte)); -} - - -/**********************************************************************/ -/**********************************************************************/ -/**********************************************************************/ - - -/** - * Default GetPointer routine. Always return NULL to indicate that - * direct buffer access is not supported. - */ -static void * -nop_get_pointer(struct gl_context *ctx, struct gl_renderbuffer *rb, GLint x, GLint y) -{ - return NULL; -} - - -/** - * Initialize the fields of a gl_renderbuffer to default values. - */ -void -_mesa_init_renderbuffer(struct gl_renderbuffer *rb, GLuint name) -{ - _glthread_INIT_MUTEX(rb->Mutex); - - rb->ClassID = 0; - rb->Name = name; - rb->RefCount = 0; - rb->Delete = _mesa_delete_renderbuffer; - - /* The rest of these should be set later by the caller of this function or - * the AllocStorage method: - */ - rb->AllocStorage = NULL; - - rb->Width = 0; - rb->Height = 0; - rb->InternalFormat = GL_NONE; - rb->Format = MESA_FORMAT_NONE; - - rb->DataType = GL_NONE; - rb->Data = NULL; - - /* Point back to ourself so that we don't have to check for Wrapped==NULL - * all over the drivers. - */ - rb->Wrapped = rb; - - rb->GetPointer = nop_get_pointer; - rb->GetRow = NULL; - rb->GetValues = NULL; - rb->PutRow = NULL; - rb->PutRowRGB = NULL; - rb->PutMonoRow = NULL; - rb->PutValues = NULL; - rb->PutMonoValues = NULL; -} - - -/** - * Allocate a new gl_renderbuffer object. This can be used for user-created - * renderbuffers or window-system renderbuffers. - */ -struct gl_renderbuffer * -_mesa_new_renderbuffer(struct gl_context *ctx, GLuint name) -{ - struct gl_renderbuffer *rb = CALLOC_STRUCT(gl_renderbuffer); - if (rb) { - _mesa_init_renderbuffer(rb, name); - } - return rb; -} - - -/** - * Delete a gl_framebuffer. - * This is the default function for renderbuffer->Delete(). - */ -void -_mesa_delete_renderbuffer(struct gl_renderbuffer *rb) -{ - if (rb->Data) { - free(rb->Data); - } - free(rb); -} - - -/** - * Allocate a software-based renderbuffer. This is called via the - * ctx->Driver.NewRenderbuffer() function when the user creates a new - * renderbuffer. - * This would not be used for hardware-based renderbuffers. - */ -struct gl_renderbuffer * -_mesa_new_soft_renderbuffer(struct gl_context *ctx, GLuint name) -{ - struct gl_renderbuffer *rb = _mesa_new_renderbuffer(ctx, name); - if (rb) { - rb->AllocStorage = _mesa_soft_renderbuffer_storage; - /* Normally, one would setup the PutRow, GetRow, etc functions here. - * But we're doing that in the _mesa_soft_renderbuffer_storage() function - * instead. - */ - } - return rb; -} - - -/** - * Add software-based color renderbuffers to the given framebuffer. - * This is a helper routine for device drivers when creating a - * window system framebuffer (not a user-created render/framebuffer). - * Once this function is called, you can basically forget about this - * renderbuffer; core Mesa will handle all the buffer management and - * rendering! - */ -GLboolean -_mesa_add_color_renderbuffers(struct gl_context *ctx, struct gl_framebuffer *fb, - GLuint rgbBits, GLuint alphaBits, - GLboolean frontLeft, GLboolean backLeft, - GLboolean frontRight, GLboolean backRight) -{ - gl_buffer_index b; - - if (rgbBits > 16 || alphaBits > 16) { - _mesa_problem(ctx, - "Unsupported bit depth in _mesa_add_color_renderbuffers"); - return GL_FALSE; - } - - assert(MAX_COLOR_ATTACHMENTS >= 4); - - for (b = BUFFER_FRONT_LEFT; b <= BUFFER_BACK_RIGHT; b++) { - struct gl_renderbuffer *rb; - - if (b == BUFFER_FRONT_LEFT && !frontLeft) - continue; - else if (b == BUFFER_BACK_LEFT && !backLeft) - continue; - else if (b == BUFFER_FRONT_RIGHT && !frontRight) - continue; - else if (b == BUFFER_BACK_RIGHT && !backRight) - continue; - - assert(fb->Attachment[b].Renderbuffer == NULL); - - rb = _mesa_new_renderbuffer(ctx, 0); - if (!rb) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating color buffer"); - return GL_FALSE; - } - - if (rgbBits <= 8) { - if (alphaBits) - rb->Format = MESA_FORMAT_RGBA8888; - else - rb->Format = MESA_FORMAT_RGB888; - } - else { - assert(rgbBits <= 16); - rb->Format = MESA_FORMAT_NONE; /*XXX RGBA16;*/ - } - rb->InternalFormat = GL_RGBA; - - rb->AllocStorage = _mesa_soft_renderbuffer_storage; - _mesa_add_renderbuffer(fb, b, rb); - } - - return GL_TRUE; -} - - -/** - * Add software-based alpha renderbuffers to the given framebuffer. - * This is a helper routine for device drivers when creating a - * window system framebuffer (not a user-created render/framebuffer). - * Once this function is called, you can basically forget about this - * renderbuffer; core Mesa will handle all the buffer management and - * rendering! - */ -GLboolean -_mesa_add_alpha_renderbuffers(struct gl_context *ctx, struct gl_framebuffer *fb, - GLuint alphaBits, - GLboolean frontLeft, GLboolean backLeft, - GLboolean frontRight, GLboolean backRight) -{ - gl_buffer_index b; - - /* for window system framebuffers only! */ - assert(fb->Name == 0); - - if (alphaBits > 8) { - _mesa_problem(ctx, - "Unsupported bit depth in _mesa_add_alpha_renderbuffers"); - return GL_FALSE; - } - - assert(MAX_COLOR_ATTACHMENTS >= 4); - - /* Wrap each of the RGB color buffers with an alpha renderbuffer. - */ - for (b = BUFFER_FRONT_LEFT; b <= BUFFER_BACK_RIGHT; b++) { - struct gl_renderbuffer *arb; - - if (b == BUFFER_FRONT_LEFT && !frontLeft) - continue; - else if (b == BUFFER_BACK_LEFT && !backLeft) - continue; - else if (b == BUFFER_FRONT_RIGHT && !frontRight) - continue; - else if (b == BUFFER_BACK_RIGHT && !backRight) - continue; - - /* the RGB buffer to wrap must already exist!! */ - assert(fb->Attachment[b].Renderbuffer); - - /* only GLubyte supported for now */ - assert(fb->Attachment[b].Renderbuffer->DataType == GL_UNSIGNED_BYTE); - - /* allocate alpha renderbuffer */ - arb = _mesa_new_renderbuffer(ctx, 0); - if (!arb) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating alpha buffer"); - return GL_FALSE; - } - - /* wrap the alpha renderbuffer around the RGB renderbuffer */ - arb->Wrapped = fb->Attachment[b].Renderbuffer; - - /* Set up my alphabuffer fields and plug in my functions. - * The functions will put/get the alpha values from/to RGBA arrays - * and then call the wrapped buffer's functions to handle the RGB - * values. - */ - arb->InternalFormat = arb->Wrapped->InternalFormat; - arb->Format = MESA_FORMAT_A8; - arb->DataType = arb->Wrapped->DataType; - arb->AllocStorage = alloc_storage_alpha8; - arb->Delete = delete_renderbuffer_alpha8; - arb->GetPointer = get_pointer_alpha8; - arb->GetRow = get_row_alpha8; - arb->GetValues = get_values_alpha8; - arb->PutRow = put_row_alpha8; - arb->PutRowRGB = put_row_rgb_alpha8; - arb->PutMonoRow = put_mono_row_alpha8; - arb->PutValues = put_values_alpha8; - arb->PutMonoValues = put_mono_values_alpha8; - - /* clear the pointer to avoid assertion/sanity check failure later */ - fb->Attachment[b].Renderbuffer = NULL; - - /* plug the alpha renderbuffer into the colorbuffer attachment */ - _mesa_add_renderbuffer(fb, b, arb); - } - - return GL_TRUE; -} - - -/** - * For framebuffers that use a software alpha channel wrapper - * created by _mesa_add_alpha_renderbuffer or _mesa_add_soft_renderbuffers, - * copy the back buffer alpha channel into the front buffer alpha channel. - */ -void -_mesa_copy_soft_alpha_renderbuffers(struct gl_context *ctx, struct gl_framebuffer *fb) -{ - if (fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer && - fb->Attachment[BUFFER_BACK_LEFT].Renderbuffer) - copy_buffer_alpha8(fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer, - fb->Attachment[BUFFER_BACK_LEFT].Renderbuffer); - - - if (fb->Attachment[BUFFER_FRONT_RIGHT].Renderbuffer && - fb->Attachment[BUFFER_BACK_RIGHT].Renderbuffer) - copy_buffer_alpha8(fb->Attachment[BUFFER_FRONT_RIGHT].Renderbuffer, - fb->Attachment[BUFFER_BACK_RIGHT].Renderbuffer); -} - - -/** - * Add a software-based depth renderbuffer to the given framebuffer. - * This is a helper routine for device drivers when creating a - * window system framebuffer (not a user-created render/framebuffer). - * Once this function is called, you can basically forget about this - * renderbuffer; core Mesa will handle all the buffer management and - * rendering! - */ -GLboolean -_mesa_add_depth_renderbuffer(struct gl_context *ctx, struct gl_framebuffer *fb, - GLuint depthBits) -{ - struct gl_renderbuffer *rb; - - if (depthBits > 32) { - _mesa_problem(ctx, - "Unsupported depthBits in _mesa_add_depth_renderbuffer"); - return GL_FALSE; - } - - assert(fb->Attachment[BUFFER_DEPTH].Renderbuffer == NULL); - - rb = _mesa_new_renderbuffer(ctx, 0); - if (!rb) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating depth buffer"); - return GL_FALSE; - } - - if (depthBits <= 16) { - rb->Format = MESA_FORMAT_Z16; - rb->InternalFormat = GL_DEPTH_COMPONENT16; - } - else if (depthBits <= 24) { - rb->Format = MESA_FORMAT_X8_Z24; - rb->InternalFormat = GL_DEPTH_COMPONENT24; - } - else { - rb->Format = MESA_FORMAT_Z32; - rb->InternalFormat = GL_DEPTH_COMPONENT32; - } - - rb->AllocStorage = _mesa_soft_renderbuffer_storage; - _mesa_add_renderbuffer(fb, BUFFER_DEPTH, rb); - - return GL_TRUE; -} - - -/** - * Add a software-based stencil renderbuffer to the given framebuffer. - * This is a helper routine for device drivers when creating a - * window system framebuffer (not a user-created render/framebuffer). - * Once this function is called, you can basically forget about this - * renderbuffer; core Mesa will handle all the buffer management and - * rendering! - */ -GLboolean -_mesa_add_stencil_renderbuffer(struct gl_context *ctx, struct gl_framebuffer *fb, - GLuint stencilBits) -{ - struct gl_renderbuffer *rb; - - if (stencilBits > 16) { - _mesa_problem(ctx, - "Unsupported stencilBits in _mesa_add_stencil_renderbuffer"); - return GL_FALSE; - } - - assert(fb->Attachment[BUFFER_STENCIL].Renderbuffer == NULL); - - rb = _mesa_new_renderbuffer(ctx, 0); - if (!rb) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating stencil buffer"); - return GL_FALSE; - } - - assert(stencilBits <= 8); - rb->Format = MESA_FORMAT_S8; - rb->InternalFormat = GL_STENCIL_INDEX8; - - rb->AllocStorage = _mesa_soft_renderbuffer_storage; - _mesa_add_renderbuffer(fb, BUFFER_STENCIL, rb); - - return GL_TRUE; -} - - -/** - * Add a software-based accumulation renderbuffer to the given framebuffer. - * This is a helper routine for device drivers when creating a - * window system framebuffer (not a user-created render/framebuffer). - * Once this function is called, you can basically forget about this - * renderbuffer; core Mesa will handle all the buffer management and - * rendering! - */ -GLboolean -_mesa_add_accum_renderbuffer(struct gl_context *ctx, struct gl_framebuffer *fb, - GLuint redBits, GLuint greenBits, - GLuint blueBits, GLuint alphaBits) -{ - struct gl_renderbuffer *rb; - - if (redBits > 16 || greenBits > 16 || blueBits > 16 || alphaBits > 16) { - _mesa_problem(ctx, - "Unsupported accumBits in _mesa_add_accum_renderbuffer"); - return GL_FALSE; - } - - assert(fb->Attachment[BUFFER_ACCUM].Renderbuffer == NULL); - - rb = _mesa_new_renderbuffer(ctx, 0); - if (!rb) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating accum buffer"); - return GL_FALSE; - } - - rb->Format = MESA_FORMAT_SIGNED_RGBA_16; - rb->InternalFormat = GL_RGBA16_SNORM; - rb->AllocStorage = _mesa_soft_renderbuffer_storage; - _mesa_add_renderbuffer(fb, BUFFER_ACCUM, rb); - - return GL_TRUE; -} - - - -/** - * Add a software-based aux renderbuffer to the given framebuffer. - * This is a helper routine for device drivers when creating a - * window system framebuffer (not a user-created render/framebuffer). - * Once this function is called, you can basically forget about this - * renderbuffer; core Mesa will handle all the buffer management and - * rendering! - * - * NOTE: color-index aux buffers not supported. - */ -GLboolean -_mesa_add_aux_renderbuffers(struct gl_context *ctx, struct gl_framebuffer *fb, - GLuint colorBits, GLuint numBuffers) -{ - GLuint i; - - if (colorBits > 16) { - _mesa_problem(ctx, - "Unsupported accumBits in _mesa_add_aux_renderbuffers"); - return GL_FALSE; - } - - assert(numBuffers <= MAX_AUX_BUFFERS); - - for (i = 0; i < numBuffers; i++) { - struct gl_renderbuffer *rb = _mesa_new_renderbuffer(ctx, 0); - - assert(fb->Attachment[BUFFER_AUX0 + i].Renderbuffer == NULL); - - if (!rb) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating aux buffer"); - return GL_FALSE; - } - - assert (colorBits <= 8); - rb->Format = MESA_FORMAT_RGBA8888; - rb->InternalFormat = GL_RGBA; - - rb->AllocStorage = _mesa_soft_renderbuffer_storage; - _mesa_add_renderbuffer(fb, BUFFER_AUX0 + i, rb); - } - return GL_TRUE; -} - - -/** - * Create/attach software-based renderbuffers to the given framebuffer. - * This is a helper routine for device drivers. Drivers can just as well - * call the individual _mesa_add_*_renderbuffer() routines directly. - */ -void -_mesa_add_soft_renderbuffers(struct gl_framebuffer *fb, - GLboolean color, - GLboolean depth, - GLboolean stencil, - GLboolean accum, - GLboolean alpha, - GLboolean aux) -{ - GLboolean frontLeft = GL_TRUE; - GLboolean backLeft = fb->Visual.doubleBufferMode; - GLboolean frontRight = fb->Visual.stereoMode; - GLboolean backRight = fb->Visual.stereoMode && fb->Visual.doubleBufferMode; - - if (color) { - assert(fb->Visual.redBits == fb->Visual.greenBits); - assert(fb->Visual.redBits == fb->Visual.blueBits); - _mesa_add_color_renderbuffers(NULL, fb, - fb->Visual.redBits, - fb->Visual.alphaBits, - frontLeft, backLeft, - frontRight, backRight); - } - - if (depth) { - assert(fb->Visual.depthBits > 0); - _mesa_add_depth_renderbuffer(NULL, fb, fb->Visual.depthBits); - } - - if (stencil) { - assert(fb->Visual.stencilBits > 0); - _mesa_add_stencil_renderbuffer(NULL, fb, fb->Visual.stencilBits); - } - - if (accum) { - assert(fb->Visual.accumRedBits > 0); - assert(fb->Visual.accumGreenBits > 0); - assert(fb->Visual.accumBlueBits > 0); - _mesa_add_accum_renderbuffer(NULL, fb, - fb->Visual.accumRedBits, - fb->Visual.accumGreenBits, - fb->Visual.accumBlueBits, - fb->Visual.accumAlphaBits); - } - - if (aux) { - assert(fb->Visual.numAuxBuffers > 0); - _mesa_add_aux_renderbuffers(NULL, fb, fb->Visual.redBits, - fb->Visual.numAuxBuffers); - } - - if (alpha) { - assert(fb->Visual.alphaBits > 0); - _mesa_add_alpha_renderbuffers(NULL, fb, fb->Visual.alphaBits, - frontLeft, backLeft, - frontRight, backRight); - } - -#if 0 - if (multisample) { - /* maybe someday */ - } -#endif -} - - -/** - * Attach a renderbuffer to a framebuffer. - * \param bufferName one of the BUFFER_x tokens - */ -void -_mesa_add_renderbuffer(struct gl_framebuffer *fb, - gl_buffer_index bufferName, struct gl_renderbuffer *rb) -{ - assert(fb); - assert(rb); - assert(bufferName < BUFFER_COUNT); - - /* There should be no previous renderbuffer on this attachment point, - * with the exception of depth/stencil since the same renderbuffer may - * be used for both. - */ - assert(bufferName == BUFFER_DEPTH || - bufferName == BUFFER_STENCIL || - fb->Attachment[bufferName].Renderbuffer == NULL); - - /* winsys vs. user-created buffer cross check */ - if (fb->Name) { - assert(rb->Name); - } - else { - assert(!rb->Name); - } - - fb->Attachment[bufferName].Type = GL_RENDERBUFFER_EXT; - fb->Attachment[bufferName].Complete = GL_TRUE; - _mesa_reference_renderbuffer(&fb->Attachment[bufferName].Renderbuffer, rb); -} - - -/** - * Remove the named renderbuffer from the given framebuffer. - * \param bufferName one of the BUFFER_x tokens - */ -void -_mesa_remove_renderbuffer(struct gl_framebuffer *fb, - gl_buffer_index bufferName) -{ - struct gl_renderbuffer *rb; - - assert(bufferName < BUFFER_COUNT); - - rb = fb->Attachment[bufferName].Renderbuffer; - if (!rb) - return; - - _mesa_reference_renderbuffer(&rb, NULL); - - fb->Attachment[bufferName].Renderbuffer = NULL; -} - - -/** - * Set *ptr to point to rb. If *ptr points to another renderbuffer, - * dereference that buffer first. The new renderbuffer's refcount will - * be incremented. The old renderbuffer's refcount will be decremented. - * This is normally only called from the _mesa_reference_renderbuffer() macro - * when there's a real pointer change. - */ -void -_mesa_reference_renderbuffer_(struct gl_renderbuffer **ptr, - struct gl_renderbuffer *rb) -{ - if (*ptr) { - /* Unreference the old renderbuffer */ - GLboolean deleteFlag = GL_FALSE; - struct gl_renderbuffer *oldRb = *ptr; - - _glthread_LOCK_MUTEX(oldRb->Mutex); - ASSERT(oldRb->RefCount > 0); - oldRb->RefCount--; - /*printf("RB DECR %p (%d) to %d\n", (void*) oldRb, oldRb->Name, oldRb->RefCount);*/ - deleteFlag = (oldRb->RefCount == 0); - _glthread_UNLOCK_MUTEX(oldRb->Mutex); - - if (deleteFlag) { - oldRb->Delete(oldRb); - } - - *ptr = NULL; - } - assert(!*ptr); - - if (rb) { - /* reference new renderbuffer */ - _glthread_LOCK_MUTEX(rb->Mutex); - rb->RefCount++; - /*printf("RB INCR %p (%d) to %d\n", (void*) rb, rb->Name, rb->RefCount);*/ - _glthread_UNLOCK_MUTEX(rb->Mutex); - *ptr = rb; - } -} +/* + * Mesa 3-D graphics library + * Version: 6.5 + * + * 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. + */ + + +/** + * Functions for allocating/managing renderbuffers. + * Also, routines for reading/writing software-based renderbuffer data as + * ubytes, ushorts, uints, etc. + * + * The 'alpha8' renderbuffer is interesting. It's used to add a software-based + * alpha channel to RGB renderbuffers. This is done by wrapping the RGB + * renderbuffer with the alpha renderbuffer. We can do this because of the + * OO-nature of renderbuffers. + * + * Down the road we'll use this for run-time support of 8, 16 and 32-bit + * color channels. For example, Mesa may use 32-bit/float color channels + * internally (swrast) and use wrapper renderbuffers to convert 32-bit + * values down to 16 or 8-bit values for whatever kind of framebuffer we have. + */ + + +#include "glheader.h" +#include "imports.h" +#include "context.h" +#include "fbobject.h" +#include "formats.h" +#include "mtypes.h" +#include "renderbuffer.h" + + +/* + * Routines for get/put values in common buffer formats follow. + */ + +/* Returns a bytes per pixel of the DataType in the get/put span + * functions for at least a subset of the available combinations a + * renderbuffer can have. + * + * It would be nice to see gl_renderbuffer start talking about a + * gl_format instead of a GLenum DataType. + */ +static int +get_datatype_bytes(struct gl_renderbuffer *rb) +{ + int component_size; + + switch (rb->DataType) { + case GL_FLOAT_32_UNSIGNED_INT_24_8_REV: + component_size = 8; + break; + case GL_FLOAT: + case GL_UNSIGNED_INT: + case GL_UNSIGNED_INT_24_8_EXT: + component_size = 4; + break; + case GL_UNSIGNED_SHORT: + component_size = 2; + break; + case GL_UNSIGNED_BYTE: + component_size = 1; + break; + default: + component_size = 1; + assert(0); + } + + switch (rb->_BaseFormat) { + case GL_DEPTH_COMPONENT: + case GL_DEPTH_STENCIL: + return component_size; + default: + return 4 * component_size; + } +} + +/* This is commonly used by most of the accessors. */ +static void * +get_pointer_generic(struct gl_context *ctx, struct gl_renderbuffer *rb, + GLint x, GLint y) +{ + if (!rb->Data) + return NULL; + + return ((char *) rb->Data + + (y * rb->RowStride + x) * _mesa_get_format_bytes(rb->Format)); +} + +/* GetRow() implementation for formats where DataType matches the rb->Format. + */ +static void +get_row_generic(struct gl_context *ctx, struct gl_renderbuffer *rb, + GLuint count, GLint x, GLint y, void *values) +{ + void *src = rb->GetPointer(ctx, rb, x, y); + memcpy(values, src, count * _mesa_get_format_bytes(rb->Format)); +} + +/* Only used for float textures currently, but might also be used for + * RGBA8888, RGBA16, etc. + */ +static void +get_values_generic(struct gl_context *ctx, struct gl_renderbuffer *rb, + GLuint count, const GLint x[], const GLint y[], void *values) +{ + int format_bytes = _mesa_get_format_bytes(rb->Format) / sizeof(GLfloat); + GLuint i; + + for (i = 0; i < count; i++) { + const void *src = rb->GetPointer(ctx, rb, x[i], y[i]); + char *dst = (char *) values + i * format_bytes; + memcpy(dst, src, format_bytes); + } +} + +/* For the GL_RED/GL_RG/GL_RGB format/DataType combinations (and + * GL_LUMINANCE/GL_INTENSITY?), the Put functions are a matter of + * storing those initial components of the value per pixel into the + * destination. + */ +static void +put_row_generic(struct gl_context *ctx, struct gl_renderbuffer *rb, + GLuint count, GLint x, GLint y, + const void *values, const GLubyte *mask) +{ + void *row = rb->GetPointer(ctx, rb, x, y); + int format_bytes = _mesa_get_format_bytes(rb->Format) / sizeof(GLfloat); + int datatype_bytes = get_datatype_bytes(rb); + unsigned int i; + + if (mask) { + for (i = 0; i < count; i++) { + char *dst = (char *) row + i * format_bytes; + const char *src = (const char *) values + i * datatype_bytes; + + if (mask[i]) { + memcpy(dst, src, format_bytes); + } + } + } + else { + for (i = 0; i < count; i++) { + char *dst = (char *) row + i * format_bytes; + const char *src = (const char *) values + i * datatype_bytes; + memcpy(dst, src, format_bytes); + } + } +} + +static void +put_mono_row_generic(struct gl_context *ctx, struct gl_renderbuffer *rb, + GLuint count, GLint x, GLint y, + const void *value, const GLubyte *mask) +{ + void *row = rb->GetPointer(ctx, rb, x, y); + int format_bytes = _mesa_get_format_bytes(rb->Format) / sizeof(GLfloat); + unsigned int i; + + if (mask) { + for (i = 0; i < count; i++) { + char *dst = (char *) row + i * format_bytes; + if (mask[i]) { + memcpy(dst, value, format_bytes); + } + } + } + else { + for (i = 0; i < count; i++) { + char *dst = (char *) row + i * format_bytes; + memcpy(dst, value, format_bytes); + } + } +} + + +static void +put_values_generic(struct gl_context *ctx, struct gl_renderbuffer *rb, + GLuint count, const GLint x[], const GLint y[], + const void *values, const GLubyte *mask) +{ + int format_bytes = _mesa_get_format_bytes(rb->Format) / sizeof(GLfloat); + int datatype_bytes = get_datatype_bytes(rb); + unsigned int i; + + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + void *dst = rb->GetPointer(ctx, rb, x[i], y[i]); + const char *src = (const char *) values + i * datatype_bytes; + memcpy(dst, src, format_bytes); + } + } +} + + +static void +put_mono_values_generic(struct gl_context *ctx, + struct gl_renderbuffer *rb, + GLuint count, const GLint x[], const GLint y[], + const void *value, const GLubyte *mask) +{ + int format_bytes = _mesa_get_format_bytes(rb->Format) / sizeof(GLfloat); + unsigned int i; + + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + void *dst = rb->GetPointer(ctx, rb, x[i], y[i]); + memcpy(dst, value, format_bytes); + } + } +} + +/********************************************************************** + * Functions for buffers of 1 X GLubyte values. + * Typically stencil. + */ + +static void +get_values_ubyte(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + const GLint x[], const GLint y[], void *values) +{ + GLubyte *dst = (GLubyte *) values; + GLuint i; + ASSERT(rb->DataType == GL_UNSIGNED_BYTE); + for (i = 0; i < count; i++) { + const GLubyte *src = (GLubyte *) rb->Data + y[i] * rb->RowStride + x[i]; + dst[i] = *src; + } +} + + +static void +put_row_ubyte(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + GLint x, GLint y, const void *values, const GLubyte *mask) +{ + const GLubyte *src = (const GLubyte *) values; + GLubyte *dst = (GLubyte *) rb->Data + y * rb->RowStride + x; + ASSERT(rb->DataType == GL_UNSIGNED_BYTE); + if (mask) { + GLuint i; + for (i = 0; i < count; i++) { + if (mask[i]) { + dst[i] = src[i]; + } + } + } + else { + memcpy(dst, values, count * sizeof(GLubyte)); + } +} + + +static void +put_mono_row_ubyte(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + GLint x, GLint y, const void *value, const GLubyte *mask) +{ + const GLubyte val = *((const GLubyte *) value); + GLubyte *dst = (GLubyte *) rb->Data + y * rb->RowStride + x; + ASSERT(rb->DataType == GL_UNSIGNED_BYTE); + if (mask) { + GLuint i; + for (i = 0; i < count; i++) { + if (mask[i]) { + dst[i] = val; + } + } + } + else { + GLuint i; + for (i = 0; i < count; i++) { + dst[i] = val; + } + } +} + + +static void +put_values_ubyte(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + const GLint x[], const GLint y[], + const void *values, const GLubyte *mask) +{ + const GLubyte *src = (const GLubyte *) values; + GLuint i; + ASSERT(rb->DataType == GL_UNSIGNED_BYTE); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + GLubyte *dst = (GLubyte *) rb->Data + y[i] * rb->RowStride + x[i]; + *dst = src[i]; + } + } +} + + +static void +put_mono_values_ubyte(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + const GLint x[], const GLint y[], + const void *value, const GLubyte *mask) +{ + const GLubyte val = *((const GLubyte *) value); + GLuint i; + ASSERT(rb->DataType == GL_UNSIGNED_BYTE); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + GLubyte *dst = (GLubyte *) rb->Data + y[i] * rb->RowStride + x[i]; + *dst = val; + } + } +} + + +/********************************************************************** + * Functions for buffers of 1 X GLushort values. + * Typically depth/Z. + */ + +static void +get_values_ushort(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + const GLint x[], const GLint y[], void *values) +{ + GLushort *dst = (GLushort *) values; + GLuint i; + ASSERT(rb->DataType == GL_UNSIGNED_SHORT); + for (i = 0; i < count; i++) { + const GLushort *src = (GLushort *) rb->Data + y[i] * rb->RowStride + x[i]; + dst[i] = *src; + } +} + + +static void +put_row_ushort(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + GLint x, GLint y, const void *values, const GLubyte *mask) +{ + const GLushort *src = (const GLushort *) values; + GLushort *dst = (GLushort *) rb->Data + y * rb->RowStride + x; + ASSERT(rb->DataType == GL_UNSIGNED_SHORT); + if (mask) { + GLuint i; + for (i = 0; i < count; i++) { + if (mask[i]) { + dst[i] = src[i]; + } + } + } + else { + memcpy(dst, src, count * sizeof(GLushort)); + } +} + + +static void +put_mono_row_ushort(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + GLint x, GLint y, const void *value, const GLubyte *mask) +{ + const GLushort val = *((const GLushort *) value); + GLushort *dst = (GLushort *) rb->Data + y * rb->RowStride + x; + ASSERT(rb->DataType == GL_UNSIGNED_SHORT); + if (mask) { + GLuint i; + for (i = 0; i < count; i++) { + if (mask[i]) { + dst[i] = val; + } + } + } + else { + GLuint i; + for (i = 0; i < count; i++) { + dst[i] = val; + } + } +} + + +static void +put_values_ushort(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + const GLint x[], const GLint y[], const void *values, + const GLubyte *mask) +{ + const GLushort *src = (const GLushort *) values; + GLuint i; + ASSERT(rb->DataType == GL_UNSIGNED_SHORT); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + GLushort *dst = (GLushort *) rb->Data + y[i] * rb->RowStride + x[i]; + *dst = src[i]; + } + } +} + + +static void +put_mono_values_ushort(struct gl_context *ctx, struct gl_renderbuffer *rb, + GLuint count, const GLint x[], const GLint y[], + const void *value, const GLubyte *mask) +{ + const GLushort val = *((const GLushort *) value); + ASSERT(rb->DataType == GL_UNSIGNED_SHORT); + if (mask) { + GLuint i; + for (i = 0; i < count; i++) { + if (mask[i]) { + GLushort *dst = (GLushort *) rb->Data + y[i] * rb->RowStride + x[i]; + *dst = val; + } + } + } + else { + GLuint i; + for (i = 0; i < count; i++) { + GLushort *dst = (GLushort *) rb->Data + y[i] * rb->RowStride + x[i]; + *dst = val; + } + } +} + + +/********************************************************************** + * Functions for buffers of 1 X GLuint values. + * Typically depth/Z or color index. + */ + +static void +get_values_uint(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + const GLint x[], const GLint y[], void *values) +{ + GLuint *dst = (GLuint *) values; + GLuint i; + ASSERT(rb->DataType == GL_UNSIGNED_INT || + rb->DataType == GL_UNSIGNED_INT_24_8_EXT); + for (i = 0; i < count; i++) { + const GLuint *src = (GLuint *) rb->Data + y[i] * rb->RowStride + x[i]; + dst[i] = *src; + } +} + + +static void +put_row_uint(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + GLint x, GLint y, const void *values, const GLubyte *mask) +{ + const GLuint *src = (const GLuint *) values; + GLuint *dst = (GLuint *) rb->Data + y * rb->RowStride + x; + ASSERT(rb->DataType == GL_UNSIGNED_INT || + rb->DataType == GL_UNSIGNED_INT_24_8_EXT); + if (mask) { + GLuint i; + for (i = 0; i < count; i++) { + if (mask[i]) { + dst[i] = src[i]; + } + } + } + else { + memcpy(dst, src, count * sizeof(GLuint)); + } +} + + +static void +put_mono_row_uint(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + GLint x, GLint y, const void *value, const GLubyte *mask) +{ + const GLuint val = *((const GLuint *) value); + GLuint *dst = (GLuint *) rb->Data + y * rb->RowStride + x; + ASSERT(rb->DataType == GL_UNSIGNED_INT || + rb->DataType == GL_UNSIGNED_INT_24_8_EXT); + if (mask) { + GLuint i; + for (i = 0; i < count; i++) { + if (mask[i]) { + dst[i] = val; + } + } + } + else { + GLuint i; + for (i = 0; i < count; i++) { + dst[i] = val; + } + } +} + + +static void +put_values_uint(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + const GLint x[], const GLint y[], const void *values, + const GLubyte *mask) +{ + const GLuint *src = (const GLuint *) values; + GLuint i; + ASSERT(rb->DataType == GL_UNSIGNED_INT || + rb->DataType == GL_UNSIGNED_INT_24_8_EXT); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + GLuint *dst = (GLuint *) rb->Data + y[i] * rb->RowStride + x[i]; + *dst = src[i]; + } + } +} + + +static void +put_mono_values_uint(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + const GLint x[], const GLint y[], const void *value, + const GLubyte *mask) +{ + const GLuint val = *((const GLuint *) value); + GLuint i; + ASSERT(rb->DataType == GL_UNSIGNED_INT || + rb->DataType == GL_UNSIGNED_INT_24_8_EXT); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + GLuint *dst = (GLuint *) rb->Data + y[i] * rb->RowStride + x[i]; + *dst = val; + } + } +} + + +/********************************************************************** + * Functions for buffers of 3 X GLubyte (or GLbyte) values. + * Typically color buffers. + * NOTE: the incoming and outgoing colors are RGBA! We ignore incoming + * alpha values and return 255 for outgoing alpha values. + */ + +static void * +get_pointer_ubyte3(struct gl_context *ctx, struct gl_renderbuffer *rb, + GLint x, GLint y) +{ + ASSERT(rb->Format == MESA_FORMAT_RGB888); + /* No direct access since this buffer is RGB but caller will be + * treating it as if it were RGBA. + */ + return NULL; +} + + +static void +get_row_ubyte3(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + GLint x, GLint y, void *values) +{ + const GLubyte *src = ((const GLubyte *) rb->Data) + + 3 * (y * rb->RowStride + x); + GLubyte *dst = (GLubyte *) values; + GLuint i; + ASSERT(rb->Format == MESA_FORMAT_RGB888); + ASSERT(rb->DataType == GL_UNSIGNED_BYTE); + for (i = 0; i < count; i++) { + dst[i * 4 + 0] = src[i * 3 + 0]; + dst[i * 4 + 1] = src[i * 3 + 1]; + dst[i * 4 + 2] = src[i * 3 + 2]; + dst[i * 4 + 3] = 255; + } +} + + +static void +get_values_ubyte3(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + const GLint x[], const GLint y[], void *values) +{ + GLubyte *dst = (GLubyte *) values; + GLuint i; + ASSERT(rb->Format == MESA_FORMAT_RGB888); + ASSERT(rb->DataType == GL_UNSIGNED_BYTE); + for (i = 0; i < count; i++) { + const GLubyte *src + = (GLubyte *) rb->Data + 3 * (y[i] * rb->RowStride + x[i]); + dst[i * 4 + 0] = src[0]; + dst[i * 4 + 1] = src[1]; + dst[i * 4 + 2] = src[2]; + dst[i * 4 + 3] = 255; + } +} + + +static void +put_row_ubyte3(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + GLint x, GLint y, const void *values, const GLubyte *mask) +{ + /* note: incoming values are RGB+A! */ + const GLubyte *src = (const GLubyte *) values; + GLubyte *dst = (GLubyte *) rb->Data + 3 * (y * rb->RowStride + x); + GLuint i; + ASSERT(rb->Format == MESA_FORMAT_RGB888); + ASSERT(rb->DataType == GL_UNSIGNED_BYTE); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + dst[i * 3 + 0] = src[i * 4 + 0]; + dst[i * 3 + 1] = src[i * 4 + 1]; + dst[i * 3 + 2] = src[i * 4 + 2]; + } + } +} + + +static void +put_row_rgb_ubyte3(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + GLint x, GLint y, const void *values, const GLubyte *mask) +{ + /* note: incoming values are RGB+A! */ + const GLubyte *src = (const GLubyte *) values; + GLubyte *dst = (GLubyte *) rb->Data + 3 * (y * rb->RowStride + x); + GLuint i; + ASSERT(rb->Format == MESA_FORMAT_RGB888); + ASSERT(rb->DataType == GL_UNSIGNED_BYTE); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + dst[i * 3 + 0] = src[i * 3 + 0]; + dst[i * 3 + 1] = src[i * 3 + 1]; + dst[i * 3 + 2] = src[i * 3 + 2]; + } + } +} + + +static void +put_mono_row_ubyte3(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + GLint x, GLint y, const void *value, const GLubyte *mask) +{ + /* note: incoming value is RGB+A! */ + const GLubyte val0 = ((const GLubyte *) value)[0]; + const GLubyte val1 = ((const GLubyte *) value)[1]; + const GLubyte val2 = ((const GLubyte *) value)[2]; + GLubyte *dst = (GLubyte *) rb->Data + 3 * (y * rb->RowStride + x); + ASSERT(rb->Format == MESA_FORMAT_RGB888); + ASSERT(rb->DataType == GL_UNSIGNED_BYTE); + if (!mask && val0 == val1 && val1 == val2) { + /* optimized case */ + memset(dst, val0, 3 * count); + } + else { + GLuint i; + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + dst[i * 3 + 0] = val0; + dst[i * 3 + 1] = val1; + dst[i * 3 + 2] = val2; + } + } + } +} + + +static void +put_values_ubyte3(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + const GLint x[], const GLint y[], const void *values, + const GLubyte *mask) +{ + /* note: incoming values are RGB+A! */ + const GLubyte *src = (const GLubyte *) values; + GLuint i; + ASSERT(rb->Format == MESA_FORMAT_RGB888); + ASSERT(rb->DataType == GL_UNSIGNED_BYTE); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + GLubyte *dst = (GLubyte *) rb->Data + 3 * (y[i] * rb->RowStride + x[i]); + dst[0] = src[i * 4 + 0]; + dst[1] = src[i * 4 + 1]; + dst[2] = src[i * 4 + 2]; + } + } +} + + +static void +put_mono_values_ubyte3(struct gl_context *ctx, struct gl_renderbuffer *rb, + GLuint count, const GLint x[], const GLint y[], + const void *value, const GLubyte *mask) +{ + /* note: incoming value is RGB+A! */ + const GLubyte val0 = ((const GLubyte *) value)[0]; + const GLubyte val1 = ((const GLubyte *) value)[1]; + const GLubyte val2 = ((const GLubyte *) value)[2]; + GLuint i; + ASSERT(rb->Format == MESA_FORMAT_RGB888); + ASSERT(rb->DataType == GL_UNSIGNED_BYTE); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + GLubyte *dst = ((GLubyte *) rb->Data) + + 3 * (y[i] * rb->RowStride + x[i]); + dst[0] = val0; + dst[1] = val1; + dst[2] = val2; + } + } +} + + +/********************************************************************** + * Functions for buffers of 4 X GLubyte (or GLbyte) values. + * Typically color buffers. + */ + +static void +get_values_ubyte4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + const GLint x[], const GLint y[], void *values) +{ + /* treat 4*GLubyte as 1*GLuint */ + GLuint *dst = (GLuint *) values; + GLuint i; + ASSERT(rb->DataType == GL_UNSIGNED_BYTE); + ASSERT(rb->Format == MESA_FORMAT_RGBA8888); + for (i = 0; i < count; i++) { + const GLuint *src = (GLuint *) rb->Data + (y[i] * rb->RowStride + x[i]); + dst[i] = *src; + } +} + + +static void +put_row_ubyte4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + GLint x, GLint y, const void *values, const GLubyte *mask) +{ + /* treat 4*GLubyte as 1*GLuint */ + const GLuint *src = (const GLuint *) values; + GLuint *dst = (GLuint *) rb->Data + (y * rb->RowStride + x); + ASSERT(rb->DataType == GL_UNSIGNED_BYTE); + ASSERT(rb->Format == MESA_FORMAT_RGBA8888); + if (mask) { + GLuint i; + for (i = 0; i < count; i++) { + if (mask[i]) { + dst[i] = src[i]; + } + } + } + else { + memcpy(dst, src, 4 * count * sizeof(GLubyte)); + } +} + + +static void +put_row_rgb_ubyte4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + GLint x, GLint y, const void *values, const GLubyte *mask) +{ + /* Store RGB values in RGBA buffer */ + const GLubyte *src = (const GLubyte *) values; + GLubyte *dst = (GLubyte *) rb->Data + 4 * (y * rb->RowStride + x); + GLuint i; + ASSERT(rb->DataType == GL_UNSIGNED_BYTE); + ASSERT(rb->Format == MESA_FORMAT_RGBA8888); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + dst[i * 4 + 0] = src[i * 3 + 0]; + dst[i * 4 + 1] = src[i * 3 + 1]; + dst[i * 4 + 2] = src[i * 3 + 2]; + dst[i * 4 + 3] = 0xff; + } + } +} + + +static void +put_mono_row_ubyte4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + GLint x, GLint y, const void *value, const GLubyte *mask) +{ + /* treat 4*GLubyte as 1*GLuint */ + const GLuint val = *((const GLuint *) value); + GLuint *dst = (GLuint *) rb->Data + (y * rb->RowStride + x); + ASSERT(rb->DataType == GL_UNSIGNED_BYTE); + ASSERT(rb->Format == MESA_FORMAT_RGBA8888); + if (!mask && val == 0) { + /* common case */ + memset(dst, 0, count * 4 * sizeof(GLubyte)); + } + else { + /* general case */ + if (mask) { + GLuint i; + for (i = 0; i < count; i++) { + if (mask[i]) { + dst[i] = val; + } + } + } + else { + GLuint i; + for (i = 0; i < count; i++) { + dst[i] = val; + } + } + } +} + + +static void +put_values_ubyte4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + const GLint x[], const GLint y[], const void *values, + const GLubyte *mask) +{ + /* treat 4*GLubyte as 1*GLuint */ + const GLuint *src = (const GLuint *) values; + GLuint i; + ASSERT(rb->DataType == GL_UNSIGNED_BYTE); + ASSERT(rb->Format == MESA_FORMAT_RGBA8888); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + GLuint *dst = (GLuint *) rb->Data + (y[i] * rb->RowStride + x[i]); + *dst = src[i]; + } + } +} + + +static void +put_mono_values_ubyte4(struct gl_context *ctx, struct gl_renderbuffer *rb, + GLuint count, const GLint x[], const GLint y[], + const void *value, const GLubyte *mask) +{ + /* treat 4*GLubyte as 1*GLuint */ + const GLuint val = *((const GLuint *) value); + GLuint i; + ASSERT(rb->DataType == GL_UNSIGNED_BYTE); + ASSERT(rb->Format == MESA_FORMAT_RGBA8888); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + GLuint *dst = (GLuint *) rb->Data + (y[i] * rb->RowStride + x[i]); + *dst = val; + } + } +} + + +/********************************************************************** + * Functions for buffers of 4 X GLushort (or GLshort) values. + * Typically accum buffer. + */ + +static void +get_values_ushort4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + const GLint x[], const GLint y[], void *values) +{ + GLushort *dst = (GLushort *) values; + GLuint i; + ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT); + for (i = 0; i < count; i++) { + const GLushort *src + = (GLushort *) rb->Data + 4 * (y[i] * rb->RowStride + x[i]); + dst[i] = *src; + } +} + + +static void +put_row_ushort4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + GLint x, GLint y, const void *values, const GLubyte *mask) +{ + const GLushort *src = (const GLushort *) values; + GLushort *dst = (GLushort *) rb->Data + 4 * (y * rb->RowStride + x); + ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT); + if (mask) { + GLuint i; + for (i = 0; i < count; i++) { + if (mask[i]) { + dst[i * 4 + 0] = src[i * 4 + 0]; + dst[i * 4 + 1] = src[i * 4 + 1]; + dst[i * 4 + 2] = src[i * 4 + 2]; + dst[i * 4 + 3] = src[i * 4 + 3]; + } + } + } + else { + memcpy(dst, src, 4 * count * sizeof(GLushort)); + } +} + + +static void +put_row_rgb_ushort4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + GLint x, GLint y, const void *values, const GLubyte *mask) +{ + /* Put RGB values in RGBA buffer */ + const GLushort *src = (const GLushort *) values; + GLushort *dst = (GLushort *) rb->Data + 4 * (y * rb->RowStride + x); + ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT); + if (mask) { + GLuint i; + for (i = 0; i < count; i++) { + if (mask[i]) { + dst[i * 4 + 0] = src[i * 3 + 0]; + dst[i * 4 + 1] = src[i * 3 + 1]; + dst[i * 4 + 2] = src[i * 3 + 2]; + dst[i * 4 + 3] = 0xffff; + } + } + } + else { + memcpy(dst, src, 4 * count * sizeof(GLushort)); + } +} + + +static void +put_mono_row_ushort4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + GLint x, GLint y, const void *value, const GLubyte *mask) +{ + const GLushort val0 = ((const GLushort *) value)[0]; + const GLushort val1 = ((const GLushort *) value)[1]; + const GLushort val2 = ((const GLushort *) value)[2]; + const GLushort val3 = ((const GLushort *) value)[3]; + GLushort *dst = (GLushort *) rb->Data + 4 * (y * rb->RowStride + x); + ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT); + if (!mask && val0 == 0 && val1 == 0 && val2 == 0 && val3 == 0) { + /* common case for clearing accum buffer */ + memset(dst, 0, count * 4 * sizeof(GLushort)); + } + else { + GLuint i; + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + dst[i * 4 + 0] = val0; + dst[i * 4 + 1] = val1; + dst[i * 4 + 2] = val2; + dst[i * 4 + 3] = val3; + } + } + } +} + + +static void +put_values_ushort4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + const GLint x[], const GLint y[], const void *values, + const GLubyte *mask) +{ + const GLushort *src = (const GLushort *) values; + GLuint i; + ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + GLushort *dst = + ((GLushort *) rb->Data) + 4 * (y[i] * rb->RowStride + x[i]); + dst[0] = src[i * 4 + 0]; + dst[1] = src[i * 4 + 1]; + dst[2] = src[i * 4 + 2]; + dst[3] = src[i * 4 + 3]; + } + } +} + + +static void +put_mono_values_ushort4(struct gl_context *ctx, struct gl_renderbuffer *rb, + GLuint count, const GLint x[], const GLint y[], + const void *value, const GLubyte *mask) +{ + const GLushort val0 = ((const GLushort *) value)[0]; + const GLushort val1 = ((const GLushort *) value)[1]; + const GLushort val2 = ((const GLushort *) value)[2]; + const GLushort val3 = ((const GLushort *) value)[3]; + GLuint i; + ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT); + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + GLushort *dst = ((GLushort *) rb->Data) + + 4 * (y[i] * rb->RowStride + x[i]); + dst[0] = val0; + dst[1] = val1; + dst[2] = val2; + dst[3] = val3; + } + } +} + +/********************************************************************** + * Functions for MESA_FORMAT_R8. + */ +static void +get_row_r8(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + GLint x, GLint y, void *values) +{ + const GLubyte *src = rb->GetPointer(ctx, rb, x, y); + GLuint *dst = values; + GLuint i; + + for (i = 0; i < count; i++) { + dst[i] = 0xff000000 | src[i]; + } +} + +static void +get_values_r8(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + const GLint x[], const GLint y[], void *values) +{ + GLuint *dst = (GLuint *) values; + GLuint i; + + for (i = 0; i < count; i++) { + const GLubyte *src = rb->GetPointer(ctx, rb, x[i], y[i]); + dst[i] = 0xff000000 | *src; + } +} + +/********************************************************************** + * Functions for MESA_FORMAT_RG88. + */ +static void +get_row_rg88(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + GLint x, GLint y, void *values) +{ + const GLushort *src = rb->GetPointer(ctx, rb, x, y); + GLuint *dst = values; + GLuint i; + + for (i = 0; i < count; i++) { + dst[i] = 0xff000000 | src[i]; + } +} + +static void +get_values_rg88(struct gl_context *ctx, struct gl_renderbuffer *rb, + GLuint count, const GLint x[], const GLint y[], void *values) +{ + GLuint *dst = (GLuint *) values; + GLuint i; + + for (i = 0; i < count; i++) { + const GLshort *src = rb->GetPointer(ctx, rb, x[i], y[i]); + dst[i] = 0xff000000 | *src; + } +} + +/********************************************************************** + * Functions for MESA_FORMAT_R16. + */ +static void +get_row_r16(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + GLint x, GLint y, void *values) +{ + const GLushort *src = rb->GetPointer(ctx, rb, x, y); + GLushort *dst = values; + GLuint i; + + for (i = 0; i < count; i++) { + dst[i * 4 + RCOMP] = src[i]; + dst[i * 4 + GCOMP] = 0; + dst[i * 4 + BCOMP] = 0; + dst[i * 4 + ACOMP] = 0xffff; + } +} + +static void +get_values_r16(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + const GLint x[], const GLint y[], void *values) +{ + GLushort *dst = values; + GLuint i; + + for (i = 0; i < count; i++) { + const GLushort *src = rb->GetPointer(ctx, rb, x[i], y[i]); + dst[i * 4 + RCOMP] = *src; + dst[i * 4 + GCOMP] = 0; + dst[i * 4 + BCOMP] = 0; + dst[i * 4 + ACOMP] = 0xffff; + } +} + +/********************************************************************** + * Functions for MESA_FORMAT_RG1616. + */ +static void +get_row_rg1616(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, + GLint x, GLint y, void *values) +{ + const GLushort *src = rb->GetPointer(ctx, rb, x, y); + GLushort *dst = values; + GLuint i; + + for (i = 0; i < count; i++) { + dst[i * 4 + RCOMP] = src[i * 2]; + dst[i * 4 + GCOMP] = src[i * 2 + 1]; + dst[i * 4 + BCOMP] = 0; + dst[i * 4 + ACOMP] = 0xffff; + } +} + +static void +get_values_rg1616(struct gl_context *ctx, struct gl_renderbuffer *rb, + GLuint count, const GLint x[], const GLint y[], void *values) +{ + GLushort *dst = values; + GLuint i; + + for (i = 0; i < count; i++) { + const GLshort *src = rb->GetPointer(ctx, rb, x[i], y[i]); + dst[i * 4 + RCOMP] = src[0]; + dst[i * 4 + GCOMP] = src[1]; + dst[i * 4 + BCOMP] = 0; + dst[i * 4 + ACOMP] = 0xffff; + } +} + +/********************************************************************** + * Functions for MESA_FORMAT_INTENSITY_FLOAT32. + */ +static void +get_row_i_float32(struct gl_context *ctx, struct gl_renderbuffer *rb, + GLuint count, GLint x, GLint y, void *values) +{ + const GLfloat *src = rb->GetPointer(ctx, rb, x, y); + GLfloat *dst = values; + GLuint i; + + for (i = 0; i < count; i++) { + dst[i * 4 + RCOMP] = + dst[i * 4 + GCOMP] = + dst[i * 4 + BCOMP] = + dst[i * 4 + ACOMP] = src[i]; + } +} + +static void +get_values_i_float32(struct gl_context *ctx, struct gl_renderbuffer *rb, + GLuint count, const GLint x[], const GLint y[], + void *values) +{ + GLfloat *dst = values; + GLuint i; + + for (i = 0; i < count; i++) { + const GLfloat *src = rb->GetPointer(ctx, rb, x[i], y[i]); + dst[i * 4 + RCOMP] = + dst[i * 4 + GCOMP] = + dst[i * 4 + BCOMP] = + dst[i * 4 + ACOMP] = src[0]; + } +} + +/********************************************************************** + * Functions for MESA_FORMAT_LUMINANCE_FLOAT32. + */ +static void +get_row_l_float32(struct gl_context *ctx, struct gl_renderbuffer *rb, + GLuint count, GLint x, GLint y, void *values) +{ + const GLfloat *src = rb->GetPointer(ctx, rb, x, y); + GLfloat *dst = values; + GLuint i; + + for (i = 0; i < count; i++) { + dst[i * 4 + RCOMP] = + dst[i * 4 + GCOMP] = + dst[i * 4 + BCOMP] = src[i]; + dst[i * 4 + ACOMP] = 1.0; + } +} + +static void +get_values_l_float32(struct gl_context *ctx, struct gl_renderbuffer *rb, + GLuint count, const GLint x[], const GLint y[], + void *values) +{ + GLfloat *dst = values; + GLuint i; + + for (i = 0; i < count; i++) { + const GLfloat *src = rb->GetPointer(ctx, rb, x[i], y[i]); + dst[i * 4 + RCOMP] = + dst[i * 4 + GCOMP] = + dst[i * 4 + BCOMP] = src[0]; + dst[i * 4 + ACOMP] = 1.0; + } +} + +/********************************************************************** + * Functions for MESA_FORMAT_ALPHA_FLOAT32. + */ +static void +get_row_a_float32(struct gl_context *ctx, struct gl_renderbuffer *rb, + GLuint count, GLint x, GLint y, void *values) +{ + const GLfloat *src = rb->GetPointer(ctx, rb, x, y); + GLfloat *dst = values; + GLuint i; + + for (i = 0; i < count; i++) { + dst[i * 4 + RCOMP] = 0.0; + dst[i * 4 + GCOMP] = 0.0; + dst[i * 4 + BCOMP] = 0.0; + dst[i * 4 + ACOMP] = src[i]; + } +} + +static void +get_values_a_float32(struct gl_context *ctx, struct gl_renderbuffer *rb, + GLuint count, const GLint x[], const GLint y[], + void *values) +{ + GLfloat *dst = values; + GLuint i; + + for (i = 0; i < count; i++) { + const GLfloat *src = rb->GetPointer(ctx, rb, x[i], y[i]); + dst[i * 4 + RCOMP] = 0.0; + dst[i * 4 + GCOMP] = 0.0; + dst[i * 4 + BCOMP] = 0.0; + dst[i * 4 + ACOMP] = src[0]; + } +} + +static void +put_row_a_float32(struct gl_context *ctx, struct gl_renderbuffer *rb, + GLuint count, GLint x, GLint y, + const void *values, const GLubyte *mask) +{ + float *dst = rb->GetPointer(ctx, rb, x, y); + const float *src = values; + unsigned int i; + + if (mask) { + for (i = 0; i < count; i++) { + if (mask[i]) { + dst[i] = src[i * 4 + ACOMP]; + } + } + } + else { + for (i = 0; i < count; i++) { + dst[i] = src[i * 4 + ACOMP]; + } + } +} + +static void +put_mono_row_a_float32(struct gl_context *ctx, struct gl_renderbuffer *rb, + GLuint count, GLint x, GLint y, + const void *value, const GLubyte *mask) +{ + float *dst = rb->GetPointer(ctx, rb, x, y); + const float *src = value; + unsigned int i; + + if (mask) { + for (i = 0; i < count; i++) { + if (mask[i]) { + dst[i] = src[ACOMP]; + } + } + } + else { + for (i = 0; i < count; i++) { + dst[i] = src[ACOMP]; + } + } +} + +static void +put_values_a_float32(struct gl_context *ctx, struct gl_renderbuffer *rb, + GLuint count, const GLint x[], const GLint y[], + const void *values, const GLubyte *mask) +{ + const float *src = values; + unsigned int i; + + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + float *dst = rb->GetPointer(ctx, rb, x[i], y[i]); + + *dst = src[i * 4 + ACOMP]; + } + } +} + +static void +put_mono_values_a_float32(struct gl_context *ctx, + struct gl_renderbuffer *rb, + GLuint count, const GLint x[], const GLint y[], + const void *value, const GLubyte *mask) +{ + const float *src = value; + unsigned int i; + + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + float *dst = rb->GetPointer(ctx, rb, x[i], y[i]); + *dst = src[ACOMP]; + } + } +} + +/********************************************************************** + * Functions for MESA_FORMAT_R_FLOAT32. + */ +static void +get_row_r_float32(struct gl_context *ctx, struct gl_renderbuffer *rb, + GLuint count, GLint x, GLint y, void *values) +{ + const GLfloat *src = rb->GetPointer(ctx, rb, x, y); + GLfloat *dst = values; + GLuint i; + + for (i = 0; i < count; i++) { + dst[i * 4 + RCOMP] = src[i]; + dst[i * 4 + GCOMP] = 0.0; + dst[i * 4 + BCOMP] = 0.0; + dst[i * 4 + ACOMP] = 1.0; + } +} + +static void +get_values_r_float32(struct gl_context *ctx, struct gl_renderbuffer *rb, + GLuint count, const GLint x[], const GLint y[], + void *values) +{ + GLfloat *dst = values; + GLuint i; + + for (i = 0; i < count; i++) { + const GLfloat *src = rb->GetPointer(ctx, rb, x[i], y[i]); + dst[i * 4 + RCOMP] = src[0]; + dst[i * 4 + GCOMP] = 0.0; + dst[i * 4 + BCOMP] = 0.0; + dst[i * 4 + ACOMP] = 1.0; + } +} + +/********************************************************************** + * Functions for MESA_FORMAT_RG_FLOAT32. + */ +static void +get_row_rg_float32(struct gl_context *ctx, struct gl_renderbuffer *rb, + GLuint count, GLint x, GLint y, void *values) +{ + const GLfloat *src = rb->GetPointer(ctx, rb, x, y); + GLfloat *dst = values; + GLuint i; + + for (i = 0; i < count; i++) { + dst[i * 4 + RCOMP] = src[i * 2 + 0]; + dst[i * 4 + GCOMP] = src[i * 2 + 1]; + dst[i * 4 + BCOMP] = 0.0; + dst[i * 4 + ACOMP] = 1.0; + } +} + +static void +get_values_rg_float32(struct gl_context *ctx, struct gl_renderbuffer *rb, + GLuint count, const GLint x[], const GLint y[], + void *values) +{ + GLfloat *dst = values; + GLuint i; + + for (i = 0; i < count; i++) { + const GLfloat *src = rb->GetPointer(ctx, rb, x[i], y[i]); + dst[i * 4 + RCOMP] = src[0]; + dst[i * 4 + GCOMP] = src[1]; + dst[i * 4 + BCOMP] = 0.0; + dst[i * 4 + ACOMP] = 1.0; + } +} + +/** + * This is the default software fallback for gl_renderbuffer's span + * access functions. + * + * The assumptions are that rb->Data will be a pointer to (0,0), that pixels + * are packed in the type of rb->Format, and that subsequent rows appear + * rb->RowStride pixels later. + */ +void +_mesa_set_renderbuffer_accessors(struct gl_renderbuffer *rb) +{ + rb->GetPointer = get_pointer_generic; + rb->GetRow = get_row_generic; + + switch (rb->Format) { + case MESA_FORMAT_RGB888: + rb->DataType = GL_UNSIGNED_BYTE; + rb->GetPointer = get_pointer_ubyte3; + rb->GetRow = get_row_ubyte3; + rb->GetValues = get_values_ubyte3; + rb->PutRow = put_row_ubyte3; + rb->PutRowRGB = put_row_rgb_ubyte3; + rb->PutMonoRow = put_mono_row_ubyte3; + rb->PutValues = put_values_ubyte3; + rb->PutMonoValues = put_mono_values_ubyte3; + break; + + case MESA_FORMAT_RGBA8888: + rb->DataType = GL_UNSIGNED_BYTE; + rb->GetValues = get_values_ubyte4; + rb->PutRow = put_row_ubyte4; + rb->PutRowRGB = put_row_rgb_ubyte4; + rb->PutMonoRow = put_mono_row_ubyte4; + rb->PutValues = put_values_ubyte4; + rb->PutMonoValues = put_mono_values_ubyte4; + break; + + case MESA_FORMAT_R8: + rb->DataType = GL_UNSIGNED_BYTE; + rb->GetValues = get_values_r8; + rb->GetRow = get_row_r8; + rb->PutRow = put_row_generic; + rb->PutRowRGB = put_row_generic; + rb->PutMonoRow = put_mono_row_generic; + rb->PutValues = put_values_generic; + rb->PutMonoValues = put_mono_values_generic; + break; + + case MESA_FORMAT_RG88: + rb->DataType = GL_UNSIGNED_BYTE; + rb->GetValues = get_values_rg88; + rb->GetRow = get_row_rg88; + rb->PutRow = put_row_generic; + rb->PutRowRGB = put_row_generic; + rb->PutMonoRow = put_mono_row_generic; + rb->PutValues = put_values_generic; + rb->PutMonoValues = put_mono_values_generic; + break; + + case MESA_FORMAT_R16: + rb->DataType = GL_UNSIGNED_SHORT; + rb->GetValues = get_values_r16; + rb->GetRow = get_row_r16; + rb->PutRow = put_row_generic; + rb->PutRowRGB = put_row_generic; + rb->PutMonoRow = put_mono_row_generic; + rb->PutValues = put_values_generic; + rb->PutMonoValues = put_mono_values_generic; + break; + + case MESA_FORMAT_RG1616: + rb->DataType = GL_UNSIGNED_SHORT; + rb->GetValues = get_values_rg1616; + rb->GetRow = get_row_rg1616; + rb->PutRow = put_row_generic; + rb->PutRowRGB = put_row_generic; + rb->PutMonoRow = put_mono_row_generic; + rb->PutValues = put_values_generic; + rb->PutMonoValues = put_mono_values_generic; + break; + + case MESA_FORMAT_SIGNED_RGBA_16: + rb->DataType = GL_SHORT; + rb->GetValues = get_values_ushort4; + rb->PutRow = put_row_ushort4; + rb->PutRowRGB = put_row_rgb_ushort4; + rb->PutMonoRow = put_mono_row_ushort4; + rb->PutValues = put_values_ushort4; + rb->PutMonoValues = put_mono_values_ushort4; + break; + +#if 0 + case MESA_FORMAT_A8: + rb->DataType = GL_UNSIGNED_BYTE; + rb->GetValues = get_values_alpha8; + rb->PutRow = put_row_alpha8; + rb->PutRowRGB = NULL; + rb->PutMonoRow = put_mono_row_alpha8; + rb->PutValues = put_values_alpha8; + rb->PutMonoValues = put_mono_values_alpha8; + break; +#endif + + case MESA_FORMAT_S8: + rb->DataType = GL_UNSIGNED_BYTE; + rb->GetValues = get_values_ubyte; + rb->PutRow = put_row_ubyte; + rb->PutRowRGB = NULL; + rb->PutMonoRow = put_mono_row_ubyte; + rb->PutValues = put_values_ubyte; + rb->PutMonoValues = put_mono_values_ubyte; + break; + + case MESA_FORMAT_Z16: + rb->DataType = GL_UNSIGNED_SHORT; + rb->GetValues = get_values_ushort; + rb->PutRow = put_row_ushort; + rb->PutRowRGB = NULL; + rb->PutMonoRow = put_mono_row_ushort; + rb->PutValues = put_values_ushort; + rb->PutMonoValues = put_mono_values_ushort; + break; + + case MESA_FORMAT_Z32: + case MESA_FORMAT_X8_Z24: + case MESA_FORMAT_Z24_X8: + rb->DataType = GL_UNSIGNED_INT; + rb->GetValues = get_values_uint; + rb->PutRow = put_row_uint; + rb->PutRowRGB = NULL; + rb->PutMonoRow = put_mono_row_uint; + rb->PutValues = put_values_uint; + rb->PutMonoValues = put_mono_values_uint; + break; + + case MESA_FORMAT_Z24_S8: + case MESA_FORMAT_S8_Z24: + rb->DataType = GL_UNSIGNED_INT_24_8_EXT; + rb->GetValues = get_values_uint; + rb->PutRow = put_row_uint; + rb->PutRowRGB = NULL; + rb->PutMonoRow = put_mono_row_uint; + rb->PutValues = put_values_uint; + rb->PutMonoValues = put_mono_values_uint; + break; + + case MESA_FORMAT_RGBA_FLOAT32: + rb->GetRow = get_row_generic; + rb->GetValues = get_values_generic; + rb->PutRow = put_row_generic; + rb->PutRowRGB = NULL; + rb->PutMonoRow = put_mono_row_generic; + rb->PutValues = put_values_generic; + rb->PutMonoValues = put_mono_values_generic; + break; + + case MESA_FORMAT_INTENSITY_FLOAT32: + rb->GetRow = get_row_i_float32; + rb->GetValues = get_values_i_float32; + rb->PutRow = put_row_generic; + rb->PutRowRGB = NULL; + rb->PutMonoRow = put_mono_row_generic; + rb->PutValues = put_values_generic; + rb->PutMonoValues = put_mono_values_generic; + break; + + case MESA_FORMAT_LUMINANCE_FLOAT32: + rb->GetRow = get_row_l_float32; + rb->GetValues = get_values_l_float32; + rb->PutRow = put_row_generic; + rb->PutRowRGB = NULL; + rb->PutMonoRow = put_mono_row_generic; + rb->PutValues = put_values_generic; + rb->PutMonoValues = put_mono_values_generic; + break; + + case MESA_FORMAT_ALPHA_FLOAT32: + rb->GetRow = get_row_a_float32; + rb->GetValues = get_values_a_float32; + rb->PutRow = put_row_a_float32; + rb->PutRowRGB = NULL; + rb->PutMonoRow = put_mono_row_a_float32; + rb->PutValues = put_values_a_float32; + rb->PutMonoValues = put_mono_values_a_float32; + break; + + case MESA_FORMAT_RG_FLOAT32: + rb->GetRow = get_row_rg_float32; + rb->GetValues = get_values_rg_float32; + rb->PutRow = put_row_generic; + rb->PutRowRGB = NULL; + rb->PutMonoRow = put_mono_row_generic; + rb->PutValues = put_values_generic; + rb->PutMonoValues = put_mono_values_generic; + break; + + case MESA_FORMAT_R_FLOAT32: + rb->GetRow = get_row_r_float32; + rb->GetValues = get_values_r_float32; + rb->PutRow = put_row_generic; + rb->PutRowRGB = NULL; + rb->PutMonoRow = put_mono_row_generic; + rb->PutValues = put_values_generic; + rb->PutMonoValues = put_mono_values_generic; + break; + + default: + break; + } +} + +/** + * This is a software fallback for the gl_renderbuffer->AllocStorage + * function. + * Device drivers will typically override this function for the buffers + * which it manages (typically color buffers, Z and stencil). + * Other buffers (like software accumulation and aux buffers) which the driver + * doesn't manage can be handled with this function. + * + * This one multi-purpose function can allocate stencil, depth, accum, color + * or color-index buffers! + * + * This function also plugs in the appropriate GetPointer, Get/PutRow and + * Get/PutValues functions. + */ +GLboolean +_mesa_soft_renderbuffer_storage(struct gl_context *ctx, struct gl_renderbuffer *rb, + GLenum internalFormat, + GLuint width, GLuint height) +{ + switch (internalFormat) { + case GL_RGB: + case GL_R3_G3_B2: + case GL_RGB4: + case GL_RGB5: + case GL_RGB8: + case GL_RGB10: + case GL_RGB12: + case GL_RGB16: + rb->Format = MESA_FORMAT_RGB888; + break; + case GL_RGBA: + case GL_RGBA2: + case GL_RGBA4: + case GL_RGB5_A1: + case GL_RGBA8: +#if 1 + case GL_RGB10_A2: + case GL_RGBA12: +#endif + rb->Format = MESA_FORMAT_RGBA8888; + break; + case GL_RGBA16: + case GL_RGBA16_SNORM: + /* for accum buffer */ + rb->Format = MESA_FORMAT_SIGNED_RGBA_16; + break; +#if 0 + case GL_ALPHA8: + rb->Format = MESA_FORMAT_A8; + break; +#endif + case GL_STENCIL_INDEX: + case GL_STENCIL_INDEX1_EXT: + case GL_STENCIL_INDEX4_EXT: + case GL_STENCIL_INDEX8_EXT: + case GL_STENCIL_INDEX16_EXT: + rb->Format = MESA_FORMAT_S8; + break; + case GL_DEPTH_COMPONENT: + case GL_DEPTH_COMPONENT16: + rb->Format = MESA_FORMAT_Z16; + break; + case GL_DEPTH_COMPONENT24: + rb->Format = MESA_FORMAT_X8_Z24; + break; + case GL_DEPTH_COMPONENT32: + rb->Format = MESA_FORMAT_Z32; + break; + case GL_DEPTH_STENCIL_EXT: + case GL_DEPTH24_STENCIL8_EXT: + rb->Format = MESA_FORMAT_Z24_S8; + break; + default: + /* unsupported format */ + return GL_FALSE; + } + + _mesa_set_renderbuffer_accessors(rb); + + ASSERT(rb->DataType); + ASSERT(rb->GetPointer); + ASSERT(rb->GetRow); + ASSERT(rb->GetValues); + ASSERT(rb->PutRow); + ASSERT(rb->PutMonoRow); + ASSERT(rb->PutValues); + ASSERT(rb->PutMonoValues); + + /* free old buffer storage */ + if (rb->Data) { + free(rb->Data); + rb->Data = NULL; + } + + rb->RowStride = width; + + if (width > 0 && height > 0) { + /* allocate new buffer storage */ + rb->Data = malloc(width * height * _mesa_get_format_bytes(rb->Format)); + + if (rb->Data == NULL) { + rb->Width = 0; + rb->Height = 0; + rb->RowStride = 0; + _mesa_error(ctx, GL_OUT_OF_MEMORY, + "software renderbuffer allocation (%d x %d x %d)", + width, height, _mesa_get_format_bytes(rb->Format)); + return GL_FALSE; + } + } + + rb->Width = width; + rb->Height = height; + rb->_BaseFormat = _mesa_base_fbo_format(ctx, internalFormat); + + if (rb->Name == 0 && + internalFormat == GL_RGBA16_SNORM && + rb->_BaseFormat == 0) { + /* NOTE: This is a special case just for accumulation buffers. + * This is a very limited use case- there's no snorm texturing or + * rendering going on. + */ + rb->_BaseFormat = GL_RGBA; + } + else { + /* the internalFormat should have been error checked long ago */ + ASSERT(rb->_BaseFormat); + } + + return GL_TRUE; +} + + + +/**********************************************************************/ +/**********************************************************************/ +/**********************************************************************/ + + +/** + * Here we utilize the gl_renderbuffer->Wrapper field to put an alpha + * buffer wrapper around an existing RGB renderbuffer (hw or sw). + * + * When PutRow is called (for example), we store the alpha values in + * this buffer, then pass on the PutRow call to the wrapped RGB + * buffer. + */ + + +static GLboolean +alloc_storage_alpha8(struct gl_context *ctx, struct gl_renderbuffer *arb, + GLenum internalFormat, GLuint width, GLuint height) +{ + ASSERT(arb != arb->Wrapped); + ASSERT(arb->Format == MESA_FORMAT_A8); + + /* first, pass the call to the wrapped RGB buffer */ + if (!arb->Wrapped->AllocStorage(ctx, arb->Wrapped, internalFormat, + width, height)) { + return GL_FALSE; + } + + /* next, resize my alpha buffer */ + if (arb->Data) { + free(arb->Data); + } + + arb->Data = malloc(width * height * sizeof(GLubyte)); + if (arb->Data == NULL) { + arb->Width = 0; + arb->Height = 0; + _mesa_error(ctx, GL_OUT_OF_MEMORY, "software alpha buffer allocation"); + return GL_FALSE; + } + + arb->Width = width; + arb->Height = height; + arb->RowStride = width; + + return GL_TRUE; +} + + +/** + * Delete an alpha_renderbuffer object, as well as the wrapped RGB buffer. + */ +static void +delete_renderbuffer_alpha8(struct gl_renderbuffer *arb) +{ + if (arb->Data) { + free(arb->Data); + } + ASSERT(arb->Wrapped); + ASSERT(arb != arb->Wrapped); + arb->Wrapped->Delete(arb->Wrapped); + arb->Wrapped = NULL; + free(arb); +} + + +static void * +get_pointer_alpha8(struct gl_context *ctx, struct gl_renderbuffer *arb, + GLint x, GLint y) +{ + return NULL; /* don't allow direct access! */ +} + + +static void +get_row_alpha8(struct gl_context *ctx, struct gl_renderbuffer *arb, GLuint count, + GLint x, GLint y, void *values) +{ + /* NOTE: 'values' is RGBA format! */ + const GLubyte *src = (const GLubyte *) arb->Data + y * arb->RowStride + x; + GLubyte *dst = (GLubyte *) values; + GLuint i; + ASSERT(arb != arb->Wrapped); + ASSERT(arb->DataType == GL_UNSIGNED_BYTE); + /* first, pass the call to the wrapped RGB buffer */ + arb->Wrapped->GetRow(ctx, arb->Wrapped, count, x, y, values); + /* second, fill in alpha values from this buffer! */ + for (i = 0; i < count; i++) { + dst[i * 4 + 3] = src[i]; + } +} + + +static void +get_values_alpha8(struct gl_context *ctx, struct gl_renderbuffer *arb, GLuint count, + const GLint x[], const GLint y[], void *values) +{ + GLubyte *dst = (GLubyte *) values; + GLuint i; + ASSERT(arb != arb->Wrapped); + ASSERT(arb->DataType == GL_UNSIGNED_BYTE); + /* first, pass the call to the wrapped RGB buffer */ + arb->Wrapped->GetValues(ctx, arb->Wrapped, count, x, y, values); + /* second, fill in alpha values from this buffer! */ + for (i = 0; i < count; i++) { + const GLubyte *src = (GLubyte *) arb->Data + y[i] * arb->RowStride + x[i]; + dst[i * 4 + 3] = *src; + } +} + + +static void +put_row_alpha8(struct gl_context *ctx, struct gl_renderbuffer *arb, GLuint count, + GLint x, GLint y, const void *values, const GLubyte *mask) +{ + const GLubyte *src = (const GLubyte *) values; + GLubyte *dst = (GLubyte *) arb->Data + y * arb->RowStride + x; + GLuint i; + ASSERT(arb != arb->Wrapped); + ASSERT(arb->DataType == GL_UNSIGNED_BYTE); + /* first, pass the call to the wrapped RGB buffer */ + arb->Wrapped->PutRow(ctx, arb->Wrapped, count, x, y, values, mask); + /* second, store alpha in our buffer */ + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + dst[i] = src[i * 4 + 3]; + } + } +} + + +static void +put_row_rgb_alpha8(struct gl_context *ctx, struct gl_renderbuffer *arb, GLuint count, + GLint x, GLint y, const void *values, const GLubyte *mask) +{ + const GLubyte *src = (const GLubyte *) values; + GLubyte *dst = (GLubyte *) arb->Data + y * arb->RowStride + x; + GLuint i; + ASSERT(arb != arb->Wrapped); + ASSERT(arb->DataType == GL_UNSIGNED_BYTE); + /* first, pass the call to the wrapped RGB buffer */ + arb->Wrapped->PutRowRGB(ctx, arb->Wrapped, count, x, y, values, mask); + /* second, store alpha in our buffer */ + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + dst[i] = src[i * 4 + 3]; + } + } +} + + +static void +put_mono_row_alpha8(struct gl_context *ctx, struct gl_renderbuffer *arb, GLuint count, + GLint x, GLint y, const void *value, const GLubyte *mask) +{ + const GLubyte val = ((const GLubyte *) value)[3]; + GLubyte *dst = (GLubyte *) arb->Data + y * arb->RowStride + x; + ASSERT(arb != arb->Wrapped); + ASSERT(arb->DataType == GL_UNSIGNED_BYTE); + /* first, pass the call to the wrapped RGB buffer */ + arb->Wrapped->PutMonoRow(ctx, arb->Wrapped, count, x, y, value, mask); + /* second, store alpha in our buffer */ + if (mask) { + GLuint i; + for (i = 0; i < count; i++) { + if (mask[i]) { + dst[i] = val; + } + } + } + else { + memset(dst, val, count); + } +} + + +static void +put_values_alpha8(struct gl_context *ctx, struct gl_renderbuffer *arb, GLuint count, + const GLint x[], const GLint y[], + const void *values, const GLubyte *mask) +{ + const GLubyte *src = (const GLubyte *) values; + GLuint i; + ASSERT(arb != arb->Wrapped); + ASSERT(arb->DataType == GL_UNSIGNED_BYTE); + /* first, pass the call to the wrapped RGB buffer */ + arb->Wrapped->PutValues(ctx, arb->Wrapped, count, x, y, values, mask); + /* second, store alpha in our buffer */ + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + GLubyte *dst = (GLubyte *) arb->Data + y[i] * arb->RowStride + x[i]; + *dst = src[i * 4 + 3]; + } + } +} + + +static void +put_mono_values_alpha8(struct gl_context *ctx, struct gl_renderbuffer *arb, + GLuint count, const GLint x[], const GLint y[], + const void *value, const GLubyte *mask) +{ + const GLubyte val = ((const GLubyte *) value)[3]; + GLuint i; + ASSERT(arb != arb->Wrapped); + ASSERT(arb->DataType == GL_UNSIGNED_BYTE); + /* first, pass the call to the wrapped RGB buffer */ + arb->Wrapped->PutValues(ctx, arb->Wrapped, count, x, y, value, mask); + /* second, store alpha in our buffer */ + for (i = 0; i < count; i++) { + if (!mask || mask[i]) { + GLubyte *dst = (GLubyte *) arb->Data + y[i] * arb->RowStride + x[i]; + *dst = val; + } + } +} + + +static void +copy_buffer_alpha8(struct gl_renderbuffer* dst, struct gl_renderbuffer* src) +{ + ASSERT(dst->Format == MESA_FORMAT_A8); + ASSERT(src->Format == MESA_FORMAT_A8); + ASSERT(dst->Width == src->Width); + ASSERT(dst->Height == src->Height); + ASSERT(dst->RowStride == src->RowStride); + + memcpy(dst->Data, src->Data, dst->RowStride * dst->Height * sizeof(GLubyte)); +} + + +/**********************************************************************/ +/**********************************************************************/ +/**********************************************************************/ + + +/** + * Default GetPointer routine. Always return NULL to indicate that + * direct buffer access is not supported. + */ +static void * +nop_get_pointer(struct gl_context *ctx, struct gl_renderbuffer *rb, GLint x, GLint y) +{ + return NULL; +} + + +/** + * Initialize the fields of a gl_renderbuffer to default values. + */ +void +_mesa_init_renderbuffer(struct gl_renderbuffer *rb, GLuint name) +{ + _glthread_INIT_MUTEX(rb->Mutex); + + rb->ClassID = 0; + rb->Name = name; + rb->RefCount = 0; + rb->Delete = _mesa_delete_renderbuffer; + + /* The rest of these should be set later by the caller of this function or + * the AllocStorage method: + */ + rb->AllocStorage = NULL; + + rb->Width = 0; + rb->Height = 0; + rb->InternalFormat = GL_NONE; + rb->Format = MESA_FORMAT_NONE; + + rb->DataType = GL_NONE; + rb->Data = NULL; + + /* Point back to ourself so that we don't have to check for Wrapped==NULL + * all over the drivers. + */ + rb->Wrapped = rb; + + rb->GetPointer = nop_get_pointer; + rb->GetRow = NULL; + rb->GetValues = NULL; + rb->PutRow = NULL; + rb->PutRowRGB = NULL; + rb->PutMonoRow = NULL; + rb->PutValues = NULL; + rb->PutMonoValues = NULL; +} + + +/** + * Allocate a new gl_renderbuffer object. This can be used for user-created + * renderbuffers or window-system renderbuffers. + */ +struct gl_renderbuffer * +_mesa_new_renderbuffer(struct gl_context *ctx, GLuint name) +{ + struct gl_renderbuffer *rb = CALLOC_STRUCT(gl_renderbuffer); + if (rb) { + _mesa_init_renderbuffer(rb, name); + } + return rb; +} + + +/** + * Delete a gl_framebuffer. + * This is the default function for renderbuffer->Delete(). + */ +void +_mesa_delete_renderbuffer(struct gl_renderbuffer *rb) +{ + if (rb->Data) { + free(rb->Data); + } + free(rb); +} + + +/** + * Allocate a software-based renderbuffer. This is called via the + * ctx->Driver.NewRenderbuffer() function when the user creates a new + * renderbuffer. + * This would not be used for hardware-based renderbuffers. + */ +struct gl_renderbuffer * +_mesa_new_soft_renderbuffer(struct gl_context *ctx, GLuint name) +{ + struct gl_renderbuffer *rb = _mesa_new_renderbuffer(ctx, name); + if (rb) { + rb->AllocStorage = _mesa_soft_renderbuffer_storage; + /* Normally, one would setup the PutRow, GetRow, etc functions here. + * But we're doing that in the _mesa_soft_renderbuffer_storage() function + * instead. + */ + } + return rb; +} + + +/** + * Add software-based color renderbuffers to the given framebuffer. + * This is a helper routine for device drivers when creating a + * window system framebuffer (not a user-created render/framebuffer). + * Once this function is called, you can basically forget about this + * renderbuffer; core Mesa will handle all the buffer management and + * rendering! + */ +GLboolean +_mesa_add_color_renderbuffers(struct gl_context *ctx, struct gl_framebuffer *fb, + GLuint rgbBits, GLuint alphaBits, + GLboolean frontLeft, GLboolean backLeft, + GLboolean frontRight, GLboolean backRight) +{ + gl_buffer_index b; + + if (rgbBits > 16 || alphaBits > 16) { + _mesa_problem(ctx, + "Unsupported bit depth in _mesa_add_color_renderbuffers"); + return GL_FALSE; + } + + assert(MAX_COLOR_ATTACHMENTS >= 4); + + for (b = BUFFER_FRONT_LEFT; b <= BUFFER_BACK_RIGHT; b++) { + struct gl_renderbuffer *rb; + + if (b == BUFFER_FRONT_LEFT && !frontLeft) + continue; + else if (b == BUFFER_BACK_LEFT && !backLeft) + continue; + else if (b == BUFFER_FRONT_RIGHT && !frontRight) + continue; + else if (b == BUFFER_BACK_RIGHT && !backRight) + continue; + + assert(fb->Attachment[b].Renderbuffer == NULL); + + rb = _mesa_new_renderbuffer(ctx, 0); + if (!rb) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating color buffer"); + return GL_FALSE; + } + + if (rgbBits <= 8) { + if (alphaBits) + rb->Format = MESA_FORMAT_RGBA8888; + else + rb->Format = MESA_FORMAT_RGB888; + } + else { + assert(rgbBits <= 16); + rb->Format = MESA_FORMAT_NONE; /*XXX RGBA16;*/ + } + rb->InternalFormat = GL_RGBA; + + rb->AllocStorage = _mesa_soft_renderbuffer_storage; + _mesa_add_renderbuffer(fb, b, rb); + } + + return GL_TRUE; +} + + +/** + * Add software-based alpha renderbuffers to the given framebuffer. + * This is a helper routine for device drivers when creating a + * window system framebuffer (not a user-created render/framebuffer). + * Once this function is called, you can basically forget about this + * renderbuffer; core Mesa will handle all the buffer management and + * rendering! + */ +GLboolean +_mesa_add_alpha_renderbuffers(struct gl_context *ctx, struct gl_framebuffer *fb, + GLuint alphaBits, + GLboolean frontLeft, GLboolean backLeft, + GLboolean frontRight, GLboolean backRight) +{ + gl_buffer_index b; + + /* for window system framebuffers only! */ + assert(fb->Name == 0); + + if (alphaBits > 8) { + _mesa_problem(ctx, + "Unsupported bit depth in _mesa_add_alpha_renderbuffers"); + return GL_FALSE; + } + + assert(MAX_COLOR_ATTACHMENTS >= 4); + + /* Wrap each of the RGB color buffers with an alpha renderbuffer. + */ + for (b = BUFFER_FRONT_LEFT; b <= BUFFER_BACK_RIGHT; b++) { + struct gl_renderbuffer *arb; + + if (b == BUFFER_FRONT_LEFT && !frontLeft) + continue; + else if (b == BUFFER_BACK_LEFT && !backLeft) + continue; + else if (b == BUFFER_FRONT_RIGHT && !frontRight) + continue; + else if (b == BUFFER_BACK_RIGHT && !backRight) + continue; + + /* the RGB buffer to wrap must already exist!! */ + assert(fb->Attachment[b].Renderbuffer); + + /* only GLubyte supported for now */ + assert(fb->Attachment[b].Renderbuffer->DataType == GL_UNSIGNED_BYTE); + + /* allocate alpha renderbuffer */ + arb = _mesa_new_renderbuffer(ctx, 0); + if (!arb) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating alpha buffer"); + return GL_FALSE; + } + + /* wrap the alpha renderbuffer around the RGB renderbuffer */ + arb->Wrapped = fb->Attachment[b].Renderbuffer; + + /* Set up my alphabuffer fields and plug in my functions. + * The functions will put/get the alpha values from/to RGBA arrays + * and then call the wrapped buffer's functions to handle the RGB + * values. + */ + arb->InternalFormat = arb->Wrapped->InternalFormat; + arb->Format = MESA_FORMAT_A8; + arb->DataType = arb->Wrapped->DataType; + arb->AllocStorage = alloc_storage_alpha8; + arb->Delete = delete_renderbuffer_alpha8; + arb->GetPointer = get_pointer_alpha8; + arb->GetRow = get_row_alpha8; + arb->GetValues = get_values_alpha8; + arb->PutRow = put_row_alpha8; + arb->PutRowRGB = put_row_rgb_alpha8; + arb->PutMonoRow = put_mono_row_alpha8; + arb->PutValues = put_values_alpha8; + arb->PutMonoValues = put_mono_values_alpha8; + + /* clear the pointer to avoid assertion/sanity check failure later */ + fb->Attachment[b].Renderbuffer = NULL; + + /* plug the alpha renderbuffer into the colorbuffer attachment */ + _mesa_add_renderbuffer(fb, b, arb); + } + + return GL_TRUE; +} + + +/** + * For framebuffers that use a software alpha channel wrapper + * created by _mesa_add_alpha_renderbuffer or _mesa_add_soft_renderbuffers, + * copy the back buffer alpha channel into the front buffer alpha channel. + */ +void +_mesa_copy_soft_alpha_renderbuffers(struct gl_context *ctx, struct gl_framebuffer *fb) +{ + if (fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer && + fb->Attachment[BUFFER_BACK_LEFT].Renderbuffer) + copy_buffer_alpha8(fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer, + fb->Attachment[BUFFER_BACK_LEFT].Renderbuffer); + + + if (fb->Attachment[BUFFER_FRONT_RIGHT].Renderbuffer && + fb->Attachment[BUFFER_BACK_RIGHT].Renderbuffer) + copy_buffer_alpha8(fb->Attachment[BUFFER_FRONT_RIGHT].Renderbuffer, + fb->Attachment[BUFFER_BACK_RIGHT].Renderbuffer); +} + + +/** + * Add a software-based depth renderbuffer to the given framebuffer. + * This is a helper routine for device drivers when creating a + * window system framebuffer (not a user-created render/framebuffer). + * Once this function is called, you can basically forget about this + * renderbuffer; core Mesa will handle all the buffer management and + * rendering! + */ +GLboolean +_mesa_add_depth_renderbuffer(struct gl_context *ctx, struct gl_framebuffer *fb, + GLuint depthBits) +{ + struct gl_renderbuffer *rb; + + if (depthBits > 32) { + _mesa_problem(ctx, + "Unsupported depthBits in _mesa_add_depth_renderbuffer"); + return GL_FALSE; + } + + assert(fb->Attachment[BUFFER_DEPTH].Renderbuffer == NULL); + + rb = _mesa_new_renderbuffer(ctx, 0); + if (!rb) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating depth buffer"); + return GL_FALSE; + } + + if (depthBits <= 16) { + rb->Format = MESA_FORMAT_Z16; + rb->InternalFormat = GL_DEPTH_COMPONENT16; + } + else if (depthBits <= 24) { + rb->Format = MESA_FORMAT_X8_Z24; + rb->InternalFormat = GL_DEPTH_COMPONENT24; + } + else { + rb->Format = MESA_FORMAT_Z32; + rb->InternalFormat = GL_DEPTH_COMPONENT32; + } + + rb->AllocStorage = _mesa_soft_renderbuffer_storage; + _mesa_add_renderbuffer(fb, BUFFER_DEPTH, rb); + + return GL_TRUE; +} + + +/** + * Add a software-based stencil renderbuffer to the given framebuffer. + * This is a helper routine for device drivers when creating a + * window system framebuffer (not a user-created render/framebuffer). + * Once this function is called, you can basically forget about this + * renderbuffer; core Mesa will handle all the buffer management and + * rendering! + */ +GLboolean +_mesa_add_stencil_renderbuffer(struct gl_context *ctx, struct gl_framebuffer *fb, + GLuint stencilBits) +{ + struct gl_renderbuffer *rb; + + if (stencilBits > 16) { + _mesa_problem(ctx, + "Unsupported stencilBits in _mesa_add_stencil_renderbuffer"); + return GL_FALSE; + } + + assert(fb->Attachment[BUFFER_STENCIL].Renderbuffer == NULL); + + rb = _mesa_new_renderbuffer(ctx, 0); + if (!rb) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating stencil buffer"); + return GL_FALSE; + } + + assert(stencilBits <= 8); + rb->Format = MESA_FORMAT_S8; + rb->InternalFormat = GL_STENCIL_INDEX8; + + rb->AllocStorage = _mesa_soft_renderbuffer_storage; + _mesa_add_renderbuffer(fb, BUFFER_STENCIL, rb); + + return GL_TRUE; +} + + +/** + * Add a software-based accumulation renderbuffer to the given framebuffer. + * This is a helper routine for device drivers when creating a + * window system framebuffer (not a user-created render/framebuffer). + * Once this function is called, you can basically forget about this + * renderbuffer; core Mesa will handle all the buffer management and + * rendering! + */ +GLboolean +_mesa_add_accum_renderbuffer(struct gl_context *ctx, struct gl_framebuffer *fb, + GLuint redBits, GLuint greenBits, + GLuint blueBits, GLuint alphaBits) +{ + struct gl_renderbuffer *rb; + + if (redBits > 16 || greenBits > 16 || blueBits > 16 || alphaBits > 16) { + _mesa_problem(ctx, + "Unsupported accumBits in _mesa_add_accum_renderbuffer"); + return GL_FALSE; + } + + assert(fb->Attachment[BUFFER_ACCUM].Renderbuffer == NULL); + + rb = _mesa_new_renderbuffer(ctx, 0); + if (!rb) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating accum buffer"); + return GL_FALSE; + } + + rb->Format = MESA_FORMAT_SIGNED_RGBA_16; + rb->InternalFormat = GL_RGBA16_SNORM; + rb->AllocStorage = _mesa_soft_renderbuffer_storage; + _mesa_add_renderbuffer(fb, BUFFER_ACCUM, rb); + + return GL_TRUE; +} + + + +/** + * Add a software-based aux renderbuffer to the given framebuffer. + * This is a helper routine for device drivers when creating a + * window system framebuffer (not a user-created render/framebuffer). + * Once this function is called, you can basically forget about this + * renderbuffer; core Mesa will handle all the buffer management and + * rendering! + * + * NOTE: color-index aux buffers not supported. + */ +GLboolean +_mesa_add_aux_renderbuffers(struct gl_context *ctx, struct gl_framebuffer *fb, + GLuint colorBits, GLuint numBuffers) +{ + GLuint i; + + if (colorBits > 16) { + _mesa_problem(ctx, + "Unsupported accumBits in _mesa_add_aux_renderbuffers"); + return GL_FALSE; + } + + assert(numBuffers <= MAX_AUX_BUFFERS); + + for (i = 0; i < numBuffers; i++) { + struct gl_renderbuffer *rb = _mesa_new_renderbuffer(ctx, 0); + + assert(fb->Attachment[BUFFER_AUX0 + i].Renderbuffer == NULL); + + if (!rb) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating aux buffer"); + return GL_FALSE; + } + + assert (colorBits <= 8); + rb->Format = MESA_FORMAT_RGBA8888; + rb->InternalFormat = GL_RGBA; + + rb->AllocStorage = _mesa_soft_renderbuffer_storage; + _mesa_add_renderbuffer(fb, BUFFER_AUX0 + i, rb); + } + return GL_TRUE; +} + + +/** + * Create/attach software-based renderbuffers to the given framebuffer. + * This is a helper routine for device drivers. Drivers can just as well + * call the individual _mesa_add_*_renderbuffer() routines directly. + */ +void +_mesa_add_soft_renderbuffers(struct gl_framebuffer *fb, + GLboolean color, + GLboolean depth, + GLboolean stencil, + GLboolean accum, + GLboolean alpha, + GLboolean aux) +{ + GLboolean frontLeft = GL_TRUE; + GLboolean backLeft = fb->Visual.doubleBufferMode; + GLboolean frontRight = fb->Visual.stereoMode; + GLboolean backRight = fb->Visual.stereoMode && fb->Visual.doubleBufferMode; + + if (color) { + assert(fb->Visual.redBits == fb->Visual.greenBits); + assert(fb->Visual.redBits == fb->Visual.blueBits); + _mesa_add_color_renderbuffers(NULL, fb, + fb->Visual.redBits, + fb->Visual.alphaBits, + frontLeft, backLeft, + frontRight, backRight); + } + + if (depth) { + assert(fb->Visual.depthBits > 0); + _mesa_add_depth_renderbuffer(NULL, fb, fb->Visual.depthBits); + } + + if (stencil) { + assert(fb->Visual.stencilBits > 0); + _mesa_add_stencil_renderbuffer(NULL, fb, fb->Visual.stencilBits); + } + + if (accum) { + assert(fb->Visual.accumRedBits > 0); + assert(fb->Visual.accumGreenBits > 0); + assert(fb->Visual.accumBlueBits > 0); + _mesa_add_accum_renderbuffer(NULL, fb, + fb->Visual.accumRedBits, + fb->Visual.accumGreenBits, + fb->Visual.accumBlueBits, + fb->Visual.accumAlphaBits); + } + + if (aux) { + assert(fb->Visual.numAuxBuffers > 0); + _mesa_add_aux_renderbuffers(NULL, fb, fb->Visual.redBits, + fb->Visual.numAuxBuffers); + } + + if (alpha) { + assert(fb->Visual.alphaBits > 0); + _mesa_add_alpha_renderbuffers(NULL, fb, fb->Visual.alphaBits, + frontLeft, backLeft, + frontRight, backRight); + } + +#if 0 + if (multisample) { + /* maybe someday */ + } +#endif +} + + +/** + * Attach a renderbuffer to a framebuffer. + * \param bufferName one of the BUFFER_x tokens + */ +void +_mesa_add_renderbuffer(struct gl_framebuffer *fb, + gl_buffer_index bufferName, struct gl_renderbuffer *rb) +{ + assert(fb); + assert(rb); + assert(bufferName < BUFFER_COUNT); + + /* There should be no previous renderbuffer on this attachment point, + * with the exception of depth/stencil since the same renderbuffer may + * be used for both. + */ + assert(bufferName == BUFFER_DEPTH || + bufferName == BUFFER_STENCIL || + fb->Attachment[bufferName].Renderbuffer == NULL); + + /* winsys vs. user-created buffer cross check */ + if (fb->Name) { + assert(rb->Name); + } + else { + assert(!rb->Name); + } + + fb->Attachment[bufferName].Type = GL_RENDERBUFFER_EXT; + fb->Attachment[bufferName].Complete = GL_TRUE; + _mesa_reference_renderbuffer(&fb->Attachment[bufferName].Renderbuffer, rb); +} + + +/** + * Remove the named renderbuffer from the given framebuffer. + * \param bufferName one of the BUFFER_x tokens + */ +void +_mesa_remove_renderbuffer(struct gl_framebuffer *fb, + gl_buffer_index bufferName) +{ + struct gl_renderbuffer *rb; + + assert(bufferName < BUFFER_COUNT); + + rb = fb->Attachment[bufferName].Renderbuffer; + if (!rb) + return; + + _mesa_reference_renderbuffer(&rb, NULL); + + fb->Attachment[bufferName].Renderbuffer = NULL; +} + + +/** + * Set *ptr to point to rb. If *ptr points to another renderbuffer, + * dereference that buffer first. The new renderbuffer's refcount will + * be incremented. The old renderbuffer's refcount will be decremented. + * This is normally only called from the _mesa_reference_renderbuffer() macro + * when there's a real pointer change. + */ +void +_mesa_reference_renderbuffer_(struct gl_renderbuffer **ptr, + struct gl_renderbuffer *rb) +{ + if (*ptr) { + /* Unreference the old renderbuffer */ + GLboolean deleteFlag = GL_FALSE; + struct gl_renderbuffer *oldRb = *ptr; + + _glthread_LOCK_MUTEX(oldRb->Mutex); + ASSERT(oldRb->RefCount > 0); + oldRb->RefCount--; + /*printf("RB DECR %p (%d) to %d\n", (void*) oldRb, oldRb->Name, oldRb->RefCount);*/ + deleteFlag = (oldRb->RefCount == 0); + _glthread_UNLOCK_MUTEX(oldRb->Mutex); + + if (deleteFlag) { + oldRb->Delete(oldRb); + } + + *ptr = NULL; + } + assert(!*ptr); + + if (rb) { + /* reference new renderbuffer */ + _glthread_LOCK_MUTEX(rb->Mutex); + rb->RefCount++; + /*printf("RB INCR %p (%d) to %d\n", (void*) rb, rb->Name, rb->RefCount);*/ + _glthread_UNLOCK_MUTEX(rb->Mutex); + *ptr = rb; + } +} diff --git a/mesalib/src/mesa/main/renderbuffer.h b/mesalib/src/mesa/main/renderbuffer.h index 99488c1d3..f9329d55f 100644 --- a/mesalib/src/mesa/main/renderbuffer.h +++ b/mesalib/src/mesa/main/renderbuffer.h @@ -1,121 +1,121 @@ -/* - * 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. - */ - - -#ifndef RENDERBUFFER_H -#define RENDERBUFFER_H - -#include "glheader.h" -#include "mtypes.h" - -struct gl_context; -struct gl_framebuffer; -struct gl_renderbuffer; - -extern void -_mesa_init_renderbuffer(struct gl_renderbuffer *rb, GLuint name); - -extern struct gl_renderbuffer * -_mesa_new_renderbuffer(struct gl_context *ctx, GLuint name); - -extern void -_mesa_delete_renderbuffer(struct gl_renderbuffer *rb); - - -extern struct gl_renderbuffer * -_mesa_new_soft_renderbuffer(struct gl_context *ctx, GLuint name); - -extern void -_mesa_set_renderbuffer_accessors(struct gl_renderbuffer *rb); - -extern GLboolean -_mesa_soft_renderbuffer_storage(struct gl_context *ctx, struct gl_renderbuffer *rb, - GLenum internalFormat, - GLuint width, GLuint height); - -extern GLboolean -_mesa_add_color_renderbuffers(struct gl_context *ctx, struct gl_framebuffer *fb, - GLuint rgbBits, GLuint alphaBits, - GLboolean frontLeft, GLboolean backLeft, - GLboolean frontRight, GLboolean backRight); - -extern GLboolean -_mesa_add_alpha_renderbuffers(struct gl_context *ctx, struct gl_framebuffer *fb, - GLuint alphaBits, - GLboolean frontLeft, GLboolean backLeft, - GLboolean frontRight, GLboolean backRight); - -extern void -_mesa_copy_soft_alpha_renderbuffers(struct gl_context *ctx, struct gl_framebuffer *fb); - -extern GLboolean -_mesa_add_depth_renderbuffer(struct gl_context *ctx, struct gl_framebuffer *fb, - GLuint depthBits); - -extern GLboolean -_mesa_add_stencil_renderbuffer(struct gl_context *ctx, struct gl_framebuffer *fb, - GLuint stencilBits); - - -extern GLboolean -_mesa_add_accum_renderbuffer(struct gl_context *ctx, struct gl_framebuffer *fb, - GLuint redBits, GLuint greenBits, - GLuint blueBits, GLuint alphaBits); - -extern GLboolean -_mesa_add_aux_renderbuffers(struct gl_context *ctx, struct gl_framebuffer *fb, - GLuint bits, GLuint numBuffers); - -extern void -_mesa_add_soft_renderbuffers(struct gl_framebuffer *fb, - GLboolean color, - GLboolean depth, - GLboolean stencil, - GLboolean accum, - GLboolean alpha, - GLboolean aux); - -extern void -_mesa_add_renderbuffer(struct gl_framebuffer *fb, - gl_buffer_index bufferName, struct gl_renderbuffer *rb); - -extern void -_mesa_remove_renderbuffer(struct gl_framebuffer *fb, - gl_buffer_index bufferName); - -extern void -_mesa_reference_renderbuffer_(struct gl_renderbuffer **ptr, - struct gl_renderbuffer *rb); - -static INLINE void -_mesa_reference_renderbuffer(struct gl_renderbuffer **ptr, - struct gl_renderbuffer *rb) -{ - if (*ptr != rb) - _mesa_reference_renderbuffer_(ptr, rb); -} - - - -#endif /* RENDERBUFFER_H */ +/* + * 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. + */ + + +#ifndef RENDERBUFFER_H +#define RENDERBUFFER_H + +#include "glheader.h" +#include "mtypes.h" + +struct gl_context; +struct gl_framebuffer; +struct gl_renderbuffer; + +extern void +_mesa_init_renderbuffer(struct gl_renderbuffer *rb, GLuint name); + +extern struct gl_renderbuffer * +_mesa_new_renderbuffer(struct gl_context *ctx, GLuint name); + +extern void +_mesa_delete_renderbuffer(struct gl_renderbuffer *rb); + + +extern struct gl_renderbuffer * +_mesa_new_soft_renderbuffer(struct gl_context *ctx, GLuint name); + +extern void +_mesa_set_renderbuffer_accessors(struct gl_renderbuffer *rb); + +extern GLboolean +_mesa_soft_renderbuffer_storage(struct gl_context *ctx, struct gl_renderbuffer *rb, + GLenum internalFormat, + GLuint width, GLuint height); + +extern GLboolean +_mesa_add_color_renderbuffers(struct gl_context *ctx, struct gl_framebuffer *fb, + GLuint rgbBits, GLuint alphaBits, + GLboolean frontLeft, GLboolean backLeft, + GLboolean frontRight, GLboolean backRight); + +extern GLboolean +_mesa_add_alpha_renderbuffers(struct gl_context *ctx, struct gl_framebuffer *fb, + GLuint alphaBits, + GLboolean frontLeft, GLboolean backLeft, + GLboolean frontRight, GLboolean backRight); + +extern void +_mesa_copy_soft_alpha_renderbuffers(struct gl_context *ctx, struct gl_framebuffer *fb); + +extern GLboolean +_mesa_add_depth_renderbuffer(struct gl_context *ctx, struct gl_framebuffer *fb, + GLuint depthBits); + +extern GLboolean +_mesa_add_stencil_renderbuffer(struct gl_context *ctx, struct gl_framebuffer *fb, + GLuint stencilBits); + + +extern GLboolean +_mesa_add_accum_renderbuffer(struct gl_context *ctx, struct gl_framebuffer *fb, + GLuint redBits, GLuint greenBits, + GLuint blueBits, GLuint alphaBits); + +extern GLboolean +_mesa_add_aux_renderbuffers(struct gl_context *ctx, struct gl_framebuffer *fb, + GLuint bits, GLuint numBuffers); + +extern void +_mesa_add_soft_renderbuffers(struct gl_framebuffer *fb, + GLboolean color, + GLboolean depth, + GLboolean stencil, + GLboolean accum, + GLboolean alpha, + GLboolean aux); + +extern void +_mesa_add_renderbuffer(struct gl_framebuffer *fb, + gl_buffer_index bufferName, struct gl_renderbuffer *rb); + +extern void +_mesa_remove_renderbuffer(struct gl_framebuffer *fb, + gl_buffer_index bufferName); + +extern void +_mesa_reference_renderbuffer_(struct gl_renderbuffer **ptr, + struct gl_renderbuffer *rb); + +static INLINE void +_mesa_reference_renderbuffer(struct gl_renderbuffer **ptr, + struct gl_renderbuffer *rb) +{ + if (*ptr != rb) + _mesa_reference_renderbuffer_(ptr, rb); +} + + + +#endif /* RENDERBUFFER_H */ diff --git a/mesalib/src/mesa/main/samplerobj.c b/mesalib/src/mesa/main/samplerobj.c index 0d6a33bbd..8f8d87b90 100644 --- a/mesalib/src/mesa/main/samplerobj.c +++ b/mesalib/src/mesa/main/samplerobj.c @@ -1,1413 +1,1413 @@ -/* - * Mesa 3-D graphics library - * - * Copyright (C) 2011 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 samplerobj.c - * \brief Functions for the GL_ARB_sampler_objects extension. - * \author Brian Paul - */ - - -#include "main/glheader.h" -#include "main/context.h" -#include "main/dispatch.h" -#include "main/enums.h" -#include "main/hash.h" -#include "main/macros.h" -#include "main/mfeatures.h" -#include "main/mtypes.h" -#include "main/samplerobj.h" - - -static struct gl_sampler_object * -_mesa_lookup_samplerobj(struct gl_context *ctx, GLuint name) -{ - if (name == 0) - return NULL; - else - return (struct gl_sampler_object *) - _mesa_HashLookup(ctx->Shared->SamplerObjects, name); -} - - -/** - * Handle reference counting. - */ -void -_mesa_reference_sampler_object(struct gl_context *ctx, - struct gl_sampler_object **ptr, - struct gl_sampler_object *samp) -{ - if (*ptr == samp) - return; - - if (*ptr) { - /* Unreference the old sampler */ - GLboolean deleteFlag = GL_FALSE; - struct gl_sampler_object *oldSamp = *ptr; - - /*_glthread_LOCK_MUTEX(oldSamp->Mutex);*/ - ASSERT(oldSamp->RefCount > 0); - oldSamp->RefCount--; -#if 0 - printf("SamplerObj %p %d DECR to %d\n", - (void *) oldSamp, oldSamp->Name, oldSamp->RefCount); -#endif - deleteFlag = (oldSamp->RefCount == 0); - /*_glthread_UNLOCK_MUTEX(oldSamp->Mutex);*/ - - if (deleteFlag) { - ASSERT(ctx->Driver.DeleteSamplerObject); - ctx->Driver.DeleteSamplerObject(ctx, oldSamp); - } - - *ptr = NULL; - } - ASSERT(!*ptr); - - if (samp) { - /* reference new sampler */ - /*_glthread_LOCK_MUTEX(samp->Mutex);*/ - if (samp->RefCount == 0) { - /* this sampler's being deleted (look just above) */ - /* Not sure this can every really happen. Warn if it does. */ - _mesa_problem(NULL, "referencing deleted sampler object"); - *ptr = NULL; - } - else { - samp->RefCount++; -#if 0 - printf("SamplerObj %p %d INCR to %d\n", - (void *) samp, samp->Name, samp->RefCount); -#endif - *ptr = samp; - } - /*_glthread_UNLOCK_MUTEX(samp->Mutex);*/ - } -} - - -/** - * Initialize the fields of the given sampler object. - */ -void -_mesa_init_sampler_object(struct gl_sampler_object *sampObj, GLuint name) -{ - sampObj->Name = name; - sampObj->RefCount = 1; - sampObj->WrapS = GL_REPEAT; - sampObj->WrapT = GL_REPEAT; - sampObj->WrapR = GL_REPEAT; - sampObj->MinFilter = GL_NEAREST_MIPMAP_LINEAR; - sampObj->MagFilter = GL_LINEAR; - sampObj->BorderColor.f[0] = 0.0; - sampObj->BorderColor.f[1] = 0.0; - sampObj->BorderColor.f[2] = 0.0; - sampObj->BorderColor.f[3] = 0.0; - sampObj->MinLod = -1000.0F; - sampObj->MaxLod = 1000.0F; - sampObj->LodBias = 0.0F; - sampObj->MaxAnisotropy = 1.0F; - sampObj->CompareMode = GL_NONE; - sampObj->CompareFunc = GL_LEQUAL; - sampObj->CompareFailValue = 0.0; - sampObj->sRGBDecode = GL_DECODE_EXT; - sampObj->CubeMapSeamless = GL_FALSE; - sampObj->DepthMode = 0; -} - - -/** - * Fallback for ctx->Driver.NewSamplerObject(); - */ -struct gl_sampler_object * -_mesa_new_sampler_object(struct gl_context *ctx, GLuint name) -{ - struct gl_sampler_object *sampObj = CALLOC_STRUCT(gl_sampler_object); - if (sampObj) { - _mesa_init_sampler_object(sampObj, name); - } - return sampObj; -} - - -/** - * Fallback for ctx->Driver.DeleteSamplerObject(); - */ -void -_mesa_delete_sampler_object(struct gl_context *ctx, - struct gl_sampler_object *sampObj) -{ - FREE(sampObj); -} - - -static void GLAPIENTRY -_mesa_GenSamplers(GLsizei count, GLuint *samplers) -{ - GET_CURRENT_CONTEXT(ctx); - GLuint first; - GLint i; - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glGenSamplers(%d)\n", count); - - if (count < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glGenSamplers"); - return; - } - - if (!samplers) - return; - - first = _mesa_HashFindFreeKeyBlock(ctx->Shared->SamplerObjects, count); - - /* Insert the ID and pointer to new sampler object into hash table */ - for (i = 0; i < count; i++) { - struct gl_sampler_object *sampObj = - ctx->Driver.NewSamplerObject(ctx, first + i); - _mesa_HashInsert(ctx->Shared->SamplerObjects, first + i, sampObj); - samplers[i] = first + i; - } -} - - -static void GLAPIENTRY -_mesa_DeleteSamplers(GLsizei count, const GLuint *samplers) -{ - GET_CURRENT_CONTEXT(ctx); - GLsizei i; - - ASSERT_OUTSIDE_BEGIN_END(ctx); - FLUSH_VERTICES(ctx, 0); - - if (count < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glDeleteSamplers(count)"); - return; - } - - _glthread_LOCK_MUTEX(ctx->Shared->Mutex); - - for (i = 0; i < count; i++) { - if (samplers[i]) { - struct gl_sampler_object *sampObj = - _mesa_lookup_samplerobj(ctx, samplers[i]); - if (sampObj) { - /* The ID is immediately freed for re-use */ - _mesa_HashRemove(ctx->Shared->SamplerObjects, samplers[i]); - /* But the object exists until its reference count goes to zero */ - _mesa_reference_sampler_object(ctx, &sampObj, NULL); - } - } - } - - _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); -} - - -static GLboolean GLAPIENTRY -_mesa_IsSampler(GLuint sampler) -{ - struct gl_sampler_object *sampObj; - GET_CURRENT_CONTEXT(ctx); - - ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); - - if (sampler == 0) - return GL_FALSE; - - sampObj = _mesa_lookup_samplerobj(ctx, sampler); - - return sampObj != NULL; -} - - -static void GLAPIENTRY -_mesa_BindSampler(GLuint unit, GLuint sampler) -{ - struct gl_sampler_object *sampObj; - GET_CURRENT_CONTEXT(ctx); - - if (unit >= ctx->Const.MaxCombinedTextureImageUnits) { - _mesa_error(ctx, GL_INVALID_VALUE, "glBindSampler(unit %u)", unit); - return; - } - - if (sampler == 0) { - /* Use the default sampler object, the one contained in the texture - * object. - */ - sampObj = NULL; - } - else { - /* user-defined sampler object */ - sampObj = _mesa_lookup_samplerobj(ctx, sampler); - if (!sampObj) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glBindSampler(sampler)"); - return; - } - } - - if (ctx->Texture.Unit[unit].Sampler != sampObj) { - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - } - - /* bind new sampler */ - _mesa_reference_sampler_object(ctx, &ctx->Texture.Unit[unit].Sampler, - sampObj); -} - - -/** - * Check if a coordinate wrap mode is legal. - * \return GL_TRUE if legal, GL_FALSE otherwise - */ -static GLboolean -validate_texture_wrap_mode(struct gl_context *ctx, GLenum wrap) -{ - const struct gl_extensions * const e = &ctx->Extensions; - - switch (wrap) { - case GL_CLAMP: - case GL_CLAMP_TO_EDGE: - case GL_REPEAT: - return GL_TRUE; - case GL_CLAMP_TO_BORDER: - return e->ARB_texture_border_clamp; - case GL_MIRRORED_REPEAT: - return e->ARB_texture_mirrored_repeat; - case GL_MIRROR_CLAMP_EXT: - return e->ATI_texture_mirror_once || e->EXT_texture_mirror_clamp; - case GL_MIRROR_CLAMP_TO_EDGE_EXT: - return e->ATI_texture_mirror_once || e->EXT_texture_mirror_clamp; - case GL_MIRROR_CLAMP_TO_BORDER_EXT: - return e->EXT_texture_mirror_clamp; - default: - return GL_FALSE; - } -} - - -/** - * This is called just prior to changing any sampler object state. - */ -static INLINE void -flush(struct gl_context *ctx) -{ - FLUSH_VERTICES(ctx, _NEW_TEXTURE); -} - - -#define INVALID_PARAM 0x100 -#define INVALID_PNAME 0x101 -#define INVALID_VALUE 0x102 - -static GLuint -set_sampler_wrap_s(struct gl_context *ctx, struct gl_sampler_object *samp, - GLint param) -{ - if (samp->WrapS == param) - return GL_FALSE; - if (validate_texture_wrap_mode(ctx, param)) { - flush(ctx); - samp->WrapS = param; - return GL_TRUE; - } - return INVALID_PARAM; -} - - -static GLuint -set_sampler_wrap_t(struct gl_context *ctx, struct gl_sampler_object *samp, - GLint param) -{ - if (samp->WrapT == param) - return GL_FALSE; - if (validate_texture_wrap_mode(ctx, param)) { - flush(ctx); - samp->WrapT = param; - return GL_TRUE; - } - return INVALID_PARAM; -} - - -static GLuint -set_sampler_wrap_r(struct gl_context *ctx, struct gl_sampler_object *samp, - GLint param) -{ - if (samp->WrapR == param) - return GL_FALSE; - if (validate_texture_wrap_mode(ctx, param)) { - flush(ctx); - samp->WrapR = param; - return GL_TRUE; - } - return INVALID_PARAM; -} - - -static GLuint -set_sampler_min_filter(struct gl_context *ctx, struct gl_sampler_object *samp, - GLint param) -{ - if (samp->MinFilter == param) - return GL_FALSE; - - switch (param) { - case GL_NEAREST: - case GL_LINEAR: - case GL_NEAREST_MIPMAP_NEAREST: - case GL_LINEAR_MIPMAP_NEAREST: - case GL_NEAREST_MIPMAP_LINEAR: - case GL_LINEAR_MIPMAP_LINEAR: - flush(ctx); - samp->MinFilter = param; - return GL_TRUE; - default: - return INVALID_PARAM; - } -} - - -static GLuint -set_sampler_mag_filter(struct gl_context *ctx, struct gl_sampler_object *samp, - GLint param) -{ - if (samp->MagFilter == param) - return GL_FALSE; - - switch (param) { - case GL_NEAREST: - case GL_LINEAR: - flush(ctx); - samp->MagFilter = param; - return GL_TRUE; - default: - return INVALID_PARAM; - } -} - - -static GLuint -set_sampler_lod_bias(struct gl_context *ctx, struct gl_sampler_object *samp, - GLfloat param) -{ - if (samp->LodBias == param) - return GL_FALSE; - - flush(ctx); - samp->LodBias = param; - return GL_TRUE; -} - - -static GLuint -set_sampler_border_colorf(struct gl_context *ctx, - struct gl_sampler_object *samp, - const GLfloat params[4]) -{ - flush(ctx); - samp->BorderColor.f[RCOMP] = params[0]; - samp->BorderColor.f[GCOMP] = params[1]; - samp->BorderColor.f[BCOMP] = params[2]; - samp->BorderColor.f[ACOMP] = params[3]; - return GL_TRUE; -} - - -static GLuint -set_sampler_border_colori(struct gl_context *ctx, - struct gl_sampler_object *samp, - const GLint params[4]) -{ - flush(ctx); - samp->BorderColor.i[RCOMP] = params[0]; - samp->BorderColor.i[GCOMP] = params[1]; - samp->BorderColor.i[BCOMP] = params[2]; - samp->BorderColor.i[ACOMP] = params[3]; - return GL_TRUE; -} - - -static GLuint -set_sampler_border_colorui(struct gl_context *ctx, - struct gl_sampler_object *samp, - const GLuint params[4]) -{ - flush(ctx); - samp->BorderColor.ui[RCOMP] = params[0]; - samp->BorderColor.ui[GCOMP] = params[1]; - samp->BorderColor.ui[BCOMP] = params[2]; - samp->BorderColor.ui[ACOMP] = params[3]; - return GL_TRUE; -} - - -static GLuint -set_sampler_min_lod(struct gl_context *ctx, struct gl_sampler_object *samp, - GLfloat param) -{ - if (samp->MinLod == param) - return GL_FALSE; - - flush(ctx); - samp->MinLod = param; - return GL_TRUE; -} - - -static GLuint -set_sampler_max_lod(struct gl_context *ctx, struct gl_sampler_object *samp, - GLfloat param) -{ - if (samp->MaxLod == param) - return GL_FALSE; - - flush(ctx); - samp->MaxLod = param; - return GL_TRUE; -} - - -static GLuint -set_sampler_compare_mode(struct gl_context *ctx, - struct gl_sampler_object *samp, GLint param) -{ - if (!ctx->Extensions.ARB_shadow) - return INVALID_PNAME; - - if (samp->CompareMode == param) - return GL_FALSE; - - if (param == GL_NONE || - param == GL_COMPARE_R_TO_TEXTURE_ARB) { - flush(ctx); - samp->CompareMode = param; - return GL_TRUE; - } - - return INVALID_PARAM; -} - - -static GLuint -set_sampler_compare_func(struct gl_context *ctx, - struct gl_sampler_object *samp, GLint param) -{ - if (!ctx->Extensions.ARB_shadow) - return INVALID_PNAME; - - if (samp->CompareFunc == param) - return GL_FALSE; - - switch (param) { - case GL_LEQUAL: - case GL_GEQUAL: - flush(ctx); - samp->CompareFunc = param; - return GL_TRUE; - case GL_EQUAL: - case GL_NOTEQUAL: - case GL_LESS: - case GL_GREATER: - case GL_ALWAYS: - case GL_NEVER: - if (ctx->Extensions.EXT_shadow_funcs) { - flush(ctx); - samp->CompareFunc = param; - return GL_TRUE; - } - /* fall-through */ - default: - return INVALID_PARAM; - } -} - - -static GLuint -set_sampler_max_anisotropy(struct gl_context *ctx, - struct gl_sampler_object *samp, GLfloat param) -{ - if (!ctx->Extensions.EXT_texture_filter_anisotropic) - return INVALID_PNAME; - - if (samp->MaxAnisotropy == param) - return GL_FALSE; - - if (param < 1.0) - return INVALID_VALUE; - - flush(ctx); - /* clamp to max, that's what NVIDIA does */ - samp->MaxAnisotropy = MIN2(param, ctx->Const.MaxTextureMaxAnisotropy); - return GL_TRUE; -} - - -static GLuint -set_sampler_cube_map_seamless(struct gl_context *ctx, - struct gl_sampler_object *samp, GLboolean param) -{ - if (!ctx->Extensions.AMD_seamless_cubemap_per_texture) - return INVALID_PNAME; - - if (samp->CubeMapSeamless == param) - return GL_FALSE; - - if (param != GL_TRUE && param != GL_FALSE) - return INVALID_VALUE; - - flush(ctx); - samp->CubeMapSeamless = param; - return GL_TRUE; -} - - -static void GLAPIENTRY -_mesa_SamplerParameteri(GLuint sampler, GLenum pname, GLint param) -{ - struct gl_sampler_object *sampObj; - GLuint res; - GET_CURRENT_CONTEXT(ctx); - - sampObj = _mesa_lookup_samplerobj(ctx, sampler); - if (!sampObj) { - _mesa_error(ctx, GL_INVALID_VALUE, "glSamplerParameteri(sampler %u)", - sampler); - return; - } - - switch (pname) { - case GL_TEXTURE_WRAP_S: - res = set_sampler_wrap_s(ctx, sampObj, param); - break; - case GL_TEXTURE_WRAP_T: - res = set_sampler_wrap_t(ctx, sampObj, param); - break; - case GL_TEXTURE_WRAP_R: - res = set_sampler_wrap_r(ctx, sampObj, param); - break; - case GL_TEXTURE_MIN_FILTER: - res = set_sampler_min_filter(ctx, sampObj, param); - break; - case GL_TEXTURE_MAG_FILTER: - res = set_sampler_mag_filter(ctx, sampObj, param); - break; - case GL_TEXTURE_MIN_LOD: - res = set_sampler_min_lod(ctx, sampObj, (GLfloat) param); - break; - case GL_TEXTURE_MAX_LOD: - res = set_sampler_max_lod(ctx, sampObj, (GLfloat) param); - break; - case GL_TEXTURE_LOD_BIAS: - res = set_sampler_lod_bias(ctx, sampObj, (GLfloat) param); - break; - case GL_TEXTURE_COMPARE_MODE: - res = set_sampler_compare_mode(ctx, sampObj, param); - break; - case GL_TEXTURE_COMPARE_FUNC: - res = set_sampler_compare_func(ctx, sampObj, param); - break; - case GL_TEXTURE_MAX_ANISOTROPY_EXT: - res = set_sampler_max_anisotropy(ctx, sampObj, (GLfloat) param); - break; - case GL_TEXTURE_CUBE_MAP_SEAMLESS: - res = set_sampler_cube_map_seamless(ctx, sampObj, param); - break; - case GL_TEXTURE_BORDER_COLOR: - /* fall-through */ - default: - res = INVALID_PNAME; - } - - switch (res) { - case GL_FALSE: - /* no change */ - break; - case GL_TRUE: - /* state change - we do nothing special at this time */ - break; - case INVALID_PNAME: - _mesa_error(ctx, GL_INVALID_ENUM, "glSamplerParameteri(pname=%s)\n", - _mesa_lookup_enum_by_nr(pname)); - break; - case INVALID_PARAM: - _mesa_error(ctx, GL_INVALID_ENUM, "glSamplerParameteri(param=%d)\n", - param); - break; - case INVALID_VALUE: - _mesa_error(ctx, GL_INVALID_VALUE, "glSamplerParameteri(param=%d)\n", - param); - break; - default: - ; - } -} - - -static void GLAPIENTRY -_mesa_SamplerParameterf(GLuint sampler, GLenum pname, GLfloat param) -{ - struct gl_sampler_object *sampObj; - GLuint res; - GET_CURRENT_CONTEXT(ctx); - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - sampObj = _mesa_lookup_samplerobj(ctx, sampler); - if (!sampObj) { - _mesa_error(ctx, GL_INVALID_VALUE, "glSamplerParameterf(sampler %u)", - sampler); - return; - } - - switch (pname) { - case GL_TEXTURE_WRAP_S: - res = set_sampler_wrap_s(ctx, sampObj, (GLint) param); - break; - case GL_TEXTURE_WRAP_T: - res = set_sampler_wrap_t(ctx, sampObj, (GLint) param); - break; - case GL_TEXTURE_WRAP_R: - res = set_sampler_wrap_r(ctx, sampObj, (GLint) param); - break; - case GL_TEXTURE_MIN_FILTER: - res = set_sampler_min_filter(ctx, sampObj, (GLint) param); - break; - case GL_TEXTURE_MAG_FILTER: - res = set_sampler_mag_filter(ctx, sampObj, (GLint) param); - break; - case GL_TEXTURE_MIN_LOD: - res = set_sampler_min_lod(ctx, sampObj, param); - break; - case GL_TEXTURE_MAX_LOD: - res = set_sampler_max_lod(ctx, sampObj, param); - break; - case GL_TEXTURE_LOD_BIAS: - res = set_sampler_lod_bias(ctx, sampObj, param); - break; - case GL_TEXTURE_COMPARE_MODE: - res = set_sampler_compare_mode(ctx, sampObj, (GLint) param); - break; - case GL_TEXTURE_COMPARE_FUNC: - res = set_sampler_compare_func(ctx, sampObj, (GLint) param); - break; - case GL_TEXTURE_MAX_ANISOTROPY_EXT: - res = set_sampler_max_anisotropy(ctx, sampObj, param); - break; - case GL_TEXTURE_CUBE_MAP_SEAMLESS: - res = set_sampler_cube_map_seamless(ctx, sampObj, (GLboolean) param); - break; - case GL_TEXTURE_BORDER_COLOR: - /* fall-through */ - default: - res = INVALID_PNAME; - } - - switch (res) { - case GL_FALSE: - /* no change */ - break; - case GL_TRUE: - /* state change - we do nothing special at this time */ - break; - case INVALID_PNAME: - _mesa_error(ctx, GL_INVALID_ENUM, "glSamplerParameterf(pname=%s)\n", - _mesa_lookup_enum_by_nr(pname)); - break; - case INVALID_PARAM: - _mesa_error(ctx, GL_INVALID_ENUM, "glSamplerParameterf(param=%f)\n", - param); - break; - case INVALID_VALUE: - _mesa_error(ctx, GL_INVALID_VALUE, "glSamplerParameterf(param=%f)\n", - param); - break; - default: - ; - } -} - -static void GLAPIENTRY -_mesa_SamplerParameteriv(GLuint sampler, GLenum pname, const GLint *params) -{ - struct gl_sampler_object *sampObj; - GLuint res; - GET_CURRENT_CONTEXT(ctx); - - sampObj = _mesa_lookup_samplerobj(ctx, sampler); - if (!sampObj) { - _mesa_error(ctx, GL_INVALID_VALUE, "glSamplerParameteriv(sampler %u)", - sampler); - return; - } - - switch (pname) { - case GL_TEXTURE_WRAP_S: - res = set_sampler_wrap_s(ctx, sampObj, params[0]); - break; - case GL_TEXTURE_WRAP_T: - res = set_sampler_wrap_t(ctx, sampObj, params[0]); - break; - case GL_TEXTURE_WRAP_R: - res = set_sampler_wrap_r(ctx, sampObj, params[0]); - break; - case GL_TEXTURE_MIN_FILTER: - res = set_sampler_min_filter(ctx, sampObj, params[0]); - break; - case GL_TEXTURE_MAG_FILTER: - res = set_sampler_mag_filter(ctx, sampObj, params[0]); - break; - case GL_TEXTURE_MIN_LOD: - res = set_sampler_min_lod(ctx, sampObj, (GLfloat) params[0]); - break; - case GL_TEXTURE_MAX_LOD: - res = set_sampler_max_lod(ctx, sampObj, (GLfloat) params[0]); - break; - case GL_TEXTURE_LOD_BIAS: - res = set_sampler_lod_bias(ctx, sampObj, (GLfloat) params[0]); - break; - case GL_TEXTURE_COMPARE_MODE: - res = set_sampler_compare_mode(ctx, sampObj, params[0]); - break; - case GL_TEXTURE_COMPARE_FUNC: - res = set_sampler_compare_func(ctx, sampObj, params[0]); - break; - case GL_TEXTURE_MAX_ANISOTROPY_EXT: - res = set_sampler_max_anisotropy(ctx, sampObj, (GLfloat) params[0]); - break; - case GL_TEXTURE_CUBE_MAP_SEAMLESS: - res = set_sampler_cube_map_seamless(ctx, sampObj, params[0]); - break; - case GL_TEXTURE_BORDER_COLOR: - { - GLfloat c[4]; - c[0] = INT_TO_FLOAT(params[0]); - c[1] = INT_TO_FLOAT(params[1]); - c[2] = INT_TO_FLOAT(params[2]); - c[3] = INT_TO_FLOAT(params[3]); - res = set_sampler_border_colorf(ctx, sampObj, c); - } - break; - default: - res = INVALID_PNAME; - } - - switch (res) { - case GL_FALSE: - /* no change */ - break; - case GL_TRUE: - /* state change - we do nothing special at this time */ - break; - case INVALID_PNAME: - _mesa_error(ctx, GL_INVALID_ENUM, "glSamplerParameteriv(pname=%s)\n", - _mesa_lookup_enum_by_nr(pname)); - break; - case INVALID_PARAM: - _mesa_error(ctx, GL_INVALID_ENUM, "glSamplerParameteriv(param=%d)\n", - params[0]); - break; - case INVALID_VALUE: - _mesa_error(ctx, GL_INVALID_VALUE, "glSamplerParameteriv(param=%d)\n", - params[0]); - break; - default: - ; - } -} - -static void GLAPIENTRY -_mesa_SamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat *params) -{ - struct gl_sampler_object *sampObj; - GLuint res; - GET_CURRENT_CONTEXT(ctx); - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - sampObj = _mesa_lookup_samplerobj(ctx, sampler); - if (!sampObj) { - _mesa_error(ctx, GL_INVALID_VALUE, "glSamplerParameterfv(sampler %u)", - sampler); - return; - } - - switch (pname) { - case GL_TEXTURE_WRAP_S: - res = set_sampler_wrap_s(ctx, sampObj, (GLint) params[0]); - break; - case GL_TEXTURE_WRAP_T: - res = set_sampler_wrap_t(ctx, sampObj, (GLint) params[0]); - break; - case GL_TEXTURE_WRAP_R: - res = set_sampler_wrap_r(ctx, sampObj, (GLint) params[0]); - break; - case GL_TEXTURE_MIN_FILTER: - res = set_sampler_min_filter(ctx, sampObj, (GLint) params[0]); - break; - case GL_TEXTURE_MAG_FILTER: - res = set_sampler_mag_filter(ctx, sampObj, (GLint) params[0]); - break; - case GL_TEXTURE_MIN_LOD: - res = set_sampler_min_lod(ctx, sampObj, params[0]); - break; - case GL_TEXTURE_MAX_LOD: - res = set_sampler_max_lod(ctx, sampObj, params[0]); - break; - case GL_TEXTURE_LOD_BIAS: - res = set_sampler_lod_bias(ctx, sampObj, params[0]); - break; - case GL_TEXTURE_COMPARE_MODE: - res = set_sampler_compare_mode(ctx, sampObj, (GLint) params[0]); - break; - case GL_TEXTURE_COMPARE_FUNC: - res = set_sampler_compare_func(ctx, sampObj, (GLint) params[0]); - break; - case GL_TEXTURE_MAX_ANISOTROPY_EXT: - res = set_sampler_max_anisotropy(ctx, sampObj, params[0]); - break; - case GL_TEXTURE_CUBE_MAP_SEAMLESS: - res = set_sampler_cube_map_seamless(ctx, sampObj, (GLboolean) params[0]); - break; - case GL_TEXTURE_BORDER_COLOR: - res = set_sampler_border_colorf(ctx, sampObj, params); - break; - default: - res = INVALID_PNAME; - } - - switch (res) { - case GL_FALSE: - /* no change */ - break; - case GL_TRUE: - /* state change - we do nothing special at this time */ - break; - case INVALID_PNAME: - _mesa_error(ctx, GL_INVALID_ENUM, "glSamplerParameterfv(pname=%s)\n", - _mesa_lookup_enum_by_nr(pname)); - break; - case INVALID_PARAM: - _mesa_error(ctx, GL_INVALID_ENUM, "glSamplerParameterfv(param=%f)\n", - params[0]); - break; - case INVALID_VALUE: - _mesa_error(ctx, GL_INVALID_VALUE, "glSamplerParameterfv(param=%f)\n", - params[0]); - break; - default: - ; - } -} - -static void GLAPIENTRY -_mesa_SamplerParameterIiv(GLuint sampler, GLenum pname, const GLint *params) -{ - struct gl_sampler_object *sampObj; - GLuint res; - GET_CURRENT_CONTEXT(ctx); - - sampObj = _mesa_lookup_samplerobj(ctx, sampler); - if (!sampObj) { - _mesa_error(ctx, GL_INVALID_VALUE, "glSamplerParameterIiv(sampler %u)", - sampler); - return; - } - - switch (pname) { - case GL_TEXTURE_WRAP_S: - res = set_sampler_wrap_s(ctx, sampObj, params[0]); - break; - case GL_TEXTURE_WRAP_T: - res = set_sampler_wrap_t(ctx, sampObj, params[0]); - break; - case GL_TEXTURE_WRAP_R: - res = set_sampler_wrap_r(ctx, sampObj, params[0]); - break; - case GL_TEXTURE_MIN_FILTER: - res = set_sampler_min_filter(ctx, sampObj, params[0]); - break; - case GL_TEXTURE_MAG_FILTER: - res = set_sampler_mag_filter(ctx, sampObj, params[0]); - break; - case GL_TEXTURE_MIN_LOD: - res = set_sampler_min_lod(ctx, sampObj, (GLfloat) params[0]); - break; - case GL_TEXTURE_MAX_LOD: - res = set_sampler_max_lod(ctx, sampObj, (GLfloat) params[0]); - break; - case GL_TEXTURE_LOD_BIAS: - res = set_sampler_lod_bias(ctx, sampObj, (GLfloat) params[0]); - break; - case GL_TEXTURE_COMPARE_MODE: - res = set_sampler_compare_mode(ctx, sampObj, params[0]); - break; - case GL_TEXTURE_COMPARE_FUNC: - res = set_sampler_compare_func(ctx, sampObj, params[0]); - break; - case GL_TEXTURE_MAX_ANISOTROPY_EXT: - res = set_sampler_max_anisotropy(ctx, sampObj, (GLfloat) params[0]); - break; - case GL_TEXTURE_CUBE_MAP_SEAMLESS: - res = set_sampler_cube_map_seamless(ctx, sampObj, params[0]); - break; - case GL_TEXTURE_BORDER_COLOR: - res = set_sampler_border_colori(ctx, sampObj, params); - break; - default: - res = INVALID_PNAME; - } - - switch (res) { - case GL_FALSE: - /* no change */ - break; - case GL_TRUE: - /* state change - we do nothing special at this time */ - break; - case INVALID_PNAME: - _mesa_error(ctx, GL_INVALID_ENUM, "glSamplerParameterIiv(pname=%s)\n", - _mesa_lookup_enum_by_nr(pname)); - break; - case INVALID_PARAM: - _mesa_error(ctx, GL_INVALID_ENUM, "glSamplerParameterIiv(param=%d)\n", - params[0]); - break; - case INVALID_VALUE: - _mesa_error(ctx, GL_INVALID_VALUE, "glSamplerParameterIiv(param=%d)\n", - params[0]); - break; - default: - ; - } -} - - -static void GLAPIENTRY -_mesa_SamplerParameterIuiv(GLuint sampler, GLenum pname, const GLuint *params) -{ - struct gl_sampler_object *sampObj; - GLuint res; - GET_CURRENT_CONTEXT(ctx); - - sampObj = _mesa_lookup_samplerobj(ctx, sampler); - if (!sampObj) { - _mesa_error(ctx, GL_INVALID_VALUE, "glSamplerParameterIuiv(sampler %u)", - sampler); - return; - } - - switch (pname) { - case GL_TEXTURE_WRAP_S: - res = set_sampler_wrap_s(ctx, sampObj, params[0]); - break; - case GL_TEXTURE_WRAP_T: - res = set_sampler_wrap_t(ctx, sampObj, params[0]); - break; - case GL_TEXTURE_WRAP_R: - res = set_sampler_wrap_r(ctx, sampObj, params[0]); - break; - case GL_TEXTURE_MIN_FILTER: - res = set_sampler_min_filter(ctx, sampObj, params[0]); - break; - case GL_TEXTURE_MAG_FILTER: - res = set_sampler_mag_filter(ctx, sampObj, params[0]); - break; - case GL_TEXTURE_MIN_LOD: - res = set_sampler_min_lod(ctx, sampObj, (GLfloat) params[0]); - break; - case GL_TEXTURE_MAX_LOD: - res = set_sampler_max_lod(ctx, sampObj, (GLfloat) params[0]); - break; - case GL_TEXTURE_LOD_BIAS: - res = set_sampler_lod_bias(ctx, sampObj, (GLfloat) params[0]); - break; - case GL_TEXTURE_COMPARE_MODE: - res = set_sampler_compare_mode(ctx, sampObj, params[0]); - break; - case GL_TEXTURE_COMPARE_FUNC: - res = set_sampler_compare_func(ctx, sampObj, params[0]); - break; - case GL_TEXTURE_MAX_ANISOTROPY_EXT: - res = set_sampler_max_anisotropy(ctx, sampObj, (GLfloat) params[0]); - break; - case GL_TEXTURE_CUBE_MAP_SEAMLESS: - res = set_sampler_cube_map_seamless(ctx, sampObj, params[0]); - break; - case GL_TEXTURE_BORDER_COLOR: - res = set_sampler_border_colorui(ctx, sampObj, params); - break; - default: - res = INVALID_PNAME; - } - - switch (res) { - case GL_FALSE: - /* no change */ - break; - case GL_TRUE: - /* state change - we do nothing special at this time */ - break; - case INVALID_PNAME: - _mesa_error(ctx, GL_INVALID_ENUM, "glSamplerParameterIuiv(pname=%s)\n", - _mesa_lookup_enum_by_nr(pname)); - break; - case INVALID_PARAM: - _mesa_error(ctx, GL_INVALID_ENUM, "glSamplerParameterIuiv(param=%u)\n", - params[0]); - break; - case INVALID_VALUE: - _mesa_error(ctx, GL_INVALID_VALUE, "glSamplerParameterIuiv(param=%u)\n", - params[0]); - break; - default: - ; - } -} - - -static void GLAPIENTRY -_mesa_GetSamplerParameteriv(GLuint sampler, GLenum pname, GLint *params) -{ - struct gl_sampler_object *sampObj; - GET_CURRENT_CONTEXT(ctx); - - sampObj = _mesa_lookup_samplerobj(ctx, sampler); - if (!sampObj) { - _mesa_error(ctx, GL_INVALID_VALUE, "glGetSamplerParameteriv(sampler %u)", - sampler); - return; - } - - switch (pname) { - case GL_TEXTURE_WRAP_S: - *params = sampObj->WrapS; - break; - case GL_TEXTURE_WRAP_T: - *params = sampObj->WrapT; - break; - case GL_TEXTURE_WRAP_R: - *params = sampObj->WrapR; - break; - case GL_TEXTURE_MIN_FILTER: - *params = sampObj->MinFilter; - break; - case GL_TEXTURE_MAG_FILTER: - *params = sampObj->MagFilter; - break; - case GL_TEXTURE_MIN_LOD: - *params = (GLint) sampObj->MinLod; - break; - case GL_TEXTURE_MAX_LOD: - *params = (GLint) sampObj->MaxLod; - break; - case GL_TEXTURE_LOD_BIAS: - *params = (GLint) sampObj->LodBias; - break; - case GL_TEXTURE_COMPARE_MODE: - if (!ctx->Extensions.ARB_shadow) - goto invalid_pname; - *params = sampObj->CompareMode; - break; - case GL_TEXTURE_COMPARE_FUNC: - if (!ctx->Extensions.ARB_shadow) - goto invalid_pname; - *params = sampObj->CompareFunc; - break; - case GL_TEXTURE_MAX_ANISOTROPY_EXT: - *params = (GLint) sampObj->MaxAnisotropy; - break; - case GL_TEXTURE_BORDER_COLOR: - params[0] = FLOAT_TO_INT(sampObj->BorderColor.f[0]); - params[1] = FLOAT_TO_INT(sampObj->BorderColor.f[1]); - params[2] = FLOAT_TO_INT(sampObj->BorderColor.f[2]); - params[3] = FLOAT_TO_INT(sampObj->BorderColor.f[3]); - break; - case GL_TEXTURE_CUBE_MAP_SEAMLESS: - if (!ctx->Extensions.AMD_seamless_cubemap_per_texture) - goto invalid_pname; - *params = sampObj->CubeMapSeamless; - break; - default: - goto invalid_pname; - } - return; - -invalid_pname: - _mesa_error(ctx, GL_INVALID_ENUM, "glGetSamplerParameteriv(pname=%s)", - _mesa_lookup_enum_by_nr(pname)); -} - - -static void GLAPIENTRY -_mesa_GetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat *params) -{ - struct gl_sampler_object *sampObj; - GET_CURRENT_CONTEXT(ctx); - - sampObj = _mesa_lookup_samplerobj(ctx, sampler); - if (!sampObj) { - _mesa_error(ctx, GL_INVALID_VALUE, "glGetSamplerParameterfv(sampler %u)", - sampler); - return; - } - - switch (pname) { - case GL_TEXTURE_WRAP_S: - *params = (GLfloat) sampObj->WrapS; - break; - case GL_TEXTURE_WRAP_T: - *params = (GLfloat) sampObj->WrapT; - break; - case GL_TEXTURE_WRAP_R: - *params = (GLfloat) sampObj->WrapR; - break; - case GL_TEXTURE_MIN_FILTER: - *params = (GLfloat) sampObj->MinFilter; - break; - case GL_TEXTURE_MAG_FILTER: - *params = (GLfloat) sampObj->MagFilter; - break; - case GL_TEXTURE_MIN_LOD: - *params = sampObj->MinLod; - break; - case GL_TEXTURE_MAX_LOD: - *params = sampObj->MaxLod; - break; - case GL_TEXTURE_LOD_BIAS: - *params = sampObj->LodBias; - break; - case GL_TEXTURE_COMPARE_MODE: - if (!ctx->Extensions.ARB_shadow) - goto invalid_pname; - *params = (GLfloat) sampObj->CompareMode; - break; - case GL_TEXTURE_COMPARE_FUNC: - if (!ctx->Extensions.ARB_shadow) - goto invalid_pname; - *params = (GLfloat) sampObj->CompareFunc; - break; - case GL_TEXTURE_MAX_ANISOTROPY_EXT: - *params = sampObj->MaxAnisotropy; - break; - case GL_TEXTURE_BORDER_COLOR: - params[0] = sampObj->BorderColor.f[0]; - params[1] = sampObj->BorderColor.f[1]; - params[2] = sampObj->BorderColor.f[2]; - params[3] = sampObj->BorderColor.f[3]; - break; - case GL_TEXTURE_CUBE_MAP_SEAMLESS: - if (!ctx->Extensions.AMD_seamless_cubemap_per_texture) - goto invalid_pname; - *params = (GLfloat) sampObj->CubeMapSeamless; - break; - default: - goto invalid_pname; - } - return; - -invalid_pname: - _mesa_error(ctx, GL_INVALID_ENUM, "glGetSamplerParameterfv(pname=%s)", - _mesa_lookup_enum_by_nr(pname)); -} - - -static void GLAPIENTRY -_mesa_GetSamplerParameterIiv(GLuint sampler, GLenum pname, GLint *params) -{ - struct gl_sampler_object *sampObj; - GET_CURRENT_CONTEXT(ctx); - - sampObj = _mesa_lookup_samplerobj(ctx, sampler); - if (!sampObj) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glGetSamplerParameterIiv(sampler %u)", - sampler); - return; - } - - switch (pname) { - case GL_TEXTURE_WRAP_S: - *params = sampObj->WrapS; - break; - case GL_TEXTURE_WRAP_T: - *params = sampObj->WrapT; - break; - case GL_TEXTURE_WRAP_R: - *params = sampObj->WrapR; - break; - case GL_TEXTURE_MIN_FILTER: - *params = sampObj->MinFilter; - break; - case GL_TEXTURE_MAG_FILTER: - *params = sampObj->MagFilter; - break; - case GL_TEXTURE_MIN_LOD: - *params = (GLint) sampObj->MinLod; - break; - case GL_TEXTURE_MAX_LOD: - *params = (GLint) sampObj->MaxLod; - break; - case GL_TEXTURE_LOD_BIAS: - *params = (GLint) sampObj->LodBias; - break; - case GL_TEXTURE_COMPARE_MODE: - if (!ctx->Extensions.ARB_shadow) - goto invalid_pname; - *params = sampObj->CompareMode; - break; - case GL_TEXTURE_COMPARE_FUNC: - if (!ctx->Extensions.ARB_shadow) - goto invalid_pname; - *params = sampObj->CompareFunc; - break; - case GL_TEXTURE_MAX_ANISOTROPY_EXT: - *params = (GLint) sampObj->MaxAnisotropy; - break; - case GL_TEXTURE_BORDER_COLOR: - params[0] = sampObj->BorderColor.i[0]; - params[1] = sampObj->BorderColor.i[1]; - params[2] = sampObj->BorderColor.i[2]; - params[3] = sampObj->BorderColor.i[3]; - break; - case GL_TEXTURE_CUBE_MAP_SEAMLESS: - if (!ctx->Extensions.AMD_seamless_cubemap_per_texture) - goto invalid_pname; - *params = sampObj->CubeMapSeamless; - break; - default: - goto invalid_pname; - } - return; - -invalid_pname: - _mesa_error(ctx, GL_INVALID_ENUM, "glGetSamplerParameterIiv(pname=%s)", - _mesa_lookup_enum_by_nr(pname)); -} - - -static void GLAPIENTRY -_mesa_GetSamplerParameterIuiv(GLuint sampler, GLenum pname, GLuint *params) -{ - struct gl_sampler_object *sampObj; - GET_CURRENT_CONTEXT(ctx); - - sampObj = _mesa_lookup_samplerobj(ctx, sampler); - if (!sampObj) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glGetSamplerParameterIuiv(sampler %u)", - sampler); - return; - } - - switch (pname) { - case GL_TEXTURE_WRAP_S: - *params = sampObj->WrapS; - break; - case GL_TEXTURE_WRAP_T: - *params = sampObj->WrapT; - break; - case GL_TEXTURE_WRAP_R: - *params = sampObj->WrapR; - break; - case GL_TEXTURE_MIN_FILTER: - *params = sampObj->MinFilter; - break; - case GL_TEXTURE_MAG_FILTER: - *params = sampObj->MagFilter; - break; - case GL_TEXTURE_MIN_LOD: - *params = (GLuint) sampObj->MinLod; - break; - case GL_TEXTURE_MAX_LOD: - *params = (GLuint) sampObj->MaxLod; - break; - case GL_TEXTURE_LOD_BIAS: - *params = (GLuint) sampObj->LodBias; - break; - case GL_TEXTURE_COMPARE_MODE: - if (!ctx->Extensions.ARB_shadow) - goto invalid_pname; - *params = sampObj->CompareMode; - break; - case GL_TEXTURE_COMPARE_FUNC: - if (!ctx->Extensions.ARB_shadow) - goto invalid_pname; - *params = sampObj->CompareFunc; - break; - case GL_TEXTURE_MAX_ANISOTROPY_EXT: - *params = (GLuint) sampObj->MaxAnisotropy; - break; - case GL_TEXTURE_BORDER_COLOR: - params[0] = sampObj->BorderColor.ui[0]; - params[1] = sampObj->BorderColor.ui[1]; - params[2] = sampObj->BorderColor.ui[2]; - params[3] = sampObj->BorderColor.ui[3]; - break; - case GL_TEXTURE_CUBE_MAP_SEAMLESS: - if (!ctx->Extensions.AMD_seamless_cubemap_per_texture) - goto invalid_pname; - *params = sampObj->CubeMapSeamless; - break; - default: - goto invalid_pname; - } - return; - -invalid_pname: - _mesa_error(ctx, GL_INVALID_ENUM, "glGetSamplerParameterIuiv(pname=%s)", - _mesa_lookup_enum_by_nr(pname)); -} - - -void -_mesa_init_sampler_object_functions(struct dd_function_table *driver) -{ - driver->NewSamplerObject = _mesa_new_sampler_object; - driver->DeleteSamplerObject = _mesa_delete_sampler_object; -} - - -void -_mesa_init_sampler_object_dispatch(struct _glapi_table *disp) -{ - SET_GenSamplers(disp, _mesa_GenSamplers); - SET_DeleteSamplers(disp, _mesa_DeleteSamplers); - SET_IsSampler(disp, _mesa_IsSampler); - SET_BindSampler(disp, _mesa_BindSampler); - SET_SamplerParameteri(disp, _mesa_SamplerParameteri); - SET_SamplerParameterf(disp, _mesa_SamplerParameterf); - SET_SamplerParameteriv(disp, _mesa_SamplerParameteriv); - SET_SamplerParameterfv(disp, _mesa_SamplerParameterfv); - SET_SamplerParameterIiv(disp, _mesa_SamplerParameterIiv); - SET_SamplerParameterIuiv(disp, _mesa_SamplerParameterIuiv); - SET_GetSamplerParameteriv(disp, _mesa_GetSamplerParameteriv); - SET_GetSamplerParameterfv(disp, _mesa_GetSamplerParameterfv); - SET_GetSamplerParameterIiv(disp, _mesa_GetSamplerParameterIiv); - SET_GetSamplerParameterIuiv(disp, _mesa_GetSamplerParameterIuiv); -} +/* + * Mesa 3-D graphics library + * + * Copyright (C) 2011 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 samplerobj.c + * \brief Functions for the GL_ARB_sampler_objects extension. + * \author Brian Paul + */ + + +#include "main/glheader.h" +#include "main/context.h" +#include "main/dispatch.h" +#include "main/enums.h" +#include "main/hash.h" +#include "main/macros.h" +#include "main/mfeatures.h" +#include "main/mtypes.h" +#include "main/samplerobj.h" + + +static struct gl_sampler_object * +_mesa_lookup_samplerobj(struct gl_context *ctx, GLuint name) +{ + if (name == 0) + return NULL; + else + return (struct gl_sampler_object *) + _mesa_HashLookup(ctx->Shared->SamplerObjects, name); +} + + +/** + * Handle reference counting. + */ +void +_mesa_reference_sampler_object(struct gl_context *ctx, + struct gl_sampler_object **ptr, + struct gl_sampler_object *samp) +{ + if (*ptr == samp) + return; + + if (*ptr) { + /* Unreference the old sampler */ + GLboolean deleteFlag = GL_FALSE; + struct gl_sampler_object *oldSamp = *ptr; + + /*_glthread_LOCK_MUTEX(oldSamp->Mutex);*/ + ASSERT(oldSamp->RefCount > 0); + oldSamp->RefCount--; +#if 0 + printf("SamplerObj %p %d DECR to %d\n", + (void *) oldSamp, oldSamp->Name, oldSamp->RefCount); +#endif + deleteFlag = (oldSamp->RefCount == 0); + /*_glthread_UNLOCK_MUTEX(oldSamp->Mutex);*/ + + if (deleteFlag) { + ASSERT(ctx->Driver.DeleteSamplerObject); + ctx->Driver.DeleteSamplerObject(ctx, oldSamp); + } + + *ptr = NULL; + } + ASSERT(!*ptr); + + if (samp) { + /* reference new sampler */ + /*_glthread_LOCK_MUTEX(samp->Mutex);*/ + if (samp->RefCount == 0) { + /* this sampler's being deleted (look just above) */ + /* Not sure this can every really happen. Warn if it does. */ + _mesa_problem(NULL, "referencing deleted sampler object"); + *ptr = NULL; + } + else { + samp->RefCount++; +#if 0 + printf("SamplerObj %p %d INCR to %d\n", + (void *) samp, samp->Name, samp->RefCount); +#endif + *ptr = samp; + } + /*_glthread_UNLOCK_MUTEX(samp->Mutex);*/ + } +} + + +/** + * Initialize the fields of the given sampler object. + */ +void +_mesa_init_sampler_object(struct gl_sampler_object *sampObj, GLuint name) +{ + sampObj->Name = name; + sampObj->RefCount = 1; + sampObj->WrapS = GL_REPEAT; + sampObj->WrapT = GL_REPEAT; + sampObj->WrapR = GL_REPEAT; + sampObj->MinFilter = GL_NEAREST_MIPMAP_LINEAR; + sampObj->MagFilter = GL_LINEAR; + sampObj->BorderColor.f[0] = 0.0; + sampObj->BorderColor.f[1] = 0.0; + sampObj->BorderColor.f[2] = 0.0; + sampObj->BorderColor.f[3] = 0.0; + sampObj->MinLod = -1000.0F; + sampObj->MaxLod = 1000.0F; + sampObj->LodBias = 0.0F; + sampObj->MaxAnisotropy = 1.0F; + sampObj->CompareMode = GL_NONE; + sampObj->CompareFunc = GL_LEQUAL; + sampObj->CompareFailValue = 0.0; + sampObj->sRGBDecode = GL_DECODE_EXT; + sampObj->CubeMapSeamless = GL_FALSE; + sampObj->DepthMode = 0; +} + + +/** + * Fallback for ctx->Driver.NewSamplerObject(); + */ +struct gl_sampler_object * +_mesa_new_sampler_object(struct gl_context *ctx, GLuint name) +{ + struct gl_sampler_object *sampObj = CALLOC_STRUCT(gl_sampler_object); + if (sampObj) { + _mesa_init_sampler_object(sampObj, name); + } + return sampObj; +} + + +/** + * Fallback for ctx->Driver.DeleteSamplerObject(); + */ +void +_mesa_delete_sampler_object(struct gl_context *ctx, + struct gl_sampler_object *sampObj) +{ + FREE(sampObj); +} + + +static void GLAPIENTRY +_mesa_GenSamplers(GLsizei count, GLuint *samplers) +{ + GET_CURRENT_CONTEXT(ctx); + GLuint first; + GLint i; + + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glGenSamplers(%d)\n", count); + + if (count < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glGenSamplers"); + return; + } + + if (!samplers) + return; + + first = _mesa_HashFindFreeKeyBlock(ctx->Shared->SamplerObjects, count); + + /* Insert the ID and pointer to new sampler object into hash table */ + for (i = 0; i < count; i++) { + struct gl_sampler_object *sampObj = + ctx->Driver.NewSamplerObject(ctx, first + i); + _mesa_HashInsert(ctx->Shared->SamplerObjects, first + i, sampObj); + samplers[i] = first + i; + } +} + + +static void GLAPIENTRY +_mesa_DeleteSamplers(GLsizei count, const GLuint *samplers) +{ + GET_CURRENT_CONTEXT(ctx); + GLsizei i; + + ASSERT_OUTSIDE_BEGIN_END(ctx); + FLUSH_VERTICES(ctx, 0); + + if (count < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glDeleteSamplers(count)"); + return; + } + + _glthread_LOCK_MUTEX(ctx->Shared->Mutex); + + for (i = 0; i < count; i++) { + if (samplers[i]) { + struct gl_sampler_object *sampObj = + _mesa_lookup_samplerobj(ctx, samplers[i]); + if (sampObj) { + /* The ID is immediately freed for re-use */ + _mesa_HashRemove(ctx->Shared->SamplerObjects, samplers[i]); + /* But the object exists until its reference count goes to zero */ + _mesa_reference_sampler_object(ctx, &sampObj, NULL); + } + } + } + + _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); +} + + +static GLboolean GLAPIENTRY +_mesa_IsSampler(GLuint sampler) +{ + struct gl_sampler_object *sampObj; + GET_CURRENT_CONTEXT(ctx); + + ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); + + if (sampler == 0) + return GL_FALSE; + + sampObj = _mesa_lookup_samplerobj(ctx, sampler); + + return sampObj != NULL; +} + + +static void GLAPIENTRY +_mesa_BindSampler(GLuint unit, GLuint sampler) +{ + struct gl_sampler_object *sampObj; + GET_CURRENT_CONTEXT(ctx); + + if (unit >= ctx->Const.MaxCombinedTextureImageUnits) { + _mesa_error(ctx, GL_INVALID_VALUE, "glBindSampler(unit %u)", unit); + return; + } + + if (sampler == 0) { + /* Use the default sampler object, the one contained in the texture + * object. + */ + sampObj = NULL; + } + else { + /* user-defined sampler object */ + sampObj = _mesa_lookup_samplerobj(ctx, sampler); + if (!sampObj) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glBindSampler(sampler)"); + return; + } + } + + if (ctx->Texture.Unit[unit].Sampler != sampObj) { + FLUSH_VERTICES(ctx, _NEW_TEXTURE); + } + + /* bind new sampler */ + _mesa_reference_sampler_object(ctx, &ctx->Texture.Unit[unit].Sampler, + sampObj); +} + + +/** + * Check if a coordinate wrap mode is legal. + * \return GL_TRUE if legal, GL_FALSE otherwise + */ +static GLboolean +validate_texture_wrap_mode(struct gl_context *ctx, GLenum wrap) +{ + const struct gl_extensions * const e = &ctx->Extensions; + + switch (wrap) { + case GL_CLAMP: + case GL_CLAMP_TO_EDGE: + case GL_REPEAT: + return GL_TRUE; + case GL_CLAMP_TO_BORDER: + return e->ARB_texture_border_clamp; + case GL_MIRRORED_REPEAT: + return e->ARB_texture_mirrored_repeat; + case GL_MIRROR_CLAMP_EXT: + return e->ATI_texture_mirror_once || e->EXT_texture_mirror_clamp; + case GL_MIRROR_CLAMP_TO_EDGE_EXT: + return e->ATI_texture_mirror_once || e->EXT_texture_mirror_clamp; + case GL_MIRROR_CLAMP_TO_BORDER_EXT: + return e->EXT_texture_mirror_clamp; + default: + return GL_FALSE; + } +} + + +/** + * This is called just prior to changing any sampler object state. + */ +static INLINE void +flush(struct gl_context *ctx) +{ + FLUSH_VERTICES(ctx, _NEW_TEXTURE); +} + + +#define INVALID_PARAM 0x100 +#define INVALID_PNAME 0x101 +#define INVALID_VALUE 0x102 + +static GLuint +set_sampler_wrap_s(struct gl_context *ctx, struct gl_sampler_object *samp, + GLint param) +{ + if (samp->WrapS == param) + return GL_FALSE; + if (validate_texture_wrap_mode(ctx, param)) { + flush(ctx); + samp->WrapS = param; + return GL_TRUE; + } + return INVALID_PARAM; +} + + +static GLuint +set_sampler_wrap_t(struct gl_context *ctx, struct gl_sampler_object *samp, + GLint param) +{ + if (samp->WrapT == param) + return GL_FALSE; + if (validate_texture_wrap_mode(ctx, param)) { + flush(ctx); + samp->WrapT = param; + return GL_TRUE; + } + return INVALID_PARAM; +} + + +static GLuint +set_sampler_wrap_r(struct gl_context *ctx, struct gl_sampler_object *samp, + GLint param) +{ + if (samp->WrapR == param) + return GL_FALSE; + if (validate_texture_wrap_mode(ctx, param)) { + flush(ctx); + samp->WrapR = param; + return GL_TRUE; + } + return INVALID_PARAM; +} + + +static GLuint +set_sampler_min_filter(struct gl_context *ctx, struct gl_sampler_object *samp, + GLint param) +{ + if (samp->MinFilter == param) + return GL_FALSE; + + switch (param) { + case GL_NEAREST: + case GL_LINEAR: + case GL_NEAREST_MIPMAP_NEAREST: + case GL_LINEAR_MIPMAP_NEAREST: + case GL_NEAREST_MIPMAP_LINEAR: + case GL_LINEAR_MIPMAP_LINEAR: + flush(ctx); + samp->MinFilter = param; + return GL_TRUE; + default: + return INVALID_PARAM; + } +} + + +static GLuint +set_sampler_mag_filter(struct gl_context *ctx, struct gl_sampler_object *samp, + GLint param) +{ + if (samp->MagFilter == param) + return GL_FALSE; + + switch (param) { + case GL_NEAREST: + case GL_LINEAR: + flush(ctx); + samp->MagFilter = param; + return GL_TRUE; + default: + return INVALID_PARAM; + } +} + + +static GLuint +set_sampler_lod_bias(struct gl_context *ctx, struct gl_sampler_object *samp, + GLfloat param) +{ + if (samp->LodBias == param) + return GL_FALSE; + + flush(ctx); + samp->LodBias = param; + return GL_TRUE; +} + + +static GLuint +set_sampler_border_colorf(struct gl_context *ctx, + struct gl_sampler_object *samp, + const GLfloat params[4]) +{ + flush(ctx); + samp->BorderColor.f[RCOMP] = params[0]; + samp->BorderColor.f[GCOMP] = params[1]; + samp->BorderColor.f[BCOMP] = params[2]; + samp->BorderColor.f[ACOMP] = params[3]; + return GL_TRUE; +} + + +static GLuint +set_sampler_border_colori(struct gl_context *ctx, + struct gl_sampler_object *samp, + const GLint params[4]) +{ + flush(ctx); + samp->BorderColor.i[RCOMP] = params[0]; + samp->BorderColor.i[GCOMP] = params[1]; + samp->BorderColor.i[BCOMP] = params[2]; + samp->BorderColor.i[ACOMP] = params[3]; + return GL_TRUE; +} + + +static GLuint +set_sampler_border_colorui(struct gl_context *ctx, + struct gl_sampler_object *samp, + const GLuint params[4]) +{ + flush(ctx); + samp->BorderColor.ui[RCOMP] = params[0]; + samp->BorderColor.ui[GCOMP] = params[1]; + samp->BorderColor.ui[BCOMP] = params[2]; + samp->BorderColor.ui[ACOMP] = params[3]; + return GL_TRUE; +} + + +static GLuint +set_sampler_min_lod(struct gl_context *ctx, struct gl_sampler_object *samp, + GLfloat param) +{ + if (samp->MinLod == param) + return GL_FALSE; + + flush(ctx); + samp->MinLod = param; + return GL_TRUE; +} + + +static GLuint +set_sampler_max_lod(struct gl_context *ctx, struct gl_sampler_object *samp, + GLfloat param) +{ + if (samp->MaxLod == param) + return GL_FALSE; + + flush(ctx); + samp->MaxLod = param; + return GL_TRUE; +} + + +static GLuint +set_sampler_compare_mode(struct gl_context *ctx, + struct gl_sampler_object *samp, GLint param) +{ + if (!ctx->Extensions.ARB_shadow) + return INVALID_PNAME; + + if (samp->CompareMode == param) + return GL_FALSE; + + if (param == GL_NONE || + param == GL_COMPARE_R_TO_TEXTURE_ARB) { + flush(ctx); + samp->CompareMode = param; + return GL_TRUE; + } + + return INVALID_PARAM; +} + + +static GLuint +set_sampler_compare_func(struct gl_context *ctx, + struct gl_sampler_object *samp, GLint param) +{ + if (!ctx->Extensions.ARB_shadow) + return INVALID_PNAME; + + if (samp->CompareFunc == param) + return GL_FALSE; + + switch (param) { + case GL_LEQUAL: + case GL_GEQUAL: + flush(ctx); + samp->CompareFunc = param; + return GL_TRUE; + case GL_EQUAL: + case GL_NOTEQUAL: + case GL_LESS: + case GL_GREATER: + case GL_ALWAYS: + case GL_NEVER: + if (ctx->Extensions.EXT_shadow_funcs) { + flush(ctx); + samp->CompareFunc = param; + return GL_TRUE; + } + /* fall-through */ + default: + return INVALID_PARAM; + } +} + + +static GLuint +set_sampler_max_anisotropy(struct gl_context *ctx, + struct gl_sampler_object *samp, GLfloat param) +{ + if (!ctx->Extensions.EXT_texture_filter_anisotropic) + return INVALID_PNAME; + + if (samp->MaxAnisotropy == param) + return GL_FALSE; + + if (param < 1.0) + return INVALID_VALUE; + + flush(ctx); + /* clamp to max, that's what NVIDIA does */ + samp->MaxAnisotropy = MIN2(param, ctx->Const.MaxTextureMaxAnisotropy); + return GL_TRUE; +} + + +static GLuint +set_sampler_cube_map_seamless(struct gl_context *ctx, + struct gl_sampler_object *samp, GLboolean param) +{ + if (!ctx->Extensions.AMD_seamless_cubemap_per_texture) + return INVALID_PNAME; + + if (samp->CubeMapSeamless == param) + return GL_FALSE; + + if (param != GL_TRUE && param != GL_FALSE) + return INVALID_VALUE; + + flush(ctx); + samp->CubeMapSeamless = param; + return GL_TRUE; +} + + +static void GLAPIENTRY +_mesa_SamplerParameteri(GLuint sampler, GLenum pname, GLint param) +{ + struct gl_sampler_object *sampObj; + GLuint res; + GET_CURRENT_CONTEXT(ctx); + + sampObj = _mesa_lookup_samplerobj(ctx, sampler); + if (!sampObj) { + _mesa_error(ctx, GL_INVALID_VALUE, "glSamplerParameteri(sampler %u)", + sampler); + return; + } + + switch (pname) { + case GL_TEXTURE_WRAP_S: + res = set_sampler_wrap_s(ctx, sampObj, param); + break; + case GL_TEXTURE_WRAP_T: + res = set_sampler_wrap_t(ctx, sampObj, param); + break; + case GL_TEXTURE_WRAP_R: + res = set_sampler_wrap_r(ctx, sampObj, param); + break; + case GL_TEXTURE_MIN_FILTER: + res = set_sampler_min_filter(ctx, sampObj, param); + break; + case GL_TEXTURE_MAG_FILTER: + res = set_sampler_mag_filter(ctx, sampObj, param); + break; + case GL_TEXTURE_MIN_LOD: + res = set_sampler_min_lod(ctx, sampObj, (GLfloat) param); + break; + case GL_TEXTURE_MAX_LOD: + res = set_sampler_max_lod(ctx, sampObj, (GLfloat) param); + break; + case GL_TEXTURE_LOD_BIAS: + res = set_sampler_lod_bias(ctx, sampObj, (GLfloat) param); + break; + case GL_TEXTURE_COMPARE_MODE: + res = set_sampler_compare_mode(ctx, sampObj, param); + break; + case GL_TEXTURE_COMPARE_FUNC: + res = set_sampler_compare_func(ctx, sampObj, param); + break; + case GL_TEXTURE_MAX_ANISOTROPY_EXT: + res = set_sampler_max_anisotropy(ctx, sampObj, (GLfloat) param); + break; + case GL_TEXTURE_CUBE_MAP_SEAMLESS: + res = set_sampler_cube_map_seamless(ctx, sampObj, param); + break; + case GL_TEXTURE_BORDER_COLOR: + /* fall-through */ + default: + res = INVALID_PNAME; + } + + switch (res) { + case GL_FALSE: + /* no change */ + break; + case GL_TRUE: + /* state change - we do nothing special at this time */ + break; + case INVALID_PNAME: + _mesa_error(ctx, GL_INVALID_ENUM, "glSamplerParameteri(pname=%s)\n", + _mesa_lookup_enum_by_nr(pname)); + break; + case INVALID_PARAM: + _mesa_error(ctx, GL_INVALID_ENUM, "glSamplerParameteri(param=%d)\n", + param); + break; + case INVALID_VALUE: + _mesa_error(ctx, GL_INVALID_VALUE, "glSamplerParameteri(param=%d)\n", + param); + break; + default: + ; + } +} + + +static void GLAPIENTRY +_mesa_SamplerParameterf(GLuint sampler, GLenum pname, GLfloat param) +{ + struct gl_sampler_object *sampObj; + GLuint res; + GET_CURRENT_CONTEXT(ctx); + + ASSERT_OUTSIDE_BEGIN_END(ctx); + + sampObj = _mesa_lookup_samplerobj(ctx, sampler); + if (!sampObj) { + _mesa_error(ctx, GL_INVALID_VALUE, "glSamplerParameterf(sampler %u)", + sampler); + return; + } + + switch (pname) { + case GL_TEXTURE_WRAP_S: + res = set_sampler_wrap_s(ctx, sampObj, (GLint) param); + break; + case GL_TEXTURE_WRAP_T: + res = set_sampler_wrap_t(ctx, sampObj, (GLint) param); + break; + case GL_TEXTURE_WRAP_R: + res = set_sampler_wrap_r(ctx, sampObj, (GLint) param); + break; + case GL_TEXTURE_MIN_FILTER: + res = set_sampler_min_filter(ctx, sampObj, (GLint) param); + break; + case GL_TEXTURE_MAG_FILTER: + res = set_sampler_mag_filter(ctx, sampObj, (GLint) param); + break; + case GL_TEXTURE_MIN_LOD: + res = set_sampler_min_lod(ctx, sampObj, param); + break; + case GL_TEXTURE_MAX_LOD: + res = set_sampler_max_lod(ctx, sampObj, param); + break; + case GL_TEXTURE_LOD_BIAS: + res = set_sampler_lod_bias(ctx, sampObj, param); + break; + case GL_TEXTURE_COMPARE_MODE: + res = set_sampler_compare_mode(ctx, sampObj, (GLint) param); + break; + case GL_TEXTURE_COMPARE_FUNC: + res = set_sampler_compare_func(ctx, sampObj, (GLint) param); + break; + case GL_TEXTURE_MAX_ANISOTROPY_EXT: + res = set_sampler_max_anisotropy(ctx, sampObj, param); + break; + case GL_TEXTURE_CUBE_MAP_SEAMLESS: + res = set_sampler_cube_map_seamless(ctx, sampObj, (GLboolean) param); + break; + case GL_TEXTURE_BORDER_COLOR: + /* fall-through */ + default: + res = INVALID_PNAME; + } + + switch (res) { + case GL_FALSE: + /* no change */ + break; + case GL_TRUE: + /* state change - we do nothing special at this time */ + break; + case INVALID_PNAME: + _mesa_error(ctx, GL_INVALID_ENUM, "glSamplerParameterf(pname=%s)\n", + _mesa_lookup_enum_by_nr(pname)); + break; + case INVALID_PARAM: + _mesa_error(ctx, GL_INVALID_ENUM, "glSamplerParameterf(param=%f)\n", + param); + break; + case INVALID_VALUE: + _mesa_error(ctx, GL_INVALID_VALUE, "glSamplerParameterf(param=%f)\n", + param); + break; + default: + ; + } +} + +static void GLAPIENTRY +_mesa_SamplerParameteriv(GLuint sampler, GLenum pname, const GLint *params) +{ + struct gl_sampler_object *sampObj; + GLuint res; + GET_CURRENT_CONTEXT(ctx); + + sampObj = _mesa_lookup_samplerobj(ctx, sampler); + if (!sampObj) { + _mesa_error(ctx, GL_INVALID_VALUE, "glSamplerParameteriv(sampler %u)", + sampler); + return; + } + + switch (pname) { + case GL_TEXTURE_WRAP_S: + res = set_sampler_wrap_s(ctx, sampObj, params[0]); + break; + case GL_TEXTURE_WRAP_T: + res = set_sampler_wrap_t(ctx, sampObj, params[0]); + break; + case GL_TEXTURE_WRAP_R: + res = set_sampler_wrap_r(ctx, sampObj, params[0]); + break; + case GL_TEXTURE_MIN_FILTER: + res = set_sampler_min_filter(ctx, sampObj, params[0]); + break; + case GL_TEXTURE_MAG_FILTER: + res = set_sampler_mag_filter(ctx, sampObj, params[0]); + break; + case GL_TEXTURE_MIN_LOD: + res = set_sampler_min_lod(ctx, sampObj, (GLfloat) params[0]); + break; + case GL_TEXTURE_MAX_LOD: + res = set_sampler_max_lod(ctx, sampObj, (GLfloat) params[0]); + break; + case GL_TEXTURE_LOD_BIAS: + res = set_sampler_lod_bias(ctx, sampObj, (GLfloat) params[0]); + break; + case GL_TEXTURE_COMPARE_MODE: + res = set_sampler_compare_mode(ctx, sampObj, params[0]); + break; + case GL_TEXTURE_COMPARE_FUNC: + res = set_sampler_compare_func(ctx, sampObj, params[0]); + break; + case GL_TEXTURE_MAX_ANISOTROPY_EXT: + res = set_sampler_max_anisotropy(ctx, sampObj, (GLfloat) params[0]); + break; + case GL_TEXTURE_CUBE_MAP_SEAMLESS: + res = set_sampler_cube_map_seamless(ctx, sampObj, params[0]); + break; + case GL_TEXTURE_BORDER_COLOR: + { + GLfloat c[4]; + c[0] = INT_TO_FLOAT(params[0]); + c[1] = INT_TO_FLOAT(params[1]); + c[2] = INT_TO_FLOAT(params[2]); + c[3] = INT_TO_FLOAT(params[3]); + res = set_sampler_border_colorf(ctx, sampObj, c); + } + break; + default: + res = INVALID_PNAME; + } + + switch (res) { + case GL_FALSE: + /* no change */ + break; + case GL_TRUE: + /* state change - we do nothing special at this time */ + break; + case INVALID_PNAME: + _mesa_error(ctx, GL_INVALID_ENUM, "glSamplerParameteriv(pname=%s)\n", + _mesa_lookup_enum_by_nr(pname)); + break; + case INVALID_PARAM: + _mesa_error(ctx, GL_INVALID_ENUM, "glSamplerParameteriv(param=%d)\n", + params[0]); + break; + case INVALID_VALUE: + _mesa_error(ctx, GL_INVALID_VALUE, "glSamplerParameteriv(param=%d)\n", + params[0]); + break; + default: + ; + } +} + +static void GLAPIENTRY +_mesa_SamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat *params) +{ + struct gl_sampler_object *sampObj; + GLuint res; + GET_CURRENT_CONTEXT(ctx); + + ASSERT_OUTSIDE_BEGIN_END(ctx); + + sampObj = _mesa_lookup_samplerobj(ctx, sampler); + if (!sampObj) { + _mesa_error(ctx, GL_INVALID_VALUE, "glSamplerParameterfv(sampler %u)", + sampler); + return; + } + + switch (pname) { + case GL_TEXTURE_WRAP_S: + res = set_sampler_wrap_s(ctx, sampObj, (GLint) params[0]); + break; + case GL_TEXTURE_WRAP_T: + res = set_sampler_wrap_t(ctx, sampObj, (GLint) params[0]); + break; + case GL_TEXTURE_WRAP_R: + res = set_sampler_wrap_r(ctx, sampObj, (GLint) params[0]); + break; + case GL_TEXTURE_MIN_FILTER: + res = set_sampler_min_filter(ctx, sampObj, (GLint) params[0]); + break; + case GL_TEXTURE_MAG_FILTER: + res = set_sampler_mag_filter(ctx, sampObj, (GLint) params[0]); + break; + case GL_TEXTURE_MIN_LOD: + res = set_sampler_min_lod(ctx, sampObj, params[0]); + break; + case GL_TEXTURE_MAX_LOD: + res = set_sampler_max_lod(ctx, sampObj, params[0]); + break; + case GL_TEXTURE_LOD_BIAS: + res = set_sampler_lod_bias(ctx, sampObj, params[0]); + break; + case GL_TEXTURE_COMPARE_MODE: + res = set_sampler_compare_mode(ctx, sampObj, (GLint) params[0]); + break; + case GL_TEXTURE_COMPARE_FUNC: + res = set_sampler_compare_func(ctx, sampObj, (GLint) params[0]); + break; + case GL_TEXTURE_MAX_ANISOTROPY_EXT: + res = set_sampler_max_anisotropy(ctx, sampObj, params[0]); + break; + case GL_TEXTURE_CUBE_MAP_SEAMLESS: + res = set_sampler_cube_map_seamless(ctx, sampObj, (GLboolean) params[0]); + break; + case GL_TEXTURE_BORDER_COLOR: + res = set_sampler_border_colorf(ctx, sampObj, params); + break; + default: + res = INVALID_PNAME; + } + + switch (res) { + case GL_FALSE: + /* no change */ + break; + case GL_TRUE: + /* state change - we do nothing special at this time */ + break; + case INVALID_PNAME: + _mesa_error(ctx, GL_INVALID_ENUM, "glSamplerParameterfv(pname=%s)\n", + _mesa_lookup_enum_by_nr(pname)); + break; + case INVALID_PARAM: + _mesa_error(ctx, GL_INVALID_ENUM, "glSamplerParameterfv(param=%f)\n", + params[0]); + break; + case INVALID_VALUE: + _mesa_error(ctx, GL_INVALID_VALUE, "glSamplerParameterfv(param=%f)\n", + params[0]); + break; + default: + ; + } +} + +static void GLAPIENTRY +_mesa_SamplerParameterIiv(GLuint sampler, GLenum pname, const GLint *params) +{ + struct gl_sampler_object *sampObj; + GLuint res; + GET_CURRENT_CONTEXT(ctx); + + sampObj = _mesa_lookup_samplerobj(ctx, sampler); + if (!sampObj) { + _mesa_error(ctx, GL_INVALID_VALUE, "glSamplerParameterIiv(sampler %u)", + sampler); + return; + } + + switch (pname) { + case GL_TEXTURE_WRAP_S: + res = set_sampler_wrap_s(ctx, sampObj, params[0]); + break; + case GL_TEXTURE_WRAP_T: + res = set_sampler_wrap_t(ctx, sampObj, params[0]); + break; + case GL_TEXTURE_WRAP_R: + res = set_sampler_wrap_r(ctx, sampObj, params[0]); + break; + case GL_TEXTURE_MIN_FILTER: + res = set_sampler_min_filter(ctx, sampObj, params[0]); + break; + case GL_TEXTURE_MAG_FILTER: + res = set_sampler_mag_filter(ctx, sampObj, params[0]); + break; + case GL_TEXTURE_MIN_LOD: + res = set_sampler_min_lod(ctx, sampObj, (GLfloat) params[0]); + break; + case GL_TEXTURE_MAX_LOD: + res = set_sampler_max_lod(ctx, sampObj, (GLfloat) params[0]); + break; + case GL_TEXTURE_LOD_BIAS: + res = set_sampler_lod_bias(ctx, sampObj, (GLfloat) params[0]); + break; + case GL_TEXTURE_COMPARE_MODE: + res = set_sampler_compare_mode(ctx, sampObj, params[0]); + break; + case GL_TEXTURE_COMPARE_FUNC: + res = set_sampler_compare_func(ctx, sampObj, params[0]); + break; + case GL_TEXTURE_MAX_ANISOTROPY_EXT: + res = set_sampler_max_anisotropy(ctx, sampObj, (GLfloat) params[0]); + break; + case GL_TEXTURE_CUBE_MAP_SEAMLESS: + res = set_sampler_cube_map_seamless(ctx, sampObj, params[0]); + break; + case GL_TEXTURE_BORDER_COLOR: + res = set_sampler_border_colori(ctx, sampObj, params); + break; + default: + res = INVALID_PNAME; + } + + switch (res) { + case GL_FALSE: + /* no change */ + break; + case GL_TRUE: + /* state change - we do nothing special at this time */ + break; + case INVALID_PNAME: + _mesa_error(ctx, GL_INVALID_ENUM, "glSamplerParameterIiv(pname=%s)\n", + _mesa_lookup_enum_by_nr(pname)); + break; + case INVALID_PARAM: + _mesa_error(ctx, GL_INVALID_ENUM, "glSamplerParameterIiv(param=%d)\n", + params[0]); + break; + case INVALID_VALUE: + _mesa_error(ctx, GL_INVALID_VALUE, "glSamplerParameterIiv(param=%d)\n", + params[0]); + break; + default: + ; + } +} + + +static void GLAPIENTRY +_mesa_SamplerParameterIuiv(GLuint sampler, GLenum pname, const GLuint *params) +{ + struct gl_sampler_object *sampObj; + GLuint res; + GET_CURRENT_CONTEXT(ctx); + + sampObj = _mesa_lookup_samplerobj(ctx, sampler); + if (!sampObj) { + _mesa_error(ctx, GL_INVALID_VALUE, "glSamplerParameterIuiv(sampler %u)", + sampler); + return; + } + + switch (pname) { + case GL_TEXTURE_WRAP_S: + res = set_sampler_wrap_s(ctx, sampObj, params[0]); + break; + case GL_TEXTURE_WRAP_T: + res = set_sampler_wrap_t(ctx, sampObj, params[0]); + break; + case GL_TEXTURE_WRAP_R: + res = set_sampler_wrap_r(ctx, sampObj, params[0]); + break; + case GL_TEXTURE_MIN_FILTER: + res = set_sampler_min_filter(ctx, sampObj, params[0]); + break; + case GL_TEXTURE_MAG_FILTER: + res = set_sampler_mag_filter(ctx, sampObj, params[0]); + break; + case GL_TEXTURE_MIN_LOD: + res = set_sampler_min_lod(ctx, sampObj, (GLfloat) params[0]); + break; + case GL_TEXTURE_MAX_LOD: + res = set_sampler_max_lod(ctx, sampObj, (GLfloat) params[0]); + break; + case GL_TEXTURE_LOD_BIAS: + res = set_sampler_lod_bias(ctx, sampObj, (GLfloat) params[0]); + break; + case GL_TEXTURE_COMPARE_MODE: + res = set_sampler_compare_mode(ctx, sampObj, params[0]); + break; + case GL_TEXTURE_COMPARE_FUNC: + res = set_sampler_compare_func(ctx, sampObj, params[0]); + break; + case GL_TEXTURE_MAX_ANISOTROPY_EXT: + res = set_sampler_max_anisotropy(ctx, sampObj, (GLfloat) params[0]); + break; + case GL_TEXTURE_CUBE_MAP_SEAMLESS: + res = set_sampler_cube_map_seamless(ctx, sampObj, params[0]); + break; + case GL_TEXTURE_BORDER_COLOR: + res = set_sampler_border_colorui(ctx, sampObj, params); + break; + default: + res = INVALID_PNAME; + } + + switch (res) { + case GL_FALSE: + /* no change */ + break; + case GL_TRUE: + /* state change - we do nothing special at this time */ + break; + case INVALID_PNAME: + _mesa_error(ctx, GL_INVALID_ENUM, "glSamplerParameterIuiv(pname=%s)\n", + _mesa_lookup_enum_by_nr(pname)); + break; + case INVALID_PARAM: + _mesa_error(ctx, GL_INVALID_ENUM, "glSamplerParameterIuiv(param=%u)\n", + params[0]); + break; + case INVALID_VALUE: + _mesa_error(ctx, GL_INVALID_VALUE, "glSamplerParameterIuiv(param=%u)\n", + params[0]); + break; + default: + ; + } +} + + +static void GLAPIENTRY +_mesa_GetSamplerParameteriv(GLuint sampler, GLenum pname, GLint *params) +{ + struct gl_sampler_object *sampObj; + GET_CURRENT_CONTEXT(ctx); + + sampObj = _mesa_lookup_samplerobj(ctx, sampler); + if (!sampObj) { + _mesa_error(ctx, GL_INVALID_VALUE, "glGetSamplerParameteriv(sampler %u)", + sampler); + return; + } + + switch (pname) { + case GL_TEXTURE_WRAP_S: + *params = sampObj->WrapS; + break; + case GL_TEXTURE_WRAP_T: + *params = sampObj->WrapT; + break; + case GL_TEXTURE_WRAP_R: + *params = sampObj->WrapR; + break; + case GL_TEXTURE_MIN_FILTER: + *params = sampObj->MinFilter; + break; + case GL_TEXTURE_MAG_FILTER: + *params = sampObj->MagFilter; + break; + case GL_TEXTURE_MIN_LOD: + *params = (GLint) sampObj->MinLod; + break; + case GL_TEXTURE_MAX_LOD: + *params = (GLint) sampObj->MaxLod; + break; + case GL_TEXTURE_LOD_BIAS: + *params = (GLint) sampObj->LodBias; + break; + case GL_TEXTURE_COMPARE_MODE: + if (!ctx->Extensions.ARB_shadow) + goto invalid_pname; + *params = sampObj->CompareMode; + break; + case GL_TEXTURE_COMPARE_FUNC: + if (!ctx->Extensions.ARB_shadow) + goto invalid_pname; + *params = sampObj->CompareFunc; + break; + case GL_TEXTURE_MAX_ANISOTROPY_EXT: + *params = (GLint) sampObj->MaxAnisotropy; + break; + case GL_TEXTURE_BORDER_COLOR: + params[0] = FLOAT_TO_INT(sampObj->BorderColor.f[0]); + params[1] = FLOAT_TO_INT(sampObj->BorderColor.f[1]); + params[2] = FLOAT_TO_INT(sampObj->BorderColor.f[2]); + params[3] = FLOAT_TO_INT(sampObj->BorderColor.f[3]); + break; + case GL_TEXTURE_CUBE_MAP_SEAMLESS: + if (!ctx->Extensions.AMD_seamless_cubemap_per_texture) + goto invalid_pname; + *params = sampObj->CubeMapSeamless; + break; + default: + goto invalid_pname; + } + return; + +invalid_pname: + _mesa_error(ctx, GL_INVALID_ENUM, "glGetSamplerParameteriv(pname=%s)", + _mesa_lookup_enum_by_nr(pname)); +} + + +static void GLAPIENTRY +_mesa_GetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat *params) +{ + struct gl_sampler_object *sampObj; + GET_CURRENT_CONTEXT(ctx); + + sampObj = _mesa_lookup_samplerobj(ctx, sampler); + if (!sampObj) { + _mesa_error(ctx, GL_INVALID_VALUE, "glGetSamplerParameterfv(sampler %u)", + sampler); + return; + } + + switch (pname) { + case GL_TEXTURE_WRAP_S: + *params = (GLfloat) sampObj->WrapS; + break; + case GL_TEXTURE_WRAP_T: + *params = (GLfloat) sampObj->WrapT; + break; + case GL_TEXTURE_WRAP_R: + *params = (GLfloat) sampObj->WrapR; + break; + case GL_TEXTURE_MIN_FILTER: + *params = (GLfloat) sampObj->MinFilter; + break; + case GL_TEXTURE_MAG_FILTER: + *params = (GLfloat) sampObj->MagFilter; + break; + case GL_TEXTURE_MIN_LOD: + *params = sampObj->MinLod; + break; + case GL_TEXTURE_MAX_LOD: + *params = sampObj->MaxLod; + break; + case GL_TEXTURE_LOD_BIAS: + *params = sampObj->LodBias; + break; + case GL_TEXTURE_COMPARE_MODE: + if (!ctx->Extensions.ARB_shadow) + goto invalid_pname; + *params = (GLfloat) sampObj->CompareMode; + break; + case GL_TEXTURE_COMPARE_FUNC: + if (!ctx->Extensions.ARB_shadow) + goto invalid_pname; + *params = (GLfloat) sampObj->CompareFunc; + break; + case GL_TEXTURE_MAX_ANISOTROPY_EXT: + *params = sampObj->MaxAnisotropy; + break; + case GL_TEXTURE_BORDER_COLOR: + params[0] = sampObj->BorderColor.f[0]; + params[1] = sampObj->BorderColor.f[1]; + params[2] = sampObj->BorderColor.f[2]; + params[3] = sampObj->BorderColor.f[3]; + break; + case GL_TEXTURE_CUBE_MAP_SEAMLESS: + if (!ctx->Extensions.AMD_seamless_cubemap_per_texture) + goto invalid_pname; + *params = (GLfloat) sampObj->CubeMapSeamless; + break; + default: + goto invalid_pname; + } + return; + +invalid_pname: + _mesa_error(ctx, GL_INVALID_ENUM, "glGetSamplerParameterfv(pname=%s)", + _mesa_lookup_enum_by_nr(pname)); +} + + +static void GLAPIENTRY +_mesa_GetSamplerParameterIiv(GLuint sampler, GLenum pname, GLint *params) +{ + struct gl_sampler_object *sampObj; + GET_CURRENT_CONTEXT(ctx); + + sampObj = _mesa_lookup_samplerobj(ctx, sampler); + if (!sampObj) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glGetSamplerParameterIiv(sampler %u)", + sampler); + return; + } + + switch (pname) { + case GL_TEXTURE_WRAP_S: + *params = sampObj->WrapS; + break; + case GL_TEXTURE_WRAP_T: + *params = sampObj->WrapT; + break; + case GL_TEXTURE_WRAP_R: + *params = sampObj->WrapR; + break; + case GL_TEXTURE_MIN_FILTER: + *params = sampObj->MinFilter; + break; + case GL_TEXTURE_MAG_FILTER: + *params = sampObj->MagFilter; + break; + case GL_TEXTURE_MIN_LOD: + *params = (GLint) sampObj->MinLod; + break; + case GL_TEXTURE_MAX_LOD: + *params = (GLint) sampObj->MaxLod; + break; + case GL_TEXTURE_LOD_BIAS: + *params = (GLint) sampObj->LodBias; + break; + case GL_TEXTURE_COMPARE_MODE: + if (!ctx->Extensions.ARB_shadow) + goto invalid_pname; + *params = sampObj->CompareMode; + break; + case GL_TEXTURE_COMPARE_FUNC: + if (!ctx->Extensions.ARB_shadow) + goto invalid_pname; + *params = sampObj->CompareFunc; + break; + case GL_TEXTURE_MAX_ANISOTROPY_EXT: + *params = (GLint) sampObj->MaxAnisotropy; + break; + case GL_TEXTURE_BORDER_COLOR: + params[0] = sampObj->BorderColor.i[0]; + params[1] = sampObj->BorderColor.i[1]; + params[2] = sampObj->BorderColor.i[2]; + params[3] = sampObj->BorderColor.i[3]; + break; + case GL_TEXTURE_CUBE_MAP_SEAMLESS: + if (!ctx->Extensions.AMD_seamless_cubemap_per_texture) + goto invalid_pname; + *params = sampObj->CubeMapSeamless; + break; + default: + goto invalid_pname; + } + return; + +invalid_pname: + _mesa_error(ctx, GL_INVALID_ENUM, "glGetSamplerParameterIiv(pname=%s)", + _mesa_lookup_enum_by_nr(pname)); +} + + +static void GLAPIENTRY +_mesa_GetSamplerParameterIuiv(GLuint sampler, GLenum pname, GLuint *params) +{ + struct gl_sampler_object *sampObj; + GET_CURRENT_CONTEXT(ctx); + + sampObj = _mesa_lookup_samplerobj(ctx, sampler); + if (!sampObj) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glGetSamplerParameterIuiv(sampler %u)", + sampler); + return; + } + + switch (pname) { + case GL_TEXTURE_WRAP_S: + *params = sampObj->WrapS; + break; + case GL_TEXTURE_WRAP_T: + *params = sampObj->WrapT; + break; + case GL_TEXTURE_WRAP_R: + *params = sampObj->WrapR; + break; + case GL_TEXTURE_MIN_FILTER: + *params = sampObj->MinFilter; + break; + case GL_TEXTURE_MAG_FILTER: + *params = sampObj->MagFilter; + break; + case GL_TEXTURE_MIN_LOD: + *params = (GLuint) sampObj->MinLod; + break; + case GL_TEXTURE_MAX_LOD: + *params = (GLuint) sampObj->MaxLod; + break; + case GL_TEXTURE_LOD_BIAS: + *params = (GLuint) sampObj->LodBias; + break; + case GL_TEXTURE_COMPARE_MODE: + if (!ctx->Extensions.ARB_shadow) + goto invalid_pname; + *params = sampObj->CompareMode; + break; + case GL_TEXTURE_COMPARE_FUNC: + if (!ctx->Extensions.ARB_shadow) + goto invalid_pname; + *params = sampObj->CompareFunc; + break; + case GL_TEXTURE_MAX_ANISOTROPY_EXT: + *params = (GLuint) sampObj->MaxAnisotropy; + break; + case GL_TEXTURE_BORDER_COLOR: + params[0] = sampObj->BorderColor.ui[0]; + params[1] = sampObj->BorderColor.ui[1]; + params[2] = sampObj->BorderColor.ui[2]; + params[3] = sampObj->BorderColor.ui[3]; + break; + case GL_TEXTURE_CUBE_MAP_SEAMLESS: + if (!ctx->Extensions.AMD_seamless_cubemap_per_texture) + goto invalid_pname; + *params = sampObj->CubeMapSeamless; + break; + default: + goto invalid_pname; + } + return; + +invalid_pname: + _mesa_error(ctx, GL_INVALID_ENUM, "glGetSamplerParameterIuiv(pname=%s)", + _mesa_lookup_enum_by_nr(pname)); +} + + +void +_mesa_init_sampler_object_functions(struct dd_function_table *driver) +{ + driver->NewSamplerObject = _mesa_new_sampler_object; + driver->DeleteSamplerObject = _mesa_delete_sampler_object; +} + + +void +_mesa_init_sampler_object_dispatch(struct _glapi_table *disp) +{ + SET_GenSamplers(disp, _mesa_GenSamplers); + SET_DeleteSamplers(disp, _mesa_DeleteSamplers); + SET_IsSampler(disp, _mesa_IsSampler); + SET_BindSampler(disp, _mesa_BindSampler); + SET_SamplerParameteri(disp, _mesa_SamplerParameteri); + SET_SamplerParameterf(disp, _mesa_SamplerParameterf); + SET_SamplerParameteriv(disp, _mesa_SamplerParameteriv); + SET_SamplerParameterfv(disp, _mesa_SamplerParameterfv); + SET_SamplerParameterIiv(disp, _mesa_SamplerParameterIiv); + SET_SamplerParameterIuiv(disp, _mesa_SamplerParameterIuiv); + SET_GetSamplerParameteriv(disp, _mesa_GetSamplerParameteriv); + SET_GetSamplerParameterfv(disp, _mesa_GetSamplerParameterfv); + SET_GetSamplerParameterIiv(disp, _mesa_GetSamplerParameterIiv); + SET_GetSamplerParameterIuiv(disp, _mesa_GetSamplerParameterIuiv); +} diff --git a/mesalib/src/mesa/main/samplerobj.h b/mesalib/src/mesa/main/samplerobj.h index 4245594d6..a839010b7 100644 --- a/mesalib/src/mesa/main/samplerobj.h +++ b/mesalib/src/mesa/main/samplerobj.h @@ -1,62 +1,62 @@ -/* - * Mesa 3-D graphics library - * - * Copyright (C) 2011 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. - */ - - - -#ifndef SAMPLEROBJ_H -#define SAMPLEROBJ_H - -struct dd_function_table; - -static INLINE struct gl_sampler_object * -_mesa_get_samplerobj(struct gl_context *ctx, GLuint unit) -{ - if (ctx->Texture.Unit[unit].Sampler) - return ctx->Texture.Unit[unit].Sampler; - else - return &ctx->Texture.Unit[unit]._Current->Sampler; -} - -extern void -_mesa_reference_sampler_object(struct gl_context *ctx, - struct gl_sampler_object **ptr, - struct gl_sampler_object *samp); - -extern void -_mesa_init_sampler_object(struct gl_sampler_object *sampObj, GLuint name); - -extern struct gl_sampler_object * -_mesa_new_sampler_object(struct gl_context *ctx, GLuint name); - -extern void -_mesa_delete_sampler_object(struct gl_context *ctx, - struct gl_sampler_object *sampObj); - -extern void -_mesa_init_sampler_object_functions(struct dd_function_table *driver); - -extern void -_mesa_init_sampler_object_dispatch(struct _glapi_table *disp); - - -#endif /* SAMPLEROBJ_H */ +/* + * Mesa 3-D graphics library + * + * Copyright (C) 2011 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. + */ + + + +#ifndef SAMPLEROBJ_H +#define SAMPLEROBJ_H + +struct dd_function_table; + +static INLINE struct gl_sampler_object * +_mesa_get_samplerobj(struct gl_context *ctx, GLuint unit) +{ + if (ctx->Texture.Unit[unit].Sampler) + return ctx->Texture.Unit[unit].Sampler; + else + return &ctx->Texture.Unit[unit]._Current->Sampler; +} + +extern void +_mesa_reference_sampler_object(struct gl_context *ctx, + struct gl_sampler_object **ptr, + struct gl_sampler_object *samp); + +extern void +_mesa_init_sampler_object(struct gl_sampler_object *sampObj, GLuint name); + +extern struct gl_sampler_object * +_mesa_new_sampler_object(struct gl_context *ctx, GLuint name); + +extern void +_mesa_delete_sampler_object(struct gl_context *ctx, + struct gl_sampler_object *sampObj); + +extern void +_mesa_init_sampler_object_functions(struct dd_function_table *driver); + +extern void +_mesa_init_sampler_object_dispatch(struct _glapi_table *disp); + + +#endif /* SAMPLEROBJ_H */ diff --git a/mesalib/src/mesa/main/shaderapi.c b/mesalib/src/mesa/main/shaderapi.c index 501627ce3..74997eaaa 100644 --- a/mesalib/src/mesa/main/shaderapi.c +++ b/mesalib/src/mesa/main/shaderapi.c @@ -1,1948 +1,1948 @@ -/* - * Mesa 3-D graphics library - * - * Copyright (C) 2004-2008 Brian Paul All Rights Reserved. - * Copyright (C) 2009-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 - * 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 shaderapi.c - * \author Brian Paul - * - * Implementation of GLSL-related API functions. - * The glUniform* functions are in uniforms.c - * - * - * XXX things to do: - * 1. Check that the right error code is generated for all _mesa_error() calls. - * 2. Insert FLUSH_VERTICES calls in various places - */ - - -#include "main/glheader.h" -#include "main/context.h" -#include "main/dispatch.h" -#include "main/enums.h" -#include "main/hash.h" -#include "main/mfeatures.h" -#include "main/mtypes.h" -#include "main/shaderapi.h" -#include "main/shaderobj.h" -#include "program/program.h" -#include "program/prog_parameter.h" -#include "program/prog_uniform.h" -#include "ralloc.h" -#include -#include "../glsl/glsl_parser_extras.h" - -/** Define this to enable shader substitution (see below) */ -#define SHADER_SUBST 0 - - -/** - * Return mask of GLSL_x flags by examining the MESA_GLSL env var. - */ -static GLbitfield -get_shader_flags(void) -{ - GLbitfield flags = 0x0; - const char *env = _mesa_getenv("MESA_GLSL"); - - if (env) { - if (strstr(env, "dump")) - flags |= GLSL_DUMP; - if (strstr(env, "log")) - flags |= GLSL_LOG; - if (strstr(env, "nopvert")) - flags |= GLSL_NOP_VERT; - if (strstr(env, "nopfrag")) - flags |= GLSL_NOP_FRAG; - if (strstr(env, "nopt")) - flags |= GLSL_NO_OPT; - else if (strstr(env, "opt")) - flags |= GLSL_OPT; - if (strstr(env, "uniform")) - flags |= GLSL_UNIFORMS; - if (strstr(env, "useprog")) - flags |= GLSL_USE_PROG; - } - - return flags; -} - - -/** - * Initialize context's shader state. - */ -void -_mesa_init_shader_state(struct gl_context *ctx) -{ - /* Device drivers may override these to control what kind of instructions - * are generated by the GLSL compiler. - */ - struct gl_shader_compiler_options options; - gl_shader_type sh; - - memset(&options, 0, sizeof(options)); - options.MaxUnrollIterations = 32; - - /* Default pragma settings */ - options.DefaultPragmas.Optimize = GL_TRUE; - - for (sh = 0; sh < MESA_SHADER_TYPES; ++sh) - memcpy(&ctx->ShaderCompilerOptions[sh], &options, sizeof(options)); - - ctx->Shader.Flags = get_shader_flags(); -} - - -/** - * Free the per-context shader-related state. - */ -void -_mesa_free_shader_state(struct gl_context *ctx) -{ - _mesa_reference_shader_program(ctx, &ctx->Shader.CurrentVertexProgram, NULL); - _mesa_reference_shader_program(ctx, &ctx->Shader.CurrentGeometryProgram, - NULL); - _mesa_reference_shader_program(ctx, &ctx->Shader.CurrentFragmentProgram, - NULL); - _mesa_reference_shader_program(ctx, &ctx->Shader.ActiveProgram, NULL); -} - - -/** - * Return the size of the given GLSL datatype, in floats (components). - */ -GLint -_mesa_sizeof_glsl_type(GLenum type) -{ - switch (type) { - case GL_FLOAT: - case GL_INT: - case GL_BOOL: - case GL_SAMPLER_1D: - case GL_SAMPLER_2D: - case GL_SAMPLER_3D: - case GL_SAMPLER_CUBE: - case GL_SAMPLER_1D_SHADOW: - case GL_SAMPLER_2D_SHADOW: - case GL_SAMPLER_2D_RECT_ARB: - case GL_SAMPLER_2D_RECT_SHADOW_ARB: - case GL_SAMPLER_1D_ARRAY_EXT: - case GL_SAMPLER_2D_ARRAY_EXT: - case GL_SAMPLER_1D_ARRAY_SHADOW_EXT: - case GL_SAMPLER_2D_ARRAY_SHADOW_EXT: - case GL_SAMPLER_CUBE_SHADOW_EXT: - return 1; - case GL_FLOAT_VEC2: - case GL_INT_VEC2: - case GL_UNSIGNED_INT_VEC2: - case GL_BOOL_VEC2: - return 2; - case GL_FLOAT_VEC3: - case GL_INT_VEC3: - case GL_UNSIGNED_INT_VEC3: - case GL_BOOL_VEC3: - return 3; - case GL_FLOAT_VEC4: - case GL_INT_VEC4: - case GL_UNSIGNED_INT_VEC4: - case GL_BOOL_VEC4: - return 4; - case GL_FLOAT_MAT2: - case GL_FLOAT_MAT2x3: - case GL_FLOAT_MAT2x4: - return 8; /* two float[4] vectors */ - case GL_FLOAT_MAT3: - case GL_FLOAT_MAT3x2: - case GL_FLOAT_MAT3x4: - return 12; /* three float[4] vectors */ - case GL_FLOAT_MAT4: - case GL_FLOAT_MAT4x2: - case GL_FLOAT_MAT4x3: - return 16; /* four float[4] vectors */ - default: - _mesa_problem(NULL, "Invalid type in _mesa_sizeof_glsl_type()"); - return 1; - } -} - - -/** - * Copy string from to , up to maxLength characters, returning - * length of in . - * \param src the strings source - * \param maxLength max chars to copy - * \param length returns number of chars copied - * \param dst the string destination - */ -void -_mesa_copy_string(GLchar *dst, GLsizei maxLength, - GLsizei *length, const GLchar *src) -{ - GLsizei len; - for (len = 0; len < maxLength - 1 && src && src[len]; len++) - dst[len] = src[len]; - if (maxLength > 0) - dst[len] = 0; - if (length) - *length = len; -} - - - -/** - * Confirm that the a shader type is valid and supported by the implementation - * - * \param ctx Current GL context - * \param type Shader target - * - */ -static bool -validate_shader_target(const struct gl_context *ctx, GLenum type) -{ - switch (type) { -#if FEATURE_ARB_fragment_shader - case GL_FRAGMENT_SHADER: - return ctx->Extensions.ARB_fragment_shader; -#endif -#if FEATURE_ARB_vertex_shader - case GL_VERTEX_SHADER: - return ctx->Extensions.ARB_vertex_shader; -#endif -#if FEATURE_ARB_geometry_shader4 - case GL_GEOMETRY_SHADER_ARB: - return ctx->Extensions.ARB_geometry_shader4; -#endif - default: - return false; - } -} - - -/** - * Find the length of the longest transform feedback varying name - * which was specified with glTransformFeedbackVaryings(). - */ -static GLint -longest_feedback_varying_name(const struct gl_shader_program *shProg) -{ - GLuint i; - GLint max = 0; - for (i = 0; i < shProg->TransformFeedback.NumVarying; i++) { - GLint len = strlen(shProg->TransformFeedback.VaryingNames[i]); - if (len > max) - max = len; - } - return max; -} - - - -static GLboolean -is_program(struct gl_context *ctx, GLuint name) -{ - struct gl_shader_program *shProg = _mesa_lookup_shader_program(ctx, name); - return shProg ? GL_TRUE : GL_FALSE; -} - - -static GLboolean -is_shader(struct gl_context *ctx, GLuint name) -{ - struct gl_shader *shader = _mesa_lookup_shader(ctx, name); - return shader ? GL_TRUE : GL_FALSE; -} - - -/** - * Attach shader to a shader program. - */ -static void -attach_shader(struct gl_context *ctx, GLuint program, GLuint shader) -{ - struct gl_shader_program *shProg; - struct gl_shader *sh; - GLuint i, n; - - shProg = _mesa_lookup_shader_program_err(ctx, program, "glAttachShader"); - if (!shProg) - return; - - sh = _mesa_lookup_shader_err(ctx, shader, "glAttachShader"); - if (!sh) { - return; - } - - n = shProg->NumShaders; - for (i = 0; i < n; i++) { - if (shProg->Shaders[i] == sh) { - /* The shader is already attched to this program. The - * GL_ARB_shader_objects spec says: - * - * "The error INVALID_OPERATION is generated by AttachObjectARB - * if is already attached to ." - */ - _mesa_error(ctx, GL_INVALID_OPERATION, "glAttachShader"); - return; - } - } - - /* grow list */ - shProg->Shaders = (struct gl_shader **) - _mesa_realloc(shProg->Shaders, - n * sizeof(struct gl_shader *), - (n + 1) * sizeof(struct gl_shader *)); - if (!shProg->Shaders) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glAttachShader"); - return; - } - - /* append */ - shProg->Shaders[n] = NULL; /* since realloc() didn't zero the new space */ - _mesa_reference_shader(ctx, &shProg->Shaders[n], sh); - shProg->NumShaders++; -} - - -static GLint -get_attrib_location(struct gl_context *ctx, GLuint program, const GLchar *name) -{ - struct gl_shader_program *shProg - = _mesa_lookup_shader_program_err(ctx, program, "glGetAttribLocation"); - - if (!shProg) { - return -1; - } - - if (!shProg->LinkStatus) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetAttribLocation(program not linked)"); - return -1; - } - - if (!name) - return -1; - - if (shProg->VertexProgram) { - const struct gl_program_parameter_list *attribs = - shProg->VertexProgram->Base.Attributes; - if (attribs) { - GLint i = _mesa_lookup_parameter_index(attribs, -1, name); - if (i >= 0) { - return attribs->Parameters[i].StateIndexes[0]; - } - } - } - return -1; -} - - -static void -bind_attrib_location(struct gl_context *ctx, GLuint program, GLuint index, - const GLchar *name) -{ - struct gl_shader_program *shProg; - const GLint size = -1; /* unknown size */ - GLint i; - GLenum datatype = GL_FLOAT_VEC4; - - shProg = _mesa_lookup_shader_program_err(ctx, program, - "glBindAttribLocation"); - if (!shProg) { - return; - } - - if (!name) - return; - - if (strncmp(name, "gl_", 3) == 0) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glBindAttribLocation(illegal name)"); - return; - } - - if (index >= ctx->Const.VertexProgram.MaxAttribs) { - _mesa_error(ctx, GL_INVALID_VALUE, "glBindAttribLocation(index)"); - return; - } - - /* this will replace the current value if it's already in the list */ - i = _mesa_add_attribute(shProg->Attributes, name, size, datatype, index); - if (i < 0) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindAttribLocation"); - return; - } - - /* - * Note that this attribute binding won't go into effect until - * glLinkProgram is called again. - */ -} - - -static void -bind_frag_data_location(struct gl_context *ctx, GLuint program, - GLuint colorNumber, const GLchar *name) -{ - _mesa_problem(ctx, "bind_frag_data_location() not implemented yet"); -} - - -static GLuint -create_shader(struct gl_context *ctx, GLenum type) -{ - struct gl_shader *sh; - GLuint name; - - if (!validate_shader_target(ctx, type)) { - _mesa_error(ctx, GL_INVALID_ENUM, "CreateShader(type)"); - return 0; - } - - name = _mesa_HashFindFreeKeyBlock(ctx->Shared->ShaderObjects, 1); - sh = ctx->Driver.NewShader(ctx, name, type); - _mesa_HashInsert(ctx->Shared->ShaderObjects, name, sh); - - return name; -} - - -static GLuint -create_shader_program(struct gl_context *ctx) -{ - GLuint name; - struct gl_shader_program *shProg; - - name = _mesa_HashFindFreeKeyBlock(ctx->Shared->ShaderObjects, 1); - - shProg = ctx->Driver.NewShaderProgram(ctx, name); - - _mesa_HashInsert(ctx->Shared->ShaderObjects, name, shProg); - - assert(shProg->RefCount == 1); - - return name; -} - - -/** - * Named w/ "2" to indicate OpenGL 2.x vs GL_ARB_fragment_programs's - * DeleteProgramARB. - */ -static void -delete_shader_program(struct gl_context *ctx, GLuint name) -{ - /* - * NOTE: deleting shaders/programs works a bit differently than - * texture objects (and buffer objects, etc). Shader/program - * handles/IDs exist in the hash table until the object is really - * deleted (refcount==0). With texture objects, the handle/ID is - * removed from the hash table in glDeleteTextures() while the tex - * object itself might linger until its refcount goes to zero. - */ - struct gl_shader_program *shProg; - - shProg = _mesa_lookup_shader_program_err(ctx, name, "glDeleteProgram"); - if (!shProg) - return; - - shProg->DeletePending = GL_TRUE; - - /* effectively, decr shProg's refcount */ - _mesa_reference_shader_program(ctx, &shProg, NULL); -} - - -static void -delete_shader(struct gl_context *ctx, GLuint shader) -{ - struct gl_shader *sh; - - sh = _mesa_lookup_shader_err(ctx, shader, "glDeleteShader"); - if (!sh) - return; - - sh->DeletePending = GL_TRUE; - - /* effectively, decr sh's refcount */ - _mesa_reference_shader(ctx, &sh, NULL); -} - - -static void -detach_shader(struct gl_context *ctx, GLuint program, GLuint shader) -{ - struct gl_shader_program *shProg; - GLuint n; - GLuint i, j; - - shProg = _mesa_lookup_shader_program_err(ctx, program, "glDetachShader"); - if (!shProg) - return; - - n = shProg->NumShaders; - - for (i = 0; i < n; i++) { - if (shProg->Shaders[i]->Name == shader) { - /* found it */ - struct gl_shader **newList; - - /* release */ - _mesa_reference_shader(ctx, &shProg->Shaders[i], NULL); - - /* alloc new, smaller array */ - newList = (struct gl_shader **) - malloc((n - 1) * sizeof(struct gl_shader *)); - if (!newList) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glDetachShader"); - return; - } - for (j = 0; j < i; j++) { - newList[j] = shProg->Shaders[j]; - } - while (++i < n) - newList[j++] = shProg->Shaders[i]; - free(shProg->Shaders); - - shProg->Shaders = newList; - shProg->NumShaders = n - 1; - -#ifdef DEBUG - /* sanity check */ - { - for (j = 0; j < shProg->NumShaders; j++) { - assert(shProg->Shaders[j]->Type == GL_VERTEX_SHADER || - shProg->Shaders[j]->Type == GL_FRAGMENT_SHADER); - assert(shProg->Shaders[j]->RefCount > 0); - } - } -#endif - - return; - } - } - - /* not found */ - { - GLenum err; - if (is_shader(ctx, shader)) - err = GL_INVALID_OPERATION; - else if (is_program(ctx, shader)) - err = GL_INVALID_OPERATION; - else - err = GL_INVALID_VALUE; - _mesa_error(ctx, err, "glDetachProgram(shader)"); - return; - } -} - - -static void -get_active_attrib(struct gl_context *ctx, GLuint program, GLuint index, - GLsizei maxLength, GLsizei *length, GLint *size, - GLenum *type, GLchar *nameOut) -{ - const struct gl_program_parameter_list *attribs = NULL; - struct gl_shader_program *shProg; - - shProg = _mesa_lookup_shader_program_err(ctx, program, "glGetActiveAttrib"); - if (!shProg) - return; - - if (shProg->VertexProgram) - attribs = shProg->VertexProgram->Base.Attributes; - - if (!attribs || index >= attribs->NumParameters) { - _mesa_error(ctx, GL_INVALID_VALUE, "glGetActiveAttrib(index)"); - return; - } - - _mesa_copy_string(nameOut, maxLength, length, - attribs->Parameters[index].Name); - - if (size) - *size = attribs->Parameters[index].Size - / _mesa_sizeof_glsl_type(attribs->Parameters[index].DataType); - - if (type) - *type = attribs->Parameters[index].DataType; -} - - -/** - * Return list of shaders attached to shader program. - */ -static void -get_attached_shaders(struct gl_context *ctx, GLuint program, GLsizei maxCount, - GLsizei *count, GLuint *obj) -{ - struct gl_shader_program *shProg = - _mesa_lookup_shader_program_err(ctx, program, "glGetAttachedShaders"); - if (shProg) { - GLuint i; - for (i = 0; i < (GLuint) maxCount && i < shProg->NumShaders; i++) { - obj[i] = shProg->Shaders[i]->Name; - } - if (count) - *count = i; - } -} - - -static GLint -get_frag_data_location(struct gl_context *ctx, GLuint program, - const GLchar *name) -{ - _mesa_problem(ctx, "get_frag_data_location() not implemented yet"); - return -1; -} - - - -/** - * glGetHandleARB() - return ID/name of currently bound shader program. - */ -static GLuint -get_handle(struct gl_context *ctx, GLenum pname) -{ - if (pname == GL_PROGRAM_OBJECT_ARB) { - if (ctx->Shader.ActiveProgram) - return ctx->Shader.ActiveProgram->Name; - else - return 0; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetHandleARB"); - return 0; - } -} - - -/** - * glGetProgramiv() - get shader program state. - * Note that this is for GLSL shader programs, not ARB vertex/fragment - * programs (see glGetProgramivARB). - */ -static void -get_programiv(struct gl_context *ctx, GLuint program, GLenum pname, GLint *params) -{ - const struct gl_program_parameter_list *attribs; - struct gl_shader_program *shProg - = _mesa_lookup_shader_program(ctx, program); - - if (!shProg) { - _mesa_error(ctx, GL_INVALID_VALUE, "glGetProgramiv(program)"); - return; - } - - if (shProg->VertexProgram) - attribs = shProg->VertexProgram->Base.Attributes; - else - attribs = NULL; - - switch (pname) { - case GL_DELETE_STATUS: - *params = shProg->DeletePending; - break; - case GL_LINK_STATUS: - *params = shProg->LinkStatus; - break; - case GL_VALIDATE_STATUS: - *params = shProg->Validated; - break; - case GL_INFO_LOG_LENGTH: - *params = shProg->InfoLog ? strlen(shProg->InfoLog) + 1 : 0; - break; - case GL_ATTACHED_SHADERS: - *params = shProg->NumShaders; - break; - case GL_ACTIVE_ATTRIBUTES: - *params = attribs ? attribs->NumParameters : 0; - break; - case GL_ACTIVE_ATTRIBUTE_MAX_LENGTH: - *params = _mesa_longest_parameter_name(attribs, PROGRAM_INPUT) + 1; - break; - case GL_ACTIVE_UNIFORMS: - *params = shProg->Uniforms ? shProg->Uniforms->NumUniforms : 0; - break; - case GL_ACTIVE_UNIFORM_MAX_LENGTH: - *params = _mesa_longest_uniform_name(shProg->Uniforms); - if (*params > 0) - (*params)++; /* add one for terminating zero */ - break; - case GL_PROGRAM_BINARY_LENGTH_OES: - *params = 0; - break; -#if FEATURE_EXT_transform_feedback - case GL_TRANSFORM_FEEDBACK_VARYINGS: - *params = shProg->TransformFeedback.NumVarying; - break; - case GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH: - *params = longest_feedback_varying_name(shProg) + 1; - break; - case GL_TRANSFORM_FEEDBACK_BUFFER_MODE: - *params = shProg->TransformFeedback.BufferMode; - break; -#endif -#if FEATURE_ARB_geometry_shader4 - case GL_GEOMETRY_VERTICES_OUT_ARB: - *params = shProg->Geom.VerticesOut; - break; - case GL_GEOMETRY_INPUT_TYPE_ARB: - *params = shProg->Geom.InputType; - break; - case GL_GEOMETRY_OUTPUT_TYPE_ARB: - *params = shProg->Geom.OutputType; - break; -#endif - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramiv(pname)"); - return; - } -} - - -/** - * glGetShaderiv() - get GLSL shader state - */ -static void -get_shaderiv(struct gl_context *ctx, GLuint name, GLenum pname, GLint *params) -{ - struct gl_shader *shader = - _mesa_lookup_shader_err(ctx, name, "glGetShaderiv"); - - if (!shader) { - return; - } - - switch (pname) { - case GL_SHADER_TYPE: - *params = shader->Type; - break; - case GL_DELETE_STATUS: - *params = shader->DeletePending; - break; - case GL_COMPILE_STATUS: - *params = shader->CompileStatus; - break; - case GL_INFO_LOG_LENGTH: - *params = shader->InfoLog ? strlen(shader->InfoLog) + 1 : 0; - break; - case GL_SHADER_SOURCE_LENGTH: - *params = shader->Source ? strlen((char *) shader->Source) + 1 : 0; - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glGetShaderiv(pname)"); - return; - } -} - - -static void -get_program_info_log(struct gl_context *ctx, GLuint program, GLsizei bufSize, - GLsizei *length, GLchar *infoLog) -{ - struct gl_shader_program *shProg - = _mesa_lookup_shader_program(ctx, program); - if (!shProg) { - _mesa_error(ctx, GL_INVALID_VALUE, "glGetProgramInfoLog(program)"); - return; - } - _mesa_copy_string(infoLog, bufSize, length, shProg->InfoLog); -} - - -static void -get_shader_info_log(struct gl_context *ctx, GLuint shader, GLsizei bufSize, - GLsizei *length, GLchar *infoLog) -{ - struct gl_shader *sh = _mesa_lookup_shader(ctx, shader); - if (!sh) { - _mesa_error(ctx, GL_INVALID_VALUE, "glGetShaderInfoLog(shader)"); - return; - } - _mesa_copy_string(infoLog, bufSize, length, sh->InfoLog); -} - - -/** - * Return shader source code. - */ -static void -get_shader_source(struct gl_context *ctx, GLuint shader, GLsizei maxLength, - GLsizei *length, GLchar *sourceOut) -{ - struct gl_shader *sh; - sh = _mesa_lookup_shader_err(ctx, shader, "glGetShaderSource"); - if (!sh) { - return; - } - _mesa_copy_string(sourceOut, maxLength, length, sh->Source); -} - - -/** - * Set/replace shader source code. - */ -static void -shader_source(struct gl_context *ctx, GLuint shader, const GLchar *source) -{ - struct gl_shader *sh; - - sh = _mesa_lookup_shader_err(ctx, shader, "glShaderSource"); - if (!sh) - return; - - /* free old shader source string and install new one */ - if (sh->Source) { - free((void *) sh->Source); - } - sh->Source = source; - sh->CompileStatus = GL_FALSE; -#ifdef DEBUG - sh->SourceChecksum = _mesa_str_checksum(sh->Source); -#endif -} - - -/** - * Compile a shader. - */ -static void -compile_shader(struct gl_context *ctx, GLuint shaderObj) -{ - struct gl_shader *sh; - struct gl_shader_compiler_options *options; - - sh = _mesa_lookup_shader_err(ctx, shaderObj, "glCompileShader"); - if (!sh) - return; - - options = &ctx->ShaderCompilerOptions[_mesa_shader_type_to_index(sh->Type)]; - - /* set default pragma state for shader */ - sh->Pragmas = options->DefaultPragmas; - - /* this call will set the sh->CompileStatus field to indicate if - * compilation was successful. - */ - _mesa_glsl_compile_shader(ctx, sh); -} - - -/** - * Link a program's shaders. - */ -static void -link_program(struct gl_context *ctx, GLuint program) -{ - struct gl_shader_program *shProg; - struct gl_transform_feedback_object *obj = - ctx->TransformFeedback.CurrentObject; - - shProg = _mesa_lookup_shader_program_err(ctx, program, "glLinkProgram"); - if (!shProg) - return; - - if (obj->Active - && (shProg == ctx->Shader.CurrentVertexProgram - || shProg == ctx->Shader.CurrentGeometryProgram - || shProg == ctx->Shader.CurrentFragmentProgram)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glLinkProgram(transform feedback active"); - return; - } - - FLUSH_VERTICES(ctx, _NEW_PROGRAM); - - _mesa_glsl_link_shader(ctx, shProg); - - /* debug code */ - if (0) { - GLuint i; - - printf("Link %u shaders in program %u: %s\n", - shProg->NumShaders, shProg->Name, - shProg->LinkStatus ? "Success" : "Failed"); - - for (i = 0; i < shProg->NumShaders; i++) { - printf(" shader %u, type 0x%x\n", - shProg->Shaders[i]->Name, - shProg->Shaders[i]->Type); - } - } -} - - -/** - * Print basic shader info (for debug). - */ -static void -print_shader_info(const struct gl_shader_program *shProg) -{ - GLuint i; - - printf("Mesa: glUseProgram(%u)\n", shProg->Name); - for (i = 0; i < shProg->NumShaders; i++) { - const char *s; - switch (shProg->Shaders[i]->Type) { - case GL_VERTEX_SHADER: - s = "vertex"; - break; - case GL_FRAGMENT_SHADER: - s = "fragment"; - break; - case GL_GEOMETRY_SHADER: - s = "geometry"; - break; - default: - s = ""; - } - printf(" %s shader %u, checksum %u\n", s, - shProg->Shaders[i]->Name, - shProg->Shaders[i]->SourceChecksum); - } - if (shProg->VertexProgram) - printf(" vert prog %u\n", shProg->VertexProgram->Base.Id); - if (shProg->FragmentProgram) - printf(" frag prog %u\n", shProg->FragmentProgram->Base.Id); - if (shProg->GeometryProgram) - printf(" geom prog %u\n", shProg->GeometryProgram->Base.Id); -} - - -/** - * Use the named shader program for subsequent glUniform calls - */ -void -_mesa_active_program(struct gl_context *ctx, struct gl_shader_program *shProg, - const char *caller) -{ - if ((shProg != NULL) && !shProg->LinkStatus) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "%s(program %u not linked)", caller, shProg->Name); - return; - } - - if (ctx->Shader.ActiveProgram != shProg) { - _mesa_reference_shader_program(ctx, &ctx->Shader.ActiveProgram, shProg); - } -} - -/** - */ -static bool -use_shader_program(struct gl_context *ctx, GLenum type, - struct gl_shader_program *shProg) -{ - struct gl_shader_program **target; - - switch (type) { -#if FEATURE_ARB_vertex_shader - case GL_VERTEX_SHADER: - target = &ctx->Shader.CurrentVertexProgram; - if ((shProg == NULL) - || (shProg->_LinkedShaders[MESA_SHADER_VERTEX] == NULL)) { - shProg = NULL; - } - break; -#endif -#if FEATURE_ARB_geometry_shader4 - case GL_GEOMETRY_SHADER_ARB: - target = &ctx->Shader.CurrentGeometryProgram; - if ((shProg == NULL) - || (shProg->_LinkedShaders[MESA_SHADER_GEOMETRY] == NULL)) { - shProg = NULL; - } - break; -#endif -#if FEATURE_ARB_fragment_shader - case GL_FRAGMENT_SHADER: - target = &ctx->Shader.CurrentFragmentProgram; - if ((shProg == NULL) - || (shProg->_LinkedShaders[MESA_SHADER_FRAGMENT] == NULL)) { - shProg = NULL; - } - break; -#endif - default: - return false; - } - - if (*target != shProg) { - FLUSH_VERTICES(ctx, _NEW_PROGRAM | _NEW_PROGRAM_CONSTANTS); - _mesa_reference_shader_program(ctx, target, shProg); - return true; - } - - return false; -} - -/** - * Use the named shader program for subsequent rendering. - */ -void -_mesa_use_program(struct gl_context *ctx, struct gl_shader_program *shProg) -{ - use_shader_program(ctx, GL_VERTEX_SHADER, shProg); - use_shader_program(ctx, GL_GEOMETRY_SHADER_ARB, shProg); - use_shader_program(ctx, GL_FRAGMENT_SHADER, shProg); - _mesa_active_program(ctx, shProg, "glUseProgram"); - - if (ctx->Driver.UseProgram) - ctx->Driver.UseProgram(ctx, shProg); -} - - -/** - * Validate a program's samplers. - * Specifically, check that there aren't two samplers of different types - * pointing to the same texture unit. - * \return GL_TRUE if valid, GL_FALSE if invalid - */ -static GLboolean -validate_samplers(const struct gl_program *prog, char *errMsg) -{ - static const char *targetName[] = { - "TEXTURE_BUFFER", - "TEXTURE_2D_ARRAY", - "TEXTURE_1D_ARRAY", - "TEXTURE_CUBE", - "TEXTURE_3D", - "TEXTURE_RECT", - "TEXTURE_2D", - "TEXTURE_1D", - }; - GLint targetUsed[MAX_COMBINED_TEXTURE_IMAGE_UNITS]; - GLbitfield samplersUsed = prog->SamplersUsed; - GLuint i; - - assert(Elements(targetName) == NUM_TEXTURE_TARGETS); - - if (samplersUsed == 0x0) - return GL_TRUE; - - for (i = 0; i < Elements(targetUsed); i++) - targetUsed[i] = -1; - - /* walk over bits which are set in 'samplers' */ - while (samplersUsed) { - GLuint unit; - gl_texture_index target; - GLint sampler = _mesa_ffs(samplersUsed) - 1; - assert(sampler >= 0); - assert(sampler < Elements(prog->SamplerUnits)); - unit = prog->SamplerUnits[sampler]; - target = prog->SamplerTargets[sampler]; - if (targetUsed[unit] != -1 && targetUsed[unit] != (int) target) { - _mesa_snprintf(errMsg, 100, - "Texture unit %d is accessed both as %s and %s", - unit, targetName[targetUsed[unit]], targetName[target]); - return GL_FALSE; - } - targetUsed[unit] = target; - samplersUsed ^= (1 << sampler); - } - - return GL_TRUE; -} - - -/** - * Do validation of the given shader program. - * \param errMsg returns error message if validation fails. - * \return GL_TRUE if valid, GL_FALSE if invalid (and set errMsg) - */ -static GLboolean -validate_shader_program(const struct gl_shader_program *shProg, - char *errMsg) -{ - const struct gl_vertex_program *vp = shProg->VertexProgram; - const struct gl_geometry_program *gp = shProg->GeometryProgram; - const struct gl_fragment_program *fp = shProg->FragmentProgram; - - if (!shProg->LinkStatus) { - return GL_FALSE; - } - - /* From the GL spec, a program is invalid if any of these are true: - - any two active samplers in the current program object are of - different types, but refer to the same texture image unit, - - any active sampler in the current program object refers to a texture - image unit where fixed-function fragment processing accesses a - texture target that does not match the sampler type, or - - the sum of the number of active samplers in the program and the - number of texture image units enabled for fixed-function fragment - processing exceeds the combined limit on the total number of texture - image units allowed. - */ - - - /* - * Check: any two active samplers in the current program object are of - * different types, but refer to the same texture image unit, - */ - if (vp && !validate_samplers(&vp->Base, errMsg)) { - return GL_FALSE; - } - if (gp && !validate_samplers(&gp->Base, errMsg)) { - return GL_FALSE; - } - if (fp && !validate_samplers(&fp->Base, errMsg)) { - return GL_FALSE; - } - - return GL_TRUE; -} - - -/** - * Called via glValidateProgram() - */ -static void -validate_program(struct gl_context *ctx, GLuint program) -{ - struct gl_shader_program *shProg; - char errMsg[100] = ""; - - shProg = _mesa_lookup_shader_program_err(ctx, program, "glValidateProgram"); - if (!shProg) { - return; - } - - shProg->Validated = validate_shader_program(shProg, errMsg); - if (!shProg->Validated) { - /* update info log */ - if (shProg->InfoLog) { - ralloc_free(shProg->InfoLog); - } - shProg->InfoLog = ralloc_strdup(shProg, errMsg); - } -} - - - -void GLAPIENTRY -_mesa_AttachObjectARB(GLhandleARB program, GLhandleARB shader) -{ - GET_CURRENT_CONTEXT(ctx); - attach_shader(ctx, program, shader); -} - - -void GLAPIENTRY -_mesa_AttachShader(GLuint program, GLuint shader) -{ - GET_CURRENT_CONTEXT(ctx); - attach_shader(ctx, program, shader); -} - - -void GLAPIENTRY -_mesa_BindAttribLocationARB(GLhandleARB program, GLuint index, - const GLcharARB *name) -{ - GET_CURRENT_CONTEXT(ctx); - bind_attrib_location(ctx, program, index, name); -} - - -/* GL_EXT_gpu_shader4, GL3 */ -void GLAPIENTRY -_mesa_BindFragDataLocation(GLuint program, GLuint colorNumber, - const GLchar *name) -{ - GET_CURRENT_CONTEXT(ctx); - bind_frag_data_location(ctx, program, colorNumber, name); -} - - -void GLAPIENTRY -_mesa_CompileShaderARB(GLhandleARB shaderObj) -{ - GET_CURRENT_CONTEXT(ctx); - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glCompileShader %u\n", shaderObj); - compile_shader(ctx, shaderObj); -} - - -GLuint GLAPIENTRY -_mesa_CreateShader(GLenum type) -{ - GET_CURRENT_CONTEXT(ctx); - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glCreateShader %s\n", _mesa_lookup_enum_by_nr(type)); - return create_shader(ctx, type); -} - - -GLhandleARB GLAPIENTRY -_mesa_CreateShaderObjectARB(GLenum type) -{ - GET_CURRENT_CONTEXT(ctx); - return create_shader(ctx, type); -} - - -GLuint GLAPIENTRY -_mesa_CreateProgram(void) -{ - GET_CURRENT_CONTEXT(ctx); - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glCreateProgram\n"); - return create_shader_program(ctx); -} - - -GLhandleARB GLAPIENTRY -_mesa_CreateProgramObjectARB(void) -{ - GET_CURRENT_CONTEXT(ctx); - return create_shader_program(ctx); -} - - -void GLAPIENTRY -_mesa_DeleteObjectARB(GLhandleARB obj) -{ - if (MESA_VERBOSE & VERBOSE_API) { - GET_CURRENT_CONTEXT(ctx); - _mesa_debug(ctx, "glDeleteObjectARB(%u)\n", obj); - } - - if (obj) { - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - if (is_program(ctx, obj)) { - delete_shader_program(ctx, obj); - } - else if (is_shader(ctx, obj)) { - delete_shader(ctx, obj); - } - else { - /* error? */ - } - } -} - - -void GLAPIENTRY -_mesa_DeleteProgram(GLuint name) -{ - if (name) { - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - delete_shader_program(ctx, name); - } -} - - -void GLAPIENTRY -_mesa_DeleteShader(GLuint name) -{ - if (name) { - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - delete_shader(ctx, name); - } -} - - -void GLAPIENTRY -_mesa_DetachObjectARB(GLhandleARB program, GLhandleARB shader) -{ - GET_CURRENT_CONTEXT(ctx); - detach_shader(ctx, program, shader); -} - - -void GLAPIENTRY -_mesa_DetachShader(GLuint program, GLuint shader) -{ - GET_CURRENT_CONTEXT(ctx); - detach_shader(ctx, program, shader); -} - - -void GLAPIENTRY -_mesa_GetActiveAttribARB(GLhandleARB program, GLuint index, - GLsizei maxLength, GLsizei * length, GLint * size, - GLenum * type, GLcharARB * name) -{ - GET_CURRENT_CONTEXT(ctx); - get_active_attrib(ctx, program, index, maxLength, length, size, type, name); -} - - -void GLAPIENTRY -_mesa_GetAttachedObjectsARB(GLhandleARB container, GLsizei maxCount, - GLsizei * count, GLhandleARB * obj) -{ - GET_CURRENT_CONTEXT(ctx); - get_attached_shaders(ctx, container, maxCount, count, obj); -} - - -void GLAPIENTRY -_mesa_GetAttachedShaders(GLuint program, GLsizei maxCount, - GLsizei *count, GLuint *obj) -{ - GET_CURRENT_CONTEXT(ctx); - get_attached_shaders(ctx, program, maxCount, count, obj); -} - - -GLint GLAPIENTRY -_mesa_GetAttribLocationARB(GLhandleARB program, const GLcharARB * name) -{ - GET_CURRENT_CONTEXT(ctx); - return get_attrib_location(ctx, program, name); -} - - -/* GL_EXT_gpu_shader4, GL3 */ -GLint GLAPIENTRY -_mesa_GetFragDataLocation(GLuint program, const GLchar *name) -{ - GET_CURRENT_CONTEXT(ctx); - return get_frag_data_location(ctx, program, name); -} - - - -void GLAPIENTRY -_mesa_GetInfoLogARB(GLhandleARB object, GLsizei maxLength, GLsizei * length, - GLcharARB * infoLog) -{ - GET_CURRENT_CONTEXT(ctx); - if (is_program(ctx, object)) { - get_program_info_log(ctx, object, maxLength, length, infoLog); - } - else if (is_shader(ctx, object)) { - get_shader_info_log(ctx, object, maxLength, length, infoLog); - } - else { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetInfoLogARB"); - } -} - - -void GLAPIENTRY -_mesa_GetObjectParameterivARB(GLhandleARB object, GLenum pname, GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - /* Implement in terms of GetProgramiv, GetShaderiv */ - if (is_program(ctx, object)) { - if (pname == GL_OBJECT_TYPE_ARB) { - *params = GL_PROGRAM_OBJECT_ARB; - } - else { - get_programiv(ctx, object, pname, params); - } - } - else if (is_shader(ctx, object)) { - if (pname == GL_OBJECT_TYPE_ARB) { - *params = GL_SHADER_OBJECT_ARB; - } - else { - get_shaderiv(ctx, object, pname, params); - } - } - else { - _mesa_error(ctx, GL_INVALID_VALUE, "glGetObjectParameterivARB"); - } -} - - -void GLAPIENTRY -_mesa_GetObjectParameterfvARB(GLhandleARB object, GLenum pname, - GLfloat *params) -{ - GLint iparams[1]; /* XXX is one element enough? */ - _mesa_GetObjectParameterivARB(object, pname, iparams); - params[0] = (GLfloat) iparams[0]; -} - - -void GLAPIENTRY -_mesa_GetProgramiv(GLuint program, GLenum pname, GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - get_programiv(ctx, program, pname, params); -} - - -void GLAPIENTRY -_mesa_GetShaderiv(GLuint shader, GLenum pname, GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - get_shaderiv(ctx, shader, pname, params); -} - - -void GLAPIENTRY -_mesa_GetProgramInfoLog(GLuint program, GLsizei bufSize, - GLsizei *length, GLchar *infoLog) -{ - GET_CURRENT_CONTEXT(ctx); - get_program_info_log(ctx, program, bufSize, length, infoLog); -} - - -void GLAPIENTRY -_mesa_GetShaderInfoLog(GLuint shader, GLsizei bufSize, - GLsizei *length, GLchar *infoLog) -{ - GET_CURRENT_CONTEXT(ctx); - get_shader_info_log(ctx, shader, bufSize, length, infoLog); -} - - -void GLAPIENTRY -_mesa_GetShaderSourceARB(GLhandleARB shader, GLsizei maxLength, - GLsizei *length, GLcharARB *sourceOut) -{ - GET_CURRENT_CONTEXT(ctx); - get_shader_source(ctx, shader, maxLength, length, sourceOut); -} - - -GLhandleARB GLAPIENTRY -_mesa_GetHandleARB(GLenum pname) -{ - GET_CURRENT_CONTEXT(ctx); - return get_handle(ctx, pname); -} - - -GLboolean GLAPIENTRY -_mesa_IsProgram(GLuint name) -{ - GET_CURRENT_CONTEXT(ctx); - return is_program(ctx, name); -} - - -GLboolean GLAPIENTRY -_mesa_IsShader(GLuint name) -{ - GET_CURRENT_CONTEXT(ctx); - return is_shader(ctx, name); -} - - -void GLAPIENTRY -_mesa_LinkProgramARB(GLhandleARB programObj) -{ - GET_CURRENT_CONTEXT(ctx); - link_program(ctx, programObj); -} - - - -/** - * Read shader source code from a file. - * Useful for debugging to override an app's shader. - */ -static GLcharARB * -read_shader(const char *fname) -{ - const int max = 50*1000; - FILE *f = fopen(fname, "r"); - GLcharARB *buffer, *shader; - int len; - - if (!f) { - return NULL; - } - - buffer = (char *) malloc(max); - len = fread(buffer, 1, max, f); - buffer[len] = 0; - - fclose(f); - - shader = _mesa_strdup(buffer); - free(buffer); - - return shader; -} - - -/** - * Called via glShaderSource() and glShaderSourceARB() API functions. - * Basically, concatenate the source code strings into one long string - * and pass it to _mesa_shader_source(). - */ -void GLAPIENTRY -_mesa_ShaderSourceARB(GLhandleARB shaderObj, GLsizei count, - const GLcharARB ** string, const GLint * length) -{ - GET_CURRENT_CONTEXT(ctx); - GLint *offsets; - GLsizei i, totalLength; - GLcharARB *source; - GLuint checksum; - - if (!shaderObj || string == NULL) { - _mesa_error(ctx, GL_INVALID_VALUE, "glShaderSourceARB"); - return; - } - - /* - * This array holds offsets of where the appropriate string ends, thus the - * last element will be set to the total length of the source code. - */ - offsets = (GLint *) malloc(count * sizeof(GLint)); - if (offsets == NULL) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glShaderSourceARB"); - return; - } - - for (i = 0; i < count; i++) { - if (string[i] == NULL) { - free((GLvoid *) offsets); - _mesa_error(ctx, GL_INVALID_OPERATION, - "glShaderSourceARB(null string)"); - return; - } - if (length == NULL || length[i] < 0) - offsets[i] = strlen(string[i]); - else - offsets[i] = length[i]; - /* accumulate string lengths */ - if (i > 0) - offsets[i] += offsets[i - 1]; - } - - /* Total length of source string is sum off all strings plus two. - * One extra byte for terminating zero, another extra byte to silence - * valgrind warnings in the parser/grammer code. - */ - totalLength = offsets[count - 1] + 2; - source = (GLcharARB *) malloc(totalLength * sizeof(GLcharARB)); - if (source == NULL) { - free((GLvoid *) offsets); - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glShaderSourceARB"); - return; - } - - for (i = 0; i < count; i++) { - GLint start = (i > 0) ? offsets[i - 1] : 0; - memcpy(source + start, string[i], - (offsets[i] - start) * sizeof(GLcharARB)); - } - source[totalLength - 1] = '\0'; - source[totalLength - 2] = '\0'; - - if (SHADER_SUBST) { - /* Compute the shader's source code checksum then try to open a file - * named newshader_. If it exists, use it in place of the - * original shader source code. For debugging. - */ - char filename[100]; - GLcharARB *newSource; - - checksum = _mesa_str_checksum(source); - - _mesa_snprintf(filename, sizeof(filename), "newshader_%d", checksum); - - newSource = read_shader(filename); - if (newSource) { - fprintf(stderr, "Mesa: Replacing shader %u chksum=%d with %s\n", - shaderObj, checksum, filename); - free(source); - source = newSource; - } - } - - shader_source(ctx, shaderObj, source); - - if (SHADER_SUBST) { - struct gl_shader *sh = _mesa_lookup_shader(ctx, shaderObj); - if (sh) - sh->SourceChecksum = checksum; /* save original checksum */ - } - - free(offsets); -} - - -void GLAPIENTRY -_mesa_UseProgramObjectARB(GLhandleARB program) -{ - GET_CURRENT_CONTEXT(ctx); - struct gl_shader_program *shProg; - struct gl_transform_feedback_object *obj = - ctx->TransformFeedback.CurrentObject; - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (obj->Active) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glUseProgram(transform feedback active)"); - return; - } - - if (program) { - shProg = _mesa_lookup_shader_program_err(ctx, program, "glUseProgram"); - if (!shProg) { - return; - } - if (!shProg->LinkStatus) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glUseProgram(program %u not linked)", program); - return; - } - - /* debug code */ - if (ctx->Shader.Flags & GLSL_USE_PROG) { - print_shader_info(shProg); - } - } - else { - shProg = NULL; - } - - _mesa_use_program(ctx, shProg); -} - - -void GLAPIENTRY -_mesa_ValidateProgramARB(GLhandleARB program) -{ - GET_CURRENT_CONTEXT(ctx); - validate_program(ctx, program); -} - -#ifdef FEATURE_ES2 - -void GLAPIENTRY -_mesa_GetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, - GLint* range, GLint* precision) -{ - const struct gl_program_constants *limits; - const struct gl_precision *p; - GET_CURRENT_CONTEXT(ctx); - - switch (shadertype) { - case GL_VERTEX_SHADER: - limits = &ctx->Const.VertexProgram; - break; - case GL_FRAGMENT_SHADER: - limits = &ctx->Const.FragmentProgram; - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, - "glGetShaderPrecisionFormat(shadertype)"); - return; - } - - switch (precisiontype) { - case GL_LOW_FLOAT: - p = &limits->LowFloat; - break; - case GL_MEDIUM_FLOAT: - p = &limits->MediumFloat; - break; - case GL_HIGH_FLOAT: - p = &limits->HighFloat; - break; - case GL_LOW_INT: - p = &limits->LowInt; - break; - case GL_MEDIUM_INT: - p = &limits->MediumInt; - break; - case GL_HIGH_INT: - p = &limits->HighInt; - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, - "glGetShaderPrecisionFormat(precisiontype)"); - return; - } - - range[0] = p->RangeMin; - range[1] = p->RangeMax; - precision[0] = p->Precision; -} - - -void GLAPIENTRY -_mesa_ReleaseShaderCompiler(void) -{ - _mesa_destroy_shader_compiler_caches(); -} - - -void GLAPIENTRY -_mesa_ShaderBinary(GLint n, const GLuint* shaders, GLenum binaryformat, - const void* binary, GLint length) -{ - GET_CURRENT_CONTEXT(ctx); - (void) n; - (void) shaders; - (void) binaryformat; - (void) binary; - (void) length; - _mesa_error(ctx, GL_INVALID_OPERATION, __FUNCTION__); -} - -#endif /* FEATURE_ES2 */ - - -#if FEATURE_ARB_geometry_shader4 - -void GLAPIENTRY -_mesa_ProgramParameteriARB(GLuint program, GLenum pname, GLint value) -{ - struct gl_shader_program *shProg; - GET_CURRENT_CONTEXT(ctx); - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - shProg = _mesa_lookup_shader_program_err(ctx, program, - "glProgramParameteri"); - if (!shProg) - return; - - switch (pname) { - case GL_GEOMETRY_VERTICES_OUT_ARB: - if (value < 1 || - (unsigned) value > ctx->Const.MaxGeometryOutputVertices) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glProgramParameteri(GL_GEOMETRY_VERTICES_OUT_ARB=%d", - value); - return; - } - shProg->Geom.VerticesOut = value; - break; - case GL_GEOMETRY_INPUT_TYPE_ARB: - switch (value) { - case GL_POINTS: - case GL_LINES: - case GL_LINES_ADJACENCY_ARB: - case GL_TRIANGLES: - case GL_TRIANGLES_ADJACENCY_ARB: - shProg->Geom.InputType = value; - break; - default: - _mesa_error(ctx, GL_INVALID_VALUE, - "glProgramParameteri(geometry input type = %s", - _mesa_lookup_enum_by_nr(value)); - return; - } - break; - case GL_GEOMETRY_OUTPUT_TYPE_ARB: - switch (value) { - case GL_POINTS: - case GL_LINE_STRIP: - case GL_TRIANGLE_STRIP: - shProg->Geom.OutputType = value; - break; - default: - _mesa_error(ctx, GL_INVALID_VALUE, - "glProgramParameteri(geometry output type = %s", - _mesa_lookup_enum_by_nr(value)); - return; - } - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glProgramParameteriARB(pname=%s)", - _mesa_lookup_enum_by_nr(pname)); - break; - } -} - -#endif - -void -_mesa_use_shader_program(struct gl_context *ctx, GLenum type, - struct gl_shader_program *shProg) -{ - use_shader_program(ctx, type, shProg); - - if (ctx->Driver.UseProgram) - ctx->Driver.UseProgram(ctx, shProg); -} - -void GLAPIENTRY -_mesa_UseShaderProgramEXT(GLenum type, GLuint program) -{ - GET_CURRENT_CONTEXT(ctx); - struct gl_shader_program *shProg = NULL; - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (!validate_shader_target(ctx, type)) { - _mesa_error(ctx, GL_INVALID_ENUM, "glUseShaderProgramEXT(type)"); - return; - } - - if (ctx->TransformFeedback.CurrentObject->Active) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glUseShaderProgramEXT(transform feedback is active)"); - return; - } - - if (program) { - shProg = _mesa_lookup_shader_program_err(ctx, program, - "glUseShaderProgramEXT"); - if (shProg == NULL) - return; - - if (!shProg->LinkStatus) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glUseShaderProgramEXT(program not linked)"); - return; - } - } - - _mesa_use_shader_program(ctx, type, shProg); -} - -void GLAPIENTRY -_mesa_ActiveProgramEXT(GLuint program) -{ - GET_CURRENT_CONTEXT(ctx); - struct gl_shader_program *shProg = (program != 0) - ? _mesa_lookup_shader_program_err(ctx, program, "glActiveProgramEXT") - : NULL; - - _mesa_active_program(ctx, shProg, "glActiveProgramEXT"); - return; -} - -GLuint GLAPIENTRY -_mesa_CreateShaderProgramEXT(GLenum type, const GLchar *string) -{ - GET_CURRENT_CONTEXT(ctx); - const GLuint shader = create_shader(ctx, type); - GLuint program = 0; - - if (shader) { - shader_source(ctx, shader, _mesa_strdup(string)); - compile_shader(ctx, shader); - - program = create_shader_program(ctx); - if (program) { - struct gl_shader_program *shProg; - struct gl_shader *sh; - GLint compiled = GL_FALSE; - - shProg = _mesa_lookup_shader_program(ctx, program); - sh = _mesa_lookup_shader(ctx, shader); - - get_shaderiv(ctx, shader, GL_COMPILE_STATUS, &compiled); - if (compiled) { - attach_shader(ctx, program, shader); - link_program(ctx, program); - detach_shader(ctx, program, shader); - -#if 0 - /* Possibly... */ - if (active-user-defined-varyings-in-linked-program) { - append-error-to-info-log; - shProg->LinkStatus = GL_FALSE; - } -#endif - } - - ralloc_strcat(&shProg->InfoLog, sh->InfoLog); - } - - delete_shader(ctx, shader); - } - - return program; -} - -/** - * Plug in shader-related functions into API dispatch table. - */ -void -_mesa_init_shader_dispatch(struct _glapi_table *exec) -{ -#if FEATURE_GL - /* GL_ARB_vertex/fragment_shader */ - SET_DeleteObjectARB(exec, _mesa_DeleteObjectARB); - SET_GetHandleARB(exec, _mesa_GetHandleARB); - SET_DetachObjectARB(exec, _mesa_DetachObjectARB); - SET_CreateShaderObjectARB(exec, _mesa_CreateShaderObjectARB); - SET_ShaderSourceARB(exec, _mesa_ShaderSourceARB); - SET_CompileShaderARB(exec, _mesa_CompileShaderARB); - SET_CreateProgramObjectARB(exec, _mesa_CreateProgramObjectARB); - SET_AttachObjectARB(exec, _mesa_AttachObjectARB); - SET_LinkProgramARB(exec, _mesa_LinkProgramARB); - SET_UseProgramObjectARB(exec, _mesa_UseProgramObjectARB); - SET_ValidateProgramARB(exec, _mesa_ValidateProgramARB); - SET_GetObjectParameterfvARB(exec, _mesa_GetObjectParameterfvARB); - SET_GetObjectParameterivARB(exec, _mesa_GetObjectParameterivARB); - SET_GetInfoLogARB(exec, _mesa_GetInfoLogARB); - SET_GetAttachedObjectsARB(exec, _mesa_GetAttachedObjectsARB); - SET_GetShaderSourceARB(exec, _mesa_GetShaderSourceARB); - - /* OpenGL 2.0 */ - SET_AttachShader(exec, _mesa_AttachShader); - SET_CreateProgram(exec, _mesa_CreateProgram); - SET_CreateShader(exec, _mesa_CreateShader); - SET_DeleteProgram(exec, _mesa_DeleteProgram); - SET_DeleteShader(exec, _mesa_DeleteShader); - SET_DetachShader(exec, _mesa_DetachShader); - SET_GetAttachedShaders(exec, _mesa_GetAttachedShaders); - SET_GetProgramiv(exec, _mesa_GetProgramiv); - SET_GetProgramInfoLog(exec, _mesa_GetProgramInfoLog); - SET_GetShaderiv(exec, _mesa_GetShaderiv); - SET_GetShaderInfoLog(exec, _mesa_GetShaderInfoLog); - SET_IsProgram(exec, _mesa_IsProgram); - SET_IsShader(exec, _mesa_IsShader); - -#if FEATURE_ARB_vertex_shader - SET_BindAttribLocationARB(exec, _mesa_BindAttribLocationARB); - SET_GetActiveAttribARB(exec, _mesa_GetActiveAttribARB); - SET_GetAttribLocationARB(exec, _mesa_GetAttribLocationARB); -#endif - -#if FEATURE_ARB_geometry_shader4 - SET_ProgramParameteriARB(exec, _mesa_ProgramParameteriARB); -#endif - - SET_UseShaderProgramEXT(exec, _mesa_UseShaderProgramEXT); - SET_ActiveProgramEXT(exec, _mesa_ActiveProgramEXT); - SET_CreateShaderProgramEXT(exec, _mesa_CreateShaderProgramEXT); - - /* GL_EXT_gpu_shader4 / GL 3.0 */ - SET_BindFragDataLocationEXT(exec, _mesa_BindFragDataLocation); - SET_GetFragDataLocationEXT(exec, _mesa_GetFragDataLocation); - - /* GL_ARB_ES2_compatibility */ - SET_ReleaseShaderCompiler(exec, _mesa_ReleaseShaderCompiler); - SET_GetShaderPrecisionFormat(exec, _mesa_GetShaderPrecisionFormat); - -#endif /* FEATURE_GL */ -} - +/* + * Mesa 3-D graphics library + * + * Copyright (C) 2004-2008 Brian Paul All Rights Reserved. + * Copyright (C) 2009-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 + * 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 shaderapi.c + * \author Brian Paul + * + * Implementation of GLSL-related API functions. + * The glUniform* functions are in uniforms.c + * + * + * XXX things to do: + * 1. Check that the right error code is generated for all _mesa_error() calls. + * 2. Insert FLUSH_VERTICES calls in various places + */ + + +#include "main/glheader.h" +#include "main/context.h" +#include "main/dispatch.h" +#include "main/enums.h" +#include "main/hash.h" +#include "main/mfeatures.h" +#include "main/mtypes.h" +#include "main/shaderapi.h" +#include "main/shaderobj.h" +#include "program/program.h" +#include "program/prog_parameter.h" +#include "program/prog_uniform.h" +#include "ralloc.h" +#include +#include "../glsl/glsl_parser_extras.h" + +/** Define this to enable shader substitution (see below) */ +#define SHADER_SUBST 0 + + +/** + * Return mask of GLSL_x flags by examining the MESA_GLSL env var. + */ +static GLbitfield +get_shader_flags(void) +{ + GLbitfield flags = 0x0; + const char *env = _mesa_getenv("MESA_GLSL"); + + if (env) { + if (strstr(env, "dump")) + flags |= GLSL_DUMP; + if (strstr(env, "log")) + flags |= GLSL_LOG; + if (strstr(env, "nopvert")) + flags |= GLSL_NOP_VERT; + if (strstr(env, "nopfrag")) + flags |= GLSL_NOP_FRAG; + if (strstr(env, "nopt")) + flags |= GLSL_NO_OPT; + else if (strstr(env, "opt")) + flags |= GLSL_OPT; + if (strstr(env, "uniform")) + flags |= GLSL_UNIFORMS; + if (strstr(env, "useprog")) + flags |= GLSL_USE_PROG; + } + + return flags; +} + + +/** + * Initialize context's shader state. + */ +void +_mesa_init_shader_state(struct gl_context *ctx) +{ + /* Device drivers may override these to control what kind of instructions + * are generated by the GLSL compiler. + */ + struct gl_shader_compiler_options options; + gl_shader_type sh; + + memset(&options, 0, sizeof(options)); + options.MaxUnrollIterations = 32; + + /* Default pragma settings */ + options.DefaultPragmas.Optimize = GL_TRUE; + + for (sh = 0; sh < MESA_SHADER_TYPES; ++sh) + memcpy(&ctx->ShaderCompilerOptions[sh], &options, sizeof(options)); + + ctx->Shader.Flags = get_shader_flags(); +} + + +/** + * Free the per-context shader-related state. + */ +void +_mesa_free_shader_state(struct gl_context *ctx) +{ + _mesa_reference_shader_program(ctx, &ctx->Shader.CurrentVertexProgram, NULL); + _mesa_reference_shader_program(ctx, &ctx->Shader.CurrentGeometryProgram, + NULL); + _mesa_reference_shader_program(ctx, &ctx->Shader.CurrentFragmentProgram, + NULL); + _mesa_reference_shader_program(ctx, &ctx->Shader.ActiveProgram, NULL); +} + + +/** + * Return the size of the given GLSL datatype, in floats (components). + */ +GLint +_mesa_sizeof_glsl_type(GLenum type) +{ + switch (type) { + case GL_FLOAT: + case GL_INT: + case GL_BOOL: + case GL_SAMPLER_1D: + case GL_SAMPLER_2D: + case GL_SAMPLER_3D: + case GL_SAMPLER_CUBE: + case GL_SAMPLER_1D_SHADOW: + case GL_SAMPLER_2D_SHADOW: + case GL_SAMPLER_2D_RECT_ARB: + case GL_SAMPLER_2D_RECT_SHADOW_ARB: + case GL_SAMPLER_1D_ARRAY_EXT: + case GL_SAMPLER_2D_ARRAY_EXT: + case GL_SAMPLER_1D_ARRAY_SHADOW_EXT: + case GL_SAMPLER_2D_ARRAY_SHADOW_EXT: + case GL_SAMPLER_CUBE_SHADOW_EXT: + return 1; + case GL_FLOAT_VEC2: + case GL_INT_VEC2: + case GL_UNSIGNED_INT_VEC2: + case GL_BOOL_VEC2: + return 2; + case GL_FLOAT_VEC3: + case GL_INT_VEC3: + case GL_UNSIGNED_INT_VEC3: + case GL_BOOL_VEC3: + return 3; + case GL_FLOAT_VEC4: + case GL_INT_VEC4: + case GL_UNSIGNED_INT_VEC4: + case GL_BOOL_VEC4: + return 4; + case GL_FLOAT_MAT2: + case GL_FLOAT_MAT2x3: + case GL_FLOAT_MAT2x4: + return 8; /* two float[4] vectors */ + case GL_FLOAT_MAT3: + case GL_FLOAT_MAT3x2: + case GL_FLOAT_MAT3x4: + return 12; /* three float[4] vectors */ + case GL_FLOAT_MAT4: + case GL_FLOAT_MAT4x2: + case GL_FLOAT_MAT4x3: + return 16; /* four float[4] vectors */ + default: + _mesa_problem(NULL, "Invalid type in _mesa_sizeof_glsl_type()"); + return 1; + } +} + + +/** + * Copy string from to , up to maxLength characters, returning + * length of in . + * \param src the strings source + * \param maxLength max chars to copy + * \param length returns number of chars copied + * \param dst the string destination + */ +void +_mesa_copy_string(GLchar *dst, GLsizei maxLength, + GLsizei *length, const GLchar *src) +{ + GLsizei len; + for (len = 0; len < maxLength - 1 && src && src[len]; len++) + dst[len] = src[len]; + if (maxLength > 0) + dst[len] = 0; + if (length) + *length = len; +} + + + +/** + * Confirm that the a shader type is valid and supported by the implementation + * + * \param ctx Current GL context + * \param type Shader target + * + */ +static bool +validate_shader_target(const struct gl_context *ctx, GLenum type) +{ + switch (type) { +#if FEATURE_ARB_fragment_shader + case GL_FRAGMENT_SHADER: + return ctx->Extensions.ARB_fragment_shader; +#endif +#if FEATURE_ARB_vertex_shader + case GL_VERTEX_SHADER: + return ctx->Extensions.ARB_vertex_shader; +#endif +#if FEATURE_ARB_geometry_shader4 + case GL_GEOMETRY_SHADER_ARB: + return ctx->Extensions.ARB_geometry_shader4; +#endif + default: + return false; + } +} + + +/** + * Find the length of the longest transform feedback varying name + * which was specified with glTransformFeedbackVaryings(). + */ +static GLint +longest_feedback_varying_name(const struct gl_shader_program *shProg) +{ + GLuint i; + GLint max = 0; + for (i = 0; i < shProg->TransformFeedback.NumVarying; i++) { + GLint len = strlen(shProg->TransformFeedback.VaryingNames[i]); + if (len > max) + max = len; + } + return max; +} + + + +static GLboolean +is_program(struct gl_context *ctx, GLuint name) +{ + struct gl_shader_program *shProg = _mesa_lookup_shader_program(ctx, name); + return shProg ? GL_TRUE : GL_FALSE; +} + + +static GLboolean +is_shader(struct gl_context *ctx, GLuint name) +{ + struct gl_shader *shader = _mesa_lookup_shader(ctx, name); + return shader ? GL_TRUE : GL_FALSE; +} + + +/** + * Attach shader to a shader program. + */ +static void +attach_shader(struct gl_context *ctx, GLuint program, GLuint shader) +{ + struct gl_shader_program *shProg; + struct gl_shader *sh; + GLuint i, n; + + shProg = _mesa_lookup_shader_program_err(ctx, program, "glAttachShader"); + if (!shProg) + return; + + sh = _mesa_lookup_shader_err(ctx, shader, "glAttachShader"); + if (!sh) { + return; + } + + n = shProg->NumShaders; + for (i = 0; i < n; i++) { + if (shProg->Shaders[i] == sh) { + /* The shader is already attched to this program. The + * GL_ARB_shader_objects spec says: + * + * "The error INVALID_OPERATION is generated by AttachObjectARB + * if is already attached to ." + */ + _mesa_error(ctx, GL_INVALID_OPERATION, "glAttachShader"); + return; + } + } + + /* grow list */ + shProg->Shaders = (struct gl_shader **) + _mesa_realloc(shProg->Shaders, + n * sizeof(struct gl_shader *), + (n + 1) * sizeof(struct gl_shader *)); + if (!shProg->Shaders) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glAttachShader"); + return; + } + + /* append */ + shProg->Shaders[n] = NULL; /* since realloc() didn't zero the new space */ + _mesa_reference_shader(ctx, &shProg->Shaders[n], sh); + shProg->NumShaders++; +} + + +static GLint +get_attrib_location(struct gl_context *ctx, GLuint program, const GLchar *name) +{ + struct gl_shader_program *shProg + = _mesa_lookup_shader_program_err(ctx, program, "glGetAttribLocation"); + + if (!shProg) { + return -1; + } + + if (!shProg->LinkStatus) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glGetAttribLocation(program not linked)"); + return -1; + } + + if (!name) + return -1; + + if (shProg->VertexProgram) { + const struct gl_program_parameter_list *attribs = + shProg->VertexProgram->Base.Attributes; + if (attribs) { + GLint i = _mesa_lookup_parameter_index(attribs, -1, name); + if (i >= 0) { + return attribs->Parameters[i].StateIndexes[0]; + } + } + } + return -1; +} + + +static void +bind_attrib_location(struct gl_context *ctx, GLuint program, GLuint index, + const GLchar *name) +{ + struct gl_shader_program *shProg; + const GLint size = -1; /* unknown size */ + GLint i; + GLenum datatype = GL_FLOAT_VEC4; + + shProg = _mesa_lookup_shader_program_err(ctx, program, + "glBindAttribLocation"); + if (!shProg) { + return; + } + + if (!name) + return; + + if (strncmp(name, "gl_", 3) == 0) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glBindAttribLocation(illegal name)"); + return; + } + + if (index >= ctx->Const.VertexProgram.MaxAttribs) { + _mesa_error(ctx, GL_INVALID_VALUE, "glBindAttribLocation(index)"); + return; + } + + /* this will replace the current value if it's already in the list */ + i = _mesa_add_attribute(shProg->Attributes, name, size, datatype, index); + if (i < 0) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindAttribLocation"); + return; + } + + /* + * Note that this attribute binding won't go into effect until + * glLinkProgram is called again. + */ +} + + +static void +bind_frag_data_location(struct gl_context *ctx, GLuint program, + GLuint colorNumber, const GLchar *name) +{ + _mesa_problem(ctx, "bind_frag_data_location() not implemented yet"); +} + + +static GLuint +create_shader(struct gl_context *ctx, GLenum type) +{ + struct gl_shader *sh; + GLuint name; + + if (!validate_shader_target(ctx, type)) { + _mesa_error(ctx, GL_INVALID_ENUM, "CreateShader(type)"); + return 0; + } + + name = _mesa_HashFindFreeKeyBlock(ctx->Shared->ShaderObjects, 1); + sh = ctx->Driver.NewShader(ctx, name, type); + _mesa_HashInsert(ctx->Shared->ShaderObjects, name, sh); + + return name; +} + + +static GLuint +create_shader_program(struct gl_context *ctx) +{ + GLuint name; + struct gl_shader_program *shProg; + + name = _mesa_HashFindFreeKeyBlock(ctx->Shared->ShaderObjects, 1); + + shProg = ctx->Driver.NewShaderProgram(ctx, name); + + _mesa_HashInsert(ctx->Shared->ShaderObjects, name, shProg); + + assert(shProg->RefCount == 1); + + return name; +} + + +/** + * Named w/ "2" to indicate OpenGL 2.x vs GL_ARB_fragment_programs's + * DeleteProgramARB. + */ +static void +delete_shader_program(struct gl_context *ctx, GLuint name) +{ + /* + * NOTE: deleting shaders/programs works a bit differently than + * texture objects (and buffer objects, etc). Shader/program + * handles/IDs exist in the hash table until the object is really + * deleted (refcount==0). With texture objects, the handle/ID is + * removed from the hash table in glDeleteTextures() while the tex + * object itself might linger until its refcount goes to zero. + */ + struct gl_shader_program *shProg; + + shProg = _mesa_lookup_shader_program_err(ctx, name, "glDeleteProgram"); + if (!shProg) + return; + + shProg->DeletePending = GL_TRUE; + + /* effectively, decr shProg's refcount */ + _mesa_reference_shader_program(ctx, &shProg, NULL); +} + + +static void +delete_shader(struct gl_context *ctx, GLuint shader) +{ + struct gl_shader *sh; + + sh = _mesa_lookup_shader_err(ctx, shader, "glDeleteShader"); + if (!sh) + return; + + sh->DeletePending = GL_TRUE; + + /* effectively, decr sh's refcount */ + _mesa_reference_shader(ctx, &sh, NULL); +} + + +static void +detach_shader(struct gl_context *ctx, GLuint program, GLuint shader) +{ + struct gl_shader_program *shProg; + GLuint n; + GLuint i, j; + + shProg = _mesa_lookup_shader_program_err(ctx, program, "glDetachShader"); + if (!shProg) + return; + + n = shProg->NumShaders; + + for (i = 0; i < n; i++) { + if (shProg->Shaders[i]->Name == shader) { + /* found it */ + struct gl_shader **newList; + + /* release */ + _mesa_reference_shader(ctx, &shProg->Shaders[i], NULL); + + /* alloc new, smaller array */ + newList = (struct gl_shader **) + malloc((n - 1) * sizeof(struct gl_shader *)); + if (!newList) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glDetachShader"); + return; + } + for (j = 0; j < i; j++) { + newList[j] = shProg->Shaders[j]; + } + while (++i < n) + newList[j++] = shProg->Shaders[i]; + free(shProg->Shaders); + + shProg->Shaders = newList; + shProg->NumShaders = n - 1; + +#ifdef DEBUG + /* sanity check */ + { + for (j = 0; j < shProg->NumShaders; j++) { + assert(shProg->Shaders[j]->Type == GL_VERTEX_SHADER || + shProg->Shaders[j]->Type == GL_FRAGMENT_SHADER); + assert(shProg->Shaders[j]->RefCount > 0); + } + } +#endif + + return; + } + } + + /* not found */ + { + GLenum err; + if (is_shader(ctx, shader)) + err = GL_INVALID_OPERATION; + else if (is_program(ctx, shader)) + err = GL_INVALID_OPERATION; + else + err = GL_INVALID_VALUE; + _mesa_error(ctx, err, "glDetachProgram(shader)"); + return; + } +} + + +static void +get_active_attrib(struct gl_context *ctx, GLuint program, GLuint index, + GLsizei maxLength, GLsizei *length, GLint *size, + GLenum *type, GLchar *nameOut) +{ + const struct gl_program_parameter_list *attribs = NULL; + struct gl_shader_program *shProg; + + shProg = _mesa_lookup_shader_program_err(ctx, program, "glGetActiveAttrib"); + if (!shProg) + return; + + if (shProg->VertexProgram) + attribs = shProg->VertexProgram->Base.Attributes; + + if (!attribs || index >= attribs->NumParameters) { + _mesa_error(ctx, GL_INVALID_VALUE, "glGetActiveAttrib(index)"); + return; + } + + _mesa_copy_string(nameOut, maxLength, length, + attribs->Parameters[index].Name); + + if (size) + *size = attribs->Parameters[index].Size + / _mesa_sizeof_glsl_type(attribs->Parameters[index].DataType); + + if (type) + *type = attribs->Parameters[index].DataType; +} + + +/** + * Return list of shaders attached to shader program. + */ +static void +get_attached_shaders(struct gl_context *ctx, GLuint program, GLsizei maxCount, + GLsizei *count, GLuint *obj) +{ + struct gl_shader_program *shProg = + _mesa_lookup_shader_program_err(ctx, program, "glGetAttachedShaders"); + if (shProg) { + GLuint i; + for (i = 0; i < (GLuint) maxCount && i < shProg->NumShaders; i++) { + obj[i] = shProg->Shaders[i]->Name; + } + if (count) + *count = i; + } +} + + +static GLint +get_frag_data_location(struct gl_context *ctx, GLuint program, + const GLchar *name) +{ + _mesa_problem(ctx, "get_frag_data_location() not implemented yet"); + return -1; +} + + + +/** + * glGetHandleARB() - return ID/name of currently bound shader program. + */ +static GLuint +get_handle(struct gl_context *ctx, GLenum pname) +{ + if (pname == GL_PROGRAM_OBJECT_ARB) { + if (ctx->Shader.ActiveProgram) + return ctx->Shader.ActiveProgram->Name; + else + return 0; + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetHandleARB"); + return 0; + } +} + + +/** + * glGetProgramiv() - get shader program state. + * Note that this is for GLSL shader programs, not ARB vertex/fragment + * programs (see glGetProgramivARB). + */ +static void +get_programiv(struct gl_context *ctx, GLuint program, GLenum pname, GLint *params) +{ + const struct gl_program_parameter_list *attribs; + struct gl_shader_program *shProg + = _mesa_lookup_shader_program(ctx, program); + + if (!shProg) { + _mesa_error(ctx, GL_INVALID_VALUE, "glGetProgramiv(program)"); + return; + } + + if (shProg->VertexProgram) + attribs = shProg->VertexProgram->Base.Attributes; + else + attribs = NULL; + + switch (pname) { + case GL_DELETE_STATUS: + *params = shProg->DeletePending; + break; + case GL_LINK_STATUS: + *params = shProg->LinkStatus; + break; + case GL_VALIDATE_STATUS: + *params = shProg->Validated; + break; + case GL_INFO_LOG_LENGTH: + *params = shProg->InfoLog ? strlen(shProg->InfoLog) + 1 : 0; + break; + case GL_ATTACHED_SHADERS: + *params = shProg->NumShaders; + break; + case GL_ACTIVE_ATTRIBUTES: + *params = attribs ? attribs->NumParameters : 0; + break; + case GL_ACTIVE_ATTRIBUTE_MAX_LENGTH: + *params = _mesa_longest_parameter_name(attribs, PROGRAM_INPUT) + 1; + break; + case GL_ACTIVE_UNIFORMS: + *params = shProg->Uniforms ? shProg->Uniforms->NumUniforms : 0; + break; + case GL_ACTIVE_UNIFORM_MAX_LENGTH: + *params = _mesa_longest_uniform_name(shProg->Uniforms); + if (*params > 0) + (*params)++; /* add one for terminating zero */ + break; + case GL_PROGRAM_BINARY_LENGTH_OES: + *params = 0; + break; +#if FEATURE_EXT_transform_feedback + case GL_TRANSFORM_FEEDBACK_VARYINGS: + *params = shProg->TransformFeedback.NumVarying; + break; + case GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH: + *params = longest_feedback_varying_name(shProg) + 1; + break; + case GL_TRANSFORM_FEEDBACK_BUFFER_MODE: + *params = shProg->TransformFeedback.BufferMode; + break; +#endif +#if FEATURE_ARB_geometry_shader4 + case GL_GEOMETRY_VERTICES_OUT_ARB: + *params = shProg->Geom.VerticesOut; + break; + case GL_GEOMETRY_INPUT_TYPE_ARB: + *params = shProg->Geom.InputType; + break; + case GL_GEOMETRY_OUTPUT_TYPE_ARB: + *params = shProg->Geom.OutputType; + break; +#endif + default: + _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramiv(pname)"); + return; + } +} + + +/** + * glGetShaderiv() - get GLSL shader state + */ +static void +get_shaderiv(struct gl_context *ctx, GLuint name, GLenum pname, GLint *params) +{ + struct gl_shader *shader = + _mesa_lookup_shader_err(ctx, name, "glGetShaderiv"); + + if (!shader) { + return; + } + + switch (pname) { + case GL_SHADER_TYPE: + *params = shader->Type; + break; + case GL_DELETE_STATUS: + *params = shader->DeletePending; + break; + case GL_COMPILE_STATUS: + *params = shader->CompileStatus; + break; + case GL_INFO_LOG_LENGTH: + *params = shader->InfoLog ? strlen(shader->InfoLog) + 1 : 0; + break; + case GL_SHADER_SOURCE_LENGTH: + *params = shader->Source ? strlen((char *) shader->Source) + 1 : 0; + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, "glGetShaderiv(pname)"); + return; + } +} + + +static void +get_program_info_log(struct gl_context *ctx, GLuint program, GLsizei bufSize, + GLsizei *length, GLchar *infoLog) +{ + struct gl_shader_program *shProg + = _mesa_lookup_shader_program(ctx, program); + if (!shProg) { + _mesa_error(ctx, GL_INVALID_VALUE, "glGetProgramInfoLog(program)"); + return; + } + _mesa_copy_string(infoLog, bufSize, length, shProg->InfoLog); +} + + +static void +get_shader_info_log(struct gl_context *ctx, GLuint shader, GLsizei bufSize, + GLsizei *length, GLchar *infoLog) +{ + struct gl_shader *sh = _mesa_lookup_shader(ctx, shader); + if (!sh) { + _mesa_error(ctx, GL_INVALID_VALUE, "glGetShaderInfoLog(shader)"); + return; + } + _mesa_copy_string(infoLog, bufSize, length, sh->InfoLog); +} + + +/** + * Return shader source code. + */ +static void +get_shader_source(struct gl_context *ctx, GLuint shader, GLsizei maxLength, + GLsizei *length, GLchar *sourceOut) +{ + struct gl_shader *sh; + sh = _mesa_lookup_shader_err(ctx, shader, "glGetShaderSource"); + if (!sh) { + return; + } + _mesa_copy_string(sourceOut, maxLength, length, sh->Source); +} + + +/** + * Set/replace shader source code. + */ +static void +shader_source(struct gl_context *ctx, GLuint shader, const GLchar *source) +{ + struct gl_shader *sh; + + sh = _mesa_lookup_shader_err(ctx, shader, "glShaderSource"); + if (!sh) + return; + + /* free old shader source string and install new one */ + if (sh->Source) { + free((void *) sh->Source); + } + sh->Source = source; + sh->CompileStatus = GL_FALSE; +#ifdef DEBUG + sh->SourceChecksum = _mesa_str_checksum(sh->Source); +#endif +} + + +/** + * Compile a shader. + */ +static void +compile_shader(struct gl_context *ctx, GLuint shaderObj) +{ + struct gl_shader *sh; + struct gl_shader_compiler_options *options; + + sh = _mesa_lookup_shader_err(ctx, shaderObj, "glCompileShader"); + if (!sh) + return; + + options = &ctx->ShaderCompilerOptions[_mesa_shader_type_to_index(sh->Type)]; + + /* set default pragma state for shader */ + sh->Pragmas = options->DefaultPragmas; + + /* this call will set the sh->CompileStatus field to indicate if + * compilation was successful. + */ + _mesa_glsl_compile_shader(ctx, sh); +} + + +/** + * Link a program's shaders. + */ +static void +link_program(struct gl_context *ctx, GLuint program) +{ + struct gl_shader_program *shProg; + struct gl_transform_feedback_object *obj = + ctx->TransformFeedback.CurrentObject; + + shProg = _mesa_lookup_shader_program_err(ctx, program, "glLinkProgram"); + if (!shProg) + return; + + if (obj->Active + && (shProg == ctx->Shader.CurrentVertexProgram + || shProg == ctx->Shader.CurrentGeometryProgram + || shProg == ctx->Shader.CurrentFragmentProgram)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glLinkProgram(transform feedback active"); + return; + } + + FLUSH_VERTICES(ctx, _NEW_PROGRAM); + + _mesa_glsl_link_shader(ctx, shProg); + + /* debug code */ + if (0) { + GLuint i; + + printf("Link %u shaders in program %u: %s\n", + shProg->NumShaders, shProg->Name, + shProg->LinkStatus ? "Success" : "Failed"); + + for (i = 0; i < shProg->NumShaders; i++) { + printf(" shader %u, type 0x%x\n", + shProg->Shaders[i]->Name, + shProg->Shaders[i]->Type); + } + } +} + + +/** + * Print basic shader info (for debug). + */ +static void +print_shader_info(const struct gl_shader_program *shProg) +{ + GLuint i; + + printf("Mesa: glUseProgram(%u)\n", shProg->Name); + for (i = 0; i < shProg->NumShaders; i++) { + const char *s; + switch (shProg->Shaders[i]->Type) { + case GL_VERTEX_SHADER: + s = "vertex"; + break; + case GL_FRAGMENT_SHADER: + s = "fragment"; + break; + case GL_GEOMETRY_SHADER: + s = "geometry"; + break; + default: + s = ""; + } + printf(" %s shader %u, checksum %u\n", s, + shProg->Shaders[i]->Name, + shProg->Shaders[i]->SourceChecksum); + } + if (shProg->VertexProgram) + printf(" vert prog %u\n", shProg->VertexProgram->Base.Id); + if (shProg->FragmentProgram) + printf(" frag prog %u\n", shProg->FragmentProgram->Base.Id); + if (shProg->GeometryProgram) + printf(" geom prog %u\n", shProg->GeometryProgram->Base.Id); +} + + +/** + * Use the named shader program for subsequent glUniform calls + */ +void +_mesa_active_program(struct gl_context *ctx, struct gl_shader_program *shProg, + const char *caller) +{ + if ((shProg != NULL) && !shProg->LinkStatus) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "%s(program %u not linked)", caller, shProg->Name); + return; + } + + if (ctx->Shader.ActiveProgram != shProg) { + _mesa_reference_shader_program(ctx, &ctx->Shader.ActiveProgram, shProg); + } +} + +/** + */ +static bool +use_shader_program(struct gl_context *ctx, GLenum type, + struct gl_shader_program *shProg) +{ + struct gl_shader_program **target; + + switch (type) { +#if FEATURE_ARB_vertex_shader + case GL_VERTEX_SHADER: + target = &ctx->Shader.CurrentVertexProgram; + if ((shProg == NULL) + || (shProg->_LinkedShaders[MESA_SHADER_VERTEX] == NULL)) { + shProg = NULL; + } + break; +#endif +#if FEATURE_ARB_geometry_shader4 + case GL_GEOMETRY_SHADER_ARB: + target = &ctx->Shader.CurrentGeometryProgram; + if ((shProg == NULL) + || (shProg->_LinkedShaders[MESA_SHADER_GEOMETRY] == NULL)) { + shProg = NULL; + } + break; +#endif +#if FEATURE_ARB_fragment_shader + case GL_FRAGMENT_SHADER: + target = &ctx->Shader.CurrentFragmentProgram; + if ((shProg == NULL) + || (shProg->_LinkedShaders[MESA_SHADER_FRAGMENT] == NULL)) { + shProg = NULL; + } + break; +#endif + default: + return false; + } + + if (*target != shProg) { + FLUSH_VERTICES(ctx, _NEW_PROGRAM | _NEW_PROGRAM_CONSTANTS); + _mesa_reference_shader_program(ctx, target, shProg); + return true; + } + + return false; +} + +/** + * Use the named shader program for subsequent rendering. + */ +void +_mesa_use_program(struct gl_context *ctx, struct gl_shader_program *shProg) +{ + use_shader_program(ctx, GL_VERTEX_SHADER, shProg); + use_shader_program(ctx, GL_GEOMETRY_SHADER_ARB, shProg); + use_shader_program(ctx, GL_FRAGMENT_SHADER, shProg); + _mesa_active_program(ctx, shProg, "glUseProgram"); + + if (ctx->Driver.UseProgram) + ctx->Driver.UseProgram(ctx, shProg); +} + + +/** + * Validate a program's samplers. + * Specifically, check that there aren't two samplers of different types + * pointing to the same texture unit. + * \return GL_TRUE if valid, GL_FALSE if invalid + */ +static GLboolean +validate_samplers(const struct gl_program *prog, char *errMsg) +{ + static const char *targetName[] = { + "TEXTURE_BUFFER", + "TEXTURE_2D_ARRAY", + "TEXTURE_1D_ARRAY", + "TEXTURE_CUBE", + "TEXTURE_3D", + "TEXTURE_RECT", + "TEXTURE_2D", + "TEXTURE_1D", + }; + GLint targetUsed[MAX_COMBINED_TEXTURE_IMAGE_UNITS]; + GLbitfield samplersUsed = prog->SamplersUsed; + GLuint i; + + assert(Elements(targetName) == NUM_TEXTURE_TARGETS); + + if (samplersUsed == 0x0) + return GL_TRUE; + + for (i = 0; i < Elements(targetUsed); i++) + targetUsed[i] = -1; + + /* walk over bits which are set in 'samplers' */ + while (samplersUsed) { + GLuint unit; + gl_texture_index target; + GLint sampler = _mesa_ffs(samplersUsed) - 1; + assert(sampler >= 0); + assert(sampler < Elements(prog->SamplerUnits)); + unit = prog->SamplerUnits[sampler]; + target = prog->SamplerTargets[sampler]; + if (targetUsed[unit] != -1 && targetUsed[unit] != (int) target) { + _mesa_snprintf(errMsg, 100, + "Texture unit %d is accessed both as %s and %s", + unit, targetName[targetUsed[unit]], targetName[target]); + return GL_FALSE; + } + targetUsed[unit] = target; + samplersUsed ^= (1 << sampler); + } + + return GL_TRUE; +} + + +/** + * Do validation of the given shader program. + * \param errMsg returns error message if validation fails. + * \return GL_TRUE if valid, GL_FALSE if invalid (and set errMsg) + */ +static GLboolean +validate_shader_program(const struct gl_shader_program *shProg, + char *errMsg) +{ + const struct gl_vertex_program *vp = shProg->VertexProgram; + const struct gl_geometry_program *gp = shProg->GeometryProgram; + const struct gl_fragment_program *fp = shProg->FragmentProgram; + + if (!shProg->LinkStatus) { + return GL_FALSE; + } + + /* From the GL spec, a program is invalid if any of these are true: + + any two active samplers in the current program object are of + different types, but refer to the same texture image unit, + + any active sampler in the current program object refers to a texture + image unit where fixed-function fragment processing accesses a + texture target that does not match the sampler type, or + + the sum of the number of active samplers in the program and the + number of texture image units enabled for fixed-function fragment + processing exceeds the combined limit on the total number of texture + image units allowed. + */ + + + /* + * Check: any two active samplers in the current program object are of + * different types, but refer to the same texture image unit, + */ + if (vp && !validate_samplers(&vp->Base, errMsg)) { + return GL_FALSE; + } + if (gp && !validate_samplers(&gp->Base, errMsg)) { + return GL_FALSE; + } + if (fp && !validate_samplers(&fp->Base, errMsg)) { + return GL_FALSE; + } + + return GL_TRUE; +} + + +/** + * Called via glValidateProgram() + */ +static void +validate_program(struct gl_context *ctx, GLuint program) +{ + struct gl_shader_program *shProg; + char errMsg[100] = ""; + + shProg = _mesa_lookup_shader_program_err(ctx, program, "glValidateProgram"); + if (!shProg) { + return; + } + + shProg->Validated = validate_shader_program(shProg, errMsg); + if (!shProg->Validated) { + /* update info log */ + if (shProg->InfoLog) { + ralloc_free(shProg->InfoLog); + } + shProg->InfoLog = ralloc_strdup(shProg, errMsg); + } +} + + + +void GLAPIENTRY +_mesa_AttachObjectARB(GLhandleARB program, GLhandleARB shader) +{ + GET_CURRENT_CONTEXT(ctx); + attach_shader(ctx, program, shader); +} + + +void GLAPIENTRY +_mesa_AttachShader(GLuint program, GLuint shader) +{ + GET_CURRENT_CONTEXT(ctx); + attach_shader(ctx, program, shader); +} + + +void GLAPIENTRY +_mesa_BindAttribLocationARB(GLhandleARB program, GLuint index, + const GLcharARB *name) +{ + GET_CURRENT_CONTEXT(ctx); + bind_attrib_location(ctx, program, index, name); +} + + +/* GL_EXT_gpu_shader4, GL3 */ +void GLAPIENTRY +_mesa_BindFragDataLocation(GLuint program, GLuint colorNumber, + const GLchar *name) +{ + GET_CURRENT_CONTEXT(ctx); + bind_frag_data_location(ctx, program, colorNumber, name); +} + + +void GLAPIENTRY +_mesa_CompileShaderARB(GLhandleARB shaderObj) +{ + GET_CURRENT_CONTEXT(ctx); + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glCompileShader %u\n", shaderObj); + compile_shader(ctx, shaderObj); +} + + +GLuint GLAPIENTRY +_mesa_CreateShader(GLenum type) +{ + GET_CURRENT_CONTEXT(ctx); + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glCreateShader %s\n", _mesa_lookup_enum_by_nr(type)); + return create_shader(ctx, type); +} + + +GLhandleARB GLAPIENTRY +_mesa_CreateShaderObjectARB(GLenum type) +{ + GET_CURRENT_CONTEXT(ctx); + return create_shader(ctx, type); +} + + +GLuint GLAPIENTRY +_mesa_CreateProgram(void) +{ + GET_CURRENT_CONTEXT(ctx); + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glCreateProgram\n"); + return create_shader_program(ctx); +} + + +GLhandleARB GLAPIENTRY +_mesa_CreateProgramObjectARB(void) +{ + GET_CURRENT_CONTEXT(ctx); + return create_shader_program(ctx); +} + + +void GLAPIENTRY +_mesa_DeleteObjectARB(GLhandleARB obj) +{ + if (MESA_VERBOSE & VERBOSE_API) { + GET_CURRENT_CONTEXT(ctx); + _mesa_debug(ctx, "glDeleteObjectARB(%u)\n", obj); + } + + if (obj) { + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + if (is_program(ctx, obj)) { + delete_shader_program(ctx, obj); + } + else if (is_shader(ctx, obj)) { + delete_shader(ctx, obj); + } + else { + /* error? */ + } + } +} + + +void GLAPIENTRY +_mesa_DeleteProgram(GLuint name) +{ + if (name) { + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + delete_shader_program(ctx, name); + } +} + + +void GLAPIENTRY +_mesa_DeleteShader(GLuint name) +{ + if (name) { + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + delete_shader(ctx, name); + } +} + + +void GLAPIENTRY +_mesa_DetachObjectARB(GLhandleARB program, GLhandleARB shader) +{ + GET_CURRENT_CONTEXT(ctx); + detach_shader(ctx, program, shader); +} + + +void GLAPIENTRY +_mesa_DetachShader(GLuint program, GLuint shader) +{ + GET_CURRENT_CONTEXT(ctx); + detach_shader(ctx, program, shader); +} + + +void GLAPIENTRY +_mesa_GetActiveAttribARB(GLhandleARB program, GLuint index, + GLsizei maxLength, GLsizei * length, GLint * size, + GLenum * type, GLcharARB * name) +{ + GET_CURRENT_CONTEXT(ctx); + get_active_attrib(ctx, program, index, maxLength, length, size, type, name); +} + + +void GLAPIENTRY +_mesa_GetAttachedObjectsARB(GLhandleARB container, GLsizei maxCount, + GLsizei * count, GLhandleARB * obj) +{ + GET_CURRENT_CONTEXT(ctx); + get_attached_shaders(ctx, container, maxCount, count, obj); +} + + +void GLAPIENTRY +_mesa_GetAttachedShaders(GLuint program, GLsizei maxCount, + GLsizei *count, GLuint *obj) +{ + GET_CURRENT_CONTEXT(ctx); + get_attached_shaders(ctx, program, maxCount, count, obj); +} + + +GLint GLAPIENTRY +_mesa_GetAttribLocationARB(GLhandleARB program, const GLcharARB * name) +{ + GET_CURRENT_CONTEXT(ctx); + return get_attrib_location(ctx, program, name); +} + + +/* GL_EXT_gpu_shader4, GL3 */ +GLint GLAPIENTRY +_mesa_GetFragDataLocation(GLuint program, const GLchar *name) +{ + GET_CURRENT_CONTEXT(ctx); + return get_frag_data_location(ctx, program, name); +} + + + +void GLAPIENTRY +_mesa_GetInfoLogARB(GLhandleARB object, GLsizei maxLength, GLsizei * length, + GLcharARB * infoLog) +{ + GET_CURRENT_CONTEXT(ctx); + if (is_program(ctx, object)) { + get_program_info_log(ctx, object, maxLength, length, infoLog); + } + else if (is_shader(ctx, object)) { + get_shader_info_log(ctx, object, maxLength, length, infoLog); + } + else { + _mesa_error(ctx, GL_INVALID_OPERATION, "glGetInfoLogARB"); + } +} + + +void GLAPIENTRY +_mesa_GetObjectParameterivARB(GLhandleARB object, GLenum pname, GLint *params) +{ + GET_CURRENT_CONTEXT(ctx); + /* Implement in terms of GetProgramiv, GetShaderiv */ + if (is_program(ctx, object)) { + if (pname == GL_OBJECT_TYPE_ARB) { + *params = GL_PROGRAM_OBJECT_ARB; + } + else { + get_programiv(ctx, object, pname, params); + } + } + else if (is_shader(ctx, object)) { + if (pname == GL_OBJECT_TYPE_ARB) { + *params = GL_SHADER_OBJECT_ARB; + } + else { + get_shaderiv(ctx, object, pname, params); + } + } + else { + _mesa_error(ctx, GL_INVALID_VALUE, "glGetObjectParameterivARB"); + } +} + + +void GLAPIENTRY +_mesa_GetObjectParameterfvARB(GLhandleARB object, GLenum pname, + GLfloat *params) +{ + GLint iparams[1]; /* XXX is one element enough? */ + _mesa_GetObjectParameterivARB(object, pname, iparams); + params[0] = (GLfloat) iparams[0]; +} + + +void GLAPIENTRY +_mesa_GetProgramiv(GLuint program, GLenum pname, GLint *params) +{ + GET_CURRENT_CONTEXT(ctx); + get_programiv(ctx, program, pname, params); +} + + +void GLAPIENTRY +_mesa_GetShaderiv(GLuint shader, GLenum pname, GLint *params) +{ + GET_CURRENT_CONTEXT(ctx); + get_shaderiv(ctx, shader, pname, params); +} + + +void GLAPIENTRY +_mesa_GetProgramInfoLog(GLuint program, GLsizei bufSize, + GLsizei *length, GLchar *infoLog) +{ + GET_CURRENT_CONTEXT(ctx); + get_program_info_log(ctx, program, bufSize, length, infoLog); +} + + +void GLAPIENTRY +_mesa_GetShaderInfoLog(GLuint shader, GLsizei bufSize, + GLsizei *length, GLchar *infoLog) +{ + GET_CURRENT_CONTEXT(ctx); + get_shader_info_log(ctx, shader, bufSize, length, infoLog); +} + + +void GLAPIENTRY +_mesa_GetShaderSourceARB(GLhandleARB shader, GLsizei maxLength, + GLsizei *length, GLcharARB *sourceOut) +{ + GET_CURRENT_CONTEXT(ctx); + get_shader_source(ctx, shader, maxLength, length, sourceOut); +} + + +GLhandleARB GLAPIENTRY +_mesa_GetHandleARB(GLenum pname) +{ + GET_CURRENT_CONTEXT(ctx); + return get_handle(ctx, pname); +} + + +GLboolean GLAPIENTRY +_mesa_IsProgram(GLuint name) +{ + GET_CURRENT_CONTEXT(ctx); + return is_program(ctx, name); +} + + +GLboolean GLAPIENTRY +_mesa_IsShader(GLuint name) +{ + GET_CURRENT_CONTEXT(ctx); + return is_shader(ctx, name); +} + + +void GLAPIENTRY +_mesa_LinkProgramARB(GLhandleARB programObj) +{ + GET_CURRENT_CONTEXT(ctx); + link_program(ctx, programObj); +} + + + +/** + * Read shader source code from a file. + * Useful for debugging to override an app's shader. + */ +static GLcharARB * +read_shader(const char *fname) +{ + const int max = 50*1000; + FILE *f = fopen(fname, "r"); + GLcharARB *buffer, *shader; + int len; + + if (!f) { + return NULL; + } + + buffer = (char *) malloc(max); + len = fread(buffer, 1, max, f); + buffer[len] = 0; + + fclose(f); + + shader = _mesa_strdup(buffer); + free(buffer); + + return shader; +} + + +/** + * Called via glShaderSource() and glShaderSourceARB() API functions. + * Basically, concatenate the source code strings into one long string + * and pass it to _mesa_shader_source(). + */ +void GLAPIENTRY +_mesa_ShaderSourceARB(GLhandleARB shaderObj, GLsizei count, + const GLcharARB ** string, const GLint * length) +{ + GET_CURRENT_CONTEXT(ctx); + GLint *offsets; + GLsizei i, totalLength; + GLcharARB *source; + GLuint checksum; + + if (!shaderObj || string == NULL) { + _mesa_error(ctx, GL_INVALID_VALUE, "glShaderSourceARB"); + return; + } + + /* + * This array holds offsets of where the appropriate string ends, thus the + * last element will be set to the total length of the source code. + */ + offsets = (GLint *) malloc(count * sizeof(GLint)); + if (offsets == NULL) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glShaderSourceARB"); + return; + } + + for (i = 0; i < count; i++) { + if (string[i] == NULL) { + free((GLvoid *) offsets); + _mesa_error(ctx, GL_INVALID_OPERATION, + "glShaderSourceARB(null string)"); + return; + } + if (length == NULL || length[i] < 0) + offsets[i] = strlen(string[i]); + else + offsets[i] = length[i]; + /* accumulate string lengths */ + if (i > 0) + offsets[i] += offsets[i - 1]; + } + + /* Total length of source string is sum off all strings plus two. + * One extra byte for terminating zero, another extra byte to silence + * valgrind warnings in the parser/grammer code. + */ + totalLength = offsets[count - 1] + 2; + source = (GLcharARB *) malloc(totalLength * sizeof(GLcharARB)); + if (source == NULL) { + free((GLvoid *) offsets); + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glShaderSourceARB"); + return; + } + + for (i = 0; i < count; i++) { + GLint start = (i > 0) ? offsets[i - 1] : 0; + memcpy(source + start, string[i], + (offsets[i] - start) * sizeof(GLcharARB)); + } + source[totalLength - 1] = '\0'; + source[totalLength - 2] = '\0'; + + if (SHADER_SUBST) { + /* Compute the shader's source code checksum then try to open a file + * named newshader_. If it exists, use it in place of the + * original shader source code. For debugging. + */ + char filename[100]; + GLcharARB *newSource; + + checksum = _mesa_str_checksum(source); + + _mesa_snprintf(filename, sizeof(filename), "newshader_%d", checksum); + + newSource = read_shader(filename); + if (newSource) { + fprintf(stderr, "Mesa: Replacing shader %u chksum=%d with %s\n", + shaderObj, checksum, filename); + free(source); + source = newSource; + } + } + + shader_source(ctx, shaderObj, source); + + if (SHADER_SUBST) { + struct gl_shader *sh = _mesa_lookup_shader(ctx, shaderObj); + if (sh) + sh->SourceChecksum = checksum; /* save original checksum */ + } + + free(offsets); +} + + +void GLAPIENTRY +_mesa_UseProgramObjectARB(GLhandleARB program) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_shader_program *shProg; + struct gl_transform_feedback_object *obj = + ctx->TransformFeedback.CurrentObject; + + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (obj->Active) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glUseProgram(transform feedback active)"); + return; + } + + if (program) { + shProg = _mesa_lookup_shader_program_err(ctx, program, "glUseProgram"); + if (!shProg) { + return; + } + if (!shProg->LinkStatus) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glUseProgram(program %u not linked)", program); + return; + } + + /* debug code */ + if (ctx->Shader.Flags & GLSL_USE_PROG) { + print_shader_info(shProg); + } + } + else { + shProg = NULL; + } + + _mesa_use_program(ctx, shProg); +} + + +void GLAPIENTRY +_mesa_ValidateProgramARB(GLhandleARB program) +{ + GET_CURRENT_CONTEXT(ctx); + validate_program(ctx, program); +} + +#ifdef FEATURE_ES2 + +void GLAPIENTRY +_mesa_GetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, + GLint* range, GLint* precision) +{ + const struct gl_program_constants *limits; + const struct gl_precision *p; + GET_CURRENT_CONTEXT(ctx); + + switch (shadertype) { + case GL_VERTEX_SHADER: + limits = &ctx->Const.VertexProgram; + break; + case GL_FRAGMENT_SHADER: + limits = &ctx->Const.FragmentProgram; + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, + "glGetShaderPrecisionFormat(shadertype)"); + return; + } + + switch (precisiontype) { + case GL_LOW_FLOAT: + p = &limits->LowFloat; + break; + case GL_MEDIUM_FLOAT: + p = &limits->MediumFloat; + break; + case GL_HIGH_FLOAT: + p = &limits->HighFloat; + break; + case GL_LOW_INT: + p = &limits->LowInt; + break; + case GL_MEDIUM_INT: + p = &limits->MediumInt; + break; + case GL_HIGH_INT: + p = &limits->HighInt; + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, + "glGetShaderPrecisionFormat(precisiontype)"); + return; + } + + range[0] = p->RangeMin; + range[1] = p->RangeMax; + precision[0] = p->Precision; +} + + +void GLAPIENTRY +_mesa_ReleaseShaderCompiler(void) +{ + _mesa_destroy_shader_compiler_caches(); +} + + +void GLAPIENTRY +_mesa_ShaderBinary(GLint n, const GLuint* shaders, GLenum binaryformat, + const void* binary, GLint length) +{ + GET_CURRENT_CONTEXT(ctx); + (void) n; + (void) shaders; + (void) binaryformat; + (void) binary; + (void) length; + _mesa_error(ctx, GL_INVALID_OPERATION, __FUNCTION__); +} + +#endif /* FEATURE_ES2 */ + + +#if FEATURE_ARB_geometry_shader4 + +void GLAPIENTRY +_mesa_ProgramParameteriARB(GLuint program, GLenum pname, GLint value) +{ + struct gl_shader_program *shProg; + GET_CURRENT_CONTEXT(ctx); + + ASSERT_OUTSIDE_BEGIN_END(ctx); + + shProg = _mesa_lookup_shader_program_err(ctx, program, + "glProgramParameteri"); + if (!shProg) + return; + + switch (pname) { + case GL_GEOMETRY_VERTICES_OUT_ARB: + if (value < 1 || + (unsigned) value > ctx->Const.MaxGeometryOutputVertices) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glProgramParameteri(GL_GEOMETRY_VERTICES_OUT_ARB=%d", + value); + return; + } + shProg->Geom.VerticesOut = value; + break; + case GL_GEOMETRY_INPUT_TYPE_ARB: + switch (value) { + case GL_POINTS: + case GL_LINES: + case GL_LINES_ADJACENCY_ARB: + case GL_TRIANGLES: + case GL_TRIANGLES_ADJACENCY_ARB: + shProg->Geom.InputType = value; + break; + default: + _mesa_error(ctx, GL_INVALID_VALUE, + "glProgramParameteri(geometry input type = %s", + _mesa_lookup_enum_by_nr(value)); + return; + } + break; + case GL_GEOMETRY_OUTPUT_TYPE_ARB: + switch (value) { + case GL_POINTS: + case GL_LINE_STRIP: + case GL_TRIANGLE_STRIP: + shProg->Geom.OutputType = value; + break; + default: + _mesa_error(ctx, GL_INVALID_VALUE, + "glProgramParameteri(geometry output type = %s", + _mesa_lookup_enum_by_nr(value)); + return; + } + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, "glProgramParameteriARB(pname=%s)", + _mesa_lookup_enum_by_nr(pname)); + break; + } +} + +#endif + +void +_mesa_use_shader_program(struct gl_context *ctx, GLenum type, + struct gl_shader_program *shProg) +{ + use_shader_program(ctx, type, shProg); + + if (ctx->Driver.UseProgram) + ctx->Driver.UseProgram(ctx, shProg); +} + +void GLAPIENTRY +_mesa_UseShaderProgramEXT(GLenum type, GLuint program) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_shader_program *shProg = NULL; + + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (!validate_shader_target(ctx, type)) { + _mesa_error(ctx, GL_INVALID_ENUM, "glUseShaderProgramEXT(type)"); + return; + } + + if (ctx->TransformFeedback.CurrentObject->Active) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glUseShaderProgramEXT(transform feedback is active)"); + return; + } + + if (program) { + shProg = _mesa_lookup_shader_program_err(ctx, program, + "glUseShaderProgramEXT"); + if (shProg == NULL) + return; + + if (!shProg->LinkStatus) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glUseShaderProgramEXT(program not linked)"); + return; + } + } + + _mesa_use_shader_program(ctx, type, shProg); +} + +void GLAPIENTRY +_mesa_ActiveProgramEXT(GLuint program) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_shader_program *shProg = (program != 0) + ? _mesa_lookup_shader_program_err(ctx, program, "glActiveProgramEXT") + : NULL; + + _mesa_active_program(ctx, shProg, "glActiveProgramEXT"); + return; +} + +GLuint GLAPIENTRY +_mesa_CreateShaderProgramEXT(GLenum type, const GLchar *string) +{ + GET_CURRENT_CONTEXT(ctx); + const GLuint shader = create_shader(ctx, type); + GLuint program = 0; + + if (shader) { + shader_source(ctx, shader, _mesa_strdup(string)); + compile_shader(ctx, shader); + + program = create_shader_program(ctx); + if (program) { + struct gl_shader_program *shProg; + struct gl_shader *sh; + GLint compiled = GL_FALSE; + + shProg = _mesa_lookup_shader_program(ctx, program); + sh = _mesa_lookup_shader(ctx, shader); + + get_shaderiv(ctx, shader, GL_COMPILE_STATUS, &compiled); + if (compiled) { + attach_shader(ctx, program, shader); + link_program(ctx, program); + detach_shader(ctx, program, shader); + +#if 0 + /* Possibly... */ + if (active-user-defined-varyings-in-linked-program) { + append-error-to-info-log; + shProg->LinkStatus = GL_FALSE; + } +#endif + } + + ralloc_strcat(&shProg->InfoLog, sh->InfoLog); + } + + delete_shader(ctx, shader); + } + + return program; +} + +/** + * Plug in shader-related functions into API dispatch table. + */ +void +_mesa_init_shader_dispatch(struct _glapi_table *exec) +{ +#if FEATURE_GL + /* GL_ARB_vertex/fragment_shader */ + SET_DeleteObjectARB(exec, _mesa_DeleteObjectARB); + SET_GetHandleARB(exec, _mesa_GetHandleARB); + SET_DetachObjectARB(exec, _mesa_DetachObjectARB); + SET_CreateShaderObjectARB(exec, _mesa_CreateShaderObjectARB); + SET_ShaderSourceARB(exec, _mesa_ShaderSourceARB); + SET_CompileShaderARB(exec, _mesa_CompileShaderARB); + SET_CreateProgramObjectARB(exec, _mesa_CreateProgramObjectARB); + SET_AttachObjectARB(exec, _mesa_AttachObjectARB); + SET_LinkProgramARB(exec, _mesa_LinkProgramARB); + SET_UseProgramObjectARB(exec, _mesa_UseProgramObjectARB); + SET_ValidateProgramARB(exec, _mesa_ValidateProgramARB); + SET_GetObjectParameterfvARB(exec, _mesa_GetObjectParameterfvARB); + SET_GetObjectParameterivARB(exec, _mesa_GetObjectParameterivARB); + SET_GetInfoLogARB(exec, _mesa_GetInfoLogARB); + SET_GetAttachedObjectsARB(exec, _mesa_GetAttachedObjectsARB); + SET_GetShaderSourceARB(exec, _mesa_GetShaderSourceARB); + + /* OpenGL 2.0 */ + SET_AttachShader(exec, _mesa_AttachShader); + SET_CreateProgram(exec, _mesa_CreateProgram); + SET_CreateShader(exec, _mesa_CreateShader); + SET_DeleteProgram(exec, _mesa_DeleteProgram); + SET_DeleteShader(exec, _mesa_DeleteShader); + SET_DetachShader(exec, _mesa_DetachShader); + SET_GetAttachedShaders(exec, _mesa_GetAttachedShaders); + SET_GetProgramiv(exec, _mesa_GetProgramiv); + SET_GetProgramInfoLog(exec, _mesa_GetProgramInfoLog); + SET_GetShaderiv(exec, _mesa_GetShaderiv); + SET_GetShaderInfoLog(exec, _mesa_GetShaderInfoLog); + SET_IsProgram(exec, _mesa_IsProgram); + SET_IsShader(exec, _mesa_IsShader); + +#if FEATURE_ARB_vertex_shader + SET_BindAttribLocationARB(exec, _mesa_BindAttribLocationARB); + SET_GetActiveAttribARB(exec, _mesa_GetActiveAttribARB); + SET_GetAttribLocationARB(exec, _mesa_GetAttribLocationARB); +#endif + +#if FEATURE_ARB_geometry_shader4 + SET_ProgramParameteriARB(exec, _mesa_ProgramParameteriARB); +#endif + + SET_UseShaderProgramEXT(exec, _mesa_UseShaderProgramEXT); + SET_ActiveProgramEXT(exec, _mesa_ActiveProgramEXT); + SET_CreateShaderProgramEXT(exec, _mesa_CreateShaderProgramEXT); + + /* GL_EXT_gpu_shader4 / GL 3.0 */ + SET_BindFragDataLocationEXT(exec, _mesa_BindFragDataLocation); + SET_GetFragDataLocationEXT(exec, _mesa_GetFragDataLocation); + + /* GL_ARB_ES2_compatibility */ + SET_ReleaseShaderCompiler(exec, _mesa_ReleaseShaderCompiler); + SET_GetShaderPrecisionFormat(exec, _mesa_GetShaderPrecisionFormat); + +#endif /* FEATURE_GL */ +} + diff --git a/mesalib/src/mesa/main/shared.c b/mesalib/src/mesa/main/shared.c index 3b3a07f34..8b7159db0 100644 --- a/mesalib/src/mesa/main/shared.c +++ b/mesalib/src/mesa/main/shared.c @@ -1,420 +1,420 @@ -/* - * Mesa 3-D graphics library - * Version: 7.5 - * - * 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. - */ - -/** - * \file shared.c - * Shared-context state - */ - -#include "imports.h" -#include "mfeatures.h" -#include "mtypes.h" -#include "hash.h" -#if FEATURE_ATI_fragment_shader -#include "atifragshader.h" -#endif -#include "bufferobj.h" -#include "shared.h" -#include "program/program.h" -#include "dlist.h" -#if FEATURE_ARB_sampler_objects -#include "samplerobj.h" -#endif -#include "shaderobj.h" -#include "syncobj.h" - - -/** - * Allocate and initialize a shared context state structure. - * Initializes the display list, texture objects and vertex programs hash - * tables, allocates the texture objects. If it runs out of memory, frees - * everything already allocated before returning NULL. - * - * \return pointer to a gl_shared_state structure on success, or NULL on - * failure. - */ -struct gl_shared_state * -_mesa_alloc_shared_state(struct gl_context *ctx) -{ - struct gl_shared_state *shared; - GLuint i; - - shared = CALLOC_STRUCT(gl_shared_state); - if (!shared) - return NULL; - - _glthread_INIT_MUTEX(shared->Mutex); - - shared->DisplayList = _mesa_NewHashTable(); - shared->TexObjects = _mesa_NewHashTable(); - shared->Programs = _mesa_NewHashTable(); - -#if FEATURE_ARB_vertex_program - shared->DefaultVertexProgram = (struct gl_vertex_program *) - ctx->Driver.NewProgram(ctx, GL_VERTEX_PROGRAM_ARB, 0); -#endif - -#if FEATURE_ARB_fragment_program - shared->DefaultFragmentProgram = (struct gl_fragment_program *) - ctx->Driver.NewProgram(ctx, GL_FRAGMENT_PROGRAM_ARB, 0); -#endif - -#if FEATURE_ATI_fragment_shader - shared->ATIShaders = _mesa_NewHashTable(); - shared->DefaultFragmentShader = _mesa_new_ati_fragment_shader(ctx, 0); -#endif - -#if FEATURE_ARB_shader_objects - shared->ShaderObjects = _mesa_NewHashTable(); -#endif - -#if FEATURE_ARB_vertex_buffer_object || FEATURE_ARB_pixel_buffer_object - shared->BufferObjects = _mesa_NewHashTable(); -#endif - -#if FEATURE_ARB_sampler_objects - /* GL_ARB_sampler_objects */ - shared->SamplerObjects = _mesa_NewHashTable(); -#endif - - /* Allocate the default buffer object */ - shared->NullBufferObj = ctx->Driver.NewBufferObject(ctx, 0, 0); - - /* Create default texture objects */ - for (i = 0; i < NUM_TEXTURE_TARGETS; i++) { - /* NOTE: the order of these enums matches the TEXTURE_x_INDEX values */ - static const GLenum targets[NUM_TEXTURE_TARGETS] = { - GL_TEXTURE_BUFFER, - GL_TEXTURE_2D_ARRAY_EXT, - GL_TEXTURE_1D_ARRAY_EXT, - GL_TEXTURE_CUBE_MAP, - GL_TEXTURE_3D, - GL_TEXTURE_RECTANGLE_NV, - GL_TEXTURE_2D, - GL_TEXTURE_1D - }; - assert(Elements(targets) == NUM_TEXTURE_TARGETS); - shared->DefaultTex[i] = ctx->Driver.NewTextureObject(ctx, 0, targets[i]); - } - - /* sanity check */ - assert(shared->DefaultTex[TEXTURE_1D_INDEX]->RefCount == 1); - - /* Mutex and timestamp for texobj state validation */ - _glthread_INIT_MUTEX(shared->TexMutex); - shared->TextureStateStamp = 0; - -#if FEATURE_EXT_framebuffer_object - shared->FrameBuffers = _mesa_NewHashTable(); - shared->RenderBuffers = _mesa_NewHashTable(); -#endif - - make_empty_list(& shared->SyncObjects); - - return shared; -} - - -/** - * Callback for deleting a display list. Called by _mesa_HashDeleteAll(). - */ -static void -delete_displaylist_cb(GLuint id, void *data, void *userData) -{ - struct gl_display_list *list = (struct gl_display_list *) data; - struct gl_context *ctx = (struct gl_context *) userData; - _mesa_delete_list(ctx, list); -} - - -/** - * Callback for deleting a texture object. Called by _mesa_HashDeleteAll(). - */ -static void -delete_texture_cb(GLuint id, void *data, void *userData) -{ - struct gl_texture_object *texObj = (struct gl_texture_object *) data; - struct gl_context *ctx = (struct gl_context *) userData; - ctx->Driver.DeleteTexture(ctx, texObj); -} - - -/** - * Callback for deleting a program object. Called by _mesa_HashDeleteAll(). - */ -static void -delete_program_cb(GLuint id, void *data, void *userData) -{ - struct gl_program *prog = (struct gl_program *) data; - struct gl_context *ctx = (struct gl_context *) userData; - if(prog != &_mesa_DummyProgram) { - ASSERT(prog->RefCount == 1); /* should only be referenced by hash table */ - prog->RefCount = 0; /* now going away */ - ctx->Driver.DeleteProgram(ctx, prog); - } -} - - -#if FEATURE_ATI_fragment_shader -/** - * Callback for deleting an ATI fragment shader object. - * Called by _mesa_HashDeleteAll(). - */ -static void -delete_fragshader_cb(GLuint id, void *data, void *userData) -{ - struct ati_fragment_shader *shader = (struct ati_fragment_shader *) data; - struct gl_context *ctx = (struct gl_context *) userData; - _mesa_delete_ati_fragment_shader(ctx, shader); -} -#endif - - -/** - * Callback for deleting a buffer object. Called by _mesa_HashDeleteAll(). - */ -static void -delete_bufferobj_cb(GLuint id, void *data, void *userData) -{ - struct gl_buffer_object *bufObj = (struct gl_buffer_object *) data; - struct gl_context *ctx = (struct gl_context *) userData; - if (_mesa_bufferobj_mapped(bufObj)) { - ctx->Driver.UnmapBuffer(ctx, bufObj); - bufObj->Pointer = NULL; - } - _mesa_reference_buffer_object(ctx, &bufObj, NULL); -} - - -/** - * Callback for freeing shader program data. Call it before delete_shader_cb - * to avoid memory access error. - */ -static void -free_shader_program_data_cb(GLuint id, void *data, void *userData) -{ - struct gl_context *ctx = (struct gl_context *) userData; - struct gl_shader_program *shProg = (struct gl_shader_program *) data; - - if (shProg->Type == GL_SHADER_PROGRAM_MESA) { - _mesa_free_shader_program_data(ctx, shProg); - } -} - - -/** - * Callback for deleting shader and shader programs objects. - * Called by _mesa_HashDeleteAll(). - */ -static void -delete_shader_cb(GLuint id, void *data, void *userData) -{ - struct gl_context *ctx = (struct gl_context *) userData; - struct gl_shader *sh = (struct gl_shader *) data; - if (sh->Type == GL_FRAGMENT_SHADER || sh->Type == GL_VERTEX_SHADER) { - ctx->Driver.DeleteShader(ctx, sh); - } - else { - struct gl_shader_program *shProg = (struct gl_shader_program *) data; - ASSERT(shProg->Type == GL_SHADER_PROGRAM_MESA); - ctx->Driver.DeleteShaderProgram(ctx, shProg); - } -} - - -/** - * Callback for deleting a framebuffer object. Called by _mesa_HashDeleteAll() - */ -static void -delete_framebuffer_cb(GLuint id, void *data, void *userData) -{ - struct gl_framebuffer *fb = (struct gl_framebuffer *) data; - /* The fact that the framebuffer is in the hashtable means its refcount - * is one, but we're removing from the hashtable now. So clear refcount. - */ - /*assert(fb->RefCount == 1);*/ - fb->RefCount = 0; - - /* NOTE: Delete should always be defined but there are two reports - * of it being NULL (bugs 13507, 14293). Work-around for now. - */ - if (fb->Delete) - fb->Delete(fb); -} - - -/** - * Callback for deleting a renderbuffer object. Called by _mesa_HashDeleteAll() - */ -static void -delete_renderbuffer_cb(GLuint id, void *data, void *userData) -{ - struct gl_renderbuffer *rb = (struct gl_renderbuffer *) data; - rb->RefCount = 0; /* see comment for FBOs above */ - if (rb->Delete) - rb->Delete(rb); -} - - -#if FEATURE_ARB_sampler_objects -/** - * Callback for deleting a sampler object. Called by _mesa_HashDeleteAll() - */ -static void -delete_sampler_object_cb(GLuint id, void *data, void *userData) -{ - struct gl_context *ctx = (struct gl_context *) userData; - struct gl_sampler_object *sampObj = (struct gl_sampler_object *) data; - _mesa_reference_sampler_object(ctx, &sampObj, NULL); -} -#endif - - -/** - * Deallocate a shared state object and all children structures. - * - * \param ctx GL context. - * \param shared shared state pointer. - * - * Frees the display lists, the texture objects (calling the driver texture - * deletion callback to free its private data) and the vertex programs, as well - * as their hash tables. - * - * \sa alloc_shared_state(). - */ -static void -free_shared_state(struct gl_context *ctx, struct gl_shared_state *shared) -{ - GLuint i; - - /* Free the dummy/fallback texture object */ - if (shared->FallbackTex) - ctx->Driver.DeleteTexture(ctx, shared->FallbackTex); - - /* - * Free display lists - */ - _mesa_HashDeleteAll(shared->DisplayList, delete_displaylist_cb, ctx); - _mesa_DeleteHashTable(shared->DisplayList); - -#if FEATURE_ARB_shader_objects - _mesa_HashWalk(shared->ShaderObjects, free_shader_program_data_cb, ctx); - _mesa_HashDeleteAll(shared->ShaderObjects, delete_shader_cb, ctx); - _mesa_DeleteHashTable(shared->ShaderObjects); -#endif - - _mesa_HashDeleteAll(shared->Programs, delete_program_cb, ctx); - _mesa_DeleteHashTable(shared->Programs); - -#if FEATURE_ARB_vertex_program - _mesa_reference_vertprog(ctx, &shared->DefaultVertexProgram, NULL); -#endif - -#if FEATURE_ARB_fragment_program - _mesa_reference_fragprog(ctx, &shared->DefaultFragmentProgram, NULL); -#endif - -#if FEATURE_ATI_fragment_shader - _mesa_HashDeleteAll(shared->ATIShaders, delete_fragshader_cb, ctx); - _mesa_DeleteHashTable(shared->ATIShaders); - _mesa_delete_ati_fragment_shader(ctx, shared->DefaultFragmentShader); -#endif - -#if FEATURE_ARB_vertex_buffer_object || FEATURE_ARB_pixel_buffer_object - _mesa_HashDeleteAll(shared->BufferObjects, delete_bufferobj_cb, ctx); - _mesa_DeleteHashTable(shared->BufferObjects); -#endif - -#if FEATURE_EXT_framebuffer_object - _mesa_HashDeleteAll(shared->FrameBuffers, delete_framebuffer_cb, ctx); - _mesa_DeleteHashTable(shared->FrameBuffers); - _mesa_HashDeleteAll(shared->RenderBuffers, delete_renderbuffer_cb, ctx); - _mesa_DeleteHashTable(shared->RenderBuffers); -#endif - -#if FEATURE_ARB_vertex_buffer_object - _mesa_reference_buffer_object(ctx, &shared->NullBufferObj, NULL); -#endif - - { - struct simple_node *node; - struct simple_node *temp; - - foreach_s(node, temp, & shared->SyncObjects) { - _mesa_unref_sync_object(ctx, (struct gl_sync_object *) node); - } - } - -#if FEATURE_ARB_sampler_objects - _mesa_HashDeleteAll(shared->SamplerObjects, delete_sampler_object_cb, ctx); - _mesa_DeleteHashTable(shared->SamplerObjects); -#endif - - /* - * Free texture objects (after FBOs since some textures might have - * been bound to FBOs). - */ - ASSERT(ctx->Driver.DeleteTexture); - /* the default textures */ - for (i = 0; i < NUM_TEXTURE_TARGETS; i++) { - ctx->Driver.DeleteTexture(ctx, shared->DefaultTex[i]); - } - - /* all other textures */ - _mesa_HashDeleteAll(shared->TexObjects, delete_texture_cb, ctx); - _mesa_DeleteHashTable(shared->TexObjects); - - _glthread_DESTROY_MUTEX(shared->Mutex); - _glthread_DESTROY_MUTEX(shared->TexMutex); - - free(shared); -} - - -/** - * Decrement shared state object reference count and potentially free it - * and all children structures. - * - * \param ctx GL context. - * \param shared shared state pointer. - * - * \sa free_shared_state(). - */ -void -_mesa_release_shared_state(struct gl_context *ctx, - struct gl_shared_state *shared) -{ - GLint RefCount; - - _glthread_LOCK_MUTEX(shared->Mutex); - RefCount = --shared->RefCount; - _glthread_UNLOCK_MUTEX(shared->Mutex); - - assert(RefCount >= 0); - - if (RefCount == 0) { - /* free shared state */ - free_shared_state( ctx, shared ); - } -} +/* + * Mesa 3-D graphics library + * Version: 7.5 + * + * 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. + */ + +/** + * \file shared.c + * Shared-context state + */ + +#include "imports.h" +#include "mfeatures.h" +#include "mtypes.h" +#include "hash.h" +#if FEATURE_ATI_fragment_shader +#include "atifragshader.h" +#endif +#include "bufferobj.h" +#include "shared.h" +#include "program/program.h" +#include "dlist.h" +#if FEATURE_ARB_sampler_objects +#include "samplerobj.h" +#endif +#include "shaderobj.h" +#include "syncobj.h" + + +/** + * Allocate and initialize a shared context state structure. + * Initializes the display list, texture objects and vertex programs hash + * tables, allocates the texture objects. If it runs out of memory, frees + * everything already allocated before returning NULL. + * + * \return pointer to a gl_shared_state structure on success, or NULL on + * failure. + */ +struct gl_shared_state * +_mesa_alloc_shared_state(struct gl_context *ctx) +{ + struct gl_shared_state *shared; + GLuint i; + + shared = CALLOC_STRUCT(gl_shared_state); + if (!shared) + return NULL; + + _glthread_INIT_MUTEX(shared->Mutex); + + shared->DisplayList = _mesa_NewHashTable(); + shared->TexObjects = _mesa_NewHashTable(); + shared->Programs = _mesa_NewHashTable(); + +#if FEATURE_ARB_vertex_program + shared->DefaultVertexProgram = (struct gl_vertex_program *) + ctx->Driver.NewProgram(ctx, GL_VERTEX_PROGRAM_ARB, 0); +#endif + +#if FEATURE_ARB_fragment_program + shared->DefaultFragmentProgram = (struct gl_fragment_program *) + ctx->Driver.NewProgram(ctx, GL_FRAGMENT_PROGRAM_ARB, 0); +#endif + +#if FEATURE_ATI_fragment_shader + shared->ATIShaders = _mesa_NewHashTable(); + shared->DefaultFragmentShader = _mesa_new_ati_fragment_shader(ctx, 0); +#endif + +#if FEATURE_ARB_shader_objects + shared->ShaderObjects = _mesa_NewHashTable(); +#endif + +#if FEATURE_ARB_vertex_buffer_object || FEATURE_ARB_pixel_buffer_object + shared->BufferObjects = _mesa_NewHashTable(); +#endif + +#if FEATURE_ARB_sampler_objects + /* GL_ARB_sampler_objects */ + shared->SamplerObjects = _mesa_NewHashTable(); +#endif + + /* Allocate the default buffer object */ + shared->NullBufferObj = ctx->Driver.NewBufferObject(ctx, 0, 0); + + /* Create default texture objects */ + for (i = 0; i < NUM_TEXTURE_TARGETS; i++) { + /* NOTE: the order of these enums matches the TEXTURE_x_INDEX values */ + static const GLenum targets[NUM_TEXTURE_TARGETS] = { + GL_TEXTURE_BUFFER, + GL_TEXTURE_2D_ARRAY_EXT, + GL_TEXTURE_1D_ARRAY_EXT, + GL_TEXTURE_CUBE_MAP, + GL_TEXTURE_3D, + GL_TEXTURE_RECTANGLE_NV, + GL_TEXTURE_2D, + GL_TEXTURE_1D + }; + assert(Elements(targets) == NUM_TEXTURE_TARGETS); + shared->DefaultTex[i] = ctx->Driver.NewTextureObject(ctx, 0, targets[i]); + } + + /* sanity check */ + assert(shared->DefaultTex[TEXTURE_1D_INDEX]->RefCount == 1); + + /* Mutex and timestamp for texobj state validation */ + _glthread_INIT_MUTEX(shared->TexMutex); + shared->TextureStateStamp = 0; + +#if FEATURE_EXT_framebuffer_object + shared->FrameBuffers = _mesa_NewHashTable(); + shared->RenderBuffers = _mesa_NewHashTable(); +#endif + + make_empty_list(& shared->SyncObjects); + + return shared; +} + + +/** + * Callback for deleting a display list. Called by _mesa_HashDeleteAll(). + */ +static void +delete_displaylist_cb(GLuint id, void *data, void *userData) +{ + struct gl_display_list *list = (struct gl_display_list *) data; + struct gl_context *ctx = (struct gl_context *) userData; + _mesa_delete_list(ctx, list); +} + + +/** + * Callback for deleting a texture object. Called by _mesa_HashDeleteAll(). + */ +static void +delete_texture_cb(GLuint id, void *data, void *userData) +{ + struct gl_texture_object *texObj = (struct gl_texture_object *) data; + struct gl_context *ctx = (struct gl_context *) userData; + ctx->Driver.DeleteTexture(ctx, texObj); +} + + +/** + * Callback for deleting a program object. Called by _mesa_HashDeleteAll(). + */ +static void +delete_program_cb(GLuint id, void *data, void *userData) +{ + struct gl_program *prog = (struct gl_program *) data; + struct gl_context *ctx = (struct gl_context *) userData; + if(prog != &_mesa_DummyProgram) { + ASSERT(prog->RefCount == 1); /* should only be referenced by hash table */ + prog->RefCount = 0; /* now going away */ + ctx->Driver.DeleteProgram(ctx, prog); + } +} + + +#if FEATURE_ATI_fragment_shader +/** + * Callback for deleting an ATI fragment shader object. + * Called by _mesa_HashDeleteAll(). + */ +static void +delete_fragshader_cb(GLuint id, void *data, void *userData) +{ + struct ati_fragment_shader *shader = (struct ati_fragment_shader *) data; + struct gl_context *ctx = (struct gl_context *) userData; + _mesa_delete_ati_fragment_shader(ctx, shader); +} +#endif + + +/** + * Callback for deleting a buffer object. Called by _mesa_HashDeleteAll(). + */ +static void +delete_bufferobj_cb(GLuint id, void *data, void *userData) +{ + struct gl_buffer_object *bufObj = (struct gl_buffer_object *) data; + struct gl_context *ctx = (struct gl_context *) userData; + if (_mesa_bufferobj_mapped(bufObj)) { + ctx->Driver.UnmapBuffer(ctx, bufObj); + bufObj->Pointer = NULL; + } + _mesa_reference_buffer_object(ctx, &bufObj, NULL); +} + + +/** + * Callback for freeing shader program data. Call it before delete_shader_cb + * to avoid memory access error. + */ +static void +free_shader_program_data_cb(GLuint id, void *data, void *userData) +{ + struct gl_context *ctx = (struct gl_context *) userData; + struct gl_shader_program *shProg = (struct gl_shader_program *) data; + + if (shProg->Type == GL_SHADER_PROGRAM_MESA) { + _mesa_free_shader_program_data(ctx, shProg); + } +} + + +/** + * Callback for deleting shader and shader programs objects. + * Called by _mesa_HashDeleteAll(). + */ +static void +delete_shader_cb(GLuint id, void *data, void *userData) +{ + struct gl_context *ctx = (struct gl_context *) userData; + struct gl_shader *sh = (struct gl_shader *) data; + if (sh->Type == GL_FRAGMENT_SHADER || sh->Type == GL_VERTEX_SHADER) { + ctx->Driver.DeleteShader(ctx, sh); + } + else { + struct gl_shader_program *shProg = (struct gl_shader_program *) data; + ASSERT(shProg->Type == GL_SHADER_PROGRAM_MESA); + ctx->Driver.DeleteShaderProgram(ctx, shProg); + } +} + + +/** + * Callback for deleting a framebuffer object. Called by _mesa_HashDeleteAll() + */ +static void +delete_framebuffer_cb(GLuint id, void *data, void *userData) +{ + struct gl_framebuffer *fb = (struct gl_framebuffer *) data; + /* The fact that the framebuffer is in the hashtable means its refcount + * is one, but we're removing from the hashtable now. So clear refcount. + */ + /*assert(fb->RefCount == 1);*/ + fb->RefCount = 0; + + /* NOTE: Delete should always be defined but there are two reports + * of it being NULL (bugs 13507, 14293). Work-around for now. + */ + if (fb->Delete) + fb->Delete(fb); +} + + +/** + * Callback for deleting a renderbuffer object. Called by _mesa_HashDeleteAll() + */ +static void +delete_renderbuffer_cb(GLuint id, void *data, void *userData) +{ + struct gl_renderbuffer *rb = (struct gl_renderbuffer *) data; + rb->RefCount = 0; /* see comment for FBOs above */ + if (rb->Delete) + rb->Delete(rb); +} + + +#if FEATURE_ARB_sampler_objects +/** + * Callback for deleting a sampler object. Called by _mesa_HashDeleteAll() + */ +static void +delete_sampler_object_cb(GLuint id, void *data, void *userData) +{ + struct gl_context *ctx = (struct gl_context *) userData; + struct gl_sampler_object *sampObj = (struct gl_sampler_object *) data; + _mesa_reference_sampler_object(ctx, &sampObj, NULL); +} +#endif + + +/** + * Deallocate a shared state object and all children structures. + * + * \param ctx GL context. + * \param shared shared state pointer. + * + * Frees the display lists, the texture objects (calling the driver texture + * deletion callback to free its private data) and the vertex programs, as well + * as their hash tables. + * + * \sa alloc_shared_state(). + */ +static void +free_shared_state(struct gl_context *ctx, struct gl_shared_state *shared) +{ + GLuint i; + + /* Free the dummy/fallback texture object */ + if (shared->FallbackTex) + ctx->Driver.DeleteTexture(ctx, shared->FallbackTex); + + /* + * Free display lists + */ + _mesa_HashDeleteAll(shared->DisplayList, delete_displaylist_cb, ctx); + _mesa_DeleteHashTable(shared->DisplayList); + +#if FEATURE_ARB_shader_objects + _mesa_HashWalk(shared->ShaderObjects, free_shader_program_data_cb, ctx); + _mesa_HashDeleteAll(shared->ShaderObjects, delete_shader_cb, ctx); + _mesa_DeleteHashTable(shared->ShaderObjects); +#endif + + _mesa_HashDeleteAll(shared->Programs, delete_program_cb, ctx); + _mesa_DeleteHashTable(shared->Programs); + +#if FEATURE_ARB_vertex_program + _mesa_reference_vertprog(ctx, &shared->DefaultVertexProgram, NULL); +#endif + +#if FEATURE_ARB_fragment_program + _mesa_reference_fragprog(ctx, &shared->DefaultFragmentProgram, NULL); +#endif + +#if FEATURE_ATI_fragment_shader + _mesa_HashDeleteAll(shared->ATIShaders, delete_fragshader_cb, ctx); + _mesa_DeleteHashTable(shared->ATIShaders); + _mesa_delete_ati_fragment_shader(ctx, shared->DefaultFragmentShader); +#endif + +#if FEATURE_ARB_vertex_buffer_object || FEATURE_ARB_pixel_buffer_object + _mesa_HashDeleteAll(shared->BufferObjects, delete_bufferobj_cb, ctx); + _mesa_DeleteHashTable(shared->BufferObjects); +#endif + +#if FEATURE_EXT_framebuffer_object + _mesa_HashDeleteAll(shared->FrameBuffers, delete_framebuffer_cb, ctx); + _mesa_DeleteHashTable(shared->FrameBuffers); + _mesa_HashDeleteAll(shared->RenderBuffers, delete_renderbuffer_cb, ctx); + _mesa_DeleteHashTable(shared->RenderBuffers); +#endif + +#if FEATURE_ARB_vertex_buffer_object + _mesa_reference_buffer_object(ctx, &shared->NullBufferObj, NULL); +#endif + + { + struct simple_node *node; + struct simple_node *temp; + + foreach_s(node, temp, & shared->SyncObjects) { + _mesa_unref_sync_object(ctx, (struct gl_sync_object *) node); + } + } + +#if FEATURE_ARB_sampler_objects + _mesa_HashDeleteAll(shared->SamplerObjects, delete_sampler_object_cb, ctx); + _mesa_DeleteHashTable(shared->SamplerObjects); +#endif + + /* + * Free texture objects (after FBOs since some textures might have + * been bound to FBOs). + */ + ASSERT(ctx->Driver.DeleteTexture); + /* the default textures */ + for (i = 0; i < NUM_TEXTURE_TARGETS; i++) { + ctx->Driver.DeleteTexture(ctx, shared->DefaultTex[i]); + } + + /* all other textures */ + _mesa_HashDeleteAll(shared->TexObjects, delete_texture_cb, ctx); + _mesa_DeleteHashTable(shared->TexObjects); + + _glthread_DESTROY_MUTEX(shared->Mutex); + _glthread_DESTROY_MUTEX(shared->TexMutex); + + free(shared); +} + + +/** + * Decrement shared state object reference count and potentially free it + * and all children structures. + * + * \param ctx GL context. + * \param shared shared state pointer. + * + * \sa free_shared_state(). + */ +void +_mesa_release_shared_state(struct gl_context *ctx, + struct gl_shared_state *shared) +{ + GLint RefCount; + + _glthread_LOCK_MUTEX(shared->Mutex); + RefCount = --shared->RefCount; + _glthread_UNLOCK_MUTEX(shared->Mutex); + + assert(RefCount >= 0); + + if (RefCount == 0) { + /* free shared state */ + free_shared_state( ctx, shared ); + } +} diff --git a/mesalib/src/mesa/main/shared.h b/mesalib/src/mesa/main/shared.h index 4e0ca2203..55516a8c3 100644 --- a/mesalib/src/mesa/main/shared.h +++ b/mesalib/src/mesa/main/shared.h @@ -1,39 +1,39 @@ -/* - * Mesa 3-D graphics library - * Version: 7.5 - * - * 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. - */ - -#ifndef SHARED_H -#define SHARED_H - -struct gl_context; - -struct gl_shared_state * -_mesa_alloc_shared_state(struct gl_context *ctx); - - -void -_mesa_release_shared_state(struct gl_context *ctx, - struct gl_shared_state *shared); - - -#endif +/* + * Mesa 3-D graphics library + * Version: 7.5 + * + * 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. + */ + +#ifndef SHARED_H +#define SHARED_H + +struct gl_context; + +struct gl_shared_state * +_mesa_alloc_shared_state(struct gl_context *ctx); + + +void +_mesa_release_shared_state(struct gl_context *ctx, + struct gl_shared_state *shared); + + +#endif diff --git a/mesalib/src/mesa/main/state.c b/mesalib/src/mesa/main/state.c index 9c82bfaf0..457a730de 100644 --- a/mesalib/src/mesa/main/state.c +++ b/mesalib/src/mesa/main/state.c @@ -1,760 +1,760 @@ -/* - * Mesa 3-D graphics library - * Version: 7.3 - * - * 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 state.c - * State management. - * - * This file manages recalculation of derived values in struct gl_context. - */ - - -#include "glheader.h" -#include "mtypes.h" -#include "context.h" -#include "debug.h" -#include "macros.h" -#include "ffvertex_prog.h" -#include "framebuffer.h" -#include "light.h" -#include "matrix.h" -#include "pixel.h" -#include "program/program.h" -#include "program/prog_parameter.h" -#include "state.h" -#include "stencil.h" -#include "texenvprogram.h" -#include "texobj.h" -#include "texstate.h" -#include "varray.h" - - -static void -update_separate_specular(struct gl_context *ctx) -{ - if (_mesa_need_secondary_color(ctx)) - ctx->_TriangleCaps |= DD_SEPARATE_SPECULAR; - else - ctx->_TriangleCaps &= ~DD_SEPARATE_SPECULAR; -} - - -/** - * Helper for update_arrays(). - * \return min(current min, array->_MaxElement). - */ -static GLuint -update_min(GLuint min, struct gl_client_array *array) -{ - _mesa_update_array_max_element(array); - return MIN2(min, array->_MaxElement); -} - - -/** - * Update ctx->Array._MaxElement (the max legal index into all enabled arrays). - * Need to do this upon new array state or new buffer object state. - */ -static void -update_arrays( struct gl_context *ctx ) -{ - struct gl_array_object *arrayObj = ctx->Array.ArrayObj; - GLuint i, min = ~0; - - /* find min of _MaxElement values for all enabled arrays */ - - /* 0 */ - if (ctx->VertexProgram._Current - && arrayObj->VertexAttrib[VERT_ATTRIB_POS].Enabled) { - min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_POS]); - } - else if (arrayObj->Vertex.Enabled) { - min = update_min(min, &arrayObj->Vertex); - } - - /* 1 */ - if (ctx->VertexProgram._Enabled - && arrayObj->VertexAttrib[VERT_ATTRIB_WEIGHT].Enabled) { - min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_WEIGHT]); - } - /* no conventional vertex weight array */ - - /* 2 */ - if (ctx->VertexProgram._Enabled - && arrayObj->VertexAttrib[VERT_ATTRIB_NORMAL].Enabled) { - min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_NORMAL]); - } - else if (arrayObj->Normal.Enabled) { - min = update_min(min, &arrayObj->Normal); - } - - /* 3 */ - if (ctx->VertexProgram._Enabled - && arrayObj->VertexAttrib[VERT_ATTRIB_COLOR0].Enabled) { - min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_COLOR0]); - } - else if (arrayObj->Color.Enabled) { - min = update_min(min, &arrayObj->Color); - } - - /* 4 */ - if (ctx->VertexProgram._Enabled - && arrayObj->VertexAttrib[VERT_ATTRIB_COLOR1].Enabled) { - min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_COLOR1]); - } - else if (arrayObj->SecondaryColor.Enabled) { - min = update_min(min, &arrayObj->SecondaryColor); - } - - /* 5 */ - if (ctx->VertexProgram._Enabled - && arrayObj->VertexAttrib[VERT_ATTRIB_FOG].Enabled) { - min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_FOG]); - } - else if (arrayObj->FogCoord.Enabled) { - min = update_min(min, &arrayObj->FogCoord); - } - - /* 6 */ - if (ctx->VertexProgram._Enabled - && arrayObj->VertexAttrib[VERT_ATTRIB_COLOR_INDEX].Enabled) { - min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_COLOR_INDEX]); - } - else if (arrayObj->Index.Enabled) { - min = update_min(min, &arrayObj->Index); - } - - /* 7 */ - if (ctx->VertexProgram._Enabled - && arrayObj->VertexAttrib[VERT_ATTRIB_EDGEFLAG].Enabled) { - min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_EDGEFLAG]); - } - - /* 8..15 */ - for (i = VERT_ATTRIB_TEX0; i <= VERT_ATTRIB_TEX7; i++) { - if (ctx->VertexProgram._Enabled - && arrayObj->VertexAttrib[i].Enabled) { - min = update_min(min, &arrayObj->VertexAttrib[i]); - } - else if (i - VERT_ATTRIB_TEX0 < ctx->Const.MaxTextureCoordUnits - && arrayObj->TexCoord[i - VERT_ATTRIB_TEX0].Enabled) { - min = update_min(min, &arrayObj->TexCoord[i - VERT_ATTRIB_TEX0]); - } - } - - /* 16..31 */ - if (ctx->VertexProgram._Current) { - for (i = 0; i < Elements(arrayObj->VertexAttrib); i++) { - if (arrayObj->VertexAttrib[i].Enabled) { - min = update_min(min, &arrayObj->VertexAttrib[i]); - } - } - } - - if (arrayObj->EdgeFlag.Enabled) { - min = update_min(min, &arrayObj->EdgeFlag); - } - - /* _MaxElement is one past the last legal array element */ - arrayObj->_MaxElement = min; -} - - -/** - * Update the following fields: - * ctx->VertexProgram._Enabled - * ctx->FragmentProgram._Enabled - * ctx->ATIFragmentShader._Enabled - * This needs to be done before texture state validation. - */ -static void -update_program_enables(struct gl_context *ctx) -{ - /* These _Enabled flags indicate if the user-defined ARB/NV vertex/fragment - * program is enabled AND valid. Similarly for ATI fragment shaders. - * GLSL shaders not relevant here. - */ - ctx->VertexProgram._Enabled = ctx->VertexProgram.Enabled - && ctx->VertexProgram.Current->Base.Instructions; - ctx->FragmentProgram._Enabled = ctx->FragmentProgram.Enabled - && ctx->FragmentProgram.Current->Base.Instructions; - ctx->ATIFragmentShader._Enabled = ctx->ATIFragmentShader.Enabled - && ctx->ATIFragmentShader.Current->Instructions[0]; -} - - -/** - * Update the ctx->Vertex/Geometry/FragmentProgram._Current pointers to point - * to the current/active programs. Then call ctx->Driver.BindProgram() to - * tell the driver which programs to use. - * - * Programs may come from 3 sources: GLSL shaders, ARB/NV_vertex/fragment - * programs or programs derived from fixed-function state. - * - * This function needs to be called after texture state validation in case - * we're generating a fragment program from fixed-function texture state. - * - * \return bitfield which will indicate _NEW_PROGRAM state if a new vertex - * or fragment program is being used. - */ -static GLbitfield -update_program(struct gl_context *ctx) -{ - const struct gl_shader_program *vsProg = ctx->Shader.CurrentVertexProgram; - const struct gl_shader_program *gsProg = ctx->Shader.CurrentGeometryProgram; - const struct gl_shader_program *fsProg = ctx->Shader.CurrentFragmentProgram; - const struct gl_vertex_program *prevVP = ctx->VertexProgram._Current; - const struct gl_fragment_program *prevFP = ctx->FragmentProgram._Current; - const struct gl_geometry_program *prevGP = ctx->GeometryProgram._Current; - GLbitfield new_state = 0x0; - - /* - * Set the ctx->VertexProgram._Current and ctx->FragmentProgram._Current - * pointers to the programs that should be used for rendering. If either - * is NULL, use fixed-function code paths. - * - * These programs may come from several sources. The priority is as - * follows: - * 1. OpenGL 2.0/ARB vertex/fragment shaders - * 2. ARB/NV vertex/fragment programs - * 3. Programs derived from fixed-function state. - * - * Note: it's possible for a vertex shader to get used with a fragment - * program (and vice versa) here, but in practice that shouldn't ever - * come up, or matter. - */ - - if (fsProg && fsProg->LinkStatus && fsProg->FragmentProgram) { - /* Use GLSL fragment shader */ - _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current, - fsProg->FragmentProgram); - } - else if (ctx->FragmentProgram._Enabled) { - /* Use user-defined fragment program */ - _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current, - ctx->FragmentProgram.Current); - } - else if (ctx->FragmentProgram._MaintainTexEnvProgram) { - /* Use fragment program generated from fixed-function state */ - _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current, - _mesa_get_fixed_func_fragment_program(ctx)); - _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._TexEnvProgram, - ctx->FragmentProgram._Current); - } - else { - /* No fragment program */ - _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current, NULL); - } - - if (gsProg && gsProg->LinkStatus && gsProg->GeometryProgram) { - /* Use GLSL geometry shader */ - _mesa_reference_geomprog(ctx, &ctx->GeometryProgram._Current, - gsProg->GeometryProgram); - } else { - /* No geometry program */ - _mesa_reference_geomprog(ctx, &ctx->GeometryProgram._Current, NULL); - } - - /* Examine vertex program after fragment program as - * _mesa_get_fixed_func_vertex_program() needs to know active - * fragprog inputs. - */ - if (vsProg && vsProg->LinkStatus && vsProg->VertexProgram) { - /* Use GLSL vertex shader */ - _mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current, - vsProg->VertexProgram); - } - else if (ctx->VertexProgram._Enabled) { - /* Use user-defined vertex program */ - _mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current, - ctx->VertexProgram.Current); - } - else if (ctx->VertexProgram._MaintainTnlProgram) { - /* Use vertex program generated from fixed-function state */ - _mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current, - _mesa_get_fixed_func_vertex_program(ctx)); - _mesa_reference_vertprog(ctx, &ctx->VertexProgram._TnlProgram, - ctx->VertexProgram._Current); - } - else { - /* no vertex program */ - _mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current, NULL); - } - - /* Let the driver know what's happening: - */ - if (ctx->FragmentProgram._Current != prevFP) { - new_state |= _NEW_PROGRAM; - if (ctx->Driver.BindProgram) { - ctx->Driver.BindProgram(ctx, GL_FRAGMENT_PROGRAM_ARB, - (struct gl_program *) ctx->FragmentProgram._Current); - } - } - - if (ctx->GeometryProgram._Current != prevGP) { - new_state |= _NEW_PROGRAM; - if (ctx->Driver.BindProgram) { - ctx->Driver.BindProgram(ctx, MESA_GEOMETRY_PROGRAM, - (struct gl_program *) ctx->GeometryProgram._Current); - } - } - - if (ctx->VertexProgram._Current != prevVP) { - new_state |= _NEW_PROGRAM; - if (ctx->Driver.BindProgram) { - ctx->Driver.BindProgram(ctx, GL_VERTEX_PROGRAM_ARB, - (struct gl_program *) ctx->VertexProgram._Current); - } - } - - return new_state; -} - - -/** - * Examine shader constants and return either _NEW_PROGRAM_CONSTANTS or 0. - */ -static GLbitfield -update_program_constants(struct gl_context *ctx) -{ - GLbitfield new_state = 0x0; - - if (ctx->FragmentProgram._Current) { - const struct gl_program_parameter_list *params = - ctx->FragmentProgram._Current->Base.Parameters; - if (params && params->StateFlags & ctx->NewState) { - new_state |= _NEW_PROGRAM_CONSTANTS; - } - } - - if (ctx->GeometryProgram._Current) { - const struct gl_program_parameter_list *params = - ctx->GeometryProgram._Current->Base.Parameters; - /*FIXME: StateFlags is always 0 because we have unnamed constant - * not state changes */ - if (params /*&& params->StateFlags & ctx->NewState*/) { - new_state |= _NEW_PROGRAM_CONSTANTS; - } - } - - if (ctx->VertexProgram._Current) { - const struct gl_program_parameter_list *params = - ctx->VertexProgram._Current->Base.Parameters; - if (params && params->StateFlags & ctx->NewState) { - new_state |= _NEW_PROGRAM_CONSTANTS; - } - } - - return new_state; -} - - - - -static void -update_viewport_matrix(struct gl_context *ctx) -{ - const GLfloat depthMax = ctx->DrawBuffer->_DepthMaxF; - - ASSERT(depthMax > 0); - - /* Compute scale and bias values. This is really driver-specific - * and should be maintained elsewhere if at all. - * NOTE: RasterPos uses this. - */ - _math_matrix_viewport(&ctx->Viewport._WindowMap, - ctx->Viewport.X, ctx->Viewport.Y, - ctx->Viewport.Width, ctx->Viewport.Height, - ctx->Viewport.Near, ctx->Viewport.Far, - depthMax); -} - - -/** - * Update derived multisample state. - */ -static void -update_multisample(struct gl_context *ctx) -{ - ctx->Multisample._Enabled = GL_FALSE; - if (ctx->Multisample.Enabled && - ctx->DrawBuffer && - ctx->DrawBuffer->Visual.sampleBuffers) - ctx->Multisample._Enabled = GL_TRUE; -} - - -/** - * Update derived color/blend/logicop state. - */ -static void -update_color(struct gl_context *ctx) -{ - /* This is needed to support 1.1's RGB logic ops AND - * 1.0's blending logicops. - */ - ctx->Color._LogicOpEnabled = _mesa_rgba_logicop_enabled(ctx); -} - - -/** - * Update the ctx->Color._ClampFragmentColor field - */ -static void -update_clamp_fragment_color(struct gl_context *ctx) -{ - if (ctx->Color.ClampFragmentColor == GL_FIXED_ONLY_ARB) - ctx->Color._ClampFragmentColor = - !ctx->DrawBuffer || !ctx->DrawBuffer->Visual.floatMode; - else - ctx->Color._ClampFragmentColor = ctx->Color.ClampFragmentColor; -} - - -/** - * Update the ctx->Color._ClampVertexColor field - */ -static void -update_clamp_vertex_color(struct gl_context *ctx) -{ - if (ctx->Light.ClampVertexColor == GL_FIXED_ONLY_ARB) - ctx->Light._ClampVertexColor = - !ctx->DrawBuffer || !ctx->DrawBuffer->Visual.floatMode; - else - ctx->Light._ClampVertexColor = ctx->Light.ClampVertexColor; -} - - -/** - * Update the ctx->Color._ClampReadColor field - */ -static void -update_clamp_read_color(struct gl_context *ctx) -{ - if (ctx->Color.ClampReadColor == GL_FIXED_ONLY_ARB) - ctx->Color._ClampReadColor = - !ctx->ReadBuffer || !ctx->ReadBuffer->Visual.floatMode; - else - ctx->Color._ClampReadColor = ctx->Color.ClampReadColor; -} - - - - -/* - * Check polygon state and set DD_TRI_CULL_FRONT_BACK and/or DD_TRI_OFFSET - * in ctx->_TriangleCaps if needed. - */ -static void -update_polygon(struct gl_context *ctx) -{ - ctx->_TriangleCaps &= ~(DD_TRI_CULL_FRONT_BACK | DD_TRI_OFFSET); - - if (ctx->Polygon.CullFlag && ctx->Polygon.CullFaceMode == GL_FRONT_AND_BACK) - ctx->_TriangleCaps |= DD_TRI_CULL_FRONT_BACK; - - if ( ctx->Polygon.OffsetPoint - || ctx->Polygon.OffsetLine - || ctx->Polygon.OffsetFill) - ctx->_TriangleCaps |= DD_TRI_OFFSET; -} - - -/** - * Update the ctx->_TriangleCaps bitfield. - * XXX that bitfield should really go away someday! - * This function must be called after other update_*() functions since - * there are dependencies on some other derived values. - */ -#if 0 -static void -update_tricaps(struct gl_context *ctx, GLbitfield new_state) -{ - ctx->_TriangleCaps = 0; - - /* - * Points - */ - if (1/*new_state & _NEW_POINT*/) { - if (ctx->Point.SmoothFlag) - ctx->_TriangleCaps |= DD_POINT_SMOOTH; - if (ctx->Point._Attenuated) - ctx->_TriangleCaps |= DD_POINT_ATTEN; - } - - /* - * Lines - */ - if (1/*new_state & _NEW_LINE*/) { - if (ctx->Line.SmoothFlag) - ctx->_TriangleCaps |= DD_LINE_SMOOTH; - if (ctx->Line.StippleFlag) - ctx->_TriangleCaps |= DD_LINE_STIPPLE; - } - - /* - * Polygons - */ - if (1/*new_state & _NEW_POLYGON*/) { - if (ctx->Polygon.SmoothFlag) - ctx->_TriangleCaps |= DD_TRI_SMOOTH; - if (ctx->Polygon.StippleFlag) - ctx->_TriangleCaps |= DD_TRI_STIPPLE; - if (ctx->Polygon.FrontMode != GL_FILL - || ctx->Polygon.BackMode != GL_FILL) - ctx->_TriangleCaps |= DD_TRI_UNFILLED; - if (ctx->Polygon.CullFlag - && ctx->Polygon.CullFaceMode == GL_FRONT_AND_BACK) - ctx->_TriangleCaps |= DD_TRI_CULL_FRONT_BACK; - if (ctx->Polygon.OffsetPoint || - ctx->Polygon.OffsetLine || - ctx->Polygon.OffsetFill) - ctx->_TriangleCaps |= DD_TRI_OFFSET; - } - - /* - * Lighting and shading - */ - if (ctx->Light.Enabled && ctx->Light.Model.TwoSide) - ctx->_TriangleCaps |= DD_TRI_LIGHT_TWOSIDE; - if (ctx->Light.ShadeModel == GL_FLAT) - ctx->_TriangleCaps |= DD_FLATSHADE; - if (_mesa_need_secondary_color(ctx)) - ctx->_TriangleCaps |= DD_SEPARATE_SPECULAR; - - /* - * Stencil - */ - if (ctx->Stencil._TestTwoSide) - ctx->_TriangleCaps |= DD_TRI_TWOSTENCIL; -} -#endif - - -/** - * Compute derived GL state. - * If __struct gl_contextRec::NewState is non-zero then this function \b must - * be called before rendering anything. - * - * Calls dd_function_table::UpdateState to perform any internal state - * management necessary. - * - * \sa _mesa_update_modelview_project(), _mesa_update_texture(), - * _mesa_update_buffer_bounds(), - * _mesa_update_lighting() and _mesa_update_tnl_spaces(). - */ -void -_mesa_update_state_locked( struct gl_context *ctx ) -{ - GLbitfield new_state = ctx->NewState; - GLbitfield prog_flags = _NEW_PROGRAM; - GLbitfield new_prog_state = 0x0; - - if (new_state == _NEW_CURRENT_ATTRIB) - goto out; - - if (MESA_VERBOSE & VERBOSE_STATE) - _mesa_print_state("_mesa_update_state", new_state); - - /* Determine which state flags effect vertex/fragment program state */ - if (ctx->FragmentProgram._MaintainTexEnvProgram) { - prog_flags |= (_NEW_BUFFERS | _NEW_TEXTURE | _NEW_FOG | - _NEW_ARRAY | _NEW_LIGHT | _NEW_POINT | _NEW_RENDERMODE | - _NEW_PROGRAM | _NEW_FRAG_CLAMP); - } - if (ctx->VertexProgram._MaintainTnlProgram) { - prog_flags |= (_NEW_ARRAY | _NEW_TEXTURE | _NEW_TEXTURE_MATRIX | - _NEW_TRANSFORM | _NEW_POINT | - _NEW_FOG | _NEW_LIGHT | - _MESA_NEW_NEED_EYE_COORDS); - } - - /* - * Now update derived state info - */ - - if (new_state & prog_flags) - update_program_enables( ctx ); - - if (new_state & (_NEW_MODELVIEW|_NEW_PROJECTION)) - _mesa_update_modelview_project( ctx, new_state ); - - if (new_state & (_NEW_PROGRAM|_NEW_TEXTURE|_NEW_TEXTURE_MATRIX)) - _mesa_update_texture( ctx, new_state ); - - if (new_state & _NEW_BUFFERS) - _mesa_update_framebuffer(ctx); - - if (new_state & (_NEW_SCISSOR | _NEW_BUFFERS | _NEW_VIEWPORT)) - _mesa_update_draw_buffer_bounds( ctx ); - - if (new_state & _NEW_POLYGON) - update_polygon( ctx ); - - if (new_state & _NEW_LIGHT) - _mesa_update_lighting( ctx ); - - if (new_state & (_NEW_LIGHT | _NEW_BUFFERS)) - update_clamp_vertex_color(ctx); - - if (new_state & (_NEW_STENCIL | _NEW_BUFFERS)) - _mesa_update_stencil( ctx ); - - if (new_state & _NEW_PIXEL) - _mesa_update_pixel( ctx, new_state ); - - if (new_state & _DD_NEW_SEPARATE_SPECULAR) - update_separate_specular( ctx ); - - if (new_state & (_NEW_BUFFERS | _NEW_VIEWPORT)) - update_viewport_matrix(ctx); - - if (new_state & (_NEW_MULTISAMPLE | _NEW_BUFFERS)) - update_multisample( ctx ); - - if (new_state & _NEW_COLOR) - update_color( ctx ); - - if (new_state & (_NEW_COLOR | _NEW_BUFFERS)) - update_clamp_read_color(ctx); - - if(new_state & (_NEW_FRAG_CLAMP | _NEW_BUFFERS)) - update_clamp_fragment_color(ctx); - -#if 0 - if (new_state & (_NEW_POINT | _NEW_LINE | _NEW_POLYGON | _NEW_LIGHT - | _NEW_STENCIL | _DD_NEW_SEPARATE_SPECULAR)) - update_tricaps( ctx, new_state ); -#endif - - /* ctx->_NeedEyeCoords is now up to date. - * - * If the truth value of this variable has changed, update for the - * new lighting space and recompute the positions of lights and the - * normal transform. - * - * If the lighting space hasn't changed, may still need to recompute - * light positions & normal transforms for other reasons. - */ - if (new_state & _MESA_NEW_NEED_EYE_COORDS) - _mesa_update_tnl_spaces( ctx, new_state ); - - if (new_state & prog_flags) { - /* When we generate programs from fixed-function vertex/fragment state - * this call may generate/bind a new program. If so, we need to - * propogate the _NEW_PROGRAM flag to the driver. - */ - new_prog_state |= update_program( ctx ); - } - - if (new_state & (_NEW_ARRAY | _NEW_PROGRAM | _NEW_BUFFER_OBJECT)) - update_arrays( ctx ); - - out: - new_prog_state |= update_program_constants(ctx); - - /* - * Give the driver a chance to act upon the new_state flags. - * The driver might plug in different span functions, for example. - * Also, this is where the driver can invalidate the state of any - * active modules (such as swrast_setup, swrast, tnl, etc). - * - * Set ctx->NewState to zero to avoid recursion if - * Driver.UpdateState() has to call FLUSH_VERTICES(). (fixed?) - */ - new_state = ctx->NewState | new_prog_state; - ctx->NewState = 0; - ctx->Driver.UpdateState(ctx, new_state); - ctx->Array.NewState = 0; - if (!ctx->Array.RebindArrays) - ctx->Array.RebindArrays = (new_state & (_NEW_ARRAY | _NEW_PROGRAM)) != 0; -} - - -/* This is the usual entrypoint for state updates: - */ -void -_mesa_update_state( struct gl_context *ctx ) -{ - _mesa_lock_context_textures(ctx); - _mesa_update_state_locked(ctx); - _mesa_unlock_context_textures(ctx); -} - - - - -/** - * Want to figure out which fragment program inputs are actually - * constant/current values from ctx->Current. These should be - * referenced as a tracked state variable rather than a fragment - * program input, to save the overhead of putting a constant value in - * every submitted vertex, transferring it to hardware, interpolating - * it across the triangle, etc... - * - * When there is a VP bound, just use vp->outputs. But when we're - * generating vp from fixed function state, basically want to - * calculate: - * - * vp_out_2_fp_in( vp_in_2_vp_out( varying_inputs ) | - * potential_vp_outputs ) - * - * Where potential_vp_outputs is calculated by looking at enabled - * texgen, etc. - * - * The generated fragment program should then only declare inputs that - * may vary or otherwise differ from the ctx->Current values. - * Otherwise, the fp should track them as state values instead. - */ -void -_mesa_set_varying_vp_inputs( struct gl_context *ctx, - GLbitfield varying_inputs ) -{ - if (ctx->varying_vp_inputs != varying_inputs) { - ctx->varying_vp_inputs = varying_inputs; - ctx->NewState |= _NEW_ARRAY; - /*printf("%s %x\n", __FUNCTION__, varying_inputs);*/ - } -} - - -/** - * Used by drivers to tell core Mesa that the driver is going to - * install/ use its own vertex program. In particular, this will - * prevent generated fragment programs from using state vars instead - * of ordinary varyings/inputs. - */ -void -_mesa_set_vp_override(struct gl_context *ctx, GLboolean flag) -{ - if (ctx->VertexProgram._Overriden != flag) { - ctx->VertexProgram._Overriden = flag; - - /* Set one of the bits which will trigger fragment program - * regeneration: - */ - ctx->NewState |= _NEW_PROGRAM; - } -} +/* + * Mesa 3-D graphics library + * Version: 7.3 + * + * 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 state.c + * State management. + * + * This file manages recalculation of derived values in struct gl_context. + */ + + +#include "glheader.h" +#include "mtypes.h" +#include "context.h" +#include "debug.h" +#include "macros.h" +#include "ffvertex_prog.h" +#include "framebuffer.h" +#include "light.h" +#include "matrix.h" +#include "pixel.h" +#include "program/program.h" +#include "program/prog_parameter.h" +#include "state.h" +#include "stencil.h" +#include "texenvprogram.h" +#include "texobj.h" +#include "texstate.h" +#include "varray.h" + + +static void +update_separate_specular(struct gl_context *ctx) +{ + if (_mesa_need_secondary_color(ctx)) + ctx->_TriangleCaps |= DD_SEPARATE_SPECULAR; + else + ctx->_TriangleCaps &= ~DD_SEPARATE_SPECULAR; +} + + +/** + * Helper for update_arrays(). + * \return min(current min, array->_MaxElement). + */ +static GLuint +update_min(GLuint min, struct gl_client_array *array) +{ + _mesa_update_array_max_element(array); + return MIN2(min, array->_MaxElement); +} + + +/** + * Update ctx->Array._MaxElement (the max legal index into all enabled arrays). + * Need to do this upon new array state or new buffer object state. + */ +static void +update_arrays( struct gl_context *ctx ) +{ + struct gl_array_object *arrayObj = ctx->Array.ArrayObj; + GLuint i, min = ~0; + + /* find min of _MaxElement values for all enabled arrays */ + + /* 0 */ + if (ctx->VertexProgram._Current + && arrayObj->VertexAttrib[VERT_ATTRIB_POS].Enabled) { + min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_POS]); + } + else if (arrayObj->Vertex.Enabled) { + min = update_min(min, &arrayObj->Vertex); + } + + /* 1 */ + if (ctx->VertexProgram._Enabled + && arrayObj->VertexAttrib[VERT_ATTRIB_WEIGHT].Enabled) { + min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_WEIGHT]); + } + /* no conventional vertex weight array */ + + /* 2 */ + if (ctx->VertexProgram._Enabled + && arrayObj->VertexAttrib[VERT_ATTRIB_NORMAL].Enabled) { + min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_NORMAL]); + } + else if (arrayObj->Normal.Enabled) { + min = update_min(min, &arrayObj->Normal); + } + + /* 3 */ + if (ctx->VertexProgram._Enabled + && arrayObj->VertexAttrib[VERT_ATTRIB_COLOR0].Enabled) { + min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_COLOR0]); + } + else if (arrayObj->Color.Enabled) { + min = update_min(min, &arrayObj->Color); + } + + /* 4 */ + if (ctx->VertexProgram._Enabled + && arrayObj->VertexAttrib[VERT_ATTRIB_COLOR1].Enabled) { + min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_COLOR1]); + } + else if (arrayObj->SecondaryColor.Enabled) { + min = update_min(min, &arrayObj->SecondaryColor); + } + + /* 5 */ + if (ctx->VertexProgram._Enabled + && arrayObj->VertexAttrib[VERT_ATTRIB_FOG].Enabled) { + min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_FOG]); + } + else if (arrayObj->FogCoord.Enabled) { + min = update_min(min, &arrayObj->FogCoord); + } + + /* 6 */ + if (ctx->VertexProgram._Enabled + && arrayObj->VertexAttrib[VERT_ATTRIB_COLOR_INDEX].Enabled) { + min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_COLOR_INDEX]); + } + else if (arrayObj->Index.Enabled) { + min = update_min(min, &arrayObj->Index); + } + + /* 7 */ + if (ctx->VertexProgram._Enabled + && arrayObj->VertexAttrib[VERT_ATTRIB_EDGEFLAG].Enabled) { + min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_EDGEFLAG]); + } + + /* 8..15 */ + for (i = VERT_ATTRIB_TEX0; i <= VERT_ATTRIB_TEX7; i++) { + if (ctx->VertexProgram._Enabled + && arrayObj->VertexAttrib[i].Enabled) { + min = update_min(min, &arrayObj->VertexAttrib[i]); + } + else if (i - VERT_ATTRIB_TEX0 < ctx->Const.MaxTextureCoordUnits + && arrayObj->TexCoord[i - VERT_ATTRIB_TEX0].Enabled) { + min = update_min(min, &arrayObj->TexCoord[i - VERT_ATTRIB_TEX0]); + } + } + + /* 16..31 */ + if (ctx->VertexProgram._Current) { + for (i = 0; i < Elements(arrayObj->VertexAttrib); i++) { + if (arrayObj->VertexAttrib[i].Enabled) { + min = update_min(min, &arrayObj->VertexAttrib[i]); + } + } + } + + if (arrayObj->EdgeFlag.Enabled) { + min = update_min(min, &arrayObj->EdgeFlag); + } + + /* _MaxElement is one past the last legal array element */ + arrayObj->_MaxElement = min; +} + + +/** + * Update the following fields: + * ctx->VertexProgram._Enabled + * ctx->FragmentProgram._Enabled + * ctx->ATIFragmentShader._Enabled + * This needs to be done before texture state validation. + */ +static void +update_program_enables(struct gl_context *ctx) +{ + /* These _Enabled flags indicate if the user-defined ARB/NV vertex/fragment + * program is enabled AND valid. Similarly for ATI fragment shaders. + * GLSL shaders not relevant here. + */ + ctx->VertexProgram._Enabled = ctx->VertexProgram.Enabled + && ctx->VertexProgram.Current->Base.Instructions; + ctx->FragmentProgram._Enabled = ctx->FragmentProgram.Enabled + && ctx->FragmentProgram.Current->Base.Instructions; + ctx->ATIFragmentShader._Enabled = ctx->ATIFragmentShader.Enabled + && ctx->ATIFragmentShader.Current->Instructions[0]; +} + + +/** + * Update the ctx->Vertex/Geometry/FragmentProgram._Current pointers to point + * to the current/active programs. Then call ctx->Driver.BindProgram() to + * tell the driver which programs to use. + * + * Programs may come from 3 sources: GLSL shaders, ARB/NV_vertex/fragment + * programs or programs derived from fixed-function state. + * + * This function needs to be called after texture state validation in case + * we're generating a fragment program from fixed-function texture state. + * + * \return bitfield which will indicate _NEW_PROGRAM state if a new vertex + * or fragment program is being used. + */ +static GLbitfield +update_program(struct gl_context *ctx) +{ + const struct gl_shader_program *vsProg = ctx->Shader.CurrentVertexProgram; + const struct gl_shader_program *gsProg = ctx->Shader.CurrentGeometryProgram; + const struct gl_shader_program *fsProg = ctx->Shader.CurrentFragmentProgram; + const struct gl_vertex_program *prevVP = ctx->VertexProgram._Current; + const struct gl_fragment_program *prevFP = ctx->FragmentProgram._Current; + const struct gl_geometry_program *prevGP = ctx->GeometryProgram._Current; + GLbitfield new_state = 0x0; + + /* + * Set the ctx->VertexProgram._Current and ctx->FragmentProgram._Current + * pointers to the programs that should be used for rendering. If either + * is NULL, use fixed-function code paths. + * + * These programs may come from several sources. The priority is as + * follows: + * 1. OpenGL 2.0/ARB vertex/fragment shaders + * 2. ARB/NV vertex/fragment programs + * 3. Programs derived from fixed-function state. + * + * Note: it's possible for a vertex shader to get used with a fragment + * program (and vice versa) here, but in practice that shouldn't ever + * come up, or matter. + */ + + if (fsProg && fsProg->LinkStatus && fsProg->FragmentProgram) { + /* Use GLSL fragment shader */ + _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current, + fsProg->FragmentProgram); + } + else if (ctx->FragmentProgram._Enabled) { + /* Use user-defined fragment program */ + _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current, + ctx->FragmentProgram.Current); + } + else if (ctx->FragmentProgram._MaintainTexEnvProgram) { + /* Use fragment program generated from fixed-function state */ + _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current, + _mesa_get_fixed_func_fragment_program(ctx)); + _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._TexEnvProgram, + ctx->FragmentProgram._Current); + } + else { + /* No fragment program */ + _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current, NULL); + } + + if (gsProg && gsProg->LinkStatus && gsProg->GeometryProgram) { + /* Use GLSL geometry shader */ + _mesa_reference_geomprog(ctx, &ctx->GeometryProgram._Current, + gsProg->GeometryProgram); + } else { + /* No geometry program */ + _mesa_reference_geomprog(ctx, &ctx->GeometryProgram._Current, NULL); + } + + /* Examine vertex program after fragment program as + * _mesa_get_fixed_func_vertex_program() needs to know active + * fragprog inputs. + */ + if (vsProg && vsProg->LinkStatus && vsProg->VertexProgram) { + /* Use GLSL vertex shader */ + _mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current, + vsProg->VertexProgram); + } + else if (ctx->VertexProgram._Enabled) { + /* Use user-defined vertex program */ + _mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current, + ctx->VertexProgram.Current); + } + else if (ctx->VertexProgram._MaintainTnlProgram) { + /* Use vertex program generated from fixed-function state */ + _mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current, + _mesa_get_fixed_func_vertex_program(ctx)); + _mesa_reference_vertprog(ctx, &ctx->VertexProgram._TnlProgram, + ctx->VertexProgram._Current); + } + else { + /* no vertex program */ + _mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current, NULL); + } + + /* Let the driver know what's happening: + */ + if (ctx->FragmentProgram._Current != prevFP) { + new_state |= _NEW_PROGRAM; + if (ctx->Driver.BindProgram) { + ctx->Driver.BindProgram(ctx, GL_FRAGMENT_PROGRAM_ARB, + (struct gl_program *) ctx->FragmentProgram._Current); + } + } + + if (ctx->GeometryProgram._Current != prevGP) { + new_state |= _NEW_PROGRAM; + if (ctx->Driver.BindProgram) { + ctx->Driver.BindProgram(ctx, MESA_GEOMETRY_PROGRAM, + (struct gl_program *) ctx->GeometryProgram._Current); + } + } + + if (ctx->VertexProgram._Current != prevVP) { + new_state |= _NEW_PROGRAM; + if (ctx->Driver.BindProgram) { + ctx->Driver.BindProgram(ctx, GL_VERTEX_PROGRAM_ARB, + (struct gl_program *) ctx->VertexProgram._Current); + } + } + + return new_state; +} + + +/** + * Examine shader constants and return either _NEW_PROGRAM_CONSTANTS or 0. + */ +static GLbitfield +update_program_constants(struct gl_context *ctx) +{ + GLbitfield new_state = 0x0; + + if (ctx->FragmentProgram._Current) { + const struct gl_program_parameter_list *params = + ctx->FragmentProgram._Current->Base.Parameters; + if (params && params->StateFlags & ctx->NewState) { + new_state |= _NEW_PROGRAM_CONSTANTS; + } + } + + if (ctx->GeometryProgram._Current) { + const struct gl_program_parameter_list *params = + ctx->GeometryProgram._Current->Base.Parameters; + /*FIXME: StateFlags is always 0 because we have unnamed constant + * not state changes */ + if (params /*&& params->StateFlags & ctx->NewState*/) { + new_state |= _NEW_PROGRAM_CONSTANTS; + } + } + + if (ctx->VertexProgram._Current) { + const struct gl_program_parameter_list *params = + ctx->VertexProgram._Current->Base.Parameters; + if (params && params->StateFlags & ctx->NewState) { + new_state |= _NEW_PROGRAM_CONSTANTS; + } + } + + return new_state; +} + + + + +static void +update_viewport_matrix(struct gl_context *ctx) +{ + const GLfloat depthMax = ctx->DrawBuffer->_DepthMaxF; + + ASSERT(depthMax > 0); + + /* Compute scale and bias values. This is really driver-specific + * and should be maintained elsewhere if at all. + * NOTE: RasterPos uses this. + */ + _math_matrix_viewport(&ctx->Viewport._WindowMap, + ctx->Viewport.X, ctx->Viewport.Y, + ctx->Viewport.Width, ctx->Viewport.Height, + ctx->Viewport.Near, ctx->Viewport.Far, + depthMax); +} + + +/** + * Update derived multisample state. + */ +static void +update_multisample(struct gl_context *ctx) +{ + ctx->Multisample._Enabled = GL_FALSE; + if (ctx->Multisample.Enabled && + ctx->DrawBuffer && + ctx->DrawBuffer->Visual.sampleBuffers) + ctx->Multisample._Enabled = GL_TRUE; +} + + +/** + * Update derived color/blend/logicop state. + */ +static void +update_color(struct gl_context *ctx) +{ + /* This is needed to support 1.1's RGB logic ops AND + * 1.0's blending logicops. + */ + ctx->Color._LogicOpEnabled = _mesa_rgba_logicop_enabled(ctx); +} + + +/** + * Update the ctx->Color._ClampFragmentColor field + */ +static void +update_clamp_fragment_color(struct gl_context *ctx) +{ + if (ctx->Color.ClampFragmentColor == GL_FIXED_ONLY_ARB) + ctx->Color._ClampFragmentColor = + !ctx->DrawBuffer || !ctx->DrawBuffer->Visual.floatMode; + else + ctx->Color._ClampFragmentColor = ctx->Color.ClampFragmentColor; +} + + +/** + * Update the ctx->Color._ClampVertexColor field + */ +static void +update_clamp_vertex_color(struct gl_context *ctx) +{ + if (ctx->Light.ClampVertexColor == GL_FIXED_ONLY_ARB) + ctx->Light._ClampVertexColor = + !ctx->DrawBuffer || !ctx->DrawBuffer->Visual.floatMode; + else + ctx->Light._ClampVertexColor = ctx->Light.ClampVertexColor; +} + + +/** + * Update the ctx->Color._ClampReadColor field + */ +static void +update_clamp_read_color(struct gl_context *ctx) +{ + if (ctx->Color.ClampReadColor == GL_FIXED_ONLY_ARB) + ctx->Color._ClampReadColor = + !ctx->ReadBuffer || !ctx->ReadBuffer->Visual.floatMode; + else + ctx->Color._ClampReadColor = ctx->Color.ClampReadColor; +} + + + + +/* + * Check polygon state and set DD_TRI_CULL_FRONT_BACK and/or DD_TRI_OFFSET + * in ctx->_TriangleCaps if needed. + */ +static void +update_polygon(struct gl_context *ctx) +{ + ctx->_TriangleCaps &= ~(DD_TRI_CULL_FRONT_BACK | DD_TRI_OFFSET); + + if (ctx->Polygon.CullFlag && ctx->Polygon.CullFaceMode == GL_FRONT_AND_BACK) + ctx->_TriangleCaps |= DD_TRI_CULL_FRONT_BACK; + + if ( ctx->Polygon.OffsetPoint + || ctx->Polygon.OffsetLine + || ctx->Polygon.OffsetFill) + ctx->_TriangleCaps |= DD_TRI_OFFSET; +} + + +/** + * Update the ctx->_TriangleCaps bitfield. + * XXX that bitfield should really go away someday! + * This function must be called after other update_*() functions since + * there are dependencies on some other derived values. + */ +#if 0 +static void +update_tricaps(struct gl_context *ctx, GLbitfield new_state) +{ + ctx->_TriangleCaps = 0; + + /* + * Points + */ + if (1/*new_state & _NEW_POINT*/) { + if (ctx->Point.SmoothFlag) + ctx->_TriangleCaps |= DD_POINT_SMOOTH; + if (ctx->Point._Attenuated) + ctx->_TriangleCaps |= DD_POINT_ATTEN; + } + + /* + * Lines + */ + if (1/*new_state & _NEW_LINE*/) { + if (ctx->Line.SmoothFlag) + ctx->_TriangleCaps |= DD_LINE_SMOOTH; + if (ctx->Line.StippleFlag) + ctx->_TriangleCaps |= DD_LINE_STIPPLE; + } + + /* + * Polygons + */ + if (1/*new_state & _NEW_POLYGON*/) { + if (ctx->Polygon.SmoothFlag) + ctx->_TriangleCaps |= DD_TRI_SMOOTH; + if (ctx->Polygon.StippleFlag) + ctx->_TriangleCaps |= DD_TRI_STIPPLE; + if (ctx->Polygon.FrontMode != GL_FILL + || ctx->Polygon.BackMode != GL_FILL) + ctx->_TriangleCaps |= DD_TRI_UNFILLED; + if (ctx->Polygon.CullFlag + && ctx->Polygon.CullFaceMode == GL_FRONT_AND_BACK) + ctx->_TriangleCaps |= DD_TRI_CULL_FRONT_BACK; + if (ctx->Polygon.OffsetPoint || + ctx->Polygon.OffsetLine || + ctx->Polygon.OffsetFill) + ctx->_TriangleCaps |= DD_TRI_OFFSET; + } + + /* + * Lighting and shading + */ + if (ctx->Light.Enabled && ctx->Light.Model.TwoSide) + ctx->_TriangleCaps |= DD_TRI_LIGHT_TWOSIDE; + if (ctx->Light.ShadeModel == GL_FLAT) + ctx->_TriangleCaps |= DD_FLATSHADE; + if (_mesa_need_secondary_color(ctx)) + ctx->_TriangleCaps |= DD_SEPARATE_SPECULAR; + + /* + * Stencil + */ + if (ctx->Stencil._TestTwoSide) + ctx->_TriangleCaps |= DD_TRI_TWOSTENCIL; +} +#endif + + +/** + * Compute derived GL state. + * If __struct gl_contextRec::NewState is non-zero then this function \b must + * be called before rendering anything. + * + * Calls dd_function_table::UpdateState to perform any internal state + * management necessary. + * + * \sa _mesa_update_modelview_project(), _mesa_update_texture(), + * _mesa_update_buffer_bounds(), + * _mesa_update_lighting() and _mesa_update_tnl_spaces(). + */ +void +_mesa_update_state_locked( struct gl_context *ctx ) +{ + GLbitfield new_state = ctx->NewState; + GLbitfield prog_flags = _NEW_PROGRAM; + GLbitfield new_prog_state = 0x0; + + if (new_state == _NEW_CURRENT_ATTRIB) + goto out; + + if (MESA_VERBOSE & VERBOSE_STATE) + _mesa_print_state("_mesa_update_state", new_state); + + /* Determine which state flags effect vertex/fragment program state */ + if (ctx->FragmentProgram._MaintainTexEnvProgram) { + prog_flags |= (_NEW_BUFFERS | _NEW_TEXTURE | _NEW_FOG | + _NEW_ARRAY | _NEW_LIGHT | _NEW_POINT | _NEW_RENDERMODE | + _NEW_PROGRAM | _NEW_FRAG_CLAMP); + } + if (ctx->VertexProgram._MaintainTnlProgram) { + prog_flags |= (_NEW_ARRAY | _NEW_TEXTURE | _NEW_TEXTURE_MATRIX | + _NEW_TRANSFORM | _NEW_POINT | + _NEW_FOG | _NEW_LIGHT | + _MESA_NEW_NEED_EYE_COORDS); + } + + /* + * Now update derived state info + */ + + if (new_state & prog_flags) + update_program_enables( ctx ); + + if (new_state & (_NEW_MODELVIEW|_NEW_PROJECTION)) + _mesa_update_modelview_project( ctx, new_state ); + + if (new_state & (_NEW_PROGRAM|_NEW_TEXTURE|_NEW_TEXTURE_MATRIX)) + _mesa_update_texture( ctx, new_state ); + + if (new_state & _NEW_BUFFERS) + _mesa_update_framebuffer(ctx); + + if (new_state & (_NEW_SCISSOR | _NEW_BUFFERS | _NEW_VIEWPORT)) + _mesa_update_draw_buffer_bounds( ctx ); + + if (new_state & _NEW_POLYGON) + update_polygon( ctx ); + + if (new_state & _NEW_LIGHT) + _mesa_update_lighting( ctx ); + + if (new_state & (_NEW_LIGHT | _NEW_BUFFERS)) + update_clamp_vertex_color(ctx); + + if (new_state & (_NEW_STENCIL | _NEW_BUFFERS)) + _mesa_update_stencil( ctx ); + + if (new_state & _NEW_PIXEL) + _mesa_update_pixel( ctx, new_state ); + + if (new_state & _DD_NEW_SEPARATE_SPECULAR) + update_separate_specular( ctx ); + + if (new_state & (_NEW_BUFFERS | _NEW_VIEWPORT)) + update_viewport_matrix(ctx); + + if (new_state & (_NEW_MULTISAMPLE | _NEW_BUFFERS)) + update_multisample( ctx ); + + if (new_state & _NEW_COLOR) + update_color( ctx ); + + if (new_state & (_NEW_COLOR | _NEW_BUFFERS)) + update_clamp_read_color(ctx); + + if(new_state & (_NEW_FRAG_CLAMP | _NEW_BUFFERS)) + update_clamp_fragment_color(ctx); + +#if 0 + if (new_state & (_NEW_POINT | _NEW_LINE | _NEW_POLYGON | _NEW_LIGHT + | _NEW_STENCIL | _DD_NEW_SEPARATE_SPECULAR)) + update_tricaps( ctx, new_state ); +#endif + + /* ctx->_NeedEyeCoords is now up to date. + * + * If the truth value of this variable has changed, update for the + * new lighting space and recompute the positions of lights and the + * normal transform. + * + * If the lighting space hasn't changed, may still need to recompute + * light positions & normal transforms for other reasons. + */ + if (new_state & _MESA_NEW_NEED_EYE_COORDS) + _mesa_update_tnl_spaces( ctx, new_state ); + + if (new_state & prog_flags) { + /* When we generate programs from fixed-function vertex/fragment state + * this call may generate/bind a new program. If so, we need to + * propogate the _NEW_PROGRAM flag to the driver. + */ + new_prog_state |= update_program( ctx ); + } + + if (new_state & (_NEW_ARRAY | _NEW_PROGRAM | _NEW_BUFFER_OBJECT)) + update_arrays( ctx ); + + out: + new_prog_state |= update_program_constants(ctx); + + /* + * Give the driver a chance to act upon the new_state flags. + * The driver might plug in different span functions, for example. + * Also, this is where the driver can invalidate the state of any + * active modules (such as swrast_setup, swrast, tnl, etc). + * + * Set ctx->NewState to zero to avoid recursion if + * Driver.UpdateState() has to call FLUSH_VERTICES(). (fixed?) + */ + new_state = ctx->NewState | new_prog_state; + ctx->NewState = 0; + ctx->Driver.UpdateState(ctx, new_state); + ctx->Array.NewState = 0; + if (!ctx->Array.RebindArrays) + ctx->Array.RebindArrays = (new_state & (_NEW_ARRAY | _NEW_PROGRAM)) != 0; +} + + +/* This is the usual entrypoint for state updates: + */ +void +_mesa_update_state( struct gl_context *ctx ) +{ + _mesa_lock_context_textures(ctx); + _mesa_update_state_locked(ctx); + _mesa_unlock_context_textures(ctx); +} + + + + +/** + * Want to figure out which fragment program inputs are actually + * constant/current values from ctx->Current. These should be + * referenced as a tracked state variable rather than a fragment + * program input, to save the overhead of putting a constant value in + * every submitted vertex, transferring it to hardware, interpolating + * it across the triangle, etc... + * + * When there is a VP bound, just use vp->outputs. But when we're + * generating vp from fixed function state, basically want to + * calculate: + * + * vp_out_2_fp_in( vp_in_2_vp_out( varying_inputs ) | + * potential_vp_outputs ) + * + * Where potential_vp_outputs is calculated by looking at enabled + * texgen, etc. + * + * The generated fragment program should then only declare inputs that + * may vary or otherwise differ from the ctx->Current values. + * Otherwise, the fp should track them as state values instead. + */ +void +_mesa_set_varying_vp_inputs( struct gl_context *ctx, + GLbitfield varying_inputs ) +{ + if (ctx->varying_vp_inputs != varying_inputs) { + ctx->varying_vp_inputs = varying_inputs; + ctx->NewState |= _NEW_ARRAY; + /*printf("%s %x\n", __FUNCTION__, varying_inputs);*/ + } +} + + +/** + * Used by drivers to tell core Mesa that the driver is going to + * install/ use its own vertex program. In particular, this will + * prevent generated fragment programs from using state vars instead + * of ordinary varyings/inputs. + */ +void +_mesa_set_vp_override(struct gl_context *ctx, GLboolean flag) +{ + if (ctx->VertexProgram._Overriden != flag) { + ctx->VertexProgram._Overriden = flag; + + /* Set one of the bits which will trigger fragment program + * regeneration: + */ + ctx->NewState |= _NEW_PROGRAM; + } +} diff --git a/mesalib/src/mesa/main/stencil.c b/mesalib/src/mesa/main/stencil.c index b49ddbdbb..d898bf1d7 100644 --- a/mesalib/src/mesa/main/stencil.c +++ b/mesalib/src/mesa/main/stencil.c @@ -1,614 +1,614 @@ -/* - * 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. - */ - - -/** - * \file stencil.c - * Stencil operations. - * - * Note: There's some conflict between GL_EXT_stencil_two_side and - * OpenGL 2.0's two-sided stencil feature. - * - * With GL_EXT_stencil_two_side, calling glStencilOp/Func/Mask() only the - * front OR back face state (as set by glActiveStencilFaceEXT) is set. - * - * But with OpenGL 2.0, calling glStencilOp/Func/Mask() sets BOTH the - * front AND back state. - * - * Also, note that GL_ATI_separate_stencil is different as well: - * glStencilFuncSeparateATI(GLenum frontfunc, GLenum backfunc, ...) vs. - * glStencilFuncSeparate(GLenum face, GLenum func, ...). - * - * This problem is solved by keeping three sets of stencil state: - * state[0] = GL_FRONT state. - * state[1] = OpenGL 2.0 / GL_ATI_separate_stencil GL_BACK state. - * state[2] = GL_EXT_stencil_two_side GL_BACK state. - */ - - -#include "glheader.h" -#include "imports.h" -#include "context.h" -#include "macros.h" -#include "stencil.h" -#include "mtypes.h" - - -static GLboolean -validate_stencil_op(struct gl_context *ctx, GLenum op) -{ - switch (op) { - case GL_KEEP: - case GL_ZERO: - case GL_REPLACE: - case GL_INCR: - case GL_DECR: - case GL_INVERT: - return GL_TRUE; - case GL_INCR_WRAP_EXT: - case GL_DECR_WRAP_EXT: - if (ctx->Extensions.EXT_stencil_wrap) { - return GL_TRUE; - } - /* FALL-THROUGH */ - default: - return GL_FALSE; - } -} - - -static GLboolean -validate_stencil_func(struct gl_context *ctx, GLenum func) -{ - switch (func) { - case GL_NEVER: - case GL_LESS: - case GL_LEQUAL: - case GL_GREATER: - case GL_GEQUAL: - case GL_EQUAL: - case GL_NOTEQUAL: - case GL_ALWAYS: - return GL_TRUE; - default: - return GL_FALSE; - } -} - - -/** - * Set the clear value for the stencil buffer. - * - * \param s clear value. - * - * \sa glClearStencil(). - * - * Updates gl_stencil_attrib::Clear. On change - * flushes the vertices and notifies the driver via - * the dd_function_table::ClearStencil callback. - */ -void GLAPIENTRY -_mesa_ClearStencil( GLint s ) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (ctx->Stencil.Clear == (GLuint) s) - return; - - FLUSH_VERTICES(ctx, _NEW_STENCIL); - ctx->Stencil.Clear = (GLuint) s; - - if (ctx->Driver.ClearStencil) { - ctx->Driver.ClearStencil( ctx, s ); - } -} - - -/** - * Set the function and reference value for stencil testing. - * - * \param frontfunc front test function. - * \param backfunc back test function. - * \param ref front and back reference value. - * \param mask front and back bitmask. - * - * \sa glStencilFunc(). - * - * Verifies the parameters and updates the respective values in - * __struct gl_contextRec::Stencil. On change flushes the vertices and notifies the - * driver via the dd_function_table::StencilFunc callback. - */ -void GLAPIENTRY -_mesa_StencilFuncSeparateATI( GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask ) -{ - GET_CURRENT_CONTEXT(ctx); - const GLint stencilMax = (1 << ctx->DrawBuffer->Visual.stencilBits) - 1; - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glStencilFuncSeparateATI()\n"); - - if (!validate_stencil_func(ctx, frontfunc)) { - _mesa_error(ctx, GL_INVALID_ENUM, - "glStencilFuncSeparateATI(frontfunc)"); - return; - } - if (!validate_stencil_func(ctx, backfunc)) { - _mesa_error(ctx, GL_INVALID_ENUM, - "glStencilFuncSeparateATI(backfunc)"); - return; - } - - ref = CLAMP( ref, 0, stencilMax ); - - /* set both front and back state */ - if (ctx->Stencil.Function[0] == frontfunc && - ctx->Stencil.Function[1] == backfunc && - ctx->Stencil.ValueMask[0] == mask && - ctx->Stencil.ValueMask[1] == mask && - ctx->Stencil.Ref[0] == ref && - ctx->Stencil.Ref[1] == ref) - return; - FLUSH_VERTICES(ctx, _NEW_STENCIL); - ctx->Stencil.Function[0] = frontfunc; - ctx->Stencil.Function[1] = backfunc; - ctx->Stencil.Ref[0] = ctx->Stencil.Ref[1] = ref; - ctx->Stencil.ValueMask[0] = ctx->Stencil.ValueMask[1] = mask; - if (ctx->Driver.StencilFuncSeparate) { - ctx->Driver.StencilFuncSeparate(ctx, GL_FRONT, - frontfunc, ref, mask); - ctx->Driver.StencilFuncSeparate(ctx, GL_BACK, - backfunc, ref, mask); - } -} - - -/** - * Set the function and reference value for stencil testing. - * - * \param func test function. - * \param ref reference value. - * \param mask bitmask. - * - * \sa glStencilFunc(). - * - * Verifies the parameters and updates the respective values in - * __struct gl_contextRec::Stencil. On change flushes the vertices and notifies the - * driver via the dd_function_table::StencilFunc callback. - */ -void GLAPIENTRY -_mesa_StencilFunc( GLenum func, GLint ref, GLuint mask ) -{ - GET_CURRENT_CONTEXT(ctx); - const GLint stencilMax = (1 << ctx->DrawBuffer->Visual.stencilBits) - 1; - const GLint face = ctx->Stencil.ActiveFace; - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glStencilFunc()\n"); - - if (!validate_stencil_func(ctx, func)) { - _mesa_error(ctx, GL_INVALID_ENUM, "glStencilFunc(func)"); - return; - } - - ref = CLAMP( ref, 0, stencilMax ); - - if (face != 0) { - if (ctx->Stencil.Function[face] == func && - ctx->Stencil.ValueMask[face] == mask && - ctx->Stencil.Ref[face] == ref) - return; - FLUSH_VERTICES(ctx, _NEW_STENCIL); - ctx->Stencil.Function[face] = func; - ctx->Stencil.Ref[face] = ref; - ctx->Stencil.ValueMask[face] = mask; - - /* Only propagate the change to the driver if EXT_stencil_two_side - * is enabled. - */ - if (ctx->Driver.StencilFuncSeparate && ctx->Stencil.TestTwoSide) { - ctx->Driver.StencilFuncSeparate(ctx, GL_BACK, func, ref, mask); - } - } - else { - /* set both front and back state */ - if (ctx->Stencil.Function[0] == func && - ctx->Stencil.Function[1] == func && - ctx->Stencil.ValueMask[0] == mask && - ctx->Stencil.ValueMask[1] == mask && - ctx->Stencil.Ref[0] == ref && - ctx->Stencil.Ref[1] == ref) - return; - FLUSH_VERTICES(ctx, _NEW_STENCIL); - ctx->Stencil.Function[0] = ctx->Stencil.Function[1] = func; - ctx->Stencil.Ref[0] = ctx->Stencil.Ref[1] = ref; - ctx->Stencil.ValueMask[0] = ctx->Stencil.ValueMask[1] = mask; - if (ctx->Driver.StencilFuncSeparate) { - ctx->Driver.StencilFuncSeparate(ctx, - ((ctx->Stencil.TestTwoSide) - ? GL_FRONT : GL_FRONT_AND_BACK), - func, ref, mask); - } - } -} - - -/** - * Set the stencil writing mask. - * - * \param mask bit-mask to enable/disable writing of individual bits in the - * stencil planes. - * - * \sa glStencilMask(). - * - * Updates gl_stencil_attrib::WriteMask. On change flushes the vertices and - * notifies the driver via the dd_function_table::StencilMask callback. - */ -void GLAPIENTRY -_mesa_StencilMask( GLuint mask ) -{ - GET_CURRENT_CONTEXT(ctx); - const GLint face = ctx->Stencil.ActiveFace; - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glStencilMask()\n"); - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (face != 0) { - /* Only modify the EXT_stencil_two_side back-face state. - */ - if (ctx->Stencil.WriteMask[face] == mask) - return; - FLUSH_VERTICES(ctx, _NEW_STENCIL); - ctx->Stencil.WriteMask[face] = mask; - - /* Only propagate the change to the driver if EXT_stencil_two_side - * is enabled. - */ - if (ctx->Driver.StencilMaskSeparate && ctx->Stencil.TestTwoSide) { - ctx->Driver.StencilMaskSeparate(ctx, GL_BACK, mask); - } - } - else { - /* set both front and back state */ - if (ctx->Stencil.WriteMask[0] == mask && - ctx->Stencil.WriteMask[1] == mask) - return; - FLUSH_VERTICES(ctx, _NEW_STENCIL); - ctx->Stencil.WriteMask[0] = ctx->Stencil.WriteMask[1] = mask; - if (ctx->Driver.StencilMaskSeparate) { - ctx->Driver.StencilMaskSeparate(ctx, - ((ctx->Stencil.TestTwoSide) - ? GL_FRONT : GL_FRONT_AND_BACK), - mask); - } - } -} - - -/** - * Set the stencil test actions. - * - * \param fail action to take when stencil test fails. - * \param zfail action to take when stencil test passes, but depth test fails. - * \param zpass action to take when stencil test passes and the depth test - * passes (or depth testing is not enabled). - * - * \sa glStencilOp(). - * - * Verifies the parameters and updates the respective fields in - * __struct gl_contextRec::Stencil. On change flushes the vertices and notifies the - * driver via the dd_function_table::StencilOp callback. - */ -void GLAPIENTRY -_mesa_StencilOp(GLenum fail, GLenum zfail, GLenum zpass) -{ - GET_CURRENT_CONTEXT(ctx); - const GLint face = ctx->Stencil.ActiveFace; - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glStencilOp()\n"); - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (!validate_stencil_op(ctx, fail)) { - _mesa_error(ctx, GL_INVALID_ENUM, "glStencilOp(sfail)"); - return; - } - if (!validate_stencil_op(ctx, zfail)) { - _mesa_error(ctx, GL_INVALID_ENUM, "glStencilOp(zfail)"); - return; - } - if (!validate_stencil_op(ctx, zpass)) { - _mesa_error(ctx, GL_INVALID_ENUM, "glStencilOp(zpass)"); - return; - } - - if (face != 0) { - /* only set active face state */ - if (ctx->Stencil.ZFailFunc[face] == zfail && - ctx->Stencil.ZPassFunc[face] == zpass && - ctx->Stencil.FailFunc[face] == fail) - return; - FLUSH_VERTICES(ctx, _NEW_STENCIL); - ctx->Stencil.ZFailFunc[face] = zfail; - ctx->Stencil.ZPassFunc[face] = zpass; - ctx->Stencil.FailFunc[face] = fail; - - /* Only propagate the change to the driver if EXT_stencil_two_side - * is enabled. - */ - if (ctx->Driver.StencilOpSeparate && ctx->Stencil.TestTwoSide) { - ctx->Driver.StencilOpSeparate(ctx, GL_BACK, fail, zfail, zpass); - } - } - else { - /* set both front and back state */ - if (ctx->Stencil.ZFailFunc[0] == zfail && - ctx->Stencil.ZFailFunc[1] == zfail && - ctx->Stencil.ZPassFunc[0] == zpass && - ctx->Stencil.ZPassFunc[1] == zpass && - ctx->Stencil.FailFunc[0] == fail && - ctx->Stencil.FailFunc[1] == fail) - return; - FLUSH_VERTICES(ctx, _NEW_STENCIL); - ctx->Stencil.ZFailFunc[0] = ctx->Stencil.ZFailFunc[1] = zfail; - ctx->Stencil.ZPassFunc[0] = ctx->Stencil.ZPassFunc[1] = zpass; - ctx->Stencil.FailFunc[0] = ctx->Stencil.FailFunc[1] = fail; - if (ctx->Driver.StencilOpSeparate) { - ctx->Driver.StencilOpSeparate(ctx, - ((ctx->Stencil.TestTwoSide) - ? GL_FRONT : GL_FRONT_AND_BACK), - fail, zfail, zpass); - } - } -} - - - -#if _HAVE_FULL_GL -/* GL_EXT_stencil_two_side */ -void GLAPIENTRY -_mesa_ActiveStencilFaceEXT(GLenum face) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glActiveStencilFaceEXT()\n"); - - if (!ctx->Extensions.EXT_stencil_two_side) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glActiveStencilFaceEXT"); - return; - } - - if (face == GL_FRONT || face == GL_BACK) { - FLUSH_VERTICES(ctx, _NEW_STENCIL); - ctx->Stencil.ActiveFace = (face == GL_FRONT) ? 0 : 2; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glActiveStencilFaceEXT(face)"); - } -} -#endif - - - -/** - * OpenGL 2.0 function. - * \todo Make StencilOp() call this function. And eventually remove the - * ctx->Driver.StencilOp function and use ctx->Driver.StencilOpSeparate - * instead. - */ -void GLAPIENTRY -_mesa_StencilOpSeparate(GLenum face, GLenum sfail, GLenum zfail, GLenum zpass) -{ - GLboolean set = GL_FALSE; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glStencilOpSeparate()\n"); - - if (!validate_stencil_op(ctx, sfail)) { - _mesa_error(ctx, GL_INVALID_ENUM, "glStencilOpSeparate(sfail)"); - return; - } - if (!validate_stencil_op(ctx, zfail)) { - _mesa_error(ctx, GL_INVALID_ENUM, "glStencilOpSeparate(zfail)"); - return; - } - if (!validate_stencil_op(ctx, zpass)) { - _mesa_error(ctx, GL_INVALID_ENUM, "glStencilOpSeparate(zpass)"); - return; - } - if (face != GL_FRONT && face != GL_BACK && face != GL_FRONT_AND_BACK) { - _mesa_error(ctx, GL_INVALID_ENUM, "glStencilOpSeparate(face)"); - return; - } - - if (face != GL_BACK) { - /* set front */ - if (ctx->Stencil.ZFailFunc[0] != zfail || - ctx->Stencil.ZPassFunc[0] != zpass || - ctx->Stencil.FailFunc[0] != sfail){ - FLUSH_VERTICES(ctx, _NEW_STENCIL); - ctx->Stencil.ZFailFunc[0] = zfail; - ctx->Stencil.ZPassFunc[0] = zpass; - ctx->Stencil.FailFunc[0] = sfail; - set = GL_TRUE; - } - } - if (face != GL_FRONT) { - /* set back */ - if (ctx->Stencil.ZFailFunc[1] != zfail || - ctx->Stencil.ZPassFunc[1] != zpass || - ctx->Stencil.FailFunc[1] != sfail) { - FLUSH_VERTICES(ctx, _NEW_STENCIL); - ctx->Stencil.ZFailFunc[1] = zfail; - ctx->Stencil.ZPassFunc[1] = zpass; - ctx->Stencil.FailFunc[1] = sfail; - set = GL_TRUE; - } - } - if (set && ctx->Driver.StencilOpSeparate) { - ctx->Driver.StencilOpSeparate(ctx, face, sfail, zfail, zpass); - } -} - - -/* OpenGL 2.0 */ -void GLAPIENTRY -_mesa_StencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask) -{ - GET_CURRENT_CONTEXT(ctx); - const GLint stencilMax = (1 << ctx->DrawBuffer->Visual.stencilBits) - 1; - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glStencilFuncSeparate()\n"); - - if (face != GL_FRONT && face != GL_BACK && face != GL_FRONT_AND_BACK) { - _mesa_error(ctx, GL_INVALID_ENUM, "glStencilFuncSeparate(face)"); - return; - } - if (!validate_stencil_func(ctx, func)) { - _mesa_error(ctx, GL_INVALID_ENUM, "glStencilFuncSeparate(func)"); - return; - } - - ref = CLAMP(ref, 0, stencilMax); - - FLUSH_VERTICES(ctx, _NEW_STENCIL); - - if (face != GL_BACK) { - /* set front */ - ctx->Stencil.Function[0] = func; - ctx->Stencil.Ref[0] = ref; - ctx->Stencil.ValueMask[0] = mask; - } - if (face != GL_FRONT) { - /* set back */ - ctx->Stencil.Function[1] = func; - ctx->Stencil.Ref[1] = ref; - ctx->Stencil.ValueMask[1] = mask; - } - if (ctx->Driver.StencilFuncSeparate) { - ctx->Driver.StencilFuncSeparate(ctx, face, func, ref, mask); - } -} - - -/* OpenGL 2.0 */ -void GLAPIENTRY -_mesa_StencilMaskSeparate(GLenum face, GLuint mask) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glStencilMaskSeparate()\n"); - - if (face != GL_FRONT && face != GL_BACK && face != GL_FRONT_AND_BACK) { - _mesa_error(ctx, GL_INVALID_ENUM, "glStencilaMaskSeparate(face)"); - return; - } - - FLUSH_VERTICES(ctx, _NEW_STENCIL); - - if (face != GL_BACK) { - ctx->Stencil.WriteMask[0] = mask; - } - if (face != GL_FRONT) { - ctx->Stencil.WriteMask[1] = mask; - } - if (ctx->Driver.StencilMaskSeparate) { - ctx->Driver.StencilMaskSeparate(ctx, face, mask); - } -} - - -/** - * Update derived stencil state. - */ -void -_mesa_update_stencil(struct gl_context *ctx) -{ - const GLint face = ctx->Stencil._BackFace; - - ctx->Stencil._Enabled = (ctx->Stencil.Enabled && - ctx->DrawBuffer->Visual.stencilBits > 0); - - ctx->Stencil._TestTwoSide = - ctx->Stencil._Enabled && - (ctx->Stencil.Function[0] != ctx->Stencil.Function[face] || - ctx->Stencil.FailFunc[0] != ctx->Stencil.FailFunc[face] || - ctx->Stencil.ZPassFunc[0] != ctx->Stencil.ZPassFunc[face] || - ctx->Stencil.ZFailFunc[0] != ctx->Stencil.ZFailFunc[face] || - ctx->Stencil.Ref[0] != ctx->Stencil.Ref[face] || - ctx->Stencil.ValueMask[0] != ctx->Stencil.ValueMask[face] || - ctx->Stencil.WriteMask[0] != ctx->Stencil.WriteMask[face]); -} - - -/** - * Initialize the context stipple state. - * - * \param ctx GL context. - * - * Initializes __struct gl_contextRec::Stencil attribute group. - */ -void -_mesa_init_stencil(struct gl_context *ctx) -{ - ctx->Stencil.Enabled = GL_FALSE; - ctx->Stencil.TestTwoSide = GL_FALSE; - ctx->Stencil.ActiveFace = 0; /* 0 = GL_FRONT, 2 = GL_BACK */ - ctx->Stencil.Function[0] = GL_ALWAYS; - ctx->Stencil.Function[1] = GL_ALWAYS; - ctx->Stencil.Function[2] = GL_ALWAYS; - ctx->Stencil.FailFunc[0] = GL_KEEP; - ctx->Stencil.FailFunc[1] = GL_KEEP; - ctx->Stencil.FailFunc[2] = GL_KEEP; - ctx->Stencil.ZPassFunc[0] = GL_KEEP; - ctx->Stencil.ZPassFunc[1] = GL_KEEP; - ctx->Stencil.ZPassFunc[2] = GL_KEEP; - ctx->Stencil.ZFailFunc[0] = GL_KEEP; - ctx->Stencil.ZFailFunc[1] = GL_KEEP; - ctx->Stencil.ZFailFunc[2] = GL_KEEP; - ctx->Stencil.Ref[0] = 0; - ctx->Stencil.Ref[1] = 0; - ctx->Stencil.Ref[2] = 0; - ctx->Stencil.ValueMask[0] = ~0U; - ctx->Stencil.ValueMask[1] = ~0U; - ctx->Stencil.ValueMask[2] = ~0U; - ctx->Stencil.WriteMask[0] = ~0U; - ctx->Stencil.WriteMask[1] = ~0U; - ctx->Stencil.WriteMask[2] = ~0U; - ctx->Stencil.Clear = 0; - ctx->Stencil._BackFace = 1; -} +/* + * 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. + */ + + +/** + * \file stencil.c + * Stencil operations. + * + * Note: There's some conflict between GL_EXT_stencil_two_side and + * OpenGL 2.0's two-sided stencil feature. + * + * With GL_EXT_stencil_two_side, calling glStencilOp/Func/Mask() only the + * front OR back face state (as set by glActiveStencilFaceEXT) is set. + * + * But with OpenGL 2.0, calling glStencilOp/Func/Mask() sets BOTH the + * front AND back state. + * + * Also, note that GL_ATI_separate_stencil is different as well: + * glStencilFuncSeparateATI(GLenum frontfunc, GLenum backfunc, ...) vs. + * glStencilFuncSeparate(GLenum face, GLenum func, ...). + * + * This problem is solved by keeping three sets of stencil state: + * state[0] = GL_FRONT state. + * state[1] = OpenGL 2.0 / GL_ATI_separate_stencil GL_BACK state. + * state[2] = GL_EXT_stencil_two_side GL_BACK state. + */ + + +#include "glheader.h" +#include "imports.h" +#include "context.h" +#include "macros.h" +#include "stencil.h" +#include "mtypes.h" + + +static GLboolean +validate_stencil_op(struct gl_context *ctx, GLenum op) +{ + switch (op) { + case GL_KEEP: + case GL_ZERO: + case GL_REPLACE: + case GL_INCR: + case GL_DECR: + case GL_INVERT: + return GL_TRUE; + case GL_INCR_WRAP_EXT: + case GL_DECR_WRAP_EXT: + if (ctx->Extensions.EXT_stencil_wrap) { + return GL_TRUE; + } + /* FALL-THROUGH */ + default: + return GL_FALSE; + } +} + + +static GLboolean +validate_stencil_func(struct gl_context *ctx, GLenum func) +{ + switch (func) { + case GL_NEVER: + case GL_LESS: + case GL_LEQUAL: + case GL_GREATER: + case GL_GEQUAL: + case GL_EQUAL: + case GL_NOTEQUAL: + case GL_ALWAYS: + return GL_TRUE; + default: + return GL_FALSE; + } +} + + +/** + * Set the clear value for the stencil buffer. + * + * \param s clear value. + * + * \sa glClearStencil(). + * + * Updates gl_stencil_attrib::Clear. On change + * flushes the vertices and notifies the driver via + * the dd_function_table::ClearStencil callback. + */ +void GLAPIENTRY +_mesa_ClearStencil( GLint s ) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (ctx->Stencil.Clear == (GLuint) s) + return; + + FLUSH_VERTICES(ctx, _NEW_STENCIL); + ctx->Stencil.Clear = (GLuint) s; + + if (ctx->Driver.ClearStencil) { + ctx->Driver.ClearStencil( ctx, s ); + } +} + + +/** + * Set the function and reference value for stencil testing. + * + * \param frontfunc front test function. + * \param backfunc back test function. + * \param ref front and back reference value. + * \param mask front and back bitmask. + * + * \sa glStencilFunc(). + * + * Verifies the parameters and updates the respective values in + * __struct gl_contextRec::Stencil. On change flushes the vertices and notifies the + * driver via the dd_function_table::StencilFunc callback. + */ +void GLAPIENTRY +_mesa_StencilFuncSeparateATI( GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask ) +{ + GET_CURRENT_CONTEXT(ctx); + const GLint stencilMax = (1 << ctx->DrawBuffer->Visual.stencilBits) - 1; + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glStencilFuncSeparateATI()\n"); + + if (!validate_stencil_func(ctx, frontfunc)) { + _mesa_error(ctx, GL_INVALID_ENUM, + "glStencilFuncSeparateATI(frontfunc)"); + return; + } + if (!validate_stencil_func(ctx, backfunc)) { + _mesa_error(ctx, GL_INVALID_ENUM, + "glStencilFuncSeparateATI(backfunc)"); + return; + } + + ref = CLAMP( ref, 0, stencilMax ); + + /* set both front and back state */ + if (ctx->Stencil.Function[0] == frontfunc && + ctx->Stencil.Function[1] == backfunc && + ctx->Stencil.ValueMask[0] == mask && + ctx->Stencil.ValueMask[1] == mask && + ctx->Stencil.Ref[0] == ref && + ctx->Stencil.Ref[1] == ref) + return; + FLUSH_VERTICES(ctx, _NEW_STENCIL); + ctx->Stencil.Function[0] = frontfunc; + ctx->Stencil.Function[1] = backfunc; + ctx->Stencil.Ref[0] = ctx->Stencil.Ref[1] = ref; + ctx->Stencil.ValueMask[0] = ctx->Stencil.ValueMask[1] = mask; + if (ctx->Driver.StencilFuncSeparate) { + ctx->Driver.StencilFuncSeparate(ctx, GL_FRONT, + frontfunc, ref, mask); + ctx->Driver.StencilFuncSeparate(ctx, GL_BACK, + backfunc, ref, mask); + } +} + + +/** + * Set the function and reference value for stencil testing. + * + * \param func test function. + * \param ref reference value. + * \param mask bitmask. + * + * \sa glStencilFunc(). + * + * Verifies the parameters and updates the respective values in + * __struct gl_contextRec::Stencil. On change flushes the vertices and notifies the + * driver via the dd_function_table::StencilFunc callback. + */ +void GLAPIENTRY +_mesa_StencilFunc( GLenum func, GLint ref, GLuint mask ) +{ + GET_CURRENT_CONTEXT(ctx); + const GLint stencilMax = (1 << ctx->DrawBuffer->Visual.stencilBits) - 1; + const GLint face = ctx->Stencil.ActiveFace; + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glStencilFunc()\n"); + + if (!validate_stencil_func(ctx, func)) { + _mesa_error(ctx, GL_INVALID_ENUM, "glStencilFunc(func)"); + return; + } + + ref = CLAMP( ref, 0, stencilMax ); + + if (face != 0) { + if (ctx->Stencil.Function[face] == func && + ctx->Stencil.ValueMask[face] == mask && + ctx->Stencil.Ref[face] == ref) + return; + FLUSH_VERTICES(ctx, _NEW_STENCIL); + ctx->Stencil.Function[face] = func; + ctx->Stencil.Ref[face] = ref; + ctx->Stencil.ValueMask[face] = mask; + + /* Only propagate the change to the driver if EXT_stencil_two_side + * is enabled. + */ + if (ctx->Driver.StencilFuncSeparate && ctx->Stencil.TestTwoSide) { + ctx->Driver.StencilFuncSeparate(ctx, GL_BACK, func, ref, mask); + } + } + else { + /* set both front and back state */ + if (ctx->Stencil.Function[0] == func && + ctx->Stencil.Function[1] == func && + ctx->Stencil.ValueMask[0] == mask && + ctx->Stencil.ValueMask[1] == mask && + ctx->Stencil.Ref[0] == ref && + ctx->Stencil.Ref[1] == ref) + return; + FLUSH_VERTICES(ctx, _NEW_STENCIL); + ctx->Stencil.Function[0] = ctx->Stencil.Function[1] = func; + ctx->Stencil.Ref[0] = ctx->Stencil.Ref[1] = ref; + ctx->Stencil.ValueMask[0] = ctx->Stencil.ValueMask[1] = mask; + if (ctx->Driver.StencilFuncSeparate) { + ctx->Driver.StencilFuncSeparate(ctx, + ((ctx->Stencil.TestTwoSide) + ? GL_FRONT : GL_FRONT_AND_BACK), + func, ref, mask); + } + } +} + + +/** + * Set the stencil writing mask. + * + * \param mask bit-mask to enable/disable writing of individual bits in the + * stencil planes. + * + * \sa glStencilMask(). + * + * Updates gl_stencil_attrib::WriteMask. On change flushes the vertices and + * notifies the driver via the dd_function_table::StencilMask callback. + */ +void GLAPIENTRY +_mesa_StencilMask( GLuint mask ) +{ + GET_CURRENT_CONTEXT(ctx); + const GLint face = ctx->Stencil.ActiveFace; + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glStencilMask()\n"); + + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (face != 0) { + /* Only modify the EXT_stencil_two_side back-face state. + */ + if (ctx->Stencil.WriteMask[face] == mask) + return; + FLUSH_VERTICES(ctx, _NEW_STENCIL); + ctx->Stencil.WriteMask[face] = mask; + + /* Only propagate the change to the driver if EXT_stencil_two_side + * is enabled. + */ + if (ctx->Driver.StencilMaskSeparate && ctx->Stencil.TestTwoSide) { + ctx->Driver.StencilMaskSeparate(ctx, GL_BACK, mask); + } + } + else { + /* set both front and back state */ + if (ctx->Stencil.WriteMask[0] == mask && + ctx->Stencil.WriteMask[1] == mask) + return; + FLUSH_VERTICES(ctx, _NEW_STENCIL); + ctx->Stencil.WriteMask[0] = ctx->Stencil.WriteMask[1] = mask; + if (ctx->Driver.StencilMaskSeparate) { + ctx->Driver.StencilMaskSeparate(ctx, + ((ctx->Stencil.TestTwoSide) + ? GL_FRONT : GL_FRONT_AND_BACK), + mask); + } + } +} + + +/** + * Set the stencil test actions. + * + * \param fail action to take when stencil test fails. + * \param zfail action to take when stencil test passes, but depth test fails. + * \param zpass action to take when stencil test passes and the depth test + * passes (or depth testing is not enabled). + * + * \sa glStencilOp(). + * + * Verifies the parameters and updates the respective fields in + * __struct gl_contextRec::Stencil. On change flushes the vertices and notifies the + * driver via the dd_function_table::StencilOp callback. + */ +void GLAPIENTRY +_mesa_StencilOp(GLenum fail, GLenum zfail, GLenum zpass) +{ + GET_CURRENT_CONTEXT(ctx); + const GLint face = ctx->Stencil.ActiveFace; + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glStencilOp()\n"); + + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (!validate_stencil_op(ctx, fail)) { + _mesa_error(ctx, GL_INVALID_ENUM, "glStencilOp(sfail)"); + return; + } + if (!validate_stencil_op(ctx, zfail)) { + _mesa_error(ctx, GL_INVALID_ENUM, "glStencilOp(zfail)"); + return; + } + if (!validate_stencil_op(ctx, zpass)) { + _mesa_error(ctx, GL_INVALID_ENUM, "glStencilOp(zpass)"); + return; + } + + if (face != 0) { + /* only set active face state */ + if (ctx->Stencil.ZFailFunc[face] == zfail && + ctx->Stencil.ZPassFunc[face] == zpass && + ctx->Stencil.FailFunc[face] == fail) + return; + FLUSH_VERTICES(ctx, _NEW_STENCIL); + ctx->Stencil.ZFailFunc[face] = zfail; + ctx->Stencil.ZPassFunc[face] = zpass; + ctx->Stencil.FailFunc[face] = fail; + + /* Only propagate the change to the driver if EXT_stencil_two_side + * is enabled. + */ + if (ctx->Driver.StencilOpSeparate && ctx->Stencil.TestTwoSide) { + ctx->Driver.StencilOpSeparate(ctx, GL_BACK, fail, zfail, zpass); + } + } + else { + /* set both front and back state */ + if (ctx->Stencil.ZFailFunc[0] == zfail && + ctx->Stencil.ZFailFunc[1] == zfail && + ctx->Stencil.ZPassFunc[0] == zpass && + ctx->Stencil.ZPassFunc[1] == zpass && + ctx->Stencil.FailFunc[0] == fail && + ctx->Stencil.FailFunc[1] == fail) + return; + FLUSH_VERTICES(ctx, _NEW_STENCIL); + ctx->Stencil.ZFailFunc[0] = ctx->Stencil.ZFailFunc[1] = zfail; + ctx->Stencil.ZPassFunc[0] = ctx->Stencil.ZPassFunc[1] = zpass; + ctx->Stencil.FailFunc[0] = ctx->Stencil.FailFunc[1] = fail; + if (ctx->Driver.StencilOpSeparate) { + ctx->Driver.StencilOpSeparate(ctx, + ((ctx->Stencil.TestTwoSide) + ? GL_FRONT : GL_FRONT_AND_BACK), + fail, zfail, zpass); + } + } +} + + + +#if _HAVE_FULL_GL +/* GL_EXT_stencil_two_side */ +void GLAPIENTRY +_mesa_ActiveStencilFaceEXT(GLenum face) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glActiveStencilFaceEXT()\n"); + + if (!ctx->Extensions.EXT_stencil_two_side) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glActiveStencilFaceEXT"); + return; + } + + if (face == GL_FRONT || face == GL_BACK) { + FLUSH_VERTICES(ctx, _NEW_STENCIL); + ctx->Stencil.ActiveFace = (face == GL_FRONT) ? 0 : 2; + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, "glActiveStencilFaceEXT(face)"); + } +} +#endif + + + +/** + * OpenGL 2.0 function. + * \todo Make StencilOp() call this function. And eventually remove the + * ctx->Driver.StencilOp function and use ctx->Driver.StencilOpSeparate + * instead. + */ +void GLAPIENTRY +_mesa_StencilOpSeparate(GLenum face, GLenum sfail, GLenum zfail, GLenum zpass) +{ + GLboolean set = GL_FALSE; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glStencilOpSeparate()\n"); + + if (!validate_stencil_op(ctx, sfail)) { + _mesa_error(ctx, GL_INVALID_ENUM, "glStencilOpSeparate(sfail)"); + return; + } + if (!validate_stencil_op(ctx, zfail)) { + _mesa_error(ctx, GL_INVALID_ENUM, "glStencilOpSeparate(zfail)"); + return; + } + if (!validate_stencil_op(ctx, zpass)) { + _mesa_error(ctx, GL_INVALID_ENUM, "glStencilOpSeparate(zpass)"); + return; + } + if (face != GL_FRONT && face != GL_BACK && face != GL_FRONT_AND_BACK) { + _mesa_error(ctx, GL_INVALID_ENUM, "glStencilOpSeparate(face)"); + return; + } + + if (face != GL_BACK) { + /* set front */ + if (ctx->Stencil.ZFailFunc[0] != zfail || + ctx->Stencil.ZPassFunc[0] != zpass || + ctx->Stencil.FailFunc[0] != sfail){ + FLUSH_VERTICES(ctx, _NEW_STENCIL); + ctx->Stencil.ZFailFunc[0] = zfail; + ctx->Stencil.ZPassFunc[0] = zpass; + ctx->Stencil.FailFunc[0] = sfail; + set = GL_TRUE; + } + } + if (face != GL_FRONT) { + /* set back */ + if (ctx->Stencil.ZFailFunc[1] != zfail || + ctx->Stencil.ZPassFunc[1] != zpass || + ctx->Stencil.FailFunc[1] != sfail) { + FLUSH_VERTICES(ctx, _NEW_STENCIL); + ctx->Stencil.ZFailFunc[1] = zfail; + ctx->Stencil.ZPassFunc[1] = zpass; + ctx->Stencil.FailFunc[1] = sfail; + set = GL_TRUE; + } + } + if (set && ctx->Driver.StencilOpSeparate) { + ctx->Driver.StencilOpSeparate(ctx, face, sfail, zfail, zpass); + } +} + + +/* OpenGL 2.0 */ +void GLAPIENTRY +_mesa_StencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask) +{ + GET_CURRENT_CONTEXT(ctx); + const GLint stencilMax = (1 << ctx->DrawBuffer->Visual.stencilBits) - 1; + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glStencilFuncSeparate()\n"); + + if (face != GL_FRONT && face != GL_BACK && face != GL_FRONT_AND_BACK) { + _mesa_error(ctx, GL_INVALID_ENUM, "glStencilFuncSeparate(face)"); + return; + } + if (!validate_stencil_func(ctx, func)) { + _mesa_error(ctx, GL_INVALID_ENUM, "glStencilFuncSeparate(func)"); + return; + } + + ref = CLAMP(ref, 0, stencilMax); + + FLUSH_VERTICES(ctx, _NEW_STENCIL); + + if (face != GL_BACK) { + /* set front */ + ctx->Stencil.Function[0] = func; + ctx->Stencil.Ref[0] = ref; + ctx->Stencil.ValueMask[0] = mask; + } + if (face != GL_FRONT) { + /* set back */ + ctx->Stencil.Function[1] = func; + ctx->Stencil.Ref[1] = ref; + ctx->Stencil.ValueMask[1] = mask; + } + if (ctx->Driver.StencilFuncSeparate) { + ctx->Driver.StencilFuncSeparate(ctx, face, func, ref, mask); + } +} + + +/* OpenGL 2.0 */ +void GLAPIENTRY +_mesa_StencilMaskSeparate(GLenum face, GLuint mask) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glStencilMaskSeparate()\n"); + + if (face != GL_FRONT && face != GL_BACK && face != GL_FRONT_AND_BACK) { + _mesa_error(ctx, GL_INVALID_ENUM, "glStencilaMaskSeparate(face)"); + return; + } + + FLUSH_VERTICES(ctx, _NEW_STENCIL); + + if (face != GL_BACK) { + ctx->Stencil.WriteMask[0] = mask; + } + if (face != GL_FRONT) { + ctx->Stencil.WriteMask[1] = mask; + } + if (ctx->Driver.StencilMaskSeparate) { + ctx->Driver.StencilMaskSeparate(ctx, face, mask); + } +} + + +/** + * Update derived stencil state. + */ +void +_mesa_update_stencil(struct gl_context *ctx) +{ + const GLint face = ctx->Stencil._BackFace; + + ctx->Stencil._Enabled = (ctx->Stencil.Enabled && + ctx->DrawBuffer->Visual.stencilBits > 0); + + ctx->Stencil._TestTwoSide = + ctx->Stencil._Enabled && + (ctx->Stencil.Function[0] != ctx->Stencil.Function[face] || + ctx->Stencil.FailFunc[0] != ctx->Stencil.FailFunc[face] || + ctx->Stencil.ZPassFunc[0] != ctx->Stencil.ZPassFunc[face] || + ctx->Stencil.ZFailFunc[0] != ctx->Stencil.ZFailFunc[face] || + ctx->Stencil.Ref[0] != ctx->Stencil.Ref[face] || + ctx->Stencil.ValueMask[0] != ctx->Stencil.ValueMask[face] || + ctx->Stencil.WriteMask[0] != ctx->Stencil.WriteMask[face]); +} + + +/** + * Initialize the context stipple state. + * + * \param ctx GL context. + * + * Initializes __struct gl_contextRec::Stencil attribute group. + */ +void +_mesa_init_stencil(struct gl_context *ctx) +{ + ctx->Stencil.Enabled = GL_FALSE; + ctx->Stencil.TestTwoSide = GL_FALSE; + ctx->Stencil.ActiveFace = 0; /* 0 = GL_FRONT, 2 = GL_BACK */ + ctx->Stencil.Function[0] = GL_ALWAYS; + ctx->Stencil.Function[1] = GL_ALWAYS; + ctx->Stencil.Function[2] = GL_ALWAYS; + ctx->Stencil.FailFunc[0] = GL_KEEP; + ctx->Stencil.FailFunc[1] = GL_KEEP; + ctx->Stencil.FailFunc[2] = GL_KEEP; + ctx->Stencil.ZPassFunc[0] = GL_KEEP; + ctx->Stencil.ZPassFunc[1] = GL_KEEP; + ctx->Stencil.ZPassFunc[2] = GL_KEEP; + ctx->Stencil.ZFailFunc[0] = GL_KEEP; + ctx->Stencil.ZFailFunc[1] = GL_KEEP; + ctx->Stencil.ZFailFunc[2] = GL_KEEP; + ctx->Stencil.Ref[0] = 0; + ctx->Stencil.Ref[1] = 0; + ctx->Stencil.Ref[2] = 0; + ctx->Stencil.ValueMask[0] = ~0U; + ctx->Stencil.ValueMask[1] = ~0U; + ctx->Stencil.ValueMask[2] = ~0U; + ctx->Stencil.WriteMask[0] = ~0U; + ctx->Stencil.WriteMask[1] = ~0U; + ctx->Stencil.WriteMask[2] = ~0U; + ctx->Stencil.Clear = 0; + ctx->Stencil._BackFace = 1; +} diff --git a/mesalib/src/mesa/main/texcompress.c b/mesalib/src/mesa/main/texcompress.c index b821dd0c0..4e5c14cbb 100644 --- a/mesalib/src/mesa/main/texcompress.c +++ b/mesalib/src/mesa/main/texcompress.c @@ -1,526 +1,526 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5.1 - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * Copyright (c) 2008 VMware, 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 - * 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 texcompress.c - * Helper functions for texture compression. - */ - - -#include "glheader.h" -#include "imports.h" -#include "colormac.h" -#include "formats.h" -#include "mfeatures.h" -#include "mtypes.h" -#include "texcompress.h" -#include "texcompress_fxt1.h" -#include "texcompress_rgtc.h" -#include "texcompress_s3tc.h" - - -/** - * Get the GL base format of a specified GL compressed texture format - * - * From page 232 of the OpenGL 3.3 (Compatiblity Profile) spec: - * - * "Compressed Internal Format Base Internal Format Type - * --------------------------- -------------------- --------- - * COMPRESSED_ALPHA ALPHA Generic - * COMPRESSED_LUMINANCE LUMINANCE Generic - * COMPRESSED_LUMINANCE_ALPHA LUMINANCE_ALPHA Generic - * COMPRESSED_INTENSITY INTENSITY Generic - * COMPRESSED_RED RED Generic - * COMPRESSED_RG RG Generic - * COMPRESSED_RGB RGB Generic - * COMPRESSED_RGBA RGBA Generic - * COMPRESSED_SRGB RGB Generic - * COMPRESSED_SRGB_ALPHA RGBA Generic - * COMPRESSED_SLUMINANCE LUMINANCE Generic - * COMPRESSED_SLUMINANCE_ALPHA LUMINANCE_ALPHA Generic - * COMPRESSED_RED_RGTC1 RED Specific - * COMPRESSED_SIGNED_RED_RGTC1 RED Specific - * COMPRESSED_RG_RGTC2 RG Specific - * COMPRESSED_SIGNED_RG_RGTC2 RG Specific" - * - * \return - * The base format of \c format if \c format is a compressed format (either - * generic or specific. Otherwise 0 is returned. - */ -GLenum -_mesa_gl_compressed_format_base_format(GLenum format) -{ - switch (format) { - case GL_COMPRESSED_RED: - case GL_COMPRESSED_RED_RGTC1: - case GL_COMPRESSED_SIGNED_RED_RGTC1: - return GL_RED; - - case GL_COMPRESSED_RG: - case GL_COMPRESSED_RG_RGTC2: - case GL_COMPRESSED_SIGNED_RG_RGTC2: - return GL_RG; - - case GL_COMPRESSED_RGB: - case GL_COMPRESSED_SRGB: - case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: - case GL_COMPRESSED_RGB_FXT1_3DFX: - case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT: - return GL_RGB; - - case GL_COMPRESSED_RGBA: - case GL_COMPRESSED_SRGB_ALPHA: - case GL_COMPRESSED_RGBA_BPTC_UNORM_ARB: - case GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB: - case GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB: - case GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB: - case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: - case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: - case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: - case GL_COMPRESSED_RGBA_FXT1_3DFX: - case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: - case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: - case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: - return GL_RGBA; - - case GL_COMPRESSED_ALPHA: - return GL_ALPHA; - - case GL_COMPRESSED_LUMINANCE: - case GL_COMPRESSED_SLUMINANCE: - case GL_COMPRESSED_LUMINANCE_LATC1_EXT: - case GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT: - return GL_LUMINANCE; - - case GL_COMPRESSED_LUMINANCE_ALPHA: - case GL_COMPRESSED_SLUMINANCE_ALPHA: - case GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT: - case GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT: - case GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI: - return GL_LUMINANCE_ALPHA; - - case GL_COMPRESSED_INTENSITY: - return GL_INTENSITY; - - default: - return 0; - } -} - -/** - * Return list of (and count of) all specific texture compression - * formats that are supported. - * - * Some formats are \b not returned by this function. The - * \c GL_COMPRESSED_TEXTURE_FORMATS query only returns formats that are - * "suitable for general-purpose usage." All texture compression extensions - * have taken this to mean either linear RGB or linear RGBA. - * - * The GL_ARB_texture_compress_rgtc spec says: - * - * "19) Should the GL_NUM_COMPRESSED_TEXTURE_FORMATS and - * GL_COMPRESSED_TEXTURE_FORMATS queries return the RGTC formats? - * - * RESOLVED: No. - * - * The OpenGL 2.1 specification says "The only values returned - * by this query [GL_COMPRESSED_TEXTURE_FORMATS"] are those - * corresponding to formats suitable for general-purpose usage. - * The renderer will not enumerate formats with restrictions that - * need to be specifically understood prior to use." - * - * Compressed textures with just red or red-green components are - * not general-purpose so should not be returned by these queries - * because they have restrictions. - * - * Applications that seek to use the RGTC formats should do so - * by looking for this extension's name in the string returned by - * glGetString(GL_EXTENSIONS) rather than - * what GL_NUM_COMPRESSED_TEXTURE_FORMATS and - * GL_COMPRESSED_TEXTURE_FORMATS return." - * - * There is nearly identical wording in the GL_EXT_texture_compression_rgtc - * spec. - * - * The GL_EXT_texture_rRGB spec says: - * - * "22) Should the new COMPRESSED_SRGB_* formats be listed in an - * implementation's GL_COMPRESSED_TEXTURE_FORMATS list? - * - * RESOLVED: No. Section 3.8.1 says formats listed by - * GL_COMPRESSED_TEXTURE_FORMATS are "suitable for general-purpose - * usage." The non-linear distribution of red, green, and - * blue for these sRGB compressed formats makes them not really - * general-purpose." - * - * The GL_EXT_texture_compression_latc spec says: - * - * "16) Should the GL_NUM_COMPRESSED_TEXTURE_FORMATS and - * GL_COMPRESSED_TEXTURE_FORMATS queries return the LATC formats? - * - * RESOLVED: No. - * - * The OpenGL 2.1 specification says "The only values returned - * by this query [GL_COMPRESSED_TEXTURE_FORMATS"] are those - * corresponding to formats suitable for general-purpose usage. - * The renderer will not enumerate formats with restrictions that - * need to be specifically understood prior to use." - * - * Historically, OpenGL implementation have advertised the RGB and - * RGBA versions of the S3TC extensions compressed format tokens - * through this mechanism. - * - * The specification is not sufficiently clear about what "suitable - * for general-purpose usage" means. Historically that seems to mean - * unsigned RGB or unsigned RGBA. The DXT1 format supporting alpha - * (GL_COMPRESSED_RGBA_S3TC_DXT1_EXT) is not exposed in the list (at - * least for NVIDIA drivers) because the alpha is always 1.0 expect - * when it is 0.0 when RGB is required to be black. NVIDIA's even - * limits itself to true linear RGB or RGBA formats, specifically - * not including EXT_texture_sRGB's sRGB S3TC compressed formats. - * - * Adding luminance and luminance-alpha texture formats (and - * certainly signed versions of luminance and luminance-alpha - * formats!) invites potential comptaibility problems with old - * applications using this mechanism since old applications are - * unlikely to expect non-RGB or non-RGBA formats to be advertised - * through this mechanism. However no specific misinteractions - * with old applications is known. - * - * Applications that seek to use the LATC formats should do so - * by looking for this extension's name in the string returned by - * glGetString(GL_EXTENSIONS) rather than - * what GL_NUM_COMPRESSED_TEXTURE_FORMATS and - * GL_COMPRESSED_TEXTURE_FORMATS return." - * - * There is no formal spec for GL_ATI_texture_compression_3dc. Since the - * formats added by this extension are luminance-alpha formats, it is - * reasonable to expect them to follow the same rules as - * GL_EXT_texture_compression_latc. At the very least, Catalyst 11.6 does not - * expose the 3dc formats through this mechanism. - * - * \param ctx the GL context - * \param formats the resulting format list (may be NULL). - * - * \return number of formats. - */ -GLuint -_mesa_get_compressed_formats(struct gl_context *ctx, GLint *formats) -{ - GLuint n = 0; - if (ctx->Extensions.TDFX_texture_compression_FXT1) { - if (formats) { - formats[n++] = GL_COMPRESSED_RGB_FXT1_3DFX; - formats[n++] = GL_COMPRESSED_RGBA_FXT1_3DFX; - } - else { - n += 2; - } - } - - if (ctx->Extensions.EXT_texture_compression_s3tc) { - if (formats) { - formats[n++] = GL_COMPRESSED_RGB_S3TC_DXT1_EXT; - formats[n++] = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT; - formats[n++] = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; - } - else { - n += 3; - } - } - if (ctx->Extensions.S3_s3tc) { - if (formats) { - formats[n++] = GL_RGB_S3TC; - formats[n++] = GL_RGB4_S3TC; - formats[n++] = GL_RGBA_S3TC; - formats[n++] = GL_RGBA4_S3TC; - } - else { - n += 4; - } - } - -#if FEATURE_ES1 || FEATURE_ES2 - if (formats) { - formats[n++] = GL_PALETTE4_RGB8_OES; - formats[n++] = GL_PALETTE4_RGBA8_OES; - formats[n++] = GL_PALETTE4_R5_G6_B5_OES; - formats[n++] = GL_PALETTE4_RGBA4_OES; - formats[n++] = GL_PALETTE4_RGB5_A1_OES; - formats[n++] = GL_PALETTE8_RGB8_OES; - formats[n++] = GL_PALETTE8_RGBA8_OES; - formats[n++] = GL_PALETTE8_R5_G6_B5_OES; - formats[n++] = GL_PALETTE8_RGBA4_OES; - formats[n++] = GL_PALETTE8_RGB5_A1_OES; - } - else { - n += 10; - } -#endif - - return n; -} - - -/** - * Convert a compressed MESA_FORMAT_x to a GLenum. - */ -gl_format -_mesa_glenum_to_compressed_format(GLenum format) -{ - switch (format) { - case GL_COMPRESSED_RGB_FXT1_3DFX: - return MESA_FORMAT_RGB_FXT1; - case GL_COMPRESSED_RGBA_FXT1_3DFX: - return MESA_FORMAT_RGBA_FXT1; - - case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: - case GL_RGB_S3TC: - return MESA_FORMAT_RGB_DXT1; - case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: - case GL_RGB4_S3TC: - return MESA_FORMAT_RGBA_DXT1; - case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: - case GL_RGBA_S3TC: - return MESA_FORMAT_RGBA_DXT3; - case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: - case GL_RGBA4_S3TC: - return MESA_FORMAT_RGBA_DXT5; - - case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT: - return MESA_FORMAT_SRGB_DXT1; - case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: - return MESA_FORMAT_SRGBA_DXT1; - case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: - return MESA_FORMAT_SRGBA_DXT3; - case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: - return MESA_FORMAT_SRGBA_DXT5; - - case GL_COMPRESSED_RED_RGTC1: - return MESA_FORMAT_RED_RGTC1; - case GL_COMPRESSED_SIGNED_RED_RGTC1: - return MESA_FORMAT_SIGNED_RED_RGTC1; - case GL_COMPRESSED_RG_RGTC2: - return MESA_FORMAT_RG_RGTC2; - case GL_COMPRESSED_SIGNED_RG_RGTC2: - return MESA_FORMAT_SIGNED_RG_RGTC2; - - case GL_COMPRESSED_LUMINANCE_LATC1_EXT: - return MESA_FORMAT_L_LATC1; - case GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT: - return MESA_FORMAT_SIGNED_L_LATC1; - case GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT: - case GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI: - return MESA_FORMAT_LA_LATC2; - case GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT: - return MESA_FORMAT_SIGNED_LA_LATC2; - - default: - return MESA_FORMAT_NONE; - } -} - - -/** - * Given a compressed MESA_FORMAT_x value, return the corresponding - * GLenum for that format. - * This is needed for glGetTexLevelParameter(GL_TEXTURE_INTERNAL_FORMAT) - * which must return the specific texture format used when the user might - * have originally specified a generic compressed format in their - * glTexImage2D() call. - * For non-compressed textures, we always return the user-specified - * internal format unchanged. - */ -GLenum -_mesa_compressed_format_to_glenum(struct gl_context *ctx, GLuint mesaFormat) -{ - switch (mesaFormat) { -#if FEATURE_texture_fxt1 - case MESA_FORMAT_RGB_FXT1: - return GL_COMPRESSED_RGB_FXT1_3DFX; - case MESA_FORMAT_RGBA_FXT1: - return GL_COMPRESSED_RGBA_FXT1_3DFX; -#endif -#if FEATURE_texture_s3tc - case MESA_FORMAT_RGB_DXT1: - return GL_COMPRESSED_RGB_S3TC_DXT1_EXT; - case MESA_FORMAT_RGBA_DXT1: - return GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; - case MESA_FORMAT_RGBA_DXT3: - return GL_COMPRESSED_RGBA_S3TC_DXT3_EXT; - case MESA_FORMAT_RGBA_DXT5: - return GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; -#if FEATURE_EXT_texture_sRGB - case MESA_FORMAT_SRGB_DXT1: - return GL_COMPRESSED_SRGB_S3TC_DXT1_EXT; - case MESA_FORMAT_SRGBA_DXT1: - return GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT; - case MESA_FORMAT_SRGBA_DXT3: - return GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT; - case MESA_FORMAT_SRGBA_DXT5: - return GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT; -#endif -#endif - - case MESA_FORMAT_RED_RGTC1: - return GL_COMPRESSED_RED_RGTC1; - case MESA_FORMAT_SIGNED_RED_RGTC1: - return GL_COMPRESSED_SIGNED_RED_RGTC1; - case MESA_FORMAT_RG_RGTC2: - return GL_COMPRESSED_RG_RGTC2; - case MESA_FORMAT_SIGNED_RG_RGTC2: - return GL_COMPRESSED_SIGNED_RG_RGTC2; - - case MESA_FORMAT_L_LATC1: - return GL_COMPRESSED_LUMINANCE_LATC1_EXT; - case MESA_FORMAT_SIGNED_L_LATC1: - return GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT; - case MESA_FORMAT_LA_LATC2: - return GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT; - case MESA_FORMAT_SIGNED_LA_LATC2: - return GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT; - - default: - _mesa_problem(ctx, "Unexpected mesa texture format in" - " _mesa_compressed_format_to_glenum()"); - return 0; - } -} - - -/* - * Return the address of the pixel at (col, row, img) in a - * compressed texture image. - * \param col, row, img - image position (3D), should be a multiple of the - * format's block size. - * \param format - compressed image format - * \param width - image width (stride) in pixels - * \param image - the image address - * \return address of pixel at (row, col, img) - */ -GLubyte * -_mesa_compressed_image_address(GLint col, GLint row, GLint img, - gl_format mesaFormat, - GLsizei width, const GLubyte *image) -{ - /* XXX only 2D images implemented, not 3D */ - const GLuint blockSize = _mesa_get_format_bytes(mesaFormat); - GLuint bw, bh; - GLint offset; - - _mesa_get_format_block_size(mesaFormat, &bw, &bh); - - ASSERT(col % bw == 0); - ASSERT(row % bh == 0); - - offset = ((width + bw - 1) / bw) * (row / bh) + col / bw; - offset *= blockSize; - - return (GLubyte *) image + offset; -} - - -/** - * Decompress a compressed texture image, returning a GL_RGBA/GL_FLOAT image. - */ -void -_mesa_decompress_image(gl_format format, GLuint width, GLuint height, - const GLubyte *src, GLint srcRowStride, - GLfloat *dest) -{ - void (*fetch)(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel); - struct gl_texture_image texImage; /* dummy teximage */ - GLuint i, j; - - /* setup dummy texture image info */ - memset(&texImage, 0, sizeof(texImage)); - texImage.Data = (void *) src; - texImage.RowStride = srcRowStride; - - switch (format) { - /* DXT formats */ - case MESA_FORMAT_RGB_DXT1: - fetch = _mesa_fetch_texel_2d_f_rgb_dxt1; - break; - case MESA_FORMAT_RGBA_DXT1: - fetch = _mesa_fetch_texel_2d_f_rgba_dxt1; - break; - case MESA_FORMAT_RGBA_DXT3: - fetch = _mesa_fetch_texel_2d_f_rgba_dxt3; - break; - case MESA_FORMAT_RGBA_DXT5: - fetch = _mesa_fetch_texel_2d_f_rgba_dxt5; - break; - - /* FXT1 formats */ - case MESA_FORMAT_RGB_FXT1: - fetch = _mesa_fetch_texel_2d_f_rgb_fxt1; - break; - case MESA_FORMAT_RGBA_FXT1: - fetch = _mesa_fetch_texel_2d_f_rgba_fxt1; - break; - - /* Red/RG formats */ - case MESA_FORMAT_RED_RGTC1: - fetch = _mesa_fetch_texel_2d_f_red_rgtc1; - break; - case MESA_FORMAT_SIGNED_RED_RGTC1: - fetch = _mesa_fetch_texel_2d_f_signed_red_rgtc1; - break; - case MESA_FORMAT_RG_RGTC2: - fetch = _mesa_fetch_texel_2d_f_rg_rgtc2; - break; - case MESA_FORMAT_SIGNED_RG_RGTC2: - fetch = _mesa_fetch_texel_2d_f_signed_rg_rgtc2; - break; - - /* L/LA formats */ - case MESA_FORMAT_L_LATC1: - fetch = _mesa_fetch_texel_2d_f_l_latc1; - break; - case MESA_FORMAT_SIGNED_L_LATC1: - fetch = _mesa_fetch_texel_2d_f_signed_l_latc1; - break; - case MESA_FORMAT_LA_LATC2: - fetch = _mesa_fetch_texel_2d_f_la_latc2; - break; - case MESA_FORMAT_SIGNED_LA_LATC2: - fetch = _mesa_fetch_texel_2d_f_signed_la_latc2; - break; - - default: - _mesa_problem(NULL, "Unexpected format in _mesa_decompress_image()"); - return; - } - - for (j = 0; j < height; j++) { - for (i = 0; i < width; i++) { - fetch(&texImage, i, j, 0, dest); - dest += 4; - } - } -} +/* + * Mesa 3-D graphics library + * Version: 6.5.1 + * + * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * Copyright (c) 2008 VMware, 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 + * 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 texcompress.c + * Helper functions for texture compression. + */ + + +#include "glheader.h" +#include "imports.h" +#include "colormac.h" +#include "formats.h" +#include "mfeatures.h" +#include "mtypes.h" +#include "texcompress.h" +#include "texcompress_fxt1.h" +#include "texcompress_rgtc.h" +#include "texcompress_s3tc.h" + + +/** + * Get the GL base format of a specified GL compressed texture format + * + * From page 232 of the OpenGL 3.3 (Compatiblity Profile) spec: + * + * "Compressed Internal Format Base Internal Format Type + * --------------------------- -------------------- --------- + * COMPRESSED_ALPHA ALPHA Generic + * COMPRESSED_LUMINANCE LUMINANCE Generic + * COMPRESSED_LUMINANCE_ALPHA LUMINANCE_ALPHA Generic + * COMPRESSED_INTENSITY INTENSITY Generic + * COMPRESSED_RED RED Generic + * COMPRESSED_RG RG Generic + * COMPRESSED_RGB RGB Generic + * COMPRESSED_RGBA RGBA Generic + * COMPRESSED_SRGB RGB Generic + * COMPRESSED_SRGB_ALPHA RGBA Generic + * COMPRESSED_SLUMINANCE LUMINANCE Generic + * COMPRESSED_SLUMINANCE_ALPHA LUMINANCE_ALPHA Generic + * COMPRESSED_RED_RGTC1 RED Specific + * COMPRESSED_SIGNED_RED_RGTC1 RED Specific + * COMPRESSED_RG_RGTC2 RG Specific + * COMPRESSED_SIGNED_RG_RGTC2 RG Specific" + * + * \return + * The base format of \c format if \c format is a compressed format (either + * generic or specific. Otherwise 0 is returned. + */ +GLenum +_mesa_gl_compressed_format_base_format(GLenum format) +{ + switch (format) { + case GL_COMPRESSED_RED: + case GL_COMPRESSED_RED_RGTC1: + case GL_COMPRESSED_SIGNED_RED_RGTC1: + return GL_RED; + + case GL_COMPRESSED_RG: + case GL_COMPRESSED_RG_RGTC2: + case GL_COMPRESSED_SIGNED_RG_RGTC2: + return GL_RG; + + case GL_COMPRESSED_RGB: + case GL_COMPRESSED_SRGB: + case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: + case GL_COMPRESSED_RGB_FXT1_3DFX: + case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT: + return GL_RGB; + + case GL_COMPRESSED_RGBA: + case GL_COMPRESSED_SRGB_ALPHA: + case GL_COMPRESSED_RGBA_BPTC_UNORM_ARB: + case GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB: + case GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB: + case GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB: + case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: + case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: + case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: + case GL_COMPRESSED_RGBA_FXT1_3DFX: + case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: + case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: + case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: + return GL_RGBA; + + case GL_COMPRESSED_ALPHA: + return GL_ALPHA; + + case GL_COMPRESSED_LUMINANCE: + case GL_COMPRESSED_SLUMINANCE: + case GL_COMPRESSED_LUMINANCE_LATC1_EXT: + case GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT: + return GL_LUMINANCE; + + case GL_COMPRESSED_LUMINANCE_ALPHA: + case GL_COMPRESSED_SLUMINANCE_ALPHA: + case GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT: + case GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT: + case GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI: + return GL_LUMINANCE_ALPHA; + + case GL_COMPRESSED_INTENSITY: + return GL_INTENSITY; + + default: + return 0; + } +} + +/** + * Return list of (and count of) all specific texture compression + * formats that are supported. + * + * Some formats are \b not returned by this function. The + * \c GL_COMPRESSED_TEXTURE_FORMATS query only returns formats that are + * "suitable for general-purpose usage." All texture compression extensions + * have taken this to mean either linear RGB or linear RGBA. + * + * The GL_ARB_texture_compress_rgtc spec says: + * + * "19) Should the GL_NUM_COMPRESSED_TEXTURE_FORMATS and + * GL_COMPRESSED_TEXTURE_FORMATS queries return the RGTC formats? + * + * RESOLVED: No. + * + * The OpenGL 2.1 specification says "The only values returned + * by this query [GL_COMPRESSED_TEXTURE_FORMATS"] are those + * corresponding to formats suitable for general-purpose usage. + * The renderer will not enumerate formats with restrictions that + * need to be specifically understood prior to use." + * + * Compressed textures with just red or red-green components are + * not general-purpose so should not be returned by these queries + * because they have restrictions. + * + * Applications that seek to use the RGTC formats should do so + * by looking for this extension's name in the string returned by + * glGetString(GL_EXTENSIONS) rather than + * what GL_NUM_COMPRESSED_TEXTURE_FORMATS and + * GL_COMPRESSED_TEXTURE_FORMATS return." + * + * There is nearly identical wording in the GL_EXT_texture_compression_rgtc + * spec. + * + * The GL_EXT_texture_rRGB spec says: + * + * "22) Should the new COMPRESSED_SRGB_* formats be listed in an + * implementation's GL_COMPRESSED_TEXTURE_FORMATS list? + * + * RESOLVED: No. Section 3.8.1 says formats listed by + * GL_COMPRESSED_TEXTURE_FORMATS are "suitable for general-purpose + * usage." The non-linear distribution of red, green, and + * blue for these sRGB compressed formats makes them not really + * general-purpose." + * + * The GL_EXT_texture_compression_latc spec says: + * + * "16) Should the GL_NUM_COMPRESSED_TEXTURE_FORMATS and + * GL_COMPRESSED_TEXTURE_FORMATS queries return the LATC formats? + * + * RESOLVED: No. + * + * The OpenGL 2.1 specification says "The only values returned + * by this query [GL_COMPRESSED_TEXTURE_FORMATS"] are those + * corresponding to formats suitable for general-purpose usage. + * The renderer will not enumerate formats with restrictions that + * need to be specifically understood prior to use." + * + * Historically, OpenGL implementation have advertised the RGB and + * RGBA versions of the S3TC extensions compressed format tokens + * through this mechanism. + * + * The specification is not sufficiently clear about what "suitable + * for general-purpose usage" means. Historically that seems to mean + * unsigned RGB or unsigned RGBA. The DXT1 format supporting alpha + * (GL_COMPRESSED_RGBA_S3TC_DXT1_EXT) is not exposed in the list (at + * least for NVIDIA drivers) because the alpha is always 1.0 expect + * when it is 0.0 when RGB is required to be black. NVIDIA's even + * limits itself to true linear RGB or RGBA formats, specifically + * not including EXT_texture_sRGB's sRGB S3TC compressed formats. + * + * Adding luminance and luminance-alpha texture formats (and + * certainly signed versions of luminance and luminance-alpha + * formats!) invites potential comptaibility problems with old + * applications using this mechanism since old applications are + * unlikely to expect non-RGB or non-RGBA formats to be advertised + * through this mechanism. However no specific misinteractions + * with old applications is known. + * + * Applications that seek to use the LATC formats should do so + * by looking for this extension's name in the string returned by + * glGetString(GL_EXTENSIONS) rather than + * what GL_NUM_COMPRESSED_TEXTURE_FORMATS and + * GL_COMPRESSED_TEXTURE_FORMATS return." + * + * There is no formal spec for GL_ATI_texture_compression_3dc. Since the + * formats added by this extension are luminance-alpha formats, it is + * reasonable to expect them to follow the same rules as + * GL_EXT_texture_compression_latc. At the very least, Catalyst 11.6 does not + * expose the 3dc formats through this mechanism. + * + * \param ctx the GL context + * \param formats the resulting format list (may be NULL). + * + * \return number of formats. + */ +GLuint +_mesa_get_compressed_formats(struct gl_context *ctx, GLint *formats) +{ + GLuint n = 0; + if (ctx->Extensions.TDFX_texture_compression_FXT1) { + if (formats) { + formats[n++] = GL_COMPRESSED_RGB_FXT1_3DFX; + formats[n++] = GL_COMPRESSED_RGBA_FXT1_3DFX; + } + else { + n += 2; + } + } + + if (ctx->Extensions.EXT_texture_compression_s3tc) { + if (formats) { + formats[n++] = GL_COMPRESSED_RGB_S3TC_DXT1_EXT; + formats[n++] = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT; + formats[n++] = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; + } + else { + n += 3; + } + } + if (ctx->Extensions.S3_s3tc) { + if (formats) { + formats[n++] = GL_RGB_S3TC; + formats[n++] = GL_RGB4_S3TC; + formats[n++] = GL_RGBA_S3TC; + formats[n++] = GL_RGBA4_S3TC; + } + else { + n += 4; + } + } + +#if FEATURE_ES1 || FEATURE_ES2 + if (formats) { + formats[n++] = GL_PALETTE4_RGB8_OES; + formats[n++] = GL_PALETTE4_RGBA8_OES; + formats[n++] = GL_PALETTE4_R5_G6_B5_OES; + formats[n++] = GL_PALETTE4_RGBA4_OES; + formats[n++] = GL_PALETTE4_RGB5_A1_OES; + formats[n++] = GL_PALETTE8_RGB8_OES; + formats[n++] = GL_PALETTE8_RGBA8_OES; + formats[n++] = GL_PALETTE8_R5_G6_B5_OES; + formats[n++] = GL_PALETTE8_RGBA4_OES; + formats[n++] = GL_PALETTE8_RGB5_A1_OES; + } + else { + n += 10; + } +#endif + + return n; +} + + +/** + * Convert a compressed MESA_FORMAT_x to a GLenum. + */ +gl_format +_mesa_glenum_to_compressed_format(GLenum format) +{ + switch (format) { + case GL_COMPRESSED_RGB_FXT1_3DFX: + return MESA_FORMAT_RGB_FXT1; + case GL_COMPRESSED_RGBA_FXT1_3DFX: + return MESA_FORMAT_RGBA_FXT1; + + case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: + case GL_RGB_S3TC: + return MESA_FORMAT_RGB_DXT1; + case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: + case GL_RGB4_S3TC: + return MESA_FORMAT_RGBA_DXT1; + case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: + case GL_RGBA_S3TC: + return MESA_FORMAT_RGBA_DXT3; + case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: + case GL_RGBA4_S3TC: + return MESA_FORMAT_RGBA_DXT5; + + case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT: + return MESA_FORMAT_SRGB_DXT1; + case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: + return MESA_FORMAT_SRGBA_DXT1; + case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: + return MESA_FORMAT_SRGBA_DXT3; + case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: + return MESA_FORMAT_SRGBA_DXT5; + + case GL_COMPRESSED_RED_RGTC1: + return MESA_FORMAT_RED_RGTC1; + case GL_COMPRESSED_SIGNED_RED_RGTC1: + return MESA_FORMAT_SIGNED_RED_RGTC1; + case GL_COMPRESSED_RG_RGTC2: + return MESA_FORMAT_RG_RGTC2; + case GL_COMPRESSED_SIGNED_RG_RGTC2: + return MESA_FORMAT_SIGNED_RG_RGTC2; + + case GL_COMPRESSED_LUMINANCE_LATC1_EXT: + return MESA_FORMAT_L_LATC1; + case GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT: + return MESA_FORMAT_SIGNED_L_LATC1; + case GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT: + case GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI: + return MESA_FORMAT_LA_LATC2; + case GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT: + return MESA_FORMAT_SIGNED_LA_LATC2; + + default: + return MESA_FORMAT_NONE; + } +} + + +/** + * Given a compressed MESA_FORMAT_x value, return the corresponding + * GLenum for that format. + * This is needed for glGetTexLevelParameter(GL_TEXTURE_INTERNAL_FORMAT) + * which must return the specific texture format used when the user might + * have originally specified a generic compressed format in their + * glTexImage2D() call. + * For non-compressed textures, we always return the user-specified + * internal format unchanged. + */ +GLenum +_mesa_compressed_format_to_glenum(struct gl_context *ctx, GLuint mesaFormat) +{ + switch (mesaFormat) { +#if FEATURE_texture_fxt1 + case MESA_FORMAT_RGB_FXT1: + return GL_COMPRESSED_RGB_FXT1_3DFX; + case MESA_FORMAT_RGBA_FXT1: + return GL_COMPRESSED_RGBA_FXT1_3DFX; +#endif +#if FEATURE_texture_s3tc + case MESA_FORMAT_RGB_DXT1: + return GL_COMPRESSED_RGB_S3TC_DXT1_EXT; + case MESA_FORMAT_RGBA_DXT1: + return GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; + case MESA_FORMAT_RGBA_DXT3: + return GL_COMPRESSED_RGBA_S3TC_DXT3_EXT; + case MESA_FORMAT_RGBA_DXT5: + return GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; +#if FEATURE_EXT_texture_sRGB + case MESA_FORMAT_SRGB_DXT1: + return GL_COMPRESSED_SRGB_S3TC_DXT1_EXT; + case MESA_FORMAT_SRGBA_DXT1: + return GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT; + case MESA_FORMAT_SRGBA_DXT3: + return GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT; + case MESA_FORMAT_SRGBA_DXT5: + return GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT; +#endif +#endif + + case MESA_FORMAT_RED_RGTC1: + return GL_COMPRESSED_RED_RGTC1; + case MESA_FORMAT_SIGNED_RED_RGTC1: + return GL_COMPRESSED_SIGNED_RED_RGTC1; + case MESA_FORMAT_RG_RGTC2: + return GL_COMPRESSED_RG_RGTC2; + case MESA_FORMAT_SIGNED_RG_RGTC2: + return GL_COMPRESSED_SIGNED_RG_RGTC2; + + case MESA_FORMAT_L_LATC1: + return GL_COMPRESSED_LUMINANCE_LATC1_EXT; + case MESA_FORMAT_SIGNED_L_LATC1: + return GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT; + case MESA_FORMAT_LA_LATC2: + return GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT; + case MESA_FORMAT_SIGNED_LA_LATC2: + return GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT; + + default: + _mesa_problem(ctx, "Unexpected mesa texture format in" + " _mesa_compressed_format_to_glenum()"); + return 0; + } +} + + +/* + * Return the address of the pixel at (col, row, img) in a + * compressed texture image. + * \param col, row, img - image position (3D), should be a multiple of the + * format's block size. + * \param format - compressed image format + * \param width - image width (stride) in pixels + * \param image - the image address + * \return address of pixel at (row, col, img) + */ +GLubyte * +_mesa_compressed_image_address(GLint col, GLint row, GLint img, + gl_format mesaFormat, + GLsizei width, const GLubyte *image) +{ + /* XXX only 2D images implemented, not 3D */ + const GLuint blockSize = _mesa_get_format_bytes(mesaFormat); + GLuint bw, bh; + GLint offset; + + _mesa_get_format_block_size(mesaFormat, &bw, &bh); + + ASSERT(col % bw == 0); + ASSERT(row % bh == 0); + + offset = ((width + bw - 1) / bw) * (row / bh) + col / bw; + offset *= blockSize; + + return (GLubyte *) image + offset; +} + + +/** + * Decompress a compressed texture image, returning a GL_RGBA/GL_FLOAT image. + */ +void +_mesa_decompress_image(gl_format format, GLuint width, GLuint height, + const GLubyte *src, GLint srcRowStride, + GLfloat *dest) +{ + void (*fetch)(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel); + struct gl_texture_image texImage; /* dummy teximage */ + GLuint i, j; + + /* setup dummy texture image info */ + memset(&texImage, 0, sizeof(texImage)); + texImage.Data = (void *) src; + texImage.RowStride = srcRowStride; + + switch (format) { + /* DXT formats */ + case MESA_FORMAT_RGB_DXT1: + fetch = _mesa_fetch_texel_2d_f_rgb_dxt1; + break; + case MESA_FORMAT_RGBA_DXT1: + fetch = _mesa_fetch_texel_2d_f_rgba_dxt1; + break; + case MESA_FORMAT_RGBA_DXT3: + fetch = _mesa_fetch_texel_2d_f_rgba_dxt3; + break; + case MESA_FORMAT_RGBA_DXT5: + fetch = _mesa_fetch_texel_2d_f_rgba_dxt5; + break; + + /* FXT1 formats */ + case MESA_FORMAT_RGB_FXT1: + fetch = _mesa_fetch_texel_2d_f_rgb_fxt1; + break; + case MESA_FORMAT_RGBA_FXT1: + fetch = _mesa_fetch_texel_2d_f_rgba_fxt1; + break; + + /* Red/RG formats */ + case MESA_FORMAT_RED_RGTC1: + fetch = _mesa_fetch_texel_2d_f_red_rgtc1; + break; + case MESA_FORMAT_SIGNED_RED_RGTC1: + fetch = _mesa_fetch_texel_2d_f_signed_red_rgtc1; + break; + case MESA_FORMAT_RG_RGTC2: + fetch = _mesa_fetch_texel_2d_f_rg_rgtc2; + break; + case MESA_FORMAT_SIGNED_RG_RGTC2: + fetch = _mesa_fetch_texel_2d_f_signed_rg_rgtc2; + break; + + /* L/LA formats */ + case MESA_FORMAT_L_LATC1: + fetch = _mesa_fetch_texel_2d_f_l_latc1; + break; + case MESA_FORMAT_SIGNED_L_LATC1: + fetch = _mesa_fetch_texel_2d_f_signed_l_latc1; + break; + case MESA_FORMAT_LA_LATC2: + fetch = _mesa_fetch_texel_2d_f_la_latc2; + break; + case MESA_FORMAT_SIGNED_LA_LATC2: + fetch = _mesa_fetch_texel_2d_f_signed_la_latc2; + break; + + default: + _mesa_problem(NULL, "Unexpected format in _mesa_decompress_image()"); + return; + } + + for (j = 0; j < height; j++) { + for (i = 0; i < width; i++) { + fetch(&texImage, i, j, 0, dest); + dest += 4; + } + } +} diff --git a/mesalib/src/mesa/main/texcompress_rgtc.h b/mesalib/src/mesa/main/texcompress_rgtc.h index a64ef9968..18766770d 100644 --- a/mesalib/src/mesa/main/texcompress_rgtc.h +++ b/mesalib/src/mesa/main/texcompress_rgtc.h @@ -1,77 +1,77 @@ -/* - * Copyright (C) 2011 Red Hat 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 (including the next - * paragraph) 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. - */ - -#ifndef TEXCOMPRESS_RGTC_H -#define TEXCOMPRESS_RGTC_H - -#include "glheader.h" -#include "mfeatures.h" -#include "texstore.h" - -struct gl_texture_image; - -extern GLboolean -_mesa_texstore_red_rgtc1(TEXSTORE_PARAMS); - -extern GLboolean -_mesa_texstore_signed_red_rgtc1(TEXSTORE_PARAMS); - -extern GLboolean -_mesa_texstore_rg_rgtc2(TEXSTORE_PARAMS); - -extern GLboolean -_mesa_texstore_signed_rg_rgtc2(TEXSTORE_PARAMS); - -extern void -_mesa_fetch_texel_2d_f_red_rgtc1(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel); - -extern void -_mesa_fetch_texel_2d_f_signed_red_rgtc1(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel); - -extern void -_mesa_fetch_texel_2d_f_rg_rgtc2(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel); - -extern void -_mesa_fetch_texel_2d_f_signed_rg_rgtc2(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel); - -extern void -_mesa_fetch_texel_2d_f_l_latc1(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel); - -extern void -_mesa_fetch_texel_2d_f_signed_l_latc1(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel); - -extern void -_mesa_fetch_texel_2d_f_la_latc2(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel); - -extern void -_mesa_fetch_texel_2d_f_signed_la_latc2(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel); - -#endif +/* + * Copyright (C) 2011 Red Hat 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 (including the next + * paragraph) 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. + */ + +#ifndef TEXCOMPRESS_RGTC_H +#define TEXCOMPRESS_RGTC_H + +#include "glheader.h" +#include "mfeatures.h" +#include "texstore.h" + +struct gl_texture_image; + +extern GLboolean +_mesa_texstore_red_rgtc1(TEXSTORE_PARAMS); + +extern GLboolean +_mesa_texstore_signed_red_rgtc1(TEXSTORE_PARAMS); + +extern GLboolean +_mesa_texstore_rg_rgtc2(TEXSTORE_PARAMS); + +extern GLboolean +_mesa_texstore_signed_rg_rgtc2(TEXSTORE_PARAMS); + +extern void +_mesa_fetch_texel_2d_f_red_rgtc1(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel); + +extern void +_mesa_fetch_texel_2d_f_signed_red_rgtc1(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel); + +extern void +_mesa_fetch_texel_2d_f_rg_rgtc2(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel); + +extern void +_mesa_fetch_texel_2d_f_signed_rg_rgtc2(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel); + +extern void +_mesa_fetch_texel_2d_f_l_latc1(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel); + +extern void +_mesa_fetch_texel_2d_f_signed_l_latc1(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel); + +extern void +_mesa_fetch_texel_2d_f_la_latc2(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel); + +extern void +_mesa_fetch_texel_2d_f_signed_la_latc2(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel); + +#endif diff --git a/mesalib/src/mesa/main/texcompress_rgtc_tmp.h b/mesalib/src/mesa/main/texcompress_rgtc_tmp.h index 211c53ece..48bbd374e 100644 --- a/mesalib/src/mesa/main/texcompress_rgtc_tmp.h +++ b/mesalib/src/mesa/main/texcompress_rgtc_tmp.h @@ -1,418 +1,418 @@ -/* - * Copyright (C) 2011 Red Hat Inc. - * - * block compression parts are: - * Copyright (C) 2004 Roland Scheidegger 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 (including the next - * paragraph) 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. - * - * Author: - * Dave Airlie - */ - -/* included by texcompress_rgtc to define byte/ubyte compressors */ - -static void TAG(fetch_texel_rgtc)(unsigned srcRowStride, const TYPE *pixdata, - unsigned i, unsigned j, TYPE *value, unsigned comps) -{ - TYPE decode; - const TYPE *blksrc = (pixdata + ((srcRowStride + 3) / 4 * (j / 4) + (i / 4)) * 8 * comps); - const TYPE alpha0 = blksrc[0]; - const TYPE alpha1 = blksrc[1]; - const char bit_pos = ((j&3) * 4 + (i&3)) * 3; - const TYPE acodelow = blksrc[2 + bit_pos / 8]; - const TYPE acodehigh = (3 + bit_pos / 8) < 8 ? blksrc[3 + bit_pos / 8] : 0; - const TYPE code = (acodelow >> (bit_pos & 0x7) | - (acodehigh << (8 - (bit_pos & 0x7)))) & 0x7; - - if (code == 0) - decode = alpha0; - else if (code == 1) - decode = alpha1; - else if (alpha0 > alpha1) - decode = ((alpha0 * (8 - code) + (alpha1 * (code - 1))) / 7); - else if (code < 6) - decode = ((alpha0 * (6 - code) + (alpha1 * (code - 1))) / 5); - else if (code == 6) - decode = T_MIN; - else - decode = T_MAX; - - *value = decode; -} - -static void TAG(write_rgtc_encoded_channel)(TYPE *blkaddr, - TYPE alphabase1, - TYPE alphabase2, - TYPE alphaenc[16]) -{ - *blkaddr++ = alphabase1; - *blkaddr++ = alphabase2; - *blkaddr++ = alphaenc[0] | (alphaenc[1] << 3) | ((alphaenc[2] & 3) << 6); - *blkaddr++ = (alphaenc[2] >> 2) | (alphaenc[3] << 1) | (alphaenc[4] << 4) | ((alphaenc[5] & 1) << 7); - *blkaddr++ = (alphaenc[5] >> 1) | (alphaenc[6] << 2) | (alphaenc[7] << 5); - *blkaddr++ = alphaenc[8] | (alphaenc[9] << 3) | ((alphaenc[10] & 3) << 6); - *blkaddr++ = (alphaenc[10] >> 2) | (alphaenc[11] << 1) | (alphaenc[12] << 4) | ((alphaenc[13] & 1) << 7); - *blkaddr++ = (alphaenc[13] >> 1) | (alphaenc[14] << 2) | (alphaenc[15] << 5); -} - -static void TAG(encode_rgtc_chan)(TYPE *blkaddr, TYPE srccolors[4][4], - int numxpixels, int numypixels) -{ - TYPE alphabase[2], alphause[2]; - short alphatest[2] = { 0 }; - unsigned int alphablockerror1, alphablockerror2, alphablockerror3; - TYPE i, j, aindex, acutValues[7]; - TYPE alphaenc1[16], alphaenc2[16], alphaenc3[16]; - int alphaabsmin = 0, alphaabsmax = 0; - short alphadist; - - /* find lowest and highest alpha value in block, alphabase[0] lowest, alphabase[1] highest */ - alphabase[0] = T_MAX; alphabase[1] = T_MIN; - for (j = 0; j < numypixels; j++) { - for (i = 0; i < numxpixels; i++) { - if (srccolors[j][i] == T_MIN) - alphaabsmin = 1; - else if (srccolors[j][i] == T_MAX) - alphaabsmax = 1; - else { - if (srccolors[j][i] > alphabase[1]) - alphabase[1] = srccolors[j][i]; - if (srccolors[j][i] < alphabase[0]) - alphabase[0] = srccolors[j][i]; - } - } - } - - - if (((alphabase[0] > alphabase[1]) && !(alphaabsmin && alphaabsmax)) - || (alphabase[0] == alphabase[1] && !alphaabsmin && !alphaabsmax)) { /* one color, either max or min */ - /* shortcut here since it is a very common case (and also avoids later problems) */ - /* could also thest for alpha0 == alpha1 (and not min/max), but probably not common, so don't bother */ - - *blkaddr++ = srccolors[0][0]; - blkaddr++; - *blkaddr++ = 0; - *blkaddr++ = 0; - *blkaddr++ = 0; - *blkaddr++ = 0; - *blkaddr++ = 0; - *blkaddr++ = 0; -#if RGTC_DEBUG - fprintf(stderr, "enc0 used\n"); -#endif - return; - } - - /* find best encoding for alpha0 > alpha1 */ - /* it's possible this encoding is better even if both alphaabsmin and alphaabsmax are true */ - alphablockerror1 = 0x0; - alphablockerror2 = 0xffffffff; - alphablockerror3 = 0xffffffff; - if (alphaabsmin) alphause[0] = T_MIN; - else alphause[0] = alphabase[0]; - if (alphaabsmax) alphause[1] = T_MAX; - else alphause[1] = alphabase[1]; - /* calculate the 7 cut values, just the middle between 2 of the computed alpha values */ - for (aindex = 0; aindex < 7; aindex++) { - /* don't forget here is always rounded down */ - acutValues[aindex] = (alphause[0] * (2*aindex + 1) + alphause[1] * (14 - (2*aindex + 1))) / 14; - } - - for (j = 0; j < numypixels; j++) { - for (i = 0; i < numxpixels; i++) { - /* maybe it's overkill to have the most complicated calculation just for the error - calculation which we only need to figure out if encoding1 or encoding2 is better... */ - if (srccolors[j][i] > acutValues[0]) { - alphaenc1[4*j + i] = 0; - alphadist = srccolors[j][i] - alphause[1]; - } - else if (srccolors[j][i] > acutValues[1]) { - alphaenc1[4*j + i] = 2; - alphadist = srccolors[j][i] - (alphause[1] * 6 + alphause[0] * 1) / 7; - } - else if (srccolors[j][i] > acutValues[2]) { - alphaenc1[4*j + i] = 3; - alphadist = srccolors[j][i] - (alphause[1] * 5 + alphause[0] * 2) / 7; - } - else if (srccolors[j][i] > acutValues[3]) { - alphaenc1[4*j + i] = 4; - alphadist = srccolors[j][i] - (alphause[1] * 4 + alphause[0] * 3) / 7; - } - else if (srccolors[j][i] > acutValues[4]) { - alphaenc1[4*j + i] = 5; - alphadist = srccolors[j][i] - (alphause[1] * 3 + alphause[0] * 4) / 7; - } - else if (srccolors[j][i] > acutValues[5]) { - alphaenc1[4*j + i] = 6; - alphadist = srccolors[j][i] - (alphause[1] * 2 + alphause[0] * 5) / 7; - } - else if (srccolors[j][i] > acutValues[6]) { - alphaenc1[4*j + i] = 7; - alphadist = srccolors[j][i] - (alphause[1] * 1 + alphause[0] * 6) / 7; - } - else { - alphaenc1[4*j + i] = 1; - alphadist = srccolors[j][i] - alphause[0]; - } - alphablockerror1 += alphadist * alphadist; - } - } - -#if RGTC_DEBUG - for (i = 0; i < 16; i++) { - fprintf(stderr, "%d ", alphaenc1[i]); - } - fprintf(stderr, "cutVals "); - for (i = 0; i < 7; i++) { - fprintf(stderr, "%d ", acutValues[i]); - } - fprintf(stderr, "srcVals "); - for (j = 0; j < numypixels; j++) { - for (i = 0; i < numxpixels; i++) { - fprintf(stderr, "%d ", srccolors[j][i]); - } - } - fprintf(stderr, "\n"); -#endif - - /* it's not very likely this encoding is better if both alphaabsmin and alphaabsmax - are false but try it anyway */ - if (alphablockerror1 >= 32) { - - /* don't bother if encoding is already very good, this condition should also imply - we have valid alphabase colors which we absolutely need (alphabase[0] <= alphabase[1]) */ - alphablockerror2 = 0; - for (aindex = 0; aindex < 5; aindex++) { - /* don't forget here is always rounded down */ - acutValues[aindex] = (alphabase[0] * (10 - (2*aindex + 1)) + alphabase[1] * (2*aindex + 1)) / 10; - } - for (j = 0; j < numypixels; j++) { - for (i = 0; i < numxpixels; i++) { - /* maybe it's overkill to have the most complicated calculation just for the error - calculation which we only need to figure out if encoding1 or encoding2 is better... */ - if (srccolors[j][i] == T_MIN) { - alphaenc2[4*j + i] = 6; - alphadist = 0; - } - else if (srccolors[j][i] == T_MAX) { - alphaenc2[4*j + i] = 7; - alphadist = 0; - } - else if (srccolors[j][i] <= acutValues[0]) { - alphaenc2[4*j + i] = 0; - alphadist = srccolors[j][i] - alphabase[0]; - } - else if (srccolors[j][i] <= acutValues[1]) { - alphaenc2[4*j + i] = 2; - alphadist = srccolors[j][i] - (alphabase[0] * 4 + alphabase[1] * 1) / 5; - } - else if (srccolors[j][i] <= acutValues[2]) { - alphaenc2[4*j + i] = 3; - alphadist = srccolors[j][i] - (alphabase[0] * 3 + alphabase[1] * 2) / 5; - } - else if (srccolors[j][i] <= acutValues[3]) { - alphaenc2[4*j + i] = 4; - alphadist = srccolors[j][i] - (alphabase[0] * 2 + alphabase[1] * 3) / 5; - } - else if (srccolors[j][i] <= acutValues[4]) { - alphaenc2[4*j + i] = 5; - alphadist = srccolors[j][i] - (alphabase[0] * 1 + alphabase[1] * 4) / 5; - } - else { - alphaenc2[4*j + i] = 1; - alphadist = srccolors[j][i] - alphabase[1]; - } - alphablockerror2 += alphadist * alphadist; - } - } - - - /* skip this if the error is already very small - this encoding is MUCH better on average than #2 though, but expensive! */ - if ((alphablockerror2 > 96) && (alphablockerror1 > 96)) { - short blockerrlin1 = 0; - short blockerrlin2 = 0; - TYPE nralphainrangelow = 0; - TYPE nralphainrangehigh = 0; - alphatest[0] = T_MAX; - alphatest[1] = T_MIN; - /* if we have large range it's likely there are values close to 0/255, try to map them to 0/255 */ - for (j = 0; j < numypixels; j++) { - for (i = 0; i < numxpixels; i++) { - if ((srccolors[j][i] > alphatest[1]) && (srccolors[j][i] < (T_MAX -(alphabase[1] - alphabase[0]) / 28))) - alphatest[1] = srccolors[j][i]; - if ((srccolors[j][i] < alphatest[0]) && (srccolors[j][i] > (alphabase[1] - alphabase[0]) / 28)) - alphatest[0] = srccolors[j][i]; - } - } - /* shouldn't happen too often, don't really care about those degenerated cases */ - if (alphatest[1] <= alphatest[0]) { - alphatest[0] = T_MIN+1; - alphatest[1] = T_MAX-1; - } - for (aindex = 0; aindex < 5; aindex++) { - /* don't forget here is always rounded down */ - acutValues[aindex] = (alphatest[0] * (10 - (2*aindex + 1)) + alphatest[1] * (2*aindex + 1)) / 10; - } - - /* find the "average" difference between the alpha values and the next encoded value. - This is then used to calculate new base values. - Should there be some weighting, i.e. those values closer to alphatest[x] have more weight, - since they will see more improvement, and also because the values in the middle are somewhat - likely to get no improvement at all (because the base values might move in different directions)? - OTOH it would mean the values in the middle are even less likely to get an improvement - */ - for (j = 0; j < numypixels; j++) { - for (i = 0; i < numxpixels; i++) { - if (srccolors[j][i] <= alphatest[0] / 2) { - } - else if (srccolors[j][i] > ((T_MAX + alphatest[1]) / 2)) { - } - else if (srccolors[j][i] <= acutValues[0]) { - blockerrlin1 += (srccolors[j][i] - alphatest[0]); - nralphainrangelow += 1; - } - else if (srccolors[j][i] <= acutValues[1]) { - blockerrlin1 += (srccolors[j][i] - (alphatest[0] * 4 + alphatest[1] * 1) / 5); - blockerrlin2 += (srccolors[j][i] - (alphatest[0] * 4 + alphatest[1] * 1) / 5); - nralphainrangelow += 1; - nralphainrangehigh += 1; - } - else if (srccolors[j][i] <= acutValues[2]) { - blockerrlin1 += (srccolors[j][i] - (alphatest[0] * 3 + alphatest[1] * 2) / 5); - blockerrlin2 += (srccolors[j][i] - (alphatest[0] * 3 + alphatest[1] * 2) / 5); - nralphainrangelow += 1; - nralphainrangehigh += 1; - } - else if (srccolors[j][i] <= acutValues[3]) { - blockerrlin1 += (srccolors[j][i] - (alphatest[0] * 2 + alphatest[1] * 3) / 5); - blockerrlin2 += (srccolors[j][i] - (alphatest[0] * 2 + alphatest[1] * 3) / 5); - nralphainrangelow += 1; - nralphainrangehigh += 1; - } - else if (srccolors[j][i] <= acutValues[4]) { - blockerrlin1 += (srccolors[j][i] - (alphatest[0] * 1 + alphatest[1] * 4) / 5); - blockerrlin2 += (srccolors[j][i] - (alphatest[0] * 1 + alphatest[1] * 4) / 5); - nralphainrangelow += 1; - nralphainrangehigh += 1; - } - else { - blockerrlin2 += (srccolors[j][i] - alphatest[1]); - nralphainrangehigh += 1; - } - } - } - /* shouldn't happen often, needed to avoid div by zero */ - if (nralphainrangelow == 0) nralphainrangelow = 1; - if (nralphainrangehigh == 0) nralphainrangehigh = 1; - alphatest[0] = alphatest[0] + (blockerrlin1 / nralphainrangelow); -#if RGTC_DEBUG - fprintf(stderr, "block err lin low %d, nr %d\n", blockerrlin1, nralphainrangelow); - fprintf(stderr, "block err lin high %d, nr %d\n", blockerrlin2, nralphainrangehigh); -#endif - /* again shouldn't really happen often... */ - if (alphatest[0] < T_MIN) { - alphatest[0] = T_MIN; - } - alphatest[1] = alphatest[1] + (blockerrlin2 / nralphainrangehigh); - if (alphatest[1] > T_MAX) { - alphatest[1] = T_MAX; - } - - alphablockerror3 = 0; - for (aindex = 0; aindex < 5; aindex++) { - /* don't forget here is always rounded down */ - acutValues[aindex] = (alphatest[0] * (10 - (2*aindex + 1)) + alphatest[1] * (2*aindex + 1)) / 10; - } - for (j = 0; j < numypixels; j++) { - for (i = 0; i < numxpixels; i++) { - /* maybe it's overkill to have the most complicated calculation just for the error - calculation which we only need to figure out if encoding1 or encoding2 is better... */ - if (srccolors[j][i] <= alphatest[0] / 2) { - alphaenc3[4*j + i] = 6; - alphadist = srccolors[j][i]; - } - else if (srccolors[j][i] > ((T_MAX + alphatest[1]) / 2)) { - alphaenc3[4*j + i] = 7; - alphadist = T_MAX - srccolors[j][i]; - } - else if (srccolors[j][i] <= acutValues[0]) { - alphaenc3[4*j + i] = 0; - alphadist = srccolors[j][i] - alphatest[0]; - } - else if (srccolors[j][i] <= acutValues[1]) { - alphaenc3[4*j + i] = 2; - alphadist = srccolors[j][i] - (alphatest[0] * 4 + alphatest[1] * 1) / 5; - } - else if (srccolors[j][i] <= acutValues[2]) { - alphaenc3[4*j + i] = 3; - alphadist = srccolors[j][i] - (alphatest[0] * 3 + alphatest[1] * 2) / 5; - } - else if (srccolors[j][i] <= acutValues[3]) { - alphaenc3[4*j + i] = 4; - alphadist = srccolors[j][i] - (alphatest[0] * 2 + alphatest[1] * 3) / 5; - } - else if (srccolors[j][i] <= acutValues[4]) { - alphaenc3[4*j + i] = 5; - alphadist = srccolors[j][i] - (alphatest[0] * 1 + alphatest[1] * 4) / 5; - } - else { - alphaenc3[4*j + i] = 1; - alphadist = srccolors[j][i] - alphatest[1]; - } - alphablockerror3 += alphadist * alphadist; - } - } - } - } - - /* write the alpha values and encoding back. */ - if ((alphablockerror1 <= alphablockerror2) && (alphablockerror1 <= alphablockerror3)) { -#if RGTC_DEBUG - if (alphablockerror1 > 96) fprintf(stderr, "enc1 used, error %d\n", alphablockerror1); - fprintf(stderr,"w1: min %d max %d au0 %d au1 %d\n", - T_MIN, T_MAX, - alphause[1], alphause[0]); -#endif - - TAG(write_rgtc_encoded_channel)( blkaddr, alphause[1], alphause[0], alphaenc1 ); - } - else if (alphablockerror2 <= alphablockerror3) { -#if RGTC_DEBUG - if (alphablockerror2 > 96) fprintf(stderr, "enc2 used, error %d\n", alphablockerror2); - fprintf(stderr,"w2: min %d max %d au0 %d au1 %d\n", - T_MIN, T_MAX, - alphabase[0], alphabase[1]); -#endif - - TAG(write_rgtc_encoded_channel)( blkaddr, alphabase[0], alphabase[1], alphaenc2 ); - } - else { -#if RGTC_DEBUG - fprintf(stderr, "enc3 used, error %d\n", alphablockerror3); - fprintf(stderr,"w3: min %d max %d au0 %d au1 %d\n", - T_MIN, T_MAX, - alphatest[0], alphatest[1]); -#endif - - TAG(write_rgtc_encoded_channel)( blkaddr, (TYPE)alphatest[0], (TYPE)alphatest[1], alphaenc3 ); - } -} +/* + * Copyright (C) 2011 Red Hat Inc. + * + * block compression parts are: + * Copyright (C) 2004 Roland Scheidegger 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 (including the next + * paragraph) 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. + * + * Author: + * Dave Airlie + */ + +/* included by texcompress_rgtc to define byte/ubyte compressors */ + +static void TAG(fetch_texel_rgtc)(unsigned srcRowStride, const TYPE *pixdata, + unsigned i, unsigned j, TYPE *value, unsigned comps) +{ + TYPE decode; + const TYPE *blksrc = (pixdata + ((srcRowStride + 3) / 4 * (j / 4) + (i / 4)) * 8 * comps); + const TYPE alpha0 = blksrc[0]; + const TYPE alpha1 = blksrc[1]; + const char bit_pos = ((j&3) * 4 + (i&3)) * 3; + const TYPE acodelow = blksrc[2 + bit_pos / 8]; + const TYPE acodehigh = (3 + bit_pos / 8) < 8 ? blksrc[3 + bit_pos / 8] : 0; + const TYPE code = (acodelow >> (bit_pos & 0x7) | + (acodehigh << (8 - (bit_pos & 0x7)))) & 0x7; + + if (code == 0) + decode = alpha0; + else if (code == 1) + decode = alpha1; + else if (alpha0 > alpha1) + decode = ((alpha0 * (8 - code) + (alpha1 * (code - 1))) / 7); + else if (code < 6) + decode = ((alpha0 * (6 - code) + (alpha1 * (code - 1))) / 5); + else if (code == 6) + decode = T_MIN; + else + decode = T_MAX; + + *value = decode; +} + +static void TAG(write_rgtc_encoded_channel)(TYPE *blkaddr, + TYPE alphabase1, + TYPE alphabase2, + TYPE alphaenc[16]) +{ + *blkaddr++ = alphabase1; + *blkaddr++ = alphabase2; + *blkaddr++ = alphaenc[0] | (alphaenc[1] << 3) | ((alphaenc[2] & 3) << 6); + *blkaddr++ = (alphaenc[2] >> 2) | (alphaenc[3] << 1) | (alphaenc[4] << 4) | ((alphaenc[5] & 1) << 7); + *blkaddr++ = (alphaenc[5] >> 1) | (alphaenc[6] << 2) | (alphaenc[7] << 5); + *blkaddr++ = alphaenc[8] | (alphaenc[9] << 3) | ((alphaenc[10] & 3) << 6); + *blkaddr++ = (alphaenc[10] >> 2) | (alphaenc[11] << 1) | (alphaenc[12] << 4) | ((alphaenc[13] & 1) << 7); + *blkaddr++ = (alphaenc[13] >> 1) | (alphaenc[14] << 2) | (alphaenc[15] << 5); +} + +static void TAG(encode_rgtc_chan)(TYPE *blkaddr, TYPE srccolors[4][4], + int numxpixels, int numypixels) +{ + TYPE alphabase[2], alphause[2]; + short alphatest[2] = { 0 }; + unsigned int alphablockerror1, alphablockerror2, alphablockerror3; + TYPE i, j, aindex, acutValues[7]; + TYPE alphaenc1[16], alphaenc2[16], alphaenc3[16]; + int alphaabsmin = 0, alphaabsmax = 0; + short alphadist; + + /* find lowest and highest alpha value in block, alphabase[0] lowest, alphabase[1] highest */ + alphabase[0] = T_MAX; alphabase[1] = T_MIN; + for (j = 0; j < numypixels; j++) { + for (i = 0; i < numxpixels; i++) { + if (srccolors[j][i] == T_MIN) + alphaabsmin = 1; + else if (srccolors[j][i] == T_MAX) + alphaabsmax = 1; + else { + if (srccolors[j][i] > alphabase[1]) + alphabase[1] = srccolors[j][i]; + if (srccolors[j][i] < alphabase[0]) + alphabase[0] = srccolors[j][i]; + } + } + } + + + if (((alphabase[0] > alphabase[1]) && !(alphaabsmin && alphaabsmax)) + || (alphabase[0] == alphabase[1] && !alphaabsmin && !alphaabsmax)) { /* one color, either max or min */ + /* shortcut here since it is a very common case (and also avoids later problems) */ + /* could also thest for alpha0 == alpha1 (and not min/max), but probably not common, so don't bother */ + + *blkaddr++ = srccolors[0][0]; + blkaddr++; + *blkaddr++ = 0; + *blkaddr++ = 0; + *blkaddr++ = 0; + *blkaddr++ = 0; + *blkaddr++ = 0; + *blkaddr++ = 0; +#if RGTC_DEBUG + fprintf(stderr, "enc0 used\n"); +#endif + return; + } + + /* find best encoding for alpha0 > alpha1 */ + /* it's possible this encoding is better even if both alphaabsmin and alphaabsmax are true */ + alphablockerror1 = 0x0; + alphablockerror2 = 0xffffffff; + alphablockerror3 = 0xffffffff; + if (alphaabsmin) alphause[0] = T_MIN; + else alphause[0] = alphabase[0]; + if (alphaabsmax) alphause[1] = T_MAX; + else alphause[1] = alphabase[1]; + /* calculate the 7 cut values, just the middle between 2 of the computed alpha values */ + for (aindex = 0; aindex < 7; aindex++) { + /* don't forget here is always rounded down */ + acutValues[aindex] = (alphause[0] * (2*aindex + 1) + alphause[1] * (14 - (2*aindex + 1))) / 14; + } + + for (j = 0; j < numypixels; j++) { + for (i = 0; i < numxpixels; i++) { + /* maybe it's overkill to have the most complicated calculation just for the error + calculation which we only need to figure out if encoding1 or encoding2 is better... */ + if (srccolors[j][i] > acutValues[0]) { + alphaenc1[4*j + i] = 0; + alphadist = srccolors[j][i] - alphause[1]; + } + else if (srccolors[j][i] > acutValues[1]) { + alphaenc1[4*j + i] = 2; + alphadist = srccolors[j][i] - (alphause[1] * 6 + alphause[0] * 1) / 7; + } + else if (srccolors[j][i] > acutValues[2]) { + alphaenc1[4*j + i] = 3; + alphadist = srccolors[j][i] - (alphause[1] * 5 + alphause[0] * 2) / 7; + } + else if (srccolors[j][i] > acutValues[3]) { + alphaenc1[4*j + i] = 4; + alphadist = srccolors[j][i] - (alphause[1] * 4 + alphause[0] * 3) / 7; + } + else if (srccolors[j][i] > acutValues[4]) { + alphaenc1[4*j + i] = 5; + alphadist = srccolors[j][i] - (alphause[1] * 3 + alphause[0] * 4) / 7; + } + else if (srccolors[j][i] > acutValues[5]) { + alphaenc1[4*j + i] = 6; + alphadist = srccolors[j][i] - (alphause[1] * 2 + alphause[0] * 5) / 7; + } + else if (srccolors[j][i] > acutValues[6]) { + alphaenc1[4*j + i] = 7; + alphadist = srccolors[j][i] - (alphause[1] * 1 + alphause[0] * 6) / 7; + } + else { + alphaenc1[4*j + i] = 1; + alphadist = srccolors[j][i] - alphause[0]; + } + alphablockerror1 += alphadist * alphadist; + } + } + +#if RGTC_DEBUG + for (i = 0; i < 16; i++) { + fprintf(stderr, "%d ", alphaenc1[i]); + } + fprintf(stderr, "cutVals "); + for (i = 0; i < 7; i++) { + fprintf(stderr, "%d ", acutValues[i]); + } + fprintf(stderr, "srcVals "); + for (j = 0; j < numypixels; j++) { + for (i = 0; i < numxpixels; i++) { + fprintf(stderr, "%d ", srccolors[j][i]); + } + } + fprintf(stderr, "\n"); +#endif + + /* it's not very likely this encoding is better if both alphaabsmin and alphaabsmax + are false but try it anyway */ + if (alphablockerror1 >= 32) { + + /* don't bother if encoding is already very good, this condition should also imply + we have valid alphabase colors which we absolutely need (alphabase[0] <= alphabase[1]) */ + alphablockerror2 = 0; + for (aindex = 0; aindex < 5; aindex++) { + /* don't forget here is always rounded down */ + acutValues[aindex] = (alphabase[0] * (10 - (2*aindex + 1)) + alphabase[1] * (2*aindex + 1)) / 10; + } + for (j = 0; j < numypixels; j++) { + for (i = 0; i < numxpixels; i++) { + /* maybe it's overkill to have the most complicated calculation just for the error + calculation which we only need to figure out if encoding1 or encoding2 is better... */ + if (srccolors[j][i] == T_MIN) { + alphaenc2[4*j + i] = 6; + alphadist = 0; + } + else if (srccolors[j][i] == T_MAX) { + alphaenc2[4*j + i] = 7; + alphadist = 0; + } + else if (srccolors[j][i] <= acutValues[0]) { + alphaenc2[4*j + i] = 0; + alphadist = srccolors[j][i] - alphabase[0]; + } + else if (srccolors[j][i] <= acutValues[1]) { + alphaenc2[4*j + i] = 2; + alphadist = srccolors[j][i] - (alphabase[0] * 4 + alphabase[1] * 1) / 5; + } + else if (srccolors[j][i] <= acutValues[2]) { + alphaenc2[4*j + i] = 3; + alphadist = srccolors[j][i] - (alphabase[0] * 3 + alphabase[1] * 2) / 5; + } + else if (srccolors[j][i] <= acutValues[3]) { + alphaenc2[4*j + i] = 4; + alphadist = srccolors[j][i] - (alphabase[0] * 2 + alphabase[1] * 3) / 5; + } + else if (srccolors[j][i] <= acutValues[4]) { + alphaenc2[4*j + i] = 5; + alphadist = srccolors[j][i] - (alphabase[0] * 1 + alphabase[1] * 4) / 5; + } + else { + alphaenc2[4*j + i] = 1; + alphadist = srccolors[j][i] - alphabase[1]; + } + alphablockerror2 += alphadist * alphadist; + } + } + + + /* skip this if the error is already very small + this encoding is MUCH better on average than #2 though, but expensive! */ + if ((alphablockerror2 > 96) && (alphablockerror1 > 96)) { + short blockerrlin1 = 0; + short blockerrlin2 = 0; + TYPE nralphainrangelow = 0; + TYPE nralphainrangehigh = 0; + alphatest[0] = T_MAX; + alphatest[1] = T_MIN; + /* if we have large range it's likely there are values close to 0/255, try to map them to 0/255 */ + for (j = 0; j < numypixels; j++) { + for (i = 0; i < numxpixels; i++) { + if ((srccolors[j][i] > alphatest[1]) && (srccolors[j][i] < (T_MAX -(alphabase[1] - alphabase[0]) / 28))) + alphatest[1] = srccolors[j][i]; + if ((srccolors[j][i] < alphatest[0]) && (srccolors[j][i] > (alphabase[1] - alphabase[0]) / 28)) + alphatest[0] = srccolors[j][i]; + } + } + /* shouldn't happen too often, don't really care about those degenerated cases */ + if (alphatest[1] <= alphatest[0]) { + alphatest[0] = T_MIN+1; + alphatest[1] = T_MAX-1; + } + for (aindex = 0; aindex < 5; aindex++) { + /* don't forget here is always rounded down */ + acutValues[aindex] = (alphatest[0] * (10 - (2*aindex + 1)) + alphatest[1] * (2*aindex + 1)) / 10; + } + + /* find the "average" difference between the alpha values and the next encoded value. + This is then used to calculate new base values. + Should there be some weighting, i.e. those values closer to alphatest[x] have more weight, + since they will see more improvement, and also because the values in the middle are somewhat + likely to get no improvement at all (because the base values might move in different directions)? + OTOH it would mean the values in the middle are even less likely to get an improvement + */ + for (j = 0; j < numypixels; j++) { + for (i = 0; i < numxpixels; i++) { + if (srccolors[j][i] <= alphatest[0] / 2) { + } + else if (srccolors[j][i] > ((T_MAX + alphatest[1]) / 2)) { + } + else if (srccolors[j][i] <= acutValues[0]) { + blockerrlin1 += (srccolors[j][i] - alphatest[0]); + nralphainrangelow += 1; + } + else if (srccolors[j][i] <= acutValues[1]) { + blockerrlin1 += (srccolors[j][i] - (alphatest[0] * 4 + alphatest[1] * 1) / 5); + blockerrlin2 += (srccolors[j][i] - (alphatest[0] * 4 + alphatest[1] * 1) / 5); + nralphainrangelow += 1; + nralphainrangehigh += 1; + } + else if (srccolors[j][i] <= acutValues[2]) { + blockerrlin1 += (srccolors[j][i] - (alphatest[0] * 3 + alphatest[1] * 2) / 5); + blockerrlin2 += (srccolors[j][i] - (alphatest[0] * 3 + alphatest[1] * 2) / 5); + nralphainrangelow += 1; + nralphainrangehigh += 1; + } + else if (srccolors[j][i] <= acutValues[3]) { + blockerrlin1 += (srccolors[j][i] - (alphatest[0] * 2 + alphatest[1] * 3) / 5); + blockerrlin2 += (srccolors[j][i] - (alphatest[0] * 2 + alphatest[1] * 3) / 5); + nralphainrangelow += 1; + nralphainrangehigh += 1; + } + else if (srccolors[j][i] <= acutValues[4]) { + blockerrlin1 += (srccolors[j][i] - (alphatest[0] * 1 + alphatest[1] * 4) / 5); + blockerrlin2 += (srccolors[j][i] - (alphatest[0] * 1 + alphatest[1] * 4) / 5); + nralphainrangelow += 1; + nralphainrangehigh += 1; + } + else { + blockerrlin2 += (srccolors[j][i] - alphatest[1]); + nralphainrangehigh += 1; + } + } + } + /* shouldn't happen often, needed to avoid div by zero */ + if (nralphainrangelow == 0) nralphainrangelow = 1; + if (nralphainrangehigh == 0) nralphainrangehigh = 1; + alphatest[0] = alphatest[0] + (blockerrlin1 / nralphainrangelow); +#if RGTC_DEBUG + fprintf(stderr, "block err lin low %d, nr %d\n", blockerrlin1, nralphainrangelow); + fprintf(stderr, "block err lin high %d, nr %d\n", blockerrlin2, nralphainrangehigh); +#endif + /* again shouldn't really happen often... */ + if (alphatest[0] < T_MIN) { + alphatest[0] = T_MIN; + } + alphatest[1] = alphatest[1] + (blockerrlin2 / nralphainrangehigh); + if (alphatest[1] > T_MAX) { + alphatest[1] = T_MAX; + } + + alphablockerror3 = 0; + for (aindex = 0; aindex < 5; aindex++) { + /* don't forget here is always rounded down */ + acutValues[aindex] = (alphatest[0] * (10 - (2*aindex + 1)) + alphatest[1] * (2*aindex + 1)) / 10; + } + for (j = 0; j < numypixels; j++) { + for (i = 0; i < numxpixels; i++) { + /* maybe it's overkill to have the most complicated calculation just for the error + calculation which we only need to figure out if encoding1 or encoding2 is better... */ + if (srccolors[j][i] <= alphatest[0] / 2) { + alphaenc3[4*j + i] = 6; + alphadist = srccolors[j][i]; + } + else if (srccolors[j][i] > ((T_MAX + alphatest[1]) / 2)) { + alphaenc3[4*j + i] = 7; + alphadist = T_MAX - srccolors[j][i]; + } + else if (srccolors[j][i] <= acutValues[0]) { + alphaenc3[4*j + i] = 0; + alphadist = srccolors[j][i] - alphatest[0]; + } + else if (srccolors[j][i] <= acutValues[1]) { + alphaenc3[4*j + i] = 2; + alphadist = srccolors[j][i] - (alphatest[0] * 4 + alphatest[1] * 1) / 5; + } + else if (srccolors[j][i] <= acutValues[2]) { + alphaenc3[4*j + i] = 3; + alphadist = srccolors[j][i] - (alphatest[0] * 3 + alphatest[1] * 2) / 5; + } + else if (srccolors[j][i] <= acutValues[3]) { + alphaenc3[4*j + i] = 4; + alphadist = srccolors[j][i] - (alphatest[0] * 2 + alphatest[1] * 3) / 5; + } + else if (srccolors[j][i] <= acutValues[4]) { + alphaenc3[4*j + i] = 5; + alphadist = srccolors[j][i] - (alphatest[0] * 1 + alphatest[1] * 4) / 5; + } + else { + alphaenc3[4*j + i] = 1; + alphadist = srccolors[j][i] - alphatest[1]; + } + alphablockerror3 += alphadist * alphadist; + } + } + } + } + + /* write the alpha values and encoding back. */ + if ((alphablockerror1 <= alphablockerror2) && (alphablockerror1 <= alphablockerror3)) { +#if RGTC_DEBUG + if (alphablockerror1 > 96) fprintf(stderr, "enc1 used, error %d\n", alphablockerror1); + fprintf(stderr,"w1: min %d max %d au0 %d au1 %d\n", + T_MIN, T_MAX, + alphause[1], alphause[0]); +#endif + + TAG(write_rgtc_encoded_channel)( blkaddr, alphause[1], alphause[0], alphaenc1 ); + } + else if (alphablockerror2 <= alphablockerror3) { +#if RGTC_DEBUG + if (alphablockerror2 > 96) fprintf(stderr, "enc2 used, error %d\n", alphablockerror2); + fprintf(stderr,"w2: min %d max %d au0 %d au1 %d\n", + T_MIN, T_MAX, + alphabase[0], alphabase[1]); +#endif + + TAG(write_rgtc_encoded_channel)( blkaddr, alphabase[0], alphabase[1], alphaenc2 ); + } + else { +#if RGTC_DEBUG + fprintf(stderr, "enc3 used, error %d\n", alphablockerror3); + fprintf(stderr,"w3: min %d max %d au0 %d au1 %d\n", + T_MIN, T_MAX, + alphatest[0], alphatest[1]); +#endif + + TAG(write_rgtc_encoded_channel)( blkaddr, (TYPE)alphatest[0], (TYPE)alphatest[1], alphaenc3 ); + } +} diff --git a/mesalib/src/mesa/main/texcompress_s3tc.c b/mesalib/src/mesa/main/texcompress_s3tc.c index c7b27c1a4..5798406db 100644 --- a/mesalib/src/mesa/main/texcompress_s3tc.c +++ b/mesalib/src/mesa/main/texcompress_s3tc.c @@ -1,562 +1,562 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5.3 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * Copyright (c) 2008 VMware, 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 - * 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 texcompress_s3tc.c - * GL_EXT_texture_compression_s3tc support. - */ - -#ifndef USE_EXTERNAL_DXTN_LIB -#define USE_EXTERNAL_DXTN_LIB 1 -#endif - -#include "glheader.h" -#include "imports.h" -#include "colormac.h" -#include "dlopen.h" -#include "image.h" -#include "macros.h" -#include "mfeatures.h" -#include "mtypes.h" -#include "texcompress.h" -#include "texcompress_s3tc.h" -#include "texstore.h" - - -#if FEATURE_texture_s3tc - - -#if defined(_WIN32) || defined(WIN32) -#ifdef _DEBUG -#define DXTN_LIBNAME "dxtn_dbg.dll" -#else -#define DXTN_LIBNAME "dxtn.dll" -#endif -#define RTLD_LAZY 0 -#define RTLD_GLOBAL 0 -#elif defined(__DJGPP__) -#define DXTN_LIBNAME "dxtn.dxe" -#else -#define DXTN_LIBNAME "libtxc_dxtn.so" -#endif - -#if FEATURE_EXT_texture_sRGB -/** - * Convert an 8-bit sRGB value from non-linear space to a - * linear RGB value in [0, 1]. - * Implemented with a 256-entry lookup table. - */ -static INLINE GLfloat -nonlinear_to_linear(GLubyte cs8) -{ - static GLfloat table[256]; - static GLboolean tableReady = GL_FALSE; - if (!tableReady) { - /* compute lookup table now */ - GLuint i; - for (i = 0; i < 256; i++) { - const GLfloat cs = UBYTE_TO_FLOAT(i); - if (cs <= 0.04045) { - table[i] = cs / 12.92f; - } - else { - table[i] = (GLfloat) pow((cs + 0.055) / 1.055, 2.4); - } - } - tableReady = GL_TRUE; - } - return table[cs8]; -} -#endif /* FEATURE_EXT_texture_sRGB */ - -typedef void (*dxtFetchTexelFuncExt)( GLint srcRowstride, GLubyte *pixdata, GLint col, GLint row, GLvoid *texelOut ); - -dxtFetchTexelFuncExt fetch_ext_rgb_dxt1 = NULL; -dxtFetchTexelFuncExt fetch_ext_rgba_dxt1 = NULL; -dxtFetchTexelFuncExt fetch_ext_rgba_dxt3 = NULL; -dxtFetchTexelFuncExt fetch_ext_rgba_dxt5 = NULL; - -typedef void (*dxtCompressTexFuncExt)(GLint srccomps, GLint width, - GLint height, const GLchan *srcPixData, - GLenum destformat, GLubyte *dest, - GLint dstRowStride); - -static dxtCompressTexFuncExt ext_tx_compress_dxtn = NULL; - -static void *dxtlibhandle = NULL; - - -void -_mesa_init_texture_s3tc( struct gl_context *ctx ) -{ - /* called during context initialization */ - ctx->Mesa_DXTn = GL_FALSE; -#if USE_EXTERNAL_DXTN_LIB - if (!dxtlibhandle) { - dxtlibhandle = _mesa_dlopen(DXTN_LIBNAME, 0); - if (!dxtlibhandle) { - _mesa_warning(ctx, "couldn't open " DXTN_LIBNAME ", software DXTn " - "compression/decompression unavailable"); - } - else { - /* the fetch functions are not per context! Might be problematic... */ - fetch_ext_rgb_dxt1 = (dxtFetchTexelFuncExt) - _mesa_dlsym(dxtlibhandle, "fetch_2d_texel_rgb_dxt1"); - fetch_ext_rgba_dxt1 = (dxtFetchTexelFuncExt) - _mesa_dlsym(dxtlibhandle, "fetch_2d_texel_rgba_dxt1"); - fetch_ext_rgba_dxt3 = (dxtFetchTexelFuncExt) - _mesa_dlsym(dxtlibhandle, "fetch_2d_texel_rgba_dxt3"); - fetch_ext_rgba_dxt5 = (dxtFetchTexelFuncExt) - _mesa_dlsym(dxtlibhandle, "fetch_2d_texel_rgba_dxt5"); - ext_tx_compress_dxtn = (dxtCompressTexFuncExt) - _mesa_dlsym(dxtlibhandle, "tx_compress_dxtn"); - - if (!fetch_ext_rgb_dxt1 || - !fetch_ext_rgba_dxt1 || - !fetch_ext_rgba_dxt3 || - !fetch_ext_rgba_dxt5 || - !ext_tx_compress_dxtn) { - _mesa_warning(ctx, "couldn't reference all symbols in " - DXTN_LIBNAME ", software DXTn compression/decompression " - "unavailable"); - fetch_ext_rgb_dxt1 = NULL; - fetch_ext_rgba_dxt1 = NULL; - fetch_ext_rgba_dxt3 = NULL; - fetch_ext_rgba_dxt5 = NULL; - ext_tx_compress_dxtn = NULL; - _mesa_dlclose(dxtlibhandle); - dxtlibhandle = NULL; - } - } - } - if (dxtlibhandle) { - ctx->Mesa_DXTn = GL_TRUE; - } -#else - (void) ctx; -#endif -} - -/** - * Store user's image in rgb_dxt1 format. - */ -GLboolean -_mesa_texstore_rgb_dxt1(TEXSTORE_PARAMS) -{ - const GLchan *pixels; - GLubyte *dst; - const GLint texWidth = dstRowStride * 4 / 8; /* a bit of a hack */ - const GLchan *tempImage = NULL; - - ASSERT(dstFormat == MESA_FORMAT_RGB_DXT1 || - dstFormat == MESA_FORMAT_SRGB_DXT1); - ASSERT(dstXoffset % 4 == 0); - ASSERT(dstYoffset % 4 == 0); - ASSERT(dstZoffset % 4 == 0); - (void) dstZoffset; - (void) dstImageOffsets; - - if (srcFormat != GL_RGB || - srcType != CHAN_TYPE || - ctx->_ImageTransferState || - srcPacking->SwapBytes) { - /* convert image to RGB/GLchan */ - tempImage = _mesa_make_temp_chan_image(ctx, dims, - baseInternalFormat, - _mesa_get_format_base_format(dstFormat), - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking); - if (!tempImage) - return GL_FALSE; /* out of memory */ - pixels = tempImage; - srcFormat = GL_RGB; - } - else { - pixels = (const GLchan *) srcAddr; - } - - dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0, - dstFormat, - texWidth, (GLubyte *) dstAddr); - - if (ext_tx_compress_dxtn) { - (*ext_tx_compress_dxtn)(3, srcWidth, srcHeight, pixels, - GL_COMPRESSED_RGB_S3TC_DXT1_EXT, - dst, dstRowStride); - } - else { - _mesa_warning(ctx, "external dxt library not available: texstore_rgb_dxt1"); - } - - if (tempImage) - free((void *) tempImage); - - return GL_TRUE; -} - - -/** - * Store user's image in rgba_dxt1 format. - */ -GLboolean -_mesa_texstore_rgba_dxt1(TEXSTORE_PARAMS) -{ - const GLchan *pixels; - GLubyte *dst; - const GLint texWidth = dstRowStride * 4 / 8; /* a bit of a hack */ - const GLchan *tempImage = NULL; - - ASSERT(dstFormat == MESA_FORMAT_RGBA_DXT1 || - dstFormat == MESA_FORMAT_SRGBA_DXT1); - ASSERT(dstXoffset % 4 == 0); - ASSERT(dstYoffset % 4 == 0); - ASSERT(dstZoffset % 4 == 0); - (void) dstZoffset; - (void) dstImageOffsets; - - if (srcFormat != GL_RGBA || - srcType != CHAN_TYPE || - ctx->_ImageTransferState || - srcPacking->SwapBytes) { - /* convert image to RGBA/GLchan */ - tempImage = _mesa_make_temp_chan_image(ctx, dims, - baseInternalFormat, - _mesa_get_format_base_format(dstFormat), - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking); - if (!tempImage) - return GL_FALSE; /* out of memory */ - pixels = tempImage; - srcFormat = GL_RGBA; - } - else { - pixels = (const GLchan *) srcAddr; - } - - dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0, - dstFormat, - texWidth, (GLubyte *) dstAddr); - if (ext_tx_compress_dxtn) { - (*ext_tx_compress_dxtn)(4, srcWidth, srcHeight, pixels, - GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, - dst, dstRowStride); - } - else { - _mesa_warning(ctx, "external dxt library not available: texstore_rgba_dxt1"); - } - - if (tempImage) - free((void*) tempImage); - - return GL_TRUE; -} - - -/** - * Store user's image in rgba_dxt3 format. - */ -GLboolean -_mesa_texstore_rgba_dxt3(TEXSTORE_PARAMS) -{ - const GLchan *pixels; - GLubyte *dst; - const GLint texWidth = dstRowStride * 4 / 16; /* a bit of a hack */ - const GLchan *tempImage = NULL; - - ASSERT(dstFormat == MESA_FORMAT_RGBA_DXT3 || - dstFormat == MESA_FORMAT_SRGBA_DXT3); - ASSERT(dstXoffset % 4 == 0); - ASSERT(dstYoffset % 4 == 0); - ASSERT(dstZoffset % 4 == 0); - (void) dstZoffset; - (void) dstImageOffsets; - - if (srcFormat != GL_RGBA || - srcType != CHAN_TYPE || - ctx->_ImageTransferState || - srcPacking->SwapBytes) { - /* convert image to RGBA/GLchan */ - tempImage = _mesa_make_temp_chan_image(ctx, dims, - baseInternalFormat, - _mesa_get_format_base_format(dstFormat), - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking); - if (!tempImage) - return GL_FALSE; /* out of memory */ - pixels = tempImage; - } - else { - pixels = (const GLchan *) srcAddr; - } - - dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0, - dstFormat, - texWidth, (GLubyte *) dstAddr); - if (ext_tx_compress_dxtn) { - (*ext_tx_compress_dxtn)(4, srcWidth, srcHeight, pixels, - GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, - dst, dstRowStride); - } - else { - _mesa_warning(ctx, "external dxt library not available: texstore_rgba_dxt3"); - } - - if (tempImage) - free((void *) tempImage); - - return GL_TRUE; -} - - -/** - * Store user's image in rgba_dxt5 format. - */ -GLboolean -_mesa_texstore_rgba_dxt5(TEXSTORE_PARAMS) -{ - const GLchan *pixels; - GLubyte *dst; - const GLint texWidth = dstRowStride * 4 / 16; /* a bit of a hack */ - const GLchan *tempImage = NULL; - - ASSERT(dstFormat == MESA_FORMAT_RGBA_DXT5 || - dstFormat == MESA_FORMAT_SRGBA_DXT5); - ASSERT(dstXoffset % 4 == 0); - ASSERT(dstYoffset % 4 == 0); - ASSERT(dstZoffset % 4 == 0); - (void) dstZoffset; - (void) dstImageOffsets; - - if (srcFormat != GL_RGBA || - srcType != CHAN_TYPE || - ctx->_ImageTransferState || - srcPacking->SwapBytes) { - /* convert image to RGBA/GLchan */ - tempImage = _mesa_make_temp_chan_image(ctx, dims, - baseInternalFormat, - _mesa_get_format_base_format(dstFormat), - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking); - if (!tempImage) - return GL_FALSE; /* out of memory */ - pixels = tempImage; - } - else { - pixels = (const GLchan *) srcAddr; - } - - dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0, - dstFormat, - texWidth, (GLubyte *) dstAddr); - if (ext_tx_compress_dxtn) { - (*ext_tx_compress_dxtn)(4, srcWidth, srcHeight, pixels, - GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, - dst, dstRowStride); - } - else { - _mesa_warning(ctx, "external dxt library not available: texstore_rgba_dxt5"); - } - - if (tempImage) - free((void *) tempImage); - - return GL_TRUE; -} - - -static void -fetch_texel_2d_rgb_dxt1( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLchan *texel ) -{ - (void) k; - if (fetch_ext_rgb_dxt1) { - ASSERT (sizeof(GLchan) == sizeof(GLubyte)); - fetch_ext_rgb_dxt1(texImage->RowStride, - (GLubyte *)(texImage)->Data, i, j, texel); - } - else - _mesa_debug(NULL, "attempted to decode s3tc texture without library available: fetch_texel_2d_rgb_dxt1"); -} - - -void -_mesa_fetch_texel_2d_f_rgb_dxt1(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel) -{ - /* just sample as GLchan and convert to float here */ - GLchan rgba[4]; - fetch_texel_2d_rgb_dxt1(texImage, i, j, k, rgba); - texel[RCOMP] = CHAN_TO_FLOAT(rgba[RCOMP]); - texel[GCOMP] = CHAN_TO_FLOAT(rgba[GCOMP]); - texel[BCOMP] = CHAN_TO_FLOAT(rgba[BCOMP]); - texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]); -} - - -static void -fetch_texel_2d_rgba_dxt1( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLchan *texel ) -{ - (void) k; - if (fetch_ext_rgba_dxt1) { - fetch_ext_rgba_dxt1(texImage->RowStride, - (GLubyte *)(texImage)->Data, i, j, texel); - } - else - _mesa_debug(NULL, "attempted to decode s3tc texture without library available: fetch_texel_2d_rgba_dxt1\n"); -} - - -void -_mesa_fetch_texel_2d_f_rgba_dxt1(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel) -{ - /* just sample as GLchan and convert to float here */ - GLchan rgba[4]; - fetch_texel_2d_rgba_dxt1(texImage, i, j, k, rgba); - texel[RCOMP] = CHAN_TO_FLOAT(rgba[RCOMP]); - texel[GCOMP] = CHAN_TO_FLOAT(rgba[GCOMP]); - texel[BCOMP] = CHAN_TO_FLOAT(rgba[BCOMP]); - texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]); -} - - -static void -fetch_texel_2d_rgba_dxt3( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLchan *texel ) -{ - (void) k; - if (fetch_ext_rgba_dxt3) { - ASSERT (sizeof(GLchan) == sizeof(GLubyte)); - fetch_ext_rgba_dxt3(texImage->RowStride, (GLubyte *)(texImage)->Data, - i, j, texel); - } - else - _mesa_debug(NULL, "attempted to decode s3tc texture without library available: fetch_texel_2d_rgba_dxt3\n"); -} - - -void -_mesa_fetch_texel_2d_f_rgba_dxt3(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel) -{ - /* just sample as GLchan and convert to float here */ - GLchan rgba[4]; - fetch_texel_2d_rgba_dxt3(texImage, i, j, k, rgba); - texel[RCOMP] = CHAN_TO_FLOAT(rgba[RCOMP]); - texel[GCOMP] = CHAN_TO_FLOAT(rgba[GCOMP]); - texel[BCOMP] = CHAN_TO_FLOAT(rgba[BCOMP]); - texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]); -} - - -static void -fetch_texel_2d_rgba_dxt5( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLchan *texel ) -{ - (void) k; - if (fetch_ext_rgba_dxt5) { - fetch_ext_rgba_dxt5(texImage->RowStride, (GLubyte *)(texImage)->Data, - i, j, texel); - } - else - _mesa_debug(NULL, "attempted to decode s3tc texture without library available: fetch_texel_2d_rgba_dxt5\n"); -} - - -void -_mesa_fetch_texel_2d_f_rgba_dxt5(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel) -{ - /* just sample as GLchan and convert to float here */ - GLchan rgba[4]; - fetch_texel_2d_rgba_dxt5(texImage, i, j, k, rgba); - texel[RCOMP] = CHAN_TO_FLOAT(rgba[RCOMP]); - texel[GCOMP] = CHAN_TO_FLOAT(rgba[GCOMP]); - texel[BCOMP] = CHAN_TO_FLOAT(rgba[BCOMP]); - texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]); -} - -#if FEATURE_EXT_texture_sRGB -void -_mesa_fetch_texel_2d_f_srgb_dxt1( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - /* just sample as GLchan and convert to float here */ - GLchan rgba[4]; - fetch_texel_2d_rgb_dxt1(texImage, i, j, k, rgba); - texel[RCOMP] = nonlinear_to_linear(rgba[RCOMP]); - texel[GCOMP] = nonlinear_to_linear(rgba[GCOMP]); - texel[BCOMP] = nonlinear_to_linear(rgba[BCOMP]); - texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]); -} - -void -_mesa_fetch_texel_2d_f_srgba_dxt1(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel) -{ - /* just sample as GLchan and convert to float here */ - GLchan rgba[4]; - fetch_texel_2d_rgba_dxt1(texImage, i, j, k, rgba); - texel[RCOMP] = nonlinear_to_linear(rgba[RCOMP]); - texel[GCOMP] = nonlinear_to_linear(rgba[GCOMP]); - texel[BCOMP] = nonlinear_to_linear(rgba[BCOMP]); - texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]); -} - -void -_mesa_fetch_texel_2d_f_srgba_dxt3(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel) -{ - /* just sample as GLchan and convert to float here */ - GLchan rgba[4]; - fetch_texel_2d_rgba_dxt3(texImage, i, j, k, rgba); - texel[RCOMP] = nonlinear_to_linear(rgba[RCOMP]); - texel[GCOMP] = nonlinear_to_linear(rgba[GCOMP]); - texel[BCOMP] = nonlinear_to_linear(rgba[BCOMP]); - texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]); -} - -void -_mesa_fetch_texel_2d_f_srgba_dxt5(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel) -{ - /* just sample as GLchan and convert to float here */ - GLchan rgba[4]; - fetch_texel_2d_rgba_dxt5(texImage, i, j, k, rgba); - texel[RCOMP] = nonlinear_to_linear(rgba[RCOMP]); - texel[GCOMP] = nonlinear_to_linear(rgba[GCOMP]); - texel[BCOMP] = nonlinear_to_linear(rgba[BCOMP]); - texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]); -} -#endif /* FEATURE_EXT_texture_sRGB */ - - -#endif /* FEATURE_texture_s3tc */ +/* + * Mesa 3-D graphics library + * Version: 6.5.3 + * + * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. + * Copyright (c) 2008 VMware, 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 + * 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 texcompress_s3tc.c + * GL_EXT_texture_compression_s3tc support. + */ + +#ifndef USE_EXTERNAL_DXTN_LIB +#define USE_EXTERNAL_DXTN_LIB 1 +#endif + +#include "glheader.h" +#include "imports.h" +#include "colormac.h" +#include "dlopen.h" +#include "image.h" +#include "macros.h" +#include "mfeatures.h" +#include "mtypes.h" +#include "texcompress.h" +#include "texcompress_s3tc.h" +#include "texstore.h" + + +#if FEATURE_texture_s3tc + + +#if defined(_WIN32) || defined(WIN32) +#ifdef _DEBUG +#define DXTN_LIBNAME "dxtn_dbg.dll" +#else +#define DXTN_LIBNAME "dxtn.dll" +#endif +#define RTLD_LAZY 0 +#define RTLD_GLOBAL 0 +#elif defined(__DJGPP__) +#define DXTN_LIBNAME "dxtn.dxe" +#else +#define DXTN_LIBNAME "libtxc_dxtn.so" +#endif + +#if FEATURE_EXT_texture_sRGB +/** + * Convert an 8-bit sRGB value from non-linear space to a + * linear RGB value in [0, 1]. + * Implemented with a 256-entry lookup table. + */ +static INLINE GLfloat +nonlinear_to_linear(GLubyte cs8) +{ + static GLfloat table[256]; + static GLboolean tableReady = GL_FALSE; + if (!tableReady) { + /* compute lookup table now */ + GLuint i; + for (i = 0; i < 256; i++) { + const GLfloat cs = UBYTE_TO_FLOAT(i); + if (cs <= 0.04045) { + table[i] = cs / 12.92f; + } + else { + table[i] = (GLfloat) pow((cs + 0.055) / 1.055, 2.4); + } + } + tableReady = GL_TRUE; + } + return table[cs8]; +} +#endif /* FEATURE_EXT_texture_sRGB */ + +typedef void (*dxtFetchTexelFuncExt)( GLint srcRowstride, GLubyte *pixdata, GLint col, GLint row, GLvoid *texelOut ); + +dxtFetchTexelFuncExt fetch_ext_rgb_dxt1 = NULL; +dxtFetchTexelFuncExt fetch_ext_rgba_dxt1 = NULL; +dxtFetchTexelFuncExt fetch_ext_rgba_dxt3 = NULL; +dxtFetchTexelFuncExt fetch_ext_rgba_dxt5 = NULL; + +typedef void (*dxtCompressTexFuncExt)(GLint srccomps, GLint width, + GLint height, const GLchan *srcPixData, + GLenum destformat, GLubyte *dest, + GLint dstRowStride); + +static dxtCompressTexFuncExt ext_tx_compress_dxtn = NULL; + +static void *dxtlibhandle = NULL; + + +void +_mesa_init_texture_s3tc( struct gl_context *ctx ) +{ + /* called during context initialization */ + ctx->Mesa_DXTn = GL_FALSE; +#if USE_EXTERNAL_DXTN_LIB + if (!dxtlibhandle) { + dxtlibhandle = _mesa_dlopen(DXTN_LIBNAME, 0); + if (!dxtlibhandle) { + _mesa_warning(ctx, "couldn't open " DXTN_LIBNAME ", software DXTn " + "compression/decompression unavailable"); + } + else { + /* the fetch functions are not per context! Might be problematic... */ + fetch_ext_rgb_dxt1 = (dxtFetchTexelFuncExt) + _mesa_dlsym(dxtlibhandle, "fetch_2d_texel_rgb_dxt1"); + fetch_ext_rgba_dxt1 = (dxtFetchTexelFuncExt) + _mesa_dlsym(dxtlibhandle, "fetch_2d_texel_rgba_dxt1"); + fetch_ext_rgba_dxt3 = (dxtFetchTexelFuncExt) + _mesa_dlsym(dxtlibhandle, "fetch_2d_texel_rgba_dxt3"); + fetch_ext_rgba_dxt5 = (dxtFetchTexelFuncExt) + _mesa_dlsym(dxtlibhandle, "fetch_2d_texel_rgba_dxt5"); + ext_tx_compress_dxtn = (dxtCompressTexFuncExt) + _mesa_dlsym(dxtlibhandle, "tx_compress_dxtn"); + + if (!fetch_ext_rgb_dxt1 || + !fetch_ext_rgba_dxt1 || + !fetch_ext_rgba_dxt3 || + !fetch_ext_rgba_dxt5 || + !ext_tx_compress_dxtn) { + _mesa_warning(ctx, "couldn't reference all symbols in " + DXTN_LIBNAME ", software DXTn compression/decompression " + "unavailable"); + fetch_ext_rgb_dxt1 = NULL; + fetch_ext_rgba_dxt1 = NULL; + fetch_ext_rgba_dxt3 = NULL; + fetch_ext_rgba_dxt5 = NULL; + ext_tx_compress_dxtn = NULL; + _mesa_dlclose(dxtlibhandle); + dxtlibhandle = NULL; + } + } + } + if (dxtlibhandle) { + ctx->Mesa_DXTn = GL_TRUE; + } +#else + (void) ctx; +#endif +} + +/** + * Store user's image in rgb_dxt1 format. + */ +GLboolean +_mesa_texstore_rgb_dxt1(TEXSTORE_PARAMS) +{ + const GLchan *pixels; + GLubyte *dst; + const GLint texWidth = dstRowStride * 4 / 8; /* a bit of a hack */ + const GLchan *tempImage = NULL; + + ASSERT(dstFormat == MESA_FORMAT_RGB_DXT1 || + dstFormat == MESA_FORMAT_SRGB_DXT1); + ASSERT(dstXoffset % 4 == 0); + ASSERT(dstYoffset % 4 == 0); + ASSERT(dstZoffset % 4 == 0); + (void) dstZoffset; + (void) dstImageOffsets; + + if (srcFormat != GL_RGB || + srcType != CHAN_TYPE || + ctx->_ImageTransferState || + srcPacking->SwapBytes) { + /* convert image to RGB/GLchan */ + tempImage = _mesa_make_temp_chan_image(ctx, dims, + baseInternalFormat, + _mesa_get_format_base_format(dstFormat), + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking); + if (!tempImage) + return GL_FALSE; /* out of memory */ + pixels = tempImage; + srcFormat = GL_RGB; + } + else { + pixels = (const GLchan *) srcAddr; + } + + dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0, + dstFormat, + texWidth, (GLubyte *) dstAddr); + + if (ext_tx_compress_dxtn) { + (*ext_tx_compress_dxtn)(3, srcWidth, srcHeight, pixels, + GL_COMPRESSED_RGB_S3TC_DXT1_EXT, + dst, dstRowStride); + } + else { + _mesa_warning(ctx, "external dxt library not available: texstore_rgb_dxt1"); + } + + if (tempImage) + free((void *) tempImage); + + return GL_TRUE; +} + + +/** + * Store user's image in rgba_dxt1 format. + */ +GLboolean +_mesa_texstore_rgba_dxt1(TEXSTORE_PARAMS) +{ + const GLchan *pixels; + GLubyte *dst; + const GLint texWidth = dstRowStride * 4 / 8; /* a bit of a hack */ + const GLchan *tempImage = NULL; + + ASSERT(dstFormat == MESA_FORMAT_RGBA_DXT1 || + dstFormat == MESA_FORMAT_SRGBA_DXT1); + ASSERT(dstXoffset % 4 == 0); + ASSERT(dstYoffset % 4 == 0); + ASSERT(dstZoffset % 4 == 0); + (void) dstZoffset; + (void) dstImageOffsets; + + if (srcFormat != GL_RGBA || + srcType != CHAN_TYPE || + ctx->_ImageTransferState || + srcPacking->SwapBytes) { + /* convert image to RGBA/GLchan */ + tempImage = _mesa_make_temp_chan_image(ctx, dims, + baseInternalFormat, + _mesa_get_format_base_format(dstFormat), + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking); + if (!tempImage) + return GL_FALSE; /* out of memory */ + pixels = tempImage; + srcFormat = GL_RGBA; + } + else { + pixels = (const GLchan *) srcAddr; + } + + dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0, + dstFormat, + texWidth, (GLubyte *) dstAddr); + if (ext_tx_compress_dxtn) { + (*ext_tx_compress_dxtn)(4, srcWidth, srcHeight, pixels, + GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, + dst, dstRowStride); + } + else { + _mesa_warning(ctx, "external dxt library not available: texstore_rgba_dxt1"); + } + + if (tempImage) + free((void*) tempImage); + + return GL_TRUE; +} + + +/** + * Store user's image in rgba_dxt3 format. + */ +GLboolean +_mesa_texstore_rgba_dxt3(TEXSTORE_PARAMS) +{ + const GLchan *pixels; + GLubyte *dst; + const GLint texWidth = dstRowStride * 4 / 16; /* a bit of a hack */ + const GLchan *tempImage = NULL; + + ASSERT(dstFormat == MESA_FORMAT_RGBA_DXT3 || + dstFormat == MESA_FORMAT_SRGBA_DXT3); + ASSERT(dstXoffset % 4 == 0); + ASSERT(dstYoffset % 4 == 0); + ASSERT(dstZoffset % 4 == 0); + (void) dstZoffset; + (void) dstImageOffsets; + + if (srcFormat != GL_RGBA || + srcType != CHAN_TYPE || + ctx->_ImageTransferState || + srcPacking->SwapBytes) { + /* convert image to RGBA/GLchan */ + tempImage = _mesa_make_temp_chan_image(ctx, dims, + baseInternalFormat, + _mesa_get_format_base_format(dstFormat), + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking); + if (!tempImage) + return GL_FALSE; /* out of memory */ + pixels = tempImage; + } + else { + pixels = (const GLchan *) srcAddr; + } + + dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0, + dstFormat, + texWidth, (GLubyte *) dstAddr); + if (ext_tx_compress_dxtn) { + (*ext_tx_compress_dxtn)(4, srcWidth, srcHeight, pixels, + GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, + dst, dstRowStride); + } + else { + _mesa_warning(ctx, "external dxt library not available: texstore_rgba_dxt3"); + } + + if (tempImage) + free((void *) tempImage); + + return GL_TRUE; +} + + +/** + * Store user's image in rgba_dxt5 format. + */ +GLboolean +_mesa_texstore_rgba_dxt5(TEXSTORE_PARAMS) +{ + const GLchan *pixels; + GLubyte *dst; + const GLint texWidth = dstRowStride * 4 / 16; /* a bit of a hack */ + const GLchan *tempImage = NULL; + + ASSERT(dstFormat == MESA_FORMAT_RGBA_DXT5 || + dstFormat == MESA_FORMAT_SRGBA_DXT5); + ASSERT(dstXoffset % 4 == 0); + ASSERT(dstYoffset % 4 == 0); + ASSERT(dstZoffset % 4 == 0); + (void) dstZoffset; + (void) dstImageOffsets; + + if (srcFormat != GL_RGBA || + srcType != CHAN_TYPE || + ctx->_ImageTransferState || + srcPacking->SwapBytes) { + /* convert image to RGBA/GLchan */ + tempImage = _mesa_make_temp_chan_image(ctx, dims, + baseInternalFormat, + _mesa_get_format_base_format(dstFormat), + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking); + if (!tempImage) + return GL_FALSE; /* out of memory */ + pixels = tempImage; + } + else { + pixels = (const GLchan *) srcAddr; + } + + dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0, + dstFormat, + texWidth, (GLubyte *) dstAddr); + if (ext_tx_compress_dxtn) { + (*ext_tx_compress_dxtn)(4, srcWidth, srcHeight, pixels, + GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, + dst, dstRowStride); + } + else { + _mesa_warning(ctx, "external dxt library not available: texstore_rgba_dxt5"); + } + + if (tempImage) + free((void *) tempImage); + + return GL_TRUE; +} + + +static void +fetch_texel_2d_rgb_dxt1( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLchan *texel ) +{ + (void) k; + if (fetch_ext_rgb_dxt1) { + ASSERT (sizeof(GLchan) == sizeof(GLubyte)); + fetch_ext_rgb_dxt1(texImage->RowStride, + (GLubyte *)(texImage)->Data, i, j, texel); + } + else + _mesa_debug(NULL, "attempted to decode s3tc texture without library available: fetch_texel_2d_rgb_dxt1"); +} + + +void +_mesa_fetch_texel_2d_f_rgb_dxt1(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) +{ + /* just sample as GLchan and convert to float here */ + GLchan rgba[4]; + fetch_texel_2d_rgb_dxt1(texImage, i, j, k, rgba); + texel[RCOMP] = CHAN_TO_FLOAT(rgba[RCOMP]); + texel[GCOMP] = CHAN_TO_FLOAT(rgba[GCOMP]); + texel[BCOMP] = CHAN_TO_FLOAT(rgba[BCOMP]); + texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]); +} + + +static void +fetch_texel_2d_rgba_dxt1( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLchan *texel ) +{ + (void) k; + if (fetch_ext_rgba_dxt1) { + fetch_ext_rgba_dxt1(texImage->RowStride, + (GLubyte *)(texImage)->Data, i, j, texel); + } + else + _mesa_debug(NULL, "attempted to decode s3tc texture without library available: fetch_texel_2d_rgba_dxt1\n"); +} + + +void +_mesa_fetch_texel_2d_f_rgba_dxt1(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) +{ + /* just sample as GLchan and convert to float here */ + GLchan rgba[4]; + fetch_texel_2d_rgba_dxt1(texImage, i, j, k, rgba); + texel[RCOMP] = CHAN_TO_FLOAT(rgba[RCOMP]); + texel[GCOMP] = CHAN_TO_FLOAT(rgba[GCOMP]); + texel[BCOMP] = CHAN_TO_FLOAT(rgba[BCOMP]); + texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]); +} + + +static void +fetch_texel_2d_rgba_dxt3( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLchan *texel ) +{ + (void) k; + if (fetch_ext_rgba_dxt3) { + ASSERT (sizeof(GLchan) == sizeof(GLubyte)); + fetch_ext_rgba_dxt3(texImage->RowStride, (GLubyte *)(texImage)->Data, + i, j, texel); + } + else + _mesa_debug(NULL, "attempted to decode s3tc texture without library available: fetch_texel_2d_rgba_dxt3\n"); +} + + +void +_mesa_fetch_texel_2d_f_rgba_dxt3(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) +{ + /* just sample as GLchan and convert to float here */ + GLchan rgba[4]; + fetch_texel_2d_rgba_dxt3(texImage, i, j, k, rgba); + texel[RCOMP] = CHAN_TO_FLOAT(rgba[RCOMP]); + texel[GCOMP] = CHAN_TO_FLOAT(rgba[GCOMP]); + texel[BCOMP] = CHAN_TO_FLOAT(rgba[BCOMP]); + texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]); +} + + +static void +fetch_texel_2d_rgba_dxt5( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLchan *texel ) +{ + (void) k; + if (fetch_ext_rgba_dxt5) { + fetch_ext_rgba_dxt5(texImage->RowStride, (GLubyte *)(texImage)->Data, + i, j, texel); + } + else + _mesa_debug(NULL, "attempted to decode s3tc texture without library available: fetch_texel_2d_rgba_dxt5\n"); +} + + +void +_mesa_fetch_texel_2d_f_rgba_dxt5(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) +{ + /* just sample as GLchan and convert to float here */ + GLchan rgba[4]; + fetch_texel_2d_rgba_dxt5(texImage, i, j, k, rgba); + texel[RCOMP] = CHAN_TO_FLOAT(rgba[RCOMP]); + texel[GCOMP] = CHAN_TO_FLOAT(rgba[GCOMP]); + texel[BCOMP] = CHAN_TO_FLOAT(rgba[BCOMP]); + texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]); +} + +#if FEATURE_EXT_texture_sRGB +void +_mesa_fetch_texel_2d_f_srgb_dxt1( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + /* just sample as GLchan and convert to float here */ + GLchan rgba[4]; + fetch_texel_2d_rgb_dxt1(texImage, i, j, k, rgba); + texel[RCOMP] = nonlinear_to_linear(rgba[RCOMP]); + texel[GCOMP] = nonlinear_to_linear(rgba[GCOMP]); + texel[BCOMP] = nonlinear_to_linear(rgba[BCOMP]); + texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]); +} + +void +_mesa_fetch_texel_2d_f_srgba_dxt1(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) +{ + /* just sample as GLchan and convert to float here */ + GLchan rgba[4]; + fetch_texel_2d_rgba_dxt1(texImage, i, j, k, rgba); + texel[RCOMP] = nonlinear_to_linear(rgba[RCOMP]); + texel[GCOMP] = nonlinear_to_linear(rgba[GCOMP]); + texel[BCOMP] = nonlinear_to_linear(rgba[BCOMP]); + texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]); +} + +void +_mesa_fetch_texel_2d_f_srgba_dxt3(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) +{ + /* just sample as GLchan and convert to float here */ + GLchan rgba[4]; + fetch_texel_2d_rgba_dxt3(texImage, i, j, k, rgba); + texel[RCOMP] = nonlinear_to_linear(rgba[RCOMP]); + texel[GCOMP] = nonlinear_to_linear(rgba[GCOMP]); + texel[BCOMP] = nonlinear_to_linear(rgba[BCOMP]); + texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]); +} + +void +_mesa_fetch_texel_2d_f_srgba_dxt5(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) +{ + /* just sample as GLchan and convert to float here */ + GLchan rgba[4]; + fetch_texel_2d_rgba_dxt5(texImage, i, j, k, rgba); + texel[RCOMP] = nonlinear_to_linear(rgba[RCOMP]); + texel[GCOMP] = nonlinear_to_linear(rgba[GCOMP]); + texel[BCOMP] = nonlinear_to_linear(rgba[BCOMP]); + texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]); +} +#endif /* FEATURE_EXT_texture_sRGB */ + + +#endif /* FEATURE_texture_s3tc */ diff --git a/mesalib/src/mesa/main/texenv.c b/mesalib/src/mesa/main/texenv.c index 7419a08fc..c0d0f3779 100644 --- a/mesalib/src/mesa/main/texenv.c +++ b/mesalib/src/mesa/main/texenv.c @@ -1,1043 +1,1043 @@ -/* - * Mesa 3-D graphics library - * Version: 7.5 - * - * Copyright (C) 1999-2008 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. - */ - -/** - * \file texenv.c - * - * glTexEnv-related functions - */ - - -#include "main/glheader.h" -#include "main/context.h" -#include "main/enums.h" -#include "main/macros.h" -#include "main/mtypes.h" -#include "main/state.h" -#include "main/texenv.h" -#include "main/texstate.h" - - -#define TE_ERROR(errCode, msg, value) \ - _mesa_error(ctx, errCode, msg, _mesa_lookup_enum_by_nr(value)); - - -/** Set texture env mode */ -static void -set_env_mode(struct gl_context *ctx, - struct gl_texture_unit *texUnit, - GLenum mode) -{ - GLboolean legal; - - if (texUnit->EnvMode == mode) - return; - - switch (mode) { - case GL_MODULATE: - case GL_BLEND: - case GL_DECAL: - case GL_REPLACE: - legal = GL_TRUE; - break; - case GL_REPLACE_EXT: - mode = GL_REPLACE; /* GL_REPLACE_EXT != GL_REPLACE */ - legal = GL_TRUE; - break; - case GL_ADD: - legal = ctx->Extensions.EXT_texture_env_add; - break; - case GL_COMBINE: - legal = (ctx->Extensions.EXT_texture_env_combine || - ctx->Extensions.ARB_texture_env_combine); - break; - case GL_COMBINE4_NV: - legal = ctx->Extensions.NV_texture_env_combine4; - break; - default: - legal = GL_FALSE; - } - - if (legal) { - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - texUnit->EnvMode = mode; - } - else { - TE_ERROR(GL_INVALID_ENUM, "glTexEnv(param=%s)", mode); - } -} - - -static void -set_env_color(struct gl_context *ctx, - struct gl_texture_unit *texUnit, - const GLfloat *color) -{ - if (TEST_EQ_4V(color, texUnit->EnvColorUnclamped)) - return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - COPY_4FV(texUnit->EnvColorUnclamped, color); - texUnit->EnvColor[0] = CLAMP(color[0], 0.0F, 1.0F); - texUnit->EnvColor[1] = CLAMP(color[1], 0.0F, 1.0F); - texUnit->EnvColor[2] = CLAMP(color[2], 0.0F, 1.0F); - texUnit->EnvColor[3] = CLAMP(color[3], 0.0F, 1.0F); -} - - -/** Set an RGB or A combiner mode/function */ -static void -set_combiner_mode(struct gl_context *ctx, - struct gl_texture_unit *texUnit, - GLenum pname, GLenum mode) -{ - GLboolean legal; - - if (!ctx->Extensions.EXT_texture_env_combine && - !ctx->Extensions.ARB_texture_env_combine) { - _mesa_error(ctx, GL_INVALID_ENUM, "glTexEnv(pname)"); - return; - } - - switch (mode) { - case GL_REPLACE: - case GL_MODULATE: - case GL_ADD: - case GL_ADD_SIGNED: - case GL_INTERPOLATE: - legal = GL_TRUE; - break; - case GL_SUBTRACT: - legal = ctx->Extensions.ARB_texture_env_combine; - break; - case GL_DOT3_RGB_EXT: - case GL_DOT3_RGBA_EXT: - legal = (ctx->Extensions.EXT_texture_env_dot3 && - pname == GL_COMBINE_RGB); - break; - case GL_DOT3_RGB: - case GL_DOT3_RGBA: - legal = (ctx->Extensions.ARB_texture_env_dot3 && - pname == GL_COMBINE_RGB); - break; - case GL_MODULATE_ADD_ATI: - case GL_MODULATE_SIGNED_ADD_ATI: - case GL_MODULATE_SUBTRACT_ATI: - legal = ctx->Extensions.ATI_texture_env_combine3; - break; - case GL_BUMP_ENVMAP_ATI: - legal = (ctx->Extensions.ATI_envmap_bumpmap && - pname == GL_COMBINE_RGB); - break; - default: - legal = GL_FALSE; - } - - if (!legal) { - TE_ERROR(GL_INVALID_ENUM, "glTexEnv(param=%s)", mode); - return; - } - - switch (pname) { - case GL_COMBINE_RGB: - if (texUnit->Combine.ModeRGB == mode) - return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - texUnit->Combine.ModeRGB = mode; - break; - - case GL_COMBINE_ALPHA: - if (texUnit->Combine.ModeA == mode) - return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - texUnit->Combine.ModeA = mode; - break; - default: - TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname); - } -} - - - -/** Set an RGB or A combiner source term */ -static void -set_combiner_source(struct gl_context *ctx, - struct gl_texture_unit *texUnit, - GLenum pname, GLenum param) -{ - GLuint term; - GLboolean alpha, legal; - - if (!ctx->Extensions.EXT_texture_env_combine && - !ctx->Extensions.ARB_texture_env_combine) { - _mesa_error(ctx, GL_INVALID_ENUM, "glTexEnv(pname)"); - return; - } - - /* - * Translate pname to (term, alpha). - * - * The enums were given sequential values for a reason. - */ - switch (pname) { - case GL_SOURCE0_RGB: - case GL_SOURCE1_RGB: - case GL_SOURCE2_RGB: - case GL_SOURCE3_RGB_NV: - term = pname - GL_SOURCE0_RGB; - alpha = GL_FALSE; - break; - case GL_SOURCE0_ALPHA: - case GL_SOURCE1_ALPHA: - case GL_SOURCE2_ALPHA: - case GL_SOURCE3_ALPHA_NV: - term = pname - GL_SOURCE0_ALPHA; - alpha = GL_TRUE; - break; - default: - TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname); - return; - } - - if ((term == 3) && !ctx->Extensions.NV_texture_env_combine4) { - TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname); - return; - } - - assert(term < MAX_COMBINER_TERMS); - - /* - * Error-check param (the source term) - */ - switch (param) { - case GL_TEXTURE: - case GL_CONSTANT: - case GL_PRIMARY_COLOR: - case GL_PREVIOUS: - legal = GL_TRUE; - break; - case GL_TEXTURE0: - case GL_TEXTURE1: - case GL_TEXTURE2: - case GL_TEXTURE3: - case GL_TEXTURE4: - case GL_TEXTURE5: - case GL_TEXTURE6: - case GL_TEXTURE7: - legal = (ctx->Extensions.ARB_texture_env_crossbar && - param - GL_TEXTURE0 < ctx->Const.MaxTextureUnits); - break; - case GL_ZERO: - legal = (ctx->Extensions.ATI_texture_env_combine3 || - ctx->Extensions.NV_texture_env_combine4); - break; - case GL_ONE: - legal = ctx->Extensions.ATI_texture_env_combine3; - break; - default: - legal = GL_FALSE; - } - - if (!legal) { - TE_ERROR(GL_INVALID_ENUM, "glTexEnv(param=%s)", param); - return; - } - - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - - if (alpha) - texUnit->Combine.SourceA[term] = param; - else - texUnit->Combine.SourceRGB[term] = param; -} - - -/** Set an RGB or A combiner operand term */ -static void -set_combiner_operand(struct gl_context *ctx, - struct gl_texture_unit *texUnit, - GLenum pname, GLenum param) -{ - GLuint term; - GLboolean alpha, legal; - - if (!ctx->Extensions.EXT_texture_env_combine && - !ctx->Extensions.ARB_texture_env_combine) { - _mesa_error(ctx, GL_INVALID_ENUM, "glTexEnv(pname)"); - return; - } - - /* The enums were given sequential values for a reason. - */ - switch (pname) { - case GL_OPERAND0_RGB: - case GL_OPERAND1_RGB: - case GL_OPERAND2_RGB: - case GL_OPERAND3_RGB_NV: - term = pname - GL_OPERAND0_RGB; - alpha = GL_FALSE; - break; - case GL_OPERAND0_ALPHA: - case GL_OPERAND1_ALPHA: - case GL_OPERAND2_ALPHA: - case GL_OPERAND3_ALPHA_NV: - term = pname - GL_OPERAND0_ALPHA; - alpha = GL_TRUE; - break; - default: - TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname); - return; - } - - if ((term == 3) && !ctx->Extensions.NV_texture_env_combine4) { - TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname); - return; - } - - assert(term < MAX_COMBINER_TERMS); - - /* - * Error-check param (the source operand) - */ - switch (param) { - case GL_SRC_COLOR: - case GL_ONE_MINUS_SRC_COLOR: - /* The color input can only be used with GL_OPERAND[01]_RGB in the EXT - * version. In the ARB and NV versions they can be used for any RGB - * operand. - */ - legal = !alpha - && ((term < 2) || ctx->Extensions.ARB_texture_env_combine - || ctx->Extensions.NV_texture_env_combine4); - break; - case GL_ONE_MINUS_SRC_ALPHA: - /* GL_ONE_MINUS_SRC_ALPHA can only be used with - * GL_OPERAND[01]_(RGB|ALPHA) in the EXT version. In the ARB and NV - * versions it can be used for any operand. - */ - legal = (term < 2) || ctx->Extensions.ARB_texture_env_combine - || ctx->Extensions.NV_texture_env_combine4; - break; - case GL_SRC_ALPHA: - legal = GL_TRUE; - break; - default: - legal = GL_FALSE; - } - - if (!legal) { - TE_ERROR(GL_INVALID_ENUM, "glTexEnv(param=%s)", param); - return; - } - - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - - if (alpha) - texUnit->Combine.OperandA[term] = param; - else - texUnit->Combine.OperandRGB[term] = param; -} - - -static void -set_combiner_scale(struct gl_context *ctx, - struct gl_texture_unit *texUnit, - GLenum pname, GLfloat scale) -{ - GLuint shift; - - if (!ctx->Extensions.EXT_texture_env_combine && - !ctx->Extensions.ARB_texture_env_combine) { - _mesa_error(ctx, GL_INVALID_ENUM, "glTexEnv(pname)"); - return; - } - - if (scale == 1.0F) { - shift = 0; - } - else if (scale == 2.0F) { - shift = 1; - } - else if (scale == 4.0F) { - shift = 2; - } - else { - _mesa_error( ctx, GL_INVALID_VALUE, - "glTexEnv(GL_RGB_SCALE not 1, 2 or 4)" ); - return; - } - - switch (pname) { - case GL_RGB_SCALE: - if (texUnit->Combine.ScaleShiftRGB == shift) - return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - texUnit->Combine.ScaleShiftRGB = shift; - break; - case GL_ALPHA_SCALE: - if (texUnit->Combine.ScaleShiftA == shift) - return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - texUnit->Combine.ScaleShiftA = shift; - break; - default: - TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname); - } -} - - - -void GLAPIENTRY -_mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param ) -{ - const GLint iparam0 = (GLint) param[0]; - struct gl_texture_unit *texUnit; - GLuint maxUnit; - - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - maxUnit = (target == GL_POINT_SPRITE_NV && pname == GL_COORD_REPLACE_NV) - ? ctx->Const.MaxTextureCoordUnits : ctx->Const.MaxCombinedTextureImageUnits; - if (ctx->Texture.CurrentUnit >= maxUnit) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glTexEnvfv(current unit)"); - return; - } - - texUnit = _mesa_get_current_tex_unit(ctx); - - if (target == GL_TEXTURE_ENV) { - switch (pname) { - case GL_TEXTURE_ENV_MODE: - set_env_mode(ctx, texUnit, (GLenum) iparam0); - break; - case GL_TEXTURE_ENV_COLOR: - set_env_color(ctx, texUnit, param); - break; - case GL_COMBINE_RGB: - case GL_COMBINE_ALPHA: - set_combiner_mode(ctx, texUnit, pname, (GLenum) iparam0); - break; - case GL_SOURCE0_RGB: - case GL_SOURCE1_RGB: - case GL_SOURCE2_RGB: - case GL_SOURCE3_RGB_NV: - case GL_SOURCE0_ALPHA: - case GL_SOURCE1_ALPHA: - case GL_SOURCE2_ALPHA: - case GL_SOURCE3_ALPHA_NV: - set_combiner_source(ctx, texUnit, pname, (GLenum) iparam0); - break; - case GL_OPERAND0_RGB: - case GL_OPERAND1_RGB: - case GL_OPERAND2_RGB: - case GL_OPERAND3_RGB_NV: - case GL_OPERAND0_ALPHA: - case GL_OPERAND1_ALPHA: - case GL_OPERAND2_ALPHA: - case GL_OPERAND3_ALPHA_NV: - set_combiner_operand(ctx, texUnit, pname, (GLenum) iparam0); - break; - case GL_RGB_SCALE: - case GL_ALPHA_SCALE: - set_combiner_scale(ctx, texUnit, pname, param[0]); - break; - case GL_BUMP_TARGET_ATI: - if (!ctx->Extensions.ATI_envmap_bumpmap) { - _mesa_error( ctx, GL_INVALID_ENUM, "glTexEnv(pname=0x%x)", pname ); - return; - } - if ((iparam0 < GL_TEXTURE0) || - (iparam0 > GL_TEXTURE31)) { - /* spec doesn't say this but it seems logical */ - _mesa_error( ctx, GL_INVALID_ENUM, "glTexEnv(param=0x%x)", iparam0); - return; - } - if (!((1 << (iparam0 - GL_TEXTURE0)) & ctx->Const.SupportedBumpUnits)) { - _mesa_error( ctx, GL_INVALID_VALUE, "glTexEnv(param=0x%x)", iparam0); - return; - } - else { - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - texUnit->BumpTarget = iparam0; - } - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glTexEnv(pname)" ); - return; - } - } - else if (target == GL_TEXTURE_FILTER_CONTROL_EXT) { - /* GL_EXT_texture_lod_bias */ - if (!ctx->Extensions.EXT_texture_lod_bias) { - _mesa_error( ctx, GL_INVALID_ENUM, "glTexEnv(target=0x%x)", target ); - return; - } - if (pname == GL_TEXTURE_LOD_BIAS_EXT) { - if (texUnit->LodBias == param[0]) - return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - texUnit->LodBias = param[0]; - } - else { - TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname); - return; - } - } - else if (target == GL_POINT_SPRITE_NV) { - /* GL_ARB_point_sprite / GL_NV_point_sprite */ - if (!ctx->Extensions.NV_point_sprite - && !ctx->Extensions.ARB_point_sprite) { - _mesa_error( ctx, GL_INVALID_ENUM, "glTexEnv(target=0x%x)", target ); - return; - } - if (pname == GL_COORD_REPLACE_NV) { - if (iparam0 == GL_TRUE || iparam0 == GL_FALSE) { - /* It's kind of weird to set point state via glTexEnv, - * but that's what the spec calls for. - */ - const GLboolean state = (GLboolean) iparam0; - if (ctx->Point.CoordReplace[ctx->Texture.CurrentUnit] == state) - return; - FLUSH_VERTICES(ctx, _NEW_POINT); - ctx->Point.CoordReplace[ctx->Texture.CurrentUnit] = state; - } - else { - _mesa_error( ctx, GL_INVALID_VALUE, "glTexEnv(param=0x%x)", iparam0); - return; - } - } - else { - _mesa_error( ctx, GL_INVALID_ENUM, "glTexEnv(pname=0x%x)", pname ); - return; - } - } - else { - _mesa_error( ctx, GL_INVALID_ENUM, "glTexEnv(target=0x%x)",target ); - return; - } - - if (MESA_VERBOSE&(VERBOSE_API|VERBOSE_TEXTURE)) - _mesa_debug(ctx, "glTexEnv %s %s %.1f(%s) ...\n", - _mesa_lookup_enum_by_nr(target), - _mesa_lookup_enum_by_nr(pname), - *param, - _mesa_lookup_enum_by_nr((GLenum) iparam0)); - - /* Tell device driver about the new texture environment */ - if (ctx->Driver.TexEnv) { - (*ctx->Driver.TexEnv)( ctx, target, pname, param ); - } -} - - -void GLAPIENTRY -_mesa_TexEnvf( GLenum target, GLenum pname, GLfloat param ) -{ - GLfloat p[4]; - p[0] = param; - p[1] = p[2] = p[3] = 0.0; - _mesa_TexEnvfv( target, pname, p ); -} - - - -void GLAPIENTRY -_mesa_TexEnvi( GLenum target, GLenum pname, GLint param ) -{ - GLfloat p[4]; - p[0] = (GLfloat) param; - p[1] = p[2] = p[3] = 0.0; - _mesa_TexEnvfv( target, pname, p ); -} - - -void GLAPIENTRY -_mesa_TexEnviv( GLenum target, GLenum pname, const GLint *param ) -{ - GLfloat p[4]; - if (pname == GL_TEXTURE_ENV_COLOR) { - p[0] = INT_TO_FLOAT( param[0] ); - p[1] = INT_TO_FLOAT( param[1] ); - p[2] = INT_TO_FLOAT( param[2] ); - p[3] = INT_TO_FLOAT( param[3] ); - } - else { - p[0] = (GLfloat) param[0]; - p[1] = p[2] = p[3] = 0; /* init to zero, just to be safe */ - } - _mesa_TexEnvfv( target, pname, p ); -} - - - -/** - * Helper for glGetTexEnvi/f() - * \return value of queried pname or -1 if error. - */ -static GLint -get_texenvi(struct gl_context *ctx, const struct gl_texture_unit *texUnit, - GLenum pname) -{ - switch (pname) { - case GL_TEXTURE_ENV_MODE: - return texUnit->EnvMode; - break; - case GL_COMBINE_RGB: - if (ctx->Extensions.EXT_texture_env_combine || - ctx->Extensions.ARB_texture_env_combine) { - return texUnit->Combine.ModeRGB; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); - } - break; - case GL_COMBINE_ALPHA: - if (ctx->Extensions.EXT_texture_env_combine || - ctx->Extensions.ARB_texture_env_combine) { - return texUnit->Combine.ModeA; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); - } - break; - case GL_SOURCE0_RGB: - case GL_SOURCE1_RGB: - case GL_SOURCE2_RGB: - if (ctx->Extensions.EXT_texture_env_combine || - ctx->Extensions.ARB_texture_env_combine) { - const unsigned rgb_idx = pname - GL_SOURCE0_RGB; - return texUnit->Combine.SourceRGB[rgb_idx]; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); - } - break; - case GL_SOURCE3_RGB_NV: - if (ctx->Extensions.NV_texture_env_combine4) { - return texUnit->Combine.SourceRGB[3]; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); - } - break; - case GL_SOURCE0_ALPHA: - case GL_SOURCE1_ALPHA: - case GL_SOURCE2_ALPHA: - if (ctx->Extensions.EXT_texture_env_combine || - ctx->Extensions.ARB_texture_env_combine) { - const unsigned alpha_idx = pname - GL_SOURCE0_ALPHA; - return texUnit->Combine.SourceA[alpha_idx]; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); - } - break; - case GL_SOURCE3_ALPHA_NV: - if (ctx->Extensions.NV_texture_env_combine4) { - return texUnit->Combine.SourceA[3]; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); - } - break; - case GL_OPERAND0_RGB: - case GL_OPERAND1_RGB: - case GL_OPERAND2_RGB: - if (ctx->Extensions.EXT_texture_env_combine || - ctx->Extensions.ARB_texture_env_combine) { - const unsigned op_rgb = pname - GL_OPERAND0_RGB; - return texUnit->Combine.OperandRGB[op_rgb]; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); - } - break; - case GL_OPERAND3_RGB_NV: - if (ctx->Extensions.NV_texture_env_combine4) { - return texUnit->Combine.OperandRGB[3]; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); - } - break; - case GL_OPERAND0_ALPHA: - case GL_OPERAND1_ALPHA: - case GL_OPERAND2_ALPHA: - if (ctx->Extensions.EXT_texture_env_combine || - ctx->Extensions.ARB_texture_env_combine) { - const unsigned op_alpha = pname - GL_OPERAND0_ALPHA; - return texUnit->Combine.OperandA[op_alpha]; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); - } - break; - case GL_OPERAND3_ALPHA_NV: - if (ctx->Extensions.NV_texture_env_combine4) { - return texUnit->Combine.OperandA[3]; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); - } - break; - case GL_RGB_SCALE: - if (ctx->Extensions.EXT_texture_env_combine || - ctx->Extensions.ARB_texture_env_combine) { - return 1 << texUnit->Combine.ScaleShiftRGB; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); - } - break; - case GL_ALPHA_SCALE: - if (ctx->Extensions.EXT_texture_env_combine || - ctx->Extensions.ARB_texture_env_combine) { - return 1 << texUnit->Combine.ScaleShiftA; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); - } - break; - case GL_BUMP_TARGET_ATI: - /* spec doesn't say so, but I think this should be queryable */ - if (ctx->Extensions.ATI_envmap_bumpmap) { - return texUnit->BumpTarget; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); - } - break; - - default: - ; - } - - return -1; /* error */ -} - - - -void GLAPIENTRY -_mesa_GetTexEnvfv( GLenum target, GLenum pname, GLfloat *params ) -{ - GLuint maxUnit; - const struct gl_texture_unit *texUnit; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - maxUnit = (target == GL_POINT_SPRITE_NV && pname == GL_COORD_REPLACE_NV) - ? ctx->Const.MaxTextureCoordUnits : ctx->Const.MaxCombinedTextureImageUnits; - if (ctx->Texture.CurrentUnit >= maxUnit) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexEnvfv(current unit)"); - return; - } - - texUnit = _mesa_get_current_tex_unit(ctx); - - if (target == GL_TEXTURE_ENV) { - if (pname == GL_TEXTURE_ENV_COLOR) { - if(ctx->NewState & (_NEW_BUFFERS | _NEW_FRAG_CLAMP)) - _mesa_update_state(ctx); - if(ctx->Color._ClampFragmentColor) - COPY_4FV( params, texUnit->EnvColor ); - else - COPY_4FV( params, texUnit->EnvColorUnclamped ); - } - else { - GLint val = get_texenvi(ctx, texUnit, pname); - if (val >= 0) { - *params = (GLfloat) val; - } - } - } - else if (target == GL_TEXTURE_FILTER_CONTROL_EXT) { - /* GL_EXT_texture_lod_bias */ - if (!ctx->Extensions.EXT_texture_lod_bias) { - _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexEnvfv(target)" ); - return; - } - if (pname == GL_TEXTURE_LOD_BIAS_EXT) { - *params = texUnit->LodBias; - } - else { - _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)" ); - return; - } - } - else if (target == GL_POINT_SPRITE_NV) { - /* GL_ARB_point_sprite / GL_NV_point_sprite */ - if (!ctx->Extensions.NV_point_sprite - && !ctx->Extensions.ARB_point_sprite) { - _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexEnvfv(target)" ); - return; - } - if (pname == GL_COORD_REPLACE_NV) { - *params = (GLfloat) ctx->Point.CoordReplace[ctx->Texture.CurrentUnit]; - } - else { - _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)" ); - return; - } - } - else { - _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexEnvfv(target)" ); - return; - } -} - - -void GLAPIENTRY -_mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params ) -{ - GLuint maxUnit; - const struct gl_texture_unit *texUnit; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - maxUnit = (target == GL_POINT_SPRITE_NV && pname == GL_COORD_REPLACE_NV) - ? ctx->Const.MaxTextureCoordUnits : ctx->Const.MaxCombinedTextureImageUnits; - if (ctx->Texture.CurrentUnit >= maxUnit) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexEnviv(current unit)"); - return; - } - - texUnit = _mesa_get_current_tex_unit(ctx); - - if (target == GL_TEXTURE_ENV) { - if (pname == GL_TEXTURE_ENV_COLOR) { - params[0] = FLOAT_TO_INT( texUnit->EnvColor[0] ); - params[1] = FLOAT_TO_INT( texUnit->EnvColor[1] ); - params[2] = FLOAT_TO_INT( texUnit->EnvColor[2] ); - params[3] = FLOAT_TO_INT( texUnit->EnvColor[3] ); - } - else { - GLint val = get_texenvi(ctx, texUnit, pname); - if (val >= 0) { - *params = val; - } - } - } - else if (target == GL_TEXTURE_FILTER_CONTROL_EXT) { - /* GL_EXT_texture_lod_bias */ - if (!ctx->Extensions.EXT_texture_lod_bias) { - _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexEnviv(target)" ); - return; - } - if (pname == GL_TEXTURE_LOD_BIAS_EXT) { - *params = (GLint) texUnit->LodBias; - } - else { - _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)" ); - return; - } - } - else if (target == GL_POINT_SPRITE_NV) { - /* GL_ARB_point_sprite / GL_NV_point_sprite */ - if (!ctx->Extensions.NV_point_sprite - && !ctx->Extensions.ARB_point_sprite) { - _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexEnviv(target)" ); - return; - } - if (pname == GL_COORD_REPLACE_NV) { - *params = (GLint) ctx->Point.CoordReplace[ctx->Texture.CurrentUnit]; - } - else { - _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)" ); - return; - } - } - else { - _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexEnviv(target)" ); - return; - } -} - - -/** - * Why does ATI_envmap_bumpmap require new entrypoints? Should just - * reuse TexEnv ones... - */ -void GLAPIENTRY -_mesa_TexBumpParameterivATI( GLenum pname, const GLint *param ) -{ - GLfloat p[4]; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (!ctx->Extensions.ATI_envmap_bumpmap) { - /* This isn't an "official" error case, but let's tell the user - * that something's wrong. - */ - _mesa_error(ctx, GL_INVALID_OPERATION, "glTexBumpParameterivATI"); - return; - } - - if (pname == GL_BUMP_ROT_MATRIX_ATI) { - /* hope that conversion is correct here */ - p[0] = INT_TO_FLOAT( param[0] ); - p[1] = INT_TO_FLOAT( param[1] ); - p[2] = INT_TO_FLOAT( param[2] ); - p[3] = INT_TO_FLOAT( param[3] ); - } - else { - p[0] = (GLfloat) param[0]; - p[1] = p[2] = p[3] = 0.0F; /* init to zero, just to be safe */ - } - _mesa_TexBumpParameterfvATI( pname, p ); -} - - -void GLAPIENTRY -_mesa_TexBumpParameterfvATI( GLenum pname, const GLfloat *param ) -{ - struct gl_texture_unit *texUnit; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (!ctx->Extensions.ATI_envmap_bumpmap) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glTexBumpParameterfvATI"); - return; - } - - texUnit = _mesa_get_current_tex_unit(ctx); - - if (pname == GL_BUMP_ROT_MATRIX_ATI) { - if (TEST_EQ_4V(param, texUnit->RotMatrix)) - return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - COPY_4FV(texUnit->RotMatrix, param); - } - else { - _mesa_error( ctx, GL_INVALID_ENUM, "glTexBumpParameter(pname)" ); - return; - } - /* Drivers might want to know about this, instead of dedicated function - just shove it into TexEnv where it really belongs anyway */ - if (ctx->Driver.TexEnv) { - (*ctx->Driver.TexEnv)( ctx, 0, pname, param ); - } -} - - -void GLAPIENTRY -_mesa_GetTexBumpParameterivATI( GLenum pname, GLint *param ) -{ - const struct gl_texture_unit *texUnit; - GLuint i; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (!ctx->Extensions.ATI_envmap_bumpmap) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexBumpParameterivATI"); - return; - } - - texUnit = _mesa_get_current_tex_unit(ctx); - - if (pname == GL_BUMP_ROT_MATRIX_SIZE_ATI) { - /* spec leaves open to support larger matrices. - Don't think anyone would ever want to use it - (and apps almost certainly would not understand it and - thus fail to submit matrices correctly) so hardcode this. */ - *param = 4; - } - else if (pname == GL_BUMP_ROT_MATRIX_ATI) { - /* hope that conversion is correct here */ - param[0] = FLOAT_TO_INT(texUnit->RotMatrix[0]); - param[1] = FLOAT_TO_INT(texUnit->RotMatrix[1]); - param[2] = FLOAT_TO_INT(texUnit->RotMatrix[2]); - param[3] = FLOAT_TO_INT(texUnit->RotMatrix[3]); - } - else if (pname == GL_BUMP_NUM_TEX_UNITS_ATI) { - GLint count = 0; - for (i = 0; i < ctx->Const.MaxTextureImageUnits; i++) { - if (ctx->Const.SupportedBumpUnits & (1 << i)) { - count++; - } - } - *param = count; - } - else if (pname == GL_BUMP_TEX_UNITS_ATI) { - for (i = 0; i < ctx->Const.MaxTextureImageUnits; i++) { - if (ctx->Const.SupportedBumpUnits & (1 << i)) { - *param++ = i + GL_TEXTURE0; - } - } - } - else { - _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexBumpParameter(pname)" ); - return; - } -} - - -void GLAPIENTRY -_mesa_GetTexBumpParameterfvATI( GLenum pname, GLfloat *param ) -{ - const struct gl_texture_unit *texUnit; - GLuint i; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (!ctx->Extensions.ATI_envmap_bumpmap) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexBumpParameterfvATI"); - return; - } - - texUnit = _mesa_get_current_tex_unit(ctx); - - if (pname == GL_BUMP_ROT_MATRIX_SIZE_ATI) { - /* spec leaves open to support larger matrices. - Don't think anyone would ever want to use it - (and apps might not understand it) so hardcode this. */ - *param = 4.0F; - } - else if (pname == GL_BUMP_ROT_MATRIX_ATI) { - param[0] = texUnit->RotMatrix[0]; - param[1] = texUnit->RotMatrix[1]; - param[2] = texUnit->RotMatrix[2]; - param[3] = texUnit->RotMatrix[3]; - } - else if (pname == GL_BUMP_NUM_TEX_UNITS_ATI) { - GLint count = 0; - for (i = 0; i < ctx->Const.MaxTextureImageUnits; i++) { - if (ctx->Const.SupportedBumpUnits & (1 << i)) { - count++; - } - } - *param = (GLfloat) count; - } - else if (pname == GL_BUMP_TEX_UNITS_ATI) { - for (i = 0; i < ctx->Const.MaxTextureImageUnits; i++) { - if (ctx->Const.SupportedBumpUnits & (1 << i)) { - *param++ = (GLfloat) (i + GL_TEXTURE0); - } - } - } - else { - _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexBumpParameter(pname)" ); - return; - } -} +/* + * Mesa 3-D graphics library + * Version: 7.5 + * + * Copyright (C) 1999-2008 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. + */ + +/** + * \file texenv.c + * + * glTexEnv-related functions + */ + + +#include "main/glheader.h" +#include "main/context.h" +#include "main/enums.h" +#include "main/macros.h" +#include "main/mtypes.h" +#include "main/state.h" +#include "main/texenv.h" +#include "main/texstate.h" + + +#define TE_ERROR(errCode, msg, value) \ + _mesa_error(ctx, errCode, msg, _mesa_lookup_enum_by_nr(value)); + + +/** Set texture env mode */ +static void +set_env_mode(struct gl_context *ctx, + struct gl_texture_unit *texUnit, + GLenum mode) +{ + GLboolean legal; + + if (texUnit->EnvMode == mode) + return; + + switch (mode) { + case GL_MODULATE: + case GL_BLEND: + case GL_DECAL: + case GL_REPLACE: + legal = GL_TRUE; + break; + case GL_REPLACE_EXT: + mode = GL_REPLACE; /* GL_REPLACE_EXT != GL_REPLACE */ + legal = GL_TRUE; + break; + case GL_ADD: + legal = ctx->Extensions.EXT_texture_env_add; + break; + case GL_COMBINE: + legal = (ctx->Extensions.EXT_texture_env_combine || + ctx->Extensions.ARB_texture_env_combine); + break; + case GL_COMBINE4_NV: + legal = ctx->Extensions.NV_texture_env_combine4; + break; + default: + legal = GL_FALSE; + } + + if (legal) { + FLUSH_VERTICES(ctx, _NEW_TEXTURE); + texUnit->EnvMode = mode; + } + else { + TE_ERROR(GL_INVALID_ENUM, "glTexEnv(param=%s)", mode); + } +} + + +static void +set_env_color(struct gl_context *ctx, + struct gl_texture_unit *texUnit, + const GLfloat *color) +{ + if (TEST_EQ_4V(color, texUnit->EnvColorUnclamped)) + return; + FLUSH_VERTICES(ctx, _NEW_TEXTURE); + COPY_4FV(texUnit->EnvColorUnclamped, color); + texUnit->EnvColor[0] = CLAMP(color[0], 0.0F, 1.0F); + texUnit->EnvColor[1] = CLAMP(color[1], 0.0F, 1.0F); + texUnit->EnvColor[2] = CLAMP(color[2], 0.0F, 1.0F); + texUnit->EnvColor[3] = CLAMP(color[3], 0.0F, 1.0F); +} + + +/** Set an RGB or A combiner mode/function */ +static void +set_combiner_mode(struct gl_context *ctx, + struct gl_texture_unit *texUnit, + GLenum pname, GLenum mode) +{ + GLboolean legal; + + if (!ctx->Extensions.EXT_texture_env_combine && + !ctx->Extensions.ARB_texture_env_combine) { + _mesa_error(ctx, GL_INVALID_ENUM, "glTexEnv(pname)"); + return; + } + + switch (mode) { + case GL_REPLACE: + case GL_MODULATE: + case GL_ADD: + case GL_ADD_SIGNED: + case GL_INTERPOLATE: + legal = GL_TRUE; + break; + case GL_SUBTRACT: + legal = ctx->Extensions.ARB_texture_env_combine; + break; + case GL_DOT3_RGB_EXT: + case GL_DOT3_RGBA_EXT: + legal = (ctx->Extensions.EXT_texture_env_dot3 && + pname == GL_COMBINE_RGB); + break; + case GL_DOT3_RGB: + case GL_DOT3_RGBA: + legal = (ctx->Extensions.ARB_texture_env_dot3 && + pname == GL_COMBINE_RGB); + break; + case GL_MODULATE_ADD_ATI: + case GL_MODULATE_SIGNED_ADD_ATI: + case GL_MODULATE_SUBTRACT_ATI: + legal = ctx->Extensions.ATI_texture_env_combine3; + break; + case GL_BUMP_ENVMAP_ATI: + legal = (ctx->Extensions.ATI_envmap_bumpmap && + pname == GL_COMBINE_RGB); + break; + default: + legal = GL_FALSE; + } + + if (!legal) { + TE_ERROR(GL_INVALID_ENUM, "glTexEnv(param=%s)", mode); + return; + } + + switch (pname) { + case GL_COMBINE_RGB: + if (texUnit->Combine.ModeRGB == mode) + return; + FLUSH_VERTICES(ctx, _NEW_TEXTURE); + texUnit->Combine.ModeRGB = mode; + break; + + case GL_COMBINE_ALPHA: + if (texUnit->Combine.ModeA == mode) + return; + FLUSH_VERTICES(ctx, _NEW_TEXTURE); + texUnit->Combine.ModeA = mode; + break; + default: + TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname); + } +} + + + +/** Set an RGB or A combiner source term */ +static void +set_combiner_source(struct gl_context *ctx, + struct gl_texture_unit *texUnit, + GLenum pname, GLenum param) +{ + GLuint term; + GLboolean alpha, legal; + + if (!ctx->Extensions.EXT_texture_env_combine && + !ctx->Extensions.ARB_texture_env_combine) { + _mesa_error(ctx, GL_INVALID_ENUM, "glTexEnv(pname)"); + return; + } + + /* + * Translate pname to (term, alpha). + * + * The enums were given sequential values for a reason. + */ + switch (pname) { + case GL_SOURCE0_RGB: + case GL_SOURCE1_RGB: + case GL_SOURCE2_RGB: + case GL_SOURCE3_RGB_NV: + term = pname - GL_SOURCE0_RGB; + alpha = GL_FALSE; + break; + case GL_SOURCE0_ALPHA: + case GL_SOURCE1_ALPHA: + case GL_SOURCE2_ALPHA: + case GL_SOURCE3_ALPHA_NV: + term = pname - GL_SOURCE0_ALPHA; + alpha = GL_TRUE; + break; + default: + TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname); + return; + } + + if ((term == 3) && !ctx->Extensions.NV_texture_env_combine4) { + TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname); + return; + } + + assert(term < MAX_COMBINER_TERMS); + + /* + * Error-check param (the source term) + */ + switch (param) { + case GL_TEXTURE: + case GL_CONSTANT: + case GL_PRIMARY_COLOR: + case GL_PREVIOUS: + legal = GL_TRUE; + break; + case GL_TEXTURE0: + case GL_TEXTURE1: + case GL_TEXTURE2: + case GL_TEXTURE3: + case GL_TEXTURE4: + case GL_TEXTURE5: + case GL_TEXTURE6: + case GL_TEXTURE7: + legal = (ctx->Extensions.ARB_texture_env_crossbar && + param - GL_TEXTURE0 < ctx->Const.MaxTextureUnits); + break; + case GL_ZERO: + legal = (ctx->Extensions.ATI_texture_env_combine3 || + ctx->Extensions.NV_texture_env_combine4); + break; + case GL_ONE: + legal = ctx->Extensions.ATI_texture_env_combine3; + break; + default: + legal = GL_FALSE; + } + + if (!legal) { + TE_ERROR(GL_INVALID_ENUM, "glTexEnv(param=%s)", param); + return; + } + + FLUSH_VERTICES(ctx, _NEW_TEXTURE); + + if (alpha) + texUnit->Combine.SourceA[term] = param; + else + texUnit->Combine.SourceRGB[term] = param; +} + + +/** Set an RGB or A combiner operand term */ +static void +set_combiner_operand(struct gl_context *ctx, + struct gl_texture_unit *texUnit, + GLenum pname, GLenum param) +{ + GLuint term; + GLboolean alpha, legal; + + if (!ctx->Extensions.EXT_texture_env_combine && + !ctx->Extensions.ARB_texture_env_combine) { + _mesa_error(ctx, GL_INVALID_ENUM, "glTexEnv(pname)"); + return; + } + + /* The enums were given sequential values for a reason. + */ + switch (pname) { + case GL_OPERAND0_RGB: + case GL_OPERAND1_RGB: + case GL_OPERAND2_RGB: + case GL_OPERAND3_RGB_NV: + term = pname - GL_OPERAND0_RGB; + alpha = GL_FALSE; + break; + case GL_OPERAND0_ALPHA: + case GL_OPERAND1_ALPHA: + case GL_OPERAND2_ALPHA: + case GL_OPERAND3_ALPHA_NV: + term = pname - GL_OPERAND0_ALPHA; + alpha = GL_TRUE; + break; + default: + TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname); + return; + } + + if ((term == 3) && !ctx->Extensions.NV_texture_env_combine4) { + TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname); + return; + } + + assert(term < MAX_COMBINER_TERMS); + + /* + * Error-check param (the source operand) + */ + switch (param) { + case GL_SRC_COLOR: + case GL_ONE_MINUS_SRC_COLOR: + /* The color input can only be used with GL_OPERAND[01]_RGB in the EXT + * version. In the ARB and NV versions they can be used for any RGB + * operand. + */ + legal = !alpha + && ((term < 2) || ctx->Extensions.ARB_texture_env_combine + || ctx->Extensions.NV_texture_env_combine4); + break; + case GL_ONE_MINUS_SRC_ALPHA: + /* GL_ONE_MINUS_SRC_ALPHA can only be used with + * GL_OPERAND[01]_(RGB|ALPHA) in the EXT version. In the ARB and NV + * versions it can be used for any operand. + */ + legal = (term < 2) || ctx->Extensions.ARB_texture_env_combine + || ctx->Extensions.NV_texture_env_combine4; + break; + case GL_SRC_ALPHA: + legal = GL_TRUE; + break; + default: + legal = GL_FALSE; + } + + if (!legal) { + TE_ERROR(GL_INVALID_ENUM, "glTexEnv(param=%s)", param); + return; + } + + FLUSH_VERTICES(ctx, _NEW_TEXTURE); + + if (alpha) + texUnit->Combine.OperandA[term] = param; + else + texUnit->Combine.OperandRGB[term] = param; +} + + +static void +set_combiner_scale(struct gl_context *ctx, + struct gl_texture_unit *texUnit, + GLenum pname, GLfloat scale) +{ + GLuint shift; + + if (!ctx->Extensions.EXT_texture_env_combine && + !ctx->Extensions.ARB_texture_env_combine) { + _mesa_error(ctx, GL_INVALID_ENUM, "glTexEnv(pname)"); + return; + } + + if (scale == 1.0F) { + shift = 0; + } + else if (scale == 2.0F) { + shift = 1; + } + else if (scale == 4.0F) { + shift = 2; + } + else { + _mesa_error( ctx, GL_INVALID_VALUE, + "glTexEnv(GL_RGB_SCALE not 1, 2 or 4)" ); + return; + } + + switch (pname) { + case GL_RGB_SCALE: + if (texUnit->Combine.ScaleShiftRGB == shift) + return; + FLUSH_VERTICES(ctx, _NEW_TEXTURE); + texUnit->Combine.ScaleShiftRGB = shift; + break; + case GL_ALPHA_SCALE: + if (texUnit->Combine.ScaleShiftA == shift) + return; + FLUSH_VERTICES(ctx, _NEW_TEXTURE); + texUnit->Combine.ScaleShiftA = shift; + break; + default: + TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname); + } +} + + + +void GLAPIENTRY +_mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param ) +{ + const GLint iparam0 = (GLint) param[0]; + struct gl_texture_unit *texUnit; + GLuint maxUnit; + + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + maxUnit = (target == GL_POINT_SPRITE_NV && pname == GL_COORD_REPLACE_NV) + ? ctx->Const.MaxTextureCoordUnits : ctx->Const.MaxCombinedTextureImageUnits; + if (ctx->Texture.CurrentUnit >= maxUnit) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glTexEnvfv(current unit)"); + return; + } + + texUnit = _mesa_get_current_tex_unit(ctx); + + if (target == GL_TEXTURE_ENV) { + switch (pname) { + case GL_TEXTURE_ENV_MODE: + set_env_mode(ctx, texUnit, (GLenum) iparam0); + break; + case GL_TEXTURE_ENV_COLOR: + set_env_color(ctx, texUnit, param); + break; + case GL_COMBINE_RGB: + case GL_COMBINE_ALPHA: + set_combiner_mode(ctx, texUnit, pname, (GLenum) iparam0); + break; + case GL_SOURCE0_RGB: + case GL_SOURCE1_RGB: + case GL_SOURCE2_RGB: + case GL_SOURCE3_RGB_NV: + case GL_SOURCE0_ALPHA: + case GL_SOURCE1_ALPHA: + case GL_SOURCE2_ALPHA: + case GL_SOURCE3_ALPHA_NV: + set_combiner_source(ctx, texUnit, pname, (GLenum) iparam0); + break; + case GL_OPERAND0_RGB: + case GL_OPERAND1_RGB: + case GL_OPERAND2_RGB: + case GL_OPERAND3_RGB_NV: + case GL_OPERAND0_ALPHA: + case GL_OPERAND1_ALPHA: + case GL_OPERAND2_ALPHA: + case GL_OPERAND3_ALPHA_NV: + set_combiner_operand(ctx, texUnit, pname, (GLenum) iparam0); + break; + case GL_RGB_SCALE: + case GL_ALPHA_SCALE: + set_combiner_scale(ctx, texUnit, pname, param[0]); + break; + case GL_BUMP_TARGET_ATI: + if (!ctx->Extensions.ATI_envmap_bumpmap) { + _mesa_error( ctx, GL_INVALID_ENUM, "glTexEnv(pname=0x%x)", pname ); + return; + } + if ((iparam0 < GL_TEXTURE0) || + (iparam0 > GL_TEXTURE31)) { + /* spec doesn't say this but it seems logical */ + _mesa_error( ctx, GL_INVALID_ENUM, "glTexEnv(param=0x%x)", iparam0); + return; + } + if (!((1 << (iparam0 - GL_TEXTURE0)) & ctx->Const.SupportedBumpUnits)) { + _mesa_error( ctx, GL_INVALID_VALUE, "glTexEnv(param=0x%x)", iparam0); + return; + } + else { + FLUSH_VERTICES(ctx, _NEW_TEXTURE); + texUnit->BumpTarget = iparam0; + } + break; + default: + _mesa_error( ctx, GL_INVALID_ENUM, "glTexEnv(pname)" ); + return; + } + } + else if (target == GL_TEXTURE_FILTER_CONTROL_EXT) { + /* GL_EXT_texture_lod_bias */ + if (!ctx->Extensions.EXT_texture_lod_bias) { + _mesa_error( ctx, GL_INVALID_ENUM, "glTexEnv(target=0x%x)", target ); + return; + } + if (pname == GL_TEXTURE_LOD_BIAS_EXT) { + if (texUnit->LodBias == param[0]) + return; + FLUSH_VERTICES(ctx, _NEW_TEXTURE); + texUnit->LodBias = param[0]; + } + else { + TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname); + return; + } + } + else if (target == GL_POINT_SPRITE_NV) { + /* GL_ARB_point_sprite / GL_NV_point_sprite */ + if (!ctx->Extensions.NV_point_sprite + && !ctx->Extensions.ARB_point_sprite) { + _mesa_error( ctx, GL_INVALID_ENUM, "glTexEnv(target=0x%x)", target ); + return; + } + if (pname == GL_COORD_REPLACE_NV) { + if (iparam0 == GL_TRUE || iparam0 == GL_FALSE) { + /* It's kind of weird to set point state via glTexEnv, + * but that's what the spec calls for. + */ + const GLboolean state = (GLboolean) iparam0; + if (ctx->Point.CoordReplace[ctx->Texture.CurrentUnit] == state) + return; + FLUSH_VERTICES(ctx, _NEW_POINT); + ctx->Point.CoordReplace[ctx->Texture.CurrentUnit] = state; + } + else { + _mesa_error( ctx, GL_INVALID_VALUE, "glTexEnv(param=0x%x)", iparam0); + return; + } + } + else { + _mesa_error( ctx, GL_INVALID_ENUM, "glTexEnv(pname=0x%x)", pname ); + return; + } + } + else { + _mesa_error( ctx, GL_INVALID_ENUM, "glTexEnv(target=0x%x)",target ); + return; + } + + if (MESA_VERBOSE&(VERBOSE_API|VERBOSE_TEXTURE)) + _mesa_debug(ctx, "glTexEnv %s %s %.1f(%s) ...\n", + _mesa_lookup_enum_by_nr(target), + _mesa_lookup_enum_by_nr(pname), + *param, + _mesa_lookup_enum_by_nr((GLenum) iparam0)); + + /* Tell device driver about the new texture environment */ + if (ctx->Driver.TexEnv) { + (*ctx->Driver.TexEnv)( ctx, target, pname, param ); + } +} + + +void GLAPIENTRY +_mesa_TexEnvf( GLenum target, GLenum pname, GLfloat param ) +{ + GLfloat p[4]; + p[0] = param; + p[1] = p[2] = p[3] = 0.0; + _mesa_TexEnvfv( target, pname, p ); +} + + + +void GLAPIENTRY +_mesa_TexEnvi( GLenum target, GLenum pname, GLint param ) +{ + GLfloat p[4]; + p[0] = (GLfloat) param; + p[1] = p[2] = p[3] = 0.0; + _mesa_TexEnvfv( target, pname, p ); +} + + +void GLAPIENTRY +_mesa_TexEnviv( GLenum target, GLenum pname, const GLint *param ) +{ + GLfloat p[4]; + if (pname == GL_TEXTURE_ENV_COLOR) { + p[0] = INT_TO_FLOAT( param[0] ); + p[1] = INT_TO_FLOAT( param[1] ); + p[2] = INT_TO_FLOAT( param[2] ); + p[3] = INT_TO_FLOAT( param[3] ); + } + else { + p[0] = (GLfloat) param[0]; + p[1] = p[2] = p[3] = 0; /* init to zero, just to be safe */ + } + _mesa_TexEnvfv( target, pname, p ); +} + + + +/** + * Helper for glGetTexEnvi/f() + * \return value of queried pname or -1 if error. + */ +static GLint +get_texenvi(struct gl_context *ctx, const struct gl_texture_unit *texUnit, + GLenum pname) +{ + switch (pname) { + case GL_TEXTURE_ENV_MODE: + return texUnit->EnvMode; + break; + case GL_COMBINE_RGB: + if (ctx->Extensions.EXT_texture_env_combine || + ctx->Extensions.ARB_texture_env_combine) { + return texUnit->Combine.ModeRGB; + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); + } + break; + case GL_COMBINE_ALPHA: + if (ctx->Extensions.EXT_texture_env_combine || + ctx->Extensions.ARB_texture_env_combine) { + return texUnit->Combine.ModeA; + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); + } + break; + case GL_SOURCE0_RGB: + case GL_SOURCE1_RGB: + case GL_SOURCE2_RGB: + if (ctx->Extensions.EXT_texture_env_combine || + ctx->Extensions.ARB_texture_env_combine) { + const unsigned rgb_idx = pname - GL_SOURCE0_RGB; + return texUnit->Combine.SourceRGB[rgb_idx]; + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); + } + break; + case GL_SOURCE3_RGB_NV: + if (ctx->Extensions.NV_texture_env_combine4) { + return texUnit->Combine.SourceRGB[3]; + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); + } + break; + case GL_SOURCE0_ALPHA: + case GL_SOURCE1_ALPHA: + case GL_SOURCE2_ALPHA: + if (ctx->Extensions.EXT_texture_env_combine || + ctx->Extensions.ARB_texture_env_combine) { + const unsigned alpha_idx = pname - GL_SOURCE0_ALPHA; + return texUnit->Combine.SourceA[alpha_idx]; + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); + } + break; + case GL_SOURCE3_ALPHA_NV: + if (ctx->Extensions.NV_texture_env_combine4) { + return texUnit->Combine.SourceA[3]; + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); + } + break; + case GL_OPERAND0_RGB: + case GL_OPERAND1_RGB: + case GL_OPERAND2_RGB: + if (ctx->Extensions.EXT_texture_env_combine || + ctx->Extensions.ARB_texture_env_combine) { + const unsigned op_rgb = pname - GL_OPERAND0_RGB; + return texUnit->Combine.OperandRGB[op_rgb]; + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); + } + break; + case GL_OPERAND3_RGB_NV: + if (ctx->Extensions.NV_texture_env_combine4) { + return texUnit->Combine.OperandRGB[3]; + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); + } + break; + case GL_OPERAND0_ALPHA: + case GL_OPERAND1_ALPHA: + case GL_OPERAND2_ALPHA: + if (ctx->Extensions.EXT_texture_env_combine || + ctx->Extensions.ARB_texture_env_combine) { + const unsigned op_alpha = pname - GL_OPERAND0_ALPHA; + return texUnit->Combine.OperandA[op_alpha]; + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); + } + break; + case GL_OPERAND3_ALPHA_NV: + if (ctx->Extensions.NV_texture_env_combine4) { + return texUnit->Combine.OperandA[3]; + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); + } + break; + case GL_RGB_SCALE: + if (ctx->Extensions.EXT_texture_env_combine || + ctx->Extensions.ARB_texture_env_combine) { + return 1 << texUnit->Combine.ScaleShiftRGB; + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); + } + break; + case GL_ALPHA_SCALE: + if (ctx->Extensions.EXT_texture_env_combine || + ctx->Extensions.ARB_texture_env_combine) { + return 1 << texUnit->Combine.ScaleShiftA; + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); + } + break; + case GL_BUMP_TARGET_ATI: + /* spec doesn't say so, but I think this should be queryable */ + if (ctx->Extensions.ATI_envmap_bumpmap) { + return texUnit->BumpTarget; + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); + } + break; + + default: + ; + } + + return -1; /* error */ +} + + + +void GLAPIENTRY +_mesa_GetTexEnvfv( GLenum target, GLenum pname, GLfloat *params ) +{ + GLuint maxUnit; + const struct gl_texture_unit *texUnit; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + maxUnit = (target == GL_POINT_SPRITE_NV && pname == GL_COORD_REPLACE_NV) + ? ctx->Const.MaxTextureCoordUnits : ctx->Const.MaxCombinedTextureImageUnits; + if (ctx->Texture.CurrentUnit >= maxUnit) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexEnvfv(current unit)"); + return; + } + + texUnit = _mesa_get_current_tex_unit(ctx); + + if (target == GL_TEXTURE_ENV) { + if (pname == GL_TEXTURE_ENV_COLOR) { + if(ctx->NewState & (_NEW_BUFFERS | _NEW_FRAG_CLAMP)) + _mesa_update_state(ctx); + if(ctx->Color._ClampFragmentColor) + COPY_4FV( params, texUnit->EnvColor ); + else + COPY_4FV( params, texUnit->EnvColorUnclamped ); + } + else { + GLint val = get_texenvi(ctx, texUnit, pname); + if (val >= 0) { + *params = (GLfloat) val; + } + } + } + else if (target == GL_TEXTURE_FILTER_CONTROL_EXT) { + /* GL_EXT_texture_lod_bias */ + if (!ctx->Extensions.EXT_texture_lod_bias) { + _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexEnvfv(target)" ); + return; + } + if (pname == GL_TEXTURE_LOD_BIAS_EXT) { + *params = texUnit->LodBias; + } + else { + _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)" ); + return; + } + } + else if (target == GL_POINT_SPRITE_NV) { + /* GL_ARB_point_sprite / GL_NV_point_sprite */ + if (!ctx->Extensions.NV_point_sprite + && !ctx->Extensions.ARB_point_sprite) { + _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexEnvfv(target)" ); + return; + } + if (pname == GL_COORD_REPLACE_NV) { + *params = (GLfloat) ctx->Point.CoordReplace[ctx->Texture.CurrentUnit]; + } + else { + _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)" ); + return; + } + } + else { + _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexEnvfv(target)" ); + return; + } +} + + +void GLAPIENTRY +_mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params ) +{ + GLuint maxUnit; + const struct gl_texture_unit *texUnit; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + maxUnit = (target == GL_POINT_SPRITE_NV && pname == GL_COORD_REPLACE_NV) + ? ctx->Const.MaxTextureCoordUnits : ctx->Const.MaxCombinedTextureImageUnits; + if (ctx->Texture.CurrentUnit >= maxUnit) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexEnviv(current unit)"); + return; + } + + texUnit = _mesa_get_current_tex_unit(ctx); + + if (target == GL_TEXTURE_ENV) { + if (pname == GL_TEXTURE_ENV_COLOR) { + params[0] = FLOAT_TO_INT( texUnit->EnvColor[0] ); + params[1] = FLOAT_TO_INT( texUnit->EnvColor[1] ); + params[2] = FLOAT_TO_INT( texUnit->EnvColor[2] ); + params[3] = FLOAT_TO_INT( texUnit->EnvColor[3] ); + } + else { + GLint val = get_texenvi(ctx, texUnit, pname); + if (val >= 0) { + *params = val; + } + } + } + else if (target == GL_TEXTURE_FILTER_CONTROL_EXT) { + /* GL_EXT_texture_lod_bias */ + if (!ctx->Extensions.EXT_texture_lod_bias) { + _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexEnviv(target)" ); + return; + } + if (pname == GL_TEXTURE_LOD_BIAS_EXT) { + *params = (GLint) texUnit->LodBias; + } + else { + _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)" ); + return; + } + } + else if (target == GL_POINT_SPRITE_NV) { + /* GL_ARB_point_sprite / GL_NV_point_sprite */ + if (!ctx->Extensions.NV_point_sprite + && !ctx->Extensions.ARB_point_sprite) { + _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexEnviv(target)" ); + return; + } + if (pname == GL_COORD_REPLACE_NV) { + *params = (GLint) ctx->Point.CoordReplace[ctx->Texture.CurrentUnit]; + } + else { + _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)" ); + return; + } + } + else { + _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexEnviv(target)" ); + return; + } +} + + +/** + * Why does ATI_envmap_bumpmap require new entrypoints? Should just + * reuse TexEnv ones... + */ +void GLAPIENTRY +_mesa_TexBumpParameterivATI( GLenum pname, const GLint *param ) +{ + GLfloat p[4]; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (!ctx->Extensions.ATI_envmap_bumpmap) { + /* This isn't an "official" error case, but let's tell the user + * that something's wrong. + */ + _mesa_error(ctx, GL_INVALID_OPERATION, "glTexBumpParameterivATI"); + return; + } + + if (pname == GL_BUMP_ROT_MATRIX_ATI) { + /* hope that conversion is correct here */ + p[0] = INT_TO_FLOAT( param[0] ); + p[1] = INT_TO_FLOAT( param[1] ); + p[2] = INT_TO_FLOAT( param[2] ); + p[3] = INT_TO_FLOAT( param[3] ); + } + else { + p[0] = (GLfloat) param[0]; + p[1] = p[2] = p[3] = 0.0F; /* init to zero, just to be safe */ + } + _mesa_TexBumpParameterfvATI( pname, p ); +} + + +void GLAPIENTRY +_mesa_TexBumpParameterfvATI( GLenum pname, const GLfloat *param ) +{ + struct gl_texture_unit *texUnit; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (!ctx->Extensions.ATI_envmap_bumpmap) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glTexBumpParameterfvATI"); + return; + } + + texUnit = _mesa_get_current_tex_unit(ctx); + + if (pname == GL_BUMP_ROT_MATRIX_ATI) { + if (TEST_EQ_4V(param, texUnit->RotMatrix)) + return; + FLUSH_VERTICES(ctx, _NEW_TEXTURE); + COPY_4FV(texUnit->RotMatrix, param); + } + else { + _mesa_error( ctx, GL_INVALID_ENUM, "glTexBumpParameter(pname)" ); + return; + } + /* Drivers might want to know about this, instead of dedicated function + just shove it into TexEnv where it really belongs anyway */ + if (ctx->Driver.TexEnv) { + (*ctx->Driver.TexEnv)( ctx, 0, pname, param ); + } +} + + +void GLAPIENTRY +_mesa_GetTexBumpParameterivATI( GLenum pname, GLint *param ) +{ + const struct gl_texture_unit *texUnit; + GLuint i; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (!ctx->Extensions.ATI_envmap_bumpmap) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexBumpParameterivATI"); + return; + } + + texUnit = _mesa_get_current_tex_unit(ctx); + + if (pname == GL_BUMP_ROT_MATRIX_SIZE_ATI) { + /* spec leaves open to support larger matrices. + Don't think anyone would ever want to use it + (and apps almost certainly would not understand it and + thus fail to submit matrices correctly) so hardcode this. */ + *param = 4; + } + else if (pname == GL_BUMP_ROT_MATRIX_ATI) { + /* hope that conversion is correct here */ + param[0] = FLOAT_TO_INT(texUnit->RotMatrix[0]); + param[1] = FLOAT_TO_INT(texUnit->RotMatrix[1]); + param[2] = FLOAT_TO_INT(texUnit->RotMatrix[2]); + param[3] = FLOAT_TO_INT(texUnit->RotMatrix[3]); + } + else if (pname == GL_BUMP_NUM_TEX_UNITS_ATI) { + GLint count = 0; + for (i = 0; i < ctx->Const.MaxTextureImageUnits; i++) { + if (ctx->Const.SupportedBumpUnits & (1 << i)) { + count++; + } + } + *param = count; + } + else if (pname == GL_BUMP_TEX_UNITS_ATI) { + for (i = 0; i < ctx->Const.MaxTextureImageUnits; i++) { + if (ctx->Const.SupportedBumpUnits & (1 << i)) { + *param++ = i + GL_TEXTURE0; + } + } + } + else { + _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexBumpParameter(pname)" ); + return; + } +} + + +void GLAPIENTRY +_mesa_GetTexBumpParameterfvATI( GLenum pname, GLfloat *param ) +{ + const struct gl_texture_unit *texUnit; + GLuint i; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (!ctx->Extensions.ATI_envmap_bumpmap) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexBumpParameterfvATI"); + return; + } + + texUnit = _mesa_get_current_tex_unit(ctx); + + if (pname == GL_BUMP_ROT_MATRIX_SIZE_ATI) { + /* spec leaves open to support larger matrices. + Don't think anyone would ever want to use it + (and apps might not understand it) so hardcode this. */ + *param = 4.0F; + } + else if (pname == GL_BUMP_ROT_MATRIX_ATI) { + param[0] = texUnit->RotMatrix[0]; + param[1] = texUnit->RotMatrix[1]; + param[2] = texUnit->RotMatrix[2]; + param[3] = texUnit->RotMatrix[3]; + } + else if (pname == GL_BUMP_NUM_TEX_UNITS_ATI) { + GLint count = 0; + for (i = 0; i < ctx->Const.MaxTextureImageUnits; i++) { + if (ctx->Const.SupportedBumpUnits & (1 << i)) { + count++; + } + } + *param = (GLfloat) count; + } + else if (pname == GL_BUMP_TEX_UNITS_ATI) { + for (i = 0; i < ctx->Const.MaxTextureImageUnits; i++) { + if (ctx->Const.SupportedBumpUnits & (1 << i)) { + *param++ = (GLfloat) (i + GL_TEXTURE0); + } + } + } + else { + _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexBumpParameter(pname)" ); + return; + } +} diff --git a/mesalib/src/mesa/main/texgetimage.c b/mesalib/src/mesa/main/texgetimage.c index 7e1fc3695..2830dda86 100644 --- a/mesalib/src/mesa/main/texgetimage.c +++ b/mesalib/src/mesa/main/texgetimage.c @@ -1,853 +1,853 @@ -/* - * Mesa 3-D graphics library - * Version: 7.7 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (c) 2009 VMware, 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 - * 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. - */ - - -/** - * Code for glGetTexImage() and glGetCompressedTexImage(). - */ - - -#include "glheader.h" -#include "bufferobj.h" -#include "enums.h" -#include "context.h" -#include "formats.h" -#include "format_unpack.h" -#include "image.h" -#include "mfeatures.h" -#include "mtypes.h" -#include "pack.h" -#include "pbo.h" -#include "texcompress.h" -#include "texgetimage.h" -#include "teximage.h" - - - -/** - * Can the given type represent negative values? - */ -static INLINE GLboolean -type_with_negative_values(GLenum type) -{ - switch (type) { - case GL_BYTE: - case GL_SHORT: - case GL_INT: - case GL_FLOAT: - case GL_HALF_FLOAT_ARB: - return GL_TRUE; - default: - return GL_FALSE; - } -} - - -/** - * glGetTexImage for depth/Z pixels. - */ -static void -get_tex_depth(struct gl_context *ctx, GLuint dimensions, - GLenum format, GLenum type, GLvoid *pixels, - const struct gl_texture_image *texImage) -{ - const GLint width = texImage->Width; - const GLint height = texImage->Height; - const GLint depth = texImage->Depth; - GLint img, row; - GLfloat *depthRow = (GLfloat *) malloc(width * sizeof(GLfloat)); - const GLint texelSize = _mesa_get_format_bytes(texImage->TexFormat); - - if (!depthRow) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGetTexImage"); - return; - } - - for (img = 0; img < depth; img++) { - for (row = 0; row < height; row++) { - void *dest = _mesa_image_address(dimensions, &ctx->Pack, pixels, - width, height, format, type, - img, row, 0); - const GLubyte *src = (GLubyte *) texImage->Data + - (texImage->ImageOffsets[img] + - texImage->RowStride * row) * texelSize; - - _mesa_unpack_float_z_row(texImage->TexFormat, width, src, depthRow); - - _mesa_pack_depth_span(ctx, width, dest, type, depthRow, &ctx->Pack); - } - } - - free(depthRow); -} - - -/** - * glGetTexImage for depth/stencil pixels. - */ -static void -get_tex_depth_stencil(struct gl_context *ctx, GLuint dimensions, - GLenum format, GLenum type, GLvoid *pixels, - const struct gl_texture_image *texImage) -{ - const GLint width = texImage->Width; - const GLint height = texImage->Height; - const GLint depth = texImage->Depth; - const GLint rowstride = texImage->RowStride; - const GLuint *src = (const GLuint *) texImage->Data; - GLint img, row; - - for (img = 0; img < depth; img++) { - for (row = 0; row < height; row++) { - void *dest = _mesa_image_address(dimensions, &ctx->Pack, pixels, - width, height, format, type, - img, row, 0); - memcpy(dest, src, width * sizeof(GLuint)); - if (ctx->Pack.SwapBytes) { - _mesa_swap4((GLuint *) dest, width); - } - - src += rowstride; - } - } -} - - -/** - * glGetTexImage for YCbCr pixels. - */ -static void -get_tex_ycbcr(struct gl_context *ctx, GLuint dimensions, - GLenum format, GLenum type, GLvoid *pixels, - const struct gl_texture_image *texImage) -{ - const GLint width = texImage->Width; - const GLint height = texImage->Height; - const GLint depth = texImage->Depth; - const GLint rowstride = texImage->RowStride; - const GLushort *src = (const GLushort *) texImage->Data; - GLint img, row; - - for (img = 0; img < depth; img++) { - for (row = 0; row < height; row++) { - void *dest = _mesa_image_address(dimensions, &ctx->Pack, pixels, - width, height, format, type, - img, row, 0); - memcpy(dest, src, width * sizeof(GLushort)); - - /* check for byte swapping */ - if ((texImage->TexFormat == MESA_FORMAT_YCBCR - && type == GL_UNSIGNED_SHORT_8_8_REV_MESA) || - (texImage->TexFormat == MESA_FORMAT_YCBCR_REV - && type == GL_UNSIGNED_SHORT_8_8_MESA)) { - if (!ctx->Pack.SwapBytes) - _mesa_swap2((GLushort *) dest, width); - } - else if (ctx->Pack.SwapBytes) { - _mesa_swap2((GLushort *) dest, width); - } - - src += rowstride; - } - } -} - - -/** - * glGetTexImage for color formats (RGBA, RGB, alpha, LA, etc). - * Compressed textures are handled here as well. - */ -static void -get_tex_rgba(struct gl_context *ctx, GLuint dimensions, - GLenum format, GLenum type, GLvoid *pixels, - struct gl_texture_image *texImage) -{ - /* don't want to apply sRGB -> RGB conversion here so override the format */ - const gl_format texFormat = _mesa_get_srgb_format_linear(texImage->TexFormat); - const GLuint width = texImage->Width; - const GLuint height = texImage->Height; - const GLuint depth = texImage->Depth; - const GLenum dataType = _mesa_get_format_datatype(texFormat); - const GLenum baseFormat = _mesa_get_format_base_format(texFormat); - /* Normally, no pixel transfer ops are performed during glGetTexImage. - * The only possible exception is component clamping to [0,1]. - */ - GLbitfield transferOps = 0x0; - - /* In general, clamping does not apply to glGetTexImage, except when - * the returned type of the image can't hold negative values. - */ - if (!type_with_negative_values(type)) { - /* the returned image type can't have negative values */ - if (dataType == GL_FLOAT || - dataType == GL_SIGNED_NORMALIZED || - format == GL_LUMINANCE || - format == GL_LUMINANCE_ALPHA) { - transferOps |= IMAGE_CLAMP_BIT; - } - } - - if (_mesa_is_format_compressed(texFormat)) { - /* Decompress into temp buffer, then pack into user buffer */ - GLfloat *tempImage, *srcRow; - GLuint row; - - tempImage = (GLfloat *) malloc(texImage->Width * texImage->Height * - texImage->Depth * 4 * sizeof(GLfloat)); - if (!tempImage) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGetTexImage()"); - return; - } - - _mesa_decompress_image(texFormat, texImage->Width, texImage->Height, - texImage->Data, texImage->RowStride, tempImage); - - if (baseFormat == GL_LUMINANCE || - baseFormat == GL_LUMINANCE_ALPHA) { - /* Set green and blue to zero since the pack function here will - * compute L=R+G+B. - */ - GLuint i; - for (i = 0; i < width * height; i++) { - tempImage[i * 4 + GCOMP] = tempImage[i * 4 + BCOMP] = 0.0f; - } - } - - srcRow = tempImage; - for (row = 0; row < height; row++) { - void *dest = _mesa_image_address(dimensions, &ctx->Pack, pixels, - width, height, format, type, - 0, row, 0); - - _mesa_pack_rgba_span_float(ctx, width, (GLfloat (*)[4]) srcRow, - format, type, dest, &ctx->Pack, transferOps); - srcRow += width * 4; - } - - free(tempImage); - } - else { - /* No decompression needed */ - const GLint texelSize = _mesa_get_format_bytes(texFormat); - GLuint img, row; - GLfloat (*rgba)[4]; - - rgba = (GLfloat (*)[4]) malloc(4 * width * sizeof(GLfloat)); - if (!rgba) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGetTexImage()"); - return; - } - - for (img = 0; img < depth; img++) { - for (row = 0; row < height; row++) { - void *dest = _mesa_image_address(dimensions, &ctx->Pack, pixels, - width, height, format, type, - img, row, 0); - const GLubyte *src = (const GLubyte *) texImage->Data + - (texImage->ImageOffsets[img] + - texImage->RowStride * row) * texelSize; - - _mesa_unpack_rgba_row(texFormat, width, src, rgba); - - if (texImage->_BaseFormat == GL_ALPHA) { - GLint col; - for (col = 0; col < width; col++) { - rgba[col][RCOMP] = 0.0F; - rgba[col][GCOMP] = 0.0F; - rgba[col][BCOMP] = 0.0F; - } - } - else if (texImage->_BaseFormat == GL_LUMINANCE) { - GLint col; - for (col = 0; col < width; col++) { - rgba[col][GCOMP] = 0.0F; - rgba[col][BCOMP] = 0.0F; - rgba[col][ACOMP] = 1.0F; - } - } - else if (texImage->_BaseFormat == GL_LUMINANCE_ALPHA) { - GLint col; - for (col = 0; col < width; col++) { - rgba[col][GCOMP] = 0.0F; - rgba[col][BCOMP] = 0.0F; - } - } - else if (texImage->_BaseFormat == GL_INTENSITY) { - GLint col; - for (col = 0; col < width; col++) { - rgba[col][GCOMP] = 0.0F; - rgba[col][BCOMP] = 0.0F; - rgba[col][ACOMP] = 1.0F; - } - } - - _mesa_pack_rgba_span_float(ctx, width, (GLfloat (*)[4]) rgba, - format, type, dest, - &ctx->Pack, transferOps); - } - } - - free(rgba); - } -} - - -/** - * Try to do glGetTexImage() with simple memcpy(). - * \return GL_TRUE if done, GL_FALSE otherwise - */ -static GLboolean -get_tex_memcpy(struct gl_context *ctx, GLenum format, GLenum type, GLvoid *pixels, - const struct gl_texture_object *texObj, - const struct gl_texture_image *texImage) -{ - GLboolean memCopy = GL_FALSE; - - /* Texture image should have been mapped already */ - assert(texImage->Data); - - /* - * Check if the src/dst formats are compatible. - * Also note that GL's pixel transfer ops don't apply to glGetTexImage() - * so we don't have to worry about those. - * XXX more format combinations could be supported here. - */ - if ((texObj->Target == GL_TEXTURE_1D || - texObj->Target == GL_TEXTURE_2D || - texObj->Target == GL_TEXTURE_RECTANGLE || - (texObj->Target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X && - texObj->Target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z))) { - if ((texImage->TexFormat == MESA_FORMAT_ARGB8888 || - texImage->TexFormat == MESA_FORMAT_SARGB8) && - format == GL_BGRA && - (type == GL_UNSIGNED_BYTE || type == GL_UNSIGNED_INT_8_8_8_8_REV) && - !ctx->Pack.SwapBytes && - _mesa_little_endian()) { - memCopy = GL_TRUE; - } - else if ((texImage->TexFormat == MESA_FORMAT_AL88 || - texImage->TexFormat == MESA_FORMAT_SLA8) && - format == GL_LUMINANCE_ALPHA && - type == GL_UNSIGNED_BYTE && - !ctx->Pack.SwapBytes && - _mesa_little_endian()) { - memCopy = GL_TRUE; - } - else if ((texImage->TexFormat == MESA_FORMAT_L8 || - texImage->TexFormat == MESA_FORMAT_SL8) && - format == GL_LUMINANCE && - type == GL_UNSIGNED_BYTE) { - memCopy = GL_TRUE; - } - else if (texImage->TexFormat == MESA_FORMAT_L16 && - format == GL_LUMINANCE && - type == GL_UNSIGNED_SHORT) { - memCopy = GL_TRUE; - } - else if (texImage->TexFormat == MESA_FORMAT_A8 && - format == GL_ALPHA && - type == GL_UNSIGNED_BYTE) { - memCopy = GL_TRUE; - } - else if (texImage->TexFormat == MESA_FORMAT_A16 && - format == GL_ALPHA && - type == GL_UNSIGNED_SHORT) { - memCopy = GL_TRUE; - } - } - - if (memCopy) { - const GLuint bpp = _mesa_get_format_bytes(texImage->TexFormat); - const GLuint bytesPerRow = texImage->Width * bpp; - GLubyte *dst = - _mesa_image_address2d(&ctx->Pack, pixels, texImage->Width, - texImage->Height, format, type, 0, 0); - const GLint dstRowStride = - _mesa_image_row_stride(&ctx->Pack, texImage->Width, format, type); - const GLubyte *src = texImage->Data; - const GLint srcRowStride = texImage->RowStride * bpp; - GLuint row; - - if (bytesPerRow == dstRowStride && bytesPerRow == srcRowStride) { - memcpy(dst, src, bytesPerRow * texImage->Height); - } - else { - for (row = 0; row < texImage->Height; row++) { - memcpy(dst, src, bytesPerRow); - dst += dstRowStride; - src += srcRowStride; - } - } - } - - return memCopy; -} - - -/** - * This is the software fallback for Driver.GetTexImage(). - * All error checking will have been done before this routine is called. - * The texture image must be mapped. - */ -void -_mesa_get_teximage(struct gl_context *ctx, GLenum target, GLint level, - GLenum format, GLenum type, GLvoid *pixels, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) -{ - GLuint dimensions; - - /* If we get here, the texture image should be mapped */ - assert(texImage->Data); - - switch (target) { - case GL_TEXTURE_1D: - dimensions = 1; - break; - case GL_TEXTURE_3D: - dimensions = 3; - break; - default: - dimensions = 2; - } - - if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { - /* Packing texture image into a PBO. - * Map the (potentially) VRAM-based buffer into our process space so - * we can write into it with the code below. - * A hardware driver might use a sophisticated blit to move the - * texture data to the PBO if the PBO is in VRAM along with the texture. - */ - GLubyte *buf = (GLubyte *) - ctx->Driver.MapBufferRange(ctx, 0, ctx->Pack.BufferObj->Size, - GL_MAP_WRITE_BIT, ctx->Pack.BufferObj); - if (!buf) { - /* out of memory or other unexpected error */ - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGetTexImage(map PBO failed)"); - return; - } - /* was an offset into the PBO. - * Now make it a real, client-side pointer inside the mapped region. - */ - pixels = ADD_POINTERS(buf, pixels); - } - - if (get_tex_memcpy(ctx, format, type, pixels, texObj, texImage)) { - /* all done */ - } - else if (format == GL_DEPTH_COMPONENT) { - get_tex_depth(ctx, dimensions, format, type, pixels, texImage); - } - else if (format == GL_DEPTH_STENCIL_EXT) { - get_tex_depth_stencil(ctx, dimensions, format, type, pixels, texImage); - } - else if (format == GL_YCBCR_MESA) { - get_tex_ycbcr(ctx, dimensions, format, type, pixels, texImage); - } - else { - get_tex_rgba(ctx, dimensions, format, type, pixels, texImage); - } - - if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { - ctx->Driver.UnmapBuffer(ctx, ctx->Pack.BufferObj); - } -} - - - -/** - * This is the software fallback for Driver.GetCompressedTexImage(). - * All error checking will have been done before this routine is called. - */ -void -_mesa_get_compressed_teximage(struct gl_context *ctx, GLenum target, GLint level, - GLvoid *img, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) -{ - const GLuint row_stride = _mesa_format_row_stride(texImage->TexFormat, - texImage->Width); - const GLuint row_stride_stored = _mesa_format_row_stride(texImage->TexFormat, - texImage->RowStride); - GLuint i; - - if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { - /* pack texture image into a PBO */ - GLubyte *buf = (GLubyte *) - ctx->Driver.MapBufferRange(ctx, 0, ctx->Pack.BufferObj->Size, - GL_MAP_WRITE_BIT, ctx->Pack.BufferObj); - if (!buf) { - /* out of memory or other unexpected error */ - _mesa_error(ctx, GL_OUT_OF_MEMORY, - "glGetCompresssedTexImage(map PBO failed)"); - return; - } - img = ADD_POINTERS(buf, img); - } - - /* no pixelstore or pixel transfer, but respect stride */ - - if (row_stride == row_stride_stored) { - const GLuint size = _mesa_format_image_size(texImage->TexFormat, - texImage->Width, - texImage->Height, - texImage->Depth); - memcpy(img, texImage->Data, size); - } - else { - GLuint bw, bh; - _mesa_get_format_block_size(texImage->TexFormat, &bw, &bh); - for (i = 0; i < (texImage->Height + bh - 1) / bh; i++) { - memcpy((GLubyte *)img + i * row_stride, - (GLubyte *)texImage->Data + i * row_stride_stored, - row_stride); - } - } - - if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { - ctx->Driver.UnmapBuffer(ctx, ctx->Pack.BufferObj); - } -} - - - -/** - * Do error checking for a glGetTexImage() call. - * \return GL_TRUE if any error, GL_FALSE if no errors. - */ -static GLboolean -getteximage_error_check(struct gl_context *ctx, GLenum target, GLint level, - GLenum format, GLenum type, GLsizei clientMemSize, - GLvoid *pixels ) -{ - struct gl_texture_object *texObj; - struct gl_texture_image *texImage; - const GLint maxLevels = _mesa_max_texture_levels(ctx, target); - const GLuint dimensions = (target == GL_TEXTURE_3D) ? 3 : 2; - GLenum baseFormat; - - if (maxLevels == 0) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexImage(target=0x%x)", target); - return GL_TRUE; - } - - if (level < 0 || level >= maxLevels) { - _mesa_error( ctx, GL_INVALID_VALUE, "glGetTexImage(level)" ); - return GL_TRUE; - } - - if (_mesa_sizeof_packed_type(type) <= 0) { - _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexImage(type)" ); - return GL_TRUE; - } - - if (_mesa_components_in_format(format) <= 0 || - format == GL_STENCIL_INDEX || - format == GL_COLOR_INDEX) { - _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexImage(format)" ); - return GL_TRUE; - } - - if (!ctx->Extensions.ARB_depth_texture && _mesa_is_depth_format(format)) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexImage(format)"); - return GL_TRUE; - } - - if (!ctx->Extensions.MESA_ycbcr_texture && _mesa_is_ycbcr_format(format)) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexImage(format)"); - return GL_TRUE; - } - - if (!ctx->Extensions.EXT_packed_depth_stencil - && _mesa_is_depthstencil_format(format)) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexImage(format)"); - return GL_TRUE; - } - - if (!ctx->Extensions.ATI_envmap_bumpmap - && _mesa_is_dudv_format(format)) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexImage(format)"); - return GL_TRUE; - } - - texObj = _mesa_get_current_tex_object(ctx, target); - - if (!texObj || _mesa_is_proxy_texture(target)) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexImage(target)"); - return GL_TRUE; - } - - texImage = _mesa_select_tex_image(ctx, texObj, target, level); - if (!texImage) { - /* out of memory */ - return GL_TRUE; - } - - baseFormat = _mesa_get_format_base_format(texImage->TexFormat); - - /* Make sure the requested image format is compatible with the - * texture's format. - */ - if (_mesa_is_color_format(format) - && !_mesa_is_color_format(baseFormat)) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexImage(format mismatch)"); - return GL_TRUE; - } - else if (_mesa_is_depth_format(format) - && !_mesa_is_depth_format(baseFormat) - && !_mesa_is_depthstencil_format(baseFormat)) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexImage(format mismatch)"); - return GL_TRUE; - } - else if (_mesa_is_ycbcr_format(format) - && !_mesa_is_ycbcr_format(baseFormat)) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexImage(format mismatch)"); - return GL_TRUE; - } - else if (_mesa_is_depthstencil_format(format) - && !_mesa_is_depthstencil_format(baseFormat)) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexImage(format mismatch)"); - return GL_TRUE; - } - else if (_mesa_is_dudv_format(format) - && !_mesa_is_dudv_format(baseFormat)) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexImage(format mismatch)"); - return GL_TRUE; - } - - if (!_mesa_validate_pbo_access(dimensions, &ctx->Pack, texImage->Width, - texImage->Height, texImage->Depth, - format, type, clientMemSize, pixels)) { - if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetTexImage(out of bounds PBO access)"); - } else { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetnTexImageARB(out of bounds access:" - " bufSize (%d) is too small)", clientMemSize); - } - return GL_TRUE; - } - - if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { - /* PBO should not be mapped */ - if (_mesa_bufferobj_mapped(ctx->Pack.BufferObj)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetTexImage(PBO is mapped)"); - return GL_TRUE; - } - } - - return GL_FALSE; -} - - - -/** - * Get texture image. Called by glGetTexImage. - * - * \param target texture target. - * \param level image level. - * \param format pixel data format for returned image. - * \param type pixel data type for returned image. - * \param bufSize size of the pixels data buffer. - * \param pixels returned pixel data. - */ -void GLAPIENTRY -_mesa_GetnTexImageARB( GLenum target, GLint level, GLenum format, - GLenum type, GLsizei bufSize, GLvoid *pixels ) -{ - struct gl_texture_object *texObj; - struct gl_texture_image *texImage; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (getteximage_error_check(ctx, target, level, format, type, - bufSize, pixels)) { - return; - } - - if (!_mesa_is_bufferobj(ctx->Pack.BufferObj) && !pixels) { - /* not an error, do nothing */ - return; - } - - texObj = _mesa_get_current_tex_object(ctx, target); - texImage = _mesa_select_tex_image(ctx, texObj, target, level); - - if (MESA_VERBOSE & (VERBOSE_API | VERBOSE_TEXTURE)) { - _mesa_debug(ctx, "glGetTexImage(tex %u) format = %s, w=%d, h=%d," - " dstFmt=0x%x, dstType=0x%x\n", - texObj->Name, - _mesa_get_format_name(texImage->TexFormat), - texImage->Width, texImage->Height, - format, type); - } - - _mesa_lock_texture(ctx, texObj); - { - ctx->Driver.GetTexImage(ctx, target, level, format, type, pixels, - texObj, texImage); - } - _mesa_unlock_texture(ctx, texObj); -} - - -void GLAPIENTRY -_mesa_GetTexImage( GLenum target, GLint level, GLenum format, - GLenum type, GLvoid *pixels ) -{ - _mesa_GetnTexImageARB(target, level, format, type, INT_MAX, pixels); -} - - -/** - * Do error checking for a glGetCompressedTexImage() call. - * \return GL_TRUE if any error, GL_FALSE if no errors. - */ -static GLboolean -getcompressedteximage_error_check(struct gl_context *ctx, GLenum target, - GLint level, GLsizei clientMemSize, GLvoid *img) -{ - struct gl_texture_object *texObj; - struct gl_texture_image *texImage; - const GLint maxLevels = _mesa_max_texture_levels(ctx, target); - GLuint compressedSize; - - if (maxLevels == 0) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetCompressedTexImage(target=0x%x)", - target); - return GL_TRUE; - } - - if (level < 0 || level >= maxLevels) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glGetCompressedTexImageARB(bad level = %d)", level); - return GL_TRUE; - } - - if (_mesa_is_proxy_texture(target)) { - _mesa_error(ctx, GL_INVALID_ENUM, - "glGetCompressedTexImageARB(bad target = %s)", - _mesa_lookup_enum_by_nr(target)); - return GL_TRUE; - } - - texObj = _mesa_get_current_tex_object(ctx, target); - if (!texObj) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetCompressedTexImageARB(target)"); - return GL_TRUE; - } - - texImage = _mesa_select_tex_image(ctx, texObj, target, level); - - if (!texImage) { - /* probably invalid mipmap level */ - _mesa_error(ctx, GL_INVALID_VALUE, - "glGetCompressedTexImageARB(level)"); - return GL_TRUE; - } - - if (!_mesa_is_format_compressed(texImage->TexFormat)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetCompressedTexImageARB(texture is not compressed)"); - return GL_TRUE; - } - - compressedSize = _mesa_format_image_size(texImage->TexFormat, - texImage->Width, - texImage->Height, - texImage->Depth); - - if (!_mesa_is_bufferobj(ctx->Pack.BufferObj)) { - /* do bounds checking on writing to client memory */ - if (clientMemSize < compressedSize) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetnCompressedTexImageARB(out of bounds access:" - " bufSize (%d) is too small)", clientMemSize); - } - } else { - /* do bounds checking on PBO write */ - if ((const GLubyte *) img + compressedSize > - (const GLubyte *) ctx->Pack.BufferObj->Size) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetCompressedTexImage(out of bounds PBO access)"); - return GL_TRUE; - } - - /* make sure PBO is not mapped */ - if (_mesa_bufferobj_mapped(ctx->Pack.BufferObj)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetCompressedTexImage(PBO is mapped)"); - return GL_TRUE; - } - } - - return GL_FALSE; -} - - -void GLAPIENTRY -_mesa_GetnCompressedTexImageARB(GLenum target, GLint level, GLsizei bufSize, - GLvoid *img) -{ - struct gl_texture_object *texObj; - struct gl_texture_image *texImage; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (getcompressedteximage_error_check(ctx, target, level, bufSize, img)) { - return; - } - - if (_mesa_is_bufferobj(ctx->Pack.BufferObj) && !img) { - /* not an error, do nothing */ - return; - } - - texObj = _mesa_get_current_tex_object(ctx, target); - texImage = _mesa_select_tex_image(ctx, texObj, target, level); - - if (MESA_VERBOSE & (VERBOSE_API | VERBOSE_TEXTURE)) { - _mesa_debug(ctx, - "glGetCompressedTexImage(tex %u) format = %s, w=%d, h=%d\n", - texObj->Name, - _mesa_get_format_name(texImage->TexFormat), - texImage->Width, texImage->Height); - } - - _mesa_lock_texture(ctx, texObj); - { - ctx->Driver.GetCompressedTexImage(ctx, target, level, img, - texObj, texImage); - } - _mesa_unlock_texture(ctx, texObj); -} - -void GLAPIENTRY -_mesa_GetCompressedTexImageARB(GLenum target, GLint level, GLvoid *img) -{ - _mesa_GetnCompressedTexImageARB(target, level, INT_MAX, img); -} +/* + * Mesa 3-D graphics library + * Version: 7.7 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (c) 2009 VMware, 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 + * 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. + */ + + +/** + * Code for glGetTexImage() and glGetCompressedTexImage(). + */ + + +#include "glheader.h" +#include "bufferobj.h" +#include "enums.h" +#include "context.h" +#include "formats.h" +#include "format_unpack.h" +#include "image.h" +#include "mfeatures.h" +#include "mtypes.h" +#include "pack.h" +#include "pbo.h" +#include "texcompress.h" +#include "texgetimage.h" +#include "teximage.h" + + + +/** + * Can the given type represent negative values? + */ +static INLINE GLboolean +type_with_negative_values(GLenum type) +{ + switch (type) { + case GL_BYTE: + case GL_SHORT: + case GL_INT: + case GL_FLOAT: + case GL_HALF_FLOAT_ARB: + return GL_TRUE; + default: + return GL_FALSE; + } +} + + +/** + * glGetTexImage for depth/Z pixels. + */ +static void +get_tex_depth(struct gl_context *ctx, GLuint dimensions, + GLenum format, GLenum type, GLvoid *pixels, + const struct gl_texture_image *texImage) +{ + const GLint width = texImage->Width; + const GLint height = texImage->Height; + const GLint depth = texImage->Depth; + GLint img, row; + GLfloat *depthRow = (GLfloat *) malloc(width * sizeof(GLfloat)); + const GLint texelSize = _mesa_get_format_bytes(texImage->TexFormat); + + if (!depthRow) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGetTexImage"); + return; + } + + for (img = 0; img < depth; img++) { + for (row = 0; row < height; row++) { + void *dest = _mesa_image_address(dimensions, &ctx->Pack, pixels, + width, height, format, type, + img, row, 0); + const GLubyte *src = (GLubyte *) texImage->Data + + (texImage->ImageOffsets[img] + + texImage->RowStride * row) * texelSize; + + _mesa_unpack_float_z_row(texImage->TexFormat, width, src, depthRow); + + _mesa_pack_depth_span(ctx, width, dest, type, depthRow, &ctx->Pack); + } + } + + free(depthRow); +} + + +/** + * glGetTexImage for depth/stencil pixels. + */ +static void +get_tex_depth_stencil(struct gl_context *ctx, GLuint dimensions, + GLenum format, GLenum type, GLvoid *pixels, + const struct gl_texture_image *texImage) +{ + const GLint width = texImage->Width; + const GLint height = texImage->Height; + const GLint depth = texImage->Depth; + const GLint rowstride = texImage->RowStride; + const GLuint *src = (const GLuint *) texImage->Data; + GLint img, row; + + for (img = 0; img < depth; img++) { + for (row = 0; row < height; row++) { + void *dest = _mesa_image_address(dimensions, &ctx->Pack, pixels, + width, height, format, type, + img, row, 0); + memcpy(dest, src, width * sizeof(GLuint)); + if (ctx->Pack.SwapBytes) { + _mesa_swap4((GLuint *) dest, width); + } + + src += rowstride; + } + } +} + + +/** + * glGetTexImage for YCbCr pixels. + */ +static void +get_tex_ycbcr(struct gl_context *ctx, GLuint dimensions, + GLenum format, GLenum type, GLvoid *pixels, + const struct gl_texture_image *texImage) +{ + const GLint width = texImage->Width; + const GLint height = texImage->Height; + const GLint depth = texImage->Depth; + const GLint rowstride = texImage->RowStride; + const GLushort *src = (const GLushort *) texImage->Data; + GLint img, row; + + for (img = 0; img < depth; img++) { + for (row = 0; row < height; row++) { + void *dest = _mesa_image_address(dimensions, &ctx->Pack, pixels, + width, height, format, type, + img, row, 0); + memcpy(dest, src, width * sizeof(GLushort)); + + /* check for byte swapping */ + if ((texImage->TexFormat == MESA_FORMAT_YCBCR + && type == GL_UNSIGNED_SHORT_8_8_REV_MESA) || + (texImage->TexFormat == MESA_FORMAT_YCBCR_REV + && type == GL_UNSIGNED_SHORT_8_8_MESA)) { + if (!ctx->Pack.SwapBytes) + _mesa_swap2((GLushort *) dest, width); + } + else if (ctx->Pack.SwapBytes) { + _mesa_swap2((GLushort *) dest, width); + } + + src += rowstride; + } + } +} + + +/** + * glGetTexImage for color formats (RGBA, RGB, alpha, LA, etc). + * Compressed textures are handled here as well. + */ +static void +get_tex_rgba(struct gl_context *ctx, GLuint dimensions, + GLenum format, GLenum type, GLvoid *pixels, + struct gl_texture_image *texImage) +{ + /* don't want to apply sRGB -> RGB conversion here so override the format */ + const gl_format texFormat = _mesa_get_srgb_format_linear(texImage->TexFormat); + const GLuint width = texImage->Width; + const GLuint height = texImage->Height; + const GLuint depth = texImage->Depth; + const GLenum dataType = _mesa_get_format_datatype(texFormat); + const GLenum baseFormat = _mesa_get_format_base_format(texFormat); + /* Normally, no pixel transfer ops are performed during glGetTexImage. + * The only possible exception is component clamping to [0,1]. + */ + GLbitfield transferOps = 0x0; + + /* In general, clamping does not apply to glGetTexImage, except when + * the returned type of the image can't hold negative values. + */ + if (!type_with_negative_values(type)) { + /* the returned image type can't have negative values */ + if (dataType == GL_FLOAT || + dataType == GL_SIGNED_NORMALIZED || + format == GL_LUMINANCE || + format == GL_LUMINANCE_ALPHA) { + transferOps |= IMAGE_CLAMP_BIT; + } + } + + if (_mesa_is_format_compressed(texFormat)) { + /* Decompress into temp buffer, then pack into user buffer */ + GLfloat *tempImage, *srcRow; + GLuint row; + + tempImage = (GLfloat *) malloc(texImage->Width * texImage->Height * + texImage->Depth * 4 * sizeof(GLfloat)); + if (!tempImage) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGetTexImage()"); + return; + } + + _mesa_decompress_image(texFormat, texImage->Width, texImage->Height, + texImage->Data, texImage->RowStride, tempImage); + + if (baseFormat == GL_LUMINANCE || + baseFormat == GL_LUMINANCE_ALPHA) { + /* Set green and blue to zero since the pack function here will + * compute L=R+G+B. + */ + GLuint i; + for (i = 0; i < width * height; i++) { + tempImage[i * 4 + GCOMP] = tempImage[i * 4 + BCOMP] = 0.0f; + } + } + + srcRow = tempImage; + for (row = 0; row < height; row++) { + void *dest = _mesa_image_address(dimensions, &ctx->Pack, pixels, + width, height, format, type, + 0, row, 0); + + _mesa_pack_rgba_span_float(ctx, width, (GLfloat (*)[4]) srcRow, + format, type, dest, &ctx->Pack, transferOps); + srcRow += width * 4; + } + + free(tempImage); + } + else { + /* No decompression needed */ + const GLint texelSize = _mesa_get_format_bytes(texFormat); + GLuint img, row; + GLfloat (*rgba)[4]; + + rgba = (GLfloat (*)[4]) malloc(4 * width * sizeof(GLfloat)); + if (!rgba) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGetTexImage()"); + return; + } + + for (img = 0; img < depth; img++) { + for (row = 0; row < height; row++) { + void *dest = _mesa_image_address(dimensions, &ctx->Pack, pixels, + width, height, format, type, + img, row, 0); + const GLubyte *src = (const GLubyte *) texImage->Data + + (texImage->ImageOffsets[img] + + texImage->RowStride * row) * texelSize; + + _mesa_unpack_rgba_row(texFormat, width, src, rgba); + + if (texImage->_BaseFormat == GL_ALPHA) { + GLint col; + for (col = 0; col < width; col++) { + rgba[col][RCOMP] = 0.0F; + rgba[col][GCOMP] = 0.0F; + rgba[col][BCOMP] = 0.0F; + } + } + else if (texImage->_BaseFormat == GL_LUMINANCE) { + GLint col; + for (col = 0; col < width; col++) { + rgba[col][GCOMP] = 0.0F; + rgba[col][BCOMP] = 0.0F; + rgba[col][ACOMP] = 1.0F; + } + } + else if (texImage->_BaseFormat == GL_LUMINANCE_ALPHA) { + GLint col; + for (col = 0; col < width; col++) { + rgba[col][GCOMP] = 0.0F; + rgba[col][BCOMP] = 0.0F; + } + } + else if (texImage->_BaseFormat == GL_INTENSITY) { + GLint col; + for (col = 0; col < width; col++) { + rgba[col][GCOMP] = 0.0F; + rgba[col][BCOMP] = 0.0F; + rgba[col][ACOMP] = 1.0F; + } + } + + _mesa_pack_rgba_span_float(ctx, width, (GLfloat (*)[4]) rgba, + format, type, dest, + &ctx->Pack, transferOps); + } + } + + free(rgba); + } +} + + +/** + * Try to do glGetTexImage() with simple memcpy(). + * \return GL_TRUE if done, GL_FALSE otherwise + */ +static GLboolean +get_tex_memcpy(struct gl_context *ctx, GLenum format, GLenum type, GLvoid *pixels, + const struct gl_texture_object *texObj, + const struct gl_texture_image *texImage) +{ + GLboolean memCopy = GL_FALSE; + + /* Texture image should have been mapped already */ + assert(texImage->Data); + + /* + * Check if the src/dst formats are compatible. + * Also note that GL's pixel transfer ops don't apply to glGetTexImage() + * so we don't have to worry about those. + * XXX more format combinations could be supported here. + */ + if ((texObj->Target == GL_TEXTURE_1D || + texObj->Target == GL_TEXTURE_2D || + texObj->Target == GL_TEXTURE_RECTANGLE || + (texObj->Target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X && + texObj->Target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z))) { + if ((texImage->TexFormat == MESA_FORMAT_ARGB8888 || + texImage->TexFormat == MESA_FORMAT_SARGB8) && + format == GL_BGRA && + (type == GL_UNSIGNED_BYTE || type == GL_UNSIGNED_INT_8_8_8_8_REV) && + !ctx->Pack.SwapBytes && + _mesa_little_endian()) { + memCopy = GL_TRUE; + } + else if ((texImage->TexFormat == MESA_FORMAT_AL88 || + texImage->TexFormat == MESA_FORMAT_SLA8) && + format == GL_LUMINANCE_ALPHA && + type == GL_UNSIGNED_BYTE && + !ctx->Pack.SwapBytes && + _mesa_little_endian()) { + memCopy = GL_TRUE; + } + else if ((texImage->TexFormat == MESA_FORMAT_L8 || + texImage->TexFormat == MESA_FORMAT_SL8) && + format == GL_LUMINANCE && + type == GL_UNSIGNED_BYTE) { + memCopy = GL_TRUE; + } + else if (texImage->TexFormat == MESA_FORMAT_L16 && + format == GL_LUMINANCE && + type == GL_UNSIGNED_SHORT) { + memCopy = GL_TRUE; + } + else if (texImage->TexFormat == MESA_FORMAT_A8 && + format == GL_ALPHA && + type == GL_UNSIGNED_BYTE) { + memCopy = GL_TRUE; + } + else if (texImage->TexFormat == MESA_FORMAT_A16 && + format == GL_ALPHA && + type == GL_UNSIGNED_SHORT) { + memCopy = GL_TRUE; + } + } + + if (memCopy) { + const GLuint bpp = _mesa_get_format_bytes(texImage->TexFormat); + const GLuint bytesPerRow = texImage->Width * bpp; + GLubyte *dst = + _mesa_image_address2d(&ctx->Pack, pixels, texImage->Width, + texImage->Height, format, type, 0, 0); + const GLint dstRowStride = + _mesa_image_row_stride(&ctx->Pack, texImage->Width, format, type); + const GLubyte *src = texImage->Data; + const GLint srcRowStride = texImage->RowStride * bpp; + GLuint row; + + if (bytesPerRow == dstRowStride && bytesPerRow == srcRowStride) { + memcpy(dst, src, bytesPerRow * texImage->Height); + } + else { + for (row = 0; row < texImage->Height; row++) { + memcpy(dst, src, bytesPerRow); + dst += dstRowStride; + src += srcRowStride; + } + } + } + + return memCopy; +} + + +/** + * This is the software fallback for Driver.GetTexImage(). + * All error checking will have been done before this routine is called. + * The texture image must be mapped. + */ +void +_mesa_get_teximage(struct gl_context *ctx, GLenum target, GLint level, + GLenum format, GLenum type, GLvoid *pixels, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage) +{ + GLuint dimensions; + + /* If we get here, the texture image should be mapped */ + assert(texImage->Data); + + switch (target) { + case GL_TEXTURE_1D: + dimensions = 1; + break; + case GL_TEXTURE_3D: + dimensions = 3; + break; + default: + dimensions = 2; + } + + if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { + /* Packing texture image into a PBO. + * Map the (potentially) VRAM-based buffer into our process space so + * we can write into it with the code below. + * A hardware driver might use a sophisticated blit to move the + * texture data to the PBO if the PBO is in VRAM along with the texture. + */ + GLubyte *buf = (GLubyte *) + ctx->Driver.MapBufferRange(ctx, 0, ctx->Pack.BufferObj->Size, + GL_MAP_WRITE_BIT, ctx->Pack.BufferObj); + if (!buf) { + /* out of memory or other unexpected error */ + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGetTexImage(map PBO failed)"); + return; + } + /* was an offset into the PBO. + * Now make it a real, client-side pointer inside the mapped region. + */ + pixels = ADD_POINTERS(buf, pixels); + } + + if (get_tex_memcpy(ctx, format, type, pixels, texObj, texImage)) { + /* all done */ + } + else if (format == GL_DEPTH_COMPONENT) { + get_tex_depth(ctx, dimensions, format, type, pixels, texImage); + } + else if (format == GL_DEPTH_STENCIL_EXT) { + get_tex_depth_stencil(ctx, dimensions, format, type, pixels, texImage); + } + else if (format == GL_YCBCR_MESA) { + get_tex_ycbcr(ctx, dimensions, format, type, pixels, texImage); + } + else { + get_tex_rgba(ctx, dimensions, format, type, pixels, texImage); + } + + if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { + ctx->Driver.UnmapBuffer(ctx, ctx->Pack.BufferObj); + } +} + + + +/** + * This is the software fallback for Driver.GetCompressedTexImage(). + * All error checking will have been done before this routine is called. + */ +void +_mesa_get_compressed_teximage(struct gl_context *ctx, GLenum target, GLint level, + GLvoid *img, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage) +{ + const GLuint row_stride = _mesa_format_row_stride(texImage->TexFormat, + texImage->Width); + const GLuint row_stride_stored = _mesa_format_row_stride(texImage->TexFormat, + texImage->RowStride); + GLuint i; + + if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { + /* pack texture image into a PBO */ + GLubyte *buf = (GLubyte *) + ctx->Driver.MapBufferRange(ctx, 0, ctx->Pack.BufferObj->Size, + GL_MAP_WRITE_BIT, ctx->Pack.BufferObj); + if (!buf) { + /* out of memory or other unexpected error */ + _mesa_error(ctx, GL_OUT_OF_MEMORY, + "glGetCompresssedTexImage(map PBO failed)"); + return; + } + img = ADD_POINTERS(buf, img); + } + + /* no pixelstore or pixel transfer, but respect stride */ + + if (row_stride == row_stride_stored) { + const GLuint size = _mesa_format_image_size(texImage->TexFormat, + texImage->Width, + texImage->Height, + texImage->Depth); + memcpy(img, texImage->Data, size); + } + else { + GLuint bw, bh; + _mesa_get_format_block_size(texImage->TexFormat, &bw, &bh); + for (i = 0; i < (texImage->Height + bh - 1) / bh; i++) { + memcpy((GLubyte *)img + i * row_stride, + (GLubyte *)texImage->Data + i * row_stride_stored, + row_stride); + } + } + + if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { + ctx->Driver.UnmapBuffer(ctx, ctx->Pack.BufferObj); + } +} + + + +/** + * Do error checking for a glGetTexImage() call. + * \return GL_TRUE if any error, GL_FALSE if no errors. + */ +static GLboolean +getteximage_error_check(struct gl_context *ctx, GLenum target, GLint level, + GLenum format, GLenum type, GLsizei clientMemSize, + GLvoid *pixels ) +{ + struct gl_texture_object *texObj; + struct gl_texture_image *texImage; + const GLint maxLevels = _mesa_max_texture_levels(ctx, target); + const GLuint dimensions = (target == GL_TEXTURE_3D) ? 3 : 2; + GLenum baseFormat; + + if (maxLevels == 0) { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexImage(target=0x%x)", target); + return GL_TRUE; + } + + if (level < 0 || level >= maxLevels) { + _mesa_error( ctx, GL_INVALID_VALUE, "glGetTexImage(level)" ); + return GL_TRUE; + } + + if (_mesa_sizeof_packed_type(type) <= 0) { + _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexImage(type)" ); + return GL_TRUE; + } + + if (_mesa_components_in_format(format) <= 0 || + format == GL_STENCIL_INDEX || + format == GL_COLOR_INDEX) { + _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexImage(format)" ); + return GL_TRUE; + } + + if (!ctx->Extensions.ARB_depth_texture && _mesa_is_depth_format(format)) { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexImage(format)"); + return GL_TRUE; + } + + if (!ctx->Extensions.MESA_ycbcr_texture && _mesa_is_ycbcr_format(format)) { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexImage(format)"); + return GL_TRUE; + } + + if (!ctx->Extensions.EXT_packed_depth_stencil + && _mesa_is_depthstencil_format(format)) { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexImage(format)"); + return GL_TRUE; + } + + if (!ctx->Extensions.ATI_envmap_bumpmap + && _mesa_is_dudv_format(format)) { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexImage(format)"); + return GL_TRUE; + } + + texObj = _mesa_get_current_tex_object(ctx, target); + + if (!texObj || _mesa_is_proxy_texture(target)) { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexImage(target)"); + return GL_TRUE; + } + + texImage = _mesa_select_tex_image(ctx, texObj, target, level); + if (!texImage) { + /* out of memory */ + return GL_TRUE; + } + + baseFormat = _mesa_get_format_base_format(texImage->TexFormat); + + /* Make sure the requested image format is compatible with the + * texture's format. + */ + if (_mesa_is_color_format(format) + && !_mesa_is_color_format(baseFormat)) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexImage(format mismatch)"); + return GL_TRUE; + } + else if (_mesa_is_depth_format(format) + && !_mesa_is_depth_format(baseFormat) + && !_mesa_is_depthstencil_format(baseFormat)) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexImage(format mismatch)"); + return GL_TRUE; + } + else if (_mesa_is_ycbcr_format(format) + && !_mesa_is_ycbcr_format(baseFormat)) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexImage(format mismatch)"); + return GL_TRUE; + } + else if (_mesa_is_depthstencil_format(format) + && !_mesa_is_depthstencil_format(baseFormat)) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexImage(format mismatch)"); + return GL_TRUE; + } + else if (_mesa_is_dudv_format(format) + && !_mesa_is_dudv_format(baseFormat)) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexImage(format mismatch)"); + return GL_TRUE; + } + + if (!_mesa_validate_pbo_access(dimensions, &ctx->Pack, texImage->Width, + texImage->Height, texImage->Depth, + format, type, clientMemSize, pixels)) { + if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glGetTexImage(out of bounds PBO access)"); + } else { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glGetnTexImageARB(out of bounds access:" + " bufSize (%d) is too small)", clientMemSize); + } + return GL_TRUE; + } + + if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { + /* PBO should not be mapped */ + if (_mesa_bufferobj_mapped(ctx->Pack.BufferObj)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glGetTexImage(PBO is mapped)"); + return GL_TRUE; + } + } + + return GL_FALSE; +} + + + +/** + * Get texture image. Called by glGetTexImage. + * + * \param target texture target. + * \param level image level. + * \param format pixel data format for returned image. + * \param type pixel data type for returned image. + * \param bufSize size of the pixels data buffer. + * \param pixels returned pixel data. + */ +void GLAPIENTRY +_mesa_GetnTexImageARB( GLenum target, GLint level, GLenum format, + GLenum type, GLsizei bufSize, GLvoid *pixels ) +{ + struct gl_texture_object *texObj; + struct gl_texture_image *texImage; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + if (getteximage_error_check(ctx, target, level, format, type, + bufSize, pixels)) { + return; + } + + if (!_mesa_is_bufferobj(ctx->Pack.BufferObj) && !pixels) { + /* not an error, do nothing */ + return; + } + + texObj = _mesa_get_current_tex_object(ctx, target); + texImage = _mesa_select_tex_image(ctx, texObj, target, level); + + if (MESA_VERBOSE & (VERBOSE_API | VERBOSE_TEXTURE)) { + _mesa_debug(ctx, "glGetTexImage(tex %u) format = %s, w=%d, h=%d," + " dstFmt=0x%x, dstType=0x%x\n", + texObj->Name, + _mesa_get_format_name(texImage->TexFormat), + texImage->Width, texImage->Height, + format, type); + } + + _mesa_lock_texture(ctx, texObj); + { + ctx->Driver.GetTexImage(ctx, target, level, format, type, pixels, + texObj, texImage); + } + _mesa_unlock_texture(ctx, texObj); +} + + +void GLAPIENTRY +_mesa_GetTexImage( GLenum target, GLint level, GLenum format, + GLenum type, GLvoid *pixels ) +{ + _mesa_GetnTexImageARB(target, level, format, type, INT_MAX, pixels); +} + + +/** + * Do error checking for a glGetCompressedTexImage() call. + * \return GL_TRUE if any error, GL_FALSE if no errors. + */ +static GLboolean +getcompressedteximage_error_check(struct gl_context *ctx, GLenum target, + GLint level, GLsizei clientMemSize, GLvoid *img) +{ + struct gl_texture_object *texObj; + struct gl_texture_image *texImage; + const GLint maxLevels = _mesa_max_texture_levels(ctx, target); + GLuint compressedSize; + + if (maxLevels == 0) { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetCompressedTexImage(target=0x%x)", + target); + return GL_TRUE; + } + + if (level < 0 || level >= maxLevels) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glGetCompressedTexImageARB(bad level = %d)", level); + return GL_TRUE; + } + + if (_mesa_is_proxy_texture(target)) { + _mesa_error(ctx, GL_INVALID_ENUM, + "glGetCompressedTexImageARB(bad target = %s)", + _mesa_lookup_enum_by_nr(target)); + return GL_TRUE; + } + + texObj = _mesa_get_current_tex_object(ctx, target); + if (!texObj) { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetCompressedTexImageARB(target)"); + return GL_TRUE; + } + + texImage = _mesa_select_tex_image(ctx, texObj, target, level); + + if (!texImage) { + /* probably invalid mipmap level */ + _mesa_error(ctx, GL_INVALID_VALUE, + "glGetCompressedTexImageARB(level)"); + return GL_TRUE; + } + + if (!_mesa_is_format_compressed(texImage->TexFormat)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glGetCompressedTexImageARB(texture is not compressed)"); + return GL_TRUE; + } + + compressedSize = _mesa_format_image_size(texImage->TexFormat, + texImage->Width, + texImage->Height, + texImage->Depth); + + if (!_mesa_is_bufferobj(ctx->Pack.BufferObj)) { + /* do bounds checking on writing to client memory */ + if (clientMemSize < compressedSize) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glGetnCompressedTexImageARB(out of bounds access:" + " bufSize (%d) is too small)", clientMemSize); + } + } else { + /* do bounds checking on PBO write */ + if ((const GLubyte *) img + compressedSize > + (const GLubyte *) ctx->Pack.BufferObj->Size) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glGetCompressedTexImage(out of bounds PBO access)"); + return GL_TRUE; + } + + /* make sure PBO is not mapped */ + if (_mesa_bufferobj_mapped(ctx->Pack.BufferObj)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glGetCompressedTexImage(PBO is mapped)"); + return GL_TRUE; + } + } + + return GL_FALSE; +} + + +void GLAPIENTRY +_mesa_GetnCompressedTexImageARB(GLenum target, GLint level, GLsizei bufSize, + GLvoid *img) +{ + struct gl_texture_object *texObj; + struct gl_texture_image *texImage; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + if (getcompressedteximage_error_check(ctx, target, level, bufSize, img)) { + return; + } + + if (_mesa_is_bufferobj(ctx->Pack.BufferObj) && !img) { + /* not an error, do nothing */ + return; + } + + texObj = _mesa_get_current_tex_object(ctx, target); + texImage = _mesa_select_tex_image(ctx, texObj, target, level); + + if (MESA_VERBOSE & (VERBOSE_API | VERBOSE_TEXTURE)) { + _mesa_debug(ctx, + "glGetCompressedTexImage(tex %u) format = %s, w=%d, h=%d\n", + texObj->Name, + _mesa_get_format_name(texImage->TexFormat), + texImage->Width, texImage->Height); + } + + _mesa_lock_texture(ctx, texObj); + { + ctx->Driver.GetCompressedTexImage(ctx, target, level, img, + texObj, texImage); + } + _mesa_unlock_texture(ctx, texObj); +} + +void GLAPIENTRY +_mesa_GetCompressedTexImageARB(GLenum target, GLint level, GLvoid *img) +{ + _mesa_GetnCompressedTexImageARB(target, level, INT_MAX, img); +} diff --git a/mesalib/src/mesa/main/texgetimage.h b/mesalib/src/mesa/main/texgetimage.h index a017a29c0..8612705ca 100644 --- a/mesalib/src/mesa/main/texgetimage.h +++ b/mesalib/src/mesa/main/texgetimage.h @@ -1,65 +1,65 @@ -/* - * Mesa 3-D graphics library - * Version: 7.5 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (c) 2009 VMware, 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 - * 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. - */ - - -#ifndef TEXGETIMAGE_H -#define TEXGETIMAGE_H - -#include "glheader.h" - -struct gl_context; -struct gl_texture_image; -struct gl_texture_object; - -extern void -_mesa_get_teximage(struct gl_context *ctx, GLenum target, GLint level, - GLenum format, GLenum type, GLvoid *pixels, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage); - - -extern void -_mesa_get_compressed_teximage(struct gl_context *ctx, GLenum target, GLint level, - GLvoid *img, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage); - - - -extern void GLAPIENTRY -_mesa_GetTexImage( GLenum target, GLint level, - GLenum format, GLenum type, GLvoid *pixels ); -extern void GLAPIENTRY -_mesa_GetnTexImageARB( GLenum target, GLint level, GLenum format, - GLenum type, GLsizei bufSize, GLvoid *pixels ); - -extern void GLAPIENTRY -_mesa_GetCompressedTexImageARB(GLenum target, GLint lod, GLvoid *img); - -extern void GLAPIENTRY -_mesa_GetnCompressedTexImageARB(GLenum target, GLint level, GLsizei bufSize, - GLvoid *img); - -#endif /* TEXGETIMAGE_H */ +/* + * Mesa 3-D graphics library + * Version: 7.5 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (c) 2009 VMware, 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 + * 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. + */ + + +#ifndef TEXGETIMAGE_H +#define TEXGETIMAGE_H + +#include "glheader.h" + +struct gl_context; +struct gl_texture_image; +struct gl_texture_object; + +extern void +_mesa_get_teximage(struct gl_context *ctx, GLenum target, GLint level, + GLenum format, GLenum type, GLvoid *pixels, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage); + + +extern void +_mesa_get_compressed_teximage(struct gl_context *ctx, GLenum target, GLint level, + GLvoid *img, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage); + + + +extern void GLAPIENTRY +_mesa_GetTexImage( GLenum target, GLint level, + GLenum format, GLenum type, GLvoid *pixels ); +extern void GLAPIENTRY +_mesa_GetnTexImageARB( GLenum target, GLint level, GLenum format, + GLenum type, GLsizei bufSize, GLvoid *pixels ); + +extern void GLAPIENTRY +_mesa_GetCompressedTexImageARB(GLenum target, GLint lod, GLvoid *img); + +extern void GLAPIENTRY +_mesa_GetnCompressedTexImageARB(GLenum target, GLint level, GLsizei bufSize, + GLvoid *img); + +#endif /* TEXGETIMAGE_H */ diff --git a/mesalib/src/mesa/main/teximage.c b/mesalib/src/mesa/main/teximage.c index 21bea6587..cb4a5b4e4 100644 --- a/mesalib/src/mesa/main/teximage.c +++ b/mesalib/src/mesa/main/teximage.c @@ -1,3819 +1,3819 @@ -/* - * Mesa 3-D graphics library - * - * Copyright (C) 1999-2008 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. - */ - - -/** - * \file teximage.c - * Texture image-related functions. - */ - - -#include "glheader.h" -#include "bufferobj.h" -#include "context.h" -#include "enums.h" -#include "fbobject.h" -#include "framebuffer.h" -#include "hash.h" -#include "image.h" -#include "imports.h" -#include "macros.h" -#include "mfeatures.h" -#include "state.h" -#include "texcompress.h" -#include "texfetch.h" -#include "teximage.h" -#include "texstate.h" -#include "texpal.h" -#include "mtypes.h" - - -/** - * State changes which we care about for glCopyTex[Sub]Image() calls. - * In particular, we care about pixel transfer state and buffer state - * (such as glReadBuffer to make sure we read from the right renderbuffer). - */ -#define NEW_COPY_TEX_STATE (_NEW_BUFFERS | _NEW_PIXEL) - - - -/** - * We allocate texture memory on 512-byte boundaries so we can use MMX/SSE - * elsewhere. - */ -void * -_mesa_alloc_texmemory(GLsizei bytes) -{ - return _mesa_align_malloc(bytes, 512); -} - - -/** - * Free texture memory allocated with _mesa_alloc_texmemory() - */ -void -_mesa_free_texmemory(void *m) -{ - _mesa_align_free(m); -} - - -/** - * Return the simple base format for a given internal texture format. - * For example, given GL_LUMINANCE12_ALPHA4, return GL_LUMINANCE_ALPHA. - * - * \param ctx GL context. - * \param internalFormat the internal texture format token or 1, 2, 3, or 4. - * - * \return the corresponding \u base internal format (GL_ALPHA, GL_LUMINANCE, - * GL_LUMANCE_ALPHA, GL_INTENSITY, GL_RGB, or GL_RGBA), or -1 if invalid enum. - * - * This is the format which is used during texture application (i.e. the - * texture format and env mode determine the arithmetic used. - * - * XXX this could be static - */ -GLint -_mesa_base_tex_format( struct gl_context *ctx, GLint internalFormat ) -{ - switch (internalFormat) { - case GL_ALPHA: - case GL_ALPHA4: - case GL_ALPHA8: - case GL_ALPHA12: - case GL_ALPHA16: - return GL_ALPHA; - case 1: - case GL_LUMINANCE: - case GL_LUMINANCE4: - case GL_LUMINANCE8: - case GL_LUMINANCE12: - case GL_LUMINANCE16: - return GL_LUMINANCE; - case 2: - case GL_LUMINANCE_ALPHA: - case GL_LUMINANCE4_ALPHA4: - case GL_LUMINANCE6_ALPHA2: - case GL_LUMINANCE8_ALPHA8: - case GL_LUMINANCE12_ALPHA4: - case GL_LUMINANCE12_ALPHA12: - case GL_LUMINANCE16_ALPHA16: - return GL_LUMINANCE_ALPHA; - case GL_INTENSITY: - case GL_INTENSITY4: - case GL_INTENSITY8: - case GL_INTENSITY12: - case GL_INTENSITY16: - return GL_INTENSITY; - case 3: - case GL_RGB: - case GL_R3_G3_B2: - case GL_RGB4: - case GL_RGB5: - case GL_RGB8: - case GL_RGB10: - case GL_RGB12: - case GL_RGB16: - return GL_RGB; - case 4: - case GL_RGBA: - case GL_RGBA2: - case GL_RGBA4: - case GL_RGB5_A1: - case GL_RGBA8: - case GL_RGB10_A2: - case GL_RGBA12: - case GL_RGBA16: - return GL_RGBA; - default: - ; /* fallthrough */ - } - - if (ctx->Extensions.EXT_texture_format_BGRA8888) { - switch (internalFormat) { - case GL_BGRA_EXT: - return GL_RGBA; - default: - ; /* fallthrough */ - } - } - - if (ctx->Extensions.ARB_depth_texture) { - switch (internalFormat) { - case GL_DEPTH_COMPONENT: - case GL_DEPTH_COMPONENT16: - case GL_DEPTH_COMPONENT24: - case GL_DEPTH_COMPONENT32: - return GL_DEPTH_COMPONENT; - default: - ; /* fallthrough */ - } - } - - switch (internalFormat) { - case GL_COMPRESSED_ALPHA: - return GL_ALPHA; - case GL_COMPRESSED_LUMINANCE: - return GL_LUMINANCE; - case GL_COMPRESSED_LUMINANCE_ALPHA: - return GL_LUMINANCE_ALPHA; - case GL_COMPRESSED_INTENSITY: - return GL_INTENSITY; - case GL_COMPRESSED_RGB: - return GL_RGB; - case GL_COMPRESSED_RGBA: - return GL_RGBA; - default: - ; /* fallthrough */ - } - - if (ctx->Extensions.TDFX_texture_compression_FXT1) { - switch (internalFormat) { - case GL_COMPRESSED_RGB_FXT1_3DFX: - return GL_RGB; - case GL_COMPRESSED_RGBA_FXT1_3DFX: - return GL_RGBA; - default: - ; /* fallthrough */ - } - } - - if (ctx->Extensions.EXT_texture_compression_s3tc) { - switch (internalFormat) { - case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: - return GL_RGB; - case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: - case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: - case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: - return GL_RGBA; - default: - ; /* fallthrough */ - } - } - - if (ctx->Extensions.S3_s3tc) { - switch (internalFormat) { - case GL_RGB_S3TC: - case GL_RGB4_S3TC: - return GL_RGB; - case GL_RGBA_S3TC: - case GL_RGBA4_S3TC: - return GL_RGBA; - default: - ; /* fallthrough */ - } - } - - if (ctx->Extensions.MESA_ycbcr_texture) { - if (internalFormat == GL_YCBCR_MESA) - return GL_YCBCR_MESA; - } - - if (ctx->Extensions.ARB_texture_float) { - switch (internalFormat) { - case GL_ALPHA16F_ARB: - case GL_ALPHA32F_ARB: - return GL_ALPHA; - case GL_RGBA16F_ARB: - case GL_RGBA32F_ARB: - return GL_RGBA; - case GL_RGB16F_ARB: - case GL_RGB32F_ARB: - return GL_RGB; - case GL_INTENSITY16F_ARB: - case GL_INTENSITY32F_ARB: - return GL_INTENSITY; - case GL_LUMINANCE16F_ARB: - case GL_LUMINANCE32F_ARB: - return GL_LUMINANCE; - case GL_LUMINANCE_ALPHA16F_ARB: - case GL_LUMINANCE_ALPHA32F_ARB: - return GL_LUMINANCE_ALPHA; - default: - ; /* fallthrough */ - } - } - - if (ctx->Extensions.ATI_envmap_bumpmap) { - switch (internalFormat) { - case GL_DUDV_ATI: - case GL_DU8DV8_ATI: - return GL_DUDV_ATI; - default: - ; /* fallthrough */ - } - } - - if (ctx->Extensions.EXT_texture_snorm) { - switch (internalFormat) { - case GL_RED_SNORM: - case GL_R8_SNORM: - case GL_R16_SNORM: - return GL_RED; - case GL_RG_SNORM: - case GL_RG8_SNORM: - case GL_RG16_SNORM: - return GL_RG; - case GL_RGB_SNORM: - case GL_RGB8_SNORM: - case GL_RGB16_SNORM: - return GL_RGB; - case GL_RGBA_SNORM: - case GL_RGBA8_SNORM: - case GL_RGBA16_SNORM: - return GL_RGBA; - case GL_ALPHA_SNORM: - case GL_ALPHA8_SNORM: - case GL_ALPHA16_SNORM: - return GL_ALPHA; - case GL_LUMINANCE_SNORM: - case GL_LUMINANCE8_SNORM: - case GL_LUMINANCE16_SNORM: - return GL_LUMINANCE; - case GL_LUMINANCE_ALPHA_SNORM: - case GL_LUMINANCE8_ALPHA8_SNORM: - case GL_LUMINANCE16_ALPHA16_SNORM: - return GL_LUMINANCE_ALPHA; - case GL_INTENSITY_SNORM: - case GL_INTENSITY8_SNORM: - case GL_INTENSITY16_SNORM: - return GL_INTENSITY; - default: - ; /* fallthrough */ - } - } - - if (ctx->Extensions.EXT_packed_depth_stencil) { - switch (internalFormat) { - case GL_DEPTH_STENCIL_EXT: - case GL_DEPTH24_STENCIL8_EXT: - return GL_DEPTH_STENCIL_EXT; - default: - ; /* fallthrough */ - } - } - -#if FEATURE_EXT_texture_sRGB - if (ctx->Extensions.EXT_texture_sRGB) { - switch (internalFormat) { - case GL_SRGB_EXT: - case GL_SRGB8_EXT: - case GL_COMPRESSED_SRGB_EXT: - case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT: - return GL_RGB; - case GL_SRGB_ALPHA_EXT: - case GL_SRGB8_ALPHA8_EXT: - case GL_COMPRESSED_SRGB_ALPHA_EXT: - case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: - case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: - case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: - return GL_RGBA; - case GL_SLUMINANCE_ALPHA_EXT: - case GL_SLUMINANCE8_ALPHA8_EXT: - case GL_COMPRESSED_SLUMINANCE_ALPHA_EXT: - return GL_LUMINANCE_ALPHA; - case GL_SLUMINANCE_EXT: - case GL_SLUMINANCE8_EXT: - case GL_COMPRESSED_SLUMINANCE_EXT: - return GL_LUMINANCE; - default: - ; /* fallthrough */ - } - } -#endif /* FEATURE_EXT_texture_sRGB */ - - if (ctx->Extensions.EXT_texture_integer) { - switch (internalFormat) { - case GL_RGBA8UI_EXT: - case GL_RGBA16UI_EXT: - case GL_RGBA32UI_EXT: - case GL_RGBA8I_EXT: - case GL_RGBA16I_EXT: - case GL_RGBA32I_EXT: - return GL_RGBA; - case GL_RGB8UI_EXT: - case GL_RGB16UI_EXT: - case GL_RGB32UI_EXT: - case GL_RGB8I_EXT: - case GL_RGB16I_EXT: - case GL_RGB32I_EXT: - return GL_RGB; - case GL_ALPHA8UI_EXT: - case GL_ALPHA16UI_EXT: - case GL_ALPHA32UI_EXT: - case GL_ALPHA8I_EXT: - case GL_ALPHA16I_EXT: - case GL_ALPHA32I_EXT: - return GL_ALPHA; - case GL_INTENSITY8UI_EXT: - case GL_INTENSITY16UI_EXT: - case GL_INTENSITY32UI_EXT: - case GL_INTENSITY8I_EXT: - case GL_INTENSITY16I_EXT: - case GL_INTENSITY32I_EXT: - return GL_INTENSITY; - case GL_LUMINANCE8UI_EXT: - case GL_LUMINANCE16UI_EXT: - case GL_LUMINANCE32UI_EXT: - case GL_LUMINANCE8I_EXT: - case GL_LUMINANCE16I_EXT: - case GL_LUMINANCE32I_EXT: - return GL_LUMINANCE; - case GL_LUMINANCE_ALPHA8UI_EXT: - case GL_LUMINANCE_ALPHA16UI_EXT: - case GL_LUMINANCE_ALPHA32UI_EXT: - case GL_LUMINANCE_ALPHA8I_EXT: - case GL_LUMINANCE_ALPHA16I_EXT: - case GL_LUMINANCE_ALPHA32I_EXT: - return GL_LUMINANCE_ALPHA; - default: - ; /* fallthrough */ - } - } - - if (ctx->Extensions.ARB_texture_rg) { - switch (internalFormat) { - case GL_R16F: - /* R16F depends on both ARB_half_float_pixel and ARB_texture_float. - */ - if (!ctx->Extensions.ARB_half_float_pixel) - break; - /* FALLTHROUGH */ - case GL_R32F: - if (!ctx->Extensions.ARB_texture_float) - break; - return GL_RED; - case GL_R8I: - case GL_R8UI: - case GL_R16I: - case GL_R16UI: - case GL_R32I: - case GL_R32UI: - if (!ctx->Extensions.EXT_texture_integer) - break; - /* FALLTHROUGH */ - case GL_R8: - case GL_R16: - case GL_RED: - case GL_COMPRESSED_RED: - return GL_RED; - - case GL_RG16F: - /* RG16F depends on both ARB_half_float_pixel and ARB_texture_float. - */ - if (!ctx->Extensions.ARB_half_float_pixel) - break; - /* FALLTHROUGH */ - case GL_RG32F: - if (!ctx->Extensions.ARB_texture_float) - break; - return GL_RG; - case GL_RG8I: - case GL_RG8UI: - case GL_RG16I: - case GL_RG16UI: - case GL_RG32I: - case GL_RG32UI: - if (!ctx->Extensions.EXT_texture_integer) - break; - /* FALLTHROUGH */ - case GL_RG: - case GL_RG8: - case GL_RG16: - case GL_COMPRESSED_RG: - return GL_RG; - default: - ; /* fallthrough */ - } - } - - if (ctx->Extensions.EXT_texture_shared_exponent) { - switch (internalFormat) { - case GL_RGB9_E5_EXT: - return GL_RGB; - default: - ; /* fallthrough */ - } - } - - if (ctx->Extensions.EXT_packed_float) { - switch (internalFormat) { - case GL_R11F_G11F_B10F_EXT: - return GL_RGB; - default: - ; /* fallthrough */ - } - } - - if (ctx->Extensions.ARB_depth_buffer_float) { - switch (internalFormat) { - case GL_DEPTH_COMPONENT32F: - return GL_DEPTH_COMPONENT; - case GL_DEPTH32F_STENCIL8: - return GL_DEPTH_STENCIL; - default: - ; /* fallthrough */ - } - } - - if (ctx->Extensions.ARB_texture_compression_rgtc) { - switch (internalFormat) { - case GL_COMPRESSED_RED_RGTC1: - case GL_COMPRESSED_SIGNED_RED_RGTC1: - return GL_RED; - case GL_COMPRESSED_RG_RGTC2: - case GL_COMPRESSED_SIGNED_RG_RGTC2: - return GL_RG; - default: - ; /* fallthrough */ - } - } - - if (ctx->Extensions.EXT_texture_compression_latc) { - switch (internalFormat) { - case GL_COMPRESSED_LUMINANCE_LATC1_EXT: - case GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT: - return GL_LUMINANCE; - case GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT: - case GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT: - return GL_LUMINANCE_ALPHA; - default: - ; /* fallthrough */ - } - } - - if (ctx->Extensions.ATI_texture_compression_3dc) { - switch (internalFormat) { - case GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI: - return GL_LUMINANCE_ALPHA; - default: - ; /* fallthrough */ - } - } - - return -1; /* error */ -} - - -/** - * For cube map faces, return a face index in [0,5]. - * For other targets return 0; - */ -GLuint -_mesa_tex_target_to_face(GLenum target) -{ - if (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB && - target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB) - return (GLuint) target - (GLuint) GL_TEXTURE_CUBE_MAP_POSITIVE_X; - else - return 0; -} - - - -/** - * Store a gl_texture_image pointer in a gl_texture_object structure - * according to the target and level parameters. - * - * \param tObj texture object. - * \param target texture target. - * \param level image level. - * \param texImage texture image. - */ -void -_mesa_set_tex_image(struct gl_texture_object *tObj, - GLenum target, GLint level, - struct gl_texture_image *texImage) -{ - const GLuint face = _mesa_tex_target_to_face(target); - - ASSERT(tObj); - ASSERT(texImage); - ASSERT(target != GL_TEXTURE_RECTANGLE_NV || level == 0); - - tObj->Image[face][level] = texImage; - - /* Set the 'back' pointer */ - texImage->TexObject = tObj; - texImage->Level = level; - texImage->Face = face; -} - - -/** - * Allocate a texture image structure. - * - * Called via ctx->Driver.NewTextureImage() unless overriden by a device - * driver. - * - * \return a pointer to gl_texture_image struct with all fields initialized to - * zero. - */ -struct gl_texture_image * -_mesa_new_texture_image( struct gl_context *ctx ) -{ - (void) ctx; - return CALLOC_STRUCT(gl_texture_image); -} - - -/** - * Free texture image data. - * This function is a fallback called via ctx->Driver.FreeTextureImageBuffer(). - * - * \param texImage texture image. - * - * Free the texture image data if it's not marked as client data. - */ -void -_mesa_free_texture_image_data(struct gl_context *ctx, - struct gl_texture_image *texImage) -{ - (void) ctx; - - if (texImage->Data && !texImage->IsClientData) { - /* free the old texture data */ - _mesa_free_texmemory(texImage->Data); - } - - texImage->Data = NULL; -} - - -/** - * Free texture image. - * - * \param texImage texture image. - * - * Free the texture image structure and the associated image data. - */ -void -_mesa_delete_texture_image(struct gl_context *ctx, - struct gl_texture_image *texImage) -{ - /* Free texImage->Data and/or any other driver-specific texture - * image storage. - */ - ASSERT(ctx->Driver.FreeTextureImageBuffer); - ctx->Driver.FreeTextureImageBuffer( ctx, texImage ); - - ASSERT(texImage->Data == NULL); - if (texImage->ImageOffsets) - free(texImage->ImageOffsets); - free(texImage); -} - - -/** - * Test if a target is a proxy target. - * - * \param target texture target. - * - * \return GL_TRUE if the target is a proxy target, GL_FALSE otherwise. - */ -GLboolean -_mesa_is_proxy_texture(GLenum target) -{ - /* NUM_TEXTURE_TARGETS should match number of terms below, - * except there's no proxy for GL_TEXTURE_BUFFER. - */ - assert(NUM_TEXTURE_TARGETS == 8); - - return (target == GL_PROXY_TEXTURE_1D || - target == GL_PROXY_TEXTURE_2D || - target == GL_PROXY_TEXTURE_3D || - target == GL_PROXY_TEXTURE_CUBE_MAP_ARB || - target == GL_PROXY_TEXTURE_RECTANGLE_NV || - target == GL_PROXY_TEXTURE_1D_ARRAY_EXT || - target == GL_PROXY_TEXTURE_2D_ARRAY_EXT); -} - - -/** - * Return the proxy target which corresponds to the given texture target - */ -static GLenum -get_proxy_target(GLenum target) -{ - switch (target) { - case GL_TEXTURE_1D: - case GL_PROXY_TEXTURE_1D: - return GL_PROXY_TEXTURE_1D; - case GL_TEXTURE_2D: - case GL_PROXY_TEXTURE_2D: - return GL_PROXY_TEXTURE_2D; - case GL_TEXTURE_3D: - case GL_PROXY_TEXTURE_3D: - return GL_PROXY_TEXTURE_3D; - case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB: - case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB: - case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB: - case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB: - case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB: - case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB: - case GL_TEXTURE_CUBE_MAP_ARB: - case GL_PROXY_TEXTURE_CUBE_MAP_ARB: - return GL_PROXY_TEXTURE_CUBE_MAP_ARB; - case GL_TEXTURE_RECTANGLE_NV: - case GL_PROXY_TEXTURE_RECTANGLE_NV: - return GL_PROXY_TEXTURE_RECTANGLE_NV; - case GL_TEXTURE_1D_ARRAY_EXT: - case GL_PROXY_TEXTURE_1D_ARRAY_EXT: - return GL_PROXY_TEXTURE_1D_ARRAY_EXT; - case GL_TEXTURE_2D_ARRAY_EXT: - case GL_PROXY_TEXTURE_2D_ARRAY_EXT: - return GL_PROXY_TEXTURE_2D_ARRAY_EXT; - default: - _mesa_problem(NULL, "unexpected target in get_proxy_target()"); - return 0; - } -} - - -/** - * Get the texture object that corresponds to the target of the given - * texture unit. The target should have already been checked for validity. - * - * \param ctx GL context. - * \param texUnit texture unit. - * \param target texture target. - * - * \return pointer to the texture object on success, or NULL on failure. - */ -struct gl_texture_object * -_mesa_select_tex_object(struct gl_context *ctx, - const struct gl_texture_unit *texUnit, - GLenum target) -{ - const GLboolean arrayTex = (ctx->Extensions.MESA_texture_array || - ctx->Extensions.EXT_texture_array); - - switch (target) { - case GL_TEXTURE_1D: - return texUnit->CurrentTex[TEXTURE_1D_INDEX]; - case GL_PROXY_TEXTURE_1D: - return ctx->Texture.ProxyTex[TEXTURE_1D_INDEX]; - case GL_TEXTURE_2D: - return texUnit->CurrentTex[TEXTURE_2D_INDEX]; - case GL_PROXY_TEXTURE_2D: - return ctx->Texture.ProxyTex[TEXTURE_2D_INDEX]; - case GL_TEXTURE_3D: - return texUnit->CurrentTex[TEXTURE_3D_INDEX]; - case GL_PROXY_TEXTURE_3D: - return ctx->Texture.ProxyTex[TEXTURE_3D_INDEX]; - case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB: - case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB: - case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB: - case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB: - case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB: - case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB: - case GL_TEXTURE_CUBE_MAP_ARB: - return ctx->Extensions.ARB_texture_cube_map - ? texUnit->CurrentTex[TEXTURE_CUBE_INDEX] : NULL; - case GL_PROXY_TEXTURE_CUBE_MAP_ARB: - return ctx->Extensions.ARB_texture_cube_map - ? ctx->Texture.ProxyTex[TEXTURE_CUBE_INDEX] : NULL; - case GL_TEXTURE_RECTANGLE_NV: - return ctx->Extensions.NV_texture_rectangle - ? texUnit->CurrentTex[TEXTURE_RECT_INDEX] : NULL; - case GL_PROXY_TEXTURE_RECTANGLE_NV: - return ctx->Extensions.NV_texture_rectangle - ? ctx->Texture.ProxyTex[TEXTURE_RECT_INDEX] : NULL; - case GL_TEXTURE_1D_ARRAY_EXT: - return arrayTex ? texUnit->CurrentTex[TEXTURE_1D_ARRAY_INDEX] : NULL; - case GL_PROXY_TEXTURE_1D_ARRAY_EXT: - return arrayTex ? ctx->Texture.ProxyTex[TEXTURE_1D_ARRAY_INDEX] : NULL; - case GL_TEXTURE_2D_ARRAY_EXT: - return arrayTex ? texUnit->CurrentTex[TEXTURE_2D_ARRAY_INDEX] : NULL; - case GL_PROXY_TEXTURE_2D_ARRAY_EXT: - return arrayTex ? ctx->Texture.ProxyTex[TEXTURE_2D_ARRAY_INDEX] : NULL; - case GL_TEXTURE_BUFFER: - return ctx->Extensions.ARB_texture_buffer_object - ? texUnit->CurrentTex[TEXTURE_BUFFER_INDEX] : NULL; - default: - _mesa_problem(NULL, "bad target in _mesa_select_tex_object()"); - return NULL; - } -} - - -/** - * Return pointer to texture object for given target on current texture unit. - */ -struct gl_texture_object * -_mesa_get_current_tex_object(struct gl_context *ctx, GLenum target) -{ - struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx); - return _mesa_select_tex_object(ctx, texUnit, target); -} - - -/** - * Get a texture image pointer from a texture object, given a texture - * target and mipmap level. The target and level parameters should - * have already been error-checked. - * - * \param ctx GL context. - * \param texObj texture unit. - * \param target texture target. - * \param level image level. - * - * \return pointer to the texture image structure, or NULL on failure. - */ -struct gl_texture_image * -_mesa_select_tex_image(struct gl_context *ctx, - const struct gl_texture_object *texObj, - GLenum target, GLint level) -{ - const GLuint face = _mesa_tex_target_to_face(target); - - ASSERT(texObj); - ASSERT(level >= 0); - ASSERT(level < MAX_TEXTURE_LEVELS); - - return texObj->Image[face][level]; -} - - -/** - * Like _mesa_select_tex_image() but if the image doesn't exist, allocate - * it and install it. Only return NULL if passed a bad parameter or run - * out of memory. - */ -struct gl_texture_image * -_mesa_get_tex_image(struct gl_context *ctx, struct gl_texture_object *texObj, - GLenum target, GLint level) -{ - struct gl_texture_image *texImage; - - if (!texObj) - return NULL; - - texImage = _mesa_select_tex_image(ctx, texObj, target, level); - if (!texImage) { - texImage = ctx->Driver.NewTextureImage(ctx); - if (!texImage) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "texture image allocation"); - return NULL; - } - - _mesa_set_tex_image(texObj, target, level, texImage); - } - - return texImage; -} - - -/** - * Return pointer to the specified proxy texture image. - * Note that proxy textures are per-context, not per-texture unit. - * \return pointer to texture image or NULL if invalid target, invalid - * level, or out of memory. - */ -struct gl_texture_image * -_mesa_get_proxy_tex_image(struct gl_context *ctx, GLenum target, GLint level) -{ - struct gl_texture_image *texImage; - GLuint texIndex; - - if (level < 0 ) - return NULL; - - switch (target) { - case GL_PROXY_TEXTURE_1D: - if (level >= ctx->Const.MaxTextureLevels) - return NULL; - texIndex = TEXTURE_1D_INDEX; - break; - case GL_PROXY_TEXTURE_2D: - if (level >= ctx->Const.MaxTextureLevels) - return NULL; - texIndex = TEXTURE_2D_INDEX; - break; - case GL_PROXY_TEXTURE_3D: - if (level >= ctx->Const.Max3DTextureLevels) - return NULL; - texIndex = TEXTURE_3D_INDEX; - break; - case GL_PROXY_TEXTURE_CUBE_MAP: - if (level >= ctx->Const.MaxCubeTextureLevels) - return NULL; - texIndex = TEXTURE_CUBE_INDEX; - break; - case GL_PROXY_TEXTURE_RECTANGLE_NV: - if (level > 0) - return NULL; - texIndex = TEXTURE_RECT_INDEX; - break; - case GL_PROXY_TEXTURE_1D_ARRAY_EXT: - if (level >= ctx->Const.MaxTextureLevels) - return NULL; - texIndex = TEXTURE_1D_ARRAY_INDEX; - break; - case GL_PROXY_TEXTURE_2D_ARRAY_EXT: - if (level >= ctx->Const.MaxTextureLevels) - return NULL; - texIndex = TEXTURE_2D_ARRAY_INDEX; - break; - default: - return NULL; - } - - texImage = ctx->Texture.ProxyTex[texIndex]->Image[0][level]; - if (!texImage) { - texImage = ctx->Driver.NewTextureImage(ctx); - if (!texImage) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "proxy texture allocation"); - return NULL; - } - ctx->Texture.ProxyTex[texIndex]->Image[0][level] = texImage; - /* Set the 'back' pointer */ - texImage->TexObject = ctx->Texture.ProxyTex[texIndex]; - } - return texImage; -} - - -/** - * Get the maximum number of allowed mipmap levels. - * - * \param ctx GL context. - * \param target texture target. - * - * \return the maximum number of allowed mipmap levels for the given - * texture target, or zero if passed a bad target. - * - * \sa gl_constants. - */ -GLint -_mesa_max_texture_levels(struct gl_context *ctx, GLenum target) -{ - switch (target) { - case GL_TEXTURE_1D: - case GL_PROXY_TEXTURE_1D: - case GL_TEXTURE_2D: - case GL_PROXY_TEXTURE_2D: - return ctx->Const.MaxTextureLevels; - case GL_TEXTURE_3D: - case GL_PROXY_TEXTURE_3D: - return ctx->Const.Max3DTextureLevels; - case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB: - case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB: - case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB: - case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB: - case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB: - case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB: - case GL_TEXTURE_CUBE_MAP_ARB: - case GL_PROXY_TEXTURE_CUBE_MAP_ARB: - return ctx->Extensions.ARB_texture_cube_map - ? ctx->Const.MaxCubeTextureLevels : 0; - case GL_TEXTURE_RECTANGLE_NV: - case GL_PROXY_TEXTURE_RECTANGLE_NV: - return ctx->Extensions.NV_texture_rectangle ? 1 : 0; - case GL_TEXTURE_1D_ARRAY_EXT: - case GL_PROXY_TEXTURE_1D_ARRAY_EXT: - case GL_TEXTURE_2D_ARRAY_EXT: - case GL_PROXY_TEXTURE_2D_ARRAY_EXT: - return (ctx->Extensions.MESA_texture_array || - ctx->Extensions.EXT_texture_array) - ? ctx->Const.MaxTextureLevels : 0; - case GL_TEXTURE_BUFFER: - /* fall-through */ - default: - return 0; /* bad target */ - } -} - - -/** - * Return number of dimensions per mipmap level for the given texture target. - */ -GLint -_mesa_get_texture_dimensions(GLenum target) -{ - switch (target) { - case GL_TEXTURE_1D: - case GL_PROXY_TEXTURE_1D: - return 1; - case GL_TEXTURE_2D: - case GL_TEXTURE_RECTANGLE: - case GL_TEXTURE_CUBE_MAP: - case GL_PROXY_TEXTURE_2D: - case GL_PROXY_TEXTURE_RECTANGLE: - case GL_PROXY_TEXTURE_CUBE_MAP: - case GL_TEXTURE_CUBE_MAP_POSITIVE_X: - case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: - case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: - case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: - case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: - case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: - case GL_TEXTURE_1D_ARRAY: - case GL_PROXY_TEXTURE_1D_ARRAY: - return 2; - case GL_TEXTURE_3D: - case GL_PROXY_TEXTURE_3D: - case GL_TEXTURE_2D_ARRAY: - case GL_PROXY_TEXTURE_2D_ARRAY: - return 3; - case GL_TEXTURE_BUFFER: - /* fall-through */ - default: - _mesa_problem(NULL, "invalid target 0x%x in get_texture_dimensions()", - target); - return 2; - } -} - - - - -#if 000 /* not used anymore */ -/* - * glTexImage[123]D can accept a NULL image pointer. In this case we - * create a texture image with unspecified image contents per the OpenGL - * spec. - */ -static GLubyte * -make_null_texture(GLint width, GLint height, GLint depth, GLenum format) -{ - const GLint components = _mesa_components_in_format(format); - const GLint numPixels = width * height * depth; - GLubyte *data = (GLubyte *) MALLOC(numPixels * components * sizeof(GLubyte)); - -#ifdef DEBUG - /* - * Let's see if anyone finds this. If glTexImage2D() is called with - * a NULL image pointer then load the texture image with something - * interesting instead of leaving it indeterminate. - */ - if (data) { - static const char message[8][32] = { - " X X XXXXX XXX X ", - " XX XX X X X X X ", - " X X X X X X X ", - " X X XXXX XXX XXXXX ", - " X X X X X X ", - " X X X X X X X ", - " X X XXXXX XXX X X ", - " " - }; - - GLubyte *imgPtr = data; - GLint h, i, j, k; - for (h = 0; h < depth; h++) { - for (i = 0; i < height; i++) { - GLint srcRow = 7 - (i % 8); - for (j = 0; j < width; j++) { - GLint srcCol = j % 32; - GLubyte texel = (message[srcRow][srcCol]=='X') ? 255 : 70; - for (k = 0; k < components; k++) { - *imgPtr++ = texel; - } - } - } - } - } -#endif - - return data; -} -#endif - - - -/** - * Reset the fields of a gl_texture_image struct to zero. - * - * \param img texture image structure. - * - * This is called when a proxy texture test fails, we set all the - * image members (except DriverData) to zero. - * It's also used in glTexImage[123]D as a safeguard to be sure all - * required fields get initialized properly by the Driver.TexImage[123]D - * functions. - */ -static void -clear_teximage_fields(struct gl_texture_image *img) -{ - ASSERT(img); - img->_BaseFormat = 0; - img->InternalFormat = 0; - img->Border = 0; - img->Width = 0; - img->Height = 0; - img->Depth = 0; - img->RowStride = 0; - if (img->ImageOffsets) { - free(img->ImageOffsets); - img->ImageOffsets = NULL; - } - img->Width2 = 0; - img->Height2 = 0; - img->Depth2 = 0; - img->WidthLog2 = 0; - img->HeightLog2 = 0; - img->DepthLog2 = 0; - img->Data = NULL; - img->TexFormat = MESA_FORMAT_NONE; - img->FetchTexelc = NULL; - img->FetchTexelf = NULL; -} - - -/** - * Initialize basic fields of the gl_texture_image struct. - * - * \param ctx GL context. - * \param target texture target (GL_TEXTURE_1D, GL_TEXTURE_RECTANGLE, etc). - * \param img texture image structure to be initialized. - * \param width image width. - * \param height image height. - * \param depth image depth. - * \param border image border. - * \param internalFormat internal format. - * \param format the actual hardware format (one of MESA_FORMAT_*) - * - * Fills in the fields of \p img with the given information. - * Note: width, height and depth include the border. - */ -void -_mesa_init_teximage_fields(struct gl_context *ctx, GLenum target, - struct gl_texture_image *img, - GLsizei width, GLsizei height, GLsizei depth, - GLint border, GLenum internalFormat, - gl_format format) -{ - GLint i, dims; - - ASSERT(img); - ASSERT(width >= 0); - ASSERT(height >= 0); - ASSERT(depth >= 0); - - img->_BaseFormat = _mesa_base_tex_format( ctx, internalFormat ); - ASSERT(img->_BaseFormat > 0); - img->InternalFormat = internalFormat; - img->Border = border; - img->Width = width; - img->Height = height; - img->Depth = depth; - - img->Width2 = width - 2 * border; /* == 1 << img->WidthLog2; */ - img->WidthLog2 = _mesa_logbase2(img->Width2); - - if (height == 1) { /* 1-D texture */ - img->Height2 = 1; - img->HeightLog2 = 0; - } - else { - img->Height2 = height - 2 * border; /* == 1 << img->HeightLog2; */ - img->HeightLog2 = _mesa_logbase2(img->Height2); - } - - if (depth == 1) { /* 2-D texture */ - img->Depth2 = 1; - img->DepthLog2 = 0; - } - else { - img->Depth2 = depth - 2 * border; /* == 1 << img->DepthLog2; */ - img->DepthLog2 = _mesa_logbase2(img->Depth2); - } - - img->MaxLog2 = MAX2(img->WidthLog2, img->HeightLog2); - - if ((width == 1 || _mesa_is_pow_two(img->Width2)) && - (height == 1 || _mesa_is_pow_two(img->Height2)) && - (depth == 1 || _mesa_is_pow_two(img->Depth2))) - img->_IsPowerOfTwo = GL_TRUE; - else - img->_IsPowerOfTwo = GL_FALSE; - - /* RowStride and ImageOffsets[] describe how to address texels in 'Data' */ - img->RowStride = width; - /* Allocate the ImageOffsets array and initialize to typical values. - * We allocate the array for 1D/2D textures too in order to avoid special- - * case code in the texstore routines. - */ - if (img->ImageOffsets) - free(img->ImageOffsets); - img->ImageOffsets = (GLuint *) malloc(depth * sizeof(GLuint)); - for (i = 0; i < depth; i++) { - img->ImageOffsets[i] = i * width * height; - } - - /* Compute Width/Height/DepthScale for mipmap lod computation */ - if (target == GL_TEXTURE_RECTANGLE_NV) { - /* scale = 1.0 since texture coords directly map to texels */ - img->WidthScale = 1.0; - img->HeightScale = 1.0; - img->DepthScale = 1.0; - } - else { - img->WidthScale = (GLfloat) img->Width; - img->HeightScale = (GLfloat) img->Height; - img->DepthScale = (GLfloat) img->Depth; - } - - img->TexFormat = format; - - dims = _mesa_get_texture_dimensions(target); - - _mesa_set_fetch_functions(img, dims); -} - - -/** - * Free and clear fields of the gl_texture_image struct. - * - * \param ctx GL context. - * \param texImage texture image structure to be cleared. - * - * After the call, \p texImage will have no data associated with it. Its - * fields are cleared so that its parent object will test incomplete. - */ -void -_mesa_clear_texture_image(struct gl_context *ctx, - struct gl_texture_image *texImage) -{ - ctx->Driver.FreeTextureImageBuffer(ctx, texImage); - clear_teximage_fields(texImage); -} - - -/** - * This is the fallback for Driver.TestProxyTexImage(). Test the texture - * level, width, height and depth against the ctx->Const limits for textures. - * - * A hardware driver might override this function if, for example, the - * max 3D texture size is 512x512x64 (i.e. not a cube). - * - * Note that width, height, depth == 0 is not an error. However, a - * texture with zero width/height/depth will be considered "incomplete" - * and texturing will effectively be disabled. - * - * \param target one of GL_PROXY_TEXTURE_1D, GL_PROXY_TEXTURE_2D, - * GL_PROXY_TEXTURE_3D, GL_PROXY_TEXTURE_RECTANGLE_NV, - * GL_PROXY_TEXTURE_CUBE_MAP_ARB. - * \param level as passed to glTexImage - * \param internalFormat as passed to glTexImage - * \param format as passed to glTexImage - * \param type as passed to glTexImage - * \param width as passed to glTexImage - * \param height as passed to glTexImage - * \param depth as passed to glTexImage - * \param border as passed to glTexImage - * \return GL_TRUE if the image is acceptable, GL_FALSE if not acceptable. - */ -GLboolean -_mesa_test_proxy_teximage(struct gl_context *ctx, GLenum target, GLint level, - GLint internalFormat, GLenum format, GLenum type, - GLint width, GLint height, GLint depth, GLint border) -{ - GLint maxSize; - - (void) internalFormat; - (void) format; - (void) type; - - switch (target) { - case GL_PROXY_TEXTURE_1D: - maxSize = 1 << (ctx->Const.MaxTextureLevels - 1); - if (width < 2 * border || width > 2 + maxSize) - return GL_FALSE; - if (level >= ctx->Const.MaxTextureLevels) - return GL_FALSE; - if (!ctx->Extensions.ARB_texture_non_power_of_two) { - if (width > 0 && !_mesa_is_pow_two(width - 2 * border)) - return GL_FALSE; - } - return GL_TRUE; - - case GL_PROXY_TEXTURE_2D: - maxSize = 1 << (ctx->Const.MaxTextureLevels - 1); - if (width < 2 * border || width > 2 + maxSize) - return GL_FALSE; - if (height < 2 * border || height > 2 + maxSize) - return GL_FALSE; - if (level >= ctx->Const.MaxTextureLevels) - return GL_FALSE; - if (!ctx->Extensions.ARB_texture_non_power_of_two) { - if (width > 0 && !_mesa_is_pow_two(width - 2 * border)) - return GL_FALSE; - if (height > 0 && !_mesa_is_pow_two(height - 2 * border)) - return GL_FALSE; - } - return GL_TRUE; - - case GL_PROXY_TEXTURE_3D: - maxSize = 1 << (ctx->Const.Max3DTextureLevels - 1); - if (width < 2 * border || width > 2 + maxSize) - return GL_FALSE; - if (height < 2 * border || height > 2 + maxSize) - return GL_FALSE; - if (depth < 2 * border || depth > 2 + maxSize) - return GL_FALSE; - if (level >= ctx->Const.Max3DTextureLevels) - return GL_FALSE; - if (!ctx->Extensions.ARB_texture_non_power_of_two) { - if (width > 0 && !_mesa_is_pow_two(width - 2 * border)) - return GL_FALSE; - if (height > 0 && !_mesa_is_pow_two(height - 2 * border)) - return GL_FALSE; - if (depth > 0 && !_mesa_is_pow_two(depth - 2 * border)) - return GL_FALSE; - } - return GL_TRUE; - - case GL_PROXY_TEXTURE_RECTANGLE_NV: - maxSize = ctx->Const.MaxTextureRectSize; - if (width < 0 || width > maxSize) - return GL_FALSE; - if (height < 0 || height > maxSize) - return GL_FALSE; - if (level != 0) - return GL_FALSE; - return GL_TRUE; - - case GL_PROXY_TEXTURE_CUBE_MAP_ARB: - maxSize = 1 << (ctx->Const.MaxCubeTextureLevels - 1); - if (width < 2 * border || width > 2 + maxSize) - return GL_FALSE; - if (height < 2 * border || height > 2 + maxSize) - return GL_FALSE; - if (level >= ctx->Const.MaxCubeTextureLevels) - return GL_FALSE; - if (!ctx->Extensions.ARB_texture_non_power_of_two) { - if (width > 0 && !_mesa_is_pow_two(width - 2 * border)) - return GL_FALSE; - if (height > 0 && !_mesa_is_pow_two(height - 2 * border)) - return GL_FALSE; - } - return GL_TRUE; - - case GL_PROXY_TEXTURE_1D_ARRAY_EXT: - maxSize = 1 << (ctx->Const.MaxTextureLevels - 1); - if (width < 2 * border || width > 2 + maxSize) - return GL_FALSE; - if (height < 1 || height > ctx->Const.MaxArrayTextureLayers) - return GL_FALSE; - if (level >= ctx->Const.MaxTextureLevels) - return GL_FALSE; - if (!ctx->Extensions.ARB_texture_non_power_of_two) { - if (width > 0 && !_mesa_is_pow_two(width - 2 * border)) - return GL_FALSE; - } - return GL_TRUE; - - case GL_PROXY_TEXTURE_2D_ARRAY_EXT: - maxSize = 1 << (ctx->Const.MaxTextureLevels - 1); - if (width < 2 * border || width > 2 + maxSize) - return GL_FALSE; - if (height < 2 * border || height > 2 + maxSize) - return GL_FALSE; - if (depth < 1 || depth > ctx->Const.MaxArrayTextureLayers) - return GL_FALSE; - if (level >= ctx->Const.MaxTextureLevels) - return GL_FALSE; - if (!ctx->Extensions.ARB_texture_non_power_of_two) { - if (width > 0 && !_mesa_is_pow_two(width - 2 * border)) - return GL_FALSE; - if (height > 0 && !_mesa_is_pow_two(height - 2 * border)) - return GL_FALSE; - } - return GL_TRUE; - - default: - _mesa_problem(ctx, "Invalid target in _mesa_test_proxy_teximage"); - return GL_FALSE; - } -} - - -/** - * Check if the memory used by the texture would exceed the driver's limit. - * This lets us support a max 3D texture size of 8K (for example) but - * prevents allocating a full 8K x 8K x 8K texture. - * XXX this could be rolled into the proxy texture size test (above) but - * we don't have the actual texture internal format at that point. - */ -static GLboolean -legal_texture_size(struct gl_context *ctx, gl_format format, - GLint width, GLint height, GLint depth) -{ - uint64_t bytes = _mesa_format_image_size64(format, width, height, depth); - uint64_t mbytes = bytes / (1024 * 1024); /* convert to MB */ - return mbytes <= (uint64_t) ctx->Const.MaxTextureMbytes; -} - - - -/** - * Helper function to determine whether a target and specific compression - * format are supported. - */ -static GLboolean -target_can_be_compressed(const struct gl_context *ctx, GLenum target, - GLenum intFormat) -{ - (void) intFormat; /* not used yet */ - - switch (target) { - case GL_TEXTURE_2D: - case GL_PROXY_TEXTURE_2D: - return GL_TRUE; /* true for any compressed format so far */ - case GL_PROXY_TEXTURE_CUBE_MAP: - case GL_TEXTURE_CUBE_MAP_POSITIVE_X: - case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: - case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: - case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: - case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: - case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: - return ctx->Extensions.ARB_texture_cube_map; - case GL_PROXY_TEXTURE_2D_ARRAY_EXT: - case GL_TEXTURE_2D_ARRAY_EXT: - return (ctx->Extensions.MESA_texture_array || - ctx->Extensions.EXT_texture_array); - default: - return GL_FALSE; - } -} - - -/** - * Check if the given texture target value is legal for a - * glTexImage1/2/3D call. - */ -static GLboolean -legal_teximage_target(struct gl_context *ctx, GLuint dims, GLenum target) -{ - switch (dims) { - case 1: - switch (target) { - case GL_TEXTURE_1D: - case GL_PROXY_TEXTURE_1D: - return GL_TRUE; - default: - return GL_FALSE; - } - case 2: - switch (target) { - case GL_TEXTURE_2D: - case GL_PROXY_TEXTURE_2D: - return GL_TRUE; - case GL_PROXY_TEXTURE_CUBE_MAP: - case GL_TEXTURE_CUBE_MAP_POSITIVE_X: - case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: - case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: - case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: - case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: - case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: - return ctx->Extensions.ARB_texture_cube_map; - case GL_TEXTURE_RECTANGLE_NV: - case GL_PROXY_TEXTURE_RECTANGLE_NV: - return ctx->Extensions.NV_texture_rectangle; - case GL_TEXTURE_1D_ARRAY_EXT: - case GL_PROXY_TEXTURE_1D_ARRAY_EXT: - return (ctx->Extensions.MESA_texture_array || - ctx->Extensions.EXT_texture_array); - default: - return GL_FALSE; - } - case 3: - switch (target) { - case GL_TEXTURE_3D: - case GL_PROXY_TEXTURE_3D: - return GL_TRUE; - case GL_TEXTURE_2D_ARRAY_EXT: - case GL_PROXY_TEXTURE_2D_ARRAY_EXT: - return (ctx->Extensions.MESA_texture_array || - ctx->Extensions.EXT_texture_array); - default: - return GL_FALSE; - } - default: - _mesa_problem(ctx, "invalid dims=%u in legal_teximage_target()", dims); - return GL_FALSE; - } -} - - -/** - * Check if the given texture target value is legal for a - * glTexSubImage, glCopyTexSubImage or glCopyTexImage call. - * The difference compared to legal_teximage_target() above is that - * proxy targets are not supported. - */ -static GLboolean -legal_texsubimage_target(struct gl_context *ctx, GLuint dims, GLenum target) -{ - switch (dims) { - case 1: - return target == GL_TEXTURE_1D; - case 2: - switch (target) { - case GL_TEXTURE_2D: - return GL_TRUE; - case GL_TEXTURE_CUBE_MAP_POSITIVE_X: - case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: - case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: - case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: - case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: - case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: - return ctx->Extensions.ARB_texture_cube_map; - case GL_TEXTURE_RECTANGLE_NV: - return ctx->Extensions.NV_texture_rectangle; - case GL_TEXTURE_1D_ARRAY_EXT: - return (ctx->Extensions.MESA_texture_array || - ctx->Extensions.EXT_texture_array); - default: - return GL_FALSE; - } - case 3: - switch (target) { - case GL_TEXTURE_3D: - return GL_TRUE; - case GL_TEXTURE_2D_ARRAY_EXT: - return (ctx->Extensions.MESA_texture_array || - ctx->Extensions.EXT_texture_array); - default: - return GL_FALSE; - } - default: - _mesa_problem(ctx, "invalid dims=%u in legal_texsubimage_target()", - dims); - return GL_FALSE; - } -} - - -/** - * Test the glTexImage[123]D() parameters for errors. - * - * \param ctx GL context. - * \param dimensions texture image dimensions (must be 1, 2 or 3). - * \param target texture target given by the user. - * \param level image level given by the user. - * \param internalFormat internal format given by the user. - * \param format pixel data format given by the user. - * \param type pixel data type given by the user. - * \param width image width given by the user. - * \param height image height given by the user. - * \param depth image depth given by the user. - * \param border image border given by the user. - * - * \return GL_TRUE if an error was detected, or GL_FALSE if no errors. - * - * Verifies each of the parameters against the constants specified in - * __struct gl_contextRec::Const and the supported extensions, and according - * to the OpenGL specification. - */ -static GLboolean -texture_error_check( struct gl_context *ctx, - GLuint dimensions, GLenum target, - GLint level, GLint internalFormat, - GLenum format, GLenum type, - GLint width, GLint height, - GLint depth, GLint border ) -{ - const GLenum proxyTarget = get_proxy_target(target); - const GLboolean isProxy = target == proxyTarget; - GLboolean sizeOK = GL_TRUE; - GLboolean colorFormat; - - /* Even though there are no color-index textures, we still have to support - * uploading color-index data and remapping it to RGB via the - * GL_PIXEL_MAP_I_TO_[RGBA] tables. - */ - const GLboolean indexFormat = (format == GL_COLOR_INDEX); - - /* Basic level check (more checking in ctx->Driver.TestProxyTexImage) */ - if (level < 0 || level >= MAX_TEXTURE_LEVELS) { - if (!isProxy) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glTexImage%dD(level=%d)", dimensions, level); - } - return GL_TRUE; - } - - /* Check border */ - if (border < 0 || border > 1 || - ((target == GL_TEXTURE_RECTANGLE_NV || - target == GL_PROXY_TEXTURE_RECTANGLE_NV) && border != 0)) { - if (!isProxy) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glTexImage%dD(border=%d)", dimensions, border); - } - return GL_TRUE; - } - - if (width < 0 || height < 0 || depth < 0) { - if (!isProxy) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glTexImage%dD(width, height or depth < 0)", dimensions); - } - return GL_TRUE; - } - - /* Do this simple check before calling the TestProxyTexImage() function */ - if (proxyTarget == GL_PROXY_TEXTURE_CUBE_MAP_ARB) { - sizeOK = (width == height); - } - - /* - * Use the proxy texture driver hook to see if the size/level/etc are - * legal. - */ - sizeOK = sizeOK && ctx->Driver.TestProxyTexImage(ctx, proxyTarget, level, - internalFormat, format, - type, width, height, - depth, border); - if (!sizeOK) { - if (!isProxy) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glTexImage%dD(level=%d, width=%d, height=%d, depth=%d)", - dimensions, level, width, height, depth); - } - return GL_TRUE; - } - - /* Check internalFormat */ - if (_mesa_base_tex_format(ctx, internalFormat) < 0) { - if (!isProxy) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glTexImage%dD(internalFormat=%s)", - dimensions, _mesa_lookup_enum_by_nr(internalFormat)); - } - return GL_TRUE; - } - - /* Check incoming image format and type */ - if (!_mesa_is_legal_format_and_type(ctx, format, type)) { - /* Normally, GL_INVALID_OPERATION is generated by a format/type - * mismatch (see the 1.2 spec page 94, sec 3.6.4.). But with the - * GL_EXT_texture_integer extension, some combinations should generate - * GL_INVALID_ENUM instead (grr!). - */ - if (!isProxy) { - GLenum error = _mesa_is_integer_format(format) - ? GL_INVALID_ENUM : GL_INVALID_OPERATION; - _mesa_error(ctx, error, - "glTexImage%dD(incompatible format 0x%x, type 0x%x)", - dimensions, format, type); - } - return GL_TRUE; - } - - /* make sure internal format and format basically agree */ - colorFormat = _mesa_is_color_format(format); - if ((_mesa_is_color_format(internalFormat) && !colorFormat && !indexFormat) || - (_mesa_is_depth_format(internalFormat) != _mesa_is_depth_format(format)) || - (_mesa_is_ycbcr_format(internalFormat) != _mesa_is_ycbcr_format(format)) || - (_mesa_is_depthstencil_format(internalFormat) != _mesa_is_depthstencil_format(format)) || - (_mesa_is_dudv_format(internalFormat) != _mesa_is_dudv_format(format))) { - if (!isProxy) - _mesa_error(ctx, GL_INVALID_OPERATION, - "glTexImage%dD(incompatible internalFormat 0x%x, format 0x%x)", - dimensions, internalFormat, format); - return GL_TRUE; - } - - /* additional checks for ycbcr textures */ - if (internalFormat == GL_YCBCR_MESA) { - ASSERT(ctx->Extensions.MESA_ycbcr_texture); - if (type != GL_UNSIGNED_SHORT_8_8_MESA && - type != GL_UNSIGNED_SHORT_8_8_REV_MESA) { - char message[100]; - _mesa_snprintf(message, sizeof(message), - "glTexImage%dD(format/type YCBCR mismatch", dimensions); - _mesa_error(ctx, GL_INVALID_ENUM, "%s", message); - return GL_TRUE; /* error */ - } - if (target != GL_TEXTURE_2D && - target != GL_PROXY_TEXTURE_2D && - target != GL_TEXTURE_RECTANGLE_NV && - target != GL_PROXY_TEXTURE_RECTANGLE_NV) { - if (!isProxy) - _mesa_error(ctx, GL_INVALID_ENUM, "glTexImage(target)"); - return GL_TRUE; - } - if (border != 0) { - if (!isProxy) { - char message[100]; - _mesa_snprintf(message, sizeof(message), - "glTexImage%dD(format=GL_YCBCR_MESA and border=%d)", - dimensions, border); - _mesa_error(ctx, GL_INVALID_VALUE, "%s", message); - } - return GL_TRUE; - } - } - - /* additional checks for depth textures */ - if (_mesa_base_tex_format(ctx, internalFormat) == GL_DEPTH_COMPONENT) { - /* Only 1D, 2D, rect and array textures supported, not 3D or cubes */ - if (target != GL_TEXTURE_1D && - target != GL_PROXY_TEXTURE_1D && - target != GL_TEXTURE_2D && - target != GL_PROXY_TEXTURE_2D && - target != GL_TEXTURE_1D_ARRAY && - target != GL_PROXY_TEXTURE_1D_ARRAY && - target != GL_TEXTURE_2D_ARRAY && - target != GL_PROXY_TEXTURE_2D_ARRAY && - target != GL_TEXTURE_RECTANGLE_ARB && - target != GL_PROXY_TEXTURE_RECTANGLE_ARB) { - if (!isProxy) - _mesa_error(ctx, GL_INVALID_ENUM, - "glTexImage(target/internalFormat)"); - return GL_TRUE; - } - } - - /* additional checks for compressed textures */ - if (_mesa_is_compressed_format(ctx, internalFormat)) { - if (!target_can_be_compressed(ctx, target, internalFormat)) { - if (!isProxy) - _mesa_error(ctx, GL_INVALID_ENUM, - "glTexImage%dD(target)", dimensions); - return GL_TRUE; - } - if (border != 0) { - if (!isProxy) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glTexImage%dD(border!=0)", dimensions); - } - return GL_TRUE; - } - } - - /* additional checks for integer textures */ - if (ctx->Extensions.EXT_texture_integer && - (_mesa_is_integer_format(format) != - _mesa_is_integer_format(internalFormat))) { - if (!isProxy) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glTexImage%dD(integer/non-integer format mismatch)", - dimensions); - } - return GL_TRUE; - } - - /* if we get here, the parameters are OK */ - return GL_FALSE; -} - - -/** - * Test glTexSubImage[123]D() parameters for errors. - * - * \param ctx GL context. - * \param dimensions texture image dimensions (must be 1, 2 or 3). - * \param target texture target given by the user. - * \param level image level given by the user. - * \param xoffset sub-image x offset given by the user. - * \param yoffset sub-image y offset given by the user. - * \param zoffset sub-image z offset given by the user. - * \param format pixel data format given by the user. - * \param type pixel data type given by the user. - * \param width image width given by the user. - * \param height image height given by the user. - * \param depth image depth given by the user. - * - * \return GL_TRUE if an error was detected, or GL_FALSE if no errors. - * - * Verifies each of the parameters against the constants specified in - * __struct gl_contextRec::Const and the supported extensions, and according - * to the OpenGL specification. - */ -static GLboolean -subtexture_error_check( struct gl_context *ctx, GLuint dimensions, - GLenum target, GLint level, - GLint xoffset, GLint yoffset, GLint zoffset, - GLint width, GLint height, GLint depth, - GLenum format, GLenum type ) -{ - /* Basic level check */ - if (level < 0 || level >= MAX_TEXTURE_LEVELS) { - _mesa_error(ctx, GL_INVALID_ENUM, "glTexSubImage2D(level=%d)", level); - return GL_TRUE; - } - - /* Check for negative sizes */ - if (width < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glTexSubImage%dD(width=%d)", dimensions, width); - return GL_TRUE; - } - if (height < 0 && dimensions > 1) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glTexSubImage%dD(height=%d)", dimensions, height); - return GL_TRUE; - } - if (depth < 0 && dimensions > 2) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glTexSubImage%dD(depth=%d)", dimensions, depth); - return GL_TRUE; - } - - if (!_mesa_is_legal_format_and_type(ctx, format, type)) { - /* As with the glTexImage2D check above, the error code here - * depends on texture integer. - */ - GLenum error = _mesa_is_integer_format(format) - ? GL_INVALID_OPERATION : GL_INVALID_ENUM; - _mesa_error(ctx, error, - "glTexSubImage%dD(incompatible format 0x%x, type 0x%x)", - dimensions, format, type); - return GL_TRUE; - } - - return GL_FALSE; -} - - -/** - * Do second part of glTexSubImage which depends on the destination texture. - * \return GL_TRUE if error recorded, GL_FALSE otherwise - */ -static GLboolean -subtexture_error_check2( struct gl_context *ctx, GLuint dimensions, - GLenum target, GLint level, - GLint xoffset, GLint yoffset, GLint zoffset, - GLint width, GLint height, GLint depth, - GLenum format, GLenum type, - const struct gl_texture_image *destTex ) -{ - if (!destTex) { - /* undefined image level */ - _mesa_error(ctx, GL_INVALID_OPERATION, "glTexSubImage%dD", dimensions); - return GL_TRUE; - } - - if (xoffset < -((GLint)destTex->Border)) { - _mesa_error(ctx, GL_INVALID_VALUE, "glTexSubImage%dD(xoffset)", - dimensions); - return GL_TRUE; - } - if (xoffset + width > (GLint) (destTex->Width + destTex->Border)) { - _mesa_error(ctx, GL_INVALID_VALUE, "glTexSubImage%dD(xoffset+width)", - dimensions); - return GL_TRUE; - } - if (dimensions > 1) { - if (yoffset < -((GLint)destTex->Border)) { - _mesa_error(ctx, GL_INVALID_VALUE, "glTexSubImage%dD(yoffset)", - dimensions); - return GL_TRUE; - } - if (yoffset + height > (GLint) (destTex->Height + destTex->Border)) { - _mesa_error(ctx, GL_INVALID_VALUE, "glTexSubImage%dD(yoffset+height)", - dimensions); - return GL_TRUE; - } - } - if (dimensions > 2) { - if (zoffset < -((GLint)destTex->Border)) { - _mesa_error(ctx, GL_INVALID_VALUE, "glTexSubImage3D(zoffset)"); - return GL_TRUE; - } - if (zoffset + depth > (GLint) (destTex->Depth + destTex->Border)) { - _mesa_error(ctx, GL_INVALID_VALUE, "glTexSubImage3D(zoffset+depth)"); - return GL_TRUE; - } - } - - if (_mesa_is_format_compressed(destTex->TexFormat)) { - GLuint bw, bh; - - /* do tests which depend on compression block size */ - _mesa_get_format_block_size(destTex->TexFormat, &bw, &bh); - - /* offset must be multiple of block size */ - if ((xoffset % bw != 0) || (yoffset % bh != 0)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glTexSubImage%dD(xoffset = %d, yoffset = %d)", - dimensions, xoffset, yoffset); - return GL_TRUE; - } - /* size must be multiple of bw by bh or equal to whole texture size */ - if ((width % bw != 0) && (GLuint) width != destTex->Width) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glTexSubImage%dD(width = %d)", dimensions, width); - return GL_TRUE; - } - if ((height % bh != 0) && (GLuint) height != destTex->Height) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glTexSubImage%dD(height = %d)", dimensions, height); - return GL_TRUE; - } - } - - return GL_FALSE; -} - - -/** - * Test glCopyTexImage[12]D() parameters for errors. - * - * \param ctx GL context. - * \param dimensions texture image dimensions (must be 1, 2 or 3). - * \param target texture target given by the user. - * \param level image level given by the user. - * \param internalFormat internal format given by the user. - * \param width image width given by the user. - * \param height image height given by the user. - * \param border texture border. - * - * \return GL_TRUE if an error was detected, or GL_FALSE if no errors. - * - * Verifies each of the parameters against the constants specified in - * __struct gl_contextRec::Const and the supported extensions, and according - * to the OpenGL specification. - */ -static GLboolean -copytexture_error_check( struct gl_context *ctx, GLuint dimensions, - GLenum target, GLint level, GLint internalFormat, - GLint width, GLint height, GLint border ) -{ - const GLenum proxyTarget = get_proxy_target(target); - const GLenum type = GL_FLOAT; - GLboolean sizeOK; - GLint format; - - /* check target */ - if (!legal_texsubimage_target(ctx, dimensions, target)) { - _mesa_error(ctx, GL_INVALID_ENUM, "glCopyTexImage%uD(target=%s)", - dimensions, _mesa_lookup_enum_by_nr(target)); - return GL_TRUE; - } - - /* Basic level check (more checking in ctx->Driver.TestProxyTexImage) */ - if (level < 0 || level >= MAX_TEXTURE_LEVELS) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glCopyTexImage%dD(level=%d)", dimensions, level); - return GL_TRUE; - } - - /* Check that the source buffer is complete */ - if (ctx->ReadBuffer->Name) { - if (ctx->ReadBuffer->_Status == 0) { - _mesa_test_framebuffer_completeness(ctx, ctx->ReadBuffer); - } - if (ctx->ReadBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) { - _mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION_EXT, - "glCopyTexImage%dD(invalid readbuffer)", dimensions); - return GL_TRUE; - } - } - - /* Check border */ - if (border < 0 || border > 1 || - ((target == GL_TEXTURE_RECTANGLE_NV || - target == GL_PROXY_TEXTURE_RECTANGLE_NV) && border != 0)) { - return GL_TRUE; - } - - format = _mesa_base_tex_format(ctx, internalFormat); - if (format < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glCopyTexImage%dD(internalFormat)", dimensions); - return GL_TRUE; - } - - if (!_mesa_source_buffer_exists(ctx, format)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glCopyTexImage%dD(missing readbuffer)", dimensions); - return GL_TRUE; - } - - /* Do size, level checking */ - sizeOK = (proxyTarget == GL_PROXY_TEXTURE_CUBE_MAP_ARB) - ? (width == height) : 1; - - sizeOK = sizeOK && ctx->Driver.TestProxyTexImage(ctx, proxyTarget, level, - internalFormat, format, - type, width, height, - 1, border); - - if (!sizeOK) { - if (dimensions == 1) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glCopyTexImage1D(width=%d)", width); - } - else { - ASSERT(dimensions == 2); - _mesa_error(ctx, GL_INVALID_VALUE, - "glCopyTexImage2D(width=%d, height=%d)", width, height); - } - return GL_TRUE; - } - - if (_mesa_is_compressed_format(ctx, internalFormat)) { - if (!target_can_be_compressed(ctx, target, internalFormat)) { - _mesa_error(ctx, GL_INVALID_ENUM, - "glCopyTexImage%dD(target)", dimensions); - return GL_TRUE; - } - if (border != 0) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glCopyTexImage%dD(border!=0)", dimensions); - return GL_TRUE; - } - } - else if (_mesa_is_depth_format(internalFormat)) { - /* make sure we have depth/stencil buffers */ - if (!ctx->ReadBuffer->_DepthBuffer) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glCopyTexImage%dD(no depth)", dimensions); - return GL_TRUE; - } - } - else if (_mesa_is_depthstencil_format(internalFormat)) { - /* make sure we have depth/stencil buffers */ - if (!ctx->ReadBuffer->_DepthBuffer || !ctx->ReadBuffer->_StencilBuffer) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glCopyTexImage%dD(no depth/stencil buffer)", dimensions); - return GL_TRUE; - } - } - - /* if we get here, the parameters are OK */ - return GL_FALSE; -} - - -/** - * Test glCopyTexSubImage[12]D() parameters for errors. - * Note that this is the first part of error checking. - * See also copytexsubimage_error_check2() below for the second part. - * - * \param ctx GL context. - * \param dimensions texture image dimensions (must be 1, 2 or 3). - * \param target texture target given by the user. - * \param level image level given by the user. - * - * \return GL_TRUE if an error was detected, or GL_FALSE if no errors. - */ -static GLboolean -copytexsubimage_error_check1( struct gl_context *ctx, GLuint dimensions, - GLenum target, GLint level) -{ - /* Check that the source buffer is complete */ - if (ctx->ReadBuffer->Name) { - if (ctx->ReadBuffer->_Status == 0) { - _mesa_test_framebuffer_completeness(ctx, ctx->ReadBuffer); - } - if (ctx->ReadBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) { - _mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION_EXT, - "glCopyTexImage%dD(invalid readbuffer)", dimensions); - return GL_TRUE; - } - } - - /* check target (proxies not allowed) */ - if (!legal_texsubimage_target(ctx, dimensions, target)) { - _mesa_error(ctx, GL_INVALID_ENUM, "glCopyTexSubImage%uD(target=%s)", - dimensions, _mesa_lookup_enum_by_nr(target)); - return GL_TRUE; - } - - /* Check level */ - if (level < 0 || level >= MAX_TEXTURE_LEVELS) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glCopyTexSubImage%dD(level=%d)", dimensions, level); - return GL_TRUE; - } - - return GL_FALSE; -} - - -/** - * Second part of error checking for glCopyTexSubImage[12]D(). - * \param xoffset sub-image x offset given by the user. - * \param yoffset sub-image y offset given by the user. - * \param zoffset sub-image z offset given by the user. - * \param width image width given by the user. - * \param height image height given by the user. - */ -static GLboolean -copytexsubimage_error_check2( struct gl_context *ctx, GLuint dimensions, - GLenum target, GLint level, - GLint xoffset, GLint yoffset, GLint zoffset, - GLsizei width, GLsizei height, - const struct gl_texture_image *teximage ) -{ - /* check that dest tex image exists */ - if (!teximage) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glCopyTexSubImage%dD(undefined texture level: %d)", - dimensions, level); - return GL_TRUE; - } - - /* Check size */ - if (width < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glCopyTexSubImage%dD(width=%d)", dimensions, width); - return GL_TRUE; - } - if (dimensions > 1 && height < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glCopyTexSubImage%dD(height=%d)", dimensions, height); - return GL_TRUE; - } - - /* check x/y offsets */ - if (xoffset < -((GLint)teximage->Border)) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glCopyTexSubImage%dD(xoffset=%d)", dimensions, xoffset); - return GL_TRUE; - } - if (xoffset + width > (GLint) (teximage->Width + teximage->Border)) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glCopyTexSubImage%dD(xoffset+width)", dimensions); - return GL_TRUE; - } - if (dimensions > 1) { - if (yoffset < -((GLint)teximage->Border)) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glCopyTexSubImage%dD(yoffset=%d)", dimensions, yoffset); - return GL_TRUE; - } - /* NOTE: we're adding the border here, not subtracting! */ - if (yoffset + height > (GLint) (teximage->Height + teximage->Border)) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glCopyTexSubImage%dD(yoffset+height)", dimensions); - return GL_TRUE; - } - } - - /* check z offset */ - if (dimensions > 2) { - if (zoffset < -((GLint)teximage->Border)) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glCopyTexSubImage%dD(zoffset)", dimensions); - return GL_TRUE; - } - if (zoffset > (GLint) (teximage->Depth + teximage->Border)) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glCopyTexSubImage%dD(zoffset+depth)", dimensions); - return GL_TRUE; - } - } - - if (_mesa_is_format_compressed(teximage->TexFormat)) { - /* offset must be multiple of 4 */ - if ((xoffset & 3) || (yoffset & 3)) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glCopyTexSubImage%dD(xoffset or yoffset)", dimensions); - return GL_TRUE; - } - /* size must be multiple of 4 */ - if ((width & 3) != 0 && (GLuint) width != teximage->Width) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glCopyTexSubImage%dD(width)", dimensions); - return GL_TRUE; - } - if ((height & 3) != 0 && (GLuint) height != teximage->Height) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glCopyTexSubImage%dD(height)", dimensions); - return GL_TRUE; - } - } - - if (teximage->InternalFormat == GL_YCBCR_MESA) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glCopyTexSubImage2D"); - return GL_TRUE; - } - - if (!_mesa_source_buffer_exists(ctx, teximage->_BaseFormat)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glCopyTexSubImage%dD(missing readbuffer, format=0x%x)", - dimensions, teximage->_BaseFormat); - return GL_TRUE; - } - - if (teximage->_BaseFormat == GL_DEPTH_COMPONENT) { - if (!ctx->ReadBuffer->_DepthBuffer) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glCopyTexSubImage%dD(no depth buffer)", - dimensions); - return GL_TRUE; - } - } - else if (teximage->_BaseFormat == GL_DEPTH_STENCIL_EXT) { - if (!ctx->ReadBuffer->_DepthBuffer || !ctx->ReadBuffer->_StencilBuffer) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glCopyTexSubImage%dD(no depth/stencil buffer)", - dimensions); - return GL_TRUE; - } - } - - /* If copying into an integer texture, the source buffer must also be - * integer-valued. - */ - if (_mesa_is_format_integer_color(teximage->TexFormat)) { - struct gl_renderbuffer *rb = ctx->ReadBuffer->_ColorReadBuffer; - if (!_mesa_is_format_integer_color(rb->Format)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glCopyTexSubImage%dD(source buffer is not integer format)", - dimensions); - return GL_TRUE; - } - } - - /* if we get here, the parameters are OK */ - return GL_FALSE; -} - - -/** Callback info for walking over FBO hash table */ -struct cb_info -{ - struct gl_context *ctx; - struct gl_texture_object *texObj; - GLuint level, face; -}; - - -/** - * Check render to texture callback. Called from _mesa_HashWalk(). - */ -static void -check_rtt_cb(GLuint key, void *data, void *userData) -{ - struct gl_framebuffer *fb = (struct gl_framebuffer *) data; - const struct cb_info *info = (struct cb_info *) userData; - struct gl_context *ctx = info->ctx; - const struct gl_texture_object *texObj = info->texObj; - const GLuint level = info->level, face = info->face; - - /* If this is a user-created FBO */ - if (fb->Name) { - GLuint i; - /* check if any of the FBO's attachments point to 'texObj' */ - for (i = 0; i < BUFFER_COUNT; i++) { - struct gl_renderbuffer_attachment *att = fb->Attachment + i; - if (att->Type == GL_TEXTURE && - att->Texture == texObj && - att->TextureLevel == level && - att->CubeMapFace == face) { - ASSERT(_mesa_get_attachment_teximage(att)); - /* Tell driver about the new renderbuffer texture */ - ctx->Driver.RenderTexture(ctx, ctx->DrawBuffer, att); - /* Mark fb status as indeterminate to force re-validation */ - fb->_Status = 0; - } - } - } -} - - -/** - * When a texture image is specified we have to check if it's bound to - * any framebuffer objects (render to texture) in order to detect changes - * in size or format since that effects FBO completeness. - * Any FBOs rendering into the texture must be re-validated. - */ -static void -update_fbo_texture(struct gl_context *ctx, struct gl_texture_object *texObj, - GLuint face, GLuint level) -{ - /* Only check this texture if it's been marked as RenderToTexture */ - if (texObj->_RenderToTexture) { - struct cb_info info; - info.ctx = ctx; - info.texObj = texObj; - info.level = level; - info.face = face; - _mesa_HashWalk(ctx->Shared->FrameBuffers, check_rtt_cb, &info); - } -} - - -/** - * If the texture object's GenerateMipmap flag is set and we've - * changed the texture base level image, regenerate the rest of the - * mipmap levels now. - */ -static INLINE void -check_gen_mipmap(struct gl_context *ctx, GLenum target, - struct gl_texture_object *texObj, GLint level) -{ - ASSERT(target != GL_TEXTURE_CUBE_MAP); - if (texObj->GenerateMipmap && - level == texObj->BaseLevel && - level < texObj->MaxLevel) { - ASSERT(ctx->Driver.GenerateMipmap); - ctx->Driver.GenerateMipmap(ctx, target, texObj); - } -} - - -/** Debug helper: override the user-requested internal format */ -static GLenum -override_internal_format(GLenum internalFormat, GLint width, GLint height) -{ -#if 0 - if (internalFormat == GL_RGBA16F_ARB || - internalFormat == GL_RGBA32F_ARB) { - printf("Convert rgba float tex to int %d x %d\n", width, height); - return GL_RGBA; - } - else if (internalFormat == GL_RGB16F_ARB || - internalFormat == GL_RGB32F_ARB) { - printf("Convert rgb float tex to int %d x %d\n", width, height); - return GL_RGB; - } - else if (internalFormat == GL_LUMINANCE_ALPHA16F_ARB || - internalFormat == GL_LUMINANCE_ALPHA32F_ARB) { - printf("Convert luminance float tex to int %d x %d\n", width, height); - return GL_LUMINANCE_ALPHA; - } - else if (internalFormat == GL_LUMINANCE16F_ARB || - internalFormat == GL_LUMINANCE32F_ARB) { - printf("Convert luminance float tex to int %d x %d\n", width, height); - return GL_LUMINANCE; - } - else if (internalFormat == GL_ALPHA16F_ARB || - internalFormat == GL_ALPHA32F_ARB) { - printf("Convert luminance float tex to int %d x %d\n", width, height); - return GL_ALPHA; - } - /* - else if (internalFormat == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT) { - internalFormat = GL_RGBA; - } - */ - else { - return internalFormat; - } -#else - return internalFormat; -#endif -} - - -/** - * Choose the actual hardware format for a texture image. - * Try to use the same format as the previous image level when possible. - * Otherwise, ask the driver for the best format. - * It's important to try to choose a consistant format for all levels - * for efficient texture memory layout/allocation. In particular, this - * comes up during automatic mipmap generation. - */ -gl_format -_mesa_choose_texture_format(struct gl_context *ctx, - struct gl_texture_object *texObj, - GLenum target, GLint level, - GLenum internalFormat, GLenum format, GLenum type) -{ - gl_format f; - - /* see if we've already chosen a format for the previous level */ - if (level > 0) { - struct gl_texture_image *prevImage = - _mesa_select_tex_image(ctx, texObj, target, level - 1); - /* See if the prev level is defined and has an internal format which - * matches the new internal format. - */ - if (prevImage && - prevImage->Width > 0 && - prevImage->InternalFormat == internalFormat) { - /* use the same format */ - ASSERT(prevImage->TexFormat != MESA_FORMAT_NONE); - return prevImage->TexFormat; - } - } - - /* choose format from scratch */ - f = ctx->Driver.ChooseTextureFormat(ctx, internalFormat, format, type); - ASSERT(f != MESA_FORMAT_NONE); - return f; -} - - -/** - * Common code to implement all the glTexImage1D/2D/3D functions. - */ -static void -teximage(struct gl_context *ctx, GLuint dims, - GLenum target, GLint level, GLint internalFormat, - GLsizei width, GLsizei height, GLsizei depth, - GLint border, GLenum format, GLenum type, - const GLvoid *pixels) -{ - GLboolean error; - - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE)) - _mesa_debug(ctx, "glTexImage%uD %s %d %s %d %d %d %d %s %s %p\n", - dims, - _mesa_lookup_enum_by_nr(target), level, - _mesa_lookup_enum_by_nr(internalFormat), - width, height, depth, border, - _mesa_lookup_enum_by_nr(format), - _mesa_lookup_enum_by_nr(type), pixels); - - internalFormat = override_internal_format(internalFormat, width, height); - - /* target error checking */ - if (!legal_teximage_target(ctx, dims, target)) { - _mesa_error(ctx, GL_INVALID_ENUM, "glTexImage%uD(target=%s)", - dims, _mesa_lookup_enum_by_nr(target)); - return; - } - - /* general error checking */ - error = texture_error_check(ctx, dims, target, level, internalFormat, - format, type, width, height, depth, border); - - if (_mesa_is_proxy_texture(target)) { - /* Proxy texture: just clear or set state depending on error checking */ - struct gl_texture_image *texImage = - _mesa_get_proxy_tex_image(ctx, target, level); - - if (error) { - /* when error, clear all proxy texture image parameters */ - if (texImage) - clear_teximage_fields(texImage); - } - else { - /* no error, set the tex image parameters */ - struct gl_texture_object *texObj = - _mesa_get_current_tex_object(ctx, target); - gl_format texFormat = _mesa_choose_texture_format(ctx, texObj, - target, level, - internalFormat, - format, type); - - if (legal_texture_size(ctx, texFormat, width, height, depth)) { - _mesa_init_teximage_fields(ctx, target, texImage, width, height, - depth, border, internalFormat, - texFormat); - } - else if (texImage) { - clear_teximage_fields(texImage); - } - } - } - else { - /* non-proxy target */ - const GLuint face = _mesa_tex_target_to_face(target); - struct gl_texture_object *texObj; - struct gl_texture_image *texImage; - - if (error) { - return; /* error was recorded */ - } - - if (ctx->NewState & _NEW_PIXEL) - _mesa_update_state(ctx); - - texObj = _mesa_get_current_tex_object(ctx, target); - - _mesa_lock_texture(ctx, texObj); - { - texImage = _mesa_get_tex_image(ctx, texObj, target, level); - - if (!texImage) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage%uD", dims); - } - else { - gl_format texFormat; - - ctx->Driver.FreeTextureImageBuffer(ctx, texImage); - - ASSERT(texImage->Data == NULL); - texFormat = _mesa_choose_texture_format(ctx, texObj, target, level, - internalFormat, format, - type); - - if (legal_texture_size(ctx, texFormat, width, height, depth)) { - _mesa_init_teximage_fields(ctx, target, texImage, - width, height, depth, - border, internalFormat, texFormat); - - /* Give the texture to the driver. may be null. */ - ASSERT(ctx->Driver.TexImage3D); - switch (dims) { - case 1: - ctx->Driver.TexImage1D(ctx, target, level, internalFormat, - width, border, format, - type, pixels, &ctx->Unpack, texObj, - texImage); - break; - case 2: - ctx->Driver.TexImage2D(ctx, target, level, internalFormat, - width, height, border, format, - type, pixels, &ctx->Unpack, texObj, - texImage); - break; - case 3: - ctx->Driver.TexImage3D(ctx, target, level, internalFormat, - width, height, depth, border, format, - type, pixels, &ctx->Unpack, texObj, - texImage); - break; - default: - _mesa_problem(ctx, "invalid dims=%u in teximage()", dims); - } - - check_gen_mipmap(ctx, target, texObj, level); - - update_fbo_texture(ctx, texObj, face, level); - - /* state update */ - texObj->_Complete = GL_FALSE; - ctx->NewState |= _NEW_TEXTURE; - } - else { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage%uD", dims); - } - } - } - _mesa_unlock_texture(ctx, texObj); - } -} - - -/* - * Called from the API. Note that width includes the border. - */ -void GLAPIENTRY -_mesa_TexImage1D( GLenum target, GLint level, GLint internalFormat, - GLsizei width, GLint border, GLenum format, - GLenum type, const GLvoid *pixels ) -{ - GET_CURRENT_CONTEXT(ctx); - teximage(ctx, 1, target, level, internalFormat, width, 1, 1, - border, format, type, pixels); -} - - -void GLAPIENTRY -_mesa_TexImage2D( GLenum target, GLint level, GLint internalFormat, - GLsizei width, GLsizei height, GLint border, - GLenum format, GLenum type, - const GLvoid *pixels ) -{ - GET_CURRENT_CONTEXT(ctx); - teximage(ctx, 2, target, level, internalFormat, width, height, 1, - border, format, type, pixels); -} - - -/* - * Called by the API or display list executor. - * Note that width and height include the border. - */ -void GLAPIENTRY -_mesa_TexImage3D( GLenum target, GLint level, GLint internalFormat, - GLsizei width, GLsizei height, GLsizei depth, - GLint border, GLenum format, GLenum type, - const GLvoid *pixels ) -{ - GET_CURRENT_CONTEXT(ctx); - teximage(ctx, 3, target, level, internalFormat, width, height, depth, - border, format, type, pixels); -} - - -void GLAPIENTRY -_mesa_TexImage3DEXT( GLenum target, GLint level, GLenum internalFormat, - GLsizei width, GLsizei height, GLsizei depth, - GLint border, GLenum format, GLenum type, - const GLvoid *pixels ) -{ - _mesa_TexImage3D(target, level, (GLint) internalFormat, width, height, - depth, border, format, type, pixels); -} - - -#if FEATURE_OES_EGL_image -void GLAPIENTRY -_mesa_EGLImageTargetTexture2DOES (GLenum target, GLeglImageOES image) -{ - struct gl_texture_object *texObj; - struct gl_texture_image *texImage; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (!ctx->Extensions.OES_EGL_image) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glEGLImageTargetTexture2DOES(unsupported)"); - return; - } - - if (target != GL_TEXTURE_2D) { - _mesa_error(ctx, GL_INVALID_ENUM, - "glEGLImageTargetTexture2D(target=%d)", target); - return; - } - - if (ctx->NewState & _NEW_PIXEL) - _mesa_update_state(ctx); - - texObj = _mesa_get_current_tex_object(ctx, target); - _mesa_lock_texture(ctx, texObj); - - texImage = _mesa_get_tex_image(ctx, texObj, target, 0); - if (!texImage) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glEGLImageTargetTexture2D"); - } else { - ctx->Driver.FreeTextureImageBuffer(ctx, texImage); - - ASSERT(texImage->Data == NULL); - ctx->Driver.EGLImageTargetTexture2D(ctx, target, - texObj, texImage, image); - - /* state update */ - texObj->_Complete = GL_FALSE; - ctx->NewState |= _NEW_TEXTURE; - } - _mesa_unlock_texture(ctx, texObj); - -} -#endif - - - -/** - * Implement all the glTexSubImage1/2/3D() functions. - */ -static void -texsubimage(struct gl_context *ctx, GLuint dims, GLenum target, GLint level, - GLint xoffset, GLint yoffset, GLint zoffset, - GLsizei width, GLsizei height, GLsizei depth, - GLenum format, GLenum type, const GLvoid *pixels ) -{ - struct gl_texture_object *texObj; - struct gl_texture_image *texImage; - - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE)) - _mesa_debug(ctx, "glTexSubImage%uD %s %d %d %d %d %d %d %d %s %s %p\n", - dims, - _mesa_lookup_enum_by_nr(target), level, - xoffset, yoffset, zoffset, width, height, depth, - _mesa_lookup_enum_by_nr(format), - _mesa_lookup_enum_by_nr(type), pixels); - - /* check target (proxies not allowed) */ - if (!legal_texsubimage_target(ctx, dims, target)) { - _mesa_error(ctx, GL_INVALID_ENUM, "glTexSubImage%uD(target=%s)", - dims, _mesa_lookup_enum_by_nr(target)); - return; - } - - if (ctx->NewState & _NEW_PIXEL) - _mesa_update_state(ctx); - - if (subtexture_error_check(ctx, dims, target, level, xoffset, yoffset, zoffset, - width, height, depth, format, type)) { - return; /* error was detected */ - } - - texObj = _mesa_get_current_tex_object(ctx, target); - - _mesa_lock_texture(ctx, texObj); - { - texImage = _mesa_select_tex_image(ctx, texObj, target, level); - - if (subtexture_error_check2(ctx, dims, target, level, - xoffset, yoffset, zoffset, - width, height, depth, - format, type, texImage)) { - /* error was recorded */ - } - else if (width > 0 && height > 0 && depth > 0) { - /* If we have a border, offset=-1 is legal. Bias by border width. */ - switch (dims) { - case 3: - zoffset += texImage->Border; - /* fall-through */ - case 2: - yoffset += texImage->Border; - /* fall-through */ - case 1: - xoffset += texImage->Border; - } - - switch (dims) { - case 1: - ctx->Driver.TexSubImage1D(ctx, target, level, - xoffset, width, - format, type, pixels, - &ctx->Unpack, texObj, texImage ); - break; - case 2: - ctx->Driver.TexSubImage2D(ctx, target, level, - xoffset, yoffset, width, height, - format, type, pixels, - &ctx->Unpack, texObj, texImage ); - break; - case 3: - ctx->Driver.TexSubImage3D(ctx, target, level, - xoffset, yoffset, zoffset, - width, height, depth, - format, type, pixels, - &ctx->Unpack, texObj, texImage ); - break; - default: - _mesa_problem(ctx, "unexpected dims in subteximage()"); - } - - check_gen_mipmap(ctx, target, texObj, level); - - ctx->NewState |= _NEW_TEXTURE; - } - } - _mesa_unlock_texture(ctx, texObj); -} - - -void GLAPIENTRY -_mesa_TexSubImage1D( GLenum target, GLint level, - GLint xoffset, GLsizei width, - GLenum format, GLenum type, - const GLvoid *pixels ) -{ - GET_CURRENT_CONTEXT(ctx); - texsubimage(ctx, 1, target, level, - xoffset, 0, 0, - width, 1, 1, - format, type, pixels); -} - - -void GLAPIENTRY -_mesa_TexSubImage2D( GLenum target, GLint level, - GLint xoffset, GLint yoffset, - GLsizei width, GLsizei height, - GLenum format, GLenum type, - const GLvoid *pixels ) -{ - GET_CURRENT_CONTEXT(ctx); - texsubimage(ctx, 2, target, level, - xoffset, yoffset, 0, - width, height, 1, - format, type, pixels); -} - - - -void GLAPIENTRY -_mesa_TexSubImage3D( GLenum target, GLint level, - GLint xoffset, GLint yoffset, GLint zoffset, - GLsizei width, GLsizei height, GLsizei depth, - GLenum format, GLenum type, - const GLvoid *pixels ) -{ - GET_CURRENT_CONTEXT(ctx); - texsubimage(ctx, 3, target, level, - xoffset, yoffset, zoffset, - width, height, depth, - format, type, pixels); -} - - - -/** - * Implement the glCopyTexImage1/2D() functions. - */ -static void -copyteximage(struct gl_context *ctx, GLuint dims, - GLenum target, GLint level, GLenum internalFormat, - GLint x, GLint y, GLsizei width, GLsizei height, GLint border ) -{ - struct gl_texture_object *texObj; - struct gl_texture_image *texImage; - const GLuint face = _mesa_tex_target_to_face(target); - - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE)) - _mesa_debug(ctx, "glCopyTexImage%uD %s %d %s %d %d %d %d %d\n", - dims, - _mesa_lookup_enum_by_nr(target), level, - _mesa_lookup_enum_by_nr(internalFormat), - x, y, width, height, border); - - if (ctx->NewState & NEW_COPY_TEX_STATE) - _mesa_update_state(ctx); - - if (copytexture_error_check(ctx, dims, target, level, internalFormat, - width, height, border)) - return; - - texObj = _mesa_get_current_tex_object(ctx, target); - - _mesa_lock_texture(ctx, texObj); - { - texImage = _mesa_get_tex_image(ctx, texObj, target, level); - - if (!texImage) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexImage%uD", dims); - } - else { - /* choose actual hw format */ - gl_format texFormat = _mesa_choose_texture_format(ctx, texObj, - target, level, - internalFormat, - GL_NONE, GL_NONE); - - if (legal_texture_size(ctx, texFormat, width, height, 1)) { - GLint srcX = x, srcY = y, dstX = 0, dstY = 0; - - /* Free old texture image */ - ctx->Driver.FreeTextureImageBuffer(ctx, texImage); - - _mesa_init_teximage_fields(ctx, target, texImage, width, height, 1, - border, internalFormat, texFormat); - - /* Allocate texture memory (no pixel data yet) */ - if (dims == 1) { - ctx->Driver.TexImage1D(ctx, target, level, internalFormat, - width, border, GL_NONE, GL_NONE, NULL, - &ctx->Unpack, texObj, texImage); - } - else { - ctx->Driver.TexImage2D(ctx, target, level, internalFormat, - width, height, border, GL_NONE, GL_NONE, - NULL, &ctx->Unpack, texObj, texImage); - } - - if (_mesa_clip_copytexsubimage(ctx, &dstX, &dstY, &srcX, &srcY, - &width, &height)) { - if (dims == 1) - ctx->Driver.CopyTexSubImage1D(ctx, target, level, dstX, - srcX, srcY, width); - - else - ctx->Driver.CopyTexSubImage2D(ctx, target, level, dstX, dstY, - srcX, srcY, width, height); - } - - check_gen_mipmap(ctx, target, texObj, level); - - update_fbo_texture(ctx, texObj, face, level); - - /* state update */ - texObj->_Complete = GL_FALSE; - ctx->NewState |= _NEW_TEXTURE; - } - else { - /* probably too large of image */ - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexImage%uD", dims); - } - } - } - _mesa_unlock_texture(ctx, texObj); -} - - - -void GLAPIENTRY -_mesa_CopyTexImage1D( GLenum target, GLint level, - GLenum internalFormat, - GLint x, GLint y, - GLsizei width, GLint border ) -{ - GET_CURRENT_CONTEXT(ctx); - copyteximage(ctx, 1, target, level, internalFormat, x, y, width, 1, border); -} - - - -void GLAPIENTRY -_mesa_CopyTexImage2D( GLenum target, GLint level, GLenum internalFormat, - GLint x, GLint y, GLsizei width, GLsizei height, - GLint border ) -{ - GET_CURRENT_CONTEXT(ctx); - copyteximage(ctx, 2, target, level, internalFormat, - x, y, width, height, border); -} - - - -/** - * Implementation for glCopyTexSubImage1/2/3D() functions. - */ -static void -copytexsubimage(struct gl_context *ctx, GLuint dims, GLenum target, GLint level, - GLint xoffset, GLint yoffset, GLint zoffset, - GLint x, GLint y, GLsizei width, GLsizei height) -{ - struct gl_texture_object *texObj; - struct gl_texture_image *texImage; - - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE)) - _mesa_debug(ctx, "glCopyTexSubImage%uD %s %d %d %d %d %d %d %d %d\n", - dims, - _mesa_lookup_enum_by_nr(target), - level, xoffset, yoffset, zoffset, x, y, width, height); - - if (ctx->NewState & NEW_COPY_TEX_STATE) - _mesa_update_state(ctx); - - if (copytexsubimage_error_check1(ctx, dims, target, level)) - return; - - texObj = _mesa_get_current_tex_object(ctx, target); - - _mesa_lock_texture(ctx, texObj); - { - texImage = _mesa_select_tex_image(ctx, texObj, target, level); - - if (copytexsubimage_error_check2(ctx, dims, target, level, xoffset, yoffset, - zoffset, width, height, texImage)) { - /* error was recored */ - } - else { - /* If we have a border, offset=-1 is legal. Bias by border width. */ - switch (dims) { - case 3: - zoffset += texImage->Border; - /* fall-through */ - case 2: - yoffset += texImage->Border; - /* fall-through */ - case 1: - xoffset += texImage->Border; - } - - if (_mesa_clip_copytexsubimage(ctx, &xoffset, &yoffset, &x, &y, - &width, &height)) { - switch (dims) { - case 1: - ctx->Driver.CopyTexSubImage1D(ctx, target, level, - xoffset, x, y, width); - break; - case 2: - ctx->Driver.CopyTexSubImage2D(ctx, target, level, - xoffset, yoffset, - x, y, width, height); - break; - case 3: - ctx->Driver.CopyTexSubImage3D(ctx, target, level, - xoffset, yoffset, zoffset, - x, y, width, height); - break; - default: - _mesa_problem(ctx, "bad dims in copytexsubimage()"); - } - - check_gen_mipmap(ctx, target, texObj, level); - - ctx->NewState |= _NEW_TEXTURE; - } - } - } - _mesa_unlock_texture(ctx, texObj); -} - - -void GLAPIENTRY -_mesa_CopyTexSubImage1D( GLenum target, GLint level, - GLint xoffset, GLint x, GLint y, GLsizei width ) -{ - GET_CURRENT_CONTEXT(ctx); - copytexsubimage(ctx, 1, target, level, xoffset, 0, 0, x, y, width, 1); -} - - - -void GLAPIENTRY -_mesa_CopyTexSubImage2D( GLenum target, GLint level, - GLint xoffset, GLint yoffset, - GLint x, GLint y, GLsizei width, GLsizei height ) -{ - GET_CURRENT_CONTEXT(ctx); - copytexsubimage(ctx, 2, target, level, xoffset, yoffset, 0, x, y, - width, height); -} - - - -void GLAPIENTRY -_mesa_CopyTexSubImage3D( GLenum target, GLint level, - GLint xoffset, GLint yoffset, GLint zoffset, - GLint x, GLint y, GLsizei width, GLsizei height ) -{ - GET_CURRENT_CONTEXT(ctx); - copytexsubimage(ctx, 3, target, level, xoffset, yoffset, zoffset, - x, y, width, height); -} - - - - -/**********************************************************************/ -/****** Compressed Textures ******/ -/**********************************************************************/ - - -/** - * Return expected size of a compressed texture. - */ -static GLuint -compressed_tex_size(GLsizei width, GLsizei height, GLsizei depth, - GLenum glformat) -{ - gl_format mesaFormat = _mesa_glenum_to_compressed_format(glformat); - return _mesa_format_image_size(mesaFormat, width, height, depth); -} - - -/* - * Return compressed texture block size, in pixels. - */ -static void -get_compressed_block_size(GLenum glformat, GLuint *bw, GLuint *bh) -{ - gl_format mesaFormat = _mesa_glenum_to_compressed_format(glformat); - _mesa_get_format_block_size(mesaFormat, bw, bh); -} - - -/** - * Error checking for glCompressedTexImage[123]D(). - * \param reason returns reason for error, if any - * \return error code or GL_NO_ERROR. - */ -static GLenum -compressed_texture_error_check(struct gl_context *ctx, GLint dimensions, - GLenum target, GLint level, - GLenum internalFormat, GLsizei width, - GLsizei height, GLsizei depth, GLint border, - GLsizei imageSize, char **reason) -{ - const GLenum proxyTarget = get_proxy_target(target); - const GLint maxLevels = _mesa_max_texture_levels(ctx, target); - GLint expectedSize; - - *reason = ""; /* no error */ - - /* check level */ - if (level < 0 || level >= maxLevels) { - *reason = "level"; - return GL_INVALID_VALUE; - } - - if (!target_can_be_compressed(ctx, target, internalFormat)) { - *reason = "target"; - return GL_INVALID_ENUM; - } - - /* This will detect any invalid internalFormat value */ - if (!_mesa_is_compressed_format(ctx, internalFormat)) { - *reason = "internalFormat"; - return GL_INVALID_ENUM; - } - - /* This should really never fail */ - if (_mesa_base_tex_format(ctx, internalFormat) < 0) { - *reason = "internalFormat"; - return GL_INVALID_ENUM; - } - - /* No compressed formats support borders at this time */ - if (border != 0) { - *reason = "border != 0"; - return GL_INVALID_VALUE; - } - - /* For cube map, width must equal height */ - if (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB && - target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB && width != height) { - *reason = "width != height"; - return GL_INVALID_VALUE; - } - - /* check image size against compression block size */ - { - gl_format texFormat = - ctx->Driver.ChooseTextureFormat(ctx, internalFormat, - GL_NONE, GL_NONE); - GLuint bw, bh; - - _mesa_get_format_block_size(texFormat, &bw, &bh); - if ((width > bw && width % bw > 0) || - (height > bh && height % bh > 0)) { - /* - * Per GL_ARB_texture_compression: GL_INVALID_OPERATION is - * generated [...] if any parameter combinations are not - * supported by the specific compressed internal format. - */ - *reason = "invalid width or height for compression format"; - return GL_INVALID_OPERATION; - } - } - - /* check image sizes */ - if (!ctx->Driver.TestProxyTexImage(ctx, proxyTarget, level, - internalFormat, GL_NONE, GL_NONE, - width, height, depth, border)) { - /* See error comment above */ - *reason = "invalid width, height or format"; - return GL_INVALID_OPERATION; - } - - /* check image size in bytes */ - expectedSize = compressed_tex_size(width, height, depth, internalFormat); - if (expectedSize != imageSize) { - /* Per GL_ARB_texture_compression: GL_INVALID_VALUE is generated [...] - * if is not consistent with the format, dimensions, and - * contents of the specified image. - */ - *reason = "imageSize inconsistant with width/height/format"; - return GL_INVALID_VALUE; - } - - return GL_NO_ERROR; -} - - -/** - * Error checking for glCompressedTexSubImage[123]D(). - * \warning There are some bad assumptions here about the size of compressed - * texture tiles (multiple of 4) used to test the validity of the - * offset and size parameters. - * \return error code or GL_NO_ERROR. - */ -static GLenum -compressed_subtexture_error_check(struct gl_context *ctx, GLint dimensions, - GLenum target, GLint level, - GLint xoffset, GLint yoffset, GLint zoffset, - GLsizei width, GLsizei height, GLsizei depth, - GLenum format, GLsizei imageSize) -{ - GLint expectedSize, maxLevels = 0, maxTextureSize; - GLuint bw, bh; - (void) zoffset; - - if (dimensions == 1) { - /* 1D compressed textures not allowed */ - return GL_INVALID_ENUM; - } - else if (dimensions == 2) { - if (target == GL_PROXY_TEXTURE_2D) { - maxLevels = ctx->Const.MaxTextureLevels; - } - else if (target == GL_TEXTURE_2D) { - maxLevels = ctx->Const.MaxTextureLevels; - } - else if (target == GL_PROXY_TEXTURE_CUBE_MAP_ARB) { - if (!ctx->Extensions.ARB_texture_cube_map) - return GL_INVALID_ENUM; /*target*/ - maxLevels = ctx->Const.MaxCubeTextureLevels; - } - else if (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB && - target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB) { - if (!ctx->Extensions.ARB_texture_cube_map) - return GL_INVALID_ENUM; /*target*/ - maxLevels = ctx->Const.MaxCubeTextureLevels; - } - else { - return GL_INVALID_ENUM; /*target*/ - } - } - else if (dimensions == 3) { - /* 3D compressed textures not allowed */ - return GL_INVALID_ENUM; - } - - maxTextureSize = 1 << (maxLevels - 1); - - /* this will catch any invalid compressed format token */ - if (!_mesa_is_compressed_format(ctx, format)) - return GL_INVALID_ENUM; - - if (width < 1 || width > maxTextureSize) - return GL_INVALID_VALUE; - - if ((height < 1 || height > maxTextureSize) - && dimensions > 1) - return GL_INVALID_VALUE; - - if (level < 0 || level >= maxLevels) - return GL_INVALID_VALUE; - - /* - * do checks which depend on compression block size - */ - get_compressed_block_size(format, &bw, &bh); - - if ((xoffset % bw != 0) || (yoffset % bh != 0)) - return GL_INVALID_VALUE; - - if ((width % bw != 0) && width != 2 && width != 1) - return GL_INVALID_VALUE; - - if ((height % bh != 0) && height != 2 && height != 1) - return GL_INVALID_VALUE; - - expectedSize = compressed_tex_size(width, height, depth, format); - if (expectedSize != imageSize) - return GL_INVALID_VALUE; - - return GL_NO_ERROR; -} - - -/** - * Do second part of glCompressedTexSubImage error checking. - * \return GL_TRUE if error found, GL_FALSE otherwise. - */ -static GLboolean -compressed_subtexture_error_check2(struct gl_context *ctx, GLuint dims, - GLsizei width, GLsizei height, - GLsizei depth, GLenum format, - struct gl_texture_image *texImage) -{ - - if ((GLint) format != texImage->InternalFormat) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glCompressedTexSubImage%uD(format=0x%x)", dims, format); - return GL_TRUE; - } - - if (((width == 1 || width == 2) && - width != (GLsizei) texImage->Width) || - (width > (GLsizei) texImage->Width)) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glCompressedTexSubImage%uD(width=%d)", dims, width); - return GL_TRUE; - } - - if (dims >= 2) { - if (((height == 1 || height == 2) && - height != (GLsizei) texImage->Height) || - (height > (GLsizei) texImage->Height)) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glCompressedTexSubImage%uD(height=%d)", dims, height); - return GL_TRUE; - } - } - - if (dims >= 3) { - if (((depth == 1 || depth == 2) && - depth != (GLsizei) texImage->Depth) || - (depth > (GLsizei) texImage->Depth)) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glCompressedTexSubImage%uD(depth=%d)", dims, depth); - return GL_TRUE; - } - } - - return GL_FALSE; -} - - -/** - * Implementation of the glCompressedTexImage1/2/3D() functions. - */ -static void -compressedteximage(struct gl_context *ctx, GLuint dims, - GLenum target, GLint level, - GLenum internalFormat, GLsizei width, - GLsizei height, GLsizei depth, GLint border, - GLsizei imageSize, const GLvoid *data) -{ - GLenum error; - char *reason = ""; - - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE)) - _mesa_debug(ctx, - "glCompressedTexImage%uDARB %s %d %s %d %d %d %d %d %p\n", - dims, - _mesa_lookup_enum_by_nr(target), level, - _mesa_lookup_enum_by_nr(internalFormat), - width, height, depth, border, imageSize, data); - - /* check target */ - if (!legal_teximage_target(ctx, dims, target)) { - _mesa_error(ctx, GL_INVALID_ENUM, "glCompressedTexImage%uD(target=%s)", - dims, _mesa_lookup_enum_by_nr(target)); - return; - } - - error = compressed_texture_error_check(ctx, dims, target, level, - internalFormat, width, height, depth, - border, imageSize, &reason); - - if (error) { - _mesa_error(ctx, error, "glCompressedTexImage%uD(%s)", dims, reason); - return; - } - -#if FEATURE_ES - /* XXX this is kind of a hack */ - if (dims == 2) { - switch (internalFormat) { - case GL_PALETTE4_RGB8_OES: - case GL_PALETTE4_RGBA8_OES: - case GL_PALETTE4_R5_G6_B5_OES: - case GL_PALETTE4_RGBA4_OES: - case GL_PALETTE4_RGB5_A1_OES: - case GL_PALETTE8_RGB8_OES: - case GL_PALETTE8_RGBA8_OES: - case GL_PALETTE8_R5_G6_B5_OES: - case GL_PALETTE8_RGBA4_OES: - case GL_PALETTE8_RGB5_A1_OES: - _mesa_cpal_compressed_teximage2d(target, level, internalFormat, - width, height, imageSize, data); - return; - } - } -#endif - - if (_mesa_is_proxy_texture(target)) { - /* Proxy texture: just check for errors and update proxy state */ - struct gl_texture_image *texImage; - - if (!error) { - struct gl_texture_object *texObj = - _mesa_get_current_tex_object(ctx, target); - gl_format texFormat = - _mesa_choose_texture_format(ctx, texObj, target, level, - internalFormat, GL_NONE, GL_NONE); - if (!legal_texture_size(ctx, texFormat, width, height, depth)) { - error = GL_OUT_OF_MEMORY; - } - } - - texImage = _mesa_get_proxy_tex_image(ctx, target, level); - if (texImage) { - if (error) { - /* if error, clear all proxy texture image parameters */ - clear_teximage_fields(texImage); - } - else { - /* no error: store the teximage parameters */ - _mesa_init_teximage_fields(ctx, target, texImage, width, height, - depth, border, internalFormat, - MESA_FORMAT_NONE); - } - } - } - else { - /* non-proxy target */ - struct gl_texture_object *texObj; - struct gl_texture_image *texImage; - - if (error) { - _mesa_error(ctx, error, "glCompressedTexImage%uD", dims); - return; - } - - texObj = _mesa_get_current_tex_object(ctx, target); - - _mesa_lock_texture(ctx, texObj); - { - texImage = _mesa_get_tex_image(ctx, texObj, target, level); - if (!texImage) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, - "glCompressedTexImage%uD", dims); - } - else { - gl_format texFormat; - - ctx->Driver.FreeTextureImageBuffer(ctx, texImage); - ASSERT(texImage->Data == NULL); - - texFormat = _mesa_choose_texture_format(ctx, texObj, target, level, - internalFormat, GL_NONE, - GL_NONE); - - if (legal_texture_size(ctx, texFormat, width, height, depth)) { - _mesa_init_teximage_fields(ctx, target, texImage, - width, height, depth, - border, internalFormat, texFormat); - - switch (dims) { - case 1: - ASSERT(ctx->Driver.CompressedTexImage1D); - ctx->Driver.CompressedTexImage1D(ctx, target, level, - internalFormat, - width, - border, imageSize, data, - texObj, texImage); - break; - case 2: - ASSERT(ctx->Driver.CompressedTexImage2D); - ctx->Driver.CompressedTexImage2D(ctx, target, level, - internalFormat, - width, height, - border, imageSize, data, - texObj, texImage); - break; - case 3: - ASSERT(ctx->Driver.CompressedTexImage3D); - ctx->Driver.CompressedTexImage3D(ctx, target, level, - internalFormat, - width, height, depth, - border, imageSize, data, - texObj, texImage); - break; - default: - _mesa_problem(ctx, "bad dims in compressedteximage"); - } - - check_gen_mipmap(ctx, target, texObj, level); - - /* state update */ - texObj->_Complete = GL_FALSE; - ctx->NewState |= _NEW_TEXTURE; - } - else { - _mesa_error(ctx, GL_OUT_OF_MEMORY, - "glCompressedTexImage%uD", dims); - } - } - } - _mesa_unlock_texture(ctx, texObj); - } -} - - -void GLAPIENTRY -_mesa_CompressedTexImage1DARB(GLenum target, GLint level, - GLenum internalFormat, GLsizei width, - GLint border, GLsizei imageSize, - const GLvoid *data) -{ - GET_CURRENT_CONTEXT(ctx); - compressedteximage(ctx, 1, target, level, internalFormat, - width, 1, 1, border, imageSize, data); -} - - -void GLAPIENTRY -_mesa_CompressedTexImage2DARB(GLenum target, GLint level, - GLenum internalFormat, GLsizei width, - GLsizei height, GLint border, GLsizei imageSize, - const GLvoid *data) -{ - GET_CURRENT_CONTEXT(ctx); - compressedteximage(ctx, 2, target, level, internalFormat, - width, height, 1, border, imageSize, data); -} - - -void GLAPIENTRY -_mesa_CompressedTexImage3DARB(GLenum target, GLint level, - GLenum internalFormat, GLsizei width, - GLsizei height, GLsizei depth, GLint border, - GLsizei imageSize, const GLvoid *data) -{ - GET_CURRENT_CONTEXT(ctx); - compressedteximage(ctx, 3, target, level, internalFormat, - width, height, depth, border, imageSize, data); -} - - -/** - * Common helper for glCompressedTexSubImage1/2/3D(). - */ -static void -compressed_tex_sub_image(GLuint dims, GLenum target, GLint level, - GLint xoffset, GLint yoffset, GLint zoffset, - GLsizei width, GLsizei height, GLsizei depth, - GLenum format, GLsizei imageSize, const GLvoid *data) -{ - struct gl_texture_object *texObj; - struct gl_texture_image *texImage; - GLenum error; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - error = compressed_subtexture_error_check(ctx, dims, target, level, - xoffset, 0, 0, /* pos */ - width, height, depth, /* size */ - format, imageSize); - if (error) { - _mesa_error(ctx, error, "glCompressedTexSubImage%uD", dims); - return; - } - - texObj = _mesa_get_current_tex_object(ctx, target); - - _mesa_lock_texture(ctx, texObj); - { - texImage = _mesa_select_tex_image(ctx, texObj, target, level); - assert(texImage); - - if (compressed_subtexture_error_check2(ctx, dims, width, height, depth, - format, texImage)) { - /* error was recorded */ - } - else if (width > 0 && height > 0 && depth > 0) { - switch (dims) { - case 1: - if (ctx->Driver.CompressedTexSubImage1D) { - ctx->Driver.CompressedTexSubImage1D(ctx, target, level, - xoffset, width, - format, imageSize, data, - texObj, texImage); - } - break; - case 2: - if (ctx->Driver.CompressedTexSubImage2D) { - ctx->Driver.CompressedTexSubImage2D(ctx, target, level, - xoffset, yoffset, - width, height, - format, imageSize, data, - texObj, texImage); - } - break; - case 3: - if (ctx->Driver.CompressedTexSubImage3D) { - ctx->Driver.CompressedTexSubImage3D(ctx, target, level, - xoffset, yoffset, zoffset, - width, height, depth, - format, imageSize, data, - texObj, texImage); - } - break; - default: - ; - } - - check_gen_mipmap(ctx, target, texObj, level); - - ctx->NewState |= _NEW_TEXTURE; - } - } - _mesa_unlock_texture(ctx, texObj); -} - - -void GLAPIENTRY -_mesa_CompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset, - GLsizei width, GLenum format, - GLsizei imageSize, const GLvoid *data) -{ - compressed_tex_sub_image(1, target, level, xoffset, 0, 0, width, 1, 1, - format, imageSize, data); -} - - -void GLAPIENTRY -_mesa_CompressedTexSubImage2DARB(GLenum target, GLint level, GLint xoffset, - GLint yoffset, GLsizei width, GLsizei height, - GLenum format, GLsizei imageSize, - const GLvoid *data) -{ - compressed_tex_sub_image(2, target, level, xoffset, yoffset, 0, - width, height, 1, format, imageSize, data); -} - - -void GLAPIENTRY -_mesa_CompressedTexSubImage3DARB(GLenum target, GLint level, GLint xoffset, - GLint yoffset, GLint zoffset, GLsizei width, - GLsizei height, GLsizei depth, GLenum format, - GLsizei imageSize, const GLvoid *data) -{ - compressed_tex_sub_image(3, target, level, xoffset, yoffset, zoffset, - width, height, depth, format, imageSize, data); -} - - -/** - * Helper for glTexBuffer(). Check if internalFormat is legal. If so, - * return the basic data type and number of components for the format. - * \param return GL_TRUE if internalFormat is legal, GL_FALSE otherwise - */ -static GLboolean -get_sized_format_info(const struct gl_context *ctx, GLenum internalFormat, - GLenum *datatype, GLuint *components) -{ - switch (internalFormat) { - case GL_ALPHA8: - *datatype = GL_UNSIGNED_BYTE; - *components = 1; - break; - case GL_ALPHA16: - *datatype = GL_UNSIGNED_SHORT; - *components = 1; - break; - case GL_ALPHA16F_ARB: - *datatype = GL_HALF_FLOAT; - *components = 1; - break; - case GL_ALPHA32F_ARB: - *datatype = GL_FLOAT; - *components = 1; - break; - case GL_ALPHA8I_EXT: - *datatype = GL_BYTE; - *components = 1; - break; - case GL_ALPHA16I_EXT: - *datatype = GL_SHORT; - *components = 1; - break; - case GL_ALPHA32I_EXT: - *datatype = GL_INT; - *components = 1; - break; - case GL_ALPHA8UI_EXT: - *datatype = GL_UNSIGNED_BYTE; - *components = 1; - break; - case GL_ALPHA16UI_EXT: - *datatype = GL_UNSIGNED_SHORT; - *components = 1; - break; - case GL_ALPHA32UI_EXT: - *datatype = GL_UNSIGNED_INT; - *components = 1; - break; - case GL_LUMINANCE8: - *datatype = GL_UNSIGNED_BYTE; - *components = 1; - break; - case GL_LUMINANCE16: - *datatype = GL_UNSIGNED_SHORT; - *components = 1; - break; - case GL_LUMINANCE16F_ARB: - *datatype = GL_HALF_FLOAT; - *components = 1; - break; - case GL_LUMINANCE32F_ARB: - *datatype = GL_FLOAT; - *components = 1; - break; - case GL_LUMINANCE8I_EXT: - *datatype = GL_BYTE; - *components = 1; - break; - case GL_LUMINANCE16I_EXT: - *datatype = GL_SHORT; - *components = 1; - break; - case GL_LUMINANCE32I_EXT: - *datatype = GL_INT; - *components = 1; - break; - case GL_LUMINANCE8UI_EXT: - *datatype = GL_UNSIGNED_BYTE; - *components = 1; - break; - case GL_LUMINANCE16UI_EXT: - *datatype = GL_UNSIGNED_SHORT; - *components = 1; - break; - case GL_LUMINANCE32UI_EXT: - *datatype = GL_UNSIGNED_INT; - *components = 1; - break; - case GL_LUMINANCE8_ALPHA8: - *datatype = GL_UNSIGNED_BYTE; - *components = 2; - break; - case GL_LUMINANCE16_ALPHA16: - *datatype = GL_UNSIGNED_SHORT; - *components = 2; - break; - case GL_LUMINANCE_ALPHA16F_ARB: - *datatype = GL_HALF_FLOAT; - *components = 2; - break; - case GL_LUMINANCE_ALPHA32F_ARB: - *datatype = GL_FLOAT; - *components = 2; - break; - case GL_LUMINANCE_ALPHA8I_EXT: - *datatype = GL_BYTE; - *components = 2; - break; - case GL_LUMINANCE_ALPHA16I_EXT: - *datatype = GL_SHORT; - *components = 2; - break; - case GL_LUMINANCE_ALPHA32I_EXT: - *datatype = GL_INT; - *components = 2; - break; - case GL_LUMINANCE_ALPHA8UI_EXT: - *datatype = GL_UNSIGNED_BYTE; - *components = 2; - break; - case GL_LUMINANCE_ALPHA16UI_EXT: - *datatype = GL_UNSIGNED_SHORT; - *components = 2; - break; - case GL_LUMINANCE_ALPHA32UI_EXT: - *datatype = GL_UNSIGNED_INT; - *components = 2; - break; - case GL_INTENSITY8: - *datatype = GL_UNSIGNED_BYTE; - *components = 1; - break; - case GL_INTENSITY16: - *datatype = GL_UNSIGNED_SHORT; - *components = 1; - break; - case GL_INTENSITY16F_ARB: - *datatype = GL_HALF_FLOAT; - *components = 1; - break; - case GL_INTENSITY32F_ARB: - *datatype = GL_FLOAT; - *components = 1; - break; - case GL_INTENSITY8I_EXT: - *datatype = GL_BYTE; - *components = 1; - break; - case GL_INTENSITY16I_EXT: - *datatype = GL_SHORT; - *components = 1; - break; - case GL_INTENSITY32I_EXT: - *datatype = GL_INT; - *components = 1; - break; - case GL_INTENSITY8UI_EXT: - *datatype = GL_UNSIGNED_BYTE; - *components = 1; - break; - case GL_INTENSITY16UI_EXT: - *datatype = GL_UNSIGNED_SHORT; - *components = 1; - break; - case GL_INTENSITY32UI_EXT: - *datatype = GL_UNSIGNED_INT; - *components = 1; - break; - case GL_RGBA8: - *datatype = GL_UNSIGNED_BYTE; - *components = 4; - break; - case GL_RGBA16: - *datatype = GL_UNSIGNED_SHORT; - *components = 4; - break; - case GL_RGBA16F_ARB: - *datatype = GL_HALF_FLOAT; - *components = 4; - break; - case GL_RGBA32F_ARB: - *datatype = GL_FLOAT; - *components = 4; - break; - case GL_RGBA8I_EXT: - *datatype = GL_BYTE; - *components = 4; - break; - case GL_RGBA16I_EXT: - *datatype = GL_SHORT; - *components = 4; - break; - case GL_RGBA32I_EXT: - *datatype = GL_INT; - *components = 4; - break; - case GL_RGBA8UI_EXT: - *datatype = GL_UNSIGNED_BYTE; - *components = 4; - break; - case GL_RGBA16UI_EXT: - *datatype = GL_UNSIGNED_SHORT; - *components = 4; - break; - case GL_RGBA32UI_EXT: - *datatype = GL_UNSIGNED_INT; - *components = 4; - break; - default: - return GL_FALSE; - } - - if (*datatype == GL_FLOAT && !ctx->Extensions.ARB_texture_float) - return GL_FALSE; - - if (*datatype == GL_HALF_FLOAT && !ctx->Extensions.ARB_half_float_pixel) - return GL_FALSE; - - return GL_TRUE; -} - - -/** GL_ARB_texture_buffer_object */ -void GLAPIENTRY -_mesa_TexBuffer(GLenum target, GLenum internalFormat, GLuint buffer) -{ - struct gl_texture_object *texObj; - struct gl_buffer_object *bufObj; - GLenum dataType; - GLuint comps; - - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (!ctx->Extensions.ARB_texture_buffer_object) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glTexBuffer"); - return; - } - - if (target != GL_TEXTURE_BUFFER_ARB) { - _mesa_error(ctx, GL_INVALID_ENUM, "glTexBuffer(target)"); - return; - } - - if (!get_sized_format_info(ctx, internalFormat, &dataType, &comps)) { - _mesa_error(ctx, GL_INVALID_ENUM, "glTexBuffer(internalFormat 0x%x)", - internalFormat); - return; - } - - bufObj = _mesa_lookup_bufferobj(ctx, buffer); - if (buffer && !bufObj) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glTexBuffer(buffer %u)", buffer); - return; - } - - texObj = _mesa_get_current_tex_object(ctx, target); - - _mesa_lock_texture(ctx, texObj); - { - _mesa_reference_buffer_object(ctx, &texObj->BufferObject, bufObj); - texObj->BufferObjectFormat = internalFormat; - } - _mesa_unlock_texture(ctx, texObj); -} +/* + * Mesa 3-D graphics library + * + * Copyright (C) 1999-2008 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. + */ + + +/** + * \file teximage.c + * Texture image-related functions. + */ + + +#include "glheader.h" +#include "bufferobj.h" +#include "context.h" +#include "enums.h" +#include "fbobject.h" +#include "framebuffer.h" +#include "hash.h" +#include "image.h" +#include "imports.h" +#include "macros.h" +#include "mfeatures.h" +#include "state.h" +#include "texcompress.h" +#include "texfetch.h" +#include "teximage.h" +#include "texstate.h" +#include "texpal.h" +#include "mtypes.h" + + +/** + * State changes which we care about for glCopyTex[Sub]Image() calls. + * In particular, we care about pixel transfer state and buffer state + * (such as glReadBuffer to make sure we read from the right renderbuffer). + */ +#define NEW_COPY_TEX_STATE (_NEW_BUFFERS | _NEW_PIXEL) + + + +/** + * We allocate texture memory on 512-byte boundaries so we can use MMX/SSE + * elsewhere. + */ +void * +_mesa_alloc_texmemory(GLsizei bytes) +{ + return _mesa_align_malloc(bytes, 512); +} + + +/** + * Free texture memory allocated with _mesa_alloc_texmemory() + */ +void +_mesa_free_texmemory(void *m) +{ + _mesa_align_free(m); +} + + +/** + * Return the simple base format for a given internal texture format. + * For example, given GL_LUMINANCE12_ALPHA4, return GL_LUMINANCE_ALPHA. + * + * \param ctx GL context. + * \param internalFormat the internal texture format token or 1, 2, 3, or 4. + * + * \return the corresponding \u base internal format (GL_ALPHA, GL_LUMINANCE, + * GL_LUMANCE_ALPHA, GL_INTENSITY, GL_RGB, or GL_RGBA), or -1 if invalid enum. + * + * This is the format which is used during texture application (i.e. the + * texture format and env mode determine the arithmetic used. + * + * XXX this could be static + */ +GLint +_mesa_base_tex_format( struct gl_context *ctx, GLint internalFormat ) +{ + switch (internalFormat) { + case GL_ALPHA: + case GL_ALPHA4: + case GL_ALPHA8: + case GL_ALPHA12: + case GL_ALPHA16: + return GL_ALPHA; + case 1: + case GL_LUMINANCE: + case GL_LUMINANCE4: + case GL_LUMINANCE8: + case GL_LUMINANCE12: + case GL_LUMINANCE16: + return GL_LUMINANCE; + case 2: + case GL_LUMINANCE_ALPHA: + case GL_LUMINANCE4_ALPHA4: + case GL_LUMINANCE6_ALPHA2: + case GL_LUMINANCE8_ALPHA8: + case GL_LUMINANCE12_ALPHA4: + case GL_LUMINANCE12_ALPHA12: + case GL_LUMINANCE16_ALPHA16: + return GL_LUMINANCE_ALPHA; + case GL_INTENSITY: + case GL_INTENSITY4: + case GL_INTENSITY8: + case GL_INTENSITY12: + case GL_INTENSITY16: + return GL_INTENSITY; + case 3: + case GL_RGB: + case GL_R3_G3_B2: + case GL_RGB4: + case GL_RGB5: + case GL_RGB8: + case GL_RGB10: + case GL_RGB12: + case GL_RGB16: + return GL_RGB; + case 4: + case GL_RGBA: + case GL_RGBA2: + case GL_RGBA4: + case GL_RGB5_A1: + case GL_RGBA8: + case GL_RGB10_A2: + case GL_RGBA12: + case GL_RGBA16: + return GL_RGBA; + default: + ; /* fallthrough */ + } + + if (ctx->Extensions.EXT_texture_format_BGRA8888) { + switch (internalFormat) { + case GL_BGRA_EXT: + return GL_RGBA; + default: + ; /* fallthrough */ + } + } + + if (ctx->Extensions.ARB_depth_texture) { + switch (internalFormat) { + case GL_DEPTH_COMPONENT: + case GL_DEPTH_COMPONENT16: + case GL_DEPTH_COMPONENT24: + case GL_DEPTH_COMPONENT32: + return GL_DEPTH_COMPONENT; + default: + ; /* fallthrough */ + } + } + + switch (internalFormat) { + case GL_COMPRESSED_ALPHA: + return GL_ALPHA; + case GL_COMPRESSED_LUMINANCE: + return GL_LUMINANCE; + case GL_COMPRESSED_LUMINANCE_ALPHA: + return GL_LUMINANCE_ALPHA; + case GL_COMPRESSED_INTENSITY: + return GL_INTENSITY; + case GL_COMPRESSED_RGB: + return GL_RGB; + case GL_COMPRESSED_RGBA: + return GL_RGBA; + default: + ; /* fallthrough */ + } + + if (ctx->Extensions.TDFX_texture_compression_FXT1) { + switch (internalFormat) { + case GL_COMPRESSED_RGB_FXT1_3DFX: + return GL_RGB; + case GL_COMPRESSED_RGBA_FXT1_3DFX: + return GL_RGBA; + default: + ; /* fallthrough */ + } + } + + if (ctx->Extensions.EXT_texture_compression_s3tc) { + switch (internalFormat) { + case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: + return GL_RGB; + case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: + case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: + case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: + return GL_RGBA; + default: + ; /* fallthrough */ + } + } + + if (ctx->Extensions.S3_s3tc) { + switch (internalFormat) { + case GL_RGB_S3TC: + case GL_RGB4_S3TC: + return GL_RGB; + case GL_RGBA_S3TC: + case GL_RGBA4_S3TC: + return GL_RGBA; + default: + ; /* fallthrough */ + } + } + + if (ctx->Extensions.MESA_ycbcr_texture) { + if (internalFormat == GL_YCBCR_MESA) + return GL_YCBCR_MESA; + } + + if (ctx->Extensions.ARB_texture_float) { + switch (internalFormat) { + case GL_ALPHA16F_ARB: + case GL_ALPHA32F_ARB: + return GL_ALPHA; + case GL_RGBA16F_ARB: + case GL_RGBA32F_ARB: + return GL_RGBA; + case GL_RGB16F_ARB: + case GL_RGB32F_ARB: + return GL_RGB; + case GL_INTENSITY16F_ARB: + case GL_INTENSITY32F_ARB: + return GL_INTENSITY; + case GL_LUMINANCE16F_ARB: + case GL_LUMINANCE32F_ARB: + return GL_LUMINANCE; + case GL_LUMINANCE_ALPHA16F_ARB: + case GL_LUMINANCE_ALPHA32F_ARB: + return GL_LUMINANCE_ALPHA; + default: + ; /* fallthrough */ + } + } + + if (ctx->Extensions.ATI_envmap_bumpmap) { + switch (internalFormat) { + case GL_DUDV_ATI: + case GL_DU8DV8_ATI: + return GL_DUDV_ATI; + default: + ; /* fallthrough */ + } + } + + if (ctx->Extensions.EXT_texture_snorm) { + switch (internalFormat) { + case GL_RED_SNORM: + case GL_R8_SNORM: + case GL_R16_SNORM: + return GL_RED; + case GL_RG_SNORM: + case GL_RG8_SNORM: + case GL_RG16_SNORM: + return GL_RG; + case GL_RGB_SNORM: + case GL_RGB8_SNORM: + case GL_RGB16_SNORM: + return GL_RGB; + case GL_RGBA_SNORM: + case GL_RGBA8_SNORM: + case GL_RGBA16_SNORM: + return GL_RGBA; + case GL_ALPHA_SNORM: + case GL_ALPHA8_SNORM: + case GL_ALPHA16_SNORM: + return GL_ALPHA; + case GL_LUMINANCE_SNORM: + case GL_LUMINANCE8_SNORM: + case GL_LUMINANCE16_SNORM: + return GL_LUMINANCE; + case GL_LUMINANCE_ALPHA_SNORM: + case GL_LUMINANCE8_ALPHA8_SNORM: + case GL_LUMINANCE16_ALPHA16_SNORM: + return GL_LUMINANCE_ALPHA; + case GL_INTENSITY_SNORM: + case GL_INTENSITY8_SNORM: + case GL_INTENSITY16_SNORM: + return GL_INTENSITY; + default: + ; /* fallthrough */ + } + } + + if (ctx->Extensions.EXT_packed_depth_stencil) { + switch (internalFormat) { + case GL_DEPTH_STENCIL_EXT: + case GL_DEPTH24_STENCIL8_EXT: + return GL_DEPTH_STENCIL_EXT; + default: + ; /* fallthrough */ + } + } + +#if FEATURE_EXT_texture_sRGB + if (ctx->Extensions.EXT_texture_sRGB) { + switch (internalFormat) { + case GL_SRGB_EXT: + case GL_SRGB8_EXT: + case GL_COMPRESSED_SRGB_EXT: + case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT: + return GL_RGB; + case GL_SRGB_ALPHA_EXT: + case GL_SRGB8_ALPHA8_EXT: + case GL_COMPRESSED_SRGB_ALPHA_EXT: + case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: + case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: + case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: + return GL_RGBA; + case GL_SLUMINANCE_ALPHA_EXT: + case GL_SLUMINANCE8_ALPHA8_EXT: + case GL_COMPRESSED_SLUMINANCE_ALPHA_EXT: + return GL_LUMINANCE_ALPHA; + case GL_SLUMINANCE_EXT: + case GL_SLUMINANCE8_EXT: + case GL_COMPRESSED_SLUMINANCE_EXT: + return GL_LUMINANCE; + default: + ; /* fallthrough */ + } + } +#endif /* FEATURE_EXT_texture_sRGB */ + + if (ctx->Extensions.EXT_texture_integer) { + switch (internalFormat) { + case GL_RGBA8UI_EXT: + case GL_RGBA16UI_EXT: + case GL_RGBA32UI_EXT: + case GL_RGBA8I_EXT: + case GL_RGBA16I_EXT: + case GL_RGBA32I_EXT: + return GL_RGBA; + case GL_RGB8UI_EXT: + case GL_RGB16UI_EXT: + case GL_RGB32UI_EXT: + case GL_RGB8I_EXT: + case GL_RGB16I_EXT: + case GL_RGB32I_EXT: + return GL_RGB; + case GL_ALPHA8UI_EXT: + case GL_ALPHA16UI_EXT: + case GL_ALPHA32UI_EXT: + case GL_ALPHA8I_EXT: + case GL_ALPHA16I_EXT: + case GL_ALPHA32I_EXT: + return GL_ALPHA; + case GL_INTENSITY8UI_EXT: + case GL_INTENSITY16UI_EXT: + case GL_INTENSITY32UI_EXT: + case GL_INTENSITY8I_EXT: + case GL_INTENSITY16I_EXT: + case GL_INTENSITY32I_EXT: + return GL_INTENSITY; + case GL_LUMINANCE8UI_EXT: + case GL_LUMINANCE16UI_EXT: + case GL_LUMINANCE32UI_EXT: + case GL_LUMINANCE8I_EXT: + case GL_LUMINANCE16I_EXT: + case GL_LUMINANCE32I_EXT: + return GL_LUMINANCE; + case GL_LUMINANCE_ALPHA8UI_EXT: + case GL_LUMINANCE_ALPHA16UI_EXT: + case GL_LUMINANCE_ALPHA32UI_EXT: + case GL_LUMINANCE_ALPHA8I_EXT: + case GL_LUMINANCE_ALPHA16I_EXT: + case GL_LUMINANCE_ALPHA32I_EXT: + return GL_LUMINANCE_ALPHA; + default: + ; /* fallthrough */ + } + } + + if (ctx->Extensions.ARB_texture_rg) { + switch (internalFormat) { + case GL_R16F: + /* R16F depends on both ARB_half_float_pixel and ARB_texture_float. + */ + if (!ctx->Extensions.ARB_half_float_pixel) + break; + /* FALLTHROUGH */ + case GL_R32F: + if (!ctx->Extensions.ARB_texture_float) + break; + return GL_RED; + case GL_R8I: + case GL_R8UI: + case GL_R16I: + case GL_R16UI: + case GL_R32I: + case GL_R32UI: + if (!ctx->Extensions.EXT_texture_integer) + break; + /* FALLTHROUGH */ + case GL_R8: + case GL_R16: + case GL_RED: + case GL_COMPRESSED_RED: + return GL_RED; + + case GL_RG16F: + /* RG16F depends on both ARB_half_float_pixel and ARB_texture_float. + */ + if (!ctx->Extensions.ARB_half_float_pixel) + break; + /* FALLTHROUGH */ + case GL_RG32F: + if (!ctx->Extensions.ARB_texture_float) + break; + return GL_RG; + case GL_RG8I: + case GL_RG8UI: + case GL_RG16I: + case GL_RG16UI: + case GL_RG32I: + case GL_RG32UI: + if (!ctx->Extensions.EXT_texture_integer) + break; + /* FALLTHROUGH */ + case GL_RG: + case GL_RG8: + case GL_RG16: + case GL_COMPRESSED_RG: + return GL_RG; + default: + ; /* fallthrough */ + } + } + + if (ctx->Extensions.EXT_texture_shared_exponent) { + switch (internalFormat) { + case GL_RGB9_E5_EXT: + return GL_RGB; + default: + ; /* fallthrough */ + } + } + + if (ctx->Extensions.EXT_packed_float) { + switch (internalFormat) { + case GL_R11F_G11F_B10F_EXT: + return GL_RGB; + default: + ; /* fallthrough */ + } + } + + if (ctx->Extensions.ARB_depth_buffer_float) { + switch (internalFormat) { + case GL_DEPTH_COMPONENT32F: + return GL_DEPTH_COMPONENT; + case GL_DEPTH32F_STENCIL8: + return GL_DEPTH_STENCIL; + default: + ; /* fallthrough */ + } + } + + if (ctx->Extensions.ARB_texture_compression_rgtc) { + switch (internalFormat) { + case GL_COMPRESSED_RED_RGTC1: + case GL_COMPRESSED_SIGNED_RED_RGTC1: + return GL_RED; + case GL_COMPRESSED_RG_RGTC2: + case GL_COMPRESSED_SIGNED_RG_RGTC2: + return GL_RG; + default: + ; /* fallthrough */ + } + } + + if (ctx->Extensions.EXT_texture_compression_latc) { + switch (internalFormat) { + case GL_COMPRESSED_LUMINANCE_LATC1_EXT: + case GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT: + return GL_LUMINANCE; + case GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT: + case GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT: + return GL_LUMINANCE_ALPHA; + default: + ; /* fallthrough */ + } + } + + if (ctx->Extensions.ATI_texture_compression_3dc) { + switch (internalFormat) { + case GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI: + return GL_LUMINANCE_ALPHA; + default: + ; /* fallthrough */ + } + } + + return -1; /* error */ +} + + +/** + * For cube map faces, return a face index in [0,5]. + * For other targets return 0; + */ +GLuint +_mesa_tex_target_to_face(GLenum target) +{ + if (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB && + target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB) + return (GLuint) target - (GLuint) GL_TEXTURE_CUBE_MAP_POSITIVE_X; + else + return 0; +} + + + +/** + * Store a gl_texture_image pointer in a gl_texture_object structure + * according to the target and level parameters. + * + * \param tObj texture object. + * \param target texture target. + * \param level image level. + * \param texImage texture image. + */ +void +_mesa_set_tex_image(struct gl_texture_object *tObj, + GLenum target, GLint level, + struct gl_texture_image *texImage) +{ + const GLuint face = _mesa_tex_target_to_face(target); + + ASSERT(tObj); + ASSERT(texImage); + ASSERT(target != GL_TEXTURE_RECTANGLE_NV || level == 0); + + tObj->Image[face][level] = texImage; + + /* Set the 'back' pointer */ + texImage->TexObject = tObj; + texImage->Level = level; + texImage->Face = face; +} + + +/** + * Allocate a texture image structure. + * + * Called via ctx->Driver.NewTextureImage() unless overriden by a device + * driver. + * + * \return a pointer to gl_texture_image struct with all fields initialized to + * zero. + */ +struct gl_texture_image * +_mesa_new_texture_image( struct gl_context *ctx ) +{ + (void) ctx; + return CALLOC_STRUCT(gl_texture_image); +} + + +/** + * Free texture image data. + * This function is a fallback called via ctx->Driver.FreeTextureImageBuffer(). + * + * \param texImage texture image. + * + * Free the texture image data if it's not marked as client data. + */ +void +_mesa_free_texture_image_data(struct gl_context *ctx, + struct gl_texture_image *texImage) +{ + (void) ctx; + + if (texImage->Data && !texImage->IsClientData) { + /* free the old texture data */ + _mesa_free_texmemory(texImage->Data); + } + + texImage->Data = NULL; +} + + +/** + * Free texture image. + * + * \param texImage texture image. + * + * Free the texture image structure and the associated image data. + */ +void +_mesa_delete_texture_image(struct gl_context *ctx, + struct gl_texture_image *texImage) +{ + /* Free texImage->Data and/or any other driver-specific texture + * image storage. + */ + ASSERT(ctx->Driver.FreeTextureImageBuffer); + ctx->Driver.FreeTextureImageBuffer( ctx, texImage ); + + ASSERT(texImage->Data == NULL); + if (texImage->ImageOffsets) + free(texImage->ImageOffsets); + free(texImage); +} + + +/** + * Test if a target is a proxy target. + * + * \param target texture target. + * + * \return GL_TRUE if the target is a proxy target, GL_FALSE otherwise. + */ +GLboolean +_mesa_is_proxy_texture(GLenum target) +{ + /* NUM_TEXTURE_TARGETS should match number of terms below, + * except there's no proxy for GL_TEXTURE_BUFFER. + */ + assert(NUM_TEXTURE_TARGETS == 8); + + return (target == GL_PROXY_TEXTURE_1D || + target == GL_PROXY_TEXTURE_2D || + target == GL_PROXY_TEXTURE_3D || + target == GL_PROXY_TEXTURE_CUBE_MAP_ARB || + target == GL_PROXY_TEXTURE_RECTANGLE_NV || + target == GL_PROXY_TEXTURE_1D_ARRAY_EXT || + target == GL_PROXY_TEXTURE_2D_ARRAY_EXT); +} + + +/** + * Return the proxy target which corresponds to the given texture target + */ +static GLenum +get_proxy_target(GLenum target) +{ + switch (target) { + case GL_TEXTURE_1D: + case GL_PROXY_TEXTURE_1D: + return GL_PROXY_TEXTURE_1D; + case GL_TEXTURE_2D: + case GL_PROXY_TEXTURE_2D: + return GL_PROXY_TEXTURE_2D; + case GL_TEXTURE_3D: + case GL_PROXY_TEXTURE_3D: + return GL_PROXY_TEXTURE_3D; + case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB: + case GL_TEXTURE_CUBE_MAP_ARB: + case GL_PROXY_TEXTURE_CUBE_MAP_ARB: + return GL_PROXY_TEXTURE_CUBE_MAP_ARB; + case GL_TEXTURE_RECTANGLE_NV: + case GL_PROXY_TEXTURE_RECTANGLE_NV: + return GL_PROXY_TEXTURE_RECTANGLE_NV; + case GL_TEXTURE_1D_ARRAY_EXT: + case GL_PROXY_TEXTURE_1D_ARRAY_EXT: + return GL_PROXY_TEXTURE_1D_ARRAY_EXT; + case GL_TEXTURE_2D_ARRAY_EXT: + case GL_PROXY_TEXTURE_2D_ARRAY_EXT: + return GL_PROXY_TEXTURE_2D_ARRAY_EXT; + default: + _mesa_problem(NULL, "unexpected target in get_proxy_target()"); + return 0; + } +} + + +/** + * Get the texture object that corresponds to the target of the given + * texture unit. The target should have already been checked for validity. + * + * \param ctx GL context. + * \param texUnit texture unit. + * \param target texture target. + * + * \return pointer to the texture object on success, or NULL on failure. + */ +struct gl_texture_object * +_mesa_select_tex_object(struct gl_context *ctx, + const struct gl_texture_unit *texUnit, + GLenum target) +{ + const GLboolean arrayTex = (ctx->Extensions.MESA_texture_array || + ctx->Extensions.EXT_texture_array); + + switch (target) { + case GL_TEXTURE_1D: + return texUnit->CurrentTex[TEXTURE_1D_INDEX]; + case GL_PROXY_TEXTURE_1D: + return ctx->Texture.ProxyTex[TEXTURE_1D_INDEX]; + case GL_TEXTURE_2D: + return texUnit->CurrentTex[TEXTURE_2D_INDEX]; + case GL_PROXY_TEXTURE_2D: + return ctx->Texture.ProxyTex[TEXTURE_2D_INDEX]; + case GL_TEXTURE_3D: + return texUnit->CurrentTex[TEXTURE_3D_INDEX]; + case GL_PROXY_TEXTURE_3D: + return ctx->Texture.ProxyTex[TEXTURE_3D_INDEX]; + case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB: + case GL_TEXTURE_CUBE_MAP_ARB: + return ctx->Extensions.ARB_texture_cube_map + ? texUnit->CurrentTex[TEXTURE_CUBE_INDEX] : NULL; + case GL_PROXY_TEXTURE_CUBE_MAP_ARB: + return ctx->Extensions.ARB_texture_cube_map + ? ctx->Texture.ProxyTex[TEXTURE_CUBE_INDEX] : NULL; + case GL_TEXTURE_RECTANGLE_NV: + return ctx->Extensions.NV_texture_rectangle + ? texUnit->CurrentTex[TEXTURE_RECT_INDEX] : NULL; + case GL_PROXY_TEXTURE_RECTANGLE_NV: + return ctx->Extensions.NV_texture_rectangle + ? ctx->Texture.ProxyTex[TEXTURE_RECT_INDEX] : NULL; + case GL_TEXTURE_1D_ARRAY_EXT: + return arrayTex ? texUnit->CurrentTex[TEXTURE_1D_ARRAY_INDEX] : NULL; + case GL_PROXY_TEXTURE_1D_ARRAY_EXT: + return arrayTex ? ctx->Texture.ProxyTex[TEXTURE_1D_ARRAY_INDEX] : NULL; + case GL_TEXTURE_2D_ARRAY_EXT: + return arrayTex ? texUnit->CurrentTex[TEXTURE_2D_ARRAY_INDEX] : NULL; + case GL_PROXY_TEXTURE_2D_ARRAY_EXT: + return arrayTex ? ctx->Texture.ProxyTex[TEXTURE_2D_ARRAY_INDEX] : NULL; + case GL_TEXTURE_BUFFER: + return ctx->Extensions.ARB_texture_buffer_object + ? texUnit->CurrentTex[TEXTURE_BUFFER_INDEX] : NULL; + default: + _mesa_problem(NULL, "bad target in _mesa_select_tex_object()"); + return NULL; + } +} + + +/** + * Return pointer to texture object for given target on current texture unit. + */ +struct gl_texture_object * +_mesa_get_current_tex_object(struct gl_context *ctx, GLenum target) +{ + struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx); + return _mesa_select_tex_object(ctx, texUnit, target); +} + + +/** + * Get a texture image pointer from a texture object, given a texture + * target and mipmap level. The target and level parameters should + * have already been error-checked. + * + * \param ctx GL context. + * \param texObj texture unit. + * \param target texture target. + * \param level image level. + * + * \return pointer to the texture image structure, or NULL on failure. + */ +struct gl_texture_image * +_mesa_select_tex_image(struct gl_context *ctx, + const struct gl_texture_object *texObj, + GLenum target, GLint level) +{ + const GLuint face = _mesa_tex_target_to_face(target); + + ASSERT(texObj); + ASSERT(level >= 0); + ASSERT(level < MAX_TEXTURE_LEVELS); + + return texObj->Image[face][level]; +} + + +/** + * Like _mesa_select_tex_image() but if the image doesn't exist, allocate + * it and install it. Only return NULL if passed a bad parameter or run + * out of memory. + */ +struct gl_texture_image * +_mesa_get_tex_image(struct gl_context *ctx, struct gl_texture_object *texObj, + GLenum target, GLint level) +{ + struct gl_texture_image *texImage; + + if (!texObj) + return NULL; + + texImage = _mesa_select_tex_image(ctx, texObj, target, level); + if (!texImage) { + texImage = ctx->Driver.NewTextureImage(ctx); + if (!texImage) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "texture image allocation"); + return NULL; + } + + _mesa_set_tex_image(texObj, target, level, texImage); + } + + return texImage; +} + + +/** + * Return pointer to the specified proxy texture image. + * Note that proxy textures are per-context, not per-texture unit. + * \return pointer to texture image or NULL if invalid target, invalid + * level, or out of memory. + */ +struct gl_texture_image * +_mesa_get_proxy_tex_image(struct gl_context *ctx, GLenum target, GLint level) +{ + struct gl_texture_image *texImage; + GLuint texIndex; + + if (level < 0 ) + return NULL; + + switch (target) { + case GL_PROXY_TEXTURE_1D: + if (level >= ctx->Const.MaxTextureLevels) + return NULL; + texIndex = TEXTURE_1D_INDEX; + break; + case GL_PROXY_TEXTURE_2D: + if (level >= ctx->Const.MaxTextureLevels) + return NULL; + texIndex = TEXTURE_2D_INDEX; + break; + case GL_PROXY_TEXTURE_3D: + if (level >= ctx->Const.Max3DTextureLevels) + return NULL; + texIndex = TEXTURE_3D_INDEX; + break; + case GL_PROXY_TEXTURE_CUBE_MAP: + if (level >= ctx->Const.MaxCubeTextureLevels) + return NULL; + texIndex = TEXTURE_CUBE_INDEX; + break; + case GL_PROXY_TEXTURE_RECTANGLE_NV: + if (level > 0) + return NULL; + texIndex = TEXTURE_RECT_INDEX; + break; + case GL_PROXY_TEXTURE_1D_ARRAY_EXT: + if (level >= ctx->Const.MaxTextureLevels) + return NULL; + texIndex = TEXTURE_1D_ARRAY_INDEX; + break; + case GL_PROXY_TEXTURE_2D_ARRAY_EXT: + if (level >= ctx->Const.MaxTextureLevels) + return NULL; + texIndex = TEXTURE_2D_ARRAY_INDEX; + break; + default: + return NULL; + } + + texImage = ctx->Texture.ProxyTex[texIndex]->Image[0][level]; + if (!texImage) { + texImage = ctx->Driver.NewTextureImage(ctx); + if (!texImage) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "proxy texture allocation"); + return NULL; + } + ctx->Texture.ProxyTex[texIndex]->Image[0][level] = texImage; + /* Set the 'back' pointer */ + texImage->TexObject = ctx->Texture.ProxyTex[texIndex]; + } + return texImage; +} + + +/** + * Get the maximum number of allowed mipmap levels. + * + * \param ctx GL context. + * \param target texture target. + * + * \return the maximum number of allowed mipmap levels for the given + * texture target, or zero if passed a bad target. + * + * \sa gl_constants. + */ +GLint +_mesa_max_texture_levels(struct gl_context *ctx, GLenum target) +{ + switch (target) { + case GL_TEXTURE_1D: + case GL_PROXY_TEXTURE_1D: + case GL_TEXTURE_2D: + case GL_PROXY_TEXTURE_2D: + return ctx->Const.MaxTextureLevels; + case GL_TEXTURE_3D: + case GL_PROXY_TEXTURE_3D: + return ctx->Const.Max3DTextureLevels; + case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB: + case GL_TEXTURE_CUBE_MAP_ARB: + case GL_PROXY_TEXTURE_CUBE_MAP_ARB: + return ctx->Extensions.ARB_texture_cube_map + ? ctx->Const.MaxCubeTextureLevels : 0; + case GL_TEXTURE_RECTANGLE_NV: + case GL_PROXY_TEXTURE_RECTANGLE_NV: + return ctx->Extensions.NV_texture_rectangle ? 1 : 0; + case GL_TEXTURE_1D_ARRAY_EXT: + case GL_PROXY_TEXTURE_1D_ARRAY_EXT: + case GL_TEXTURE_2D_ARRAY_EXT: + case GL_PROXY_TEXTURE_2D_ARRAY_EXT: + return (ctx->Extensions.MESA_texture_array || + ctx->Extensions.EXT_texture_array) + ? ctx->Const.MaxTextureLevels : 0; + case GL_TEXTURE_BUFFER: + /* fall-through */ + default: + return 0; /* bad target */ + } +} + + +/** + * Return number of dimensions per mipmap level for the given texture target. + */ +GLint +_mesa_get_texture_dimensions(GLenum target) +{ + switch (target) { + case GL_TEXTURE_1D: + case GL_PROXY_TEXTURE_1D: + return 1; + case GL_TEXTURE_2D: + case GL_TEXTURE_RECTANGLE: + case GL_TEXTURE_CUBE_MAP: + case GL_PROXY_TEXTURE_2D: + case GL_PROXY_TEXTURE_RECTANGLE: + case GL_PROXY_TEXTURE_CUBE_MAP: + case GL_TEXTURE_CUBE_MAP_POSITIVE_X: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: + case GL_TEXTURE_1D_ARRAY: + case GL_PROXY_TEXTURE_1D_ARRAY: + return 2; + case GL_TEXTURE_3D: + case GL_PROXY_TEXTURE_3D: + case GL_TEXTURE_2D_ARRAY: + case GL_PROXY_TEXTURE_2D_ARRAY: + return 3; + case GL_TEXTURE_BUFFER: + /* fall-through */ + default: + _mesa_problem(NULL, "invalid target 0x%x in get_texture_dimensions()", + target); + return 2; + } +} + + + + +#if 000 /* not used anymore */ +/* + * glTexImage[123]D can accept a NULL image pointer. In this case we + * create a texture image with unspecified image contents per the OpenGL + * spec. + */ +static GLubyte * +make_null_texture(GLint width, GLint height, GLint depth, GLenum format) +{ + const GLint components = _mesa_components_in_format(format); + const GLint numPixels = width * height * depth; + GLubyte *data = (GLubyte *) MALLOC(numPixels * components * sizeof(GLubyte)); + +#ifdef DEBUG + /* + * Let's see if anyone finds this. If glTexImage2D() is called with + * a NULL image pointer then load the texture image with something + * interesting instead of leaving it indeterminate. + */ + if (data) { + static const char message[8][32] = { + " X X XXXXX XXX X ", + " XX XX X X X X X ", + " X X X X X X X ", + " X X XXXX XXX XXXXX ", + " X X X X X X ", + " X X X X X X X ", + " X X XXXXX XXX X X ", + " " + }; + + GLubyte *imgPtr = data; + GLint h, i, j, k; + for (h = 0; h < depth; h++) { + for (i = 0; i < height; i++) { + GLint srcRow = 7 - (i % 8); + for (j = 0; j < width; j++) { + GLint srcCol = j % 32; + GLubyte texel = (message[srcRow][srcCol]=='X') ? 255 : 70; + for (k = 0; k < components; k++) { + *imgPtr++ = texel; + } + } + } + } + } +#endif + + return data; +} +#endif + + + +/** + * Reset the fields of a gl_texture_image struct to zero. + * + * \param img texture image structure. + * + * This is called when a proxy texture test fails, we set all the + * image members (except DriverData) to zero. + * It's also used in glTexImage[123]D as a safeguard to be sure all + * required fields get initialized properly by the Driver.TexImage[123]D + * functions. + */ +static void +clear_teximage_fields(struct gl_texture_image *img) +{ + ASSERT(img); + img->_BaseFormat = 0; + img->InternalFormat = 0; + img->Border = 0; + img->Width = 0; + img->Height = 0; + img->Depth = 0; + img->RowStride = 0; + if (img->ImageOffsets) { + free(img->ImageOffsets); + img->ImageOffsets = NULL; + } + img->Width2 = 0; + img->Height2 = 0; + img->Depth2 = 0; + img->WidthLog2 = 0; + img->HeightLog2 = 0; + img->DepthLog2 = 0; + img->Data = NULL; + img->TexFormat = MESA_FORMAT_NONE; + img->FetchTexelc = NULL; + img->FetchTexelf = NULL; +} + + +/** + * Initialize basic fields of the gl_texture_image struct. + * + * \param ctx GL context. + * \param target texture target (GL_TEXTURE_1D, GL_TEXTURE_RECTANGLE, etc). + * \param img texture image structure to be initialized. + * \param width image width. + * \param height image height. + * \param depth image depth. + * \param border image border. + * \param internalFormat internal format. + * \param format the actual hardware format (one of MESA_FORMAT_*) + * + * Fills in the fields of \p img with the given information. + * Note: width, height and depth include the border. + */ +void +_mesa_init_teximage_fields(struct gl_context *ctx, GLenum target, + struct gl_texture_image *img, + GLsizei width, GLsizei height, GLsizei depth, + GLint border, GLenum internalFormat, + gl_format format) +{ + GLint i, dims; + + ASSERT(img); + ASSERT(width >= 0); + ASSERT(height >= 0); + ASSERT(depth >= 0); + + img->_BaseFormat = _mesa_base_tex_format( ctx, internalFormat ); + ASSERT(img->_BaseFormat > 0); + img->InternalFormat = internalFormat; + img->Border = border; + img->Width = width; + img->Height = height; + img->Depth = depth; + + img->Width2 = width - 2 * border; /* == 1 << img->WidthLog2; */ + img->WidthLog2 = _mesa_logbase2(img->Width2); + + if (height == 1) { /* 1-D texture */ + img->Height2 = 1; + img->HeightLog2 = 0; + } + else { + img->Height2 = height - 2 * border; /* == 1 << img->HeightLog2; */ + img->HeightLog2 = _mesa_logbase2(img->Height2); + } + + if (depth == 1) { /* 2-D texture */ + img->Depth2 = 1; + img->DepthLog2 = 0; + } + else { + img->Depth2 = depth - 2 * border; /* == 1 << img->DepthLog2; */ + img->DepthLog2 = _mesa_logbase2(img->Depth2); + } + + img->MaxLog2 = MAX2(img->WidthLog2, img->HeightLog2); + + if ((width == 1 || _mesa_is_pow_two(img->Width2)) && + (height == 1 || _mesa_is_pow_two(img->Height2)) && + (depth == 1 || _mesa_is_pow_two(img->Depth2))) + img->_IsPowerOfTwo = GL_TRUE; + else + img->_IsPowerOfTwo = GL_FALSE; + + /* RowStride and ImageOffsets[] describe how to address texels in 'Data' */ + img->RowStride = width; + /* Allocate the ImageOffsets array and initialize to typical values. + * We allocate the array for 1D/2D textures too in order to avoid special- + * case code in the texstore routines. + */ + if (img->ImageOffsets) + free(img->ImageOffsets); + img->ImageOffsets = (GLuint *) malloc(depth * sizeof(GLuint)); + for (i = 0; i < depth; i++) { + img->ImageOffsets[i] = i * width * height; + } + + /* Compute Width/Height/DepthScale for mipmap lod computation */ + if (target == GL_TEXTURE_RECTANGLE_NV) { + /* scale = 1.0 since texture coords directly map to texels */ + img->WidthScale = 1.0; + img->HeightScale = 1.0; + img->DepthScale = 1.0; + } + else { + img->WidthScale = (GLfloat) img->Width; + img->HeightScale = (GLfloat) img->Height; + img->DepthScale = (GLfloat) img->Depth; + } + + img->TexFormat = format; + + dims = _mesa_get_texture_dimensions(target); + + _mesa_set_fetch_functions(img, dims); +} + + +/** + * Free and clear fields of the gl_texture_image struct. + * + * \param ctx GL context. + * \param texImage texture image structure to be cleared. + * + * After the call, \p texImage will have no data associated with it. Its + * fields are cleared so that its parent object will test incomplete. + */ +void +_mesa_clear_texture_image(struct gl_context *ctx, + struct gl_texture_image *texImage) +{ + ctx->Driver.FreeTextureImageBuffer(ctx, texImage); + clear_teximage_fields(texImage); +} + + +/** + * This is the fallback for Driver.TestProxyTexImage(). Test the texture + * level, width, height and depth against the ctx->Const limits for textures. + * + * A hardware driver might override this function if, for example, the + * max 3D texture size is 512x512x64 (i.e. not a cube). + * + * Note that width, height, depth == 0 is not an error. However, a + * texture with zero width/height/depth will be considered "incomplete" + * and texturing will effectively be disabled. + * + * \param target one of GL_PROXY_TEXTURE_1D, GL_PROXY_TEXTURE_2D, + * GL_PROXY_TEXTURE_3D, GL_PROXY_TEXTURE_RECTANGLE_NV, + * GL_PROXY_TEXTURE_CUBE_MAP_ARB. + * \param level as passed to glTexImage + * \param internalFormat as passed to glTexImage + * \param format as passed to glTexImage + * \param type as passed to glTexImage + * \param width as passed to glTexImage + * \param height as passed to glTexImage + * \param depth as passed to glTexImage + * \param border as passed to glTexImage + * \return GL_TRUE if the image is acceptable, GL_FALSE if not acceptable. + */ +GLboolean +_mesa_test_proxy_teximage(struct gl_context *ctx, GLenum target, GLint level, + GLint internalFormat, GLenum format, GLenum type, + GLint width, GLint height, GLint depth, GLint border) +{ + GLint maxSize; + + (void) internalFormat; + (void) format; + (void) type; + + switch (target) { + case GL_PROXY_TEXTURE_1D: + maxSize = 1 << (ctx->Const.MaxTextureLevels - 1); + if (width < 2 * border || width > 2 + maxSize) + return GL_FALSE; + if (level >= ctx->Const.MaxTextureLevels) + return GL_FALSE; + if (!ctx->Extensions.ARB_texture_non_power_of_two) { + if (width > 0 && !_mesa_is_pow_two(width - 2 * border)) + return GL_FALSE; + } + return GL_TRUE; + + case GL_PROXY_TEXTURE_2D: + maxSize = 1 << (ctx->Const.MaxTextureLevels - 1); + if (width < 2 * border || width > 2 + maxSize) + return GL_FALSE; + if (height < 2 * border || height > 2 + maxSize) + return GL_FALSE; + if (level >= ctx->Const.MaxTextureLevels) + return GL_FALSE; + if (!ctx->Extensions.ARB_texture_non_power_of_two) { + if (width > 0 && !_mesa_is_pow_two(width - 2 * border)) + return GL_FALSE; + if (height > 0 && !_mesa_is_pow_two(height - 2 * border)) + return GL_FALSE; + } + return GL_TRUE; + + case GL_PROXY_TEXTURE_3D: + maxSize = 1 << (ctx->Const.Max3DTextureLevels - 1); + if (width < 2 * border || width > 2 + maxSize) + return GL_FALSE; + if (height < 2 * border || height > 2 + maxSize) + return GL_FALSE; + if (depth < 2 * border || depth > 2 + maxSize) + return GL_FALSE; + if (level >= ctx->Const.Max3DTextureLevels) + return GL_FALSE; + if (!ctx->Extensions.ARB_texture_non_power_of_two) { + if (width > 0 && !_mesa_is_pow_two(width - 2 * border)) + return GL_FALSE; + if (height > 0 && !_mesa_is_pow_two(height - 2 * border)) + return GL_FALSE; + if (depth > 0 && !_mesa_is_pow_two(depth - 2 * border)) + return GL_FALSE; + } + return GL_TRUE; + + case GL_PROXY_TEXTURE_RECTANGLE_NV: + maxSize = ctx->Const.MaxTextureRectSize; + if (width < 0 || width > maxSize) + return GL_FALSE; + if (height < 0 || height > maxSize) + return GL_FALSE; + if (level != 0) + return GL_FALSE; + return GL_TRUE; + + case GL_PROXY_TEXTURE_CUBE_MAP_ARB: + maxSize = 1 << (ctx->Const.MaxCubeTextureLevels - 1); + if (width < 2 * border || width > 2 + maxSize) + return GL_FALSE; + if (height < 2 * border || height > 2 + maxSize) + return GL_FALSE; + if (level >= ctx->Const.MaxCubeTextureLevels) + return GL_FALSE; + if (!ctx->Extensions.ARB_texture_non_power_of_two) { + if (width > 0 && !_mesa_is_pow_two(width - 2 * border)) + return GL_FALSE; + if (height > 0 && !_mesa_is_pow_two(height - 2 * border)) + return GL_FALSE; + } + return GL_TRUE; + + case GL_PROXY_TEXTURE_1D_ARRAY_EXT: + maxSize = 1 << (ctx->Const.MaxTextureLevels - 1); + if (width < 2 * border || width > 2 + maxSize) + return GL_FALSE; + if (height < 1 || height > ctx->Const.MaxArrayTextureLayers) + return GL_FALSE; + if (level >= ctx->Const.MaxTextureLevels) + return GL_FALSE; + if (!ctx->Extensions.ARB_texture_non_power_of_two) { + if (width > 0 && !_mesa_is_pow_two(width - 2 * border)) + return GL_FALSE; + } + return GL_TRUE; + + case GL_PROXY_TEXTURE_2D_ARRAY_EXT: + maxSize = 1 << (ctx->Const.MaxTextureLevels - 1); + if (width < 2 * border || width > 2 + maxSize) + return GL_FALSE; + if (height < 2 * border || height > 2 + maxSize) + return GL_FALSE; + if (depth < 1 || depth > ctx->Const.MaxArrayTextureLayers) + return GL_FALSE; + if (level >= ctx->Const.MaxTextureLevels) + return GL_FALSE; + if (!ctx->Extensions.ARB_texture_non_power_of_two) { + if (width > 0 && !_mesa_is_pow_two(width - 2 * border)) + return GL_FALSE; + if (height > 0 && !_mesa_is_pow_two(height - 2 * border)) + return GL_FALSE; + } + return GL_TRUE; + + default: + _mesa_problem(ctx, "Invalid target in _mesa_test_proxy_teximage"); + return GL_FALSE; + } +} + + +/** + * Check if the memory used by the texture would exceed the driver's limit. + * This lets us support a max 3D texture size of 8K (for example) but + * prevents allocating a full 8K x 8K x 8K texture. + * XXX this could be rolled into the proxy texture size test (above) but + * we don't have the actual texture internal format at that point. + */ +static GLboolean +legal_texture_size(struct gl_context *ctx, gl_format format, + GLint width, GLint height, GLint depth) +{ + uint64_t bytes = _mesa_format_image_size64(format, width, height, depth); + uint64_t mbytes = bytes / (1024 * 1024); /* convert to MB */ + return mbytes <= (uint64_t) ctx->Const.MaxTextureMbytes; +} + + + +/** + * Helper function to determine whether a target and specific compression + * format are supported. + */ +static GLboolean +target_can_be_compressed(const struct gl_context *ctx, GLenum target, + GLenum intFormat) +{ + (void) intFormat; /* not used yet */ + + switch (target) { + case GL_TEXTURE_2D: + case GL_PROXY_TEXTURE_2D: + return GL_TRUE; /* true for any compressed format so far */ + case GL_PROXY_TEXTURE_CUBE_MAP: + case GL_TEXTURE_CUBE_MAP_POSITIVE_X: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: + return ctx->Extensions.ARB_texture_cube_map; + case GL_PROXY_TEXTURE_2D_ARRAY_EXT: + case GL_TEXTURE_2D_ARRAY_EXT: + return (ctx->Extensions.MESA_texture_array || + ctx->Extensions.EXT_texture_array); + default: + return GL_FALSE; + } +} + + +/** + * Check if the given texture target value is legal for a + * glTexImage1/2/3D call. + */ +static GLboolean +legal_teximage_target(struct gl_context *ctx, GLuint dims, GLenum target) +{ + switch (dims) { + case 1: + switch (target) { + case GL_TEXTURE_1D: + case GL_PROXY_TEXTURE_1D: + return GL_TRUE; + default: + return GL_FALSE; + } + case 2: + switch (target) { + case GL_TEXTURE_2D: + case GL_PROXY_TEXTURE_2D: + return GL_TRUE; + case GL_PROXY_TEXTURE_CUBE_MAP: + case GL_TEXTURE_CUBE_MAP_POSITIVE_X: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: + return ctx->Extensions.ARB_texture_cube_map; + case GL_TEXTURE_RECTANGLE_NV: + case GL_PROXY_TEXTURE_RECTANGLE_NV: + return ctx->Extensions.NV_texture_rectangle; + case GL_TEXTURE_1D_ARRAY_EXT: + case GL_PROXY_TEXTURE_1D_ARRAY_EXT: + return (ctx->Extensions.MESA_texture_array || + ctx->Extensions.EXT_texture_array); + default: + return GL_FALSE; + } + case 3: + switch (target) { + case GL_TEXTURE_3D: + case GL_PROXY_TEXTURE_3D: + return GL_TRUE; + case GL_TEXTURE_2D_ARRAY_EXT: + case GL_PROXY_TEXTURE_2D_ARRAY_EXT: + return (ctx->Extensions.MESA_texture_array || + ctx->Extensions.EXT_texture_array); + default: + return GL_FALSE; + } + default: + _mesa_problem(ctx, "invalid dims=%u in legal_teximage_target()", dims); + return GL_FALSE; + } +} + + +/** + * Check if the given texture target value is legal for a + * glTexSubImage, glCopyTexSubImage or glCopyTexImage call. + * The difference compared to legal_teximage_target() above is that + * proxy targets are not supported. + */ +static GLboolean +legal_texsubimage_target(struct gl_context *ctx, GLuint dims, GLenum target) +{ + switch (dims) { + case 1: + return target == GL_TEXTURE_1D; + case 2: + switch (target) { + case GL_TEXTURE_2D: + return GL_TRUE; + case GL_TEXTURE_CUBE_MAP_POSITIVE_X: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: + return ctx->Extensions.ARB_texture_cube_map; + case GL_TEXTURE_RECTANGLE_NV: + return ctx->Extensions.NV_texture_rectangle; + case GL_TEXTURE_1D_ARRAY_EXT: + return (ctx->Extensions.MESA_texture_array || + ctx->Extensions.EXT_texture_array); + default: + return GL_FALSE; + } + case 3: + switch (target) { + case GL_TEXTURE_3D: + return GL_TRUE; + case GL_TEXTURE_2D_ARRAY_EXT: + return (ctx->Extensions.MESA_texture_array || + ctx->Extensions.EXT_texture_array); + default: + return GL_FALSE; + } + default: + _mesa_problem(ctx, "invalid dims=%u in legal_texsubimage_target()", + dims); + return GL_FALSE; + } +} + + +/** + * Test the glTexImage[123]D() parameters for errors. + * + * \param ctx GL context. + * \param dimensions texture image dimensions (must be 1, 2 or 3). + * \param target texture target given by the user. + * \param level image level given by the user. + * \param internalFormat internal format given by the user. + * \param format pixel data format given by the user. + * \param type pixel data type given by the user. + * \param width image width given by the user. + * \param height image height given by the user. + * \param depth image depth given by the user. + * \param border image border given by the user. + * + * \return GL_TRUE if an error was detected, or GL_FALSE if no errors. + * + * Verifies each of the parameters against the constants specified in + * __struct gl_contextRec::Const and the supported extensions, and according + * to the OpenGL specification. + */ +static GLboolean +texture_error_check( struct gl_context *ctx, + GLuint dimensions, GLenum target, + GLint level, GLint internalFormat, + GLenum format, GLenum type, + GLint width, GLint height, + GLint depth, GLint border ) +{ + const GLenum proxyTarget = get_proxy_target(target); + const GLboolean isProxy = target == proxyTarget; + GLboolean sizeOK = GL_TRUE; + GLboolean colorFormat; + + /* Even though there are no color-index textures, we still have to support + * uploading color-index data and remapping it to RGB via the + * GL_PIXEL_MAP_I_TO_[RGBA] tables. + */ + const GLboolean indexFormat = (format == GL_COLOR_INDEX); + + /* Basic level check (more checking in ctx->Driver.TestProxyTexImage) */ + if (level < 0 || level >= MAX_TEXTURE_LEVELS) { + if (!isProxy) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glTexImage%dD(level=%d)", dimensions, level); + } + return GL_TRUE; + } + + /* Check border */ + if (border < 0 || border > 1 || + ((target == GL_TEXTURE_RECTANGLE_NV || + target == GL_PROXY_TEXTURE_RECTANGLE_NV) && border != 0)) { + if (!isProxy) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glTexImage%dD(border=%d)", dimensions, border); + } + return GL_TRUE; + } + + if (width < 0 || height < 0 || depth < 0) { + if (!isProxy) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glTexImage%dD(width, height or depth < 0)", dimensions); + } + return GL_TRUE; + } + + /* Do this simple check before calling the TestProxyTexImage() function */ + if (proxyTarget == GL_PROXY_TEXTURE_CUBE_MAP_ARB) { + sizeOK = (width == height); + } + + /* + * Use the proxy texture driver hook to see if the size/level/etc are + * legal. + */ + sizeOK = sizeOK && ctx->Driver.TestProxyTexImage(ctx, proxyTarget, level, + internalFormat, format, + type, width, height, + depth, border); + if (!sizeOK) { + if (!isProxy) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glTexImage%dD(level=%d, width=%d, height=%d, depth=%d)", + dimensions, level, width, height, depth); + } + return GL_TRUE; + } + + /* Check internalFormat */ + if (_mesa_base_tex_format(ctx, internalFormat) < 0) { + if (!isProxy) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glTexImage%dD(internalFormat=%s)", + dimensions, _mesa_lookup_enum_by_nr(internalFormat)); + } + return GL_TRUE; + } + + /* Check incoming image format and type */ + if (!_mesa_is_legal_format_and_type(ctx, format, type)) { + /* Normally, GL_INVALID_OPERATION is generated by a format/type + * mismatch (see the 1.2 spec page 94, sec 3.6.4.). But with the + * GL_EXT_texture_integer extension, some combinations should generate + * GL_INVALID_ENUM instead (grr!). + */ + if (!isProxy) { + GLenum error = _mesa_is_integer_format(format) + ? GL_INVALID_ENUM : GL_INVALID_OPERATION; + _mesa_error(ctx, error, + "glTexImage%dD(incompatible format 0x%x, type 0x%x)", + dimensions, format, type); + } + return GL_TRUE; + } + + /* make sure internal format and format basically agree */ + colorFormat = _mesa_is_color_format(format); + if ((_mesa_is_color_format(internalFormat) && !colorFormat && !indexFormat) || + (_mesa_is_depth_format(internalFormat) != _mesa_is_depth_format(format)) || + (_mesa_is_ycbcr_format(internalFormat) != _mesa_is_ycbcr_format(format)) || + (_mesa_is_depthstencil_format(internalFormat) != _mesa_is_depthstencil_format(format)) || + (_mesa_is_dudv_format(internalFormat) != _mesa_is_dudv_format(format))) { + if (!isProxy) + _mesa_error(ctx, GL_INVALID_OPERATION, + "glTexImage%dD(incompatible internalFormat 0x%x, format 0x%x)", + dimensions, internalFormat, format); + return GL_TRUE; + } + + /* additional checks for ycbcr textures */ + if (internalFormat == GL_YCBCR_MESA) { + ASSERT(ctx->Extensions.MESA_ycbcr_texture); + if (type != GL_UNSIGNED_SHORT_8_8_MESA && + type != GL_UNSIGNED_SHORT_8_8_REV_MESA) { + char message[100]; + _mesa_snprintf(message, sizeof(message), + "glTexImage%dD(format/type YCBCR mismatch", dimensions); + _mesa_error(ctx, GL_INVALID_ENUM, "%s", message); + return GL_TRUE; /* error */ + } + if (target != GL_TEXTURE_2D && + target != GL_PROXY_TEXTURE_2D && + target != GL_TEXTURE_RECTANGLE_NV && + target != GL_PROXY_TEXTURE_RECTANGLE_NV) { + if (!isProxy) + _mesa_error(ctx, GL_INVALID_ENUM, "glTexImage(target)"); + return GL_TRUE; + } + if (border != 0) { + if (!isProxy) { + char message[100]; + _mesa_snprintf(message, sizeof(message), + "glTexImage%dD(format=GL_YCBCR_MESA and border=%d)", + dimensions, border); + _mesa_error(ctx, GL_INVALID_VALUE, "%s", message); + } + return GL_TRUE; + } + } + + /* additional checks for depth textures */ + if (_mesa_base_tex_format(ctx, internalFormat) == GL_DEPTH_COMPONENT) { + /* Only 1D, 2D, rect and array textures supported, not 3D or cubes */ + if (target != GL_TEXTURE_1D && + target != GL_PROXY_TEXTURE_1D && + target != GL_TEXTURE_2D && + target != GL_PROXY_TEXTURE_2D && + target != GL_TEXTURE_1D_ARRAY && + target != GL_PROXY_TEXTURE_1D_ARRAY && + target != GL_TEXTURE_2D_ARRAY && + target != GL_PROXY_TEXTURE_2D_ARRAY && + target != GL_TEXTURE_RECTANGLE_ARB && + target != GL_PROXY_TEXTURE_RECTANGLE_ARB) { + if (!isProxy) + _mesa_error(ctx, GL_INVALID_ENUM, + "glTexImage(target/internalFormat)"); + return GL_TRUE; + } + } + + /* additional checks for compressed textures */ + if (_mesa_is_compressed_format(ctx, internalFormat)) { + if (!target_can_be_compressed(ctx, target, internalFormat)) { + if (!isProxy) + _mesa_error(ctx, GL_INVALID_ENUM, + "glTexImage%dD(target)", dimensions); + return GL_TRUE; + } + if (border != 0) { + if (!isProxy) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glTexImage%dD(border!=0)", dimensions); + } + return GL_TRUE; + } + } + + /* additional checks for integer textures */ + if (ctx->Extensions.EXT_texture_integer && + (_mesa_is_integer_format(format) != + _mesa_is_integer_format(internalFormat))) { + if (!isProxy) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glTexImage%dD(integer/non-integer format mismatch)", + dimensions); + } + return GL_TRUE; + } + + /* if we get here, the parameters are OK */ + return GL_FALSE; +} + + +/** + * Test glTexSubImage[123]D() parameters for errors. + * + * \param ctx GL context. + * \param dimensions texture image dimensions (must be 1, 2 or 3). + * \param target texture target given by the user. + * \param level image level given by the user. + * \param xoffset sub-image x offset given by the user. + * \param yoffset sub-image y offset given by the user. + * \param zoffset sub-image z offset given by the user. + * \param format pixel data format given by the user. + * \param type pixel data type given by the user. + * \param width image width given by the user. + * \param height image height given by the user. + * \param depth image depth given by the user. + * + * \return GL_TRUE if an error was detected, or GL_FALSE if no errors. + * + * Verifies each of the parameters against the constants specified in + * __struct gl_contextRec::Const and the supported extensions, and according + * to the OpenGL specification. + */ +static GLboolean +subtexture_error_check( struct gl_context *ctx, GLuint dimensions, + GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLint width, GLint height, GLint depth, + GLenum format, GLenum type ) +{ + /* Basic level check */ + if (level < 0 || level >= MAX_TEXTURE_LEVELS) { + _mesa_error(ctx, GL_INVALID_ENUM, "glTexSubImage2D(level=%d)", level); + return GL_TRUE; + } + + /* Check for negative sizes */ + if (width < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glTexSubImage%dD(width=%d)", dimensions, width); + return GL_TRUE; + } + if (height < 0 && dimensions > 1) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glTexSubImage%dD(height=%d)", dimensions, height); + return GL_TRUE; + } + if (depth < 0 && dimensions > 2) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glTexSubImage%dD(depth=%d)", dimensions, depth); + return GL_TRUE; + } + + if (!_mesa_is_legal_format_and_type(ctx, format, type)) { + /* As with the glTexImage2D check above, the error code here + * depends on texture integer. + */ + GLenum error = _mesa_is_integer_format(format) + ? GL_INVALID_OPERATION : GL_INVALID_ENUM; + _mesa_error(ctx, error, + "glTexSubImage%dD(incompatible format 0x%x, type 0x%x)", + dimensions, format, type); + return GL_TRUE; + } + + return GL_FALSE; +} + + +/** + * Do second part of glTexSubImage which depends on the destination texture. + * \return GL_TRUE if error recorded, GL_FALSE otherwise + */ +static GLboolean +subtexture_error_check2( struct gl_context *ctx, GLuint dimensions, + GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLint width, GLint height, GLint depth, + GLenum format, GLenum type, + const struct gl_texture_image *destTex ) +{ + if (!destTex) { + /* undefined image level */ + _mesa_error(ctx, GL_INVALID_OPERATION, "glTexSubImage%dD", dimensions); + return GL_TRUE; + } + + if (xoffset < -((GLint)destTex->Border)) { + _mesa_error(ctx, GL_INVALID_VALUE, "glTexSubImage%dD(xoffset)", + dimensions); + return GL_TRUE; + } + if (xoffset + width > (GLint) (destTex->Width + destTex->Border)) { + _mesa_error(ctx, GL_INVALID_VALUE, "glTexSubImage%dD(xoffset+width)", + dimensions); + return GL_TRUE; + } + if (dimensions > 1) { + if (yoffset < -((GLint)destTex->Border)) { + _mesa_error(ctx, GL_INVALID_VALUE, "glTexSubImage%dD(yoffset)", + dimensions); + return GL_TRUE; + } + if (yoffset + height > (GLint) (destTex->Height + destTex->Border)) { + _mesa_error(ctx, GL_INVALID_VALUE, "glTexSubImage%dD(yoffset+height)", + dimensions); + return GL_TRUE; + } + } + if (dimensions > 2) { + if (zoffset < -((GLint)destTex->Border)) { + _mesa_error(ctx, GL_INVALID_VALUE, "glTexSubImage3D(zoffset)"); + return GL_TRUE; + } + if (zoffset + depth > (GLint) (destTex->Depth + destTex->Border)) { + _mesa_error(ctx, GL_INVALID_VALUE, "glTexSubImage3D(zoffset+depth)"); + return GL_TRUE; + } + } + + if (_mesa_is_format_compressed(destTex->TexFormat)) { + GLuint bw, bh; + + /* do tests which depend on compression block size */ + _mesa_get_format_block_size(destTex->TexFormat, &bw, &bh); + + /* offset must be multiple of block size */ + if ((xoffset % bw != 0) || (yoffset % bh != 0)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glTexSubImage%dD(xoffset = %d, yoffset = %d)", + dimensions, xoffset, yoffset); + return GL_TRUE; + } + /* size must be multiple of bw by bh or equal to whole texture size */ + if ((width % bw != 0) && (GLuint) width != destTex->Width) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glTexSubImage%dD(width = %d)", dimensions, width); + return GL_TRUE; + } + if ((height % bh != 0) && (GLuint) height != destTex->Height) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glTexSubImage%dD(height = %d)", dimensions, height); + return GL_TRUE; + } + } + + return GL_FALSE; +} + + +/** + * Test glCopyTexImage[12]D() parameters for errors. + * + * \param ctx GL context. + * \param dimensions texture image dimensions (must be 1, 2 or 3). + * \param target texture target given by the user. + * \param level image level given by the user. + * \param internalFormat internal format given by the user. + * \param width image width given by the user. + * \param height image height given by the user. + * \param border texture border. + * + * \return GL_TRUE if an error was detected, or GL_FALSE if no errors. + * + * Verifies each of the parameters against the constants specified in + * __struct gl_contextRec::Const and the supported extensions, and according + * to the OpenGL specification. + */ +static GLboolean +copytexture_error_check( struct gl_context *ctx, GLuint dimensions, + GLenum target, GLint level, GLint internalFormat, + GLint width, GLint height, GLint border ) +{ + const GLenum proxyTarget = get_proxy_target(target); + const GLenum type = GL_FLOAT; + GLboolean sizeOK; + GLint format; + + /* check target */ + if (!legal_texsubimage_target(ctx, dimensions, target)) { + _mesa_error(ctx, GL_INVALID_ENUM, "glCopyTexImage%uD(target=%s)", + dimensions, _mesa_lookup_enum_by_nr(target)); + return GL_TRUE; + } + + /* Basic level check (more checking in ctx->Driver.TestProxyTexImage) */ + if (level < 0 || level >= MAX_TEXTURE_LEVELS) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glCopyTexImage%dD(level=%d)", dimensions, level); + return GL_TRUE; + } + + /* Check that the source buffer is complete */ + if (ctx->ReadBuffer->Name) { + if (ctx->ReadBuffer->_Status == 0) { + _mesa_test_framebuffer_completeness(ctx, ctx->ReadBuffer); + } + if (ctx->ReadBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) { + _mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION_EXT, + "glCopyTexImage%dD(invalid readbuffer)", dimensions); + return GL_TRUE; + } + } + + /* Check border */ + if (border < 0 || border > 1 || + ((target == GL_TEXTURE_RECTANGLE_NV || + target == GL_PROXY_TEXTURE_RECTANGLE_NV) && border != 0)) { + return GL_TRUE; + } + + format = _mesa_base_tex_format(ctx, internalFormat); + if (format < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glCopyTexImage%dD(internalFormat)", dimensions); + return GL_TRUE; + } + + if (!_mesa_source_buffer_exists(ctx, format)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glCopyTexImage%dD(missing readbuffer)", dimensions); + return GL_TRUE; + } + + /* Do size, level checking */ + sizeOK = (proxyTarget == GL_PROXY_TEXTURE_CUBE_MAP_ARB) + ? (width == height) : 1; + + sizeOK = sizeOK && ctx->Driver.TestProxyTexImage(ctx, proxyTarget, level, + internalFormat, format, + type, width, height, + 1, border); + + if (!sizeOK) { + if (dimensions == 1) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glCopyTexImage1D(width=%d)", width); + } + else { + ASSERT(dimensions == 2); + _mesa_error(ctx, GL_INVALID_VALUE, + "glCopyTexImage2D(width=%d, height=%d)", width, height); + } + return GL_TRUE; + } + + if (_mesa_is_compressed_format(ctx, internalFormat)) { + if (!target_can_be_compressed(ctx, target, internalFormat)) { + _mesa_error(ctx, GL_INVALID_ENUM, + "glCopyTexImage%dD(target)", dimensions); + return GL_TRUE; + } + if (border != 0) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glCopyTexImage%dD(border!=0)", dimensions); + return GL_TRUE; + } + } + else if (_mesa_is_depth_format(internalFormat)) { + /* make sure we have depth/stencil buffers */ + if (!ctx->ReadBuffer->_DepthBuffer) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glCopyTexImage%dD(no depth)", dimensions); + return GL_TRUE; + } + } + else if (_mesa_is_depthstencil_format(internalFormat)) { + /* make sure we have depth/stencil buffers */ + if (!ctx->ReadBuffer->_DepthBuffer || !ctx->ReadBuffer->_StencilBuffer) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glCopyTexImage%dD(no depth/stencil buffer)", dimensions); + return GL_TRUE; + } + } + + /* if we get here, the parameters are OK */ + return GL_FALSE; +} + + +/** + * Test glCopyTexSubImage[12]D() parameters for errors. + * Note that this is the first part of error checking. + * See also copytexsubimage_error_check2() below for the second part. + * + * \param ctx GL context. + * \param dimensions texture image dimensions (must be 1, 2 or 3). + * \param target texture target given by the user. + * \param level image level given by the user. + * + * \return GL_TRUE if an error was detected, or GL_FALSE if no errors. + */ +static GLboolean +copytexsubimage_error_check1( struct gl_context *ctx, GLuint dimensions, + GLenum target, GLint level) +{ + /* Check that the source buffer is complete */ + if (ctx->ReadBuffer->Name) { + if (ctx->ReadBuffer->_Status == 0) { + _mesa_test_framebuffer_completeness(ctx, ctx->ReadBuffer); + } + if (ctx->ReadBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) { + _mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION_EXT, + "glCopyTexImage%dD(invalid readbuffer)", dimensions); + return GL_TRUE; + } + } + + /* check target (proxies not allowed) */ + if (!legal_texsubimage_target(ctx, dimensions, target)) { + _mesa_error(ctx, GL_INVALID_ENUM, "glCopyTexSubImage%uD(target=%s)", + dimensions, _mesa_lookup_enum_by_nr(target)); + return GL_TRUE; + } + + /* Check level */ + if (level < 0 || level >= MAX_TEXTURE_LEVELS) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glCopyTexSubImage%dD(level=%d)", dimensions, level); + return GL_TRUE; + } + + return GL_FALSE; +} + + +/** + * Second part of error checking for glCopyTexSubImage[12]D(). + * \param xoffset sub-image x offset given by the user. + * \param yoffset sub-image y offset given by the user. + * \param zoffset sub-image z offset given by the user. + * \param width image width given by the user. + * \param height image height given by the user. + */ +static GLboolean +copytexsubimage_error_check2( struct gl_context *ctx, GLuint dimensions, + GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLsizei width, GLsizei height, + const struct gl_texture_image *teximage ) +{ + /* check that dest tex image exists */ + if (!teximage) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glCopyTexSubImage%dD(undefined texture level: %d)", + dimensions, level); + return GL_TRUE; + } + + /* Check size */ + if (width < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glCopyTexSubImage%dD(width=%d)", dimensions, width); + return GL_TRUE; + } + if (dimensions > 1 && height < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glCopyTexSubImage%dD(height=%d)", dimensions, height); + return GL_TRUE; + } + + /* check x/y offsets */ + if (xoffset < -((GLint)teximage->Border)) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glCopyTexSubImage%dD(xoffset=%d)", dimensions, xoffset); + return GL_TRUE; + } + if (xoffset + width > (GLint) (teximage->Width + teximage->Border)) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glCopyTexSubImage%dD(xoffset+width)", dimensions); + return GL_TRUE; + } + if (dimensions > 1) { + if (yoffset < -((GLint)teximage->Border)) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glCopyTexSubImage%dD(yoffset=%d)", dimensions, yoffset); + return GL_TRUE; + } + /* NOTE: we're adding the border here, not subtracting! */ + if (yoffset + height > (GLint) (teximage->Height + teximage->Border)) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glCopyTexSubImage%dD(yoffset+height)", dimensions); + return GL_TRUE; + } + } + + /* check z offset */ + if (dimensions > 2) { + if (zoffset < -((GLint)teximage->Border)) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glCopyTexSubImage%dD(zoffset)", dimensions); + return GL_TRUE; + } + if (zoffset > (GLint) (teximage->Depth + teximage->Border)) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glCopyTexSubImage%dD(zoffset+depth)", dimensions); + return GL_TRUE; + } + } + + if (_mesa_is_format_compressed(teximage->TexFormat)) { + /* offset must be multiple of 4 */ + if ((xoffset & 3) || (yoffset & 3)) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glCopyTexSubImage%dD(xoffset or yoffset)", dimensions); + return GL_TRUE; + } + /* size must be multiple of 4 */ + if ((width & 3) != 0 && (GLuint) width != teximage->Width) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glCopyTexSubImage%dD(width)", dimensions); + return GL_TRUE; + } + if ((height & 3) != 0 && (GLuint) height != teximage->Height) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glCopyTexSubImage%dD(height)", dimensions); + return GL_TRUE; + } + } + + if (teximage->InternalFormat == GL_YCBCR_MESA) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glCopyTexSubImage2D"); + return GL_TRUE; + } + + if (!_mesa_source_buffer_exists(ctx, teximage->_BaseFormat)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glCopyTexSubImage%dD(missing readbuffer, format=0x%x)", + dimensions, teximage->_BaseFormat); + return GL_TRUE; + } + + if (teximage->_BaseFormat == GL_DEPTH_COMPONENT) { + if (!ctx->ReadBuffer->_DepthBuffer) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glCopyTexSubImage%dD(no depth buffer)", + dimensions); + return GL_TRUE; + } + } + else if (teximage->_BaseFormat == GL_DEPTH_STENCIL_EXT) { + if (!ctx->ReadBuffer->_DepthBuffer || !ctx->ReadBuffer->_StencilBuffer) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glCopyTexSubImage%dD(no depth/stencil buffer)", + dimensions); + return GL_TRUE; + } + } + + /* If copying into an integer texture, the source buffer must also be + * integer-valued. + */ + if (_mesa_is_format_integer_color(teximage->TexFormat)) { + struct gl_renderbuffer *rb = ctx->ReadBuffer->_ColorReadBuffer; + if (!_mesa_is_format_integer_color(rb->Format)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glCopyTexSubImage%dD(source buffer is not integer format)", + dimensions); + return GL_TRUE; + } + } + + /* if we get here, the parameters are OK */ + return GL_FALSE; +} + + +/** Callback info for walking over FBO hash table */ +struct cb_info +{ + struct gl_context *ctx; + struct gl_texture_object *texObj; + GLuint level, face; +}; + + +/** + * Check render to texture callback. Called from _mesa_HashWalk(). + */ +static void +check_rtt_cb(GLuint key, void *data, void *userData) +{ + struct gl_framebuffer *fb = (struct gl_framebuffer *) data; + const struct cb_info *info = (struct cb_info *) userData; + struct gl_context *ctx = info->ctx; + const struct gl_texture_object *texObj = info->texObj; + const GLuint level = info->level, face = info->face; + + /* If this is a user-created FBO */ + if (fb->Name) { + GLuint i; + /* check if any of the FBO's attachments point to 'texObj' */ + for (i = 0; i < BUFFER_COUNT; i++) { + struct gl_renderbuffer_attachment *att = fb->Attachment + i; + if (att->Type == GL_TEXTURE && + att->Texture == texObj && + att->TextureLevel == level && + att->CubeMapFace == face) { + ASSERT(_mesa_get_attachment_teximage(att)); + /* Tell driver about the new renderbuffer texture */ + ctx->Driver.RenderTexture(ctx, ctx->DrawBuffer, att); + /* Mark fb status as indeterminate to force re-validation */ + fb->_Status = 0; + } + } + } +} + + +/** + * When a texture image is specified we have to check if it's bound to + * any framebuffer objects (render to texture) in order to detect changes + * in size or format since that effects FBO completeness. + * Any FBOs rendering into the texture must be re-validated. + */ +static void +update_fbo_texture(struct gl_context *ctx, struct gl_texture_object *texObj, + GLuint face, GLuint level) +{ + /* Only check this texture if it's been marked as RenderToTexture */ + if (texObj->_RenderToTexture) { + struct cb_info info; + info.ctx = ctx; + info.texObj = texObj; + info.level = level; + info.face = face; + _mesa_HashWalk(ctx->Shared->FrameBuffers, check_rtt_cb, &info); + } +} + + +/** + * If the texture object's GenerateMipmap flag is set and we've + * changed the texture base level image, regenerate the rest of the + * mipmap levels now. + */ +static INLINE void +check_gen_mipmap(struct gl_context *ctx, GLenum target, + struct gl_texture_object *texObj, GLint level) +{ + ASSERT(target != GL_TEXTURE_CUBE_MAP); + if (texObj->GenerateMipmap && + level == texObj->BaseLevel && + level < texObj->MaxLevel) { + ASSERT(ctx->Driver.GenerateMipmap); + ctx->Driver.GenerateMipmap(ctx, target, texObj); + } +} + + +/** Debug helper: override the user-requested internal format */ +static GLenum +override_internal_format(GLenum internalFormat, GLint width, GLint height) +{ +#if 0 + if (internalFormat == GL_RGBA16F_ARB || + internalFormat == GL_RGBA32F_ARB) { + printf("Convert rgba float tex to int %d x %d\n", width, height); + return GL_RGBA; + } + else if (internalFormat == GL_RGB16F_ARB || + internalFormat == GL_RGB32F_ARB) { + printf("Convert rgb float tex to int %d x %d\n", width, height); + return GL_RGB; + } + else if (internalFormat == GL_LUMINANCE_ALPHA16F_ARB || + internalFormat == GL_LUMINANCE_ALPHA32F_ARB) { + printf("Convert luminance float tex to int %d x %d\n", width, height); + return GL_LUMINANCE_ALPHA; + } + else if (internalFormat == GL_LUMINANCE16F_ARB || + internalFormat == GL_LUMINANCE32F_ARB) { + printf("Convert luminance float tex to int %d x %d\n", width, height); + return GL_LUMINANCE; + } + else if (internalFormat == GL_ALPHA16F_ARB || + internalFormat == GL_ALPHA32F_ARB) { + printf("Convert luminance float tex to int %d x %d\n", width, height); + return GL_ALPHA; + } + /* + else if (internalFormat == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT) { + internalFormat = GL_RGBA; + } + */ + else { + return internalFormat; + } +#else + return internalFormat; +#endif +} + + +/** + * Choose the actual hardware format for a texture image. + * Try to use the same format as the previous image level when possible. + * Otherwise, ask the driver for the best format. + * It's important to try to choose a consistant format for all levels + * for efficient texture memory layout/allocation. In particular, this + * comes up during automatic mipmap generation. + */ +gl_format +_mesa_choose_texture_format(struct gl_context *ctx, + struct gl_texture_object *texObj, + GLenum target, GLint level, + GLenum internalFormat, GLenum format, GLenum type) +{ + gl_format f; + + /* see if we've already chosen a format for the previous level */ + if (level > 0) { + struct gl_texture_image *prevImage = + _mesa_select_tex_image(ctx, texObj, target, level - 1); + /* See if the prev level is defined and has an internal format which + * matches the new internal format. + */ + if (prevImage && + prevImage->Width > 0 && + prevImage->InternalFormat == internalFormat) { + /* use the same format */ + ASSERT(prevImage->TexFormat != MESA_FORMAT_NONE); + return prevImage->TexFormat; + } + } + + /* choose format from scratch */ + f = ctx->Driver.ChooseTextureFormat(ctx, internalFormat, format, type); + ASSERT(f != MESA_FORMAT_NONE); + return f; +} + + +/** + * Common code to implement all the glTexImage1D/2D/3D functions. + */ +static void +teximage(struct gl_context *ctx, GLuint dims, + GLenum target, GLint level, GLint internalFormat, + GLsizei width, GLsizei height, GLsizei depth, + GLint border, GLenum format, GLenum type, + const GLvoid *pixels) +{ + GLboolean error; + + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE)) + _mesa_debug(ctx, "glTexImage%uD %s %d %s %d %d %d %d %s %s %p\n", + dims, + _mesa_lookup_enum_by_nr(target), level, + _mesa_lookup_enum_by_nr(internalFormat), + width, height, depth, border, + _mesa_lookup_enum_by_nr(format), + _mesa_lookup_enum_by_nr(type), pixels); + + internalFormat = override_internal_format(internalFormat, width, height); + + /* target error checking */ + if (!legal_teximage_target(ctx, dims, target)) { + _mesa_error(ctx, GL_INVALID_ENUM, "glTexImage%uD(target=%s)", + dims, _mesa_lookup_enum_by_nr(target)); + return; + } + + /* general error checking */ + error = texture_error_check(ctx, dims, target, level, internalFormat, + format, type, width, height, depth, border); + + if (_mesa_is_proxy_texture(target)) { + /* Proxy texture: just clear or set state depending on error checking */ + struct gl_texture_image *texImage = + _mesa_get_proxy_tex_image(ctx, target, level); + + if (error) { + /* when error, clear all proxy texture image parameters */ + if (texImage) + clear_teximage_fields(texImage); + } + else { + /* no error, set the tex image parameters */ + struct gl_texture_object *texObj = + _mesa_get_current_tex_object(ctx, target); + gl_format texFormat = _mesa_choose_texture_format(ctx, texObj, + target, level, + internalFormat, + format, type); + + if (legal_texture_size(ctx, texFormat, width, height, depth)) { + _mesa_init_teximage_fields(ctx, target, texImage, width, height, + depth, border, internalFormat, + texFormat); + } + else if (texImage) { + clear_teximage_fields(texImage); + } + } + } + else { + /* non-proxy target */ + const GLuint face = _mesa_tex_target_to_face(target); + struct gl_texture_object *texObj; + struct gl_texture_image *texImage; + + if (error) { + return; /* error was recorded */ + } + + if (ctx->NewState & _NEW_PIXEL) + _mesa_update_state(ctx); + + texObj = _mesa_get_current_tex_object(ctx, target); + + _mesa_lock_texture(ctx, texObj); + { + texImage = _mesa_get_tex_image(ctx, texObj, target, level); + + if (!texImage) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage%uD", dims); + } + else { + gl_format texFormat; + + ctx->Driver.FreeTextureImageBuffer(ctx, texImage); + + ASSERT(texImage->Data == NULL); + texFormat = _mesa_choose_texture_format(ctx, texObj, target, level, + internalFormat, format, + type); + + if (legal_texture_size(ctx, texFormat, width, height, depth)) { + _mesa_init_teximage_fields(ctx, target, texImage, + width, height, depth, + border, internalFormat, texFormat); + + /* Give the texture to the driver. may be null. */ + ASSERT(ctx->Driver.TexImage3D); + switch (dims) { + case 1: + ctx->Driver.TexImage1D(ctx, target, level, internalFormat, + width, border, format, + type, pixels, &ctx->Unpack, texObj, + texImage); + break; + case 2: + ctx->Driver.TexImage2D(ctx, target, level, internalFormat, + width, height, border, format, + type, pixels, &ctx->Unpack, texObj, + texImage); + break; + case 3: + ctx->Driver.TexImage3D(ctx, target, level, internalFormat, + width, height, depth, border, format, + type, pixels, &ctx->Unpack, texObj, + texImage); + break; + default: + _mesa_problem(ctx, "invalid dims=%u in teximage()", dims); + } + + check_gen_mipmap(ctx, target, texObj, level); + + update_fbo_texture(ctx, texObj, face, level); + + /* state update */ + texObj->_Complete = GL_FALSE; + ctx->NewState |= _NEW_TEXTURE; + } + else { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage%uD", dims); + } + } + } + _mesa_unlock_texture(ctx, texObj); + } +} + + +/* + * Called from the API. Note that width includes the border. + */ +void GLAPIENTRY +_mesa_TexImage1D( GLenum target, GLint level, GLint internalFormat, + GLsizei width, GLint border, GLenum format, + GLenum type, const GLvoid *pixels ) +{ + GET_CURRENT_CONTEXT(ctx); + teximage(ctx, 1, target, level, internalFormat, width, 1, 1, + border, format, type, pixels); +} + + +void GLAPIENTRY +_mesa_TexImage2D( GLenum target, GLint level, GLint internalFormat, + GLsizei width, GLsizei height, GLint border, + GLenum format, GLenum type, + const GLvoid *pixels ) +{ + GET_CURRENT_CONTEXT(ctx); + teximage(ctx, 2, target, level, internalFormat, width, height, 1, + border, format, type, pixels); +} + + +/* + * Called by the API or display list executor. + * Note that width and height include the border. + */ +void GLAPIENTRY +_mesa_TexImage3D( GLenum target, GLint level, GLint internalFormat, + GLsizei width, GLsizei height, GLsizei depth, + GLint border, GLenum format, GLenum type, + const GLvoid *pixels ) +{ + GET_CURRENT_CONTEXT(ctx); + teximage(ctx, 3, target, level, internalFormat, width, height, depth, + border, format, type, pixels); +} + + +void GLAPIENTRY +_mesa_TexImage3DEXT( GLenum target, GLint level, GLenum internalFormat, + GLsizei width, GLsizei height, GLsizei depth, + GLint border, GLenum format, GLenum type, + const GLvoid *pixels ) +{ + _mesa_TexImage3D(target, level, (GLint) internalFormat, width, height, + depth, border, format, type, pixels); +} + + +#if FEATURE_OES_EGL_image +void GLAPIENTRY +_mesa_EGLImageTargetTexture2DOES (GLenum target, GLeglImageOES image) +{ + struct gl_texture_object *texObj; + struct gl_texture_image *texImage; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + if (!ctx->Extensions.OES_EGL_image) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glEGLImageTargetTexture2DOES(unsupported)"); + return; + } + + if (target != GL_TEXTURE_2D) { + _mesa_error(ctx, GL_INVALID_ENUM, + "glEGLImageTargetTexture2D(target=%d)", target); + return; + } + + if (ctx->NewState & _NEW_PIXEL) + _mesa_update_state(ctx); + + texObj = _mesa_get_current_tex_object(ctx, target); + _mesa_lock_texture(ctx, texObj); + + texImage = _mesa_get_tex_image(ctx, texObj, target, 0); + if (!texImage) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glEGLImageTargetTexture2D"); + } else { + ctx->Driver.FreeTextureImageBuffer(ctx, texImage); + + ASSERT(texImage->Data == NULL); + ctx->Driver.EGLImageTargetTexture2D(ctx, target, + texObj, texImage, image); + + /* state update */ + texObj->_Complete = GL_FALSE; + ctx->NewState |= _NEW_TEXTURE; + } + _mesa_unlock_texture(ctx, texObj); + +} +#endif + + + +/** + * Implement all the glTexSubImage1/2/3D() functions. + */ +static void +texsubimage(struct gl_context *ctx, GLuint dims, GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLsizei width, GLsizei height, GLsizei depth, + GLenum format, GLenum type, const GLvoid *pixels ) +{ + struct gl_texture_object *texObj; + struct gl_texture_image *texImage; + + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE)) + _mesa_debug(ctx, "glTexSubImage%uD %s %d %d %d %d %d %d %d %s %s %p\n", + dims, + _mesa_lookup_enum_by_nr(target), level, + xoffset, yoffset, zoffset, width, height, depth, + _mesa_lookup_enum_by_nr(format), + _mesa_lookup_enum_by_nr(type), pixels); + + /* check target (proxies not allowed) */ + if (!legal_texsubimage_target(ctx, dims, target)) { + _mesa_error(ctx, GL_INVALID_ENUM, "glTexSubImage%uD(target=%s)", + dims, _mesa_lookup_enum_by_nr(target)); + return; + } + + if (ctx->NewState & _NEW_PIXEL) + _mesa_update_state(ctx); + + if (subtexture_error_check(ctx, dims, target, level, xoffset, yoffset, zoffset, + width, height, depth, format, type)) { + return; /* error was detected */ + } + + texObj = _mesa_get_current_tex_object(ctx, target); + + _mesa_lock_texture(ctx, texObj); + { + texImage = _mesa_select_tex_image(ctx, texObj, target, level); + + if (subtexture_error_check2(ctx, dims, target, level, + xoffset, yoffset, zoffset, + width, height, depth, + format, type, texImage)) { + /* error was recorded */ + } + else if (width > 0 && height > 0 && depth > 0) { + /* If we have a border, offset=-1 is legal. Bias by border width. */ + switch (dims) { + case 3: + zoffset += texImage->Border; + /* fall-through */ + case 2: + yoffset += texImage->Border; + /* fall-through */ + case 1: + xoffset += texImage->Border; + } + + switch (dims) { + case 1: + ctx->Driver.TexSubImage1D(ctx, target, level, + xoffset, width, + format, type, pixels, + &ctx->Unpack, texObj, texImage ); + break; + case 2: + ctx->Driver.TexSubImage2D(ctx, target, level, + xoffset, yoffset, width, height, + format, type, pixels, + &ctx->Unpack, texObj, texImage ); + break; + case 3: + ctx->Driver.TexSubImage3D(ctx, target, level, + xoffset, yoffset, zoffset, + width, height, depth, + format, type, pixels, + &ctx->Unpack, texObj, texImage ); + break; + default: + _mesa_problem(ctx, "unexpected dims in subteximage()"); + } + + check_gen_mipmap(ctx, target, texObj, level); + + ctx->NewState |= _NEW_TEXTURE; + } + } + _mesa_unlock_texture(ctx, texObj); +} + + +void GLAPIENTRY +_mesa_TexSubImage1D( GLenum target, GLint level, + GLint xoffset, GLsizei width, + GLenum format, GLenum type, + const GLvoid *pixels ) +{ + GET_CURRENT_CONTEXT(ctx); + texsubimage(ctx, 1, target, level, + xoffset, 0, 0, + width, 1, 1, + format, type, pixels); +} + + +void GLAPIENTRY +_mesa_TexSubImage2D( GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLsizei width, GLsizei height, + GLenum format, GLenum type, + const GLvoid *pixels ) +{ + GET_CURRENT_CONTEXT(ctx); + texsubimage(ctx, 2, target, level, + xoffset, yoffset, 0, + width, height, 1, + format, type, pixels); +} + + + +void GLAPIENTRY +_mesa_TexSubImage3D( GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLsizei width, GLsizei height, GLsizei depth, + GLenum format, GLenum type, + const GLvoid *pixels ) +{ + GET_CURRENT_CONTEXT(ctx); + texsubimage(ctx, 3, target, level, + xoffset, yoffset, zoffset, + width, height, depth, + format, type, pixels); +} + + + +/** + * Implement the glCopyTexImage1/2D() functions. + */ +static void +copyteximage(struct gl_context *ctx, GLuint dims, + GLenum target, GLint level, GLenum internalFormat, + GLint x, GLint y, GLsizei width, GLsizei height, GLint border ) +{ + struct gl_texture_object *texObj; + struct gl_texture_image *texImage; + const GLuint face = _mesa_tex_target_to_face(target); + + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE)) + _mesa_debug(ctx, "glCopyTexImage%uD %s %d %s %d %d %d %d %d\n", + dims, + _mesa_lookup_enum_by_nr(target), level, + _mesa_lookup_enum_by_nr(internalFormat), + x, y, width, height, border); + + if (ctx->NewState & NEW_COPY_TEX_STATE) + _mesa_update_state(ctx); + + if (copytexture_error_check(ctx, dims, target, level, internalFormat, + width, height, border)) + return; + + texObj = _mesa_get_current_tex_object(ctx, target); + + _mesa_lock_texture(ctx, texObj); + { + texImage = _mesa_get_tex_image(ctx, texObj, target, level); + + if (!texImage) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexImage%uD", dims); + } + else { + /* choose actual hw format */ + gl_format texFormat = _mesa_choose_texture_format(ctx, texObj, + target, level, + internalFormat, + GL_NONE, GL_NONE); + + if (legal_texture_size(ctx, texFormat, width, height, 1)) { + GLint srcX = x, srcY = y, dstX = 0, dstY = 0; + + /* Free old texture image */ + ctx->Driver.FreeTextureImageBuffer(ctx, texImage); + + _mesa_init_teximage_fields(ctx, target, texImage, width, height, 1, + border, internalFormat, texFormat); + + /* Allocate texture memory (no pixel data yet) */ + if (dims == 1) { + ctx->Driver.TexImage1D(ctx, target, level, internalFormat, + width, border, GL_NONE, GL_NONE, NULL, + &ctx->Unpack, texObj, texImage); + } + else { + ctx->Driver.TexImage2D(ctx, target, level, internalFormat, + width, height, border, GL_NONE, GL_NONE, + NULL, &ctx->Unpack, texObj, texImage); + } + + if (_mesa_clip_copytexsubimage(ctx, &dstX, &dstY, &srcX, &srcY, + &width, &height)) { + if (dims == 1) + ctx->Driver.CopyTexSubImage1D(ctx, target, level, dstX, + srcX, srcY, width); + + else + ctx->Driver.CopyTexSubImage2D(ctx, target, level, dstX, dstY, + srcX, srcY, width, height); + } + + check_gen_mipmap(ctx, target, texObj, level); + + update_fbo_texture(ctx, texObj, face, level); + + /* state update */ + texObj->_Complete = GL_FALSE; + ctx->NewState |= _NEW_TEXTURE; + } + else { + /* probably too large of image */ + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexImage%uD", dims); + } + } + } + _mesa_unlock_texture(ctx, texObj); +} + + + +void GLAPIENTRY +_mesa_CopyTexImage1D( GLenum target, GLint level, + GLenum internalFormat, + GLint x, GLint y, + GLsizei width, GLint border ) +{ + GET_CURRENT_CONTEXT(ctx); + copyteximage(ctx, 1, target, level, internalFormat, x, y, width, 1, border); +} + + + +void GLAPIENTRY +_mesa_CopyTexImage2D( GLenum target, GLint level, GLenum internalFormat, + GLint x, GLint y, GLsizei width, GLsizei height, + GLint border ) +{ + GET_CURRENT_CONTEXT(ctx); + copyteximage(ctx, 2, target, level, internalFormat, + x, y, width, height, border); +} + + + +/** + * Implementation for glCopyTexSubImage1/2/3D() functions. + */ +static void +copytexsubimage(struct gl_context *ctx, GLuint dims, GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLint x, GLint y, GLsizei width, GLsizei height) +{ + struct gl_texture_object *texObj; + struct gl_texture_image *texImage; + + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE)) + _mesa_debug(ctx, "glCopyTexSubImage%uD %s %d %d %d %d %d %d %d %d\n", + dims, + _mesa_lookup_enum_by_nr(target), + level, xoffset, yoffset, zoffset, x, y, width, height); + + if (ctx->NewState & NEW_COPY_TEX_STATE) + _mesa_update_state(ctx); + + if (copytexsubimage_error_check1(ctx, dims, target, level)) + return; + + texObj = _mesa_get_current_tex_object(ctx, target); + + _mesa_lock_texture(ctx, texObj); + { + texImage = _mesa_select_tex_image(ctx, texObj, target, level); + + if (copytexsubimage_error_check2(ctx, dims, target, level, xoffset, yoffset, + zoffset, width, height, texImage)) { + /* error was recored */ + } + else { + /* If we have a border, offset=-1 is legal. Bias by border width. */ + switch (dims) { + case 3: + zoffset += texImage->Border; + /* fall-through */ + case 2: + yoffset += texImage->Border; + /* fall-through */ + case 1: + xoffset += texImage->Border; + } + + if (_mesa_clip_copytexsubimage(ctx, &xoffset, &yoffset, &x, &y, + &width, &height)) { + switch (dims) { + case 1: + ctx->Driver.CopyTexSubImage1D(ctx, target, level, + xoffset, x, y, width); + break; + case 2: + ctx->Driver.CopyTexSubImage2D(ctx, target, level, + xoffset, yoffset, + x, y, width, height); + break; + case 3: + ctx->Driver.CopyTexSubImage3D(ctx, target, level, + xoffset, yoffset, zoffset, + x, y, width, height); + break; + default: + _mesa_problem(ctx, "bad dims in copytexsubimage()"); + } + + check_gen_mipmap(ctx, target, texObj, level); + + ctx->NewState |= _NEW_TEXTURE; + } + } + } + _mesa_unlock_texture(ctx, texObj); +} + + +void GLAPIENTRY +_mesa_CopyTexSubImage1D( GLenum target, GLint level, + GLint xoffset, GLint x, GLint y, GLsizei width ) +{ + GET_CURRENT_CONTEXT(ctx); + copytexsubimage(ctx, 1, target, level, xoffset, 0, 0, x, y, width, 1); +} + + + +void GLAPIENTRY +_mesa_CopyTexSubImage2D( GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLint x, GLint y, GLsizei width, GLsizei height ) +{ + GET_CURRENT_CONTEXT(ctx); + copytexsubimage(ctx, 2, target, level, xoffset, yoffset, 0, x, y, + width, height); +} + + + +void GLAPIENTRY +_mesa_CopyTexSubImage3D( GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLint x, GLint y, GLsizei width, GLsizei height ) +{ + GET_CURRENT_CONTEXT(ctx); + copytexsubimage(ctx, 3, target, level, xoffset, yoffset, zoffset, + x, y, width, height); +} + + + + +/**********************************************************************/ +/****** Compressed Textures ******/ +/**********************************************************************/ + + +/** + * Return expected size of a compressed texture. + */ +static GLuint +compressed_tex_size(GLsizei width, GLsizei height, GLsizei depth, + GLenum glformat) +{ + gl_format mesaFormat = _mesa_glenum_to_compressed_format(glformat); + return _mesa_format_image_size(mesaFormat, width, height, depth); +} + + +/* + * Return compressed texture block size, in pixels. + */ +static void +get_compressed_block_size(GLenum glformat, GLuint *bw, GLuint *bh) +{ + gl_format mesaFormat = _mesa_glenum_to_compressed_format(glformat); + _mesa_get_format_block_size(mesaFormat, bw, bh); +} + + +/** + * Error checking for glCompressedTexImage[123]D(). + * \param reason returns reason for error, if any + * \return error code or GL_NO_ERROR. + */ +static GLenum +compressed_texture_error_check(struct gl_context *ctx, GLint dimensions, + GLenum target, GLint level, + GLenum internalFormat, GLsizei width, + GLsizei height, GLsizei depth, GLint border, + GLsizei imageSize, char **reason) +{ + const GLenum proxyTarget = get_proxy_target(target); + const GLint maxLevels = _mesa_max_texture_levels(ctx, target); + GLint expectedSize; + + *reason = ""; /* no error */ + + /* check level */ + if (level < 0 || level >= maxLevels) { + *reason = "level"; + return GL_INVALID_VALUE; + } + + if (!target_can_be_compressed(ctx, target, internalFormat)) { + *reason = "target"; + return GL_INVALID_ENUM; + } + + /* This will detect any invalid internalFormat value */ + if (!_mesa_is_compressed_format(ctx, internalFormat)) { + *reason = "internalFormat"; + return GL_INVALID_ENUM; + } + + /* This should really never fail */ + if (_mesa_base_tex_format(ctx, internalFormat) < 0) { + *reason = "internalFormat"; + return GL_INVALID_ENUM; + } + + /* No compressed formats support borders at this time */ + if (border != 0) { + *reason = "border != 0"; + return GL_INVALID_VALUE; + } + + /* For cube map, width must equal height */ + if (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB && + target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB && width != height) { + *reason = "width != height"; + return GL_INVALID_VALUE; + } + + /* check image size against compression block size */ + { + gl_format texFormat = + ctx->Driver.ChooseTextureFormat(ctx, internalFormat, + GL_NONE, GL_NONE); + GLuint bw, bh; + + _mesa_get_format_block_size(texFormat, &bw, &bh); + if ((width > bw && width % bw > 0) || + (height > bh && height % bh > 0)) { + /* + * Per GL_ARB_texture_compression: GL_INVALID_OPERATION is + * generated [...] if any parameter combinations are not + * supported by the specific compressed internal format. + */ + *reason = "invalid width or height for compression format"; + return GL_INVALID_OPERATION; + } + } + + /* check image sizes */ + if (!ctx->Driver.TestProxyTexImage(ctx, proxyTarget, level, + internalFormat, GL_NONE, GL_NONE, + width, height, depth, border)) { + /* See error comment above */ + *reason = "invalid width, height or format"; + return GL_INVALID_OPERATION; + } + + /* check image size in bytes */ + expectedSize = compressed_tex_size(width, height, depth, internalFormat); + if (expectedSize != imageSize) { + /* Per GL_ARB_texture_compression: GL_INVALID_VALUE is generated [...] + * if is not consistent with the format, dimensions, and + * contents of the specified image. + */ + *reason = "imageSize inconsistant with width/height/format"; + return GL_INVALID_VALUE; + } + + return GL_NO_ERROR; +} + + +/** + * Error checking for glCompressedTexSubImage[123]D(). + * \warning There are some bad assumptions here about the size of compressed + * texture tiles (multiple of 4) used to test the validity of the + * offset and size parameters. + * \return error code or GL_NO_ERROR. + */ +static GLenum +compressed_subtexture_error_check(struct gl_context *ctx, GLint dimensions, + GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLsizei width, GLsizei height, GLsizei depth, + GLenum format, GLsizei imageSize) +{ + GLint expectedSize, maxLevels = 0, maxTextureSize; + GLuint bw, bh; + (void) zoffset; + + if (dimensions == 1) { + /* 1D compressed textures not allowed */ + return GL_INVALID_ENUM; + } + else if (dimensions == 2) { + if (target == GL_PROXY_TEXTURE_2D) { + maxLevels = ctx->Const.MaxTextureLevels; + } + else if (target == GL_TEXTURE_2D) { + maxLevels = ctx->Const.MaxTextureLevels; + } + else if (target == GL_PROXY_TEXTURE_CUBE_MAP_ARB) { + if (!ctx->Extensions.ARB_texture_cube_map) + return GL_INVALID_ENUM; /*target*/ + maxLevels = ctx->Const.MaxCubeTextureLevels; + } + else if (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB && + target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB) { + if (!ctx->Extensions.ARB_texture_cube_map) + return GL_INVALID_ENUM; /*target*/ + maxLevels = ctx->Const.MaxCubeTextureLevels; + } + else { + return GL_INVALID_ENUM; /*target*/ + } + } + else if (dimensions == 3) { + /* 3D compressed textures not allowed */ + return GL_INVALID_ENUM; + } + + maxTextureSize = 1 << (maxLevels - 1); + + /* this will catch any invalid compressed format token */ + if (!_mesa_is_compressed_format(ctx, format)) + return GL_INVALID_ENUM; + + if (width < 1 || width > maxTextureSize) + return GL_INVALID_VALUE; + + if ((height < 1 || height > maxTextureSize) + && dimensions > 1) + return GL_INVALID_VALUE; + + if (level < 0 || level >= maxLevels) + return GL_INVALID_VALUE; + + /* + * do checks which depend on compression block size + */ + get_compressed_block_size(format, &bw, &bh); + + if ((xoffset % bw != 0) || (yoffset % bh != 0)) + return GL_INVALID_VALUE; + + if ((width % bw != 0) && width != 2 && width != 1) + return GL_INVALID_VALUE; + + if ((height % bh != 0) && height != 2 && height != 1) + return GL_INVALID_VALUE; + + expectedSize = compressed_tex_size(width, height, depth, format); + if (expectedSize != imageSize) + return GL_INVALID_VALUE; + + return GL_NO_ERROR; +} + + +/** + * Do second part of glCompressedTexSubImage error checking. + * \return GL_TRUE if error found, GL_FALSE otherwise. + */ +static GLboolean +compressed_subtexture_error_check2(struct gl_context *ctx, GLuint dims, + GLsizei width, GLsizei height, + GLsizei depth, GLenum format, + struct gl_texture_image *texImage) +{ + + if ((GLint) format != texImage->InternalFormat) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glCompressedTexSubImage%uD(format=0x%x)", dims, format); + return GL_TRUE; + } + + if (((width == 1 || width == 2) && + width != (GLsizei) texImage->Width) || + (width > (GLsizei) texImage->Width)) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glCompressedTexSubImage%uD(width=%d)", dims, width); + return GL_TRUE; + } + + if (dims >= 2) { + if (((height == 1 || height == 2) && + height != (GLsizei) texImage->Height) || + (height > (GLsizei) texImage->Height)) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glCompressedTexSubImage%uD(height=%d)", dims, height); + return GL_TRUE; + } + } + + if (dims >= 3) { + if (((depth == 1 || depth == 2) && + depth != (GLsizei) texImage->Depth) || + (depth > (GLsizei) texImage->Depth)) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glCompressedTexSubImage%uD(depth=%d)", dims, depth); + return GL_TRUE; + } + } + + return GL_FALSE; +} + + +/** + * Implementation of the glCompressedTexImage1/2/3D() functions. + */ +static void +compressedteximage(struct gl_context *ctx, GLuint dims, + GLenum target, GLint level, + GLenum internalFormat, GLsizei width, + GLsizei height, GLsizei depth, GLint border, + GLsizei imageSize, const GLvoid *data) +{ + GLenum error; + char *reason = ""; + + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE)) + _mesa_debug(ctx, + "glCompressedTexImage%uDARB %s %d %s %d %d %d %d %d %p\n", + dims, + _mesa_lookup_enum_by_nr(target), level, + _mesa_lookup_enum_by_nr(internalFormat), + width, height, depth, border, imageSize, data); + + /* check target */ + if (!legal_teximage_target(ctx, dims, target)) { + _mesa_error(ctx, GL_INVALID_ENUM, "glCompressedTexImage%uD(target=%s)", + dims, _mesa_lookup_enum_by_nr(target)); + return; + } + + error = compressed_texture_error_check(ctx, dims, target, level, + internalFormat, width, height, depth, + border, imageSize, &reason); + + if (error) { + _mesa_error(ctx, error, "glCompressedTexImage%uD(%s)", dims, reason); + return; + } + +#if FEATURE_ES + /* XXX this is kind of a hack */ + if (dims == 2) { + switch (internalFormat) { + case GL_PALETTE4_RGB8_OES: + case GL_PALETTE4_RGBA8_OES: + case GL_PALETTE4_R5_G6_B5_OES: + case GL_PALETTE4_RGBA4_OES: + case GL_PALETTE4_RGB5_A1_OES: + case GL_PALETTE8_RGB8_OES: + case GL_PALETTE8_RGBA8_OES: + case GL_PALETTE8_R5_G6_B5_OES: + case GL_PALETTE8_RGBA4_OES: + case GL_PALETTE8_RGB5_A1_OES: + _mesa_cpal_compressed_teximage2d(target, level, internalFormat, + width, height, imageSize, data); + return; + } + } +#endif + + if (_mesa_is_proxy_texture(target)) { + /* Proxy texture: just check for errors and update proxy state */ + struct gl_texture_image *texImage; + + if (!error) { + struct gl_texture_object *texObj = + _mesa_get_current_tex_object(ctx, target); + gl_format texFormat = + _mesa_choose_texture_format(ctx, texObj, target, level, + internalFormat, GL_NONE, GL_NONE); + if (!legal_texture_size(ctx, texFormat, width, height, depth)) { + error = GL_OUT_OF_MEMORY; + } + } + + texImage = _mesa_get_proxy_tex_image(ctx, target, level); + if (texImage) { + if (error) { + /* if error, clear all proxy texture image parameters */ + clear_teximage_fields(texImage); + } + else { + /* no error: store the teximage parameters */ + _mesa_init_teximage_fields(ctx, target, texImage, width, height, + depth, border, internalFormat, + MESA_FORMAT_NONE); + } + } + } + else { + /* non-proxy target */ + struct gl_texture_object *texObj; + struct gl_texture_image *texImage; + + if (error) { + _mesa_error(ctx, error, "glCompressedTexImage%uD", dims); + return; + } + + texObj = _mesa_get_current_tex_object(ctx, target); + + _mesa_lock_texture(ctx, texObj); + { + texImage = _mesa_get_tex_image(ctx, texObj, target, level); + if (!texImage) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, + "glCompressedTexImage%uD", dims); + } + else { + gl_format texFormat; + + ctx->Driver.FreeTextureImageBuffer(ctx, texImage); + ASSERT(texImage->Data == NULL); + + texFormat = _mesa_choose_texture_format(ctx, texObj, target, level, + internalFormat, GL_NONE, + GL_NONE); + + if (legal_texture_size(ctx, texFormat, width, height, depth)) { + _mesa_init_teximage_fields(ctx, target, texImage, + width, height, depth, + border, internalFormat, texFormat); + + switch (dims) { + case 1: + ASSERT(ctx->Driver.CompressedTexImage1D); + ctx->Driver.CompressedTexImage1D(ctx, target, level, + internalFormat, + width, + border, imageSize, data, + texObj, texImage); + break; + case 2: + ASSERT(ctx->Driver.CompressedTexImage2D); + ctx->Driver.CompressedTexImage2D(ctx, target, level, + internalFormat, + width, height, + border, imageSize, data, + texObj, texImage); + break; + case 3: + ASSERT(ctx->Driver.CompressedTexImage3D); + ctx->Driver.CompressedTexImage3D(ctx, target, level, + internalFormat, + width, height, depth, + border, imageSize, data, + texObj, texImage); + break; + default: + _mesa_problem(ctx, "bad dims in compressedteximage"); + } + + check_gen_mipmap(ctx, target, texObj, level); + + /* state update */ + texObj->_Complete = GL_FALSE; + ctx->NewState |= _NEW_TEXTURE; + } + else { + _mesa_error(ctx, GL_OUT_OF_MEMORY, + "glCompressedTexImage%uD", dims); + } + } + } + _mesa_unlock_texture(ctx, texObj); + } +} + + +void GLAPIENTRY +_mesa_CompressedTexImage1DARB(GLenum target, GLint level, + GLenum internalFormat, GLsizei width, + GLint border, GLsizei imageSize, + const GLvoid *data) +{ + GET_CURRENT_CONTEXT(ctx); + compressedteximage(ctx, 1, target, level, internalFormat, + width, 1, 1, border, imageSize, data); +} + + +void GLAPIENTRY +_mesa_CompressedTexImage2DARB(GLenum target, GLint level, + GLenum internalFormat, GLsizei width, + GLsizei height, GLint border, GLsizei imageSize, + const GLvoid *data) +{ + GET_CURRENT_CONTEXT(ctx); + compressedteximage(ctx, 2, target, level, internalFormat, + width, height, 1, border, imageSize, data); +} + + +void GLAPIENTRY +_mesa_CompressedTexImage3DARB(GLenum target, GLint level, + GLenum internalFormat, GLsizei width, + GLsizei height, GLsizei depth, GLint border, + GLsizei imageSize, const GLvoid *data) +{ + GET_CURRENT_CONTEXT(ctx); + compressedteximage(ctx, 3, target, level, internalFormat, + width, height, depth, border, imageSize, data); +} + + +/** + * Common helper for glCompressedTexSubImage1/2/3D(). + */ +static void +compressed_tex_sub_image(GLuint dims, GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLsizei width, GLsizei height, GLsizei depth, + GLenum format, GLsizei imageSize, const GLvoid *data) +{ + struct gl_texture_object *texObj; + struct gl_texture_image *texImage; + GLenum error; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + error = compressed_subtexture_error_check(ctx, dims, target, level, + xoffset, 0, 0, /* pos */ + width, height, depth, /* size */ + format, imageSize); + if (error) { + _mesa_error(ctx, error, "glCompressedTexSubImage%uD", dims); + return; + } + + texObj = _mesa_get_current_tex_object(ctx, target); + + _mesa_lock_texture(ctx, texObj); + { + texImage = _mesa_select_tex_image(ctx, texObj, target, level); + assert(texImage); + + if (compressed_subtexture_error_check2(ctx, dims, width, height, depth, + format, texImage)) { + /* error was recorded */ + } + else if (width > 0 && height > 0 && depth > 0) { + switch (dims) { + case 1: + if (ctx->Driver.CompressedTexSubImage1D) { + ctx->Driver.CompressedTexSubImage1D(ctx, target, level, + xoffset, width, + format, imageSize, data, + texObj, texImage); + } + break; + case 2: + if (ctx->Driver.CompressedTexSubImage2D) { + ctx->Driver.CompressedTexSubImage2D(ctx, target, level, + xoffset, yoffset, + width, height, + format, imageSize, data, + texObj, texImage); + } + break; + case 3: + if (ctx->Driver.CompressedTexSubImage3D) { + ctx->Driver.CompressedTexSubImage3D(ctx, target, level, + xoffset, yoffset, zoffset, + width, height, depth, + format, imageSize, data, + texObj, texImage); + } + break; + default: + ; + } + + check_gen_mipmap(ctx, target, texObj, level); + + ctx->NewState |= _NEW_TEXTURE; + } + } + _mesa_unlock_texture(ctx, texObj); +} + + +void GLAPIENTRY +_mesa_CompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset, + GLsizei width, GLenum format, + GLsizei imageSize, const GLvoid *data) +{ + compressed_tex_sub_image(1, target, level, xoffset, 0, 0, width, 1, 1, + format, imageSize, data); +} + + +void GLAPIENTRY +_mesa_CompressedTexSubImage2DARB(GLenum target, GLint level, GLint xoffset, + GLint yoffset, GLsizei width, GLsizei height, + GLenum format, GLsizei imageSize, + const GLvoid *data) +{ + compressed_tex_sub_image(2, target, level, xoffset, yoffset, 0, + width, height, 1, format, imageSize, data); +} + + +void GLAPIENTRY +_mesa_CompressedTexSubImage3DARB(GLenum target, GLint level, GLint xoffset, + GLint yoffset, GLint zoffset, GLsizei width, + GLsizei height, GLsizei depth, GLenum format, + GLsizei imageSize, const GLvoid *data) +{ + compressed_tex_sub_image(3, target, level, xoffset, yoffset, zoffset, + width, height, depth, format, imageSize, data); +} + + +/** + * Helper for glTexBuffer(). Check if internalFormat is legal. If so, + * return the basic data type and number of components for the format. + * \param return GL_TRUE if internalFormat is legal, GL_FALSE otherwise + */ +static GLboolean +get_sized_format_info(const struct gl_context *ctx, GLenum internalFormat, + GLenum *datatype, GLuint *components) +{ + switch (internalFormat) { + case GL_ALPHA8: + *datatype = GL_UNSIGNED_BYTE; + *components = 1; + break; + case GL_ALPHA16: + *datatype = GL_UNSIGNED_SHORT; + *components = 1; + break; + case GL_ALPHA16F_ARB: + *datatype = GL_HALF_FLOAT; + *components = 1; + break; + case GL_ALPHA32F_ARB: + *datatype = GL_FLOAT; + *components = 1; + break; + case GL_ALPHA8I_EXT: + *datatype = GL_BYTE; + *components = 1; + break; + case GL_ALPHA16I_EXT: + *datatype = GL_SHORT; + *components = 1; + break; + case GL_ALPHA32I_EXT: + *datatype = GL_INT; + *components = 1; + break; + case GL_ALPHA8UI_EXT: + *datatype = GL_UNSIGNED_BYTE; + *components = 1; + break; + case GL_ALPHA16UI_EXT: + *datatype = GL_UNSIGNED_SHORT; + *components = 1; + break; + case GL_ALPHA32UI_EXT: + *datatype = GL_UNSIGNED_INT; + *components = 1; + break; + case GL_LUMINANCE8: + *datatype = GL_UNSIGNED_BYTE; + *components = 1; + break; + case GL_LUMINANCE16: + *datatype = GL_UNSIGNED_SHORT; + *components = 1; + break; + case GL_LUMINANCE16F_ARB: + *datatype = GL_HALF_FLOAT; + *components = 1; + break; + case GL_LUMINANCE32F_ARB: + *datatype = GL_FLOAT; + *components = 1; + break; + case GL_LUMINANCE8I_EXT: + *datatype = GL_BYTE; + *components = 1; + break; + case GL_LUMINANCE16I_EXT: + *datatype = GL_SHORT; + *components = 1; + break; + case GL_LUMINANCE32I_EXT: + *datatype = GL_INT; + *components = 1; + break; + case GL_LUMINANCE8UI_EXT: + *datatype = GL_UNSIGNED_BYTE; + *components = 1; + break; + case GL_LUMINANCE16UI_EXT: + *datatype = GL_UNSIGNED_SHORT; + *components = 1; + break; + case GL_LUMINANCE32UI_EXT: + *datatype = GL_UNSIGNED_INT; + *components = 1; + break; + case GL_LUMINANCE8_ALPHA8: + *datatype = GL_UNSIGNED_BYTE; + *components = 2; + break; + case GL_LUMINANCE16_ALPHA16: + *datatype = GL_UNSIGNED_SHORT; + *components = 2; + break; + case GL_LUMINANCE_ALPHA16F_ARB: + *datatype = GL_HALF_FLOAT; + *components = 2; + break; + case GL_LUMINANCE_ALPHA32F_ARB: + *datatype = GL_FLOAT; + *components = 2; + break; + case GL_LUMINANCE_ALPHA8I_EXT: + *datatype = GL_BYTE; + *components = 2; + break; + case GL_LUMINANCE_ALPHA16I_EXT: + *datatype = GL_SHORT; + *components = 2; + break; + case GL_LUMINANCE_ALPHA32I_EXT: + *datatype = GL_INT; + *components = 2; + break; + case GL_LUMINANCE_ALPHA8UI_EXT: + *datatype = GL_UNSIGNED_BYTE; + *components = 2; + break; + case GL_LUMINANCE_ALPHA16UI_EXT: + *datatype = GL_UNSIGNED_SHORT; + *components = 2; + break; + case GL_LUMINANCE_ALPHA32UI_EXT: + *datatype = GL_UNSIGNED_INT; + *components = 2; + break; + case GL_INTENSITY8: + *datatype = GL_UNSIGNED_BYTE; + *components = 1; + break; + case GL_INTENSITY16: + *datatype = GL_UNSIGNED_SHORT; + *components = 1; + break; + case GL_INTENSITY16F_ARB: + *datatype = GL_HALF_FLOAT; + *components = 1; + break; + case GL_INTENSITY32F_ARB: + *datatype = GL_FLOAT; + *components = 1; + break; + case GL_INTENSITY8I_EXT: + *datatype = GL_BYTE; + *components = 1; + break; + case GL_INTENSITY16I_EXT: + *datatype = GL_SHORT; + *components = 1; + break; + case GL_INTENSITY32I_EXT: + *datatype = GL_INT; + *components = 1; + break; + case GL_INTENSITY8UI_EXT: + *datatype = GL_UNSIGNED_BYTE; + *components = 1; + break; + case GL_INTENSITY16UI_EXT: + *datatype = GL_UNSIGNED_SHORT; + *components = 1; + break; + case GL_INTENSITY32UI_EXT: + *datatype = GL_UNSIGNED_INT; + *components = 1; + break; + case GL_RGBA8: + *datatype = GL_UNSIGNED_BYTE; + *components = 4; + break; + case GL_RGBA16: + *datatype = GL_UNSIGNED_SHORT; + *components = 4; + break; + case GL_RGBA16F_ARB: + *datatype = GL_HALF_FLOAT; + *components = 4; + break; + case GL_RGBA32F_ARB: + *datatype = GL_FLOAT; + *components = 4; + break; + case GL_RGBA8I_EXT: + *datatype = GL_BYTE; + *components = 4; + break; + case GL_RGBA16I_EXT: + *datatype = GL_SHORT; + *components = 4; + break; + case GL_RGBA32I_EXT: + *datatype = GL_INT; + *components = 4; + break; + case GL_RGBA8UI_EXT: + *datatype = GL_UNSIGNED_BYTE; + *components = 4; + break; + case GL_RGBA16UI_EXT: + *datatype = GL_UNSIGNED_SHORT; + *components = 4; + break; + case GL_RGBA32UI_EXT: + *datatype = GL_UNSIGNED_INT; + *components = 4; + break; + default: + return GL_FALSE; + } + + if (*datatype == GL_FLOAT && !ctx->Extensions.ARB_texture_float) + return GL_FALSE; + + if (*datatype == GL_HALF_FLOAT && !ctx->Extensions.ARB_half_float_pixel) + return GL_FALSE; + + return GL_TRUE; +} + + +/** GL_ARB_texture_buffer_object */ +void GLAPIENTRY +_mesa_TexBuffer(GLenum target, GLenum internalFormat, GLuint buffer) +{ + struct gl_texture_object *texObj; + struct gl_buffer_object *bufObj; + GLenum dataType; + GLuint comps; + + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + if (!ctx->Extensions.ARB_texture_buffer_object) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glTexBuffer"); + return; + } + + if (target != GL_TEXTURE_BUFFER_ARB) { + _mesa_error(ctx, GL_INVALID_ENUM, "glTexBuffer(target)"); + return; + } + + if (!get_sized_format_info(ctx, internalFormat, &dataType, &comps)) { + _mesa_error(ctx, GL_INVALID_ENUM, "glTexBuffer(internalFormat 0x%x)", + internalFormat); + return; + } + + bufObj = _mesa_lookup_bufferobj(ctx, buffer); + if (buffer && !bufObj) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glTexBuffer(buffer %u)", buffer); + return; + } + + texObj = _mesa_get_current_tex_object(ctx, target); + + _mesa_lock_texture(ctx, texObj); + { + _mesa_reference_buffer_object(ctx, &texObj->BufferObject, bufObj); + texObj->BufferObjectFormat = internalFormat; + } + _mesa_unlock_texture(ctx, texObj); +} diff --git a/mesalib/src/mesa/main/texobj.c b/mesalib/src/mesa/main/texobj.c index 0a940d72d..1168f1842 100644 --- a/mesalib/src/mesa/main/texobj.c +++ b/mesalib/src/mesa/main/texobj.c @@ -1,1276 +1,1276 @@ -/** - * \file texobj.c - * Texture object management. - */ - -/* - * 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 "mfeatures.h" -#include "bufferobj.h" -#include "colortab.h" -#include "context.h" -#include "enums.h" -#include "fbobject.h" -#include "formats.h" -#include "hash.h" -#include "imports.h" -#include "macros.h" -#include "teximage.h" -#include "texobj.h" -#include "texstate.h" -#include "mtypes.h" -#include "program/prog_instruction.h" - - - -/**********************************************************************/ -/** \name Internal functions */ -/*@{*/ - - -/** - * Return the gl_texture_object for a given ID. - */ -struct gl_texture_object * -_mesa_lookup_texture(struct gl_context *ctx, GLuint id) -{ - return (struct gl_texture_object *) - _mesa_HashLookup(ctx->Shared->TexObjects, id); -} - - - -/** - * Allocate and initialize a new texture object. But don't put it into the - * texture object hash table. - * - * Called via ctx->Driver.NewTextureObject, unless overridden by a device - * driver. - * - * \param shared the shared GL state structure to contain the texture object - * \param name integer name for the texture object - * \param target either GL_TEXTURE_1D, GL_TEXTURE_2D, GL_TEXTURE_3D, - * GL_TEXTURE_CUBE_MAP_ARB or GL_TEXTURE_RECTANGLE_NV. zero is ok for the sake - * of GenTextures() - * - * \return pointer to new texture object. - */ -struct gl_texture_object * -_mesa_new_texture_object( struct gl_context *ctx, GLuint name, GLenum target ) -{ - struct gl_texture_object *obj; - (void) ctx; - obj = MALLOC_STRUCT(gl_texture_object); - _mesa_initialize_texture_object(obj, name, target); - return obj; -} - - -/** - * Initialize a new texture object to default values. - * \param obj the texture object - * \param name the texture name - * \param target the texture target - */ -void -_mesa_initialize_texture_object( struct gl_texture_object *obj, - GLuint name, GLenum target ) -{ - ASSERT(target == 0 || - target == GL_TEXTURE_1D || - target == GL_TEXTURE_2D || - target == GL_TEXTURE_3D || - target == GL_TEXTURE_CUBE_MAP_ARB || - target == GL_TEXTURE_RECTANGLE_NV || - target == GL_TEXTURE_1D_ARRAY_EXT || - target == GL_TEXTURE_2D_ARRAY_EXT || - target == GL_TEXTURE_BUFFER); - - memset(obj, 0, sizeof(*obj)); - /* init the non-zero fields */ - _glthread_INIT_MUTEX(obj->Mutex); - obj->RefCount = 1; - obj->Name = name; - obj->Target = target; - obj->Priority = 1.0F; - obj->BaseLevel = 0; - obj->MaxLevel = 1000; - - /* sampler state */ - if (target == GL_TEXTURE_RECTANGLE_NV) { - obj->Sampler.WrapS = GL_CLAMP_TO_EDGE; - obj->Sampler.WrapT = GL_CLAMP_TO_EDGE; - obj->Sampler.WrapR = GL_CLAMP_TO_EDGE; - obj->Sampler.MinFilter = GL_LINEAR; - } - else { - obj->Sampler.WrapS = GL_REPEAT; - obj->Sampler.WrapT = GL_REPEAT; - obj->Sampler.WrapR = GL_REPEAT; - obj->Sampler.MinFilter = GL_NEAREST_MIPMAP_LINEAR; - } - obj->Sampler.MagFilter = GL_LINEAR; - obj->Sampler.MinLod = -1000.0; - obj->Sampler.MaxLod = 1000.0; - obj->Sampler.LodBias = 0.0; - obj->Sampler.MaxAnisotropy = 1.0; - obj->Sampler.CompareMode = GL_NONE; /* ARB_shadow */ - obj->Sampler.CompareFunc = GL_LEQUAL; /* ARB_shadow */ - obj->Sampler.CompareFailValue = 0.0F; /* ARB_shadow_ambient */ - obj->Sampler.DepthMode = GL_LUMINANCE; /* ARB_depth_texture */ - obj->Sampler.CubeMapSeamless = GL_FALSE; - obj->Swizzle[0] = GL_RED; - obj->Swizzle[1] = GL_GREEN; - obj->Swizzle[2] = GL_BLUE; - obj->Swizzle[3] = GL_ALPHA; - obj->_Swizzle = SWIZZLE_NOOP; - obj->Sampler.sRGBDecode = GL_DECODE_EXT; -} - - -/** - * Some texture initialization can't be finished until we know which - * target it's getting bound to (GL_TEXTURE_1D/2D/etc). - */ -static void -finish_texture_init(struct gl_context *ctx, GLenum target, - struct gl_texture_object *obj) -{ - assert(obj->Target == 0); - - if (target == GL_TEXTURE_RECTANGLE_NV) { - /* have to init wrap and filter state here - kind of klunky */ - obj->Sampler.WrapS = GL_CLAMP_TO_EDGE; - obj->Sampler.WrapT = GL_CLAMP_TO_EDGE; - obj->Sampler.WrapR = GL_CLAMP_TO_EDGE; - obj->Sampler.MinFilter = GL_LINEAR; - if (ctx->Driver.TexParameter) { - static const GLfloat fparam_wrap[1] = {(GLfloat) GL_CLAMP_TO_EDGE}; - static const GLfloat fparam_filter[1] = {(GLfloat) GL_LINEAR}; - ctx->Driver.TexParameter(ctx, target, obj, GL_TEXTURE_WRAP_S, fparam_wrap); - ctx->Driver.TexParameter(ctx, target, obj, GL_TEXTURE_WRAP_T, fparam_wrap); - ctx->Driver.TexParameter(ctx, target, obj, GL_TEXTURE_WRAP_R, fparam_wrap); - ctx->Driver.TexParameter(ctx, target, obj, GL_TEXTURE_MIN_FILTER, fparam_filter); - } - } -} - - -/** - * Deallocate a texture object struct. It should have already been - * removed from the texture object pool. - * Called via ctx->Driver.DeleteTexture() if not overriden by a driver. - * - * \param shared the shared GL state to which the object belongs. - * \param texObj the texture object to delete. - */ -void -_mesa_delete_texture_object(struct gl_context *ctx, - struct gl_texture_object *texObj) -{ - GLuint i, face; - - /* Set Target to an invalid value. With some assertions elsewhere - * we can try to detect possible use of deleted textures. - */ - texObj->Target = 0x99; - - /* free the texture images */ - for (face = 0; face < 6; face++) { - for (i = 0; i < MAX_TEXTURE_LEVELS; i++) { - if (texObj->Image[face][i]) { - _mesa_delete_texture_image( ctx, texObj->Image[face][i] ); - } - } - } - - _mesa_reference_buffer_object(ctx, &texObj->BufferObject, NULL); - - /* destroy the mutex -- it may have allocated memory (eg on bsd) */ - _glthread_DESTROY_MUTEX(texObj->Mutex); - - /* free this object */ - free(texObj); -} - - - -/** - * Copy texture object state from one texture object to another. - * Use for glPush/PopAttrib. - * - * \param dest destination texture object. - * \param src source texture object. - */ -void -_mesa_copy_texture_object( struct gl_texture_object *dest, - const struct gl_texture_object *src ) -{ - dest->Target = src->Target; - dest->Name = src->Name; - dest->Priority = src->Priority; - dest->Sampler.BorderColor.f[0] = src->Sampler.BorderColor.f[0]; - dest->Sampler.BorderColor.f[1] = src->Sampler.BorderColor.f[1]; - dest->Sampler.BorderColor.f[2] = src->Sampler.BorderColor.f[2]; - dest->Sampler.BorderColor.f[3] = src->Sampler.BorderColor.f[3]; - dest->Sampler.WrapS = src->Sampler.WrapS; - dest->Sampler.WrapT = src->Sampler.WrapT; - dest->Sampler.WrapR = src->Sampler.WrapR; - dest->Sampler.MinFilter = src->Sampler.MinFilter; - dest->Sampler.MagFilter = src->Sampler.MagFilter; - dest->Sampler.MinLod = src->Sampler.MinLod; - dest->Sampler.MaxLod = src->Sampler.MaxLod; - dest->Sampler.LodBias = src->Sampler.LodBias; - dest->BaseLevel = src->BaseLevel; - dest->MaxLevel = src->MaxLevel; - dest->Sampler.MaxAnisotropy = src->Sampler.MaxAnisotropy; - dest->Sampler.CompareMode = src->Sampler.CompareMode; - dest->Sampler.CompareFunc = src->Sampler.CompareFunc; - dest->Sampler.CompareFailValue = src->Sampler.CompareFailValue; - dest->Sampler.CubeMapSeamless = src->Sampler.CubeMapSeamless; - dest->Sampler.DepthMode = src->Sampler.DepthMode; - dest->Sampler.sRGBDecode = src->Sampler.sRGBDecode; - dest->_MaxLevel = src->_MaxLevel; - dest->_MaxLambda = src->_MaxLambda; - dest->GenerateMipmap = src->GenerateMipmap; - dest->_Complete = src->_Complete; - COPY_4V(dest->Swizzle, src->Swizzle); - dest->_Swizzle = src->_Swizzle; -} - - -/** - * Free all texture images of the given texture object. - * - * \param ctx GL context. - * \param t texture object. - * - * \sa _mesa_clear_texture_image(). - */ -void -_mesa_clear_texture_object(struct gl_context *ctx, - struct gl_texture_object *texObj) -{ - GLuint i, j; - - if (texObj->Target == 0) - return; - - for (i = 0; i < MAX_FACES; i++) { - for (j = 0; j < MAX_TEXTURE_LEVELS; j++) { - struct gl_texture_image *texImage = texObj->Image[i][j]; - if (texImage) - _mesa_clear_texture_image(ctx, texImage); - } - } -} - - -/** - * Check if the given texture object is valid by examining its Target field. - * For debugging only. - */ -static GLboolean -valid_texture_object(const struct gl_texture_object *tex) -{ - switch (tex->Target) { - case 0: - case GL_TEXTURE_1D: - case GL_TEXTURE_2D: - case GL_TEXTURE_3D: - case GL_TEXTURE_CUBE_MAP_ARB: - case GL_TEXTURE_RECTANGLE_NV: - case GL_TEXTURE_1D_ARRAY_EXT: - case GL_TEXTURE_2D_ARRAY_EXT: - case GL_TEXTURE_BUFFER: - return GL_TRUE; - case 0x99: - _mesa_problem(NULL, "invalid reference to a deleted texture object"); - return GL_FALSE; - default: - _mesa_problem(NULL, "invalid texture object Target 0x%x, Id = %u", - tex->Target, tex->Name); - return GL_FALSE; - } -} - - -/** - * Reference (or unreference) a texture object. - * If '*ptr', decrement *ptr's refcount (and delete if it becomes zero). - * If 'tex' is non-null, increment its refcount. - * This is normally only called from the _mesa_reference_texobj() macro - * when there's a real pointer change. - */ -void -_mesa_reference_texobj_(struct gl_texture_object **ptr, - struct gl_texture_object *tex) -{ - assert(ptr); - - if (*ptr) { - /* Unreference the old texture */ - GLboolean deleteFlag = GL_FALSE; - struct gl_texture_object *oldTex = *ptr; - - ASSERT(valid_texture_object(oldTex)); - (void) valid_texture_object; /* silence warning in release builds */ - - _glthread_LOCK_MUTEX(oldTex->Mutex); - ASSERT(oldTex->RefCount > 0); - oldTex->RefCount--; - - deleteFlag = (oldTex->RefCount == 0); - _glthread_UNLOCK_MUTEX(oldTex->Mutex); - - if (deleteFlag) { - GET_CURRENT_CONTEXT(ctx); - if (ctx) - ctx->Driver.DeleteTexture(ctx, oldTex); - else - _mesa_problem(NULL, "Unable to delete texture, no context"); - } - - *ptr = NULL; - } - assert(!*ptr); - - if (tex) { - /* reference new texture */ - ASSERT(valid_texture_object(tex)); - _glthread_LOCK_MUTEX(tex->Mutex); - if (tex->RefCount == 0) { - /* this texture's being deleted (look just above) */ - /* Not sure this can every really happen. Warn if it does. */ - _mesa_problem(NULL, "referencing deleted texture object"); - *ptr = NULL; - } - else { - tex->RefCount++; - *ptr = tex; - } - _glthread_UNLOCK_MUTEX(tex->Mutex); - } -} - - - -/** - * Mark a texture object as incomplete. - * \param t texture object - * \param fmt... string describing why it's incomplete (for debugging). - */ -static void -incomplete(struct gl_texture_object *t, const char *fmt, ...) -{ -#if 0 - va_list args; - char s[100]; - - va_start(args, fmt); - vsnprintf(s, sizeof(s), fmt, args); - va_end(args); - - printf("Texture Obj %d incomplete because: %s\n", t->Name, s); -#endif - t->_Complete = GL_FALSE; -} - - -/** - * Examine a texture object to determine if it is complete. - * - * The gl_texture_object::Complete flag will be set to GL_TRUE or GL_FALSE - * accordingly. - * - * \param ctx GL context. - * \param t texture object. - * - * According to the texture target, verifies that each of the mipmaps is - * present and has the expected size. - */ -void -_mesa_test_texobj_completeness( const struct gl_context *ctx, - struct gl_texture_object *t ) -{ - const GLint baseLevel = t->BaseLevel; - GLint maxLog2 = 0, maxLevels = 0; - - t->_Complete = GL_TRUE; /* be optimistic */ - - /* Detect cases where the application set the base level to an invalid - * value. - */ - if ((baseLevel < 0) || (baseLevel >= MAX_TEXTURE_LEVELS)) { - incomplete(t, "base level = %d is invalid", baseLevel); - return; - } - - /* Always need the base level image */ - if (!t->Image[0][baseLevel]) { - incomplete(t, "Image[baseLevel=%d] == NULL", baseLevel); - return; - } - - /* Check width/height/depth for zero */ - if (t->Image[0][baseLevel]->Width == 0 || - t->Image[0][baseLevel]->Height == 0 || - t->Image[0][baseLevel]->Depth == 0) { - incomplete(t, "texture width = 0"); - return; - } - - /* Compute _MaxLevel */ - if ((t->Target == GL_TEXTURE_1D) || - (t->Target == GL_TEXTURE_1D_ARRAY_EXT)) { - maxLog2 = t->Image[0][baseLevel]->WidthLog2; - maxLevels = ctx->Const.MaxTextureLevels; - } - else if ((t->Target == GL_TEXTURE_2D) || - (t->Target == GL_TEXTURE_2D_ARRAY_EXT)) { - maxLog2 = MAX2(t->Image[0][baseLevel]->WidthLog2, - t->Image[0][baseLevel]->HeightLog2); - maxLevels = ctx->Const.MaxTextureLevels; - } - else if (t->Target == GL_TEXTURE_3D) { - GLint max = MAX2(t->Image[0][baseLevel]->WidthLog2, - t->Image[0][baseLevel]->HeightLog2); - maxLog2 = MAX2(max, (GLint)(t->Image[0][baseLevel]->DepthLog2)); - maxLevels = ctx->Const.Max3DTextureLevels; - } - else if (t->Target == GL_TEXTURE_CUBE_MAP_ARB) { - maxLog2 = MAX2(t->Image[0][baseLevel]->WidthLog2, - t->Image[0][baseLevel]->HeightLog2); - maxLevels = ctx->Const.MaxCubeTextureLevels; - } - else if (t->Target == GL_TEXTURE_RECTANGLE_NV) { - maxLog2 = 0; /* not applicable */ - maxLevels = 1; /* no mipmapping */ - } - else { - _mesa_problem(ctx, "Bad t->Target in _mesa_test_texobj_completeness"); - return; - } - - ASSERT(maxLevels > 0); - - if (t->MaxLevel < t->BaseLevel) { - incomplete(t, "MAX_LEVEL (%d) < BASE_LEVEL (%d)", - t->MaxLevel, t->BaseLevel); - return; - } - - t->_MaxLevel = baseLevel + maxLog2; - t->_MaxLevel = MIN2(t->_MaxLevel, t->MaxLevel); - t->_MaxLevel = MIN2(t->_MaxLevel, maxLevels - 1); - - /* Compute _MaxLambda = q - b (see the 1.2 spec) used during mipmapping */ - t->_MaxLambda = (GLfloat) (t->_MaxLevel - t->BaseLevel); - - if (t->Target == GL_TEXTURE_CUBE_MAP_ARB) { - /* make sure that all six cube map level 0 images are the same size */ - const GLuint w = t->Image[0][baseLevel]->Width2; - const GLuint h = t->Image[0][baseLevel]->Height2; - GLuint face; - for (face = 1; face < 6; face++) { - if (t->Image[face][baseLevel] == NULL || - t->Image[face][baseLevel]->Width2 != w || - t->Image[face][baseLevel]->Height2 != h) { - incomplete(t, "Cube face missing or mismatched size"); - return; - } - } - } - - /* extra checking for mipmaps */ - if (t->Sampler.MinFilter != GL_NEAREST && t->Sampler.MinFilter != GL_LINEAR) { - /* - * Mipmapping: determine if we have a complete set of mipmaps - */ - GLint i; - GLint minLevel = baseLevel; - GLint maxLevel = t->_MaxLevel; - - if (minLevel > maxLevel) { - incomplete(t, "minLevel > maxLevel"); - return; - } - - /* Test dimension-independent attributes */ - for (i = minLevel; i <= maxLevel; i++) { - if (t->Image[0][i]) { - if (t->Image[0][i]->TexFormat != t->Image[0][baseLevel]->TexFormat) { - incomplete(t, "Format[i] != Format[baseLevel]"); - return; - } - if (t->Image[0][i]->Border != t->Image[0][baseLevel]->Border) { - incomplete(t, "Border[i] != Border[baseLevel]"); - return; - } - } - } - - /* Test things which depend on number of texture image dimensions */ - if ((t->Target == GL_TEXTURE_1D) || - (t->Target == GL_TEXTURE_1D_ARRAY_EXT)) { - /* Test 1-D mipmaps */ - GLuint width = t->Image[0][baseLevel]->Width2; - for (i = baseLevel + 1; i < maxLevels; i++) { - if (width > 1) { - width /= 2; - } - if (i >= minLevel && i <= maxLevel) { - if (!t->Image[0][i]) { - incomplete(t, "1D Image[0][i] == NULL"); - return; - } - if (t->Image[0][i]->Width2 != width ) { - incomplete(t, "1D Image[0][i] bad width"); - return; - } - } - if (width == 1) { - return; /* found smallest needed mipmap, all done! */ - } - } - } - else if ((t->Target == GL_TEXTURE_2D) || - (t->Target == GL_TEXTURE_2D_ARRAY_EXT)) { - /* Test 2-D mipmaps */ - GLuint width = t->Image[0][baseLevel]->Width2; - GLuint height = t->Image[0][baseLevel]->Height2; - for (i = baseLevel + 1; i < maxLevels; i++) { - if (width > 1) { - width /= 2; - } - if (height > 1) { - height /= 2; - } - if (i >= minLevel && i <= maxLevel) { - if (!t->Image[0][i]) { - incomplete(t, "2D Image[0][i] == NULL"); - return; - } - if (t->Image[0][i]->Width2 != width) { - incomplete(t, "2D Image[0][i] bad width"); - return; - } - if (t->Image[0][i]->Height2 != height) { - incomplete(t, "2D Image[0][i] bad height"); - return; - } - if (width==1 && height==1) { - return; /* found smallest needed mipmap, all done! */ - } - } - } - } - else if (t->Target == GL_TEXTURE_3D) { - /* Test 3-D mipmaps */ - GLuint width = t->Image[0][baseLevel]->Width2; - GLuint height = t->Image[0][baseLevel]->Height2; - GLuint depth = t->Image[0][baseLevel]->Depth2; - for (i = baseLevel + 1; i < maxLevels; i++) { - if (width > 1) { - width /= 2; - } - if (height > 1) { - height /= 2; - } - if (depth > 1) { - depth /= 2; - } - if (i >= minLevel && i <= maxLevel) { - if (!t->Image[0][i]) { - incomplete(t, "3D Image[0][i] == NULL"); - return; - } - if (t->Image[0][i]->_BaseFormat == GL_DEPTH_COMPONENT) { - incomplete(t, "GL_DEPTH_COMPONENT only works with 1/2D tex"); - return; - } - if (t->Image[0][i]->Width2 != width) { - incomplete(t, "3D Image[0][i] bad width"); - return; - } - if (t->Image[0][i]->Height2 != height) { - incomplete(t, "3D Image[0][i] bad height"); - return; - } - if (t->Image[0][i]->Depth2 != depth) { - incomplete(t, "3D Image[0][i] bad depth"); - return; - } - } - if (width == 1 && height == 1 && depth == 1) { - return; /* found smallest needed mipmap, all done! */ - } - } - } - else if (t->Target == GL_TEXTURE_CUBE_MAP_ARB) { - /* make sure 6 cube faces are consistant */ - GLuint width = t->Image[0][baseLevel]->Width2; - GLuint height = t->Image[0][baseLevel]->Height2; - for (i = baseLevel + 1; i < maxLevels; i++) { - if (width > 1) { - width /= 2; - } - if (height > 1) { - height /= 2; - } - if (i >= minLevel && i <= maxLevel) { - GLuint face; - for (face = 0; face < 6; face++) { - /* check that we have images defined */ - if (!t->Image[face][i]) { - incomplete(t, "CubeMap Image[n][i] == NULL"); - return; - } - /* Don't support GL_DEPTH_COMPONENT for cube maps */ - if (t->Image[face][i]->_BaseFormat == GL_DEPTH_COMPONENT) { - incomplete(t, "GL_DEPTH_COMPONENT only works with 1/2D tex"); - return; - } - /* check that all six images have same size */ - if (t->Image[face][i]->Width2 != width || - t->Image[face][i]->Height2 != height) { - incomplete(t, "CubeMap Image[n][i] bad size"); - return; - } - } - } - if (width == 1 && height == 1) { - return; /* found smallest needed mipmap, all done! */ - } - } - } - else if (t->Target == GL_TEXTURE_RECTANGLE_NV) { - /* XXX special checking? */ - } - else { - /* Target = ??? */ - _mesa_problem(ctx, "Bug in gl_test_texture_object_completeness\n"); - } - } -} - - -/** - * Check if the given cube map texture is "cube complete" as defined in - * the OpenGL specification. - */ -GLboolean -_mesa_cube_complete(const struct gl_texture_object *texObj) -{ - const GLint baseLevel = texObj->BaseLevel; - const struct gl_texture_image *img0, *img; - GLuint face; - - if (texObj->Target != GL_TEXTURE_CUBE_MAP) - return GL_FALSE; - - if ((baseLevel < 0) || (baseLevel >= MAX_TEXTURE_LEVELS)) - return GL_FALSE; - - /* check first face */ - img0 = texObj->Image[0][baseLevel]; - if (!img0 || - img0->Width < 1 || - img0->Width != img0->Height) - return GL_FALSE; - - /* check remaining faces vs. first face */ - for (face = 1; face < 6; face++) { - img = texObj->Image[face][baseLevel]; - if (!img || - img->Width != img0->Width || - img->Height != img0->Height || - img->TexFormat != img0->TexFormat) - return GL_FALSE; - } - - return GL_TRUE; -} - - -/** - * Mark a texture object dirty. It forces the object to be incomplete - * and optionally forces the context to re-validate its state. - * - * \param ctx GL context. - * \param texObj texture object. - * \param invalidate_state also invalidate context state. - */ -void -_mesa_dirty_texobj(struct gl_context *ctx, struct gl_texture_object *texObj, - GLboolean invalidate_state) -{ - texObj->_Complete = GL_FALSE; - if (invalidate_state) - ctx->NewState |= _NEW_TEXTURE; -} - - -/** - * Return pointer to a default/fallback texture. - * The texture is a 2D 8x8 RGBA texture with all texels = (0,0,0,1). - * That's the value a sampler should get when sampling from an - * incomplete texture. - */ -struct gl_texture_object * -_mesa_get_fallback_texture(struct gl_context *ctx) -{ - if (!ctx->Shared->FallbackTex) { - /* create fallback texture now */ - static GLubyte texels[8 * 8][4]; - struct gl_texture_object *texObj; - struct gl_texture_image *texImage; - gl_format texFormat; - GLuint i; - - for (i = 0; i < 8 * 8; i++) { - texels[i][0] = - texels[i][1] = - texels[i][2] = 0x0; - texels[i][3] = 0xff; - } - - /* create texture object */ - texObj = ctx->Driver.NewTextureObject(ctx, 0, GL_TEXTURE_2D); - assert(texObj->RefCount == 1); - texObj->Sampler.MinFilter = GL_NEAREST; - texObj->Sampler.MagFilter = GL_NEAREST; - - /* create level[0] texture image */ - texImage = _mesa_get_tex_image(ctx, texObj, GL_TEXTURE_2D, 0); - - texFormat = ctx->Driver.ChooseTextureFormat(ctx, GL_RGBA, GL_RGBA, - GL_UNSIGNED_BYTE); - - /* init the image fields */ - _mesa_init_teximage_fields(ctx, GL_TEXTURE_2D, texImage, - 8, 8, 1, 0, GL_RGBA, texFormat); - - ASSERT(texImage->TexFormat != MESA_FORMAT_NONE); - - /* set image data */ - ctx->Driver.TexImage2D(ctx, GL_TEXTURE_2D, 0, GL_RGBA, - 8, 8, 0, - GL_RGBA, GL_UNSIGNED_BYTE, texels, - &ctx->DefaultPacking, texObj, texImage); - - _mesa_test_texobj_completeness(ctx, texObj); - assert(texObj->_Complete); - - ctx->Shared->FallbackTex = texObj; - } - return ctx->Shared->FallbackTex; -} - - -/*@}*/ - - -/***********************************************************************/ -/** \name API functions */ -/*@{*/ - - -/** - * Generate texture names. - * - * \param n number of texture names to be generated. - * \param textures an array in which will hold the generated texture names. - * - * \sa glGenTextures(). - * - * Calls _mesa_HashFindFreeKeyBlock() to find a block of free texture - * IDs which are stored in \p textures. Corresponding empty texture - * objects are also generated. - */ -void GLAPIENTRY -_mesa_GenTextures( GLsizei n, GLuint *textures ) -{ - GET_CURRENT_CONTEXT(ctx); - GLuint first; - GLint i; - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (n < 0) { - _mesa_error( ctx, GL_INVALID_VALUE, "glGenTextures" ); - return; - } - - if (!textures) - return; - - /* - * This must be atomic (generation and allocation of texture IDs) - */ - _glthread_LOCK_MUTEX(ctx->Shared->Mutex); - - first = _mesa_HashFindFreeKeyBlock(ctx->Shared->TexObjects, n); - - /* Allocate new, empty texture objects */ - for (i = 0; i < n; i++) { - struct gl_texture_object *texObj; - GLuint name = first + i; - GLenum target = 0; - texObj = ctx->Driver.NewTextureObject(ctx, name, target); - if (!texObj) { - _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGenTextures"); - return; - } - - /* insert into hash table */ - _mesa_HashInsert(ctx->Shared->TexObjects, texObj->Name, texObj); - - textures[i] = name; - } - - _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); -} - - -/** - * Check if the given texture object is bound to the current draw or - * read framebuffer. If so, Unbind it. - */ -static void -unbind_texobj_from_fbo(struct gl_context *ctx, - struct gl_texture_object *texObj) -{ - const GLuint n = (ctx->DrawBuffer == ctx->ReadBuffer) ? 1 : 2; - GLuint i; - - for (i = 0; i < n; i++) { - struct gl_framebuffer *fb = (i == 0) ? ctx->DrawBuffer : ctx->ReadBuffer; - if (fb->Name) { - GLuint j; - for (j = 0; j < BUFFER_COUNT; j++) { - if (fb->Attachment[j].Type == GL_TEXTURE && - fb->Attachment[j].Texture == texObj) { - /* Vertices are already flushed by _mesa_DeleteTextures */ - ctx->NewState |= _NEW_BUFFERS; - _mesa_remove_attachment(ctx, fb->Attachment + j); - } - } - } - } -} - - -/** - * Check if the given texture object is bound to any texture image units and - * unbind it if so (revert to default textures). - */ -static void -unbind_texobj_from_texunits(struct gl_context *ctx, - struct gl_texture_object *texObj) -{ - GLuint u, tex; - - for (u = 0; u < Elements(ctx->Texture.Unit); u++) { - struct gl_texture_unit *unit = &ctx->Texture.Unit[u]; - for (tex = 0; tex < NUM_TEXTURE_TARGETS; tex++) { - if (texObj == unit->CurrentTex[tex]) { - _mesa_reference_texobj(&unit->CurrentTex[tex], - ctx->Shared->DefaultTex[tex]); - ASSERT(unit->CurrentTex[tex]); - break; - } - } - } -} - - -/** - * Delete named textures. - * - * \param n number of textures to be deleted. - * \param textures array of texture IDs to be deleted. - * - * \sa glDeleteTextures(). - * - * If we're about to delete a texture that's currently bound to any - * texture unit, unbind the texture first. Decrement the reference - * count on the texture object and delete it if it's zero. - * Recall that texture objects can be shared among several rendering - * contexts. - */ -void GLAPIENTRY -_mesa_DeleteTextures( GLsizei n, const GLuint *textures) -{ - GET_CURRENT_CONTEXT(ctx); - GLint i; - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); /* too complex */ - - if (!textures) - return; - - for (i = 0; i < n; i++) { - if (textures[i] > 0) { - struct gl_texture_object *delObj - = _mesa_lookup_texture(ctx, textures[i]); - - if (delObj) { - _mesa_lock_texture(ctx, delObj); - - /* Check if texture is bound to any framebuffer objects. - * If so, unbind. - * See section 4.4.2.3 of GL_EXT_framebuffer_object. - */ - unbind_texobj_from_fbo(ctx, delObj); - - /* Check if this texture is currently bound to any texture units. - * If so, unbind it. - */ - unbind_texobj_from_texunits(ctx, delObj); - - _mesa_unlock_texture(ctx, delObj); - - ctx->NewState |= _NEW_TEXTURE; - - /* The texture _name_ is now free for re-use. - * Remove it from the hash table now. - */ - _glthread_LOCK_MUTEX(ctx->Shared->Mutex); - _mesa_HashRemove(ctx->Shared->TexObjects, delObj->Name); - _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); - - /* Unreference the texobj. If refcount hits zero, the texture - * will be deleted. - */ - _mesa_reference_texobj(&delObj, NULL); - } - } - } -} - - -/** - * Convert a GL texture target enum such as GL_TEXTURE_2D or GL_TEXTURE_3D - * into the corresponding Mesa texture target index. - * Note that proxy targets are not valid here. - * \return TEXTURE_x_INDEX or -1 if target is invalid - */ -static GLint -target_enum_to_index(GLenum target) -{ - switch (target) { - case GL_TEXTURE_1D: - return TEXTURE_1D_INDEX; - case GL_TEXTURE_2D: - return TEXTURE_2D_INDEX; - case GL_TEXTURE_3D: - return TEXTURE_3D_INDEX; - case GL_TEXTURE_CUBE_MAP_ARB: - return TEXTURE_CUBE_INDEX; - case GL_TEXTURE_RECTANGLE_NV: - return TEXTURE_RECT_INDEX; - case GL_TEXTURE_1D_ARRAY_EXT: - return TEXTURE_1D_ARRAY_INDEX; - case GL_TEXTURE_2D_ARRAY_EXT: - return TEXTURE_2D_ARRAY_INDEX; - case GL_TEXTURE_BUFFER_ARB: - return TEXTURE_BUFFER_INDEX; - default: - return -1; - } -} - - -/** - * Bind a named texture to a texturing target. - * - * \param target texture target. - * \param texName texture name. - * - * \sa glBindTexture(). - * - * Determines the old texture object bound and returns immediately if rebinding - * the same texture. Get the current texture which is either a default texture - * if name is null, a named texture from the hash, or a new texture if the - * given texture name is new. Increments its reference count, binds it, and - * calls dd_function_table::BindTexture. Decrements the old texture reference - * count and deletes it if it reaches zero. - */ -void GLAPIENTRY -_mesa_BindTexture( GLenum target, GLuint texName ) -{ - GET_CURRENT_CONTEXT(ctx); - struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx); - struct gl_texture_object *newTexObj = NULL; - GLint targetIndex; - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE)) - _mesa_debug(ctx, "glBindTexture %s %d\n", - _mesa_lookup_enum_by_nr(target), (GLint) texName); - - targetIndex = target_enum_to_index(target); - if (targetIndex < 0) { - _mesa_error(ctx, GL_INVALID_ENUM, "glBindTexture(target)"); - return; - } - assert(targetIndex < NUM_TEXTURE_TARGETS); - - /* - * Get pointer to new texture object (newTexObj) - */ - if (texName == 0) { - /* Use a default texture object */ - newTexObj = ctx->Shared->DefaultTex[targetIndex]; - } - else { - /* non-default texture object */ - newTexObj = _mesa_lookup_texture(ctx, texName); - if (newTexObj) { - /* error checking */ - if (newTexObj->Target != 0 && newTexObj->Target != target) { - /* the named texture object's target doesn't match the given target */ - _mesa_error( ctx, GL_INVALID_OPERATION, - "glBindTexture(target mismatch)" ); - return; - } - if (newTexObj->Target == 0) { - finish_texture_init(ctx, target, newTexObj); - } - } - else { - /* if this is a new texture id, allocate a texture object now */ - newTexObj = ctx->Driver.NewTextureObject(ctx, texName, target); - if (!newTexObj) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindTexture"); - return; - } - - /* and insert it into hash table */ - _glthread_LOCK_MUTEX(ctx->Shared->Mutex); - _mesa_HashInsert(ctx->Shared->TexObjects, texName, newTexObj); - _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); - } - newTexObj->Target = target; - } - - assert(valid_texture_object(newTexObj)); - - /* Check if this texture is only used by this context and is already bound. - * If so, just return. - */ - { - GLboolean early_out; - _glthread_LOCK_MUTEX(ctx->Shared->Mutex); - early_out = ((ctx->Shared->RefCount == 1) - && (newTexObj == texUnit->CurrentTex[targetIndex])); - _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); - if (early_out) { - return; - } - } - - /* flush before changing binding */ - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - - /* Do the actual binding. The refcount on the previously bound - * texture object will be decremented. It'll be deleted if the - * count hits zero. - */ - _mesa_reference_texobj(&texUnit->CurrentTex[targetIndex], newTexObj); - ASSERT(texUnit->CurrentTex[targetIndex]); - - /* Pass BindTexture call to device driver */ - if (ctx->Driver.BindTexture) - ctx->Driver.BindTexture(ctx, target, newTexObj); -} - - -/** - * Set texture priorities. - * - * \param n number of textures. - * \param texName texture names. - * \param priorities corresponding texture priorities. - * - * \sa glPrioritizeTextures(). - * - * Looks up each texture in the hash, clamps the corresponding priority between - * 0.0 and 1.0, and calls dd_function_table::PrioritizeTexture. - */ -void GLAPIENTRY -_mesa_PrioritizeTextures( GLsizei n, const GLuint *texName, - const GLclampf *priorities ) -{ - GET_CURRENT_CONTEXT(ctx); - GLint i; - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (n < 0) { - _mesa_error( ctx, GL_INVALID_VALUE, "glPrioritizeTextures" ); - return; - } - - if (!priorities) - return; - - for (i = 0; i < n; i++) { - if (texName[i] > 0) { - struct gl_texture_object *t = _mesa_lookup_texture(ctx, texName[i]); - if (t) { - t->Priority = CLAMP( priorities[i], 0.0F, 1.0F ); - } - } - } - - ctx->NewState |= _NEW_TEXTURE; -} - - - -/** - * See if textures are loaded in texture memory. - * - * \param n number of textures to query. - * \param texName array with the texture names. - * \param residences array which will hold the residence status. - * - * \return GL_TRUE if all textures are resident and \p residences is left unchanged, - * - * \sa glAreTexturesResident(). - * - * Looks up each texture in the hash and calls - * dd_function_table::IsTextureResident. - */ -GLboolean GLAPIENTRY -_mesa_AreTexturesResident(GLsizei n, const GLuint *texName, - GLboolean *residences) -{ - GET_CURRENT_CONTEXT(ctx); - GLboolean allResident = GL_TRUE; - GLint i, j; - ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); - - if (n < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glAreTexturesResident(n)"); - return GL_FALSE; - } - - if (!texName || !residences) - return GL_FALSE; - - for (i = 0; i < n; i++) { - struct gl_texture_object *t; - if (texName[i] == 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glAreTexturesResident"); - return GL_FALSE; - } - t = _mesa_lookup_texture(ctx, texName[i]); - if (!t) { - _mesa_error(ctx, GL_INVALID_VALUE, "glAreTexturesResident"); - return GL_FALSE; - } - if (!ctx->Driver.IsTextureResident || - ctx->Driver.IsTextureResident(ctx, t)) { - /* The texture is resident */ - if (!allResident) - residences[i] = GL_TRUE; - } - else { - /* The texture is not resident */ - if (allResident) { - allResident = GL_FALSE; - for (j = 0; j < i; j++) - residences[j] = GL_TRUE; - } - residences[i] = GL_FALSE; - } - } - - return allResident; -} - - -/** - * See if a name corresponds to a texture. - * - * \param texture texture name. - * - * \return GL_TRUE if texture name corresponds to a texture, or GL_FALSE - * otherwise. - * - * \sa glIsTexture(). - * - * Calls _mesa_HashLookup(). - */ -GLboolean GLAPIENTRY -_mesa_IsTexture( GLuint texture ) -{ - struct gl_texture_object *t; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); - - if (!texture) - return GL_FALSE; - - t = _mesa_lookup_texture(ctx, texture); - - /* IsTexture is true only after object has been bound once. */ - return t && t->Target; -} - - -/** - * Simplest implementation of texture locking: grab the shared tex - * mutex. Examine the shared context state timestamp and if there has - * been a change, set the appropriate bits in ctx->NewState. - * - * This is used to deal with synchronizing things when a texture object - * is used/modified by different contexts (or threads) which are sharing - * the texture. - * - * See also _mesa_lock/unlock_texture() in teximage.h - */ -void -_mesa_lock_context_textures( struct gl_context *ctx ) -{ - _glthread_LOCK_MUTEX(ctx->Shared->TexMutex); - - if (ctx->Shared->TextureStateStamp != ctx->TextureStateTimestamp) { - ctx->NewState |= _NEW_TEXTURE; - ctx->TextureStateTimestamp = ctx->Shared->TextureStateStamp; - } -} - - -void -_mesa_unlock_context_textures( struct gl_context *ctx ) -{ - assert(ctx->Shared->TextureStateStamp == ctx->TextureStateTimestamp); - _glthread_UNLOCK_MUTEX(ctx->Shared->TexMutex); -} - -/*@}*/ +/** + * \file texobj.c + * Texture object management. + */ + +/* + * 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 "mfeatures.h" +#include "bufferobj.h" +#include "colortab.h" +#include "context.h" +#include "enums.h" +#include "fbobject.h" +#include "formats.h" +#include "hash.h" +#include "imports.h" +#include "macros.h" +#include "teximage.h" +#include "texobj.h" +#include "texstate.h" +#include "mtypes.h" +#include "program/prog_instruction.h" + + + +/**********************************************************************/ +/** \name Internal functions */ +/*@{*/ + + +/** + * Return the gl_texture_object for a given ID. + */ +struct gl_texture_object * +_mesa_lookup_texture(struct gl_context *ctx, GLuint id) +{ + return (struct gl_texture_object *) + _mesa_HashLookup(ctx->Shared->TexObjects, id); +} + + + +/** + * Allocate and initialize a new texture object. But don't put it into the + * texture object hash table. + * + * Called via ctx->Driver.NewTextureObject, unless overridden by a device + * driver. + * + * \param shared the shared GL state structure to contain the texture object + * \param name integer name for the texture object + * \param target either GL_TEXTURE_1D, GL_TEXTURE_2D, GL_TEXTURE_3D, + * GL_TEXTURE_CUBE_MAP_ARB or GL_TEXTURE_RECTANGLE_NV. zero is ok for the sake + * of GenTextures() + * + * \return pointer to new texture object. + */ +struct gl_texture_object * +_mesa_new_texture_object( struct gl_context *ctx, GLuint name, GLenum target ) +{ + struct gl_texture_object *obj; + (void) ctx; + obj = MALLOC_STRUCT(gl_texture_object); + _mesa_initialize_texture_object(obj, name, target); + return obj; +} + + +/** + * Initialize a new texture object to default values. + * \param obj the texture object + * \param name the texture name + * \param target the texture target + */ +void +_mesa_initialize_texture_object( struct gl_texture_object *obj, + GLuint name, GLenum target ) +{ + ASSERT(target == 0 || + target == GL_TEXTURE_1D || + target == GL_TEXTURE_2D || + target == GL_TEXTURE_3D || + target == GL_TEXTURE_CUBE_MAP_ARB || + target == GL_TEXTURE_RECTANGLE_NV || + target == GL_TEXTURE_1D_ARRAY_EXT || + target == GL_TEXTURE_2D_ARRAY_EXT || + target == GL_TEXTURE_BUFFER); + + memset(obj, 0, sizeof(*obj)); + /* init the non-zero fields */ + _glthread_INIT_MUTEX(obj->Mutex); + obj->RefCount = 1; + obj->Name = name; + obj->Target = target; + obj->Priority = 1.0F; + obj->BaseLevel = 0; + obj->MaxLevel = 1000; + + /* sampler state */ + if (target == GL_TEXTURE_RECTANGLE_NV) { + obj->Sampler.WrapS = GL_CLAMP_TO_EDGE; + obj->Sampler.WrapT = GL_CLAMP_TO_EDGE; + obj->Sampler.WrapR = GL_CLAMP_TO_EDGE; + obj->Sampler.MinFilter = GL_LINEAR; + } + else { + obj->Sampler.WrapS = GL_REPEAT; + obj->Sampler.WrapT = GL_REPEAT; + obj->Sampler.WrapR = GL_REPEAT; + obj->Sampler.MinFilter = GL_NEAREST_MIPMAP_LINEAR; + } + obj->Sampler.MagFilter = GL_LINEAR; + obj->Sampler.MinLod = -1000.0; + obj->Sampler.MaxLod = 1000.0; + obj->Sampler.LodBias = 0.0; + obj->Sampler.MaxAnisotropy = 1.0; + obj->Sampler.CompareMode = GL_NONE; /* ARB_shadow */ + obj->Sampler.CompareFunc = GL_LEQUAL; /* ARB_shadow */ + obj->Sampler.CompareFailValue = 0.0F; /* ARB_shadow_ambient */ + obj->Sampler.DepthMode = GL_LUMINANCE; /* ARB_depth_texture */ + obj->Sampler.CubeMapSeamless = GL_FALSE; + obj->Swizzle[0] = GL_RED; + obj->Swizzle[1] = GL_GREEN; + obj->Swizzle[2] = GL_BLUE; + obj->Swizzle[3] = GL_ALPHA; + obj->_Swizzle = SWIZZLE_NOOP; + obj->Sampler.sRGBDecode = GL_DECODE_EXT; +} + + +/** + * Some texture initialization can't be finished until we know which + * target it's getting bound to (GL_TEXTURE_1D/2D/etc). + */ +static void +finish_texture_init(struct gl_context *ctx, GLenum target, + struct gl_texture_object *obj) +{ + assert(obj->Target == 0); + + if (target == GL_TEXTURE_RECTANGLE_NV) { + /* have to init wrap and filter state here - kind of klunky */ + obj->Sampler.WrapS = GL_CLAMP_TO_EDGE; + obj->Sampler.WrapT = GL_CLAMP_TO_EDGE; + obj->Sampler.WrapR = GL_CLAMP_TO_EDGE; + obj->Sampler.MinFilter = GL_LINEAR; + if (ctx->Driver.TexParameter) { + static const GLfloat fparam_wrap[1] = {(GLfloat) GL_CLAMP_TO_EDGE}; + static const GLfloat fparam_filter[1] = {(GLfloat) GL_LINEAR}; + ctx->Driver.TexParameter(ctx, target, obj, GL_TEXTURE_WRAP_S, fparam_wrap); + ctx->Driver.TexParameter(ctx, target, obj, GL_TEXTURE_WRAP_T, fparam_wrap); + ctx->Driver.TexParameter(ctx, target, obj, GL_TEXTURE_WRAP_R, fparam_wrap); + ctx->Driver.TexParameter(ctx, target, obj, GL_TEXTURE_MIN_FILTER, fparam_filter); + } + } +} + + +/** + * Deallocate a texture object struct. It should have already been + * removed from the texture object pool. + * Called via ctx->Driver.DeleteTexture() if not overriden by a driver. + * + * \param shared the shared GL state to which the object belongs. + * \param texObj the texture object to delete. + */ +void +_mesa_delete_texture_object(struct gl_context *ctx, + struct gl_texture_object *texObj) +{ + GLuint i, face; + + /* Set Target to an invalid value. With some assertions elsewhere + * we can try to detect possible use of deleted textures. + */ + texObj->Target = 0x99; + + /* free the texture images */ + for (face = 0; face < 6; face++) { + for (i = 0; i < MAX_TEXTURE_LEVELS; i++) { + if (texObj->Image[face][i]) { + _mesa_delete_texture_image( ctx, texObj->Image[face][i] ); + } + } + } + + _mesa_reference_buffer_object(ctx, &texObj->BufferObject, NULL); + + /* destroy the mutex -- it may have allocated memory (eg on bsd) */ + _glthread_DESTROY_MUTEX(texObj->Mutex); + + /* free this object */ + free(texObj); +} + + + +/** + * Copy texture object state from one texture object to another. + * Use for glPush/PopAttrib. + * + * \param dest destination texture object. + * \param src source texture object. + */ +void +_mesa_copy_texture_object( struct gl_texture_object *dest, + const struct gl_texture_object *src ) +{ + dest->Target = src->Target; + dest->Name = src->Name; + dest->Priority = src->Priority; + dest->Sampler.BorderColor.f[0] = src->Sampler.BorderColor.f[0]; + dest->Sampler.BorderColor.f[1] = src->Sampler.BorderColor.f[1]; + dest->Sampler.BorderColor.f[2] = src->Sampler.BorderColor.f[2]; + dest->Sampler.BorderColor.f[3] = src->Sampler.BorderColor.f[3]; + dest->Sampler.WrapS = src->Sampler.WrapS; + dest->Sampler.WrapT = src->Sampler.WrapT; + dest->Sampler.WrapR = src->Sampler.WrapR; + dest->Sampler.MinFilter = src->Sampler.MinFilter; + dest->Sampler.MagFilter = src->Sampler.MagFilter; + dest->Sampler.MinLod = src->Sampler.MinLod; + dest->Sampler.MaxLod = src->Sampler.MaxLod; + dest->Sampler.LodBias = src->Sampler.LodBias; + dest->BaseLevel = src->BaseLevel; + dest->MaxLevel = src->MaxLevel; + dest->Sampler.MaxAnisotropy = src->Sampler.MaxAnisotropy; + dest->Sampler.CompareMode = src->Sampler.CompareMode; + dest->Sampler.CompareFunc = src->Sampler.CompareFunc; + dest->Sampler.CompareFailValue = src->Sampler.CompareFailValue; + dest->Sampler.CubeMapSeamless = src->Sampler.CubeMapSeamless; + dest->Sampler.DepthMode = src->Sampler.DepthMode; + dest->Sampler.sRGBDecode = src->Sampler.sRGBDecode; + dest->_MaxLevel = src->_MaxLevel; + dest->_MaxLambda = src->_MaxLambda; + dest->GenerateMipmap = src->GenerateMipmap; + dest->_Complete = src->_Complete; + COPY_4V(dest->Swizzle, src->Swizzle); + dest->_Swizzle = src->_Swizzle; +} + + +/** + * Free all texture images of the given texture object. + * + * \param ctx GL context. + * \param t texture object. + * + * \sa _mesa_clear_texture_image(). + */ +void +_mesa_clear_texture_object(struct gl_context *ctx, + struct gl_texture_object *texObj) +{ + GLuint i, j; + + if (texObj->Target == 0) + return; + + for (i = 0; i < MAX_FACES; i++) { + for (j = 0; j < MAX_TEXTURE_LEVELS; j++) { + struct gl_texture_image *texImage = texObj->Image[i][j]; + if (texImage) + _mesa_clear_texture_image(ctx, texImage); + } + } +} + + +/** + * Check if the given texture object is valid by examining its Target field. + * For debugging only. + */ +static GLboolean +valid_texture_object(const struct gl_texture_object *tex) +{ + switch (tex->Target) { + case 0: + case GL_TEXTURE_1D: + case GL_TEXTURE_2D: + case GL_TEXTURE_3D: + case GL_TEXTURE_CUBE_MAP_ARB: + case GL_TEXTURE_RECTANGLE_NV: + case GL_TEXTURE_1D_ARRAY_EXT: + case GL_TEXTURE_2D_ARRAY_EXT: + case GL_TEXTURE_BUFFER: + return GL_TRUE; + case 0x99: + _mesa_problem(NULL, "invalid reference to a deleted texture object"); + return GL_FALSE; + default: + _mesa_problem(NULL, "invalid texture object Target 0x%x, Id = %u", + tex->Target, tex->Name); + return GL_FALSE; + } +} + + +/** + * Reference (or unreference) a texture object. + * If '*ptr', decrement *ptr's refcount (and delete if it becomes zero). + * If 'tex' is non-null, increment its refcount. + * This is normally only called from the _mesa_reference_texobj() macro + * when there's a real pointer change. + */ +void +_mesa_reference_texobj_(struct gl_texture_object **ptr, + struct gl_texture_object *tex) +{ + assert(ptr); + + if (*ptr) { + /* Unreference the old texture */ + GLboolean deleteFlag = GL_FALSE; + struct gl_texture_object *oldTex = *ptr; + + ASSERT(valid_texture_object(oldTex)); + (void) valid_texture_object; /* silence warning in release builds */ + + _glthread_LOCK_MUTEX(oldTex->Mutex); + ASSERT(oldTex->RefCount > 0); + oldTex->RefCount--; + + deleteFlag = (oldTex->RefCount == 0); + _glthread_UNLOCK_MUTEX(oldTex->Mutex); + + if (deleteFlag) { + GET_CURRENT_CONTEXT(ctx); + if (ctx) + ctx->Driver.DeleteTexture(ctx, oldTex); + else + _mesa_problem(NULL, "Unable to delete texture, no context"); + } + + *ptr = NULL; + } + assert(!*ptr); + + if (tex) { + /* reference new texture */ + ASSERT(valid_texture_object(tex)); + _glthread_LOCK_MUTEX(tex->Mutex); + if (tex->RefCount == 0) { + /* this texture's being deleted (look just above) */ + /* Not sure this can every really happen. Warn if it does. */ + _mesa_problem(NULL, "referencing deleted texture object"); + *ptr = NULL; + } + else { + tex->RefCount++; + *ptr = tex; + } + _glthread_UNLOCK_MUTEX(tex->Mutex); + } +} + + + +/** + * Mark a texture object as incomplete. + * \param t texture object + * \param fmt... string describing why it's incomplete (for debugging). + */ +static void +incomplete(struct gl_texture_object *t, const char *fmt, ...) +{ +#if 0 + va_list args; + char s[100]; + + va_start(args, fmt); + vsnprintf(s, sizeof(s), fmt, args); + va_end(args); + + printf("Texture Obj %d incomplete because: %s\n", t->Name, s); +#endif + t->_Complete = GL_FALSE; +} + + +/** + * Examine a texture object to determine if it is complete. + * + * The gl_texture_object::Complete flag will be set to GL_TRUE or GL_FALSE + * accordingly. + * + * \param ctx GL context. + * \param t texture object. + * + * According to the texture target, verifies that each of the mipmaps is + * present and has the expected size. + */ +void +_mesa_test_texobj_completeness( const struct gl_context *ctx, + struct gl_texture_object *t ) +{ + const GLint baseLevel = t->BaseLevel; + GLint maxLog2 = 0, maxLevels = 0; + + t->_Complete = GL_TRUE; /* be optimistic */ + + /* Detect cases where the application set the base level to an invalid + * value. + */ + if ((baseLevel < 0) || (baseLevel >= MAX_TEXTURE_LEVELS)) { + incomplete(t, "base level = %d is invalid", baseLevel); + return; + } + + /* Always need the base level image */ + if (!t->Image[0][baseLevel]) { + incomplete(t, "Image[baseLevel=%d] == NULL", baseLevel); + return; + } + + /* Check width/height/depth for zero */ + if (t->Image[0][baseLevel]->Width == 0 || + t->Image[0][baseLevel]->Height == 0 || + t->Image[0][baseLevel]->Depth == 0) { + incomplete(t, "texture width = 0"); + return; + } + + /* Compute _MaxLevel */ + if ((t->Target == GL_TEXTURE_1D) || + (t->Target == GL_TEXTURE_1D_ARRAY_EXT)) { + maxLog2 = t->Image[0][baseLevel]->WidthLog2; + maxLevels = ctx->Const.MaxTextureLevels; + } + else if ((t->Target == GL_TEXTURE_2D) || + (t->Target == GL_TEXTURE_2D_ARRAY_EXT)) { + maxLog2 = MAX2(t->Image[0][baseLevel]->WidthLog2, + t->Image[0][baseLevel]->HeightLog2); + maxLevels = ctx->Const.MaxTextureLevels; + } + else if (t->Target == GL_TEXTURE_3D) { + GLint max = MAX2(t->Image[0][baseLevel]->WidthLog2, + t->Image[0][baseLevel]->HeightLog2); + maxLog2 = MAX2(max, (GLint)(t->Image[0][baseLevel]->DepthLog2)); + maxLevels = ctx->Const.Max3DTextureLevels; + } + else if (t->Target == GL_TEXTURE_CUBE_MAP_ARB) { + maxLog2 = MAX2(t->Image[0][baseLevel]->WidthLog2, + t->Image[0][baseLevel]->HeightLog2); + maxLevels = ctx->Const.MaxCubeTextureLevels; + } + else if (t->Target == GL_TEXTURE_RECTANGLE_NV) { + maxLog2 = 0; /* not applicable */ + maxLevels = 1; /* no mipmapping */ + } + else { + _mesa_problem(ctx, "Bad t->Target in _mesa_test_texobj_completeness"); + return; + } + + ASSERT(maxLevels > 0); + + if (t->MaxLevel < t->BaseLevel) { + incomplete(t, "MAX_LEVEL (%d) < BASE_LEVEL (%d)", + t->MaxLevel, t->BaseLevel); + return; + } + + t->_MaxLevel = baseLevel + maxLog2; + t->_MaxLevel = MIN2(t->_MaxLevel, t->MaxLevel); + t->_MaxLevel = MIN2(t->_MaxLevel, maxLevels - 1); + + /* Compute _MaxLambda = q - b (see the 1.2 spec) used during mipmapping */ + t->_MaxLambda = (GLfloat) (t->_MaxLevel - t->BaseLevel); + + if (t->Target == GL_TEXTURE_CUBE_MAP_ARB) { + /* make sure that all six cube map level 0 images are the same size */ + const GLuint w = t->Image[0][baseLevel]->Width2; + const GLuint h = t->Image[0][baseLevel]->Height2; + GLuint face; + for (face = 1; face < 6; face++) { + if (t->Image[face][baseLevel] == NULL || + t->Image[face][baseLevel]->Width2 != w || + t->Image[face][baseLevel]->Height2 != h) { + incomplete(t, "Cube face missing or mismatched size"); + return; + } + } + } + + /* extra checking for mipmaps */ + if (t->Sampler.MinFilter != GL_NEAREST && t->Sampler.MinFilter != GL_LINEAR) { + /* + * Mipmapping: determine if we have a complete set of mipmaps + */ + GLint i; + GLint minLevel = baseLevel; + GLint maxLevel = t->_MaxLevel; + + if (minLevel > maxLevel) { + incomplete(t, "minLevel > maxLevel"); + return; + } + + /* Test dimension-independent attributes */ + for (i = minLevel; i <= maxLevel; i++) { + if (t->Image[0][i]) { + if (t->Image[0][i]->TexFormat != t->Image[0][baseLevel]->TexFormat) { + incomplete(t, "Format[i] != Format[baseLevel]"); + return; + } + if (t->Image[0][i]->Border != t->Image[0][baseLevel]->Border) { + incomplete(t, "Border[i] != Border[baseLevel]"); + return; + } + } + } + + /* Test things which depend on number of texture image dimensions */ + if ((t->Target == GL_TEXTURE_1D) || + (t->Target == GL_TEXTURE_1D_ARRAY_EXT)) { + /* Test 1-D mipmaps */ + GLuint width = t->Image[0][baseLevel]->Width2; + for (i = baseLevel + 1; i < maxLevels; i++) { + if (width > 1) { + width /= 2; + } + if (i >= minLevel && i <= maxLevel) { + if (!t->Image[0][i]) { + incomplete(t, "1D Image[0][i] == NULL"); + return; + } + if (t->Image[0][i]->Width2 != width ) { + incomplete(t, "1D Image[0][i] bad width"); + return; + } + } + if (width == 1) { + return; /* found smallest needed mipmap, all done! */ + } + } + } + else if ((t->Target == GL_TEXTURE_2D) || + (t->Target == GL_TEXTURE_2D_ARRAY_EXT)) { + /* Test 2-D mipmaps */ + GLuint width = t->Image[0][baseLevel]->Width2; + GLuint height = t->Image[0][baseLevel]->Height2; + for (i = baseLevel + 1; i < maxLevels; i++) { + if (width > 1) { + width /= 2; + } + if (height > 1) { + height /= 2; + } + if (i >= minLevel && i <= maxLevel) { + if (!t->Image[0][i]) { + incomplete(t, "2D Image[0][i] == NULL"); + return; + } + if (t->Image[0][i]->Width2 != width) { + incomplete(t, "2D Image[0][i] bad width"); + return; + } + if (t->Image[0][i]->Height2 != height) { + incomplete(t, "2D Image[0][i] bad height"); + return; + } + if (width==1 && height==1) { + return; /* found smallest needed mipmap, all done! */ + } + } + } + } + else if (t->Target == GL_TEXTURE_3D) { + /* Test 3-D mipmaps */ + GLuint width = t->Image[0][baseLevel]->Width2; + GLuint height = t->Image[0][baseLevel]->Height2; + GLuint depth = t->Image[0][baseLevel]->Depth2; + for (i = baseLevel + 1; i < maxLevels; i++) { + if (width > 1) { + width /= 2; + } + if (height > 1) { + height /= 2; + } + if (depth > 1) { + depth /= 2; + } + if (i >= minLevel && i <= maxLevel) { + if (!t->Image[0][i]) { + incomplete(t, "3D Image[0][i] == NULL"); + return; + } + if (t->Image[0][i]->_BaseFormat == GL_DEPTH_COMPONENT) { + incomplete(t, "GL_DEPTH_COMPONENT only works with 1/2D tex"); + return; + } + if (t->Image[0][i]->Width2 != width) { + incomplete(t, "3D Image[0][i] bad width"); + return; + } + if (t->Image[0][i]->Height2 != height) { + incomplete(t, "3D Image[0][i] bad height"); + return; + } + if (t->Image[0][i]->Depth2 != depth) { + incomplete(t, "3D Image[0][i] bad depth"); + return; + } + } + if (width == 1 && height == 1 && depth == 1) { + return; /* found smallest needed mipmap, all done! */ + } + } + } + else if (t->Target == GL_TEXTURE_CUBE_MAP_ARB) { + /* make sure 6 cube faces are consistant */ + GLuint width = t->Image[0][baseLevel]->Width2; + GLuint height = t->Image[0][baseLevel]->Height2; + for (i = baseLevel + 1; i < maxLevels; i++) { + if (width > 1) { + width /= 2; + } + if (height > 1) { + height /= 2; + } + if (i >= minLevel && i <= maxLevel) { + GLuint face; + for (face = 0; face < 6; face++) { + /* check that we have images defined */ + if (!t->Image[face][i]) { + incomplete(t, "CubeMap Image[n][i] == NULL"); + return; + } + /* Don't support GL_DEPTH_COMPONENT for cube maps */ + if (t->Image[face][i]->_BaseFormat == GL_DEPTH_COMPONENT) { + incomplete(t, "GL_DEPTH_COMPONENT only works with 1/2D tex"); + return; + } + /* check that all six images have same size */ + if (t->Image[face][i]->Width2 != width || + t->Image[face][i]->Height2 != height) { + incomplete(t, "CubeMap Image[n][i] bad size"); + return; + } + } + } + if (width == 1 && height == 1) { + return; /* found smallest needed mipmap, all done! */ + } + } + } + else if (t->Target == GL_TEXTURE_RECTANGLE_NV) { + /* XXX special checking? */ + } + else { + /* Target = ??? */ + _mesa_problem(ctx, "Bug in gl_test_texture_object_completeness\n"); + } + } +} + + +/** + * Check if the given cube map texture is "cube complete" as defined in + * the OpenGL specification. + */ +GLboolean +_mesa_cube_complete(const struct gl_texture_object *texObj) +{ + const GLint baseLevel = texObj->BaseLevel; + const struct gl_texture_image *img0, *img; + GLuint face; + + if (texObj->Target != GL_TEXTURE_CUBE_MAP) + return GL_FALSE; + + if ((baseLevel < 0) || (baseLevel >= MAX_TEXTURE_LEVELS)) + return GL_FALSE; + + /* check first face */ + img0 = texObj->Image[0][baseLevel]; + if (!img0 || + img0->Width < 1 || + img0->Width != img0->Height) + return GL_FALSE; + + /* check remaining faces vs. first face */ + for (face = 1; face < 6; face++) { + img = texObj->Image[face][baseLevel]; + if (!img || + img->Width != img0->Width || + img->Height != img0->Height || + img->TexFormat != img0->TexFormat) + return GL_FALSE; + } + + return GL_TRUE; +} + + +/** + * Mark a texture object dirty. It forces the object to be incomplete + * and optionally forces the context to re-validate its state. + * + * \param ctx GL context. + * \param texObj texture object. + * \param invalidate_state also invalidate context state. + */ +void +_mesa_dirty_texobj(struct gl_context *ctx, struct gl_texture_object *texObj, + GLboolean invalidate_state) +{ + texObj->_Complete = GL_FALSE; + if (invalidate_state) + ctx->NewState |= _NEW_TEXTURE; +} + + +/** + * Return pointer to a default/fallback texture. + * The texture is a 2D 8x8 RGBA texture with all texels = (0,0,0,1). + * That's the value a sampler should get when sampling from an + * incomplete texture. + */ +struct gl_texture_object * +_mesa_get_fallback_texture(struct gl_context *ctx) +{ + if (!ctx->Shared->FallbackTex) { + /* create fallback texture now */ + static GLubyte texels[8 * 8][4]; + struct gl_texture_object *texObj; + struct gl_texture_image *texImage; + gl_format texFormat; + GLuint i; + + for (i = 0; i < 8 * 8; i++) { + texels[i][0] = + texels[i][1] = + texels[i][2] = 0x0; + texels[i][3] = 0xff; + } + + /* create texture object */ + texObj = ctx->Driver.NewTextureObject(ctx, 0, GL_TEXTURE_2D); + assert(texObj->RefCount == 1); + texObj->Sampler.MinFilter = GL_NEAREST; + texObj->Sampler.MagFilter = GL_NEAREST; + + /* create level[0] texture image */ + texImage = _mesa_get_tex_image(ctx, texObj, GL_TEXTURE_2D, 0); + + texFormat = ctx->Driver.ChooseTextureFormat(ctx, GL_RGBA, GL_RGBA, + GL_UNSIGNED_BYTE); + + /* init the image fields */ + _mesa_init_teximage_fields(ctx, GL_TEXTURE_2D, texImage, + 8, 8, 1, 0, GL_RGBA, texFormat); + + ASSERT(texImage->TexFormat != MESA_FORMAT_NONE); + + /* set image data */ + ctx->Driver.TexImage2D(ctx, GL_TEXTURE_2D, 0, GL_RGBA, + 8, 8, 0, + GL_RGBA, GL_UNSIGNED_BYTE, texels, + &ctx->DefaultPacking, texObj, texImage); + + _mesa_test_texobj_completeness(ctx, texObj); + assert(texObj->_Complete); + + ctx->Shared->FallbackTex = texObj; + } + return ctx->Shared->FallbackTex; +} + + +/*@}*/ + + +/***********************************************************************/ +/** \name API functions */ +/*@{*/ + + +/** + * Generate texture names. + * + * \param n number of texture names to be generated. + * \param textures an array in which will hold the generated texture names. + * + * \sa glGenTextures(). + * + * Calls _mesa_HashFindFreeKeyBlock() to find a block of free texture + * IDs which are stored in \p textures. Corresponding empty texture + * objects are also generated. + */ +void GLAPIENTRY +_mesa_GenTextures( GLsizei n, GLuint *textures ) +{ + GET_CURRENT_CONTEXT(ctx); + GLuint first; + GLint i; + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (n < 0) { + _mesa_error( ctx, GL_INVALID_VALUE, "glGenTextures" ); + return; + } + + if (!textures) + return; + + /* + * This must be atomic (generation and allocation of texture IDs) + */ + _glthread_LOCK_MUTEX(ctx->Shared->Mutex); + + first = _mesa_HashFindFreeKeyBlock(ctx->Shared->TexObjects, n); + + /* Allocate new, empty texture objects */ + for (i = 0; i < n; i++) { + struct gl_texture_object *texObj; + GLuint name = first + i; + GLenum target = 0; + texObj = ctx->Driver.NewTextureObject(ctx, name, target); + if (!texObj) { + _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGenTextures"); + return; + } + + /* insert into hash table */ + _mesa_HashInsert(ctx->Shared->TexObjects, texObj->Name, texObj); + + textures[i] = name; + } + + _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); +} + + +/** + * Check if the given texture object is bound to the current draw or + * read framebuffer. If so, Unbind it. + */ +static void +unbind_texobj_from_fbo(struct gl_context *ctx, + struct gl_texture_object *texObj) +{ + const GLuint n = (ctx->DrawBuffer == ctx->ReadBuffer) ? 1 : 2; + GLuint i; + + for (i = 0; i < n; i++) { + struct gl_framebuffer *fb = (i == 0) ? ctx->DrawBuffer : ctx->ReadBuffer; + if (fb->Name) { + GLuint j; + for (j = 0; j < BUFFER_COUNT; j++) { + if (fb->Attachment[j].Type == GL_TEXTURE && + fb->Attachment[j].Texture == texObj) { + /* Vertices are already flushed by _mesa_DeleteTextures */ + ctx->NewState |= _NEW_BUFFERS; + _mesa_remove_attachment(ctx, fb->Attachment + j); + } + } + } + } +} + + +/** + * Check if the given texture object is bound to any texture image units and + * unbind it if so (revert to default textures). + */ +static void +unbind_texobj_from_texunits(struct gl_context *ctx, + struct gl_texture_object *texObj) +{ + GLuint u, tex; + + for (u = 0; u < Elements(ctx->Texture.Unit); u++) { + struct gl_texture_unit *unit = &ctx->Texture.Unit[u]; + for (tex = 0; tex < NUM_TEXTURE_TARGETS; tex++) { + if (texObj == unit->CurrentTex[tex]) { + _mesa_reference_texobj(&unit->CurrentTex[tex], + ctx->Shared->DefaultTex[tex]); + ASSERT(unit->CurrentTex[tex]); + break; + } + } + } +} + + +/** + * Delete named textures. + * + * \param n number of textures to be deleted. + * \param textures array of texture IDs to be deleted. + * + * \sa glDeleteTextures(). + * + * If we're about to delete a texture that's currently bound to any + * texture unit, unbind the texture first. Decrement the reference + * count on the texture object and delete it if it's zero. + * Recall that texture objects can be shared among several rendering + * contexts. + */ +void GLAPIENTRY +_mesa_DeleteTextures( GLsizei n, const GLuint *textures) +{ + GET_CURRENT_CONTEXT(ctx); + GLint i; + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); /* too complex */ + + if (!textures) + return; + + for (i = 0; i < n; i++) { + if (textures[i] > 0) { + struct gl_texture_object *delObj + = _mesa_lookup_texture(ctx, textures[i]); + + if (delObj) { + _mesa_lock_texture(ctx, delObj); + + /* Check if texture is bound to any framebuffer objects. + * If so, unbind. + * See section 4.4.2.3 of GL_EXT_framebuffer_object. + */ + unbind_texobj_from_fbo(ctx, delObj); + + /* Check if this texture is currently bound to any texture units. + * If so, unbind it. + */ + unbind_texobj_from_texunits(ctx, delObj); + + _mesa_unlock_texture(ctx, delObj); + + ctx->NewState |= _NEW_TEXTURE; + + /* The texture _name_ is now free for re-use. + * Remove it from the hash table now. + */ + _glthread_LOCK_MUTEX(ctx->Shared->Mutex); + _mesa_HashRemove(ctx->Shared->TexObjects, delObj->Name); + _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); + + /* Unreference the texobj. If refcount hits zero, the texture + * will be deleted. + */ + _mesa_reference_texobj(&delObj, NULL); + } + } + } +} + + +/** + * Convert a GL texture target enum such as GL_TEXTURE_2D or GL_TEXTURE_3D + * into the corresponding Mesa texture target index. + * Note that proxy targets are not valid here. + * \return TEXTURE_x_INDEX or -1 if target is invalid + */ +static GLint +target_enum_to_index(GLenum target) +{ + switch (target) { + case GL_TEXTURE_1D: + return TEXTURE_1D_INDEX; + case GL_TEXTURE_2D: + return TEXTURE_2D_INDEX; + case GL_TEXTURE_3D: + return TEXTURE_3D_INDEX; + case GL_TEXTURE_CUBE_MAP_ARB: + return TEXTURE_CUBE_INDEX; + case GL_TEXTURE_RECTANGLE_NV: + return TEXTURE_RECT_INDEX; + case GL_TEXTURE_1D_ARRAY_EXT: + return TEXTURE_1D_ARRAY_INDEX; + case GL_TEXTURE_2D_ARRAY_EXT: + return TEXTURE_2D_ARRAY_INDEX; + case GL_TEXTURE_BUFFER_ARB: + return TEXTURE_BUFFER_INDEX; + default: + return -1; + } +} + + +/** + * Bind a named texture to a texturing target. + * + * \param target texture target. + * \param texName texture name. + * + * \sa glBindTexture(). + * + * Determines the old texture object bound and returns immediately if rebinding + * the same texture. Get the current texture which is either a default texture + * if name is null, a named texture from the hash, or a new texture if the + * given texture name is new. Increments its reference count, binds it, and + * calls dd_function_table::BindTexture. Decrements the old texture reference + * count and deletes it if it reaches zero. + */ +void GLAPIENTRY +_mesa_BindTexture( GLenum target, GLuint texName ) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx); + struct gl_texture_object *newTexObj = NULL; + GLint targetIndex; + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE)) + _mesa_debug(ctx, "glBindTexture %s %d\n", + _mesa_lookup_enum_by_nr(target), (GLint) texName); + + targetIndex = target_enum_to_index(target); + if (targetIndex < 0) { + _mesa_error(ctx, GL_INVALID_ENUM, "glBindTexture(target)"); + return; + } + assert(targetIndex < NUM_TEXTURE_TARGETS); + + /* + * Get pointer to new texture object (newTexObj) + */ + if (texName == 0) { + /* Use a default texture object */ + newTexObj = ctx->Shared->DefaultTex[targetIndex]; + } + else { + /* non-default texture object */ + newTexObj = _mesa_lookup_texture(ctx, texName); + if (newTexObj) { + /* error checking */ + if (newTexObj->Target != 0 && newTexObj->Target != target) { + /* the named texture object's target doesn't match the given target */ + _mesa_error( ctx, GL_INVALID_OPERATION, + "glBindTexture(target mismatch)" ); + return; + } + if (newTexObj->Target == 0) { + finish_texture_init(ctx, target, newTexObj); + } + } + else { + /* if this is a new texture id, allocate a texture object now */ + newTexObj = ctx->Driver.NewTextureObject(ctx, texName, target); + if (!newTexObj) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindTexture"); + return; + } + + /* and insert it into hash table */ + _glthread_LOCK_MUTEX(ctx->Shared->Mutex); + _mesa_HashInsert(ctx->Shared->TexObjects, texName, newTexObj); + _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); + } + newTexObj->Target = target; + } + + assert(valid_texture_object(newTexObj)); + + /* Check if this texture is only used by this context and is already bound. + * If so, just return. + */ + { + GLboolean early_out; + _glthread_LOCK_MUTEX(ctx->Shared->Mutex); + early_out = ((ctx->Shared->RefCount == 1) + && (newTexObj == texUnit->CurrentTex[targetIndex])); + _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); + if (early_out) { + return; + } + } + + /* flush before changing binding */ + FLUSH_VERTICES(ctx, _NEW_TEXTURE); + + /* Do the actual binding. The refcount on the previously bound + * texture object will be decremented. It'll be deleted if the + * count hits zero. + */ + _mesa_reference_texobj(&texUnit->CurrentTex[targetIndex], newTexObj); + ASSERT(texUnit->CurrentTex[targetIndex]); + + /* Pass BindTexture call to device driver */ + if (ctx->Driver.BindTexture) + ctx->Driver.BindTexture(ctx, target, newTexObj); +} + + +/** + * Set texture priorities. + * + * \param n number of textures. + * \param texName texture names. + * \param priorities corresponding texture priorities. + * + * \sa glPrioritizeTextures(). + * + * Looks up each texture in the hash, clamps the corresponding priority between + * 0.0 and 1.0, and calls dd_function_table::PrioritizeTexture. + */ +void GLAPIENTRY +_mesa_PrioritizeTextures( GLsizei n, const GLuint *texName, + const GLclampf *priorities ) +{ + GET_CURRENT_CONTEXT(ctx); + GLint i; + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + if (n < 0) { + _mesa_error( ctx, GL_INVALID_VALUE, "glPrioritizeTextures" ); + return; + } + + if (!priorities) + return; + + for (i = 0; i < n; i++) { + if (texName[i] > 0) { + struct gl_texture_object *t = _mesa_lookup_texture(ctx, texName[i]); + if (t) { + t->Priority = CLAMP( priorities[i], 0.0F, 1.0F ); + } + } + } + + ctx->NewState |= _NEW_TEXTURE; +} + + + +/** + * See if textures are loaded in texture memory. + * + * \param n number of textures to query. + * \param texName array with the texture names. + * \param residences array which will hold the residence status. + * + * \return GL_TRUE if all textures are resident and \p residences is left unchanged, + * + * \sa glAreTexturesResident(). + * + * Looks up each texture in the hash and calls + * dd_function_table::IsTextureResident. + */ +GLboolean GLAPIENTRY +_mesa_AreTexturesResident(GLsizei n, const GLuint *texName, + GLboolean *residences) +{ + GET_CURRENT_CONTEXT(ctx); + GLboolean allResident = GL_TRUE; + GLint i, j; + ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); + + if (n < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glAreTexturesResident(n)"); + return GL_FALSE; + } + + if (!texName || !residences) + return GL_FALSE; + + for (i = 0; i < n; i++) { + struct gl_texture_object *t; + if (texName[i] == 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glAreTexturesResident"); + return GL_FALSE; + } + t = _mesa_lookup_texture(ctx, texName[i]); + if (!t) { + _mesa_error(ctx, GL_INVALID_VALUE, "glAreTexturesResident"); + return GL_FALSE; + } + if (!ctx->Driver.IsTextureResident || + ctx->Driver.IsTextureResident(ctx, t)) { + /* The texture is resident */ + if (!allResident) + residences[i] = GL_TRUE; + } + else { + /* The texture is not resident */ + if (allResident) { + allResident = GL_FALSE; + for (j = 0; j < i; j++) + residences[j] = GL_TRUE; + } + residences[i] = GL_FALSE; + } + } + + return allResident; +} + + +/** + * See if a name corresponds to a texture. + * + * \param texture texture name. + * + * \return GL_TRUE if texture name corresponds to a texture, or GL_FALSE + * otherwise. + * + * \sa glIsTexture(). + * + * Calls _mesa_HashLookup(). + */ +GLboolean GLAPIENTRY +_mesa_IsTexture( GLuint texture ) +{ + struct gl_texture_object *t; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); + + if (!texture) + return GL_FALSE; + + t = _mesa_lookup_texture(ctx, texture); + + /* IsTexture is true only after object has been bound once. */ + return t && t->Target; +} + + +/** + * Simplest implementation of texture locking: grab the shared tex + * mutex. Examine the shared context state timestamp and if there has + * been a change, set the appropriate bits in ctx->NewState. + * + * This is used to deal with synchronizing things when a texture object + * is used/modified by different contexts (or threads) which are sharing + * the texture. + * + * See also _mesa_lock/unlock_texture() in teximage.h + */ +void +_mesa_lock_context_textures( struct gl_context *ctx ) +{ + _glthread_LOCK_MUTEX(ctx->Shared->TexMutex); + + if (ctx->Shared->TextureStateStamp != ctx->TextureStateTimestamp) { + ctx->NewState |= _NEW_TEXTURE; + ctx->TextureStateTimestamp = ctx->Shared->TextureStateStamp; + } +} + + +void +_mesa_unlock_context_textures( struct gl_context *ctx ) +{ + assert(ctx->Shared->TextureStateStamp == ctx->TextureStateTimestamp); + _glthread_UNLOCK_MUTEX(ctx->Shared->TexMutex); +} + +/*@}*/ diff --git a/mesalib/src/mesa/main/texparam.c b/mesalib/src/mesa/main/texparam.c index bdd1f3fd8..19a01a14d 100644 --- a/mesalib/src/mesa/main/texparam.c +++ b/mesalib/src/mesa/main/texparam.c @@ -1,1416 +1,1416 @@ -/* - * Mesa 3-D graphics library - * Version: 7.5 - * - * Copyright (C) 1999-2008 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. - */ - -/** - * \file texparam.c - * - * glTexParameter-related functions - */ - - -#include "main/glheader.h" -#include "main/colormac.h" -#include "main/context.h" -#include "main/enums.h" -#include "main/formats.h" -#include "main/macros.h" -#include "main/mfeatures.h" -#include "main/mtypes.h" -#include "main/state.h" -#include "main/texcompress.h" -#include "main/texparam.h" -#include "main/teximage.h" -#include "main/texstate.h" -#include "main/texfetch.h" -#include "program/prog_instruction.h" - - -/** - * Check if a coordinate wrap mode is supported for the texture target. - * \return GL_TRUE if legal, GL_FALSE otherwise - */ -static GLboolean -validate_texture_wrap_mode(struct gl_context * ctx, GLenum target, GLenum wrap) -{ - const struct gl_extensions * const e = & ctx->Extensions; - - if (wrap == GL_CLAMP || wrap == GL_CLAMP_TO_EDGE || - (wrap == GL_CLAMP_TO_BORDER && e->ARB_texture_border_clamp)) { - /* any texture target */ - return GL_TRUE; - } - else if (target != GL_TEXTURE_RECTANGLE_NV && - (wrap == GL_REPEAT || - (wrap == GL_MIRRORED_REPEAT && - e->ARB_texture_mirrored_repeat) || - (wrap == GL_MIRROR_CLAMP_EXT && - (e->ATI_texture_mirror_once || e->EXT_texture_mirror_clamp)) || - (wrap == GL_MIRROR_CLAMP_TO_EDGE_EXT && - (e->ATI_texture_mirror_once || e->EXT_texture_mirror_clamp)) || - (wrap == GL_MIRROR_CLAMP_TO_BORDER_EXT && - (e->EXT_texture_mirror_clamp)))) { - /* non-rectangle texture */ - return GL_TRUE; - } - - _mesa_error( ctx, GL_INVALID_ENUM, "glTexParameter(param=0x%x)", wrap ); - return GL_FALSE; -} - - -/** - * Get current texture object for given target. - * Return NULL if any error (and record the error). - * Note that this is different from _mesa_select_tex_object() in that proxy - * targets are not accepted. - * Only the glGetTexLevelParameter() functions accept proxy targets. - */ -static struct gl_texture_object * -get_texobj(struct gl_context *ctx, GLenum target, GLboolean get) -{ - struct gl_texture_unit *texUnit; - - if (ctx->Texture.CurrentUnit >= ctx->Const.MaxCombinedTextureImageUnits) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "gl%sTexParameter(current unit)", get ? "Get" : ""); - return NULL; - } - - texUnit = _mesa_get_current_tex_unit(ctx); - - switch (target) { - case GL_TEXTURE_1D: - return texUnit->CurrentTex[TEXTURE_1D_INDEX]; - case GL_TEXTURE_2D: - return texUnit->CurrentTex[TEXTURE_2D_INDEX]; - case GL_TEXTURE_3D: - return texUnit->CurrentTex[TEXTURE_3D_INDEX]; - case GL_TEXTURE_CUBE_MAP: - if (ctx->Extensions.ARB_texture_cube_map) { - return texUnit->CurrentTex[TEXTURE_CUBE_INDEX]; - } - break; - case GL_TEXTURE_RECTANGLE_NV: - if (ctx->Extensions.NV_texture_rectangle) { - return texUnit->CurrentTex[TEXTURE_RECT_INDEX]; - } - break; - case GL_TEXTURE_1D_ARRAY_EXT: - if (ctx->Extensions.MESA_texture_array || - ctx->Extensions.EXT_texture_array) { - return texUnit->CurrentTex[TEXTURE_1D_ARRAY_INDEX]; - } - break; - case GL_TEXTURE_2D_ARRAY_EXT: - if (ctx->Extensions.MESA_texture_array || - ctx->Extensions.EXT_texture_array) { - return texUnit->CurrentTex[TEXTURE_2D_ARRAY_INDEX]; - } - break; - default: - ; - } - - _mesa_error(ctx, GL_INVALID_ENUM, - "gl%sTexParameter(target)", get ? "Get" : ""); - return NULL; -} - - -/** - * Convert GL_RED/GREEN/BLUE/ALPHA/ZERO/ONE to SWIZZLE_X/Y/Z/W/ZERO/ONE. - * \return -1 if error. - */ -static GLint -comp_to_swizzle(GLenum comp) -{ - switch (comp) { - case GL_RED: - return SWIZZLE_X; - case GL_GREEN: - return SWIZZLE_Y; - case GL_BLUE: - return SWIZZLE_Z; - case GL_ALPHA: - return SWIZZLE_W; - case GL_ZERO: - return SWIZZLE_ZERO; - case GL_ONE: - return SWIZZLE_ONE; - default: - return -1; - } -} - - -static void -set_swizzle_component(GLuint *swizzle, GLuint comp, GLuint swz) -{ - ASSERT(comp < 4); - ASSERT(swz <= SWIZZLE_NIL); - { - GLuint mask = 0x7 << (3 * comp); - GLuint s = (*swizzle & ~mask) | (swz << (3 * comp)); - *swizzle = s; - } -} - - -/** - * This is called just prior to changing any texture object state which - * will not effect texture completeness. - */ -static INLINE void -flush(struct gl_context *ctx) -{ - FLUSH_VERTICES(ctx, _NEW_TEXTURE); -} - - -/** - * This is called just prior to changing any texture object state which - * can effect texture completeness (texture base level, max level, - * minification filter). - * Any pending rendering will be flushed out, we'll set the _NEW_TEXTURE - * state flag and then mark the texture object as 'incomplete' so that any - * per-texture derived state gets recomputed. - */ -static INLINE void -incomplete(struct gl_context *ctx, struct gl_texture_object *texObj) -{ - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - texObj->_Complete = GL_FALSE; -} - - -/** - * Set an integer-valued texture parameter - * \return GL_TRUE if legal AND the value changed, GL_FALSE otherwise - */ -static GLboolean -set_tex_parameteri(struct gl_context *ctx, - struct gl_texture_object *texObj, - GLenum pname, const GLint *params) -{ - switch (pname) { - case GL_TEXTURE_MIN_FILTER: - if (texObj->Sampler.MinFilter == params[0]) - return GL_FALSE; - switch (params[0]) { - case GL_NEAREST: - case GL_LINEAR: - incomplete(ctx, texObj); - texObj->Sampler.MinFilter = params[0]; - return GL_TRUE; - case GL_NEAREST_MIPMAP_NEAREST: - case GL_LINEAR_MIPMAP_NEAREST: - case GL_NEAREST_MIPMAP_LINEAR: - case GL_LINEAR_MIPMAP_LINEAR: - if (texObj->Target != GL_TEXTURE_RECTANGLE_NV) { - incomplete(ctx, texObj); - texObj->Sampler.MinFilter = params[0]; - return GL_TRUE; - } - /* fall-through */ - default: - goto invalid_param; - } - return GL_FALSE; - - case GL_TEXTURE_MAG_FILTER: - if (texObj->Sampler.MagFilter == params[0]) - return GL_FALSE; - switch (params[0]) { - case GL_NEAREST: - case GL_LINEAR: - flush(ctx); /* does not effect completeness */ - texObj->Sampler.MagFilter = params[0]; - return GL_TRUE; - default: - goto invalid_param; - } - return GL_FALSE; - - case GL_TEXTURE_WRAP_S: - if (texObj->Sampler.WrapS == params[0]) - return GL_FALSE; - if (validate_texture_wrap_mode(ctx, texObj->Target, params[0])) { - flush(ctx); - texObj->Sampler.WrapS = params[0]; - return GL_TRUE; - } - return GL_FALSE; - - case GL_TEXTURE_WRAP_T: - if (texObj->Sampler.WrapT == params[0]) - return GL_FALSE; - if (validate_texture_wrap_mode(ctx, texObj->Target, params[0])) { - flush(ctx); - texObj->Sampler.WrapT = params[0]; - return GL_TRUE; - } - return GL_FALSE; - - case GL_TEXTURE_WRAP_R: - if (texObj->Sampler.WrapR == params[0]) - return GL_FALSE; - if (validate_texture_wrap_mode(ctx, texObj->Target, params[0])) { - flush(ctx); - texObj->Sampler.WrapR = params[0]; - return GL_TRUE; - } - return GL_FALSE; - - case GL_TEXTURE_BASE_LEVEL: - if (texObj->BaseLevel == params[0]) - return GL_FALSE; - if (params[0] < 0 || - (texObj->Target == GL_TEXTURE_RECTANGLE_ARB && params[0] != 0)) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glTexParameter(param=%d)", params[0]); - return GL_FALSE; - } - incomplete(ctx, texObj); - texObj->BaseLevel = params[0]; - return GL_TRUE; - - case GL_TEXTURE_MAX_LEVEL: - if (texObj->MaxLevel == params[0]) - return GL_FALSE; - if (params[0] < 0 || texObj->Target == GL_TEXTURE_RECTANGLE_ARB) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glTexParameter(param=%d)", params[0]); - return GL_FALSE; - } - incomplete(ctx, texObj); - texObj->MaxLevel = params[0]; - return GL_TRUE; - - case GL_GENERATE_MIPMAP_SGIS: - if (texObj->GenerateMipmap != params[0]) { - /* no flush() */ - texObj->GenerateMipmap = params[0] ? GL_TRUE : GL_FALSE; - return GL_TRUE; - } - return GL_FALSE; - - case GL_TEXTURE_COMPARE_MODE_ARB: - if (ctx->Extensions.ARB_shadow) { - if (texObj->Sampler.CompareMode == params[0]) - return GL_FALSE; - if (params[0] == GL_NONE || - params[0] == GL_COMPARE_R_TO_TEXTURE_ARB) { - flush(ctx); - texObj->Sampler.CompareMode = params[0]; - return GL_TRUE; - } - goto invalid_param; - } - goto invalid_pname; - - case GL_TEXTURE_COMPARE_FUNC_ARB: - if (ctx->Extensions.ARB_shadow) { - if (texObj->Sampler.CompareFunc == params[0]) - return GL_FALSE; - switch (params[0]) { - case GL_LEQUAL: - case GL_GEQUAL: - flush(ctx); - texObj->Sampler.CompareFunc = params[0]; - return GL_TRUE; - case GL_EQUAL: - case GL_NOTEQUAL: - case GL_LESS: - case GL_GREATER: - case GL_ALWAYS: - case GL_NEVER: - if (ctx->Extensions.EXT_shadow_funcs) { - flush(ctx); - texObj->Sampler.CompareFunc = params[0]; - return GL_TRUE; - } - /* fall-through */ - default: - goto invalid_param; - } - } - goto invalid_pname; - - case GL_DEPTH_TEXTURE_MODE_ARB: - if (ctx->Extensions.ARB_depth_texture) { - if (texObj->Sampler.DepthMode == params[0]) - return GL_FALSE; - if (params[0] == GL_LUMINANCE || - params[0] == GL_INTENSITY || - params[0] == GL_ALPHA || - (ctx->Extensions.ARB_texture_rg && params[0] == GL_RED)) { - flush(ctx); - texObj->Sampler.DepthMode = params[0]; - return GL_TRUE; - } - goto invalid_param; - } - goto invalid_pname; - -#if FEATURE_OES_draw_texture - case GL_TEXTURE_CROP_RECT_OES: - texObj->CropRect[0] = params[0]; - texObj->CropRect[1] = params[1]; - texObj->CropRect[2] = params[2]; - texObj->CropRect[3] = params[3]; - return GL_TRUE; -#endif - - case GL_TEXTURE_SWIZZLE_R_EXT: - case GL_TEXTURE_SWIZZLE_G_EXT: - case GL_TEXTURE_SWIZZLE_B_EXT: - case GL_TEXTURE_SWIZZLE_A_EXT: - if (ctx->Extensions.EXT_texture_swizzle) { - const GLuint comp = pname - GL_TEXTURE_SWIZZLE_R_EXT; - const GLint swz = comp_to_swizzle(params[0]); - if (swz < 0) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glTexParameter(swizzle 0x%x)", params[0]); - return GL_FALSE; - } - ASSERT(comp < 4); - if (swz >= 0) { - flush(ctx); - texObj->Swizzle[comp] = params[0]; - set_swizzle_component(&texObj->_Swizzle, comp, swz); - return GL_TRUE; - } - } - goto invalid_pname; - - case GL_TEXTURE_SWIZZLE_RGBA_EXT: - if (ctx->Extensions.EXT_texture_swizzle) { - GLuint comp; - flush(ctx); - for (comp = 0; comp < 4; comp++) { - const GLint swz = comp_to_swizzle(params[comp]); - if (swz >= 0) { - texObj->Swizzle[comp] = params[comp]; - set_swizzle_component(&texObj->_Swizzle, comp, swz); - } - else { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glTexParameter(swizzle 0x%x)", params[comp]); - return GL_FALSE; - } - } - return GL_TRUE; - } - goto invalid_pname; - - case GL_TEXTURE_SRGB_DECODE_EXT: - if (ctx->Extensions.EXT_texture_sRGB_decode) { - GLenum decode = params[0]; - if (decode == GL_DECODE_EXT || decode == GL_SKIP_DECODE_EXT) { - if (texObj->Sampler.sRGBDecode != decode) { - flush(ctx); - texObj->Sampler.sRGBDecode = decode; - _mesa_update_fetch_functions(texObj); - } - return GL_TRUE; - } - } - goto invalid_pname; - - case GL_TEXTURE_CUBE_MAP_SEAMLESS: - if (ctx->Extensions.AMD_seamless_cubemap_per_texture) { - GLenum param = params[0]; - if (param != GL_TRUE && param != GL_FALSE) { - goto invalid_param; - } - if (param != texObj->Sampler.CubeMapSeamless) { - flush(ctx); - texObj->Sampler.CubeMapSeamless = param; - } - return GL_TRUE; - } - goto invalid_pname; - - default: - goto invalid_pname; - } - -invalid_pname: - _mesa_error(ctx, GL_INVALID_ENUM, "glTexParameter(pname=%s)", - _mesa_lookup_enum_by_nr(pname)); - return GL_FALSE; - -invalid_param: - _mesa_error(ctx, GL_INVALID_ENUM, "glTexParameter(param=%s)", - _mesa_lookup_enum_by_nr(params[0])); - return GL_FALSE; -} - - -/** - * Set a float-valued texture parameter - * \return GL_TRUE if legal AND the value changed, GL_FALSE otherwise - */ -static GLboolean -set_tex_parameterf(struct gl_context *ctx, - struct gl_texture_object *texObj, - GLenum pname, const GLfloat *params) -{ - switch (pname) { - case GL_TEXTURE_MIN_LOD: - if (texObj->Sampler.MinLod == params[0]) - return GL_FALSE; - flush(ctx); - texObj->Sampler.MinLod = params[0]; - return GL_TRUE; - - case GL_TEXTURE_MAX_LOD: - if (texObj->Sampler.MaxLod == params[0]) - return GL_FALSE; - flush(ctx); - texObj->Sampler.MaxLod = params[0]; - return GL_TRUE; - - case GL_TEXTURE_PRIORITY: - flush(ctx); - texObj->Priority = CLAMP(params[0], 0.0F, 1.0F); - return GL_TRUE; - - case GL_TEXTURE_MAX_ANISOTROPY_EXT: - if (ctx->Extensions.EXT_texture_filter_anisotropic) { - if (texObj->Sampler.MaxAnisotropy == params[0]) - return GL_FALSE; - if (params[0] < 1.0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glTexParameter(param)" ); - return GL_FALSE; - } - flush(ctx); - /* clamp to max, that's what NVIDIA does */ - texObj->Sampler.MaxAnisotropy = MIN2(params[0], - ctx->Const.MaxTextureMaxAnisotropy); - return GL_TRUE; - } - else { - static GLuint count = 0; - if (count++ < 10) - _mesa_error(ctx, GL_INVALID_ENUM, - "glTexParameter(pname=GL_TEXTURE_MAX_ANISOTROPY_EXT)"); - } - return GL_FALSE; - - case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB: - if (ctx->Extensions.ARB_shadow_ambient) { - if (texObj->Sampler.CompareFailValue != params[0]) { - flush(ctx); - texObj->Sampler.CompareFailValue = CLAMP(params[0], 0.0F, 1.0F); - return GL_TRUE; - } - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, - "glTexParameter(pname=GL_TEXTURE_COMPARE_FAIL_VALUE_ARB)"); - } - return GL_FALSE; - - case GL_TEXTURE_LOD_BIAS: - /* NOTE: this is really part of OpenGL 1.4, not EXT_texture_lod_bias */ - if (ctx->Extensions.EXT_texture_lod_bias) { - if (texObj->Sampler.LodBias != params[0]) { - flush(ctx); - texObj->Sampler.LodBias = params[0]; - return GL_TRUE; - } - return GL_FALSE; - } - break; - - case GL_TEXTURE_BORDER_COLOR: - flush(ctx); - /* ARB_texture_float disables clamping */ - if (ctx->Extensions.ARB_texture_float) { - texObj->Sampler.BorderColor.f[RCOMP] = params[0]; - texObj->Sampler.BorderColor.f[GCOMP] = params[1]; - texObj->Sampler.BorderColor.f[BCOMP] = params[2]; - texObj->Sampler.BorderColor.f[ACOMP] = params[3]; - } else { - texObj->Sampler.BorderColor.f[RCOMP] = CLAMP(params[0], 0.0F, 1.0F); - texObj->Sampler.BorderColor.f[GCOMP] = CLAMP(params[1], 0.0F, 1.0F); - texObj->Sampler.BorderColor.f[BCOMP] = CLAMP(params[2], 0.0F, 1.0F); - texObj->Sampler.BorderColor.f[ACOMP] = CLAMP(params[3], 0.0F, 1.0F); - } - return GL_TRUE; - - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glTexParameter(pname=0x%x)", pname); - } - return GL_FALSE; -} - - -void GLAPIENTRY -_mesa_TexParameterf(GLenum target, GLenum pname, GLfloat param) -{ - GLboolean need_update; - struct gl_texture_object *texObj; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - texObj = get_texobj(ctx, target, GL_FALSE); - if (!texObj) - return; - - switch (pname) { - case GL_TEXTURE_MIN_FILTER: - case GL_TEXTURE_MAG_FILTER: - case GL_TEXTURE_WRAP_S: - case GL_TEXTURE_WRAP_T: - case GL_TEXTURE_WRAP_R: - case GL_TEXTURE_BASE_LEVEL: - case GL_TEXTURE_MAX_LEVEL: - case GL_GENERATE_MIPMAP_SGIS: - case GL_TEXTURE_COMPARE_MODE_ARB: - case GL_TEXTURE_COMPARE_FUNC_ARB: - case GL_DEPTH_TEXTURE_MODE_ARB: - case GL_TEXTURE_SRGB_DECODE_EXT: - case GL_TEXTURE_CUBE_MAP_SEAMLESS: - { - /* convert float param to int */ - GLint p[4]; - p[0] = (GLint) param; - p[1] = p[2] = p[3] = 0; - need_update = set_tex_parameteri(ctx, texObj, pname, p); - } - break; - default: - { - /* this will generate an error if pname is illegal */ - GLfloat p[4]; - p[0] = param; - p[1] = p[2] = p[3] = 0.0F; - need_update = set_tex_parameterf(ctx, texObj, pname, p); - } - } - - if (ctx->Driver.TexParameter && need_update) { - ctx->Driver.TexParameter(ctx, target, texObj, pname, ¶m); - } -} - - -void GLAPIENTRY -_mesa_TexParameterfv(GLenum target, GLenum pname, const GLfloat *params) -{ - GLboolean need_update; - struct gl_texture_object *texObj; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - texObj = get_texobj(ctx, target, GL_FALSE); - if (!texObj) - return; - - switch (pname) { - case GL_TEXTURE_MIN_FILTER: - case GL_TEXTURE_MAG_FILTER: - case GL_TEXTURE_WRAP_S: - case GL_TEXTURE_WRAP_T: - case GL_TEXTURE_WRAP_R: - case GL_TEXTURE_BASE_LEVEL: - case GL_TEXTURE_MAX_LEVEL: - case GL_GENERATE_MIPMAP_SGIS: - case GL_TEXTURE_COMPARE_MODE_ARB: - case GL_TEXTURE_COMPARE_FUNC_ARB: - case GL_DEPTH_TEXTURE_MODE_ARB: - case GL_TEXTURE_SRGB_DECODE_EXT: - case GL_TEXTURE_CUBE_MAP_SEAMLESS: - { - /* convert float param to int */ - GLint p[4]; - p[0] = (GLint) params[0]; - p[1] = p[2] = p[3] = 0; - need_update = set_tex_parameteri(ctx, texObj, pname, p); - } - break; - -#if FEATURE_OES_draw_texture - case GL_TEXTURE_CROP_RECT_OES: - { - /* convert float params to int */ - GLint iparams[4]; - iparams[0] = (GLint) params[0]; - iparams[1] = (GLint) params[1]; - iparams[2] = (GLint) params[2]; - iparams[3] = (GLint) params[3]; - need_update = set_tex_parameteri(ctx, texObj, pname, iparams); - } - break; -#endif - - default: - /* this will generate an error if pname is illegal */ - need_update = set_tex_parameterf(ctx, texObj, pname, params); - } - - if (ctx->Driver.TexParameter && need_update) { - ctx->Driver.TexParameter(ctx, target, texObj, pname, params); - } -} - - -void GLAPIENTRY -_mesa_TexParameteri(GLenum target, GLenum pname, GLint param) -{ - GLboolean need_update; - struct gl_texture_object *texObj; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - texObj = get_texobj(ctx, target, GL_FALSE); - if (!texObj) - return; - - switch (pname) { - case GL_TEXTURE_MIN_LOD: - case GL_TEXTURE_MAX_LOD: - case GL_TEXTURE_PRIORITY: - case GL_TEXTURE_MAX_ANISOTROPY_EXT: - case GL_TEXTURE_LOD_BIAS: - case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB: - { - GLfloat fparam[4]; - fparam[0] = (GLfloat) param; - fparam[1] = fparam[2] = fparam[3] = 0.0F; - /* convert int param to float */ - need_update = set_tex_parameterf(ctx, texObj, pname, fparam); - } - break; - default: - /* this will generate an error if pname is illegal */ - { - GLint iparam[4]; - iparam[0] = param; - iparam[1] = iparam[2] = iparam[3] = 0; - need_update = set_tex_parameteri(ctx, texObj, pname, iparam); - } - } - - if (ctx->Driver.TexParameter && need_update) { - GLfloat fparam = (GLfloat) param; - ctx->Driver.TexParameter(ctx, target, texObj, pname, &fparam); - } -} - - -void GLAPIENTRY -_mesa_TexParameteriv(GLenum target, GLenum pname, const GLint *params) -{ - GLboolean need_update; - struct gl_texture_object *texObj; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - texObj = get_texobj(ctx, target, GL_FALSE); - if (!texObj) - return; - - switch (pname) { - case GL_TEXTURE_BORDER_COLOR: - { - /* convert int params to float */ - GLfloat fparams[4]; - fparams[0] = INT_TO_FLOAT(params[0]); - fparams[1] = INT_TO_FLOAT(params[1]); - fparams[2] = INT_TO_FLOAT(params[2]); - fparams[3] = INT_TO_FLOAT(params[3]); - need_update = set_tex_parameterf(ctx, texObj, pname, fparams); - } - break; - case GL_TEXTURE_MIN_LOD: - case GL_TEXTURE_MAX_LOD: - case GL_TEXTURE_PRIORITY: - case GL_TEXTURE_MAX_ANISOTROPY_EXT: - case GL_TEXTURE_LOD_BIAS: - case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB: - { - /* convert int param to float */ - GLfloat fparams[4]; - fparams[0] = (GLfloat) params[0]; - fparams[1] = fparams[2] = fparams[3] = 0.0F; - need_update = set_tex_parameterf(ctx, texObj, pname, fparams); - } - break; - default: - /* this will generate an error if pname is illegal */ - need_update = set_tex_parameteri(ctx, texObj, pname, params); - } - - if (ctx->Driver.TexParameter && need_update) { - GLfloat fparams[4]; - fparams[0] = INT_TO_FLOAT(params[0]); - if (pname == GL_TEXTURE_BORDER_COLOR || - pname == GL_TEXTURE_CROP_RECT_OES) { - fparams[1] = INT_TO_FLOAT(params[1]); - fparams[2] = INT_TO_FLOAT(params[2]); - fparams[3] = INT_TO_FLOAT(params[3]); - } - ctx->Driver.TexParameter(ctx, target, texObj, pname, fparams); - } -} - - -/** - * Set tex parameter to integer value(s). Primarily intended to set - * integer-valued texture border color (for integer-valued textures). - * New in GL 3.0. - */ -void GLAPIENTRY -_mesa_TexParameterIiv(GLenum target, GLenum pname, const GLint *params) -{ - struct gl_texture_object *texObj; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - texObj = get_texobj(ctx, target, GL_FALSE); - if (!texObj) - return; - - switch (pname) { - case GL_TEXTURE_BORDER_COLOR: - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - /* set the integer-valued border color */ - COPY_4V(texObj->Sampler.BorderColor.i, params); - break; - default: - _mesa_TexParameteriv(target, pname, params); - break; - } - /* XXX no driver hook for TexParameterIiv() yet */ -} - - -/** - * Set tex parameter to unsigned integer value(s). Primarily intended to set - * uint-valued texture border color (for integer-valued textures). - * New in GL 3.0 - */ -void GLAPIENTRY -_mesa_TexParameterIuiv(GLenum target, GLenum pname, const GLuint *params) -{ - struct gl_texture_object *texObj; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - texObj = get_texobj(ctx, target, GL_FALSE); - if (!texObj) - return; - - switch (pname) { - case GL_TEXTURE_BORDER_COLOR: - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - /* set the unsigned integer-valued border color */ - COPY_4V(texObj->Sampler.BorderColor.ui, params); - break; - default: - _mesa_TexParameteriv(target, pname, (const GLint *) params); - break; - } - /* XXX no driver hook for TexParameterIuiv() yet */ -} - - - - -void GLAPIENTRY -_mesa_GetTexLevelParameterfv( GLenum target, GLint level, - GLenum pname, GLfloat *params ) -{ - GLint iparam; - _mesa_GetTexLevelParameteriv( target, level, pname, &iparam ); - *params = (GLfloat) iparam; -} - - -void GLAPIENTRY -_mesa_GetTexLevelParameteriv( GLenum target, GLint level, - GLenum pname, GLint *params ) -{ - const struct gl_texture_unit *texUnit; - struct gl_texture_object *texObj; - const struct gl_texture_image *img = NULL; - GLint maxLevels; - gl_format texFormat; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (ctx->Texture.CurrentUnit >= ctx->Const.MaxCombinedTextureImageUnits) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetTexLevelParameteriv(current unit)"); - return; - } - - texUnit = _mesa_get_current_tex_unit(ctx); - - /* this will catch bad target values */ - maxLevels = _mesa_max_texture_levels(ctx, target); - if (maxLevels == 0) { - _mesa_error(ctx, GL_INVALID_ENUM, - "glGetTexLevelParameter[if]v(target=0x%x)", target); - return; - } - - if (level < 0 || level >= maxLevels) { - _mesa_error( ctx, GL_INVALID_VALUE, "glGetTexLevelParameter[if]v" ); - return; - } - - texObj = _mesa_select_tex_object(ctx, texUnit, target); - - img = _mesa_select_tex_image(ctx, texObj, target, level); - if (!img || img->TexFormat == MESA_FORMAT_NONE) { - /* undefined texture image */ - if (pname == GL_TEXTURE_COMPONENTS) - *params = 1; - else - *params = 0; - return; - } - - texFormat = img->TexFormat; - - switch (pname) { - case GL_TEXTURE_WIDTH: - *params = img->Width; - break; - case GL_TEXTURE_HEIGHT: - *params = img->Height; - break; - case GL_TEXTURE_DEPTH: - *params = img->Depth; - break; - case GL_TEXTURE_INTERNAL_FORMAT: - if (_mesa_is_format_compressed(texFormat)) { - /* need to return the actual compressed format */ - *params = _mesa_compressed_format_to_glenum(ctx, texFormat); - } - else { - /* If the true internal format is not compressed but the user - * requested a generic compressed format, we have to return the - * generic base format that matches. - * - * From page 119 (page 129 of the PDF) of the OpenGL 1.3 spec: - * - * "If no specific compressed format is available, - * internalformat is instead replaced by the corresponding base - * internal format." - * - * Otherwise just return the user's requested internal format - */ - const GLenum f = - _mesa_gl_compressed_format_base_format(img->InternalFormat); - - *params = (f != 0) ? f : img->InternalFormat; - } - break; - case GL_TEXTURE_BORDER: - *params = img->Border; - break; - case GL_TEXTURE_RED_SIZE: - if (img->_BaseFormat == GL_RED) { - *params = _mesa_get_format_bits(texFormat, pname); - break; - } - /* FALLTHROUGH */ - case GL_TEXTURE_GREEN_SIZE: - if (img->_BaseFormat == GL_RG) { - *params = _mesa_get_format_bits(texFormat, pname); - break; - } - /* FALLTHROUGH */ - case GL_TEXTURE_BLUE_SIZE: - if (img->_BaseFormat == GL_RGB || img->_BaseFormat == GL_RGBA) - *params = _mesa_get_format_bits(texFormat, pname); - else - *params = 0; - break; - case GL_TEXTURE_ALPHA_SIZE: - if (img->_BaseFormat == GL_ALPHA || - img->_BaseFormat == GL_LUMINANCE_ALPHA || - img->_BaseFormat == GL_RGBA) - *params = _mesa_get_format_bits(texFormat, pname); - else - *params = 0; - break; - case GL_TEXTURE_INTENSITY_SIZE: - if (img->_BaseFormat != GL_INTENSITY) - *params = 0; - else { - *params = _mesa_get_format_bits(texFormat, pname); - if (*params == 0) { - /* intensity probably stored as rgb texture */ - *params = MIN2(_mesa_get_format_bits(texFormat, GL_TEXTURE_RED_SIZE), - _mesa_get_format_bits(texFormat, GL_TEXTURE_GREEN_SIZE)); - } - } - break; - case GL_TEXTURE_LUMINANCE_SIZE: - if (img->_BaseFormat != GL_LUMINANCE && - img->_BaseFormat != GL_LUMINANCE_ALPHA) - *params = 0; - else { - *params = _mesa_get_format_bits(texFormat, pname); - if (*params == 0) { - /* luminance probably stored as rgb texture */ - *params = MIN2(_mesa_get_format_bits(texFormat, GL_TEXTURE_RED_SIZE), - _mesa_get_format_bits(texFormat, GL_TEXTURE_GREEN_SIZE)); - } - } - break; - case GL_TEXTURE_DEPTH_SIZE_ARB: - if (!ctx->Extensions.ARB_depth_texture) - goto invalid_pname; - *params = _mesa_get_format_bits(texFormat, pname); - break; - case GL_TEXTURE_STENCIL_SIZE_EXT: - if (!ctx->Extensions.EXT_packed_depth_stencil && - !ctx->Extensions.ARB_framebuffer_object) - goto invalid_pname; - *params = _mesa_get_format_bits(texFormat, pname); - break; - case GL_TEXTURE_SHARED_SIZE: - if (ctx->VersionMajor < 3 && - !ctx->Extensions.EXT_texture_shared_exponent) - goto invalid_pname; - *params = texFormat == MESA_FORMAT_RGB9_E5_FLOAT ? 5 : 0; - break; - - /* GL_ARB_texture_compression */ - case GL_TEXTURE_COMPRESSED_IMAGE_SIZE: - if (_mesa_is_format_compressed(texFormat) && - !_mesa_is_proxy_texture(target)) { - *params = _mesa_format_image_size(texFormat, img->Width, - img->Height, img->Depth); - } - else { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetTexLevelParameter[if]v(pname)"); - } - break; - case GL_TEXTURE_COMPRESSED: - *params = (GLint) _mesa_is_format_compressed(texFormat); - break; - - /* GL_ARB_texture_float */ - case GL_TEXTURE_RED_TYPE_ARB: - if (!ctx->Extensions.ARB_texture_float) - goto invalid_pname; - *params = _mesa_get_format_bits(texFormat, GL_TEXTURE_RED_SIZE) ? - _mesa_get_format_datatype(texFormat) : GL_NONE; - break; - case GL_TEXTURE_GREEN_TYPE_ARB: - if (!ctx->Extensions.ARB_texture_float) - goto invalid_pname; - *params = _mesa_get_format_bits(texFormat, GL_TEXTURE_GREEN_SIZE) ? - _mesa_get_format_datatype(texFormat) : GL_NONE; - break; - case GL_TEXTURE_BLUE_TYPE_ARB: - if (!ctx->Extensions.ARB_texture_float) - goto invalid_pname; - *params = _mesa_get_format_bits(texFormat, GL_TEXTURE_BLUE_SIZE) ? - _mesa_get_format_datatype(texFormat) : GL_NONE; - break; - case GL_TEXTURE_ALPHA_TYPE_ARB: - if (!ctx->Extensions.ARB_texture_float) - goto invalid_pname; - *params = _mesa_get_format_bits(texFormat, GL_TEXTURE_ALPHA_SIZE) ? - _mesa_get_format_datatype(texFormat) : GL_NONE; - break; - case GL_TEXTURE_LUMINANCE_TYPE_ARB: - if (!ctx->Extensions.ARB_texture_float) - goto invalid_pname; - *params = _mesa_get_format_bits(texFormat, GL_TEXTURE_LUMINANCE_SIZE) ? - _mesa_get_format_datatype(texFormat) : GL_NONE; - break; - case GL_TEXTURE_INTENSITY_TYPE_ARB: - if (!ctx->Extensions.ARB_texture_float) - goto invalid_pname; - *params = _mesa_get_format_bits(texFormat, GL_TEXTURE_INTENSITY_SIZE) ? - _mesa_get_format_datatype(texFormat) : GL_NONE; - break; - case GL_TEXTURE_DEPTH_TYPE_ARB: - if (!ctx->Extensions.ARB_texture_float) - goto invalid_pname; - *params = _mesa_get_format_bits(texFormat, GL_TEXTURE_DEPTH_SIZE) ? - _mesa_get_format_datatype(texFormat) : GL_NONE; - break; - - default: - goto invalid_pname; - } - - /* no error if we get here */ - return; - -invalid_pname: - _mesa_error(ctx, GL_INVALID_ENUM, - "glGetTexLevelParameter[if]v(pname=%s)", - _mesa_lookup_enum_by_nr(pname)); -} - - - -void GLAPIENTRY -_mesa_GetTexParameterfv( GLenum target, GLenum pname, GLfloat *params ) -{ - struct gl_texture_object *obj; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - obj = get_texobj(ctx, target, GL_TRUE); - if (!obj) - return; - - _mesa_lock_texture(ctx, obj); - switch (pname) { - case GL_TEXTURE_MAG_FILTER: - *params = ENUM_TO_FLOAT(obj->Sampler.MagFilter); - break; - case GL_TEXTURE_MIN_FILTER: - *params = ENUM_TO_FLOAT(obj->Sampler.MinFilter); - break; - case GL_TEXTURE_WRAP_S: - *params = ENUM_TO_FLOAT(obj->Sampler.WrapS); - break; - case GL_TEXTURE_WRAP_T: - *params = ENUM_TO_FLOAT(obj->Sampler.WrapT); - break; - case GL_TEXTURE_WRAP_R: - *params = ENUM_TO_FLOAT(obj->Sampler.WrapR); - break; - case GL_TEXTURE_BORDER_COLOR: - if (ctx->NewState & (_NEW_BUFFERS | _NEW_FRAG_CLAMP)) - _mesa_update_state_locked(ctx); - if (ctx->Color._ClampFragmentColor) { - params[0] = CLAMP(obj->Sampler.BorderColor.f[0], 0.0F, 1.0F); - params[1] = CLAMP(obj->Sampler.BorderColor.f[1], 0.0F, 1.0F); - params[2] = CLAMP(obj->Sampler.BorderColor.f[2], 0.0F, 1.0F); - params[3] = CLAMP(obj->Sampler.BorderColor.f[3], 0.0F, 1.0F); - } - else { - params[0] = obj->Sampler.BorderColor.f[0]; - params[1] = obj->Sampler.BorderColor.f[1]; - params[2] = obj->Sampler.BorderColor.f[2]; - params[3] = obj->Sampler.BorderColor.f[3]; - } - break; - case GL_TEXTURE_RESIDENT: - *params = ctx->Driver.IsTextureResident ? - ctx->Driver.IsTextureResident(ctx, obj) : 1.0F; - break; - case GL_TEXTURE_PRIORITY: - *params = obj->Priority; - break; - case GL_TEXTURE_MIN_LOD: - *params = obj->Sampler.MinLod; - break; - case GL_TEXTURE_MAX_LOD: - *params = obj->Sampler.MaxLod; - break; - case GL_TEXTURE_BASE_LEVEL: - *params = (GLfloat) obj->BaseLevel; - break; - case GL_TEXTURE_MAX_LEVEL: - *params = (GLfloat) obj->MaxLevel; - break; - case GL_TEXTURE_MAX_ANISOTROPY_EXT: - if (!ctx->Extensions.EXT_texture_filter_anisotropic) - goto invalid_pname; - *params = obj->Sampler.MaxAnisotropy; - break; - case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB: - if (!ctx->Extensions.ARB_shadow_ambient) - goto invalid_pname; - *params = obj->Sampler.CompareFailValue; - break; - case GL_GENERATE_MIPMAP_SGIS: - *params = (GLfloat) obj->GenerateMipmap; - break; - case GL_TEXTURE_COMPARE_MODE_ARB: - if (!ctx->Extensions.ARB_shadow) - goto invalid_pname; - *params = (GLfloat) obj->Sampler.CompareMode; - break; - case GL_TEXTURE_COMPARE_FUNC_ARB: - if (!ctx->Extensions.ARB_shadow) - goto invalid_pname; - *params = (GLfloat) obj->Sampler.CompareFunc; - break; - case GL_DEPTH_TEXTURE_MODE_ARB: - if (!ctx->Extensions.ARB_depth_texture) - goto invalid_pname; - *params = (GLfloat) obj->Sampler.DepthMode; - break; - case GL_TEXTURE_LOD_BIAS: - if (!ctx->Extensions.EXT_texture_lod_bias) - goto invalid_pname; - *params = obj->Sampler.LodBias; - break; -#if FEATURE_OES_draw_texture - case GL_TEXTURE_CROP_RECT_OES: - params[0] = obj->CropRect[0]; - params[1] = obj->CropRect[1]; - params[2] = obj->CropRect[2]; - params[3] = obj->CropRect[3]; - break; -#endif - - case GL_TEXTURE_SWIZZLE_R_EXT: - case GL_TEXTURE_SWIZZLE_G_EXT: - case GL_TEXTURE_SWIZZLE_B_EXT: - case GL_TEXTURE_SWIZZLE_A_EXT: - if (!ctx->Extensions.EXT_texture_swizzle) - goto invalid_pname; - *params = (GLfloat) obj->Swizzle[pname - GL_TEXTURE_SWIZZLE_R_EXT]; - break; - - case GL_TEXTURE_SWIZZLE_RGBA_EXT: - if (!ctx->Extensions.EXT_texture_swizzle) { - goto invalid_pname; - } - else { - GLuint comp; - for (comp = 0; comp < 4; comp++) { - params[comp] = (GLfloat) obj->Swizzle[comp]; - } - } - break; - - case GL_TEXTURE_CUBE_MAP_SEAMLESS: - if (!ctx->Extensions.AMD_seamless_cubemap_per_texture) - goto invalid_pname; - *params = (GLfloat) obj->Sampler.CubeMapSeamless; - break; - - default: - goto invalid_pname; - } - - /* no error if we get here */ - _mesa_unlock_texture(ctx, obj); - return; - -invalid_pname: - _mesa_unlock_texture(ctx, obj); - _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexParameterfv(pname=0x%x)", pname); -} - - -void GLAPIENTRY -_mesa_GetTexParameteriv( GLenum target, GLenum pname, GLint *params ) -{ - struct gl_texture_object *obj; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - obj = get_texobj(ctx, target, GL_TRUE); - if (!obj) - return; - - _mesa_lock_texture(ctx, obj); - switch (pname) { - case GL_TEXTURE_MAG_FILTER: - *params = (GLint) obj->Sampler.MagFilter; - break;; - case GL_TEXTURE_MIN_FILTER: - *params = (GLint) obj->Sampler.MinFilter; - break;; - case GL_TEXTURE_WRAP_S: - *params = (GLint) obj->Sampler.WrapS; - break;; - case GL_TEXTURE_WRAP_T: - *params = (GLint) obj->Sampler.WrapT; - break;; - case GL_TEXTURE_WRAP_R: - *params = (GLint) obj->Sampler.WrapR; - break;; - case GL_TEXTURE_BORDER_COLOR: - { - GLfloat b[4]; - b[0] = CLAMP(obj->Sampler.BorderColor.f[0], 0.0F, 1.0F); - b[1] = CLAMP(obj->Sampler.BorderColor.f[1], 0.0F, 1.0F); - b[2] = CLAMP(obj->Sampler.BorderColor.f[2], 0.0F, 1.0F); - b[3] = CLAMP(obj->Sampler.BorderColor.f[3], 0.0F, 1.0F); - params[0] = FLOAT_TO_INT(b[0]); - params[1] = FLOAT_TO_INT(b[1]); - params[2] = FLOAT_TO_INT(b[2]); - params[3] = FLOAT_TO_INT(b[3]); - } - break;; - case GL_TEXTURE_RESIDENT: - *params = ctx->Driver.IsTextureResident ? - ctx->Driver.IsTextureResident(ctx, obj) : 1; - break;; - case GL_TEXTURE_PRIORITY: - *params = FLOAT_TO_INT(obj->Priority); - break;; - case GL_TEXTURE_MIN_LOD: - *params = (GLint) obj->Sampler.MinLod; - break;; - case GL_TEXTURE_MAX_LOD: - *params = (GLint) obj->Sampler.MaxLod; - break;; - case GL_TEXTURE_BASE_LEVEL: - *params = obj->BaseLevel; - break;; - case GL_TEXTURE_MAX_LEVEL: - *params = obj->MaxLevel; - break;; - case GL_TEXTURE_MAX_ANISOTROPY_EXT: - if (!ctx->Extensions.EXT_texture_filter_anisotropic) - goto invalid_pname; - *params = (GLint) obj->Sampler.MaxAnisotropy; - break; - case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB: - if (!ctx->Extensions.ARB_shadow_ambient) - goto invalid_pname; - *params = (GLint) FLOAT_TO_INT(obj->Sampler.CompareFailValue); - break; - case GL_GENERATE_MIPMAP_SGIS: - *params = (GLint) obj->GenerateMipmap; - break; - case GL_TEXTURE_COMPARE_MODE_ARB: - if (!ctx->Extensions.ARB_shadow) - goto invalid_pname; - *params = (GLint) obj->Sampler.CompareMode; - break; - case GL_TEXTURE_COMPARE_FUNC_ARB: - if (!ctx->Extensions.ARB_shadow) - goto invalid_pname; - *params = (GLint) obj->Sampler.CompareFunc; - break; - case GL_DEPTH_TEXTURE_MODE_ARB: - if (!ctx->Extensions.ARB_depth_texture) - goto invalid_pname; - *params = (GLint) obj->Sampler.DepthMode; - break; - case GL_TEXTURE_LOD_BIAS: - if (!ctx->Extensions.EXT_texture_lod_bias) - goto invalid_pname; - *params = (GLint) obj->Sampler.LodBias; - break; -#if FEATURE_OES_draw_texture - case GL_TEXTURE_CROP_RECT_OES: - params[0] = obj->CropRect[0]; - params[1] = obj->CropRect[1]; - params[2] = obj->CropRect[2]; - params[3] = obj->CropRect[3]; - break; -#endif - case GL_TEXTURE_SWIZZLE_R_EXT: - case GL_TEXTURE_SWIZZLE_G_EXT: - case GL_TEXTURE_SWIZZLE_B_EXT: - case GL_TEXTURE_SWIZZLE_A_EXT: - if (!ctx->Extensions.EXT_texture_swizzle) - goto invalid_pname; - *params = obj->Swizzle[pname - GL_TEXTURE_SWIZZLE_R_EXT]; - break; - - case GL_TEXTURE_SWIZZLE_RGBA_EXT: - if (!ctx->Extensions.EXT_texture_swizzle) - goto invalid_pname; - COPY_4V(params, obj->Swizzle); - break; - - case GL_TEXTURE_CUBE_MAP_SEAMLESS: - if (!ctx->Extensions.AMD_seamless_cubemap_per_texture) - goto invalid_pname; - *params = (GLint) obj->Sampler.CubeMapSeamless; - break; - - default: - goto invalid_pname; - } - - /* no error if we get here */ - _mesa_unlock_texture(ctx, obj); - return; - -invalid_pname: - _mesa_unlock_texture(ctx, obj); - _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexParameteriv(pname=0x%x)", pname); -} - - -/** New in GL 3.0 */ -void GLAPIENTRY -_mesa_GetTexParameterIiv(GLenum target, GLenum pname, GLint *params) -{ - struct gl_texture_object *texObj; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - texObj = get_texobj(ctx, target, GL_TRUE); - if (!texObj) - return; - - switch (pname) { - case GL_TEXTURE_BORDER_COLOR: - COPY_4V(params, texObj->Sampler.BorderColor.i); - break; - default: - _mesa_GetTexParameteriv(target, pname, params); - } -} - - -/** New in GL 3.0 */ -void GLAPIENTRY -_mesa_GetTexParameterIuiv(GLenum target, GLenum pname, GLuint *params) -{ - struct gl_texture_object *texObj; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - texObj = get_texobj(ctx, target, GL_TRUE); - if (!texObj) - return; - - switch (pname) { - case GL_TEXTURE_BORDER_COLOR: - COPY_4V(params, texObj->Sampler.BorderColor.i); - break; - default: - { - GLint ip[4]; - _mesa_GetTexParameteriv(target, pname, ip); - params[0] = ip[0]; - if (pname == GL_TEXTURE_SWIZZLE_RGBA_EXT || - pname == GL_TEXTURE_CROP_RECT_OES) { - params[1] = ip[1]; - params[2] = ip[2]; - params[3] = ip[3]; - } - } - } -} +/* + * Mesa 3-D graphics library + * Version: 7.5 + * + * Copyright (C) 1999-2008 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. + */ + +/** + * \file texparam.c + * + * glTexParameter-related functions + */ + + +#include "main/glheader.h" +#include "main/colormac.h" +#include "main/context.h" +#include "main/enums.h" +#include "main/formats.h" +#include "main/macros.h" +#include "main/mfeatures.h" +#include "main/mtypes.h" +#include "main/state.h" +#include "main/texcompress.h" +#include "main/texparam.h" +#include "main/teximage.h" +#include "main/texstate.h" +#include "main/texfetch.h" +#include "program/prog_instruction.h" + + +/** + * Check if a coordinate wrap mode is supported for the texture target. + * \return GL_TRUE if legal, GL_FALSE otherwise + */ +static GLboolean +validate_texture_wrap_mode(struct gl_context * ctx, GLenum target, GLenum wrap) +{ + const struct gl_extensions * const e = & ctx->Extensions; + + if (wrap == GL_CLAMP || wrap == GL_CLAMP_TO_EDGE || + (wrap == GL_CLAMP_TO_BORDER && e->ARB_texture_border_clamp)) { + /* any texture target */ + return GL_TRUE; + } + else if (target != GL_TEXTURE_RECTANGLE_NV && + (wrap == GL_REPEAT || + (wrap == GL_MIRRORED_REPEAT && + e->ARB_texture_mirrored_repeat) || + (wrap == GL_MIRROR_CLAMP_EXT && + (e->ATI_texture_mirror_once || e->EXT_texture_mirror_clamp)) || + (wrap == GL_MIRROR_CLAMP_TO_EDGE_EXT && + (e->ATI_texture_mirror_once || e->EXT_texture_mirror_clamp)) || + (wrap == GL_MIRROR_CLAMP_TO_BORDER_EXT && + (e->EXT_texture_mirror_clamp)))) { + /* non-rectangle texture */ + return GL_TRUE; + } + + _mesa_error( ctx, GL_INVALID_ENUM, "glTexParameter(param=0x%x)", wrap ); + return GL_FALSE; +} + + +/** + * Get current texture object for given target. + * Return NULL if any error (and record the error). + * Note that this is different from _mesa_select_tex_object() in that proxy + * targets are not accepted. + * Only the glGetTexLevelParameter() functions accept proxy targets. + */ +static struct gl_texture_object * +get_texobj(struct gl_context *ctx, GLenum target, GLboolean get) +{ + struct gl_texture_unit *texUnit; + + if (ctx->Texture.CurrentUnit >= ctx->Const.MaxCombinedTextureImageUnits) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "gl%sTexParameter(current unit)", get ? "Get" : ""); + return NULL; + } + + texUnit = _mesa_get_current_tex_unit(ctx); + + switch (target) { + case GL_TEXTURE_1D: + return texUnit->CurrentTex[TEXTURE_1D_INDEX]; + case GL_TEXTURE_2D: + return texUnit->CurrentTex[TEXTURE_2D_INDEX]; + case GL_TEXTURE_3D: + return texUnit->CurrentTex[TEXTURE_3D_INDEX]; + case GL_TEXTURE_CUBE_MAP: + if (ctx->Extensions.ARB_texture_cube_map) { + return texUnit->CurrentTex[TEXTURE_CUBE_INDEX]; + } + break; + case GL_TEXTURE_RECTANGLE_NV: + if (ctx->Extensions.NV_texture_rectangle) { + return texUnit->CurrentTex[TEXTURE_RECT_INDEX]; + } + break; + case GL_TEXTURE_1D_ARRAY_EXT: + if (ctx->Extensions.MESA_texture_array || + ctx->Extensions.EXT_texture_array) { + return texUnit->CurrentTex[TEXTURE_1D_ARRAY_INDEX]; + } + break; + case GL_TEXTURE_2D_ARRAY_EXT: + if (ctx->Extensions.MESA_texture_array || + ctx->Extensions.EXT_texture_array) { + return texUnit->CurrentTex[TEXTURE_2D_ARRAY_INDEX]; + } + break; + default: + ; + } + + _mesa_error(ctx, GL_INVALID_ENUM, + "gl%sTexParameter(target)", get ? "Get" : ""); + return NULL; +} + + +/** + * Convert GL_RED/GREEN/BLUE/ALPHA/ZERO/ONE to SWIZZLE_X/Y/Z/W/ZERO/ONE. + * \return -1 if error. + */ +static GLint +comp_to_swizzle(GLenum comp) +{ + switch (comp) { + case GL_RED: + return SWIZZLE_X; + case GL_GREEN: + return SWIZZLE_Y; + case GL_BLUE: + return SWIZZLE_Z; + case GL_ALPHA: + return SWIZZLE_W; + case GL_ZERO: + return SWIZZLE_ZERO; + case GL_ONE: + return SWIZZLE_ONE; + default: + return -1; + } +} + + +static void +set_swizzle_component(GLuint *swizzle, GLuint comp, GLuint swz) +{ + ASSERT(comp < 4); + ASSERT(swz <= SWIZZLE_NIL); + { + GLuint mask = 0x7 << (3 * comp); + GLuint s = (*swizzle & ~mask) | (swz << (3 * comp)); + *swizzle = s; + } +} + + +/** + * This is called just prior to changing any texture object state which + * will not effect texture completeness. + */ +static INLINE void +flush(struct gl_context *ctx) +{ + FLUSH_VERTICES(ctx, _NEW_TEXTURE); +} + + +/** + * This is called just prior to changing any texture object state which + * can effect texture completeness (texture base level, max level, + * minification filter). + * Any pending rendering will be flushed out, we'll set the _NEW_TEXTURE + * state flag and then mark the texture object as 'incomplete' so that any + * per-texture derived state gets recomputed. + */ +static INLINE void +incomplete(struct gl_context *ctx, struct gl_texture_object *texObj) +{ + FLUSH_VERTICES(ctx, _NEW_TEXTURE); + texObj->_Complete = GL_FALSE; +} + + +/** + * Set an integer-valued texture parameter + * \return GL_TRUE if legal AND the value changed, GL_FALSE otherwise + */ +static GLboolean +set_tex_parameteri(struct gl_context *ctx, + struct gl_texture_object *texObj, + GLenum pname, const GLint *params) +{ + switch (pname) { + case GL_TEXTURE_MIN_FILTER: + if (texObj->Sampler.MinFilter == params[0]) + return GL_FALSE; + switch (params[0]) { + case GL_NEAREST: + case GL_LINEAR: + incomplete(ctx, texObj); + texObj->Sampler.MinFilter = params[0]; + return GL_TRUE; + case GL_NEAREST_MIPMAP_NEAREST: + case GL_LINEAR_MIPMAP_NEAREST: + case GL_NEAREST_MIPMAP_LINEAR: + case GL_LINEAR_MIPMAP_LINEAR: + if (texObj->Target != GL_TEXTURE_RECTANGLE_NV) { + incomplete(ctx, texObj); + texObj->Sampler.MinFilter = params[0]; + return GL_TRUE; + } + /* fall-through */ + default: + goto invalid_param; + } + return GL_FALSE; + + case GL_TEXTURE_MAG_FILTER: + if (texObj->Sampler.MagFilter == params[0]) + return GL_FALSE; + switch (params[0]) { + case GL_NEAREST: + case GL_LINEAR: + flush(ctx); /* does not effect completeness */ + texObj->Sampler.MagFilter = params[0]; + return GL_TRUE; + default: + goto invalid_param; + } + return GL_FALSE; + + case GL_TEXTURE_WRAP_S: + if (texObj->Sampler.WrapS == params[0]) + return GL_FALSE; + if (validate_texture_wrap_mode(ctx, texObj->Target, params[0])) { + flush(ctx); + texObj->Sampler.WrapS = params[0]; + return GL_TRUE; + } + return GL_FALSE; + + case GL_TEXTURE_WRAP_T: + if (texObj->Sampler.WrapT == params[0]) + return GL_FALSE; + if (validate_texture_wrap_mode(ctx, texObj->Target, params[0])) { + flush(ctx); + texObj->Sampler.WrapT = params[0]; + return GL_TRUE; + } + return GL_FALSE; + + case GL_TEXTURE_WRAP_R: + if (texObj->Sampler.WrapR == params[0]) + return GL_FALSE; + if (validate_texture_wrap_mode(ctx, texObj->Target, params[0])) { + flush(ctx); + texObj->Sampler.WrapR = params[0]; + return GL_TRUE; + } + return GL_FALSE; + + case GL_TEXTURE_BASE_LEVEL: + if (texObj->BaseLevel == params[0]) + return GL_FALSE; + if (params[0] < 0 || + (texObj->Target == GL_TEXTURE_RECTANGLE_ARB && params[0] != 0)) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glTexParameter(param=%d)", params[0]); + return GL_FALSE; + } + incomplete(ctx, texObj); + texObj->BaseLevel = params[0]; + return GL_TRUE; + + case GL_TEXTURE_MAX_LEVEL: + if (texObj->MaxLevel == params[0]) + return GL_FALSE; + if (params[0] < 0 || texObj->Target == GL_TEXTURE_RECTANGLE_ARB) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glTexParameter(param=%d)", params[0]); + return GL_FALSE; + } + incomplete(ctx, texObj); + texObj->MaxLevel = params[0]; + return GL_TRUE; + + case GL_GENERATE_MIPMAP_SGIS: + if (texObj->GenerateMipmap != params[0]) { + /* no flush() */ + texObj->GenerateMipmap = params[0] ? GL_TRUE : GL_FALSE; + return GL_TRUE; + } + return GL_FALSE; + + case GL_TEXTURE_COMPARE_MODE_ARB: + if (ctx->Extensions.ARB_shadow) { + if (texObj->Sampler.CompareMode == params[0]) + return GL_FALSE; + if (params[0] == GL_NONE || + params[0] == GL_COMPARE_R_TO_TEXTURE_ARB) { + flush(ctx); + texObj->Sampler.CompareMode = params[0]; + return GL_TRUE; + } + goto invalid_param; + } + goto invalid_pname; + + case GL_TEXTURE_COMPARE_FUNC_ARB: + if (ctx->Extensions.ARB_shadow) { + if (texObj->Sampler.CompareFunc == params[0]) + return GL_FALSE; + switch (params[0]) { + case GL_LEQUAL: + case GL_GEQUAL: + flush(ctx); + texObj->Sampler.CompareFunc = params[0]; + return GL_TRUE; + case GL_EQUAL: + case GL_NOTEQUAL: + case GL_LESS: + case GL_GREATER: + case GL_ALWAYS: + case GL_NEVER: + if (ctx->Extensions.EXT_shadow_funcs) { + flush(ctx); + texObj->Sampler.CompareFunc = params[0]; + return GL_TRUE; + } + /* fall-through */ + default: + goto invalid_param; + } + } + goto invalid_pname; + + case GL_DEPTH_TEXTURE_MODE_ARB: + if (ctx->Extensions.ARB_depth_texture) { + if (texObj->Sampler.DepthMode == params[0]) + return GL_FALSE; + if (params[0] == GL_LUMINANCE || + params[0] == GL_INTENSITY || + params[0] == GL_ALPHA || + (ctx->Extensions.ARB_texture_rg && params[0] == GL_RED)) { + flush(ctx); + texObj->Sampler.DepthMode = params[0]; + return GL_TRUE; + } + goto invalid_param; + } + goto invalid_pname; + +#if FEATURE_OES_draw_texture + case GL_TEXTURE_CROP_RECT_OES: + texObj->CropRect[0] = params[0]; + texObj->CropRect[1] = params[1]; + texObj->CropRect[2] = params[2]; + texObj->CropRect[3] = params[3]; + return GL_TRUE; +#endif + + case GL_TEXTURE_SWIZZLE_R_EXT: + case GL_TEXTURE_SWIZZLE_G_EXT: + case GL_TEXTURE_SWIZZLE_B_EXT: + case GL_TEXTURE_SWIZZLE_A_EXT: + if (ctx->Extensions.EXT_texture_swizzle) { + const GLuint comp = pname - GL_TEXTURE_SWIZZLE_R_EXT; + const GLint swz = comp_to_swizzle(params[0]); + if (swz < 0) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glTexParameter(swizzle 0x%x)", params[0]); + return GL_FALSE; + } + ASSERT(comp < 4); + if (swz >= 0) { + flush(ctx); + texObj->Swizzle[comp] = params[0]; + set_swizzle_component(&texObj->_Swizzle, comp, swz); + return GL_TRUE; + } + } + goto invalid_pname; + + case GL_TEXTURE_SWIZZLE_RGBA_EXT: + if (ctx->Extensions.EXT_texture_swizzle) { + GLuint comp; + flush(ctx); + for (comp = 0; comp < 4; comp++) { + const GLint swz = comp_to_swizzle(params[comp]); + if (swz >= 0) { + texObj->Swizzle[comp] = params[comp]; + set_swizzle_component(&texObj->_Swizzle, comp, swz); + } + else { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glTexParameter(swizzle 0x%x)", params[comp]); + return GL_FALSE; + } + } + return GL_TRUE; + } + goto invalid_pname; + + case GL_TEXTURE_SRGB_DECODE_EXT: + if (ctx->Extensions.EXT_texture_sRGB_decode) { + GLenum decode = params[0]; + if (decode == GL_DECODE_EXT || decode == GL_SKIP_DECODE_EXT) { + if (texObj->Sampler.sRGBDecode != decode) { + flush(ctx); + texObj->Sampler.sRGBDecode = decode; + _mesa_update_fetch_functions(texObj); + } + return GL_TRUE; + } + } + goto invalid_pname; + + case GL_TEXTURE_CUBE_MAP_SEAMLESS: + if (ctx->Extensions.AMD_seamless_cubemap_per_texture) { + GLenum param = params[0]; + if (param != GL_TRUE && param != GL_FALSE) { + goto invalid_param; + } + if (param != texObj->Sampler.CubeMapSeamless) { + flush(ctx); + texObj->Sampler.CubeMapSeamless = param; + } + return GL_TRUE; + } + goto invalid_pname; + + default: + goto invalid_pname; + } + +invalid_pname: + _mesa_error(ctx, GL_INVALID_ENUM, "glTexParameter(pname=%s)", + _mesa_lookup_enum_by_nr(pname)); + return GL_FALSE; + +invalid_param: + _mesa_error(ctx, GL_INVALID_ENUM, "glTexParameter(param=%s)", + _mesa_lookup_enum_by_nr(params[0])); + return GL_FALSE; +} + + +/** + * Set a float-valued texture parameter + * \return GL_TRUE if legal AND the value changed, GL_FALSE otherwise + */ +static GLboolean +set_tex_parameterf(struct gl_context *ctx, + struct gl_texture_object *texObj, + GLenum pname, const GLfloat *params) +{ + switch (pname) { + case GL_TEXTURE_MIN_LOD: + if (texObj->Sampler.MinLod == params[0]) + return GL_FALSE; + flush(ctx); + texObj->Sampler.MinLod = params[0]; + return GL_TRUE; + + case GL_TEXTURE_MAX_LOD: + if (texObj->Sampler.MaxLod == params[0]) + return GL_FALSE; + flush(ctx); + texObj->Sampler.MaxLod = params[0]; + return GL_TRUE; + + case GL_TEXTURE_PRIORITY: + flush(ctx); + texObj->Priority = CLAMP(params[0], 0.0F, 1.0F); + return GL_TRUE; + + case GL_TEXTURE_MAX_ANISOTROPY_EXT: + if (ctx->Extensions.EXT_texture_filter_anisotropic) { + if (texObj->Sampler.MaxAnisotropy == params[0]) + return GL_FALSE; + if (params[0] < 1.0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glTexParameter(param)" ); + return GL_FALSE; + } + flush(ctx); + /* clamp to max, that's what NVIDIA does */ + texObj->Sampler.MaxAnisotropy = MIN2(params[0], + ctx->Const.MaxTextureMaxAnisotropy); + return GL_TRUE; + } + else { + static GLuint count = 0; + if (count++ < 10) + _mesa_error(ctx, GL_INVALID_ENUM, + "glTexParameter(pname=GL_TEXTURE_MAX_ANISOTROPY_EXT)"); + } + return GL_FALSE; + + case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB: + if (ctx->Extensions.ARB_shadow_ambient) { + if (texObj->Sampler.CompareFailValue != params[0]) { + flush(ctx); + texObj->Sampler.CompareFailValue = CLAMP(params[0], 0.0F, 1.0F); + return GL_TRUE; + } + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, + "glTexParameter(pname=GL_TEXTURE_COMPARE_FAIL_VALUE_ARB)"); + } + return GL_FALSE; + + case GL_TEXTURE_LOD_BIAS: + /* NOTE: this is really part of OpenGL 1.4, not EXT_texture_lod_bias */ + if (ctx->Extensions.EXT_texture_lod_bias) { + if (texObj->Sampler.LodBias != params[0]) { + flush(ctx); + texObj->Sampler.LodBias = params[0]; + return GL_TRUE; + } + return GL_FALSE; + } + break; + + case GL_TEXTURE_BORDER_COLOR: + flush(ctx); + /* ARB_texture_float disables clamping */ + if (ctx->Extensions.ARB_texture_float) { + texObj->Sampler.BorderColor.f[RCOMP] = params[0]; + texObj->Sampler.BorderColor.f[GCOMP] = params[1]; + texObj->Sampler.BorderColor.f[BCOMP] = params[2]; + texObj->Sampler.BorderColor.f[ACOMP] = params[3]; + } else { + texObj->Sampler.BorderColor.f[RCOMP] = CLAMP(params[0], 0.0F, 1.0F); + texObj->Sampler.BorderColor.f[GCOMP] = CLAMP(params[1], 0.0F, 1.0F); + texObj->Sampler.BorderColor.f[BCOMP] = CLAMP(params[2], 0.0F, 1.0F); + texObj->Sampler.BorderColor.f[ACOMP] = CLAMP(params[3], 0.0F, 1.0F); + } + return GL_TRUE; + + default: + _mesa_error(ctx, GL_INVALID_ENUM, "glTexParameter(pname=0x%x)", pname); + } + return GL_FALSE; +} + + +void GLAPIENTRY +_mesa_TexParameterf(GLenum target, GLenum pname, GLfloat param) +{ + GLboolean need_update; + struct gl_texture_object *texObj; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + texObj = get_texobj(ctx, target, GL_FALSE); + if (!texObj) + return; + + switch (pname) { + case GL_TEXTURE_MIN_FILTER: + case GL_TEXTURE_MAG_FILTER: + case GL_TEXTURE_WRAP_S: + case GL_TEXTURE_WRAP_T: + case GL_TEXTURE_WRAP_R: + case GL_TEXTURE_BASE_LEVEL: + case GL_TEXTURE_MAX_LEVEL: + case GL_GENERATE_MIPMAP_SGIS: + case GL_TEXTURE_COMPARE_MODE_ARB: + case GL_TEXTURE_COMPARE_FUNC_ARB: + case GL_DEPTH_TEXTURE_MODE_ARB: + case GL_TEXTURE_SRGB_DECODE_EXT: + case GL_TEXTURE_CUBE_MAP_SEAMLESS: + { + /* convert float param to int */ + GLint p[4]; + p[0] = (GLint) param; + p[1] = p[2] = p[3] = 0; + need_update = set_tex_parameteri(ctx, texObj, pname, p); + } + break; + default: + { + /* this will generate an error if pname is illegal */ + GLfloat p[4]; + p[0] = param; + p[1] = p[2] = p[3] = 0.0F; + need_update = set_tex_parameterf(ctx, texObj, pname, p); + } + } + + if (ctx->Driver.TexParameter && need_update) { + ctx->Driver.TexParameter(ctx, target, texObj, pname, ¶m); + } +} + + +void GLAPIENTRY +_mesa_TexParameterfv(GLenum target, GLenum pname, const GLfloat *params) +{ + GLboolean need_update; + struct gl_texture_object *texObj; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + texObj = get_texobj(ctx, target, GL_FALSE); + if (!texObj) + return; + + switch (pname) { + case GL_TEXTURE_MIN_FILTER: + case GL_TEXTURE_MAG_FILTER: + case GL_TEXTURE_WRAP_S: + case GL_TEXTURE_WRAP_T: + case GL_TEXTURE_WRAP_R: + case GL_TEXTURE_BASE_LEVEL: + case GL_TEXTURE_MAX_LEVEL: + case GL_GENERATE_MIPMAP_SGIS: + case GL_TEXTURE_COMPARE_MODE_ARB: + case GL_TEXTURE_COMPARE_FUNC_ARB: + case GL_DEPTH_TEXTURE_MODE_ARB: + case GL_TEXTURE_SRGB_DECODE_EXT: + case GL_TEXTURE_CUBE_MAP_SEAMLESS: + { + /* convert float param to int */ + GLint p[4]; + p[0] = (GLint) params[0]; + p[1] = p[2] = p[3] = 0; + need_update = set_tex_parameteri(ctx, texObj, pname, p); + } + break; + +#if FEATURE_OES_draw_texture + case GL_TEXTURE_CROP_RECT_OES: + { + /* convert float params to int */ + GLint iparams[4]; + iparams[0] = (GLint) params[0]; + iparams[1] = (GLint) params[1]; + iparams[2] = (GLint) params[2]; + iparams[3] = (GLint) params[3]; + need_update = set_tex_parameteri(ctx, texObj, pname, iparams); + } + break; +#endif + + default: + /* this will generate an error if pname is illegal */ + need_update = set_tex_parameterf(ctx, texObj, pname, params); + } + + if (ctx->Driver.TexParameter && need_update) { + ctx->Driver.TexParameter(ctx, target, texObj, pname, params); + } +} + + +void GLAPIENTRY +_mesa_TexParameteri(GLenum target, GLenum pname, GLint param) +{ + GLboolean need_update; + struct gl_texture_object *texObj; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + texObj = get_texobj(ctx, target, GL_FALSE); + if (!texObj) + return; + + switch (pname) { + case GL_TEXTURE_MIN_LOD: + case GL_TEXTURE_MAX_LOD: + case GL_TEXTURE_PRIORITY: + case GL_TEXTURE_MAX_ANISOTROPY_EXT: + case GL_TEXTURE_LOD_BIAS: + case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB: + { + GLfloat fparam[4]; + fparam[0] = (GLfloat) param; + fparam[1] = fparam[2] = fparam[3] = 0.0F; + /* convert int param to float */ + need_update = set_tex_parameterf(ctx, texObj, pname, fparam); + } + break; + default: + /* this will generate an error if pname is illegal */ + { + GLint iparam[4]; + iparam[0] = param; + iparam[1] = iparam[2] = iparam[3] = 0; + need_update = set_tex_parameteri(ctx, texObj, pname, iparam); + } + } + + if (ctx->Driver.TexParameter && need_update) { + GLfloat fparam = (GLfloat) param; + ctx->Driver.TexParameter(ctx, target, texObj, pname, &fparam); + } +} + + +void GLAPIENTRY +_mesa_TexParameteriv(GLenum target, GLenum pname, const GLint *params) +{ + GLboolean need_update; + struct gl_texture_object *texObj; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + texObj = get_texobj(ctx, target, GL_FALSE); + if (!texObj) + return; + + switch (pname) { + case GL_TEXTURE_BORDER_COLOR: + { + /* convert int params to float */ + GLfloat fparams[4]; + fparams[0] = INT_TO_FLOAT(params[0]); + fparams[1] = INT_TO_FLOAT(params[1]); + fparams[2] = INT_TO_FLOAT(params[2]); + fparams[3] = INT_TO_FLOAT(params[3]); + need_update = set_tex_parameterf(ctx, texObj, pname, fparams); + } + break; + case GL_TEXTURE_MIN_LOD: + case GL_TEXTURE_MAX_LOD: + case GL_TEXTURE_PRIORITY: + case GL_TEXTURE_MAX_ANISOTROPY_EXT: + case GL_TEXTURE_LOD_BIAS: + case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB: + { + /* convert int param to float */ + GLfloat fparams[4]; + fparams[0] = (GLfloat) params[0]; + fparams[1] = fparams[2] = fparams[3] = 0.0F; + need_update = set_tex_parameterf(ctx, texObj, pname, fparams); + } + break; + default: + /* this will generate an error if pname is illegal */ + need_update = set_tex_parameteri(ctx, texObj, pname, params); + } + + if (ctx->Driver.TexParameter && need_update) { + GLfloat fparams[4]; + fparams[0] = INT_TO_FLOAT(params[0]); + if (pname == GL_TEXTURE_BORDER_COLOR || + pname == GL_TEXTURE_CROP_RECT_OES) { + fparams[1] = INT_TO_FLOAT(params[1]); + fparams[2] = INT_TO_FLOAT(params[2]); + fparams[3] = INT_TO_FLOAT(params[3]); + } + ctx->Driver.TexParameter(ctx, target, texObj, pname, fparams); + } +} + + +/** + * Set tex parameter to integer value(s). Primarily intended to set + * integer-valued texture border color (for integer-valued textures). + * New in GL 3.0. + */ +void GLAPIENTRY +_mesa_TexParameterIiv(GLenum target, GLenum pname, const GLint *params) +{ + struct gl_texture_object *texObj; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + texObj = get_texobj(ctx, target, GL_FALSE); + if (!texObj) + return; + + switch (pname) { + case GL_TEXTURE_BORDER_COLOR: + FLUSH_VERTICES(ctx, _NEW_TEXTURE); + /* set the integer-valued border color */ + COPY_4V(texObj->Sampler.BorderColor.i, params); + break; + default: + _mesa_TexParameteriv(target, pname, params); + break; + } + /* XXX no driver hook for TexParameterIiv() yet */ +} + + +/** + * Set tex parameter to unsigned integer value(s). Primarily intended to set + * uint-valued texture border color (for integer-valued textures). + * New in GL 3.0 + */ +void GLAPIENTRY +_mesa_TexParameterIuiv(GLenum target, GLenum pname, const GLuint *params) +{ + struct gl_texture_object *texObj; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + texObj = get_texobj(ctx, target, GL_FALSE); + if (!texObj) + return; + + switch (pname) { + case GL_TEXTURE_BORDER_COLOR: + FLUSH_VERTICES(ctx, _NEW_TEXTURE); + /* set the unsigned integer-valued border color */ + COPY_4V(texObj->Sampler.BorderColor.ui, params); + break; + default: + _mesa_TexParameteriv(target, pname, (const GLint *) params); + break; + } + /* XXX no driver hook for TexParameterIuiv() yet */ +} + + + + +void GLAPIENTRY +_mesa_GetTexLevelParameterfv( GLenum target, GLint level, + GLenum pname, GLfloat *params ) +{ + GLint iparam; + _mesa_GetTexLevelParameteriv( target, level, pname, &iparam ); + *params = (GLfloat) iparam; +} + + +void GLAPIENTRY +_mesa_GetTexLevelParameteriv( GLenum target, GLint level, + GLenum pname, GLint *params ) +{ + const struct gl_texture_unit *texUnit; + struct gl_texture_object *texObj; + const struct gl_texture_image *img = NULL; + GLint maxLevels; + gl_format texFormat; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (ctx->Texture.CurrentUnit >= ctx->Const.MaxCombinedTextureImageUnits) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glGetTexLevelParameteriv(current unit)"); + return; + } + + texUnit = _mesa_get_current_tex_unit(ctx); + + /* this will catch bad target values */ + maxLevels = _mesa_max_texture_levels(ctx, target); + if (maxLevels == 0) { + _mesa_error(ctx, GL_INVALID_ENUM, + "glGetTexLevelParameter[if]v(target=0x%x)", target); + return; + } + + if (level < 0 || level >= maxLevels) { + _mesa_error( ctx, GL_INVALID_VALUE, "glGetTexLevelParameter[if]v" ); + return; + } + + texObj = _mesa_select_tex_object(ctx, texUnit, target); + + img = _mesa_select_tex_image(ctx, texObj, target, level); + if (!img || img->TexFormat == MESA_FORMAT_NONE) { + /* undefined texture image */ + if (pname == GL_TEXTURE_COMPONENTS) + *params = 1; + else + *params = 0; + return; + } + + texFormat = img->TexFormat; + + switch (pname) { + case GL_TEXTURE_WIDTH: + *params = img->Width; + break; + case GL_TEXTURE_HEIGHT: + *params = img->Height; + break; + case GL_TEXTURE_DEPTH: + *params = img->Depth; + break; + case GL_TEXTURE_INTERNAL_FORMAT: + if (_mesa_is_format_compressed(texFormat)) { + /* need to return the actual compressed format */ + *params = _mesa_compressed_format_to_glenum(ctx, texFormat); + } + else { + /* If the true internal format is not compressed but the user + * requested a generic compressed format, we have to return the + * generic base format that matches. + * + * From page 119 (page 129 of the PDF) of the OpenGL 1.3 spec: + * + * "If no specific compressed format is available, + * internalformat is instead replaced by the corresponding base + * internal format." + * + * Otherwise just return the user's requested internal format + */ + const GLenum f = + _mesa_gl_compressed_format_base_format(img->InternalFormat); + + *params = (f != 0) ? f : img->InternalFormat; + } + break; + case GL_TEXTURE_BORDER: + *params = img->Border; + break; + case GL_TEXTURE_RED_SIZE: + if (img->_BaseFormat == GL_RED) { + *params = _mesa_get_format_bits(texFormat, pname); + break; + } + /* FALLTHROUGH */ + case GL_TEXTURE_GREEN_SIZE: + if (img->_BaseFormat == GL_RG) { + *params = _mesa_get_format_bits(texFormat, pname); + break; + } + /* FALLTHROUGH */ + case GL_TEXTURE_BLUE_SIZE: + if (img->_BaseFormat == GL_RGB || img->_BaseFormat == GL_RGBA) + *params = _mesa_get_format_bits(texFormat, pname); + else + *params = 0; + break; + case GL_TEXTURE_ALPHA_SIZE: + if (img->_BaseFormat == GL_ALPHA || + img->_BaseFormat == GL_LUMINANCE_ALPHA || + img->_BaseFormat == GL_RGBA) + *params = _mesa_get_format_bits(texFormat, pname); + else + *params = 0; + break; + case GL_TEXTURE_INTENSITY_SIZE: + if (img->_BaseFormat != GL_INTENSITY) + *params = 0; + else { + *params = _mesa_get_format_bits(texFormat, pname); + if (*params == 0) { + /* intensity probably stored as rgb texture */ + *params = MIN2(_mesa_get_format_bits(texFormat, GL_TEXTURE_RED_SIZE), + _mesa_get_format_bits(texFormat, GL_TEXTURE_GREEN_SIZE)); + } + } + break; + case GL_TEXTURE_LUMINANCE_SIZE: + if (img->_BaseFormat != GL_LUMINANCE && + img->_BaseFormat != GL_LUMINANCE_ALPHA) + *params = 0; + else { + *params = _mesa_get_format_bits(texFormat, pname); + if (*params == 0) { + /* luminance probably stored as rgb texture */ + *params = MIN2(_mesa_get_format_bits(texFormat, GL_TEXTURE_RED_SIZE), + _mesa_get_format_bits(texFormat, GL_TEXTURE_GREEN_SIZE)); + } + } + break; + case GL_TEXTURE_DEPTH_SIZE_ARB: + if (!ctx->Extensions.ARB_depth_texture) + goto invalid_pname; + *params = _mesa_get_format_bits(texFormat, pname); + break; + case GL_TEXTURE_STENCIL_SIZE_EXT: + if (!ctx->Extensions.EXT_packed_depth_stencil && + !ctx->Extensions.ARB_framebuffer_object) + goto invalid_pname; + *params = _mesa_get_format_bits(texFormat, pname); + break; + case GL_TEXTURE_SHARED_SIZE: + if (ctx->VersionMajor < 3 && + !ctx->Extensions.EXT_texture_shared_exponent) + goto invalid_pname; + *params = texFormat == MESA_FORMAT_RGB9_E5_FLOAT ? 5 : 0; + break; + + /* GL_ARB_texture_compression */ + case GL_TEXTURE_COMPRESSED_IMAGE_SIZE: + if (_mesa_is_format_compressed(texFormat) && + !_mesa_is_proxy_texture(target)) { + *params = _mesa_format_image_size(texFormat, img->Width, + img->Height, img->Depth); + } + else { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glGetTexLevelParameter[if]v(pname)"); + } + break; + case GL_TEXTURE_COMPRESSED: + *params = (GLint) _mesa_is_format_compressed(texFormat); + break; + + /* GL_ARB_texture_float */ + case GL_TEXTURE_RED_TYPE_ARB: + if (!ctx->Extensions.ARB_texture_float) + goto invalid_pname; + *params = _mesa_get_format_bits(texFormat, GL_TEXTURE_RED_SIZE) ? + _mesa_get_format_datatype(texFormat) : GL_NONE; + break; + case GL_TEXTURE_GREEN_TYPE_ARB: + if (!ctx->Extensions.ARB_texture_float) + goto invalid_pname; + *params = _mesa_get_format_bits(texFormat, GL_TEXTURE_GREEN_SIZE) ? + _mesa_get_format_datatype(texFormat) : GL_NONE; + break; + case GL_TEXTURE_BLUE_TYPE_ARB: + if (!ctx->Extensions.ARB_texture_float) + goto invalid_pname; + *params = _mesa_get_format_bits(texFormat, GL_TEXTURE_BLUE_SIZE) ? + _mesa_get_format_datatype(texFormat) : GL_NONE; + break; + case GL_TEXTURE_ALPHA_TYPE_ARB: + if (!ctx->Extensions.ARB_texture_float) + goto invalid_pname; + *params = _mesa_get_format_bits(texFormat, GL_TEXTURE_ALPHA_SIZE) ? + _mesa_get_format_datatype(texFormat) : GL_NONE; + break; + case GL_TEXTURE_LUMINANCE_TYPE_ARB: + if (!ctx->Extensions.ARB_texture_float) + goto invalid_pname; + *params = _mesa_get_format_bits(texFormat, GL_TEXTURE_LUMINANCE_SIZE) ? + _mesa_get_format_datatype(texFormat) : GL_NONE; + break; + case GL_TEXTURE_INTENSITY_TYPE_ARB: + if (!ctx->Extensions.ARB_texture_float) + goto invalid_pname; + *params = _mesa_get_format_bits(texFormat, GL_TEXTURE_INTENSITY_SIZE) ? + _mesa_get_format_datatype(texFormat) : GL_NONE; + break; + case GL_TEXTURE_DEPTH_TYPE_ARB: + if (!ctx->Extensions.ARB_texture_float) + goto invalid_pname; + *params = _mesa_get_format_bits(texFormat, GL_TEXTURE_DEPTH_SIZE) ? + _mesa_get_format_datatype(texFormat) : GL_NONE; + break; + + default: + goto invalid_pname; + } + + /* no error if we get here */ + return; + +invalid_pname: + _mesa_error(ctx, GL_INVALID_ENUM, + "glGetTexLevelParameter[if]v(pname=%s)", + _mesa_lookup_enum_by_nr(pname)); +} + + + +void GLAPIENTRY +_mesa_GetTexParameterfv( GLenum target, GLenum pname, GLfloat *params ) +{ + struct gl_texture_object *obj; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + obj = get_texobj(ctx, target, GL_TRUE); + if (!obj) + return; + + _mesa_lock_texture(ctx, obj); + switch (pname) { + case GL_TEXTURE_MAG_FILTER: + *params = ENUM_TO_FLOAT(obj->Sampler.MagFilter); + break; + case GL_TEXTURE_MIN_FILTER: + *params = ENUM_TO_FLOAT(obj->Sampler.MinFilter); + break; + case GL_TEXTURE_WRAP_S: + *params = ENUM_TO_FLOAT(obj->Sampler.WrapS); + break; + case GL_TEXTURE_WRAP_T: + *params = ENUM_TO_FLOAT(obj->Sampler.WrapT); + break; + case GL_TEXTURE_WRAP_R: + *params = ENUM_TO_FLOAT(obj->Sampler.WrapR); + break; + case GL_TEXTURE_BORDER_COLOR: + if (ctx->NewState & (_NEW_BUFFERS | _NEW_FRAG_CLAMP)) + _mesa_update_state_locked(ctx); + if (ctx->Color._ClampFragmentColor) { + params[0] = CLAMP(obj->Sampler.BorderColor.f[0], 0.0F, 1.0F); + params[1] = CLAMP(obj->Sampler.BorderColor.f[1], 0.0F, 1.0F); + params[2] = CLAMP(obj->Sampler.BorderColor.f[2], 0.0F, 1.0F); + params[3] = CLAMP(obj->Sampler.BorderColor.f[3], 0.0F, 1.0F); + } + else { + params[0] = obj->Sampler.BorderColor.f[0]; + params[1] = obj->Sampler.BorderColor.f[1]; + params[2] = obj->Sampler.BorderColor.f[2]; + params[3] = obj->Sampler.BorderColor.f[3]; + } + break; + case GL_TEXTURE_RESIDENT: + *params = ctx->Driver.IsTextureResident ? + ctx->Driver.IsTextureResident(ctx, obj) : 1.0F; + break; + case GL_TEXTURE_PRIORITY: + *params = obj->Priority; + break; + case GL_TEXTURE_MIN_LOD: + *params = obj->Sampler.MinLod; + break; + case GL_TEXTURE_MAX_LOD: + *params = obj->Sampler.MaxLod; + break; + case GL_TEXTURE_BASE_LEVEL: + *params = (GLfloat) obj->BaseLevel; + break; + case GL_TEXTURE_MAX_LEVEL: + *params = (GLfloat) obj->MaxLevel; + break; + case GL_TEXTURE_MAX_ANISOTROPY_EXT: + if (!ctx->Extensions.EXT_texture_filter_anisotropic) + goto invalid_pname; + *params = obj->Sampler.MaxAnisotropy; + break; + case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB: + if (!ctx->Extensions.ARB_shadow_ambient) + goto invalid_pname; + *params = obj->Sampler.CompareFailValue; + break; + case GL_GENERATE_MIPMAP_SGIS: + *params = (GLfloat) obj->GenerateMipmap; + break; + case GL_TEXTURE_COMPARE_MODE_ARB: + if (!ctx->Extensions.ARB_shadow) + goto invalid_pname; + *params = (GLfloat) obj->Sampler.CompareMode; + break; + case GL_TEXTURE_COMPARE_FUNC_ARB: + if (!ctx->Extensions.ARB_shadow) + goto invalid_pname; + *params = (GLfloat) obj->Sampler.CompareFunc; + break; + case GL_DEPTH_TEXTURE_MODE_ARB: + if (!ctx->Extensions.ARB_depth_texture) + goto invalid_pname; + *params = (GLfloat) obj->Sampler.DepthMode; + break; + case GL_TEXTURE_LOD_BIAS: + if (!ctx->Extensions.EXT_texture_lod_bias) + goto invalid_pname; + *params = obj->Sampler.LodBias; + break; +#if FEATURE_OES_draw_texture + case GL_TEXTURE_CROP_RECT_OES: + params[0] = obj->CropRect[0]; + params[1] = obj->CropRect[1]; + params[2] = obj->CropRect[2]; + params[3] = obj->CropRect[3]; + break; +#endif + + case GL_TEXTURE_SWIZZLE_R_EXT: + case GL_TEXTURE_SWIZZLE_G_EXT: + case GL_TEXTURE_SWIZZLE_B_EXT: + case GL_TEXTURE_SWIZZLE_A_EXT: + if (!ctx->Extensions.EXT_texture_swizzle) + goto invalid_pname; + *params = (GLfloat) obj->Swizzle[pname - GL_TEXTURE_SWIZZLE_R_EXT]; + break; + + case GL_TEXTURE_SWIZZLE_RGBA_EXT: + if (!ctx->Extensions.EXT_texture_swizzle) { + goto invalid_pname; + } + else { + GLuint comp; + for (comp = 0; comp < 4; comp++) { + params[comp] = (GLfloat) obj->Swizzle[comp]; + } + } + break; + + case GL_TEXTURE_CUBE_MAP_SEAMLESS: + if (!ctx->Extensions.AMD_seamless_cubemap_per_texture) + goto invalid_pname; + *params = (GLfloat) obj->Sampler.CubeMapSeamless; + break; + + default: + goto invalid_pname; + } + + /* no error if we get here */ + _mesa_unlock_texture(ctx, obj); + return; + +invalid_pname: + _mesa_unlock_texture(ctx, obj); + _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexParameterfv(pname=0x%x)", pname); +} + + +void GLAPIENTRY +_mesa_GetTexParameteriv( GLenum target, GLenum pname, GLint *params ) +{ + struct gl_texture_object *obj; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + obj = get_texobj(ctx, target, GL_TRUE); + if (!obj) + return; + + _mesa_lock_texture(ctx, obj); + switch (pname) { + case GL_TEXTURE_MAG_FILTER: + *params = (GLint) obj->Sampler.MagFilter; + break;; + case GL_TEXTURE_MIN_FILTER: + *params = (GLint) obj->Sampler.MinFilter; + break;; + case GL_TEXTURE_WRAP_S: + *params = (GLint) obj->Sampler.WrapS; + break;; + case GL_TEXTURE_WRAP_T: + *params = (GLint) obj->Sampler.WrapT; + break;; + case GL_TEXTURE_WRAP_R: + *params = (GLint) obj->Sampler.WrapR; + break;; + case GL_TEXTURE_BORDER_COLOR: + { + GLfloat b[4]; + b[0] = CLAMP(obj->Sampler.BorderColor.f[0], 0.0F, 1.0F); + b[1] = CLAMP(obj->Sampler.BorderColor.f[1], 0.0F, 1.0F); + b[2] = CLAMP(obj->Sampler.BorderColor.f[2], 0.0F, 1.0F); + b[3] = CLAMP(obj->Sampler.BorderColor.f[3], 0.0F, 1.0F); + params[0] = FLOAT_TO_INT(b[0]); + params[1] = FLOAT_TO_INT(b[1]); + params[2] = FLOAT_TO_INT(b[2]); + params[3] = FLOAT_TO_INT(b[3]); + } + break;; + case GL_TEXTURE_RESIDENT: + *params = ctx->Driver.IsTextureResident ? + ctx->Driver.IsTextureResident(ctx, obj) : 1; + break;; + case GL_TEXTURE_PRIORITY: + *params = FLOAT_TO_INT(obj->Priority); + break;; + case GL_TEXTURE_MIN_LOD: + *params = (GLint) obj->Sampler.MinLod; + break;; + case GL_TEXTURE_MAX_LOD: + *params = (GLint) obj->Sampler.MaxLod; + break;; + case GL_TEXTURE_BASE_LEVEL: + *params = obj->BaseLevel; + break;; + case GL_TEXTURE_MAX_LEVEL: + *params = obj->MaxLevel; + break;; + case GL_TEXTURE_MAX_ANISOTROPY_EXT: + if (!ctx->Extensions.EXT_texture_filter_anisotropic) + goto invalid_pname; + *params = (GLint) obj->Sampler.MaxAnisotropy; + break; + case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB: + if (!ctx->Extensions.ARB_shadow_ambient) + goto invalid_pname; + *params = (GLint) FLOAT_TO_INT(obj->Sampler.CompareFailValue); + break; + case GL_GENERATE_MIPMAP_SGIS: + *params = (GLint) obj->GenerateMipmap; + break; + case GL_TEXTURE_COMPARE_MODE_ARB: + if (!ctx->Extensions.ARB_shadow) + goto invalid_pname; + *params = (GLint) obj->Sampler.CompareMode; + break; + case GL_TEXTURE_COMPARE_FUNC_ARB: + if (!ctx->Extensions.ARB_shadow) + goto invalid_pname; + *params = (GLint) obj->Sampler.CompareFunc; + break; + case GL_DEPTH_TEXTURE_MODE_ARB: + if (!ctx->Extensions.ARB_depth_texture) + goto invalid_pname; + *params = (GLint) obj->Sampler.DepthMode; + break; + case GL_TEXTURE_LOD_BIAS: + if (!ctx->Extensions.EXT_texture_lod_bias) + goto invalid_pname; + *params = (GLint) obj->Sampler.LodBias; + break; +#if FEATURE_OES_draw_texture + case GL_TEXTURE_CROP_RECT_OES: + params[0] = obj->CropRect[0]; + params[1] = obj->CropRect[1]; + params[2] = obj->CropRect[2]; + params[3] = obj->CropRect[3]; + break; +#endif + case GL_TEXTURE_SWIZZLE_R_EXT: + case GL_TEXTURE_SWIZZLE_G_EXT: + case GL_TEXTURE_SWIZZLE_B_EXT: + case GL_TEXTURE_SWIZZLE_A_EXT: + if (!ctx->Extensions.EXT_texture_swizzle) + goto invalid_pname; + *params = obj->Swizzle[pname - GL_TEXTURE_SWIZZLE_R_EXT]; + break; + + case GL_TEXTURE_SWIZZLE_RGBA_EXT: + if (!ctx->Extensions.EXT_texture_swizzle) + goto invalid_pname; + COPY_4V(params, obj->Swizzle); + break; + + case GL_TEXTURE_CUBE_MAP_SEAMLESS: + if (!ctx->Extensions.AMD_seamless_cubemap_per_texture) + goto invalid_pname; + *params = (GLint) obj->Sampler.CubeMapSeamless; + break; + + default: + goto invalid_pname; + } + + /* no error if we get here */ + _mesa_unlock_texture(ctx, obj); + return; + +invalid_pname: + _mesa_unlock_texture(ctx, obj); + _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexParameteriv(pname=0x%x)", pname); +} + + +/** New in GL 3.0 */ +void GLAPIENTRY +_mesa_GetTexParameterIiv(GLenum target, GLenum pname, GLint *params) +{ + struct gl_texture_object *texObj; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + texObj = get_texobj(ctx, target, GL_TRUE); + if (!texObj) + return; + + switch (pname) { + case GL_TEXTURE_BORDER_COLOR: + COPY_4V(params, texObj->Sampler.BorderColor.i); + break; + default: + _mesa_GetTexParameteriv(target, pname, params); + } +} + + +/** New in GL 3.0 */ +void GLAPIENTRY +_mesa_GetTexParameterIuiv(GLenum target, GLenum pname, GLuint *params) +{ + struct gl_texture_object *texObj; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + texObj = get_texobj(ctx, target, GL_TRUE); + if (!texObj) + return; + + switch (pname) { + case GL_TEXTURE_BORDER_COLOR: + COPY_4V(params, texObj->Sampler.BorderColor.i); + break; + default: + { + GLint ip[4]; + _mesa_GetTexParameteriv(target, pname, ip); + params[0] = ip[0]; + if (pname == GL_TEXTURE_SWIZZLE_RGBA_EXT || + pname == GL_TEXTURE_CROP_RECT_OES) { + params[1] = ip[1]; + params[2] = ip[2]; + params[3] = ip[3]; + } + } + } +} diff --git a/mesalib/src/mesa/main/texstate.c b/mesalib/src/mesa/main/texstate.c index b4a119215..e02f16240 100644 --- a/mesalib/src/mesa/main/texstate.c +++ b/mesalib/src/mesa/main/texstate.c @@ -1,850 +1,850 @@ -/* - * Mesa 3-D graphics library - * Version: 7.5 - * - * 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. - */ - -/** - * \file texstate.c - * - * Texture state handling. - */ - -#include "glheader.h" -#include "mfeatures.h" -#include "bufferobj.h" -#include "colormac.h" -#include "colortab.h" -#include "context.h" -#include "enums.h" -#include "macros.h" -#include "texobj.h" -#include "teximage.h" -#include "texstate.h" -#include "mtypes.h" - - - -/** - * Default texture combine environment state. This is used to initialize - * a context's texture units and as the basis for converting "classic" - * texture environmnets to ARB_texture_env_combine style values. - */ -static const struct gl_tex_env_combine_state default_combine_state = { - GL_MODULATE, GL_MODULATE, - { GL_TEXTURE, GL_PREVIOUS, GL_CONSTANT, GL_CONSTANT }, - { GL_TEXTURE, GL_PREVIOUS, GL_CONSTANT, GL_CONSTANT }, - { GL_SRC_COLOR, GL_SRC_COLOR, GL_SRC_ALPHA, GL_SRC_ALPHA }, - { GL_SRC_ALPHA, GL_SRC_ALPHA, GL_SRC_ALPHA, GL_SRC_ALPHA }, - 0, 0, - 2, 2 -}; - - - -/** - * Used by glXCopyContext to copy texture state from one context to another. - */ -void -_mesa_copy_texture_state( const struct gl_context *src, struct gl_context *dst ) -{ - GLuint u, tex; - - ASSERT(src); - ASSERT(dst); - - dst->Texture.CurrentUnit = src->Texture.CurrentUnit; - dst->Texture._GenFlags = src->Texture._GenFlags; - dst->Texture._TexGenEnabled = src->Texture._TexGenEnabled; - dst->Texture._TexMatEnabled = src->Texture._TexMatEnabled; - - /* per-unit state */ - for (u = 0; u < src->Const.MaxCombinedTextureImageUnits; u++) { - dst->Texture.Unit[u].Enabled = src->Texture.Unit[u].Enabled; - dst->Texture.Unit[u].EnvMode = src->Texture.Unit[u].EnvMode; - COPY_4V(dst->Texture.Unit[u].EnvColor, src->Texture.Unit[u].EnvColor); - dst->Texture.Unit[u].TexGenEnabled = src->Texture.Unit[u].TexGenEnabled; - dst->Texture.Unit[u].GenS = src->Texture.Unit[u].GenS; - dst->Texture.Unit[u].GenT = src->Texture.Unit[u].GenT; - dst->Texture.Unit[u].GenR = src->Texture.Unit[u].GenR; - dst->Texture.Unit[u].GenQ = src->Texture.Unit[u].GenQ; - dst->Texture.Unit[u].LodBias = src->Texture.Unit[u].LodBias; - - /* GL_EXT_texture_env_combine */ - dst->Texture.Unit[u].Combine = src->Texture.Unit[u].Combine; - - /* GL_ATI_envmap_bumpmap - need this? */ - dst->Texture.Unit[u].BumpTarget = src->Texture.Unit[u].BumpTarget; - COPY_4V(dst->Texture.Unit[u].RotMatrix, src->Texture.Unit[u].RotMatrix); - - /* - * XXX strictly speaking, we should compare texture names/ids and - * bind textures in the dest context according to id. For now, only - * copy bindings if the contexts share the same pool of textures to - * avoid refcounting bugs. - */ - if (dst->Shared == src->Shared) { - /* copy texture object bindings, not contents of texture objects */ - _mesa_lock_context_textures(dst); - - for (tex = 0; tex < NUM_TEXTURE_TARGETS; tex++) { - _mesa_reference_texobj(&dst->Texture.Unit[u].CurrentTex[tex], - src->Texture.Unit[u].CurrentTex[tex]); - } - _mesa_unlock_context_textures(dst); - } - } -} - - -/* - * For debugging - */ -void -_mesa_print_texunit_state( struct gl_context *ctx, GLuint unit ) -{ - const struct gl_texture_unit *texUnit = ctx->Texture.Unit + unit; - printf("Texture Unit %d\n", unit); - printf(" GL_TEXTURE_ENV_MODE = %s\n", _mesa_lookup_enum_by_nr(texUnit->EnvMode)); - printf(" GL_COMBINE_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.ModeRGB)); - printf(" GL_COMBINE_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.ModeA)); - printf(" GL_SOURCE0_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.SourceRGB[0])); - printf(" GL_SOURCE1_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.SourceRGB[1])); - printf(" GL_SOURCE2_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.SourceRGB[2])); - printf(" GL_SOURCE0_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.SourceA[0])); - printf(" GL_SOURCE1_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.SourceA[1])); - printf(" GL_SOURCE2_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.SourceA[2])); - printf(" GL_OPERAND0_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.OperandRGB[0])); - printf(" GL_OPERAND1_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.OperandRGB[1])); - printf(" GL_OPERAND2_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.OperandRGB[2])); - printf(" GL_OPERAND0_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.OperandA[0])); - printf(" GL_OPERAND1_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.OperandA[1])); - printf(" GL_OPERAND2_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.OperandA[2])); - printf(" GL_RGB_SCALE = %d\n", 1 << texUnit->Combine.ScaleShiftRGB); - printf(" GL_ALPHA_SCALE = %d\n", 1 << texUnit->Combine.ScaleShiftA); - printf(" GL_TEXTURE_ENV_COLOR = (%f, %f, %f, %f)\n", texUnit->EnvColor[0], texUnit->EnvColor[1], texUnit->EnvColor[2], texUnit->EnvColor[3]); -} - - - -/**********************************************************************/ -/* Texture Environment */ -/**********************************************************************/ - -/** - * Convert "classic" texture environment to ARB_texture_env_combine style - * environments. - * - * \param state texture_env_combine state vector to be filled-in. - * \param mode Classic texture environment mode (i.e., \c GL_REPLACE, - * \c GL_BLEND, \c GL_DECAL, etc.). - * \param texBaseFormat Base format of the texture associated with the - * texture unit. - */ -static void -calculate_derived_texenv( struct gl_tex_env_combine_state *state, - GLenum mode, GLenum texBaseFormat ) -{ - GLenum mode_rgb; - GLenum mode_a; - - *state = default_combine_state; - - switch (texBaseFormat) { - case GL_ALPHA: - state->SourceRGB[0] = GL_PREVIOUS; - break; - - case GL_LUMINANCE_ALPHA: - case GL_INTENSITY: - case GL_RGBA: - break; - - case GL_LUMINANCE: - case GL_RED: - case GL_RG: - case GL_RGB: - case GL_YCBCR_MESA: - case GL_DUDV_ATI: - state->SourceA[0] = GL_PREVIOUS; - break; - - default: - _mesa_problem(NULL, - "Invalid texBaseFormat 0x%x in calculate_derived_texenv", - texBaseFormat); - return; - } - - if (mode == GL_REPLACE_EXT) - mode = GL_REPLACE; - - switch (mode) { - case GL_REPLACE: - case GL_MODULATE: - mode_rgb = (texBaseFormat == GL_ALPHA) ? GL_REPLACE : mode; - mode_a = mode; - break; - - case GL_DECAL: - mode_rgb = GL_INTERPOLATE; - mode_a = GL_REPLACE; - - state->SourceA[0] = GL_PREVIOUS; - - /* Having alpha / luminance / intensity textures replace using the - * incoming fragment color matches the definition in NV_texture_shader. - * The 1.5 spec simply marks these as "undefined". - */ - switch (texBaseFormat) { - case GL_ALPHA: - case GL_LUMINANCE: - case GL_LUMINANCE_ALPHA: - case GL_INTENSITY: - state->SourceRGB[0] = GL_PREVIOUS; - break; - case GL_RED: - case GL_RG: - case GL_RGB: - case GL_YCBCR_MESA: - case GL_DUDV_ATI: - mode_rgb = GL_REPLACE; - break; - case GL_RGBA: - state->SourceRGB[2] = GL_TEXTURE; - break; - } - break; - - case GL_BLEND: - mode_rgb = GL_INTERPOLATE; - mode_a = GL_MODULATE; - - switch (texBaseFormat) { - case GL_ALPHA: - mode_rgb = GL_REPLACE; - break; - case GL_INTENSITY: - mode_a = GL_INTERPOLATE; - state->SourceA[0] = GL_CONSTANT; - state->OperandA[2] = GL_SRC_ALPHA; - /* FALLTHROUGH */ - case GL_LUMINANCE: - case GL_RED: - case GL_RG: - case GL_RGB: - case GL_LUMINANCE_ALPHA: - case GL_RGBA: - case GL_YCBCR_MESA: - case GL_DUDV_ATI: - state->SourceRGB[2] = GL_TEXTURE; - state->SourceA[2] = GL_TEXTURE; - state->SourceRGB[0] = GL_CONSTANT; - state->OperandRGB[2] = GL_SRC_COLOR; - break; - } - break; - - case GL_ADD: - mode_rgb = (texBaseFormat == GL_ALPHA) ? GL_REPLACE : GL_ADD; - mode_a = (texBaseFormat == GL_INTENSITY) ? GL_ADD : GL_MODULATE; - break; - - default: - _mesa_problem(NULL, - "Invalid texture env mode 0x%x in calculate_derived_texenv", - mode); - return; - } - - state->ModeRGB = (state->SourceRGB[0] != GL_PREVIOUS) - ? mode_rgb : GL_REPLACE; - state->ModeA = (state->SourceA[0] != GL_PREVIOUS) - ? mode_a : GL_REPLACE; -} - - - - -/* GL_ARB_multitexture */ -void GLAPIENTRY -_mesa_ActiveTextureARB(GLenum texture) -{ - const GLuint texUnit = texture - GL_TEXTURE0; - GLuint k; - GET_CURRENT_CONTEXT(ctx); - - /* See OpenGL spec for glActiveTexture: */ - k = MAX2(ctx->Const.MaxCombinedTextureImageUnits, - ctx->Const.MaxTextureCoordUnits); - - ASSERT(k <= Elements(ctx->Texture.Unit)); - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE)) - _mesa_debug(ctx, "glActiveTexture %s\n", - _mesa_lookup_enum_by_nr(texture)); - - if (texUnit >= k) { - _mesa_error(ctx, GL_INVALID_ENUM, "glActiveTexture(texture=%s)", - _mesa_lookup_enum_by_nr(texture)); - return; - } - - if (ctx->Texture.CurrentUnit == texUnit) - return; - - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - - ctx->Texture.CurrentUnit = texUnit; - if (ctx->Transform.MatrixMode == GL_TEXTURE) { - /* update current stack pointer */ - ctx->CurrentStack = &ctx->TextureMatrixStack[texUnit]; - } -} - - -/* GL_ARB_multitexture */ -void GLAPIENTRY -_mesa_ClientActiveTextureARB(GLenum texture) -{ - GET_CURRENT_CONTEXT(ctx); - GLuint texUnit = texture - GL_TEXTURE0; - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE & (VERBOSE_API | VERBOSE_TEXTURE)) - _mesa_debug(ctx, "glClientActiveTexture %s\n", - _mesa_lookup_enum_by_nr(texture)); - - if (texUnit >= ctx->Const.MaxTextureCoordUnits) { - _mesa_error(ctx, GL_INVALID_ENUM, "glClientActiveTexture(texture)"); - return; - } - - if (ctx->Array.ActiveTexture == texUnit) - return; - - FLUSH_VERTICES(ctx, _NEW_ARRAY); - ctx->Array.ActiveTexture = texUnit; -} - - - -/**********************************************************************/ -/***** State management *****/ -/**********************************************************************/ - - -/** - * \note This routine refers to derived texture attribute values to - * compute the ENABLE_TEXMAT flags, but is only called on - * _NEW_TEXTURE_MATRIX. On changes to _NEW_TEXTURE, the ENABLE_TEXMAT - * flags are updated by _mesa_update_textures(), below. - * - * \param ctx GL context. - */ -static void -update_texture_matrices( struct gl_context *ctx ) -{ - GLuint u; - - ctx->Texture._TexMatEnabled = 0x0; - - for (u = 0; u < ctx->Const.MaxTextureCoordUnits; u++) { - ASSERT(u < Elements(ctx->TextureMatrixStack)); - if (_math_matrix_is_dirty(ctx->TextureMatrixStack[u].Top)) { - _math_matrix_analyse( ctx->TextureMatrixStack[u].Top ); - - if (ctx->Texture.Unit[u]._ReallyEnabled && - ctx->TextureMatrixStack[u].Top->type != MATRIX_IDENTITY) - ctx->Texture._TexMatEnabled |= ENABLE_TEXMAT(u); - } - } -} - - -/** - * Examine texture unit's combine/env state to update derived state. - */ -static void -update_tex_combine(struct gl_context *ctx, struct gl_texture_unit *texUnit) -{ - struct gl_tex_env_combine_state *combine; - - /* Set the texUnit->_CurrentCombine field to point to the user's combiner - * state, or the combiner state which is derived from traditional texenv - * mode. - */ - if (texUnit->EnvMode == GL_COMBINE || - texUnit->EnvMode == GL_COMBINE4_NV) { - texUnit->_CurrentCombine = & texUnit->Combine; - } - else { - const struct gl_texture_object *texObj = texUnit->_Current; - GLenum format = texObj->Image[0][texObj->BaseLevel]->_BaseFormat; - - if (format == GL_DEPTH_COMPONENT || format == GL_DEPTH_STENCIL_EXT) { - format = texObj->Sampler.DepthMode; - } - calculate_derived_texenv(&texUnit->_EnvMode, texUnit->EnvMode, format); - texUnit->_CurrentCombine = & texUnit->_EnvMode; - } - - combine = texUnit->_CurrentCombine; - - /* Determine number of source RGB terms in the combiner function */ - switch (combine->ModeRGB) { - case GL_REPLACE: - combine->_NumArgsRGB = 1; - break; - case GL_ADD: - case GL_ADD_SIGNED: - if (texUnit->EnvMode == GL_COMBINE4_NV) - combine->_NumArgsRGB = 4; - else - combine->_NumArgsRGB = 2; - break; - case GL_MODULATE: - case GL_SUBTRACT: - case GL_DOT3_RGB: - case GL_DOT3_RGBA: - case GL_DOT3_RGB_EXT: - case GL_DOT3_RGBA_EXT: - combine->_NumArgsRGB = 2; - break; - case GL_INTERPOLATE: - case GL_MODULATE_ADD_ATI: - case GL_MODULATE_SIGNED_ADD_ATI: - case GL_MODULATE_SUBTRACT_ATI: - combine->_NumArgsRGB = 3; - break; - case GL_BUMP_ENVMAP_ATI: - /* no real arguments for this case */ - combine->_NumArgsRGB = 0; - break; - default: - combine->_NumArgsRGB = 0; - _mesa_problem(ctx, "invalid RGB combine mode in update_texture_state"); - return; - } - - /* Determine number of source Alpha terms in the combiner function */ - switch (combine->ModeA) { - case GL_REPLACE: - combine->_NumArgsA = 1; - break; - case GL_ADD: - case GL_ADD_SIGNED: - if (texUnit->EnvMode == GL_COMBINE4_NV) - combine->_NumArgsA = 4; - else - combine->_NumArgsA = 2; - break; - case GL_MODULATE: - case GL_SUBTRACT: - combine->_NumArgsA = 2; - break; - case GL_INTERPOLATE: - case GL_MODULATE_ADD_ATI: - case GL_MODULATE_SIGNED_ADD_ATI: - case GL_MODULATE_SUBTRACT_ATI: - combine->_NumArgsA = 3; - break; - default: - combine->_NumArgsA = 0; - _mesa_problem(ctx, "invalid Alpha combine mode in update_texture_state"); - break; - } -} - - -/** - * \note This routine refers to derived texture matrix values to - * compute the ENABLE_TEXMAT flags, but is only called on - * _NEW_TEXTURE. On changes to _NEW_TEXTURE_MATRIX, the ENABLE_TEXMAT - * flags are updated by _mesa_update_texture_matrices, above. - * - * \param ctx GL context. - */ -static void -update_texture_state( struct gl_context *ctx ) -{ - GLuint unit; - struct gl_fragment_program *fprog = NULL; - struct gl_vertex_program *vprog = NULL; - GLbitfield enabledFragUnits = 0x0; - - if (ctx->Shader.CurrentVertexProgram && - ctx->Shader.CurrentVertexProgram->LinkStatus) { - vprog = ctx->Shader.CurrentVertexProgram->VertexProgram; - } else if (ctx->VertexProgram._Enabled) { - /* XXX enable this if/when non-shader vertex programs get - * texture fetches: - vprog = ctx->VertexProgram.Current; - */ - } - - if (ctx->Shader.CurrentFragmentProgram && - ctx->Shader.CurrentFragmentProgram->LinkStatus) { - fprog = ctx->Shader.CurrentFragmentProgram->FragmentProgram; - } - else if (ctx->FragmentProgram._Enabled) { - fprog = ctx->FragmentProgram.Current; - } - - /* FINISHME: Geometry shader texture accesses should also be considered - * FINISHME: here. - */ - - /* TODO: only set this if there are actual changes */ - ctx->NewState |= _NEW_TEXTURE; - - ctx->Texture._EnabledUnits = 0x0; - ctx->Texture._GenFlags = 0x0; - ctx->Texture._TexMatEnabled = 0x0; - ctx->Texture._TexGenEnabled = 0x0; - - /* - * Update texture unit state. - */ - for (unit = 0; unit < ctx->Const.MaxCombinedTextureImageUnits; unit++) { - struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; - GLbitfield enabledVertTargets = 0x0; - GLbitfield enabledFragTargets = 0x0; - GLbitfield enabledTargets = 0x0; - GLuint texIndex; - - /* Get the bitmask of texture target enables. - * enableBits will be a mask of the TEXTURE_*_BIT flags indicating - * which texture targets are enabled (fixed function) or referenced - * by a fragment program/program. When multiple flags are set, we'll - * settle on the one with highest priority (see below). - */ - if (vprog) { - enabledVertTargets |= vprog->Base.TexturesUsed[unit]; - } - - if (fprog) { - enabledFragTargets |= fprog->Base.TexturesUsed[unit]; - } - else { - /* fixed-function fragment program */ - enabledFragTargets |= texUnit->Enabled; - } - - enabledTargets = enabledVertTargets | enabledFragTargets; - - texUnit->_ReallyEnabled = 0x0; - - if (enabledTargets == 0x0) { - /* neither vertex nor fragment processing uses this unit */ - continue; - } - - /* Look for the highest priority texture target that's enabled (or used - * by the vert/frag shaders) and "complete". That's the one we'll use - * for texturing. If we're using vert/frag program we're guaranteed - * that bitcount(enabledBits) <= 1. - * Note that the TEXTURE_x_INDEX values are in high to low priority. - */ - for (texIndex = 0; texIndex < NUM_TEXTURE_TARGETS; texIndex++) { - if (enabledTargets & (1 << texIndex)) { - struct gl_texture_object *texObj = texUnit->CurrentTex[texIndex]; - if (!texObj->_Complete) { - _mesa_test_texobj_completeness(ctx, texObj); - } - if (texObj->_Complete) { - texUnit->_ReallyEnabled = 1 << texIndex; - _mesa_reference_texobj(&texUnit->_Current, texObj); - break; - } - } - } - - if (!texUnit->_ReallyEnabled) { - if (fprog) { - /* If we get here it means the shader is expecting a texture - * object, but there isn't one (or it's incomplete). Use the - * fallback texture. - */ - struct gl_texture_object *texObj = _mesa_get_fallback_texture(ctx); - texUnit->_ReallyEnabled = 1 << TEXTURE_2D_INDEX; - _mesa_reference_texobj(&texUnit->_Current, texObj); - } - else { - /* fixed-function: texture unit is really disabled */ - continue; - } - } - - /* if we get here, we know this texture unit is enabled */ - - ctx->Texture._EnabledUnits |= (1 << unit); - - if (enabledFragTargets) - enabledFragUnits |= (1 << unit); - - update_tex_combine(ctx, texUnit); - } - - - /* Determine which texture coordinate sets are actually needed */ - if (fprog) { - const GLuint coordMask = (1 << MAX_TEXTURE_COORD_UNITS) - 1; - ctx->Texture._EnabledCoordUnits - = (fprog->Base.InputsRead >> FRAG_ATTRIB_TEX0) & coordMask; - } - else { - ctx->Texture._EnabledCoordUnits = enabledFragUnits; - } - - /* Setup texgen for those texture coordinate sets that are in use */ - for (unit = 0; unit < ctx->Const.MaxTextureCoordUnits; unit++) { - struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; - - texUnit->_GenFlags = 0x0; - - if (!(ctx->Texture._EnabledCoordUnits & (1 << unit))) - continue; - - if (texUnit->TexGenEnabled) { - if (texUnit->TexGenEnabled & S_BIT) { - texUnit->_GenFlags |= texUnit->GenS._ModeBit; - } - if (texUnit->TexGenEnabled & T_BIT) { - texUnit->_GenFlags |= texUnit->GenT._ModeBit; - } - if (texUnit->TexGenEnabled & R_BIT) { - texUnit->_GenFlags |= texUnit->GenR._ModeBit; - } - if (texUnit->TexGenEnabled & Q_BIT) { - texUnit->_GenFlags |= texUnit->GenQ._ModeBit; - } - - ctx->Texture._TexGenEnabled |= ENABLE_TEXGEN(unit); - ctx->Texture._GenFlags |= texUnit->_GenFlags; - } - - ASSERT(unit < Elements(ctx->TextureMatrixStack)); - if (ctx->TextureMatrixStack[unit].Top->type != MATRIX_IDENTITY) - ctx->Texture._TexMatEnabled |= ENABLE_TEXMAT(unit); - } -} - - -/** - * Update texture-related derived state. - */ -void -_mesa_update_texture( struct gl_context *ctx, GLuint new_state ) -{ - if (new_state & _NEW_TEXTURE_MATRIX) - update_texture_matrices( ctx ); - - if (new_state & (_NEW_TEXTURE | _NEW_PROGRAM)) - update_texture_state( ctx ); -} - - -/**********************************************************************/ -/***** Initialization *****/ -/**********************************************************************/ - -/** - * Allocate the proxy textures for the given context. - * - * \param ctx the context to allocate proxies for. - * - * \return GL_TRUE on success, or GL_FALSE on failure - * - * If run out of memory part way through the allocations, clean up and return - * GL_FALSE. - */ -static GLboolean -alloc_proxy_textures( struct gl_context *ctx ) -{ - static const GLenum targets[] = { - GL_TEXTURE_1D, - GL_TEXTURE_2D, - GL_TEXTURE_3D, - GL_TEXTURE_CUBE_MAP_ARB, - GL_TEXTURE_RECTANGLE_NV, - GL_TEXTURE_1D_ARRAY_EXT, - GL_TEXTURE_2D_ARRAY_EXT, - GL_TEXTURE_BUFFER - }; - GLint tgt; - - ASSERT(Elements(targets) == NUM_TEXTURE_TARGETS); - - for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++) { - if (!(ctx->Texture.ProxyTex[tgt] - = ctx->Driver.NewTextureObject(ctx, 0, targets[tgt]))) { - /* out of memory, free what we did allocate */ - while (--tgt >= 0) { - ctx->Driver.DeleteTexture(ctx, ctx->Texture.ProxyTex[tgt]); - } - return GL_FALSE; - } - } - - assert(ctx->Texture.ProxyTex[0]->RefCount == 1); /* sanity check */ - return GL_TRUE; -} - - -/** - * Initialize a texture unit. - * - * \param ctx GL context. - * \param unit texture unit number to be initialized. - */ -static void -init_texture_unit( struct gl_context *ctx, GLuint unit ) -{ - struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; - GLuint tex; - - texUnit->EnvMode = GL_MODULATE; - ASSIGN_4V( texUnit->EnvColor, 0.0, 0.0, 0.0, 0.0 ); - - texUnit->Combine = default_combine_state; - texUnit->_EnvMode = default_combine_state; - texUnit->_CurrentCombine = & texUnit->_EnvMode; - texUnit->BumpTarget = GL_TEXTURE0; - - texUnit->TexGenEnabled = 0x0; - texUnit->GenS.Mode = GL_EYE_LINEAR; - texUnit->GenT.Mode = GL_EYE_LINEAR; - texUnit->GenR.Mode = GL_EYE_LINEAR; - texUnit->GenQ.Mode = GL_EYE_LINEAR; - texUnit->GenS._ModeBit = TEXGEN_EYE_LINEAR; - texUnit->GenT._ModeBit = TEXGEN_EYE_LINEAR; - texUnit->GenR._ModeBit = TEXGEN_EYE_LINEAR; - texUnit->GenQ._ModeBit = TEXGEN_EYE_LINEAR; - - /* Yes, these plane coefficients are correct! */ - ASSIGN_4V( texUnit->GenS.ObjectPlane, 1.0, 0.0, 0.0, 0.0 ); - ASSIGN_4V( texUnit->GenT.ObjectPlane, 0.0, 1.0, 0.0, 0.0 ); - ASSIGN_4V( texUnit->GenR.ObjectPlane, 0.0, 0.0, 0.0, 0.0 ); - ASSIGN_4V( texUnit->GenQ.ObjectPlane, 0.0, 0.0, 0.0, 0.0 ); - ASSIGN_4V( texUnit->GenS.EyePlane, 1.0, 0.0, 0.0, 0.0 ); - ASSIGN_4V( texUnit->GenT.EyePlane, 0.0, 1.0, 0.0, 0.0 ); - ASSIGN_4V( texUnit->GenR.EyePlane, 0.0, 0.0, 0.0, 0.0 ); - ASSIGN_4V( texUnit->GenQ.EyePlane, 0.0, 0.0, 0.0, 0.0 ); - - /* no mention of this in spec, but maybe id matrix expected? */ - ASSIGN_4V( texUnit->RotMatrix, 1.0, 0.0, 0.0, 1.0 ); - - /* initialize current texture object ptrs to the shared default objects */ - for (tex = 0; tex < NUM_TEXTURE_TARGETS; tex++) { - _mesa_reference_texobj(&texUnit->CurrentTex[tex], - ctx->Shared->DefaultTex[tex]); - } -} - - -/** - * Initialize texture state for the given context. - */ -GLboolean -_mesa_init_texture(struct gl_context *ctx) -{ - GLuint u; - - /* Texture group */ - ctx->Texture.CurrentUnit = 0; /* multitexture */ - ctx->Texture._EnabledUnits = 0x0; - - for (u = 0; u < Elements(ctx->Texture.Unit); u++) - init_texture_unit(ctx, u); - - /* After we're done initializing the context's texture state the default - * texture objects' refcounts should be at least - * MAX_COMBINED_TEXTURE_IMAGE_UNITS + 1. - */ - assert(ctx->Shared->DefaultTex[TEXTURE_1D_INDEX]->RefCount - >= MAX_COMBINED_TEXTURE_IMAGE_UNITS + 1); - - /* Allocate proxy textures */ - if (!alloc_proxy_textures( ctx )) - return GL_FALSE; - - /* GL_ARB_texture_buffer_object */ - _mesa_reference_buffer_object(ctx, &ctx->Texture.BufferObject, - ctx->Shared->NullBufferObj); - - return GL_TRUE; -} - - -/** - * Free dynamically-allocted texture data attached to the given context. - */ -void -_mesa_free_texture_data(struct gl_context *ctx) -{ - GLuint u, tgt; - - /* unreference current textures */ - for (u = 0; u < Elements(ctx->Texture.Unit); u++) { - /* The _Current texture could account for another reference */ - _mesa_reference_texobj(&ctx->Texture.Unit[u]._Current, NULL); - - for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++) { - _mesa_reference_texobj(&ctx->Texture.Unit[u].CurrentTex[tgt], NULL); - } - } - - /* Free proxy texture objects */ - for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++) - ctx->Driver.DeleteTexture(ctx, ctx->Texture.ProxyTex[tgt]); - - /* GL_ARB_texture_buffer_object */ - _mesa_reference_buffer_object(ctx, &ctx->Texture.BufferObject, NULL); - -#if FEATURE_sampler_objects - for (u = 0; u < Elements(ctx->Texture.Unit); u++) { - _mesa_reference_sampler_object(ctx, &ctx->Texture.Unit[u].Sampler, NULL); - } -#endif -} - - -/** - * Update the default texture objects in the given context to reference those - * specified in the shared state and release those referencing the old - * shared state. - */ -void -_mesa_update_default_objects_texture(struct gl_context *ctx) -{ - GLuint u, tex; - - for (u = 0; u < Elements(ctx->Texture.Unit); u++) { - struct gl_texture_unit *texUnit = &ctx->Texture.Unit[u]; - for (tex = 0; tex < NUM_TEXTURE_TARGETS; tex++) { - _mesa_reference_texobj(&texUnit->CurrentTex[tex], - ctx->Shared->DefaultTex[tex]); - } - } -} +/* + * Mesa 3-D graphics library + * Version: 7.5 + * + * 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. + */ + +/** + * \file texstate.c + * + * Texture state handling. + */ + +#include "glheader.h" +#include "mfeatures.h" +#include "bufferobj.h" +#include "colormac.h" +#include "colortab.h" +#include "context.h" +#include "enums.h" +#include "macros.h" +#include "texobj.h" +#include "teximage.h" +#include "texstate.h" +#include "mtypes.h" + + + +/** + * Default texture combine environment state. This is used to initialize + * a context's texture units and as the basis for converting "classic" + * texture environmnets to ARB_texture_env_combine style values. + */ +static const struct gl_tex_env_combine_state default_combine_state = { + GL_MODULATE, GL_MODULATE, + { GL_TEXTURE, GL_PREVIOUS, GL_CONSTANT, GL_CONSTANT }, + { GL_TEXTURE, GL_PREVIOUS, GL_CONSTANT, GL_CONSTANT }, + { GL_SRC_COLOR, GL_SRC_COLOR, GL_SRC_ALPHA, GL_SRC_ALPHA }, + { GL_SRC_ALPHA, GL_SRC_ALPHA, GL_SRC_ALPHA, GL_SRC_ALPHA }, + 0, 0, + 2, 2 +}; + + + +/** + * Used by glXCopyContext to copy texture state from one context to another. + */ +void +_mesa_copy_texture_state( const struct gl_context *src, struct gl_context *dst ) +{ + GLuint u, tex; + + ASSERT(src); + ASSERT(dst); + + dst->Texture.CurrentUnit = src->Texture.CurrentUnit; + dst->Texture._GenFlags = src->Texture._GenFlags; + dst->Texture._TexGenEnabled = src->Texture._TexGenEnabled; + dst->Texture._TexMatEnabled = src->Texture._TexMatEnabled; + + /* per-unit state */ + for (u = 0; u < src->Const.MaxCombinedTextureImageUnits; u++) { + dst->Texture.Unit[u].Enabled = src->Texture.Unit[u].Enabled; + dst->Texture.Unit[u].EnvMode = src->Texture.Unit[u].EnvMode; + COPY_4V(dst->Texture.Unit[u].EnvColor, src->Texture.Unit[u].EnvColor); + dst->Texture.Unit[u].TexGenEnabled = src->Texture.Unit[u].TexGenEnabled; + dst->Texture.Unit[u].GenS = src->Texture.Unit[u].GenS; + dst->Texture.Unit[u].GenT = src->Texture.Unit[u].GenT; + dst->Texture.Unit[u].GenR = src->Texture.Unit[u].GenR; + dst->Texture.Unit[u].GenQ = src->Texture.Unit[u].GenQ; + dst->Texture.Unit[u].LodBias = src->Texture.Unit[u].LodBias; + + /* GL_EXT_texture_env_combine */ + dst->Texture.Unit[u].Combine = src->Texture.Unit[u].Combine; + + /* GL_ATI_envmap_bumpmap - need this? */ + dst->Texture.Unit[u].BumpTarget = src->Texture.Unit[u].BumpTarget; + COPY_4V(dst->Texture.Unit[u].RotMatrix, src->Texture.Unit[u].RotMatrix); + + /* + * XXX strictly speaking, we should compare texture names/ids and + * bind textures in the dest context according to id. For now, only + * copy bindings if the contexts share the same pool of textures to + * avoid refcounting bugs. + */ + if (dst->Shared == src->Shared) { + /* copy texture object bindings, not contents of texture objects */ + _mesa_lock_context_textures(dst); + + for (tex = 0; tex < NUM_TEXTURE_TARGETS; tex++) { + _mesa_reference_texobj(&dst->Texture.Unit[u].CurrentTex[tex], + src->Texture.Unit[u].CurrentTex[tex]); + } + _mesa_unlock_context_textures(dst); + } + } +} + + +/* + * For debugging + */ +void +_mesa_print_texunit_state( struct gl_context *ctx, GLuint unit ) +{ + const struct gl_texture_unit *texUnit = ctx->Texture.Unit + unit; + printf("Texture Unit %d\n", unit); + printf(" GL_TEXTURE_ENV_MODE = %s\n", _mesa_lookup_enum_by_nr(texUnit->EnvMode)); + printf(" GL_COMBINE_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.ModeRGB)); + printf(" GL_COMBINE_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.ModeA)); + printf(" GL_SOURCE0_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.SourceRGB[0])); + printf(" GL_SOURCE1_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.SourceRGB[1])); + printf(" GL_SOURCE2_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.SourceRGB[2])); + printf(" GL_SOURCE0_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.SourceA[0])); + printf(" GL_SOURCE1_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.SourceA[1])); + printf(" GL_SOURCE2_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.SourceA[2])); + printf(" GL_OPERAND0_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.OperandRGB[0])); + printf(" GL_OPERAND1_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.OperandRGB[1])); + printf(" GL_OPERAND2_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.OperandRGB[2])); + printf(" GL_OPERAND0_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.OperandA[0])); + printf(" GL_OPERAND1_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.OperandA[1])); + printf(" GL_OPERAND2_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.OperandA[2])); + printf(" GL_RGB_SCALE = %d\n", 1 << texUnit->Combine.ScaleShiftRGB); + printf(" GL_ALPHA_SCALE = %d\n", 1 << texUnit->Combine.ScaleShiftA); + printf(" GL_TEXTURE_ENV_COLOR = (%f, %f, %f, %f)\n", texUnit->EnvColor[0], texUnit->EnvColor[1], texUnit->EnvColor[2], texUnit->EnvColor[3]); +} + + + +/**********************************************************************/ +/* Texture Environment */ +/**********************************************************************/ + +/** + * Convert "classic" texture environment to ARB_texture_env_combine style + * environments. + * + * \param state texture_env_combine state vector to be filled-in. + * \param mode Classic texture environment mode (i.e., \c GL_REPLACE, + * \c GL_BLEND, \c GL_DECAL, etc.). + * \param texBaseFormat Base format of the texture associated with the + * texture unit. + */ +static void +calculate_derived_texenv( struct gl_tex_env_combine_state *state, + GLenum mode, GLenum texBaseFormat ) +{ + GLenum mode_rgb; + GLenum mode_a; + + *state = default_combine_state; + + switch (texBaseFormat) { + case GL_ALPHA: + state->SourceRGB[0] = GL_PREVIOUS; + break; + + case GL_LUMINANCE_ALPHA: + case GL_INTENSITY: + case GL_RGBA: + break; + + case GL_LUMINANCE: + case GL_RED: + case GL_RG: + case GL_RGB: + case GL_YCBCR_MESA: + case GL_DUDV_ATI: + state->SourceA[0] = GL_PREVIOUS; + break; + + default: + _mesa_problem(NULL, + "Invalid texBaseFormat 0x%x in calculate_derived_texenv", + texBaseFormat); + return; + } + + if (mode == GL_REPLACE_EXT) + mode = GL_REPLACE; + + switch (mode) { + case GL_REPLACE: + case GL_MODULATE: + mode_rgb = (texBaseFormat == GL_ALPHA) ? GL_REPLACE : mode; + mode_a = mode; + break; + + case GL_DECAL: + mode_rgb = GL_INTERPOLATE; + mode_a = GL_REPLACE; + + state->SourceA[0] = GL_PREVIOUS; + + /* Having alpha / luminance / intensity textures replace using the + * incoming fragment color matches the definition in NV_texture_shader. + * The 1.5 spec simply marks these as "undefined". + */ + switch (texBaseFormat) { + case GL_ALPHA: + case GL_LUMINANCE: + case GL_LUMINANCE_ALPHA: + case GL_INTENSITY: + state->SourceRGB[0] = GL_PREVIOUS; + break; + case GL_RED: + case GL_RG: + case GL_RGB: + case GL_YCBCR_MESA: + case GL_DUDV_ATI: + mode_rgb = GL_REPLACE; + break; + case GL_RGBA: + state->SourceRGB[2] = GL_TEXTURE; + break; + } + break; + + case GL_BLEND: + mode_rgb = GL_INTERPOLATE; + mode_a = GL_MODULATE; + + switch (texBaseFormat) { + case GL_ALPHA: + mode_rgb = GL_REPLACE; + break; + case GL_INTENSITY: + mode_a = GL_INTERPOLATE; + state->SourceA[0] = GL_CONSTANT; + state->OperandA[2] = GL_SRC_ALPHA; + /* FALLTHROUGH */ + case GL_LUMINANCE: + case GL_RED: + case GL_RG: + case GL_RGB: + case GL_LUMINANCE_ALPHA: + case GL_RGBA: + case GL_YCBCR_MESA: + case GL_DUDV_ATI: + state->SourceRGB[2] = GL_TEXTURE; + state->SourceA[2] = GL_TEXTURE; + state->SourceRGB[0] = GL_CONSTANT; + state->OperandRGB[2] = GL_SRC_COLOR; + break; + } + break; + + case GL_ADD: + mode_rgb = (texBaseFormat == GL_ALPHA) ? GL_REPLACE : GL_ADD; + mode_a = (texBaseFormat == GL_INTENSITY) ? GL_ADD : GL_MODULATE; + break; + + default: + _mesa_problem(NULL, + "Invalid texture env mode 0x%x in calculate_derived_texenv", + mode); + return; + } + + state->ModeRGB = (state->SourceRGB[0] != GL_PREVIOUS) + ? mode_rgb : GL_REPLACE; + state->ModeA = (state->SourceA[0] != GL_PREVIOUS) + ? mode_a : GL_REPLACE; +} + + + + +/* GL_ARB_multitexture */ +void GLAPIENTRY +_mesa_ActiveTextureARB(GLenum texture) +{ + const GLuint texUnit = texture - GL_TEXTURE0; + GLuint k; + GET_CURRENT_CONTEXT(ctx); + + /* See OpenGL spec for glActiveTexture: */ + k = MAX2(ctx->Const.MaxCombinedTextureImageUnits, + ctx->Const.MaxTextureCoordUnits); + + ASSERT(k <= Elements(ctx->Texture.Unit)); + + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE)) + _mesa_debug(ctx, "glActiveTexture %s\n", + _mesa_lookup_enum_by_nr(texture)); + + if (texUnit >= k) { + _mesa_error(ctx, GL_INVALID_ENUM, "glActiveTexture(texture=%s)", + _mesa_lookup_enum_by_nr(texture)); + return; + } + + if (ctx->Texture.CurrentUnit == texUnit) + return; + + FLUSH_VERTICES(ctx, _NEW_TEXTURE); + + ctx->Texture.CurrentUnit = texUnit; + if (ctx->Transform.MatrixMode == GL_TEXTURE) { + /* update current stack pointer */ + ctx->CurrentStack = &ctx->TextureMatrixStack[texUnit]; + } +} + + +/* GL_ARB_multitexture */ +void GLAPIENTRY +_mesa_ClientActiveTextureARB(GLenum texture) +{ + GET_CURRENT_CONTEXT(ctx); + GLuint texUnit = texture - GL_TEXTURE0; + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (MESA_VERBOSE & (VERBOSE_API | VERBOSE_TEXTURE)) + _mesa_debug(ctx, "glClientActiveTexture %s\n", + _mesa_lookup_enum_by_nr(texture)); + + if (texUnit >= ctx->Const.MaxTextureCoordUnits) { + _mesa_error(ctx, GL_INVALID_ENUM, "glClientActiveTexture(texture)"); + return; + } + + if (ctx->Array.ActiveTexture == texUnit) + return; + + FLUSH_VERTICES(ctx, _NEW_ARRAY); + ctx->Array.ActiveTexture = texUnit; +} + + + +/**********************************************************************/ +/***** State management *****/ +/**********************************************************************/ + + +/** + * \note This routine refers to derived texture attribute values to + * compute the ENABLE_TEXMAT flags, but is only called on + * _NEW_TEXTURE_MATRIX. On changes to _NEW_TEXTURE, the ENABLE_TEXMAT + * flags are updated by _mesa_update_textures(), below. + * + * \param ctx GL context. + */ +static void +update_texture_matrices( struct gl_context *ctx ) +{ + GLuint u; + + ctx->Texture._TexMatEnabled = 0x0; + + for (u = 0; u < ctx->Const.MaxTextureCoordUnits; u++) { + ASSERT(u < Elements(ctx->TextureMatrixStack)); + if (_math_matrix_is_dirty(ctx->TextureMatrixStack[u].Top)) { + _math_matrix_analyse( ctx->TextureMatrixStack[u].Top ); + + if (ctx->Texture.Unit[u]._ReallyEnabled && + ctx->TextureMatrixStack[u].Top->type != MATRIX_IDENTITY) + ctx->Texture._TexMatEnabled |= ENABLE_TEXMAT(u); + } + } +} + + +/** + * Examine texture unit's combine/env state to update derived state. + */ +static void +update_tex_combine(struct gl_context *ctx, struct gl_texture_unit *texUnit) +{ + struct gl_tex_env_combine_state *combine; + + /* Set the texUnit->_CurrentCombine field to point to the user's combiner + * state, or the combiner state which is derived from traditional texenv + * mode. + */ + if (texUnit->EnvMode == GL_COMBINE || + texUnit->EnvMode == GL_COMBINE4_NV) { + texUnit->_CurrentCombine = & texUnit->Combine; + } + else { + const struct gl_texture_object *texObj = texUnit->_Current; + GLenum format = texObj->Image[0][texObj->BaseLevel]->_BaseFormat; + + if (format == GL_DEPTH_COMPONENT || format == GL_DEPTH_STENCIL_EXT) { + format = texObj->Sampler.DepthMode; + } + calculate_derived_texenv(&texUnit->_EnvMode, texUnit->EnvMode, format); + texUnit->_CurrentCombine = & texUnit->_EnvMode; + } + + combine = texUnit->_CurrentCombine; + + /* Determine number of source RGB terms in the combiner function */ + switch (combine->ModeRGB) { + case GL_REPLACE: + combine->_NumArgsRGB = 1; + break; + case GL_ADD: + case GL_ADD_SIGNED: + if (texUnit->EnvMode == GL_COMBINE4_NV) + combine->_NumArgsRGB = 4; + else + combine->_NumArgsRGB = 2; + break; + case GL_MODULATE: + case GL_SUBTRACT: + case GL_DOT3_RGB: + case GL_DOT3_RGBA: + case GL_DOT3_RGB_EXT: + case GL_DOT3_RGBA_EXT: + combine->_NumArgsRGB = 2; + break; + case GL_INTERPOLATE: + case GL_MODULATE_ADD_ATI: + case GL_MODULATE_SIGNED_ADD_ATI: + case GL_MODULATE_SUBTRACT_ATI: + combine->_NumArgsRGB = 3; + break; + case GL_BUMP_ENVMAP_ATI: + /* no real arguments for this case */ + combine->_NumArgsRGB = 0; + break; + default: + combine->_NumArgsRGB = 0; + _mesa_problem(ctx, "invalid RGB combine mode in update_texture_state"); + return; + } + + /* Determine number of source Alpha terms in the combiner function */ + switch (combine->ModeA) { + case GL_REPLACE: + combine->_NumArgsA = 1; + break; + case GL_ADD: + case GL_ADD_SIGNED: + if (texUnit->EnvMode == GL_COMBINE4_NV) + combine->_NumArgsA = 4; + else + combine->_NumArgsA = 2; + break; + case GL_MODULATE: + case GL_SUBTRACT: + combine->_NumArgsA = 2; + break; + case GL_INTERPOLATE: + case GL_MODULATE_ADD_ATI: + case GL_MODULATE_SIGNED_ADD_ATI: + case GL_MODULATE_SUBTRACT_ATI: + combine->_NumArgsA = 3; + break; + default: + combine->_NumArgsA = 0; + _mesa_problem(ctx, "invalid Alpha combine mode in update_texture_state"); + break; + } +} + + +/** + * \note This routine refers to derived texture matrix values to + * compute the ENABLE_TEXMAT flags, but is only called on + * _NEW_TEXTURE. On changes to _NEW_TEXTURE_MATRIX, the ENABLE_TEXMAT + * flags are updated by _mesa_update_texture_matrices, above. + * + * \param ctx GL context. + */ +static void +update_texture_state( struct gl_context *ctx ) +{ + GLuint unit; + struct gl_fragment_program *fprog = NULL; + struct gl_vertex_program *vprog = NULL; + GLbitfield enabledFragUnits = 0x0; + + if (ctx->Shader.CurrentVertexProgram && + ctx->Shader.CurrentVertexProgram->LinkStatus) { + vprog = ctx->Shader.CurrentVertexProgram->VertexProgram; + } else if (ctx->VertexProgram._Enabled) { + /* XXX enable this if/when non-shader vertex programs get + * texture fetches: + vprog = ctx->VertexProgram.Current; + */ + } + + if (ctx->Shader.CurrentFragmentProgram && + ctx->Shader.CurrentFragmentProgram->LinkStatus) { + fprog = ctx->Shader.CurrentFragmentProgram->FragmentProgram; + } + else if (ctx->FragmentProgram._Enabled) { + fprog = ctx->FragmentProgram.Current; + } + + /* FINISHME: Geometry shader texture accesses should also be considered + * FINISHME: here. + */ + + /* TODO: only set this if there are actual changes */ + ctx->NewState |= _NEW_TEXTURE; + + ctx->Texture._EnabledUnits = 0x0; + ctx->Texture._GenFlags = 0x0; + ctx->Texture._TexMatEnabled = 0x0; + ctx->Texture._TexGenEnabled = 0x0; + + /* + * Update texture unit state. + */ + for (unit = 0; unit < ctx->Const.MaxCombinedTextureImageUnits; unit++) { + struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; + GLbitfield enabledVertTargets = 0x0; + GLbitfield enabledFragTargets = 0x0; + GLbitfield enabledTargets = 0x0; + GLuint texIndex; + + /* Get the bitmask of texture target enables. + * enableBits will be a mask of the TEXTURE_*_BIT flags indicating + * which texture targets are enabled (fixed function) or referenced + * by a fragment program/program. When multiple flags are set, we'll + * settle on the one with highest priority (see below). + */ + if (vprog) { + enabledVertTargets |= vprog->Base.TexturesUsed[unit]; + } + + if (fprog) { + enabledFragTargets |= fprog->Base.TexturesUsed[unit]; + } + else { + /* fixed-function fragment program */ + enabledFragTargets |= texUnit->Enabled; + } + + enabledTargets = enabledVertTargets | enabledFragTargets; + + texUnit->_ReallyEnabled = 0x0; + + if (enabledTargets == 0x0) { + /* neither vertex nor fragment processing uses this unit */ + continue; + } + + /* Look for the highest priority texture target that's enabled (or used + * by the vert/frag shaders) and "complete". That's the one we'll use + * for texturing. If we're using vert/frag program we're guaranteed + * that bitcount(enabledBits) <= 1. + * Note that the TEXTURE_x_INDEX values are in high to low priority. + */ + for (texIndex = 0; texIndex < NUM_TEXTURE_TARGETS; texIndex++) { + if (enabledTargets & (1 << texIndex)) { + struct gl_texture_object *texObj = texUnit->CurrentTex[texIndex]; + if (!texObj->_Complete) { + _mesa_test_texobj_completeness(ctx, texObj); + } + if (texObj->_Complete) { + texUnit->_ReallyEnabled = 1 << texIndex; + _mesa_reference_texobj(&texUnit->_Current, texObj); + break; + } + } + } + + if (!texUnit->_ReallyEnabled) { + if (fprog) { + /* If we get here it means the shader is expecting a texture + * object, but there isn't one (or it's incomplete). Use the + * fallback texture. + */ + struct gl_texture_object *texObj = _mesa_get_fallback_texture(ctx); + texUnit->_ReallyEnabled = 1 << TEXTURE_2D_INDEX; + _mesa_reference_texobj(&texUnit->_Current, texObj); + } + else { + /* fixed-function: texture unit is really disabled */ + continue; + } + } + + /* if we get here, we know this texture unit is enabled */ + + ctx->Texture._EnabledUnits |= (1 << unit); + + if (enabledFragTargets) + enabledFragUnits |= (1 << unit); + + update_tex_combine(ctx, texUnit); + } + + + /* Determine which texture coordinate sets are actually needed */ + if (fprog) { + const GLuint coordMask = (1 << MAX_TEXTURE_COORD_UNITS) - 1; + ctx->Texture._EnabledCoordUnits + = (fprog->Base.InputsRead >> FRAG_ATTRIB_TEX0) & coordMask; + } + else { + ctx->Texture._EnabledCoordUnits = enabledFragUnits; + } + + /* Setup texgen for those texture coordinate sets that are in use */ + for (unit = 0; unit < ctx->Const.MaxTextureCoordUnits; unit++) { + struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; + + texUnit->_GenFlags = 0x0; + + if (!(ctx->Texture._EnabledCoordUnits & (1 << unit))) + continue; + + if (texUnit->TexGenEnabled) { + if (texUnit->TexGenEnabled & S_BIT) { + texUnit->_GenFlags |= texUnit->GenS._ModeBit; + } + if (texUnit->TexGenEnabled & T_BIT) { + texUnit->_GenFlags |= texUnit->GenT._ModeBit; + } + if (texUnit->TexGenEnabled & R_BIT) { + texUnit->_GenFlags |= texUnit->GenR._ModeBit; + } + if (texUnit->TexGenEnabled & Q_BIT) { + texUnit->_GenFlags |= texUnit->GenQ._ModeBit; + } + + ctx->Texture._TexGenEnabled |= ENABLE_TEXGEN(unit); + ctx->Texture._GenFlags |= texUnit->_GenFlags; + } + + ASSERT(unit < Elements(ctx->TextureMatrixStack)); + if (ctx->TextureMatrixStack[unit].Top->type != MATRIX_IDENTITY) + ctx->Texture._TexMatEnabled |= ENABLE_TEXMAT(unit); + } +} + + +/** + * Update texture-related derived state. + */ +void +_mesa_update_texture( struct gl_context *ctx, GLuint new_state ) +{ + if (new_state & _NEW_TEXTURE_MATRIX) + update_texture_matrices( ctx ); + + if (new_state & (_NEW_TEXTURE | _NEW_PROGRAM)) + update_texture_state( ctx ); +} + + +/**********************************************************************/ +/***** Initialization *****/ +/**********************************************************************/ + +/** + * Allocate the proxy textures for the given context. + * + * \param ctx the context to allocate proxies for. + * + * \return GL_TRUE on success, or GL_FALSE on failure + * + * If run out of memory part way through the allocations, clean up and return + * GL_FALSE. + */ +static GLboolean +alloc_proxy_textures( struct gl_context *ctx ) +{ + static const GLenum targets[] = { + GL_TEXTURE_1D, + GL_TEXTURE_2D, + GL_TEXTURE_3D, + GL_TEXTURE_CUBE_MAP_ARB, + GL_TEXTURE_RECTANGLE_NV, + GL_TEXTURE_1D_ARRAY_EXT, + GL_TEXTURE_2D_ARRAY_EXT, + GL_TEXTURE_BUFFER + }; + GLint tgt; + + ASSERT(Elements(targets) == NUM_TEXTURE_TARGETS); + + for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++) { + if (!(ctx->Texture.ProxyTex[tgt] + = ctx->Driver.NewTextureObject(ctx, 0, targets[tgt]))) { + /* out of memory, free what we did allocate */ + while (--tgt >= 0) { + ctx->Driver.DeleteTexture(ctx, ctx->Texture.ProxyTex[tgt]); + } + return GL_FALSE; + } + } + + assert(ctx->Texture.ProxyTex[0]->RefCount == 1); /* sanity check */ + return GL_TRUE; +} + + +/** + * Initialize a texture unit. + * + * \param ctx GL context. + * \param unit texture unit number to be initialized. + */ +static void +init_texture_unit( struct gl_context *ctx, GLuint unit ) +{ + struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; + GLuint tex; + + texUnit->EnvMode = GL_MODULATE; + ASSIGN_4V( texUnit->EnvColor, 0.0, 0.0, 0.0, 0.0 ); + + texUnit->Combine = default_combine_state; + texUnit->_EnvMode = default_combine_state; + texUnit->_CurrentCombine = & texUnit->_EnvMode; + texUnit->BumpTarget = GL_TEXTURE0; + + texUnit->TexGenEnabled = 0x0; + texUnit->GenS.Mode = GL_EYE_LINEAR; + texUnit->GenT.Mode = GL_EYE_LINEAR; + texUnit->GenR.Mode = GL_EYE_LINEAR; + texUnit->GenQ.Mode = GL_EYE_LINEAR; + texUnit->GenS._ModeBit = TEXGEN_EYE_LINEAR; + texUnit->GenT._ModeBit = TEXGEN_EYE_LINEAR; + texUnit->GenR._ModeBit = TEXGEN_EYE_LINEAR; + texUnit->GenQ._ModeBit = TEXGEN_EYE_LINEAR; + + /* Yes, these plane coefficients are correct! */ + ASSIGN_4V( texUnit->GenS.ObjectPlane, 1.0, 0.0, 0.0, 0.0 ); + ASSIGN_4V( texUnit->GenT.ObjectPlane, 0.0, 1.0, 0.0, 0.0 ); + ASSIGN_4V( texUnit->GenR.ObjectPlane, 0.0, 0.0, 0.0, 0.0 ); + ASSIGN_4V( texUnit->GenQ.ObjectPlane, 0.0, 0.0, 0.0, 0.0 ); + ASSIGN_4V( texUnit->GenS.EyePlane, 1.0, 0.0, 0.0, 0.0 ); + ASSIGN_4V( texUnit->GenT.EyePlane, 0.0, 1.0, 0.0, 0.0 ); + ASSIGN_4V( texUnit->GenR.EyePlane, 0.0, 0.0, 0.0, 0.0 ); + ASSIGN_4V( texUnit->GenQ.EyePlane, 0.0, 0.0, 0.0, 0.0 ); + + /* no mention of this in spec, but maybe id matrix expected? */ + ASSIGN_4V( texUnit->RotMatrix, 1.0, 0.0, 0.0, 1.0 ); + + /* initialize current texture object ptrs to the shared default objects */ + for (tex = 0; tex < NUM_TEXTURE_TARGETS; tex++) { + _mesa_reference_texobj(&texUnit->CurrentTex[tex], + ctx->Shared->DefaultTex[tex]); + } +} + + +/** + * Initialize texture state for the given context. + */ +GLboolean +_mesa_init_texture(struct gl_context *ctx) +{ + GLuint u; + + /* Texture group */ + ctx->Texture.CurrentUnit = 0; /* multitexture */ + ctx->Texture._EnabledUnits = 0x0; + + for (u = 0; u < Elements(ctx->Texture.Unit); u++) + init_texture_unit(ctx, u); + + /* After we're done initializing the context's texture state the default + * texture objects' refcounts should be at least + * MAX_COMBINED_TEXTURE_IMAGE_UNITS + 1. + */ + assert(ctx->Shared->DefaultTex[TEXTURE_1D_INDEX]->RefCount + >= MAX_COMBINED_TEXTURE_IMAGE_UNITS + 1); + + /* Allocate proxy textures */ + if (!alloc_proxy_textures( ctx )) + return GL_FALSE; + + /* GL_ARB_texture_buffer_object */ + _mesa_reference_buffer_object(ctx, &ctx->Texture.BufferObject, + ctx->Shared->NullBufferObj); + + return GL_TRUE; +} + + +/** + * Free dynamically-allocted texture data attached to the given context. + */ +void +_mesa_free_texture_data(struct gl_context *ctx) +{ + GLuint u, tgt; + + /* unreference current textures */ + for (u = 0; u < Elements(ctx->Texture.Unit); u++) { + /* The _Current texture could account for another reference */ + _mesa_reference_texobj(&ctx->Texture.Unit[u]._Current, NULL); + + for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++) { + _mesa_reference_texobj(&ctx->Texture.Unit[u].CurrentTex[tgt], NULL); + } + } + + /* Free proxy texture objects */ + for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++) + ctx->Driver.DeleteTexture(ctx, ctx->Texture.ProxyTex[tgt]); + + /* GL_ARB_texture_buffer_object */ + _mesa_reference_buffer_object(ctx, &ctx->Texture.BufferObject, NULL); + +#if FEATURE_sampler_objects + for (u = 0; u < Elements(ctx->Texture.Unit); u++) { + _mesa_reference_sampler_object(ctx, &ctx->Texture.Unit[u].Sampler, NULL); + } +#endif +} + + +/** + * Update the default texture objects in the given context to reference those + * specified in the shared state and release those referencing the old + * shared state. + */ +void +_mesa_update_default_objects_texture(struct gl_context *ctx) +{ + GLuint u, tex; + + for (u = 0; u < Elements(ctx->Texture.Unit); u++) { + struct gl_texture_unit *texUnit = &ctx->Texture.Unit[u]; + for (tex = 0; tex < NUM_TEXTURE_TARGETS; tex++) { + _mesa_reference_texobj(&texUnit->CurrentTex[tex], + ctx->Shared->DefaultTex[tex]); + } + } +} diff --git a/mesalib/src/mesa/main/texstore.h b/mesalib/src/mesa/main/texstore.h index 1d0ce7d4a..d56318709 100644 --- a/mesalib/src/mesa/main/texstore.h +++ b/mesalib/src/mesa/main/texstore.h @@ -1,209 +1,209 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5.1 - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * Copyright (c) 2008 VMware, 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 - * 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 texstore.h - * Texture image storage routines. - * - * \author Brian Paul - */ - - -#ifndef TEXSTORE_H -#define TEXSTORE_H - - -#include "mtypes.h" -#include "formats.h" - - -/** - * This macro defines the (many) parameters to the texstore functions. - * \param dims either 1 or 2 or 3 - * \param baseInternalFormat user-specified base internal format - * \param dstFormat destination Mesa texture format - * \param dstAddr destination image address - * \param dstX/Y/Zoffset destination x/y/z offset (ala TexSubImage), in texels - * \param dstRowStride destination image row stride, in bytes - * \param dstImageOffsets offset of each 2D slice within 3D texture, in texels - * \param srcWidth/Height/Depth source image size, in pixels - * \param srcFormat incoming image format - * \param srcType incoming image data type - * \param srcAddr source image address - * \param srcPacking source image packing parameters - */ -#define TEXSTORE_PARAMS \ - struct gl_context *ctx, GLuint dims, \ - GLenum baseInternalFormat, \ - gl_format dstFormat, \ - GLvoid *dstAddr, \ - GLint dstXoffset, GLint dstYoffset, GLint dstZoffset, \ - GLint dstRowStride, const GLuint *dstImageOffsets, \ - GLint srcWidth, GLint srcHeight, GLint srcDepth, \ - GLenum srcFormat, GLenum srcType, \ - const GLvoid *srcAddr, \ - const struct gl_pixelstore_attrib *srcPacking - - -extern GLboolean -_mesa_texstore(TEXSTORE_PARAMS); - - -extern GLchan * -_mesa_make_temp_chan_image(struct gl_context *ctx, GLuint dims, - GLenum logicalBaseFormat, - GLenum textureBaseFormat, - GLint srcWidth, GLint srcHeight, GLint srcDepth, - GLenum srcFormat, GLenum srcType, - const GLvoid *srcAddr, - const struct gl_pixelstore_attrib *srcPacking); - -GLfloat * -_mesa_make_temp_float_image(struct gl_context *ctx, GLuint dims, - GLenum logicalBaseFormat, - GLenum textureBaseFormat, - GLint srcWidth, GLint srcHeight, GLint srcDepth, - GLenum srcFormat, GLenum srcType, - const GLvoid *srcAddr, - const struct gl_pixelstore_attrib *srcPacking, - GLbitfield transferOps); - -extern void -_mesa_store_teximage1d(struct gl_context *ctx, GLenum target, GLint level, - GLint internalFormat, - GLint width, GLint border, - GLenum format, GLenum type, const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage); - - -extern void -_mesa_store_teximage2d(struct gl_context *ctx, GLenum target, GLint level, - GLint internalFormat, - GLint width, GLint height, GLint border, - GLenum format, GLenum type, const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage); - - -extern void -_mesa_store_teximage3d(struct gl_context *ctx, GLenum target, GLint level, - GLint internalFormat, - GLint width, GLint height, GLint depth, GLint border, - GLenum format, GLenum type, const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage); - - -extern void -_mesa_store_texsubimage1d(struct gl_context *ctx, GLenum target, GLint level, - GLint xoffset, GLint width, - GLenum format, GLenum type, const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage); - - -extern void -_mesa_store_texsubimage2d(struct gl_context *ctx, GLenum target, GLint level, - GLint xoffset, GLint yoffset, - GLint width, GLint height, - GLenum format, GLenum type, const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage); - - -extern void -_mesa_store_texsubimage3d(struct gl_context *ctx, GLenum target, GLint level, - GLint xoffset, GLint yoffset, GLint zoffset, - GLint width, GLint height, GLint depth, - GLenum format, GLenum type, const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage); - - -extern void -_mesa_store_compressed_teximage1d(struct gl_context *ctx, GLenum target, GLint level, - GLint internalFormat, - GLint width, GLint border, - GLsizei imageSize, const GLvoid *data, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage); - -extern void -_mesa_store_compressed_teximage2d(struct gl_context *ctx, GLenum target, GLint level, - GLint internalFormat, - GLint width, GLint height, GLint border, - GLsizei imageSize, const GLvoid *data, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage); - -extern void -_mesa_store_compressed_teximage3d(struct gl_context *ctx, GLenum target, GLint level, - GLint internalFormat, - GLint width, GLint height, GLint depth, - GLint border, - GLsizei imageSize, const GLvoid *data, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage); - - -extern void -_mesa_store_compressed_texsubimage1d(struct gl_context *ctx, GLenum target, - GLint level, - GLint xoffset, GLsizei width, - GLenum format, - GLsizei imageSize, const GLvoid *data, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage); - -extern void -_mesa_store_compressed_texsubimage2d(struct gl_context *ctx, GLenum target, - GLint level, - GLint xoffset, GLint yoffset, - GLsizei width, GLsizei height, - GLenum format, - GLsizei imageSize, const GLvoid *data, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage); - -extern void -_mesa_store_compressed_texsubimage3d(struct gl_context *ctx, GLenum target, - GLint level, - GLint xoffset, GLint yoffset, GLint zoffset, - GLsizei width, GLsizei height, GLsizei depth, - GLenum format, - GLsizei imageSize, const GLvoid *data, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage); - - -#endif +/* + * Mesa 3-D graphics library + * Version: 6.5.1 + * + * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * Copyright (c) 2008 VMware, 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 + * 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 texstore.h + * Texture image storage routines. + * + * \author Brian Paul + */ + + +#ifndef TEXSTORE_H +#define TEXSTORE_H + + +#include "mtypes.h" +#include "formats.h" + + +/** + * This macro defines the (many) parameters to the texstore functions. + * \param dims either 1 or 2 or 3 + * \param baseInternalFormat user-specified base internal format + * \param dstFormat destination Mesa texture format + * \param dstAddr destination image address + * \param dstX/Y/Zoffset destination x/y/z offset (ala TexSubImage), in texels + * \param dstRowStride destination image row stride, in bytes + * \param dstImageOffsets offset of each 2D slice within 3D texture, in texels + * \param srcWidth/Height/Depth source image size, in pixels + * \param srcFormat incoming image format + * \param srcType incoming image data type + * \param srcAddr source image address + * \param srcPacking source image packing parameters + */ +#define TEXSTORE_PARAMS \ + struct gl_context *ctx, GLuint dims, \ + GLenum baseInternalFormat, \ + gl_format dstFormat, \ + GLvoid *dstAddr, \ + GLint dstXoffset, GLint dstYoffset, GLint dstZoffset, \ + GLint dstRowStride, const GLuint *dstImageOffsets, \ + GLint srcWidth, GLint srcHeight, GLint srcDepth, \ + GLenum srcFormat, GLenum srcType, \ + const GLvoid *srcAddr, \ + const struct gl_pixelstore_attrib *srcPacking + + +extern GLboolean +_mesa_texstore(TEXSTORE_PARAMS); + + +extern GLchan * +_mesa_make_temp_chan_image(struct gl_context *ctx, GLuint dims, + GLenum logicalBaseFormat, + GLenum textureBaseFormat, + GLint srcWidth, GLint srcHeight, GLint srcDepth, + GLenum srcFormat, GLenum srcType, + const GLvoid *srcAddr, + const struct gl_pixelstore_attrib *srcPacking); + +GLfloat * +_mesa_make_temp_float_image(struct gl_context *ctx, GLuint dims, + GLenum logicalBaseFormat, + GLenum textureBaseFormat, + GLint srcWidth, GLint srcHeight, GLint srcDepth, + GLenum srcFormat, GLenum srcType, + const GLvoid *srcAddr, + const struct gl_pixelstore_attrib *srcPacking, + GLbitfield transferOps); + +extern void +_mesa_store_teximage1d(struct gl_context *ctx, GLenum target, GLint level, + GLint internalFormat, + GLint width, GLint border, + GLenum format, GLenum type, const GLvoid *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage); + + +extern void +_mesa_store_teximage2d(struct gl_context *ctx, GLenum target, GLint level, + GLint internalFormat, + GLint width, GLint height, GLint border, + GLenum format, GLenum type, const GLvoid *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage); + + +extern void +_mesa_store_teximage3d(struct gl_context *ctx, GLenum target, GLint level, + GLint internalFormat, + GLint width, GLint height, GLint depth, GLint border, + GLenum format, GLenum type, const GLvoid *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage); + + +extern void +_mesa_store_texsubimage1d(struct gl_context *ctx, GLenum target, GLint level, + GLint xoffset, GLint width, + GLenum format, GLenum type, const GLvoid *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage); + + +extern void +_mesa_store_texsubimage2d(struct gl_context *ctx, GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLint width, GLint height, + GLenum format, GLenum type, const GLvoid *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage); + + +extern void +_mesa_store_texsubimage3d(struct gl_context *ctx, GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLint width, GLint height, GLint depth, + GLenum format, GLenum type, const GLvoid *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage); + + +extern void +_mesa_store_compressed_teximage1d(struct gl_context *ctx, GLenum target, GLint level, + GLint internalFormat, + GLint width, GLint border, + GLsizei imageSize, const GLvoid *data, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage); + +extern void +_mesa_store_compressed_teximage2d(struct gl_context *ctx, GLenum target, GLint level, + GLint internalFormat, + GLint width, GLint height, GLint border, + GLsizei imageSize, const GLvoid *data, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage); + +extern void +_mesa_store_compressed_teximage3d(struct gl_context *ctx, GLenum target, GLint level, + GLint internalFormat, + GLint width, GLint height, GLint depth, + GLint border, + GLsizei imageSize, const GLvoid *data, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage); + + +extern void +_mesa_store_compressed_texsubimage1d(struct gl_context *ctx, GLenum target, + GLint level, + GLint xoffset, GLsizei width, + GLenum format, + GLsizei imageSize, const GLvoid *data, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage); + +extern void +_mesa_store_compressed_texsubimage2d(struct gl_context *ctx, GLenum target, + GLint level, + GLint xoffset, GLint yoffset, + GLsizei width, GLsizei height, + GLenum format, + GLsizei imageSize, const GLvoid *data, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage); + +extern void +_mesa_store_compressed_texsubimage3d(struct gl_context *ctx, GLenum target, + GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLsizei width, GLsizei height, GLsizei depth, + GLenum format, + GLsizei imageSize, const GLvoid *data, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage); + + +#endif diff --git a/mesalib/src/mesa/main/uniforms.c b/mesalib/src/mesa/main/uniforms.c index 0c0548467..b0f9c33b8 100644 --- a/mesalib/src/mesa/main/uniforms.c +++ b/mesalib/src/mesa/main/uniforms.c @@ -1,1517 +1,1517 @@ -/* - * Mesa 3-D graphics library - * - * Copyright (C) 2004-2008 Brian Paul All Rights Reserved. - * Copyright (C) 2009-2010 VMware, Inc. All Rights Reserved. - * Copyright © 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. - */ - -/** - * \file uniforms.c - * Functions related to GLSL uniform variables. - * \author Brian Paul - */ - -/** - * XXX things to do: - * 1. Check that the right error code is generated for all _mesa_error() calls. - * 2. Insert FLUSH_VERTICES calls in various places - */ - - -#include "main/glheader.h" -#include "main/context.h" -#include "main/dispatch.h" -#include "main/image.h" -#include "main/mfeatures.h" -#include "main/mtypes.h" -#include "main/shaderapi.h" -#include "main/shaderobj.h" -#include "main/uniforms.h" -#include "program/prog_parameter.h" -#include "program/prog_statevars.h" -#include "program/prog_uniform.h" -#include "program/prog_instruction.h" - - -static GLenum -base_uniform_type(GLenum type) -{ - switch (type) { - case GL_BOOL: - case GL_BOOL_VEC2: - case GL_BOOL_VEC3: - case GL_BOOL_VEC4: - return GL_BOOL; - case GL_FLOAT: - case GL_FLOAT_VEC2: - case GL_FLOAT_VEC3: - case GL_FLOAT_VEC4: - case GL_FLOAT_MAT2: - case GL_FLOAT_MAT2x3: - case GL_FLOAT_MAT2x4: - case GL_FLOAT_MAT3x2: - case GL_FLOAT_MAT3: - case GL_FLOAT_MAT3x4: - case GL_FLOAT_MAT4x2: - case GL_FLOAT_MAT4x3: - case GL_FLOAT_MAT4: - return GL_FLOAT; - case GL_UNSIGNED_INT: - case GL_UNSIGNED_INT_VEC2: - case GL_UNSIGNED_INT_VEC3: - case GL_UNSIGNED_INT_VEC4: - return GL_UNSIGNED_INT; - case GL_INT: - case GL_INT_VEC2: - case GL_INT_VEC3: - case GL_INT_VEC4: - return GL_INT; - default: - _mesa_problem(NULL, "Invalid type in base_uniform_type()"); - return GL_FLOAT; - } -} - - -static GLboolean -is_boolean_type(GLenum type) -{ - switch (type) { - case GL_BOOL: - case GL_BOOL_VEC2: - case GL_BOOL_VEC3: - case GL_BOOL_VEC4: - return GL_TRUE; - default: - return GL_FALSE; - } -} - - -static GLboolean -is_sampler_type(GLenum type) -{ - switch (type) { - case GL_SAMPLER_1D: - case GL_SAMPLER_2D: - case GL_SAMPLER_3D: - case GL_SAMPLER_CUBE: - case GL_SAMPLER_1D_SHADOW: - case GL_SAMPLER_2D_SHADOW: - case GL_SAMPLER_CUBE_SHADOW: - case GL_SAMPLER_2D_RECT_ARB: - case GL_SAMPLER_2D_RECT_SHADOW_ARB: - case GL_SAMPLER_1D_ARRAY_EXT: - case GL_SAMPLER_2D_ARRAY_EXT: - case GL_SAMPLER_1D_ARRAY_SHADOW_EXT: - case GL_SAMPLER_2D_ARRAY_SHADOW_EXT: - case GL_SAMPLER_CUBE_MAP_ARRAY: - case GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW: - case GL_SAMPLER_BUFFER: - return GL_TRUE; - default: - return GL_FALSE; - } -} - - -/** - * Given a uniform index, return the vertex/geometry/fragment program - * that has that parameter, plus the position of the parameter in the - * parameter/constant buffer. - * \param shProg the shader program - * \param index the uniform index in [0, NumUniforms-1] - * \param progOut returns containing program - * \param posOut returns position of the uniform in the param/const buffer - * \return GL_TRUE for success, GL_FALSE for invalid index - */ -static GLboolean -find_uniform_parameter_pos(struct gl_shader_program *shProg, GLint index, - struct gl_program **progOut, GLint *posOut) -{ - struct gl_program *prog = NULL; - GLint pos; - - if (!shProg->Uniforms || - index < 0 || - index >= (GLint) shProg->Uniforms->NumUniforms) { - return GL_FALSE; - } - - pos = shProg->Uniforms->Uniforms[index].VertPos; - if (pos >= 0) { - prog = &shProg->VertexProgram->Base; - } - else { - pos = shProg->Uniforms->Uniforms[index].FragPos; - if (pos >= 0) { - prog = &shProg->FragmentProgram->Base; - } - else { - pos = shProg->Uniforms->Uniforms[index].GeomPos; - if (pos >= 0) { - prog = &shProg->GeometryProgram->Base; - } - } - } - - if (!prog || pos < 0) - return GL_FALSE; /* should really never happen */ - - *progOut = prog; - *posOut = pos; - - return GL_TRUE; -} - - -/** - * Return pointer to a gl_program_parameter which corresponds to a uniform. - * \param shProg the shader program - * \param index the uniform index in [0, NumUniforms-1] - * \return gl_program_parameter point or NULL if index is invalid - */ -static const struct gl_program_parameter * -get_uniform_parameter(struct gl_shader_program *shProg, GLint index) -{ - struct gl_program *prog; - GLint progPos; - - if (find_uniform_parameter_pos(shProg, index, &prog, &progPos)) - return &prog->Parameters->Parameters[progPos]; - else - return NULL; -} - - -/** - * Called by glGetActiveUniform(). - */ -static void -_mesa_get_active_uniform(struct gl_context *ctx, GLuint program, GLuint index, - GLsizei maxLength, GLsizei *length, GLint *size, - GLenum *type, GLchar *nameOut) -{ - struct gl_shader_program *shProg = - _mesa_lookup_shader_program_err(ctx, program, "glGetActiveUniform"); - const struct gl_program_parameter *param; - - if (!shProg) - return; - - if (!shProg->Uniforms || index >= shProg->Uniforms->NumUniforms) { - _mesa_error(ctx, GL_INVALID_VALUE, "glGetActiveUniform(index)"); - return; - } - - param = get_uniform_parameter(shProg, index); - if (!param) - return; - - if (nameOut) { - _mesa_copy_string(nameOut, maxLength, length, param->Name); - } - - if (size) { - GLint typeSize = _mesa_sizeof_glsl_type(param->DataType); - if ((GLint) param->Size > typeSize) { - /* This is an array. - * Array elements are placed on vector[4] boundaries so they're - * a multiple of four floats. We round typeSize up to next multiple - * of four to get the right size below. - */ - typeSize = (typeSize + 3) & ~3; - } - /* Note that the returned size is in units of the , not bytes */ - *size = param->Size / typeSize; - } - - if (type) { - *type = param->DataType; - } -} - - -static unsigned -get_vector_elements(GLenum type) -{ - switch (type) { - case GL_FLOAT: - case GL_INT: - case GL_BOOL: - case GL_UNSIGNED_INT: - default: /* Catch all the various sampler types. */ - return 1; - - case GL_FLOAT_VEC2: - case GL_INT_VEC2: - case GL_BOOL_VEC2: - case GL_UNSIGNED_INT_VEC2: - return 2; - - case GL_FLOAT_VEC3: - case GL_INT_VEC3: - case GL_BOOL_VEC3: - case GL_UNSIGNED_INT_VEC3: - return 3; - - case GL_FLOAT_VEC4: - case GL_INT_VEC4: - case GL_BOOL_VEC4: - case GL_UNSIGNED_INT_VEC4: - return 4; - } -} - -static void -get_matrix_dims(GLenum type, GLint *rows, GLint *cols) -{ - switch (type) { - case GL_FLOAT_MAT2: - *rows = *cols = 2; - break; - case GL_FLOAT_MAT2x3: - *rows = 3; - *cols = 2; - break; - case GL_FLOAT_MAT2x4: - *rows = 4; - *cols = 2; - break; - case GL_FLOAT_MAT3: - *rows = 3; - *cols = 3; - break; - case GL_FLOAT_MAT3x2: - *rows = 2; - *cols = 3; - break; - case GL_FLOAT_MAT3x4: - *rows = 4; - *cols = 3; - break; - case GL_FLOAT_MAT4: - *rows = 4; - *cols = 4; - break; - case GL_FLOAT_MAT4x2: - *rows = 2; - *cols = 4; - break; - case GL_FLOAT_MAT4x3: - *rows = 3; - *cols = 4; - break; - default: - *rows = *cols = 0; - } -} - - -/** - * Determine the number of rows and columns occupied by a uniform - * according to its datatype. For non-matrix types (such as GL_FLOAT_VEC4), - * the number of rows = 1 and cols = number of elements in the vector. - */ -static void -get_uniform_rows_cols(const struct gl_program_parameter *p, - GLint *rows, GLint *cols) -{ - get_matrix_dims(p->DataType, rows, cols); - if (*rows == 0 && *cols == 0) { - /* not a matrix type, probably a float or vector */ - *rows = 1; - *cols = get_vector_elements(p->DataType); - } -} - - -/** - * GLSL uniform arrays and structs require special handling. - * - * The GL_ARB_shader_objects spec says that if you use - * glGetUniformLocation to get the location of an array, you CANNOT - * access other elements of the array by adding an offset to the - * returned location. For example, you must call - * glGetUniformLocation("foo[16]") if you want to set the 16th element - * of the array with glUniform(). - * - * HOWEVER, some other OpenGL drivers allow accessing array elements - * by adding an offset to the returned array location. And some apps - * seem to depend on that behaviour. - * - * Mesa's gl_uniform_list doesn't directly support this since each - * entry in the list describes one uniform variable, not one uniform - * element. We could insert dummy entries in the list for each array - * element after [0] but that causes complications elsewhere. - * - * We solve this problem by encoding two values in the location that's - * returned by glGetUniformLocation(): - * a) index into gl_uniform_list::Uniforms[] for the uniform - * b) an array/field offset (0 for simple types) - * - * These two values are encoded in the high and low halves of a GLint. - * By putting the uniform number in the high part and the offset in the - * low part, we can support the unofficial ability to index into arrays - * by adding offsets to the location value. - */ -static void -merge_location_offset(GLint *location, GLint offset) -{ - *location = (*location << 16) | offset; -} - - -/** - * Separate the uniform location and parameter offset. See above. - */ -static void -split_location_offset(GLint *location, GLint *offset) -{ - *offset = *location & 0xffff; - *location = *location >> 16; -} - - - -/** - * Called via glGetUniform[fiui]v() to get the current value of a uniform. - */ -static void -get_uniform(struct gl_context *ctx, GLuint program, GLint location, - GLsizei bufSize, GLenum returnType, GLvoid *paramsOut) -{ - struct gl_shader_program *shProg = - _mesa_lookup_shader_program_err(ctx, program, "glGetUniformfv"); - struct gl_program *prog; - GLint paramPos, offset; - - if (!shProg) - return; - - split_location_offset(&location, &offset); - - if (!find_uniform_parameter_pos(shProg, location, &prog, ¶mPos)) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetUniformfv(location)"); - } - else { - const struct gl_program_parameter *p = - &prog->Parameters->Parameters[paramPos]; - gl_constant_value (*values)[4]; - GLint rows, cols, i, j, k; - GLsizei numBytes; - GLenum storage_type; - - values = prog->Parameters->ParameterValues + paramPos + offset; - - get_uniform_rows_cols(p, &rows, &cols); - - numBytes = rows * cols * _mesa_sizeof_type(returnType); - if (bufSize < numBytes) { - _mesa_error( ctx, GL_INVALID_OPERATION, - "glGetnUniformfvARB(out of bounds: bufSize is %d," - " but %d bytes are required)", bufSize, numBytes ); - return; - } - - if (ctx->Const.NativeIntegers) { - storage_type = base_uniform_type(p->DataType); - } else { - storage_type = GL_FLOAT; - } - - k = 0; - for (i = 0; i < rows; i++) { - for (j = 0; j < cols; j++ ) { - void *out = (char *)paramsOut + 4 * k; - - switch (returnType) { - case GL_FLOAT: - switch (storage_type) { - case GL_FLOAT: - *(float *)out = values[i][j].f; - break; - case GL_INT: - case GL_BOOL: /* boolean is just an integer 1 or 0. */ - *(float *)out = values[i][j].i; - break; - case GL_UNSIGNED_INT: - *(float *)out = values[i][j].u; - break; - } - break; - - case GL_INT: - case GL_UNSIGNED_INT: - switch (storage_type) { - case GL_FLOAT: - /* While the GL 3.2 core spec doesn't explicitly - * state how conversion of float uniforms to integer - * values works, in section 6.2 "State Tables" on - * page 267 it says: - * - * "Unless otherwise specified, when floating - * point state is returned as integer values or - * integer state is returned as floating-point - * values it is converted in the fashion - * described in section 6.1.2" - * - * That section, on page 248, says: - * - * "If GetIntegerv or GetInteger64v are called, - * a floating-point value is rounded to the - * nearest integer..." - */ - *(int *)out = IROUND(values[i][j].f); - break; - - case GL_INT: - case GL_UNSIGNED_INT: - case GL_BOOL: - /* type conversions for these to int/uint are just - * copying the data. - */ - *(int *)out = values[i][j].i; - break; - break; - } - break; - } - - k++; - } - } - } -} - - -/** - * Called via glGetUniformLocation(). - * - * The return value will encode two values, the uniform location and an - * offset (used for arrays, structs). - */ -GLint -_mesa_get_uniform_location(struct gl_context *ctx, - struct gl_shader_program *shProg, - const GLchar *name) -{ - GLint offset = 0, location = -1; - - if (shProg->LinkStatus == GL_FALSE) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetUniformfv(program)"); - return -1; - } - - /* XXX we should return -1 if the uniform was declared, but not - * actually used. - */ - - /* XXX we need to be able to parse uniform names for structs and arrays - * such as: - * mymatrix[1] - * mystruct.field1 - */ - - { - /* handle 1-dimension arrays here... */ - char *c = strchr(name, '['); - if (c) { - /* truncate name at [ */ - const GLint len = c - name; - GLchar *newName = malloc(len + 1); - if (!newName) - return -1; /* out of mem */ - memcpy(newName, name, len); - newName[len] = 0; - - location = _mesa_lookup_uniform(shProg->Uniforms, newName); - if (location >= 0) { - const GLint element = atoi(c + 1); - if (element > 0) { - /* get type of the uniform array element */ - const struct gl_program_parameter *p = - get_uniform_parameter(shProg, location); - if (p) { - GLint rows, cols; - get_matrix_dims(p->DataType, &rows, &cols); - if (rows < 1) - rows = 1; - offset = element * rows; - } - } - } - - free(newName); - } - } - - if (location < 0) { - location = _mesa_lookup_uniform(shProg->Uniforms, name); - } - - if (location >= 0) { - merge_location_offset(&location, offset); - } - - return location; -} - - - -/** - * Update the vertex/fragment program's TexturesUsed array. - * - * This needs to be called after glUniform(set sampler var) is called. - * A call to glUniform(samplerVar, value) causes a sampler to point to a - * particular texture unit. We know the sampler's texture target - * (1D/2D/3D/etc) from compile time but the sampler's texture unit is - * set by glUniform() calls. - * - * So, scan the program->SamplerUnits[] and program->SamplerTargets[] - * information to update the prog->TexturesUsed[] values. - * Each value of TexturesUsed[unit] is one of zero, TEXTURE_1D_INDEX, - * TEXTURE_2D_INDEX, TEXTURE_3D_INDEX, etc. - * We'll use that info for state validation before rendering. - */ -void -_mesa_update_shader_textures_used(struct gl_program *prog) -{ - GLuint s; - - memset(prog->TexturesUsed, 0, sizeof(prog->TexturesUsed)); - - for (s = 0; s < MAX_SAMPLERS; s++) { - if (prog->SamplersUsed & (1 << s)) { - GLuint unit = prog->SamplerUnits[s]; - GLuint tgt = prog->SamplerTargets[s]; - assert(unit < Elements(prog->TexturesUsed)); - assert(tgt < NUM_TEXTURE_TARGETS); - prog->TexturesUsed[unit] |= (1 << tgt); - } - } -} - - -/** - * Check if the type given by userType is allowed to set a uniform of the - * target type. Generally, equivalence is required, but setting Boolean - * uniforms can be done with glUniformiv or glUniformfv. - */ -static GLboolean -compatible_types(GLenum userType, GLenum targetType) -{ - if (userType == targetType) - return GL_TRUE; - - if (targetType == GL_BOOL && (userType == GL_FLOAT || - userType == GL_UNSIGNED_INT || - userType == GL_INT)) - return GL_TRUE; - - if (targetType == GL_BOOL_VEC2 && (userType == GL_FLOAT_VEC2 || - userType == GL_UNSIGNED_INT_VEC2 || - userType == GL_INT_VEC2)) - return GL_TRUE; - - if (targetType == GL_BOOL_VEC3 && (userType == GL_FLOAT_VEC3 || - userType == GL_UNSIGNED_INT_VEC3 || - userType == GL_INT_VEC3)) - return GL_TRUE; - - if (targetType == GL_BOOL_VEC4 && (userType == GL_FLOAT_VEC4 || - userType == GL_UNSIGNED_INT_VEC4 || - userType == GL_INT_VEC4)) - return GL_TRUE; - - if (is_sampler_type(targetType) && userType == GL_INT) - return GL_TRUE; - - return GL_FALSE; -} - - -/** - * Set the value of a program's uniform variable. - * \param program the program whose uniform to update - * \param index the index of the program parameter for the uniform - * \param offset additional parameter slot offset (for arrays) - * \param type the incoming datatype of 'values' - * \param count the number of uniforms to set - * \param elems number of elements per uniform (1, 2, 3 or 4) - * \param values the new values, of datatype 'type' - */ -static void -set_program_uniform(struct gl_context *ctx, struct gl_program *program, - GLint index, GLint offset, - GLenum type, GLsizei count, GLint elems, - const void *values) -{ - const struct gl_program_parameter *param = - &program->Parameters->Parameters[index]; - - assert(offset >= 0); - assert(elems >= 1); - assert(elems <= 4); - - if (!compatible_types(type, param->DataType)) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glUniform(type mismatch)"); - return; - } - - if (index + offset > (GLint) program->Parameters->Size) { - /* out of bounds! */ - return; - } - - if (param->Type == PROGRAM_SAMPLER) { - /* This controls which texture unit which is used by a sampler */ - GLboolean changed = GL_FALSE; - GLint i; - - /* this should have been caught by the compatible_types() check */ - ASSERT(type == GL_INT); - - /* loop over number of samplers to change */ - for (i = 0; i < count; i++) { - GLuint sampler = (GLuint) - program->Parameters->ParameterValues[index+offset + i][0].f; - GLuint texUnit = ((GLuint *) values)[i]; - - /* check that the sampler (tex unit index) is legal */ - if (texUnit >= ctx->Const.MaxCombinedTextureImageUnits) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glUniform1(invalid sampler/tex unit index for '%s')", - param->Name); - return; - } - - /* This maps a sampler to a texture unit: */ - if (sampler < MAX_SAMPLERS) { -#if 0 - printf("Set program %p sampler %d '%s' to unit %u\n", - program, sampler, param->Name, texUnit); -#endif - if (program->SamplerUnits[sampler] != texUnit) { - program->SamplerUnits[sampler] = texUnit; - changed = GL_TRUE; - } - } - } - - if (changed) { - /* When a sampler's value changes it usually requires rewriting - * a GPU program's TEX instructions since there may not be a - * sampler->texture lookup table. We signal this with the - * ProgramStringNotify() callback. - */ - FLUSH_VERTICES(ctx, _NEW_TEXTURE | _NEW_PROGRAM); - _mesa_update_shader_textures_used(program); - /* Do we need to care about the return value here? - * This should not be the first time the driver was notified of - * this program. - */ - (void) ctx->Driver.ProgramStringNotify(ctx, program->Target, program); - } - } - else { - /* ordinary uniform variable */ - const GLboolean isUniformBool = is_boolean_type(param->DataType); - const GLenum basicType = base_uniform_type(type); - const GLint slots = (param->Size + 3) / 4; - const GLint typeSize = _mesa_sizeof_glsl_type(param->DataType); - GLsizei k, i; - - if ((GLint) param->Size > typeSize) { - /* an array */ - /* we'll ignore extra data below */ - } - else { - /* non-array: count must be at most one; count == 0 is handled - * by the loop below - */ - if (count > 1) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glUniform(uniform '%s' is not an array)", - param->Name); - return; - } - } - - /* loop over number of array elements */ - for (k = 0; k < count; k++) { - gl_constant_value *uniformVal; - - if (offset + k >= slots) { - /* Extra array data is ignored */ - break; - } - - /* uniformVal (the destination) is always gl_constant_value[4] */ - uniformVal = program->Parameters->ParameterValues[index + offset + k]; - - if (basicType == GL_INT) { - const GLint *iValues = ((const GLint *) values) + k * elems; - for (i = 0; i < elems; i++) { - if (!ctx->Const.NativeIntegers) - uniformVal[i].f = (GLfloat) iValues[i]; - else - uniformVal[i].i = iValues[i]; - } - } - else if (basicType == GL_UNSIGNED_INT) { - const GLuint *iValues = ((const GLuint *) values) + k * elems; - for (i = 0; i < elems; i++) { - if (!ctx->Const.NativeIntegers) - uniformVal[i].f = (GLfloat)(GLuint) iValues[i]; - else - uniformVal[i].u = iValues[i]; - } - } - else { - const GLfloat *fValues = ((const GLfloat *) values) + k * elems; - assert(basicType == GL_FLOAT); - for (i = 0; i < elems; i++) { - uniformVal[i].f = fValues[i]; - } - } - - /* if the uniform is bool-valued, convert to 1 or 0 */ - if (isUniformBool) { - for (i = 0; i < elems; i++) { - if (basicType == GL_FLOAT) - uniformVal[i].b = uniformVal[i].f != 0.0f ? 1 : 0; - else - uniformVal[i].b = uniformVal[i].u ? 1 : 0; - - if (ctx->Const.NativeIntegers) - uniformVal[i].u = - uniformVal[i].b ? ctx->Const.UniformBooleanTrue : 0; - else - uniformVal[i].f = uniformVal[i].b ? 1.0f : 0.0f; - } - } - } - } -} - - -/** - * Called via glUniform*() functions. - */ -void -_mesa_uniform(struct gl_context *ctx, struct gl_shader_program *shProg, - GLint location, GLsizei count, - const GLvoid *values, GLenum type) -{ - struct gl_uniform *uniform; - GLint elems, offset; - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (!shProg || !shProg->LinkStatus) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glUniform(program not linked)"); - return; - } - - if (location == -1) - return; /* The standard specifies this as a no-op */ - - if (location < -1) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glUniform(location=%d)", - location); - return; - } - - split_location_offset(&location, &offset); - - if (location < 0 || location >= (GLint) shProg->Uniforms->NumUniforms) { - _mesa_error(ctx, GL_INVALID_VALUE, "glUniform(location=%d)", location); - return; - } - - if (count < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glUniform(count < 0)"); - return; - } - - elems = _mesa_sizeof_glsl_type(type); - - FLUSH_VERTICES(ctx, _NEW_PROGRAM_CONSTANTS); - - uniform = &shProg->Uniforms->Uniforms[location]; - - if (ctx->Shader.Flags & GLSL_UNIFORMS) { - const GLenum basicType = base_uniform_type(type); - GLint i; - printf("Mesa: set program %u uniform %s (loc %d) to: ", - shProg->Name, uniform->Name, location); - if (basicType == GL_INT) { - const GLint *v = (const GLint *) values; - for (i = 0; i < count * elems; i++) { - printf("%d ", v[i]); - } - } - else if (basicType == GL_UNSIGNED_INT) { - const GLuint *v = (const GLuint *) values; - for (i = 0; i < count * elems; i++) { - printf("%u ", v[i]); - } - } - else { - const GLfloat *v = (const GLfloat *) values; - assert(basicType == GL_FLOAT); - for (i = 0; i < count * elems; i++) { - printf("%g ", v[i]); - } - } - printf("\n"); - } - - /* A uniform var may be used by both a vertex shader and a fragment - * shader. We may need to update one or both shader's uniform here: - */ - if (shProg->VertexProgram) { - /* convert uniform location to program parameter index */ - GLint index = uniform->VertPos; - if (index >= 0) { - set_program_uniform(ctx, &shProg->VertexProgram->Base, - index, offset, type, count, elems, values); - } - } - - if (shProg->FragmentProgram) { - /* convert uniform location to program parameter index */ - GLint index = uniform->FragPos; - if (index >= 0) { - set_program_uniform(ctx, &shProg->FragmentProgram->Base, - index, offset, type, count, elems, values); - } - } - - if (shProg->GeometryProgram) { - /* convert uniform location to program parameter index */ - GLint index = uniform->GeomPos; - if (index >= 0) { - set_program_uniform(ctx, &shProg->GeometryProgram->Base, - index, offset, type, count, elems, values); - } - } - - uniform->Initialized = GL_TRUE; -} - - -/** - * Set a matrix-valued program parameter. - */ -static void -set_program_uniform_matrix(struct gl_context *ctx, struct gl_program *program, - GLuint index, GLuint offset, - GLuint count, GLuint rows, GLuint cols, - GLboolean transpose, const GLfloat *values) -{ - GLuint mat, row, col; - GLuint src = 0; - const struct gl_program_parameter *param = - &program->Parameters->Parameters[index]; - const GLuint slots = (param->Size + 3) / 4; - const GLint typeSize = _mesa_sizeof_glsl_type(param->DataType); - GLint nr, nc; - - /* check that the number of rows, columns is correct */ - get_matrix_dims(param->DataType, &nr, &nc); - if (rows != nr || cols != nc) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glUniformMatrix(matrix size mismatch)"); - return; - } - - if ((GLint) param->Size <= typeSize) { - /* non-array: count must be at most one; count == 0 is handled - * by the loop below - */ - if (count > 1) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glUniformMatrix(uniform is not an array)"); - return; - } - } - - /* - * Note: the _columns_ of a matrix are stored in program registers, not - * the rows. So, the loops below look a little funny. - * XXX could optimize this a bit... - */ - - /* loop over matrices */ - for (mat = 0; mat < count; mat++) { - - /* each matrix: */ - for (col = 0; col < cols; col++) { - GLfloat *v; - if (offset >= slots) { - /* Ignore writes beyond the end of (the used part of) an array */ - return; - } - v = (GLfloat *) program->Parameters->ParameterValues[index + offset]; - for (row = 0; row < rows; row++) { - if (transpose) { - v[row] = values[src + row * cols + col]; - } - else { - v[row] = values[src + col * rows + row]; - } - } - - offset++; - } - - src += rows * cols; /* next matrix */ - } -} - - -/** - * Called by glUniformMatrix*() functions. - * Note: cols=2, rows=4 ==> array[2] of vec4 - */ -void -_mesa_uniform_matrix(struct gl_context *ctx, struct gl_shader_program *shProg, - GLint cols, GLint rows, - GLint location, GLsizei count, - GLboolean transpose, const GLfloat *values) -{ - struct gl_uniform *uniform; - GLint offset; - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (!shProg || !shProg->LinkStatus) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glUniformMatrix(program not linked)"); - return; - } - - if (location == -1) - return; /* The standard specifies this as a no-op */ - - if (location < -1) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glUniformMatrix(location)"); - return; - } - - split_location_offset(&location, &offset); - - if (location < 0 || location >= (GLint) shProg->Uniforms->NumUniforms) { - _mesa_error(ctx, GL_INVALID_VALUE, "glUniformMatrix(location)"); - return; - } - if (values == NULL) { - _mesa_error(ctx, GL_INVALID_VALUE, "glUniformMatrix"); - return; - } - - FLUSH_VERTICES(ctx, _NEW_PROGRAM_CONSTANTS); - - uniform = &shProg->Uniforms->Uniforms[location]; - - if (shProg->VertexProgram) { - /* convert uniform location to program parameter index */ - GLint index = uniform->VertPos; - if (index >= 0) { - set_program_uniform_matrix(ctx, &shProg->VertexProgram->Base, - index, offset, - count, rows, cols, transpose, values); - } - } - - if (shProg->FragmentProgram) { - /* convert uniform location to program parameter index */ - GLint index = uniform->FragPos; - if (index >= 0) { - set_program_uniform_matrix(ctx, &shProg->FragmentProgram->Base, - index, offset, - count, rows, cols, transpose, values); - } - } - - if (shProg->GeometryProgram) { - /* convert uniform location to program parameter index */ - GLint index = uniform->GeomPos; - if (index >= 0) { - set_program_uniform_matrix(ctx, &shProg->GeometryProgram->Base, - index, offset, - count, rows, cols, transpose, values); - } - } - - uniform->Initialized = GL_TRUE; -} - - -void GLAPIENTRY -_mesa_Uniform1fARB(GLint location, GLfloat v0) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, 1, &v0, GL_FLOAT); -} - -void GLAPIENTRY -_mesa_Uniform2fARB(GLint location, GLfloat v0, GLfloat v1) -{ - GET_CURRENT_CONTEXT(ctx); - GLfloat v[2]; - v[0] = v0; - v[1] = v1; - _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, 1, v, GL_FLOAT_VEC2); -} - -void GLAPIENTRY -_mesa_Uniform3fARB(GLint location, GLfloat v0, GLfloat v1, GLfloat v2) -{ - GET_CURRENT_CONTEXT(ctx); - GLfloat v[3]; - v[0] = v0; - v[1] = v1; - v[2] = v2; - _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, 1, v, GL_FLOAT_VEC3); -} - -void GLAPIENTRY -_mesa_Uniform4fARB(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, - GLfloat v3) -{ - GET_CURRENT_CONTEXT(ctx); - GLfloat v[4]; - v[0] = v0; - v[1] = v1; - v[2] = v2; - v[3] = v3; - _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, 1, v, GL_FLOAT_VEC4); -} - -void GLAPIENTRY -_mesa_Uniform1iARB(GLint location, GLint v0) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, 1, &v0, GL_INT); -} - -void GLAPIENTRY -_mesa_Uniform2iARB(GLint location, GLint v0, GLint v1) -{ - GET_CURRENT_CONTEXT(ctx); - GLint v[2]; - v[0] = v0; - v[1] = v1; - _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, 1, v, GL_INT_VEC2); -} - -void GLAPIENTRY -_mesa_Uniform3iARB(GLint location, GLint v0, GLint v1, GLint v2) -{ - GET_CURRENT_CONTEXT(ctx); - GLint v[3]; - v[0] = v0; - v[1] = v1; - v[2] = v2; - _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, 1, v, GL_INT_VEC3); -} - -void GLAPIENTRY -_mesa_Uniform4iARB(GLint location, GLint v0, GLint v1, GLint v2, GLint v3) -{ - GET_CURRENT_CONTEXT(ctx); - GLint v[4]; - v[0] = v0; - v[1] = v1; - v[2] = v2; - v[3] = v3; - _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, 1, v, GL_INT_VEC4); -} - -void GLAPIENTRY -_mesa_Uniform1fvARB(GLint location, GLsizei count, const GLfloat * value) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, count, value, GL_FLOAT); -} - -void GLAPIENTRY -_mesa_Uniform2fvARB(GLint location, GLsizei count, const GLfloat * value) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, count, value, GL_FLOAT_VEC2); -} - -void GLAPIENTRY -_mesa_Uniform3fvARB(GLint location, GLsizei count, const GLfloat * value) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, count, value, GL_FLOAT_VEC3); -} - -void GLAPIENTRY -_mesa_Uniform4fvARB(GLint location, GLsizei count, const GLfloat * value) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, count, value, GL_FLOAT_VEC4); -} - -void GLAPIENTRY -_mesa_Uniform1ivARB(GLint location, GLsizei count, const GLint * value) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, count, value, GL_INT); -} - -void GLAPIENTRY -_mesa_Uniform2ivARB(GLint location, GLsizei count, const GLint * value) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, count, value, GL_INT_VEC2); -} - -void GLAPIENTRY -_mesa_Uniform3ivARB(GLint location, GLsizei count, const GLint * value) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, count, value, GL_INT_VEC3); -} - -void GLAPIENTRY -_mesa_Uniform4ivARB(GLint location, GLsizei count, const GLint * value) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, count, value, GL_INT_VEC4); -} - - -/** OpenGL 3.0 GLuint-valued functions **/ -void GLAPIENTRY -_mesa_Uniform1ui(GLint location, GLuint v0) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, 1, &v0, GL_UNSIGNED_INT); -} - -void GLAPIENTRY -_mesa_Uniform2ui(GLint location, GLuint v0, GLuint v1) -{ - GET_CURRENT_CONTEXT(ctx); - GLuint v[2]; - v[0] = v0; - v[1] = v1; - _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, 1, v, GL_UNSIGNED_INT_VEC2); -} - -void GLAPIENTRY -_mesa_Uniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2) -{ - GET_CURRENT_CONTEXT(ctx); - GLuint v[3]; - v[0] = v0; - v[1] = v1; - v[2] = v2; - _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, 1, v, GL_UNSIGNED_INT_VEC3); -} - -void GLAPIENTRY -_mesa_Uniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3) -{ - GET_CURRENT_CONTEXT(ctx); - GLuint v[4]; - v[0] = v0; - v[1] = v1; - v[2] = v2; - v[3] = v3; - _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, 1, v, GL_UNSIGNED_INT_VEC4); -} - -void GLAPIENTRY -_mesa_Uniform1uiv(GLint location, GLsizei count, const GLuint *value) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, count, value, GL_UNSIGNED_INT); -} - -void GLAPIENTRY -_mesa_Uniform2uiv(GLint location, GLsizei count, const GLuint *value) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, count, value, GL_UNSIGNED_INT_VEC2); -} - -void GLAPIENTRY -_mesa_Uniform3uiv(GLint location, GLsizei count, const GLuint *value) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, count, value, GL_UNSIGNED_INT_VEC3); -} - -void GLAPIENTRY -_mesa_Uniform4uiv(GLint location, GLsizei count, const GLuint *value) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, count, value, GL_UNSIGNED_INT_VEC4); -} - - - -void GLAPIENTRY -_mesa_UniformMatrix2fvARB(GLint location, GLsizei count, GLboolean transpose, - const GLfloat * value) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_uniform_matrix(ctx, ctx->Shader.ActiveProgram, - 2, 2, location, count, transpose, value); -} - -void GLAPIENTRY -_mesa_UniformMatrix3fvARB(GLint location, GLsizei count, GLboolean transpose, - const GLfloat * value) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_uniform_matrix(ctx, ctx->Shader.ActiveProgram, - 3, 3, location, count, transpose, value); -} - -void GLAPIENTRY -_mesa_UniformMatrix4fvARB(GLint location, GLsizei count, GLboolean transpose, - const GLfloat * value) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_uniform_matrix(ctx, ctx->Shader.ActiveProgram, - 4, 4, location, count, transpose, value); -} - - -/** - * Non-square UniformMatrix are OpenGL 2.1 - */ -void GLAPIENTRY -_mesa_UniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, - const GLfloat *value) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_uniform_matrix(ctx, ctx->Shader.ActiveProgram, - 2, 3, location, count, transpose, value); -} - -void GLAPIENTRY -_mesa_UniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, - const GLfloat *value) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_uniform_matrix(ctx, ctx->Shader.ActiveProgram, - 3, 2, location, count, transpose, value); -} - -void GLAPIENTRY -_mesa_UniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, - const GLfloat *value) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_uniform_matrix(ctx, ctx->Shader.ActiveProgram, - 2, 4, location, count, transpose, value); -} - -void GLAPIENTRY -_mesa_UniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, - const GLfloat *value) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_uniform_matrix(ctx, ctx->Shader.ActiveProgram, - 4, 2, location, count, transpose, value); -} - -void GLAPIENTRY -_mesa_UniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, - const GLfloat *value) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_uniform_matrix(ctx, ctx->Shader.ActiveProgram, - 3, 4, location, count, transpose, value); -} - -void GLAPIENTRY -_mesa_UniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, - const GLfloat *value) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_uniform_matrix(ctx, ctx->Shader.ActiveProgram, - 4, 3, location, count, transpose, value); -} - - -void GLAPIENTRY -_mesa_GetnUniformfvARB(GLhandleARB program, GLint location, - GLsizei bufSize, GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - get_uniform(ctx, program, location, bufSize, GL_FLOAT, params); -} - -void GLAPIENTRY -_mesa_GetUniformfvARB(GLhandleARB program, GLint location, GLfloat *params) -{ - _mesa_GetnUniformfvARB(program, location, INT_MAX, params); -} - - -void GLAPIENTRY -_mesa_GetnUniformivARB(GLhandleARB program, GLint location, - GLsizei bufSize, GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - get_uniform(ctx, program, location, bufSize, GL_INT, params); -} - -void GLAPIENTRY -_mesa_GetUniformivARB(GLhandleARB program, GLint location, GLint *params) -{ - _mesa_GetnUniformivARB(program, location, INT_MAX, params); -} - - -/* GL3 */ -void GLAPIENTRY -_mesa_GetnUniformuivARB(GLhandleARB program, GLint location, - GLsizei bufSize, GLuint *params) -{ - GET_CURRENT_CONTEXT(ctx); - get_uniform(ctx, program, location, bufSize, GL_UNSIGNED_INT, params); -} - -void GLAPIENTRY -_mesa_GetUniformuiv(GLhandleARB program, GLint location, GLuint *params) -{ - _mesa_GetnUniformuivARB(program, location, INT_MAX, params); -} - - -/* GL4 */ -void GLAPIENTRY -_mesa_GetnUniformdvARB(GLhandleARB program, GLint location, - GLsizei bufSize, GLdouble *params) -{ - GET_CURRENT_CONTEXT(ctx); - /* - get_uniform(ctx, program, location, bufSize, GL_DOUBLE, params); - */ - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetUniformdvARB" - "(GL_ARB_gpu_shader_fp64 not implemented)"); -} - -void GLAPIENTRY -_mesa_GetUniformdv(GLhandleARB program, GLint location, GLdouble *params) -{ - _mesa_GetnUniformdvARB(program, location, INT_MAX, params); -} - - -GLint GLAPIENTRY -_mesa_GetUniformLocationARB(GLhandleARB programObj, const GLcharARB *name) -{ - struct gl_shader_program *shProg; - - GET_CURRENT_CONTEXT(ctx); - - shProg = _mesa_lookup_shader_program_err(ctx, programObj, - "glGetUniformLocation"); - if (!shProg) - return -1; - - return _mesa_get_uniform_location(ctx, shProg, name); -} - - -void GLAPIENTRY -_mesa_GetActiveUniformARB(GLhandleARB program, GLuint index, - GLsizei maxLength, GLsizei * length, GLint * size, - GLenum * type, GLcharARB * name) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_get_active_uniform(ctx, program, index, maxLength, length, size, - type, name); -} - - -/** - * Plug in shader uniform-related functions into API dispatch table. - */ -void -_mesa_init_shader_uniform_dispatch(struct _glapi_table *exec) -{ -#if FEATURE_GL - SET_Uniform1fARB(exec, _mesa_Uniform1fARB); - SET_Uniform2fARB(exec, _mesa_Uniform2fARB); - SET_Uniform3fARB(exec, _mesa_Uniform3fARB); - SET_Uniform4fARB(exec, _mesa_Uniform4fARB); - SET_Uniform1iARB(exec, _mesa_Uniform1iARB); - SET_Uniform2iARB(exec, _mesa_Uniform2iARB); - SET_Uniform3iARB(exec, _mesa_Uniform3iARB); - SET_Uniform4iARB(exec, _mesa_Uniform4iARB); - SET_Uniform1fvARB(exec, _mesa_Uniform1fvARB); - SET_Uniform2fvARB(exec, _mesa_Uniform2fvARB); - SET_Uniform3fvARB(exec, _mesa_Uniform3fvARB); - SET_Uniform4fvARB(exec, _mesa_Uniform4fvARB); - SET_Uniform1ivARB(exec, _mesa_Uniform1ivARB); - SET_Uniform2ivARB(exec, _mesa_Uniform2ivARB); - SET_Uniform3ivARB(exec, _mesa_Uniform3ivARB); - SET_Uniform4ivARB(exec, _mesa_Uniform4ivARB); - SET_UniformMatrix2fvARB(exec, _mesa_UniformMatrix2fvARB); - SET_UniformMatrix3fvARB(exec, _mesa_UniformMatrix3fvARB); - SET_UniformMatrix4fvARB(exec, _mesa_UniformMatrix4fvARB); - - SET_GetActiveUniformARB(exec, _mesa_GetActiveUniformARB); - SET_GetUniformLocationARB(exec, _mesa_GetUniformLocationARB); - SET_GetUniformfvARB(exec, _mesa_GetUniformfvARB); - SET_GetUniformivARB(exec, _mesa_GetUniformivARB); - - /* OpenGL 2.1 */ - SET_UniformMatrix2x3fv(exec, _mesa_UniformMatrix2x3fv); - SET_UniformMatrix3x2fv(exec, _mesa_UniformMatrix3x2fv); - SET_UniformMatrix2x4fv(exec, _mesa_UniformMatrix2x4fv); - SET_UniformMatrix4x2fv(exec, _mesa_UniformMatrix4x2fv); - SET_UniformMatrix3x4fv(exec, _mesa_UniformMatrix3x4fv); - SET_UniformMatrix4x3fv(exec, _mesa_UniformMatrix4x3fv); - - /* OpenGL 3.0 */ - SET_Uniform1uiEXT(exec, _mesa_Uniform1ui); - SET_Uniform2uiEXT(exec, _mesa_Uniform2ui); - SET_Uniform3uiEXT(exec, _mesa_Uniform3ui); - SET_Uniform4uiEXT(exec, _mesa_Uniform4ui); - SET_Uniform1uivEXT(exec, _mesa_Uniform1uiv); - SET_Uniform2uivEXT(exec, _mesa_Uniform2uiv); - SET_Uniform3uivEXT(exec, _mesa_Uniform3uiv); - SET_Uniform4uivEXT(exec, _mesa_Uniform4uiv); - SET_GetUniformuivEXT(exec, _mesa_GetUniformuiv); - - /* GL_ARB_robustness */ - SET_GetnUniformfvARB(exec, _mesa_GetnUniformfvARB); - SET_GetnUniformivARB(exec, _mesa_GetnUniformivARB); - SET_GetnUniformuivARB(exec, _mesa_GetnUniformuivARB); - SET_GetnUniformdvARB(exec, _mesa_GetnUniformdvARB); /* GL 4.0 */ - -#endif /* FEATURE_GL */ -} +/* + * Mesa 3-D graphics library + * + * Copyright (C) 2004-2008 Brian Paul All Rights Reserved. + * Copyright (C) 2009-2010 VMware, Inc. All Rights Reserved. + * Copyright © 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. + */ + +/** + * \file uniforms.c + * Functions related to GLSL uniform variables. + * \author Brian Paul + */ + +/** + * XXX things to do: + * 1. Check that the right error code is generated for all _mesa_error() calls. + * 2. Insert FLUSH_VERTICES calls in various places + */ + + +#include "main/glheader.h" +#include "main/context.h" +#include "main/dispatch.h" +#include "main/image.h" +#include "main/mfeatures.h" +#include "main/mtypes.h" +#include "main/shaderapi.h" +#include "main/shaderobj.h" +#include "main/uniforms.h" +#include "program/prog_parameter.h" +#include "program/prog_statevars.h" +#include "program/prog_uniform.h" +#include "program/prog_instruction.h" + + +static GLenum +base_uniform_type(GLenum type) +{ + switch (type) { + case GL_BOOL: + case GL_BOOL_VEC2: + case GL_BOOL_VEC3: + case GL_BOOL_VEC4: + return GL_BOOL; + case GL_FLOAT: + case GL_FLOAT_VEC2: + case GL_FLOAT_VEC3: + case GL_FLOAT_VEC4: + case GL_FLOAT_MAT2: + case GL_FLOAT_MAT2x3: + case GL_FLOAT_MAT2x4: + case GL_FLOAT_MAT3x2: + case GL_FLOAT_MAT3: + case GL_FLOAT_MAT3x4: + case GL_FLOAT_MAT4x2: + case GL_FLOAT_MAT4x3: + case GL_FLOAT_MAT4: + return GL_FLOAT; + case GL_UNSIGNED_INT: + case GL_UNSIGNED_INT_VEC2: + case GL_UNSIGNED_INT_VEC3: + case GL_UNSIGNED_INT_VEC4: + return GL_UNSIGNED_INT; + case GL_INT: + case GL_INT_VEC2: + case GL_INT_VEC3: + case GL_INT_VEC4: + return GL_INT; + default: + _mesa_problem(NULL, "Invalid type in base_uniform_type()"); + return GL_FLOAT; + } +} + + +static GLboolean +is_boolean_type(GLenum type) +{ + switch (type) { + case GL_BOOL: + case GL_BOOL_VEC2: + case GL_BOOL_VEC3: + case GL_BOOL_VEC4: + return GL_TRUE; + default: + return GL_FALSE; + } +} + + +static GLboolean +is_sampler_type(GLenum type) +{ + switch (type) { + case GL_SAMPLER_1D: + case GL_SAMPLER_2D: + case GL_SAMPLER_3D: + case GL_SAMPLER_CUBE: + case GL_SAMPLER_1D_SHADOW: + case GL_SAMPLER_2D_SHADOW: + case GL_SAMPLER_CUBE_SHADOW: + case GL_SAMPLER_2D_RECT_ARB: + case GL_SAMPLER_2D_RECT_SHADOW_ARB: + case GL_SAMPLER_1D_ARRAY_EXT: + case GL_SAMPLER_2D_ARRAY_EXT: + case GL_SAMPLER_1D_ARRAY_SHADOW_EXT: + case GL_SAMPLER_2D_ARRAY_SHADOW_EXT: + case GL_SAMPLER_CUBE_MAP_ARRAY: + case GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW: + case GL_SAMPLER_BUFFER: + return GL_TRUE; + default: + return GL_FALSE; + } +} + + +/** + * Given a uniform index, return the vertex/geometry/fragment program + * that has that parameter, plus the position of the parameter in the + * parameter/constant buffer. + * \param shProg the shader program + * \param index the uniform index in [0, NumUniforms-1] + * \param progOut returns containing program + * \param posOut returns position of the uniform in the param/const buffer + * \return GL_TRUE for success, GL_FALSE for invalid index + */ +static GLboolean +find_uniform_parameter_pos(struct gl_shader_program *shProg, GLint index, + struct gl_program **progOut, GLint *posOut) +{ + struct gl_program *prog = NULL; + GLint pos; + + if (!shProg->Uniforms || + index < 0 || + index >= (GLint) shProg->Uniforms->NumUniforms) { + return GL_FALSE; + } + + pos = shProg->Uniforms->Uniforms[index].VertPos; + if (pos >= 0) { + prog = &shProg->VertexProgram->Base; + } + else { + pos = shProg->Uniforms->Uniforms[index].FragPos; + if (pos >= 0) { + prog = &shProg->FragmentProgram->Base; + } + else { + pos = shProg->Uniforms->Uniforms[index].GeomPos; + if (pos >= 0) { + prog = &shProg->GeometryProgram->Base; + } + } + } + + if (!prog || pos < 0) + return GL_FALSE; /* should really never happen */ + + *progOut = prog; + *posOut = pos; + + return GL_TRUE; +} + + +/** + * Return pointer to a gl_program_parameter which corresponds to a uniform. + * \param shProg the shader program + * \param index the uniform index in [0, NumUniforms-1] + * \return gl_program_parameter point or NULL if index is invalid + */ +static const struct gl_program_parameter * +get_uniform_parameter(struct gl_shader_program *shProg, GLint index) +{ + struct gl_program *prog; + GLint progPos; + + if (find_uniform_parameter_pos(shProg, index, &prog, &progPos)) + return &prog->Parameters->Parameters[progPos]; + else + return NULL; +} + + +/** + * Called by glGetActiveUniform(). + */ +static void +_mesa_get_active_uniform(struct gl_context *ctx, GLuint program, GLuint index, + GLsizei maxLength, GLsizei *length, GLint *size, + GLenum *type, GLchar *nameOut) +{ + struct gl_shader_program *shProg = + _mesa_lookup_shader_program_err(ctx, program, "glGetActiveUniform"); + const struct gl_program_parameter *param; + + if (!shProg) + return; + + if (!shProg->Uniforms || index >= shProg->Uniforms->NumUniforms) { + _mesa_error(ctx, GL_INVALID_VALUE, "glGetActiveUniform(index)"); + return; + } + + param = get_uniform_parameter(shProg, index); + if (!param) + return; + + if (nameOut) { + _mesa_copy_string(nameOut, maxLength, length, param->Name); + } + + if (size) { + GLint typeSize = _mesa_sizeof_glsl_type(param->DataType); + if ((GLint) param->Size > typeSize) { + /* This is an array. + * Array elements are placed on vector[4] boundaries so they're + * a multiple of four floats. We round typeSize up to next multiple + * of four to get the right size below. + */ + typeSize = (typeSize + 3) & ~3; + } + /* Note that the returned size is in units of the , not bytes */ + *size = param->Size / typeSize; + } + + if (type) { + *type = param->DataType; + } +} + + +static unsigned +get_vector_elements(GLenum type) +{ + switch (type) { + case GL_FLOAT: + case GL_INT: + case GL_BOOL: + case GL_UNSIGNED_INT: + default: /* Catch all the various sampler types. */ + return 1; + + case GL_FLOAT_VEC2: + case GL_INT_VEC2: + case GL_BOOL_VEC2: + case GL_UNSIGNED_INT_VEC2: + return 2; + + case GL_FLOAT_VEC3: + case GL_INT_VEC3: + case GL_BOOL_VEC3: + case GL_UNSIGNED_INT_VEC3: + return 3; + + case GL_FLOAT_VEC4: + case GL_INT_VEC4: + case GL_BOOL_VEC4: + case GL_UNSIGNED_INT_VEC4: + return 4; + } +} + +static void +get_matrix_dims(GLenum type, GLint *rows, GLint *cols) +{ + switch (type) { + case GL_FLOAT_MAT2: + *rows = *cols = 2; + break; + case GL_FLOAT_MAT2x3: + *rows = 3; + *cols = 2; + break; + case GL_FLOAT_MAT2x4: + *rows = 4; + *cols = 2; + break; + case GL_FLOAT_MAT3: + *rows = 3; + *cols = 3; + break; + case GL_FLOAT_MAT3x2: + *rows = 2; + *cols = 3; + break; + case GL_FLOAT_MAT3x4: + *rows = 4; + *cols = 3; + break; + case GL_FLOAT_MAT4: + *rows = 4; + *cols = 4; + break; + case GL_FLOAT_MAT4x2: + *rows = 2; + *cols = 4; + break; + case GL_FLOAT_MAT4x3: + *rows = 3; + *cols = 4; + break; + default: + *rows = *cols = 0; + } +} + + +/** + * Determine the number of rows and columns occupied by a uniform + * according to its datatype. For non-matrix types (such as GL_FLOAT_VEC4), + * the number of rows = 1 and cols = number of elements in the vector. + */ +static void +get_uniform_rows_cols(const struct gl_program_parameter *p, + GLint *rows, GLint *cols) +{ + get_matrix_dims(p->DataType, rows, cols); + if (*rows == 0 && *cols == 0) { + /* not a matrix type, probably a float or vector */ + *rows = 1; + *cols = get_vector_elements(p->DataType); + } +} + + +/** + * GLSL uniform arrays and structs require special handling. + * + * The GL_ARB_shader_objects spec says that if you use + * glGetUniformLocation to get the location of an array, you CANNOT + * access other elements of the array by adding an offset to the + * returned location. For example, you must call + * glGetUniformLocation("foo[16]") if you want to set the 16th element + * of the array with glUniform(). + * + * HOWEVER, some other OpenGL drivers allow accessing array elements + * by adding an offset to the returned array location. And some apps + * seem to depend on that behaviour. + * + * Mesa's gl_uniform_list doesn't directly support this since each + * entry in the list describes one uniform variable, not one uniform + * element. We could insert dummy entries in the list for each array + * element after [0] but that causes complications elsewhere. + * + * We solve this problem by encoding two values in the location that's + * returned by glGetUniformLocation(): + * a) index into gl_uniform_list::Uniforms[] for the uniform + * b) an array/field offset (0 for simple types) + * + * These two values are encoded in the high and low halves of a GLint. + * By putting the uniform number in the high part and the offset in the + * low part, we can support the unofficial ability to index into arrays + * by adding offsets to the location value. + */ +static void +merge_location_offset(GLint *location, GLint offset) +{ + *location = (*location << 16) | offset; +} + + +/** + * Separate the uniform location and parameter offset. See above. + */ +static void +split_location_offset(GLint *location, GLint *offset) +{ + *offset = *location & 0xffff; + *location = *location >> 16; +} + + + +/** + * Called via glGetUniform[fiui]v() to get the current value of a uniform. + */ +static void +get_uniform(struct gl_context *ctx, GLuint program, GLint location, + GLsizei bufSize, GLenum returnType, GLvoid *paramsOut) +{ + struct gl_shader_program *shProg = + _mesa_lookup_shader_program_err(ctx, program, "glGetUniformfv"); + struct gl_program *prog; + GLint paramPos, offset; + + if (!shProg) + return; + + split_location_offset(&location, &offset); + + if (!find_uniform_parameter_pos(shProg, location, &prog, ¶mPos)) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glGetUniformfv(location)"); + } + else { + const struct gl_program_parameter *p = + &prog->Parameters->Parameters[paramPos]; + gl_constant_value (*values)[4]; + GLint rows, cols, i, j, k; + GLsizei numBytes; + GLenum storage_type; + + values = prog->Parameters->ParameterValues + paramPos + offset; + + get_uniform_rows_cols(p, &rows, &cols); + + numBytes = rows * cols * _mesa_sizeof_type(returnType); + if (bufSize < numBytes) { + _mesa_error( ctx, GL_INVALID_OPERATION, + "glGetnUniformfvARB(out of bounds: bufSize is %d," + " but %d bytes are required)", bufSize, numBytes ); + return; + } + + if (ctx->Const.NativeIntegers) { + storage_type = base_uniform_type(p->DataType); + } else { + storage_type = GL_FLOAT; + } + + k = 0; + for (i = 0; i < rows; i++) { + for (j = 0; j < cols; j++ ) { + void *out = (char *)paramsOut + 4 * k; + + switch (returnType) { + case GL_FLOAT: + switch (storage_type) { + case GL_FLOAT: + *(float *)out = values[i][j].f; + break; + case GL_INT: + case GL_BOOL: /* boolean is just an integer 1 or 0. */ + *(float *)out = values[i][j].i; + break; + case GL_UNSIGNED_INT: + *(float *)out = values[i][j].u; + break; + } + break; + + case GL_INT: + case GL_UNSIGNED_INT: + switch (storage_type) { + case GL_FLOAT: + /* While the GL 3.2 core spec doesn't explicitly + * state how conversion of float uniforms to integer + * values works, in section 6.2 "State Tables" on + * page 267 it says: + * + * "Unless otherwise specified, when floating + * point state is returned as integer values or + * integer state is returned as floating-point + * values it is converted in the fashion + * described in section 6.1.2" + * + * That section, on page 248, says: + * + * "If GetIntegerv or GetInteger64v are called, + * a floating-point value is rounded to the + * nearest integer..." + */ + *(int *)out = IROUND(values[i][j].f); + break; + + case GL_INT: + case GL_UNSIGNED_INT: + case GL_BOOL: + /* type conversions for these to int/uint are just + * copying the data. + */ + *(int *)out = values[i][j].i; + break; + break; + } + break; + } + + k++; + } + } + } +} + + +/** + * Called via glGetUniformLocation(). + * + * The return value will encode two values, the uniform location and an + * offset (used for arrays, structs). + */ +GLint +_mesa_get_uniform_location(struct gl_context *ctx, + struct gl_shader_program *shProg, + const GLchar *name) +{ + GLint offset = 0, location = -1; + + if (shProg->LinkStatus == GL_FALSE) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glGetUniformfv(program)"); + return -1; + } + + /* XXX we should return -1 if the uniform was declared, but not + * actually used. + */ + + /* XXX we need to be able to parse uniform names for structs and arrays + * such as: + * mymatrix[1] + * mystruct.field1 + */ + + { + /* handle 1-dimension arrays here... */ + char *c = strchr(name, '['); + if (c) { + /* truncate name at [ */ + const GLint len = c - name; + GLchar *newName = malloc(len + 1); + if (!newName) + return -1; /* out of mem */ + memcpy(newName, name, len); + newName[len] = 0; + + location = _mesa_lookup_uniform(shProg->Uniforms, newName); + if (location >= 0) { + const GLint element = atoi(c + 1); + if (element > 0) { + /* get type of the uniform array element */ + const struct gl_program_parameter *p = + get_uniform_parameter(shProg, location); + if (p) { + GLint rows, cols; + get_matrix_dims(p->DataType, &rows, &cols); + if (rows < 1) + rows = 1; + offset = element * rows; + } + } + } + + free(newName); + } + } + + if (location < 0) { + location = _mesa_lookup_uniform(shProg->Uniforms, name); + } + + if (location >= 0) { + merge_location_offset(&location, offset); + } + + return location; +} + + + +/** + * Update the vertex/fragment program's TexturesUsed array. + * + * This needs to be called after glUniform(set sampler var) is called. + * A call to glUniform(samplerVar, value) causes a sampler to point to a + * particular texture unit. We know the sampler's texture target + * (1D/2D/3D/etc) from compile time but the sampler's texture unit is + * set by glUniform() calls. + * + * So, scan the program->SamplerUnits[] and program->SamplerTargets[] + * information to update the prog->TexturesUsed[] values. + * Each value of TexturesUsed[unit] is one of zero, TEXTURE_1D_INDEX, + * TEXTURE_2D_INDEX, TEXTURE_3D_INDEX, etc. + * We'll use that info for state validation before rendering. + */ +void +_mesa_update_shader_textures_used(struct gl_program *prog) +{ + GLuint s; + + memset(prog->TexturesUsed, 0, sizeof(prog->TexturesUsed)); + + for (s = 0; s < MAX_SAMPLERS; s++) { + if (prog->SamplersUsed & (1 << s)) { + GLuint unit = prog->SamplerUnits[s]; + GLuint tgt = prog->SamplerTargets[s]; + assert(unit < Elements(prog->TexturesUsed)); + assert(tgt < NUM_TEXTURE_TARGETS); + prog->TexturesUsed[unit] |= (1 << tgt); + } + } +} + + +/** + * Check if the type given by userType is allowed to set a uniform of the + * target type. Generally, equivalence is required, but setting Boolean + * uniforms can be done with glUniformiv or glUniformfv. + */ +static GLboolean +compatible_types(GLenum userType, GLenum targetType) +{ + if (userType == targetType) + return GL_TRUE; + + if (targetType == GL_BOOL && (userType == GL_FLOAT || + userType == GL_UNSIGNED_INT || + userType == GL_INT)) + return GL_TRUE; + + if (targetType == GL_BOOL_VEC2 && (userType == GL_FLOAT_VEC2 || + userType == GL_UNSIGNED_INT_VEC2 || + userType == GL_INT_VEC2)) + return GL_TRUE; + + if (targetType == GL_BOOL_VEC3 && (userType == GL_FLOAT_VEC3 || + userType == GL_UNSIGNED_INT_VEC3 || + userType == GL_INT_VEC3)) + return GL_TRUE; + + if (targetType == GL_BOOL_VEC4 && (userType == GL_FLOAT_VEC4 || + userType == GL_UNSIGNED_INT_VEC4 || + userType == GL_INT_VEC4)) + return GL_TRUE; + + if (is_sampler_type(targetType) && userType == GL_INT) + return GL_TRUE; + + return GL_FALSE; +} + + +/** + * Set the value of a program's uniform variable. + * \param program the program whose uniform to update + * \param index the index of the program parameter for the uniform + * \param offset additional parameter slot offset (for arrays) + * \param type the incoming datatype of 'values' + * \param count the number of uniforms to set + * \param elems number of elements per uniform (1, 2, 3 or 4) + * \param values the new values, of datatype 'type' + */ +static void +set_program_uniform(struct gl_context *ctx, struct gl_program *program, + GLint index, GLint offset, + GLenum type, GLsizei count, GLint elems, + const void *values) +{ + const struct gl_program_parameter *param = + &program->Parameters->Parameters[index]; + + assert(offset >= 0); + assert(elems >= 1); + assert(elems <= 4); + + if (!compatible_types(type, param->DataType)) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glUniform(type mismatch)"); + return; + } + + if (index + offset > (GLint) program->Parameters->Size) { + /* out of bounds! */ + return; + } + + if (param->Type == PROGRAM_SAMPLER) { + /* This controls which texture unit which is used by a sampler */ + GLboolean changed = GL_FALSE; + GLint i; + + /* this should have been caught by the compatible_types() check */ + ASSERT(type == GL_INT); + + /* loop over number of samplers to change */ + for (i = 0; i < count; i++) { + GLuint sampler = (GLuint) + program->Parameters->ParameterValues[index+offset + i][0].f; + GLuint texUnit = ((GLuint *) values)[i]; + + /* check that the sampler (tex unit index) is legal */ + if (texUnit >= ctx->Const.MaxCombinedTextureImageUnits) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glUniform1(invalid sampler/tex unit index for '%s')", + param->Name); + return; + } + + /* This maps a sampler to a texture unit: */ + if (sampler < MAX_SAMPLERS) { +#if 0 + printf("Set program %p sampler %d '%s' to unit %u\n", + program, sampler, param->Name, texUnit); +#endif + if (program->SamplerUnits[sampler] != texUnit) { + program->SamplerUnits[sampler] = texUnit; + changed = GL_TRUE; + } + } + } + + if (changed) { + /* When a sampler's value changes it usually requires rewriting + * a GPU program's TEX instructions since there may not be a + * sampler->texture lookup table. We signal this with the + * ProgramStringNotify() callback. + */ + FLUSH_VERTICES(ctx, _NEW_TEXTURE | _NEW_PROGRAM); + _mesa_update_shader_textures_used(program); + /* Do we need to care about the return value here? + * This should not be the first time the driver was notified of + * this program. + */ + (void) ctx->Driver.ProgramStringNotify(ctx, program->Target, program); + } + } + else { + /* ordinary uniform variable */ + const GLboolean isUniformBool = is_boolean_type(param->DataType); + const GLenum basicType = base_uniform_type(type); + const GLint slots = (param->Size + 3) / 4; + const GLint typeSize = _mesa_sizeof_glsl_type(param->DataType); + GLsizei k, i; + + if ((GLint) param->Size > typeSize) { + /* an array */ + /* we'll ignore extra data below */ + } + else { + /* non-array: count must be at most one; count == 0 is handled + * by the loop below + */ + if (count > 1) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glUniform(uniform '%s' is not an array)", + param->Name); + return; + } + } + + /* loop over number of array elements */ + for (k = 0; k < count; k++) { + gl_constant_value *uniformVal; + + if (offset + k >= slots) { + /* Extra array data is ignored */ + break; + } + + /* uniformVal (the destination) is always gl_constant_value[4] */ + uniformVal = program->Parameters->ParameterValues[index + offset + k]; + + if (basicType == GL_INT) { + const GLint *iValues = ((const GLint *) values) + k * elems; + for (i = 0; i < elems; i++) { + if (!ctx->Const.NativeIntegers) + uniformVal[i].f = (GLfloat) iValues[i]; + else + uniformVal[i].i = iValues[i]; + } + } + else if (basicType == GL_UNSIGNED_INT) { + const GLuint *iValues = ((const GLuint *) values) + k * elems; + for (i = 0; i < elems; i++) { + if (!ctx->Const.NativeIntegers) + uniformVal[i].f = (GLfloat)(GLuint) iValues[i]; + else + uniformVal[i].u = iValues[i]; + } + } + else { + const GLfloat *fValues = ((const GLfloat *) values) + k * elems; + assert(basicType == GL_FLOAT); + for (i = 0; i < elems; i++) { + uniformVal[i].f = fValues[i]; + } + } + + /* if the uniform is bool-valued, convert to 1 or 0 */ + if (isUniformBool) { + for (i = 0; i < elems; i++) { + if (basicType == GL_FLOAT) + uniformVal[i].b = uniformVal[i].f != 0.0f ? 1 : 0; + else + uniformVal[i].b = uniformVal[i].u ? 1 : 0; + + if (ctx->Const.NativeIntegers) + uniformVal[i].u = + uniformVal[i].b ? ctx->Const.UniformBooleanTrue : 0; + else + uniformVal[i].f = uniformVal[i].b ? 1.0f : 0.0f; + } + } + } + } +} + + +/** + * Called via glUniform*() functions. + */ +void +_mesa_uniform(struct gl_context *ctx, struct gl_shader_program *shProg, + GLint location, GLsizei count, + const GLvoid *values, GLenum type) +{ + struct gl_uniform *uniform; + GLint elems, offset; + + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (!shProg || !shProg->LinkStatus) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glUniform(program not linked)"); + return; + } + + if (location == -1) + return; /* The standard specifies this as a no-op */ + + if (location < -1) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glUniform(location=%d)", + location); + return; + } + + split_location_offset(&location, &offset); + + if (location < 0 || location >= (GLint) shProg->Uniforms->NumUniforms) { + _mesa_error(ctx, GL_INVALID_VALUE, "glUniform(location=%d)", location); + return; + } + + if (count < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glUniform(count < 0)"); + return; + } + + elems = _mesa_sizeof_glsl_type(type); + + FLUSH_VERTICES(ctx, _NEW_PROGRAM_CONSTANTS); + + uniform = &shProg->Uniforms->Uniforms[location]; + + if (ctx->Shader.Flags & GLSL_UNIFORMS) { + const GLenum basicType = base_uniform_type(type); + GLint i; + printf("Mesa: set program %u uniform %s (loc %d) to: ", + shProg->Name, uniform->Name, location); + if (basicType == GL_INT) { + const GLint *v = (const GLint *) values; + for (i = 0; i < count * elems; i++) { + printf("%d ", v[i]); + } + } + else if (basicType == GL_UNSIGNED_INT) { + const GLuint *v = (const GLuint *) values; + for (i = 0; i < count * elems; i++) { + printf("%u ", v[i]); + } + } + else { + const GLfloat *v = (const GLfloat *) values; + assert(basicType == GL_FLOAT); + for (i = 0; i < count * elems; i++) { + printf("%g ", v[i]); + } + } + printf("\n"); + } + + /* A uniform var may be used by both a vertex shader and a fragment + * shader. We may need to update one or both shader's uniform here: + */ + if (shProg->VertexProgram) { + /* convert uniform location to program parameter index */ + GLint index = uniform->VertPos; + if (index >= 0) { + set_program_uniform(ctx, &shProg->VertexProgram->Base, + index, offset, type, count, elems, values); + } + } + + if (shProg->FragmentProgram) { + /* convert uniform location to program parameter index */ + GLint index = uniform->FragPos; + if (index >= 0) { + set_program_uniform(ctx, &shProg->FragmentProgram->Base, + index, offset, type, count, elems, values); + } + } + + if (shProg->GeometryProgram) { + /* convert uniform location to program parameter index */ + GLint index = uniform->GeomPos; + if (index >= 0) { + set_program_uniform(ctx, &shProg->GeometryProgram->Base, + index, offset, type, count, elems, values); + } + } + + uniform->Initialized = GL_TRUE; +} + + +/** + * Set a matrix-valued program parameter. + */ +static void +set_program_uniform_matrix(struct gl_context *ctx, struct gl_program *program, + GLuint index, GLuint offset, + GLuint count, GLuint rows, GLuint cols, + GLboolean transpose, const GLfloat *values) +{ + GLuint mat, row, col; + GLuint src = 0; + const struct gl_program_parameter *param = + &program->Parameters->Parameters[index]; + const GLuint slots = (param->Size + 3) / 4; + const GLint typeSize = _mesa_sizeof_glsl_type(param->DataType); + GLint nr, nc; + + /* check that the number of rows, columns is correct */ + get_matrix_dims(param->DataType, &nr, &nc); + if (rows != nr || cols != nc) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glUniformMatrix(matrix size mismatch)"); + return; + } + + if ((GLint) param->Size <= typeSize) { + /* non-array: count must be at most one; count == 0 is handled + * by the loop below + */ + if (count > 1) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glUniformMatrix(uniform is not an array)"); + return; + } + } + + /* + * Note: the _columns_ of a matrix are stored in program registers, not + * the rows. So, the loops below look a little funny. + * XXX could optimize this a bit... + */ + + /* loop over matrices */ + for (mat = 0; mat < count; mat++) { + + /* each matrix: */ + for (col = 0; col < cols; col++) { + GLfloat *v; + if (offset >= slots) { + /* Ignore writes beyond the end of (the used part of) an array */ + return; + } + v = (GLfloat *) program->Parameters->ParameterValues[index + offset]; + for (row = 0; row < rows; row++) { + if (transpose) { + v[row] = values[src + row * cols + col]; + } + else { + v[row] = values[src + col * rows + row]; + } + } + + offset++; + } + + src += rows * cols; /* next matrix */ + } +} + + +/** + * Called by glUniformMatrix*() functions. + * Note: cols=2, rows=4 ==> array[2] of vec4 + */ +void +_mesa_uniform_matrix(struct gl_context *ctx, struct gl_shader_program *shProg, + GLint cols, GLint rows, + GLint location, GLsizei count, + GLboolean transpose, const GLfloat *values) +{ + struct gl_uniform *uniform; + GLint offset; + + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (!shProg || !shProg->LinkStatus) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glUniformMatrix(program not linked)"); + return; + } + + if (location == -1) + return; /* The standard specifies this as a no-op */ + + if (location < -1) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glUniformMatrix(location)"); + return; + } + + split_location_offset(&location, &offset); + + if (location < 0 || location >= (GLint) shProg->Uniforms->NumUniforms) { + _mesa_error(ctx, GL_INVALID_VALUE, "glUniformMatrix(location)"); + return; + } + if (values == NULL) { + _mesa_error(ctx, GL_INVALID_VALUE, "glUniformMatrix"); + return; + } + + FLUSH_VERTICES(ctx, _NEW_PROGRAM_CONSTANTS); + + uniform = &shProg->Uniforms->Uniforms[location]; + + if (shProg->VertexProgram) { + /* convert uniform location to program parameter index */ + GLint index = uniform->VertPos; + if (index >= 0) { + set_program_uniform_matrix(ctx, &shProg->VertexProgram->Base, + index, offset, + count, rows, cols, transpose, values); + } + } + + if (shProg->FragmentProgram) { + /* convert uniform location to program parameter index */ + GLint index = uniform->FragPos; + if (index >= 0) { + set_program_uniform_matrix(ctx, &shProg->FragmentProgram->Base, + index, offset, + count, rows, cols, transpose, values); + } + } + + if (shProg->GeometryProgram) { + /* convert uniform location to program parameter index */ + GLint index = uniform->GeomPos; + if (index >= 0) { + set_program_uniform_matrix(ctx, &shProg->GeometryProgram->Base, + index, offset, + count, rows, cols, transpose, values); + } + } + + uniform->Initialized = GL_TRUE; +} + + +void GLAPIENTRY +_mesa_Uniform1fARB(GLint location, GLfloat v0) +{ + GET_CURRENT_CONTEXT(ctx); + _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, 1, &v0, GL_FLOAT); +} + +void GLAPIENTRY +_mesa_Uniform2fARB(GLint location, GLfloat v0, GLfloat v1) +{ + GET_CURRENT_CONTEXT(ctx); + GLfloat v[2]; + v[0] = v0; + v[1] = v1; + _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, 1, v, GL_FLOAT_VEC2); +} + +void GLAPIENTRY +_mesa_Uniform3fARB(GLint location, GLfloat v0, GLfloat v1, GLfloat v2) +{ + GET_CURRENT_CONTEXT(ctx); + GLfloat v[3]; + v[0] = v0; + v[1] = v1; + v[2] = v2; + _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, 1, v, GL_FLOAT_VEC3); +} + +void GLAPIENTRY +_mesa_Uniform4fARB(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, + GLfloat v3) +{ + GET_CURRENT_CONTEXT(ctx); + GLfloat v[4]; + v[0] = v0; + v[1] = v1; + v[2] = v2; + v[3] = v3; + _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, 1, v, GL_FLOAT_VEC4); +} + +void GLAPIENTRY +_mesa_Uniform1iARB(GLint location, GLint v0) +{ + GET_CURRENT_CONTEXT(ctx); + _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, 1, &v0, GL_INT); +} + +void GLAPIENTRY +_mesa_Uniform2iARB(GLint location, GLint v0, GLint v1) +{ + GET_CURRENT_CONTEXT(ctx); + GLint v[2]; + v[0] = v0; + v[1] = v1; + _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, 1, v, GL_INT_VEC2); +} + +void GLAPIENTRY +_mesa_Uniform3iARB(GLint location, GLint v0, GLint v1, GLint v2) +{ + GET_CURRENT_CONTEXT(ctx); + GLint v[3]; + v[0] = v0; + v[1] = v1; + v[2] = v2; + _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, 1, v, GL_INT_VEC3); +} + +void GLAPIENTRY +_mesa_Uniform4iARB(GLint location, GLint v0, GLint v1, GLint v2, GLint v3) +{ + GET_CURRENT_CONTEXT(ctx); + GLint v[4]; + v[0] = v0; + v[1] = v1; + v[2] = v2; + v[3] = v3; + _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, 1, v, GL_INT_VEC4); +} + +void GLAPIENTRY +_mesa_Uniform1fvARB(GLint location, GLsizei count, const GLfloat * value) +{ + GET_CURRENT_CONTEXT(ctx); + _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, count, value, GL_FLOAT); +} + +void GLAPIENTRY +_mesa_Uniform2fvARB(GLint location, GLsizei count, const GLfloat * value) +{ + GET_CURRENT_CONTEXT(ctx); + _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, count, value, GL_FLOAT_VEC2); +} + +void GLAPIENTRY +_mesa_Uniform3fvARB(GLint location, GLsizei count, const GLfloat * value) +{ + GET_CURRENT_CONTEXT(ctx); + _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, count, value, GL_FLOAT_VEC3); +} + +void GLAPIENTRY +_mesa_Uniform4fvARB(GLint location, GLsizei count, const GLfloat * value) +{ + GET_CURRENT_CONTEXT(ctx); + _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, count, value, GL_FLOAT_VEC4); +} + +void GLAPIENTRY +_mesa_Uniform1ivARB(GLint location, GLsizei count, const GLint * value) +{ + GET_CURRENT_CONTEXT(ctx); + _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, count, value, GL_INT); +} + +void GLAPIENTRY +_mesa_Uniform2ivARB(GLint location, GLsizei count, const GLint * value) +{ + GET_CURRENT_CONTEXT(ctx); + _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, count, value, GL_INT_VEC2); +} + +void GLAPIENTRY +_mesa_Uniform3ivARB(GLint location, GLsizei count, const GLint * value) +{ + GET_CURRENT_CONTEXT(ctx); + _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, count, value, GL_INT_VEC3); +} + +void GLAPIENTRY +_mesa_Uniform4ivARB(GLint location, GLsizei count, const GLint * value) +{ + GET_CURRENT_CONTEXT(ctx); + _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, count, value, GL_INT_VEC4); +} + + +/** OpenGL 3.0 GLuint-valued functions **/ +void GLAPIENTRY +_mesa_Uniform1ui(GLint location, GLuint v0) +{ + GET_CURRENT_CONTEXT(ctx); + _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, 1, &v0, GL_UNSIGNED_INT); +} + +void GLAPIENTRY +_mesa_Uniform2ui(GLint location, GLuint v0, GLuint v1) +{ + GET_CURRENT_CONTEXT(ctx); + GLuint v[2]; + v[0] = v0; + v[1] = v1; + _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, 1, v, GL_UNSIGNED_INT_VEC2); +} + +void GLAPIENTRY +_mesa_Uniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2) +{ + GET_CURRENT_CONTEXT(ctx); + GLuint v[3]; + v[0] = v0; + v[1] = v1; + v[2] = v2; + _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, 1, v, GL_UNSIGNED_INT_VEC3); +} + +void GLAPIENTRY +_mesa_Uniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3) +{ + GET_CURRENT_CONTEXT(ctx); + GLuint v[4]; + v[0] = v0; + v[1] = v1; + v[2] = v2; + v[3] = v3; + _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, 1, v, GL_UNSIGNED_INT_VEC4); +} + +void GLAPIENTRY +_mesa_Uniform1uiv(GLint location, GLsizei count, const GLuint *value) +{ + GET_CURRENT_CONTEXT(ctx); + _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, count, value, GL_UNSIGNED_INT); +} + +void GLAPIENTRY +_mesa_Uniform2uiv(GLint location, GLsizei count, const GLuint *value) +{ + GET_CURRENT_CONTEXT(ctx); + _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, count, value, GL_UNSIGNED_INT_VEC2); +} + +void GLAPIENTRY +_mesa_Uniform3uiv(GLint location, GLsizei count, const GLuint *value) +{ + GET_CURRENT_CONTEXT(ctx); + _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, count, value, GL_UNSIGNED_INT_VEC3); +} + +void GLAPIENTRY +_mesa_Uniform4uiv(GLint location, GLsizei count, const GLuint *value) +{ + GET_CURRENT_CONTEXT(ctx); + _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, count, value, GL_UNSIGNED_INT_VEC4); +} + + + +void GLAPIENTRY +_mesa_UniformMatrix2fvARB(GLint location, GLsizei count, GLboolean transpose, + const GLfloat * value) +{ + GET_CURRENT_CONTEXT(ctx); + _mesa_uniform_matrix(ctx, ctx->Shader.ActiveProgram, + 2, 2, location, count, transpose, value); +} + +void GLAPIENTRY +_mesa_UniformMatrix3fvARB(GLint location, GLsizei count, GLboolean transpose, + const GLfloat * value) +{ + GET_CURRENT_CONTEXT(ctx); + _mesa_uniform_matrix(ctx, ctx->Shader.ActiveProgram, + 3, 3, location, count, transpose, value); +} + +void GLAPIENTRY +_mesa_UniformMatrix4fvARB(GLint location, GLsizei count, GLboolean transpose, + const GLfloat * value) +{ + GET_CURRENT_CONTEXT(ctx); + _mesa_uniform_matrix(ctx, ctx->Shader.ActiveProgram, + 4, 4, location, count, transpose, value); +} + + +/** + * Non-square UniformMatrix are OpenGL 2.1 + */ +void GLAPIENTRY +_mesa_UniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, + const GLfloat *value) +{ + GET_CURRENT_CONTEXT(ctx); + _mesa_uniform_matrix(ctx, ctx->Shader.ActiveProgram, + 2, 3, location, count, transpose, value); +} + +void GLAPIENTRY +_mesa_UniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, + const GLfloat *value) +{ + GET_CURRENT_CONTEXT(ctx); + _mesa_uniform_matrix(ctx, ctx->Shader.ActiveProgram, + 3, 2, location, count, transpose, value); +} + +void GLAPIENTRY +_mesa_UniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, + const GLfloat *value) +{ + GET_CURRENT_CONTEXT(ctx); + _mesa_uniform_matrix(ctx, ctx->Shader.ActiveProgram, + 2, 4, location, count, transpose, value); +} + +void GLAPIENTRY +_mesa_UniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, + const GLfloat *value) +{ + GET_CURRENT_CONTEXT(ctx); + _mesa_uniform_matrix(ctx, ctx->Shader.ActiveProgram, + 4, 2, location, count, transpose, value); +} + +void GLAPIENTRY +_mesa_UniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, + const GLfloat *value) +{ + GET_CURRENT_CONTEXT(ctx); + _mesa_uniform_matrix(ctx, ctx->Shader.ActiveProgram, + 3, 4, location, count, transpose, value); +} + +void GLAPIENTRY +_mesa_UniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, + const GLfloat *value) +{ + GET_CURRENT_CONTEXT(ctx); + _mesa_uniform_matrix(ctx, ctx->Shader.ActiveProgram, + 4, 3, location, count, transpose, value); +} + + +void GLAPIENTRY +_mesa_GetnUniformfvARB(GLhandleARB program, GLint location, + GLsizei bufSize, GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + get_uniform(ctx, program, location, bufSize, GL_FLOAT, params); +} + +void GLAPIENTRY +_mesa_GetUniformfvARB(GLhandleARB program, GLint location, GLfloat *params) +{ + _mesa_GetnUniformfvARB(program, location, INT_MAX, params); +} + + +void GLAPIENTRY +_mesa_GetnUniformivARB(GLhandleARB program, GLint location, + GLsizei bufSize, GLint *params) +{ + GET_CURRENT_CONTEXT(ctx); + get_uniform(ctx, program, location, bufSize, GL_INT, params); +} + +void GLAPIENTRY +_mesa_GetUniformivARB(GLhandleARB program, GLint location, GLint *params) +{ + _mesa_GetnUniformivARB(program, location, INT_MAX, params); +} + + +/* GL3 */ +void GLAPIENTRY +_mesa_GetnUniformuivARB(GLhandleARB program, GLint location, + GLsizei bufSize, GLuint *params) +{ + GET_CURRENT_CONTEXT(ctx); + get_uniform(ctx, program, location, bufSize, GL_UNSIGNED_INT, params); +} + +void GLAPIENTRY +_mesa_GetUniformuiv(GLhandleARB program, GLint location, GLuint *params) +{ + _mesa_GetnUniformuivARB(program, location, INT_MAX, params); +} + + +/* GL4 */ +void GLAPIENTRY +_mesa_GetnUniformdvARB(GLhandleARB program, GLint location, + GLsizei bufSize, GLdouble *params) +{ + GET_CURRENT_CONTEXT(ctx); + /* + get_uniform(ctx, program, location, bufSize, GL_DOUBLE, params); + */ + _mesa_error(ctx, GL_INVALID_OPERATION, "glGetUniformdvARB" + "(GL_ARB_gpu_shader_fp64 not implemented)"); +} + +void GLAPIENTRY +_mesa_GetUniformdv(GLhandleARB program, GLint location, GLdouble *params) +{ + _mesa_GetnUniformdvARB(program, location, INT_MAX, params); +} + + +GLint GLAPIENTRY +_mesa_GetUniformLocationARB(GLhandleARB programObj, const GLcharARB *name) +{ + struct gl_shader_program *shProg; + + GET_CURRENT_CONTEXT(ctx); + + shProg = _mesa_lookup_shader_program_err(ctx, programObj, + "glGetUniformLocation"); + if (!shProg) + return -1; + + return _mesa_get_uniform_location(ctx, shProg, name); +} + + +void GLAPIENTRY +_mesa_GetActiveUniformARB(GLhandleARB program, GLuint index, + GLsizei maxLength, GLsizei * length, GLint * size, + GLenum * type, GLcharARB * name) +{ + GET_CURRENT_CONTEXT(ctx); + _mesa_get_active_uniform(ctx, program, index, maxLength, length, size, + type, name); +} + + +/** + * Plug in shader uniform-related functions into API dispatch table. + */ +void +_mesa_init_shader_uniform_dispatch(struct _glapi_table *exec) +{ +#if FEATURE_GL + SET_Uniform1fARB(exec, _mesa_Uniform1fARB); + SET_Uniform2fARB(exec, _mesa_Uniform2fARB); + SET_Uniform3fARB(exec, _mesa_Uniform3fARB); + SET_Uniform4fARB(exec, _mesa_Uniform4fARB); + SET_Uniform1iARB(exec, _mesa_Uniform1iARB); + SET_Uniform2iARB(exec, _mesa_Uniform2iARB); + SET_Uniform3iARB(exec, _mesa_Uniform3iARB); + SET_Uniform4iARB(exec, _mesa_Uniform4iARB); + SET_Uniform1fvARB(exec, _mesa_Uniform1fvARB); + SET_Uniform2fvARB(exec, _mesa_Uniform2fvARB); + SET_Uniform3fvARB(exec, _mesa_Uniform3fvARB); + SET_Uniform4fvARB(exec, _mesa_Uniform4fvARB); + SET_Uniform1ivARB(exec, _mesa_Uniform1ivARB); + SET_Uniform2ivARB(exec, _mesa_Uniform2ivARB); + SET_Uniform3ivARB(exec, _mesa_Uniform3ivARB); + SET_Uniform4ivARB(exec, _mesa_Uniform4ivARB); + SET_UniformMatrix2fvARB(exec, _mesa_UniformMatrix2fvARB); + SET_UniformMatrix3fvARB(exec, _mesa_UniformMatrix3fvARB); + SET_UniformMatrix4fvARB(exec, _mesa_UniformMatrix4fvARB); + + SET_GetActiveUniformARB(exec, _mesa_GetActiveUniformARB); + SET_GetUniformLocationARB(exec, _mesa_GetUniformLocationARB); + SET_GetUniformfvARB(exec, _mesa_GetUniformfvARB); + SET_GetUniformivARB(exec, _mesa_GetUniformivARB); + + /* OpenGL 2.1 */ + SET_UniformMatrix2x3fv(exec, _mesa_UniformMatrix2x3fv); + SET_UniformMatrix3x2fv(exec, _mesa_UniformMatrix3x2fv); + SET_UniformMatrix2x4fv(exec, _mesa_UniformMatrix2x4fv); + SET_UniformMatrix4x2fv(exec, _mesa_UniformMatrix4x2fv); + SET_UniformMatrix3x4fv(exec, _mesa_UniformMatrix3x4fv); + SET_UniformMatrix4x3fv(exec, _mesa_UniformMatrix4x3fv); + + /* OpenGL 3.0 */ + SET_Uniform1uiEXT(exec, _mesa_Uniform1ui); + SET_Uniform2uiEXT(exec, _mesa_Uniform2ui); + SET_Uniform3uiEXT(exec, _mesa_Uniform3ui); + SET_Uniform4uiEXT(exec, _mesa_Uniform4ui); + SET_Uniform1uivEXT(exec, _mesa_Uniform1uiv); + SET_Uniform2uivEXT(exec, _mesa_Uniform2uiv); + SET_Uniform3uivEXT(exec, _mesa_Uniform3uiv); + SET_Uniform4uivEXT(exec, _mesa_Uniform4uiv); + SET_GetUniformuivEXT(exec, _mesa_GetUniformuiv); + + /* GL_ARB_robustness */ + SET_GetnUniformfvARB(exec, _mesa_GetnUniformfvARB); + SET_GetnUniformivARB(exec, _mesa_GetnUniformivARB); + SET_GetnUniformuivARB(exec, _mesa_GetnUniformuivARB); + SET_GetnUniformdvARB(exec, _mesa_GetnUniformdvARB); /* GL 4.0 */ + +#endif /* FEATURE_GL */ +} diff --git a/mesalib/src/mesa/main/uniforms.h b/mesalib/src/mesa/main/uniforms.h index adc3c6406..b024cb30b 100644 --- a/mesalib/src/mesa/main/uniforms.h +++ b/mesalib/src/mesa/main/uniforms.h @@ -1,208 +1,208 @@ -/* - * 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. - */ - - -#ifndef UNIFORMS_H -#define UNIFORMS_H - -#include "glheader.h" -#include "program/prog_parameter.h" - -struct gl_program; -struct _glapi_table; - -extern void GLAPIENTRY -_mesa_Uniform1fARB(GLint, GLfloat); - -extern void GLAPIENTRY -_mesa_Uniform2fARB(GLint, GLfloat, GLfloat); - -extern void GLAPIENTRY -_mesa_Uniform3fARB(GLint, GLfloat, GLfloat, GLfloat); - -extern void GLAPIENTRY -_mesa_Uniform4fARB(GLint, GLfloat, GLfloat, GLfloat, GLfloat); - -extern void GLAPIENTRY -_mesa_Uniform1iARB(GLint, GLint); - -extern void GLAPIENTRY -_mesa_Uniform2iARB(GLint, GLint, GLint); - -extern void GLAPIENTRY -_mesa_Uniform3iARB(GLint, GLint, GLint, GLint); - -extern void GLAPIENTRY -_mesa_Uniform4iARB(GLint, GLint, GLint, GLint, GLint); - -extern void GLAPIENTRY -_mesa_Uniform1fvARB(GLint, GLsizei, const GLfloat *); - -extern void GLAPIENTRY -_mesa_Uniform2fvARB(GLint, GLsizei, const GLfloat *); - -extern void GLAPIENTRY -_mesa_Uniform3fvARB(GLint, GLsizei, const GLfloat *); - -extern void GLAPIENTRY -_mesa_Uniform4fvARB(GLint, GLsizei, const GLfloat *); - -extern void GLAPIENTRY -_mesa_Uniform1ivARB(GLint, GLsizei, const GLint *); - -extern void GLAPIENTRY -_mesa_Uniform2ivARB(GLint, GLsizei, const GLint *); - -extern void GLAPIENTRY -_mesa_Uniform3ivARB(GLint, GLsizei, const GLint *); - -extern void GLAPIENTRY -_mesa_Uniform4ivARB(GLint, GLsizei, const GLint *); - -extern void GLAPIENTRY -_mesa_Uniform1ui(GLint location, GLuint v0); - -extern void GLAPIENTRY -_mesa_Uniform2ui(GLint location, GLuint v0, GLuint v1); - -extern void GLAPIENTRY -_mesa_Uniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2); - -extern void GLAPIENTRY -_mesa_Uniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); - -extern void GLAPIENTRY -_mesa_Uniform1uiv(GLint location, GLsizei count, const GLuint *value); - -extern void GLAPIENTRY -_mesa_Uniform2uiv(GLint location, GLsizei count, const GLuint *value); - -extern void GLAPIENTRY -_mesa_Uniform3uiv(GLint location, GLsizei count, const GLuint *value); - -extern void GLAPIENTRY -_mesa_Uniform4uiv(GLint location, GLsizei count, const GLuint *value); - - -extern void GLAPIENTRY -_mesa_UniformMatrix2fvARB(GLint, GLsizei, GLboolean, const GLfloat *); - -extern void GLAPIENTRY -_mesa_UniformMatrix3fvARB(GLint, GLsizei, GLboolean, const GLfloat *); - -extern void GLAPIENTRY -_mesa_UniformMatrix4fvARB(GLint, GLsizei, GLboolean, const GLfloat *); - -extern void GLAPIENTRY -_mesa_UniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, - const GLfloat *value); - -extern void GLAPIENTRY -_mesa_UniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, - const GLfloat *value); - -extern void GLAPIENTRY -_mesa_UniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, - const GLfloat *value); - -extern void GLAPIENTRY -_mesa_UniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, - const GLfloat *value); - -extern void GLAPIENTRY -_mesa_UniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, - const GLfloat *value); - -extern void GLAPIENTRY -_mesa_UniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, - const GLfloat *value); - - -extern void GLAPIENTRY -_mesa_GetActiveUniformARB(GLhandleARB, GLuint, GLsizei, GLsizei *, - GLint *, GLenum *, GLcharARB *); - -extern void GLAPIENTRY -_mesa_GetUniformfvARB(GLhandleARB, GLint, GLfloat *); - -extern void GLAPIENTRY -_mesa_GetnUniformfvARB(GLhandleARB, GLint, GLsizei, GLfloat *); - -extern void GLAPIENTRY -_mesa_GetUniformivARB(GLhandleARB, GLint, GLint *); - -extern void GLAPIENTRY -_mesa_GetnUniformivARB(GLhandleARB, GLint, GLsizei, GLint *); - -extern void GLAPIENTRY -_mesa_GetUniformuiv(GLhandleARB, GLint, GLuint *); - -extern void GLAPIENTRY -_mesa_GetnUniformuivARB(GLhandleARB, GLint, GLsizei, GLuint *); - -extern void GLAPIENTRY -_mesa_GetUniformdv(GLhandleARB, GLint, GLdouble *); - -extern void GLAPIENTRY -_mesa_GetnUniformdvARB(GLhandleARB, GLint, GLsizei, GLdouble *); - -extern GLint GLAPIENTRY -_mesa_GetUniformLocationARB(GLhandleARB, const GLcharARB *); - -GLint -_mesa_get_uniform_location(struct gl_context *ctx, struct gl_shader_program *shProg, - const GLchar *name); - -void -_mesa_uniform(struct gl_context *ctx, struct gl_shader_program *shader_program, - GLint location, GLsizei count, - const GLvoid *values, GLenum type); - -void -_mesa_uniform_matrix(struct gl_context *ctx, struct gl_shader_program *shProg, - GLint cols, GLint rows, - GLint location, GLsizei count, - GLboolean transpose, const GLfloat *values); - -extern void -_mesa_update_shader_textures_used(struct gl_program *prog); - - -extern void -_mesa_init_shader_uniform_dispatch(struct _glapi_table *exec); - -struct gl_builtin_uniform_element { - const char *field; - int tokens[STATE_LENGTH]; - int swizzle; -}; - -struct gl_builtin_uniform_desc { - const char *name; - struct gl_builtin_uniform_element *elements; - unsigned int num_elements; -}; - -extern const struct gl_builtin_uniform_desc _mesa_builtin_uniform_desc[]; - -#endif /* UNIFORMS_H */ +/* + * 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. + */ + + +#ifndef UNIFORMS_H +#define UNIFORMS_H + +#include "glheader.h" +#include "program/prog_parameter.h" + +struct gl_program; +struct _glapi_table; + +extern void GLAPIENTRY +_mesa_Uniform1fARB(GLint, GLfloat); + +extern void GLAPIENTRY +_mesa_Uniform2fARB(GLint, GLfloat, GLfloat); + +extern void GLAPIENTRY +_mesa_Uniform3fARB(GLint, GLfloat, GLfloat, GLfloat); + +extern void GLAPIENTRY +_mesa_Uniform4fARB(GLint, GLfloat, GLfloat, GLfloat, GLfloat); + +extern void GLAPIENTRY +_mesa_Uniform1iARB(GLint, GLint); + +extern void GLAPIENTRY +_mesa_Uniform2iARB(GLint, GLint, GLint); + +extern void GLAPIENTRY +_mesa_Uniform3iARB(GLint, GLint, GLint, GLint); + +extern void GLAPIENTRY +_mesa_Uniform4iARB(GLint, GLint, GLint, GLint, GLint); + +extern void GLAPIENTRY +_mesa_Uniform1fvARB(GLint, GLsizei, const GLfloat *); + +extern void GLAPIENTRY +_mesa_Uniform2fvARB(GLint, GLsizei, const GLfloat *); + +extern void GLAPIENTRY +_mesa_Uniform3fvARB(GLint, GLsizei, const GLfloat *); + +extern void GLAPIENTRY +_mesa_Uniform4fvARB(GLint, GLsizei, const GLfloat *); + +extern void GLAPIENTRY +_mesa_Uniform1ivARB(GLint, GLsizei, const GLint *); + +extern void GLAPIENTRY +_mesa_Uniform2ivARB(GLint, GLsizei, const GLint *); + +extern void GLAPIENTRY +_mesa_Uniform3ivARB(GLint, GLsizei, const GLint *); + +extern void GLAPIENTRY +_mesa_Uniform4ivARB(GLint, GLsizei, const GLint *); + +extern void GLAPIENTRY +_mesa_Uniform1ui(GLint location, GLuint v0); + +extern void GLAPIENTRY +_mesa_Uniform2ui(GLint location, GLuint v0, GLuint v1); + +extern void GLAPIENTRY +_mesa_Uniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2); + +extern void GLAPIENTRY +_mesa_Uniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); + +extern void GLAPIENTRY +_mesa_Uniform1uiv(GLint location, GLsizei count, const GLuint *value); + +extern void GLAPIENTRY +_mesa_Uniform2uiv(GLint location, GLsizei count, const GLuint *value); + +extern void GLAPIENTRY +_mesa_Uniform3uiv(GLint location, GLsizei count, const GLuint *value); + +extern void GLAPIENTRY +_mesa_Uniform4uiv(GLint location, GLsizei count, const GLuint *value); + + +extern void GLAPIENTRY +_mesa_UniformMatrix2fvARB(GLint, GLsizei, GLboolean, const GLfloat *); + +extern void GLAPIENTRY +_mesa_UniformMatrix3fvARB(GLint, GLsizei, GLboolean, const GLfloat *); + +extern void GLAPIENTRY +_mesa_UniformMatrix4fvARB(GLint, GLsizei, GLboolean, const GLfloat *); + +extern void GLAPIENTRY +_mesa_UniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, + const GLfloat *value); + +extern void GLAPIENTRY +_mesa_UniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, + const GLfloat *value); + +extern void GLAPIENTRY +_mesa_UniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, + const GLfloat *value); + +extern void GLAPIENTRY +_mesa_UniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, + const GLfloat *value); + +extern void GLAPIENTRY +_mesa_UniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, + const GLfloat *value); + +extern void GLAPIENTRY +_mesa_UniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, + const GLfloat *value); + + +extern void GLAPIENTRY +_mesa_GetActiveUniformARB(GLhandleARB, GLuint, GLsizei, GLsizei *, + GLint *, GLenum *, GLcharARB *); + +extern void GLAPIENTRY +_mesa_GetUniformfvARB(GLhandleARB, GLint, GLfloat *); + +extern void GLAPIENTRY +_mesa_GetnUniformfvARB(GLhandleARB, GLint, GLsizei, GLfloat *); + +extern void GLAPIENTRY +_mesa_GetUniformivARB(GLhandleARB, GLint, GLint *); + +extern void GLAPIENTRY +_mesa_GetnUniformivARB(GLhandleARB, GLint, GLsizei, GLint *); + +extern void GLAPIENTRY +_mesa_GetUniformuiv(GLhandleARB, GLint, GLuint *); + +extern void GLAPIENTRY +_mesa_GetnUniformuivARB(GLhandleARB, GLint, GLsizei, GLuint *); + +extern void GLAPIENTRY +_mesa_GetUniformdv(GLhandleARB, GLint, GLdouble *); + +extern void GLAPIENTRY +_mesa_GetnUniformdvARB(GLhandleARB, GLint, GLsizei, GLdouble *); + +extern GLint GLAPIENTRY +_mesa_GetUniformLocationARB(GLhandleARB, const GLcharARB *); + +GLint +_mesa_get_uniform_location(struct gl_context *ctx, struct gl_shader_program *shProg, + const GLchar *name); + +void +_mesa_uniform(struct gl_context *ctx, struct gl_shader_program *shader_program, + GLint location, GLsizei count, + const GLvoid *values, GLenum type); + +void +_mesa_uniform_matrix(struct gl_context *ctx, struct gl_shader_program *shProg, + GLint cols, GLint rows, + GLint location, GLsizei count, + GLboolean transpose, const GLfloat *values); + +extern void +_mesa_update_shader_textures_used(struct gl_program *prog); + + +extern void +_mesa_init_shader_uniform_dispatch(struct _glapi_table *exec); + +struct gl_builtin_uniform_element { + const char *field; + int tokens[STATE_LENGTH]; + int swizzle; +}; + +struct gl_builtin_uniform_desc { + const char *name; + struct gl_builtin_uniform_element *elements; + unsigned int num_elements; +}; + +extern const struct gl_builtin_uniform_desc _mesa_builtin_uniform_desc[]; + +#endif /* UNIFORMS_H */ diff --git a/mesalib/src/mesa/main/varray.h b/mesalib/src/mesa/main/varray.h index 493494e5c..1c423200f 100644 --- a/mesalib/src/mesa/main/varray.h +++ b/mesalib/src/mesa/main/varray.h @@ -1,279 +1,279 @@ -/* - * Mesa 3-D graphics library - * Version: 7.6 - * - * Copyright (C) 1999-2008 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. - */ - - -#ifndef VARRAY_H -#define VARRAY_H - - -#include "glheader.h" -#include "mfeatures.h" - -struct gl_client_array; -struct gl_context; - - -/** - * Compute the index of the last array element that can be safely accessed in - * a vertex array. We can really only do this when the array lives in a VBO. - * The array->_MaxElement field will be updated. - * Later in glDrawArrays/Elements/etc we can do some bounds checking. - */ -static INLINE void -_mesa_update_array_max_element(struct gl_client_array *array) -{ - assert(array->Enabled); - - if (array->BufferObj->Name) { - GLsizeiptrARB offset = (GLsizeiptrARB) array->Ptr; - GLsizeiptrARB bufSize = (GLsizeiptrARB) array->BufferObj->Size; - - if (offset < bufSize) { - array->_MaxElement = (bufSize - offset + array->StrideB - - array->_ElementSize) / array->StrideB; - } - else { - array->_MaxElement = 0; - } - } - else { - /* user-space array, no idea how big it is */ - array->_MaxElement = 2 * 1000 * 1000 * 1000; /* just a big number */ - } -} - - -#if _HAVE_FULL_GL - -extern void GLAPIENTRY -_mesa_VertexPointer(GLint size, GLenum type, GLsizei stride, - const GLvoid *ptr); - -extern void GLAPIENTRY -_mesa_UnlockArraysEXT( void ); - -extern void GLAPIENTRY -_mesa_LockArraysEXT(GLint first, GLsizei count); - - -extern void GLAPIENTRY -_mesa_NormalPointer(GLenum type, GLsizei stride, const GLvoid *ptr); - - -extern void GLAPIENTRY -_mesa_ColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr); - - -extern void GLAPIENTRY -_mesa_IndexPointer(GLenum type, GLsizei stride, const GLvoid *ptr); - - -extern void GLAPIENTRY -_mesa_TexCoordPointer(GLint size, GLenum type, GLsizei stride, - const GLvoid *ptr); - - -extern void GLAPIENTRY -_mesa_EdgeFlagPointer(GLsizei stride, const GLvoid *ptr); - - -extern void GLAPIENTRY -_mesa_VertexPointerEXT(GLint size, GLenum type, GLsizei stride, - GLsizei count, const GLvoid *ptr); - - -extern void GLAPIENTRY -_mesa_NormalPointerEXT(GLenum type, GLsizei stride, GLsizei count, - const GLvoid *ptr); - - -extern void GLAPIENTRY -_mesa_ColorPointerEXT(GLint size, GLenum type, GLsizei stride, GLsizei count, - const GLvoid *ptr); - - -extern void GLAPIENTRY -_mesa_IndexPointerEXT(GLenum type, GLsizei stride, GLsizei count, - const GLvoid *ptr); - - -extern void GLAPIENTRY -_mesa_TexCoordPointerEXT(GLint size, GLenum type, GLsizei stride, - GLsizei count, const GLvoid *ptr); - - -extern void GLAPIENTRY -_mesa_EdgeFlagPointerEXT(GLsizei stride, GLsizei count, const GLboolean *ptr); - - -extern void GLAPIENTRY -_mesa_FogCoordPointerEXT(GLenum type, GLsizei stride, const GLvoid *ptr); - - -extern void GLAPIENTRY -_mesa_SecondaryColorPointerEXT(GLint size, GLenum type, - GLsizei stride, const GLvoid *ptr); - - -extern void GLAPIENTRY -_mesa_PointSizePointer(GLenum type, GLsizei stride, const GLvoid *ptr); - - -extern void GLAPIENTRY -_mesa_VertexAttribPointerNV(GLuint index, GLint size, GLenum type, - GLsizei stride, const GLvoid *pointer); - - -extern void GLAPIENTRY -_mesa_VertexAttribPointerARB(GLuint index, GLint size, GLenum type, - GLboolean normalized, GLsizei stride, - const GLvoid *pointer); - -void GLAPIENTRY -_mesa_VertexAttribIPointer(GLuint index, GLint size, GLenum type, - GLsizei stride, const GLvoid *ptr); - - -extern void GLAPIENTRY -_mesa_EnableVertexAttribArrayARB(GLuint index); - - -extern void GLAPIENTRY -_mesa_DisableVertexAttribArrayARB(GLuint index); - - -extern void GLAPIENTRY -_mesa_GetVertexAttribdvARB(GLuint index, GLenum pname, GLdouble *params); - - -extern void GLAPIENTRY -_mesa_GetVertexAttribfvARB(GLuint index, GLenum pname, GLfloat *params); - - -extern void GLAPIENTRY -_mesa_GetVertexAttribivARB(GLuint index, GLenum pname, GLint *params); - - -extern void GLAPIENTRY -_mesa_GetVertexAttribIiv(GLuint index, GLenum pname, GLint *params); - - -extern void GLAPIENTRY -_mesa_GetVertexAttribIuiv(GLuint index, GLenum pname, GLuint *params); - - -extern void GLAPIENTRY -_mesa_GetVertexAttribPointervARB(GLuint index, GLenum pname, GLvoid **pointer); - - -extern void GLAPIENTRY -_mesa_InterleavedArrays(GLenum format, GLsizei stride, const GLvoid *pointer); - - -extern void GLAPIENTRY -_mesa_MultiDrawArraysEXT( GLenum mode, const GLint *first, - const GLsizei *count, GLsizei primcount ); - -extern void GLAPIENTRY -_mesa_MultiDrawElementsEXT( GLenum mode, const GLsizei *count, GLenum type, - const GLvoid **indices, GLsizei primcount ); - -extern void GLAPIENTRY -_mesa_MultiDrawElementsBaseVertex( GLenum mode, - const GLsizei *count, GLenum type, - const GLvoid **indices, GLsizei primcount, - const GLint *basevertex); - -extern void GLAPIENTRY -_mesa_MultiModeDrawArraysIBM( const GLenum * mode, const GLint * first, - const GLsizei * count, - GLsizei primcount, GLint modestride ); - - -extern void GLAPIENTRY -_mesa_MultiModeDrawElementsIBM( const GLenum * mode, const GLsizei * count, - GLenum type, const GLvoid * const * indices, - GLsizei primcount, GLint modestride ); - -extern void GLAPIENTRY -_mesa_LockArraysEXT(GLint first, GLsizei count); - -extern void GLAPIENTRY -_mesa_UnlockArraysEXT( void ); - - -extern void GLAPIENTRY -_mesa_DrawArrays(GLenum mode, GLint first, GLsizei count); - -extern void GLAPIENTRY -_mesa_DrawElements(GLenum mode, GLsizei count, GLenum type, - const GLvoid *indices); - -extern void GLAPIENTRY -_mesa_DrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, - GLenum type, const GLvoid *indices); - -extern void GLAPIENTRY -_mesa_DrawElementsBaseVertex(GLenum mode, GLsizei count, GLenum type, - const GLvoid *indices, GLint basevertex); - -extern void GLAPIENTRY -_mesa_DrawRangeElementsBaseVertex(GLenum mode, GLuint start, GLuint end, - GLsizei count, GLenum type, - const GLvoid *indices, - GLint basevertex); - -extern void GLAPIENTRY -_mesa_PrimitiveRestartIndex(GLuint index); - - -extern void GLAPIENTRY -_mesa_VertexAttribDivisor(GLuint index, GLuint divisor); - - -extern void -_mesa_copy_client_array(struct gl_context *ctx, - struct gl_client_array *dst, - struct gl_client_array *src); - - -extern void -_mesa_print_arrays(struct gl_context *ctx); - -extern void -_mesa_init_varray( struct gl_context * ctx ); - -extern void -_mesa_free_varray_data(struct gl_context *ctx); - -#else - -/** No-op */ -#define _mesa_init_varray( c ) ((void)0) -#define _mesa_free_varray_data( c ) ((void)0) - -#endif - -#endif +/* + * Mesa 3-D graphics library + * Version: 7.6 + * + * Copyright (C) 1999-2008 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. + */ + + +#ifndef VARRAY_H +#define VARRAY_H + + +#include "glheader.h" +#include "mfeatures.h" + +struct gl_client_array; +struct gl_context; + + +/** + * Compute the index of the last array element that can be safely accessed in + * a vertex array. We can really only do this when the array lives in a VBO. + * The array->_MaxElement field will be updated. + * Later in glDrawArrays/Elements/etc we can do some bounds checking. + */ +static INLINE void +_mesa_update_array_max_element(struct gl_client_array *array) +{ + assert(array->Enabled); + + if (array->BufferObj->Name) { + GLsizeiptrARB offset = (GLsizeiptrARB) array->Ptr; + GLsizeiptrARB bufSize = (GLsizeiptrARB) array->BufferObj->Size; + + if (offset < bufSize) { + array->_MaxElement = (bufSize - offset + array->StrideB + - array->_ElementSize) / array->StrideB; + } + else { + array->_MaxElement = 0; + } + } + else { + /* user-space array, no idea how big it is */ + array->_MaxElement = 2 * 1000 * 1000 * 1000; /* just a big number */ + } +} + + +#if _HAVE_FULL_GL + +extern void GLAPIENTRY +_mesa_VertexPointer(GLint size, GLenum type, GLsizei stride, + const GLvoid *ptr); + +extern void GLAPIENTRY +_mesa_UnlockArraysEXT( void ); + +extern void GLAPIENTRY +_mesa_LockArraysEXT(GLint first, GLsizei count); + + +extern void GLAPIENTRY +_mesa_NormalPointer(GLenum type, GLsizei stride, const GLvoid *ptr); + + +extern void GLAPIENTRY +_mesa_ColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr); + + +extern void GLAPIENTRY +_mesa_IndexPointer(GLenum type, GLsizei stride, const GLvoid *ptr); + + +extern void GLAPIENTRY +_mesa_TexCoordPointer(GLint size, GLenum type, GLsizei stride, + const GLvoid *ptr); + + +extern void GLAPIENTRY +_mesa_EdgeFlagPointer(GLsizei stride, const GLvoid *ptr); + + +extern void GLAPIENTRY +_mesa_VertexPointerEXT(GLint size, GLenum type, GLsizei stride, + GLsizei count, const GLvoid *ptr); + + +extern void GLAPIENTRY +_mesa_NormalPointerEXT(GLenum type, GLsizei stride, GLsizei count, + const GLvoid *ptr); + + +extern void GLAPIENTRY +_mesa_ColorPointerEXT(GLint size, GLenum type, GLsizei stride, GLsizei count, + const GLvoid *ptr); + + +extern void GLAPIENTRY +_mesa_IndexPointerEXT(GLenum type, GLsizei stride, GLsizei count, + const GLvoid *ptr); + + +extern void GLAPIENTRY +_mesa_TexCoordPointerEXT(GLint size, GLenum type, GLsizei stride, + GLsizei count, const GLvoid *ptr); + + +extern void GLAPIENTRY +_mesa_EdgeFlagPointerEXT(GLsizei stride, GLsizei count, const GLboolean *ptr); + + +extern void GLAPIENTRY +_mesa_FogCoordPointerEXT(GLenum type, GLsizei stride, const GLvoid *ptr); + + +extern void GLAPIENTRY +_mesa_SecondaryColorPointerEXT(GLint size, GLenum type, + GLsizei stride, const GLvoid *ptr); + + +extern void GLAPIENTRY +_mesa_PointSizePointer(GLenum type, GLsizei stride, const GLvoid *ptr); + + +extern void GLAPIENTRY +_mesa_VertexAttribPointerNV(GLuint index, GLint size, GLenum type, + GLsizei stride, const GLvoid *pointer); + + +extern void GLAPIENTRY +_mesa_VertexAttribPointerARB(GLuint index, GLint size, GLenum type, + GLboolean normalized, GLsizei stride, + const GLvoid *pointer); + +void GLAPIENTRY +_mesa_VertexAttribIPointer(GLuint index, GLint size, GLenum type, + GLsizei stride, const GLvoid *ptr); + + +extern void GLAPIENTRY +_mesa_EnableVertexAttribArrayARB(GLuint index); + + +extern void GLAPIENTRY +_mesa_DisableVertexAttribArrayARB(GLuint index); + + +extern void GLAPIENTRY +_mesa_GetVertexAttribdvARB(GLuint index, GLenum pname, GLdouble *params); + + +extern void GLAPIENTRY +_mesa_GetVertexAttribfvARB(GLuint index, GLenum pname, GLfloat *params); + + +extern void GLAPIENTRY +_mesa_GetVertexAttribivARB(GLuint index, GLenum pname, GLint *params); + + +extern void GLAPIENTRY +_mesa_GetVertexAttribIiv(GLuint index, GLenum pname, GLint *params); + + +extern void GLAPIENTRY +_mesa_GetVertexAttribIuiv(GLuint index, GLenum pname, GLuint *params); + + +extern void GLAPIENTRY +_mesa_GetVertexAttribPointervARB(GLuint index, GLenum pname, GLvoid **pointer); + + +extern void GLAPIENTRY +_mesa_InterleavedArrays(GLenum format, GLsizei stride, const GLvoid *pointer); + + +extern void GLAPIENTRY +_mesa_MultiDrawArraysEXT( GLenum mode, const GLint *first, + const GLsizei *count, GLsizei primcount ); + +extern void GLAPIENTRY +_mesa_MultiDrawElementsEXT( GLenum mode, const GLsizei *count, GLenum type, + const GLvoid **indices, GLsizei primcount ); + +extern void GLAPIENTRY +_mesa_MultiDrawElementsBaseVertex( GLenum mode, + const GLsizei *count, GLenum type, + const GLvoid **indices, GLsizei primcount, + const GLint *basevertex); + +extern void GLAPIENTRY +_mesa_MultiModeDrawArraysIBM( const GLenum * mode, const GLint * first, + const GLsizei * count, + GLsizei primcount, GLint modestride ); + + +extern void GLAPIENTRY +_mesa_MultiModeDrawElementsIBM( const GLenum * mode, const GLsizei * count, + GLenum type, const GLvoid * const * indices, + GLsizei primcount, GLint modestride ); + +extern void GLAPIENTRY +_mesa_LockArraysEXT(GLint first, GLsizei count); + +extern void GLAPIENTRY +_mesa_UnlockArraysEXT( void ); + + +extern void GLAPIENTRY +_mesa_DrawArrays(GLenum mode, GLint first, GLsizei count); + +extern void GLAPIENTRY +_mesa_DrawElements(GLenum mode, GLsizei count, GLenum type, + const GLvoid *indices); + +extern void GLAPIENTRY +_mesa_DrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, + GLenum type, const GLvoid *indices); + +extern void GLAPIENTRY +_mesa_DrawElementsBaseVertex(GLenum mode, GLsizei count, GLenum type, + const GLvoid *indices, GLint basevertex); + +extern void GLAPIENTRY +_mesa_DrawRangeElementsBaseVertex(GLenum mode, GLuint start, GLuint end, + GLsizei count, GLenum type, + const GLvoid *indices, + GLint basevertex); + +extern void GLAPIENTRY +_mesa_PrimitiveRestartIndex(GLuint index); + + +extern void GLAPIENTRY +_mesa_VertexAttribDivisor(GLuint index, GLuint divisor); + + +extern void +_mesa_copy_client_array(struct gl_context *ctx, + struct gl_client_array *dst, + struct gl_client_array *src); + + +extern void +_mesa_print_arrays(struct gl_context *ctx); + +extern void +_mesa_init_varray( struct gl_context * ctx ); + +extern void +_mesa_free_varray_data(struct gl_context *ctx); + +#else + +/** No-op */ +#define _mesa_init_varray( c ) ((void)0) +#define _mesa_free_varray_data( c ) ((void)0) + +#endif + +#endif -- cgit v1.2.3