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"
37 #include "spirv_extensions.h"
39 #include "texcompress.h"
41 #include "framebuffer.h"
42 #include "samplerobj.h"
46 /* This is a table driven implemetation of the glGet*v() functions.
47 * The basic idea is that most getters just look up an int somewhere
48 * in struct gl_context and then convert it to a bool or float according to
49 * which of glGetIntegerv() glGetBooleanv() etc is being called.
50 * Instead of generating code to do this, we can just record the enum
51 * value and the offset into struct gl_context in an array of structs. Then
52 * in glGet*(), we lookup the struct for the enum in question, and use
53 * the offset to get the int we need.
55 * Sometimes we need to look up a float, a boolean, a bit in a
56 * bitfield, a matrix or other types instead, so we need to track the
57 * type of the value in struct gl_context. And sometimes the value isn't in
58 * struct gl_context but in the drawbuffer, the array object, current texture
59 * unit, or maybe it's a computed value. So we need to also track
60 * where or how to find the value. Finally, we sometimes need to
61 * check that one of a number of extensions are enabled, the GL
62 * version or flush or call _mesa_update_state(). This is done by
63 * attaching optional extra information to the value description
64 * struct, it's sort of like an array of opcodes that describe extra
67 * Putting all this together we end up with struct value_desc below,
68 * and with a couple of macros to help, the table of struct value_desc
69 * is about as concise as the specification in the old python script.
72 #define FLOAT_TO_BOOLEAN(X) ( (X) ? GL_TRUE : GL_FALSE )
73 #define FLOAT_TO_FIXED(F) ( ((F) * 65536.0f > INT_MAX) ? INT_MAX : \
74 ((F) * 65536.0f < INT_MIN) ? INT_MIN : \
75 (GLint) ((F) * 65536.0f) )
77 #define INT_TO_BOOLEAN(I) ( (I) ? GL_TRUE : GL_FALSE )
78 #define INT_TO_FIXED(I) ( ((I) > SHRT_MAX) ? INT_MAX : \
79 ((I) < SHRT_MIN) ? INT_MIN : \
80 (GLint) ((I) * 65536) )
82 #define INT64_TO_BOOLEAN(I) ( (I) ? GL_TRUE : GL_FALSE )
83 #define INT64_TO_INT(I) ( (GLint)((I > INT_MAX) ? INT_MAX : ((I < INT_MIN) ? INT_MIN : (I))) )
85 #define BOOLEAN_TO_INT(B) ( (GLint) (B) )
86 #define BOOLEAN_TO_INT64(B) ( (GLint64) (B) )
87 #define BOOLEAN_TO_FLOAT(B) ( (B) ? 1.0F : 0.0F )
88 #define BOOLEAN_TO_FIXED(B) ( (GLint) ((B) ? 1 : 0) << 16 )
90 #define ENUM_TO_INT64(E) ( (GLint64) (E) )
91 #define ENUM_TO_FIXED(E) (E)
135 enum value_location
{
157 EXTRA_NEW_FRAG_CLAMP
,
158 EXTRA_VALID_DRAW_BUFFER
,
159 EXTRA_VALID_TEXTURE_UNIT
,
160 EXTRA_VALID_CLIP_DISTANCE
,
164 EXTRA_EXT_ATOMICS_GS
,
165 EXTRA_EXT_SHADER_IMAGE_GS
,
166 EXTRA_EXT_ATOMICS_TESS
,
167 EXTRA_EXT_SHADER_IMAGE_TESS
,
169 EXTRA_EXT_FB_NO_ATTACH_GS
,
171 EXTRA_EXT_PROVOKING_VERTEX_32
,
174 #define NO_EXTRA NULL
179 GLubyte location
; /**< enum value_location */
180 GLubyte type
; /**< enum value_type */
187 GLfloat value_float_4
[4];
188 GLdouble value_double_2
[2];
189 GLmatrix
*value_matrix
;
191 GLint value_int_4
[4];
198 /* Sigh, see GL_COMPRESSED_TEXTURE_FORMATS_ARB handling */
202 GLboolean value_bool
;
205 #define BUFFER_FIELD(field, type) \
206 LOC_BUFFER, type, offsetof(struct gl_framebuffer, field)
207 #define CONTEXT_FIELD(field, type) \
208 LOC_CONTEXT, type, offsetof(struct gl_context, field)
209 #define ARRAY_FIELD(field, type) \
210 LOC_ARRAY, type, offsetof(struct gl_vertex_array_object, field)
211 #undef CONST /* already defined through windows.h */
212 #define CONST(value) \
213 LOC_CONTEXT, TYPE_CONST, value
215 #define BUFFER_INT(field) BUFFER_FIELD(field, TYPE_INT)
216 #define BUFFER_ENUM(field) BUFFER_FIELD(field, TYPE_ENUM)
217 #define BUFFER_ENUM16(field) BUFFER_FIELD(field, TYPE_ENUM16)
218 #define BUFFER_BOOL(field) BUFFER_FIELD(field, TYPE_BOOLEAN)
220 #define CONTEXT_INT(field) CONTEXT_FIELD(field, TYPE_INT)
221 #define CONTEXT_INT2(field) CONTEXT_FIELD(field, TYPE_INT_2)
222 #define CONTEXT_INT64(field) CONTEXT_FIELD(field, TYPE_INT64)
223 #define CONTEXT_UINT(field) CONTEXT_FIELD(field, TYPE_UINT)
224 #define CONTEXT_ENUM16(field) CONTEXT_FIELD(field, TYPE_ENUM16)
225 #define CONTEXT_ENUM(field) CONTEXT_FIELD(field, TYPE_ENUM)
226 #define CONTEXT_ENUM2(field) CONTEXT_FIELD(field, TYPE_ENUM_2)
227 #define CONTEXT_BOOL(field) CONTEXT_FIELD(field, TYPE_BOOLEAN)
228 #define CONTEXT_BIT0(field) CONTEXT_FIELD(field, TYPE_BIT_0)
229 #define CONTEXT_BIT1(field) CONTEXT_FIELD(field, TYPE_BIT_1)
230 #define CONTEXT_BIT2(field) CONTEXT_FIELD(field, TYPE_BIT_2)
231 #define CONTEXT_BIT3(field) CONTEXT_FIELD(field, TYPE_BIT_3)
232 #define CONTEXT_BIT4(field) CONTEXT_FIELD(field, TYPE_BIT_4)
233 #define CONTEXT_BIT5(field) CONTEXT_FIELD(field, TYPE_BIT_5)
234 #define CONTEXT_BIT6(field) CONTEXT_FIELD(field, TYPE_BIT_6)
235 #define CONTEXT_BIT7(field) CONTEXT_FIELD(field, TYPE_BIT_7)
236 #define CONTEXT_FLOAT(field) CONTEXT_FIELD(field, TYPE_FLOAT)
237 #define CONTEXT_FLOAT2(field) CONTEXT_FIELD(field, TYPE_FLOAT_2)
238 #define CONTEXT_FLOAT3(field) CONTEXT_FIELD(field, TYPE_FLOAT_3)
239 #define CONTEXT_FLOAT4(field) CONTEXT_FIELD(field, TYPE_FLOAT_4)
240 #define CONTEXT_FLOAT8(field) CONTEXT_FIELD(field, TYPE_FLOAT_8)
241 #define CONTEXT_MATRIX(field) CONTEXT_FIELD(field, TYPE_MATRIX)
242 #define CONTEXT_MATRIX_T(field) CONTEXT_FIELD(field, TYPE_MATRIX_T)
244 /* Vertex array fields */
245 #define ARRAY_INT(field) ARRAY_FIELD(field, TYPE_INT)
246 #define ARRAY_ENUM(field) ARRAY_FIELD(field, TYPE_ENUM)
247 #define ARRAY_ENUM16(field) ARRAY_FIELD(field, TYPE_ENUM16)
248 #define ARRAY_BOOL(field) ARRAY_FIELD(field, TYPE_BOOLEAN)
249 #define ARRAY_UBYTE(field) ARRAY_FIELD(field, TYPE_UBYTE)
250 #define ARRAY_SHORT(field) ARRAY_FIELD(field, TYPE_SHORT)
253 offsetof(struct gl_extensions, f)
255 #define EXTRA_EXT(e) \
256 static const int extra_##e[] = { \
260 #define EXTRA_EXT2(e1, e2) \
261 static const int extra_##e1##_##e2[] = { \
262 EXT(e1), EXT(e2), EXTRA_END \
265 /* The 'extra' mechanism is a way to specify extra checks (such as
266 * extensions or specific gl versions) or actions (flush current, new
267 * buffers) that we need to do before looking up an enum. We need to
268 * declare them all up front so we can refer to them in the value_desc
271 * Each EXTRA_ will be executed. For EXTRA_* enums of extensions and API
272 * versions, listing multiple ones in an array means an error will be thrown
273 * only if none of them are available. If you need to check for "AND"
274 * behavior, you would need to make a custom EXTRA_ enum.
277 static const int extra_new_buffers
[] = {
282 static const int extra_new_frag_clamp
[] = {
283 EXTRA_NEW_FRAG_CLAMP
,
287 static const int extra_valid_draw_buffer
[] = {
288 EXTRA_VALID_DRAW_BUFFER
,
292 static const int extra_valid_texture_unit
[] = {
293 EXTRA_VALID_TEXTURE_UNIT
,
297 static const int extra_valid_clip_distance
[] = {
298 EXTRA_VALID_CLIP_DISTANCE
,
302 static const int extra_flush_current_valid_texture_unit
[] = {
304 EXTRA_VALID_TEXTURE_UNIT
,
308 static const int extra_flush_current
[] = {
313 static const int extra_EXT_texture_integer_and_new_buffers
[] = {
314 EXT(EXT_texture_integer
),
319 static const int extra_GLSL_130_es3_gpushader4
[] = {
322 EXT(EXT_gpu_shader4
),
326 static const int extra_texture_buffer_object
[] = {
327 EXT(ARB_texture_buffer_object
),
331 static const int extra_ARB_transform_feedback2_api_es3
[] = {
332 EXT(ARB_transform_feedback2
),
337 static const int extra_ARB_uniform_buffer_object_and_geometry_shader
[] = {
342 static const int extra_ARB_ES2_compatibility_api_es2
[] = {
343 EXT(ARB_ES2_compatibility
),
348 static const int extra_ARB_ES3_compatibility_api_es3
[] = {
349 EXT(ARB_ES3_compatibility
),
354 static const int extra_EXT_framebuffer_sRGB_and_new_buffers
[] = {
355 EXT(EXT_framebuffer_sRGB
),
360 static const int extra_EXT_packed_float
[] = {
361 EXT(EXT_packed_float
),
366 static const int extra_EXT_texture_array_es3
[] = {
367 EXT(EXT_texture_array
),
372 static const int extra_ARB_shader_atomic_counters_and_geometry_shader
[] = {
373 EXTRA_EXT_ATOMICS_GS
,
377 static const int extra_ARB_shader_image_load_store_and_geometry_shader
[] = {
378 EXTRA_EXT_SHADER_IMAGE_GS
,
382 static const int extra_ARB_shader_atomic_counters_and_tessellation
[] = {
383 EXTRA_EXT_ATOMICS_TESS
,
387 static const int extra_ARB_shader_image_load_store_and_tessellation
[] = {
388 EXTRA_EXT_SHADER_IMAGE_TESS
,
392 /* HACK: remove when ARB_compute_shader is actually supported */
393 static const int extra_ARB_compute_shader_es31
[] = {
394 EXT(ARB_compute_shader
),
399 static const int extra_ARB_shader_storage_buffer_object_es31
[] = {
400 EXT(ARB_shader_storage_buffer_object
),
405 static const int extra_ARB_shader_storage_buffer_object_and_geometry_shader
[] = {
410 static const int extra_ARB_shader_image_load_store_shader_storage_buffer_object_es31
[] = {
411 EXT(ARB_shader_image_load_store
),
412 EXT(ARB_shader_storage_buffer_object
),
417 static const int extra_ARB_framebuffer_no_attachments_and_geometry_shader
[] = {
418 EXTRA_EXT_FB_NO_ATTACH_GS
,
422 static const int extra_ARB_viewport_array_or_oes_geometry_shader
[] = {
423 EXT(ARB_viewport_array
),
428 static const int extra_ARB_viewport_array_or_oes_viewport_array
[] = {
429 EXT(ARB_viewport_array
),
430 EXT(OES_viewport_array
),
434 static const int extra_ARB_gpu_shader5_or_oes_geometry_shader
[] = {
435 EXT(ARB_gpu_shader5
),
440 static const int extra_ARB_gpu_shader5_or_OES_sample_variables
[] = {
441 EXT(ARB_gpu_shader5
),
442 EXT(OES_sample_variables
),
446 static const int extra_ES32
[] = {
447 EXT(ARB_ES3_2_compatibility
),
452 static const int extra_KHR_robustness_or_GL
[] = {
459 static const int extra_INTEL_conservative_rasterization
[] = {
460 EXT(INTEL_conservative_rasterization
),
464 EXTRA_EXT(ARB_texture_cube_map
);
465 EXTRA_EXT(EXT_texture_array
);
466 EXTRA_EXT(NV_fog_distance
);
467 EXTRA_EXT(EXT_texture_filter_anisotropic
);
468 EXTRA_EXT(NV_point_sprite
);
469 EXTRA_EXT(NV_texture_rectangle
);
470 EXTRA_EXT(EXT_stencil_two_side
);
471 EXTRA_EXT(EXT_depth_bounds_test
);
472 EXTRA_EXT(ARB_depth_clamp
);
473 EXTRA_EXT(AMD_depth_clamp_separate
);
474 EXTRA_EXT(ATI_fragment_shader
);
475 EXTRA_EXT(EXT_provoking_vertex
);
476 EXTRA_EXT(ARB_fragment_shader
);
477 EXTRA_EXT(ARB_fragment_program
);
478 EXTRA_EXT2(ARB_framebuffer_object
, EXT_framebuffer_multisample
);
479 EXTRA_EXT(ARB_seamless_cube_map
);
481 EXTRA_EXT(ARB_vertex_shader
);
482 EXTRA_EXT(EXT_transform_feedback
);
483 EXTRA_EXT(ARB_transform_feedback3
);
484 EXTRA_EXT(EXT_pixel_buffer_object
);
485 EXTRA_EXT(ARB_vertex_program
);
486 EXTRA_EXT2(NV_point_sprite
, ARB_point_sprite
);
487 EXTRA_EXT2(ARB_vertex_program
, ARB_fragment_program
);
488 EXTRA_EXT(ARB_color_buffer_float
);
489 EXTRA_EXT(EXT_framebuffer_sRGB
);
490 EXTRA_EXT(OES_EGL_image_external
);
491 EXTRA_EXT(ARB_blend_func_extended
);
492 EXTRA_EXT(ARB_uniform_buffer_object
);
493 EXTRA_EXT(ARB_timer_query
);
494 EXTRA_EXT2(ARB_texture_cube_map_array
, OES_texture_cube_map_array
);
495 EXTRA_EXT(ARB_texture_buffer_range
);
496 EXTRA_EXT(ARB_texture_multisample
);
497 EXTRA_EXT(ARB_texture_gather
);
498 EXTRA_EXT(ARB_shader_atomic_counters
);
499 EXTRA_EXT(ARB_draw_indirect
);
500 EXTRA_EXT(ARB_shader_image_load_store
);
501 EXTRA_EXT(ARB_query_buffer_object
);
502 EXTRA_EXT2(ARB_transform_feedback3
, ARB_gpu_shader5
);
503 EXTRA_EXT(INTEL_performance_query
);
504 EXTRA_EXT(ARB_explicit_uniform_location
);
505 EXTRA_EXT(ARB_clip_control
);
506 EXTRA_EXT(ARB_polygon_offset_clamp
);
507 EXTRA_EXT(ARB_framebuffer_no_attachments
);
508 EXTRA_EXT(ARB_tessellation_shader
);
509 EXTRA_EXT(ARB_shader_storage_buffer_object
);
510 EXTRA_EXT(ARB_indirect_parameters
);
511 EXTRA_EXT(ATI_meminfo
);
512 EXTRA_EXT(NVX_gpu_memory_info
);
513 EXTRA_EXT(ARB_cull_distance
);
514 EXTRA_EXT(EXT_window_rectangles
);
515 EXTRA_EXT(KHR_blend_equation_advanced_coherent
);
516 EXTRA_EXT(OES_primitive_bounding_box
);
517 EXTRA_EXT(ARB_compute_variable_group_size
);
518 EXTRA_EXT(KHR_robustness
);
519 EXTRA_EXT(ARB_sparse_buffer
);
520 EXTRA_EXT(NV_conservative_raster
);
521 EXTRA_EXT(NV_conservative_raster_dilate
);
522 EXTRA_EXT(NV_conservative_raster_pre_snap_triangles
);
523 EXTRA_EXT(ARB_sample_locations
);
524 EXTRA_EXT(AMD_framebuffer_multisample_advanced
);
525 EXTRA_EXT(ARB_spirv_extensions
);
528 extra_ARB_color_buffer_float_or_glcore
[] = {
529 EXT(ARB_color_buffer_float
),
535 extra_NV_primitive_restart
[] = {
536 EXT(NV_primitive_restart
),
540 static const int extra_version_30
[] = { EXTRA_VERSION_30
, EXTRA_END
};
541 static const int extra_version_31
[] = { EXTRA_VERSION_31
, EXTRA_END
};
542 static const int extra_version_32
[] = { EXTRA_VERSION_32
, EXTRA_END
};
543 static const int extra_version_43
[] = { EXTRA_VERSION_43
, EXTRA_END
};
545 static const int extra_gl30_es3
[] = {
551 static const int extra_gl32_es3
[] = {
557 static const int extra_version_32_OES_geometry_shader
[] = {
563 static const int extra_gl40_ARB_sample_shading
[] = {
565 EXT(ARB_sample_shading
),
570 extra_ARB_vertex_program_api_es2
[] = {
571 EXT(ARB_vertex_program
),
576 /* The ReadBuffer get token is valid under either full GL or under
577 * GLES2 if the NV_read_buffer extension is available. */
579 extra_NV_read_buffer_api_gl
[] = {
585 static const int extra_core_ARB_color_buffer_float_and_new_buffers
[] = {
587 EXT(ARB_color_buffer_float
),
592 static const int extra_EXT_shader_framebuffer_fetch
[] = {
595 EXT(EXT_shader_framebuffer_fetch
),
599 static const int extra_EXT_provoking_vertex_32
[] = {
600 EXTRA_EXT_PROVOKING_VERTEX_32
,
604 static const int extra_EXT_disjoint_timer_query
[] = {
607 EXT(EXT_disjoint_timer_query
),
612 /* This is the big table describing all the enums we accept in
613 * glGet*v(). The table is partitioned into six parts: enums
614 * understood by all GL APIs (OpenGL, GLES and GLES2), enums shared
615 * between OpenGL and GLES, enums exclusive to GLES, etc for the
616 * remaining combinations. To look up the enums valid in a given API
617 * we will use a hash table specific to that API. These tables are in
618 * turn generated at build time and included through get_hash.h.
621 #include "get_hash.h"
623 /* All we need now is a way to look up the value struct from the enum.
624 * The code generated by gcc for the old generated big switch
625 * statement is a big, balanced, open coded if/else tree, essentially
626 * an unrolled binary search. It would be natural to sort the new
627 * enum table and use bsearch(), but we will use a read-only hash
628 * table instead. bsearch() has a nice guaranteed worst case
629 * performance, but we're also guaranteed to hit that worst case
630 * (log2(n) iterations) for about half the enums. Instead, using an
631 * open addressing hash table, we can find the enum on the first try
632 * for 80% of the enums, 1 collision for 10% and never more than 5
633 * collisions for any enum (typical numbers). And the code is very
634 * simple, even though it feels a little magic. */
637 * Handle irregular enums
639 * Some values don't conform to the "well-known type at context
640 * pointer + offset" pattern, so we have this function to catch all
641 * the corner cases. Typically, it's a computed value or a one-off
642 * pointer to a custom struct or something.
644 * In this case we can't return a pointer to the value, so we'll have
645 * to use the temporary variable 'v' declared back in the calling
646 * glGet*v() function to store the result.
648 * \param ctx the current context
649 * \param d the struct value_desc that describes the enum
650 * \param v pointer to the tmp declared in the calling glGet*v() function
653 find_custom_value(struct gl_context
*ctx
, const struct value_desc
*d
, union value
*v
)
655 struct gl_buffer_object
**buffer_obj
;
656 struct gl_array_attributes
*array
;
660 case GL_MAJOR_VERSION
:
661 v
->value_int
= ctx
->Version
/ 10;
663 case GL_MINOR_VERSION
:
664 v
->value_int
= ctx
->Version
% 10;
670 case GL_TEXTURE_CUBE_MAP
:
671 case GL_TEXTURE_RECTANGLE_NV
:
672 case GL_TEXTURE_EXTERNAL_OES
:
673 v
->value_bool
= _mesa_IsEnabled(d
->pname
);
676 case GL_LINE_STIPPLE_PATTERN
:
677 /* This is the only GLushort, special case it here by promoting
678 * to an int rather than introducing a new type. */
679 v
->value_int
= ctx
->Line
.StipplePattern
;
682 case GL_CURRENT_RASTER_TEXTURE_COORDS
:
683 unit
= ctx
->Texture
.CurrentUnit
;
684 v
->value_float_4
[0] = ctx
->Current
.RasterTexCoords
[unit
][0];
685 v
->value_float_4
[1] = ctx
->Current
.RasterTexCoords
[unit
][1];
686 v
->value_float_4
[2] = ctx
->Current
.RasterTexCoords
[unit
][2];
687 v
->value_float_4
[3] = ctx
->Current
.RasterTexCoords
[unit
][3];
690 case GL_CURRENT_TEXTURE_COORDS
:
691 unit
= ctx
->Texture
.CurrentUnit
;
692 v
->value_float_4
[0] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
][0];
693 v
->value_float_4
[1] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
][1];
694 v
->value_float_4
[2] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
][2];
695 v
->value_float_4
[3] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
][3];
698 case GL_COLOR_WRITEMASK
:
699 v
->value_int_4
[0] = GET_COLORMASK_BIT(ctx
->Color
.ColorMask
, 0, 0);
700 v
->value_int_4
[1] = GET_COLORMASK_BIT(ctx
->Color
.ColorMask
, 0, 1);
701 v
->value_int_4
[2] = GET_COLORMASK_BIT(ctx
->Color
.ColorMask
, 0, 2);
702 v
->value_int_4
[3] = GET_COLORMASK_BIT(ctx
->Color
.ColorMask
, 0, 3);
706 v
->value_bool
= ctx
->Transform
.DepthClampNear
|| ctx
->Transform
.DepthClampFar
;
710 v
->value_bool
= ctx
->Current
.Attrib
[VERT_ATTRIB_EDGEFLAG
][0] == 1.0F
;
714 v
->value_enum
= ctx
->ReadBuffer
->ColorReadBuffer
;
717 case GL_MAP2_GRID_DOMAIN
:
718 v
->value_float_4
[0] = ctx
->Eval
.MapGrid2u1
;
719 v
->value_float_4
[1] = ctx
->Eval
.MapGrid2u2
;
720 v
->value_float_4
[2] = ctx
->Eval
.MapGrid2v1
;
721 v
->value_float_4
[3] = ctx
->Eval
.MapGrid2v2
;
724 case GL_TEXTURE_STACK_DEPTH
:
725 unit
= ctx
->Texture
.CurrentUnit
;
726 v
->value_int
= ctx
->TextureMatrixStack
[unit
].Depth
+ 1;
728 case GL_TEXTURE_MATRIX
:
729 unit
= ctx
->Texture
.CurrentUnit
;
730 v
->value_matrix
= ctx
->TextureMatrixStack
[unit
].Top
;
733 case GL_VERTEX_ARRAY
:
734 v
->value_bool
= !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_POS
);
736 case GL_NORMAL_ARRAY
:
737 v
->value_bool
= !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_NORMAL
);
740 v
->value_bool
= !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_COLOR0
);
742 case GL_TEXTURE_COORD_ARRAY
:
743 v
->value_bool
= !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_TEX(ctx
->Array
.ActiveTexture
));
746 v
->value_bool
= !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_COLOR_INDEX
);
748 case GL_EDGE_FLAG_ARRAY
:
749 v
->value_bool
= !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_EDGEFLAG
);
751 case GL_SECONDARY_COLOR_ARRAY
:
752 v
->value_bool
= !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_COLOR1
);
754 case GL_FOG_COORDINATE_ARRAY
:
755 v
->value_bool
= !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_FOG
);
757 case GL_POINT_SIZE_ARRAY_OES
:
758 v
->value_bool
= !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_POINT_SIZE
);
761 case GL_TEXTURE_COORD_ARRAY_TYPE
:
762 case GL_TEXTURE_COORD_ARRAY_STRIDE
:
763 array
= &ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_TEX(ctx
->Array
.ActiveTexture
)];
764 v
->value_int
= *(GLuint
*) ((char *) array
+ d
->offset
);
767 case GL_TEXTURE_COORD_ARRAY_SIZE
:
768 array
= &ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_TEX(ctx
->Array
.ActiveTexture
)];
769 v
->value_int
= array
->Format
.Size
;
772 case GL_VERTEX_ARRAY_SIZE
:
773 array
= &ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_POS
];
774 v
->value_int
= array
->Format
.Size
;
777 case GL_ACTIVE_TEXTURE_ARB
:
778 v
->value_int
= GL_TEXTURE0_ARB
+ ctx
->Texture
.CurrentUnit
;
780 case GL_CLIENT_ACTIVE_TEXTURE_ARB
:
781 v
->value_int
= GL_TEXTURE0_ARB
+ ctx
->Array
.ActiveTexture
;
784 case GL_MODELVIEW_STACK_DEPTH
:
785 case GL_PROJECTION_STACK_DEPTH
:
786 v
->value_int
= *(GLint
*) ((char *) ctx
+ d
->offset
) + 1;
789 case GL_MAX_TEXTURE_SIZE
:
790 case GL_MAX_3D_TEXTURE_SIZE
:
791 case GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB
:
792 p
= (GLuint
*) ((char *) ctx
+ d
->offset
);
793 v
->value_int
= 1 << (*p
- 1);
797 v
->value_int_4
[0] = ctx
->Scissor
.ScissorArray
[0].X
;
798 v
->value_int_4
[1] = ctx
->Scissor
.ScissorArray
[0].Y
;
799 v
->value_int_4
[2] = ctx
->Scissor
.ScissorArray
[0].Width
;
800 v
->value_int_4
[3] = ctx
->Scissor
.ScissorArray
[0].Height
;
803 case GL_SCISSOR_TEST
:
804 v
->value_bool
= ctx
->Scissor
.EnableFlags
& 1;
809 ctx
->ListState
.CurrentList
? ctx
->ListState
.CurrentList
->Name
: 0;
812 if (!ctx
->CompileFlag
)
814 else if (ctx
->ExecuteFlag
)
815 v
->value_enum
= GL_COMPILE_AND_EXECUTE
;
817 v
->value_enum
= GL_COMPILE
;
821 v
->value_float_4
[0] = ctx
->ViewportArray
[0].X
;
822 v
->value_float_4
[1] = ctx
->ViewportArray
[0].Y
;
823 v
->value_float_4
[2] = ctx
->ViewportArray
[0].Width
;
824 v
->value_float_4
[3] = ctx
->ViewportArray
[0].Height
;
828 v
->value_double_2
[0] = ctx
->ViewportArray
[0].Near
;
829 v
->value_double_2
[1] = ctx
->ViewportArray
[0].Far
;
832 case GL_ACTIVE_STENCIL_FACE_EXT
:
833 v
->value_enum
= ctx
->Stencil
.ActiveFace
? GL_BACK
: GL_FRONT
;
836 case GL_STENCIL_FAIL
:
837 v
->value_enum
= ctx
->Stencil
.FailFunc
[ctx
->Stencil
.ActiveFace
];
839 case GL_STENCIL_FUNC
:
840 v
->value_enum
= ctx
->Stencil
.Function
[ctx
->Stencil
.ActiveFace
];
842 case GL_STENCIL_PASS_DEPTH_FAIL
:
843 v
->value_enum
= ctx
->Stencil
.ZFailFunc
[ctx
->Stencil
.ActiveFace
];
845 case GL_STENCIL_PASS_DEPTH_PASS
:
846 v
->value_enum
= ctx
->Stencil
.ZPassFunc
[ctx
->Stencil
.ActiveFace
];
849 v
->value_int
= _mesa_get_stencil_ref(ctx
, ctx
->Stencil
.ActiveFace
);
851 case GL_STENCIL_BACK_REF
:
852 v
->value_int
= _mesa_get_stencil_ref(ctx
, 1);
854 case GL_STENCIL_VALUE_MASK
:
855 v
->value_int
= ctx
->Stencil
.ValueMask
[ctx
->Stencil
.ActiveFace
];
857 case GL_STENCIL_WRITEMASK
:
858 v
->value_int
= ctx
->Stencil
.WriteMask
[ctx
->Stencil
.ActiveFace
];
861 case GL_NUM_EXTENSIONS
:
862 v
->value_int
= _mesa_get_extension_count(ctx
);
865 case GL_IMPLEMENTATION_COLOR_READ_TYPE_OES
:
866 v
->value_int
= _mesa_get_color_read_type(ctx
, NULL
, "glGetIntegerv");
868 case GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES
:
869 v
->value_int
= _mesa_get_color_read_format(ctx
, NULL
, "glGetIntegerv");
872 case GL_CURRENT_MATRIX_STACK_DEPTH_ARB
:
873 v
->value_int
= ctx
->CurrentStack
->Depth
+ 1;
875 case GL_CURRENT_MATRIX_ARB
:
876 case GL_TRANSPOSE_CURRENT_MATRIX_ARB
:
877 v
->value_matrix
= ctx
->CurrentStack
->Top
;
880 case GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB
:
881 v
->value_int
= _mesa_get_compressed_formats(ctx
, NULL
);
883 case GL_COMPRESSED_TEXTURE_FORMATS_ARB
:
885 _mesa_get_compressed_formats(ctx
, v
->value_int_n
.ints
);
886 assert(v
->value_int_n
.n
<= (int) ARRAY_SIZE(v
->value_int_n
.ints
));
889 case GL_MAX_VARYING_FLOATS_ARB
:
890 v
->value_int
= ctx
->Const
.MaxVarying
* 4;
893 /* Various object names */
895 case GL_TEXTURE_BINDING_1D
:
896 case GL_TEXTURE_BINDING_2D
:
897 case GL_TEXTURE_BINDING_3D
:
898 case GL_TEXTURE_BINDING_1D_ARRAY_EXT
:
899 case GL_TEXTURE_BINDING_2D_ARRAY_EXT
:
900 case GL_TEXTURE_BINDING_CUBE_MAP_ARB
:
901 case GL_TEXTURE_BINDING_RECTANGLE_NV
:
902 case GL_TEXTURE_BINDING_EXTERNAL_OES
:
903 case GL_TEXTURE_BINDING_CUBE_MAP_ARRAY
:
904 case GL_TEXTURE_BINDING_2D_MULTISAMPLE
:
905 case GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY
:
906 unit
= ctx
->Texture
.CurrentUnit
;
908 ctx
->Texture
.Unit
[unit
].CurrentTex
[d
->offset
]->Name
;
911 /* GL_EXT_external_objects */
912 case GL_NUM_DEVICE_UUIDS_EXT
:
915 case GL_DRIVER_UUID_EXT
:
916 _mesa_get_driver_uuid(ctx
, v
->value_int_4
);
918 case GL_DEVICE_UUID_EXT
:
919 _mesa_get_device_uuid(ctx
, v
->value_int_4
);
922 /* GL_EXT_packed_float */
923 case GL_RGBA_SIGNED_COMPONENTS_EXT
:
925 /* Note: we only check the 0th color attachment. */
926 const struct gl_renderbuffer
*rb
=
927 ctx
->DrawBuffer
->_ColorDrawBuffers
[0];
928 if (rb
&& _mesa_is_format_signed(rb
->Format
)) {
929 /* Issue 17 of GL_EXT_packed_float: If a component (such as
930 * alpha) has zero bits, the component should not be considered
931 * signed and so the bit for the respective component should be
935 _mesa_get_format_bits(rb
->Format
, GL_RED_BITS
);
937 _mesa_get_format_bits(rb
->Format
, GL_GREEN_BITS
);
939 _mesa_get_format_bits(rb
->Format
, GL_BLUE_BITS
);
941 _mesa_get_format_bits(rb
->Format
, GL_ALPHA_BITS
);
943 _mesa_get_format_bits(rb
->Format
, GL_TEXTURE_LUMINANCE_SIZE
);
945 _mesa_get_format_bits(rb
->Format
, GL_TEXTURE_INTENSITY_SIZE
);
947 v
->value_int_4
[0] = r_bits
+ l_bits
+ i_bits
> 0;
948 v
->value_int_4
[1] = g_bits
+ l_bits
+ i_bits
> 0;
949 v
->value_int_4
[2] = b_bits
+ l_bits
+ i_bits
> 0;
950 v
->value_int_4
[3] = a_bits
+ i_bits
> 0;
956 v
->value_int_4
[3] = 0;
961 /* GL_ARB_vertex_buffer_object */
962 case GL_VERTEX_ARRAY_BUFFER_BINDING_ARB
:
963 case GL_NORMAL_ARRAY_BUFFER_BINDING_ARB
:
964 case GL_COLOR_ARRAY_BUFFER_BINDING_ARB
:
965 case GL_INDEX_ARRAY_BUFFER_BINDING_ARB
:
966 case GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB
:
967 case GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB
:
968 case GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB
:
969 buffer_obj
= (struct gl_buffer_object
**)
970 ((char *) ctx
->Array
.VAO
+ d
->offset
);
971 v
->value_int
= (*buffer_obj
)->Name
;
973 case GL_ARRAY_BUFFER_BINDING_ARB
:
974 v
->value_int
= ctx
->Array
.ArrayBufferObj
->Name
;
976 case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB
:
978 ctx
->Array
.VAO
->BufferBinding
[VERT_ATTRIB_TEX(ctx
->Array
.ActiveTexture
)].BufferObj
->Name
;
980 case GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB
:
981 v
->value_int
= ctx
->Array
.VAO
->IndexBufferObj
->Name
;
984 /* ARB_vertex_array_bgra */
985 case GL_COLOR_ARRAY_SIZE
:
986 array
= &ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_COLOR0
];
987 v
->value_int
= array
->Format
.Format
== GL_BGRA
? GL_BGRA
: array
->Format
.Size
;
989 case GL_SECONDARY_COLOR_ARRAY_SIZE
:
990 array
= &ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_COLOR1
];
991 v
->value_int
= array
->Format
.Format
== GL_BGRA
? GL_BGRA
: array
->Format
.Size
;
994 /* ARB_copy_buffer */
995 case GL_COPY_READ_BUFFER
:
996 v
->value_int
= ctx
->CopyReadBuffer
->Name
;
998 case GL_COPY_WRITE_BUFFER
:
999 v
->value_int
= ctx
->CopyWriteBuffer
->Name
;
1002 case GL_PIXEL_PACK_BUFFER_BINDING_EXT
:
1003 v
->value_int
= ctx
->Pack
.BufferObj
->Name
;
1005 case GL_PIXEL_UNPACK_BUFFER_BINDING_EXT
:
1006 v
->value_int
= ctx
->Unpack
.BufferObj
->Name
;
1008 case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING
:
1009 v
->value_int
= ctx
->TransformFeedback
.CurrentBuffer
->Name
;
1011 case GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED
:
1012 v
->value_int
= ctx
->TransformFeedback
.CurrentObject
->Paused
;
1014 case GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE
:
1015 v
->value_int
= ctx
->TransformFeedback
.CurrentObject
->Active
;
1017 case GL_TRANSFORM_FEEDBACK_BINDING
:
1018 v
->value_int
= ctx
->TransformFeedback
.CurrentObject
->Name
;
1020 case GL_CURRENT_PROGRAM
:
1021 /* The Changelog of the ARB_separate_shader_objects spec says:
1023 * 24 25 Jul 2011 pbrown Remove the language erroneously deleting
1024 * CURRENT_PROGRAM. In the EXT extension, this
1025 * token was aliased to ACTIVE_PROGRAM_EXT, and
1026 * was used to indicate the last program set by
1027 * either ActiveProgramEXT or UseProgram. In
1028 * the ARB extension, the SSO active programs
1029 * are now program pipeline object state and
1030 * CURRENT_PROGRAM should still be used to query
1031 * the last program set by UseProgram (bug 7822).
1034 ctx
->Shader
.ActiveProgram
? ctx
->Shader
.ActiveProgram
->Name
: 0;
1036 case GL_READ_FRAMEBUFFER_BINDING_EXT
:
1037 v
->value_int
= ctx
->ReadBuffer
->Name
;
1039 case GL_RENDERBUFFER_BINDING_EXT
:
1041 ctx
->CurrentRenderbuffer
? ctx
->CurrentRenderbuffer
->Name
: 0;
1043 case GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES
:
1044 v
->value_int
= ctx
->Array
.VAO
->BufferBinding
[VERT_ATTRIB_POINT_SIZE
].BufferObj
->Name
;
1048 if (_mesa_get_clamp_fragment_color(ctx
, ctx
->DrawBuffer
))
1049 COPY_4FV(v
->value_float_4
, ctx
->Fog
.Color
);
1051 COPY_4FV(v
->value_float_4
, ctx
->Fog
.ColorUnclamped
);
1053 case GL_COLOR_CLEAR_VALUE
:
1054 if (_mesa_get_clamp_fragment_color(ctx
, ctx
->DrawBuffer
)) {
1055 v
->value_float_4
[0] = CLAMP(ctx
->Color
.ClearColor
.f
[0], 0.0F
, 1.0F
);
1056 v
->value_float_4
[1] = CLAMP(ctx
->Color
.ClearColor
.f
[1], 0.0F
, 1.0F
);
1057 v
->value_float_4
[2] = CLAMP(ctx
->Color
.ClearColor
.f
[2], 0.0F
, 1.0F
);
1058 v
->value_float_4
[3] = CLAMP(ctx
->Color
.ClearColor
.f
[3], 0.0F
, 1.0F
);
1060 COPY_4FV(v
->value_float_4
, ctx
->Color
.ClearColor
.f
);
1062 case GL_BLEND_COLOR_EXT
:
1063 if (_mesa_get_clamp_fragment_color(ctx
, ctx
->DrawBuffer
))
1064 COPY_4FV(v
->value_float_4
, ctx
->Color
.BlendColor
);
1066 COPY_4FV(v
->value_float_4
, ctx
->Color
.BlendColorUnclamped
);
1068 case GL_ALPHA_TEST_REF
:
1069 if (_mesa_get_clamp_fragment_color(ctx
, ctx
->DrawBuffer
))
1070 v
->value_float
= ctx
->Color
.AlphaRef
;
1072 v
->value_float
= ctx
->Color
.AlphaRefUnclamped
;
1074 case GL_MAX_VERTEX_UNIFORM_VECTORS
:
1075 v
->value_int
= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxUniformComponents
/ 4;
1078 case GL_MAX_FRAGMENT_UNIFORM_VECTORS
:
1079 v
->value_int
= ctx
->Const
.Program
[MESA_SHADER_FRAGMENT
].MaxUniformComponents
/ 4;
1082 /* GL_ARB_texture_buffer_object */
1083 case GL_TEXTURE_BUFFER_ARB
:
1084 v
->value_int
= ctx
->Texture
.BufferObject
->Name
;
1086 case GL_TEXTURE_BINDING_BUFFER_ARB
:
1087 unit
= ctx
->Texture
.CurrentUnit
;
1089 ctx
->Texture
.Unit
[unit
].CurrentTex
[TEXTURE_BUFFER_INDEX
]->Name
;
1091 case GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB
:
1093 struct gl_buffer_object
*buf
=
1094 ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
]
1095 .CurrentTex
[TEXTURE_BUFFER_INDEX
]->BufferObject
;
1096 v
->value_int
= buf
? buf
->Name
: 0;
1099 case GL_TEXTURE_BUFFER_FORMAT_ARB
:
1100 v
->value_int
= ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
]
1101 .CurrentTex
[TEXTURE_BUFFER_INDEX
]->BufferObjectFormat
;
1104 /* GL_ARB_sampler_objects */
1105 case GL_SAMPLER_BINDING
:
1107 struct gl_sampler_object
*samp
=
1108 ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
].Sampler
;
1109 v
->value_int
= samp
? samp
->Name
: 0;
1112 /* GL_ARB_uniform_buffer_object */
1113 case GL_UNIFORM_BUFFER_BINDING
:
1114 v
->value_int
= ctx
->UniformBuffer
->Name
;
1116 /* GL_ARB_shader_storage_buffer_object */
1117 case GL_SHADER_STORAGE_BUFFER_BINDING
:
1118 v
->value_int
= ctx
->ShaderStorageBuffer
->Name
;
1120 /* GL_ARB_query_buffer_object */
1121 case GL_QUERY_BUFFER_BINDING
:
1122 v
->value_int
= ctx
->QueryBuffer
->Name
;
1124 /* GL_ARB_timer_query */
1126 if (ctx
->Driver
.GetTimestamp
) {
1127 v
->value_int64
= ctx
->Driver
.GetTimestamp(ctx
);
1130 _mesa_problem(ctx
, "driver doesn't implement GetTimestamp");
1134 case GL_DEBUG_OUTPUT
:
1135 case GL_DEBUG_OUTPUT_SYNCHRONOUS
:
1136 case GL_DEBUG_LOGGED_MESSAGES
:
1137 case GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH
:
1138 case GL_DEBUG_GROUP_STACK_DEPTH
:
1139 v
->value_int
= _mesa_get_debug_state_int(ctx
, d
->pname
);
1141 /* GL_ARB_shader_atomic_counters */
1142 case GL_ATOMIC_COUNTER_BUFFER_BINDING
:
1143 if (ctx
->AtomicBuffer
) {
1144 v
->value_int
= ctx
->AtomicBuffer
->Name
;
1150 case GL_NUM_SHADING_LANGUAGE_VERSIONS
:
1151 v
->value_int
= _mesa_get_shading_language_version(ctx
, -1, NULL
);
1153 /* GL_ARB_draw_indirect */
1154 case GL_DRAW_INDIRECT_BUFFER_BINDING
:
1155 v
->value_int
= ctx
->DrawIndirectBuffer
->Name
;
1157 /* GL_ARB_indirect_parameters */
1158 case GL_PARAMETER_BUFFER_BINDING_ARB
:
1159 v
->value_int
= ctx
->ParameterBuffer
->Name
;
1161 /* GL_ARB_separate_shader_objects */
1162 case GL_PROGRAM_PIPELINE_BINDING
:
1163 if (ctx
->Pipeline
.Current
) {
1164 v
->value_int
= ctx
->Pipeline
.Current
->Name
;
1169 /* GL_ARB_compute_shader */
1170 case GL_DISPATCH_INDIRECT_BUFFER_BINDING
:
1171 v
->value_int
= ctx
->DispatchIndirectBuffer
->Name
;
1173 /* GL_ARB_multisample */
1175 v
->value_int
= _mesa_geometric_samples(ctx
->DrawBuffer
);
1177 case GL_SAMPLE_BUFFERS
:
1178 v
->value_int
= _mesa_geometric_samples(ctx
->DrawBuffer
) > 0;
1180 /* GL_EXT_textrue_integer */
1181 case GL_RGBA_INTEGER_MODE_EXT
:
1182 v
->value_int
= (ctx
->DrawBuffer
->_IntegerBuffers
!= 0);
1184 /* GL_ATI_meminfo & GL_NVX_gpu_memory_info */
1185 case GL_VBO_FREE_MEMORY_ATI
:
1186 case GL_TEXTURE_FREE_MEMORY_ATI
:
1187 case GL_RENDERBUFFER_FREE_MEMORY_ATI
:
1188 case GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX
:
1189 case GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX
:
1190 case GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX
:
1191 case GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX
:
1192 case GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX
:
1194 struct gl_memory_info info
;
1196 ctx
->Driver
.QueryMemoryInfo(ctx
, &info
);
1198 if (d
->pname
== GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX
)
1199 v
->value_int
= info
.total_device_memory
;
1200 else if (d
->pname
== GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX
)
1201 v
->value_int
= info
.total_device_memory
+
1202 info
.total_staging_memory
;
1203 else if (d
->pname
== GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX
)
1204 v
->value_int
= info
.avail_device_memory
;
1205 else if (d
->pname
== GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX
)
1206 v
->value_int
= info
.nr_device_memory_evictions
;
1207 else if (d
->pname
== GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX
)
1208 v
->value_int
= info
.device_memory_evicted
;
1210 /* ATI free memory enums.
1212 * Since the GPU memory is (usually) page-table based, every two
1213 * consecutive elements are equal. From the GL_ATI_meminfo
1216 * "param[0] - total memory free in the pool
1217 * param[1] - largest available free block in the pool
1218 * param[2] - total auxiliary memory free
1219 * param[3] - largest auxiliary free block"
1221 * All three (VBO, TEXTURE, RENDERBUFFER) queries return
1222 * the same numbers here.
1224 v
->value_int_4
[0] = info
.avail_device_memory
;
1225 v
->value_int_4
[1] = info
.avail_device_memory
;
1226 v
->value_int_4
[2] = info
.avail_staging_memory
;
1227 v
->value_int_4
[3] = info
.avail_staging_memory
;
1232 /* GL_ARB_get_program_binary */
1233 case GL_PROGRAM_BINARY_FORMATS
:
1234 assert(ctx
->Const
.NumProgramBinaryFormats
<= 1);
1235 v
->value_int_n
.n
= MIN2(ctx
->Const
.NumProgramBinaryFormats
, 1);
1236 if (ctx
->Const
.NumProgramBinaryFormats
> 0) {
1237 v
->value_int_n
.ints
[0] = GL_PROGRAM_BINARY_FORMAT_MESA
;
1240 /* ARB_spirv_extensions */
1241 case GL_NUM_SPIR_V_EXTENSIONS
:
1242 v
->value_int
= _mesa_get_spirv_extension_count(ctx
);
1244 /* GL_EXT_disjoint_timer_query */
1245 case GL_GPU_DISJOINT_EXT
:
1247 simple_mtx_lock(&ctx
->Shared
->Mutex
);
1248 v
->value_int
= ctx
->Shared
->DisjointOperation
;
1249 /* Reset state as expected by the spec. */
1250 ctx
->Shared
->DisjointOperation
= false;
1251 simple_mtx_unlock(&ctx
->Shared
->Mutex
);
1254 /* GL_ARB_sample_locations */
1255 case GL_SAMPLE_LOCATION_SUBPIXEL_BITS_ARB
:
1256 case GL_SAMPLE_LOCATION_PIXEL_GRID_WIDTH_ARB
:
1257 case GL_SAMPLE_LOCATION_PIXEL_GRID_HEIGHT_ARB
:
1259 GLuint bits
, width
, height
;
1261 if (ctx
->NewState
& _NEW_BUFFERS
)
1262 _mesa_update_state(ctx
);
1264 if (ctx
->DrawBuffer
->_Status
!= GL_FRAMEBUFFER_COMPLETE
) {
1269 ctx
->Driver
.GetProgrammableSampleCaps(ctx
, ctx
->DrawBuffer
,
1270 &bits
, &width
, &height
);
1272 if (d
->pname
== GL_SAMPLE_LOCATION_PIXEL_GRID_WIDTH_ARB
)
1273 v
->value_uint
= width
;
1274 else if (d
->pname
== GL_SAMPLE_LOCATION_PIXEL_GRID_HEIGHT_ARB
)
1275 v
->value_uint
= height
;
1277 v
->value_uint
= bits
;
1280 case GL_PROGRAMMABLE_SAMPLE_LOCATION_TABLE_SIZE_ARB
:
1281 v
->value_uint
= MAX_SAMPLE_LOCATION_TABLE_SIZE
;
1284 /* GL_AMD_framebuffer_multisample_advanced */
1285 case GL_SUPPORTED_MULTISAMPLE_MODES_AMD
:
1286 v
->value_int_n
.n
= ctx
->Const
.NumSupportedMultisampleModes
* 3;
1287 memcpy(v
->value_int_n
.ints
, ctx
->Const
.SupportedMultisampleModes
,
1288 v
->value_int_n
.n
* sizeof(GLint
));
1294 * Check extra constraints on a struct value_desc descriptor
1296 * If a struct value_desc has a non-NULL extra pointer, it means that
1297 * there are a number of extra constraints to check or actions to
1298 * perform. The extras is just an integer array where each integer
1299 * encode different constraints or actions.
1301 * \param ctx current context
1302 * \param func name of calling glGet*v() function for error reporting
1303 * \param d the struct value_desc that has the extra constraints
1305 * \return GL_FALSE if all of the constraints were not satisfied,
1306 * otherwise GL_TRUE.
1309 check_extra(struct gl_context
*ctx
, const char *func
, const struct value_desc
*d
)
1311 const GLuint version
= ctx
->Version
;
1312 GLboolean api_check
= GL_FALSE
;
1313 GLboolean api_found
= GL_FALSE
;
1316 for (e
= d
->extra
; *e
!= EXTRA_END
; e
++) {
1318 case EXTRA_VERSION_30
:
1319 api_check
= GL_TRUE
;
1321 api_found
= GL_TRUE
;
1323 case EXTRA_VERSION_31
:
1324 api_check
= GL_TRUE
;
1326 api_found
= GL_TRUE
;
1328 case EXTRA_VERSION_32
:
1329 api_check
= GL_TRUE
;
1331 api_found
= GL_TRUE
;
1333 case EXTRA_VERSION_40
:
1334 api_check
= GL_TRUE
;
1336 api_found
= GL_TRUE
;
1338 case EXTRA_VERSION_43
:
1340 if (_mesa_is_desktop_gl(ctx
) && version
>= 43)
1341 api_found
= GL_TRUE
;
1343 case EXTRA_NEW_FRAG_CLAMP
:
1344 if (ctx
->NewState
& (_NEW_BUFFERS
| _NEW_FRAG_CLAMP
))
1345 _mesa_update_state(ctx
);
1348 api_check
= GL_TRUE
;
1349 if (ctx
->API
== API_OPENGLES2
)
1350 api_found
= GL_TRUE
;
1353 api_check
= GL_TRUE
;
1354 if (_mesa_is_gles3(ctx
))
1355 api_found
= GL_TRUE
;
1357 case EXTRA_API_ES31
:
1358 api_check
= GL_TRUE
;
1359 if (_mesa_is_gles31(ctx
))
1360 api_found
= GL_TRUE
;
1362 case EXTRA_API_ES32
:
1363 api_check
= GL_TRUE
;
1364 if (_mesa_is_gles32(ctx
))
1365 api_found
= GL_TRUE
;
1368 api_check
= GL_TRUE
;
1369 if (_mesa_is_desktop_gl(ctx
))
1370 api_found
= GL_TRUE
;
1372 case EXTRA_API_GL_CORE
:
1373 api_check
= GL_TRUE
;
1374 if (ctx
->API
== API_OPENGL_CORE
)
1375 api_found
= GL_TRUE
;
1377 case EXTRA_NEW_BUFFERS
:
1378 if (ctx
->NewState
& _NEW_BUFFERS
)
1379 _mesa_update_state(ctx
);
1381 case EXTRA_FLUSH_CURRENT
:
1382 FLUSH_CURRENT(ctx
, 0);
1384 case EXTRA_VALID_DRAW_BUFFER
:
1385 if (d
->pname
- GL_DRAW_BUFFER0_ARB
>= ctx
->Const
.MaxDrawBuffers
) {
1386 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(draw buffer %u)",
1387 func
, d
->pname
- GL_DRAW_BUFFER0_ARB
);
1391 case EXTRA_VALID_TEXTURE_UNIT
:
1392 if (ctx
->Texture
.CurrentUnit
>= ctx
->Const
.MaxTextureCoordUnits
) {
1393 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(texture %u)",
1394 func
, ctx
->Texture
.CurrentUnit
);
1398 case EXTRA_VALID_CLIP_DISTANCE
:
1399 if (d
->pname
- GL_CLIP_DISTANCE0
>= ctx
->Const
.MaxClipPlanes
) {
1400 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(clip distance %u)",
1401 func
, d
->pname
- GL_CLIP_DISTANCE0
);
1405 case EXTRA_GLSL_130
:
1406 api_check
= GL_TRUE
;
1407 if (ctx
->Const
.GLSLVersion
>= 130)
1408 api_found
= GL_TRUE
;
1410 case EXTRA_EXT_UBO_GS
:
1411 api_check
= GL_TRUE
;
1412 if (ctx
->Extensions
.ARB_uniform_buffer_object
&&
1413 _mesa_has_geometry_shaders(ctx
))
1414 api_found
= GL_TRUE
;
1416 case EXTRA_EXT_ATOMICS_GS
:
1417 api_check
= GL_TRUE
;
1418 if (ctx
->Extensions
.ARB_shader_atomic_counters
&&
1419 _mesa_has_geometry_shaders(ctx
))
1420 api_found
= GL_TRUE
;
1422 case EXTRA_EXT_SHADER_IMAGE_GS
:
1423 api_check
= GL_TRUE
;
1424 if (ctx
->Extensions
.ARB_shader_image_load_store
&&
1425 _mesa_has_geometry_shaders(ctx
))
1426 api_found
= GL_TRUE
;
1428 case EXTRA_EXT_ATOMICS_TESS
:
1429 api_check
= GL_TRUE
;
1430 api_found
= ctx
->Extensions
.ARB_shader_atomic_counters
&&
1431 _mesa_has_tessellation(ctx
);
1433 case EXTRA_EXT_SHADER_IMAGE_TESS
:
1434 api_check
= GL_TRUE
;
1435 api_found
= ctx
->Extensions
.ARB_shader_image_load_store
&&
1436 _mesa_has_tessellation(ctx
);
1438 case EXTRA_EXT_SSBO_GS
:
1439 api_check
= GL_TRUE
;
1440 if (ctx
->Extensions
.ARB_shader_storage_buffer_object
&&
1441 _mesa_has_geometry_shaders(ctx
))
1442 api_found
= GL_TRUE
;
1444 case EXTRA_EXT_FB_NO_ATTACH_GS
:
1445 api_check
= GL_TRUE
;
1446 if (ctx
->Extensions
.ARB_framebuffer_no_attachments
&&
1447 (_mesa_is_desktop_gl(ctx
) ||
1448 _mesa_has_OES_geometry_shader(ctx
)))
1449 api_found
= GL_TRUE
;
1451 case EXTRA_EXT_ES_GS
:
1452 api_check
= GL_TRUE
;
1453 if (_mesa_has_OES_geometry_shader(ctx
))
1454 api_found
= GL_TRUE
;
1456 case EXTRA_EXT_PROVOKING_VERTEX_32
:
1458 if (ctx
->API
== API_OPENGL_COMPAT
|| version
== 32)
1459 api_found
= ctx
->Extensions
.EXT_provoking_vertex
;
1463 default: /* *e is a offset into the extension struct */
1464 api_check
= GL_TRUE
;
1465 if (*(GLboolean
*) ((char *) &ctx
->Extensions
+ *e
))
1466 api_found
= GL_TRUE
;
1471 if (api_check
&& !api_found
) {
1472 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(pname=%s)", func
,
1473 _mesa_enum_to_string(d
->pname
));
1480 static const struct value_desc error_value
=
1481 { 0, 0, TYPE_INVALID
, NO_OFFSET
, NO_EXTRA
};
1484 * Find the struct value_desc corresponding to the enum 'pname'.
1486 * We hash the enum value to get an index into the 'table' array,
1487 * which holds the index in the 'values' array of struct value_desc.
1488 * Once we've found the entry, we do the extra checks, if any, then
1489 * look up the value and return a pointer to it.
1491 * If the value has to be computed (for example, it's the result of a
1492 * function call or we need to add 1 to it), we use the tmp 'v' to
1495 * \param func name of glGet*v() func for error reporting
1496 * \param pname the enum value we're looking up
1497 * \param p is were we return the pointer to the value
1498 * \param v a tmp union value variable in the calling glGet*v() function
1500 * \return the struct value_desc corresponding to the enum or a struct
1501 * value_desc of TYPE_INVALID if not found. This lets the calling
1502 * glGet*v() function jump right into a switch statement and
1503 * handle errors there instead of having to check for NULL.
1505 static const struct value_desc
*
1506 find_value(const char *func
, GLenum pname
, void **p
, union value
*v
)
1508 GET_CURRENT_CONTEXT(ctx
);
1510 const struct value_desc
*d
;
1514 /* We index into the table_set[] list of per-API hash tables using the API's
1515 * value in the gl_api enum. Since GLES 3 doesn't have an API_OPENGL* enum
1516 * value since it's compatible with GLES2 its entry in table_set[] is at the
1519 STATIC_ASSERT(ARRAY_SIZE(table_set
) == API_OPENGL_LAST
+ 4);
1520 if (ctx
->API
== API_OPENGLES2
) {
1521 if (ctx
->Version
>= 32)
1522 api
= API_OPENGL_LAST
+ 3;
1523 else if (ctx
->Version
>= 31)
1524 api
= API_OPENGL_LAST
+ 2;
1525 else if (ctx
->Version
>= 30)
1526 api
= API_OPENGL_LAST
+ 1;
1528 mask
= ARRAY_SIZE(table(api
)) - 1;
1529 hash
= (pname
* prime_factor
);
1531 int idx
= table(api
)[hash
& mask
];
1533 /* If the enum isn't valid, the hash walk ends with index 0,
1534 * pointing to the first entry of values[] which doesn't hold
1535 * any valid enum. */
1536 if (unlikely(idx
== 0)) {
1537 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(pname=%s)", func
,
1538 _mesa_enum_to_string(pname
));
1539 return &error_value
;
1543 if (likely(d
->pname
== pname
))
1549 if (unlikely(d
->extra
&& !check_extra(ctx
, func
, d
)))
1550 return &error_value
;
1552 switch (d
->location
) {
1554 *p
= ((char *) ctx
->DrawBuffer
+ d
->offset
);
1557 *p
= ((char *) ctx
+ d
->offset
);
1560 *p
= ((char *) ctx
->Array
.VAO
+ d
->offset
);
1563 if (ctx
->Texture
.CurrentUnit
< ARRAY_SIZE(ctx
->Texture
.FixedFuncUnit
)) {
1564 unsigned index
= ctx
->Texture
.CurrentUnit
;
1565 *p
= ((char *)&ctx
->Texture
.FixedFuncUnit
[index
] + d
->offset
);
1569 find_custom_value(ctx
, d
, v
);
1577 /* silence warning */
1578 return &error_value
;
1581 static const int transpose
[] = {
1589 get_value_size(enum value_type type
, const union value
*v
)
1597 return sizeof(GLint
);
1600 return sizeof(GLint
) * 2;
1603 return sizeof(GLint
) * 3;
1606 return sizeof(GLint
) * 4;
1608 return sizeof(GLint
) * v
->value_int_n
.n
;
1610 return sizeof(GLint64
);
1613 return sizeof(GLenum16
);
1615 return sizeof(GLenum
);
1617 return sizeof(GLenum
) * 2;
1619 return sizeof(GLboolean
);
1621 return sizeof(GLubyte
);
1623 return sizeof(GLshort
);
1635 return sizeof(GLfloat
);
1638 return sizeof(GLfloat
) * 2;
1641 return sizeof(GLfloat
) * 3;
1644 return sizeof(GLfloat
) * 4;
1646 return sizeof(GLfloat
) * 8;
1648 return sizeof(GLdouble
);
1649 case TYPE_DOUBLEN_2
:
1650 return sizeof(GLdouble
) * 2;
1652 return sizeof (GLfloat
) * 16;
1654 return sizeof (GLfloat
) * 16;
1661 _mesa_GetBooleanv(GLenum pname
, GLboolean
*params
)
1663 const struct value_desc
*d
;
1669 d
= find_value("glGetBooleanv", pname
, &p
, &v
);
1674 params
[0] = INT_TO_BOOLEAN(d
->offset
);
1678 params
[7] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[7]);
1679 params
[6] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[6]);
1680 params
[5] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[5]);
1681 params
[4] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[4]);
1684 params
[3] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[3]);
1687 params
[2] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[2]);
1690 params
[1] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[1]);
1693 params
[0] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[0]);
1696 case TYPE_DOUBLEN_2
:
1697 params
[1] = FLOAT_TO_BOOLEAN(((GLdouble
*) p
)[1]);
1699 params
[0] = FLOAT_TO_BOOLEAN(((GLdouble
*) p
)[0]);
1704 params
[3] = INT_TO_BOOLEAN(((GLint
*) p
)[3]);
1707 params
[2] = INT_TO_BOOLEAN(((GLint
*) p
)[2]);
1711 params
[1] = INT_TO_BOOLEAN(((GLint
*) p
)[1]);
1715 params
[0] = INT_TO_BOOLEAN(((GLint
*) p
)[0]);
1719 params
[0] = INT_TO_BOOLEAN(((GLenum16
*) p
)[0]);
1723 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
1724 params
[i
] = INT_TO_BOOLEAN(v
.value_int_n
.ints
[i
]);
1728 params
[0] = INT64_TO_BOOLEAN(((GLint64
*) p
)[0]);
1732 params
[0] = ((GLboolean
*) p
)[0];
1736 params
[0] = INT_TO_BOOLEAN(((GLubyte
*) p
)[0]);
1740 params
[0] = INT_TO_BOOLEAN(((GLshort
*) p
)[0]);
1744 m
= *(GLmatrix
**) p
;
1745 for (i
= 0; i
< 16; i
++)
1746 params
[i
] = FLOAT_TO_BOOLEAN(m
->m
[i
]);
1750 m
= *(GLmatrix
**) p
;
1751 for (i
= 0; i
< 16; i
++)
1752 params
[i
] = FLOAT_TO_BOOLEAN(m
->m
[transpose
[i
]]);
1763 shift
= d
->type
- TYPE_BIT_0
;
1764 params
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
1770 _mesa_GetFloatv(GLenum pname
, GLfloat
*params
)
1772 const struct value_desc
*d
;
1778 d
= find_value("glGetFloatv", pname
, &p
, &v
);
1783 params
[0] = (GLfloat
) d
->offset
;
1787 params
[7] = ((GLfloat
*) p
)[7];
1788 params
[6] = ((GLfloat
*) p
)[6];
1789 params
[5] = ((GLfloat
*) p
)[5];
1790 params
[4] = ((GLfloat
*) p
)[4];
1793 params
[3] = ((GLfloat
*) p
)[3];
1796 params
[2] = ((GLfloat
*) p
)[2];
1799 params
[1] = ((GLfloat
*) p
)[1];
1802 params
[0] = ((GLfloat
*) p
)[0];
1805 case TYPE_DOUBLEN_2
:
1806 params
[1] = (GLfloat
) (((GLdouble
*) p
)[1]);
1808 params
[0] = (GLfloat
) (((GLdouble
*) p
)[0]);
1812 params
[3] = (GLfloat
) (((GLint
*) p
)[3]);
1814 params
[2] = (GLfloat
) (((GLint
*) p
)[2]);
1817 params
[1] = (GLfloat
) (((GLint
*) p
)[1]);
1820 params
[0] = (GLfloat
) (((GLint
*) p
)[0]);
1824 params
[0] = (GLfloat
) (((GLenum16
*) p
)[0]);
1828 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
1829 params
[i
] = (GLfloat
) v
.value_int_n
.ints
[i
];
1833 params
[3] = (GLfloat
) (((GLuint
*) p
)[3]);
1835 params
[2] = (GLfloat
) (((GLuint
*) p
)[2]);
1837 params
[1] = (GLfloat
) (((GLuint
*) p
)[1]);
1839 params
[0] = (GLfloat
) (((GLuint
*) p
)[0]);
1843 params
[0] = (GLfloat
) (((GLint64
*) p
)[0]);
1847 params
[0] = BOOLEAN_TO_FLOAT(*(GLboolean
*) p
);
1851 params
[0] = (GLfloat
) ((GLubyte
*) p
)[0];
1855 params
[0] = (GLfloat
) ((GLshort
*) p
)[0];
1859 m
= *(GLmatrix
**) p
;
1860 for (i
= 0; i
< 16; i
++)
1861 params
[i
] = m
->m
[i
];
1865 m
= *(GLmatrix
**) p
;
1866 for (i
= 0; i
< 16; i
++)
1867 params
[i
] = m
->m
[transpose
[i
]];
1878 shift
= d
->type
- TYPE_BIT_0
;
1879 params
[0] = BOOLEAN_TO_FLOAT((*(GLbitfield
*) p
>> shift
) & 1);
1885 _mesa_GetIntegerv(GLenum pname
, GLint
*params
)
1887 const struct value_desc
*d
;
1893 d
= find_value("glGetIntegerv", pname
, &p
, &v
);
1898 params
[0] = d
->offset
;
1902 params
[7] = IROUND(((GLfloat
*) p
)[7]);
1903 params
[6] = IROUND(((GLfloat
*) p
)[6]);
1904 params
[5] = IROUND(((GLfloat
*) p
)[5]);
1905 params
[4] = IROUND(((GLfloat
*) p
)[4]);
1907 params
[3] = IROUND(((GLfloat
*) p
)[3]);
1909 params
[2] = IROUND(((GLfloat
*) p
)[2]);
1911 params
[1] = IROUND(((GLfloat
*) p
)[1]);
1913 params
[0] = IROUND(((GLfloat
*) p
)[0]);
1917 params
[3] = FLOAT_TO_INT(((GLfloat
*) p
)[3]);
1919 params
[2] = FLOAT_TO_INT(((GLfloat
*) p
)[2]);
1921 params
[1] = FLOAT_TO_INT(((GLfloat
*) p
)[1]);
1923 params
[0] = FLOAT_TO_INT(((GLfloat
*) p
)[0]);
1926 case TYPE_DOUBLEN_2
:
1927 params
[1] = FLOAT_TO_INT(((GLdouble
*) p
)[1]);
1929 params
[0] = FLOAT_TO_INT(((GLdouble
*) p
)[0]);
1934 params
[3] = ((GLint
*) p
)[3];
1937 params
[2] = ((GLint
*) p
)[2];
1941 params
[1] = ((GLint
*) p
)[1];
1945 params
[0] = ((GLint
*) p
)[0];
1949 params
[0] = ((GLenum16
*) p
)[0];
1953 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
1954 params
[i
] = v
.value_int_n
.ints
[i
];
1958 params
[0] = INT64_TO_INT(((GLint64
*) p
)[0]);
1962 params
[0] = BOOLEAN_TO_INT(*(GLboolean
*) p
);
1966 params
[0] = ((GLubyte
*) p
)[0];
1970 params
[0] = ((GLshort
*) p
)[0];
1974 m
= *(GLmatrix
**) p
;
1975 for (i
= 0; i
< 16; i
++)
1976 params
[i
] = FLOAT_TO_INT(m
->m
[i
]);
1980 m
= *(GLmatrix
**) p
;
1981 for (i
= 0; i
< 16; i
++)
1982 params
[i
] = FLOAT_TO_INT(m
->m
[transpose
[i
]]);
1993 shift
= d
->type
- TYPE_BIT_0
;
1994 params
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
2000 _mesa_GetInteger64v(GLenum pname
, GLint64
*params
)
2002 const struct value_desc
*d
;
2008 d
= find_value("glGetInteger64v", pname
, &p
, &v
);
2013 params
[0] = d
->offset
;
2017 params
[7] = IROUND64(((GLfloat
*) p
)[7]);
2018 params
[6] = IROUND64(((GLfloat
*) p
)[6]);
2019 params
[5] = IROUND64(((GLfloat
*) p
)[5]);
2020 params
[4] = IROUND64(((GLfloat
*) p
)[4]);
2022 params
[3] = IROUND64(((GLfloat
*) p
)[3]);
2024 params
[2] = IROUND64(((GLfloat
*) p
)[2]);
2026 params
[1] = IROUND64(((GLfloat
*) p
)[1]);
2028 params
[0] = IROUND64(((GLfloat
*) p
)[0]);
2032 params
[3] = FLOAT_TO_INT(((GLfloat
*) p
)[3]);
2034 params
[2] = FLOAT_TO_INT(((GLfloat
*) p
)[2]);
2036 params
[1] = FLOAT_TO_INT(((GLfloat
*) p
)[1]);
2038 params
[0] = FLOAT_TO_INT(((GLfloat
*) p
)[0]);
2041 case TYPE_DOUBLEN_2
:
2042 params
[1] = FLOAT_TO_INT(((GLdouble
*) p
)[1]);
2044 params
[0] = FLOAT_TO_INT(((GLdouble
*) p
)[0]);
2048 params
[3] = ((GLint
*) p
)[3];
2050 params
[2] = ((GLint
*) p
)[2];
2053 params
[1] = ((GLint
*) p
)[1];
2056 params
[0] = ((GLint
*) p
)[0];
2060 params
[0] = ((GLenum16
*) p
)[0];
2064 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
2065 params
[i
] = v
.value_int_n
.ints
[i
];
2069 params
[3] = ((GLuint
*) p
)[3];
2071 params
[2] = ((GLuint
*) p
)[2];
2073 params
[1] = ((GLuint
*) p
)[1];
2075 params
[0] = ((GLuint
*) p
)[0];
2079 params
[0] = ((GLint64
*) p
)[0];
2083 params
[0] = ((GLboolean
*) p
)[0];
2087 m
= *(GLmatrix
**) p
;
2088 for (i
= 0; i
< 16; i
++)
2089 params
[i
] = FLOAT_TO_INT64(m
->m
[i
]);
2093 m
= *(GLmatrix
**) p
;
2094 for (i
= 0; i
< 16; i
++)
2095 params
[i
] = FLOAT_TO_INT64(m
->m
[transpose
[i
]]);
2106 shift
= d
->type
- TYPE_BIT_0
;
2107 params
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
2113 _mesa_GetDoublev(GLenum pname
, GLdouble
*params
)
2115 const struct value_desc
*d
;
2121 d
= find_value("glGetDoublev", pname
, &p
, &v
);
2126 params
[0] = d
->offset
;
2130 params
[7] = ((GLfloat
*) p
)[7];
2131 params
[6] = ((GLfloat
*) p
)[6];
2132 params
[5] = ((GLfloat
*) p
)[5];
2133 params
[4] = ((GLfloat
*) p
)[4];
2136 params
[3] = ((GLfloat
*) p
)[3];
2139 params
[2] = ((GLfloat
*) p
)[2];
2142 params
[1] = ((GLfloat
*) p
)[1];
2145 params
[0] = ((GLfloat
*) p
)[0];
2148 case TYPE_DOUBLEN_2
:
2149 params
[1] = ((GLdouble
*) p
)[1];
2151 params
[0] = ((GLdouble
*) p
)[0];
2155 params
[3] = ((GLint
*) p
)[3];
2157 params
[2] = ((GLint
*) p
)[2];
2160 params
[1] = ((GLint
*) p
)[1];
2163 params
[0] = ((GLint
*) p
)[0];
2167 params
[0] = ((GLenum16
*) p
)[0];
2171 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
2172 params
[i
] = v
.value_int_n
.ints
[i
];
2176 params
[3] = ((GLuint
*) p
)[3];
2178 params
[2] = ((GLuint
*) p
)[2];
2180 params
[1] = ((GLuint
*) p
)[1];
2182 params
[0] = ((GLuint
*) p
)[0];
2186 params
[0] = (GLdouble
) (((GLint64
*) p
)[0]);
2190 params
[0] = *(GLboolean
*) p
;
2194 params
[0] = ((GLubyte
*) p
)[0];
2198 params
[0] = ((GLshort
*) p
)[0];
2202 m
= *(GLmatrix
**) p
;
2203 for (i
= 0; i
< 16; i
++)
2204 params
[i
] = m
->m
[i
];
2208 m
= *(GLmatrix
**) p
;
2209 for (i
= 0; i
< 16; i
++)
2210 params
[i
] = m
->m
[transpose
[i
]];
2221 shift
= d
->type
- TYPE_BIT_0
;
2222 params
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
2228 _mesa_GetUnsignedBytevEXT(GLenum pname
, GLubyte
*data
)
2230 const struct value_desc
*d
;
2235 const char *func
= "glGetUnsignedBytevEXT";
2237 GET_CURRENT_CONTEXT(ctx
);
2239 if (!ctx
->Extensions
.EXT_memory_object
) {
2240 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(unsupported)", func
);
2244 d
= find_value(func
, pname
, &p
, &v
);
2245 size
= get_value_size(d
->type
, &v
);
2247 _mesa_problem(ctx
, "invalid value type in GetUnsignedBytevEXT()");
2259 shift
= d
->type
- TYPE_BIT_0
;
2260 data
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
2263 memcpy(data
, &d
->offset
, size
);
2266 memcpy(data
, &v
.value_int_n
.ints
, size
);
2292 case TYPE_DOUBLEN_2
:
2295 memcpy(data
, p
, size
);
2298 GLenum e
= *(GLenum16
*)p
;
2299 memcpy(data
, &e
, sizeof(e
));
2303 break; /* nothing - GL error was recorded */
2308 * Convert a GL texture binding enum such as GL_TEXTURE_BINDING_2D
2309 * into the corresponding Mesa texture target index.
2310 * \return TEXTURE_x_INDEX or -1 if binding is invalid
2313 tex_binding_to_index(const struct gl_context
*ctx
, GLenum binding
)
2316 case GL_TEXTURE_BINDING_1D
:
2317 return _mesa_is_desktop_gl(ctx
) ? TEXTURE_1D_INDEX
: -1;
2318 case GL_TEXTURE_BINDING_2D
:
2319 return TEXTURE_2D_INDEX
;
2320 case GL_TEXTURE_BINDING_3D
:
2321 return ctx
->API
!= API_OPENGLES
? TEXTURE_3D_INDEX
: -1;
2322 case GL_TEXTURE_BINDING_CUBE_MAP
:
2323 return ctx
->Extensions
.ARB_texture_cube_map
2324 ? TEXTURE_CUBE_INDEX
: -1;
2325 case GL_TEXTURE_BINDING_RECTANGLE
:
2326 return _mesa_is_desktop_gl(ctx
) && ctx
->Extensions
.NV_texture_rectangle
2327 ? TEXTURE_RECT_INDEX
: -1;
2328 case GL_TEXTURE_BINDING_1D_ARRAY
:
2329 return _mesa_is_desktop_gl(ctx
) && ctx
->Extensions
.EXT_texture_array
2330 ? TEXTURE_1D_ARRAY_INDEX
: -1;
2331 case GL_TEXTURE_BINDING_2D_ARRAY
:
2332 return (_mesa_is_desktop_gl(ctx
) && ctx
->Extensions
.EXT_texture_array
)
2333 || _mesa_is_gles3(ctx
)
2334 ? TEXTURE_2D_ARRAY_INDEX
: -1;
2335 case GL_TEXTURE_BINDING_BUFFER
:
2336 return (_mesa_has_ARB_texture_buffer_object(ctx
) ||
2337 _mesa_has_OES_texture_buffer(ctx
)) ?
2338 TEXTURE_BUFFER_INDEX
: -1;
2339 case GL_TEXTURE_BINDING_CUBE_MAP_ARRAY
:
2340 return _mesa_has_texture_cube_map_array(ctx
)
2341 ? TEXTURE_CUBE_ARRAY_INDEX
: -1;
2342 case GL_TEXTURE_BINDING_2D_MULTISAMPLE
:
2343 return _mesa_is_desktop_gl(ctx
) && ctx
->Extensions
.ARB_texture_multisample
2344 ? TEXTURE_2D_MULTISAMPLE_INDEX
: -1;
2345 case GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY
:
2346 return _mesa_is_desktop_gl(ctx
) && ctx
->Extensions
.ARB_texture_multisample
2347 ? TEXTURE_2D_MULTISAMPLE_ARRAY_INDEX
: -1;
2353 static enum value_type
2354 find_value_indexed(const char *func
, GLenum pname
, GLuint index
, union value
*v
)
2356 GET_CURRENT_CONTEXT(ctx
);
2361 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2363 if (!ctx
->Extensions
.EXT_draw_buffers2
)
2365 v
->value_int
= (ctx
->Color
.BlendEnabled
>> index
) & 1;
2370 case GL_BLEND_SRC_RGB
:
2371 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2373 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
2375 v
->value_int
= ctx
->Color
.Blend
[index
].SrcRGB
;
2377 case GL_BLEND_SRC_ALPHA
:
2378 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2380 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
2382 v
->value_int
= ctx
->Color
.Blend
[index
].SrcA
;
2386 case GL_BLEND_DST_RGB
:
2387 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2389 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
2391 v
->value_int
= ctx
->Color
.Blend
[index
].DstRGB
;
2393 case GL_BLEND_DST_ALPHA
:
2394 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2396 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
2398 v
->value_int
= ctx
->Color
.Blend
[index
].DstA
;
2400 case GL_BLEND_EQUATION_RGB
:
2401 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2403 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
2405 v
->value_int
= ctx
->Color
.Blend
[index
].EquationRGB
;
2407 case GL_BLEND_EQUATION_ALPHA
:
2408 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2410 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
2412 v
->value_int
= ctx
->Color
.Blend
[index
].EquationA
;
2415 case GL_COLOR_WRITEMASK
:
2416 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2418 if (!ctx
->Extensions
.EXT_draw_buffers2
)
2420 v
->value_int_4
[0] = GET_COLORMASK_BIT(ctx
->Color
.ColorMask
, index
, 0);
2421 v
->value_int_4
[1] = GET_COLORMASK_BIT(ctx
->Color
.ColorMask
, index
, 1);
2422 v
->value_int_4
[2] = GET_COLORMASK_BIT(ctx
->Color
.ColorMask
, index
, 2);
2423 v
->value_int_4
[3] = GET_COLORMASK_BIT(ctx
->Color
.ColorMask
, index
, 3);
2426 case GL_SCISSOR_BOX
:
2427 if (index
>= ctx
->Const
.MaxViewports
)
2429 v
->value_int_4
[0] = ctx
->Scissor
.ScissorArray
[index
].X
;
2430 v
->value_int_4
[1] = ctx
->Scissor
.ScissorArray
[index
].Y
;
2431 v
->value_int_4
[2] = ctx
->Scissor
.ScissorArray
[index
].Width
;
2432 v
->value_int_4
[3] = ctx
->Scissor
.ScissorArray
[index
].Height
;
2435 case GL_WINDOW_RECTANGLE_EXT
:
2436 if (!ctx
->Extensions
.EXT_window_rectangles
)
2438 if (index
>= ctx
->Const
.MaxWindowRectangles
)
2440 v
->value_int_4
[0] = ctx
->Scissor
.WindowRects
[index
].X
;
2441 v
->value_int_4
[1] = ctx
->Scissor
.WindowRects
[index
].Y
;
2442 v
->value_int_4
[2] = ctx
->Scissor
.WindowRects
[index
].Width
;
2443 v
->value_int_4
[3] = ctx
->Scissor
.WindowRects
[index
].Height
;
2447 if (index
>= ctx
->Const
.MaxViewports
)
2449 v
->value_float_4
[0] = ctx
->ViewportArray
[index
].X
;
2450 v
->value_float_4
[1] = ctx
->ViewportArray
[index
].Y
;
2451 v
->value_float_4
[2] = ctx
->ViewportArray
[index
].Width
;
2452 v
->value_float_4
[3] = ctx
->ViewportArray
[index
].Height
;
2453 return TYPE_FLOAT_4
;
2455 case GL_DEPTH_RANGE
:
2456 if (index
>= ctx
->Const
.MaxViewports
)
2458 v
->value_double_2
[0] = ctx
->ViewportArray
[index
].Near
;
2459 v
->value_double_2
[1] = ctx
->ViewportArray
[index
].Far
;
2460 return TYPE_DOUBLEN_2
;
2462 case GL_TRANSFORM_FEEDBACK_BUFFER_START
:
2463 if (index
>= ctx
->Const
.MaxTransformFeedbackBuffers
)
2465 if (!ctx
->Extensions
.EXT_transform_feedback
)
2467 v
->value_int64
= ctx
->TransformFeedback
.CurrentObject
->Offset
[index
];
2470 case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE
:
2471 if (index
>= ctx
->Const
.MaxTransformFeedbackBuffers
)
2473 if (!ctx
->Extensions
.EXT_transform_feedback
)
2476 = ctx
->TransformFeedback
.CurrentObject
->RequestedSize
[index
];
2479 case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING
:
2480 if (index
>= ctx
->Const
.MaxTransformFeedbackBuffers
)
2482 if (!ctx
->Extensions
.EXT_transform_feedback
)
2484 v
->value_int
= ctx
->TransformFeedback
.CurrentObject
->BufferNames
[index
];
2487 case GL_UNIFORM_BUFFER_BINDING
:
2488 if (index
>= ctx
->Const
.MaxUniformBufferBindings
)
2490 if (!ctx
->Extensions
.ARB_uniform_buffer_object
)
2492 v
->value_int
= ctx
->UniformBufferBindings
[index
].BufferObject
->Name
;
2495 case GL_UNIFORM_BUFFER_START
:
2496 if (index
>= ctx
->Const
.MaxUniformBufferBindings
)
2498 if (!ctx
->Extensions
.ARB_uniform_buffer_object
)
2500 v
->value_int
= ctx
->UniformBufferBindings
[index
].Offset
< 0 ? 0 :
2501 ctx
->UniformBufferBindings
[index
].Offset
;
2504 case GL_UNIFORM_BUFFER_SIZE
:
2505 if (index
>= ctx
->Const
.MaxUniformBufferBindings
)
2507 if (!ctx
->Extensions
.ARB_uniform_buffer_object
)
2509 v
->value_int
= ctx
->UniformBufferBindings
[index
].Size
< 0 ? 0 :
2510 ctx
->UniformBufferBindings
[index
].Size
;
2513 /* ARB_shader_storage_buffer_object */
2514 case GL_SHADER_STORAGE_BUFFER_BINDING
:
2515 if (!ctx
->Extensions
.ARB_shader_storage_buffer_object
)
2517 if (index
>= ctx
->Const
.MaxShaderStorageBufferBindings
)
2519 v
->value_int
= ctx
->ShaderStorageBufferBindings
[index
].BufferObject
->Name
;
2522 case GL_SHADER_STORAGE_BUFFER_START
:
2523 if (!ctx
->Extensions
.ARB_shader_storage_buffer_object
)
2525 if (index
>= ctx
->Const
.MaxShaderStorageBufferBindings
)
2527 v
->value_int
= ctx
->ShaderStorageBufferBindings
[index
].Offset
< 0 ? 0 :
2528 ctx
->ShaderStorageBufferBindings
[index
].Offset
;
2531 case GL_SHADER_STORAGE_BUFFER_SIZE
:
2532 if (!ctx
->Extensions
.ARB_shader_storage_buffer_object
)
2534 if (index
>= ctx
->Const
.MaxShaderStorageBufferBindings
)
2536 v
->value_int
= ctx
->ShaderStorageBufferBindings
[index
].Size
< 0 ? 0 :
2537 ctx
->ShaderStorageBufferBindings
[index
].Size
;
2540 /* ARB_texture_multisample / GL3.2 */
2541 case GL_SAMPLE_MASK_VALUE
:
2544 if (!ctx
->Extensions
.ARB_texture_multisample
)
2546 v
->value_int
= ctx
->Multisample
.SampleMaskValue
;
2549 case GL_ATOMIC_COUNTER_BUFFER_BINDING
:
2550 if (!ctx
->Extensions
.ARB_shader_atomic_counters
)
2552 if (index
>= ctx
->Const
.MaxAtomicBufferBindings
)
2554 v
->value_int
= ctx
->AtomicBufferBindings
[index
].BufferObject
->Name
;
2557 case GL_ATOMIC_COUNTER_BUFFER_START
:
2558 if (!ctx
->Extensions
.ARB_shader_atomic_counters
)
2560 if (index
>= ctx
->Const
.MaxAtomicBufferBindings
)
2562 v
->value_int64
= ctx
->AtomicBufferBindings
[index
].Offset
< 0 ? 0 :
2563 ctx
->AtomicBufferBindings
[index
].Offset
;
2566 case GL_ATOMIC_COUNTER_BUFFER_SIZE
:
2567 if (!ctx
->Extensions
.ARB_shader_atomic_counters
)
2569 if (index
>= ctx
->Const
.MaxAtomicBufferBindings
)
2571 v
->value_int64
= ctx
->AtomicBufferBindings
[index
].Size
< 0 ? 0 :
2572 ctx
->AtomicBufferBindings
[index
].Size
;
2575 case GL_VERTEX_BINDING_DIVISOR
:
2576 if ((!_mesa_is_desktop_gl(ctx
) || !ctx
->Extensions
.ARB_instanced_arrays
) &&
2577 !_mesa_is_gles31(ctx
))
2579 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
)
2581 v
->value_int
= ctx
->Array
.VAO
->BufferBinding
[VERT_ATTRIB_GENERIC(index
)].InstanceDivisor
;
2584 case GL_VERTEX_BINDING_OFFSET
:
2585 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles31(ctx
))
2587 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
)
2589 v
->value_int
= ctx
->Array
.VAO
->BufferBinding
[VERT_ATTRIB_GENERIC(index
)].Offset
;
2592 case GL_VERTEX_BINDING_STRIDE
:
2593 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles31(ctx
))
2595 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
)
2597 v
->value_int
= ctx
->Array
.VAO
->BufferBinding
[VERT_ATTRIB_GENERIC(index
)].Stride
;
2600 case GL_VERTEX_BINDING_BUFFER
:
2601 if (ctx
->API
== API_OPENGLES2
&& ctx
->Version
< 31)
2603 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
)
2605 v
->value_int
= ctx
->Array
.VAO
->BufferBinding
[VERT_ATTRIB_GENERIC(index
)].BufferObj
->Name
;
2608 /* ARB_shader_image_load_store */
2609 case GL_IMAGE_BINDING_NAME
: {
2610 struct gl_texture_object
*t
;
2612 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
2614 if (index
>= ctx
->Const
.MaxImageUnits
)
2617 t
= ctx
->ImageUnits
[index
].TexObj
;
2618 v
->value_int
= (t
? t
->Name
: 0);
2622 case GL_IMAGE_BINDING_LEVEL
:
2623 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
2625 if (index
>= ctx
->Const
.MaxImageUnits
)
2628 v
->value_int
= ctx
->ImageUnits
[index
].Level
;
2631 case GL_IMAGE_BINDING_LAYERED
:
2632 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
2634 if (index
>= ctx
->Const
.MaxImageUnits
)
2637 v
->value_int
= ctx
->ImageUnits
[index
].Layered
;
2640 case GL_IMAGE_BINDING_LAYER
:
2641 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
2643 if (index
>= ctx
->Const
.MaxImageUnits
)
2646 v
->value_int
= ctx
->ImageUnits
[index
].Layer
;
2649 case GL_IMAGE_BINDING_ACCESS
:
2650 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
2652 if (index
>= ctx
->Const
.MaxImageUnits
)
2655 v
->value_int
= ctx
->ImageUnits
[index
].Access
;
2658 case GL_IMAGE_BINDING_FORMAT
:
2659 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
2661 if (index
>= ctx
->Const
.MaxImageUnits
)
2664 v
->value_int
= ctx
->ImageUnits
[index
].Format
;
2667 /* ARB_direct_state_access */
2668 case GL_TEXTURE_BINDING_1D
:
2669 case GL_TEXTURE_BINDING_1D_ARRAY
:
2670 case GL_TEXTURE_BINDING_2D
:
2671 case GL_TEXTURE_BINDING_2D_ARRAY
:
2672 case GL_TEXTURE_BINDING_2D_MULTISAMPLE
:
2673 case GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY
:
2674 case GL_TEXTURE_BINDING_3D
:
2675 case GL_TEXTURE_BINDING_BUFFER
:
2676 case GL_TEXTURE_BINDING_CUBE_MAP
:
2677 case GL_TEXTURE_BINDING_CUBE_MAP_ARRAY
:
2678 case GL_TEXTURE_BINDING_RECTANGLE
: {
2681 if (ctx
->API
!= API_OPENGL_CORE
)
2683 target
= tex_binding_to_index(ctx
, pname
);
2686 if (index
>= _mesa_max_tex_unit(ctx
))
2689 v
->value_int
= ctx
->Texture
.Unit
[index
].CurrentTex
[target
]->Name
;
2693 case GL_SAMPLER_BINDING
: {
2694 struct gl_sampler_object
*samp
;
2696 if (!_mesa_is_desktop_gl(ctx
) || ctx
->Version
< 33)
2698 if (index
>= _mesa_max_tex_unit(ctx
))
2701 samp
= ctx
->Texture
.Unit
[index
].Sampler
;
2702 v
->value_int
= samp
? samp
->Name
: 0;
2706 case GL_MAX_COMPUTE_WORK_GROUP_COUNT
:
2707 if (!_mesa_has_compute_shaders(ctx
))
2711 v
->value_int
= ctx
->Const
.MaxComputeWorkGroupCount
[index
];
2714 case GL_MAX_COMPUTE_WORK_GROUP_SIZE
:
2715 if (!_mesa_has_compute_shaders(ctx
))
2719 v
->value_int
= ctx
->Const
.MaxComputeWorkGroupSize
[index
];
2722 /* ARB_compute_variable_group_size */
2723 case GL_MAX_COMPUTE_VARIABLE_GROUP_SIZE_ARB
:
2724 if (!ctx
->Extensions
.ARB_compute_variable_group_size
)
2728 v
->value_int
= ctx
->Const
.MaxComputeVariableGroupSize
[index
];
2731 /* GL_EXT_external_objects */
2732 case GL_NUM_DEVICE_UUIDS_EXT
:
2735 case GL_DRIVER_UUID_EXT
:
2738 _mesa_get_driver_uuid(ctx
, v
->value_int_4
);
2740 case GL_DEVICE_UUID_EXT
:
2743 _mesa_get_device_uuid(ctx
, v
->value_int_4
);
2748 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(pname=%s)", func
,
2749 _mesa_enum_to_string(pname
));
2750 return TYPE_INVALID
;
2752 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(pname=%s)", func
,
2753 _mesa_enum_to_string(pname
));
2754 return TYPE_INVALID
;
2758 _mesa_GetBooleani_v( GLenum pname
, GLuint index
, GLboolean
*params
)
2761 enum value_type type
=
2762 find_value_indexed("glGetBooleani_v", pname
, index
, &v
);
2767 params
[0] = INT_TO_BOOLEAN(v
.value_int
);
2771 params
[0] = INT_TO_BOOLEAN(v
.value_int_4
[0]);
2772 params
[1] = INT_TO_BOOLEAN(v
.value_int_4
[1]);
2773 params
[2] = INT_TO_BOOLEAN(v
.value_int_4
[2]);
2774 params
[3] = INT_TO_BOOLEAN(v
.value_int_4
[3]);
2777 params
[0] = INT64_TO_BOOLEAN(v
.value_int64
);
2780 ; /* nothing - GL error was recorded */
2785 _mesa_GetIntegeri_v( GLenum pname
, GLuint index
, GLint
*params
)
2788 enum value_type type
=
2789 find_value_indexed("glGetIntegeri_v", pname
, index
, &v
);
2794 params
[3] = IROUND(v
.value_float_4
[3]);
2797 params
[2] = IROUND(v
.value_float_4
[2]);
2800 params
[1] = IROUND(v
.value_float_4
[1]);
2803 params
[0] = IROUND(v
.value_float_4
[0]);
2806 case TYPE_DOUBLEN_2
:
2807 params
[1] = IROUND(v
.value_double_2
[1]);
2809 params
[0] = IROUND(v
.value_double_2
[0]);
2814 params
[0] = v
.value_int
;
2818 params
[0] = v
.value_int_4
[0];
2819 params
[1] = v
.value_int_4
[1];
2820 params
[2] = v
.value_int_4
[2];
2821 params
[3] = v
.value_int_4
[3];
2824 params
[0] = INT64_TO_INT(v
.value_int64
);
2827 ; /* nothing - GL error was recorded */
2832 _mesa_GetInteger64i_v( GLenum pname
, GLuint index
, GLint64
*params
)
2835 enum value_type type
=
2836 find_value_indexed("glGetInteger64i_v", pname
, index
, &v
);
2840 params
[0] = v
.value_int
;
2843 params
[0] = v
.value_int_4
[0];
2844 params
[1] = v
.value_int_4
[1];
2845 params
[2] = v
.value_int_4
[2];
2846 params
[3] = v
.value_int_4
[3];
2849 params
[0] = (GLuint
) v
.value_int
;
2852 params
[0] = (GLuint
) v
.value_int_4
[0];
2853 params
[1] = (GLuint
) v
.value_int_4
[1];
2854 params
[2] = (GLuint
) v
.value_int_4
[2];
2855 params
[3] = (GLuint
) v
.value_int_4
[3];
2858 params
[0] = v
.value_int64
;
2861 ; /* nothing - GL error was recorded */
2866 _mesa_GetFloati_v(GLenum pname
, GLuint index
, GLfloat
*params
)
2871 enum value_type type
=
2872 find_value_indexed("glGetFloati_v", pname
, index
, &v
);
2877 params
[3] = v
.value_float_4
[3];
2880 params
[2] = v
.value_float_4
[2];
2883 params
[1] = v
.value_float_4
[1];
2886 params
[0] = v
.value_float_4
[0];
2889 case TYPE_DOUBLEN_2
:
2890 params
[1] = (GLfloat
) v
.value_double_2
[1];
2892 params
[0] = (GLfloat
) v
.value_double_2
[0];
2896 params
[3] = (GLfloat
) v
.value_int_4
[3];
2898 params
[2] = (GLfloat
) v
.value_int_4
[2];
2901 params
[1] = (GLfloat
) v
.value_int_4
[1];
2905 params
[0] = (GLfloat
) v
.value_int_4
[0];
2909 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
2910 params
[i
] = (GLfloat
) v
.value_int_n
.ints
[i
];
2914 params
[3] = (GLfloat
) ((GLuint
) v
.value_int_4
[3]);
2916 params
[2] = (GLfloat
) ((GLuint
) v
.value_int_4
[2]);
2918 params
[1] = (GLfloat
) ((GLuint
) v
.value_int_4
[1]);
2920 params
[0] = (GLfloat
) ((GLuint
) v
.value_int_4
[0]);
2924 params
[0] = (GLfloat
) v
.value_int64
;
2928 params
[0] = BOOLEAN_TO_FLOAT(v
.value_bool
);
2932 params
[0] = (GLfloat
) v
.value_ubyte
;
2936 params
[0] = (GLfloat
) v
.value_short
;
2940 m
= *(GLmatrix
**) &v
;
2941 for (i
= 0; i
< 16; i
++)
2942 params
[i
] = m
->m
[i
];
2946 m
= *(GLmatrix
**) &v
;
2947 for (i
= 0; i
< 16; i
++)
2948 params
[i
] = m
->m
[transpose
[i
]];
2957 _mesa_GetDoublei_v(GLenum pname
, GLuint index
, GLdouble
*params
)
2962 enum value_type type
=
2963 find_value_indexed("glGetDoublei_v", pname
, index
, &v
);
2968 params
[3] = (GLdouble
) v
.value_float_4
[3];
2971 params
[2] = (GLdouble
) v
.value_float_4
[2];
2974 params
[1] = (GLdouble
) v
.value_float_4
[1];
2977 params
[0] = (GLdouble
) v
.value_float_4
[0];
2980 case TYPE_DOUBLEN_2
:
2981 params
[1] = v
.value_double_2
[1];
2983 params
[0] = v
.value_double_2
[0];
2987 params
[3] = (GLdouble
) v
.value_int_4
[3];
2989 params
[2] = (GLdouble
) v
.value_int_4
[2];
2992 params
[1] = (GLdouble
) v
.value_int_4
[1];
2996 params
[0] = (GLdouble
) v
.value_int_4
[0];
3000 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
3001 params
[i
] = (GLdouble
) v
.value_int_n
.ints
[i
];
3005 params
[3] = (GLdouble
) ((GLuint
) v
.value_int_4
[3]);
3007 params
[2] = (GLdouble
) ((GLuint
) v
.value_int_4
[2]);
3009 params
[1] = (GLdouble
) ((GLuint
) v
.value_int_4
[1]);
3011 params
[0] = (GLdouble
) ((GLuint
) v
.value_int_4
[0]);
3015 params
[0] = (GLdouble
) v
.value_int64
;
3019 params
[0] = (GLdouble
) BOOLEAN_TO_FLOAT(v
.value_bool
);
3023 params
[0] = (GLdouble
) v
.value_ubyte
;
3027 params
[0] = (GLdouble
) v
.value_short
;
3031 m
= *(GLmatrix
**) &v
;
3032 for (i
= 0; i
< 16; i
++)
3033 params
[i
] = (GLdouble
) m
->m
[i
];
3037 m
= *(GLmatrix
**) &v
;
3038 for (i
= 0; i
< 16; i
++)
3039 params
[i
] = (GLdouble
) m
->m
[transpose
[i
]];
3048 _mesa_GetUnsignedBytei_vEXT(GLenum target
, GLuint index
, GLubyte
*data
)
3052 enum value_type type
;
3053 const char *func
= "glGetUnsignedBytei_vEXT";
3055 GET_CURRENT_CONTEXT(ctx
);
3057 if (!ctx
->Extensions
.EXT_memory_object
) {
3058 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(unsupported)", func
);
3062 type
= find_value_indexed(func
, target
, index
, &v
);
3063 size
= get_value_size(type
, &v
);
3065 _mesa_problem(ctx
, "invalid value type in GetUnsignedBytei_vEXT()");
3094 case TYPE_DOUBLEN_2
:
3097 memcpy(data
, &v
.value_int
, size
);
3100 memcpy(data
, &v
.value_int_n
.ints
, size
);
3103 break; /* nothing - GL error was recorded */
3108 _mesa_GetFixedv(GLenum pname
, GLfixed
*params
)
3110 const struct value_desc
*d
;
3116 d
= find_value("glGetDoublev", pname
, &p
, &v
);
3121 params
[0] = INT_TO_FIXED(d
->offset
);
3126 params
[3] = FLOAT_TO_FIXED(((GLfloat
*) p
)[3]);
3129 params
[2] = FLOAT_TO_FIXED(((GLfloat
*) p
)[2]);
3132 params
[1] = FLOAT_TO_FIXED(((GLfloat
*) p
)[1]);
3135 params
[0] = FLOAT_TO_FIXED(((GLfloat
*) p
)[0]);
3138 case TYPE_DOUBLEN_2
:
3139 params
[1] = FLOAT_TO_FIXED(((GLdouble
*) p
)[1]);
3141 params
[0] = FLOAT_TO_FIXED(((GLdouble
*) p
)[0]);
3146 params
[3] = INT_TO_FIXED(((GLint
*) p
)[3]);
3149 params
[2] = INT_TO_FIXED(((GLint
*) p
)[2]);
3153 params
[1] = INT_TO_FIXED(((GLint
*) p
)[1]);
3157 params
[0] = INT_TO_FIXED(((GLint
*) p
)[0]);
3161 params
[0] = INT_TO_FIXED((GLint
)(((GLenum16
*) p
)[0]));
3165 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
3166 params
[i
] = INT_TO_FIXED(v
.value_int_n
.ints
[i
]);
3170 params
[0] = ((GLint64
*) p
)[0];
3174 params
[0] = BOOLEAN_TO_FIXED(((GLboolean
*) p
)[0]);
3178 params
[0] = INT_TO_FIXED(((GLubyte
*) p
)[0]);
3182 params
[0] = INT_TO_FIXED(((GLshort
*) p
)[0]);
3186 m
= *(GLmatrix
**) p
;
3187 for (i
= 0; i
< 16; i
++)
3188 params
[i
] = FLOAT_TO_FIXED(m
->m
[i
]);
3192 m
= *(GLmatrix
**) p
;
3193 for (i
= 0; i
< 16; i
++)
3194 params
[i
] = FLOAT_TO_FIXED(m
->m
[transpose
[i
]]);
3205 shift
= d
->type
- TYPE_BIT_0
;
3206 params
[0] = BOOLEAN_TO_FIXED((*(GLbitfield
*) p
>> shift
) & 1);