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];
197 /* Sigh, see GL_COMPRESSED_TEXTURE_FORMATS_ARB handling */
201 GLboolean value_bool
;
204 #define BUFFER_FIELD(field, type) \
205 LOC_BUFFER, type, offsetof(struct gl_framebuffer, field)
206 #define CONTEXT_FIELD(field, type) \
207 LOC_CONTEXT, type, offsetof(struct gl_context, field)
208 #define ARRAY_FIELD(field, type) \
209 LOC_ARRAY, type, offsetof(struct gl_vertex_array_object, field)
210 #undef CONST /* already defined through windows.h */
211 #define CONST(value) \
212 LOC_CONTEXT, TYPE_CONST, value
214 #define BUFFER_INT(field) BUFFER_FIELD(field, TYPE_INT)
215 #define BUFFER_ENUM(field) BUFFER_FIELD(field, TYPE_ENUM)
216 #define BUFFER_ENUM16(field) BUFFER_FIELD(field, TYPE_ENUM16)
217 #define BUFFER_BOOL(field) BUFFER_FIELD(field, TYPE_BOOLEAN)
219 #define CONTEXT_INT(field) CONTEXT_FIELD(field, TYPE_INT)
220 #define CONTEXT_INT2(field) CONTEXT_FIELD(field, TYPE_INT_2)
221 #define CONTEXT_INT64(field) CONTEXT_FIELD(field, TYPE_INT64)
222 #define CONTEXT_UINT(field) CONTEXT_FIELD(field, TYPE_UINT)
223 #define CONTEXT_ENUM16(field) CONTEXT_FIELD(field, TYPE_ENUM16)
224 #define CONTEXT_ENUM(field) CONTEXT_FIELD(field, TYPE_ENUM)
225 #define CONTEXT_ENUM2(field) CONTEXT_FIELD(field, TYPE_ENUM_2)
226 #define CONTEXT_BOOL(field) CONTEXT_FIELD(field, TYPE_BOOLEAN)
227 #define CONTEXT_BIT0(field) CONTEXT_FIELD(field, TYPE_BIT_0)
228 #define CONTEXT_BIT1(field) CONTEXT_FIELD(field, TYPE_BIT_1)
229 #define CONTEXT_BIT2(field) CONTEXT_FIELD(field, TYPE_BIT_2)
230 #define CONTEXT_BIT3(field) CONTEXT_FIELD(field, TYPE_BIT_3)
231 #define CONTEXT_BIT4(field) CONTEXT_FIELD(field, TYPE_BIT_4)
232 #define CONTEXT_BIT5(field) CONTEXT_FIELD(field, TYPE_BIT_5)
233 #define CONTEXT_BIT6(field) CONTEXT_FIELD(field, TYPE_BIT_6)
234 #define CONTEXT_BIT7(field) CONTEXT_FIELD(field, TYPE_BIT_7)
235 #define CONTEXT_FLOAT(field) CONTEXT_FIELD(field, TYPE_FLOAT)
236 #define CONTEXT_FLOAT2(field) CONTEXT_FIELD(field, TYPE_FLOAT_2)
237 #define CONTEXT_FLOAT3(field) CONTEXT_FIELD(field, TYPE_FLOAT_3)
238 #define CONTEXT_FLOAT4(field) CONTEXT_FIELD(field, TYPE_FLOAT_4)
239 #define CONTEXT_FLOAT8(field) CONTEXT_FIELD(field, TYPE_FLOAT_8)
240 #define CONTEXT_MATRIX(field) CONTEXT_FIELD(field, TYPE_MATRIX)
241 #define CONTEXT_MATRIX_T(field) CONTEXT_FIELD(field, TYPE_MATRIX_T)
243 /* Vertex array fields */
244 #define ARRAY_INT(field) ARRAY_FIELD(field, TYPE_INT)
245 #define ARRAY_ENUM(field) ARRAY_FIELD(field, TYPE_ENUM)
246 #define ARRAY_ENUM16(field) ARRAY_FIELD(field, TYPE_ENUM16)
247 #define ARRAY_BOOL(field) ARRAY_FIELD(field, TYPE_BOOLEAN)
248 #define ARRAY_UBYTE(field) ARRAY_FIELD(field, TYPE_UBYTE)
249 #define ARRAY_SHORT(field) ARRAY_FIELD(field, TYPE_SHORT)
252 offsetof(struct gl_extensions, f)
254 #define EXTRA_EXT(e) \
255 static const int extra_##e[] = { \
259 #define EXTRA_EXT2(e1, e2) \
260 static const int extra_##e1##_##e2[] = { \
261 EXT(e1), EXT(e2), EXTRA_END \
264 /* The 'extra' mechanism is a way to specify extra checks (such as
265 * extensions or specific gl versions) or actions (flush current, new
266 * buffers) that we need to do before looking up an enum. We need to
267 * declare them all up front so we can refer to them in the value_desc
270 * Each EXTRA_ will be executed. For EXTRA_* enums of extensions and API
271 * versions, listing multiple ones in an array means an error will be thrown
272 * only if none of them are available. If you need to check for "AND"
273 * behavior, you would need to make a custom EXTRA_ enum.
276 static const int extra_new_buffers
[] = {
281 static const int extra_new_frag_clamp
[] = {
282 EXTRA_NEW_FRAG_CLAMP
,
286 static const int extra_valid_draw_buffer
[] = {
287 EXTRA_VALID_DRAW_BUFFER
,
291 static const int extra_valid_texture_unit
[] = {
292 EXTRA_VALID_TEXTURE_UNIT
,
296 static const int extra_valid_clip_distance
[] = {
297 EXTRA_VALID_CLIP_DISTANCE
,
301 static const int extra_flush_current_valid_texture_unit
[] = {
303 EXTRA_VALID_TEXTURE_UNIT
,
307 static const int extra_flush_current
[] = {
312 static const int extra_EXT_texture_integer_and_new_buffers
[] = {
313 EXT(EXT_texture_integer
),
318 static const int extra_GLSL_130_es3
[] = {
324 static const int extra_texture_buffer_object
[] = {
325 EXT(ARB_texture_buffer_object
),
329 static const int extra_ARB_transform_feedback2_api_es3
[] = {
330 EXT(ARB_transform_feedback2
),
335 static const int extra_ARB_uniform_buffer_object_and_geometry_shader
[] = {
340 static const int extra_ARB_ES2_compatibility_api_es2
[] = {
341 EXT(ARB_ES2_compatibility
),
346 static const int extra_ARB_ES3_compatibility_api_es3
[] = {
347 EXT(ARB_ES3_compatibility
),
352 static const int extra_EXT_framebuffer_sRGB_and_new_buffers
[] = {
353 EXT(EXT_framebuffer_sRGB
),
358 static const int extra_EXT_packed_float
[] = {
359 EXT(EXT_packed_float
),
364 static const int extra_EXT_texture_array_es3
[] = {
365 EXT(EXT_texture_array
),
370 static const int extra_ARB_shader_atomic_counters_and_geometry_shader
[] = {
371 EXTRA_EXT_ATOMICS_GS
,
375 static const int extra_ARB_shader_image_load_store_and_geometry_shader
[] = {
376 EXTRA_EXT_SHADER_IMAGE_GS
,
380 static const int extra_ARB_shader_atomic_counters_and_tessellation
[] = {
381 EXTRA_EXT_ATOMICS_TESS
,
385 static const int extra_ARB_shader_image_load_store_and_tessellation
[] = {
386 EXTRA_EXT_SHADER_IMAGE_TESS
,
390 /* HACK: remove when ARB_compute_shader is actually supported */
391 static const int extra_ARB_compute_shader_es31
[] = {
392 EXT(ARB_compute_shader
),
397 static const int extra_ARB_shader_storage_buffer_object_es31
[] = {
398 EXT(ARB_shader_storage_buffer_object
),
403 static const int extra_ARB_shader_storage_buffer_object_and_geometry_shader
[] = {
408 static const int extra_ARB_shader_image_load_store_shader_storage_buffer_object_es31
[] = {
409 EXT(ARB_shader_image_load_store
),
410 EXT(ARB_shader_storage_buffer_object
),
415 static const int extra_ARB_framebuffer_no_attachments_and_geometry_shader
[] = {
416 EXTRA_EXT_FB_NO_ATTACH_GS
,
420 static const int extra_ARB_viewport_array_or_oes_geometry_shader
[] = {
421 EXT(ARB_viewport_array
),
426 static const int extra_ARB_viewport_array_or_oes_viewport_array
[] = {
427 EXT(ARB_viewport_array
),
428 EXT(OES_viewport_array
),
432 static const int extra_ARB_gpu_shader5_or_oes_geometry_shader
[] = {
433 EXT(ARB_gpu_shader5
),
438 static const int extra_ARB_gpu_shader5_or_OES_sample_variables
[] = {
439 EXT(ARB_gpu_shader5
),
440 EXT(OES_sample_variables
),
444 static const int extra_ES32
[] = {
445 EXT(ARB_ES3_2_compatibility
),
450 static const int extra_KHR_robustness_or_GL
[] = {
457 static const int extra_INTEL_conservative_rasterization
[] = {
458 EXT(INTEL_conservative_rasterization
),
462 EXTRA_EXT(ARB_texture_cube_map
);
463 EXTRA_EXT(EXT_texture_array
);
464 EXTRA_EXT(NV_fog_distance
);
465 EXTRA_EXT(EXT_texture_filter_anisotropic
);
466 EXTRA_EXT(NV_point_sprite
);
467 EXTRA_EXT(NV_texture_rectangle
);
468 EXTRA_EXT(EXT_stencil_two_side
);
469 EXTRA_EXT(EXT_depth_bounds_test
);
470 EXTRA_EXT(ARB_depth_clamp
);
471 EXTRA_EXT(ATI_fragment_shader
);
472 EXTRA_EXT(EXT_provoking_vertex
);
473 EXTRA_EXT(ARB_fragment_shader
);
474 EXTRA_EXT(ARB_fragment_program
);
475 EXTRA_EXT2(ARB_framebuffer_object
, EXT_framebuffer_multisample
);
476 EXTRA_EXT(ARB_seamless_cube_map
);
478 EXTRA_EXT(ARB_vertex_shader
);
479 EXTRA_EXT(EXT_transform_feedback
);
480 EXTRA_EXT(ARB_transform_feedback3
);
481 EXTRA_EXT(EXT_pixel_buffer_object
);
482 EXTRA_EXT(ARB_vertex_program
);
483 EXTRA_EXT2(NV_point_sprite
, ARB_point_sprite
);
484 EXTRA_EXT2(ARB_vertex_program
, ARB_fragment_program
);
485 EXTRA_EXT(ARB_color_buffer_float
);
486 EXTRA_EXT(EXT_framebuffer_sRGB
);
487 EXTRA_EXT(OES_EGL_image_external
);
488 EXTRA_EXT(ARB_blend_func_extended
);
489 EXTRA_EXT(ARB_uniform_buffer_object
);
490 EXTRA_EXT(ARB_timer_query
);
491 EXTRA_EXT2(ARB_texture_cube_map_array
, OES_texture_cube_map_array
);
492 EXTRA_EXT(ARB_texture_buffer_range
);
493 EXTRA_EXT(ARB_texture_multisample
);
494 EXTRA_EXT(ARB_texture_gather
);
495 EXTRA_EXT(ARB_shader_atomic_counters
);
496 EXTRA_EXT(ARB_draw_indirect
);
497 EXTRA_EXT(ARB_shader_image_load_store
);
498 EXTRA_EXT(ARB_query_buffer_object
);
499 EXTRA_EXT2(ARB_transform_feedback3
, ARB_gpu_shader5
);
500 EXTRA_EXT(INTEL_performance_query
);
501 EXTRA_EXT(ARB_explicit_uniform_location
);
502 EXTRA_EXT(ARB_clip_control
);
503 EXTRA_EXT(ARB_polygon_offset_clamp
);
504 EXTRA_EXT(ARB_framebuffer_no_attachments
);
505 EXTRA_EXT(ARB_tessellation_shader
);
506 EXTRA_EXT(ARB_shader_storage_buffer_object
);
507 EXTRA_EXT(ARB_indirect_parameters
);
508 EXTRA_EXT(ATI_meminfo
);
509 EXTRA_EXT(NVX_gpu_memory_info
);
510 EXTRA_EXT(ARB_cull_distance
);
511 EXTRA_EXT(EXT_window_rectangles
);
512 EXTRA_EXT(KHR_blend_equation_advanced_coherent
);
513 EXTRA_EXT(OES_primitive_bounding_box
);
514 EXTRA_EXT(ARB_compute_variable_group_size
);
515 EXTRA_EXT(KHR_robustness
);
516 EXTRA_EXT(ARB_sparse_buffer
);
517 EXTRA_EXT(NV_conservative_raster
);
518 EXTRA_EXT(NV_conservative_raster_dilate
);
519 EXTRA_EXT(NV_conservative_raster_pre_snap_triangles
);
520 EXTRA_EXT(ARB_sample_locations
);
523 extra_ARB_color_buffer_float_or_glcore
[] = {
524 EXT(ARB_color_buffer_float
),
530 extra_NV_primitive_restart
[] = {
531 EXT(NV_primitive_restart
),
535 static const int extra_version_30
[] = { EXTRA_VERSION_30
, EXTRA_END
};
536 static const int extra_version_31
[] = { EXTRA_VERSION_31
, EXTRA_END
};
537 static const int extra_version_32
[] = { EXTRA_VERSION_32
, EXTRA_END
};
538 static const int extra_version_43
[] = { EXTRA_VERSION_43
, EXTRA_END
};
540 static const int extra_gl30_es3
[] = {
546 static const int extra_gl32_es3
[] = {
552 static const int extra_version_32_OES_geometry_shader
[] = {
558 static const int extra_gl40_ARB_sample_shading
[] = {
560 EXT(ARB_sample_shading
),
565 extra_ARB_vertex_program_api_es2
[] = {
566 EXT(ARB_vertex_program
),
571 /* The ReadBuffer get token is valid under either full GL or under
572 * GLES2 if the NV_read_buffer extension is available. */
574 extra_NV_read_buffer_api_gl
[] = {
580 static const int extra_core_ARB_color_buffer_float_and_new_buffers
[] = {
582 EXT(ARB_color_buffer_float
),
587 static const int extra_EXT_shader_framebuffer_fetch
[] = {
590 EXT(EXT_shader_framebuffer_fetch
),
594 static const int extra_EXT_provoking_vertex_32
[] = {
595 EXTRA_EXT_PROVOKING_VERTEX_32
,
599 static const int extra_EXT_disjoint_timer_query
[] = {
602 EXT(EXT_disjoint_timer_query
),
607 /* This is the big table describing all the enums we accept in
608 * glGet*v(). The table is partitioned into six parts: enums
609 * understood by all GL APIs (OpenGL, GLES and GLES2), enums shared
610 * between OpenGL and GLES, enums exclusive to GLES, etc for the
611 * remaining combinations. To look up the enums valid in a given API
612 * we will use a hash table specific to that API. These tables are in
613 * turn generated at build time and included through get_hash.h.
616 #include "get_hash.h"
618 /* All we need now is a way to look up the value struct from the enum.
619 * The code generated by gcc for the old generated big switch
620 * statement is a big, balanced, open coded if/else tree, essentially
621 * an unrolled binary search. It would be natural to sort the new
622 * enum table and use bsearch(), but we will use a read-only hash
623 * table instead. bsearch() has a nice guaranteed worst case
624 * performance, but we're also guaranteed to hit that worst case
625 * (log2(n) iterations) for about half the enums. Instead, using an
626 * open addressing hash table, we can find the enum on the first try
627 * for 80% of the enums, 1 collision for 10% and never more than 5
628 * collisions for any enum (typical numbers). And the code is very
629 * simple, even though it feels a little magic. */
632 * Handle irregular enums
634 * Some values don't conform to the "well-known type at context
635 * pointer + offset" pattern, so we have this function to catch all
636 * the corner cases. Typically, it's a computed value or a one-off
637 * pointer to a custom struct or something.
639 * In this case we can't return a pointer to the value, so we'll have
640 * to use the temporary variable 'v' declared back in the calling
641 * glGet*v() function to store the result.
643 * \param ctx the current context
644 * \param d the struct value_desc that describes the enum
645 * \param v pointer to the tmp declared in the calling glGet*v() function
648 find_custom_value(struct gl_context
*ctx
, const struct value_desc
*d
, union value
*v
)
650 struct gl_buffer_object
**buffer_obj
;
651 struct gl_array_attributes
*array
;
655 case GL_MAJOR_VERSION
:
656 v
->value_int
= ctx
->Version
/ 10;
658 case GL_MINOR_VERSION
:
659 v
->value_int
= ctx
->Version
% 10;
665 case GL_TEXTURE_CUBE_MAP
:
666 case GL_TEXTURE_RECTANGLE_NV
:
667 case GL_TEXTURE_EXTERNAL_OES
:
668 v
->value_bool
= _mesa_IsEnabled(d
->pname
);
671 case GL_LINE_STIPPLE_PATTERN
:
672 /* This is the only GLushort, special case it here by promoting
673 * to an int rather than introducing a new type. */
674 v
->value_int
= ctx
->Line
.StipplePattern
;
677 case GL_CURRENT_RASTER_TEXTURE_COORDS
:
678 unit
= ctx
->Texture
.CurrentUnit
;
679 v
->value_float_4
[0] = ctx
->Current
.RasterTexCoords
[unit
][0];
680 v
->value_float_4
[1] = ctx
->Current
.RasterTexCoords
[unit
][1];
681 v
->value_float_4
[2] = ctx
->Current
.RasterTexCoords
[unit
][2];
682 v
->value_float_4
[3] = ctx
->Current
.RasterTexCoords
[unit
][3];
685 case GL_CURRENT_TEXTURE_COORDS
:
686 unit
= ctx
->Texture
.CurrentUnit
;
687 v
->value_float_4
[0] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
][0];
688 v
->value_float_4
[1] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
][1];
689 v
->value_float_4
[2] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
][2];
690 v
->value_float_4
[3] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
][3];
693 case GL_COLOR_WRITEMASK
:
694 v
->value_int_4
[0] = GET_COLORMASK_BIT(ctx
->Color
.ColorMask
, 0, 0);
695 v
->value_int_4
[1] = GET_COLORMASK_BIT(ctx
->Color
.ColorMask
, 0, 1);
696 v
->value_int_4
[2] = GET_COLORMASK_BIT(ctx
->Color
.ColorMask
, 0, 2);
697 v
->value_int_4
[3] = GET_COLORMASK_BIT(ctx
->Color
.ColorMask
, 0, 3);
701 v
->value_bool
= ctx
->Current
.Attrib
[VERT_ATTRIB_EDGEFLAG
][0] == 1.0F
;
705 v
->value_enum
= ctx
->ReadBuffer
->ColorReadBuffer
;
708 case GL_MAP2_GRID_DOMAIN
:
709 v
->value_float_4
[0] = ctx
->Eval
.MapGrid2u1
;
710 v
->value_float_4
[1] = ctx
->Eval
.MapGrid2u2
;
711 v
->value_float_4
[2] = ctx
->Eval
.MapGrid2v1
;
712 v
->value_float_4
[3] = ctx
->Eval
.MapGrid2v2
;
715 case GL_TEXTURE_STACK_DEPTH
:
716 unit
= ctx
->Texture
.CurrentUnit
;
717 v
->value_int
= ctx
->TextureMatrixStack
[unit
].Depth
+ 1;
719 case GL_TEXTURE_MATRIX
:
720 unit
= ctx
->Texture
.CurrentUnit
;
721 v
->value_matrix
= ctx
->TextureMatrixStack
[unit
].Top
;
724 case GL_TEXTURE_COORD_ARRAY
:
725 case GL_TEXTURE_COORD_ARRAY_SIZE
:
726 case GL_TEXTURE_COORD_ARRAY_TYPE
:
727 case GL_TEXTURE_COORD_ARRAY_STRIDE
:
728 array
= &ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_TEX(ctx
->Array
.ActiveTexture
)];
729 v
->value_int
= *(GLuint
*) ((char *) array
+ d
->offset
);
732 case GL_ACTIVE_TEXTURE_ARB
:
733 v
->value_int
= GL_TEXTURE0_ARB
+ ctx
->Texture
.CurrentUnit
;
735 case GL_CLIENT_ACTIVE_TEXTURE_ARB
:
736 v
->value_int
= GL_TEXTURE0_ARB
+ ctx
->Array
.ActiveTexture
;
739 case GL_MODELVIEW_STACK_DEPTH
:
740 case GL_PROJECTION_STACK_DEPTH
:
741 v
->value_int
= *(GLint
*) ((char *) ctx
+ d
->offset
) + 1;
744 case GL_MAX_TEXTURE_SIZE
:
745 case GL_MAX_3D_TEXTURE_SIZE
:
746 case GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB
:
747 p
= (GLuint
*) ((char *) ctx
+ d
->offset
);
748 v
->value_int
= 1 << (*p
- 1);
752 v
->value_int_4
[0] = ctx
->Scissor
.ScissorArray
[0].X
;
753 v
->value_int_4
[1] = ctx
->Scissor
.ScissorArray
[0].Y
;
754 v
->value_int_4
[2] = ctx
->Scissor
.ScissorArray
[0].Width
;
755 v
->value_int_4
[3] = ctx
->Scissor
.ScissorArray
[0].Height
;
758 case GL_SCISSOR_TEST
:
759 v
->value_bool
= ctx
->Scissor
.EnableFlags
& 1;
764 ctx
->ListState
.CurrentList
? ctx
->ListState
.CurrentList
->Name
: 0;
767 if (!ctx
->CompileFlag
)
769 else if (ctx
->ExecuteFlag
)
770 v
->value_enum
= GL_COMPILE_AND_EXECUTE
;
772 v
->value_enum
= GL_COMPILE
;
776 v
->value_float_4
[0] = ctx
->ViewportArray
[0].X
;
777 v
->value_float_4
[1] = ctx
->ViewportArray
[0].Y
;
778 v
->value_float_4
[2] = ctx
->ViewportArray
[0].Width
;
779 v
->value_float_4
[3] = ctx
->ViewportArray
[0].Height
;
783 v
->value_double_2
[0] = ctx
->ViewportArray
[0].Near
;
784 v
->value_double_2
[1] = ctx
->ViewportArray
[0].Far
;
787 case GL_ACTIVE_STENCIL_FACE_EXT
:
788 v
->value_enum
= ctx
->Stencil
.ActiveFace
? GL_BACK
: GL_FRONT
;
791 case GL_STENCIL_FAIL
:
792 v
->value_enum
= ctx
->Stencil
.FailFunc
[ctx
->Stencil
.ActiveFace
];
794 case GL_STENCIL_FUNC
:
795 v
->value_enum
= ctx
->Stencil
.Function
[ctx
->Stencil
.ActiveFace
];
797 case GL_STENCIL_PASS_DEPTH_FAIL
:
798 v
->value_enum
= ctx
->Stencil
.ZFailFunc
[ctx
->Stencil
.ActiveFace
];
800 case GL_STENCIL_PASS_DEPTH_PASS
:
801 v
->value_enum
= ctx
->Stencil
.ZPassFunc
[ctx
->Stencil
.ActiveFace
];
804 v
->value_int
= _mesa_get_stencil_ref(ctx
, ctx
->Stencil
.ActiveFace
);
806 case GL_STENCIL_BACK_REF
:
807 v
->value_int
= _mesa_get_stencil_ref(ctx
, 1);
809 case GL_STENCIL_VALUE_MASK
:
810 v
->value_int
= ctx
->Stencil
.ValueMask
[ctx
->Stencil
.ActiveFace
];
812 case GL_STENCIL_WRITEMASK
:
813 v
->value_int
= ctx
->Stencil
.WriteMask
[ctx
->Stencil
.ActiveFace
];
816 case GL_NUM_EXTENSIONS
:
817 v
->value_int
= _mesa_get_extension_count(ctx
);
820 case GL_IMPLEMENTATION_COLOR_READ_TYPE_OES
:
821 v
->value_int
= _mesa_get_color_read_type(ctx
, NULL
, "glGetIntegerv");
823 case GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES
:
824 v
->value_int
= _mesa_get_color_read_format(ctx
, NULL
, "glGetIntegerv");
827 case GL_CURRENT_MATRIX_STACK_DEPTH_ARB
:
828 v
->value_int
= ctx
->CurrentStack
->Depth
+ 1;
830 case GL_CURRENT_MATRIX_ARB
:
831 case GL_TRANSPOSE_CURRENT_MATRIX_ARB
:
832 v
->value_matrix
= ctx
->CurrentStack
->Top
;
835 case GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB
:
836 v
->value_int
= _mesa_get_compressed_formats(ctx
, NULL
);
838 case GL_COMPRESSED_TEXTURE_FORMATS_ARB
:
840 _mesa_get_compressed_formats(ctx
, v
->value_int_n
.ints
);
841 assert(v
->value_int_n
.n
<= (int) ARRAY_SIZE(v
->value_int_n
.ints
));
844 case GL_MAX_VARYING_FLOATS_ARB
:
845 v
->value_int
= ctx
->Const
.MaxVarying
* 4;
848 /* Various object names */
850 case GL_TEXTURE_BINDING_1D
:
851 case GL_TEXTURE_BINDING_2D
:
852 case GL_TEXTURE_BINDING_3D
:
853 case GL_TEXTURE_BINDING_1D_ARRAY_EXT
:
854 case GL_TEXTURE_BINDING_2D_ARRAY_EXT
:
855 case GL_TEXTURE_BINDING_CUBE_MAP_ARB
:
856 case GL_TEXTURE_BINDING_RECTANGLE_NV
:
857 case GL_TEXTURE_BINDING_EXTERNAL_OES
:
858 case GL_TEXTURE_BINDING_CUBE_MAP_ARRAY
:
859 case GL_TEXTURE_BINDING_2D_MULTISAMPLE
:
860 case GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY
:
861 unit
= ctx
->Texture
.CurrentUnit
;
863 ctx
->Texture
.Unit
[unit
].CurrentTex
[d
->offset
]->Name
;
866 /* GL_EXT_external_objects */
867 case GL_DRIVER_UUID_EXT
:
868 _mesa_get_driver_uuid(ctx
, v
->value_int_4
);
870 case GL_DEVICE_UUID_EXT
:
871 _mesa_get_device_uuid(ctx
, v
->value_int_4
);
874 /* GL_EXT_packed_float */
875 case GL_RGBA_SIGNED_COMPONENTS_EXT
:
877 /* Note: we only check the 0th color attachment. */
878 const struct gl_renderbuffer
*rb
=
879 ctx
->DrawBuffer
->_ColorDrawBuffers
[0];
880 if (rb
&& _mesa_is_format_signed(rb
->Format
)) {
881 /* Issue 17 of GL_EXT_packed_float: If a component (such as
882 * alpha) has zero bits, the component should not be considered
883 * signed and so the bit for the respective component should be
887 _mesa_get_format_bits(rb
->Format
, GL_RED_BITS
);
889 _mesa_get_format_bits(rb
->Format
, GL_GREEN_BITS
);
891 _mesa_get_format_bits(rb
->Format
, GL_BLUE_BITS
);
893 _mesa_get_format_bits(rb
->Format
, GL_ALPHA_BITS
);
895 _mesa_get_format_bits(rb
->Format
, GL_TEXTURE_LUMINANCE_SIZE
);
897 _mesa_get_format_bits(rb
->Format
, GL_TEXTURE_INTENSITY_SIZE
);
899 v
->value_int_4
[0] = r_bits
+ l_bits
+ i_bits
> 0;
900 v
->value_int_4
[1] = g_bits
+ l_bits
+ i_bits
> 0;
901 v
->value_int_4
[2] = b_bits
+ l_bits
+ i_bits
> 0;
902 v
->value_int_4
[3] = a_bits
+ i_bits
> 0;
908 v
->value_int_4
[3] = 0;
913 /* GL_ARB_vertex_buffer_object */
914 case GL_VERTEX_ARRAY_BUFFER_BINDING_ARB
:
915 case GL_NORMAL_ARRAY_BUFFER_BINDING_ARB
:
916 case GL_COLOR_ARRAY_BUFFER_BINDING_ARB
:
917 case GL_INDEX_ARRAY_BUFFER_BINDING_ARB
:
918 case GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB
:
919 case GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB
:
920 case GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB
:
921 buffer_obj
= (struct gl_buffer_object
**)
922 ((char *) ctx
->Array
.VAO
+ d
->offset
);
923 v
->value_int
= (*buffer_obj
)->Name
;
925 case GL_ARRAY_BUFFER_BINDING_ARB
:
926 v
->value_int
= ctx
->Array
.ArrayBufferObj
->Name
;
928 case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB
:
930 ctx
->Array
.VAO
->BufferBinding
[VERT_ATTRIB_TEX(ctx
->Array
.ActiveTexture
)].BufferObj
->Name
;
932 case GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB
:
933 v
->value_int
= ctx
->Array
.VAO
->IndexBufferObj
->Name
;
936 /* ARB_vertex_array_bgra */
937 case GL_COLOR_ARRAY_SIZE
:
938 array
= &ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_COLOR0
];
939 v
->value_int
= array
->Format
== GL_BGRA
? GL_BGRA
: array
->Size
;
941 case GL_SECONDARY_COLOR_ARRAY_SIZE
:
942 array
= &ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_COLOR1
];
943 v
->value_int
= array
->Format
== GL_BGRA
? GL_BGRA
: array
->Size
;
946 /* ARB_copy_buffer */
947 case GL_COPY_READ_BUFFER
:
948 v
->value_int
= ctx
->CopyReadBuffer
->Name
;
950 case GL_COPY_WRITE_BUFFER
:
951 v
->value_int
= ctx
->CopyWriteBuffer
->Name
;
954 case GL_PIXEL_PACK_BUFFER_BINDING_EXT
:
955 v
->value_int
= ctx
->Pack
.BufferObj
->Name
;
957 case GL_PIXEL_UNPACK_BUFFER_BINDING_EXT
:
958 v
->value_int
= ctx
->Unpack
.BufferObj
->Name
;
960 case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING
:
961 v
->value_int
= ctx
->TransformFeedback
.CurrentBuffer
->Name
;
963 case GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED
:
964 v
->value_int
= ctx
->TransformFeedback
.CurrentObject
->Paused
;
966 case GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE
:
967 v
->value_int
= ctx
->TransformFeedback
.CurrentObject
->Active
;
969 case GL_TRANSFORM_FEEDBACK_BINDING
:
970 v
->value_int
= ctx
->TransformFeedback
.CurrentObject
->Name
;
972 case GL_CURRENT_PROGRAM
:
973 /* The Changelog of the ARB_separate_shader_objects spec says:
975 * 24 25 Jul 2011 pbrown Remove the language erroneously deleting
976 * CURRENT_PROGRAM. In the EXT extension, this
977 * token was aliased to ACTIVE_PROGRAM_EXT, and
978 * was used to indicate the last program set by
979 * either ActiveProgramEXT or UseProgram. In
980 * the ARB extension, the SSO active programs
981 * are now program pipeline object state and
982 * CURRENT_PROGRAM should still be used to query
983 * the last program set by UseProgram (bug 7822).
986 ctx
->Shader
.ActiveProgram
? ctx
->Shader
.ActiveProgram
->Name
: 0;
988 case GL_READ_FRAMEBUFFER_BINDING_EXT
:
989 v
->value_int
= ctx
->ReadBuffer
->Name
;
991 case GL_RENDERBUFFER_BINDING_EXT
:
993 ctx
->CurrentRenderbuffer
? ctx
->CurrentRenderbuffer
->Name
: 0;
995 case GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES
:
996 v
->value_int
= ctx
->Array
.VAO
->BufferBinding
[VERT_ATTRIB_POINT_SIZE
].BufferObj
->Name
;
1000 if (_mesa_get_clamp_fragment_color(ctx
, ctx
->DrawBuffer
))
1001 COPY_4FV(v
->value_float_4
, ctx
->Fog
.Color
);
1003 COPY_4FV(v
->value_float_4
, ctx
->Fog
.ColorUnclamped
);
1005 case GL_COLOR_CLEAR_VALUE
:
1006 if (_mesa_get_clamp_fragment_color(ctx
, ctx
->DrawBuffer
)) {
1007 v
->value_float_4
[0] = CLAMP(ctx
->Color
.ClearColor
.f
[0], 0.0F
, 1.0F
);
1008 v
->value_float_4
[1] = CLAMP(ctx
->Color
.ClearColor
.f
[1], 0.0F
, 1.0F
);
1009 v
->value_float_4
[2] = CLAMP(ctx
->Color
.ClearColor
.f
[2], 0.0F
, 1.0F
);
1010 v
->value_float_4
[3] = CLAMP(ctx
->Color
.ClearColor
.f
[3], 0.0F
, 1.0F
);
1012 COPY_4FV(v
->value_float_4
, ctx
->Color
.ClearColor
.f
);
1014 case GL_BLEND_COLOR_EXT
:
1015 if (_mesa_get_clamp_fragment_color(ctx
, ctx
->DrawBuffer
))
1016 COPY_4FV(v
->value_float_4
, ctx
->Color
.BlendColor
);
1018 COPY_4FV(v
->value_float_4
, ctx
->Color
.BlendColorUnclamped
);
1020 case GL_ALPHA_TEST_REF
:
1021 if (_mesa_get_clamp_fragment_color(ctx
, ctx
->DrawBuffer
))
1022 v
->value_float
= ctx
->Color
.AlphaRef
;
1024 v
->value_float
= ctx
->Color
.AlphaRefUnclamped
;
1026 case GL_MAX_VERTEX_UNIFORM_VECTORS
:
1027 v
->value_int
= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxUniformComponents
/ 4;
1030 case GL_MAX_FRAGMENT_UNIFORM_VECTORS
:
1031 v
->value_int
= ctx
->Const
.Program
[MESA_SHADER_FRAGMENT
].MaxUniformComponents
/ 4;
1034 /* GL_ARB_texture_buffer_object */
1035 case GL_TEXTURE_BUFFER_ARB
:
1036 v
->value_int
= ctx
->Texture
.BufferObject
->Name
;
1038 case GL_TEXTURE_BINDING_BUFFER_ARB
:
1039 unit
= ctx
->Texture
.CurrentUnit
;
1041 ctx
->Texture
.Unit
[unit
].CurrentTex
[TEXTURE_BUFFER_INDEX
]->Name
;
1043 case GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB
:
1045 struct gl_buffer_object
*buf
=
1046 ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
]
1047 .CurrentTex
[TEXTURE_BUFFER_INDEX
]->BufferObject
;
1048 v
->value_int
= buf
? buf
->Name
: 0;
1051 case GL_TEXTURE_BUFFER_FORMAT_ARB
:
1052 v
->value_int
= ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
]
1053 .CurrentTex
[TEXTURE_BUFFER_INDEX
]->BufferObjectFormat
;
1056 /* GL_ARB_sampler_objects */
1057 case GL_SAMPLER_BINDING
:
1059 struct gl_sampler_object
*samp
=
1060 ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
].Sampler
;
1061 v
->value_int
= samp
? samp
->Name
: 0;
1064 /* GL_ARB_uniform_buffer_object */
1065 case GL_UNIFORM_BUFFER_BINDING
:
1066 v
->value_int
= ctx
->UniformBuffer
->Name
;
1068 /* GL_ARB_shader_storage_buffer_object */
1069 case GL_SHADER_STORAGE_BUFFER_BINDING
:
1070 v
->value_int
= ctx
->ShaderStorageBuffer
->Name
;
1072 /* GL_ARB_query_buffer_object */
1073 case GL_QUERY_BUFFER_BINDING
:
1074 v
->value_int
= ctx
->QueryBuffer
->Name
;
1076 /* GL_ARB_timer_query */
1078 if (ctx
->Driver
.GetTimestamp
) {
1079 v
->value_int64
= ctx
->Driver
.GetTimestamp(ctx
);
1082 _mesa_problem(ctx
, "driver doesn't implement GetTimestamp");
1086 case GL_DEBUG_OUTPUT
:
1087 case GL_DEBUG_OUTPUT_SYNCHRONOUS
:
1088 case GL_DEBUG_LOGGED_MESSAGES
:
1089 case GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH
:
1090 case GL_DEBUG_GROUP_STACK_DEPTH
:
1091 v
->value_int
= _mesa_get_debug_state_int(ctx
, d
->pname
);
1093 /* GL_ARB_shader_atomic_counters */
1094 case GL_ATOMIC_COUNTER_BUFFER_BINDING
:
1095 if (ctx
->AtomicBuffer
) {
1096 v
->value_int
= ctx
->AtomicBuffer
->Name
;
1102 case GL_NUM_SHADING_LANGUAGE_VERSIONS
:
1103 v
->value_int
= _mesa_get_shading_language_version(ctx
, -1, NULL
);
1105 /* GL_ARB_draw_indirect */
1106 case GL_DRAW_INDIRECT_BUFFER_BINDING
:
1107 v
->value_int
= ctx
->DrawIndirectBuffer
->Name
;
1109 /* GL_ARB_indirect_parameters */
1110 case GL_PARAMETER_BUFFER_BINDING_ARB
:
1111 v
->value_int
= ctx
->ParameterBuffer
->Name
;
1113 /* GL_ARB_separate_shader_objects */
1114 case GL_PROGRAM_PIPELINE_BINDING
:
1115 if (ctx
->Pipeline
.Current
) {
1116 v
->value_int
= ctx
->Pipeline
.Current
->Name
;
1121 /* GL_ARB_compute_shader */
1122 case GL_DISPATCH_INDIRECT_BUFFER_BINDING
:
1123 v
->value_int
= ctx
->DispatchIndirectBuffer
->Name
;
1125 /* GL_ARB_multisample */
1127 v
->value_int
= _mesa_geometric_samples(ctx
->DrawBuffer
);
1129 case GL_SAMPLE_BUFFERS
:
1130 v
->value_int
= _mesa_geometric_samples(ctx
->DrawBuffer
) > 0;
1132 /* GL_EXT_textrue_integer */
1133 case GL_RGBA_INTEGER_MODE_EXT
:
1134 v
->value_int
= (ctx
->DrawBuffer
->_IntegerBuffers
!= 0);
1136 /* GL_ATI_meminfo & GL_NVX_gpu_memory_info */
1137 case GL_VBO_FREE_MEMORY_ATI
:
1138 case GL_TEXTURE_FREE_MEMORY_ATI
:
1139 case GL_RENDERBUFFER_FREE_MEMORY_ATI
:
1140 case GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX
:
1141 case GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX
:
1142 case GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX
:
1143 case GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX
:
1144 case GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX
:
1146 struct gl_memory_info info
;
1148 ctx
->Driver
.QueryMemoryInfo(ctx
, &info
);
1150 if (d
->pname
== GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX
)
1151 v
->value_int
= info
.total_device_memory
;
1152 else if (d
->pname
== GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX
)
1153 v
->value_int
= info
.total_device_memory
+
1154 info
.total_staging_memory
;
1155 else if (d
->pname
== GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX
)
1156 v
->value_int
= info
.avail_device_memory
;
1157 else if (d
->pname
== GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX
)
1158 v
->value_int
= info
.nr_device_memory_evictions
;
1159 else if (d
->pname
== GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX
)
1160 v
->value_int
= info
.device_memory_evicted
;
1162 /* ATI free memory enums.
1164 * Since the GPU memory is (usually) page-table based, every two
1165 * consecutive elements are equal. From the GL_ATI_meminfo
1168 * "param[0] - total memory free in the pool
1169 * param[1] - largest available free block in the pool
1170 * param[2] - total auxiliary memory free
1171 * param[3] - largest auxiliary free block"
1173 * All three (VBO, TEXTURE, RENDERBUFFER) queries return
1174 * the same numbers here.
1176 v
->value_int_4
[0] = info
.avail_device_memory
;
1177 v
->value_int_4
[1] = info
.avail_device_memory
;
1178 v
->value_int_4
[2] = info
.avail_staging_memory
;
1179 v
->value_int_4
[3] = info
.avail_staging_memory
;
1184 /* GL_ARB_get_program_binary */
1185 case GL_PROGRAM_BINARY_FORMATS
:
1186 assert(ctx
->Const
.NumProgramBinaryFormats
<= 1);
1187 v
->value_int_n
.n
= MIN2(ctx
->Const
.NumProgramBinaryFormats
, 1);
1188 if (ctx
->Const
.NumProgramBinaryFormats
> 0) {
1189 v
->value_int_n
.ints
[0] = GL_PROGRAM_BINARY_FORMAT_MESA
;
1192 /* GL_EXT_disjoint_timer_query */
1193 case GL_GPU_DISJOINT_EXT
:
1195 simple_mtx_lock(&ctx
->Shared
->Mutex
);
1196 v
->value_int
= ctx
->Shared
->DisjointOperation
;
1197 /* Reset state as expected by the spec. */
1198 ctx
->Shared
->DisjointOperation
= false;
1199 simple_mtx_unlock(&ctx
->Shared
->Mutex
);
1202 /* GL_ARB_sample_locations */
1203 case GL_SAMPLE_LOCATION_SUBPIXEL_BITS_ARB
:
1204 case GL_SAMPLE_LOCATION_PIXEL_GRID_WIDTH_ARB
:
1205 case GL_SAMPLE_LOCATION_PIXEL_GRID_HEIGHT_ARB
:
1207 GLuint bits
, width
, height
;
1209 if (ctx
->NewState
& _NEW_BUFFERS
)
1210 _mesa_update_state(ctx
);
1212 if (ctx
->DrawBuffer
->_Status
!= GL_FRAMEBUFFER_COMPLETE
) {
1217 ctx
->Driver
.GetProgrammableSampleCaps(ctx
, ctx
->DrawBuffer
,
1218 &bits
, &width
, &height
);
1220 if (d
->pname
== GL_SAMPLE_LOCATION_PIXEL_GRID_WIDTH_ARB
)
1221 v
->value_uint
= width
;
1222 else if (d
->pname
== GL_SAMPLE_LOCATION_PIXEL_GRID_HEIGHT_ARB
)
1223 v
->value_uint
= height
;
1225 v
->value_uint
= bits
;
1228 case GL_PROGRAMMABLE_SAMPLE_LOCATION_TABLE_SIZE_ARB
:
1229 v
->value_uint
= MAX_SAMPLE_LOCATION_TABLE_SIZE
;
1235 * Check extra constraints on a struct value_desc descriptor
1237 * If a struct value_desc has a non-NULL extra pointer, it means that
1238 * there are a number of extra constraints to check or actions to
1239 * perform. The extras is just an integer array where each integer
1240 * encode different constraints or actions.
1242 * \param ctx current context
1243 * \param func name of calling glGet*v() function for error reporting
1244 * \param d the struct value_desc that has the extra constraints
1246 * \return GL_FALSE if all of the constraints were not satisfied,
1247 * otherwise GL_TRUE.
1250 check_extra(struct gl_context
*ctx
, const char *func
, const struct value_desc
*d
)
1252 const GLuint version
= ctx
->Version
;
1253 GLboolean api_check
= GL_FALSE
;
1254 GLboolean api_found
= GL_FALSE
;
1257 for (e
= d
->extra
; *e
!= EXTRA_END
; e
++) {
1259 case EXTRA_VERSION_30
:
1260 api_check
= GL_TRUE
;
1262 api_found
= GL_TRUE
;
1264 case EXTRA_VERSION_31
:
1265 api_check
= GL_TRUE
;
1267 api_found
= GL_TRUE
;
1269 case EXTRA_VERSION_32
:
1270 api_check
= GL_TRUE
;
1272 api_found
= GL_TRUE
;
1274 case EXTRA_VERSION_40
:
1275 api_check
= GL_TRUE
;
1277 api_found
= GL_TRUE
;
1279 case EXTRA_VERSION_43
:
1281 if (_mesa_is_desktop_gl(ctx
) && version
>= 43)
1282 api_found
= GL_TRUE
;
1284 case EXTRA_NEW_FRAG_CLAMP
:
1285 if (ctx
->NewState
& (_NEW_BUFFERS
| _NEW_FRAG_CLAMP
))
1286 _mesa_update_state(ctx
);
1289 api_check
= GL_TRUE
;
1290 if (ctx
->API
== API_OPENGLES2
)
1291 api_found
= GL_TRUE
;
1294 api_check
= GL_TRUE
;
1295 if (_mesa_is_gles3(ctx
))
1296 api_found
= GL_TRUE
;
1298 case EXTRA_API_ES31
:
1299 api_check
= GL_TRUE
;
1300 if (_mesa_is_gles31(ctx
))
1301 api_found
= GL_TRUE
;
1303 case EXTRA_API_ES32
:
1304 api_check
= GL_TRUE
;
1305 if (_mesa_is_gles32(ctx
))
1306 api_found
= GL_TRUE
;
1309 api_check
= GL_TRUE
;
1310 if (_mesa_is_desktop_gl(ctx
))
1311 api_found
= GL_TRUE
;
1313 case EXTRA_API_GL_CORE
:
1314 api_check
= GL_TRUE
;
1315 if (ctx
->API
== API_OPENGL_CORE
)
1316 api_found
= GL_TRUE
;
1318 case EXTRA_NEW_BUFFERS
:
1319 if (ctx
->NewState
& _NEW_BUFFERS
)
1320 _mesa_update_state(ctx
);
1322 case EXTRA_FLUSH_CURRENT
:
1323 FLUSH_CURRENT(ctx
, 0);
1325 case EXTRA_VALID_DRAW_BUFFER
:
1326 if (d
->pname
- GL_DRAW_BUFFER0_ARB
>= ctx
->Const
.MaxDrawBuffers
) {
1327 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(draw buffer %u)",
1328 func
, d
->pname
- GL_DRAW_BUFFER0_ARB
);
1332 case EXTRA_VALID_TEXTURE_UNIT
:
1333 if (ctx
->Texture
.CurrentUnit
>= ctx
->Const
.MaxTextureCoordUnits
) {
1334 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(texture %u)",
1335 func
, ctx
->Texture
.CurrentUnit
);
1339 case EXTRA_VALID_CLIP_DISTANCE
:
1340 if (d
->pname
- GL_CLIP_DISTANCE0
>= ctx
->Const
.MaxClipPlanes
) {
1341 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(clip distance %u)",
1342 func
, d
->pname
- GL_CLIP_DISTANCE0
);
1346 case EXTRA_GLSL_130
:
1347 api_check
= GL_TRUE
;
1348 if (ctx
->Const
.GLSLVersion
>= 130)
1349 api_found
= GL_TRUE
;
1351 case EXTRA_EXT_UBO_GS
:
1352 api_check
= GL_TRUE
;
1353 if (ctx
->Extensions
.ARB_uniform_buffer_object
&&
1354 _mesa_has_geometry_shaders(ctx
))
1355 api_found
= GL_TRUE
;
1357 case EXTRA_EXT_ATOMICS_GS
:
1358 api_check
= GL_TRUE
;
1359 if (ctx
->Extensions
.ARB_shader_atomic_counters
&&
1360 _mesa_has_geometry_shaders(ctx
))
1361 api_found
= GL_TRUE
;
1363 case EXTRA_EXT_SHADER_IMAGE_GS
:
1364 api_check
= GL_TRUE
;
1365 if (ctx
->Extensions
.ARB_shader_image_load_store
&&
1366 _mesa_has_geometry_shaders(ctx
))
1367 api_found
= GL_TRUE
;
1369 case EXTRA_EXT_ATOMICS_TESS
:
1370 api_check
= GL_TRUE
;
1371 api_found
= ctx
->Extensions
.ARB_shader_atomic_counters
&&
1372 _mesa_has_tessellation(ctx
);
1374 case EXTRA_EXT_SHADER_IMAGE_TESS
:
1375 api_check
= GL_TRUE
;
1376 api_found
= ctx
->Extensions
.ARB_shader_image_load_store
&&
1377 _mesa_has_tessellation(ctx
);
1379 case EXTRA_EXT_SSBO_GS
:
1380 api_check
= GL_TRUE
;
1381 if (ctx
->Extensions
.ARB_shader_storage_buffer_object
&&
1382 _mesa_has_geometry_shaders(ctx
))
1383 api_found
= GL_TRUE
;
1385 case EXTRA_EXT_FB_NO_ATTACH_GS
:
1386 api_check
= GL_TRUE
;
1387 if (ctx
->Extensions
.ARB_framebuffer_no_attachments
&&
1388 (_mesa_is_desktop_gl(ctx
) ||
1389 _mesa_has_OES_geometry_shader(ctx
)))
1390 api_found
= GL_TRUE
;
1392 case EXTRA_EXT_ES_GS
:
1393 api_check
= GL_TRUE
;
1394 if (_mesa_has_OES_geometry_shader(ctx
))
1395 api_found
= GL_TRUE
;
1397 case EXTRA_EXT_PROVOKING_VERTEX_32
:
1399 if (ctx
->API
== API_OPENGL_COMPAT
|| version
== 32)
1400 api_found
= ctx
->Extensions
.EXT_provoking_vertex
;
1404 default: /* *e is a offset into the extension struct */
1405 api_check
= GL_TRUE
;
1406 if (*(GLboolean
*) ((char *) &ctx
->Extensions
+ *e
))
1407 api_found
= GL_TRUE
;
1412 if (api_check
&& !api_found
) {
1413 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(pname=%s)", func
,
1414 _mesa_enum_to_string(d
->pname
));
1421 static const struct value_desc error_value
=
1422 { 0, 0, TYPE_INVALID
, NO_OFFSET
, NO_EXTRA
};
1425 * Find the struct value_desc corresponding to the enum 'pname'.
1427 * We hash the enum value to get an index into the 'table' array,
1428 * which holds the index in the 'values' array of struct value_desc.
1429 * Once we've found the entry, we do the extra checks, if any, then
1430 * look up the value and return a pointer to it.
1432 * If the value has to be computed (for example, it's the result of a
1433 * function call or we need to add 1 to it), we use the tmp 'v' to
1436 * \param func name of glGet*v() func for error reporting
1437 * \param pname the enum value we're looking up
1438 * \param p is were we return the pointer to the value
1439 * \param v a tmp union value variable in the calling glGet*v() function
1441 * \return the struct value_desc corresponding to the enum or a struct
1442 * value_desc of TYPE_INVALID if not found. This lets the calling
1443 * glGet*v() function jump right into a switch statement and
1444 * handle errors there instead of having to check for NULL.
1446 static const struct value_desc
*
1447 find_value(const char *func
, GLenum pname
, void **p
, union value
*v
)
1449 GET_CURRENT_CONTEXT(ctx
);
1451 const struct value_desc
*d
;
1455 /* We index into the table_set[] list of per-API hash tables using the API's
1456 * value in the gl_api enum. Since GLES 3 doesn't have an API_OPENGL* enum
1457 * value since it's compatible with GLES2 its entry in table_set[] is at the
1460 STATIC_ASSERT(ARRAY_SIZE(table_set
) == API_OPENGL_LAST
+ 4);
1461 if (ctx
->API
== API_OPENGLES2
) {
1462 if (ctx
->Version
>= 32)
1463 api
= API_OPENGL_LAST
+ 3;
1464 else if (ctx
->Version
>= 31)
1465 api
= API_OPENGL_LAST
+ 2;
1466 else if (ctx
->Version
>= 30)
1467 api
= API_OPENGL_LAST
+ 1;
1469 mask
= ARRAY_SIZE(table(api
)) - 1;
1470 hash
= (pname
* prime_factor
);
1472 int idx
= table(api
)[hash
& mask
];
1474 /* If the enum isn't valid, the hash walk ends with index 0,
1475 * pointing to the first entry of values[] which doesn't hold
1476 * any valid enum. */
1477 if (unlikely(idx
== 0)) {
1478 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(pname=%s)", func
,
1479 _mesa_enum_to_string(pname
));
1480 return &error_value
;
1484 if (likely(d
->pname
== pname
))
1490 if (unlikely(d
->extra
&& !check_extra(ctx
, func
, d
)))
1491 return &error_value
;
1493 switch (d
->location
) {
1495 *p
= ((char *) ctx
->DrawBuffer
+ d
->offset
);
1498 *p
= ((char *) ctx
+ d
->offset
);
1501 *p
= ((char *) ctx
->Array
.VAO
+ d
->offset
);
1504 if (ctx
->Texture
.CurrentUnit
< ARRAY_SIZE(ctx
->Texture
.FixedFuncUnit
)) {
1505 unsigned index
= ctx
->Texture
.CurrentUnit
;
1506 *p
= ((char *)&ctx
->Texture
.FixedFuncUnit
[index
] + d
->offset
);
1510 find_custom_value(ctx
, d
, v
);
1518 /* silence warning */
1519 return &error_value
;
1522 static const int transpose
[] = {
1530 get_value_size(enum value_type type
, const union value
*v
)
1538 return sizeof(GLint
);
1541 return sizeof(GLint
) * 2;
1544 return sizeof(GLint
) * 3;
1547 return sizeof(GLint
) * 4;
1549 return sizeof(GLint
) * v
->value_int_n
.n
;
1551 return sizeof(GLint64
);
1554 return sizeof(GLenum16
);
1556 return sizeof(GLenum
);
1558 return sizeof(GLenum
) * 2;
1560 return sizeof(GLboolean
);
1562 return sizeof(GLubyte
);
1564 return sizeof(GLshort
);
1576 return sizeof(GLfloat
);
1579 return sizeof(GLfloat
) * 2;
1582 return sizeof(GLfloat
) * 3;
1585 return sizeof(GLfloat
) * 4;
1587 return sizeof(GLfloat
) * 8;
1589 return sizeof(GLdouble
);
1590 case TYPE_DOUBLEN_2
:
1591 return sizeof(GLdouble
) * 2;
1593 return sizeof (GLfloat
) * 16;
1595 return sizeof (GLfloat
) * 16;
1602 _mesa_GetBooleanv(GLenum pname
, GLboolean
*params
)
1604 const struct value_desc
*d
;
1610 d
= find_value("glGetBooleanv", pname
, &p
, &v
);
1615 params
[0] = INT_TO_BOOLEAN(d
->offset
);
1619 params
[7] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[7]);
1620 params
[6] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[6]);
1621 params
[5] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[5]);
1622 params
[4] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[4]);
1625 params
[3] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[3]);
1628 params
[2] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[2]);
1631 params
[1] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[1]);
1634 params
[0] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[0]);
1637 case TYPE_DOUBLEN_2
:
1638 params
[1] = FLOAT_TO_BOOLEAN(((GLdouble
*) p
)[1]);
1640 params
[0] = FLOAT_TO_BOOLEAN(((GLdouble
*) p
)[0]);
1645 params
[3] = INT_TO_BOOLEAN(((GLint
*) p
)[3]);
1648 params
[2] = INT_TO_BOOLEAN(((GLint
*) p
)[2]);
1652 params
[1] = INT_TO_BOOLEAN(((GLint
*) p
)[1]);
1656 params
[0] = INT_TO_BOOLEAN(((GLint
*) p
)[0]);
1660 params
[0] = INT_TO_BOOLEAN(((GLenum16
*) p
)[0]);
1664 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
1665 params
[i
] = INT_TO_BOOLEAN(v
.value_int_n
.ints
[i
]);
1669 params
[0] = INT64_TO_BOOLEAN(((GLint64
*) p
)[0]);
1673 params
[0] = ((GLboolean
*) p
)[0];
1677 params
[0] = INT_TO_BOOLEAN(((GLubyte
*) p
)[0]);
1681 params
[0] = INT_TO_BOOLEAN(((GLshort
*) p
)[0]);
1685 m
= *(GLmatrix
**) p
;
1686 for (i
= 0; i
< 16; i
++)
1687 params
[i
] = FLOAT_TO_BOOLEAN(m
->m
[i
]);
1691 m
= *(GLmatrix
**) p
;
1692 for (i
= 0; i
< 16; i
++)
1693 params
[i
] = FLOAT_TO_BOOLEAN(m
->m
[transpose
[i
]]);
1704 shift
= d
->type
- TYPE_BIT_0
;
1705 params
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
1711 _mesa_GetFloatv(GLenum pname
, GLfloat
*params
)
1713 const struct value_desc
*d
;
1719 d
= find_value("glGetFloatv", pname
, &p
, &v
);
1724 params
[0] = (GLfloat
) d
->offset
;
1728 params
[7] = ((GLfloat
*) p
)[7];
1729 params
[6] = ((GLfloat
*) p
)[6];
1730 params
[5] = ((GLfloat
*) p
)[5];
1731 params
[4] = ((GLfloat
*) p
)[4];
1734 params
[3] = ((GLfloat
*) p
)[3];
1737 params
[2] = ((GLfloat
*) p
)[2];
1740 params
[1] = ((GLfloat
*) p
)[1];
1743 params
[0] = ((GLfloat
*) p
)[0];
1746 case TYPE_DOUBLEN_2
:
1747 params
[1] = (GLfloat
) (((GLdouble
*) p
)[1]);
1749 params
[0] = (GLfloat
) (((GLdouble
*) p
)[0]);
1753 params
[3] = (GLfloat
) (((GLint
*) p
)[3]);
1755 params
[2] = (GLfloat
) (((GLint
*) p
)[2]);
1758 params
[1] = (GLfloat
) (((GLint
*) p
)[1]);
1761 params
[0] = (GLfloat
) (((GLint
*) p
)[0]);
1765 params
[0] = (GLfloat
) (((GLenum16
*) p
)[0]);
1769 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
1770 params
[i
] = (GLfloat
) v
.value_int_n
.ints
[i
];
1774 params
[3] = (GLfloat
) (((GLuint
*) p
)[3]);
1776 params
[2] = (GLfloat
) (((GLuint
*) p
)[2]);
1778 params
[1] = (GLfloat
) (((GLuint
*) p
)[1]);
1780 params
[0] = (GLfloat
) (((GLuint
*) p
)[0]);
1784 params
[0] = (GLfloat
) (((GLint64
*) p
)[0]);
1788 params
[0] = BOOLEAN_TO_FLOAT(*(GLboolean
*) p
);
1792 params
[0] = (GLfloat
) ((GLubyte
*) p
)[0];
1796 params
[0] = (GLfloat
) ((GLshort
*) p
)[0];
1800 m
= *(GLmatrix
**) p
;
1801 for (i
= 0; i
< 16; i
++)
1802 params
[i
] = m
->m
[i
];
1806 m
= *(GLmatrix
**) p
;
1807 for (i
= 0; i
< 16; i
++)
1808 params
[i
] = m
->m
[transpose
[i
]];
1819 shift
= d
->type
- TYPE_BIT_0
;
1820 params
[0] = BOOLEAN_TO_FLOAT((*(GLbitfield
*) p
>> shift
) & 1);
1826 _mesa_GetIntegerv(GLenum pname
, GLint
*params
)
1828 const struct value_desc
*d
;
1834 d
= find_value("glGetIntegerv", pname
, &p
, &v
);
1839 params
[0] = d
->offset
;
1843 params
[7] = IROUND(((GLfloat
*) p
)[7]);
1844 params
[6] = IROUND(((GLfloat
*) p
)[6]);
1845 params
[5] = IROUND(((GLfloat
*) p
)[5]);
1846 params
[4] = IROUND(((GLfloat
*) p
)[4]);
1848 params
[3] = IROUND(((GLfloat
*) p
)[3]);
1850 params
[2] = IROUND(((GLfloat
*) p
)[2]);
1852 params
[1] = IROUND(((GLfloat
*) p
)[1]);
1854 params
[0] = IROUND(((GLfloat
*) p
)[0]);
1858 params
[3] = FLOAT_TO_INT(((GLfloat
*) p
)[3]);
1860 params
[2] = FLOAT_TO_INT(((GLfloat
*) p
)[2]);
1862 params
[1] = FLOAT_TO_INT(((GLfloat
*) p
)[1]);
1864 params
[0] = FLOAT_TO_INT(((GLfloat
*) p
)[0]);
1867 case TYPE_DOUBLEN_2
:
1868 params
[1] = FLOAT_TO_INT(((GLdouble
*) p
)[1]);
1870 params
[0] = FLOAT_TO_INT(((GLdouble
*) p
)[0]);
1875 params
[3] = ((GLint
*) p
)[3];
1878 params
[2] = ((GLint
*) p
)[2];
1882 params
[1] = ((GLint
*) p
)[1];
1886 params
[0] = ((GLint
*) p
)[0];
1890 params
[0] = ((GLenum16
*) p
)[0];
1894 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
1895 params
[i
] = v
.value_int_n
.ints
[i
];
1899 params
[0] = INT64_TO_INT(((GLint64
*) p
)[0]);
1903 params
[0] = BOOLEAN_TO_INT(*(GLboolean
*) p
);
1907 params
[0] = ((GLubyte
*) p
)[0];
1911 params
[0] = ((GLshort
*) p
)[0];
1915 m
= *(GLmatrix
**) p
;
1916 for (i
= 0; i
< 16; i
++)
1917 params
[i
] = FLOAT_TO_INT(m
->m
[i
]);
1921 m
= *(GLmatrix
**) p
;
1922 for (i
= 0; i
< 16; i
++)
1923 params
[i
] = FLOAT_TO_INT(m
->m
[transpose
[i
]]);
1934 shift
= d
->type
- TYPE_BIT_0
;
1935 params
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
1941 _mesa_GetInteger64v(GLenum pname
, GLint64
*params
)
1943 const struct value_desc
*d
;
1949 d
= find_value("glGetInteger64v", pname
, &p
, &v
);
1954 params
[0] = d
->offset
;
1958 params
[7] = IROUND64(((GLfloat
*) p
)[7]);
1959 params
[6] = IROUND64(((GLfloat
*) p
)[6]);
1960 params
[5] = IROUND64(((GLfloat
*) p
)[5]);
1961 params
[4] = IROUND64(((GLfloat
*) p
)[4]);
1963 params
[3] = IROUND64(((GLfloat
*) p
)[3]);
1965 params
[2] = IROUND64(((GLfloat
*) p
)[2]);
1967 params
[1] = IROUND64(((GLfloat
*) p
)[1]);
1969 params
[0] = IROUND64(((GLfloat
*) p
)[0]);
1973 params
[3] = FLOAT_TO_INT(((GLfloat
*) p
)[3]);
1975 params
[2] = FLOAT_TO_INT(((GLfloat
*) p
)[2]);
1977 params
[1] = FLOAT_TO_INT(((GLfloat
*) p
)[1]);
1979 params
[0] = FLOAT_TO_INT(((GLfloat
*) p
)[0]);
1982 case TYPE_DOUBLEN_2
:
1983 params
[1] = FLOAT_TO_INT(((GLdouble
*) p
)[1]);
1985 params
[0] = FLOAT_TO_INT(((GLdouble
*) p
)[0]);
1989 params
[3] = ((GLint
*) p
)[3];
1991 params
[2] = ((GLint
*) p
)[2];
1994 params
[1] = ((GLint
*) p
)[1];
1997 params
[0] = ((GLint
*) p
)[0];
2001 params
[0] = ((GLenum16
*) p
)[0];
2005 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
2006 params
[i
] = v
.value_int_n
.ints
[i
];
2010 params
[3] = ((GLuint
*) p
)[3];
2012 params
[2] = ((GLuint
*) p
)[2];
2014 params
[1] = ((GLuint
*) p
)[1];
2016 params
[0] = ((GLuint
*) p
)[0];
2020 params
[0] = ((GLint64
*) p
)[0];
2024 params
[0] = ((GLboolean
*) p
)[0];
2028 m
= *(GLmatrix
**) p
;
2029 for (i
= 0; i
< 16; i
++)
2030 params
[i
] = FLOAT_TO_INT64(m
->m
[i
]);
2034 m
= *(GLmatrix
**) p
;
2035 for (i
= 0; i
< 16; i
++)
2036 params
[i
] = FLOAT_TO_INT64(m
->m
[transpose
[i
]]);
2047 shift
= d
->type
- TYPE_BIT_0
;
2048 params
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
2054 _mesa_GetDoublev(GLenum pname
, GLdouble
*params
)
2056 const struct value_desc
*d
;
2062 d
= find_value("glGetDoublev", pname
, &p
, &v
);
2067 params
[0] = d
->offset
;
2071 params
[7] = ((GLfloat
*) p
)[7];
2072 params
[6] = ((GLfloat
*) p
)[6];
2073 params
[5] = ((GLfloat
*) p
)[5];
2074 params
[4] = ((GLfloat
*) p
)[4];
2077 params
[3] = ((GLfloat
*) p
)[3];
2080 params
[2] = ((GLfloat
*) p
)[2];
2083 params
[1] = ((GLfloat
*) p
)[1];
2086 params
[0] = ((GLfloat
*) p
)[0];
2089 case TYPE_DOUBLEN_2
:
2090 params
[1] = ((GLdouble
*) p
)[1];
2092 params
[0] = ((GLdouble
*) p
)[0];
2096 params
[3] = ((GLint
*) p
)[3];
2098 params
[2] = ((GLint
*) p
)[2];
2101 params
[1] = ((GLint
*) p
)[1];
2104 params
[0] = ((GLint
*) p
)[0];
2108 params
[0] = ((GLenum16
*) p
)[0];
2112 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
2113 params
[i
] = v
.value_int_n
.ints
[i
];
2117 params
[3] = ((GLuint
*) p
)[3];
2119 params
[2] = ((GLuint
*) p
)[2];
2121 params
[1] = ((GLuint
*) p
)[1];
2123 params
[0] = ((GLuint
*) p
)[0];
2127 params
[0] = (GLdouble
) (((GLint64
*) p
)[0]);
2131 params
[0] = *(GLboolean
*) p
;
2135 params
[0] = ((GLubyte
*) p
)[0];
2139 params
[0] = ((GLshort
*) p
)[0];
2143 m
= *(GLmatrix
**) p
;
2144 for (i
= 0; i
< 16; i
++)
2145 params
[i
] = m
->m
[i
];
2149 m
= *(GLmatrix
**) p
;
2150 for (i
= 0; i
< 16; i
++)
2151 params
[i
] = m
->m
[transpose
[i
]];
2162 shift
= d
->type
- TYPE_BIT_0
;
2163 params
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
2169 _mesa_GetUnsignedBytevEXT(GLenum pname
, GLubyte
*data
)
2171 const struct value_desc
*d
;
2176 const char *func
= "glGetUnsignedBytevEXT";
2178 GET_CURRENT_CONTEXT(ctx
);
2180 if (!ctx
->Extensions
.EXT_memory_object
) {
2181 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(unsupported)", func
);
2185 d
= find_value(func
, pname
, &p
, &v
);
2186 size
= get_value_size(d
->type
, &v
);
2188 _mesa_problem(ctx
, "invalid value type in GetUnsignedBytevEXT()");
2200 shift
= d
->type
- TYPE_BIT_0
;
2201 data
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
2204 memcpy(data
, &d
->offset
, size
);
2207 memcpy(data
, &v
.value_int_n
.ints
, size
);
2233 case TYPE_DOUBLEN_2
:
2236 memcpy(data
, p
, size
);
2239 GLenum e
= *(GLenum16
*)p
;
2240 memcpy(data
, &e
, sizeof(e
));
2244 break; /* nothing - GL error was recorded */
2249 * Convert a GL texture binding enum such as GL_TEXTURE_BINDING_2D
2250 * into the corresponding Mesa texture target index.
2251 * \return TEXTURE_x_INDEX or -1 if binding is invalid
2254 tex_binding_to_index(const struct gl_context
*ctx
, GLenum binding
)
2257 case GL_TEXTURE_BINDING_1D
:
2258 return _mesa_is_desktop_gl(ctx
) ? TEXTURE_1D_INDEX
: -1;
2259 case GL_TEXTURE_BINDING_2D
:
2260 return TEXTURE_2D_INDEX
;
2261 case GL_TEXTURE_BINDING_3D
:
2262 return ctx
->API
!= API_OPENGLES
? TEXTURE_3D_INDEX
: -1;
2263 case GL_TEXTURE_BINDING_CUBE_MAP
:
2264 return ctx
->Extensions
.ARB_texture_cube_map
2265 ? TEXTURE_CUBE_INDEX
: -1;
2266 case GL_TEXTURE_BINDING_RECTANGLE
:
2267 return _mesa_is_desktop_gl(ctx
) && ctx
->Extensions
.NV_texture_rectangle
2268 ? TEXTURE_RECT_INDEX
: -1;
2269 case GL_TEXTURE_BINDING_1D_ARRAY
:
2270 return _mesa_is_desktop_gl(ctx
) && ctx
->Extensions
.EXT_texture_array
2271 ? TEXTURE_1D_ARRAY_INDEX
: -1;
2272 case GL_TEXTURE_BINDING_2D_ARRAY
:
2273 return (_mesa_is_desktop_gl(ctx
) && ctx
->Extensions
.EXT_texture_array
)
2274 || _mesa_is_gles3(ctx
)
2275 ? TEXTURE_2D_ARRAY_INDEX
: -1;
2276 case GL_TEXTURE_BINDING_BUFFER
:
2277 return (_mesa_has_ARB_texture_buffer_object(ctx
) ||
2278 _mesa_has_OES_texture_buffer(ctx
)) ?
2279 TEXTURE_BUFFER_INDEX
: -1;
2280 case GL_TEXTURE_BINDING_CUBE_MAP_ARRAY
:
2281 return _mesa_has_texture_cube_map_array(ctx
)
2282 ? TEXTURE_CUBE_ARRAY_INDEX
: -1;
2283 case GL_TEXTURE_BINDING_2D_MULTISAMPLE
:
2284 return _mesa_is_desktop_gl(ctx
) && ctx
->Extensions
.ARB_texture_multisample
2285 ? TEXTURE_2D_MULTISAMPLE_INDEX
: -1;
2286 case GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY
:
2287 return _mesa_is_desktop_gl(ctx
) && ctx
->Extensions
.ARB_texture_multisample
2288 ? TEXTURE_2D_MULTISAMPLE_ARRAY_INDEX
: -1;
2294 static enum value_type
2295 find_value_indexed(const char *func
, GLenum pname
, GLuint index
, union value
*v
)
2297 GET_CURRENT_CONTEXT(ctx
);
2302 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2304 if (!ctx
->Extensions
.EXT_draw_buffers2
)
2306 v
->value_int
= (ctx
->Color
.BlendEnabled
>> index
) & 1;
2311 case GL_BLEND_SRC_RGB
:
2312 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2314 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
2316 v
->value_int
= ctx
->Color
.Blend
[index
].SrcRGB
;
2318 case GL_BLEND_SRC_ALPHA
:
2319 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2321 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
2323 v
->value_int
= ctx
->Color
.Blend
[index
].SrcA
;
2327 case GL_BLEND_DST_RGB
:
2328 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2330 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
2332 v
->value_int
= ctx
->Color
.Blend
[index
].DstRGB
;
2334 case GL_BLEND_DST_ALPHA
:
2335 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2337 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
2339 v
->value_int
= ctx
->Color
.Blend
[index
].DstA
;
2341 case GL_BLEND_EQUATION_RGB
:
2342 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2344 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
2346 v
->value_int
= ctx
->Color
.Blend
[index
].EquationRGB
;
2348 case GL_BLEND_EQUATION_ALPHA
:
2349 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2351 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
2353 v
->value_int
= ctx
->Color
.Blend
[index
].EquationA
;
2356 case GL_COLOR_WRITEMASK
:
2357 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2359 if (!ctx
->Extensions
.EXT_draw_buffers2
)
2361 v
->value_int_4
[0] = GET_COLORMASK_BIT(ctx
->Color
.ColorMask
, index
, 0);
2362 v
->value_int_4
[1] = GET_COLORMASK_BIT(ctx
->Color
.ColorMask
, index
, 1);
2363 v
->value_int_4
[2] = GET_COLORMASK_BIT(ctx
->Color
.ColorMask
, index
, 2);
2364 v
->value_int_4
[3] = GET_COLORMASK_BIT(ctx
->Color
.ColorMask
, index
, 3);
2367 case GL_SCISSOR_BOX
:
2368 if (index
>= ctx
->Const
.MaxViewports
)
2370 v
->value_int_4
[0] = ctx
->Scissor
.ScissorArray
[index
].X
;
2371 v
->value_int_4
[1] = ctx
->Scissor
.ScissorArray
[index
].Y
;
2372 v
->value_int_4
[2] = ctx
->Scissor
.ScissorArray
[index
].Width
;
2373 v
->value_int_4
[3] = ctx
->Scissor
.ScissorArray
[index
].Height
;
2376 case GL_WINDOW_RECTANGLE_EXT
:
2377 if (!ctx
->Extensions
.EXT_window_rectangles
)
2379 if (index
>= ctx
->Const
.MaxWindowRectangles
)
2381 v
->value_int_4
[0] = ctx
->Scissor
.WindowRects
[index
].X
;
2382 v
->value_int_4
[1] = ctx
->Scissor
.WindowRects
[index
].Y
;
2383 v
->value_int_4
[2] = ctx
->Scissor
.WindowRects
[index
].Width
;
2384 v
->value_int_4
[3] = ctx
->Scissor
.WindowRects
[index
].Height
;
2388 if (index
>= ctx
->Const
.MaxViewports
)
2390 v
->value_float_4
[0] = ctx
->ViewportArray
[index
].X
;
2391 v
->value_float_4
[1] = ctx
->ViewportArray
[index
].Y
;
2392 v
->value_float_4
[2] = ctx
->ViewportArray
[index
].Width
;
2393 v
->value_float_4
[3] = ctx
->ViewportArray
[index
].Height
;
2394 return TYPE_FLOAT_4
;
2396 case GL_DEPTH_RANGE
:
2397 if (index
>= ctx
->Const
.MaxViewports
)
2399 v
->value_double_2
[0] = ctx
->ViewportArray
[index
].Near
;
2400 v
->value_double_2
[1] = ctx
->ViewportArray
[index
].Far
;
2401 return TYPE_DOUBLEN_2
;
2403 case GL_TRANSFORM_FEEDBACK_BUFFER_START
:
2404 if (index
>= ctx
->Const
.MaxTransformFeedbackBuffers
)
2406 if (!ctx
->Extensions
.EXT_transform_feedback
)
2408 v
->value_int64
= ctx
->TransformFeedback
.CurrentObject
->Offset
[index
];
2411 case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE
:
2412 if (index
>= ctx
->Const
.MaxTransformFeedbackBuffers
)
2414 if (!ctx
->Extensions
.EXT_transform_feedback
)
2417 = ctx
->TransformFeedback
.CurrentObject
->RequestedSize
[index
];
2420 case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING
:
2421 if (index
>= ctx
->Const
.MaxTransformFeedbackBuffers
)
2423 if (!ctx
->Extensions
.EXT_transform_feedback
)
2425 v
->value_int
= ctx
->TransformFeedback
.CurrentObject
->BufferNames
[index
];
2428 case GL_UNIFORM_BUFFER_BINDING
:
2429 if (index
>= ctx
->Const
.MaxUniformBufferBindings
)
2431 if (!ctx
->Extensions
.ARB_uniform_buffer_object
)
2433 v
->value_int
= ctx
->UniformBufferBindings
[index
].BufferObject
->Name
;
2436 case GL_UNIFORM_BUFFER_START
:
2437 if (index
>= ctx
->Const
.MaxUniformBufferBindings
)
2439 if (!ctx
->Extensions
.ARB_uniform_buffer_object
)
2441 v
->value_int
= ctx
->UniformBufferBindings
[index
].Offset
< 0 ? 0 :
2442 ctx
->UniformBufferBindings
[index
].Offset
;
2445 case GL_UNIFORM_BUFFER_SIZE
:
2446 if (index
>= ctx
->Const
.MaxUniformBufferBindings
)
2448 if (!ctx
->Extensions
.ARB_uniform_buffer_object
)
2450 v
->value_int
= ctx
->UniformBufferBindings
[index
].Size
< 0 ? 0 :
2451 ctx
->UniformBufferBindings
[index
].Size
;
2454 /* ARB_shader_storage_buffer_object */
2455 case GL_SHADER_STORAGE_BUFFER_BINDING
:
2456 if (!ctx
->Extensions
.ARB_shader_storage_buffer_object
)
2458 if (index
>= ctx
->Const
.MaxShaderStorageBufferBindings
)
2460 v
->value_int
= ctx
->ShaderStorageBufferBindings
[index
].BufferObject
->Name
;
2463 case GL_SHADER_STORAGE_BUFFER_START
:
2464 if (!ctx
->Extensions
.ARB_shader_storage_buffer_object
)
2466 if (index
>= ctx
->Const
.MaxShaderStorageBufferBindings
)
2468 v
->value_int
= ctx
->ShaderStorageBufferBindings
[index
].Offset
< 0 ? 0 :
2469 ctx
->ShaderStorageBufferBindings
[index
].Offset
;
2472 case GL_SHADER_STORAGE_BUFFER_SIZE
:
2473 if (!ctx
->Extensions
.ARB_shader_storage_buffer_object
)
2475 if (index
>= ctx
->Const
.MaxShaderStorageBufferBindings
)
2477 v
->value_int
= ctx
->ShaderStorageBufferBindings
[index
].Size
< 0 ? 0 :
2478 ctx
->ShaderStorageBufferBindings
[index
].Size
;
2481 /* ARB_texture_multisample / GL3.2 */
2482 case GL_SAMPLE_MASK_VALUE
:
2485 if (!ctx
->Extensions
.ARB_texture_multisample
)
2487 v
->value_int
= ctx
->Multisample
.SampleMaskValue
;
2490 case GL_ATOMIC_COUNTER_BUFFER_BINDING
:
2491 if (!ctx
->Extensions
.ARB_shader_atomic_counters
)
2493 if (index
>= ctx
->Const
.MaxAtomicBufferBindings
)
2495 v
->value_int
= ctx
->AtomicBufferBindings
[index
].BufferObject
->Name
;
2498 case GL_ATOMIC_COUNTER_BUFFER_START
:
2499 if (!ctx
->Extensions
.ARB_shader_atomic_counters
)
2501 if (index
>= ctx
->Const
.MaxAtomicBufferBindings
)
2503 v
->value_int64
= ctx
->AtomicBufferBindings
[index
].Offset
< 0 ? 0 :
2504 ctx
->AtomicBufferBindings
[index
].Offset
;
2507 case GL_ATOMIC_COUNTER_BUFFER_SIZE
:
2508 if (!ctx
->Extensions
.ARB_shader_atomic_counters
)
2510 if (index
>= ctx
->Const
.MaxAtomicBufferBindings
)
2512 v
->value_int64
= ctx
->AtomicBufferBindings
[index
].Size
< 0 ? 0 :
2513 ctx
->AtomicBufferBindings
[index
].Size
;
2516 case GL_VERTEX_BINDING_DIVISOR
:
2517 if ((!_mesa_is_desktop_gl(ctx
) || !ctx
->Extensions
.ARB_instanced_arrays
) &&
2518 !_mesa_is_gles31(ctx
))
2520 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
)
2522 v
->value_int
= ctx
->Array
.VAO
->BufferBinding
[VERT_ATTRIB_GENERIC(index
)].InstanceDivisor
;
2525 case GL_VERTEX_BINDING_OFFSET
:
2526 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles31(ctx
))
2528 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
)
2530 v
->value_int
= ctx
->Array
.VAO
->BufferBinding
[VERT_ATTRIB_GENERIC(index
)].Offset
;
2533 case GL_VERTEX_BINDING_STRIDE
:
2534 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles31(ctx
))
2536 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
)
2538 v
->value_int
= ctx
->Array
.VAO
->BufferBinding
[VERT_ATTRIB_GENERIC(index
)].Stride
;
2541 case GL_VERTEX_BINDING_BUFFER
:
2542 if (ctx
->API
== API_OPENGLES2
&& ctx
->Version
< 31)
2544 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
)
2546 v
->value_int
= ctx
->Array
.VAO
->BufferBinding
[VERT_ATTRIB_GENERIC(index
)].BufferObj
->Name
;
2549 /* ARB_shader_image_load_store */
2550 case GL_IMAGE_BINDING_NAME
: {
2551 struct gl_texture_object
*t
;
2553 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
2555 if (index
>= ctx
->Const
.MaxImageUnits
)
2558 t
= ctx
->ImageUnits
[index
].TexObj
;
2559 v
->value_int
= (t
? t
->Name
: 0);
2563 case GL_IMAGE_BINDING_LEVEL
:
2564 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
2566 if (index
>= ctx
->Const
.MaxImageUnits
)
2569 v
->value_int
= ctx
->ImageUnits
[index
].Level
;
2572 case GL_IMAGE_BINDING_LAYERED
:
2573 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
2575 if (index
>= ctx
->Const
.MaxImageUnits
)
2578 v
->value_int
= ctx
->ImageUnits
[index
].Layered
;
2581 case GL_IMAGE_BINDING_LAYER
:
2582 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
2584 if (index
>= ctx
->Const
.MaxImageUnits
)
2587 v
->value_int
= ctx
->ImageUnits
[index
].Layer
;
2590 case GL_IMAGE_BINDING_ACCESS
:
2591 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
2593 if (index
>= ctx
->Const
.MaxImageUnits
)
2596 v
->value_int
= ctx
->ImageUnits
[index
].Access
;
2599 case GL_IMAGE_BINDING_FORMAT
:
2600 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
2602 if (index
>= ctx
->Const
.MaxImageUnits
)
2605 v
->value_int
= ctx
->ImageUnits
[index
].Format
;
2608 /* ARB_direct_state_access */
2609 case GL_TEXTURE_BINDING_1D
:
2610 case GL_TEXTURE_BINDING_1D_ARRAY
:
2611 case GL_TEXTURE_BINDING_2D
:
2612 case GL_TEXTURE_BINDING_2D_ARRAY
:
2613 case GL_TEXTURE_BINDING_2D_MULTISAMPLE
:
2614 case GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY
:
2615 case GL_TEXTURE_BINDING_3D
:
2616 case GL_TEXTURE_BINDING_BUFFER
:
2617 case GL_TEXTURE_BINDING_CUBE_MAP
:
2618 case GL_TEXTURE_BINDING_CUBE_MAP_ARRAY
:
2619 case GL_TEXTURE_BINDING_RECTANGLE
: {
2622 if (ctx
->API
!= API_OPENGL_CORE
)
2624 target
= tex_binding_to_index(ctx
, pname
);
2627 if (index
>= _mesa_max_tex_unit(ctx
))
2630 v
->value_int
= ctx
->Texture
.Unit
[index
].CurrentTex
[target
]->Name
;
2634 case GL_SAMPLER_BINDING
: {
2635 struct gl_sampler_object
*samp
;
2637 if (!_mesa_is_desktop_gl(ctx
) || ctx
->Version
< 33)
2639 if (index
>= _mesa_max_tex_unit(ctx
))
2642 samp
= ctx
->Texture
.Unit
[index
].Sampler
;
2643 v
->value_int
= samp
? samp
->Name
: 0;
2647 case GL_MAX_COMPUTE_WORK_GROUP_COUNT
:
2648 if (!_mesa_has_compute_shaders(ctx
))
2652 v
->value_int
= ctx
->Const
.MaxComputeWorkGroupCount
[index
];
2655 case GL_MAX_COMPUTE_WORK_GROUP_SIZE
:
2656 if (!_mesa_has_compute_shaders(ctx
))
2660 v
->value_int
= ctx
->Const
.MaxComputeWorkGroupSize
[index
];
2663 /* ARB_compute_variable_group_size */
2664 case GL_MAX_COMPUTE_VARIABLE_GROUP_SIZE_ARB
:
2665 if (!ctx
->Extensions
.ARB_compute_variable_group_size
)
2669 v
->value_int
= ctx
->Const
.MaxComputeVariableGroupSize
[index
];
2672 /* GL_EXT_external_objects */
2673 case GL_NUM_DEVICE_UUIDS_EXT
:
2676 case GL_DRIVER_UUID_EXT
:
2679 _mesa_get_driver_uuid(ctx
, v
->value_int_4
);
2681 case GL_DEVICE_UUID_EXT
:
2684 _mesa_get_device_uuid(ctx
, v
->value_int_4
);
2689 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(pname=%s)", func
,
2690 _mesa_enum_to_string(pname
));
2691 return TYPE_INVALID
;
2693 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(pname=%s)", func
,
2694 _mesa_enum_to_string(pname
));
2695 return TYPE_INVALID
;
2699 _mesa_GetBooleani_v( GLenum pname
, GLuint index
, GLboolean
*params
)
2702 enum value_type type
=
2703 find_value_indexed("glGetBooleani_v", pname
, index
, &v
);
2708 params
[0] = INT_TO_BOOLEAN(v
.value_int
);
2712 params
[0] = INT_TO_BOOLEAN(v
.value_int_4
[0]);
2713 params
[1] = INT_TO_BOOLEAN(v
.value_int_4
[1]);
2714 params
[2] = INT_TO_BOOLEAN(v
.value_int_4
[2]);
2715 params
[3] = INT_TO_BOOLEAN(v
.value_int_4
[3]);
2718 params
[0] = INT64_TO_BOOLEAN(v
.value_int64
);
2721 ; /* nothing - GL error was recorded */
2726 _mesa_GetIntegeri_v( GLenum pname
, GLuint index
, GLint
*params
)
2729 enum value_type type
=
2730 find_value_indexed("glGetIntegeri_v", pname
, index
, &v
);
2735 params
[3] = IROUND(v
.value_float_4
[3]);
2738 params
[2] = IROUND(v
.value_float_4
[2]);
2741 params
[1] = IROUND(v
.value_float_4
[1]);
2744 params
[0] = IROUND(v
.value_float_4
[0]);
2747 case TYPE_DOUBLEN_2
:
2748 params
[1] = IROUND(v
.value_double_2
[1]);
2750 params
[0] = IROUND(v
.value_double_2
[0]);
2755 params
[0] = v
.value_int
;
2759 params
[0] = v
.value_int_4
[0];
2760 params
[1] = v
.value_int_4
[1];
2761 params
[2] = v
.value_int_4
[2];
2762 params
[3] = v
.value_int_4
[3];
2765 params
[0] = INT64_TO_INT(v
.value_int64
);
2768 ; /* nothing - GL error was recorded */
2773 _mesa_GetInteger64i_v( GLenum pname
, GLuint index
, GLint64
*params
)
2776 enum value_type type
=
2777 find_value_indexed("glGetInteger64i_v", pname
, index
, &v
);
2781 params
[0] = v
.value_int
;
2784 params
[0] = v
.value_int_4
[0];
2785 params
[1] = v
.value_int_4
[1];
2786 params
[2] = v
.value_int_4
[2];
2787 params
[3] = v
.value_int_4
[3];
2790 params
[0] = (GLuint
) v
.value_int
;
2793 params
[0] = (GLuint
) v
.value_int_4
[0];
2794 params
[1] = (GLuint
) v
.value_int_4
[1];
2795 params
[2] = (GLuint
) v
.value_int_4
[2];
2796 params
[3] = (GLuint
) v
.value_int_4
[3];
2799 params
[0] = v
.value_int64
;
2802 ; /* nothing - GL error was recorded */
2807 _mesa_GetFloati_v(GLenum pname
, GLuint index
, GLfloat
*params
)
2812 enum value_type type
=
2813 find_value_indexed("glGetFloati_v", pname
, index
, &v
);
2818 params
[3] = v
.value_float_4
[3];
2821 params
[2] = v
.value_float_4
[2];
2824 params
[1] = v
.value_float_4
[1];
2827 params
[0] = v
.value_float_4
[0];
2830 case TYPE_DOUBLEN_2
:
2831 params
[1] = (GLfloat
) v
.value_double_2
[1];
2833 params
[0] = (GLfloat
) v
.value_double_2
[0];
2837 params
[3] = (GLfloat
) v
.value_int_4
[3];
2839 params
[2] = (GLfloat
) v
.value_int_4
[2];
2842 params
[1] = (GLfloat
) v
.value_int_4
[1];
2846 params
[0] = (GLfloat
) v
.value_int_4
[0];
2850 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
2851 params
[i
] = (GLfloat
) v
.value_int_n
.ints
[i
];
2855 params
[3] = (GLfloat
) ((GLuint
) v
.value_int_4
[3]);
2857 params
[2] = (GLfloat
) ((GLuint
) v
.value_int_4
[2]);
2859 params
[1] = (GLfloat
) ((GLuint
) v
.value_int_4
[1]);
2861 params
[0] = (GLfloat
) ((GLuint
) v
.value_int_4
[0]);
2865 params
[0] = (GLfloat
) v
.value_int64
;
2869 params
[0] = BOOLEAN_TO_FLOAT(v
.value_bool
);
2873 params
[0] = (GLfloat
) v
.value_ubyte
;
2877 params
[0] = (GLfloat
) v
.value_short
;
2881 m
= *(GLmatrix
**) &v
;
2882 for (i
= 0; i
< 16; i
++)
2883 params
[i
] = m
->m
[i
];
2887 m
= *(GLmatrix
**) &v
;
2888 for (i
= 0; i
< 16; i
++)
2889 params
[i
] = m
->m
[transpose
[i
]];
2898 _mesa_GetDoublei_v(GLenum pname
, GLuint index
, GLdouble
*params
)
2903 enum value_type type
=
2904 find_value_indexed("glGetDoublei_v", pname
, index
, &v
);
2909 params
[3] = (GLdouble
) v
.value_float_4
[3];
2912 params
[2] = (GLdouble
) v
.value_float_4
[2];
2915 params
[1] = (GLdouble
) v
.value_float_4
[1];
2918 params
[0] = (GLdouble
) v
.value_float_4
[0];
2921 case TYPE_DOUBLEN_2
:
2922 params
[1] = v
.value_double_2
[1];
2924 params
[0] = v
.value_double_2
[0];
2928 params
[3] = (GLdouble
) v
.value_int_4
[3];
2930 params
[2] = (GLdouble
) v
.value_int_4
[2];
2933 params
[1] = (GLdouble
) v
.value_int_4
[1];
2937 params
[0] = (GLdouble
) v
.value_int_4
[0];
2941 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
2942 params
[i
] = (GLdouble
) v
.value_int_n
.ints
[i
];
2946 params
[3] = (GLdouble
) ((GLuint
) v
.value_int_4
[3]);
2948 params
[2] = (GLdouble
) ((GLuint
) v
.value_int_4
[2]);
2950 params
[1] = (GLdouble
) ((GLuint
) v
.value_int_4
[1]);
2952 params
[0] = (GLdouble
) ((GLuint
) v
.value_int_4
[0]);
2956 params
[0] = (GLdouble
) v
.value_int64
;
2960 params
[0] = (GLdouble
) BOOLEAN_TO_FLOAT(v
.value_bool
);
2964 params
[0] = (GLdouble
) v
.value_ubyte
;
2968 params
[0] = (GLdouble
) v
.value_short
;
2972 m
= *(GLmatrix
**) &v
;
2973 for (i
= 0; i
< 16; i
++)
2974 params
[i
] = (GLdouble
) m
->m
[i
];
2978 m
= *(GLmatrix
**) &v
;
2979 for (i
= 0; i
< 16; i
++)
2980 params
[i
] = (GLdouble
) m
->m
[transpose
[i
]];
2989 _mesa_GetUnsignedBytei_vEXT(GLenum target
, GLuint index
, GLubyte
*data
)
2993 enum value_type type
;
2994 const char *func
= "glGetUnsignedBytei_vEXT";
2996 GET_CURRENT_CONTEXT(ctx
);
2998 if (!ctx
->Extensions
.EXT_memory_object
) {
2999 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(unsupported)", func
);
3003 type
= find_value_indexed(func
, target
, index
, &v
);
3004 size
= get_value_size(type
, &v
);
3006 _mesa_problem(ctx
, "invalid value type in GetUnsignedBytei_vEXT()");
3035 case TYPE_DOUBLEN_2
:
3038 memcpy(data
, &v
.value_int
, size
);
3041 memcpy(data
, &v
.value_int_n
.ints
, size
);
3044 break; /* nothing - GL error was recorded */
3049 _mesa_GetFixedv(GLenum pname
, GLfixed
*params
)
3051 const struct value_desc
*d
;
3057 d
= find_value("glGetDoublev", pname
, &p
, &v
);
3062 params
[0] = INT_TO_FIXED(d
->offset
);
3067 params
[3] = FLOAT_TO_FIXED(((GLfloat
*) p
)[3]);
3070 params
[2] = FLOAT_TO_FIXED(((GLfloat
*) p
)[2]);
3073 params
[1] = FLOAT_TO_FIXED(((GLfloat
*) p
)[1]);
3076 params
[0] = FLOAT_TO_FIXED(((GLfloat
*) p
)[0]);
3079 case TYPE_DOUBLEN_2
:
3080 params
[1] = FLOAT_TO_FIXED(((GLdouble
*) p
)[1]);
3082 params
[0] = FLOAT_TO_FIXED(((GLdouble
*) p
)[0]);
3087 params
[3] = INT_TO_FIXED(((GLint
*) p
)[3]);
3090 params
[2] = INT_TO_FIXED(((GLint
*) p
)[2]);
3094 params
[1] = INT_TO_FIXED(((GLint
*) p
)[1]);
3098 params
[0] = INT_TO_FIXED(((GLint
*) p
)[0]);
3102 params
[0] = INT_TO_FIXED((GLint
)(((GLenum16
*) p
)[0]));
3106 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
3107 params
[i
] = INT_TO_FIXED(v
.value_int_n
.ints
[i
]);
3111 params
[0] = ((GLint64
*) p
)[0];
3115 params
[0] = BOOLEAN_TO_FIXED(((GLboolean
*) p
)[0]);
3119 params
[0] = INT_TO_FIXED(((GLubyte
*) p
)[0]);
3123 params
[0] = INT_TO_FIXED(((GLshort
*) p
)[0]);
3127 m
= *(GLmatrix
**) p
;
3128 for (i
= 0; i
< 16; i
++)
3129 params
[i
] = FLOAT_TO_FIXED(m
->m
[i
]);
3133 m
= *(GLmatrix
**) p
;
3134 for (i
= 0; i
< 16; i
++)
3135 params
[i
] = FLOAT_TO_FIXED(m
->m
[transpose
[i
]]);
3146 shift
= d
->type
- TYPE_BIT_0
;
3147 params
[0] = BOOLEAN_TO_FIXED((*(GLbitfield
*) p
>> shift
) & 1);