mesa: Remove EXT_convolution.
[mesa.git] / src / mesa / main / get.c
1 /*
2 * Copyright (C) 2010 Brian Paul All Rights Reserved.
3 * Copyright (C) 2010 Intel Corporation
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included
13 * in all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
19 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 *
22 * Author: Kristian Høgsberg <krh@bitplanet.net>
23 */
24
25 #include "glheader.h"
26 #include "context.h"
27 #include "enable.h"
28 #include "enums.h"
29 #include "extensions.h"
30 #include "get.h"
31 #include "macros.h"
32 #include "mtypes.h"
33 #include "state.h"
34 #include "texcompress.h"
35 #include "framebuffer.h"
36
37 /* This is a table driven implemetation of the glGet*v() functions.
38 * The basic idea is that most getters just look up an int somewhere
39 * in GLcontext and then convert it to a bool or float according to
40 * which of glGetIntegerv() glGetBooleanv() etc is being called.
41 * Instead of generating code to do this, we can just record the enum
42 * value and the offset into GLcontext in an array of structs. Then
43 * in glGet*(), we lookup the struct for the enum in question, and use
44 * the offset to get the int we need.
45 *
46 * Sometimes we need to look up a float, a boolean, a bit in a
47 * bitfield, a matrix or other types instead, so we need to track the
48 * type of the value in GLcontext. And sometimes the value isn't in
49 * GLcontext but in the drawbuffer, the array object, current texture
50 * unit, or maybe it's a computed value. So we need to also track
51 * where or how to find the value. Finally, we sometimes need to
52 * check that one of a number of extensions are enabled, the GL
53 * version or flush or call _mesa_update_state(). This is done by
54 * attaching optional extra information to the value description
55 * struct, it's sort of like an array of opcodes that describe extra
56 * checks or actions.
57 *
58 * Putting all this together we end up with struct value_desc below,
59 * and with a couple of macros to help, the table of struct value_desc
60 * is about as concise as the specification in the old python script.
61 */
62
63 #undef CONST
64
65 #define FLOAT_TO_BOOLEAN(X) ( (X) ? GL_TRUE : GL_FALSE )
66 #define FLOAT_TO_FIXED(F) ( ((F) * 65536.0f > INT_MAX) ? INT_MAX : \
67 ((F) * 65536.0f < INT_MIN) ? INT_MIN : \
68 (GLint) ((F) * 65536.0f) )
69
70 #define INT_TO_BOOLEAN(I) ( (I) ? GL_TRUE : GL_FALSE )
71 #define INT_TO_FIXED(I) ( ((I) > SHRT_MAX) ? INT_MAX : \
72 ((I) < SHRT_MIN) ? INT_MIN : \
73 (GLint) ((I) * 65536) )
74
75 #define INT64_TO_BOOLEAN(I) ( (I) ? GL_TRUE : GL_FALSE )
76 #define INT64_TO_INT(I) ( (GLint)((I > INT_MAX) ? INT_MAX : ((I < INT_MIN) ? INT_MIN : (I))) )
77
78 #define BOOLEAN_TO_INT(B) ( (GLint) (B) )
79 #define BOOLEAN_TO_INT64(B) ( (GLint64) (B) )
80 #define BOOLEAN_TO_FLOAT(B) ( (B) ? 1.0F : 0.0F )
81 #define BOOLEAN_TO_FIXED(B) ( (GLint) ((B) ? 1 : 0) << 16 )
82
83 #define ENUM_TO_INT64(E) ( (GLint64) (E) )
84 #define ENUM_TO_FIXED(E) (E)
85
86 enum value_type {
87 TYPE_INVALID,
88 TYPE_API_MASK,
89 TYPE_INT,
90 TYPE_INT_2,
91 TYPE_INT_3,
92 TYPE_INT_4,
93 TYPE_INT_N,
94 TYPE_INT64,
95 TYPE_ENUM,
96 TYPE_ENUM_2,
97 TYPE_BOOLEAN,
98 TYPE_BIT_0,
99 TYPE_BIT_1,
100 TYPE_BIT_2,
101 TYPE_BIT_3,
102 TYPE_BIT_4,
103 TYPE_BIT_5,
104 TYPE_FLOAT,
105 TYPE_FLOAT_2,
106 TYPE_FLOAT_3,
107 TYPE_FLOAT_4,
108 TYPE_FLOATN,
109 TYPE_FLOATN_2,
110 TYPE_FLOATN_3,
111 TYPE_FLOATN_4,
112 TYPE_DOUBLEN,
113 TYPE_MATRIX,
114 TYPE_MATRIX_T,
115 TYPE_CONST
116 };
117
118 enum value_location {
119 LOC_BUFFER,
120 LOC_CONTEXT,
121 LOC_ARRAY,
122 LOC_TEXUNIT,
123 LOC_CUSTOM
124 };
125
126 enum value_extra {
127 EXTRA_END = 0x8000,
128 EXTRA_VERSION_30,
129 EXTRA_VERSION_31,
130 EXTRA_VERSION_32,
131 EXTRA_VERSION_ES2,
132 EXTRA_NEW_BUFFERS,
133 EXTRA_VALID_DRAW_BUFFER,
134 EXTRA_VALID_TEXTURE_UNIT,
135 EXTRA_FLUSH_CURRENT,
136 };
137
138 #define NO_EXTRA NULL
139 #define NO_OFFSET 0
140
141 struct value_desc {
142 GLenum pname;
143 GLubyte location; /**< enum value_location */
144 GLubyte type; /**< enum value_type */
145 int offset;
146 const int *extra;
147 };
148
149 union value {
150 GLfloat value_float;
151 GLfloat value_float_4[4];
152 GLmatrix *value_matrix;
153 GLint value_int;
154 GLint value_int_4[4];
155 GLint64 value_int64;
156 GLenum value_enum;
157
158 /* Sigh, see GL_COMPRESSED_TEXTURE_FORMATS_ARB handling */
159 struct {
160 GLint n, ints[100];
161 } value_int_n;
162 GLboolean value_bool;
163 };
164
165 #define BUFFER_FIELD(field, type) \
166 LOC_BUFFER, type, offsetof(struct gl_framebuffer, field)
167 #define CONTEXT_FIELD(field, type) \
168 LOC_CONTEXT, type, offsetof(GLcontext, field)
169 #define ARRAY_FIELD(field, type) \
170 LOC_ARRAY, type, offsetof(struct gl_array_object, field)
171 #define CONST(value) \
172 LOC_CONTEXT, TYPE_CONST, value
173
174 #define BUFFER_INT(field) BUFFER_FIELD(field, TYPE_INT)
175 #define BUFFER_ENUM(field) BUFFER_FIELD(field, TYPE_ENUM)
176
177 #define CONTEXT_INT(field) CONTEXT_FIELD(field, TYPE_INT)
178 #define CONTEXT_INT2(field) CONTEXT_FIELD(field, TYPE_INT_2)
179 #define CONTEXT_INT64(field) CONTEXT_FIELD(field, TYPE_INT64)
180 #define CONTEXT_ENUM(field) CONTEXT_FIELD(field, TYPE_ENUM)
181 #define CONTEXT_ENUM2(field) CONTEXT_FIELD(field, TYPE_ENUM_2)
182 #define CONTEXT_BOOL(field) CONTEXT_FIELD(field, TYPE_BOOLEAN)
183 #define CONTEXT_BIT0(field) CONTEXT_FIELD(field, TYPE_BIT_0)
184 #define CONTEXT_BIT1(field) CONTEXT_FIELD(field, TYPE_BIT_1)
185 #define CONTEXT_BIT2(field) CONTEXT_FIELD(field, TYPE_BIT_2)
186 #define CONTEXT_BIT3(field) CONTEXT_FIELD(field, TYPE_BIT_3)
187 #define CONTEXT_BIT4(field) CONTEXT_FIELD(field, TYPE_BIT_4)
188 #define CONTEXT_BIT5(field) CONTEXT_FIELD(field, TYPE_BIT_5)
189 #define CONTEXT_FLOAT(field) CONTEXT_FIELD(field, TYPE_FLOAT)
190 #define CONTEXT_FLOAT2(field) CONTEXT_FIELD(field, TYPE_FLOAT_2)
191 #define CONTEXT_FLOAT3(field) CONTEXT_FIELD(field, TYPE_FLOAT_3)
192 #define CONTEXT_FLOAT4(field) CONTEXT_FIELD(field, TYPE_FLOAT_4)
193 #define CONTEXT_MATRIX(field) CONTEXT_FIELD(field, TYPE_MATRIX)
194 #define CONTEXT_MATRIX_T(field) CONTEXT_FIELD(field, TYPE_MATRIX_T)
195
196 #define ARRAY_INT(field) ARRAY_FIELD(field, TYPE_INT)
197 #define ARRAY_ENUM(field) ARRAY_FIELD(field, TYPE_ENUM)
198 #define ARRAY_BOOL(field) ARRAY_FIELD(field, TYPE_BOOLEAN)
199
200 #define EXT(f) \
201 offsetof(struct gl_extensions, f)
202
203 #define EXTRA_EXT(e) \
204 static const int extra_##e[] = { \
205 EXT(e), EXTRA_END \
206 }
207
208 #define EXTRA_EXT2(e1, e2) \
209 static const int extra_##e1##_##e2[] = { \
210 EXT(e1), EXT(e2), EXTRA_END \
211 }
212
213 /* The 'extra' mechanism is a way to specify extra checks (such as
214 * extensions or specific gl versions) or actions (flush current, new
215 * buffers) that we need to do before looking up an enum. We need to
216 * declare them all up front so we can refer to them in the value_desc
217 * structs below. */
218
219 static const int extra_new_buffers[] = {
220 EXTRA_NEW_BUFFERS,
221 EXTRA_END
222 };
223
224 static const int extra_valid_draw_buffer[] = {
225 EXTRA_VALID_DRAW_BUFFER,
226 EXTRA_END
227 };
228
229 static const int extra_valid_texture_unit[] = {
230 EXTRA_VALID_TEXTURE_UNIT,
231 EXTRA_END
232 };
233
234 static const int extra_flush_current_valid_texture_unit[] = {
235 EXTRA_FLUSH_CURRENT,
236 EXTRA_VALID_TEXTURE_UNIT,
237 EXTRA_END
238 };
239
240 static const int extra_flush_current[] = {
241 EXTRA_FLUSH_CURRENT,
242 EXTRA_END
243 };
244
245 static const int extra_new_buffers_OES_read_format[] = {
246 EXTRA_NEW_BUFFERS,
247 EXT(OES_read_format),
248 EXTRA_END
249 };
250
251 static const int extra_EXT_secondary_color_flush_current[] = {
252 EXT(EXT_secondary_color),
253 EXTRA_FLUSH_CURRENT,
254 EXTRA_END
255 };
256
257 static const int extra_EXT_fog_coord_flush_current[] = {
258 EXT(EXT_fog_coord),
259 EXTRA_FLUSH_CURRENT,
260 EXTRA_END
261 };
262
263 EXTRA_EXT(ARB_multitexture);
264 EXTRA_EXT(ARB_texture_cube_map);
265 EXTRA_EXT(MESA_texture_array);
266 EXTRA_EXT2(EXT_secondary_color, ARB_vertex_program);
267 EXTRA_EXT(EXT_secondary_color);
268 EXTRA_EXT(EXT_fog_coord);
269 EXTRA_EXT(EXT_texture_lod_bias);
270 EXTRA_EXT(EXT_texture_filter_anisotropic);
271 EXTRA_EXT(IBM_rasterpos_clip);
272 EXTRA_EXT(NV_point_sprite);
273 EXTRA_EXT(SGIS_generate_mipmap);
274 EXTRA_EXT(NV_vertex_program);
275 EXTRA_EXT(NV_fragment_program);
276 EXTRA_EXT(NV_texture_rectangle);
277 EXTRA_EXT(EXT_stencil_two_side);
278 EXTRA_EXT(NV_light_max_exponent);
279 EXTRA_EXT(SGI_texture_color_table);
280 EXTRA_EXT(EXT_depth_bounds_test);
281 EXTRA_EXT(ARB_depth_clamp);
282 EXTRA_EXT(ATI_fragment_shader);
283 EXTRA_EXT(EXT_framebuffer_blit);
284 EXTRA_EXT(ARB_shader_objects);
285 EXTRA_EXT(EXT_provoking_vertex);
286 EXTRA_EXT(ARB_fragment_shader);
287 EXTRA_EXT(ARB_fragment_program);
288 EXTRA_EXT(ARB_framebuffer_object);
289 EXTRA_EXT(EXT_framebuffer_object);
290 EXTRA_EXT(APPLE_vertex_array_object);
291 EXTRA_EXT(ARB_seamless_cube_map);
292 EXTRA_EXT(EXT_compiled_vertex_array);
293 EXTRA_EXT(ARB_sync);
294 EXTRA_EXT(ARB_vertex_shader);
295 EXTRA_EXT(EXT_transform_feedback);
296 EXTRA_EXT(ARB_transform_feedback2);
297 EXTRA_EXT(EXT_pixel_buffer_object);
298 EXTRA_EXT(ARB_vertex_program);
299 EXTRA_EXT2(NV_point_sprite, ARB_point_sprite);
300 EXTRA_EXT2(ARB_fragment_program, NV_fragment_program);
301 EXTRA_EXT2(ARB_vertex_program, NV_vertex_program);
302 EXTRA_EXT2(ARB_vertex_program, ARB_fragment_program);
303 EXTRA_EXT(ARB_vertex_buffer_object);
304 EXTRA_EXT(ARB_geometry_shader4);
305
306 static const int
307 extra_ARB_vertex_program_ARB_fragment_program_NV_vertex_program[] = {
308 EXT(ARB_vertex_program),
309 EXT(ARB_fragment_program),
310 EXT(NV_vertex_program),
311 EXTRA_END
312 };
313
314 static const int
315 extra_NV_vertex_program_ARB_vertex_program_ARB_fragment_program_NV_vertex_program[] = {
316 EXT(NV_vertex_program),
317 EXT(ARB_vertex_program),
318 EXT(ARB_fragment_program),
319 EXT(NV_vertex_program),
320 EXTRA_END
321 };
322
323 static const int extra_version_30[] = { EXTRA_VERSION_30, EXTRA_END };
324 static const int extra_version_31[] = { EXTRA_VERSION_31, EXTRA_END };
325 static const int extra_version_32[] = { EXTRA_VERSION_32, EXTRA_END };
326
327 static const int
328 extra_ARB_vertex_program_version_es2[] = {
329 EXT(ARB_vertex_program),
330 EXTRA_VERSION_ES2,
331 EXTRA_END
332 };
333
334 #define API_OPENGL_BIT (1 << API_OPENGL)
335 #define API_OPENGLES_BIT (1 << API_OPENGLES)
336 #define API_OPENGLES2_BIT (1 << API_OPENGLES2)
337
338 /* This is the big table describing all the enums we accept in
339 * glGet*v(). The table is partitioned into six parts: enums
340 * understood by all GL APIs (OpenGL, GLES and GLES2), enums shared
341 * between OpenGL and GLES, enums exclusive to GLES, etc for the
342 * remaining combinations. When we add the enums to the hash table in
343 * _mesa_init_get_hash(), we only add the enums for the API we're
344 * instantiating and the different sections are guarded by #if
345 * FEATURE_GL etc to make sure we only compile in the enums we may
346 * need. */
347
348 static const struct value_desc values[] = {
349 /* Enums shared between OpenGL, GLES1 and GLES2 */
350 { 0, 0, TYPE_API_MASK,
351 API_OPENGL_BIT | API_OPENGLES_BIT | API_OPENGLES2_BIT, NO_EXTRA},
352 { GL_ALPHA_BITS, BUFFER_INT(Visual.alphaBits), extra_new_buffers },
353 { GL_BLEND, CONTEXT_BIT0(Color.BlendEnabled), NO_EXTRA },
354 { GL_BLEND_SRC, CONTEXT_ENUM(Color.BlendSrcRGB), NO_EXTRA },
355 { GL_BLUE_BITS, BUFFER_INT(Visual.blueBits), extra_new_buffers },
356 { GL_COLOR_CLEAR_VALUE, CONTEXT_FIELD(Color.ClearColor[0], TYPE_FLOATN_4), NO_EXTRA },
357 { GL_COLOR_WRITEMASK, LOC_CUSTOM, TYPE_INT_4, 0, NO_EXTRA },
358 { GL_CULL_FACE, CONTEXT_BOOL(Polygon.CullFlag), NO_EXTRA },
359 { GL_CULL_FACE_MODE, CONTEXT_ENUM(Polygon.CullFaceMode), NO_EXTRA },
360 { GL_DEPTH_BITS, BUFFER_INT(Visual.depthBits), NO_EXTRA },
361 { GL_DEPTH_CLEAR_VALUE, CONTEXT_FIELD(Depth.Clear, TYPE_DOUBLEN), NO_EXTRA },
362 { GL_DEPTH_FUNC, CONTEXT_ENUM(Depth.Func), NO_EXTRA },
363 { GL_DEPTH_RANGE, CONTEXT_FIELD(Viewport.Near, TYPE_FLOATN_2), NO_EXTRA },
364 { GL_DEPTH_TEST, CONTEXT_BOOL(Depth.Test), NO_EXTRA },
365 { GL_DEPTH_WRITEMASK, CONTEXT_BOOL(Depth.Mask), NO_EXTRA },
366 { GL_DITHER, CONTEXT_BOOL(Color.DitherFlag), NO_EXTRA },
367 { GL_FRONT_FACE, CONTEXT_ENUM(Polygon.FrontFace), NO_EXTRA },
368 { GL_GREEN_BITS, BUFFER_INT(Visual.greenBits), extra_new_buffers },
369 { GL_LINE_WIDTH, CONTEXT_FLOAT(Line.Width), NO_EXTRA },
370 { GL_ALIASED_LINE_WIDTH_RANGE, CONTEXT_FLOAT2(Const.MinLineWidth), NO_EXTRA },
371 { GL_MAX_ELEMENTS_VERTICES, CONTEXT_INT(Const.MaxArrayLockSize), NO_EXTRA },
372 { GL_MAX_ELEMENTS_INDICES, CONTEXT_INT(Const.MaxArrayLockSize), NO_EXTRA },
373 { GL_MAX_TEXTURE_SIZE, LOC_CUSTOM, TYPE_INT,
374 offsetof(GLcontext, Const.MaxTextureLevels), NO_EXTRA },
375 { GL_MAX_VIEWPORT_DIMS, CONTEXT_INT2(Const.MaxViewportWidth), NO_EXTRA },
376 { GL_PACK_ALIGNMENT, CONTEXT_INT(Pack.Alignment), NO_EXTRA },
377 { GL_ALIASED_POINT_SIZE_RANGE, CONTEXT_FLOAT2(Const.MinPointSize), NO_EXTRA },
378 { GL_POLYGON_OFFSET_FACTOR, CONTEXT_FLOAT(Polygon.OffsetFactor ), NO_EXTRA },
379 { GL_POLYGON_OFFSET_UNITS, CONTEXT_FLOAT(Polygon.OffsetUnits ), NO_EXTRA },
380 { GL_POLYGON_OFFSET_FILL, CONTEXT_BOOL(Polygon.OffsetFill), NO_EXTRA },
381 { GL_RED_BITS, BUFFER_INT(Visual.redBits), extra_new_buffers },
382 { GL_SCISSOR_BOX, LOC_CUSTOM, TYPE_INT_4, 0, NO_EXTRA },
383 { GL_SCISSOR_TEST, CONTEXT_BOOL(Scissor.Enabled), NO_EXTRA },
384 { GL_STENCIL_BITS, BUFFER_INT(Visual.stencilBits), NO_EXTRA },
385 { GL_STENCIL_CLEAR_VALUE, CONTEXT_INT(Stencil.Clear), NO_EXTRA },
386 { GL_STENCIL_FAIL, LOC_CUSTOM, TYPE_ENUM, NO_OFFSET, NO_EXTRA },
387 { GL_STENCIL_FUNC, LOC_CUSTOM, TYPE_ENUM, NO_OFFSET, NO_EXTRA },
388 { GL_STENCIL_PASS_DEPTH_FAIL, LOC_CUSTOM, TYPE_ENUM, NO_OFFSET, NO_EXTRA },
389 { GL_STENCIL_PASS_DEPTH_PASS, LOC_CUSTOM, TYPE_ENUM, NO_OFFSET, NO_EXTRA },
390 { GL_STENCIL_REF, LOC_CUSTOM, TYPE_INT, NO_OFFSET, NO_EXTRA },
391 { GL_STENCIL_TEST, CONTEXT_BOOL(Stencil.Enabled), NO_EXTRA },
392 { GL_STENCIL_VALUE_MASK, LOC_CUSTOM, TYPE_INT, NO_OFFSET, NO_EXTRA },
393 { GL_STENCIL_WRITEMASK, LOC_CUSTOM, TYPE_INT, NO_OFFSET, NO_EXTRA },
394 { GL_SUBPIXEL_BITS, CONTEXT_INT(Const.SubPixelBits), NO_EXTRA },
395 { GL_TEXTURE_BINDING_2D, LOC_CUSTOM, TYPE_INT, TEXTURE_2D_INDEX, NO_EXTRA },
396 { GL_UNPACK_ALIGNMENT, CONTEXT_INT(Unpack.Alignment), NO_EXTRA },
397 { GL_VIEWPORT, LOC_CUSTOM, TYPE_INT_4, 0, NO_EXTRA },
398
399 /* GL_ARB_multitexture */
400 { GL_ACTIVE_TEXTURE_ARB,
401 LOC_CUSTOM, TYPE_INT, 0, extra_ARB_multitexture },
402
403 /* Note that all the OES_* extensions require that the Mesa "struct
404 * gl_extensions" include a member with the name of the extension.
405 * That structure does not yet include OES extensions (and we're
406 * not sure whether it will). If it does, all the OES_*
407 * extensions below should mark the dependency. */
408
409 /* GL_ARB_texture_cube_map */
410 { GL_TEXTURE_BINDING_CUBE_MAP_ARB, LOC_CUSTOM, TYPE_INT,
411 TEXTURE_CUBE_INDEX, extra_ARB_texture_cube_map },
412 { GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB, LOC_CUSTOM, TYPE_INT,
413 offsetof(GLcontext, Const.MaxCubeTextureLevels),
414 extra_ARB_texture_cube_map }, /* XXX: OES_texture_cube_map */
415
416 /* XXX: OES_blend_subtract */
417 { GL_BLEND_SRC_RGB_EXT, CONTEXT_ENUM(Color.BlendSrcRGB), NO_EXTRA },
418 { GL_BLEND_DST_RGB_EXT, CONTEXT_ENUM(Color.BlendDstRGB), NO_EXTRA },
419 { GL_BLEND_SRC_ALPHA_EXT, CONTEXT_ENUM(Color.BlendSrcA), NO_EXTRA },
420 { GL_BLEND_DST_ALPHA_EXT, CONTEXT_ENUM(Color.BlendDstA), NO_EXTRA },
421
422 /* GL_BLEND_EQUATION_RGB, which is what we're really after, is
423 * defined identically to GL_BLEND_EQUATION. */
424 { GL_BLEND_EQUATION, CONTEXT_ENUM(Color.BlendEquationRGB), NO_EXTRA },
425 { GL_BLEND_EQUATION_ALPHA_EXT, CONTEXT_ENUM(Color.BlendEquationA), NO_EXTRA },
426
427 /* GL_ARB_texture_compression */
428 { GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB, LOC_CUSTOM, TYPE_INT, 0, NO_EXTRA },
429 { GL_COMPRESSED_TEXTURE_FORMATS_ARB, LOC_CUSTOM, TYPE_INT_N, 0, NO_EXTRA },
430
431 /* GL_ARB_multisample */
432 { GL_SAMPLE_ALPHA_TO_COVERAGE_ARB,
433 CONTEXT_BOOL(Multisample.SampleAlphaToCoverage), NO_EXTRA },
434 { GL_SAMPLE_COVERAGE_ARB, CONTEXT_BOOL(Multisample.SampleCoverage), NO_EXTRA },
435 { GL_SAMPLE_COVERAGE_VALUE_ARB,
436 CONTEXT_FLOAT(Multisample.SampleCoverageValue), NO_EXTRA },
437 { GL_SAMPLE_COVERAGE_INVERT_ARB,
438 CONTEXT_BOOL(Multisample.SampleCoverageInvert), NO_EXTRA },
439 { GL_SAMPLE_BUFFERS_ARB, BUFFER_INT(Visual.sampleBuffers), NO_EXTRA },
440 { GL_SAMPLES_ARB, BUFFER_INT(Visual.samples), NO_EXTRA },
441
442 /* GL_SGIS_generate_mipmap */
443 { GL_GENERATE_MIPMAP_HINT_SGIS, CONTEXT_ENUM(Hint.GenerateMipmap),
444 extra_SGIS_generate_mipmap },
445
446 /* GL_ARB_vertex_buffer_object */
447 { GL_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT, 0, NO_EXTRA },
448
449 /* GL_ARB_vertex_buffer_object */
450 /* GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB - not supported */
451 { GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT, 0,
452 extra_ARB_vertex_buffer_object },
453
454 /* GL_OES_read_format */
455 { GL_IMPLEMENTATION_COLOR_READ_TYPE_OES, LOC_CUSTOM, TYPE_INT, 0,
456 extra_new_buffers_OES_read_format },
457 { GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES, LOC_CUSTOM, TYPE_INT, 0,
458 extra_new_buffers_OES_read_format },
459
460 /* GL_EXT_framebuffer_object */
461 { GL_FRAMEBUFFER_BINDING_EXT, BUFFER_INT(Name),
462 extra_EXT_framebuffer_object },
463 { GL_RENDERBUFFER_BINDING_EXT, LOC_CUSTOM, TYPE_INT, 0,
464 extra_EXT_framebuffer_object },
465 { GL_MAX_RENDERBUFFER_SIZE_EXT, CONTEXT_INT(Const.MaxRenderbufferSize),
466 extra_EXT_framebuffer_object },
467
468 /* This entry isn't spec'ed for GLES 2, but is needed for Mesa's
469 * GLSL: */
470 { GL_MAX_CLIP_PLANES, CONTEXT_INT(Const.MaxClipPlanes), NO_EXTRA },
471
472 #if FEATURE_GL || FEATURE_ES1
473 /* Enums in OpenGL and GLES1 */
474 { 0, 0, TYPE_API_MASK, API_OPENGL_BIT | API_OPENGLES_BIT, NO_EXTRA },
475 { GL_LIGHT0, CONTEXT_BOOL(Light.Light[0].Enabled), NO_EXTRA },
476 { GL_LIGHT1, CONTEXT_BOOL(Light.Light[1].Enabled), NO_EXTRA },
477 { GL_LIGHT2, CONTEXT_BOOL(Light.Light[2].Enabled), NO_EXTRA },
478 { GL_LIGHT3, CONTEXT_BOOL(Light.Light[3].Enabled), NO_EXTRA },
479 { GL_LIGHT4, CONTEXT_BOOL(Light.Light[4].Enabled), NO_EXTRA },
480 { GL_LIGHT5, CONTEXT_BOOL(Light.Light[5].Enabled), NO_EXTRA },
481 { GL_LIGHT6, CONTEXT_BOOL(Light.Light[6].Enabled), NO_EXTRA },
482 { GL_LIGHT7, CONTEXT_BOOL(Light.Light[7].Enabled), NO_EXTRA },
483 { GL_LIGHTING, CONTEXT_BOOL(Light.Enabled), NO_EXTRA },
484 { GL_LIGHT_MODEL_AMBIENT,
485 CONTEXT_FIELD(Light.Model.Ambient[0], TYPE_FLOATN_4), NO_EXTRA },
486 { GL_LIGHT_MODEL_TWO_SIDE, CONTEXT_BOOL(Light.Model.TwoSide), NO_EXTRA },
487 { GL_ALPHA_TEST, CONTEXT_BOOL(Color.AlphaEnabled), NO_EXTRA },
488 { GL_ALPHA_TEST_FUNC, CONTEXT_ENUM(Color.AlphaFunc), NO_EXTRA },
489 { GL_ALPHA_TEST_REF, CONTEXT_FIELD(Color.AlphaRef, TYPE_FLOATN), NO_EXTRA },
490 { GL_BLEND_DST, CONTEXT_ENUM(Color.BlendDstRGB), NO_EXTRA },
491 { GL_CLIP_PLANE0, CONTEXT_BIT0(Transform.ClipPlanesEnabled), NO_EXTRA },
492 { GL_CLIP_PLANE1, CONTEXT_BIT1(Transform.ClipPlanesEnabled), NO_EXTRA },
493 { GL_CLIP_PLANE2, CONTEXT_BIT2(Transform.ClipPlanesEnabled), NO_EXTRA },
494 { GL_CLIP_PLANE3, CONTEXT_BIT3(Transform.ClipPlanesEnabled), NO_EXTRA },
495 { GL_CLIP_PLANE4, CONTEXT_BIT4(Transform.ClipPlanesEnabled), NO_EXTRA },
496 { GL_CLIP_PLANE5, CONTEXT_BIT5(Transform.ClipPlanesEnabled), NO_EXTRA },
497 { GL_COLOR_MATERIAL, CONTEXT_BOOL(Light.ColorMaterialEnabled), NO_EXTRA },
498 { GL_CURRENT_COLOR,
499 CONTEXT_FIELD(Current.Attrib[VERT_ATTRIB_COLOR0][0], TYPE_FLOATN_4),
500 extra_flush_current },
501 { GL_CURRENT_NORMAL,
502 CONTEXT_FIELD(Current.Attrib[VERT_ATTRIB_NORMAL][0], TYPE_FLOATN_3),
503 extra_flush_current },
504 { GL_CURRENT_TEXTURE_COORDS, LOC_CUSTOM, TYPE_FLOAT_4, 0,
505 extra_flush_current_valid_texture_unit },
506 { GL_DISTANCE_ATTENUATION_EXT, CONTEXT_FLOAT3(Point.Params[0]), NO_EXTRA },
507 { GL_FOG, CONTEXT_BOOL(Fog.Enabled), NO_EXTRA },
508 { GL_FOG_COLOR, CONTEXT_FIELD(Fog.Color[0], TYPE_FLOATN_4), NO_EXTRA },
509 { GL_FOG_DENSITY, CONTEXT_FLOAT(Fog.Density), NO_EXTRA },
510 { GL_FOG_END, CONTEXT_FLOAT(Fog.End), NO_EXTRA },
511 { GL_FOG_HINT, CONTEXT_ENUM(Hint.Fog), NO_EXTRA },
512 { GL_FOG_MODE, CONTEXT_ENUM(Fog.Mode), NO_EXTRA },
513 { GL_FOG_START, CONTEXT_FLOAT(Fog.Start), NO_EXTRA },
514 { GL_LINE_SMOOTH, CONTEXT_BOOL(Line.SmoothFlag), NO_EXTRA },
515 { GL_LINE_SMOOTH_HINT, CONTEXT_ENUM(Hint.LineSmooth), NO_EXTRA },
516 { GL_LINE_WIDTH_RANGE, CONTEXT_FLOAT2(Const.MinLineWidthAA), NO_EXTRA },
517 { GL_COLOR_LOGIC_OP, CONTEXT_BOOL(Color.ColorLogicOpEnabled), NO_EXTRA },
518 { GL_LOGIC_OP_MODE, CONTEXT_ENUM(Color.LogicOp), NO_EXTRA },
519 { GL_MATRIX_MODE, CONTEXT_ENUM(Transform.MatrixMode), NO_EXTRA },
520 { GL_MAX_MODELVIEW_STACK_DEPTH, CONST(MAX_MODELVIEW_STACK_DEPTH), NO_EXTRA },
521 { GL_MAX_PROJECTION_STACK_DEPTH, CONST(MAX_PROJECTION_STACK_DEPTH), NO_EXTRA },
522 { GL_MAX_TEXTURE_STACK_DEPTH, CONST(MAX_TEXTURE_STACK_DEPTH), NO_EXTRA },
523 { GL_MODELVIEW_MATRIX, CONTEXT_MATRIX(ModelviewMatrixStack.Top), NO_EXTRA },
524 { GL_MODELVIEW_STACK_DEPTH, LOC_CUSTOM, TYPE_INT,
525 offsetof(GLcontext, ModelviewMatrixStack.Depth), NO_EXTRA },
526 { GL_NORMALIZE, CONTEXT_BOOL(Transform.Normalize), NO_EXTRA },
527 { GL_PACK_SKIP_IMAGES_EXT, CONTEXT_INT(Pack.SkipImages), NO_EXTRA },
528 { GL_PERSPECTIVE_CORRECTION_HINT, CONTEXT_ENUM(Hint.PerspectiveCorrection), NO_EXTRA },
529 { GL_POINT_SIZE, CONTEXT_FLOAT(Point.Size), NO_EXTRA },
530 { GL_POINT_SIZE_RANGE, CONTEXT_FLOAT2(Const.MinPointSizeAA), NO_EXTRA },
531 { GL_POINT_SMOOTH, CONTEXT_BOOL(Point.SmoothFlag), NO_EXTRA },
532 { GL_POINT_SMOOTH_HINT, CONTEXT_ENUM(Hint.PointSmooth), NO_EXTRA },
533 { GL_POINT_SIZE_MIN_EXT, CONTEXT_FLOAT(Point.MinSize), NO_EXTRA },
534 { GL_POINT_SIZE_MAX_EXT, CONTEXT_FLOAT(Point.MaxSize), NO_EXTRA },
535 { GL_POINT_FADE_THRESHOLD_SIZE_EXT, CONTEXT_FLOAT(Point.Threshold), NO_EXTRA },
536 { GL_PROJECTION_MATRIX, CONTEXT_MATRIX(ProjectionMatrixStack.Top), NO_EXTRA },
537 { GL_PROJECTION_STACK_DEPTH, LOC_CUSTOM, TYPE_INT,
538 offsetof(GLcontext, ProjectionMatrixStack.Depth), NO_EXTRA },
539 { GL_RESCALE_NORMAL, CONTEXT_BOOL(Transform.RescaleNormals), NO_EXTRA },
540 { GL_SHADE_MODEL, CONTEXT_ENUM(Light.ShadeModel), NO_EXTRA },
541 { GL_TEXTURE_2D, LOC_CUSTOM, TYPE_BOOLEAN, 0, NO_EXTRA },
542 { GL_TEXTURE_MATRIX, LOC_CUSTOM, TYPE_MATRIX, 0, extra_valid_texture_unit },
543 { GL_TEXTURE_STACK_DEPTH, LOC_CUSTOM, TYPE_INT, 0,
544 extra_valid_texture_unit },
545
546 { GL_VERTEX_ARRAY, ARRAY_BOOL(Vertex.Enabled), NO_EXTRA },
547 { GL_VERTEX_ARRAY_SIZE, ARRAY_INT(Vertex.Size), NO_EXTRA },
548 { GL_VERTEX_ARRAY_TYPE, ARRAY_ENUM(Vertex.Type), NO_EXTRA },
549 { GL_VERTEX_ARRAY_STRIDE, ARRAY_INT(Vertex.Stride), NO_EXTRA },
550 { GL_NORMAL_ARRAY, ARRAY_ENUM(Normal.Enabled), NO_EXTRA },
551 { GL_NORMAL_ARRAY_TYPE, ARRAY_ENUM(Normal.Type), NO_EXTRA },
552 { GL_NORMAL_ARRAY_STRIDE, ARRAY_INT(Normal.Stride), NO_EXTRA },
553 { GL_COLOR_ARRAY, ARRAY_BOOL(Color.Enabled), NO_EXTRA },
554 { GL_COLOR_ARRAY_SIZE, ARRAY_INT(Color.Size), NO_EXTRA },
555 { GL_COLOR_ARRAY_TYPE, ARRAY_ENUM(Color.Type), NO_EXTRA },
556 { GL_COLOR_ARRAY_STRIDE, ARRAY_INT(Color.Stride), NO_EXTRA },
557 { GL_TEXTURE_COORD_ARRAY,
558 LOC_CUSTOM, TYPE_BOOLEAN, offsetof(struct gl_client_array, Enabled), NO_EXTRA },
559 { GL_TEXTURE_COORD_ARRAY_SIZE,
560 LOC_CUSTOM, TYPE_BOOLEAN, offsetof(struct gl_client_array, Size), NO_EXTRA },
561 { GL_TEXTURE_COORD_ARRAY_TYPE,
562 LOC_CUSTOM, TYPE_BOOLEAN, offsetof(struct gl_client_array, Type), NO_EXTRA },
563 { GL_TEXTURE_COORD_ARRAY_STRIDE,
564 LOC_CUSTOM, TYPE_BOOLEAN, offsetof(struct gl_client_array, Stride), NO_EXTRA },
565
566 /* GL_ARB_multitexture */
567 { GL_MAX_TEXTURE_UNITS_ARB,
568 CONTEXT_INT(Const.MaxTextureUnits), extra_ARB_multitexture },
569 { GL_CLIENT_ACTIVE_TEXTURE_ARB,
570 LOC_CUSTOM, TYPE_INT, 0, extra_ARB_multitexture },
571
572 /* GL_ARB_texture_cube_map */
573 { GL_TEXTURE_CUBE_MAP_ARB, LOC_CUSTOM, TYPE_BOOLEAN, 0, NO_EXTRA },
574 /* S, T, and R are always set at the same time */
575 { GL_TEXTURE_GEN_STR_OES, LOC_TEXUNIT, TYPE_BIT_0,
576 offsetof(struct gl_texture_unit, TexGenEnabled), NO_EXTRA },
577
578 /* GL_ARB_multisample */
579 { GL_MULTISAMPLE_ARB, CONTEXT_BOOL(Multisample.Enabled), NO_EXTRA },
580 { GL_SAMPLE_ALPHA_TO_ONE_ARB, CONTEXT_BOOL(Multisample.SampleAlphaToOne), NO_EXTRA },
581
582 /* GL_ARB_vertex_buffer_object */
583 { GL_VERTEX_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT,
584 offsetof(struct gl_array_object, Vertex.BufferObj), NO_EXTRA },
585 { GL_NORMAL_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT,
586 offsetof(struct gl_array_object, Normal.BufferObj), NO_EXTRA },
587 { GL_COLOR_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT,
588 offsetof(struct gl_array_object, Color.BufferObj), NO_EXTRA },
589 { GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT, NO_OFFSET, NO_EXTRA },
590
591 /* GL_OES_point_sprite */
592 { GL_POINT_SPRITE_NV,
593 CONTEXT_BOOL(Point.PointSprite),
594 extra_NV_point_sprite_ARB_point_sprite },
595
596 /* GL_ARB_fragment_shader */
597 { GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB,
598 CONTEXT_INT(Const.FragmentProgram.MaxUniformComponents),
599 extra_ARB_fragment_shader },
600
601 /* GL_ARB_vertex_shader */
602 { GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB,
603 CONTEXT_INT(Const.VertexProgram.MaxUniformComponents),
604 extra_ARB_vertex_shader },
605 { GL_MAX_VARYING_FLOATS_ARB, LOC_CUSTOM, TYPE_INT, 0,
606 extra_ARB_vertex_shader },
607
608 /* GL_EXT_texture_lod_bias */
609 { GL_MAX_TEXTURE_LOD_BIAS_EXT, CONTEXT_FLOAT(Const.MaxTextureLodBias),
610 extra_EXT_texture_lod_bias },
611
612 /* GL_EXT_texture_filter_anisotropic */
613 { GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT,
614 CONTEXT_FLOAT(Const.MaxTextureMaxAnisotropy),
615 extra_EXT_texture_filter_anisotropic },
616 #endif /* FEATURE_GL || FEATURE_ES1 */
617
618 #if FEATURE_ES1
619 { 0, 0, TYPE_API_MASK, API_OPENGLES_BIT },
620 /* XXX: OES_matrix_get */
621 { GL_MODELVIEW_MATRIX_FLOAT_AS_INT_BITS_OES },
622 { GL_PROJECTION_MATRIX_FLOAT_AS_INT_BITS_OES },
623 { GL_TEXTURE_MATRIX_FLOAT_AS_INT_BITS_OES },
624
625 /* OES_point_size_array */
626 { GL_POINT_SIZE_ARRAY_OES, ARRAY_FIELD(PointSize.Enabled, TYPE_BOOLEAN) },
627 { GL_POINT_SIZE_ARRAY_TYPE_OES, ARRAY_FIELD(PointSize.Type, TYPE_ENUM) },
628 { GL_POINT_SIZE_ARRAY_STRIDE_OES, ARRAY_FIELD(PointSize.Stride, TYPE_INT) },
629 { GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES, LOC_CUSTOM, TYPE_INT, 0 },
630 #endif /* FEATURE_ES1 */
631
632 #if FEATURE_GL || FEATURE_ES2
633 { 0, 0, TYPE_API_MASK, API_OPENGL_BIT | API_OPENGLES2_BIT, NO_EXTRA },
634 /* This entry isn't spec'ed for GLES 2, but is needed for Mesa's GLSL: */
635 { GL_MAX_LIGHTS, CONTEXT_INT(Const.MaxLights), NO_EXTRA },
636 { GL_MAX_TEXTURE_COORDS_ARB, /* == GL_MAX_TEXTURE_COORDS_NV */
637 CONTEXT_INT(Const.MaxTextureCoordUnits),
638 extra_ARB_fragment_program_NV_fragment_program },
639
640 /* GL_ARB_draw_buffers */
641 { GL_MAX_DRAW_BUFFERS_ARB, CONTEXT_INT(Const.MaxDrawBuffers), NO_EXTRA },
642
643 { GL_BLEND_COLOR_EXT, CONTEXT_FIELD(Color.BlendColor[0], TYPE_FLOATN_4), NO_EXTRA },
644 /* GL_ARB_fragment_program */
645 { GL_MAX_TEXTURE_IMAGE_UNITS_ARB, /* == GL_MAX_TEXTURE_IMAGE_UNITS_NV */
646 CONTEXT_INT(Const.MaxTextureImageUnits),
647 extra_ARB_fragment_program_NV_fragment_program },
648 { GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB,
649 CONTEXT_INT(Const.MaxVertexTextureImageUnits), extra_ARB_vertex_shader },
650 { GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB,
651 CONTEXT_INT(Const.MaxCombinedTextureImageUnits),
652 extra_ARB_vertex_shader },
653
654 /* GL_ARB_shader_objects
655 * Actually, this token isn't part of GL_ARB_shader_objects, but is
656 * close enough for now. */
657 { GL_CURRENT_PROGRAM, LOC_CUSTOM, TYPE_INT, 0, extra_ARB_shader_objects },
658
659 /* OpenGL 2.0 */
660 { GL_STENCIL_BACK_FUNC, CONTEXT_ENUM(Stencil.Function[1]), NO_EXTRA },
661 { GL_STENCIL_BACK_VALUE_MASK, CONTEXT_INT(Stencil.ValueMask[1]), NO_EXTRA },
662 { GL_STENCIL_BACK_WRITEMASK, CONTEXT_INT(Stencil.WriteMask[1]), NO_EXTRA },
663 { GL_STENCIL_BACK_REF, CONTEXT_INT(Stencil.Ref[1]), NO_EXTRA },
664 { GL_STENCIL_BACK_FAIL, CONTEXT_ENUM(Stencil.FailFunc[1]), NO_EXTRA },
665 { GL_STENCIL_BACK_PASS_DEPTH_FAIL, CONTEXT_ENUM(Stencil.ZFailFunc[1]), NO_EXTRA },
666 { GL_STENCIL_BACK_PASS_DEPTH_PASS, CONTEXT_ENUM(Stencil.ZPassFunc[1]), NO_EXTRA },
667
668 { GL_MAX_VERTEX_ATTRIBS_ARB,
669 CONTEXT_INT(Const.VertexProgram.MaxAttribs),
670 extra_ARB_vertex_program_version_es2 },
671
672 /* OES_texture_3D */
673 { GL_TEXTURE_BINDING_3D, LOC_CUSTOM, TYPE_INT, TEXTURE_3D_INDEX, NO_EXTRA },
674 { GL_MAX_3D_TEXTURE_SIZE, LOC_CUSTOM, TYPE_INT,
675 offsetof(GLcontext, Const.Max3DTextureLevels), NO_EXTRA },
676
677 /* GL_ARB_fragment_program/OES_standard_derivatives */
678 { GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB,
679 CONTEXT_ENUM(Hint.FragmentShaderDerivative), extra_ARB_fragment_shader },
680 #endif /* FEATURE_GL || FEATURE_ES2 */
681
682 #if FEATURE_ES2
683 /* Enums unique to OpenGL ES 2.0 */
684 { 0, 0, TYPE_API_MASK, API_OPENGLES2_BIT, NO_EXTRA },
685 { GL_MAX_FRAGMENT_UNIFORM_VECTORS, LOC_CUSTOM, TYPE_INT,
686 offsetof(GLcontext, Const.FragmentProgram.MaxUniformComponents), NO_EXTRA },
687 { GL_MAX_VARYING_VECTORS, LOC_CUSTOM, TYPE_INT,
688 offsetof(GLcontext, Const.MaxVarying), NO_EXTRA },
689 { GL_MAX_VERTEX_UNIFORM_VECTORS, LOC_CUSTOM, TYPE_INT,
690 offsetof(GLcontext, Const.VertexProgram.MaxUniformComponents), NO_EXTRA },
691 { GL_SHADER_COMPILER, CONST(1), NO_EXTRA },
692 /* OES_get_program_binary */
693 { GL_NUM_SHADER_BINARY_FORMATS, CONST(0), NO_EXTRA },
694 { GL_SHADER_BINARY_FORMATS, CONST(0), NO_EXTRA },
695 #endif /* FEATURE_ES2 */
696
697 #if FEATURE_GL
698 /* Remaining enums are only in OpenGL */
699 { 0, 0, TYPE_API_MASK, API_OPENGL_BIT, NO_EXTRA },
700 { GL_ACCUM_RED_BITS, BUFFER_INT(Visual.accumRedBits), NO_EXTRA },
701 { GL_ACCUM_GREEN_BITS, BUFFER_INT(Visual.accumGreenBits), NO_EXTRA },
702 { GL_ACCUM_BLUE_BITS, BUFFER_INT(Visual.accumBlueBits), NO_EXTRA },
703 { GL_ACCUM_ALPHA_BITS, BUFFER_INT(Visual.accumAlphaBits), NO_EXTRA },
704 { GL_ACCUM_CLEAR_VALUE, CONTEXT_FIELD(Accum.ClearColor[0], TYPE_FLOATN_4), NO_EXTRA },
705 { GL_ALPHA_BIAS, CONTEXT_FLOAT(Pixel.AlphaBias), NO_EXTRA },
706 { GL_ALPHA_SCALE, CONTEXT_FLOAT(Pixel.AlphaScale), NO_EXTRA },
707 { GL_ATTRIB_STACK_DEPTH, CONTEXT_INT(AttribStackDepth), NO_EXTRA },
708 { GL_AUTO_NORMAL, CONTEXT_BOOL(Eval.AutoNormal), NO_EXTRA },
709 { GL_AUX_BUFFERS, BUFFER_INT(Visual.numAuxBuffers), NO_EXTRA },
710 { GL_BLUE_BIAS, CONTEXT_FLOAT(Pixel.BlueBias), NO_EXTRA },
711 { GL_BLUE_SCALE, CONTEXT_FLOAT(Pixel.BlueScale), NO_EXTRA },
712 { GL_CLIENT_ATTRIB_STACK_DEPTH, CONTEXT_INT(ClientAttribStackDepth), NO_EXTRA },
713 { GL_COLOR_MATERIAL_FACE, CONTEXT_ENUM(Light.ColorMaterialFace), NO_EXTRA },
714 { GL_COLOR_MATERIAL_PARAMETER, CONTEXT_ENUM(Light.ColorMaterialMode), NO_EXTRA },
715 { GL_CURRENT_INDEX,
716 CONTEXT_FLOAT(Current.Attrib[VERT_ATTRIB_COLOR_INDEX][0]),
717 extra_flush_current },
718 { GL_CURRENT_RASTER_COLOR,
719 CONTEXT_FIELD(Current.RasterColor[0], TYPE_FLOATN_4), NO_EXTRA },
720 { GL_CURRENT_RASTER_DISTANCE, CONTEXT_FLOAT(Current.RasterDistance), NO_EXTRA },
721 { GL_CURRENT_RASTER_INDEX, CONST(1), NO_EXTRA },
722 { GL_CURRENT_RASTER_POSITION, CONTEXT_FLOAT4(Current.RasterPos[0]), NO_EXTRA },
723 { GL_CURRENT_RASTER_SECONDARY_COLOR,
724 CONTEXT_FIELD(Current.RasterSecondaryColor[0], TYPE_FLOATN_4), NO_EXTRA },
725 { GL_CURRENT_RASTER_TEXTURE_COORDS, LOC_CUSTOM, TYPE_FLOAT_4, 0,
726 extra_valid_texture_unit },
727 { GL_CURRENT_RASTER_POSITION_VALID, CONTEXT_BOOL(Current.RasterPosValid), NO_EXTRA },
728 { GL_DEPTH_BIAS, CONTEXT_FLOAT(Pixel.DepthBias), NO_EXTRA },
729 { GL_DEPTH_SCALE, CONTEXT_FLOAT(Pixel.DepthScale), NO_EXTRA },
730 { GL_DOUBLEBUFFER, BUFFER_INT(Visual.doubleBufferMode), NO_EXTRA },
731 { GL_DRAW_BUFFER, BUFFER_ENUM(ColorDrawBuffer[0]), NO_EXTRA },
732 { GL_EDGE_FLAG, LOC_CUSTOM, TYPE_BOOLEAN, 0, NO_EXTRA },
733 { GL_FEEDBACK_BUFFER_SIZE, CONTEXT_INT(Feedback.BufferSize), NO_EXTRA },
734 { GL_FEEDBACK_BUFFER_TYPE, CONTEXT_ENUM(Feedback.Type), NO_EXTRA },
735 { GL_FOG_INDEX, CONTEXT_FLOAT(Fog.Index), NO_EXTRA },
736 { GL_GREEN_BIAS, CONTEXT_FLOAT(Pixel.GreenBias), NO_EXTRA },
737 { GL_GREEN_SCALE, CONTEXT_FLOAT(Pixel.GreenScale), NO_EXTRA },
738 { GL_INDEX_BITS, BUFFER_INT(Visual.indexBits), extra_new_buffers },
739 { GL_INDEX_CLEAR_VALUE, CONTEXT_INT(Color.ClearIndex), NO_EXTRA },
740 { GL_INDEX_MODE, CONST(0) , NO_EXTRA},
741 { GL_INDEX_OFFSET, CONTEXT_INT(Pixel.IndexOffset), NO_EXTRA },
742 { GL_INDEX_SHIFT, CONTEXT_INT(Pixel.IndexShift), NO_EXTRA },
743 { GL_INDEX_WRITEMASK, CONTEXT_INT(Color.IndexMask), NO_EXTRA },
744 { GL_LIGHT_MODEL_COLOR_CONTROL, CONTEXT_ENUM(Light.Model.ColorControl), NO_EXTRA },
745 { GL_LIGHT_MODEL_LOCAL_VIEWER, CONTEXT_BOOL(Light.Model.LocalViewer), NO_EXTRA },
746 { GL_LINE_STIPPLE, CONTEXT_BOOL(Line.StippleFlag), NO_EXTRA },
747 { GL_LINE_STIPPLE_PATTERN, LOC_CUSTOM, TYPE_INT, 0, NO_EXTRA },
748 { GL_LINE_STIPPLE_REPEAT, CONTEXT_INT(Line.StippleFactor), NO_EXTRA },
749 { GL_LINE_WIDTH_GRANULARITY, CONTEXT_FLOAT(Const.LineWidthGranularity), NO_EXTRA },
750 { GL_LIST_BASE, CONTEXT_INT(List.ListBase), NO_EXTRA },
751 { GL_LIST_INDEX, LOC_CUSTOM, TYPE_INT, 0, NO_EXTRA },
752 { GL_LIST_MODE, LOC_CUSTOM, TYPE_ENUM, 0, NO_EXTRA },
753 { GL_INDEX_LOGIC_OP, CONTEXT_BOOL(Color.IndexLogicOpEnabled), NO_EXTRA },
754 { GL_MAP1_COLOR_4, CONTEXT_BOOL(Eval.Map1Color4), NO_EXTRA },
755 { GL_MAP1_GRID_DOMAIN, CONTEXT_FLOAT2(Eval.MapGrid1u1), NO_EXTRA },
756 { GL_MAP1_GRID_SEGMENTS, CONTEXT_INT(Eval.MapGrid1un), NO_EXTRA },
757 { GL_MAP1_INDEX, CONTEXT_BOOL(Eval.Map1Index), NO_EXTRA },
758 { GL_MAP1_NORMAL, CONTEXT_BOOL(Eval.Map1Normal), NO_EXTRA },
759 { GL_MAP1_TEXTURE_COORD_1, CONTEXT_BOOL(Eval.Map1TextureCoord1), NO_EXTRA },
760 { GL_MAP1_TEXTURE_COORD_2, CONTEXT_BOOL(Eval.Map1TextureCoord2), NO_EXTRA },
761 { GL_MAP1_TEXTURE_COORD_3, CONTEXT_BOOL(Eval.Map1TextureCoord3), NO_EXTRA },
762 { GL_MAP1_TEXTURE_COORD_4, CONTEXT_BOOL(Eval.Map1TextureCoord4), NO_EXTRA },
763 { GL_MAP1_VERTEX_3, CONTEXT_BOOL(Eval.Map1Vertex3), NO_EXTRA },
764 { GL_MAP1_VERTEX_4, CONTEXT_BOOL(Eval.Map1Vertex4), NO_EXTRA },
765 { GL_MAP2_COLOR_4, CONTEXT_BOOL(Eval.Map2Color4), NO_EXTRA },
766 { GL_MAP2_GRID_DOMAIN, LOC_CUSTOM, TYPE_FLOAT_4, 0, NO_EXTRA },
767 { GL_MAP2_GRID_SEGMENTS, CONTEXT_INT2(Eval.MapGrid2un), NO_EXTRA },
768 { GL_MAP2_INDEX, CONTEXT_BOOL(Eval.Map2Index), NO_EXTRA },
769 { GL_MAP2_NORMAL, CONTEXT_BOOL(Eval.Map2Normal), NO_EXTRA },
770 { GL_MAP2_TEXTURE_COORD_1, CONTEXT_BOOL(Eval.Map2TextureCoord1), NO_EXTRA },
771 { GL_MAP2_TEXTURE_COORD_2, CONTEXT_BOOL(Eval.Map2TextureCoord2), NO_EXTRA },
772 { GL_MAP2_TEXTURE_COORD_3, CONTEXT_BOOL(Eval.Map2TextureCoord3), NO_EXTRA },
773 { GL_MAP2_TEXTURE_COORD_4, CONTEXT_BOOL(Eval.Map2TextureCoord4), NO_EXTRA },
774 { GL_MAP2_VERTEX_3, CONTEXT_BOOL(Eval.Map2Vertex3), NO_EXTRA },
775 { GL_MAP2_VERTEX_4, CONTEXT_BOOL(Eval.Map2Vertex4), NO_EXTRA },
776 { GL_MAP_COLOR, CONTEXT_BOOL(Pixel.MapColorFlag), NO_EXTRA },
777 { GL_MAP_STENCIL, CONTEXT_BOOL(Pixel.MapStencilFlag), NO_EXTRA },
778 { GL_MAX_ATTRIB_STACK_DEPTH, CONST(MAX_ATTRIB_STACK_DEPTH), NO_EXTRA },
779 { GL_MAX_CLIENT_ATTRIB_STACK_DEPTH, CONST(MAX_CLIENT_ATTRIB_STACK_DEPTH), NO_EXTRA },
780
781 { GL_MAX_EVAL_ORDER, CONST(MAX_EVAL_ORDER), NO_EXTRA },
782 { GL_MAX_LIST_NESTING, CONST(MAX_LIST_NESTING), NO_EXTRA },
783 { GL_MAX_NAME_STACK_DEPTH, CONST(MAX_NAME_STACK_DEPTH), NO_EXTRA },
784 { GL_MAX_PIXEL_MAP_TABLE, CONST(MAX_PIXEL_MAP_TABLE), NO_EXTRA },
785 { GL_NAME_STACK_DEPTH, CONTEXT_INT(Select.NameStackDepth), NO_EXTRA },
786 { GL_PACK_LSB_FIRST, CONTEXT_BOOL(Pack.LsbFirst), NO_EXTRA },
787 { GL_PACK_ROW_LENGTH, CONTEXT_INT(Pack.RowLength), NO_EXTRA },
788 { GL_PACK_SKIP_PIXELS, CONTEXT_INT(Pack.SkipPixels), NO_EXTRA },
789 { GL_PACK_SKIP_ROWS, CONTEXT_INT(Pack.SkipRows), NO_EXTRA },
790 { GL_PACK_SWAP_BYTES, CONTEXT_BOOL(Pack.SwapBytes), NO_EXTRA },
791 { GL_PACK_IMAGE_HEIGHT_EXT, CONTEXT_INT(Pack.ImageHeight), NO_EXTRA },
792 { GL_PACK_INVERT_MESA, CONTEXT_BOOL(Pack.Invert), NO_EXTRA },
793 { GL_PIXEL_MAP_A_TO_A_SIZE, CONTEXT_INT(PixelMaps.AtoA.Size), NO_EXTRA },
794 { GL_PIXEL_MAP_B_TO_B_SIZE, CONTEXT_INT(PixelMaps.BtoB.Size), NO_EXTRA },
795 { GL_PIXEL_MAP_G_TO_G_SIZE, CONTEXT_INT(PixelMaps.GtoG.Size), NO_EXTRA },
796 { GL_PIXEL_MAP_I_TO_A_SIZE, CONTEXT_INT(PixelMaps.ItoA.Size), NO_EXTRA },
797 { GL_PIXEL_MAP_I_TO_B_SIZE, CONTEXT_INT(PixelMaps.ItoB.Size), NO_EXTRA },
798 { GL_PIXEL_MAP_I_TO_G_SIZE, CONTEXT_INT(PixelMaps.ItoG.Size), NO_EXTRA },
799 { GL_PIXEL_MAP_I_TO_I_SIZE, CONTEXT_INT(PixelMaps.ItoI.Size), NO_EXTRA },
800 { GL_PIXEL_MAP_I_TO_R_SIZE, CONTEXT_INT(PixelMaps.ItoR.Size), NO_EXTRA },
801 { GL_PIXEL_MAP_R_TO_R_SIZE, CONTEXT_INT(PixelMaps.RtoR.Size), NO_EXTRA },
802 { GL_PIXEL_MAP_S_TO_S_SIZE, CONTEXT_INT(PixelMaps.StoS.Size), NO_EXTRA },
803 { GL_POINT_SIZE_GRANULARITY, CONTEXT_FLOAT(Const.PointSizeGranularity), NO_EXTRA },
804 { GL_POLYGON_MODE, CONTEXT_ENUM2(Polygon.FrontMode), NO_EXTRA },
805 { GL_POLYGON_OFFSET_BIAS_EXT, CONTEXT_FLOAT(Polygon.OffsetUnits), NO_EXTRA },
806 { GL_POLYGON_OFFSET_POINT, CONTEXT_BOOL(Polygon.OffsetPoint), NO_EXTRA },
807 { GL_POLYGON_OFFSET_LINE, CONTEXT_BOOL(Polygon.OffsetLine), NO_EXTRA },
808 { GL_POLYGON_SMOOTH, CONTEXT_BOOL(Polygon.SmoothFlag), NO_EXTRA },
809 { GL_POLYGON_SMOOTH_HINT, CONTEXT_ENUM(Hint.PolygonSmooth), NO_EXTRA },
810 { GL_POLYGON_STIPPLE, CONTEXT_BOOL(Polygon.StippleFlag), NO_EXTRA },
811 { GL_READ_BUFFER, LOC_CUSTOM, TYPE_ENUM, NO_OFFSET, NO_EXTRA },
812 { GL_RED_BIAS, CONTEXT_FLOAT(Pixel.RedBias), NO_EXTRA },
813 { GL_RED_SCALE, CONTEXT_FLOAT(Pixel.RedScale), NO_EXTRA },
814 { GL_RENDER_MODE, CONTEXT_ENUM(RenderMode), NO_EXTRA },
815 { GL_RGBA_MODE, CONST(1), NO_EXTRA },
816 { GL_SELECTION_BUFFER_SIZE, CONTEXT_INT(Select.BufferSize), NO_EXTRA },
817 { GL_SHARED_TEXTURE_PALETTE_EXT, CONTEXT_BOOL(Texture.SharedPalette), NO_EXTRA },
818
819 { GL_STEREO, BUFFER_INT(Visual.stereoMode), NO_EXTRA },
820
821 { GL_TEXTURE_1D, LOC_CUSTOM, TYPE_BOOLEAN, NO_OFFSET, NO_EXTRA },
822 { GL_TEXTURE_3D, LOC_CUSTOM, TYPE_BOOLEAN, NO_OFFSET, NO_EXTRA },
823 { GL_TEXTURE_1D_ARRAY_EXT, LOC_CUSTOM, TYPE_BOOLEAN, NO_OFFSET, NO_EXTRA },
824 { GL_TEXTURE_2D_ARRAY_EXT, LOC_CUSTOM, TYPE_BOOLEAN, NO_OFFSET, NO_EXTRA },
825
826 { GL_TEXTURE_BINDING_1D, LOC_CUSTOM, TYPE_INT, TEXTURE_1D_INDEX, NO_EXTRA },
827 { GL_TEXTURE_BINDING_1D_ARRAY, LOC_CUSTOM, TYPE_INT,
828 TEXTURE_1D_ARRAY_INDEX, extra_MESA_texture_array },
829 { GL_TEXTURE_BINDING_2D_ARRAY, LOC_CUSTOM, TYPE_INT,
830 TEXTURE_1D_ARRAY_INDEX, extra_MESA_texture_array },
831 { GL_MAX_ARRAY_TEXTURE_LAYERS_EXT,
832 CONTEXT_INT(Const.MaxArrayTextureLayers), extra_MESA_texture_array },
833
834 { GL_TEXTURE_GEN_S, LOC_TEXUNIT, TYPE_BIT_0,
835 offsetof(struct gl_texture_unit, TexGenEnabled), NO_EXTRA },
836 { GL_TEXTURE_GEN_T, LOC_TEXUNIT, TYPE_BIT_1,
837 offsetof(struct gl_texture_unit, TexGenEnabled), NO_EXTRA },
838 { GL_TEXTURE_GEN_R, LOC_TEXUNIT, TYPE_BIT_2,
839 offsetof(struct gl_texture_unit, TexGenEnabled), NO_EXTRA },
840 { GL_TEXTURE_GEN_Q, LOC_TEXUNIT, TYPE_BIT_3,
841 offsetof(struct gl_texture_unit, TexGenEnabled), NO_EXTRA },
842 { GL_UNPACK_LSB_FIRST, CONTEXT_BOOL(Unpack.LsbFirst), NO_EXTRA },
843 { GL_UNPACK_ROW_LENGTH, CONTEXT_INT(Unpack.RowLength), NO_EXTRA },
844 { GL_UNPACK_SKIP_PIXELS, CONTEXT_INT(Unpack.SkipPixels), NO_EXTRA },
845 { GL_UNPACK_SKIP_ROWS, CONTEXT_INT(Unpack.SkipRows), NO_EXTRA },
846 { GL_UNPACK_SWAP_BYTES, CONTEXT_BOOL(Unpack.SwapBytes), NO_EXTRA },
847 { GL_UNPACK_SKIP_IMAGES_EXT, CONTEXT_INT(Unpack.SkipImages), NO_EXTRA },
848 { GL_UNPACK_IMAGE_HEIGHT_EXT, CONTEXT_INT(Unpack.ImageHeight), NO_EXTRA },
849 { GL_UNPACK_CLIENT_STORAGE_APPLE, CONTEXT_BOOL(Unpack.ClientStorage), NO_EXTRA },
850 { GL_ZOOM_X, CONTEXT_FLOAT(Pixel.ZoomX), NO_EXTRA },
851 { GL_ZOOM_Y, CONTEXT_FLOAT(Pixel.ZoomY), NO_EXTRA },
852
853 /* Vertex arrays */
854 { GL_VERTEX_ARRAY_COUNT_EXT, CONST(0), NO_EXTRA },
855 { GL_NORMAL_ARRAY_COUNT_EXT, CONST(0), NO_EXTRA },
856 { GL_COLOR_ARRAY_COUNT_EXT, CONST(0), NO_EXTRA },
857 { GL_INDEX_ARRAY, ARRAY_BOOL(Index.Enabled), NO_EXTRA },
858 { GL_INDEX_ARRAY_TYPE, ARRAY_ENUM(Index.Type), NO_EXTRA },
859 { GL_INDEX_ARRAY_STRIDE, ARRAY_INT(Index.Stride), NO_EXTRA },
860 { GL_INDEX_ARRAY_COUNT_EXT, CONST(0), NO_EXTRA },
861 { GL_TEXTURE_COORD_ARRAY_COUNT_EXT, CONST(0), NO_EXTRA },
862 { GL_EDGE_FLAG_ARRAY, ARRAY_BOOL(EdgeFlag.Enabled), NO_EXTRA },
863 { GL_EDGE_FLAG_ARRAY_STRIDE, ARRAY_INT(EdgeFlag.Stride), NO_EXTRA },
864 { GL_EDGE_FLAG_ARRAY_COUNT_EXT, CONST(0), NO_EXTRA },
865
866 /* GL_ARB_texture_compression */
867 { GL_TEXTURE_COMPRESSION_HINT_ARB, CONTEXT_INT(Hint.TextureCompression), NO_EXTRA },
868
869 /* GL_EXT_compiled_vertex_array */
870 { GL_ARRAY_ELEMENT_LOCK_FIRST_EXT, CONTEXT_INT(Array.LockFirst),
871 extra_EXT_compiled_vertex_array },
872 { GL_ARRAY_ELEMENT_LOCK_COUNT_EXT, CONTEXT_INT(Array.LockCount),
873 extra_EXT_compiled_vertex_array },
874
875 /* GL_ARB_transpose_matrix */
876 { GL_TRANSPOSE_MODELVIEW_MATRIX_ARB,
877 CONTEXT_MATRIX_T(ModelviewMatrixStack), NO_EXTRA },
878 { GL_TRANSPOSE_PROJECTION_MATRIX_ARB,
879 CONTEXT_MATRIX_T(ProjectionMatrixStack.Top), NO_EXTRA },
880 { GL_TRANSPOSE_TEXTURE_MATRIX_ARB, CONTEXT_MATRIX_T(TextureMatrixStack), NO_EXTRA },
881
882 /* GL_SGI_texture_color_table */
883 { GL_TEXTURE_COLOR_TABLE_SGI, LOC_TEXUNIT, TYPE_BOOLEAN,
884 offsetof(struct gl_texture_unit, ColorTableEnabled),
885 extra_SGI_texture_color_table },
886
887 /* GL_EXT_secondary_color */
888 { GL_COLOR_SUM_EXT, CONTEXT_BOOL(Fog.ColorSumEnabled),
889 extra_EXT_secondary_color_ARB_vertex_program },
890 { GL_CURRENT_SECONDARY_COLOR_EXT,
891 CONTEXT_FIELD(Current.Attrib[VERT_ATTRIB_COLOR1][0], TYPE_FLOATN_4),
892 extra_EXT_secondary_color_flush_current },
893 { GL_SECONDARY_COLOR_ARRAY_EXT, ARRAY_BOOL(SecondaryColor.Enabled),
894 extra_EXT_secondary_color },
895 { GL_SECONDARY_COLOR_ARRAY_TYPE_EXT, ARRAY_ENUM(SecondaryColor.Type),
896 extra_EXT_secondary_color },
897 { GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT, ARRAY_INT(SecondaryColor.Stride),
898 extra_EXT_secondary_color },
899 { GL_SECONDARY_COLOR_ARRAY_SIZE_EXT, ARRAY_INT(SecondaryColor.Size),
900 extra_EXT_secondary_color },
901
902 /* GL_EXT_fog_coord */
903 { GL_CURRENT_FOG_COORDINATE_EXT,
904 CONTEXT_FLOAT(Current.Attrib[VERT_ATTRIB_FOG][0]),
905 extra_EXT_fog_coord_flush_current },
906 { GL_FOG_COORDINATE_ARRAY_EXT, ARRAY_BOOL(FogCoord.Enabled),
907 extra_EXT_fog_coord },
908 { GL_FOG_COORDINATE_ARRAY_TYPE_EXT, ARRAY_ENUM(FogCoord.Type),
909 extra_EXT_fog_coord },
910 { GL_FOG_COORDINATE_ARRAY_STRIDE_EXT, ARRAY_INT(FogCoord.Stride),
911 extra_EXT_fog_coord },
912 { GL_FOG_COORDINATE_SOURCE_EXT, CONTEXT_ENUM(Fog.FogCoordinateSource),
913 extra_EXT_fog_coord },
914
915 /* GL_IBM_rasterpos_clip */
916 { GL_RASTER_POSITION_UNCLIPPED_IBM,
917 CONTEXT_BOOL(Transform.RasterPositionUnclipped),
918 extra_IBM_rasterpos_clip },
919
920 /* GL_NV_point_sprite */
921 { GL_POINT_SPRITE_R_MODE_NV,
922 CONTEXT_ENUM(Point.SpriteRMode), extra_NV_point_sprite },
923 { GL_POINT_SPRITE_COORD_ORIGIN, CONTEXT_ENUM(Point.SpriteOrigin),
924 extra_NV_point_sprite_ARB_point_sprite },
925
926 /* GL_NV_vertex_program */
927 { GL_VERTEX_PROGRAM_BINDING_NV, LOC_CUSTOM, TYPE_INT, 0,
928 extra_NV_vertex_program },
929 { GL_VERTEX_ATTRIB_ARRAY0_NV, ARRAY_BOOL(VertexAttrib[0].Enabled),
930 extra_NV_vertex_program },
931 { GL_VERTEX_ATTRIB_ARRAY1_NV, ARRAY_BOOL(VertexAttrib[1].Enabled),
932 extra_NV_vertex_program },
933 { GL_VERTEX_ATTRIB_ARRAY2_NV, ARRAY_BOOL(VertexAttrib[2].Enabled),
934 extra_NV_vertex_program },
935 { GL_VERTEX_ATTRIB_ARRAY3_NV, ARRAY_BOOL(VertexAttrib[3].Enabled),
936 extra_NV_vertex_program },
937 { GL_VERTEX_ATTRIB_ARRAY4_NV, ARRAY_BOOL(VertexAttrib[4].Enabled),
938 extra_NV_vertex_program },
939 { GL_VERTEX_ATTRIB_ARRAY5_NV, ARRAY_BOOL(VertexAttrib[5].Enabled),
940 extra_NV_vertex_program },
941 { GL_VERTEX_ATTRIB_ARRAY6_NV, ARRAY_BOOL(VertexAttrib[6].Enabled),
942 extra_NV_vertex_program },
943 { GL_VERTEX_ATTRIB_ARRAY7_NV, ARRAY_BOOL(VertexAttrib[7].Enabled),
944 extra_NV_vertex_program },
945 { GL_VERTEX_ATTRIB_ARRAY8_NV, ARRAY_BOOL(VertexAttrib[8].Enabled),
946 extra_NV_vertex_program },
947 { GL_VERTEX_ATTRIB_ARRAY9_NV, ARRAY_BOOL(VertexAttrib[9].Enabled),
948 extra_NV_vertex_program },
949 { GL_VERTEX_ATTRIB_ARRAY10_NV, ARRAY_BOOL(VertexAttrib[10].Enabled),
950 extra_NV_vertex_program },
951 { GL_VERTEX_ATTRIB_ARRAY11_NV, ARRAY_BOOL(VertexAttrib[11].Enabled),
952 extra_NV_vertex_program },
953 { GL_VERTEX_ATTRIB_ARRAY12_NV, ARRAY_BOOL(VertexAttrib[12].Enabled),
954 extra_NV_vertex_program },
955 { GL_VERTEX_ATTRIB_ARRAY13_NV, ARRAY_BOOL(VertexAttrib[13].Enabled),
956 extra_NV_vertex_program },
957 { GL_VERTEX_ATTRIB_ARRAY14_NV, ARRAY_BOOL(VertexAttrib[14].Enabled),
958 extra_NV_vertex_program },
959 { GL_VERTEX_ATTRIB_ARRAY15_NV, ARRAY_BOOL(VertexAttrib[15].Enabled),
960 extra_NV_vertex_program },
961 { GL_MAP1_VERTEX_ATTRIB0_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[0]),
962 extra_NV_vertex_program },
963 { GL_MAP1_VERTEX_ATTRIB1_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[1]),
964 extra_NV_vertex_program },
965 { GL_MAP1_VERTEX_ATTRIB2_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[2]),
966 extra_NV_vertex_program },
967 { GL_MAP1_VERTEX_ATTRIB3_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[3]),
968 extra_NV_vertex_program },
969 { GL_MAP1_VERTEX_ATTRIB4_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[4]),
970 extra_NV_vertex_program },
971 { GL_MAP1_VERTEX_ATTRIB5_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[5]),
972 extra_NV_vertex_program },
973 { GL_MAP1_VERTEX_ATTRIB6_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[6]),
974 extra_NV_vertex_program },
975 { GL_MAP1_VERTEX_ATTRIB7_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[7]),
976 extra_NV_vertex_program },
977 { GL_MAP1_VERTEX_ATTRIB8_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[8]),
978 extra_NV_vertex_program },
979 { GL_MAP1_VERTEX_ATTRIB9_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[9]),
980 extra_NV_vertex_program },
981 { GL_MAP1_VERTEX_ATTRIB10_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[10]),
982 extra_NV_vertex_program },
983 { GL_MAP1_VERTEX_ATTRIB11_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[11]),
984 extra_NV_vertex_program },
985 { GL_MAP1_VERTEX_ATTRIB12_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[12]),
986 extra_NV_vertex_program },
987 { GL_MAP1_VERTEX_ATTRIB13_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[13]),
988 extra_NV_vertex_program },
989 { GL_MAP1_VERTEX_ATTRIB14_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[14]),
990 extra_NV_vertex_program },
991 { GL_MAP1_VERTEX_ATTRIB15_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[15]),
992 extra_NV_vertex_program },
993
994 /* GL_NV_fragment_program */
995 { GL_FRAGMENT_PROGRAM_NV, CONTEXT_BOOL(FragmentProgram.Enabled),
996 extra_NV_fragment_program },
997 { GL_FRAGMENT_PROGRAM_BINDING_NV, LOC_CUSTOM, TYPE_INT, 0,
998 extra_NV_fragment_program },
999 { GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV,
1000 CONST(MAX_NV_FRAGMENT_PROGRAM_PARAMS),
1001 extra_NV_fragment_program },
1002
1003 /* GL_NV_texture_rectangle */
1004 { GL_TEXTURE_RECTANGLE_NV,
1005 LOC_CUSTOM, TYPE_BOOLEAN, 0, extra_NV_texture_rectangle },
1006 { GL_TEXTURE_BINDING_RECTANGLE_NV,
1007 LOC_CUSTOM, TYPE_INT, TEXTURE_RECT_INDEX, extra_NV_texture_rectangle },
1008 { GL_MAX_RECTANGLE_TEXTURE_SIZE_NV,
1009 CONTEXT_INT(Const.MaxTextureRectSize), extra_NV_texture_rectangle },
1010
1011 /* GL_EXT_stencil_two_side */
1012 { GL_STENCIL_TEST_TWO_SIDE_EXT, CONTEXT_BOOL(Stencil.TestTwoSide),
1013 extra_EXT_stencil_two_side },
1014 { GL_ACTIVE_STENCIL_FACE_EXT, LOC_CUSTOM, TYPE_ENUM, NO_OFFSET, NO_EXTRA },
1015
1016 /* GL_NV_light_max_exponent */
1017 { GL_MAX_SHININESS_NV, CONTEXT_FLOAT(Const.MaxShininess),
1018 extra_NV_light_max_exponent },
1019 { GL_MAX_SPOT_EXPONENT_NV, CONTEXT_FLOAT(Const.MaxSpotExponent),
1020 extra_NV_light_max_exponent },
1021
1022 /* GL_ARB_vertex_buffer_object */
1023 { GL_INDEX_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT,
1024 offsetof(struct gl_array_object, Index.BufferObj), NO_EXTRA },
1025 { GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT,
1026 offsetof(struct gl_array_object, EdgeFlag.BufferObj), NO_EXTRA },
1027 { GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT,
1028 offsetof(struct gl_array_object, SecondaryColor.BufferObj), NO_EXTRA },
1029 { GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT,
1030 offsetof(struct gl_array_object, FogCoord.BufferObj), NO_EXTRA },
1031
1032 /* GL_EXT_pixel_buffer_object */
1033 { GL_PIXEL_PACK_BUFFER_BINDING_EXT, LOC_CUSTOM, TYPE_INT, 0,
1034 extra_EXT_pixel_buffer_object },
1035 { GL_PIXEL_UNPACK_BUFFER_BINDING_EXT, LOC_CUSTOM, TYPE_INT, 0,
1036 extra_EXT_pixel_buffer_object },
1037
1038 /* GL_ARB_vertex_program */
1039 { GL_VERTEX_PROGRAM_ARB, /* == GL_VERTEX_PROGRAM_NV */
1040 CONTEXT_BOOL(VertexProgram.Enabled),
1041 extra_ARB_vertex_program_NV_vertex_program },
1042 { GL_VERTEX_PROGRAM_POINT_SIZE_ARB, /* == GL_VERTEX_PROGRAM_POINT_SIZE_NV*/
1043 CONTEXT_BOOL(VertexProgram.PointSizeEnabled),
1044 extra_ARB_vertex_program_NV_vertex_program },
1045 { GL_VERTEX_PROGRAM_TWO_SIDE_ARB, /* == GL_VERTEX_PROGRAM_TWO_SIDE_NV */
1046 CONTEXT_BOOL(VertexProgram.TwoSideEnabled),
1047 extra_ARB_vertex_program_NV_vertex_program },
1048 { GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB, /* == GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV */
1049 CONTEXT_INT(Const.MaxProgramMatrixStackDepth),
1050 extra_ARB_vertex_program_ARB_fragment_program_NV_vertex_program },
1051 { GL_MAX_PROGRAM_MATRICES_ARB, /* == GL_MAX_TRACK_MATRICES_NV */
1052 CONTEXT_INT(Const.MaxProgramMatrices),
1053 extra_ARB_vertex_program_ARB_fragment_program_NV_vertex_program },
1054 { GL_CURRENT_MATRIX_STACK_DEPTH_ARB, /* == GL_CURRENT_MATRIX_STACK_DEPTH_NV */
1055 LOC_CUSTOM, TYPE_INT, 0,
1056 extra_ARB_vertex_program_ARB_fragment_program_NV_vertex_program },
1057
1058 { GL_CURRENT_MATRIX_ARB, /* == GL_CURRENT_MATRIX_NV */
1059 LOC_CUSTOM, TYPE_MATRIX, 0,
1060 extra_ARB_vertex_program_ARB_fragment_program_NV_vertex_program },
1061 { GL_TRANSPOSE_CURRENT_MATRIX_ARB, /* == GL_CURRENT_MATRIX_NV */
1062 LOC_CUSTOM, TYPE_MATRIX, 0,
1063 extra_ARB_vertex_program_ARB_fragment_program },
1064
1065 { GL_PROGRAM_ERROR_POSITION_ARB, /* == GL_PROGRAM_ERROR_POSITION_NV */
1066 CONTEXT_INT(Program.ErrorPos),
1067 extra_NV_vertex_program_ARB_vertex_program_ARB_fragment_program_NV_vertex_program },
1068
1069 /* GL_ARB_fragment_program */
1070 { GL_FRAGMENT_PROGRAM_ARB, CONTEXT_BOOL(FragmentProgram.Enabled),
1071 extra_ARB_fragment_program },
1072
1073 /* GL_EXT_depth_bounds_test */
1074 { GL_DEPTH_BOUNDS_TEST_EXT, CONTEXT_BOOL(Depth.BoundsTest),
1075 extra_EXT_depth_bounds_test },
1076 { GL_DEPTH_BOUNDS_EXT, CONTEXT_FLOAT2(Depth.BoundsMin),
1077 extra_EXT_depth_bounds_test },
1078
1079 /* GL_ARB_depth_clamp*/
1080 { GL_DEPTH_CLAMP, CONTEXT_BOOL(Transform.DepthClamp),
1081 extra_ARB_depth_clamp },
1082
1083 /* GL_ARB_draw_buffers */
1084 { GL_DRAW_BUFFER0_ARB, BUFFER_ENUM(ColorDrawBuffer[0]), NO_EXTRA },
1085 { GL_DRAW_BUFFER1_ARB, BUFFER_ENUM(ColorDrawBuffer[1]),
1086 extra_valid_draw_buffer },
1087 { GL_DRAW_BUFFER2_ARB, BUFFER_ENUM(ColorDrawBuffer[2]),
1088 extra_valid_draw_buffer },
1089 { GL_DRAW_BUFFER3_ARB, BUFFER_ENUM(ColorDrawBuffer[3]),
1090 extra_valid_draw_buffer },
1091
1092 /* GL_ATI_fragment_shader */
1093 { GL_NUM_FRAGMENT_REGISTERS_ATI, CONST(6), extra_ATI_fragment_shader },
1094 { GL_NUM_FRAGMENT_CONSTANTS_ATI, CONST(8), extra_ATI_fragment_shader },
1095 { GL_NUM_PASSES_ATI, CONST(2), extra_ATI_fragment_shader },
1096 { GL_NUM_INSTRUCTIONS_PER_PASS_ATI, CONST(8), extra_ATI_fragment_shader },
1097 { GL_NUM_INSTRUCTIONS_TOTAL_ATI, CONST(16), extra_ATI_fragment_shader },
1098 { GL_COLOR_ALPHA_PAIRING_ATI, CONST(GL_TRUE), extra_ATI_fragment_shader },
1099 { GL_NUM_LOOPBACK_COMPONENTS_ATI, CONST(3), extra_ATI_fragment_shader },
1100 { GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI,
1101 CONST(3), extra_ATI_fragment_shader },
1102
1103 /* GL_EXT_framebuffer_object */
1104 { GL_MAX_COLOR_ATTACHMENTS_EXT, CONTEXT_INT(Const.MaxColorAttachments),
1105 extra_EXT_framebuffer_object },
1106
1107 /* GL_EXT_framebuffer_blit
1108 * NOTE: GL_DRAW_FRAMEBUFFER_BINDING_EXT == GL_FRAMEBUFFER_BINDING_EXT */
1109 { GL_READ_FRAMEBUFFER_BINDING_EXT, LOC_CUSTOM, TYPE_INT, 0,
1110 extra_EXT_framebuffer_blit },
1111
1112 /* GL_EXT_provoking_vertex */
1113 { GL_PROVOKING_VERTEX_EXT,
1114 CONTEXT_BOOL(Light.ProvokingVertex), extra_EXT_provoking_vertex },
1115 { GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT,
1116 CONTEXT_BOOL(Const.QuadsFollowProvokingVertexConvention),
1117 extra_EXT_provoking_vertex },
1118
1119 /* GL_ARB_framebuffer_object */
1120 { GL_MAX_SAMPLES, CONTEXT_INT(Const.MaxSamples),
1121 extra_ARB_framebuffer_object },
1122
1123 /* GL_APPLE_vertex_array_object */
1124 { GL_VERTEX_ARRAY_BINDING_APPLE, ARRAY_INT(Name),
1125 extra_APPLE_vertex_array_object },
1126
1127 /* GL_ARB_seamless_cube_map */
1128 { GL_TEXTURE_CUBE_MAP_SEAMLESS,
1129 CONTEXT_BOOL(Texture.CubeMapSeamless), extra_ARB_seamless_cube_map },
1130
1131 /* GL_ARB_sync */
1132 { GL_MAX_SERVER_WAIT_TIMEOUT,
1133 CONTEXT_INT64(Const.MaxServerWaitTimeout), extra_ARB_sync },
1134
1135 /* GL_EXT_transform_feedback */
1136 { GL_TRANSFORM_FEEDBACK_BUFFER_BINDING, LOC_CUSTOM, TYPE_INT, 0,
1137 extra_EXT_transform_feedback },
1138 { GL_RASTERIZER_DISCARD, CONTEXT_BOOL(TransformFeedback.RasterDiscard),
1139 extra_EXT_transform_feedback },
1140 { GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS,
1141 CONTEXT_INT(Const.MaxTransformFeedbackInterleavedComponents),
1142 extra_EXT_transform_feedback },
1143 { GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS,
1144 CONTEXT_INT(Const.MaxTransformFeedbackSeparateAttribs),
1145 extra_EXT_transform_feedback },
1146 { GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS,
1147 CONTEXT_INT(Const.MaxTransformFeedbackSeparateComponents),
1148 extra_EXT_transform_feedback },
1149
1150 /* GL_ARB_transform_feedback2 */
1151 { GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED, LOC_CUSTOM, TYPE_BOOLEAN, 0,
1152 extra_ARB_transform_feedback2 },
1153 { GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE, LOC_CUSTOM, TYPE_BOOLEAN, 0,
1154 extra_ARB_transform_feedback2 },
1155 { GL_TRANSFORM_FEEDBACK_BINDING, LOC_CUSTOM, TYPE_INT, 0,
1156 extra_ARB_transform_feedback2 },
1157
1158 /* GL_ARB_geometry_shader4 */
1159 { GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB,
1160 CONTEXT_INT(Const.GeometryProgram.MaxGeometryTextureImageUnits),
1161 extra_ARB_geometry_shader4 },
1162 { GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB,
1163 CONTEXT_INT(Const.GeometryProgram.MaxGeometryOutputVertices),
1164 extra_ARB_geometry_shader4 },
1165 { GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB,
1166 CONTEXT_INT(Const.GeometryProgram.MaxGeometryTotalOutputComponents),
1167 extra_ARB_geometry_shader4 },
1168 { GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB,
1169 CONTEXT_INT(Const.GeometryProgram.MaxGeometryUniformComponents),
1170 extra_ARB_geometry_shader4 },
1171 { GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB,
1172 CONTEXT_INT(Const.GeometryProgram.MaxGeometryVaryingComponents),
1173 extra_ARB_geometry_shader4 },
1174 { GL_MAX_VERTEX_VARYING_COMPONENTS_ARB,
1175 CONTEXT_INT(Const.GeometryProgram.MaxVertexVaryingComponents),
1176 extra_ARB_geometry_shader4 },
1177
1178 /* GL 3.0 */
1179 { GL_NUM_EXTENSIONS, LOC_CUSTOM, TYPE_INT, 0, extra_version_30 },
1180 { GL_MAJOR_VERSION, CONTEXT_INT(VersionMajor), extra_version_30 },
1181 { GL_MINOR_VERSION, CONTEXT_INT(VersionMinor), extra_version_30 },
1182 { GL_CONTEXT_FLAGS, CONTEXT_INT(Const.ContextFlags), extra_version_30 },
1183
1184 /* GL 3.1 */
1185 { GL_PRIMITIVE_RESTART, CONTEXT_BOOL(Array.PrimitiveRestart),
1186 extra_version_31 },
1187 { GL_PRIMITIVE_RESTART_INDEX, CONTEXT_INT(Array.RestartIndex),
1188 extra_version_31 },
1189
1190 /* GL 3.2 */
1191 { GL_CONTEXT_PROFILE_MASK, CONTEXT_INT(Const.ProfileMask),
1192 extra_version_32 },
1193 #endif /* FEATURE_GL */
1194 };
1195
1196 /* All we need now is a way to look up the value struct from the enum.
1197 * The code generated by gcc for the old generated big switch
1198 * statement is a big, balanced, open coded if/else tree, essentially
1199 * an unrolled binary search. It would be natural to sort the new
1200 * enum table and use bsearch(), but we will use a read-only hash
1201 * table instead. bsearch() has a nice guaranteed worst case
1202 * performance, but we're also guaranteed to hit that worst case
1203 * (log2(n) iterations) for about half the enums. Instead, using an
1204 * open addressing hash table, we can find the enum on the first try
1205 * for 80% of the enums, 1 collision for 10% and never more than 5
1206 * collisions for any enum (typical numbers). And the code is very
1207 * simple, even though it feels a little magic. */
1208
1209 static unsigned short table[1024];
1210 static const int prime_factor = 89, prime_step = 281;
1211
1212 #ifdef GET_DEBUG
1213 static void
1214 print_table_stats(void)
1215 {
1216 int i, j, collisions[11], count, hash, mask;
1217 const struct value_desc *d;
1218
1219 count = 0;
1220 mask = Elements(table) - 1;
1221 memset(collisions, 0, sizeof collisions);
1222
1223 for (i = 0; i < Elements(table); i++) {
1224 if (!table[i])
1225 continue;
1226 count++;
1227 d = &values[table[i]];
1228 hash = (d->pname * prime_factor);
1229 j = 0;
1230 while (1) {
1231 if (values[table[hash & mask]].pname == d->pname)
1232 break;
1233 hash += prime_step;
1234 j++;
1235 }
1236
1237 if (j < 10)
1238 collisions[j]++;
1239 else
1240 collisions[10]++;
1241 }
1242
1243 printf("number of enums: %d (total %d)\n", count, Elements(values));
1244 for (i = 0; i < Elements(collisions) - 1; i++)
1245 if (collisions[i] > 0)
1246 printf(" %d enums with %d %scollisions\n",
1247 collisions[i], i, i == 10 ? "or more " : "");
1248 }
1249 #endif
1250
1251 /**
1252 * Initialize the enum hash for a given API
1253 *
1254 * This is called from one_time_init() to insert the enum values that
1255 * are valid for the API in question into the enum hash table.
1256 *
1257 * \param the current context, for determining the API in question
1258 */
1259 void _mesa_init_get_hash(GLcontext *ctx)
1260 {
1261 int i, hash, index, mask;
1262 int api_mask = 0, api_bit;
1263
1264 mask = Elements(table) - 1;
1265 api_bit = 1 << ctx->API;
1266
1267 for (i = 0; i < Elements(values); i++) {
1268 if (values[i].type == TYPE_API_MASK) {
1269 api_mask = values[i].offset;
1270 continue;
1271 }
1272 if (!(api_mask & api_bit))
1273 continue;
1274
1275 hash = (values[i].pname * prime_factor) & mask;
1276 while (1) {
1277 index = hash & mask;
1278 if (!table[index]) {
1279 table[index] = i;
1280 break;
1281 }
1282 hash += prime_step;
1283 }
1284 }
1285
1286 #ifdef GET_DEBUG
1287 print_table_stats();
1288 #endif
1289 }
1290
1291 /**
1292 * Handle irregular enums
1293 *
1294 * Some values don't conform to the "well-known type at context
1295 * pointer + offset" pattern, so we have this function to catch all
1296 * the corner cases. Typically, it's a computed value or a one-off
1297 * pointer to a custom struct or something.
1298 *
1299 * In this case we can't return a pointer to the value, so we'll have
1300 * to use the temporary variable 'v' declared back in the calling
1301 * glGet*v() function to store the result.
1302 *
1303 * \param ctx the current context
1304 * \param d the struct value_desc that describes the enum
1305 * \param v pointer to the tmp declared in the calling glGet*v() function
1306 */
1307 static void
1308 find_custom_value(GLcontext *ctx, const struct value_desc *d, union value *v)
1309 {
1310 struct gl_buffer_object *buffer_obj;
1311 struct gl_client_array *array;
1312 GLuint unit, *p;
1313
1314 switch (d->pname) {
1315 case GL_TEXTURE_1D:
1316 case GL_TEXTURE_2D:
1317 case GL_TEXTURE_3D:
1318 case GL_TEXTURE_1D_ARRAY_EXT:
1319 case GL_TEXTURE_2D_ARRAY_EXT:
1320 case GL_TEXTURE_CUBE_MAP_ARB:
1321 case GL_TEXTURE_RECTANGLE_NV:
1322 v->value_bool = _mesa_IsEnabled(d->pname);
1323 break;
1324
1325 case GL_LINE_STIPPLE_PATTERN:
1326 /* This is the only GLushort, special case it here by promoting
1327 * to an int rather than introducing a new type. */
1328 v->value_int = ctx->Line.StipplePattern;
1329 break;
1330
1331 case GL_CURRENT_RASTER_TEXTURE_COORDS:
1332 unit = ctx->Texture.CurrentUnit;
1333 v->value_float_4[0] = ctx->Current.RasterTexCoords[unit][0];
1334 v->value_float_4[1] = ctx->Current.RasterTexCoords[unit][1];
1335 v->value_float_4[2] = ctx->Current.RasterTexCoords[unit][2];
1336 v->value_float_4[3] = ctx->Current.RasterTexCoords[unit][3];
1337 break;
1338
1339 case GL_CURRENT_TEXTURE_COORDS:
1340 unit = ctx->Texture.CurrentUnit;
1341 v->value_float_4[0] = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][0];
1342 v->value_float_4[1] = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][1];
1343 v->value_float_4[2] = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][2];
1344 v->value_float_4[3] = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][3];
1345 break;
1346
1347 case GL_COLOR_WRITEMASK:
1348 v->value_int_4[0] = ctx->Color.ColorMask[0][RCOMP] ? 1 : 0;
1349 v->value_int_4[1] = ctx->Color.ColorMask[0][GCOMP] ? 1 : 0;
1350 v->value_int_4[2] = ctx->Color.ColorMask[0][BCOMP] ? 1 : 0;
1351 v->value_int_4[3] = ctx->Color.ColorMask[0][ACOMP] ? 1 : 0;
1352 break;
1353
1354 case GL_EDGE_FLAG:
1355 v->value_bool = ctx->Current.Attrib[VERT_ATTRIB_EDGEFLAG][0] == 1.0;
1356 break;
1357
1358 case GL_READ_BUFFER:
1359 v->value_enum = ctx->ReadBuffer->ColorReadBuffer;
1360 break;
1361
1362 case GL_MAP2_GRID_DOMAIN:
1363 v->value_float_4[0] = ctx->Eval.MapGrid2u1;
1364 v->value_float_4[1] = ctx->Eval.MapGrid2u2;
1365 v->value_float_4[2] = ctx->Eval.MapGrid2v1;
1366 v->value_float_4[3] = ctx->Eval.MapGrid2v2;
1367 break;
1368
1369 case GL_TEXTURE_STACK_DEPTH:
1370 unit = ctx->Texture.CurrentUnit;
1371 v->value_int = ctx->TextureMatrixStack[unit].Depth + 1;
1372 break;
1373 case GL_TEXTURE_MATRIX:
1374 unit = ctx->Texture.CurrentUnit;
1375 v->value_matrix = ctx->TextureMatrixStack[unit].Top;
1376 break;
1377
1378 case GL_TEXTURE_COORD_ARRAY:
1379 case GL_TEXTURE_COORD_ARRAY_SIZE:
1380 case GL_TEXTURE_COORD_ARRAY_TYPE:
1381 case GL_TEXTURE_COORD_ARRAY_STRIDE:
1382 array = &ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture];
1383 v->value_int = *(GLuint *) ((char *) array + d->offset);
1384 break;
1385
1386 case GL_ACTIVE_TEXTURE_ARB:
1387 v->value_int = GL_TEXTURE0_ARB + ctx->Texture.CurrentUnit;
1388 break;
1389 case GL_CLIENT_ACTIVE_TEXTURE_ARB:
1390 v->value_int = GL_TEXTURE0_ARB + ctx->Array.ActiveTexture;
1391 break;
1392
1393 case GL_MODELVIEW_STACK_DEPTH:
1394 case GL_PROJECTION_STACK_DEPTH:
1395 v->value_int = *(GLint *) ((char *) ctx + d->offset) + 1;
1396 break;
1397
1398 case GL_MAX_TEXTURE_SIZE:
1399 case GL_MAX_3D_TEXTURE_SIZE:
1400 case GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB:
1401 p = (GLuint *) ((char *) ctx + d->offset);
1402 v->value_int = 1 << (*p - 1);
1403 break;
1404
1405 case GL_SCISSOR_BOX:
1406 v->value_int_4[0] = ctx->Scissor.X;
1407 v->value_int_4[1] = ctx->Scissor.Y;
1408 v->value_int_4[2] = ctx->Scissor.Width;
1409 v->value_int_4[3] = ctx->Scissor.Height;
1410 break;
1411
1412 case GL_LIST_INDEX:
1413 v->value_int =
1414 ctx->ListState.CurrentList ? ctx->ListState.CurrentList->Name : 0;
1415 break;
1416 case GL_LIST_MODE:
1417 if (!ctx->CompileFlag)
1418 v->value_enum = 0;
1419 else if (ctx->ExecuteFlag)
1420 v->value_enum = GL_COMPILE_AND_EXECUTE;
1421 else
1422 v->value_enum = GL_COMPILE;
1423 break;
1424
1425 case GL_VIEWPORT:
1426 v->value_int_4[0] = ctx->Viewport.X;
1427 v->value_int_4[1] = ctx->Viewport.Y;
1428 v->value_int_4[2] = ctx->Viewport.Width;
1429 v->value_int_4[3] = ctx->Viewport.Height;
1430 break;
1431
1432 case GL_ACTIVE_STENCIL_FACE_EXT:
1433 v->value_enum = ctx->Stencil.ActiveFace ? GL_BACK : GL_FRONT;
1434 break;
1435
1436 case GL_STENCIL_FAIL:
1437 v->value_enum = ctx->Stencil.FailFunc[ctx->Stencil.ActiveFace];
1438 break;
1439 case GL_STENCIL_FUNC:
1440 v->value_enum = ctx->Stencil.Function[ctx->Stencil.ActiveFace];
1441 break;
1442 case GL_STENCIL_PASS_DEPTH_FAIL:
1443 v->value_enum = ctx->Stencil.ZFailFunc[ctx->Stencil.ActiveFace];
1444 break;
1445 case GL_STENCIL_PASS_DEPTH_PASS:
1446 v->value_enum = ctx->Stencil.ZPassFunc[ctx->Stencil.ActiveFace];
1447 break;
1448 case GL_STENCIL_REF:
1449 v->value_int = ctx->Stencil.Ref[ctx->Stencil.ActiveFace];
1450 break;
1451 case GL_STENCIL_VALUE_MASK:
1452 v->value_int = ctx->Stencil.ValueMask[ctx->Stencil.ActiveFace];
1453 break;
1454 case GL_STENCIL_WRITEMASK:
1455 v->value_int = ctx->Stencil.WriteMask[ctx->Stencil.ActiveFace];
1456 break;
1457
1458 case GL_NUM_EXTENSIONS:
1459 v->value_int = _mesa_get_extension_count(ctx);
1460 break;
1461
1462 case GL_IMPLEMENTATION_COLOR_READ_TYPE_OES:
1463 v->value_int = _mesa_get_color_read_type(ctx);
1464 break;
1465 case GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES:
1466 v->value_int = _mesa_get_color_read_format(ctx);
1467 break;
1468
1469 case GL_CURRENT_MATRIX_STACK_DEPTH_ARB:
1470 v->value_int = ctx->CurrentStack->Depth + 1;
1471 break;
1472 case GL_CURRENT_MATRIX_ARB:
1473 case GL_TRANSPOSE_CURRENT_MATRIX_ARB:
1474 v->value_matrix = ctx->CurrentStack->Top;
1475 break;
1476
1477 case GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB:
1478 v->value_int = _mesa_get_compressed_formats(ctx, NULL, GL_FALSE);
1479 break;
1480 case GL_COMPRESSED_TEXTURE_FORMATS_ARB:
1481 v->value_int_n.n =
1482 _mesa_get_compressed_formats(ctx, v->value_int_n.ints, GL_FALSE);
1483 ASSERT(v->value_int_n.n <= 100);
1484 break;
1485
1486 case GL_MAX_VARYING_FLOATS_ARB:
1487 v->value_int = ctx->Const.MaxVarying * 4;
1488 break;
1489
1490 /* Various object names */
1491
1492 case GL_TEXTURE_BINDING_1D:
1493 case GL_TEXTURE_BINDING_2D:
1494 case GL_TEXTURE_BINDING_3D:
1495 case GL_TEXTURE_BINDING_1D_ARRAY_EXT:
1496 case GL_TEXTURE_BINDING_2D_ARRAY_EXT:
1497 case GL_TEXTURE_BINDING_CUBE_MAP_ARB:
1498 case GL_TEXTURE_BINDING_RECTANGLE_NV:
1499 unit = ctx->Texture.CurrentUnit;
1500 v->value_int =
1501 ctx->Texture.Unit[unit].CurrentTex[d->offset]->Name;
1502 break;
1503
1504 /* GL_ARB_vertex_buffer_object */
1505 case GL_VERTEX_ARRAY_BUFFER_BINDING_ARB:
1506 case GL_NORMAL_ARRAY_BUFFER_BINDING_ARB:
1507 case GL_COLOR_ARRAY_BUFFER_BINDING_ARB:
1508 case GL_INDEX_ARRAY_BUFFER_BINDING_ARB:
1509 case GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB:
1510 case GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB:
1511 case GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB:
1512 buffer_obj = (struct gl_buffer_object *)
1513 ((char *) ctx->Array.ArrayObj + d->offset);
1514 v->value_int = buffer_obj->Name;
1515 break;
1516 case GL_ARRAY_BUFFER_BINDING_ARB:
1517 v->value_int = ctx->Array.ArrayBufferObj->Name;
1518 break;
1519 case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB:
1520 v->value_int =
1521 ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].BufferObj->Name;
1522 break;
1523 case GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB:
1524 v->value_int = ctx->Array.ElementArrayBufferObj->Name;
1525 break;
1526
1527 case GL_FRAGMENT_PROGRAM_BINDING_NV:
1528 v->value_int =
1529 ctx->FragmentProgram.Current ? ctx->FragmentProgram.Current->Base.Id : 0;
1530 break;
1531 case GL_VERTEX_PROGRAM_BINDING_NV:
1532 v->value_int =
1533 ctx->VertexProgram.Current ? ctx->VertexProgram.Current->Base.Id : 0;
1534 break;
1535 case GL_PIXEL_PACK_BUFFER_BINDING_EXT:
1536 v->value_int = ctx->Pack.BufferObj->Name;
1537 break;
1538 case GL_PIXEL_UNPACK_BUFFER_BINDING_EXT:
1539 v->value_int = ctx->Unpack.BufferObj->Name;
1540 break;
1541 case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING:
1542 v->value_int = ctx->TransformFeedback.CurrentBuffer->Name;
1543 break;
1544 case GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED:
1545 v->value_int = ctx->TransformFeedback.CurrentObject->Paused;
1546 break;
1547 case GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE:
1548 v->value_int = ctx->TransformFeedback.CurrentObject->Active;
1549 break;
1550 case GL_TRANSFORM_FEEDBACK_BINDING:
1551 v->value_int = ctx->TransformFeedback.CurrentObject->Name;
1552 break;
1553 case GL_CURRENT_PROGRAM:
1554 v->value_int =
1555 ctx->Shader.CurrentProgram ? ctx->Shader.CurrentProgram->Name : 0;
1556 break;
1557 case GL_READ_FRAMEBUFFER_BINDING_EXT:
1558 v->value_int = ctx->ReadBuffer->Name;
1559 break;
1560 case GL_RENDERBUFFER_BINDING_EXT:
1561 v->value_int =
1562 ctx->CurrentRenderbuffer ? ctx->CurrentRenderbuffer->Name : 0;
1563 break;
1564 case GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES:
1565 v->value_int = ctx->Array.ArrayObj->PointSize.BufferObj->Name;
1566 break;
1567 }
1568 }
1569
1570 /**
1571 * Check extra constraints on a struct value_desc descriptor
1572 *
1573 * If a struct value_desc has a non-NULL extra pointer, it means that
1574 * there are a number of extra constraints to check or actions to
1575 * perform. The extras is just an integer array where each integer
1576 * encode different constraints or actions.
1577 *
1578 * \param ctx current context
1579 * \param func name of calling glGet*v() function for error reporting
1580 * \param d the struct value_desc that has the extra constraints
1581 *
1582 * \return GL_FALSE if one of the constraints was not satisfied,
1583 * otherwise GL_TRUE.
1584 */
1585 static GLboolean
1586 check_extra(GLcontext *ctx, const char *func, const struct value_desc *d)
1587 {
1588 const GLuint version = ctx->VersionMajor * 10 + ctx->VersionMinor;
1589 int total, enabled;
1590 const int *e;
1591
1592 total = 0;
1593 enabled = 0;
1594 for (e = d->extra; *e != EXTRA_END; e++)
1595 switch (*e) {
1596 case EXTRA_VERSION_30:
1597 if (version >= 30) {
1598 total++;
1599 enabled++;
1600 }
1601 break;
1602 case EXTRA_VERSION_31:
1603 if (version >= 31) {
1604 total++;
1605 enabled++;
1606 }
1607 break;
1608 case EXTRA_VERSION_32:
1609 if (version >= 32) {
1610 total++;
1611 enabled++;
1612 }
1613 break;
1614 case EXTRA_VERSION_ES2:
1615 if (ctx->API == API_OPENGLES2) {
1616 total++;
1617 enabled++;
1618 }
1619 break;
1620 case EXTRA_NEW_BUFFERS:
1621 if (ctx->NewState & _NEW_BUFFERS)
1622 _mesa_update_state(ctx);
1623 break;
1624 case EXTRA_FLUSH_CURRENT:
1625 FLUSH_CURRENT(ctx, 0);
1626 break;
1627 case EXTRA_VALID_DRAW_BUFFER:
1628 if (d->pname - GL_DRAW_BUFFER0_ARB >= ctx->Const.MaxDrawBuffers) {
1629 _mesa_error(ctx, GL_INVALID_OPERATION, "%s(draw buffer %u)",
1630 func, d->pname - GL_DRAW_BUFFER0_ARB);
1631 return GL_FALSE;
1632 }
1633 break;
1634 case EXTRA_VALID_TEXTURE_UNIT:
1635 if (ctx->Texture.CurrentUnit >= ctx->Const.MaxTextureCoordUnits) {
1636 _mesa_error(ctx, GL_INVALID_OPERATION, "%s(texture %u)",
1637 func, ctx->Texture.CurrentUnit);
1638 return GL_FALSE;
1639 }
1640 break;
1641 case EXTRA_END:
1642 break;
1643 default: /* *e is a offset into the extension struct */
1644 total++;
1645 if (*(GLboolean *) ((char *) &ctx->Extensions + *e))
1646 enabled++;
1647 break;
1648 }
1649
1650 if (total > 0 && enabled == 0) {
1651 _mesa_error(ctx, GL_INVALID_ENUM, "%s(pname=%s)", func,
1652 _mesa_lookup_enum_by_nr(d->pname));
1653 return GL_FALSE;
1654 }
1655
1656 return GL_TRUE;
1657 }
1658
1659 static const struct value_desc error_value =
1660 { 0, 0, TYPE_INVALID, NO_OFFSET, NO_EXTRA };
1661
1662 /**
1663 * Find the struct value_desc corresponding to the enum 'pname'.
1664 *
1665 * We hash the enum value to get an index into the 'table' array,
1666 * which holds the index in the 'values' array of struct value_desc.
1667 * Once we've found the entry, we do the extra checks, if any, then
1668 * look up the value and return a pointer to it.
1669 *
1670 * If the value has to be computed (for example, it's the result of a
1671 * function call or we need to add 1 to it), we use the tmp 'v' to
1672 * store the result.
1673 *
1674 * \param func name of glGet*v() func for error reporting
1675 * \param pname the enum value we're looking up
1676 * \param p is were we return the pointer to the value
1677 * \param v a tmp union value variable in the calling glGet*v() function
1678 *
1679 * \return the struct value_desc corresponding to the enum or a struct
1680 * value_desc of TYPE_INVALID if not found. This lets the calling
1681 * glGet*v() function jump right into a switch statement and
1682 * handle errors there instead of having to check for NULL.
1683 */
1684 static const struct value_desc *
1685 find_value(const char *func, GLenum pname, void **p, union value *v)
1686 {
1687 GET_CURRENT_CONTEXT(ctx);
1688 struct gl_texture_unit *unit;
1689 int mask, hash;
1690 const struct value_desc *d;
1691
1692 mask = Elements(table) - 1;
1693 hash = (pname * prime_factor);
1694 while (1) {
1695 d = &values[table[hash & mask]];
1696 if (likely(d->pname == pname))
1697 break;
1698
1699 /* If the enum isn't valid, the hash walk ends with index 0,
1700 * which is the API mask entry at the beginning of values[]. */
1701 if (d->type == TYPE_API_MASK) {
1702 _mesa_error(ctx, GL_INVALID_ENUM, "%s(pname=%s)", func,
1703 _mesa_lookup_enum_by_nr(pname));
1704 return &error_value;
1705 }
1706 hash += prime_step;
1707 }
1708
1709 if (unlikely(d->extra && !check_extra(ctx, func, d)))
1710 return &error_value;
1711
1712 switch (d->location) {
1713 case LOC_BUFFER:
1714 *p = ((char *) ctx->DrawBuffer + d->offset);
1715 return d;
1716 case LOC_CONTEXT:
1717 *p = ((char *) ctx + d->offset);
1718 return d;
1719 case LOC_ARRAY:
1720 *p = ((char *) ctx->Array.ArrayObj + d->offset);
1721 return d;
1722 case LOC_TEXUNIT:
1723 unit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
1724 *p = ((char *) unit + d->offset);
1725 return d;
1726 case LOC_CUSTOM:
1727 find_custom_value(ctx, d, v);
1728 *p = v;
1729 return d;
1730 default:
1731 assert(0);
1732 break;
1733 }
1734
1735 /* silence warning */
1736 return &error_value;
1737 }
1738
1739 static const int transpose[] = {
1740 0, 4, 8, 12,
1741 1, 5, 9, 13,
1742 2, 6, 10, 14,
1743 3, 7, 11, 15
1744 };
1745
1746 void GLAPIENTRY
1747 _mesa_GetBooleanv(GLenum pname, GLboolean *params)
1748 {
1749 const struct value_desc *d;
1750 union value v;
1751 GLmatrix *m;
1752 int shift, i;
1753 void *p;
1754
1755 d = find_value("glGetBooleanv", pname, &p, &v);
1756 switch (d->type) {
1757 case TYPE_INVALID:
1758 break;
1759 case TYPE_CONST:
1760 params[0] = INT_TO_BOOLEAN(d->offset);
1761 break;
1762
1763 case TYPE_FLOAT_4:
1764 case TYPE_FLOATN_4:
1765 params[3] = FLOAT_TO_BOOLEAN(((GLfloat *) p)[3]);
1766 case TYPE_FLOAT_3:
1767 case TYPE_FLOATN_3:
1768 params[2] = FLOAT_TO_BOOLEAN(((GLfloat *) p)[2]);
1769 case TYPE_FLOAT_2:
1770 case TYPE_FLOATN_2:
1771 params[1] = FLOAT_TO_BOOLEAN(((GLfloat *) p)[1]);
1772 case TYPE_FLOAT:
1773 case TYPE_FLOATN:
1774 params[0] = FLOAT_TO_BOOLEAN(((GLfloat *) p)[0]);
1775 break;
1776
1777 case TYPE_DOUBLEN:
1778 params[0] = FLOAT_TO_BOOLEAN(((GLdouble *) p)[0]);
1779 break;
1780
1781 case TYPE_INT_4:
1782 params[3] = INT_TO_BOOLEAN(((GLint *) p)[3]);
1783 case TYPE_INT_3:
1784 params[2] = INT_TO_BOOLEAN(((GLint *) p)[2]);
1785 case TYPE_INT_2:
1786 case TYPE_ENUM_2:
1787 params[1] = INT_TO_BOOLEAN(((GLint *) p)[1]);
1788 case TYPE_INT:
1789 case TYPE_ENUM:
1790 params[0] = INT_TO_BOOLEAN(((GLint *) p)[0]);
1791 break;
1792
1793 case TYPE_INT_N:
1794 for (i = 0; i < v.value_int_n.n; i++)
1795 params[i] = INT_TO_BOOLEAN(v.value_int_n.ints[i]);
1796 break;
1797
1798 case TYPE_INT64:
1799 params[0] = INT64_TO_BOOLEAN(((GLint64 *) p)[0]);
1800 break;
1801
1802 case TYPE_BOOLEAN:
1803 params[0] = ((GLboolean*) p)[0];
1804 break;
1805
1806 case TYPE_MATRIX:
1807 m = *(GLmatrix **) p;
1808 for (i = 0; i < 16; i++)
1809 params[i] = FLOAT_TO_BOOLEAN(m->m[i]);
1810 break;
1811
1812 case TYPE_MATRIX_T:
1813 m = *(GLmatrix **) p;
1814 for (i = 0; i < 16; i++)
1815 params[i] = FLOAT_TO_BOOLEAN(m->m[transpose[i]]);
1816 break;
1817
1818 case TYPE_BIT_0:
1819 case TYPE_BIT_1:
1820 case TYPE_BIT_2:
1821 case TYPE_BIT_3:
1822 case TYPE_BIT_4:
1823 case TYPE_BIT_5:
1824 shift = d->type - TYPE_BIT_0;
1825 params[0] = (*(GLbitfield *) p >> shift) & 1;
1826 break;
1827 }
1828 }
1829
1830 void GLAPIENTRY
1831 _mesa_GetFloatv(GLenum pname, GLfloat *params)
1832 {
1833 const struct value_desc *d;
1834 union value v;
1835 GLmatrix *m;
1836 int shift, i;
1837 void *p;
1838
1839 d = find_value("glGetFloatv", pname, &p, &v);
1840 switch (d->type) {
1841 case TYPE_INVALID:
1842 break;
1843 case TYPE_CONST:
1844 params[0] = (GLfloat) d->offset;
1845 break;
1846
1847 case TYPE_FLOAT_4:
1848 case TYPE_FLOATN_4:
1849 params[3] = ((GLfloat *) p)[3];
1850 case TYPE_FLOAT_3:
1851 case TYPE_FLOATN_3:
1852 params[2] = ((GLfloat *) p)[2];
1853 case TYPE_FLOAT_2:
1854 case TYPE_FLOATN_2:
1855 params[1] = ((GLfloat *) p)[1];
1856 case TYPE_FLOAT:
1857 case TYPE_FLOATN:
1858 params[0] = ((GLfloat *) p)[0];
1859 break;
1860
1861 case TYPE_DOUBLEN:
1862 params[0] = ((GLdouble *) p)[0];
1863 break;
1864
1865 case TYPE_INT_4:
1866 params[3] = (GLfloat) (((GLint *) p)[3]);
1867 case TYPE_INT_3:
1868 params[2] = (GLfloat) (((GLint *) p)[2]);
1869 case TYPE_INT_2:
1870 case TYPE_ENUM_2:
1871 params[1] = (GLfloat) (((GLint *) p)[1]);
1872 case TYPE_INT:
1873 case TYPE_ENUM:
1874 params[0] = (GLfloat) (((GLint *) p)[0]);
1875 break;
1876
1877 case TYPE_INT_N:
1878 for (i = 0; i < v.value_int_n.n; i++)
1879 params[i] = INT_TO_FLOAT(v.value_int_n.ints[i]);
1880 break;
1881
1882 case TYPE_INT64:
1883 params[0] = ((GLint64 *) p)[0];
1884 break;
1885
1886 case TYPE_BOOLEAN:
1887 params[0] = BOOLEAN_TO_FLOAT(*(GLboolean*) p);
1888 break;
1889
1890 case TYPE_MATRIX:
1891 m = *(GLmatrix **) p;
1892 for (i = 0; i < 16; i++)
1893 params[i] = m->m[i];
1894 break;
1895
1896 case TYPE_MATRIX_T:
1897 m = *(GLmatrix **) p;
1898 for (i = 0; i < 16; i++)
1899 params[i] = m->m[transpose[i]];
1900 break;
1901
1902 case TYPE_BIT_0:
1903 case TYPE_BIT_1:
1904 case TYPE_BIT_2:
1905 case TYPE_BIT_3:
1906 case TYPE_BIT_4:
1907 case TYPE_BIT_5:
1908 shift = d->type - TYPE_BIT_0;
1909 params[0] = BOOLEAN_TO_FLOAT((*(GLbitfield *) p >> shift) & 1);
1910 break;
1911 }
1912 }
1913
1914 void GLAPIENTRY
1915 _mesa_GetIntegerv(GLenum pname, GLint *params)
1916 {
1917 const struct value_desc *d;
1918 union value v;
1919 GLmatrix *m;
1920 int shift, i;
1921 void *p;
1922
1923 d = find_value("glGetIntegerv", pname, &p, &v);
1924 switch (d->type) {
1925 case TYPE_INVALID:
1926 break;
1927 case TYPE_CONST:
1928 params[0] = d->offset;
1929 break;
1930
1931 case TYPE_FLOAT_4:
1932 params[3] = IROUND(((GLfloat *) p)[3]);
1933 case TYPE_FLOAT_3:
1934 params[2] = IROUND(((GLfloat *) p)[2]);
1935 case TYPE_FLOAT_2:
1936 params[1] = IROUND(((GLfloat *) p)[1]);
1937 case TYPE_FLOAT:
1938 params[0] = IROUND(((GLfloat *) p)[0]);
1939 break;
1940
1941 case TYPE_FLOATN_4:
1942 params[3] = FLOAT_TO_INT(((GLfloat *) p)[3]);
1943 case TYPE_FLOATN_3:
1944 params[2] = FLOAT_TO_INT(((GLfloat *) p)[2]);
1945 case TYPE_FLOATN_2:
1946 params[1] = FLOAT_TO_INT(((GLfloat *) p)[1]);
1947 case TYPE_FLOATN:
1948 params[0] = FLOAT_TO_INT(((GLfloat *) p)[0]);
1949 break;
1950
1951 case TYPE_DOUBLEN:
1952 params[0] = FLOAT_TO_INT(((GLdouble *) p)[0]);
1953 break;
1954
1955 case TYPE_INT_4:
1956 params[3] = ((GLint *) p)[3];
1957 case TYPE_INT_3:
1958 params[2] = ((GLint *) p)[2];
1959 case TYPE_INT_2:
1960 case TYPE_ENUM_2:
1961 params[1] = ((GLint *) p)[1];
1962 case TYPE_INT:
1963 case TYPE_ENUM:
1964 params[0] = ((GLint *) p)[0];
1965 break;
1966
1967 case TYPE_INT_N:
1968 for (i = 0; i < v.value_int_n.n; i++)
1969 params[i] = v.value_int_n.ints[i];
1970 break;
1971
1972 case TYPE_INT64:
1973 params[0] = INT64_TO_INT(((GLint64 *) p)[0]);
1974 break;
1975
1976 case TYPE_BOOLEAN:
1977 params[0] = BOOLEAN_TO_INT(*(GLboolean*) p);
1978 break;
1979
1980 case TYPE_MATRIX:
1981 m = *(GLmatrix **) p;
1982 for (i = 0; i < 16; i++)
1983 params[i] = FLOAT_TO_INT(m->m[i]);
1984 break;
1985
1986 case TYPE_MATRIX_T:
1987 m = *(GLmatrix **) p;
1988 for (i = 0; i < 16; i++)
1989 params[i] = FLOAT_TO_INT(m->m[transpose[i]]);
1990 break;
1991
1992 case TYPE_BIT_0:
1993 case TYPE_BIT_1:
1994 case TYPE_BIT_2:
1995 case TYPE_BIT_3:
1996 case TYPE_BIT_4:
1997 case TYPE_BIT_5:
1998 shift = d->type - TYPE_BIT_0;
1999 params[0] = (*(GLbitfield *) p >> shift) & 1;
2000 break;
2001 }
2002 }
2003
2004 #if FEATURE_ARB_sync
2005 void GLAPIENTRY
2006 _mesa_GetInteger64v(GLenum pname, GLint64 *params)
2007 {
2008 const struct value_desc *d;
2009 union value v;
2010 GLmatrix *m;
2011 int shift, i;
2012 void *p;
2013
2014 d = find_value("glGetInteger64v", pname, &p, &v);
2015 switch (d->type) {
2016 case TYPE_INVALID:
2017 break;
2018 case TYPE_CONST:
2019 params[0] = d->offset;
2020 break;
2021
2022 case TYPE_FLOAT_4:
2023 params[3] = IROUND64(((GLfloat *) p)[3]);
2024 case TYPE_FLOAT_3:
2025 params[2] = IROUND64(((GLfloat *) p)[2]);
2026 case TYPE_FLOAT_2:
2027 params[1] = IROUND64(((GLfloat *) p)[1]);
2028 case TYPE_FLOAT:
2029 params[0] = IROUND64(((GLfloat *) p)[0]);
2030 break;
2031
2032 case TYPE_FLOATN_4:
2033 params[3] = FLOAT_TO_INT64(((GLfloat *) p)[3]);
2034 case TYPE_FLOATN_3:
2035 params[2] = FLOAT_TO_INT64(((GLfloat *) p)[2]);
2036 case TYPE_FLOATN_2:
2037 params[1] = FLOAT_TO_INT64(((GLfloat *) p)[1]);
2038 case TYPE_FLOATN:
2039 params[0] = FLOAT_TO_INT64(((GLfloat *) p)[0]);
2040 break;
2041
2042 case TYPE_DOUBLEN:
2043 params[0] = FLOAT_TO_INT64(((GLdouble *) p)[0]);
2044 break;
2045
2046 case TYPE_INT_4:
2047 params[3] = ((GLint *) p)[3];
2048 case TYPE_INT_3:
2049 params[2] = ((GLint *) p)[2];
2050 case TYPE_INT_2:
2051 case TYPE_ENUM_2:
2052 params[1] = ((GLint *) p)[1];
2053 case TYPE_INT:
2054 case TYPE_ENUM:
2055 params[0] = ((GLint *) p)[0];
2056 break;
2057
2058 case TYPE_INT_N:
2059 for (i = 0; i < v.value_int_n.n; i++)
2060 params[i] = INT_TO_BOOLEAN(v.value_int_n.ints[i]);
2061 break;
2062
2063 case TYPE_INT64:
2064 params[0] = ((GLint64 *) p)[0];
2065 break;
2066
2067 case TYPE_BOOLEAN:
2068 params[0] = ((GLboolean*) p)[0];
2069 break;
2070
2071 case TYPE_MATRIX:
2072 m = *(GLmatrix **) p;
2073 for (i = 0; i < 16; i++)
2074 params[i] = FLOAT_TO_INT64(m->m[i]);
2075 break;
2076
2077 case TYPE_MATRIX_T:
2078 m = *(GLmatrix **) p;
2079 for (i = 0; i < 16; i++)
2080 params[i] = FLOAT_TO_INT64(m->m[transpose[i]]);
2081 break;
2082
2083 case TYPE_BIT_0:
2084 case TYPE_BIT_1:
2085 case TYPE_BIT_2:
2086 case TYPE_BIT_3:
2087 case TYPE_BIT_4:
2088 case TYPE_BIT_5:
2089 shift = d->type - TYPE_BIT_0;
2090 params[0] = (*(GLbitfield *) p >> shift) & 1;
2091 break;
2092 }
2093 }
2094 #endif /* FEATURE_ARB_sync */
2095
2096 void GLAPIENTRY
2097 _mesa_GetDoublev(GLenum pname, GLdouble *params)
2098 {
2099 const struct value_desc *d;
2100 union value v;
2101 GLmatrix *m;
2102 int shift, i;
2103 void *p;
2104
2105 d = find_value("glGetDoublev", pname, &p, &v);
2106 switch (d->type) {
2107 case TYPE_INVALID:
2108 break;
2109 case TYPE_CONST:
2110 params[0] = d->offset;
2111 break;
2112
2113 case TYPE_FLOAT_4:
2114 case TYPE_FLOATN_4:
2115 params[3] = ((GLfloat *) p)[3];
2116 case TYPE_FLOAT_3:
2117 case TYPE_FLOATN_3:
2118 params[2] = ((GLfloat *) p)[2];
2119 case TYPE_FLOAT_2:
2120 case TYPE_FLOATN_2:
2121 params[1] = ((GLfloat *) p)[1];
2122 case TYPE_FLOAT:
2123 case TYPE_FLOATN:
2124 params[0] = ((GLfloat *) p)[0];
2125 break;
2126
2127 case TYPE_DOUBLEN:
2128 params[0] = ((GLdouble *) p)[0];
2129 break;
2130
2131 case TYPE_INT_4:
2132 params[3] = ((GLint *) p)[3];
2133 case TYPE_INT_3:
2134 params[2] = ((GLint *) p)[2];
2135 case TYPE_INT_2:
2136 case TYPE_ENUM_2:
2137 params[1] = ((GLint *) p)[1];
2138 case TYPE_INT:
2139 case TYPE_ENUM:
2140 params[0] = ((GLint *) p)[0];
2141 break;
2142
2143 case TYPE_INT_N:
2144 for (i = 0; i < v.value_int_n.n; i++)
2145 params[i] = v.value_int_n.ints[i];
2146 break;
2147
2148 case TYPE_INT64:
2149 params[0] = ((GLint64 *) p)[0];
2150 break;
2151
2152 case TYPE_BOOLEAN:
2153 params[0] = *(GLboolean*) p;
2154 break;
2155
2156 case TYPE_MATRIX:
2157 m = *(GLmatrix **) p;
2158 for (i = 0; i < 16; i++)
2159 params[i] = m->m[i];
2160 break;
2161
2162 case TYPE_MATRIX_T:
2163 m = *(GLmatrix **) p;
2164 for (i = 0; i < 16; i++)
2165 params[i] = m->m[transpose[i]];
2166 break;
2167
2168 case TYPE_BIT_0:
2169 case TYPE_BIT_1:
2170 case TYPE_BIT_2:
2171 case TYPE_BIT_3:
2172 case TYPE_BIT_4:
2173 case TYPE_BIT_5:
2174 shift = d->type - TYPE_BIT_0;
2175 params[0] = (*(GLbitfield *) p >> shift) & 1;
2176 break;
2177 }
2178 }
2179
2180 static enum value_type
2181 find_value_indexed(const char *func, GLenum pname, int index, union value *v)
2182 {
2183 GET_CURRENT_CONTEXT(ctx);
2184
2185 switch (pname) {
2186
2187 case GL_BLEND:
2188 if (index >= ctx->Const.MaxDrawBuffers)
2189 goto invalid_value;
2190 if (!ctx->Extensions.EXT_draw_buffers2)
2191 goto invalid_enum;
2192 v->value_int = (ctx->Color.BlendEnabled >> index) & 1;
2193 return TYPE_INT;
2194
2195 case GL_COLOR_WRITEMASK:
2196 if (index >= ctx->Const.MaxDrawBuffers)
2197 goto invalid_value;
2198 if (!ctx->Extensions.EXT_draw_buffers2)
2199 goto invalid_enum;
2200 v->value_int_4[0] = ctx->Color.ColorMask[index][RCOMP] ? 1 : 0;
2201 v->value_int_4[1] = ctx->Color.ColorMask[index][GCOMP] ? 1 : 0;
2202 v->value_int_4[2] = ctx->Color.ColorMask[index][BCOMP] ? 1 : 0;
2203 v->value_int_4[3] = ctx->Color.ColorMask[index][ACOMP] ? 1 : 0;
2204 return TYPE_INT_4;
2205
2206 case GL_TRANSFORM_FEEDBACK_BUFFER_START:
2207 if (index >= ctx->Const.MaxTransformFeedbackSeparateAttribs)
2208 goto invalid_value;
2209 if (!ctx->Extensions.EXT_transform_feedback)
2210 goto invalid_enum;
2211 v->value_int64 = ctx->TransformFeedback.CurrentObject->Offset[index];
2212 return TYPE_INT64;
2213
2214 case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE:
2215 if (index >= ctx->Const.MaxTransformFeedbackSeparateAttribs)
2216 goto invalid_value;
2217 if (!ctx->Extensions.EXT_transform_feedback)
2218 goto invalid_enum;
2219 v->value_int64 = ctx->TransformFeedback.CurrentObject->Size[index];
2220 return TYPE_INT64;
2221
2222 case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING:
2223 if (index >= ctx->Const.MaxTransformFeedbackSeparateAttribs)
2224 goto invalid_value;
2225 if (!ctx->Extensions.EXT_transform_feedback)
2226 goto invalid_enum;
2227 v->value_int = ctx->TransformFeedback.CurrentObject->Buffers[index]->Name;
2228 return TYPE_INT;
2229 }
2230
2231 invalid_enum:
2232 _mesa_error(ctx, GL_INVALID_ENUM, "%s(pname=%s)", func,
2233 _mesa_lookup_enum_by_nr(pname));
2234 return TYPE_INVALID;
2235 invalid_value:
2236 _mesa_error(ctx, GL_INVALID_VALUE, "%s(pname=%s)", func,
2237 _mesa_lookup_enum_by_nr(pname));
2238 return TYPE_INVALID;
2239 }
2240
2241 void GLAPIENTRY
2242 _mesa_GetBooleanIndexedv( GLenum pname, GLuint index, GLboolean *params )
2243 {
2244 union value v;
2245
2246 switch (find_value_indexed("glGetBooleanIndexedv", pname, index, &v)) {
2247 case TYPE_INT:
2248 params[0] = INT_TO_BOOLEAN(v.value_int);
2249 break;
2250 case TYPE_INT_4:
2251 params[0] = INT_TO_BOOLEAN(v.value_int_4[0]);
2252 params[1] = INT_TO_BOOLEAN(v.value_int_4[1]);
2253 params[2] = INT_TO_BOOLEAN(v.value_int_4[2]);
2254 params[3] = INT_TO_BOOLEAN(v.value_int_4[3]);
2255 break;
2256 case TYPE_INT64:
2257 params[0] = INT64_TO_BOOLEAN(v.value_int);
2258 break;
2259 default:
2260 assert(0);
2261 }
2262 }
2263
2264 void GLAPIENTRY
2265 _mesa_GetIntegerIndexedv( GLenum pname, GLuint index, GLint *params )
2266 {
2267 union value v;
2268
2269 switch (find_value_indexed("glGetIntegerIndexedv", pname, index, &v)) {
2270 case TYPE_INT:
2271 params[0] = v.value_int;
2272 break;
2273 case TYPE_INT_4:
2274 params[0] = v.value_int_4[0];
2275 params[1] = v.value_int_4[1];
2276 params[2] = v.value_int_4[2];
2277 params[3] = v.value_int_4[3];
2278 break;
2279 case TYPE_INT64:
2280 params[0] = INT64_TO_INT(v.value_int);
2281 break;
2282 default:
2283 assert(0);
2284 }
2285 }
2286
2287 #if FEATURE_ARB_sync
2288 void GLAPIENTRY
2289 _mesa_GetInteger64Indexedv( GLenum pname, GLuint index, GLint64 *params )
2290 {
2291 union value v;
2292
2293 switch (find_value_indexed("glGetIntegerIndexedv", pname, index, &v)) {
2294 case TYPE_INT:
2295 params[0] = v.value_int;
2296 break;
2297 case TYPE_INT_4:
2298 params[0] = v.value_int_4[0];
2299 params[1] = v.value_int_4[1];
2300 params[2] = v.value_int_4[2];
2301 params[3] = v.value_int_4[3];
2302 break;
2303 case TYPE_INT64:
2304 params[0] = v.value_int;
2305 break;
2306 default:
2307 assert(0);
2308 }
2309 }
2310 #endif /* FEATURE_ARB_sync */
2311
2312 #if FEATURE_ES1
2313 void GLAPIENTRY
2314 _mesa_GetFixedv(GLenum pname, GLfixed *params)
2315 {
2316 const struct value_desc *d;
2317 union value v;
2318 GLmatrix *m;
2319 int shift, i;
2320 void *p;
2321
2322 d = find_value("glGetDoublev", pname, &p, &v);
2323 switch (d->type) {
2324 case TYPE_INVALID:
2325 break;
2326 case TYPE_CONST:
2327 params[0] = INT_TO_FIXED(d->offset);
2328 break;
2329
2330 case TYPE_FLOAT_4:
2331 case TYPE_FLOATN_4:
2332 params[3] = FLOAT_TO_FIXED(((GLfloat *) p)[3]);
2333 case TYPE_FLOAT_3:
2334 case TYPE_FLOATN_3:
2335 params[2] = FLOAT_TO_FIXED(((GLfloat *) p)[2]);
2336 case TYPE_FLOAT_2:
2337 case TYPE_FLOATN_2:
2338 params[1] = FLOAT_TO_FIXED(((GLfloat *) p)[1]);
2339 case TYPE_FLOAT:
2340 case TYPE_FLOATN:
2341 params[0] = FLOAT_TO_FIXED(((GLfloat *) p)[0]);
2342 break;
2343
2344 case TYPE_DOUBLEN:
2345 params[0] = FLOAT_TO_FIXED(((GLdouble *) p)[0]);
2346 break;
2347
2348 case TYPE_INT_4:
2349 params[3] = INT_TO_FIXED(((GLint *) p)[3]);
2350 case TYPE_INT_3:
2351 params[2] = INT_TO_FIXED(((GLint *) p)[2]);
2352 case TYPE_INT_2:
2353 case TYPE_ENUM_2:
2354 params[1] = INT_TO_FIXED(((GLint *) p)[1]);
2355 case TYPE_INT:
2356 case TYPE_ENUM:
2357 params[0] = INT_TO_FIXED(((GLint *) p)[0]);
2358 break;
2359
2360 case TYPE_INT_N:
2361 for (i = 0; i < v.value_int_n.n; i++)
2362 params[i] = INT_TO_FIXED(v.value_int_n.ints[i]);
2363 break;
2364
2365 case TYPE_INT64:
2366 params[0] = ((GLint64 *) p)[0];
2367 break;
2368
2369 case TYPE_BOOLEAN:
2370 params[0] = BOOLEAN_TO_FIXED(((GLboolean*) p)[0]);
2371 break;
2372
2373 case TYPE_MATRIX:
2374 m = *(GLmatrix **) p;
2375 for (i = 0; i < 16; i++)
2376 params[i] = FLOAT_TO_FIXED(m->m[i]);
2377 break;
2378
2379 case TYPE_MATRIX_T:
2380 m = *(GLmatrix **) p;
2381 for (i = 0; i < 16; i++)
2382 params[i] = FLOAT_TO_FIXED(m->m[transpose[i]]);
2383 break;
2384
2385 case TYPE_BIT_0:
2386 case TYPE_BIT_1:
2387 case TYPE_BIT_2:
2388 case TYPE_BIT_3:
2389 case TYPE_BIT_4:
2390 case TYPE_BIT_5:
2391 shift = d->type - TYPE_BIT_0;
2392 params[0] = BOOLEAN_TO_FIXED((*(GLbitfield *) p >> shift) & 1);
2393 break;
2394 }
2395 }
2396 #endif