2 * Copyright (C) 2010 Brian Paul All Rights Reserved.
3 * Copyright (C) 2010 Intel Corporation
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:
12 * The above copyright notice and this permission notice shall be included
13 * in all copies or substantial portions of the Software.
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.
22 * Author: Kristian Høgsberg <krh@bitplanet.net>
29 #include "extensions.h"
32 #include "mfeatures.h"
35 #include "framebuffer.h"
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 struct gl_context 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 struct gl_context 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.
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 struct gl_context. And sometimes the value isn't in
49 * struct gl_context 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
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.
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) )
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) )
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))) )
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 )
83 #define ENUM_TO_INT64(E) ( (GLint64) (E) )
84 #define ENUM_TO_FIXED(E) (E)
119 enum value_location
{
133 EXTRA_VALID_TEXTURE_UNIT
,
134 EXTRA_VALID_CLIP_DISTANCE
,
139 #define NO_EXTRA NULL
144 GLubyte location
; /**< enum value_location */
145 GLubyte type
; /**< enum value_type */
152 GLfloat value_float_4
[4];
153 GLmatrix
*value_matrix
;
155 GLint value_int_4
[4];
159 /* Sigh, see GL_COMPRESSED_TEXTURE_FORMATS_ARB handling */
163 GLboolean value_bool
;
166 #define BUFFER_FIELD(field, type) \
167 LOC_BUFFER, type, offsetof(struct gl_framebuffer, field)
168 #define CONTEXT_FIELD(field, type) \
169 LOC_CONTEXT, type, offsetof(struct gl_context, field)
170 #define ARRAY_FIELD(field, type) \
171 LOC_ARRAY, type, offsetof(struct gl_array_object, field)
172 #define CONST(value) \
173 LOC_CONTEXT, TYPE_CONST, value
175 #define BUFFER_INT(field) BUFFER_FIELD(field, TYPE_INT)
176 #define BUFFER_ENUM(field) BUFFER_FIELD(field, TYPE_ENUM)
177 #define BUFFER_BOOL(field) BUFFER_FIELD(field, TYPE_BOOLEAN)
179 #define CONTEXT_INT(field) CONTEXT_FIELD(field, TYPE_INT)
180 #define CONTEXT_INT2(field) CONTEXT_FIELD(field, TYPE_INT_2)
181 #define CONTEXT_INT64(field) CONTEXT_FIELD(field, TYPE_INT64)
182 #define CONTEXT_ENUM(field) CONTEXT_FIELD(field, TYPE_ENUM)
183 #define CONTEXT_ENUM2(field) CONTEXT_FIELD(field, TYPE_ENUM_2)
184 #define CONTEXT_BOOL(field) CONTEXT_FIELD(field, TYPE_BOOLEAN)
185 #define CONTEXT_BIT0(field) CONTEXT_FIELD(field, TYPE_BIT_0)
186 #define CONTEXT_BIT1(field) CONTEXT_FIELD(field, TYPE_BIT_1)
187 #define CONTEXT_BIT2(field) CONTEXT_FIELD(field, TYPE_BIT_2)
188 #define CONTEXT_BIT3(field) CONTEXT_FIELD(field, TYPE_BIT_3)
189 #define CONTEXT_BIT4(field) CONTEXT_FIELD(field, TYPE_BIT_4)
190 #define CONTEXT_BIT5(field) CONTEXT_FIELD(field, TYPE_BIT_5)
191 #define CONTEXT_BIT6(field) CONTEXT_FIELD(field, TYPE_BIT_6)
192 #define CONTEXT_BIT7(field) CONTEXT_FIELD(field, TYPE_BIT_7)
193 #define CONTEXT_FLOAT(field) CONTEXT_FIELD(field, TYPE_FLOAT)
194 #define CONTEXT_FLOAT2(field) CONTEXT_FIELD(field, TYPE_FLOAT_2)
195 #define CONTEXT_FLOAT3(field) CONTEXT_FIELD(field, TYPE_FLOAT_3)
196 #define CONTEXT_FLOAT4(field) CONTEXT_FIELD(field, TYPE_FLOAT_4)
197 #define CONTEXT_MATRIX(field) CONTEXT_FIELD(field, TYPE_MATRIX)
198 #define CONTEXT_MATRIX_T(field) CONTEXT_FIELD(field, TYPE_MATRIX_T)
200 #define ARRAY_INT(field) ARRAY_FIELD(field, TYPE_INT)
201 #define ARRAY_ENUM(field) ARRAY_FIELD(field, TYPE_ENUM)
202 #define ARRAY_BOOL(field) ARRAY_FIELD(field, TYPE_BOOLEAN)
205 offsetof(struct gl_extensions, f)
207 #define EXTRA_EXT(e) \
208 static const int extra_##e[] = { \
212 #define EXTRA_EXT2(e1, e2) \
213 static const int extra_##e1##_##e2[] = { \
214 EXT(e1), EXT(e2), EXTRA_END \
217 /* The 'extra' mechanism is a way to specify extra checks (such as
218 * extensions or specific gl versions) or actions (flush current, new
219 * buffers) that we need to do before looking up an enum. We need to
220 * declare them all up front so we can refer to them in the value_desc
223 static const int extra_new_buffers
[] = {
228 static const int extra_valid_texture_unit
[] = {
229 EXTRA_VALID_TEXTURE_UNIT
,
233 static const int extra_valid_clip_distance
[] = {
234 EXTRA_VALID_CLIP_DISTANCE
,
238 static const int extra_flush_current_valid_texture_unit
[] = {
240 EXTRA_VALID_TEXTURE_UNIT
,
244 static const int extra_flush_current
[] = {
249 static const int extra_EXT_secondary_color_flush_current
[] = {
250 EXT(EXT_secondary_color
),
255 static const int extra_EXT_fog_coord_flush_current
[] = {
261 static const int extra_EXT_texture_integer
[] = {
262 EXT(EXT_texture_integer
),
266 static const int extra_GLSL_130
[] = {
272 EXTRA_EXT(ARB_texture_cube_map
);
273 EXTRA_EXT2(EXT_secondary_color
, ARB_vertex_program
);
274 EXTRA_EXT(EXT_secondary_color
);
275 EXTRA_EXT(EXT_fog_coord
);
276 EXTRA_EXT(NV_fog_distance
);
277 EXTRA_EXT(EXT_texture_filter_anisotropic
);
278 EXTRA_EXT(IBM_rasterpos_clip
);
279 EXTRA_EXT(NV_point_sprite
);
280 EXTRA_EXT(NV_vertex_program
);
281 EXTRA_EXT(NV_fragment_program
);
282 EXTRA_EXT(EXT_stencil_two_side
);
283 EXTRA_EXT(NV_light_max_exponent
);
284 EXTRA_EXT(EXT_depth_bounds_test
);
285 EXTRA_EXT(ARB_shader_objects
);
286 EXTRA_EXT(ARB_fragment_shader
);
287 EXTRA_EXT(ARB_fragment_program
);
288 EXTRA_EXT(APPLE_vertex_array_object
);
289 EXTRA_EXT(EXT_compiled_vertex_array
);
290 EXTRA_EXT(ARB_vertex_shader
);
291 EXTRA_EXT(EXT_pixel_buffer_object
);
292 EXTRA_EXT(ARB_vertex_program
);
293 EXTRA_EXT2(NV_point_sprite
, ARB_point_sprite
);
294 EXTRA_EXT2(ARB_fragment_program
, NV_fragment_program
);
295 EXTRA_EXT2(ARB_vertex_program
, NV_vertex_program
);
296 EXTRA_EXT2(ARB_vertex_program
, ARB_fragment_program
);
299 extra_ARB_vertex_program_ARB_fragment_program_NV_vertex_program
[] = {
300 EXT(ARB_vertex_program
),
301 EXT(ARB_fragment_program
),
302 EXT(NV_vertex_program
),
307 extra_NV_vertex_program_ARB_vertex_program_ARB_fragment_program_NV_vertex_program
[] = {
308 EXT(NV_vertex_program
),
309 EXT(ARB_vertex_program
),
310 EXT(ARB_fragment_program
),
311 EXT(NV_vertex_program
),
315 static const int extra_version_30
[] = { EXTRA_VERSION_30
, EXTRA_END
};
316 static const int extra_version_31
[] = { EXTRA_VERSION_31
, EXTRA_END
};
317 static const int extra_version_32
[] = { EXTRA_VERSION_32
, EXTRA_END
};
319 #define API_OPENGL_BIT (1 << API_OPENGL)
321 /* This is the big table describing all the enums we accept in
322 * glGet*v(). The table is partitioned into six parts: enums
323 * understood by all GL APIs (OpenGL, GLES and GLES2), enums shared
324 * between OpenGL and GLES, enums exclusive to GLES, etc for the
325 * remaining combinations. When we add the enums to the hash table in
326 * _mesa_init_get_hash(), we only add the enums for the API we're
327 * instantiating and the different sections are guarded by #if
328 * FEATURE_GL etc to make sure we only compile in the enums we may
331 static const struct value_desc values
[] = {
332 { GL_ALPHA_BITS
, BUFFER_INT(Visual
.alphaBits
), extra_new_buffers
},
333 { GL_BLEND
, CONTEXT_BIT0(Color
.BlendEnabled
), NO_EXTRA
},
334 { GL_BLEND_SRC
, CONTEXT_ENUM(Color
.SrcRGB
), NO_EXTRA
},
335 { GL_BLUE_BITS
, BUFFER_INT(Visual
.blueBits
), extra_new_buffers
},
336 { GL_COLOR_CLEAR_VALUE
, LOC_CUSTOM
, TYPE_FLOATN_4
, 0, NO_EXTRA
},
337 { GL_COLOR_WRITEMASK
, LOC_CUSTOM
, TYPE_INT_4
, 0, NO_EXTRA
},
338 { GL_CULL_FACE
, CONTEXT_BOOL(Polygon
.CullFlag
), NO_EXTRA
},
339 { GL_CULL_FACE_MODE
, CONTEXT_ENUM(Polygon
.CullFaceMode
), NO_EXTRA
},
340 { GL_DEPTH_BITS
, BUFFER_INT(Visual
.depthBits
), NO_EXTRA
},
341 { GL_DEPTH_CLEAR_VALUE
, CONTEXT_FIELD(Depth
.Clear
, TYPE_DOUBLEN
), NO_EXTRA
},
342 { GL_DEPTH_FUNC
, CONTEXT_ENUM(Depth
.Func
), NO_EXTRA
},
343 { GL_DEPTH_RANGE
, CONTEXT_FIELD(Viewport
.Near
, TYPE_FLOATN_2
), NO_EXTRA
},
344 { GL_DEPTH_TEST
, CONTEXT_BOOL(Depth
.Test
), NO_EXTRA
},
345 { GL_DEPTH_WRITEMASK
, CONTEXT_BOOL(Depth
.Mask
), NO_EXTRA
},
346 { GL_DITHER
, CONTEXT_BOOL(Color
.DitherFlag
), NO_EXTRA
},
347 { GL_FRONT_FACE
, CONTEXT_ENUM(Polygon
.FrontFace
), NO_EXTRA
},
348 { GL_GREEN_BITS
, BUFFER_INT(Visual
.greenBits
), extra_new_buffers
},
349 { GL_LINE_WIDTH
, CONTEXT_FLOAT(Line
.Width
), NO_EXTRA
},
350 { GL_ALIASED_LINE_WIDTH_RANGE
, CONTEXT_FLOAT2(Const
.MinLineWidth
), NO_EXTRA
},
351 { GL_MAX_ELEMENTS_VERTICES
, CONTEXT_INT(Const
.MaxArrayLockSize
), NO_EXTRA
},
352 { GL_MAX_ELEMENTS_INDICES
, CONTEXT_INT(Const
.MaxArrayLockSize
), NO_EXTRA
},
353 { GL_MAX_TEXTURE_SIZE
, LOC_CUSTOM
, TYPE_INT
,
354 offsetof(struct gl_context
, Const
.MaxTextureLevels
), NO_EXTRA
},
355 { GL_MAX_VIEWPORT_DIMS
, CONTEXT_INT2(Const
.MaxViewportWidth
), NO_EXTRA
},
356 { GL_PACK_ALIGNMENT
, CONTEXT_INT(Pack
.Alignment
), NO_EXTRA
},
357 { GL_ALIASED_POINT_SIZE_RANGE
, CONTEXT_FLOAT2(Const
.MinPointSize
), NO_EXTRA
},
358 { GL_POLYGON_OFFSET_FACTOR
, CONTEXT_FLOAT(Polygon
.OffsetFactor
), NO_EXTRA
},
359 { GL_POLYGON_OFFSET_UNITS
, CONTEXT_FLOAT(Polygon
.OffsetUnits
), NO_EXTRA
},
360 { GL_POLYGON_OFFSET_FILL
, CONTEXT_BOOL(Polygon
.OffsetFill
), NO_EXTRA
},
361 { GL_RED_BITS
, BUFFER_INT(Visual
.redBits
), extra_new_buffers
},
362 { GL_SCISSOR_BOX
, LOC_CUSTOM
, TYPE_INT_4
, 0, NO_EXTRA
},
363 { GL_SCISSOR_TEST
, CONTEXT_BOOL(Scissor
.Enabled
), NO_EXTRA
},
364 { GL_STENCIL_BITS
, BUFFER_INT(Visual
.stencilBits
), NO_EXTRA
},
365 { GL_STENCIL_CLEAR_VALUE
, CONTEXT_INT(Stencil
.Clear
), NO_EXTRA
},
366 { GL_STENCIL_FAIL
, LOC_CUSTOM
, TYPE_ENUM
, NO_OFFSET
, NO_EXTRA
},
367 { GL_STENCIL_FUNC
, LOC_CUSTOM
, TYPE_ENUM
, NO_OFFSET
, NO_EXTRA
},
368 { GL_STENCIL_PASS_DEPTH_FAIL
, LOC_CUSTOM
, TYPE_ENUM
, NO_OFFSET
, NO_EXTRA
},
369 { GL_STENCIL_PASS_DEPTH_PASS
, LOC_CUSTOM
, TYPE_ENUM
, NO_OFFSET
, NO_EXTRA
},
370 { GL_STENCIL_REF
, LOC_CUSTOM
, TYPE_INT
, NO_OFFSET
, NO_EXTRA
},
371 { GL_STENCIL_TEST
, CONTEXT_BOOL(Stencil
.Enabled
), NO_EXTRA
},
372 { GL_STENCIL_VALUE_MASK
, LOC_CUSTOM
, TYPE_INT
, NO_OFFSET
, NO_EXTRA
},
373 { GL_STENCIL_WRITEMASK
, LOC_CUSTOM
, TYPE_INT
, NO_OFFSET
, NO_EXTRA
},
374 { GL_SUBPIXEL_BITS
, CONTEXT_INT(Const
.SubPixelBits
), NO_EXTRA
},
375 { GL_TEXTURE_BINDING_2D
, LOC_CUSTOM
, TYPE_INT
, TEXTURE_2D_INDEX
, NO_EXTRA
},
376 { GL_UNPACK_ALIGNMENT
, CONTEXT_INT(Unpack
.Alignment
), NO_EXTRA
},
377 { GL_VIEWPORT
, LOC_CUSTOM
, TYPE_INT_4
, 0, NO_EXTRA
},
379 /* GL_ARB_multitexture */
380 { GL_ACTIVE_TEXTURE
, LOC_CUSTOM
, TYPE_INT
, 0, NO_EXTRA
},
382 /* Note that all the OES_* extensions require that the Mesa "struct
383 * gl_extensions" include a member with the name of the extension.
384 * That structure does not yet include OES extensions (and we're
385 * not sure whether it will). If it does, all the OES_*
386 * extensions below should mark the dependency. */
388 /* GL_ARB_texture_cube_map */
389 { GL_TEXTURE_BINDING_CUBE_MAP_ARB
, LOC_CUSTOM
, TYPE_INT
,
390 TEXTURE_CUBE_INDEX
, extra_ARB_texture_cube_map
},
391 { GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB
, LOC_CUSTOM
, TYPE_INT
,
392 offsetof(struct gl_context
, Const
.MaxCubeTextureLevels
),
393 extra_ARB_texture_cube_map
}, /* XXX: OES_texture_cube_map */
395 /* XXX: OES_blend_subtract */
396 { GL_BLEND_SRC_RGB_EXT
, CONTEXT_ENUM(Color
.SrcRGB
), NO_EXTRA
},
397 { GL_BLEND_DST_RGB_EXT
, CONTEXT_ENUM(Color
.DstRGB
), NO_EXTRA
},
398 { GL_BLEND_SRC_ALPHA_EXT
, CONTEXT_ENUM(Color
.SrcA
), NO_EXTRA
},
399 { GL_BLEND_DST_ALPHA_EXT
, CONTEXT_ENUM(Color
.DstA
), NO_EXTRA
},
401 /* GL_BLEND_EQUATION_RGB, which is what we're really after, is
402 * defined identically to GL_BLEND_EQUATION. */
403 { GL_BLEND_EQUATION
, CONTEXT_ENUM(Color
.EquationRGB
), NO_EXTRA
},
404 { GL_BLEND_EQUATION_ALPHA_EXT
, CONTEXT_ENUM(Color
.EquationA
), NO_EXTRA
},
406 /* GL_ARB_texture_compression */
407 { GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB
, LOC_CUSTOM
, TYPE_INT
, 0, NO_EXTRA
},
408 { GL_COMPRESSED_TEXTURE_FORMATS_ARB
, LOC_CUSTOM
, TYPE_INT_N
, 0, NO_EXTRA
},
410 /* GL_ARB_multisample */
411 { GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
,
412 CONTEXT_BOOL(Multisample
.SampleAlphaToCoverage
), NO_EXTRA
},
413 { GL_SAMPLE_COVERAGE_ARB
, CONTEXT_BOOL(Multisample
.SampleCoverage
), NO_EXTRA
},
414 { GL_SAMPLE_COVERAGE_VALUE_ARB
,
415 CONTEXT_FLOAT(Multisample
.SampleCoverageValue
), NO_EXTRA
},
416 { GL_SAMPLE_COVERAGE_INVERT_ARB
,
417 CONTEXT_BOOL(Multisample
.SampleCoverageInvert
), NO_EXTRA
},
419 /* GL_ARB_vertex_buffer_object */
420 { GL_ARRAY_BUFFER_BINDING_ARB
, LOC_CUSTOM
, TYPE_INT
, 0, NO_EXTRA
},
422 /* GL_ARB_vertex_buffer_object */
423 /* GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB - not supported */
424 { GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB
, LOC_CUSTOM
, TYPE_INT
, 0, NO_EXTRA
},
426 /* GL_OES_read_format */
427 { GL_IMPLEMENTATION_COLOR_READ_TYPE_OES
, LOC_CUSTOM
, TYPE_INT
, 0,
429 { GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES
, LOC_CUSTOM
, TYPE_INT
, 0,
432 /* This entry isn't spec'ed for GLES 2, but is needed for Mesa's
434 { GL_MAX_CLIP_PLANES
, CONTEXT_INT(Const
.MaxClipPlanes
), NO_EXTRA
},
436 { GL_MAX_LIGHTS
, CONTEXT_INT(Const
.MaxLights
), NO_EXTRA
},
437 { GL_LIGHT0
, CONTEXT_BOOL(Light
.Light
[0].Enabled
), NO_EXTRA
},
438 { GL_LIGHT1
, CONTEXT_BOOL(Light
.Light
[1].Enabled
), NO_EXTRA
},
439 { GL_LIGHT2
, CONTEXT_BOOL(Light
.Light
[2].Enabled
), NO_EXTRA
},
440 { GL_LIGHT3
, CONTEXT_BOOL(Light
.Light
[3].Enabled
), NO_EXTRA
},
441 { GL_LIGHT4
, CONTEXT_BOOL(Light
.Light
[4].Enabled
), NO_EXTRA
},
442 { GL_LIGHT5
, CONTEXT_BOOL(Light
.Light
[5].Enabled
), NO_EXTRA
},
443 { GL_LIGHT6
, CONTEXT_BOOL(Light
.Light
[6].Enabled
), NO_EXTRA
},
444 { GL_LIGHT7
, CONTEXT_BOOL(Light
.Light
[7].Enabled
), NO_EXTRA
},
445 { GL_LIGHTING
, CONTEXT_BOOL(Light
.Enabled
), NO_EXTRA
},
446 { GL_LIGHT_MODEL_AMBIENT
,
447 CONTEXT_FIELD(Light
.Model
.Ambient
[0], TYPE_FLOATN_4
), NO_EXTRA
},
448 { GL_LIGHT_MODEL_TWO_SIDE
, CONTEXT_BOOL(Light
.Model
.TwoSide
), NO_EXTRA
},
449 { GL_ALPHA_TEST
, CONTEXT_BOOL(Color
.AlphaEnabled
), NO_EXTRA
},
450 { GL_ALPHA_TEST_FUNC
, CONTEXT_ENUM(Color
.AlphaFunc
), NO_EXTRA
},
451 { GL_ALPHA_TEST_REF
, LOC_CUSTOM
, TYPE_FLOATN
, 0, NO_EXTRA
},
452 { GL_BLEND_DST
, CONTEXT_ENUM(Color
.DstRGB
), NO_EXTRA
},
453 { GL_CLIP_DISTANCE0
, CONTEXT_BIT0(Transform
.ClipPlanesEnabled
), extra_valid_clip_distance
},
454 { GL_CLIP_DISTANCE1
, CONTEXT_BIT1(Transform
.ClipPlanesEnabled
), extra_valid_clip_distance
},
455 { GL_CLIP_DISTANCE2
, CONTEXT_BIT2(Transform
.ClipPlanesEnabled
), extra_valid_clip_distance
},
456 { GL_CLIP_DISTANCE3
, CONTEXT_BIT3(Transform
.ClipPlanesEnabled
), extra_valid_clip_distance
},
457 { GL_CLIP_DISTANCE4
, CONTEXT_BIT4(Transform
.ClipPlanesEnabled
), extra_valid_clip_distance
},
458 { GL_CLIP_DISTANCE5
, CONTEXT_BIT5(Transform
.ClipPlanesEnabled
), extra_valid_clip_distance
},
459 { GL_CLIP_DISTANCE6
, CONTEXT_BIT6(Transform
.ClipPlanesEnabled
), extra_valid_clip_distance
},
460 { GL_CLIP_DISTANCE7
, CONTEXT_BIT7(Transform
.ClipPlanesEnabled
), extra_valid_clip_distance
},
461 { GL_COLOR_MATERIAL
, CONTEXT_BOOL(Light
.ColorMaterialEnabled
), NO_EXTRA
},
463 CONTEXT_FIELD(Current
.Attrib
[VERT_ATTRIB_COLOR0
][0], TYPE_FLOATN_4
),
464 extra_flush_current
},
466 CONTEXT_FIELD(Current
.Attrib
[VERT_ATTRIB_NORMAL
][0], TYPE_FLOATN_3
),
467 extra_flush_current
},
468 { GL_CURRENT_TEXTURE_COORDS
, LOC_CUSTOM
, TYPE_FLOAT_4
, 0,
469 extra_flush_current_valid_texture_unit
},
470 { GL_DISTANCE_ATTENUATION_EXT
, CONTEXT_FLOAT3(Point
.Params
[0]), NO_EXTRA
},
471 { GL_FOG
, CONTEXT_BOOL(Fog
.Enabled
), NO_EXTRA
},
472 { GL_FOG_COLOR
, LOC_CUSTOM
, TYPE_FLOATN_4
, 0, NO_EXTRA
},
473 { GL_FOG_DENSITY
, CONTEXT_FLOAT(Fog
.Density
), NO_EXTRA
},
474 { GL_FOG_END
, CONTEXT_FLOAT(Fog
.End
), NO_EXTRA
},
475 { GL_FOG_HINT
, CONTEXT_ENUM(Hint
.Fog
), NO_EXTRA
},
476 { GL_FOG_MODE
, CONTEXT_ENUM(Fog
.Mode
), NO_EXTRA
},
477 { GL_FOG_START
, CONTEXT_FLOAT(Fog
.Start
), NO_EXTRA
},
478 { GL_LINE_SMOOTH
, CONTEXT_BOOL(Line
.SmoothFlag
), NO_EXTRA
},
479 { GL_LINE_SMOOTH_HINT
, CONTEXT_ENUM(Hint
.LineSmooth
), NO_EXTRA
},
480 { GL_LINE_WIDTH_RANGE
, CONTEXT_FLOAT2(Const
.MinLineWidthAA
), NO_EXTRA
},
481 { GL_COLOR_LOGIC_OP
, CONTEXT_BOOL(Color
.ColorLogicOpEnabled
), NO_EXTRA
},
482 { GL_LOGIC_OP_MODE
, CONTEXT_ENUM(Color
.LogicOp
), NO_EXTRA
},
483 { GL_MATRIX_MODE
, CONTEXT_ENUM(Transform
.MatrixMode
), NO_EXTRA
},
484 { GL_MAX_MODELVIEW_STACK_DEPTH
, CONST(MAX_MODELVIEW_STACK_DEPTH
), NO_EXTRA
},
485 { GL_MAX_PROJECTION_STACK_DEPTH
, CONST(MAX_PROJECTION_STACK_DEPTH
), NO_EXTRA
},
486 { GL_MAX_TEXTURE_STACK_DEPTH
, CONST(MAX_TEXTURE_STACK_DEPTH
), NO_EXTRA
},
487 { GL_MODELVIEW_MATRIX
, CONTEXT_MATRIX(ModelviewMatrixStack
.Top
), NO_EXTRA
},
488 { GL_MODELVIEW_STACK_DEPTH
, LOC_CUSTOM
, TYPE_INT
,
489 offsetof(struct gl_context
, ModelviewMatrixStack
.Depth
), NO_EXTRA
},
490 { GL_NORMALIZE
, CONTEXT_BOOL(Transform
.Normalize
), NO_EXTRA
},
491 { GL_PACK_SKIP_IMAGES_EXT
, CONTEXT_INT(Pack
.SkipImages
), NO_EXTRA
},
492 { GL_PERSPECTIVE_CORRECTION_HINT
, CONTEXT_ENUM(Hint
.PerspectiveCorrection
), NO_EXTRA
},
493 { GL_POINT_SIZE
, CONTEXT_FLOAT(Point
.Size
), NO_EXTRA
},
494 { GL_POINT_SIZE_RANGE
, CONTEXT_FLOAT2(Const
.MinPointSizeAA
), NO_EXTRA
},
495 { GL_POINT_SMOOTH
, CONTEXT_BOOL(Point
.SmoothFlag
), NO_EXTRA
},
496 { GL_POINT_SMOOTH_HINT
, CONTEXT_ENUM(Hint
.PointSmooth
), NO_EXTRA
},
497 { GL_POINT_SIZE_MIN_EXT
, CONTEXT_FLOAT(Point
.MinSize
), NO_EXTRA
},
498 { GL_POINT_SIZE_MAX_EXT
, CONTEXT_FLOAT(Point
.MaxSize
), NO_EXTRA
},
499 { GL_POINT_FADE_THRESHOLD_SIZE_EXT
, CONTEXT_FLOAT(Point
.Threshold
), NO_EXTRA
},
500 { GL_PROJECTION_MATRIX
, CONTEXT_MATRIX(ProjectionMatrixStack
.Top
), NO_EXTRA
},
501 { GL_PROJECTION_STACK_DEPTH
, LOC_CUSTOM
, TYPE_INT
,
502 offsetof(struct gl_context
, ProjectionMatrixStack
.Depth
), NO_EXTRA
},
503 { GL_RESCALE_NORMAL
, CONTEXT_BOOL(Transform
.RescaleNormals
), NO_EXTRA
},
504 { GL_SHADE_MODEL
, CONTEXT_ENUM(Light
.ShadeModel
), NO_EXTRA
},
505 { GL_TEXTURE_2D
, LOC_CUSTOM
, TYPE_BOOLEAN
, 0, NO_EXTRA
},
506 { GL_TEXTURE_MATRIX
, LOC_CUSTOM
, TYPE_MATRIX
, 0, extra_valid_texture_unit
},
507 { GL_TEXTURE_STACK_DEPTH
, LOC_CUSTOM
, TYPE_INT
, 0,
508 extra_valid_texture_unit
},
510 { GL_VERTEX_ARRAY
, ARRAY_BOOL(VertexAttrib
[VERT_ATTRIB_POS
].Enabled
), NO_EXTRA
},
511 { GL_VERTEX_ARRAY_SIZE
, ARRAY_INT(VertexAttrib
[VERT_ATTRIB_POS
].Size
), NO_EXTRA
},
512 { GL_VERTEX_ARRAY_TYPE
, ARRAY_ENUM(VertexAttrib
[VERT_ATTRIB_POS
].Type
), NO_EXTRA
},
513 { GL_VERTEX_ARRAY_STRIDE
, ARRAY_INT(VertexAttrib
[VERT_ATTRIB_POS
].Stride
), NO_EXTRA
},
514 { GL_NORMAL_ARRAY
, ARRAY_BOOL(VertexAttrib
[VERT_ATTRIB_NORMAL
].Enabled
), NO_EXTRA
},
515 { GL_NORMAL_ARRAY_TYPE
, ARRAY_ENUM(VertexAttrib
[VERT_ATTRIB_NORMAL
].Type
), NO_EXTRA
},
516 { GL_NORMAL_ARRAY_STRIDE
, ARRAY_INT(VertexAttrib
[VERT_ATTRIB_NORMAL
].Stride
), NO_EXTRA
},
517 { GL_COLOR_ARRAY
, ARRAY_BOOL(VertexAttrib
[VERT_ATTRIB_COLOR0
].Enabled
), NO_EXTRA
},
518 { GL_COLOR_ARRAY_SIZE
, ARRAY_INT(VertexAttrib
[VERT_ATTRIB_COLOR0
].Size
), NO_EXTRA
},
519 { GL_COLOR_ARRAY_TYPE
, ARRAY_ENUM(VertexAttrib
[VERT_ATTRIB_COLOR0
].Type
), NO_EXTRA
},
520 { GL_COLOR_ARRAY_STRIDE
, ARRAY_INT(VertexAttrib
[VERT_ATTRIB_COLOR0
].Stride
), NO_EXTRA
},
521 { GL_TEXTURE_COORD_ARRAY
,
522 LOC_CUSTOM
, TYPE_BOOLEAN
, offsetof(struct gl_client_array
, Enabled
), NO_EXTRA
},
523 { GL_TEXTURE_COORD_ARRAY_SIZE
,
524 LOC_CUSTOM
, TYPE_INT
, offsetof(struct gl_client_array
, Size
), NO_EXTRA
},
525 { GL_TEXTURE_COORD_ARRAY_TYPE
,
526 LOC_CUSTOM
, TYPE_ENUM
, offsetof(struct gl_client_array
, Type
), NO_EXTRA
},
527 { GL_TEXTURE_COORD_ARRAY_STRIDE
,
528 LOC_CUSTOM
, TYPE_INT
, offsetof(struct gl_client_array
, Stride
), NO_EXTRA
},
530 /* GL_ARB_multitexture */
531 { GL_MAX_TEXTURE_UNITS
, CONTEXT_INT(Const
.MaxTextureUnits
), NO_EXTRA
},
532 { GL_CLIENT_ACTIVE_TEXTURE
, LOC_CUSTOM
, TYPE_INT
, 0, NO_EXTRA
},
534 /* GL_ARB_texture_cube_map */
535 { GL_TEXTURE_CUBE_MAP_ARB
, LOC_CUSTOM
, TYPE_BOOLEAN
, 0, NO_EXTRA
},
536 /* S, T, and R are always set at the same time */
537 { GL_TEXTURE_GEN_STR_OES
, LOC_TEXUNIT
, TYPE_BIT_0
,
538 offsetof(struct gl_texture_unit
, TexGenEnabled
), NO_EXTRA
},
540 /* GL_ARB_multisample */
541 { GL_MULTISAMPLE_ARB
, CONTEXT_BOOL(Multisample
.Enabled
), NO_EXTRA
},
542 { GL_SAMPLE_ALPHA_TO_ONE_ARB
, CONTEXT_BOOL(Multisample
.SampleAlphaToOne
), NO_EXTRA
},
544 /* GL_ARB_vertex_buffer_object */
545 { GL_VERTEX_ARRAY_BUFFER_BINDING_ARB
, LOC_CUSTOM
, TYPE_INT
,
546 offsetof(struct gl_array_object
, VertexAttrib
[VERT_ATTRIB_POS
].BufferObj
), NO_EXTRA
},
547 { GL_NORMAL_ARRAY_BUFFER_BINDING_ARB
, LOC_CUSTOM
, TYPE_INT
,
548 offsetof(struct gl_array_object
, VertexAttrib
[VERT_ATTRIB_NORMAL
].BufferObj
), NO_EXTRA
},
549 { GL_COLOR_ARRAY_BUFFER_BINDING_ARB
, LOC_CUSTOM
, TYPE_INT
,
550 offsetof(struct gl_array_object
, VertexAttrib
[VERT_ATTRIB_COLOR0
].BufferObj
), NO_EXTRA
},
551 { GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB
, LOC_CUSTOM
, TYPE_INT
, NO_OFFSET
, NO_EXTRA
},
553 /* GL_OES_point_sprite */
554 { GL_POINT_SPRITE_NV
,
555 CONTEXT_BOOL(Point
.PointSprite
),
556 extra_NV_point_sprite_ARB_point_sprite
},
558 /* GL_ARB_fragment_shader */
559 { GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB
,
560 CONTEXT_INT(Const
.FragmentProgram
.MaxUniformComponents
),
561 extra_ARB_fragment_shader
},
563 /* GL_ARB_vertex_shader */
564 { GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB
,
565 CONTEXT_INT(Const
.VertexProgram
.MaxUniformComponents
),
566 extra_ARB_vertex_shader
},
567 { GL_MAX_VARYING_FLOATS_ARB
, LOC_CUSTOM
, TYPE_INT
, 0,
568 extra_ARB_vertex_shader
},
570 /* GL_EXT_texture_filter_anisotropic */
571 { GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT
,
572 CONTEXT_FLOAT(Const
.MaxTextureMaxAnisotropy
),
573 extra_EXT_texture_filter_anisotropic
},
575 { GL_MAX_TEXTURE_COORDS_ARB
, /* == GL_MAX_TEXTURE_COORDS_NV */
576 CONTEXT_INT(Const
.MaxTextureCoordUnits
),
577 extra_ARB_fragment_program_NV_fragment_program
},
579 { GL_BLEND_COLOR_EXT
, LOC_CUSTOM
, TYPE_FLOATN_4
, 0, NO_EXTRA
},
580 /* GL_ARB_fragment_program */
581 { GL_MAX_TEXTURE_IMAGE_UNITS_ARB
, /* == GL_MAX_TEXTURE_IMAGE_UNITS_NV */
582 CONTEXT_INT(Const
.MaxTextureImageUnits
),
583 extra_ARB_fragment_program_NV_fragment_program
},
584 { GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB
,
585 CONTEXT_INT(Const
.MaxVertexTextureImageUnits
), extra_ARB_vertex_shader
},
586 { GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB
,
587 CONTEXT_INT(Const
.MaxCombinedTextureImageUnits
),
588 extra_ARB_vertex_shader
},
590 /* GL_ARB_shader_objects
591 * Actually, this token isn't part of GL_ARB_shader_objects, but is
592 * close enough for now. */
593 { GL_CURRENT_PROGRAM
, LOC_CUSTOM
, TYPE_INT
, 0, extra_ARB_shader_objects
},
596 { GL_STENCIL_BACK_FUNC
, CONTEXT_ENUM(Stencil
.Function
[1]), NO_EXTRA
},
597 { GL_STENCIL_BACK_VALUE_MASK
, CONTEXT_INT(Stencil
.ValueMask
[1]), NO_EXTRA
},
598 { GL_STENCIL_BACK_WRITEMASK
, CONTEXT_INT(Stencil
.WriteMask
[1]), NO_EXTRA
},
599 { GL_STENCIL_BACK_REF
, CONTEXT_INT(Stencil
.Ref
[1]), NO_EXTRA
},
600 { GL_STENCIL_BACK_FAIL
, CONTEXT_ENUM(Stencil
.FailFunc
[1]), NO_EXTRA
},
601 { GL_STENCIL_BACK_PASS_DEPTH_FAIL
, CONTEXT_ENUM(Stencil
.ZFailFunc
[1]), NO_EXTRA
},
602 { GL_STENCIL_BACK_PASS_DEPTH_PASS
, CONTEXT_ENUM(Stencil
.ZPassFunc
[1]), NO_EXTRA
},
605 { GL_TEXTURE_BINDING_3D
, LOC_CUSTOM
, TYPE_INT
, TEXTURE_3D_INDEX
, NO_EXTRA
},
606 { GL_MAX_3D_TEXTURE_SIZE
, LOC_CUSTOM
, TYPE_INT
,
607 offsetof(struct gl_context
, Const
.Max3DTextureLevels
), NO_EXTRA
},
609 /* GL_ARB_fragment_program/OES_standard_derivatives */
610 { GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB
,
611 CONTEXT_ENUM(Hint
.FragmentShaderDerivative
), extra_ARB_fragment_shader
},
613 { GL_ACCUM_RED_BITS
, BUFFER_INT(Visual
.accumRedBits
), NO_EXTRA
},
614 { GL_ACCUM_GREEN_BITS
, BUFFER_INT(Visual
.accumGreenBits
), NO_EXTRA
},
615 { GL_ACCUM_BLUE_BITS
, BUFFER_INT(Visual
.accumBlueBits
), NO_EXTRA
},
616 { GL_ACCUM_ALPHA_BITS
, BUFFER_INT(Visual
.accumAlphaBits
), NO_EXTRA
},
617 { GL_ACCUM_CLEAR_VALUE
, CONTEXT_FIELD(Accum
.ClearColor
[0], TYPE_FLOATN_4
), NO_EXTRA
},
618 { GL_ALPHA_BIAS
, CONTEXT_FLOAT(Pixel
.AlphaBias
), NO_EXTRA
},
619 { GL_ALPHA_SCALE
, CONTEXT_FLOAT(Pixel
.AlphaScale
), NO_EXTRA
},
620 { GL_ATTRIB_STACK_DEPTH
, CONTEXT_INT(AttribStackDepth
), NO_EXTRA
},
621 { GL_AUTO_NORMAL
, CONTEXT_BOOL(Eval
.AutoNormal
), NO_EXTRA
},
622 { GL_AUX_BUFFERS
, BUFFER_INT(Visual
.numAuxBuffers
), NO_EXTRA
},
623 { GL_BLUE_BIAS
, CONTEXT_FLOAT(Pixel
.BlueBias
), NO_EXTRA
},
624 { GL_BLUE_SCALE
, CONTEXT_FLOAT(Pixel
.BlueScale
), NO_EXTRA
},
625 { GL_CLIENT_ATTRIB_STACK_DEPTH
, CONTEXT_INT(ClientAttribStackDepth
), NO_EXTRA
},
626 { GL_COLOR_MATERIAL_FACE
, CONTEXT_ENUM(Light
.ColorMaterialFace
), NO_EXTRA
},
627 { GL_COLOR_MATERIAL_PARAMETER
, CONTEXT_ENUM(Light
.ColorMaterialMode
), NO_EXTRA
},
629 CONTEXT_FLOAT(Current
.Attrib
[VERT_ATTRIB_COLOR_INDEX
][0]),
630 extra_flush_current
},
631 { GL_CURRENT_RASTER_COLOR
,
632 CONTEXT_FIELD(Current
.RasterColor
[0], TYPE_FLOATN_4
), NO_EXTRA
},
633 { GL_CURRENT_RASTER_DISTANCE
, CONTEXT_FLOAT(Current
.RasterDistance
), NO_EXTRA
},
634 { GL_CURRENT_RASTER_INDEX
, CONST(1), NO_EXTRA
},
635 { GL_CURRENT_RASTER_POSITION
, CONTEXT_FLOAT4(Current
.RasterPos
[0]), NO_EXTRA
},
636 { GL_CURRENT_RASTER_SECONDARY_COLOR
,
637 CONTEXT_FIELD(Current
.RasterSecondaryColor
[0], TYPE_FLOATN_4
), NO_EXTRA
},
638 { GL_CURRENT_RASTER_TEXTURE_COORDS
, LOC_CUSTOM
, TYPE_FLOAT_4
, 0,
639 extra_valid_texture_unit
},
640 { GL_CURRENT_RASTER_POSITION_VALID
, CONTEXT_BOOL(Current
.RasterPosValid
), NO_EXTRA
},
641 { GL_DEPTH_BIAS
, CONTEXT_FLOAT(Pixel
.DepthBias
), NO_EXTRA
},
642 { GL_DEPTH_SCALE
, CONTEXT_FLOAT(Pixel
.DepthScale
), NO_EXTRA
},
643 { GL_DOUBLEBUFFER
, BUFFER_INT(Visual
.doubleBufferMode
), NO_EXTRA
},
644 { GL_DRAW_BUFFER
, BUFFER_ENUM(ColorDrawBuffer
), NO_EXTRA
},
645 { GL_EDGE_FLAG
, LOC_CUSTOM
, TYPE_BOOLEAN
, 0, NO_EXTRA
},
646 { GL_FEEDBACK_BUFFER_SIZE
, CONTEXT_INT(Feedback
.BufferSize
), NO_EXTRA
},
647 { GL_FEEDBACK_BUFFER_TYPE
, CONTEXT_ENUM(Feedback
.Type
), NO_EXTRA
},
648 { GL_FOG_INDEX
, CONTEXT_FLOAT(Fog
.Index
), NO_EXTRA
},
649 { GL_GREEN_BIAS
, CONTEXT_FLOAT(Pixel
.GreenBias
), NO_EXTRA
},
650 { GL_GREEN_SCALE
, CONTEXT_FLOAT(Pixel
.GreenScale
), NO_EXTRA
},
651 { GL_INDEX_BITS
, BUFFER_INT(Visual
.indexBits
), extra_new_buffers
},
652 { GL_INDEX_CLEAR_VALUE
, CONTEXT_INT(Color
.ClearIndex
), NO_EXTRA
},
653 { GL_INDEX_MODE
, CONST(0) , NO_EXTRA
},
654 { GL_INDEX_OFFSET
, CONTEXT_INT(Pixel
.IndexOffset
), NO_EXTRA
},
655 { GL_INDEX_SHIFT
, CONTEXT_INT(Pixel
.IndexShift
), NO_EXTRA
},
656 { GL_INDEX_WRITEMASK
, CONTEXT_INT(Color
.IndexMask
), NO_EXTRA
},
657 { GL_LIGHT_MODEL_COLOR_CONTROL
, CONTEXT_ENUM(Light
.Model
.ColorControl
), NO_EXTRA
},
658 { GL_LIGHT_MODEL_LOCAL_VIEWER
, CONTEXT_BOOL(Light
.Model
.LocalViewer
), NO_EXTRA
},
659 { GL_LINE_STIPPLE
, CONTEXT_BOOL(Line
.StippleFlag
), NO_EXTRA
},
660 { GL_LINE_STIPPLE_PATTERN
, LOC_CUSTOM
, TYPE_INT
, 0, NO_EXTRA
},
661 { GL_LINE_STIPPLE_REPEAT
, CONTEXT_INT(Line
.StippleFactor
), NO_EXTRA
},
662 { GL_LINE_WIDTH_GRANULARITY
, CONTEXT_FLOAT(Const
.LineWidthGranularity
), NO_EXTRA
},
663 { GL_LIST_BASE
, CONTEXT_INT(List
.ListBase
), NO_EXTRA
},
664 { GL_LIST_INDEX
, LOC_CUSTOM
, TYPE_INT
, 0, NO_EXTRA
},
665 { GL_LIST_MODE
, LOC_CUSTOM
, TYPE_ENUM
, 0, NO_EXTRA
},
666 { GL_INDEX_LOGIC_OP
, CONTEXT_BOOL(Color
.IndexLogicOpEnabled
), NO_EXTRA
},
667 { GL_MAP1_COLOR_4
, CONTEXT_BOOL(Eval
.Map1Color4
), NO_EXTRA
},
668 { GL_MAP1_GRID_DOMAIN
, CONTEXT_FLOAT2(Eval
.MapGrid1u1
), NO_EXTRA
},
669 { GL_MAP1_GRID_SEGMENTS
, CONTEXT_INT(Eval
.MapGrid1un
), NO_EXTRA
},
670 { GL_MAP1_INDEX
, CONTEXT_BOOL(Eval
.Map1Index
), NO_EXTRA
},
671 { GL_MAP1_NORMAL
, CONTEXT_BOOL(Eval
.Map1Normal
), NO_EXTRA
},
672 { GL_MAP1_TEXTURE_COORD_1
, CONTEXT_BOOL(Eval
.Map1TextureCoord1
), NO_EXTRA
},
673 { GL_MAP1_TEXTURE_COORD_2
, CONTEXT_BOOL(Eval
.Map1TextureCoord2
), NO_EXTRA
},
674 { GL_MAP1_TEXTURE_COORD_3
, CONTEXT_BOOL(Eval
.Map1TextureCoord3
), NO_EXTRA
},
675 { GL_MAP1_TEXTURE_COORD_4
, CONTEXT_BOOL(Eval
.Map1TextureCoord4
), NO_EXTRA
},
676 { GL_MAP1_VERTEX_3
, CONTEXT_BOOL(Eval
.Map1Vertex3
), NO_EXTRA
},
677 { GL_MAP1_VERTEX_4
, CONTEXT_BOOL(Eval
.Map1Vertex4
), NO_EXTRA
},
678 { GL_MAP2_COLOR_4
, CONTEXT_BOOL(Eval
.Map2Color4
), NO_EXTRA
},
679 { GL_MAP2_GRID_DOMAIN
, LOC_CUSTOM
, TYPE_FLOAT_4
, 0, NO_EXTRA
},
680 { GL_MAP2_GRID_SEGMENTS
, CONTEXT_INT2(Eval
.MapGrid2un
), NO_EXTRA
},
681 { GL_MAP2_INDEX
, CONTEXT_BOOL(Eval
.Map2Index
), NO_EXTRA
},
682 { GL_MAP2_NORMAL
, CONTEXT_BOOL(Eval
.Map2Normal
), NO_EXTRA
},
683 { GL_MAP2_TEXTURE_COORD_1
, CONTEXT_BOOL(Eval
.Map2TextureCoord1
), NO_EXTRA
},
684 { GL_MAP2_TEXTURE_COORD_2
, CONTEXT_BOOL(Eval
.Map2TextureCoord2
), NO_EXTRA
},
685 { GL_MAP2_TEXTURE_COORD_3
, CONTEXT_BOOL(Eval
.Map2TextureCoord3
), NO_EXTRA
},
686 { GL_MAP2_TEXTURE_COORD_4
, CONTEXT_BOOL(Eval
.Map2TextureCoord4
), NO_EXTRA
},
687 { GL_MAP2_VERTEX_3
, CONTEXT_BOOL(Eval
.Map2Vertex3
), NO_EXTRA
},
688 { GL_MAP2_VERTEX_4
, CONTEXT_BOOL(Eval
.Map2Vertex4
), NO_EXTRA
},
689 { GL_MAP_COLOR
, CONTEXT_BOOL(Pixel
.MapColorFlag
), NO_EXTRA
},
690 { GL_MAP_STENCIL
, CONTEXT_BOOL(Pixel
.MapStencilFlag
), NO_EXTRA
},
691 { GL_MAX_ATTRIB_STACK_DEPTH
, CONST(MAX_ATTRIB_STACK_DEPTH
), NO_EXTRA
},
692 { GL_MAX_CLIENT_ATTRIB_STACK_DEPTH
, CONST(MAX_CLIENT_ATTRIB_STACK_DEPTH
), NO_EXTRA
},
694 { GL_MAX_EVAL_ORDER
, CONST(MAX_EVAL_ORDER
), NO_EXTRA
},
695 { GL_MAX_LIST_NESTING
, CONST(MAX_LIST_NESTING
), NO_EXTRA
},
696 { GL_MAX_NAME_STACK_DEPTH
, CONST(MAX_NAME_STACK_DEPTH
), NO_EXTRA
},
697 { GL_MAX_PIXEL_MAP_TABLE
, CONST(MAX_PIXEL_MAP_TABLE
), NO_EXTRA
},
698 { GL_NAME_STACK_DEPTH
, CONTEXT_INT(Select
.NameStackDepth
), NO_EXTRA
},
699 { GL_PACK_LSB_FIRST
, CONTEXT_BOOL(Pack
.LsbFirst
), NO_EXTRA
},
700 { GL_PACK_ROW_LENGTH
, CONTEXT_INT(Pack
.RowLength
), NO_EXTRA
},
701 { GL_PACK_SKIP_PIXELS
, CONTEXT_INT(Pack
.SkipPixels
), NO_EXTRA
},
702 { GL_PACK_SKIP_ROWS
, CONTEXT_INT(Pack
.SkipRows
), NO_EXTRA
},
703 { GL_PACK_SWAP_BYTES
, CONTEXT_BOOL(Pack
.SwapBytes
), NO_EXTRA
},
704 { GL_PACK_IMAGE_HEIGHT_EXT
, CONTEXT_INT(Pack
.ImageHeight
), NO_EXTRA
},
705 { GL_PACK_INVERT_MESA
, CONTEXT_BOOL(Pack
.Invert
), NO_EXTRA
},
706 { GL_PIXEL_MAP_A_TO_A_SIZE
, CONTEXT_INT(PixelMaps
.AtoA
.Size
), NO_EXTRA
},
707 { GL_PIXEL_MAP_B_TO_B_SIZE
, CONTEXT_INT(PixelMaps
.BtoB
.Size
), NO_EXTRA
},
708 { GL_PIXEL_MAP_G_TO_G_SIZE
, CONTEXT_INT(PixelMaps
.GtoG
.Size
), NO_EXTRA
},
709 { GL_PIXEL_MAP_I_TO_A_SIZE
, CONTEXT_INT(PixelMaps
.ItoA
.Size
), NO_EXTRA
},
710 { GL_PIXEL_MAP_I_TO_B_SIZE
, CONTEXT_INT(PixelMaps
.ItoB
.Size
), NO_EXTRA
},
711 { GL_PIXEL_MAP_I_TO_G_SIZE
, CONTEXT_INT(PixelMaps
.ItoG
.Size
), NO_EXTRA
},
712 { GL_PIXEL_MAP_I_TO_I_SIZE
, CONTEXT_INT(PixelMaps
.ItoI
.Size
), NO_EXTRA
},
713 { GL_PIXEL_MAP_I_TO_R_SIZE
, CONTEXT_INT(PixelMaps
.ItoR
.Size
), NO_EXTRA
},
714 { GL_PIXEL_MAP_R_TO_R_SIZE
, CONTEXT_INT(PixelMaps
.RtoR
.Size
), NO_EXTRA
},
715 { GL_PIXEL_MAP_S_TO_S_SIZE
, CONTEXT_INT(PixelMaps
.StoS
.Size
), NO_EXTRA
},
716 { GL_POINT_SIZE_GRANULARITY
, CONTEXT_FLOAT(Const
.PointSizeGranularity
), NO_EXTRA
},
717 { GL_POLYGON_MODE
, CONTEXT_ENUM2(Polygon
.FrontMode
), NO_EXTRA
},
718 { GL_POLYGON_OFFSET_BIAS_EXT
, CONTEXT_FLOAT(Polygon
.OffsetUnits
), NO_EXTRA
},
719 { GL_POLYGON_OFFSET_POINT
, CONTEXT_BOOL(Polygon
.OffsetPoint
), NO_EXTRA
},
720 { GL_POLYGON_OFFSET_LINE
, CONTEXT_BOOL(Polygon
.OffsetLine
), NO_EXTRA
},
721 { GL_POLYGON_SMOOTH
, CONTEXT_BOOL(Polygon
.SmoothFlag
), NO_EXTRA
},
722 { GL_POLYGON_SMOOTH_HINT
, CONTEXT_ENUM(Hint
.PolygonSmooth
), NO_EXTRA
},
723 { GL_POLYGON_STIPPLE
, CONTEXT_BOOL(Polygon
.StippleFlag
), NO_EXTRA
},
724 { GL_READ_BUFFER
, LOC_CUSTOM
, TYPE_ENUM
, NO_OFFSET
, NO_EXTRA
},
725 { GL_RED_BIAS
, CONTEXT_FLOAT(Pixel
.RedBias
), NO_EXTRA
},
726 { GL_RED_SCALE
, CONTEXT_FLOAT(Pixel
.RedScale
), NO_EXTRA
},
727 { GL_RENDER_MODE
, CONTEXT_ENUM(RenderMode
), NO_EXTRA
},
728 { GL_RGBA_MODE
, CONST(1), NO_EXTRA
},
729 { GL_SELECTION_BUFFER_SIZE
, CONTEXT_INT(Select
.BufferSize
), NO_EXTRA
},
731 { GL_STEREO
, BUFFER_INT(Visual
.stereoMode
), NO_EXTRA
},
733 { GL_TEXTURE_1D
, LOC_CUSTOM
, TYPE_BOOLEAN
, NO_OFFSET
, NO_EXTRA
},
734 { GL_TEXTURE_3D
, LOC_CUSTOM
, TYPE_BOOLEAN
, NO_OFFSET
, NO_EXTRA
},
736 { GL_TEXTURE_BINDING_1D
, LOC_CUSTOM
, TYPE_INT
, TEXTURE_1D_INDEX
, NO_EXTRA
},
738 { GL_TEXTURE_GEN_S
, LOC_TEXUNIT
, TYPE_BIT_0
,
739 offsetof(struct gl_texture_unit
, TexGenEnabled
), NO_EXTRA
},
740 { GL_TEXTURE_GEN_T
, LOC_TEXUNIT
, TYPE_BIT_1
,
741 offsetof(struct gl_texture_unit
, TexGenEnabled
), NO_EXTRA
},
742 { GL_TEXTURE_GEN_R
, LOC_TEXUNIT
, TYPE_BIT_2
,
743 offsetof(struct gl_texture_unit
, TexGenEnabled
), NO_EXTRA
},
744 { GL_TEXTURE_GEN_Q
, LOC_TEXUNIT
, TYPE_BIT_3
,
745 offsetof(struct gl_texture_unit
, TexGenEnabled
), NO_EXTRA
},
746 { GL_UNPACK_LSB_FIRST
, CONTEXT_BOOL(Unpack
.LsbFirst
), NO_EXTRA
},
747 { GL_UNPACK_ROW_LENGTH
, CONTEXT_INT(Unpack
.RowLength
), NO_EXTRA
},
748 { GL_UNPACK_SKIP_PIXELS
, CONTEXT_INT(Unpack
.SkipPixels
), NO_EXTRA
},
749 { GL_UNPACK_SKIP_ROWS
, CONTEXT_INT(Unpack
.SkipRows
), NO_EXTRA
},
750 { GL_UNPACK_SWAP_BYTES
, CONTEXT_BOOL(Unpack
.SwapBytes
), NO_EXTRA
},
751 { GL_UNPACK_SKIP_IMAGES_EXT
, CONTEXT_INT(Unpack
.SkipImages
), NO_EXTRA
},
752 { GL_UNPACK_IMAGE_HEIGHT_EXT
, CONTEXT_INT(Unpack
.ImageHeight
), NO_EXTRA
},
753 { GL_ZOOM_X
, CONTEXT_FLOAT(Pixel
.ZoomX
), NO_EXTRA
},
754 { GL_ZOOM_Y
, CONTEXT_FLOAT(Pixel
.ZoomY
), NO_EXTRA
},
757 { GL_VERTEX_ARRAY_COUNT_EXT
, CONST(0), NO_EXTRA
},
758 { GL_NORMAL_ARRAY_COUNT_EXT
, CONST(0), NO_EXTRA
},
759 { GL_COLOR_ARRAY_COUNT_EXT
, CONST(0), NO_EXTRA
},
760 { GL_INDEX_ARRAY
, ARRAY_BOOL(VertexAttrib
[VERT_ATTRIB_COLOR_INDEX
].Enabled
), NO_EXTRA
},
761 { GL_INDEX_ARRAY_TYPE
, ARRAY_ENUM(VertexAttrib
[VERT_ATTRIB_COLOR_INDEX
].Type
), NO_EXTRA
},
762 { GL_INDEX_ARRAY_STRIDE
, ARRAY_INT(VertexAttrib
[VERT_ATTRIB_COLOR_INDEX
].Stride
), NO_EXTRA
},
763 { GL_INDEX_ARRAY_COUNT_EXT
, CONST(0), NO_EXTRA
},
764 { GL_TEXTURE_COORD_ARRAY_COUNT_EXT
, CONST(0), NO_EXTRA
},
765 { GL_EDGE_FLAG_ARRAY
, ARRAY_BOOL(VertexAttrib
[VERT_ATTRIB_EDGEFLAG
].Enabled
), NO_EXTRA
},
766 { GL_EDGE_FLAG_ARRAY_STRIDE
, ARRAY_INT(VertexAttrib
[VERT_ATTRIB_EDGEFLAG
].Stride
), NO_EXTRA
},
767 { GL_EDGE_FLAG_ARRAY_COUNT_EXT
, CONST(0), NO_EXTRA
},
769 /* GL_EXT_compiled_vertex_array */
770 { GL_ARRAY_ELEMENT_LOCK_FIRST_EXT
, CONTEXT_INT(Array
.LockFirst
),
771 extra_EXT_compiled_vertex_array
},
772 { GL_ARRAY_ELEMENT_LOCK_COUNT_EXT
, CONTEXT_INT(Array
.LockCount
),
773 extra_EXT_compiled_vertex_array
},
775 /* GL_ARB_transpose_matrix */
776 { GL_TRANSPOSE_MODELVIEW_MATRIX_ARB
,
777 CONTEXT_MATRIX_T(ModelviewMatrixStack
), NO_EXTRA
},
778 { GL_TRANSPOSE_PROJECTION_MATRIX_ARB
,
779 CONTEXT_MATRIX_T(ProjectionMatrixStack
.Top
), NO_EXTRA
},
780 { GL_TRANSPOSE_TEXTURE_MATRIX_ARB
, CONTEXT_MATRIX_T(TextureMatrixStack
), NO_EXTRA
},
782 /* GL_EXT_secondary_color */
783 { GL_COLOR_SUM_EXT
, CONTEXT_BOOL(Fog
.ColorSumEnabled
),
784 extra_EXT_secondary_color_ARB_vertex_program
},
785 { GL_CURRENT_SECONDARY_COLOR_EXT
,
786 CONTEXT_FIELD(Current
.Attrib
[VERT_ATTRIB_COLOR1
][0], TYPE_FLOATN_4
),
787 extra_EXT_secondary_color_flush_current
},
788 { GL_SECONDARY_COLOR_ARRAY_EXT
, ARRAY_BOOL(VertexAttrib
[VERT_ATTRIB_COLOR1
].Enabled
),
789 extra_EXT_secondary_color
},
790 { GL_SECONDARY_COLOR_ARRAY_TYPE_EXT
, ARRAY_ENUM(VertexAttrib
[VERT_ATTRIB_COLOR1
].Type
),
791 extra_EXT_secondary_color
},
792 { GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT
, ARRAY_INT(VertexAttrib
[VERT_ATTRIB_COLOR1
].Stride
),
793 extra_EXT_secondary_color
},
794 { GL_SECONDARY_COLOR_ARRAY_SIZE_EXT
, ARRAY_INT(VertexAttrib
[VERT_ATTRIB_COLOR1
].Size
),
795 extra_EXT_secondary_color
},
797 /* GL_EXT_fog_coord */
798 { GL_CURRENT_FOG_COORDINATE_EXT
,
799 CONTEXT_FLOAT(Current
.Attrib
[VERT_ATTRIB_FOG
][0]),
800 extra_EXT_fog_coord_flush_current
},
801 { GL_FOG_COORDINATE_ARRAY_EXT
, ARRAY_BOOL(VertexAttrib
[VERT_ATTRIB_FOG
].Enabled
),
802 extra_EXT_fog_coord
},
803 { GL_FOG_COORDINATE_ARRAY_TYPE_EXT
, ARRAY_ENUM(VertexAttrib
[VERT_ATTRIB_FOG
].Type
),
804 extra_EXT_fog_coord
},
805 { GL_FOG_COORDINATE_ARRAY_STRIDE_EXT
, ARRAY_INT(VertexAttrib
[VERT_ATTRIB_FOG
].Stride
),
806 extra_EXT_fog_coord
},
807 { GL_FOG_COORDINATE_SOURCE_EXT
, CONTEXT_ENUM(Fog
.FogCoordinateSource
),
808 extra_EXT_fog_coord
},
810 /* GL_NV_fog_distance */
811 { GL_FOG_DISTANCE_MODE_NV
, CONTEXT_ENUM(Fog
.FogDistanceMode
),
812 extra_NV_fog_distance
},
814 /* GL_IBM_rasterpos_clip */
815 { GL_RASTER_POSITION_UNCLIPPED_IBM
,
816 CONTEXT_BOOL(Transform
.RasterPositionUnclipped
),
817 extra_IBM_rasterpos_clip
},
819 /* GL_NV_point_sprite */
820 { GL_POINT_SPRITE_R_MODE_NV
,
821 CONTEXT_ENUM(Point
.SpriteRMode
), extra_NV_point_sprite
},
822 { GL_POINT_SPRITE_COORD_ORIGIN
, CONTEXT_ENUM(Point
.SpriteOrigin
),
823 extra_NV_point_sprite_ARB_point_sprite
},
825 /* GL_NV_vertex_program */
826 { GL_VERTEX_PROGRAM_BINDING_NV
, LOC_CUSTOM
, TYPE_INT
, 0,
827 extra_NV_vertex_program
},
828 { GL_VERTEX_ATTRIB_ARRAY0_NV
, ARRAY_BOOL(VertexAttrib
[VERT_ATTRIB_GENERIC(0)].Enabled
),
829 extra_NV_vertex_program
},
830 { GL_VERTEX_ATTRIB_ARRAY1_NV
, ARRAY_BOOL(VertexAttrib
[VERT_ATTRIB_GENERIC(1)].Enabled
),
831 extra_NV_vertex_program
},
832 { GL_VERTEX_ATTRIB_ARRAY2_NV
, ARRAY_BOOL(VertexAttrib
[VERT_ATTRIB_GENERIC(2)].Enabled
),
833 extra_NV_vertex_program
},
834 { GL_VERTEX_ATTRIB_ARRAY3_NV
, ARRAY_BOOL(VertexAttrib
[VERT_ATTRIB_GENERIC(3)].Enabled
),
835 extra_NV_vertex_program
},
836 { GL_VERTEX_ATTRIB_ARRAY4_NV
, ARRAY_BOOL(VertexAttrib
[VERT_ATTRIB_GENERIC(4)].Enabled
),
837 extra_NV_vertex_program
},
838 { GL_VERTEX_ATTRIB_ARRAY5_NV
, ARRAY_BOOL(VertexAttrib
[VERT_ATTRIB_GENERIC(5)].Enabled
),
839 extra_NV_vertex_program
},
840 { GL_VERTEX_ATTRIB_ARRAY6_NV
, ARRAY_BOOL(VertexAttrib
[VERT_ATTRIB_GENERIC(6)].Enabled
),
841 extra_NV_vertex_program
},
842 { GL_VERTEX_ATTRIB_ARRAY7_NV
, ARRAY_BOOL(VertexAttrib
[VERT_ATTRIB_GENERIC(7)].Enabled
),
843 extra_NV_vertex_program
},
844 { GL_VERTEX_ATTRIB_ARRAY8_NV
, ARRAY_BOOL(VertexAttrib
[VERT_ATTRIB_GENERIC(8)].Enabled
),
845 extra_NV_vertex_program
},
846 { GL_VERTEX_ATTRIB_ARRAY9_NV
, ARRAY_BOOL(VertexAttrib
[VERT_ATTRIB_GENERIC(9)].Enabled
),
847 extra_NV_vertex_program
},
848 { GL_VERTEX_ATTRIB_ARRAY10_NV
, ARRAY_BOOL(VertexAttrib
[VERT_ATTRIB_GENERIC(10)].Enabled
),
849 extra_NV_vertex_program
},
850 { GL_VERTEX_ATTRIB_ARRAY11_NV
, ARRAY_BOOL(VertexAttrib
[VERT_ATTRIB_GENERIC(11)].Enabled
),
851 extra_NV_vertex_program
},
852 { GL_VERTEX_ATTRIB_ARRAY12_NV
, ARRAY_BOOL(VertexAttrib
[VERT_ATTRIB_GENERIC(12)].Enabled
),
853 extra_NV_vertex_program
},
854 { GL_VERTEX_ATTRIB_ARRAY13_NV
, ARRAY_BOOL(VertexAttrib
[VERT_ATTRIB_GENERIC(13)].Enabled
),
855 extra_NV_vertex_program
},
856 { GL_VERTEX_ATTRIB_ARRAY14_NV
, ARRAY_BOOL(VertexAttrib
[VERT_ATTRIB_GENERIC(14)].Enabled
),
857 extra_NV_vertex_program
},
858 { GL_VERTEX_ATTRIB_ARRAY15_NV
, ARRAY_BOOL(VertexAttrib
[VERT_ATTRIB_GENERIC(15)].Enabled
),
859 extra_NV_vertex_program
},
860 { GL_MAP1_VERTEX_ATTRIB0_4_NV
, CONTEXT_BOOL(Eval
.Map1Attrib
[0]),
861 extra_NV_vertex_program
},
862 { GL_MAP1_VERTEX_ATTRIB1_4_NV
, CONTEXT_BOOL(Eval
.Map1Attrib
[1]),
863 extra_NV_vertex_program
},
864 { GL_MAP1_VERTEX_ATTRIB2_4_NV
, CONTEXT_BOOL(Eval
.Map1Attrib
[2]),
865 extra_NV_vertex_program
},
866 { GL_MAP1_VERTEX_ATTRIB3_4_NV
, CONTEXT_BOOL(Eval
.Map1Attrib
[3]),
867 extra_NV_vertex_program
},
868 { GL_MAP1_VERTEX_ATTRIB4_4_NV
, CONTEXT_BOOL(Eval
.Map1Attrib
[4]),
869 extra_NV_vertex_program
},
870 { GL_MAP1_VERTEX_ATTRIB5_4_NV
, CONTEXT_BOOL(Eval
.Map1Attrib
[5]),
871 extra_NV_vertex_program
},
872 { GL_MAP1_VERTEX_ATTRIB6_4_NV
, CONTEXT_BOOL(Eval
.Map1Attrib
[6]),
873 extra_NV_vertex_program
},
874 { GL_MAP1_VERTEX_ATTRIB7_4_NV
, CONTEXT_BOOL(Eval
.Map1Attrib
[7]),
875 extra_NV_vertex_program
},
876 { GL_MAP1_VERTEX_ATTRIB8_4_NV
, CONTEXT_BOOL(Eval
.Map1Attrib
[8]),
877 extra_NV_vertex_program
},
878 { GL_MAP1_VERTEX_ATTRIB9_4_NV
, CONTEXT_BOOL(Eval
.Map1Attrib
[9]),
879 extra_NV_vertex_program
},
880 { GL_MAP1_VERTEX_ATTRIB10_4_NV
, CONTEXT_BOOL(Eval
.Map1Attrib
[10]),
881 extra_NV_vertex_program
},
882 { GL_MAP1_VERTEX_ATTRIB11_4_NV
, CONTEXT_BOOL(Eval
.Map1Attrib
[11]),
883 extra_NV_vertex_program
},
884 { GL_MAP1_VERTEX_ATTRIB12_4_NV
, CONTEXT_BOOL(Eval
.Map1Attrib
[12]),
885 extra_NV_vertex_program
},
886 { GL_MAP1_VERTEX_ATTRIB13_4_NV
, CONTEXT_BOOL(Eval
.Map1Attrib
[13]),
887 extra_NV_vertex_program
},
888 { GL_MAP1_VERTEX_ATTRIB14_4_NV
, CONTEXT_BOOL(Eval
.Map1Attrib
[14]),
889 extra_NV_vertex_program
},
890 { GL_MAP1_VERTEX_ATTRIB15_4_NV
, CONTEXT_BOOL(Eval
.Map1Attrib
[15]),
891 extra_NV_vertex_program
},
893 /* GL_NV_fragment_program */
894 { GL_FRAGMENT_PROGRAM_NV
, CONTEXT_BOOL(FragmentProgram
.Enabled
),
895 extra_NV_fragment_program
},
896 { GL_FRAGMENT_PROGRAM_BINDING_NV
, LOC_CUSTOM
, TYPE_INT
, 0,
897 extra_NV_fragment_program
},
898 { GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV
,
899 CONST(MAX_NV_FRAGMENT_PROGRAM_PARAMS
),
900 extra_NV_fragment_program
},
902 /* GL_EXT_stencil_two_side */
903 { GL_STENCIL_TEST_TWO_SIDE_EXT
, CONTEXT_BOOL(Stencil
.TestTwoSide
),
904 extra_EXT_stencil_two_side
},
905 { GL_ACTIVE_STENCIL_FACE_EXT
, LOC_CUSTOM
, TYPE_ENUM
, NO_OFFSET
, NO_EXTRA
},
907 /* GL_NV_light_max_exponent */
908 { GL_MAX_SHININESS_NV
, CONTEXT_FLOAT(Const
.MaxShininess
),
909 extra_NV_light_max_exponent
},
910 { GL_MAX_SPOT_EXPONENT_NV
, CONTEXT_FLOAT(Const
.MaxSpotExponent
),
911 extra_NV_light_max_exponent
},
913 /* GL_ARB_vertex_buffer_object */
914 { GL_INDEX_ARRAY_BUFFER_BINDING_ARB
, LOC_CUSTOM
, TYPE_INT
,
915 offsetof(struct gl_array_object
, VertexAttrib
[VERT_ATTRIB_COLOR_INDEX
].BufferObj
), NO_EXTRA
},
916 { GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB
, LOC_CUSTOM
, TYPE_INT
,
917 offsetof(struct gl_array_object
, VertexAttrib
[VERT_ATTRIB_EDGEFLAG
].BufferObj
), NO_EXTRA
},
918 { GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB
, LOC_CUSTOM
, TYPE_INT
,
919 offsetof(struct gl_array_object
, VertexAttrib
[VERT_ATTRIB_COLOR1
].BufferObj
), NO_EXTRA
},
920 { GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB
, LOC_CUSTOM
, TYPE_INT
,
921 offsetof(struct gl_array_object
, VertexAttrib
[VERT_ATTRIB_FOG
].BufferObj
), NO_EXTRA
},
923 /* GL_EXT_pixel_buffer_object */
924 { GL_PIXEL_PACK_BUFFER_BINDING_EXT
, LOC_CUSTOM
, TYPE_INT
, 0,
925 extra_EXT_pixel_buffer_object
},
926 { GL_PIXEL_UNPACK_BUFFER_BINDING_EXT
, LOC_CUSTOM
, TYPE_INT
, 0,
927 extra_EXT_pixel_buffer_object
},
929 /* GL_ARB_vertex_program */
930 { GL_VERTEX_PROGRAM_ARB
, /* == GL_VERTEX_PROGRAM_NV */
931 CONTEXT_BOOL(VertexProgram
.Enabled
),
932 extra_ARB_vertex_program_NV_vertex_program
},
933 { GL_VERTEX_PROGRAM_POINT_SIZE_ARB
, /* == GL_VERTEX_PROGRAM_POINT_SIZE_NV*/
934 CONTEXT_BOOL(VertexProgram
.PointSizeEnabled
),
935 extra_ARB_vertex_program_NV_vertex_program
},
936 { GL_VERTEX_PROGRAM_TWO_SIDE_ARB
, /* == GL_VERTEX_PROGRAM_TWO_SIDE_NV */
937 CONTEXT_BOOL(VertexProgram
.TwoSideEnabled
),
938 extra_ARB_vertex_program_NV_vertex_program
},
939 { GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB
, /* == GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV */
940 CONTEXT_INT(Const
.MaxProgramMatrixStackDepth
),
941 extra_ARB_vertex_program_ARB_fragment_program_NV_vertex_program
},
942 { GL_MAX_PROGRAM_MATRICES_ARB
, /* == GL_MAX_TRACK_MATRICES_NV */
943 CONTEXT_INT(Const
.MaxProgramMatrices
),
944 extra_ARB_vertex_program_ARB_fragment_program_NV_vertex_program
},
945 { GL_CURRENT_MATRIX_STACK_DEPTH_ARB
, /* == GL_CURRENT_MATRIX_STACK_DEPTH_NV */
946 LOC_CUSTOM
, TYPE_INT
, 0,
947 extra_ARB_vertex_program_ARB_fragment_program_NV_vertex_program
},
949 { GL_CURRENT_MATRIX_ARB
, /* == GL_CURRENT_MATRIX_NV */
950 LOC_CUSTOM
, TYPE_MATRIX
, 0,
951 extra_ARB_vertex_program_ARB_fragment_program_NV_vertex_program
},
952 { GL_TRANSPOSE_CURRENT_MATRIX_ARB
, /* == GL_CURRENT_MATRIX_NV */
953 LOC_CUSTOM
, TYPE_MATRIX
, 0,
954 extra_ARB_vertex_program_ARB_fragment_program
},
956 { GL_PROGRAM_ERROR_POSITION_ARB
, /* == GL_PROGRAM_ERROR_POSITION_NV */
957 CONTEXT_INT(Program
.ErrorPos
),
958 extra_NV_vertex_program_ARB_vertex_program_ARB_fragment_program_NV_vertex_program
},
960 /* GL_ARB_fragment_program */
961 { GL_FRAGMENT_PROGRAM_ARB
, CONTEXT_BOOL(FragmentProgram
.Enabled
),
962 extra_ARB_fragment_program
},
964 /* GL_EXT_depth_bounds_test */
965 { GL_DEPTH_BOUNDS_TEST_EXT
, CONTEXT_BOOL(Depth
.BoundsTest
),
966 extra_EXT_depth_bounds_test
},
967 { GL_DEPTH_BOUNDS_EXT
, CONTEXT_FLOAT2(Depth
.BoundsMin
),
968 extra_EXT_depth_bounds_test
},
970 /* GL_APPLE_vertex_array_object */
971 { GL_VERTEX_ARRAY_BINDING_APPLE
, ARRAY_INT(Name
),
972 extra_APPLE_vertex_array_object
},
974 /* GL_EXT_texture_integer */
975 { GL_RGBA_INTEGER_MODE_EXT
, BUFFER_BOOL(_IntegerColor
),
976 extra_EXT_texture_integer
},
978 /* GL_EXT_gpu_shader4 / GLSL 1.30 */
979 { GL_MIN_PROGRAM_TEXEL_OFFSET
,
980 CONTEXT_INT(Const
.MinProgramTexelOffset
),
982 { GL_MAX_PROGRAM_TEXEL_OFFSET
,
983 CONTEXT_INT(Const
.MaxProgramTexelOffset
),
987 { GL_NUM_EXTENSIONS
, LOC_CUSTOM
, TYPE_INT
, 0, extra_version_30
},
988 { GL_MAJOR_VERSION
, CONTEXT_INT(VersionMajor
), extra_version_30
},
989 { GL_MINOR_VERSION
, CONTEXT_INT(VersionMinor
), extra_version_30
},
990 { GL_CONTEXT_FLAGS
, CONTEXT_INT(Const
.ContextFlags
), extra_version_30
},
994 { GL_CONTEXT_PROFILE_MASK
, CONTEXT_INT(Const
.ProfileMask
),
997 /* GL_ARB_robustness */
998 { GL_RESET_NOTIFICATION_STRATEGY_ARB
, CONTEXT_ENUM(Const
.ResetStrategy
), NO_EXTRA
},
1001 /* All we need now is a way to look up the value struct from the enum.
1002 * The code generated by gcc for the old generated big switch
1003 * statement is a big, balanced, open coded if/else tree, essentially
1004 * an unrolled binary search. It would be natural to sort the new
1005 * enum table and use bsearch(), but we will use a read-only hash
1006 * table instead. bsearch() has a nice guaranteed worst case
1007 * performance, but we're also guaranteed to hit that worst case
1008 * (log2(n) iterations) for about half the enums. Instead, using an
1009 * open addressing hash table, we can find the enum on the first try
1010 * for 80% of the enums, 1 collision for 10% and never more than 5
1011 * collisions for any enum (typical numbers). And the code is very
1012 * simple, even though it feels a little magic. */
1014 static unsigned short table
[1024];
1015 static const int prime_factor
= 89, prime_step
= 281;
1019 print_table_stats(void)
1021 int i
, j
, collisions
[11], count
, hash
, mask
;
1022 const struct value_desc
*d
;
1025 mask
= Elements(table
) - 1;
1026 memset(collisions
, 0, sizeof collisions
);
1028 for (i
= 0; i
< Elements(table
); i
++) {
1032 d
= &values
[table
[i
]];
1033 hash
= (d
->pname
* prime_factor
);
1036 if (values
[table
[hash
& mask
]].pname
== d
->pname
)
1048 printf("number of enums: %d (total %d)\n", count
, Elements(values
));
1049 for (i
= 0; i
< Elements(collisions
) - 1; i
++)
1050 if (collisions
[i
] > 0)
1051 printf(" %d enums with %d %scollisions\n",
1052 collisions
[i
], i
, i
== 10 ? "or more " : "");
1057 * Initialize the enum hash for a given API
1059 * This is called from one_time_init() to insert the enum values that
1060 * are valid for the API in question into the enum hash table.
1062 * \param the current context, for determining the API in question
1064 void _mesa_init_get_hash(struct gl_context
*ctx
)
1066 int i
, hash
, index
, mask
;
1068 mask
= Elements(table
) - 1;
1070 for (i
= 0; i
< Elements(values
); i
++) {
1072 hash
= (values
[i
].pname
* prime_factor
) & mask
;
1074 index
= hash
& mask
;
1075 if (!table
[index
]) {
1084 print_table_stats();
1089 * Handle irregular enums
1091 * Some values don't conform to the "well-known type at context
1092 * pointer + offset" pattern, so we have this function to catch all
1093 * the corner cases. Typically, it's a computed value or a one-off
1094 * pointer to a custom struct or something.
1096 * In this case we can't return a pointer to the value, so we'll have
1097 * to use the temporary variable 'v' declared back in the calling
1098 * glGet*v() function to store the result.
1100 * \param ctx the current context
1101 * \param d the struct value_desc that describes the enum
1102 * \param v pointer to the tmp declared in the calling glGet*v() function
1105 find_custom_value(struct gl_context
*ctx
, const struct value_desc
*d
, union value
*v
)
1107 struct gl_buffer_object
**buffer_obj
;
1108 struct gl_client_array
*array
;
1115 case GL_TEXTURE_CUBE_MAP_ARB
:
1116 v
->value_bool
= _mesa_IsEnabled(d
->pname
);
1119 case GL_LINE_STIPPLE_PATTERN
:
1120 /* This is the only GLushort, special case it here by promoting
1121 * to an int rather than introducing a new type. */
1122 v
->value_int
= ctx
->Line
.StipplePattern
;
1125 case GL_CURRENT_RASTER_TEXTURE_COORDS
:
1126 unit
= ctx
->Texture
.CurrentUnit
;
1127 v
->value_float_4
[0] = ctx
->Current
.RasterTexCoords
[unit
][0];
1128 v
->value_float_4
[1] = ctx
->Current
.RasterTexCoords
[unit
][1];
1129 v
->value_float_4
[2] = ctx
->Current
.RasterTexCoords
[unit
][2];
1130 v
->value_float_4
[3] = ctx
->Current
.RasterTexCoords
[unit
][3];
1133 case GL_CURRENT_TEXTURE_COORDS
:
1134 unit
= ctx
->Texture
.CurrentUnit
;
1135 v
->value_float_4
[0] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
][0];
1136 v
->value_float_4
[1] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
][1];
1137 v
->value_float_4
[2] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
][2];
1138 v
->value_float_4
[3] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
][3];
1141 case GL_COLOR_WRITEMASK
:
1142 v
->value_int_4
[0] = ctx
->Color
.ColorMask
[RCOMP
] ? 1 : 0;
1143 v
->value_int_4
[1] = ctx
->Color
.ColorMask
[GCOMP
] ? 1 : 0;
1144 v
->value_int_4
[2] = ctx
->Color
.ColorMask
[BCOMP
] ? 1 : 0;
1145 v
->value_int_4
[3] = ctx
->Color
.ColorMask
[ACOMP
] ? 1 : 0;
1149 v
->value_bool
= ctx
->Current
.Attrib
[VERT_ATTRIB_EDGEFLAG
][0] == 1.0;
1152 case GL_READ_BUFFER
:
1153 v
->value_enum
= ctx
->ReadBuffer
->ColorReadBuffer
;
1156 case GL_MAP2_GRID_DOMAIN
:
1157 v
->value_float_4
[0] = ctx
->Eval
.MapGrid2u1
;
1158 v
->value_float_4
[1] = ctx
->Eval
.MapGrid2u2
;
1159 v
->value_float_4
[2] = ctx
->Eval
.MapGrid2v1
;
1160 v
->value_float_4
[3] = ctx
->Eval
.MapGrid2v2
;
1163 case GL_TEXTURE_STACK_DEPTH
:
1164 unit
= ctx
->Texture
.CurrentUnit
;
1165 v
->value_int
= ctx
->TextureMatrixStack
[unit
].Depth
+ 1;
1167 case GL_TEXTURE_MATRIX
:
1168 unit
= ctx
->Texture
.CurrentUnit
;
1169 v
->value_matrix
= ctx
->TextureMatrixStack
[unit
].Top
;
1172 case GL_TEXTURE_COORD_ARRAY
:
1173 case GL_TEXTURE_COORD_ARRAY_SIZE
:
1174 case GL_TEXTURE_COORD_ARRAY_TYPE
:
1175 case GL_TEXTURE_COORD_ARRAY_STRIDE
:
1176 array
= &ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_TEX(ctx
->Array
.ActiveTexture
)];
1177 v
->value_int
= *(GLuint
*) ((char *) array
+ d
->offset
);
1180 case GL_ACTIVE_TEXTURE_ARB
:
1181 v
->value_int
= GL_TEXTURE0_ARB
+ ctx
->Texture
.CurrentUnit
;
1183 case GL_CLIENT_ACTIVE_TEXTURE_ARB
:
1184 v
->value_int
= GL_TEXTURE0_ARB
+ ctx
->Array
.ActiveTexture
;
1187 case GL_MODELVIEW_STACK_DEPTH
:
1188 case GL_PROJECTION_STACK_DEPTH
:
1189 v
->value_int
= *(GLint
*) ((char *) ctx
+ d
->offset
) + 1;
1192 case GL_MAX_TEXTURE_SIZE
:
1193 case GL_MAX_3D_TEXTURE_SIZE
:
1194 case GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB
:
1195 p
= (GLuint
*) ((char *) ctx
+ d
->offset
);
1196 v
->value_int
= 1 << (*p
- 1);
1199 case GL_SCISSOR_BOX
:
1200 v
->value_int_4
[0] = ctx
->Scissor
.X
;
1201 v
->value_int_4
[1] = ctx
->Scissor
.Y
;
1202 v
->value_int_4
[2] = ctx
->Scissor
.Width
;
1203 v
->value_int_4
[3] = ctx
->Scissor
.Height
;
1208 ctx
->ListState
.CurrentList
? ctx
->ListState
.CurrentList
->Name
: 0;
1211 if (!ctx
->CompileFlag
)
1213 else if (ctx
->ExecuteFlag
)
1214 v
->value_enum
= GL_COMPILE_AND_EXECUTE
;
1216 v
->value_enum
= GL_COMPILE
;
1220 v
->value_int_4
[0] = ctx
->Viewport
.X
;
1221 v
->value_int_4
[1] = ctx
->Viewport
.Y
;
1222 v
->value_int_4
[2] = ctx
->Viewport
.Width
;
1223 v
->value_int_4
[3] = ctx
->Viewport
.Height
;
1226 case GL_ACTIVE_STENCIL_FACE_EXT
:
1227 v
->value_enum
= ctx
->Stencil
.ActiveFace
? GL_BACK
: GL_FRONT
;
1230 case GL_STENCIL_FAIL
:
1231 v
->value_enum
= ctx
->Stencil
.FailFunc
[ctx
->Stencil
.ActiveFace
];
1233 case GL_STENCIL_FUNC
:
1234 v
->value_enum
= ctx
->Stencil
.Function
[ctx
->Stencil
.ActiveFace
];
1236 case GL_STENCIL_PASS_DEPTH_FAIL
:
1237 v
->value_enum
= ctx
->Stencil
.ZFailFunc
[ctx
->Stencil
.ActiveFace
];
1239 case GL_STENCIL_PASS_DEPTH_PASS
:
1240 v
->value_enum
= ctx
->Stencil
.ZPassFunc
[ctx
->Stencil
.ActiveFace
];
1242 case GL_STENCIL_REF
:
1243 v
->value_int
= ctx
->Stencil
.Ref
[ctx
->Stencil
.ActiveFace
];
1245 case GL_STENCIL_VALUE_MASK
:
1246 v
->value_int
= ctx
->Stencil
.ValueMask
[ctx
->Stencil
.ActiveFace
];
1248 case GL_STENCIL_WRITEMASK
:
1249 v
->value_int
= ctx
->Stencil
.WriteMask
[ctx
->Stencil
.ActiveFace
];
1252 case GL_NUM_EXTENSIONS
:
1253 v
->value_int
= _mesa_get_extension_count(ctx
);
1256 case GL_IMPLEMENTATION_COLOR_READ_TYPE_OES
:
1257 v
->value_int
= _mesa_get_color_read_type(ctx
);
1259 case GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES
:
1260 v
->value_int
= _mesa_get_color_read_format(ctx
);
1263 case GL_CURRENT_MATRIX_STACK_DEPTH_ARB
:
1264 v
->value_int
= ctx
->CurrentStack
->Depth
+ 1;
1266 case GL_CURRENT_MATRIX_ARB
:
1267 case GL_TRANSPOSE_CURRENT_MATRIX_ARB
:
1268 v
->value_matrix
= ctx
->CurrentStack
->Top
;
1271 case GL_MAX_VARYING_FLOATS_ARB
:
1272 v
->value_int
= ctx
->Const
.MaxVarying
* 4;
1275 /* Various object names */
1277 case GL_TEXTURE_BINDING_1D
:
1278 case GL_TEXTURE_BINDING_2D
:
1279 case GL_TEXTURE_BINDING_3D
:
1280 case GL_TEXTURE_BINDING_CUBE_MAP_ARB
:
1281 unit
= ctx
->Texture
.CurrentUnit
;
1283 ctx
->Texture
.Unit
[unit
].CurrentTex
[d
->offset
]->Name
;
1286 /* GL_ARB_vertex_buffer_object */
1287 case GL_VERTEX_ARRAY_BUFFER_BINDING_ARB
:
1288 case GL_NORMAL_ARRAY_BUFFER_BINDING_ARB
:
1289 case GL_COLOR_ARRAY_BUFFER_BINDING_ARB
:
1290 case GL_INDEX_ARRAY_BUFFER_BINDING_ARB
:
1291 case GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB
:
1292 case GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB
:
1293 case GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB
:
1294 buffer_obj
= (struct gl_buffer_object
**)
1295 ((char *) ctx
->Array
.ArrayObj
+ d
->offset
);
1296 v
->value_int
= (*buffer_obj
)->Name
;
1298 case GL_ARRAY_BUFFER_BINDING_ARB
:
1299 v
->value_int
= ctx
->Array
.ArrayBufferObj
->Name
;
1301 case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB
:
1303 ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_TEX(ctx
->Array
.ActiveTexture
)].BufferObj
->Name
;
1305 case GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB
:
1306 v
->value_int
= ctx
->Array
.ArrayObj
->ElementArrayBufferObj
->Name
;
1309 case GL_FRAGMENT_PROGRAM_BINDING_NV
:
1311 ctx
->FragmentProgram
.Current
? ctx
->FragmentProgram
.Current
->Base
.Id
: 0;
1313 case GL_VERTEX_PROGRAM_BINDING_NV
:
1315 ctx
->VertexProgram
.Current
? ctx
->VertexProgram
.Current
->Base
.Id
: 0;
1317 case GL_PIXEL_PACK_BUFFER_BINDING_EXT
:
1318 v
->value_int
= ctx
->Pack
.BufferObj
->Name
;
1320 case GL_PIXEL_UNPACK_BUFFER_BINDING_EXT
:
1321 v
->value_int
= ctx
->Unpack
.BufferObj
->Name
;
1323 case GL_CURRENT_PROGRAM
:
1325 ctx
->Shader
.ActiveProgram
? ctx
->Shader
.ActiveProgram
->Name
: 0;
1327 case GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES
:
1328 v
->value_int
= ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_POINT_SIZE
].BufferObj
->Name
;
1332 COPY_4FV(v
->value_float_4
, ctx
->Fog
.Color
);
1334 case GL_COLOR_CLEAR_VALUE
:
1335 v
->value_float_4
[0] = CLAMP(ctx
->Color
.ClearColor
.f
[0], 0.0F
, 1.0F
);
1336 v
->value_float_4
[1] = CLAMP(ctx
->Color
.ClearColor
.f
[1], 0.0F
, 1.0F
);
1337 v
->value_float_4
[2] = CLAMP(ctx
->Color
.ClearColor
.f
[2], 0.0F
, 1.0F
);
1338 v
->value_float_4
[3] = CLAMP(ctx
->Color
.ClearColor
.f
[3], 0.0F
, 1.0F
);
1340 case GL_BLEND_COLOR_EXT
:
1341 COPY_4FV(v
->value_float_4
, ctx
->Color
.BlendColor
);
1343 case GL_ALPHA_TEST_REF
:
1344 v
->value_float
= ctx
->Color
.AlphaRef
;
1346 case GL_MAX_VERTEX_UNIFORM_VECTORS
:
1347 v
->value_int
= ctx
->Const
.VertexProgram
.MaxUniformComponents
/ 4;
1350 case GL_MAX_FRAGMENT_UNIFORM_VECTORS
:
1351 v
->value_int
= ctx
->Const
.FragmentProgram
.MaxUniformComponents
/ 4;
1357 * Check extra constraints on a struct value_desc descriptor
1359 * If a struct value_desc has a non-NULL extra pointer, it means that
1360 * there are a number of extra constraints to check or actions to
1361 * perform. The extras is just an integer array where each integer
1362 * encode different constraints or actions.
1364 * \param ctx current context
1365 * \param func name of calling glGet*v() function for error reporting
1366 * \param d the struct value_desc that has the extra constraints
1368 * \return GL_FALSE if one of the constraints was not satisfied,
1369 * otherwise GL_TRUE.
1372 check_extra(struct gl_context
*ctx
, const char *func
, const struct value_desc
*d
)
1374 const GLuint version
= ctx
->VersionMajor
* 10 + ctx
->VersionMinor
;
1380 for (e
= d
->extra
; *e
!= EXTRA_END
; e
++)
1382 case EXTRA_VERSION_30
:
1383 if (version
>= 30) {
1388 case EXTRA_VERSION_31
:
1389 if (version
>= 31) {
1394 case EXTRA_VERSION_32
:
1395 if (version
>= 32) {
1400 case EXTRA_NEW_BUFFERS
:
1401 if (ctx
->NewState
& _NEW_BUFFERS
)
1402 _mesa_update_state(ctx
);
1404 case EXTRA_FLUSH_CURRENT
:
1405 FLUSH_CURRENT(ctx
, 0);
1407 case EXTRA_VALID_TEXTURE_UNIT
:
1408 if (ctx
->Texture
.CurrentUnit
>= ctx
->Const
.MaxTextureCoordUnits
) {
1409 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(texture %u)",
1410 func
, ctx
->Texture
.CurrentUnit
);
1414 case EXTRA_VALID_CLIP_DISTANCE
:
1415 if (d
->pname
- GL_CLIP_DISTANCE0
>= ctx
->Const
.MaxClipPlanes
) {
1416 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(clip distance %u)",
1417 func
, d
->pname
- GL_CLIP_DISTANCE0
);
1421 case EXTRA_GLSL_130
:
1422 if (ctx
->Const
.GLSLVersion
>= 130) {
1429 default: /* *e is a offset into the extension struct */
1431 if (*(GLboolean
*) ((char *) &ctx
->Extensions
+ *e
))
1436 if (total
> 0 && enabled
== 0) {
1437 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(pname=%s)", func
,
1438 _mesa_lookup_enum_by_nr(d
->pname
));
1445 static const struct value_desc error_value
=
1446 { 0, 0, TYPE_INVALID
, NO_OFFSET
, NO_EXTRA
};
1449 * Find the struct value_desc corresponding to the enum 'pname'.
1451 * We hash the enum value to get an index into the 'table' array,
1452 * which holds the index in the 'values' array of struct value_desc.
1453 * Once we've found the entry, we do the extra checks, if any, then
1454 * look up the value and return a pointer to it.
1456 * If the value has to be computed (for example, it's the result of a
1457 * function call or we need to add 1 to it), we use the tmp 'v' to
1460 * \param func name of glGet*v() func for error reporting
1461 * \param pname the enum value we're looking up
1462 * \param p is were we return the pointer to the value
1463 * \param v a tmp union value variable in the calling glGet*v() function
1465 * \return the struct value_desc corresponding to the enum or a struct
1466 * value_desc of TYPE_INVALID if not found. This lets the calling
1467 * glGet*v() function jump right into a switch statement and
1468 * handle errors there instead of having to check for NULL.
1470 static const struct value_desc
*
1471 find_value(const char *func
, GLenum pname
, void **p
, union value
*v
)
1473 GET_CURRENT_CONTEXT(ctx
);
1474 struct gl_texture_unit
*unit
;
1476 const struct value_desc
*d
;
1478 mask
= Elements(table
) - 1;
1479 hash
= (pname
* prime_factor
);
1481 d
= &values
[table
[hash
& mask
]];
1483 if (likely(d
->pname
== pname
))
1489 if (unlikely(d
->extra
&& !check_extra(ctx
, func
, d
)))
1490 return &error_value
;
1492 switch (d
->location
) {
1494 *p
= ((char *) ctx
->DrawBuffer
+ d
->offset
);
1497 *p
= ((char *) ctx
+ d
->offset
);
1500 *p
= ((char *) ctx
->Array
.ArrayObj
+ d
->offset
);
1503 unit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1504 *p
= ((char *) unit
+ d
->offset
);
1507 find_custom_value(ctx
, d
, v
);
1515 /* silence warning */
1516 return &error_value
;
1519 static const int transpose
[] = {
1527 _mesa_GetBooleanv(GLenum pname
, GLboolean
*params
)
1529 const struct value_desc
*d
;
1534 GET_CURRENT_CONTEXT(ctx
);
1536 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1538 d
= find_value("glGetBooleanv", pname
, &p
, &v
);
1543 params
[0] = INT_TO_BOOLEAN(d
->offset
);
1548 params
[3] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[3]);
1551 params
[2] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[2]);
1554 params
[1] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[1]);
1557 params
[0] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[0]);
1561 params
[0] = FLOAT_TO_BOOLEAN(((GLdouble
*) p
)[0]);
1565 params
[3] = INT_TO_BOOLEAN(((GLint
*) p
)[3]);
1567 params
[2] = INT_TO_BOOLEAN(((GLint
*) p
)[2]);
1570 params
[1] = INT_TO_BOOLEAN(((GLint
*) p
)[1]);
1573 params
[0] = INT_TO_BOOLEAN(((GLint
*) p
)[0]);
1577 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
1578 params
[i
] = INT_TO_BOOLEAN(v
.value_int_n
.ints
[i
]);
1582 params
[0] = INT64_TO_BOOLEAN(((GLint64
*) p
)[0]);
1586 params
[0] = ((GLboolean
*) p
)[0];
1590 m
= *(GLmatrix
**) p
;
1591 for (i
= 0; i
< 16; i
++)
1592 params
[i
] = FLOAT_TO_BOOLEAN(m
->m
[i
]);
1596 m
= *(GLmatrix
**) p
;
1597 for (i
= 0; i
< 16; i
++)
1598 params
[i
] = FLOAT_TO_BOOLEAN(m
->m
[transpose
[i
]]);
1609 shift
= d
->type
- TYPE_BIT_0
;
1610 params
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
1616 _mesa_GetFloatv(GLenum pname
, GLfloat
*params
)
1618 const struct value_desc
*d
;
1623 GET_CURRENT_CONTEXT(ctx
);
1625 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1627 d
= find_value("glGetFloatv", pname
, &p
, &v
);
1632 params
[0] = (GLfloat
) d
->offset
;
1637 params
[3] = ((GLfloat
*) p
)[3];
1640 params
[2] = ((GLfloat
*) p
)[2];
1643 params
[1] = ((GLfloat
*) p
)[1];
1646 params
[0] = ((GLfloat
*) p
)[0];
1650 params
[0] = ((GLdouble
*) p
)[0];
1654 params
[3] = (GLfloat
) (((GLint
*) p
)[3]);
1656 params
[2] = (GLfloat
) (((GLint
*) p
)[2]);
1659 params
[1] = (GLfloat
) (((GLint
*) p
)[1]);
1662 params
[0] = (GLfloat
) (((GLint
*) p
)[0]);
1666 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
1667 params
[i
] = INT_TO_FLOAT(v
.value_int_n
.ints
[i
]);
1671 params
[0] = ((GLint64
*) p
)[0];
1675 params
[0] = BOOLEAN_TO_FLOAT(*(GLboolean
*) p
);
1679 m
= *(GLmatrix
**) p
;
1680 for (i
= 0; i
< 16; i
++)
1681 params
[i
] = m
->m
[i
];
1685 m
= *(GLmatrix
**) p
;
1686 for (i
= 0; i
< 16; i
++)
1687 params
[i
] = m
->m
[transpose
[i
]];
1698 shift
= d
->type
- TYPE_BIT_0
;
1699 params
[0] = BOOLEAN_TO_FLOAT((*(GLbitfield
*) p
>> shift
) & 1);
1705 _mesa_GetIntegerv(GLenum pname
, GLint
*params
)
1707 const struct value_desc
*d
;
1712 GET_CURRENT_CONTEXT(ctx
);
1714 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1716 d
= find_value("glGetIntegerv", pname
, &p
, &v
);
1721 params
[0] = d
->offset
;
1725 params
[3] = IROUND(((GLfloat
*) p
)[3]);
1727 params
[2] = IROUND(((GLfloat
*) p
)[2]);
1729 params
[1] = IROUND(((GLfloat
*) p
)[1]);
1731 params
[0] = IROUND(((GLfloat
*) p
)[0]);
1735 params
[3] = FLOAT_TO_INT(((GLfloat
*) p
)[3]);
1737 params
[2] = FLOAT_TO_INT(((GLfloat
*) p
)[2]);
1739 params
[1] = FLOAT_TO_INT(((GLfloat
*) p
)[1]);
1741 params
[0] = FLOAT_TO_INT(((GLfloat
*) p
)[0]);
1745 params
[0] = FLOAT_TO_INT(((GLdouble
*) p
)[0]);
1749 params
[3] = ((GLint
*) p
)[3];
1751 params
[2] = ((GLint
*) p
)[2];
1754 params
[1] = ((GLint
*) p
)[1];
1757 params
[0] = ((GLint
*) p
)[0];
1761 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
1762 params
[i
] = v
.value_int_n
.ints
[i
];
1766 params
[0] = INT64_TO_INT(((GLint64
*) p
)[0]);
1770 params
[0] = BOOLEAN_TO_INT(*(GLboolean
*) p
);
1774 m
= *(GLmatrix
**) p
;
1775 for (i
= 0; i
< 16; i
++)
1776 params
[i
] = FLOAT_TO_INT(m
->m
[i
]);
1780 m
= *(GLmatrix
**) p
;
1781 for (i
= 0; i
< 16; i
++)
1782 params
[i
] = FLOAT_TO_INT(m
->m
[transpose
[i
]]);
1793 shift
= d
->type
- TYPE_BIT_0
;
1794 params
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
1801 _mesa_GetDoublev(GLenum pname
, GLdouble
*params
)
1803 const struct value_desc
*d
;
1808 GET_CURRENT_CONTEXT(ctx
);
1810 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1812 d
= find_value("glGetDoublev", pname
, &p
, &v
);
1817 params
[0] = d
->offset
;
1822 params
[3] = ((GLfloat
*) p
)[3];
1825 params
[2] = ((GLfloat
*) p
)[2];
1828 params
[1] = ((GLfloat
*) p
)[1];
1831 params
[0] = ((GLfloat
*) p
)[0];
1835 params
[0] = ((GLdouble
*) p
)[0];
1839 params
[3] = ((GLint
*) p
)[3];
1841 params
[2] = ((GLint
*) p
)[2];
1844 params
[1] = ((GLint
*) p
)[1];
1847 params
[0] = ((GLint
*) p
)[0];
1851 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
1852 params
[i
] = v
.value_int_n
.ints
[i
];
1856 params
[0] = ((GLint64
*) p
)[0];
1860 params
[0] = *(GLboolean
*) p
;
1864 m
= *(GLmatrix
**) p
;
1865 for (i
= 0; i
< 16; i
++)
1866 params
[i
] = m
->m
[i
];
1870 m
= *(GLmatrix
**) p
;
1871 for (i
= 0; i
< 16; i
++)
1872 params
[i
] = m
->m
[transpose
[i
]];
1883 shift
= d
->type
- TYPE_BIT_0
;
1884 params
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
1891 _mesa_GetFixedv(GLenum pname
, GLfixed
*params
)
1893 const struct value_desc
*d
;
1899 d
= find_value("glGetDoublev", pname
, &p
, &v
);
1904 params
[0] = INT_TO_FIXED(d
->offset
);
1909 params
[3] = FLOAT_TO_FIXED(((GLfloat
*) p
)[3]);
1912 params
[2] = FLOAT_TO_FIXED(((GLfloat
*) p
)[2]);
1915 params
[1] = FLOAT_TO_FIXED(((GLfloat
*) p
)[1]);
1918 params
[0] = FLOAT_TO_FIXED(((GLfloat
*) p
)[0]);
1922 params
[0] = FLOAT_TO_FIXED(((GLdouble
*) p
)[0]);
1926 params
[3] = INT_TO_FIXED(((GLint
*) p
)[3]);
1928 params
[2] = INT_TO_FIXED(((GLint
*) p
)[2]);
1931 params
[1] = INT_TO_FIXED(((GLint
*) p
)[1]);
1934 params
[0] = INT_TO_FIXED(((GLint
*) p
)[0]);
1938 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
1939 params
[i
] = INT_TO_FIXED(v
.value_int_n
.ints
[i
]);
1943 params
[0] = ((GLint64
*) p
)[0];
1947 params
[0] = BOOLEAN_TO_FIXED(((GLboolean
*) p
)[0]);
1951 m
= *(GLmatrix
**) p
;
1952 for (i
= 0; i
< 16; i
++)
1953 params
[i
] = FLOAT_TO_FIXED(m
->m
[i
]);
1957 m
= *(GLmatrix
**) p
;
1958 for (i
= 0; i
< 16; i
++)
1959 params
[i
] = FLOAT_TO_FIXED(m
->m
[transpose
[i
]]);
1970 shift
= d
->type
- TYPE_BIT_0
;
1971 params
[0] = BOOLEAN_TO_FIXED((*(GLbitfield
*) p
>> shift
) & 1);