2 * Copyright (C) 2010 Brian Paul All Rights Reserved.
3 * Copyright (C) 2010 Intel Corporation
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included
13 * in all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * 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.
23 * Author: Kristian Høgsberg <krh@bitplanet.net>
32 #include "extensions.h"
37 #include "texcompress.h"
38 #include "framebuffer.h"
39 #include "samplerobj.h"
42 /* This is a table driven implemetation of the glGet*v() functions.
43 * The basic idea is that most getters just look up an int somewhere
44 * in struct gl_context and then convert it to a bool or float according to
45 * which of glGetIntegerv() glGetBooleanv() etc is being called.
46 * Instead of generating code to do this, we can just record the enum
47 * value and the offset into struct gl_context in an array of structs. Then
48 * in glGet*(), we lookup the struct for the enum in question, and use
49 * the offset to get the int we need.
51 * Sometimes we need to look up a float, a boolean, a bit in a
52 * bitfield, a matrix or other types instead, so we need to track the
53 * type of the value in struct gl_context. And sometimes the value isn't in
54 * struct gl_context but in the drawbuffer, the array object, current texture
55 * unit, or maybe it's a computed value. So we need to also track
56 * where or how to find the value. Finally, we sometimes need to
57 * check that one of a number of extensions are enabled, the GL
58 * version or flush or call _mesa_update_state(). This is done by
59 * attaching optional extra information to the value description
60 * struct, it's sort of like an array of opcodes that describe extra
63 * Putting all this together we end up with struct value_desc below,
64 * and with a couple of macros to help, the table of struct value_desc
65 * is about as concise as the specification in the old python script.
68 #define FLOAT_TO_BOOLEAN(X) ( (X) ? GL_TRUE : GL_FALSE )
69 #define FLOAT_TO_FIXED(F) ( ((F) * 65536.0f > INT_MAX) ? INT_MAX : \
70 ((F) * 65536.0f < INT_MIN) ? INT_MIN : \
71 (GLint) ((F) * 65536.0f) )
73 #define INT_TO_BOOLEAN(I) ( (I) ? GL_TRUE : GL_FALSE )
74 #define INT_TO_FIXED(I) ( ((I) > SHRT_MAX) ? INT_MAX : \
75 ((I) < SHRT_MIN) ? INT_MIN : \
76 (GLint) ((I) * 65536) )
78 #define INT64_TO_BOOLEAN(I) ( (I) ? GL_TRUE : GL_FALSE )
79 #define INT64_TO_INT(I) ( (GLint)((I > INT_MAX) ? INT_MAX : ((I < INT_MIN) ? INT_MIN : (I))) )
81 #define BOOLEAN_TO_INT(B) ( (GLint) (B) )
82 #define BOOLEAN_TO_INT64(B) ( (GLint64) (B) )
83 #define BOOLEAN_TO_FLOAT(B) ( (B) ? 1.0F : 0.0F )
84 #define BOOLEAN_TO_FIXED(B) ( (GLint) ((B) ? 1 : 0) << 16 )
86 #define ENUM_TO_INT64(E) ( (GLint64) (E) )
87 #define ENUM_TO_FIXED(E) (E)
123 enum value_location
{
143 EXTRA_NEW_FRAG_CLAMP
,
144 EXTRA_VALID_DRAW_BUFFER
,
145 EXTRA_VALID_TEXTURE_UNIT
,
146 EXTRA_VALID_CLIP_DISTANCE
,
150 EXTRA_EXT_ATOMICS_GS4
,
151 EXTRA_EXT_SHADER_IMAGE_GS4
,
152 EXTRA_EXT_ATOMICS_TESS
,
153 EXTRA_EXT_SHADER_IMAGE_TESS
,
156 #define NO_EXTRA NULL
161 GLubyte location
; /**< enum value_location */
162 GLubyte type
; /**< enum value_type */
169 GLfloat value_float_4
[4];
170 GLdouble value_double_2
[2];
171 GLmatrix
*value_matrix
;
173 GLint value_int_4
[4];
177 /* Sigh, see GL_COMPRESSED_TEXTURE_FORMATS_ARB handling */
181 GLboolean value_bool
;
184 #define BUFFER_FIELD(field, type) \
185 LOC_BUFFER, type, offsetof(struct gl_framebuffer, field)
186 #define CONTEXT_FIELD(field, type) \
187 LOC_CONTEXT, type, offsetof(struct gl_context, field)
188 #define ARRAY_FIELD(field, type) \
189 LOC_ARRAY, type, offsetof(struct gl_vertex_array_object, field)
190 #undef CONST /* already defined through windows.h */
191 #define CONST(value) \
192 LOC_CONTEXT, TYPE_CONST, value
194 #define BUFFER_INT(field) BUFFER_FIELD(field, TYPE_INT)
195 #define BUFFER_ENUM(field) BUFFER_FIELD(field, TYPE_ENUM)
196 #define BUFFER_BOOL(field) BUFFER_FIELD(field, TYPE_BOOLEAN)
198 #define CONTEXT_INT(field) CONTEXT_FIELD(field, TYPE_INT)
199 #define CONTEXT_INT2(field) CONTEXT_FIELD(field, TYPE_INT_2)
200 #define CONTEXT_INT64(field) CONTEXT_FIELD(field, TYPE_INT64)
201 #define CONTEXT_ENUM(field) CONTEXT_FIELD(field, TYPE_ENUM)
202 #define CONTEXT_ENUM2(field) CONTEXT_FIELD(field, TYPE_ENUM_2)
203 #define CONTEXT_BOOL(field) CONTEXT_FIELD(field, TYPE_BOOLEAN)
204 #define CONTEXT_BIT0(field) CONTEXT_FIELD(field, TYPE_BIT_0)
205 #define CONTEXT_BIT1(field) CONTEXT_FIELD(field, TYPE_BIT_1)
206 #define CONTEXT_BIT2(field) CONTEXT_FIELD(field, TYPE_BIT_2)
207 #define CONTEXT_BIT3(field) CONTEXT_FIELD(field, TYPE_BIT_3)
208 #define CONTEXT_BIT4(field) CONTEXT_FIELD(field, TYPE_BIT_4)
209 #define CONTEXT_BIT5(field) CONTEXT_FIELD(field, TYPE_BIT_5)
210 #define CONTEXT_BIT6(field) CONTEXT_FIELD(field, TYPE_BIT_6)
211 #define CONTEXT_BIT7(field) CONTEXT_FIELD(field, TYPE_BIT_7)
212 #define CONTEXT_FLOAT(field) CONTEXT_FIELD(field, TYPE_FLOAT)
213 #define CONTEXT_FLOAT2(field) CONTEXT_FIELD(field, TYPE_FLOAT_2)
214 #define CONTEXT_FLOAT3(field) CONTEXT_FIELD(field, TYPE_FLOAT_3)
215 #define CONTEXT_FLOAT4(field) CONTEXT_FIELD(field, TYPE_FLOAT_4)
216 #define CONTEXT_MATRIX(field) CONTEXT_FIELD(field, TYPE_MATRIX)
217 #define CONTEXT_MATRIX_T(field) CONTEXT_FIELD(field, TYPE_MATRIX_T)
219 #define ARRAY_INT(field) ARRAY_FIELD(field, TYPE_INT)
220 #define ARRAY_ENUM(field) ARRAY_FIELD(field, TYPE_ENUM)
221 #define ARRAY_BOOL(field) ARRAY_FIELD(field, TYPE_BOOLEAN)
224 offsetof(struct gl_extensions, f)
226 #define EXTRA_EXT(e) \
227 static const int extra_##e[] = { \
231 #define EXTRA_EXT2(e1, e2) \
232 static const int extra_##e1##_##e2[] = { \
233 EXT(e1), EXT(e2), EXTRA_END \
236 /* The 'extra' mechanism is a way to specify extra checks (such as
237 * extensions or specific gl versions) or actions (flush current, new
238 * buffers) that we need to do before looking up an enum. We need to
239 * declare them all up front so we can refer to them in the value_desc
242 * Each EXTRA_ will be executed. For EXTRA_* enums of extensions and API
243 * versions, listing multiple ones in an array means an error will be thrown
244 * only if none of them are available. If you need to check for "AND"
245 * behavior, you would need to make a custom EXTRA_ enum.
248 static const int extra_new_buffers
[] = {
253 static const int extra_new_frag_clamp
[] = {
254 EXTRA_NEW_FRAG_CLAMP
,
258 static const int extra_valid_draw_buffer
[] = {
259 EXTRA_VALID_DRAW_BUFFER
,
263 static const int extra_valid_texture_unit
[] = {
264 EXTRA_VALID_TEXTURE_UNIT
,
268 static const int extra_valid_clip_distance
[] = {
269 EXTRA_VALID_CLIP_DISTANCE
,
273 static const int extra_flush_current_valid_texture_unit
[] = {
275 EXTRA_VALID_TEXTURE_UNIT
,
279 static const int extra_flush_current
[] = {
284 static const int extra_EXT_texture_integer_and_new_buffers
[] = {
285 EXT(EXT_texture_integer
),
290 static const int extra_GLSL_130_es3
[] = {
296 static const int extra_texture_buffer_object
[] = {
299 EXT(ARB_texture_buffer_object
),
303 static const int extra_ARB_transform_feedback2_api_es3
[] = {
304 EXT(ARB_transform_feedback2
),
309 static const int extra_ARB_uniform_buffer_object_and_geometry_shader
[] = {
314 static const int extra_ARB_ES2_compatibility_api_es2
[] = {
315 EXT(ARB_ES2_compatibility
),
320 static const int extra_ARB_ES3_compatibility_api_es3
[] = {
321 EXT(ARB_ES3_compatibility
),
326 static const int extra_EXT_framebuffer_sRGB_and_new_buffers
[] = {
327 EXT(EXT_framebuffer_sRGB
),
332 static const int extra_EXT_packed_float
[] = {
333 EXT(EXT_packed_float
),
338 static const int extra_EXT_texture_array_es3
[] = {
339 EXT(EXT_texture_array
),
344 static const int extra_ARB_shader_atomic_counters_and_geometry_shader
[] = {
345 EXTRA_EXT_ATOMICS_GS4
,
349 static const int extra_ARB_shader_image_load_store_and_geometry_shader
[] = {
350 EXTRA_EXT_SHADER_IMAGE_GS4
,
354 static const int extra_ARB_shader_atomic_counters_and_tessellation
[] = {
355 EXTRA_EXT_ATOMICS_TESS
,
359 static const int extra_ARB_shader_image_load_store_and_tessellation
[] = {
360 EXTRA_EXT_SHADER_IMAGE_TESS
,
364 static const int extra_ARB_draw_indirect_es31
[] = {
365 EXT(ARB_draw_indirect
),
370 static const int extra_ARB_shader_image_load_store_es31
[] = {
371 EXT(ARB_shader_image_load_store
),
376 static const int extra_ARB_shader_atomic_counters_es31
[] = {
377 EXT(ARB_shader_atomic_counters
),
382 static const int extra_ARB_texture_multisample_es31
[] = {
383 EXT(ARB_texture_multisample
),
388 static const int extra_ARB_texture_gather_es31
[] = {
389 EXT(ARB_texture_gather
),
394 static const int extra_ARB_compute_shader_es31
[] = {
395 EXT(ARB_compute_shader
),
400 EXTRA_EXT(ARB_texture_cube_map
);
401 EXTRA_EXT(EXT_texture_array
);
402 EXTRA_EXT(NV_fog_distance
);
403 EXTRA_EXT(EXT_texture_filter_anisotropic
);
404 EXTRA_EXT(NV_point_sprite
);
405 EXTRA_EXT(NV_texture_rectangle
);
406 EXTRA_EXT(EXT_stencil_two_side
);
407 EXTRA_EXT(EXT_depth_bounds_test
);
408 EXTRA_EXT(ARB_depth_clamp
);
409 EXTRA_EXT(ATI_fragment_shader
);
410 EXTRA_EXT(EXT_provoking_vertex
);
411 EXTRA_EXT(ARB_fragment_shader
);
412 EXTRA_EXT(ARB_fragment_program
);
413 EXTRA_EXT2(ARB_framebuffer_object
, EXT_framebuffer_multisample
);
414 EXTRA_EXT(ARB_seamless_cube_map
);
416 EXTRA_EXT(ARB_vertex_shader
);
417 EXTRA_EXT(EXT_transform_feedback
);
418 EXTRA_EXT(ARB_transform_feedback3
);
419 EXTRA_EXT(EXT_pixel_buffer_object
);
420 EXTRA_EXT(ARB_vertex_program
);
421 EXTRA_EXT2(NV_point_sprite
, ARB_point_sprite
);
422 EXTRA_EXT2(ARB_vertex_program
, ARB_fragment_program
);
423 EXTRA_EXT(ARB_geometry_shader4
);
424 EXTRA_EXT(ARB_color_buffer_float
);
425 EXTRA_EXT(EXT_framebuffer_sRGB
);
426 EXTRA_EXT(OES_EGL_image_external
);
427 EXTRA_EXT(ARB_blend_func_extended
);
428 EXTRA_EXT(ARB_uniform_buffer_object
);
429 EXTRA_EXT(ARB_timer_query
);
430 EXTRA_EXT(ARB_texture_cube_map_array
);
431 EXTRA_EXT(ARB_texture_buffer_range
);
432 EXTRA_EXT(ARB_texture_multisample
);
433 EXTRA_EXT(ARB_texture_gather
);
434 EXTRA_EXT(ARB_shader_atomic_counters
);
435 EXTRA_EXT(ARB_draw_indirect
);
436 EXTRA_EXT(ARB_shader_image_load_store
);
437 EXTRA_EXT(ARB_viewport_array
);
438 EXTRA_EXT(ARB_compute_shader
);
439 EXTRA_EXT(ARB_gpu_shader5
);
440 EXTRA_EXT2(ARB_transform_feedback3
, ARB_gpu_shader5
);
441 EXTRA_EXT(INTEL_performance_query
);
442 EXTRA_EXT(ARB_explicit_uniform_location
);
443 EXTRA_EXT(ARB_clip_control
);
444 EXTRA_EXT(EXT_polygon_offset_clamp
);
445 EXTRA_EXT(ARB_framebuffer_no_attachments
);
446 EXTRA_EXT(ARB_tessellation_shader
);
447 EXTRA_EXT(ARB_shader_subroutine
);
450 extra_ARB_color_buffer_float_or_glcore
[] = {
451 EXT(ARB_color_buffer_float
),
457 extra_NV_primitive_restart
[] = {
458 EXT(NV_primitive_restart
),
462 static const int extra_version_30
[] = { EXTRA_VERSION_30
, EXTRA_END
};
463 static const int extra_version_31
[] = { EXTRA_VERSION_31
, EXTRA_END
};
464 static const int extra_version_32
[] = { EXTRA_VERSION_32
, EXTRA_END
};
465 static const int extra_version_40
[] = { EXTRA_VERSION_40
, EXTRA_END
};
467 static const int extra_gl30_es3
[] = {
473 static const int extra_gl32_es3
[] = {
479 static const int extra_gl32_ARB_geometry_shader4
[] = {
481 EXT(ARB_geometry_shader4
),
485 static const int extra_gl40_ARB_sample_shading
[] = {
487 EXT(ARB_sample_shading
),
492 extra_ARB_vertex_program_api_es2
[] = {
493 EXT(ARB_vertex_program
),
498 /* The ReadBuffer get token is valid under either full GL or under
499 * GLES2 if the NV_read_buffer extension is available. */
501 extra_NV_read_buffer_api_gl
[] = {
507 static const int extra_core_ARB_color_buffer_float_and_new_buffers
[] = {
509 EXT(ARB_color_buffer_float
),
514 /* This is the big table describing all the enums we accept in
515 * glGet*v(). The table is partitioned into six parts: enums
516 * understood by all GL APIs (OpenGL, GLES and GLES2), enums shared
517 * between OpenGL and GLES, enums exclusive to GLES, etc for the
518 * remaining combinations. To look up the enums valid in a given API
519 * we will use a hash table specific to that API. These tables are in
520 * turn generated at build time and included through get_hash.h.
523 #include "get_hash.h"
525 /* All we need now is a way to look up the value struct from the enum.
526 * The code generated by gcc for the old generated big switch
527 * statement is a big, balanced, open coded if/else tree, essentially
528 * an unrolled binary search. It would be natural to sort the new
529 * enum table and use bsearch(), but we will use a read-only hash
530 * table instead. bsearch() has a nice guaranteed worst case
531 * performance, but we're also guaranteed to hit that worst case
532 * (log2(n) iterations) for about half the enums. Instead, using an
533 * open addressing hash table, we can find the enum on the first try
534 * for 80% of the enums, 1 collision for 10% and never more than 5
535 * collisions for any enum (typical numbers). And the code is very
536 * simple, even though it feels a little magic. */
540 print_table_stats(int api
)
542 int i
, j
, collisions
[11], count
, hash
, mask
;
543 const struct value_desc
*d
;
544 const char *api_names
[] = {
545 [API_OPENGL_COMPAT
] = "GL",
546 [API_OPENGL_CORE
] = "GL_CORE",
547 [API_OPENGLES
] = "GLES",
548 [API_OPENGLES2
] = "GLES2",
550 const char *api_name
;
552 api_name
= api
< ARRAY_SIZE(api_names
) ? api_names
[api
] : "N/A";
554 mask
= ARRAY_SIZE(table(api
)) - 1;
555 memset(collisions
, 0, sizeof collisions
);
557 for (i
= 0; i
< ARRAY_SIZE(table(api
)); i
++) {
561 d
= &values
[table(api
)[i
]];
562 hash
= (d
->pname
* prime_factor
);
565 if (values
[table(api
)[hash
& mask
]].pname
== d
->pname
)
577 printf("number of enums for %s: %d (total %ld)\n",
578 api_name
, count
, ARRAY_SIZE(values
));
579 for (i
= 0; i
< ARRAY_SIZE(collisions
) - 1; i
++)
580 if (collisions
[i
] > 0)
581 printf(" %d enums with %d %scollisions\n",
582 collisions
[i
], i
, i
== 10 ? "or more " : "");
587 * Initialize the enum hash for a given API
589 * This is called from one_time_init() to insert the enum values that
590 * are valid for the API in question into the enum hash table.
592 * \param the current context, for determining the API in question
594 void _mesa_init_get_hash(struct gl_context
*ctx
)
597 print_table_stats(ctx
->API
);
604 * Handle irregular enums
606 * Some values don't conform to the "well-known type at context
607 * pointer + offset" pattern, so we have this function to catch all
608 * the corner cases. Typically, it's a computed value or a one-off
609 * pointer to a custom struct or something.
611 * In this case we can't return a pointer to the value, so we'll have
612 * to use the temporary variable 'v' declared back in the calling
613 * glGet*v() function to store the result.
615 * \param ctx the current context
616 * \param d the struct value_desc that describes the enum
617 * \param v pointer to the tmp declared in the calling glGet*v() function
620 find_custom_value(struct gl_context
*ctx
, const struct value_desc
*d
, union value
*v
)
622 struct gl_buffer_object
**buffer_obj
;
623 struct gl_vertex_attrib_array
*array
;
627 case GL_MAJOR_VERSION
:
628 v
->value_int
= ctx
->Version
/ 10;
630 case GL_MINOR_VERSION
:
631 v
->value_int
= ctx
->Version
% 10;
637 case GL_TEXTURE_CUBE_MAP_ARB
:
638 case GL_TEXTURE_RECTANGLE_NV
:
639 case GL_TEXTURE_EXTERNAL_OES
:
640 v
->value_bool
= _mesa_IsEnabled(d
->pname
);
643 case GL_LINE_STIPPLE_PATTERN
:
644 /* This is the only GLushort, special case it here by promoting
645 * to an int rather than introducing a new type. */
646 v
->value_int
= ctx
->Line
.StipplePattern
;
649 case GL_CURRENT_RASTER_TEXTURE_COORDS
:
650 unit
= ctx
->Texture
.CurrentUnit
;
651 v
->value_float_4
[0] = ctx
->Current
.RasterTexCoords
[unit
][0];
652 v
->value_float_4
[1] = ctx
->Current
.RasterTexCoords
[unit
][1];
653 v
->value_float_4
[2] = ctx
->Current
.RasterTexCoords
[unit
][2];
654 v
->value_float_4
[3] = ctx
->Current
.RasterTexCoords
[unit
][3];
657 case GL_CURRENT_TEXTURE_COORDS
:
658 unit
= ctx
->Texture
.CurrentUnit
;
659 v
->value_float_4
[0] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
][0];
660 v
->value_float_4
[1] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
][1];
661 v
->value_float_4
[2] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
][2];
662 v
->value_float_4
[3] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
][3];
665 case GL_COLOR_WRITEMASK
:
666 v
->value_int_4
[0] = ctx
->Color
.ColorMask
[0][RCOMP
] ? 1 : 0;
667 v
->value_int_4
[1] = ctx
->Color
.ColorMask
[0][GCOMP
] ? 1 : 0;
668 v
->value_int_4
[2] = ctx
->Color
.ColorMask
[0][BCOMP
] ? 1 : 0;
669 v
->value_int_4
[3] = ctx
->Color
.ColorMask
[0][ACOMP
] ? 1 : 0;
673 v
->value_bool
= ctx
->Current
.Attrib
[VERT_ATTRIB_EDGEFLAG
][0] == 1.0;
677 v
->value_enum
= ctx
->ReadBuffer
->ColorReadBuffer
;
680 case GL_MAP2_GRID_DOMAIN
:
681 v
->value_float_4
[0] = ctx
->Eval
.MapGrid2u1
;
682 v
->value_float_4
[1] = ctx
->Eval
.MapGrid2u2
;
683 v
->value_float_4
[2] = ctx
->Eval
.MapGrid2v1
;
684 v
->value_float_4
[3] = ctx
->Eval
.MapGrid2v2
;
687 case GL_TEXTURE_STACK_DEPTH
:
688 unit
= ctx
->Texture
.CurrentUnit
;
689 v
->value_int
= ctx
->TextureMatrixStack
[unit
].Depth
+ 1;
691 case GL_TEXTURE_MATRIX
:
692 unit
= ctx
->Texture
.CurrentUnit
;
693 v
->value_matrix
= ctx
->TextureMatrixStack
[unit
].Top
;
696 case GL_TEXTURE_COORD_ARRAY
:
697 case GL_TEXTURE_COORD_ARRAY_SIZE
:
698 case GL_TEXTURE_COORD_ARRAY_TYPE
:
699 case GL_TEXTURE_COORD_ARRAY_STRIDE
:
700 array
= &ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_TEX(ctx
->Array
.ActiveTexture
)];
701 v
->value_int
= *(GLuint
*) ((char *) array
+ d
->offset
);
704 case GL_ACTIVE_TEXTURE_ARB
:
705 v
->value_int
= GL_TEXTURE0_ARB
+ ctx
->Texture
.CurrentUnit
;
707 case GL_CLIENT_ACTIVE_TEXTURE_ARB
:
708 v
->value_int
= GL_TEXTURE0_ARB
+ ctx
->Array
.ActiveTexture
;
711 case GL_MODELVIEW_STACK_DEPTH
:
712 case GL_PROJECTION_STACK_DEPTH
:
713 v
->value_int
= *(GLint
*) ((char *) ctx
+ d
->offset
) + 1;
716 case GL_MAX_TEXTURE_SIZE
:
717 case GL_MAX_3D_TEXTURE_SIZE
:
718 case GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB
:
719 p
= (GLuint
*) ((char *) ctx
+ d
->offset
);
720 v
->value_int
= 1 << (*p
- 1);
724 v
->value_int_4
[0] = ctx
->Scissor
.ScissorArray
[0].X
;
725 v
->value_int_4
[1] = ctx
->Scissor
.ScissorArray
[0].Y
;
726 v
->value_int_4
[2] = ctx
->Scissor
.ScissorArray
[0].Width
;
727 v
->value_int_4
[3] = ctx
->Scissor
.ScissorArray
[0].Height
;
730 case GL_SCISSOR_TEST
:
731 v
->value_bool
= ctx
->Scissor
.EnableFlags
& 1;
736 ctx
->ListState
.CurrentList
? ctx
->ListState
.CurrentList
->Name
: 0;
739 if (!ctx
->CompileFlag
)
741 else if (ctx
->ExecuteFlag
)
742 v
->value_enum
= GL_COMPILE_AND_EXECUTE
;
744 v
->value_enum
= GL_COMPILE
;
748 v
->value_float_4
[0] = ctx
->ViewportArray
[0].X
;
749 v
->value_float_4
[1] = ctx
->ViewportArray
[0].Y
;
750 v
->value_float_4
[2] = ctx
->ViewportArray
[0].Width
;
751 v
->value_float_4
[3] = ctx
->ViewportArray
[0].Height
;
755 v
->value_double_2
[0] = ctx
->ViewportArray
[0].Near
;
756 v
->value_double_2
[1] = ctx
->ViewportArray
[0].Far
;
759 case GL_ACTIVE_STENCIL_FACE_EXT
:
760 v
->value_enum
= ctx
->Stencil
.ActiveFace
? GL_BACK
: GL_FRONT
;
763 case GL_STENCIL_FAIL
:
764 v
->value_enum
= ctx
->Stencil
.FailFunc
[ctx
->Stencil
.ActiveFace
];
766 case GL_STENCIL_FUNC
:
767 v
->value_enum
= ctx
->Stencil
.Function
[ctx
->Stencil
.ActiveFace
];
769 case GL_STENCIL_PASS_DEPTH_FAIL
:
770 v
->value_enum
= ctx
->Stencil
.ZFailFunc
[ctx
->Stencil
.ActiveFace
];
772 case GL_STENCIL_PASS_DEPTH_PASS
:
773 v
->value_enum
= ctx
->Stencil
.ZPassFunc
[ctx
->Stencil
.ActiveFace
];
776 v
->value_int
= _mesa_get_stencil_ref(ctx
, ctx
->Stencil
.ActiveFace
);
778 case GL_STENCIL_BACK_REF
:
779 v
->value_int
= _mesa_get_stencil_ref(ctx
, 1);
781 case GL_STENCIL_VALUE_MASK
:
782 v
->value_int
= ctx
->Stencil
.ValueMask
[ctx
->Stencil
.ActiveFace
];
784 case GL_STENCIL_WRITEMASK
:
785 v
->value_int
= ctx
->Stencil
.WriteMask
[ctx
->Stencil
.ActiveFace
];
788 case GL_NUM_EXTENSIONS
:
789 v
->value_int
= _mesa_get_extension_count(ctx
);
792 case GL_IMPLEMENTATION_COLOR_READ_TYPE_OES
:
793 v
->value_int
= _mesa_get_color_read_type(ctx
);
795 case GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES
:
796 v
->value_int
= _mesa_get_color_read_format(ctx
);
799 case GL_CURRENT_MATRIX_STACK_DEPTH_ARB
:
800 v
->value_int
= ctx
->CurrentStack
->Depth
+ 1;
802 case GL_CURRENT_MATRIX_ARB
:
803 case GL_TRANSPOSE_CURRENT_MATRIX_ARB
:
804 v
->value_matrix
= ctx
->CurrentStack
->Top
;
807 case GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB
:
808 v
->value_int
= _mesa_get_compressed_formats(ctx
, NULL
);
810 case GL_COMPRESSED_TEXTURE_FORMATS_ARB
:
812 _mesa_get_compressed_formats(ctx
, v
->value_int_n
.ints
);
813 assert(v
->value_int_n
.n
<= (int) ARRAY_SIZE(v
->value_int_n
.ints
));
816 case GL_MAX_VARYING_FLOATS_ARB
:
817 v
->value_int
= ctx
->Const
.MaxVarying
* 4;
820 /* Various object names */
822 case GL_TEXTURE_BINDING_1D
:
823 case GL_TEXTURE_BINDING_2D
:
824 case GL_TEXTURE_BINDING_3D
:
825 case GL_TEXTURE_BINDING_1D_ARRAY_EXT
:
826 case GL_TEXTURE_BINDING_2D_ARRAY_EXT
:
827 case GL_TEXTURE_BINDING_CUBE_MAP_ARB
:
828 case GL_TEXTURE_BINDING_RECTANGLE_NV
:
829 case GL_TEXTURE_BINDING_EXTERNAL_OES
:
830 case GL_TEXTURE_BINDING_CUBE_MAP_ARRAY
:
831 case GL_TEXTURE_BINDING_2D_MULTISAMPLE
:
832 case GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY
:
833 unit
= ctx
->Texture
.CurrentUnit
;
835 ctx
->Texture
.Unit
[unit
].CurrentTex
[d
->offset
]->Name
;
838 /* GL_EXT_packed_float */
839 case GL_RGBA_SIGNED_COMPONENTS_EXT
:
841 /* Note: we only check the 0th color attachment. */
842 const struct gl_renderbuffer
*rb
=
843 ctx
->DrawBuffer
->_ColorDrawBuffers
[0];
844 if (rb
&& _mesa_is_format_signed(rb
->Format
)) {
845 /* Issue 17 of GL_EXT_packed_float: If a component (such as
846 * alpha) has zero bits, the component should not be considered
847 * signed and so the bit for the respective component should be
851 _mesa_get_format_bits(rb
->Format
, GL_RED_BITS
);
853 _mesa_get_format_bits(rb
->Format
, GL_GREEN_BITS
);
855 _mesa_get_format_bits(rb
->Format
, GL_BLUE_BITS
);
857 _mesa_get_format_bits(rb
->Format
, GL_ALPHA_BITS
);
859 _mesa_get_format_bits(rb
->Format
, GL_TEXTURE_LUMINANCE_SIZE
);
861 _mesa_get_format_bits(rb
->Format
, GL_TEXTURE_INTENSITY_SIZE
);
863 v
->value_int_4
[0] = r_bits
+ l_bits
+ i_bits
> 0;
864 v
->value_int_4
[1] = g_bits
+ l_bits
+ i_bits
> 0;
865 v
->value_int_4
[2] = b_bits
+ l_bits
+ i_bits
> 0;
866 v
->value_int_4
[3] = a_bits
+ i_bits
> 0;
872 v
->value_int_4
[3] = 0;
877 /* GL_ARB_vertex_buffer_object */
878 case GL_VERTEX_ARRAY_BUFFER_BINDING_ARB
:
879 case GL_NORMAL_ARRAY_BUFFER_BINDING_ARB
:
880 case GL_COLOR_ARRAY_BUFFER_BINDING_ARB
:
881 case GL_INDEX_ARRAY_BUFFER_BINDING_ARB
:
882 case GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB
:
883 case GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB
:
884 case GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB
:
885 buffer_obj
= (struct gl_buffer_object
**)
886 ((char *) ctx
->Array
.VAO
+ d
->offset
);
887 v
->value_int
= (*buffer_obj
)->Name
;
889 case GL_ARRAY_BUFFER_BINDING_ARB
:
890 v
->value_int
= ctx
->Array
.ArrayBufferObj
->Name
;
892 case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB
:
894 ctx
->Array
.VAO
->VertexBinding
[VERT_ATTRIB_TEX(ctx
->Array
.ActiveTexture
)].BufferObj
->Name
;
896 case GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB
:
897 v
->value_int
= ctx
->Array
.VAO
->IndexBufferObj
->Name
;
900 /* ARB_vertex_array_bgra */
901 case GL_COLOR_ARRAY_SIZE
:
902 array
= &ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_COLOR0
];
903 v
->value_int
= array
->Format
== GL_BGRA
? GL_BGRA
: array
->Size
;
905 case GL_SECONDARY_COLOR_ARRAY_SIZE
:
906 array
= &ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_COLOR1
];
907 v
->value_int
= array
->Format
== GL_BGRA
? GL_BGRA
: array
->Size
;
910 /* ARB_copy_buffer */
911 case GL_COPY_READ_BUFFER
:
912 v
->value_int
= ctx
->CopyReadBuffer
->Name
;
914 case GL_COPY_WRITE_BUFFER
:
915 v
->value_int
= ctx
->CopyWriteBuffer
->Name
;
918 case GL_PIXEL_PACK_BUFFER_BINDING_EXT
:
919 v
->value_int
= ctx
->Pack
.BufferObj
->Name
;
921 case GL_PIXEL_UNPACK_BUFFER_BINDING_EXT
:
922 v
->value_int
= ctx
->Unpack
.BufferObj
->Name
;
924 case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING
:
925 v
->value_int
= ctx
->TransformFeedback
.CurrentBuffer
->Name
;
927 case GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED
:
928 v
->value_int
= ctx
->TransformFeedback
.CurrentObject
->Paused
;
930 case GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE
:
931 v
->value_int
= ctx
->TransformFeedback
.CurrentObject
->Active
;
933 case GL_TRANSFORM_FEEDBACK_BINDING
:
934 v
->value_int
= ctx
->TransformFeedback
.CurrentObject
->Name
;
936 case GL_CURRENT_PROGRAM
:
937 /* The Changelog of the ARB_separate_shader_objects spec says:
939 * 24 25 Jul 2011 pbrown Remove the language erroneously deleting
940 * CURRENT_PROGRAM. In the EXT extension, this
941 * token was aliased to ACTIVE_PROGRAM_EXT, and
942 * was used to indicate the last program set by
943 * either ActiveProgramEXT or UseProgram. In
944 * the ARB extension, the SSO active programs
945 * are now program pipeline object state and
946 * CURRENT_PROGRAM should still be used to query
947 * the last program set by UseProgram (bug 7822).
950 ctx
->Shader
.ActiveProgram
? ctx
->Shader
.ActiveProgram
->Name
: 0;
952 case GL_READ_FRAMEBUFFER_BINDING_EXT
:
953 v
->value_int
= ctx
->ReadBuffer
->Name
;
955 case GL_RENDERBUFFER_BINDING_EXT
:
957 ctx
->CurrentRenderbuffer
? ctx
->CurrentRenderbuffer
->Name
: 0;
959 case GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES
:
960 v
->value_int
= ctx
->Array
.VAO
->VertexBinding
[VERT_ATTRIB_POINT_SIZE
].BufferObj
->Name
;
964 if (_mesa_get_clamp_fragment_color(ctx
, ctx
->DrawBuffer
))
965 COPY_4FV(v
->value_float_4
, ctx
->Fog
.Color
);
967 COPY_4FV(v
->value_float_4
, ctx
->Fog
.ColorUnclamped
);
969 case GL_COLOR_CLEAR_VALUE
:
970 if (_mesa_get_clamp_fragment_color(ctx
, ctx
->DrawBuffer
)) {
971 v
->value_float_4
[0] = CLAMP(ctx
->Color
.ClearColor
.f
[0], 0.0F
, 1.0F
);
972 v
->value_float_4
[1] = CLAMP(ctx
->Color
.ClearColor
.f
[1], 0.0F
, 1.0F
);
973 v
->value_float_4
[2] = CLAMP(ctx
->Color
.ClearColor
.f
[2], 0.0F
, 1.0F
);
974 v
->value_float_4
[3] = CLAMP(ctx
->Color
.ClearColor
.f
[3], 0.0F
, 1.0F
);
976 COPY_4FV(v
->value_float_4
, ctx
->Color
.ClearColor
.f
);
978 case GL_BLEND_COLOR_EXT
:
979 if (_mesa_get_clamp_fragment_color(ctx
, ctx
->DrawBuffer
))
980 COPY_4FV(v
->value_float_4
, ctx
->Color
.BlendColor
);
982 COPY_4FV(v
->value_float_4
, ctx
->Color
.BlendColorUnclamped
);
984 case GL_ALPHA_TEST_REF
:
985 if (_mesa_get_clamp_fragment_color(ctx
, ctx
->DrawBuffer
))
986 v
->value_float
= ctx
->Color
.AlphaRef
;
988 v
->value_float
= ctx
->Color
.AlphaRefUnclamped
;
990 case GL_MAX_VERTEX_UNIFORM_VECTORS
:
991 v
->value_int
= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxUniformComponents
/ 4;
994 case GL_MAX_FRAGMENT_UNIFORM_VECTORS
:
995 v
->value_int
= ctx
->Const
.Program
[MESA_SHADER_FRAGMENT
].MaxUniformComponents
/ 4;
998 /* GL_ARB_texture_buffer_object */
999 case GL_TEXTURE_BUFFER_ARB
:
1000 v
->value_int
= ctx
->Texture
.BufferObject
->Name
;
1002 case GL_TEXTURE_BINDING_BUFFER_ARB
:
1003 unit
= ctx
->Texture
.CurrentUnit
;
1005 ctx
->Texture
.Unit
[unit
].CurrentTex
[TEXTURE_BUFFER_INDEX
]->Name
;
1007 case GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB
:
1009 struct gl_buffer_object
*buf
=
1010 ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
]
1011 .CurrentTex
[TEXTURE_BUFFER_INDEX
]->BufferObject
;
1012 v
->value_int
= buf
? buf
->Name
: 0;
1015 case GL_TEXTURE_BUFFER_FORMAT_ARB
:
1016 v
->value_int
= ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
]
1017 .CurrentTex
[TEXTURE_BUFFER_INDEX
]->BufferObjectFormat
;
1020 /* GL_ARB_sampler_objects */
1021 case GL_SAMPLER_BINDING
:
1023 struct gl_sampler_object
*samp
=
1024 ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
].Sampler
;
1027 * The sampler object may have been deleted on another context,
1028 * so we try to lookup the sampler object before returning its Name.
1030 if (samp
&& _mesa_lookup_samplerobj(ctx
, samp
->Name
)) {
1031 v
->value_int
= samp
->Name
;
1037 /* GL_ARB_uniform_buffer_object */
1038 case GL_UNIFORM_BUFFER_BINDING
:
1039 v
->value_int
= ctx
->UniformBuffer
->Name
;
1041 /* GL_ARB_timer_query */
1043 if (ctx
->Driver
.GetTimestamp
) {
1044 v
->value_int64
= ctx
->Driver
.GetTimestamp(ctx
);
1047 _mesa_problem(ctx
, "driver doesn't implement GetTimestamp");
1051 case GL_DEBUG_LOGGED_MESSAGES
:
1052 case GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH
:
1053 case GL_DEBUG_GROUP_STACK_DEPTH
:
1054 v
->value_int
= _mesa_get_debug_state_int(ctx
, d
->pname
);
1056 /* GL_ARB_shader_atomic_counters */
1057 case GL_ATOMIC_COUNTER_BUFFER_BINDING
:
1058 if (ctx
->AtomicBuffer
) {
1059 v
->value_int
= ctx
->AtomicBuffer
->Name
;
1064 /* GL_ARB_draw_indirect */
1065 case GL_DRAW_INDIRECT_BUFFER_BINDING
:
1066 v
->value_int
= ctx
->DrawIndirectBuffer
->Name
;
1068 /* GL_ARB_separate_shader_objects */
1069 case GL_PROGRAM_PIPELINE_BINDING
:
1070 if (ctx
->Pipeline
.Current
) {
1071 v
->value_int
= ctx
->Pipeline
.Current
->Name
;
1080 * Check extra constraints on a struct value_desc descriptor
1082 * If a struct value_desc has a non-NULL extra pointer, it means that
1083 * there are a number of extra constraints to check or actions to
1084 * perform. The extras is just an integer array where each integer
1085 * encode different constraints or actions.
1087 * \param ctx current context
1088 * \param func name of calling glGet*v() function for error reporting
1089 * \param d the struct value_desc that has the extra constraints
1091 * \return GL_FALSE if all of the constraints were not satisfied,
1092 * otherwise GL_TRUE.
1095 check_extra(struct gl_context
*ctx
, const char *func
, const struct value_desc
*d
)
1097 const GLuint version
= ctx
->Version
;
1098 GLboolean api_check
= GL_FALSE
;
1099 GLboolean api_found
= GL_FALSE
;
1102 for (e
= d
->extra
; *e
!= EXTRA_END
; e
++) {
1104 case EXTRA_VERSION_30
:
1105 api_check
= GL_TRUE
;
1107 api_found
= GL_TRUE
;
1109 case EXTRA_VERSION_31
:
1110 api_check
= GL_TRUE
;
1112 api_found
= GL_TRUE
;
1114 case EXTRA_VERSION_32
:
1115 api_check
= GL_TRUE
;
1117 api_found
= GL_TRUE
;
1119 case EXTRA_NEW_FRAG_CLAMP
:
1120 if (ctx
->NewState
& (_NEW_BUFFERS
| _NEW_FRAG_CLAMP
))
1121 _mesa_update_state(ctx
);
1124 api_check
= GL_TRUE
;
1125 if (ctx
->API
== API_OPENGLES2
)
1126 api_found
= GL_TRUE
;
1129 api_check
= GL_TRUE
;
1130 if (_mesa_is_gles3(ctx
))
1131 api_found
= GL_TRUE
;
1133 case EXTRA_API_ES31
:
1134 api_check
= GL_TRUE
;
1135 if (_mesa_is_gles31(ctx
))
1136 api_found
= GL_TRUE
;
1139 api_check
= GL_TRUE
;
1140 if (_mesa_is_desktop_gl(ctx
))
1141 api_found
= GL_TRUE
;
1143 case EXTRA_API_GL_CORE
:
1144 api_check
= GL_TRUE
;
1145 if (ctx
->API
== API_OPENGL_CORE
)
1146 api_found
= GL_TRUE
;
1148 case EXTRA_NEW_BUFFERS
:
1149 if (ctx
->NewState
& _NEW_BUFFERS
)
1150 _mesa_update_state(ctx
);
1152 case EXTRA_FLUSH_CURRENT
:
1153 FLUSH_CURRENT(ctx
, 0);
1155 case EXTRA_VALID_DRAW_BUFFER
:
1156 if (d
->pname
- GL_DRAW_BUFFER0_ARB
>= ctx
->Const
.MaxDrawBuffers
) {
1157 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(draw buffer %u)",
1158 func
, d
->pname
- GL_DRAW_BUFFER0_ARB
);
1162 case EXTRA_VALID_TEXTURE_UNIT
:
1163 if (ctx
->Texture
.CurrentUnit
>= ctx
->Const
.MaxTextureCoordUnits
) {
1164 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(texture %u)",
1165 func
, ctx
->Texture
.CurrentUnit
);
1169 case EXTRA_VALID_CLIP_DISTANCE
:
1170 if (d
->pname
- GL_CLIP_DISTANCE0
>= ctx
->Const
.MaxClipPlanes
) {
1171 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(clip distance %u)",
1172 func
, d
->pname
- GL_CLIP_DISTANCE0
);
1176 case EXTRA_GLSL_130
:
1177 api_check
= GL_TRUE
;
1178 if (ctx
->Const
.GLSLVersion
>= 130)
1179 api_found
= GL_TRUE
;
1181 case EXTRA_EXT_UBO_GS4
:
1182 api_check
= GL_TRUE
;
1183 api_found
= (ctx
->Extensions
.ARB_uniform_buffer_object
&&
1184 _mesa_has_geometry_shaders(ctx
));
1186 case EXTRA_EXT_ATOMICS_GS4
:
1187 api_check
= GL_TRUE
;
1188 api_found
= (ctx
->Extensions
.ARB_shader_atomic_counters
&&
1189 _mesa_has_geometry_shaders(ctx
));
1191 case EXTRA_EXT_SHADER_IMAGE_GS4
:
1192 api_check
= GL_TRUE
;
1193 api_found
= (ctx
->Extensions
.ARB_shader_image_load_store
&&
1194 _mesa_has_geometry_shaders(ctx
));
1196 case EXTRA_EXT_ATOMICS_TESS
:
1197 api_check
= GL_TRUE
;
1198 api_found
= ctx
->Extensions
.ARB_shader_atomic_counters
&&
1199 _mesa_has_tessellation(ctx
);
1201 case EXTRA_EXT_SHADER_IMAGE_TESS
:
1202 api_check
= GL_TRUE
;
1203 api_found
= ctx
->Extensions
.ARB_shader_image_load_store
&&
1204 _mesa_has_tessellation(ctx
);
1208 default: /* *e is a offset into the extension struct */
1209 api_check
= GL_TRUE
;
1210 if (*(GLboolean
*) ((char *) &ctx
->Extensions
+ *e
))
1211 api_found
= GL_TRUE
;
1216 if (api_check
&& !api_found
) {
1217 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(pname=%s)", func
,
1218 _mesa_enum_to_string(d
->pname
));
1225 static const struct value_desc error_value
=
1226 { 0, 0, TYPE_INVALID
, NO_OFFSET
, NO_EXTRA
};
1229 * Find the struct value_desc corresponding to the enum 'pname'.
1231 * We hash the enum value to get an index into the 'table' array,
1232 * which holds the index in the 'values' array of struct value_desc.
1233 * Once we've found the entry, we do the extra checks, if any, then
1234 * look up the value and return a pointer to it.
1236 * If the value has to be computed (for example, it's the result of a
1237 * function call or we need to add 1 to it), we use the tmp 'v' to
1240 * \param func name of glGet*v() func for error reporting
1241 * \param pname the enum value we're looking up
1242 * \param p is were we return the pointer to the value
1243 * \param v a tmp union value variable in the calling glGet*v() function
1245 * \return the struct value_desc corresponding to the enum or a struct
1246 * value_desc of TYPE_INVALID if not found. This lets the calling
1247 * glGet*v() function jump right into a switch statement and
1248 * handle errors there instead of having to check for NULL.
1250 static const struct value_desc
*
1251 find_value(const char *func
, GLenum pname
, void **p
, union value
*v
)
1253 GET_CURRENT_CONTEXT(ctx
);
1254 struct gl_texture_unit
*unit
;
1256 const struct value_desc
*d
;
1260 /* We index into the table_set[] list of per-API hash tables using the API's
1261 * value in the gl_api enum. Since GLES 3 doesn't have an API_OPENGL* enum
1262 * value since it's compatible with GLES2 its entry in table_set[] is at the
1265 STATIC_ASSERT(ARRAY_SIZE(table_set
) == API_OPENGL_LAST
+ 3);
1266 if (_mesa_is_gles3(ctx
)) {
1267 api
= API_OPENGL_LAST
+ 1;
1269 if (_mesa_is_gles31(ctx
)) {
1270 api
= API_OPENGL_LAST
+ 2;
1272 mask
= ARRAY_SIZE(table(api
)) - 1;
1273 hash
= (pname
* prime_factor
);
1275 int idx
= table(api
)[hash
& mask
];
1277 /* If the enum isn't valid, the hash walk ends with index 0,
1278 * pointing to the first entry of values[] which doesn't hold
1279 * any valid enum. */
1280 if (unlikely(idx
== 0)) {
1281 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(pname=%s)", func
,
1282 _mesa_enum_to_string(pname
));
1283 return &error_value
;
1287 if (likely(d
->pname
== pname
))
1293 if (unlikely(d
->extra
&& !check_extra(ctx
, func
, d
)))
1294 return &error_value
;
1296 switch (d
->location
) {
1298 *p
= ((char *) ctx
->DrawBuffer
+ d
->offset
);
1301 *p
= ((char *) ctx
+ d
->offset
);
1304 *p
= ((char *) ctx
->Array
.VAO
+ d
->offset
);
1307 unit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1308 *p
= ((char *) unit
+ d
->offset
);
1311 find_custom_value(ctx
, d
, v
);
1319 /* silence warning */
1320 return &error_value
;
1323 static const int transpose
[] = {
1331 _mesa_GetBooleanv(GLenum pname
, GLboolean
*params
)
1333 const struct value_desc
*d
;
1339 d
= find_value("glGetBooleanv", pname
, &p
, &v
);
1344 params
[0] = INT_TO_BOOLEAN(d
->offset
);
1349 params
[3] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[3]);
1352 params
[2] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[2]);
1355 params
[1] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[1]);
1358 params
[0] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[0]);
1361 case TYPE_DOUBLEN_2
:
1362 params
[1] = FLOAT_TO_BOOLEAN(((GLdouble
*) p
)[1]);
1364 params
[0] = FLOAT_TO_BOOLEAN(((GLdouble
*) p
)[0]);
1368 params
[3] = INT_TO_BOOLEAN(((GLint
*) p
)[3]);
1370 params
[2] = INT_TO_BOOLEAN(((GLint
*) p
)[2]);
1373 params
[1] = INT_TO_BOOLEAN(((GLint
*) p
)[1]);
1376 params
[0] = INT_TO_BOOLEAN(((GLint
*) p
)[0]);
1380 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
1381 params
[i
] = INT_TO_BOOLEAN(v
.value_int_n
.ints
[i
]);
1385 params
[0] = INT64_TO_BOOLEAN(((GLint64
*) p
)[0]);
1389 params
[0] = ((GLboolean
*) p
)[0];
1393 m
= *(GLmatrix
**) p
;
1394 for (i
= 0; i
< 16; i
++)
1395 params
[i
] = FLOAT_TO_BOOLEAN(m
->m
[i
]);
1399 m
= *(GLmatrix
**) p
;
1400 for (i
= 0; i
< 16; i
++)
1401 params
[i
] = FLOAT_TO_BOOLEAN(m
->m
[transpose
[i
]]);
1412 shift
= d
->type
- TYPE_BIT_0
;
1413 params
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
1419 _mesa_GetFloatv(GLenum pname
, GLfloat
*params
)
1421 const struct value_desc
*d
;
1427 d
= find_value("glGetFloatv", pname
, &p
, &v
);
1432 params
[0] = (GLfloat
) d
->offset
;
1437 params
[3] = ((GLfloat
*) p
)[3];
1440 params
[2] = ((GLfloat
*) p
)[2];
1443 params
[1] = ((GLfloat
*) p
)[1];
1446 params
[0] = ((GLfloat
*) p
)[0];
1449 case TYPE_DOUBLEN_2
:
1450 params
[1] = (GLfloat
) (((GLdouble
*) p
)[1]);
1452 params
[0] = (GLfloat
) (((GLdouble
*) p
)[0]);
1456 params
[3] = (GLfloat
) (((GLint
*) p
)[3]);
1458 params
[2] = (GLfloat
) (((GLint
*) p
)[2]);
1461 params
[1] = (GLfloat
) (((GLint
*) p
)[1]);
1464 params
[0] = (GLfloat
) (((GLint
*) p
)[0]);
1468 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
1469 params
[i
] = INT_TO_FLOAT(v
.value_int_n
.ints
[i
]);
1473 params
[0] = (GLfloat
) (((GLint64
*) p
)[0]);
1477 params
[0] = BOOLEAN_TO_FLOAT(*(GLboolean
*) p
);
1481 m
= *(GLmatrix
**) p
;
1482 for (i
= 0; i
< 16; i
++)
1483 params
[i
] = m
->m
[i
];
1487 m
= *(GLmatrix
**) p
;
1488 for (i
= 0; i
< 16; i
++)
1489 params
[i
] = m
->m
[transpose
[i
]];
1500 shift
= d
->type
- TYPE_BIT_0
;
1501 params
[0] = BOOLEAN_TO_FLOAT((*(GLbitfield
*) p
>> shift
) & 1);
1507 _mesa_GetIntegerv(GLenum pname
, GLint
*params
)
1509 const struct value_desc
*d
;
1515 d
= find_value("glGetIntegerv", pname
, &p
, &v
);
1520 params
[0] = d
->offset
;
1524 params
[3] = IROUND(((GLfloat
*) p
)[3]);
1526 params
[2] = IROUND(((GLfloat
*) p
)[2]);
1528 params
[1] = IROUND(((GLfloat
*) p
)[1]);
1530 params
[0] = IROUND(((GLfloat
*) p
)[0]);
1534 params
[3] = FLOAT_TO_INT(((GLfloat
*) p
)[3]);
1536 params
[2] = FLOAT_TO_INT(((GLfloat
*) p
)[2]);
1538 params
[1] = FLOAT_TO_INT(((GLfloat
*) p
)[1]);
1540 params
[0] = FLOAT_TO_INT(((GLfloat
*) p
)[0]);
1543 case TYPE_DOUBLEN_2
:
1544 params
[1] = FLOAT_TO_INT(((GLdouble
*) p
)[1]);
1546 params
[0] = FLOAT_TO_INT(((GLdouble
*) p
)[0]);
1550 params
[3] = ((GLint
*) p
)[3];
1552 params
[2] = ((GLint
*) p
)[2];
1555 params
[1] = ((GLint
*) p
)[1];
1558 params
[0] = ((GLint
*) p
)[0];
1562 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
1563 params
[i
] = v
.value_int_n
.ints
[i
];
1567 params
[0] = INT64_TO_INT(((GLint64
*) p
)[0]);
1571 params
[0] = BOOLEAN_TO_INT(*(GLboolean
*) p
);
1575 m
= *(GLmatrix
**) p
;
1576 for (i
= 0; i
< 16; i
++)
1577 params
[i
] = FLOAT_TO_INT(m
->m
[i
]);
1581 m
= *(GLmatrix
**) p
;
1582 for (i
= 0; i
< 16; i
++)
1583 params
[i
] = FLOAT_TO_INT(m
->m
[transpose
[i
]]);
1594 shift
= d
->type
- TYPE_BIT_0
;
1595 params
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
1601 _mesa_GetInteger64v(GLenum pname
, GLint64
*params
)
1603 const struct value_desc
*d
;
1609 d
= find_value("glGetInteger64v", pname
, &p
, &v
);
1614 params
[0] = d
->offset
;
1618 params
[3] = IROUND64(((GLfloat
*) p
)[3]);
1620 params
[2] = IROUND64(((GLfloat
*) p
)[2]);
1622 params
[1] = IROUND64(((GLfloat
*) p
)[1]);
1624 params
[0] = IROUND64(((GLfloat
*) p
)[0]);
1628 params
[3] = FLOAT_TO_INT64(((GLfloat
*) p
)[3]);
1630 params
[2] = FLOAT_TO_INT64(((GLfloat
*) p
)[2]);
1632 params
[1] = FLOAT_TO_INT64(((GLfloat
*) p
)[1]);
1634 params
[0] = FLOAT_TO_INT64(((GLfloat
*) p
)[0]);
1637 case TYPE_DOUBLEN_2
:
1638 params
[1] = FLOAT_TO_INT64(((GLdouble
*) p
)[1]);
1640 params
[0] = FLOAT_TO_INT64(((GLdouble
*) p
)[0]);
1644 params
[3] = ((GLint
*) p
)[3];
1646 params
[2] = ((GLint
*) p
)[2];
1649 params
[1] = ((GLint
*) p
)[1];
1652 params
[0] = ((GLint
*) p
)[0];
1656 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
1657 params
[i
] = INT_TO_BOOLEAN(v
.value_int_n
.ints
[i
]);
1661 params
[0] = ((GLint64
*) p
)[0];
1665 params
[0] = ((GLboolean
*) p
)[0];
1669 m
= *(GLmatrix
**) p
;
1670 for (i
= 0; i
< 16; i
++)
1671 params
[i
] = FLOAT_TO_INT64(m
->m
[i
]);
1675 m
= *(GLmatrix
**) p
;
1676 for (i
= 0; i
< 16; i
++)
1677 params
[i
] = FLOAT_TO_INT64(m
->m
[transpose
[i
]]);
1688 shift
= d
->type
- TYPE_BIT_0
;
1689 params
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
1695 _mesa_GetDoublev(GLenum pname
, GLdouble
*params
)
1697 const struct value_desc
*d
;
1703 d
= find_value("glGetDoublev", pname
, &p
, &v
);
1708 params
[0] = d
->offset
;
1713 params
[3] = ((GLfloat
*) p
)[3];
1716 params
[2] = ((GLfloat
*) p
)[2];
1719 params
[1] = ((GLfloat
*) p
)[1];
1722 params
[0] = ((GLfloat
*) p
)[0];
1725 case TYPE_DOUBLEN_2
:
1726 params
[1] = ((GLdouble
*) p
)[1];
1728 params
[0] = ((GLdouble
*) p
)[0];
1732 params
[3] = ((GLint
*) p
)[3];
1734 params
[2] = ((GLint
*) p
)[2];
1737 params
[1] = ((GLint
*) p
)[1];
1740 params
[0] = ((GLint
*) p
)[0];
1744 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
1745 params
[i
] = v
.value_int_n
.ints
[i
];
1749 params
[0] = (GLdouble
) (((GLint64
*) p
)[0]);
1753 params
[0] = *(GLboolean
*) p
;
1757 m
= *(GLmatrix
**) p
;
1758 for (i
= 0; i
< 16; i
++)
1759 params
[i
] = m
->m
[i
];
1763 m
= *(GLmatrix
**) p
;
1764 for (i
= 0; i
< 16; i
++)
1765 params
[i
] = m
->m
[transpose
[i
]];
1776 shift
= d
->type
- TYPE_BIT_0
;
1777 params
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
1782 static enum value_type
1783 find_value_indexed(const char *func
, GLenum pname
, GLuint index
, union value
*v
)
1785 GET_CURRENT_CONTEXT(ctx
);
1790 if (index
>= ctx
->Const
.MaxDrawBuffers
)
1792 if (!ctx
->Extensions
.EXT_draw_buffers2
)
1794 v
->value_int
= (ctx
->Color
.BlendEnabled
>> index
) & 1;
1799 case GL_BLEND_SRC_RGB
:
1800 if (index
>= ctx
->Const
.MaxDrawBuffers
)
1802 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
1804 v
->value_int
= ctx
->Color
.Blend
[index
].SrcRGB
;
1806 case GL_BLEND_SRC_ALPHA
:
1807 if (index
>= ctx
->Const
.MaxDrawBuffers
)
1809 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
1811 v
->value_int
= ctx
->Color
.Blend
[index
].SrcA
;
1815 case GL_BLEND_DST_RGB
:
1816 if (index
>= ctx
->Const
.MaxDrawBuffers
)
1818 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
1820 v
->value_int
= ctx
->Color
.Blend
[index
].DstRGB
;
1822 case GL_BLEND_DST_ALPHA
:
1823 if (index
>= ctx
->Const
.MaxDrawBuffers
)
1825 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
1827 v
->value_int
= ctx
->Color
.Blend
[index
].DstA
;
1829 case GL_BLEND_EQUATION_RGB
:
1830 if (index
>= ctx
->Const
.MaxDrawBuffers
)
1832 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
1834 v
->value_int
= ctx
->Color
.Blend
[index
].EquationRGB
;
1836 case GL_BLEND_EQUATION_ALPHA
:
1837 if (index
>= ctx
->Const
.MaxDrawBuffers
)
1839 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
1841 v
->value_int
= ctx
->Color
.Blend
[index
].EquationA
;
1844 case GL_COLOR_WRITEMASK
:
1845 if (index
>= ctx
->Const
.MaxDrawBuffers
)
1847 if (!ctx
->Extensions
.EXT_draw_buffers2
)
1849 v
->value_int_4
[0] = ctx
->Color
.ColorMask
[index
][RCOMP
] ? 1 : 0;
1850 v
->value_int_4
[1] = ctx
->Color
.ColorMask
[index
][GCOMP
] ? 1 : 0;
1851 v
->value_int_4
[2] = ctx
->Color
.ColorMask
[index
][BCOMP
] ? 1 : 0;
1852 v
->value_int_4
[3] = ctx
->Color
.ColorMask
[index
][ACOMP
] ? 1 : 0;
1855 case GL_SCISSOR_BOX
:
1856 if (index
>= ctx
->Const
.MaxViewports
)
1858 v
->value_int_4
[0] = ctx
->Scissor
.ScissorArray
[index
].X
;
1859 v
->value_int_4
[1] = ctx
->Scissor
.ScissorArray
[index
].Y
;
1860 v
->value_int_4
[2] = ctx
->Scissor
.ScissorArray
[index
].Width
;
1861 v
->value_int_4
[3] = ctx
->Scissor
.ScissorArray
[index
].Height
;
1865 if (index
>= ctx
->Const
.MaxViewports
)
1867 v
->value_float_4
[0] = ctx
->ViewportArray
[index
].X
;
1868 v
->value_float_4
[1] = ctx
->ViewportArray
[index
].Y
;
1869 v
->value_float_4
[2] = ctx
->ViewportArray
[index
].Width
;
1870 v
->value_float_4
[3] = ctx
->ViewportArray
[index
].Height
;
1871 return TYPE_FLOAT_4
;
1873 case GL_DEPTH_RANGE
:
1874 if (index
>= ctx
->Const
.MaxViewports
)
1876 v
->value_double_2
[0] = ctx
->ViewportArray
[index
].Near
;
1877 v
->value_double_2
[1] = ctx
->ViewportArray
[index
].Far
;
1878 return TYPE_DOUBLEN_2
;
1880 case GL_TRANSFORM_FEEDBACK_BUFFER_START
:
1881 if (index
>= ctx
->Const
.MaxTransformFeedbackBuffers
)
1883 if (!ctx
->Extensions
.EXT_transform_feedback
)
1885 v
->value_int64
= ctx
->TransformFeedback
.CurrentObject
->Offset
[index
];
1888 case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE
:
1889 if (index
>= ctx
->Const
.MaxTransformFeedbackBuffers
)
1891 if (!ctx
->Extensions
.EXT_transform_feedback
)
1894 = ctx
->TransformFeedback
.CurrentObject
->RequestedSize
[index
];
1897 case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING
:
1898 if (index
>= ctx
->Const
.MaxTransformFeedbackBuffers
)
1900 if (!ctx
->Extensions
.EXT_transform_feedback
)
1902 v
->value_int
= ctx
->TransformFeedback
.CurrentObject
->BufferNames
[index
];
1905 case GL_UNIFORM_BUFFER_BINDING
:
1906 if (index
>= ctx
->Const
.MaxUniformBufferBindings
)
1908 if (!ctx
->Extensions
.ARB_uniform_buffer_object
)
1910 v
->value_int
= ctx
->UniformBufferBindings
[index
].BufferObject
->Name
;
1913 case GL_UNIFORM_BUFFER_START
:
1914 if (index
>= ctx
->Const
.MaxUniformBufferBindings
)
1916 if (!ctx
->Extensions
.ARB_uniform_buffer_object
)
1918 v
->value_int
= ctx
->UniformBufferBindings
[index
].Offset
;
1921 case GL_UNIFORM_BUFFER_SIZE
:
1922 if (index
>= ctx
->Const
.MaxUniformBufferBindings
)
1924 if (!ctx
->Extensions
.ARB_uniform_buffer_object
)
1926 v
->value_int
= ctx
->UniformBufferBindings
[index
].Size
;
1929 /* ARB_texture_multisample / GL3.2 */
1930 case GL_SAMPLE_MASK_VALUE
:
1933 if (!ctx
->Extensions
.ARB_texture_multisample
)
1935 v
->value_int
= ctx
->Multisample
.SampleMaskValue
;
1938 case GL_ATOMIC_COUNTER_BUFFER_BINDING
:
1939 if (!ctx
->Extensions
.ARB_shader_atomic_counters
)
1941 if (index
>= ctx
->Const
.MaxAtomicBufferBindings
)
1943 v
->value_int
= ctx
->AtomicBufferBindings
[index
].BufferObject
->Name
;
1946 case GL_ATOMIC_COUNTER_BUFFER_START
:
1947 if (!ctx
->Extensions
.ARB_shader_atomic_counters
)
1949 if (index
>= ctx
->Const
.MaxAtomicBufferBindings
)
1951 v
->value_int64
= ctx
->AtomicBufferBindings
[index
].Offset
;
1954 case GL_ATOMIC_COUNTER_BUFFER_SIZE
:
1955 if (!ctx
->Extensions
.ARB_shader_atomic_counters
)
1957 if (index
>= ctx
->Const
.MaxAtomicBufferBindings
)
1959 v
->value_int64
= ctx
->AtomicBufferBindings
[index
].Size
;
1962 case GL_VERTEX_BINDING_DIVISOR
:
1963 if (!_mesa_is_desktop_gl(ctx
) || !ctx
->Extensions
.ARB_instanced_arrays
)
1965 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
)
1967 v
->value_int
= ctx
->Array
.VAO
->VertexBinding
[VERT_ATTRIB_GENERIC(index
)].InstanceDivisor
;
1970 case GL_VERTEX_BINDING_OFFSET
:
1971 if (!_mesa_is_desktop_gl(ctx
))
1973 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
)
1975 v
->value_int
= ctx
->Array
.VAO
->VertexBinding
[VERT_ATTRIB_GENERIC(index
)].Offset
;
1978 case GL_VERTEX_BINDING_STRIDE
:
1979 if (!_mesa_is_desktop_gl(ctx
))
1981 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
)
1983 v
->value_int
= ctx
->Array
.VAO
->VertexBinding
[VERT_ATTRIB_GENERIC(index
)].Stride
;
1986 /* ARB_shader_image_load_store */
1987 case GL_IMAGE_BINDING_NAME
: {
1988 struct gl_texture_object
*t
;
1990 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
1992 if (index
>= ctx
->Const
.MaxImageUnits
)
1995 t
= ctx
->ImageUnits
[index
].TexObj
;
1996 v
->value_int
= (t
? t
->Name
: 0);
2000 case GL_IMAGE_BINDING_LEVEL
:
2001 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
2003 if (index
>= ctx
->Const
.MaxImageUnits
)
2006 v
->value_int
= ctx
->ImageUnits
[index
].Level
;
2009 case GL_IMAGE_BINDING_LAYERED
:
2010 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
2012 if (index
>= ctx
->Const
.MaxImageUnits
)
2015 v
->value_int
= ctx
->ImageUnits
[index
].Layered
;
2018 case GL_IMAGE_BINDING_LAYER
:
2019 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
2021 if (index
>= ctx
->Const
.MaxImageUnits
)
2024 v
->value_int
= ctx
->ImageUnits
[index
].Layer
;
2027 case GL_IMAGE_BINDING_ACCESS
:
2028 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
2030 if (index
>= ctx
->Const
.MaxImageUnits
)
2033 v
->value_int
= ctx
->ImageUnits
[index
].Access
;
2036 case GL_IMAGE_BINDING_FORMAT
:
2037 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
2039 if (index
>= ctx
->Const
.MaxImageUnits
)
2042 v
->value_int
= ctx
->ImageUnits
[index
].Format
;
2045 case GL_MAX_COMPUTE_WORK_GROUP_COUNT
:
2046 if (!_mesa_is_desktop_gl(ctx
) || !ctx
->Extensions
.ARB_compute_shader
)
2050 v
->value_int
= ctx
->Const
.MaxComputeWorkGroupCount
[index
];
2053 case GL_MAX_COMPUTE_WORK_GROUP_SIZE
:
2054 if (!_mesa_is_desktop_gl(ctx
) || !ctx
->Extensions
.ARB_compute_shader
)
2058 v
->value_int
= ctx
->Const
.MaxComputeWorkGroupSize
[index
];
2063 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(pname=%s)", func
,
2064 _mesa_enum_to_string(pname
));
2065 return TYPE_INVALID
;
2067 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(pname=%s)", func
,
2068 _mesa_enum_to_string(pname
));
2069 return TYPE_INVALID
;
2073 _mesa_GetBooleani_v( GLenum pname
, GLuint index
, GLboolean
*params
)
2076 enum value_type type
=
2077 find_value_indexed("glGetBooleani_v", pname
, index
, &v
);
2081 params
[0] = INT_TO_BOOLEAN(v
.value_int
);
2084 params
[0] = INT_TO_BOOLEAN(v
.value_int_4
[0]);
2085 params
[1] = INT_TO_BOOLEAN(v
.value_int_4
[1]);
2086 params
[2] = INT_TO_BOOLEAN(v
.value_int_4
[2]);
2087 params
[3] = INT_TO_BOOLEAN(v
.value_int_4
[3]);
2090 params
[0] = INT64_TO_BOOLEAN(v
.value_int64
);
2093 ; /* nothing - GL error was recorded */
2098 _mesa_GetIntegeri_v( GLenum pname
, GLuint index
, GLint
*params
)
2101 enum value_type type
=
2102 find_value_indexed("glGetIntegeri_v", pname
, index
, &v
);
2107 params
[3] = IROUND(v
.value_float_4
[3]);
2110 params
[2] = IROUND(v
.value_float_4
[2]);
2113 params
[1] = IROUND(v
.value_float_4
[1]);
2116 params
[0] = IROUND(v
.value_float_4
[0]);
2119 case TYPE_DOUBLEN_2
:
2120 params
[1] = IROUND(v
.value_double_2
[1]);
2122 params
[0] = IROUND(v
.value_double_2
[0]);
2126 params
[0] = v
.value_int
;
2129 params
[0] = v
.value_int_4
[0];
2130 params
[1] = v
.value_int_4
[1];
2131 params
[2] = v
.value_int_4
[2];
2132 params
[3] = v
.value_int_4
[3];
2135 params
[0] = INT64_TO_INT(v
.value_int64
);
2138 ; /* nothing - GL error was recorded */
2143 _mesa_GetInteger64i_v( GLenum pname
, GLuint index
, GLint64
*params
)
2146 enum value_type type
=
2147 find_value_indexed("glGetInteger64i_v", pname
, index
, &v
);
2151 params
[0] = v
.value_int
;
2154 params
[0] = v
.value_int_4
[0];
2155 params
[1] = v
.value_int_4
[1];
2156 params
[2] = v
.value_int_4
[2];
2157 params
[3] = v
.value_int_4
[3];
2160 params
[0] = v
.value_int64
;
2163 ; /* nothing - GL error was recorded */
2168 _mesa_GetFloati_v(GLenum pname
, GLuint index
, GLfloat
*params
)
2173 enum value_type type
=
2174 find_value_indexed("glGetFloati_v", pname
, index
, &v
);
2179 params
[3] = v
.value_float_4
[3];
2182 params
[2] = v
.value_float_4
[2];
2185 params
[1] = v
.value_float_4
[1];
2188 params
[0] = v
.value_float_4
[0];
2191 case TYPE_DOUBLEN_2
:
2192 params
[1] = (GLfloat
) v
.value_double_2
[1];
2194 params
[0] = (GLfloat
) v
.value_double_2
[0];
2198 params
[3] = (GLfloat
) v
.value_int_4
[3];
2200 params
[2] = (GLfloat
) v
.value_int_4
[2];
2203 params
[1] = (GLfloat
) v
.value_int_4
[1];
2206 params
[0] = (GLfloat
) v
.value_int_4
[0];
2210 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
2211 params
[i
] = INT_TO_FLOAT(v
.value_int_n
.ints
[i
]);
2215 params
[0] = (GLfloat
) v
.value_int64
;
2219 params
[0] = BOOLEAN_TO_FLOAT(v
.value_bool
);
2223 m
= *(GLmatrix
**) &v
;
2224 for (i
= 0; i
< 16; i
++)
2225 params
[i
] = m
->m
[i
];
2229 m
= *(GLmatrix
**) &v
;
2230 for (i
= 0; i
< 16; i
++)
2231 params
[i
] = m
->m
[transpose
[i
]];
2240 _mesa_GetDoublei_v(GLenum pname
, GLuint index
, GLdouble
*params
)
2245 enum value_type type
=
2246 find_value_indexed("glGetDoublei_v", pname
, index
, &v
);
2251 params
[3] = (GLdouble
) v
.value_float_4
[3];
2254 params
[2] = (GLdouble
) v
.value_float_4
[2];
2257 params
[1] = (GLdouble
) v
.value_float_4
[1];
2260 params
[0] = (GLdouble
) v
.value_float_4
[0];
2263 case TYPE_DOUBLEN_2
:
2264 params
[1] = v
.value_double_2
[1];
2266 params
[0] = v
.value_double_2
[0];
2270 params
[3] = (GLdouble
) v
.value_int_4
[3];
2272 params
[2] = (GLdouble
) v
.value_int_4
[2];
2275 params
[1] = (GLdouble
) v
.value_int_4
[1];
2278 params
[0] = (GLdouble
) v
.value_int_4
[0];
2282 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
2283 params
[i
] = (GLdouble
) INT_TO_FLOAT(v
.value_int_n
.ints
[i
]);
2287 params
[0] = (GLdouble
) v
.value_int64
;
2291 params
[0] = (GLdouble
) BOOLEAN_TO_FLOAT(v
.value_bool
);
2295 m
= *(GLmatrix
**) &v
;
2296 for (i
= 0; i
< 16; i
++)
2297 params
[i
] = (GLdouble
) m
->m
[i
];
2301 m
= *(GLmatrix
**) &v
;
2302 for (i
= 0; i
< 16; i
++)
2303 params
[i
] = (GLdouble
) m
->m
[transpose
[i
]];
2312 _mesa_GetFixedv(GLenum pname
, GLfixed
*params
)
2314 const struct value_desc
*d
;
2320 d
= find_value("glGetDoublev", pname
, &p
, &v
);
2325 params
[0] = INT_TO_FIXED(d
->offset
);
2330 params
[3] = FLOAT_TO_FIXED(((GLfloat
*) p
)[3]);
2333 params
[2] = FLOAT_TO_FIXED(((GLfloat
*) p
)[2]);
2336 params
[1] = FLOAT_TO_FIXED(((GLfloat
*) p
)[1]);
2339 params
[0] = FLOAT_TO_FIXED(((GLfloat
*) p
)[0]);
2342 case TYPE_DOUBLEN_2
:
2343 params
[1] = FLOAT_TO_FIXED(((GLdouble
*) p
)[1]);
2345 params
[0] = FLOAT_TO_FIXED(((GLdouble
*) p
)[0]);
2349 params
[3] = INT_TO_FIXED(((GLint
*) p
)[3]);
2351 params
[2] = INT_TO_FIXED(((GLint
*) p
)[2]);
2354 params
[1] = INT_TO_FIXED(((GLint
*) p
)[1]);
2357 params
[0] = INT_TO_FIXED(((GLint
*) p
)[0]);
2361 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
2362 params
[i
] = INT_TO_FIXED(v
.value_int_n
.ints
[i
]);
2366 params
[0] = ((GLint64
*) p
)[0];
2370 params
[0] = BOOLEAN_TO_FIXED(((GLboolean
*) p
)[0]);
2374 m
= *(GLmatrix
**) p
;
2375 for (i
= 0; i
< 16; i
++)
2376 params
[i
] = FLOAT_TO_FIXED(m
->m
[i
]);
2380 m
= *(GLmatrix
**) p
;
2381 for (i
= 0; i
< 16; i
++)
2382 params
[i
] = FLOAT_TO_FIXED(m
->m
[transpose
[i
]]);
2393 shift
= d
->type
- TYPE_BIT_0
;
2394 params
[0] = BOOLEAN_TO_FIXED((*(GLbitfield
*) p
>> shift
) & 1);