get.c revision 3464ebd5
13464ebd5Sriastradh/*
23464ebd5Sriastradh * Copyright (C) 2010  Brian Paul   All Rights Reserved.
33464ebd5Sriastradh * Copyright (C) 2010  Intel Corporation
43464ebd5Sriastradh *
53464ebd5Sriastradh * Permission is hereby granted, free of charge, to any person obtaining a
63464ebd5Sriastradh * copy of this software and associated documentation files (the "Software"),
73464ebd5Sriastradh * to deal in the Software without restriction, including without limitation
83464ebd5Sriastradh * the rights to use, copy, modify, merge, publish, distribute, sublicense,
93464ebd5Sriastradh * and/or sell copies of the Software, and to permit persons to whom the
103464ebd5Sriastradh * Software is furnished to do so, subject to the following conditions:
113464ebd5Sriastradh *
123464ebd5Sriastradh * The above copyright notice and this permission notice shall be included
133464ebd5Sriastradh * in all copies or substantial portions of the Software.
143464ebd5Sriastradh *
153464ebd5Sriastradh * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
163464ebd5Sriastradh * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
173464ebd5Sriastradh * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
183464ebd5Sriastradh * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
193464ebd5Sriastradh * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
203464ebd5Sriastradh * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
213464ebd5Sriastradh *
223464ebd5Sriastradh * Author: Kristian Høgsberg <krh@bitplanet.net>
233464ebd5Sriastradh */
247117f1b4Smrg
257117f1b4Smrg#include "glheader.h"
267117f1b4Smrg#include "context.h"
277117f1b4Smrg#include "enable.h"
283464ebd5Sriastradh#include "enums.h"
297117f1b4Smrg#include "extensions.h"
307117f1b4Smrg#include "get.h"
317117f1b4Smrg#include "macros.h"
323464ebd5Sriastradh#include "mfeatures.h"
337117f1b4Smrg#include "mtypes.h"
347117f1b4Smrg#include "state.h"
357117f1b4Smrg#include "texcompress.h"
364a49301eSmrg#include "framebuffer.h"
377117f1b4Smrg
383464ebd5Sriastradh/* This is a table driven implemetation of the glGet*v() functions.
393464ebd5Sriastradh * The basic idea is that most getters just look up an int somewhere
403464ebd5Sriastradh * in struct gl_context and then convert it to a bool or float according to
413464ebd5Sriastradh * which of glGetIntegerv() glGetBooleanv() etc is being called.
423464ebd5Sriastradh * Instead of generating code to do this, we can just record the enum
433464ebd5Sriastradh * value and the offset into struct gl_context in an array of structs.  Then
443464ebd5Sriastradh * in glGet*(), we lookup the struct for the enum in question, and use
453464ebd5Sriastradh * the offset to get the int we need.
463464ebd5Sriastradh *
473464ebd5Sriastradh * Sometimes we need to look up a float, a boolean, a bit in a
483464ebd5Sriastradh * bitfield, a matrix or other types instead, so we need to track the
493464ebd5Sriastradh * type of the value in struct gl_context.  And sometimes the value isn't in
503464ebd5Sriastradh * struct gl_context but in the drawbuffer, the array object, current texture
513464ebd5Sriastradh * unit, or maybe it's a computed value.  So we need to also track
523464ebd5Sriastradh * where or how to find the value.  Finally, we sometimes need to
533464ebd5Sriastradh * check that one of a number of extensions are enabled, the GL
543464ebd5Sriastradh * version or flush or call _mesa_update_state().  This is done by
553464ebd5Sriastradh * attaching optional extra information to the value description
563464ebd5Sriastradh * struct, it's sort of like an array of opcodes that describe extra
573464ebd5Sriastradh * checks or actions.
583464ebd5Sriastradh *
593464ebd5Sriastradh * Putting all this together we end up with struct value_desc below,
603464ebd5Sriastradh * and with a couple of macros to help, the table of struct value_desc
613464ebd5Sriastradh * is about as concise as the specification in the old python script.
623464ebd5Sriastradh */
633464ebd5Sriastradh
643464ebd5Sriastradh#undef CONST
657117f1b4Smrg
667117f1b4Smrg#define FLOAT_TO_BOOLEAN(X)   ( (X) ? GL_TRUE : GL_FALSE )
673464ebd5Sriastradh#define FLOAT_TO_FIXED(F)     ( ((F) * 65536.0f > INT_MAX) ? INT_MAX : \
683464ebd5Sriastradh                                ((F) * 65536.0f < INT_MIN) ? INT_MIN : \
693464ebd5Sriastradh                                (GLint) ((F) * 65536.0f) )
707117f1b4Smrg
717117f1b4Smrg#define INT_TO_BOOLEAN(I)     ( (I) ? GL_TRUE : GL_FALSE )
723464ebd5Sriastradh#define INT_TO_FIXED(I)       ( ((I) > SHRT_MAX) ? INT_MAX : \
733464ebd5Sriastradh                                ((I) < SHRT_MIN) ? INT_MIN : \
743464ebd5Sriastradh                                (GLint) ((I) * 65536) )
757117f1b4Smrg
764a49301eSmrg#define INT64_TO_BOOLEAN(I)   ( (I) ? GL_TRUE : GL_FALSE )
774a49301eSmrg#define INT64_TO_INT(I)       ( (GLint)((I > INT_MAX) ? INT_MAX : ((I < INT_MIN) ? INT_MIN : (I))) )
784a49301eSmrg
797117f1b4Smrg#define BOOLEAN_TO_INT(B)     ( (GLint) (B) )
804a49301eSmrg#define BOOLEAN_TO_INT64(B)   ( (GLint64) (B) )
817117f1b4Smrg#define BOOLEAN_TO_FLOAT(B)   ( (B) ? 1.0F : 0.0F )
823464ebd5Sriastradh#define BOOLEAN_TO_FIXED(B)   ( (GLint) ((B) ? 1 : 0) << 16 )
837117f1b4Smrg
844a49301eSmrg#define ENUM_TO_INT64(E)      ( (GLint64) (E) )
853464ebd5Sriastradh#define ENUM_TO_FIXED(E)      (E)
864a49301eSmrg
873464ebd5Sriastradhenum value_type {
883464ebd5Sriastradh   TYPE_INVALID,
893464ebd5Sriastradh   TYPE_API_MASK,
903464ebd5Sriastradh   TYPE_INT,
913464ebd5Sriastradh   TYPE_INT_2,
923464ebd5Sriastradh   TYPE_INT_3,
933464ebd5Sriastradh   TYPE_INT_4,
943464ebd5Sriastradh   TYPE_INT_N,
953464ebd5Sriastradh   TYPE_INT64,
963464ebd5Sriastradh   TYPE_ENUM,
973464ebd5Sriastradh   TYPE_ENUM_2,
983464ebd5Sriastradh   TYPE_BOOLEAN,
993464ebd5Sriastradh   TYPE_BIT_0,
1003464ebd5Sriastradh   TYPE_BIT_1,
1013464ebd5Sriastradh   TYPE_BIT_2,
1023464ebd5Sriastradh   TYPE_BIT_3,
1033464ebd5Sriastradh   TYPE_BIT_4,
1043464ebd5Sriastradh   TYPE_BIT_5,
1053464ebd5Sriastradh   TYPE_FLOAT,
1063464ebd5Sriastradh   TYPE_FLOAT_2,
1073464ebd5Sriastradh   TYPE_FLOAT_3,
1083464ebd5Sriastradh   TYPE_FLOAT_4,
1093464ebd5Sriastradh   TYPE_FLOATN,
1103464ebd5Sriastradh   TYPE_FLOATN_2,
1113464ebd5Sriastradh   TYPE_FLOATN_3,
1123464ebd5Sriastradh   TYPE_FLOATN_4,
1133464ebd5Sriastradh   TYPE_DOUBLEN,
1143464ebd5Sriastradh   TYPE_MATRIX,
1153464ebd5Sriastradh   TYPE_MATRIX_T,
1163464ebd5Sriastradh   TYPE_CONST
1173464ebd5Sriastradh};
1187117f1b4Smrg
1193464ebd5Sriastradhenum value_location {
1203464ebd5Sriastradh   LOC_BUFFER,
1213464ebd5Sriastradh   LOC_CONTEXT,
1223464ebd5Sriastradh   LOC_ARRAY,
1233464ebd5Sriastradh   LOC_TEXUNIT,
1243464ebd5Sriastradh   LOC_CUSTOM
1253464ebd5Sriastradh};
1263464ebd5Sriastradh
1273464ebd5Sriastradhenum value_extra {
1283464ebd5Sriastradh   EXTRA_END = 0x8000,
1293464ebd5Sriastradh   EXTRA_VERSION_30,
1303464ebd5Sriastradh   EXTRA_VERSION_31,
1313464ebd5Sriastradh   EXTRA_VERSION_32,
1323464ebd5Sriastradh   EXTRA_VERSION_ES2,
1333464ebd5Sriastradh   EXTRA_NEW_BUFFERS,
1343464ebd5Sriastradh   EXTRA_NEW_FRAG_CLAMP,
1353464ebd5Sriastradh   EXTRA_VALID_DRAW_BUFFER,
1363464ebd5Sriastradh   EXTRA_VALID_TEXTURE_UNIT,
1373464ebd5Sriastradh   EXTRA_FLUSH_CURRENT,
1383464ebd5Sriastradh};
1393464ebd5Sriastradh
1403464ebd5Sriastradh#define NO_EXTRA NULL
1413464ebd5Sriastradh#define NO_OFFSET 0
1423464ebd5Sriastradh
1433464ebd5Sriastradhstruct value_desc {
1443464ebd5Sriastradh   GLenum pname;
1453464ebd5Sriastradh   GLubyte location;  /**< enum value_location */
1463464ebd5Sriastradh   GLubyte type;      /**< enum value_type */
1473464ebd5Sriastradh   int offset;
1483464ebd5Sriastradh   const int *extra;
1493464ebd5Sriastradh};
1503464ebd5Sriastradh
1513464ebd5Sriastradhunion value {
1523464ebd5Sriastradh   GLfloat value_float;
1533464ebd5Sriastradh   GLfloat value_float_4[4];
1543464ebd5Sriastradh   GLmatrix *value_matrix;
1553464ebd5Sriastradh   GLint value_int;
1563464ebd5Sriastradh   GLint value_int_4[4];
1573464ebd5Sriastradh   GLint64 value_int64;
1583464ebd5Sriastradh   GLenum value_enum;
1593464ebd5Sriastradh
1603464ebd5Sriastradh   /* Sigh, see GL_COMPRESSED_TEXTURE_FORMATS_ARB handling */
1613464ebd5Sriastradh   struct {
1623464ebd5Sriastradh      GLint n, ints[100];
1633464ebd5Sriastradh   } value_int_n;
1643464ebd5Sriastradh   GLboolean value_bool;
1653464ebd5Sriastradh};
1663464ebd5Sriastradh
1673464ebd5Sriastradh#define BUFFER_FIELD(field, type) \
1683464ebd5Sriastradh   LOC_BUFFER, type, offsetof(struct gl_framebuffer, field)
1693464ebd5Sriastradh#define CONTEXT_FIELD(field, type) \
1703464ebd5Sriastradh   LOC_CONTEXT, type, offsetof(struct gl_context, field)
1713464ebd5Sriastradh#define ARRAY_FIELD(field, type) \
1723464ebd5Sriastradh   LOC_ARRAY, type, offsetof(struct gl_array_object, field)
1733464ebd5Sriastradh#define CONST(value) \
1743464ebd5Sriastradh   LOC_CONTEXT, TYPE_CONST, value
1753464ebd5Sriastradh
1763464ebd5Sriastradh#define BUFFER_INT(field) BUFFER_FIELD(field, TYPE_INT)
1773464ebd5Sriastradh#define BUFFER_ENUM(field) BUFFER_FIELD(field, TYPE_ENUM)
1783464ebd5Sriastradh#define BUFFER_BOOL(field) BUFFER_FIELD(field, TYPE_BOOLEAN)
1793464ebd5Sriastradh
1803464ebd5Sriastradh#define CONTEXT_INT(field) CONTEXT_FIELD(field, TYPE_INT)
1813464ebd5Sriastradh#define CONTEXT_INT2(field) CONTEXT_FIELD(field, TYPE_INT_2)
1823464ebd5Sriastradh#define CONTEXT_INT64(field) CONTEXT_FIELD(field, TYPE_INT64)
1833464ebd5Sriastradh#define CONTEXT_ENUM(field) CONTEXT_FIELD(field, TYPE_ENUM)
1843464ebd5Sriastradh#define CONTEXT_ENUM2(field) CONTEXT_FIELD(field, TYPE_ENUM_2)
1853464ebd5Sriastradh#define CONTEXT_BOOL(field) CONTEXT_FIELD(field, TYPE_BOOLEAN)
1863464ebd5Sriastradh#define CONTEXT_BIT0(field) CONTEXT_FIELD(field, TYPE_BIT_0)
1873464ebd5Sriastradh#define CONTEXT_BIT1(field) CONTEXT_FIELD(field, TYPE_BIT_1)
1883464ebd5Sriastradh#define CONTEXT_BIT2(field) CONTEXT_FIELD(field, TYPE_BIT_2)
1893464ebd5Sriastradh#define CONTEXT_BIT3(field) CONTEXT_FIELD(field, TYPE_BIT_3)
1903464ebd5Sriastradh#define CONTEXT_BIT4(field) CONTEXT_FIELD(field, TYPE_BIT_4)
1913464ebd5Sriastradh#define CONTEXT_BIT5(field) CONTEXT_FIELD(field, TYPE_BIT_5)
1923464ebd5Sriastradh#define CONTEXT_FLOAT(field) CONTEXT_FIELD(field, TYPE_FLOAT)
1933464ebd5Sriastradh#define CONTEXT_FLOAT2(field) CONTEXT_FIELD(field, TYPE_FLOAT_2)
1943464ebd5Sriastradh#define CONTEXT_FLOAT3(field) CONTEXT_FIELD(field, TYPE_FLOAT_3)
1953464ebd5Sriastradh#define CONTEXT_FLOAT4(field) CONTEXT_FIELD(field, TYPE_FLOAT_4)
1963464ebd5Sriastradh#define CONTEXT_MATRIX(field) CONTEXT_FIELD(field, TYPE_MATRIX)
1973464ebd5Sriastradh#define CONTEXT_MATRIX_T(field) CONTEXT_FIELD(field, TYPE_MATRIX_T)
1983464ebd5Sriastradh
1993464ebd5Sriastradh#define ARRAY_INT(field) ARRAY_FIELD(field, TYPE_INT)
2003464ebd5Sriastradh#define ARRAY_ENUM(field) ARRAY_FIELD(field, TYPE_ENUM)
2013464ebd5Sriastradh#define ARRAY_BOOL(field) ARRAY_FIELD(field, TYPE_BOOLEAN)
2023464ebd5Sriastradh
2033464ebd5Sriastradh#define EXT(f)					\
2043464ebd5Sriastradh   offsetof(struct gl_extensions, f)
2053464ebd5Sriastradh
2063464ebd5Sriastradh#define EXTRA_EXT(e)				\
2073464ebd5Sriastradh   static const int extra_##e[] = {		\
2083464ebd5Sriastradh      EXT(e), EXTRA_END				\
2097117f1b4Smrg   }
2107117f1b4Smrg
2113464ebd5Sriastradh#define EXTRA_EXT2(e1, e2)			\
2123464ebd5Sriastradh   static const int extra_##e1##_##e2[] = {	\
2133464ebd5Sriastradh      EXT(e1), EXT(e2), EXTRA_END		\
2143464ebd5Sriastradh   }
2153464ebd5Sriastradh
2163464ebd5Sriastradh/* The 'extra' mechanism is a way to specify extra checks (such as
2173464ebd5Sriastradh * extensions or specific gl versions) or actions (flush current, new
2183464ebd5Sriastradh * buffers) that we need to do before looking up an enum.  We need to
2193464ebd5Sriastradh * declare them all up front so we can refer to them in the value_desc
2203464ebd5Sriastradh * structs below. */
2213464ebd5Sriastradh
2223464ebd5Sriastradhstatic const int extra_new_buffers[] = {
2233464ebd5Sriastradh   EXTRA_NEW_BUFFERS,
2243464ebd5Sriastradh   EXTRA_END
2253464ebd5Sriastradh};
2263464ebd5Sriastradh
2273464ebd5Sriastradhstatic const int extra_new_frag_clamp[] = {
2283464ebd5Sriastradh   EXTRA_NEW_FRAG_CLAMP,
2293464ebd5Sriastradh   EXTRA_END
2303464ebd5Sriastradh};
2313464ebd5Sriastradh
2323464ebd5Sriastradhstatic const int extra_valid_draw_buffer[] = {
2333464ebd5Sriastradh   EXTRA_VALID_DRAW_BUFFER,
2343464ebd5Sriastradh   EXTRA_END
2353464ebd5Sriastradh};
2363464ebd5Sriastradh
2373464ebd5Sriastradhstatic const int extra_valid_texture_unit[] = {
2383464ebd5Sriastradh   EXTRA_VALID_TEXTURE_UNIT,
2393464ebd5Sriastradh   EXTRA_END
2403464ebd5Sriastradh};
2413464ebd5Sriastradh
2423464ebd5Sriastradhstatic const int extra_flush_current_valid_texture_unit[] = {
2433464ebd5Sriastradh   EXTRA_FLUSH_CURRENT,
2443464ebd5Sriastradh   EXTRA_VALID_TEXTURE_UNIT,
2453464ebd5Sriastradh   EXTRA_END
2463464ebd5Sriastradh};
2473464ebd5Sriastradh
2483464ebd5Sriastradhstatic const int extra_flush_current[] = {
2493464ebd5Sriastradh   EXTRA_FLUSH_CURRENT,
2503464ebd5Sriastradh   EXTRA_END
2513464ebd5Sriastradh};
2523464ebd5Sriastradh
2533464ebd5Sriastradhstatic const int extra_new_buffers_OES_read_format[] = {
2543464ebd5Sriastradh   EXTRA_NEW_BUFFERS,
2553464ebd5Sriastradh   EXT(OES_read_format),
2563464ebd5Sriastradh   EXTRA_END
2573464ebd5Sriastradh};
2583464ebd5Sriastradh
2593464ebd5Sriastradhstatic const int extra_EXT_secondary_color_flush_current[] = {
2603464ebd5Sriastradh   EXT(EXT_secondary_color),
2613464ebd5Sriastradh   EXTRA_FLUSH_CURRENT,
2623464ebd5Sriastradh   EXTRA_END
2633464ebd5Sriastradh};
2643464ebd5Sriastradh
2653464ebd5Sriastradhstatic const int extra_EXT_fog_coord_flush_current[] = {
2663464ebd5Sriastradh   EXT(EXT_fog_coord),
2673464ebd5Sriastradh   EXTRA_FLUSH_CURRENT,
2683464ebd5Sriastradh   EXTRA_END
2693464ebd5Sriastradh};
2703464ebd5Sriastradh
2713464ebd5Sriastradhstatic const int extra_EXT_texture_integer[] = {
2723464ebd5Sriastradh   EXT(EXT_texture_integer),
2733464ebd5Sriastradh   EXTRA_END
2743464ebd5Sriastradh};
2753464ebd5Sriastradh
2763464ebd5Sriastradhstatic const int extra_EXT_gpu_shader4[] = {
2773464ebd5Sriastradh   EXT(EXT_gpu_shader4),
2783464ebd5Sriastradh   EXTRA_END
2793464ebd5Sriastradh};
2803464ebd5Sriastradh
2813464ebd5Sriastradhstatic const int extra_ARB_sampler_objects[] = {
2823464ebd5Sriastradh   EXT(ARB_sampler_objects),
2833464ebd5Sriastradh   EXTRA_END
2843464ebd5Sriastradh};
2853464ebd5Sriastradh
2863464ebd5Sriastradh
2873464ebd5SriastradhEXTRA_EXT(ARB_ES2_compatibility);
2883464ebd5SriastradhEXTRA_EXT(ARB_multitexture);
2893464ebd5SriastradhEXTRA_EXT(ARB_texture_cube_map);
2903464ebd5SriastradhEXTRA_EXT(MESA_texture_array);
2913464ebd5SriastradhEXTRA_EXT2(EXT_secondary_color, ARB_vertex_program);
2923464ebd5SriastradhEXTRA_EXT(EXT_secondary_color);
2933464ebd5SriastradhEXTRA_EXT(EXT_fog_coord);
2943464ebd5SriastradhEXTRA_EXT(EXT_texture_lod_bias);
2953464ebd5SriastradhEXTRA_EXT(EXT_texture_filter_anisotropic);
2963464ebd5SriastradhEXTRA_EXT(IBM_rasterpos_clip);
2973464ebd5SriastradhEXTRA_EXT(NV_point_sprite);
2983464ebd5SriastradhEXTRA_EXT(SGIS_generate_mipmap);
2993464ebd5SriastradhEXTRA_EXT(NV_vertex_program);
3003464ebd5SriastradhEXTRA_EXT(NV_fragment_program);
3013464ebd5SriastradhEXTRA_EXT(NV_texture_rectangle);
3023464ebd5SriastradhEXTRA_EXT(EXT_stencil_two_side);
3033464ebd5SriastradhEXTRA_EXT(NV_light_max_exponent);
3043464ebd5SriastradhEXTRA_EXT(EXT_depth_bounds_test);
3053464ebd5SriastradhEXTRA_EXT(ARB_depth_clamp);
3063464ebd5SriastradhEXTRA_EXT(ATI_fragment_shader);
3073464ebd5SriastradhEXTRA_EXT(EXT_framebuffer_blit);
3083464ebd5SriastradhEXTRA_EXT(ARB_shader_objects);
3093464ebd5SriastradhEXTRA_EXT(EXT_provoking_vertex);
3103464ebd5SriastradhEXTRA_EXT(ARB_fragment_shader);
3113464ebd5SriastradhEXTRA_EXT(ARB_fragment_program);
3123464ebd5SriastradhEXTRA_EXT2(ARB_framebuffer_object, EXT_framebuffer_multisample);
3133464ebd5SriastradhEXTRA_EXT(EXT_framebuffer_object);
3143464ebd5SriastradhEXTRA_EXT(APPLE_vertex_array_object);
3153464ebd5SriastradhEXTRA_EXT(ARB_seamless_cube_map);
3163464ebd5SriastradhEXTRA_EXT(EXT_compiled_vertex_array);
3173464ebd5SriastradhEXTRA_EXT(ARB_sync);
3183464ebd5SriastradhEXTRA_EXT(ARB_vertex_shader);
3193464ebd5SriastradhEXTRA_EXT(EXT_transform_feedback);
3203464ebd5SriastradhEXTRA_EXT(ARB_transform_feedback2);
3213464ebd5SriastradhEXTRA_EXT(EXT_pixel_buffer_object);
3223464ebd5SriastradhEXTRA_EXT(ARB_vertex_program);
3233464ebd5SriastradhEXTRA_EXT2(NV_point_sprite, ARB_point_sprite);
3243464ebd5SriastradhEXTRA_EXT2(ARB_fragment_program, NV_fragment_program);
3253464ebd5SriastradhEXTRA_EXT2(ARB_vertex_program, NV_vertex_program);
3263464ebd5SriastradhEXTRA_EXT2(ARB_vertex_program, ARB_fragment_program);
3273464ebd5SriastradhEXTRA_EXT(ARB_vertex_buffer_object);
3283464ebd5SriastradhEXTRA_EXT(ARB_geometry_shader4);
3293464ebd5SriastradhEXTRA_EXT(ARB_copy_buffer);
3303464ebd5SriastradhEXTRA_EXT(EXT_framebuffer_sRGB);
3313464ebd5SriastradhEXTRA_EXT(ARB_texture_buffer_object);
3323464ebd5Sriastradh
3333464ebd5Sriastradhstatic const int
3343464ebd5Sriastradhextra_ARB_vertex_program_ARB_fragment_program_NV_vertex_program[] = {
3353464ebd5Sriastradh   EXT(ARB_vertex_program),
3363464ebd5Sriastradh   EXT(ARB_fragment_program),
3373464ebd5Sriastradh   EXT(NV_vertex_program),
3383464ebd5Sriastradh   EXTRA_END
3393464ebd5Sriastradh};
3403464ebd5Sriastradh
3413464ebd5Sriastradhstatic const int
3423464ebd5Sriastradhextra_NV_vertex_program_ARB_vertex_program_ARB_fragment_program_NV_vertex_program[] = {
3433464ebd5Sriastradh   EXT(NV_vertex_program),
3443464ebd5Sriastradh   EXT(ARB_vertex_program),
3453464ebd5Sriastradh   EXT(ARB_fragment_program),
3463464ebd5Sriastradh   EXT(NV_vertex_program),
3473464ebd5Sriastradh   EXTRA_END
3483464ebd5Sriastradh};
3493464ebd5Sriastradh
3503464ebd5Sriastradhstatic const int
3513464ebd5Sriastradhextra_NV_primitive_restart[] = {
3523464ebd5Sriastradh   EXT(NV_primitive_restart),
3533464ebd5Sriastradh   EXTRA_END
3543464ebd5Sriastradh};
3553464ebd5Sriastradh
3563464ebd5Sriastradhstatic const int extra_version_30[] = { EXTRA_VERSION_30, EXTRA_END };
3573464ebd5Sriastradhstatic const int extra_version_31[] = { EXTRA_VERSION_31, EXTRA_END };
3583464ebd5Sriastradhstatic const int extra_version_32[] = { EXTRA_VERSION_32, EXTRA_END };
3593464ebd5Sriastradh
3603464ebd5Sriastradhstatic const int
3613464ebd5Sriastradhextra_ARB_vertex_program_version_es2[] = {
3623464ebd5Sriastradh   EXT(ARB_vertex_program),
3633464ebd5Sriastradh   EXTRA_VERSION_ES2,
3643464ebd5Sriastradh   EXTRA_END
3653464ebd5Sriastradh};
3663464ebd5Sriastradh
3673464ebd5Sriastradh#define API_OPENGL_BIT (1 << API_OPENGL)
3683464ebd5Sriastradh#define API_OPENGLES_BIT (1 << API_OPENGLES)
3693464ebd5Sriastradh#define API_OPENGLES2_BIT (1 << API_OPENGLES2)
3703464ebd5Sriastradh
3713464ebd5Sriastradh/* This is the big table describing all the enums we accept in
3723464ebd5Sriastradh * glGet*v().  The table is partitioned into six parts: enums
3733464ebd5Sriastradh * understood by all GL APIs (OpenGL, GLES and GLES2), enums shared
3743464ebd5Sriastradh * between OpenGL and GLES, enums exclusive to GLES, etc for the
3753464ebd5Sriastradh * remaining combinations.  When we add the enums to the hash table in
3763464ebd5Sriastradh * _mesa_init_get_hash(), we only add the enums for the API we're
3773464ebd5Sriastradh * instantiating and the different sections are guarded by #if
3783464ebd5Sriastradh * FEATURE_GL etc to make sure we only compile in the enums we may
3793464ebd5Sriastradh * need. */
3803464ebd5Sriastradh
3813464ebd5Sriastradhstatic const struct value_desc values[] = {
3823464ebd5Sriastradh   /* Enums shared between OpenGL, GLES1 and GLES2 */
3833464ebd5Sriastradh   { 0, 0, TYPE_API_MASK,
3843464ebd5Sriastradh     API_OPENGL_BIT | API_OPENGLES_BIT | API_OPENGLES2_BIT, NO_EXTRA},
3853464ebd5Sriastradh   { GL_ALPHA_BITS, BUFFER_INT(Visual.alphaBits), extra_new_buffers },
3863464ebd5Sriastradh   { GL_BLEND, CONTEXT_BIT0(Color.BlendEnabled), NO_EXTRA },
3873464ebd5Sriastradh   { GL_BLEND_SRC, CONTEXT_ENUM(Color.Blend[0].SrcRGB), NO_EXTRA },
3883464ebd5Sriastradh   { GL_BLUE_BITS, BUFFER_INT(Visual.blueBits), extra_new_buffers },
3893464ebd5Sriastradh   { GL_COLOR_CLEAR_VALUE, LOC_CUSTOM, TYPE_FLOATN_4, 0, extra_new_frag_clamp },
3903464ebd5Sriastradh   { GL_COLOR_WRITEMASK, LOC_CUSTOM, TYPE_INT_4, 0, NO_EXTRA },
3913464ebd5Sriastradh   { GL_CULL_FACE, CONTEXT_BOOL(Polygon.CullFlag), NO_EXTRA },
3923464ebd5Sriastradh   { GL_CULL_FACE_MODE, CONTEXT_ENUM(Polygon.CullFaceMode), NO_EXTRA },
3933464ebd5Sriastradh   { GL_DEPTH_BITS, BUFFER_INT(Visual.depthBits), NO_EXTRA },
3943464ebd5Sriastradh   { GL_DEPTH_CLEAR_VALUE, CONTEXT_FIELD(Depth.Clear, TYPE_DOUBLEN), NO_EXTRA },
3953464ebd5Sriastradh   { GL_DEPTH_FUNC, CONTEXT_ENUM(Depth.Func), NO_EXTRA },
3963464ebd5Sriastradh   { GL_DEPTH_RANGE, CONTEXT_FIELD(Viewport.Near, TYPE_FLOATN_2), NO_EXTRA },
3973464ebd5Sriastradh   { GL_DEPTH_TEST, CONTEXT_BOOL(Depth.Test), NO_EXTRA },
3983464ebd5Sriastradh   { GL_DEPTH_WRITEMASK, CONTEXT_BOOL(Depth.Mask), NO_EXTRA },
3993464ebd5Sriastradh   { GL_DITHER, CONTEXT_BOOL(Color.DitherFlag), NO_EXTRA },
4003464ebd5Sriastradh   { GL_FRONT_FACE, CONTEXT_ENUM(Polygon.FrontFace), NO_EXTRA },
4013464ebd5Sriastradh   { GL_GREEN_BITS, BUFFER_INT(Visual.greenBits), extra_new_buffers },
4023464ebd5Sriastradh   { GL_LINE_WIDTH, CONTEXT_FLOAT(Line.Width), NO_EXTRA },
4033464ebd5Sriastradh   { GL_ALIASED_LINE_WIDTH_RANGE, CONTEXT_FLOAT2(Const.MinLineWidth), NO_EXTRA },
4043464ebd5Sriastradh   { GL_MAX_ELEMENTS_VERTICES, CONTEXT_INT(Const.MaxArrayLockSize), NO_EXTRA },
4053464ebd5Sriastradh   { GL_MAX_ELEMENTS_INDICES, CONTEXT_INT(Const.MaxArrayLockSize), NO_EXTRA },
4063464ebd5Sriastradh   { GL_MAX_TEXTURE_SIZE, LOC_CUSTOM, TYPE_INT,
4073464ebd5Sriastradh     offsetof(struct gl_context, Const.MaxTextureLevels), NO_EXTRA },
4083464ebd5Sriastradh   { GL_MAX_VIEWPORT_DIMS, CONTEXT_INT2(Const.MaxViewportWidth), NO_EXTRA },
4093464ebd5Sriastradh   { GL_PACK_ALIGNMENT, CONTEXT_INT(Pack.Alignment), NO_EXTRA },
4103464ebd5Sriastradh   { GL_ALIASED_POINT_SIZE_RANGE, CONTEXT_FLOAT2(Const.MinPointSize), NO_EXTRA },
4113464ebd5Sriastradh   { GL_POLYGON_OFFSET_FACTOR, CONTEXT_FLOAT(Polygon.OffsetFactor ), NO_EXTRA },
4123464ebd5Sriastradh   { GL_POLYGON_OFFSET_UNITS, CONTEXT_FLOAT(Polygon.OffsetUnits ), NO_EXTRA },
4133464ebd5Sriastradh   { GL_POLYGON_OFFSET_FILL, CONTEXT_BOOL(Polygon.OffsetFill), NO_EXTRA },
4143464ebd5Sriastradh   { GL_RED_BITS, BUFFER_INT(Visual.redBits), extra_new_buffers },
4153464ebd5Sriastradh   { GL_SCISSOR_BOX, LOC_CUSTOM, TYPE_INT_4, 0, NO_EXTRA },
4163464ebd5Sriastradh   { GL_SCISSOR_TEST, CONTEXT_BOOL(Scissor.Enabled), NO_EXTRA },
4173464ebd5Sriastradh   { GL_STENCIL_BITS, BUFFER_INT(Visual.stencilBits), NO_EXTRA },
4183464ebd5Sriastradh   { GL_STENCIL_CLEAR_VALUE, CONTEXT_INT(Stencil.Clear), NO_EXTRA },
4193464ebd5Sriastradh   { GL_STENCIL_FAIL, LOC_CUSTOM, TYPE_ENUM, NO_OFFSET, NO_EXTRA },
4203464ebd5Sriastradh   { GL_STENCIL_FUNC, LOC_CUSTOM, TYPE_ENUM, NO_OFFSET, NO_EXTRA },
4213464ebd5Sriastradh   { GL_STENCIL_PASS_DEPTH_FAIL, LOC_CUSTOM, TYPE_ENUM, NO_OFFSET, NO_EXTRA },
4223464ebd5Sriastradh   { GL_STENCIL_PASS_DEPTH_PASS, LOC_CUSTOM, TYPE_ENUM, NO_OFFSET, NO_EXTRA },
4233464ebd5Sriastradh   { GL_STENCIL_REF, LOC_CUSTOM, TYPE_INT, NO_OFFSET, NO_EXTRA },
4243464ebd5Sriastradh   { GL_STENCIL_TEST, CONTEXT_BOOL(Stencil.Enabled), NO_EXTRA },
4253464ebd5Sriastradh   { GL_STENCIL_VALUE_MASK, LOC_CUSTOM, TYPE_INT, NO_OFFSET, NO_EXTRA },
4263464ebd5Sriastradh   { GL_STENCIL_WRITEMASK, LOC_CUSTOM, TYPE_INT, NO_OFFSET, NO_EXTRA },
4273464ebd5Sriastradh   { GL_SUBPIXEL_BITS, CONTEXT_INT(Const.SubPixelBits), NO_EXTRA },
4283464ebd5Sriastradh   { GL_TEXTURE_BINDING_2D, LOC_CUSTOM, TYPE_INT, TEXTURE_2D_INDEX, NO_EXTRA },
4293464ebd5Sriastradh   { GL_UNPACK_ALIGNMENT, CONTEXT_INT(Unpack.Alignment), NO_EXTRA },
4303464ebd5Sriastradh   { GL_VIEWPORT, LOC_CUSTOM, TYPE_INT_4, 0, NO_EXTRA },
4313464ebd5Sriastradh
4323464ebd5Sriastradh   /* GL_ARB_multitexture */
4333464ebd5Sriastradh   { GL_ACTIVE_TEXTURE_ARB,
4343464ebd5Sriastradh     LOC_CUSTOM, TYPE_INT, 0, extra_ARB_multitexture },
4353464ebd5Sriastradh
4363464ebd5Sriastradh   /* Note that all the OES_* extensions require that the Mesa "struct
4373464ebd5Sriastradh    * gl_extensions" include a member with the name of the extension.
4383464ebd5Sriastradh    * That structure does not yet include OES extensions (and we're
4393464ebd5Sriastradh    * not sure whether it will).  If it does, all the OES_*
4403464ebd5Sriastradh    * extensions below should mark the dependency. */
4413464ebd5Sriastradh
4423464ebd5Sriastradh   /* GL_ARB_texture_cube_map */
4433464ebd5Sriastradh   { GL_TEXTURE_BINDING_CUBE_MAP_ARB, LOC_CUSTOM, TYPE_INT,
4443464ebd5Sriastradh     TEXTURE_CUBE_INDEX, extra_ARB_texture_cube_map },
4453464ebd5Sriastradh   { GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB, LOC_CUSTOM, TYPE_INT,
4463464ebd5Sriastradh     offsetof(struct gl_context, Const.MaxCubeTextureLevels),
4473464ebd5Sriastradh     extra_ARB_texture_cube_map }, /* XXX: OES_texture_cube_map */
4483464ebd5Sriastradh
4493464ebd5Sriastradh   /* XXX: OES_blend_subtract */
4503464ebd5Sriastradh   { GL_BLEND_SRC_RGB_EXT, CONTEXT_ENUM(Color.Blend[0].SrcRGB), NO_EXTRA },
4513464ebd5Sriastradh   { GL_BLEND_DST_RGB_EXT, CONTEXT_ENUM(Color.Blend[0].DstRGB), NO_EXTRA },
4523464ebd5Sriastradh   { GL_BLEND_SRC_ALPHA_EXT, CONTEXT_ENUM(Color.Blend[0].SrcA), NO_EXTRA },
4533464ebd5Sriastradh   { GL_BLEND_DST_ALPHA_EXT, CONTEXT_ENUM(Color.Blend[0].DstA), NO_EXTRA },
4543464ebd5Sriastradh
4553464ebd5Sriastradh   /* GL_BLEND_EQUATION_RGB, which is what we're really after, is
4563464ebd5Sriastradh    * defined identically to GL_BLEND_EQUATION. */
4573464ebd5Sriastradh   { GL_BLEND_EQUATION, CONTEXT_ENUM(Color.Blend[0].EquationRGB), NO_EXTRA },
4583464ebd5Sriastradh   { GL_BLEND_EQUATION_ALPHA_EXT, CONTEXT_ENUM(Color.Blend[0].EquationA), NO_EXTRA },
4593464ebd5Sriastradh
4603464ebd5Sriastradh   /* GL_ARB_texture_compression */
4613464ebd5Sriastradh   { GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB, LOC_CUSTOM, TYPE_INT, 0, NO_EXTRA },
4623464ebd5Sriastradh   { GL_COMPRESSED_TEXTURE_FORMATS_ARB, LOC_CUSTOM, TYPE_INT_N, 0, NO_EXTRA },
4633464ebd5Sriastradh
4643464ebd5Sriastradh   /* GL_ARB_multisample */
4653464ebd5Sriastradh   { GL_SAMPLE_ALPHA_TO_COVERAGE_ARB,
4663464ebd5Sriastradh     CONTEXT_BOOL(Multisample.SampleAlphaToCoverage), NO_EXTRA },
4673464ebd5Sriastradh   { GL_SAMPLE_COVERAGE_ARB, CONTEXT_BOOL(Multisample.SampleCoverage), NO_EXTRA },
4683464ebd5Sriastradh   { GL_SAMPLE_COVERAGE_VALUE_ARB,
4693464ebd5Sriastradh     CONTEXT_FLOAT(Multisample.SampleCoverageValue), NO_EXTRA },
4703464ebd5Sriastradh   { GL_SAMPLE_COVERAGE_INVERT_ARB,
4713464ebd5Sriastradh     CONTEXT_BOOL(Multisample.SampleCoverageInvert), NO_EXTRA },
4723464ebd5Sriastradh   { GL_SAMPLE_BUFFERS_ARB, BUFFER_INT(Visual.sampleBuffers), NO_EXTRA },
4733464ebd5Sriastradh   { GL_SAMPLES_ARB, BUFFER_INT(Visual.samples), NO_EXTRA },
4743464ebd5Sriastradh
4753464ebd5Sriastradh   /* GL_SGIS_generate_mipmap */
4763464ebd5Sriastradh   { GL_GENERATE_MIPMAP_HINT_SGIS, CONTEXT_ENUM(Hint.GenerateMipmap),
4773464ebd5Sriastradh     extra_SGIS_generate_mipmap },
4783464ebd5Sriastradh
4793464ebd5Sriastradh   /* GL_ARB_vertex_buffer_object */
4803464ebd5Sriastradh   { GL_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT, 0, NO_EXTRA },
4813464ebd5Sriastradh
4823464ebd5Sriastradh   /* GL_ARB_vertex_buffer_object */
4833464ebd5Sriastradh   /* GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB - not supported */
4843464ebd5Sriastradh   { GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT, 0,
4853464ebd5Sriastradh     extra_ARB_vertex_buffer_object },
4863464ebd5Sriastradh
4873464ebd5Sriastradh   /* GL_ARB_copy_buffer */
4883464ebd5Sriastradh   { GL_COPY_READ_BUFFER, LOC_CUSTOM, TYPE_INT, 0, extra_ARB_copy_buffer },
4893464ebd5Sriastradh   { GL_COPY_WRITE_BUFFER, LOC_CUSTOM, TYPE_INT, 0, extra_ARB_copy_buffer },
4903464ebd5Sriastradh
4913464ebd5Sriastradh   /* GL_OES_read_format */
4923464ebd5Sriastradh   { GL_IMPLEMENTATION_COLOR_READ_TYPE_OES, LOC_CUSTOM, TYPE_INT, 0,
4933464ebd5Sriastradh     extra_new_buffers_OES_read_format },
4943464ebd5Sriastradh   { GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES, LOC_CUSTOM, TYPE_INT, 0,
4953464ebd5Sriastradh     extra_new_buffers_OES_read_format },
4963464ebd5Sriastradh
4973464ebd5Sriastradh   /* GL_EXT_framebuffer_object */
4983464ebd5Sriastradh   { GL_FRAMEBUFFER_BINDING_EXT, BUFFER_INT(Name),
4993464ebd5Sriastradh     extra_EXT_framebuffer_object },
5003464ebd5Sriastradh   { GL_RENDERBUFFER_BINDING_EXT, LOC_CUSTOM, TYPE_INT, 0,
5013464ebd5Sriastradh     extra_EXT_framebuffer_object },
5023464ebd5Sriastradh   { GL_MAX_RENDERBUFFER_SIZE_EXT, CONTEXT_INT(Const.MaxRenderbufferSize),
5033464ebd5Sriastradh     extra_EXT_framebuffer_object },
5043464ebd5Sriastradh
5053464ebd5Sriastradh   /* This entry isn't spec'ed for GLES 2, but is needed for Mesa's
5063464ebd5Sriastradh    * GLSL: */
5073464ebd5Sriastradh   { GL_MAX_CLIP_PLANES, CONTEXT_INT(Const.MaxClipPlanes), NO_EXTRA },
5083464ebd5Sriastradh
5093464ebd5Sriastradh#if FEATURE_GL || FEATURE_ES1
5103464ebd5Sriastradh   /* Enums in OpenGL and GLES1 */
5113464ebd5Sriastradh   { 0, 0, TYPE_API_MASK, API_OPENGL_BIT | API_OPENGLES_BIT, NO_EXTRA },
5123464ebd5Sriastradh   { GL_MAX_LIGHTS, CONTEXT_INT(Const.MaxLights), NO_EXTRA },
5133464ebd5Sriastradh   { GL_LIGHT0, CONTEXT_BOOL(Light.Light[0].Enabled), NO_EXTRA },
5143464ebd5Sriastradh   { GL_LIGHT1, CONTEXT_BOOL(Light.Light[1].Enabled), NO_EXTRA },
5153464ebd5Sriastradh   { GL_LIGHT2, CONTEXT_BOOL(Light.Light[2].Enabled), NO_EXTRA },
5163464ebd5Sriastradh   { GL_LIGHT3, CONTEXT_BOOL(Light.Light[3].Enabled), NO_EXTRA },
5173464ebd5Sriastradh   { GL_LIGHT4, CONTEXT_BOOL(Light.Light[4].Enabled), NO_EXTRA },
5183464ebd5Sriastradh   { GL_LIGHT5, CONTEXT_BOOL(Light.Light[5].Enabled), NO_EXTRA },
5193464ebd5Sriastradh   { GL_LIGHT6, CONTEXT_BOOL(Light.Light[6].Enabled), NO_EXTRA },
5203464ebd5Sriastradh   { GL_LIGHT7, CONTEXT_BOOL(Light.Light[7].Enabled), NO_EXTRA },
5213464ebd5Sriastradh   { GL_LIGHTING, CONTEXT_BOOL(Light.Enabled), NO_EXTRA },
5223464ebd5Sriastradh   { GL_LIGHT_MODEL_AMBIENT,
5233464ebd5Sriastradh     CONTEXT_FIELD(Light.Model.Ambient[0], TYPE_FLOATN_4), NO_EXTRA },
5243464ebd5Sriastradh   { GL_LIGHT_MODEL_TWO_SIDE, CONTEXT_BOOL(Light.Model.TwoSide), NO_EXTRA },
5253464ebd5Sriastradh   { GL_ALPHA_TEST, CONTEXT_BOOL(Color.AlphaEnabled), NO_EXTRA },
5263464ebd5Sriastradh   { GL_ALPHA_TEST_FUNC, CONTEXT_ENUM(Color.AlphaFunc), NO_EXTRA },
5273464ebd5Sriastradh   { GL_ALPHA_TEST_REF, LOC_CUSTOM, TYPE_FLOATN, 0, extra_new_frag_clamp },
5283464ebd5Sriastradh   { GL_BLEND_DST, CONTEXT_ENUM(Color.Blend[0].DstRGB), NO_EXTRA },
5293464ebd5Sriastradh   { GL_CLIP_PLANE0, CONTEXT_BIT0(Transform.ClipPlanesEnabled), NO_EXTRA },
5303464ebd5Sriastradh   { GL_CLIP_PLANE1, CONTEXT_BIT1(Transform.ClipPlanesEnabled), NO_EXTRA },
5313464ebd5Sriastradh   { GL_CLIP_PLANE2, CONTEXT_BIT2(Transform.ClipPlanesEnabled), NO_EXTRA },
5323464ebd5Sriastradh   { GL_CLIP_PLANE3, CONTEXT_BIT3(Transform.ClipPlanesEnabled), NO_EXTRA },
5333464ebd5Sriastradh   { GL_CLIP_PLANE4, CONTEXT_BIT4(Transform.ClipPlanesEnabled), NO_EXTRA },
5343464ebd5Sriastradh   { GL_CLIP_PLANE5, CONTEXT_BIT5(Transform.ClipPlanesEnabled), NO_EXTRA },
5353464ebd5Sriastradh   { GL_COLOR_MATERIAL, CONTEXT_BOOL(Light.ColorMaterialEnabled), NO_EXTRA },
5363464ebd5Sriastradh   { GL_CURRENT_COLOR,
5373464ebd5Sriastradh     CONTEXT_FIELD(Current.Attrib[VERT_ATTRIB_COLOR0][0], TYPE_FLOATN_4),
5383464ebd5Sriastradh     extra_flush_current },
5393464ebd5Sriastradh   { GL_CURRENT_NORMAL,
5403464ebd5Sriastradh     CONTEXT_FIELD(Current.Attrib[VERT_ATTRIB_NORMAL][0], TYPE_FLOATN_3),
5413464ebd5Sriastradh     extra_flush_current },
5423464ebd5Sriastradh   { GL_CURRENT_TEXTURE_COORDS, LOC_CUSTOM, TYPE_FLOAT_4, 0,
5433464ebd5Sriastradh     extra_flush_current_valid_texture_unit },
5443464ebd5Sriastradh   { GL_DISTANCE_ATTENUATION_EXT, CONTEXT_FLOAT3(Point.Params[0]), NO_EXTRA },
5453464ebd5Sriastradh   { GL_FOG, CONTEXT_BOOL(Fog.Enabled), NO_EXTRA },
5463464ebd5Sriastradh   { GL_FOG_COLOR, LOC_CUSTOM, TYPE_FLOATN_4, 0, extra_new_frag_clamp },
5473464ebd5Sriastradh   { GL_FOG_DENSITY, CONTEXT_FLOAT(Fog.Density), NO_EXTRA },
5483464ebd5Sriastradh   { GL_FOG_END, CONTEXT_FLOAT(Fog.End), NO_EXTRA },
5493464ebd5Sriastradh   { GL_FOG_HINT, CONTEXT_ENUM(Hint.Fog), NO_EXTRA },
5503464ebd5Sriastradh   { GL_FOG_MODE, CONTEXT_ENUM(Fog.Mode), NO_EXTRA },
5513464ebd5Sriastradh   { GL_FOG_START, CONTEXT_FLOAT(Fog.Start), NO_EXTRA },
5523464ebd5Sriastradh   { GL_LINE_SMOOTH, CONTEXT_BOOL(Line.SmoothFlag), NO_EXTRA },
5533464ebd5Sriastradh   { GL_LINE_SMOOTH_HINT, CONTEXT_ENUM(Hint.LineSmooth), NO_EXTRA },
5543464ebd5Sriastradh   { GL_LINE_WIDTH_RANGE, CONTEXT_FLOAT2(Const.MinLineWidthAA), NO_EXTRA },
5553464ebd5Sriastradh   { GL_COLOR_LOGIC_OP, CONTEXT_BOOL(Color.ColorLogicOpEnabled), NO_EXTRA },
5563464ebd5Sriastradh   { GL_LOGIC_OP_MODE, CONTEXT_ENUM(Color.LogicOp), NO_EXTRA },
5573464ebd5Sriastradh   { GL_MATRIX_MODE, CONTEXT_ENUM(Transform.MatrixMode), NO_EXTRA },
5583464ebd5Sriastradh   { GL_MAX_MODELVIEW_STACK_DEPTH, CONST(MAX_MODELVIEW_STACK_DEPTH), NO_EXTRA },
5593464ebd5Sriastradh   { GL_MAX_PROJECTION_STACK_DEPTH, CONST(MAX_PROJECTION_STACK_DEPTH), NO_EXTRA },
5603464ebd5Sriastradh   { GL_MAX_TEXTURE_STACK_DEPTH, CONST(MAX_TEXTURE_STACK_DEPTH), NO_EXTRA },
5613464ebd5Sriastradh   { GL_MODELVIEW_MATRIX, CONTEXT_MATRIX(ModelviewMatrixStack.Top), NO_EXTRA },
5623464ebd5Sriastradh   { GL_MODELVIEW_STACK_DEPTH, LOC_CUSTOM, TYPE_INT,
5633464ebd5Sriastradh     offsetof(struct gl_context, ModelviewMatrixStack.Depth), NO_EXTRA },
5643464ebd5Sriastradh   { GL_NORMALIZE, CONTEXT_BOOL(Transform.Normalize), NO_EXTRA },
5653464ebd5Sriastradh   { GL_PACK_SKIP_IMAGES_EXT, CONTEXT_INT(Pack.SkipImages), NO_EXTRA },
5663464ebd5Sriastradh   { GL_PERSPECTIVE_CORRECTION_HINT, CONTEXT_ENUM(Hint.PerspectiveCorrection), NO_EXTRA },
5673464ebd5Sriastradh   { GL_POINT_SIZE, CONTEXT_FLOAT(Point.Size), NO_EXTRA },
5683464ebd5Sriastradh   { GL_POINT_SIZE_RANGE, CONTEXT_FLOAT2(Const.MinPointSizeAA), NO_EXTRA },
5693464ebd5Sriastradh   { GL_POINT_SMOOTH, CONTEXT_BOOL(Point.SmoothFlag), NO_EXTRA },
5703464ebd5Sriastradh   { GL_POINT_SMOOTH_HINT, CONTEXT_ENUM(Hint.PointSmooth), NO_EXTRA },
5713464ebd5Sriastradh   { GL_POINT_SIZE_MIN_EXT, CONTEXT_FLOAT(Point.MinSize), NO_EXTRA },
5723464ebd5Sriastradh   { GL_POINT_SIZE_MAX_EXT, CONTEXT_FLOAT(Point.MaxSize), NO_EXTRA },
5733464ebd5Sriastradh   { GL_POINT_FADE_THRESHOLD_SIZE_EXT, CONTEXT_FLOAT(Point.Threshold), NO_EXTRA },
5743464ebd5Sriastradh   { GL_PROJECTION_MATRIX, CONTEXT_MATRIX(ProjectionMatrixStack.Top), NO_EXTRA },
5753464ebd5Sriastradh   { GL_PROJECTION_STACK_DEPTH, LOC_CUSTOM, TYPE_INT,
5763464ebd5Sriastradh     offsetof(struct gl_context, ProjectionMatrixStack.Depth), NO_EXTRA },
5773464ebd5Sriastradh   { GL_RESCALE_NORMAL, CONTEXT_BOOL(Transform.RescaleNormals), NO_EXTRA },
5783464ebd5Sriastradh   { GL_SHADE_MODEL, CONTEXT_ENUM(Light.ShadeModel), NO_EXTRA },
5793464ebd5Sriastradh   { GL_TEXTURE_2D, LOC_CUSTOM, TYPE_BOOLEAN, 0, NO_EXTRA },
5803464ebd5Sriastradh   { GL_TEXTURE_MATRIX, LOC_CUSTOM, TYPE_MATRIX, 0, extra_valid_texture_unit },
5813464ebd5Sriastradh   { GL_TEXTURE_STACK_DEPTH, LOC_CUSTOM, TYPE_INT, 0,
5823464ebd5Sriastradh     extra_valid_texture_unit  },
5833464ebd5Sriastradh
5843464ebd5Sriastradh   { GL_VERTEX_ARRAY, ARRAY_BOOL(Vertex.Enabled), NO_EXTRA },
5853464ebd5Sriastradh   { GL_VERTEX_ARRAY_SIZE, ARRAY_INT(Vertex.Size), NO_EXTRA },
5863464ebd5Sriastradh   { GL_VERTEX_ARRAY_TYPE, ARRAY_ENUM(Vertex.Type), NO_EXTRA },
5873464ebd5Sriastradh   { GL_VERTEX_ARRAY_STRIDE, ARRAY_INT(Vertex.Stride), NO_EXTRA },
5883464ebd5Sriastradh   { GL_NORMAL_ARRAY, ARRAY_BOOL(Normal.Enabled), NO_EXTRA },
5893464ebd5Sriastradh   { GL_NORMAL_ARRAY_TYPE, ARRAY_ENUM(Normal.Type), NO_EXTRA },
5903464ebd5Sriastradh   { GL_NORMAL_ARRAY_STRIDE, ARRAY_INT(Normal.Stride), NO_EXTRA },
5913464ebd5Sriastradh   { GL_COLOR_ARRAY, ARRAY_BOOL(Color.Enabled), NO_EXTRA },
5923464ebd5Sriastradh   { GL_COLOR_ARRAY_SIZE, ARRAY_INT(Color.Size), NO_EXTRA },
5933464ebd5Sriastradh   { GL_COLOR_ARRAY_TYPE, ARRAY_ENUM(Color.Type), NO_EXTRA },
5943464ebd5Sriastradh   { GL_COLOR_ARRAY_STRIDE, ARRAY_INT(Color.Stride), NO_EXTRA },
5953464ebd5Sriastradh   { GL_TEXTURE_COORD_ARRAY,
5963464ebd5Sriastradh     LOC_CUSTOM, TYPE_BOOLEAN, offsetof(struct gl_client_array, Enabled), NO_EXTRA },
5973464ebd5Sriastradh   { GL_TEXTURE_COORD_ARRAY_SIZE,
5983464ebd5Sriastradh     LOC_CUSTOM, TYPE_INT, offsetof(struct gl_client_array, Size), NO_EXTRA },
5993464ebd5Sriastradh   { GL_TEXTURE_COORD_ARRAY_TYPE,
6003464ebd5Sriastradh     LOC_CUSTOM, TYPE_ENUM, offsetof(struct gl_client_array, Type), NO_EXTRA },
6013464ebd5Sriastradh   { GL_TEXTURE_COORD_ARRAY_STRIDE,
6023464ebd5Sriastradh     LOC_CUSTOM, TYPE_INT, offsetof(struct gl_client_array, Stride), NO_EXTRA },
6033464ebd5Sriastradh
6043464ebd5Sriastradh   /* GL_ARB_ES2_compatibility */
6053464ebd5Sriastradh   { GL_SHADER_COMPILER, CONST(1), extra_ARB_ES2_compatibility },
6063464ebd5Sriastradh   { GL_MAX_VARYING_VECTORS, CONTEXT_INT(Const.MaxVarying),
6073464ebd5Sriastradh     extra_ARB_ES2_compatibility },
6083464ebd5Sriastradh   { GL_MAX_VERTEX_UNIFORM_VECTORS, LOC_CUSTOM, TYPE_INT, 0,
6093464ebd5Sriastradh     extra_ARB_ES2_compatibility },
6103464ebd5Sriastradh   { GL_MAX_FRAGMENT_UNIFORM_VECTORS, LOC_CUSTOM, TYPE_INT, 0,
6113464ebd5Sriastradh     extra_ARB_ES2_compatibility },
6123464ebd5Sriastradh
6133464ebd5Sriastradh   /* GL_ARB_multitexture */
6143464ebd5Sriastradh   { GL_MAX_TEXTURE_UNITS_ARB,
6153464ebd5Sriastradh     CONTEXT_INT(Const.MaxTextureUnits), extra_ARB_multitexture },
6163464ebd5Sriastradh   { GL_CLIENT_ACTIVE_TEXTURE_ARB,
6173464ebd5Sriastradh     LOC_CUSTOM, TYPE_INT, 0, extra_ARB_multitexture },
6183464ebd5Sriastradh
6193464ebd5Sriastradh   /* GL_ARB_texture_cube_map */
6203464ebd5Sriastradh   { GL_TEXTURE_CUBE_MAP_ARB, LOC_CUSTOM, TYPE_BOOLEAN, 0, NO_EXTRA },
6213464ebd5Sriastradh   /* S, T, and R are always set at the same time */
6223464ebd5Sriastradh   { GL_TEXTURE_GEN_STR_OES, LOC_TEXUNIT, TYPE_BIT_0,
6233464ebd5Sriastradh     offsetof(struct gl_texture_unit, TexGenEnabled), NO_EXTRA },
6243464ebd5Sriastradh
6253464ebd5Sriastradh   /* GL_ARB_multisample */
6263464ebd5Sriastradh   { GL_MULTISAMPLE_ARB, CONTEXT_BOOL(Multisample.Enabled), NO_EXTRA },
6273464ebd5Sriastradh   { GL_SAMPLE_ALPHA_TO_ONE_ARB, CONTEXT_BOOL(Multisample.SampleAlphaToOne), NO_EXTRA },
6283464ebd5Sriastradh
6293464ebd5Sriastradh   /* GL_ARB_vertex_buffer_object */
6303464ebd5Sriastradh   { GL_VERTEX_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT,
6313464ebd5Sriastradh     offsetof(struct gl_array_object, Vertex.BufferObj), NO_EXTRA },
6323464ebd5Sriastradh   { GL_NORMAL_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT,
6333464ebd5Sriastradh     offsetof(struct gl_array_object, Normal.BufferObj), NO_EXTRA },
6343464ebd5Sriastradh   { GL_COLOR_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT,
6353464ebd5Sriastradh     offsetof(struct gl_array_object, Color.BufferObj), NO_EXTRA },
6363464ebd5Sriastradh   { GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT, NO_OFFSET, NO_EXTRA },
6373464ebd5Sriastradh
6383464ebd5Sriastradh   /* GL_OES_point_sprite */
6393464ebd5Sriastradh   { GL_POINT_SPRITE_NV,
6403464ebd5Sriastradh     CONTEXT_BOOL(Point.PointSprite),
6413464ebd5Sriastradh     extra_NV_point_sprite_ARB_point_sprite },
6423464ebd5Sriastradh
6433464ebd5Sriastradh   /* GL_ARB_fragment_shader */
6443464ebd5Sriastradh   { GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB,
6453464ebd5Sriastradh     CONTEXT_INT(Const.FragmentProgram.MaxUniformComponents),
6463464ebd5Sriastradh     extra_ARB_fragment_shader },
6473464ebd5Sriastradh
6483464ebd5Sriastradh   /* GL_ARB_vertex_shader */
6493464ebd5Sriastradh   { GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB,
6503464ebd5Sriastradh     CONTEXT_INT(Const.VertexProgram.MaxUniformComponents),
6513464ebd5Sriastradh     extra_ARB_vertex_shader },
6523464ebd5Sriastradh   { GL_MAX_VARYING_FLOATS_ARB, LOC_CUSTOM, TYPE_INT, 0,
6533464ebd5Sriastradh     extra_ARB_vertex_shader },
6543464ebd5Sriastradh
6553464ebd5Sriastradh   /* GL_EXT_texture_lod_bias */
6563464ebd5Sriastradh   { GL_MAX_TEXTURE_LOD_BIAS_EXT, CONTEXT_FLOAT(Const.MaxTextureLodBias),
6573464ebd5Sriastradh	 extra_EXT_texture_lod_bias },
6583464ebd5Sriastradh
6593464ebd5Sriastradh   /* GL_EXT_texture_filter_anisotropic */
6603464ebd5Sriastradh   { GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT,
6613464ebd5Sriastradh     CONTEXT_FLOAT(Const.MaxTextureMaxAnisotropy),
6623464ebd5Sriastradh     extra_EXT_texture_filter_anisotropic },
6633464ebd5Sriastradh#endif /* FEATURE_GL || FEATURE_ES1 */
6643464ebd5Sriastradh
6653464ebd5Sriastradh#if FEATURE_ES1
6663464ebd5Sriastradh   { 0, 0, TYPE_API_MASK, API_OPENGLES_BIT },
6673464ebd5Sriastradh   /* XXX: OES_matrix_get */
6683464ebd5Sriastradh   { GL_MODELVIEW_MATRIX_FLOAT_AS_INT_BITS_OES },
6693464ebd5Sriastradh   { GL_PROJECTION_MATRIX_FLOAT_AS_INT_BITS_OES },
6703464ebd5Sriastradh   { GL_TEXTURE_MATRIX_FLOAT_AS_INT_BITS_OES },
6713464ebd5Sriastradh
6723464ebd5Sriastradh   /* OES_point_size_array */
6733464ebd5Sriastradh   { GL_POINT_SIZE_ARRAY_OES, ARRAY_FIELD(PointSize.Enabled, TYPE_BOOLEAN) },
6743464ebd5Sriastradh   { GL_POINT_SIZE_ARRAY_TYPE_OES, ARRAY_FIELD(PointSize.Type, TYPE_ENUM) },
6753464ebd5Sriastradh   { GL_POINT_SIZE_ARRAY_STRIDE_OES, ARRAY_FIELD(PointSize.Stride, TYPE_INT) },
6763464ebd5Sriastradh   { GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES, LOC_CUSTOM, TYPE_INT, 0 },
6773464ebd5Sriastradh#endif /* FEATURE_ES1 */
6783464ebd5Sriastradh
6793464ebd5Sriastradh#if FEATURE_GL || FEATURE_ES2
6803464ebd5Sriastradh   { 0, 0, TYPE_API_MASK, API_OPENGL_BIT | API_OPENGLES2_BIT, NO_EXTRA },
6813464ebd5Sriastradh   { GL_MAX_TEXTURE_COORDS_ARB, /* == GL_MAX_TEXTURE_COORDS_NV */
6823464ebd5Sriastradh     CONTEXT_INT(Const.MaxTextureCoordUnits),
6833464ebd5Sriastradh     extra_ARB_fragment_program_NV_fragment_program },
6843464ebd5Sriastradh
6853464ebd5Sriastradh   /* GL_ARB_draw_buffers */
6863464ebd5Sriastradh   { GL_MAX_DRAW_BUFFERS_ARB, CONTEXT_INT(Const.MaxDrawBuffers), NO_EXTRA },
6873464ebd5Sriastradh
6883464ebd5Sriastradh   { GL_BLEND_COLOR_EXT, LOC_CUSTOM, TYPE_FLOATN_4, 0, extra_new_frag_clamp },
6893464ebd5Sriastradh   /* GL_ARB_fragment_program */
6903464ebd5Sriastradh   { GL_MAX_TEXTURE_IMAGE_UNITS_ARB, /* == GL_MAX_TEXTURE_IMAGE_UNITS_NV */
6913464ebd5Sriastradh     CONTEXT_INT(Const.MaxTextureImageUnits),
6923464ebd5Sriastradh     extra_ARB_fragment_program_NV_fragment_program },
6933464ebd5Sriastradh   { GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB,
6943464ebd5Sriastradh     CONTEXT_INT(Const.MaxVertexTextureImageUnits), extra_ARB_vertex_shader },
6953464ebd5Sriastradh   { GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB,
6963464ebd5Sriastradh     CONTEXT_INT(Const.MaxCombinedTextureImageUnits),
6973464ebd5Sriastradh     extra_ARB_vertex_shader },
6983464ebd5Sriastradh
6993464ebd5Sriastradh   /* GL_ARB_shader_objects
7003464ebd5Sriastradh    * Actually, this token isn't part of GL_ARB_shader_objects, but is
7013464ebd5Sriastradh    * close enough for now. */
7023464ebd5Sriastradh   { GL_CURRENT_PROGRAM, LOC_CUSTOM, TYPE_INT, 0, extra_ARB_shader_objects },
7033464ebd5Sriastradh
7043464ebd5Sriastradh   /* OpenGL 2.0 */
7053464ebd5Sriastradh   { GL_STENCIL_BACK_FUNC, CONTEXT_ENUM(Stencil.Function[1]), NO_EXTRA },
7063464ebd5Sriastradh   { GL_STENCIL_BACK_VALUE_MASK, CONTEXT_INT(Stencil.ValueMask[1]), NO_EXTRA },
7073464ebd5Sriastradh   { GL_STENCIL_BACK_WRITEMASK, CONTEXT_INT(Stencil.WriteMask[1]), NO_EXTRA },
7083464ebd5Sriastradh   { GL_STENCIL_BACK_REF, CONTEXT_INT(Stencil.Ref[1]), NO_EXTRA },
7093464ebd5Sriastradh   { GL_STENCIL_BACK_FAIL, CONTEXT_ENUM(Stencil.FailFunc[1]), NO_EXTRA },
7103464ebd5Sriastradh   { GL_STENCIL_BACK_PASS_DEPTH_FAIL, CONTEXT_ENUM(Stencil.ZFailFunc[1]), NO_EXTRA },
7113464ebd5Sriastradh   { GL_STENCIL_BACK_PASS_DEPTH_PASS, CONTEXT_ENUM(Stencil.ZPassFunc[1]), NO_EXTRA },
7123464ebd5Sriastradh
7133464ebd5Sriastradh   { GL_MAX_VERTEX_ATTRIBS_ARB,
7143464ebd5Sriastradh     CONTEXT_INT(Const.VertexProgram.MaxAttribs),
7153464ebd5Sriastradh     extra_ARB_vertex_program_version_es2 },
7163464ebd5Sriastradh
7173464ebd5Sriastradh   /* OES_texture_3D */
7183464ebd5Sriastradh   { GL_TEXTURE_BINDING_3D, LOC_CUSTOM, TYPE_INT, TEXTURE_3D_INDEX, NO_EXTRA },
7193464ebd5Sriastradh   { GL_MAX_3D_TEXTURE_SIZE, LOC_CUSTOM, TYPE_INT,
7203464ebd5Sriastradh     offsetof(struct gl_context, Const.Max3DTextureLevels), NO_EXTRA },
7213464ebd5Sriastradh
7223464ebd5Sriastradh   /* GL_ARB_fragment_program/OES_standard_derivatives */
7233464ebd5Sriastradh   { GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB,
7243464ebd5Sriastradh     CONTEXT_ENUM(Hint.FragmentShaderDerivative), extra_ARB_fragment_shader },
7253464ebd5Sriastradh#endif /* FEATURE_GL || FEATURE_ES2 */
7263464ebd5Sriastradh
7273464ebd5Sriastradh#if FEATURE_ES2
7283464ebd5Sriastradh   /* Enums unique to OpenGL ES 2.0 */
7293464ebd5Sriastradh   { 0, 0, TYPE_API_MASK, API_OPENGLES2_BIT, NO_EXTRA },
7303464ebd5Sriastradh   { GL_MAX_FRAGMENT_UNIFORM_VECTORS, LOC_CUSTOM, TYPE_INT, 0, NO_EXTRA },
7313464ebd5Sriastradh   { GL_MAX_VARYING_VECTORS, CONTEXT_INT(Const.MaxVarying), NO_EXTRA },
7323464ebd5Sriastradh   { GL_MAX_VERTEX_UNIFORM_VECTORS, LOC_CUSTOM, TYPE_INT, 0, NO_EXTRA },
7333464ebd5Sriastradh   { GL_SHADER_COMPILER, CONST(1), NO_EXTRA },
7343464ebd5Sriastradh   /* OES_get_program_binary */
7353464ebd5Sriastradh   { GL_NUM_SHADER_BINARY_FORMATS, CONST(0), NO_EXTRA },
7363464ebd5Sriastradh   { GL_SHADER_BINARY_FORMATS, CONST(0), NO_EXTRA },
7373464ebd5Sriastradh#endif /* FEATURE_ES2 */
7383464ebd5Sriastradh
7393464ebd5Sriastradh#if FEATURE_GL
7403464ebd5Sriastradh   /* Remaining enums are only in OpenGL */
7413464ebd5Sriastradh   { 0, 0, TYPE_API_MASK, API_OPENGL_BIT, NO_EXTRA },
7423464ebd5Sriastradh   { GL_ACCUM_RED_BITS, BUFFER_INT(Visual.accumRedBits), NO_EXTRA },
7433464ebd5Sriastradh   { GL_ACCUM_GREEN_BITS, BUFFER_INT(Visual.accumGreenBits), NO_EXTRA },
7443464ebd5Sriastradh   { GL_ACCUM_BLUE_BITS, BUFFER_INT(Visual.accumBlueBits), NO_EXTRA },
7453464ebd5Sriastradh   { GL_ACCUM_ALPHA_BITS, BUFFER_INT(Visual.accumAlphaBits), NO_EXTRA },
7463464ebd5Sriastradh   { GL_ACCUM_CLEAR_VALUE, CONTEXT_FIELD(Accum.ClearColor[0], TYPE_FLOATN_4), NO_EXTRA },
7473464ebd5Sriastradh   { GL_ALPHA_BIAS, CONTEXT_FLOAT(Pixel.AlphaBias), NO_EXTRA },
7483464ebd5Sriastradh   { GL_ALPHA_SCALE, CONTEXT_FLOAT(Pixel.AlphaScale), NO_EXTRA },
7493464ebd5Sriastradh   { GL_ATTRIB_STACK_DEPTH, CONTEXT_INT(AttribStackDepth), NO_EXTRA },
7503464ebd5Sriastradh   { GL_AUTO_NORMAL, CONTEXT_BOOL(Eval.AutoNormal), NO_EXTRA },
7513464ebd5Sriastradh   { GL_AUX_BUFFERS, BUFFER_INT(Visual.numAuxBuffers), NO_EXTRA },
7523464ebd5Sriastradh   { GL_BLUE_BIAS, CONTEXT_FLOAT(Pixel.BlueBias), NO_EXTRA },
7533464ebd5Sriastradh   { GL_BLUE_SCALE, CONTEXT_FLOAT(Pixel.BlueScale), NO_EXTRA },
7543464ebd5Sriastradh   { GL_CLIENT_ATTRIB_STACK_DEPTH, CONTEXT_INT(ClientAttribStackDepth), NO_EXTRA },
7553464ebd5Sriastradh   { GL_COLOR_MATERIAL_FACE, CONTEXT_ENUM(Light.ColorMaterialFace), NO_EXTRA },
7563464ebd5Sriastradh   { GL_COLOR_MATERIAL_PARAMETER, CONTEXT_ENUM(Light.ColorMaterialMode), NO_EXTRA },
7573464ebd5Sriastradh   { GL_CURRENT_INDEX,
7583464ebd5Sriastradh     CONTEXT_FLOAT(Current.Attrib[VERT_ATTRIB_COLOR_INDEX][0]),
7593464ebd5Sriastradh     extra_flush_current },
7603464ebd5Sriastradh   { GL_CURRENT_RASTER_COLOR,
7613464ebd5Sriastradh     CONTEXT_FIELD(Current.RasterColor[0], TYPE_FLOATN_4), NO_EXTRA },
7623464ebd5Sriastradh   { GL_CURRENT_RASTER_DISTANCE, CONTEXT_FLOAT(Current.RasterDistance), NO_EXTRA },
7633464ebd5Sriastradh   { GL_CURRENT_RASTER_INDEX, CONST(1), NO_EXTRA },
7643464ebd5Sriastradh   { GL_CURRENT_RASTER_POSITION, CONTEXT_FLOAT4(Current.RasterPos[0]), NO_EXTRA },
7653464ebd5Sriastradh   { GL_CURRENT_RASTER_SECONDARY_COLOR,
7663464ebd5Sriastradh     CONTEXT_FIELD(Current.RasterSecondaryColor[0], TYPE_FLOATN_4), NO_EXTRA },
7673464ebd5Sriastradh   { GL_CURRENT_RASTER_TEXTURE_COORDS, LOC_CUSTOM, TYPE_FLOAT_4, 0,
7683464ebd5Sriastradh     extra_valid_texture_unit },
7693464ebd5Sriastradh   { GL_CURRENT_RASTER_POSITION_VALID, CONTEXT_BOOL(Current.RasterPosValid), NO_EXTRA },
7703464ebd5Sriastradh   { GL_DEPTH_BIAS, CONTEXT_FLOAT(Pixel.DepthBias), NO_EXTRA },
7713464ebd5Sriastradh   { GL_DEPTH_SCALE, CONTEXT_FLOAT(Pixel.DepthScale), NO_EXTRA },
7723464ebd5Sriastradh   { GL_DOUBLEBUFFER, BUFFER_INT(Visual.doubleBufferMode), NO_EXTRA },
7733464ebd5Sriastradh   { GL_DRAW_BUFFER, BUFFER_ENUM(ColorDrawBuffer[0]), NO_EXTRA },
7743464ebd5Sriastradh   { GL_EDGE_FLAG, LOC_CUSTOM, TYPE_BOOLEAN, 0, NO_EXTRA },
7753464ebd5Sriastradh   { GL_FEEDBACK_BUFFER_SIZE, CONTEXT_INT(Feedback.BufferSize), NO_EXTRA },
7763464ebd5Sriastradh   { GL_FEEDBACK_BUFFER_TYPE, CONTEXT_ENUM(Feedback.Type), NO_EXTRA },
7773464ebd5Sriastradh   { GL_FOG_INDEX, CONTEXT_FLOAT(Fog.Index), NO_EXTRA },
7783464ebd5Sriastradh   { GL_GREEN_BIAS, CONTEXT_FLOAT(Pixel.GreenBias), NO_EXTRA },
7793464ebd5Sriastradh   { GL_GREEN_SCALE, CONTEXT_FLOAT(Pixel.GreenScale), NO_EXTRA },
7803464ebd5Sriastradh   { GL_INDEX_BITS, BUFFER_INT(Visual.indexBits), extra_new_buffers },
7813464ebd5Sriastradh   { GL_INDEX_CLEAR_VALUE, CONTEXT_INT(Color.ClearIndex), NO_EXTRA },
7823464ebd5Sriastradh   { GL_INDEX_MODE, CONST(0) , NO_EXTRA},
7833464ebd5Sriastradh   { GL_INDEX_OFFSET, CONTEXT_INT(Pixel.IndexOffset), NO_EXTRA },
7843464ebd5Sriastradh   { GL_INDEX_SHIFT, CONTEXT_INT(Pixel.IndexShift), NO_EXTRA },
7853464ebd5Sriastradh   { GL_INDEX_WRITEMASK, CONTEXT_INT(Color.IndexMask), NO_EXTRA },
7863464ebd5Sriastradh   { GL_LIGHT_MODEL_COLOR_CONTROL, CONTEXT_ENUM(Light.Model.ColorControl), NO_EXTRA },
7873464ebd5Sriastradh   { GL_LIGHT_MODEL_LOCAL_VIEWER, CONTEXT_BOOL(Light.Model.LocalViewer), NO_EXTRA },
7883464ebd5Sriastradh   { GL_LINE_STIPPLE, CONTEXT_BOOL(Line.StippleFlag), NO_EXTRA },
7893464ebd5Sriastradh   { GL_LINE_STIPPLE_PATTERN, LOC_CUSTOM, TYPE_INT, 0, NO_EXTRA },
7903464ebd5Sriastradh   { GL_LINE_STIPPLE_REPEAT, CONTEXT_INT(Line.StippleFactor), NO_EXTRA },
7913464ebd5Sriastradh   { GL_LINE_WIDTH_GRANULARITY, CONTEXT_FLOAT(Const.LineWidthGranularity), NO_EXTRA },
7923464ebd5Sriastradh   { GL_LIST_BASE, CONTEXT_INT(List.ListBase), NO_EXTRA },
7933464ebd5Sriastradh   { GL_LIST_INDEX, LOC_CUSTOM, TYPE_INT, 0, NO_EXTRA },
7943464ebd5Sriastradh   { GL_LIST_MODE, LOC_CUSTOM, TYPE_ENUM, 0, NO_EXTRA },
7953464ebd5Sriastradh   { GL_INDEX_LOGIC_OP, CONTEXT_BOOL(Color.IndexLogicOpEnabled), NO_EXTRA },
7963464ebd5Sriastradh   { GL_MAP1_COLOR_4, CONTEXT_BOOL(Eval.Map1Color4), NO_EXTRA },
7973464ebd5Sriastradh   { GL_MAP1_GRID_DOMAIN, CONTEXT_FLOAT2(Eval.MapGrid1u1), NO_EXTRA },
7983464ebd5Sriastradh   { GL_MAP1_GRID_SEGMENTS, CONTEXT_INT(Eval.MapGrid1un), NO_EXTRA },
7993464ebd5Sriastradh   { GL_MAP1_INDEX, CONTEXT_BOOL(Eval.Map1Index), NO_EXTRA },
8003464ebd5Sriastradh   { GL_MAP1_NORMAL, CONTEXT_BOOL(Eval.Map1Normal), NO_EXTRA },
8013464ebd5Sriastradh   { GL_MAP1_TEXTURE_COORD_1, CONTEXT_BOOL(Eval.Map1TextureCoord1), NO_EXTRA },
8023464ebd5Sriastradh   { GL_MAP1_TEXTURE_COORD_2, CONTEXT_BOOL(Eval.Map1TextureCoord2), NO_EXTRA },
8033464ebd5Sriastradh   { GL_MAP1_TEXTURE_COORD_3, CONTEXT_BOOL(Eval.Map1TextureCoord3), NO_EXTRA },
8043464ebd5Sriastradh   { GL_MAP1_TEXTURE_COORD_4, CONTEXT_BOOL(Eval.Map1TextureCoord4), NO_EXTRA },
8053464ebd5Sriastradh   { GL_MAP1_VERTEX_3, CONTEXT_BOOL(Eval.Map1Vertex3), NO_EXTRA },
8063464ebd5Sriastradh   { GL_MAP1_VERTEX_4, CONTEXT_BOOL(Eval.Map1Vertex4), NO_EXTRA },
8073464ebd5Sriastradh   { GL_MAP2_COLOR_4, CONTEXT_BOOL(Eval.Map2Color4), NO_EXTRA },
8083464ebd5Sriastradh   { GL_MAP2_GRID_DOMAIN, LOC_CUSTOM, TYPE_FLOAT_4, 0, NO_EXTRA },
8093464ebd5Sriastradh   { GL_MAP2_GRID_SEGMENTS, CONTEXT_INT2(Eval.MapGrid2un), NO_EXTRA },
8103464ebd5Sriastradh   { GL_MAP2_INDEX, CONTEXT_BOOL(Eval.Map2Index), NO_EXTRA },
8113464ebd5Sriastradh   { GL_MAP2_NORMAL, CONTEXT_BOOL(Eval.Map2Normal), NO_EXTRA },
8123464ebd5Sriastradh   { GL_MAP2_TEXTURE_COORD_1, CONTEXT_BOOL(Eval.Map2TextureCoord1), NO_EXTRA },
8133464ebd5Sriastradh   { GL_MAP2_TEXTURE_COORD_2, CONTEXT_BOOL(Eval.Map2TextureCoord2), NO_EXTRA },
8143464ebd5Sriastradh   { GL_MAP2_TEXTURE_COORD_3, CONTEXT_BOOL(Eval.Map2TextureCoord3), NO_EXTRA },
8153464ebd5Sriastradh   { GL_MAP2_TEXTURE_COORD_4, CONTEXT_BOOL(Eval.Map2TextureCoord4), NO_EXTRA },
8163464ebd5Sriastradh   { GL_MAP2_VERTEX_3, CONTEXT_BOOL(Eval.Map2Vertex3), NO_EXTRA },
8173464ebd5Sriastradh   { GL_MAP2_VERTEX_4, CONTEXT_BOOL(Eval.Map2Vertex4), NO_EXTRA },
8183464ebd5Sriastradh   { GL_MAP_COLOR, CONTEXT_BOOL(Pixel.MapColorFlag), NO_EXTRA },
8193464ebd5Sriastradh   { GL_MAP_STENCIL, CONTEXT_BOOL(Pixel.MapStencilFlag), NO_EXTRA },
8203464ebd5Sriastradh   { GL_MAX_ATTRIB_STACK_DEPTH, CONST(MAX_ATTRIB_STACK_DEPTH), NO_EXTRA },
8213464ebd5Sriastradh   { GL_MAX_CLIENT_ATTRIB_STACK_DEPTH, CONST(MAX_CLIENT_ATTRIB_STACK_DEPTH), NO_EXTRA },
8223464ebd5Sriastradh
8233464ebd5Sriastradh   { GL_MAX_EVAL_ORDER, CONST(MAX_EVAL_ORDER), NO_EXTRA },
8243464ebd5Sriastradh   { GL_MAX_LIST_NESTING, CONST(MAX_LIST_NESTING), NO_EXTRA },
8253464ebd5Sriastradh   { GL_MAX_NAME_STACK_DEPTH, CONST(MAX_NAME_STACK_DEPTH), NO_EXTRA },
8263464ebd5Sriastradh   { GL_MAX_PIXEL_MAP_TABLE, CONST(MAX_PIXEL_MAP_TABLE), NO_EXTRA },
8273464ebd5Sriastradh   { GL_NAME_STACK_DEPTH, CONTEXT_INT(Select.NameStackDepth), NO_EXTRA },
8283464ebd5Sriastradh   { GL_PACK_LSB_FIRST, CONTEXT_BOOL(Pack.LsbFirst), NO_EXTRA },
8293464ebd5Sriastradh   { GL_PACK_ROW_LENGTH, CONTEXT_INT(Pack.RowLength), NO_EXTRA },
8303464ebd5Sriastradh   { GL_PACK_SKIP_PIXELS, CONTEXT_INT(Pack.SkipPixels), NO_EXTRA },
8313464ebd5Sriastradh   { GL_PACK_SKIP_ROWS, CONTEXT_INT(Pack.SkipRows), NO_EXTRA },
8323464ebd5Sriastradh   { GL_PACK_SWAP_BYTES, CONTEXT_BOOL(Pack.SwapBytes), NO_EXTRA },
8333464ebd5Sriastradh   { GL_PACK_IMAGE_HEIGHT_EXT, CONTEXT_INT(Pack.ImageHeight), NO_EXTRA },
8343464ebd5Sriastradh   { GL_PACK_INVERT_MESA, CONTEXT_BOOL(Pack.Invert), NO_EXTRA },
8353464ebd5Sriastradh   { GL_PIXEL_MAP_A_TO_A_SIZE, CONTEXT_INT(PixelMaps.AtoA.Size), NO_EXTRA },
8363464ebd5Sriastradh   { GL_PIXEL_MAP_B_TO_B_SIZE, CONTEXT_INT(PixelMaps.BtoB.Size), NO_EXTRA },
8373464ebd5Sriastradh   { GL_PIXEL_MAP_G_TO_G_SIZE, CONTEXT_INT(PixelMaps.GtoG.Size), NO_EXTRA },
8383464ebd5Sriastradh   { GL_PIXEL_MAP_I_TO_A_SIZE, CONTEXT_INT(PixelMaps.ItoA.Size), NO_EXTRA },
8393464ebd5Sriastradh   { GL_PIXEL_MAP_I_TO_B_SIZE, CONTEXT_INT(PixelMaps.ItoB.Size), NO_EXTRA },
8403464ebd5Sriastradh   { GL_PIXEL_MAP_I_TO_G_SIZE, CONTEXT_INT(PixelMaps.ItoG.Size), NO_EXTRA },
8413464ebd5Sriastradh   { GL_PIXEL_MAP_I_TO_I_SIZE, CONTEXT_INT(PixelMaps.ItoI.Size), NO_EXTRA },
8423464ebd5Sriastradh   { GL_PIXEL_MAP_I_TO_R_SIZE, CONTEXT_INT(PixelMaps.ItoR.Size), NO_EXTRA },
8433464ebd5Sriastradh   { GL_PIXEL_MAP_R_TO_R_SIZE, CONTEXT_INT(PixelMaps.RtoR.Size), NO_EXTRA },
8443464ebd5Sriastradh   { GL_PIXEL_MAP_S_TO_S_SIZE, CONTEXT_INT(PixelMaps.StoS.Size), NO_EXTRA },
8453464ebd5Sriastradh   { GL_POINT_SIZE_GRANULARITY, CONTEXT_FLOAT(Const.PointSizeGranularity), NO_EXTRA },
8463464ebd5Sriastradh   { GL_POLYGON_MODE, CONTEXT_ENUM2(Polygon.FrontMode), NO_EXTRA },
8473464ebd5Sriastradh   { GL_POLYGON_OFFSET_BIAS_EXT, CONTEXT_FLOAT(Polygon.OffsetUnits), NO_EXTRA },
8483464ebd5Sriastradh   { GL_POLYGON_OFFSET_POINT, CONTEXT_BOOL(Polygon.OffsetPoint), NO_EXTRA },
8493464ebd5Sriastradh   { GL_POLYGON_OFFSET_LINE, CONTEXT_BOOL(Polygon.OffsetLine), NO_EXTRA },
8503464ebd5Sriastradh   { GL_POLYGON_SMOOTH, CONTEXT_BOOL(Polygon.SmoothFlag), NO_EXTRA },
8513464ebd5Sriastradh   { GL_POLYGON_SMOOTH_HINT, CONTEXT_ENUM(Hint.PolygonSmooth), NO_EXTRA },
8523464ebd5Sriastradh   { GL_POLYGON_STIPPLE, CONTEXT_BOOL(Polygon.StippleFlag), NO_EXTRA },
8533464ebd5Sriastradh   { GL_READ_BUFFER, LOC_CUSTOM, TYPE_ENUM, NO_OFFSET, NO_EXTRA },
8543464ebd5Sriastradh   { GL_RED_BIAS, CONTEXT_FLOAT(Pixel.RedBias), NO_EXTRA },
8553464ebd5Sriastradh   { GL_RED_SCALE, CONTEXT_FLOAT(Pixel.RedScale), NO_EXTRA },
8563464ebd5Sriastradh   { GL_RENDER_MODE, CONTEXT_ENUM(RenderMode), NO_EXTRA },
8573464ebd5Sriastradh   { GL_RGBA_MODE, CONST(1), NO_EXTRA },
8583464ebd5Sriastradh   { GL_SELECTION_BUFFER_SIZE, CONTEXT_INT(Select.BufferSize), NO_EXTRA },
8593464ebd5Sriastradh   { GL_SHARED_TEXTURE_PALETTE_EXT, CONTEXT_BOOL(Texture.SharedPalette), NO_EXTRA },
8603464ebd5Sriastradh
8613464ebd5Sriastradh   { GL_STEREO, BUFFER_INT(Visual.stereoMode), NO_EXTRA },
8623464ebd5Sriastradh
8633464ebd5Sriastradh   { GL_TEXTURE_1D, LOC_CUSTOM, TYPE_BOOLEAN, NO_OFFSET, NO_EXTRA },
8643464ebd5Sriastradh   { GL_TEXTURE_3D, LOC_CUSTOM, TYPE_BOOLEAN, NO_OFFSET, NO_EXTRA },
8653464ebd5Sriastradh   { GL_TEXTURE_1D_ARRAY_EXT, LOC_CUSTOM, TYPE_BOOLEAN, NO_OFFSET, NO_EXTRA },
8663464ebd5Sriastradh   { GL_TEXTURE_2D_ARRAY_EXT, LOC_CUSTOM, TYPE_BOOLEAN, NO_OFFSET, NO_EXTRA },
8673464ebd5Sriastradh
8683464ebd5Sriastradh   { GL_TEXTURE_BINDING_1D, LOC_CUSTOM, TYPE_INT, TEXTURE_1D_INDEX, NO_EXTRA },
8693464ebd5Sriastradh   { GL_TEXTURE_BINDING_1D_ARRAY, LOC_CUSTOM, TYPE_INT,
8703464ebd5Sriastradh     TEXTURE_1D_ARRAY_INDEX, extra_MESA_texture_array },
8713464ebd5Sriastradh   { GL_TEXTURE_BINDING_2D_ARRAY, LOC_CUSTOM, TYPE_INT,
8723464ebd5Sriastradh     TEXTURE_1D_ARRAY_INDEX, extra_MESA_texture_array },
8733464ebd5Sriastradh   { GL_MAX_ARRAY_TEXTURE_LAYERS_EXT,
8743464ebd5Sriastradh     CONTEXT_INT(Const.MaxArrayTextureLayers), extra_MESA_texture_array },
8753464ebd5Sriastradh
8763464ebd5Sriastradh   { GL_TEXTURE_GEN_S, LOC_TEXUNIT, TYPE_BIT_0,
8773464ebd5Sriastradh     offsetof(struct gl_texture_unit, TexGenEnabled), NO_EXTRA },
8783464ebd5Sriastradh   { GL_TEXTURE_GEN_T, LOC_TEXUNIT, TYPE_BIT_1,
8793464ebd5Sriastradh     offsetof(struct gl_texture_unit, TexGenEnabled), NO_EXTRA },
8803464ebd5Sriastradh   { GL_TEXTURE_GEN_R, LOC_TEXUNIT, TYPE_BIT_2,
8813464ebd5Sriastradh     offsetof(struct gl_texture_unit, TexGenEnabled), NO_EXTRA },
8823464ebd5Sriastradh   { GL_TEXTURE_GEN_Q, LOC_TEXUNIT, TYPE_BIT_3,
8833464ebd5Sriastradh     offsetof(struct gl_texture_unit, TexGenEnabled), NO_EXTRA },
8843464ebd5Sriastradh   { GL_UNPACK_LSB_FIRST, CONTEXT_BOOL(Unpack.LsbFirst), NO_EXTRA },
8853464ebd5Sriastradh   { GL_UNPACK_ROW_LENGTH, CONTEXT_INT(Unpack.RowLength), NO_EXTRA },
8863464ebd5Sriastradh   { GL_UNPACK_SKIP_PIXELS, CONTEXT_INT(Unpack.SkipPixels), NO_EXTRA },
8873464ebd5Sriastradh   { GL_UNPACK_SKIP_ROWS, CONTEXT_INT(Unpack.SkipRows), NO_EXTRA },
8883464ebd5Sriastradh   { GL_UNPACK_SWAP_BYTES, CONTEXT_BOOL(Unpack.SwapBytes), NO_EXTRA },
8893464ebd5Sriastradh   { GL_UNPACK_SKIP_IMAGES_EXT, CONTEXT_INT(Unpack.SkipImages), NO_EXTRA },
8903464ebd5Sriastradh   { GL_UNPACK_IMAGE_HEIGHT_EXT, CONTEXT_INT(Unpack.ImageHeight), NO_EXTRA },
8913464ebd5Sriastradh   { GL_UNPACK_CLIENT_STORAGE_APPLE, CONTEXT_BOOL(Unpack.ClientStorage), NO_EXTRA },
8923464ebd5Sriastradh   { GL_ZOOM_X, CONTEXT_FLOAT(Pixel.ZoomX), NO_EXTRA },
8933464ebd5Sriastradh   { GL_ZOOM_Y, CONTEXT_FLOAT(Pixel.ZoomY), NO_EXTRA },
8943464ebd5Sriastradh
8953464ebd5Sriastradh   /* Vertex arrays */
8963464ebd5Sriastradh   { GL_VERTEX_ARRAY_COUNT_EXT, CONST(0), NO_EXTRA },
8973464ebd5Sriastradh   { GL_NORMAL_ARRAY_COUNT_EXT, CONST(0), NO_EXTRA },
8983464ebd5Sriastradh   { GL_COLOR_ARRAY_COUNT_EXT, CONST(0), NO_EXTRA },
8993464ebd5Sriastradh   { GL_INDEX_ARRAY, ARRAY_BOOL(Index.Enabled), NO_EXTRA },
9003464ebd5Sriastradh   { GL_INDEX_ARRAY_TYPE, ARRAY_ENUM(Index.Type), NO_EXTRA },
9013464ebd5Sriastradh   { GL_INDEX_ARRAY_STRIDE, ARRAY_INT(Index.Stride), NO_EXTRA },
9023464ebd5Sriastradh   { GL_INDEX_ARRAY_COUNT_EXT, CONST(0), NO_EXTRA },
9033464ebd5Sriastradh   { GL_TEXTURE_COORD_ARRAY_COUNT_EXT, CONST(0), NO_EXTRA },
9043464ebd5Sriastradh   { GL_EDGE_FLAG_ARRAY, ARRAY_BOOL(EdgeFlag.Enabled), NO_EXTRA },
9053464ebd5Sriastradh   { GL_EDGE_FLAG_ARRAY_STRIDE, ARRAY_INT(EdgeFlag.Stride), NO_EXTRA },
9063464ebd5Sriastradh   { GL_EDGE_FLAG_ARRAY_COUNT_EXT, CONST(0), NO_EXTRA },
9073464ebd5Sriastradh
9083464ebd5Sriastradh   /* GL_ARB_texture_compression */
9093464ebd5Sriastradh   { GL_TEXTURE_COMPRESSION_HINT_ARB, CONTEXT_INT(Hint.TextureCompression), NO_EXTRA },
9103464ebd5Sriastradh
9113464ebd5Sriastradh   /* GL_EXT_compiled_vertex_array */
9123464ebd5Sriastradh   { GL_ARRAY_ELEMENT_LOCK_FIRST_EXT, CONTEXT_INT(Array.LockFirst),
9133464ebd5Sriastradh     extra_EXT_compiled_vertex_array },
9143464ebd5Sriastradh   { GL_ARRAY_ELEMENT_LOCK_COUNT_EXT, CONTEXT_INT(Array.LockCount),
9153464ebd5Sriastradh     extra_EXT_compiled_vertex_array },
9163464ebd5Sriastradh
9173464ebd5Sriastradh   /* GL_ARB_transpose_matrix */
9183464ebd5Sriastradh   { GL_TRANSPOSE_MODELVIEW_MATRIX_ARB,
9193464ebd5Sriastradh     CONTEXT_MATRIX_T(ModelviewMatrixStack), NO_EXTRA },
9203464ebd5Sriastradh   { GL_TRANSPOSE_PROJECTION_MATRIX_ARB,
9213464ebd5Sriastradh     CONTEXT_MATRIX_T(ProjectionMatrixStack.Top), NO_EXTRA },
9223464ebd5Sriastradh   { GL_TRANSPOSE_TEXTURE_MATRIX_ARB, CONTEXT_MATRIX_T(TextureMatrixStack), NO_EXTRA },
9233464ebd5Sriastradh
9243464ebd5Sriastradh   /* GL_EXT_secondary_color */
9253464ebd5Sriastradh   { GL_COLOR_SUM_EXT, CONTEXT_BOOL(Fog.ColorSumEnabled),
9263464ebd5Sriastradh     extra_EXT_secondary_color_ARB_vertex_program },
9273464ebd5Sriastradh   { GL_CURRENT_SECONDARY_COLOR_EXT,
9283464ebd5Sriastradh     CONTEXT_FIELD(Current.Attrib[VERT_ATTRIB_COLOR1][0], TYPE_FLOATN_4),
9293464ebd5Sriastradh     extra_EXT_secondary_color_flush_current },
9303464ebd5Sriastradh   { GL_SECONDARY_COLOR_ARRAY_EXT, ARRAY_BOOL(SecondaryColor.Enabled),
9313464ebd5Sriastradh     extra_EXT_secondary_color },
9323464ebd5Sriastradh   { GL_SECONDARY_COLOR_ARRAY_TYPE_EXT, ARRAY_ENUM(SecondaryColor.Type),
9333464ebd5Sriastradh     extra_EXT_secondary_color },
9343464ebd5Sriastradh   { GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT, ARRAY_INT(SecondaryColor.Stride),
9353464ebd5Sriastradh     extra_EXT_secondary_color },
9363464ebd5Sriastradh   { GL_SECONDARY_COLOR_ARRAY_SIZE_EXT, ARRAY_INT(SecondaryColor.Size),
9373464ebd5Sriastradh     extra_EXT_secondary_color },
9383464ebd5Sriastradh
9393464ebd5Sriastradh   /* GL_EXT_fog_coord */
9403464ebd5Sriastradh   { GL_CURRENT_FOG_COORDINATE_EXT,
9413464ebd5Sriastradh     CONTEXT_FLOAT(Current.Attrib[VERT_ATTRIB_FOG][0]),
9423464ebd5Sriastradh     extra_EXT_fog_coord_flush_current },
9433464ebd5Sriastradh   { GL_FOG_COORDINATE_ARRAY_EXT, ARRAY_BOOL(FogCoord.Enabled),
9443464ebd5Sriastradh     extra_EXT_fog_coord },
9453464ebd5Sriastradh   { GL_FOG_COORDINATE_ARRAY_TYPE_EXT, ARRAY_ENUM(FogCoord.Type),
9463464ebd5Sriastradh     extra_EXT_fog_coord },
9473464ebd5Sriastradh   { GL_FOG_COORDINATE_ARRAY_STRIDE_EXT, ARRAY_INT(FogCoord.Stride),
9483464ebd5Sriastradh     extra_EXT_fog_coord },
9493464ebd5Sriastradh   { GL_FOG_COORDINATE_SOURCE_EXT, CONTEXT_ENUM(Fog.FogCoordinateSource),
9503464ebd5Sriastradh     extra_EXT_fog_coord },
9513464ebd5Sriastradh
9523464ebd5Sriastradh   /* GL_IBM_rasterpos_clip */
9533464ebd5Sriastradh   { GL_RASTER_POSITION_UNCLIPPED_IBM,
9543464ebd5Sriastradh     CONTEXT_BOOL(Transform.RasterPositionUnclipped),
9553464ebd5Sriastradh     extra_IBM_rasterpos_clip },
9563464ebd5Sriastradh
9573464ebd5Sriastradh   /* GL_NV_point_sprite */
9583464ebd5Sriastradh   { GL_POINT_SPRITE_R_MODE_NV,
9593464ebd5Sriastradh     CONTEXT_ENUM(Point.SpriteRMode), extra_NV_point_sprite },
9603464ebd5Sriastradh   { GL_POINT_SPRITE_COORD_ORIGIN, CONTEXT_ENUM(Point.SpriteOrigin),
9613464ebd5Sriastradh     extra_NV_point_sprite_ARB_point_sprite },
9623464ebd5Sriastradh
9633464ebd5Sriastradh   /* GL_NV_vertex_program */
9643464ebd5Sriastradh   { GL_VERTEX_PROGRAM_BINDING_NV, LOC_CUSTOM, TYPE_INT, 0,
9653464ebd5Sriastradh     extra_NV_vertex_program },
9663464ebd5Sriastradh   { GL_VERTEX_ATTRIB_ARRAY0_NV, ARRAY_BOOL(VertexAttrib[0].Enabled),
9673464ebd5Sriastradh     extra_NV_vertex_program },
9683464ebd5Sriastradh   { GL_VERTEX_ATTRIB_ARRAY1_NV, ARRAY_BOOL(VertexAttrib[1].Enabled),
9693464ebd5Sriastradh     extra_NV_vertex_program },
9703464ebd5Sriastradh   { GL_VERTEX_ATTRIB_ARRAY2_NV, ARRAY_BOOL(VertexAttrib[2].Enabled),
9713464ebd5Sriastradh     extra_NV_vertex_program },
9723464ebd5Sriastradh   { GL_VERTEX_ATTRIB_ARRAY3_NV, ARRAY_BOOL(VertexAttrib[3].Enabled),
9733464ebd5Sriastradh     extra_NV_vertex_program },
9743464ebd5Sriastradh   { GL_VERTEX_ATTRIB_ARRAY4_NV, ARRAY_BOOL(VertexAttrib[4].Enabled),
9753464ebd5Sriastradh     extra_NV_vertex_program },
9763464ebd5Sriastradh   { GL_VERTEX_ATTRIB_ARRAY5_NV, ARRAY_BOOL(VertexAttrib[5].Enabled),
9773464ebd5Sriastradh     extra_NV_vertex_program },
9783464ebd5Sriastradh   { GL_VERTEX_ATTRIB_ARRAY6_NV, ARRAY_BOOL(VertexAttrib[6].Enabled),
9793464ebd5Sriastradh     extra_NV_vertex_program },
9803464ebd5Sriastradh   { GL_VERTEX_ATTRIB_ARRAY7_NV, ARRAY_BOOL(VertexAttrib[7].Enabled),
9813464ebd5Sriastradh     extra_NV_vertex_program },
9823464ebd5Sriastradh   { GL_VERTEX_ATTRIB_ARRAY8_NV, ARRAY_BOOL(VertexAttrib[8].Enabled),
9833464ebd5Sriastradh     extra_NV_vertex_program },
9843464ebd5Sriastradh   { GL_VERTEX_ATTRIB_ARRAY9_NV, ARRAY_BOOL(VertexAttrib[9].Enabled),
9853464ebd5Sriastradh     extra_NV_vertex_program },
9863464ebd5Sriastradh   { GL_VERTEX_ATTRIB_ARRAY10_NV, ARRAY_BOOL(VertexAttrib[10].Enabled),
9873464ebd5Sriastradh     extra_NV_vertex_program },
9883464ebd5Sriastradh   { GL_VERTEX_ATTRIB_ARRAY11_NV, ARRAY_BOOL(VertexAttrib[11].Enabled),
9893464ebd5Sriastradh     extra_NV_vertex_program },
9903464ebd5Sriastradh   { GL_VERTEX_ATTRIB_ARRAY12_NV, ARRAY_BOOL(VertexAttrib[12].Enabled),
9913464ebd5Sriastradh     extra_NV_vertex_program },
9923464ebd5Sriastradh   { GL_VERTEX_ATTRIB_ARRAY13_NV, ARRAY_BOOL(VertexAttrib[13].Enabled),
9933464ebd5Sriastradh     extra_NV_vertex_program },
9943464ebd5Sriastradh   { GL_VERTEX_ATTRIB_ARRAY14_NV, ARRAY_BOOL(VertexAttrib[14].Enabled),
9953464ebd5Sriastradh     extra_NV_vertex_program },
9963464ebd5Sriastradh   { GL_VERTEX_ATTRIB_ARRAY15_NV, ARRAY_BOOL(VertexAttrib[15].Enabled),
9973464ebd5Sriastradh     extra_NV_vertex_program },
9983464ebd5Sriastradh   { GL_MAP1_VERTEX_ATTRIB0_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[0]),
9993464ebd5Sriastradh     extra_NV_vertex_program },
10003464ebd5Sriastradh   { GL_MAP1_VERTEX_ATTRIB1_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[1]),
10013464ebd5Sriastradh     extra_NV_vertex_program },
10023464ebd5Sriastradh   { GL_MAP1_VERTEX_ATTRIB2_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[2]),
10033464ebd5Sriastradh     extra_NV_vertex_program },
10043464ebd5Sriastradh   { GL_MAP1_VERTEX_ATTRIB3_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[3]),
10053464ebd5Sriastradh     extra_NV_vertex_program },
10063464ebd5Sriastradh   { GL_MAP1_VERTEX_ATTRIB4_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[4]),
10073464ebd5Sriastradh     extra_NV_vertex_program },
10083464ebd5Sriastradh   { GL_MAP1_VERTEX_ATTRIB5_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[5]),
10093464ebd5Sriastradh     extra_NV_vertex_program },
10103464ebd5Sriastradh   { GL_MAP1_VERTEX_ATTRIB6_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[6]),
10113464ebd5Sriastradh     extra_NV_vertex_program },
10123464ebd5Sriastradh   { GL_MAP1_VERTEX_ATTRIB7_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[7]),
10133464ebd5Sriastradh     extra_NV_vertex_program },
10143464ebd5Sriastradh   { GL_MAP1_VERTEX_ATTRIB8_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[8]),
10153464ebd5Sriastradh     extra_NV_vertex_program },
10163464ebd5Sriastradh   { GL_MAP1_VERTEX_ATTRIB9_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[9]),
10173464ebd5Sriastradh     extra_NV_vertex_program },
10183464ebd5Sriastradh   { GL_MAP1_VERTEX_ATTRIB10_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[10]),
10193464ebd5Sriastradh     extra_NV_vertex_program },
10203464ebd5Sriastradh   { GL_MAP1_VERTEX_ATTRIB11_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[11]),
10213464ebd5Sriastradh     extra_NV_vertex_program },
10223464ebd5Sriastradh   { GL_MAP1_VERTEX_ATTRIB12_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[12]),
10233464ebd5Sriastradh     extra_NV_vertex_program },
10243464ebd5Sriastradh   { GL_MAP1_VERTEX_ATTRIB13_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[13]),
10253464ebd5Sriastradh     extra_NV_vertex_program },
10263464ebd5Sriastradh   { GL_MAP1_VERTEX_ATTRIB14_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[14]),
10273464ebd5Sriastradh     extra_NV_vertex_program },
10283464ebd5Sriastradh   { GL_MAP1_VERTEX_ATTRIB15_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[15]),
10293464ebd5Sriastradh     extra_NV_vertex_program },
10303464ebd5Sriastradh
10313464ebd5Sriastradh   /* GL_NV_fragment_program */
10323464ebd5Sriastradh   { GL_FRAGMENT_PROGRAM_NV, CONTEXT_BOOL(FragmentProgram.Enabled),
10333464ebd5Sriastradh     extra_NV_fragment_program },
10343464ebd5Sriastradh   { GL_FRAGMENT_PROGRAM_BINDING_NV, LOC_CUSTOM, TYPE_INT, 0,
10353464ebd5Sriastradh     extra_NV_fragment_program },
10363464ebd5Sriastradh   { GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV,
10373464ebd5Sriastradh     CONST(MAX_NV_FRAGMENT_PROGRAM_PARAMS),
10383464ebd5Sriastradh     extra_NV_fragment_program },
10393464ebd5Sriastradh
10403464ebd5Sriastradh   /* GL_NV_texture_rectangle */
10413464ebd5Sriastradh   { GL_TEXTURE_RECTANGLE_NV,
10423464ebd5Sriastradh     LOC_CUSTOM, TYPE_BOOLEAN, 0, extra_NV_texture_rectangle },
10433464ebd5Sriastradh   { GL_TEXTURE_BINDING_RECTANGLE_NV,
10443464ebd5Sriastradh     LOC_CUSTOM, TYPE_INT, TEXTURE_RECT_INDEX, extra_NV_texture_rectangle },
10453464ebd5Sriastradh   { GL_MAX_RECTANGLE_TEXTURE_SIZE_NV,
10463464ebd5Sriastradh     CONTEXT_INT(Const.MaxTextureRectSize), extra_NV_texture_rectangle },
10473464ebd5Sriastradh
10483464ebd5Sriastradh   /* GL_EXT_stencil_two_side */
10493464ebd5Sriastradh   { GL_STENCIL_TEST_TWO_SIDE_EXT, CONTEXT_BOOL(Stencil.TestTwoSide),
10503464ebd5Sriastradh	 extra_EXT_stencil_two_side },
10513464ebd5Sriastradh   { GL_ACTIVE_STENCIL_FACE_EXT, LOC_CUSTOM, TYPE_ENUM, NO_OFFSET, NO_EXTRA },
10523464ebd5Sriastradh
10533464ebd5Sriastradh   /* GL_NV_light_max_exponent */
10543464ebd5Sriastradh   { GL_MAX_SHININESS_NV, CONTEXT_FLOAT(Const.MaxShininess),
10553464ebd5Sriastradh     extra_NV_light_max_exponent },
10563464ebd5Sriastradh   { GL_MAX_SPOT_EXPONENT_NV, CONTEXT_FLOAT(Const.MaxSpotExponent),
10573464ebd5Sriastradh     extra_NV_light_max_exponent },
10583464ebd5Sriastradh
10593464ebd5Sriastradh   /* GL_NV_primitive_restart */
10603464ebd5Sriastradh   { GL_PRIMITIVE_RESTART_NV, CONTEXT_BOOL(Array.PrimitiveRestart),
10613464ebd5Sriastradh     extra_NV_primitive_restart },
10623464ebd5Sriastradh   { GL_PRIMITIVE_RESTART_INDEX_NV, CONTEXT_INT(Array.RestartIndex),
10633464ebd5Sriastradh     extra_NV_primitive_restart },
10643464ebd5Sriastradh
10653464ebd5Sriastradh   /* GL_ARB_vertex_buffer_object */
10663464ebd5Sriastradh   { GL_INDEX_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT,
10673464ebd5Sriastradh     offsetof(struct gl_array_object, Index.BufferObj), NO_EXTRA },
10683464ebd5Sriastradh   { GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT,
10693464ebd5Sriastradh     offsetof(struct gl_array_object, EdgeFlag.BufferObj), NO_EXTRA },
10703464ebd5Sriastradh   { GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT,
10713464ebd5Sriastradh     offsetof(struct gl_array_object, SecondaryColor.BufferObj), NO_EXTRA },
10723464ebd5Sriastradh   { GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT,
10733464ebd5Sriastradh     offsetof(struct gl_array_object, FogCoord.BufferObj), NO_EXTRA },
10743464ebd5Sriastradh
10753464ebd5Sriastradh   /* GL_EXT_pixel_buffer_object */
10763464ebd5Sriastradh   { GL_PIXEL_PACK_BUFFER_BINDING_EXT, LOC_CUSTOM, TYPE_INT, 0,
10773464ebd5Sriastradh     extra_EXT_pixel_buffer_object },
10783464ebd5Sriastradh   { GL_PIXEL_UNPACK_BUFFER_BINDING_EXT, LOC_CUSTOM, TYPE_INT, 0,
10793464ebd5Sriastradh     extra_EXT_pixel_buffer_object },
10803464ebd5Sriastradh
10813464ebd5Sriastradh   /* GL_ARB_vertex_program */
10823464ebd5Sriastradh   { GL_VERTEX_PROGRAM_ARB, /* == GL_VERTEX_PROGRAM_NV */
10833464ebd5Sriastradh     CONTEXT_BOOL(VertexProgram.Enabled),
10843464ebd5Sriastradh     extra_ARB_vertex_program_NV_vertex_program },
10853464ebd5Sriastradh   { GL_VERTEX_PROGRAM_POINT_SIZE_ARB, /* == GL_VERTEX_PROGRAM_POINT_SIZE_NV*/
10863464ebd5Sriastradh     CONTEXT_BOOL(VertexProgram.PointSizeEnabled),
10873464ebd5Sriastradh     extra_ARB_vertex_program_NV_vertex_program },
10883464ebd5Sriastradh   { GL_VERTEX_PROGRAM_TWO_SIDE_ARB, /* == GL_VERTEX_PROGRAM_TWO_SIDE_NV */
10893464ebd5Sriastradh     CONTEXT_BOOL(VertexProgram.TwoSideEnabled),
10903464ebd5Sriastradh     extra_ARB_vertex_program_NV_vertex_program },
10913464ebd5Sriastradh   { GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB, /* == GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV */
10923464ebd5Sriastradh     CONTEXT_INT(Const.MaxProgramMatrixStackDepth),
10933464ebd5Sriastradh     extra_ARB_vertex_program_ARB_fragment_program_NV_vertex_program },
10943464ebd5Sriastradh   { GL_MAX_PROGRAM_MATRICES_ARB, /* == GL_MAX_TRACK_MATRICES_NV */
10953464ebd5Sriastradh     CONTEXT_INT(Const.MaxProgramMatrices),
10963464ebd5Sriastradh     extra_ARB_vertex_program_ARB_fragment_program_NV_vertex_program },
10973464ebd5Sriastradh   { GL_CURRENT_MATRIX_STACK_DEPTH_ARB, /* == GL_CURRENT_MATRIX_STACK_DEPTH_NV */
10983464ebd5Sriastradh     LOC_CUSTOM, TYPE_INT, 0,
10993464ebd5Sriastradh     extra_ARB_vertex_program_ARB_fragment_program_NV_vertex_program },
11003464ebd5Sriastradh
11013464ebd5Sriastradh   { GL_CURRENT_MATRIX_ARB, /* == GL_CURRENT_MATRIX_NV */
11023464ebd5Sriastradh     LOC_CUSTOM, TYPE_MATRIX, 0,
11033464ebd5Sriastradh     extra_ARB_vertex_program_ARB_fragment_program_NV_vertex_program },
11043464ebd5Sriastradh   { GL_TRANSPOSE_CURRENT_MATRIX_ARB, /* == GL_CURRENT_MATRIX_NV */
11053464ebd5Sriastradh     LOC_CUSTOM, TYPE_MATRIX, 0,
11063464ebd5Sriastradh     extra_ARB_vertex_program_ARB_fragment_program },
11073464ebd5Sriastradh
11083464ebd5Sriastradh   { GL_PROGRAM_ERROR_POSITION_ARB, /* == GL_PROGRAM_ERROR_POSITION_NV */
11093464ebd5Sriastradh     CONTEXT_INT(Program.ErrorPos),
11103464ebd5Sriastradh     extra_NV_vertex_program_ARB_vertex_program_ARB_fragment_program_NV_vertex_program },
11113464ebd5Sriastradh
11123464ebd5Sriastradh   /* GL_ARB_fragment_program */
11133464ebd5Sriastradh   { GL_FRAGMENT_PROGRAM_ARB, CONTEXT_BOOL(FragmentProgram.Enabled),
11143464ebd5Sriastradh     extra_ARB_fragment_program },
11153464ebd5Sriastradh
11163464ebd5Sriastradh   /* GL_EXT_depth_bounds_test */
11173464ebd5Sriastradh   { GL_DEPTH_BOUNDS_TEST_EXT, CONTEXT_BOOL(Depth.BoundsTest),
11183464ebd5Sriastradh     extra_EXT_depth_bounds_test },
11193464ebd5Sriastradh   { GL_DEPTH_BOUNDS_EXT, CONTEXT_FLOAT2(Depth.BoundsMin),
11203464ebd5Sriastradh     extra_EXT_depth_bounds_test },
11213464ebd5Sriastradh
11223464ebd5Sriastradh   /* GL_ARB_depth_clamp*/
11233464ebd5Sriastradh   { GL_DEPTH_CLAMP, CONTEXT_BOOL(Transform.DepthClamp),
11243464ebd5Sriastradh     extra_ARB_depth_clamp },
11253464ebd5Sriastradh
11263464ebd5Sriastradh   /* GL_ARB_draw_buffers */
11273464ebd5Sriastradh   { GL_DRAW_BUFFER0_ARB, BUFFER_ENUM(ColorDrawBuffer[0]), NO_EXTRA },
11283464ebd5Sriastradh   { GL_DRAW_BUFFER1_ARB, BUFFER_ENUM(ColorDrawBuffer[1]),
11293464ebd5Sriastradh     extra_valid_draw_buffer },
11303464ebd5Sriastradh   { GL_DRAW_BUFFER2_ARB, BUFFER_ENUM(ColorDrawBuffer[2]),
11313464ebd5Sriastradh     extra_valid_draw_buffer },
11323464ebd5Sriastradh   { GL_DRAW_BUFFER3_ARB, BUFFER_ENUM(ColorDrawBuffer[3]),
11333464ebd5Sriastradh     extra_valid_draw_buffer },
11343464ebd5Sriastradh   { GL_DRAW_BUFFER4_ARB, BUFFER_ENUM(ColorDrawBuffer[4]),
11353464ebd5Sriastradh     extra_valid_draw_buffer },
11363464ebd5Sriastradh   { GL_DRAW_BUFFER5_ARB, BUFFER_ENUM(ColorDrawBuffer[5]),
11373464ebd5Sriastradh     extra_valid_draw_buffer },
11383464ebd5Sriastradh   { GL_DRAW_BUFFER6_ARB, BUFFER_ENUM(ColorDrawBuffer[6]),
11393464ebd5Sriastradh     extra_valid_draw_buffer },
11403464ebd5Sriastradh   { GL_DRAW_BUFFER7_ARB, BUFFER_ENUM(ColorDrawBuffer[7]),
11413464ebd5Sriastradh     extra_valid_draw_buffer },
11423464ebd5Sriastradh
11433464ebd5Sriastradh   /* GL_ATI_fragment_shader */
11443464ebd5Sriastradh   { GL_NUM_FRAGMENT_REGISTERS_ATI, CONST(6), extra_ATI_fragment_shader },
11453464ebd5Sriastradh   { GL_NUM_FRAGMENT_CONSTANTS_ATI, CONST(8), extra_ATI_fragment_shader },
11463464ebd5Sriastradh   { GL_NUM_PASSES_ATI, CONST(2), extra_ATI_fragment_shader },
11473464ebd5Sriastradh   { GL_NUM_INSTRUCTIONS_PER_PASS_ATI, CONST(8), extra_ATI_fragment_shader },
11483464ebd5Sriastradh   { GL_NUM_INSTRUCTIONS_TOTAL_ATI, CONST(16), extra_ATI_fragment_shader },
11493464ebd5Sriastradh   { GL_COLOR_ALPHA_PAIRING_ATI, CONST(GL_TRUE), extra_ATI_fragment_shader },
11503464ebd5Sriastradh   { GL_NUM_LOOPBACK_COMPONENTS_ATI, CONST(3), extra_ATI_fragment_shader },
11513464ebd5Sriastradh   { GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI,
11523464ebd5Sriastradh     CONST(3), extra_ATI_fragment_shader },
11533464ebd5Sriastradh
11543464ebd5Sriastradh   /* GL_EXT_framebuffer_object */
11553464ebd5Sriastradh   { GL_MAX_COLOR_ATTACHMENTS_EXT, CONTEXT_INT(Const.MaxColorAttachments),
11563464ebd5Sriastradh     extra_EXT_framebuffer_object },
11573464ebd5Sriastradh
11583464ebd5Sriastradh   /* GL_EXT_framebuffer_blit
11593464ebd5Sriastradh    * NOTE: GL_DRAW_FRAMEBUFFER_BINDING_EXT == GL_FRAMEBUFFER_BINDING_EXT */
11603464ebd5Sriastradh   { GL_READ_FRAMEBUFFER_BINDING_EXT, LOC_CUSTOM, TYPE_INT, 0,
11613464ebd5Sriastradh     extra_EXT_framebuffer_blit },
11623464ebd5Sriastradh
11633464ebd5Sriastradh   /* GL_EXT_provoking_vertex */
11643464ebd5Sriastradh   { GL_PROVOKING_VERTEX_EXT,
11653464ebd5Sriastradh     CONTEXT_ENUM(Light.ProvokingVertex), extra_EXT_provoking_vertex },
11663464ebd5Sriastradh   { GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT,
11673464ebd5Sriastradh     CONTEXT_BOOL(Const.QuadsFollowProvokingVertexConvention),
11683464ebd5Sriastradh     extra_EXT_provoking_vertex },
11693464ebd5Sriastradh
11703464ebd5Sriastradh   /* GL_ARB_framebuffer_object */
11713464ebd5Sriastradh   { GL_MAX_SAMPLES, CONTEXT_INT(Const.MaxSamples),
11723464ebd5Sriastradh     extra_ARB_framebuffer_object_EXT_framebuffer_multisample },
11733464ebd5Sriastradh
11743464ebd5Sriastradh   /* GL_APPLE_vertex_array_object */
11753464ebd5Sriastradh   { GL_VERTEX_ARRAY_BINDING_APPLE, ARRAY_INT(Name),
11763464ebd5Sriastradh     extra_APPLE_vertex_array_object },
11773464ebd5Sriastradh
11783464ebd5Sriastradh   /* GL_ARB_seamless_cube_map */
11793464ebd5Sriastradh   { GL_TEXTURE_CUBE_MAP_SEAMLESS,
11803464ebd5Sriastradh     CONTEXT_BOOL(Texture.CubeMapSeamless), extra_ARB_seamless_cube_map },
11813464ebd5Sriastradh
11823464ebd5Sriastradh   /* GL_ARB_sync */
11833464ebd5Sriastradh   { GL_MAX_SERVER_WAIT_TIMEOUT,
11843464ebd5Sriastradh     CONTEXT_INT64(Const.MaxServerWaitTimeout), extra_ARB_sync },
11853464ebd5Sriastradh
11863464ebd5Sriastradh   /* GL_EXT_texture_integer */
11873464ebd5Sriastradh   { GL_RGBA_INTEGER_MODE_EXT, BUFFER_BOOL(_IntegerColor),
11883464ebd5Sriastradh     extra_EXT_texture_integer },
11893464ebd5Sriastradh
11903464ebd5Sriastradh   /* GL_EXT_transform_feedback */
11913464ebd5Sriastradh   { GL_TRANSFORM_FEEDBACK_BUFFER_BINDING, LOC_CUSTOM, TYPE_INT, 0,
11923464ebd5Sriastradh     extra_EXT_transform_feedback },
11933464ebd5Sriastradh   { GL_RASTERIZER_DISCARD, CONTEXT_BOOL(TransformFeedback.RasterDiscard),
11943464ebd5Sriastradh     extra_EXT_transform_feedback },
11953464ebd5Sriastradh   { GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS,
11963464ebd5Sriastradh     CONTEXT_INT(Const.MaxTransformFeedbackInterleavedComponents),
11973464ebd5Sriastradh     extra_EXT_transform_feedback },
11983464ebd5Sriastradh   { GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS,
11993464ebd5Sriastradh     CONTEXT_INT(Const.MaxTransformFeedbackSeparateAttribs),
12003464ebd5Sriastradh     extra_EXT_transform_feedback },
12013464ebd5Sriastradh   { GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS,
12023464ebd5Sriastradh     CONTEXT_INT(Const.MaxTransformFeedbackSeparateComponents),
12033464ebd5Sriastradh     extra_EXT_transform_feedback },
12043464ebd5Sriastradh
12053464ebd5Sriastradh   /* GL_ARB_transform_feedback2 */
12063464ebd5Sriastradh   { GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED, LOC_CUSTOM, TYPE_BOOLEAN, 0,
12073464ebd5Sriastradh     extra_ARB_transform_feedback2 },
12083464ebd5Sriastradh   { GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE, LOC_CUSTOM, TYPE_BOOLEAN, 0,
12093464ebd5Sriastradh     extra_ARB_transform_feedback2 },
12103464ebd5Sriastradh   { GL_TRANSFORM_FEEDBACK_BINDING, LOC_CUSTOM, TYPE_INT, 0,
12113464ebd5Sriastradh     extra_ARB_transform_feedback2 },
12123464ebd5Sriastradh
12133464ebd5Sriastradh   /* GL_ARB_geometry_shader4 */
12143464ebd5Sriastradh   { GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB,
12153464ebd5Sriastradh     CONTEXT_INT(Const.MaxGeometryTextureImageUnits),
12163464ebd5Sriastradh     extra_ARB_geometry_shader4 },
12173464ebd5Sriastradh   { GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB,
12183464ebd5Sriastradh     CONTEXT_INT(Const.MaxGeometryOutputVertices),
12193464ebd5Sriastradh     extra_ARB_geometry_shader4 },
12203464ebd5Sriastradh   { GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB,
12213464ebd5Sriastradh     CONTEXT_INT(Const.MaxGeometryTotalOutputComponents),
12223464ebd5Sriastradh     extra_ARB_geometry_shader4 },
12233464ebd5Sriastradh   { GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB,
12243464ebd5Sriastradh     CONTEXT_INT(Const.GeometryProgram.MaxUniformComponents),
12253464ebd5Sriastradh     extra_ARB_geometry_shader4 },
12263464ebd5Sriastradh   { GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB,
12273464ebd5Sriastradh     CONTEXT_INT(Const.MaxGeometryVaryingComponents),
12283464ebd5Sriastradh     extra_ARB_geometry_shader4 },
12293464ebd5Sriastradh   { GL_MAX_VERTEX_VARYING_COMPONENTS_ARB,
12303464ebd5Sriastradh     CONTEXT_INT(Const.MaxVertexVaryingComponents),
12313464ebd5Sriastradh     extra_ARB_geometry_shader4 },
12323464ebd5Sriastradh
12333464ebd5Sriastradh   /* GL_ARB_color_buffer_float */
12343464ebd5Sriastradh   { GL_RGBA_FLOAT_MODE_ARB, BUFFER_FIELD(Visual.floatMode, TYPE_BOOLEAN), 0 },
12353464ebd5Sriastradh
12363464ebd5Sriastradh   /* GL_EXT_gpu_shader4 / GL 3.0 */
12373464ebd5Sriastradh   { GL_MIN_PROGRAM_TEXEL_OFFSET,
12383464ebd5Sriastradh     CONTEXT_INT(Const.MinProgramTexelOffset),
12393464ebd5Sriastradh     extra_EXT_gpu_shader4 },
12403464ebd5Sriastradh   { GL_MAX_PROGRAM_TEXEL_OFFSET,
12413464ebd5Sriastradh     CONTEXT_INT(Const.MaxProgramTexelOffset),
12423464ebd5Sriastradh     extra_EXT_gpu_shader4 },
12433464ebd5Sriastradh
12443464ebd5Sriastradh   /* GL_ARB_texture_buffer_object */
12453464ebd5Sriastradh   { GL_MAX_TEXTURE_BUFFER_SIZE_ARB, CONTEXT_INT(Const.MaxTextureBufferSize),
12463464ebd5Sriastradh     extra_ARB_texture_buffer_object },
12473464ebd5Sriastradh   { GL_TEXTURE_BINDING_BUFFER_ARB, LOC_CUSTOM, TYPE_INT, 0,
12483464ebd5Sriastradh     extra_ARB_texture_buffer_object },
12493464ebd5Sriastradh   { GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB, LOC_CUSTOM, TYPE_INT,
12503464ebd5Sriastradh     TEXTURE_BUFFER_INDEX, extra_ARB_texture_buffer_object },
12513464ebd5Sriastradh   { GL_TEXTURE_BUFFER_FORMAT_ARB, LOC_CUSTOM, TYPE_INT, 0,
12523464ebd5Sriastradh     extra_ARB_texture_buffer_object },
12533464ebd5Sriastradh   { GL_TEXTURE_BUFFER_ARB, LOC_CUSTOM, TYPE_INT, 0,
12543464ebd5Sriastradh     extra_ARB_texture_buffer_object },
12553464ebd5Sriastradh
12563464ebd5Sriastradh   /* GL_ARB_sampler_objects / GL 3.3 */
12573464ebd5Sriastradh   { GL_SAMPLER_BINDING,
12583464ebd5Sriastradh     LOC_CUSTOM, TYPE_INT, GL_SAMPLER_BINDING, extra_ARB_sampler_objects },
12593464ebd5Sriastradh
12603464ebd5Sriastradh   /* GL 3.0 */
12613464ebd5Sriastradh   { GL_NUM_EXTENSIONS, LOC_CUSTOM, TYPE_INT, 0, extra_version_30 },
12623464ebd5Sriastradh   { GL_MAJOR_VERSION, CONTEXT_INT(VersionMajor), extra_version_30 },
12633464ebd5Sriastradh   { GL_MINOR_VERSION, CONTEXT_INT(VersionMinor), extra_version_30  },
12643464ebd5Sriastradh   { GL_CONTEXT_FLAGS, CONTEXT_INT(Const.ContextFlags), extra_version_30  },
12653464ebd5Sriastradh
12663464ebd5Sriastradh   /* GL3.0 / GL_EXT_framebuffer_sRGB */
12673464ebd5Sriastradh   { GL_FRAMEBUFFER_SRGB_EXT, CONTEXT_BOOL(Color.sRGBEnabled), extra_EXT_framebuffer_sRGB },
12683464ebd5Sriastradh   { GL_FRAMEBUFFER_SRGB_CAPABLE_EXT, BUFFER_INT(Visual.sRGBCapable), extra_EXT_framebuffer_sRGB },
12693464ebd5Sriastradh
12703464ebd5Sriastradh   /* GL 3.1 */
12713464ebd5Sriastradh   /* NOTE: different enum values for GL_PRIMITIVE_RESTART_NV
12723464ebd5Sriastradh    * vs. GL_PRIMITIVE_RESTART!
12733464ebd5Sriastradh    */
12743464ebd5Sriastradh   { GL_PRIMITIVE_RESTART, CONTEXT_BOOL(Array.PrimitiveRestart),
12753464ebd5Sriastradh     extra_version_31 },
12763464ebd5Sriastradh   { GL_PRIMITIVE_RESTART_INDEX, CONTEXT_INT(Array.RestartIndex),
12773464ebd5Sriastradh     extra_version_31 },
12783464ebd5Sriastradh
12793464ebd5Sriastradh
12803464ebd5Sriastradh   /* GL 3.2 */
12813464ebd5Sriastradh   { GL_CONTEXT_PROFILE_MASK, CONTEXT_INT(Const.ProfileMask),
12823464ebd5Sriastradh     extra_version_32 },
12833464ebd5Sriastradh
12843464ebd5Sriastradh   /* GL_ARB_robustness */
12853464ebd5Sriastradh   { GL_RESET_NOTIFICATION_STRATEGY_ARB, CONTEXT_ENUM(Const.ResetStrategy), NO_EXTRA },
12863464ebd5Sriastradh#endif /* FEATURE_GL */
12873464ebd5Sriastradh};
12883464ebd5Sriastradh
12893464ebd5Sriastradh/* All we need now is a way to look up the value struct from the enum.
12903464ebd5Sriastradh * The code generated by gcc for the old generated big switch
12913464ebd5Sriastradh * statement is a big, balanced, open coded if/else tree, essentially
12923464ebd5Sriastradh * an unrolled binary search.  It would be natural to sort the new
12933464ebd5Sriastradh * enum table and use bsearch(), but we will use a read-only hash
12943464ebd5Sriastradh * table instead.  bsearch() has a nice guaranteed worst case
12953464ebd5Sriastradh * performance, but we're also guaranteed to hit that worst case
12963464ebd5Sriastradh * (log2(n) iterations) for about half the enums.  Instead, using an
12973464ebd5Sriastradh * open addressing hash table, we can find the enum on the first try
12983464ebd5Sriastradh * for 80% of the enums, 1 collision for 10% and never more than 5
12993464ebd5Sriastradh * collisions for any enum (typical numbers).  And the code is very
13003464ebd5Sriastradh * simple, even though it feels a little magic. */
13013464ebd5Sriastradh
13023464ebd5Sriastradhstatic unsigned short table[1024];
13033464ebd5Sriastradhstatic const int prime_factor = 89, prime_step = 281;
13043464ebd5Sriastradh
13053464ebd5Sriastradh#ifdef GET_DEBUG
13063464ebd5Sriastradhstatic void
13073464ebd5Sriastradhprint_table_stats(void)
13083464ebd5Sriastradh{
13093464ebd5Sriastradh   int i, j, collisions[11], count, hash, mask;
13103464ebd5Sriastradh   const struct value_desc *d;
13113464ebd5Sriastradh
13123464ebd5Sriastradh   count = 0;
13133464ebd5Sriastradh   mask = Elements(table) - 1;
13143464ebd5Sriastradh   memset(collisions, 0, sizeof collisions);
13153464ebd5Sriastradh
13163464ebd5Sriastradh   for (i = 0; i < Elements(table); i++) {
13173464ebd5Sriastradh      if (!table[i])
13183464ebd5Sriastradh	 continue;
13193464ebd5Sriastradh      count++;
13203464ebd5Sriastradh      d = &values[table[i]];
13213464ebd5Sriastradh      hash = (d->pname * prime_factor);
13223464ebd5Sriastradh      j = 0;
13233464ebd5Sriastradh      while (1) {
13243464ebd5Sriastradh	 if (values[table[hash & mask]].pname == d->pname)
13253464ebd5Sriastradh	    break;
13263464ebd5Sriastradh	 hash += prime_step;
13273464ebd5Sriastradh	 j++;
13283464ebd5Sriastradh      }
13293464ebd5Sriastradh
13303464ebd5Sriastradh      if (j < 10)
13313464ebd5Sriastradh	 collisions[j]++;
13323464ebd5Sriastradh      else
13333464ebd5Sriastradh	 collisions[10]++;
13343464ebd5Sriastradh   }
13353464ebd5Sriastradh
13363464ebd5Sriastradh   printf("number of enums: %d (total %d)\n", count, Elements(values));
13373464ebd5Sriastradh   for (i = 0; i < Elements(collisions) - 1; i++)
13383464ebd5Sriastradh      if (collisions[i] > 0)
13393464ebd5Sriastradh	 printf("  %d enums with %d %scollisions\n",
13403464ebd5Sriastradh		collisions[i], i, i == 10 ? "or more " : "");
13413464ebd5Sriastradh}
13423464ebd5Sriastradh#endif
13433464ebd5Sriastradh
13443464ebd5Sriastradh/**
13453464ebd5Sriastradh * Initialize the enum hash for a given API
13463464ebd5Sriastradh *
13473464ebd5Sriastradh * This is called from one_time_init() to insert the enum values that
13483464ebd5Sriastradh * are valid for the API in question into the enum hash table.
13493464ebd5Sriastradh *
13503464ebd5Sriastradh * \param the current context, for determining the API in question
13517117f1b4Smrg */
13523464ebd5Sriastradhvoid _mesa_init_get_hash(struct gl_context *ctx)
13533464ebd5Sriastradh{
13543464ebd5Sriastradh   int i, hash, index, mask;
13553464ebd5Sriastradh   int api_mask = 0, api_bit;
13563464ebd5Sriastradh
13573464ebd5Sriastradh   mask = Elements(table) - 1;
13583464ebd5Sriastradh   api_bit = 1 << ctx->API;
13593464ebd5Sriastradh
13603464ebd5Sriastradh   for (i = 0; i < Elements(values); i++) {
13613464ebd5Sriastradh      if (values[i].type == TYPE_API_MASK) {
13623464ebd5Sriastradh	 api_mask = values[i].offset;
13633464ebd5Sriastradh	 continue;
13643464ebd5Sriastradh      }
13653464ebd5Sriastradh      if (!(api_mask & api_bit))
13663464ebd5Sriastradh	 continue;
13673464ebd5Sriastradh
13683464ebd5Sriastradh      hash = (values[i].pname * prime_factor) & mask;
13693464ebd5Sriastradh      while (1) {
13703464ebd5Sriastradh	 index = hash & mask;
13713464ebd5Sriastradh	 if (!table[index]) {
13723464ebd5Sriastradh	    table[index] = i;
13733464ebd5Sriastradh	    break;
13743464ebd5Sriastradh	 }
13753464ebd5Sriastradh	 hash += prime_step;
13763464ebd5Sriastradh      }
13777117f1b4Smrg   }
13787117f1b4Smrg
13793464ebd5Sriastradh#ifdef GET_DEBUG
13803464ebd5Sriastradh   print_table_stats();
13813464ebd5Sriastradh#endif
13823464ebd5Sriastradh}
13833464ebd5Sriastradh
13843464ebd5Sriastradh/**
13853464ebd5Sriastradh * Handle irregular enums
13863464ebd5Sriastradh *
13873464ebd5Sriastradh * Some values don't conform to the "well-known type at context
13883464ebd5Sriastradh * pointer + offset" pattern, so we have this function to catch all
13893464ebd5Sriastradh * the corner cases.  Typically, it's a computed value or a one-off
13903464ebd5Sriastradh * pointer to a custom struct or something.
13913464ebd5Sriastradh *
13923464ebd5Sriastradh * In this case we can't return a pointer to the value, so we'll have
13933464ebd5Sriastradh * to use the temporary variable 'v' declared back in the calling
13943464ebd5Sriastradh * glGet*v() function to store the result.
13953464ebd5Sriastradh *
13963464ebd5Sriastradh * \param ctx the current context
13973464ebd5Sriastradh * \param d the struct value_desc that describes the enum
13983464ebd5Sriastradh * \param v pointer to the tmp declared in the calling glGet*v() function
13993464ebd5Sriastradh */
14003464ebd5Sriastradhstatic void
14013464ebd5Sriastradhfind_custom_value(struct gl_context *ctx, const struct value_desc *d, union value *v)
14023464ebd5Sriastradh{
14033464ebd5Sriastradh   struct gl_buffer_object **buffer_obj;
14043464ebd5Sriastradh   struct gl_client_array *array;
14053464ebd5Sriastradh   GLuint unit, *p;
14063464ebd5Sriastradh
14073464ebd5Sriastradh   switch (d->pname) {
14083464ebd5Sriastradh   case GL_TEXTURE_1D:
14093464ebd5Sriastradh   case GL_TEXTURE_2D:
14103464ebd5Sriastradh   case GL_TEXTURE_3D:
14113464ebd5Sriastradh   case GL_TEXTURE_1D_ARRAY_EXT:
14123464ebd5Sriastradh   case GL_TEXTURE_2D_ARRAY_EXT:
14133464ebd5Sriastradh   case GL_TEXTURE_CUBE_MAP_ARB:
14143464ebd5Sriastradh   case GL_TEXTURE_RECTANGLE_NV:
14153464ebd5Sriastradh      v->value_bool = _mesa_IsEnabled(d->pname);
14163464ebd5Sriastradh      break;
14173464ebd5Sriastradh
14183464ebd5Sriastradh   case GL_LINE_STIPPLE_PATTERN:
14193464ebd5Sriastradh      /* This is the only GLushort, special case it here by promoting
14203464ebd5Sriastradh       * to an int rather than introducing a new type. */
14213464ebd5Sriastradh      v->value_int = ctx->Line.StipplePattern;
14223464ebd5Sriastradh      break;
14233464ebd5Sriastradh
14243464ebd5Sriastradh   case GL_CURRENT_RASTER_TEXTURE_COORDS:
14253464ebd5Sriastradh      unit = ctx->Texture.CurrentUnit;
14263464ebd5Sriastradh      v->value_float_4[0] = ctx->Current.RasterTexCoords[unit][0];
14273464ebd5Sriastradh      v->value_float_4[1] = ctx->Current.RasterTexCoords[unit][1];
14283464ebd5Sriastradh      v->value_float_4[2] = ctx->Current.RasterTexCoords[unit][2];
14293464ebd5Sriastradh      v->value_float_4[3] = ctx->Current.RasterTexCoords[unit][3];
14303464ebd5Sriastradh      break;
14313464ebd5Sriastradh
14323464ebd5Sriastradh   case GL_CURRENT_TEXTURE_COORDS:
14333464ebd5Sriastradh      unit = ctx->Texture.CurrentUnit;
14343464ebd5Sriastradh      v->value_float_4[0] = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][0];
14353464ebd5Sriastradh      v->value_float_4[1] = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][1];
14363464ebd5Sriastradh      v->value_float_4[2] = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][2];
14373464ebd5Sriastradh      v->value_float_4[3] = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][3];
14383464ebd5Sriastradh      break;
14393464ebd5Sriastradh
14403464ebd5Sriastradh   case GL_COLOR_WRITEMASK:
14413464ebd5Sriastradh      v->value_int_4[0] = ctx->Color.ColorMask[0][RCOMP] ? 1 : 0;
14423464ebd5Sriastradh      v->value_int_4[1] = ctx->Color.ColorMask[0][GCOMP] ? 1 : 0;
14433464ebd5Sriastradh      v->value_int_4[2] = ctx->Color.ColorMask[0][BCOMP] ? 1 : 0;
14443464ebd5Sriastradh      v->value_int_4[3] = ctx->Color.ColorMask[0][ACOMP] ? 1 : 0;
14453464ebd5Sriastradh      break;
14463464ebd5Sriastradh
14473464ebd5Sriastradh   case GL_EDGE_FLAG:
14483464ebd5Sriastradh      v->value_bool = ctx->Current.Attrib[VERT_ATTRIB_EDGEFLAG][0] == 1.0;
14493464ebd5Sriastradh      break;
14503464ebd5Sriastradh
14513464ebd5Sriastradh   case GL_READ_BUFFER:
14523464ebd5Sriastradh      v->value_enum = ctx->ReadBuffer->ColorReadBuffer;
14533464ebd5Sriastradh      break;
14543464ebd5Sriastradh
14553464ebd5Sriastradh   case GL_MAP2_GRID_DOMAIN:
14563464ebd5Sriastradh      v->value_float_4[0] = ctx->Eval.MapGrid2u1;
14573464ebd5Sriastradh      v->value_float_4[1] = ctx->Eval.MapGrid2u2;
14583464ebd5Sriastradh      v->value_float_4[2] = ctx->Eval.MapGrid2v1;
14593464ebd5Sriastradh      v->value_float_4[3] = ctx->Eval.MapGrid2v2;
14603464ebd5Sriastradh      break;
14613464ebd5Sriastradh
14623464ebd5Sriastradh   case GL_TEXTURE_STACK_DEPTH:
14633464ebd5Sriastradh      unit = ctx->Texture.CurrentUnit;
14643464ebd5Sriastradh      v->value_int = ctx->TextureMatrixStack[unit].Depth + 1;
14653464ebd5Sriastradh      break;
14663464ebd5Sriastradh   case GL_TEXTURE_MATRIX:
14673464ebd5Sriastradh      unit = ctx->Texture.CurrentUnit;
14683464ebd5Sriastradh      v->value_matrix = ctx->TextureMatrixStack[unit].Top;
14693464ebd5Sriastradh      break;
14703464ebd5Sriastradh
14713464ebd5Sriastradh   case GL_TEXTURE_COORD_ARRAY:
14723464ebd5Sriastradh   case GL_TEXTURE_COORD_ARRAY_SIZE:
14733464ebd5Sriastradh   case GL_TEXTURE_COORD_ARRAY_TYPE:
14743464ebd5Sriastradh   case GL_TEXTURE_COORD_ARRAY_STRIDE:
14753464ebd5Sriastradh      array = &ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture];
14763464ebd5Sriastradh      v->value_int = *(GLuint *) ((char *) array + d->offset);
14773464ebd5Sriastradh      break;
14783464ebd5Sriastradh
14793464ebd5Sriastradh   case GL_ACTIVE_TEXTURE_ARB:
14803464ebd5Sriastradh      v->value_int = GL_TEXTURE0_ARB + ctx->Texture.CurrentUnit;
14813464ebd5Sriastradh      break;
14823464ebd5Sriastradh   case GL_CLIENT_ACTIVE_TEXTURE_ARB:
14833464ebd5Sriastradh      v->value_int = GL_TEXTURE0_ARB + ctx->Array.ActiveTexture;
14843464ebd5Sriastradh      break;
14853464ebd5Sriastradh
14863464ebd5Sriastradh   case GL_MODELVIEW_STACK_DEPTH:
14873464ebd5Sriastradh   case GL_PROJECTION_STACK_DEPTH:
14883464ebd5Sriastradh      v->value_int = *(GLint *) ((char *) ctx + d->offset) + 1;
14893464ebd5Sriastradh      break;
14903464ebd5Sriastradh
14913464ebd5Sriastradh   case GL_MAX_TEXTURE_SIZE:
14923464ebd5Sriastradh   case GL_MAX_3D_TEXTURE_SIZE:
14933464ebd5Sriastradh   case GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB:
14943464ebd5Sriastradh      p = (GLuint *) ((char *) ctx + d->offset);
14953464ebd5Sriastradh      v->value_int = 1 << (*p - 1);
14963464ebd5Sriastradh      break;
14973464ebd5Sriastradh
14983464ebd5Sriastradh   case GL_SCISSOR_BOX:
14993464ebd5Sriastradh      v->value_int_4[0] = ctx->Scissor.X;
15003464ebd5Sriastradh      v->value_int_4[1] = ctx->Scissor.Y;
15013464ebd5Sriastradh      v->value_int_4[2] = ctx->Scissor.Width;
15023464ebd5Sriastradh      v->value_int_4[3] = ctx->Scissor.Height;
15033464ebd5Sriastradh      break;
15043464ebd5Sriastradh
15053464ebd5Sriastradh   case GL_LIST_INDEX:
15063464ebd5Sriastradh      v->value_int =
15073464ebd5Sriastradh	 ctx->ListState.CurrentList ? ctx->ListState.CurrentList->Name : 0;
15083464ebd5Sriastradh      break;
15093464ebd5Sriastradh   case GL_LIST_MODE:
15103464ebd5Sriastradh      if (!ctx->CompileFlag)
15113464ebd5Sriastradh	 v->value_enum = 0;
15123464ebd5Sriastradh      else if (ctx->ExecuteFlag)
15133464ebd5Sriastradh	 v->value_enum = GL_COMPILE_AND_EXECUTE;
15143464ebd5Sriastradh      else
15153464ebd5Sriastradh	 v->value_enum = GL_COMPILE;
15163464ebd5Sriastradh      break;
15173464ebd5Sriastradh
15183464ebd5Sriastradh   case GL_VIEWPORT:
15193464ebd5Sriastradh      v->value_int_4[0] = ctx->Viewport.X;
15203464ebd5Sriastradh      v->value_int_4[1] = ctx->Viewport.Y;
15213464ebd5Sriastradh      v->value_int_4[2] = ctx->Viewport.Width;
15223464ebd5Sriastradh      v->value_int_4[3] = ctx->Viewport.Height;
15233464ebd5Sriastradh      break;
15243464ebd5Sriastradh
15253464ebd5Sriastradh   case GL_ACTIVE_STENCIL_FACE_EXT:
15263464ebd5Sriastradh      v->value_enum = ctx->Stencil.ActiveFace ? GL_BACK : GL_FRONT;
15273464ebd5Sriastradh      break;
15283464ebd5Sriastradh
15293464ebd5Sriastradh   case GL_STENCIL_FAIL:
15303464ebd5Sriastradh      v->value_enum = ctx->Stencil.FailFunc[ctx->Stencil.ActiveFace];
15313464ebd5Sriastradh      break;
15323464ebd5Sriastradh   case GL_STENCIL_FUNC:
15333464ebd5Sriastradh      v->value_enum = ctx->Stencil.Function[ctx->Stencil.ActiveFace];
15343464ebd5Sriastradh      break;
15353464ebd5Sriastradh   case GL_STENCIL_PASS_DEPTH_FAIL:
15363464ebd5Sriastradh      v->value_enum = ctx->Stencil.ZFailFunc[ctx->Stencil.ActiveFace];
15373464ebd5Sriastradh      break;
15383464ebd5Sriastradh   case GL_STENCIL_PASS_DEPTH_PASS:
15393464ebd5Sriastradh      v->value_enum = ctx->Stencil.ZPassFunc[ctx->Stencil.ActiveFace];
15403464ebd5Sriastradh      break;
15413464ebd5Sriastradh   case GL_STENCIL_REF:
15423464ebd5Sriastradh      v->value_int = ctx->Stencil.Ref[ctx->Stencil.ActiveFace];
15433464ebd5Sriastradh      break;
15443464ebd5Sriastradh   case GL_STENCIL_VALUE_MASK:
15453464ebd5Sriastradh      v->value_int = ctx->Stencil.ValueMask[ctx->Stencil.ActiveFace];
15463464ebd5Sriastradh      break;
15473464ebd5Sriastradh   case GL_STENCIL_WRITEMASK:
15483464ebd5Sriastradh      v->value_int = ctx->Stencil.WriteMask[ctx->Stencil.ActiveFace];
15493464ebd5Sriastradh      break;
15503464ebd5Sriastradh
15513464ebd5Sriastradh   case GL_NUM_EXTENSIONS:
15523464ebd5Sriastradh      v->value_int = _mesa_get_extension_count(ctx);
15533464ebd5Sriastradh      break;
15543464ebd5Sriastradh
15553464ebd5Sriastradh   case GL_IMPLEMENTATION_COLOR_READ_TYPE_OES:
15563464ebd5Sriastradh      v->value_int = _mesa_get_color_read_type(ctx);
15573464ebd5Sriastradh      break;
15583464ebd5Sriastradh   case GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES:
15593464ebd5Sriastradh      v->value_int = _mesa_get_color_read_format(ctx);
15603464ebd5Sriastradh      break;
15613464ebd5Sriastradh
15623464ebd5Sriastradh   case GL_CURRENT_MATRIX_STACK_DEPTH_ARB:
15633464ebd5Sriastradh      v->value_int = ctx->CurrentStack->Depth + 1;
15643464ebd5Sriastradh      break;
15653464ebd5Sriastradh   case GL_CURRENT_MATRIX_ARB:
15663464ebd5Sriastradh   case GL_TRANSPOSE_CURRENT_MATRIX_ARB:
15673464ebd5Sriastradh      v->value_matrix = ctx->CurrentStack->Top;
15683464ebd5Sriastradh      break;
15693464ebd5Sriastradh
15703464ebd5Sriastradh   case GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB:
15713464ebd5Sriastradh      v->value_int = _mesa_get_compressed_formats(ctx, NULL);
15723464ebd5Sriastradh      break;
15733464ebd5Sriastradh   case GL_COMPRESSED_TEXTURE_FORMATS_ARB:
15743464ebd5Sriastradh      v->value_int_n.n =
15753464ebd5Sriastradh	 _mesa_get_compressed_formats(ctx, v->value_int_n.ints);
15763464ebd5Sriastradh      ASSERT(v->value_int_n.n <= 100);
15773464ebd5Sriastradh      break;
15783464ebd5Sriastradh
15793464ebd5Sriastradh   case GL_MAX_VARYING_FLOATS_ARB:
15803464ebd5Sriastradh      v->value_int = ctx->Const.MaxVarying * 4;
15813464ebd5Sriastradh      break;
15823464ebd5Sriastradh
15833464ebd5Sriastradh   /* Various object names */
15843464ebd5Sriastradh
15853464ebd5Sriastradh   case GL_TEXTURE_BINDING_1D:
15863464ebd5Sriastradh   case GL_TEXTURE_BINDING_2D:
15873464ebd5Sriastradh   case GL_TEXTURE_BINDING_3D:
15883464ebd5Sriastradh   case GL_TEXTURE_BINDING_1D_ARRAY_EXT:
15893464ebd5Sriastradh   case GL_TEXTURE_BINDING_2D_ARRAY_EXT:
15903464ebd5Sriastradh   case GL_TEXTURE_BINDING_CUBE_MAP_ARB:
15913464ebd5Sriastradh   case GL_TEXTURE_BINDING_RECTANGLE_NV:
15923464ebd5Sriastradh      unit = ctx->Texture.CurrentUnit;
15933464ebd5Sriastradh      v->value_int =
15943464ebd5Sriastradh	 ctx->Texture.Unit[unit].CurrentTex[d->offset]->Name;
15953464ebd5Sriastradh      break;
15963464ebd5Sriastradh
15973464ebd5Sriastradh   /* GL_ARB_vertex_buffer_object */
15983464ebd5Sriastradh   case GL_VERTEX_ARRAY_BUFFER_BINDING_ARB:
15993464ebd5Sriastradh   case GL_NORMAL_ARRAY_BUFFER_BINDING_ARB:
16003464ebd5Sriastradh   case GL_COLOR_ARRAY_BUFFER_BINDING_ARB:
16013464ebd5Sriastradh   case GL_INDEX_ARRAY_BUFFER_BINDING_ARB:
16023464ebd5Sriastradh   case GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB:
16033464ebd5Sriastradh   case GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB:
16043464ebd5Sriastradh   case GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB:
16053464ebd5Sriastradh      buffer_obj = (struct gl_buffer_object **)
16063464ebd5Sriastradh	 ((char *) ctx->Array.ArrayObj + d->offset);
16073464ebd5Sriastradh      v->value_int = (*buffer_obj)->Name;
16083464ebd5Sriastradh      break;
16093464ebd5Sriastradh   case GL_ARRAY_BUFFER_BINDING_ARB:
16103464ebd5Sriastradh      v->value_int = ctx->Array.ArrayBufferObj->Name;
16113464ebd5Sriastradh      break;
16123464ebd5Sriastradh   case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB:
16133464ebd5Sriastradh      v->value_int =
16143464ebd5Sriastradh	 ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].BufferObj->Name;
16153464ebd5Sriastradh      break;
16163464ebd5Sriastradh   case GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB:
16173464ebd5Sriastradh      v->value_int = ctx->Array.ElementArrayBufferObj->Name;
16183464ebd5Sriastradh      break;
16193464ebd5Sriastradh
16203464ebd5Sriastradh   /* ARB_copy_buffer */
16213464ebd5Sriastradh   case GL_COPY_READ_BUFFER:
16223464ebd5Sriastradh      v->value_int = ctx->CopyReadBuffer->Name;
16233464ebd5Sriastradh      break;
16243464ebd5Sriastradh   case GL_COPY_WRITE_BUFFER:
16253464ebd5Sriastradh      v->value_int = ctx->CopyWriteBuffer->Name;
16263464ebd5Sriastradh      break;
16273464ebd5Sriastradh
16283464ebd5Sriastradh   case GL_FRAGMENT_PROGRAM_BINDING_NV:
16293464ebd5Sriastradh      v->value_int =
16303464ebd5Sriastradh	 ctx->FragmentProgram.Current ? ctx->FragmentProgram.Current->Base.Id : 0;
16313464ebd5Sriastradh      break;
16323464ebd5Sriastradh   case GL_VERTEX_PROGRAM_BINDING_NV:
16333464ebd5Sriastradh      v->value_int =
16343464ebd5Sriastradh	 ctx->VertexProgram.Current ? ctx->VertexProgram.Current->Base.Id : 0;
16353464ebd5Sriastradh      break;
16363464ebd5Sriastradh   case GL_PIXEL_PACK_BUFFER_BINDING_EXT:
16373464ebd5Sriastradh      v->value_int = ctx->Pack.BufferObj->Name;
16383464ebd5Sriastradh      break;
16393464ebd5Sriastradh   case GL_PIXEL_UNPACK_BUFFER_BINDING_EXT:
16403464ebd5Sriastradh      v->value_int = ctx->Unpack.BufferObj->Name;
16413464ebd5Sriastradh      break;
16423464ebd5Sriastradh   case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING:
16433464ebd5Sriastradh      v->value_int = ctx->TransformFeedback.CurrentBuffer->Name;
16443464ebd5Sriastradh      break;
16453464ebd5Sriastradh   case GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED:
16463464ebd5Sriastradh      v->value_int = ctx->TransformFeedback.CurrentObject->Paused;
16473464ebd5Sriastradh      break;
16483464ebd5Sriastradh   case GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE:
16493464ebd5Sriastradh      v->value_int = ctx->TransformFeedback.CurrentObject->Active;
16503464ebd5Sriastradh      break;
16513464ebd5Sriastradh   case GL_TRANSFORM_FEEDBACK_BINDING:
16523464ebd5Sriastradh      v->value_int = ctx->TransformFeedback.CurrentObject->Name;
16533464ebd5Sriastradh      break;
16543464ebd5Sriastradh   case GL_CURRENT_PROGRAM:
16553464ebd5Sriastradh      v->value_int =
16563464ebd5Sriastradh	 ctx->Shader.ActiveProgram ? ctx->Shader.ActiveProgram->Name : 0;
16573464ebd5Sriastradh      break;
16583464ebd5Sriastradh   case GL_READ_FRAMEBUFFER_BINDING_EXT:
16593464ebd5Sriastradh      v->value_int = ctx->ReadBuffer->Name;
16603464ebd5Sriastradh      break;
16613464ebd5Sriastradh   case GL_RENDERBUFFER_BINDING_EXT:
16623464ebd5Sriastradh      v->value_int =
16633464ebd5Sriastradh	 ctx->CurrentRenderbuffer ? ctx->CurrentRenderbuffer->Name : 0;
16643464ebd5Sriastradh      break;
16653464ebd5Sriastradh   case GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES:
16663464ebd5Sriastradh      v->value_int = ctx->Array.ArrayObj->PointSize.BufferObj->Name;
16673464ebd5Sriastradh      break;
16683464ebd5Sriastradh
16693464ebd5Sriastradh   case GL_FOG_COLOR:
16703464ebd5Sriastradh      if(ctx->Color._ClampFragmentColor)
16713464ebd5Sriastradh         COPY_4FV(v->value_float_4, ctx->Fog.Color);
16723464ebd5Sriastradh      else
16733464ebd5Sriastradh         COPY_4FV(v->value_float_4, ctx->Fog.ColorUnclamped);
16743464ebd5Sriastradh      break;
16753464ebd5Sriastradh   case GL_COLOR_CLEAR_VALUE:
16763464ebd5Sriastradh      if(ctx->Color._ClampFragmentColor)
16773464ebd5Sriastradh         COPY_4FV(v->value_float_4, ctx->Color.ClearColor);
16783464ebd5Sriastradh      else
16793464ebd5Sriastradh         COPY_4FV(v->value_float_4, ctx->Color.ClearColorUnclamped);
16803464ebd5Sriastradh      break;
16813464ebd5Sriastradh   case GL_BLEND_COLOR_EXT:
16823464ebd5Sriastradh      if(ctx->Color._ClampFragmentColor)
16833464ebd5Sriastradh         COPY_4FV(v->value_float_4, ctx->Color.BlendColor);
16843464ebd5Sriastradh      else
16853464ebd5Sriastradh         COPY_4FV(v->value_float_4, ctx->Color.BlendColorUnclamped);
16863464ebd5Sriastradh      break;
16873464ebd5Sriastradh   case GL_ALPHA_TEST_REF:
16883464ebd5Sriastradh      if(ctx->Color._ClampFragmentColor)
16893464ebd5Sriastradh         v->value_float = ctx->Color.AlphaRef;
16903464ebd5Sriastradh      else
16913464ebd5Sriastradh         v->value_float = ctx->Color.AlphaRefUnclamped;
16923464ebd5Sriastradh      break;
16933464ebd5Sriastradh   case GL_MAX_VERTEX_UNIFORM_VECTORS:
16943464ebd5Sriastradh      v->value_int = ctx->Const.VertexProgram.MaxUniformComponents / 4;
16953464ebd5Sriastradh      break;
16963464ebd5Sriastradh
16973464ebd5Sriastradh   case GL_MAX_FRAGMENT_UNIFORM_VECTORS:
16983464ebd5Sriastradh      v->value_int = ctx->Const.FragmentProgram.MaxUniformComponents / 4;
16993464ebd5Sriastradh      break;
17003464ebd5Sriastradh
17013464ebd5Sriastradh   /* GL_ARB_texture_buffer_object */
17023464ebd5Sriastradh   case GL_TEXTURE_BUFFER_ARB:
17033464ebd5Sriastradh      v->value_int = ctx->Texture.BufferObject->Name;
17043464ebd5Sriastradh      break;
17053464ebd5Sriastradh   case GL_TEXTURE_BINDING_BUFFER_ARB:
17063464ebd5Sriastradh      unit = ctx->Texture.CurrentUnit;
17073464ebd5Sriastradh      v->value_int =
17083464ebd5Sriastradh         ctx->Texture.Unit[unit].CurrentTex[TEXTURE_BUFFER_INDEX]->Name;
17093464ebd5Sriastradh      break;
17103464ebd5Sriastradh   case GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB:
17113464ebd5Sriastradh      {
17123464ebd5Sriastradh         struct gl_buffer_object *buf =
17133464ebd5Sriastradh            ctx->Texture.Unit[ctx->Texture.CurrentUnit]
17143464ebd5Sriastradh            .CurrentTex[TEXTURE_BUFFER_INDEX]->BufferObject;
17153464ebd5Sriastradh         v->value_int = buf ? buf->Name : 0;
17163464ebd5Sriastradh      }
17173464ebd5Sriastradh      break;
17183464ebd5Sriastradh   case GL_TEXTURE_BUFFER_FORMAT_ARB:
17193464ebd5Sriastradh      v->value_int = ctx->Texture.Unit[ctx->Texture.CurrentUnit]
17203464ebd5Sriastradh         .CurrentTex[TEXTURE_BUFFER_INDEX]->BufferObjectFormat;
17213464ebd5Sriastradh      break;
17223464ebd5Sriastradh
17233464ebd5Sriastradh   /* GL_ARB_sampler_objects */
17243464ebd5Sriastradh   case GL_SAMPLER_BINDING:
17253464ebd5Sriastradh      {
17263464ebd5Sriastradh         struct gl_sampler_object *samp =
17273464ebd5Sriastradh            ctx->Texture.Unit[ctx->Texture.CurrentUnit].Sampler;
17283464ebd5Sriastradh         v->value_int = samp ? samp->Name : 0;
17293464ebd5Sriastradh      }
17303464ebd5Sriastradh      break;
17313464ebd5Sriastradh   }
17323464ebd5Sriastradh}
17333464ebd5Sriastradh
17343464ebd5Sriastradh/**
17353464ebd5Sriastradh * Check extra constraints on a struct value_desc descriptor
17363464ebd5Sriastradh *
17373464ebd5Sriastradh * If a struct value_desc has a non-NULL extra pointer, it means that
17383464ebd5Sriastradh * there are a number of extra constraints to check or actions to
17393464ebd5Sriastradh * perform.  The extras is just an integer array where each integer
17403464ebd5Sriastradh * encode different constraints or actions.
17413464ebd5Sriastradh *
17423464ebd5Sriastradh * \param ctx current context
17433464ebd5Sriastradh * \param func name of calling glGet*v() function for error reporting
17443464ebd5Sriastradh * \param d the struct value_desc that has the extra constraints
17453464ebd5Sriastradh *
17463464ebd5Sriastradh * \return GL_FALSE if one of the constraints was not satisfied,
17473464ebd5Sriastradh *     otherwise GL_TRUE.
17487117f1b4Smrg */
17493464ebd5Sriastradhstatic GLboolean
17503464ebd5Sriastradhcheck_extra(struct gl_context *ctx, const char *func, const struct value_desc *d)
17513464ebd5Sriastradh{
17523464ebd5Sriastradh   const GLuint version = ctx->VersionMajor * 10 + ctx->VersionMinor;
17533464ebd5Sriastradh   int total, enabled;
17543464ebd5Sriastradh   const int *e;
17553464ebd5Sriastradh
17563464ebd5Sriastradh   total = 0;
17573464ebd5Sriastradh   enabled = 0;
17583464ebd5Sriastradh   for (e = d->extra; *e != EXTRA_END; e++)
17593464ebd5Sriastradh      switch (*e) {
17603464ebd5Sriastradh      case EXTRA_VERSION_30:
17613464ebd5Sriastradh	 if (version >= 30) {
17623464ebd5Sriastradh	    total++;
17633464ebd5Sriastradh	    enabled++;
17643464ebd5Sriastradh	 }
17653464ebd5Sriastradh	 break;
17663464ebd5Sriastradh      case EXTRA_VERSION_31:
17673464ebd5Sriastradh	 if (version >= 31) {
17683464ebd5Sriastradh	    total++;
17693464ebd5Sriastradh	    enabled++;
17703464ebd5Sriastradh	 }
17713464ebd5Sriastradh	 break;
17723464ebd5Sriastradh      case EXTRA_VERSION_32:
17733464ebd5Sriastradh	 if (version >= 32) {
17743464ebd5Sriastradh	    total++;
17753464ebd5Sriastradh	    enabled++;
17763464ebd5Sriastradh	 }
17773464ebd5Sriastradh	 break;
17783464ebd5Sriastradh      case EXTRA_NEW_FRAG_CLAMP:
17793464ebd5Sriastradh         if (ctx->NewState & (_NEW_BUFFERS | _NEW_FRAG_CLAMP))
17803464ebd5Sriastradh            _mesa_update_state(ctx);
17813464ebd5Sriastradh         break;
17823464ebd5Sriastradh      case EXTRA_VERSION_ES2:
17833464ebd5Sriastradh	 if (ctx->API == API_OPENGLES2) {
17843464ebd5Sriastradh	    total++;
17853464ebd5Sriastradh	    enabled++;
17863464ebd5Sriastradh	 }
17873464ebd5Sriastradh	 break;
17883464ebd5Sriastradh      case EXTRA_NEW_BUFFERS:
17893464ebd5Sriastradh	 if (ctx->NewState & _NEW_BUFFERS)
17903464ebd5Sriastradh	    _mesa_update_state(ctx);
17913464ebd5Sriastradh	 break;
17923464ebd5Sriastradh      case EXTRA_FLUSH_CURRENT:
17933464ebd5Sriastradh	 FLUSH_CURRENT(ctx, 0);
17943464ebd5Sriastradh	 break;
17953464ebd5Sriastradh      case EXTRA_VALID_DRAW_BUFFER:
17963464ebd5Sriastradh	 if (d->pname - GL_DRAW_BUFFER0_ARB >= ctx->Const.MaxDrawBuffers) {
17973464ebd5Sriastradh	    _mesa_error(ctx, GL_INVALID_OPERATION, "%s(draw buffer %u)",
17983464ebd5Sriastradh			func, d->pname - GL_DRAW_BUFFER0_ARB);
17993464ebd5Sriastradh	    return GL_FALSE;
18003464ebd5Sriastradh	 }
18013464ebd5Sriastradh	 break;
18023464ebd5Sriastradh      case EXTRA_VALID_TEXTURE_UNIT:
18033464ebd5Sriastradh	 if (ctx->Texture.CurrentUnit >= ctx->Const.MaxTextureCoordUnits) {
18043464ebd5Sriastradh	    _mesa_error(ctx, GL_INVALID_OPERATION, "%s(texture %u)",
18053464ebd5Sriastradh			func, ctx->Texture.CurrentUnit);
18063464ebd5Sriastradh	    return GL_FALSE;
18073464ebd5Sriastradh	 }
18083464ebd5Sriastradh	 break;
18093464ebd5Sriastradh      case EXTRA_END:
18103464ebd5Sriastradh	 break;
18113464ebd5Sriastradh      default: /* *e is a offset into the extension struct */
18123464ebd5Sriastradh	 total++;
18133464ebd5Sriastradh	 if (*(GLboolean *) ((char *) &ctx->Extensions + *e))
18143464ebd5Sriastradh	    enabled++;
18153464ebd5Sriastradh	 break;
18163464ebd5Sriastradh      }
18173464ebd5Sriastradh
18183464ebd5Sriastradh   if (total > 0 && enabled == 0) {
18193464ebd5Sriastradh      _mesa_error(ctx, GL_INVALID_ENUM, "%s(pname=%s)", func,
18203464ebd5Sriastradh                  _mesa_lookup_enum_by_nr(d->pname));
18213464ebd5Sriastradh      return GL_FALSE;
18227117f1b4Smrg   }
18237117f1b4Smrg
18243464ebd5Sriastradh   return GL_TRUE;
18253464ebd5Sriastradh}
18263464ebd5Sriastradh
18273464ebd5Sriastradhstatic const struct value_desc error_value =
18283464ebd5Sriastradh   { 0, 0, TYPE_INVALID, NO_OFFSET, NO_EXTRA };
18293464ebd5Sriastradh
18303464ebd5Sriastradh/**
18313464ebd5Sriastradh * Find the struct value_desc corresponding to the enum 'pname'.
18323464ebd5Sriastradh *
18333464ebd5Sriastradh * We hash the enum value to get an index into the 'table' array,
18343464ebd5Sriastradh * which holds the index in the 'values' array of struct value_desc.
18353464ebd5Sriastradh * Once we've found the entry, we do the extra checks, if any, then
18363464ebd5Sriastradh * look up the value and return a pointer to it.
18373464ebd5Sriastradh *
18383464ebd5Sriastradh * If the value has to be computed (for example, it's the result of a
18393464ebd5Sriastradh * function call or we need to add 1 to it), we use the tmp 'v' to
18403464ebd5Sriastradh * store the result.
18413464ebd5Sriastradh *
18423464ebd5Sriastradh * \param func name of glGet*v() func for error reporting
18433464ebd5Sriastradh * \param pname the enum value we're looking up
18443464ebd5Sriastradh * \param p is were we return the pointer to the value
18453464ebd5Sriastradh * \param v a tmp union value variable in the calling glGet*v() function
18463464ebd5Sriastradh *
18473464ebd5Sriastradh * \return the struct value_desc corresponding to the enum or a struct
18483464ebd5Sriastradh *     value_desc of TYPE_INVALID if not found.  This lets the calling
18493464ebd5Sriastradh *     glGet*v() function jump right into a switch statement and
18503464ebd5Sriastradh *     handle errors there instead of having to check for NULL.
18517117f1b4Smrg */
18523464ebd5Sriastradhstatic const struct value_desc *
18533464ebd5Sriastradhfind_value(const char *func, GLenum pname, void **p, union value *v)
18543464ebd5Sriastradh{
18553464ebd5Sriastradh   GET_CURRENT_CONTEXT(ctx);
18563464ebd5Sriastradh   struct gl_texture_unit *unit;
18573464ebd5Sriastradh   int mask, hash;
18583464ebd5Sriastradh   const struct value_desc *d;
18593464ebd5Sriastradh
18603464ebd5Sriastradh   mask = Elements(table) - 1;
18613464ebd5Sriastradh   hash = (pname * prime_factor);
18623464ebd5Sriastradh   while (1) {
18633464ebd5Sriastradh      d = &values[table[hash & mask]];
18643464ebd5Sriastradh
18653464ebd5Sriastradh      /* If the enum isn't valid, the hash walk ends with index 0,
18663464ebd5Sriastradh       * which is the API mask entry at the beginning of values[]. */
18673464ebd5Sriastradh      if (unlikely(d->type == TYPE_API_MASK)) {
18683464ebd5Sriastradh	 _mesa_error(ctx, GL_INVALID_ENUM, "%s(pname=%s)", func,
18693464ebd5Sriastradh                     _mesa_lookup_enum_by_nr(pname));
18703464ebd5Sriastradh	 return &error_value;
18713464ebd5Sriastradh      }
18723464ebd5Sriastradh
18733464ebd5Sriastradh      if (likely(d->pname == pname))
18743464ebd5Sriastradh	 break;
18753464ebd5Sriastradh
18763464ebd5Sriastradh      hash += prime_step;
18777117f1b4Smrg   }
18787117f1b4Smrg
18793464ebd5Sriastradh   if (unlikely(d->extra && !check_extra(ctx, func, d)))
18803464ebd5Sriastradh      return &error_value;
18813464ebd5Sriastradh
18823464ebd5Sriastradh   switch (d->location) {
18833464ebd5Sriastradh   case LOC_BUFFER:
18843464ebd5Sriastradh      *p = ((char *) ctx->DrawBuffer + d->offset);
18853464ebd5Sriastradh      return d;
18863464ebd5Sriastradh   case LOC_CONTEXT:
18873464ebd5Sriastradh      *p = ((char *) ctx + d->offset);
18883464ebd5Sriastradh      return d;
18893464ebd5Sriastradh   case LOC_ARRAY:
18903464ebd5Sriastradh      *p = ((char *) ctx->Array.ArrayObj + d->offset);
18913464ebd5Sriastradh      return d;
18923464ebd5Sriastradh   case LOC_TEXUNIT:
18933464ebd5Sriastradh      unit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
18943464ebd5Sriastradh      *p = ((char *) unit + d->offset);
18953464ebd5Sriastradh      return d;
18963464ebd5Sriastradh   case LOC_CUSTOM:
18973464ebd5Sriastradh      find_custom_value(ctx, d, v);
18983464ebd5Sriastradh      *p = v;
18993464ebd5Sriastradh      return d;
19003464ebd5Sriastradh   default:
19013464ebd5Sriastradh      assert(0);
19023464ebd5Sriastradh      break;
19033464ebd5Sriastradh   }
19043464ebd5Sriastradh
19053464ebd5Sriastradh   /* silence warning */
19063464ebd5Sriastradh   return &error_value;
19073464ebd5Sriastradh}
19083464ebd5Sriastradh
19093464ebd5Sriastradhstatic const int transpose[] = {
19103464ebd5Sriastradh   0, 4,  8, 12,
19113464ebd5Sriastradh   1, 5,  9, 13,
19123464ebd5Sriastradh   2, 6, 10, 14,
19133464ebd5Sriastradh   3, 7, 11, 15
19143464ebd5Sriastradh};
19157117f1b4Smrg
19167117f1b4Smrgvoid GLAPIENTRY
19173464ebd5Sriastradh_mesa_GetBooleanv(GLenum pname, GLboolean *params)
19187117f1b4Smrg{
19193464ebd5Sriastradh   const struct value_desc *d;
19203464ebd5Sriastradh   union value v;
19213464ebd5Sriastradh   GLmatrix *m;
19223464ebd5Sriastradh   int shift, i;
19233464ebd5Sriastradh   void *p;
19247117f1b4Smrg   GET_CURRENT_CONTEXT(ctx);
19253464ebd5Sriastradh
19267117f1b4Smrg   ASSERT_OUTSIDE_BEGIN_END(ctx);
19277117f1b4Smrg
19283464ebd5Sriastradh   d = find_value("glGetBooleanv", pname, &p, &v);
19293464ebd5Sriastradh   switch (d->type) {
19303464ebd5Sriastradh   case TYPE_INVALID:
19313464ebd5Sriastradh      break;
19323464ebd5Sriastradh   case TYPE_CONST:
19333464ebd5Sriastradh      params[0] = INT_TO_BOOLEAN(d->offset);
19343464ebd5Sriastradh      break;
19357117f1b4Smrg
19363464ebd5Sriastradh   case TYPE_FLOAT_4:
19373464ebd5Sriastradh   case TYPE_FLOATN_4:
19383464ebd5Sriastradh      params[3] = FLOAT_TO_BOOLEAN(((GLfloat *) p)[3]);
19393464ebd5Sriastradh   case TYPE_FLOAT_3:
19403464ebd5Sriastradh   case TYPE_FLOATN_3:
19413464ebd5Sriastradh      params[2] = FLOAT_TO_BOOLEAN(((GLfloat *) p)[2]);
19423464ebd5Sriastradh   case TYPE_FLOAT_2:
19433464ebd5Sriastradh   case TYPE_FLOATN_2:
19443464ebd5Sriastradh      params[1] = FLOAT_TO_BOOLEAN(((GLfloat *) p)[1]);
19453464ebd5Sriastradh   case TYPE_FLOAT:
19463464ebd5Sriastradh   case TYPE_FLOATN:
19473464ebd5Sriastradh      params[0] = FLOAT_TO_BOOLEAN(((GLfloat *) p)[0]);
19483464ebd5Sriastradh      break;
19497117f1b4Smrg
19503464ebd5Sriastradh   case TYPE_DOUBLEN:
19513464ebd5Sriastradh      params[0] = FLOAT_TO_BOOLEAN(((GLdouble *) p)[0]);
19523464ebd5Sriastradh      break;
19537117f1b4Smrg
19543464ebd5Sriastradh   case TYPE_INT_4:
19553464ebd5Sriastradh      params[3] = INT_TO_BOOLEAN(((GLint *) p)[3]);
19563464ebd5Sriastradh   case TYPE_INT_3:
19573464ebd5Sriastradh      params[2] = INT_TO_BOOLEAN(((GLint *) p)[2]);
19583464ebd5Sriastradh   case TYPE_INT_2:
19593464ebd5Sriastradh   case TYPE_ENUM_2:
19603464ebd5Sriastradh      params[1] = INT_TO_BOOLEAN(((GLint *) p)[1]);
19613464ebd5Sriastradh   case TYPE_INT:
19623464ebd5Sriastradh   case TYPE_ENUM:
19633464ebd5Sriastradh      params[0] = INT_TO_BOOLEAN(((GLint *) p)[0]);
19643464ebd5Sriastradh      break;
19653464ebd5Sriastradh
19663464ebd5Sriastradh   case TYPE_INT_N:
19673464ebd5Sriastradh      for (i = 0; i < v.value_int_n.n; i++)
19683464ebd5Sriastradh	 params[i] = INT_TO_BOOLEAN(v.value_int_n.ints[i]);
19693464ebd5Sriastradh      break;
19703464ebd5Sriastradh
19713464ebd5Sriastradh   case TYPE_INT64:
19723464ebd5Sriastradh      params[0] = INT64_TO_BOOLEAN(((GLint64 *) p)[0]);
19733464ebd5Sriastradh      break;
19743464ebd5Sriastradh
19753464ebd5Sriastradh   case TYPE_BOOLEAN:
19763464ebd5Sriastradh      params[0] = ((GLboolean*) p)[0];
19773464ebd5Sriastradh      break;
19783464ebd5Sriastradh
19793464ebd5Sriastradh   case TYPE_MATRIX:
19803464ebd5Sriastradh      m = *(GLmatrix **) p;
19813464ebd5Sriastradh      for (i = 0; i < 16; i++)
19823464ebd5Sriastradh	 params[i] = FLOAT_TO_BOOLEAN(m->m[i]);
19833464ebd5Sriastradh      break;
19843464ebd5Sriastradh
19853464ebd5Sriastradh   case TYPE_MATRIX_T:
19863464ebd5Sriastradh      m = *(GLmatrix **) p;
19873464ebd5Sriastradh      for (i = 0; i < 16; i++)
19883464ebd5Sriastradh	 params[i] = FLOAT_TO_BOOLEAN(m->m[transpose[i]]);
19893464ebd5Sriastradh      break;
19903464ebd5Sriastradh
19913464ebd5Sriastradh   case TYPE_BIT_0:
19923464ebd5Sriastradh   case TYPE_BIT_1:
19933464ebd5Sriastradh   case TYPE_BIT_2:
19943464ebd5Sriastradh   case TYPE_BIT_3:
19953464ebd5Sriastradh   case TYPE_BIT_4:
19963464ebd5Sriastradh   case TYPE_BIT_5:
19973464ebd5Sriastradh      shift = d->type - TYPE_BIT_0;
19983464ebd5Sriastradh      params[0] = (*(GLbitfield *) p >> shift) & 1;
19993464ebd5Sriastradh      break;
20004a49301eSmrg   }
20014a49301eSmrg}
20027117f1b4Smrg
20037117f1b4Smrgvoid GLAPIENTRY
20043464ebd5Sriastradh_mesa_GetFloatv(GLenum pname, GLfloat *params)
20057117f1b4Smrg{
20063464ebd5Sriastradh   const struct value_desc *d;
20073464ebd5Sriastradh   union value v;
20083464ebd5Sriastradh   GLmatrix *m;
20093464ebd5Sriastradh   int shift, i;
20103464ebd5Sriastradh   void *p;
20113464ebd5Sriastradh   GET_CURRENT_CONTEXT(ctx);
20123464ebd5Sriastradh
20133464ebd5Sriastradh   ASSERT_OUTSIDE_BEGIN_END(ctx);
20147117f1b4Smrg
20153464ebd5Sriastradh   d = find_value("glGetFloatv", pname, &p, &v);
20163464ebd5Sriastradh   switch (d->type) {
20173464ebd5Sriastradh   case TYPE_INVALID:
20183464ebd5Sriastradh      break;
20193464ebd5Sriastradh   case TYPE_CONST:
20203464ebd5Sriastradh      params[0] = (GLfloat) d->offset;
20213464ebd5Sriastradh      break;
20227117f1b4Smrg
20233464ebd5Sriastradh   case TYPE_FLOAT_4:
20243464ebd5Sriastradh   case TYPE_FLOATN_4:
20253464ebd5Sriastradh      params[3] = ((GLfloat *) p)[3];
20263464ebd5Sriastradh   case TYPE_FLOAT_3:
20273464ebd5Sriastradh   case TYPE_FLOATN_3:
20283464ebd5Sriastradh      params[2] = ((GLfloat *) p)[2];
20293464ebd5Sriastradh   case TYPE_FLOAT_2:
20303464ebd5Sriastradh   case TYPE_FLOATN_2:
20313464ebd5Sriastradh      params[1] = ((GLfloat *) p)[1];
20323464ebd5Sriastradh   case TYPE_FLOAT:
20333464ebd5Sriastradh   case TYPE_FLOATN:
20343464ebd5Sriastradh      params[0] = ((GLfloat *) p)[0];
20353464ebd5Sriastradh      break;
20367117f1b4Smrg
20373464ebd5Sriastradh   case TYPE_DOUBLEN:
20383464ebd5Sriastradh      params[0] = ((GLdouble *) p)[0];
20393464ebd5Sriastradh      break;
20403464ebd5Sriastradh
20413464ebd5Sriastradh   case TYPE_INT_4:
20423464ebd5Sriastradh      params[3] = (GLfloat) (((GLint *) p)[3]);
20433464ebd5Sriastradh   case TYPE_INT_3:
20443464ebd5Sriastradh      params[2] = (GLfloat) (((GLint *) p)[2]);
20453464ebd5Sriastradh   case TYPE_INT_2:
20463464ebd5Sriastradh   case TYPE_ENUM_2:
20473464ebd5Sriastradh      params[1] = (GLfloat) (((GLint *) p)[1]);
20483464ebd5Sriastradh   case TYPE_INT:
20493464ebd5Sriastradh   case TYPE_ENUM:
20503464ebd5Sriastradh      params[0] = (GLfloat) (((GLint *) p)[0]);
20513464ebd5Sriastradh      break;
20523464ebd5Sriastradh
20533464ebd5Sriastradh   case TYPE_INT_N:
20543464ebd5Sriastradh      for (i = 0; i < v.value_int_n.n; i++)
20553464ebd5Sriastradh	 params[i] = INT_TO_FLOAT(v.value_int_n.ints[i]);
20563464ebd5Sriastradh      break;
20573464ebd5Sriastradh
20583464ebd5Sriastradh   case TYPE_INT64:
20593464ebd5Sriastradh      params[0] = ((GLint64 *) p)[0];
20603464ebd5Sriastradh      break;
20613464ebd5Sriastradh
20623464ebd5Sriastradh   case TYPE_BOOLEAN:
20633464ebd5Sriastradh      params[0] = BOOLEAN_TO_FLOAT(*(GLboolean*) p);
20643464ebd5Sriastradh      break;
20653464ebd5Sriastradh
20663464ebd5Sriastradh   case TYPE_MATRIX:
20673464ebd5Sriastradh      m = *(GLmatrix **) p;
20683464ebd5Sriastradh      for (i = 0; i < 16; i++)
20693464ebd5Sriastradh	 params[i] = m->m[i];
20703464ebd5Sriastradh      break;
20713464ebd5Sriastradh
20723464ebd5Sriastradh   case TYPE_MATRIX_T:
20733464ebd5Sriastradh      m = *(GLmatrix **) p;
20743464ebd5Sriastradh      for (i = 0; i < 16; i++)
20753464ebd5Sriastradh	 params[i] = m->m[transpose[i]];
20763464ebd5Sriastradh      break;
20773464ebd5Sriastradh
20783464ebd5Sriastradh   case TYPE_BIT_0:
20793464ebd5Sriastradh   case TYPE_BIT_1:
20803464ebd5Sriastradh   case TYPE_BIT_2:
20813464ebd5Sriastradh   case TYPE_BIT_3:
20823464ebd5Sriastradh   case TYPE_BIT_4:
20833464ebd5Sriastradh   case TYPE_BIT_5:
20843464ebd5Sriastradh      shift = d->type - TYPE_BIT_0;
20853464ebd5Sriastradh      params[0] = BOOLEAN_TO_FLOAT((*(GLbitfield *) p >> shift) & 1);
20863464ebd5Sriastradh      break;
20873464ebd5Sriastradh   }
20887117f1b4Smrg}
20897117f1b4Smrg
2090cdc920a0Smrgvoid GLAPIENTRY
20913464ebd5Sriastradh_mesa_GetIntegerv(GLenum pname, GLint *params)
2092cdc920a0Smrg{
20933464ebd5Sriastradh   const struct value_desc *d;
20943464ebd5Sriastradh   union value v;
20953464ebd5Sriastradh   GLmatrix *m;
20963464ebd5Sriastradh   int shift, i;
20973464ebd5Sriastradh   void *p;
2098cdc920a0Smrg   GET_CURRENT_CONTEXT(ctx);
20993464ebd5Sriastradh
2100cdc920a0Smrg   ASSERT_OUTSIDE_BEGIN_END(ctx);
2101cdc920a0Smrg
21023464ebd5Sriastradh   d = find_value("glGetIntegerv", pname, &p, &v);
21033464ebd5Sriastradh   switch (d->type) {
21043464ebd5Sriastradh   case TYPE_INVALID:
21053464ebd5Sriastradh      break;
21063464ebd5Sriastradh   case TYPE_CONST:
21073464ebd5Sriastradh      params[0] = d->offset;
21083464ebd5Sriastradh      break;
2109cdc920a0Smrg
21103464ebd5Sriastradh   case TYPE_FLOAT_4:
21113464ebd5Sriastradh      params[3] = IROUND(((GLfloat *) p)[3]);
21123464ebd5Sriastradh   case TYPE_FLOAT_3:
21133464ebd5Sriastradh      params[2] = IROUND(((GLfloat *) p)[2]);
21143464ebd5Sriastradh   case TYPE_FLOAT_2:
21153464ebd5Sriastradh      params[1] = IROUND(((GLfloat *) p)[1]);
21163464ebd5Sriastradh   case TYPE_FLOAT:
21173464ebd5Sriastradh      params[0] = IROUND(((GLfloat *) p)[0]);
21183464ebd5Sriastradh      break;
2119cdc920a0Smrg
21203464ebd5Sriastradh   case TYPE_FLOATN_4:
21213464ebd5Sriastradh      params[3] = FLOAT_TO_INT(((GLfloat *) p)[3]);
21223464ebd5Sriastradh   case TYPE_FLOATN_3:
21233464ebd5Sriastradh      params[2] = FLOAT_TO_INT(((GLfloat *) p)[2]);
21243464ebd5Sriastradh   case TYPE_FLOATN_2:
21253464ebd5Sriastradh      params[1] = FLOAT_TO_INT(((GLfloat *) p)[1]);
21263464ebd5Sriastradh   case TYPE_FLOATN:
21273464ebd5Sriastradh      params[0] = FLOAT_TO_INT(((GLfloat *) p)[0]);
21283464ebd5Sriastradh      break;
21293464ebd5Sriastradh
21303464ebd5Sriastradh   case TYPE_DOUBLEN:
21313464ebd5Sriastradh      params[0] = FLOAT_TO_INT(((GLdouble *) p)[0]);
21323464ebd5Sriastradh      break;
21333464ebd5Sriastradh
21343464ebd5Sriastradh   case TYPE_INT_4:
21353464ebd5Sriastradh      params[3] = ((GLint *) p)[3];
21363464ebd5Sriastradh   case TYPE_INT_3:
21373464ebd5Sriastradh      params[2] = ((GLint *) p)[2];
21383464ebd5Sriastradh   case TYPE_INT_2:
21393464ebd5Sriastradh   case TYPE_ENUM_2:
21403464ebd5Sriastradh      params[1] = ((GLint *) p)[1];
21413464ebd5Sriastradh   case TYPE_INT:
21423464ebd5Sriastradh   case TYPE_ENUM:
21433464ebd5Sriastradh      params[0] = ((GLint *) p)[0];
21443464ebd5Sriastradh      break;
21453464ebd5Sriastradh
21463464ebd5Sriastradh   case TYPE_INT_N:
21473464ebd5Sriastradh      for (i = 0; i < v.value_int_n.n; i++)
21483464ebd5Sriastradh	 params[i] = v.value_int_n.ints[i];
21493464ebd5Sriastradh      break;
21503464ebd5Sriastradh
21513464ebd5Sriastradh   case TYPE_INT64:
21523464ebd5Sriastradh      params[0] = INT64_TO_INT(((GLint64 *) p)[0]);
21533464ebd5Sriastradh      break;
21543464ebd5Sriastradh
21553464ebd5Sriastradh   case TYPE_BOOLEAN:
21563464ebd5Sriastradh      params[0] = BOOLEAN_TO_INT(*(GLboolean*) p);
21573464ebd5Sriastradh      break;
21583464ebd5Sriastradh
21593464ebd5Sriastradh   case TYPE_MATRIX:
21603464ebd5Sriastradh      m = *(GLmatrix **) p;
21613464ebd5Sriastradh      for (i = 0; i < 16; i++)
21623464ebd5Sriastradh	 params[i] = FLOAT_TO_INT(m->m[i]);
21633464ebd5Sriastradh      break;
21643464ebd5Sriastradh
21653464ebd5Sriastradh   case TYPE_MATRIX_T:
21663464ebd5Sriastradh      m = *(GLmatrix **) p;
21673464ebd5Sriastradh      for (i = 0; i < 16; i++)
21683464ebd5Sriastradh	 params[i] = FLOAT_TO_INT(m->m[transpose[i]]);
21693464ebd5Sriastradh      break;
21703464ebd5Sriastradh
21713464ebd5Sriastradh   case TYPE_BIT_0:
21723464ebd5Sriastradh   case TYPE_BIT_1:
21733464ebd5Sriastradh   case TYPE_BIT_2:
21743464ebd5Sriastradh   case TYPE_BIT_3:
21753464ebd5Sriastradh   case TYPE_BIT_4:
21763464ebd5Sriastradh   case TYPE_BIT_5:
21773464ebd5Sriastradh      shift = d->type - TYPE_BIT_0;
21783464ebd5Sriastradh      params[0] = (*(GLbitfield *) p >> shift) & 1;
21793464ebd5Sriastradh      break;
2180cdc920a0Smrg   }
2181cdc920a0Smrg}
2182cdc920a0Smrg
21833464ebd5Sriastradh#if FEATURE_ARB_sync
2184cdc920a0Smrgvoid GLAPIENTRY
21853464ebd5Sriastradh_mesa_GetInteger64v(GLenum pname, GLint64 *params)
2186cdc920a0Smrg{
21873464ebd5Sriastradh   const struct value_desc *d;
21883464ebd5Sriastradh   union value v;
21893464ebd5Sriastradh   GLmatrix *m;
21903464ebd5Sriastradh   int shift, i;
21913464ebd5Sriastradh   void *p;
2192cdc920a0Smrg   GET_CURRENT_CONTEXT(ctx);
21933464ebd5Sriastradh
2194cdc920a0Smrg   ASSERT_OUTSIDE_BEGIN_END(ctx);
2195cdc920a0Smrg
21963464ebd5Sriastradh   d = find_value("glGetInteger64v", pname, &p, &v);
21973464ebd5Sriastradh   switch (d->type) {
21983464ebd5Sriastradh   case TYPE_INVALID:
21993464ebd5Sriastradh      break;
22003464ebd5Sriastradh   case TYPE_CONST:
22013464ebd5Sriastradh      params[0] = d->offset;
22023464ebd5Sriastradh      break;
2203cdc920a0Smrg
22043464ebd5Sriastradh   case TYPE_FLOAT_4:
22053464ebd5Sriastradh      params[3] = IROUND64(((GLfloat *) p)[3]);
22063464ebd5Sriastradh   case TYPE_FLOAT_3:
22073464ebd5Sriastradh      params[2] = IROUND64(((GLfloat *) p)[2]);
22083464ebd5Sriastradh   case TYPE_FLOAT_2:
22093464ebd5Sriastradh      params[1] = IROUND64(((GLfloat *) p)[1]);
22103464ebd5Sriastradh   case TYPE_FLOAT:
22113464ebd5Sriastradh      params[0] = IROUND64(((GLfloat *) p)[0]);
22123464ebd5Sriastradh      break;
2213cdc920a0Smrg
22143464ebd5Sriastradh   case TYPE_FLOATN_4:
22153464ebd5Sriastradh      params[3] = FLOAT_TO_INT64(((GLfloat *) p)[3]);
22163464ebd5Sriastradh   case TYPE_FLOATN_3:
22173464ebd5Sriastradh      params[2] = FLOAT_TO_INT64(((GLfloat *) p)[2]);
22183464ebd5Sriastradh   case TYPE_FLOATN_2:
22193464ebd5Sriastradh      params[1] = FLOAT_TO_INT64(((GLfloat *) p)[1]);
22203464ebd5Sriastradh   case TYPE_FLOATN:
22213464ebd5Sriastradh      params[0] = FLOAT_TO_INT64(((GLfloat *) p)[0]);
22223464ebd5Sriastradh      break;
22233464ebd5Sriastradh
22243464ebd5Sriastradh   case TYPE_DOUBLEN:
22253464ebd5Sriastradh      params[0] = FLOAT_TO_INT64(((GLdouble *) p)[0]);
22263464ebd5Sriastradh      break;
22273464ebd5Sriastradh
22283464ebd5Sriastradh   case TYPE_INT_4:
22293464ebd5Sriastradh      params[3] = ((GLint *) p)[3];
22303464ebd5Sriastradh   case TYPE_INT_3:
22313464ebd5Sriastradh      params[2] = ((GLint *) p)[2];
22323464ebd5Sriastradh   case TYPE_INT_2:
22333464ebd5Sriastradh   case TYPE_ENUM_2:
22343464ebd5Sriastradh      params[1] = ((GLint *) p)[1];
22353464ebd5Sriastradh   case TYPE_INT:
22363464ebd5Sriastradh   case TYPE_ENUM:
22373464ebd5Sriastradh      params[0] = ((GLint *) p)[0];
22383464ebd5Sriastradh      break;
22393464ebd5Sriastradh
22403464ebd5Sriastradh   case TYPE_INT_N:
22413464ebd5Sriastradh      for (i = 0; i < v.value_int_n.n; i++)
22423464ebd5Sriastradh	 params[i] = INT_TO_BOOLEAN(v.value_int_n.ints[i]);
22433464ebd5Sriastradh      break;
22443464ebd5Sriastradh
22453464ebd5Sriastradh   case TYPE_INT64:
22463464ebd5Sriastradh      params[0] = ((GLint64 *) p)[0];
22473464ebd5Sriastradh      break;
22483464ebd5Sriastradh
22493464ebd5Sriastradh   case TYPE_BOOLEAN:
22503464ebd5Sriastradh      params[0] = ((GLboolean*) p)[0];
22513464ebd5Sriastradh      break;
22523464ebd5Sriastradh
22533464ebd5Sriastradh   case TYPE_MATRIX:
22543464ebd5Sriastradh      m = *(GLmatrix **) p;
22553464ebd5Sriastradh      for (i = 0; i < 16; i++)
22563464ebd5Sriastradh	 params[i] = FLOAT_TO_INT64(m->m[i]);
22573464ebd5Sriastradh      break;
22583464ebd5Sriastradh
22593464ebd5Sriastradh   case TYPE_MATRIX_T:
22603464ebd5Sriastradh      m = *(GLmatrix **) p;
22613464ebd5Sriastradh      for (i = 0; i < 16; i++)
22623464ebd5Sriastradh	 params[i] = FLOAT_TO_INT64(m->m[transpose[i]]);
22633464ebd5Sriastradh      break;
22643464ebd5Sriastradh
22653464ebd5Sriastradh   case TYPE_BIT_0:
22663464ebd5Sriastradh   case TYPE_BIT_1:
22673464ebd5Sriastradh   case TYPE_BIT_2:
22683464ebd5Sriastradh   case TYPE_BIT_3:
22693464ebd5Sriastradh   case TYPE_BIT_4:
22703464ebd5Sriastradh   case TYPE_BIT_5:
22713464ebd5Sriastradh      shift = d->type - TYPE_BIT_0;
22723464ebd5Sriastradh      params[0] = (*(GLbitfield *) p >> shift) & 1;
22733464ebd5Sriastradh      break;
2274cdc920a0Smrg   }
2275cdc920a0Smrg}
22763464ebd5Sriastradh#endif /* FEATURE_ARB_sync */
2277cdc920a0Smrg
2278cdc920a0Smrgvoid GLAPIENTRY
22793464ebd5Sriastradh_mesa_GetDoublev(GLenum pname, GLdouble *params)
2280cdc920a0Smrg{
22813464ebd5Sriastradh   const struct value_desc *d;
22823464ebd5Sriastradh   union value v;
22833464ebd5Sriastradh   GLmatrix *m;
22843464ebd5Sriastradh   int shift, i;
22853464ebd5Sriastradh   void *p;
2286cdc920a0Smrg   GET_CURRENT_CONTEXT(ctx);
22873464ebd5Sriastradh
2288cdc920a0Smrg   ASSERT_OUTSIDE_BEGIN_END(ctx);
2289cdc920a0Smrg
22903464ebd5Sriastradh   d = find_value("glGetDoublev", pname, &p, &v);
22913464ebd5Sriastradh   switch (d->type) {
22923464ebd5Sriastradh   case TYPE_INVALID:
22933464ebd5Sriastradh      break;
22943464ebd5Sriastradh   case TYPE_CONST:
22953464ebd5Sriastradh      params[0] = d->offset;
22963464ebd5Sriastradh      break;
22973464ebd5Sriastradh
22983464ebd5Sriastradh   case TYPE_FLOAT_4:
22993464ebd5Sriastradh   case TYPE_FLOATN_4:
23003464ebd5Sriastradh      params[3] = ((GLfloat *) p)[3];
23013464ebd5Sriastradh   case TYPE_FLOAT_3:
23023464ebd5Sriastradh   case TYPE_FLOATN_3:
23033464ebd5Sriastradh      params[2] = ((GLfloat *) p)[2];
23043464ebd5Sriastradh   case TYPE_FLOAT_2:
23053464ebd5Sriastradh   case TYPE_FLOATN_2:
23063464ebd5Sriastradh      params[1] = ((GLfloat *) p)[1];
23073464ebd5Sriastradh   case TYPE_FLOAT:
23083464ebd5Sriastradh   case TYPE_FLOATN:
23093464ebd5Sriastradh      params[0] = ((GLfloat *) p)[0];
23103464ebd5Sriastradh      break;
23113464ebd5Sriastradh
23123464ebd5Sriastradh   case TYPE_DOUBLEN:
23133464ebd5Sriastradh      params[0] = ((GLdouble *) p)[0];
23143464ebd5Sriastradh      break;
23153464ebd5Sriastradh
23163464ebd5Sriastradh   case TYPE_INT_4:
23173464ebd5Sriastradh      params[3] = ((GLint *) p)[3];
23183464ebd5Sriastradh   case TYPE_INT_3:
23193464ebd5Sriastradh      params[2] = ((GLint *) p)[2];
23203464ebd5Sriastradh   case TYPE_INT_2:
23213464ebd5Sriastradh   case TYPE_ENUM_2:
23223464ebd5Sriastradh      params[1] = ((GLint *) p)[1];
23233464ebd5Sriastradh   case TYPE_INT:
23243464ebd5Sriastradh   case TYPE_ENUM:
23253464ebd5Sriastradh      params[0] = ((GLint *) p)[0];
23263464ebd5Sriastradh      break;
23273464ebd5Sriastradh
23283464ebd5Sriastradh   case TYPE_INT_N:
23293464ebd5Sriastradh      for (i = 0; i < v.value_int_n.n; i++)
23303464ebd5Sriastradh	 params[i] = v.value_int_n.ints[i];
23313464ebd5Sriastradh      break;
23323464ebd5Sriastradh
23333464ebd5Sriastradh   case TYPE_INT64:
23343464ebd5Sriastradh      params[0] = ((GLint64 *) p)[0];
23353464ebd5Sriastradh      break;
23363464ebd5Sriastradh
23373464ebd5Sriastradh   case TYPE_BOOLEAN:
23383464ebd5Sriastradh      params[0] = *(GLboolean*) p;
23393464ebd5Sriastradh      break;
23403464ebd5Sriastradh
23413464ebd5Sriastradh   case TYPE_MATRIX:
23423464ebd5Sriastradh      m = *(GLmatrix **) p;
23433464ebd5Sriastradh      for (i = 0; i < 16; i++)
23443464ebd5Sriastradh	 params[i] = m->m[i];
23453464ebd5Sriastradh      break;
23463464ebd5Sriastradh
23473464ebd5Sriastradh   case TYPE_MATRIX_T:
23483464ebd5Sriastradh      m = *(GLmatrix **) p;
23493464ebd5Sriastradh      for (i = 0; i < 16; i++)
23503464ebd5Sriastradh	 params[i] = m->m[transpose[i]];
23513464ebd5Sriastradh      break;
23523464ebd5Sriastradh
23533464ebd5Sriastradh   case TYPE_BIT_0:
23543464ebd5Sriastradh   case TYPE_BIT_1:
23553464ebd5Sriastradh   case TYPE_BIT_2:
23563464ebd5Sriastradh   case TYPE_BIT_3:
23573464ebd5Sriastradh   case TYPE_BIT_4:
23583464ebd5Sriastradh   case TYPE_BIT_5:
23593464ebd5Sriastradh      shift = d->type - TYPE_BIT_0;
23603464ebd5Sriastradh      params[0] = (*(GLbitfield *) p >> shift) & 1;
23613464ebd5Sriastradh      break;
23623464ebd5Sriastradh   }
23633464ebd5Sriastradh}
2364cdc920a0Smrg
23653464ebd5Sriastradhstatic enum value_type
23663464ebd5Sriastradhfind_value_indexed(const char *func, GLenum pname, int index, union value *v)
23673464ebd5Sriastradh{
23683464ebd5Sriastradh   GET_CURRENT_CONTEXT(ctx);
2369cdc920a0Smrg
2370cdc920a0Smrg   switch (pname) {
23713464ebd5Sriastradh
23723464ebd5Sriastradh   case GL_BLEND:
23733464ebd5Sriastradh      if (index >= ctx->Const.MaxDrawBuffers)
23743464ebd5Sriastradh	 goto invalid_value;
23753464ebd5Sriastradh      if (!ctx->Extensions.EXT_draw_buffers2)
23763464ebd5Sriastradh	 goto invalid_enum;
23773464ebd5Sriastradh      v->value_int = (ctx->Color.BlendEnabled >> index) & 1;
23783464ebd5Sriastradh      return TYPE_INT;
23793464ebd5Sriastradh
23803464ebd5Sriastradh   case GL_BLEND_SRC:
23813464ebd5Sriastradh      /* fall-through */
23823464ebd5Sriastradh   case GL_BLEND_SRC_RGB:
23833464ebd5Sriastradh      if (index >= ctx->Const.MaxDrawBuffers)
23843464ebd5Sriastradh	 goto invalid_value;
23853464ebd5Sriastradh      if (!ctx->Extensions.ARB_draw_buffers_blend)
23863464ebd5Sriastradh	 goto invalid_enum;
23873464ebd5Sriastradh      v->value_int = ctx->Color.Blend[index].SrcRGB;
23883464ebd5Sriastradh      return TYPE_INT;
23893464ebd5Sriastradh   case GL_BLEND_SRC_ALPHA:
23903464ebd5Sriastradh      if (index >= ctx->Const.MaxDrawBuffers)
23913464ebd5Sriastradh	 goto invalid_value;
23923464ebd5Sriastradh      if (!ctx->Extensions.ARB_draw_buffers_blend)
23933464ebd5Sriastradh	 goto invalid_enum;
23943464ebd5Sriastradh      v->value_int = ctx->Color.Blend[index].SrcA;
23953464ebd5Sriastradh      return TYPE_INT;
23963464ebd5Sriastradh   case GL_BLEND_DST:
23973464ebd5Sriastradh      /* fall-through */
23983464ebd5Sriastradh   case GL_BLEND_DST_RGB:
23993464ebd5Sriastradh      if (index >= ctx->Const.MaxDrawBuffers)
24003464ebd5Sriastradh	 goto invalid_value;
24013464ebd5Sriastradh      if (!ctx->Extensions.ARB_draw_buffers_blend)
24023464ebd5Sriastradh	 goto invalid_enum;
24033464ebd5Sriastradh      v->value_int = ctx->Color.Blend[index].DstRGB;
24043464ebd5Sriastradh      return TYPE_INT;
24053464ebd5Sriastradh   case GL_BLEND_DST_ALPHA:
24063464ebd5Sriastradh      if (index >= ctx->Const.MaxDrawBuffers)
24073464ebd5Sriastradh	 goto invalid_value;
24083464ebd5Sriastradh      if (!ctx->Extensions.ARB_draw_buffers_blend)
24093464ebd5Sriastradh	 goto invalid_enum;
24103464ebd5Sriastradh      v->value_int = ctx->Color.Blend[index].DstA;
24113464ebd5Sriastradh      return TYPE_INT;
24123464ebd5Sriastradh   case GL_BLEND_EQUATION_RGB:
24133464ebd5Sriastradh      if (index >= ctx->Const.MaxDrawBuffers)
24143464ebd5Sriastradh	 goto invalid_value;
24153464ebd5Sriastradh      if (!ctx->Extensions.ARB_draw_buffers_blend)
24163464ebd5Sriastradh	 goto invalid_enum;
24173464ebd5Sriastradh      v->value_int = ctx->Color.Blend[index].EquationRGB;
24183464ebd5Sriastradh      return TYPE_INT;
24193464ebd5Sriastradh   case GL_BLEND_EQUATION_ALPHA:
24203464ebd5Sriastradh      if (index >= ctx->Const.MaxDrawBuffers)
24213464ebd5Sriastradh	 goto invalid_value;
24223464ebd5Sriastradh      if (!ctx->Extensions.ARB_draw_buffers_blend)
24233464ebd5Sriastradh	 goto invalid_enum;
24243464ebd5Sriastradh      v->value_int = ctx->Color.Blend[index].EquationA;
24253464ebd5Sriastradh      return TYPE_INT;
24263464ebd5Sriastradh
24273464ebd5Sriastradh   case GL_COLOR_WRITEMASK:
24283464ebd5Sriastradh      if (index >= ctx->Const.MaxDrawBuffers)
24293464ebd5Sriastradh	 goto invalid_value;
24303464ebd5Sriastradh      if (!ctx->Extensions.EXT_draw_buffers2)
24313464ebd5Sriastradh	 goto invalid_enum;
24323464ebd5Sriastradh      v->value_int_4[0] = ctx->Color.ColorMask[index][RCOMP] ? 1 : 0;
24333464ebd5Sriastradh      v->value_int_4[1] = ctx->Color.ColorMask[index][GCOMP] ? 1 : 0;
24343464ebd5Sriastradh      v->value_int_4[2] = ctx->Color.ColorMask[index][BCOMP] ? 1 : 0;
24353464ebd5Sriastradh      v->value_int_4[3] = ctx->Color.ColorMask[index][ACOMP] ? 1 : 0;
24363464ebd5Sriastradh      return TYPE_INT_4;
24373464ebd5Sriastradh
24383464ebd5Sriastradh   case GL_TRANSFORM_FEEDBACK_BUFFER_START:
24393464ebd5Sriastradh      if (index >= ctx->Const.MaxTransformFeedbackSeparateAttribs)
24403464ebd5Sriastradh	 goto invalid_value;
24413464ebd5Sriastradh      if (!ctx->Extensions.EXT_transform_feedback)
24423464ebd5Sriastradh	 goto invalid_enum;
24433464ebd5Sriastradh      v->value_int64 = ctx->TransformFeedback.CurrentObject->Offset[index];
24443464ebd5Sriastradh      return TYPE_INT64;
24453464ebd5Sriastradh
24463464ebd5Sriastradh   case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE:
24473464ebd5Sriastradh      if (index >= ctx->Const.MaxTransformFeedbackSeparateAttribs)
24483464ebd5Sriastradh	 goto invalid_value;
24493464ebd5Sriastradh      if (!ctx->Extensions.EXT_transform_feedback)
24503464ebd5Sriastradh	 goto invalid_enum;
24513464ebd5Sriastradh      v->value_int64 = ctx->TransformFeedback.CurrentObject->Size[index];
24523464ebd5Sriastradh      return TYPE_INT64;
24533464ebd5Sriastradh
24543464ebd5Sriastradh   case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING:
24553464ebd5Sriastradh      if (index >= ctx->Const.MaxTransformFeedbackSeparateAttribs)
24563464ebd5Sriastradh	 goto invalid_value;
24573464ebd5Sriastradh      if (!ctx->Extensions.EXT_transform_feedback)
24583464ebd5Sriastradh	 goto invalid_enum;
24593464ebd5Sriastradh      v->value_int = ctx->TransformFeedback.CurrentObject->Buffers[index]->Name;
24603464ebd5Sriastradh      return TYPE_INT;
24613464ebd5Sriastradh   }
24623464ebd5Sriastradh
24633464ebd5Sriastradh invalid_enum:
24643464ebd5Sriastradh   _mesa_error(ctx, GL_INVALID_ENUM, "%s(pname=%s)", func,
24653464ebd5Sriastradh               _mesa_lookup_enum_by_nr(pname));
24663464ebd5Sriastradh   return TYPE_INVALID;
24673464ebd5Sriastradh invalid_value:
24683464ebd5Sriastradh   _mesa_error(ctx, GL_INVALID_VALUE, "%s(pname=%s)", func,
24693464ebd5Sriastradh               _mesa_lookup_enum_by_nr(pname));
24703464ebd5Sriastradh   return TYPE_INVALID;
24713464ebd5Sriastradh}
24723464ebd5Sriastradh
24733464ebd5Sriastradhvoid GLAPIENTRY
24743464ebd5Sriastradh_mesa_GetBooleanIndexedv( GLenum pname, GLuint index, GLboolean *params )
24753464ebd5Sriastradh{
24763464ebd5Sriastradh   union value v;
24773464ebd5Sriastradh   enum value_type type =
24783464ebd5Sriastradh      find_value_indexed("glGetBooleanIndexedv", pname, index, &v);
24793464ebd5Sriastradh
24803464ebd5Sriastradh   switch (type) {
24813464ebd5Sriastradh   case TYPE_INT:
24823464ebd5Sriastradh      params[0] = INT_TO_BOOLEAN(v.value_int);
24833464ebd5Sriastradh      break;
24843464ebd5Sriastradh   case TYPE_INT_4:
24853464ebd5Sriastradh      params[0] = INT_TO_BOOLEAN(v.value_int_4[0]);
24863464ebd5Sriastradh      params[1] = INT_TO_BOOLEAN(v.value_int_4[1]);
24873464ebd5Sriastradh      params[2] = INT_TO_BOOLEAN(v.value_int_4[2]);
24883464ebd5Sriastradh      params[3] = INT_TO_BOOLEAN(v.value_int_4[3]);
24893464ebd5Sriastradh      break;
24903464ebd5Sriastradh   case TYPE_INT64:
24913464ebd5Sriastradh      params[0] = INT64_TO_BOOLEAN(v.value_int);
24923464ebd5Sriastradh      break;
24933464ebd5Sriastradh   default:
24943464ebd5Sriastradh      ; /* nothing - GL error was recorded */
24953464ebd5Sriastradh   }
24963464ebd5Sriastradh}
24973464ebd5Sriastradh
24983464ebd5Sriastradhvoid GLAPIENTRY
24993464ebd5Sriastradh_mesa_GetIntegerIndexedv( GLenum pname, GLuint index, GLint *params )
25003464ebd5Sriastradh{
25013464ebd5Sriastradh   union value v;
25023464ebd5Sriastradh   enum value_type type =
25033464ebd5Sriastradh      find_value_indexed("glGetIntegerIndexedv", pname, index, &v);
25043464ebd5Sriastradh
25053464ebd5Sriastradh   switch (type) {
25063464ebd5Sriastradh   case TYPE_INT:
25073464ebd5Sriastradh      params[0] = v.value_int;
25083464ebd5Sriastradh      break;
25093464ebd5Sriastradh   case TYPE_INT_4:
25103464ebd5Sriastradh      params[0] = v.value_int_4[0];
25113464ebd5Sriastradh      params[1] = v.value_int_4[1];
25123464ebd5Sriastradh      params[2] = v.value_int_4[2];
25133464ebd5Sriastradh      params[3] = v.value_int_4[3];
25143464ebd5Sriastradh      break;
25153464ebd5Sriastradh   case TYPE_INT64:
25163464ebd5Sriastradh      params[0] = INT64_TO_INT(v.value_int);
25173464ebd5Sriastradh      break;
25183464ebd5Sriastradh   default:
25193464ebd5Sriastradh      ; /* nothing - GL error was recorded */
25203464ebd5Sriastradh   }
25213464ebd5Sriastradh}
25223464ebd5Sriastradh
25233464ebd5Sriastradh#if FEATURE_ARB_sync
25243464ebd5Sriastradhvoid GLAPIENTRY
25253464ebd5Sriastradh_mesa_GetInteger64Indexedv( GLenum pname, GLuint index, GLint64 *params )
25263464ebd5Sriastradh{
25273464ebd5Sriastradh   union value v;
25283464ebd5Sriastradh   enum value_type type =
25293464ebd5Sriastradh      find_value_indexed("glGetIntegerIndexedv", pname, index, &v);
25303464ebd5Sriastradh
25313464ebd5Sriastradh   switch (type) {
25323464ebd5Sriastradh   case TYPE_INT:
25333464ebd5Sriastradh      params[0] = v.value_int;
25343464ebd5Sriastradh      break;
25353464ebd5Sriastradh   case TYPE_INT_4:
25363464ebd5Sriastradh      params[0] = v.value_int_4[0];
25373464ebd5Sriastradh      params[1] = v.value_int_4[1];
25383464ebd5Sriastradh      params[2] = v.value_int_4[2];
25393464ebd5Sriastradh      params[3] = v.value_int_4[3];
25403464ebd5Sriastradh      break;
25413464ebd5Sriastradh   case TYPE_INT64:
25423464ebd5Sriastradh      params[0] = v.value_int;
25433464ebd5Sriastradh      break;
25443464ebd5Sriastradh   default:
25453464ebd5Sriastradh      ; /* nothing - GL error was recorded */
2546cdc920a0Smrg   }
2547cdc920a0Smrg}
2548cdc920a0Smrg#endif /* FEATURE_ARB_sync */
2549cdc920a0Smrg
25503464ebd5Sriastradh#if FEATURE_ES1
25513464ebd5Sriastradhvoid GLAPIENTRY
25523464ebd5Sriastradh_mesa_GetFixedv(GLenum pname, GLfixed *params)
25533464ebd5Sriastradh{
25543464ebd5Sriastradh   const struct value_desc *d;
25553464ebd5Sriastradh   union value v;
25563464ebd5Sriastradh   GLmatrix *m;
25573464ebd5Sriastradh   int shift, i;
25583464ebd5Sriastradh   void *p;
25593464ebd5Sriastradh
25603464ebd5Sriastradh   d = find_value("glGetDoublev", pname, &p, &v);
25613464ebd5Sriastradh   switch (d->type) {
25623464ebd5Sriastradh   case TYPE_INVALID:
25633464ebd5Sriastradh      break;
25643464ebd5Sriastradh   case TYPE_CONST:
25653464ebd5Sriastradh      params[0] = INT_TO_FIXED(d->offset);
25663464ebd5Sriastradh      break;
25673464ebd5Sriastradh
25683464ebd5Sriastradh   case TYPE_FLOAT_4:
25693464ebd5Sriastradh   case TYPE_FLOATN_4:
25703464ebd5Sriastradh      params[3] = FLOAT_TO_FIXED(((GLfloat *) p)[3]);
25713464ebd5Sriastradh   case TYPE_FLOAT_3:
25723464ebd5Sriastradh   case TYPE_FLOATN_3:
25733464ebd5Sriastradh      params[2] = FLOAT_TO_FIXED(((GLfloat *) p)[2]);
25743464ebd5Sriastradh   case TYPE_FLOAT_2:
25753464ebd5Sriastradh   case TYPE_FLOATN_2:
25763464ebd5Sriastradh      params[1] = FLOAT_TO_FIXED(((GLfloat *) p)[1]);
25773464ebd5Sriastradh   case TYPE_FLOAT:
25783464ebd5Sriastradh   case TYPE_FLOATN:
25793464ebd5Sriastradh      params[0] = FLOAT_TO_FIXED(((GLfloat *) p)[0]);
25803464ebd5Sriastradh      break;
25813464ebd5Sriastradh
25823464ebd5Sriastradh   case TYPE_DOUBLEN:
25833464ebd5Sriastradh      params[0] = FLOAT_TO_FIXED(((GLdouble *) p)[0]);
25843464ebd5Sriastradh      break;
25853464ebd5Sriastradh
25863464ebd5Sriastradh   case TYPE_INT_4:
25873464ebd5Sriastradh      params[3] = INT_TO_FIXED(((GLint *) p)[3]);
25883464ebd5Sriastradh   case TYPE_INT_3:
25893464ebd5Sriastradh      params[2] = INT_TO_FIXED(((GLint *) p)[2]);
25903464ebd5Sriastradh   case TYPE_INT_2:
25913464ebd5Sriastradh   case TYPE_ENUM_2:
25923464ebd5Sriastradh      params[1] = INT_TO_FIXED(((GLint *) p)[1]);
25933464ebd5Sriastradh   case TYPE_INT:
25943464ebd5Sriastradh   case TYPE_ENUM:
25953464ebd5Sriastradh      params[0] = INT_TO_FIXED(((GLint *) p)[0]);
25963464ebd5Sriastradh      break;
25973464ebd5Sriastradh
25983464ebd5Sriastradh   case TYPE_INT_N:
25993464ebd5Sriastradh      for (i = 0; i < v.value_int_n.n; i++)
26003464ebd5Sriastradh	 params[i] = INT_TO_FIXED(v.value_int_n.ints[i]);
26013464ebd5Sriastradh      break;
26023464ebd5Sriastradh
26033464ebd5Sriastradh   case TYPE_INT64:
26043464ebd5Sriastradh      params[0] = ((GLint64 *) p)[0];
26053464ebd5Sriastradh      break;
26063464ebd5Sriastradh
26073464ebd5Sriastradh   case TYPE_BOOLEAN:
26083464ebd5Sriastradh      params[0] = BOOLEAN_TO_FIXED(((GLboolean*) p)[0]);
26093464ebd5Sriastradh      break;
26103464ebd5Sriastradh
26113464ebd5Sriastradh   case TYPE_MATRIX:
26123464ebd5Sriastradh      m = *(GLmatrix **) p;
26133464ebd5Sriastradh      for (i = 0; i < 16; i++)
26143464ebd5Sriastradh	 params[i] = FLOAT_TO_FIXED(m->m[i]);
26153464ebd5Sriastradh      break;
26163464ebd5Sriastradh
26173464ebd5Sriastradh   case TYPE_MATRIX_T:
26183464ebd5Sriastradh      m = *(GLmatrix **) p;
26193464ebd5Sriastradh      for (i = 0; i < 16; i++)
26203464ebd5Sriastradh	 params[i] = FLOAT_TO_FIXED(m->m[transpose[i]]);
26213464ebd5Sriastradh      break;
26223464ebd5Sriastradh
26233464ebd5Sriastradh   case TYPE_BIT_0:
26243464ebd5Sriastradh   case TYPE_BIT_1:
26253464ebd5Sriastradh   case TYPE_BIT_2:
26263464ebd5Sriastradh   case TYPE_BIT_3:
26273464ebd5Sriastradh   case TYPE_BIT_4:
26283464ebd5Sriastradh   case TYPE_BIT_5:
26293464ebd5Sriastradh      shift = d->type - TYPE_BIT_0;
26303464ebd5Sriastradh      params[0] = BOOLEAN_TO_FIXED((*(GLbitfield *) p >> shift) & 1);
26313464ebd5Sriastradh      break;
26323464ebd5Sriastradh   }
26333464ebd5Sriastradh}
26343464ebd5Sriastradh#endif
2635