get.c revision 3464ebd5
1/* 2 * Copyright (C) 2010 Brian Paul All Rights Reserved. 3 * Copyright (C) 2010 Intel Corporation 4 * 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: 11 * 12 * The above copyright notice and this permission notice shall be included 13 * in all copies or substantial portions of the Software. 14 * 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. 21 * 22 * Author: Kristian Høgsberg <krh@bitplanet.net> 23 */ 24 25#include "glheader.h" 26#include "context.h" 27#include "enable.h" 28#include "enums.h" 29#include "extensions.h" 30#include "get.h" 31#include "macros.h" 32#include "mfeatures.h" 33#include "mtypes.h" 34#include "state.h" 35#include "texcompress.h" 36#include "framebuffer.h" 37 38/* This is a table driven implemetation of the glGet*v() functions. 39 * The basic idea is that most getters just look up an int somewhere 40 * in struct gl_context and then convert it to a bool or float according to 41 * which of glGetIntegerv() glGetBooleanv() etc is being called. 42 * Instead of generating code to do this, we can just record the enum 43 * value and the offset into struct gl_context in an array of structs. Then 44 * in glGet*(), we lookup the struct for the enum in question, and use 45 * the offset to get the int we need. 46 * 47 * Sometimes we need to look up a float, a boolean, a bit in a 48 * bitfield, a matrix or other types instead, so we need to track the 49 * type of the value in struct gl_context. And sometimes the value isn't in 50 * struct gl_context but in the drawbuffer, the array object, current texture 51 * unit, or maybe it's a computed value. So we need to also track 52 * where or how to find the value. Finally, we sometimes need to 53 * check that one of a number of extensions are enabled, the GL 54 * version or flush or call _mesa_update_state(). This is done by 55 * attaching optional extra information to the value description 56 * struct, it's sort of like an array of opcodes that describe extra 57 * checks or actions. 58 * 59 * Putting all this together we end up with struct value_desc below, 60 * and with a couple of macros to help, the table of struct value_desc 61 * is about as concise as the specification in the old python script. 62 */ 63 64#undef CONST 65 66#define FLOAT_TO_BOOLEAN(X) ( (X) ? GL_TRUE : GL_FALSE ) 67#define FLOAT_TO_FIXED(F) ( ((F) * 65536.0f > INT_MAX) ? INT_MAX : \ 68 ((F) * 65536.0f < INT_MIN) ? INT_MIN : \ 69 (GLint) ((F) * 65536.0f) ) 70 71#define INT_TO_BOOLEAN(I) ( (I) ? GL_TRUE : GL_FALSE ) 72#define INT_TO_FIXED(I) ( ((I) > SHRT_MAX) ? INT_MAX : \ 73 ((I) < SHRT_MIN) ? INT_MIN : \ 74 (GLint) ((I) * 65536) ) 75 76#define INT64_TO_BOOLEAN(I) ( (I) ? GL_TRUE : GL_FALSE ) 77#define INT64_TO_INT(I) ( (GLint)((I > INT_MAX) ? INT_MAX : ((I < INT_MIN) ? INT_MIN : (I))) ) 78 79#define BOOLEAN_TO_INT(B) ( (GLint) (B) ) 80#define BOOLEAN_TO_INT64(B) ( (GLint64) (B) ) 81#define BOOLEAN_TO_FLOAT(B) ( (B) ? 1.0F : 0.0F ) 82#define BOOLEAN_TO_FIXED(B) ( (GLint) ((B) ? 1 : 0) << 16 ) 83 84#define ENUM_TO_INT64(E) ( (GLint64) (E) ) 85#define ENUM_TO_FIXED(E) (E) 86 87enum value_type { 88 TYPE_INVALID, 89 TYPE_API_MASK, 90 TYPE_INT, 91 TYPE_INT_2, 92 TYPE_INT_3, 93 TYPE_INT_4, 94 TYPE_INT_N, 95 TYPE_INT64, 96 TYPE_ENUM, 97 TYPE_ENUM_2, 98 TYPE_BOOLEAN, 99 TYPE_BIT_0, 100 TYPE_BIT_1, 101 TYPE_BIT_2, 102 TYPE_BIT_3, 103 TYPE_BIT_4, 104 TYPE_BIT_5, 105 TYPE_FLOAT, 106 TYPE_FLOAT_2, 107 TYPE_FLOAT_3, 108 TYPE_FLOAT_4, 109 TYPE_FLOATN, 110 TYPE_FLOATN_2, 111 TYPE_FLOATN_3, 112 TYPE_FLOATN_4, 113 TYPE_DOUBLEN, 114 TYPE_MATRIX, 115 TYPE_MATRIX_T, 116 TYPE_CONST 117}; 118 119enum value_location { 120 LOC_BUFFER, 121 LOC_CONTEXT, 122 LOC_ARRAY, 123 LOC_TEXUNIT, 124 LOC_CUSTOM 125}; 126 127enum value_extra { 128 EXTRA_END = 0x8000, 129 EXTRA_VERSION_30, 130 EXTRA_VERSION_31, 131 EXTRA_VERSION_32, 132 EXTRA_VERSION_ES2, 133 EXTRA_NEW_BUFFERS, 134 EXTRA_NEW_FRAG_CLAMP, 135 EXTRA_VALID_DRAW_BUFFER, 136 EXTRA_VALID_TEXTURE_UNIT, 137 EXTRA_FLUSH_CURRENT, 138}; 139 140#define NO_EXTRA NULL 141#define NO_OFFSET 0 142 143struct value_desc { 144 GLenum pname; 145 GLubyte location; /**< enum value_location */ 146 GLubyte type; /**< enum value_type */ 147 int offset; 148 const int *extra; 149}; 150 151union value { 152 GLfloat value_float; 153 GLfloat value_float_4[4]; 154 GLmatrix *value_matrix; 155 GLint value_int; 156 GLint value_int_4[4]; 157 GLint64 value_int64; 158 GLenum value_enum; 159 160 /* Sigh, see GL_COMPRESSED_TEXTURE_FORMATS_ARB handling */ 161 struct { 162 GLint n, ints[100]; 163 } value_int_n; 164 GLboolean value_bool; 165}; 166 167#define BUFFER_FIELD(field, type) \ 168 LOC_BUFFER, type, offsetof(struct gl_framebuffer, field) 169#define CONTEXT_FIELD(field, type) \ 170 LOC_CONTEXT, type, offsetof(struct gl_context, field) 171#define ARRAY_FIELD(field, type) \ 172 LOC_ARRAY, type, offsetof(struct gl_array_object, field) 173#define CONST(value) \ 174 LOC_CONTEXT, TYPE_CONST, value 175 176#define BUFFER_INT(field) BUFFER_FIELD(field, TYPE_INT) 177#define BUFFER_ENUM(field) BUFFER_FIELD(field, TYPE_ENUM) 178#define BUFFER_BOOL(field) BUFFER_FIELD(field, TYPE_BOOLEAN) 179 180#define CONTEXT_INT(field) CONTEXT_FIELD(field, TYPE_INT) 181#define CONTEXT_INT2(field) CONTEXT_FIELD(field, TYPE_INT_2) 182#define CONTEXT_INT64(field) CONTEXT_FIELD(field, TYPE_INT64) 183#define CONTEXT_ENUM(field) CONTEXT_FIELD(field, TYPE_ENUM) 184#define CONTEXT_ENUM2(field) CONTEXT_FIELD(field, TYPE_ENUM_2) 185#define CONTEXT_BOOL(field) CONTEXT_FIELD(field, TYPE_BOOLEAN) 186#define CONTEXT_BIT0(field) CONTEXT_FIELD(field, TYPE_BIT_0) 187#define CONTEXT_BIT1(field) CONTEXT_FIELD(field, TYPE_BIT_1) 188#define CONTEXT_BIT2(field) CONTEXT_FIELD(field, TYPE_BIT_2) 189#define CONTEXT_BIT3(field) CONTEXT_FIELD(field, TYPE_BIT_3) 190#define CONTEXT_BIT4(field) CONTEXT_FIELD(field, TYPE_BIT_4) 191#define CONTEXT_BIT5(field) CONTEXT_FIELD(field, TYPE_BIT_5) 192#define CONTEXT_FLOAT(field) CONTEXT_FIELD(field, TYPE_FLOAT) 193#define CONTEXT_FLOAT2(field) CONTEXT_FIELD(field, TYPE_FLOAT_2) 194#define CONTEXT_FLOAT3(field) CONTEXT_FIELD(field, TYPE_FLOAT_3) 195#define CONTEXT_FLOAT4(field) CONTEXT_FIELD(field, TYPE_FLOAT_4) 196#define CONTEXT_MATRIX(field) CONTEXT_FIELD(field, TYPE_MATRIX) 197#define CONTEXT_MATRIX_T(field) CONTEXT_FIELD(field, TYPE_MATRIX_T) 198 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) 202 203#define EXT(f) \ 204 offsetof(struct gl_extensions, f) 205 206#define EXTRA_EXT(e) \ 207 static const int extra_##e[] = { \ 208 EXT(e), EXTRA_END \ 209 } 210 211#define EXTRA_EXT2(e1, e2) \ 212 static const int extra_##e1##_##e2[] = { \ 213 EXT(e1), EXT(e2), EXTRA_END \ 214 } 215 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 220 * structs below. */ 221 222static const int extra_new_buffers[] = { 223 EXTRA_NEW_BUFFERS, 224 EXTRA_END 225}; 226 227static const int extra_new_frag_clamp[] = { 228 EXTRA_NEW_FRAG_CLAMP, 229 EXTRA_END 230}; 231 232static const int extra_valid_draw_buffer[] = { 233 EXTRA_VALID_DRAW_BUFFER, 234 EXTRA_END 235}; 236 237static const int extra_valid_texture_unit[] = { 238 EXTRA_VALID_TEXTURE_UNIT, 239 EXTRA_END 240}; 241 242static const int extra_flush_current_valid_texture_unit[] = { 243 EXTRA_FLUSH_CURRENT, 244 EXTRA_VALID_TEXTURE_UNIT, 245 EXTRA_END 246}; 247 248static const int extra_flush_current[] = { 249 EXTRA_FLUSH_CURRENT, 250 EXTRA_END 251}; 252 253static const int extra_new_buffers_OES_read_format[] = { 254 EXTRA_NEW_BUFFERS, 255 EXT(OES_read_format), 256 EXTRA_END 257}; 258 259static const int extra_EXT_secondary_color_flush_current[] = { 260 EXT(EXT_secondary_color), 261 EXTRA_FLUSH_CURRENT, 262 EXTRA_END 263}; 264 265static const int extra_EXT_fog_coord_flush_current[] = { 266 EXT(EXT_fog_coord), 267 EXTRA_FLUSH_CURRENT, 268 EXTRA_END 269}; 270 271static const int extra_EXT_texture_integer[] = { 272 EXT(EXT_texture_integer), 273 EXTRA_END 274}; 275 276static const int extra_EXT_gpu_shader4[] = { 277 EXT(EXT_gpu_shader4), 278 EXTRA_END 279}; 280 281static const int extra_ARB_sampler_objects[] = { 282 EXT(ARB_sampler_objects), 283 EXTRA_END 284}; 285 286 287EXTRA_EXT(ARB_ES2_compatibility); 288EXTRA_EXT(ARB_multitexture); 289EXTRA_EXT(ARB_texture_cube_map); 290EXTRA_EXT(MESA_texture_array); 291EXTRA_EXT2(EXT_secondary_color, ARB_vertex_program); 292EXTRA_EXT(EXT_secondary_color); 293EXTRA_EXT(EXT_fog_coord); 294EXTRA_EXT(EXT_texture_lod_bias); 295EXTRA_EXT(EXT_texture_filter_anisotropic); 296EXTRA_EXT(IBM_rasterpos_clip); 297EXTRA_EXT(NV_point_sprite); 298EXTRA_EXT(SGIS_generate_mipmap); 299EXTRA_EXT(NV_vertex_program); 300EXTRA_EXT(NV_fragment_program); 301EXTRA_EXT(NV_texture_rectangle); 302EXTRA_EXT(EXT_stencil_two_side); 303EXTRA_EXT(NV_light_max_exponent); 304EXTRA_EXT(EXT_depth_bounds_test); 305EXTRA_EXT(ARB_depth_clamp); 306EXTRA_EXT(ATI_fragment_shader); 307EXTRA_EXT(EXT_framebuffer_blit); 308EXTRA_EXT(ARB_shader_objects); 309EXTRA_EXT(EXT_provoking_vertex); 310EXTRA_EXT(ARB_fragment_shader); 311EXTRA_EXT(ARB_fragment_program); 312EXTRA_EXT2(ARB_framebuffer_object, EXT_framebuffer_multisample); 313EXTRA_EXT(EXT_framebuffer_object); 314EXTRA_EXT(APPLE_vertex_array_object); 315EXTRA_EXT(ARB_seamless_cube_map); 316EXTRA_EXT(EXT_compiled_vertex_array); 317EXTRA_EXT(ARB_sync); 318EXTRA_EXT(ARB_vertex_shader); 319EXTRA_EXT(EXT_transform_feedback); 320EXTRA_EXT(ARB_transform_feedback2); 321EXTRA_EXT(EXT_pixel_buffer_object); 322EXTRA_EXT(ARB_vertex_program); 323EXTRA_EXT2(NV_point_sprite, ARB_point_sprite); 324EXTRA_EXT2(ARB_fragment_program, NV_fragment_program); 325EXTRA_EXT2(ARB_vertex_program, NV_vertex_program); 326EXTRA_EXT2(ARB_vertex_program, ARB_fragment_program); 327EXTRA_EXT(ARB_vertex_buffer_object); 328EXTRA_EXT(ARB_geometry_shader4); 329EXTRA_EXT(ARB_copy_buffer); 330EXTRA_EXT(EXT_framebuffer_sRGB); 331EXTRA_EXT(ARB_texture_buffer_object); 332 333static const int 334extra_ARB_vertex_program_ARB_fragment_program_NV_vertex_program[] = { 335 EXT(ARB_vertex_program), 336 EXT(ARB_fragment_program), 337 EXT(NV_vertex_program), 338 EXTRA_END 339}; 340 341static const int 342extra_NV_vertex_program_ARB_vertex_program_ARB_fragment_program_NV_vertex_program[] = { 343 EXT(NV_vertex_program), 344 EXT(ARB_vertex_program), 345 EXT(ARB_fragment_program), 346 EXT(NV_vertex_program), 347 EXTRA_END 348}; 349 350static const int 351extra_NV_primitive_restart[] = { 352 EXT(NV_primitive_restart), 353 EXTRA_END 354}; 355 356static const int extra_version_30[] = { EXTRA_VERSION_30, EXTRA_END }; 357static const int extra_version_31[] = { EXTRA_VERSION_31, EXTRA_END }; 358static const int extra_version_32[] = { EXTRA_VERSION_32, EXTRA_END }; 359 360static const int 361extra_ARB_vertex_program_version_es2[] = { 362 EXT(ARB_vertex_program), 363 EXTRA_VERSION_ES2, 364 EXTRA_END 365}; 366 367#define API_OPENGL_BIT (1 << API_OPENGL) 368#define API_OPENGLES_BIT (1 << API_OPENGLES) 369#define API_OPENGLES2_BIT (1 << API_OPENGLES2) 370 371/* This is the big table describing all the enums we accept in 372 * glGet*v(). The table is partitioned into six parts: enums 373 * understood by all GL APIs (OpenGL, GLES and GLES2), enums shared 374 * between OpenGL and GLES, enums exclusive to GLES, etc for the 375 * remaining combinations. When we add the enums to the hash table in 376 * _mesa_init_get_hash(), we only add the enums for the API we're 377 * instantiating and the different sections are guarded by #if 378 * FEATURE_GL etc to make sure we only compile in the enums we may 379 * need. */ 380 381static const struct value_desc values[] = { 382 /* Enums shared between OpenGL, GLES1 and GLES2 */ 383 { 0, 0, TYPE_API_MASK, 384 API_OPENGL_BIT | API_OPENGLES_BIT | API_OPENGLES2_BIT, NO_EXTRA}, 385 { GL_ALPHA_BITS, BUFFER_INT(Visual.alphaBits), extra_new_buffers }, 386 { GL_BLEND, CONTEXT_BIT0(Color.BlendEnabled), NO_EXTRA }, 387 { GL_BLEND_SRC, CONTEXT_ENUM(Color.Blend[0].SrcRGB), NO_EXTRA }, 388 { GL_BLUE_BITS, BUFFER_INT(Visual.blueBits), extra_new_buffers }, 389 { GL_COLOR_CLEAR_VALUE, LOC_CUSTOM, TYPE_FLOATN_4, 0, extra_new_frag_clamp }, 390 { GL_COLOR_WRITEMASK, LOC_CUSTOM, TYPE_INT_4, 0, NO_EXTRA }, 391 { GL_CULL_FACE, CONTEXT_BOOL(Polygon.CullFlag), NO_EXTRA }, 392 { GL_CULL_FACE_MODE, CONTEXT_ENUM(Polygon.CullFaceMode), NO_EXTRA }, 393 { GL_DEPTH_BITS, BUFFER_INT(Visual.depthBits), NO_EXTRA }, 394 { GL_DEPTH_CLEAR_VALUE, CONTEXT_FIELD(Depth.Clear, TYPE_DOUBLEN), NO_EXTRA }, 395 { GL_DEPTH_FUNC, CONTEXT_ENUM(Depth.Func), NO_EXTRA }, 396 { GL_DEPTH_RANGE, CONTEXT_FIELD(Viewport.Near, TYPE_FLOATN_2), NO_EXTRA }, 397 { GL_DEPTH_TEST, CONTEXT_BOOL(Depth.Test), NO_EXTRA }, 398 { GL_DEPTH_WRITEMASK, CONTEXT_BOOL(Depth.Mask), NO_EXTRA }, 399 { GL_DITHER, CONTEXT_BOOL(Color.DitherFlag), NO_EXTRA }, 400 { GL_FRONT_FACE, CONTEXT_ENUM(Polygon.FrontFace), NO_EXTRA }, 401 { GL_GREEN_BITS, BUFFER_INT(Visual.greenBits), extra_new_buffers }, 402 { GL_LINE_WIDTH, CONTEXT_FLOAT(Line.Width), NO_EXTRA }, 403 { GL_ALIASED_LINE_WIDTH_RANGE, CONTEXT_FLOAT2(Const.MinLineWidth), NO_EXTRA }, 404 { GL_MAX_ELEMENTS_VERTICES, CONTEXT_INT(Const.MaxArrayLockSize), NO_EXTRA }, 405 { GL_MAX_ELEMENTS_INDICES, CONTEXT_INT(Const.MaxArrayLockSize), NO_EXTRA }, 406 { GL_MAX_TEXTURE_SIZE, LOC_CUSTOM, TYPE_INT, 407 offsetof(struct gl_context, Const.MaxTextureLevels), NO_EXTRA }, 408 { GL_MAX_VIEWPORT_DIMS, CONTEXT_INT2(Const.MaxViewportWidth), NO_EXTRA }, 409 { GL_PACK_ALIGNMENT, CONTEXT_INT(Pack.Alignment), NO_EXTRA }, 410 { GL_ALIASED_POINT_SIZE_RANGE, CONTEXT_FLOAT2(Const.MinPointSize), NO_EXTRA }, 411 { GL_POLYGON_OFFSET_FACTOR, CONTEXT_FLOAT(Polygon.OffsetFactor ), NO_EXTRA }, 412 { GL_POLYGON_OFFSET_UNITS, CONTEXT_FLOAT(Polygon.OffsetUnits ), NO_EXTRA }, 413 { GL_POLYGON_OFFSET_FILL, CONTEXT_BOOL(Polygon.OffsetFill), NO_EXTRA }, 414 { GL_RED_BITS, BUFFER_INT(Visual.redBits), extra_new_buffers }, 415 { GL_SCISSOR_BOX, LOC_CUSTOM, TYPE_INT_4, 0, NO_EXTRA }, 416 { GL_SCISSOR_TEST, CONTEXT_BOOL(Scissor.Enabled), NO_EXTRA }, 417 { GL_STENCIL_BITS, BUFFER_INT(Visual.stencilBits), NO_EXTRA }, 418 { GL_STENCIL_CLEAR_VALUE, CONTEXT_INT(Stencil.Clear), NO_EXTRA }, 419 { GL_STENCIL_FAIL, LOC_CUSTOM, TYPE_ENUM, NO_OFFSET, NO_EXTRA }, 420 { GL_STENCIL_FUNC, LOC_CUSTOM, TYPE_ENUM, NO_OFFSET, NO_EXTRA }, 421 { GL_STENCIL_PASS_DEPTH_FAIL, LOC_CUSTOM, TYPE_ENUM, NO_OFFSET, NO_EXTRA }, 422 { GL_STENCIL_PASS_DEPTH_PASS, LOC_CUSTOM, TYPE_ENUM, NO_OFFSET, NO_EXTRA }, 423 { GL_STENCIL_REF, LOC_CUSTOM, TYPE_INT, NO_OFFSET, NO_EXTRA }, 424 { GL_STENCIL_TEST, CONTEXT_BOOL(Stencil.Enabled), NO_EXTRA }, 425 { GL_STENCIL_VALUE_MASK, LOC_CUSTOM, TYPE_INT, NO_OFFSET, NO_EXTRA }, 426 { GL_STENCIL_WRITEMASK, LOC_CUSTOM, TYPE_INT, NO_OFFSET, NO_EXTRA }, 427 { GL_SUBPIXEL_BITS, CONTEXT_INT(Const.SubPixelBits), NO_EXTRA }, 428 { GL_TEXTURE_BINDING_2D, LOC_CUSTOM, TYPE_INT, TEXTURE_2D_INDEX, NO_EXTRA }, 429 { GL_UNPACK_ALIGNMENT, CONTEXT_INT(Unpack.Alignment), NO_EXTRA }, 430 { GL_VIEWPORT, LOC_CUSTOM, TYPE_INT_4, 0, NO_EXTRA }, 431 432 /* GL_ARB_multitexture */ 433 { GL_ACTIVE_TEXTURE_ARB, 434 LOC_CUSTOM, TYPE_INT, 0, extra_ARB_multitexture }, 435 436 /* Note that all the OES_* extensions require that the Mesa "struct 437 * gl_extensions" include a member with the name of the extension. 438 * That structure does not yet include OES extensions (and we're 439 * not sure whether it will). If it does, all the OES_* 440 * extensions below should mark the dependency. */ 441 442 /* GL_ARB_texture_cube_map */ 443 { GL_TEXTURE_BINDING_CUBE_MAP_ARB, LOC_CUSTOM, TYPE_INT, 444 TEXTURE_CUBE_INDEX, extra_ARB_texture_cube_map }, 445 { GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB, LOC_CUSTOM, TYPE_INT, 446 offsetof(struct gl_context, Const.MaxCubeTextureLevels), 447 extra_ARB_texture_cube_map }, /* XXX: OES_texture_cube_map */ 448 449 /* XXX: OES_blend_subtract */ 450 { GL_BLEND_SRC_RGB_EXT, CONTEXT_ENUM(Color.Blend[0].SrcRGB), NO_EXTRA }, 451 { GL_BLEND_DST_RGB_EXT, CONTEXT_ENUM(Color.Blend[0].DstRGB), NO_EXTRA }, 452 { GL_BLEND_SRC_ALPHA_EXT, CONTEXT_ENUM(Color.Blend[0].SrcA), NO_EXTRA }, 453 { GL_BLEND_DST_ALPHA_EXT, CONTEXT_ENUM(Color.Blend[0].DstA), NO_EXTRA }, 454 455 /* GL_BLEND_EQUATION_RGB, which is what we're really after, is 456 * defined identically to GL_BLEND_EQUATION. */ 457 { GL_BLEND_EQUATION, CONTEXT_ENUM(Color.Blend[0].EquationRGB), NO_EXTRA }, 458 { GL_BLEND_EQUATION_ALPHA_EXT, CONTEXT_ENUM(Color.Blend[0].EquationA), NO_EXTRA }, 459 460 /* GL_ARB_texture_compression */ 461 { GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB, LOC_CUSTOM, TYPE_INT, 0, NO_EXTRA }, 462 { GL_COMPRESSED_TEXTURE_FORMATS_ARB, LOC_CUSTOM, TYPE_INT_N, 0, NO_EXTRA }, 463 464 /* GL_ARB_multisample */ 465 { GL_SAMPLE_ALPHA_TO_COVERAGE_ARB, 466 CONTEXT_BOOL(Multisample.SampleAlphaToCoverage), NO_EXTRA }, 467 { GL_SAMPLE_COVERAGE_ARB, CONTEXT_BOOL(Multisample.SampleCoverage), NO_EXTRA }, 468 { GL_SAMPLE_COVERAGE_VALUE_ARB, 469 CONTEXT_FLOAT(Multisample.SampleCoverageValue), NO_EXTRA }, 470 { GL_SAMPLE_COVERAGE_INVERT_ARB, 471 CONTEXT_BOOL(Multisample.SampleCoverageInvert), NO_EXTRA }, 472 { GL_SAMPLE_BUFFERS_ARB, BUFFER_INT(Visual.sampleBuffers), NO_EXTRA }, 473 { GL_SAMPLES_ARB, BUFFER_INT(Visual.samples), NO_EXTRA }, 474 475 /* GL_SGIS_generate_mipmap */ 476 { GL_GENERATE_MIPMAP_HINT_SGIS, CONTEXT_ENUM(Hint.GenerateMipmap), 477 extra_SGIS_generate_mipmap }, 478 479 /* GL_ARB_vertex_buffer_object */ 480 { GL_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT, 0, NO_EXTRA }, 481 482 /* GL_ARB_vertex_buffer_object */ 483 /* GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB - not supported */ 484 { GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT, 0, 485 extra_ARB_vertex_buffer_object }, 486 487 /* GL_ARB_copy_buffer */ 488 { GL_COPY_READ_BUFFER, LOC_CUSTOM, TYPE_INT, 0, extra_ARB_copy_buffer }, 489 { GL_COPY_WRITE_BUFFER, LOC_CUSTOM, TYPE_INT, 0, extra_ARB_copy_buffer }, 490 491 /* GL_OES_read_format */ 492 { GL_IMPLEMENTATION_COLOR_READ_TYPE_OES, LOC_CUSTOM, TYPE_INT, 0, 493 extra_new_buffers_OES_read_format }, 494 { GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES, LOC_CUSTOM, TYPE_INT, 0, 495 extra_new_buffers_OES_read_format }, 496 497 /* GL_EXT_framebuffer_object */ 498 { GL_FRAMEBUFFER_BINDING_EXT, BUFFER_INT(Name), 499 extra_EXT_framebuffer_object }, 500 { GL_RENDERBUFFER_BINDING_EXT, LOC_CUSTOM, TYPE_INT, 0, 501 extra_EXT_framebuffer_object }, 502 { GL_MAX_RENDERBUFFER_SIZE_EXT, CONTEXT_INT(Const.MaxRenderbufferSize), 503 extra_EXT_framebuffer_object }, 504 505 /* This entry isn't spec'ed for GLES 2, but is needed for Mesa's 506 * GLSL: */ 507 { GL_MAX_CLIP_PLANES, CONTEXT_INT(Const.MaxClipPlanes), NO_EXTRA }, 508 509#if FEATURE_GL || FEATURE_ES1 510 /* Enums in OpenGL and GLES1 */ 511 { 0, 0, TYPE_API_MASK, API_OPENGL_BIT | API_OPENGLES_BIT, NO_EXTRA }, 512 { GL_MAX_LIGHTS, CONTEXT_INT(Const.MaxLights), NO_EXTRA }, 513 { GL_LIGHT0, CONTEXT_BOOL(Light.Light[0].Enabled), NO_EXTRA }, 514 { GL_LIGHT1, CONTEXT_BOOL(Light.Light[1].Enabled), NO_EXTRA }, 515 { GL_LIGHT2, CONTEXT_BOOL(Light.Light[2].Enabled), NO_EXTRA }, 516 { GL_LIGHT3, CONTEXT_BOOL(Light.Light[3].Enabled), NO_EXTRA }, 517 { GL_LIGHT4, CONTEXT_BOOL(Light.Light[4].Enabled), NO_EXTRA }, 518 { GL_LIGHT5, CONTEXT_BOOL(Light.Light[5].Enabled), NO_EXTRA }, 519 { GL_LIGHT6, CONTEXT_BOOL(Light.Light[6].Enabled), NO_EXTRA }, 520 { GL_LIGHT7, CONTEXT_BOOL(Light.Light[7].Enabled), NO_EXTRA }, 521 { GL_LIGHTING, CONTEXT_BOOL(Light.Enabled), NO_EXTRA }, 522 { GL_LIGHT_MODEL_AMBIENT, 523 CONTEXT_FIELD(Light.Model.Ambient[0], TYPE_FLOATN_4), NO_EXTRA }, 524 { GL_LIGHT_MODEL_TWO_SIDE, CONTEXT_BOOL(Light.Model.TwoSide), NO_EXTRA }, 525 { GL_ALPHA_TEST, CONTEXT_BOOL(Color.AlphaEnabled), NO_EXTRA }, 526 { GL_ALPHA_TEST_FUNC, CONTEXT_ENUM(Color.AlphaFunc), NO_EXTRA }, 527 { GL_ALPHA_TEST_REF, LOC_CUSTOM, TYPE_FLOATN, 0, extra_new_frag_clamp }, 528 { GL_BLEND_DST, CONTEXT_ENUM(Color.Blend[0].DstRGB), NO_EXTRA }, 529 { GL_CLIP_PLANE0, CONTEXT_BIT0(Transform.ClipPlanesEnabled), NO_EXTRA }, 530 { GL_CLIP_PLANE1, CONTEXT_BIT1(Transform.ClipPlanesEnabled), NO_EXTRA }, 531 { GL_CLIP_PLANE2, CONTEXT_BIT2(Transform.ClipPlanesEnabled), NO_EXTRA }, 532 { GL_CLIP_PLANE3, CONTEXT_BIT3(Transform.ClipPlanesEnabled), NO_EXTRA }, 533 { GL_CLIP_PLANE4, CONTEXT_BIT4(Transform.ClipPlanesEnabled), NO_EXTRA }, 534 { GL_CLIP_PLANE5, CONTEXT_BIT5(Transform.ClipPlanesEnabled), NO_EXTRA }, 535 { GL_COLOR_MATERIAL, CONTEXT_BOOL(Light.ColorMaterialEnabled), NO_EXTRA }, 536 { GL_CURRENT_COLOR, 537 CONTEXT_FIELD(Current.Attrib[VERT_ATTRIB_COLOR0][0], TYPE_FLOATN_4), 538 extra_flush_current }, 539 { GL_CURRENT_NORMAL, 540 CONTEXT_FIELD(Current.Attrib[VERT_ATTRIB_NORMAL][0], TYPE_FLOATN_3), 541 extra_flush_current }, 542 { GL_CURRENT_TEXTURE_COORDS, LOC_CUSTOM, TYPE_FLOAT_4, 0, 543 extra_flush_current_valid_texture_unit }, 544 { GL_DISTANCE_ATTENUATION_EXT, CONTEXT_FLOAT3(Point.Params[0]), NO_EXTRA }, 545 { GL_FOG, CONTEXT_BOOL(Fog.Enabled), NO_EXTRA }, 546 { GL_FOG_COLOR, LOC_CUSTOM, TYPE_FLOATN_4, 0, extra_new_frag_clamp }, 547 { GL_FOG_DENSITY, CONTEXT_FLOAT(Fog.Density), NO_EXTRA }, 548 { GL_FOG_END, CONTEXT_FLOAT(Fog.End), NO_EXTRA }, 549 { GL_FOG_HINT, CONTEXT_ENUM(Hint.Fog), NO_EXTRA }, 550 { GL_FOG_MODE, CONTEXT_ENUM(Fog.Mode), NO_EXTRA }, 551 { GL_FOG_START, CONTEXT_FLOAT(Fog.Start), NO_EXTRA }, 552 { GL_LINE_SMOOTH, CONTEXT_BOOL(Line.SmoothFlag), NO_EXTRA }, 553 { GL_LINE_SMOOTH_HINT, CONTEXT_ENUM(Hint.LineSmooth), NO_EXTRA }, 554 { GL_LINE_WIDTH_RANGE, CONTEXT_FLOAT2(Const.MinLineWidthAA), NO_EXTRA }, 555 { GL_COLOR_LOGIC_OP, CONTEXT_BOOL(Color.ColorLogicOpEnabled), NO_EXTRA }, 556 { GL_LOGIC_OP_MODE, CONTEXT_ENUM(Color.LogicOp), NO_EXTRA }, 557 { GL_MATRIX_MODE, CONTEXT_ENUM(Transform.MatrixMode), NO_EXTRA }, 558 { GL_MAX_MODELVIEW_STACK_DEPTH, CONST(MAX_MODELVIEW_STACK_DEPTH), NO_EXTRA }, 559 { GL_MAX_PROJECTION_STACK_DEPTH, CONST(MAX_PROJECTION_STACK_DEPTH), NO_EXTRA }, 560 { GL_MAX_TEXTURE_STACK_DEPTH, CONST(MAX_TEXTURE_STACK_DEPTH), NO_EXTRA }, 561 { GL_MODELVIEW_MATRIX, CONTEXT_MATRIX(ModelviewMatrixStack.Top), NO_EXTRA }, 562 { GL_MODELVIEW_STACK_DEPTH, LOC_CUSTOM, TYPE_INT, 563 offsetof(struct gl_context, ModelviewMatrixStack.Depth), NO_EXTRA }, 564 { GL_NORMALIZE, CONTEXT_BOOL(Transform.Normalize), NO_EXTRA }, 565 { GL_PACK_SKIP_IMAGES_EXT, CONTEXT_INT(Pack.SkipImages), NO_EXTRA }, 566 { GL_PERSPECTIVE_CORRECTION_HINT, CONTEXT_ENUM(Hint.PerspectiveCorrection), NO_EXTRA }, 567 { GL_POINT_SIZE, CONTEXT_FLOAT(Point.Size), NO_EXTRA }, 568 { GL_POINT_SIZE_RANGE, CONTEXT_FLOAT2(Const.MinPointSizeAA), NO_EXTRA }, 569 { GL_POINT_SMOOTH, CONTEXT_BOOL(Point.SmoothFlag), NO_EXTRA }, 570 { GL_POINT_SMOOTH_HINT, CONTEXT_ENUM(Hint.PointSmooth), NO_EXTRA }, 571 { GL_POINT_SIZE_MIN_EXT, CONTEXT_FLOAT(Point.MinSize), NO_EXTRA }, 572 { GL_POINT_SIZE_MAX_EXT, CONTEXT_FLOAT(Point.MaxSize), NO_EXTRA }, 573 { GL_POINT_FADE_THRESHOLD_SIZE_EXT, CONTEXT_FLOAT(Point.Threshold), NO_EXTRA }, 574 { GL_PROJECTION_MATRIX, CONTEXT_MATRIX(ProjectionMatrixStack.Top), NO_EXTRA }, 575 { GL_PROJECTION_STACK_DEPTH, LOC_CUSTOM, TYPE_INT, 576 offsetof(struct gl_context, ProjectionMatrixStack.Depth), NO_EXTRA }, 577 { GL_RESCALE_NORMAL, CONTEXT_BOOL(Transform.RescaleNormals), NO_EXTRA }, 578 { GL_SHADE_MODEL, CONTEXT_ENUM(Light.ShadeModel), NO_EXTRA }, 579 { GL_TEXTURE_2D, LOC_CUSTOM, TYPE_BOOLEAN, 0, NO_EXTRA }, 580 { GL_TEXTURE_MATRIX, LOC_CUSTOM, TYPE_MATRIX, 0, extra_valid_texture_unit }, 581 { GL_TEXTURE_STACK_DEPTH, LOC_CUSTOM, TYPE_INT, 0, 582 extra_valid_texture_unit }, 583 584 { GL_VERTEX_ARRAY, ARRAY_BOOL(Vertex.Enabled), NO_EXTRA }, 585 { GL_VERTEX_ARRAY_SIZE, ARRAY_INT(Vertex.Size), NO_EXTRA }, 586 { GL_VERTEX_ARRAY_TYPE, ARRAY_ENUM(Vertex.Type), NO_EXTRA }, 587 { GL_VERTEX_ARRAY_STRIDE, ARRAY_INT(Vertex.Stride), NO_EXTRA }, 588 { GL_NORMAL_ARRAY, ARRAY_BOOL(Normal.Enabled), NO_EXTRA }, 589 { GL_NORMAL_ARRAY_TYPE, ARRAY_ENUM(Normal.Type), NO_EXTRA }, 590 { GL_NORMAL_ARRAY_STRIDE, ARRAY_INT(Normal.Stride), NO_EXTRA }, 591 { GL_COLOR_ARRAY, ARRAY_BOOL(Color.Enabled), NO_EXTRA }, 592 { GL_COLOR_ARRAY_SIZE, ARRAY_INT(Color.Size), NO_EXTRA }, 593 { GL_COLOR_ARRAY_TYPE, ARRAY_ENUM(Color.Type), NO_EXTRA }, 594 { GL_COLOR_ARRAY_STRIDE, ARRAY_INT(Color.Stride), NO_EXTRA }, 595 { GL_TEXTURE_COORD_ARRAY, 596 LOC_CUSTOM, TYPE_BOOLEAN, offsetof(struct gl_client_array, Enabled), NO_EXTRA }, 597 { GL_TEXTURE_COORD_ARRAY_SIZE, 598 LOC_CUSTOM, TYPE_INT, offsetof(struct gl_client_array, Size), NO_EXTRA }, 599 { GL_TEXTURE_COORD_ARRAY_TYPE, 600 LOC_CUSTOM, TYPE_ENUM, offsetof(struct gl_client_array, Type), NO_EXTRA }, 601 { GL_TEXTURE_COORD_ARRAY_STRIDE, 602 LOC_CUSTOM, TYPE_INT, offsetof(struct gl_client_array, Stride), NO_EXTRA }, 603 604 /* GL_ARB_ES2_compatibility */ 605 { GL_SHADER_COMPILER, CONST(1), extra_ARB_ES2_compatibility }, 606 { GL_MAX_VARYING_VECTORS, CONTEXT_INT(Const.MaxVarying), 607 extra_ARB_ES2_compatibility }, 608 { GL_MAX_VERTEX_UNIFORM_VECTORS, LOC_CUSTOM, TYPE_INT, 0, 609 extra_ARB_ES2_compatibility }, 610 { GL_MAX_FRAGMENT_UNIFORM_VECTORS, LOC_CUSTOM, TYPE_INT, 0, 611 extra_ARB_ES2_compatibility }, 612 613 /* GL_ARB_multitexture */ 614 { GL_MAX_TEXTURE_UNITS_ARB, 615 CONTEXT_INT(Const.MaxTextureUnits), extra_ARB_multitexture }, 616 { GL_CLIENT_ACTIVE_TEXTURE_ARB, 617 LOC_CUSTOM, TYPE_INT, 0, extra_ARB_multitexture }, 618 619 /* GL_ARB_texture_cube_map */ 620 { GL_TEXTURE_CUBE_MAP_ARB, LOC_CUSTOM, TYPE_BOOLEAN, 0, NO_EXTRA }, 621 /* S, T, and R are always set at the same time */ 622 { GL_TEXTURE_GEN_STR_OES, LOC_TEXUNIT, TYPE_BIT_0, 623 offsetof(struct gl_texture_unit, TexGenEnabled), NO_EXTRA }, 624 625 /* GL_ARB_multisample */ 626 { GL_MULTISAMPLE_ARB, CONTEXT_BOOL(Multisample.Enabled), NO_EXTRA }, 627 { GL_SAMPLE_ALPHA_TO_ONE_ARB, CONTEXT_BOOL(Multisample.SampleAlphaToOne), NO_EXTRA }, 628 629 /* GL_ARB_vertex_buffer_object */ 630 { GL_VERTEX_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT, 631 offsetof(struct gl_array_object, Vertex.BufferObj), NO_EXTRA }, 632 { GL_NORMAL_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT, 633 offsetof(struct gl_array_object, Normal.BufferObj), NO_EXTRA }, 634 { GL_COLOR_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT, 635 offsetof(struct gl_array_object, Color.BufferObj), NO_EXTRA }, 636 { GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT, NO_OFFSET, NO_EXTRA }, 637 638 /* GL_OES_point_sprite */ 639 { GL_POINT_SPRITE_NV, 640 CONTEXT_BOOL(Point.PointSprite), 641 extra_NV_point_sprite_ARB_point_sprite }, 642 643 /* GL_ARB_fragment_shader */ 644 { GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB, 645 CONTEXT_INT(Const.FragmentProgram.MaxUniformComponents), 646 extra_ARB_fragment_shader }, 647 648 /* GL_ARB_vertex_shader */ 649 { GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB, 650 CONTEXT_INT(Const.VertexProgram.MaxUniformComponents), 651 extra_ARB_vertex_shader }, 652 { GL_MAX_VARYING_FLOATS_ARB, LOC_CUSTOM, TYPE_INT, 0, 653 extra_ARB_vertex_shader }, 654 655 /* GL_EXT_texture_lod_bias */ 656 { GL_MAX_TEXTURE_LOD_BIAS_EXT, CONTEXT_FLOAT(Const.MaxTextureLodBias), 657 extra_EXT_texture_lod_bias }, 658 659 /* GL_EXT_texture_filter_anisotropic */ 660 { GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, 661 CONTEXT_FLOAT(Const.MaxTextureMaxAnisotropy), 662 extra_EXT_texture_filter_anisotropic }, 663#endif /* FEATURE_GL || FEATURE_ES1 */ 664 665#if FEATURE_ES1 666 { 0, 0, TYPE_API_MASK, API_OPENGLES_BIT }, 667 /* XXX: OES_matrix_get */ 668 { GL_MODELVIEW_MATRIX_FLOAT_AS_INT_BITS_OES }, 669 { GL_PROJECTION_MATRIX_FLOAT_AS_INT_BITS_OES }, 670 { GL_TEXTURE_MATRIX_FLOAT_AS_INT_BITS_OES }, 671 672 /* OES_point_size_array */ 673 { GL_POINT_SIZE_ARRAY_OES, ARRAY_FIELD(PointSize.Enabled, TYPE_BOOLEAN) }, 674 { GL_POINT_SIZE_ARRAY_TYPE_OES, ARRAY_FIELD(PointSize.Type, TYPE_ENUM) }, 675 { GL_POINT_SIZE_ARRAY_STRIDE_OES, ARRAY_FIELD(PointSize.Stride, TYPE_INT) }, 676 { GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES, LOC_CUSTOM, TYPE_INT, 0 }, 677#endif /* FEATURE_ES1 */ 678 679#if FEATURE_GL || FEATURE_ES2 680 { 0, 0, TYPE_API_MASK, API_OPENGL_BIT | API_OPENGLES2_BIT, NO_EXTRA }, 681 { GL_MAX_TEXTURE_COORDS_ARB, /* == GL_MAX_TEXTURE_COORDS_NV */ 682 CONTEXT_INT(Const.MaxTextureCoordUnits), 683 extra_ARB_fragment_program_NV_fragment_program }, 684 685 /* GL_ARB_draw_buffers */ 686 { GL_MAX_DRAW_BUFFERS_ARB, CONTEXT_INT(Const.MaxDrawBuffers), NO_EXTRA }, 687 688 { GL_BLEND_COLOR_EXT, LOC_CUSTOM, TYPE_FLOATN_4, 0, extra_new_frag_clamp }, 689 /* GL_ARB_fragment_program */ 690 { GL_MAX_TEXTURE_IMAGE_UNITS_ARB, /* == GL_MAX_TEXTURE_IMAGE_UNITS_NV */ 691 CONTEXT_INT(Const.MaxTextureImageUnits), 692 extra_ARB_fragment_program_NV_fragment_program }, 693 { GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB, 694 CONTEXT_INT(Const.MaxVertexTextureImageUnits), extra_ARB_vertex_shader }, 695 { GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB, 696 CONTEXT_INT(Const.MaxCombinedTextureImageUnits), 697 extra_ARB_vertex_shader }, 698 699 /* GL_ARB_shader_objects 700 * Actually, this token isn't part of GL_ARB_shader_objects, but is 701 * close enough for now. */ 702 { GL_CURRENT_PROGRAM, LOC_CUSTOM, TYPE_INT, 0, extra_ARB_shader_objects }, 703 704 /* OpenGL 2.0 */ 705 { GL_STENCIL_BACK_FUNC, CONTEXT_ENUM(Stencil.Function[1]), NO_EXTRA }, 706 { GL_STENCIL_BACK_VALUE_MASK, CONTEXT_INT(Stencil.ValueMask[1]), NO_EXTRA }, 707 { GL_STENCIL_BACK_WRITEMASK, CONTEXT_INT(Stencil.WriteMask[1]), NO_EXTRA }, 708 { GL_STENCIL_BACK_REF, CONTEXT_INT(Stencil.Ref[1]), NO_EXTRA }, 709 { GL_STENCIL_BACK_FAIL, CONTEXT_ENUM(Stencil.FailFunc[1]), NO_EXTRA }, 710 { GL_STENCIL_BACK_PASS_DEPTH_FAIL, CONTEXT_ENUM(Stencil.ZFailFunc[1]), NO_EXTRA }, 711 { GL_STENCIL_BACK_PASS_DEPTH_PASS, CONTEXT_ENUM(Stencil.ZPassFunc[1]), NO_EXTRA }, 712 713 { GL_MAX_VERTEX_ATTRIBS_ARB, 714 CONTEXT_INT(Const.VertexProgram.MaxAttribs), 715 extra_ARB_vertex_program_version_es2 }, 716 717 /* OES_texture_3D */ 718 { GL_TEXTURE_BINDING_3D, LOC_CUSTOM, TYPE_INT, TEXTURE_3D_INDEX, NO_EXTRA }, 719 { GL_MAX_3D_TEXTURE_SIZE, LOC_CUSTOM, TYPE_INT, 720 offsetof(struct gl_context, Const.Max3DTextureLevels), NO_EXTRA }, 721 722 /* GL_ARB_fragment_program/OES_standard_derivatives */ 723 { GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB, 724 CONTEXT_ENUM(Hint.FragmentShaderDerivative), extra_ARB_fragment_shader }, 725#endif /* FEATURE_GL || FEATURE_ES2 */ 726 727#if FEATURE_ES2 728 /* Enums unique to OpenGL ES 2.0 */ 729 { 0, 0, TYPE_API_MASK, API_OPENGLES2_BIT, NO_EXTRA }, 730 { GL_MAX_FRAGMENT_UNIFORM_VECTORS, LOC_CUSTOM, TYPE_INT, 0, NO_EXTRA }, 731 { GL_MAX_VARYING_VECTORS, CONTEXT_INT(Const.MaxVarying), NO_EXTRA }, 732 { GL_MAX_VERTEX_UNIFORM_VECTORS, LOC_CUSTOM, TYPE_INT, 0, NO_EXTRA }, 733 { GL_SHADER_COMPILER, CONST(1), NO_EXTRA }, 734 /* OES_get_program_binary */ 735 { GL_NUM_SHADER_BINARY_FORMATS, CONST(0), NO_EXTRA }, 736 { GL_SHADER_BINARY_FORMATS, CONST(0), NO_EXTRA }, 737#endif /* FEATURE_ES2 */ 738 739#if FEATURE_GL 740 /* Remaining enums are only in OpenGL */ 741 { 0, 0, TYPE_API_MASK, API_OPENGL_BIT, NO_EXTRA }, 742 { GL_ACCUM_RED_BITS, BUFFER_INT(Visual.accumRedBits), NO_EXTRA }, 743 { GL_ACCUM_GREEN_BITS, BUFFER_INT(Visual.accumGreenBits), NO_EXTRA }, 744 { GL_ACCUM_BLUE_BITS, BUFFER_INT(Visual.accumBlueBits), NO_EXTRA }, 745 { GL_ACCUM_ALPHA_BITS, BUFFER_INT(Visual.accumAlphaBits), NO_EXTRA }, 746 { GL_ACCUM_CLEAR_VALUE, CONTEXT_FIELD(Accum.ClearColor[0], TYPE_FLOATN_4), NO_EXTRA }, 747 { GL_ALPHA_BIAS, CONTEXT_FLOAT(Pixel.AlphaBias), NO_EXTRA }, 748 { GL_ALPHA_SCALE, CONTEXT_FLOAT(Pixel.AlphaScale), NO_EXTRA }, 749 { GL_ATTRIB_STACK_DEPTH, CONTEXT_INT(AttribStackDepth), NO_EXTRA }, 750 { GL_AUTO_NORMAL, CONTEXT_BOOL(Eval.AutoNormal), NO_EXTRA }, 751 { GL_AUX_BUFFERS, BUFFER_INT(Visual.numAuxBuffers), NO_EXTRA }, 752 { GL_BLUE_BIAS, CONTEXT_FLOAT(Pixel.BlueBias), NO_EXTRA }, 753 { GL_BLUE_SCALE, CONTEXT_FLOAT(Pixel.BlueScale), NO_EXTRA }, 754 { GL_CLIENT_ATTRIB_STACK_DEPTH, CONTEXT_INT(ClientAttribStackDepth), NO_EXTRA }, 755 { GL_COLOR_MATERIAL_FACE, CONTEXT_ENUM(Light.ColorMaterialFace), NO_EXTRA }, 756 { GL_COLOR_MATERIAL_PARAMETER, CONTEXT_ENUM(Light.ColorMaterialMode), NO_EXTRA }, 757 { GL_CURRENT_INDEX, 758 CONTEXT_FLOAT(Current.Attrib[VERT_ATTRIB_COLOR_INDEX][0]), 759 extra_flush_current }, 760 { GL_CURRENT_RASTER_COLOR, 761 CONTEXT_FIELD(Current.RasterColor[0], TYPE_FLOATN_4), NO_EXTRA }, 762 { GL_CURRENT_RASTER_DISTANCE, CONTEXT_FLOAT(Current.RasterDistance), NO_EXTRA }, 763 { GL_CURRENT_RASTER_INDEX, CONST(1), NO_EXTRA }, 764 { GL_CURRENT_RASTER_POSITION, CONTEXT_FLOAT4(Current.RasterPos[0]), NO_EXTRA }, 765 { GL_CURRENT_RASTER_SECONDARY_COLOR, 766 CONTEXT_FIELD(Current.RasterSecondaryColor[0], TYPE_FLOATN_4), NO_EXTRA }, 767 { GL_CURRENT_RASTER_TEXTURE_COORDS, LOC_CUSTOM, TYPE_FLOAT_4, 0, 768 extra_valid_texture_unit }, 769 { GL_CURRENT_RASTER_POSITION_VALID, CONTEXT_BOOL(Current.RasterPosValid), NO_EXTRA }, 770 { GL_DEPTH_BIAS, CONTEXT_FLOAT(Pixel.DepthBias), NO_EXTRA }, 771 { GL_DEPTH_SCALE, CONTEXT_FLOAT(Pixel.DepthScale), NO_EXTRA }, 772 { GL_DOUBLEBUFFER, BUFFER_INT(Visual.doubleBufferMode), NO_EXTRA }, 773 { GL_DRAW_BUFFER, BUFFER_ENUM(ColorDrawBuffer[0]), NO_EXTRA }, 774 { GL_EDGE_FLAG, LOC_CUSTOM, TYPE_BOOLEAN, 0, NO_EXTRA }, 775 { GL_FEEDBACK_BUFFER_SIZE, CONTEXT_INT(Feedback.BufferSize), NO_EXTRA }, 776 { GL_FEEDBACK_BUFFER_TYPE, CONTEXT_ENUM(Feedback.Type), NO_EXTRA }, 777 { GL_FOG_INDEX, CONTEXT_FLOAT(Fog.Index), NO_EXTRA }, 778 { GL_GREEN_BIAS, CONTEXT_FLOAT(Pixel.GreenBias), NO_EXTRA }, 779 { GL_GREEN_SCALE, CONTEXT_FLOAT(Pixel.GreenScale), NO_EXTRA }, 780 { GL_INDEX_BITS, BUFFER_INT(Visual.indexBits), extra_new_buffers }, 781 { GL_INDEX_CLEAR_VALUE, CONTEXT_INT(Color.ClearIndex), NO_EXTRA }, 782 { GL_INDEX_MODE, CONST(0) , NO_EXTRA}, 783 { GL_INDEX_OFFSET, CONTEXT_INT(Pixel.IndexOffset), NO_EXTRA }, 784 { GL_INDEX_SHIFT, CONTEXT_INT(Pixel.IndexShift), NO_EXTRA }, 785 { GL_INDEX_WRITEMASK, CONTEXT_INT(Color.IndexMask), NO_EXTRA }, 786 { GL_LIGHT_MODEL_COLOR_CONTROL, CONTEXT_ENUM(Light.Model.ColorControl), NO_EXTRA }, 787 { GL_LIGHT_MODEL_LOCAL_VIEWER, CONTEXT_BOOL(Light.Model.LocalViewer), NO_EXTRA }, 788 { GL_LINE_STIPPLE, CONTEXT_BOOL(Line.StippleFlag), NO_EXTRA }, 789 { GL_LINE_STIPPLE_PATTERN, LOC_CUSTOM, TYPE_INT, 0, NO_EXTRA }, 790 { GL_LINE_STIPPLE_REPEAT, CONTEXT_INT(Line.StippleFactor), NO_EXTRA }, 791 { GL_LINE_WIDTH_GRANULARITY, CONTEXT_FLOAT(Const.LineWidthGranularity), NO_EXTRA }, 792 { GL_LIST_BASE, CONTEXT_INT(List.ListBase), NO_EXTRA }, 793 { GL_LIST_INDEX, LOC_CUSTOM, TYPE_INT, 0, NO_EXTRA }, 794 { GL_LIST_MODE, LOC_CUSTOM, TYPE_ENUM, 0, NO_EXTRA }, 795 { GL_INDEX_LOGIC_OP, CONTEXT_BOOL(Color.IndexLogicOpEnabled), NO_EXTRA }, 796 { GL_MAP1_COLOR_4, CONTEXT_BOOL(Eval.Map1Color4), NO_EXTRA }, 797 { GL_MAP1_GRID_DOMAIN, CONTEXT_FLOAT2(Eval.MapGrid1u1), NO_EXTRA }, 798 { GL_MAP1_GRID_SEGMENTS, CONTEXT_INT(Eval.MapGrid1un), NO_EXTRA }, 799 { GL_MAP1_INDEX, CONTEXT_BOOL(Eval.Map1Index), NO_EXTRA }, 800 { GL_MAP1_NORMAL, CONTEXT_BOOL(Eval.Map1Normal), NO_EXTRA }, 801 { GL_MAP1_TEXTURE_COORD_1, CONTEXT_BOOL(Eval.Map1TextureCoord1), NO_EXTRA }, 802 { GL_MAP1_TEXTURE_COORD_2, CONTEXT_BOOL(Eval.Map1TextureCoord2), NO_EXTRA }, 803 { GL_MAP1_TEXTURE_COORD_3, CONTEXT_BOOL(Eval.Map1TextureCoord3), NO_EXTRA }, 804 { GL_MAP1_TEXTURE_COORD_4, CONTEXT_BOOL(Eval.Map1TextureCoord4), NO_EXTRA }, 805 { GL_MAP1_VERTEX_3, CONTEXT_BOOL(Eval.Map1Vertex3), NO_EXTRA }, 806 { GL_MAP1_VERTEX_4, CONTEXT_BOOL(Eval.Map1Vertex4), NO_EXTRA }, 807 { GL_MAP2_COLOR_4, CONTEXT_BOOL(Eval.Map2Color4), NO_EXTRA }, 808 { GL_MAP2_GRID_DOMAIN, LOC_CUSTOM, TYPE_FLOAT_4, 0, NO_EXTRA }, 809 { GL_MAP2_GRID_SEGMENTS, CONTEXT_INT2(Eval.MapGrid2un), NO_EXTRA }, 810 { GL_MAP2_INDEX, CONTEXT_BOOL(Eval.Map2Index), NO_EXTRA }, 811 { GL_MAP2_NORMAL, CONTEXT_BOOL(Eval.Map2Normal), NO_EXTRA }, 812 { GL_MAP2_TEXTURE_COORD_1, CONTEXT_BOOL(Eval.Map2TextureCoord1), NO_EXTRA }, 813 { GL_MAP2_TEXTURE_COORD_2, CONTEXT_BOOL(Eval.Map2TextureCoord2), NO_EXTRA }, 814 { GL_MAP2_TEXTURE_COORD_3, CONTEXT_BOOL(Eval.Map2TextureCoord3), NO_EXTRA }, 815 { GL_MAP2_TEXTURE_COORD_4, CONTEXT_BOOL(Eval.Map2TextureCoord4), NO_EXTRA }, 816 { GL_MAP2_VERTEX_3, CONTEXT_BOOL(Eval.Map2Vertex3), NO_EXTRA }, 817 { GL_MAP2_VERTEX_4, CONTEXT_BOOL(Eval.Map2Vertex4), NO_EXTRA }, 818 { GL_MAP_COLOR, CONTEXT_BOOL(Pixel.MapColorFlag), NO_EXTRA }, 819 { GL_MAP_STENCIL, CONTEXT_BOOL(Pixel.MapStencilFlag), NO_EXTRA }, 820 { GL_MAX_ATTRIB_STACK_DEPTH, CONST(MAX_ATTRIB_STACK_DEPTH), NO_EXTRA }, 821 { GL_MAX_CLIENT_ATTRIB_STACK_DEPTH, CONST(MAX_CLIENT_ATTRIB_STACK_DEPTH), NO_EXTRA }, 822 823 { GL_MAX_EVAL_ORDER, CONST(MAX_EVAL_ORDER), NO_EXTRA }, 824 { GL_MAX_LIST_NESTING, CONST(MAX_LIST_NESTING), NO_EXTRA }, 825 { GL_MAX_NAME_STACK_DEPTH, CONST(MAX_NAME_STACK_DEPTH), NO_EXTRA }, 826 { GL_MAX_PIXEL_MAP_TABLE, CONST(MAX_PIXEL_MAP_TABLE), NO_EXTRA }, 827 { GL_NAME_STACK_DEPTH, CONTEXT_INT(Select.NameStackDepth), NO_EXTRA }, 828 { GL_PACK_LSB_FIRST, CONTEXT_BOOL(Pack.LsbFirst), NO_EXTRA }, 829 { GL_PACK_ROW_LENGTH, CONTEXT_INT(Pack.RowLength), NO_EXTRA }, 830 { GL_PACK_SKIP_PIXELS, CONTEXT_INT(Pack.SkipPixels), NO_EXTRA }, 831 { GL_PACK_SKIP_ROWS, CONTEXT_INT(Pack.SkipRows), NO_EXTRA }, 832 { GL_PACK_SWAP_BYTES, CONTEXT_BOOL(Pack.SwapBytes), NO_EXTRA }, 833 { GL_PACK_IMAGE_HEIGHT_EXT, CONTEXT_INT(Pack.ImageHeight), NO_EXTRA }, 834 { GL_PACK_INVERT_MESA, CONTEXT_BOOL(Pack.Invert), NO_EXTRA }, 835 { GL_PIXEL_MAP_A_TO_A_SIZE, CONTEXT_INT(PixelMaps.AtoA.Size), NO_EXTRA }, 836 { GL_PIXEL_MAP_B_TO_B_SIZE, CONTEXT_INT(PixelMaps.BtoB.Size), NO_EXTRA }, 837 { GL_PIXEL_MAP_G_TO_G_SIZE, CONTEXT_INT(PixelMaps.GtoG.Size), NO_EXTRA }, 838 { GL_PIXEL_MAP_I_TO_A_SIZE, CONTEXT_INT(PixelMaps.ItoA.Size), NO_EXTRA }, 839 { GL_PIXEL_MAP_I_TO_B_SIZE, CONTEXT_INT(PixelMaps.ItoB.Size), NO_EXTRA }, 840 { GL_PIXEL_MAP_I_TO_G_SIZE, CONTEXT_INT(PixelMaps.ItoG.Size), NO_EXTRA }, 841 { GL_PIXEL_MAP_I_TO_I_SIZE, CONTEXT_INT(PixelMaps.ItoI.Size), NO_EXTRA }, 842 { GL_PIXEL_MAP_I_TO_R_SIZE, CONTEXT_INT(PixelMaps.ItoR.Size), NO_EXTRA }, 843 { GL_PIXEL_MAP_R_TO_R_SIZE, CONTEXT_INT(PixelMaps.RtoR.Size), NO_EXTRA }, 844 { GL_PIXEL_MAP_S_TO_S_SIZE, CONTEXT_INT(PixelMaps.StoS.Size), NO_EXTRA }, 845 { GL_POINT_SIZE_GRANULARITY, CONTEXT_FLOAT(Const.PointSizeGranularity), NO_EXTRA }, 846 { GL_POLYGON_MODE, CONTEXT_ENUM2(Polygon.FrontMode), NO_EXTRA }, 847 { GL_POLYGON_OFFSET_BIAS_EXT, CONTEXT_FLOAT(Polygon.OffsetUnits), NO_EXTRA }, 848 { GL_POLYGON_OFFSET_POINT, CONTEXT_BOOL(Polygon.OffsetPoint), NO_EXTRA }, 849 { GL_POLYGON_OFFSET_LINE, CONTEXT_BOOL(Polygon.OffsetLine), NO_EXTRA }, 850 { GL_POLYGON_SMOOTH, CONTEXT_BOOL(Polygon.SmoothFlag), NO_EXTRA }, 851 { GL_POLYGON_SMOOTH_HINT, CONTEXT_ENUM(Hint.PolygonSmooth), NO_EXTRA }, 852 { GL_POLYGON_STIPPLE, CONTEXT_BOOL(Polygon.StippleFlag), NO_EXTRA }, 853 { GL_READ_BUFFER, LOC_CUSTOM, TYPE_ENUM, NO_OFFSET, NO_EXTRA }, 854 { GL_RED_BIAS, CONTEXT_FLOAT(Pixel.RedBias), NO_EXTRA }, 855 { GL_RED_SCALE, CONTEXT_FLOAT(Pixel.RedScale), NO_EXTRA }, 856 { GL_RENDER_MODE, CONTEXT_ENUM(RenderMode), NO_EXTRA }, 857 { GL_RGBA_MODE, CONST(1), NO_EXTRA }, 858 { GL_SELECTION_BUFFER_SIZE, CONTEXT_INT(Select.BufferSize), NO_EXTRA }, 859 { GL_SHARED_TEXTURE_PALETTE_EXT, CONTEXT_BOOL(Texture.SharedPalette), NO_EXTRA }, 860 861 { GL_STEREO, BUFFER_INT(Visual.stereoMode), NO_EXTRA }, 862 863 { GL_TEXTURE_1D, LOC_CUSTOM, TYPE_BOOLEAN, NO_OFFSET, NO_EXTRA }, 864 { GL_TEXTURE_3D, LOC_CUSTOM, TYPE_BOOLEAN, NO_OFFSET, NO_EXTRA }, 865 { GL_TEXTURE_1D_ARRAY_EXT, LOC_CUSTOM, TYPE_BOOLEAN, NO_OFFSET, NO_EXTRA }, 866 { GL_TEXTURE_2D_ARRAY_EXT, LOC_CUSTOM, TYPE_BOOLEAN, NO_OFFSET, NO_EXTRA }, 867 868 { GL_TEXTURE_BINDING_1D, LOC_CUSTOM, TYPE_INT, TEXTURE_1D_INDEX, NO_EXTRA }, 869 { GL_TEXTURE_BINDING_1D_ARRAY, LOC_CUSTOM, TYPE_INT, 870 TEXTURE_1D_ARRAY_INDEX, extra_MESA_texture_array }, 871 { GL_TEXTURE_BINDING_2D_ARRAY, LOC_CUSTOM, TYPE_INT, 872 TEXTURE_1D_ARRAY_INDEX, extra_MESA_texture_array }, 873 { GL_MAX_ARRAY_TEXTURE_LAYERS_EXT, 874 CONTEXT_INT(Const.MaxArrayTextureLayers), extra_MESA_texture_array }, 875 876 { GL_TEXTURE_GEN_S, LOC_TEXUNIT, TYPE_BIT_0, 877 offsetof(struct gl_texture_unit, TexGenEnabled), NO_EXTRA }, 878 { GL_TEXTURE_GEN_T, LOC_TEXUNIT, TYPE_BIT_1, 879 offsetof(struct gl_texture_unit, TexGenEnabled), NO_EXTRA }, 880 { GL_TEXTURE_GEN_R, LOC_TEXUNIT, TYPE_BIT_2, 881 offsetof(struct gl_texture_unit, TexGenEnabled), NO_EXTRA }, 882 { GL_TEXTURE_GEN_Q, LOC_TEXUNIT, TYPE_BIT_3, 883 offsetof(struct gl_texture_unit, TexGenEnabled), NO_EXTRA }, 884 { GL_UNPACK_LSB_FIRST, CONTEXT_BOOL(Unpack.LsbFirst), NO_EXTRA }, 885 { GL_UNPACK_ROW_LENGTH, CONTEXT_INT(Unpack.RowLength), NO_EXTRA }, 886 { GL_UNPACK_SKIP_PIXELS, CONTEXT_INT(Unpack.SkipPixels), NO_EXTRA }, 887 { GL_UNPACK_SKIP_ROWS, CONTEXT_INT(Unpack.SkipRows), NO_EXTRA }, 888 { GL_UNPACK_SWAP_BYTES, CONTEXT_BOOL(Unpack.SwapBytes), NO_EXTRA }, 889 { GL_UNPACK_SKIP_IMAGES_EXT, CONTEXT_INT(Unpack.SkipImages), NO_EXTRA }, 890 { GL_UNPACK_IMAGE_HEIGHT_EXT, CONTEXT_INT(Unpack.ImageHeight), NO_EXTRA }, 891 { GL_UNPACK_CLIENT_STORAGE_APPLE, CONTEXT_BOOL(Unpack.ClientStorage), NO_EXTRA }, 892 { GL_ZOOM_X, CONTEXT_FLOAT(Pixel.ZoomX), NO_EXTRA }, 893 { GL_ZOOM_Y, CONTEXT_FLOAT(Pixel.ZoomY), NO_EXTRA }, 894 895 /* Vertex arrays */ 896 { GL_VERTEX_ARRAY_COUNT_EXT, CONST(0), NO_EXTRA }, 897 { GL_NORMAL_ARRAY_COUNT_EXT, CONST(0), NO_EXTRA }, 898 { GL_COLOR_ARRAY_COUNT_EXT, CONST(0), NO_EXTRA }, 899 { GL_INDEX_ARRAY, ARRAY_BOOL(Index.Enabled), NO_EXTRA }, 900 { GL_INDEX_ARRAY_TYPE, ARRAY_ENUM(Index.Type), NO_EXTRA }, 901 { GL_INDEX_ARRAY_STRIDE, ARRAY_INT(Index.Stride), NO_EXTRA }, 902 { GL_INDEX_ARRAY_COUNT_EXT, CONST(0), NO_EXTRA }, 903 { GL_TEXTURE_COORD_ARRAY_COUNT_EXT, CONST(0), NO_EXTRA }, 904 { GL_EDGE_FLAG_ARRAY, ARRAY_BOOL(EdgeFlag.Enabled), NO_EXTRA }, 905 { GL_EDGE_FLAG_ARRAY_STRIDE, ARRAY_INT(EdgeFlag.Stride), NO_EXTRA }, 906 { GL_EDGE_FLAG_ARRAY_COUNT_EXT, CONST(0), NO_EXTRA }, 907 908 /* GL_ARB_texture_compression */ 909 { GL_TEXTURE_COMPRESSION_HINT_ARB, CONTEXT_INT(Hint.TextureCompression), NO_EXTRA }, 910 911 /* GL_EXT_compiled_vertex_array */ 912 { GL_ARRAY_ELEMENT_LOCK_FIRST_EXT, CONTEXT_INT(Array.LockFirst), 913 extra_EXT_compiled_vertex_array }, 914 { GL_ARRAY_ELEMENT_LOCK_COUNT_EXT, CONTEXT_INT(Array.LockCount), 915 extra_EXT_compiled_vertex_array }, 916 917 /* GL_ARB_transpose_matrix */ 918 { GL_TRANSPOSE_MODELVIEW_MATRIX_ARB, 919 CONTEXT_MATRIX_T(ModelviewMatrixStack), NO_EXTRA }, 920 { GL_TRANSPOSE_PROJECTION_MATRIX_ARB, 921 CONTEXT_MATRIX_T(ProjectionMatrixStack.Top), NO_EXTRA }, 922 { GL_TRANSPOSE_TEXTURE_MATRIX_ARB, CONTEXT_MATRIX_T(TextureMatrixStack), NO_EXTRA }, 923 924 /* GL_EXT_secondary_color */ 925 { GL_COLOR_SUM_EXT, CONTEXT_BOOL(Fog.ColorSumEnabled), 926 extra_EXT_secondary_color_ARB_vertex_program }, 927 { GL_CURRENT_SECONDARY_COLOR_EXT, 928 CONTEXT_FIELD(Current.Attrib[VERT_ATTRIB_COLOR1][0], TYPE_FLOATN_4), 929 extra_EXT_secondary_color_flush_current }, 930 { GL_SECONDARY_COLOR_ARRAY_EXT, ARRAY_BOOL(SecondaryColor.Enabled), 931 extra_EXT_secondary_color }, 932 { GL_SECONDARY_COLOR_ARRAY_TYPE_EXT, ARRAY_ENUM(SecondaryColor.Type), 933 extra_EXT_secondary_color }, 934 { GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT, ARRAY_INT(SecondaryColor.Stride), 935 extra_EXT_secondary_color }, 936 { GL_SECONDARY_COLOR_ARRAY_SIZE_EXT, ARRAY_INT(SecondaryColor.Size), 937 extra_EXT_secondary_color }, 938 939 /* GL_EXT_fog_coord */ 940 { GL_CURRENT_FOG_COORDINATE_EXT, 941 CONTEXT_FLOAT(Current.Attrib[VERT_ATTRIB_FOG][0]), 942 extra_EXT_fog_coord_flush_current }, 943 { GL_FOG_COORDINATE_ARRAY_EXT, ARRAY_BOOL(FogCoord.Enabled), 944 extra_EXT_fog_coord }, 945 { GL_FOG_COORDINATE_ARRAY_TYPE_EXT, ARRAY_ENUM(FogCoord.Type), 946 extra_EXT_fog_coord }, 947 { GL_FOG_COORDINATE_ARRAY_STRIDE_EXT, ARRAY_INT(FogCoord.Stride), 948 extra_EXT_fog_coord }, 949 { GL_FOG_COORDINATE_SOURCE_EXT, CONTEXT_ENUM(Fog.FogCoordinateSource), 950 extra_EXT_fog_coord }, 951 952 /* GL_IBM_rasterpos_clip */ 953 { GL_RASTER_POSITION_UNCLIPPED_IBM, 954 CONTEXT_BOOL(Transform.RasterPositionUnclipped), 955 extra_IBM_rasterpos_clip }, 956 957 /* GL_NV_point_sprite */ 958 { GL_POINT_SPRITE_R_MODE_NV, 959 CONTEXT_ENUM(Point.SpriteRMode), extra_NV_point_sprite }, 960 { GL_POINT_SPRITE_COORD_ORIGIN, CONTEXT_ENUM(Point.SpriteOrigin), 961 extra_NV_point_sprite_ARB_point_sprite }, 962 963 /* GL_NV_vertex_program */ 964 { GL_VERTEX_PROGRAM_BINDING_NV, LOC_CUSTOM, TYPE_INT, 0, 965 extra_NV_vertex_program }, 966 { GL_VERTEX_ATTRIB_ARRAY0_NV, ARRAY_BOOL(VertexAttrib[0].Enabled), 967 extra_NV_vertex_program }, 968 { GL_VERTEX_ATTRIB_ARRAY1_NV, ARRAY_BOOL(VertexAttrib[1].Enabled), 969 extra_NV_vertex_program }, 970 { GL_VERTEX_ATTRIB_ARRAY2_NV, ARRAY_BOOL(VertexAttrib[2].Enabled), 971 extra_NV_vertex_program }, 972 { GL_VERTEX_ATTRIB_ARRAY3_NV, ARRAY_BOOL(VertexAttrib[3].Enabled), 973 extra_NV_vertex_program }, 974 { GL_VERTEX_ATTRIB_ARRAY4_NV, ARRAY_BOOL(VertexAttrib[4].Enabled), 975 extra_NV_vertex_program }, 976 { GL_VERTEX_ATTRIB_ARRAY5_NV, ARRAY_BOOL(VertexAttrib[5].Enabled), 977 extra_NV_vertex_program }, 978 { GL_VERTEX_ATTRIB_ARRAY6_NV, ARRAY_BOOL(VertexAttrib[6].Enabled), 979 extra_NV_vertex_program }, 980 { GL_VERTEX_ATTRIB_ARRAY7_NV, ARRAY_BOOL(VertexAttrib[7].Enabled), 981 extra_NV_vertex_program }, 982 { GL_VERTEX_ATTRIB_ARRAY8_NV, ARRAY_BOOL(VertexAttrib[8].Enabled), 983 extra_NV_vertex_program }, 984 { GL_VERTEX_ATTRIB_ARRAY9_NV, ARRAY_BOOL(VertexAttrib[9].Enabled), 985 extra_NV_vertex_program }, 986 { GL_VERTEX_ATTRIB_ARRAY10_NV, ARRAY_BOOL(VertexAttrib[10].Enabled), 987 extra_NV_vertex_program }, 988 { GL_VERTEX_ATTRIB_ARRAY11_NV, ARRAY_BOOL(VertexAttrib[11].Enabled), 989 extra_NV_vertex_program }, 990 { GL_VERTEX_ATTRIB_ARRAY12_NV, ARRAY_BOOL(VertexAttrib[12].Enabled), 991 extra_NV_vertex_program }, 992 { GL_VERTEX_ATTRIB_ARRAY13_NV, ARRAY_BOOL(VertexAttrib[13].Enabled), 993 extra_NV_vertex_program }, 994 { GL_VERTEX_ATTRIB_ARRAY14_NV, ARRAY_BOOL(VertexAttrib[14].Enabled), 995 extra_NV_vertex_program }, 996 { GL_VERTEX_ATTRIB_ARRAY15_NV, ARRAY_BOOL(VertexAttrib[15].Enabled), 997 extra_NV_vertex_program }, 998 { GL_MAP1_VERTEX_ATTRIB0_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[0]), 999 extra_NV_vertex_program }, 1000 { GL_MAP1_VERTEX_ATTRIB1_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[1]), 1001 extra_NV_vertex_program }, 1002 { GL_MAP1_VERTEX_ATTRIB2_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[2]), 1003 extra_NV_vertex_program }, 1004 { GL_MAP1_VERTEX_ATTRIB3_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[3]), 1005 extra_NV_vertex_program }, 1006 { GL_MAP1_VERTEX_ATTRIB4_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[4]), 1007 extra_NV_vertex_program }, 1008 { GL_MAP1_VERTEX_ATTRIB5_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[5]), 1009 extra_NV_vertex_program }, 1010 { GL_MAP1_VERTEX_ATTRIB6_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[6]), 1011 extra_NV_vertex_program }, 1012 { GL_MAP1_VERTEX_ATTRIB7_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[7]), 1013 extra_NV_vertex_program }, 1014 { GL_MAP1_VERTEX_ATTRIB8_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[8]), 1015 extra_NV_vertex_program }, 1016 { GL_MAP1_VERTEX_ATTRIB9_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[9]), 1017 extra_NV_vertex_program }, 1018 { GL_MAP1_VERTEX_ATTRIB10_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[10]), 1019 extra_NV_vertex_program }, 1020 { GL_MAP1_VERTEX_ATTRIB11_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[11]), 1021 extra_NV_vertex_program }, 1022 { GL_MAP1_VERTEX_ATTRIB12_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[12]), 1023 extra_NV_vertex_program }, 1024 { GL_MAP1_VERTEX_ATTRIB13_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[13]), 1025 extra_NV_vertex_program }, 1026 { GL_MAP1_VERTEX_ATTRIB14_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[14]), 1027 extra_NV_vertex_program }, 1028 { GL_MAP1_VERTEX_ATTRIB15_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[15]), 1029 extra_NV_vertex_program }, 1030 1031 /* GL_NV_fragment_program */ 1032 { GL_FRAGMENT_PROGRAM_NV, CONTEXT_BOOL(FragmentProgram.Enabled), 1033 extra_NV_fragment_program }, 1034 { GL_FRAGMENT_PROGRAM_BINDING_NV, LOC_CUSTOM, TYPE_INT, 0, 1035 extra_NV_fragment_program }, 1036 { GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV, 1037 CONST(MAX_NV_FRAGMENT_PROGRAM_PARAMS), 1038 extra_NV_fragment_program }, 1039 1040 /* GL_NV_texture_rectangle */ 1041 { GL_TEXTURE_RECTANGLE_NV, 1042 LOC_CUSTOM, TYPE_BOOLEAN, 0, extra_NV_texture_rectangle }, 1043 { GL_TEXTURE_BINDING_RECTANGLE_NV, 1044 LOC_CUSTOM, TYPE_INT, TEXTURE_RECT_INDEX, extra_NV_texture_rectangle }, 1045 { GL_MAX_RECTANGLE_TEXTURE_SIZE_NV, 1046 CONTEXT_INT(Const.MaxTextureRectSize), extra_NV_texture_rectangle }, 1047 1048 /* GL_EXT_stencil_two_side */ 1049 { GL_STENCIL_TEST_TWO_SIDE_EXT, CONTEXT_BOOL(Stencil.TestTwoSide), 1050 extra_EXT_stencil_two_side }, 1051 { GL_ACTIVE_STENCIL_FACE_EXT, LOC_CUSTOM, TYPE_ENUM, NO_OFFSET, NO_EXTRA }, 1052 1053 /* GL_NV_light_max_exponent */ 1054 { GL_MAX_SHININESS_NV, CONTEXT_FLOAT(Const.MaxShininess), 1055 extra_NV_light_max_exponent }, 1056 { GL_MAX_SPOT_EXPONENT_NV, CONTEXT_FLOAT(Const.MaxSpotExponent), 1057 extra_NV_light_max_exponent }, 1058 1059 /* GL_NV_primitive_restart */ 1060 { GL_PRIMITIVE_RESTART_NV, CONTEXT_BOOL(Array.PrimitiveRestart), 1061 extra_NV_primitive_restart }, 1062 { GL_PRIMITIVE_RESTART_INDEX_NV, CONTEXT_INT(Array.RestartIndex), 1063 extra_NV_primitive_restart }, 1064 1065 /* GL_ARB_vertex_buffer_object */ 1066 { GL_INDEX_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT, 1067 offsetof(struct gl_array_object, Index.BufferObj), NO_EXTRA }, 1068 { GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT, 1069 offsetof(struct gl_array_object, EdgeFlag.BufferObj), NO_EXTRA }, 1070 { GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT, 1071 offsetof(struct gl_array_object, SecondaryColor.BufferObj), NO_EXTRA }, 1072 { GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT, 1073 offsetof(struct gl_array_object, FogCoord.BufferObj), NO_EXTRA }, 1074 1075 /* GL_EXT_pixel_buffer_object */ 1076 { GL_PIXEL_PACK_BUFFER_BINDING_EXT, LOC_CUSTOM, TYPE_INT, 0, 1077 extra_EXT_pixel_buffer_object }, 1078 { GL_PIXEL_UNPACK_BUFFER_BINDING_EXT, LOC_CUSTOM, TYPE_INT, 0, 1079 extra_EXT_pixel_buffer_object }, 1080 1081 /* GL_ARB_vertex_program */ 1082 { GL_VERTEX_PROGRAM_ARB, /* == GL_VERTEX_PROGRAM_NV */ 1083 CONTEXT_BOOL(VertexProgram.Enabled), 1084 extra_ARB_vertex_program_NV_vertex_program }, 1085 { GL_VERTEX_PROGRAM_POINT_SIZE_ARB, /* == GL_VERTEX_PROGRAM_POINT_SIZE_NV*/ 1086 CONTEXT_BOOL(VertexProgram.PointSizeEnabled), 1087 extra_ARB_vertex_program_NV_vertex_program }, 1088 { GL_VERTEX_PROGRAM_TWO_SIDE_ARB, /* == GL_VERTEX_PROGRAM_TWO_SIDE_NV */ 1089 CONTEXT_BOOL(VertexProgram.TwoSideEnabled), 1090 extra_ARB_vertex_program_NV_vertex_program }, 1091 { GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB, /* == GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV */ 1092 CONTEXT_INT(Const.MaxProgramMatrixStackDepth), 1093 extra_ARB_vertex_program_ARB_fragment_program_NV_vertex_program }, 1094 { GL_MAX_PROGRAM_MATRICES_ARB, /* == GL_MAX_TRACK_MATRICES_NV */ 1095 CONTEXT_INT(Const.MaxProgramMatrices), 1096 extra_ARB_vertex_program_ARB_fragment_program_NV_vertex_program }, 1097 { GL_CURRENT_MATRIX_STACK_DEPTH_ARB, /* == GL_CURRENT_MATRIX_STACK_DEPTH_NV */ 1098 LOC_CUSTOM, TYPE_INT, 0, 1099 extra_ARB_vertex_program_ARB_fragment_program_NV_vertex_program }, 1100 1101 { GL_CURRENT_MATRIX_ARB, /* == GL_CURRENT_MATRIX_NV */ 1102 LOC_CUSTOM, TYPE_MATRIX, 0, 1103 extra_ARB_vertex_program_ARB_fragment_program_NV_vertex_program }, 1104 { GL_TRANSPOSE_CURRENT_MATRIX_ARB, /* == GL_CURRENT_MATRIX_NV */ 1105 LOC_CUSTOM, TYPE_MATRIX, 0, 1106 extra_ARB_vertex_program_ARB_fragment_program }, 1107 1108 { GL_PROGRAM_ERROR_POSITION_ARB, /* == GL_PROGRAM_ERROR_POSITION_NV */ 1109 CONTEXT_INT(Program.ErrorPos), 1110 extra_NV_vertex_program_ARB_vertex_program_ARB_fragment_program_NV_vertex_program }, 1111 1112 /* GL_ARB_fragment_program */ 1113 { GL_FRAGMENT_PROGRAM_ARB, CONTEXT_BOOL(FragmentProgram.Enabled), 1114 extra_ARB_fragment_program }, 1115 1116 /* GL_EXT_depth_bounds_test */ 1117 { GL_DEPTH_BOUNDS_TEST_EXT, CONTEXT_BOOL(Depth.BoundsTest), 1118 extra_EXT_depth_bounds_test }, 1119 { GL_DEPTH_BOUNDS_EXT, CONTEXT_FLOAT2(Depth.BoundsMin), 1120 extra_EXT_depth_bounds_test }, 1121 1122 /* GL_ARB_depth_clamp*/ 1123 { GL_DEPTH_CLAMP, CONTEXT_BOOL(Transform.DepthClamp), 1124 extra_ARB_depth_clamp }, 1125 1126 /* GL_ARB_draw_buffers */ 1127 { GL_DRAW_BUFFER0_ARB, BUFFER_ENUM(ColorDrawBuffer[0]), NO_EXTRA }, 1128 { GL_DRAW_BUFFER1_ARB, BUFFER_ENUM(ColorDrawBuffer[1]), 1129 extra_valid_draw_buffer }, 1130 { GL_DRAW_BUFFER2_ARB, BUFFER_ENUM(ColorDrawBuffer[2]), 1131 extra_valid_draw_buffer }, 1132 { GL_DRAW_BUFFER3_ARB, BUFFER_ENUM(ColorDrawBuffer[3]), 1133 extra_valid_draw_buffer }, 1134 { GL_DRAW_BUFFER4_ARB, BUFFER_ENUM(ColorDrawBuffer[4]), 1135 extra_valid_draw_buffer }, 1136 { GL_DRAW_BUFFER5_ARB, BUFFER_ENUM(ColorDrawBuffer[5]), 1137 extra_valid_draw_buffer }, 1138 { GL_DRAW_BUFFER6_ARB, BUFFER_ENUM(ColorDrawBuffer[6]), 1139 extra_valid_draw_buffer }, 1140 { GL_DRAW_BUFFER7_ARB, BUFFER_ENUM(ColorDrawBuffer[7]), 1141 extra_valid_draw_buffer }, 1142 1143 /* GL_ATI_fragment_shader */ 1144 { GL_NUM_FRAGMENT_REGISTERS_ATI, CONST(6), extra_ATI_fragment_shader }, 1145 { GL_NUM_FRAGMENT_CONSTANTS_ATI, CONST(8), extra_ATI_fragment_shader }, 1146 { GL_NUM_PASSES_ATI, CONST(2), extra_ATI_fragment_shader }, 1147 { GL_NUM_INSTRUCTIONS_PER_PASS_ATI, CONST(8), extra_ATI_fragment_shader }, 1148 { GL_NUM_INSTRUCTIONS_TOTAL_ATI, CONST(16), extra_ATI_fragment_shader }, 1149 { GL_COLOR_ALPHA_PAIRING_ATI, CONST(GL_TRUE), extra_ATI_fragment_shader }, 1150 { GL_NUM_LOOPBACK_COMPONENTS_ATI, CONST(3), extra_ATI_fragment_shader }, 1151 { GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI, 1152 CONST(3), extra_ATI_fragment_shader }, 1153 1154 /* GL_EXT_framebuffer_object */ 1155 { GL_MAX_COLOR_ATTACHMENTS_EXT, CONTEXT_INT(Const.MaxColorAttachments), 1156 extra_EXT_framebuffer_object }, 1157 1158 /* GL_EXT_framebuffer_blit 1159 * NOTE: GL_DRAW_FRAMEBUFFER_BINDING_EXT == GL_FRAMEBUFFER_BINDING_EXT */ 1160 { GL_READ_FRAMEBUFFER_BINDING_EXT, LOC_CUSTOM, TYPE_INT, 0, 1161 extra_EXT_framebuffer_blit }, 1162 1163 /* GL_EXT_provoking_vertex */ 1164 { GL_PROVOKING_VERTEX_EXT, 1165 CONTEXT_ENUM(Light.ProvokingVertex), extra_EXT_provoking_vertex }, 1166 { GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT, 1167 CONTEXT_BOOL(Const.QuadsFollowProvokingVertexConvention), 1168 extra_EXT_provoking_vertex }, 1169 1170 /* GL_ARB_framebuffer_object */ 1171 { GL_MAX_SAMPLES, CONTEXT_INT(Const.MaxSamples), 1172 extra_ARB_framebuffer_object_EXT_framebuffer_multisample }, 1173 1174 /* GL_APPLE_vertex_array_object */ 1175 { GL_VERTEX_ARRAY_BINDING_APPLE, ARRAY_INT(Name), 1176 extra_APPLE_vertex_array_object }, 1177 1178 /* GL_ARB_seamless_cube_map */ 1179 { GL_TEXTURE_CUBE_MAP_SEAMLESS, 1180 CONTEXT_BOOL(Texture.CubeMapSeamless), extra_ARB_seamless_cube_map }, 1181 1182 /* GL_ARB_sync */ 1183 { GL_MAX_SERVER_WAIT_TIMEOUT, 1184 CONTEXT_INT64(Const.MaxServerWaitTimeout), extra_ARB_sync }, 1185 1186 /* GL_EXT_texture_integer */ 1187 { GL_RGBA_INTEGER_MODE_EXT, BUFFER_BOOL(_IntegerColor), 1188 extra_EXT_texture_integer }, 1189 1190 /* GL_EXT_transform_feedback */ 1191 { GL_TRANSFORM_FEEDBACK_BUFFER_BINDING, LOC_CUSTOM, TYPE_INT, 0, 1192 extra_EXT_transform_feedback }, 1193 { GL_RASTERIZER_DISCARD, CONTEXT_BOOL(TransformFeedback.RasterDiscard), 1194 extra_EXT_transform_feedback }, 1195 { GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS, 1196 CONTEXT_INT(Const.MaxTransformFeedbackInterleavedComponents), 1197 extra_EXT_transform_feedback }, 1198 { GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS, 1199 CONTEXT_INT(Const.MaxTransformFeedbackSeparateAttribs), 1200 extra_EXT_transform_feedback }, 1201 { GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS, 1202 CONTEXT_INT(Const.MaxTransformFeedbackSeparateComponents), 1203 extra_EXT_transform_feedback }, 1204 1205 /* GL_ARB_transform_feedback2 */ 1206 { GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED, LOC_CUSTOM, TYPE_BOOLEAN, 0, 1207 extra_ARB_transform_feedback2 }, 1208 { GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE, LOC_CUSTOM, TYPE_BOOLEAN, 0, 1209 extra_ARB_transform_feedback2 }, 1210 { GL_TRANSFORM_FEEDBACK_BINDING, LOC_CUSTOM, TYPE_INT, 0, 1211 extra_ARB_transform_feedback2 }, 1212 1213 /* GL_ARB_geometry_shader4 */ 1214 { GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB, 1215 CONTEXT_INT(Const.MaxGeometryTextureImageUnits), 1216 extra_ARB_geometry_shader4 }, 1217 { GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB, 1218 CONTEXT_INT(Const.MaxGeometryOutputVertices), 1219 extra_ARB_geometry_shader4 }, 1220 { GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB, 1221 CONTEXT_INT(Const.MaxGeometryTotalOutputComponents), 1222 extra_ARB_geometry_shader4 }, 1223 { GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB, 1224 CONTEXT_INT(Const.GeometryProgram.MaxUniformComponents), 1225 extra_ARB_geometry_shader4 }, 1226 { GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB, 1227 CONTEXT_INT(Const.MaxGeometryVaryingComponents), 1228 extra_ARB_geometry_shader4 }, 1229 { GL_MAX_VERTEX_VARYING_COMPONENTS_ARB, 1230 CONTEXT_INT(Const.MaxVertexVaryingComponents), 1231 extra_ARB_geometry_shader4 }, 1232 1233 /* GL_ARB_color_buffer_float */ 1234 { GL_RGBA_FLOAT_MODE_ARB, BUFFER_FIELD(Visual.floatMode, TYPE_BOOLEAN), 0 }, 1235 1236 /* GL_EXT_gpu_shader4 / GL 3.0 */ 1237 { GL_MIN_PROGRAM_TEXEL_OFFSET, 1238 CONTEXT_INT(Const.MinProgramTexelOffset), 1239 extra_EXT_gpu_shader4 }, 1240 { GL_MAX_PROGRAM_TEXEL_OFFSET, 1241 CONTEXT_INT(Const.MaxProgramTexelOffset), 1242 extra_EXT_gpu_shader4 }, 1243 1244 /* GL_ARB_texture_buffer_object */ 1245 { GL_MAX_TEXTURE_BUFFER_SIZE_ARB, CONTEXT_INT(Const.MaxTextureBufferSize), 1246 extra_ARB_texture_buffer_object }, 1247 { GL_TEXTURE_BINDING_BUFFER_ARB, LOC_CUSTOM, TYPE_INT, 0, 1248 extra_ARB_texture_buffer_object }, 1249 { GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB, LOC_CUSTOM, TYPE_INT, 1250 TEXTURE_BUFFER_INDEX, extra_ARB_texture_buffer_object }, 1251 { GL_TEXTURE_BUFFER_FORMAT_ARB, LOC_CUSTOM, TYPE_INT, 0, 1252 extra_ARB_texture_buffer_object }, 1253 { GL_TEXTURE_BUFFER_ARB, LOC_CUSTOM, TYPE_INT, 0, 1254 extra_ARB_texture_buffer_object }, 1255 1256 /* GL_ARB_sampler_objects / GL 3.3 */ 1257 { GL_SAMPLER_BINDING, 1258 LOC_CUSTOM, TYPE_INT, GL_SAMPLER_BINDING, extra_ARB_sampler_objects }, 1259 1260 /* GL 3.0 */ 1261 { GL_NUM_EXTENSIONS, LOC_CUSTOM, TYPE_INT, 0, extra_version_30 }, 1262 { GL_MAJOR_VERSION, CONTEXT_INT(VersionMajor), extra_version_30 }, 1263 { GL_MINOR_VERSION, CONTEXT_INT(VersionMinor), extra_version_30 }, 1264 { GL_CONTEXT_FLAGS, CONTEXT_INT(Const.ContextFlags), extra_version_30 }, 1265 1266 /* GL3.0 / GL_EXT_framebuffer_sRGB */ 1267 { GL_FRAMEBUFFER_SRGB_EXT, CONTEXT_BOOL(Color.sRGBEnabled), extra_EXT_framebuffer_sRGB }, 1268 { GL_FRAMEBUFFER_SRGB_CAPABLE_EXT, BUFFER_INT(Visual.sRGBCapable), extra_EXT_framebuffer_sRGB }, 1269 1270 /* GL 3.1 */ 1271 /* NOTE: different enum values for GL_PRIMITIVE_RESTART_NV 1272 * vs. GL_PRIMITIVE_RESTART! 1273 */ 1274 { GL_PRIMITIVE_RESTART, CONTEXT_BOOL(Array.PrimitiveRestart), 1275 extra_version_31 }, 1276 { GL_PRIMITIVE_RESTART_INDEX, CONTEXT_INT(Array.RestartIndex), 1277 extra_version_31 }, 1278 1279 1280 /* GL 3.2 */ 1281 { GL_CONTEXT_PROFILE_MASK, CONTEXT_INT(Const.ProfileMask), 1282 extra_version_32 }, 1283 1284 /* GL_ARB_robustness */ 1285 { GL_RESET_NOTIFICATION_STRATEGY_ARB, CONTEXT_ENUM(Const.ResetStrategy), NO_EXTRA }, 1286#endif /* FEATURE_GL */ 1287}; 1288 1289/* All we need now is a way to look up the value struct from the enum. 1290 * The code generated by gcc for the old generated big switch 1291 * statement is a big, balanced, open coded if/else tree, essentially 1292 * an unrolled binary search. It would be natural to sort the new 1293 * enum table and use bsearch(), but we will use a read-only hash 1294 * table instead. bsearch() has a nice guaranteed worst case 1295 * performance, but we're also guaranteed to hit that worst case 1296 * (log2(n) iterations) for about half the enums. Instead, using an 1297 * open addressing hash table, we can find the enum on the first try 1298 * for 80% of the enums, 1 collision for 10% and never more than 5 1299 * collisions for any enum (typical numbers). And the code is very 1300 * simple, even though it feels a little magic. */ 1301 1302static unsigned short table[1024]; 1303static const int prime_factor = 89, prime_step = 281; 1304 1305#ifdef GET_DEBUG 1306static void 1307print_table_stats(void) 1308{ 1309 int i, j, collisions[11], count, hash, mask; 1310 const struct value_desc *d; 1311 1312 count = 0; 1313 mask = Elements(table) - 1; 1314 memset(collisions, 0, sizeof collisions); 1315 1316 for (i = 0; i < Elements(table); i++) { 1317 if (!table[i]) 1318 continue; 1319 count++; 1320 d = &values[table[i]]; 1321 hash = (d->pname * prime_factor); 1322 j = 0; 1323 while (1) { 1324 if (values[table[hash & mask]].pname == d->pname) 1325 break; 1326 hash += prime_step; 1327 j++; 1328 } 1329 1330 if (j < 10) 1331 collisions[j]++; 1332 else 1333 collisions[10]++; 1334 } 1335 1336 printf("number of enums: %d (total %d)\n", count, Elements(values)); 1337 for (i = 0; i < Elements(collisions) - 1; i++) 1338 if (collisions[i] > 0) 1339 printf(" %d enums with %d %scollisions\n", 1340 collisions[i], i, i == 10 ? "or more " : ""); 1341} 1342#endif 1343 1344/** 1345 * Initialize the enum hash for a given API 1346 * 1347 * This is called from one_time_init() to insert the enum values that 1348 * are valid for the API in question into the enum hash table. 1349 * 1350 * \param the current context, for determining the API in question 1351 */ 1352void _mesa_init_get_hash(struct gl_context *ctx) 1353{ 1354 int i, hash, index, mask; 1355 int api_mask = 0, api_bit; 1356 1357 mask = Elements(table) - 1; 1358 api_bit = 1 << ctx->API; 1359 1360 for (i = 0; i < Elements(values); i++) { 1361 if (values[i].type == TYPE_API_MASK) { 1362 api_mask = values[i].offset; 1363 continue; 1364 } 1365 if (!(api_mask & api_bit)) 1366 continue; 1367 1368 hash = (values[i].pname * prime_factor) & mask; 1369 while (1) { 1370 index = hash & mask; 1371 if (!table[index]) { 1372 table[index] = i; 1373 break; 1374 } 1375 hash += prime_step; 1376 } 1377 } 1378 1379#ifdef GET_DEBUG 1380 print_table_stats(); 1381#endif 1382} 1383 1384/** 1385 * Handle irregular enums 1386 * 1387 * Some values don't conform to the "well-known type at context 1388 * pointer + offset" pattern, so we have this function to catch all 1389 * the corner cases. Typically, it's a computed value or a one-off 1390 * pointer to a custom struct or something. 1391 * 1392 * In this case we can't return a pointer to the value, so we'll have 1393 * to use the temporary variable 'v' declared back in the calling 1394 * glGet*v() function to store the result. 1395 * 1396 * \param ctx the current context 1397 * \param d the struct value_desc that describes the enum 1398 * \param v pointer to the tmp declared in the calling glGet*v() function 1399 */ 1400static void 1401find_custom_value(struct gl_context *ctx, const struct value_desc *d, union value *v) 1402{ 1403 struct gl_buffer_object **buffer_obj; 1404 struct gl_client_array *array; 1405 GLuint unit, *p; 1406 1407 switch (d->pname) { 1408 case GL_TEXTURE_1D: 1409 case GL_TEXTURE_2D: 1410 case GL_TEXTURE_3D: 1411 case GL_TEXTURE_1D_ARRAY_EXT: 1412 case GL_TEXTURE_2D_ARRAY_EXT: 1413 case GL_TEXTURE_CUBE_MAP_ARB: 1414 case GL_TEXTURE_RECTANGLE_NV: 1415 v->value_bool = _mesa_IsEnabled(d->pname); 1416 break; 1417 1418 case GL_LINE_STIPPLE_PATTERN: 1419 /* This is the only GLushort, special case it here by promoting 1420 * to an int rather than introducing a new type. */ 1421 v->value_int = ctx->Line.StipplePattern; 1422 break; 1423 1424 case GL_CURRENT_RASTER_TEXTURE_COORDS: 1425 unit = ctx->Texture.CurrentUnit; 1426 v->value_float_4[0] = ctx->Current.RasterTexCoords[unit][0]; 1427 v->value_float_4[1] = ctx->Current.RasterTexCoords[unit][1]; 1428 v->value_float_4[2] = ctx->Current.RasterTexCoords[unit][2]; 1429 v->value_float_4[3] = ctx->Current.RasterTexCoords[unit][3]; 1430 break; 1431 1432 case GL_CURRENT_TEXTURE_COORDS: 1433 unit = ctx->Texture.CurrentUnit; 1434 v->value_float_4[0] = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][0]; 1435 v->value_float_4[1] = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][1]; 1436 v->value_float_4[2] = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][2]; 1437 v->value_float_4[3] = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][3]; 1438 break; 1439 1440 case GL_COLOR_WRITEMASK: 1441 v->value_int_4[0] = ctx->Color.ColorMask[0][RCOMP] ? 1 : 0; 1442 v->value_int_4[1] = ctx->Color.ColorMask[0][GCOMP] ? 1 : 0; 1443 v->value_int_4[2] = ctx->Color.ColorMask[0][BCOMP] ? 1 : 0; 1444 v->value_int_4[3] = ctx->Color.ColorMask[0][ACOMP] ? 1 : 0; 1445 break; 1446 1447 case GL_EDGE_FLAG: 1448 v->value_bool = ctx->Current.Attrib[VERT_ATTRIB_EDGEFLAG][0] == 1.0; 1449 break; 1450 1451 case GL_READ_BUFFER: 1452 v->value_enum = ctx->ReadBuffer->ColorReadBuffer; 1453 break; 1454 1455 case GL_MAP2_GRID_DOMAIN: 1456 v->value_float_4[0] = ctx->Eval.MapGrid2u1; 1457 v->value_float_4[1] = ctx->Eval.MapGrid2u2; 1458 v->value_float_4[2] = ctx->Eval.MapGrid2v1; 1459 v->value_float_4[3] = ctx->Eval.MapGrid2v2; 1460 break; 1461 1462 case GL_TEXTURE_STACK_DEPTH: 1463 unit = ctx->Texture.CurrentUnit; 1464 v->value_int = ctx->TextureMatrixStack[unit].Depth + 1; 1465 break; 1466 case GL_TEXTURE_MATRIX: 1467 unit = ctx->Texture.CurrentUnit; 1468 v->value_matrix = ctx->TextureMatrixStack[unit].Top; 1469 break; 1470 1471 case GL_TEXTURE_COORD_ARRAY: 1472 case GL_TEXTURE_COORD_ARRAY_SIZE: 1473 case GL_TEXTURE_COORD_ARRAY_TYPE: 1474 case GL_TEXTURE_COORD_ARRAY_STRIDE: 1475 array = &ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture]; 1476 v->value_int = *(GLuint *) ((char *) array + d->offset); 1477 break; 1478 1479 case GL_ACTIVE_TEXTURE_ARB: 1480 v->value_int = GL_TEXTURE0_ARB + ctx->Texture.CurrentUnit; 1481 break; 1482 case GL_CLIENT_ACTIVE_TEXTURE_ARB: 1483 v->value_int = GL_TEXTURE0_ARB + ctx->Array.ActiveTexture; 1484 break; 1485 1486 case GL_MODELVIEW_STACK_DEPTH: 1487 case GL_PROJECTION_STACK_DEPTH: 1488 v->value_int = *(GLint *) ((char *) ctx + d->offset) + 1; 1489 break; 1490 1491 case GL_MAX_TEXTURE_SIZE: 1492 case GL_MAX_3D_TEXTURE_SIZE: 1493 case GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB: 1494 p = (GLuint *) ((char *) ctx + d->offset); 1495 v->value_int = 1 << (*p - 1); 1496 break; 1497 1498 case GL_SCISSOR_BOX: 1499 v->value_int_4[0] = ctx->Scissor.X; 1500 v->value_int_4[1] = ctx->Scissor.Y; 1501 v->value_int_4[2] = ctx->Scissor.Width; 1502 v->value_int_4[3] = ctx->Scissor.Height; 1503 break; 1504 1505 case GL_LIST_INDEX: 1506 v->value_int = 1507 ctx->ListState.CurrentList ? ctx->ListState.CurrentList->Name : 0; 1508 break; 1509 case GL_LIST_MODE: 1510 if (!ctx->CompileFlag) 1511 v->value_enum = 0; 1512 else if (ctx->ExecuteFlag) 1513 v->value_enum = GL_COMPILE_AND_EXECUTE; 1514 else 1515 v->value_enum = GL_COMPILE; 1516 break; 1517 1518 case GL_VIEWPORT: 1519 v->value_int_4[0] = ctx->Viewport.X; 1520 v->value_int_4[1] = ctx->Viewport.Y; 1521 v->value_int_4[2] = ctx->Viewport.Width; 1522 v->value_int_4[3] = ctx->Viewport.Height; 1523 break; 1524 1525 case GL_ACTIVE_STENCIL_FACE_EXT: 1526 v->value_enum = ctx->Stencil.ActiveFace ? GL_BACK : GL_FRONT; 1527 break; 1528 1529 case GL_STENCIL_FAIL: 1530 v->value_enum = ctx->Stencil.FailFunc[ctx->Stencil.ActiveFace]; 1531 break; 1532 case GL_STENCIL_FUNC: 1533 v->value_enum = ctx->Stencil.Function[ctx->Stencil.ActiveFace]; 1534 break; 1535 case GL_STENCIL_PASS_DEPTH_FAIL: 1536 v->value_enum = ctx->Stencil.ZFailFunc[ctx->Stencil.ActiveFace]; 1537 break; 1538 case GL_STENCIL_PASS_DEPTH_PASS: 1539 v->value_enum = ctx->Stencil.ZPassFunc[ctx->Stencil.ActiveFace]; 1540 break; 1541 case GL_STENCIL_REF: 1542 v->value_int = ctx->Stencil.Ref[ctx->Stencil.ActiveFace]; 1543 break; 1544 case GL_STENCIL_VALUE_MASK: 1545 v->value_int = ctx->Stencil.ValueMask[ctx->Stencil.ActiveFace]; 1546 break; 1547 case GL_STENCIL_WRITEMASK: 1548 v->value_int = ctx->Stencil.WriteMask[ctx->Stencil.ActiveFace]; 1549 break; 1550 1551 case GL_NUM_EXTENSIONS: 1552 v->value_int = _mesa_get_extension_count(ctx); 1553 break; 1554 1555 case GL_IMPLEMENTATION_COLOR_READ_TYPE_OES: 1556 v->value_int = _mesa_get_color_read_type(ctx); 1557 break; 1558 case GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES: 1559 v->value_int = _mesa_get_color_read_format(ctx); 1560 break; 1561 1562 case GL_CURRENT_MATRIX_STACK_DEPTH_ARB: 1563 v->value_int = ctx->CurrentStack->Depth + 1; 1564 break; 1565 case GL_CURRENT_MATRIX_ARB: 1566 case GL_TRANSPOSE_CURRENT_MATRIX_ARB: 1567 v->value_matrix = ctx->CurrentStack->Top; 1568 break; 1569 1570 case GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB: 1571 v->value_int = _mesa_get_compressed_formats(ctx, NULL); 1572 break; 1573 case GL_COMPRESSED_TEXTURE_FORMATS_ARB: 1574 v->value_int_n.n = 1575 _mesa_get_compressed_formats(ctx, v->value_int_n.ints); 1576 ASSERT(v->value_int_n.n <= 100); 1577 break; 1578 1579 case GL_MAX_VARYING_FLOATS_ARB: 1580 v->value_int = ctx->Const.MaxVarying * 4; 1581 break; 1582 1583 /* Various object names */ 1584 1585 case GL_TEXTURE_BINDING_1D: 1586 case GL_TEXTURE_BINDING_2D: 1587 case GL_TEXTURE_BINDING_3D: 1588 case GL_TEXTURE_BINDING_1D_ARRAY_EXT: 1589 case GL_TEXTURE_BINDING_2D_ARRAY_EXT: 1590 case GL_TEXTURE_BINDING_CUBE_MAP_ARB: 1591 case GL_TEXTURE_BINDING_RECTANGLE_NV: 1592 unit = ctx->Texture.CurrentUnit; 1593 v->value_int = 1594 ctx->Texture.Unit[unit].CurrentTex[d->offset]->Name; 1595 break; 1596 1597 /* GL_ARB_vertex_buffer_object */ 1598 case GL_VERTEX_ARRAY_BUFFER_BINDING_ARB: 1599 case GL_NORMAL_ARRAY_BUFFER_BINDING_ARB: 1600 case GL_COLOR_ARRAY_BUFFER_BINDING_ARB: 1601 case GL_INDEX_ARRAY_BUFFER_BINDING_ARB: 1602 case GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB: 1603 case GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB: 1604 case GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB: 1605 buffer_obj = (struct gl_buffer_object **) 1606 ((char *) ctx->Array.ArrayObj + d->offset); 1607 v->value_int = (*buffer_obj)->Name; 1608 break; 1609 case GL_ARRAY_BUFFER_BINDING_ARB: 1610 v->value_int = ctx->Array.ArrayBufferObj->Name; 1611 break; 1612 case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB: 1613 v->value_int = 1614 ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].BufferObj->Name; 1615 break; 1616 case GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB: 1617 v->value_int = ctx->Array.ElementArrayBufferObj->Name; 1618 break; 1619 1620 /* ARB_copy_buffer */ 1621 case GL_COPY_READ_BUFFER: 1622 v->value_int = ctx->CopyReadBuffer->Name; 1623 break; 1624 case GL_COPY_WRITE_BUFFER: 1625 v->value_int = ctx->CopyWriteBuffer->Name; 1626 break; 1627 1628 case GL_FRAGMENT_PROGRAM_BINDING_NV: 1629 v->value_int = 1630 ctx->FragmentProgram.Current ? ctx->FragmentProgram.Current->Base.Id : 0; 1631 break; 1632 case GL_VERTEX_PROGRAM_BINDING_NV: 1633 v->value_int = 1634 ctx->VertexProgram.Current ? ctx->VertexProgram.Current->Base.Id : 0; 1635 break; 1636 case GL_PIXEL_PACK_BUFFER_BINDING_EXT: 1637 v->value_int = ctx->Pack.BufferObj->Name; 1638 break; 1639 case GL_PIXEL_UNPACK_BUFFER_BINDING_EXT: 1640 v->value_int = ctx->Unpack.BufferObj->Name; 1641 break; 1642 case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING: 1643 v->value_int = ctx->TransformFeedback.CurrentBuffer->Name; 1644 break; 1645 case GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED: 1646 v->value_int = ctx->TransformFeedback.CurrentObject->Paused; 1647 break; 1648 case GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE: 1649 v->value_int = ctx->TransformFeedback.CurrentObject->Active; 1650 break; 1651 case GL_TRANSFORM_FEEDBACK_BINDING: 1652 v->value_int = ctx->TransformFeedback.CurrentObject->Name; 1653 break; 1654 case GL_CURRENT_PROGRAM: 1655 v->value_int = 1656 ctx->Shader.ActiveProgram ? ctx->Shader.ActiveProgram->Name : 0; 1657 break; 1658 case GL_READ_FRAMEBUFFER_BINDING_EXT: 1659 v->value_int = ctx->ReadBuffer->Name; 1660 break; 1661 case GL_RENDERBUFFER_BINDING_EXT: 1662 v->value_int = 1663 ctx->CurrentRenderbuffer ? ctx->CurrentRenderbuffer->Name : 0; 1664 break; 1665 case GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES: 1666 v->value_int = ctx->Array.ArrayObj->PointSize.BufferObj->Name; 1667 break; 1668 1669 case GL_FOG_COLOR: 1670 if(ctx->Color._ClampFragmentColor) 1671 COPY_4FV(v->value_float_4, ctx->Fog.Color); 1672 else 1673 COPY_4FV(v->value_float_4, ctx->Fog.ColorUnclamped); 1674 break; 1675 case GL_COLOR_CLEAR_VALUE: 1676 if(ctx->Color._ClampFragmentColor) 1677 COPY_4FV(v->value_float_4, ctx->Color.ClearColor); 1678 else 1679 COPY_4FV(v->value_float_4, ctx->Color.ClearColorUnclamped); 1680 break; 1681 case GL_BLEND_COLOR_EXT: 1682 if(ctx->Color._ClampFragmentColor) 1683 COPY_4FV(v->value_float_4, ctx->Color.BlendColor); 1684 else 1685 COPY_4FV(v->value_float_4, ctx->Color.BlendColorUnclamped); 1686 break; 1687 case GL_ALPHA_TEST_REF: 1688 if(ctx->Color._ClampFragmentColor) 1689 v->value_float = ctx->Color.AlphaRef; 1690 else 1691 v->value_float = ctx->Color.AlphaRefUnclamped; 1692 break; 1693 case GL_MAX_VERTEX_UNIFORM_VECTORS: 1694 v->value_int = ctx->Const.VertexProgram.MaxUniformComponents / 4; 1695 break; 1696 1697 case GL_MAX_FRAGMENT_UNIFORM_VECTORS: 1698 v->value_int = ctx->Const.FragmentProgram.MaxUniformComponents / 4; 1699 break; 1700 1701 /* GL_ARB_texture_buffer_object */ 1702 case GL_TEXTURE_BUFFER_ARB: 1703 v->value_int = ctx->Texture.BufferObject->Name; 1704 break; 1705 case GL_TEXTURE_BINDING_BUFFER_ARB: 1706 unit = ctx->Texture.CurrentUnit; 1707 v->value_int = 1708 ctx->Texture.Unit[unit].CurrentTex[TEXTURE_BUFFER_INDEX]->Name; 1709 break; 1710 case GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB: 1711 { 1712 struct gl_buffer_object *buf = 1713 ctx->Texture.Unit[ctx->Texture.CurrentUnit] 1714 .CurrentTex[TEXTURE_BUFFER_INDEX]->BufferObject; 1715 v->value_int = buf ? buf->Name : 0; 1716 } 1717 break; 1718 case GL_TEXTURE_BUFFER_FORMAT_ARB: 1719 v->value_int = ctx->Texture.Unit[ctx->Texture.CurrentUnit] 1720 .CurrentTex[TEXTURE_BUFFER_INDEX]->BufferObjectFormat; 1721 break; 1722 1723 /* GL_ARB_sampler_objects */ 1724 case GL_SAMPLER_BINDING: 1725 { 1726 struct gl_sampler_object *samp = 1727 ctx->Texture.Unit[ctx->Texture.CurrentUnit].Sampler; 1728 v->value_int = samp ? samp->Name : 0; 1729 } 1730 break; 1731 } 1732} 1733 1734/** 1735 * Check extra constraints on a struct value_desc descriptor 1736 * 1737 * If a struct value_desc has a non-NULL extra pointer, it means that 1738 * there are a number of extra constraints to check or actions to 1739 * perform. The extras is just an integer array where each integer 1740 * encode different constraints or actions. 1741 * 1742 * \param ctx current context 1743 * \param func name of calling glGet*v() function for error reporting 1744 * \param d the struct value_desc that has the extra constraints 1745 * 1746 * \return GL_FALSE if one of the constraints was not satisfied, 1747 * otherwise GL_TRUE. 1748 */ 1749static GLboolean 1750check_extra(struct gl_context *ctx, const char *func, const struct value_desc *d) 1751{ 1752 const GLuint version = ctx->VersionMajor * 10 + ctx->VersionMinor; 1753 int total, enabled; 1754 const int *e; 1755 1756 total = 0; 1757 enabled = 0; 1758 for (e = d->extra; *e != EXTRA_END; e++) 1759 switch (*e) { 1760 case EXTRA_VERSION_30: 1761 if (version >= 30) { 1762 total++; 1763 enabled++; 1764 } 1765 break; 1766 case EXTRA_VERSION_31: 1767 if (version >= 31) { 1768 total++; 1769 enabled++; 1770 } 1771 break; 1772 case EXTRA_VERSION_32: 1773 if (version >= 32) { 1774 total++; 1775 enabled++; 1776 } 1777 break; 1778 case EXTRA_NEW_FRAG_CLAMP: 1779 if (ctx->NewState & (_NEW_BUFFERS | _NEW_FRAG_CLAMP)) 1780 _mesa_update_state(ctx); 1781 break; 1782 case EXTRA_VERSION_ES2: 1783 if (ctx->API == API_OPENGLES2) { 1784 total++; 1785 enabled++; 1786 } 1787 break; 1788 case EXTRA_NEW_BUFFERS: 1789 if (ctx->NewState & _NEW_BUFFERS) 1790 _mesa_update_state(ctx); 1791 break; 1792 case EXTRA_FLUSH_CURRENT: 1793 FLUSH_CURRENT(ctx, 0); 1794 break; 1795 case EXTRA_VALID_DRAW_BUFFER: 1796 if (d->pname - GL_DRAW_BUFFER0_ARB >= ctx->Const.MaxDrawBuffers) { 1797 _mesa_error(ctx, GL_INVALID_OPERATION, "%s(draw buffer %u)", 1798 func, d->pname - GL_DRAW_BUFFER0_ARB); 1799 return GL_FALSE; 1800 } 1801 break; 1802 case EXTRA_VALID_TEXTURE_UNIT: 1803 if (ctx->Texture.CurrentUnit >= ctx->Const.MaxTextureCoordUnits) { 1804 _mesa_error(ctx, GL_INVALID_OPERATION, "%s(texture %u)", 1805 func, ctx->Texture.CurrentUnit); 1806 return GL_FALSE; 1807 } 1808 break; 1809 case EXTRA_END: 1810 break; 1811 default: /* *e is a offset into the extension struct */ 1812 total++; 1813 if (*(GLboolean *) ((char *) &ctx->Extensions + *e)) 1814 enabled++; 1815 break; 1816 } 1817 1818 if (total > 0 && enabled == 0) { 1819 _mesa_error(ctx, GL_INVALID_ENUM, "%s(pname=%s)", func, 1820 _mesa_lookup_enum_by_nr(d->pname)); 1821 return GL_FALSE; 1822 } 1823 1824 return GL_TRUE; 1825} 1826 1827static const struct value_desc error_value = 1828 { 0, 0, TYPE_INVALID, NO_OFFSET, NO_EXTRA }; 1829 1830/** 1831 * Find the struct value_desc corresponding to the enum 'pname'. 1832 * 1833 * We hash the enum value to get an index into the 'table' array, 1834 * which holds the index in the 'values' array of struct value_desc. 1835 * Once we've found the entry, we do the extra checks, if any, then 1836 * look up the value and return a pointer to it. 1837 * 1838 * If the value has to be computed (for example, it's the result of a 1839 * function call or we need to add 1 to it), we use the tmp 'v' to 1840 * store the result. 1841 * 1842 * \param func name of glGet*v() func for error reporting 1843 * \param pname the enum value we're looking up 1844 * \param p is were we return the pointer to the value 1845 * \param v a tmp union value variable in the calling glGet*v() function 1846 * 1847 * \return the struct value_desc corresponding to the enum or a struct 1848 * value_desc of TYPE_INVALID if not found. This lets the calling 1849 * glGet*v() function jump right into a switch statement and 1850 * handle errors there instead of having to check for NULL. 1851 */ 1852static const struct value_desc * 1853find_value(const char *func, GLenum pname, void **p, union value *v) 1854{ 1855 GET_CURRENT_CONTEXT(ctx); 1856 struct gl_texture_unit *unit; 1857 int mask, hash; 1858 const struct value_desc *d; 1859 1860 mask = Elements(table) - 1; 1861 hash = (pname * prime_factor); 1862 while (1) { 1863 d = &values[table[hash & mask]]; 1864 1865 /* If the enum isn't valid, the hash walk ends with index 0, 1866 * which is the API mask entry at the beginning of values[]. */ 1867 if (unlikely(d->type == TYPE_API_MASK)) { 1868 _mesa_error(ctx, GL_INVALID_ENUM, "%s(pname=%s)", func, 1869 _mesa_lookup_enum_by_nr(pname)); 1870 return &error_value; 1871 } 1872 1873 if (likely(d->pname == pname)) 1874 break; 1875 1876 hash += prime_step; 1877 } 1878 1879 if (unlikely(d->extra && !check_extra(ctx, func, d))) 1880 return &error_value; 1881 1882 switch (d->location) { 1883 case LOC_BUFFER: 1884 *p = ((char *) ctx->DrawBuffer + d->offset); 1885 return d; 1886 case LOC_CONTEXT: 1887 *p = ((char *) ctx + d->offset); 1888 return d; 1889 case LOC_ARRAY: 1890 *p = ((char *) ctx->Array.ArrayObj + d->offset); 1891 return d; 1892 case LOC_TEXUNIT: 1893 unit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; 1894 *p = ((char *) unit + d->offset); 1895 return d; 1896 case LOC_CUSTOM: 1897 find_custom_value(ctx, d, v); 1898 *p = v; 1899 return d; 1900 default: 1901 assert(0); 1902 break; 1903 } 1904 1905 /* silence warning */ 1906 return &error_value; 1907} 1908 1909static const int transpose[] = { 1910 0, 4, 8, 12, 1911 1, 5, 9, 13, 1912 2, 6, 10, 14, 1913 3, 7, 11, 15 1914}; 1915 1916void GLAPIENTRY 1917_mesa_GetBooleanv(GLenum pname, GLboolean *params) 1918{ 1919 const struct value_desc *d; 1920 union value v; 1921 GLmatrix *m; 1922 int shift, i; 1923 void *p; 1924 GET_CURRENT_CONTEXT(ctx); 1925 1926 ASSERT_OUTSIDE_BEGIN_END(ctx); 1927 1928 d = find_value("glGetBooleanv", pname, &p, &v); 1929 switch (d->type) { 1930 case TYPE_INVALID: 1931 break; 1932 case TYPE_CONST: 1933 params[0] = INT_TO_BOOLEAN(d->offset); 1934 break; 1935 1936 case TYPE_FLOAT_4: 1937 case TYPE_FLOATN_4: 1938 params[3] = FLOAT_TO_BOOLEAN(((GLfloat *) p)[3]); 1939 case TYPE_FLOAT_3: 1940 case TYPE_FLOATN_3: 1941 params[2] = FLOAT_TO_BOOLEAN(((GLfloat *) p)[2]); 1942 case TYPE_FLOAT_2: 1943 case TYPE_FLOATN_2: 1944 params[1] = FLOAT_TO_BOOLEAN(((GLfloat *) p)[1]); 1945 case TYPE_FLOAT: 1946 case TYPE_FLOATN: 1947 params[0] = FLOAT_TO_BOOLEAN(((GLfloat *) p)[0]); 1948 break; 1949 1950 case TYPE_DOUBLEN: 1951 params[0] = FLOAT_TO_BOOLEAN(((GLdouble *) p)[0]); 1952 break; 1953 1954 case TYPE_INT_4: 1955 params[3] = INT_TO_BOOLEAN(((GLint *) p)[3]); 1956 case TYPE_INT_3: 1957 params[2] = INT_TO_BOOLEAN(((GLint *) p)[2]); 1958 case TYPE_INT_2: 1959 case TYPE_ENUM_2: 1960 params[1] = INT_TO_BOOLEAN(((GLint *) p)[1]); 1961 case TYPE_INT: 1962 case TYPE_ENUM: 1963 params[0] = INT_TO_BOOLEAN(((GLint *) p)[0]); 1964 break; 1965 1966 case TYPE_INT_N: 1967 for (i = 0; i < v.value_int_n.n; i++) 1968 params[i] = INT_TO_BOOLEAN(v.value_int_n.ints[i]); 1969 break; 1970 1971 case TYPE_INT64: 1972 params[0] = INT64_TO_BOOLEAN(((GLint64 *) p)[0]); 1973 break; 1974 1975 case TYPE_BOOLEAN: 1976 params[0] = ((GLboolean*) p)[0]; 1977 break; 1978 1979 case TYPE_MATRIX: 1980 m = *(GLmatrix **) p; 1981 for (i = 0; i < 16; i++) 1982 params[i] = FLOAT_TO_BOOLEAN(m->m[i]); 1983 break; 1984 1985 case TYPE_MATRIX_T: 1986 m = *(GLmatrix **) p; 1987 for (i = 0; i < 16; i++) 1988 params[i] = FLOAT_TO_BOOLEAN(m->m[transpose[i]]); 1989 break; 1990 1991 case TYPE_BIT_0: 1992 case TYPE_BIT_1: 1993 case TYPE_BIT_2: 1994 case TYPE_BIT_3: 1995 case TYPE_BIT_4: 1996 case TYPE_BIT_5: 1997 shift = d->type - TYPE_BIT_0; 1998 params[0] = (*(GLbitfield *) p >> shift) & 1; 1999 break; 2000 } 2001} 2002 2003void GLAPIENTRY 2004_mesa_GetFloatv(GLenum pname, GLfloat *params) 2005{ 2006 const struct value_desc *d; 2007 union value v; 2008 GLmatrix *m; 2009 int shift, i; 2010 void *p; 2011 GET_CURRENT_CONTEXT(ctx); 2012 2013 ASSERT_OUTSIDE_BEGIN_END(ctx); 2014 2015 d = find_value("glGetFloatv", pname, &p, &v); 2016 switch (d->type) { 2017 case TYPE_INVALID: 2018 break; 2019 case TYPE_CONST: 2020 params[0] = (GLfloat) d->offset; 2021 break; 2022 2023 case TYPE_FLOAT_4: 2024 case TYPE_FLOATN_4: 2025 params[3] = ((GLfloat *) p)[3]; 2026 case TYPE_FLOAT_3: 2027 case TYPE_FLOATN_3: 2028 params[2] = ((GLfloat *) p)[2]; 2029 case TYPE_FLOAT_2: 2030 case TYPE_FLOATN_2: 2031 params[1] = ((GLfloat *) p)[1]; 2032 case TYPE_FLOAT: 2033 case TYPE_FLOATN: 2034 params[0] = ((GLfloat *) p)[0]; 2035 break; 2036 2037 case TYPE_DOUBLEN: 2038 params[0] = ((GLdouble *) p)[0]; 2039 break; 2040 2041 case TYPE_INT_4: 2042 params[3] = (GLfloat) (((GLint *) p)[3]); 2043 case TYPE_INT_3: 2044 params[2] = (GLfloat) (((GLint *) p)[2]); 2045 case TYPE_INT_2: 2046 case TYPE_ENUM_2: 2047 params[1] = (GLfloat) (((GLint *) p)[1]); 2048 case TYPE_INT: 2049 case TYPE_ENUM: 2050 params[0] = (GLfloat) (((GLint *) p)[0]); 2051 break; 2052 2053 case TYPE_INT_N: 2054 for (i = 0; i < v.value_int_n.n; i++) 2055 params[i] = INT_TO_FLOAT(v.value_int_n.ints[i]); 2056 break; 2057 2058 case TYPE_INT64: 2059 params[0] = ((GLint64 *) p)[0]; 2060 break; 2061 2062 case TYPE_BOOLEAN: 2063 params[0] = BOOLEAN_TO_FLOAT(*(GLboolean*) p); 2064 break; 2065 2066 case TYPE_MATRIX: 2067 m = *(GLmatrix **) p; 2068 for (i = 0; i < 16; i++) 2069 params[i] = m->m[i]; 2070 break; 2071 2072 case TYPE_MATRIX_T: 2073 m = *(GLmatrix **) p; 2074 for (i = 0; i < 16; i++) 2075 params[i] = m->m[transpose[i]]; 2076 break; 2077 2078 case TYPE_BIT_0: 2079 case TYPE_BIT_1: 2080 case TYPE_BIT_2: 2081 case TYPE_BIT_3: 2082 case TYPE_BIT_4: 2083 case TYPE_BIT_5: 2084 shift = d->type - TYPE_BIT_0; 2085 params[0] = BOOLEAN_TO_FLOAT((*(GLbitfield *) p >> shift) & 1); 2086 break; 2087 } 2088} 2089 2090void GLAPIENTRY 2091_mesa_GetIntegerv(GLenum pname, GLint *params) 2092{ 2093 const struct value_desc *d; 2094 union value v; 2095 GLmatrix *m; 2096 int shift, i; 2097 void *p; 2098 GET_CURRENT_CONTEXT(ctx); 2099 2100 ASSERT_OUTSIDE_BEGIN_END(ctx); 2101 2102 d = find_value("glGetIntegerv", pname, &p, &v); 2103 switch (d->type) { 2104 case TYPE_INVALID: 2105 break; 2106 case TYPE_CONST: 2107 params[0] = d->offset; 2108 break; 2109 2110 case TYPE_FLOAT_4: 2111 params[3] = IROUND(((GLfloat *) p)[3]); 2112 case TYPE_FLOAT_3: 2113 params[2] = IROUND(((GLfloat *) p)[2]); 2114 case TYPE_FLOAT_2: 2115 params[1] = IROUND(((GLfloat *) p)[1]); 2116 case TYPE_FLOAT: 2117 params[0] = IROUND(((GLfloat *) p)[0]); 2118 break; 2119 2120 case TYPE_FLOATN_4: 2121 params[3] = FLOAT_TO_INT(((GLfloat *) p)[3]); 2122 case TYPE_FLOATN_3: 2123 params[2] = FLOAT_TO_INT(((GLfloat *) p)[2]); 2124 case TYPE_FLOATN_2: 2125 params[1] = FLOAT_TO_INT(((GLfloat *) p)[1]); 2126 case TYPE_FLOATN: 2127 params[0] = FLOAT_TO_INT(((GLfloat *) p)[0]); 2128 break; 2129 2130 case TYPE_DOUBLEN: 2131 params[0] = FLOAT_TO_INT(((GLdouble *) p)[0]); 2132 break; 2133 2134 case TYPE_INT_4: 2135 params[3] = ((GLint *) p)[3]; 2136 case TYPE_INT_3: 2137 params[2] = ((GLint *) p)[2]; 2138 case TYPE_INT_2: 2139 case TYPE_ENUM_2: 2140 params[1] = ((GLint *) p)[1]; 2141 case TYPE_INT: 2142 case TYPE_ENUM: 2143 params[0] = ((GLint *) p)[0]; 2144 break; 2145 2146 case TYPE_INT_N: 2147 for (i = 0; i < v.value_int_n.n; i++) 2148 params[i] = v.value_int_n.ints[i]; 2149 break; 2150 2151 case TYPE_INT64: 2152 params[0] = INT64_TO_INT(((GLint64 *) p)[0]); 2153 break; 2154 2155 case TYPE_BOOLEAN: 2156 params[0] = BOOLEAN_TO_INT(*(GLboolean*) p); 2157 break; 2158 2159 case TYPE_MATRIX: 2160 m = *(GLmatrix **) p; 2161 for (i = 0; i < 16; i++) 2162 params[i] = FLOAT_TO_INT(m->m[i]); 2163 break; 2164 2165 case TYPE_MATRIX_T: 2166 m = *(GLmatrix **) p; 2167 for (i = 0; i < 16; i++) 2168 params[i] = FLOAT_TO_INT(m->m[transpose[i]]); 2169 break; 2170 2171 case TYPE_BIT_0: 2172 case TYPE_BIT_1: 2173 case TYPE_BIT_2: 2174 case TYPE_BIT_3: 2175 case TYPE_BIT_4: 2176 case TYPE_BIT_5: 2177 shift = d->type - TYPE_BIT_0; 2178 params[0] = (*(GLbitfield *) p >> shift) & 1; 2179 break; 2180 } 2181} 2182 2183#if FEATURE_ARB_sync 2184void GLAPIENTRY 2185_mesa_GetInteger64v(GLenum pname, GLint64 *params) 2186{ 2187 const struct value_desc *d; 2188 union value v; 2189 GLmatrix *m; 2190 int shift, i; 2191 void *p; 2192 GET_CURRENT_CONTEXT(ctx); 2193 2194 ASSERT_OUTSIDE_BEGIN_END(ctx); 2195 2196 d = find_value("glGetInteger64v", pname, &p, &v); 2197 switch (d->type) { 2198 case TYPE_INVALID: 2199 break; 2200 case TYPE_CONST: 2201 params[0] = d->offset; 2202 break; 2203 2204 case TYPE_FLOAT_4: 2205 params[3] = IROUND64(((GLfloat *) p)[3]); 2206 case TYPE_FLOAT_3: 2207 params[2] = IROUND64(((GLfloat *) p)[2]); 2208 case TYPE_FLOAT_2: 2209 params[1] = IROUND64(((GLfloat *) p)[1]); 2210 case TYPE_FLOAT: 2211 params[0] = IROUND64(((GLfloat *) p)[0]); 2212 break; 2213 2214 case TYPE_FLOATN_4: 2215 params[3] = FLOAT_TO_INT64(((GLfloat *) p)[3]); 2216 case TYPE_FLOATN_3: 2217 params[2] = FLOAT_TO_INT64(((GLfloat *) p)[2]); 2218 case TYPE_FLOATN_2: 2219 params[1] = FLOAT_TO_INT64(((GLfloat *) p)[1]); 2220 case TYPE_FLOATN: 2221 params[0] = FLOAT_TO_INT64(((GLfloat *) p)[0]); 2222 break; 2223 2224 case TYPE_DOUBLEN: 2225 params[0] = FLOAT_TO_INT64(((GLdouble *) p)[0]); 2226 break; 2227 2228 case TYPE_INT_4: 2229 params[3] = ((GLint *) p)[3]; 2230 case TYPE_INT_3: 2231 params[2] = ((GLint *) p)[2]; 2232 case TYPE_INT_2: 2233 case TYPE_ENUM_2: 2234 params[1] = ((GLint *) p)[1]; 2235 case TYPE_INT: 2236 case TYPE_ENUM: 2237 params[0] = ((GLint *) p)[0]; 2238 break; 2239 2240 case TYPE_INT_N: 2241 for (i = 0; i < v.value_int_n.n; i++) 2242 params[i] = INT_TO_BOOLEAN(v.value_int_n.ints[i]); 2243 break; 2244 2245 case TYPE_INT64: 2246 params[0] = ((GLint64 *) p)[0]; 2247 break; 2248 2249 case TYPE_BOOLEAN: 2250 params[0] = ((GLboolean*) p)[0]; 2251 break; 2252 2253 case TYPE_MATRIX: 2254 m = *(GLmatrix **) p; 2255 for (i = 0; i < 16; i++) 2256 params[i] = FLOAT_TO_INT64(m->m[i]); 2257 break; 2258 2259 case TYPE_MATRIX_T: 2260 m = *(GLmatrix **) p; 2261 for (i = 0; i < 16; i++) 2262 params[i] = FLOAT_TO_INT64(m->m[transpose[i]]); 2263 break; 2264 2265 case TYPE_BIT_0: 2266 case TYPE_BIT_1: 2267 case TYPE_BIT_2: 2268 case TYPE_BIT_3: 2269 case TYPE_BIT_4: 2270 case TYPE_BIT_5: 2271 shift = d->type - TYPE_BIT_0; 2272 params[0] = (*(GLbitfield *) p >> shift) & 1; 2273 break; 2274 } 2275} 2276#endif /* FEATURE_ARB_sync */ 2277 2278void GLAPIENTRY 2279_mesa_GetDoublev(GLenum pname, GLdouble *params) 2280{ 2281 const struct value_desc *d; 2282 union value v; 2283 GLmatrix *m; 2284 int shift, i; 2285 void *p; 2286 GET_CURRENT_CONTEXT(ctx); 2287 2288 ASSERT_OUTSIDE_BEGIN_END(ctx); 2289 2290 d = find_value("glGetDoublev", pname, &p, &v); 2291 switch (d->type) { 2292 case TYPE_INVALID: 2293 break; 2294 case TYPE_CONST: 2295 params[0] = d->offset; 2296 break; 2297 2298 case TYPE_FLOAT_4: 2299 case TYPE_FLOATN_4: 2300 params[3] = ((GLfloat *) p)[3]; 2301 case TYPE_FLOAT_3: 2302 case TYPE_FLOATN_3: 2303 params[2] = ((GLfloat *) p)[2]; 2304 case TYPE_FLOAT_2: 2305 case TYPE_FLOATN_2: 2306 params[1] = ((GLfloat *) p)[1]; 2307 case TYPE_FLOAT: 2308 case TYPE_FLOATN: 2309 params[0] = ((GLfloat *) p)[0]; 2310 break; 2311 2312 case TYPE_DOUBLEN: 2313 params[0] = ((GLdouble *) p)[0]; 2314 break; 2315 2316 case TYPE_INT_4: 2317 params[3] = ((GLint *) p)[3]; 2318 case TYPE_INT_3: 2319 params[2] = ((GLint *) p)[2]; 2320 case TYPE_INT_2: 2321 case TYPE_ENUM_2: 2322 params[1] = ((GLint *) p)[1]; 2323 case TYPE_INT: 2324 case TYPE_ENUM: 2325 params[0] = ((GLint *) p)[0]; 2326 break; 2327 2328 case TYPE_INT_N: 2329 for (i = 0; i < v.value_int_n.n; i++) 2330 params[i] = v.value_int_n.ints[i]; 2331 break; 2332 2333 case TYPE_INT64: 2334 params[0] = ((GLint64 *) p)[0]; 2335 break; 2336 2337 case TYPE_BOOLEAN: 2338 params[0] = *(GLboolean*) p; 2339 break; 2340 2341 case TYPE_MATRIX: 2342 m = *(GLmatrix **) p; 2343 for (i = 0; i < 16; i++) 2344 params[i] = m->m[i]; 2345 break; 2346 2347 case TYPE_MATRIX_T: 2348 m = *(GLmatrix **) p; 2349 for (i = 0; i < 16; i++) 2350 params[i] = m->m[transpose[i]]; 2351 break; 2352 2353 case TYPE_BIT_0: 2354 case TYPE_BIT_1: 2355 case TYPE_BIT_2: 2356 case TYPE_BIT_3: 2357 case TYPE_BIT_4: 2358 case TYPE_BIT_5: 2359 shift = d->type - TYPE_BIT_0; 2360 params[0] = (*(GLbitfield *) p >> shift) & 1; 2361 break; 2362 } 2363} 2364 2365static enum value_type 2366find_value_indexed(const char *func, GLenum pname, int index, union value *v) 2367{ 2368 GET_CURRENT_CONTEXT(ctx); 2369 2370 switch (pname) { 2371 2372 case GL_BLEND: 2373 if (index >= ctx->Const.MaxDrawBuffers) 2374 goto invalid_value; 2375 if (!ctx->Extensions.EXT_draw_buffers2) 2376 goto invalid_enum; 2377 v->value_int = (ctx->Color.BlendEnabled >> index) & 1; 2378 return TYPE_INT; 2379 2380 case GL_BLEND_SRC: 2381 /* fall-through */ 2382 case GL_BLEND_SRC_RGB: 2383 if (index >= ctx->Const.MaxDrawBuffers) 2384 goto invalid_value; 2385 if (!ctx->Extensions.ARB_draw_buffers_blend) 2386 goto invalid_enum; 2387 v->value_int = ctx->Color.Blend[index].SrcRGB; 2388 return TYPE_INT; 2389 case GL_BLEND_SRC_ALPHA: 2390 if (index >= ctx->Const.MaxDrawBuffers) 2391 goto invalid_value; 2392 if (!ctx->Extensions.ARB_draw_buffers_blend) 2393 goto invalid_enum; 2394 v->value_int = ctx->Color.Blend[index].SrcA; 2395 return TYPE_INT; 2396 case GL_BLEND_DST: 2397 /* fall-through */ 2398 case GL_BLEND_DST_RGB: 2399 if (index >= ctx->Const.MaxDrawBuffers) 2400 goto invalid_value; 2401 if (!ctx->Extensions.ARB_draw_buffers_blend) 2402 goto invalid_enum; 2403 v->value_int = ctx->Color.Blend[index].DstRGB; 2404 return TYPE_INT; 2405 case GL_BLEND_DST_ALPHA: 2406 if (index >= ctx->Const.MaxDrawBuffers) 2407 goto invalid_value; 2408 if (!ctx->Extensions.ARB_draw_buffers_blend) 2409 goto invalid_enum; 2410 v->value_int = ctx->Color.Blend[index].DstA; 2411 return TYPE_INT; 2412 case GL_BLEND_EQUATION_RGB: 2413 if (index >= ctx->Const.MaxDrawBuffers) 2414 goto invalid_value; 2415 if (!ctx->Extensions.ARB_draw_buffers_blend) 2416 goto invalid_enum; 2417 v->value_int = ctx->Color.Blend[index].EquationRGB; 2418 return TYPE_INT; 2419 case GL_BLEND_EQUATION_ALPHA: 2420 if (index >= ctx->Const.MaxDrawBuffers) 2421 goto invalid_value; 2422 if (!ctx->Extensions.ARB_draw_buffers_blend) 2423 goto invalid_enum; 2424 v->value_int = ctx->Color.Blend[index].EquationA; 2425 return TYPE_INT; 2426 2427 case GL_COLOR_WRITEMASK: 2428 if (index >= ctx->Const.MaxDrawBuffers) 2429 goto invalid_value; 2430 if (!ctx->Extensions.EXT_draw_buffers2) 2431 goto invalid_enum; 2432 v->value_int_4[0] = ctx->Color.ColorMask[index][RCOMP] ? 1 : 0; 2433 v->value_int_4[1] = ctx->Color.ColorMask[index][GCOMP] ? 1 : 0; 2434 v->value_int_4[2] = ctx->Color.ColorMask[index][BCOMP] ? 1 : 0; 2435 v->value_int_4[3] = ctx->Color.ColorMask[index][ACOMP] ? 1 : 0; 2436 return TYPE_INT_4; 2437 2438 case GL_TRANSFORM_FEEDBACK_BUFFER_START: 2439 if (index >= ctx->Const.MaxTransformFeedbackSeparateAttribs) 2440 goto invalid_value; 2441 if (!ctx->Extensions.EXT_transform_feedback) 2442 goto invalid_enum; 2443 v->value_int64 = ctx->TransformFeedback.CurrentObject->Offset[index]; 2444 return TYPE_INT64; 2445 2446 case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE: 2447 if (index >= ctx->Const.MaxTransformFeedbackSeparateAttribs) 2448 goto invalid_value; 2449 if (!ctx->Extensions.EXT_transform_feedback) 2450 goto invalid_enum; 2451 v->value_int64 = ctx->TransformFeedback.CurrentObject->Size[index]; 2452 return TYPE_INT64; 2453 2454 case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING: 2455 if (index >= ctx->Const.MaxTransformFeedbackSeparateAttribs) 2456 goto invalid_value; 2457 if (!ctx->Extensions.EXT_transform_feedback) 2458 goto invalid_enum; 2459 v->value_int = ctx->TransformFeedback.CurrentObject->Buffers[index]->Name; 2460 return TYPE_INT; 2461 } 2462 2463 invalid_enum: 2464 _mesa_error(ctx, GL_INVALID_ENUM, "%s(pname=%s)", func, 2465 _mesa_lookup_enum_by_nr(pname)); 2466 return TYPE_INVALID; 2467 invalid_value: 2468 _mesa_error(ctx, GL_INVALID_VALUE, "%s(pname=%s)", func, 2469 _mesa_lookup_enum_by_nr(pname)); 2470 return TYPE_INVALID; 2471} 2472 2473void GLAPIENTRY 2474_mesa_GetBooleanIndexedv( GLenum pname, GLuint index, GLboolean *params ) 2475{ 2476 union value v; 2477 enum value_type type = 2478 find_value_indexed("glGetBooleanIndexedv", pname, index, &v); 2479 2480 switch (type) { 2481 case TYPE_INT: 2482 params[0] = INT_TO_BOOLEAN(v.value_int); 2483 break; 2484 case TYPE_INT_4: 2485 params[0] = INT_TO_BOOLEAN(v.value_int_4[0]); 2486 params[1] = INT_TO_BOOLEAN(v.value_int_4[1]); 2487 params[2] = INT_TO_BOOLEAN(v.value_int_4[2]); 2488 params[3] = INT_TO_BOOLEAN(v.value_int_4[3]); 2489 break; 2490 case TYPE_INT64: 2491 params[0] = INT64_TO_BOOLEAN(v.value_int); 2492 break; 2493 default: 2494 ; /* nothing - GL error was recorded */ 2495 } 2496} 2497 2498void GLAPIENTRY 2499_mesa_GetIntegerIndexedv( GLenum pname, GLuint index, GLint *params ) 2500{ 2501 union value v; 2502 enum value_type type = 2503 find_value_indexed("glGetIntegerIndexedv", pname, index, &v); 2504 2505 switch (type) { 2506 case TYPE_INT: 2507 params[0] = v.value_int; 2508 break; 2509 case TYPE_INT_4: 2510 params[0] = v.value_int_4[0]; 2511 params[1] = v.value_int_4[1]; 2512 params[2] = v.value_int_4[2]; 2513 params[3] = v.value_int_4[3]; 2514 break; 2515 case TYPE_INT64: 2516 params[0] = INT64_TO_INT(v.value_int); 2517 break; 2518 default: 2519 ; /* nothing - GL error was recorded */ 2520 } 2521} 2522 2523#if FEATURE_ARB_sync 2524void GLAPIENTRY 2525_mesa_GetInteger64Indexedv( GLenum pname, GLuint index, GLint64 *params ) 2526{ 2527 union value v; 2528 enum value_type type = 2529 find_value_indexed("glGetIntegerIndexedv", pname, index, &v); 2530 2531 switch (type) { 2532 case TYPE_INT: 2533 params[0] = v.value_int; 2534 break; 2535 case TYPE_INT_4: 2536 params[0] = v.value_int_4[0]; 2537 params[1] = v.value_int_4[1]; 2538 params[2] = v.value_int_4[2]; 2539 params[3] = v.value_int_4[3]; 2540 break; 2541 case TYPE_INT64: 2542 params[0] = v.value_int; 2543 break; 2544 default: 2545 ; /* nothing - GL error was recorded */ 2546 } 2547} 2548#endif /* FEATURE_ARB_sync */ 2549 2550#if FEATURE_ES1 2551void GLAPIENTRY 2552_mesa_GetFixedv(GLenum pname, GLfixed *params) 2553{ 2554 const struct value_desc *d; 2555 union value v; 2556 GLmatrix *m; 2557 int shift, i; 2558 void *p; 2559 2560 d = find_value("glGetDoublev", pname, &p, &v); 2561 switch (d->type) { 2562 case TYPE_INVALID: 2563 break; 2564 case TYPE_CONST: 2565 params[0] = INT_TO_FIXED(d->offset); 2566 break; 2567 2568 case TYPE_FLOAT_4: 2569 case TYPE_FLOATN_4: 2570 params[3] = FLOAT_TO_FIXED(((GLfloat *) p)[3]); 2571 case TYPE_FLOAT_3: 2572 case TYPE_FLOATN_3: 2573 params[2] = FLOAT_TO_FIXED(((GLfloat *) p)[2]); 2574 case TYPE_FLOAT_2: 2575 case TYPE_FLOATN_2: 2576 params[1] = FLOAT_TO_FIXED(((GLfloat *) p)[1]); 2577 case TYPE_FLOAT: 2578 case TYPE_FLOATN: 2579 params[0] = FLOAT_TO_FIXED(((GLfloat *) p)[0]); 2580 break; 2581 2582 case TYPE_DOUBLEN: 2583 params[0] = FLOAT_TO_FIXED(((GLdouble *) p)[0]); 2584 break; 2585 2586 case TYPE_INT_4: 2587 params[3] = INT_TO_FIXED(((GLint *) p)[3]); 2588 case TYPE_INT_3: 2589 params[2] = INT_TO_FIXED(((GLint *) p)[2]); 2590 case TYPE_INT_2: 2591 case TYPE_ENUM_2: 2592 params[1] = INT_TO_FIXED(((GLint *) p)[1]); 2593 case TYPE_INT: 2594 case TYPE_ENUM: 2595 params[0] = INT_TO_FIXED(((GLint *) p)[0]); 2596 break; 2597 2598 case TYPE_INT_N: 2599 for (i = 0; i < v.value_int_n.n; i++) 2600 params[i] = INT_TO_FIXED(v.value_int_n.ints[i]); 2601 break; 2602 2603 case TYPE_INT64: 2604 params[0] = ((GLint64 *) p)[0]; 2605 break; 2606 2607 case TYPE_BOOLEAN: 2608 params[0] = BOOLEAN_TO_FIXED(((GLboolean*) p)[0]); 2609 break; 2610 2611 case TYPE_MATRIX: 2612 m = *(GLmatrix **) p; 2613 for (i = 0; i < 16; i++) 2614 params[i] = FLOAT_TO_FIXED(m->m[i]); 2615 break; 2616 2617 case TYPE_MATRIX_T: 2618 m = *(GLmatrix **) p; 2619 for (i = 0; i < 16; i++) 2620 params[i] = FLOAT_TO_FIXED(m->m[transpose[i]]); 2621 break; 2622 2623 case TYPE_BIT_0: 2624 case TYPE_BIT_1: 2625 case TYPE_BIT_2: 2626 case TYPE_BIT_3: 2627 case TYPE_BIT_4: 2628 case TYPE_BIT_5: 2629 shift = d->type - TYPE_BIT_0; 2630 params[0] = BOOLEAN_TO_FIXED((*(GLbitfield *) p >> shift) & 1); 2631 break; 2632 } 2633} 2634#endif 2635