2 * Copyright (C) 2010 Brian Paul All Rights Reserved.
3 * Copyright (C) 2010 Intel Corporation
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included
13 * in all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
19 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 * Author: Kristian Høgsberg <krh@bitplanet.net>
29 #include "extensions.h"
32 #include "mfeatures.h"
35 #include "framebuffer.h"
37 /* This is a table driven implemetation of the glGet*v() functions.
38 * The basic idea is that most getters just look up an int somewhere
39 * in struct gl_context and then convert it to a bool or float according to
40 * which of glGetIntegerv() glGetBooleanv() etc is being called.
41 * Instead of generating code to do this, we can just record the enum
42 * value and the offset into struct gl_context in an array of structs. Then
43 * in glGet*(), we lookup the struct for the enum in question, and use
44 * the offset to get the int we need.
46 * Sometimes we need to look up a float, a boolean, a bit in a
47 * bitfield, a matrix or other types instead, so we need to track the
48 * type of the value in struct gl_context. And sometimes the value isn't in
49 * struct gl_context but in the drawbuffer, the array object, current texture
50 * unit, or maybe it's a computed value. So we need to also track
51 * where or how to find the value. Finally, we sometimes need to
52 * check that one of a number of extensions are enabled, the GL
53 * version or flush or call _mesa_update_state(). This is done by
54 * attaching optional extra information to the value description
55 * struct, it's sort of like an array of opcodes that describe extra
58 * Putting all this together we end up with struct value_desc below,
59 * and with a couple of macros to help, the table of struct value_desc
60 * is about as concise as the specification in the old python script.
65 #define FLOAT_TO_BOOLEAN(X) ( (X) ? GL_TRUE : GL_FALSE )
66 #define FLOAT_TO_FIXED(F) ( ((F) * 65536.0f > INT_MAX) ? INT_MAX : \
67 ((F) * 65536.0f < INT_MIN) ? INT_MIN : \
68 (GLint) ((F) * 65536.0f) )
70 #define INT_TO_BOOLEAN(I) ( (I) ? GL_TRUE : GL_FALSE )
71 #define INT_TO_FIXED(I) ( ((I) > SHRT_MAX) ? INT_MAX : \
72 ((I) < SHRT_MIN) ? INT_MIN : \
73 (GLint) ((I) * 65536) )
75 #define INT64_TO_BOOLEAN(I) ( (I) ? GL_TRUE : GL_FALSE )
76 #define INT64_TO_INT(I) ( (GLint)((I > INT_MAX) ? INT_MAX : ((I < INT_MIN) ? INT_MIN : (I))) )
78 #define BOOLEAN_TO_INT(B) ( (GLint) (B) )
79 #define BOOLEAN_TO_INT64(B) ( (GLint64) (B) )
80 #define BOOLEAN_TO_FLOAT(B) ( (B) ? 1.0F : 0.0F )
81 #define BOOLEAN_TO_FIXED(B) ( (GLint) ((B) ? 1 : 0) << 16 )
83 #define ENUM_TO_INT64(E) ( (GLint64) (E) )
84 #define ENUM_TO_FIXED(E) (E)
119 enum value_location
{
133 EXTRA_VALID_TEXTURE_UNIT
,
134 EXTRA_VALID_CLIP_DISTANCE
,
138 #define NO_EXTRA NULL
143 GLubyte location
; /**< enum value_location */
144 GLubyte type
; /**< enum value_type */
151 GLfloat value_float_4
[4];
152 GLmatrix
*value_matrix
;
154 GLint value_int_4
[4];
158 /* Sigh, see GL_COMPRESSED_TEXTURE_FORMATS_ARB handling */
162 GLboolean value_bool
;
165 #define BUFFER_FIELD(field, type) \
166 LOC_BUFFER, type, offsetof(struct gl_framebuffer, field)
167 #define CONTEXT_FIELD(field, type) \
168 LOC_CONTEXT, type, offsetof(struct gl_context, field)
169 #define ARRAY_FIELD(field, type) \
170 LOC_ARRAY, type, offsetof(struct gl_array_object, field)
171 #define CONST(value) \
172 LOC_CONTEXT, TYPE_CONST, value
174 #define BUFFER_INT(field) BUFFER_FIELD(field, TYPE_INT)
175 #define BUFFER_ENUM(field) BUFFER_FIELD(field, TYPE_ENUM)
176 #define BUFFER_BOOL(field) BUFFER_FIELD(field, TYPE_BOOLEAN)
178 #define CONTEXT_INT(field) CONTEXT_FIELD(field, TYPE_INT)
179 #define CONTEXT_INT2(field) CONTEXT_FIELD(field, TYPE_INT_2)
180 #define CONTEXT_INT64(field) CONTEXT_FIELD(field, TYPE_INT64)
181 #define CONTEXT_ENUM(field) CONTEXT_FIELD(field, TYPE_ENUM)
182 #define CONTEXT_ENUM2(field) CONTEXT_FIELD(field, TYPE_ENUM_2)
183 #define CONTEXT_BOOL(field) CONTEXT_FIELD(field, TYPE_BOOLEAN)
184 #define CONTEXT_BIT0(field) CONTEXT_FIELD(field, TYPE_BIT_0)
185 #define CONTEXT_BIT1(field) CONTEXT_FIELD(field, TYPE_BIT_1)
186 #define CONTEXT_BIT2(field) CONTEXT_FIELD(field, TYPE_BIT_2)
187 #define CONTEXT_BIT3(field) CONTEXT_FIELD(field, TYPE_BIT_3)
188 #define CONTEXT_BIT4(field) CONTEXT_FIELD(field, TYPE_BIT_4)
189 #define CONTEXT_BIT5(field) CONTEXT_FIELD(field, TYPE_BIT_5)
190 #define CONTEXT_BIT6(field) CONTEXT_FIELD(field, TYPE_BIT_6)
191 #define CONTEXT_BIT7(field) CONTEXT_FIELD(field, TYPE_BIT_7)
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_valid_texture_unit
[] = {
228 EXTRA_VALID_TEXTURE_UNIT
,
232 static const int extra_valid_clip_distance
[] = {
233 EXTRA_VALID_CLIP_DISTANCE
,
237 static const int extra_flush_current_valid_texture_unit
[] = {
239 EXTRA_VALID_TEXTURE_UNIT
,
243 static const int extra_flush_current
[] = {
248 static const int extra_EXT_secondary_color_flush_current
[] = {
249 EXT(EXT_secondary_color
),
254 static const int extra_EXT_fog_coord_flush_current
[] = {
260 static const int extra_EXT_texture_integer
[] = {
261 EXT(EXT_texture_integer
),
266 EXTRA_EXT(ARB_texture_cube_map
);
267 EXTRA_EXT(EXT_secondary_color
);
268 EXTRA_EXT(EXT_fog_coord
);
269 EXTRA_EXT(NV_fog_distance
);
270 EXTRA_EXT(EXT_texture_filter_anisotropic
);
271 EXTRA_EXT(IBM_rasterpos_clip
);
272 EXTRA_EXT(NV_point_sprite
);
273 EXTRA_EXT(EXT_stencil_two_side
);
274 EXTRA_EXT(NV_light_max_exponent
);
275 EXTRA_EXT(EXT_depth_bounds_test
);
276 EXTRA_EXT(APPLE_vertex_array_object
);
277 EXTRA_EXT(EXT_compiled_vertex_array
);
278 EXTRA_EXT(EXT_pixel_buffer_object
);
279 EXTRA_EXT2(NV_point_sprite
, ARB_point_sprite
);
281 static const int extra_version_30
[] = { EXTRA_VERSION_30
, EXTRA_END
};
282 static const int extra_version_31
[] = { EXTRA_VERSION_31
, EXTRA_END
};
283 static const int extra_version_32
[] = { EXTRA_VERSION_32
, EXTRA_END
};
285 #define API_OPENGL_BIT (1 << API_OPENGL)
287 /* This is the big table describing all the enums we accept in
288 * glGet*v(). The table is partitioned into six parts: enums
289 * understood by all GL APIs (OpenGL, GLES and GLES2), enums shared
290 * between OpenGL and GLES, enums exclusive to GLES, etc for the
291 * remaining combinations. When we add the enums to the hash table in
292 * _mesa_init_get_hash(), we only add the enums for the API we're
293 * instantiating and the different sections are guarded by #if
294 * FEATURE_GL etc to make sure we only compile in the enums we may
297 static const struct value_desc values
[] = {
298 { GL_ALPHA_BITS
, BUFFER_INT(Visual
.alphaBits
), extra_new_buffers
},
299 { GL_BLEND
, CONTEXT_BIT0(Color
.BlendEnabled
), NO_EXTRA
},
300 { GL_BLEND_SRC
, CONTEXT_ENUM(Color
.SrcRGB
), NO_EXTRA
},
301 { GL_BLUE_BITS
, BUFFER_INT(Visual
.blueBits
), extra_new_buffers
},
302 { GL_COLOR_CLEAR_VALUE
, LOC_CUSTOM
, TYPE_FLOATN_4
, 0, NO_EXTRA
},
303 { GL_COLOR_WRITEMASK
, LOC_CUSTOM
, TYPE_INT_4
, 0, NO_EXTRA
},
304 { GL_CULL_FACE
, CONTEXT_BOOL(Polygon
.CullFlag
), NO_EXTRA
},
305 { GL_CULL_FACE_MODE
, CONTEXT_ENUM(Polygon
.CullFaceMode
), NO_EXTRA
},
306 { GL_DEPTH_BITS
, BUFFER_INT(Visual
.depthBits
), NO_EXTRA
},
307 { GL_DEPTH_CLEAR_VALUE
, CONTEXT_FIELD(Depth
.Clear
, TYPE_DOUBLEN
), NO_EXTRA
},
308 { GL_DEPTH_FUNC
, CONTEXT_ENUM(Depth
.Func
), NO_EXTRA
},
309 { GL_DEPTH_RANGE
, CONTEXT_FIELD(Viewport
.Near
, TYPE_FLOATN_2
), NO_EXTRA
},
310 { GL_DEPTH_TEST
, CONTEXT_BOOL(Depth
.Test
), NO_EXTRA
},
311 { GL_DEPTH_WRITEMASK
, CONTEXT_BOOL(Depth
.Mask
), NO_EXTRA
},
312 { GL_DITHER
, CONTEXT_BOOL(Color
.DitherFlag
), NO_EXTRA
},
313 { GL_FRONT_FACE
, CONTEXT_ENUM(Polygon
.FrontFace
), NO_EXTRA
},
314 { GL_GREEN_BITS
, BUFFER_INT(Visual
.greenBits
), extra_new_buffers
},
315 { GL_LINE_WIDTH
, CONTEXT_FLOAT(Line
.Width
), NO_EXTRA
},
316 { GL_ALIASED_LINE_WIDTH_RANGE
, CONTEXT_FLOAT2(Const
.MinLineWidth
), NO_EXTRA
},
317 { GL_MAX_ELEMENTS_VERTICES
, CONTEXT_INT(Const
.MaxArrayLockSize
), NO_EXTRA
},
318 { GL_MAX_ELEMENTS_INDICES
, CONTEXT_INT(Const
.MaxArrayLockSize
), NO_EXTRA
},
319 { GL_MAX_TEXTURE_SIZE
, LOC_CUSTOM
, TYPE_INT
,
320 offsetof(struct gl_context
, Const
.MaxTextureLevels
), NO_EXTRA
},
321 { GL_MAX_VIEWPORT_DIMS
, CONTEXT_INT2(Const
.MaxViewportWidth
), NO_EXTRA
},
322 { GL_PACK_ALIGNMENT
, CONTEXT_INT(Pack
.Alignment
), NO_EXTRA
},
323 { GL_ALIASED_POINT_SIZE_RANGE
, CONTEXT_FLOAT2(Const
.MinPointSize
), NO_EXTRA
},
324 { GL_POLYGON_OFFSET_FACTOR
, CONTEXT_FLOAT(Polygon
.OffsetFactor
), NO_EXTRA
},
325 { GL_POLYGON_OFFSET_UNITS
, CONTEXT_FLOAT(Polygon
.OffsetUnits
), NO_EXTRA
},
326 { GL_POLYGON_OFFSET_FILL
, CONTEXT_BOOL(Polygon
.OffsetFill
), NO_EXTRA
},
327 { GL_RED_BITS
, BUFFER_INT(Visual
.redBits
), extra_new_buffers
},
328 { GL_SCISSOR_BOX
, LOC_CUSTOM
, TYPE_INT_4
, 0, NO_EXTRA
},
329 { GL_SCISSOR_TEST
, CONTEXT_BOOL(Scissor
.Enabled
), NO_EXTRA
},
330 { GL_STENCIL_BITS
, BUFFER_INT(Visual
.stencilBits
), NO_EXTRA
},
331 { GL_STENCIL_CLEAR_VALUE
, CONTEXT_INT(Stencil
.Clear
), NO_EXTRA
},
332 { GL_STENCIL_FAIL
, LOC_CUSTOM
, TYPE_ENUM
, NO_OFFSET
, NO_EXTRA
},
333 { GL_STENCIL_FUNC
, LOC_CUSTOM
, TYPE_ENUM
, NO_OFFSET
, NO_EXTRA
},
334 { GL_STENCIL_PASS_DEPTH_FAIL
, LOC_CUSTOM
, TYPE_ENUM
, NO_OFFSET
, NO_EXTRA
},
335 { GL_STENCIL_PASS_DEPTH_PASS
, LOC_CUSTOM
, TYPE_ENUM
, NO_OFFSET
, NO_EXTRA
},
336 { GL_STENCIL_REF
, LOC_CUSTOM
, TYPE_INT
, NO_OFFSET
, NO_EXTRA
},
337 { GL_STENCIL_TEST
, CONTEXT_BOOL(Stencil
.Enabled
), NO_EXTRA
},
338 { GL_STENCIL_VALUE_MASK
, LOC_CUSTOM
, TYPE_INT
, NO_OFFSET
, NO_EXTRA
},
339 { GL_STENCIL_WRITEMASK
, LOC_CUSTOM
, TYPE_INT
, NO_OFFSET
, NO_EXTRA
},
340 { GL_SUBPIXEL_BITS
, CONTEXT_INT(Const
.SubPixelBits
), NO_EXTRA
},
341 { GL_TEXTURE_BINDING_2D
, LOC_CUSTOM
, TYPE_INT
, TEXTURE_2D_INDEX
, NO_EXTRA
},
342 { GL_UNPACK_ALIGNMENT
, CONTEXT_INT(Unpack
.Alignment
), NO_EXTRA
},
343 { GL_VIEWPORT
, LOC_CUSTOM
, TYPE_INT_4
, 0, NO_EXTRA
},
345 /* GL_ARB_multitexture */
346 { GL_ACTIVE_TEXTURE
, LOC_CUSTOM
, TYPE_INT
, 0, NO_EXTRA
},
348 /* Note that all the OES_* extensions require that the Mesa "struct
349 * gl_extensions" include a member with the name of the extension.
350 * That structure does not yet include OES extensions (and we're
351 * not sure whether it will). If it does, all the OES_*
352 * extensions below should mark the dependency. */
354 /* GL_ARB_texture_cube_map */
355 { GL_TEXTURE_BINDING_CUBE_MAP_ARB
, LOC_CUSTOM
, TYPE_INT
,
356 TEXTURE_CUBE_INDEX
, extra_ARB_texture_cube_map
},
357 { GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB
, LOC_CUSTOM
, TYPE_INT
,
358 offsetof(struct gl_context
, Const
.MaxCubeTextureLevels
),
359 extra_ARB_texture_cube_map
}, /* XXX: OES_texture_cube_map */
361 /* XXX: OES_blend_subtract */
362 { GL_BLEND_SRC_RGB_EXT
, CONTEXT_ENUM(Color
.SrcRGB
), NO_EXTRA
},
363 { GL_BLEND_DST_RGB_EXT
, CONTEXT_ENUM(Color
.DstRGB
), NO_EXTRA
},
364 { GL_BLEND_SRC_ALPHA_EXT
, CONTEXT_ENUM(Color
.SrcA
), NO_EXTRA
},
365 { GL_BLEND_DST_ALPHA_EXT
, CONTEXT_ENUM(Color
.DstA
), NO_EXTRA
},
367 /* GL_BLEND_EQUATION_RGB, which is what we're really after, is
368 * defined identically to GL_BLEND_EQUATION. */
369 { GL_BLEND_EQUATION
, CONTEXT_ENUM(Color
.EquationRGB
), NO_EXTRA
},
370 { GL_BLEND_EQUATION_ALPHA_EXT
, CONTEXT_ENUM(Color
.EquationA
), NO_EXTRA
},
372 /* GL_ARB_texture_compression */
373 { GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB
, LOC_CUSTOM
, TYPE_INT
, 0, NO_EXTRA
},
374 { GL_COMPRESSED_TEXTURE_FORMATS_ARB
, LOC_CUSTOM
, TYPE_INT_N
, 0, NO_EXTRA
},
376 /* GL_ARB_multisample */
377 { GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
,
378 CONTEXT_BOOL(Multisample
.SampleAlphaToCoverage
), NO_EXTRA
},
379 { GL_SAMPLE_COVERAGE_ARB
, CONTEXT_BOOL(Multisample
.SampleCoverage
), NO_EXTRA
},
380 { GL_SAMPLE_COVERAGE_VALUE_ARB
,
381 CONTEXT_FLOAT(Multisample
.SampleCoverageValue
), NO_EXTRA
},
382 { GL_SAMPLE_COVERAGE_INVERT_ARB
,
383 CONTEXT_BOOL(Multisample
.SampleCoverageInvert
), NO_EXTRA
},
385 /* GL_ARB_vertex_buffer_object */
386 { GL_ARRAY_BUFFER_BINDING_ARB
, LOC_CUSTOM
, TYPE_INT
, 0, NO_EXTRA
},
388 /* GL_ARB_vertex_buffer_object */
389 /* GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB - not supported */
390 { GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB
, LOC_CUSTOM
, TYPE_INT
, 0, NO_EXTRA
},
392 /* GL_OES_read_format */
393 { GL_IMPLEMENTATION_COLOR_READ_TYPE_OES
, LOC_CUSTOM
, TYPE_INT
, 0,
395 { GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES
, LOC_CUSTOM
, TYPE_INT
, 0,
398 /* This entry isn't spec'ed for GLES 2, but is needed for Mesa's
400 { GL_MAX_CLIP_PLANES
, CONTEXT_INT(Const
.MaxClipPlanes
), NO_EXTRA
},
402 { GL_MAX_LIGHTS
, CONTEXT_INT(Const
.MaxLights
), NO_EXTRA
},
403 { GL_LIGHT0
, CONTEXT_BOOL(Light
.Light
[0].Enabled
), NO_EXTRA
},
404 { GL_LIGHT1
, CONTEXT_BOOL(Light
.Light
[1].Enabled
), NO_EXTRA
},
405 { GL_LIGHT2
, CONTEXT_BOOL(Light
.Light
[2].Enabled
), NO_EXTRA
},
406 { GL_LIGHT3
, CONTEXT_BOOL(Light
.Light
[3].Enabled
), NO_EXTRA
},
407 { GL_LIGHT4
, CONTEXT_BOOL(Light
.Light
[4].Enabled
), NO_EXTRA
},
408 { GL_LIGHT5
, CONTEXT_BOOL(Light
.Light
[5].Enabled
), NO_EXTRA
},
409 { GL_LIGHT6
, CONTEXT_BOOL(Light
.Light
[6].Enabled
), NO_EXTRA
},
410 { GL_LIGHT7
, CONTEXT_BOOL(Light
.Light
[7].Enabled
), NO_EXTRA
},
411 { GL_LIGHTING
, CONTEXT_BOOL(Light
.Enabled
), NO_EXTRA
},
412 { GL_LIGHT_MODEL_AMBIENT
,
413 CONTEXT_FIELD(Light
.Model
.Ambient
[0], TYPE_FLOATN_4
), NO_EXTRA
},
414 { GL_LIGHT_MODEL_TWO_SIDE
, CONTEXT_BOOL(Light
.Model
.TwoSide
), NO_EXTRA
},
415 { GL_ALPHA_TEST
, CONTEXT_BOOL(Color
.AlphaEnabled
), NO_EXTRA
},
416 { GL_ALPHA_TEST_FUNC
, CONTEXT_ENUM(Color
.AlphaFunc
), NO_EXTRA
},
417 { GL_ALPHA_TEST_REF
, LOC_CUSTOM
, TYPE_FLOATN
, 0, NO_EXTRA
},
418 { GL_BLEND_DST
, CONTEXT_ENUM(Color
.DstRGB
), NO_EXTRA
},
419 { GL_CLIP_DISTANCE0
, CONTEXT_BIT0(Transform
.ClipPlanesEnabled
), extra_valid_clip_distance
},
420 { GL_CLIP_DISTANCE1
, CONTEXT_BIT1(Transform
.ClipPlanesEnabled
), extra_valid_clip_distance
},
421 { GL_CLIP_DISTANCE2
, CONTEXT_BIT2(Transform
.ClipPlanesEnabled
), extra_valid_clip_distance
},
422 { GL_CLIP_DISTANCE3
, CONTEXT_BIT3(Transform
.ClipPlanesEnabled
), extra_valid_clip_distance
},
423 { GL_CLIP_DISTANCE4
, CONTEXT_BIT4(Transform
.ClipPlanesEnabled
), extra_valid_clip_distance
},
424 { GL_CLIP_DISTANCE5
, CONTEXT_BIT5(Transform
.ClipPlanesEnabled
), extra_valid_clip_distance
},
425 { GL_CLIP_DISTANCE6
, CONTEXT_BIT6(Transform
.ClipPlanesEnabled
), extra_valid_clip_distance
},
426 { GL_CLIP_DISTANCE7
, CONTEXT_BIT7(Transform
.ClipPlanesEnabled
), extra_valid_clip_distance
},
427 { GL_COLOR_MATERIAL
, CONTEXT_BOOL(Light
.ColorMaterialEnabled
), NO_EXTRA
},
429 CONTEXT_FIELD(Current
.Attrib
[VERT_ATTRIB_COLOR0
][0], TYPE_FLOATN_4
),
430 extra_flush_current
},
432 CONTEXT_FIELD(Current
.Attrib
[VERT_ATTRIB_NORMAL
][0], TYPE_FLOATN_3
),
433 extra_flush_current
},
434 { GL_CURRENT_TEXTURE_COORDS
, LOC_CUSTOM
, TYPE_FLOAT_4
, 0,
435 extra_flush_current_valid_texture_unit
},
436 { GL_DISTANCE_ATTENUATION_EXT
, CONTEXT_FLOAT3(Point
.Params
[0]), NO_EXTRA
},
437 { GL_FOG
, CONTEXT_BOOL(Fog
.Enabled
), NO_EXTRA
},
438 { GL_FOG_COLOR
, LOC_CUSTOM
, TYPE_FLOATN_4
, 0, NO_EXTRA
},
439 { GL_FOG_DENSITY
, CONTEXT_FLOAT(Fog
.Density
), NO_EXTRA
},
440 { GL_FOG_END
, CONTEXT_FLOAT(Fog
.End
), NO_EXTRA
},
441 { GL_FOG_HINT
, CONTEXT_ENUM(Hint
.Fog
), NO_EXTRA
},
442 { GL_FOG_MODE
, CONTEXT_ENUM(Fog
.Mode
), NO_EXTRA
},
443 { GL_FOG_START
, CONTEXT_FLOAT(Fog
.Start
), NO_EXTRA
},
444 { GL_LINE_SMOOTH
, CONTEXT_BOOL(Line
.SmoothFlag
), NO_EXTRA
},
445 { GL_LINE_SMOOTH_HINT
, CONTEXT_ENUM(Hint
.LineSmooth
), NO_EXTRA
},
446 { GL_LINE_WIDTH_RANGE
, CONTEXT_FLOAT2(Const
.MinLineWidthAA
), NO_EXTRA
},
447 { GL_COLOR_LOGIC_OP
, CONTEXT_BOOL(Color
.ColorLogicOpEnabled
), NO_EXTRA
},
448 { GL_LOGIC_OP_MODE
, CONTEXT_ENUM(Color
.LogicOp
), NO_EXTRA
},
449 { GL_MATRIX_MODE
, CONTEXT_ENUM(Transform
.MatrixMode
), NO_EXTRA
},
450 { GL_MAX_MODELVIEW_STACK_DEPTH
, CONST(MAX_MODELVIEW_STACK_DEPTH
), NO_EXTRA
},
451 { GL_MAX_PROJECTION_STACK_DEPTH
, CONST(MAX_PROJECTION_STACK_DEPTH
), NO_EXTRA
},
452 { GL_MAX_TEXTURE_STACK_DEPTH
, CONST(MAX_TEXTURE_STACK_DEPTH
), NO_EXTRA
},
453 { GL_MODELVIEW_MATRIX
, CONTEXT_MATRIX(ModelviewMatrixStack
.Top
), NO_EXTRA
},
454 { GL_MODELVIEW_STACK_DEPTH
, LOC_CUSTOM
, TYPE_INT
,
455 offsetof(struct gl_context
, ModelviewMatrixStack
.Depth
), NO_EXTRA
},
456 { GL_NORMALIZE
, CONTEXT_BOOL(Transform
.Normalize
), NO_EXTRA
},
457 { GL_PACK_SKIP_IMAGES_EXT
, CONTEXT_INT(Pack
.SkipImages
), NO_EXTRA
},
458 { GL_PERSPECTIVE_CORRECTION_HINT
, CONTEXT_ENUM(Hint
.PerspectiveCorrection
), NO_EXTRA
},
459 { GL_POINT_SIZE
, CONTEXT_FLOAT(Point
.Size
), NO_EXTRA
},
460 { GL_POINT_SIZE_RANGE
, CONTEXT_FLOAT2(Const
.MinPointSizeAA
), NO_EXTRA
},
461 { GL_POINT_SMOOTH
, CONTEXT_BOOL(Point
.SmoothFlag
), NO_EXTRA
},
462 { GL_POINT_SMOOTH_HINT
, CONTEXT_ENUM(Hint
.PointSmooth
), NO_EXTRA
},
463 { GL_POINT_SIZE_MIN_EXT
, CONTEXT_FLOAT(Point
.MinSize
), NO_EXTRA
},
464 { GL_POINT_SIZE_MAX_EXT
, CONTEXT_FLOAT(Point
.MaxSize
), NO_EXTRA
},
465 { GL_POINT_FADE_THRESHOLD_SIZE_EXT
, CONTEXT_FLOAT(Point
.Threshold
), NO_EXTRA
},
466 { GL_PROJECTION_MATRIX
, CONTEXT_MATRIX(ProjectionMatrixStack
.Top
), NO_EXTRA
},
467 { GL_PROJECTION_STACK_DEPTH
, LOC_CUSTOM
, TYPE_INT
,
468 offsetof(struct gl_context
, ProjectionMatrixStack
.Depth
), NO_EXTRA
},
469 { GL_RESCALE_NORMAL
, CONTEXT_BOOL(Transform
.RescaleNormals
), NO_EXTRA
},
470 { GL_SHADE_MODEL
, CONTEXT_ENUM(Light
.ShadeModel
), NO_EXTRA
},
471 { GL_TEXTURE_2D
, LOC_CUSTOM
, TYPE_BOOLEAN
, 0, NO_EXTRA
},
472 { GL_TEXTURE_MATRIX
, LOC_CUSTOM
, TYPE_MATRIX
, 0, extra_valid_texture_unit
},
473 { GL_TEXTURE_STACK_DEPTH
, LOC_CUSTOM
, TYPE_INT
, 0,
474 extra_valid_texture_unit
},
476 { GL_VERTEX_ARRAY
, ARRAY_BOOL(VertexAttrib
[VERT_ATTRIB_POS
].Enabled
), NO_EXTRA
},
477 { GL_VERTEX_ARRAY_SIZE
, ARRAY_INT(VertexAttrib
[VERT_ATTRIB_POS
].Size
), NO_EXTRA
},
478 { GL_VERTEX_ARRAY_TYPE
, ARRAY_ENUM(VertexAttrib
[VERT_ATTRIB_POS
].Type
), NO_EXTRA
},
479 { GL_VERTEX_ARRAY_STRIDE
, ARRAY_INT(VertexAttrib
[VERT_ATTRIB_POS
].Stride
), NO_EXTRA
},
480 { GL_NORMAL_ARRAY
, ARRAY_BOOL(VertexAttrib
[VERT_ATTRIB_NORMAL
].Enabled
), NO_EXTRA
},
481 { GL_NORMAL_ARRAY_TYPE
, ARRAY_ENUM(VertexAttrib
[VERT_ATTRIB_NORMAL
].Type
), NO_EXTRA
},
482 { GL_NORMAL_ARRAY_STRIDE
, ARRAY_INT(VertexAttrib
[VERT_ATTRIB_NORMAL
].Stride
), NO_EXTRA
},
483 { GL_COLOR_ARRAY
, ARRAY_BOOL(VertexAttrib
[VERT_ATTRIB_COLOR0
].Enabled
), NO_EXTRA
},
484 { GL_COLOR_ARRAY_SIZE
, ARRAY_INT(VertexAttrib
[VERT_ATTRIB_COLOR0
].Size
), NO_EXTRA
},
485 { GL_COLOR_ARRAY_TYPE
, ARRAY_ENUM(VertexAttrib
[VERT_ATTRIB_COLOR0
].Type
), NO_EXTRA
},
486 { GL_COLOR_ARRAY_STRIDE
, ARRAY_INT(VertexAttrib
[VERT_ATTRIB_COLOR0
].Stride
), NO_EXTRA
},
487 { GL_TEXTURE_COORD_ARRAY
,
488 LOC_CUSTOM
, TYPE_BOOLEAN
, offsetof(struct gl_client_array
, Enabled
), NO_EXTRA
},
489 { GL_TEXTURE_COORD_ARRAY_SIZE
,
490 LOC_CUSTOM
, TYPE_INT
, offsetof(struct gl_client_array
, Size
), NO_EXTRA
},
491 { GL_TEXTURE_COORD_ARRAY_TYPE
,
492 LOC_CUSTOM
, TYPE_ENUM
, offsetof(struct gl_client_array
, Type
), NO_EXTRA
},
493 { GL_TEXTURE_COORD_ARRAY_STRIDE
,
494 LOC_CUSTOM
, TYPE_INT
, offsetof(struct gl_client_array
, Stride
), NO_EXTRA
},
496 /* GL_ARB_texture_cube_map */
497 { GL_TEXTURE_CUBE_MAP_ARB
, LOC_CUSTOM
, TYPE_BOOLEAN
, 0, NO_EXTRA
},
498 /* S, T, and R are always set at the same time */
499 { GL_TEXTURE_GEN_STR_OES
, LOC_TEXUNIT
, TYPE_BIT_0
,
500 offsetof(struct gl_texture_unit
, TexGenEnabled
), NO_EXTRA
},
502 /* GL_ARB_multisample */
503 { GL_MULTISAMPLE_ARB
, CONTEXT_BOOL(Multisample
.Enabled
), NO_EXTRA
},
504 { GL_SAMPLE_ALPHA_TO_ONE_ARB
, CONTEXT_BOOL(Multisample
.SampleAlphaToOne
), NO_EXTRA
},
506 /* GL_ARB_vertex_buffer_object */
507 { GL_VERTEX_ARRAY_BUFFER_BINDING_ARB
, LOC_CUSTOM
, TYPE_INT
,
508 offsetof(struct gl_array_object
, VertexAttrib
[VERT_ATTRIB_POS
].BufferObj
), NO_EXTRA
},
509 { GL_NORMAL_ARRAY_BUFFER_BINDING_ARB
, LOC_CUSTOM
, TYPE_INT
,
510 offsetof(struct gl_array_object
, VertexAttrib
[VERT_ATTRIB_NORMAL
].BufferObj
), NO_EXTRA
},
511 { GL_COLOR_ARRAY_BUFFER_BINDING_ARB
, LOC_CUSTOM
, TYPE_INT
,
512 offsetof(struct gl_array_object
, VertexAttrib
[VERT_ATTRIB_COLOR0
].BufferObj
), NO_EXTRA
},
513 { GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB
, LOC_CUSTOM
, TYPE_INT
, NO_OFFSET
, NO_EXTRA
},
515 /* GL_OES_point_sprite */
516 { GL_POINT_SPRITE_NV
,
517 CONTEXT_BOOL(Point
.PointSprite
),
518 extra_NV_point_sprite_ARB_point_sprite
},
520 /* GL_EXT_texture_filter_anisotropic */
521 { GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT
,
522 CONTEXT_FLOAT(Const
.MaxTextureMaxAnisotropy
),
523 extra_EXT_texture_filter_anisotropic
},
525 { GL_BLEND_COLOR_EXT
, LOC_CUSTOM
, TYPE_FLOATN_4
, 0, NO_EXTRA
},
528 { GL_STENCIL_BACK_FUNC
, CONTEXT_ENUM(Stencil
.Function
[1]), NO_EXTRA
},
529 { GL_STENCIL_BACK_VALUE_MASK
, CONTEXT_INT(Stencil
.ValueMask
[1]), NO_EXTRA
},
530 { GL_STENCIL_BACK_WRITEMASK
, CONTEXT_INT(Stencil
.WriteMask
[1]), NO_EXTRA
},
531 { GL_STENCIL_BACK_REF
, CONTEXT_INT(Stencil
.Ref
[1]), NO_EXTRA
},
532 { GL_STENCIL_BACK_FAIL
, CONTEXT_ENUM(Stencil
.FailFunc
[1]), NO_EXTRA
},
533 { GL_STENCIL_BACK_PASS_DEPTH_FAIL
, CONTEXT_ENUM(Stencil
.ZFailFunc
[1]), NO_EXTRA
},
534 { GL_STENCIL_BACK_PASS_DEPTH_PASS
, CONTEXT_ENUM(Stencil
.ZPassFunc
[1]), NO_EXTRA
},
537 { GL_TEXTURE_BINDING_3D
, LOC_CUSTOM
, TYPE_INT
, TEXTURE_3D_INDEX
, NO_EXTRA
},
538 { GL_MAX_3D_TEXTURE_SIZE
, LOC_CUSTOM
, TYPE_INT
,
539 offsetof(struct gl_context
, Const
.Max3DTextureLevels
), NO_EXTRA
},
541 { GL_ACCUM_RED_BITS
, BUFFER_INT(Visual
.accumRedBits
), NO_EXTRA
},
542 { GL_ACCUM_GREEN_BITS
, BUFFER_INT(Visual
.accumGreenBits
), NO_EXTRA
},
543 { GL_ACCUM_BLUE_BITS
, BUFFER_INT(Visual
.accumBlueBits
), NO_EXTRA
},
544 { GL_ACCUM_ALPHA_BITS
, BUFFER_INT(Visual
.accumAlphaBits
), NO_EXTRA
},
545 { GL_ACCUM_CLEAR_VALUE
, CONTEXT_FIELD(Accum
.ClearColor
[0], TYPE_FLOATN_4
), NO_EXTRA
},
546 { GL_ALPHA_BIAS
, CONTEXT_FLOAT(Pixel
.AlphaBias
), NO_EXTRA
},
547 { GL_ALPHA_SCALE
, CONTEXT_FLOAT(Pixel
.AlphaScale
), NO_EXTRA
},
548 { GL_ATTRIB_STACK_DEPTH
, CONTEXT_INT(AttribStackDepth
), NO_EXTRA
},
549 { GL_AUTO_NORMAL
, CONTEXT_BOOL(Eval
.AutoNormal
), NO_EXTRA
},
550 { GL_AUX_BUFFERS
, BUFFER_INT(Visual
.numAuxBuffers
), NO_EXTRA
},
551 { GL_BLUE_BIAS
, CONTEXT_FLOAT(Pixel
.BlueBias
), NO_EXTRA
},
552 { GL_BLUE_SCALE
, CONTEXT_FLOAT(Pixel
.BlueScale
), NO_EXTRA
},
553 { GL_CLIENT_ATTRIB_STACK_DEPTH
, CONTEXT_INT(ClientAttribStackDepth
), NO_EXTRA
},
554 { GL_COLOR_MATERIAL_FACE
, CONTEXT_ENUM(Light
.ColorMaterialFace
), NO_EXTRA
},
555 { GL_COLOR_MATERIAL_PARAMETER
, CONTEXT_ENUM(Light
.ColorMaterialMode
), NO_EXTRA
},
557 CONTEXT_FLOAT(Current
.Attrib
[VERT_ATTRIB_COLOR_INDEX
][0]),
558 extra_flush_current
},
559 { GL_CURRENT_RASTER_COLOR
,
560 CONTEXT_FIELD(Current
.RasterColor
[0], TYPE_FLOATN_4
), NO_EXTRA
},
561 { GL_CURRENT_RASTER_DISTANCE
, CONTEXT_FLOAT(Current
.RasterDistance
), NO_EXTRA
},
562 { GL_CURRENT_RASTER_INDEX
, CONST(1), NO_EXTRA
},
563 { GL_CURRENT_RASTER_POSITION
, CONTEXT_FLOAT4(Current
.RasterPos
[0]), NO_EXTRA
},
564 { GL_CURRENT_RASTER_SECONDARY_COLOR
,
565 CONTEXT_FIELD(Current
.RasterSecondaryColor
[0], TYPE_FLOATN_4
), NO_EXTRA
},
566 { GL_CURRENT_RASTER_TEXTURE_COORDS
, LOC_CUSTOM
, TYPE_FLOAT_4
, 0,
567 extra_valid_texture_unit
},
568 { GL_CURRENT_RASTER_POSITION_VALID
, CONTEXT_BOOL(Current
.RasterPosValid
), NO_EXTRA
},
569 { GL_DEPTH_BIAS
, CONTEXT_FLOAT(Pixel
.DepthBias
), NO_EXTRA
},
570 { GL_DEPTH_SCALE
, CONTEXT_FLOAT(Pixel
.DepthScale
), NO_EXTRA
},
571 { GL_DOUBLEBUFFER
, BUFFER_INT(Visual
.doubleBufferMode
), NO_EXTRA
},
572 { GL_DRAW_BUFFER
, BUFFER_ENUM(ColorDrawBuffer
), NO_EXTRA
},
573 { GL_EDGE_FLAG
, LOC_CUSTOM
, TYPE_BOOLEAN
, 0, NO_EXTRA
},
574 { GL_FEEDBACK_BUFFER_SIZE
, CONTEXT_INT(Feedback
.BufferSize
), NO_EXTRA
},
575 { GL_FEEDBACK_BUFFER_TYPE
, CONTEXT_ENUM(Feedback
.Type
), NO_EXTRA
},
576 { GL_FOG_INDEX
, CONTEXT_FLOAT(Fog
.Index
), NO_EXTRA
},
577 { GL_GREEN_BIAS
, CONTEXT_FLOAT(Pixel
.GreenBias
), NO_EXTRA
},
578 { GL_GREEN_SCALE
, CONTEXT_FLOAT(Pixel
.GreenScale
), NO_EXTRA
},
579 { GL_INDEX_BITS
, BUFFER_INT(Visual
.indexBits
), extra_new_buffers
},
580 { GL_INDEX_CLEAR_VALUE
, CONTEXT_INT(Color
.ClearIndex
), NO_EXTRA
},
581 { GL_INDEX_MODE
, CONST(0) , NO_EXTRA
},
582 { GL_INDEX_OFFSET
, CONTEXT_INT(Pixel
.IndexOffset
), NO_EXTRA
},
583 { GL_INDEX_SHIFT
, CONTEXT_INT(Pixel
.IndexShift
), NO_EXTRA
},
584 { GL_INDEX_WRITEMASK
, CONTEXT_INT(Color
.IndexMask
), NO_EXTRA
},
585 { GL_LIGHT_MODEL_COLOR_CONTROL
, CONTEXT_ENUM(Light
.Model
.ColorControl
), NO_EXTRA
},
586 { GL_LIGHT_MODEL_LOCAL_VIEWER
, CONTEXT_BOOL(Light
.Model
.LocalViewer
), NO_EXTRA
},
587 { GL_LINE_STIPPLE
, CONTEXT_BOOL(Line
.StippleFlag
), NO_EXTRA
},
588 { GL_LINE_STIPPLE_PATTERN
, LOC_CUSTOM
, TYPE_INT
, 0, NO_EXTRA
},
589 { GL_LINE_STIPPLE_REPEAT
, CONTEXT_INT(Line
.StippleFactor
), NO_EXTRA
},
590 { GL_LINE_WIDTH_GRANULARITY
, CONTEXT_FLOAT(Const
.LineWidthGranularity
), NO_EXTRA
},
591 { GL_LIST_BASE
, CONTEXT_INT(List
.ListBase
), NO_EXTRA
},
592 { GL_LIST_INDEX
, LOC_CUSTOM
, TYPE_INT
, 0, NO_EXTRA
},
593 { GL_LIST_MODE
, LOC_CUSTOM
, TYPE_ENUM
, 0, NO_EXTRA
},
594 { GL_INDEX_LOGIC_OP
, CONTEXT_BOOL(Color
.IndexLogicOpEnabled
), NO_EXTRA
},
595 { GL_MAP1_COLOR_4
, CONTEXT_BOOL(Eval
.Map1Color4
), NO_EXTRA
},
596 { GL_MAP1_GRID_DOMAIN
, CONTEXT_FLOAT2(Eval
.MapGrid1u1
), NO_EXTRA
},
597 { GL_MAP1_GRID_SEGMENTS
, CONTEXT_INT(Eval
.MapGrid1un
), NO_EXTRA
},
598 { GL_MAP1_INDEX
, CONTEXT_BOOL(Eval
.Map1Index
), NO_EXTRA
},
599 { GL_MAP1_NORMAL
, CONTEXT_BOOL(Eval
.Map1Normal
), NO_EXTRA
},
600 { GL_MAP1_TEXTURE_COORD_1
, CONTEXT_BOOL(Eval
.Map1TextureCoord1
), NO_EXTRA
},
601 { GL_MAP1_TEXTURE_COORD_2
, CONTEXT_BOOL(Eval
.Map1TextureCoord2
), NO_EXTRA
},
602 { GL_MAP1_TEXTURE_COORD_3
, CONTEXT_BOOL(Eval
.Map1TextureCoord3
), NO_EXTRA
},
603 { GL_MAP1_TEXTURE_COORD_4
, CONTEXT_BOOL(Eval
.Map1TextureCoord4
), NO_EXTRA
},
604 { GL_MAP1_VERTEX_3
, CONTEXT_BOOL(Eval
.Map1Vertex3
), NO_EXTRA
},
605 { GL_MAP1_VERTEX_4
, CONTEXT_BOOL(Eval
.Map1Vertex4
), NO_EXTRA
},
606 { GL_MAP2_COLOR_4
, CONTEXT_BOOL(Eval
.Map2Color4
), NO_EXTRA
},
607 { GL_MAP2_GRID_DOMAIN
, LOC_CUSTOM
, TYPE_FLOAT_4
, 0, NO_EXTRA
},
608 { GL_MAP2_GRID_SEGMENTS
, CONTEXT_INT2(Eval
.MapGrid2un
), NO_EXTRA
},
609 { GL_MAP2_INDEX
, CONTEXT_BOOL(Eval
.Map2Index
), NO_EXTRA
},
610 { GL_MAP2_NORMAL
, CONTEXT_BOOL(Eval
.Map2Normal
), NO_EXTRA
},
611 { GL_MAP2_TEXTURE_COORD_1
, CONTEXT_BOOL(Eval
.Map2TextureCoord1
), NO_EXTRA
},
612 { GL_MAP2_TEXTURE_COORD_2
, CONTEXT_BOOL(Eval
.Map2TextureCoord2
), NO_EXTRA
},
613 { GL_MAP2_TEXTURE_COORD_3
, CONTEXT_BOOL(Eval
.Map2TextureCoord3
), NO_EXTRA
},
614 { GL_MAP2_TEXTURE_COORD_4
, CONTEXT_BOOL(Eval
.Map2TextureCoord4
), NO_EXTRA
},
615 { GL_MAP2_VERTEX_3
, CONTEXT_BOOL(Eval
.Map2Vertex3
), NO_EXTRA
},
616 { GL_MAP2_VERTEX_4
, CONTEXT_BOOL(Eval
.Map2Vertex4
), NO_EXTRA
},
617 { GL_MAP_COLOR
, CONTEXT_BOOL(Pixel
.MapColorFlag
), NO_EXTRA
},
618 { GL_MAP_STENCIL
, CONTEXT_BOOL(Pixel
.MapStencilFlag
), NO_EXTRA
},
619 { GL_MAX_ATTRIB_STACK_DEPTH
, CONST(MAX_ATTRIB_STACK_DEPTH
), NO_EXTRA
},
620 { GL_MAX_CLIENT_ATTRIB_STACK_DEPTH
, CONST(MAX_CLIENT_ATTRIB_STACK_DEPTH
), NO_EXTRA
},
622 { GL_MAX_EVAL_ORDER
, CONST(MAX_EVAL_ORDER
), NO_EXTRA
},
623 { GL_MAX_LIST_NESTING
, CONST(MAX_LIST_NESTING
), NO_EXTRA
},
624 { GL_MAX_NAME_STACK_DEPTH
, CONST(MAX_NAME_STACK_DEPTH
), NO_EXTRA
},
625 { GL_MAX_PIXEL_MAP_TABLE
, CONST(MAX_PIXEL_MAP_TABLE
), NO_EXTRA
},
626 { GL_NAME_STACK_DEPTH
, CONTEXT_INT(Select
.NameStackDepth
), NO_EXTRA
},
627 { GL_PACK_LSB_FIRST
, CONTEXT_BOOL(Pack
.LsbFirst
), NO_EXTRA
},
628 { GL_PACK_ROW_LENGTH
, CONTEXT_INT(Pack
.RowLength
), NO_EXTRA
},
629 { GL_PACK_SKIP_PIXELS
, CONTEXT_INT(Pack
.SkipPixels
), NO_EXTRA
},
630 { GL_PACK_SKIP_ROWS
, CONTEXT_INT(Pack
.SkipRows
), NO_EXTRA
},
631 { GL_PACK_SWAP_BYTES
, CONTEXT_BOOL(Pack
.SwapBytes
), NO_EXTRA
},
632 { GL_PACK_IMAGE_HEIGHT_EXT
, CONTEXT_INT(Pack
.ImageHeight
), NO_EXTRA
},
633 { GL_PACK_INVERT_MESA
, CONTEXT_BOOL(Pack
.Invert
), NO_EXTRA
},
634 { GL_PIXEL_MAP_A_TO_A_SIZE
, CONTEXT_INT(PixelMaps
.AtoA
.Size
), NO_EXTRA
},
635 { GL_PIXEL_MAP_B_TO_B_SIZE
, CONTEXT_INT(PixelMaps
.BtoB
.Size
), NO_EXTRA
},
636 { GL_PIXEL_MAP_G_TO_G_SIZE
, CONTEXT_INT(PixelMaps
.GtoG
.Size
), NO_EXTRA
},
637 { GL_PIXEL_MAP_I_TO_A_SIZE
, CONTEXT_INT(PixelMaps
.ItoA
.Size
), NO_EXTRA
},
638 { GL_PIXEL_MAP_I_TO_B_SIZE
, CONTEXT_INT(PixelMaps
.ItoB
.Size
), NO_EXTRA
},
639 { GL_PIXEL_MAP_I_TO_G_SIZE
, CONTEXT_INT(PixelMaps
.ItoG
.Size
), NO_EXTRA
},
640 { GL_PIXEL_MAP_I_TO_I_SIZE
, CONTEXT_INT(PixelMaps
.ItoI
.Size
), NO_EXTRA
},
641 { GL_PIXEL_MAP_I_TO_R_SIZE
, CONTEXT_INT(PixelMaps
.ItoR
.Size
), NO_EXTRA
},
642 { GL_PIXEL_MAP_R_TO_R_SIZE
, CONTEXT_INT(PixelMaps
.RtoR
.Size
), NO_EXTRA
},
643 { GL_PIXEL_MAP_S_TO_S_SIZE
, CONTEXT_INT(PixelMaps
.StoS
.Size
), NO_EXTRA
},
644 { GL_POINT_SIZE_GRANULARITY
, CONTEXT_FLOAT(Const
.PointSizeGranularity
), NO_EXTRA
},
645 { GL_POLYGON_MODE
, CONTEXT_ENUM2(Polygon
.FrontMode
), NO_EXTRA
},
646 { GL_POLYGON_OFFSET_BIAS_EXT
, CONTEXT_FLOAT(Polygon
.OffsetUnits
), NO_EXTRA
},
647 { GL_POLYGON_OFFSET_POINT
, CONTEXT_BOOL(Polygon
.OffsetPoint
), NO_EXTRA
},
648 { GL_POLYGON_OFFSET_LINE
, CONTEXT_BOOL(Polygon
.OffsetLine
), NO_EXTRA
},
649 { GL_POLYGON_SMOOTH
, CONTEXT_BOOL(Polygon
.SmoothFlag
), NO_EXTRA
},
650 { GL_POLYGON_SMOOTH_HINT
, CONTEXT_ENUM(Hint
.PolygonSmooth
), NO_EXTRA
},
651 { GL_POLYGON_STIPPLE
, CONTEXT_BOOL(Polygon
.StippleFlag
), NO_EXTRA
},
652 { GL_READ_BUFFER
, LOC_CUSTOM
, TYPE_ENUM
, NO_OFFSET
, NO_EXTRA
},
653 { GL_RED_BIAS
, CONTEXT_FLOAT(Pixel
.RedBias
), NO_EXTRA
},
654 { GL_RED_SCALE
, CONTEXT_FLOAT(Pixel
.RedScale
), NO_EXTRA
},
655 { GL_RENDER_MODE
, CONTEXT_ENUM(RenderMode
), NO_EXTRA
},
656 { GL_RGBA_MODE
, CONST(1), NO_EXTRA
},
657 { GL_SELECTION_BUFFER_SIZE
, CONTEXT_INT(Select
.BufferSize
), NO_EXTRA
},
659 { GL_STEREO
, BUFFER_INT(Visual
.stereoMode
), NO_EXTRA
},
661 { GL_TEXTURE_1D
, LOC_CUSTOM
, TYPE_BOOLEAN
, NO_OFFSET
, NO_EXTRA
},
662 { GL_TEXTURE_3D
, LOC_CUSTOM
, TYPE_BOOLEAN
, NO_OFFSET
, NO_EXTRA
},
664 { GL_TEXTURE_BINDING_1D
, LOC_CUSTOM
, TYPE_INT
, TEXTURE_1D_INDEX
, NO_EXTRA
},
666 { GL_TEXTURE_GEN_S
, LOC_TEXUNIT
, TYPE_BIT_0
,
667 offsetof(struct gl_texture_unit
, TexGenEnabled
), NO_EXTRA
},
668 { GL_TEXTURE_GEN_T
, LOC_TEXUNIT
, TYPE_BIT_1
,
669 offsetof(struct gl_texture_unit
, TexGenEnabled
), NO_EXTRA
},
670 { GL_TEXTURE_GEN_R
, LOC_TEXUNIT
, TYPE_BIT_2
,
671 offsetof(struct gl_texture_unit
, TexGenEnabled
), NO_EXTRA
},
672 { GL_TEXTURE_GEN_Q
, LOC_TEXUNIT
, TYPE_BIT_3
,
673 offsetof(struct gl_texture_unit
, TexGenEnabled
), NO_EXTRA
},
674 { GL_UNPACK_LSB_FIRST
, CONTEXT_BOOL(Unpack
.LsbFirst
), NO_EXTRA
},
675 { GL_UNPACK_ROW_LENGTH
, CONTEXT_INT(Unpack
.RowLength
), NO_EXTRA
},
676 { GL_UNPACK_SKIP_PIXELS
, CONTEXT_INT(Unpack
.SkipPixels
), NO_EXTRA
},
677 { GL_UNPACK_SKIP_ROWS
, CONTEXT_INT(Unpack
.SkipRows
), NO_EXTRA
},
678 { GL_UNPACK_SWAP_BYTES
, CONTEXT_BOOL(Unpack
.SwapBytes
), NO_EXTRA
},
679 { GL_UNPACK_SKIP_IMAGES_EXT
, CONTEXT_INT(Unpack
.SkipImages
), NO_EXTRA
},
680 { GL_UNPACK_IMAGE_HEIGHT_EXT
, CONTEXT_INT(Unpack
.ImageHeight
), NO_EXTRA
},
681 { GL_ZOOM_X
, CONTEXT_FLOAT(Pixel
.ZoomX
), NO_EXTRA
},
682 { GL_ZOOM_Y
, CONTEXT_FLOAT(Pixel
.ZoomY
), NO_EXTRA
},
685 { GL_VERTEX_ARRAY_COUNT_EXT
, CONST(0), NO_EXTRA
},
686 { GL_NORMAL_ARRAY_COUNT_EXT
, CONST(0), NO_EXTRA
},
687 { GL_COLOR_ARRAY_COUNT_EXT
, CONST(0), NO_EXTRA
},
688 { GL_INDEX_ARRAY
, ARRAY_BOOL(VertexAttrib
[VERT_ATTRIB_COLOR_INDEX
].Enabled
), NO_EXTRA
},
689 { GL_INDEX_ARRAY_TYPE
, ARRAY_ENUM(VertexAttrib
[VERT_ATTRIB_COLOR_INDEX
].Type
), NO_EXTRA
},
690 { GL_INDEX_ARRAY_STRIDE
, ARRAY_INT(VertexAttrib
[VERT_ATTRIB_COLOR_INDEX
].Stride
), NO_EXTRA
},
691 { GL_INDEX_ARRAY_COUNT_EXT
, CONST(0), NO_EXTRA
},
692 { GL_TEXTURE_COORD_ARRAY_COUNT_EXT
, CONST(0), NO_EXTRA
},
693 { GL_EDGE_FLAG_ARRAY
, ARRAY_BOOL(VertexAttrib
[VERT_ATTRIB_EDGEFLAG
].Enabled
), NO_EXTRA
},
694 { GL_EDGE_FLAG_ARRAY_STRIDE
, ARRAY_INT(VertexAttrib
[VERT_ATTRIB_EDGEFLAG
].Stride
), NO_EXTRA
},
695 { GL_EDGE_FLAG_ARRAY_COUNT_EXT
, CONST(0), NO_EXTRA
},
697 /* GL_EXT_compiled_vertex_array */
698 { GL_ARRAY_ELEMENT_LOCK_FIRST_EXT
, CONTEXT_INT(Array
.LockFirst
),
699 extra_EXT_compiled_vertex_array
},
700 { GL_ARRAY_ELEMENT_LOCK_COUNT_EXT
, CONTEXT_INT(Array
.LockCount
),
701 extra_EXT_compiled_vertex_array
},
703 /* GL_ARB_transpose_matrix */
704 { GL_TRANSPOSE_MODELVIEW_MATRIX_ARB
,
705 CONTEXT_MATRIX_T(ModelviewMatrixStack
), NO_EXTRA
},
706 { GL_TRANSPOSE_PROJECTION_MATRIX_ARB
,
707 CONTEXT_MATRIX_T(ProjectionMatrixStack
.Top
), NO_EXTRA
},
708 { GL_TRANSPOSE_TEXTURE_MATRIX_ARB
, CONTEXT_MATRIX_T(TextureMatrixStack
), NO_EXTRA
},
710 /* GL_EXT_secondary_color */
711 { GL_CURRENT_SECONDARY_COLOR_EXT
,
712 CONTEXT_FIELD(Current
.Attrib
[VERT_ATTRIB_COLOR1
][0], TYPE_FLOATN_4
),
713 extra_EXT_secondary_color_flush_current
},
714 { GL_SECONDARY_COLOR_ARRAY_EXT
, ARRAY_BOOL(VertexAttrib
[VERT_ATTRIB_COLOR1
].Enabled
),
715 extra_EXT_secondary_color
},
716 { GL_SECONDARY_COLOR_ARRAY_TYPE_EXT
, ARRAY_ENUM(VertexAttrib
[VERT_ATTRIB_COLOR1
].Type
),
717 extra_EXT_secondary_color
},
718 { GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT
, ARRAY_INT(VertexAttrib
[VERT_ATTRIB_COLOR1
].Stride
),
719 extra_EXT_secondary_color
},
720 { GL_SECONDARY_COLOR_ARRAY_SIZE_EXT
, ARRAY_INT(VertexAttrib
[VERT_ATTRIB_COLOR1
].Size
),
721 extra_EXT_secondary_color
},
723 /* GL_EXT_fog_coord */
724 { GL_CURRENT_FOG_COORDINATE_EXT
,
725 CONTEXT_FLOAT(Current
.Attrib
[VERT_ATTRIB_FOG
][0]),
726 extra_EXT_fog_coord_flush_current
},
727 { GL_FOG_COORDINATE_ARRAY_EXT
, ARRAY_BOOL(VertexAttrib
[VERT_ATTRIB_FOG
].Enabled
),
728 extra_EXT_fog_coord
},
729 { GL_FOG_COORDINATE_ARRAY_TYPE_EXT
, ARRAY_ENUM(VertexAttrib
[VERT_ATTRIB_FOG
].Type
),
730 extra_EXT_fog_coord
},
731 { GL_FOG_COORDINATE_ARRAY_STRIDE_EXT
, ARRAY_INT(VertexAttrib
[VERT_ATTRIB_FOG
].Stride
),
732 extra_EXT_fog_coord
},
733 { GL_FOG_COORDINATE_SOURCE_EXT
, CONTEXT_ENUM(Fog
.FogCoordinateSource
),
734 extra_EXT_fog_coord
},
736 /* GL_NV_fog_distance */
737 { GL_FOG_DISTANCE_MODE_NV
, CONTEXT_ENUM(Fog
.FogDistanceMode
),
738 extra_NV_fog_distance
},
740 /* GL_IBM_rasterpos_clip */
741 { GL_RASTER_POSITION_UNCLIPPED_IBM
,
742 CONTEXT_BOOL(Transform
.RasterPositionUnclipped
),
743 extra_IBM_rasterpos_clip
},
745 /* GL_NV_point_sprite */
746 { GL_POINT_SPRITE_R_MODE_NV
,
747 CONTEXT_ENUM(Point
.SpriteRMode
), extra_NV_point_sprite
},
748 { GL_POINT_SPRITE_COORD_ORIGIN
, CONTEXT_ENUM(Point
.SpriteOrigin
),
749 extra_NV_point_sprite_ARB_point_sprite
},
751 /* GL_EXT_stencil_two_side */
752 { GL_STENCIL_TEST_TWO_SIDE_EXT
, CONTEXT_BOOL(Stencil
.TestTwoSide
),
753 extra_EXT_stencil_two_side
},
754 { GL_ACTIVE_STENCIL_FACE_EXT
, LOC_CUSTOM
, TYPE_ENUM
, NO_OFFSET
, NO_EXTRA
},
756 /* GL_NV_light_max_exponent */
757 { GL_MAX_SHININESS_NV
, CONTEXT_FLOAT(Const
.MaxShininess
),
758 extra_NV_light_max_exponent
},
759 { GL_MAX_SPOT_EXPONENT_NV
, CONTEXT_FLOAT(Const
.MaxSpotExponent
),
760 extra_NV_light_max_exponent
},
762 /* GL_ARB_vertex_buffer_object */
763 { GL_INDEX_ARRAY_BUFFER_BINDING_ARB
, LOC_CUSTOM
, TYPE_INT
,
764 offsetof(struct gl_array_object
, VertexAttrib
[VERT_ATTRIB_COLOR_INDEX
].BufferObj
), NO_EXTRA
},
765 { GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB
, LOC_CUSTOM
, TYPE_INT
,
766 offsetof(struct gl_array_object
, VertexAttrib
[VERT_ATTRIB_EDGEFLAG
].BufferObj
), NO_EXTRA
},
767 { GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB
, LOC_CUSTOM
, TYPE_INT
,
768 offsetof(struct gl_array_object
, VertexAttrib
[VERT_ATTRIB_COLOR1
].BufferObj
), NO_EXTRA
},
769 { GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB
, LOC_CUSTOM
, TYPE_INT
,
770 offsetof(struct gl_array_object
, VertexAttrib
[VERT_ATTRIB_FOG
].BufferObj
), NO_EXTRA
},
772 /* GL_EXT_pixel_buffer_object */
773 { GL_PIXEL_PACK_BUFFER_BINDING_EXT
, LOC_CUSTOM
, TYPE_INT
, 0,
774 extra_EXT_pixel_buffer_object
},
775 { GL_PIXEL_UNPACK_BUFFER_BINDING_EXT
, LOC_CUSTOM
, TYPE_INT
, 0,
776 extra_EXT_pixel_buffer_object
},
778 /* GL_EXT_depth_bounds_test */
779 { GL_DEPTH_BOUNDS_TEST_EXT
, CONTEXT_BOOL(Depth
.BoundsTest
),
780 extra_EXT_depth_bounds_test
},
781 { GL_DEPTH_BOUNDS_EXT
, CONTEXT_FLOAT2(Depth
.BoundsMin
),
782 extra_EXT_depth_bounds_test
},
784 /* GL_APPLE_vertex_array_object */
785 { GL_VERTEX_ARRAY_BINDING_APPLE
, ARRAY_INT(Name
),
786 extra_APPLE_vertex_array_object
},
788 /* GL_EXT_texture_integer */
789 { GL_RGBA_INTEGER_MODE_EXT
, BUFFER_BOOL(_IntegerColor
),
790 extra_EXT_texture_integer
},
793 { GL_NUM_EXTENSIONS
, LOC_CUSTOM
, TYPE_INT
, 0, extra_version_30
},
794 { GL_MAJOR_VERSION
, CONTEXT_INT(VersionMajor
), extra_version_30
},
795 { GL_MINOR_VERSION
, CONTEXT_INT(VersionMinor
), extra_version_30
},
796 { GL_CONTEXT_FLAGS
, CONTEXT_INT(Const
.ContextFlags
), extra_version_30
},
800 { GL_CONTEXT_PROFILE_MASK
, CONTEXT_INT(Const
.ProfileMask
),
803 /* GL_ARB_robustness */
804 { GL_RESET_NOTIFICATION_STRATEGY_ARB
, CONTEXT_ENUM(Const
.ResetStrategy
), NO_EXTRA
},
807 /* All we need now is a way to look up the value struct from the enum.
808 * The code generated by gcc for the old generated big switch
809 * statement is a big, balanced, open coded if/else tree, essentially
810 * an unrolled binary search. It would be natural to sort the new
811 * enum table and use bsearch(), but we will use a read-only hash
812 * table instead. bsearch() has a nice guaranteed worst case
813 * performance, but we're also guaranteed to hit that worst case
814 * (log2(n) iterations) for about half the enums. Instead, using an
815 * open addressing hash table, we can find the enum on the first try
816 * for 80% of the enums, 1 collision for 10% and never more than 5
817 * collisions for any enum (typical numbers). And the code is very
818 * simple, even though it feels a little magic. */
820 static unsigned short table
[1024];
821 static const int prime_factor
= 89, prime_step
= 281;
825 print_table_stats(void)
827 int i
, j
, collisions
[11], count
, hash
, mask
;
828 const struct value_desc
*d
;
831 mask
= Elements(table
) - 1;
832 memset(collisions
, 0, sizeof collisions
);
834 for (i
= 0; i
< Elements(table
); i
++) {
838 d
= &values
[table
[i
]];
839 hash
= (d
->pname
* prime_factor
);
842 if (values
[table
[hash
& mask
]].pname
== d
->pname
)
854 printf("number of enums: %d (total %d)\n", count
, Elements(values
));
855 for (i
= 0; i
< Elements(collisions
) - 1; i
++)
856 if (collisions
[i
] > 0)
857 printf(" %d enums with %d %scollisions\n",
858 collisions
[i
], i
, i
== 10 ? "or more " : "");
863 * Initialize the enum hash for a given API
865 * This is called from one_time_init() to insert the enum values that
866 * are valid for the API in question into the enum hash table.
868 * \param the current context, for determining the API in question
870 void _mesa_init_get_hash(struct gl_context
*ctx
)
872 int i
, hash
, index
, mask
;
874 mask
= Elements(table
) - 1;
876 for (i
= 0; i
< Elements(values
); i
++) {
878 hash
= (values
[i
].pname
* prime_factor
) & mask
;
895 * Handle irregular enums
897 * Some values don't conform to the "well-known type at context
898 * pointer + offset" pattern, so we have this function to catch all
899 * the corner cases. Typically, it's a computed value or a one-off
900 * pointer to a custom struct or something.
902 * In this case we can't return a pointer to the value, so we'll have
903 * to use the temporary variable 'v' declared back in the calling
904 * glGet*v() function to store the result.
906 * \param ctx the current context
907 * \param d the struct value_desc that describes the enum
908 * \param v pointer to the tmp declared in the calling glGet*v() function
911 find_custom_value(struct gl_context
*ctx
, const struct value_desc
*d
, union value
*v
)
913 struct gl_buffer_object
**buffer_obj
;
914 struct gl_client_array
*array
;
921 case GL_TEXTURE_CUBE_MAP_ARB
:
922 v
->value_bool
= _mesa_IsEnabled(d
->pname
);
925 case GL_LINE_STIPPLE_PATTERN
:
926 /* This is the only GLushort, special case it here by promoting
927 * to an int rather than introducing a new type. */
928 v
->value_int
= ctx
->Line
.StipplePattern
;
931 case GL_CURRENT_RASTER_TEXTURE_COORDS
:
932 v
->value_float_4
[0] = ctx
->Current
.RasterTexCoords
[0];
933 v
->value_float_4
[1] = ctx
->Current
.RasterTexCoords
[1];
934 v
->value_float_4
[2] = ctx
->Current
.RasterTexCoords
[2];
935 v
->value_float_4
[3] = ctx
->Current
.RasterTexCoords
[3];
938 case GL_CURRENT_TEXTURE_COORDS
:
939 v
->value_float_4
[0] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX
][0];
940 v
->value_float_4
[1] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX
][1];
941 v
->value_float_4
[2] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX
][2];
942 v
->value_float_4
[3] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX
][3];
945 case GL_COLOR_WRITEMASK
:
946 v
->value_int_4
[0] = ctx
->Color
.ColorMask
[RCOMP
] ? 1 : 0;
947 v
->value_int_4
[1] = ctx
->Color
.ColorMask
[GCOMP
] ? 1 : 0;
948 v
->value_int_4
[2] = ctx
->Color
.ColorMask
[BCOMP
] ? 1 : 0;
949 v
->value_int_4
[3] = ctx
->Color
.ColorMask
[ACOMP
] ? 1 : 0;
953 v
->value_bool
= ctx
->Current
.Attrib
[VERT_ATTRIB_EDGEFLAG
][0] == 1.0;
957 v
->value_enum
= ctx
->ReadBuffer
->ColorReadBuffer
;
960 case GL_MAP2_GRID_DOMAIN
:
961 v
->value_float_4
[0] = ctx
->Eval
.MapGrid2u1
;
962 v
->value_float_4
[1] = ctx
->Eval
.MapGrid2u2
;
963 v
->value_float_4
[2] = ctx
->Eval
.MapGrid2v1
;
964 v
->value_float_4
[3] = ctx
->Eval
.MapGrid2v2
;
967 case GL_TEXTURE_STACK_DEPTH
:
968 v
->value_int
= ctx
->TextureMatrixStack
.Depth
+ 1;
970 case GL_TEXTURE_MATRIX
:
971 v
->value_matrix
= ctx
->TextureMatrixStack
.Top
;
974 case GL_TEXTURE_COORD_ARRAY
:
975 case GL_TEXTURE_COORD_ARRAY_SIZE
:
976 case GL_TEXTURE_COORD_ARRAY_TYPE
:
977 case GL_TEXTURE_COORD_ARRAY_STRIDE
:
978 array
= &ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_TEX
];
979 v
->value_int
= *(GLuint
*) ((char *) array
+ d
->offset
);
982 case GL_MODELVIEW_STACK_DEPTH
:
983 case GL_PROJECTION_STACK_DEPTH
:
984 v
->value_int
= *(GLint
*) ((char *) ctx
+ d
->offset
) + 1;
987 case GL_MAX_TEXTURE_SIZE
:
988 case GL_MAX_3D_TEXTURE_SIZE
:
989 case GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB
:
990 p
= (GLuint
*) ((char *) ctx
+ d
->offset
);
991 v
->value_int
= 1 << (*p
- 1);
995 v
->value_int_4
[0] = ctx
->Scissor
.X
;
996 v
->value_int_4
[1] = ctx
->Scissor
.Y
;
997 v
->value_int_4
[2] = ctx
->Scissor
.Width
;
998 v
->value_int_4
[3] = ctx
->Scissor
.Height
;
1003 ctx
->ListState
.CurrentList
? ctx
->ListState
.CurrentList
->Name
: 0;
1006 if (!ctx
->CompileFlag
)
1008 else if (ctx
->ExecuteFlag
)
1009 v
->value_enum
= GL_COMPILE_AND_EXECUTE
;
1011 v
->value_enum
= GL_COMPILE
;
1015 v
->value_int_4
[0] = ctx
->Viewport
.X
;
1016 v
->value_int_4
[1] = ctx
->Viewport
.Y
;
1017 v
->value_int_4
[2] = ctx
->Viewport
.Width
;
1018 v
->value_int_4
[3] = ctx
->Viewport
.Height
;
1021 case GL_ACTIVE_STENCIL_FACE_EXT
:
1022 v
->value_enum
= ctx
->Stencil
.ActiveFace
? GL_BACK
: GL_FRONT
;
1025 case GL_STENCIL_FAIL
:
1026 v
->value_enum
= ctx
->Stencil
.FailFunc
[ctx
->Stencil
.ActiveFace
];
1028 case GL_STENCIL_FUNC
:
1029 v
->value_enum
= ctx
->Stencil
.Function
[ctx
->Stencil
.ActiveFace
];
1031 case GL_STENCIL_PASS_DEPTH_FAIL
:
1032 v
->value_enum
= ctx
->Stencil
.ZFailFunc
[ctx
->Stencil
.ActiveFace
];
1034 case GL_STENCIL_PASS_DEPTH_PASS
:
1035 v
->value_enum
= ctx
->Stencil
.ZPassFunc
[ctx
->Stencil
.ActiveFace
];
1037 case GL_STENCIL_REF
:
1038 v
->value_int
= ctx
->Stencil
.Ref
[ctx
->Stencil
.ActiveFace
];
1040 case GL_STENCIL_VALUE_MASK
:
1041 v
->value_int
= ctx
->Stencil
.ValueMask
[ctx
->Stencil
.ActiveFace
];
1043 case GL_STENCIL_WRITEMASK
:
1044 v
->value_int
= ctx
->Stencil
.WriteMask
[ctx
->Stencil
.ActiveFace
];
1047 case GL_NUM_EXTENSIONS
:
1048 v
->value_int
= _mesa_get_extension_count(ctx
);
1051 case GL_IMPLEMENTATION_COLOR_READ_TYPE_OES
:
1052 v
->value_int
= _mesa_get_color_read_type(ctx
);
1054 case GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES
:
1055 v
->value_int
= _mesa_get_color_read_format(ctx
);
1058 case GL_CURRENT_MATRIX_STACK_DEPTH_ARB
:
1059 v
->value_int
= ctx
->CurrentStack
->Depth
+ 1;
1061 case GL_CURRENT_MATRIX_ARB
:
1062 case GL_TRANSPOSE_CURRENT_MATRIX_ARB
:
1063 v
->value_matrix
= ctx
->CurrentStack
->Top
;
1066 /* Various object names */
1068 case GL_TEXTURE_BINDING_1D
:
1069 case GL_TEXTURE_BINDING_2D
:
1070 case GL_TEXTURE_BINDING_3D
:
1071 case GL_TEXTURE_BINDING_CUBE_MAP_ARB
:
1073 ctx
->Texture
.Unit
.CurrentTex
[d
->offset
]->Name
;
1076 /* GL_ARB_vertex_buffer_object */
1077 case GL_VERTEX_ARRAY_BUFFER_BINDING_ARB
:
1078 case GL_NORMAL_ARRAY_BUFFER_BINDING_ARB
:
1079 case GL_COLOR_ARRAY_BUFFER_BINDING_ARB
:
1080 case GL_INDEX_ARRAY_BUFFER_BINDING_ARB
:
1081 case GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB
:
1082 case GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB
:
1083 case GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB
:
1084 buffer_obj
= (struct gl_buffer_object
**)
1085 ((char *) ctx
->Array
.ArrayObj
+ d
->offset
);
1086 v
->value_int
= (*buffer_obj
)->Name
;
1088 case GL_ARRAY_BUFFER_BINDING_ARB
:
1089 v
->value_int
= ctx
->Array
.ArrayBufferObj
->Name
;
1091 case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB
:
1093 ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_TEX
].BufferObj
->Name
;
1095 case GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB
:
1096 v
->value_int
= ctx
->Array
.ArrayObj
->ElementArrayBufferObj
->Name
;
1099 case GL_PIXEL_PACK_BUFFER_BINDING_EXT
:
1100 v
->value_int
= ctx
->Pack
.BufferObj
->Name
;
1102 case GL_PIXEL_UNPACK_BUFFER_BINDING_EXT
:
1103 v
->value_int
= ctx
->Unpack
.BufferObj
->Name
;
1105 case GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES
:
1106 v
->value_int
= ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_POINT_SIZE
].BufferObj
->Name
;
1110 COPY_4FV(v
->value_float_4
, ctx
->Fog
.Color
);
1112 case GL_COLOR_CLEAR_VALUE
:
1113 v
->value_float_4
[0] = ctx
->Color
.ClearColor
.f
[0], 0.0F
, 1.0F
;
1114 v
->value_float_4
[1] = ctx
->Color
.ClearColor
.f
[1], 0.0F
, 1.0F
;
1115 v
->value_float_4
[2] = ctx
->Color
.ClearColor
.f
[2], 0.0F
, 1.0F
;
1116 v
->value_float_4
[3] = ctx
->Color
.ClearColor
.f
[3], 0.0F
, 1.0F
;
1118 case GL_BLEND_COLOR_EXT
:
1119 COPY_4FV(v
->value_float_4
, ctx
->Color
.BlendColor
);
1121 case GL_ALPHA_TEST_REF
:
1122 v
->value_float
= ctx
->Color
.AlphaRef
;
1128 * Check extra constraints on a struct value_desc descriptor
1130 * If a struct value_desc has a non-NULL extra pointer, it means that
1131 * there are a number of extra constraints to check or actions to
1132 * perform. The extras is just an integer array where each integer
1133 * encode different constraints or actions.
1135 * \param ctx current context
1136 * \param func name of calling glGet*v() function for error reporting
1137 * \param d the struct value_desc that has the extra constraints
1139 * \return GL_FALSE if one of the constraints was not satisfied,
1140 * otherwise GL_TRUE.
1143 check_extra(struct gl_context
*ctx
, const char *func
, const struct value_desc
*d
)
1145 const GLuint version
= ctx
->VersionMajor
* 10 + ctx
->VersionMinor
;
1151 for (e
= d
->extra
; *e
!= EXTRA_END
; e
++)
1153 case EXTRA_VERSION_30
:
1154 if (version
>= 30) {
1159 case EXTRA_VERSION_31
:
1160 if (version
>= 31) {
1165 case EXTRA_VERSION_32
:
1166 if (version
>= 32) {
1171 case EXTRA_NEW_BUFFERS
:
1172 if (ctx
->NewState
& _NEW_BUFFERS
)
1173 _mesa_update_state(ctx
);
1175 case EXTRA_FLUSH_CURRENT
:
1176 FLUSH_CURRENT(ctx
, 0);
1178 case EXTRA_VALID_CLIP_DISTANCE
:
1179 if (d
->pname
- GL_CLIP_DISTANCE0
>= ctx
->Const
.MaxClipPlanes
) {
1180 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(clip distance %u)",
1181 func
, d
->pname
- GL_CLIP_DISTANCE0
);
1187 default: /* *e is a offset into the extension struct */
1189 if (*(GLboolean
*) ((char *) &ctx
->Extensions
+ *e
))
1194 if (total
> 0 && enabled
== 0) {
1195 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(pname=%s)", func
,
1196 _mesa_lookup_enum_by_nr(d
->pname
));
1203 static const struct value_desc error_value
=
1204 { 0, 0, TYPE_INVALID
, NO_OFFSET
, NO_EXTRA
};
1207 * Find the struct value_desc corresponding to the enum 'pname'.
1209 * We hash the enum value to get an index into the 'table' array,
1210 * which holds the index in the 'values' array of struct value_desc.
1211 * Once we've found the entry, we do the extra checks, if any, then
1212 * look up the value and return a pointer to it.
1214 * If the value has to be computed (for example, it's the result of a
1215 * function call or we need to add 1 to it), we use the tmp 'v' to
1218 * \param func name of glGet*v() func for error reporting
1219 * \param pname the enum value we're looking up
1220 * \param p is were we return the pointer to the value
1221 * \param v a tmp union value variable in the calling glGet*v() function
1223 * \return the struct value_desc corresponding to the enum or a struct
1224 * value_desc of TYPE_INVALID if not found. This lets the calling
1225 * glGet*v() function jump right into a switch statement and
1226 * handle errors there instead of having to check for NULL.
1228 static const struct value_desc
*
1229 find_value(const char *func
, GLenum pname
, void **p
, union value
*v
)
1231 GET_CURRENT_CONTEXT(ctx
);
1232 struct gl_texture_unit
*unit
;
1234 const struct value_desc
*d
;
1236 mask
= Elements(table
) - 1;
1237 hash
= (pname
* prime_factor
);
1239 d
= &values
[table
[hash
& mask
]];
1241 if (likely(d
->pname
== pname
))
1247 if (unlikely(d
->extra
&& !check_extra(ctx
, func
, d
)))
1248 return &error_value
;
1250 switch (d
->location
) {
1252 *p
= ((char *) ctx
->DrawBuffer
+ d
->offset
);
1255 *p
= ((char *) ctx
+ d
->offset
);
1258 *p
= ((char *) ctx
->Array
.ArrayObj
+ d
->offset
);
1261 unit
= &ctx
->Texture
.Unit
;
1262 *p
= ((char *) unit
+ d
->offset
);
1265 find_custom_value(ctx
, d
, v
);
1273 /* silence warning */
1274 return &error_value
;
1277 static const int transpose
[] = {
1285 _mesa_GetBooleanv(GLenum pname
, GLboolean
*params
)
1287 const struct value_desc
*d
;
1292 GET_CURRENT_CONTEXT(ctx
);
1294 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1296 d
= find_value("glGetBooleanv", pname
, &p
, &v
);
1301 params
[0] = INT_TO_BOOLEAN(d
->offset
);
1306 params
[3] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[3]);
1309 params
[2] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[2]);
1312 params
[1] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[1]);
1315 params
[0] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[0]);
1319 params
[0] = FLOAT_TO_BOOLEAN(((GLdouble
*) p
)[0]);
1323 params
[3] = INT_TO_BOOLEAN(((GLint
*) p
)[3]);
1325 params
[2] = INT_TO_BOOLEAN(((GLint
*) p
)[2]);
1328 params
[1] = INT_TO_BOOLEAN(((GLint
*) p
)[1]);
1331 params
[0] = INT_TO_BOOLEAN(((GLint
*) p
)[0]);
1335 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
1336 params
[i
] = INT_TO_BOOLEAN(v
.value_int_n
.ints
[i
]);
1340 params
[0] = INT64_TO_BOOLEAN(((GLint64
*) p
)[0]);
1344 params
[0] = ((GLboolean
*) p
)[0];
1348 m
= *(GLmatrix
**) p
;
1349 for (i
= 0; i
< 16; i
++)
1350 params
[i
] = FLOAT_TO_BOOLEAN(m
->m
[i
]);
1354 m
= *(GLmatrix
**) p
;
1355 for (i
= 0; i
< 16; i
++)
1356 params
[i
] = FLOAT_TO_BOOLEAN(m
->m
[transpose
[i
]]);
1367 shift
= d
->type
- TYPE_BIT_0
;
1368 params
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
1374 _mesa_GetFloatv(GLenum pname
, GLfloat
*params
)
1376 const struct value_desc
*d
;
1381 GET_CURRENT_CONTEXT(ctx
);
1383 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1385 d
= find_value("glGetFloatv", pname
, &p
, &v
);
1390 params
[0] = (GLfloat
) d
->offset
;
1395 params
[3] = ((GLfloat
*) p
)[3];
1398 params
[2] = ((GLfloat
*) p
)[2];
1401 params
[1] = ((GLfloat
*) p
)[1];
1404 params
[0] = ((GLfloat
*) p
)[0];
1408 params
[0] = ((GLdouble
*) p
)[0];
1412 params
[3] = (GLfloat
) (((GLint
*) p
)[3]);
1414 params
[2] = (GLfloat
) (((GLint
*) p
)[2]);
1417 params
[1] = (GLfloat
) (((GLint
*) p
)[1]);
1420 params
[0] = (GLfloat
) (((GLint
*) p
)[0]);
1424 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
1425 params
[i
] = INT_TO_FLOAT(v
.value_int_n
.ints
[i
]);
1429 params
[0] = ((GLint64
*) p
)[0];
1433 params
[0] = BOOLEAN_TO_FLOAT(*(GLboolean
*) p
);
1437 m
= *(GLmatrix
**) p
;
1438 for (i
= 0; i
< 16; i
++)
1439 params
[i
] = m
->m
[i
];
1443 m
= *(GLmatrix
**) p
;
1444 for (i
= 0; i
< 16; i
++)
1445 params
[i
] = m
->m
[transpose
[i
]];
1456 shift
= d
->type
- TYPE_BIT_0
;
1457 params
[0] = BOOLEAN_TO_FLOAT((*(GLbitfield
*) p
>> shift
) & 1);
1463 _mesa_GetIntegerv(GLenum pname
, GLint
*params
)
1465 const struct value_desc
*d
;
1470 GET_CURRENT_CONTEXT(ctx
);
1472 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1474 d
= find_value("glGetIntegerv", pname
, &p
, &v
);
1479 params
[0] = d
->offset
;
1483 params
[3] = IROUND(((GLfloat
*) p
)[3]);
1485 params
[2] = IROUND(((GLfloat
*) p
)[2]);
1487 params
[1] = IROUND(((GLfloat
*) p
)[1]);
1489 params
[0] = IROUND(((GLfloat
*) p
)[0]);
1493 params
[3] = FLOAT_TO_INT(((GLfloat
*) p
)[3]);
1495 params
[2] = FLOAT_TO_INT(((GLfloat
*) p
)[2]);
1497 params
[1] = FLOAT_TO_INT(((GLfloat
*) p
)[1]);
1499 params
[0] = FLOAT_TO_INT(((GLfloat
*) p
)[0]);
1503 params
[0] = FLOAT_TO_INT(((GLdouble
*) p
)[0]);
1507 params
[3] = ((GLint
*) p
)[3];
1509 params
[2] = ((GLint
*) p
)[2];
1512 params
[1] = ((GLint
*) p
)[1];
1515 params
[0] = ((GLint
*) p
)[0];
1519 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
1520 params
[i
] = v
.value_int_n
.ints
[i
];
1524 params
[0] = INT64_TO_INT(((GLint64
*) p
)[0]);
1528 params
[0] = BOOLEAN_TO_INT(*(GLboolean
*) p
);
1532 m
= *(GLmatrix
**) p
;
1533 for (i
= 0; i
< 16; i
++)
1534 params
[i
] = FLOAT_TO_INT(m
->m
[i
]);
1538 m
= *(GLmatrix
**) p
;
1539 for (i
= 0; i
< 16; i
++)
1540 params
[i
] = FLOAT_TO_INT(m
->m
[transpose
[i
]]);
1551 shift
= d
->type
- TYPE_BIT_0
;
1552 params
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
1559 _mesa_GetDoublev(GLenum pname
, GLdouble
*params
)
1561 const struct value_desc
*d
;
1566 GET_CURRENT_CONTEXT(ctx
);
1568 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1570 d
= find_value("glGetDoublev", pname
, &p
, &v
);
1575 params
[0] = d
->offset
;
1580 params
[3] = ((GLfloat
*) p
)[3];
1583 params
[2] = ((GLfloat
*) p
)[2];
1586 params
[1] = ((GLfloat
*) p
)[1];
1589 params
[0] = ((GLfloat
*) p
)[0];
1593 params
[0] = ((GLdouble
*) p
)[0];
1597 params
[3] = ((GLint
*) p
)[3];
1599 params
[2] = ((GLint
*) p
)[2];
1602 params
[1] = ((GLint
*) p
)[1];
1605 params
[0] = ((GLint
*) p
)[0];
1609 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
1610 params
[i
] = v
.value_int_n
.ints
[i
];
1614 params
[0] = ((GLint64
*) p
)[0];
1618 params
[0] = *(GLboolean
*) p
;
1622 m
= *(GLmatrix
**) p
;
1623 for (i
= 0; i
< 16; i
++)
1624 params
[i
] = m
->m
[i
];
1628 m
= *(GLmatrix
**) p
;
1629 for (i
= 0; i
< 16; i
++)
1630 params
[i
] = m
->m
[transpose
[i
]];
1641 shift
= d
->type
- TYPE_BIT_0
;
1642 params
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
1649 _mesa_GetFixedv(GLenum pname
, GLfixed
*params
)
1651 const struct value_desc
*d
;
1657 d
= find_value("glGetDoublev", pname
, &p
, &v
);
1662 params
[0] = INT_TO_FIXED(d
->offset
);
1667 params
[3] = FLOAT_TO_FIXED(((GLfloat
*) p
)[3]);
1670 params
[2] = FLOAT_TO_FIXED(((GLfloat
*) p
)[2]);
1673 params
[1] = FLOAT_TO_FIXED(((GLfloat
*) p
)[1]);
1676 params
[0] = FLOAT_TO_FIXED(((GLfloat
*) p
)[0]);
1680 params
[0] = FLOAT_TO_FIXED(((GLdouble
*) p
)[0]);
1684 params
[3] = INT_TO_FIXED(((GLint
*) p
)[3]);
1686 params
[2] = INT_TO_FIXED(((GLint
*) p
)[2]);
1689 params
[1] = INT_TO_FIXED(((GLint
*) p
)[1]);
1692 params
[0] = INT_TO_FIXED(((GLint
*) p
)[0]);
1696 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
1697 params
[i
] = INT_TO_FIXED(v
.value_int_n
.ints
[i
]);
1701 params
[0] = ((GLint64
*) p
)[0];
1705 params
[0] = BOOLEAN_TO_FIXED(((GLboolean
*) p
)[0]);
1709 m
= *(GLmatrix
**) p
;
1710 for (i
= 0; i
< 16; i
++)
1711 params
[i
] = FLOAT_TO_FIXED(m
->m
[i
]);
1715 m
= *(GLmatrix
**) p
;
1716 for (i
= 0; i
< 16; i
++)
1717 params
[i
] = FLOAT_TO_FIXED(m
->m
[transpose
[i
]]);
1728 shift
= d
->type
- TYPE_BIT_0
;
1729 params
[0] = BOOLEAN_TO_FIXED((*(GLbitfield
*) p
>> shift
) & 1);