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_gpushader4
[] = {
321 EXT(EXT_gpu_shader4
),
325 static const int extra_texture_buffer_object
[] = {
326 EXT(ARB_texture_buffer_object
),
330 static const int extra_ARB_transform_feedback2_api_es3
[] = {
331 EXT(ARB_transform_feedback2
),
336 static const int extra_ARB_uniform_buffer_object_and_geometry_shader
[] = {
341 static const int extra_ARB_ES2_compatibility_api_es2
[] = {
342 EXT(ARB_ES2_compatibility
),
347 static const int extra_ARB_ES3_compatibility_api_es3
[] = {
348 EXT(ARB_ES3_compatibility
),
353 static const int extra_EXT_framebuffer_sRGB_and_new_buffers
[] = {
354 EXT(EXT_framebuffer_sRGB
),
359 static const int extra_EXT_packed_float
[] = {
360 EXT(EXT_packed_float
),
365 static const int extra_EXT_texture_array_es3
[] = {
366 EXT(EXT_texture_array
),
371 static const int extra_ARB_shader_atomic_counters_and_geometry_shader
[] = {
372 EXTRA_EXT_ATOMICS_GS
,
376 static const int extra_ARB_shader_image_load_store_and_geometry_shader
[] = {
377 EXTRA_EXT_SHADER_IMAGE_GS
,
381 static const int extra_ARB_shader_atomic_counters_and_tessellation
[] = {
382 EXTRA_EXT_ATOMICS_TESS
,
386 static const int extra_ARB_shader_image_load_store_and_tessellation
[] = {
387 EXTRA_EXT_SHADER_IMAGE_TESS
,
391 /* HACK: remove when ARB_compute_shader is actually supported */
392 static const int extra_ARB_compute_shader_es31
[] = {
393 EXT(ARB_compute_shader
),
398 static const int extra_ARB_shader_storage_buffer_object_es31
[] = {
399 EXT(ARB_shader_storage_buffer_object
),
404 static const int extra_ARB_shader_storage_buffer_object_and_geometry_shader
[] = {
409 static const int extra_ARB_shader_image_load_store_shader_storage_buffer_object_es31
[] = {
410 EXT(ARB_shader_image_load_store
),
411 EXT(ARB_shader_storage_buffer_object
),
416 static const int extra_ARB_framebuffer_no_attachments_and_geometry_shader
[] = {
417 EXTRA_EXT_FB_NO_ATTACH_GS
,
421 static const int extra_ARB_viewport_array_or_oes_geometry_shader
[] = {
422 EXT(ARB_viewport_array
),
427 static const int extra_ARB_viewport_array_or_oes_viewport_array
[] = {
428 EXT(ARB_viewport_array
),
429 EXT(OES_viewport_array
),
433 static const int extra_ARB_gpu_shader5_or_oes_geometry_shader
[] = {
434 EXT(ARB_gpu_shader5
),
439 static const int extra_ARB_gpu_shader5_or_OES_sample_variables
[] = {
440 EXT(ARB_gpu_shader5
),
441 EXT(OES_sample_variables
),
445 static const int extra_ES32
[] = {
446 EXT(ARB_ES3_2_compatibility
),
451 static const int extra_KHR_robustness_or_GL
[] = {
458 static const int extra_INTEL_conservative_rasterization
[] = {
459 EXT(INTEL_conservative_rasterization
),
463 EXTRA_EXT(ARB_texture_cube_map
);
464 EXTRA_EXT(EXT_texture_array
);
465 EXTRA_EXT(NV_fog_distance
);
466 EXTRA_EXT(EXT_texture_filter_anisotropic
);
467 EXTRA_EXT(NV_point_sprite
);
468 EXTRA_EXT(NV_texture_rectangle
);
469 EXTRA_EXT(EXT_stencil_two_side
);
470 EXTRA_EXT(EXT_depth_bounds_test
);
471 EXTRA_EXT(ARB_depth_clamp
);
472 EXTRA_EXT(AMD_depth_clamp_separate
);
473 EXTRA_EXT(ATI_fragment_shader
);
474 EXTRA_EXT(EXT_provoking_vertex
);
475 EXTRA_EXT(ARB_fragment_shader
);
476 EXTRA_EXT(ARB_fragment_program
);
477 EXTRA_EXT2(ARB_framebuffer_object
, EXT_framebuffer_multisample
);
478 EXTRA_EXT(ARB_seamless_cube_map
);
480 EXTRA_EXT(ARB_vertex_shader
);
481 EXTRA_EXT(EXT_transform_feedback
);
482 EXTRA_EXT(ARB_transform_feedback3
);
483 EXTRA_EXT(EXT_pixel_buffer_object
);
484 EXTRA_EXT(ARB_vertex_program
);
485 EXTRA_EXT2(NV_point_sprite
, ARB_point_sprite
);
486 EXTRA_EXT2(ARB_vertex_program
, ARB_fragment_program
);
487 EXTRA_EXT(ARB_color_buffer_float
);
488 EXTRA_EXT(EXT_framebuffer_sRGB
);
489 EXTRA_EXT(OES_EGL_image_external
);
490 EXTRA_EXT(ARB_blend_func_extended
);
491 EXTRA_EXT(ARB_uniform_buffer_object
);
492 EXTRA_EXT(ARB_timer_query
);
493 EXTRA_EXT2(ARB_texture_cube_map_array
, OES_texture_cube_map_array
);
494 EXTRA_EXT(ARB_texture_buffer_range
);
495 EXTRA_EXT(ARB_texture_multisample
);
496 EXTRA_EXT(ARB_texture_gather
);
497 EXTRA_EXT(ARB_shader_atomic_counters
);
498 EXTRA_EXT(ARB_draw_indirect
);
499 EXTRA_EXT(ARB_shader_image_load_store
);
500 EXTRA_EXT(ARB_query_buffer_object
);
501 EXTRA_EXT2(ARB_transform_feedback3
, ARB_gpu_shader5
);
502 EXTRA_EXT(INTEL_performance_query
);
503 EXTRA_EXT(ARB_explicit_uniform_location
);
504 EXTRA_EXT(ARB_clip_control
);
505 EXTRA_EXT(ARB_polygon_offset_clamp
);
506 EXTRA_EXT(ARB_framebuffer_no_attachments
);
507 EXTRA_EXT(ARB_tessellation_shader
);
508 EXTRA_EXT(ARB_shader_storage_buffer_object
);
509 EXTRA_EXT(ARB_indirect_parameters
);
510 EXTRA_EXT(ATI_meminfo
);
511 EXTRA_EXT(NVX_gpu_memory_info
);
512 EXTRA_EXT(ARB_cull_distance
);
513 EXTRA_EXT(EXT_window_rectangles
);
514 EXTRA_EXT(KHR_blend_equation_advanced_coherent
);
515 EXTRA_EXT(OES_primitive_bounding_box
);
516 EXTRA_EXT(ARB_compute_variable_group_size
);
517 EXTRA_EXT(KHR_robustness
);
518 EXTRA_EXT(ARB_sparse_buffer
);
519 EXTRA_EXT(NV_conservative_raster
);
520 EXTRA_EXT(NV_conservative_raster_dilate
);
521 EXTRA_EXT(NV_conservative_raster_pre_snap_triangles
);
522 EXTRA_EXT(ARB_sample_locations
);
523 EXTRA_EXT(AMD_framebuffer_multisample_advanced
);
526 extra_ARB_color_buffer_float_or_glcore
[] = {
527 EXT(ARB_color_buffer_float
),
533 extra_NV_primitive_restart
[] = {
534 EXT(NV_primitive_restart
),
538 static const int extra_version_30
[] = { EXTRA_VERSION_30
, EXTRA_END
};
539 static const int extra_version_31
[] = { EXTRA_VERSION_31
, EXTRA_END
};
540 static const int extra_version_32
[] = { EXTRA_VERSION_32
, EXTRA_END
};
541 static const int extra_version_43
[] = { EXTRA_VERSION_43
, EXTRA_END
};
543 static const int extra_gl30_es3
[] = {
549 static const int extra_gl32_es3
[] = {
555 static const int extra_version_32_OES_geometry_shader
[] = {
561 static const int extra_gl40_ARB_sample_shading
[] = {
563 EXT(ARB_sample_shading
),
568 extra_ARB_vertex_program_api_es2
[] = {
569 EXT(ARB_vertex_program
),
574 /* The ReadBuffer get token is valid under either full GL or under
575 * GLES2 if the NV_read_buffer extension is available. */
577 extra_NV_read_buffer_api_gl
[] = {
583 static const int extra_core_ARB_color_buffer_float_and_new_buffers
[] = {
585 EXT(ARB_color_buffer_float
),
590 static const int extra_EXT_shader_framebuffer_fetch
[] = {
593 EXT(EXT_shader_framebuffer_fetch
),
597 static const int extra_EXT_provoking_vertex_32
[] = {
598 EXTRA_EXT_PROVOKING_VERTEX_32
,
602 static const int extra_EXT_disjoint_timer_query
[] = {
605 EXT(EXT_disjoint_timer_query
),
610 /* This is the big table describing all the enums we accept in
611 * glGet*v(). The table is partitioned into six parts: enums
612 * understood by all GL APIs (OpenGL, GLES and GLES2), enums shared
613 * between OpenGL and GLES, enums exclusive to GLES, etc for the
614 * remaining combinations. To look up the enums valid in a given API
615 * we will use a hash table specific to that API. These tables are in
616 * turn generated at build time and included through get_hash.h.
619 #include "get_hash.h"
621 /* All we need now is a way to look up the value struct from the enum.
622 * The code generated by gcc for the old generated big switch
623 * statement is a big, balanced, open coded if/else tree, essentially
624 * an unrolled binary search. It would be natural to sort the new
625 * enum table and use bsearch(), but we will use a read-only hash
626 * table instead. bsearch() has a nice guaranteed worst case
627 * performance, but we're also guaranteed to hit that worst case
628 * (log2(n) iterations) for about half the enums. Instead, using an
629 * open addressing hash table, we can find the enum on the first try
630 * for 80% of the enums, 1 collision for 10% and never more than 5
631 * collisions for any enum (typical numbers). And the code is very
632 * simple, even though it feels a little magic. */
635 * Handle irregular enums
637 * Some values don't conform to the "well-known type at context
638 * pointer + offset" pattern, so we have this function to catch all
639 * the corner cases. Typically, it's a computed value or a one-off
640 * pointer to a custom struct or something.
642 * In this case we can't return a pointer to the value, so we'll have
643 * to use the temporary variable 'v' declared back in the calling
644 * glGet*v() function to store the result.
646 * \param ctx the current context
647 * \param d the struct value_desc that describes the enum
648 * \param v pointer to the tmp declared in the calling glGet*v() function
651 find_custom_value(struct gl_context
*ctx
, const struct value_desc
*d
, union value
*v
)
653 struct gl_buffer_object
**buffer_obj
;
654 struct gl_array_attributes
*array
;
658 case GL_MAJOR_VERSION
:
659 v
->value_int
= ctx
->Version
/ 10;
661 case GL_MINOR_VERSION
:
662 v
->value_int
= ctx
->Version
% 10;
668 case GL_TEXTURE_CUBE_MAP
:
669 case GL_TEXTURE_RECTANGLE_NV
:
670 case GL_TEXTURE_EXTERNAL_OES
:
671 v
->value_bool
= _mesa_IsEnabled(d
->pname
);
674 case GL_LINE_STIPPLE_PATTERN
:
675 /* This is the only GLushort, special case it here by promoting
676 * to an int rather than introducing a new type. */
677 v
->value_int
= ctx
->Line
.StipplePattern
;
680 case GL_CURRENT_RASTER_TEXTURE_COORDS
:
681 unit
= ctx
->Texture
.CurrentUnit
;
682 v
->value_float_4
[0] = ctx
->Current
.RasterTexCoords
[unit
][0];
683 v
->value_float_4
[1] = ctx
->Current
.RasterTexCoords
[unit
][1];
684 v
->value_float_4
[2] = ctx
->Current
.RasterTexCoords
[unit
][2];
685 v
->value_float_4
[3] = ctx
->Current
.RasterTexCoords
[unit
][3];
688 case GL_CURRENT_TEXTURE_COORDS
:
689 unit
= ctx
->Texture
.CurrentUnit
;
690 v
->value_float_4
[0] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
][0];
691 v
->value_float_4
[1] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
][1];
692 v
->value_float_4
[2] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
][2];
693 v
->value_float_4
[3] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
][3];
696 case GL_COLOR_WRITEMASK
:
697 v
->value_int_4
[0] = GET_COLORMASK_BIT(ctx
->Color
.ColorMask
, 0, 0);
698 v
->value_int_4
[1] = GET_COLORMASK_BIT(ctx
->Color
.ColorMask
, 0, 1);
699 v
->value_int_4
[2] = GET_COLORMASK_BIT(ctx
->Color
.ColorMask
, 0, 2);
700 v
->value_int_4
[3] = GET_COLORMASK_BIT(ctx
->Color
.ColorMask
, 0, 3);
704 v
->value_bool
= ctx
->Transform
.DepthClampNear
|| ctx
->Transform
.DepthClampFar
;
708 v
->value_bool
= ctx
->Current
.Attrib
[VERT_ATTRIB_EDGEFLAG
][0] == 1.0F
;
712 v
->value_enum
= ctx
->ReadBuffer
->ColorReadBuffer
;
715 case GL_MAP2_GRID_DOMAIN
:
716 v
->value_float_4
[0] = ctx
->Eval
.MapGrid2u1
;
717 v
->value_float_4
[1] = ctx
->Eval
.MapGrid2u2
;
718 v
->value_float_4
[2] = ctx
->Eval
.MapGrid2v1
;
719 v
->value_float_4
[3] = ctx
->Eval
.MapGrid2v2
;
722 case GL_TEXTURE_STACK_DEPTH
:
723 unit
= ctx
->Texture
.CurrentUnit
;
724 v
->value_int
= ctx
->TextureMatrixStack
[unit
].Depth
+ 1;
726 case GL_TEXTURE_MATRIX
:
727 unit
= ctx
->Texture
.CurrentUnit
;
728 v
->value_matrix
= ctx
->TextureMatrixStack
[unit
].Top
;
731 case GL_VERTEX_ARRAY
:
732 v
->value_bool
= !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_POS
);
734 case GL_NORMAL_ARRAY
:
735 v
->value_bool
= !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_NORMAL
);
738 v
->value_bool
= !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_COLOR0
);
740 case GL_TEXTURE_COORD_ARRAY
:
741 v
->value_bool
= !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_TEX(ctx
->Array
.ActiveTexture
));
744 v
->value_bool
= !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_COLOR_INDEX
);
746 case GL_EDGE_FLAG_ARRAY
:
747 v
->value_bool
= !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_EDGEFLAG
);
749 case GL_SECONDARY_COLOR_ARRAY
:
750 v
->value_bool
= !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_COLOR1
);
752 case GL_FOG_COORDINATE_ARRAY
:
753 v
->value_bool
= !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_FOG
);
755 case GL_POINT_SIZE_ARRAY_OES
:
756 v
->value_bool
= !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_POINT_SIZE
);
759 case GL_TEXTURE_COORD_ARRAY_TYPE
:
760 case GL_TEXTURE_COORD_ARRAY_STRIDE
:
761 array
= &ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_TEX(ctx
->Array
.ActiveTexture
)];
762 v
->value_int
= *(GLuint
*) ((char *) array
+ d
->offset
);
765 case GL_TEXTURE_COORD_ARRAY_SIZE
:
766 array
= &ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_TEX(ctx
->Array
.ActiveTexture
)];
767 v
->value_int
= array
->Format
.Size
;
770 case GL_VERTEX_ARRAY_SIZE
:
771 array
= &ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_POS
];
772 v
->value_int
= array
->Format
.Size
;
775 case GL_ACTIVE_TEXTURE_ARB
:
776 v
->value_int
= GL_TEXTURE0_ARB
+ ctx
->Texture
.CurrentUnit
;
778 case GL_CLIENT_ACTIVE_TEXTURE_ARB
:
779 v
->value_int
= GL_TEXTURE0_ARB
+ ctx
->Array
.ActiveTexture
;
782 case GL_MODELVIEW_STACK_DEPTH
:
783 case GL_PROJECTION_STACK_DEPTH
:
784 v
->value_int
= *(GLint
*) ((char *) ctx
+ d
->offset
) + 1;
787 case GL_MAX_TEXTURE_SIZE
:
788 case GL_MAX_3D_TEXTURE_SIZE
:
789 case GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB
:
790 p
= (GLuint
*) ((char *) ctx
+ d
->offset
);
791 v
->value_int
= 1 << (*p
- 1);
795 v
->value_int_4
[0] = ctx
->Scissor
.ScissorArray
[0].X
;
796 v
->value_int_4
[1] = ctx
->Scissor
.ScissorArray
[0].Y
;
797 v
->value_int_4
[2] = ctx
->Scissor
.ScissorArray
[0].Width
;
798 v
->value_int_4
[3] = ctx
->Scissor
.ScissorArray
[0].Height
;
801 case GL_SCISSOR_TEST
:
802 v
->value_bool
= ctx
->Scissor
.EnableFlags
& 1;
807 ctx
->ListState
.CurrentList
? ctx
->ListState
.CurrentList
->Name
: 0;
810 if (!ctx
->CompileFlag
)
812 else if (ctx
->ExecuteFlag
)
813 v
->value_enum
= GL_COMPILE_AND_EXECUTE
;
815 v
->value_enum
= GL_COMPILE
;
819 v
->value_float_4
[0] = ctx
->ViewportArray
[0].X
;
820 v
->value_float_4
[1] = ctx
->ViewportArray
[0].Y
;
821 v
->value_float_4
[2] = ctx
->ViewportArray
[0].Width
;
822 v
->value_float_4
[3] = ctx
->ViewportArray
[0].Height
;
826 v
->value_double_2
[0] = ctx
->ViewportArray
[0].Near
;
827 v
->value_double_2
[1] = ctx
->ViewportArray
[0].Far
;
830 case GL_ACTIVE_STENCIL_FACE_EXT
:
831 v
->value_enum
= ctx
->Stencil
.ActiveFace
? GL_BACK
: GL_FRONT
;
834 case GL_STENCIL_FAIL
:
835 v
->value_enum
= ctx
->Stencil
.FailFunc
[ctx
->Stencil
.ActiveFace
];
837 case GL_STENCIL_FUNC
:
838 v
->value_enum
= ctx
->Stencil
.Function
[ctx
->Stencil
.ActiveFace
];
840 case GL_STENCIL_PASS_DEPTH_FAIL
:
841 v
->value_enum
= ctx
->Stencil
.ZFailFunc
[ctx
->Stencil
.ActiveFace
];
843 case GL_STENCIL_PASS_DEPTH_PASS
:
844 v
->value_enum
= ctx
->Stencil
.ZPassFunc
[ctx
->Stencil
.ActiveFace
];
847 v
->value_int
= _mesa_get_stencil_ref(ctx
, ctx
->Stencil
.ActiveFace
);
849 case GL_STENCIL_BACK_REF
:
850 v
->value_int
= _mesa_get_stencil_ref(ctx
, 1);
852 case GL_STENCIL_VALUE_MASK
:
853 v
->value_int
= ctx
->Stencil
.ValueMask
[ctx
->Stencil
.ActiveFace
];
855 case GL_STENCIL_WRITEMASK
:
856 v
->value_int
= ctx
->Stencil
.WriteMask
[ctx
->Stencil
.ActiveFace
];
859 case GL_NUM_EXTENSIONS
:
860 v
->value_int
= _mesa_get_extension_count(ctx
);
863 case GL_IMPLEMENTATION_COLOR_READ_TYPE_OES
:
864 v
->value_int
= _mesa_get_color_read_type(ctx
, NULL
, "glGetIntegerv");
866 case GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES
:
867 v
->value_int
= _mesa_get_color_read_format(ctx
, NULL
, "glGetIntegerv");
870 case GL_CURRENT_MATRIX_STACK_DEPTH_ARB
:
871 v
->value_int
= ctx
->CurrentStack
->Depth
+ 1;
873 case GL_CURRENT_MATRIX_ARB
:
874 case GL_TRANSPOSE_CURRENT_MATRIX_ARB
:
875 v
->value_matrix
= ctx
->CurrentStack
->Top
;
878 case GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB
:
879 v
->value_int
= _mesa_get_compressed_formats(ctx
, NULL
);
881 case GL_COMPRESSED_TEXTURE_FORMATS_ARB
:
883 _mesa_get_compressed_formats(ctx
, v
->value_int_n
.ints
);
884 assert(v
->value_int_n
.n
<= (int) ARRAY_SIZE(v
->value_int_n
.ints
));
887 case GL_MAX_VARYING_FLOATS_ARB
:
888 v
->value_int
= ctx
->Const
.MaxVarying
* 4;
891 /* Various object names */
893 case GL_TEXTURE_BINDING_1D
:
894 case GL_TEXTURE_BINDING_2D
:
895 case GL_TEXTURE_BINDING_3D
:
896 case GL_TEXTURE_BINDING_1D_ARRAY_EXT
:
897 case GL_TEXTURE_BINDING_2D_ARRAY_EXT
:
898 case GL_TEXTURE_BINDING_CUBE_MAP_ARB
:
899 case GL_TEXTURE_BINDING_RECTANGLE_NV
:
900 case GL_TEXTURE_BINDING_EXTERNAL_OES
:
901 case GL_TEXTURE_BINDING_CUBE_MAP_ARRAY
:
902 case GL_TEXTURE_BINDING_2D_MULTISAMPLE
:
903 case GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY
:
904 unit
= ctx
->Texture
.CurrentUnit
;
906 ctx
->Texture
.Unit
[unit
].CurrentTex
[d
->offset
]->Name
;
909 /* GL_EXT_external_objects */
910 case GL_NUM_DEVICE_UUIDS_EXT
:
913 case GL_DRIVER_UUID_EXT
:
914 _mesa_get_driver_uuid(ctx
, v
->value_int_4
);
916 case GL_DEVICE_UUID_EXT
:
917 _mesa_get_device_uuid(ctx
, v
->value_int_4
);
920 /* GL_EXT_packed_float */
921 case GL_RGBA_SIGNED_COMPONENTS_EXT
:
923 /* Note: we only check the 0th color attachment. */
924 const struct gl_renderbuffer
*rb
=
925 ctx
->DrawBuffer
->_ColorDrawBuffers
[0];
926 if (rb
&& _mesa_is_format_signed(rb
->Format
)) {
927 /* Issue 17 of GL_EXT_packed_float: If a component (such as
928 * alpha) has zero bits, the component should not be considered
929 * signed and so the bit for the respective component should be
933 _mesa_get_format_bits(rb
->Format
, GL_RED_BITS
);
935 _mesa_get_format_bits(rb
->Format
, GL_GREEN_BITS
);
937 _mesa_get_format_bits(rb
->Format
, GL_BLUE_BITS
);
939 _mesa_get_format_bits(rb
->Format
, GL_ALPHA_BITS
);
941 _mesa_get_format_bits(rb
->Format
, GL_TEXTURE_LUMINANCE_SIZE
);
943 _mesa_get_format_bits(rb
->Format
, GL_TEXTURE_INTENSITY_SIZE
);
945 v
->value_int_4
[0] = r_bits
+ l_bits
+ i_bits
> 0;
946 v
->value_int_4
[1] = g_bits
+ l_bits
+ i_bits
> 0;
947 v
->value_int_4
[2] = b_bits
+ l_bits
+ i_bits
> 0;
948 v
->value_int_4
[3] = a_bits
+ i_bits
> 0;
954 v
->value_int_4
[3] = 0;
959 /* GL_ARB_vertex_buffer_object */
960 case GL_VERTEX_ARRAY_BUFFER_BINDING_ARB
:
961 case GL_NORMAL_ARRAY_BUFFER_BINDING_ARB
:
962 case GL_COLOR_ARRAY_BUFFER_BINDING_ARB
:
963 case GL_INDEX_ARRAY_BUFFER_BINDING_ARB
:
964 case GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB
:
965 case GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB
:
966 case GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB
:
967 buffer_obj
= (struct gl_buffer_object
**)
968 ((char *) ctx
->Array
.VAO
+ d
->offset
);
969 v
->value_int
= (*buffer_obj
)->Name
;
971 case GL_ARRAY_BUFFER_BINDING_ARB
:
972 v
->value_int
= ctx
->Array
.ArrayBufferObj
->Name
;
974 case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB
:
976 ctx
->Array
.VAO
->BufferBinding
[VERT_ATTRIB_TEX(ctx
->Array
.ActiveTexture
)].BufferObj
->Name
;
978 case GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB
:
979 v
->value_int
= ctx
->Array
.VAO
->IndexBufferObj
->Name
;
982 /* ARB_vertex_array_bgra */
983 case GL_COLOR_ARRAY_SIZE
:
984 array
= &ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_COLOR0
];
985 v
->value_int
= array
->Format
.Format
== GL_BGRA
? GL_BGRA
: array
->Format
.Size
;
987 case GL_SECONDARY_COLOR_ARRAY_SIZE
:
988 array
= &ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_COLOR1
];
989 v
->value_int
= array
->Format
.Format
== GL_BGRA
? GL_BGRA
: array
->Format
.Size
;
992 /* ARB_copy_buffer */
993 case GL_COPY_READ_BUFFER
:
994 v
->value_int
= ctx
->CopyReadBuffer
->Name
;
996 case GL_COPY_WRITE_BUFFER
:
997 v
->value_int
= ctx
->CopyWriteBuffer
->Name
;
1000 case GL_PIXEL_PACK_BUFFER_BINDING_EXT
:
1001 v
->value_int
= ctx
->Pack
.BufferObj
->Name
;
1003 case GL_PIXEL_UNPACK_BUFFER_BINDING_EXT
:
1004 v
->value_int
= ctx
->Unpack
.BufferObj
->Name
;
1006 case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING
:
1007 v
->value_int
= ctx
->TransformFeedback
.CurrentBuffer
->Name
;
1009 case GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED
:
1010 v
->value_int
= ctx
->TransformFeedback
.CurrentObject
->Paused
;
1012 case GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE
:
1013 v
->value_int
= ctx
->TransformFeedback
.CurrentObject
->Active
;
1015 case GL_TRANSFORM_FEEDBACK_BINDING
:
1016 v
->value_int
= ctx
->TransformFeedback
.CurrentObject
->Name
;
1018 case GL_CURRENT_PROGRAM
:
1019 /* The Changelog of the ARB_separate_shader_objects spec says:
1021 * 24 25 Jul 2011 pbrown Remove the language erroneously deleting
1022 * CURRENT_PROGRAM. In the EXT extension, this
1023 * token was aliased to ACTIVE_PROGRAM_EXT, and
1024 * was used to indicate the last program set by
1025 * either ActiveProgramEXT or UseProgram. In
1026 * the ARB extension, the SSO active programs
1027 * are now program pipeline object state and
1028 * CURRENT_PROGRAM should still be used to query
1029 * the last program set by UseProgram (bug 7822).
1032 ctx
->Shader
.ActiveProgram
? ctx
->Shader
.ActiveProgram
->Name
: 0;
1034 case GL_READ_FRAMEBUFFER_BINDING_EXT
:
1035 v
->value_int
= ctx
->ReadBuffer
->Name
;
1037 case GL_RENDERBUFFER_BINDING_EXT
:
1039 ctx
->CurrentRenderbuffer
? ctx
->CurrentRenderbuffer
->Name
: 0;
1041 case GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES
:
1042 v
->value_int
= ctx
->Array
.VAO
->BufferBinding
[VERT_ATTRIB_POINT_SIZE
].BufferObj
->Name
;
1046 if (_mesa_get_clamp_fragment_color(ctx
, ctx
->DrawBuffer
))
1047 COPY_4FV(v
->value_float_4
, ctx
->Fog
.Color
);
1049 COPY_4FV(v
->value_float_4
, ctx
->Fog
.ColorUnclamped
);
1051 case GL_COLOR_CLEAR_VALUE
:
1052 if (_mesa_get_clamp_fragment_color(ctx
, ctx
->DrawBuffer
)) {
1053 v
->value_float_4
[0] = CLAMP(ctx
->Color
.ClearColor
.f
[0], 0.0F
, 1.0F
);
1054 v
->value_float_4
[1] = CLAMP(ctx
->Color
.ClearColor
.f
[1], 0.0F
, 1.0F
);
1055 v
->value_float_4
[2] = CLAMP(ctx
->Color
.ClearColor
.f
[2], 0.0F
, 1.0F
);
1056 v
->value_float_4
[3] = CLAMP(ctx
->Color
.ClearColor
.f
[3], 0.0F
, 1.0F
);
1058 COPY_4FV(v
->value_float_4
, ctx
->Color
.ClearColor
.f
);
1060 case GL_BLEND_COLOR_EXT
:
1061 if (_mesa_get_clamp_fragment_color(ctx
, ctx
->DrawBuffer
))
1062 COPY_4FV(v
->value_float_4
, ctx
->Color
.BlendColor
);
1064 COPY_4FV(v
->value_float_4
, ctx
->Color
.BlendColorUnclamped
);
1066 case GL_ALPHA_TEST_REF
:
1067 if (_mesa_get_clamp_fragment_color(ctx
, ctx
->DrawBuffer
))
1068 v
->value_float
= ctx
->Color
.AlphaRef
;
1070 v
->value_float
= ctx
->Color
.AlphaRefUnclamped
;
1072 case GL_MAX_VERTEX_UNIFORM_VECTORS
:
1073 v
->value_int
= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxUniformComponents
/ 4;
1076 case GL_MAX_FRAGMENT_UNIFORM_VECTORS
:
1077 v
->value_int
= ctx
->Const
.Program
[MESA_SHADER_FRAGMENT
].MaxUniformComponents
/ 4;
1080 /* GL_ARB_texture_buffer_object */
1081 case GL_TEXTURE_BUFFER_ARB
:
1082 v
->value_int
= ctx
->Texture
.BufferObject
->Name
;
1084 case GL_TEXTURE_BINDING_BUFFER_ARB
:
1085 unit
= ctx
->Texture
.CurrentUnit
;
1087 ctx
->Texture
.Unit
[unit
].CurrentTex
[TEXTURE_BUFFER_INDEX
]->Name
;
1089 case GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB
:
1091 struct gl_buffer_object
*buf
=
1092 ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
]
1093 .CurrentTex
[TEXTURE_BUFFER_INDEX
]->BufferObject
;
1094 v
->value_int
= buf
? buf
->Name
: 0;
1097 case GL_TEXTURE_BUFFER_FORMAT_ARB
:
1098 v
->value_int
= ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
]
1099 .CurrentTex
[TEXTURE_BUFFER_INDEX
]->BufferObjectFormat
;
1102 /* GL_ARB_sampler_objects */
1103 case GL_SAMPLER_BINDING
:
1105 struct gl_sampler_object
*samp
=
1106 ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
].Sampler
;
1107 v
->value_int
= samp
? samp
->Name
: 0;
1110 /* GL_ARB_uniform_buffer_object */
1111 case GL_UNIFORM_BUFFER_BINDING
:
1112 v
->value_int
= ctx
->UniformBuffer
->Name
;
1114 /* GL_ARB_shader_storage_buffer_object */
1115 case GL_SHADER_STORAGE_BUFFER_BINDING
:
1116 v
->value_int
= ctx
->ShaderStorageBuffer
->Name
;
1118 /* GL_ARB_query_buffer_object */
1119 case GL_QUERY_BUFFER_BINDING
:
1120 v
->value_int
= ctx
->QueryBuffer
->Name
;
1122 /* GL_ARB_timer_query */
1124 if (ctx
->Driver
.GetTimestamp
) {
1125 v
->value_int64
= ctx
->Driver
.GetTimestamp(ctx
);
1128 _mesa_problem(ctx
, "driver doesn't implement GetTimestamp");
1132 case GL_DEBUG_OUTPUT
:
1133 case GL_DEBUG_OUTPUT_SYNCHRONOUS
:
1134 case GL_DEBUG_LOGGED_MESSAGES
:
1135 case GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH
:
1136 case GL_DEBUG_GROUP_STACK_DEPTH
:
1137 v
->value_int
= _mesa_get_debug_state_int(ctx
, d
->pname
);
1139 /* GL_ARB_shader_atomic_counters */
1140 case GL_ATOMIC_COUNTER_BUFFER_BINDING
:
1141 if (ctx
->AtomicBuffer
) {
1142 v
->value_int
= ctx
->AtomicBuffer
->Name
;
1148 case GL_NUM_SHADING_LANGUAGE_VERSIONS
:
1149 v
->value_int
= _mesa_get_shading_language_version(ctx
, -1, NULL
);
1151 /* GL_ARB_draw_indirect */
1152 case GL_DRAW_INDIRECT_BUFFER_BINDING
:
1153 v
->value_int
= ctx
->DrawIndirectBuffer
->Name
;
1155 /* GL_ARB_indirect_parameters */
1156 case GL_PARAMETER_BUFFER_BINDING_ARB
:
1157 v
->value_int
= ctx
->ParameterBuffer
->Name
;
1159 /* GL_ARB_separate_shader_objects */
1160 case GL_PROGRAM_PIPELINE_BINDING
:
1161 if (ctx
->Pipeline
.Current
) {
1162 v
->value_int
= ctx
->Pipeline
.Current
->Name
;
1167 /* GL_ARB_compute_shader */
1168 case GL_DISPATCH_INDIRECT_BUFFER_BINDING
:
1169 v
->value_int
= ctx
->DispatchIndirectBuffer
->Name
;
1171 /* GL_ARB_multisample */
1173 v
->value_int
= _mesa_geometric_samples(ctx
->DrawBuffer
);
1175 case GL_SAMPLE_BUFFERS
:
1176 v
->value_int
= _mesa_geometric_samples(ctx
->DrawBuffer
) > 0;
1178 /* GL_EXT_textrue_integer */
1179 case GL_RGBA_INTEGER_MODE_EXT
:
1180 v
->value_int
= (ctx
->DrawBuffer
->_IntegerBuffers
!= 0);
1182 /* GL_ATI_meminfo & GL_NVX_gpu_memory_info */
1183 case GL_VBO_FREE_MEMORY_ATI
:
1184 case GL_TEXTURE_FREE_MEMORY_ATI
:
1185 case GL_RENDERBUFFER_FREE_MEMORY_ATI
:
1186 case GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX
:
1187 case GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX
:
1188 case GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX
:
1189 case GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX
:
1190 case GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX
:
1192 struct gl_memory_info info
;
1194 ctx
->Driver
.QueryMemoryInfo(ctx
, &info
);
1196 if (d
->pname
== GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX
)
1197 v
->value_int
= info
.total_device_memory
;
1198 else if (d
->pname
== GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX
)
1199 v
->value_int
= info
.total_device_memory
+
1200 info
.total_staging_memory
;
1201 else if (d
->pname
== GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX
)
1202 v
->value_int
= info
.avail_device_memory
;
1203 else if (d
->pname
== GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX
)
1204 v
->value_int
= info
.nr_device_memory_evictions
;
1205 else if (d
->pname
== GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX
)
1206 v
->value_int
= info
.device_memory_evicted
;
1208 /* ATI free memory enums.
1210 * Since the GPU memory is (usually) page-table based, every two
1211 * consecutive elements are equal. From the GL_ATI_meminfo
1214 * "param[0] - total memory free in the pool
1215 * param[1] - largest available free block in the pool
1216 * param[2] - total auxiliary memory free
1217 * param[3] - largest auxiliary free block"
1219 * All three (VBO, TEXTURE, RENDERBUFFER) queries return
1220 * the same numbers here.
1222 v
->value_int_4
[0] = info
.avail_device_memory
;
1223 v
->value_int_4
[1] = info
.avail_device_memory
;
1224 v
->value_int_4
[2] = info
.avail_staging_memory
;
1225 v
->value_int_4
[3] = info
.avail_staging_memory
;
1230 /* GL_ARB_get_program_binary */
1231 case GL_PROGRAM_BINARY_FORMATS
:
1232 assert(ctx
->Const
.NumProgramBinaryFormats
<= 1);
1233 v
->value_int_n
.n
= MIN2(ctx
->Const
.NumProgramBinaryFormats
, 1);
1234 if (ctx
->Const
.NumProgramBinaryFormats
> 0) {
1235 v
->value_int_n
.ints
[0] = GL_PROGRAM_BINARY_FORMAT_MESA
;
1238 /* GL_EXT_disjoint_timer_query */
1239 case GL_GPU_DISJOINT_EXT
:
1241 simple_mtx_lock(&ctx
->Shared
->Mutex
);
1242 v
->value_int
= ctx
->Shared
->DisjointOperation
;
1243 /* Reset state as expected by the spec. */
1244 ctx
->Shared
->DisjointOperation
= false;
1245 simple_mtx_unlock(&ctx
->Shared
->Mutex
);
1248 /* GL_ARB_sample_locations */
1249 case GL_SAMPLE_LOCATION_SUBPIXEL_BITS_ARB
:
1250 case GL_SAMPLE_LOCATION_PIXEL_GRID_WIDTH_ARB
:
1251 case GL_SAMPLE_LOCATION_PIXEL_GRID_HEIGHT_ARB
:
1253 GLuint bits
, width
, height
;
1255 if (ctx
->NewState
& _NEW_BUFFERS
)
1256 _mesa_update_state(ctx
);
1258 if (ctx
->DrawBuffer
->_Status
!= GL_FRAMEBUFFER_COMPLETE
) {
1263 ctx
->Driver
.GetProgrammableSampleCaps(ctx
, ctx
->DrawBuffer
,
1264 &bits
, &width
, &height
);
1266 if (d
->pname
== GL_SAMPLE_LOCATION_PIXEL_GRID_WIDTH_ARB
)
1267 v
->value_uint
= width
;
1268 else if (d
->pname
== GL_SAMPLE_LOCATION_PIXEL_GRID_HEIGHT_ARB
)
1269 v
->value_uint
= height
;
1271 v
->value_uint
= bits
;
1274 case GL_PROGRAMMABLE_SAMPLE_LOCATION_TABLE_SIZE_ARB
:
1275 v
->value_uint
= MAX_SAMPLE_LOCATION_TABLE_SIZE
;
1278 /* GL_AMD_framebuffer_multisample_advanced */
1279 case GL_SUPPORTED_MULTISAMPLE_MODES_AMD
:
1280 v
->value_int_n
.n
= ctx
->Const
.NumSupportedMultisampleModes
* 3;
1281 memcpy(v
->value_int_n
.ints
, ctx
->Const
.SupportedMultisampleModes
,
1282 v
->value_int_n
.n
* sizeof(GLint
));
1288 * Check extra constraints on a struct value_desc descriptor
1290 * If a struct value_desc has a non-NULL extra pointer, it means that
1291 * there are a number of extra constraints to check or actions to
1292 * perform. The extras is just an integer array where each integer
1293 * encode different constraints or actions.
1295 * \param ctx current context
1296 * \param func name of calling glGet*v() function for error reporting
1297 * \param d the struct value_desc that has the extra constraints
1299 * \return GL_FALSE if all of the constraints were not satisfied,
1300 * otherwise GL_TRUE.
1303 check_extra(struct gl_context
*ctx
, const char *func
, const struct value_desc
*d
)
1305 const GLuint version
= ctx
->Version
;
1306 GLboolean api_check
= GL_FALSE
;
1307 GLboolean api_found
= GL_FALSE
;
1310 for (e
= d
->extra
; *e
!= EXTRA_END
; e
++) {
1312 case EXTRA_VERSION_30
:
1313 api_check
= GL_TRUE
;
1315 api_found
= GL_TRUE
;
1317 case EXTRA_VERSION_31
:
1318 api_check
= GL_TRUE
;
1320 api_found
= GL_TRUE
;
1322 case EXTRA_VERSION_32
:
1323 api_check
= GL_TRUE
;
1325 api_found
= GL_TRUE
;
1327 case EXTRA_VERSION_40
:
1328 api_check
= GL_TRUE
;
1330 api_found
= GL_TRUE
;
1332 case EXTRA_VERSION_43
:
1334 if (_mesa_is_desktop_gl(ctx
) && version
>= 43)
1335 api_found
= GL_TRUE
;
1337 case EXTRA_NEW_FRAG_CLAMP
:
1338 if (ctx
->NewState
& (_NEW_BUFFERS
| _NEW_FRAG_CLAMP
))
1339 _mesa_update_state(ctx
);
1342 api_check
= GL_TRUE
;
1343 if (ctx
->API
== API_OPENGLES2
)
1344 api_found
= GL_TRUE
;
1347 api_check
= GL_TRUE
;
1348 if (_mesa_is_gles3(ctx
))
1349 api_found
= GL_TRUE
;
1351 case EXTRA_API_ES31
:
1352 api_check
= GL_TRUE
;
1353 if (_mesa_is_gles31(ctx
))
1354 api_found
= GL_TRUE
;
1356 case EXTRA_API_ES32
:
1357 api_check
= GL_TRUE
;
1358 if (_mesa_is_gles32(ctx
))
1359 api_found
= GL_TRUE
;
1362 api_check
= GL_TRUE
;
1363 if (_mesa_is_desktop_gl(ctx
))
1364 api_found
= GL_TRUE
;
1366 case EXTRA_API_GL_CORE
:
1367 api_check
= GL_TRUE
;
1368 if (ctx
->API
== API_OPENGL_CORE
)
1369 api_found
= GL_TRUE
;
1371 case EXTRA_NEW_BUFFERS
:
1372 if (ctx
->NewState
& _NEW_BUFFERS
)
1373 _mesa_update_state(ctx
);
1375 case EXTRA_FLUSH_CURRENT
:
1376 FLUSH_CURRENT(ctx
, 0);
1378 case EXTRA_VALID_DRAW_BUFFER
:
1379 if (d
->pname
- GL_DRAW_BUFFER0_ARB
>= ctx
->Const
.MaxDrawBuffers
) {
1380 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(draw buffer %u)",
1381 func
, d
->pname
- GL_DRAW_BUFFER0_ARB
);
1385 case EXTRA_VALID_TEXTURE_UNIT
:
1386 if (ctx
->Texture
.CurrentUnit
>= ctx
->Const
.MaxTextureCoordUnits
) {
1387 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(texture %u)",
1388 func
, ctx
->Texture
.CurrentUnit
);
1392 case EXTRA_VALID_CLIP_DISTANCE
:
1393 if (d
->pname
- GL_CLIP_DISTANCE0
>= ctx
->Const
.MaxClipPlanes
) {
1394 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(clip distance %u)",
1395 func
, d
->pname
- GL_CLIP_DISTANCE0
);
1399 case EXTRA_GLSL_130
:
1400 api_check
= GL_TRUE
;
1401 if (ctx
->Const
.GLSLVersion
>= 130)
1402 api_found
= GL_TRUE
;
1404 case EXTRA_EXT_UBO_GS
:
1405 api_check
= GL_TRUE
;
1406 if (ctx
->Extensions
.ARB_uniform_buffer_object
&&
1407 _mesa_has_geometry_shaders(ctx
))
1408 api_found
= GL_TRUE
;
1410 case EXTRA_EXT_ATOMICS_GS
:
1411 api_check
= GL_TRUE
;
1412 if (ctx
->Extensions
.ARB_shader_atomic_counters
&&
1413 _mesa_has_geometry_shaders(ctx
))
1414 api_found
= GL_TRUE
;
1416 case EXTRA_EXT_SHADER_IMAGE_GS
:
1417 api_check
= GL_TRUE
;
1418 if (ctx
->Extensions
.ARB_shader_image_load_store
&&
1419 _mesa_has_geometry_shaders(ctx
))
1420 api_found
= GL_TRUE
;
1422 case EXTRA_EXT_ATOMICS_TESS
:
1423 api_check
= GL_TRUE
;
1424 api_found
= ctx
->Extensions
.ARB_shader_atomic_counters
&&
1425 _mesa_has_tessellation(ctx
);
1427 case EXTRA_EXT_SHADER_IMAGE_TESS
:
1428 api_check
= GL_TRUE
;
1429 api_found
= ctx
->Extensions
.ARB_shader_image_load_store
&&
1430 _mesa_has_tessellation(ctx
);
1432 case EXTRA_EXT_SSBO_GS
:
1433 api_check
= GL_TRUE
;
1434 if (ctx
->Extensions
.ARB_shader_storage_buffer_object
&&
1435 _mesa_has_geometry_shaders(ctx
))
1436 api_found
= GL_TRUE
;
1438 case EXTRA_EXT_FB_NO_ATTACH_GS
:
1439 api_check
= GL_TRUE
;
1440 if (ctx
->Extensions
.ARB_framebuffer_no_attachments
&&
1441 (_mesa_is_desktop_gl(ctx
) ||
1442 _mesa_has_OES_geometry_shader(ctx
)))
1443 api_found
= GL_TRUE
;
1445 case EXTRA_EXT_ES_GS
:
1446 api_check
= GL_TRUE
;
1447 if (_mesa_has_OES_geometry_shader(ctx
))
1448 api_found
= GL_TRUE
;
1450 case EXTRA_EXT_PROVOKING_VERTEX_32
:
1452 if (ctx
->API
== API_OPENGL_COMPAT
|| version
== 32)
1453 api_found
= ctx
->Extensions
.EXT_provoking_vertex
;
1457 default: /* *e is a offset into the extension struct */
1458 api_check
= GL_TRUE
;
1459 if (*(GLboolean
*) ((char *) &ctx
->Extensions
+ *e
))
1460 api_found
= GL_TRUE
;
1465 if (api_check
&& !api_found
) {
1466 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(pname=%s)", func
,
1467 _mesa_enum_to_string(d
->pname
));
1474 static const struct value_desc error_value
=
1475 { 0, 0, TYPE_INVALID
, NO_OFFSET
, NO_EXTRA
};
1478 * Find the struct value_desc corresponding to the enum 'pname'.
1480 * We hash the enum value to get an index into the 'table' array,
1481 * which holds the index in the 'values' array of struct value_desc.
1482 * Once we've found the entry, we do the extra checks, if any, then
1483 * look up the value and return a pointer to it.
1485 * If the value has to be computed (for example, it's the result of a
1486 * function call or we need to add 1 to it), we use the tmp 'v' to
1489 * \param func name of glGet*v() func for error reporting
1490 * \param pname the enum value we're looking up
1491 * \param p is were we return the pointer to the value
1492 * \param v a tmp union value variable in the calling glGet*v() function
1494 * \return the struct value_desc corresponding to the enum or a struct
1495 * value_desc of TYPE_INVALID if not found. This lets the calling
1496 * glGet*v() function jump right into a switch statement and
1497 * handle errors there instead of having to check for NULL.
1499 static const struct value_desc
*
1500 find_value(const char *func
, GLenum pname
, void **p
, union value
*v
)
1502 GET_CURRENT_CONTEXT(ctx
);
1504 const struct value_desc
*d
;
1508 /* We index into the table_set[] list of per-API hash tables using the API's
1509 * value in the gl_api enum. Since GLES 3 doesn't have an API_OPENGL* enum
1510 * value since it's compatible with GLES2 its entry in table_set[] is at the
1513 STATIC_ASSERT(ARRAY_SIZE(table_set
) == API_OPENGL_LAST
+ 4);
1514 if (ctx
->API
== API_OPENGLES2
) {
1515 if (ctx
->Version
>= 32)
1516 api
= API_OPENGL_LAST
+ 3;
1517 else if (ctx
->Version
>= 31)
1518 api
= API_OPENGL_LAST
+ 2;
1519 else if (ctx
->Version
>= 30)
1520 api
= API_OPENGL_LAST
+ 1;
1522 mask
= ARRAY_SIZE(table(api
)) - 1;
1523 hash
= (pname
* prime_factor
);
1525 int idx
= table(api
)[hash
& mask
];
1527 /* If the enum isn't valid, the hash walk ends with index 0,
1528 * pointing to the first entry of values[] which doesn't hold
1529 * any valid enum. */
1530 if (unlikely(idx
== 0)) {
1531 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(pname=%s)", func
,
1532 _mesa_enum_to_string(pname
));
1533 return &error_value
;
1537 if (likely(d
->pname
== pname
))
1543 if (unlikely(d
->extra
&& !check_extra(ctx
, func
, d
)))
1544 return &error_value
;
1546 switch (d
->location
) {
1548 *p
= ((char *) ctx
->DrawBuffer
+ d
->offset
);
1551 *p
= ((char *) ctx
+ d
->offset
);
1554 *p
= ((char *) ctx
->Array
.VAO
+ d
->offset
);
1557 if (ctx
->Texture
.CurrentUnit
< ARRAY_SIZE(ctx
->Texture
.FixedFuncUnit
)) {
1558 unsigned index
= ctx
->Texture
.CurrentUnit
;
1559 *p
= ((char *)&ctx
->Texture
.FixedFuncUnit
[index
] + d
->offset
);
1563 find_custom_value(ctx
, d
, v
);
1571 /* silence warning */
1572 return &error_value
;
1575 static const int transpose
[] = {
1583 get_value_size(enum value_type type
, const union value
*v
)
1591 return sizeof(GLint
);
1594 return sizeof(GLint
) * 2;
1597 return sizeof(GLint
) * 3;
1600 return sizeof(GLint
) * 4;
1602 return sizeof(GLint
) * v
->value_int_n
.n
;
1604 return sizeof(GLint64
);
1607 return sizeof(GLenum16
);
1609 return sizeof(GLenum
);
1611 return sizeof(GLenum
) * 2;
1613 return sizeof(GLboolean
);
1615 return sizeof(GLubyte
);
1617 return sizeof(GLshort
);
1629 return sizeof(GLfloat
);
1632 return sizeof(GLfloat
) * 2;
1635 return sizeof(GLfloat
) * 3;
1638 return sizeof(GLfloat
) * 4;
1640 return sizeof(GLfloat
) * 8;
1642 return sizeof(GLdouble
);
1643 case TYPE_DOUBLEN_2
:
1644 return sizeof(GLdouble
) * 2;
1646 return sizeof (GLfloat
) * 16;
1648 return sizeof (GLfloat
) * 16;
1655 _mesa_GetBooleanv(GLenum pname
, GLboolean
*params
)
1657 const struct value_desc
*d
;
1663 d
= find_value("glGetBooleanv", pname
, &p
, &v
);
1668 params
[0] = INT_TO_BOOLEAN(d
->offset
);
1672 params
[7] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[7]);
1673 params
[6] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[6]);
1674 params
[5] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[5]);
1675 params
[4] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[4]);
1678 params
[3] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[3]);
1681 params
[2] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[2]);
1684 params
[1] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[1]);
1687 params
[0] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[0]);
1690 case TYPE_DOUBLEN_2
:
1691 params
[1] = FLOAT_TO_BOOLEAN(((GLdouble
*) p
)[1]);
1693 params
[0] = FLOAT_TO_BOOLEAN(((GLdouble
*) p
)[0]);
1698 params
[3] = INT_TO_BOOLEAN(((GLint
*) p
)[3]);
1701 params
[2] = INT_TO_BOOLEAN(((GLint
*) p
)[2]);
1705 params
[1] = INT_TO_BOOLEAN(((GLint
*) p
)[1]);
1709 params
[0] = INT_TO_BOOLEAN(((GLint
*) p
)[0]);
1713 params
[0] = INT_TO_BOOLEAN(((GLenum16
*) p
)[0]);
1717 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
1718 params
[i
] = INT_TO_BOOLEAN(v
.value_int_n
.ints
[i
]);
1722 params
[0] = INT64_TO_BOOLEAN(((GLint64
*) p
)[0]);
1726 params
[0] = ((GLboolean
*) p
)[0];
1730 params
[0] = INT_TO_BOOLEAN(((GLubyte
*) p
)[0]);
1734 params
[0] = INT_TO_BOOLEAN(((GLshort
*) p
)[0]);
1738 m
= *(GLmatrix
**) p
;
1739 for (i
= 0; i
< 16; i
++)
1740 params
[i
] = FLOAT_TO_BOOLEAN(m
->m
[i
]);
1744 m
= *(GLmatrix
**) p
;
1745 for (i
= 0; i
< 16; i
++)
1746 params
[i
] = FLOAT_TO_BOOLEAN(m
->m
[transpose
[i
]]);
1757 shift
= d
->type
- TYPE_BIT_0
;
1758 params
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
1764 _mesa_GetFloatv(GLenum pname
, GLfloat
*params
)
1766 const struct value_desc
*d
;
1772 d
= find_value("glGetFloatv", pname
, &p
, &v
);
1777 params
[0] = (GLfloat
) d
->offset
;
1781 params
[7] = ((GLfloat
*) p
)[7];
1782 params
[6] = ((GLfloat
*) p
)[6];
1783 params
[5] = ((GLfloat
*) p
)[5];
1784 params
[4] = ((GLfloat
*) p
)[4];
1787 params
[3] = ((GLfloat
*) p
)[3];
1790 params
[2] = ((GLfloat
*) p
)[2];
1793 params
[1] = ((GLfloat
*) p
)[1];
1796 params
[0] = ((GLfloat
*) p
)[0];
1799 case TYPE_DOUBLEN_2
:
1800 params
[1] = (GLfloat
) (((GLdouble
*) p
)[1]);
1802 params
[0] = (GLfloat
) (((GLdouble
*) p
)[0]);
1806 params
[3] = (GLfloat
) (((GLint
*) p
)[3]);
1808 params
[2] = (GLfloat
) (((GLint
*) p
)[2]);
1811 params
[1] = (GLfloat
) (((GLint
*) p
)[1]);
1814 params
[0] = (GLfloat
) (((GLint
*) p
)[0]);
1818 params
[0] = (GLfloat
) (((GLenum16
*) p
)[0]);
1822 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
1823 params
[i
] = (GLfloat
) v
.value_int_n
.ints
[i
];
1827 params
[3] = (GLfloat
) (((GLuint
*) p
)[3]);
1829 params
[2] = (GLfloat
) (((GLuint
*) p
)[2]);
1831 params
[1] = (GLfloat
) (((GLuint
*) p
)[1]);
1833 params
[0] = (GLfloat
) (((GLuint
*) p
)[0]);
1837 params
[0] = (GLfloat
) (((GLint64
*) p
)[0]);
1841 params
[0] = BOOLEAN_TO_FLOAT(*(GLboolean
*) p
);
1845 params
[0] = (GLfloat
) ((GLubyte
*) p
)[0];
1849 params
[0] = (GLfloat
) ((GLshort
*) p
)[0];
1853 m
= *(GLmatrix
**) p
;
1854 for (i
= 0; i
< 16; i
++)
1855 params
[i
] = m
->m
[i
];
1859 m
= *(GLmatrix
**) p
;
1860 for (i
= 0; i
< 16; i
++)
1861 params
[i
] = m
->m
[transpose
[i
]];
1872 shift
= d
->type
- TYPE_BIT_0
;
1873 params
[0] = BOOLEAN_TO_FLOAT((*(GLbitfield
*) p
>> shift
) & 1);
1879 _mesa_GetIntegerv(GLenum pname
, GLint
*params
)
1881 const struct value_desc
*d
;
1887 d
= find_value("glGetIntegerv", pname
, &p
, &v
);
1892 params
[0] = d
->offset
;
1896 params
[7] = IROUND(((GLfloat
*) p
)[7]);
1897 params
[6] = IROUND(((GLfloat
*) p
)[6]);
1898 params
[5] = IROUND(((GLfloat
*) p
)[5]);
1899 params
[4] = IROUND(((GLfloat
*) p
)[4]);
1901 params
[3] = IROUND(((GLfloat
*) p
)[3]);
1903 params
[2] = IROUND(((GLfloat
*) p
)[2]);
1905 params
[1] = IROUND(((GLfloat
*) p
)[1]);
1907 params
[0] = IROUND(((GLfloat
*) p
)[0]);
1911 params
[3] = FLOAT_TO_INT(((GLfloat
*) p
)[3]);
1913 params
[2] = FLOAT_TO_INT(((GLfloat
*) p
)[2]);
1915 params
[1] = FLOAT_TO_INT(((GLfloat
*) p
)[1]);
1917 params
[0] = FLOAT_TO_INT(((GLfloat
*) p
)[0]);
1920 case TYPE_DOUBLEN_2
:
1921 params
[1] = FLOAT_TO_INT(((GLdouble
*) p
)[1]);
1923 params
[0] = FLOAT_TO_INT(((GLdouble
*) p
)[0]);
1928 params
[3] = ((GLint
*) p
)[3];
1931 params
[2] = ((GLint
*) p
)[2];
1935 params
[1] = ((GLint
*) p
)[1];
1939 params
[0] = ((GLint
*) p
)[0];
1943 params
[0] = ((GLenum16
*) p
)[0];
1947 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
1948 params
[i
] = v
.value_int_n
.ints
[i
];
1952 params
[0] = INT64_TO_INT(((GLint64
*) p
)[0]);
1956 params
[0] = BOOLEAN_TO_INT(*(GLboolean
*) p
);
1960 params
[0] = ((GLubyte
*) p
)[0];
1964 params
[0] = ((GLshort
*) p
)[0];
1968 m
= *(GLmatrix
**) p
;
1969 for (i
= 0; i
< 16; i
++)
1970 params
[i
] = FLOAT_TO_INT(m
->m
[i
]);
1974 m
= *(GLmatrix
**) p
;
1975 for (i
= 0; i
< 16; i
++)
1976 params
[i
] = FLOAT_TO_INT(m
->m
[transpose
[i
]]);
1987 shift
= d
->type
- TYPE_BIT_0
;
1988 params
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
1994 _mesa_GetInteger64v(GLenum pname
, GLint64
*params
)
1996 const struct value_desc
*d
;
2002 d
= find_value("glGetInteger64v", pname
, &p
, &v
);
2007 params
[0] = d
->offset
;
2011 params
[7] = IROUND64(((GLfloat
*) p
)[7]);
2012 params
[6] = IROUND64(((GLfloat
*) p
)[6]);
2013 params
[5] = IROUND64(((GLfloat
*) p
)[5]);
2014 params
[4] = IROUND64(((GLfloat
*) p
)[4]);
2016 params
[3] = IROUND64(((GLfloat
*) p
)[3]);
2018 params
[2] = IROUND64(((GLfloat
*) p
)[2]);
2020 params
[1] = IROUND64(((GLfloat
*) p
)[1]);
2022 params
[0] = IROUND64(((GLfloat
*) p
)[0]);
2026 params
[3] = FLOAT_TO_INT(((GLfloat
*) p
)[3]);
2028 params
[2] = FLOAT_TO_INT(((GLfloat
*) p
)[2]);
2030 params
[1] = FLOAT_TO_INT(((GLfloat
*) p
)[1]);
2032 params
[0] = FLOAT_TO_INT(((GLfloat
*) p
)[0]);
2035 case TYPE_DOUBLEN_2
:
2036 params
[1] = FLOAT_TO_INT(((GLdouble
*) p
)[1]);
2038 params
[0] = FLOAT_TO_INT(((GLdouble
*) p
)[0]);
2042 params
[3] = ((GLint
*) p
)[3];
2044 params
[2] = ((GLint
*) p
)[2];
2047 params
[1] = ((GLint
*) p
)[1];
2050 params
[0] = ((GLint
*) p
)[0];
2054 params
[0] = ((GLenum16
*) p
)[0];
2058 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
2059 params
[i
] = v
.value_int_n
.ints
[i
];
2063 params
[3] = ((GLuint
*) p
)[3];
2065 params
[2] = ((GLuint
*) p
)[2];
2067 params
[1] = ((GLuint
*) p
)[1];
2069 params
[0] = ((GLuint
*) p
)[0];
2073 params
[0] = ((GLint64
*) p
)[0];
2077 params
[0] = ((GLboolean
*) p
)[0];
2081 m
= *(GLmatrix
**) p
;
2082 for (i
= 0; i
< 16; i
++)
2083 params
[i
] = FLOAT_TO_INT64(m
->m
[i
]);
2087 m
= *(GLmatrix
**) p
;
2088 for (i
= 0; i
< 16; i
++)
2089 params
[i
] = FLOAT_TO_INT64(m
->m
[transpose
[i
]]);
2100 shift
= d
->type
- TYPE_BIT_0
;
2101 params
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
2107 _mesa_GetDoublev(GLenum pname
, GLdouble
*params
)
2109 const struct value_desc
*d
;
2115 d
= find_value("glGetDoublev", pname
, &p
, &v
);
2120 params
[0] = d
->offset
;
2124 params
[7] = ((GLfloat
*) p
)[7];
2125 params
[6] = ((GLfloat
*) p
)[6];
2126 params
[5] = ((GLfloat
*) p
)[5];
2127 params
[4] = ((GLfloat
*) p
)[4];
2130 params
[3] = ((GLfloat
*) p
)[3];
2133 params
[2] = ((GLfloat
*) p
)[2];
2136 params
[1] = ((GLfloat
*) p
)[1];
2139 params
[0] = ((GLfloat
*) p
)[0];
2142 case TYPE_DOUBLEN_2
:
2143 params
[1] = ((GLdouble
*) p
)[1];
2145 params
[0] = ((GLdouble
*) p
)[0];
2149 params
[3] = ((GLint
*) p
)[3];
2151 params
[2] = ((GLint
*) p
)[2];
2154 params
[1] = ((GLint
*) p
)[1];
2157 params
[0] = ((GLint
*) p
)[0];
2161 params
[0] = ((GLenum16
*) p
)[0];
2165 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
2166 params
[i
] = v
.value_int_n
.ints
[i
];
2170 params
[3] = ((GLuint
*) p
)[3];
2172 params
[2] = ((GLuint
*) p
)[2];
2174 params
[1] = ((GLuint
*) p
)[1];
2176 params
[0] = ((GLuint
*) p
)[0];
2180 params
[0] = (GLdouble
) (((GLint64
*) p
)[0]);
2184 params
[0] = *(GLboolean
*) p
;
2188 params
[0] = ((GLubyte
*) p
)[0];
2192 params
[0] = ((GLshort
*) p
)[0];
2196 m
= *(GLmatrix
**) p
;
2197 for (i
= 0; i
< 16; i
++)
2198 params
[i
] = m
->m
[i
];
2202 m
= *(GLmatrix
**) p
;
2203 for (i
= 0; i
< 16; i
++)
2204 params
[i
] = m
->m
[transpose
[i
]];
2215 shift
= d
->type
- TYPE_BIT_0
;
2216 params
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
2222 _mesa_GetUnsignedBytevEXT(GLenum pname
, GLubyte
*data
)
2224 const struct value_desc
*d
;
2229 const char *func
= "glGetUnsignedBytevEXT";
2231 GET_CURRENT_CONTEXT(ctx
);
2233 if (!ctx
->Extensions
.EXT_memory_object
) {
2234 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(unsupported)", func
);
2238 d
= find_value(func
, pname
, &p
, &v
);
2239 size
= get_value_size(d
->type
, &v
);
2241 _mesa_problem(ctx
, "invalid value type in GetUnsignedBytevEXT()");
2253 shift
= d
->type
- TYPE_BIT_0
;
2254 data
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
2257 memcpy(data
, &d
->offset
, size
);
2260 memcpy(data
, &v
.value_int_n
.ints
, size
);
2286 case TYPE_DOUBLEN_2
:
2289 memcpy(data
, p
, size
);
2292 GLenum e
= *(GLenum16
*)p
;
2293 memcpy(data
, &e
, sizeof(e
));
2297 break; /* nothing - GL error was recorded */
2302 * Convert a GL texture binding enum such as GL_TEXTURE_BINDING_2D
2303 * into the corresponding Mesa texture target index.
2304 * \return TEXTURE_x_INDEX or -1 if binding is invalid
2307 tex_binding_to_index(const struct gl_context
*ctx
, GLenum binding
)
2310 case GL_TEXTURE_BINDING_1D
:
2311 return _mesa_is_desktop_gl(ctx
) ? TEXTURE_1D_INDEX
: -1;
2312 case GL_TEXTURE_BINDING_2D
:
2313 return TEXTURE_2D_INDEX
;
2314 case GL_TEXTURE_BINDING_3D
:
2315 return ctx
->API
!= API_OPENGLES
? TEXTURE_3D_INDEX
: -1;
2316 case GL_TEXTURE_BINDING_CUBE_MAP
:
2317 return ctx
->Extensions
.ARB_texture_cube_map
2318 ? TEXTURE_CUBE_INDEX
: -1;
2319 case GL_TEXTURE_BINDING_RECTANGLE
:
2320 return _mesa_is_desktop_gl(ctx
) && ctx
->Extensions
.NV_texture_rectangle
2321 ? TEXTURE_RECT_INDEX
: -1;
2322 case GL_TEXTURE_BINDING_1D_ARRAY
:
2323 return _mesa_is_desktop_gl(ctx
) && ctx
->Extensions
.EXT_texture_array
2324 ? TEXTURE_1D_ARRAY_INDEX
: -1;
2325 case GL_TEXTURE_BINDING_2D_ARRAY
:
2326 return (_mesa_is_desktop_gl(ctx
) && ctx
->Extensions
.EXT_texture_array
)
2327 || _mesa_is_gles3(ctx
)
2328 ? TEXTURE_2D_ARRAY_INDEX
: -1;
2329 case GL_TEXTURE_BINDING_BUFFER
:
2330 return (_mesa_has_ARB_texture_buffer_object(ctx
) ||
2331 _mesa_has_OES_texture_buffer(ctx
)) ?
2332 TEXTURE_BUFFER_INDEX
: -1;
2333 case GL_TEXTURE_BINDING_CUBE_MAP_ARRAY
:
2334 return _mesa_has_texture_cube_map_array(ctx
)
2335 ? TEXTURE_CUBE_ARRAY_INDEX
: -1;
2336 case GL_TEXTURE_BINDING_2D_MULTISAMPLE
:
2337 return _mesa_is_desktop_gl(ctx
) && ctx
->Extensions
.ARB_texture_multisample
2338 ? TEXTURE_2D_MULTISAMPLE_INDEX
: -1;
2339 case GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY
:
2340 return _mesa_is_desktop_gl(ctx
) && ctx
->Extensions
.ARB_texture_multisample
2341 ? TEXTURE_2D_MULTISAMPLE_ARRAY_INDEX
: -1;
2347 static enum value_type
2348 find_value_indexed(const char *func
, GLenum pname
, GLuint index
, union value
*v
)
2350 GET_CURRENT_CONTEXT(ctx
);
2355 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2357 if (!ctx
->Extensions
.EXT_draw_buffers2
)
2359 v
->value_int
= (ctx
->Color
.BlendEnabled
>> index
) & 1;
2364 case GL_BLEND_SRC_RGB
:
2365 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2367 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
2369 v
->value_int
= ctx
->Color
.Blend
[index
].SrcRGB
;
2371 case GL_BLEND_SRC_ALPHA
:
2372 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2374 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
2376 v
->value_int
= ctx
->Color
.Blend
[index
].SrcA
;
2380 case GL_BLEND_DST_RGB
:
2381 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2383 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
2385 v
->value_int
= ctx
->Color
.Blend
[index
].DstRGB
;
2387 case GL_BLEND_DST_ALPHA
:
2388 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2390 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
2392 v
->value_int
= ctx
->Color
.Blend
[index
].DstA
;
2394 case GL_BLEND_EQUATION_RGB
:
2395 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2397 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
2399 v
->value_int
= ctx
->Color
.Blend
[index
].EquationRGB
;
2401 case GL_BLEND_EQUATION_ALPHA
:
2402 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2404 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
2406 v
->value_int
= ctx
->Color
.Blend
[index
].EquationA
;
2409 case GL_COLOR_WRITEMASK
:
2410 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2412 if (!ctx
->Extensions
.EXT_draw_buffers2
)
2414 v
->value_int_4
[0] = GET_COLORMASK_BIT(ctx
->Color
.ColorMask
, index
, 0);
2415 v
->value_int_4
[1] = GET_COLORMASK_BIT(ctx
->Color
.ColorMask
, index
, 1);
2416 v
->value_int_4
[2] = GET_COLORMASK_BIT(ctx
->Color
.ColorMask
, index
, 2);
2417 v
->value_int_4
[3] = GET_COLORMASK_BIT(ctx
->Color
.ColorMask
, index
, 3);
2420 case GL_SCISSOR_BOX
:
2421 if (index
>= ctx
->Const
.MaxViewports
)
2423 v
->value_int_4
[0] = ctx
->Scissor
.ScissorArray
[index
].X
;
2424 v
->value_int_4
[1] = ctx
->Scissor
.ScissorArray
[index
].Y
;
2425 v
->value_int_4
[2] = ctx
->Scissor
.ScissorArray
[index
].Width
;
2426 v
->value_int_4
[3] = ctx
->Scissor
.ScissorArray
[index
].Height
;
2429 case GL_WINDOW_RECTANGLE_EXT
:
2430 if (!ctx
->Extensions
.EXT_window_rectangles
)
2432 if (index
>= ctx
->Const
.MaxWindowRectangles
)
2434 v
->value_int_4
[0] = ctx
->Scissor
.WindowRects
[index
].X
;
2435 v
->value_int_4
[1] = ctx
->Scissor
.WindowRects
[index
].Y
;
2436 v
->value_int_4
[2] = ctx
->Scissor
.WindowRects
[index
].Width
;
2437 v
->value_int_4
[3] = ctx
->Scissor
.WindowRects
[index
].Height
;
2441 if (index
>= ctx
->Const
.MaxViewports
)
2443 v
->value_float_4
[0] = ctx
->ViewportArray
[index
].X
;
2444 v
->value_float_4
[1] = ctx
->ViewportArray
[index
].Y
;
2445 v
->value_float_4
[2] = ctx
->ViewportArray
[index
].Width
;
2446 v
->value_float_4
[3] = ctx
->ViewportArray
[index
].Height
;
2447 return TYPE_FLOAT_4
;
2449 case GL_DEPTH_RANGE
:
2450 if (index
>= ctx
->Const
.MaxViewports
)
2452 v
->value_double_2
[0] = ctx
->ViewportArray
[index
].Near
;
2453 v
->value_double_2
[1] = ctx
->ViewportArray
[index
].Far
;
2454 return TYPE_DOUBLEN_2
;
2456 case GL_TRANSFORM_FEEDBACK_BUFFER_START
:
2457 if (index
>= ctx
->Const
.MaxTransformFeedbackBuffers
)
2459 if (!ctx
->Extensions
.EXT_transform_feedback
)
2461 v
->value_int64
= ctx
->TransformFeedback
.CurrentObject
->Offset
[index
];
2464 case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE
:
2465 if (index
>= ctx
->Const
.MaxTransformFeedbackBuffers
)
2467 if (!ctx
->Extensions
.EXT_transform_feedback
)
2470 = ctx
->TransformFeedback
.CurrentObject
->RequestedSize
[index
];
2473 case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING
:
2474 if (index
>= ctx
->Const
.MaxTransformFeedbackBuffers
)
2476 if (!ctx
->Extensions
.EXT_transform_feedback
)
2478 v
->value_int
= ctx
->TransformFeedback
.CurrentObject
->BufferNames
[index
];
2481 case GL_UNIFORM_BUFFER_BINDING
:
2482 if (index
>= ctx
->Const
.MaxUniformBufferBindings
)
2484 if (!ctx
->Extensions
.ARB_uniform_buffer_object
)
2486 v
->value_int
= ctx
->UniformBufferBindings
[index
].BufferObject
->Name
;
2489 case GL_UNIFORM_BUFFER_START
:
2490 if (index
>= ctx
->Const
.MaxUniformBufferBindings
)
2492 if (!ctx
->Extensions
.ARB_uniform_buffer_object
)
2494 v
->value_int
= ctx
->UniformBufferBindings
[index
].Offset
< 0 ? 0 :
2495 ctx
->UniformBufferBindings
[index
].Offset
;
2498 case GL_UNIFORM_BUFFER_SIZE
:
2499 if (index
>= ctx
->Const
.MaxUniformBufferBindings
)
2501 if (!ctx
->Extensions
.ARB_uniform_buffer_object
)
2503 v
->value_int
= ctx
->UniformBufferBindings
[index
].Size
< 0 ? 0 :
2504 ctx
->UniformBufferBindings
[index
].Size
;
2507 /* ARB_shader_storage_buffer_object */
2508 case GL_SHADER_STORAGE_BUFFER_BINDING
:
2509 if (!ctx
->Extensions
.ARB_shader_storage_buffer_object
)
2511 if (index
>= ctx
->Const
.MaxShaderStorageBufferBindings
)
2513 v
->value_int
= ctx
->ShaderStorageBufferBindings
[index
].BufferObject
->Name
;
2516 case GL_SHADER_STORAGE_BUFFER_START
:
2517 if (!ctx
->Extensions
.ARB_shader_storage_buffer_object
)
2519 if (index
>= ctx
->Const
.MaxShaderStorageBufferBindings
)
2521 v
->value_int
= ctx
->ShaderStorageBufferBindings
[index
].Offset
< 0 ? 0 :
2522 ctx
->ShaderStorageBufferBindings
[index
].Offset
;
2525 case GL_SHADER_STORAGE_BUFFER_SIZE
:
2526 if (!ctx
->Extensions
.ARB_shader_storage_buffer_object
)
2528 if (index
>= ctx
->Const
.MaxShaderStorageBufferBindings
)
2530 v
->value_int
= ctx
->ShaderStorageBufferBindings
[index
].Size
< 0 ? 0 :
2531 ctx
->ShaderStorageBufferBindings
[index
].Size
;
2534 /* ARB_texture_multisample / GL3.2 */
2535 case GL_SAMPLE_MASK_VALUE
:
2538 if (!ctx
->Extensions
.ARB_texture_multisample
)
2540 v
->value_int
= ctx
->Multisample
.SampleMaskValue
;
2543 case GL_ATOMIC_COUNTER_BUFFER_BINDING
:
2544 if (!ctx
->Extensions
.ARB_shader_atomic_counters
)
2546 if (index
>= ctx
->Const
.MaxAtomicBufferBindings
)
2548 v
->value_int
= ctx
->AtomicBufferBindings
[index
].BufferObject
->Name
;
2551 case GL_ATOMIC_COUNTER_BUFFER_START
:
2552 if (!ctx
->Extensions
.ARB_shader_atomic_counters
)
2554 if (index
>= ctx
->Const
.MaxAtomicBufferBindings
)
2556 v
->value_int64
= ctx
->AtomicBufferBindings
[index
].Offset
< 0 ? 0 :
2557 ctx
->AtomicBufferBindings
[index
].Offset
;
2560 case GL_ATOMIC_COUNTER_BUFFER_SIZE
:
2561 if (!ctx
->Extensions
.ARB_shader_atomic_counters
)
2563 if (index
>= ctx
->Const
.MaxAtomicBufferBindings
)
2565 v
->value_int64
= ctx
->AtomicBufferBindings
[index
].Size
< 0 ? 0 :
2566 ctx
->AtomicBufferBindings
[index
].Size
;
2569 case GL_VERTEX_BINDING_DIVISOR
:
2570 if ((!_mesa_is_desktop_gl(ctx
) || !ctx
->Extensions
.ARB_instanced_arrays
) &&
2571 !_mesa_is_gles31(ctx
))
2573 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
)
2575 v
->value_int
= ctx
->Array
.VAO
->BufferBinding
[VERT_ATTRIB_GENERIC(index
)].InstanceDivisor
;
2578 case GL_VERTEX_BINDING_OFFSET
:
2579 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles31(ctx
))
2581 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
)
2583 v
->value_int
= ctx
->Array
.VAO
->BufferBinding
[VERT_ATTRIB_GENERIC(index
)].Offset
;
2586 case GL_VERTEX_BINDING_STRIDE
:
2587 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles31(ctx
))
2589 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
)
2591 v
->value_int
= ctx
->Array
.VAO
->BufferBinding
[VERT_ATTRIB_GENERIC(index
)].Stride
;
2594 case GL_VERTEX_BINDING_BUFFER
:
2595 if (ctx
->API
== API_OPENGLES2
&& ctx
->Version
< 31)
2597 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
)
2599 v
->value_int
= ctx
->Array
.VAO
->BufferBinding
[VERT_ATTRIB_GENERIC(index
)].BufferObj
->Name
;
2602 /* ARB_shader_image_load_store */
2603 case GL_IMAGE_BINDING_NAME
: {
2604 struct gl_texture_object
*t
;
2606 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
2608 if (index
>= ctx
->Const
.MaxImageUnits
)
2611 t
= ctx
->ImageUnits
[index
].TexObj
;
2612 v
->value_int
= (t
? t
->Name
: 0);
2616 case GL_IMAGE_BINDING_LEVEL
:
2617 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
2619 if (index
>= ctx
->Const
.MaxImageUnits
)
2622 v
->value_int
= ctx
->ImageUnits
[index
].Level
;
2625 case GL_IMAGE_BINDING_LAYERED
:
2626 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
2628 if (index
>= ctx
->Const
.MaxImageUnits
)
2631 v
->value_int
= ctx
->ImageUnits
[index
].Layered
;
2634 case GL_IMAGE_BINDING_LAYER
:
2635 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
2637 if (index
>= ctx
->Const
.MaxImageUnits
)
2640 v
->value_int
= ctx
->ImageUnits
[index
].Layer
;
2643 case GL_IMAGE_BINDING_ACCESS
:
2644 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
2646 if (index
>= ctx
->Const
.MaxImageUnits
)
2649 v
->value_int
= ctx
->ImageUnits
[index
].Access
;
2652 case GL_IMAGE_BINDING_FORMAT
:
2653 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
2655 if (index
>= ctx
->Const
.MaxImageUnits
)
2658 v
->value_int
= ctx
->ImageUnits
[index
].Format
;
2661 /* ARB_direct_state_access */
2662 case GL_TEXTURE_BINDING_1D
:
2663 case GL_TEXTURE_BINDING_1D_ARRAY
:
2664 case GL_TEXTURE_BINDING_2D
:
2665 case GL_TEXTURE_BINDING_2D_ARRAY
:
2666 case GL_TEXTURE_BINDING_2D_MULTISAMPLE
:
2667 case GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY
:
2668 case GL_TEXTURE_BINDING_3D
:
2669 case GL_TEXTURE_BINDING_BUFFER
:
2670 case GL_TEXTURE_BINDING_CUBE_MAP
:
2671 case GL_TEXTURE_BINDING_CUBE_MAP_ARRAY
:
2672 case GL_TEXTURE_BINDING_RECTANGLE
: {
2675 if (ctx
->API
!= API_OPENGL_CORE
)
2677 target
= tex_binding_to_index(ctx
, pname
);
2680 if (index
>= _mesa_max_tex_unit(ctx
))
2683 v
->value_int
= ctx
->Texture
.Unit
[index
].CurrentTex
[target
]->Name
;
2687 case GL_SAMPLER_BINDING
: {
2688 struct gl_sampler_object
*samp
;
2690 if (!_mesa_is_desktop_gl(ctx
) || ctx
->Version
< 33)
2692 if (index
>= _mesa_max_tex_unit(ctx
))
2695 samp
= ctx
->Texture
.Unit
[index
].Sampler
;
2696 v
->value_int
= samp
? samp
->Name
: 0;
2700 case GL_MAX_COMPUTE_WORK_GROUP_COUNT
:
2701 if (!_mesa_has_compute_shaders(ctx
))
2705 v
->value_int
= ctx
->Const
.MaxComputeWorkGroupCount
[index
];
2708 case GL_MAX_COMPUTE_WORK_GROUP_SIZE
:
2709 if (!_mesa_has_compute_shaders(ctx
))
2713 v
->value_int
= ctx
->Const
.MaxComputeWorkGroupSize
[index
];
2716 /* ARB_compute_variable_group_size */
2717 case GL_MAX_COMPUTE_VARIABLE_GROUP_SIZE_ARB
:
2718 if (!ctx
->Extensions
.ARB_compute_variable_group_size
)
2722 v
->value_int
= ctx
->Const
.MaxComputeVariableGroupSize
[index
];
2725 /* GL_EXT_external_objects */
2726 case GL_NUM_DEVICE_UUIDS_EXT
:
2729 case GL_DRIVER_UUID_EXT
:
2732 _mesa_get_driver_uuid(ctx
, v
->value_int_4
);
2734 case GL_DEVICE_UUID_EXT
:
2737 _mesa_get_device_uuid(ctx
, v
->value_int_4
);
2742 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(pname=%s)", func
,
2743 _mesa_enum_to_string(pname
));
2744 return TYPE_INVALID
;
2746 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(pname=%s)", func
,
2747 _mesa_enum_to_string(pname
));
2748 return TYPE_INVALID
;
2752 _mesa_GetBooleani_v( GLenum pname
, GLuint index
, GLboolean
*params
)
2755 enum value_type type
=
2756 find_value_indexed("glGetBooleani_v", pname
, index
, &v
);
2761 params
[0] = INT_TO_BOOLEAN(v
.value_int
);
2765 params
[0] = INT_TO_BOOLEAN(v
.value_int_4
[0]);
2766 params
[1] = INT_TO_BOOLEAN(v
.value_int_4
[1]);
2767 params
[2] = INT_TO_BOOLEAN(v
.value_int_4
[2]);
2768 params
[3] = INT_TO_BOOLEAN(v
.value_int_4
[3]);
2771 params
[0] = INT64_TO_BOOLEAN(v
.value_int64
);
2774 ; /* nothing - GL error was recorded */
2779 _mesa_GetIntegeri_v( GLenum pname
, GLuint index
, GLint
*params
)
2782 enum value_type type
=
2783 find_value_indexed("glGetIntegeri_v", pname
, index
, &v
);
2788 params
[3] = IROUND(v
.value_float_4
[3]);
2791 params
[2] = IROUND(v
.value_float_4
[2]);
2794 params
[1] = IROUND(v
.value_float_4
[1]);
2797 params
[0] = IROUND(v
.value_float_4
[0]);
2800 case TYPE_DOUBLEN_2
:
2801 params
[1] = IROUND(v
.value_double_2
[1]);
2803 params
[0] = IROUND(v
.value_double_2
[0]);
2808 params
[0] = v
.value_int
;
2812 params
[0] = v
.value_int_4
[0];
2813 params
[1] = v
.value_int_4
[1];
2814 params
[2] = v
.value_int_4
[2];
2815 params
[3] = v
.value_int_4
[3];
2818 params
[0] = INT64_TO_INT(v
.value_int64
);
2821 ; /* nothing - GL error was recorded */
2826 _mesa_GetInteger64i_v( GLenum pname
, GLuint index
, GLint64
*params
)
2829 enum value_type type
=
2830 find_value_indexed("glGetInteger64i_v", pname
, index
, &v
);
2834 params
[0] = v
.value_int
;
2837 params
[0] = v
.value_int_4
[0];
2838 params
[1] = v
.value_int_4
[1];
2839 params
[2] = v
.value_int_4
[2];
2840 params
[3] = v
.value_int_4
[3];
2843 params
[0] = (GLuint
) v
.value_int
;
2846 params
[0] = (GLuint
) v
.value_int_4
[0];
2847 params
[1] = (GLuint
) v
.value_int_4
[1];
2848 params
[2] = (GLuint
) v
.value_int_4
[2];
2849 params
[3] = (GLuint
) v
.value_int_4
[3];
2852 params
[0] = v
.value_int64
;
2855 ; /* nothing - GL error was recorded */
2860 _mesa_GetFloati_v(GLenum pname
, GLuint index
, GLfloat
*params
)
2865 enum value_type type
=
2866 find_value_indexed("glGetFloati_v", pname
, index
, &v
);
2871 params
[3] = v
.value_float_4
[3];
2874 params
[2] = v
.value_float_4
[2];
2877 params
[1] = v
.value_float_4
[1];
2880 params
[0] = v
.value_float_4
[0];
2883 case TYPE_DOUBLEN_2
:
2884 params
[1] = (GLfloat
) v
.value_double_2
[1];
2886 params
[0] = (GLfloat
) v
.value_double_2
[0];
2890 params
[3] = (GLfloat
) v
.value_int_4
[3];
2892 params
[2] = (GLfloat
) v
.value_int_4
[2];
2895 params
[1] = (GLfloat
) v
.value_int_4
[1];
2899 params
[0] = (GLfloat
) v
.value_int_4
[0];
2903 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
2904 params
[i
] = (GLfloat
) v
.value_int_n
.ints
[i
];
2908 params
[3] = (GLfloat
) ((GLuint
) v
.value_int_4
[3]);
2910 params
[2] = (GLfloat
) ((GLuint
) v
.value_int_4
[2]);
2912 params
[1] = (GLfloat
) ((GLuint
) v
.value_int_4
[1]);
2914 params
[0] = (GLfloat
) ((GLuint
) v
.value_int_4
[0]);
2918 params
[0] = (GLfloat
) v
.value_int64
;
2922 params
[0] = BOOLEAN_TO_FLOAT(v
.value_bool
);
2926 params
[0] = (GLfloat
) v
.value_ubyte
;
2930 params
[0] = (GLfloat
) v
.value_short
;
2934 m
= *(GLmatrix
**) &v
;
2935 for (i
= 0; i
< 16; i
++)
2936 params
[i
] = m
->m
[i
];
2940 m
= *(GLmatrix
**) &v
;
2941 for (i
= 0; i
< 16; i
++)
2942 params
[i
] = m
->m
[transpose
[i
]];
2951 _mesa_GetDoublei_v(GLenum pname
, GLuint index
, GLdouble
*params
)
2956 enum value_type type
=
2957 find_value_indexed("glGetDoublei_v", pname
, index
, &v
);
2962 params
[3] = (GLdouble
) v
.value_float_4
[3];
2965 params
[2] = (GLdouble
) v
.value_float_4
[2];
2968 params
[1] = (GLdouble
) v
.value_float_4
[1];
2971 params
[0] = (GLdouble
) v
.value_float_4
[0];
2974 case TYPE_DOUBLEN_2
:
2975 params
[1] = v
.value_double_2
[1];
2977 params
[0] = v
.value_double_2
[0];
2981 params
[3] = (GLdouble
) v
.value_int_4
[3];
2983 params
[2] = (GLdouble
) v
.value_int_4
[2];
2986 params
[1] = (GLdouble
) v
.value_int_4
[1];
2990 params
[0] = (GLdouble
) v
.value_int_4
[0];
2994 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
2995 params
[i
] = (GLdouble
) v
.value_int_n
.ints
[i
];
2999 params
[3] = (GLdouble
) ((GLuint
) v
.value_int_4
[3]);
3001 params
[2] = (GLdouble
) ((GLuint
) v
.value_int_4
[2]);
3003 params
[1] = (GLdouble
) ((GLuint
) v
.value_int_4
[1]);
3005 params
[0] = (GLdouble
) ((GLuint
) v
.value_int_4
[0]);
3009 params
[0] = (GLdouble
) v
.value_int64
;
3013 params
[0] = (GLdouble
) BOOLEAN_TO_FLOAT(v
.value_bool
);
3017 params
[0] = (GLdouble
) v
.value_ubyte
;
3021 params
[0] = (GLdouble
) v
.value_short
;
3025 m
= *(GLmatrix
**) &v
;
3026 for (i
= 0; i
< 16; i
++)
3027 params
[i
] = (GLdouble
) m
->m
[i
];
3031 m
= *(GLmatrix
**) &v
;
3032 for (i
= 0; i
< 16; i
++)
3033 params
[i
] = (GLdouble
) m
->m
[transpose
[i
]];
3042 _mesa_GetUnsignedBytei_vEXT(GLenum target
, GLuint index
, GLubyte
*data
)
3046 enum value_type type
;
3047 const char *func
= "glGetUnsignedBytei_vEXT";
3049 GET_CURRENT_CONTEXT(ctx
);
3051 if (!ctx
->Extensions
.EXT_memory_object
) {
3052 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(unsupported)", func
);
3056 type
= find_value_indexed(func
, target
, index
, &v
);
3057 size
= get_value_size(type
, &v
);
3059 _mesa_problem(ctx
, "invalid value type in GetUnsignedBytei_vEXT()");
3088 case TYPE_DOUBLEN_2
:
3091 memcpy(data
, &v
.value_int
, size
);
3094 memcpy(data
, &v
.value_int_n
.ints
, size
);
3097 break; /* nothing - GL error was recorded */
3102 _mesa_GetFixedv(GLenum pname
, GLfixed
*params
)
3104 const struct value_desc
*d
;
3110 d
= find_value("glGetDoublev", pname
, &p
, &v
);
3115 params
[0] = INT_TO_FIXED(d
->offset
);
3120 params
[3] = FLOAT_TO_FIXED(((GLfloat
*) p
)[3]);
3123 params
[2] = FLOAT_TO_FIXED(((GLfloat
*) p
)[2]);
3126 params
[1] = FLOAT_TO_FIXED(((GLfloat
*) p
)[1]);
3129 params
[0] = FLOAT_TO_FIXED(((GLfloat
*) p
)[0]);
3132 case TYPE_DOUBLEN_2
:
3133 params
[1] = FLOAT_TO_FIXED(((GLdouble
*) p
)[1]);
3135 params
[0] = FLOAT_TO_FIXED(((GLdouble
*) p
)[0]);
3140 params
[3] = INT_TO_FIXED(((GLint
*) p
)[3]);
3143 params
[2] = INT_TO_FIXED(((GLint
*) p
)[2]);
3147 params
[1] = INT_TO_FIXED(((GLint
*) p
)[1]);
3151 params
[0] = INT_TO_FIXED(((GLint
*) p
)[0]);
3155 params
[0] = INT_TO_FIXED((GLint
)(((GLenum16
*) p
)[0]));
3159 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
3160 params
[i
] = INT_TO_FIXED(v
.value_int_n
.ints
[i
]);
3164 params
[0] = ((GLint64
*) p
)[0];
3168 params
[0] = BOOLEAN_TO_FIXED(((GLboolean
*) p
)[0]);
3172 params
[0] = INT_TO_FIXED(((GLubyte
*) p
)[0]);
3176 params
[0] = INT_TO_FIXED(((GLshort
*) p
)[0]);
3180 m
= *(GLmatrix
**) p
;
3181 for (i
= 0; i
< 16; i
++)
3182 params
[i
] = FLOAT_TO_FIXED(m
->m
[i
]);
3186 m
= *(GLmatrix
**) p
;
3187 for (i
= 0; i
< 16; i
++)
3188 params
[i
] = FLOAT_TO_FIXED(m
->m
[transpose
[i
]]);
3199 shift
= d
->type
- TYPE_BIT_0
;
3200 params
[0] = BOOLEAN_TO_FIXED((*(GLbitfield
*) p
>> shift
) & 1);