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>
27 /* This is a table driven implemetation of the glGet*v() functions.
28 * The basic idea is that most getters just look up an int somewhere
29 * in struct gl_context and then convert it to a bool or float according to
30 * which of glGetIntegerv() glGetBooleanv() etc is being called.
31 * Instead of generating code to do this, we can just record the enum
32 * value and the offset into struct gl_context in an array of structs. Then
33 * in glGet*(), we lookup the struct for the enum in question, and use
34 * the offset to get the int we need.
36 * Sometimes we need to look up a float, a boolean, a bit in a
37 * bitfield, a matrix or other types instead, so we need to track the
38 * type of the value in struct gl_context. And sometimes the value isn't in
39 * struct gl_context but in the drawbuffer, the array object, current texture
40 * unit, or maybe it's a computed value. So we need to also track
41 * where or how to find the value. Finally, we sometimes need to
42 * check that one of a number of extensions are enabled, the GL
43 * version or flush or call _mesa_update_state(). This is done by
44 * attaching optional extra information to the value description
45 * struct, it's sort of like an array of opcodes that describe extra
48 * Putting all this together we end up with struct value_desc below,
49 * and with a couple of macros to help, the table of struct value_desc
50 * is about as concise as the specification in the old python script.
55 #define FLOAT_TO_BOOLEAN(X) ( (X) ? GL_TRUE : GL_FALSE )
56 #define FLOAT_TO_FIXED(F) ( ((F) * 65536.0f > INT_MAX) ? INT_MAX : \
57 ((F) * 65536.0f < INT_MIN) ? INT_MIN : \
58 (GLint) ((F) * 65536.0f) )
60 #define INT_TO_BOOLEAN(I) ( (I) ? GL_TRUE : GL_FALSE )
61 #define INT_TO_FIXED(I) ( ((I) > SHRT_MAX) ? INT_MAX : \
62 ((I) < SHRT_MIN) ? INT_MIN : \
63 (GLint) ((I) * 65536) )
65 #define INT64_TO_BOOLEAN(I) ( (I) ? GL_TRUE : GL_FALSE )
66 #define INT64_TO_INT(I) ( (GLint)((I > INT_MAX) ? INT_MAX : ((I < INT_MIN) ? INT_MIN : (I))) )
68 #define BOOLEAN_TO_INT(B) ( (GLint) (B) )
69 #define BOOLEAN_TO_INT64(B) ( (GLint64) (B) )
70 #define BOOLEAN_TO_FLOAT(B) ( (B) ? 1.0F : 0.0F )
71 #define BOOLEAN_TO_FIXED(B) ( (GLint) ((B) ? 1 : 0) << 16 )
73 #define ENUM_TO_INT64(E) ( (GLint64) (E) )
74 #define ENUM_TO_FIXED(E) (E)
109 enum value_location
{
123 EXTRA_VALID_TEXTURE_UNIT
,
124 EXTRA_VALID_CLIP_DISTANCE
,
128 #define NO_EXTRA NULL
133 GLubyte location
; /**< enum value_location */
134 GLubyte type
; /**< enum value_type */
141 GLfloat value_float_4
[4];
142 GLmatrix
*value_matrix
;
144 GLint value_int_4
[4];
148 /* Sigh, see GL_COMPRESSED_TEXTURE_FORMATS_ARB handling */
152 GLboolean value_bool
;
155 #define BUFFER_FIELD(field, type) \
156 LOC_BUFFER, type, offsetof(struct gl_framebuffer, field)
157 #define CONTEXT_FIELD(field, type) \
158 LOC_CONTEXT, type, offsetof(struct gl_context, field)
159 #define ARRAY_FIELD(field, type) \
160 LOC_ARRAY, type, offsetof(struct gl_array_attrib, field)
161 #define CONST(value) \
162 LOC_CONTEXT, TYPE_CONST, value
164 #define BUFFER_INT(field) BUFFER_FIELD(field, TYPE_INT)
165 #define BUFFER_ENUM(field) BUFFER_FIELD(field, TYPE_ENUM)
166 #define BUFFER_BOOL(field) BUFFER_FIELD(field, TYPE_BOOLEAN)
168 #define CONTEXT_INT(field) CONTEXT_FIELD(field, TYPE_INT)
169 #define CONTEXT_INT2(field) CONTEXT_FIELD(field, TYPE_INT_2)
170 #define CONTEXT_INT64(field) CONTEXT_FIELD(field, TYPE_INT64)
171 #define CONTEXT_ENUM(field) CONTEXT_FIELD(field, TYPE_ENUM)
172 #define CONTEXT_ENUM2(field) CONTEXT_FIELD(field, TYPE_ENUM_2)
173 #define CONTEXT_BOOL(field) CONTEXT_FIELD(field, TYPE_BOOLEAN)
174 #define CONTEXT_BIT0(field) CONTEXT_FIELD(field, TYPE_BIT_0)
175 #define CONTEXT_BIT1(field) CONTEXT_FIELD(field, TYPE_BIT_1)
176 #define CONTEXT_BIT2(field) CONTEXT_FIELD(field, TYPE_BIT_2)
177 #define CONTEXT_BIT3(field) CONTEXT_FIELD(field, TYPE_BIT_3)
178 #define CONTEXT_BIT4(field) CONTEXT_FIELD(field, TYPE_BIT_4)
179 #define CONTEXT_BIT5(field) CONTEXT_FIELD(field, TYPE_BIT_5)
180 #define CONTEXT_BIT6(field) CONTEXT_FIELD(field, TYPE_BIT_6)
181 #define CONTEXT_BIT7(field) CONTEXT_FIELD(field, TYPE_BIT_7)
182 #define CONTEXT_FLOAT(field) CONTEXT_FIELD(field, TYPE_FLOAT)
183 #define CONTEXT_FLOAT2(field) CONTEXT_FIELD(field, TYPE_FLOAT_2)
184 #define CONTEXT_FLOAT3(field) CONTEXT_FIELD(field, TYPE_FLOAT_3)
185 #define CONTEXT_FLOAT4(field) CONTEXT_FIELD(field, TYPE_FLOAT_4)
186 #define CONTEXT_MATRIX(field) CONTEXT_FIELD(field, TYPE_MATRIX)
187 #define CONTEXT_MATRIX_T(field) CONTEXT_FIELD(field, TYPE_MATRIX_T)
189 #define ARRAY_INT(field) ARRAY_FIELD(field, TYPE_INT)
190 #define ARRAY_ENUM(field) ARRAY_FIELD(field, TYPE_ENUM)
191 #define ARRAY_BOOL(field) ARRAY_FIELD(field, TYPE_BOOLEAN)
194 offsetof(struct gl_extensions, f)
196 #define EXTRA_EXT(e) \
197 static const int extra_##e[] = { \
201 #define EXTRA_EXT2(e1, e2) \
202 static const int extra_##e1##_##e2[] = { \
203 EXT(e1), EXT(e2), EXTRA_END \
206 /* The 'extra' mechanism is a way to specify extra checks (such as
207 * extensions or specific gl versions) or actions (flush current, new
208 * buffers) that we need to do before looking up an enum. We need to
209 * declare them all up front so we can refer to them in the value_desc
212 static const int extra_new_buffers
[] = {
217 static const int extra_valid_texture_unit
[] = {
218 EXTRA_VALID_TEXTURE_UNIT
,
222 static const int extra_valid_clip_distance
[] = {
223 EXTRA_VALID_CLIP_DISTANCE
,
227 static const int extra_flush_current_valid_texture_unit
[] = {
229 EXTRA_VALID_TEXTURE_UNIT
,
233 static const int extra_flush_current
[] = {
238 static const int extra_EXT_fog_coord_flush_current
[] = {
244 static const int extra_EXT_texture_integer
[] = {
245 EXT(EXT_texture_integer
),
250 EXTRA_EXT(ARB_texture_cube_map
);
251 EXTRA_EXT(EXT_fog_coord
);
252 EXTRA_EXT(NV_fog_distance
);
253 EXTRA_EXT(EXT_texture_filter_anisotropic
);
254 EXTRA_EXT(IBM_rasterpos_clip
);
255 EXTRA_EXT(NV_point_sprite
);
256 EXTRA_EXT(NV_light_max_exponent
);
257 EXTRA_EXT(EXT_depth_bounds_test
);
258 EXTRA_EXT(EXT_compiled_vertex_array
);
259 EXTRA_EXT2(NV_point_sprite
, ARB_point_sprite
);
261 static const int extra_version_30
[] = { EXTRA_VERSION_30
, EXTRA_END
};
262 static const int extra_version_32
[] = { EXTRA_VERSION_32
, EXTRA_END
};
264 #define API_OPENGL_BIT (1 << API_OPENGL)
266 /* This is the big table describing all the enums we accept in
267 * glGet*v(). The table is partitioned into six parts: enums
268 * understood by all GL APIs (OpenGL, GLES and GLES2), enums shared
269 * between OpenGL and GLES, enums exclusive to GLES, etc for the
270 * remaining combinations. When we add the enums to the hash table in
271 * _mesa_init_get_hash(), we only add the enums for the API we're
272 * instantiating and the different sections are guarded by #if
273 * FEATURE_GL etc to make sure we only compile in the enums we may
276 static const struct value_desc values
[] = {
277 { GL_ALPHA_BITS
, BUFFER_INT(Visual
.alphaBits
), extra_new_buffers
},
278 { GL_BLEND
, CONTEXT_BIT0(Color
.BlendEnabled
), NO_EXTRA
},
279 { GL_BLEND_SRC
, CONTEXT_ENUM(Color
.SrcFactor
), NO_EXTRA
},
280 { GL_BLUE_BITS
, BUFFER_INT(Visual
.blueBits
), extra_new_buffers
},
281 { GL_COLOR_CLEAR_VALUE
, LOC_CUSTOM
, TYPE_FLOATN_4
, 0, NO_EXTRA
},
282 { GL_COLOR_WRITEMASK
, LOC_CUSTOM
, TYPE_INT_4
, 0, NO_EXTRA
},
283 { GL_CULL_FACE
, CONTEXT_BOOL(Polygon
.CullFlag
), NO_EXTRA
},
284 { GL_CULL_FACE_MODE
, CONTEXT_ENUM(Polygon
.CullFaceMode
), NO_EXTRA
},
285 { GL_DEPTH_BITS
, BUFFER_INT(Visual
.depthBits
), NO_EXTRA
},
286 { GL_DEPTH_CLEAR_VALUE
, CONTEXT_FIELD(Depth
.Clear
, TYPE_DOUBLEN
), NO_EXTRA
},
287 { GL_DEPTH_FUNC
, CONTEXT_ENUM(Depth
.Func
), NO_EXTRA
},
288 { GL_DEPTH_RANGE
, CONTEXT_FIELD(Viewport
.Near
, TYPE_FLOATN_2
), NO_EXTRA
},
289 { GL_DEPTH_TEST
, CONTEXT_BOOL(Depth
.Test
), NO_EXTRA
},
290 { GL_DEPTH_WRITEMASK
, CONTEXT_BOOL(Depth
.Mask
), NO_EXTRA
},
291 { GL_DITHER
, CONTEXT_BOOL(Color
.DitherFlag
), NO_EXTRA
},
292 { GL_FRONT_FACE
, CONTEXT_ENUM(Polygon
.FrontFace
), NO_EXTRA
},
293 { GL_GREEN_BITS
, BUFFER_INT(Visual
.greenBits
), extra_new_buffers
},
294 { GL_LINE_WIDTH
, CONTEXT_FLOAT(Line
.Width
), NO_EXTRA
},
295 { GL_ALIASED_LINE_WIDTH_RANGE
, CONTEXT_FLOAT2(Const
.MinLineWidth
), NO_EXTRA
},
296 { GL_MAX_ELEMENTS_VERTICES
, CONTEXT_INT(Const
.MaxArrayLockSize
), NO_EXTRA
},
297 { GL_MAX_ELEMENTS_INDICES
, CONTEXT_INT(Const
.MaxArrayLockSize
), NO_EXTRA
},
298 { GL_MAX_TEXTURE_SIZE
, LOC_CUSTOM
, TYPE_INT
,
299 offsetof(struct gl_context
, Const
.MaxTextureLevels
), NO_EXTRA
},
300 { GL_MAX_VIEWPORT_DIMS
, CONTEXT_INT2(Const
.MaxViewportWidth
), NO_EXTRA
},
301 { GL_PACK_ALIGNMENT
, CONTEXT_INT(Pack
.Alignment
), NO_EXTRA
},
302 { GL_ALIASED_POINT_SIZE_RANGE
, CONTEXT_FLOAT2(Const
.MinPointSize
), NO_EXTRA
},
303 { GL_POLYGON_OFFSET_FACTOR
, CONTEXT_FLOAT(Polygon
.OffsetFactor
), NO_EXTRA
},
304 { GL_POLYGON_OFFSET_UNITS
, CONTEXT_FLOAT(Polygon
.OffsetUnits
), NO_EXTRA
},
305 { GL_POLYGON_OFFSET_FILL
, CONTEXT_BOOL(Polygon
.OffsetFill
), NO_EXTRA
},
306 { GL_RED_BITS
, BUFFER_INT(Visual
.redBits
), extra_new_buffers
},
307 { GL_SCISSOR_BOX
, LOC_CUSTOM
, TYPE_INT_4
, 0, NO_EXTRA
},
308 { GL_SCISSOR_TEST
, CONTEXT_BOOL(Scissor
.Enabled
), NO_EXTRA
},
309 { GL_STENCIL_BITS
, BUFFER_INT(Visual
.stencilBits
), NO_EXTRA
},
310 { GL_STENCIL_CLEAR_VALUE
, CONTEXT_INT(Stencil
.Clear
), NO_EXTRA
},
311 { GL_STENCIL_FAIL
, LOC_CUSTOM
, TYPE_ENUM
, NO_OFFSET
, NO_EXTRA
},
312 { GL_STENCIL_FUNC
, LOC_CUSTOM
, TYPE_ENUM
, NO_OFFSET
, NO_EXTRA
},
313 { GL_STENCIL_PASS_DEPTH_FAIL
, LOC_CUSTOM
, TYPE_ENUM
, NO_OFFSET
, NO_EXTRA
},
314 { GL_STENCIL_PASS_DEPTH_PASS
, LOC_CUSTOM
, TYPE_ENUM
, NO_OFFSET
, NO_EXTRA
},
315 { GL_STENCIL_REF
, LOC_CUSTOM
, TYPE_INT
, NO_OFFSET
, NO_EXTRA
},
316 { GL_STENCIL_TEST
, CONTEXT_BOOL(Stencil
.Enabled
), NO_EXTRA
},
317 { GL_STENCIL_VALUE_MASK
, LOC_CUSTOM
, TYPE_INT
, NO_OFFSET
, NO_EXTRA
},
318 { GL_STENCIL_WRITEMASK
, LOC_CUSTOM
, TYPE_INT
, NO_OFFSET
, NO_EXTRA
},
319 { GL_SUBPIXEL_BITS
, CONTEXT_INT(Const
.SubPixelBits
), NO_EXTRA
},
320 { GL_TEXTURE_BINDING_2D
, LOC_CUSTOM
, TYPE_INT
, TEXTURE_2D_INDEX
, NO_EXTRA
},
321 { GL_UNPACK_ALIGNMENT
, CONTEXT_INT(Unpack
.Alignment
), NO_EXTRA
},
322 { GL_VIEWPORT
, LOC_CUSTOM
, TYPE_INT_4
, 0, NO_EXTRA
},
324 /* GL_ARB_multitexture */
325 { GL_ACTIVE_TEXTURE
, LOC_CUSTOM
, TYPE_INT
, 0, NO_EXTRA
},
327 /* Note that all the OES_* extensions require that the Mesa "struct
328 * gl_extensions" include a member with the name of the extension.
329 * That structure does not yet include OES extensions (and we're
330 * not sure whether it will). If it does, all the OES_*
331 * extensions below should mark the dependency. */
333 /* GL_ARB_texture_cube_map */
334 { GL_TEXTURE_BINDING_CUBE_MAP_ARB
, LOC_CUSTOM
, TYPE_INT
,
335 TEXTURE_CUBE_INDEX
, extra_ARB_texture_cube_map
},
336 { GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB
, LOC_CUSTOM
, TYPE_INT
,
337 offsetof(struct gl_context
, Const
.MaxCubeTextureLevels
),
338 extra_ARB_texture_cube_map
}, /* XXX: OES_texture_cube_map */
340 /* XXX: OES_blend_subtract */
341 { GL_BLEND_SRC_RGB_EXT
, CONTEXT_ENUM(Color
.SrcFactor
), NO_EXTRA
},
342 { GL_BLEND_DST_RGB_EXT
, CONTEXT_ENUM(Color
.DstFactor
), NO_EXTRA
},
344 /* GL_ARB_multisample */
345 { GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
,
346 CONTEXT_BOOL(Multisample
.SampleAlphaToCoverage
), NO_EXTRA
},
347 { GL_SAMPLE_COVERAGE_ARB
, CONTEXT_BOOL(Multisample
.SampleCoverage
), NO_EXTRA
},
348 { GL_SAMPLE_COVERAGE_VALUE_ARB
,
349 CONTEXT_FLOAT(Multisample
.SampleCoverageValue
), NO_EXTRA
},
350 { GL_SAMPLE_COVERAGE_INVERT_ARB
,
351 CONTEXT_BOOL(Multisample
.SampleCoverageInvert
), NO_EXTRA
},
353 /* GL_ARB_vertex_buffer_object */
354 { GL_ARRAY_BUFFER_BINDING_ARB
, LOC_CUSTOM
, TYPE_INT
, 0, NO_EXTRA
},
356 /* GL_ARB_vertex_buffer_object */
357 /* GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB - not supported */
358 { GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB
, LOC_CUSTOM
, TYPE_INT
, 0, NO_EXTRA
},
360 /* GL_OES_read_format */
361 { GL_IMPLEMENTATION_COLOR_READ_TYPE_OES
, LOC_CUSTOM
, TYPE_INT
, 0,
363 { GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES
, LOC_CUSTOM
, TYPE_INT
, 0,
366 /* This entry isn't spec'ed for GLES 2, but is needed for Mesa's
368 { GL_MAX_CLIP_PLANES
, CONTEXT_INT(Const
.MaxClipPlanes
), NO_EXTRA
},
370 { GL_MAX_LIGHTS
, CONTEXT_INT(Const
.MaxLights
), NO_EXTRA
},
371 { GL_LIGHT0
, CONTEXT_BOOL(Light
.Light
[0].Enabled
), NO_EXTRA
},
372 { GL_LIGHT1
, CONTEXT_BOOL(Light
.Light
[1].Enabled
), NO_EXTRA
},
373 { GL_LIGHT2
, CONTEXT_BOOL(Light
.Light
[2].Enabled
), NO_EXTRA
},
374 { GL_LIGHT3
, CONTEXT_BOOL(Light
.Light
[3].Enabled
), NO_EXTRA
},
375 { GL_LIGHT4
, CONTEXT_BOOL(Light
.Light
[4].Enabled
), NO_EXTRA
},
376 { GL_LIGHT5
, CONTEXT_BOOL(Light
.Light
[5].Enabled
), NO_EXTRA
},
377 { GL_LIGHT6
, CONTEXT_BOOL(Light
.Light
[6].Enabled
), NO_EXTRA
},
378 { GL_LIGHT7
, CONTEXT_BOOL(Light
.Light
[7].Enabled
), NO_EXTRA
},
379 { GL_LIGHTING
, CONTEXT_BOOL(Light
.Enabled
), NO_EXTRA
},
380 { GL_LIGHT_MODEL_AMBIENT
,
381 CONTEXT_FIELD(Light
.Model
.Ambient
[0], TYPE_FLOATN_4
), NO_EXTRA
},
382 { GL_LIGHT_MODEL_TWO_SIDE
, CONTEXT_BOOL(Light
.Model
.TwoSide
), NO_EXTRA
},
383 { GL_ALPHA_TEST
, CONTEXT_BOOL(Color
.AlphaEnabled
), NO_EXTRA
},
384 { GL_ALPHA_TEST_FUNC
, CONTEXT_ENUM(Color
.AlphaFunc
), NO_EXTRA
},
385 { GL_ALPHA_TEST_REF
, LOC_CUSTOM
, TYPE_FLOATN
, 0, NO_EXTRA
},
386 { GL_BLEND_DST
, CONTEXT_ENUM(Color
.DstFactor
), NO_EXTRA
},
387 { GL_CLIP_DISTANCE0
, CONTEXT_BIT0(Transform
.ClipPlanesEnabled
), extra_valid_clip_distance
},
388 { GL_CLIP_DISTANCE1
, CONTEXT_BIT1(Transform
.ClipPlanesEnabled
), extra_valid_clip_distance
},
389 { GL_CLIP_DISTANCE2
, CONTEXT_BIT2(Transform
.ClipPlanesEnabled
), extra_valid_clip_distance
},
390 { GL_CLIP_DISTANCE3
, CONTEXT_BIT3(Transform
.ClipPlanesEnabled
), extra_valid_clip_distance
},
391 { GL_CLIP_DISTANCE4
, CONTEXT_BIT4(Transform
.ClipPlanesEnabled
), extra_valid_clip_distance
},
392 { GL_CLIP_DISTANCE5
, CONTEXT_BIT5(Transform
.ClipPlanesEnabled
), extra_valid_clip_distance
},
393 { GL_CLIP_DISTANCE6
, CONTEXT_BIT6(Transform
.ClipPlanesEnabled
), extra_valid_clip_distance
},
394 { GL_CLIP_DISTANCE7
, CONTEXT_BIT7(Transform
.ClipPlanesEnabled
), extra_valid_clip_distance
},
395 { GL_COLOR_MATERIAL
, CONTEXT_BOOL(Light
.ColorMaterialEnabled
), NO_EXTRA
},
397 CONTEXT_FIELD(Current
.Attrib
[VERT_ATTRIB_COLOR
][0], TYPE_FLOATN_4
),
398 extra_flush_current
},
400 CONTEXT_FIELD(Current
.Attrib
[VERT_ATTRIB_NORMAL
][0], TYPE_FLOATN_3
),
401 extra_flush_current
},
402 { GL_CURRENT_TEXTURE_COORDS
, LOC_CUSTOM
, TYPE_FLOAT_4
, 0,
403 extra_flush_current_valid_texture_unit
},
404 { GL_DISTANCE_ATTENUATION_EXT
, CONTEXT_FLOAT3(Point
.Params
[0]), NO_EXTRA
},
405 { GL_FOG
, CONTEXT_BOOL(Fog
.Enabled
), NO_EXTRA
},
406 { GL_FOG_COLOR
, LOC_CUSTOM
, TYPE_FLOATN_4
, 0, NO_EXTRA
},
407 { GL_FOG_DENSITY
, CONTEXT_FLOAT(Fog
.Density
), NO_EXTRA
},
408 { GL_FOG_END
, CONTEXT_FLOAT(Fog
.End
), NO_EXTRA
},
409 { GL_FOG_HINT
, CONTEXT_ENUM(Hint
.Fog
), NO_EXTRA
},
410 { GL_FOG_MODE
, CONTEXT_ENUM(Fog
.Mode
), NO_EXTRA
},
411 { GL_FOG_START
, CONTEXT_FLOAT(Fog
.Start
), NO_EXTRA
},
412 { GL_LINE_SMOOTH
, CONTEXT_BOOL(Line
.SmoothFlag
), NO_EXTRA
},
413 { GL_LINE_SMOOTH_HINT
, CONTEXT_ENUM(Hint
.LineSmooth
), NO_EXTRA
},
414 { GL_LINE_WIDTH_RANGE
, CONTEXT_FLOAT2(Const
.MinLineWidthAA
), NO_EXTRA
},
415 { GL_COLOR_LOGIC_OP
, CONTEXT_BOOL(Color
.ColorLogicOpEnabled
), NO_EXTRA
},
416 { GL_LOGIC_OP_MODE
, CONTEXT_ENUM(Color
.LogicOp
), NO_EXTRA
},
417 { GL_MATRIX_MODE
, CONTEXT_ENUM(Transform
.MatrixMode
), NO_EXTRA
},
418 { GL_MAX_MODELVIEW_STACK_DEPTH
, CONST(MAX_MODELVIEW_STACK_DEPTH
), NO_EXTRA
},
419 { GL_MAX_PROJECTION_STACK_DEPTH
, CONST(MAX_PROJECTION_STACK_DEPTH
), NO_EXTRA
},
420 { GL_MAX_TEXTURE_STACK_DEPTH
, CONST(MAX_TEXTURE_STACK_DEPTH
), NO_EXTRA
},
421 { GL_MODELVIEW_MATRIX
, CONTEXT_MATRIX(ModelviewMatrixStack
.Top
), NO_EXTRA
},
422 { GL_MODELVIEW_STACK_DEPTH
, LOC_CUSTOM
, TYPE_INT
,
423 offsetof(struct gl_context
, ModelviewMatrixStack
.Depth
), NO_EXTRA
},
424 { GL_NORMALIZE
, CONTEXT_BOOL(Transform
.Normalize
), NO_EXTRA
},
425 { GL_PACK_SKIP_IMAGES_EXT
, CONTEXT_INT(Pack
.SkipImages
), NO_EXTRA
},
426 { GL_PERSPECTIVE_CORRECTION_HINT
, CONTEXT_ENUM(Hint
.PerspectiveCorrection
), NO_EXTRA
},
427 { GL_POINT_SIZE
, CONTEXT_FLOAT(Point
.Size
), NO_EXTRA
},
428 { GL_POINT_SIZE_RANGE
, CONTEXT_FLOAT2(Const
.MinPointSizeAA
), NO_EXTRA
},
429 { GL_POINT_SMOOTH
, CONTEXT_BOOL(Point
.SmoothFlag
), NO_EXTRA
},
430 { GL_POINT_SMOOTH_HINT
, CONTEXT_ENUM(Hint
.PointSmooth
), NO_EXTRA
},
431 { GL_POINT_SIZE_MIN_EXT
, CONTEXT_FLOAT(Point
.MinSize
), NO_EXTRA
},
432 { GL_POINT_SIZE_MAX_EXT
, CONTEXT_FLOAT(Point
.MaxSize
), NO_EXTRA
},
433 { GL_POINT_FADE_THRESHOLD_SIZE_EXT
, CONTEXT_FLOAT(Point
.Threshold
), NO_EXTRA
},
434 { GL_PROJECTION_MATRIX
, CONTEXT_MATRIX(ProjectionMatrixStack
.Top
), NO_EXTRA
},
435 { GL_PROJECTION_STACK_DEPTH
, LOC_CUSTOM
, TYPE_INT
,
436 offsetof(struct gl_context
, ProjectionMatrixStack
.Depth
), NO_EXTRA
},
437 { GL_RESCALE_NORMAL
, CONTEXT_BOOL(Transform
.RescaleNormals
), NO_EXTRA
},
438 { GL_SHADE_MODEL
, CONTEXT_ENUM(Light
.ShadeModel
), NO_EXTRA
},
439 { GL_TEXTURE_2D
, LOC_CUSTOM
, TYPE_BOOLEAN
, 0, NO_EXTRA
},
440 { GL_TEXTURE_MATRIX
, LOC_CUSTOM
, TYPE_MATRIX
, 0, extra_valid_texture_unit
},
441 { GL_TEXTURE_STACK_DEPTH
, LOC_CUSTOM
, TYPE_INT
, 0,
442 extra_valid_texture_unit
},
444 { GL_VERTEX_ARRAY
, ARRAY_BOOL(VertexAttrib
[VERT_ATTRIB_POS
].Enabled
), NO_EXTRA
},
445 { GL_VERTEX_ARRAY_SIZE
, ARRAY_INT(VertexAttrib
[VERT_ATTRIB_POS
].Size
), NO_EXTRA
},
446 { GL_VERTEX_ARRAY_TYPE
, ARRAY_ENUM(VertexAttrib
[VERT_ATTRIB_POS
].Type
), NO_EXTRA
},
447 { GL_VERTEX_ARRAY_STRIDE
, ARRAY_INT(VertexAttrib
[VERT_ATTRIB_POS
].Stride
), NO_EXTRA
},
448 { GL_NORMAL_ARRAY
, ARRAY_BOOL(VertexAttrib
[VERT_ATTRIB_NORMAL
].Enabled
), NO_EXTRA
},
449 { GL_NORMAL_ARRAY_TYPE
, ARRAY_ENUM(VertexAttrib
[VERT_ATTRIB_NORMAL
].Type
), NO_EXTRA
},
450 { GL_NORMAL_ARRAY_STRIDE
, ARRAY_INT(VertexAttrib
[VERT_ATTRIB_NORMAL
].Stride
), NO_EXTRA
},
451 { GL_COLOR_ARRAY
, ARRAY_BOOL(VertexAttrib
[VERT_ATTRIB_COLOR
].Enabled
), NO_EXTRA
},
452 { GL_COLOR_ARRAY_SIZE
, ARRAY_INT(VertexAttrib
[VERT_ATTRIB_COLOR
].Size
), NO_EXTRA
},
453 { GL_COLOR_ARRAY_TYPE
, ARRAY_ENUM(VertexAttrib
[VERT_ATTRIB_COLOR
].Type
), NO_EXTRA
},
454 { GL_COLOR_ARRAY_STRIDE
, ARRAY_INT(VertexAttrib
[VERT_ATTRIB_COLOR
].Stride
), NO_EXTRA
},
455 { GL_TEXTURE_COORD_ARRAY
,
456 LOC_CUSTOM
, TYPE_BOOLEAN
, offsetof(struct gl_client_array
, Enabled
), NO_EXTRA
},
457 { GL_TEXTURE_COORD_ARRAY_SIZE
,
458 LOC_CUSTOM
, TYPE_INT
, offsetof(struct gl_client_array
, Size
), NO_EXTRA
},
459 { GL_TEXTURE_COORD_ARRAY_TYPE
,
460 LOC_CUSTOM
, TYPE_ENUM
, offsetof(struct gl_client_array
, Type
), NO_EXTRA
},
461 { GL_TEXTURE_COORD_ARRAY_STRIDE
,
462 LOC_CUSTOM
, TYPE_INT
, offsetof(struct gl_client_array
, Stride
), NO_EXTRA
},
464 /* GL_ARB_texture_cube_map */
465 { GL_TEXTURE_CUBE_MAP_ARB
, LOC_CUSTOM
, TYPE_BOOLEAN
, 0, NO_EXTRA
},
466 /* S, T, and R are always set at the same time */
467 { GL_TEXTURE_GEN_STR_OES
, LOC_TEXUNIT
, TYPE_BIT_0
,
468 offsetof(struct gl_texture_unit
, TexGenEnabled
), NO_EXTRA
},
470 /* GL_ARB_multisample */
471 { GL_MULTISAMPLE_ARB
, CONTEXT_BOOL(Multisample
.Enabled
), NO_EXTRA
},
472 { GL_SAMPLE_ALPHA_TO_ONE_ARB
, CONTEXT_BOOL(Multisample
.SampleAlphaToOne
), NO_EXTRA
},
474 /* GL_ARB_vertex_buffer_object */
475 { GL_VERTEX_ARRAY_BUFFER_BINDING_ARB
, LOC_CUSTOM
, TYPE_INT
,
476 offsetof(struct gl_array_attrib
, VertexAttrib
[VERT_ATTRIB_POS
].BufferObj
), NO_EXTRA
},
477 { GL_NORMAL_ARRAY_BUFFER_BINDING_ARB
, LOC_CUSTOM
, TYPE_INT
,
478 offsetof(struct gl_array_attrib
, VertexAttrib
[VERT_ATTRIB_NORMAL
].BufferObj
), NO_EXTRA
},
479 { GL_COLOR_ARRAY_BUFFER_BINDING_ARB
, LOC_CUSTOM
, TYPE_INT
,
480 offsetof(struct gl_array_attrib
, VertexAttrib
[VERT_ATTRIB_COLOR
].BufferObj
), NO_EXTRA
},
481 { GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB
, LOC_CUSTOM
, TYPE_INT
, NO_OFFSET
, NO_EXTRA
},
483 /* GL_OES_point_sprite */
484 { GL_POINT_SPRITE_NV
,
485 CONTEXT_BOOL(Point
.PointSprite
),
486 extra_NV_point_sprite_ARB_point_sprite
},
488 /* GL_EXT_texture_filter_anisotropic */
489 { GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT
,
490 CONTEXT_FLOAT(Const
.MaxTextureMaxAnisotropy
),
491 extra_EXT_texture_filter_anisotropic
},
493 { GL_BLEND_COLOR_EXT
, LOC_CUSTOM
, TYPE_FLOATN_4
, 0, NO_EXTRA
},
495 { GL_ACCUM_RED_BITS
, BUFFER_INT(Visual
.accumRedBits
), NO_EXTRA
},
496 { GL_ACCUM_GREEN_BITS
, BUFFER_INT(Visual
.accumGreenBits
), NO_EXTRA
},
497 { GL_ACCUM_BLUE_BITS
, BUFFER_INT(Visual
.accumBlueBits
), NO_EXTRA
},
498 { GL_ACCUM_ALPHA_BITS
, BUFFER_INT(Visual
.accumAlphaBits
), NO_EXTRA
},
499 { GL_ACCUM_CLEAR_VALUE
, CONTEXT_FIELD(Accum
.ClearColor
[0], TYPE_FLOATN_4
), NO_EXTRA
},
500 { GL_ALPHA_BIAS
, CONTEXT_FLOAT(Pixel
.AlphaBias
), NO_EXTRA
},
501 { GL_ALPHA_SCALE
, CONTEXT_FLOAT(Pixel
.AlphaScale
), NO_EXTRA
},
502 { GL_ATTRIB_STACK_DEPTH
, CONTEXT_INT(AttribStackDepth
), NO_EXTRA
},
503 { GL_AUTO_NORMAL
, CONTEXT_BOOL(Eval
.AutoNormal
), NO_EXTRA
},
504 { GL_AUX_BUFFERS
, BUFFER_INT(Visual
.numAuxBuffers
), NO_EXTRA
},
505 { GL_BLUE_BIAS
, CONTEXT_FLOAT(Pixel
.BlueBias
), NO_EXTRA
},
506 { GL_BLUE_SCALE
, CONTEXT_FLOAT(Pixel
.BlueScale
), NO_EXTRA
},
507 { GL_CLIENT_ATTRIB_STACK_DEPTH
, CONTEXT_INT(ClientAttribStackDepth
), NO_EXTRA
},
508 { GL_COLOR_MATERIAL_FACE
, CONTEXT_ENUM(Light
.ColorMaterialFace
), NO_EXTRA
},
509 { GL_COLOR_MATERIAL_PARAMETER
, CONTEXT_ENUM(Light
.ColorMaterialMode
), NO_EXTRA
},
511 CONTEXT_FLOAT(Current
.Attrib
[VERT_ATTRIB_COLOR_INDEX
][0]),
512 extra_flush_current
},
513 { GL_CURRENT_RASTER_COLOR
,
514 CONTEXT_FIELD(Current
.RasterColor
[0], TYPE_FLOATN_4
), NO_EXTRA
},
515 { GL_CURRENT_RASTER_DISTANCE
, CONTEXT_FLOAT(Current
.RasterDistance
), NO_EXTRA
},
516 { GL_CURRENT_RASTER_INDEX
, CONST(1), NO_EXTRA
},
517 { GL_CURRENT_RASTER_POSITION
, CONTEXT_FLOAT4(Current
.RasterPos
[0]), NO_EXTRA
},
518 { GL_CURRENT_RASTER_TEXTURE_COORDS
, LOC_CUSTOM
, TYPE_FLOAT_4
, 0,
519 extra_valid_texture_unit
},
520 { GL_CURRENT_RASTER_POSITION_VALID
, CONTEXT_BOOL(Current
.RasterPosValid
), NO_EXTRA
},
521 { GL_DEPTH_BIAS
, CONTEXT_FLOAT(Pixel
.DepthBias
), NO_EXTRA
},
522 { GL_DEPTH_SCALE
, CONTEXT_FLOAT(Pixel
.DepthScale
), NO_EXTRA
},
523 { GL_DOUBLEBUFFER
, BUFFER_INT(Visual
.doubleBufferMode
), NO_EXTRA
},
524 { GL_DRAW_BUFFER
, BUFFER_ENUM(ColorDrawBuffer
), NO_EXTRA
},
525 { GL_EDGE_FLAG
, LOC_CUSTOM
, TYPE_BOOLEAN
, 0, NO_EXTRA
},
526 { GL_FEEDBACK_BUFFER_SIZE
, CONTEXT_INT(Feedback
.BufferSize
), NO_EXTRA
},
527 { GL_FEEDBACK_BUFFER_TYPE
, CONTEXT_ENUM(Feedback
.Type
), NO_EXTRA
},
528 { GL_FOG_INDEX
, CONTEXT_FLOAT(Fog
.Index
), NO_EXTRA
},
529 { GL_GREEN_BIAS
, CONTEXT_FLOAT(Pixel
.GreenBias
), NO_EXTRA
},
530 { GL_GREEN_SCALE
, CONTEXT_FLOAT(Pixel
.GreenScale
), NO_EXTRA
},
531 { GL_INDEX_BITS
, BUFFER_INT(Visual
.indexBits
), extra_new_buffers
},
532 { GL_INDEX_CLEAR_VALUE
, CONTEXT_INT(Color
.ClearIndex
), NO_EXTRA
},
533 { GL_INDEX_MODE
, CONST(0) , NO_EXTRA
},
534 { GL_INDEX_OFFSET
, CONTEXT_INT(Pixel
.IndexOffset
), NO_EXTRA
},
535 { GL_INDEX_SHIFT
, CONTEXT_INT(Pixel
.IndexShift
), NO_EXTRA
},
536 { GL_INDEX_WRITEMASK
, CONTEXT_INT(Color
.IndexMask
), NO_EXTRA
},
537 { GL_LIGHT_MODEL_LOCAL_VIEWER
, CONTEXT_BOOL(Light
.Model
.LocalViewer
), NO_EXTRA
},
538 { GL_LINE_STIPPLE
, CONTEXT_BOOL(Line
.StippleFlag
), NO_EXTRA
},
539 { GL_LINE_STIPPLE_PATTERN
, LOC_CUSTOM
, TYPE_INT
, 0, NO_EXTRA
},
540 { GL_LINE_STIPPLE_REPEAT
, CONTEXT_INT(Line
.StippleFactor
), NO_EXTRA
},
541 { GL_LINE_WIDTH_GRANULARITY
, CONTEXT_FLOAT(Const
.LineWidthGranularity
), NO_EXTRA
},
542 { GL_LIST_BASE
, CONTEXT_INT(List
.ListBase
), NO_EXTRA
},
543 { GL_LIST_INDEX
, LOC_CUSTOM
, TYPE_INT
, 0, NO_EXTRA
},
544 { GL_LIST_MODE
, LOC_CUSTOM
, TYPE_ENUM
, 0, NO_EXTRA
},
545 { GL_INDEX_LOGIC_OP
, CONTEXT_BOOL(Color
.IndexLogicOpEnabled
), NO_EXTRA
},
546 { GL_MAP1_COLOR_4
, CONTEXT_BOOL(Eval
.Map1Color4
), NO_EXTRA
},
547 { GL_MAP1_GRID_DOMAIN
, CONTEXT_FLOAT2(Eval
.MapGrid1u1
), NO_EXTRA
},
548 { GL_MAP1_GRID_SEGMENTS
, CONTEXT_INT(Eval
.MapGrid1un
), NO_EXTRA
},
549 { GL_MAP1_INDEX
, CONTEXT_BOOL(Eval
.Map1Index
), NO_EXTRA
},
550 { GL_MAP1_NORMAL
, CONTEXT_BOOL(Eval
.Map1Normal
), NO_EXTRA
},
551 { GL_MAP1_TEXTURE_COORD_1
, CONTEXT_BOOL(Eval
.Map1TextureCoord1
), NO_EXTRA
},
552 { GL_MAP1_TEXTURE_COORD_2
, CONTEXT_BOOL(Eval
.Map1TextureCoord2
), NO_EXTRA
},
553 { GL_MAP1_TEXTURE_COORD_3
, CONTEXT_BOOL(Eval
.Map1TextureCoord3
), NO_EXTRA
},
554 { GL_MAP1_TEXTURE_COORD_4
, CONTEXT_BOOL(Eval
.Map1TextureCoord4
), NO_EXTRA
},
555 { GL_MAP1_VERTEX_3
, CONTEXT_BOOL(Eval
.Map1Vertex3
), NO_EXTRA
},
556 { GL_MAP1_VERTEX_4
, CONTEXT_BOOL(Eval
.Map1Vertex4
), NO_EXTRA
},
557 { GL_MAP2_COLOR_4
, CONTEXT_BOOL(Eval
.Map2Color4
), NO_EXTRA
},
558 { GL_MAP2_GRID_DOMAIN
, LOC_CUSTOM
, TYPE_FLOAT_4
, 0, NO_EXTRA
},
559 { GL_MAP2_GRID_SEGMENTS
, CONTEXT_INT2(Eval
.MapGrid2un
), NO_EXTRA
},
560 { GL_MAP2_INDEX
, CONTEXT_BOOL(Eval
.Map2Index
), NO_EXTRA
},
561 { GL_MAP2_NORMAL
, CONTEXT_BOOL(Eval
.Map2Normal
), NO_EXTRA
},
562 { GL_MAP2_TEXTURE_COORD_1
, CONTEXT_BOOL(Eval
.Map2TextureCoord1
), NO_EXTRA
},
563 { GL_MAP2_TEXTURE_COORD_2
, CONTEXT_BOOL(Eval
.Map2TextureCoord2
), NO_EXTRA
},
564 { GL_MAP2_TEXTURE_COORD_3
, CONTEXT_BOOL(Eval
.Map2TextureCoord3
), NO_EXTRA
},
565 { GL_MAP2_TEXTURE_COORD_4
, CONTEXT_BOOL(Eval
.Map2TextureCoord4
), NO_EXTRA
},
566 { GL_MAP2_VERTEX_3
, CONTEXT_BOOL(Eval
.Map2Vertex3
), NO_EXTRA
},
567 { GL_MAP2_VERTEX_4
, CONTEXT_BOOL(Eval
.Map2Vertex4
), NO_EXTRA
},
568 { GL_MAP_COLOR
, CONTEXT_BOOL(Pixel
.MapColorFlag
), NO_EXTRA
},
569 { GL_MAP_STENCIL
, CONTEXT_BOOL(Pixel
.MapStencilFlag
), NO_EXTRA
},
570 { GL_MAX_ATTRIB_STACK_DEPTH
, CONST(MAX_ATTRIB_STACK_DEPTH
), NO_EXTRA
},
571 { GL_MAX_CLIENT_ATTRIB_STACK_DEPTH
, CONST(MAX_CLIENT_ATTRIB_STACK_DEPTH
), NO_EXTRA
},
573 { GL_MAX_EVAL_ORDER
, CONST(MAX_EVAL_ORDER
), NO_EXTRA
},
574 { GL_MAX_LIST_NESTING
, CONST(MAX_LIST_NESTING
), NO_EXTRA
},
575 { GL_MAX_NAME_STACK_DEPTH
, CONST(MAX_NAME_STACK_DEPTH
), NO_EXTRA
},
576 { GL_MAX_PIXEL_MAP_TABLE
, CONST(MAX_PIXEL_MAP_TABLE
), NO_EXTRA
},
577 { GL_NAME_STACK_DEPTH
, CONTEXT_INT(Select
.NameStackDepth
), NO_EXTRA
},
578 { GL_PACK_LSB_FIRST
, CONTEXT_BOOL(Pack
.LsbFirst
), NO_EXTRA
},
579 { GL_PACK_ROW_LENGTH
, CONTEXT_INT(Pack
.RowLength
), NO_EXTRA
},
580 { GL_PACK_SKIP_PIXELS
, CONTEXT_INT(Pack
.SkipPixels
), NO_EXTRA
},
581 { GL_PACK_SKIP_ROWS
, CONTEXT_INT(Pack
.SkipRows
), NO_EXTRA
},
582 { GL_PACK_SWAP_BYTES
, CONTEXT_BOOL(Pack
.SwapBytes
), NO_EXTRA
},
583 { GL_PACK_IMAGE_HEIGHT_EXT
, CONTEXT_INT(Pack
.ImageHeight
), NO_EXTRA
},
584 { GL_PACK_INVERT_MESA
, CONTEXT_BOOL(Pack
.Invert
), NO_EXTRA
},
585 { GL_PIXEL_MAP_A_TO_A_SIZE
, CONTEXT_INT(PixelMaps
.AtoA
.Size
), NO_EXTRA
},
586 { GL_PIXEL_MAP_B_TO_B_SIZE
, CONTEXT_INT(PixelMaps
.BtoB
.Size
), NO_EXTRA
},
587 { GL_PIXEL_MAP_G_TO_G_SIZE
, CONTEXT_INT(PixelMaps
.GtoG
.Size
), NO_EXTRA
},
588 { GL_PIXEL_MAP_I_TO_A_SIZE
, CONTEXT_INT(PixelMaps
.ItoA
.Size
), NO_EXTRA
},
589 { GL_PIXEL_MAP_I_TO_B_SIZE
, CONTEXT_INT(PixelMaps
.ItoB
.Size
), NO_EXTRA
},
590 { GL_PIXEL_MAP_I_TO_G_SIZE
, CONTEXT_INT(PixelMaps
.ItoG
.Size
), NO_EXTRA
},
591 { GL_PIXEL_MAP_I_TO_I_SIZE
, CONTEXT_INT(PixelMaps
.ItoI
.Size
), NO_EXTRA
},
592 { GL_PIXEL_MAP_I_TO_R_SIZE
, CONTEXT_INT(PixelMaps
.ItoR
.Size
), NO_EXTRA
},
593 { GL_PIXEL_MAP_R_TO_R_SIZE
, CONTEXT_INT(PixelMaps
.RtoR
.Size
), NO_EXTRA
},
594 { GL_PIXEL_MAP_S_TO_S_SIZE
, CONTEXT_INT(PixelMaps
.StoS
.Size
), NO_EXTRA
},
595 { GL_POINT_SIZE_GRANULARITY
, CONTEXT_FLOAT(Const
.PointSizeGranularity
), NO_EXTRA
},
596 { GL_POLYGON_MODE
, CONTEXT_ENUM2(Polygon
.FrontMode
), NO_EXTRA
},
597 { GL_POLYGON_OFFSET_BIAS_EXT
, CONTEXT_FLOAT(Polygon
.OffsetUnits
), NO_EXTRA
},
598 { GL_POLYGON_OFFSET_POINT
, CONTEXT_BOOL(Polygon
.OffsetPoint
), NO_EXTRA
},
599 { GL_POLYGON_OFFSET_LINE
, CONTEXT_BOOL(Polygon
.OffsetLine
), NO_EXTRA
},
600 { GL_POLYGON_SMOOTH
, CONTEXT_BOOL(Polygon
.SmoothFlag
), NO_EXTRA
},
601 { GL_POLYGON_SMOOTH_HINT
, CONTEXT_ENUM(Hint
.PolygonSmooth
), NO_EXTRA
},
602 { GL_POLYGON_STIPPLE
, CONTEXT_BOOL(Polygon
.StippleFlag
), NO_EXTRA
},
603 { GL_READ_BUFFER
, LOC_CUSTOM
, TYPE_ENUM
, NO_OFFSET
, NO_EXTRA
},
604 { GL_RED_BIAS
, CONTEXT_FLOAT(Pixel
.RedBias
), NO_EXTRA
},
605 { GL_RED_SCALE
, CONTEXT_FLOAT(Pixel
.RedScale
), NO_EXTRA
},
606 { GL_RENDER_MODE
, CONTEXT_ENUM(RenderMode
), NO_EXTRA
},
607 { GL_RGBA_MODE
, CONST(1), NO_EXTRA
},
608 { GL_SELECTION_BUFFER_SIZE
, CONTEXT_INT(Select
.BufferSize
), NO_EXTRA
},
610 { GL_STEREO
, BUFFER_INT(Visual
.stereoMode
), NO_EXTRA
},
612 { GL_TEXTURE_1D
, LOC_CUSTOM
, TYPE_BOOLEAN
, NO_OFFSET
, NO_EXTRA
},
614 { GL_TEXTURE_BINDING_1D
, LOC_CUSTOM
, TYPE_INT
, TEXTURE_1D_INDEX
, NO_EXTRA
},
616 { GL_TEXTURE_GEN_S
, LOC_TEXUNIT
, TYPE_BIT_0
,
617 offsetof(struct gl_texture_unit
, TexGenEnabled
), NO_EXTRA
},
618 { GL_TEXTURE_GEN_T
, LOC_TEXUNIT
, TYPE_BIT_1
,
619 offsetof(struct gl_texture_unit
, TexGenEnabled
), NO_EXTRA
},
620 { GL_TEXTURE_GEN_R
, LOC_TEXUNIT
, TYPE_BIT_2
,
621 offsetof(struct gl_texture_unit
, TexGenEnabled
), NO_EXTRA
},
622 { GL_TEXTURE_GEN_Q
, LOC_TEXUNIT
, TYPE_BIT_3
,
623 offsetof(struct gl_texture_unit
, TexGenEnabled
), NO_EXTRA
},
624 { GL_UNPACK_LSB_FIRST
, CONTEXT_BOOL(Unpack
.LsbFirst
), NO_EXTRA
},
625 { GL_UNPACK_ROW_LENGTH
, CONTEXT_INT(Unpack
.RowLength
), NO_EXTRA
},
626 { GL_UNPACK_SKIP_PIXELS
, CONTEXT_INT(Unpack
.SkipPixels
), NO_EXTRA
},
627 { GL_UNPACK_SKIP_ROWS
, CONTEXT_INT(Unpack
.SkipRows
), NO_EXTRA
},
628 { GL_UNPACK_SWAP_BYTES
, CONTEXT_BOOL(Unpack
.SwapBytes
), NO_EXTRA
},
629 { GL_UNPACK_SKIP_IMAGES_EXT
, CONTEXT_INT(Unpack
.SkipImages
), NO_EXTRA
},
630 { GL_UNPACK_IMAGE_HEIGHT_EXT
, CONTEXT_INT(Unpack
.ImageHeight
), NO_EXTRA
},
631 { GL_ZOOM_X
, CONTEXT_FLOAT(Pixel
.ZoomX
), NO_EXTRA
},
632 { GL_ZOOM_Y
, CONTEXT_FLOAT(Pixel
.ZoomY
), NO_EXTRA
},
635 { GL_VERTEX_ARRAY_COUNT_EXT
, CONST(0), NO_EXTRA
},
636 { GL_NORMAL_ARRAY_COUNT_EXT
, CONST(0), NO_EXTRA
},
637 { GL_COLOR_ARRAY_COUNT_EXT
, CONST(0), NO_EXTRA
},
638 { GL_INDEX_ARRAY
, ARRAY_BOOL(VertexAttrib
[VERT_ATTRIB_COLOR_INDEX
].Enabled
), NO_EXTRA
},
639 { GL_INDEX_ARRAY_TYPE
, ARRAY_ENUM(VertexAttrib
[VERT_ATTRIB_COLOR_INDEX
].Type
), NO_EXTRA
},
640 { GL_INDEX_ARRAY_STRIDE
, ARRAY_INT(VertexAttrib
[VERT_ATTRIB_COLOR_INDEX
].Stride
), NO_EXTRA
},
641 { GL_INDEX_ARRAY_COUNT_EXT
, CONST(0), NO_EXTRA
},
642 { GL_TEXTURE_COORD_ARRAY_COUNT_EXT
, CONST(0), NO_EXTRA
},
643 { GL_EDGE_FLAG_ARRAY
, ARRAY_BOOL(VertexAttrib
[VERT_ATTRIB_EDGEFLAG
].Enabled
), NO_EXTRA
},
644 { GL_EDGE_FLAG_ARRAY_STRIDE
, ARRAY_INT(VertexAttrib
[VERT_ATTRIB_EDGEFLAG
].Stride
), NO_EXTRA
},
645 { GL_EDGE_FLAG_ARRAY_COUNT_EXT
, CONST(0), NO_EXTRA
},
647 /* GL_EXT_compiled_vertex_array */
648 { GL_ARRAY_ELEMENT_LOCK_FIRST_EXT
, CONTEXT_INT(Array
.LockFirst
),
649 extra_EXT_compiled_vertex_array
},
650 { GL_ARRAY_ELEMENT_LOCK_COUNT_EXT
, CONTEXT_INT(Array
.LockCount
),
651 extra_EXT_compiled_vertex_array
},
653 /* GL_ARB_transpose_matrix */
654 { GL_TRANSPOSE_MODELVIEW_MATRIX_ARB
,
655 CONTEXT_MATRIX_T(ModelviewMatrixStack
), NO_EXTRA
},
656 { GL_TRANSPOSE_PROJECTION_MATRIX_ARB
,
657 CONTEXT_MATRIX_T(ProjectionMatrixStack
.Top
), NO_EXTRA
},
658 { GL_TRANSPOSE_TEXTURE_MATRIX_ARB
, CONTEXT_MATRIX_T(TextureMatrixStack
), NO_EXTRA
},
660 /* GL_EXT_fog_coord */
661 { GL_CURRENT_FOG_COORDINATE_EXT
,
662 CONTEXT_FLOAT(Current
.Attrib
[VERT_ATTRIB_FOG
][0]),
663 extra_EXT_fog_coord_flush_current
},
664 { GL_FOG_COORDINATE_ARRAY_EXT
, ARRAY_BOOL(VertexAttrib
[VERT_ATTRIB_FOG
].Enabled
),
665 extra_EXT_fog_coord
},
666 { GL_FOG_COORDINATE_ARRAY_TYPE_EXT
, ARRAY_ENUM(VertexAttrib
[VERT_ATTRIB_FOG
].Type
),
667 extra_EXT_fog_coord
},
668 { GL_FOG_COORDINATE_ARRAY_STRIDE_EXT
, ARRAY_INT(VertexAttrib
[VERT_ATTRIB_FOG
].Stride
),
669 extra_EXT_fog_coord
},
670 { GL_FOG_COORDINATE_SOURCE_EXT
, CONTEXT_ENUM(Fog
.FogCoordinateSource
),
671 extra_EXT_fog_coord
},
673 /* GL_NV_fog_distance */
674 { GL_FOG_DISTANCE_MODE_NV
, CONTEXT_ENUM(Fog
.FogDistanceMode
),
675 extra_NV_fog_distance
},
677 /* GL_IBM_rasterpos_clip */
678 { GL_RASTER_POSITION_UNCLIPPED_IBM
,
679 CONTEXT_BOOL(Transform
.RasterPositionUnclipped
),
680 extra_IBM_rasterpos_clip
},
682 /* GL_NV_point_sprite */
683 { GL_POINT_SPRITE_R_MODE_NV
,
684 CONTEXT_ENUM(Point
.SpriteRMode
), extra_NV_point_sprite
},
685 { GL_POINT_SPRITE_COORD_ORIGIN
, CONTEXT_ENUM(Point
.SpriteOrigin
),
686 extra_NV_point_sprite_ARB_point_sprite
},
688 /* GL_NV_light_max_exponent */
689 { GL_MAX_SHININESS_NV
, CONTEXT_FLOAT(Const
.MaxShininess
),
690 extra_NV_light_max_exponent
},
691 { GL_MAX_SPOT_EXPONENT_NV
, CONTEXT_FLOAT(Const
.MaxSpotExponent
),
692 extra_NV_light_max_exponent
},
694 /* GL_ARB_vertex_buffer_object */
695 { GL_INDEX_ARRAY_BUFFER_BINDING_ARB
, LOC_CUSTOM
, TYPE_INT
,
696 offsetof(struct gl_array_attrib
, VertexAttrib
[VERT_ATTRIB_COLOR_INDEX
].BufferObj
), NO_EXTRA
},
697 { GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB
, LOC_CUSTOM
, TYPE_INT
,
698 offsetof(struct gl_array_attrib
, VertexAttrib
[VERT_ATTRIB_EDGEFLAG
].BufferObj
), NO_EXTRA
},
699 { GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB
, LOC_CUSTOM
, TYPE_INT
,
700 offsetof(struct gl_array_attrib
, VertexAttrib
[VERT_ATTRIB_FOG
].BufferObj
), NO_EXTRA
},
702 /* GL_EXT_depth_bounds_test */
703 { GL_DEPTH_BOUNDS_TEST_EXT
, CONTEXT_BOOL(Depth
.BoundsTest
),
704 extra_EXT_depth_bounds_test
},
705 { GL_DEPTH_BOUNDS_EXT
, CONTEXT_FLOAT2(Depth
.BoundsMin
),
706 extra_EXT_depth_bounds_test
},
708 /* GL_EXT_texture_integer */
709 { GL_RGBA_INTEGER_MODE_EXT
, BUFFER_BOOL(_IntegerColor
),
710 extra_EXT_texture_integer
},
713 { GL_NUM_EXTENSIONS
, LOC_CUSTOM
, TYPE_INT
, 0, extra_version_30
},
714 { GL_MAJOR_VERSION
, CONTEXT_INT(VersionMajor
), extra_version_30
},
715 { GL_MINOR_VERSION
, CONTEXT_INT(VersionMinor
), extra_version_30
},
716 { GL_CONTEXT_FLAGS
, CONTEXT_INT(Const
.ContextFlags
), extra_version_30
},
720 { GL_CONTEXT_PROFILE_MASK
, CONTEXT_INT(Const
.ProfileMask
),
724 /* All we need now is a way to look up the value struct from the enum.
725 * The code generated by gcc for the old generated big switch
726 * statement is a big, balanced, open coded if/else tree, essentially
727 * an unrolled binary search. It would be natural to sort the new
728 * enum table and use bsearch(), but we will use a read-only hash
729 * table instead. bsearch() has a nice guaranteed worst case
730 * performance, but we're also guaranteed to hit that worst case
731 * (log2(n) iterations) for about half the enums. Instead, using an
732 * open addressing hash table, we can find the enum on the first try
733 * for 80% of the enums, 1 collision for 10% and never more than 5
734 * collisions for any enum (typical numbers). And the code is very
735 * simple, even though it feels a little magic. */
737 static unsigned short table
[1024];
738 static const int prime_factor
= 89, prime_step
= 281;
742 print_table_stats(void)
744 int i
, j
, collisions
[11], count
, hash
, mask
;
745 const struct value_desc
*d
;
748 mask
= Elements(table
) - 1;
749 memset(collisions
, 0, sizeof collisions
);
751 for (i
= 0; i
< Elements(table
); i
++) {
755 d
= &values
[table
[i
]];
756 hash
= (d
->pname
* prime_factor
);
759 if (values
[table
[hash
& mask
]].pname
== d
->pname
)
771 printf("number of enums: %d (total %d)\n", count
, Elements(values
));
772 for (i
= 0; i
< Elements(collisions
) - 1; i
++)
773 if (collisions
[i
] > 0)
774 printf(" %d enums with %d %scollisions\n",
775 collisions
[i
], i
, i
== 10 ? "or more " : "");
780 * Initialize the enum hash for a given API
782 * This is called from one_time_init() to insert the enum values that
783 * are valid for the API in question into the enum hash table.
785 * \param the current context, for determining the API in question
787 void _mesa_init_get_hash(struct gl_context
*ctx
)
789 int i
, hash
, index
, mask
;
791 mask
= Elements(table
) - 1;
793 for (i
= 0; i
< Elements(values
); i
++) {
795 hash
= (values
[i
].pname
* prime_factor
) & mask
;
812 * Handle irregular enums
814 * Some values don't conform to the "well-known type at context
815 * pointer + offset" pattern, so we have this function to catch all
816 * the corner cases. Typically, it's a computed value or a one-off
817 * pointer to a custom struct or something.
819 * In this case we can't return a pointer to the value, so we'll have
820 * to use the temporary variable 'v' declared back in the calling
821 * glGet*v() function to store the result.
823 * \param ctx the current context
824 * \param d the struct value_desc that describes the enum
825 * \param v pointer to the tmp declared in the calling glGet*v() function
828 find_custom_value(struct gl_context
*ctx
, const struct value_desc
*d
, union value
*v
)
830 struct gl_buffer_object
**buffer_obj
;
831 struct gl_client_array
*array
;
837 case GL_TEXTURE_CUBE_MAP_ARB
:
838 v
->value_bool
= _mesa_IsEnabled(d
->pname
);
841 case GL_LINE_STIPPLE_PATTERN
:
842 /* This is the only GLushort, special case it here by promoting
843 * to an int rather than introducing a new type. */
844 v
->value_int
= ctx
->Line
.StipplePattern
;
847 case GL_CURRENT_RASTER_TEXTURE_COORDS
:
848 v
->value_float_4
[0] = ctx
->Current
.RasterTexCoords
[0];
849 v
->value_float_4
[1] = ctx
->Current
.RasterTexCoords
[1];
850 v
->value_float_4
[2] = ctx
->Current
.RasterTexCoords
[2];
851 v
->value_float_4
[3] = ctx
->Current
.RasterTexCoords
[3];
854 case GL_CURRENT_TEXTURE_COORDS
:
855 v
->value_float_4
[0] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX
][0];
856 v
->value_float_4
[1] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX
][1];
857 v
->value_float_4
[2] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX
][2];
858 v
->value_float_4
[3] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX
][3];
861 case GL_COLOR_WRITEMASK
:
862 v
->value_int_4
[0] = ctx
->Color
.ColorMask
[RCOMP
] ? 1 : 0;
863 v
->value_int_4
[1] = ctx
->Color
.ColorMask
[GCOMP
] ? 1 : 0;
864 v
->value_int_4
[2] = ctx
->Color
.ColorMask
[BCOMP
] ? 1 : 0;
865 v
->value_int_4
[3] = ctx
->Color
.ColorMask
[ACOMP
] ? 1 : 0;
869 v
->value_bool
= ctx
->Current
.Attrib
[VERT_ATTRIB_EDGEFLAG
][0] == 1.0;
873 v
->value_enum
= ctx
->ReadBuffer
->ColorReadBuffer
;
876 case GL_MAP2_GRID_DOMAIN
:
877 v
->value_float_4
[0] = ctx
->Eval
.MapGrid2u1
;
878 v
->value_float_4
[1] = ctx
->Eval
.MapGrid2u2
;
879 v
->value_float_4
[2] = ctx
->Eval
.MapGrid2v1
;
880 v
->value_float_4
[3] = ctx
->Eval
.MapGrid2v2
;
883 case GL_TEXTURE_STACK_DEPTH
:
884 v
->value_int
= ctx
->TextureMatrixStack
.Depth
+ 1;
886 case GL_TEXTURE_MATRIX
:
887 v
->value_matrix
= ctx
->TextureMatrixStack
.Top
;
890 case GL_TEXTURE_COORD_ARRAY
:
891 case GL_TEXTURE_COORD_ARRAY_SIZE
:
892 case GL_TEXTURE_COORD_ARRAY_TYPE
:
893 case GL_TEXTURE_COORD_ARRAY_STRIDE
:
894 array
= &ctx
->Array
.VertexAttrib
[VERT_ATTRIB_TEX
];
895 v
->value_int
= *(GLuint
*) ((char *) array
+ d
->offset
);
898 case GL_MODELVIEW_STACK_DEPTH
:
899 case GL_PROJECTION_STACK_DEPTH
:
900 v
->value_int
= *(GLint
*) ((char *) ctx
+ d
->offset
) + 1;
903 case GL_MAX_TEXTURE_SIZE
:
904 case GL_MAX_3D_TEXTURE_SIZE
:
905 case GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB
:
906 p
= (GLuint
*) ((char *) ctx
+ d
->offset
);
907 v
->value_int
= 1 << (*p
- 1);
911 v
->value_int_4
[0] = ctx
->Scissor
.X
;
912 v
->value_int_4
[1] = ctx
->Scissor
.Y
;
913 v
->value_int_4
[2] = ctx
->Scissor
.Width
;
914 v
->value_int_4
[3] = ctx
->Scissor
.Height
;
919 ctx
->ListState
.CurrentList
? ctx
->ListState
.CurrentList
->Name
: 0;
922 if (!ctx
->CompileFlag
)
924 else if (ctx
->ExecuteFlag
)
925 v
->value_enum
= GL_COMPILE_AND_EXECUTE
;
927 v
->value_enum
= GL_COMPILE
;
931 v
->value_int_4
[0] = ctx
->Viewport
.X
;
932 v
->value_int_4
[1] = ctx
->Viewport
.Y
;
933 v
->value_int_4
[2] = ctx
->Viewport
.Width
;
934 v
->value_int_4
[3] = ctx
->Viewport
.Height
;
937 case GL_STENCIL_FAIL
:
938 v
->value_enum
= ctx
->Stencil
.FailFunc
;
940 case GL_STENCIL_FUNC
:
941 v
->value_enum
= ctx
->Stencil
.Function
;
943 case GL_STENCIL_PASS_DEPTH_FAIL
:
944 v
->value_enum
= ctx
->Stencil
.ZFailFunc
;
946 case GL_STENCIL_PASS_DEPTH_PASS
:
947 v
->value_enum
= ctx
->Stencil
.ZPassFunc
;
950 v
->value_int
= ctx
->Stencil
.Ref
;
952 case GL_STENCIL_VALUE_MASK
:
953 v
->value_int
= ctx
->Stencil
.ValueMask
;
955 case GL_STENCIL_WRITEMASK
:
956 v
->value_int
= ctx
->Stencil
.WriteMask
;
959 case GL_NUM_EXTENSIONS
:
960 v
->value_int
= _mesa_get_extension_count(ctx
);
963 case GL_IMPLEMENTATION_COLOR_READ_TYPE_OES
:
964 v
->value_int
= _mesa_get_color_read_type(ctx
);
966 case GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES
:
967 v
->value_int
= _mesa_get_color_read_format(ctx
);
970 case GL_CURRENT_MATRIX_STACK_DEPTH_ARB
:
971 v
->value_int
= ctx
->CurrentStack
->Depth
+ 1;
973 case GL_CURRENT_MATRIX_ARB
:
974 case GL_TRANSPOSE_CURRENT_MATRIX_ARB
:
975 v
->value_matrix
= ctx
->CurrentStack
->Top
;
978 /* Various object names */
980 case GL_TEXTURE_BINDING_1D
:
981 case GL_TEXTURE_BINDING_2D
:
982 case GL_TEXTURE_BINDING_3D
:
983 case GL_TEXTURE_BINDING_CUBE_MAP_ARB
:
985 ctx
->Texture
.Unit
.CurrentTex
[d
->offset
]->Name
;
988 /* GL_ARB_vertex_buffer_object */
989 case GL_VERTEX_ARRAY_BUFFER_BINDING_ARB
:
990 case GL_NORMAL_ARRAY_BUFFER_BINDING_ARB
:
991 case GL_COLOR_ARRAY_BUFFER_BINDING_ARB
:
992 case GL_INDEX_ARRAY_BUFFER_BINDING_ARB
:
993 case GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB
:
994 case GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB
:
995 case GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB
:
996 buffer_obj
= (struct gl_buffer_object
**)
997 ((char *) &ctx
->Array
+ d
->offset
);
998 v
->value_int
= (*buffer_obj
)->Name
;
1000 case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB
:
1002 ctx
->Array
.VertexAttrib
[VERT_ATTRIB_TEX
].BufferObj
->Name
;
1004 case GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB
:
1005 v
->value_int
= ctx
->Array
.ElementArrayBufferObj
->Name
;
1009 COPY_4FV(v
->value_float_4
, ctx
->Fog
.Color
);
1011 case GL_COLOR_CLEAR_VALUE
:
1012 v
->value_float_4
[0] = ctx
->Color
.ClearColor
.f
[0], 0.0F
, 1.0F
;
1013 v
->value_float_4
[1] = ctx
->Color
.ClearColor
.f
[1], 0.0F
, 1.0F
;
1014 v
->value_float_4
[2] = ctx
->Color
.ClearColor
.f
[2], 0.0F
, 1.0F
;
1015 v
->value_float_4
[3] = ctx
->Color
.ClearColor
.f
[3], 0.0F
, 1.0F
;
1017 case GL_ALPHA_TEST_REF
:
1018 v
->value_float
= ctx
->Color
.AlphaRef
;
1024 * Check extra constraints on a struct value_desc descriptor
1026 * If a struct value_desc has a non-NULL extra pointer, it means that
1027 * there are a number of extra constraints to check or actions to
1028 * perform. The extras is just an integer array where each integer
1029 * encode different constraints or actions.
1031 * \param ctx current context
1032 * \param func name of calling glGet*v() function for error reporting
1033 * \param d the struct value_desc that has the extra constraints
1035 * \return GL_FALSE if one of the constraints was not satisfied,
1036 * otherwise GL_TRUE.
1039 check_extra(struct gl_context
*ctx
, const char *func
, const struct value_desc
*d
)
1041 const GLuint version
= ctx
->VersionMajor
* 10 + ctx
->VersionMinor
;
1047 for (e
= d
->extra
; *e
!= EXTRA_END
; e
++)
1049 case EXTRA_VERSION_30
:
1050 if (version
>= 30) {
1055 case EXTRA_VERSION_31
:
1056 if (version
>= 31) {
1061 case EXTRA_VERSION_32
:
1062 if (version
>= 32) {
1067 case EXTRA_NEW_BUFFERS
:
1068 if (ctx
->NewState
& _NEW_BUFFERS
)
1069 _mesa_update_state(ctx
);
1071 case EXTRA_FLUSH_CURRENT
:
1072 FLUSH_CURRENT(ctx
, 0);
1074 case EXTRA_VALID_CLIP_DISTANCE
:
1075 if (d
->pname
- GL_CLIP_DISTANCE0
>= ctx
->Const
.MaxClipPlanes
) {
1076 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(clip distance %u)",
1077 func
, d
->pname
- GL_CLIP_DISTANCE0
);
1083 default: /* *e is a offset into the extension struct */
1085 if (*(GLboolean
*) ((char *) &ctx
->Extensions
+ *e
))
1090 if (total
> 0 && enabled
== 0) {
1091 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(pname=%s)", func
,
1092 _mesa_lookup_enum_by_nr(d
->pname
));
1099 static const struct value_desc error_value
=
1100 { 0, 0, TYPE_INVALID
, NO_OFFSET
, NO_EXTRA
};
1103 * Find the struct value_desc corresponding to the enum 'pname'.
1105 * We hash the enum value to get an index into the 'table' array,
1106 * which holds the index in the 'values' array of struct value_desc.
1107 * Once we've found the entry, we do the extra checks, if any, then
1108 * look up the value and return a pointer to it.
1110 * If the value has to be computed (for example, it's the result of a
1111 * function call or we need to add 1 to it), we use the tmp 'v' to
1114 * \param func name of glGet*v() func for error reporting
1115 * \param pname the enum value we're looking up
1116 * \param p is were we return the pointer to the value
1117 * \param v a tmp union value variable in the calling glGet*v() function
1119 * \return the struct value_desc corresponding to the enum or a struct
1120 * value_desc of TYPE_INVALID if not found. This lets the calling
1121 * glGet*v() function jump right into a switch statement and
1122 * handle errors there instead of having to check for NULL.
1124 static const struct value_desc
*
1125 find_value(const char *func
, GLenum pname
, void **p
, union value
*v
)
1127 GET_CURRENT_CONTEXT(ctx
);
1128 struct gl_texture_unit
*unit
;
1130 const struct value_desc
*d
;
1132 mask
= Elements(table
) - 1;
1133 hash
= (pname
* prime_factor
);
1135 int idx
= table
[hash
& mask
];
1137 /* If the enum isn't valid, the hash walk ends with index 0,
1138 * pointing to the first entry of values[] which doesn't hold
1139 * any valid enum. */
1140 if (unlikely(idx
== 0)) {
1141 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(pname=%s)", func
,
1142 _mesa_lookup_enum_by_nr(pname
));
1143 return &error_value
;
1147 if (likely(d
->pname
== pname
))
1153 if (unlikely(d
->extra
&& !check_extra(ctx
, func
, d
)))
1154 return &error_value
;
1156 switch (d
->location
) {
1158 *p
= ((char *) ctx
->DrawBuffer
+ d
->offset
);
1161 *p
= ((char *) ctx
+ d
->offset
);
1164 *p
= ((char *)&ctx
->Array
+ d
->offset
);
1167 unit
= &ctx
->Texture
.Unit
;
1168 *p
= ((char *) unit
+ d
->offset
);
1171 find_custom_value(ctx
, d
, v
);
1179 /* silence warning */
1180 return &error_value
;
1183 static const int transpose
[] = {
1191 _mesa_GetBooleanv(GLenum pname
, GLboolean
*params
)
1193 const struct value_desc
*d
;
1198 GET_CURRENT_CONTEXT(ctx
);
1200 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1202 d
= find_value("glGetBooleanv", pname
, &p
, &v
);
1207 params
[0] = INT_TO_BOOLEAN(d
->offset
);
1212 params
[3] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[3]);
1215 params
[2] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[2]);
1218 params
[1] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[1]);
1221 params
[0] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[0]);
1225 params
[0] = FLOAT_TO_BOOLEAN(((GLdouble
*) p
)[0]);
1229 params
[3] = INT_TO_BOOLEAN(((GLint
*) p
)[3]);
1231 params
[2] = INT_TO_BOOLEAN(((GLint
*) p
)[2]);
1234 params
[1] = INT_TO_BOOLEAN(((GLint
*) p
)[1]);
1237 params
[0] = INT_TO_BOOLEAN(((GLint
*) p
)[0]);
1241 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
1242 params
[i
] = INT_TO_BOOLEAN(v
.value_int_n
.ints
[i
]);
1246 params
[0] = INT64_TO_BOOLEAN(((GLint64
*) p
)[0]);
1250 params
[0] = ((GLboolean
*) p
)[0];
1254 m
= *(GLmatrix
**) p
;
1255 for (i
= 0; i
< 16; i
++)
1256 params
[i
] = FLOAT_TO_BOOLEAN(m
->m
[i
]);
1260 m
= *(GLmatrix
**) p
;
1261 for (i
= 0; i
< 16; i
++)
1262 params
[i
] = FLOAT_TO_BOOLEAN(m
->m
[transpose
[i
]]);
1273 shift
= d
->type
- TYPE_BIT_0
;
1274 params
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
1280 _mesa_GetFloatv(GLenum pname
, GLfloat
*params
)
1282 const struct value_desc
*d
;
1287 GET_CURRENT_CONTEXT(ctx
);
1289 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1291 d
= find_value("glGetFloatv", pname
, &p
, &v
);
1296 params
[0] = (GLfloat
) d
->offset
;
1301 params
[3] = ((GLfloat
*) p
)[3];
1304 params
[2] = ((GLfloat
*) p
)[2];
1307 params
[1] = ((GLfloat
*) p
)[1];
1310 params
[0] = ((GLfloat
*) p
)[0];
1314 params
[0] = ((GLdouble
*) p
)[0];
1318 params
[3] = (GLfloat
) (((GLint
*) p
)[3]);
1320 params
[2] = (GLfloat
) (((GLint
*) p
)[2]);
1323 params
[1] = (GLfloat
) (((GLint
*) p
)[1]);
1326 params
[0] = (GLfloat
) (((GLint
*) p
)[0]);
1330 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
1331 params
[i
] = INT_TO_FLOAT(v
.value_int_n
.ints
[i
]);
1335 params
[0] = ((GLint64
*) p
)[0];
1339 params
[0] = BOOLEAN_TO_FLOAT(*(GLboolean
*) p
);
1343 m
= *(GLmatrix
**) p
;
1344 for (i
= 0; i
< 16; i
++)
1345 params
[i
] = m
->m
[i
];
1349 m
= *(GLmatrix
**) p
;
1350 for (i
= 0; i
< 16; i
++)
1351 params
[i
] = m
->m
[transpose
[i
]];
1362 shift
= d
->type
- TYPE_BIT_0
;
1363 params
[0] = BOOLEAN_TO_FLOAT((*(GLbitfield
*) p
>> shift
) & 1);
1369 _mesa_GetIntegerv(GLenum pname
, GLint
*params
)
1371 const struct value_desc
*d
;
1376 GET_CURRENT_CONTEXT(ctx
);
1378 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1380 d
= find_value("glGetIntegerv", pname
, &p
, &v
);
1385 params
[0] = d
->offset
;
1389 params
[3] = IROUND(((GLfloat
*) p
)[3]);
1391 params
[2] = IROUND(((GLfloat
*) p
)[2]);
1393 params
[1] = IROUND(((GLfloat
*) p
)[1]);
1395 params
[0] = IROUND(((GLfloat
*) p
)[0]);
1399 params
[3] = FLOAT_TO_INT(((GLfloat
*) p
)[3]);
1401 params
[2] = FLOAT_TO_INT(((GLfloat
*) p
)[2]);
1403 params
[1] = FLOAT_TO_INT(((GLfloat
*) p
)[1]);
1405 params
[0] = FLOAT_TO_INT(((GLfloat
*) p
)[0]);
1409 params
[0] = FLOAT_TO_INT(((GLdouble
*) p
)[0]);
1413 params
[3] = ((GLint
*) p
)[3];
1415 params
[2] = ((GLint
*) p
)[2];
1418 params
[1] = ((GLint
*) p
)[1];
1421 params
[0] = ((GLint
*) p
)[0];
1425 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
1426 params
[i
] = v
.value_int_n
.ints
[i
];
1430 params
[0] = INT64_TO_INT(((GLint64
*) p
)[0]);
1434 params
[0] = BOOLEAN_TO_INT(*(GLboolean
*) p
);
1438 m
= *(GLmatrix
**) p
;
1439 for (i
= 0; i
< 16; i
++)
1440 params
[i
] = FLOAT_TO_INT(m
->m
[i
]);
1444 m
= *(GLmatrix
**) p
;
1445 for (i
= 0; i
< 16; i
++)
1446 params
[i
] = FLOAT_TO_INT(m
->m
[transpose
[i
]]);
1457 shift
= d
->type
- TYPE_BIT_0
;
1458 params
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
1465 _mesa_GetDoublev(GLenum pname
, GLdouble
*params
)
1467 const struct value_desc
*d
;
1472 GET_CURRENT_CONTEXT(ctx
);
1474 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1476 d
= find_value("glGetDoublev", pname
, &p
, &v
);
1481 params
[0] = d
->offset
;
1486 params
[3] = ((GLfloat
*) p
)[3];
1489 params
[2] = ((GLfloat
*) p
)[2];
1492 params
[1] = ((GLfloat
*) p
)[1];
1495 params
[0] = ((GLfloat
*) p
)[0];
1499 params
[0] = ((GLdouble
*) p
)[0];
1503 params
[3] = ((GLint
*) p
)[3];
1505 params
[2] = ((GLint
*) p
)[2];
1508 params
[1] = ((GLint
*) p
)[1];
1511 params
[0] = ((GLint
*) p
)[0];
1515 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
1516 params
[i
] = v
.value_int_n
.ints
[i
];
1520 params
[0] = ((GLint64
*) p
)[0];
1524 params
[0] = *(GLboolean
*) p
;
1528 m
= *(GLmatrix
**) p
;
1529 for (i
= 0; i
< 16; i
++)
1530 params
[i
] = m
->m
[i
];
1534 m
= *(GLmatrix
**) p
;
1535 for (i
= 0; i
< 16; i
++)
1536 params
[i
] = m
->m
[transpose
[i
]];
1547 shift
= d
->type
- TYPE_BIT_0
;
1548 params
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
1555 _mesa_GetFixedv(GLenum pname
, GLfixed
*params
)
1557 const struct value_desc
*d
;
1563 d
= find_value("glGetDoublev", pname
, &p
, &v
);
1568 params
[0] = INT_TO_FIXED(d
->offset
);
1573 params
[3] = FLOAT_TO_FIXED(((GLfloat
*) p
)[3]);
1576 params
[2] = FLOAT_TO_FIXED(((GLfloat
*) p
)[2]);
1579 params
[1] = FLOAT_TO_FIXED(((GLfloat
*) p
)[1]);
1582 params
[0] = FLOAT_TO_FIXED(((GLfloat
*) p
)[0]);
1586 params
[0] = FLOAT_TO_FIXED(((GLdouble
*) p
)[0]);
1590 params
[3] = INT_TO_FIXED(((GLint
*) p
)[3]);
1592 params
[2] = INT_TO_FIXED(((GLint
*) p
)[2]);
1595 params
[1] = INT_TO_FIXED(((GLint
*) p
)[1]);
1598 params
[0] = INT_TO_FIXED(((GLint
*) p
)[0]);
1602 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
1603 params
[i
] = INT_TO_FIXED(v
.value_int_n
.ints
[i
]);
1607 params
[0] = ((GLint64
*) p
)[0];
1611 params
[0] = BOOLEAN_TO_FIXED(((GLboolean
*) p
)[0]);
1615 m
= *(GLmatrix
**) p
;
1616 for (i
= 0; i
< 16; i
++)
1617 params
[i
] = FLOAT_TO_FIXED(m
->m
[i
]);
1621 m
= *(GLmatrix
**) p
;
1622 for (i
= 0; i
< 16; i
++)
1623 params
[i
] = FLOAT_TO_FIXED(m
->m
[transpose
[i
]]);
1634 shift
= d
->type
- TYPE_BIT_0
;
1635 params
[0] = BOOLEAN_TO_FIXED((*(GLbitfield
*) p
>> shift
) & 1);