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 "texcompress.h"
36 #include "framebuffer.h"
38 /* This is a table driven implemetation of the glGet*v() functions.
39 * The basic idea is that most getters just look up an int somewhere
40 * in struct gl_context and then convert it to a bool or float according to
41 * which of glGetIntegerv() glGetBooleanv() etc is being called.
42 * Instead of generating code to do this, we can just record the enum
43 * value and the offset into struct gl_context in an array of structs. Then
44 * in glGet*(), we lookup the struct for the enum in question, and use
45 * the offset to get the int we need.
47 * Sometimes we need to look up a float, a boolean, a bit in a
48 * bitfield, a matrix or other types instead, so we need to track the
49 * type of the value in struct gl_context. And sometimes the value isn't in
50 * struct gl_context but in the drawbuffer, the array object, current texture
51 * unit, or maybe it's a computed value. So we need to also track
52 * where or how to find the value. Finally, we sometimes need to
53 * check that one of a number of extensions are enabled, the GL
54 * version or flush or call _mesa_update_state(). This is done by
55 * attaching optional extra information to the value description
56 * struct, it's sort of like an array of opcodes that describe extra
59 * Putting all this together we end up with struct value_desc below,
60 * and with a couple of macros to help, the table of struct value_desc
61 * is about as concise as the specification in the old python script.
66 #define FLOAT_TO_BOOLEAN(X) ( (X) ? GL_TRUE : GL_FALSE )
67 #define FLOAT_TO_FIXED(F) ( ((F) * 65536.0f > INT_MAX) ? INT_MAX : \
68 ((F) * 65536.0f < INT_MIN) ? INT_MIN : \
69 (GLint) ((F) * 65536.0f) )
71 #define INT_TO_BOOLEAN(I) ( (I) ? GL_TRUE : GL_FALSE )
72 #define INT_TO_FIXED(I) ( ((I) > SHRT_MAX) ? INT_MAX : \
73 ((I) < SHRT_MIN) ? INT_MIN : \
74 (GLint) ((I) * 65536) )
76 #define INT64_TO_BOOLEAN(I) ( (I) ? GL_TRUE : GL_FALSE )
77 #define INT64_TO_INT(I) ( (GLint)((I > INT_MAX) ? INT_MAX : ((I < INT_MIN) ? INT_MIN : (I))) )
79 #define BOOLEAN_TO_INT(B) ( (GLint) (B) )
80 #define BOOLEAN_TO_INT64(B) ( (GLint64) (B) )
81 #define BOOLEAN_TO_FLOAT(B) ( (B) ? 1.0F : 0.0F )
82 #define BOOLEAN_TO_FIXED(B) ( (GLint) ((B) ? 1 : 0) << 16 )
84 #define ENUM_TO_INT64(E) ( (GLint64) (E) )
85 #define ENUM_TO_FIXED(E) (E)
119 enum value_location
{
134 EXTRA_NEW_FRAG_CLAMP
,
135 EXTRA_VALID_DRAW_BUFFER
,
136 EXTRA_VALID_TEXTURE_UNIT
,
140 #define NO_EXTRA NULL
145 GLubyte location
; /**< enum value_location */
146 GLubyte type
; /**< enum value_type */
153 GLfloat value_float_4
[4];
154 GLmatrix
*value_matrix
;
156 GLint value_int_4
[4];
160 /* Sigh, see GL_COMPRESSED_TEXTURE_FORMATS_ARB handling */
164 GLboolean value_bool
;
167 #define BUFFER_FIELD(field, type) \
168 LOC_BUFFER, type, offsetof(struct gl_framebuffer, field)
169 #define CONTEXT_FIELD(field, type) \
170 LOC_CONTEXT, type, offsetof(struct gl_context, field)
171 #define ARRAY_FIELD(field, type) \
172 LOC_ARRAY, type, offsetof(struct gl_array_object, field)
173 #define CONST(value) \
174 LOC_CONTEXT, TYPE_CONST, value
176 #define BUFFER_INT(field) BUFFER_FIELD(field, TYPE_INT)
177 #define BUFFER_ENUM(field) BUFFER_FIELD(field, TYPE_ENUM)
178 #define BUFFER_BOOL(field) BUFFER_FIELD(field, TYPE_BOOLEAN)
180 #define CONTEXT_INT(field) CONTEXT_FIELD(field, TYPE_INT)
181 #define CONTEXT_INT2(field) CONTEXT_FIELD(field, TYPE_INT_2)
182 #define CONTEXT_INT64(field) CONTEXT_FIELD(field, TYPE_INT64)
183 #define CONTEXT_ENUM(field) CONTEXT_FIELD(field, TYPE_ENUM)
184 #define CONTEXT_ENUM2(field) CONTEXT_FIELD(field, TYPE_ENUM_2)
185 #define CONTEXT_BOOL(field) CONTEXT_FIELD(field, TYPE_BOOLEAN)
186 #define CONTEXT_BIT0(field) CONTEXT_FIELD(field, TYPE_BIT_0)
187 #define CONTEXT_BIT1(field) CONTEXT_FIELD(field, TYPE_BIT_1)
188 #define CONTEXT_BIT2(field) CONTEXT_FIELD(field, TYPE_BIT_2)
189 #define CONTEXT_BIT3(field) CONTEXT_FIELD(field, TYPE_BIT_3)
190 #define CONTEXT_BIT4(field) CONTEXT_FIELD(field, TYPE_BIT_4)
191 #define CONTEXT_BIT5(field) CONTEXT_FIELD(field, TYPE_BIT_5)
192 #define CONTEXT_FLOAT(field) CONTEXT_FIELD(field, TYPE_FLOAT)
193 #define CONTEXT_FLOAT2(field) CONTEXT_FIELD(field, TYPE_FLOAT_2)
194 #define CONTEXT_FLOAT3(field) CONTEXT_FIELD(field, TYPE_FLOAT_3)
195 #define CONTEXT_FLOAT4(field) CONTEXT_FIELD(field, TYPE_FLOAT_4)
196 #define CONTEXT_MATRIX(field) CONTEXT_FIELD(field, TYPE_MATRIX)
197 #define CONTEXT_MATRIX_T(field) CONTEXT_FIELD(field, TYPE_MATRIX_T)
199 #define ARRAY_INT(field) ARRAY_FIELD(field, TYPE_INT)
200 #define ARRAY_ENUM(field) ARRAY_FIELD(field, TYPE_ENUM)
201 #define ARRAY_BOOL(field) ARRAY_FIELD(field, TYPE_BOOLEAN)
204 offsetof(struct gl_extensions, f)
206 #define EXTRA_EXT(e) \
207 static const int extra_##e[] = { \
211 #define EXTRA_EXT2(e1, e2) \
212 static const int extra_##e1##_##e2[] = { \
213 EXT(e1), EXT(e2), EXTRA_END \
216 /* The 'extra' mechanism is a way to specify extra checks (such as
217 * extensions or specific gl versions) or actions (flush current, new
218 * buffers) that we need to do before looking up an enum. We need to
219 * declare them all up front so we can refer to them in the value_desc
222 static const int extra_new_buffers
[] = {
227 static const int extra_new_frag_clamp
[] = {
228 EXTRA_NEW_FRAG_CLAMP
,
232 static const int extra_valid_draw_buffer
[] = {
233 EXTRA_VALID_DRAW_BUFFER
,
237 static const int extra_valid_texture_unit
[] = {
238 EXTRA_VALID_TEXTURE_UNIT
,
242 static const int extra_flush_current_valid_texture_unit
[] = {
244 EXTRA_VALID_TEXTURE_UNIT
,
248 static const int extra_flush_current
[] = {
253 static const int extra_new_buffers_OES_read_format
[] = {
255 EXT(OES_read_format
),
259 static const int extra_EXT_secondary_color_flush_current
[] = {
260 EXT(EXT_secondary_color
),
265 static const int extra_EXT_fog_coord_flush_current
[] = {
271 static const int extra_EXT_texture_integer
[] = {
272 EXT(EXT_texture_integer
),
276 static const int extra_EXT_gpu_shader4
[] = {
277 EXT(EXT_gpu_shader4
),
282 EXTRA_EXT(ARB_ES2_compatibility
);
283 EXTRA_EXT(ARB_multitexture
);
284 EXTRA_EXT(ARB_texture_cube_map
);
285 EXTRA_EXT(MESA_texture_array
);
286 EXTRA_EXT2(EXT_secondary_color
, ARB_vertex_program
);
287 EXTRA_EXT(EXT_secondary_color
);
288 EXTRA_EXT(EXT_fog_coord
);
289 EXTRA_EXT(EXT_texture_lod_bias
);
290 EXTRA_EXT(EXT_texture_filter_anisotropic
);
291 EXTRA_EXT(IBM_rasterpos_clip
);
292 EXTRA_EXT(NV_point_sprite
);
293 EXTRA_EXT(SGIS_generate_mipmap
);
294 EXTRA_EXT(NV_vertex_program
);
295 EXTRA_EXT(NV_fragment_program
);
296 EXTRA_EXT(NV_texture_rectangle
);
297 EXTRA_EXT(EXT_stencil_two_side
);
298 EXTRA_EXT(NV_light_max_exponent
);
299 EXTRA_EXT(EXT_depth_bounds_test
);
300 EXTRA_EXT(ARB_depth_clamp
);
301 EXTRA_EXT(ATI_fragment_shader
);
302 EXTRA_EXT(EXT_framebuffer_blit
);
303 EXTRA_EXT(ARB_shader_objects
);
304 EXTRA_EXT(EXT_provoking_vertex
);
305 EXTRA_EXT(ARB_fragment_shader
);
306 EXTRA_EXT(ARB_fragment_program
);
307 EXTRA_EXT2(ARB_framebuffer_object
, EXT_framebuffer_multisample
);
308 EXTRA_EXT(EXT_framebuffer_object
);
309 EXTRA_EXT(APPLE_vertex_array_object
);
310 EXTRA_EXT(ARB_seamless_cube_map
);
311 EXTRA_EXT(EXT_compiled_vertex_array
);
313 EXTRA_EXT(ARB_vertex_shader
);
314 EXTRA_EXT(EXT_transform_feedback
);
315 EXTRA_EXT(ARB_transform_feedback2
);
316 EXTRA_EXT(EXT_pixel_buffer_object
);
317 EXTRA_EXT(ARB_vertex_program
);
318 EXTRA_EXT2(NV_point_sprite
, ARB_point_sprite
);
319 EXTRA_EXT2(ARB_fragment_program
, NV_fragment_program
);
320 EXTRA_EXT2(ARB_vertex_program
, NV_vertex_program
);
321 EXTRA_EXT2(ARB_vertex_program
, ARB_fragment_program
);
322 EXTRA_EXT(ARB_vertex_buffer_object
);
323 EXTRA_EXT(ARB_geometry_shader4
);
324 EXTRA_EXT(ARB_copy_buffer
);
325 EXTRA_EXT(EXT_framebuffer_sRGB
);
328 extra_ARB_vertex_program_ARB_fragment_program_NV_vertex_program
[] = {
329 EXT(ARB_vertex_program
),
330 EXT(ARB_fragment_program
),
331 EXT(NV_vertex_program
),
336 extra_NV_vertex_program_ARB_vertex_program_ARB_fragment_program_NV_vertex_program
[] = {
337 EXT(NV_vertex_program
),
338 EXT(ARB_vertex_program
),
339 EXT(ARB_fragment_program
),
340 EXT(NV_vertex_program
),
345 extra_NV_primitive_restart
[] = {
346 EXT(NV_primitive_restart
),
350 static const int extra_version_30
[] = { EXTRA_VERSION_30
, EXTRA_END
};
351 static const int extra_version_31
[] = { EXTRA_VERSION_31
, EXTRA_END
};
352 static const int extra_version_32
[] = { EXTRA_VERSION_32
, EXTRA_END
};
355 extra_ARB_vertex_program_version_es2
[] = {
356 EXT(ARB_vertex_program
),
361 #define API_OPENGL_BIT (1 << API_OPENGL)
362 #define API_OPENGLES_BIT (1 << API_OPENGLES)
363 #define API_OPENGLES2_BIT (1 << API_OPENGLES2)
365 /* This is the big table describing all the enums we accept in
366 * glGet*v(). The table is partitioned into six parts: enums
367 * understood by all GL APIs (OpenGL, GLES and GLES2), enums shared
368 * between OpenGL and GLES, enums exclusive to GLES, etc for the
369 * remaining combinations. When we add the enums to the hash table in
370 * _mesa_init_get_hash(), we only add the enums for the API we're
371 * instantiating and the different sections are guarded by #if
372 * FEATURE_GL etc to make sure we only compile in the enums we may
375 static const struct value_desc values
[] = {
376 /* Enums shared between OpenGL, GLES1 and GLES2 */
377 { 0, 0, TYPE_API_MASK
,
378 API_OPENGL_BIT
| API_OPENGLES_BIT
| API_OPENGLES2_BIT
, NO_EXTRA
},
379 { GL_ALPHA_BITS
, BUFFER_INT(Visual
.alphaBits
), extra_new_buffers
},
380 { GL_BLEND
, CONTEXT_BIT0(Color
.BlendEnabled
), NO_EXTRA
},
381 { GL_BLEND_SRC
, CONTEXT_ENUM(Color
.Blend
[0].SrcRGB
), NO_EXTRA
},
382 { GL_BLUE_BITS
, BUFFER_INT(Visual
.blueBits
), extra_new_buffers
},
383 { GL_COLOR_CLEAR_VALUE
, LOC_CUSTOM
, TYPE_FLOATN_4
, 0, extra_new_frag_clamp
},
384 { GL_COLOR_WRITEMASK
, LOC_CUSTOM
, TYPE_INT_4
, 0, NO_EXTRA
},
385 { GL_CULL_FACE
, CONTEXT_BOOL(Polygon
.CullFlag
), NO_EXTRA
},
386 { GL_CULL_FACE_MODE
, CONTEXT_ENUM(Polygon
.CullFaceMode
), NO_EXTRA
},
387 { GL_DEPTH_BITS
, BUFFER_INT(Visual
.depthBits
), NO_EXTRA
},
388 { GL_DEPTH_CLEAR_VALUE
, CONTEXT_FIELD(Depth
.Clear
, TYPE_DOUBLEN
), NO_EXTRA
},
389 { GL_DEPTH_FUNC
, CONTEXT_ENUM(Depth
.Func
), NO_EXTRA
},
390 { GL_DEPTH_RANGE
, CONTEXT_FIELD(Viewport
.Near
, TYPE_FLOATN_2
), NO_EXTRA
},
391 { GL_DEPTH_TEST
, CONTEXT_BOOL(Depth
.Test
), NO_EXTRA
},
392 { GL_DEPTH_WRITEMASK
, CONTEXT_BOOL(Depth
.Mask
), NO_EXTRA
},
393 { GL_DITHER
, CONTEXT_BOOL(Color
.DitherFlag
), NO_EXTRA
},
394 { GL_FRONT_FACE
, CONTEXT_ENUM(Polygon
.FrontFace
), NO_EXTRA
},
395 { GL_GREEN_BITS
, BUFFER_INT(Visual
.greenBits
), extra_new_buffers
},
396 { GL_LINE_WIDTH
, CONTEXT_FLOAT(Line
.Width
), NO_EXTRA
},
397 { GL_ALIASED_LINE_WIDTH_RANGE
, CONTEXT_FLOAT2(Const
.MinLineWidth
), NO_EXTRA
},
398 { GL_MAX_ELEMENTS_VERTICES
, CONTEXT_INT(Const
.MaxArrayLockSize
), NO_EXTRA
},
399 { GL_MAX_ELEMENTS_INDICES
, CONTEXT_INT(Const
.MaxArrayLockSize
), NO_EXTRA
},
400 { GL_MAX_TEXTURE_SIZE
, LOC_CUSTOM
, TYPE_INT
,
401 offsetof(struct gl_context
, Const
.MaxTextureLevels
), NO_EXTRA
},
402 { GL_MAX_VIEWPORT_DIMS
, CONTEXT_INT2(Const
.MaxViewportWidth
), NO_EXTRA
},
403 { GL_PACK_ALIGNMENT
, CONTEXT_INT(Pack
.Alignment
), NO_EXTRA
},
404 { GL_ALIASED_POINT_SIZE_RANGE
, CONTEXT_FLOAT2(Const
.MinPointSize
), NO_EXTRA
},
405 { GL_POLYGON_OFFSET_FACTOR
, CONTEXT_FLOAT(Polygon
.OffsetFactor
), NO_EXTRA
},
406 { GL_POLYGON_OFFSET_UNITS
, CONTEXT_FLOAT(Polygon
.OffsetUnits
), NO_EXTRA
},
407 { GL_POLYGON_OFFSET_FILL
, CONTEXT_BOOL(Polygon
.OffsetFill
), NO_EXTRA
},
408 { GL_RED_BITS
, BUFFER_INT(Visual
.redBits
), extra_new_buffers
},
409 { GL_SCISSOR_BOX
, LOC_CUSTOM
, TYPE_INT_4
, 0, NO_EXTRA
},
410 { GL_SCISSOR_TEST
, CONTEXT_BOOL(Scissor
.Enabled
), NO_EXTRA
},
411 { GL_STENCIL_BITS
, BUFFER_INT(Visual
.stencilBits
), NO_EXTRA
},
412 { GL_STENCIL_CLEAR_VALUE
, CONTEXT_INT(Stencil
.Clear
), NO_EXTRA
},
413 { GL_STENCIL_FAIL
, LOC_CUSTOM
, TYPE_ENUM
, NO_OFFSET
, NO_EXTRA
},
414 { GL_STENCIL_FUNC
, LOC_CUSTOM
, TYPE_ENUM
, NO_OFFSET
, NO_EXTRA
},
415 { GL_STENCIL_PASS_DEPTH_FAIL
, LOC_CUSTOM
, TYPE_ENUM
, NO_OFFSET
, NO_EXTRA
},
416 { GL_STENCIL_PASS_DEPTH_PASS
, LOC_CUSTOM
, TYPE_ENUM
, NO_OFFSET
, NO_EXTRA
},
417 { GL_STENCIL_REF
, LOC_CUSTOM
, TYPE_INT
, NO_OFFSET
, NO_EXTRA
},
418 { GL_STENCIL_TEST
, CONTEXT_BOOL(Stencil
.Enabled
), NO_EXTRA
},
419 { GL_STENCIL_VALUE_MASK
, LOC_CUSTOM
, TYPE_INT
, NO_OFFSET
, NO_EXTRA
},
420 { GL_STENCIL_WRITEMASK
, LOC_CUSTOM
, TYPE_INT
, NO_OFFSET
, NO_EXTRA
},
421 { GL_SUBPIXEL_BITS
, CONTEXT_INT(Const
.SubPixelBits
), NO_EXTRA
},
422 { GL_TEXTURE_BINDING_2D
, LOC_CUSTOM
, TYPE_INT
, TEXTURE_2D_INDEX
, NO_EXTRA
},
423 { GL_UNPACK_ALIGNMENT
, CONTEXT_INT(Unpack
.Alignment
), NO_EXTRA
},
424 { GL_VIEWPORT
, LOC_CUSTOM
, TYPE_INT_4
, 0, NO_EXTRA
},
426 /* GL_ARB_multitexture */
427 { GL_ACTIVE_TEXTURE_ARB
,
428 LOC_CUSTOM
, TYPE_INT
, 0, extra_ARB_multitexture
},
430 /* Note that all the OES_* extensions require that the Mesa "struct
431 * gl_extensions" include a member with the name of the extension.
432 * That structure does not yet include OES extensions (and we're
433 * not sure whether it will). If it does, all the OES_*
434 * extensions below should mark the dependency. */
436 /* GL_ARB_texture_cube_map */
437 { GL_TEXTURE_BINDING_CUBE_MAP_ARB
, LOC_CUSTOM
, TYPE_INT
,
438 TEXTURE_CUBE_INDEX
, extra_ARB_texture_cube_map
},
439 { GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB
, LOC_CUSTOM
, TYPE_INT
,
440 offsetof(struct gl_context
, Const
.MaxCubeTextureLevels
),
441 extra_ARB_texture_cube_map
}, /* XXX: OES_texture_cube_map */
443 /* XXX: OES_blend_subtract */
444 { GL_BLEND_SRC_RGB_EXT
, CONTEXT_ENUM(Color
.Blend
[0].SrcRGB
), NO_EXTRA
},
445 { GL_BLEND_DST_RGB_EXT
, CONTEXT_ENUM(Color
.Blend
[0].DstRGB
), NO_EXTRA
},
446 { GL_BLEND_SRC_ALPHA_EXT
, CONTEXT_ENUM(Color
.Blend
[0].SrcA
), NO_EXTRA
},
447 { GL_BLEND_DST_ALPHA_EXT
, CONTEXT_ENUM(Color
.Blend
[0].DstA
), NO_EXTRA
},
449 /* GL_BLEND_EQUATION_RGB, which is what we're really after, is
450 * defined identically to GL_BLEND_EQUATION. */
451 { GL_BLEND_EQUATION
, CONTEXT_ENUM(Color
.Blend
[0].EquationRGB
), NO_EXTRA
},
452 { GL_BLEND_EQUATION_ALPHA_EXT
, CONTEXT_ENUM(Color
.Blend
[0].EquationA
), NO_EXTRA
},
454 /* GL_ARB_texture_compression */
455 { GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB
, LOC_CUSTOM
, TYPE_INT
, 0, NO_EXTRA
},
456 { GL_COMPRESSED_TEXTURE_FORMATS_ARB
, LOC_CUSTOM
, TYPE_INT_N
, 0, NO_EXTRA
},
458 /* GL_ARB_multisample */
459 { GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
,
460 CONTEXT_BOOL(Multisample
.SampleAlphaToCoverage
), NO_EXTRA
},
461 { GL_SAMPLE_COVERAGE_ARB
, CONTEXT_BOOL(Multisample
.SampleCoverage
), NO_EXTRA
},
462 { GL_SAMPLE_COVERAGE_VALUE_ARB
,
463 CONTEXT_FLOAT(Multisample
.SampleCoverageValue
), NO_EXTRA
},
464 { GL_SAMPLE_COVERAGE_INVERT_ARB
,
465 CONTEXT_BOOL(Multisample
.SampleCoverageInvert
), NO_EXTRA
},
466 { GL_SAMPLE_BUFFERS_ARB
, BUFFER_INT(Visual
.sampleBuffers
), NO_EXTRA
},
467 { GL_SAMPLES_ARB
, BUFFER_INT(Visual
.samples
), NO_EXTRA
},
469 /* GL_SGIS_generate_mipmap */
470 { GL_GENERATE_MIPMAP_HINT_SGIS
, CONTEXT_ENUM(Hint
.GenerateMipmap
),
471 extra_SGIS_generate_mipmap
},
473 /* GL_ARB_vertex_buffer_object */
474 { GL_ARRAY_BUFFER_BINDING_ARB
, LOC_CUSTOM
, TYPE_INT
, 0, NO_EXTRA
},
476 /* GL_ARB_vertex_buffer_object */
477 /* GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB - not supported */
478 { GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB
, LOC_CUSTOM
, TYPE_INT
, 0,
479 extra_ARB_vertex_buffer_object
},
481 /* GL_ARB_copy_buffer */
482 { GL_COPY_READ_BUFFER
, LOC_CUSTOM
, TYPE_INT
, 0, extra_ARB_copy_buffer
},
483 { GL_COPY_WRITE_BUFFER
, LOC_CUSTOM
, TYPE_INT
, 0, extra_ARB_copy_buffer
},
485 /* GL_OES_read_format */
486 { GL_IMPLEMENTATION_COLOR_READ_TYPE_OES
, LOC_CUSTOM
, TYPE_INT
, 0,
487 extra_new_buffers_OES_read_format
},
488 { GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES
, LOC_CUSTOM
, TYPE_INT
, 0,
489 extra_new_buffers_OES_read_format
},
491 /* GL_EXT_framebuffer_object */
492 { GL_FRAMEBUFFER_BINDING_EXT
, BUFFER_INT(Name
),
493 extra_EXT_framebuffer_object
},
494 { GL_RENDERBUFFER_BINDING_EXT
, LOC_CUSTOM
, TYPE_INT
, 0,
495 extra_EXT_framebuffer_object
},
496 { GL_MAX_RENDERBUFFER_SIZE_EXT
, CONTEXT_INT(Const
.MaxRenderbufferSize
),
497 extra_EXT_framebuffer_object
},
499 /* This entry isn't spec'ed for GLES 2, but is needed for Mesa's
501 { GL_MAX_CLIP_PLANES
, CONTEXT_INT(Const
.MaxClipPlanes
), NO_EXTRA
},
503 #if FEATURE_GL || FEATURE_ES1
504 /* Enums in OpenGL and GLES1 */
505 { 0, 0, TYPE_API_MASK
, API_OPENGL_BIT
| API_OPENGLES_BIT
, NO_EXTRA
},
506 { GL_LIGHT0
, CONTEXT_BOOL(Light
.Light
[0].Enabled
), NO_EXTRA
},
507 { GL_LIGHT1
, CONTEXT_BOOL(Light
.Light
[1].Enabled
), NO_EXTRA
},
508 { GL_LIGHT2
, CONTEXT_BOOL(Light
.Light
[2].Enabled
), NO_EXTRA
},
509 { GL_LIGHT3
, CONTEXT_BOOL(Light
.Light
[3].Enabled
), NO_EXTRA
},
510 { GL_LIGHT4
, CONTEXT_BOOL(Light
.Light
[4].Enabled
), NO_EXTRA
},
511 { GL_LIGHT5
, CONTEXT_BOOL(Light
.Light
[5].Enabled
), NO_EXTRA
},
512 { GL_LIGHT6
, CONTEXT_BOOL(Light
.Light
[6].Enabled
), NO_EXTRA
},
513 { GL_LIGHT7
, CONTEXT_BOOL(Light
.Light
[7].Enabled
), NO_EXTRA
},
514 { GL_LIGHTING
, CONTEXT_BOOL(Light
.Enabled
), NO_EXTRA
},
515 { GL_LIGHT_MODEL_AMBIENT
,
516 CONTEXT_FIELD(Light
.Model
.Ambient
[0], TYPE_FLOATN_4
), NO_EXTRA
},
517 { GL_LIGHT_MODEL_TWO_SIDE
, CONTEXT_BOOL(Light
.Model
.TwoSide
), NO_EXTRA
},
518 { GL_ALPHA_TEST
, CONTEXT_BOOL(Color
.AlphaEnabled
), NO_EXTRA
},
519 { GL_ALPHA_TEST_FUNC
, CONTEXT_ENUM(Color
.AlphaFunc
), NO_EXTRA
},
520 { GL_ALPHA_TEST_REF
, LOC_CUSTOM
, TYPE_FLOATN
, 0, extra_new_frag_clamp
},
521 { GL_BLEND_DST
, CONTEXT_ENUM(Color
.Blend
[0].DstRGB
), NO_EXTRA
},
522 { GL_CLIP_PLANE0
, CONTEXT_BIT0(Transform
.ClipPlanesEnabled
), NO_EXTRA
},
523 { GL_CLIP_PLANE1
, CONTEXT_BIT1(Transform
.ClipPlanesEnabled
), NO_EXTRA
},
524 { GL_CLIP_PLANE2
, CONTEXT_BIT2(Transform
.ClipPlanesEnabled
), NO_EXTRA
},
525 { GL_CLIP_PLANE3
, CONTEXT_BIT3(Transform
.ClipPlanesEnabled
), NO_EXTRA
},
526 { GL_CLIP_PLANE4
, CONTEXT_BIT4(Transform
.ClipPlanesEnabled
), NO_EXTRA
},
527 { GL_CLIP_PLANE5
, CONTEXT_BIT5(Transform
.ClipPlanesEnabled
), NO_EXTRA
},
528 { GL_COLOR_MATERIAL
, CONTEXT_BOOL(Light
.ColorMaterialEnabled
), NO_EXTRA
},
530 CONTEXT_FIELD(Current
.Attrib
[VERT_ATTRIB_COLOR0
][0], TYPE_FLOATN_4
),
531 extra_flush_current
},
533 CONTEXT_FIELD(Current
.Attrib
[VERT_ATTRIB_NORMAL
][0], TYPE_FLOATN_3
),
534 extra_flush_current
},
535 { GL_CURRENT_TEXTURE_COORDS
, LOC_CUSTOM
, TYPE_FLOAT_4
, 0,
536 extra_flush_current_valid_texture_unit
},
537 { GL_DISTANCE_ATTENUATION_EXT
, CONTEXT_FLOAT3(Point
.Params
[0]), NO_EXTRA
},
538 { GL_FOG
, CONTEXT_BOOL(Fog
.Enabled
), NO_EXTRA
},
539 { GL_FOG_COLOR
, LOC_CUSTOM
, TYPE_FLOATN_4
, 0, extra_new_frag_clamp
},
540 { GL_FOG_DENSITY
, CONTEXT_FLOAT(Fog
.Density
), NO_EXTRA
},
541 { GL_FOG_END
, CONTEXT_FLOAT(Fog
.End
), NO_EXTRA
},
542 { GL_FOG_HINT
, CONTEXT_ENUM(Hint
.Fog
), NO_EXTRA
},
543 { GL_FOG_MODE
, CONTEXT_ENUM(Fog
.Mode
), NO_EXTRA
},
544 { GL_FOG_START
, CONTEXT_FLOAT(Fog
.Start
), NO_EXTRA
},
545 { GL_LINE_SMOOTH
, CONTEXT_BOOL(Line
.SmoothFlag
), NO_EXTRA
},
546 { GL_LINE_SMOOTH_HINT
, CONTEXT_ENUM(Hint
.LineSmooth
), NO_EXTRA
},
547 { GL_LINE_WIDTH_RANGE
, CONTEXT_FLOAT2(Const
.MinLineWidthAA
), NO_EXTRA
},
548 { GL_COLOR_LOGIC_OP
, CONTEXT_BOOL(Color
.ColorLogicOpEnabled
), NO_EXTRA
},
549 { GL_LOGIC_OP_MODE
, CONTEXT_ENUM(Color
.LogicOp
), NO_EXTRA
},
550 { GL_MATRIX_MODE
, CONTEXT_ENUM(Transform
.MatrixMode
), NO_EXTRA
},
551 { GL_MAX_MODELVIEW_STACK_DEPTH
, CONST(MAX_MODELVIEW_STACK_DEPTH
), NO_EXTRA
},
552 { GL_MAX_PROJECTION_STACK_DEPTH
, CONST(MAX_PROJECTION_STACK_DEPTH
), NO_EXTRA
},
553 { GL_MAX_TEXTURE_STACK_DEPTH
, CONST(MAX_TEXTURE_STACK_DEPTH
), NO_EXTRA
},
554 { GL_MODELVIEW_MATRIX
, CONTEXT_MATRIX(ModelviewMatrixStack
.Top
), NO_EXTRA
},
555 { GL_MODELVIEW_STACK_DEPTH
, LOC_CUSTOM
, TYPE_INT
,
556 offsetof(struct gl_context
, ModelviewMatrixStack
.Depth
), NO_EXTRA
},
557 { GL_NORMALIZE
, CONTEXT_BOOL(Transform
.Normalize
), NO_EXTRA
},
558 { GL_PACK_SKIP_IMAGES_EXT
, CONTEXT_INT(Pack
.SkipImages
), NO_EXTRA
},
559 { GL_PERSPECTIVE_CORRECTION_HINT
, CONTEXT_ENUM(Hint
.PerspectiveCorrection
), NO_EXTRA
},
560 { GL_POINT_SIZE
, CONTEXT_FLOAT(Point
.Size
), NO_EXTRA
},
561 { GL_POINT_SIZE_RANGE
, CONTEXT_FLOAT2(Const
.MinPointSizeAA
), NO_EXTRA
},
562 { GL_POINT_SMOOTH
, CONTEXT_BOOL(Point
.SmoothFlag
), NO_EXTRA
},
563 { GL_POINT_SMOOTH_HINT
, CONTEXT_ENUM(Hint
.PointSmooth
), NO_EXTRA
},
564 { GL_POINT_SIZE_MIN_EXT
, CONTEXT_FLOAT(Point
.MinSize
), NO_EXTRA
},
565 { GL_POINT_SIZE_MAX_EXT
, CONTEXT_FLOAT(Point
.MaxSize
), NO_EXTRA
},
566 { GL_POINT_FADE_THRESHOLD_SIZE_EXT
, CONTEXT_FLOAT(Point
.Threshold
), NO_EXTRA
},
567 { GL_PROJECTION_MATRIX
, CONTEXT_MATRIX(ProjectionMatrixStack
.Top
), NO_EXTRA
},
568 { GL_PROJECTION_STACK_DEPTH
, LOC_CUSTOM
, TYPE_INT
,
569 offsetof(struct gl_context
, ProjectionMatrixStack
.Depth
), NO_EXTRA
},
570 { GL_RESCALE_NORMAL
, CONTEXT_BOOL(Transform
.RescaleNormals
), NO_EXTRA
},
571 { GL_SHADE_MODEL
, CONTEXT_ENUM(Light
.ShadeModel
), NO_EXTRA
},
572 { GL_TEXTURE_2D
, LOC_CUSTOM
, TYPE_BOOLEAN
, 0, NO_EXTRA
},
573 { GL_TEXTURE_MATRIX
, LOC_CUSTOM
, TYPE_MATRIX
, 0, extra_valid_texture_unit
},
574 { GL_TEXTURE_STACK_DEPTH
, LOC_CUSTOM
, TYPE_INT
, 0,
575 extra_valid_texture_unit
},
577 { GL_VERTEX_ARRAY
, ARRAY_BOOL(Vertex
.Enabled
), NO_EXTRA
},
578 { GL_VERTEX_ARRAY_SIZE
, ARRAY_INT(Vertex
.Size
), NO_EXTRA
},
579 { GL_VERTEX_ARRAY_TYPE
, ARRAY_ENUM(Vertex
.Type
), NO_EXTRA
},
580 { GL_VERTEX_ARRAY_STRIDE
, ARRAY_INT(Vertex
.Stride
), NO_EXTRA
},
581 { GL_NORMAL_ARRAY
, ARRAY_BOOL(Normal
.Enabled
), NO_EXTRA
},
582 { GL_NORMAL_ARRAY_TYPE
, ARRAY_ENUM(Normal
.Type
), NO_EXTRA
},
583 { GL_NORMAL_ARRAY_STRIDE
, ARRAY_INT(Normal
.Stride
), NO_EXTRA
},
584 { GL_COLOR_ARRAY
, ARRAY_BOOL(Color
.Enabled
), NO_EXTRA
},
585 { GL_COLOR_ARRAY_SIZE
, ARRAY_INT(Color
.Size
), NO_EXTRA
},
586 { GL_COLOR_ARRAY_TYPE
, ARRAY_ENUM(Color
.Type
), NO_EXTRA
},
587 { GL_COLOR_ARRAY_STRIDE
, ARRAY_INT(Color
.Stride
), NO_EXTRA
},
588 { GL_TEXTURE_COORD_ARRAY
,
589 LOC_CUSTOM
, TYPE_BOOLEAN
, offsetof(struct gl_client_array
, Enabled
), NO_EXTRA
},
590 { GL_TEXTURE_COORD_ARRAY_SIZE
,
591 LOC_CUSTOM
, TYPE_INT
, offsetof(struct gl_client_array
, Size
), NO_EXTRA
},
592 { GL_TEXTURE_COORD_ARRAY_TYPE
,
593 LOC_CUSTOM
, TYPE_ENUM
, offsetof(struct gl_client_array
, Type
), NO_EXTRA
},
594 { GL_TEXTURE_COORD_ARRAY_STRIDE
,
595 LOC_CUSTOM
, TYPE_INT
, offsetof(struct gl_client_array
, Stride
), NO_EXTRA
},
597 /* GL_ARB_ES2_compatibility */
598 { GL_SHADER_COMPILER
, CONST(1), extra_ARB_ES2_compatibility
},
599 { GL_MAX_VARYING_VECTORS
, CONTEXT_INT(Const
.MaxVarying
),
600 extra_ARB_ES2_compatibility
},
601 { GL_MAX_VERTEX_UNIFORM_VECTORS
, LOC_CUSTOM
, TYPE_INT
, 0,
602 extra_ARB_ES2_compatibility
},
603 { GL_MAX_FRAGMENT_UNIFORM_VECTORS
, LOC_CUSTOM
, TYPE_INT
, 0,
604 extra_ARB_ES2_compatibility
},
606 /* GL_ARB_multitexture */
607 { GL_MAX_TEXTURE_UNITS_ARB
,
608 CONTEXT_INT(Const
.MaxTextureUnits
), extra_ARB_multitexture
},
609 { GL_CLIENT_ACTIVE_TEXTURE_ARB
,
610 LOC_CUSTOM
, TYPE_INT
, 0, extra_ARB_multitexture
},
612 /* GL_ARB_texture_cube_map */
613 { GL_TEXTURE_CUBE_MAP_ARB
, LOC_CUSTOM
, TYPE_BOOLEAN
, 0, NO_EXTRA
},
614 /* S, T, and R are always set at the same time */
615 { GL_TEXTURE_GEN_STR_OES
, LOC_TEXUNIT
, TYPE_BIT_0
,
616 offsetof(struct gl_texture_unit
, TexGenEnabled
), NO_EXTRA
},
618 /* GL_ARB_multisample */
619 { GL_MULTISAMPLE_ARB
, CONTEXT_BOOL(Multisample
.Enabled
), NO_EXTRA
},
620 { GL_SAMPLE_ALPHA_TO_ONE_ARB
, CONTEXT_BOOL(Multisample
.SampleAlphaToOne
), NO_EXTRA
},
622 /* GL_ARB_vertex_buffer_object */
623 { GL_VERTEX_ARRAY_BUFFER_BINDING_ARB
, LOC_CUSTOM
, TYPE_INT
,
624 offsetof(struct gl_array_object
, Vertex
.BufferObj
), NO_EXTRA
},
625 { GL_NORMAL_ARRAY_BUFFER_BINDING_ARB
, LOC_CUSTOM
, TYPE_INT
,
626 offsetof(struct gl_array_object
, Normal
.BufferObj
), NO_EXTRA
},
627 { GL_COLOR_ARRAY_BUFFER_BINDING_ARB
, LOC_CUSTOM
, TYPE_INT
,
628 offsetof(struct gl_array_object
, Color
.BufferObj
), NO_EXTRA
},
629 { GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB
, LOC_CUSTOM
, TYPE_INT
, NO_OFFSET
, NO_EXTRA
},
631 /* GL_OES_point_sprite */
632 { GL_POINT_SPRITE_NV
,
633 CONTEXT_BOOL(Point
.PointSprite
),
634 extra_NV_point_sprite_ARB_point_sprite
},
636 /* GL_ARB_fragment_shader */
637 { GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB
,
638 CONTEXT_INT(Const
.FragmentProgram
.MaxUniformComponents
),
639 extra_ARB_fragment_shader
},
641 /* GL_ARB_vertex_shader */
642 { GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB
,
643 CONTEXT_INT(Const
.VertexProgram
.MaxUniformComponents
),
644 extra_ARB_vertex_shader
},
645 { GL_MAX_VARYING_FLOATS_ARB
, LOC_CUSTOM
, TYPE_INT
, 0,
646 extra_ARB_vertex_shader
},
648 /* GL_EXT_texture_lod_bias */
649 { GL_MAX_TEXTURE_LOD_BIAS_EXT
, CONTEXT_FLOAT(Const
.MaxTextureLodBias
),
650 extra_EXT_texture_lod_bias
},
652 /* GL_EXT_texture_filter_anisotropic */
653 { GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT
,
654 CONTEXT_FLOAT(Const
.MaxTextureMaxAnisotropy
),
655 extra_EXT_texture_filter_anisotropic
},
656 #endif /* FEATURE_GL || FEATURE_ES1 */
659 { 0, 0, TYPE_API_MASK
, API_OPENGLES_BIT
},
660 /* XXX: OES_matrix_get */
661 { GL_MODELVIEW_MATRIX_FLOAT_AS_INT_BITS_OES
},
662 { GL_PROJECTION_MATRIX_FLOAT_AS_INT_BITS_OES
},
663 { GL_TEXTURE_MATRIX_FLOAT_AS_INT_BITS_OES
},
665 /* OES_point_size_array */
666 { GL_POINT_SIZE_ARRAY_OES
, ARRAY_FIELD(PointSize
.Enabled
, TYPE_BOOLEAN
) },
667 { GL_POINT_SIZE_ARRAY_TYPE_OES
, ARRAY_FIELD(PointSize
.Type
, TYPE_ENUM
) },
668 { GL_POINT_SIZE_ARRAY_STRIDE_OES
, ARRAY_FIELD(PointSize
.Stride
, TYPE_INT
) },
669 { GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES
, LOC_CUSTOM
, TYPE_INT
, 0 },
670 #endif /* FEATURE_ES1 */
672 #if FEATURE_GL || FEATURE_ES2
673 { 0, 0, TYPE_API_MASK
, API_OPENGL_BIT
| API_OPENGLES2_BIT
, NO_EXTRA
},
674 /* This entry isn't spec'ed for GLES 2, but is needed for Mesa's GLSL: */
675 { GL_MAX_LIGHTS
, CONTEXT_INT(Const
.MaxLights
), NO_EXTRA
},
676 { GL_MAX_TEXTURE_COORDS_ARB
, /* == GL_MAX_TEXTURE_COORDS_NV */
677 CONTEXT_INT(Const
.MaxTextureCoordUnits
),
678 extra_ARB_fragment_program_NV_fragment_program
},
680 /* GL_ARB_draw_buffers */
681 { GL_MAX_DRAW_BUFFERS_ARB
, CONTEXT_INT(Const
.MaxDrawBuffers
), NO_EXTRA
},
683 { GL_BLEND_COLOR_EXT
, LOC_CUSTOM
, TYPE_FLOATN_4
, 0, extra_new_frag_clamp
},
684 /* GL_ARB_fragment_program */
685 { GL_MAX_TEXTURE_IMAGE_UNITS_ARB
, /* == GL_MAX_TEXTURE_IMAGE_UNITS_NV */
686 CONTEXT_INT(Const
.MaxTextureImageUnits
),
687 extra_ARB_fragment_program_NV_fragment_program
},
688 { GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB
,
689 CONTEXT_INT(Const
.MaxVertexTextureImageUnits
), extra_ARB_vertex_shader
},
690 { GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB
,
691 CONTEXT_INT(Const
.MaxCombinedTextureImageUnits
),
692 extra_ARB_vertex_shader
},
694 /* GL_ARB_shader_objects
695 * Actually, this token isn't part of GL_ARB_shader_objects, but is
696 * close enough for now. */
697 { GL_CURRENT_PROGRAM
, LOC_CUSTOM
, TYPE_INT
, 0, extra_ARB_shader_objects
},
700 { GL_STENCIL_BACK_FUNC
, CONTEXT_ENUM(Stencil
.Function
[1]), NO_EXTRA
},
701 { GL_STENCIL_BACK_VALUE_MASK
, CONTEXT_INT(Stencil
.ValueMask
[1]), NO_EXTRA
},
702 { GL_STENCIL_BACK_WRITEMASK
, CONTEXT_INT(Stencil
.WriteMask
[1]), NO_EXTRA
},
703 { GL_STENCIL_BACK_REF
, CONTEXT_INT(Stencil
.Ref
[1]), NO_EXTRA
},
704 { GL_STENCIL_BACK_FAIL
, CONTEXT_ENUM(Stencil
.FailFunc
[1]), NO_EXTRA
},
705 { GL_STENCIL_BACK_PASS_DEPTH_FAIL
, CONTEXT_ENUM(Stencil
.ZFailFunc
[1]), NO_EXTRA
},
706 { GL_STENCIL_BACK_PASS_DEPTH_PASS
, CONTEXT_ENUM(Stencil
.ZPassFunc
[1]), NO_EXTRA
},
708 { GL_MAX_VERTEX_ATTRIBS_ARB
,
709 CONTEXT_INT(Const
.VertexProgram
.MaxAttribs
),
710 extra_ARB_vertex_program_version_es2
},
713 { GL_TEXTURE_BINDING_3D
, LOC_CUSTOM
, TYPE_INT
, TEXTURE_3D_INDEX
, NO_EXTRA
},
714 { GL_MAX_3D_TEXTURE_SIZE
, LOC_CUSTOM
, TYPE_INT
,
715 offsetof(struct gl_context
, Const
.Max3DTextureLevels
), NO_EXTRA
},
717 /* GL_ARB_fragment_program/OES_standard_derivatives */
718 { GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB
,
719 CONTEXT_ENUM(Hint
.FragmentShaderDerivative
), extra_ARB_fragment_shader
},
720 #endif /* FEATURE_GL || FEATURE_ES2 */
723 /* Enums unique to OpenGL ES 2.0 */
724 { 0, 0, TYPE_API_MASK
, API_OPENGLES2_BIT
, NO_EXTRA
},
725 { GL_MAX_FRAGMENT_UNIFORM_VECTORS
, LOC_CUSTOM
, TYPE_INT
, 0, NO_EXTRA
},
726 { GL_MAX_VARYING_VECTORS
, CONTEXT_INT(Const
.MaxVarying
), NO_EXTRA
},
727 { GL_MAX_VERTEX_UNIFORM_VECTORS
, LOC_CUSTOM
, TYPE_INT
, 0, NO_EXTRA
},
728 { GL_SHADER_COMPILER
, CONST(1), NO_EXTRA
},
729 /* OES_get_program_binary */
730 { GL_NUM_SHADER_BINARY_FORMATS
, CONST(0), NO_EXTRA
},
731 { GL_SHADER_BINARY_FORMATS
, CONST(0), NO_EXTRA
},
732 #endif /* FEATURE_ES2 */
735 /* Remaining enums are only in OpenGL */
736 { 0, 0, TYPE_API_MASK
, API_OPENGL_BIT
, NO_EXTRA
},
737 { GL_ACCUM_RED_BITS
, BUFFER_INT(Visual
.accumRedBits
), NO_EXTRA
},
738 { GL_ACCUM_GREEN_BITS
, BUFFER_INT(Visual
.accumGreenBits
), NO_EXTRA
},
739 { GL_ACCUM_BLUE_BITS
, BUFFER_INT(Visual
.accumBlueBits
), NO_EXTRA
},
740 { GL_ACCUM_ALPHA_BITS
, BUFFER_INT(Visual
.accumAlphaBits
), NO_EXTRA
},
741 { GL_ACCUM_CLEAR_VALUE
, CONTEXT_FIELD(Accum
.ClearColor
[0], TYPE_FLOATN_4
), NO_EXTRA
},
742 { GL_ALPHA_BIAS
, CONTEXT_FLOAT(Pixel
.AlphaBias
), NO_EXTRA
},
743 { GL_ALPHA_SCALE
, CONTEXT_FLOAT(Pixel
.AlphaScale
), NO_EXTRA
},
744 { GL_ATTRIB_STACK_DEPTH
, CONTEXT_INT(AttribStackDepth
), NO_EXTRA
},
745 { GL_AUTO_NORMAL
, CONTEXT_BOOL(Eval
.AutoNormal
), NO_EXTRA
},
746 { GL_AUX_BUFFERS
, BUFFER_INT(Visual
.numAuxBuffers
), NO_EXTRA
},
747 { GL_BLUE_BIAS
, CONTEXT_FLOAT(Pixel
.BlueBias
), NO_EXTRA
},
748 { GL_BLUE_SCALE
, CONTEXT_FLOAT(Pixel
.BlueScale
), NO_EXTRA
},
749 { GL_CLIENT_ATTRIB_STACK_DEPTH
, CONTEXT_INT(ClientAttribStackDepth
), NO_EXTRA
},
750 { GL_COLOR_MATERIAL_FACE
, CONTEXT_ENUM(Light
.ColorMaterialFace
), NO_EXTRA
},
751 { GL_COLOR_MATERIAL_PARAMETER
, CONTEXT_ENUM(Light
.ColorMaterialMode
), NO_EXTRA
},
753 CONTEXT_FLOAT(Current
.Attrib
[VERT_ATTRIB_COLOR_INDEX
][0]),
754 extra_flush_current
},
755 { GL_CURRENT_RASTER_COLOR
,
756 CONTEXT_FIELD(Current
.RasterColor
[0], TYPE_FLOATN_4
), NO_EXTRA
},
757 { GL_CURRENT_RASTER_DISTANCE
, CONTEXT_FLOAT(Current
.RasterDistance
), NO_EXTRA
},
758 { GL_CURRENT_RASTER_INDEX
, CONST(1), NO_EXTRA
},
759 { GL_CURRENT_RASTER_POSITION
, CONTEXT_FLOAT4(Current
.RasterPos
[0]), NO_EXTRA
},
760 { GL_CURRENT_RASTER_SECONDARY_COLOR
,
761 CONTEXT_FIELD(Current
.RasterSecondaryColor
[0], TYPE_FLOATN_4
), NO_EXTRA
},
762 { GL_CURRENT_RASTER_TEXTURE_COORDS
, LOC_CUSTOM
, TYPE_FLOAT_4
, 0,
763 extra_valid_texture_unit
},
764 { GL_CURRENT_RASTER_POSITION_VALID
, CONTEXT_BOOL(Current
.RasterPosValid
), NO_EXTRA
},
765 { GL_DEPTH_BIAS
, CONTEXT_FLOAT(Pixel
.DepthBias
), NO_EXTRA
},
766 { GL_DEPTH_SCALE
, CONTEXT_FLOAT(Pixel
.DepthScale
), NO_EXTRA
},
767 { GL_DOUBLEBUFFER
, BUFFER_INT(Visual
.doubleBufferMode
), NO_EXTRA
},
768 { GL_DRAW_BUFFER
, BUFFER_ENUM(ColorDrawBuffer
[0]), NO_EXTRA
},
769 { GL_EDGE_FLAG
, LOC_CUSTOM
, TYPE_BOOLEAN
, 0, NO_EXTRA
},
770 { GL_FEEDBACK_BUFFER_SIZE
, CONTEXT_INT(Feedback
.BufferSize
), NO_EXTRA
},
771 { GL_FEEDBACK_BUFFER_TYPE
, CONTEXT_ENUM(Feedback
.Type
), NO_EXTRA
},
772 { GL_FOG_INDEX
, CONTEXT_FLOAT(Fog
.Index
), NO_EXTRA
},
773 { GL_GREEN_BIAS
, CONTEXT_FLOAT(Pixel
.GreenBias
), NO_EXTRA
},
774 { GL_GREEN_SCALE
, CONTEXT_FLOAT(Pixel
.GreenScale
), NO_EXTRA
},
775 { GL_INDEX_BITS
, BUFFER_INT(Visual
.indexBits
), extra_new_buffers
},
776 { GL_INDEX_CLEAR_VALUE
, CONTEXT_INT(Color
.ClearIndex
), NO_EXTRA
},
777 { GL_INDEX_MODE
, CONST(0) , NO_EXTRA
},
778 { GL_INDEX_OFFSET
, CONTEXT_INT(Pixel
.IndexOffset
), NO_EXTRA
},
779 { GL_INDEX_SHIFT
, CONTEXT_INT(Pixel
.IndexShift
), NO_EXTRA
},
780 { GL_INDEX_WRITEMASK
, CONTEXT_INT(Color
.IndexMask
), NO_EXTRA
},
781 { GL_LIGHT_MODEL_COLOR_CONTROL
, CONTEXT_ENUM(Light
.Model
.ColorControl
), NO_EXTRA
},
782 { GL_LIGHT_MODEL_LOCAL_VIEWER
, CONTEXT_BOOL(Light
.Model
.LocalViewer
), NO_EXTRA
},
783 { GL_LINE_STIPPLE
, CONTEXT_BOOL(Line
.StippleFlag
), NO_EXTRA
},
784 { GL_LINE_STIPPLE_PATTERN
, LOC_CUSTOM
, TYPE_INT
, 0, NO_EXTRA
},
785 { GL_LINE_STIPPLE_REPEAT
, CONTEXT_INT(Line
.StippleFactor
), NO_EXTRA
},
786 { GL_LINE_WIDTH_GRANULARITY
, CONTEXT_FLOAT(Const
.LineWidthGranularity
), NO_EXTRA
},
787 { GL_LIST_BASE
, CONTEXT_INT(List
.ListBase
), NO_EXTRA
},
788 { GL_LIST_INDEX
, LOC_CUSTOM
, TYPE_INT
, 0, NO_EXTRA
},
789 { GL_LIST_MODE
, LOC_CUSTOM
, TYPE_ENUM
, 0, NO_EXTRA
},
790 { GL_INDEX_LOGIC_OP
, CONTEXT_BOOL(Color
.IndexLogicOpEnabled
), NO_EXTRA
},
791 { GL_MAP1_COLOR_4
, CONTEXT_BOOL(Eval
.Map1Color4
), NO_EXTRA
},
792 { GL_MAP1_GRID_DOMAIN
, CONTEXT_FLOAT2(Eval
.MapGrid1u1
), NO_EXTRA
},
793 { GL_MAP1_GRID_SEGMENTS
, CONTEXT_INT(Eval
.MapGrid1un
), NO_EXTRA
},
794 { GL_MAP1_INDEX
, CONTEXT_BOOL(Eval
.Map1Index
), NO_EXTRA
},
795 { GL_MAP1_NORMAL
, CONTEXT_BOOL(Eval
.Map1Normal
), NO_EXTRA
},
796 { GL_MAP1_TEXTURE_COORD_1
, CONTEXT_BOOL(Eval
.Map1TextureCoord1
), NO_EXTRA
},
797 { GL_MAP1_TEXTURE_COORD_2
, CONTEXT_BOOL(Eval
.Map1TextureCoord2
), NO_EXTRA
},
798 { GL_MAP1_TEXTURE_COORD_3
, CONTEXT_BOOL(Eval
.Map1TextureCoord3
), NO_EXTRA
},
799 { GL_MAP1_TEXTURE_COORD_4
, CONTEXT_BOOL(Eval
.Map1TextureCoord4
), NO_EXTRA
},
800 { GL_MAP1_VERTEX_3
, CONTEXT_BOOL(Eval
.Map1Vertex3
), NO_EXTRA
},
801 { GL_MAP1_VERTEX_4
, CONTEXT_BOOL(Eval
.Map1Vertex4
), NO_EXTRA
},
802 { GL_MAP2_COLOR_4
, CONTEXT_BOOL(Eval
.Map2Color4
), NO_EXTRA
},
803 { GL_MAP2_GRID_DOMAIN
, LOC_CUSTOM
, TYPE_FLOAT_4
, 0, NO_EXTRA
},
804 { GL_MAP2_GRID_SEGMENTS
, CONTEXT_INT2(Eval
.MapGrid2un
), NO_EXTRA
},
805 { GL_MAP2_INDEX
, CONTEXT_BOOL(Eval
.Map2Index
), NO_EXTRA
},
806 { GL_MAP2_NORMAL
, CONTEXT_BOOL(Eval
.Map2Normal
), NO_EXTRA
},
807 { GL_MAP2_TEXTURE_COORD_1
, CONTEXT_BOOL(Eval
.Map2TextureCoord1
), NO_EXTRA
},
808 { GL_MAP2_TEXTURE_COORD_2
, CONTEXT_BOOL(Eval
.Map2TextureCoord2
), NO_EXTRA
},
809 { GL_MAP2_TEXTURE_COORD_3
, CONTEXT_BOOL(Eval
.Map2TextureCoord3
), NO_EXTRA
},
810 { GL_MAP2_TEXTURE_COORD_4
, CONTEXT_BOOL(Eval
.Map2TextureCoord4
), NO_EXTRA
},
811 { GL_MAP2_VERTEX_3
, CONTEXT_BOOL(Eval
.Map2Vertex3
), NO_EXTRA
},
812 { GL_MAP2_VERTEX_4
, CONTEXT_BOOL(Eval
.Map2Vertex4
), NO_EXTRA
},
813 { GL_MAP_COLOR
, CONTEXT_BOOL(Pixel
.MapColorFlag
), NO_EXTRA
},
814 { GL_MAP_STENCIL
, CONTEXT_BOOL(Pixel
.MapStencilFlag
), NO_EXTRA
},
815 { GL_MAX_ATTRIB_STACK_DEPTH
, CONST(MAX_ATTRIB_STACK_DEPTH
), NO_EXTRA
},
816 { GL_MAX_CLIENT_ATTRIB_STACK_DEPTH
, CONST(MAX_CLIENT_ATTRIB_STACK_DEPTH
), NO_EXTRA
},
818 { GL_MAX_EVAL_ORDER
, CONST(MAX_EVAL_ORDER
), NO_EXTRA
},
819 { GL_MAX_LIST_NESTING
, CONST(MAX_LIST_NESTING
), NO_EXTRA
},
820 { GL_MAX_NAME_STACK_DEPTH
, CONST(MAX_NAME_STACK_DEPTH
), NO_EXTRA
},
821 { GL_MAX_PIXEL_MAP_TABLE
, CONST(MAX_PIXEL_MAP_TABLE
), NO_EXTRA
},
822 { GL_NAME_STACK_DEPTH
, CONTEXT_INT(Select
.NameStackDepth
), NO_EXTRA
},
823 { GL_PACK_LSB_FIRST
, CONTEXT_BOOL(Pack
.LsbFirst
), NO_EXTRA
},
824 { GL_PACK_ROW_LENGTH
, CONTEXT_INT(Pack
.RowLength
), NO_EXTRA
},
825 { GL_PACK_SKIP_PIXELS
, CONTEXT_INT(Pack
.SkipPixels
), NO_EXTRA
},
826 { GL_PACK_SKIP_ROWS
, CONTEXT_INT(Pack
.SkipRows
), NO_EXTRA
},
827 { GL_PACK_SWAP_BYTES
, CONTEXT_BOOL(Pack
.SwapBytes
), NO_EXTRA
},
828 { GL_PACK_IMAGE_HEIGHT_EXT
, CONTEXT_INT(Pack
.ImageHeight
), NO_EXTRA
},
829 { GL_PACK_INVERT_MESA
, CONTEXT_BOOL(Pack
.Invert
), NO_EXTRA
},
830 { GL_PIXEL_MAP_A_TO_A_SIZE
, CONTEXT_INT(PixelMaps
.AtoA
.Size
), NO_EXTRA
},
831 { GL_PIXEL_MAP_B_TO_B_SIZE
, CONTEXT_INT(PixelMaps
.BtoB
.Size
), NO_EXTRA
},
832 { GL_PIXEL_MAP_G_TO_G_SIZE
, CONTEXT_INT(PixelMaps
.GtoG
.Size
), NO_EXTRA
},
833 { GL_PIXEL_MAP_I_TO_A_SIZE
, CONTEXT_INT(PixelMaps
.ItoA
.Size
), NO_EXTRA
},
834 { GL_PIXEL_MAP_I_TO_B_SIZE
, CONTEXT_INT(PixelMaps
.ItoB
.Size
), NO_EXTRA
},
835 { GL_PIXEL_MAP_I_TO_G_SIZE
, CONTEXT_INT(PixelMaps
.ItoG
.Size
), NO_EXTRA
},
836 { GL_PIXEL_MAP_I_TO_I_SIZE
, CONTEXT_INT(PixelMaps
.ItoI
.Size
), NO_EXTRA
},
837 { GL_PIXEL_MAP_I_TO_R_SIZE
, CONTEXT_INT(PixelMaps
.ItoR
.Size
), NO_EXTRA
},
838 { GL_PIXEL_MAP_R_TO_R_SIZE
, CONTEXT_INT(PixelMaps
.RtoR
.Size
), NO_EXTRA
},
839 { GL_PIXEL_MAP_S_TO_S_SIZE
, CONTEXT_INT(PixelMaps
.StoS
.Size
), NO_EXTRA
},
840 { GL_POINT_SIZE_GRANULARITY
, CONTEXT_FLOAT(Const
.PointSizeGranularity
), NO_EXTRA
},
841 { GL_POLYGON_MODE
, CONTEXT_ENUM2(Polygon
.FrontMode
), NO_EXTRA
},
842 { GL_POLYGON_OFFSET_BIAS_EXT
, CONTEXT_FLOAT(Polygon
.OffsetUnits
), NO_EXTRA
},
843 { GL_POLYGON_OFFSET_POINT
, CONTEXT_BOOL(Polygon
.OffsetPoint
), NO_EXTRA
},
844 { GL_POLYGON_OFFSET_LINE
, CONTEXT_BOOL(Polygon
.OffsetLine
), NO_EXTRA
},
845 { GL_POLYGON_SMOOTH
, CONTEXT_BOOL(Polygon
.SmoothFlag
), NO_EXTRA
},
846 { GL_POLYGON_SMOOTH_HINT
, CONTEXT_ENUM(Hint
.PolygonSmooth
), NO_EXTRA
},
847 { GL_POLYGON_STIPPLE
, CONTEXT_BOOL(Polygon
.StippleFlag
), NO_EXTRA
},
848 { GL_READ_BUFFER
, LOC_CUSTOM
, TYPE_ENUM
, NO_OFFSET
, NO_EXTRA
},
849 { GL_RED_BIAS
, CONTEXT_FLOAT(Pixel
.RedBias
), NO_EXTRA
},
850 { GL_RED_SCALE
, CONTEXT_FLOAT(Pixel
.RedScale
), NO_EXTRA
},
851 { GL_RENDER_MODE
, CONTEXT_ENUM(RenderMode
), NO_EXTRA
},
852 { GL_RGBA_MODE
, CONST(1), NO_EXTRA
},
853 { GL_SELECTION_BUFFER_SIZE
, CONTEXT_INT(Select
.BufferSize
), NO_EXTRA
},
854 { GL_SHARED_TEXTURE_PALETTE_EXT
, CONTEXT_BOOL(Texture
.SharedPalette
), NO_EXTRA
},
856 { GL_STEREO
, BUFFER_INT(Visual
.stereoMode
), NO_EXTRA
},
858 { GL_TEXTURE_1D
, LOC_CUSTOM
, TYPE_BOOLEAN
, NO_OFFSET
, NO_EXTRA
},
859 { GL_TEXTURE_3D
, LOC_CUSTOM
, TYPE_BOOLEAN
, NO_OFFSET
, NO_EXTRA
},
860 { GL_TEXTURE_1D_ARRAY_EXT
, LOC_CUSTOM
, TYPE_BOOLEAN
, NO_OFFSET
, NO_EXTRA
},
861 { GL_TEXTURE_2D_ARRAY_EXT
, LOC_CUSTOM
, TYPE_BOOLEAN
, NO_OFFSET
, NO_EXTRA
},
863 { GL_TEXTURE_BINDING_1D
, LOC_CUSTOM
, TYPE_INT
, TEXTURE_1D_INDEX
, NO_EXTRA
},
864 { GL_TEXTURE_BINDING_1D_ARRAY
, LOC_CUSTOM
, TYPE_INT
,
865 TEXTURE_1D_ARRAY_INDEX
, extra_MESA_texture_array
},
866 { GL_TEXTURE_BINDING_2D_ARRAY
, LOC_CUSTOM
, TYPE_INT
,
867 TEXTURE_1D_ARRAY_INDEX
, extra_MESA_texture_array
},
868 { GL_MAX_ARRAY_TEXTURE_LAYERS_EXT
,
869 CONTEXT_INT(Const
.MaxArrayTextureLayers
), extra_MESA_texture_array
},
871 { GL_TEXTURE_GEN_S
, LOC_TEXUNIT
, TYPE_BIT_0
,
872 offsetof(struct gl_texture_unit
, TexGenEnabled
), NO_EXTRA
},
873 { GL_TEXTURE_GEN_T
, LOC_TEXUNIT
, TYPE_BIT_1
,
874 offsetof(struct gl_texture_unit
, TexGenEnabled
), NO_EXTRA
},
875 { GL_TEXTURE_GEN_R
, LOC_TEXUNIT
, TYPE_BIT_2
,
876 offsetof(struct gl_texture_unit
, TexGenEnabled
), NO_EXTRA
},
877 { GL_TEXTURE_GEN_Q
, LOC_TEXUNIT
, TYPE_BIT_3
,
878 offsetof(struct gl_texture_unit
, TexGenEnabled
), NO_EXTRA
},
879 { GL_UNPACK_LSB_FIRST
, CONTEXT_BOOL(Unpack
.LsbFirst
), NO_EXTRA
},
880 { GL_UNPACK_ROW_LENGTH
, CONTEXT_INT(Unpack
.RowLength
), NO_EXTRA
},
881 { GL_UNPACK_SKIP_PIXELS
, CONTEXT_INT(Unpack
.SkipPixels
), NO_EXTRA
},
882 { GL_UNPACK_SKIP_ROWS
, CONTEXT_INT(Unpack
.SkipRows
), NO_EXTRA
},
883 { GL_UNPACK_SWAP_BYTES
, CONTEXT_BOOL(Unpack
.SwapBytes
), NO_EXTRA
},
884 { GL_UNPACK_SKIP_IMAGES_EXT
, CONTEXT_INT(Unpack
.SkipImages
), NO_EXTRA
},
885 { GL_UNPACK_IMAGE_HEIGHT_EXT
, CONTEXT_INT(Unpack
.ImageHeight
), NO_EXTRA
},
886 { GL_UNPACK_CLIENT_STORAGE_APPLE
, CONTEXT_BOOL(Unpack
.ClientStorage
), NO_EXTRA
},
887 { GL_ZOOM_X
, CONTEXT_FLOAT(Pixel
.ZoomX
), NO_EXTRA
},
888 { GL_ZOOM_Y
, CONTEXT_FLOAT(Pixel
.ZoomY
), NO_EXTRA
},
891 { GL_VERTEX_ARRAY_COUNT_EXT
, CONST(0), NO_EXTRA
},
892 { GL_NORMAL_ARRAY_COUNT_EXT
, CONST(0), NO_EXTRA
},
893 { GL_COLOR_ARRAY_COUNT_EXT
, CONST(0), NO_EXTRA
},
894 { GL_INDEX_ARRAY
, ARRAY_BOOL(Index
.Enabled
), NO_EXTRA
},
895 { GL_INDEX_ARRAY_TYPE
, ARRAY_ENUM(Index
.Type
), NO_EXTRA
},
896 { GL_INDEX_ARRAY_STRIDE
, ARRAY_INT(Index
.Stride
), NO_EXTRA
},
897 { GL_INDEX_ARRAY_COUNT_EXT
, CONST(0), NO_EXTRA
},
898 { GL_TEXTURE_COORD_ARRAY_COUNT_EXT
, CONST(0), NO_EXTRA
},
899 { GL_EDGE_FLAG_ARRAY
, ARRAY_BOOL(EdgeFlag
.Enabled
), NO_EXTRA
},
900 { GL_EDGE_FLAG_ARRAY_STRIDE
, ARRAY_INT(EdgeFlag
.Stride
), NO_EXTRA
},
901 { GL_EDGE_FLAG_ARRAY_COUNT_EXT
, CONST(0), NO_EXTRA
},
903 /* GL_ARB_texture_compression */
904 { GL_TEXTURE_COMPRESSION_HINT_ARB
, CONTEXT_INT(Hint
.TextureCompression
), NO_EXTRA
},
906 /* GL_EXT_compiled_vertex_array */
907 { GL_ARRAY_ELEMENT_LOCK_FIRST_EXT
, CONTEXT_INT(Array
.LockFirst
),
908 extra_EXT_compiled_vertex_array
},
909 { GL_ARRAY_ELEMENT_LOCK_COUNT_EXT
, CONTEXT_INT(Array
.LockCount
),
910 extra_EXT_compiled_vertex_array
},
912 /* GL_ARB_transpose_matrix */
913 { GL_TRANSPOSE_MODELVIEW_MATRIX_ARB
,
914 CONTEXT_MATRIX_T(ModelviewMatrixStack
), NO_EXTRA
},
915 { GL_TRANSPOSE_PROJECTION_MATRIX_ARB
,
916 CONTEXT_MATRIX_T(ProjectionMatrixStack
.Top
), NO_EXTRA
},
917 { GL_TRANSPOSE_TEXTURE_MATRIX_ARB
, CONTEXT_MATRIX_T(TextureMatrixStack
), NO_EXTRA
},
919 /* GL_EXT_secondary_color */
920 { GL_COLOR_SUM_EXT
, CONTEXT_BOOL(Fog
.ColorSumEnabled
),
921 extra_EXT_secondary_color_ARB_vertex_program
},
922 { GL_CURRENT_SECONDARY_COLOR_EXT
,
923 CONTEXT_FIELD(Current
.Attrib
[VERT_ATTRIB_COLOR1
][0], TYPE_FLOATN_4
),
924 extra_EXT_secondary_color_flush_current
},
925 { GL_SECONDARY_COLOR_ARRAY_EXT
, ARRAY_BOOL(SecondaryColor
.Enabled
),
926 extra_EXT_secondary_color
},
927 { GL_SECONDARY_COLOR_ARRAY_TYPE_EXT
, ARRAY_ENUM(SecondaryColor
.Type
),
928 extra_EXT_secondary_color
},
929 { GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT
, ARRAY_INT(SecondaryColor
.Stride
),
930 extra_EXT_secondary_color
},
931 { GL_SECONDARY_COLOR_ARRAY_SIZE_EXT
, ARRAY_INT(SecondaryColor
.Size
),
932 extra_EXT_secondary_color
},
934 /* GL_EXT_fog_coord */
935 { GL_CURRENT_FOG_COORDINATE_EXT
,
936 CONTEXT_FLOAT(Current
.Attrib
[VERT_ATTRIB_FOG
][0]),
937 extra_EXT_fog_coord_flush_current
},
938 { GL_FOG_COORDINATE_ARRAY_EXT
, ARRAY_BOOL(FogCoord
.Enabled
),
939 extra_EXT_fog_coord
},
940 { GL_FOG_COORDINATE_ARRAY_TYPE_EXT
, ARRAY_ENUM(FogCoord
.Type
),
941 extra_EXT_fog_coord
},
942 { GL_FOG_COORDINATE_ARRAY_STRIDE_EXT
, ARRAY_INT(FogCoord
.Stride
),
943 extra_EXT_fog_coord
},
944 { GL_FOG_COORDINATE_SOURCE_EXT
, CONTEXT_ENUM(Fog
.FogCoordinateSource
),
945 extra_EXT_fog_coord
},
947 /* GL_IBM_rasterpos_clip */
948 { GL_RASTER_POSITION_UNCLIPPED_IBM
,
949 CONTEXT_BOOL(Transform
.RasterPositionUnclipped
),
950 extra_IBM_rasterpos_clip
},
952 /* GL_NV_point_sprite */
953 { GL_POINT_SPRITE_R_MODE_NV
,
954 CONTEXT_ENUM(Point
.SpriteRMode
), extra_NV_point_sprite
},
955 { GL_POINT_SPRITE_COORD_ORIGIN
, CONTEXT_ENUM(Point
.SpriteOrigin
),
956 extra_NV_point_sprite_ARB_point_sprite
},
958 /* GL_NV_vertex_program */
959 { GL_VERTEX_PROGRAM_BINDING_NV
, LOC_CUSTOM
, TYPE_INT
, 0,
960 extra_NV_vertex_program
},
961 { GL_VERTEX_ATTRIB_ARRAY0_NV
, ARRAY_BOOL(VertexAttrib
[0].Enabled
),
962 extra_NV_vertex_program
},
963 { GL_VERTEX_ATTRIB_ARRAY1_NV
, ARRAY_BOOL(VertexAttrib
[1].Enabled
),
964 extra_NV_vertex_program
},
965 { GL_VERTEX_ATTRIB_ARRAY2_NV
, ARRAY_BOOL(VertexAttrib
[2].Enabled
),
966 extra_NV_vertex_program
},
967 { GL_VERTEX_ATTRIB_ARRAY3_NV
, ARRAY_BOOL(VertexAttrib
[3].Enabled
),
968 extra_NV_vertex_program
},
969 { GL_VERTEX_ATTRIB_ARRAY4_NV
, ARRAY_BOOL(VertexAttrib
[4].Enabled
),
970 extra_NV_vertex_program
},
971 { GL_VERTEX_ATTRIB_ARRAY5_NV
, ARRAY_BOOL(VertexAttrib
[5].Enabled
),
972 extra_NV_vertex_program
},
973 { GL_VERTEX_ATTRIB_ARRAY6_NV
, ARRAY_BOOL(VertexAttrib
[6].Enabled
),
974 extra_NV_vertex_program
},
975 { GL_VERTEX_ATTRIB_ARRAY7_NV
, ARRAY_BOOL(VertexAttrib
[7].Enabled
),
976 extra_NV_vertex_program
},
977 { GL_VERTEX_ATTRIB_ARRAY8_NV
, ARRAY_BOOL(VertexAttrib
[8].Enabled
),
978 extra_NV_vertex_program
},
979 { GL_VERTEX_ATTRIB_ARRAY9_NV
, ARRAY_BOOL(VertexAttrib
[9].Enabled
),
980 extra_NV_vertex_program
},
981 { GL_VERTEX_ATTRIB_ARRAY10_NV
, ARRAY_BOOL(VertexAttrib
[10].Enabled
),
982 extra_NV_vertex_program
},
983 { GL_VERTEX_ATTRIB_ARRAY11_NV
, ARRAY_BOOL(VertexAttrib
[11].Enabled
),
984 extra_NV_vertex_program
},
985 { GL_VERTEX_ATTRIB_ARRAY12_NV
, ARRAY_BOOL(VertexAttrib
[12].Enabled
),
986 extra_NV_vertex_program
},
987 { GL_VERTEX_ATTRIB_ARRAY13_NV
, ARRAY_BOOL(VertexAttrib
[13].Enabled
),
988 extra_NV_vertex_program
},
989 { GL_VERTEX_ATTRIB_ARRAY14_NV
, ARRAY_BOOL(VertexAttrib
[14].Enabled
),
990 extra_NV_vertex_program
},
991 { GL_VERTEX_ATTRIB_ARRAY15_NV
, ARRAY_BOOL(VertexAttrib
[15].Enabled
),
992 extra_NV_vertex_program
},
993 { GL_MAP1_VERTEX_ATTRIB0_4_NV
, CONTEXT_BOOL(Eval
.Map1Attrib
[0]),
994 extra_NV_vertex_program
},
995 { GL_MAP1_VERTEX_ATTRIB1_4_NV
, CONTEXT_BOOL(Eval
.Map1Attrib
[1]),
996 extra_NV_vertex_program
},
997 { GL_MAP1_VERTEX_ATTRIB2_4_NV
, CONTEXT_BOOL(Eval
.Map1Attrib
[2]),
998 extra_NV_vertex_program
},
999 { GL_MAP1_VERTEX_ATTRIB3_4_NV
, CONTEXT_BOOL(Eval
.Map1Attrib
[3]),
1000 extra_NV_vertex_program
},
1001 { GL_MAP1_VERTEX_ATTRIB4_4_NV
, CONTEXT_BOOL(Eval
.Map1Attrib
[4]),
1002 extra_NV_vertex_program
},
1003 { GL_MAP1_VERTEX_ATTRIB5_4_NV
, CONTEXT_BOOL(Eval
.Map1Attrib
[5]),
1004 extra_NV_vertex_program
},
1005 { GL_MAP1_VERTEX_ATTRIB6_4_NV
, CONTEXT_BOOL(Eval
.Map1Attrib
[6]),
1006 extra_NV_vertex_program
},
1007 { GL_MAP1_VERTEX_ATTRIB7_4_NV
, CONTEXT_BOOL(Eval
.Map1Attrib
[7]),
1008 extra_NV_vertex_program
},
1009 { GL_MAP1_VERTEX_ATTRIB8_4_NV
, CONTEXT_BOOL(Eval
.Map1Attrib
[8]),
1010 extra_NV_vertex_program
},
1011 { GL_MAP1_VERTEX_ATTRIB9_4_NV
, CONTEXT_BOOL(Eval
.Map1Attrib
[9]),
1012 extra_NV_vertex_program
},
1013 { GL_MAP1_VERTEX_ATTRIB10_4_NV
, CONTEXT_BOOL(Eval
.Map1Attrib
[10]),
1014 extra_NV_vertex_program
},
1015 { GL_MAP1_VERTEX_ATTRIB11_4_NV
, CONTEXT_BOOL(Eval
.Map1Attrib
[11]),
1016 extra_NV_vertex_program
},
1017 { GL_MAP1_VERTEX_ATTRIB12_4_NV
, CONTEXT_BOOL(Eval
.Map1Attrib
[12]),
1018 extra_NV_vertex_program
},
1019 { GL_MAP1_VERTEX_ATTRIB13_4_NV
, CONTEXT_BOOL(Eval
.Map1Attrib
[13]),
1020 extra_NV_vertex_program
},
1021 { GL_MAP1_VERTEX_ATTRIB14_4_NV
, CONTEXT_BOOL(Eval
.Map1Attrib
[14]),
1022 extra_NV_vertex_program
},
1023 { GL_MAP1_VERTEX_ATTRIB15_4_NV
, CONTEXT_BOOL(Eval
.Map1Attrib
[15]),
1024 extra_NV_vertex_program
},
1026 /* GL_NV_fragment_program */
1027 { GL_FRAGMENT_PROGRAM_NV
, CONTEXT_BOOL(FragmentProgram
.Enabled
),
1028 extra_NV_fragment_program
},
1029 { GL_FRAGMENT_PROGRAM_BINDING_NV
, LOC_CUSTOM
, TYPE_INT
, 0,
1030 extra_NV_fragment_program
},
1031 { GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV
,
1032 CONST(MAX_NV_FRAGMENT_PROGRAM_PARAMS
),
1033 extra_NV_fragment_program
},
1035 /* GL_NV_texture_rectangle */
1036 { GL_TEXTURE_RECTANGLE_NV
,
1037 LOC_CUSTOM
, TYPE_BOOLEAN
, 0, extra_NV_texture_rectangle
},
1038 { GL_TEXTURE_BINDING_RECTANGLE_NV
,
1039 LOC_CUSTOM
, TYPE_INT
, TEXTURE_RECT_INDEX
, extra_NV_texture_rectangle
},
1040 { GL_MAX_RECTANGLE_TEXTURE_SIZE_NV
,
1041 CONTEXT_INT(Const
.MaxTextureRectSize
), extra_NV_texture_rectangle
},
1043 /* GL_EXT_stencil_two_side */
1044 { GL_STENCIL_TEST_TWO_SIDE_EXT
, CONTEXT_BOOL(Stencil
.TestTwoSide
),
1045 extra_EXT_stencil_two_side
},
1046 { GL_ACTIVE_STENCIL_FACE_EXT
, LOC_CUSTOM
, TYPE_ENUM
, NO_OFFSET
, NO_EXTRA
},
1048 /* GL_NV_light_max_exponent */
1049 { GL_MAX_SHININESS_NV
, CONTEXT_FLOAT(Const
.MaxShininess
),
1050 extra_NV_light_max_exponent
},
1051 { GL_MAX_SPOT_EXPONENT_NV
, CONTEXT_FLOAT(Const
.MaxSpotExponent
),
1052 extra_NV_light_max_exponent
},
1054 /* GL_NV_primitive_restart */
1055 { GL_PRIMITIVE_RESTART_NV
, CONTEXT_BOOL(Array
.PrimitiveRestart
),
1056 extra_NV_primitive_restart
},
1057 { GL_PRIMITIVE_RESTART_INDEX_NV
, CONTEXT_INT(Array
.RestartIndex
),
1058 extra_NV_primitive_restart
},
1060 /* GL_ARB_vertex_buffer_object */
1061 { GL_INDEX_ARRAY_BUFFER_BINDING_ARB
, LOC_CUSTOM
, TYPE_INT
,
1062 offsetof(struct gl_array_object
, Index
.BufferObj
), NO_EXTRA
},
1063 { GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB
, LOC_CUSTOM
, TYPE_INT
,
1064 offsetof(struct gl_array_object
, EdgeFlag
.BufferObj
), NO_EXTRA
},
1065 { GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB
, LOC_CUSTOM
, TYPE_INT
,
1066 offsetof(struct gl_array_object
, SecondaryColor
.BufferObj
), NO_EXTRA
},
1067 { GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB
, LOC_CUSTOM
, TYPE_INT
,
1068 offsetof(struct gl_array_object
, FogCoord
.BufferObj
), NO_EXTRA
},
1070 /* GL_EXT_pixel_buffer_object */
1071 { GL_PIXEL_PACK_BUFFER_BINDING_EXT
, LOC_CUSTOM
, TYPE_INT
, 0,
1072 extra_EXT_pixel_buffer_object
},
1073 { GL_PIXEL_UNPACK_BUFFER_BINDING_EXT
, LOC_CUSTOM
, TYPE_INT
, 0,
1074 extra_EXT_pixel_buffer_object
},
1076 /* GL_ARB_vertex_program */
1077 { GL_VERTEX_PROGRAM_ARB
, /* == GL_VERTEX_PROGRAM_NV */
1078 CONTEXT_BOOL(VertexProgram
.Enabled
),
1079 extra_ARB_vertex_program_NV_vertex_program
},
1080 { GL_VERTEX_PROGRAM_POINT_SIZE_ARB
, /* == GL_VERTEX_PROGRAM_POINT_SIZE_NV*/
1081 CONTEXT_BOOL(VertexProgram
.PointSizeEnabled
),
1082 extra_ARB_vertex_program_NV_vertex_program
},
1083 { GL_VERTEX_PROGRAM_TWO_SIDE_ARB
, /* == GL_VERTEX_PROGRAM_TWO_SIDE_NV */
1084 CONTEXT_BOOL(VertexProgram
.TwoSideEnabled
),
1085 extra_ARB_vertex_program_NV_vertex_program
},
1086 { GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB
, /* == GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV */
1087 CONTEXT_INT(Const
.MaxProgramMatrixStackDepth
),
1088 extra_ARB_vertex_program_ARB_fragment_program_NV_vertex_program
},
1089 { GL_MAX_PROGRAM_MATRICES_ARB
, /* == GL_MAX_TRACK_MATRICES_NV */
1090 CONTEXT_INT(Const
.MaxProgramMatrices
),
1091 extra_ARB_vertex_program_ARB_fragment_program_NV_vertex_program
},
1092 { GL_CURRENT_MATRIX_STACK_DEPTH_ARB
, /* == GL_CURRENT_MATRIX_STACK_DEPTH_NV */
1093 LOC_CUSTOM
, TYPE_INT
, 0,
1094 extra_ARB_vertex_program_ARB_fragment_program_NV_vertex_program
},
1096 { GL_CURRENT_MATRIX_ARB
, /* == GL_CURRENT_MATRIX_NV */
1097 LOC_CUSTOM
, TYPE_MATRIX
, 0,
1098 extra_ARB_vertex_program_ARB_fragment_program_NV_vertex_program
},
1099 { GL_TRANSPOSE_CURRENT_MATRIX_ARB
, /* == GL_CURRENT_MATRIX_NV */
1100 LOC_CUSTOM
, TYPE_MATRIX
, 0,
1101 extra_ARB_vertex_program_ARB_fragment_program
},
1103 { GL_PROGRAM_ERROR_POSITION_ARB
, /* == GL_PROGRAM_ERROR_POSITION_NV */
1104 CONTEXT_INT(Program
.ErrorPos
),
1105 extra_NV_vertex_program_ARB_vertex_program_ARB_fragment_program_NV_vertex_program
},
1107 /* GL_ARB_fragment_program */
1108 { GL_FRAGMENT_PROGRAM_ARB
, CONTEXT_BOOL(FragmentProgram
.Enabled
),
1109 extra_ARB_fragment_program
},
1111 /* GL_EXT_depth_bounds_test */
1112 { GL_DEPTH_BOUNDS_TEST_EXT
, CONTEXT_BOOL(Depth
.BoundsTest
),
1113 extra_EXT_depth_bounds_test
},
1114 { GL_DEPTH_BOUNDS_EXT
, CONTEXT_FLOAT2(Depth
.BoundsMin
),
1115 extra_EXT_depth_bounds_test
},
1117 /* GL_ARB_depth_clamp*/
1118 { GL_DEPTH_CLAMP
, CONTEXT_BOOL(Transform
.DepthClamp
),
1119 extra_ARB_depth_clamp
},
1121 /* GL_ARB_draw_buffers */
1122 { GL_DRAW_BUFFER0_ARB
, BUFFER_ENUM(ColorDrawBuffer
[0]), NO_EXTRA
},
1123 { GL_DRAW_BUFFER1_ARB
, BUFFER_ENUM(ColorDrawBuffer
[1]),
1124 extra_valid_draw_buffer
},
1125 { GL_DRAW_BUFFER2_ARB
, BUFFER_ENUM(ColorDrawBuffer
[2]),
1126 extra_valid_draw_buffer
},
1127 { GL_DRAW_BUFFER3_ARB
, BUFFER_ENUM(ColorDrawBuffer
[3]),
1128 extra_valid_draw_buffer
},
1129 { GL_DRAW_BUFFER4_ARB
, BUFFER_ENUM(ColorDrawBuffer
[4]),
1130 extra_valid_draw_buffer
},
1131 { GL_DRAW_BUFFER5_ARB
, BUFFER_ENUM(ColorDrawBuffer
[5]),
1132 extra_valid_draw_buffer
},
1133 { GL_DRAW_BUFFER6_ARB
, BUFFER_ENUM(ColorDrawBuffer
[6]),
1134 extra_valid_draw_buffer
},
1135 { GL_DRAW_BUFFER7_ARB
, BUFFER_ENUM(ColorDrawBuffer
[7]),
1136 extra_valid_draw_buffer
},
1138 /* GL_ATI_fragment_shader */
1139 { GL_NUM_FRAGMENT_REGISTERS_ATI
, CONST(6), extra_ATI_fragment_shader
},
1140 { GL_NUM_FRAGMENT_CONSTANTS_ATI
, CONST(8), extra_ATI_fragment_shader
},
1141 { GL_NUM_PASSES_ATI
, CONST(2), extra_ATI_fragment_shader
},
1142 { GL_NUM_INSTRUCTIONS_PER_PASS_ATI
, CONST(8), extra_ATI_fragment_shader
},
1143 { GL_NUM_INSTRUCTIONS_TOTAL_ATI
, CONST(16), extra_ATI_fragment_shader
},
1144 { GL_COLOR_ALPHA_PAIRING_ATI
, CONST(GL_TRUE
), extra_ATI_fragment_shader
},
1145 { GL_NUM_LOOPBACK_COMPONENTS_ATI
, CONST(3), extra_ATI_fragment_shader
},
1146 { GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI
,
1147 CONST(3), extra_ATI_fragment_shader
},
1149 /* GL_EXT_framebuffer_object */
1150 { GL_MAX_COLOR_ATTACHMENTS_EXT
, CONTEXT_INT(Const
.MaxColorAttachments
),
1151 extra_EXT_framebuffer_object
},
1153 /* GL_EXT_framebuffer_blit
1154 * NOTE: GL_DRAW_FRAMEBUFFER_BINDING_EXT == GL_FRAMEBUFFER_BINDING_EXT */
1155 { GL_READ_FRAMEBUFFER_BINDING_EXT
, LOC_CUSTOM
, TYPE_INT
, 0,
1156 extra_EXT_framebuffer_blit
},
1158 /* GL_EXT_provoking_vertex */
1159 { GL_PROVOKING_VERTEX_EXT
,
1160 CONTEXT_BOOL(Light
.ProvokingVertex
), extra_EXT_provoking_vertex
},
1161 { GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT
,
1162 CONTEXT_BOOL(Const
.QuadsFollowProvokingVertexConvention
),
1163 extra_EXT_provoking_vertex
},
1165 /* GL_ARB_framebuffer_object */
1166 { GL_MAX_SAMPLES
, CONTEXT_INT(Const
.MaxSamples
),
1167 extra_ARB_framebuffer_object_EXT_framebuffer_multisample
},
1169 /* GL_APPLE_vertex_array_object */
1170 { GL_VERTEX_ARRAY_BINDING_APPLE
, ARRAY_INT(Name
),
1171 extra_APPLE_vertex_array_object
},
1173 /* GL_ARB_seamless_cube_map */
1174 { GL_TEXTURE_CUBE_MAP_SEAMLESS
,
1175 CONTEXT_BOOL(Texture
.CubeMapSeamless
), extra_ARB_seamless_cube_map
},
1178 { GL_MAX_SERVER_WAIT_TIMEOUT
,
1179 CONTEXT_INT64(Const
.MaxServerWaitTimeout
), extra_ARB_sync
},
1181 /* GL_EXT_texture_integer */
1182 { GL_RGBA_INTEGER_MODE_EXT
, BUFFER_BOOL(_IntegerColor
),
1183 extra_EXT_texture_integer
},
1185 /* GL_EXT_transform_feedback */
1186 { GL_TRANSFORM_FEEDBACK_BUFFER_BINDING
, LOC_CUSTOM
, TYPE_INT
, 0,
1187 extra_EXT_transform_feedback
},
1188 { GL_RASTERIZER_DISCARD
, CONTEXT_BOOL(TransformFeedback
.RasterDiscard
),
1189 extra_EXT_transform_feedback
},
1190 { GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS
,
1191 CONTEXT_INT(Const
.MaxTransformFeedbackInterleavedComponents
),
1192 extra_EXT_transform_feedback
},
1193 { GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS
,
1194 CONTEXT_INT(Const
.MaxTransformFeedbackSeparateAttribs
),
1195 extra_EXT_transform_feedback
},
1196 { GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS
,
1197 CONTEXT_INT(Const
.MaxTransformFeedbackSeparateComponents
),
1198 extra_EXT_transform_feedback
},
1200 /* GL_ARB_transform_feedback2 */
1201 { GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED
, LOC_CUSTOM
, TYPE_BOOLEAN
, 0,
1202 extra_ARB_transform_feedback2
},
1203 { GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE
, LOC_CUSTOM
, TYPE_BOOLEAN
, 0,
1204 extra_ARB_transform_feedback2
},
1205 { GL_TRANSFORM_FEEDBACK_BINDING
, LOC_CUSTOM
, TYPE_INT
, 0,
1206 extra_ARB_transform_feedback2
},
1208 /* GL_ARB_geometry_shader4 */
1209 { GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB
,
1210 CONTEXT_INT(Const
.MaxGeometryTextureImageUnits
),
1211 extra_ARB_geometry_shader4
},
1212 { GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB
,
1213 CONTEXT_INT(Const
.MaxGeometryOutputVertices
),
1214 extra_ARB_geometry_shader4
},
1215 { GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB
,
1216 CONTEXT_INT(Const
.MaxGeometryTotalOutputComponents
),
1217 extra_ARB_geometry_shader4
},
1218 { GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB
,
1219 CONTEXT_INT(Const
.GeometryProgram
.MaxUniformComponents
),
1220 extra_ARB_geometry_shader4
},
1221 { GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB
,
1222 CONTEXT_INT(Const
.MaxGeometryVaryingComponents
),
1223 extra_ARB_geometry_shader4
},
1224 { GL_MAX_VERTEX_VARYING_COMPONENTS_ARB
,
1225 CONTEXT_INT(Const
.MaxVertexVaryingComponents
),
1226 extra_ARB_geometry_shader4
},
1228 /* GL_ARB_color_buffer_float */
1229 { GL_RGBA_FLOAT_MODE_ARB
, BUFFER_FIELD(Visual
.floatMode
, TYPE_BOOLEAN
), 0 },
1231 /* GL_EXT_gpu_shader4 / GL 3.0 */
1232 { GL_MIN_PROGRAM_TEXEL_OFFSET
,
1233 CONTEXT_INT(Const
.MinProgramTexelOffset
),
1234 extra_EXT_gpu_shader4
},
1235 { GL_MAX_PROGRAM_TEXEL_OFFSET
,
1236 CONTEXT_INT(Const
.MaxProgramTexelOffset
),
1237 extra_EXT_gpu_shader4
},
1240 { GL_NUM_EXTENSIONS
, LOC_CUSTOM
, TYPE_INT
, 0, extra_version_30
},
1241 { GL_MAJOR_VERSION
, CONTEXT_INT(VersionMajor
), extra_version_30
},
1242 { GL_MINOR_VERSION
, CONTEXT_INT(VersionMinor
), extra_version_30
},
1243 { GL_CONTEXT_FLAGS
, CONTEXT_INT(Const
.ContextFlags
), extra_version_30
},
1245 /* GL3.0 / GL_EXT_framebuffer_sRGB */
1246 { GL_FRAMEBUFFER_SRGB_EXT
, CONTEXT_BOOL(Color
.sRGBEnabled
), extra_EXT_framebuffer_sRGB
},
1247 { GL_FRAMEBUFFER_SRGB_CAPABLE_EXT
, BUFFER_INT(Visual
.sRGBCapable
), extra_EXT_framebuffer_sRGB
},
1250 /* NOTE: different enum values for GL_PRIMITIVE_RESTART_NV
1251 * vs. GL_PRIMITIVE_RESTART!
1253 { GL_PRIMITIVE_RESTART
, CONTEXT_BOOL(Array
.PrimitiveRestart
),
1255 { GL_PRIMITIVE_RESTART_INDEX
, CONTEXT_INT(Array
.RestartIndex
),
1260 { GL_CONTEXT_PROFILE_MASK
, CONTEXT_INT(Const
.ProfileMask
),
1262 #endif /* FEATURE_GL */
1265 /* All we need now is a way to look up the value struct from the enum.
1266 * The code generated by gcc for the old generated big switch
1267 * statement is a big, balanced, open coded if/else tree, essentially
1268 * an unrolled binary search. It would be natural to sort the new
1269 * enum table and use bsearch(), but we will use a read-only hash
1270 * table instead. bsearch() has a nice guaranteed worst case
1271 * performance, but we're also guaranteed to hit that worst case
1272 * (log2(n) iterations) for about half the enums. Instead, using an
1273 * open addressing hash table, we can find the enum on the first try
1274 * for 80% of the enums, 1 collision for 10% and never more than 5
1275 * collisions for any enum (typical numbers). And the code is very
1276 * simple, even though it feels a little magic. */
1278 static unsigned short table
[1024];
1279 static const int prime_factor
= 89, prime_step
= 281;
1283 print_table_stats(void)
1285 int i
, j
, collisions
[11], count
, hash
, mask
;
1286 const struct value_desc
*d
;
1289 mask
= Elements(table
) - 1;
1290 memset(collisions
, 0, sizeof collisions
);
1292 for (i
= 0; i
< Elements(table
); i
++) {
1296 d
= &values
[table
[i
]];
1297 hash
= (d
->pname
* prime_factor
);
1300 if (values
[table
[hash
& mask
]].pname
== d
->pname
)
1312 printf("number of enums: %d (total %d)\n", count
, Elements(values
));
1313 for (i
= 0; i
< Elements(collisions
) - 1; i
++)
1314 if (collisions
[i
] > 0)
1315 printf(" %d enums with %d %scollisions\n",
1316 collisions
[i
], i
, i
== 10 ? "or more " : "");
1321 * Initialize the enum hash for a given API
1323 * This is called from one_time_init() to insert the enum values that
1324 * are valid for the API in question into the enum hash table.
1326 * \param the current context, for determining the API in question
1328 void _mesa_init_get_hash(struct gl_context
*ctx
)
1330 int i
, hash
, index
, mask
;
1331 int api_mask
= 0, api_bit
;
1333 mask
= Elements(table
) - 1;
1334 api_bit
= 1 << ctx
->API
;
1336 for (i
= 0; i
< Elements(values
); i
++) {
1337 if (values
[i
].type
== TYPE_API_MASK
) {
1338 api_mask
= values
[i
].offset
;
1341 if (!(api_mask
& api_bit
))
1344 hash
= (values
[i
].pname
* prime_factor
) & mask
;
1346 index
= hash
& mask
;
1347 if (!table
[index
]) {
1356 print_table_stats();
1361 * Handle irregular enums
1363 * Some values don't conform to the "well-known type at context
1364 * pointer + offset" pattern, so we have this function to catch all
1365 * the corner cases. Typically, it's a computed value or a one-off
1366 * pointer to a custom struct or something.
1368 * In this case we can't return a pointer to the value, so we'll have
1369 * to use the temporary variable 'v' declared back in the calling
1370 * glGet*v() function to store the result.
1372 * \param ctx the current context
1373 * \param d the struct value_desc that describes the enum
1374 * \param v pointer to the tmp declared in the calling glGet*v() function
1377 find_custom_value(struct gl_context
*ctx
, const struct value_desc
*d
, union value
*v
)
1379 struct gl_buffer_object
**buffer_obj
;
1380 struct gl_client_array
*array
;
1387 case GL_TEXTURE_1D_ARRAY_EXT
:
1388 case GL_TEXTURE_2D_ARRAY_EXT
:
1389 case GL_TEXTURE_CUBE_MAP_ARB
:
1390 case GL_TEXTURE_RECTANGLE_NV
:
1391 v
->value_bool
= _mesa_IsEnabled(d
->pname
);
1394 case GL_LINE_STIPPLE_PATTERN
:
1395 /* This is the only GLushort, special case it here by promoting
1396 * to an int rather than introducing a new type. */
1397 v
->value_int
= ctx
->Line
.StipplePattern
;
1400 case GL_CURRENT_RASTER_TEXTURE_COORDS
:
1401 unit
= ctx
->Texture
.CurrentUnit
;
1402 v
->value_float_4
[0] = ctx
->Current
.RasterTexCoords
[unit
][0];
1403 v
->value_float_4
[1] = ctx
->Current
.RasterTexCoords
[unit
][1];
1404 v
->value_float_4
[2] = ctx
->Current
.RasterTexCoords
[unit
][2];
1405 v
->value_float_4
[3] = ctx
->Current
.RasterTexCoords
[unit
][3];
1408 case GL_CURRENT_TEXTURE_COORDS
:
1409 unit
= ctx
->Texture
.CurrentUnit
;
1410 v
->value_float_4
[0] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
][0];
1411 v
->value_float_4
[1] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
][1];
1412 v
->value_float_4
[2] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
][2];
1413 v
->value_float_4
[3] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
][3];
1416 case GL_COLOR_WRITEMASK
:
1417 v
->value_int_4
[0] = ctx
->Color
.ColorMask
[0][RCOMP
] ? 1 : 0;
1418 v
->value_int_4
[1] = ctx
->Color
.ColorMask
[0][GCOMP
] ? 1 : 0;
1419 v
->value_int_4
[2] = ctx
->Color
.ColorMask
[0][BCOMP
] ? 1 : 0;
1420 v
->value_int_4
[3] = ctx
->Color
.ColorMask
[0][ACOMP
] ? 1 : 0;
1424 v
->value_bool
= ctx
->Current
.Attrib
[VERT_ATTRIB_EDGEFLAG
][0] == 1.0;
1427 case GL_READ_BUFFER
:
1428 v
->value_enum
= ctx
->ReadBuffer
->ColorReadBuffer
;
1431 case GL_MAP2_GRID_DOMAIN
:
1432 v
->value_float_4
[0] = ctx
->Eval
.MapGrid2u1
;
1433 v
->value_float_4
[1] = ctx
->Eval
.MapGrid2u2
;
1434 v
->value_float_4
[2] = ctx
->Eval
.MapGrid2v1
;
1435 v
->value_float_4
[3] = ctx
->Eval
.MapGrid2v2
;
1438 case GL_TEXTURE_STACK_DEPTH
:
1439 unit
= ctx
->Texture
.CurrentUnit
;
1440 v
->value_int
= ctx
->TextureMatrixStack
[unit
].Depth
+ 1;
1442 case GL_TEXTURE_MATRIX
:
1443 unit
= ctx
->Texture
.CurrentUnit
;
1444 v
->value_matrix
= ctx
->TextureMatrixStack
[unit
].Top
;
1447 case GL_TEXTURE_COORD_ARRAY
:
1448 case GL_TEXTURE_COORD_ARRAY_SIZE
:
1449 case GL_TEXTURE_COORD_ARRAY_TYPE
:
1450 case GL_TEXTURE_COORD_ARRAY_STRIDE
:
1451 array
= &ctx
->Array
.ArrayObj
->TexCoord
[ctx
->Array
.ActiveTexture
];
1452 v
->value_int
= *(GLuint
*) ((char *) array
+ d
->offset
);
1455 case GL_ACTIVE_TEXTURE_ARB
:
1456 v
->value_int
= GL_TEXTURE0_ARB
+ ctx
->Texture
.CurrentUnit
;
1458 case GL_CLIENT_ACTIVE_TEXTURE_ARB
:
1459 v
->value_int
= GL_TEXTURE0_ARB
+ ctx
->Array
.ActiveTexture
;
1462 case GL_MODELVIEW_STACK_DEPTH
:
1463 case GL_PROJECTION_STACK_DEPTH
:
1464 v
->value_int
= *(GLint
*) ((char *) ctx
+ d
->offset
) + 1;
1467 case GL_MAX_TEXTURE_SIZE
:
1468 case GL_MAX_3D_TEXTURE_SIZE
:
1469 case GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB
:
1470 p
= (GLuint
*) ((char *) ctx
+ d
->offset
);
1471 v
->value_int
= 1 << (*p
- 1);
1474 case GL_SCISSOR_BOX
:
1475 v
->value_int_4
[0] = ctx
->Scissor
.X
;
1476 v
->value_int_4
[1] = ctx
->Scissor
.Y
;
1477 v
->value_int_4
[2] = ctx
->Scissor
.Width
;
1478 v
->value_int_4
[3] = ctx
->Scissor
.Height
;
1483 ctx
->ListState
.CurrentList
? ctx
->ListState
.CurrentList
->Name
: 0;
1486 if (!ctx
->CompileFlag
)
1488 else if (ctx
->ExecuteFlag
)
1489 v
->value_enum
= GL_COMPILE_AND_EXECUTE
;
1491 v
->value_enum
= GL_COMPILE
;
1495 v
->value_int_4
[0] = ctx
->Viewport
.X
;
1496 v
->value_int_4
[1] = ctx
->Viewport
.Y
;
1497 v
->value_int_4
[2] = ctx
->Viewport
.Width
;
1498 v
->value_int_4
[3] = ctx
->Viewport
.Height
;
1501 case GL_ACTIVE_STENCIL_FACE_EXT
:
1502 v
->value_enum
= ctx
->Stencil
.ActiveFace
? GL_BACK
: GL_FRONT
;
1505 case GL_STENCIL_FAIL
:
1506 v
->value_enum
= ctx
->Stencil
.FailFunc
[ctx
->Stencil
.ActiveFace
];
1508 case GL_STENCIL_FUNC
:
1509 v
->value_enum
= ctx
->Stencil
.Function
[ctx
->Stencil
.ActiveFace
];
1511 case GL_STENCIL_PASS_DEPTH_FAIL
:
1512 v
->value_enum
= ctx
->Stencil
.ZFailFunc
[ctx
->Stencil
.ActiveFace
];
1514 case GL_STENCIL_PASS_DEPTH_PASS
:
1515 v
->value_enum
= ctx
->Stencil
.ZPassFunc
[ctx
->Stencil
.ActiveFace
];
1517 case GL_STENCIL_REF
:
1518 v
->value_int
= ctx
->Stencil
.Ref
[ctx
->Stencil
.ActiveFace
];
1520 case GL_STENCIL_VALUE_MASK
:
1521 v
->value_int
= ctx
->Stencil
.ValueMask
[ctx
->Stencil
.ActiveFace
];
1523 case GL_STENCIL_WRITEMASK
:
1524 v
->value_int
= ctx
->Stencil
.WriteMask
[ctx
->Stencil
.ActiveFace
];
1527 case GL_NUM_EXTENSIONS
:
1528 v
->value_int
= _mesa_get_extension_count(ctx
);
1531 case GL_IMPLEMENTATION_COLOR_READ_TYPE_OES
:
1532 v
->value_int
= _mesa_get_color_read_type(ctx
);
1534 case GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES
:
1535 v
->value_int
= _mesa_get_color_read_format(ctx
);
1538 case GL_CURRENT_MATRIX_STACK_DEPTH_ARB
:
1539 v
->value_int
= ctx
->CurrentStack
->Depth
+ 1;
1541 case GL_CURRENT_MATRIX_ARB
:
1542 case GL_TRANSPOSE_CURRENT_MATRIX_ARB
:
1543 v
->value_matrix
= ctx
->CurrentStack
->Top
;
1546 case GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB
:
1547 v
->value_int
= _mesa_get_compressed_formats(ctx
, NULL
, GL_FALSE
);
1549 case GL_COMPRESSED_TEXTURE_FORMATS_ARB
:
1551 _mesa_get_compressed_formats(ctx
, v
->value_int_n
.ints
, GL_FALSE
);
1552 ASSERT(v
->value_int_n
.n
<= 100);
1555 case GL_MAX_VARYING_FLOATS_ARB
:
1556 v
->value_int
= ctx
->Const
.MaxVarying
* 4;
1559 /* Various object names */
1561 case GL_TEXTURE_BINDING_1D
:
1562 case GL_TEXTURE_BINDING_2D
:
1563 case GL_TEXTURE_BINDING_3D
:
1564 case GL_TEXTURE_BINDING_1D_ARRAY_EXT
:
1565 case GL_TEXTURE_BINDING_2D_ARRAY_EXT
:
1566 case GL_TEXTURE_BINDING_CUBE_MAP_ARB
:
1567 case GL_TEXTURE_BINDING_RECTANGLE_NV
:
1568 unit
= ctx
->Texture
.CurrentUnit
;
1570 ctx
->Texture
.Unit
[unit
].CurrentTex
[d
->offset
]->Name
;
1573 /* GL_ARB_vertex_buffer_object */
1574 case GL_VERTEX_ARRAY_BUFFER_BINDING_ARB
:
1575 case GL_NORMAL_ARRAY_BUFFER_BINDING_ARB
:
1576 case GL_COLOR_ARRAY_BUFFER_BINDING_ARB
:
1577 case GL_INDEX_ARRAY_BUFFER_BINDING_ARB
:
1578 case GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB
:
1579 case GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB
:
1580 case GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB
:
1581 buffer_obj
= (struct gl_buffer_object
**)
1582 ((char *) ctx
->Array
.ArrayObj
+ d
->offset
);
1583 v
->value_int
= (*buffer_obj
)->Name
;
1585 case GL_ARRAY_BUFFER_BINDING_ARB
:
1586 v
->value_int
= ctx
->Array
.ArrayBufferObj
->Name
;
1588 case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB
:
1590 ctx
->Array
.ArrayObj
->TexCoord
[ctx
->Array
.ActiveTexture
].BufferObj
->Name
;
1592 case GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB
:
1593 v
->value_int
= ctx
->Array
.ElementArrayBufferObj
->Name
;
1596 /* ARB_copy_buffer */
1597 case GL_COPY_READ_BUFFER
:
1598 v
->value_int
= ctx
->CopyReadBuffer
->Name
;
1600 case GL_COPY_WRITE_BUFFER
:
1601 v
->value_int
= ctx
->CopyWriteBuffer
->Name
;
1604 case GL_FRAGMENT_PROGRAM_BINDING_NV
:
1606 ctx
->FragmentProgram
.Current
? ctx
->FragmentProgram
.Current
->Base
.Id
: 0;
1608 case GL_VERTEX_PROGRAM_BINDING_NV
:
1610 ctx
->VertexProgram
.Current
? ctx
->VertexProgram
.Current
->Base
.Id
: 0;
1612 case GL_PIXEL_PACK_BUFFER_BINDING_EXT
:
1613 v
->value_int
= ctx
->Pack
.BufferObj
->Name
;
1615 case GL_PIXEL_UNPACK_BUFFER_BINDING_EXT
:
1616 v
->value_int
= ctx
->Unpack
.BufferObj
->Name
;
1618 case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING
:
1619 v
->value_int
= ctx
->TransformFeedback
.CurrentBuffer
->Name
;
1621 case GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED
:
1622 v
->value_int
= ctx
->TransformFeedback
.CurrentObject
->Paused
;
1624 case GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE
:
1625 v
->value_int
= ctx
->TransformFeedback
.CurrentObject
->Active
;
1627 case GL_TRANSFORM_FEEDBACK_BINDING
:
1628 v
->value_int
= ctx
->TransformFeedback
.CurrentObject
->Name
;
1630 case GL_CURRENT_PROGRAM
:
1632 ctx
->Shader
.ActiveProgram
? ctx
->Shader
.ActiveProgram
->Name
: 0;
1634 case GL_READ_FRAMEBUFFER_BINDING_EXT
:
1635 v
->value_int
= ctx
->ReadBuffer
->Name
;
1637 case GL_RENDERBUFFER_BINDING_EXT
:
1639 ctx
->CurrentRenderbuffer
? ctx
->CurrentRenderbuffer
->Name
: 0;
1641 case GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES
:
1642 v
->value_int
= ctx
->Array
.ArrayObj
->PointSize
.BufferObj
->Name
;
1646 if(ctx
->Color
._ClampFragmentColor
)
1647 COPY_4FV(v
->value_float_4
, ctx
->Fog
.Color
);
1649 COPY_4FV(v
->value_float_4
, ctx
->Fog
.ColorUnclamped
);
1651 case GL_COLOR_CLEAR_VALUE
:
1652 if(ctx
->Color
._ClampFragmentColor
)
1653 COPY_4FV(v
->value_float_4
, ctx
->Color
.ClearColor
);
1655 COPY_4FV(v
->value_float_4
, ctx
->Color
.ClearColorUnclamped
);
1657 case GL_BLEND_COLOR_EXT
:
1658 if(ctx
->Color
._ClampFragmentColor
)
1659 COPY_4FV(v
->value_float_4
, ctx
->Color
.BlendColor
);
1661 COPY_4FV(v
->value_float_4
, ctx
->Color
.BlendColorUnclamped
);
1663 case GL_ALPHA_TEST_REF
:
1664 if(ctx
->Color
._ClampFragmentColor
)
1665 v
->value_float
= ctx
->Color
.AlphaRef
;
1667 v
->value_float
= ctx
->Color
.AlphaRefUnclamped
;
1669 case GL_MAX_VERTEX_UNIFORM_VECTORS
:
1670 v
->value_int
= ctx
->Const
.VertexProgram
.MaxUniformComponents
/ 4;
1673 case GL_MAX_FRAGMENT_UNIFORM_VECTORS
:
1674 v
->value_int
= ctx
->Const
.FragmentProgram
.MaxUniformComponents
/ 4;
1680 * Check extra constraints on a struct value_desc descriptor
1682 * If a struct value_desc has a non-NULL extra pointer, it means that
1683 * there are a number of extra constraints to check or actions to
1684 * perform. The extras is just an integer array where each integer
1685 * encode different constraints or actions.
1687 * \param ctx current context
1688 * \param func name of calling glGet*v() function for error reporting
1689 * \param d the struct value_desc that has the extra constraints
1691 * \return GL_FALSE if one of the constraints was not satisfied,
1692 * otherwise GL_TRUE.
1695 check_extra(struct gl_context
*ctx
, const char *func
, const struct value_desc
*d
)
1697 const GLuint version
= ctx
->VersionMajor
* 10 + ctx
->VersionMinor
;
1703 for (e
= d
->extra
; *e
!= EXTRA_END
; e
++)
1705 case EXTRA_VERSION_30
:
1706 if (version
>= 30) {
1711 case EXTRA_VERSION_31
:
1712 if (version
>= 31) {
1717 case EXTRA_VERSION_32
:
1718 if (version
>= 32) {
1723 case EXTRA_NEW_FRAG_CLAMP
:
1724 if (ctx
->NewState
& (_NEW_BUFFERS
| _NEW_FRAG_CLAMP
))
1725 _mesa_update_state(ctx
);
1727 case EXTRA_VERSION_ES2
:
1728 if (ctx
->API
== API_OPENGLES2
) {
1733 case EXTRA_NEW_BUFFERS
:
1734 if (ctx
->NewState
& _NEW_BUFFERS
)
1735 _mesa_update_state(ctx
);
1737 case EXTRA_FLUSH_CURRENT
:
1738 FLUSH_CURRENT(ctx
, 0);
1740 case EXTRA_VALID_DRAW_BUFFER
:
1741 if (d
->pname
- GL_DRAW_BUFFER0_ARB
>= ctx
->Const
.MaxDrawBuffers
) {
1742 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(draw buffer %u)",
1743 func
, d
->pname
- GL_DRAW_BUFFER0_ARB
);
1747 case EXTRA_VALID_TEXTURE_UNIT
:
1748 if (ctx
->Texture
.CurrentUnit
>= ctx
->Const
.MaxTextureCoordUnits
) {
1749 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(texture %u)",
1750 func
, ctx
->Texture
.CurrentUnit
);
1756 default: /* *e is a offset into the extension struct */
1758 if (*(GLboolean
*) ((char *) &ctx
->Extensions
+ *e
))
1763 if (total
> 0 && enabled
== 0) {
1764 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(pname=%s)", func
,
1765 _mesa_lookup_enum_by_nr(d
->pname
));
1772 static const struct value_desc error_value
=
1773 { 0, 0, TYPE_INVALID
, NO_OFFSET
, NO_EXTRA
};
1776 * Find the struct value_desc corresponding to the enum 'pname'.
1778 * We hash the enum value to get an index into the 'table' array,
1779 * which holds the index in the 'values' array of struct value_desc.
1780 * Once we've found the entry, we do the extra checks, if any, then
1781 * look up the value and return a pointer to it.
1783 * If the value has to be computed (for example, it's the result of a
1784 * function call or we need to add 1 to it), we use the tmp 'v' to
1787 * \param func name of glGet*v() func for error reporting
1788 * \param pname the enum value we're looking up
1789 * \param p is were we return the pointer to the value
1790 * \param v a tmp union value variable in the calling glGet*v() function
1792 * \return the struct value_desc corresponding to the enum or a struct
1793 * value_desc of TYPE_INVALID if not found. This lets the calling
1794 * glGet*v() function jump right into a switch statement and
1795 * handle errors there instead of having to check for NULL.
1797 static const struct value_desc
*
1798 find_value(const char *func
, GLenum pname
, void **p
, union value
*v
)
1800 GET_CURRENT_CONTEXT(ctx
);
1801 struct gl_texture_unit
*unit
;
1803 const struct value_desc
*d
;
1805 mask
= Elements(table
) - 1;
1806 hash
= (pname
* prime_factor
);
1808 d
= &values
[table
[hash
& mask
]];
1810 /* If the enum isn't valid, the hash walk ends with index 0,
1811 * which is the API mask entry at the beginning of values[]. */
1812 if (unlikely(d
->type
== TYPE_API_MASK
)) {
1813 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(pname=%s)", func
,
1814 _mesa_lookup_enum_by_nr(pname
));
1815 return &error_value
;
1818 if (likely(d
->pname
== pname
))
1824 if (unlikely(d
->extra
&& !check_extra(ctx
, func
, d
)))
1825 return &error_value
;
1827 switch (d
->location
) {
1829 *p
= ((char *) ctx
->DrawBuffer
+ d
->offset
);
1832 *p
= ((char *) ctx
+ d
->offset
);
1835 *p
= ((char *) ctx
->Array
.ArrayObj
+ d
->offset
);
1838 unit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1839 *p
= ((char *) unit
+ d
->offset
);
1842 find_custom_value(ctx
, d
, v
);
1850 /* silence warning */
1851 return &error_value
;
1854 static const int transpose
[] = {
1862 _mesa_GetBooleanv(GLenum pname
, GLboolean
*params
)
1864 const struct value_desc
*d
;
1870 d
= find_value("glGetBooleanv", pname
, &p
, &v
);
1875 params
[0] = INT_TO_BOOLEAN(d
->offset
);
1880 params
[3] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[3]);
1883 params
[2] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[2]);
1886 params
[1] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[1]);
1889 params
[0] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[0]);
1893 params
[0] = FLOAT_TO_BOOLEAN(((GLdouble
*) p
)[0]);
1897 params
[3] = INT_TO_BOOLEAN(((GLint
*) p
)[3]);
1899 params
[2] = INT_TO_BOOLEAN(((GLint
*) p
)[2]);
1902 params
[1] = INT_TO_BOOLEAN(((GLint
*) p
)[1]);
1905 params
[0] = INT_TO_BOOLEAN(((GLint
*) p
)[0]);
1909 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
1910 params
[i
] = INT_TO_BOOLEAN(v
.value_int_n
.ints
[i
]);
1914 params
[0] = INT64_TO_BOOLEAN(((GLint64
*) p
)[0]);
1918 params
[0] = ((GLboolean
*) p
)[0];
1922 m
= *(GLmatrix
**) p
;
1923 for (i
= 0; i
< 16; i
++)
1924 params
[i
] = FLOAT_TO_BOOLEAN(m
->m
[i
]);
1928 m
= *(GLmatrix
**) p
;
1929 for (i
= 0; i
< 16; i
++)
1930 params
[i
] = FLOAT_TO_BOOLEAN(m
->m
[transpose
[i
]]);
1939 shift
= d
->type
- TYPE_BIT_0
;
1940 params
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
1946 _mesa_GetFloatv(GLenum pname
, GLfloat
*params
)
1948 const struct value_desc
*d
;
1954 d
= find_value("glGetFloatv", pname
, &p
, &v
);
1959 params
[0] = (GLfloat
) d
->offset
;
1964 params
[3] = ((GLfloat
*) p
)[3];
1967 params
[2] = ((GLfloat
*) p
)[2];
1970 params
[1] = ((GLfloat
*) p
)[1];
1973 params
[0] = ((GLfloat
*) p
)[0];
1977 params
[0] = ((GLdouble
*) p
)[0];
1981 params
[3] = (GLfloat
) (((GLint
*) p
)[3]);
1983 params
[2] = (GLfloat
) (((GLint
*) p
)[2]);
1986 params
[1] = (GLfloat
) (((GLint
*) p
)[1]);
1989 params
[0] = (GLfloat
) (((GLint
*) p
)[0]);
1993 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
1994 params
[i
] = INT_TO_FLOAT(v
.value_int_n
.ints
[i
]);
1998 params
[0] = ((GLint64
*) p
)[0];
2002 params
[0] = BOOLEAN_TO_FLOAT(*(GLboolean
*) p
);
2006 m
= *(GLmatrix
**) p
;
2007 for (i
= 0; i
< 16; i
++)
2008 params
[i
] = m
->m
[i
];
2012 m
= *(GLmatrix
**) p
;
2013 for (i
= 0; i
< 16; i
++)
2014 params
[i
] = m
->m
[transpose
[i
]];
2023 shift
= d
->type
- TYPE_BIT_0
;
2024 params
[0] = BOOLEAN_TO_FLOAT((*(GLbitfield
*) p
>> shift
) & 1);
2030 _mesa_GetIntegerv(GLenum pname
, GLint
*params
)
2032 const struct value_desc
*d
;
2038 d
= find_value("glGetIntegerv", pname
, &p
, &v
);
2043 params
[0] = d
->offset
;
2047 params
[3] = IROUND(((GLfloat
*) p
)[3]);
2049 params
[2] = IROUND(((GLfloat
*) p
)[2]);
2051 params
[1] = IROUND(((GLfloat
*) p
)[1]);
2053 params
[0] = IROUND(((GLfloat
*) p
)[0]);
2057 params
[3] = FLOAT_TO_INT(((GLfloat
*) p
)[3]);
2059 params
[2] = FLOAT_TO_INT(((GLfloat
*) p
)[2]);
2061 params
[1] = FLOAT_TO_INT(((GLfloat
*) p
)[1]);
2063 params
[0] = FLOAT_TO_INT(((GLfloat
*) p
)[0]);
2067 params
[0] = FLOAT_TO_INT(((GLdouble
*) p
)[0]);
2071 params
[3] = ((GLint
*) p
)[3];
2073 params
[2] = ((GLint
*) p
)[2];
2076 params
[1] = ((GLint
*) p
)[1];
2079 params
[0] = ((GLint
*) p
)[0];
2083 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
2084 params
[i
] = v
.value_int_n
.ints
[i
];
2088 params
[0] = INT64_TO_INT(((GLint64
*) p
)[0]);
2092 params
[0] = BOOLEAN_TO_INT(*(GLboolean
*) p
);
2096 m
= *(GLmatrix
**) p
;
2097 for (i
= 0; i
< 16; i
++)
2098 params
[i
] = FLOAT_TO_INT(m
->m
[i
]);
2102 m
= *(GLmatrix
**) p
;
2103 for (i
= 0; i
< 16; i
++)
2104 params
[i
] = FLOAT_TO_INT(m
->m
[transpose
[i
]]);
2113 shift
= d
->type
- TYPE_BIT_0
;
2114 params
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
2119 #if FEATURE_ARB_sync
2121 _mesa_GetInteger64v(GLenum pname
, GLint64
*params
)
2123 const struct value_desc
*d
;
2129 d
= find_value("glGetInteger64v", pname
, &p
, &v
);
2134 params
[0] = d
->offset
;
2138 params
[3] = IROUND64(((GLfloat
*) p
)[3]);
2140 params
[2] = IROUND64(((GLfloat
*) p
)[2]);
2142 params
[1] = IROUND64(((GLfloat
*) p
)[1]);
2144 params
[0] = IROUND64(((GLfloat
*) p
)[0]);
2148 params
[3] = FLOAT_TO_INT64(((GLfloat
*) p
)[3]);
2150 params
[2] = FLOAT_TO_INT64(((GLfloat
*) p
)[2]);
2152 params
[1] = FLOAT_TO_INT64(((GLfloat
*) p
)[1]);
2154 params
[0] = FLOAT_TO_INT64(((GLfloat
*) p
)[0]);
2158 params
[0] = FLOAT_TO_INT64(((GLdouble
*) p
)[0]);
2162 params
[3] = ((GLint
*) p
)[3];
2164 params
[2] = ((GLint
*) p
)[2];
2167 params
[1] = ((GLint
*) p
)[1];
2170 params
[0] = ((GLint
*) p
)[0];
2174 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
2175 params
[i
] = INT_TO_BOOLEAN(v
.value_int_n
.ints
[i
]);
2179 params
[0] = ((GLint64
*) p
)[0];
2183 params
[0] = ((GLboolean
*) p
)[0];
2187 m
= *(GLmatrix
**) p
;
2188 for (i
= 0; i
< 16; i
++)
2189 params
[i
] = FLOAT_TO_INT64(m
->m
[i
]);
2193 m
= *(GLmatrix
**) p
;
2194 for (i
= 0; i
< 16; i
++)
2195 params
[i
] = FLOAT_TO_INT64(m
->m
[transpose
[i
]]);
2204 shift
= d
->type
- TYPE_BIT_0
;
2205 params
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
2209 #endif /* FEATURE_ARB_sync */
2212 _mesa_GetDoublev(GLenum pname
, GLdouble
*params
)
2214 const struct value_desc
*d
;
2220 d
= find_value("glGetDoublev", pname
, &p
, &v
);
2225 params
[0] = d
->offset
;
2230 params
[3] = ((GLfloat
*) p
)[3];
2233 params
[2] = ((GLfloat
*) p
)[2];
2236 params
[1] = ((GLfloat
*) p
)[1];
2239 params
[0] = ((GLfloat
*) p
)[0];
2243 params
[0] = ((GLdouble
*) p
)[0];
2247 params
[3] = ((GLint
*) p
)[3];
2249 params
[2] = ((GLint
*) p
)[2];
2252 params
[1] = ((GLint
*) p
)[1];
2255 params
[0] = ((GLint
*) p
)[0];
2259 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
2260 params
[i
] = v
.value_int_n
.ints
[i
];
2264 params
[0] = ((GLint64
*) p
)[0];
2268 params
[0] = *(GLboolean
*) p
;
2272 m
= *(GLmatrix
**) p
;
2273 for (i
= 0; i
< 16; i
++)
2274 params
[i
] = m
->m
[i
];
2278 m
= *(GLmatrix
**) p
;
2279 for (i
= 0; i
< 16; i
++)
2280 params
[i
] = m
->m
[transpose
[i
]];
2289 shift
= d
->type
- TYPE_BIT_0
;
2290 params
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
2295 static enum value_type
2296 find_value_indexed(const char *func
, GLenum pname
, int index
, union value
*v
)
2298 GET_CURRENT_CONTEXT(ctx
);
2303 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2305 if (!ctx
->Extensions
.EXT_draw_buffers2
)
2307 v
->value_int
= (ctx
->Color
.BlendEnabled
>> index
) & 1;
2312 case GL_BLEND_SRC_RGB
:
2313 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2315 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
2317 v
->value_int
= ctx
->Color
.Blend
[index
].SrcRGB
;
2319 case GL_BLEND_SRC_ALPHA
:
2320 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2322 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
2324 v
->value_int
= ctx
->Color
.Blend
[index
].SrcA
;
2328 case GL_BLEND_DST_RGB
:
2329 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2331 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
2333 v
->value_int
= ctx
->Color
.Blend
[index
].DstRGB
;
2335 case GL_BLEND_DST_ALPHA
:
2336 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2338 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
2340 v
->value_int
= ctx
->Color
.Blend
[index
].DstA
;
2342 case GL_BLEND_EQUATION_RGB
:
2343 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2345 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
2347 v
->value_int
= ctx
->Color
.Blend
[index
].EquationRGB
;
2349 case GL_BLEND_EQUATION_ALPHA
:
2350 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2352 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
2354 v
->value_int
= ctx
->Color
.Blend
[index
].EquationA
;
2357 case GL_COLOR_WRITEMASK
:
2358 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2360 if (!ctx
->Extensions
.EXT_draw_buffers2
)
2362 v
->value_int_4
[0] = ctx
->Color
.ColorMask
[index
][RCOMP
] ? 1 : 0;
2363 v
->value_int_4
[1] = ctx
->Color
.ColorMask
[index
][GCOMP
] ? 1 : 0;
2364 v
->value_int_4
[2] = ctx
->Color
.ColorMask
[index
][BCOMP
] ? 1 : 0;
2365 v
->value_int_4
[3] = ctx
->Color
.ColorMask
[index
][ACOMP
] ? 1 : 0;
2368 case GL_TRANSFORM_FEEDBACK_BUFFER_START
:
2369 if (index
>= ctx
->Const
.MaxTransformFeedbackSeparateAttribs
)
2371 if (!ctx
->Extensions
.EXT_transform_feedback
)
2373 v
->value_int64
= ctx
->TransformFeedback
.CurrentObject
->Offset
[index
];
2376 case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE
:
2377 if (index
>= ctx
->Const
.MaxTransformFeedbackSeparateAttribs
)
2379 if (!ctx
->Extensions
.EXT_transform_feedback
)
2381 v
->value_int64
= ctx
->TransformFeedback
.CurrentObject
->Size
[index
];
2384 case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING
:
2385 if (index
>= ctx
->Const
.MaxTransformFeedbackSeparateAttribs
)
2387 if (!ctx
->Extensions
.EXT_transform_feedback
)
2389 v
->value_int
= ctx
->TransformFeedback
.CurrentObject
->Buffers
[index
]->Name
;
2394 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(pname=%s)", func
,
2395 _mesa_lookup_enum_by_nr(pname
));
2396 return TYPE_INVALID
;
2398 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(pname=%s)", func
,
2399 _mesa_lookup_enum_by_nr(pname
));
2400 return TYPE_INVALID
;
2404 _mesa_GetBooleanIndexedv( GLenum pname
, GLuint index
, GLboolean
*params
)
2407 enum value_type type
=
2408 find_value_indexed("glGetBooleanIndexedv", pname
, index
, &v
);
2412 params
[0] = INT_TO_BOOLEAN(v
.value_int
);
2415 params
[0] = INT_TO_BOOLEAN(v
.value_int_4
[0]);
2416 params
[1] = INT_TO_BOOLEAN(v
.value_int_4
[1]);
2417 params
[2] = INT_TO_BOOLEAN(v
.value_int_4
[2]);
2418 params
[3] = INT_TO_BOOLEAN(v
.value_int_4
[3]);
2421 params
[0] = INT64_TO_BOOLEAN(v
.value_int
);
2424 ; /* nothing - GL error was recorded */
2429 _mesa_GetIntegerIndexedv( GLenum pname
, GLuint index
, GLint
*params
)
2432 enum value_type type
=
2433 find_value_indexed("glGetIntegerIndexedv", pname
, index
, &v
);
2437 params
[0] = v
.value_int
;
2440 params
[0] = v
.value_int_4
[0];
2441 params
[1] = v
.value_int_4
[1];
2442 params
[2] = v
.value_int_4
[2];
2443 params
[3] = v
.value_int_4
[3];
2446 params
[0] = INT64_TO_INT(v
.value_int
);
2449 ; /* nothing - GL error was recorded */
2453 #if FEATURE_ARB_sync
2455 _mesa_GetInteger64Indexedv( GLenum pname
, GLuint index
, GLint64
*params
)
2458 enum value_type type
=
2459 find_value_indexed("glGetIntegerIndexedv", pname
, index
, &v
);
2463 params
[0] = v
.value_int
;
2466 params
[0] = v
.value_int_4
[0];
2467 params
[1] = v
.value_int_4
[1];
2468 params
[2] = v
.value_int_4
[2];
2469 params
[3] = v
.value_int_4
[3];
2472 params
[0] = v
.value_int
;
2475 ; /* nothing - GL error was recorded */
2478 #endif /* FEATURE_ARB_sync */
2482 _mesa_GetFixedv(GLenum pname
, GLfixed
*params
)
2484 const struct value_desc
*d
;
2490 d
= find_value("glGetDoublev", pname
, &p
, &v
);
2495 params
[0] = INT_TO_FIXED(d
->offset
);
2500 params
[3] = FLOAT_TO_FIXED(((GLfloat
*) p
)[3]);
2503 params
[2] = FLOAT_TO_FIXED(((GLfloat
*) p
)[2]);
2506 params
[1] = FLOAT_TO_FIXED(((GLfloat
*) p
)[1]);
2509 params
[0] = FLOAT_TO_FIXED(((GLfloat
*) p
)[0]);
2513 params
[0] = FLOAT_TO_FIXED(((GLdouble
*) p
)[0]);
2517 params
[3] = INT_TO_FIXED(((GLint
*) p
)[3]);
2519 params
[2] = INT_TO_FIXED(((GLint
*) p
)[2]);
2522 params
[1] = INT_TO_FIXED(((GLint
*) p
)[1]);
2525 params
[0] = INT_TO_FIXED(((GLint
*) p
)[0]);
2529 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
2530 params
[i
] = INT_TO_FIXED(v
.value_int_n
.ints
[i
]);
2534 params
[0] = ((GLint64
*) p
)[0];
2538 params
[0] = BOOLEAN_TO_FIXED(((GLboolean
*) p
)[0]);
2542 m
= *(GLmatrix
**) p
;
2543 for (i
= 0; i
< 16; i
++)
2544 params
[i
] = FLOAT_TO_FIXED(m
->m
[i
]);
2548 m
= *(GLmatrix
**) p
;
2549 for (i
= 0; i
< 16; i
++)
2550 params
[i
] = FLOAT_TO_FIXED(m
->m
[transpose
[i
]]);
2559 shift
= d
->type
- TYPE_BIT_0
;
2560 params
[0] = BOOLEAN_TO_FIXED((*(GLbitfield
*) p
>> shift
) & 1);