get.c revision 7ec681f3
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 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 19 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 20 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 21 * OTHER DEALINGS IN THE SOFTWARE. 22 * 23 * Author: Kristian Høgsberg <krh@bitplanet.net> 24 */ 25 26#include "glheader.h" 27#include "context.h" 28#include "blend.h" 29#include "debug_output.h" 30#include "enable.h" 31#include "enums.h" 32#include "errors.h" 33#include "extensions.h" 34#include "get.h" 35#include "macros.h" 36#include "mtypes.h" 37#include "spirv_extensions.h" 38#include "state.h" 39#include "texcompress.h" 40#include "texstate.h" 41#include "framebuffer.h" 42#include "samplerobj.h" 43#include "stencil.h" 44#include "version.h" 45 46/* This is a table driven implemetation of the glGet*v() functions. 47 * The basic idea is that most getters just look up an int somewhere 48 * in struct gl_context and then convert it to a bool or float according to 49 * which of glGetIntegerv() glGetBooleanv() etc is being called. 50 * Instead of generating code to do this, we can just record the enum 51 * value and the offset into struct gl_context in an array of structs. Then 52 * in glGet*(), we lookup the struct for the enum in question, and use 53 * the offset to get the int we need. 54 * 55 * Sometimes we need to look up a float, a boolean, a bit in a 56 * bitfield, a matrix or other types instead, so we need to track the 57 * type of the value in struct gl_context. And sometimes the value isn't in 58 * struct gl_context but in the drawbuffer, the array object, current texture 59 * unit, or maybe it's a computed value. So we need to also track 60 * where or how to find the value. Finally, we sometimes need to 61 * check that one of a number of extensions are enabled, the GL 62 * version or flush or call _mesa_update_state(). This is done by 63 * attaching optional extra information to the value description 64 * struct, it's sort of like an array of opcodes that describe extra 65 * checks or actions. 66 * 67 * Putting all this together we end up with struct value_desc below, 68 * and with a couple of macros to help, the table of struct value_desc 69 * is about as concise as the specification in the old python script. 70 */ 71 72static inline GLboolean 73FLOAT_TO_BOOLEAN(GLfloat X) 74{ 75 return ( (X) ? GL_TRUE : GL_FALSE ); 76} 77 78static inline GLint 79FLOAT_TO_FIXED(GLfloat F) 80{ 81 return ( ((F) * 65536.0f > INT_MAX) ? INT_MAX : 82 ((F) * 65536.0f < INT_MIN) ? INT_MIN : 83 (GLint) ((F) * 65536.0f) ); 84} 85 86static inline GLboolean 87INT_TO_BOOLEAN(GLint I) 88{ 89 return ( (I) ? GL_TRUE : GL_FALSE ); 90} 91 92static inline GLfixed 93INT_TO_FIXED(GLint I) 94{ 95 return (((I) > SHRT_MAX) ? INT_MAX : 96 ((I) < SHRT_MIN) ? INT_MIN : 97 (GLint) ((I) * 65536) ); 98} 99 100 101static inline GLboolean 102INT64_TO_BOOLEAN(GLint64 I) 103{ 104 return ( (I) ? GL_TRUE : GL_FALSE ); 105} 106 107static inline GLint 108INT64_TO_INT(GLint64 I) 109{ 110 return ( (GLint)((I > INT_MAX) ? INT_MAX : ((I < INT_MIN) ? INT_MIN : (I))) ); 111} 112 113static inline GLint 114BOOLEAN_TO_INT(GLboolean B) 115{ 116 return ( (GLint) (B) ); 117} 118 119static inline GLfloat 120BOOLEAN_TO_FLOAT(GLboolean B) 121{ 122 return ( (B) ? 1.0F : 0.0F ); 123} 124 125static inline GLfixed 126BOOLEAN_TO_FIXED(GLboolean B) 127{ 128 return ( (GLint) ((B) ? 1 : 0) << 16 ); 129} 130 131enum value_type { 132 TYPE_INVALID, 133 TYPE_INT, 134 TYPE_INT_2, 135 TYPE_INT_3, 136 TYPE_INT_4, 137 TYPE_INT_N, 138 TYPE_UINT, 139 TYPE_UINT_2, 140 TYPE_UINT_3, 141 TYPE_UINT_4, 142 TYPE_INT64, 143 TYPE_ENUM16, 144 TYPE_ENUM, 145 TYPE_ENUM_2, 146 TYPE_BOOLEAN, 147 TYPE_UBYTE, 148 TYPE_SHORT, 149 TYPE_BIT_0, 150 TYPE_BIT_1, 151 TYPE_BIT_2, 152 TYPE_BIT_3, 153 TYPE_BIT_4, 154 TYPE_BIT_5, 155 TYPE_BIT_6, 156 TYPE_BIT_7, 157 TYPE_FLOAT, 158 TYPE_FLOAT_2, 159 TYPE_FLOAT_3, 160 TYPE_FLOAT_4, 161 TYPE_FLOAT_8, 162 TYPE_FLOATN, 163 TYPE_FLOATN_2, 164 TYPE_FLOATN_3, 165 TYPE_FLOATN_4, 166 TYPE_DOUBLEN, 167 TYPE_DOUBLEN_2, 168 TYPE_MATRIX, 169 TYPE_MATRIX_T, 170 TYPE_CONST 171}; 172 173enum value_location { 174 LOC_BUFFER, 175 LOC_CONTEXT, 176 LOC_ARRAY, 177 LOC_TEXUNIT, 178 LOC_CUSTOM 179}; 180 181enum value_extra { 182 EXTRA_END = 0x8000, 183 EXTRA_VERSION_30, 184 EXTRA_VERSION_31, 185 EXTRA_VERSION_32, 186 EXTRA_VERSION_40, 187 EXTRA_VERSION_43, 188 EXTRA_API_GL, 189 EXTRA_API_GL_CORE, 190 EXTRA_API_ES2, 191 EXTRA_API_ES3, 192 EXTRA_API_ES31, 193 EXTRA_API_ES32, 194 EXTRA_NEW_BUFFERS, 195 EXTRA_VALID_DRAW_BUFFER, 196 EXTRA_VALID_TEXTURE_UNIT, 197 EXTRA_VALID_CLIP_DISTANCE, 198 EXTRA_FLUSH_CURRENT, 199 EXTRA_GLSL_130, 200 EXTRA_EXT_UBO_GS, 201 EXTRA_EXT_ATOMICS_GS, 202 EXTRA_EXT_SHADER_IMAGE_GS, 203 EXTRA_EXT_ATOMICS_TESS, 204 EXTRA_EXT_SHADER_IMAGE_TESS, 205 EXTRA_EXT_SSBO_GS, 206 EXTRA_EXT_FB_NO_ATTACH_GS, 207 EXTRA_EXT_ES_GS, 208 EXTRA_EXT_PROVOKING_VERTEX_32, 209}; 210 211#define NO_EXTRA NULL 212#define NO_OFFSET 0 213 214struct value_desc { 215 GLenum pname; 216 GLubyte location; /**< enum value_location */ 217 GLubyte type; /**< enum value_type */ 218 int offset; 219 const int *extra; 220}; 221 222union value { 223 GLfloat value_float; 224 GLfloat value_float_4[4]; 225 GLdouble value_double_2[2]; 226 GLmatrix *value_matrix; 227 GLint value_int; 228 GLint value_int_4[4]; 229 GLint64 value_int64; 230 GLenum value_enum; 231 GLenum16 value_enum16; 232 GLubyte value_ubyte; 233 GLshort value_short; 234 GLuint value_uint; 235 236 /* Sigh, see GL_COMPRESSED_TEXTURE_FORMATS_ARB handling */ 237 struct { 238 GLint n, ints[100]; 239 } value_int_n; 240 GLboolean value_bool; 241}; 242 243#define BUFFER_FIELD(field, type) \ 244 LOC_BUFFER, type, offsetof(struct gl_framebuffer, field) 245#define CONTEXT_FIELD(field, type) \ 246 LOC_CONTEXT, type, offsetof(struct gl_context, field) 247#define ARRAY_FIELD(field, type) \ 248 LOC_ARRAY, type, offsetof(struct gl_vertex_array_object, field) 249#undef CONST /* already defined through windows.h */ 250#define CONST(value) \ 251 LOC_CONTEXT, TYPE_CONST, value 252 253#define BUFFER_INT(field) BUFFER_FIELD(field, TYPE_INT) 254#define BUFFER_ENUM(field) BUFFER_FIELD(field, TYPE_ENUM) 255#define BUFFER_ENUM16(field) BUFFER_FIELD(field, TYPE_ENUM16) 256#define BUFFER_BOOL(field) BUFFER_FIELD(field, TYPE_BOOLEAN) 257 258#define CONTEXT_INT(field) CONTEXT_FIELD(field, TYPE_INT) 259#define CONTEXT_INT2(field) CONTEXT_FIELD(field, TYPE_INT_2) 260#define CONTEXT_INT64(field) CONTEXT_FIELD(field, TYPE_INT64) 261#define CONTEXT_UINT(field) CONTEXT_FIELD(field, TYPE_UINT) 262#define CONTEXT_ENUM16(field) CONTEXT_FIELD(field, TYPE_ENUM16) 263#define CONTEXT_ENUM(field) CONTEXT_FIELD(field, TYPE_ENUM) 264#define CONTEXT_ENUM2(field) CONTEXT_FIELD(field, TYPE_ENUM_2) 265#define CONTEXT_BOOL(field) CONTEXT_FIELD(field, TYPE_BOOLEAN) 266#define CONTEXT_BIT0(field) CONTEXT_FIELD(field, TYPE_BIT_0) 267#define CONTEXT_BIT1(field) CONTEXT_FIELD(field, TYPE_BIT_1) 268#define CONTEXT_BIT2(field) CONTEXT_FIELD(field, TYPE_BIT_2) 269#define CONTEXT_BIT3(field) CONTEXT_FIELD(field, TYPE_BIT_3) 270#define CONTEXT_BIT4(field) CONTEXT_FIELD(field, TYPE_BIT_4) 271#define CONTEXT_BIT5(field) CONTEXT_FIELD(field, TYPE_BIT_5) 272#define CONTEXT_BIT6(field) CONTEXT_FIELD(field, TYPE_BIT_6) 273#define CONTEXT_BIT7(field) CONTEXT_FIELD(field, TYPE_BIT_7) 274#define CONTEXT_FLOAT(field) CONTEXT_FIELD(field, TYPE_FLOAT) 275#define CONTEXT_FLOAT2(field) CONTEXT_FIELD(field, TYPE_FLOAT_2) 276#define CONTEXT_FLOAT3(field) CONTEXT_FIELD(field, TYPE_FLOAT_3) 277#define CONTEXT_FLOAT4(field) CONTEXT_FIELD(field, TYPE_FLOAT_4) 278#define CONTEXT_FLOAT8(field) CONTEXT_FIELD(field, TYPE_FLOAT_8) 279#define CONTEXT_MATRIX(field) CONTEXT_FIELD(field, TYPE_MATRIX) 280#define CONTEXT_MATRIX_T(field) CONTEXT_FIELD(field, TYPE_MATRIX_T) 281 282/* Vertex array fields */ 283#define ARRAY_INT(field) ARRAY_FIELD(field, TYPE_INT) 284#define ARRAY_ENUM(field) ARRAY_FIELD(field, TYPE_ENUM) 285#define ARRAY_ENUM16(field) ARRAY_FIELD(field, TYPE_ENUM16) 286#define ARRAY_BOOL(field) ARRAY_FIELD(field, TYPE_BOOLEAN) 287#define ARRAY_UBYTE(field) ARRAY_FIELD(field, TYPE_UBYTE) 288#define ARRAY_SHORT(field) ARRAY_FIELD(field, TYPE_SHORT) 289 290#define EXT(f) \ 291 offsetof(struct gl_extensions, f) 292 293#define EXTRA_EXT(e) \ 294 static const int extra_##e[] = { \ 295 EXT(e), EXTRA_END \ 296 } 297 298#define EXTRA_EXT2(e1, e2) \ 299 static const int extra_##e1##_##e2[] = { \ 300 EXT(e1), EXT(e2), EXTRA_END \ 301 } 302 303/* The 'extra' mechanism is a way to specify extra checks (such as 304 * extensions or specific gl versions) or actions (flush current, new 305 * buffers) that we need to do before looking up an enum. We need to 306 * declare them all up front so we can refer to them in the value_desc 307 * structs below. 308 * 309 * Each EXTRA_ will be executed. For EXTRA_* enums of extensions and API 310 * versions, listing multiple ones in an array means an error will be thrown 311 * only if none of them are available. If you need to check for "AND" 312 * behavior, you would need to make a custom EXTRA_ enum. 313 */ 314 315static const int extra_new_buffers[] = { 316 EXTRA_NEW_BUFFERS, 317 EXTRA_END 318}; 319 320static const int extra_valid_draw_buffer[] = { 321 EXTRA_VALID_DRAW_BUFFER, 322 EXTRA_END 323}; 324 325static const int extra_valid_texture_unit[] = { 326 EXTRA_VALID_TEXTURE_UNIT, 327 EXTRA_END 328}; 329 330static const int extra_valid_clip_distance[] = { 331 EXTRA_VALID_CLIP_DISTANCE, 332 EXTRA_END 333}; 334 335static const int extra_flush_current_valid_texture_unit[] = { 336 EXTRA_FLUSH_CURRENT, 337 EXTRA_VALID_TEXTURE_UNIT, 338 EXTRA_END 339}; 340 341static const int extra_flush_current[] = { 342 EXTRA_FLUSH_CURRENT, 343 EXTRA_END 344}; 345 346static const int extra_EXT_texture_integer_and_new_buffers[] = { 347 EXT(EXT_texture_integer), 348 EXTRA_NEW_BUFFERS, 349 EXTRA_END 350}; 351 352static const int extra_GLSL_130_es3_gpushader4[] = { 353 EXTRA_GLSL_130, 354 EXTRA_API_ES3, 355 EXT(EXT_gpu_shader4), 356 EXTRA_END 357}; 358 359static const int extra_texture_buffer_object[] = { 360 EXT(ARB_texture_buffer_object), 361 EXTRA_END 362}; 363 364static const int extra_ARB_transform_feedback2_api_es3[] = { 365 EXT(ARB_transform_feedback2), 366 EXTRA_API_ES3, 367 EXTRA_END 368}; 369 370static const int extra_ARB_uniform_buffer_object_and_geometry_shader[] = { 371 EXTRA_EXT_UBO_GS, 372 EXTRA_END 373}; 374 375static const int extra_ARB_ES2_compatibility_api_es2[] = { 376 EXT(ARB_ES2_compatibility), 377 EXTRA_API_ES2, 378 EXTRA_END 379}; 380 381static const int extra_ARB_ES3_compatibility_api_es3[] = { 382 EXT(ARB_ES3_compatibility), 383 EXTRA_API_ES3, 384 EXTRA_END 385}; 386 387static const int extra_EXT_framebuffer_sRGB_and_new_buffers[] = { 388 EXT(EXT_framebuffer_sRGB), 389 EXTRA_NEW_BUFFERS, 390 EXTRA_END 391}; 392 393static const int extra_EXT_packed_float[] = { 394 EXT(EXT_packed_float), 395 EXTRA_NEW_BUFFERS, 396 EXTRA_END 397}; 398 399static const int extra_EXT_texture_array_es3[] = { 400 EXT(EXT_texture_array), 401 EXTRA_API_ES3, 402 EXTRA_END 403}; 404 405static const int extra_ARB_shader_atomic_counters_and_geometry_shader[] = { 406 EXTRA_EXT_ATOMICS_GS, 407 EXTRA_END 408}; 409 410static const int extra_ARB_shader_atomic_counters_es31[] = { 411 EXT(ARB_shader_atomic_counters), 412 EXTRA_API_ES31, 413 EXTRA_END 414}; 415 416static const int extra_ARB_shader_image_load_store_and_geometry_shader[] = { 417 EXTRA_EXT_SHADER_IMAGE_GS, 418 EXTRA_END 419}; 420 421static const int extra_ARB_shader_atomic_counters_and_tessellation[] = { 422 EXTRA_EXT_ATOMICS_TESS, 423 EXTRA_END 424}; 425 426static const int extra_ARB_shader_image_load_store_and_tessellation[] = { 427 EXTRA_EXT_SHADER_IMAGE_TESS, 428 EXTRA_END 429}; 430 431static const int extra_ARB_shader_image_load_store_es31[] = { 432 EXT(ARB_shader_image_load_store), 433 EXTRA_API_ES31, 434 EXTRA_END 435}; 436 437/* HACK: remove when ARB_compute_shader is actually supported */ 438static const int extra_ARB_compute_shader_es31[] = { 439 EXT(ARB_compute_shader), 440 EXTRA_API_ES31, 441 EXTRA_END 442}; 443 444static const int extra_ARB_shader_storage_buffer_object_es31[] = { 445 EXT(ARB_shader_storage_buffer_object), 446 EXTRA_API_ES31, 447 EXTRA_END 448}; 449 450static const int extra_ARB_shader_storage_buffer_object_and_geometry_shader[] = { 451 EXTRA_EXT_SSBO_GS, 452 EXTRA_END 453}; 454 455static const int extra_ARB_shader_image_load_store_shader_storage_buffer_object_es31[] = { 456 EXT(ARB_shader_image_load_store), 457 EXT(ARB_shader_storage_buffer_object), 458 EXTRA_API_ES31, 459 EXTRA_END 460}; 461 462static const int extra_ARB_framebuffer_no_attachments_and_geometry_shader[] = { 463 EXTRA_EXT_FB_NO_ATTACH_GS, 464 EXTRA_END 465}; 466 467static const int extra_ARB_viewport_array_or_oes_geometry_shader[] = { 468 EXT(ARB_viewport_array), 469 EXTRA_EXT_ES_GS, 470 EXTRA_END 471}; 472 473static const int extra_ARB_viewport_array_or_oes_viewport_array[] = { 474 EXT(ARB_viewport_array), 475 EXT(OES_viewport_array), 476 EXTRA_END 477}; 478 479static const int extra_ARB_gpu_shader5_or_oes_geometry_shader[] = { 480 EXT(ARB_gpu_shader5), 481 EXTRA_EXT_ES_GS, 482 EXTRA_END 483}; 484 485static const int extra_ARB_gpu_shader5_or_OES_sample_variables[] = { 486 EXT(ARB_gpu_shader5), 487 EXT(OES_sample_variables), 488 EXTRA_END 489}; 490 491static const int extra_ES32[] = { 492 EXT(ARB_ES3_2_compatibility), 493 EXTRA_API_ES32, 494 EXTRA_END 495}; 496 497static const int extra_KHR_robustness_or_GL[] = { 498 EXT(KHR_robustness), 499 EXTRA_API_GL, 500 EXTRA_API_GL_CORE, 501 EXTRA_END 502}; 503 504static const int extra_INTEL_conservative_rasterization[] = { 505 EXT(INTEL_conservative_rasterization), 506 EXTRA_END 507}; 508 509static const int extra_ARB_timer_query_or_EXT_disjoint_timer_query[] = { 510 EXT(ARB_timer_query), 511 EXT(EXT_disjoint_timer_query), 512 EXTRA_END 513}; 514 515EXTRA_EXT(ARB_texture_cube_map); 516EXTRA_EXT(EXT_texture_array); 517EXTRA_EXT(NV_fog_distance); 518EXTRA_EXT(EXT_texture_filter_anisotropic); 519EXTRA_EXT(NV_texture_rectangle); 520EXTRA_EXT(EXT_stencil_two_side); 521EXTRA_EXT(EXT_depth_bounds_test); 522EXTRA_EXT(ARB_depth_clamp); 523EXTRA_EXT(AMD_depth_clamp_separate); 524EXTRA_EXT(ATI_fragment_shader); 525EXTRA_EXT(EXT_provoking_vertex); 526EXTRA_EXT(ARB_fragment_shader); 527EXTRA_EXT(ARB_fragment_program); 528EXTRA_EXT2(ARB_framebuffer_object, EXT_framebuffer_multisample); 529EXTRA_EXT(ARB_seamless_cube_map); 530EXTRA_EXT(ARB_sync); 531EXTRA_EXT(ARB_vertex_shader); 532EXTRA_EXT(EXT_transform_feedback); 533EXTRA_EXT(ARB_transform_feedback3); 534EXTRA_EXT(EXT_pixel_buffer_object); 535EXTRA_EXT(ARB_vertex_program); 536EXTRA_EXT(ARB_point_sprite); 537EXTRA_EXT2(ARB_vertex_program, ARB_fragment_program); 538EXTRA_EXT(ARB_color_buffer_float); 539EXTRA_EXT(EXT_framebuffer_sRGB); 540EXTRA_EXT(OES_EGL_image_external); 541EXTRA_EXT(ARB_blend_func_extended); 542EXTRA_EXT(ARB_uniform_buffer_object); 543EXTRA_EXT2(ARB_texture_cube_map_array, OES_texture_cube_map_array); 544EXTRA_EXT(ARB_texture_buffer_range); 545EXTRA_EXT(ARB_texture_multisample); 546EXTRA_EXT(ARB_texture_gather); 547EXTRA_EXT(ARB_draw_indirect); 548EXTRA_EXT(ARB_shader_image_load_store); 549EXTRA_EXT(ARB_query_buffer_object); 550EXTRA_EXT2(ARB_transform_feedback3, ARB_gpu_shader5); 551EXTRA_EXT(INTEL_performance_query); 552EXTRA_EXT(ARB_explicit_uniform_location); 553EXTRA_EXT(ARB_clip_control); 554EXTRA_EXT(ARB_polygon_offset_clamp); 555EXTRA_EXT(ARB_framebuffer_no_attachments); 556EXTRA_EXT(ARB_tessellation_shader); 557EXTRA_EXT(ARB_shader_storage_buffer_object); 558EXTRA_EXT(ARB_indirect_parameters); 559EXTRA_EXT(ATI_meminfo); 560EXTRA_EXT(NVX_gpu_memory_info); 561EXTRA_EXT(ARB_cull_distance); 562EXTRA_EXT(EXT_window_rectangles); 563EXTRA_EXT(KHR_blend_equation_advanced_coherent); 564EXTRA_EXT(OES_primitive_bounding_box); 565EXTRA_EXT(ARB_compute_variable_group_size); 566EXTRA_EXT(KHR_robustness); 567EXTRA_EXT(ARB_sparse_buffer); 568EXTRA_EXT(NV_conservative_raster); 569EXTRA_EXT(NV_conservative_raster_dilate); 570EXTRA_EXT(NV_conservative_raster_pre_snap_triangles); 571EXTRA_EXT(ARB_sample_locations); 572EXTRA_EXT(AMD_framebuffer_multisample_advanced); 573EXTRA_EXT(ARB_spirv_extensions); 574EXTRA_EXT(NV_viewport_swizzle); 575 576static const int 577extra_ARB_color_buffer_float_or_glcore[] = { 578 EXT(ARB_color_buffer_float), 579 EXTRA_API_GL_CORE, 580 EXTRA_END 581}; 582 583static const int 584extra_NV_primitive_restart[] = { 585 EXT(NV_primitive_restart), 586 EXTRA_END 587}; 588 589static const int extra_version_30[] = { EXTRA_VERSION_30, EXTRA_END }; 590static const int extra_version_31[] = { EXTRA_VERSION_31, EXTRA_END }; 591static const int extra_version_32[] = { EXTRA_VERSION_32, EXTRA_END }; 592static const int extra_version_43[] = { EXTRA_VERSION_43, EXTRA_END }; 593 594static const int extra_gl30_es3[] = { 595 EXTRA_VERSION_30, 596 EXTRA_API_ES3, 597 EXTRA_END, 598}; 599 600static const int extra_gl32_es3[] = { 601 EXTRA_VERSION_32, 602 EXTRA_API_ES3, 603 EXTRA_END, 604}; 605 606static const int extra_version_32_OES_geometry_shader[] = { 607 EXTRA_VERSION_32, 608 EXTRA_EXT_ES_GS, 609 EXTRA_END 610}; 611 612static const int extra_gl40_ARB_sample_shading[] = { 613 EXTRA_VERSION_40, 614 EXT(ARB_sample_shading), 615 EXTRA_END 616}; 617 618static const int 619extra_ARB_vertex_program_api_es2[] = { 620 EXT(ARB_vertex_program), 621 EXTRA_API_ES2, 622 EXTRA_END 623}; 624 625/* The ReadBuffer get token is valid under either full GL or under 626 * GLES2 if the NV_read_buffer extension is available. */ 627static const int 628extra_NV_read_buffer_api_gl[] = { 629 EXTRA_API_ES2, 630 EXTRA_API_GL, 631 EXTRA_END 632}; 633 634static const int extra_core_ARB_color_buffer_float_and_new_buffers[] = { 635 EXTRA_API_GL_CORE, 636 EXT(ARB_color_buffer_float), 637 EXTRA_NEW_BUFFERS, 638 EXTRA_END 639}; 640 641static const int extra_EXT_shader_framebuffer_fetch[] = { 642 EXTRA_API_ES2, 643 EXTRA_API_ES3, 644 EXT(EXT_shader_framebuffer_fetch), 645 EXTRA_END 646}; 647 648static const int extra_EXT_provoking_vertex_32[] = { 649 EXTRA_EXT_PROVOKING_VERTEX_32, 650 EXTRA_END 651}; 652 653static const int extra_EXT_disjoint_timer_query[] = { 654 EXTRA_API_ES2, 655 EXTRA_API_ES3, 656 EXT(EXT_disjoint_timer_query), 657 EXTRA_END 658}; 659 660 661/* This is the big table describing all the enums we accept in 662 * glGet*v(). The table is partitioned into six parts: enums 663 * understood by all GL APIs (OpenGL, GLES and GLES2), enums shared 664 * between OpenGL and GLES, enums exclusive to GLES, etc for the 665 * remaining combinations. To look up the enums valid in a given API 666 * we will use a hash table specific to that API. These tables are in 667 * turn generated at build time and included through get_hash.h. 668 */ 669 670#include "get_hash.h" 671 672/* All we need now is a way to look up the value struct from the enum. 673 * The code generated by gcc for the old generated big switch 674 * statement is a big, balanced, open coded if/else tree, essentially 675 * an unrolled binary search. It would be natural to sort the new 676 * enum table and use bsearch(), but we will use a read-only hash 677 * table instead. bsearch() has a nice guaranteed worst case 678 * performance, but we're also guaranteed to hit that worst case 679 * (log2(n) iterations) for about half the enums. Instead, using an 680 * open addressing hash table, we can find the enum on the first try 681 * for 80% of the enums, 1 collision for 10% and never more than 5 682 * collisions for any enum (typical numbers). And the code is very 683 * simple, even though it feels a little magic. */ 684 685/** 686 * Handle irregular enums 687 * 688 * Some values don't conform to the "well-known type at context 689 * pointer + offset" pattern, so we have this function to catch all 690 * the corner cases. Typically, it's a computed value or a one-off 691 * pointer to a custom struct or something. 692 * 693 * In this case we can't return a pointer to the value, so we'll have 694 * to use the temporary variable 'v' declared back in the calling 695 * glGet*v() function to store the result. 696 * 697 * \param ctx the current context 698 * \param d the struct value_desc that describes the enum 699 * \param v pointer to the tmp declared in the calling glGet*v() function 700 */ 701static void 702find_custom_value(struct gl_context *ctx, const struct value_desc *d, union value *v) 703{ 704 struct gl_buffer_object **buffer_obj, *buf; 705 struct gl_array_attributes *array; 706 GLuint unit, *p; 707 708 switch (d->pname) { 709 case GL_MAJOR_VERSION: 710 v->value_int = ctx->Version / 10; 711 break; 712 case GL_MINOR_VERSION: 713 v->value_int = ctx->Version % 10; 714 break; 715 716 case GL_TEXTURE_1D: 717 case GL_TEXTURE_2D: 718 case GL_TEXTURE_3D: 719 case GL_TEXTURE_CUBE_MAP: 720 case GL_TEXTURE_RECTANGLE_NV: 721 case GL_TEXTURE_EXTERNAL_OES: 722 v->value_bool = _mesa_IsEnabled(d->pname); 723 break; 724 725 case GL_LINE_STIPPLE_PATTERN: 726 /* This is the only GLushort, special case it here by promoting 727 * to an int rather than introducing a new type. */ 728 v->value_int = ctx->Line.StipplePattern; 729 break; 730 731 case GL_CURRENT_RASTER_TEXTURE_COORDS: 732 unit = ctx->Texture.CurrentUnit; 733 v->value_float_4[0] = ctx->Current.RasterTexCoords[unit][0]; 734 v->value_float_4[1] = ctx->Current.RasterTexCoords[unit][1]; 735 v->value_float_4[2] = ctx->Current.RasterTexCoords[unit][2]; 736 v->value_float_4[3] = ctx->Current.RasterTexCoords[unit][3]; 737 break; 738 739 case GL_CURRENT_TEXTURE_COORDS: 740 unit = ctx->Texture.CurrentUnit; 741 v->value_float_4[0] = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][0]; 742 v->value_float_4[1] = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][1]; 743 v->value_float_4[2] = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][2]; 744 v->value_float_4[3] = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][3]; 745 break; 746 747 case GL_COLOR_WRITEMASK: 748 v->value_int_4[0] = GET_COLORMASK_BIT(ctx->Color.ColorMask, 0, 0); 749 v->value_int_4[1] = GET_COLORMASK_BIT(ctx->Color.ColorMask, 0, 1); 750 v->value_int_4[2] = GET_COLORMASK_BIT(ctx->Color.ColorMask, 0, 2); 751 v->value_int_4[3] = GET_COLORMASK_BIT(ctx->Color.ColorMask, 0, 3); 752 break; 753 754 case GL_DEPTH_CLAMP: 755 v->value_bool = ctx->Transform.DepthClampNear || ctx->Transform.DepthClampFar; 756 break; 757 758 case GL_EDGE_FLAG: 759 v->value_bool = ctx->Current.Attrib[VERT_ATTRIB_EDGEFLAG][0] == 1.0F; 760 break; 761 762 case GL_READ_BUFFER: 763 v->value_enum16 = ctx->ReadBuffer->ColorReadBuffer; 764 break; 765 766 case GL_MAP2_GRID_DOMAIN: 767 v->value_float_4[0] = ctx->Eval.MapGrid2u1; 768 v->value_float_4[1] = ctx->Eval.MapGrid2u2; 769 v->value_float_4[2] = ctx->Eval.MapGrid2v1; 770 v->value_float_4[3] = ctx->Eval.MapGrid2v2; 771 break; 772 773 case GL_TEXTURE_STACK_DEPTH: 774 unit = ctx->Texture.CurrentUnit; 775 v->value_int = ctx->TextureMatrixStack[unit].Depth + 1; 776 break; 777 case GL_TEXTURE_MATRIX: 778 unit = ctx->Texture.CurrentUnit; 779 v->value_matrix = ctx->TextureMatrixStack[unit].Top; 780 break; 781 782 case GL_VERTEX_ARRAY: 783 v->value_bool = !!(ctx->Array.VAO->Enabled & VERT_BIT_POS); 784 break; 785 case GL_NORMAL_ARRAY: 786 v->value_bool = !!(ctx->Array.VAO->Enabled & VERT_BIT_NORMAL); 787 break; 788 case GL_COLOR_ARRAY: 789 v->value_bool = !!(ctx->Array.VAO->Enabled & VERT_BIT_COLOR0); 790 break; 791 case GL_TEXTURE_COORD_ARRAY: 792 v->value_bool = !!(ctx->Array.VAO->Enabled & VERT_BIT_TEX(ctx->Array.ActiveTexture)); 793 break; 794 case GL_INDEX_ARRAY: 795 v->value_bool = !!(ctx->Array.VAO->Enabled & VERT_BIT_COLOR_INDEX); 796 break; 797 case GL_EDGE_FLAG_ARRAY: 798 v->value_bool = !!(ctx->Array.VAO->Enabled & VERT_BIT_EDGEFLAG); 799 break; 800 case GL_SECONDARY_COLOR_ARRAY: 801 v->value_bool = !!(ctx->Array.VAO->Enabled & VERT_BIT_COLOR1); 802 break; 803 case GL_FOG_COORDINATE_ARRAY: 804 v->value_bool = !!(ctx->Array.VAO->Enabled & VERT_BIT_FOG); 805 break; 806 case GL_POINT_SIZE_ARRAY_OES: 807 v->value_bool = !!(ctx->Array.VAO->Enabled & VERT_BIT_POINT_SIZE); 808 break; 809 810 case GL_TEXTURE_COORD_ARRAY_TYPE: 811 case GL_TEXTURE_COORD_ARRAY_STRIDE: 812 array = &ctx->Array.VAO->VertexAttrib[VERT_ATTRIB_TEX(ctx->Array.ActiveTexture)]; 813 v->value_int = *(GLuint *) ((char *) array + d->offset); 814 break; 815 816 case GL_TEXTURE_COORD_ARRAY_SIZE: 817 array = &ctx->Array.VAO->VertexAttrib[VERT_ATTRIB_TEX(ctx->Array.ActiveTexture)]; 818 v->value_int = array->Format.Size; 819 break; 820 821 case GL_VERTEX_ARRAY_SIZE: 822 array = &ctx->Array.VAO->VertexAttrib[VERT_ATTRIB_POS]; 823 v->value_int = array->Format.Size; 824 break; 825 826 case GL_ACTIVE_TEXTURE_ARB: 827 v->value_int = GL_TEXTURE0_ARB + ctx->Texture.CurrentUnit; 828 break; 829 case GL_CLIENT_ACTIVE_TEXTURE_ARB: 830 v->value_int = GL_TEXTURE0_ARB + ctx->Array.ActiveTexture; 831 break; 832 833 case GL_MODELVIEW_STACK_DEPTH: 834 case GL_PROJECTION_STACK_DEPTH: 835 v->value_int = *(GLint *) ((char *) ctx + d->offset) + 1; 836 break; 837 838 case GL_MAX_TEXTURE_SIZE: 839 case GL_MAX_3D_TEXTURE_SIZE: 840 case GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB: 841 p = (GLuint *) ((char *) ctx + d->offset); 842 v->value_int = 1 << (*p - 1); 843 break; 844 845 case GL_SCISSOR_BOX: 846 v->value_int_4[0] = ctx->Scissor.ScissorArray[0].X; 847 v->value_int_4[1] = ctx->Scissor.ScissorArray[0].Y; 848 v->value_int_4[2] = ctx->Scissor.ScissorArray[0].Width; 849 v->value_int_4[3] = ctx->Scissor.ScissorArray[0].Height; 850 break; 851 852 case GL_SCISSOR_TEST: 853 v->value_bool = ctx->Scissor.EnableFlags & 1; 854 break; 855 856 case GL_LIST_INDEX: 857 v->value_int = 858 ctx->ListState.CurrentList ? ctx->ListState.CurrentList->Name : 0; 859 break; 860 case GL_LIST_MODE: 861 if (!ctx->CompileFlag) 862 v->value_enum16 = 0; 863 else if (ctx->ExecuteFlag) 864 v->value_enum16 = GL_COMPILE_AND_EXECUTE; 865 else 866 v->value_enum16 = GL_COMPILE; 867 break; 868 869 case GL_VIEWPORT: 870 v->value_float_4[0] = ctx->ViewportArray[0].X; 871 v->value_float_4[1] = ctx->ViewportArray[0].Y; 872 v->value_float_4[2] = ctx->ViewportArray[0].Width; 873 v->value_float_4[3] = ctx->ViewportArray[0].Height; 874 break; 875 876 case GL_DEPTH_RANGE: 877 v->value_double_2[0] = ctx->ViewportArray[0].Near; 878 v->value_double_2[1] = ctx->ViewportArray[0].Far; 879 break; 880 881 case GL_ACTIVE_STENCIL_FACE_EXT: 882 v->value_enum16 = ctx->Stencil.ActiveFace ? GL_BACK : GL_FRONT; 883 break; 884 885 case GL_STENCIL_FAIL: 886 v->value_enum16 = ctx->Stencil.FailFunc[ctx->Stencil.ActiveFace]; 887 break; 888 case GL_STENCIL_FUNC: 889 v->value_enum16 = ctx->Stencil.Function[ctx->Stencil.ActiveFace]; 890 break; 891 case GL_STENCIL_PASS_DEPTH_FAIL: 892 v->value_enum16 = ctx->Stencil.ZFailFunc[ctx->Stencil.ActiveFace]; 893 break; 894 case GL_STENCIL_PASS_DEPTH_PASS: 895 v->value_enum16 = ctx->Stencil.ZPassFunc[ctx->Stencil.ActiveFace]; 896 break; 897 case GL_STENCIL_REF: 898 v->value_int = _mesa_get_stencil_ref(ctx, ctx->Stencil.ActiveFace); 899 break; 900 case GL_STENCIL_BACK_REF: 901 v->value_int = _mesa_get_stencil_ref(ctx, 1); 902 break; 903 case GL_STENCIL_VALUE_MASK: 904 v->value_int = ctx->Stencil.ValueMask[ctx->Stencil.ActiveFace]; 905 break; 906 case GL_STENCIL_WRITEMASK: 907 v->value_int = ctx->Stencil.WriteMask[ctx->Stencil.ActiveFace]; 908 break; 909 910 case GL_NUM_EXTENSIONS: 911 v->value_int = _mesa_get_extension_count(ctx); 912 break; 913 914 case GL_IMPLEMENTATION_COLOR_READ_TYPE_OES: 915 v->value_int = _mesa_get_color_read_type(ctx, NULL, "glGetIntegerv"); 916 break; 917 case GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES: 918 v->value_int = _mesa_get_color_read_format(ctx, NULL, "glGetIntegerv"); 919 break; 920 921 case GL_CURRENT_MATRIX_STACK_DEPTH_ARB: 922 v->value_int = ctx->CurrentStack->Depth + 1; 923 break; 924 case GL_CURRENT_MATRIX_ARB: 925 case GL_TRANSPOSE_CURRENT_MATRIX_ARB: 926 v->value_matrix = ctx->CurrentStack->Top; 927 break; 928 929 case GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB: 930 v->value_int = _mesa_get_compressed_formats(ctx, NULL); 931 break; 932 case GL_COMPRESSED_TEXTURE_FORMATS_ARB: 933 v->value_int_n.n = 934 _mesa_get_compressed_formats(ctx, v->value_int_n.ints); 935 assert(v->value_int_n.n <= (int) ARRAY_SIZE(v->value_int_n.ints)); 936 break; 937 938 case GL_MAX_VARYING_FLOATS_ARB: 939 v->value_int = ctx->Const.MaxVarying * 4; 940 break; 941 942 /* Various object names */ 943 944 case GL_TEXTURE_BINDING_1D: 945 case GL_TEXTURE_BINDING_2D: 946 case GL_TEXTURE_BINDING_3D: 947 case GL_TEXTURE_BINDING_1D_ARRAY_EXT: 948 case GL_TEXTURE_BINDING_2D_ARRAY_EXT: 949 case GL_TEXTURE_BINDING_CUBE_MAP_ARB: 950 case GL_TEXTURE_BINDING_RECTANGLE_NV: 951 case GL_TEXTURE_BINDING_EXTERNAL_OES: 952 case GL_TEXTURE_BINDING_CUBE_MAP_ARRAY: 953 case GL_TEXTURE_BINDING_2D_MULTISAMPLE: 954 case GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY: 955 unit = ctx->Texture.CurrentUnit; 956 v->value_int = 957 ctx->Texture.Unit[unit].CurrentTex[d->offset]->Name; 958 break; 959 960 /* GL_EXT_external_objects */ 961 case GL_NUM_DEVICE_UUIDS_EXT: 962 v->value_int = 1; 963 break; 964 case GL_DRIVER_UUID_EXT: 965 _mesa_get_driver_uuid(ctx, v->value_int_4); 966 break; 967 case GL_DEVICE_UUID_EXT: 968 _mesa_get_device_uuid(ctx, v->value_int_4); 969 break; 970 971 /* GL_EXT_packed_float */ 972 case GL_RGBA_SIGNED_COMPONENTS_EXT: 973 { 974 /* Note: we only check the 0th color attachment. */ 975 const struct gl_renderbuffer *rb = 976 ctx->DrawBuffer->_ColorDrawBuffers[0]; 977 if (rb && _mesa_is_format_signed(rb->Format)) { 978 /* Issue 17 of GL_EXT_packed_float: If a component (such as 979 * alpha) has zero bits, the component should not be considered 980 * signed and so the bit for the respective component should be 981 * zeroed. 982 */ 983 GLint r_bits = 984 _mesa_get_format_bits(rb->Format, GL_RED_BITS); 985 GLint g_bits = 986 _mesa_get_format_bits(rb->Format, GL_GREEN_BITS); 987 GLint b_bits = 988 _mesa_get_format_bits(rb->Format, GL_BLUE_BITS); 989 GLint a_bits = 990 _mesa_get_format_bits(rb->Format, GL_ALPHA_BITS); 991 GLint l_bits = 992 _mesa_get_format_bits(rb->Format, GL_TEXTURE_LUMINANCE_SIZE); 993 GLint i_bits = 994 _mesa_get_format_bits(rb->Format, GL_TEXTURE_INTENSITY_SIZE); 995 996 v->value_int_4[0] = r_bits + l_bits + i_bits > 0; 997 v->value_int_4[1] = g_bits + l_bits + i_bits > 0; 998 v->value_int_4[2] = b_bits + l_bits + i_bits > 0; 999 v->value_int_4[3] = a_bits + i_bits > 0; 1000 } 1001 else { 1002 v->value_int_4[0] = 1003 v->value_int_4[1] = 1004 v->value_int_4[2] = 1005 v->value_int_4[3] = 0; 1006 } 1007 } 1008 break; 1009 1010 /* GL_ARB_vertex_buffer_object */ 1011 case GL_VERTEX_ARRAY_BUFFER_BINDING_ARB: 1012 case GL_NORMAL_ARRAY_BUFFER_BINDING_ARB: 1013 case GL_COLOR_ARRAY_BUFFER_BINDING_ARB: 1014 case GL_INDEX_ARRAY_BUFFER_BINDING_ARB: 1015 case GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB: 1016 case GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB: 1017 case GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB: 1018 buffer_obj = (struct gl_buffer_object **) 1019 ((char *) ctx->Array.VAO + d->offset); 1020 v->value_int = (*buffer_obj) ? (*buffer_obj)->Name : 0; 1021 break; 1022 case GL_ARRAY_BUFFER_BINDING_ARB: 1023 buf = ctx->Array.ArrayBufferObj; 1024 v->value_int = buf ? buf->Name : 0; 1025 break; 1026 case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB: 1027 buf = ctx->Array.VAO->BufferBinding[VERT_ATTRIB_TEX(ctx->Array.ActiveTexture)].BufferObj; 1028 v->value_int = buf ? buf->Name : 0; 1029 break; 1030 case GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB: 1031 buf = ctx->Array.VAO->IndexBufferObj; 1032 v->value_int = buf ? buf->Name : 0; 1033 break; 1034 1035 /* ARB_vertex_array_bgra */ 1036 case GL_COLOR_ARRAY_SIZE: 1037 array = &ctx->Array.VAO->VertexAttrib[VERT_ATTRIB_COLOR0]; 1038 v->value_int = array->Format.Format == GL_BGRA ? GL_BGRA : array->Format.Size; 1039 break; 1040 case GL_SECONDARY_COLOR_ARRAY_SIZE: 1041 array = &ctx->Array.VAO->VertexAttrib[VERT_ATTRIB_COLOR1]; 1042 v->value_int = array->Format.Format == GL_BGRA ? GL_BGRA : array->Format.Size; 1043 break; 1044 1045 /* ARB_copy_buffer */ 1046 case GL_COPY_READ_BUFFER: 1047 v->value_int = ctx->CopyReadBuffer ? ctx->CopyReadBuffer->Name : 0; 1048 break; 1049 case GL_COPY_WRITE_BUFFER: 1050 v->value_int = ctx->CopyWriteBuffer ? ctx->CopyWriteBuffer->Name : 0; 1051 break; 1052 1053 case GL_PIXEL_PACK_BUFFER_BINDING_EXT: 1054 v->value_int = ctx->Pack.BufferObj ? ctx->Pack.BufferObj->Name : 0; 1055 break; 1056 case GL_PIXEL_UNPACK_BUFFER_BINDING_EXT: 1057 v->value_int = ctx->Unpack.BufferObj ? ctx->Unpack.BufferObj->Name : 0; 1058 break; 1059 case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING: 1060 v->value_int = ctx->TransformFeedback.CurrentBuffer ? 1061 ctx->TransformFeedback.CurrentBuffer->Name : 0; 1062 break; 1063 case GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED: 1064 v->value_int = ctx->TransformFeedback.CurrentObject->Paused; 1065 break; 1066 case GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE: 1067 v->value_int = ctx->TransformFeedback.CurrentObject->Active; 1068 break; 1069 case GL_TRANSFORM_FEEDBACK_BINDING: 1070 v->value_int = ctx->TransformFeedback.CurrentObject->Name; 1071 break; 1072 case GL_CURRENT_PROGRAM: 1073 /* The Changelog of the ARB_separate_shader_objects spec says: 1074 * 1075 * 24 25 Jul 2011 pbrown Remove the language erroneously deleting 1076 * CURRENT_PROGRAM. In the EXT extension, this 1077 * token was aliased to ACTIVE_PROGRAM_EXT, and 1078 * was used to indicate the last program set by 1079 * either ActiveProgramEXT or UseProgram. In 1080 * the ARB extension, the SSO active programs 1081 * are now program pipeline object state and 1082 * CURRENT_PROGRAM should still be used to query 1083 * the last program set by UseProgram (bug 7822). 1084 */ 1085 v->value_int = 1086 ctx->Shader.ActiveProgram ? ctx->Shader.ActiveProgram->Name : 0; 1087 break; 1088 case GL_READ_FRAMEBUFFER_BINDING_EXT: 1089 v->value_int = ctx->ReadBuffer->Name; 1090 break; 1091 case GL_RENDERBUFFER_BINDING_EXT: 1092 v->value_int = 1093 ctx->CurrentRenderbuffer ? ctx->CurrentRenderbuffer->Name : 0; 1094 break; 1095 case GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES: 1096 buf = ctx->Array.VAO->BufferBinding[VERT_ATTRIB_POINT_SIZE].BufferObj; 1097 v->value_int = buf ? buf->Name : 0; 1098 break; 1099 1100 case GL_FOG_COLOR: 1101 if (_mesa_get_clamp_fragment_color(ctx, ctx->DrawBuffer)) 1102 COPY_4FV(v->value_float_4, ctx->Fog.Color); 1103 else 1104 COPY_4FV(v->value_float_4, ctx->Fog.ColorUnclamped); 1105 break; 1106 case GL_COLOR_CLEAR_VALUE: 1107 if (_mesa_get_clamp_fragment_color(ctx, ctx->DrawBuffer)) { 1108 v->value_float_4[0] = CLAMP(ctx->Color.ClearColor.f[0], 0.0F, 1.0F); 1109 v->value_float_4[1] = CLAMP(ctx->Color.ClearColor.f[1], 0.0F, 1.0F); 1110 v->value_float_4[2] = CLAMP(ctx->Color.ClearColor.f[2], 0.0F, 1.0F); 1111 v->value_float_4[3] = CLAMP(ctx->Color.ClearColor.f[3], 0.0F, 1.0F); 1112 } else 1113 COPY_4FV(v->value_float_4, ctx->Color.ClearColor.f); 1114 break; 1115 case GL_BLEND_COLOR_EXT: 1116 if (_mesa_get_clamp_fragment_color(ctx, ctx->DrawBuffer)) 1117 COPY_4FV(v->value_float_4, ctx->Color.BlendColor); 1118 else 1119 COPY_4FV(v->value_float_4, ctx->Color.BlendColorUnclamped); 1120 break; 1121 case GL_ALPHA_TEST_REF: 1122 if (_mesa_get_clamp_fragment_color(ctx, ctx->DrawBuffer)) 1123 v->value_float = ctx->Color.AlphaRef; 1124 else 1125 v->value_float = ctx->Color.AlphaRefUnclamped; 1126 break; 1127 case GL_MAX_VERTEX_UNIFORM_VECTORS: 1128 v->value_int = ctx->Const.Program[MESA_SHADER_VERTEX].MaxUniformComponents / 4; 1129 break; 1130 1131 case GL_MAX_FRAGMENT_UNIFORM_VECTORS: 1132 v->value_int = ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxUniformComponents / 4; 1133 break; 1134 1135 /* GL_ARB_texture_buffer_object */ 1136 case GL_TEXTURE_BUFFER_ARB: 1137 v->value_int = ctx->Texture.BufferObject ? ctx->Texture.BufferObject->Name : 0; 1138 break; 1139 case GL_TEXTURE_BINDING_BUFFER_ARB: 1140 unit = ctx->Texture.CurrentUnit; 1141 v->value_int = 1142 ctx->Texture.Unit[unit].CurrentTex[TEXTURE_BUFFER_INDEX]->Name; 1143 break; 1144 case GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB: 1145 { 1146 struct gl_buffer_object *buf = 1147 ctx->Texture.Unit[ctx->Texture.CurrentUnit] 1148 .CurrentTex[TEXTURE_BUFFER_INDEX]->BufferObject; 1149 v->value_int = buf ? buf->Name : 0; 1150 } 1151 break; 1152 case GL_TEXTURE_BUFFER_FORMAT_ARB: 1153 v->value_int = ctx->Texture.Unit[ctx->Texture.CurrentUnit] 1154 .CurrentTex[TEXTURE_BUFFER_INDEX]->BufferObjectFormat; 1155 break; 1156 1157 /* GL_ARB_sampler_objects */ 1158 case GL_SAMPLER_BINDING: 1159 { 1160 struct gl_sampler_object *samp = 1161 ctx->Texture.Unit[ctx->Texture.CurrentUnit].Sampler; 1162 v->value_int = samp ? samp->Name : 0; 1163 } 1164 break; 1165 /* GL_ARB_uniform_buffer_object */ 1166 case GL_UNIFORM_BUFFER_BINDING: 1167 v->value_int = ctx->UniformBuffer ? ctx->UniformBuffer->Name : 0; 1168 break; 1169 /* GL_ARB_shader_storage_buffer_object */ 1170 case GL_SHADER_STORAGE_BUFFER_BINDING: 1171 v->value_int = ctx->ShaderStorageBuffer ? ctx->ShaderStorageBuffer->Name : 0; 1172 break; 1173 /* GL_ARB_query_buffer_object */ 1174 case GL_QUERY_BUFFER_BINDING: 1175 v->value_int = ctx->QueryBuffer ? ctx->QueryBuffer->Name : 0; 1176 break; 1177 /* GL_ARB_timer_query */ 1178 case GL_TIMESTAMP: 1179 if (ctx->Driver.GetTimestamp) { 1180 v->value_int64 = ctx->Driver.GetTimestamp(ctx); 1181 } 1182 else { 1183 _mesa_problem(ctx, "driver doesn't implement GetTimestamp"); 1184 } 1185 break; 1186 /* GL_KHR_DEBUG */ 1187 case GL_DEBUG_OUTPUT: 1188 case GL_DEBUG_OUTPUT_SYNCHRONOUS: 1189 case GL_DEBUG_LOGGED_MESSAGES: 1190 case GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH: 1191 case GL_DEBUG_GROUP_STACK_DEPTH: 1192 v->value_int = _mesa_get_debug_state_int(ctx, d->pname); 1193 break; 1194 /* GL_ARB_shader_atomic_counters */ 1195 case GL_ATOMIC_COUNTER_BUFFER_BINDING: 1196 v->value_int = ctx->AtomicBuffer ? ctx->AtomicBuffer->Name : 0; 1197 break; 1198 /* GL 4.3 */ 1199 case GL_NUM_SHADING_LANGUAGE_VERSIONS: 1200 v->value_int = _mesa_get_shading_language_version(ctx, -1, NULL); 1201 break; 1202 /* GL_ARB_draw_indirect */ 1203 case GL_DRAW_INDIRECT_BUFFER_BINDING: 1204 v->value_int = ctx->DrawIndirectBuffer ? ctx->DrawIndirectBuffer->Name: 0; 1205 break; 1206 /* GL_ARB_indirect_parameters */ 1207 case GL_PARAMETER_BUFFER_BINDING_ARB: 1208 v->value_int = ctx->ParameterBuffer ? ctx->ParameterBuffer->Name : 0; 1209 break; 1210 /* GL_ARB_separate_shader_objects */ 1211 case GL_PROGRAM_PIPELINE_BINDING: 1212 if (ctx->Pipeline.Current) { 1213 v->value_int = ctx->Pipeline.Current->Name; 1214 } else { 1215 v->value_int = 0; 1216 } 1217 break; 1218 /* GL_ARB_compute_shader */ 1219 case GL_DISPATCH_INDIRECT_BUFFER_BINDING: 1220 v->value_int = ctx->DispatchIndirectBuffer ? 1221 ctx->DispatchIndirectBuffer->Name : 0; 1222 break; 1223 /* GL_ARB_multisample */ 1224 case GL_SAMPLES: 1225 v->value_int = _mesa_geometric_samples(ctx->DrawBuffer); 1226 break; 1227 case GL_SAMPLE_BUFFERS: 1228 v->value_int = _mesa_geometric_samples(ctx->DrawBuffer) > 0; 1229 break; 1230 /* GL_EXT_textrue_integer */ 1231 case GL_RGBA_INTEGER_MODE_EXT: 1232 v->value_int = (ctx->DrawBuffer->_IntegerBuffers != 0); 1233 break; 1234 /* GL_ATI_meminfo & GL_NVX_gpu_memory_info */ 1235 case GL_VBO_FREE_MEMORY_ATI: 1236 case GL_TEXTURE_FREE_MEMORY_ATI: 1237 case GL_RENDERBUFFER_FREE_MEMORY_ATI: 1238 case GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX: 1239 case GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX: 1240 case GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX: 1241 case GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX: 1242 case GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX: 1243 { 1244 struct gl_memory_info info; 1245 1246 ctx->Driver.QueryMemoryInfo(ctx, &info); 1247 1248 if (d->pname == GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX) 1249 v->value_int = info.total_device_memory; 1250 else if (d->pname == GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX) 1251 v->value_int = info.total_device_memory + 1252 info.total_staging_memory; 1253 else if (d->pname == GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX) 1254 v->value_int = info.avail_device_memory; 1255 else if (d->pname == GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX) 1256 v->value_int = info.nr_device_memory_evictions; 1257 else if (d->pname == GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX) 1258 v->value_int = info.device_memory_evicted; 1259 else { 1260 /* ATI free memory enums. 1261 * 1262 * Since the GPU memory is (usually) page-table based, every two 1263 * consecutive elements are equal. From the GL_ATI_meminfo 1264 * specification: 1265 * 1266 * "param[0] - total memory free in the pool 1267 * param[1] - largest available free block in the pool 1268 * param[2] - total auxiliary memory free 1269 * param[3] - largest auxiliary free block" 1270 * 1271 * All three (VBO, TEXTURE, RENDERBUFFER) queries return 1272 * the same numbers here. 1273 */ 1274 v->value_int_4[0] = info.avail_device_memory; 1275 v->value_int_4[1] = info.avail_device_memory; 1276 v->value_int_4[2] = info.avail_staging_memory; 1277 v->value_int_4[3] = info.avail_staging_memory; 1278 } 1279 } 1280 break; 1281 1282 /* GL_ARB_get_program_binary */ 1283 case GL_PROGRAM_BINARY_FORMATS: 1284 assert(ctx->Const.NumProgramBinaryFormats <= 1); 1285 v->value_int_n.n = MIN2(ctx->Const.NumProgramBinaryFormats, 1); 1286 if (ctx->Const.NumProgramBinaryFormats > 0) { 1287 v->value_int_n.ints[0] = GL_PROGRAM_BINARY_FORMAT_MESA; 1288 } 1289 break; 1290 /* ARB_spirv_extensions */ 1291 case GL_NUM_SPIR_V_EXTENSIONS: 1292 v->value_int = _mesa_get_spirv_extension_count(ctx); 1293 break; 1294 /* GL_EXT_disjoint_timer_query */ 1295 case GL_GPU_DISJOINT_EXT: 1296 { 1297 simple_mtx_lock(&ctx->Shared->Mutex); 1298 v->value_int = ctx->Shared->DisjointOperation; 1299 /* Reset state as expected by the spec. */ 1300 ctx->Shared->DisjointOperation = false; 1301 simple_mtx_unlock(&ctx->Shared->Mutex); 1302 } 1303 break; 1304 /* GL_ARB_sample_locations */ 1305 case GL_SAMPLE_LOCATION_SUBPIXEL_BITS_ARB: 1306 case GL_SAMPLE_LOCATION_PIXEL_GRID_WIDTH_ARB: 1307 case GL_SAMPLE_LOCATION_PIXEL_GRID_HEIGHT_ARB: 1308 { 1309 GLuint bits, width, height; 1310 1311 if (ctx->NewState & _NEW_BUFFERS) 1312 _mesa_update_state(ctx); 1313 1314 if (ctx->DrawBuffer->_Status != GL_FRAMEBUFFER_COMPLETE) { 1315 v->value_uint = 0; 1316 break; 1317 } 1318 1319 ctx->Driver.GetProgrammableSampleCaps(ctx, ctx->DrawBuffer, 1320 &bits, &width, &height); 1321 1322 if (d->pname == GL_SAMPLE_LOCATION_PIXEL_GRID_WIDTH_ARB) 1323 v->value_uint = width; 1324 else if (d->pname == GL_SAMPLE_LOCATION_PIXEL_GRID_HEIGHT_ARB) 1325 v->value_uint = height; 1326 else 1327 v->value_uint = bits; 1328 } 1329 break; 1330 case GL_PROGRAMMABLE_SAMPLE_LOCATION_TABLE_SIZE_ARB: 1331 v->value_uint = MAX_SAMPLE_LOCATION_TABLE_SIZE; 1332 break; 1333 1334 /* GL_AMD_framebuffer_multisample_advanced */ 1335 case GL_SUPPORTED_MULTISAMPLE_MODES_AMD: 1336 v->value_int_n.n = ctx->Const.NumSupportedMultisampleModes * 3; 1337 memcpy(v->value_int_n.ints, ctx->Const.SupportedMultisampleModes, 1338 v->value_int_n.n * sizeof(GLint)); 1339 break; 1340 1341 /* GL_NV_viewport_swizzle */ 1342 case GL_VIEWPORT_SWIZZLE_X_NV: 1343 v->value_enum = ctx->ViewportArray[0].SwizzleX; 1344 break; 1345 case GL_VIEWPORT_SWIZZLE_Y_NV: 1346 v->value_enum = ctx->ViewportArray[0].SwizzleY; 1347 break; 1348 case GL_VIEWPORT_SWIZZLE_Z_NV: 1349 v->value_enum = ctx->ViewportArray[0].SwizzleZ; 1350 break; 1351 case GL_VIEWPORT_SWIZZLE_W_NV: 1352 v->value_enum = ctx->ViewportArray[0].SwizzleW; 1353 break; 1354 } 1355} 1356 1357/** 1358 * Check extra constraints on a struct value_desc descriptor 1359 * 1360 * If a struct value_desc has a non-NULL extra pointer, it means that 1361 * there are a number of extra constraints to check or actions to 1362 * perform. The extras is just an integer array where each integer 1363 * encode different constraints or actions. 1364 * 1365 * \param ctx current context 1366 * \param func name of calling glGet*v() function for error reporting 1367 * \param d the struct value_desc that has the extra constraints 1368 * 1369 * \return GL_FALSE if all of the constraints were not satisfied, 1370 * otherwise GL_TRUE. 1371 */ 1372static GLboolean 1373check_extra(struct gl_context *ctx, const char *func, const struct value_desc *d) 1374{ 1375 const GLuint version = ctx->Version; 1376 GLboolean api_check = GL_FALSE; 1377 GLboolean api_found = GL_FALSE; 1378 const int *e; 1379 1380 for (e = d->extra; *e != EXTRA_END; e++) { 1381 switch (*e) { 1382 case EXTRA_VERSION_30: 1383 api_check = GL_TRUE; 1384 if (version >= 30) 1385 api_found = GL_TRUE; 1386 break; 1387 case EXTRA_VERSION_31: 1388 api_check = GL_TRUE; 1389 if (version >= 31) 1390 api_found = GL_TRUE; 1391 break; 1392 case EXTRA_VERSION_32: 1393 api_check = GL_TRUE; 1394 if (version >= 32) 1395 api_found = GL_TRUE; 1396 break; 1397 case EXTRA_VERSION_40: 1398 api_check = GL_TRUE; 1399 if (version >= 40) 1400 api_found = GL_TRUE; 1401 break; 1402 case EXTRA_VERSION_43: 1403 api_check = GL_TRUE; 1404 if (_mesa_is_desktop_gl(ctx) && version >= 43) 1405 api_found = GL_TRUE; 1406 break; 1407 case EXTRA_API_ES2: 1408 api_check = GL_TRUE; 1409 if (ctx->API == API_OPENGLES2) 1410 api_found = GL_TRUE; 1411 break; 1412 case EXTRA_API_ES3: 1413 api_check = GL_TRUE; 1414 if (_mesa_is_gles3(ctx)) 1415 api_found = GL_TRUE; 1416 break; 1417 case EXTRA_API_ES31: 1418 api_check = GL_TRUE; 1419 if (_mesa_is_gles31(ctx)) 1420 api_found = GL_TRUE; 1421 break; 1422 case EXTRA_API_ES32: 1423 api_check = GL_TRUE; 1424 if (_mesa_is_gles32(ctx)) 1425 api_found = GL_TRUE; 1426 break; 1427 case EXTRA_API_GL: 1428 api_check = GL_TRUE; 1429 if (_mesa_is_desktop_gl(ctx)) 1430 api_found = GL_TRUE; 1431 break; 1432 case EXTRA_API_GL_CORE: 1433 api_check = GL_TRUE; 1434 if (ctx->API == API_OPENGL_CORE) 1435 api_found = GL_TRUE; 1436 break; 1437 case EXTRA_NEW_BUFFERS: 1438 if (ctx->NewState & _NEW_BUFFERS) 1439 _mesa_update_state(ctx); 1440 break; 1441 case EXTRA_FLUSH_CURRENT: 1442 FLUSH_CURRENT(ctx, 0); 1443 break; 1444 case EXTRA_VALID_DRAW_BUFFER: 1445 if (d->pname - GL_DRAW_BUFFER0_ARB >= ctx->Const.MaxDrawBuffers) { 1446 _mesa_error(ctx, GL_INVALID_OPERATION, "%s(draw buffer %u)", 1447 func, d->pname - GL_DRAW_BUFFER0_ARB); 1448 return GL_FALSE; 1449 } 1450 break; 1451 case EXTRA_VALID_TEXTURE_UNIT: 1452 if (ctx->Texture.CurrentUnit >= ctx->Const.MaxTextureCoordUnits) { 1453 _mesa_error(ctx, GL_INVALID_OPERATION, "%s(texture %u)", 1454 func, ctx->Texture.CurrentUnit); 1455 return GL_FALSE; 1456 } 1457 break; 1458 case EXTRA_VALID_CLIP_DISTANCE: 1459 if (d->pname - GL_CLIP_DISTANCE0 >= ctx->Const.MaxClipPlanes) { 1460 _mesa_error(ctx, GL_INVALID_ENUM, "%s(clip distance %u)", 1461 func, d->pname - GL_CLIP_DISTANCE0); 1462 return GL_FALSE; 1463 } 1464 break; 1465 case EXTRA_GLSL_130: 1466 api_check = GL_TRUE; 1467 if (ctx->Const.GLSLVersion >= 130) 1468 api_found = GL_TRUE; 1469 break; 1470 case EXTRA_EXT_UBO_GS: 1471 api_check = GL_TRUE; 1472 if (ctx->Extensions.ARB_uniform_buffer_object && 1473 _mesa_has_geometry_shaders(ctx)) 1474 api_found = GL_TRUE; 1475 break; 1476 case EXTRA_EXT_ATOMICS_GS: 1477 api_check = GL_TRUE; 1478 if (ctx->Extensions.ARB_shader_atomic_counters && 1479 _mesa_has_geometry_shaders(ctx)) 1480 api_found = GL_TRUE; 1481 break; 1482 case EXTRA_EXT_SHADER_IMAGE_GS: 1483 api_check = GL_TRUE; 1484 if (ctx->Extensions.ARB_shader_image_load_store && 1485 _mesa_has_geometry_shaders(ctx)) 1486 api_found = GL_TRUE; 1487 break; 1488 case EXTRA_EXT_ATOMICS_TESS: 1489 api_check = GL_TRUE; 1490 api_found = ctx->Extensions.ARB_shader_atomic_counters && 1491 _mesa_has_tessellation(ctx); 1492 break; 1493 case EXTRA_EXT_SHADER_IMAGE_TESS: 1494 api_check = GL_TRUE; 1495 api_found = ctx->Extensions.ARB_shader_image_load_store && 1496 _mesa_has_tessellation(ctx); 1497 break; 1498 case EXTRA_EXT_SSBO_GS: 1499 api_check = GL_TRUE; 1500 if (ctx->Extensions.ARB_shader_storage_buffer_object && 1501 _mesa_has_geometry_shaders(ctx)) 1502 api_found = GL_TRUE; 1503 break; 1504 case EXTRA_EXT_FB_NO_ATTACH_GS: 1505 api_check = GL_TRUE; 1506 if (ctx->Extensions.ARB_framebuffer_no_attachments && 1507 (_mesa_is_desktop_gl(ctx) || 1508 _mesa_has_OES_geometry_shader(ctx))) 1509 api_found = GL_TRUE; 1510 break; 1511 case EXTRA_EXT_ES_GS: 1512 api_check = GL_TRUE; 1513 if (_mesa_has_OES_geometry_shader(ctx)) 1514 api_found = GL_TRUE; 1515 break; 1516 case EXTRA_EXT_PROVOKING_VERTEX_32: 1517 api_check = GL_TRUE; 1518 if (ctx->API == API_OPENGL_COMPAT || version == 32) 1519 api_found = ctx->Extensions.EXT_provoking_vertex; 1520 break; 1521 case EXTRA_END: 1522 break; 1523 default: /* *e is a offset into the extension struct */ 1524 api_check = GL_TRUE; 1525 if (*(GLboolean *) ((char *) &ctx->Extensions + *e)) 1526 api_found = GL_TRUE; 1527 break; 1528 } 1529 } 1530 1531 if (api_check && !api_found) { 1532 _mesa_error(ctx, GL_INVALID_ENUM, "%s(pname=%s)", func, 1533 _mesa_enum_to_string(d->pname)); 1534 return GL_FALSE; 1535 } 1536 1537 return GL_TRUE; 1538} 1539 1540static const struct value_desc error_value = 1541 { 0, 0, TYPE_INVALID, NO_OFFSET, NO_EXTRA }; 1542 1543/** 1544 * Find the struct value_desc corresponding to the enum 'pname'. 1545 * 1546 * We hash the enum value to get an index into the 'table' array, 1547 * which holds the index in the 'values' array of struct value_desc. 1548 * Once we've found the entry, we do the extra checks, if any, then 1549 * look up the value and return a pointer to it. 1550 * 1551 * If the value has to be computed (for example, it's the result of a 1552 * function call or we need to add 1 to it), we use the tmp 'v' to 1553 * store the result. 1554 * 1555 * \param func name of glGet*v() func for error reporting 1556 * \param pname the enum value we're looking up 1557 * \param p is were we return the pointer to the value 1558 * \param v a tmp union value variable in the calling glGet*v() function 1559 * 1560 * \return the struct value_desc corresponding to the enum or a struct 1561 * value_desc of TYPE_INVALID if not found. This lets the calling 1562 * glGet*v() function jump right into a switch statement and 1563 * handle errors there instead of having to check for NULL. 1564 */ 1565static const struct value_desc * 1566find_value(const char *func, GLenum pname, void **p, union value *v) 1567{ 1568 GET_CURRENT_CONTEXT(ctx); 1569 int mask, hash; 1570 const struct value_desc *d; 1571 int api; 1572 1573 *p = NULL; 1574 1575 api = ctx->API; 1576 /* We index into the table_set[] list of per-API hash tables using the API's 1577 * value in the gl_api enum. Since GLES 3 doesn't have an API_OPENGL* enum 1578 * value since it's compatible with GLES2 its entry in table_set[] is at the 1579 * end. 1580 */ 1581 STATIC_ASSERT(ARRAY_SIZE(table_set) == API_OPENGL_LAST + 4); 1582 if (ctx->API == API_OPENGLES2) { 1583 if (ctx->Version >= 32) 1584 api = API_OPENGL_LAST + 3; 1585 else if (ctx->Version >= 31) 1586 api = API_OPENGL_LAST + 2; 1587 else if (ctx->Version >= 30) 1588 api = API_OPENGL_LAST + 1; 1589 } 1590 mask = ARRAY_SIZE(table(api)) - 1; 1591 hash = (pname * prime_factor); 1592 while (1) { 1593 int idx = table(api)[hash & mask]; 1594 1595 /* If the enum isn't valid, the hash walk ends with index 0, 1596 * pointing to the first entry of values[] which doesn't hold 1597 * any valid enum. */ 1598 if (unlikely(idx == 0)) { 1599 _mesa_error(ctx, GL_INVALID_ENUM, "%s(pname=%s)", func, 1600 _mesa_enum_to_string(pname)); 1601 return &error_value; 1602 } 1603 1604 d = &values[idx]; 1605 if (likely(d->pname == pname)) 1606 break; 1607 1608 hash += prime_step; 1609 } 1610 1611 if (unlikely(d->extra && !check_extra(ctx, func, d))) 1612 return &error_value; 1613 1614 switch (d->location) { 1615 case LOC_BUFFER: 1616 *p = ((char *) ctx->DrawBuffer + d->offset); 1617 return d; 1618 case LOC_CONTEXT: 1619 *p = ((char *) ctx + d->offset); 1620 return d; 1621 case LOC_ARRAY: 1622 *p = ((char *) ctx->Array.VAO + d->offset); 1623 return d; 1624 case LOC_TEXUNIT: 1625 if (ctx->Texture.CurrentUnit < ARRAY_SIZE(ctx->Texture.FixedFuncUnit)) { 1626 unsigned index = ctx->Texture.CurrentUnit; 1627 *p = ((char *)&ctx->Texture.FixedFuncUnit[index] + d->offset); 1628 return d; 1629 } 1630 _mesa_error(ctx, GL_INVALID_VALUE, "%s(pname=%s,unit=%d)", func, 1631 _mesa_enum_to_string(pname), 1632 ctx->Texture.CurrentUnit); 1633 return &error_value; 1634 case LOC_CUSTOM: 1635 find_custom_value(ctx, d, v); 1636 *p = v; 1637 return d; 1638 default: 1639 assert(0); 1640 break; 1641 } 1642 1643 /* silence warning */ 1644 return &error_value; 1645} 1646 1647static const int transpose[] = { 1648 0, 4, 8, 12, 1649 1, 5, 9, 13, 1650 2, 6, 10, 14, 1651 3, 7, 11, 15 1652}; 1653 1654static GLsizei 1655get_value_size(enum value_type type, const union value *v) 1656{ 1657 switch (type) { 1658 case TYPE_INVALID: 1659 return 0; 1660 case TYPE_CONST: 1661 case TYPE_UINT: 1662 case TYPE_INT: 1663 return sizeof(GLint); 1664 case TYPE_INT_2: 1665 case TYPE_UINT_2: 1666 return sizeof(GLint) * 2; 1667 case TYPE_INT_3: 1668 case TYPE_UINT_3: 1669 return sizeof(GLint) * 3; 1670 case TYPE_INT_4: 1671 case TYPE_UINT_4: 1672 return sizeof(GLint) * 4; 1673 case TYPE_INT_N: 1674 return sizeof(GLint) * v->value_int_n.n; 1675 case TYPE_INT64: 1676 return sizeof(GLint64); 1677 break; 1678 case TYPE_ENUM16: 1679 return sizeof(GLenum16); 1680 case TYPE_ENUM: 1681 return sizeof(GLenum); 1682 case TYPE_ENUM_2: 1683 return sizeof(GLenum) * 2; 1684 case TYPE_BOOLEAN: 1685 return sizeof(GLboolean); 1686 case TYPE_UBYTE: 1687 return sizeof(GLubyte); 1688 case TYPE_SHORT: 1689 return sizeof(GLshort); 1690 case TYPE_BIT_0: 1691 case TYPE_BIT_1: 1692 case TYPE_BIT_2: 1693 case TYPE_BIT_3: 1694 case TYPE_BIT_4: 1695 case TYPE_BIT_5: 1696 case TYPE_BIT_6: 1697 case TYPE_BIT_7: 1698 return 1; 1699 case TYPE_FLOAT: 1700 case TYPE_FLOATN: 1701 return sizeof(GLfloat); 1702 case TYPE_FLOAT_2: 1703 case TYPE_FLOATN_2: 1704 return sizeof(GLfloat) * 2; 1705 case TYPE_FLOAT_3: 1706 case TYPE_FLOATN_3: 1707 return sizeof(GLfloat) * 3; 1708 case TYPE_FLOAT_4: 1709 case TYPE_FLOATN_4: 1710 return sizeof(GLfloat) * 4; 1711 case TYPE_FLOAT_8: 1712 return sizeof(GLfloat) * 8; 1713 case TYPE_DOUBLEN: 1714 return sizeof(GLdouble); 1715 case TYPE_DOUBLEN_2: 1716 return sizeof(GLdouble) * 2; 1717 case TYPE_MATRIX: 1718 return sizeof (GLfloat) * 16; 1719 case TYPE_MATRIX_T: 1720 return sizeof (GLfloat) * 16; 1721 default: 1722 assert(!"invalid value_type given for get_value_size()"); 1723 return -1; 1724 } 1725} 1726 1727void GLAPIENTRY 1728_mesa_GetBooleanv(GLenum pname, GLboolean *params) 1729{ 1730 const struct value_desc *d; 1731 union value v; 1732 GLmatrix *m; 1733 int shift, i; 1734 void *p; 1735 1736 d = find_value("glGetBooleanv", pname, &p, &v); 1737 switch (d->type) { 1738 case TYPE_INVALID: 1739 break; 1740 case TYPE_CONST: 1741 params[0] = INT_TO_BOOLEAN(d->offset); 1742 break; 1743 1744 case TYPE_FLOAT_8: 1745 params[7] = FLOAT_TO_BOOLEAN(((GLfloat *) p)[7]); 1746 params[6] = FLOAT_TO_BOOLEAN(((GLfloat *) p)[6]); 1747 params[5] = FLOAT_TO_BOOLEAN(((GLfloat *) p)[5]); 1748 params[4] = FLOAT_TO_BOOLEAN(((GLfloat *) p)[4]); 1749 FALLTHROUGH; 1750 case TYPE_FLOAT_4: 1751 case TYPE_FLOATN_4: 1752 params[3] = FLOAT_TO_BOOLEAN(((GLfloat *) p)[3]); 1753 FALLTHROUGH; 1754 case TYPE_FLOAT_3: 1755 case TYPE_FLOATN_3: 1756 params[2] = FLOAT_TO_BOOLEAN(((GLfloat *) p)[2]); 1757 FALLTHROUGH; 1758 case TYPE_FLOAT_2: 1759 case TYPE_FLOATN_2: 1760 params[1] = FLOAT_TO_BOOLEAN(((GLfloat *) p)[1]); 1761 FALLTHROUGH; 1762 case TYPE_FLOAT: 1763 case TYPE_FLOATN: 1764 params[0] = FLOAT_TO_BOOLEAN(((GLfloat *) p)[0]); 1765 break; 1766 1767 case TYPE_DOUBLEN_2: 1768 params[1] = FLOAT_TO_BOOLEAN(((GLdouble *) p)[1]); 1769 FALLTHROUGH; 1770 case TYPE_DOUBLEN: 1771 params[0] = FLOAT_TO_BOOLEAN(((GLdouble *) p)[0]); 1772 break; 1773 1774 case TYPE_INT_4: 1775 case TYPE_UINT_4: 1776 params[3] = INT_TO_BOOLEAN(((GLint *) p)[3]); 1777 FALLTHROUGH; 1778 case TYPE_INT_3: 1779 case TYPE_UINT_3: 1780 params[2] = INT_TO_BOOLEAN(((GLint *) p)[2]); 1781 FALLTHROUGH; 1782 case TYPE_INT_2: 1783 case TYPE_UINT_2: 1784 case TYPE_ENUM_2: 1785 params[1] = INT_TO_BOOLEAN(((GLint *) p)[1]); 1786 FALLTHROUGH; 1787 case TYPE_INT: 1788 case TYPE_UINT: 1789 case TYPE_ENUM: 1790 params[0] = INT_TO_BOOLEAN(((GLint *) p)[0]); 1791 break; 1792 1793 case TYPE_ENUM16: 1794 params[0] = INT_TO_BOOLEAN(((GLenum16 *) p)[0]); 1795 break; 1796 1797 case TYPE_INT_N: 1798 for (i = 0; i < v.value_int_n.n; i++) 1799 params[i] = INT_TO_BOOLEAN(v.value_int_n.ints[i]); 1800 break; 1801 1802 case TYPE_INT64: 1803 params[0] = INT64_TO_BOOLEAN(((GLint64 *) p)[0]); 1804 break; 1805 1806 case TYPE_BOOLEAN: 1807 params[0] = ((GLboolean*) p)[0]; 1808 break; 1809 1810 case TYPE_UBYTE: 1811 params[0] = INT_TO_BOOLEAN(((GLubyte *) p)[0]); 1812 break; 1813 1814 case TYPE_SHORT: 1815 params[0] = INT_TO_BOOLEAN(((GLshort *) p)[0]); 1816 break; 1817 1818 case TYPE_MATRIX: 1819 m = *(GLmatrix **) p; 1820 for (i = 0; i < 16; i++) 1821 params[i] = FLOAT_TO_BOOLEAN(m->m[i]); 1822 break; 1823 1824 case TYPE_MATRIX_T: 1825 m = *(GLmatrix **) p; 1826 for (i = 0; i < 16; i++) 1827 params[i] = FLOAT_TO_BOOLEAN(m->m[transpose[i]]); 1828 break; 1829 1830 case TYPE_BIT_0: 1831 case TYPE_BIT_1: 1832 case TYPE_BIT_2: 1833 case TYPE_BIT_3: 1834 case TYPE_BIT_4: 1835 case TYPE_BIT_5: 1836 case TYPE_BIT_6: 1837 case TYPE_BIT_7: 1838 shift = d->type - TYPE_BIT_0; 1839 params[0] = (*(GLbitfield *) p >> shift) & 1; 1840 break; 1841 } 1842} 1843 1844void GLAPIENTRY 1845_mesa_GetFloatv(GLenum pname, GLfloat *params) 1846{ 1847 const struct value_desc *d; 1848 union value v; 1849 GLmatrix *m; 1850 int shift, i; 1851 void *p; 1852 1853 d = find_value("glGetFloatv", pname, &p, &v); 1854 switch (d->type) { 1855 case TYPE_INVALID: 1856 break; 1857 case TYPE_CONST: 1858 params[0] = (GLfloat) d->offset; 1859 break; 1860 1861 case TYPE_FLOAT_8: 1862 params[7] = ((GLfloat *) p)[7]; 1863 params[6] = ((GLfloat *) p)[6]; 1864 params[5] = ((GLfloat *) p)[5]; 1865 params[4] = ((GLfloat *) p)[4]; 1866 FALLTHROUGH; 1867 case TYPE_FLOAT_4: 1868 case TYPE_FLOATN_4: 1869 params[3] = ((GLfloat *) p)[3]; 1870 FALLTHROUGH; 1871 case TYPE_FLOAT_3: 1872 case TYPE_FLOATN_3: 1873 params[2] = ((GLfloat *) p)[2]; 1874 FALLTHROUGH; 1875 case TYPE_FLOAT_2: 1876 case TYPE_FLOATN_2: 1877 params[1] = ((GLfloat *) p)[1]; 1878 FALLTHROUGH; 1879 case TYPE_FLOAT: 1880 case TYPE_FLOATN: 1881 params[0] = ((GLfloat *) p)[0]; 1882 break; 1883 1884 case TYPE_DOUBLEN_2: 1885 params[1] = (GLfloat) (((GLdouble *) p)[1]); 1886 FALLTHROUGH; 1887 case TYPE_DOUBLEN: 1888 params[0] = (GLfloat) (((GLdouble *) p)[0]); 1889 break; 1890 1891 case TYPE_INT_4: 1892 params[3] = (GLfloat) (((GLint *) p)[3]); 1893 FALLTHROUGH; 1894 case TYPE_INT_3: 1895 params[2] = (GLfloat) (((GLint *) p)[2]); 1896 FALLTHROUGH; 1897 case TYPE_INT_2: 1898 case TYPE_ENUM_2: 1899 params[1] = (GLfloat) (((GLint *) p)[1]); 1900 FALLTHROUGH; 1901 case TYPE_INT: 1902 case TYPE_ENUM: 1903 params[0] = (GLfloat) (((GLint *) p)[0]); 1904 break; 1905 1906 case TYPE_ENUM16: 1907 params[0] = (GLfloat) (((GLenum16 *) p)[0]); 1908 break; 1909 1910 case TYPE_INT_N: 1911 for (i = 0; i < v.value_int_n.n; i++) 1912 params[i] = (GLfloat) v.value_int_n.ints[i]; 1913 break; 1914 1915 case TYPE_UINT_4: 1916 params[3] = (GLfloat) (((GLuint *) p)[3]); 1917 FALLTHROUGH; 1918 case TYPE_UINT_3: 1919 params[2] = (GLfloat) (((GLuint *) p)[2]); 1920 FALLTHROUGH; 1921 case TYPE_UINT_2: 1922 params[1] = (GLfloat) (((GLuint *) p)[1]); 1923 FALLTHROUGH; 1924 case TYPE_UINT: 1925 params[0] = (GLfloat) (((GLuint *) p)[0]); 1926 break; 1927 1928 case TYPE_INT64: 1929 params[0] = (GLfloat) (((GLint64 *) p)[0]); 1930 break; 1931 1932 case TYPE_BOOLEAN: 1933 params[0] = BOOLEAN_TO_FLOAT(*(GLboolean*) p); 1934 break; 1935 1936 case TYPE_UBYTE: 1937 params[0] = (GLfloat) ((GLubyte *) p)[0]; 1938 break; 1939 1940 case TYPE_SHORT: 1941 params[0] = (GLfloat) ((GLshort *) p)[0]; 1942 break; 1943 1944 case TYPE_MATRIX: 1945 m = *(GLmatrix **) p; 1946 for (i = 0; i < 16; i++) 1947 params[i] = m->m[i]; 1948 break; 1949 1950 case TYPE_MATRIX_T: 1951 m = *(GLmatrix **) p; 1952 for (i = 0; i < 16; i++) 1953 params[i] = m->m[transpose[i]]; 1954 break; 1955 1956 case TYPE_BIT_0: 1957 case TYPE_BIT_1: 1958 case TYPE_BIT_2: 1959 case TYPE_BIT_3: 1960 case TYPE_BIT_4: 1961 case TYPE_BIT_5: 1962 case TYPE_BIT_6: 1963 case TYPE_BIT_7: 1964 shift = d->type - TYPE_BIT_0; 1965 params[0] = BOOLEAN_TO_FLOAT((*(GLbitfield *) p >> shift) & 1); 1966 break; 1967 } 1968} 1969 1970void GLAPIENTRY 1971_mesa_GetIntegerv(GLenum pname, GLint *params) 1972{ 1973 const struct value_desc *d; 1974 union value v; 1975 GLmatrix *m; 1976 int shift, i; 1977 void *p; 1978 1979 d = find_value("glGetIntegerv", pname, &p, &v); 1980 switch (d->type) { 1981 case TYPE_INVALID: 1982 break; 1983 case TYPE_CONST: 1984 params[0] = d->offset; 1985 break; 1986 1987 case TYPE_FLOAT_8: 1988 params[7] = lroundf(((GLfloat *) p)[7]); 1989 params[6] = lroundf(((GLfloat *) p)[6]); 1990 params[5] = lroundf(((GLfloat *) p)[5]); 1991 params[4] = lroundf(((GLfloat *) p)[4]); 1992 FALLTHROUGH; 1993 case TYPE_FLOAT_4: 1994 params[3] = lroundf(((GLfloat *) p)[3]); 1995 FALLTHROUGH; 1996 case TYPE_FLOAT_3: 1997 params[2] = lroundf(((GLfloat *) p)[2]); 1998 FALLTHROUGH; 1999 case TYPE_FLOAT_2: 2000 params[1] = lroundf(((GLfloat *) p)[1]); 2001 FALLTHROUGH; 2002 case TYPE_FLOAT: 2003 params[0] = lroundf(((GLfloat *) p)[0]); 2004 break; 2005 2006 case TYPE_FLOATN_4: 2007 params[3] = FLOAT_TO_INT(((GLfloat *) p)[3]); 2008 FALLTHROUGH; 2009 case TYPE_FLOATN_3: 2010 params[2] = FLOAT_TO_INT(((GLfloat *) p)[2]); 2011 FALLTHROUGH; 2012 case TYPE_FLOATN_2: 2013 params[1] = FLOAT_TO_INT(((GLfloat *) p)[1]); 2014 FALLTHROUGH; 2015 case TYPE_FLOATN: 2016 params[0] = FLOAT_TO_INT(((GLfloat *) p)[0]); 2017 break; 2018 2019 case TYPE_DOUBLEN_2: 2020 params[1] = FLOAT_TO_INT(((GLdouble *) p)[1]); 2021 FALLTHROUGH; 2022 case TYPE_DOUBLEN: 2023 params[0] = FLOAT_TO_INT(((GLdouble *) p)[0]); 2024 break; 2025 2026 case TYPE_INT_4: 2027 case TYPE_UINT_4: 2028 params[3] = ((GLint *) p)[3]; 2029 FALLTHROUGH; 2030 case TYPE_INT_3: 2031 case TYPE_UINT_3: 2032 params[2] = ((GLint *) p)[2]; 2033 FALLTHROUGH; 2034 case TYPE_INT_2: 2035 case TYPE_UINT_2: 2036 case TYPE_ENUM_2: 2037 params[1] = ((GLint *) p)[1]; 2038 FALLTHROUGH; 2039 case TYPE_INT: 2040 case TYPE_UINT: 2041 case TYPE_ENUM: 2042 params[0] = ((GLint *) p)[0]; 2043 break; 2044 2045 case TYPE_ENUM16: 2046 params[0] = ((GLenum16 *) p)[0]; 2047 break; 2048 2049 case TYPE_INT_N: 2050 for (i = 0; i < v.value_int_n.n; i++) 2051 params[i] = v.value_int_n.ints[i]; 2052 break; 2053 2054 case TYPE_INT64: 2055 params[0] = INT64_TO_INT(((GLint64 *) p)[0]); 2056 break; 2057 2058 case TYPE_BOOLEAN: 2059 params[0] = BOOLEAN_TO_INT(*(GLboolean*) p); 2060 break; 2061 2062 case TYPE_UBYTE: 2063 params[0] = ((GLubyte *) p)[0]; 2064 break; 2065 2066 case TYPE_SHORT: 2067 params[0] = ((GLshort *) p)[0]; 2068 break; 2069 2070 case TYPE_MATRIX: 2071 m = *(GLmatrix **) p; 2072 for (i = 0; i < 16; i++) 2073 params[i] = FLOAT_TO_INT(m->m[i]); 2074 break; 2075 2076 case TYPE_MATRIX_T: 2077 m = *(GLmatrix **) p; 2078 for (i = 0; i < 16; i++) 2079 params[i] = FLOAT_TO_INT(m->m[transpose[i]]); 2080 break; 2081 2082 case TYPE_BIT_0: 2083 case TYPE_BIT_1: 2084 case TYPE_BIT_2: 2085 case TYPE_BIT_3: 2086 case TYPE_BIT_4: 2087 case TYPE_BIT_5: 2088 case TYPE_BIT_6: 2089 case TYPE_BIT_7: 2090 shift = d->type - TYPE_BIT_0; 2091 params[0] = (*(GLbitfield *) p >> shift) & 1; 2092 break; 2093 } 2094} 2095 2096void GLAPIENTRY 2097_mesa_GetInteger64v(GLenum pname, GLint64 *params) 2098{ 2099 const struct value_desc *d; 2100 union value v; 2101 GLmatrix *m; 2102 int shift, i; 2103 void *p; 2104 2105 d = find_value("glGetInteger64v", pname, &p, &v); 2106 switch (d->type) { 2107 case TYPE_INVALID: 2108 break; 2109 case TYPE_CONST: 2110 params[0] = d->offset; 2111 break; 2112 2113 case TYPE_FLOAT_8: 2114 params[7] = llround(((GLfloat *) p)[7]); 2115 params[6] = llround(((GLfloat *) p)[6]); 2116 params[5] = llround(((GLfloat *) p)[5]); 2117 params[4] = llround(((GLfloat *) p)[4]); 2118 FALLTHROUGH; 2119 case TYPE_FLOAT_4: 2120 params[3] = llround(((GLfloat *) p)[3]); 2121 FALLTHROUGH; 2122 case TYPE_FLOAT_3: 2123 params[2] = llround(((GLfloat *) p)[2]); 2124 FALLTHROUGH; 2125 case TYPE_FLOAT_2: 2126 params[1] = llround(((GLfloat *) p)[1]); 2127 FALLTHROUGH; 2128 case TYPE_FLOAT: 2129 params[0] = llround(((GLfloat *) p)[0]); 2130 break; 2131 2132 case TYPE_FLOATN_4: 2133 params[3] = FLOAT_TO_INT(((GLfloat *) p)[3]); 2134 FALLTHROUGH; 2135 case TYPE_FLOATN_3: 2136 params[2] = FLOAT_TO_INT(((GLfloat *) p)[2]); 2137 FALLTHROUGH; 2138 case TYPE_FLOATN_2: 2139 params[1] = FLOAT_TO_INT(((GLfloat *) p)[1]); 2140 FALLTHROUGH; 2141 case TYPE_FLOATN: 2142 params[0] = FLOAT_TO_INT(((GLfloat *) p)[0]); 2143 break; 2144 2145 case TYPE_DOUBLEN_2: 2146 params[1] = FLOAT_TO_INT(((GLdouble *) p)[1]); 2147 FALLTHROUGH; 2148 case TYPE_DOUBLEN: 2149 params[0] = FLOAT_TO_INT(((GLdouble *) p)[0]); 2150 break; 2151 2152 case TYPE_INT_4: 2153 params[3] = ((GLint *) p)[3]; 2154 FALLTHROUGH; 2155 case TYPE_INT_3: 2156 params[2] = ((GLint *) p)[2]; 2157 FALLTHROUGH; 2158 case TYPE_INT_2: 2159 case TYPE_ENUM_2: 2160 params[1] = ((GLint *) p)[1]; 2161 FALLTHROUGH; 2162 case TYPE_INT: 2163 case TYPE_ENUM: 2164 params[0] = ((GLint *) p)[0]; 2165 break; 2166 2167 case TYPE_ENUM16: 2168 params[0] = ((GLenum16 *) p)[0]; 2169 break; 2170 2171 case TYPE_INT_N: 2172 for (i = 0; i < v.value_int_n.n; i++) 2173 params[i] = v.value_int_n.ints[i]; 2174 break; 2175 2176 case TYPE_UINT_4: 2177 params[3] = ((GLuint *) p)[3]; 2178 FALLTHROUGH; 2179 case TYPE_UINT_3: 2180 params[2] = ((GLuint *) p)[2]; 2181 FALLTHROUGH; 2182 case TYPE_UINT_2: 2183 params[1] = ((GLuint *) p)[1]; 2184 FALLTHROUGH; 2185 case TYPE_UINT: 2186 params[0] = ((GLuint *) p)[0]; 2187 break; 2188 2189 case TYPE_INT64: 2190 params[0] = ((GLint64 *) p)[0]; 2191 break; 2192 2193 case TYPE_BOOLEAN: 2194 params[0] = ((GLboolean*) p)[0]; 2195 break; 2196 2197 case TYPE_MATRIX: 2198 m = *(GLmatrix **) p; 2199 for (i = 0; i < 16; i++) 2200 params[i] = FLOAT_TO_INT64(m->m[i]); 2201 break; 2202 2203 case TYPE_MATRIX_T: 2204 m = *(GLmatrix **) p; 2205 for (i = 0; i < 16; i++) 2206 params[i] = FLOAT_TO_INT64(m->m[transpose[i]]); 2207 break; 2208 2209 case TYPE_BIT_0: 2210 case TYPE_BIT_1: 2211 case TYPE_BIT_2: 2212 case TYPE_BIT_3: 2213 case TYPE_BIT_4: 2214 case TYPE_BIT_5: 2215 case TYPE_BIT_6: 2216 case TYPE_BIT_7: 2217 shift = d->type - TYPE_BIT_0; 2218 params[0] = (*(GLbitfield *) p >> shift) & 1; 2219 break; 2220 } 2221} 2222 2223void GLAPIENTRY 2224_mesa_GetDoublev(GLenum pname, GLdouble *params) 2225{ 2226 const struct value_desc *d; 2227 union value v; 2228 GLmatrix *m; 2229 int shift, i; 2230 void *p; 2231 2232 d = find_value("glGetDoublev", pname, &p, &v); 2233 switch (d->type) { 2234 case TYPE_INVALID: 2235 break; 2236 case TYPE_CONST: 2237 params[0] = d->offset; 2238 break; 2239 2240 case TYPE_FLOAT_8: 2241 params[7] = ((GLfloat *) p)[7]; 2242 params[6] = ((GLfloat *) p)[6]; 2243 params[5] = ((GLfloat *) p)[5]; 2244 params[4] = ((GLfloat *) p)[4]; 2245 FALLTHROUGH; 2246 case TYPE_FLOAT_4: 2247 case TYPE_FLOATN_4: 2248 params[3] = ((GLfloat *) p)[3]; 2249 FALLTHROUGH; 2250 case TYPE_FLOAT_3: 2251 case TYPE_FLOATN_3: 2252 params[2] = ((GLfloat *) p)[2]; 2253 FALLTHROUGH; 2254 case TYPE_FLOAT_2: 2255 case TYPE_FLOATN_2: 2256 params[1] = ((GLfloat *) p)[1]; 2257 FALLTHROUGH; 2258 case TYPE_FLOAT: 2259 case TYPE_FLOATN: 2260 params[0] = ((GLfloat *) p)[0]; 2261 break; 2262 2263 case TYPE_DOUBLEN_2: 2264 params[1] = ((GLdouble *) p)[1]; 2265 FALLTHROUGH; 2266 case TYPE_DOUBLEN: 2267 params[0] = ((GLdouble *) p)[0]; 2268 break; 2269 2270 case TYPE_INT_4: 2271 params[3] = ((GLint *) p)[3]; 2272 FALLTHROUGH; 2273 case TYPE_INT_3: 2274 params[2] = ((GLint *) p)[2]; 2275 FALLTHROUGH; 2276 case TYPE_INT_2: 2277 case TYPE_ENUM_2: 2278 params[1] = ((GLint *) p)[1]; 2279 FALLTHROUGH; 2280 case TYPE_INT: 2281 case TYPE_ENUM: 2282 params[0] = ((GLint *) p)[0]; 2283 break; 2284 2285 case TYPE_ENUM16: 2286 params[0] = ((GLenum16 *) p)[0]; 2287 break; 2288 2289 case TYPE_INT_N: 2290 for (i = 0; i < v.value_int_n.n; i++) 2291 params[i] = v.value_int_n.ints[i]; 2292 break; 2293 2294 case TYPE_UINT_4: 2295 params[3] = ((GLuint *) p)[3]; 2296 FALLTHROUGH; 2297 case TYPE_UINT_3: 2298 params[2] = ((GLuint *) p)[2]; 2299 FALLTHROUGH; 2300 case TYPE_UINT_2: 2301 params[1] = ((GLuint *) p)[1]; 2302 FALLTHROUGH; 2303 case TYPE_UINT: 2304 params[0] = ((GLuint *) p)[0]; 2305 break; 2306 2307 case TYPE_INT64: 2308 params[0] = (GLdouble) (((GLint64 *) p)[0]); 2309 break; 2310 2311 case TYPE_BOOLEAN: 2312 params[0] = *(GLboolean*) p; 2313 break; 2314 2315 case TYPE_UBYTE: 2316 params[0] = ((GLubyte *) p)[0]; 2317 break; 2318 2319 case TYPE_SHORT: 2320 params[0] = ((GLshort *) p)[0]; 2321 break; 2322 2323 case TYPE_MATRIX: 2324 m = *(GLmatrix **) p; 2325 for (i = 0; i < 16; i++) 2326 params[i] = m->m[i]; 2327 break; 2328 2329 case TYPE_MATRIX_T: 2330 m = *(GLmatrix **) p; 2331 for (i = 0; i < 16; i++) 2332 params[i] = m->m[transpose[i]]; 2333 break; 2334 2335 case TYPE_BIT_0: 2336 case TYPE_BIT_1: 2337 case TYPE_BIT_2: 2338 case TYPE_BIT_3: 2339 case TYPE_BIT_4: 2340 case TYPE_BIT_5: 2341 case TYPE_BIT_6: 2342 case TYPE_BIT_7: 2343 shift = d->type - TYPE_BIT_0; 2344 params[0] = (*(GLbitfield *) p >> shift) & 1; 2345 break; 2346 } 2347} 2348 2349void GLAPIENTRY 2350_mesa_GetUnsignedBytevEXT(GLenum pname, GLubyte *data) 2351{ 2352 const struct value_desc *d; 2353 union value v; 2354 int shift; 2355 void *p = NULL; 2356 GLsizei size; 2357 const char *func = "glGetUnsignedBytevEXT"; 2358 2359 GET_CURRENT_CONTEXT(ctx); 2360 2361 if (!ctx->Extensions.EXT_memory_object) { 2362 _mesa_error(ctx, GL_INVALID_OPERATION, "%s(unsupported)", func); 2363 return; 2364 } 2365 2366 d = find_value(func, pname, &p, &v); 2367 size = get_value_size(d->type, &v); 2368 2369 switch (d->type) { 2370 case TYPE_BIT_0: 2371 case TYPE_BIT_1: 2372 case TYPE_BIT_2: 2373 case TYPE_BIT_3: 2374 case TYPE_BIT_4: 2375 case TYPE_BIT_5: 2376 case TYPE_BIT_6: 2377 case TYPE_BIT_7: 2378 shift = d->type - TYPE_BIT_0; 2379 data[0] = (*(GLbitfield *) p >> shift) & 1; 2380 break; 2381 case TYPE_CONST: 2382 memcpy(data, &d->offset, size); 2383 break; 2384 case TYPE_INT_N: 2385 memcpy(data, &v.value_int_n.ints, size); 2386 break; 2387 case TYPE_UINT: 2388 case TYPE_INT: 2389 case TYPE_INT_2: 2390 case TYPE_UINT_2: 2391 case TYPE_INT_3: 2392 case TYPE_UINT_3: 2393 case TYPE_INT_4: 2394 case TYPE_UINT_4: 2395 case TYPE_INT64: 2396 case TYPE_ENUM: 2397 case TYPE_ENUM_2: 2398 case TYPE_BOOLEAN: 2399 case TYPE_UBYTE: 2400 case TYPE_SHORT: 2401 case TYPE_FLOAT: 2402 case TYPE_FLOATN: 2403 case TYPE_FLOAT_2: 2404 case TYPE_FLOATN_2: 2405 case TYPE_FLOAT_3: 2406 case TYPE_FLOATN_3: 2407 case TYPE_FLOAT_4: 2408 case TYPE_FLOATN_4: 2409 case TYPE_FLOAT_8: 2410 case TYPE_DOUBLEN: 2411 case TYPE_DOUBLEN_2: 2412 case TYPE_MATRIX: 2413 case TYPE_MATRIX_T: 2414 memcpy(data, p, size); 2415 break; 2416 case TYPE_ENUM16: { 2417 GLenum e = *(GLenum16 *)p; 2418 memcpy(data, &e, sizeof(e)); 2419 break; 2420 } 2421 default: 2422 break; /* nothing - GL error was recorded */ 2423 } 2424} 2425 2426/** 2427 * Convert a GL texture binding enum such as GL_TEXTURE_BINDING_2D 2428 * into the corresponding Mesa texture target index. 2429 * \return TEXTURE_x_INDEX or -1 if binding is invalid 2430 */ 2431static int 2432tex_binding_to_index(const struct gl_context *ctx, GLenum binding) 2433{ 2434 switch (binding) { 2435 case GL_TEXTURE_BINDING_1D: 2436 return _mesa_is_desktop_gl(ctx) ? TEXTURE_1D_INDEX : -1; 2437 case GL_TEXTURE_BINDING_2D: 2438 return TEXTURE_2D_INDEX; 2439 case GL_TEXTURE_BINDING_3D: 2440 return ctx->API != API_OPENGLES ? TEXTURE_3D_INDEX : -1; 2441 case GL_TEXTURE_BINDING_CUBE_MAP: 2442 return ctx->Extensions.ARB_texture_cube_map 2443 ? TEXTURE_CUBE_INDEX : -1; 2444 case GL_TEXTURE_BINDING_RECTANGLE: 2445 return _mesa_is_desktop_gl(ctx) && ctx->Extensions.NV_texture_rectangle 2446 ? TEXTURE_RECT_INDEX : -1; 2447 case GL_TEXTURE_BINDING_1D_ARRAY: 2448 return _mesa_is_desktop_gl(ctx) && ctx->Extensions.EXT_texture_array 2449 ? TEXTURE_1D_ARRAY_INDEX : -1; 2450 case GL_TEXTURE_BINDING_2D_ARRAY: 2451 return (_mesa_is_desktop_gl(ctx) && ctx->Extensions.EXT_texture_array) 2452 || _mesa_is_gles3(ctx) 2453 ? TEXTURE_2D_ARRAY_INDEX : -1; 2454 case GL_TEXTURE_BINDING_BUFFER: 2455 return (_mesa_has_ARB_texture_buffer_object(ctx) || 2456 _mesa_has_OES_texture_buffer(ctx)) ? 2457 TEXTURE_BUFFER_INDEX : -1; 2458 case GL_TEXTURE_BINDING_CUBE_MAP_ARRAY: 2459 return _mesa_has_texture_cube_map_array(ctx) 2460 ? TEXTURE_CUBE_ARRAY_INDEX : -1; 2461 case GL_TEXTURE_BINDING_2D_MULTISAMPLE: 2462 return _mesa_is_desktop_gl(ctx) && ctx->Extensions.ARB_texture_multisample 2463 ? TEXTURE_2D_MULTISAMPLE_INDEX : -1; 2464 case GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY: 2465 return _mesa_is_desktop_gl(ctx) && ctx->Extensions.ARB_texture_multisample 2466 ? TEXTURE_2D_MULTISAMPLE_ARRAY_INDEX : -1; 2467 default: 2468 return -1; 2469 } 2470} 2471 2472static enum value_type 2473find_value_indexed(const char *func, GLenum pname, GLuint index, union value *v) 2474{ 2475 GET_CURRENT_CONTEXT(ctx); 2476 struct gl_buffer_object *buf; 2477 2478 switch (pname) { 2479 2480 case GL_BLEND: 2481 if (index >= ctx->Const.MaxDrawBuffers) 2482 goto invalid_value; 2483 if (!ctx->Extensions.EXT_draw_buffers2) 2484 goto invalid_enum; 2485 v->value_int = (ctx->Color.BlendEnabled >> index) & 1; 2486 return TYPE_INT; 2487 2488 case GL_BLEND_SRC: 2489 FALLTHROUGH; 2490 case GL_BLEND_SRC_RGB: 2491 if (index >= ctx->Const.MaxDrawBuffers) 2492 goto invalid_value; 2493 if (!ctx->Extensions.ARB_draw_buffers_blend) 2494 goto invalid_enum; 2495 v->value_int = ctx->Color.Blend[index].SrcRGB; 2496 return TYPE_INT; 2497 case GL_BLEND_SRC_ALPHA: 2498 if (index >= ctx->Const.MaxDrawBuffers) 2499 goto invalid_value; 2500 if (!ctx->Extensions.ARB_draw_buffers_blend) 2501 goto invalid_enum; 2502 v->value_int = ctx->Color.Blend[index].SrcA; 2503 return TYPE_INT; 2504 case GL_BLEND_DST: 2505 FALLTHROUGH; 2506 case GL_BLEND_DST_RGB: 2507 if (index >= ctx->Const.MaxDrawBuffers) 2508 goto invalid_value; 2509 if (!ctx->Extensions.ARB_draw_buffers_blend) 2510 goto invalid_enum; 2511 v->value_int = ctx->Color.Blend[index].DstRGB; 2512 return TYPE_INT; 2513 case GL_BLEND_DST_ALPHA: 2514 if (index >= ctx->Const.MaxDrawBuffers) 2515 goto invalid_value; 2516 if (!ctx->Extensions.ARB_draw_buffers_blend) 2517 goto invalid_enum; 2518 v->value_int = ctx->Color.Blend[index].DstA; 2519 return TYPE_INT; 2520 case GL_BLEND_EQUATION_RGB: 2521 if (index >= ctx->Const.MaxDrawBuffers) 2522 goto invalid_value; 2523 if (!ctx->Extensions.ARB_draw_buffers_blend) 2524 goto invalid_enum; 2525 v->value_int = ctx->Color.Blend[index].EquationRGB; 2526 return TYPE_INT; 2527 case GL_BLEND_EQUATION_ALPHA: 2528 if (index >= ctx->Const.MaxDrawBuffers) 2529 goto invalid_value; 2530 if (!ctx->Extensions.ARB_draw_buffers_blend) 2531 goto invalid_enum; 2532 v->value_int = ctx->Color.Blend[index].EquationA; 2533 return TYPE_INT; 2534 2535 case GL_COLOR_WRITEMASK: 2536 if (index >= ctx->Const.MaxDrawBuffers) 2537 goto invalid_value; 2538 if (!ctx->Extensions.EXT_draw_buffers2) 2539 goto invalid_enum; 2540 v->value_int_4[0] = GET_COLORMASK_BIT(ctx->Color.ColorMask, index, 0); 2541 v->value_int_4[1] = GET_COLORMASK_BIT(ctx->Color.ColorMask, index, 1); 2542 v->value_int_4[2] = GET_COLORMASK_BIT(ctx->Color.ColorMask, index, 2); 2543 v->value_int_4[3] = GET_COLORMASK_BIT(ctx->Color.ColorMask, index, 3); 2544 return TYPE_INT_4; 2545 2546 case GL_SCISSOR_BOX: 2547 if (index >= ctx->Const.MaxViewports) 2548 goto invalid_value; 2549 v->value_int_4[0] = ctx->Scissor.ScissorArray[index].X; 2550 v->value_int_4[1] = ctx->Scissor.ScissorArray[index].Y; 2551 v->value_int_4[2] = ctx->Scissor.ScissorArray[index].Width; 2552 v->value_int_4[3] = ctx->Scissor.ScissorArray[index].Height; 2553 return TYPE_INT_4; 2554 2555 case GL_WINDOW_RECTANGLE_EXT: 2556 if (!ctx->Extensions.EXT_window_rectangles) 2557 goto invalid_enum; 2558 if (index >= ctx->Const.MaxWindowRectangles) 2559 goto invalid_value; 2560 v->value_int_4[0] = ctx->Scissor.WindowRects[index].X; 2561 v->value_int_4[1] = ctx->Scissor.WindowRects[index].Y; 2562 v->value_int_4[2] = ctx->Scissor.WindowRects[index].Width; 2563 v->value_int_4[3] = ctx->Scissor.WindowRects[index].Height; 2564 return TYPE_INT_4; 2565 2566 case GL_VIEWPORT: 2567 if (index >= ctx->Const.MaxViewports) 2568 goto invalid_value; 2569 v->value_float_4[0] = ctx->ViewportArray[index].X; 2570 v->value_float_4[1] = ctx->ViewportArray[index].Y; 2571 v->value_float_4[2] = ctx->ViewportArray[index].Width; 2572 v->value_float_4[3] = ctx->ViewportArray[index].Height; 2573 return TYPE_FLOAT_4; 2574 2575 case GL_DEPTH_RANGE: 2576 if (index >= ctx->Const.MaxViewports) 2577 goto invalid_value; 2578 v->value_double_2[0] = ctx->ViewportArray[index].Near; 2579 v->value_double_2[1] = ctx->ViewportArray[index].Far; 2580 return TYPE_DOUBLEN_2; 2581 2582 case GL_TRANSFORM_FEEDBACK_BUFFER_START: 2583 if (index >= ctx->Const.MaxTransformFeedbackBuffers) 2584 goto invalid_value; 2585 if (!ctx->Extensions.EXT_transform_feedback) 2586 goto invalid_enum; 2587 v->value_int64 = ctx->TransformFeedback.CurrentObject->Offset[index]; 2588 return TYPE_INT64; 2589 2590 case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE: 2591 if (index >= ctx->Const.MaxTransformFeedbackBuffers) 2592 goto invalid_value; 2593 if (!ctx->Extensions.EXT_transform_feedback) 2594 goto invalid_enum; 2595 v->value_int64 2596 = ctx->TransformFeedback.CurrentObject->RequestedSize[index]; 2597 return TYPE_INT64; 2598 2599 case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING: 2600 if (index >= ctx->Const.MaxTransformFeedbackBuffers) 2601 goto invalid_value; 2602 if (!ctx->Extensions.EXT_transform_feedback) 2603 goto invalid_enum; 2604 v->value_int = ctx->TransformFeedback.CurrentObject->BufferNames[index]; 2605 return TYPE_INT; 2606 2607 case GL_UNIFORM_BUFFER_BINDING: 2608 if (index >= ctx->Const.MaxUniformBufferBindings) 2609 goto invalid_value; 2610 if (!ctx->Extensions.ARB_uniform_buffer_object) 2611 goto invalid_enum; 2612 buf = ctx->UniformBufferBindings[index].BufferObject; 2613 v->value_int = buf ? buf->Name : 0; 2614 return TYPE_INT; 2615 2616 case GL_UNIFORM_BUFFER_START: 2617 if (index >= ctx->Const.MaxUniformBufferBindings) 2618 goto invalid_value; 2619 if (!ctx->Extensions.ARB_uniform_buffer_object) 2620 goto invalid_enum; 2621 v->value_int = ctx->UniformBufferBindings[index].Offset < 0 ? 0 : 2622 ctx->UniformBufferBindings[index].Offset; 2623 return TYPE_INT; 2624 2625 case GL_UNIFORM_BUFFER_SIZE: 2626 if (index >= ctx->Const.MaxUniformBufferBindings) 2627 goto invalid_value; 2628 if (!ctx->Extensions.ARB_uniform_buffer_object) 2629 goto invalid_enum; 2630 v->value_int = ctx->UniformBufferBindings[index].Size < 0 ? 0 : 2631 ctx->UniformBufferBindings[index].Size; 2632 return TYPE_INT; 2633 2634 /* ARB_shader_storage_buffer_object */ 2635 case GL_SHADER_STORAGE_BUFFER_BINDING: 2636 if (!ctx->Extensions.ARB_shader_storage_buffer_object && !_mesa_is_gles31(ctx)) 2637 goto invalid_enum; 2638 if (index >= ctx->Const.MaxShaderStorageBufferBindings) 2639 goto invalid_value; 2640 buf = ctx->ShaderStorageBufferBindings[index].BufferObject; 2641 v->value_int = buf ? buf->Name : 0; 2642 return TYPE_INT; 2643 2644 case GL_SHADER_STORAGE_BUFFER_START: 2645 if (!ctx->Extensions.ARB_shader_storage_buffer_object && !_mesa_is_gles31(ctx)) 2646 goto invalid_enum; 2647 if (index >= ctx->Const.MaxShaderStorageBufferBindings) 2648 goto invalid_value; 2649 v->value_int = ctx->ShaderStorageBufferBindings[index].Offset < 0 ? 0 : 2650 ctx->ShaderStorageBufferBindings[index].Offset; 2651 return TYPE_INT; 2652 2653 case GL_SHADER_STORAGE_BUFFER_SIZE: 2654 if (!ctx->Extensions.ARB_shader_storage_buffer_object && !_mesa_is_gles31(ctx)) 2655 goto invalid_enum; 2656 if (index >= ctx->Const.MaxShaderStorageBufferBindings) 2657 goto invalid_value; 2658 v->value_int = ctx->ShaderStorageBufferBindings[index].Size < 0 ? 0 : 2659 ctx->ShaderStorageBufferBindings[index].Size; 2660 return TYPE_INT; 2661 2662 /* ARB_texture_multisample / GL3.2 */ 2663 case GL_SAMPLE_MASK_VALUE: 2664 if (index != 0) 2665 goto invalid_value; 2666 if (!ctx->Extensions.ARB_texture_multisample) 2667 goto invalid_enum; 2668 v->value_int = ctx->Multisample.SampleMaskValue; 2669 return TYPE_INT; 2670 2671 case GL_ATOMIC_COUNTER_BUFFER_BINDING: 2672 if (!ctx->Extensions.ARB_shader_atomic_counters && !_mesa_is_gles31(ctx)) 2673 goto invalid_enum; 2674 if (index >= ctx->Const.MaxAtomicBufferBindings) 2675 goto invalid_value; 2676 buf = ctx->AtomicBufferBindings[index].BufferObject; 2677 v->value_int = buf ? buf->Name : 0; 2678 return TYPE_INT; 2679 2680 case GL_ATOMIC_COUNTER_BUFFER_START: 2681 if (!ctx->Extensions.ARB_shader_atomic_counters && !_mesa_is_gles31(ctx)) 2682 goto invalid_enum; 2683 if (index >= ctx->Const.MaxAtomicBufferBindings) 2684 goto invalid_value; 2685 v->value_int64 = ctx->AtomicBufferBindings[index].Offset < 0 ? 0 : 2686 ctx->AtomicBufferBindings[index].Offset; 2687 return TYPE_INT64; 2688 2689 case GL_ATOMIC_COUNTER_BUFFER_SIZE: 2690 if (!ctx->Extensions.ARB_shader_atomic_counters && !_mesa_is_gles31(ctx)) 2691 goto invalid_enum; 2692 if (index >= ctx->Const.MaxAtomicBufferBindings) 2693 goto invalid_value; 2694 v->value_int64 = ctx->AtomicBufferBindings[index].Size < 0 ? 0 : 2695 ctx->AtomicBufferBindings[index].Size; 2696 return TYPE_INT64; 2697 2698 case GL_VERTEX_BINDING_DIVISOR: 2699 if ((!_mesa_is_desktop_gl(ctx) || !ctx->Extensions.ARB_instanced_arrays) && 2700 !_mesa_is_gles31(ctx)) 2701 goto invalid_enum; 2702 if (index >= ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs) 2703 goto invalid_value; 2704 v->value_int = ctx->Array.VAO->BufferBinding[VERT_ATTRIB_GENERIC(index)].InstanceDivisor; 2705 return TYPE_INT; 2706 2707 case GL_VERTEX_BINDING_OFFSET: 2708 if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles31(ctx)) 2709 goto invalid_enum; 2710 if (index >= ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs) 2711 goto invalid_value; 2712 v->value_int = ctx->Array.VAO->BufferBinding[VERT_ATTRIB_GENERIC(index)].Offset; 2713 return TYPE_INT; 2714 2715 case GL_VERTEX_BINDING_STRIDE: 2716 if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles31(ctx)) 2717 goto invalid_enum; 2718 if (index >= ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs) 2719 goto invalid_value; 2720 v->value_int = ctx->Array.VAO->BufferBinding[VERT_ATTRIB_GENERIC(index)].Stride; 2721 return TYPE_INT; 2722 2723 case GL_VERTEX_BINDING_BUFFER: 2724 if (ctx->API == API_OPENGLES2 && ctx->Version < 31) 2725 goto invalid_enum; 2726 if (index >= ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs) 2727 goto invalid_value; 2728 buf = ctx->Array.VAO->BufferBinding[VERT_ATTRIB_GENERIC(index)].BufferObj; 2729 v->value_int = buf ? buf->Name : 0; 2730 return TYPE_INT; 2731 2732 /* ARB_shader_image_load_store */ 2733 case GL_IMAGE_BINDING_NAME: { 2734 struct gl_texture_object *t; 2735 2736 if (!ctx->Extensions.ARB_shader_image_load_store && !_mesa_is_gles31(ctx)) 2737 goto invalid_enum; 2738 if (index >= ctx->Const.MaxImageUnits) 2739 goto invalid_value; 2740 2741 t = ctx->ImageUnits[index].TexObj; 2742 v->value_int = (t ? t->Name : 0); 2743 return TYPE_INT; 2744 } 2745 2746 case GL_IMAGE_BINDING_LEVEL: 2747 if (!ctx->Extensions.ARB_shader_image_load_store && !_mesa_is_gles31(ctx)) 2748 goto invalid_enum; 2749 if (index >= ctx->Const.MaxImageUnits) 2750 goto invalid_value; 2751 2752 v->value_int = ctx->ImageUnits[index].Level; 2753 return TYPE_INT; 2754 2755 case GL_IMAGE_BINDING_LAYERED: 2756 if (!ctx->Extensions.ARB_shader_image_load_store && !_mesa_is_gles31(ctx)) 2757 goto invalid_enum; 2758 if (index >= ctx->Const.MaxImageUnits) 2759 goto invalid_value; 2760 2761 v->value_int = ctx->ImageUnits[index].Layered; 2762 return TYPE_INT; 2763 2764 case GL_IMAGE_BINDING_LAYER: 2765 if (!ctx->Extensions.ARB_shader_image_load_store && !_mesa_is_gles31(ctx)) 2766 goto invalid_enum; 2767 if (index >= ctx->Const.MaxImageUnits) 2768 goto invalid_value; 2769 2770 v->value_int = ctx->ImageUnits[index].Layer; 2771 return TYPE_INT; 2772 2773 case GL_IMAGE_BINDING_ACCESS: 2774 if (!ctx->Extensions.ARB_shader_image_load_store && !_mesa_is_gles31(ctx)) 2775 goto invalid_enum; 2776 if (index >= ctx->Const.MaxImageUnits) 2777 goto invalid_value; 2778 2779 v->value_int = ctx->ImageUnits[index].Access; 2780 return TYPE_INT; 2781 2782 case GL_IMAGE_BINDING_FORMAT: 2783 if (!ctx->Extensions.ARB_shader_image_load_store && !_mesa_is_gles31(ctx)) 2784 goto invalid_enum; 2785 if (index >= ctx->Const.MaxImageUnits) 2786 goto invalid_value; 2787 2788 v->value_int = ctx->ImageUnits[index].Format; 2789 return TYPE_INT; 2790 2791 /* ARB_direct_state_access */ 2792 case GL_TEXTURE_BINDING_1D: 2793 case GL_TEXTURE_BINDING_1D_ARRAY: 2794 case GL_TEXTURE_BINDING_2D: 2795 case GL_TEXTURE_BINDING_2D_ARRAY: 2796 case GL_TEXTURE_BINDING_2D_MULTISAMPLE: 2797 case GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY: 2798 case GL_TEXTURE_BINDING_3D: 2799 case GL_TEXTURE_BINDING_BUFFER: 2800 case GL_TEXTURE_BINDING_CUBE_MAP: 2801 case GL_TEXTURE_BINDING_CUBE_MAP_ARRAY: 2802 case GL_TEXTURE_BINDING_RECTANGLE: { 2803 int target; 2804 2805 target = tex_binding_to_index(ctx, pname); 2806 if (target < 0) 2807 goto invalid_enum; 2808 if (index >= _mesa_max_tex_unit(ctx)) 2809 goto invalid_value; 2810 2811 v->value_int = ctx->Texture.Unit[index].CurrentTex[target]->Name; 2812 return TYPE_INT; 2813 } 2814 2815 case GL_SAMPLER_BINDING: { 2816 struct gl_sampler_object *samp; 2817 2818 if (!_mesa_is_desktop_gl(ctx) || ctx->Version < 33) 2819 goto invalid_enum; 2820 if (index >= _mesa_max_tex_unit(ctx)) 2821 goto invalid_value; 2822 2823 samp = ctx->Texture.Unit[index].Sampler; 2824 v->value_int = samp ? samp->Name : 0; 2825 return TYPE_INT; 2826 } 2827 2828 case GL_MAX_COMPUTE_WORK_GROUP_COUNT: 2829 if (!_mesa_has_compute_shaders(ctx)) 2830 goto invalid_enum; 2831 if (index >= 3) 2832 goto invalid_value; 2833 v->value_int = ctx->Const.MaxComputeWorkGroupCount[index]; 2834 return TYPE_INT; 2835 2836 case GL_MAX_COMPUTE_WORK_GROUP_SIZE: 2837 if (!_mesa_has_compute_shaders(ctx)) 2838 goto invalid_enum; 2839 if (index >= 3) 2840 goto invalid_value; 2841 v->value_int = ctx->Const.MaxComputeWorkGroupSize[index]; 2842 return TYPE_INT; 2843 2844 /* ARB_compute_variable_group_size */ 2845 case GL_MAX_COMPUTE_VARIABLE_GROUP_SIZE_ARB: 2846 if (!ctx->Extensions.ARB_compute_variable_group_size) 2847 goto invalid_enum; 2848 if (index >= 3) 2849 goto invalid_value; 2850 v->value_int = ctx->Const.MaxComputeVariableGroupSize[index]; 2851 return TYPE_INT; 2852 2853 /* GL_EXT_external_objects */ 2854 case GL_NUM_DEVICE_UUIDS_EXT: 2855 v->value_int = 1; 2856 return TYPE_INT; 2857 case GL_DRIVER_UUID_EXT: 2858 if (index >= 1) 2859 goto invalid_value; 2860 _mesa_get_driver_uuid(ctx, v->value_int_4); 2861 return TYPE_INT_4; 2862 case GL_DEVICE_UUID_EXT: 2863 if (index >= 1) 2864 goto invalid_value; 2865 _mesa_get_device_uuid(ctx, v->value_int_4); 2866 return TYPE_INT_4; 2867 /* GL_EXT_direct_state_access */ 2868 case GL_TEXTURE_1D: 2869 case GL_TEXTURE_2D: 2870 case GL_TEXTURE_3D: 2871 case GL_TEXTURE_CUBE_MAP: 2872 case GL_TEXTURE_GEN_S: 2873 case GL_TEXTURE_GEN_T: 2874 case GL_TEXTURE_GEN_R: 2875 case GL_TEXTURE_GEN_Q: 2876 case GL_TEXTURE_RECTANGLE_ARB: { 2877 GLuint curTexUnitSave; 2878 if (index >= _mesa_max_tex_unit(ctx)) 2879 goto invalid_enum; 2880 curTexUnitSave = ctx->Texture.CurrentUnit; 2881 _mesa_ActiveTexture_no_error(GL_TEXTURE0 + index); 2882 v->value_int = _mesa_IsEnabled(pname); 2883 _mesa_ActiveTexture_no_error(GL_TEXTURE0 + curTexUnitSave); 2884 return TYPE_INT; 2885 } 2886 case GL_TEXTURE_COORD_ARRAY: { 2887 GLuint curTexUnitSave; 2888 if (index >= ctx->Const.MaxTextureCoordUnits) 2889 goto invalid_enum; 2890 curTexUnitSave = ctx->Array.ActiveTexture; 2891 _mesa_ClientActiveTexture(GL_TEXTURE0 + index); 2892 v->value_int = _mesa_IsEnabled(pname); 2893 _mesa_ClientActiveTexture(GL_TEXTURE0 + curTexUnitSave); 2894 return TYPE_INT; 2895 } 2896 case GL_TEXTURE_MATRIX: 2897 if (index >= ARRAY_SIZE(ctx->TextureMatrixStack)) 2898 goto invalid_enum; 2899 v->value_matrix = ctx->TextureMatrixStack[index].Top; 2900 return TYPE_MATRIX; 2901 case GL_TRANSPOSE_TEXTURE_MATRIX: 2902 if (index >= ARRAY_SIZE(ctx->TextureMatrixStack)) 2903 goto invalid_enum; 2904 v->value_matrix = ctx->TextureMatrixStack[index].Top; 2905 return TYPE_MATRIX_T; 2906 /* GL_NV_viewport_swizzle */ 2907 case GL_VIEWPORT_SWIZZLE_X_NV: 2908 if (!ctx->Extensions.NV_viewport_swizzle) 2909 goto invalid_enum; 2910 if (index >= ctx->Const.MaxViewports) 2911 goto invalid_value; 2912 v->value_int = ctx->ViewportArray[index].SwizzleX; 2913 return TYPE_INT; 2914 case GL_VIEWPORT_SWIZZLE_Y_NV: 2915 if (!ctx->Extensions.NV_viewport_swizzle) 2916 goto invalid_enum; 2917 if (index >= ctx->Const.MaxViewports) 2918 goto invalid_value; 2919 v->value_int = ctx->ViewportArray[index].SwizzleY; 2920 return TYPE_INT; 2921 case GL_VIEWPORT_SWIZZLE_Z_NV: 2922 if (!ctx->Extensions.NV_viewport_swizzle) 2923 goto invalid_enum; 2924 if (index >= ctx->Const.MaxViewports) 2925 goto invalid_value; 2926 v->value_int = ctx->ViewportArray[index].SwizzleZ; 2927 return TYPE_INT; 2928 case GL_VIEWPORT_SWIZZLE_W_NV: 2929 if (!ctx->Extensions.NV_viewport_swizzle) 2930 goto invalid_enum; 2931 if (index >= ctx->Const.MaxViewports) 2932 goto invalid_value; 2933 v->value_int = ctx->ViewportArray[index].SwizzleW; 2934 return TYPE_INT; 2935 } 2936 2937 invalid_enum: 2938 _mesa_error(ctx, GL_INVALID_ENUM, "%s(pname=%s)", func, 2939 _mesa_enum_to_string(pname)); 2940 return TYPE_INVALID; 2941 invalid_value: 2942 _mesa_error(ctx, GL_INVALID_VALUE, "%s(pname=%s)", func, 2943 _mesa_enum_to_string(pname)); 2944 return TYPE_INVALID; 2945} 2946 2947void GLAPIENTRY 2948_mesa_GetBooleani_v( GLenum pname, GLuint index, GLboolean *params ) 2949{ 2950 union value v; 2951 enum value_type type = 2952 find_value_indexed("glGetBooleani_v", pname, index, &v); 2953 2954 switch (type) { 2955 case TYPE_INT: 2956 case TYPE_UINT: 2957 params[0] = INT_TO_BOOLEAN(v.value_int); 2958 break; 2959 case TYPE_INT_4: 2960 case TYPE_UINT_4: 2961 params[0] = INT_TO_BOOLEAN(v.value_int_4[0]); 2962 params[1] = INT_TO_BOOLEAN(v.value_int_4[1]); 2963 params[2] = INT_TO_BOOLEAN(v.value_int_4[2]); 2964 params[3] = INT_TO_BOOLEAN(v.value_int_4[3]); 2965 break; 2966 case TYPE_INT64: 2967 params[0] = INT64_TO_BOOLEAN(v.value_int64); 2968 break; 2969 default: 2970 ; /* nothing - GL error was recorded */ 2971 } 2972} 2973 2974void GLAPIENTRY 2975_mesa_GetIntegeri_v( GLenum pname, GLuint index, GLint *params ) 2976{ 2977 union value v; 2978 enum value_type type = 2979 find_value_indexed("glGetIntegeri_v", pname, index, &v); 2980 2981 switch (type) { 2982 case TYPE_FLOAT_4: 2983 case TYPE_FLOATN_4: 2984 params[3] = lroundf(v.value_float_4[3]); 2985 FALLTHROUGH; 2986 case TYPE_FLOAT_3: 2987 case TYPE_FLOATN_3: 2988 params[2] = lroundf(v.value_float_4[2]); 2989 FALLTHROUGH; 2990 case TYPE_FLOAT_2: 2991 case TYPE_FLOATN_2: 2992 params[1] = lroundf(v.value_float_4[1]); 2993 FALLTHROUGH; 2994 case TYPE_FLOAT: 2995 case TYPE_FLOATN: 2996 params[0] = lroundf(v.value_float_4[0]); 2997 break; 2998 2999 case TYPE_DOUBLEN_2: 3000 params[1] = lroundf(v.value_double_2[1]); 3001 FALLTHROUGH; 3002 case TYPE_DOUBLEN: 3003 params[0] = lroundf(v.value_double_2[0]); 3004 break; 3005 3006 case TYPE_INT: 3007 case TYPE_UINT: 3008 params[0] = v.value_int; 3009 break; 3010 case TYPE_INT_4: 3011 case TYPE_UINT_4: 3012 params[0] = v.value_int_4[0]; 3013 params[1] = v.value_int_4[1]; 3014 params[2] = v.value_int_4[2]; 3015 params[3] = v.value_int_4[3]; 3016 break; 3017 case TYPE_INT64: 3018 params[0] = INT64_TO_INT(v.value_int64); 3019 break; 3020 default: 3021 ; /* nothing - GL error was recorded */ 3022 } 3023} 3024 3025void GLAPIENTRY 3026_mesa_GetInteger64i_v( GLenum pname, GLuint index, GLint64 *params ) 3027{ 3028 union value v; 3029 enum value_type type = 3030 find_value_indexed("glGetInteger64i_v", pname, index, &v); 3031 3032 switch (type) { 3033 case TYPE_INT: 3034 params[0] = v.value_int; 3035 break; 3036 case TYPE_INT_4: 3037 params[0] = v.value_int_4[0]; 3038 params[1] = v.value_int_4[1]; 3039 params[2] = v.value_int_4[2]; 3040 params[3] = v.value_int_4[3]; 3041 break; 3042 case TYPE_UINT: 3043 params[0] = (GLuint) v.value_int; 3044 break; 3045 case TYPE_UINT_4: 3046 params[0] = (GLuint) v.value_int_4[0]; 3047 params[1] = (GLuint) v.value_int_4[1]; 3048 params[2] = (GLuint) v.value_int_4[2]; 3049 params[3] = (GLuint) v.value_int_4[3]; 3050 break; 3051 case TYPE_INT64: 3052 params[0] = v.value_int64; 3053 break; 3054 default: 3055 ; /* nothing - GL error was recorded */ 3056 } 3057} 3058 3059void GLAPIENTRY 3060_mesa_GetFloati_v(GLenum pname, GLuint index, GLfloat *params) 3061{ 3062 int i; 3063 GLmatrix *m; 3064 union value v; 3065 enum value_type type = 3066 find_value_indexed("glGetFloati_v", pname, index, &v); 3067 3068 switch (type) { 3069 case TYPE_FLOAT_4: 3070 case TYPE_FLOATN_4: 3071 params[3] = v.value_float_4[3]; 3072 FALLTHROUGH; 3073 case TYPE_FLOAT_3: 3074 case TYPE_FLOATN_3: 3075 params[2] = v.value_float_4[2]; 3076 FALLTHROUGH; 3077 case TYPE_FLOAT_2: 3078 case TYPE_FLOATN_2: 3079 params[1] = v.value_float_4[1]; 3080 FALLTHROUGH; 3081 case TYPE_FLOAT: 3082 case TYPE_FLOATN: 3083 params[0] = v.value_float_4[0]; 3084 break; 3085 3086 case TYPE_DOUBLEN_2: 3087 params[1] = (GLfloat) v.value_double_2[1]; 3088 FALLTHROUGH; 3089 case TYPE_DOUBLEN: 3090 params[0] = (GLfloat) v.value_double_2[0]; 3091 break; 3092 3093 case TYPE_INT_4: 3094 params[3] = (GLfloat) v.value_int_4[3]; 3095 FALLTHROUGH; 3096 case TYPE_INT_3: 3097 params[2] = (GLfloat) v.value_int_4[2]; 3098 FALLTHROUGH; 3099 case TYPE_INT_2: 3100 case TYPE_ENUM_2: 3101 params[1] = (GLfloat) v.value_int_4[1]; 3102 FALLTHROUGH; 3103 case TYPE_INT: 3104 case TYPE_ENUM: 3105 case TYPE_ENUM16: 3106 params[0] = (GLfloat) v.value_int_4[0]; 3107 break; 3108 3109 case TYPE_INT_N: 3110 for (i = 0; i < v.value_int_n.n; i++) 3111 params[i] = (GLfloat) v.value_int_n.ints[i]; 3112 break; 3113 3114 case TYPE_UINT_4: 3115 params[3] = (GLfloat) ((GLuint) v.value_int_4[3]); 3116 FALLTHROUGH; 3117 case TYPE_UINT_3: 3118 params[2] = (GLfloat) ((GLuint) v.value_int_4[2]); 3119 FALLTHROUGH; 3120 case TYPE_UINT_2: 3121 params[1] = (GLfloat) ((GLuint) v.value_int_4[1]); 3122 FALLTHROUGH; 3123 case TYPE_UINT: 3124 params[0] = (GLfloat) ((GLuint) v.value_int_4[0]); 3125 break; 3126 3127 case TYPE_INT64: 3128 params[0] = (GLfloat) v.value_int64; 3129 break; 3130 3131 case TYPE_BOOLEAN: 3132 params[0] = BOOLEAN_TO_FLOAT(v.value_bool); 3133 break; 3134 3135 case TYPE_UBYTE: 3136 params[0] = (GLfloat) v.value_ubyte; 3137 break; 3138 3139 case TYPE_SHORT: 3140 params[0] = (GLfloat) v.value_short; 3141 break; 3142 3143 case TYPE_MATRIX: 3144 m = *(GLmatrix **) &v; 3145 for (i = 0; i < 16; i++) 3146 params[i] = m->m[i]; 3147 break; 3148 3149 case TYPE_MATRIX_T: 3150 m = *(GLmatrix **) &v; 3151 for (i = 0; i < 16; i++) 3152 params[i] = m->m[transpose[i]]; 3153 break; 3154 3155 default: 3156 ; 3157 } 3158} 3159 3160void GLAPIENTRY 3161_mesa_GetDoublei_v(GLenum pname, GLuint index, GLdouble *params) 3162{ 3163 int i; 3164 GLmatrix *m; 3165 union value v; 3166 enum value_type type = 3167 find_value_indexed("glGetDoublei_v", pname, index, &v); 3168 3169 switch (type) { 3170 case TYPE_FLOAT_4: 3171 case TYPE_FLOATN_4: 3172 params[3] = (GLdouble) v.value_float_4[3]; 3173 FALLTHROUGH; 3174 case TYPE_FLOAT_3: 3175 case TYPE_FLOATN_3: 3176 params[2] = (GLdouble) v.value_float_4[2]; 3177 FALLTHROUGH; 3178 case TYPE_FLOAT_2: 3179 case TYPE_FLOATN_2: 3180 params[1] = (GLdouble) v.value_float_4[1]; 3181 FALLTHROUGH; 3182 case TYPE_FLOAT: 3183 case TYPE_FLOATN: 3184 params[0] = (GLdouble) v.value_float_4[0]; 3185 break; 3186 3187 case TYPE_DOUBLEN_2: 3188 params[1] = v.value_double_2[1]; 3189 FALLTHROUGH; 3190 case TYPE_DOUBLEN: 3191 params[0] = v.value_double_2[0]; 3192 break; 3193 3194 case TYPE_INT_4: 3195 params[3] = (GLdouble) v.value_int_4[3]; 3196 FALLTHROUGH; 3197 case TYPE_INT_3: 3198 params[2] = (GLdouble) v.value_int_4[2]; 3199 FALLTHROUGH; 3200 case TYPE_INT_2: 3201 case TYPE_ENUM_2: 3202 params[1] = (GLdouble) v.value_int_4[1]; 3203 FALLTHROUGH; 3204 case TYPE_INT: 3205 case TYPE_ENUM: 3206 case TYPE_ENUM16: 3207 params[0] = (GLdouble) v.value_int_4[0]; 3208 break; 3209 3210 case TYPE_INT_N: 3211 for (i = 0; i < v.value_int_n.n; i++) 3212 params[i] = (GLdouble) v.value_int_n.ints[i]; 3213 break; 3214 3215 case TYPE_UINT_4: 3216 params[3] = (GLdouble) ((GLuint) v.value_int_4[3]); 3217 FALLTHROUGH; 3218 case TYPE_UINT_3: 3219 params[2] = (GLdouble) ((GLuint) v.value_int_4[2]); 3220 FALLTHROUGH; 3221 case TYPE_UINT_2: 3222 params[1] = (GLdouble) ((GLuint) v.value_int_4[1]); 3223 FALLTHROUGH; 3224 case TYPE_UINT: 3225 params[0] = (GLdouble) ((GLuint) v.value_int_4[0]); 3226 break; 3227 3228 case TYPE_INT64: 3229 params[0] = (GLdouble) v.value_int64; 3230 break; 3231 3232 case TYPE_BOOLEAN: 3233 params[0] = (GLdouble) BOOLEAN_TO_FLOAT(v.value_bool); 3234 break; 3235 3236 case TYPE_UBYTE: 3237 params[0] = (GLdouble) v.value_ubyte; 3238 break; 3239 3240 case TYPE_SHORT: 3241 params[0] = (GLdouble) v.value_short; 3242 break; 3243 3244 case TYPE_MATRIX: 3245 m = *(GLmatrix **) &v; 3246 for (i = 0; i < 16; i++) 3247 params[i] = (GLdouble) m->m[i]; 3248 break; 3249 3250 case TYPE_MATRIX_T: 3251 m = *(GLmatrix **) &v; 3252 for (i = 0; i < 16; i++) 3253 params[i] = (GLdouble) m->m[transpose[i]]; 3254 break; 3255 3256 default: 3257 ; 3258 } 3259} 3260 3261void GLAPIENTRY 3262_mesa_GetUnsignedBytei_vEXT(GLenum target, GLuint index, GLubyte *data) 3263{ 3264 GLsizei size; 3265 union value v; 3266 enum value_type type; 3267 const char *func = "glGetUnsignedBytei_vEXT"; 3268 3269 GET_CURRENT_CONTEXT(ctx); 3270 3271 if (!ctx->Extensions.EXT_memory_object) { 3272 _mesa_error(ctx, GL_INVALID_OPERATION, "%s(unsupported)", func); 3273 return; 3274 } 3275 3276 type = find_value_indexed(func, target, index, &v); 3277 size = get_value_size(type, &v); 3278 3279 switch (type) { 3280 case TYPE_UINT: 3281 case TYPE_INT: 3282 case TYPE_INT_2: 3283 case TYPE_UINT_2: 3284 case TYPE_INT_3: 3285 case TYPE_UINT_3: 3286 case TYPE_INT_4: 3287 case TYPE_UINT_4: 3288 case TYPE_INT64: 3289 case TYPE_ENUM16: 3290 case TYPE_ENUM: 3291 case TYPE_ENUM_2: 3292 case TYPE_BOOLEAN: 3293 case TYPE_UBYTE: 3294 case TYPE_SHORT: 3295 case TYPE_FLOAT: 3296 case TYPE_FLOATN: 3297 case TYPE_FLOAT_2: 3298 case TYPE_FLOATN_2: 3299 case TYPE_FLOAT_3: 3300 case TYPE_FLOATN_3: 3301 case TYPE_FLOAT_4: 3302 case TYPE_FLOATN_4: 3303 case TYPE_FLOAT_8: 3304 case TYPE_DOUBLEN: 3305 case TYPE_DOUBLEN_2: 3306 case TYPE_MATRIX: 3307 case TYPE_MATRIX_T: 3308 memcpy(data, &v.value_int, size); 3309 break; 3310 case TYPE_INT_N: 3311 memcpy(data, &v.value_int_n.ints, size); 3312 break; 3313 default: 3314 break; /* nothing - GL error was recorded */ 3315 } 3316} 3317 3318void GLAPIENTRY 3319_mesa_GetFixedv(GLenum pname, GLfixed *params) 3320{ 3321 const struct value_desc *d; 3322 union value v; 3323 GLmatrix *m; 3324 int shift, i; 3325 void *p; 3326 3327 d = find_value("glGetDoublev", pname, &p, &v); 3328 switch (d->type) { 3329 case TYPE_INVALID: 3330 break; 3331 case TYPE_CONST: 3332 params[0] = INT_TO_FIXED(d->offset); 3333 break; 3334 3335 case TYPE_FLOAT_4: 3336 case TYPE_FLOATN_4: 3337 params[3] = FLOAT_TO_FIXED(((GLfloat *) p)[3]); 3338 FALLTHROUGH; 3339 case TYPE_FLOAT_3: 3340 case TYPE_FLOATN_3: 3341 params[2] = FLOAT_TO_FIXED(((GLfloat *) p)[2]); 3342 FALLTHROUGH; 3343 case TYPE_FLOAT_2: 3344 case TYPE_FLOATN_2: 3345 params[1] = FLOAT_TO_FIXED(((GLfloat *) p)[1]); 3346 FALLTHROUGH; 3347 case TYPE_FLOAT: 3348 case TYPE_FLOATN: 3349 params[0] = FLOAT_TO_FIXED(((GLfloat *) p)[0]); 3350 break; 3351 3352 case TYPE_DOUBLEN_2: 3353 params[1] = FLOAT_TO_FIXED(((GLdouble *) p)[1]); 3354 FALLTHROUGH; 3355 case TYPE_DOUBLEN: 3356 params[0] = FLOAT_TO_FIXED(((GLdouble *) p)[0]); 3357 break; 3358 3359 case TYPE_INT_4: 3360 case TYPE_UINT_4: 3361 params[3] = INT_TO_FIXED(((GLint *) p)[3]); 3362 FALLTHROUGH; 3363 case TYPE_INT_3: 3364 case TYPE_UINT_3: 3365 params[2] = INT_TO_FIXED(((GLint *) p)[2]); 3366 FALLTHROUGH; 3367 case TYPE_INT_2: 3368 case TYPE_UINT_2: 3369 case TYPE_ENUM_2: 3370 params[1] = INT_TO_FIXED(((GLint *) p)[1]); 3371 FALLTHROUGH; 3372 case TYPE_INT: 3373 case TYPE_UINT: 3374 case TYPE_ENUM: 3375 params[0] = INT_TO_FIXED(((GLint *) p)[0]); 3376 break; 3377 3378 case TYPE_ENUM16: 3379 params[0] = INT_TO_FIXED((GLint)(((GLenum16 *) p)[0])); 3380 break; 3381 3382 case TYPE_INT_N: 3383 for (i = 0; i < v.value_int_n.n; i++) 3384 params[i] = INT_TO_FIXED(v.value_int_n.ints[i]); 3385 break; 3386 3387 case TYPE_INT64: 3388 params[0] = ((GLint64 *) p)[0]; 3389 break; 3390 3391 case TYPE_BOOLEAN: 3392 params[0] = BOOLEAN_TO_FIXED(((GLboolean*) p)[0]); 3393 break; 3394 3395 case TYPE_UBYTE: 3396 params[0] = INT_TO_FIXED(((GLubyte *) p)[0]); 3397 break; 3398 3399 case TYPE_SHORT: 3400 params[0] = INT_TO_FIXED(((GLshort *) p)[0]); 3401 break; 3402 3403 case TYPE_MATRIX: 3404 m = *(GLmatrix **) p; 3405 for (i = 0; i < 16; i++) 3406 params[i] = FLOAT_TO_FIXED(m->m[i]); 3407 break; 3408 3409 case TYPE_MATRIX_T: 3410 m = *(GLmatrix **) p; 3411 for (i = 0; i < 16; i++) 3412 params[i] = FLOAT_TO_FIXED(m->m[transpose[i]]); 3413 break; 3414 3415 case TYPE_BIT_0: 3416 case TYPE_BIT_1: 3417 case TYPE_BIT_2: 3418 case TYPE_BIT_3: 3419 case TYPE_BIT_4: 3420 case TYPE_BIT_5: 3421 case TYPE_BIT_6: 3422 case TYPE_BIT_7: 3423 shift = d->type - TYPE_BIT_0; 3424 params[0] = BOOLEAN_TO_FIXED((*(GLbitfield *) p >> shift) & 1); 3425 break; 3426 } 3427} 3428