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>
29 #include "debug_output.h"
33 #include "extensions.h"
38 #include "texcompress.h"
40 #include "framebuffer.h"
41 #include "samplerobj.h"
45 /* This is a table driven implemetation of the glGet*v() functions.
46 * The basic idea is that most getters just look up an int somewhere
47 * in struct gl_context and then convert it to a bool or float according to
48 * which of glGetIntegerv() glGetBooleanv() etc is being called.
49 * Instead of generating code to do this, we can just record the enum
50 * value and the offset into struct gl_context in an array of structs. Then
51 * in glGet*(), we lookup the struct for the enum in question, and use
52 * the offset to get the int we need.
54 * Sometimes we need to look up a float, a boolean, a bit in a
55 * bitfield, a matrix or other types instead, so we need to track the
56 * type of the value in struct gl_context. And sometimes the value isn't in
57 * struct gl_context but in the drawbuffer, the array object, current texture
58 * unit, or maybe it's a computed value. So we need to also track
59 * where or how to find the value. Finally, we sometimes need to
60 * check that one of a number of extensions are enabled, the GL
61 * version or flush or call _mesa_update_state(). This is done by
62 * attaching optional extra information to the value description
63 * struct, it's sort of like an array of opcodes that describe extra
66 * Putting all this together we end up with struct value_desc below,
67 * and with a couple of macros to help, the table of struct value_desc
68 * is about as concise as the specification in the old python script.
71 #define FLOAT_TO_BOOLEAN(X) ( (X) ? GL_TRUE : GL_FALSE )
72 #define FLOAT_TO_FIXED(F) ( ((F) * 65536.0f > INT_MAX) ? INT_MAX : \
73 ((F) * 65536.0f < INT_MIN) ? INT_MIN : \
74 (GLint) ((F) * 65536.0f) )
76 #define INT_TO_BOOLEAN(I) ( (I) ? GL_TRUE : GL_FALSE )
77 #define INT_TO_FIXED(I) ( ((I) > SHRT_MAX) ? INT_MAX : \
78 ((I) < SHRT_MIN) ? INT_MIN : \
79 (GLint) ((I) * 65536) )
81 #define INT64_TO_BOOLEAN(I) ( (I) ? GL_TRUE : GL_FALSE )
82 #define INT64_TO_INT(I) ( (GLint)((I > INT_MAX) ? INT_MAX : ((I < INT_MIN) ? INT_MIN : (I))) )
84 #define BOOLEAN_TO_INT(B) ( (GLint) (B) )
85 #define BOOLEAN_TO_INT64(B) ( (GLint64) (B) )
86 #define BOOLEAN_TO_FLOAT(B) ( (B) ? 1.0F : 0.0F )
87 #define BOOLEAN_TO_FIXED(B) ( (GLint) ((B) ? 1 : 0) << 16 )
89 #define ENUM_TO_INT64(E) ( (GLint64) (E) )
90 #define ENUM_TO_FIXED(E) (E)
132 enum value_location
{
153 EXTRA_NEW_FRAG_CLAMP
,
154 EXTRA_VALID_DRAW_BUFFER
,
155 EXTRA_VALID_TEXTURE_UNIT
,
156 EXTRA_VALID_CLIP_DISTANCE
,
160 EXTRA_EXT_ATOMICS_GS
,
161 EXTRA_EXT_SHADER_IMAGE_GS
,
162 EXTRA_EXT_ATOMICS_TESS
,
163 EXTRA_EXT_SHADER_IMAGE_TESS
,
165 EXTRA_EXT_FB_NO_ATTACH_GS
,
167 EXTRA_EXT_PROVOKING_VERTEX_32
,
170 #define NO_EXTRA NULL
175 GLubyte location
; /**< enum value_location */
176 GLubyte type
; /**< enum value_type */
183 GLfloat value_float_4
[4];
184 GLdouble value_double_2
[2];
185 GLmatrix
*value_matrix
;
187 GLint value_int_4
[4];
191 /* Sigh, see GL_COMPRESSED_TEXTURE_FORMATS_ARB handling */
195 GLboolean value_bool
;
198 #define BUFFER_FIELD(field, type) \
199 LOC_BUFFER, type, offsetof(struct gl_framebuffer, field)
200 #define CONTEXT_FIELD(field, type) \
201 LOC_CONTEXT, type, offsetof(struct gl_context, field)
202 #define ARRAY_FIELD(field, type) \
203 LOC_ARRAY, type, offsetof(struct gl_vertex_array_object, field)
204 #undef CONST /* already defined through windows.h */
205 #define CONST(value) \
206 LOC_CONTEXT, TYPE_CONST, value
208 #define BUFFER_INT(field) BUFFER_FIELD(field, TYPE_INT)
209 #define BUFFER_ENUM(field) BUFFER_FIELD(field, TYPE_ENUM)
210 #define BUFFER_ENUM16(field) BUFFER_FIELD(field, TYPE_ENUM16)
211 #define BUFFER_BOOL(field) BUFFER_FIELD(field, TYPE_BOOLEAN)
213 #define CONTEXT_INT(field) CONTEXT_FIELD(field, TYPE_INT)
214 #define CONTEXT_INT2(field) CONTEXT_FIELD(field, TYPE_INT_2)
215 #define CONTEXT_INT64(field) CONTEXT_FIELD(field, TYPE_INT64)
216 #define CONTEXT_UINT(field) CONTEXT_FIELD(field, TYPE_UINT)
217 #define CONTEXT_ENUM16(field) CONTEXT_FIELD(field, TYPE_ENUM16)
218 #define CONTEXT_ENUM(field) CONTEXT_FIELD(field, TYPE_ENUM)
219 #define CONTEXT_ENUM2(field) CONTEXT_FIELD(field, TYPE_ENUM_2)
220 #define CONTEXT_BOOL(field) CONTEXT_FIELD(field, TYPE_BOOLEAN)
221 #define CONTEXT_BIT0(field) CONTEXT_FIELD(field, TYPE_BIT_0)
222 #define CONTEXT_BIT1(field) CONTEXT_FIELD(field, TYPE_BIT_1)
223 #define CONTEXT_BIT2(field) CONTEXT_FIELD(field, TYPE_BIT_2)
224 #define CONTEXT_BIT3(field) CONTEXT_FIELD(field, TYPE_BIT_3)
225 #define CONTEXT_BIT4(field) CONTEXT_FIELD(field, TYPE_BIT_4)
226 #define CONTEXT_BIT5(field) CONTEXT_FIELD(field, TYPE_BIT_5)
227 #define CONTEXT_BIT6(field) CONTEXT_FIELD(field, TYPE_BIT_6)
228 #define CONTEXT_BIT7(field) CONTEXT_FIELD(field, TYPE_BIT_7)
229 #define CONTEXT_FLOAT(field) CONTEXT_FIELD(field, TYPE_FLOAT)
230 #define CONTEXT_FLOAT2(field) CONTEXT_FIELD(field, TYPE_FLOAT_2)
231 #define CONTEXT_FLOAT3(field) CONTEXT_FIELD(field, TYPE_FLOAT_3)
232 #define CONTEXT_FLOAT4(field) CONTEXT_FIELD(field, TYPE_FLOAT_4)
233 #define CONTEXT_FLOAT8(field) CONTEXT_FIELD(field, TYPE_FLOAT_8)
234 #define CONTEXT_MATRIX(field) CONTEXT_FIELD(field, TYPE_MATRIX)
235 #define CONTEXT_MATRIX_T(field) CONTEXT_FIELD(field, TYPE_MATRIX_T)
237 #define ARRAY_INT(field) ARRAY_FIELD(field, TYPE_INT)
238 #define ARRAY_ENUM(field) ARRAY_FIELD(field, TYPE_ENUM)
239 #define ARRAY_ENUM16(field) ARRAY_FIELD(field, TYPE_ENUM16)
240 #define ARRAY_BOOL(field) ARRAY_FIELD(field, TYPE_BOOLEAN)
243 offsetof(struct gl_extensions, f)
245 #define EXTRA_EXT(e) \
246 static const int extra_##e[] = { \
250 #define EXTRA_EXT2(e1, e2) \
251 static const int extra_##e1##_##e2[] = { \
252 EXT(e1), EXT(e2), EXTRA_END \
255 /* The 'extra' mechanism is a way to specify extra checks (such as
256 * extensions or specific gl versions) or actions (flush current, new
257 * buffers) that we need to do before looking up an enum. We need to
258 * declare them all up front so we can refer to them in the value_desc
261 * Each EXTRA_ will be executed. For EXTRA_* enums of extensions and API
262 * versions, listing multiple ones in an array means an error will be thrown
263 * only if none of them are available. If you need to check for "AND"
264 * behavior, you would need to make a custom EXTRA_ enum.
267 static const int extra_new_buffers
[] = {
272 static const int extra_new_frag_clamp
[] = {
273 EXTRA_NEW_FRAG_CLAMP
,
277 static const int extra_valid_draw_buffer
[] = {
278 EXTRA_VALID_DRAW_BUFFER
,
282 static const int extra_valid_texture_unit
[] = {
283 EXTRA_VALID_TEXTURE_UNIT
,
287 static const int extra_valid_clip_distance
[] = {
288 EXTRA_VALID_CLIP_DISTANCE
,
292 static const int extra_flush_current_valid_texture_unit
[] = {
294 EXTRA_VALID_TEXTURE_UNIT
,
298 static const int extra_flush_current
[] = {
303 static const int extra_EXT_texture_integer_and_new_buffers
[] = {
304 EXT(EXT_texture_integer
),
309 static const int extra_GLSL_130_es3
[] = {
315 static const int extra_texture_buffer_object
[] = {
316 EXT(ARB_texture_buffer_object
),
320 static const int extra_ARB_transform_feedback2_api_es3
[] = {
321 EXT(ARB_transform_feedback2
),
326 static const int extra_ARB_uniform_buffer_object_and_geometry_shader
[] = {
331 static const int extra_ARB_ES2_compatibility_api_es2
[] = {
332 EXT(ARB_ES2_compatibility
),
337 static const int extra_ARB_ES3_compatibility_api_es3
[] = {
338 EXT(ARB_ES3_compatibility
),
343 static const int extra_EXT_framebuffer_sRGB_and_new_buffers
[] = {
344 EXT(EXT_framebuffer_sRGB
),
349 static const int extra_EXT_packed_float
[] = {
350 EXT(EXT_packed_float
),
355 static const int extra_EXT_texture_array_es3
[] = {
356 EXT(EXT_texture_array
),
361 static const int extra_ARB_shader_atomic_counters_and_geometry_shader
[] = {
362 EXTRA_EXT_ATOMICS_GS
,
366 static const int extra_ARB_shader_image_load_store_and_geometry_shader
[] = {
367 EXTRA_EXT_SHADER_IMAGE_GS
,
371 static const int extra_ARB_shader_atomic_counters_and_tessellation
[] = {
372 EXTRA_EXT_ATOMICS_TESS
,
376 static const int extra_ARB_shader_image_load_store_and_tessellation
[] = {
377 EXTRA_EXT_SHADER_IMAGE_TESS
,
381 /* HACK: remove when ARB_compute_shader is actually supported */
382 static const int extra_ARB_compute_shader_es31
[] = {
383 EXT(ARB_compute_shader
),
388 static const int extra_ARB_shader_storage_buffer_object_es31
[] = {
389 EXT(ARB_shader_storage_buffer_object
),
394 static const int extra_ARB_shader_storage_buffer_object_and_geometry_shader
[] = {
399 static const int extra_ARB_shader_image_load_store_shader_storage_buffer_object_es31
[] = {
400 EXT(ARB_shader_image_load_store
),
401 EXT(ARB_shader_storage_buffer_object
),
406 static const int extra_ARB_framebuffer_no_attachments_and_geometry_shader
[] = {
407 EXTRA_EXT_FB_NO_ATTACH_GS
,
411 static const int extra_ARB_viewport_array_or_oes_geometry_shader
[] = {
412 EXT(ARB_viewport_array
),
417 static const int extra_ARB_viewport_array_or_oes_viewport_array
[] = {
418 EXT(ARB_viewport_array
),
419 EXT(OES_viewport_array
),
423 static const int extra_ARB_gpu_shader5_or_oes_geometry_shader
[] = {
424 EXT(ARB_gpu_shader5
),
429 static const int extra_ARB_gpu_shader5_or_OES_sample_variables
[] = {
430 EXT(ARB_gpu_shader5
),
431 EXT(OES_sample_variables
),
435 static const int extra_ES32
[] = {
436 EXT(ARB_ES3_2_compatibility
),
441 static const int extra_KHR_robustness_or_GL
[] = {
448 static const int extra_INTEL_conservative_rasterization
[] = {
449 EXT(INTEL_conservative_rasterization
),
453 EXTRA_EXT(ARB_texture_cube_map
);
454 EXTRA_EXT(EXT_texture_array
);
455 EXTRA_EXT(NV_fog_distance
);
456 EXTRA_EXT(EXT_texture_filter_anisotropic
);
457 EXTRA_EXT(NV_point_sprite
);
458 EXTRA_EXT(NV_texture_rectangle
);
459 EXTRA_EXT(EXT_stencil_two_side
);
460 EXTRA_EXT(EXT_depth_bounds_test
);
461 EXTRA_EXT(ARB_depth_clamp
);
462 EXTRA_EXT(ATI_fragment_shader
);
463 EXTRA_EXT(EXT_provoking_vertex
);
464 EXTRA_EXT(ARB_fragment_shader
);
465 EXTRA_EXT(ARB_fragment_program
);
466 EXTRA_EXT2(ARB_framebuffer_object
, EXT_framebuffer_multisample
);
467 EXTRA_EXT(ARB_seamless_cube_map
);
469 EXTRA_EXT(ARB_vertex_shader
);
470 EXTRA_EXT(EXT_transform_feedback
);
471 EXTRA_EXT(ARB_transform_feedback3
);
472 EXTRA_EXT(EXT_pixel_buffer_object
);
473 EXTRA_EXT(ARB_vertex_program
);
474 EXTRA_EXT2(NV_point_sprite
, ARB_point_sprite
);
475 EXTRA_EXT2(ARB_vertex_program
, ARB_fragment_program
);
476 EXTRA_EXT(ARB_color_buffer_float
);
477 EXTRA_EXT(EXT_framebuffer_sRGB
);
478 EXTRA_EXT(OES_EGL_image_external
);
479 EXTRA_EXT(ARB_blend_func_extended
);
480 EXTRA_EXT(ARB_uniform_buffer_object
);
481 EXTRA_EXT(ARB_timer_query
);
482 EXTRA_EXT2(ARB_texture_cube_map_array
, OES_texture_cube_map_array
);
483 EXTRA_EXT(ARB_texture_buffer_range
);
484 EXTRA_EXT(ARB_texture_multisample
);
485 EXTRA_EXT(ARB_texture_gather
);
486 EXTRA_EXT(ARB_shader_atomic_counters
);
487 EXTRA_EXT(ARB_draw_indirect
);
488 EXTRA_EXT(ARB_shader_image_load_store
);
489 EXTRA_EXT(ARB_query_buffer_object
);
490 EXTRA_EXT2(ARB_transform_feedback3
, ARB_gpu_shader5
);
491 EXTRA_EXT(INTEL_performance_query
);
492 EXTRA_EXT(ARB_explicit_uniform_location
);
493 EXTRA_EXT(ARB_clip_control
);
494 EXTRA_EXT(ARB_polygon_offset_clamp
);
495 EXTRA_EXT(ARB_framebuffer_no_attachments
);
496 EXTRA_EXT(ARB_tessellation_shader
);
497 EXTRA_EXT(ARB_shader_storage_buffer_object
);
498 EXTRA_EXT(ARB_indirect_parameters
);
499 EXTRA_EXT(ATI_meminfo
);
500 EXTRA_EXT(NVX_gpu_memory_info
);
501 EXTRA_EXT(ARB_cull_distance
);
502 EXTRA_EXT(EXT_window_rectangles
);
503 EXTRA_EXT(KHR_blend_equation_advanced_coherent
);
504 EXTRA_EXT(OES_primitive_bounding_box
);
505 EXTRA_EXT(ARB_compute_variable_group_size
);
506 EXTRA_EXT(KHR_robustness
);
507 EXTRA_EXT(ARB_sparse_buffer
);
510 extra_ARB_color_buffer_float_or_glcore
[] = {
511 EXT(ARB_color_buffer_float
),
517 extra_NV_primitive_restart
[] = {
518 EXT(NV_primitive_restart
),
522 static const int extra_version_30
[] = { EXTRA_VERSION_30
, EXTRA_END
};
523 static const int extra_version_31
[] = { EXTRA_VERSION_31
, EXTRA_END
};
524 static const int extra_version_32
[] = { EXTRA_VERSION_32
, EXTRA_END
};
526 static const int extra_gl30_es3
[] = {
532 static const int extra_gl32_es3
[] = {
538 static const int extra_version_32_OES_geometry_shader
[] = {
544 static const int extra_gl40_ARB_sample_shading
[] = {
546 EXT(ARB_sample_shading
),
551 extra_ARB_vertex_program_api_es2
[] = {
552 EXT(ARB_vertex_program
),
557 /* The ReadBuffer get token is valid under either full GL or under
558 * GLES2 if the NV_read_buffer extension is available. */
560 extra_NV_read_buffer_api_gl
[] = {
566 static const int extra_core_ARB_color_buffer_float_and_new_buffers
[] = {
568 EXT(ARB_color_buffer_float
),
573 static const int extra_EXT_shader_framebuffer_fetch
[] = {
576 EXT(MESA_shader_framebuffer_fetch
),
580 static const int extra_EXT_provoking_vertex_32
[] = {
581 EXTRA_EXT_PROVOKING_VERTEX_32
,
585 static const int extra_EXT_disjoint_timer_query
[] = {
588 EXT(EXT_disjoint_timer_query
),
593 /* This is the big table describing all the enums we accept in
594 * glGet*v(). The table is partitioned into six parts: enums
595 * understood by all GL APIs (OpenGL, GLES and GLES2), enums shared
596 * between OpenGL and GLES, enums exclusive to GLES, etc for the
597 * remaining combinations. To look up the enums valid in a given API
598 * we will use a hash table specific to that API. These tables are in
599 * turn generated at build time and included through get_hash.h.
602 #include "get_hash.h"
604 /* All we need now is a way to look up the value struct from the enum.
605 * The code generated by gcc for the old generated big switch
606 * statement is a big, balanced, open coded if/else tree, essentially
607 * an unrolled binary search. It would be natural to sort the new
608 * enum table and use bsearch(), but we will use a read-only hash
609 * table instead. bsearch() has a nice guaranteed worst case
610 * performance, but we're also guaranteed to hit that worst case
611 * (log2(n) iterations) for about half the enums. Instead, using an
612 * open addressing hash table, we can find the enum on the first try
613 * for 80% of the enums, 1 collision for 10% and never more than 5
614 * collisions for any enum (typical numbers). And the code is very
615 * simple, even though it feels a little magic. */
618 * Handle irregular enums
620 * Some values don't conform to the "well-known type at context
621 * pointer + offset" pattern, so we have this function to catch all
622 * the corner cases. Typically, it's a computed value or a one-off
623 * pointer to a custom struct or something.
625 * In this case we can't return a pointer to the value, so we'll have
626 * to use the temporary variable 'v' declared back in the calling
627 * glGet*v() function to store the result.
629 * \param ctx the current context
630 * \param d the struct value_desc that describes the enum
631 * \param v pointer to the tmp declared in the calling glGet*v() function
634 find_custom_value(struct gl_context
*ctx
, const struct value_desc
*d
, union value
*v
)
636 struct gl_buffer_object
**buffer_obj
;
637 struct gl_array_attributes
*array
;
641 case GL_MAJOR_VERSION
:
642 v
->value_int
= ctx
->Version
/ 10;
644 case GL_MINOR_VERSION
:
645 v
->value_int
= ctx
->Version
% 10;
651 case GL_TEXTURE_CUBE_MAP
:
652 case GL_TEXTURE_RECTANGLE_NV
:
653 case GL_TEXTURE_EXTERNAL_OES
:
654 v
->value_bool
= _mesa_IsEnabled(d
->pname
);
657 case GL_LINE_STIPPLE_PATTERN
:
658 /* This is the only GLushort, special case it here by promoting
659 * to an int rather than introducing a new type. */
660 v
->value_int
= ctx
->Line
.StipplePattern
;
663 case GL_CURRENT_RASTER_TEXTURE_COORDS
:
664 unit
= ctx
->Texture
.CurrentUnit
;
665 v
->value_float_4
[0] = ctx
->Current
.RasterTexCoords
[unit
][0];
666 v
->value_float_4
[1] = ctx
->Current
.RasterTexCoords
[unit
][1];
667 v
->value_float_4
[2] = ctx
->Current
.RasterTexCoords
[unit
][2];
668 v
->value_float_4
[3] = ctx
->Current
.RasterTexCoords
[unit
][3];
671 case GL_CURRENT_TEXTURE_COORDS
:
672 unit
= ctx
->Texture
.CurrentUnit
;
673 v
->value_float_4
[0] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
][0];
674 v
->value_float_4
[1] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
][1];
675 v
->value_float_4
[2] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
][2];
676 v
->value_float_4
[3] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
][3];
679 case GL_COLOR_WRITEMASK
:
680 v
->value_int_4
[0] = ctx
->Color
.ColorMask
[0][RCOMP
] ? 1 : 0;
681 v
->value_int_4
[1] = ctx
->Color
.ColorMask
[0][GCOMP
] ? 1 : 0;
682 v
->value_int_4
[2] = ctx
->Color
.ColorMask
[0][BCOMP
] ? 1 : 0;
683 v
->value_int_4
[3] = ctx
->Color
.ColorMask
[0][ACOMP
] ? 1 : 0;
687 v
->value_bool
= ctx
->Current
.Attrib
[VERT_ATTRIB_EDGEFLAG
][0] == 1.0F
;
691 v
->value_enum
= ctx
->ReadBuffer
->ColorReadBuffer
;
694 case GL_MAP2_GRID_DOMAIN
:
695 v
->value_float_4
[0] = ctx
->Eval
.MapGrid2u1
;
696 v
->value_float_4
[1] = ctx
->Eval
.MapGrid2u2
;
697 v
->value_float_4
[2] = ctx
->Eval
.MapGrid2v1
;
698 v
->value_float_4
[3] = ctx
->Eval
.MapGrid2v2
;
701 case GL_TEXTURE_STACK_DEPTH
:
702 unit
= ctx
->Texture
.CurrentUnit
;
703 v
->value_int
= ctx
->TextureMatrixStack
[unit
].Depth
+ 1;
705 case GL_TEXTURE_MATRIX
:
706 unit
= ctx
->Texture
.CurrentUnit
;
707 v
->value_matrix
= ctx
->TextureMatrixStack
[unit
].Top
;
710 case GL_TEXTURE_COORD_ARRAY
:
711 case GL_TEXTURE_COORD_ARRAY_SIZE
:
712 case GL_TEXTURE_COORD_ARRAY_TYPE
:
713 case GL_TEXTURE_COORD_ARRAY_STRIDE
:
714 array
= &ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_TEX(ctx
->Array
.ActiveTexture
)];
715 v
->value_int
= *(GLuint
*) ((char *) array
+ d
->offset
);
718 case GL_ACTIVE_TEXTURE_ARB
:
719 v
->value_int
= GL_TEXTURE0_ARB
+ ctx
->Texture
.CurrentUnit
;
721 case GL_CLIENT_ACTIVE_TEXTURE_ARB
:
722 v
->value_int
= GL_TEXTURE0_ARB
+ ctx
->Array
.ActiveTexture
;
725 case GL_MODELVIEW_STACK_DEPTH
:
726 case GL_PROJECTION_STACK_DEPTH
:
727 v
->value_int
= *(GLint
*) ((char *) ctx
+ d
->offset
) + 1;
730 case GL_MAX_TEXTURE_SIZE
:
731 case GL_MAX_3D_TEXTURE_SIZE
:
732 case GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB
:
733 p
= (GLuint
*) ((char *) ctx
+ d
->offset
);
734 v
->value_int
= 1 << (*p
- 1);
738 v
->value_int_4
[0] = ctx
->Scissor
.ScissorArray
[0].X
;
739 v
->value_int_4
[1] = ctx
->Scissor
.ScissorArray
[0].Y
;
740 v
->value_int_4
[2] = ctx
->Scissor
.ScissorArray
[0].Width
;
741 v
->value_int_4
[3] = ctx
->Scissor
.ScissorArray
[0].Height
;
744 case GL_SCISSOR_TEST
:
745 v
->value_bool
= ctx
->Scissor
.EnableFlags
& 1;
750 ctx
->ListState
.CurrentList
? ctx
->ListState
.CurrentList
->Name
: 0;
753 if (!ctx
->CompileFlag
)
755 else if (ctx
->ExecuteFlag
)
756 v
->value_enum
= GL_COMPILE_AND_EXECUTE
;
758 v
->value_enum
= GL_COMPILE
;
762 v
->value_float_4
[0] = ctx
->ViewportArray
[0].X
;
763 v
->value_float_4
[1] = ctx
->ViewportArray
[0].Y
;
764 v
->value_float_4
[2] = ctx
->ViewportArray
[0].Width
;
765 v
->value_float_4
[3] = ctx
->ViewportArray
[0].Height
;
769 v
->value_double_2
[0] = ctx
->ViewportArray
[0].Near
;
770 v
->value_double_2
[1] = ctx
->ViewportArray
[0].Far
;
773 case GL_ACTIVE_STENCIL_FACE_EXT
:
774 v
->value_enum
= ctx
->Stencil
.ActiveFace
? GL_BACK
: GL_FRONT
;
777 case GL_STENCIL_FAIL
:
778 v
->value_enum
= ctx
->Stencil
.FailFunc
[ctx
->Stencil
.ActiveFace
];
780 case GL_STENCIL_FUNC
:
781 v
->value_enum
= ctx
->Stencil
.Function
[ctx
->Stencil
.ActiveFace
];
783 case GL_STENCIL_PASS_DEPTH_FAIL
:
784 v
->value_enum
= ctx
->Stencil
.ZFailFunc
[ctx
->Stencil
.ActiveFace
];
786 case GL_STENCIL_PASS_DEPTH_PASS
:
787 v
->value_enum
= ctx
->Stencil
.ZPassFunc
[ctx
->Stencil
.ActiveFace
];
790 v
->value_int
= _mesa_get_stencil_ref(ctx
, ctx
->Stencil
.ActiveFace
);
792 case GL_STENCIL_BACK_REF
:
793 v
->value_int
= _mesa_get_stencil_ref(ctx
, 1);
795 case GL_STENCIL_VALUE_MASK
:
796 v
->value_int
= ctx
->Stencil
.ValueMask
[ctx
->Stencil
.ActiveFace
];
798 case GL_STENCIL_WRITEMASK
:
799 v
->value_int
= ctx
->Stencil
.WriteMask
[ctx
->Stencil
.ActiveFace
];
802 case GL_NUM_EXTENSIONS
:
803 v
->value_int
= _mesa_get_extension_count(ctx
);
806 case GL_IMPLEMENTATION_COLOR_READ_TYPE_OES
:
807 v
->value_int
= _mesa_get_color_read_type(ctx
, NULL
, "glGetIntegerv");
809 case GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES
:
810 v
->value_int
= _mesa_get_color_read_format(ctx
, NULL
, "glGetIntegerv");
813 case GL_CURRENT_MATRIX_STACK_DEPTH_ARB
:
814 v
->value_int
= ctx
->CurrentStack
->Depth
+ 1;
816 case GL_CURRENT_MATRIX_ARB
:
817 case GL_TRANSPOSE_CURRENT_MATRIX_ARB
:
818 v
->value_matrix
= ctx
->CurrentStack
->Top
;
821 case GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB
:
822 v
->value_int
= _mesa_get_compressed_formats(ctx
, NULL
);
824 case GL_COMPRESSED_TEXTURE_FORMATS_ARB
:
826 _mesa_get_compressed_formats(ctx
, v
->value_int_n
.ints
);
827 assert(v
->value_int_n
.n
<= (int) ARRAY_SIZE(v
->value_int_n
.ints
));
830 case GL_MAX_VARYING_FLOATS_ARB
:
831 v
->value_int
= ctx
->Const
.MaxVarying
* 4;
834 /* Various object names */
836 case GL_TEXTURE_BINDING_1D
:
837 case GL_TEXTURE_BINDING_2D
:
838 case GL_TEXTURE_BINDING_3D
:
839 case GL_TEXTURE_BINDING_1D_ARRAY_EXT
:
840 case GL_TEXTURE_BINDING_2D_ARRAY_EXT
:
841 case GL_TEXTURE_BINDING_CUBE_MAP_ARB
:
842 case GL_TEXTURE_BINDING_RECTANGLE_NV
:
843 case GL_TEXTURE_BINDING_EXTERNAL_OES
:
844 case GL_TEXTURE_BINDING_CUBE_MAP_ARRAY
:
845 case GL_TEXTURE_BINDING_2D_MULTISAMPLE
:
846 case GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY
:
847 unit
= ctx
->Texture
.CurrentUnit
;
849 ctx
->Texture
.Unit
[unit
].CurrentTex
[d
->offset
]->Name
;
852 /* GL_EXT_external_objects */
853 case GL_DRIVER_UUID_EXT
:
854 _mesa_get_driver_uuid(ctx
, v
->value_int_4
);
856 case GL_DEVICE_UUID_EXT
:
857 _mesa_get_device_uuid(ctx
, v
->value_int_4
);
860 /* GL_EXT_packed_float */
861 case GL_RGBA_SIGNED_COMPONENTS_EXT
:
863 /* Note: we only check the 0th color attachment. */
864 const struct gl_renderbuffer
*rb
=
865 ctx
->DrawBuffer
->_ColorDrawBuffers
[0];
866 if (rb
&& _mesa_is_format_signed(rb
->Format
)) {
867 /* Issue 17 of GL_EXT_packed_float: If a component (such as
868 * alpha) has zero bits, the component should not be considered
869 * signed and so the bit for the respective component should be
873 _mesa_get_format_bits(rb
->Format
, GL_RED_BITS
);
875 _mesa_get_format_bits(rb
->Format
, GL_GREEN_BITS
);
877 _mesa_get_format_bits(rb
->Format
, GL_BLUE_BITS
);
879 _mesa_get_format_bits(rb
->Format
, GL_ALPHA_BITS
);
881 _mesa_get_format_bits(rb
->Format
, GL_TEXTURE_LUMINANCE_SIZE
);
883 _mesa_get_format_bits(rb
->Format
, GL_TEXTURE_INTENSITY_SIZE
);
885 v
->value_int_4
[0] = r_bits
+ l_bits
+ i_bits
> 0;
886 v
->value_int_4
[1] = g_bits
+ l_bits
+ i_bits
> 0;
887 v
->value_int_4
[2] = b_bits
+ l_bits
+ i_bits
> 0;
888 v
->value_int_4
[3] = a_bits
+ i_bits
> 0;
894 v
->value_int_4
[3] = 0;
899 /* GL_ARB_vertex_buffer_object */
900 case GL_VERTEX_ARRAY_BUFFER_BINDING_ARB
:
901 case GL_NORMAL_ARRAY_BUFFER_BINDING_ARB
:
902 case GL_COLOR_ARRAY_BUFFER_BINDING_ARB
:
903 case GL_INDEX_ARRAY_BUFFER_BINDING_ARB
:
904 case GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB
:
905 case GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB
:
906 case GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB
:
907 buffer_obj
= (struct gl_buffer_object
**)
908 ((char *) ctx
->Array
.VAO
+ d
->offset
);
909 v
->value_int
= (*buffer_obj
)->Name
;
911 case GL_ARRAY_BUFFER_BINDING_ARB
:
912 v
->value_int
= ctx
->Array
.ArrayBufferObj
->Name
;
914 case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB
:
916 ctx
->Array
.VAO
->BufferBinding
[VERT_ATTRIB_TEX(ctx
->Array
.ActiveTexture
)].BufferObj
->Name
;
918 case GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB
:
919 v
->value_int
= ctx
->Array
.VAO
->IndexBufferObj
->Name
;
922 /* ARB_vertex_array_bgra */
923 case GL_COLOR_ARRAY_SIZE
:
924 array
= &ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_COLOR0
];
925 v
->value_int
= array
->Format
== GL_BGRA
? GL_BGRA
: array
->Size
;
927 case GL_SECONDARY_COLOR_ARRAY_SIZE
:
928 array
= &ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_COLOR1
];
929 v
->value_int
= array
->Format
== GL_BGRA
? GL_BGRA
: array
->Size
;
932 /* ARB_copy_buffer */
933 case GL_COPY_READ_BUFFER
:
934 v
->value_int
= ctx
->CopyReadBuffer
->Name
;
936 case GL_COPY_WRITE_BUFFER
:
937 v
->value_int
= ctx
->CopyWriteBuffer
->Name
;
940 case GL_PIXEL_PACK_BUFFER_BINDING_EXT
:
941 v
->value_int
= ctx
->Pack
.BufferObj
->Name
;
943 case GL_PIXEL_UNPACK_BUFFER_BINDING_EXT
:
944 v
->value_int
= ctx
->Unpack
.BufferObj
->Name
;
946 case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING
:
947 v
->value_int
= ctx
->TransformFeedback
.CurrentBuffer
->Name
;
949 case GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED
:
950 v
->value_int
= ctx
->TransformFeedback
.CurrentObject
->Paused
;
952 case GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE
:
953 v
->value_int
= ctx
->TransformFeedback
.CurrentObject
->Active
;
955 case GL_TRANSFORM_FEEDBACK_BINDING
:
956 v
->value_int
= ctx
->TransformFeedback
.CurrentObject
->Name
;
958 case GL_CURRENT_PROGRAM
:
959 /* The Changelog of the ARB_separate_shader_objects spec says:
961 * 24 25 Jul 2011 pbrown Remove the language erroneously deleting
962 * CURRENT_PROGRAM. In the EXT extension, this
963 * token was aliased to ACTIVE_PROGRAM_EXT, and
964 * was used to indicate the last program set by
965 * either ActiveProgramEXT or UseProgram. In
966 * the ARB extension, the SSO active programs
967 * are now program pipeline object state and
968 * CURRENT_PROGRAM should still be used to query
969 * the last program set by UseProgram (bug 7822).
972 ctx
->Shader
.ActiveProgram
? ctx
->Shader
.ActiveProgram
->Name
: 0;
974 case GL_READ_FRAMEBUFFER_BINDING_EXT
:
975 v
->value_int
= ctx
->ReadBuffer
->Name
;
977 case GL_RENDERBUFFER_BINDING_EXT
:
979 ctx
->CurrentRenderbuffer
? ctx
->CurrentRenderbuffer
->Name
: 0;
981 case GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES
:
982 v
->value_int
= ctx
->Array
.VAO
->BufferBinding
[VERT_ATTRIB_POINT_SIZE
].BufferObj
->Name
;
986 if (_mesa_get_clamp_fragment_color(ctx
, ctx
->DrawBuffer
))
987 COPY_4FV(v
->value_float_4
, ctx
->Fog
.Color
);
989 COPY_4FV(v
->value_float_4
, ctx
->Fog
.ColorUnclamped
);
991 case GL_COLOR_CLEAR_VALUE
:
992 if (_mesa_get_clamp_fragment_color(ctx
, ctx
->DrawBuffer
)) {
993 v
->value_float_4
[0] = CLAMP(ctx
->Color
.ClearColor
.f
[0], 0.0F
, 1.0F
);
994 v
->value_float_4
[1] = CLAMP(ctx
->Color
.ClearColor
.f
[1], 0.0F
, 1.0F
);
995 v
->value_float_4
[2] = CLAMP(ctx
->Color
.ClearColor
.f
[2], 0.0F
, 1.0F
);
996 v
->value_float_4
[3] = CLAMP(ctx
->Color
.ClearColor
.f
[3], 0.0F
, 1.0F
);
998 COPY_4FV(v
->value_float_4
, ctx
->Color
.ClearColor
.f
);
1000 case GL_BLEND_COLOR_EXT
:
1001 if (_mesa_get_clamp_fragment_color(ctx
, ctx
->DrawBuffer
))
1002 COPY_4FV(v
->value_float_4
, ctx
->Color
.BlendColor
);
1004 COPY_4FV(v
->value_float_4
, ctx
->Color
.BlendColorUnclamped
);
1006 case GL_ALPHA_TEST_REF
:
1007 if (_mesa_get_clamp_fragment_color(ctx
, ctx
->DrawBuffer
))
1008 v
->value_float
= ctx
->Color
.AlphaRef
;
1010 v
->value_float
= ctx
->Color
.AlphaRefUnclamped
;
1012 case GL_MAX_VERTEX_UNIFORM_VECTORS
:
1013 v
->value_int
= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxUniformComponents
/ 4;
1016 case GL_MAX_FRAGMENT_UNIFORM_VECTORS
:
1017 v
->value_int
= ctx
->Const
.Program
[MESA_SHADER_FRAGMENT
].MaxUniformComponents
/ 4;
1020 /* GL_ARB_texture_buffer_object */
1021 case GL_TEXTURE_BUFFER_ARB
:
1022 v
->value_int
= ctx
->Texture
.BufferObject
->Name
;
1024 case GL_TEXTURE_BINDING_BUFFER_ARB
:
1025 unit
= ctx
->Texture
.CurrentUnit
;
1027 ctx
->Texture
.Unit
[unit
].CurrentTex
[TEXTURE_BUFFER_INDEX
]->Name
;
1029 case GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB
:
1031 struct gl_buffer_object
*buf
=
1032 ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
]
1033 .CurrentTex
[TEXTURE_BUFFER_INDEX
]->BufferObject
;
1034 v
->value_int
= buf
? buf
->Name
: 0;
1037 case GL_TEXTURE_BUFFER_FORMAT_ARB
:
1038 v
->value_int
= ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
]
1039 .CurrentTex
[TEXTURE_BUFFER_INDEX
]->BufferObjectFormat
;
1042 /* GL_ARB_sampler_objects */
1043 case GL_SAMPLER_BINDING
:
1045 struct gl_sampler_object
*samp
=
1046 ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
].Sampler
;
1047 v
->value_int
= samp
? samp
->Name
: 0;
1050 /* GL_ARB_uniform_buffer_object */
1051 case GL_UNIFORM_BUFFER_BINDING
:
1052 v
->value_int
= ctx
->UniformBuffer
->Name
;
1054 /* GL_ARB_shader_storage_buffer_object */
1055 case GL_SHADER_STORAGE_BUFFER_BINDING
:
1056 v
->value_int
= ctx
->ShaderStorageBuffer
->Name
;
1058 /* GL_ARB_query_buffer_object */
1059 case GL_QUERY_BUFFER_BINDING
:
1060 v
->value_int
= ctx
->QueryBuffer
->Name
;
1062 /* GL_ARB_timer_query */
1064 if (ctx
->Driver
.GetTimestamp
) {
1065 v
->value_int64
= ctx
->Driver
.GetTimestamp(ctx
);
1068 _mesa_problem(ctx
, "driver doesn't implement GetTimestamp");
1072 case GL_DEBUG_OUTPUT
:
1073 case GL_DEBUG_OUTPUT_SYNCHRONOUS
:
1074 case GL_DEBUG_LOGGED_MESSAGES
:
1075 case GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH
:
1076 case GL_DEBUG_GROUP_STACK_DEPTH
:
1077 v
->value_int
= _mesa_get_debug_state_int(ctx
, d
->pname
);
1079 /* GL_ARB_shader_atomic_counters */
1080 case GL_ATOMIC_COUNTER_BUFFER_BINDING
:
1081 if (ctx
->AtomicBuffer
) {
1082 v
->value_int
= ctx
->AtomicBuffer
->Name
;
1087 /* GL_ARB_draw_indirect */
1088 case GL_DRAW_INDIRECT_BUFFER_BINDING
:
1089 v
->value_int
= ctx
->DrawIndirectBuffer
->Name
;
1091 /* GL_ARB_indirect_parameters */
1092 case GL_PARAMETER_BUFFER_BINDING_ARB
:
1093 v
->value_int
= ctx
->ParameterBuffer
->Name
;
1095 /* GL_ARB_separate_shader_objects */
1096 case GL_PROGRAM_PIPELINE_BINDING
:
1097 if (ctx
->Pipeline
.Current
) {
1098 v
->value_int
= ctx
->Pipeline
.Current
->Name
;
1103 /* GL_ARB_compute_shader */
1104 case GL_DISPATCH_INDIRECT_BUFFER_BINDING
:
1105 v
->value_int
= ctx
->DispatchIndirectBuffer
->Name
;
1107 /* GL_ARB_multisample */
1109 v
->value_int
= _mesa_geometric_samples(ctx
->DrawBuffer
);
1111 case GL_SAMPLE_BUFFERS
:
1112 v
->value_int
= _mesa_geometric_samples(ctx
->DrawBuffer
) > 0;
1114 /* GL_EXT_textrue_integer */
1115 case GL_RGBA_INTEGER_MODE_EXT
:
1116 v
->value_int
= (ctx
->DrawBuffer
->_IntegerBuffers
!= 0);
1118 /* GL_ATI_meminfo & GL_NVX_gpu_memory_info */
1119 case GL_VBO_FREE_MEMORY_ATI
:
1120 case GL_TEXTURE_FREE_MEMORY_ATI
:
1121 case GL_RENDERBUFFER_FREE_MEMORY_ATI
:
1122 case GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX
:
1123 case GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX
:
1124 case GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX
:
1125 case GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX
:
1126 case GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX
:
1128 struct gl_memory_info info
;
1130 ctx
->Driver
.QueryMemoryInfo(ctx
, &info
);
1132 if (d
->pname
== GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX
)
1133 v
->value_int
= info
.total_device_memory
;
1134 else if (d
->pname
== GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX
)
1135 v
->value_int
= info
.total_device_memory
+
1136 info
.total_staging_memory
;
1137 else if (d
->pname
== GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX
)
1138 v
->value_int
= info
.avail_device_memory
;
1139 else if (d
->pname
== GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX
)
1140 v
->value_int
= info
.nr_device_memory_evictions
;
1141 else if (d
->pname
== GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX
)
1142 v
->value_int
= info
.device_memory_evicted
;
1144 /* ATI free memory enums.
1146 * Since the GPU memory is (usually) page-table based, every two
1147 * consecutive elements are equal. From the GL_ATI_meminfo
1150 * "param[0] - total memory free in the pool
1151 * param[1] - largest available free block in the pool
1152 * param[2] - total auxiliary memory free
1153 * param[3] - largest auxiliary free block"
1155 * All three (VBO, TEXTURE, RENDERBUFFER) queries return
1156 * the same numbers here.
1158 v
->value_int_4
[0] = info
.avail_device_memory
;
1159 v
->value_int_4
[1] = info
.avail_device_memory
;
1160 v
->value_int_4
[2] = info
.avail_staging_memory
;
1161 v
->value_int_4
[3] = info
.avail_staging_memory
;
1166 /* GL_ARB_get_program_binary */
1167 case GL_PROGRAM_BINARY_FORMATS
:
1168 assert(ctx
->Const
.NumProgramBinaryFormats
<= 1);
1169 v
->value_int_n
.n
= MIN2(ctx
->Const
.NumProgramBinaryFormats
, 1);
1170 if (ctx
->Const
.NumProgramBinaryFormats
> 0) {
1171 v
->value_int_n
.ints
[0] = GL_PROGRAM_BINARY_FORMAT_MESA
;
1174 /* GL_EXT_disjoint_timer_query */
1175 case GL_GPU_DISJOINT_EXT
:
1177 simple_mtx_lock(&ctx
->Shared
->Mutex
);
1178 v
->value_int
= ctx
->Shared
->DisjointOperation
;
1179 /* Reset state as expected by the spec. */
1180 ctx
->Shared
->DisjointOperation
= false;
1181 simple_mtx_unlock(&ctx
->Shared
->Mutex
);
1188 * Check extra constraints on a struct value_desc descriptor
1190 * If a struct value_desc has a non-NULL extra pointer, it means that
1191 * there are a number of extra constraints to check or actions to
1192 * perform. The extras is just an integer array where each integer
1193 * encode different constraints or actions.
1195 * \param ctx current context
1196 * \param func name of calling glGet*v() function for error reporting
1197 * \param d the struct value_desc that has the extra constraints
1199 * \return GL_FALSE if all of the constraints were not satisfied,
1200 * otherwise GL_TRUE.
1203 check_extra(struct gl_context
*ctx
, const char *func
, const struct value_desc
*d
)
1205 const GLuint version
= ctx
->Version
;
1206 GLboolean api_check
= GL_FALSE
;
1207 GLboolean api_found
= GL_FALSE
;
1210 for (e
= d
->extra
; *e
!= EXTRA_END
; e
++) {
1212 case EXTRA_VERSION_30
:
1213 api_check
= GL_TRUE
;
1215 api_found
= GL_TRUE
;
1217 case EXTRA_VERSION_31
:
1218 api_check
= GL_TRUE
;
1220 api_found
= GL_TRUE
;
1222 case EXTRA_VERSION_32
:
1223 api_check
= GL_TRUE
;
1225 api_found
= GL_TRUE
;
1227 case EXTRA_NEW_FRAG_CLAMP
:
1228 if (ctx
->NewState
& (_NEW_BUFFERS
| _NEW_FRAG_CLAMP
))
1229 _mesa_update_state(ctx
);
1232 api_check
= GL_TRUE
;
1233 if (ctx
->API
== API_OPENGLES2
)
1234 api_found
= GL_TRUE
;
1237 api_check
= GL_TRUE
;
1238 if (_mesa_is_gles3(ctx
))
1239 api_found
= GL_TRUE
;
1241 case EXTRA_API_ES31
:
1242 api_check
= GL_TRUE
;
1243 if (_mesa_is_gles31(ctx
))
1244 api_found
= GL_TRUE
;
1246 case EXTRA_API_ES32
:
1247 api_check
= GL_TRUE
;
1248 if (_mesa_is_gles32(ctx
))
1249 api_found
= GL_TRUE
;
1252 api_check
= GL_TRUE
;
1253 if (_mesa_is_desktop_gl(ctx
))
1254 api_found
= GL_TRUE
;
1256 case EXTRA_API_GL_CORE
:
1257 api_check
= GL_TRUE
;
1258 if (ctx
->API
== API_OPENGL_CORE
)
1259 api_found
= GL_TRUE
;
1261 case EXTRA_NEW_BUFFERS
:
1262 if (ctx
->NewState
& _NEW_BUFFERS
)
1263 _mesa_update_state(ctx
);
1265 case EXTRA_FLUSH_CURRENT
:
1266 FLUSH_CURRENT(ctx
, 0);
1268 case EXTRA_VALID_DRAW_BUFFER
:
1269 if (d
->pname
- GL_DRAW_BUFFER0_ARB
>= ctx
->Const
.MaxDrawBuffers
) {
1270 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(draw buffer %u)",
1271 func
, d
->pname
- GL_DRAW_BUFFER0_ARB
);
1275 case EXTRA_VALID_TEXTURE_UNIT
:
1276 if (ctx
->Texture
.CurrentUnit
>= ctx
->Const
.MaxTextureCoordUnits
) {
1277 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(texture %u)",
1278 func
, ctx
->Texture
.CurrentUnit
);
1282 case EXTRA_VALID_CLIP_DISTANCE
:
1283 if (d
->pname
- GL_CLIP_DISTANCE0
>= ctx
->Const
.MaxClipPlanes
) {
1284 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(clip distance %u)",
1285 func
, d
->pname
- GL_CLIP_DISTANCE0
);
1289 case EXTRA_GLSL_130
:
1290 api_check
= GL_TRUE
;
1291 if (ctx
->Const
.GLSLVersion
>= 130)
1292 api_found
= GL_TRUE
;
1294 case EXTRA_EXT_UBO_GS
:
1295 api_check
= GL_TRUE
;
1296 if (ctx
->Extensions
.ARB_uniform_buffer_object
&&
1297 _mesa_has_geometry_shaders(ctx
))
1298 api_found
= GL_TRUE
;
1300 case EXTRA_EXT_ATOMICS_GS
:
1301 api_check
= GL_TRUE
;
1302 if (ctx
->Extensions
.ARB_shader_atomic_counters
&&
1303 _mesa_has_geometry_shaders(ctx
))
1304 api_found
= GL_TRUE
;
1306 case EXTRA_EXT_SHADER_IMAGE_GS
:
1307 api_check
= GL_TRUE
;
1308 if (ctx
->Extensions
.ARB_shader_image_load_store
&&
1309 _mesa_has_geometry_shaders(ctx
))
1310 api_found
= GL_TRUE
;
1312 case EXTRA_EXT_ATOMICS_TESS
:
1313 api_check
= GL_TRUE
;
1314 api_found
= ctx
->Extensions
.ARB_shader_atomic_counters
&&
1315 _mesa_has_tessellation(ctx
);
1317 case EXTRA_EXT_SHADER_IMAGE_TESS
:
1318 api_check
= GL_TRUE
;
1319 api_found
= ctx
->Extensions
.ARB_shader_image_load_store
&&
1320 _mesa_has_tessellation(ctx
);
1322 case EXTRA_EXT_SSBO_GS
:
1323 api_check
= GL_TRUE
;
1324 if (ctx
->Extensions
.ARB_shader_storage_buffer_object
&&
1325 _mesa_has_geometry_shaders(ctx
))
1326 api_found
= GL_TRUE
;
1328 case EXTRA_EXT_FB_NO_ATTACH_GS
:
1329 api_check
= GL_TRUE
;
1330 if (ctx
->Extensions
.ARB_framebuffer_no_attachments
&&
1331 (_mesa_is_desktop_gl(ctx
) ||
1332 _mesa_has_OES_geometry_shader(ctx
)))
1333 api_found
= GL_TRUE
;
1335 case EXTRA_EXT_ES_GS
:
1336 api_check
= GL_TRUE
;
1337 if (_mesa_has_OES_geometry_shader(ctx
))
1338 api_found
= GL_TRUE
;
1340 case EXTRA_EXT_PROVOKING_VERTEX_32
:
1342 if (ctx
->API
== API_OPENGL_COMPAT
|| version
== 32)
1343 api_found
= ctx
->Extensions
.EXT_provoking_vertex
;
1347 default: /* *e is a offset into the extension struct */
1348 api_check
= GL_TRUE
;
1349 if (*(GLboolean
*) ((char *) &ctx
->Extensions
+ *e
))
1350 api_found
= GL_TRUE
;
1355 if (api_check
&& !api_found
) {
1356 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(pname=%s)", func
,
1357 _mesa_enum_to_string(d
->pname
));
1364 static const struct value_desc error_value
=
1365 { 0, 0, TYPE_INVALID
, NO_OFFSET
, NO_EXTRA
};
1368 * Find the struct value_desc corresponding to the enum 'pname'.
1370 * We hash the enum value to get an index into the 'table' array,
1371 * which holds the index in the 'values' array of struct value_desc.
1372 * Once we've found the entry, we do the extra checks, if any, then
1373 * look up the value and return a pointer to it.
1375 * If the value has to be computed (for example, it's the result of a
1376 * function call or we need to add 1 to it), we use the tmp 'v' to
1379 * \param func name of glGet*v() func for error reporting
1380 * \param pname the enum value we're looking up
1381 * \param p is were we return the pointer to the value
1382 * \param v a tmp union value variable in the calling glGet*v() function
1384 * \return the struct value_desc corresponding to the enum or a struct
1385 * value_desc of TYPE_INVALID if not found. This lets the calling
1386 * glGet*v() function jump right into a switch statement and
1387 * handle errors there instead of having to check for NULL.
1389 static const struct value_desc
*
1390 find_value(const char *func
, GLenum pname
, void **p
, union value
*v
)
1392 GET_CURRENT_CONTEXT(ctx
);
1393 struct gl_texture_unit
*unit
;
1395 const struct value_desc
*d
;
1399 /* We index into the table_set[] list of per-API hash tables using the API's
1400 * value in the gl_api enum. Since GLES 3 doesn't have an API_OPENGL* enum
1401 * value since it's compatible with GLES2 its entry in table_set[] is at the
1404 STATIC_ASSERT(ARRAY_SIZE(table_set
) == API_OPENGL_LAST
+ 4);
1405 if (ctx
->API
== API_OPENGLES2
) {
1406 if (ctx
->Version
>= 32)
1407 api
= API_OPENGL_LAST
+ 3;
1408 else if (ctx
->Version
>= 31)
1409 api
= API_OPENGL_LAST
+ 2;
1410 else if (ctx
->Version
>= 30)
1411 api
= API_OPENGL_LAST
+ 1;
1413 mask
= ARRAY_SIZE(table(api
)) - 1;
1414 hash
= (pname
* prime_factor
);
1416 int idx
= table(api
)[hash
& mask
];
1418 /* If the enum isn't valid, the hash walk ends with index 0,
1419 * pointing to the first entry of values[] which doesn't hold
1420 * any valid enum. */
1421 if (unlikely(idx
== 0)) {
1422 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(pname=%s)", func
,
1423 _mesa_enum_to_string(pname
));
1424 return &error_value
;
1428 if (likely(d
->pname
== pname
))
1434 if (unlikely(d
->extra
&& !check_extra(ctx
, func
, d
)))
1435 return &error_value
;
1437 switch (d
->location
) {
1439 *p
= ((char *) ctx
->DrawBuffer
+ d
->offset
);
1442 *p
= ((char *) ctx
+ d
->offset
);
1445 *p
= ((char *) ctx
->Array
.VAO
+ d
->offset
);
1448 unit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1449 *p
= ((char *) unit
+ d
->offset
);
1452 find_custom_value(ctx
, d
, v
);
1460 /* silence warning */
1461 return &error_value
;
1464 static const int transpose
[] = {
1472 get_value_size(enum value_type type
, const union value
*v
)
1480 return sizeof(GLint
);
1483 return sizeof(GLint
) * 2;
1486 return sizeof(GLint
) * 3;
1489 return sizeof(GLint
) * 4;
1491 return sizeof(GLint
) * v
->value_int_n
.n
;
1493 return sizeof(GLint64
);
1496 return sizeof(GLenum16
);
1498 return sizeof(GLenum
);
1500 return sizeof(GLenum
) * 2;
1502 return sizeof(GLboolean
);
1514 return sizeof(GLfloat
);
1517 return sizeof(GLfloat
) * 2;
1520 return sizeof(GLfloat
) * 3;
1523 return sizeof(GLfloat
) * 4;
1525 return sizeof(GLfloat
) * 8;
1527 return sizeof(GLdouble
);
1528 case TYPE_DOUBLEN_2
:
1529 return sizeof(GLdouble
) * 2;
1531 return sizeof (GLfloat
) * 16;
1533 return sizeof (GLfloat
) * 16;
1540 _mesa_GetBooleanv(GLenum pname
, GLboolean
*params
)
1542 const struct value_desc
*d
;
1548 d
= find_value("glGetBooleanv", pname
, &p
, &v
);
1553 params
[0] = INT_TO_BOOLEAN(d
->offset
);
1557 params
[7] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[7]);
1558 params
[6] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[6]);
1559 params
[5] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[5]);
1560 params
[4] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[4]);
1563 params
[3] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[3]);
1566 params
[2] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[2]);
1569 params
[1] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[1]);
1572 params
[0] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[0]);
1575 case TYPE_DOUBLEN_2
:
1576 params
[1] = FLOAT_TO_BOOLEAN(((GLdouble
*) p
)[1]);
1578 params
[0] = FLOAT_TO_BOOLEAN(((GLdouble
*) p
)[0]);
1583 params
[3] = INT_TO_BOOLEAN(((GLint
*) p
)[3]);
1586 params
[2] = INT_TO_BOOLEAN(((GLint
*) p
)[2]);
1590 params
[1] = INT_TO_BOOLEAN(((GLint
*) p
)[1]);
1594 params
[0] = INT_TO_BOOLEAN(((GLint
*) p
)[0]);
1598 params
[0] = INT_TO_BOOLEAN(((GLenum16
*) p
)[0]);
1602 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
1603 params
[i
] = INT_TO_BOOLEAN(v
.value_int_n
.ints
[i
]);
1607 params
[0] = INT64_TO_BOOLEAN(((GLint64
*) p
)[0]);
1611 params
[0] = ((GLboolean
*) p
)[0];
1615 m
= *(GLmatrix
**) p
;
1616 for (i
= 0; i
< 16; i
++)
1617 params
[i
] = FLOAT_TO_BOOLEAN(m
->m
[i
]);
1621 m
= *(GLmatrix
**) p
;
1622 for (i
= 0; i
< 16; i
++)
1623 params
[i
] = FLOAT_TO_BOOLEAN(m
->m
[transpose
[i
]]);
1634 shift
= d
->type
- TYPE_BIT_0
;
1635 params
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
1641 _mesa_GetFloatv(GLenum pname
, GLfloat
*params
)
1643 const struct value_desc
*d
;
1649 d
= find_value("glGetFloatv", pname
, &p
, &v
);
1654 params
[0] = (GLfloat
) d
->offset
;
1658 params
[7] = ((GLfloat
*) p
)[7];
1659 params
[6] = ((GLfloat
*) p
)[6];
1660 params
[5] = ((GLfloat
*) p
)[5];
1661 params
[4] = ((GLfloat
*) p
)[4];
1664 params
[3] = ((GLfloat
*) p
)[3];
1667 params
[2] = ((GLfloat
*) p
)[2];
1670 params
[1] = ((GLfloat
*) p
)[1];
1673 params
[0] = ((GLfloat
*) p
)[0];
1676 case TYPE_DOUBLEN_2
:
1677 params
[1] = (GLfloat
) (((GLdouble
*) p
)[1]);
1679 params
[0] = (GLfloat
) (((GLdouble
*) p
)[0]);
1683 params
[3] = (GLfloat
) (((GLint
*) p
)[3]);
1685 params
[2] = (GLfloat
) (((GLint
*) p
)[2]);
1688 params
[1] = (GLfloat
) (((GLint
*) p
)[1]);
1691 params
[0] = (GLfloat
) (((GLint
*) p
)[0]);
1695 params
[0] = (GLfloat
) (((GLenum16
*) p
)[0]);
1699 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
1700 params
[i
] = (GLfloat
) v
.value_int_n
.ints
[i
];
1704 params
[3] = (GLfloat
) (((GLuint
*) p
)[3]);
1706 params
[2] = (GLfloat
) (((GLuint
*) p
)[2]);
1708 params
[1] = (GLfloat
) (((GLuint
*) p
)[1]);
1710 params
[0] = (GLfloat
) (((GLuint
*) p
)[0]);
1714 params
[0] = (GLfloat
) (((GLint64
*) p
)[0]);
1718 params
[0] = BOOLEAN_TO_FLOAT(*(GLboolean
*) p
);
1722 m
= *(GLmatrix
**) p
;
1723 for (i
= 0; i
< 16; i
++)
1724 params
[i
] = m
->m
[i
];
1728 m
= *(GLmatrix
**) p
;
1729 for (i
= 0; i
< 16; i
++)
1730 params
[i
] = m
->m
[transpose
[i
]];
1741 shift
= d
->type
- TYPE_BIT_0
;
1742 params
[0] = BOOLEAN_TO_FLOAT((*(GLbitfield
*) p
>> shift
) & 1);
1748 _mesa_GetIntegerv(GLenum pname
, GLint
*params
)
1750 const struct value_desc
*d
;
1756 d
= find_value("glGetIntegerv", pname
, &p
, &v
);
1761 params
[0] = d
->offset
;
1765 params
[7] = IROUND(((GLfloat
*) p
)[7]);
1766 params
[6] = IROUND(((GLfloat
*) p
)[6]);
1767 params
[5] = IROUND(((GLfloat
*) p
)[5]);
1768 params
[4] = IROUND(((GLfloat
*) p
)[4]);
1770 params
[3] = IROUND(((GLfloat
*) p
)[3]);
1772 params
[2] = IROUND(((GLfloat
*) p
)[2]);
1774 params
[1] = IROUND(((GLfloat
*) p
)[1]);
1776 params
[0] = IROUND(((GLfloat
*) p
)[0]);
1780 params
[3] = FLOAT_TO_INT(((GLfloat
*) p
)[3]);
1782 params
[2] = FLOAT_TO_INT(((GLfloat
*) p
)[2]);
1784 params
[1] = FLOAT_TO_INT(((GLfloat
*) p
)[1]);
1786 params
[0] = FLOAT_TO_INT(((GLfloat
*) p
)[0]);
1789 case TYPE_DOUBLEN_2
:
1790 params
[1] = FLOAT_TO_INT(((GLdouble
*) p
)[1]);
1792 params
[0] = FLOAT_TO_INT(((GLdouble
*) p
)[0]);
1797 params
[3] = ((GLint
*) p
)[3];
1800 params
[2] = ((GLint
*) p
)[2];
1804 params
[1] = ((GLint
*) p
)[1];
1808 params
[0] = ((GLint
*) p
)[0];
1812 params
[0] = ((GLenum16
*) p
)[0];
1816 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
1817 params
[i
] = v
.value_int_n
.ints
[i
];
1821 params
[0] = INT64_TO_INT(((GLint64
*) p
)[0]);
1825 params
[0] = BOOLEAN_TO_INT(*(GLboolean
*) p
);
1829 m
= *(GLmatrix
**) p
;
1830 for (i
= 0; i
< 16; i
++)
1831 params
[i
] = FLOAT_TO_INT(m
->m
[i
]);
1835 m
= *(GLmatrix
**) p
;
1836 for (i
= 0; i
< 16; i
++)
1837 params
[i
] = FLOAT_TO_INT(m
->m
[transpose
[i
]]);
1848 shift
= d
->type
- TYPE_BIT_0
;
1849 params
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
1855 _mesa_GetInteger64v(GLenum pname
, GLint64
*params
)
1857 const struct value_desc
*d
;
1863 d
= find_value("glGetInteger64v", pname
, &p
, &v
);
1868 params
[0] = d
->offset
;
1872 params
[7] = IROUND64(((GLfloat
*) p
)[7]);
1873 params
[6] = IROUND64(((GLfloat
*) p
)[6]);
1874 params
[5] = IROUND64(((GLfloat
*) p
)[5]);
1875 params
[4] = IROUND64(((GLfloat
*) p
)[4]);
1877 params
[3] = IROUND64(((GLfloat
*) p
)[3]);
1879 params
[2] = IROUND64(((GLfloat
*) p
)[2]);
1881 params
[1] = IROUND64(((GLfloat
*) p
)[1]);
1883 params
[0] = IROUND64(((GLfloat
*) p
)[0]);
1887 params
[3] = FLOAT_TO_INT(((GLfloat
*) p
)[3]);
1889 params
[2] = FLOAT_TO_INT(((GLfloat
*) p
)[2]);
1891 params
[1] = FLOAT_TO_INT(((GLfloat
*) p
)[1]);
1893 params
[0] = FLOAT_TO_INT(((GLfloat
*) p
)[0]);
1896 case TYPE_DOUBLEN_2
:
1897 params
[1] = FLOAT_TO_INT(((GLdouble
*) p
)[1]);
1899 params
[0] = FLOAT_TO_INT(((GLdouble
*) p
)[0]);
1903 params
[3] = ((GLint
*) p
)[3];
1905 params
[2] = ((GLint
*) p
)[2];
1908 params
[1] = ((GLint
*) p
)[1];
1911 params
[0] = ((GLint
*) p
)[0];
1915 params
[0] = ((GLenum16
*) p
)[0];
1919 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
1920 params
[i
] = INT_TO_BOOLEAN(v
.value_int_n
.ints
[i
]);
1924 params
[3] = ((GLuint
*) p
)[3];
1926 params
[2] = ((GLuint
*) p
)[2];
1928 params
[1] = ((GLuint
*) p
)[1];
1930 params
[0] = ((GLuint
*) p
)[0];
1934 params
[0] = ((GLint64
*) p
)[0];
1938 params
[0] = ((GLboolean
*) p
)[0];
1942 m
= *(GLmatrix
**) p
;
1943 for (i
= 0; i
< 16; i
++)
1944 params
[i
] = FLOAT_TO_INT64(m
->m
[i
]);
1948 m
= *(GLmatrix
**) p
;
1949 for (i
= 0; i
< 16; i
++)
1950 params
[i
] = FLOAT_TO_INT64(m
->m
[transpose
[i
]]);
1961 shift
= d
->type
- TYPE_BIT_0
;
1962 params
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
1968 _mesa_GetDoublev(GLenum pname
, GLdouble
*params
)
1970 const struct value_desc
*d
;
1976 d
= find_value("glGetDoublev", pname
, &p
, &v
);
1981 params
[0] = d
->offset
;
1985 params
[7] = ((GLfloat
*) p
)[7];
1986 params
[6] = ((GLfloat
*) p
)[6];
1987 params
[5] = ((GLfloat
*) p
)[5];
1988 params
[4] = ((GLfloat
*) p
)[4];
1991 params
[3] = ((GLfloat
*) p
)[3];
1994 params
[2] = ((GLfloat
*) p
)[2];
1997 params
[1] = ((GLfloat
*) p
)[1];
2000 params
[0] = ((GLfloat
*) p
)[0];
2003 case TYPE_DOUBLEN_2
:
2004 params
[1] = ((GLdouble
*) p
)[1];
2006 params
[0] = ((GLdouble
*) p
)[0];
2010 params
[3] = ((GLint
*) p
)[3];
2012 params
[2] = ((GLint
*) p
)[2];
2015 params
[1] = ((GLint
*) p
)[1];
2018 params
[0] = ((GLint
*) p
)[0];
2022 params
[0] = ((GLenum16
*) p
)[0];
2026 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
2027 params
[i
] = v
.value_int_n
.ints
[i
];
2031 params
[3] = ((GLuint
*) p
)[3];
2033 params
[2] = ((GLuint
*) p
)[2];
2035 params
[1] = ((GLuint
*) p
)[1];
2037 params
[0] = ((GLuint
*) p
)[0];
2041 params
[0] = (GLdouble
) (((GLint64
*) p
)[0]);
2045 params
[0] = *(GLboolean
*) p
;
2049 m
= *(GLmatrix
**) p
;
2050 for (i
= 0; i
< 16; i
++)
2051 params
[i
] = m
->m
[i
];
2055 m
= *(GLmatrix
**) p
;
2056 for (i
= 0; i
< 16; i
++)
2057 params
[i
] = m
->m
[transpose
[i
]];
2068 shift
= d
->type
- TYPE_BIT_0
;
2069 params
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
2075 _mesa_GetUnsignedBytevEXT(GLenum pname
, GLubyte
*data
)
2077 const struct value_desc
*d
;
2082 const char *func
= "glGetUnsignedBytevEXT";
2084 GET_CURRENT_CONTEXT(ctx
);
2086 if (!ctx
->Extensions
.EXT_memory_object
) {
2087 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(unsupported)", func
);
2091 d
= find_value(func
, pname
, &p
, &v
);
2092 size
= get_value_size(d
->type
, &v
);
2094 _mesa_problem(ctx
, "invalid value type in GetUnsignedBytevEXT()");
2106 shift
= d
->type
- TYPE_BIT_0
;
2107 data
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
2110 memcpy(data
, &d
->offset
, size
);
2113 memcpy(data
, &v
.value_int_n
.ints
, size
);
2137 case TYPE_DOUBLEN_2
:
2140 memcpy(data
, p
, size
);
2143 GLenum e
= *(GLenum16
*)p
;
2144 memcpy(data
, &e
, sizeof(e
));
2148 break; /* nothing - GL error was recorded */
2153 * Convert a GL texture binding enum such as GL_TEXTURE_BINDING_2D
2154 * into the corresponding Mesa texture target index.
2155 * \return TEXTURE_x_INDEX or -1 if binding is invalid
2158 tex_binding_to_index(const struct gl_context
*ctx
, GLenum binding
)
2161 case GL_TEXTURE_BINDING_1D
:
2162 return _mesa_is_desktop_gl(ctx
) ? TEXTURE_1D_INDEX
: -1;
2163 case GL_TEXTURE_BINDING_2D
:
2164 return TEXTURE_2D_INDEX
;
2165 case GL_TEXTURE_BINDING_3D
:
2166 return ctx
->API
!= API_OPENGLES
? TEXTURE_3D_INDEX
: -1;
2167 case GL_TEXTURE_BINDING_CUBE_MAP
:
2168 return ctx
->Extensions
.ARB_texture_cube_map
2169 ? TEXTURE_CUBE_INDEX
: -1;
2170 case GL_TEXTURE_BINDING_RECTANGLE
:
2171 return _mesa_is_desktop_gl(ctx
) && ctx
->Extensions
.NV_texture_rectangle
2172 ? TEXTURE_RECT_INDEX
: -1;
2173 case GL_TEXTURE_BINDING_1D_ARRAY
:
2174 return _mesa_is_desktop_gl(ctx
) && ctx
->Extensions
.EXT_texture_array
2175 ? TEXTURE_1D_ARRAY_INDEX
: -1;
2176 case GL_TEXTURE_BINDING_2D_ARRAY
:
2177 return (_mesa_is_desktop_gl(ctx
) && ctx
->Extensions
.EXT_texture_array
)
2178 || _mesa_is_gles3(ctx
)
2179 ? TEXTURE_2D_ARRAY_INDEX
: -1;
2180 case GL_TEXTURE_BINDING_BUFFER
:
2181 return (_mesa_has_ARB_texture_buffer_object(ctx
) ||
2182 _mesa_has_OES_texture_buffer(ctx
)) ?
2183 TEXTURE_BUFFER_INDEX
: -1;
2184 case GL_TEXTURE_BINDING_CUBE_MAP_ARRAY
:
2185 return _mesa_has_texture_cube_map_array(ctx
)
2186 ? TEXTURE_CUBE_ARRAY_INDEX
: -1;
2187 case GL_TEXTURE_BINDING_2D_MULTISAMPLE
:
2188 return _mesa_is_desktop_gl(ctx
) && ctx
->Extensions
.ARB_texture_multisample
2189 ? TEXTURE_2D_MULTISAMPLE_INDEX
: -1;
2190 case GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY
:
2191 return _mesa_is_desktop_gl(ctx
) && ctx
->Extensions
.ARB_texture_multisample
2192 ? TEXTURE_2D_MULTISAMPLE_ARRAY_INDEX
: -1;
2198 static enum value_type
2199 find_value_indexed(const char *func
, GLenum pname
, GLuint index
, union value
*v
)
2201 GET_CURRENT_CONTEXT(ctx
);
2206 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2208 if (!ctx
->Extensions
.EXT_draw_buffers2
)
2210 v
->value_int
= (ctx
->Color
.BlendEnabled
>> index
) & 1;
2215 case GL_BLEND_SRC_RGB
:
2216 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2218 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
2220 v
->value_int
= ctx
->Color
.Blend
[index
].SrcRGB
;
2222 case GL_BLEND_SRC_ALPHA
:
2223 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2225 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
2227 v
->value_int
= ctx
->Color
.Blend
[index
].SrcA
;
2231 case GL_BLEND_DST_RGB
:
2232 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2234 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
2236 v
->value_int
= ctx
->Color
.Blend
[index
].DstRGB
;
2238 case GL_BLEND_DST_ALPHA
:
2239 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2241 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
2243 v
->value_int
= ctx
->Color
.Blend
[index
].DstA
;
2245 case GL_BLEND_EQUATION_RGB
:
2246 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2248 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
2250 v
->value_int
= ctx
->Color
.Blend
[index
].EquationRGB
;
2252 case GL_BLEND_EQUATION_ALPHA
:
2253 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2255 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
2257 v
->value_int
= ctx
->Color
.Blend
[index
].EquationA
;
2260 case GL_COLOR_WRITEMASK
:
2261 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2263 if (!ctx
->Extensions
.EXT_draw_buffers2
)
2265 v
->value_int_4
[0] = ctx
->Color
.ColorMask
[index
][RCOMP
] ? 1 : 0;
2266 v
->value_int_4
[1] = ctx
->Color
.ColorMask
[index
][GCOMP
] ? 1 : 0;
2267 v
->value_int_4
[2] = ctx
->Color
.ColorMask
[index
][BCOMP
] ? 1 : 0;
2268 v
->value_int_4
[3] = ctx
->Color
.ColorMask
[index
][ACOMP
] ? 1 : 0;
2271 case GL_SCISSOR_BOX
:
2272 if (index
>= ctx
->Const
.MaxViewports
)
2274 v
->value_int_4
[0] = ctx
->Scissor
.ScissorArray
[index
].X
;
2275 v
->value_int_4
[1] = ctx
->Scissor
.ScissorArray
[index
].Y
;
2276 v
->value_int_4
[2] = ctx
->Scissor
.ScissorArray
[index
].Width
;
2277 v
->value_int_4
[3] = ctx
->Scissor
.ScissorArray
[index
].Height
;
2280 case GL_WINDOW_RECTANGLE_EXT
:
2281 if (!ctx
->Extensions
.EXT_window_rectangles
)
2283 if (index
>= ctx
->Const
.MaxWindowRectangles
)
2285 v
->value_int_4
[0] = ctx
->Scissor
.WindowRects
[index
].X
;
2286 v
->value_int_4
[1] = ctx
->Scissor
.WindowRects
[index
].Y
;
2287 v
->value_int_4
[2] = ctx
->Scissor
.WindowRects
[index
].Width
;
2288 v
->value_int_4
[3] = ctx
->Scissor
.WindowRects
[index
].Height
;
2292 if (index
>= ctx
->Const
.MaxViewports
)
2294 v
->value_float_4
[0] = ctx
->ViewportArray
[index
].X
;
2295 v
->value_float_4
[1] = ctx
->ViewportArray
[index
].Y
;
2296 v
->value_float_4
[2] = ctx
->ViewportArray
[index
].Width
;
2297 v
->value_float_4
[3] = ctx
->ViewportArray
[index
].Height
;
2298 return TYPE_FLOAT_4
;
2300 case GL_DEPTH_RANGE
:
2301 if (index
>= ctx
->Const
.MaxViewports
)
2303 v
->value_double_2
[0] = ctx
->ViewportArray
[index
].Near
;
2304 v
->value_double_2
[1] = ctx
->ViewportArray
[index
].Far
;
2305 return TYPE_DOUBLEN_2
;
2307 case GL_TRANSFORM_FEEDBACK_BUFFER_START
:
2308 if (index
>= ctx
->Const
.MaxTransformFeedbackBuffers
)
2310 if (!ctx
->Extensions
.EXT_transform_feedback
)
2312 v
->value_int64
= ctx
->TransformFeedback
.CurrentObject
->Offset
[index
];
2315 case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE
:
2316 if (index
>= ctx
->Const
.MaxTransformFeedbackBuffers
)
2318 if (!ctx
->Extensions
.EXT_transform_feedback
)
2321 = ctx
->TransformFeedback
.CurrentObject
->RequestedSize
[index
];
2324 case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING
:
2325 if (index
>= ctx
->Const
.MaxTransformFeedbackBuffers
)
2327 if (!ctx
->Extensions
.EXT_transform_feedback
)
2329 v
->value_int
= ctx
->TransformFeedback
.CurrentObject
->BufferNames
[index
];
2332 case GL_UNIFORM_BUFFER_BINDING
:
2333 if (index
>= ctx
->Const
.MaxUniformBufferBindings
)
2335 if (!ctx
->Extensions
.ARB_uniform_buffer_object
)
2337 v
->value_int
= ctx
->UniformBufferBindings
[index
].BufferObject
->Name
;
2340 case GL_UNIFORM_BUFFER_START
:
2341 if (index
>= ctx
->Const
.MaxUniformBufferBindings
)
2343 if (!ctx
->Extensions
.ARB_uniform_buffer_object
)
2345 v
->value_int
= ctx
->UniformBufferBindings
[index
].Offset
< 0 ? 0 :
2346 ctx
->UniformBufferBindings
[index
].Offset
;
2349 case GL_UNIFORM_BUFFER_SIZE
:
2350 if (index
>= ctx
->Const
.MaxUniformBufferBindings
)
2352 if (!ctx
->Extensions
.ARB_uniform_buffer_object
)
2354 v
->value_int
= ctx
->UniformBufferBindings
[index
].Size
< 0 ? 0 :
2355 ctx
->UniformBufferBindings
[index
].Size
;
2358 /* ARB_shader_storage_buffer_object */
2359 case GL_SHADER_STORAGE_BUFFER_BINDING
:
2360 if (!ctx
->Extensions
.ARB_shader_storage_buffer_object
)
2362 if (index
>= ctx
->Const
.MaxShaderStorageBufferBindings
)
2364 v
->value_int
= ctx
->ShaderStorageBufferBindings
[index
].BufferObject
->Name
;
2367 case GL_SHADER_STORAGE_BUFFER_START
:
2368 if (!ctx
->Extensions
.ARB_shader_storage_buffer_object
)
2370 if (index
>= ctx
->Const
.MaxShaderStorageBufferBindings
)
2372 v
->value_int
= ctx
->ShaderStorageBufferBindings
[index
].Offset
< 0 ? 0 :
2373 ctx
->ShaderStorageBufferBindings
[index
].Offset
;
2376 case GL_SHADER_STORAGE_BUFFER_SIZE
:
2377 if (!ctx
->Extensions
.ARB_shader_storage_buffer_object
)
2379 if (index
>= ctx
->Const
.MaxShaderStorageBufferBindings
)
2381 v
->value_int
= ctx
->ShaderStorageBufferBindings
[index
].Size
< 0 ? 0 :
2382 ctx
->ShaderStorageBufferBindings
[index
].Size
;
2385 /* ARB_texture_multisample / GL3.2 */
2386 case GL_SAMPLE_MASK_VALUE
:
2389 if (!ctx
->Extensions
.ARB_texture_multisample
)
2391 v
->value_int
= ctx
->Multisample
.SampleMaskValue
;
2394 case GL_ATOMIC_COUNTER_BUFFER_BINDING
:
2395 if (!ctx
->Extensions
.ARB_shader_atomic_counters
)
2397 if (index
>= ctx
->Const
.MaxAtomicBufferBindings
)
2399 v
->value_int
= ctx
->AtomicBufferBindings
[index
].BufferObject
->Name
;
2402 case GL_ATOMIC_COUNTER_BUFFER_START
:
2403 if (!ctx
->Extensions
.ARB_shader_atomic_counters
)
2405 if (index
>= ctx
->Const
.MaxAtomicBufferBindings
)
2407 v
->value_int64
= ctx
->AtomicBufferBindings
[index
].Offset
< 0 ? 0 :
2408 ctx
->AtomicBufferBindings
[index
].Offset
;
2411 case GL_ATOMIC_COUNTER_BUFFER_SIZE
:
2412 if (!ctx
->Extensions
.ARB_shader_atomic_counters
)
2414 if (index
>= ctx
->Const
.MaxAtomicBufferBindings
)
2416 v
->value_int64
= ctx
->AtomicBufferBindings
[index
].Size
< 0 ? 0 :
2417 ctx
->AtomicBufferBindings
[index
].Size
;
2420 case GL_VERTEX_BINDING_DIVISOR
:
2421 if ((!_mesa_is_desktop_gl(ctx
) || !ctx
->Extensions
.ARB_instanced_arrays
) &&
2422 !_mesa_is_gles31(ctx
))
2424 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
)
2426 v
->value_int
= ctx
->Array
.VAO
->BufferBinding
[VERT_ATTRIB_GENERIC(index
)].InstanceDivisor
;
2429 case GL_VERTEX_BINDING_OFFSET
:
2430 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles31(ctx
))
2432 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
)
2434 v
->value_int
= ctx
->Array
.VAO
->BufferBinding
[VERT_ATTRIB_GENERIC(index
)].Offset
;
2437 case GL_VERTEX_BINDING_STRIDE
:
2438 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles31(ctx
))
2440 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
)
2442 v
->value_int
= ctx
->Array
.VAO
->BufferBinding
[VERT_ATTRIB_GENERIC(index
)].Stride
;
2445 case GL_VERTEX_BINDING_BUFFER
:
2446 if (ctx
->API
== API_OPENGLES2
&& ctx
->Version
< 31)
2448 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
)
2450 v
->value_int
= ctx
->Array
.VAO
->BufferBinding
[VERT_ATTRIB_GENERIC(index
)].BufferObj
->Name
;
2453 /* ARB_shader_image_load_store */
2454 case GL_IMAGE_BINDING_NAME
: {
2455 struct gl_texture_object
*t
;
2457 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
2459 if (index
>= ctx
->Const
.MaxImageUnits
)
2462 t
= ctx
->ImageUnits
[index
].TexObj
;
2463 v
->value_int
= (t
? t
->Name
: 0);
2467 case GL_IMAGE_BINDING_LEVEL
:
2468 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
2470 if (index
>= ctx
->Const
.MaxImageUnits
)
2473 v
->value_int
= ctx
->ImageUnits
[index
].Level
;
2476 case GL_IMAGE_BINDING_LAYERED
:
2477 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
2479 if (index
>= ctx
->Const
.MaxImageUnits
)
2482 v
->value_int
= ctx
->ImageUnits
[index
].Layered
;
2485 case GL_IMAGE_BINDING_LAYER
:
2486 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
2488 if (index
>= ctx
->Const
.MaxImageUnits
)
2491 v
->value_int
= ctx
->ImageUnits
[index
].Layer
;
2494 case GL_IMAGE_BINDING_ACCESS
:
2495 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
2497 if (index
>= ctx
->Const
.MaxImageUnits
)
2500 v
->value_int
= ctx
->ImageUnits
[index
].Access
;
2503 case GL_IMAGE_BINDING_FORMAT
:
2504 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
2506 if (index
>= ctx
->Const
.MaxImageUnits
)
2509 v
->value_int
= ctx
->ImageUnits
[index
].Format
;
2512 /* ARB_direct_state_access */
2513 case GL_TEXTURE_BINDING_1D
:
2514 case GL_TEXTURE_BINDING_1D_ARRAY
:
2515 case GL_TEXTURE_BINDING_2D
:
2516 case GL_TEXTURE_BINDING_2D_ARRAY
:
2517 case GL_TEXTURE_BINDING_2D_MULTISAMPLE
:
2518 case GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY
:
2519 case GL_TEXTURE_BINDING_3D
:
2520 case GL_TEXTURE_BINDING_BUFFER
:
2521 case GL_TEXTURE_BINDING_CUBE_MAP
:
2522 case GL_TEXTURE_BINDING_CUBE_MAP_ARRAY
:
2523 case GL_TEXTURE_BINDING_RECTANGLE
: {
2526 if (ctx
->API
!= API_OPENGL_CORE
)
2528 target
= tex_binding_to_index(ctx
, pname
);
2531 if (index
>= _mesa_max_tex_unit(ctx
))
2534 v
->value_int
= ctx
->Texture
.Unit
[index
].CurrentTex
[target
]->Name
;
2538 case GL_SAMPLER_BINDING
: {
2539 struct gl_sampler_object
*samp
;
2541 if (ctx
->API
!= API_OPENGL_CORE
)
2543 if (index
>= _mesa_max_tex_unit(ctx
))
2546 samp
= ctx
->Texture
.Unit
[index
].Sampler
;
2547 v
->value_int
= samp
? samp
->Name
: 0;
2551 case GL_MAX_COMPUTE_WORK_GROUP_COUNT
:
2552 if (!_mesa_has_compute_shaders(ctx
))
2556 v
->value_int
= ctx
->Const
.MaxComputeWorkGroupCount
[index
];
2559 case GL_MAX_COMPUTE_WORK_GROUP_SIZE
:
2560 if (!_mesa_has_compute_shaders(ctx
))
2564 v
->value_int
= ctx
->Const
.MaxComputeWorkGroupSize
[index
];
2567 /* ARB_compute_variable_group_size */
2568 case GL_MAX_COMPUTE_VARIABLE_GROUP_SIZE_ARB
:
2569 if (!ctx
->Extensions
.ARB_compute_variable_group_size
)
2573 v
->value_int
= ctx
->Const
.MaxComputeVariableGroupSize
[index
];
2576 /* GL_EXT_external_objects */
2577 case GL_NUM_DEVICE_UUIDS_EXT
:
2580 case GL_DRIVER_UUID_EXT
:
2581 _mesa_get_driver_uuid(ctx
, v
->value_int_4
);
2583 case GL_DEVICE_UUID_EXT
:
2584 _mesa_get_device_uuid(ctx
, v
->value_int_4
);
2589 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(pname=%s)", func
,
2590 _mesa_enum_to_string(pname
));
2591 return TYPE_INVALID
;
2593 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(pname=%s)", func
,
2594 _mesa_enum_to_string(pname
));
2595 return TYPE_INVALID
;
2599 _mesa_GetBooleani_v( GLenum pname
, GLuint index
, GLboolean
*params
)
2602 enum value_type type
=
2603 find_value_indexed("glGetBooleani_v", pname
, index
, &v
);
2608 params
[0] = INT_TO_BOOLEAN(v
.value_int
);
2612 params
[0] = INT_TO_BOOLEAN(v
.value_int_4
[0]);
2613 params
[1] = INT_TO_BOOLEAN(v
.value_int_4
[1]);
2614 params
[2] = INT_TO_BOOLEAN(v
.value_int_4
[2]);
2615 params
[3] = INT_TO_BOOLEAN(v
.value_int_4
[3]);
2618 params
[0] = INT64_TO_BOOLEAN(v
.value_int64
);
2621 ; /* nothing - GL error was recorded */
2626 _mesa_GetIntegeri_v( GLenum pname
, GLuint index
, GLint
*params
)
2629 enum value_type type
=
2630 find_value_indexed("glGetIntegeri_v", pname
, index
, &v
);
2635 params
[3] = IROUND(v
.value_float_4
[3]);
2638 params
[2] = IROUND(v
.value_float_4
[2]);
2641 params
[1] = IROUND(v
.value_float_4
[1]);
2644 params
[0] = IROUND(v
.value_float_4
[0]);
2647 case TYPE_DOUBLEN_2
:
2648 params
[1] = IROUND(v
.value_double_2
[1]);
2650 params
[0] = IROUND(v
.value_double_2
[0]);
2655 params
[0] = v
.value_int
;
2659 params
[0] = v
.value_int_4
[0];
2660 params
[1] = v
.value_int_4
[1];
2661 params
[2] = v
.value_int_4
[2];
2662 params
[3] = v
.value_int_4
[3];
2665 params
[0] = INT64_TO_INT(v
.value_int64
);
2668 ; /* nothing - GL error was recorded */
2673 _mesa_GetInteger64i_v( GLenum pname
, GLuint index
, GLint64
*params
)
2676 enum value_type type
=
2677 find_value_indexed("glGetInteger64i_v", pname
, index
, &v
);
2681 params
[0] = v
.value_int
;
2684 params
[0] = v
.value_int_4
[0];
2685 params
[1] = v
.value_int_4
[1];
2686 params
[2] = v
.value_int_4
[2];
2687 params
[3] = v
.value_int_4
[3];
2690 params
[0] = (GLuint
) v
.value_int
;
2693 params
[0] = (GLuint
) v
.value_int_4
[0];
2694 params
[1] = (GLuint
) v
.value_int_4
[1];
2695 params
[2] = (GLuint
) v
.value_int_4
[2];
2696 params
[3] = (GLuint
) v
.value_int_4
[3];
2699 params
[0] = v
.value_int64
;
2702 ; /* nothing - GL error was recorded */
2707 _mesa_GetFloati_v(GLenum pname
, GLuint index
, GLfloat
*params
)
2712 enum value_type type
=
2713 find_value_indexed("glGetFloati_v", pname
, index
, &v
);
2718 params
[3] = v
.value_float_4
[3];
2721 params
[2] = v
.value_float_4
[2];
2724 params
[1] = v
.value_float_4
[1];
2727 params
[0] = v
.value_float_4
[0];
2730 case TYPE_DOUBLEN_2
:
2731 params
[1] = (GLfloat
) v
.value_double_2
[1];
2733 params
[0] = (GLfloat
) v
.value_double_2
[0];
2737 params
[3] = (GLfloat
) v
.value_int_4
[3];
2739 params
[2] = (GLfloat
) v
.value_int_4
[2];
2742 params
[1] = (GLfloat
) v
.value_int_4
[1];
2746 params
[0] = (GLfloat
) v
.value_int_4
[0];
2750 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
2751 params
[i
] = (GLfloat
) v
.value_int_n
.ints
[i
];
2755 params
[3] = (GLfloat
) ((GLuint
) v
.value_int_4
[3]);
2757 params
[2] = (GLfloat
) ((GLuint
) v
.value_int_4
[2]);
2759 params
[1] = (GLfloat
) ((GLuint
) v
.value_int_4
[1]);
2761 params
[0] = (GLfloat
) ((GLuint
) v
.value_int_4
[0]);
2765 params
[0] = (GLfloat
) v
.value_int64
;
2769 params
[0] = BOOLEAN_TO_FLOAT(v
.value_bool
);
2773 m
= *(GLmatrix
**) &v
;
2774 for (i
= 0; i
< 16; i
++)
2775 params
[i
] = m
->m
[i
];
2779 m
= *(GLmatrix
**) &v
;
2780 for (i
= 0; i
< 16; i
++)
2781 params
[i
] = m
->m
[transpose
[i
]];
2790 _mesa_GetDoublei_v(GLenum pname
, GLuint index
, GLdouble
*params
)
2795 enum value_type type
=
2796 find_value_indexed("glGetDoublei_v", pname
, index
, &v
);
2801 params
[3] = (GLdouble
) v
.value_float_4
[3];
2804 params
[2] = (GLdouble
) v
.value_float_4
[2];
2807 params
[1] = (GLdouble
) v
.value_float_4
[1];
2810 params
[0] = (GLdouble
) v
.value_float_4
[0];
2813 case TYPE_DOUBLEN_2
:
2814 params
[1] = v
.value_double_2
[1];
2816 params
[0] = v
.value_double_2
[0];
2820 params
[3] = (GLdouble
) v
.value_int_4
[3];
2822 params
[2] = (GLdouble
) v
.value_int_4
[2];
2825 params
[1] = (GLdouble
) v
.value_int_4
[1];
2829 params
[0] = (GLdouble
) v
.value_int_4
[0];
2833 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
2834 params
[i
] = (GLdouble
) v
.value_int_n
.ints
[i
];
2838 params
[3] = (GLdouble
) ((GLuint
) v
.value_int_4
[3]);
2840 params
[2] = (GLdouble
) ((GLuint
) v
.value_int_4
[2]);
2842 params
[1] = (GLdouble
) ((GLuint
) v
.value_int_4
[1]);
2844 params
[0] = (GLdouble
) ((GLuint
) v
.value_int_4
[0]);
2848 params
[0] = (GLdouble
) v
.value_int64
;
2852 params
[0] = (GLdouble
) BOOLEAN_TO_FLOAT(v
.value_bool
);
2856 m
= *(GLmatrix
**) &v
;
2857 for (i
= 0; i
< 16; i
++)
2858 params
[i
] = (GLdouble
) m
->m
[i
];
2862 m
= *(GLmatrix
**) &v
;
2863 for (i
= 0; i
< 16; i
++)
2864 params
[i
] = (GLdouble
) m
->m
[transpose
[i
]];
2873 _mesa_GetUnsignedBytei_vEXT(GLenum target
, GLuint index
, GLubyte
*data
)
2877 enum value_type type
;
2878 const char *func
= "glGetUnsignedBytei_vEXT";
2880 GET_CURRENT_CONTEXT(ctx
);
2882 if (!ctx
->Extensions
.EXT_memory_object
) {
2883 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(unsupported)", func
);
2887 type
= find_value_indexed(func
, target
, index
, &v
);
2888 size
= get_value_size(type
, &v
);
2890 _mesa_problem(ctx
, "invalid value type in GetUnsignedBytei_vEXT()");
2917 case TYPE_DOUBLEN_2
:
2920 memcpy(data
, &v
.value_int
, size
);
2923 memcpy(data
, &v
.value_int_n
.ints
, size
);
2926 break; /* nothing - GL error was recorded */
2931 _mesa_GetFixedv(GLenum pname
, GLfixed
*params
)
2933 const struct value_desc
*d
;
2939 d
= find_value("glGetDoublev", pname
, &p
, &v
);
2944 params
[0] = INT_TO_FIXED(d
->offset
);
2949 params
[3] = FLOAT_TO_FIXED(((GLfloat
*) p
)[3]);
2952 params
[2] = FLOAT_TO_FIXED(((GLfloat
*) p
)[2]);
2955 params
[1] = FLOAT_TO_FIXED(((GLfloat
*) p
)[1]);
2958 params
[0] = FLOAT_TO_FIXED(((GLfloat
*) p
)[0]);
2961 case TYPE_DOUBLEN_2
:
2962 params
[1] = FLOAT_TO_FIXED(((GLdouble
*) p
)[1]);
2964 params
[0] = FLOAT_TO_FIXED(((GLdouble
*) p
)[0]);
2969 params
[3] = INT_TO_FIXED(((GLint
*) p
)[3]);
2972 params
[2] = INT_TO_FIXED(((GLint
*) p
)[2]);
2976 params
[1] = INT_TO_FIXED(((GLint
*) p
)[1]);
2980 params
[0] = INT_TO_FIXED(((GLint
*) p
)[0]);
2984 params
[0] = INT_TO_FIXED(((GLenum16
*) p
)[0]);
2988 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
2989 params
[i
] = INT_TO_FIXED(v
.value_int_n
.ints
[i
]);
2993 params
[0] = ((GLint64
*) p
)[0];
2997 params
[0] = BOOLEAN_TO_FIXED(((GLboolean
*) p
)[0]);
3001 m
= *(GLmatrix
**) p
;
3002 for (i
= 0; i
< 16; i
++)
3003 params
[i
] = FLOAT_TO_FIXED(m
->m
[i
]);
3007 m
= *(GLmatrix
**) p
;
3008 for (i
= 0; i
< 16; i
++)
3009 params
[i
] = FLOAT_TO_FIXED(m
->m
[transpose
[i
]]);
3020 shift
= d
->type
- TYPE_BIT_0
;
3021 params
[0] = BOOLEAN_TO_FIXED((*(GLbitfield
*) p
>> shift
) & 1);