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_VALID_DRAW_BUFFER
,
135 EXTRA_VALID_TEXTURE_UNIT
,
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_FLOAT(field) CONTEXT_FIELD(field, TYPE_FLOAT)
192 #define CONTEXT_FLOAT2(field) CONTEXT_FIELD(field, TYPE_FLOAT_2)
193 #define CONTEXT_FLOAT3(field) CONTEXT_FIELD(field, TYPE_FLOAT_3)
194 #define CONTEXT_FLOAT4(field) CONTEXT_FIELD(field, TYPE_FLOAT_4)
195 #define CONTEXT_MATRIX(field) CONTEXT_FIELD(field, TYPE_MATRIX)
196 #define CONTEXT_MATRIX_T(field) CONTEXT_FIELD(field, TYPE_MATRIX_T)
198 #define ARRAY_INT(field) ARRAY_FIELD(field, TYPE_INT)
199 #define ARRAY_ENUM(field) ARRAY_FIELD(field, TYPE_ENUM)
200 #define ARRAY_BOOL(field) ARRAY_FIELD(field, TYPE_BOOLEAN)
203 offsetof(struct gl_extensions, f)
205 #define EXTRA_EXT(e) \
206 static const int extra_##e[] = { \
210 #define EXTRA_EXT2(e1, e2) \
211 static const int extra_##e1##_##e2[] = { \
212 EXT(e1), EXT(e2), EXTRA_END \
215 /* The 'extra' mechanism is a way to specify extra checks (such as
216 * extensions or specific gl versions) or actions (flush current, new
217 * buffers) that we need to do before looking up an enum. We need to
218 * declare them all up front so we can refer to them in the value_desc
221 static const int extra_new_buffers
[] = {
226 static const int extra_valid_draw_buffer
[] = {
227 EXTRA_VALID_DRAW_BUFFER
,
231 static const int extra_valid_texture_unit
[] = {
232 EXTRA_VALID_TEXTURE_UNIT
,
236 static const int extra_flush_current_valid_texture_unit
[] = {
238 EXTRA_VALID_TEXTURE_UNIT
,
242 static const int extra_flush_current
[] = {
247 static const int extra_new_buffers_OES_read_format
[] = {
249 EXT(OES_read_format
),
253 static const int extra_EXT_secondary_color_flush_current
[] = {
254 EXT(EXT_secondary_color
),
259 static const int extra_EXT_fog_coord_flush_current
[] = {
265 static const int extra_EXT_texture_integer
[] = {
266 EXT(EXT_texture_integer
),
270 static const int extra_EXT_gpu_shader4
[] = {
271 EXT(EXT_gpu_shader4
),
276 EXTRA_EXT(ARB_ES2_compatibility
);
277 EXTRA_EXT(ARB_multitexture
);
278 EXTRA_EXT(ARB_texture_cube_map
);
279 EXTRA_EXT(MESA_texture_array
);
280 EXTRA_EXT2(EXT_secondary_color
, ARB_vertex_program
);
281 EXTRA_EXT(EXT_secondary_color
);
282 EXTRA_EXT(EXT_fog_coord
);
283 EXTRA_EXT(EXT_texture_lod_bias
);
284 EXTRA_EXT(EXT_texture_filter_anisotropic
);
285 EXTRA_EXT(IBM_rasterpos_clip
);
286 EXTRA_EXT(NV_point_sprite
);
287 EXTRA_EXT(SGIS_generate_mipmap
);
288 EXTRA_EXT(NV_vertex_program
);
289 EXTRA_EXT(NV_fragment_program
);
290 EXTRA_EXT(NV_texture_rectangle
);
291 EXTRA_EXT(EXT_stencil_two_side
);
292 EXTRA_EXT(NV_light_max_exponent
);
293 EXTRA_EXT(SGI_texture_color_table
);
294 EXTRA_EXT(EXT_depth_bounds_test
);
295 EXTRA_EXT(ARB_depth_clamp
);
296 EXTRA_EXT(ATI_fragment_shader
);
297 EXTRA_EXT(EXT_framebuffer_blit
);
298 EXTRA_EXT(ARB_shader_objects
);
299 EXTRA_EXT(EXT_provoking_vertex
);
300 EXTRA_EXT(ARB_fragment_shader
);
301 EXTRA_EXT(ARB_fragment_program
);
302 EXTRA_EXT2(ARB_framebuffer_object
, EXT_framebuffer_multisample
);
303 EXTRA_EXT(EXT_framebuffer_object
);
304 EXTRA_EXT(APPLE_vertex_array_object
);
305 EXTRA_EXT(ARB_seamless_cube_map
);
306 EXTRA_EXT(EXT_compiled_vertex_array
);
308 EXTRA_EXT(ARB_vertex_shader
);
309 EXTRA_EXT(EXT_transform_feedback
);
310 EXTRA_EXT(ARB_transform_feedback2
);
311 EXTRA_EXT(EXT_pixel_buffer_object
);
312 EXTRA_EXT(ARB_vertex_program
);
313 EXTRA_EXT2(NV_point_sprite
, ARB_point_sprite
);
314 EXTRA_EXT2(ARB_fragment_program
, NV_fragment_program
);
315 EXTRA_EXT2(ARB_vertex_program
, NV_vertex_program
);
316 EXTRA_EXT2(ARB_vertex_program
, ARB_fragment_program
);
317 EXTRA_EXT(ARB_vertex_buffer_object
);
318 EXTRA_EXT(ARB_geometry_shader4
);
319 EXTRA_EXT(ARB_copy_buffer
);
322 extra_ARB_vertex_program_ARB_fragment_program_NV_vertex_program
[] = {
323 EXT(ARB_vertex_program
),
324 EXT(ARB_fragment_program
),
325 EXT(NV_vertex_program
),
330 extra_NV_vertex_program_ARB_vertex_program_ARB_fragment_program_NV_vertex_program
[] = {
331 EXT(NV_vertex_program
),
332 EXT(ARB_vertex_program
),
333 EXT(ARB_fragment_program
),
334 EXT(NV_vertex_program
),
339 extra_NV_primitive_restart
[] = {
340 EXT(NV_primitive_restart
),
344 static const int extra_version_30
[] = { EXTRA_VERSION_30
, EXTRA_END
};
345 static const int extra_version_31
[] = { EXTRA_VERSION_31
, EXTRA_END
};
346 static const int extra_version_32
[] = { EXTRA_VERSION_32
, EXTRA_END
};
349 extra_ARB_vertex_program_version_es2
[] = {
350 EXT(ARB_vertex_program
),
355 #define API_OPENGL_BIT (1 << API_OPENGL)
356 #define API_OPENGLES_BIT (1 << API_OPENGLES)
357 #define API_OPENGLES2_BIT (1 << API_OPENGLES2)
359 /* This is the big table describing all the enums we accept in
360 * glGet*v(). The table is partitioned into six parts: enums
361 * understood by all GL APIs (OpenGL, GLES and GLES2), enums shared
362 * between OpenGL and GLES, enums exclusive to GLES, etc for the
363 * remaining combinations. When we add the enums to the hash table in
364 * _mesa_init_get_hash(), we only add the enums for the API we're
365 * instantiating and the different sections are guarded by #if
366 * FEATURE_GL etc to make sure we only compile in the enums we may
369 static const struct value_desc values
[] = {
370 /* Enums shared between OpenGL, GLES1 and GLES2 */
371 { 0, 0, TYPE_API_MASK
,
372 API_OPENGL_BIT
| API_OPENGLES_BIT
| API_OPENGLES2_BIT
, NO_EXTRA
},
373 { GL_ALPHA_BITS
, BUFFER_INT(Visual
.alphaBits
), extra_new_buffers
},
374 { GL_BLEND
, CONTEXT_BIT0(Color
.BlendEnabled
), NO_EXTRA
},
375 { GL_BLEND_SRC
, CONTEXT_ENUM(Color
.Blend
[0].SrcRGB
), NO_EXTRA
},
376 { GL_BLUE_BITS
, BUFFER_INT(Visual
.blueBits
), extra_new_buffers
},
377 { GL_COLOR_CLEAR_VALUE
, CONTEXT_FIELD(Color
.ClearColor
[0], TYPE_FLOATN_4
), NO_EXTRA
},
378 { GL_COLOR_WRITEMASK
, LOC_CUSTOM
, TYPE_INT_4
, 0, NO_EXTRA
},
379 { GL_CULL_FACE
, CONTEXT_BOOL(Polygon
.CullFlag
), NO_EXTRA
},
380 { GL_CULL_FACE_MODE
, CONTEXT_ENUM(Polygon
.CullFaceMode
), NO_EXTRA
},
381 { GL_DEPTH_BITS
, BUFFER_INT(Visual
.depthBits
), NO_EXTRA
},
382 { GL_DEPTH_CLEAR_VALUE
, CONTEXT_FIELD(Depth
.Clear
, TYPE_DOUBLEN
), NO_EXTRA
},
383 { GL_DEPTH_FUNC
, CONTEXT_ENUM(Depth
.Func
), NO_EXTRA
},
384 { GL_DEPTH_RANGE
, CONTEXT_FIELD(Viewport
.Near
, TYPE_FLOATN_2
), NO_EXTRA
},
385 { GL_DEPTH_TEST
, CONTEXT_BOOL(Depth
.Test
), NO_EXTRA
},
386 { GL_DEPTH_WRITEMASK
, CONTEXT_BOOL(Depth
.Mask
), NO_EXTRA
},
387 { GL_DITHER
, CONTEXT_BOOL(Color
.DitherFlag
), NO_EXTRA
},
388 { GL_FRONT_FACE
, CONTEXT_ENUM(Polygon
.FrontFace
), NO_EXTRA
},
389 { GL_GREEN_BITS
, BUFFER_INT(Visual
.greenBits
), extra_new_buffers
},
390 { GL_LINE_WIDTH
, CONTEXT_FLOAT(Line
.Width
), NO_EXTRA
},
391 { GL_ALIASED_LINE_WIDTH_RANGE
, CONTEXT_FLOAT2(Const
.MinLineWidth
), NO_EXTRA
},
392 { GL_MAX_ELEMENTS_VERTICES
, CONTEXT_INT(Const
.MaxArrayLockSize
), NO_EXTRA
},
393 { GL_MAX_ELEMENTS_INDICES
, CONTEXT_INT(Const
.MaxArrayLockSize
), NO_EXTRA
},
394 { GL_MAX_TEXTURE_SIZE
, LOC_CUSTOM
, TYPE_INT
,
395 offsetof(struct gl_context
, Const
.MaxTextureLevels
), NO_EXTRA
},
396 { GL_MAX_VIEWPORT_DIMS
, CONTEXT_INT2(Const
.MaxViewportWidth
), NO_EXTRA
},
397 { GL_PACK_ALIGNMENT
, CONTEXT_INT(Pack
.Alignment
), NO_EXTRA
},
398 { GL_ALIASED_POINT_SIZE_RANGE
, CONTEXT_FLOAT2(Const
.MinPointSize
), NO_EXTRA
},
399 { GL_POLYGON_OFFSET_FACTOR
, CONTEXT_FLOAT(Polygon
.OffsetFactor
), NO_EXTRA
},
400 { GL_POLYGON_OFFSET_UNITS
, CONTEXT_FLOAT(Polygon
.OffsetUnits
), NO_EXTRA
},
401 { GL_POLYGON_OFFSET_FILL
, CONTEXT_BOOL(Polygon
.OffsetFill
), NO_EXTRA
},
402 { GL_RED_BITS
, BUFFER_INT(Visual
.redBits
), extra_new_buffers
},
403 { GL_SCISSOR_BOX
, LOC_CUSTOM
, TYPE_INT_4
, 0, NO_EXTRA
},
404 { GL_SCISSOR_TEST
, CONTEXT_BOOL(Scissor
.Enabled
), NO_EXTRA
},
405 { GL_STENCIL_BITS
, BUFFER_INT(Visual
.stencilBits
), NO_EXTRA
},
406 { GL_STENCIL_CLEAR_VALUE
, CONTEXT_INT(Stencil
.Clear
), NO_EXTRA
},
407 { GL_STENCIL_FAIL
, LOC_CUSTOM
, TYPE_ENUM
, NO_OFFSET
, NO_EXTRA
},
408 { GL_STENCIL_FUNC
, LOC_CUSTOM
, TYPE_ENUM
, NO_OFFSET
, NO_EXTRA
},
409 { GL_STENCIL_PASS_DEPTH_FAIL
, LOC_CUSTOM
, TYPE_ENUM
, NO_OFFSET
, NO_EXTRA
},
410 { GL_STENCIL_PASS_DEPTH_PASS
, LOC_CUSTOM
, TYPE_ENUM
, NO_OFFSET
, NO_EXTRA
},
411 { GL_STENCIL_REF
, LOC_CUSTOM
, TYPE_INT
, NO_OFFSET
, NO_EXTRA
},
412 { GL_STENCIL_TEST
, CONTEXT_BOOL(Stencil
.Enabled
), NO_EXTRA
},
413 { GL_STENCIL_VALUE_MASK
, LOC_CUSTOM
, TYPE_INT
, NO_OFFSET
, NO_EXTRA
},
414 { GL_STENCIL_WRITEMASK
, LOC_CUSTOM
, TYPE_INT
, NO_OFFSET
, NO_EXTRA
},
415 { GL_SUBPIXEL_BITS
, CONTEXT_INT(Const
.SubPixelBits
), NO_EXTRA
},
416 { GL_TEXTURE_BINDING_2D
, LOC_CUSTOM
, TYPE_INT
, TEXTURE_2D_INDEX
, NO_EXTRA
},
417 { GL_UNPACK_ALIGNMENT
, CONTEXT_INT(Unpack
.Alignment
), NO_EXTRA
},
418 { GL_VIEWPORT
, LOC_CUSTOM
, TYPE_INT_4
, 0, NO_EXTRA
},
420 /* GL_ARB_multitexture */
421 { GL_ACTIVE_TEXTURE_ARB
,
422 LOC_CUSTOM
, TYPE_INT
, 0, extra_ARB_multitexture
},
424 /* Note that all the OES_* extensions require that the Mesa "struct
425 * gl_extensions" include a member with the name of the extension.
426 * That structure does not yet include OES extensions (and we're
427 * not sure whether it will). If it does, all the OES_*
428 * extensions below should mark the dependency. */
430 /* GL_ARB_texture_cube_map */
431 { GL_TEXTURE_BINDING_CUBE_MAP_ARB
, LOC_CUSTOM
, TYPE_INT
,
432 TEXTURE_CUBE_INDEX
, extra_ARB_texture_cube_map
},
433 { GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB
, LOC_CUSTOM
, TYPE_INT
,
434 offsetof(struct gl_context
, Const
.MaxCubeTextureLevels
),
435 extra_ARB_texture_cube_map
}, /* XXX: OES_texture_cube_map */
437 /* XXX: OES_blend_subtract */
438 { GL_BLEND_SRC_RGB_EXT
, CONTEXT_ENUM(Color
.Blend
[0].SrcRGB
), NO_EXTRA
},
439 { GL_BLEND_DST_RGB_EXT
, CONTEXT_ENUM(Color
.Blend
[0].DstRGB
), NO_EXTRA
},
440 { GL_BLEND_SRC_ALPHA_EXT
, CONTEXT_ENUM(Color
.Blend
[0].SrcA
), NO_EXTRA
},
441 { GL_BLEND_DST_ALPHA_EXT
, CONTEXT_ENUM(Color
.Blend
[0].DstA
), NO_EXTRA
},
443 /* GL_BLEND_EQUATION_RGB, which is what we're really after, is
444 * defined identically to GL_BLEND_EQUATION. */
445 { GL_BLEND_EQUATION
, CONTEXT_ENUM(Color
.Blend
[0].EquationRGB
), NO_EXTRA
},
446 { GL_BLEND_EQUATION_ALPHA_EXT
, CONTEXT_ENUM(Color
.Blend
[0].EquationA
), NO_EXTRA
},
448 /* GL_ARB_texture_compression */
449 { GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB
, LOC_CUSTOM
, TYPE_INT
, 0, NO_EXTRA
},
450 { GL_COMPRESSED_TEXTURE_FORMATS_ARB
, LOC_CUSTOM
, TYPE_INT_N
, 0, NO_EXTRA
},
452 /* GL_ARB_multisample */
453 { GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
,
454 CONTEXT_BOOL(Multisample
.SampleAlphaToCoverage
), NO_EXTRA
},
455 { GL_SAMPLE_COVERAGE_ARB
, CONTEXT_BOOL(Multisample
.SampleCoverage
), NO_EXTRA
},
456 { GL_SAMPLE_COVERAGE_VALUE_ARB
,
457 CONTEXT_FLOAT(Multisample
.SampleCoverageValue
), NO_EXTRA
},
458 { GL_SAMPLE_COVERAGE_INVERT_ARB
,
459 CONTEXT_BOOL(Multisample
.SampleCoverageInvert
), NO_EXTRA
},
460 { GL_SAMPLE_BUFFERS_ARB
, BUFFER_INT(Visual
.sampleBuffers
), NO_EXTRA
},
461 { GL_SAMPLES_ARB
, BUFFER_INT(Visual
.samples
), NO_EXTRA
},
463 /* GL_SGIS_generate_mipmap */
464 { GL_GENERATE_MIPMAP_HINT_SGIS
, CONTEXT_ENUM(Hint
.GenerateMipmap
),
465 extra_SGIS_generate_mipmap
},
467 /* GL_ARB_vertex_buffer_object */
468 { GL_ARRAY_BUFFER_BINDING_ARB
, LOC_CUSTOM
, TYPE_INT
, 0, NO_EXTRA
},
470 /* GL_ARB_vertex_buffer_object */
471 /* GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB - not supported */
472 { GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB
, LOC_CUSTOM
, TYPE_INT
, 0,
473 extra_ARB_vertex_buffer_object
},
475 /* GL_ARB_copy_buffer */
476 { GL_COPY_READ_BUFFER
, LOC_CUSTOM
, TYPE_INT
, 0, extra_ARB_copy_buffer
},
477 { GL_COPY_WRITE_BUFFER
, LOC_CUSTOM
, TYPE_INT
, 0, extra_ARB_copy_buffer
},
479 /* GL_OES_read_format */
480 { GL_IMPLEMENTATION_COLOR_READ_TYPE_OES
, LOC_CUSTOM
, TYPE_INT
, 0,
481 extra_new_buffers_OES_read_format
},
482 { GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES
, LOC_CUSTOM
, TYPE_INT
, 0,
483 extra_new_buffers_OES_read_format
},
485 /* GL_EXT_framebuffer_object */
486 { GL_FRAMEBUFFER_BINDING_EXT
, BUFFER_INT(Name
),
487 extra_EXT_framebuffer_object
},
488 { GL_RENDERBUFFER_BINDING_EXT
, LOC_CUSTOM
, TYPE_INT
, 0,
489 extra_EXT_framebuffer_object
},
490 { GL_MAX_RENDERBUFFER_SIZE_EXT
, CONTEXT_INT(Const
.MaxRenderbufferSize
),
491 extra_EXT_framebuffer_object
},
493 /* This entry isn't spec'ed for GLES 2, but is needed for Mesa's
495 { GL_MAX_CLIP_PLANES
, CONTEXT_INT(Const
.MaxClipPlanes
), NO_EXTRA
},
497 #if FEATURE_GL || FEATURE_ES1
498 /* Enums in OpenGL and GLES1 */
499 { 0, 0, TYPE_API_MASK
, API_OPENGL_BIT
| API_OPENGLES_BIT
, NO_EXTRA
},
500 { GL_LIGHT0
, CONTEXT_BOOL(Light
.Light
[0].Enabled
), NO_EXTRA
},
501 { GL_LIGHT1
, CONTEXT_BOOL(Light
.Light
[1].Enabled
), NO_EXTRA
},
502 { GL_LIGHT2
, CONTEXT_BOOL(Light
.Light
[2].Enabled
), NO_EXTRA
},
503 { GL_LIGHT3
, CONTEXT_BOOL(Light
.Light
[3].Enabled
), NO_EXTRA
},
504 { GL_LIGHT4
, CONTEXT_BOOL(Light
.Light
[4].Enabled
), NO_EXTRA
},
505 { GL_LIGHT5
, CONTEXT_BOOL(Light
.Light
[5].Enabled
), NO_EXTRA
},
506 { GL_LIGHT6
, CONTEXT_BOOL(Light
.Light
[6].Enabled
), NO_EXTRA
},
507 { GL_LIGHT7
, CONTEXT_BOOL(Light
.Light
[7].Enabled
), NO_EXTRA
},
508 { GL_LIGHTING
, CONTEXT_BOOL(Light
.Enabled
), NO_EXTRA
},
509 { GL_LIGHT_MODEL_AMBIENT
,
510 CONTEXT_FIELD(Light
.Model
.Ambient
[0], TYPE_FLOATN_4
), NO_EXTRA
},
511 { GL_LIGHT_MODEL_TWO_SIDE
, CONTEXT_BOOL(Light
.Model
.TwoSide
), NO_EXTRA
},
512 { GL_ALPHA_TEST
, CONTEXT_BOOL(Color
.AlphaEnabled
), NO_EXTRA
},
513 { GL_ALPHA_TEST_FUNC
, CONTEXT_ENUM(Color
.AlphaFunc
), NO_EXTRA
},
514 { GL_ALPHA_TEST_REF
, CONTEXT_FIELD(Color
.AlphaRef
, TYPE_FLOATN
), NO_EXTRA
},
515 { GL_BLEND_DST
, CONTEXT_ENUM(Color
.Blend
[0].DstRGB
), NO_EXTRA
},
516 { GL_CLIP_PLANE0
, CONTEXT_BIT0(Transform
.ClipPlanesEnabled
), NO_EXTRA
},
517 { GL_CLIP_PLANE1
, CONTEXT_BIT1(Transform
.ClipPlanesEnabled
), NO_EXTRA
},
518 { GL_CLIP_PLANE2
, CONTEXT_BIT2(Transform
.ClipPlanesEnabled
), NO_EXTRA
},
519 { GL_CLIP_PLANE3
, CONTEXT_BIT3(Transform
.ClipPlanesEnabled
), NO_EXTRA
},
520 { GL_CLIP_PLANE4
, CONTEXT_BIT4(Transform
.ClipPlanesEnabled
), NO_EXTRA
},
521 { GL_CLIP_PLANE5
, CONTEXT_BIT5(Transform
.ClipPlanesEnabled
), NO_EXTRA
},
522 { GL_COLOR_MATERIAL
, CONTEXT_BOOL(Light
.ColorMaterialEnabled
), NO_EXTRA
},
524 CONTEXT_FIELD(Current
.Attrib
[VERT_ATTRIB_COLOR0
][0], TYPE_FLOATN_4
),
525 extra_flush_current
},
527 CONTEXT_FIELD(Current
.Attrib
[VERT_ATTRIB_NORMAL
][0], TYPE_FLOATN_3
),
528 extra_flush_current
},
529 { GL_CURRENT_TEXTURE_COORDS
, LOC_CUSTOM
, TYPE_FLOAT_4
, 0,
530 extra_flush_current_valid_texture_unit
},
531 { GL_DISTANCE_ATTENUATION_EXT
, CONTEXT_FLOAT3(Point
.Params
[0]), NO_EXTRA
},
532 { GL_FOG
, CONTEXT_BOOL(Fog
.Enabled
), NO_EXTRA
},
533 { GL_FOG_COLOR
, CONTEXT_FIELD(Fog
.Color
[0], TYPE_FLOATN_4
), NO_EXTRA
},
534 { GL_FOG_DENSITY
, CONTEXT_FLOAT(Fog
.Density
), NO_EXTRA
},
535 { GL_FOG_END
, CONTEXT_FLOAT(Fog
.End
), NO_EXTRA
},
536 { GL_FOG_HINT
, CONTEXT_ENUM(Hint
.Fog
), NO_EXTRA
},
537 { GL_FOG_MODE
, CONTEXT_ENUM(Fog
.Mode
), NO_EXTRA
},
538 { GL_FOG_START
, CONTEXT_FLOAT(Fog
.Start
), NO_EXTRA
},
539 { GL_LINE_SMOOTH
, CONTEXT_BOOL(Line
.SmoothFlag
), NO_EXTRA
},
540 { GL_LINE_SMOOTH_HINT
, CONTEXT_ENUM(Hint
.LineSmooth
), NO_EXTRA
},
541 { GL_LINE_WIDTH_RANGE
, CONTEXT_FLOAT2(Const
.MinLineWidthAA
), NO_EXTRA
},
542 { GL_COLOR_LOGIC_OP
, CONTEXT_BOOL(Color
.ColorLogicOpEnabled
), NO_EXTRA
},
543 { GL_LOGIC_OP_MODE
, CONTEXT_ENUM(Color
.LogicOp
), NO_EXTRA
},
544 { GL_MATRIX_MODE
, CONTEXT_ENUM(Transform
.MatrixMode
), NO_EXTRA
},
545 { GL_MAX_MODELVIEW_STACK_DEPTH
, CONST(MAX_MODELVIEW_STACK_DEPTH
), NO_EXTRA
},
546 { GL_MAX_PROJECTION_STACK_DEPTH
, CONST(MAX_PROJECTION_STACK_DEPTH
), NO_EXTRA
},
547 { GL_MAX_TEXTURE_STACK_DEPTH
, CONST(MAX_TEXTURE_STACK_DEPTH
), NO_EXTRA
},
548 { GL_MODELVIEW_MATRIX
, CONTEXT_MATRIX(ModelviewMatrixStack
.Top
), NO_EXTRA
},
549 { GL_MODELVIEW_STACK_DEPTH
, LOC_CUSTOM
, TYPE_INT
,
550 offsetof(struct gl_context
, ModelviewMatrixStack
.Depth
), NO_EXTRA
},
551 { GL_NORMALIZE
, CONTEXT_BOOL(Transform
.Normalize
), NO_EXTRA
},
552 { GL_PACK_SKIP_IMAGES_EXT
, CONTEXT_INT(Pack
.SkipImages
), NO_EXTRA
},
553 { GL_PERSPECTIVE_CORRECTION_HINT
, CONTEXT_ENUM(Hint
.PerspectiveCorrection
), NO_EXTRA
},
554 { GL_POINT_SIZE
, CONTEXT_FLOAT(Point
.Size
), NO_EXTRA
},
555 { GL_POINT_SIZE_RANGE
, CONTEXT_FLOAT2(Const
.MinPointSizeAA
), NO_EXTRA
},
556 { GL_POINT_SMOOTH
, CONTEXT_BOOL(Point
.SmoothFlag
), NO_EXTRA
},
557 { GL_POINT_SMOOTH_HINT
, CONTEXT_ENUM(Hint
.PointSmooth
), NO_EXTRA
},
558 { GL_POINT_SIZE_MIN_EXT
, CONTEXT_FLOAT(Point
.MinSize
), NO_EXTRA
},
559 { GL_POINT_SIZE_MAX_EXT
, CONTEXT_FLOAT(Point
.MaxSize
), NO_EXTRA
},
560 { GL_POINT_FADE_THRESHOLD_SIZE_EXT
, CONTEXT_FLOAT(Point
.Threshold
), NO_EXTRA
},
561 { GL_PROJECTION_MATRIX
, CONTEXT_MATRIX(ProjectionMatrixStack
.Top
), NO_EXTRA
},
562 { GL_PROJECTION_STACK_DEPTH
, LOC_CUSTOM
, TYPE_INT
,
563 offsetof(struct gl_context
, ProjectionMatrixStack
.Depth
), NO_EXTRA
},
564 { GL_RESCALE_NORMAL
, CONTEXT_BOOL(Transform
.RescaleNormals
), NO_EXTRA
},
565 { GL_SHADE_MODEL
, CONTEXT_ENUM(Light
.ShadeModel
), NO_EXTRA
},
566 { GL_TEXTURE_2D
, LOC_CUSTOM
, TYPE_BOOLEAN
, 0, NO_EXTRA
},
567 { GL_TEXTURE_MATRIX
, LOC_CUSTOM
, TYPE_MATRIX
, 0, extra_valid_texture_unit
},
568 { GL_TEXTURE_STACK_DEPTH
, LOC_CUSTOM
, TYPE_INT
, 0,
569 extra_valid_texture_unit
},
571 { GL_VERTEX_ARRAY
, ARRAY_BOOL(Vertex
.Enabled
), NO_EXTRA
},
572 { GL_VERTEX_ARRAY_SIZE
, ARRAY_INT(Vertex
.Size
), NO_EXTRA
},
573 { GL_VERTEX_ARRAY_TYPE
, ARRAY_ENUM(Vertex
.Type
), NO_EXTRA
},
574 { GL_VERTEX_ARRAY_STRIDE
, ARRAY_INT(Vertex
.Stride
), NO_EXTRA
},
575 { GL_NORMAL_ARRAY
, ARRAY_ENUM(Normal
.Enabled
), NO_EXTRA
},
576 { GL_NORMAL_ARRAY_TYPE
, ARRAY_ENUM(Normal
.Type
), NO_EXTRA
},
577 { GL_NORMAL_ARRAY_STRIDE
, ARRAY_INT(Normal
.Stride
), NO_EXTRA
},
578 { GL_COLOR_ARRAY
, ARRAY_BOOL(Color
.Enabled
), NO_EXTRA
},
579 { GL_COLOR_ARRAY_SIZE
, ARRAY_INT(Color
.Size
), NO_EXTRA
},
580 { GL_COLOR_ARRAY_TYPE
, ARRAY_ENUM(Color
.Type
), NO_EXTRA
},
581 { GL_COLOR_ARRAY_STRIDE
, ARRAY_INT(Color
.Stride
), NO_EXTRA
},
582 { GL_TEXTURE_COORD_ARRAY
,
583 LOC_CUSTOM
, TYPE_BOOLEAN
, offsetof(struct gl_client_array
, Enabled
), NO_EXTRA
},
584 { GL_TEXTURE_COORD_ARRAY_SIZE
,
585 LOC_CUSTOM
, TYPE_BOOLEAN
, offsetof(struct gl_client_array
, Size
), NO_EXTRA
},
586 { GL_TEXTURE_COORD_ARRAY_TYPE
,
587 LOC_CUSTOM
, TYPE_BOOLEAN
, offsetof(struct gl_client_array
, Type
), NO_EXTRA
},
588 { GL_TEXTURE_COORD_ARRAY_STRIDE
,
589 LOC_CUSTOM
, TYPE_BOOLEAN
, offsetof(struct gl_client_array
, Stride
), NO_EXTRA
},
591 /* GL_ARB_ES2_compatibility */
592 { GL_SHADER_COMPILER
, CONST(1), extra_ARB_ES2_compatibility
},
593 { GL_MAX_VARYING_VECTORS
, CONTEXT_INT(Const
.MaxVarying
),
594 extra_ARB_ES2_compatibility
},
595 { GL_MAX_VERTEX_UNIFORM_VECTORS
, LOC_CUSTOM
, TYPE_INT
, 0,
596 extra_ARB_ES2_compatibility
},
597 { GL_MAX_FRAGMENT_UNIFORM_VECTORS
, LOC_CUSTOM
, TYPE_INT
, 0,
598 extra_ARB_ES2_compatibility
},
600 /* GL_ARB_multitexture */
601 { GL_MAX_TEXTURE_UNITS_ARB
,
602 CONTEXT_INT(Const
.MaxTextureUnits
), extra_ARB_multitexture
},
603 { GL_CLIENT_ACTIVE_TEXTURE_ARB
,
604 LOC_CUSTOM
, TYPE_INT
, 0, extra_ARB_multitexture
},
606 /* GL_ARB_texture_cube_map */
607 { GL_TEXTURE_CUBE_MAP_ARB
, LOC_CUSTOM
, TYPE_BOOLEAN
, 0, NO_EXTRA
},
608 /* S, T, and R are always set at the same time */
609 { GL_TEXTURE_GEN_STR_OES
, LOC_TEXUNIT
, TYPE_BIT_0
,
610 offsetof(struct gl_texture_unit
, TexGenEnabled
), NO_EXTRA
},
612 /* GL_ARB_multisample */
613 { GL_MULTISAMPLE_ARB
, CONTEXT_BOOL(Multisample
.Enabled
), NO_EXTRA
},
614 { GL_SAMPLE_ALPHA_TO_ONE_ARB
, CONTEXT_BOOL(Multisample
.SampleAlphaToOne
), NO_EXTRA
},
616 /* GL_ARB_vertex_buffer_object */
617 { GL_VERTEX_ARRAY_BUFFER_BINDING_ARB
, LOC_CUSTOM
, TYPE_INT
,
618 offsetof(struct gl_array_object
, Vertex
.BufferObj
), NO_EXTRA
},
619 { GL_NORMAL_ARRAY_BUFFER_BINDING_ARB
, LOC_CUSTOM
, TYPE_INT
,
620 offsetof(struct gl_array_object
, Normal
.BufferObj
), NO_EXTRA
},
621 { GL_COLOR_ARRAY_BUFFER_BINDING_ARB
, LOC_CUSTOM
, TYPE_INT
,
622 offsetof(struct gl_array_object
, Color
.BufferObj
), NO_EXTRA
},
623 { GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB
, LOC_CUSTOM
, TYPE_INT
, NO_OFFSET
, NO_EXTRA
},
625 /* GL_OES_point_sprite */
626 { GL_POINT_SPRITE_NV
,
627 CONTEXT_BOOL(Point
.PointSprite
),
628 extra_NV_point_sprite_ARB_point_sprite
},
630 /* GL_ARB_fragment_shader */
631 { GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB
,
632 CONTEXT_INT(Const
.FragmentProgram
.MaxUniformComponents
),
633 extra_ARB_fragment_shader
},
635 /* GL_ARB_vertex_shader */
636 { GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB
,
637 CONTEXT_INT(Const
.VertexProgram
.MaxUniformComponents
),
638 extra_ARB_vertex_shader
},
639 { GL_MAX_VARYING_FLOATS_ARB
, LOC_CUSTOM
, TYPE_INT
, 0,
640 extra_ARB_vertex_shader
},
642 /* GL_EXT_texture_lod_bias */
643 { GL_MAX_TEXTURE_LOD_BIAS_EXT
, CONTEXT_FLOAT(Const
.MaxTextureLodBias
),
644 extra_EXT_texture_lod_bias
},
646 /* GL_EXT_texture_filter_anisotropic */
647 { GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT
,
648 CONTEXT_FLOAT(Const
.MaxTextureMaxAnisotropy
),
649 extra_EXT_texture_filter_anisotropic
},
650 #endif /* FEATURE_GL || FEATURE_ES1 */
653 { 0, 0, TYPE_API_MASK
, API_OPENGLES_BIT
},
654 /* XXX: OES_matrix_get */
655 { GL_MODELVIEW_MATRIX_FLOAT_AS_INT_BITS_OES
},
656 { GL_PROJECTION_MATRIX_FLOAT_AS_INT_BITS_OES
},
657 { GL_TEXTURE_MATRIX_FLOAT_AS_INT_BITS_OES
},
659 /* OES_point_size_array */
660 { GL_POINT_SIZE_ARRAY_OES
, ARRAY_FIELD(PointSize
.Enabled
, TYPE_BOOLEAN
) },
661 { GL_POINT_SIZE_ARRAY_TYPE_OES
, ARRAY_FIELD(PointSize
.Type
, TYPE_ENUM
) },
662 { GL_POINT_SIZE_ARRAY_STRIDE_OES
, ARRAY_FIELD(PointSize
.Stride
, TYPE_INT
) },
663 { GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES
, LOC_CUSTOM
, TYPE_INT
, 0 },
664 #endif /* FEATURE_ES1 */
666 #if FEATURE_GL || FEATURE_ES2
667 { 0, 0, TYPE_API_MASK
, API_OPENGL_BIT
| API_OPENGLES2_BIT
, NO_EXTRA
},
668 /* This entry isn't spec'ed for GLES 2, but is needed for Mesa's GLSL: */
669 { GL_MAX_LIGHTS
, CONTEXT_INT(Const
.MaxLights
), NO_EXTRA
},
670 { GL_MAX_TEXTURE_COORDS_ARB
, /* == GL_MAX_TEXTURE_COORDS_NV */
671 CONTEXT_INT(Const
.MaxTextureCoordUnits
),
672 extra_ARB_fragment_program_NV_fragment_program
},
674 /* GL_ARB_draw_buffers */
675 { GL_MAX_DRAW_BUFFERS_ARB
, CONTEXT_INT(Const
.MaxDrawBuffers
), NO_EXTRA
},
677 { GL_BLEND_COLOR_EXT
, CONTEXT_FIELD(Color
.BlendColor
[0], TYPE_FLOATN_4
), NO_EXTRA
},
678 /* GL_ARB_fragment_program */
679 { GL_MAX_TEXTURE_IMAGE_UNITS_ARB
, /* == GL_MAX_TEXTURE_IMAGE_UNITS_NV */
680 CONTEXT_INT(Const
.MaxTextureImageUnits
),
681 extra_ARB_fragment_program_NV_fragment_program
},
682 { GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB
,
683 CONTEXT_INT(Const
.MaxVertexTextureImageUnits
), extra_ARB_vertex_shader
},
684 { GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB
,
685 CONTEXT_INT(Const
.MaxCombinedTextureImageUnits
),
686 extra_ARB_vertex_shader
},
688 /* GL_ARB_shader_objects
689 * Actually, this token isn't part of GL_ARB_shader_objects, but is
690 * close enough for now. */
691 { GL_CURRENT_PROGRAM
, LOC_CUSTOM
, TYPE_INT
, 0, extra_ARB_shader_objects
},
694 { GL_STENCIL_BACK_FUNC
, CONTEXT_ENUM(Stencil
.Function
[1]), NO_EXTRA
},
695 { GL_STENCIL_BACK_VALUE_MASK
, CONTEXT_INT(Stencil
.ValueMask
[1]), NO_EXTRA
},
696 { GL_STENCIL_BACK_WRITEMASK
, CONTEXT_INT(Stencil
.WriteMask
[1]), NO_EXTRA
},
697 { GL_STENCIL_BACK_REF
, CONTEXT_INT(Stencil
.Ref
[1]), NO_EXTRA
},
698 { GL_STENCIL_BACK_FAIL
, CONTEXT_ENUM(Stencil
.FailFunc
[1]), NO_EXTRA
},
699 { GL_STENCIL_BACK_PASS_DEPTH_FAIL
, CONTEXT_ENUM(Stencil
.ZFailFunc
[1]), NO_EXTRA
},
700 { GL_STENCIL_BACK_PASS_DEPTH_PASS
, CONTEXT_ENUM(Stencil
.ZPassFunc
[1]), NO_EXTRA
},
702 { GL_MAX_VERTEX_ATTRIBS_ARB
,
703 CONTEXT_INT(Const
.VertexProgram
.MaxAttribs
),
704 extra_ARB_vertex_program_version_es2
},
707 { GL_TEXTURE_BINDING_3D
, LOC_CUSTOM
, TYPE_INT
, TEXTURE_3D_INDEX
, NO_EXTRA
},
708 { GL_MAX_3D_TEXTURE_SIZE
, LOC_CUSTOM
, TYPE_INT
,
709 offsetof(struct gl_context
, Const
.Max3DTextureLevels
), NO_EXTRA
},
711 /* GL_ARB_fragment_program/OES_standard_derivatives */
712 { GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB
,
713 CONTEXT_ENUM(Hint
.FragmentShaderDerivative
), extra_ARB_fragment_shader
},
714 #endif /* FEATURE_GL || FEATURE_ES2 */
717 /* Enums unique to OpenGL ES 2.0 */
718 { 0, 0, TYPE_API_MASK
, API_OPENGLES2_BIT
, NO_EXTRA
},
719 { GL_MAX_FRAGMENT_UNIFORM_VECTORS
, LOC_CUSTOM
, TYPE_INT
, 0, NO_EXTRA
},
720 { GL_MAX_VARYING_VECTORS
, CONTEXT_INT(Const
.MaxVarying
), NO_EXTRA
},
721 { GL_MAX_VERTEX_UNIFORM_VECTORS
, LOC_CUSTOM
, TYPE_INT
, 0, NO_EXTRA
},
722 { GL_SHADER_COMPILER
, CONST(1), NO_EXTRA
},
723 /* OES_get_program_binary */
724 { GL_NUM_SHADER_BINARY_FORMATS
, CONST(0), NO_EXTRA
},
725 { GL_SHADER_BINARY_FORMATS
, CONST(0), NO_EXTRA
},
726 #endif /* FEATURE_ES2 */
729 /* Remaining enums are only in OpenGL */
730 { 0, 0, TYPE_API_MASK
, API_OPENGL_BIT
, NO_EXTRA
},
731 { GL_ACCUM_RED_BITS
, BUFFER_INT(Visual
.accumRedBits
), NO_EXTRA
},
732 { GL_ACCUM_GREEN_BITS
, BUFFER_INT(Visual
.accumGreenBits
), NO_EXTRA
},
733 { GL_ACCUM_BLUE_BITS
, BUFFER_INT(Visual
.accumBlueBits
), NO_EXTRA
},
734 { GL_ACCUM_ALPHA_BITS
, BUFFER_INT(Visual
.accumAlphaBits
), NO_EXTRA
},
735 { GL_ACCUM_CLEAR_VALUE
, CONTEXT_FIELD(Accum
.ClearColor
[0], TYPE_FLOATN_4
), NO_EXTRA
},
736 { GL_ALPHA_BIAS
, CONTEXT_FLOAT(Pixel
.AlphaBias
), NO_EXTRA
},
737 { GL_ALPHA_SCALE
, CONTEXT_FLOAT(Pixel
.AlphaScale
), NO_EXTRA
},
738 { GL_ATTRIB_STACK_DEPTH
, CONTEXT_INT(AttribStackDepth
), NO_EXTRA
},
739 { GL_AUTO_NORMAL
, CONTEXT_BOOL(Eval
.AutoNormal
), NO_EXTRA
},
740 { GL_AUX_BUFFERS
, BUFFER_INT(Visual
.numAuxBuffers
), NO_EXTRA
},
741 { GL_BLUE_BIAS
, CONTEXT_FLOAT(Pixel
.BlueBias
), NO_EXTRA
},
742 { GL_BLUE_SCALE
, CONTEXT_FLOAT(Pixel
.BlueScale
), NO_EXTRA
},
743 { GL_CLIENT_ATTRIB_STACK_DEPTH
, CONTEXT_INT(ClientAttribStackDepth
), NO_EXTRA
},
744 { GL_COLOR_MATERIAL_FACE
, CONTEXT_ENUM(Light
.ColorMaterialFace
), NO_EXTRA
},
745 { GL_COLOR_MATERIAL_PARAMETER
, CONTEXT_ENUM(Light
.ColorMaterialMode
), NO_EXTRA
},
747 CONTEXT_FLOAT(Current
.Attrib
[VERT_ATTRIB_COLOR_INDEX
][0]),
748 extra_flush_current
},
749 { GL_CURRENT_RASTER_COLOR
,
750 CONTEXT_FIELD(Current
.RasterColor
[0], TYPE_FLOATN_4
), NO_EXTRA
},
751 { GL_CURRENT_RASTER_DISTANCE
, CONTEXT_FLOAT(Current
.RasterDistance
), NO_EXTRA
},
752 { GL_CURRENT_RASTER_INDEX
, CONST(1), NO_EXTRA
},
753 { GL_CURRENT_RASTER_POSITION
, CONTEXT_FLOAT4(Current
.RasterPos
[0]), NO_EXTRA
},
754 { GL_CURRENT_RASTER_SECONDARY_COLOR
,
755 CONTEXT_FIELD(Current
.RasterSecondaryColor
[0], TYPE_FLOATN_4
), NO_EXTRA
},
756 { GL_CURRENT_RASTER_TEXTURE_COORDS
, LOC_CUSTOM
, TYPE_FLOAT_4
, 0,
757 extra_valid_texture_unit
},
758 { GL_CURRENT_RASTER_POSITION_VALID
, CONTEXT_BOOL(Current
.RasterPosValid
), NO_EXTRA
},
759 { GL_DEPTH_BIAS
, CONTEXT_FLOAT(Pixel
.DepthBias
), NO_EXTRA
},
760 { GL_DEPTH_SCALE
, CONTEXT_FLOAT(Pixel
.DepthScale
), NO_EXTRA
},
761 { GL_DOUBLEBUFFER
, BUFFER_INT(Visual
.doubleBufferMode
), NO_EXTRA
},
762 { GL_DRAW_BUFFER
, BUFFER_ENUM(ColorDrawBuffer
[0]), NO_EXTRA
},
763 { GL_EDGE_FLAG
, LOC_CUSTOM
, TYPE_BOOLEAN
, 0, NO_EXTRA
},
764 { GL_FEEDBACK_BUFFER_SIZE
, CONTEXT_INT(Feedback
.BufferSize
), NO_EXTRA
},
765 { GL_FEEDBACK_BUFFER_TYPE
, CONTEXT_ENUM(Feedback
.Type
), NO_EXTRA
},
766 { GL_FOG_INDEX
, CONTEXT_FLOAT(Fog
.Index
), NO_EXTRA
},
767 { GL_GREEN_BIAS
, CONTEXT_FLOAT(Pixel
.GreenBias
), NO_EXTRA
},
768 { GL_GREEN_SCALE
, CONTEXT_FLOAT(Pixel
.GreenScale
), NO_EXTRA
},
769 { GL_INDEX_BITS
, BUFFER_INT(Visual
.indexBits
), extra_new_buffers
},
770 { GL_INDEX_CLEAR_VALUE
, CONTEXT_INT(Color
.ClearIndex
), NO_EXTRA
},
771 { GL_INDEX_MODE
, CONST(0) , NO_EXTRA
},
772 { GL_INDEX_OFFSET
, CONTEXT_INT(Pixel
.IndexOffset
), NO_EXTRA
},
773 { GL_INDEX_SHIFT
, CONTEXT_INT(Pixel
.IndexShift
), NO_EXTRA
},
774 { GL_INDEX_WRITEMASK
, CONTEXT_INT(Color
.IndexMask
), NO_EXTRA
},
775 { GL_LIGHT_MODEL_COLOR_CONTROL
, CONTEXT_ENUM(Light
.Model
.ColorControl
), NO_EXTRA
},
776 { GL_LIGHT_MODEL_LOCAL_VIEWER
, CONTEXT_BOOL(Light
.Model
.LocalViewer
), NO_EXTRA
},
777 { GL_LINE_STIPPLE
, CONTEXT_BOOL(Line
.StippleFlag
), NO_EXTRA
},
778 { GL_LINE_STIPPLE_PATTERN
, LOC_CUSTOM
, TYPE_INT
, 0, NO_EXTRA
},
779 { GL_LINE_STIPPLE_REPEAT
, CONTEXT_INT(Line
.StippleFactor
), NO_EXTRA
},
780 { GL_LINE_WIDTH_GRANULARITY
, CONTEXT_FLOAT(Const
.LineWidthGranularity
), NO_EXTRA
},
781 { GL_LIST_BASE
, CONTEXT_INT(List
.ListBase
), NO_EXTRA
},
782 { GL_LIST_INDEX
, LOC_CUSTOM
, TYPE_INT
, 0, NO_EXTRA
},
783 { GL_LIST_MODE
, LOC_CUSTOM
, TYPE_ENUM
, 0, NO_EXTRA
},
784 { GL_INDEX_LOGIC_OP
, CONTEXT_BOOL(Color
.IndexLogicOpEnabled
), NO_EXTRA
},
785 { GL_MAP1_COLOR_4
, CONTEXT_BOOL(Eval
.Map1Color4
), NO_EXTRA
},
786 { GL_MAP1_GRID_DOMAIN
, CONTEXT_FLOAT2(Eval
.MapGrid1u1
), NO_EXTRA
},
787 { GL_MAP1_GRID_SEGMENTS
, CONTEXT_INT(Eval
.MapGrid1un
), NO_EXTRA
},
788 { GL_MAP1_INDEX
, CONTEXT_BOOL(Eval
.Map1Index
), NO_EXTRA
},
789 { GL_MAP1_NORMAL
, CONTEXT_BOOL(Eval
.Map1Normal
), NO_EXTRA
},
790 { GL_MAP1_TEXTURE_COORD_1
, CONTEXT_BOOL(Eval
.Map1TextureCoord1
), NO_EXTRA
},
791 { GL_MAP1_TEXTURE_COORD_2
, CONTEXT_BOOL(Eval
.Map1TextureCoord2
), NO_EXTRA
},
792 { GL_MAP1_TEXTURE_COORD_3
, CONTEXT_BOOL(Eval
.Map1TextureCoord3
), NO_EXTRA
},
793 { GL_MAP1_TEXTURE_COORD_4
, CONTEXT_BOOL(Eval
.Map1TextureCoord4
), NO_EXTRA
},
794 { GL_MAP1_VERTEX_3
, CONTEXT_BOOL(Eval
.Map1Vertex3
), NO_EXTRA
},
795 { GL_MAP1_VERTEX_4
, CONTEXT_BOOL(Eval
.Map1Vertex4
), NO_EXTRA
},
796 { GL_MAP2_COLOR_4
, CONTEXT_BOOL(Eval
.Map2Color4
), NO_EXTRA
},
797 { GL_MAP2_GRID_DOMAIN
, LOC_CUSTOM
, TYPE_FLOAT_4
, 0, NO_EXTRA
},
798 { GL_MAP2_GRID_SEGMENTS
, CONTEXT_INT2(Eval
.MapGrid2un
), NO_EXTRA
},
799 { GL_MAP2_INDEX
, CONTEXT_BOOL(Eval
.Map2Index
), NO_EXTRA
},
800 { GL_MAP2_NORMAL
, CONTEXT_BOOL(Eval
.Map2Normal
), NO_EXTRA
},
801 { GL_MAP2_TEXTURE_COORD_1
, CONTEXT_BOOL(Eval
.Map2TextureCoord1
), NO_EXTRA
},
802 { GL_MAP2_TEXTURE_COORD_2
, CONTEXT_BOOL(Eval
.Map2TextureCoord2
), NO_EXTRA
},
803 { GL_MAP2_TEXTURE_COORD_3
, CONTEXT_BOOL(Eval
.Map2TextureCoord3
), NO_EXTRA
},
804 { GL_MAP2_TEXTURE_COORD_4
, CONTEXT_BOOL(Eval
.Map2TextureCoord4
), NO_EXTRA
},
805 { GL_MAP2_VERTEX_3
, CONTEXT_BOOL(Eval
.Map2Vertex3
), NO_EXTRA
},
806 { GL_MAP2_VERTEX_4
, CONTEXT_BOOL(Eval
.Map2Vertex4
), NO_EXTRA
},
807 { GL_MAP_COLOR
, CONTEXT_BOOL(Pixel
.MapColorFlag
), NO_EXTRA
},
808 { GL_MAP_STENCIL
, CONTEXT_BOOL(Pixel
.MapStencilFlag
), NO_EXTRA
},
809 { GL_MAX_ATTRIB_STACK_DEPTH
, CONST(MAX_ATTRIB_STACK_DEPTH
), NO_EXTRA
},
810 { GL_MAX_CLIENT_ATTRIB_STACK_DEPTH
, CONST(MAX_CLIENT_ATTRIB_STACK_DEPTH
), NO_EXTRA
},
812 { GL_MAX_EVAL_ORDER
, CONST(MAX_EVAL_ORDER
), NO_EXTRA
},
813 { GL_MAX_LIST_NESTING
, CONST(MAX_LIST_NESTING
), NO_EXTRA
},
814 { GL_MAX_NAME_STACK_DEPTH
, CONST(MAX_NAME_STACK_DEPTH
), NO_EXTRA
},
815 { GL_MAX_PIXEL_MAP_TABLE
, CONST(MAX_PIXEL_MAP_TABLE
), NO_EXTRA
},
816 { GL_NAME_STACK_DEPTH
, CONTEXT_INT(Select
.NameStackDepth
), NO_EXTRA
},
817 { GL_PACK_LSB_FIRST
, CONTEXT_BOOL(Pack
.LsbFirst
), NO_EXTRA
},
818 { GL_PACK_ROW_LENGTH
, CONTEXT_INT(Pack
.RowLength
), NO_EXTRA
},
819 { GL_PACK_SKIP_PIXELS
, CONTEXT_INT(Pack
.SkipPixels
), NO_EXTRA
},
820 { GL_PACK_SKIP_ROWS
, CONTEXT_INT(Pack
.SkipRows
), NO_EXTRA
},
821 { GL_PACK_SWAP_BYTES
, CONTEXT_BOOL(Pack
.SwapBytes
), NO_EXTRA
},
822 { GL_PACK_IMAGE_HEIGHT_EXT
, CONTEXT_INT(Pack
.ImageHeight
), NO_EXTRA
},
823 { GL_PACK_INVERT_MESA
, CONTEXT_BOOL(Pack
.Invert
), NO_EXTRA
},
824 { GL_PIXEL_MAP_A_TO_A_SIZE
, CONTEXT_INT(PixelMaps
.AtoA
.Size
), NO_EXTRA
},
825 { GL_PIXEL_MAP_B_TO_B_SIZE
, CONTEXT_INT(PixelMaps
.BtoB
.Size
), NO_EXTRA
},
826 { GL_PIXEL_MAP_G_TO_G_SIZE
, CONTEXT_INT(PixelMaps
.GtoG
.Size
), NO_EXTRA
},
827 { GL_PIXEL_MAP_I_TO_A_SIZE
, CONTEXT_INT(PixelMaps
.ItoA
.Size
), NO_EXTRA
},
828 { GL_PIXEL_MAP_I_TO_B_SIZE
, CONTEXT_INT(PixelMaps
.ItoB
.Size
), NO_EXTRA
},
829 { GL_PIXEL_MAP_I_TO_G_SIZE
, CONTEXT_INT(PixelMaps
.ItoG
.Size
), NO_EXTRA
},
830 { GL_PIXEL_MAP_I_TO_I_SIZE
, CONTEXT_INT(PixelMaps
.ItoI
.Size
), NO_EXTRA
},
831 { GL_PIXEL_MAP_I_TO_R_SIZE
, CONTEXT_INT(PixelMaps
.ItoR
.Size
), NO_EXTRA
},
832 { GL_PIXEL_MAP_R_TO_R_SIZE
, CONTEXT_INT(PixelMaps
.RtoR
.Size
), NO_EXTRA
},
833 { GL_PIXEL_MAP_S_TO_S_SIZE
, CONTEXT_INT(PixelMaps
.StoS
.Size
), NO_EXTRA
},
834 { GL_POINT_SIZE_GRANULARITY
, CONTEXT_FLOAT(Const
.PointSizeGranularity
), NO_EXTRA
},
835 { GL_POLYGON_MODE
, CONTEXT_ENUM2(Polygon
.FrontMode
), NO_EXTRA
},
836 { GL_POLYGON_OFFSET_BIAS_EXT
, CONTEXT_FLOAT(Polygon
.OffsetUnits
), NO_EXTRA
},
837 { GL_POLYGON_OFFSET_POINT
, CONTEXT_BOOL(Polygon
.OffsetPoint
), NO_EXTRA
},
838 { GL_POLYGON_OFFSET_LINE
, CONTEXT_BOOL(Polygon
.OffsetLine
), NO_EXTRA
},
839 { GL_POLYGON_SMOOTH
, CONTEXT_BOOL(Polygon
.SmoothFlag
), NO_EXTRA
},
840 { GL_POLYGON_SMOOTH_HINT
, CONTEXT_ENUM(Hint
.PolygonSmooth
), NO_EXTRA
},
841 { GL_POLYGON_STIPPLE
, CONTEXT_BOOL(Polygon
.StippleFlag
), NO_EXTRA
},
842 { GL_READ_BUFFER
, LOC_CUSTOM
, TYPE_ENUM
, NO_OFFSET
, NO_EXTRA
},
843 { GL_RED_BIAS
, CONTEXT_FLOAT(Pixel
.RedBias
), NO_EXTRA
},
844 { GL_RED_SCALE
, CONTEXT_FLOAT(Pixel
.RedScale
), NO_EXTRA
},
845 { GL_RENDER_MODE
, CONTEXT_ENUM(RenderMode
), NO_EXTRA
},
846 { GL_RGBA_MODE
, CONST(1), NO_EXTRA
},
847 { GL_SELECTION_BUFFER_SIZE
, CONTEXT_INT(Select
.BufferSize
), NO_EXTRA
},
848 { GL_SHARED_TEXTURE_PALETTE_EXT
, CONTEXT_BOOL(Texture
.SharedPalette
), NO_EXTRA
},
850 { GL_STEREO
, BUFFER_INT(Visual
.stereoMode
), NO_EXTRA
},
852 { GL_TEXTURE_1D
, LOC_CUSTOM
, TYPE_BOOLEAN
, NO_OFFSET
, NO_EXTRA
},
853 { GL_TEXTURE_3D
, LOC_CUSTOM
, TYPE_BOOLEAN
, NO_OFFSET
, NO_EXTRA
},
854 { GL_TEXTURE_1D_ARRAY_EXT
, LOC_CUSTOM
, TYPE_BOOLEAN
, NO_OFFSET
, NO_EXTRA
},
855 { GL_TEXTURE_2D_ARRAY_EXT
, LOC_CUSTOM
, TYPE_BOOLEAN
, NO_OFFSET
, NO_EXTRA
},
857 { GL_TEXTURE_BINDING_1D
, LOC_CUSTOM
, TYPE_INT
, TEXTURE_1D_INDEX
, NO_EXTRA
},
858 { GL_TEXTURE_BINDING_1D_ARRAY
, LOC_CUSTOM
, TYPE_INT
,
859 TEXTURE_1D_ARRAY_INDEX
, extra_MESA_texture_array
},
860 { GL_TEXTURE_BINDING_2D_ARRAY
, LOC_CUSTOM
, TYPE_INT
,
861 TEXTURE_1D_ARRAY_INDEX
, extra_MESA_texture_array
},
862 { GL_MAX_ARRAY_TEXTURE_LAYERS_EXT
,
863 CONTEXT_INT(Const
.MaxArrayTextureLayers
), extra_MESA_texture_array
},
865 { GL_TEXTURE_GEN_S
, LOC_TEXUNIT
, TYPE_BIT_0
,
866 offsetof(struct gl_texture_unit
, TexGenEnabled
), NO_EXTRA
},
867 { GL_TEXTURE_GEN_T
, LOC_TEXUNIT
, TYPE_BIT_1
,
868 offsetof(struct gl_texture_unit
, TexGenEnabled
), NO_EXTRA
},
869 { GL_TEXTURE_GEN_R
, LOC_TEXUNIT
, TYPE_BIT_2
,
870 offsetof(struct gl_texture_unit
, TexGenEnabled
), NO_EXTRA
},
871 { GL_TEXTURE_GEN_Q
, LOC_TEXUNIT
, TYPE_BIT_3
,
872 offsetof(struct gl_texture_unit
, TexGenEnabled
), NO_EXTRA
},
873 { GL_UNPACK_LSB_FIRST
, CONTEXT_BOOL(Unpack
.LsbFirst
), NO_EXTRA
},
874 { GL_UNPACK_ROW_LENGTH
, CONTEXT_INT(Unpack
.RowLength
), NO_EXTRA
},
875 { GL_UNPACK_SKIP_PIXELS
, CONTEXT_INT(Unpack
.SkipPixels
), NO_EXTRA
},
876 { GL_UNPACK_SKIP_ROWS
, CONTEXT_INT(Unpack
.SkipRows
), NO_EXTRA
},
877 { GL_UNPACK_SWAP_BYTES
, CONTEXT_BOOL(Unpack
.SwapBytes
), NO_EXTRA
},
878 { GL_UNPACK_SKIP_IMAGES_EXT
, CONTEXT_INT(Unpack
.SkipImages
), NO_EXTRA
},
879 { GL_UNPACK_IMAGE_HEIGHT_EXT
, CONTEXT_INT(Unpack
.ImageHeight
), NO_EXTRA
},
880 { GL_UNPACK_CLIENT_STORAGE_APPLE
, CONTEXT_BOOL(Unpack
.ClientStorage
), NO_EXTRA
},
881 { GL_ZOOM_X
, CONTEXT_FLOAT(Pixel
.ZoomX
), NO_EXTRA
},
882 { GL_ZOOM_Y
, CONTEXT_FLOAT(Pixel
.ZoomY
), NO_EXTRA
},
885 { GL_VERTEX_ARRAY_COUNT_EXT
, CONST(0), NO_EXTRA
},
886 { GL_NORMAL_ARRAY_COUNT_EXT
, CONST(0), NO_EXTRA
},
887 { GL_COLOR_ARRAY_COUNT_EXT
, CONST(0), NO_EXTRA
},
888 { GL_INDEX_ARRAY
, ARRAY_BOOL(Index
.Enabled
), NO_EXTRA
},
889 { GL_INDEX_ARRAY_TYPE
, ARRAY_ENUM(Index
.Type
), NO_EXTRA
},
890 { GL_INDEX_ARRAY_STRIDE
, ARRAY_INT(Index
.Stride
), NO_EXTRA
},
891 { GL_INDEX_ARRAY_COUNT_EXT
, CONST(0), NO_EXTRA
},
892 { GL_TEXTURE_COORD_ARRAY_COUNT_EXT
, CONST(0), NO_EXTRA
},
893 { GL_EDGE_FLAG_ARRAY
, ARRAY_BOOL(EdgeFlag
.Enabled
), NO_EXTRA
},
894 { GL_EDGE_FLAG_ARRAY_STRIDE
, ARRAY_INT(EdgeFlag
.Stride
), NO_EXTRA
},
895 { GL_EDGE_FLAG_ARRAY_COUNT_EXT
, CONST(0), NO_EXTRA
},
897 /* GL_ARB_texture_compression */
898 { GL_TEXTURE_COMPRESSION_HINT_ARB
, CONTEXT_INT(Hint
.TextureCompression
), NO_EXTRA
},
900 /* GL_EXT_compiled_vertex_array */
901 { GL_ARRAY_ELEMENT_LOCK_FIRST_EXT
, CONTEXT_INT(Array
.LockFirst
),
902 extra_EXT_compiled_vertex_array
},
903 { GL_ARRAY_ELEMENT_LOCK_COUNT_EXT
, CONTEXT_INT(Array
.LockCount
),
904 extra_EXT_compiled_vertex_array
},
906 /* GL_ARB_transpose_matrix */
907 { GL_TRANSPOSE_MODELVIEW_MATRIX_ARB
,
908 CONTEXT_MATRIX_T(ModelviewMatrixStack
), NO_EXTRA
},
909 { GL_TRANSPOSE_PROJECTION_MATRIX_ARB
,
910 CONTEXT_MATRIX_T(ProjectionMatrixStack
.Top
), NO_EXTRA
},
911 { GL_TRANSPOSE_TEXTURE_MATRIX_ARB
, CONTEXT_MATRIX_T(TextureMatrixStack
), NO_EXTRA
},
913 /* GL_SGI_texture_color_table */
914 { GL_TEXTURE_COLOR_TABLE_SGI
, LOC_TEXUNIT
, TYPE_BOOLEAN
,
915 offsetof(struct gl_texture_unit
, ColorTableEnabled
),
916 extra_SGI_texture_color_table
},
918 /* GL_EXT_secondary_color */
919 { GL_COLOR_SUM_EXT
, CONTEXT_BOOL(Fog
.ColorSumEnabled
),
920 extra_EXT_secondary_color_ARB_vertex_program
},
921 { GL_CURRENT_SECONDARY_COLOR_EXT
,
922 CONTEXT_FIELD(Current
.Attrib
[VERT_ATTRIB_COLOR1
][0], TYPE_FLOATN_4
),
923 extra_EXT_secondary_color_flush_current
},
924 { GL_SECONDARY_COLOR_ARRAY_EXT
, ARRAY_BOOL(SecondaryColor
.Enabled
),
925 extra_EXT_secondary_color
},
926 { GL_SECONDARY_COLOR_ARRAY_TYPE_EXT
, ARRAY_ENUM(SecondaryColor
.Type
),
927 extra_EXT_secondary_color
},
928 { GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT
, ARRAY_INT(SecondaryColor
.Stride
),
929 extra_EXT_secondary_color
},
930 { GL_SECONDARY_COLOR_ARRAY_SIZE_EXT
, ARRAY_INT(SecondaryColor
.Size
),
931 extra_EXT_secondary_color
},
933 /* GL_EXT_fog_coord */
934 { GL_CURRENT_FOG_COORDINATE_EXT
,
935 CONTEXT_FLOAT(Current
.Attrib
[VERT_ATTRIB_FOG
][0]),
936 extra_EXT_fog_coord_flush_current
},
937 { GL_FOG_COORDINATE_ARRAY_EXT
, ARRAY_BOOL(FogCoord
.Enabled
),
938 extra_EXT_fog_coord
},
939 { GL_FOG_COORDINATE_ARRAY_TYPE_EXT
, ARRAY_ENUM(FogCoord
.Type
),
940 extra_EXT_fog_coord
},
941 { GL_FOG_COORDINATE_ARRAY_STRIDE_EXT
, ARRAY_INT(FogCoord
.Stride
),
942 extra_EXT_fog_coord
},
943 { GL_FOG_COORDINATE_SOURCE_EXT
, CONTEXT_ENUM(Fog
.FogCoordinateSource
),
944 extra_EXT_fog_coord
},
946 /* GL_IBM_rasterpos_clip */
947 { GL_RASTER_POSITION_UNCLIPPED_IBM
,
948 CONTEXT_BOOL(Transform
.RasterPositionUnclipped
),
949 extra_IBM_rasterpos_clip
},
951 /* GL_NV_point_sprite */
952 { GL_POINT_SPRITE_R_MODE_NV
,
953 CONTEXT_ENUM(Point
.SpriteRMode
), extra_NV_point_sprite
},
954 { GL_POINT_SPRITE_COORD_ORIGIN
, CONTEXT_ENUM(Point
.SpriteOrigin
),
955 extra_NV_point_sprite_ARB_point_sprite
},
957 /* GL_NV_vertex_program */
958 { GL_VERTEX_PROGRAM_BINDING_NV
, LOC_CUSTOM
, TYPE_INT
, 0,
959 extra_NV_vertex_program
},
960 { GL_VERTEX_ATTRIB_ARRAY0_NV
, ARRAY_BOOL(VertexAttrib
[0].Enabled
),
961 extra_NV_vertex_program
},
962 { GL_VERTEX_ATTRIB_ARRAY1_NV
, ARRAY_BOOL(VertexAttrib
[1].Enabled
),
963 extra_NV_vertex_program
},
964 { GL_VERTEX_ATTRIB_ARRAY2_NV
, ARRAY_BOOL(VertexAttrib
[2].Enabled
),
965 extra_NV_vertex_program
},
966 { GL_VERTEX_ATTRIB_ARRAY3_NV
, ARRAY_BOOL(VertexAttrib
[3].Enabled
),
967 extra_NV_vertex_program
},
968 { GL_VERTEX_ATTRIB_ARRAY4_NV
, ARRAY_BOOL(VertexAttrib
[4].Enabled
),
969 extra_NV_vertex_program
},
970 { GL_VERTEX_ATTRIB_ARRAY5_NV
, ARRAY_BOOL(VertexAttrib
[5].Enabled
),
971 extra_NV_vertex_program
},
972 { GL_VERTEX_ATTRIB_ARRAY6_NV
, ARRAY_BOOL(VertexAttrib
[6].Enabled
),
973 extra_NV_vertex_program
},
974 { GL_VERTEX_ATTRIB_ARRAY7_NV
, ARRAY_BOOL(VertexAttrib
[7].Enabled
),
975 extra_NV_vertex_program
},
976 { GL_VERTEX_ATTRIB_ARRAY8_NV
, ARRAY_BOOL(VertexAttrib
[8].Enabled
),
977 extra_NV_vertex_program
},
978 { GL_VERTEX_ATTRIB_ARRAY9_NV
, ARRAY_BOOL(VertexAttrib
[9].Enabled
),
979 extra_NV_vertex_program
},
980 { GL_VERTEX_ATTRIB_ARRAY10_NV
, ARRAY_BOOL(VertexAttrib
[10].Enabled
),
981 extra_NV_vertex_program
},
982 { GL_VERTEX_ATTRIB_ARRAY11_NV
, ARRAY_BOOL(VertexAttrib
[11].Enabled
),
983 extra_NV_vertex_program
},
984 { GL_VERTEX_ATTRIB_ARRAY12_NV
, ARRAY_BOOL(VertexAttrib
[12].Enabled
),
985 extra_NV_vertex_program
},
986 { GL_VERTEX_ATTRIB_ARRAY13_NV
, ARRAY_BOOL(VertexAttrib
[13].Enabled
),
987 extra_NV_vertex_program
},
988 { GL_VERTEX_ATTRIB_ARRAY14_NV
, ARRAY_BOOL(VertexAttrib
[14].Enabled
),
989 extra_NV_vertex_program
},
990 { GL_VERTEX_ATTRIB_ARRAY15_NV
, ARRAY_BOOL(VertexAttrib
[15].Enabled
),
991 extra_NV_vertex_program
},
992 { GL_MAP1_VERTEX_ATTRIB0_4_NV
, CONTEXT_BOOL(Eval
.Map1Attrib
[0]),
993 extra_NV_vertex_program
},
994 { GL_MAP1_VERTEX_ATTRIB1_4_NV
, CONTEXT_BOOL(Eval
.Map1Attrib
[1]),
995 extra_NV_vertex_program
},
996 { GL_MAP1_VERTEX_ATTRIB2_4_NV
, CONTEXT_BOOL(Eval
.Map1Attrib
[2]),
997 extra_NV_vertex_program
},
998 { GL_MAP1_VERTEX_ATTRIB3_4_NV
, CONTEXT_BOOL(Eval
.Map1Attrib
[3]),
999 extra_NV_vertex_program
},
1000 { GL_MAP1_VERTEX_ATTRIB4_4_NV
, CONTEXT_BOOL(Eval
.Map1Attrib
[4]),
1001 extra_NV_vertex_program
},
1002 { GL_MAP1_VERTEX_ATTRIB5_4_NV
, CONTEXT_BOOL(Eval
.Map1Attrib
[5]),
1003 extra_NV_vertex_program
},
1004 { GL_MAP1_VERTEX_ATTRIB6_4_NV
, CONTEXT_BOOL(Eval
.Map1Attrib
[6]),
1005 extra_NV_vertex_program
},
1006 { GL_MAP1_VERTEX_ATTRIB7_4_NV
, CONTEXT_BOOL(Eval
.Map1Attrib
[7]),
1007 extra_NV_vertex_program
},
1008 { GL_MAP1_VERTEX_ATTRIB8_4_NV
, CONTEXT_BOOL(Eval
.Map1Attrib
[8]),
1009 extra_NV_vertex_program
},
1010 { GL_MAP1_VERTEX_ATTRIB9_4_NV
, CONTEXT_BOOL(Eval
.Map1Attrib
[9]),
1011 extra_NV_vertex_program
},
1012 { GL_MAP1_VERTEX_ATTRIB10_4_NV
, CONTEXT_BOOL(Eval
.Map1Attrib
[10]),
1013 extra_NV_vertex_program
},
1014 { GL_MAP1_VERTEX_ATTRIB11_4_NV
, CONTEXT_BOOL(Eval
.Map1Attrib
[11]),
1015 extra_NV_vertex_program
},
1016 { GL_MAP1_VERTEX_ATTRIB12_4_NV
, CONTEXT_BOOL(Eval
.Map1Attrib
[12]),
1017 extra_NV_vertex_program
},
1018 { GL_MAP1_VERTEX_ATTRIB13_4_NV
, CONTEXT_BOOL(Eval
.Map1Attrib
[13]),
1019 extra_NV_vertex_program
},
1020 { GL_MAP1_VERTEX_ATTRIB14_4_NV
, CONTEXT_BOOL(Eval
.Map1Attrib
[14]),
1021 extra_NV_vertex_program
},
1022 { GL_MAP1_VERTEX_ATTRIB15_4_NV
, CONTEXT_BOOL(Eval
.Map1Attrib
[15]),
1023 extra_NV_vertex_program
},
1025 /* GL_NV_fragment_program */
1026 { GL_FRAGMENT_PROGRAM_NV
, CONTEXT_BOOL(FragmentProgram
.Enabled
),
1027 extra_NV_fragment_program
},
1028 { GL_FRAGMENT_PROGRAM_BINDING_NV
, LOC_CUSTOM
, TYPE_INT
, 0,
1029 extra_NV_fragment_program
},
1030 { GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV
,
1031 CONST(MAX_NV_FRAGMENT_PROGRAM_PARAMS
),
1032 extra_NV_fragment_program
},
1034 /* GL_NV_texture_rectangle */
1035 { GL_TEXTURE_RECTANGLE_NV
,
1036 LOC_CUSTOM
, TYPE_BOOLEAN
, 0, extra_NV_texture_rectangle
},
1037 { GL_TEXTURE_BINDING_RECTANGLE_NV
,
1038 LOC_CUSTOM
, TYPE_INT
, TEXTURE_RECT_INDEX
, extra_NV_texture_rectangle
},
1039 { GL_MAX_RECTANGLE_TEXTURE_SIZE_NV
,
1040 CONTEXT_INT(Const
.MaxTextureRectSize
), extra_NV_texture_rectangle
},
1042 /* GL_EXT_stencil_two_side */
1043 { GL_STENCIL_TEST_TWO_SIDE_EXT
, CONTEXT_BOOL(Stencil
.TestTwoSide
),
1044 extra_EXT_stencil_two_side
},
1045 { GL_ACTIVE_STENCIL_FACE_EXT
, LOC_CUSTOM
, TYPE_ENUM
, NO_OFFSET
, NO_EXTRA
},
1047 /* GL_NV_light_max_exponent */
1048 { GL_MAX_SHININESS_NV
, CONTEXT_FLOAT(Const
.MaxShininess
),
1049 extra_NV_light_max_exponent
},
1050 { GL_MAX_SPOT_EXPONENT_NV
, CONTEXT_FLOAT(Const
.MaxSpotExponent
),
1051 extra_NV_light_max_exponent
},
1053 /* GL_NV_primitive_restart */
1054 { GL_PRIMITIVE_RESTART_NV
, CONTEXT_BOOL(Array
.PrimitiveRestart
),
1055 extra_NV_primitive_restart
},
1056 { GL_PRIMITIVE_RESTART_INDEX_NV
, CONTEXT_INT(Array
.RestartIndex
),
1057 extra_NV_primitive_restart
},
1059 /* GL_ARB_vertex_buffer_object */
1060 { GL_INDEX_ARRAY_BUFFER_BINDING_ARB
, LOC_CUSTOM
, TYPE_INT
,
1061 offsetof(struct gl_array_object
, Index
.BufferObj
), NO_EXTRA
},
1062 { GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB
, LOC_CUSTOM
, TYPE_INT
,
1063 offsetof(struct gl_array_object
, EdgeFlag
.BufferObj
), NO_EXTRA
},
1064 { GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB
, LOC_CUSTOM
, TYPE_INT
,
1065 offsetof(struct gl_array_object
, SecondaryColor
.BufferObj
), NO_EXTRA
},
1066 { GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB
, LOC_CUSTOM
, TYPE_INT
,
1067 offsetof(struct gl_array_object
, FogCoord
.BufferObj
), NO_EXTRA
},
1069 /* GL_EXT_pixel_buffer_object */
1070 { GL_PIXEL_PACK_BUFFER_BINDING_EXT
, LOC_CUSTOM
, TYPE_INT
, 0,
1071 extra_EXT_pixel_buffer_object
},
1072 { GL_PIXEL_UNPACK_BUFFER_BINDING_EXT
, LOC_CUSTOM
, TYPE_INT
, 0,
1073 extra_EXT_pixel_buffer_object
},
1075 /* GL_ARB_vertex_program */
1076 { GL_VERTEX_PROGRAM_ARB
, /* == GL_VERTEX_PROGRAM_NV */
1077 CONTEXT_BOOL(VertexProgram
.Enabled
),
1078 extra_ARB_vertex_program_NV_vertex_program
},
1079 { GL_VERTEX_PROGRAM_POINT_SIZE_ARB
, /* == GL_VERTEX_PROGRAM_POINT_SIZE_NV*/
1080 CONTEXT_BOOL(VertexProgram
.PointSizeEnabled
),
1081 extra_ARB_vertex_program_NV_vertex_program
},
1082 { GL_VERTEX_PROGRAM_TWO_SIDE_ARB
, /* == GL_VERTEX_PROGRAM_TWO_SIDE_NV */
1083 CONTEXT_BOOL(VertexProgram
.TwoSideEnabled
),
1084 extra_ARB_vertex_program_NV_vertex_program
},
1085 { GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB
, /* == GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV */
1086 CONTEXT_INT(Const
.MaxProgramMatrixStackDepth
),
1087 extra_ARB_vertex_program_ARB_fragment_program_NV_vertex_program
},
1088 { GL_MAX_PROGRAM_MATRICES_ARB
, /* == GL_MAX_TRACK_MATRICES_NV */
1089 CONTEXT_INT(Const
.MaxProgramMatrices
),
1090 extra_ARB_vertex_program_ARB_fragment_program_NV_vertex_program
},
1091 { GL_CURRENT_MATRIX_STACK_DEPTH_ARB
, /* == GL_CURRENT_MATRIX_STACK_DEPTH_NV */
1092 LOC_CUSTOM
, TYPE_INT
, 0,
1093 extra_ARB_vertex_program_ARB_fragment_program_NV_vertex_program
},
1095 { GL_CURRENT_MATRIX_ARB
, /* == GL_CURRENT_MATRIX_NV */
1096 LOC_CUSTOM
, TYPE_MATRIX
, 0,
1097 extra_ARB_vertex_program_ARB_fragment_program_NV_vertex_program
},
1098 { GL_TRANSPOSE_CURRENT_MATRIX_ARB
, /* == GL_CURRENT_MATRIX_NV */
1099 LOC_CUSTOM
, TYPE_MATRIX
, 0,
1100 extra_ARB_vertex_program_ARB_fragment_program
},
1102 { GL_PROGRAM_ERROR_POSITION_ARB
, /* == GL_PROGRAM_ERROR_POSITION_NV */
1103 CONTEXT_INT(Program
.ErrorPos
),
1104 extra_NV_vertex_program_ARB_vertex_program_ARB_fragment_program_NV_vertex_program
},
1106 /* GL_ARB_fragment_program */
1107 { GL_FRAGMENT_PROGRAM_ARB
, CONTEXT_BOOL(FragmentProgram
.Enabled
),
1108 extra_ARB_fragment_program
},
1110 /* GL_EXT_depth_bounds_test */
1111 { GL_DEPTH_BOUNDS_TEST_EXT
, CONTEXT_BOOL(Depth
.BoundsTest
),
1112 extra_EXT_depth_bounds_test
},
1113 { GL_DEPTH_BOUNDS_EXT
, CONTEXT_FLOAT2(Depth
.BoundsMin
),
1114 extra_EXT_depth_bounds_test
},
1116 /* GL_ARB_depth_clamp*/
1117 { GL_DEPTH_CLAMP
, CONTEXT_BOOL(Transform
.DepthClamp
),
1118 extra_ARB_depth_clamp
},
1120 /* GL_ARB_draw_buffers */
1121 { GL_DRAW_BUFFER0_ARB
, BUFFER_ENUM(ColorDrawBuffer
[0]), NO_EXTRA
},
1122 { GL_DRAW_BUFFER1_ARB
, BUFFER_ENUM(ColorDrawBuffer
[1]),
1123 extra_valid_draw_buffer
},
1124 { GL_DRAW_BUFFER2_ARB
, BUFFER_ENUM(ColorDrawBuffer
[2]),
1125 extra_valid_draw_buffer
},
1126 { GL_DRAW_BUFFER3_ARB
, BUFFER_ENUM(ColorDrawBuffer
[3]),
1127 extra_valid_draw_buffer
},
1128 { GL_DRAW_BUFFER4_ARB
, BUFFER_ENUM(ColorDrawBuffer
[4]),
1129 extra_valid_draw_buffer
},
1130 { GL_DRAW_BUFFER5_ARB
, BUFFER_ENUM(ColorDrawBuffer
[5]),
1131 extra_valid_draw_buffer
},
1132 { GL_DRAW_BUFFER6_ARB
, BUFFER_ENUM(ColorDrawBuffer
[6]),
1133 extra_valid_draw_buffer
},
1134 { GL_DRAW_BUFFER7_ARB
, BUFFER_ENUM(ColorDrawBuffer
[7]),
1135 extra_valid_draw_buffer
},
1137 /* GL_ATI_fragment_shader */
1138 { GL_NUM_FRAGMENT_REGISTERS_ATI
, CONST(6), extra_ATI_fragment_shader
},
1139 { GL_NUM_FRAGMENT_CONSTANTS_ATI
, CONST(8), extra_ATI_fragment_shader
},
1140 { GL_NUM_PASSES_ATI
, CONST(2), extra_ATI_fragment_shader
},
1141 { GL_NUM_INSTRUCTIONS_PER_PASS_ATI
, CONST(8), extra_ATI_fragment_shader
},
1142 { GL_NUM_INSTRUCTIONS_TOTAL_ATI
, CONST(16), extra_ATI_fragment_shader
},
1143 { GL_COLOR_ALPHA_PAIRING_ATI
, CONST(GL_TRUE
), extra_ATI_fragment_shader
},
1144 { GL_NUM_LOOPBACK_COMPONENTS_ATI
, CONST(3), extra_ATI_fragment_shader
},
1145 { GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI
,
1146 CONST(3), extra_ATI_fragment_shader
},
1148 /* GL_EXT_framebuffer_object */
1149 { GL_MAX_COLOR_ATTACHMENTS_EXT
, CONTEXT_INT(Const
.MaxColorAttachments
),
1150 extra_EXT_framebuffer_object
},
1152 /* GL_EXT_framebuffer_blit
1153 * NOTE: GL_DRAW_FRAMEBUFFER_BINDING_EXT == GL_FRAMEBUFFER_BINDING_EXT */
1154 { GL_READ_FRAMEBUFFER_BINDING_EXT
, LOC_CUSTOM
, TYPE_INT
, 0,
1155 extra_EXT_framebuffer_blit
},
1157 /* GL_EXT_provoking_vertex */
1158 { GL_PROVOKING_VERTEX_EXT
,
1159 CONTEXT_BOOL(Light
.ProvokingVertex
), extra_EXT_provoking_vertex
},
1160 { GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT
,
1161 CONTEXT_BOOL(Const
.QuadsFollowProvokingVertexConvention
),
1162 extra_EXT_provoking_vertex
},
1164 /* GL_ARB_framebuffer_object */
1165 { GL_MAX_SAMPLES
, CONTEXT_INT(Const
.MaxSamples
),
1166 extra_ARB_framebuffer_object_EXT_framebuffer_multisample
},
1168 /* GL_APPLE_vertex_array_object */
1169 { GL_VERTEX_ARRAY_BINDING_APPLE
, ARRAY_INT(Name
),
1170 extra_APPLE_vertex_array_object
},
1172 /* GL_ARB_seamless_cube_map */
1173 { GL_TEXTURE_CUBE_MAP_SEAMLESS
,
1174 CONTEXT_BOOL(Texture
.CubeMapSeamless
), extra_ARB_seamless_cube_map
},
1177 { GL_MAX_SERVER_WAIT_TIMEOUT
,
1178 CONTEXT_INT64(Const
.MaxServerWaitTimeout
), extra_ARB_sync
},
1180 /* GL_EXT_texture_integer */
1181 { GL_RGBA_INTEGER_MODE_EXT
, BUFFER_BOOL(_IntegerColor
),
1182 extra_EXT_texture_integer
},
1184 /* GL_EXT_transform_feedback */
1185 { GL_TRANSFORM_FEEDBACK_BUFFER_BINDING
, LOC_CUSTOM
, TYPE_INT
, 0,
1186 extra_EXT_transform_feedback
},
1187 { GL_RASTERIZER_DISCARD
, CONTEXT_BOOL(TransformFeedback
.RasterDiscard
),
1188 extra_EXT_transform_feedback
},
1189 { GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS
,
1190 CONTEXT_INT(Const
.MaxTransformFeedbackInterleavedComponents
),
1191 extra_EXT_transform_feedback
},
1192 { GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS
,
1193 CONTEXT_INT(Const
.MaxTransformFeedbackSeparateAttribs
),
1194 extra_EXT_transform_feedback
},
1195 { GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS
,
1196 CONTEXT_INT(Const
.MaxTransformFeedbackSeparateComponents
),
1197 extra_EXT_transform_feedback
},
1199 /* GL_ARB_transform_feedback2 */
1200 { GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED
, LOC_CUSTOM
, TYPE_BOOLEAN
, 0,
1201 extra_ARB_transform_feedback2
},
1202 { GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE
, LOC_CUSTOM
, TYPE_BOOLEAN
, 0,
1203 extra_ARB_transform_feedback2
},
1204 { GL_TRANSFORM_FEEDBACK_BINDING
, LOC_CUSTOM
, TYPE_INT
, 0,
1205 extra_ARB_transform_feedback2
},
1207 /* GL_ARB_geometry_shader4 */
1208 { GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB
,
1209 CONTEXT_INT(Const
.GeometryProgram
.MaxGeometryTextureImageUnits
),
1210 extra_ARB_geometry_shader4
},
1211 { GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB
,
1212 CONTEXT_INT(Const
.GeometryProgram
.MaxGeometryOutputVertices
),
1213 extra_ARB_geometry_shader4
},
1214 { GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB
,
1215 CONTEXT_INT(Const
.GeometryProgram
.MaxGeometryTotalOutputComponents
),
1216 extra_ARB_geometry_shader4
},
1217 { GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB
,
1218 CONTEXT_INT(Const
.GeometryProgram
.MaxGeometryUniformComponents
),
1219 extra_ARB_geometry_shader4
},
1220 { GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB
,
1221 CONTEXT_INT(Const
.GeometryProgram
.MaxGeometryVaryingComponents
),
1222 extra_ARB_geometry_shader4
},
1223 { GL_MAX_VERTEX_VARYING_COMPONENTS_ARB
,
1224 CONTEXT_INT(Const
.GeometryProgram
.MaxVertexVaryingComponents
),
1225 extra_ARB_geometry_shader4
},
1227 /* GL_EXT_gpu_shader4 / GL 3.0 */
1228 { GL_MIN_PROGRAM_TEXEL_OFFSET
,
1229 CONTEXT_INT(Const
.MinProgramTexelOffset
),
1230 extra_EXT_gpu_shader4
},
1231 { GL_MAX_PROGRAM_TEXEL_OFFSET
,
1232 CONTEXT_INT(Const
.MaxProgramTexelOffset
),
1233 extra_EXT_gpu_shader4
},
1236 { GL_NUM_EXTENSIONS
, LOC_CUSTOM
, TYPE_INT
, 0, extra_version_30
},
1237 { GL_MAJOR_VERSION
, CONTEXT_INT(VersionMajor
), extra_version_30
},
1238 { GL_MINOR_VERSION
, CONTEXT_INT(VersionMinor
), extra_version_30
},
1239 { GL_CONTEXT_FLAGS
, CONTEXT_INT(Const
.ContextFlags
), extra_version_30
},
1242 /* NOTE: different enum values for GL_PRIMITIVE_RESTART_NV
1243 * vs. GL_PRIMITIVE_RESTART!
1245 { GL_PRIMITIVE_RESTART
, CONTEXT_BOOL(Array
.PrimitiveRestart
),
1247 { GL_PRIMITIVE_RESTART_INDEX
, CONTEXT_INT(Array
.RestartIndex
),
1252 { GL_CONTEXT_PROFILE_MASK
, CONTEXT_INT(Const
.ProfileMask
),
1254 #endif /* FEATURE_GL */
1257 /* All we need now is a way to look up the value struct from the enum.
1258 * The code generated by gcc for the old generated big switch
1259 * statement is a big, balanced, open coded if/else tree, essentially
1260 * an unrolled binary search. It would be natural to sort the new
1261 * enum table and use bsearch(), but we will use a read-only hash
1262 * table instead. bsearch() has a nice guaranteed worst case
1263 * performance, but we're also guaranteed to hit that worst case
1264 * (log2(n) iterations) for about half the enums. Instead, using an
1265 * open addressing hash table, we can find the enum on the first try
1266 * for 80% of the enums, 1 collision for 10% and never more than 5
1267 * collisions for any enum (typical numbers). And the code is very
1268 * simple, even though it feels a little magic. */
1270 static unsigned short table
[1024];
1271 static const int prime_factor
= 89, prime_step
= 281;
1275 print_table_stats(void)
1277 int i
, j
, collisions
[11], count
, hash
, mask
;
1278 const struct value_desc
*d
;
1281 mask
= Elements(table
) - 1;
1282 memset(collisions
, 0, sizeof collisions
);
1284 for (i
= 0; i
< Elements(table
); i
++) {
1288 d
= &values
[table
[i
]];
1289 hash
= (d
->pname
* prime_factor
);
1292 if (values
[table
[hash
& mask
]].pname
== d
->pname
)
1304 printf("number of enums: %d (total %d)\n", count
, Elements(values
));
1305 for (i
= 0; i
< Elements(collisions
) - 1; i
++)
1306 if (collisions
[i
] > 0)
1307 printf(" %d enums with %d %scollisions\n",
1308 collisions
[i
], i
, i
== 10 ? "or more " : "");
1313 * Initialize the enum hash for a given API
1315 * This is called from one_time_init() to insert the enum values that
1316 * are valid for the API in question into the enum hash table.
1318 * \param the current context, for determining the API in question
1320 void _mesa_init_get_hash(struct gl_context
*ctx
)
1322 int i
, hash
, index
, mask
;
1323 int api_mask
= 0, api_bit
;
1325 mask
= Elements(table
) - 1;
1326 api_bit
= 1 << ctx
->API
;
1328 for (i
= 0; i
< Elements(values
); i
++) {
1329 if (values
[i
].type
== TYPE_API_MASK
) {
1330 api_mask
= values
[i
].offset
;
1333 if (!(api_mask
& api_bit
))
1336 hash
= (values
[i
].pname
* prime_factor
) & mask
;
1338 index
= hash
& mask
;
1339 if (!table
[index
]) {
1348 print_table_stats();
1353 * Handle irregular enums
1355 * Some values don't conform to the "well-known type at context
1356 * pointer + offset" pattern, so we have this function to catch all
1357 * the corner cases. Typically, it's a computed value or a one-off
1358 * pointer to a custom struct or something.
1360 * In this case we can't return a pointer to the value, so we'll have
1361 * to use the temporary variable 'v' declared back in the calling
1362 * glGet*v() function to store the result.
1364 * \param ctx the current context
1365 * \param d the struct value_desc that describes the enum
1366 * \param v pointer to the tmp declared in the calling glGet*v() function
1369 find_custom_value(struct gl_context
*ctx
, const struct value_desc
*d
, union value
*v
)
1371 struct gl_buffer_object
*buffer_obj
;
1372 struct gl_client_array
*array
;
1379 case GL_TEXTURE_1D_ARRAY_EXT
:
1380 case GL_TEXTURE_2D_ARRAY_EXT
:
1381 case GL_TEXTURE_CUBE_MAP_ARB
:
1382 case GL_TEXTURE_RECTANGLE_NV
:
1383 v
->value_bool
= _mesa_IsEnabled(d
->pname
);
1386 case GL_LINE_STIPPLE_PATTERN
:
1387 /* This is the only GLushort, special case it here by promoting
1388 * to an int rather than introducing a new type. */
1389 v
->value_int
= ctx
->Line
.StipplePattern
;
1392 case GL_CURRENT_RASTER_TEXTURE_COORDS
:
1393 unit
= ctx
->Texture
.CurrentUnit
;
1394 v
->value_float_4
[0] = ctx
->Current
.RasterTexCoords
[unit
][0];
1395 v
->value_float_4
[1] = ctx
->Current
.RasterTexCoords
[unit
][1];
1396 v
->value_float_4
[2] = ctx
->Current
.RasterTexCoords
[unit
][2];
1397 v
->value_float_4
[3] = ctx
->Current
.RasterTexCoords
[unit
][3];
1400 case GL_CURRENT_TEXTURE_COORDS
:
1401 unit
= ctx
->Texture
.CurrentUnit
;
1402 v
->value_float_4
[0] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
][0];
1403 v
->value_float_4
[1] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
][1];
1404 v
->value_float_4
[2] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
][2];
1405 v
->value_float_4
[3] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
][3];
1408 case GL_COLOR_WRITEMASK
:
1409 v
->value_int_4
[0] = ctx
->Color
.ColorMask
[0][RCOMP
] ? 1 : 0;
1410 v
->value_int_4
[1] = ctx
->Color
.ColorMask
[0][GCOMP
] ? 1 : 0;
1411 v
->value_int_4
[2] = ctx
->Color
.ColorMask
[0][BCOMP
] ? 1 : 0;
1412 v
->value_int_4
[3] = ctx
->Color
.ColorMask
[0][ACOMP
] ? 1 : 0;
1416 v
->value_bool
= ctx
->Current
.Attrib
[VERT_ATTRIB_EDGEFLAG
][0] == 1.0;
1419 case GL_READ_BUFFER
:
1420 v
->value_enum
= ctx
->ReadBuffer
->ColorReadBuffer
;
1423 case GL_MAP2_GRID_DOMAIN
:
1424 v
->value_float_4
[0] = ctx
->Eval
.MapGrid2u1
;
1425 v
->value_float_4
[1] = ctx
->Eval
.MapGrid2u2
;
1426 v
->value_float_4
[2] = ctx
->Eval
.MapGrid2v1
;
1427 v
->value_float_4
[3] = ctx
->Eval
.MapGrid2v2
;
1430 case GL_TEXTURE_STACK_DEPTH
:
1431 unit
= ctx
->Texture
.CurrentUnit
;
1432 v
->value_int
= ctx
->TextureMatrixStack
[unit
].Depth
+ 1;
1434 case GL_TEXTURE_MATRIX
:
1435 unit
= ctx
->Texture
.CurrentUnit
;
1436 v
->value_matrix
= ctx
->TextureMatrixStack
[unit
].Top
;
1439 case GL_TEXTURE_COORD_ARRAY
:
1440 case GL_TEXTURE_COORD_ARRAY_SIZE
:
1441 case GL_TEXTURE_COORD_ARRAY_TYPE
:
1442 case GL_TEXTURE_COORD_ARRAY_STRIDE
:
1443 array
= &ctx
->Array
.ArrayObj
->TexCoord
[ctx
->Array
.ActiveTexture
];
1444 v
->value_int
= *(GLuint
*) ((char *) array
+ d
->offset
);
1447 case GL_ACTIVE_TEXTURE_ARB
:
1448 v
->value_int
= GL_TEXTURE0_ARB
+ ctx
->Texture
.CurrentUnit
;
1450 case GL_CLIENT_ACTIVE_TEXTURE_ARB
:
1451 v
->value_int
= GL_TEXTURE0_ARB
+ ctx
->Array
.ActiveTexture
;
1454 case GL_MODELVIEW_STACK_DEPTH
:
1455 case GL_PROJECTION_STACK_DEPTH
:
1456 v
->value_int
= *(GLint
*) ((char *) ctx
+ d
->offset
) + 1;
1459 case GL_MAX_TEXTURE_SIZE
:
1460 case GL_MAX_3D_TEXTURE_SIZE
:
1461 case GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB
:
1462 p
= (GLuint
*) ((char *) ctx
+ d
->offset
);
1463 v
->value_int
= 1 << (*p
- 1);
1466 case GL_SCISSOR_BOX
:
1467 v
->value_int_4
[0] = ctx
->Scissor
.X
;
1468 v
->value_int_4
[1] = ctx
->Scissor
.Y
;
1469 v
->value_int_4
[2] = ctx
->Scissor
.Width
;
1470 v
->value_int_4
[3] = ctx
->Scissor
.Height
;
1475 ctx
->ListState
.CurrentList
? ctx
->ListState
.CurrentList
->Name
: 0;
1478 if (!ctx
->CompileFlag
)
1480 else if (ctx
->ExecuteFlag
)
1481 v
->value_enum
= GL_COMPILE_AND_EXECUTE
;
1483 v
->value_enum
= GL_COMPILE
;
1487 v
->value_int_4
[0] = ctx
->Viewport
.X
;
1488 v
->value_int_4
[1] = ctx
->Viewport
.Y
;
1489 v
->value_int_4
[2] = ctx
->Viewport
.Width
;
1490 v
->value_int_4
[3] = ctx
->Viewport
.Height
;
1493 case GL_ACTIVE_STENCIL_FACE_EXT
:
1494 v
->value_enum
= ctx
->Stencil
.ActiveFace
? GL_BACK
: GL_FRONT
;
1497 case GL_STENCIL_FAIL
:
1498 v
->value_enum
= ctx
->Stencil
.FailFunc
[ctx
->Stencil
.ActiveFace
];
1500 case GL_STENCIL_FUNC
:
1501 v
->value_enum
= ctx
->Stencil
.Function
[ctx
->Stencil
.ActiveFace
];
1503 case GL_STENCIL_PASS_DEPTH_FAIL
:
1504 v
->value_enum
= ctx
->Stencil
.ZFailFunc
[ctx
->Stencil
.ActiveFace
];
1506 case GL_STENCIL_PASS_DEPTH_PASS
:
1507 v
->value_enum
= ctx
->Stencil
.ZPassFunc
[ctx
->Stencil
.ActiveFace
];
1509 case GL_STENCIL_REF
:
1510 v
->value_int
= ctx
->Stencil
.Ref
[ctx
->Stencil
.ActiveFace
];
1512 case GL_STENCIL_VALUE_MASK
:
1513 v
->value_int
= ctx
->Stencil
.ValueMask
[ctx
->Stencil
.ActiveFace
];
1515 case GL_STENCIL_WRITEMASK
:
1516 v
->value_int
= ctx
->Stencil
.WriteMask
[ctx
->Stencil
.ActiveFace
];
1519 case GL_NUM_EXTENSIONS
:
1520 v
->value_int
= _mesa_get_extension_count(ctx
);
1523 case GL_IMPLEMENTATION_COLOR_READ_TYPE_OES
:
1524 v
->value_int
= _mesa_get_color_read_type(ctx
);
1526 case GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES
:
1527 v
->value_int
= _mesa_get_color_read_format(ctx
);
1530 case GL_CURRENT_MATRIX_STACK_DEPTH_ARB
:
1531 v
->value_int
= ctx
->CurrentStack
->Depth
+ 1;
1533 case GL_CURRENT_MATRIX_ARB
:
1534 case GL_TRANSPOSE_CURRENT_MATRIX_ARB
:
1535 v
->value_matrix
= ctx
->CurrentStack
->Top
;
1538 case GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB
:
1539 v
->value_int
= _mesa_get_compressed_formats(ctx
, NULL
, GL_FALSE
);
1541 case GL_COMPRESSED_TEXTURE_FORMATS_ARB
:
1543 _mesa_get_compressed_formats(ctx
, v
->value_int_n
.ints
, GL_FALSE
);
1544 ASSERT(v
->value_int_n
.n
<= 100);
1547 case GL_MAX_VARYING_FLOATS_ARB
:
1548 v
->value_int
= ctx
->Const
.MaxVarying
* 4;
1551 /* Various object names */
1553 case GL_TEXTURE_BINDING_1D
:
1554 case GL_TEXTURE_BINDING_2D
:
1555 case GL_TEXTURE_BINDING_3D
:
1556 case GL_TEXTURE_BINDING_1D_ARRAY_EXT
:
1557 case GL_TEXTURE_BINDING_2D_ARRAY_EXT
:
1558 case GL_TEXTURE_BINDING_CUBE_MAP_ARB
:
1559 case GL_TEXTURE_BINDING_RECTANGLE_NV
:
1560 unit
= ctx
->Texture
.CurrentUnit
;
1562 ctx
->Texture
.Unit
[unit
].CurrentTex
[d
->offset
]->Name
;
1565 /* GL_ARB_vertex_buffer_object */
1566 case GL_VERTEX_ARRAY_BUFFER_BINDING_ARB
:
1567 case GL_NORMAL_ARRAY_BUFFER_BINDING_ARB
:
1568 case GL_COLOR_ARRAY_BUFFER_BINDING_ARB
:
1569 case GL_INDEX_ARRAY_BUFFER_BINDING_ARB
:
1570 case GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB
:
1571 case GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB
:
1572 case GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB
:
1573 buffer_obj
= (struct gl_buffer_object
*)
1574 ((char *) ctx
->Array
.ArrayObj
+ d
->offset
);
1575 v
->value_int
= buffer_obj
->Name
;
1577 case GL_ARRAY_BUFFER_BINDING_ARB
:
1578 v
->value_int
= ctx
->Array
.ArrayBufferObj
->Name
;
1580 case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB
:
1582 ctx
->Array
.ArrayObj
->TexCoord
[ctx
->Array
.ActiveTexture
].BufferObj
->Name
;
1584 case GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB
:
1585 v
->value_int
= ctx
->Array
.ElementArrayBufferObj
->Name
;
1588 /* ARB_copy_buffer */
1589 case GL_COPY_READ_BUFFER
:
1590 v
->value_int
= ctx
->CopyReadBuffer
->Name
;
1592 case GL_COPY_WRITE_BUFFER
:
1593 v
->value_int
= ctx
->CopyWriteBuffer
->Name
;
1596 case GL_FRAGMENT_PROGRAM_BINDING_NV
:
1598 ctx
->FragmentProgram
.Current
? ctx
->FragmentProgram
.Current
->Base
.Id
: 0;
1600 case GL_VERTEX_PROGRAM_BINDING_NV
:
1602 ctx
->VertexProgram
.Current
? ctx
->VertexProgram
.Current
->Base
.Id
: 0;
1604 case GL_PIXEL_PACK_BUFFER_BINDING_EXT
:
1605 v
->value_int
= ctx
->Pack
.BufferObj
->Name
;
1607 case GL_PIXEL_UNPACK_BUFFER_BINDING_EXT
:
1608 v
->value_int
= ctx
->Unpack
.BufferObj
->Name
;
1610 case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING
:
1611 v
->value_int
= ctx
->TransformFeedback
.CurrentBuffer
->Name
;
1613 case GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED
:
1614 v
->value_int
= ctx
->TransformFeedback
.CurrentObject
->Paused
;
1616 case GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE
:
1617 v
->value_int
= ctx
->TransformFeedback
.CurrentObject
->Active
;
1619 case GL_TRANSFORM_FEEDBACK_BINDING
:
1620 v
->value_int
= ctx
->TransformFeedback
.CurrentObject
->Name
;
1622 case GL_CURRENT_PROGRAM
:
1624 ctx
->Shader
.ActiveProgram
? ctx
->Shader
.ActiveProgram
->Name
: 0;
1626 case GL_READ_FRAMEBUFFER_BINDING_EXT
:
1627 v
->value_int
= ctx
->ReadBuffer
->Name
;
1629 case GL_RENDERBUFFER_BINDING_EXT
:
1631 ctx
->CurrentRenderbuffer
? ctx
->CurrentRenderbuffer
->Name
: 0;
1633 case GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES
:
1634 v
->value_int
= ctx
->Array
.ArrayObj
->PointSize
.BufferObj
->Name
;
1637 case GL_MAX_VERTEX_UNIFORM_VECTORS
:
1638 v
->value_int
= ctx
->Const
.VertexProgram
.MaxUniformComponents
/ 4;
1641 case GL_MAX_FRAGMENT_UNIFORM_VECTORS
:
1642 v
->value_int
= ctx
->Const
.FragmentProgram
.MaxUniformComponents
/ 4;
1648 * Check extra constraints on a struct value_desc descriptor
1650 * If a struct value_desc has a non-NULL extra pointer, it means that
1651 * there are a number of extra constraints to check or actions to
1652 * perform. The extras is just an integer array where each integer
1653 * encode different constraints or actions.
1655 * \param ctx current context
1656 * \param func name of calling glGet*v() function for error reporting
1657 * \param d the struct value_desc that has the extra constraints
1659 * \return GL_FALSE if one of the constraints was not satisfied,
1660 * otherwise GL_TRUE.
1663 check_extra(struct gl_context
*ctx
, const char *func
, const struct value_desc
*d
)
1665 const GLuint version
= ctx
->VersionMajor
* 10 + ctx
->VersionMinor
;
1671 for (e
= d
->extra
; *e
!= EXTRA_END
; e
++)
1673 case EXTRA_VERSION_30
:
1674 if (version
>= 30) {
1679 case EXTRA_VERSION_31
:
1680 if (version
>= 31) {
1685 case EXTRA_VERSION_32
:
1686 if (version
>= 32) {
1691 case EXTRA_VERSION_ES2
:
1692 if (ctx
->API
== API_OPENGLES2
) {
1697 case EXTRA_NEW_BUFFERS
:
1698 if (ctx
->NewState
& _NEW_BUFFERS
)
1699 _mesa_update_state(ctx
);
1701 case EXTRA_FLUSH_CURRENT
:
1702 FLUSH_CURRENT(ctx
, 0);
1704 case EXTRA_VALID_DRAW_BUFFER
:
1705 if (d
->pname
- GL_DRAW_BUFFER0_ARB
>= ctx
->Const
.MaxDrawBuffers
) {
1706 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(draw buffer %u)",
1707 func
, d
->pname
- GL_DRAW_BUFFER0_ARB
);
1711 case EXTRA_VALID_TEXTURE_UNIT
:
1712 if (ctx
->Texture
.CurrentUnit
>= ctx
->Const
.MaxTextureCoordUnits
) {
1713 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(texture %u)",
1714 func
, ctx
->Texture
.CurrentUnit
);
1720 default: /* *e is a offset into the extension struct */
1722 if (*(GLboolean
*) ((char *) &ctx
->Extensions
+ *e
))
1727 if (total
> 0 && enabled
== 0) {
1728 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(pname=%s)", func
,
1729 _mesa_lookup_enum_by_nr(d
->pname
));
1736 static const struct value_desc error_value
=
1737 { 0, 0, TYPE_INVALID
, NO_OFFSET
, NO_EXTRA
};
1740 * Find the struct value_desc corresponding to the enum 'pname'.
1742 * We hash the enum value to get an index into the 'table' array,
1743 * which holds the index in the 'values' array of struct value_desc.
1744 * Once we've found the entry, we do the extra checks, if any, then
1745 * look up the value and return a pointer to it.
1747 * If the value has to be computed (for example, it's the result of a
1748 * function call or we need to add 1 to it), we use the tmp 'v' to
1751 * \param func name of glGet*v() func for error reporting
1752 * \param pname the enum value we're looking up
1753 * \param p is were we return the pointer to the value
1754 * \param v a tmp union value variable in the calling glGet*v() function
1756 * \return the struct value_desc corresponding to the enum or a struct
1757 * value_desc of TYPE_INVALID if not found. This lets the calling
1758 * glGet*v() function jump right into a switch statement and
1759 * handle errors there instead of having to check for NULL.
1761 static const struct value_desc
*
1762 find_value(const char *func
, GLenum pname
, void **p
, union value
*v
)
1764 GET_CURRENT_CONTEXT(ctx
);
1765 struct gl_texture_unit
*unit
;
1767 const struct value_desc
*d
;
1769 mask
= Elements(table
) - 1;
1770 hash
= (pname
* prime_factor
);
1772 d
= &values
[table
[hash
& mask
]];
1774 /* If the enum isn't valid, the hash walk ends with index 0,
1775 * which is the API mask entry at the beginning of values[]. */
1776 if (unlikely(d
->type
== TYPE_API_MASK
)) {
1777 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(pname=%s)", func
,
1778 _mesa_lookup_enum_by_nr(pname
));
1779 return &error_value
;
1782 if (likely(d
->pname
== pname
))
1788 if (unlikely(d
->extra
&& !check_extra(ctx
, func
, d
)))
1789 return &error_value
;
1791 switch (d
->location
) {
1793 *p
= ((char *) ctx
->DrawBuffer
+ d
->offset
);
1796 *p
= ((char *) ctx
+ d
->offset
);
1799 *p
= ((char *) ctx
->Array
.ArrayObj
+ d
->offset
);
1802 unit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1803 *p
= ((char *) unit
+ d
->offset
);
1806 find_custom_value(ctx
, d
, v
);
1814 /* silence warning */
1815 return &error_value
;
1818 static const int transpose
[] = {
1826 _mesa_GetBooleanv(GLenum pname
, GLboolean
*params
)
1828 const struct value_desc
*d
;
1834 d
= find_value("glGetBooleanv", pname
, &p
, &v
);
1839 params
[0] = INT_TO_BOOLEAN(d
->offset
);
1844 params
[3] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[3]);
1847 params
[2] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[2]);
1850 params
[1] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[1]);
1853 params
[0] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[0]);
1857 params
[0] = FLOAT_TO_BOOLEAN(((GLdouble
*) p
)[0]);
1861 params
[3] = INT_TO_BOOLEAN(((GLint
*) p
)[3]);
1863 params
[2] = INT_TO_BOOLEAN(((GLint
*) p
)[2]);
1866 params
[1] = INT_TO_BOOLEAN(((GLint
*) p
)[1]);
1869 params
[0] = INT_TO_BOOLEAN(((GLint
*) p
)[0]);
1873 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
1874 params
[i
] = INT_TO_BOOLEAN(v
.value_int_n
.ints
[i
]);
1878 params
[0] = INT64_TO_BOOLEAN(((GLint64
*) p
)[0]);
1882 params
[0] = ((GLboolean
*) p
)[0];
1886 m
= *(GLmatrix
**) p
;
1887 for (i
= 0; i
< 16; i
++)
1888 params
[i
] = FLOAT_TO_BOOLEAN(m
->m
[i
]);
1892 m
= *(GLmatrix
**) p
;
1893 for (i
= 0; i
< 16; i
++)
1894 params
[i
] = FLOAT_TO_BOOLEAN(m
->m
[transpose
[i
]]);
1903 shift
= d
->type
- TYPE_BIT_0
;
1904 params
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
1910 _mesa_GetFloatv(GLenum pname
, GLfloat
*params
)
1912 const struct value_desc
*d
;
1918 d
= find_value("glGetFloatv", pname
, &p
, &v
);
1923 params
[0] = (GLfloat
) d
->offset
;
1928 params
[3] = ((GLfloat
*) p
)[3];
1931 params
[2] = ((GLfloat
*) p
)[2];
1934 params
[1] = ((GLfloat
*) p
)[1];
1937 params
[0] = ((GLfloat
*) p
)[0];
1941 params
[0] = ((GLdouble
*) p
)[0];
1945 params
[3] = (GLfloat
) (((GLint
*) p
)[3]);
1947 params
[2] = (GLfloat
) (((GLint
*) p
)[2]);
1950 params
[1] = (GLfloat
) (((GLint
*) p
)[1]);
1953 params
[0] = (GLfloat
) (((GLint
*) p
)[0]);
1957 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
1958 params
[i
] = INT_TO_FLOAT(v
.value_int_n
.ints
[i
]);
1962 params
[0] = ((GLint64
*) p
)[0];
1966 params
[0] = BOOLEAN_TO_FLOAT(*(GLboolean
*) p
);
1970 m
= *(GLmatrix
**) p
;
1971 for (i
= 0; i
< 16; i
++)
1972 params
[i
] = m
->m
[i
];
1976 m
= *(GLmatrix
**) p
;
1977 for (i
= 0; i
< 16; i
++)
1978 params
[i
] = m
->m
[transpose
[i
]];
1987 shift
= d
->type
- TYPE_BIT_0
;
1988 params
[0] = BOOLEAN_TO_FLOAT((*(GLbitfield
*) p
>> shift
) & 1);
1994 _mesa_GetIntegerv(GLenum pname
, GLint
*params
)
1996 const struct value_desc
*d
;
2002 d
= find_value("glGetIntegerv", pname
, &p
, &v
);
2007 params
[0] = d
->offset
;
2011 params
[3] = IROUND(((GLfloat
*) p
)[3]);
2013 params
[2] = IROUND(((GLfloat
*) p
)[2]);
2015 params
[1] = IROUND(((GLfloat
*) p
)[1]);
2017 params
[0] = IROUND(((GLfloat
*) p
)[0]);
2021 params
[3] = FLOAT_TO_INT(((GLfloat
*) p
)[3]);
2023 params
[2] = FLOAT_TO_INT(((GLfloat
*) p
)[2]);
2025 params
[1] = FLOAT_TO_INT(((GLfloat
*) p
)[1]);
2027 params
[0] = FLOAT_TO_INT(((GLfloat
*) p
)[0]);
2031 params
[0] = FLOAT_TO_INT(((GLdouble
*) p
)[0]);
2035 params
[3] = ((GLint
*) p
)[3];
2037 params
[2] = ((GLint
*) p
)[2];
2040 params
[1] = ((GLint
*) p
)[1];
2043 params
[0] = ((GLint
*) p
)[0];
2047 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
2048 params
[i
] = v
.value_int_n
.ints
[i
];
2052 params
[0] = INT64_TO_INT(((GLint64
*) p
)[0]);
2056 params
[0] = BOOLEAN_TO_INT(*(GLboolean
*) p
);
2060 m
= *(GLmatrix
**) p
;
2061 for (i
= 0; i
< 16; i
++)
2062 params
[i
] = FLOAT_TO_INT(m
->m
[i
]);
2066 m
= *(GLmatrix
**) p
;
2067 for (i
= 0; i
< 16; i
++)
2068 params
[i
] = FLOAT_TO_INT(m
->m
[transpose
[i
]]);
2077 shift
= d
->type
- TYPE_BIT_0
;
2078 params
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
2083 #if FEATURE_ARB_sync
2085 _mesa_GetInteger64v(GLenum pname
, GLint64
*params
)
2087 const struct value_desc
*d
;
2093 d
= find_value("glGetInteger64v", pname
, &p
, &v
);
2098 params
[0] = d
->offset
;
2102 params
[3] = IROUND64(((GLfloat
*) p
)[3]);
2104 params
[2] = IROUND64(((GLfloat
*) p
)[2]);
2106 params
[1] = IROUND64(((GLfloat
*) p
)[1]);
2108 params
[0] = IROUND64(((GLfloat
*) p
)[0]);
2112 params
[3] = FLOAT_TO_INT64(((GLfloat
*) p
)[3]);
2114 params
[2] = FLOAT_TO_INT64(((GLfloat
*) p
)[2]);
2116 params
[1] = FLOAT_TO_INT64(((GLfloat
*) p
)[1]);
2118 params
[0] = FLOAT_TO_INT64(((GLfloat
*) p
)[0]);
2122 params
[0] = FLOAT_TO_INT64(((GLdouble
*) p
)[0]);
2126 params
[3] = ((GLint
*) p
)[3];
2128 params
[2] = ((GLint
*) p
)[2];
2131 params
[1] = ((GLint
*) p
)[1];
2134 params
[0] = ((GLint
*) p
)[0];
2138 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
2139 params
[i
] = INT_TO_BOOLEAN(v
.value_int_n
.ints
[i
]);
2143 params
[0] = ((GLint64
*) p
)[0];
2147 params
[0] = ((GLboolean
*) p
)[0];
2151 m
= *(GLmatrix
**) p
;
2152 for (i
= 0; i
< 16; i
++)
2153 params
[i
] = FLOAT_TO_INT64(m
->m
[i
]);
2157 m
= *(GLmatrix
**) p
;
2158 for (i
= 0; i
< 16; i
++)
2159 params
[i
] = FLOAT_TO_INT64(m
->m
[transpose
[i
]]);
2168 shift
= d
->type
- TYPE_BIT_0
;
2169 params
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
2173 #endif /* FEATURE_ARB_sync */
2176 _mesa_GetDoublev(GLenum pname
, GLdouble
*params
)
2178 const struct value_desc
*d
;
2184 d
= find_value("glGetDoublev", pname
, &p
, &v
);
2189 params
[0] = d
->offset
;
2194 params
[3] = ((GLfloat
*) p
)[3];
2197 params
[2] = ((GLfloat
*) p
)[2];
2200 params
[1] = ((GLfloat
*) p
)[1];
2203 params
[0] = ((GLfloat
*) p
)[0];
2207 params
[0] = ((GLdouble
*) p
)[0];
2211 params
[3] = ((GLint
*) p
)[3];
2213 params
[2] = ((GLint
*) p
)[2];
2216 params
[1] = ((GLint
*) p
)[1];
2219 params
[0] = ((GLint
*) p
)[0];
2223 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
2224 params
[i
] = v
.value_int_n
.ints
[i
];
2228 params
[0] = ((GLint64
*) p
)[0];
2232 params
[0] = *(GLboolean
*) p
;
2236 m
= *(GLmatrix
**) p
;
2237 for (i
= 0; i
< 16; i
++)
2238 params
[i
] = m
->m
[i
];
2242 m
= *(GLmatrix
**) p
;
2243 for (i
= 0; i
< 16; i
++)
2244 params
[i
] = m
->m
[transpose
[i
]];
2253 shift
= d
->type
- TYPE_BIT_0
;
2254 params
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
2259 static enum value_type
2260 find_value_indexed(const char *func
, GLenum pname
, int index
, union value
*v
)
2262 GET_CURRENT_CONTEXT(ctx
);
2267 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2269 if (!ctx
->Extensions
.EXT_draw_buffers2
)
2271 v
->value_int
= (ctx
->Color
.BlendEnabled
>> index
) & 1;
2276 case GL_BLEND_SRC_RGB
:
2277 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2279 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
2281 v
->value_int
= ctx
->Color
.Blend
[index
].SrcRGB
;
2283 case GL_BLEND_SRC_ALPHA
:
2284 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2286 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
2288 v
->value_int
= ctx
->Color
.Blend
[index
].SrcA
;
2292 case GL_BLEND_DST_RGB
:
2293 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2295 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
2297 v
->value_int
= ctx
->Color
.Blend
[index
].DstRGB
;
2299 case GL_BLEND_DST_ALPHA
:
2300 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2302 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
2304 v
->value_int
= ctx
->Color
.Blend
[index
].DstA
;
2306 case GL_BLEND_EQUATION_RGB
:
2307 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2309 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
2311 v
->value_int
= ctx
->Color
.Blend
[index
].EquationRGB
;
2313 case GL_BLEND_EQUATION_ALPHA
:
2314 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2316 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
2318 v
->value_int
= ctx
->Color
.Blend
[index
].EquationA
;
2321 case GL_COLOR_WRITEMASK
:
2322 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2324 if (!ctx
->Extensions
.EXT_draw_buffers2
)
2326 v
->value_int_4
[0] = ctx
->Color
.ColorMask
[index
][RCOMP
] ? 1 : 0;
2327 v
->value_int_4
[1] = ctx
->Color
.ColorMask
[index
][GCOMP
] ? 1 : 0;
2328 v
->value_int_4
[2] = ctx
->Color
.ColorMask
[index
][BCOMP
] ? 1 : 0;
2329 v
->value_int_4
[3] = ctx
->Color
.ColorMask
[index
][ACOMP
] ? 1 : 0;
2332 case GL_TRANSFORM_FEEDBACK_BUFFER_START
:
2333 if (index
>= ctx
->Const
.MaxTransformFeedbackSeparateAttribs
)
2335 if (!ctx
->Extensions
.EXT_transform_feedback
)
2337 v
->value_int64
= ctx
->TransformFeedback
.CurrentObject
->Offset
[index
];
2340 case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE
:
2341 if (index
>= ctx
->Const
.MaxTransformFeedbackSeparateAttribs
)
2343 if (!ctx
->Extensions
.EXT_transform_feedback
)
2345 v
->value_int64
= ctx
->TransformFeedback
.CurrentObject
->Size
[index
];
2348 case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING
:
2349 if (index
>= ctx
->Const
.MaxTransformFeedbackSeparateAttribs
)
2351 if (!ctx
->Extensions
.EXT_transform_feedback
)
2353 v
->value_int
= ctx
->TransformFeedback
.CurrentObject
->Buffers
[index
]->Name
;
2358 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(pname=%s)", func
,
2359 _mesa_lookup_enum_by_nr(pname
));
2360 return TYPE_INVALID
;
2362 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(pname=%s)", func
,
2363 _mesa_lookup_enum_by_nr(pname
));
2364 return TYPE_INVALID
;
2368 _mesa_GetBooleanIndexedv( GLenum pname
, GLuint index
, GLboolean
*params
)
2371 enum value_type type
=
2372 find_value_indexed("glGetBooleanIndexedv", pname
, index
, &v
);
2376 params
[0] = INT_TO_BOOLEAN(v
.value_int
);
2379 params
[0] = INT_TO_BOOLEAN(v
.value_int_4
[0]);
2380 params
[1] = INT_TO_BOOLEAN(v
.value_int_4
[1]);
2381 params
[2] = INT_TO_BOOLEAN(v
.value_int_4
[2]);
2382 params
[3] = INT_TO_BOOLEAN(v
.value_int_4
[3]);
2385 params
[0] = INT64_TO_BOOLEAN(v
.value_int
);
2388 ; /* nothing - GL error was recorded */
2393 _mesa_GetIntegerIndexedv( GLenum pname
, GLuint index
, GLint
*params
)
2396 enum value_type type
=
2397 find_value_indexed("glGetIntegerIndexedv", pname
, index
, &v
);
2401 params
[0] = v
.value_int
;
2404 params
[0] = v
.value_int_4
[0];
2405 params
[1] = v
.value_int_4
[1];
2406 params
[2] = v
.value_int_4
[2];
2407 params
[3] = v
.value_int_4
[3];
2410 params
[0] = INT64_TO_INT(v
.value_int
);
2413 ; /* nothing - GL error was recorded */
2417 #if FEATURE_ARB_sync
2419 _mesa_GetInteger64Indexedv( GLenum pname
, GLuint index
, GLint64
*params
)
2422 enum value_type type
=
2423 find_value_indexed("glGetIntegerIndexedv", pname
, index
, &v
);
2427 params
[0] = v
.value_int
;
2430 params
[0] = v
.value_int_4
[0];
2431 params
[1] = v
.value_int_4
[1];
2432 params
[2] = v
.value_int_4
[2];
2433 params
[3] = v
.value_int_4
[3];
2436 params
[0] = v
.value_int
;
2439 ; /* nothing - GL error was recorded */
2442 #endif /* FEATURE_ARB_sync */
2446 _mesa_GetFixedv(GLenum pname
, GLfixed
*params
)
2448 const struct value_desc
*d
;
2454 d
= find_value("glGetDoublev", pname
, &p
, &v
);
2459 params
[0] = INT_TO_FIXED(d
->offset
);
2464 params
[3] = FLOAT_TO_FIXED(((GLfloat
*) p
)[3]);
2467 params
[2] = FLOAT_TO_FIXED(((GLfloat
*) p
)[2]);
2470 params
[1] = FLOAT_TO_FIXED(((GLfloat
*) p
)[1]);
2473 params
[0] = FLOAT_TO_FIXED(((GLfloat
*) p
)[0]);
2477 params
[0] = FLOAT_TO_FIXED(((GLdouble
*) p
)[0]);
2481 params
[3] = INT_TO_FIXED(((GLint
*) p
)[3]);
2483 params
[2] = INT_TO_FIXED(((GLint
*) p
)[2]);
2486 params
[1] = INT_TO_FIXED(((GLint
*) p
)[1]);
2489 params
[0] = INT_TO_FIXED(((GLint
*) p
)[0]);
2493 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
2494 params
[i
] = INT_TO_FIXED(v
.value_int_n
.ints
[i
]);
2498 params
[0] = ((GLint64
*) p
)[0];
2502 params
[0] = BOOLEAN_TO_FIXED(((GLboolean
*) p
)[0]);
2506 m
= *(GLmatrix
**) p
;
2507 for (i
= 0; i
< 16; i
++)
2508 params
[i
] = FLOAT_TO_FIXED(m
->m
[i
]);
2512 m
= *(GLmatrix
**) p
;
2513 for (i
= 0; i
< 16; i
++)
2514 params
[i
] = FLOAT_TO_FIXED(m
->m
[transpose
[i
]]);
2523 shift
= d
->type
- TYPE_BIT_0
;
2524 params
[0] = BOOLEAN_TO_FIXED((*(GLbitfield
*) p
>> shift
) & 1);