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
{
154 EXTRA_NEW_FRAG_CLAMP
,
155 EXTRA_VALID_DRAW_BUFFER
,
156 EXTRA_VALID_TEXTURE_UNIT
,
157 EXTRA_VALID_CLIP_DISTANCE
,
161 EXTRA_EXT_ATOMICS_GS
,
162 EXTRA_EXT_SHADER_IMAGE_GS
,
163 EXTRA_EXT_ATOMICS_TESS
,
164 EXTRA_EXT_SHADER_IMAGE_TESS
,
166 EXTRA_EXT_FB_NO_ATTACH_GS
,
168 EXTRA_EXT_PROVOKING_VERTEX_32
,
171 #define NO_EXTRA NULL
176 GLubyte location
; /**< enum value_location */
177 GLubyte type
; /**< enum value_type */
184 GLfloat value_float_4
[4];
185 GLdouble value_double_2
[2];
186 GLmatrix
*value_matrix
;
188 GLint value_int_4
[4];
192 /* Sigh, see GL_COMPRESSED_TEXTURE_FORMATS_ARB handling */
196 GLboolean value_bool
;
199 #define BUFFER_FIELD(field, type) \
200 LOC_BUFFER, type, offsetof(struct gl_framebuffer, field)
201 #define CONTEXT_FIELD(field, type) \
202 LOC_CONTEXT, type, offsetof(struct gl_context, field)
203 #define ARRAY_FIELD(field, type) \
204 LOC_ARRAY, type, offsetof(struct gl_vertex_array_object, field)
205 #undef CONST /* already defined through windows.h */
206 #define CONST(value) \
207 LOC_CONTEXT, TYPE_CONST, value
209 #define BUFFER_INT(field) BUFFER_FIELD(field, TYPE_INT)
210 #define BUFFER_ENUM(field) BUFFER_FIELD(field, TYPE_ENUM)
211 #define BUFFER_ENUM16(field) BUFFER_FIELD(field, TYPE_ENUM16)
212 #define BUFFER_BOOL(field) BUFFER_FIELD(field, TYPE_BOOLEAN)
214 #define CONTEXT_INT(field) CONTEXT_FIELD(field, TYPE_INT)
215 #define CONTEXT_INT2(field) CONTEXT_FIELD(field, TYPE_INT_2)
216 #define CONTEXT_INT64(field) CONTEXT_FIELD(field, TYPE_INT64)
217 #define CONTEXT_UINT(field) CONTEXT_FIELD(field, TYPE_UINT)
218 #define CONTEXT_ENUM16(field) CONTEXT_FIELD(field, TYPE_ENUM16)
219 #define CONTEXT_ENUM(field) CONTEXT_FIELD(field, TYPE_ENUM)
220 #define CONTEXT_ENUM2(field) CONTEXT_FIELD(field, TYPE_ENUM_2)
221 #define CONTEXT_BOOL(field) CONTEXT_FIELD(field, TYPE_BOOLEAN)
222 #define CONTEXT_BIT0(field) CONTEXT_FIELD(field, TYPE_BIT_0)
223 #define CONTEXT_BIT1(field) CONTEXT_FIELD(field, TYPE_BIT_1)
224 #define CONTEXT_BIT2(field) CONTEXT_FIELD(field, TYPE_BIT_2)
225 #define CONTEXT_BIT3(field) CONTEXT_FIELD(field, TYPE_BIT_3)
226 #define CONTEXT_BIT4(field) CONTEXT_FIELD(field, TYPE_BIT_4)
227 #define CONTEXT_BIT5(field) CONTEXT_FIELD(field, TYPE_BIT_5)
228 #define CONTEXT_BIT6(field) CONTEXT_FIELD(field, TYPE_BIT_6)
229 #define CONTEXT_BIT7(field) CONTEXT_FIELD(field, TYPE_BIT_7)
230 #define CONTEXT_FLOAT(field) CONTEXT_FIELD(field, TYPE_FLOAT)
231 #define CONTEXT_FLOAT2(field) CONTEXT_FIELD(field, TYPE_FLOAT_2)
232 #define CONTEXT_FLOAT3(field) CONTEXT_FIELD(field, TYPE_FLOAT_3)
233 #define CONTEXT_FLOAT4(field) CONTEXT_FIELD(field, TYPE_FLOAT_4)
234 #define CONTEXT_FLOAT8(field) CONTEXT_FIELD(field, TYPE_FLOAT_8)
235 #define CONTEXT_MATRIX(field) CONTEXT_FIELD(field, TYPE_MATRIX)
236 #define CONTEXT_MATRIX_T(field) CONTEXT_FIELD(field, TYPE_MATRIX_T)
238 #define ARRAY_INT(field) ARRAY_FIELD(field, TYPE_INT)
239 #define ARRAY_ENUM(field) ARRAY_FIELD(field, TYPE_ENUM)
240 #define ARRAY_ENUM16(field) ARRAY_FIELD(field, TYPE_ENUM16)
241 #define ARRAY_BOOL(field) ARRAY_FIELD(field, TYPE_BOOLEAN)
244 offsetof(struct gl_extensions, f)
246 #define EXTRA_EXT(e) \
247 static const int extra_##e[] = { \
251 #define EXTRA_EXT2(e1, e2) \
252 static const int extra_##e1##_##e2[] = { \
253 EXT(e1), EXT(e2), EXTRA_END \
256 /* The 'extra' mechanism is a way to specify extra checks (such as
257 * extensions or specific gl versions) or actions (flush current, new
258 * buffers) that we need to do before looking up an enum. We need to
259 * declare them all up front so we can refer to them in the value_desc
262 * Each EXTRA_ will be executed. For EXTRA_* enums of extensions and API
263 * versions, listing multiple ones in an array means an error will be thrown
264 * only if none of them are available. If you need to check for "AND"
265 * behavior, you would need to make a custom EXTRA_ enum.
268 static const int extra_new_buffers
[] = {
273 static const int extra_new_frag_clamp
[] = {
274 EXTRA_NEW_FRAG_CLAMP
,
278 static const int extra_valid_draw_buffer
[] = {
279 EXTRA_VALID_DRAW_BUFFER
,
283 static const int extra_valid_texture_unit
[] = {
284 EXTRA_VALID_TEXTURE_UNIT
,
288 static const int extra_valid_clip_distance
[] = {
289 EXTRA_VALID_CLIP_DISTANCE
,
293 static const int extra_flush_current_valid_texture_unit
[] = {
295 EXTRA_VALID_TEXTURE_UNIT
,
299 static const int extra_flush_current
[] = {
304 static const int extra_EXT_texture_integer_and_new_buffers
[] = {
305 EXT(EXT_texture_integer
),
310 static const int extra_GLSL_130_es3
[] = {
316 static const int extra_texture_buffer_object
[] = {
317 EXT(ARB_texture_buffer_object
),
321 static const int extra_ARB_transform_feedback2_api_es3
[] = {
322 EXT(ARB_transform_feedback2
),
327 static const int extra_ARB_uniform_buffer_object_and_geometry_shader
[] = {
332 static const int extra_ARB_ES2_compatibility_api_es2
[] = {
333 EXT(ARB_ES2_compatibility
),
338 static const int extra_ARB_ES3_compatibility_api_es3
[] = {
339 EXT(ARB_ES3_compatibility
),
344 static const int extra_EXT_framebuffer_sRGB_and_new_buffers
[] = {
345 EXT(EXT_framebuffer_sRGB
),
350 static const int extra_EXT_packed_float
[] = {
351 EXT(EXT_packed_float
),
356 static const int extra_EXT_texture_array_es3
[] = {
357 EXT(EXT_texture_array
),
362 static const int extra_ARB_shader_atomic_counters_and_geometry_shader
[] = {
363 EXTRA_EXT_ATOMICS_GS
,
367 static const int extra_ARB_shader_image_load_store_and_geometry_shader
[] = {
368 EXTRA_EXT_SHADER_IMAGE_GS
,
372 static const int extra_ARB_shader_atomic_counters_and_tessellation
[] = {
373 EXTRA_EXT_ATOMICS_TESS
,
377 static const int extra_ARB_shader_image_load_store_and_tessellation
[] = {
378 EXTRA_EXT_SHADER_IMAGE_TESS
,
382 /* HACK: remove when ARB_compute_shader is actually supported */
383 static const int extra_ARB_compute_shader_es31
[] = {
384 EXT(ARB_compute_shader
),
389 static const int extra_ARB_shader_storage_buffer_object_es31
[] = {
390 EXT(ARB_shader_storage_buffer_object
),
395 static const int extra_ARB_shader_storage_buffer_object_and_geometry_shader
[] = {
400 static const int extra_ARB_shader_image_load_store_shader_storage_buffer_object_es31
[] = {
401 EXT(ARB_shader_image_load_store
),
402 EXT(ARB_shader_storage_buffer_object
),
407 static const int extra_ARB_framebuffer_no_attachments_and_geometry_shader
[] = {
408 EXTRA_EXT_FB_NO_ATTACH_GS
,
412 static const int extra_ARB_viewport_array_or_oes_geometry_shader
[] = {
413 EXT(ARB_viewport_array
),
418 static const int extra_ARB_viewport_array_or_oes_viewport_array
[] = {
419 EXT(ARB_viewport_array
),
420 EXT(OES_viewport_array
),
424 static const int extra_ARB_gpu_shader5_or_oes_geometry_shader
[] = {
425 EXT(ARB_gpu_shader5
),
430 static const int extra_ARB_gpu_shader5_or_OES_sample_variables
[] = {
431 EXT(ARB_gpu_shader5
),
432 EXT(OES_sample_variables
),
436 static const int extra_ES32
[] = {
437 EXT(ARB_ES3_2_compatibility
),
442 static const int extra_KHR_robustness_or_GL
[] = {
449 static const int extra_INTEL_conservative_rasterization
[] = {
450 EXT(INTEL_conservative_rasterization
),
454 EXTRA_EXT(ARB_texture_cube_map
);
455 EXTRA_EXT(EXT_texture_array
);
456 EXTRA_EXT(NV_fog_distance
);
457 EXTRA_EXT(EXT_texture_filter_anisotropic
);
458 EXTRA_EXT(NV_point_sprite
);
459 EXTRA_EXT(NV_texture_rectangle
);
460 EXTRA_EXT(EXT_stencil_two_side
);
461 EXTRA_EXT(EXT_depth_bounds_test
);
462 EXTRA_EXT(ARB_depth_clamp
);
463 EXTRA_EXT(ATI_fragment_shader
);
464 EXTRA_EXT(EXT_provoking_vertex
);
465 EXTRA_EXT(ARB_fragment_shader
);
466 EXTRA_EXT(ARB_fragment_program
);
467 EXTRA_EXT2(ARB_framebuffer_object
, EXT_framebuffer_multisample
);
468 EXTRA_EXT(ARB_seamless_cube_map
);
470 EXTRA_EXT(ARB_vertex_shader
);
471 EXTRA_EXT(EXT_transform_feedback
);
472 EXTRA_EXT(ARB_transform_feedback3
);
473 EXTRA_EXT(EXT_pixel_buffer_object
);
474 EXTRA_EXT(ARB_vertex_program
);
475 EXTRA_EXT2(NV_point_sprite
, ARB_point_sprite
);
476 EXTRA_EXT2(ARB_vertex_program
, ARB_fragment_program
);
477 EXTRA_EXT(ARB_color_buffer_float
);
478 EXTRA_EXT(EXT_framebuffer_sRGB
);
479 EXTRA_EXT(OES_EGL_image_external
);
480 EXTRA_EXT(ARB_blend_func_extended
);
481 EXTRA_EXT(ARB_uniform_buffer_object
);
482 EXTRA_EXT(ARB_timer_query
);
483 EXTRA_EXT2(ARB_texture_cube_map_array
, OES_texture_cube_map_array
);
484 EXTRA_EXT(ARB_texture_buffer_range
);
485 EXTRA_EXT(ARB_texture_multisample
);
486 EXTRA_EXT(ARB_texture_gather
);
487 EXTRA_EXT(ARB_shader_atomic_counters
);
488 EXTRA_EXT(ARB_draw_indirect
);
489 EXTRA_EXT(ARB_shader_image_load_store
);
490 EXTRA_EXT(ARB_query_buffer_object
);
491 EXTRA_EXT2(ARB_transform_feedback3
, ARB_gpu_shader5
);
492 EXTRA_EXT(INTEL_performance_query
);
493 EXTRA_EXT(ARB_explicit_uniform_location
);
494 EXTRA_EXT(ARB_clip_control
);
495 EXTRA_EXT(ARB_polygon_offset_clamp
);
496 EXTRA_EXT(ARB_framebuffer_no_attachments
);
497 EXTRA_EXT(ARB_tessellation_shader
);
498 EXTRA_EXT(ARB_shader_storage_buffer_object
);
499 EXTRA_EXT(ARB_indirect_parameters
);
500 EXTRA_EXT(ATI_meminfo
);
501 EXTRA_EXT(NVX_gpu_memory_info
);
502 EXTRA_EXT(ARB_cull_distance
);
503 EXTRA_EXT(EXT_window_rectangles
);
504 EXTRA_EXT(KHR_blend_equation_advanced_coherent
);
505 EXTRA_EXT(OES_primitive_bounding_box
);
506 EXTRA_EXT(ARB_compute_variable_group_size
);
507 EXTRA_EXT(KHR_robustness
);
508 EXTRA_EXT(ARB_sparse_buffer
);
511 extra_ARB_color_buffer_float_or_glcore
[] = {
512 EXT(ARB_color_buffer_float
),
518 extra_NV_primitive_restart
[] = {
519 EXT(NV_primitive_restart
),
523 static const int extra_version_30
[] = { EXTRA_VERSION_30
, EXTRA_END
};
524 static const int extra_version_31
[] = { EXTRA_VERSION_31
, EXTRA_END
};
525 static const int extra_version_32
[] = { EXTRA_VERSION_32
, EXTRA_END
};
526 static const int extra_version_43
[] = { EXTRA_VERSION_43
, EXTRA_END
};
528 static const int extra_gl30_es3
[] = {
534 static const int extra_gl32_es3
[] = {
540 static const int extra_version_32_OES_geometry_shader
[] = {
546 static const int extra_gl40_ARB_sample_shading
[] = {
548 EXT(ARB_sample_shading
),
553 extra_ARB_vertex_program_api_es2
[] = {
554 EXT(ARB_vertex_program
),
559 /* The ReadBuffer get token is valid under either full GL or under
560 * GLES2 if the NV_read_buffer extension is available. */
562 extra_NV_read_buffer_api_gl
[] = {
568 static const int extra_core_ARB_color_buffer_float_and_new_buffers
[] = {
570 EXT(ARB_color_buffer_float
),
575 static const int extra_EXT_shader_framebuffer_fetch
[] = {
578 EXT(MESA_shader_framebuffer_fetch
),
582 static const int extra_EXT_provoking_vertex_32
[] = {
583 EXTRA_EXT_PROVOKING_VERTEX_32
,
587 static const int extra_EXT_disjoint_timer_query
[] = {
590 EXT(EXT_disjoint_timer_query
),
595 /* This is the big table describing all the enums we accept in
596 * glGet*v(). The table is partitioned into six parts: enums
597 * understood by all GL APIs (OpenGL, GLES and GLES2), enums shared
598 * between OpenGL and GLES, enums exclusive to GLES, etc for the
599 * remaining combinations. To look up the enums valid in a given API
600 * we will use a hash table specific to that API. These tables are in
601 * turn generated at build time and included through get_hash.h.
604 #include "get_hash.h"
606 /* All we need now is a way to look up the value struct from the enum.
607 * The code generated by gcc for the old generated big switch
608 * statement is a big, balanced, open coded if/else tree, essentially
609 * an unrolled binary search. It would be natural to sort the new
610 * enum table and use bsearch(), but we will use a read-only hash
611 * table instead. bsearch() has a nice guaranteed worst case
612 * performance, but we're also guaranteed to hit that worst case
613 * (log2(n) iterations) for about half the enums. Instead, using an
614 * open addressing hash table, we can find the enum on the first try
615 * for 80% of the enums, 1 collision for 10% and never more than 5
616 * collisions for any enum (typical numbers). And the code is very
617 * simple, even though it feels a little magic. */
620 * Handle irregular enums
622 * Some values don't conform to the "well-known type at context
623 * pointer + offset" pattern, so we have this function to catch all
624 * the corner cases. Typically, it's a computed value or a one-off
625 * pointer to a custom struct or something.
627 * In this case we can't return a pointer to the value, so we'll have
628 * to use the temporary variable 'v' declared back in the calling
629 * glGet*v() function to store the result.
631 * \param ctx the current context
632 * \param d the struct value_desc that describes the enum
633 * \param v pointer to the tmp declared in the calling glGet*v() function
636 find_custom_value(struct gl_context
*ctx
, const struct value_desc
*d
, union value
*v
)
638 struct gl_buffer_object
**buffer_obj
;
639 struct gl_array_attributes
*array
;
643 case GL_MAJOR_VERSION
:
644 v
->value_int
= ctx
->Version
/ 10;
646 case GL_MINOR_VERSION
:
647 v
->value_int
= ctx
->Version
% 10;
653 case GL_TEXTURE_CUBE_MAP
:
654 case GL_TEXTURE_RECTANGLE_NV
:
655 case GL_TEXTURE_EXTERNAL_OES
:
656 v
->value_bool
= _mesa_IsEnabled(d
->pname
);
659 case GL_LINE_STIPPLE_PATTERN
:
660 /* This is the only GLushort, special case it here by promoting
661 * to an int rather than introducing a new type. */
662 v
->value_int
= ctx
->Line
.StipplePattern
;
665 case GL_CURRENT_RASTER_TEXTURE_COORDS
:
666 unit
= ctx
->Texture
.CurrentUnit
;
667 v
->value_float_4
[0] = ctx
->Current
.RasterTexCoords
[unit
][0];
668 v
->value_float_4
[1] = ctx
->Current
.RasterTexCoords
[unit
][1];
669 v
->value_float_4
[2] = ctx
->Current
.RasterTexCoords
[unit
][2];
670 v
->value_float_4
[3] = ctx
->Current
.RasterTexCoords
[unit
][3];
673 case GL_CURRENT_TEXTURE_COORDS
:
674 unit
= ctx
->Texture
.CurrentUnit
;
675 v
->value_float_4
[0] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
][0];
676 v
->value_float_4
[1] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
][1];
677 v
->value_float_4
[2] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
][2];
678 v
->value_float_4
[3] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
][3];
681 case GL_COLOR_WRITEMASK
:
682 v
->value_int_4
[0] = GET_COLORMASK_BIT(ctx
->Color
.ColorMask
, 0, 0);
683 v
->value_int_4
[1] = GET_COLORMASK_BIT(ctx
->Color
.ColorMask
, 0, 1);
684 v
->value_int_4
[2] = GET_COLORMASK_BIT(ctx
->Color
.ColorMask
, 0, 2);
685 v
->value_int_4
[3] = GET_COLORMASK_BIT(ctx
->Color
.ColorMask
, 0, 3);
689 v
->value_bool
= ctx
->Current
.Attrib
[VERT_ATTRIB_EDGEFLAG
][0] == 1.0F
;
693 v
->value_enum
= ctx
->ReadBuffer
->ColorReadBuffer
;
696 case GL_MAP2_GRID_DOMAIN
:
697 v
->value_float_4
[0] = ctx
->Eval
.MapGrid2u1
;
698 v
->value_float_4
[1] = ctx
->Eval
.MapGrid2u2
;
699 v
->value_float_4
[2] = ctx
->Eval
.MapGrid2v1
;
700 v
->value_float_4
[3] = ctx
->Eval
.MapGrid2v2
;
703 case GL_TEXTURE_STACK_DEPTH
:
704 unit
= ctx
->Texture
.CurrentUnit
;
705 v
->value_int
= ctx
->TextureMatrixStack
[unit
].Depth
+ 1;
707 case GL_TEXTURE_MATRIX
:
708 unit
= ctx
->Texture
.CurrentUnit
;
709 v
->value_matrix
= ctx
->TextureMatrixStack
[unit
].Top
;
712 case GL_TEXTURE_COORD_ARRAY
:
713 case GL_TEXTURE_COORD_ARRAY_SIZE
:
714 case GL_TEXTURE_COORD_ARRAY_TYPE
:
715 case GL_TEXTURE_COORD_ARRAY_STRIDE
:
716 array
= &ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_TEX(ctx
->Array
.ActiveTexture
)];
717 v
->value_int
= *(GLuint
*) ((char *) array
+ d
->offset
);
720 case GL_ACTIVE_TEXTURE_ARB
:
721 v
->value_int
= GL_TEXTURE0_ARB
+ ctx
->Texture
.CurrentUnit
;
723 case GL_CLIENT_ACTIVE_TEXTURE_ARB
:
724 v
->value_int
= GL_TEXTURE0_ARB
+ ctx
->Array
.ActiveTexture
;
727 case GL_MODELVIEW_STACK_DEPTH
:
728 case GL_PROJECTION_STACK_DEPTH
:
729 v
->value_int
= *(GLint
*) ((char *) ctx
+ d
->offset
) + 1;
732 case GL_MAX_TEXTURE_SIZE
:
733 case GL_MAX_3D_TEXTURE_SIZE
:
734 case GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB
:
735 p
= (GLuint
*) ((char *) ctx
+ d
->offset
);
736 v
->value_int
= 1 << (*p
- 1);
740 v
->value_int_4
[0] = ctx
->Scissor
.ScissorArray
[0].X
;
741 v
->value_int_4
[1] = ctx
->Scissor
.ScissorArray
[0].Y
;
742 v
->value_int_4
[2] = ctx
->Scissor
.ScissorArray
[0].Width
;
743 v
->value_int_4
[3] = ctx
->Scissor
.ScissorArray
[0].Height
;
746 case GL_SCISSOR_TEST
:
747 v
->value_bool
= ctx
->Scissor
.EnableFlags
& 1;
752 ctx
->ListState
.CurrentList
? ctx
->ListState
.CurrentList
->Name
: 0;
755 if (!ctx
->CompileFlag
)
757 else if (ctx
->ExecuteFlag
)
758 v
->value_enum
= GL_COMPILE_AND_EXECUTE
;
760 v
->value_enum
= GL_COMPILE
;
764 v
->value_float_4
[0] = ctx
->ViewportArray
[0].X
;
765 v
->value_float_4
[1] = ctx
->ViewportArray
[0].Y
;
766 v
->value_float_4
[2] = ctx
->ViewportArray
[0].Width
;
767 v
->value_float_4
[3] = ctx
->ViewportArray
[0].Height
;
771 v
->value_double_2
[0] = ctx
->ViewportArray
[0].Near
;
772 v
->value_double_2
[1] = ctx
->ViewportArray
[0].Far
;
775 case GL_ACTIVE_STENCIL_FACE_EXT
:
776 v
->value_enum
= ctx
->Stencil
.ActiveFace
? GL_BACK
: GL_FRONT
;
779 case GL_STENCIL_FAIL
:
780 v
->value_enum
= ctx
->Stencil
.FailFunc
[ctx
->Stencil
.ActiveFace
];
782 case GL_STENCIL_FUNC
:
783 v
->value_enum
= ctx
->Stencil
.Function
[ctx
->Stencil
.ActiveFace
];
785 case GL_STENCIL_PASS_DEPTH_FAIL
:
786 v
->value_enum
= ctx
->Stencil
.ZFailFunc
[ctx
->Stencil
.ActiveFace
];
788 case GL_STENCIL_PASS_DEPTH_PASS
:
789 v
->value_enum
= ctx
->Stencil
.ZPassFunc
[ctx
->Stencil
.ActiveFace
];
792 v
->value_int
= _mesa_get_stencil_ref(ctx
, ctx
->Stencil
.ActiveFace
);
794 case GL_STENCIL_BACK_REF
:
795 v
->value_int
= _mesa_get_stencil_ref(ctx
, 1);
797 case GL_STENCIL_VALUE_MASK
:
798 v
->value_int
= ctx
->Stencil
.ValueMask
[ctx
->Stencil
.ActiveFace
];
800 case GL_STENCIL_WRITEMASK
:
801 v
->value_int
= ctx
->Stencil
.WriteMask
[ctx
->Stencil
.ActiveFace
];
804 case GL_NUM_EXTENSIONS
:
805 v
->value_int
= _mesa_get_extension_count(ctx
);
808 case GL_IMPLEMENTATION_COLOR_READ_TYPE_OES
:
809 v
->value_int
= _mesa_get_color_read_type(ctx
, NULL
, "glGetIntegerv");
811 case GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES
:
812 v
->value_int
= _mesa_get_color_read_format(ctx
, NULL
, "glGetIntegerv");
815 case GL_CURRENT_MATRIX_STACK_DEPTH_ARB
:
816 v
->value_int
= ctx
->CurrentStack
->Depth
+ 1;
818 case GL_CURRENT_MATRIX_ARB
:
819 case GL_TRANSPOSE_CURRENT_MATRIX_ARB
:
820 v
->value_matrix
= ctx
->CurrentStack
->Top
;
823 case GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB
:
824 v
->value_int
= _mesa_get_compressed_formats(ctx
, NULL
);
826 case GL_COMPRESSED_TEXTURE_FORMATS_ARB
:
828 _mesa_get_compressed_formats(ctx
, v
->value_int_n
.ints
);
829 assert(v
->value_int_n
.n
<= (int) ARRAY_SIZE(v
->value_int_n
.ints
));
832 case GL_MAX_VARYING_FLOATS_ARB
:
833 v
->value_int
= ctx
->Const
.MaxVarying
* 4;
836 /* Various object names */
838 case GL_TEXTURE_BINDING_1D
:
839 case GL_TEXTURE_BINDING_2D
:
840 case GL_TEXTURE_BINDING_3D
:
841 case GL_TEXTURE_BINDING_1D_ARRAY_EXT
:
842 case GL_TEXTURE_BINDING_2D_ARRAY_EXT
:
843 case GL_TEXTURE_BINDING_CUBE_MAP_ARB
:
844 case GL_TEXTURE_BINDING_RECTANGLE_NV
:
845 case GL_TEXTURE_BINDING_EXTERNAL_OES
:
846 case GL_TEXTURE_BINDING_CUBE_MAP_ARRAY
:
847 case GL_TEXTURE_BINDING_2D_MULTISAMPLE
:
848 case GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY
:
849 unit
= ctx
->Texture
.CurrentUnit
;
851 ctx
->Texture
.Unit
[unit
].CurrentTex
[d
->offset
]->Name
;
854 /* GL_EXT_external_objects */
855 case GL_DRIVER_UUID_EXT
:
856 _mesa_get_driver_uuid(ctx
, v
->value_int_4
);
858 case GL_DEVICE_UUID_EXT
:
859 _mesa_get_device_uuid(ctx
, v
->value_int_4
);
862 /* GL_EXT_packed_float */
863 case GL_RGBA_SIGNED_COMPONENTS_EXT
:
865 /* Note: we only check the 0th color attachment. */
866 const struct gl_renderbuffer
*rb
=
867 ctx
->DrawBuffer
->_ColorDrawBuffers
[0];
868 if (rb
&& _mesa_is_format_signed(rb
->Format
)) {
869 /* Issue 17 of GL_EXT_packed_float: If a component (such as
870 * alpha) has zero bits, the component should not be considered
871 * signed and so the bit for the respective component should be
875 _mesa_get_format_bits(rb
->Format
, GL_RED_BITS
);
877 _mesa_get_format_bits(rb
->Format
, GL_GREEN_BITS
);
879 _mesa_get_format_bits(rb
->Format
, GL_BLUE_BITS
);
881 _mesa_get_format_bits(rb
->Format
, GL_ALPHA_BITS
);
883 _mesa_get_format_bits(rb
->Format
, GL_TEXTURE_LUMINANCE_SIZE
);
885 _mesa_get_format_bits(rb
->Format
, GL_TEXTURE_INTENSITY_SIZE
);
887 v
->value_int_4
[0] = r_bits
+ l_bits
+ i_bits
> 0;
888 v
->value_int_4
[1] = g_bits
+ l_bits
+ i_bits
> 0;
889 v
->value_int_4
[2] = b_bits
+ l_bits
+ i_bits
> 0;
890 v
->value_int_4
[3] = a_bits
+ i_bits
> 0;
896 v
->value_int_4
[3] = 0;
901 /* GL_ARB_vertex_buffer_object */
902 case GL_VERTEX_ARRAY_BUFFER_BINDING_ARB
:
903 case GL_NORMAL_ARRAY_BUFFER_BINDING_ARB
:
904 case GL_COLOR_ARRAY_BUFFER_BINDING_ARB
:
905 case GL_INDEX_ARRAY_BUFFER_BINDING_ARB
:
906 case GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB
:
907 case GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB
:
908 case GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB
:
909 buffer_obj
= (struct gl_buffer_object
**)
910 ((char *) ctx
->Array
.VAO
+ d
->offset
);
911 v
->value_int
= (*buffer_obj
)->Name
;
913 case GL_ARRAY_BUFFER_BINDING_ARB
:
914 v
->value_int
= ctx
->Array
.ArrayBufferObj
->Name
;
916 case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB
:
918 ctx
->Array
.VAO
->BufferBinding
[VERT_ATTRIB_TEX(ctx
->Array
.ActiveTexture
)].BufferObj
->Name
;
920 case GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB
:
921 v
->value_int
= ctx
->Array
.VAO
->IndexBufferObj
->Name
;
924 /* ARB_vertex_array_bgra */
925 case GL_COLOR_ARRAY_SIZE
:
926 array
= &ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_COLOR0
];
927 v
->value_int
= array
->Format
== GL_BGRA
? GL_BGRA
: array
->Size
;
929 case GL_SECONDARY_COLOR_ARRAY_SIZE
:
930 array
= &ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_COLOR1
];
931 v
->value_int
= array
->Format
== GL_BGRA
? GL_BGRA
: array
->Size
;
934 /* ARB_copy_buffer */
935 case GL_COPY_READ_BUFFER
:
936 v
->value_int
= ctx
->CopyReadBuffer
->Name
;
938 case GL_COPY_WRITE_BUFFER
:
939 v
->value_int
= ctx
->CopyWriteBuffer
->Name
;
942 case GL_PIXEL_PACK_BUFFER_BINDING_EXT
:
943 v
->value_int
= ctx
->Pack
.BufferObj
->Name
;
945 case GL_PIXEL_UNPACK_BUFFER_BINDING_EXT
:
946 v
->value_int
= ctx
->Unpack
.BufferObj
->Name
;
948 case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING
:
949 v
->value_int
= ctx
->TransformFeedback
.CurrentBuffer
->Name
;
951 case GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED
:
952 v
->value_int
= ctx
->TransformFeedback
.CurrentObject
->Paused
;
954 case GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE
:
955 v
->value_int
= ctx
->TransformFeedback
.CurrentObject
->Active
;
957 case GL_TRANSFORM_FEEDBACK_BINDING
:
958 v
->value_int
= ctx
->TransformFeedback
.CurrentObject
->Name
;
960 case GL_CURRENT_PROGRAM
:
961 /* The Changelog of the ARB_separate_shader_objects spec says:
963 * 24 25 Jul 2011 pbrown Remove the language erroneously deleting
964 * CURRENT_PROGRAM. In the EXT extension, this
965 * token was aliased to ACTIVE_PROGRAM_EXT, and
966 * was used to indicate the last program set by
967 * either ActiveProgramEXT or UseProgram. In
968 * the ARB extension, the SSO active programs
969 * are now program pipeline object state and
970 * CURRENT_PROGRAM should still be used to query
971 * the last program set by UseProgram (bug 7822).
974 ctx
->Shader
.ActiveProgram
? ctx
->Shader
.ActiveProgram
->Name
: 0;
976 case GL_READ_FRAMEBUFFER_BINDING_EXT
:
977 v
->value_int
= ctx
->ReadBuffer
->Name
;
979 case GL_RENDERBUFFER_BINDING_EXT
:
981 ctx
->CurrentRenderbuffer
? ctx
->CurrentRenderbuffer
->Name
: 0;
983 case GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES
:
984 v
->value_int
= ctx
->Array
.VAO
->BufferBinding
[VERT_ATTRIB_POINT_SIZE
].BufferObj
->Name
;
988 if (_mesa_get_clamp_fragment_color(ctx
, ctx
->DrawBuffer
))
989 COPY_4FV(v
->value_float_4
, ctx
->Fog
.Color
);
991 COPY_4FV(v
->value_float_4
, ctx
->Fog
.ColorUnclamped
);
993 case GL_COLOR_CLEAR_VALUE
:
994 if (_mesa_get_clamp_fragment_color(ctx
, ctx
->DrawBuffer
)) {
995 v
->value_float_4
[0] = CLAMP(ctx
->Color
.ClearColor
.f
[0], 0.0F
, 1.0F
);
996 v
->value_float_4
[1] = CLAMP(ctx
->Color
.ClearColor
.f
[1], 0.0F
, 1.0F
);
997 v
->value_float_4
[2] = CLAMP(ctx
->Color
.ClearColor
.f
[2], 0.0F
, 1.0F
);
998 v
->value_float_4
[3] = CLAMP(ctx
->Color
.ClearColor
.f
[3], 0.0F
, 1.0F
);
1000 COPY_4FV(v
->value_float_4
, ctx
->Color
.ClearColor
.f
);
1002 case GL_BLEND_COLOR_EXT
:
1003 if (_mesa_get_clamp_fragment_color(ctx
, ctx
->DrawBuffer
))
1004 COPY_4FV(v
->value_float_4
, ctx
->Color
.BlendColor
);
1006 COPY_4FV(v
->value_float_4
, ctx
->Color
.BlendColorUnclamped
);
1008 case GL_ALPHA_TEST_REF
:
1009 if (_mesa_get_clamp_fragment_color(ctx
, ctx
->DrawBuffer
))
1010 v
->value_float
= ctx
->Color
.AlphaRef
;
1012 v
->value_float
= ctx
->Color
.AlphaRefUnclamped
;
1014 case GL_MAX_VERTEX_UNIFORM_VECTORS
:
1015 v
->value_int
= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxUniformComponents
/ 4;
1018 case GL_MAX_FRAGMENT_UNIFORM_VECTORS
:
1019 v
->value_int
= ctx
->Const
.Program
[MESA_SHADER_FRAGMENT
].MaxUniformComponents
/ 4;
1022 /* GL_ARB_texture_buffer_object */
1023 case GL_TEXTURE_BUFFER_ARB
:
1024 v
->value_int
= ctx
->Texture
.BufferObject
->Name
;
1026 case GL_TEXTURE_BINDING_BUFFER_ARB
:
1027 unit
= ctx
->Texture
.CurrentUnit
;
1029 ctx
->Texture
.Unit
[unit
].CurrentTex
[TEXTURE_BUFFER_INDEX
]->Name
;
1031 case GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB
:
1033 struct gl_buffer_object
*buf
=
1034 ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
]
1035 .CurrentTex
[TEXTURE_BUFFER_INDEX
]->BufferObject
;
1036 v
->value_int
= buf
? buf
->Name
: 0;
1039 case GL_TEXTURE_BUFFER_FORMAT_ARB
:
1040 v
->value_int
= ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
]
1041 .CurrentTex
[TEXTURE_BUFFER_INDEX
]->BufferObjectFormat
;
1044 /* GL_ARB_sampler_objects */
1045 case GL_SAMPLER_BINDING
:
1047 struct gl_sampler_object
*samp
=
1048 ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
].Sampler
;
1049 v
->value_int
= samp
? samp
->Name
: 0;
1052 /* GL_ARB_uniform_buffer_object */
1053 case GL_UNIFORM_BUFFER_BINDING
:
1054 v
->value_int
= ctx
->UniformBuffer
->Name
;
1056 /* GL_ARB_shader_storage_buffer_object */
1057 case GL_SHADER_STORAGE_BUFFER_BINDING
:
1058 v
->value_int
= ctx
->ShaderStorageBuffer
->Name
;
1060 /* GL_ARB_query_buffer_object */
1061 case GL_QUERY_BUFFER_BINDING
:
1062 v
->value_int
= ctx
->QueryBuffer
->Name
;
1064 /* GL_ARB_timer_query */
1066 if (ctx
->Driver
.GetTimestamp
) {
1067 v
->value_int64
= ctx
->Driver
.GetTimestamp(ctx
);
1070 _mesa_problem(ctx
, "driver doesn't implement GetTimestamp");
1074 case GL_DEBUG_OUTPUT
:
1075 case GL_DEBUG_OUTPUT_SYNCHRONOUS
:
1076 case GL_DEBUG_LOGGED_MESSAGES
:
1077 case GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH
:
1078 case GL_DEBUG_GROUP_STACK_DEPTH
:
1079 v
->value_int
= _mesa_get_debug_state_int(ctx
, d
->pname
);
1081 /* GL_ARB_shader_atomic_counters */
1082 case GL_ATOMIC_COUNTER_BUFFER_BINDING
:
1083 if (ctx
->AtomicBuffer
) {
1084 v
->value_int
= ctx
->AtomicBuffer
->Name
;
1090 case GL_NUM_SHADING_LANGUAGE_VERSIONS
:
1091 v
->value_int
= _mesa_get_shading_language_version(ctx
, -1, NULL
);
1093 /* GL_ARB_draw_indirect */
1094 case GL_DRAW_INDIRECT_BUFFER_BINDING
:
1095 v
->value_int
= ctx
->DrawIndirectBuffer
->Name
;
1097 /* GL_ARB_indirect_parameters */
1098 case GL_PARAMETER_BUFFER_BINDING_ARB
:
1099 v
->value_int
= ctx
->ParameterBuffer
->Name
;
1101 /* GL_ARB_separate_shader_objects */
1102 case GL_PROGRAM_PIPELINE_BINDING
:
1103 if (ctx
->Pipeline
.Current
) {
1104 v
->value_int
= ctx
->Pipeline
.Current
->Name
;
1109 /* GL_ARB_compute_shader */
1110 case GL_DISPATCH_INDIRECT_BUFFER_BINDING
:
1111 v
->value_int
= ctx
->DispatchIndirectBuffer
->Name
;
1113 /* GL_ARB_multisample */
1115 v
->value_int
= _mesa_geometric_samples(ctx
->DrawBuffer
);
1117 case GL_SAMPLE_BUFFERS
:
1118 v
->value_int
= _mesa_geometric_samples(ctx
->DrawBuffer
) > 0;
1120 /* GL_EXT_textrue_integer */
1121 case GL_RGBA_INTEGER_MODE_EXT
:
1122 v
->value_int
= (ctx
->DrawBuffer
->_IntegerBuffers
!= 0);
1124 /* GL_ATI_meminfo & GL_NVX_gpu_memory_info */
1125 case GL_VBO_FREE_MEMORY_ATI
:
1126 case GL_TEXTURE_FREE_MEMORY_ATI
:
1127 case GL_RENDERBUFFER_FREE_MEMORY_ATI
:
1128 case GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX
:
1129 case GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX
:
1130 case GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX
:
1131 case GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX
:
1132 case GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX
:
1134 struct gl_memory_info info
;
1136 ctx
->Driver
.QueryMemoryInfo(ctx
, &info
);
1138 if (d
->pname
== GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX
)
1139 v
->value_int
= info
.total_device_memory
;
1140 else if (d
->pname
== GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX
)
1141 v
->value_int
= info
.total_device_memory
+
1142 info
.total_staging_memory
;
1143 else if (d
->pname
== GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX
)
1144 v
->value_int
= info
.avail_device_memory
;
1145 else if (d
->pname
== GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX
)
1146 v
->value_int
= info
.nr_device_memory_evictions
;
1147 else if (d
->pname
== GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX
)
1148 v
->value_int
= info
.device_memory_evicted
;
1150 /* ATI free memory enums.
1152 * Since the GPU memory is (usually) page-table based, every two
1153 * consecutive elements are equal. From the GL_ATI_meminfo
1156 * "param[0] - total memory free in the pool
1157 * param[1] - largest available free block in the pool
1158 * param[2] - total auxiliary memory free
1159 * param[3] - largest auxiliary free block"
1161 * All three (VBO, TEXTURE, RENDERBUFFER) queries return
1162 * the same numbers here.
1164 v
->value_int_4
[0] = info
.avail_device_memory
;
1165 v
->value_int_4
[1] = info
.avail_device_memory
;
1166 v
->value_int_4
[2] = info
.avail_staging_memory
;
1167 v
->value_int_4
[3] = info
.avail_staging_memory
;
1172 /* GL_ARB_get_program_binary */
1173 case GL_PROGRAM_BINARY_FORMATS
:
1174 assert(ctx
->Const
.NumProgramBinaryFormats
<= 1);
1175 v
->value_int_n
.n
= MIN2(ctx
->Const
.NumProgramBinaryFormats
, 1);
1176 if (ctx
->Const
.NumProgramBinaryFormats
> 0) {
1177 v
->value_int_n
.ints
[0] = GL_PROGRAM_BINARY_FORMAT_MESA
;
1180 /* GL_EXT_disjoint_timer_query */
1181 case GL_GPU_DISJOINT_EXT
:
1183 simple_mtx_lock(&ctx
->Shared
->Mutex
);
1184 v
->value_int
= ctx
->Shared
->DisjointOperation
;
1185 /* Reset state as expected by the spec. */
1186 ctx
->Shared
->DisjointOperation
= false;
1187 simple_mtx_unlock(&ctx
->Shared
->Mutex
);
1194 * Check extra constraints on a struct value_desc descriptor
1196 * If a struct value_desc has a non-NULL extra pointer, it means that
1197 * there are a number of extra constraints to check or actions to
1198 * perform. The extras is just an integer array where each integer
1199 * encode different constraints or actions.
1201 * \param ctx current context
1202 * \param func name of calling glGet*v() function for error reporting
1203 * \param d the struct value_desc that has the extra constraints
1205 * \return GL_FALSE if all of the constraints were not satisfied,
1206 * otherwise GL_TRUE.
1209 check_extra(struct gl_context
*ctx
, const char *func
, const struct value_desc
*d
)
1211 const GLuint version
= ctx
->Version
;
1212 GLboolean api_check
= GL_FALSE
;
1213 GLboolean api_found
= GL_FALSE
;
1216 for (e
= d
->extra
; *e
!= EXTRA_END
; e
++) {
1218 case EXTRA_VERSION_30
:
1219 api_check
= GL_TRUE
;
1221 api_found
= GL_TRUE
;
1223 case EXTRA_VERSION_31
:
1224 api_check
= GL_TRUE
;
1226 api_found
= GL_TRUE
;
1228 case EXTRA_VERSION_32
:
1229 api_check
= GL_TRUE
;
1231 api_found
= GL_TRUE
;
1233 case EXTRA_VERSION_40
:
1234 api_check
= GL_TRUE
;
1236 api_found
= GL_TRUE
;
1238 case EXTRA_VERSION_43
:
1240 if (_mesa_is_desktop_gl(ctx
) && version
>= 43)
1241 api_found
= GL_TRUE
;
1243 case EXTRA_NEW_FRAG_CLAMP
:
1244 if (ctx
->NewState
& (_NEW_BUFFERS
| _NEW_FRAG_CLAMP
))
1245 _mesa_update_state(ctx
);
1248 api_check
= GL_TRUE
;
1249 if (ctx
->API
== API_OPENGLES2
)
1250 api_found
= GL_TRUE
;
1253 api_check
= GL_TRUE
;
1254 if (_mesa_is_gles3(ctx
))
1255 api_found
= GL_TRUE
;
1257 case EXTRA_API_ES31
:
1258 api_check
= GL_TRUE
;
1259 if (_mesa_is_gles31(ctx
))
1260 api_found
= GL_TRUE
;
1262 case EXTRA_API_ES32
:
1263 api_check
= GL_TRUE
;
1264 if (_mesa_is_gles32(ctx
))
1265 api_found
= GL_TRUE
;
1268 api_check
= GL_TRUE
;
1269 if (_mesa_is_desktop_gl(ctx
))
1270 api_found
= GL_TRUE
;
1272 case EXTRA_API_GL_CORE
:
1273 api_check
= GL_TRUE
;
1274 if (ctx
->API
== API_OPENGL_CORE
)
1275 api_found
= GL_TRUE
;
1277 case EXTRA_NEW_BUFFERS
:
1278 if (ctx
->NewState
& _NEW_BUFFERS
)
1279 _mesa_update_state(ctx
);
1281 case EXTRA_FLUSH_CURRENT
:
1282 FLUSH_CURRENT(ctx
, 0);
1284 case EXTRA_VALID_DRAW_BUFFER
:
1285 if (d
->pname
- GL_DRAW_BUFFER0_ARB
>= ctx
->Const
.MaxDrawBuffers
) {
1286 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(draw buffer %u)",
1287 func
, d
->pname
- GL_DRAW_BUFFER0_ARB
);
1291 case EXTRA_VALID_TEXTURE_UNIT
:
1292 if (ctx
->Texture
.CurrentUnit
>= ctx
->Const
.MaxTextureCoordUnits
) {
1293 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(texture %u)",
1294 func
, ctx
->Texture
.CurrentUnit
);
1298 case EXTRA_VALID_CLIP_DISTANCE
:
1299 if (d
->pname
- GL_CLIP_DISTANCE0
>= ctx
->Const
.MaxClipPlanes
) {
1300 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(clip distance %u)",
1301 func
, d
->pname
- GL_CLIP_DISTANCE0
);
1305 case EXTRA_GLSL_130
:
1306 api_check
= GL_TRUE
;
1307 if (ctx
->Const
.GLSLVersion
>= 130)
1308 api_found
= GL_TRUE
;
1310 case EXTRA_EXT_UBO_GS
:
1311 api_check
= GL_TRUE
;
1312 if (ctx
->Extensions
.ARB_uniform_buffer_object
&&
1313 _mesa_has_geometry_shaders(ctx
))
1314 api_found
= GL_TRUE
;
1316 case EXTRA_EXT_ATOMICS_GS
:
1317 api_check
= GL_TRUE
;
1318 if (ctx
->Extensions
.ARB_shader_atomic_counters
&&
1319 _mesa_has_geometry_shaders(ctx
))
1320 api_found
= GL_TRUE
;
1322 case EXTRA_EXT_SHADER_IMAGE_GS
:
1323 api_check
= GL_TRUE
;
1324 if (ctx
->Extensions
.ARB_shader_image_load_store
&&
1325 _mesa_has_geometry_shaders(ctx
))
1326 api_found
= GL_TRUE
;
1328 case EXTRA_EXT_ATOMICS_TESS
:
1329 api_check
= GL_TRUE
;
1330 api_found
= ctx
->Extensions
.ARB_shader_atomic_counters
&&
1331 _mesa_has_tessellation(ctx
);
1333 case EXTRA_EXT_SHADER_IMAGE_TESS
:
1334 api_check
= GL_TRUE
;
1335 api_found
= ctx
->Extensions
.ARB_shader_image_load_store
&&
1336 _mesa_has_tessellation(ctx
);
1338 case EXTRA_EXT_SSBO_GS
:
1339 api_check
= GL_TRUE
;
1340 if (ctx
->Extensions
.ARB_shader_storage_buffer_object
&&
1341 _mesa_has_geometry_shaders(ctx
))
1342 api_found
= GL_TRUE
;
1344 case EXTRA_EXT_FB_NO_ATTACH_GS
:
1345 api_check
= GL_TRUE
;
1346 if (ctx
->Extensions
.ARB_framebuffer_no_attachments
&&
1347 (_mesa_is_desktop_gl(ctx
) ||
1348 _mesa_has_OES_geometry_shader(ctx
)))
1349 api_found
= GL_TRUE
;
1351 case EXTRA_EXT_ES_GS
:
1352 api_check
= GL_TRUE
;
1353 if (_mesa_has_OES_geometry_shader(ctx
))
1354 api_found
= GL_TRUE
;
1356 case EXTRA_EXT_PROVOKING_VERTEX_32
:
1358 if (ctx
->API
== API_OPENGL_COMPAT
|| version
== 32)
1359 api_found
= ctx
->Extensions
.EXT_provoking_vertex
;
1363 default: /* *e is a offset into the extension struct */
1364 api_check
= GL_TRUE
;
1365 if (*(GLboolean
*) ((char *) &ctx
->Extensions
+ *e
))
1366 api_found
= GL_TRUE
;
1371 if (api_check
&& !api_found
) {
1372 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(pname=%s)", func
,
1373 _mesa_enum_to_string(d
->pname
));
1380 static const struct value_desc error_value
=
1381 { 0, 0, TYPE_INVALID
, NO_OFFSET
, NO_EXTRA
};
1384 * Find the struct value_desc corresponding to the enum 'pname'.
1386 * We hash the enum value to get an index into the 'table' array,
1387 * which holds the index in the 'values' array of struct value_desc.
1388 * Once we've found the entry, we do the extra checks, if any, then
1389 * look up the value and return a pointer to it.
1391 * If the value has to be computed (for example, it's the result of a
1392 * function call or we need to add 1 to it), we use the tmp 'v' to
1395 * \param func name of glGet*v() func for error reporting
1396 * \param pname the enum value we're looking up
1397 * \param p is were we return the pointer to the value
1398 * \param v a tmp union value variable in the calling glGet*v() function
1400 * \return the struct value_desc corresponding to the enum or a struct
1401 * value_desc of TYPE_INVALID if not found. This lets the calling
1402 * glGet*v() function jump right into a switch statement and
1403 * handle errors there instead of having to check for NULL.
1405 static const struct value_desc
*
1406 find_value(const char *func
, GLenum pname
, void **p
, union value
*v
)
1408 GET_CURRENT_CONTEXT(ctx
);
1410 const struct value_desc
*d
;
1414 /* We index into the table_set[] list of per-API hash tables using the API's
1415 * value in the gl_api enum. Since GLES 3 doesn't have an API_OPENGL* enum
1416 * value since it's compatible with GLES2 its entry in table_set[] is at the
1419 STATIC_ASSERT(ARRAY_SIZE(table_set
) == API_OPENGL_LAST
+ 4);
1420 if (ctx
->API
== API_OPENGLES2
) {
1421 if (ctx
->Version
>= 32)
1422 api
= API_OPENGL_LAST
+ 3;
1423 else if (ctx
->Version
>= 31)
1424 api
= API_OPENGL_LAST
+ 2;
1425 else if (ctx
->Version
>= 30)
1426 api
= API_OPENGL_LAST
+ 1;
1428 mask
= ARRAY_SIZE(table(api
)) - 1;
1429 hash
= (pname
* prime_factor
);
1431 int idx
= table(api
)[hash
& mask
];
1433 /* If the enum isn't valid, the hash walk ends with index 0,
1434 * pointing to the first entry of values[] which doesn't hold
1435 * any valid enum. */
1436 if (unlikely(idx
== 0)) {
1437 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(pname=%s)", func
,
1438 _mesa_enum_to_string(pname
));
1439 return &error_value
;
1443 if (likely(d
->pname
== pname
))
1449 if (unlikely(d
->extra
&& !check_extra(ctx
, func
, d
)))
1450 return &error_value
;
1452 switch (d
->location
) {
1454 *p
= ((char *) ctx
->DrawBuffer
+ d
->offset
);
1457 *p
= ((char *) ctx
+ d
->offset
);
1460 *p
= ((char *) ctx
->Array
.VAO
+ d
->offset
);
1463 if (ctx
->Texture
.CurrentUnit
< ARRAY_SIZE(ctx
->Texture
.FixedFuncUnit
)) {
1464 unsigned index
= ctx
->Texture
.CurrentUnit
;
1465 *p
= ((char *)&ctx
->Texture
.FixedFuncUnit
[index
] + d
->offset
);
1469 find_custom_value(ctx
, d
, v
);
1477 /* silence warning */
1478 return &error_value
;
1481 static const int transpose
[] = {
1489 get_value_size(enum value_type type
, const union value
*v
)
1497 return sizeof(GLint
);
1500 return sizeof(GLint
) * 2;
1503 return sizeof(GLint
) * 3;
1506 return sizeof(GLint
) * 4;
1508 return sizeof(GLint
) * v
->value_int_n
.n
;
1510 return sizeof(GLint64
);
1513 return sizeof(GLenum16
);
1515 return sizeof(GLenum
);
1517 return sizeof(GLenum
) * 2;
1519 return sizeof(GLboolean
);
1531 return sizeof(GLfloat
);
1534 return sizeof(GLfloat
) * 2;
1537 return sizeof(GLfloat
) * 3;
1540 return sizeof(GLfloat
) * 4;
1542 return sizeof(GLfloat
) * 8;
1544 return sizeof(GLdouble
);
1545 case TYPE_DOUBLEN_2
:
1546 return sizeof(GLdouble
) * 2;
1548 return sizeof (GLfloat
) * 16;
1550 return sizeof (GLfloat
) * 16;
1557 _mesa_GetBooleanv(GLenum pname
, GLboolean
*params
)
1559 const struct value_desc
*d
;
1565 d
= find_value("glGetBooleanv", pname
, &p
, &v
);
1570 params
[0] = INT_TO_BOOLEAN(d
->offset
);
1574 params
[7] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[7]);
1575 params
[6] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[6]);
1576 params
[5] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[5]);
1577 params
[4] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[4]);
1580 params
[3] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[3]);
1583 params
[2] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[2]);
1586 params
[1] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[1]);
1589 params
[0] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[0]);
1592 case TYPE_DOUBLEN_2
:
1593 params
[1] = FLOAT_TO_BOOLEAN(((GLdouble
*) p
)[1]);
1595 params
[0] = FLOAT_TO_BOOLEAN(((GLdouble
*) p
)[0]);
1600 params
[3] = INT_TO_BOOLEAN(((GLint
*) p
)[3]);
1603 params
[2] = INT_TO_BOOLEAN(((GLint
*) p
)[2]);
1607 params
[1] = INT_TO_BOOLEAN(((GLint
*) p
)[1]);
1611 params
[0] = INT_TO_BOOLEAN(((GLint
*) p
)[0]);
1615 params
[0] = INT_TO_BOOLEAN(((GLenum16
*) p
)[0]);
1619 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
1620 params
[i
] = INT_TO_BOOLEAN(v
.value_int_n
.ints
[i
]);
1624 params
[0] = INT64_TO_BOOLEAN(((GLint64
*) p
)[0]);
1628 params
[0] = ((GLboolean
*) p
)[0];
1632 m
= *(GLmatrix
**) p
;
1633 for (i
= 0; i
< 16; i
++)
1634 params
[i
] = FLOAT_TO_BOOLEAN(m
->m
[i
]);
1638 m
= *(GLmatrix
**) p
;
1639 for (i
= 0; i
< 16; i
++)
1640 params
[i
] = FLOAT_TO_BOOLEAN(m
->m
[transpose
[i
]]);
1651 shift
= d
->type
- TYPE_BIT_0
;
1652 params
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
1658 _mesa_GetFloatv(GLenum pname
, GLfloat
*params
)
1660 const struct value_desc
*d
;
1666 d
= find_value("glGetFloatv", pname
, &p
, &v
);
1671 params
[0] = (GLfloat
) d
->offset
;
1675 params
[7] = ((GLfloat
*) p
)[7];
1676 params
[6] = ((GLfloat
*) p
)[6];
1677 params
[5] = ((GLfloat
*) p
)[5];
1678 params
[4] = ((GLfloat
*) p
)[4];
1681 params
[3] = ((GLfloat
*) p
)[3];
1684 params
[2] = ((GLfloat
*) p
)[2];
1687 params
[1] = ((GLfloat
*) p
)[1];
1690 params
[0] = ((GLfloat
*) p
)[0];
1693 case TYPE_DOUBLEN_2
:
1694 params
[1] = (GLfloat
) (((GLdouble
*) p
)[1]);
1696 params
[0] = (GLfloat
) (((GLdouble
*) p
)[0]);
1700 params
[3] = (GLfloat
) (((GLint
*) p
)[3]);
1702 params
[2] = (GLfloat
) (((GLint
*) p
)[2]);
1705 params
[1] = (GLfloat
) (((GLint
*) p
)[1]);
1708 params
[0] = (GLfloat
) (((GLint
*) p
)[0]);
1712 params
[0] = (GLfloat
) (((GLenum16
*) p
)[0]);
1716 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
1717 params
[i
] = (GLfloat
) v
.value_int_n
.ints
[i
];
1721 params
[3] = (GLfloat
) (((GLuint
*) p
)[3]);
1723 params
[2] = (GLfloat
) (((GLuint
*) p
)[2]);
1725 params
[1] = (GLfloat
) (((GLuint
*) p
)[1]);
1727 params
[0] = (GLfloat
) (((GLuint
*) p
)[0]);
1731 params
[0] = (GLfloat
) (((GLint64
*) p
)[0]);
1735 params
[0] = BOOLEAN_TO_FLOAT(*(GLboolean
*) p
);
1739 m
= *(GLmatrix
**) p
;
1740 for (i
= 0; i
< 16; i
++)
1741 params
[i
] = m
->m
[i
];
1745 m
= *(GLmatrix
**) p
;
1746 for (i
= 0; i
< 16; i
++)
1747 params
[i
] = m
->m
[transpose
[i
]];
1758 shift
= d
->type
- TYPE_BIT_0
;
1759 params
[0] = BOOLEAN_TO_FLOAT((*(GLbitfield
*) p
>> shift
) & 1);
1765 _mesa_GetIntegerv(GLenum pname
, GLint
*params
)
1767 const struct value_desc
*d
;
1773 d
= find_value("glGetIntegerv", pname
, &p
, &v
);
1778 params
[0] = d
->offset
;
1782 params
[7] = IROUND(((GLfloat
*) p
)[7]);
1783 params
[6] = IROUND(((GLfloat
*) p
)[6]);
1784 params
[5] = IROUND(((GLfloat
*) p
)[5]);
1785 params
[4] = IROUND(((GLfloat
*) p
)[4]);
1787 params
[3] = IROUND(((GLfloat
*) p
)[3]);
1789 params
[2] = IROUND(((GLfloat
*) p
)[2]);
1791 params
[1] = IROUND(((GLfloat
*) p
)[1]);
1793 params
[0] = IROUND(((GLfloat
*) p
)[0]);
1797 params
[3] = FLOAT_TO_INT(((GLfloat
*) p
)[3]);
1799 params
[2] = FLOAT_TO_INT(((GLfloat
*) p
)[2]);
1801 params
[1] = FLOAT_TO_INT(((GLfloat
*) p
)[1]);
1803 params
[0] = FLOAT_TO_INT(((GLfloat
*) p
)[0]);
1806 case TYPE_DOUBLEN_2
:
1807 params
[1] = FLOAT_TO_INT(((GLdouble
*) p
)[1]);
1809 params
[0] = FLOAT_TO_INT(((GLdouble
*) p
)[0]);
1814 params
[3] = ((GLint
*) p
)[3];
1817 params
[2] = ((GLint
*) p
)[2];
1821 params
[1] = ((GLint
*) p
)[1];
1825 params
[0] = ((GLint
*) p
)[0];
1829 params
[0] = ((GLenum16
*) p
)[0];
1833 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
1834 params
[i
] = v
.value_int_n
.ints
[i
];
1838 params
[0] = INT64_TO_INT(((GLint64
*) p
)[0]);
1842 params
[0] = BOOLEAN_TO_INT(*(GLboolean
*) p
);
1846 m
= *(GLmatrix
**) p
;
1847 for (i
= 0; i
< 16; i
++)
1848 params
[i
] = FLOAT_TO_INT(m
->m
[i
]);
1852 m
= *(GLmatrix
**) p
;
1853 for (i
= 0; i
< 16; i
++)
1854 params
[i
] = FLOAT_TO_INT(m
->m
[transpose
[i
]]);
1865 shift
= d
->type
- TYPE_BIT_0
;
1866 params
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
1872 _mesa_GetInteger64v(GLenum pname
, GLint64
*params
)
1874 const struct value_desc
*d
;
1880 d
= find_value("glGetInteger64v", pname
, &p
, &v
);
1885 params
[0] = d
->offset
;
1889 params
[7] = IROUND64(((GLfloat
*) p
)[7]);
1890 params
[6] = IROUND64(((GLfloat
*) p
)[6]);
1891 params
[5] = IROUND64(((GLfloat
*) p
)[5]);
1892 params
[4] = IROUND64(((GLfloat
*) p
)[4]);
1894 params
[3] = IROUND64(((GLfloat
*) p
)[3]);
1896 params
[2] = IROUND64(((GLfloat
*) p
)[2]);
1898 params
[1] = IROUND64(((GLfloat
*) p
)[1]);
1900 params
[0] = IROUND64(((GLfloat
*) p
)[0]);
1904 params
[3] = FLOAT_TO_INT(((GLfloat
*) p
)[3]);
1906 params
[2] = FLOAT_TO_INT(((GLfloat
*) p
)[2]);
1908 params
[1] = FLOAT_TO_INT(((GLfloat
*) p
)[1]);
1910 params
[0] = FLOAT_TO_INT(((GLfloat
*) p
)[0]);
1913 case TYPE_DOUBLEN_2
:
1914 params
[1] = FLOAT_TO_INT(((GLdouble
*) p
)[1]);
1916 params
[0] = FLOAT_TO_INT(((GLdouble
*) p
)[0]);
1920 params
[3] = ((GLint
*) p
)[3];
1922 params
[2] = ((GLint
*) p
)[2];
1925 params
[1] = ((GLint
*) p
)[1];
1928 params
[0] = ((GLint
*) p
)[0];
1932 params
[0] = ((GLenum16
*) p
)[0];
1936 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
1937 params
[i
] = INT_TO_BOOLEAN(v
.value_int_n
.ints
[i
]);
1941 params
[3] = ((GLuint
*) p
)[3];
1943 params
[2] = ((GLuint
*) p
)[2];
1945 params
[1] = ((GLuint
*) p
)[1];
1947 params
[0] = ((GLuint
*) p
)[0];
1951 params
[0] = ((GLint64
*) p
)[0];
1955 params
[0] = ((GLboolean
*) p
)[0];
1959 m
= *(GLmatrix
**) p
;
1960 for (i
= 0; i
< 16; i
++)
1961 params
[i
] = FLOAT_TO_INT64(m
->m
[i
]);
1965 m
= *(GLmatrix
**) p
;
1966 for (i
= 0; i
< 16; i
++)
1967 params
[i
] = FLOAT_TO_INT64(m
->m
[transpose
[i
]]);
1978 shift
= d
->type
- TYPE_BIT_0
;
1979 params
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
1985 _mesa_GetDoublev(GLenum pname
, GLdouble
*params
)
1987 const struct value_desc
*d
;
1993 d
= find_value("glGetDoublev", pname
, &p
, &v
);
1998 params
[0] = d
->offset
;
2002 params
[7] = ((GLfloat
*) p
)[7];
2003 params
[6] = ((GLfloat
*) p
)[6];
2004 params
[5] = ((GLfloat
*) p
)[5];
2005 params
[4] = ((GLfloat
*) p
)[4];
2008 params
[3] = ((GLfloat
*) p
)[3];
2011 params
[2] = ((GLfloat
*) p
)[2];
2014 params
[1] = ((GLfloat
*) p
)[1];
2017 params
[0] = ((GLfloat
*) p
)[0];
2020 case TYPE_DOUBLEN_2
:
2021 params
[1] = ((GLdouble
*) p
)[1];
2023 params
[0] = ((GLdouble
*) p
)[0];
2027 params
[3] = ((GLint
*) p
)[3];
2029 params
[2] = ((GLint
*) p
)[2];
2032 params
[1] = ((GLint
*) p
)[1];
2035 params
[0] = ((GLint
*) p
)[0];
2039 params
[0] = ((GLenum16
*) p
)[0];
2043 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
2044 params
[i
] = v
.value_int_n
.ints
[i
];
2048 params
[3] = ((GLuint
*) p
)[3];
2050 params
[2] = ((GLuint
*) p
)[2];
2052 params
[1] = ((GLuint
*) p
)[1];
2054 params
[0] = ((GLuint
*) p
)[0];
2058 params
[0] = (GLdouble
) (((GLint64
*) p
)[0]);
2062 params
[0] = *(GLboolean
*) p
;
2066 m
= *(GLmatrix
**) p
;
2067 for (i
= 0; i
< 16; i
++)
2068 params
[i
] = m
->m
[i
];
2072 m
= *(GLmatrix
**) p
;
2073 for (i
= 0; i
< 16; i
++)
2074 params
[i
] = m
->m
[transpose
[i
]];
2085 shift
= d
->type
- TYPE_BIT_0
;
2086 params
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
2092 _mesa_GetUnsignedBytevEXT(GLenum pname
, GLubyte
*data
)
2094 const struct value_desc
*d
;
2099 const char *func
= "glGetUnsignedBytevEXT";
2101 GET_CURRENT_CONTEXT(ctx
);
2103 if (!ctx
->Extensions
.EXT_memory_object
) {
2104 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(unsupported)", func
);
2108 d
= find_value(func
, pname
, &p
, &v
);
2109 size
= get_value_size(d
->type
, &v
);
2111 _mesa_problem(ctx
, "invalid value type in GetUnsignedBytevEXT()");
2123 shift
= d
->type
- TYPE_BIT_0
;
2124 data
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
2127 memcpy(data
, &d
->offset
, size
);
2130 memcpy(data
, &v
.value_int_n
.ints
, size
);
2154 case TYPE_DOUBLEN_2
:
2157 memcpy(data
, p
, size
);
2160 GLenum e
= *(GLenum16
*)p
;
2161 memcpy(data
, &e
, sizeof(e
));
2165 break; /* nothing - GL error was recorded */
2170 * Convert a GL texture binding enum such as GL_TEXTURE_BINDING_2D
2171 * into the corresponding Mesa texture target index.
2172 * \return TEXTURE_x_INDEX or -1 if binding is invalid
2175 tex_binding_to_index(const struct gl_context
*ctx
, GLenum binding
)
2178 case GL_TEXTURE_BINDING_1D
:
2179 return _mesa_is_desktop_gl(ctx
) ? TEXTURE_1D_INDEX
: -1;
2180 case GL_TEXTURE_BINDING_2D
:
2181 return TEXTURE_2D_INDEX
;
2182 case GL_TEXTURE_BINDING_3D
:
2183 return ctx
->API
!= API_OPENGLES
? TEXTURE_3D_INDEX
: -1;
2184 case GL_TEXTURE_BINDING_CUBE_MAP
:
2185 return ctx
->Extensions
.ARB_texture_cube_map
2186 ? TEXTURE_CUBE_INDEX
: -1;
2187 case GL_TEXTURE_BINDING_RECTANGLE
:
2188 return _mesa_is_desktop_gl(ctx
) && ctx
->Extensions
.NV_texture_rectangle
2189 ? TEXTURE_RECT_INDEX
: -1;
2190 case GL_TEXTURE_BINDING_1D_ARRAY
:
2191 return _mesa_is_desktop_gl(ctx
) && ctx
->Extensions
.EXT_texture_array
2192 ? TEXTURE_1D_ARRAY_INDEX
: -1;
2193 case GL_TEXTURE_BINDING_2D_ARRAY
:
2194 return (_mesa_is_desktop_gl(ctx
) && ctx
->Extensions
.EXT_texture_array
)
2195 || _mesa_is_gles3(ctx
)
2196 ? TEXTURE_2D_ARRAY_INDEX
: -1;
2197 case GL_TEXTURE_BINDING_BUFFER
:
2198 return (_mesa_has_ARB_texture_buffer_object(ctx
) ||
2199 _mesa_has_OES_texture_buffer(ctx
)) ?
2200 TEXTURE_BUFFER_INDEX
: -1;
2201 case GL_TEXTURE_BINDING_CUBE_MAP_ARRAY
:
2202 return _mesa_has_texture_cube_map_array(ctx
)
2203 ? TEXTURE_CUBE_ARRAY_INDEX
: -1;
2204 case GL_TEXTURE_BINDING_2D_MULTISAMPLE
:
2205 return _mesa_is_desktop_gl(ctx
) && ctx
->Extensions
.ARB_texture_multisample
2206 ? TEXTURE_2D_MULTISAMPLE_INDEX
: -1;
2207 case GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY
:
2208 return _mesa_is_desktop_gl(ctx
) && ctx
->Extensions
.ARB_texture_multisample
2209 ? TEXTURE_2D_MULTISAMPLE_ARRAY_INDEX
: -1;
2215 static enum value_type
2216 find_value_indexed(const char *func
, GLenum pname
, GLuint index
, union value
*v
)
2218 GET_CURRENT_CONTEXT(ctx
);
2223 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2225 if (!ctx
->Extensions
.EXT_draw_buffers2
)
2227 v
->value_int
= (ctx
->Color
.BlendEnabled
>> index
) & 1;
2232 case GL_BLEND_SRC_RGB
:
2233 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2235 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
2237 v
->value_int
= ctx
->Color
.Blend
[index
].SrcRGB
;
2239 case GL_BLEND_SRC_ALPHA
:
2240 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2242 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
2244 v
->value_int
= ctx
->Color
.Blend
[index
].SrcA
;
2248 case GL_BLEND_DST_RGB
:
2249 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2251 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
2253 v
->value_int
= ctx
->Color
.Blend
[index
].DstRGB
;
2255 case GL_BLEND_DST_ALPHA
:
2256 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2258 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
2260 v
->value_int
= ctx
->Color
.Blend
[index
].DstA
;
2262 case GL_BLEND_EQUATION_RGB
:
2263 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2265 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
2267 v
->value_int
= ctx
->Color
.Blend
[index
].EquationRGB
;
2269 case GL_BLEND_EQUATION_ALPHA
:
2270 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2272 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
2274 v
->value_int
= ctx
->Color
.Blend
[index
].EquationA
;
2277 case GL_COLOR_WRITEMASK
:
2278 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2280 if (!ctx
->Extensions
.EXT_draw_buffers2
)
2282 v
->value_int_4
[0] = GET_COLORMASK_BIT(ctx
->Color
.ColorMask
, index
, 0);
2283 v
->value_int_4
[1] = GET_COLORMASK_BIT(ctx
->Color
.ColorMask
, index
, 1);
2284 v
->value_int_4
[2] = GET_COLORMASK_BIT(ctx
->Color
.ColorMask
, index
, 2);
2285 v
->value_int_4
[3] = GET_COLORMASK_BIT(ctx
->Color
.ColorMask
, index
, 3);
2288 case GL_SCISSOR_BOX
:
2289 if (index
>= ctx
->Const
.MaxViewports
)
2291 v
->value_int_4
[0] = ctx
->Scissor
.ScissorArray
[index
].X
;
2292 v
->value_int_4
[1] = ctx
->Scissor
.ScissorArray
[index
].Y
;
2293 v
->value_int_4
[2] = ctx
->Scissor
.ScissorArray
[index
].Width
;
2294 v
->value_int_4
[3] = ctx
->Scissor
.ScissorArray
[index
].Height
;
2297 case GL_WINDOW_RECTANGLE_EXT
:
2298 if (!ctx
->Extensions
.EXT_window_rectangles
)
2300 if (index
>= ctx
->Const
.MaxWindowRectangles
)
2302 v
->value_int_4
[0] = ctx
->Scissor
.WindowRects
[index
].X
;
2303 v
->value_int_4
[1] = ctx
->Scissor
.WindowRects
[index
].Y
;
2304 v
->value_int_4
[2] = ctx
->Scissor
.WindowRects
[index
].Width
;
2305 v
->value_int_4
[3] = ctx
->Scissor
.WindowRects
[index
].Height
;
2309 if (index
>= ctx
->Const
.MaxViewports
)
2311 v
->value_float_4
[0] = ctx
->ViewportArray
[index
].X
;
2312 v
->value_float_4
[1] = ctx
->ViewportArray
[index
].Y
;
2313 v
->value_float_4
[2] = ctx
->ViewportArray
[index
].Width
;
2314 v
->value_float_4
[3] = ctx
->ViewportArray
[index
].Height
;
2315 return TYPE_FLOAT_4
;
2317 case GL_DEPTH_RANGE
:
2318 if (index
>= ctx
->Const
.MaxViewports
)
2320 v
->value_double_2
[0] = ctx
->ViewportArray
[index
].Near
;
2321 v
->value_double_2
[1] = ctx
->ViewportArray
[index
].Far
;
2322 return TYPE_DOUBLEN_2
;
2324 case GL_TRANSFORM_FEEDBACK_BUFFER_START
:
2325 if (index
>= ctx
->Const
.MaxTransformFeedbackBuffers
)
2327 if (!ctx
->Extensions
.EXT_transform_feedback
)
2329 v
->value_int64
= ctx
->TransformFeedback
.CurrentObject
->Offset
[index
];
2332 case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE
:
2333 if (index
>= ctx
->Const
.MaxTransformFeedbackBuffers
)
2335 if (!ctx
->Extensions
.EXT_transform_feedback
)
2338 = ctx
->TransformFeedback
.CurrentObject
->RequestedSize
[index
];
2341 case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING
:
2342 if (index
>= ctx
->Const
.MaxTransformFeedbackBuffers
)
2344 if (!ctx
->Extensions
.EXT_transform_feedback
)
2346 v
->value_int
= ctx
->TransformFeedback
.CurrentObject
->BufferNames
[index
];
2349 case GL_UNIFORM_BUFFER_BINDING
:
2350 if (index
>= ctx
->Const
.MaxUniformBufferBindings
)
2352 if (!ctx
->Extensions
.ARB_uniform_buffer_object
)
2354 v
->value_int
= ctx
->UniformBufferBindings
[index
].BufferObject
->Name
;
2357 case GL_UNIFORM_BUFFER_START
:
2358 if (index
>= ctx
->Const
.MaxUniformBufferBindings
)
2360 if (!ctx
->Extensions
.ARB_uniform_buffer_object
)
2362 v
->value_int
= ctx
->UniformBufferBindings
[index
].Offset
< 0 ? 0 :
2363 ctx
->UniformBufferBindings
[index
].Offset
;
2366 case GL_UNIFORM_BUFFER_SIZE
:
2367 if (index
>= ctx
->Const
.MaxUniformBufferBindings
)
2369 if (!ctx
->Extensions
.ARB_uniform_buffer_object
)
2371 v
->value_int
= ctx
->UniformBufferBindings
[index
].Size
< 0 ? 0 :
2372 ctx
->UniformBufferBindings
[index
].Size
;
2375 /* ARB_shader_storage_buffer_object */
2376 case GL_SHADER_STORAGE_BUFFER_BINDING
:
2377 if (!ctx
->Extensions
.ARB_shader_storage_buffer_object
)
2379 if (index
>= ctx
->Const
.MaxShaderStorageBufferBindings
)
2381 v
->value_int
= ctx
->ShaderStorageBufferBindings
[index
].BufferObject
->Name
;
2384 case GL_SHADER_STORAGE_BUFFER_START
:
2385 if (!ctx
->Extensions
.ARB_shader_storage_buffer_object
)
2387 if (index
>= ctx
->Const
.MaxShaderStorageBufferBindings
)
2389 v
->value_int
= ctx
->ShaderStorageBufferBindings
[index
].Offset
< 0 ? 0 :
2390 ctx
->ShaderStorageBufferBindings
[index
].Offset
;
2393 case GL_SHADER_STORAGE_BUFFER_SIZE
:
2394 if (!ctx
->Extensions
.ARB_shader_storage_buffer_object
)
2396 if (index
>= ctx
->Const
.MaxShaderStorageBufferBindings
)
2398 v
->value_int
= ctx
->ShaderStorageBufferBindings
[index
].Size
< 0 ? 0 :
2399 ctx
->ShaderStorageBufferBindings
[index
].Size
;
2402 /* ARB_texture_multisample / GL3.2 */
2403 case GL_SAMPLE_MASK_VALUE
:
2406 if (!ctx
->Extensions
.ARB_texture_multisample
)
2408 v
->value_int
= ctx
->Multisample
.SampleMaskValue
;
2411 case GL_ATOMIC_COUNTER_BUFFER_BINDING
:
2412 if (!ctx
->Extensions
.ARB_shader_atomic_counters
)
2414 if (index
>= ctx
->Const
.MaxAtomicBufferBindings
)
2416 v
->value_int
= ctx
->AtomicBufferBindings
[index
].BufferObject
->Name
;
2419 case GL_ATOMIC_COUNTER_BUFFER_START
:
2420 if (!ctx
->Extensions
.ARB_shader_atomic_counters
)
2422 if (index
>= ctx
->Const
.MaxAtomicBufferBindings
)
2424 v
->value_int64
= ctx
->AtomicBufferBindings
[index
].Offset
< 0 ? 0 :
2425 ctx
->AtomicBufferBindings
[index
].Offset
;
2428 case GL_ATOMIC_COUNTER_BUFFER_SIZE
:
2429 if (!ctx
->Extensions
.ARB_shader_atomic_counters
)
2431 if (index
>= ctx
->Const
.MaxAtomicBufferBindings
)
2433 v
->value_int64
= ctx
->AtomicBufferBindings
[index
].Size
< 0 ? 0 :
2434 ctx
->AtomicBufferBindings
[index
].Size
;
2437 case GL_VERTEX_BINDING_DIVISOR
:
2438 if ((!_mesa_is_desktop_gl(ctx
) || !ctx
->Extensions
.ARB_instanced_arrays
) &&
2439 !_mesa_is_gles31(ctx
))
2441 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
)
2443 v
->value_int
= ctx
->Array
.VAO
->BufferBinding
[VERT_ATTRIB_GENERIC(index
)].InstanceDivisor
;
2446 case GL_VERTEX_BINDING_OFFSET
:
2447 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles31(ctx
))
2449 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
)
2451 v
->value_int
= ctx
->Array
.VAO
->BufferBinding
[VERT_ATTRIB_GENERIC(index
)].Offset
;
2454 case GL_VERTEX_BINDING_STRIDE
:
2455 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles31(ctx
))
2457 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
)
2459 v
->value_int
= ctx
->Array
.VAO
->BufferBinding
[VERT_ATTRIB_GENERIC(index
)].Stride
;
2462 case GL_VERTEX_BINDING_BUFFER
:
2463 if (ctx
->API
== API_OPENGLES2
&& ctx
->Version
< 31)
2465 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
)
2467 v
->value_int
= ctx
->Array
.VAO
->BufferBinding
[VERT_ATTRIB_GENERIC(index
)].BufferObj
->Name
;
2470 /* ARB_shader_image_load_store */
2471 case GL_IMAGE_BINDING_NAME
: {
2472 struct gl_texture_object
*t
;
2474 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
2476 if (index
>= ctx
->Const
.MaxImageUnits
)
2479 t
= ctx
->ImageUnits
[index
].TexObj
;
2480 v
->value_int
= (t
? t
->Name
: 0);
2484 case GL_IMAGE_BINDING_LEVEL
:
2485 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
2487 if (index
>= ctx
->Const
.MaxImageUnits
)
2490 v
->value_int
= ctx
->ImageUnits
[index
].Level
;
2493 case GL_IMAGE_BINDING_LAYERED
:
2494 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
2496 if (index
>= ctx
->Const
.MaxImageUnits
)
2499 v
->value_int
= ctx
->ImageUnits
[index
].Layered
;
2502 case GL_IMAGE_BINDING_LAYER
:
2503 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
2505 if (index
>= ctx
->Const
.MaxImageUnits
)
2508 v
->value_int
= ctx
->ImageUnits
[index
].Layer
;
2511 case GL_IMAGE_BINDING_ACCESS
:
2512 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
2514 if (index
>= ctx
->Const
.MaxImageUnits
)
2517 v
->value_int
= ctx
->ImageUnits
[index
].Access
;
2520 case GL_IMAGE_BINDING_FORMAT
:
2521 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
2523 if (index
>= ctx
->Const
.MaxImageUnits
)
2526 v
->value_int
= ctx
->ImageUnits
[index
].Format
;
2529 /* ARB_direct_state_access */
2530 case GL_TEXTURE_BINDING_1D
:
2531 case GL_TEXTURE_BINDING_1D_ARRAY
:
2532 case GL_TEXTURE_BINDING_2D
:
2533 case GL_TEXTURE_BINDING_2D_ARRAY
:
2534 case GL_TEXTURE_BINDING_2D_MULTISAMPLE
:
2535 case GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY
:
2536 case GL_TEXTURE_BINDING_3D
:
2537 case GL_TEXTURE_BINDING_BUFFER
:
2538 case GL_TEXTURE_BINDING_CUBE_MAP
:
2539 case GL_TEXTURE_BINDING_CUBE_MAP_ARRAY
:
2540 case GL_TEXTURE_BINDING_RECTANGLE
: {
2543 if (ctx
->API
!= API_OPENGL_CORE
)
2545 target
= tex_binding_to_index(ctx
, pname
);
2548 if (index
>= _mesa_max_tex_unit(ctx
))
2551 v
->value_int
= ctx
->Texture
.Unit
[index
].CurrentTex
[target
]->Name
;
2555 case GL_SAMPLER_BINDING
: {
2556 struct gl_sampler_object
*samp
;
2558 if (ctx
->API
!= API_OPENGL_CORE
)
2560 if (index
>= _mesa_max_tex_unit(ctx
))
2563 samp
= ctx
->Texture
.Unit
[index
].Sampler
;
2564 v
->value_int
= samp
? samp
->Name
: 0;
2568 case GL_MAX_COMPUTE_WORK_GROUP_COUNT
:
2569 if (!_mesa_has_compute_shaders(ctx
))
2573 v
->value_int
= ctx
->Const
.MaxComputeWorkGroupCount
[index
];
2576 case GL_MAX_COMPUTE_WORK_GROUP_SIZE
:
2577 if (!_mesa_has_compute_shaders(ctx
))
2581 v
->value_int
= ctx
->Const
.MaxComputeWorkGroupSize
[index
];
2584 /* ARB_compute_variable_group_size */
2585 case GL_MAX_COMPUTE_VARIABLE_GROUP_SIZE_ARB
:
2586 if (!ctx
->Extensions
.ARB_compute_variable_group_size
)
2590 v
->value_int
= ctx
->Const
.MaxComputeVariableGroupSize
[index
];
2593 /* GL_EXT_external_objects */
2594 case GL_NUM_DEVICE_UUIDS_EXT
:
2597 case GL_DRIVER_UUID_EXT
:
2600 _mesa_get_driver_uuid(ctx
, v
->value_int_4
);
2602 case GL_DEVICE_UUID_EXT
:
2605 _mesa_get_device_uuid(ctx
, v
->value_int_4
);
2610 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(pname=%s)", func
,
2611 _mesa_enum_to_string(pname
));
2612 return TYPE_INVALID
;
2614 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(pname=%s)", func
,
2615 _mesa_enum_to_string(pname
));
2616 return TYPE_INVALID
;
2620 _mesa_GetBooleani_v( GLenum pname
, GLuint index
, GLboolean
*params
)
2623 enum value_type type
=
2624 find_value_indexed("glGetBooleani_v", pname
, index
, &v
);
2629 params
[0] = INT_TO_BOOLEAN(v
.value_int
);
2633 params
[0] = INT_TO_BOOLEAN(v
.value_int_4
[0]);
2634 params
[1] = INT_TO_BOOLEAN(v
.value_int_4
[1]);
2635 params
[2] = INT_TO_BOOLEAN(v
.value_int_4
[2]);
2636 params
[3] = INT_TO_BOOLEAN(v
.value_int_4
[3]);
2639 params
[0] = INT64_TO_BOOLEAN(v
.value_int64
);
2642 ; /* nothing - GL error was recorded */
2647 _mesa_GetIntegeri_v( GLenum pname
, GLuint index
, GLint
*params
)
2650 enum value_type type
=
2651 find_value_indexed("glGetIntegeri_v", pname
, index
, &v
);
2656 params
[3] = IROUND(v
.value_float_4
[3]);
2659 params
[2] = IROUND(v
.value_float_4
[2]);
2662 params
[1] = IROUND(v
.value_float_4
[1]);
2665 params
[0] = IROUND(v
.value_float_4
[0]);
2668 case TYPE_DOUBLEN_2
:
2669 params
[1] = IROUND(v
.value_double_2
[1]);
2671 params
[0] = IROUND(v
.value_double_2
[0]);
2676 params
[0] = v
.value_int
;
2680 params
[0] = v
.value_int_4
[0];
2681 params
[1] = v
.value_int_4
[1];
2682 params
[2] = v
.value_int_4
[2];
2683 params
[3] = v
.value_int_4
[3];
2686 params
[0] = INT64_TO_INT(v
.value_int64
);
2689 ; /* nothing - GL error was recorded */
2694 _mesa_GetInteger64i_v( GLenum pname
, GLuint index
, GLint64
*params
)
2697 enum value_type type
=
2698 find_value_indexed("glGetInteger64i_v", pname
, index
, &v
);
2702 params
[0] = v
.value_int
;
2705 params
[0] = v
.value_int_4
[0];
2706 params
[1] = v
.value_int_4
[1];
2707 params
[2] = v
.value_int_4
[2];
2708 params
[3] = v
.value_int_4
[3];
2711 params
[0] = (GLuint
) v
.value_int
;
2714 params
[0] = (GLuint
) v
.value_int_4
[0];
2715 params
[1] = (GLuint
) v
.value_int_4
[1];
2716 params
[2] = (GLuint
) v
.value_int_4
[2];
2717 params
[3] = (GLuint
) v
.value_int_4
[3];
2720 params
[0] = v
.value_int64
;
2723 ; /* nothing - GL error was recorded */
2728 _mesa_GetFloati_v(GLenum pname
, GLuint index
, GLfloat
*params
)
2733 enum value_type type
=
2734 find_value_indexed("glGetFloati_v", pname
, index
, &v
);
2739 params
[3] = v
.value_float_4
[3];
2742 params
[2] = v
.value_float_4
[2];
2745 params
[1] = v
.value_float_4
[1];
2748 params
[0] = v
.value_float_4
[0];
2751 case TYPE_DOUBLEN_2
:
2752 params
[1] = (GLfloat
) v
.value_double_2
[1];
2754 params
[0] = (GLfloat
) v
.value_double_2
[0];
2758 params
[3] = (GLfloat
) v
.value_int_4
[3];
2760 params
[2] = (GLfloat
) v
.value_int_4
[2];
2763 params
[1] = (GLfloat
) v
.value_int_4
[1];
2767 params
[0] = (GLfloat
) v
.value_int_4
[0];
2771 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
2772 params
[i
] = (GLfloat
) v
.value_int_n
.ints
[i
];
2776 params
[3] = (GLfloat
) ((GLuint
) v
.value_int_4
[3]);
2778 params
[2] = (GLfloat
) ((GLuint
) v
.value_int_4
[2]);
2780 params
[1] = (GLfloat
) ((GLuint
) v
.value_int_4
[1]);
2782 params
[0] = (GLfloat
) ((GLuint
) v
.value_int_4
[0]);
2786 params
[0] = (GLfloat
) v
.value_int64
;
2790 params
[0] = BOOLEAN_TO_FLOAT(v
.value_bool
);
2794 m
= *(GLmatrix
**) &v
;
2795 for (i
= 0; i
< 16; i
++)
2796 params
[i
] = m
->m
[i
];
2800 m
= *(GLmatrix
**) &v
;
2801 for (i
= 0; i
< 16; i
++)
2802 params
[i
] = m
->m
[transpose
[i
]];
2811 _mesa_GetDoublei_v(GLenum pname
, GLuint index
, GLdouble
*params
)
2816 enum value_type type
=
2817 find_value_indexed("glGetDoublei_v", pname
, index
, &v
);
2822 params
[3] = (GLdouble
) v
.value_float_4
[3];
2825 params
[2] = (GLdouble
) v
.value_float_4
[2];
2828 params
[1] = (GLdouble
) v
.value_float_4
[1];
2831 params
[0] = (GLdouble
) v
.value_float_4
[0];
2834 case TYPE_DOUBLEN_2
:
2835 params
[1] = v
.value_double_2
[1];
2837 params
[0] = v
.value_double_2
[0];
2841 params
[3] = (GLdouble
) v
.value_int_4
[3];
2843 params
[2] = (GLdouble
) v
.value_int_4
[2];
2846 params
[1] = (GLdouble
) v
.value_int_4
[1];
2850 params
[0] = (GLdouble
) v
.value_int_4
[0];
2854 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
2855 params
[i
] = (GLdouble
) v
.value_int_n
.ints
[i
];
2859 params
[3] = (GLdouble
) ((GLuint
) v
.value_int_4
[3]);
2861 params
[2] = (GLdouble
) ((GLuint
) v
.value_int_4
[2]);
2863 params
[1] = (GLdouble
) ((GLuint
) v
.value_int_4
[1]);
2865 params
[0] = (GLdouble
) ((GLuint
) v
.value_int_4
[0]);
2869 params
[0] = (GLdouble
) v
.value_int64
;
2873 params
[0] = (GLdouble
) BOOLEAN_TO_FLOAT(v
.value_bool
);
2877 m
= *(GLmatrix
**) &v
;
2878 for (i
= 0; i
< 16; i
++)
2879 params
[i
] = (GLdouble
) m
->m
[i
];
2883 m
= *(GLmatrix
**) &v
;
2884 for (i
= 0; i
< 16; i
++)
2885 params
[i
] = (GLdouble
) m
->m
[transpose
[i
]];
2894 _mesa_GetUnsignedBytei_vEXT(GLenum target
, GLuint index
, GLubyte
*data
)
2898 enum value_type type
;
2899 const char *func
= "glGetUnsignedBytei_vEXT";
2901 GET_CURRENT_CONTEXT(ctx
);
2903 if (!ctx
->Extensions
.EXT_memory_object
) {
2904 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(unsupported)", func
);
2908 type
= find_value_indexed(func
, target
, index
, &v
);
2909 size
= get_value_size(type
, &v
);
2911 _mesa_problem(ctx
, "invalid value type in GetUnsignedBytei_vEXT()");
2938 case TYPE_DOUBLEN_2
:
2941 memcpy(data
, &v
.value_int
, size
);
2944 memcpy(data
, &v
.value_int_n
.ints
, size
);
2947 break; /* nothing - GL error was recorded */
2952 _mesa_GetFixedv(GLenum pname
, GLfixed
*params
)
2954 const struct value_desc
*d
;
2960 d
= find_value("glGetDoublev", pname
, &p
, &v
);
2965 params
[0] = INT_TO_FIXED(d
->offset
);
2970 params
[3] = FLOAT_TO_FIXED(((GLfloat
*) p
)[3]);
2973 params
[2] = FLOAT_TO_FIXED(((GLfloat
*) p
)[2]);
2976 params
[1] = FLOAT_TO_FIXED(((GLfloat
*) p
)[1]);
2979 params
[0] = FLOAT_TO_FIXED(((GLfloat
*) p
)[0]);
2982 case TYPE_DOUBLEN_2
:
2983 params
[1] = FLOAT_TO_FIXED(((GLdouble
*) p
)[1]);
2985 params
[0] = FLOAT_TO_FIXED(((GLdouble
*) p
)[0]);
2990 params
[3] = INT_TO_FIXED(((GLint
*) p
)[3]);
2993 params
[2] = INT_TO_FIXED(((GLint
*) p
)[2]);
2997 params
[1] = INT_TO_FIXED(((GLint
*) p
)[1]);
3001 params
[0] = INT_TO_FIXED(((GLint
*) p
)[0]);
3005 params
[0] = INT_TO_FIXED(((GLenum16
*) p
)[0]);
3009 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
3010 params
[i
] = INT_TO_FIXED(v
.value_int_n
.ints
[i
]);
3014 params
[0] = ((GLint64
*) p
)[0];
3018 params
[0] = BOOLEAN_TO_FIXED(((GLboolean
*) p
)[0]);
3022 m
= *(GLmatrix
**) p
;
3023 for (i
= 0; i
< 16; i
++)
3024 params
[i
] = FLOAT_TO_FIXED(m
->m
[i
]);
3028 m
= *(GLmatrix
**) p
;
3029 for (i
= 0; i
< 16; i
++)
3030 params
[i
] = FLOAT_TO_FIXED(m
->m
[transpose
[i
]]);
3041 shift
= d
->type
- TYPE_BIT_0
;
3042 params
[0] = BOOLEAN_TO_FIXED((*(GLbitfield
*) p
>> shift
) & 1);