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)
134 enum value_location
{
156 EXTRA_NEW_FRAG_CLAMP
,
157 EXTRA_VALID_DRAW_BUFFER
,
158 EXTRA_VALID_TEXTURE_UNIT
,
159 EXTRA_VALID_CLIP_DISTANCE
,
163 EXTRA_EXT_ATOMICS_GS
,
164 EXTRA_EXT_SHADER_IMAGE_GS
,
165 EXTRA_EXT_ATOMICS_TESS
,
166 EXTRA_EXT_SHADER_IMAGE_TESS
,
168 EXTRA_EXT_FB_NO_ATTACH_GS
,
170 EXTRA_EXT_PROVOKING_VERTEX_32
,
173 #define NO_EXTRA NULL
178 GLubyte location
; /**< enum value_location */
179 GLubyte type
; /**< enum value_type */
186 GLfloat value_float_4
[4];
187 GLdouble value_double_2
[2];
188 GLmatrix
*value_matrix
;
190 GLint value_int_4
[4];
196 /* Sigh, see GL_COMPRESSED_TEXTURE_FORMATS_ARB handling */
200 GLboolean value_bool
;
203 #define BUFFER_FIELD(field, type) \
204 LOC_BUFFER, type, offsetof(struct gl_framebuffer, field)
205 #define CONTEXT_FIELD(field, type) \
206 LOC_CONTEXT, type, offsetof(struct gl_context, field)
207 #define ARRAY_FIELD(field, type) \
208 LOC_ARRAY, type, offsetof(struct gl_vertex_array_object, field)
209 #undef CONST /* already defined through windows.h */
210 #define CONST(value) \
211 LOC_CONTEXT, TYPE_CONST, value
213 #define BUFFER_INT(field) BUFFER_FIELD(field, TYPE_INT)
214 #define BUFFER_ENUM(field) BUFFER_FIELD(field, TYPE_ENUM)
215 #define BUFFER_ENUM16(field) BUFFER_FIELD(field, TYPE_ENUM16)
216 #define BUFFER_BOOL(field) BUFFER_FIELD(field, TYPE_BOOLEAN)
218 #define CONTEXT_INT(field) CONTEXT_FIELD(field, TYPE_INT)
219 #define CONTEXT_INT2(field) CONTEXT_FIELD(field, TYPE_INT_2)
220 #define CONTEXT_INT64(field) CONTEXT_FIELD(field, TYPE_INT64)
221 #define CONTEXT_UINT(field) CONTEXT_FIELD(field, TYPE_UINT)
222 #define CONTEXT_ENUM16(field) CONTEXT_FIELD(field, TYPE_ENUM16)
223 #define CONTEXT_ENUM(field) CONTEXT_FIELD(field, TYPE_ENUM)
224 #define CONTEXT_ENUM2(field) CONTEXT_FIELD(field, TYPE_ENUM_2)
225 #define CONTEXT_BOOL(field) CONTEXT_FIELD(field, TYPE_BOOLEAN)
226 #define CONTEXT_BIT0(field) CONTEXT_FIELD(field, TYPE_BIT_0)
227 #define CONTEXT_BIT1(field) CONTEXT_FIELD(field, TYPE_BIT_1)
228 #define CONTEXT_BIT2(field) CONTEXT_FIELD(field, TYPE_BIT_2)
229 #define CONTEXT_BIT3(field) CONTEXT_FIELD(field, TYPE_BIT_3)
230 #define CONTEXT_BIT4(field) CONTEXT_FIELD(field, TYPE_BIT_4)
231 #define CONTEXT_BIT5(field) CONTEXT_FIELD(field, TYPE_BIT_5)
232 #define CONTEXT_BIT6(field) CONTEXT_FIELD(field, TYPE_BIT_6)
233 #define CONTEXT_BIT7(field) CONTEXT_FIELD(field, TYPE_BIT_7)
234 #define CONTEXT_FLOAT(field) CONTEXT_FIELD(field, TYPE_FLOAT)
235 #define CONTEXT_FLOAT2(field) CONTEXT_FIELD(field, TYPE_FLOAT_2)
236 #define CONTEXT_FLOAT3(field) CONTEXT_FIELD(field, TYPE_FLOAT_3)
237 #define CONTEXT_FLOAT4(field) CONTEXT_FIELD(field, TYPE_FLOAT_4)
238 #define CONTEXT_FLOAT8(field) CONTEXT_FIELD(field, TYPE_FLOAT_8)
239 #define CONTEXT_MATRIX(field) CONTEXT_FIELD(field, TYPE_MATRIX)
240 #define CONTEXT_MATRIX_T(field) CONTEXT_FIELD(field, TYPE_MATRIX_T)
242 /* Vertex array fields */
243 #define ARRAY_INT(field) ARRAY_FIELD(field, TYPE_INT)
244 #define ARRAY_ENUM(field) ARRAY_FIELD(field, TYPE_ENUM)
245 #define ARRAY_ENUM16(field) ARRAY_FIELD(field, TYPE_ENUM16)
246 #define ARRAY_BOOL(field) ARRAY_FIELD(field, TYPE_BOOLEAN)
247 #define ARRAY_UBYTE(field) ARRAY_FIELD(field, TYPE_UBYTE)
248 #define ARRAY_SHORT(field) ARRAY_FIELD(field, TYPE_SHORT)
251 offsetof(struct gl_extensions, f)
253 #define EXTRA_EXT(e) \
254 static const int extra_##e[] = { \
258 #define EXTRA_EXT2(e1, e2) \
259 static const int extra_##e1##_##e2[] = { \
260 EXT(e1), EXT(e2), EXTRA_END \
263 /* The 'extra' mechanism is a way to specify extra checks (such as
264 * extensions or specific gl versions) or actions (flush current, new
265 * buffers) that we need to do before looking up an enum. We need to
266 * declare them all up front so we can refer to them in the value_desc
269 * Each EXTRA_ will be executed. For EXTRA_* enums of extensions and API
270 * versions, listing multiple ones in an array means an error will be thrown
271 * only if none of them are available. If you need to check for "AND"
272 * behavior, you would need to make a custom EXTRA_ enum.
275 static const int extra_new_buffers
[] = {
280 static const int extra_new_frag_clamp
[] = {
281 EXTRA_NEW_FRAG_CLAMP
,
285 static const int extra_valid_draw_buffer
[] = {
286 EXTRA_VALID_DRAW_BUFFER
,
290 static const int extra_valid_texture_unit
[] = {
291 EXTRA_VALID_TEXTURE_UNIT
,
295 static const int extra_valid_clip_distance
[] = {
296 EXTRA_VALID_CLIP_DISTANCE
,
300 static const int extra_flush_current_valid_texture_unit
[] = {
302 EXTRA_VALID_TEXTURE_UNIT
,
306 static const int extra_flush_current
[] = {
311 static const int extra_EXT_texture_integer_and_new_buffers
[] = {
312 EXT(EXT_texture_integer
),
317 static const int extra_GLSL_130_es3
[] = {
323 static const int extra_texture_buffer_object
[] = {
324 EXT(ARB_texture_buffer_object
),
328 static const int extra_ARB_transform_feedback2_api_es3
[] = {
329 EXT(ARB_transform_feedback2
),
334 static const int extra_ARB_uniform_buffer_object_and_geometry_shader
[] = {
339 static const int extra_ARB_ES2_compatibility_api_es2
[] = {
340 EXT(ARB_ES2_compatibility
),
345 static const int extra_ARB_ES3_compatibility_api_es3
[] = {
346 EXT(ARB_ES3_compatibility
),
351 static const int extra_EXT_framebuffer_sRGB_and_new_buffers
[] = {
352 EXT(EXT_framebuffer_sRGB
),
357 static const int extra_EXT_packed_float
[] = {
358 EXT(EXT_packed_float
),
363 static const int extra_EXT_texture_array_es3
[] = {
364 EXT(EXT_texture_array
),
369 static const int extra_ARB_shader_atomic_counters_and_geometry_shader
[] = {
370 EXTRA_EXT_ATOMICS_GS
,
374 static const int extra_ARB_shader_image_load_store_and_geometry_shader
[] = {
375 EXTRA_EXT_SHADER_IMAGE_GS
,
379 static const int extra_ARB_shader_atomic_counters_and_tessellation
[] = {
380 EXTRA_EXT_ATOMICS_TESS
,
384 static const int extra_ARB_shader_image_load_store_and_tessellation
[] = {
385 EXTRA_EXT_SHADER_IMAGE_TESS
,
389 /* HACK: remove when ARB_compute_shader is actually supported */
390 static const int extra_ARB_compute_shader_es31
[] = {
391 EXT(ARB_compute_shader
),
396 static const int extra_ARB_shader_storage_buffer_object_es31
[] = {
397 EXT(ARB_shader_storage_buffer_object
),
402 static const int extra_ARB_shader_storage_buffer_object_and_geometry_shader
[] = {
407 static const int extra_ARB_shader_image_load_store_shader_storage_buffer_object_es31
[] = {
408 EXT(ARB_shader_image_load_store
),
409 EXT(ARB_shader_storage_buffer_object
),
414 static const int extra_ARB_framebuffer_no_attachments_and_geometry_shader
[] = {
415 EXTRA_EXT_FB_NO_ATTACH_GS
,
419 static const int extra_ARB_viewport_array_or_oes_geometry_shader
[] = {
420 EXT(ARB_viewport_array
),
425 static const int extra_ARB_viewport_array_or_oes_viewport_array
[] = {
426 EXT(ARB_viewport_array
),
427 EXT(OES_viewport_array
),
431 static const int extra_ARB_gpu_shader5_or_oes_geometry_shader
[] = {
432 EXT(ARB_gpu_shader5
),
437 static const int extra_ARB_gpu_shader5_or_OES_sample_variables
[] = {
438 EXT(ARB_gpu_shader5
),
439 EXT(OES_sample_variables
),
443 static const int extra_ES32
[] = {
444 EXT(ARB_ES3_2_compatibility
),
449 static const int extra_KHR_robustness_or_GL
[] = {
456 static const int extra_INTEL_conservative_rasterization
[] = {
457 EXT(INTEL_conservative_rasterization
),
461 EXTRA_EXT(ARB_texture_cube_map
);
462 EXTRA_EXT(EXT_texture_array
);
463 EXTRA_EXT(NV_fog_distance
);
464 EXTRA_EXT(EXT_texture_filter_anisotropic
);
465 EXTRA_EXT(NV_point_sprite
);
466 EXTRA_EXT(NV_texture_rectangle
);
467 EXTRA_EXT(EXT_stencil_two_side
);
468 EXTRA_EXT(EXT_depth_bounds_test
);
469 EXTRA_EXT(ARB_depth_clamp
);
470 EXTRA_EXT(ATI_fragment_shader
);
471 EXTRA_EXT(EXT_provoking_vertex
);
472 EXTRA_EXT(ARB_fragment_shader
);
473 EXTRA_EXT(ARB_fragment_program
);
474 EXTRA_EXT2(ARB_framebuffer_object
, EXT_framebuffer_multisample
);
475 EXTRA_EXT(ARB_seamless_cube_map
);
477 EXTRA_EXT(ARB_vertex_shader
);
478 EXTRA_EXT(EXT_transform_feedback
);
479 EXTRA_EXT(ARB_transform_feedback3
);
480 EXTRA_EXT(EXT_pixel_buffer_object
);
481 EXTRA_EXT(ARB_vertex_program
);
482 EXTRA_EXT2(NV_point_sprite
, ARB_point_sprite
);
483 EXTRA_EXT2(ARB_vertex_program
, ARB_fragment_program
);
484 EXTRA_EXT(ARB_color_buffer_float
);
485 EXTRA_EXT(EXT_framebuffer_sRGB
);
486 EXTRA_EXT(OES_EGL_image_external
);
487 EXTRA_EXT(ARB_blend_func_extended
);
488 EXTRA_EXT(ARB_uniform_buffer_object
);
489 EXTRA_EXT(ARB_timer_query
);
490 EXTRA_EXT2(ARB_texture_cube_map_array
, OES_texture_cube_map_array
);
491 EXTRA_EXT(ARB_texture_buffer_range
);
492 EXTRA_EXT(ARB_texture_multisample
);
493 EXTRA_EXT(ARB_texture_gather
);
494 EXTRA_EXT(ARB_shader_atomic_counters
);
495 EXTRA_EXT(ARB_draw_indirect
);
496 EXTRA_EXT(ARB_shader_image_load_store
);
497 EXTRA_EXT(ARB_query_buffer_object
);
498 EXTRA_EXT2(ARB_transform_feedback3
, ARB_gpu_shader5
);
499 EXTRA_EXT(INTEL_performance_query
);
500 EXTRA_EXT(ARB_explicit_uniform_location
);
501 EXTRA_EXT(ARB_clip_control
);
502 EXTRA_EXT(ARB_polygon_offset_clamp
);
503 EXTRA_EXT(ARB_framebuffer_no_attachments
);
504 EXTRA_EXT(ARB_tessellation_shader
);
505 EXTRA_EXT(ARB_shader_storage_buffer_object
);
506 EXTRA_EXT(ARB_indirect_parameters
);
507 EXTRA_EXT(ATI_meminfo
);
508 EXTRA_EXT(NVX_gpu_memory_info
);
509 EXTRA_EXT(ARB_cull_distance
);
510 EXTRA_EXT(EXT_window_rectangles
);
511 EXTRA_EXT(KHR_blend_equation_advanced_coherent
);
512 EXTRA_EXT(OES_primitive_bounding_box
);
513 EXTRA_EXT(ARB_compute_variable_group_size
);
514 EXTRA_EXT(KHR_robustness
);
515 EXTRA_EXT(ARB_sparse_buffer
);
516 EXTRA_EXT(NV_conservative_raster
);
517 EXTRA_EXT(NV_conservative_raster_dilate
);
518 EXTRA_EXT(NV_conservative_raster_pre_snap_triangles
);
521 extra_ARB_color_buffer_float_or_glcore
[] = {
522 EXT(ARB_color_buffer_float
),
528 extra_NV_primitive_restart
[] = {
529 EXT(NV_primitive_restart
),
533 static const int extra_version_30
[] = { EXTRA_VERSION_30
, EXTRA_END
};
534 static const int extra_version_31
[] = { EXTRA_VERSION_31
, EXTRA_END
};
535 static const int extra_version_32
[] = { EXTRA_VERSION_32
, EXTRA_END
};
536 static const int extra_version_43
[] = { EXTRA_VERSION_43
, EXTRA_END
};
538 static const int extra_gl30_es3
[] = {
544 static const int extra_gl32_es3
[] = {
550 static const int extra_version_32_OES_geometry_shader
[] = {
556 static const int extra_gl40_ARB_sample_shading
[] = {
558 EXT(ARB_sample_shading
),
563 extra_ARB_vertex_program_api_es2
[] = {
564 EXT(ARB_vertex_program
),
569 /* The ReadBuffer get token is valid under either full GL or under
570 * GLES2 if the NV_read_buffer extension is available. */
572 extra_NV_read_buffer_api_gl
[] = {
578 static const int extra_core_ARB_color_buffer_float_and_new_buffers
[] = {
580 EXT(ARB_color_buffer_float
),
585 static const int extra_EXT_shader_framebuffer_fetch
[] = {
588 EXT(EXT_shader_framebuffer_fetch
),
592 static const int extra_EXT_provoking_vertex_32
[] = {
593 EXTRA_EXT_PROVOKING_VERTEX_32
,
597 static const int extra_EXT_disjoint_timer_query
[] = {
600 EXT(EXT_disjoint_timer_query
),
605 /* This is the big table describing all the enums we accept in
606 * glGet*v(). The table is partitioned into six parts: enums
607 * understood by all GL APIs (OpenGL, GLES and GLES2), enums shared
608 * between OpenGL and GLES, enums exclusive to GLES, etc for the
609 * remaining combinations. To look up the enums valid in a given API
610 * we will use a hash table specific to that API. These tables are in
611 * turn generated at build time and included through get_hash.h.
614 #include "get_hash.h"
616 /* All we need now is a way to look up the value struct from the enum.
617 * The code generated by gcc for the old generated big switch
618 * statement is a big, balanced, open coded if/else tree, essentially
619 * an unrolled binary search. It would be natural to sort the new
620 * enum table and use bsearch(), but we will use a read-only hash
621 * table instead. bsearch() has a nice guaranteed worst case
622 * performance, but we're also guaranteed to hit that worst case
623 * (log2(n) iterations) for about half the enums. Instead, using an
624 * open addressing hash table, we can find the enum on the first try
625 * for 80% of the enums, 1 collision for 10% and never more than 5
626 * collisions for any enum (typical numbers). And the code is very
627 * simple, even though it feels a little magic. */
630 * Handle irregular enums
632 * Some values don't conform to the "well-known type at context
633 * pointer + offset" pattern, so we have this function to catch all
634 * the corner cases. Typically, it's a computed value or a one-off
635 * pointer to a custom struct or something.
637 * In this case we can't return a pointer to the value, so we'll have
638 * to use the temporary variable 'v' declared back in the calling
639 * glGet*v() function to store the result.
641 * \param ctx the current context
642 * \param d the struct value_desc that describes the enum
643 * \param v pointer to the tmp declared in the calling glGet*v() function
646 find_custom_value(struct gl_context
*ctx
, const struct value_desc
*d
, union value
*v
)
648 struct gl_buffer_object
**buffer_obj
;
649 struct gl_array_attributes
*array
;
653 case GL_MAJOR_VERSION
:
654 v
->value_int
= ctx
->Version
/ 10;
656 case GL_MINOR_VERSION
:
657 v
->value_int
= ctx
->Version
% 10;
663 case GL_TEXTURE_CUBE_MAP
:
664 case GL_TEXTURE_RECTANGLE_NV
:
665 case GL_TEXTURE_EXTERNAL_OES
:
666 v
->value_bool
= _mesa_IsEnabled(d
->pname
);
669 case GL_LINE_STIPPLE_PATTERN
:
670 /* This is the only GLushort, special case it here by promoting
671 * to an int rather than introducing a new type. */
672 v
->value_int
= ctx
->Line
.StipplePattern
;
675 case GL_CURRENT_RASTER_TEXTURE_COORDS
:
676 unit
= ctx
->Texture
.CurrentUnit
;
677 v
->value_float_4
[0] = ctx
->Current
.RasterTexCoords
[unit
][0];
678 v
->value_float_4
[1] = ctx
->Current
.RasterTexCoords
[unit
][1];
679 v
->value_float_4
[2] = ctx
->Current
.RasterTexCoords
[unit
][2];
680 v
->value_float_4
[3] = ctx
->Current
.RasterTexCoords
[unit
][3];
683 case GL_CURRENT_TEXTURE_COORDS
:
684 unit
= ctx
->Texture
.CurrentUnit
;
685 v
->value_float_4
[0] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
][0];
686 v
->value_float_4
[1] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
][1];
687 v
->value_float_4
[2] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
][2];
688 v
->value_float_4
[3] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
][3];
691 case GL_COLOR_WRITEMASK
:
692 v
->value_int_4
[0] = GET_COLORMASK_BIT(ctx
->Color
.ColorMask
, 0, 0);
693 v
->value_int_4
[1] = GET_COLORMASK_BIT(ctx
->Color
.ColorMask
, 0, 1);
694 v
->value_int_4
[2] = GET_COLORMASK_BIT(ctx
->Color
.ColorMask
, 0, 2);
695 v
->value_int_4
[3] = GET_COLORMASK_BIT(ctx
->Color
.ColorMask
, 0, 3);
699 v
->value_bool
= ctx
->Current
.Attrib
[VERT_ATTRIB_EDGEFLAG
][0] == 1.0F
;
703 v
->value_enum
= ctx
->ReadBuffer
->ColorReadBuffer
;
706 case GL_MAP2_GRID_DOMAIN
:
707 v
->value_float_4
[0] = ctx
->Eval
.MapGrid2u1
;
708 v
->value_float_4
[1] = ctx
->Eval
.MapGrid2u2
;
709 v
->value_float_4
[2] = ctx
->Eval
.MapGrid2v1
;
710 v
->value_float_4
[3] = ctx
->Eval
.MapGrid2v2
;
713 case GL_TEXTURE_STACK_DEPTH
:
714 unit
= ctx
->Texture
.CurrentUnit
;
715 v
->value_int
= ctx
->TextureMatrixStack
[unit
].Depth
+ 1;
717 case GL_TEXTURE_MATRIX
:
718 unit
= ctx
->Texture
.CurrentUnit
;
719 v
->value_matrix
= ctx
->TextureMatrixStack
[unit
].Top
;
722 case GL_TEXTURE_COORD_ARRAY
:
723 case GL_TEXTURE_COORD_ARRAY_SIZE
:
724 case GL_TEXTURE_COORD_ARRAY_TYPE
:
725 case GL_TEXTURE_COORD_ARRAY_STRIDE
:
726 array
= &ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_TEX(ctx
->Array
.ActiveTexture
)];
727 v
->value_int
= *(GLuint
*) ((char *) array
+ d
->offset
);
730 case GL_ACTIVE_TEXTURE_ARB
:
731 v
->value_int
= GL_TEXTURE0_ARB
+ ctx
->Texture
.CurrentUnit
;
733 case GL_CLIENT_ACTIVE_TEXTURE_ARB
:
734 v
->value_int
= GL_TEXTURE0_ARB
+ ctx
->Array
.ActiveTexture
;
737 case GL_MODELVIEW_STACK_DEPTH
:
738 case GL_PROJECTION_STACK_DEPTH
:
739 v
->value_int
= *(GLint
*) ((char *) ctx
+ d
->offset
) + 1;
742 case GL_MAX_TEXTURE_SIZE
:
743 case GL_MAX_3D_TEXTURE_SIZE
:
744 case GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB
:
745 p
= (GLuint
*) ((char *) ctx
+ d
->offset
);
746 v
->value_int
= 1 << (*p
- 1);
750 v
->value_int_4
[0] = ctx
->Scissor
.ScissorArray
[0].X
;
751 v
->value_int_4
[1] = ctx
->Scissor
.ScissorArray
[0].Y
;
752 v
->value_int_4
[2] = ctx
->Scissor
.ScissorArray
[0].Width
;
753 v
->value_int_4
[3] = ctx
->Scissor
.ScissorArray
[0].Height
;
756 case GL_SCISSOR_TEST
:
757 v
->value_bool
= ctx
->Scissor
.EnableFlags
& 1;
762 ctx
->ListState
.CurrentList
? ctx
->ListState
.CurrentList
->Name
: 0;
765 if (!ctx
->CompileFlag
)
767 else if (ctx
->ExecuteFlag
)
768 v
->value_enum
= GL_COMPILE_AND_EXECUTE
;
770 v
->value_enum
= GL_COMPILE
;
774 v
->value_float_4
[0] = ctx
->ViewportArray
[0].X
;
775 v
->value_float_4
[1] = ctx
->ViewportArray
[0].Y
;
776 v
->value_float_4
[2] = ctx
->ViewportArray
[0].Width
;
777 v
->value_float_4
[3] = ctx
->ViewportArray
[0].Height
;
781 v
->value_double_2
[0] = ctx
->ViewportArray
[0].Near
;
782 v
->value_double_2
[1] = ctx
->ViewportArray
[0].Far
;
785 case GL_ACTIVE_STENCIL_FACE_EXT
:
786 v
->value_enum
= ctx
->Stencil
.ActiveFace
? GL_BACK
: GL_FRONT
;
789 case GL_STENCIL_FAIL
:
790 v
->value_enum
= ctx
->Stencil
.FailFunc
[ctx
->Stencil
.ActiveFace
];
792 case GL_STENCIL_FUNC
:
793 v
->value_enum
= ctx
->Stencil
.Function
[ctx
->Stencil
.ActiveFace
];
795 case GL_STENCIL_PASS_DEPTH_FAIL
:
796 v
->value_enum
= ctx
->Stencil
.ZFailFunc
[ctx
->Stencil
.ActiveFace
];
798 case GL_STENCIL_PASS_DEPTH_PASS
:
799 v
->value_enum
= ctx
->Stencil
.ZPassFunc
[ctx
->Stencil
.ActiveFace
];
802 v
->value_int
= _mesa_get_stencil_ref(ctx
, ctx
->Stencil
.ActiveFace
);
804 case GL_STENCIL_BACK_REF
:
805 v
->value_int
= _mesa_get_stencil_ref(ctx
, 1);
807 case GL_STENCIL_VALUE_MASK
:
808 v
->value_int
= ctx
->Stencil
.ValueMask
[ctx
->Stencil
.ActiveFace
];
810 case GL_STENCIL_WRITEMASK
:
811 v
->value_int
= ctx
->Stencil
.WriteMask
[ctx
->Stencil
.ActiveFace
];
814 case GL_NUM_EXTENSIONS
:
815 v
->value_int
= _mesa_get_extension_count(ctx
);
818 case GL_IMPLEMENTATION_COLOR_READ_TYPE_OES
:
819 v
->value_int
= _mesa_get_color_read_type(ctx
, NULL
, "glGetIntegerv");
821 case GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES
:
822 v
->value_int
= _mesa_get_color_read_format(ctx
, NULL
, "glGetIntegerv");
825 case GL_CURRENT_MATRIX_STACK_DEPTH_ARB
:
826 v
->value_int
= ctx
->CurrentStack
->Depth
+ 1;
828 case GL_CURRENT_MATRIX_ARB
:
829 case GL_TRANSPOSE_CURRENT_MATRIX_ARB
:
830 v
->value_matrix
= ctx
->CurrentStack
->Top
;
833 case GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB
:
834 v
->value_int
= _mesa_get_compressed_formats(ctx
, NULL
);
836 case GL_COMPRESSED_TEXTURE_FORMATS_ARB
:
838 _mesa_get_compressed_formats(ctx
, v
->value_int_n
.ints
);
839 assert(v
->value_int_n
.n
<= (int) ARRAY_SIZE(v
->value_int_n
.ints
));
842 case GL_MAX_VARYING_FLOATS_ARB
:
843 v
->value_int
= ctx
->Const
.MaxVarying
* 4;
846 /* Various object names */
848 case GL_TEXTURE_BINDING_1D
:
849 case GL_TEXTURE_BINDING_2D
:
850 case GL_TEXTURE_BINDING_3D
:
851 case GL_TEXTURE_BINDING_1D_ARRAY_EXT
:
852 case GL_TEXTURE_BINDING_2D_ARRAY_EXT
:
853 case GL_TEXTURE_BINDING_CUBE_MAP_ARB
:
854 case GL_TEXTURE_BINDING_RECTANGLE_NV
:
855 case GL_TEXTURE_BINDING_EXTERNAL_OES
:
856 case GL_TEXTURE_BINDING_CUBE_MAP_ARRAY
:
857 case GL_TEXTURE_BINDING_2D_MULTISAMPLE
:
858 case GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY
:
859 unit
= ctx
->Texture
.CurrentUnit
;
861 ctx
->Texture
.Unit
[unit
].CurrentTex
[d
->offset
]->Name
;
864 /* GL_EXT_external_objects */
865 case GL_DRIVER_UUID_EXT
:
866 _mesa_get_driver_uuid(ctx
, v
->value_int_4
);
868 case GL_DEVICE_UUID_EXT
:
869 _mesa_get_device_uuid(ctx
, v
->value_int_4
);
872 /* GL_EXT_packed_float */
873 case GL_RGBA_SIGNED_COMPONENTS_EXT
:
875 /* Note: we only check the 0th color attachment. */
876 const struct gl_renderbuffer
*rb
=
877 ctx
->DrawBuffer
->_ColorDrawBuffers
[0];
878 if (rb
&& _mesa_is_format_signed(rb
->Format
)) {
879 /* Issue 17 of GL_EXT_packed_float: If a component (such as
880 * alpha) has zero bits, the component should not be considered
881 * signed and so the bit for the respective component should be
885 _mesa_get_format_bits(rb
->Format
, GL_RED_BITS
);
887 _mesa_get_format_bits(rb
->Format
, GL_GREEN_BITS
);
889 _mesa_get_format_bits(rb
->Format
, GL_BLUE_BITS
);
891 _mesa_get_format_bits(rb
->Format
, GL_ALPHA_BITS
);
893 _mesa_get_format_bits(rb
->Format
, GL_TEXTURE_LUMINANCE_SIZE
);
895 _mesa_get_format_bits(rb
->Format
, GL_TEXTURE_INTENSITY_SIZE
);
897 v
->value_int_4
[0] = r_bits
+ l_bits
+ i_bits
> 0;
898 v
->value_int_4
[1] = g_bits
+ l_bits
+ i_bits
> 0;
899 v
->value_int_4
[2] = b_bits
+ l_bits
+ i_bits
> 0;
900 v
->value_int_4
[3] = a_bits
+ i_bits
> 0;
906 v
->value_int_4
[3] = 0;
911 /* GL_ARB_vertex_buffer_object */
912 case GL_VERTEX_ARRAY_BUFFER_BINDING_ARB
:
913 case GL_NORMAL_ARRAY_BUFFER_BINDING_ARB
:
914 case GL_COLOR_ARRAY_BUFFER_BINDING_ARB
:
915 case GL_INDEX_ARRAY_BUFFER_BINDING_ARB
:
916 case GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB
:
917 case GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB
:
918 case GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB
:
919 buffer_obj
= (struct gl_buffer_object
**)
920 ((char *) ctx
->Array
.VAO
+ d
->offset
);
921 v
->value_int
= (*buffer_obj
)->Name
;
923 case GL_ARRAY_BUFFER_BINDING_ARB
:
924 v
->value_int
= ctx
->Array
.ArrayBufferObj
->Name
;
926 case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB
:
928 ctx
->Array
.VAO
->BufferBinding
[VERT_ATTRIB_TEX(ctx
->Array
.ActiveTexture
)].BufferObj
->Name
;
930 case GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB
:
931 v
->value_int
= ctx
->Array
.VAO
->IndexBufferObj
->Name
;
934 /* ARB_vertex_array_bgra */
935 case GL_COLOR_ARRAY_SIZE
:
936 array
= &ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_COLOR0
];
937 v
->value_int
= array
->Format
== GL_BGRA
? GL_BGRA
: array
->Size
;
939 case GL_SECONDARY_COLOR_ARRAY_SIZE
:
940 array
= &ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_COLOR1
];
941 v
->value_int
= array
->Format
== GL_BGRA
? GL_BGRA
: array
->Size
;
944 /* ARB_copy_buffer */
945 case GL_COPY_READ_BUFFER
:
946 v
->value_int
= ctx
->CopyReadBuffer
->Name
;
948 case GL_COPY_WRITE_BUFFER
:
949 v
->value_int
= ctx
->CopyWriteBuffer
->Name
;
952 case GL_PIXEL_PACK_BUFFER_BINDING_EXT
:
953 v
->value_int
= ctx
->Pack
.BufferObj
->Name
;
955 case GL_PIXEL_UNPACK_BUFFER_BINDING_EXT
:
956 v
->value_int
= ctx
->Unpack
.BufferObj
->Name
;
958 case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING
:
959 v
->value_int
= ctx
->TransformFeedback
.CurrentBuffer
->Name
;
961 case GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED
:
962 v
->value_int
= ctx
->TransformFeedback
.CurrentObject
->Paused
;
964 case GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE
:
965 v
->value_int
= ctx
->TransformFeedback
.CurrentObject
->Active
;
967 case GL_TRANSFORM_FEEDBACK_BINDING
:
968 v
->value_int
= ctx
->TransformFeedback
.CurrentObject
->Name
;
970 case GL_CURRENT_PROGRAM
:
971 /* The Changelog of the ARB_separate_shader_objects spec says:
973 * 24 25 Jul 2011 pbrown Remove the language erroneously deleting
974 * CURRENT_PROGRAM. In the EXT extension, this
975 * token was aliased to ACTIVE_PROGRAM_EXT, and
976 * was used to indicate the last program set by
977 * either ActiveProgramEXT or UseProgram. In
978 * the ARB extension, the SSO active programs
979 * are now program pipeline object state and
980 * CURRENT_PROGRAM should still be used to query
981 * the last program set by UseProgram (bug 7822).
984 ctx
->Shader
.ActiveProgram
? ctx
->Shader
.ActiveProgram
->Name
: 0;
986 case GL_READ_FRAMEBUFFER_BINDING_EXT
:
987 v
->value_int
= ctx
->ReadBuffer
->Name
;
989 case GL_RENDERBUFFER_BINDING_EXT
:
991 ctx
->CurrentRenderbuffer
? ctx
->CurrentRenderbuffer
->Name
: 0;
993 case GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES
:
994 v
->value_int
= ctx
->Array
.VAO
->BufferBinding
[VERT_ATTRIB_POINT_SIZE
].BufferObj
->Name
;
998 if (_mesa_get_clamp_fragment_color(ctx
, ctx
->DrawBuffer
))
999 COPY_4FV(v
->value_float_4
, ctx
->Fog
.Color
);
1001 COPY_4FV(v
->value_float_4
, ctx
->Fog
.ColorUnclamped
);
1003 case GL_COLOR_CLEAR_VALUE
:
1004 if (_mesa_get_clamp_fragment_color(ctx
, ctx
->DrawBuffer
)) {
1005 v
->value_float_4
[0] = CLAMP(ctx
->Color
.ClearColor
.f
[0], 0.0F
, 1.0F
);
1006 v
->value_float_4
[1] = CLAMP(ctx
->Color
.ClearColor
.f
[1], 0.0F
, 1.0F
);
1007 v
->value_float_4
[2] = CLAMP(ctx
->Color
.ClearColor
.f
[2], 0.0F
, 1.0F
);
1008 v
->value_float_4
[3] = CLAMP(ctx
->Color
.ClearColor
.f
[3], 0.0F
, 1.0F
);
1010 COPY_4FV(v
->value_float_4
, ctx
->Color
.ClearColor
.f
);
1012 case GL_BLEND_COLOR_EXT
:
1013 if (_mesa_get_clamp_fragment_color(ctx
, ctx
->DrawBuffer
))
1014 COPY_4FV(v
->value_float_4
, ctx
->Color
.BlendColor
);
1016 COPY_4FV(v
->value_float_4
, ctx
->Color
.BlendColorUnclamped
);
1018 case GL_ALPHA_TEST_REF
:
1019 if (_mesa_get_clamp_fragment_color(ctx
, ctx
->DrawBuffer
))
1020 v
->value_float
= ctx
->Color
.AlphaRef
;
1022 v
->value_float
= ctx
->Color
.AlphaRefUnclamped
;
1024 case GL_MAX_VERTEX_UNIFORM_VECTORS
:
1025 v
->value_int
= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxUniformComponents
/ 4;
1028 case GL_MAX_FRAGMENT_UNIFORM_VECTORS
:
1029 v
->value_int
= ctx
->Const
.Program
[MESA_SHADER_FRAGMENT
].MaxUniformComponents
/ 4;
1032 /* GL_ARB_texture_buffer_object */
1033 case GL_TEXTURE_BUFFER_ARB
:
1034 v
->value_int
= ctx
->Texture
.BufferObject
->Name
;
1036 case GL_TEXTURE_BINDING_BUFFER_ARB
:
1037 unit
= ctx
->Texture
.CurrentUnit
;
1039 ctx
->Texture
.Unit
[unit
].CurrentTex
[TEXTURE_BUFFER_INDEX
]->Name
;
1041 case GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB
:
1043 struct gl_buffer_object
*buf
=
1044 ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
]
1045 .CurrentTex
[TEXTURE_BUFFER_INDEX
]->BufferObject
;
1046 v
->value_int
= buf
? buf
->Name
: 0;
1049 case GL_TEXTURE_BUFFER_FORMAT_ARB
:
1050 v
->value_int
= ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
]
1051 .CurrentTex
[TEXTURE_BUFFER_INDEX
]->BufferObjectFormat
;
1054 /* GL_ARB_sampler_objects */
1055 case GL_SAMPLER_BINDING
:
1057 struct gl_sampler_object
*samp
=
1058 ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
].Sampler
;
1059 v
->value_int
= samp
? samp
->Name
: 0;
1062 /* GL_ARB_uniform_buffer_object */
1063 case GL_UNIFORM_BUFFER_BINDING
:
1064 v
->value_int
= ctx
->UniformBuffer
->Name
;
1066 /* GL_ARB_shader_storage_buffer_object */
1067 case GL_SHADER_STORAGE_BUFFER_BINDING
:
1068 v
->value_int
= ctx
->ShaderStorageBuffer
->Name
;
1070 /* GL_ARB_query_buffer_object */
1071 case GL_QUERY_BUFFER_BINDING
:
1072 v
->value_int
= ctx
->QueryBuffer
->Name
;
1074 /* GL_ARB_timer_query */
1076 if (ctx
->Driver
.GetTimestamp
) {
1077 v
->value_int64
= ctx
->Driver
.GetTimestamp(ctx
);
1080 _mesa_problem(ctx
, "driver doesn't implement GetTimestamp");
1084 case GL_DEBUG_OUTPUT
:
1085 case GL_DEBUG_OUTPUT_SYNCHRONOUS
:
1086 case GL_DEBUG_LOGGED_MESSAGES
:
1087 case GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH
:
1088 case GL_DEBUG_GROUP_STACK_DEPTH
:
1089 v
->value_int
= _mesa_get_debug_state_int(ctx
, d
->pname
);
1091 /* GL_ARB_shader_atomic_counters */
1092 case GL_ATOMIC_COUNTER_BUFFER_BINDING
:
1093 if (ctx
->AtomicBuffer
) {
1094 v
->value_int
= ctx
->AtomicBuffer
->Name
;
1100 case GL_NUM_SHADING_LANGUAGE_VERSIONS
:
1101 v
->value_int
= _mesa_get_shading_language_version(ctx
, -1, NULL
);
1103 /* GL_ARB_draw_indirect */
1104 case GL_DRAW_INDIRECT_BUFFER_BINDING
:
1105 v
->value_int
= ctx
->DrawIndirectBuffer
->Name
;
1107 /* GL_ARB_indirect_parameters */
1108 case GL_PARAMETER_BUFFER_BINDING_ARB
:
1109 v
->value_int
= ctx
->ParameterBuffer
->Name
;
1111 /* GL_ARB_separate_shader_objects */
1112 case GL_PROGRAM_PIPELINE_BINDING
:
1113 if (ctx
->Pipeline
.Current
) {
1114 v
->value_int
= ctx
->Pipeline
.Current
->Name
;
1119 /* GL_ARB_compute_shader */
1120 case GL_DISPATCH_INDIRECT_BUFFER_BINDING
:
1121 v
->value_int
= ctx
->DispatchIndirectBuffer
->Name
;
1123 /* GL_ARB_multisample */
1125 v
->value_int
= _mesa_geometric_samples(ctx
->DrawBuffer
);
1127 case GL_SAMPLE_BUFFERS
:
1128 v
->value_int
= _mesa_geometric_samples(ctx
->DrawBuffer
) > 0;
1130 /* GL_EXT_textrue_integer */
1131 case GL_RGBA_INTEGER_MODE_EXT
:
1132 v
->value_int
= (ctx
->DrawBuffer
->_IntegerBuffers
!= 0);
1134 /* GL_ATI_meminfo & GL_NVX_gpu_memory_info */
1135 case GL_VBO_FREE_MEMORY_ATI
:
1136 case GL_TEXTURE_FREE_MEMORY_ATI
:
1137 case GL_RENDERBUFFER_FREE_MEMORY_ATI
:
1138 case GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX
:
1139 case GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX
:
1140 case GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX
:
1141 case GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX
:
1142 case GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX
:
1144 struct gl_memory_info info
;
1146 ctx
->Driver
.QueryMemoryInfo(ctx
, &info
);
1148 if (d
->pname
== GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX
)
1149 v
->value_int
= info
.total_device_memory
;
1150 else if (d
->pname
== GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX
)
1151 v
->value_int
= info
.total_device_memory
+
1152 info
.total_staging_memory
;
1153 else if (d
->pname
== GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX
)
1154 v
->value_int
= info
.avail_device_memory
;
1155 else if (d
->pname
== GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX
)
1156 v
->value_int
= info
.nr_device_memory_evictions
;
1157 else if (d
->pname
== GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX
)
1158 v
->value_int
= info
.device_memory_evicted
;
1160 /* ATI free memory enums.
1162 * Since the GPU memory is (usually) page-table based, every two
1163 * consecutive elements are equal. From the GL_ATI_meminfo
1166 * "param[0] - total memory free in the pool
1167 * param[1] - largest available free block in the pool
1168 * param[2] - total auxiliary memory free
1169 * param[3] - largest auxiliary free block"
1171 * All three (VBO, TEXTURE, RENDERBUFFER) queries return
1172 * the same numbers here.
1174 v
->value_int_4
[0] = info
.avail_device_memory
;
1175 v
->value_int_4
[1] = info
.avail_device_memory
;
1176 v
->value_int_4
[2] = info
.avail_staging_memory
;
1177 v
->value_int_4
[3] = info
.avail_staging_memory
;
1182 /* GL_ARB_get_program_binary */
1183 case GL_PROGRAM_BINARY_FORMATS
:
1184 assert(ctx
->Const
.NumProgramBinaryFormats
<= 1);
1185 v
->value_int_n
.n
= MIN2(ctx
->Const
.NumProgramBinaryFormats
, 1);
1186 if (ctx
->Const
.NumProgramBinaryFormats
> 0) {
1187 v
->value_int_n
.ints
[0] = GL_PROGRAM_BINARY_FORMAT_MESA
;
1190 /* GL_EXT_disjoint_timer_query */
1191 case GL_GPU_DISJOINT_EXT
:
1193 simple_mtx_lock(&ctx
->Shared
->Mutex
);
1194 v
->value_int
= ctx
->Shared
->DisjointOperation
;
1195 /* Reset state as expected by the spec. */
1196 ctx
->Shared
->DisjointOperation
= false;
1197 simple_mtx_unlock(&ctx
->Shared
->Mutex
);
1204 * Check extra constraints on a struct value_desc descriptor
1206 * If a struct value_desc has a non-NULL extra pointer, it means that
1207 * there are a number of extra constraints to check or actions to
1208 * perform. The extras is just an integer array where each integer
1209 * encode different constraints or actions.
1211 * \param ctx current context
1212 * \param func name of calling glGet*v() function for error reporting
1213 * \param d the struct value_desc that has the extra constraints
1215 * \return GL_FALSE if all of the constraints were not satisfied,
1216 * otherwise GL_TRUE.
1219 check_extra(struct gl_context
*ctx
, const char *func
, const struct value_desc
*d
)
1221 const GLuint version
= ctx
->Version
;
1222 GLboolean api_check
= GL_FALSE
;
1223 GLboolean api_found
= GL_FALSE
;
1226 for (e
= d
->extra
; *e
!= EXTRA_END
; e
++) {
1228 case EXTRA_VERSION_30
:
1229 api_check
= GL_TRUE
;
1231 api_found
= GL_TRUE
;
1233 case EXTRA_VERSION_31
:
1234 api_check
= GL_TRUE
;
1236 api_found
= GL_TRUE
;
1238 case EXTRA_VERSION_32
:
1239 api_check
= GL_TRUE
;
1241 api_found
= GL_TRUE
;
1243 case EXTRA_VERSION_40
:
1244 api_check
= GL_TRUE
;
1246 api_found
= GL_TRUE
;
1248 case EXTRA_VERSION_43
:
1250 if (_mesa_is_desktop_gl(ctx
) && version
>= 43)
1251 api_found
= GL_TRUE
;
1253 case EXTRA_NEW_FRAG_CLAMP
:
1254 if (ctx
->NewState
& (_NEW_BUFFERS
| _NEW_FRAG_CLAMP
))
1255 _mesa_update_state(ctx
);
1258 api_check
= GL_TRUE
;
1259 if (ctx
->API
== API_OPENGLES2
)
1260 api_found
= GL_TRUE
;
1263 api_check
= GL_TRUE
;
1264 if (_mesa_is_gles3(ctx
))
1265 api_found
= GL_TRUE
;
1267 case EXTRA_API_ES31
:
1268 api_check
= GL_TRUE
;
1269 if (_mesa_is_gles31(ctx
))
1270 api_found
= GL_TRUE
;
1272 case EXTRA_API_ES32
:
1273 api_check
= GL_TRUE
;
1274 if (_mesa_is_gles32(ctx
))
1275 api_found
= GL_TRUE
;
1278 api_check
= GL_TRUE
;
1279 if (_mesa_is_desktop_gl(ctx
))
1280 api_found
= GL_TRUE
;
1282 case EXTRA_API_GL_CORE
:
1283 api_check
= GL_TRUE
;
1284 if (ctx
->API
== API_OPENGL_CORE
)
1285 api_found
= GL_TRUE
;
1287 case EXTRA_NEW_BUFFERS
:
1288 if (ctx
->NewState
& _NEW_BUFFERS
)
1289 _mesa_update_state(ctx
);
1291 case EXTRA_FLUSH_CURRENT
:
1292 FLUSH_CURRENT(ctx
, 0);
1294 case EXTRA_VALID_DRAW_BUFFER
:
1295 if (d
->pname
- GL_DRAW_BUFFER0_ARB
>= ctx
->Const
.MaxDrawBuffers
) {
1296 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(draw buffer %u)",
1297 func
, d
->pname
- GL_DRAW_BUFFER0_ARB
);
1301 case EXTRA_VALID_TEXTURE_UNIT
:
1302 if (ctx
->Texture
.CurrentUnit
>= ctx
->Const
.MaxTextureCoordUnits
) {
1303 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(texture %u)",
1304 func
, ctx
->Texture
.CurrentUnit
);
1308 case EXTRA_VALID_CLIP_DISTANCE
:
1309 if (d
->pname
- GL_CLIP_DISTANCE0
>= ctx
->Const
.MaxClipPlanes
) {
1310 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(clip distance %u)",
1311 func
, d
->pname
- GL_CLIP_DISTANCE0
);
1315 case EXTRA_GLSL_130
:
1316 api_check
= GL_TRUE
;
1317 if (ctx
->Const
.GLSLVersion
>= 130)
1318 api_found
= GL_TRUE
;
1320 case EXTRA_EXT_UBO_GS
:
1321 api_check
= GL_TRUE
;
1322 if (ctx
->Extensions
.ARB_uniform_buffer_object
&&
1323 _mesa_has_geometry_shaders(ctx
))
1324 api_found
= GL_TRUE
;
1326 case EXTRA_EXT_ATOMICS_GS
:
1327 api_check
= GL_TRUE
;
1328 if (ctx
->Extensions
.ARB_shader_atomic_counters
&&
1329 _mesa_has_geometry_shaders(ctx
))
1330 api_found
= GL_TRUE
;
1332 case EXTRA_EXT_SHADER_IMAGE_GS
:
1333 api_check
= GL_TRUE
;
1334 if (ctx
->Extensions
.ARB_shader_image_load_store
&&
1335 _mesa_has_geometry_shaders(ctx
))
1336 api_found
= GL_TRUE
;
1338 case EXTRA_EXT_ATOMICS_TESS
:
1339 api_check
= GL_TRUE
;
1340 api_found
= ctx
->Extensions
.ARB_shader_atomic_counters
&&
1341 _mesa_has_tessellation(ctx
);
1343 case EXTRA_EXT_SHADER_IMAGE_TESS
:
1344 api_check
= GL_TRUE
;
1345 api_found
= ctx
->Extensions
.ARB_shader_image_load_store
&&
1346 _mesa_has_tessellation(ctx
);
1348 case EXTRA_EXT_SSBO_GS
:
1349 api_check
= GL_TRUE
;
1350 if (ctx
->Extensions
.ARB_shader_storage_buffer_object
&&
1351 _mesa_has_geometry_shaders(ctx
))
1352 api_found
= GL_TRUE
;
1354 case EXTRA_EXT_FB_NO_ATTACH_GS
:
1355 api_check
= GL_TRUE
;
1356 if (ctx
->Extensions
.ARB_framebuffer_no_attachments
&&
1357 (_mesa_is_desktop_gl(ctx
) ||
1358 _mesa_has_OES_geometry_shader(ctx
)))
1359 api_found
= GL_TRUE
;
1361 case EXTRA_EXT_ES_GS
:
1362 api_check
= GL_TRUE
;
1363 if (_mesa_has_OES_geometry_shader(ctx
))
1364 api_found
= GL_TRUE
;
1366 case EXTRA_EXT_PROVOKING_VERTEX_32
:
1368 if (ctx
->API
== API_OPENGL_COMPAT
|| version
== 32)
1369 api_found
= ctx
->Extensions
.EXT_provoking_vertex
;
1373 default: /* *e is a offset into the extension struct */
1374 api_check
= GL_TRUE
;
1375 if (*(GLboolean
*) ((char *) &ctx
->Extensions
+ *e
))
1376 api_found
= GL_TRUE
;
1381 if (api_check
&& !api_found
) {
1382 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(pname=%s)", func
,
1383 _mesa_enum_to_string(d
->pname
));
1390 static const struct value_desc error_value
=
1391 { 0, 0, TYPE_INVALID
, NO_OFFSET
, NO_EXTRA
};
1394 * Find the struct value_desc corresponding to the enum 'pname'.
1396 * We hash the enum value to get an index into the 'table' array,
1397 * which holds the index in the 'values' array of struct value_desc.
1398 * Once we've found the entry, we do the extra checks, if any, then
1399 * look up the value and return a pointer to it.
1401 * If the value has to be computed (for example, it's the result of a
1402 * function call or we need to add 1 to it), we use the tmp 'v' to
1405 * \param func name of glGet*v() func for error reporting
1406 * \param pname the enum value we're looking up
1407 * \param p is were we return the pointer to the value
1408 * \param v a tmp union value variable in the calling glGet*v() function
1410 * \return the struct value_desc corresponding to the enum or a struct
1411 * value_desc of TYPE_INVALID if not found. This lets the calling
1412 * glGet*v() function jump right into a switch statement and
1413 * handle errors there instead of having to check for NULL.
1415 static const struct value_desc
*
1416 find_value(const char *func
, GLenum pname
, void **p
, union value
*v
)
1418 GET_CURRENT_CONTEXT(ctx
);
1420 const struct value_desc
*d
;
1424 /* We index into the table_set[] list of per-API hash tables using the API's
1425 * value in the gl_api enum. Since GLES 3 doesn't have an API_OPENGL* enum
1426 * value since it's compatible with GLES2 its entry in table_set[] is at the
1429 STATIC_ASSERT(ARRAY_SIZE(table_set
) == API_OPENGL_LAST
+ 4);
1430 if (ctx
->API
== API_OPENGLES2
) {
1431 if (ctx
->Version
>= 32)
1432 api
= API_OPENGL_LAST
+ 3;
1433 else if (ctx
->Version
>= 31)
1434 api
= API_OPENGL_LAST
+ 2;
1435 else if (ctx
->Version
>= 30)
1436 api
= API_OPENGL_LAST
+ 1;
1438 mask
= ARRAY_SIZE(table(api
)) - 1;
1439 hash
= (pname
* prime_factor
);
1441 int idx
= table(api
)[hash
& mask
];
1443 /* If the enum isn't valid, the hash walk ends with index 0,
1444 * pointing to the first entry of values[] which doesn't hold
1445 * any valid enum. */
1446 if (unlikely(idx
== 0)) {
1447 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(pname=%s)", func
,
1448 _mesa_enum_to_string(pname
));
1449 return &error_value
;
1453 if (likely(d
->pname
== pname
))
1459 if (unlikely(d
->extra
&& !check_extra(ctx
, func
, d
)))
1460 return &error_value
;
1462 switch (d
->location
) {
1464 *p
= ((char *) ctx
->DrawBuffer
+ d
->offset
);
1467 *p
= ((char *) ctx
+ d
->offset
);
1470 *p
= ((char *) ctx
->Array
.VAO
+ d
->offset
);
1473 if (ctx
->Texture
.CurrentUnit
< ARRAY_SIZE(ctx
->Texture
.FixedFuncUnit
)) {
1474 unsigned index
= ctx
->Texture
.CurrentUnit
;
1475 *p
= ((char *)&ctx
->Texture
.FixedFuncUnit
[index
] + d
->offset
);
1479 find_custom_value(ctx
, d
, v
);
1487 /* silence warning */
1488 return &error_value
;
1491 static const int transpose
[] = {
1499 get_value_size(enum value_type type
, const union value
*v
)
1507 return sizeof(GLint
);
1510 return sizeof(GLint
) * 2;
1513 return sizeof(GLint
) * 3;
1516 return sizeof(GLint
) * 4;
1518 return sizeof(GLint
) * v
->value_int_n
.n
;
1520 return sizeof(GLint64
);
1523 return sizeof(GLenum16
);
1525 return sizeof(GLenum
);
1527 return sizeof(GLenum
) * 2;
1529 return sizeof(GLboolean
);
1531 return sizeof(GLubyte
);
1533 return sizeof(GLshort
);
1545 return sizeof(GLfloat
);
1548 return sizeof(GLfloat
) * 2;
1551 return sizeof(GLfloat
) * 3;
1554 return sizeof(GLfloat
) * 4;
1556 return sizeof(GLfloat
) * 8;
1558 return sizeof(GLdouble
);
1559 case TYPE_DOUBLEN_2
:
1560 return sizeof(GLdouble
) * 2;
1562 return sizeof (GLfloat
) * 16;
1564 return sizeof (GLfloat
) * 16;
1571 _mesa_GetBooleanv(GLenum pname
, GLboolean
*params
)
1573 const struct value_desc
*d
;
1579 d
= find_value("glGetBooleanv", pname
, &p
, &v
);
1584 params
[0] = INT_TO_BOOLEAN(d
->offset
);
1588 params
[7] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[7]);
1589 params
[6] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[6]);
1590 params
[5] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[5]);
1591 params
[4] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[4]);
1594 params
[3] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[3]);
1597 params
[2] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[2]);
1600 params
[1] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[1]);
1603 params
[0] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[0]);
1606 case TYPE_DOUBLEN_2
:
1607 params
[1] = FLOAT_TO_BOOLEAN(((GLdouble
*) p
)[1]);
1609 params
[0] = FLOAT_TO_BOOLEAN(((GLdouble
*) p
)[0]);
1614 params
[3] = INT_TO_BOOLEAN(((GLint
*) p
)[3]);
1617 params
[2] = INT_TO_BOOLEAN(((GLint
*) p
)[2]);
1621 params
[1] = INT_TO_BOOLEAN(((GLint
*) p
)[1]);
1625 params
[0] = INT_TO_BOOLEAN(((GLint
*) p
)[0]);
1629 params
[0] = INT_TO_BOOLEAN(((GLenum16
*) p
)[0]);
1633 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
1634 params
[i
] = INT_TO_BOOLEAN(v
.value_int_n
.ints
[i
]);
1638 params
[0] = INT64_TO_BOOLEAN(((GLint64
*) p
)[0]);
1642 params
[0] = ((GLboolean
*) p
)[0];
1646 params
[0] = INT_TO_BOOLEAN(((GLubyte
*) p
)[0]);
1650 params
[0] = INT_TO_BOOLEAN(((GLshort
*) p
)[0]);
1654 m
= *(GLmatrix
**) p
;
1655 for (i
= 0; i
< 16; i
++)
1656 params
[i
] = FLOAT_TO_BOOLEAN(m
->m
[i
]);
1660 m
= *(GLmatrix
**) p
;
1661 for (i
= 0; i
< 16; i
++)
1662 params
[i
] = FLOAT_TO_BOOLEAN(m
->m
[transpose
[i
]]);
1673 shift
= d
->type
- TYPE_BIT_0
;
1674 params
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
1680 _mesa_GetFloatv(GLenum pname
, GLfloat
*params
)
1682 const struct value_desc
*d
;
1688 d
= find_value("glGetFloatv", pname
, &p
, &v
);
1693 params
[0] = (GLfloat
) d
->offset
;
1697 params
[7] = ((GLfloat
*) p
)[7];
1698 params
[6] = ((GLfloat
*) p
)[6];
1699 params
[5] = ((GLfloat
*) p
)[5];
1700 params
[4] = ((GLfloat
*) p
)[4];
1703 params
[3] = ((GLfloat
*) p
)[3];
1706 params
[2] = ((GLfloat
*) p
)[2];
1709 params
[1] = ((GLfloat
*) p
)[1];
1712 params
[0] = ((GLfloat
*) p
)[0];
1715 case TYPE_DOUBLEN_2
:
1716 params
[1] = (GLfloat
) (((GLdouble
*) p
)[1]);
1718 params
[0] = (GLfloat
) (((GLdouble
*) p
)[0]);
1722 params
[3] = (GLfloat
) (((GLint
*) p
)[3]);
1724 params
[2] = (GLfloat
) (((GLint
*) p
)[2]);
1727 params
[1] = (GLfloat
) (((GLint
*) p
)[1]);
1730 params
[0] = (GLfloat
) (((GLint
*) p
)[0]);
1734 params
[0] = (GLfloat
) (((GLenum16
*) p
)[0]);
1738 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
1739 params
[i
] = (GLfloat
) v
.value_int_n
.ints
[i
];
1743 params
[3] = (GLfloat
) (((GLuint
*) p
)[3]);
1745 params
[2] = (GLfloat
) (((GLuint
*) p
)[2]);
1747 params
[1] = (GLfloat
) (((GLuint
*) p
)[1]);
1749 params
[0] = (GLfloat
) (((GLuint
*) p
)[0]);
1753 params
[0] = (GLfloat
) (((GLint64
*) p
)[0]);
1757 params
[0] = BOOLEAN_TO_FLOAT(*(GLboolean
*) p
);
1761 params
[0] = (GLfloat
) ((GLubyte
*) p
)[0];
1765 params
[0] = (GLfloat
) ((GLshort
*) p
)[0];
1769 m
= *(GLmatrix
**) p
;
1770 for (i
= 0; i
< 16; i
++)
1771 params
[i
] = m
->m
[i
];
1775 m
= *(GLmatrix
**) p
;
1776 for (i
= 0; i
< 16; i
++)
1777 params
[i
] = m
->m
[transpose
[i
]];
1788 shift
= d
->type
- TYPE_BIT_0
;
1789 params
[0] = BOOLEAN_TO_FLOAT((*(GLbitfield
*) p
>> shift
) & 1);
1795 _mesa_GetIntegerv(GLenum pname
, GLint
*params
)
1797 const struct value_desc
*d
;
1803 d
= find_value("glGetIntegerv", pname
, &p
, &v
);
1808 params
[0] = d
->offset
;
1812 params
[7] = IROUND(((GLfloat
*) p
)[7]);
1813 params
[6] = IROUND(((GLfloat
*) p
)[6]);
1814 params
[5] = IROUND(((GLfloat
*) p
)[5]);
1815 params
[4] = IROUND(((GLfloat
*) p
)[4]);
1817 params
[3] = IROUND(((GLfloat
*) p
)[3]);
1819 params
[2] = IROUND(((GLfloat
*) p
)[2]);
1821 params
[1] = IROUND(((GLfloat
*) p
)[1]);
1823 params
[0] = IROUND(((GLfloat
*) p
)[0]);
1827 params
[3] = FLOAT_TO_INT(((GLfloat
*) p
)[3]);
1829 params
[2] = FLOAT_TO_INT(((GLfloat
*) p
)[2]);
1831 params
[1] = FLOAT_TO_INT(((GLfloat
*) p
)[1]);
1833 params
[0] = FLOAT_TO_INT(((GLfloat
*) p
)[0]);
1836 case TYPE_DOUBLEN_2
:
1837 params
[1] = FLOAT_TO_INT(((GLdouble
*) p
)[1]);
1839 params
[0] = FLOAT_TO_INT(((GLdouble
*) p
)[0]);
1844 params
[3] = ((GLint
*) p
)[3];
1847 params
[2] = ((GLint
*) p
)[2];
1851 params
[1] = ((GLint
*) p
)[1];
1855 params
[0] = ((GLint
*) p
)[0];
1859 params
[0] = ((GLenum16
*) p
)[0];
1863 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
1864 params
[i
] = v
.value_int_n
.ints
[i
];
1868 params
[0] = INT64_TO_INT(((GLint64
*) p
)[0]);
1872 params
[0] = BOOLEAN_TO_INT(*(GLboolean
*) p
);
1876 params
[0] = ((GLubyte
*) p
)[0];
1880 params
[0] = ((GLshort
*) p
)[0];
1884 m
= *(GLmatrix
**) p
;
1885 for (i
= 0; i
< 16; i
++)
1886 params
[i
] = FLOAT_TO_INT(m
->m
[i
]);
1890 m
= *(GLmatrix
**) p
;
1891 for (i
= 0; i
< 16; i
++)
1892 params
[i
] = FLOAT_TO_INT(m
->m
[transpose
[i
]]);
1903 shift
= d
->type
- TYPE_BIT_0
;
1904 params
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
1910 _mesa_GetInteger64v(GLenum pname
, GLint64
*params
)
1912 const struct value_desc
*d
;
1918 d
= find_value("glGetInteger64v", pname
, &p
, &v
);
1923 params
[0] = d
->offset
;
1927 params
[7] = IROUND64(((GLfloat
*) p
)[7]);
1928 params
[6] = IROUND64(((GLfloat
*) p
)[6]);
1929 params
[5] = IROUND64(((GLfloat
*) p
)[5]);
1930 params
[4] = IROUND64(((GLfloat
*) p
)[4]);
1932 params
[3] = IROUND64(((GLfloat
*) p
)[3]);
1934 params
[2] = IROUND64(((GLfloat
*) p
)[2]);
1936 params
[1] = IROUND64(((GLfloat
*) p
)[1]);
1938 params
[0] = IROUND64(((GLfloat
*) p
)[0]);
1942 params
[3] = FLOAT_TO_INT(((GLfloat
*) p
)[3]);
1944 params
[2] = FLOAT_TO_INT(((GLfloat
*) p
)[2]);
1946 params
[1] = FLOAT_TO_INT(((GLfloat
*) p
)[1]);
1948 params
[0] = FLOAT_TO_INT(((GLfloat
*) p
)[0]);
1951 case TYPE_DOUBLEN_2
:
1952 params
[1] = FLOAT_TO_INT(((GLdouble
*) p
)[1]);
1954 params
[0] = FLOAT_TO_INT(((GLdouble
*) p
)[0]);
1958 params
[3] = ((GLint
*) p
)[3];
1960 params
[2] = ((GLint
*) p
)[2];
1963 params
[1] = ((GLint
*) p
)[1];
1966 params
[0] = ((GLint
*) p
)[0];
1970 params
[0] = ((GLenum16
*) p
)[0];
1974 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
1975 params
[i
] = INT_TO_BOOLEAN(v
.value_int_n
.ints
[i
]);
1979 params
[3] = ((GLuint
*) p
)[3];
1981 params
[2] = ((GLuint
*) p
)[2];
1983 params
[1] = ((GLuint
*) p
)[1];
1985 params
[0] = ((GLuint
*) p
)[0];
1989 params
[0] = ((GLint64
*) p
)[0];
1993 params
[0] = ((GLboolean
*) p
)[0];
1997 m
= *(GLmatrix
**) p
;
1998 for (i
= 0; i
< 16; i
++)
1999 params
[i
] = FLOAT_TO_INT64(m
->m
[i
]);
2003 m
= *(GLmatrix
**) p
;
2004 for (i
= 0; i
< 16; i
++)
2005 params
[i
] = FLOAT_TO_INT64(m
->m
[transpose
[i
]]);
2016 shift
= d
->type
- TYPE_BIT_0
;
2017 params
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
2023 _mesa_GetDoublev(GLenum pname
, GLdouble
*params
)
2025 const struct value_desc
*d
;
2031 d
= find_value("glGetDoublev", pname
, &p
, &v
);
2036 params
[0] = d
->offset
;
2040 params
[7] = ((GLfloat
*) p
)[7];
2041 params
[6] = ((GLfloat
*) p
)[6];
2042 params
[5] = ((GLfloat
*) p
)[5];
2043 params
[4] = ((GLfloat
*) p
)[4];
2046 params
[3] = ((GLfloat
*) p
)[3];
2049 params
[2] = ((GLfloat
*) p
)[2];
2052 params
[1] = ((GLfloat
*) p
)[1];
2055 params
[0] = ((GLfloat
*) p
)[0];
2058 case TYPE_DOUBLEN_2
:
2059 params
[1] = ((GLdouble
*) p
)[1];
2061 params
[0] = ((GLdouble
*) p
)[0];
2065 params
[3] = ((GLint
*) p
)[3];
2067 params
[2] = ((GLint
*) p
)[2];
2070 params
[1] = ((GLint
*) p
)[1];
2073 params
[0] = ((GLint
*) p
)[0];
2077 params
[0] = ((GLenum16
*) p
)[0];
2081 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
2082 params
[i
] = v
.value_int_n
.ints
[i
];
2086 params
[3] = ((GLuint
*) p
)[3];
2088 params
[2] = ((GLuint
*) p
)[2];
2090 params
[1] = ((GLuint
*) p
)[1];
2092 params
[0] = ((GLuint
*) p
)[0];
2096 params
[0] = (GLdouble
) (((GLint64
*) p
)[0]);
2100 params
[0] = *(GLboolean
*) p
;
2104 params
[0] = ((GLubyte
*) p
)[0];
2108 params
[0] = ((GLshort
*) p
)[0];
2112 m
= *(GLmatrix
**) p
;
2113 for (i
= 0; i
< 16; i
++)
2114 params
[i
] = m
->m
[i
];
2118 m
= *(GLmatrix
**) p
;
2119 for (i
= 0; i
< 16; i
++)
2120 params
[i
] = m
->m
[transpose
[i
]];
2131 shift
= d
->type
- TYPE_BIT_0
;
2132 params
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
2138 _mesa_GetUnsignedBytevEXT(GLenum pname
, GLubyte
*data
)
2140 const struct value_desc
*d
;
2145 const char *func
= "glGetUnsignedBytevEXT";
2147 GET_CURRENT_CONTEXT(ctx
);
2149 if (!ctx
->Extensions
.EXT_memory_object
) {
2150 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(unsupported)", func
);
2154 d
= find_value(func
, pname
, &p
, &v
);
2155 size
= get_value_size(d
->type
, &v
);
2157 _mesa_problem(ctx
, "invalid value type in GetUnsignedBytevEXT()");
2169 shift
= d
->type
- TYPE_BIT_0
;
2170 data
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
2173 memcpy(data
, &d
->offset
, size
);
2176 memcpy(data
, &v
.value_int_n
.ints
, size
);
2202 case TYPE_DOUBLEN_2
:
2205 memcpy(data
, p
, size
);
2208 GLenum e
= *(GLenum16
*)p
;
2209 memcpy(data
, &e
, sizeof(e
));
2213 break; /* nothing - GL error was recorded */
2218 * Convert a GL texture binding enum such as GL_TEXTURE_BINDING_2D
2219 * into the corresponding Mesa texture target index.
2220 * \return TEXTURE_x_INDEX or -1 if binding is invalid
2223 tex_binding_to_index(const struct gl_context
*ctx
, GLenum binding
)
2226 case GL_TEXTURE_BINDING_1D
:
2227 return _mesa_is_desktop_gl(ctx
) ? TEXTURE_1D_INDEX
: -1;
2228 case GL_TEXTURE_BINDING_2D
:
2229 return TEXTURE_2D_INDEX
;
2230 case GL_TEXTURE_BINDING_3D
:
2231 return ctx
->API
!= API_OPENGLES
? TEXTURE_3D_INDEX
: -1;
2232 case GL_TEXTURE_BINDING_CUBE_MAP
:
2233 return ctx
->Extensions
.ARB_texture_cube_map
2234 ? TEXTURE_CUBE_INDEX
: -1;
2235 case GL_TEXTURE_BINDING_RECTANGLE
:
2236 return _mesa_is_desktop_gl(ctx
) && ctx
->Extensions
.NV_texture_rectangle
2237 ? TEXTURE_RECT_INDEX
: -1;
2238 case GL_TEXTURE_BINDING_1D_ARRAY
:
2239 return _mesa_is_desktop_gl(ctx
) && ctx
->Extensions
.EXT_texture_array
2240 ? TEXTURE_1D_ARRAY_INDEX
: -1;
2241 case GL_TEXTURE_BINDING_2D_ARRAY
:
2242 return (_mesa_is_desktop_gl(ctx
) && ctx
->Extensions
.EXT_texture_array
)
2243 || _mesa_is_gles3(ctx
)
2244 ? TEXTURE_2D_ARRAY_INDEX
: -1;
2245 case GL_TEXTURE_BINDING_BUFFER
:
2246 return (_mesa_has_ARB_texture_buffer_object(ctx
) ||
2247 _mesa_has_OES_texture_buffer(ctx
)) ?
2248 TEXTURE_BUFFER_INDEX
: -1;
2249 case GL_TEXTURE_BINDING_CUBE_MAP_ARRAY
:
2250 return _mesa_has_texture_cube_map_array(ctx
)
2251 ? TEXTURE_CUBE_ARRAY_INDEX
: -1;
2252 case GL_TEXTURE_BINDING_2D_MULTISAMPLE
:
2253 return _mesa_is_desktop_gl(ctx
) && ctx
->Extensions
.ARB_texture_multisample
2254 ? TEXTURE_2D_MULTISAMPLE_INDEX
: -1;
2255 case GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY
:
2256 return _mesa_is_desktop_gl(ctx
) && ctx
->Extensions
.ARB_texture_multisample
2257 ? TEXTURE_2D_MULTISAMPLE_ARRAY_INDEX
: -1;
2263 static enum value_type
2264 find_value_indexed(const char *func
, GLenum pname
, GLuint index
, union value
*v
)
2266 GET_CURRENT_CONTEXT(ctx
);
2271 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2273 if (!ctx
->Extensions
.EXT_draw_buffers2
)
2275 v
->value_int
= (ctx
->Color
.BlendEnabled
>> index
) & 1;
2280 case GL_BLEND_SRC_RGB
:
2281 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2283 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
2285 v
->value_int
= ctx
->Color
.Blend
[index
].SrcRGB
;
2287 case GL_BLEND_SRC_ALPHA
:
2288 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2290 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
2292 v
->value_int
= ctx
->Color
.Blend
[index
].SrcA
;
2296 case GL_BLEND_DST_RGB
:
2297 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2299 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
2301 v
->value_int
= ctx
->Color
.Blend
[index
].DstRGB
;
2303 case GL_BLEND_DST_ALPHA
:
2304 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2306 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
2308 v
->value_int
= ctx
->Color
.Blend
[index
].DstA
;
2310 case GL_BLEND_EQUATION_RGB
:
2311 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2313 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
2315 v
->value_int
= ctx
->Color
.Blend
[index
].EquationRGB
;
2317 case GL_BLEND_EQUATION_ALPHA
:
2318 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2320 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
2322 v
->value_int
= ctx
->Color
.Blend
[index
].EquationA
;
2325 case GL_COLOR_WRITEMASK
:
2326 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2328 if (!ctx
->Extensions
.EXT_draw_buffers2
)
2330 v
->value_int_4
[0] = GET_COLORMASK_BIT(ctx
->Color
.ColorMask
, index
, 0);
2331 v
->value_int_4
[1] = GET_COLORMASK_BIT(ctx
->Color
.ColorMask
, index
, 1);
2332 v
->value_int_4
[2] = GET_COLORMASK_BIT(ctx
->Color
.ColorMask
, index
, 2);
2333 v
->value_int_4
[3] = GET_COLORMASK_BIT(ctx
->Color
.ColorMask
, index
, 3);
2336 case GL_SCISSOR_BOX
:
2337 if (index
>= ctx
->Const
.MaxViewports
)
2339 v
->value_int_4
[0] = ctx
->Scissor
.ScissorArray
[index
].X
;
2340 v
->value_int_4
[1] = ctx
->Scissor
.ScissorArray
[index
].Y
;
2341 v
->value_int_4
[2] = ctx
->Scissor
.ScissorArray
[index
].Width
;
2342 v
->value_int_4
[3] = ctx
->Scissor
.ScissorArray
[index
].Height
;
2345 case GL_WINDOW_RECTANGLE_EXT
:
2346 if (!ctx
->Extensions
.EXT_window_rectangles
)
2348 if (index
>= ctx
->Const
.MaxWindowRectangles
)
2350 v
->value_int_4
[0] = ctx
->Scissor
.WindowRects
[index
].X
;
2351 v
->value_int_4
[1] = ctx
->Scissor
.WindowRects
[index
].Y
;
2352 v
->value_int_4
[2] = ctx
->Scissor
.WindowRects
[index
].Width
;
2353 v
->value_int_4
[3] = ctx
->Scissor
.WindowRects
[index
].Height
;
2357 if (index
>= ctx
->Const
.MaxViewports
)
2359 v
->value_float_4
[0] = ctx
->ViewportArray
[index
].X
;
2360 v
->value_float_4
[1] = ctx
->ViewportArray
[index
].Y
;
2361 v
->value_float_4
[2] = ctx
->ViewportArray
[index
].Width
;
2362 v
->value_float_4
[3] = ctx
->ViewportArray
[index
].Height
;
2363 return TYPE_FLOAT_4
;
2365 case GL_DEPTH_RANGE
:
2366 if (index
>= ctx
->Const
.MaxViewports
)
2368 v
->value_double_2
[0] = ctx
->ViewportArray
[index
].Near
;
2369 v
->value_double_2
[1] = ctx
->ViewportArray
[index
].Far
;
2370 return TYPE_DOUBLEN_2
;
2372 case GL_TRANSFORM_FEEDBACK_BUFFER_START
:
2373 if (index
>= ctx
->Const
.MaxTransformFeedbackBuffers
)
2375 if (!ctx
->Extensions
.EXT_transform_feedback
)
2377 v
->value_int64
= ctx
->TransformFeedback
.CurrentObject
->Offset
[index
];
2380 case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE
:
2381 if (index
>= ctx
->Const
.MaxTransformFeedbackBuffers
)
2383 if (!ctx
->Extensions
.EXT_transform_feedback
)
2386 = ctx
->TransformFeedback
.CurrentObject
->RequestedSize
[index
];
2389 case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING
:
2390 if (index
>= ctx
->Const
.MaxTransformFeedbackBuffers
)
2392 if (!ctx
->Extensions
.EXT_transform_feedback
)
2394 v
->value_int
= ctx
->TransformFeedback
.CurrentObject
->BufferNames
[index
];
2397 case GL_UNIFORM_BUFFER_BINDING
:
2398 if (index
>= ctx
->Const
.MaxUniformBufferBindings
)
2400 if (!ctx
->Extensions
.ARB_uniform_buffer_object
)
2402 v
->value_int
= ctx
->UniformBufferBindings
[index
].BufferObject
->Name
;
2405 case GL_UNIFORM_BUFFER_START
:
2406 if (index
>= ctx
->Const
.MaxUniformBufferBindings
)
2408 if (!ctx
->Extensions
.ARB_uniform_buffer_object
)
2410 v
->value_int
= ctx
->UniformBufferBindings
[index
].Offset
< 0 ? 0 :
2411 ctx
->UniformBufferBindings
[index
].Offset
;
2414 case GL_UNIFORM_BUFFER_SIZE
:
2415 if (index
>= ctx
->Const
.MaxUniformBufferBindings
)
2417 if (!ctx
->Extensions
.ARB_uniform_buffer_object
)
2419 v
->value_int
= ctx
->UniformBufferBindings
[index
].Size
< 0 ? 0 :
2420 ctx
->UniformBufferBindings
[index
].Size
;
2423 /* ARB_shader_storage_buffer_object */
2424 case GL_SHADER_STORAGE_BUFFER_BINDING
:
2425 if (!ctx
->Extensions
.ARB_shader_storage_buffer_object
)
2427 if (index
>= ctx
->Const
.MaxShaderStorageBufferBindings
)
2429 v
->value_int
= ctx
->ShaderStorageBufferBindings
[index
].BufferObject
->Name
;
2432 case GL_SHADER_STORAGE_BUFFER_START
:
2433 if (!ctx
->Extensions
.ARB_shader_storage_buffer_object
)
2435 if (index
>= ctx
->Const
.MaxShaderStorageBufferBindings
)
2437 v
->value_int
= ctx
->ShaderStorageBufferBindings
[index
].Offset
< 0 ? 0 :
2438 ctx
->ShaderStorageBufferBindings
[index
].Offset
;
2441 case GL_SHADER_STORAGE_BUFFER_SIZE
:
2442 if (!ctx
->Extensions
.ARB_shader_storage_buffer_object
)
2444 if (index
>= ctx
->Const
.MaxShaderStorageBufferBindings
)
2446 v
->value_int
= ctx
->ShaderStorageBufferBindings
[index
].Size
< 0 ? 0 :
2447 ctx
->ShaderStorageBufferBindings
[index
].Size
;
2450 /* ARB_texture_multisample / GL3.2 */
2451 case GL_SAMPLE_MASK_VALUE
:
2454 if (!ctx
->Extensions
.ARB_texture_multisample
)
2456 v
->value_int
= ctx
->Multisample
.SampleMaskValue
;
2459 case GL_ATOMIC_COUNTER_BUFFER_BINDING
:
2460 if (!ctx
->Extensions
.ARB_shader_atomic_counters
)
2462 if (index
>= ctx
->Const
.MaxAtomicBufferBindings
)
2464 v
->value_int
= ctx
->AtomicBufferBindings
[index
].BufferObject
->Name
;
2467 case GL_ATOMIC_COUNTER_BUFFER_START
:
2468 if (!ctx
->Extensions
.ARB_shader_atomic_counters
)
2470 if (index
>= ctx
->Const
.MaxAtomicBufferBindings
)
2472 v
->value_int64
= ctx
->AtomicBufferBindings
[index
].Offset
< 0 ? 0 :
2473 ctx
->AtomicBufferBindings
[index
].Offset
;
2476 case GL_ATOMIC_COUNTER_BUFFER_SIZE
:
2477 if (!ctx
->Extensions
.ARB_shader_atomic_counters
)
2479 if (index
>= ctx
->Const
.MaxAtomicBufferBindings
)
2481 v
->value_int64
= ctx
->AtomicBufferBindings
[index
].Size
< 0 ? 0 :
2482 ctx
->AtomicBufferBindings
[index
].Size
;
2485 case GL_VERTEX_BINDING_DIVISOR
:
2486 if ((!_mesa_is_desktop_gl(ctx
) || !ctx
->Extensions
.ARB_instanced_arrays
) &&
2487 !_mesa_is_gles31(ctx
))
2489 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
)
2491 v
->value_int
= ctx
->Array
.VAO
->BufferBinding
[VERT_ATTRIB_GENERIC(index
)].InstanceDivisor
;
2494 case GL_VERTEX_BINDING_OFFSET
:
2495 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles31(ctx
))
2497 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
)
2499 v
->value_int
= ctx
->Array
.VAO
->BufferBinding
[VERT_ATTRIB_GENERIC(index
)].Offset
;
2502 case GL_VERTEX_BINDING_STRIDE
:
2503 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles31(ctx
))
2505 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
)
2507 v
->value_int
= ctx
->Array
.VAO
->BufferBinding
[VERT_ATTRIB_GENERIC(index
)].Stride
;
2510 case GL_VERTEX_BINDING_BUFFER
:
2511 if (ctx
->API
== API_OPENGLES2
&& ctx
->Version
< 31)
2513 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
)
2515 v
->value_int
= ctx
->Array
.VAO
->BufferBinding
[VERT_ATTRIB_GENERIC(index
)].BufferObj
->Name
;
2518 /* ARB_shader_image_load_store */
2519 case GL_IMAGE_BINDING_NAME
: {
2520 struct gl_texture_object
*t
;
2522 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
2524 if (index
>= ctx
->Const
.MaxImageUnits
)
2527 t
= ctx
->ImageUnits
[index
].TexObj
;
2528 v
->value_int
= (t
? t
->Name
: 0);
2532 case GL_IMAGE_BINDING_LEVEL
:
2533 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
2535 if (index
>= ctx
->Const
.MaxImageUnits
)
2538 v
->value_int
= ctx
->ImageUnits
[index
].Level
;
2541 case GL_IMAGE_BINDING_LAYERED
:
2542 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
2544 if (index
>= ctx
->Const
.MaxImageUnits
)
2547 v
->value_int
= ctx
->ImageUnits
[index
].Layered
;
2550 case GL_IMAGE_BINDING_LAYER
:
2551 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
2553 if (index
>= ctx
->Const
.MaxImageUnits
)
2556 v
->value_int
= ctx
->ImageUnits
[index
].Layer
;
2559 case GL_IMAGE_BINDING_ACCESS
:
2560 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
2562 if (index
>= ctx
->Const
.MaxImageUnits
)
2565 v
->value_int
= ctx
->ImageUnits
[index
].Access
;
2568 case GL_IMAGE_BINDING_FORMAT
:
2569 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
2571 if (index
>= ctx
->Const
.MaxImageUnits
)
2574 v
->value_int
= ctx
->ImageUnits
[index
].Format
;
2577 /* ARB_direct_state_access */
2578 case GL_TEXTURE_BINDING_1D
:
2579 case GL_TEXTURE_BINDING_1D_ARRAY
:
2580 case GL_TEXTURE_BINDING_2D
:
2581 case GL_TEXTURE_BINDING_2D_ARRAY
:
2582 case GL_TEXTURE_BINDING_2D_MULTISAMPLE
:
2583 case GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY
:
2584 case GL_TEXTURE_BINDING_3D
:
2585 case GL_TEXTURE_BINDING_BUFFER
:
2586 case GL_TEXTURE_BINDING_CUBE_MAP
:
2587 case GL_TEXTURE_BINDING_CUBE_MAP_ARRAY
:
2588 case GL_TEXTURE_BINDING_RECTANGLE
: {
2591 if (ctx
->API
!= API_OPENGL_CORE
)
2593 target
= tex_binding_to_index(ctx
, pname
);
2596 if (index
>= _mesa_max_tex_unit(ctx
))
2599 v
->value_int
= ctx
->Texture
.Unit
[index
].CurrentTex
[target
]->Name
;
2603 case GL_SAMPLER_BINDING
: {
2604 struct gl_sampler_object
*samp
;
2606 if (!_mesa_is_desktop_gl(ctx
) || ctx
->Version
< 33)
2608 if (index
>= _mesa_max_tex_unit(ctx
))
2611 samp
= ctx
->Texture
.Unit
[index
].Sampler
;
2612 v
->value_int
= samp
? samp
->Name
: 0;
2616 case GL_MAX_COMPUTE_WORK_GROUP_COUNT
:
2617 if (!_mesa_has_compute_shaders(ctx
))
2621 v
->value_int
= ctx
->Const
.MaxComputeWorkGroupCount
[index
];
2624 case GL_MAX_COMPUTE_WORK_GROUP_SIZE
:
2625 if (!_mesa_has_compute_shaders(ctx
))
2629 v
->value_int
= ctx
->Const
.MaxComputeWorkGroupSize
[index
];
2632 /* ARB_compute_variable_group_size */
2633 case GL_MAX_COMPUTE_VARIABLE_GROUP_SIZE_ARB
:
2634 if (!ctx
->Extensions
.ARB_compute_variable_group_size
)
2638 v
->value_int
= ctx
->Const
.MaxComputeVariableGroupSize
[index
];
2641 /* GL_EXT_external_objects */
2642 case GL_NUM_DEVICE_UUIDS_EXT
:
2645 case GL_DRIVER_UUID_EXT
:
2648 _mesa_get_driver_uuid(ctx
, v
->value_int_4
);
2650 case GL_DEVICE_UUID_EXT
:
2653 _mesa_get_device_uuid(ctx
, v
->value_int_4
);
2658 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(pname=%s)", func
,
2659 _mesa_enum_to_string(pname
));
2660 return TYPE_INVALID
;
2662 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(pname=%s)", func
,
2663 _mesa_enum_to_string(pname
));
2664 return TYPE_INVALID
;
2668 _mesa_GetBooleani_v( GLenum pname
, GLuint index
, GLboolean
*params
)
2671 enum value_type type
=
2672 find_value_indexed("glGetBooleani_v", pname
, index
, &v
);
2677 params
[0] = INT_TO_BOOLEAN(v
.value_int
);
2681 params
[0] = INT_TO_BOOLEAN(v
.value_int_4
[0]);
2682 params
[1] = INT_TO_BOOLEAN(v
.value_int_4
[1]);
2683 params
[2] = INT_TO_BOOLEAN(v
.value_int_4
[2]);
2684 params
[3] = INT_TO_BOOLEAN(v
.value_int_4
[3]);
2687 params
[0] = INT64_TO_BOOLEAN(v
.value_int64
);
2690 ; /* nothing - GL error was recorded */
2695 _mesa_GetIntegeri_v( GLenum pname
, GLuint index
, GLint
*params
)
2698 enum value_type type
=
2699 find_value_indexed("glGetIntegeri_v", pname
, index
, &v
);
2704 params
[3] = IROUND(v
.value_float_4
[3]);
2707 params
[2] = IROUND(v
.value_float_4
[2]);
2710 params
[1] = IROUND(v
.value_float_4
[1]);
2713 params
[0] = IROUND(v
.value_float_4
[0]);
2716 case TYPE_DOUBLEN_2
:
2717 params
[1] = IROUND(v
.value_double_2
[1]);
2719 params
[0] = IROUND(v
.value_double_2
[0]);
2724 params
[0] = v
.value_int
;
2728 params
[0] = v
.value_int_4
[0];
2729 params
[1] = v
.value_int_4
[1];
2730 params
[2] = v
.value_int_4
[2];
2731 params
[3] = v
.value_int_4
[3];
2734 params
[0] = INT64_TO_INT(v
.value_int64
);
2737 ; /* nothing - GL error was recorded */
2742 _mesa_GetInteger64i_v( GLenum pname
, GLuint index
, GLint64
*params
)
2745 enum value_type type
=
2746 find_value_indexed("glGetInteger64i_v", pname
, index
, &v
);
2750 params
[0] = v
.value_int
;
2753 params
[0] = v
.value_int_4
[0];
2754 params
[1] = v
.value_int_4
[1];
2755 params
[2] = v
.value_int_4
[2];
2756 params
[3] = v
.value_int_4
[3];
2759 params
[0] = (GLuint
) v
.value_int
;
2762 params
[0] = (GLuint
) v
.value_int_4
[0];
2763 params
[1] = (GLuint
) v
.value_int_4
[1];
2764 params
[2] = (GLuint
) v
.value_int_4
[2];
2765 params
[3] = (GLuint
) v
.value_int_4
[3];
2768 params
[0] = v
.value_int64
;
2771 ; /* nothing - GL error was recorded */
2776 _mesa_GetFloati_v(GLenum pname
, GLuint index
, GLfloat
*params
)
2781 enum value_type type
=
2782 find_value_indexed("glGetFloati_v", pname
, index
, &v
);
2787 params
[3] = v
.value_float_4
[3];
2790 params
[2] = v
.value_float_4
[2];
2793 params
[1] = v
.value_float_4
[1];
2796 params
[0] = v
.value_float_4
[0];
2799 case TYPE_DOUBLEN_2
:
2800 params
[1] = (GLfloat
) v
.value_double_2
[1];
2802 params
[0] = (GLfloat
) v
.value_double_2
[0];
2806 params
[3] = (GLfloat
) v
.value_int_4
[3];
2808 params
[2] = (GLfloat
) v
.value_int_4
[2];
2811 params
[1] = (GLfloat
) v
.value_int_4
[1];
2815 params
[0] = (GLfloat
) v
.value_int_4
[0];
2819 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
2820 params
[i
] = (GLfloat
) v
.value_int_n
.ints
[i
];
2824 params
[3] = (GLfloat
) ((GLuint
) v
.value_int_4
[3]);
2826 params
[2] = (GLfloat
) ((GLuint
) v
.value_int_4
[2]);
2828 params
[1] = (GLfloat
) ((GLuint
) v
.value_int_4
[1]);
2830 params
[0] = (GLfloat
) ((GLuint
) v
.value_int_4
[0]);
2834 params
[0] = (GLfloat
) v
.value_int64
;
2838 params
[0] = BOOLEAN_TO_FLOAT(v
.value_bool
);
2842 params
[0] = (GLfloat
) v
.value_ubyte
;
2846 params
[0] = (GLfloat
) v
.value_short
;
2850 m
= *(GLmatrix
**) &v
;
2851 for (i
= 0; i
< 16; i
++)
2852 params
[i
] = m
->m
[i
];
2856 m
= *(GLmatrix
**) &v
;
2857 for (i
= 0; i
< 16; i
++)
2858 params
[i
] = m
->m
[transpose
[i
]];
2867 _mesa_GetDoublei_v(GLenum pname
, GLuint index
, GLdouble
*params
)
2872 enum value_type type
=
2873 find_value_indexed("glGetDoublei_v", pname
, index
, &v
);
2878 params
[3] = (GLdouble
) v
.value_float_4
[3];
2881 params
[2] = (GLdouble
) v
.value_float_4
[2];
2884 params
[1] = (GLdouble
) v
.value_float_4
[1];
2887 params
[0] = (GLdouble
) v
.value_float_4
[0];
2890 case TYPE_DOUBLEN_2
:
2891 params
[1] = v
.value_double_2
[1];
2893 params
[0] = v
.value_double_2
[0];
2897 params
[3] = (GLdouble
) v
.value_int_4
[3];
2899 params
[2] = (GLdouble
) v
.value_int_4
[2];
2902 params
[1] = (GLdouble
) v
.value_int_4
[1];
2906 params
[0] = (GLdouble
) v
.value_int_4
[0];
2910 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
2911 params
[i
] = (GLdouble
) v
.value_int_n
.ints
[i
];
2915 params
[3] = (GLdouble
) ((GLuint
) v
.value_int_4
[3]);
2917 params
[2] = (GLdouble
) ((GLuint
) v
.value_int_4
[2]);
2919 params
[1] = (GLdouble
) ((GLuint
) v
.value_int_4
[1]);
2921 params
[0] = (GLdouble
) ((GLuint
) v
.value_int_4
[0]);
2925 params
[0] = (GLdouble
) v
.value_int64
;
2929 params
[0] = (GLdouble
) BOOLEAN_TO_FLOAT(v
.value_bool
);
2933 params
[0] = (GLdouble
) v
.value_ubyte
;
2937 params
[0] = (GLdouble
) v
.value_short
;
2941 m
= *(GLmatrix
**) &v
;
2942 for (i
= 0; i
< 16; i
++)
2943 params
[i
] = (GLdouble
) m
->m
[i
];
2947 m
= *(GLmatrix
**) &v
;
2948 for (i
= 0; i
< 16; i
++)
2949 params
[i
] = (GLdouble
) m
->m
[transpose
[i
]];
2958 _mesa_GetUnsignedBytei_vEXT(GLenum target
, GLuint index
, GLubyte
*data
)
2962 enum value_type type
;
2963 const char *func
= "glGetUnsignedBytei_vEXT";
2965 GET_CURRENT_CONTEXT(ctx
);
2967 if (!ctx
->Extensions
.EXT_memory_object
) {
2968 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(unsupported)", func
);
2972 type
= find_value_indexed(func
, target
, index
, &v
);
2973 size
= get_value_size(type
, &v
);
2975 _mesa_problem(ctx
, "invalid value type in GetUnsignedBytei_vEXT()");
3004 case TYPE_DOUBLEN_2
:
3007 memcpy(data
, &v
.value_int
, size
);
3010 memcpy(data
, &v
.value_int_n
.ints
, size
);
3013 break; /* nothing - GL error was recorded */
3018 _mesa_GetFixedv(GLenum pname
, GLfixed
*params
)
3020 const struct value_desc
*d
;
3026 d
= find_value("glGetDoublev", pname
, &p
, &v
);
3031 params
[0] = INT_TO_FIXED(d
->offset
);
3036 params
[3] = FLOAT_TO_FIXED(((GLfloat
*) p
)[3]);
3039 params
[2] = FLOAT_TO_FIXED(((GLfloat
*) p
)[2]);
3042 params
[1] = FLOAT_TO_FIXED(((GLfloat
*) p
)[1]);
3045 params
[0] = FLOAT_TO_FIXED(((GLfloat
*) p
)[0]);
3048 case TYPE_DOUBLEN_2
:
3049 params
[1] = FLOAT_TO_FIXED(((GLdouble
*) p
)[1]);
3051 params
[0] = FLOAT_TO_FIXED(((GLdouble
*) p
)[0]);
3056 params
[3] = INT_TO_FIXED(((GLint
*) p
)[3]);
3059 params
[2] = INT_TO_FIXED(((GLint
*) p
)[2]);
3063 params
[1] = INT_TO_FIXED(((GLint
*) p
)[1]);
3067 params
[0] = INT_TO_FIXED(((GLint
*) p
)[0]);
3071 params
[0] = INT_TO_FIXED(((GLenum16
*) p
)[0]);
3075 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
3076 params
[i
] = INT_TO_FIXED(v
.value_int_n
.ints
[i
]);
3080 params
[0] = ((GLint64
*) p
)[0];
3084 params
[0] = BOOLEAN_TO_FIXED(((GLboolean
*) p
)[0]);
3088 params
[0] = INT_TO_FIXED(((GLubyte
*) p
)[0]);
3092 params
[0] = INT_TO_FIXED(((GLshort
*) p
)[0]);
3096 m
= *(GLmatrix
**) p
;
3097 for (i
= 0; i
< 16; i
++)
3098 params
[i
] = FLOAT_TO_FIXED(m
->m
[i
]);
3102 m
= *(GLmatrix
**) p
;
3103 for (i
= 0; i
< 16; i
++)
3104 params
[i
] = FLOAT_TO_FIXED(m
->m
[transpose
[i
]]);
3115 shift
= d
->type
- TYPE_BIT_0
;
3116 params
[0] = BOOLEAN_TO_FIXED((*(GLbitfield
*) p
>> shift
) & 1);