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 static inline GLboolean
73 FLOAT_TO_BOOLEAN(GLfloat X
)
75 return ( (X
) ? GL_TRUE
: GL_FALSE
);
79 FLOAT_TO_FIXED(GLfloat F
)
81 return ( ((F
) * 65536.0f
> INT_MAX
) ? INT_MAX
:
82 ((F
) * 65536.0f
< INT_MIN
) ? INT_MIN
:
83 (GLint
) ((F
) * 65536.0f
) );
86 static inline GLboolean
87 INT_TO_BOOLEAN(GLint I
)
89 return ( (I
) ? GL_TRUE
: GL_FALSE
);
95 return (((I
) > SHRT_MAX
) ? INT_MAX
:
96 ((I
) < SHRT_MIN
) ? INT_MIN
:
97 (GLint
) ((I
) * 65536) );
101 static inline GLboolean
102 INT64_TO_BOOLEAN(GLint64 I
)
104 return ( (I
) ? GL_TRUE
: GL_FALSE
);
108 INT64_TO_INT(GLint64 I
)
110 return ( (GLint
)((I
> INT_MAX
) ? INT_MAX
: ((I
< INT_MIN
) ? INT_MIN
: (I
))) );
114 BOOLEAN_TO_INT(GLboolean B
)
116 return ( (GLint
) (B
) );
119 static inline GLfloat
120 BOOLEAN_TO_FLOAT(GLboolean B
)
122 return ( (B
) ? 1.0F
: 0.0F
);
125 static inline GLfixed
126 BOOLEAN_TO_FIXED(GLboolean B
)
128 return ( (GLint
) ((B
) ? 1 : 0) << 16 );
173 enum value_location
{
195 EXTRA_NEW_FRAG_CLAMP
,
196 EXTRA_VALID_DRAW_BUFFER
,
197 EXTRA_VALID_TEXTURE_UNIT
,
198 EXTRA_VALID_CLIP_DISTANCE
,
202 EXTRA_EXT_ATOMICS_GS
,
203 EXTRA_EXT_SHADER_IMAGE_GS
,
204 EXTRA_EXT_ATOMICS_TESS
,
205 EXTRA_EXT_SHADER_IMAGE_TESS
,
207 EXTRA_EXT_FB_NO_ATTACH_GS
,
209 EXTRA_EXT_PROVOKING_VERTEX_32
,
212 #define NO_EXTRA NULL
217 GLubyte location
; /**< enum value_location */
218 GLubyte type
; /**< enum value_type */
225 GLfloat value_float_4
[4];
226 GLdouble value_double_2
[2];
227 GLmatrix
*value_matrix
;
229 GLint value_int_4
[4];
236 /* Sigh, see GL_COMPRESSED_TEXTURE_FORMATS_ARB handling */
240 GLboolean value_bool
;
243 #define BUFFER_FIELD(field, type) \
244 LOC_BUFFER, type, offsetof(struct gl_framebuffer, field)
245 #define CONTEXT_FIELD(field, type) \
246 LOC_CONTEXT, type, offsetof(struct gl_context, field)
247 #define ARRAY_FIELD(field, type) \
248 LOC_ARRAY, type, offsetof(struct gl_vertex_array_object, field)
249 #undef CONST /* already defined through windows.h */
250 #define CONST(value) \
251 LOC_CONTEXT, TYPE_CONST, value
253 #define BUFFER_INT(field) BUFFER_FIELD(field, TYPE_INT)
254 #define BUFFER_ENUM(field) BUFFER_FIELD(field, TYPE_ENUM)
255 #define BUFFER_ENUM16(field) BUFFER_FIELD(field, TYPE_ENUM16)
256 #define BUFFER_BOOL(field) BUFFER_FIELD(field, TYPE_BOOLEAN)
258 #define CONTEXT_INT(field) CONTEXT_FIELD(field, TYPE_INT)
259 #define CONTEXT_INT2(field) CONTEXT_FIELD(field, TYPE_INT_2)
260 #define CONTEXT_INT64(field) CONTEXT_FIELD(field, TYPE_INT64)
261 #define CONTEXT_UINT(field) CONTEXT_FIELD(field, TYPE_UINT)
262 #define CONTEXT_ENUM16(field) CONTEXT_FIELD(field, TYPE_ENUM16)
263 #define CONTEXT_ENUM(field) CONTEXT_FIELD(field, TYPE_ENUM)
264 #define CONTEXT_ENUM2(field) CONTEXT_FIELD(field, TYPE_ENUM_2)
265 #define CONTEXT_BOOL(field) CONTEXT_FIELD(field, TYPE_BOOLEAN)
266 #define CONTEXT_BIT0(field) CONTEXT_FIELD(field, TYPE_BIT_0)
267 #define CONTEXT_BIT1(field) CONTEXT_FIELD(field, TYPE_BIT_1)
268 #define CONTEXT_BIT2(field) CONTEXT_FIELD(field, TYPE_BIT_2)
269 #define CONTEXT_BIT3(field) CONTEXT_FIELD(field, TYPE_BIT_3)
270 #define CONTEXT_BIT4(field) CONTEXT_FIELD(field, TYPE_BIT_4)
271 #define CONTEXT_BIT5(field) CONTEXT_FIELD(field, TYPE_BIT_5)
272 #define CONTEXT_BIT6(field) CONTEXT_FIELD(field, TYPE_BIT_6)
273 #define CONTEXT_BIT7(field) CONTEXT_FIELD(field, TYPE_BIT_7)
274 #define CONTEXT_FLOAT(field) CONTEXT_FIELD(field, TYPE_FLOAT)
275 #define CONTEXT_FLOAT2(field) CONTEXT_FIELD(field, TYPE_FLOAT_2)
276 #define CONTEXT_FLOAT3(field) CONTEXT_FIELD(field, TYPE_FLOAT_3)
277 #define CONTEXT_FLOAT4(field) CONTEXT_FIELD(field, TYPE_FLOAT_4)
278 #define CONTEXT_FLOAT8(field) CONTEXT_FIELD(field, TYPE_FLOAT_8)
279 #define CONTEXT_MATRIX(field) CONTEXT_FIELD(field, TYPE_MATRIX)
280 #define CONTEXT_MATRIX_T(field) CONTEXT_FIELD(field, TYPE_MATRIX_T)
282 /* Vertex array fields */
283 #define ARRAY_INT(field) ARRAY_FIELD(field, TYPE_INT)
284 #define ARRAY_ENUM(field) ARRAY_FIELD(field, TYPE_ENUM)
285 #define ARRAY_ENUM16(field) ARRAY_FIELD(field, TYPE_ENUM16)
286 #define ARRAY_BOOL(field) ARRAY_FIELD(field, TYPE_BOOLEAN)
287 #define ARRAY_UBYTE(field) ARRAY_FIELD(field, TYPE_UBYTE)
288 #define ARRAY_SHORT(field) ARRAY_FIELD(field, TYPE_SHORT)
291 offsetof(struct gl_extensions, f)
293 #define EXTRA_EXT(e) \
294 static const int extra_##e[] = { \
298 #define EXTRA_EXT2(e1, e2) \
299 static const int extra_##e1##_##e2[] = { \
300 EXT(e1), EXT(e2), EXTRA_END \
303 /* The 'extra' mechanism is a way to specify extra checks (such as
304 * extensions or specific gl versions) or actions (flush current, new
305 * buffers) that we need to do before looking up an enum. We need to
306 * declare them all up front so we can refer to them in the value_desc
309 * Each EXTRA_ will be executed. For EXTRA_* enums of extensions and API
310 * versions, listing multiple ones in an array means an error will be thrown
311 * only if none of them are available. If you need to check for "AND"
312 * behavior, you would need to make a custom EXTRA_ enum.
315 static const int extra_new_buffers
[] = {
320 static const int extra_new_frag_clamp
[] = {
321 EXTRA_NEW_FRAG_CLAMP
,
325 static const int extra_valid_draw_buffer
[] = {
326 EXTRA_VALID_DRAW_BUFFER
,
330 static const int extra_valid_texture_unit
[] = {
331 EXTRA_VALID_TEXTURE_UNIT
,
335 static const int extra_valid_clip_distance
[] = {
336 EXTRA_VALID_CLIP_DISTANCE
,
340 static const int extra_flush_current_valid_texture_unit
[] = {
342 EXTRA_VALID_TEXTURE_UNIT
,
346 static const int extra_flush_current
[] = {
351 static const int extra_EXT_texture_integer_and_new_buffers
[] = {
352 EXT(EXT_texture_integer
),
357 static const int extra_GLSL_130_es3_gpushader4
[] = {
360 EXT(EXT_gpu_shader4
),
364 static const int extra_texture_buffer_object
[] = {
365 EXT(ARB_texture_buffer_object
),
369 static const int extra_ARB_transform_feedback2_api_es3
[] = {
370 EXT(ARB_transform_feedback2
),
375 static const int extra_ARB_uniform_buffer_object_and_geometry_shader
[] = {
380 static const int extra_ARB_ES2_compatibility_api_es2
[] = {
381 EXT(ARB_ES2_compatibility
),
386 static const int extra_ARB_ES3_compatibility_api_es3
[] = {
387 EXT(ARB_ES3_compatibility
),
392 static const int extra_EXT_framebuffer_sRGB_and_new_buffers
[] = {
393 EXT(EXT_framebuffer_sRGB
),
398 static const int extra_EXT_packed_float
[] = {
399 EXT(EXT_packed_float
),
404 static const int extra_EXT_texture_array_es3
[] = {
405 EXT(EXT_texture_array
),
410 static const int extra_ARB_shader_atomic_counters_and_geometry_shader
[] = {
411 EXTRA_EXT_ATOMICS_GS
,
415 static const int extra_ARB_shader_image_load_store_and_geometry_shader
[] = {
416 EXTRA_EXT_SHADER_IMAGE_GS
,
420 static const int extra_ARB_shader_atomic_counters_and_tessellation
[] = {
421 EXTRA_EXT_ATOMICS_TESS
,
425 static const int extra_ARB_shader_image_load_store_and_tessellation
[] = {
426 EXTRA_EXT_SHADER_IMAGE_TESS
,
430 /* HACK: remove when ARB_compute_shader is actually supported */
431 static const int extra_ARB_compute_shader_es31
[] = {
432 EXT(ARB_compute_shader
),
437 static const int extra_ARB_shader_storage_buffer_object_es31
[] = {
438 EXT(ARB_shader_storage_buffer_object
),
443 static const int extra_ARB_shader_storage_buffer_object_and_geometry_shader
[] = {
448 static const int extra_ARB_shader_image_load_store_shader_storage_buffer_object_es31
[] = {
449 EXT(ARB_shader_image_load_store
),
450 EXT(ARB_shader_storage_buffer_object
),
455 static const int extra_ARB_framebuffer_no_attachments_and_geometry_shader
[] = {
456 EXTRA_EXT_FB_NO_ATTACH_GS
,
460 static const int extra_ARB_viewport_array_or_oes_geometry_shader
[] = {
461 EXT(ARB_viewport_array
),
466 static const int extra_ARB_viewport_array_or_oes_viewport_array
[] = {
467 EXT(ARB_viewport_array
),
468 EXT(OES_viewport_array
),
472 static const int extra_ARB_gpu_shader5_or_oes_geometry_shader
[] = {
473 EXT(ARB_gpu_shader5
),
478 static const int extra_ARB_gpu_shader5_or_OES_sample_variables
[] = {
479 EXT(ARB_gpu_shader5
),
480 EXT(OES_sample_variables
),
484 static const int extra_ES32
[] = {
485 EXT(ARB_ES3_2_compatibility
),
490 static const int extra_KHR_robustness_or_GL
[] = {
497 static const int extra_INTEL_conservative_rasterization
[] = {
498 EXT(INTEL_conservative_rasterization
),
502 EXTRA_EXT(ARB_texture_cube_map
);
503 EXTRA_EXT(EXT_texture_array
);
504 EXTRA_EXT(NV_fog_distance
);
505 EXTRA_EXT(EXT_texture_filter_anisotropic
);
506 EXTRA_EXT(NV_point_sprite
);
507 EXTRA_EXT(NV_texture_rectangle
);
508 EXTRA_EXT(EXT_stencil_two_side
);
509 EXTRA_EXT(EXT_depth_bounds_test
);
510 EXTRA_EXT(ARB_depth_clamp
);
511 EXTRA_EXT(AMD_depth_clamp_separate
);
512 EXTRA_EXT(ATI_fragment_shader
);
513 EXTRA_EXT(EXT_provoking_vertex
);
514 EXTRA_EXT(ARB_fragment_shader
);
515 EXTRA_EXT(ARB_fragment_program
);
516 EXTRA_EXT2(ARB_framebuffer_object
, EXT_framebuffer_multisample
);
517 EXTRA_EXT(ARB_seamless_cube_map
);
519 EXTRA_EXT(ARB_vertex_shader
);
520 EXTRA_EXT(EXT_transform_feedback
);
521 EXTRA_EXT(ARB_transform_feedback3
);
522 EXTRA_EXT(EXT_pixel_buffer_object
);
523 EXTRA_EXT(ARB_vertex_program
);
524 EXTRA_EXT2(NV_point_sprite
, ARB_point_sprite
);
525 EXTRA_EXT2(ARB_vertex_program
, ARB_fragment_program
);
526 EXTRA_EXT(ARB_color_buffer_float
);
527 EXTRA_EXT(EXT_framebuffer_sRGB
);
528 EXTRA_EXT(OES_EGL_image_external
);
529 EXTRA_EXT(ARB_blend_func_extended
);
530 EXTRA_EXT(ARB_uniform_buffer_object
);
531 EXTRA_EXT(ARB_timer_query
);
532 EXTRA_EXT2(ARB_texture_cube_map_array
, OES_texture_cube_map_array
);
533 EXTRA_EXT(ARB_texture_buffer_range
);
534 EXTRA_EXT(ARB_texture_multisample
);
535 EXTRA_EXT(ARB_texture_gather
);
536 EXTRA_EXT(ARB_shader_atomic_counters
);
537 EXTRA_EXT(ARB_draw_indirect
);
538 EXTRA_EXT(ARB_shader_image_load_store
);
539 EXTRA_EXT(ARB_query_buffer_object
);
540 EXTRA_EXT2(ARB_transform_feedback3
, ARB_gpu_shader5
);
541 EXTRA_EXT(INTEL_performance_query
);
542 EXTRA_EXT(ARB_explicit_uniform_location
);
543 EXTRA_EXT(ARB_clip_control
);
544 EXTRA_EXT(ARB_polygon_offset_clamp
);
545 EXTRA_EXT(ARB_framebuffer_no_attachments
);
546 EXTRA_EXT(ARB_tessellation_shader
);
547 EXTRA_EXT(ARB_shader_storage_buffer_object
);
548 EXTRA_EXT(ARB_indirect_parameters
);
549 EXTRA_EXT(ATI_meminfo
);
550 EXTRA_EXT(NVX_gpu_memory_info
);
551 EXTRA_EXT(ARB_cull_distance
);
552 EXTRA_EXT(EXT_window_rectangles
);
553 EXTRA_EXT(KHR_blend_equation_advanced_coherent
);
554 EXTRA_EXT(OES_primitive_bounding_box
);
555 EXTRA_EXT(ARB_compute_variable_group_size
);
556 EXTRA_EXT(KHR_robustness
);
557 EXTRA_EXT(ARB_sparse_buffer
);
558 EXTRA_EXT(NV_conservative_raster
);
559 EXTRA_EXT(NV_conservative_raster_dilate
);
560 EXTRA_EXT(NV_conservative_raster_pre_snap_triangles
);
561 EXTRA_EXT(ARB_sample_locations
);
562 EXTRA_EXT(AMD_framebuffer_multisample_advanced
);
563 EXTRA_EXT(ARB_spirv_extensions
);
564 EXTRA_EXT(NV_viewport_swizzle
);
567 extra_ARB_color_buffer_float_or_glcore
[] = {
568 EXT(ARB_color_buffer_float
),
574 extra_NV_primitive_restart
[] = {
575 EXT(NV_primitive_restart
),
579 static const int extra_version_30
[] = { EXTRA_VERSION_30
, EXTRA_END
};
580 static const int extra_version_31
[] = { EXTRA_VERSION_31
, EXTRA_END
};
581 static const int extra_version_32
[] = { EXTRA_VERSION_32
, EXTRA_END
};
582 static const int extra_version_43
[] = { EXTRA_VERSION_43
, EXTRA_END
};
584 static const int extra_gl30_es3
[] = {
590 static const int extra_gl32_es3
[] = {
596 static const int extra_version_32_OES_geometry_shader
[] = {
602 static const int extra_gl40_ARB_sample_shading
[] = {
604 EXT(ARB_sample_shading
),
609 extra_ARB_vertex_program_api_es2
[] = {
610 EXT(ARB_vertex_program
),
615 /* The ReadBuffer get token is valid under either full GL or under
616 * GLES2 if the NV_read_buffer extension is available. */
618 extra_NV_read_buffer_api_gl
[] = {
624 static const int extra_core_ARB_color_buffer_float_and_new_buffers
[] = {
626 EXT(ARB_color_buffer_float
),
631 static const int extra_EXT_shader_framebuffer_fetch
[] = {
634 EXT(EXT_shader_framebuffer_fetch
),
638 static const int extra_EXT_provoking_vertex_32
[] = {
639 EXTRA_EXT_PROVOKING_VERTEX_32
,
643 static const int extra_EXT_disjoint_timer_query
[] = {
646 EXT(EXT_disjoint_timer_query
),
651 /* This is the big table describing all the enums we accept in
652 * glGet*v(). The table is partitioned into six parts: enums
653 * understood by all GL APIs (OpenGL, GLES and GLES2), enums shared
654 * between OpenGL and GLES, enums exclusive to GLES, etc for the
655 * remaining combinations. To look up the enums valid in a given API
656 * we will use a hash table specific to that API. These tables are in
657 * turn generated at build time and included through get_hash.h.
660 #include "get_hash.h"
662 /* All we need now is a way to look up the value struct from the enum.
663 * The code generated by gcc for the old generated big switch
664 * statement is a big, balanced, open coded if/else tree, essentially
665 * an unrolled binary search. It would be natural to sort the new
666 * enum table and use bsearch(), but we will use a read-only hash
667 * table instead. bsearch() has a nice guaranteed worst case
668 * performance, but we're also guaranteed to hit that worst case
669 * (log2(n) iterations) for about half the enums. Instead, using an
670 * open addressing hash table, we can find the enum on the first try
671 * for 80% of the enums, 1 collision for 10% and never more than 5
672 * collisions for any enum (typical numbers). And the code is very
673 * simple, even though it feels a little magic. */
676 * Handle irregular enums
678 * Some values don't conform to the "well-known type at context
679 * pointer + offset" pattern, so we have this function to catch all
680 * the corner cases. Typically, it's a computed value or a one-off
681 * pointer to a custom struct or something.
683 * In this case we can't return a pointer to the value, so we'll have
684 * to use the temporary variable 'v' declared back in the calling
685 * glGet*v() function to store the result.
687 * \param ctx the current context
688 * \param d the struct value_desc that describes the enum
689 * \param v pointer to the tmp declared in the calling glGet*v() function
692 find_custom_value(struct gl_context
*ctx
, const struct value_desc
*d
, union value
*v
)
694 struct gl_buffer_object
**buffer_obj
, *buf
;
695 struct gl_array_attributes
*array
;
699 case GL_MAJOR_VERSION
:
700 v
->value_int
= ctx
->Version
/ 10;
702 case GL_MINOR_VERSION
:
703 v
->value_int
= ctx
->Version
% 10;
709 case GL_TEXTURE_CUBE_MAP
:
710 case GL_TEXTURE_RECTANGLE_NV
:
711 case GL_TEXTURE_EXTERNAL_OES
:
712 v
->value_bool
= _mesa_IsEnabled(d
->pname
);
715 case GL_LINE_STIPPLE_PATTERN
:
716 /* This is the only GLushort, special case it here by promoting
717 * to an int rather than introducing a new type. */
718 v
->value_int
= ctx
->Line
.StipplePattern
;
721 case GL_CURRENT_RASTER_TEXTURE_COORDS
:
722 unit
= ctx
->Texture
.CurrentUnit
;
723 v
->value_float_4
[0] = ctx
->Current
.RasterTexCoords
[unit
][0];
724 v
->value_float_4
[1] = ctx
->Current
.RasterTexCoords
[unit
][1];
725 v
->value_float_4
[2] = ctx
->Current
.RasterTexCoords
[unit
][2];
726 v
->value_float_4
[3] = ctx
->Current
.RasterTexCoords
[unit
][3];
729 case GL_CURRENT_TEXTURE_COORDS
:
730 unit
= ctx
->Texture
.CurrentUnit
;
731 v
->value_float_4
[0] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
][0];
732 v
->value_float_4
[1] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
][1];
733 v
->value_float_4
[2] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
][2];
734 v
->value_float_4
[3] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
][3];
737 case GL_COLOR_WRITEMASK
:
738 v
->value_int_4
[0] = GET_COLORMASK_BIT(ctx
->Color
.ColorMask
, 0, 0);
739 v
->value_int_4
[1] = GET_COLORMASK_BIT(ctx
->Color
.ColorMask
, 0, 1);
740 v
->value_int_4
[2] = GET_COLORMASK_BIT(ctx
->Color
.ColorMask
, 0, 2);
741 v
->value_int_4
[3] = GET_COLORMASK_BIT(ctx
->Color
.ColorMask
, 0, 3);
745 v
->value_bool
= ctx
->Transform
.DepthClampNear
|| ctx
->Transform
.DepthClampFar
;
749 v
->value_bool
= ctx
->Current
.Attrib
[VERT_ATTRIB_EDGEFLAG
][0] == 1.0F
;
753 v
->value_enum
= ctx
->ReadBuffer
->ColorReadBuffer
;
756 case GL_MAP2_GRID_DOMAIN
:
757 v
->value_float_4
[0] = ctx
->Eval
.MapGrid2u1
;
758 v
->value_float_4
[1] = ctx
->Eval
.MapGrid2u2
;
759 v
->value_float_4
[2] = ctx
->Eval
.MapGrid2v1
;
760 v
->value_float_4
[3] = ctx
->Eval
.MapGrid2v2
;
763 case GL_TEXTURE_STACK_DEPTH
:
764 unit
= ctx
->Texture
.CurrentUnit
;
765 v
->value_int
= ctx
->TextureMatrixStack
[unit
].Depth
+ 1;
767 case GL_TEXTURE_MATRIX
:
768 unit
= ctx
->Texture
.CurrentUnit
;
769 v
->value_matrix
= ctx
->TextureMatrixStack
[unit
].Top
;
772 case GL_VERTEX_ARRAY
:
773 v
->value_bool
= !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_POS
);
775 case GL_NORMAL_ARRAY
:
776 v
->value_bool
= !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_NORMAL
);
779 v
->value_bool
= !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_COLOR0
);
781 case GL_TEXTURE_COORD_ARRAY
:
782 v
->value_bool
= !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_TEX(ctx
->Array
.ActiveTexture
));
785 v
->value_bool
= !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_COLOR_INDEX
);
787 case GL_EDGE_FLAG_ARRAY
:
788 v
->value_bool
= !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_EDGEFLAG
);
790 case GL_SECONDARY_COLOR_ARRAY
:
791 v
->value_bool
= !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_COLOR1
);
793 case GL_FOG_COORDINATE_ARRAY
:
794 v
->value_bool
= !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_FOG
);
796 case GL_POINT_SIZE_ARRAY_OES
:
797 v
->value_bool
= !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_POINT_SIZE
);
800 case GL_TEXTURE_COORD_ARRAY_TYPE
:
801 case GL_TEXTURE_COORD_ARRAY_STRIDE
:
802 array
= &ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_TEX(ctx
->Array
.ActiveTexture
)];
803 v
->value_int
= *(GLuint
*) ((char *) array
+ d
->offset
);
806 case GL_TEXTURE_COORD_ARRAY_SIZE
:
807 array
= &ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_TEX(ctx
->Array
.ActiveTexture
)];
808 v
->value_int
= array
->Format
.Size
;
811 case GL_VERTEX_ARRAY_SIZE
:
812 array
= &ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_POS
];
813 v
->value_int
= array
->Format
.Size
;
816 case GL_ACTIVE_TEXTURE_ARB
:
817 v
->value_int
= GL_TEXTURE0_ARB
+ ctx
->Texture
.CurrentUnit
;
819 case GL_CLIENT_ACTIVE_TEXTURE_ARB
:
820 v
->value_int
= GL_TEXTURE0_ARB
+ ctx
->Array
.ActiveTexture
;
823 case GL_MODELVIEW_STACK_DEPTH
:
824 case GL_PROJECTION_STACK_DEPTH
:
825 v
->value_int
= *(GLint
*) ((char *) ctx
+ d
->offset
) + 1;
828 case GL_MAX_TEXTURE_SIZE
:
829 case GL_MAX_3D_TEXTURE_SIZE
:
830 case GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB
:
831 p
= (GLuint
*) ((char *) ctx
+ d
->offset
);
832 v
->value_int
= 1 << (*p
- 1);
836 v
->value_int_4
[0] = ctx
->Scissor
.ScissorArray
[0].X
;
837 v
->value_int_4
[1] = ctx
->Scissor
.ScissorArray
[0].Y
;
838 v
->value_int_4
[2] = ctx
->Scissor
.ScissorArray
[0].Width
;
839 v
->value_int_4
[3] = ctx
->Scissor
.ScissorArray
[0].Height
;
842 case GL_SCISSOR_TEST
:
843 v
->value_bool
= ctx
->Scissor
.EnableFlags
& 1;
848 ctx
->ListState
.CurrentList
? ctx
->ListState
.CurrentList
->Name
: 0;
851 if (!ctx
->CompileFlag
)
853 else if (ctx
->ExecuteFlag
)
854 v
->value_enum
= GL_COMPILE_AND_EXECUTE
;
856 v
->value_enum
= GL_COMPILE
;
860 v
->value_float_4
[0] = ctx
->ViewportArray
[0].X
;
861 v
->value_float_4
[1] = ctx
->ViewportArray
[0].Y
;
862 v
->value_float_4
[2] = ctx
->ViewportArray
[0].Width
;
863 v
->value_float_4
[3] = ctx
->ViewportArray
[0].Height
;
867 v
->value_double_2
[0] = ctx
->ViewportArray
[0].Near
;
868 v
->value_double_2
[1] = ctx
->ViewportArray
[0].Far
;
871 case GL_ACTIVE_STENCIL_FACE_EXT
:
872 v
->value_enum
= ctx
->Stencil
.ActiveFace
? GL_BACK
: GL_FRONT
;
875 case GL_STENCIL_FAIL
:
876 v
->value_enum
= ctx
->Stencil
.FailFunc
[ctx
->Stencil
.ActiveFace
];
878 case GL_STENCIL_FUNC
:
879 v
->value_enum
= ctx
->Stencil
.Function
[ctx
->Stencil
.ActiveFace
];
881 case GL_STENCIL_PASS_DEPTH_FAIL
:
882 v
->value_enum
= ctx
->Stencil
.ZFailFunc
[ctx
->Stencil
.ActiveFace
];
884 case GL_STENCIL_PASS_DEPTH_PASS
:
885 v
->value_enum
= ctx
->Stencil
.ZPassFunc
[ctx
->Stencil
.ActiveFace
];
888 v
->value_int
= _mesa_get_stencil_ref(ctx
, ctx
->Stencil
.ActiveFace
);
890 case GL_STENCIL_BACK_REF
:
891 v
->value_int
= _mesa_get_stencil_ref(ctx
, 1);
893 case GL_STENCIL_VALUE_MASK
:
894 v
->value_int
= ctx
->Stencil
.ValueMask
[ctx
->Stencil
.ActiveFace
];
896 case GL_STENCIL_WRITEMASK
:
897 v
->value_int
= ctx
->Stencil
.WriteMask
[ctx
->Stencil
.ActiveFace
];
900 case GL_NUM_EXTENSIONS
:
901 v
->value_int
= _mesa_get_extension_count(ctx
);
904 case GL_IMPLEMENTATION_COLOR_READ_TYPE_OES
:
905 v
->value_int
= _mesa_get_color_read_type(ctx
, NULL
, "glGetIntegerv");
907 case GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES
:
908 v
->value_int
= _mesa_get_color_read_format(ctx
, NULL
, "glGetIntegerv");
911 case GL_CURRENT_MATRIX_STACK_DEPTH_ARB
:
912 v
->value_int
= ctx
->CurrentStack
->Depth
+ 1;
914 case GL_CURRENT_MATRIX_ARB
:
915 case GL_TRANSPOSE_CURRENT_MATRIX_ARB
:
916 v
->value_matrix
= ctx
->CurrentStack
->Top
;
919 case GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB
:
920 v
->value_int
= _mesa_get_compressed_formats(ctx
, NULL
);
922 case GL_COMPRESSED_TEXTURE_FORMATS_ARB
:
924 _mesa_get_compressed_formats(ctx
, v
->value_int_n
.ints
);
925 assert(v
->value_int_n
.n
<= (int) ARRAY_SIZE(v
->value_int_n
.ints
));
928 case GL_MAX_VARYING_FLOATS_ARB
:
929 v
->value_int
= ctx
->Const
.MaxVarying
* 4;
932 /* Various object names */
934 case GL_TEXTURE_BINDING_1D
:
935 case GL_TEXTURE_BINDING_2D
:
936 case GL_TEXTURE_BINDING_3D
:
937 case GL_TEXTURE_BINDING_1D_ARRAY_EXT
:
938 case GL_TEXTURE_BINDING_2D_ARRAY_EXT
:
939 case GL_TEXTURE_BINDING_CUBE_MAP_ARB
:
940 case GL_TEXTURE_BINDING_RECTANGLE_NV
:
941 case GL_TEXTURE_BINDING_EXTERNAL_OES
:
942 case GL_TEXTURE_BINDING_CUBE_MAP_ARRAY
:
943 case GL_TEXTURE_BINDING_2D_MULTISAMPLE
:
944 case GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY
:
945 unit
= ctx
->Texture
.CurrentUnit
;
947 ctx
->Texture
.Unit
[unit
].CurrentTex
[d
->offset
]->Name
;
950 /* GL_EXT_external_objects */
951 case GL_NUM_DEVICE_UUIDS_EXT
:
954 case GL_DRIVER_UUID_EXT
:
955 _mesa_get_driver_uuid(ctx
, v
->value_int_4
);
957 case GL_DEVICE_UUID_EXT
:
958 _mesa_get_device_uuid(ctx
, v
->value_int_4
);
961 /* GL_EXT_packed_float */
962 case GL_RGBA_SIGNED_COMPONENTS_EXT
:
964 /* Note: we only check the 0th color attachment. */
965 const struct gl_renderbuffer
*rb
=
966 ctx
->DrawBuffer
->_ColorDrawBuffers
[0];
967 if (rb
&& _mesa_is_format_signed(rb
->Format
)) {
968 /* Issue 17 of GL_EXT_packed_float: If a component (such as
969 * alpha) has zero bits, the component should not be considered
970 * signed and so the bit for the respective component should be
974 _mesa_get_format_bits(rb
->Format
, GL_RED_BITS
);
976 _mesa_get_format_bits(rb
->Format
, GL_GREEN_BITS
);
978 _mesa_get_format_bits(rb
->Format
, GL_BLUE_BITS
);
980 _mesa_get_format_bits(rb
->Format
, GL_ALPHA_BITS
);
982 _mesa_get_format_bits(rb
->Format
, GL_TEXTURE_LUMINANCE_SIZE
);
984 _mesa_get_format_bits(rb
->Format
, GL_TEXTURE_INTENSITY_SIZE
);
986 v
->value_int_4
[0] = r_bits
+ l_bits
+ i_bits
> 0;
987 v
->value_int_4
[1] = g_bits
+ l_bits
+ i_bits
> 0;
988 v
->value_int_4
[2] = b_bits
+ l_bits
+ i_bits
> 0;
989 v
->value_int_4
[3] = a_bits
+ i_bits
> 0;
995 v
->value_int_4
[3] = 0;
1000 /* GL_ARB_vertex_buffer_object */
1001 case GL_VERTEX_ARRAY_BUFFER_BINDING_ARB
:
1002 case GL_NORMAL_ARRAY_BUFFER_BINDING_ARB
:
1003 case GL_COLOR_ARRAY_BUFFER_BINDING_ARB
:
1004 case GL_INDEX_ARRAY_BUFFER_BINDING_ARB
:
1005 case GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB
:
1006 case GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB
:
1007 case GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB
:
1008 buffer_obj
= (struct gl_buffer_object
**)
1009 ((char *) ctx
->Array
.VAO
+ d
->offset
);
1010 v
->value_int
= (*buffer_obj
) ? (*buffer_obj
)->Name
: 0;
1012 case GL_ARRAY_BUFFER_BINDING_ARB
:
1013 buf
= ctx
->Array
.ArrayBufferObj
;
1014 v
->value_int
= buf
? buf
->Name
: 0;
1016 case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB
:
1017 buf
= ctx
->Array
.VAO
->BufferBinding
[VERT_ATTRIB_TEX(ctx
->Array
.ActiveTexture
)].BufferObj
;
1018 v
->value_int
= buf
? buf
->Name
: 0;
1020 case GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB
:
1021 buf
= ctx
->Array
.VAO
->IndexBufferObj
;
1022 v
->value_int
= buf
? buf
->Name
: 0;
1025 /* ARB_vertex_array_bgra */
1026 case GL_COLOR_ARRAY_SIZE
:
1027 array
= &ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_COLOR0
];
1028 v
->value_int
= array
->Format
.Format
== GL_BGRA
? GL_BGRA
: array
->Format
.Size
;
1030 case GL_SECONDARY_COLOR_ARRAY_SIZE
:
1031 array
= &ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_COLOR1
];
1032 v
->value_int
= array
->Format
.Format
== GL_BGRA
? GL_BGRA
: array
->Format
.Size
;
1035 /* ARB_copy_buffer */
1036 case GL_COPY_READ_BUFFER
:
1037 v
->value_int
= ctx
->CopyReadBuffer
? ctx
->CopyReadBuffer
->Name
: 0;
1039 case GL_COPY_WRITE_BUFFER
:
1040 v
->value_int
= ctx
->CopyWriteBuffer
? ctx
->CopyWriteBuffer
->Name
: 0;
1043 case GL_PIXEL_PACK_BUFFER_BINDING_EXT
:
1044 v
->value_int
= ctx
->Pack
.BufferObj
? ctx
->Pack
.BufferObj
->Name
: 0;
1046 case GL_PIXEL_UNPACK_BUFFER_BINDING_EXT
:
1047 v
->value_int
= ctx
->Unpack
.BufferObj
? ctx
->Unpack
.BufferObj
->Name
: 0;
1049 case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING
:
1050 v
->value_int
= ctx
->TransformFeedback
.CurrentBuffer
?
1051 ctx
->TransformFeedback
.CurrentBuffer
->Name
: 0;
1053 case GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED
:
1054 v
->value_int
= ctx
->TransformFeedback
.CurrentObject
->Paused
;
1056 case GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE
:
1057 v
->value_int
= ctx
->TransformFeedback
.CurrentObject
->Active
;
1059 case GL_TRANSFORM_FEEDBACK_BINDING
:
1060 v
->value_int
= ctx
->TransformFeedback
.CurrentObject
->Name
;
1062 case GL_CURRENT_PROGRAM
:
1063 /* The Changelog of the ARB_separate_shader_objects spec says:
1065 * 24 25 Jul 2011 pbrown Remove the language erroneously deleting
1066 * CURRENT_PROGRAM. In the EXT extension, this
1067 * token was aliased to ACTIVE_PROGRAM_EXT, and
1068 * was used to indicate the last program set by
1069 * either ActiveProgramEXT or UseProgram. In
1070 * the ARB extension, the SSO active programs
1071 * are now program pipeline object state and
1072 * CURRENT_PROGRAM should still be used to query
1073 * the last program set by UseProgram (bug 7822).
1076 ctx
->Shader
.ActiveProgram
? ctx
->Shader
.ActiveProgram
->Name
: 0;
1078 case GL_READ_FRAMEBUFFER_BINDING_EXT
:
1079 v
->value_int
= ctx
->ReadBuffer
->Name
;
1081 case GL_RENDERBUFFER_BINDING_EXT
:
1083 ctx
->CurrentRenderbuffer
? ctx
->CurrentRenderbuffer
->Name
: 0;
1085 case GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES
:
1086 buf
= ctx
->Array
.VAO
->BufferBinding
[VERT_ATTRIB_POINT_SIZE
].BufferObj
;
1087 v
->value_int
= buf
? buf
->Name
: 0;
1091 if (_mesa_get_clamp_fragment_color(ctx
, ctx
->DrawBuffer
))
1092 COPY_4FV(v
->value_float_4
, ctx
->Fog
.Color
);
1094 COPY_4FV(v
->value_float_4
, ctx
->Fog
.ColorUnclamped
);
1096 case GL_COLOR_CLEAR_VALUE
:
1097 if (_mesa_get_clamp_fragment_color(ctx
, ctx
->DrawBuffer
)) {
1098 v
->value_float_4
[0] = CLAMP(ctx
->Color
.ClearColor
.f
[0], 0.0F
, 1.0F
);
1099 v
->value_float_4
[1] = CLAMP(ctx
->Color
.ClearColor
.f
[1], 0.0F
, 1.0F
);
1100 v
->value_float_4
[2] = CLAMP(ctx
->Color
.ClearColor
.f
[2], 0.0F
, 1.0F
);
1101 v
->value_float_4
[3] = CLAMP(ctx
->Color
.ClearColor
.f
[3], 0.0F
, 1.0F
);
1103 COPY_4FV(v
->value_float_4
, ctx
->Color
.ClearColor
.f
);
1105 case GL_BLEND_COLOR_EXT
:
1106 if (_mesa_get_clamp_fragment_color(ctx
, ctx
->DrawBuffer
))
1107 COPY_4FV(v
->value_float_4
, ctx
->Color
.BlendColor
);
1109 COPY_4FV(v
->value_float_4
, ctx
->Color
.BlendColorUnclamped
);
1111 case GL_ALPHA_TEST_REF
:
1112 if (_mesa_get_clamp_fragment_color(ctx
, ctx
->DrawBuffer
))
1113 v
->value_float
= ctx
->Color
.AlphaRef
;
1115 v
->value_float
= ctx
->Color
.AlphaRefUnclamped
;
1117 case GL_MAX_VERTEX_UNIFORM_VECTORS
:
1118 v
->value_int
= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxUniformComponents
/ 4;
1121 case GL_MAX_FRAGMENT_UNIFORM_VECTORS
:
1122 v
->value_int
= ctx
->Const
.Program
[MESA_SHADER_FRAGMENT
].MaxUniformComponents
/ 4;
1125 /* GL_ARB_texture_buffer_object */
1126 case GL_TEXTURE_BUFFER_ARB
:
1127 v
->value_int
= ctx
->Texture
.BufferObject
? ctx
->Texture
.BufferObject
->Name
: 0;
1129 case GL_TEXTURE_BINDING_BUFFER_ARB
:
1130 unit
= ctx
->Texture
.CurrentUnit
;
1132 ctx
->Texture
.Unit
[unit
].CurrentTex
[TEXTURE_BUFFER_INDEX
]->Name
;
1134 case GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB
:
1136 struct gl_buffer_object
*buf
=
1137 ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
]
1138 .CurrentTex
[TEXTURE_BUFFER_INDEX
]->BufferObject
;
1139 v
->value_int
= buf
? buf
->Name
: 0;
1142 case GL_TEXTURE_BUFFER_FORMAT_ARB
:
1143 v
->value_int
= ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
]
1144 .CurrentTex
[TEXTURE_BUFFER_INDEX
]->BufferObjectFormat
;
1147 /* GL_ARB_sampler_objects */
1148 case GL_SAMPLER_BINDING
:
1150 struct gl_sampler_object
*samp
=
1151 ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
].Sampler
;
1152 v
->value_int
= samp
? samp
->Name
: 0;
1155 /* GL_ARB_uniform_buffer_object */
1156 case GL_UNIFORM_BUFFER_BINDING
:
1157 v
->value_int
= ctx
->UniformBuffer
? ctx
->UniformBuffer
->Name
: 0;
1159 /* GL_ARB_shader_storage_buffer_object */
1160 case GL_SHADER_STORAGE_BUFFER_BINDING
:
1161 v
->value_int
= ctx
->ShaderStorageBuffer
? ctx
->ShaderStorageBuffer
->Name
: 0;
1163 /* GL_ARB_query_buffer_object */
1164 case GL_QUERY_BUFFER_BINDING
:
1165 v
->value_int
= ctx
->QueryBuffer
? ctx
->QueryBuffer
->Name
: 0;
1167 /* GL_ARB_timer_query */
1169 if (ctx
->Driver
.GetTimestamp
) {
1170 v
->value_int64
= ctx
->Driver
.GetTimestamp(ctx
);
1173 _mesa_problem(ctx
, "driver doesn't implement GetTimestamp");
1177 case GL_DEBUG_OUTPUT
:
1178 case GL_DEBUG_OUTPUT_SYNCHRONOUS
:
1179 case GL_DEBUG_LOGGED_MESSAGES
:
1180 case GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH
:
1181 case GL_DEBUG_GROUP_STACK_DEPTH
:
1182 v
->value_int
= _mesa_get_debug_state_int(ctx
, d
->pname
);
1184 /* GL_ARB_shader_atomic_counters */
1185 case GL_ATOMIC_COUNTER_BUFFER_BINDING
:
1186 v
->value_int
= ctx
->AtomicBuffer
? ctx
->AtomicBuffer
->Name
: 0;
1189 case GL_NUM_SHADING_LANGUAGE_VERSIONS
:
1190 v
->value_int
= _mesa_get_shading_language_version(ctx
, -1, NULL
);
1192 /* GL_ARB_draw_indirect */
1193 case GL_DRAW_INDIRECT_BUFFER_BINDING
:
1194 v
->value_int
= ctx
->DrawIndirectBuffer
? ctx
->DrawIndirectBuffer
->Name
: 0;
1196 /* GL_ARB_indirect_parameters */
1197 case GL_PARAMETER_BUFFER_BINDING_ARB
:
1198 v
->value_int
= ctx
->ParameterBuffer
? ctx
->ParameterBuffer
->Name
: 0;
1200 /* GL_ARB_separate_shader_objects */
1201 case GL_PROGRAM_PIPELINE_BINDING
:
1202 if (ctx
->Pipeline
.Current
) {
1203 v
->value_int
= ctx
->Pipeline
.Current
->Name
;
1208 /* GL_ARB_compute_shader */
1209 case GL_DISPATCH_INDIRECT_BUFFER_BINDING
:
1210 v
->value_int
= ctx
->DispatchIndirectBuffer
?
1211 ctx
->DispatchIndirectBuffer
->Name
: 0;
1213 /* GL_ARB_multisample */
1215 v
->value_int
= _mesa_geometric_samples(ctx
->DrawBuffer
);
1217 case GL_SAMPLE_BUFFERS
:
1218 v
->value_int
= _mesa_geometric_samples(ctx
->DrawBuffer
) > 0;
1220 /* GL_EXT_textrue_integer */
1221 case GL_RGBA_INTEGER_MODE_EXT
:
1222 v
->value_int
= (ctx
->DrawBuffer
->_IntegerBuffers
!= 0);
1224 /* GL_ATI_meminfo & GL_NVX_gpu_memory_info */
1225 case GL_VBO_FREE_MEMORY_ATI
:
1226 case GL_TEXTURE_FREE_MEMORY_ATI
:
1227 case GL_RENDERBUFFER_FREE_MEMORY_ATI
:
1228 case GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX
:
1229 case GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX
:
1230 case GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX
:
1231 case GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX
:
1232 case GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX
:
1234 struct gl_memory_info info
;
1236 ctx
->Driver
.QueryMemoryInfo(ctx
, &info
);
1238 if (d
->pname
== GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX
)
1239 v
->value_int
= info
.total_device_memory
;
1240 else if (d
->pname
== GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX
)
1241 v
->value_int
= info
.total_device_memory
+
1242 info
.total_staging_memory
;
1243 else if (d
->pname
== GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX
)
1244 v
->value_int
= info
.avail_device_memory
;
1245 else if (d
->pname
== GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX
)
1246 v
->value_int
= info
.nr_device_memory_evictions
;
1247 else if (d
->pname
== GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX
)
1248 v
->value_int
= info
.device_memory_evicted
;
1250 /* ATI free memory enums.
1252 * Since the GPU memory is (usually) page-table based, every two
1253 * consecutive elements are equal. From the GL_ATI_meminfo
1256 * "param[0] - total memory free in the pool
1257 * param[1] - largest available free block in the pool
1258 * param[2] - total auxiliary memory free
1259 * param[3] - largest auxiliary free block"
1261 * All three (VBO, TEXTURE, RENDERBUFFER) queries return
1262 * the same numbers here.
1264 v
->value_int_4
[0] = info
.avail_device_memory
;
1265 v
->value_int_4
[1] = info
.avail_device_memory
;
1266 v
->value_int_4
[2] = info
.avail_staging_memory
;
1267 v
->value_int_4
[3] = info
.avail_staging_memory
;
1272 /* GL_ARB_get_program_binary */
1273 case GL_PROGRAM_BINARY_FORMATS
:
1274 assert(ctx
->Const
.NumProgramBinaryFormats
<= 1);
1275 v
->value_int_n
.n
= MIN2(ctx
->Const
.NumProgramBinaryFormats
, 1);
1276 if (ctx
->Const
.NumProgramBinaryFormats
> 0) {
1277 v
->value_int_n
.ints
[0] = GL_PROGRAM_BINARY_FORMAT_MESA
;
1280 /* ARB_spirv_extensions */
1281 case GL_NUM_SPIR_V_EXTENSIONS
:
1282 v
->value_int
= _mesa_get_spirv_extension_count(ctx
);
1284 /* GL_EXT_disjoint_timer_query */
1285 case GL_GPU_DISJOINT_EXT
:
1287 simple_mtx_lock(&ctx
->Shared
->Mutex
);
1288 v
->value_int
= ctx
->Shared
->DisjointOperation
;
1289 /* Reset state as expected by the spec. */
1290 ctx
->Shared
->DisjointOperation
= false;
1291 simple_mtx_unlock(&ctx
->Shared
->Mutex
);
1294 /* GL_ARB_sample_locations */
1295 case GL_SAMPLE_LOCATION_SUBPIXEL_BITS_ARB
:
1296 case GL_SAMPLE_LOCATION_PIXEL_GRID_WIDTH_ARB
:
1297 case GL_SAMPLE_LOCATION_PIXEL_GRID_HEIGHT_ARB
:
1299 GLuint bits
, width
, height
;
1301 if (ctx
->NewState
& _NEW_BUFFERS
)
1302 _mesa_update_state(ctx
);
1304 if (ctx
->DrawBuffer
->_Status
!= GL_FRAMEBUFFER_COMPLETE
) {
1309 ctx
->Driver
.GetProgrammableSampleCaps(ctx
, ctx
->DrawBuffer
,
1310 &bits
, &width
, &height
);
1312 if (d
->pname
== GL_SAMPLE_LOCATION_PIXEL_GRID_WIDTH_ARB
)
1313 v
->value_uint
= width
;
1314 else if (d
->pname
== GL_SAMPLE_LOCATION_PIXEL_GRID_HEIGHT_ARB
)
1315 v
->value_uint
= height
;
1317 v
->value_uint
= bits
;
1320 case GL_PROGRAMMABLE_SAMPLE_LOCATION_TABLE_SIZE_ARB
:
1321 v
->value_uint
= MAX_SAMPLE_LOCATION_TABLE_SIZE
;
1324 /* GL_AMD_framebuffer_multisample_advanced */
1325 case GL_SUPPORTED_MULTISAMPLE_MODES_AMD
:
1326 v
->value_int_n
.n
= ctx
->Const
.NumSupportedMultisampleModes
* 3;
1327 memcpy(v
->value_int_n
.ints
, ctx
->Const
.SupportedMultisampleModes
,
1328 v
->value_int_n
.n
* sizeof(GLint
));
1331 /* GL_NV_viewport_swizzle */
1332 case GL_VIEWPORT_SWIZZLE_X_NV
:
1333 v
->value_enum
= ctx
->ViewportArray
[0].SwizzleX
;
1335 case GL_VIEWPORT_SWIZZLE_Y_NV
:
1336 v
->value_enum
= ctx
->ViewportArray
[0].SwizzleY
;
1338 case GL_VIEWPORT_SWIZZLE_Z_NV
:
1339 v
->value_enum
= ctx
->ViewportArray
[0].SwizzleZ
;
1341 case GL_VIEWPORT_SWIZZLE_W_NV
:
1342 v
->value_enum
= ctx
->ViewportArray
[0].SwizzleW
;
1348 * Check extra constraints on a struct value_desc descriptor
1350 * If a struct value_desc has a non-NULL extra pointer, it means that
1351 * there are a number of extra constraints to check or actions to
1352 * perform. The extras is just an integer array where each integer
1353 * encode different constraints or actions.
1355 * \param ctx current context
1356 * \param func name of calling glGet*v() function for error reporting
1357 * \param d the struct value_desc that has the extra constraints
1359 * \return GL_FALSE if all of the constraints were not satisfied,
1360 * otherwise GL_TRUE.
1363 check_extra(struct gl_context
*ctx
, const char *func
, const struct value_desc
*d
)
1365 const GLuint version
= ctx
->Version
;
1366 GLboolean api_check
= GL_FALSE
;
1367 GLboolean api_found
= GL_FALSE
;
1370 for (e
= d
->extra
; *e
!= EXTRA_END
; e
++) {
1372 case EXTRA_VERSION_30
:
1373 api_check
= GL_TRUE
;
1375 api_found
= GL_TRUE
;
1377 case EXTRA_VERSION_31
:
1378 api_check
= GL_TRUE
;
1380 api_found
= GL_TRUE
;
1382 case EXTRA_VERSION_32
:
1383 api_check
= GL_TRUE
;
1385 api_found
= GL_TRUE
;
1387 case EXTRA_VERSION_40
:
1388 api_check
= GL_TRUE
;
1390 api_found
= GL_TRUE
;
1392 case EXTRA_VERSION_43
:
1393 api_check
= GL_TRUE
;
1394 if (_mesa_is_desktop_gl(ctx
) && version
>= 43)
1395 api_found
= GL_TRUE
;
1397 case EXTRA_NEW_FRAG_CLAMP
:
1398 if (ctx
->NewState
& (_NEW_BUFFERS
| _NEW_FRAG_CLAMP
))
1399 _mesa_update_state(ctx
);
1402 api_check
= GL_TRUE
;
1403 if (ctx
->API
== API_OPENGLES2
)
1404 api_found
= GL_TRUE
;
1407 api_check
= GL_TRUE
;
1408 if (_mesa_is_gles3(ctx
))
1409 api_found
= GL_TRUE
;
1411 case EXTRA_API_ES31
:
1412 api_check
= GL_TRUE
;
1413 if (_mesa_is_gles31(ctx
))
1414 api_found
= GL_TRUE
;
1416 case EXTRA_API_ES32
:
1417 api_check
= GL_TRUE
;
1418 if (_mesa_is_gles32(ctx
))
1419 api_found
= GL_TRUE
;
1422 api_check
= GL_TRUE
;
1423 if (_mesa_is_desktop_gl(ctx
))
1424 api_found
= GL_TRUE
;
1426 case EXTRA_API_GL_CORE
:
1427 api_check
= GL_TRUE
;
1428 if (ctx
->API
== API_OPENGL_CORE
)
1429 api_found
= GL_TRUE
;
1431 case EXTRA_NEW_BUFFERS
:
1432 if (ctx
->NewState
& _NEW_BUFFERS
)
1433 _mesa_update_state(ctx
);
1435 case EXTRA_FLUSH_CURRENT
:
1436 FLUSH_CURRENT(ctx
, 0);
1438 case EXTRA_VALID_DRAW_BUFFER
:
1439 if (d
->pname
- GL_DRAW_BUFFER0_ARB
>= ctx
->Const
.MaxDrawBuffers
) {
1440 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(draw buffer %u)",
1441 func
, d
->pname
- GL_DRAW_BUFFER0_ARB
);
1445 case EXTRA_VALID_TEXTURE_UNIT
:
1446 if (ctx
->Texture
.CurrentUnit
>= ctx
->Const
.MaxTextureCoordUnits
) {
1447 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(texture %u)",
1448 func
, ctx
->Texture
.CurrentUnit
);
1452 case EXTRA_VALID_CLIP_DISTANCE
:
1453 if (d
->pname
- GL_CLIP_DISTANCE0
>= ctx
->Const
.MaxClipPlanes
) {
1454 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(clip distance %u)",
1455 func
, d
->pname
- GL_CLIP_DISTANCE0
);
1459 case EXTRA_GLSL_130
:
1460 api_check
= GL_TRUE
;
1461 if (ctx
->Const
.GLSLVersion
>= 130)
1462 api_found
= GL_TRUE
;
1464 case EXTRA_EXT_UBO_GS
:
1465 api_check
= GL_TRUE
;
1466 if (ctx
->Extensions
.ARB_uniform_buffer_object
&&
1467 _mesa_has_geometry_shaders(ctx
))
1468 api_found
= GL_TRUE
;
1470 case EXTRA_EXT_ATOMICS_GS
:
1471 api_check
= GL_TRUE
;
1472 if (ctx
->Extensions
.ARB_shader_atomic_counters
&&
1473 _mesa_has_geometry_shaders(ctx
))
1474 api_found
= GL_TRUE
;
1476 case EXTRA_EXT_SHADER_IMAGE_GS
:
1477 api_check
= GL_TRUE
;
1478 if (ctx
->Extensions
.ARB_shader_image_load_store
&&
1479 _mesa_has_geometry_shaders(ctx
))
1480 api_found
= GL_TRUE
;
1482 case EXTRA_EXT_ATOMICS_TESS
:
1483 api_check
= GL_TRUE
;
1484 api_found
= ctx
->Extensions
.ARB_shader_atomic_counters
&&
1485 _mesa_has_tessellation(ctx
);
1487 case EXTRA_EXT_SHADER_IMAGE_TESS
:
1488 api_check
= GL_TRUE
;
1489 api_found
= ctx
->Extensions
.ARB_shader_image_load_store
&&
1490 _mesa_has_tessellation(ctx
);
1492 case EXTRA_EXT_SSBO_GS
:
1493 api_check
= GL_TRUE
;
1494 if (ctx
->Extensions
.ARB_shader_storage_buffer_object
&&
1495 _mesa_has_geometry_shaders(ctx
))
1496 api_found
= GL_TRUE
;
1498 case EXTRA_EXT_FB_NO_ATTACH_GS
:
1499 api_check
= GL_TRUE
;
1500 if (ctx
->Extensions
.ARB_framebuffer_no_attachments
&&
1501 (_mesa_is_desktop_gl(ctx
) ||
1502 _mesa_has_OES_geometry_shader(ctx
)))
1503 api_found
= GL_TRUE
;
1505 case EXTRA_EXT_ES_GS
:
1506 api_check
= GL_TRUE
;
1507 if (_mesa_has_OES_geometry_shader(ctx
))
1508 api_found
= GL_TRUE
;
1510 case EXTRA_EXT_PROVOKING_VERTEX_32
:
1511 api_check
= GL_TRUE
;
1512 if (ctx
->API
== API_OPENGL_COMPAT
|| version
== 32)
1513 api_found
= ctx
->Extensions
.EXT_provoking_vertex
;
1517 default: /* *e is a offset into the extension struct */
1518 api_check
= GL_TRUE
;
1519 if (*(GLboolean
*) ((char *) &ctx
->Extensions
+ *e
))
1520 api_found
= GL_TRUE
;
1525 if (api_check
&& !api_found
) {
1526 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(pname=%s)", func
,
1527 _mesa_enum_to_string(d
->pname
));
1534 static const struct value_desc error_value
=
1535 { 0, 0, TYPE_INVALID
, NO_OFFSET
, NO_EXTRA
};
1538 * Find the struct value_desc corresponding to the enum 'pname'.
1540 * We hash the enum value to get an index into the 'table' array,
1541 * which holds the index in the 'values' array of struct value_desc.
1542 * Once we've found the entry, we do the extra checks, if any, then
1543 * look up the value and return a pointer to it.
1545 * If the value has to be computed (for example, it's the result of a
1546 * function call or we need to add 1 to it), we use the tmp 'v' to
1549 * \param func name of glGet*v() func for error reporting
1550 * \param pname the enum value we're looking up
1551 * \param p is were we return the pointer to the value
1552 * \param v a tmp union value variable in the calling glGet*v() function
1554 * \return the struct value_desc corresponding to the enum or a struct
1555 * value_desc of TYPE_INVALID if not found. This lets the calling
1556 * glGet*v() function jump right into a switch statement and
1557 * handle errors there instead of having to check for NULL.
1559 static const struct value_desc
*
1560 find_value(const char *func
, GLenum pname
, void **p
, union value
*v
)
1562 GET_CURRENT_CONTEXT(ctx
);
1564 const struct value_desc
*d
;
1570 /* We index into the table_set[] list of per-API hash tables using the API's
1571 * value in the gl_api enum. Since GLES 3 doesn't have an API_OPENGL* enum
1572 * value since it's compatible with GLES2 its entry in table_set[] is at the
1575 STATIC_ASSERT(ARRAY_SIZE(table_set
) == API_OPENGL_LAST
+ 4);
1576 if (ctx
->API
== API_OPENGLES2
) {
1577 if (ctx
->Version
>= 32)
1578 api
= API_OPENGL_LAST
+ 3;
1579 else if (ctx
->Version
>= 31)
1580 api
= API_OPENGL_LAST
+ 2;
1581 else if (ctx
->Version
>= 30)
1582 api
= API_OPENGL_LAST
+ 1;
1584 mask
= ARRAY_SIZE(table(api
)) - 1;
1585 hash
= (pname
* prime_factor
);
1587 int idx
= table(api
)[hash
& mask
];
1589 /* If the enum isn't valid, the hash walk ends with index 0,
1590 * pointing to the first entry of values[] which doesn't hold
1591 * any valid enum. */
1592 if (unlikely(idx
== 0)) {
1593 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(pname=%s)", func
,
1594 _mesa_enum_to_string(pname
));
1595 return &error_value
;
1599 if (likely(d
->pname
== pname
))
1605 if (unlikely(d
->extra
&& !check_extra(ctx
, func
, d
)))
1606 return &error_value
;
1608 switch (d
->location
) {
1610 *p
= ((char *) ctx
->DrawBuffer
+ d
->offset
);
1613 *p
= ((char *) ctx
+ d
->offset
);
1616 *p
= ((char *) ctx
->Array
.VAO
+ d
->offset
);
1619 if (ctx
->Texture
.CurrentUnit
< ARRAY_SIZE(ctx
->Texture
.FixedFuncUnit
)) {
1620 unsigned index
= ctx
->Texture
.CurrentUnit
;
1621 *p
= ((char *)&ctx
->Texture
.FixedFuncUnit
[index
] + d
->offset
);
1625 find_custom_value(ctx
, d
, v
);
1633 /* silence warning */
1634 return &error_value
;
1637 static const int transpose
[] = {
1645 get_value_size(enum value_type type
, const union value
*v
)
1653 return sizeof(GLint
);
1656 return sizeof(GLint
) * 2;
1659 return sizeof(GLint
) * 3;
1662 return sizeof(GLint
) * 4;
1664 return sizeof(GLint
) * v
->value_int_n
.n
;
1666 return sizeof(GLint64
);
1669 return sizeof(GLenum16
);
1671 return sizeof(GLenum
);
1673 return sizeof(GLenum
) * 2;
1675 return sizeof(GLboolean
);
1677 return sizeof(GLubyte
);
1679 return sizeof(GLshort
);
1691 return sizeof(GLfloat
);
1694 return sizeof(GLfloat
) * 2;
1697 return sizeof(GLfloat
) * 3;
1700 return sizeof(GLfloat
) * 4;
1702 return sizeof(GLfloat
) * 8;
1704 return sizeof(GLdouble
);
1705 case TYPE_DOUBLEN_2
:
1706 return sizeof(GLdouble
) * 2;
1708 return sizeof (GLfloat
) * 16;
1710 return sizeof (GLfloat
) * 16;
1717 _mesa_GetBooleanv(GLenum pname
, GLboolean
*params
)
1719 const struct value_desc
*d
;
1725 d
= find_value("glGetBooleanv", pname
, &p
, &v
);
1730 params
[0] = INT_TO_BOOLEAN(d
->offset
);
1734 params
[7] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[7]);
1735 params
[6] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[6]);
1736 params
[5] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[5]);
1737 params
[4] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[4]);
1740 params
[3] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[3]);
1743 params
[2] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[2]);
1746 params
[1] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[1]);
1749 params
[0] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[0]);
1752 case TYPE_DOUBLEN_2
:
1753 params
[1] = FLOAT_TO_BOOLEAN(((GLdouble
*) p
)[1]);
1755 params
[0] = FLOAT_TO_BOOLEAN(((GLdouble
*) p
)[0]);
1760 params
[3] = INT_TO_BOOLEAN(((GLint
*) p
)[3]);
1763 params
[2] = INT_TO_BOOLEAN(((GLint
*) p
)[2]);
1767 params
[1] = INT_TO_BOOLEAN(((GLint
*) p
)[1]);
1771 params
[0] = INT_TO_BOOLEAN(((GLint
*) p
)[0]);
1775 params
[0] = INT_TO_BOOLEAN(((GLenum16
*) p
)[0]);
1779 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
1780 params
[i
] = INT_TO_BOOLEAN(v
.value_int_n
.ints
[i
]);
1784 params
[0] = INT64_TO_BOOLEAN(((GLint64
*) p
)[0]);
1788 params
[0] = ((GLboolean
*) p
)[0];
1792 params
[0] = INT_TO_BOOLEAN(((GLubyte
*) p
)[0]);
1796 params
[0] = INT_TO_BOOLEAN(((GLshort
*) p
)[0]);
1800 m
= *(GLmatrix
**) p
;
1801 for (i
= 0; i
< 16; i
++)
1802 params
[i
] = FLOAT_TO_BOOLEAN(m
->m
[i
]);
1806 m
= *(GLmatrix
**) p
;
1807 for (i
= 0; i
< 16; i
++)
1808 params
[i
] = FLOAT_TO_BOOLEAN(m
->m
[transpose
[i
]]);
1819 shift
= d
->type
- TYPE_BIT_0
;
1820 params
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
1826 _mesa_GetFloatv(GLenum pname
, GLfloat
*params
)
1828 const struct value_desc
*d
;
1834 d
= find_value("glGetFloatv", pname
, &p
, &v
);
1839 params
[0] = (GLfloat
) d
->offset
;
1843 params
[7] = ((GLfloat
*) p
)[7];
1844 params
[6] = ((GLfloat
*) p
)[6];
1845 params
[5] = ((GLfloat
*) p
)[5];
1846 params
[4] = ((GLfloat
*) p
)[4];
1849 params
[3] = ((GLfloat
*) p
)[3];
1852 params
[2] = ((GLfloat
*) p
)[2];
1855 params
[1] = ((GLfloat
*) p
)[1];
1858 params
[0] = ((GLfloat
*) p
)[0];
1861 case TYPE_DOUBLEN_2
:
1862 params
[1] = (GLfloat
) (((GLdouble
*) p
)[1]);
1864 params
[0] = (GLfloat
) (((GLdouble
*) p
)[0]);
1868 params
[3] = (GLfloat
) (((GLint
*) p
)[3]);
1870 params
[2] = (GLfloat
) (((GLint
*) p
)[2]);
1873 params
[1] = (GLfloat
) (((GLint
*) p
)[1]);
1876 params
[0] = (GLfloat
) (((GLint
*) p
)[0]);
1880 params
[0] = (GLfloat
) (((GLenum16
*) p
)[0]);
1884 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
1885 params
[i
] = (GLfloat
) v
.value_int_n
.ints
[i
];
1889 params
[3] = (GLfloat
) (((GLuint
*) p
)[3]);
1891 params
[2] = (GLfloat
) (((GLuint
*) p
)[2]);
1893 params
[1] = (GLfloat
) (((GLuint
*) p
)[1]);
1895 params
[0] = (GLfloat
) (((GLuint
*) p
)[0]);
1899 params
[0] = (GLfloat
) (((GLint64
*) p
)[0]);
1903 params
[0] = BOOLEAN_TO_FLOAT(*(GLboolean
*) p
);
1907 params
[0] = (GLfloat
) ((GLubyte
*) p
)[0];
1911 params
[0] = (GLfloat
) ((GLshort
*) p
)[0];
1915 m
= *(GLmatrix
**) p
;
1916 for (i
= 0; i
< 16; i
++)
1917 params
[i
] = m
->m
[i
];
1921 m
= *(GLmatrix
**) p
;
1922 for (i
= 0; i
< 16; i
++)
1923 params
[i
] = m
->m
[transpose
[i
]];
1934 shift
= d
->type
- TYPE_BIT_0
;
1935 params
[0] = BOOLEAN_TO_FLOAT((*(GLbitfield
*) p
>> shift
) & 1);
1941 _mesa_GetIntegerv(GLenum pname
, GLint
*params
)
1943 const struct value_desc
*d
;
1949 d
= find_value("glGetIntegerv", pname
, &p
, &v
);
1954 params
[0] = d
->offset
;
1958 params
[7] = IROUND(((GLfloat
*) p
)[7]);
1959 params
[6] = IROUND(((GLfloat
*) p
)[6]);
1960 params
[5] = IROUND(((GLfloat
*) p
)[5]);
1961 params
[4] = IROUND(((GLfloat
*) p
)[4]);
1963 params
[3] = IROUND(((GLfloat
*) p
)[3]);
1965 params
[2] = IROUND(((GLfloat
*) p
)[2]);
1967 params
[1] = IROUND(((GLfloat
*) p
)[1]);
1969 params
[0] = IROUND(((GLfloat
*) p
)[0]);
1973 params
[3] = FLOAT_TO_INT(((GLfloat
*) p
)[3]);
1975 params
[2] = FLOAT_TO_INT(((GLfloat
*) p
)[2]);
1977 params
[1] = FLOAT_TO_INT(((GLfloat
*) p
)[1]);
1979 params
[0] = FLOAT_TO_INT(((GLfloat
*) p
)[0]);
1982 case TYPE_DOUBLEN_2
:
1983 params
[1] = FLOAT_TO_INT(((GLdouble
*) p
)[1]);
1985 params
[0] = FLOAT_TO_INT(((GLdouble
*) p
)[0]);
1990 params
[3] = ((GLint
*) p
)[3];
1993 params
[2] = ((GLint
*) p
)[2];
1997 params
[1] = ((GLint
*) p
)[1];
2001 params
[0] = ((GLint
*) p
)[0];
2005 params
[0] = ((GLenum16
*) p
)[0];
2009 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
2010 params
[i
] = v
.value_int_n
.ints
[i
];
2014 params
[0] = INT64_TO_INT(((GLint64
*) p
)[0]);
2018 params
[0] = BOOLEAN_TO_INT(*(GLboolean
*) p
);
2022 params
[0] = ((GLubyte
*) p
)[0];
2026 params
[0] = ((GLshort
*) p
)[0];
2030 m
= *(GLmatrix
**) p
;
2031 for (i
= 0; i
< 16; i
++)
2032 params
[i
] = FLOAT_TO_INT(m
->m
[i
]);
2036 m
= *(GLmatrix
**) p
;
2037 for (i
= 0; i
< 16; i
++)
2038 params
[i
] = FLOAT_TO_INT(m
->m
[transpose
[i
]]);
2049 shift
= d
->type
- TYPE_BIT_0
;
2050 params
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
2056 _mesa_GetInteger64v(GLenum pname
, GLint64
*params
)
2058 const struct value_desc
*d
;
2064 d
= find_value("glGetInteger64v", pname
, &p
, &v
);
2069 params
[0] = d
->offset
;
2073 params
[7] = IROUND64(((GLfloat
*) p
)[7]);
2074 params
[6] = IROUND64(((GLfloat
*) p
)[6]);
2075 params
[5] = IROUND64(((GLfloat
*) p
)[5]);
2076 params
[4] = IROUND64(((GLfloat
*) p
)[4]);
2078 params
[3] = IROUND64(((GLfloat
*) p
)[3]);
2080 params
[2] = IROUND64(((GLfloat
*) p
)[2]);
2082 params
[1] = IROUND64(((GLfloat
*) p
)[1]);
2084 params
[0] = IROUND64(((GLfloat
*) p
)[0]);
2088 params
[3] = FLOAT_TO_INT(((GLfloat
*) p
)[3]);
2090 params
[2] = FLOAT_TO_INT(((GLfloat
*) p
)[2]);
2092 params
[1] = FLOAT_TO_INT(((GLfloat
*) p
)[1]);
2094 params
[0] = FLOAT_TO_INT(((GLfloat
*) p
)[0]);
2097 case TYPE_DOUBLEN_2
:
2098 params
[1] = FLOAT_TO_INT(((GLdouble
*) p
)[1]);
2100 params
[0] = FLOAT_TO_INT(((GLdouble
*) p
)[0]);
2104 params
[3] = ((GLint
*) p
)[3];
2106 params
[2] = ((GLint
*) p
)[2];
2109 params
[1] = ((GLint
*) p
)[1];
2112 params
[0] = ((GLint
*) p
)[0];
2116 params
[0] = ((GLenum16
*) p
)[0];
2120 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
2121 params
[i
] = v
.value_int_n
.ints
[i
];
2125 params
[3] = ((GLuint
*) p
)[3];
2127 params
[2] = ((GLuint
*) p
)[2];
2129 params
[1] = ((GLuint
*) p
)[1];
2131 params
[0] = ((GLuint
*) p
)[0];
2135 params
[0] = ((GLint64
*) p
)[0];
2139 params
[0] = ((GLboolean
*) p
)[0];
2143 m
= *(GLmatrix
**) p
;
2144 for (i
= 0; i
< 16; i
++)
2145 params
[i
] = FLOAT_TO_INT64(m
->m
[i
]);
2149 m
= *(GLmatrix
**) p
;
2150 for (i
= 0; i
< 16; i
++)
2151 params
[i
] = FLOAT_TO_INT64(m
->m
[transpose
[i
]]);
2162 shift
= d
->type
- TYPE_BIT_0
;
2163 params
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
2169 _mesa_GetDoublev(GLenum pname
, GLdouble
*params
)
2171 const struct value_desc
*d
;
2177 d
= find_value("glGetDoublev", pname
, &p
, &v
);
2182 params
[0] = d
->offset
;
2186 params
[7] = ((GLfloat
*) p
)[7];
2187 params
[6] = ((GLfloat
*) p
)[6];
2188 params
[5] = ((GLfloat
*) p
)[5];
2189 params
[4] = ((GLfloat
*) p
)[4];
2192 params
[3] = ((GLfloat
*) p
)[3];
2195 params
[2] = ((GLfloat
*) p
)[2];
2198 params
[1] = ((GLfloat
*) p
)[1];
2201 params
[0] = ((GLfloat
*) p
)[0];
2204 case TYPE_DOUBLEN_2
:
2205 params
[1] = ((GLdouble
*) p
)[1];
2207 params
[0] = ((GLdouble
*) p
)[0];
2211 params
[3] = ((GLint
*) p
)[3];
2213 params
[2] = ((GLint
*) p
)[2];
2216 params
[1] = ((GLint
*) p
)[1];
2219 params
[0] = ((GLint
*) p
)[0];
2223 params
[0] = ((GLenum16
*) p
)[0];
2227 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
2228 params
[i
] = v
.value_int_n
.ints
[i
];
2232 params
[3] = ((GLuint
*) p
)[3];
2234 params
[2] = ((GLuint
*) p
)[2];
2236 params
[1] = ((GLuint
*) p
)[1];
2238 params
[0] = ((GLuint
*) p
)[0];
2242 params
[0] = (GLdouble
) (((GLint64
*) p
)[0]);
2246 params
[0] = *(GLboolean
*) p
;
2250 params
[0] = ((GLubyte
*) p
)[0];
2254 params
[0] = ((GLshort
*) p
)[0];
2258 m
= *(GLmatrix
**) p
;
2259 for (i
= 0; i
< 16; i
++)
2260 params
[i
] = m
->m
[i
];
2264 m
= *(GLmatrix
**) p
;
2265 for (i
= 0; i
< 16; i
++)
2266 params
[i
] = m
->m
[transpose
[i
]];
2277 shift
= d
->type
- TYPE_BIT_0
;
2278 params
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
2284 _mesa_GetUnsignedBytevEXT(GLenum pname
, GLubyte
*data
)
2286 const struct value_desc
*d
;
2291 const char *func
= "glGetUnsignedBytevEXT";
2293 GET_CURRENT_CONTEXT(ctx
);
2295 if (!ctx
->Extensions
.EXT_memory_object
) {
2296 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(unsupported)", func
);
2300 d
= find_value(func
, pname
, &p
, &v
);
2301 size
= get_value_size(d
->type
, &v
);
2303 _mesa_problem(ctx
, "invalid value type in GetUnsignedBytevEXT()");
2315 shift
= d
->type
- TYPE_BIT_0
;
2316 data
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
2319 memcpy(data
, &d
->offset
, size
);
2322 memcpy(data
, &v
.value_int_n
.ints
, size
);
2348 case TYPE_DOUBLEN_2
:
2351 memcpy(data
, p
, size
);
2354 GLenum e
= *(GLenum16
*)p
;
2355 memcpy(data
, &e
, sizeof(e
));
2359 break; /* nothing - GL error was recorded */
2364 * Convert a GL texture binding enum such as GL_TEXTURE_BINDING_2D
2365 * into the corresponding Mesa texture target index.
2366 * \return TEXTURE_x_INDEX or -1 if binding is invalid
2369 tex_binding_to_index(const struct gl_context
*ctx
, GLenum binding
)
2372 case GL_TEXTURE_BINDING_1D
:
2373 return _mesa_is_desktop_gl(ctx
) ? TEXTURE_1D_INDEX
: -1;
2374 case GL_TEXTURE_BINDING_2D
:
2375 return TEXTURE_2D_INDEX
;
2376 case GL_TEXTURE_BINDING_3D
:
2377 return ctx
->API
!= API_OPENGLES
? TEXTURE_3D_INDEX
: -1;
2378 case GL_TEXTURE_BINDING_CUBE_MAP
:
2379 return ctx
->Extensions
.ARB_texture_cube_map
2380 ? TEXTURE_CUBE_INDEX
: -1;
2381 case GL_TEXTURE_BINDING_RECTANGLE
:
2382 return _mesa_is_desktop_gl(ctx
) && ctx
->Extensions
.NV_texture_rectangle
2383 ? TEXTURE_RECT_INDEX
: -1;
2384 case GL_TEXTURE_BINDING_1D_ARRAY
:
2385 return _mesa_is_desktop_gl(ctx
) && ctx
->Extensions
.EXT_texture_array
2386 ? TEXTURE_1D_ARRAY_INDEX
: -1;
2387 case GL_TEXTURE_BINDING_2D_ARRAY
:
2388 return (_mesa_is_desktop_gl(ctx
) && ctx
->Extensions
.EXT_texture_array
)
2389 || _mesa_is_gles3(ctx
)
2390 ? TEXTURE_2D_ARRAY_INDEX
: -1;
2391 case GL_TEXTURE_BINDING_BUFFER
:
2392 return (_mesa_has_ARB_texture_buffer_object(ctx
) ||
2393 _mesa_has_OES_texture_buffer(ctx
)) ?
2394 TEXTURE_BUFFER_INDEX
: -1;
2395 case GL_TEXTURE_BINDING_CUBE_MAP_ARRAY
:
2396 return _mesa_has_texture_cube_map_array(ctx
)
2397 ? TEXTURE_CUBE_ARRAY_INDEX
: -1;
2398 case GL_TEXTURE_BINDING_2D_MULTISAMPLE
:
2399 return _mesa_is_desktop_gl(ctx
) && ctx
->Extensions
.ARB_texture_multisample
2400 ? TEXTURE_2D_MULTISAMPLE_INDEX
: -1;
2401 case GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY
:
2402 return _mesa_is_desktop_gl(ctx
) && ctx
->Extensions
.ARB_texture_multisample
2403 ? TEXTURE_2D_MULTISAMPLE_ARRAY_INDEX
: -1;
2409 static enum value_type
2410 find_value_indexed(const char *func
, GLenum pname
, GLuint index
, union value
*v
)
2412 GET_CURRENT_CONTEXT(ctx
);
2413 struct gl_buffer_object
*buf
;
2418 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2420 if (!ctx
->Extensions
.EXT_draw_buffers2
)
2422 v
->value_int
= (ctx
->Color
.BlendEnabled
>> index
) & 1;
2427 case GL_BLEND_SRC_RGB
:
2428 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2430 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
2432 v
->value_int
= ctx
->Color
.Blend
[index
].SrcRGB
;
2434 case GL_BLEND_SRC_ALPHA
:
2435 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2437 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
2439 v
->value_int
= ctx
->Color
.Blend
[index
].SrcA
;
2443 case GL_BLEND_DST_RGB
:
2444 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2446 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
2448 v
->value_int
= ctx
->Color
.Blend
[index
].DstRGB
;
2450 case GL_BLEND_DST_ALPHA
:
2451 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2453 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
2455 v
->value_int
= ctx
->Color
.Blend
[index
].DstA
;
2457 case GL_BLEND_EQUATION_RGB
:
2458 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2460 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
2462 v
->value_int
= ctx
->Color
.Blend
[index
].EquationRGB
;
2464 case GL_BLEND_EQUATION_ALPHA
:
2465 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2467 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
2469 v
->value_int
= ctx
->Color
.Blend
[index
].EquationA
;
2472 case GL_COLOR_WRITEMASK
:
2473 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2475 if (!ctx
->Extensions
.EXT_draw_buffers2
)
2477 v
->value_int_4
[0] = GET_COLORMASK_BIT(ctx
->Color
.ColorMask
, index
, 0);
2478 v
->value_int_4
[1] = GET_COLORMASK_BIT(ctx
->Color
.ColorMask
, index
, 1);
2479 v
->value_int_4
[2] = GET_COLORMASK_BIT(ctx
->Color
.ColorMask
, index
, 2);
2480 v
->value_int_4
[3] = GET_COLORMASK_BIT(ctx
->Color
.ColorMask
, index
, 3);
2483 case GL_SCISSOR_BOX
:
2484 if (index
>= ctx
->Const
.MaxViewports
)
2486 v
->value_int_4
[0] = ctx
->Scissor
.ScissorArray
[index
].X
;
2487 v
->value_int_4
[1] = ctx
->Scissor
.ScissorArray
[index
].Y
;
2488 v
->value_int_4
[2] = ctx
->Scissor
.ScissorArray
[index
].Width
;
2489 v
->value_int_4
[3] = ctx
->Scissor
.ScissorArray
[index
].Height
;
2492 case GL_WINDOW_RECTANGLE_EXT
:
2493 if (!ctx
->Extensions
.EXT_window_rectangles
)
2495 if (index
>= ctx
->Const
.MaxWindowRectangles
)
2497 v
->value_int_4
[0] = ctx
->Scissor
.WindowRects
[index
].X
;
2498 v
->value_int_4
[1] = ctx
->Scissor
.WindowRects
[index
].Y
;
2499 v
->value_int_4
[2] = ctx
->Scissor
.WindowRects
[index
].Width
;
2500 v
->value_int_4
[3] = ctx
->Scissor
.WindowRects
[index
].Height
;
2504 if (index
>= ctx
->Const
.MaxViewports
)
2506 v
->value_float_4
[0] = ctx
->ViewportArray
[index
].X
;
2507 v
->value_float_4
[1] = ctx
->ViewportArray
[index
].Y
;
2508 v
->value_float_4
[2] = ctx
->ViewportArray
[index
].Width
;
2509 v
->value_float_4
[3] = ctx
->ViewportArray
[index
].Height
;
2510 return TYPE_FLOAT_4
;
2512 case GL_DEPTH_RANGE
:
2513 if (index
>= ctx
->Const
.MaxViewports
)
2515 v
->value_double_2
[0] = ctx
->ViewportArray
[index
].Near
;
2516 v
->value_double_2
[1] = ctx
->ViewportArray
[index
].Far
;
2517 return TYPE_DOUBLEN_2
;
2519 case GL_TRANSFORM_FEEDBACK_BUFFER_START
:
2520 if (index
>= ctx
->Const
.MaxTransformFeedbackBuffers
)
2522 if (!ctx
->Extensions
.EXT_transform_feedback
)
2524 v
->value_int64
= ctx
->TransformFeedback
.CurrentObject
->Offset
[index
];
2527 case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE
:
2528 if (index
>= ctx
->Const
.MaxTransformFeedbackBuffers
)
2530 if (!ctx
->Extensions
.EXT_transform_feedback
)
2533 = ctx
->TransformFeedback
.CurrentObject
->RequestedSize
[index
];
2536 case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING
:
2537 if (index
>= ctx
->Const
.MaxTransformFeedbackBuffers
)
2539 if (!ctx
->Extensions
.EXT_transform_feedback
)
2541 v
->value_int
= ctx
->TransformFeedback
.CurrentObject
->BufferNames
[index
];
2544 case GL_UNIFORM_BUFFER_BINDING
:
2545 if (index
>= ctx
->Const
.MaxUniformBufferBindings
)
2547 if (!ctx
->Extensions
.ARB_uniform_buffer_object
)
2549 buf
= ctx
->UniformBufferBindings
[index
].BufferObject
;
2550 v
->value_int
= buf
? buf
->Name
: 0;
2553 case GL_UNIFORM_BUFFER_START
:
2554 if (index
>= ctx
->Const
.MaxUniformBufferBindings
)
2556 if (!ctx
->Extensions
.ARB_uniform_buffer_object
)
2558 v
->value_int
= ctx
->UniformBufferBindings
[index
].Offset
< 0 ? 0 :
2559 ctx
->UniformBufferBindings
[index
].Offset
;
2562 case GL_UNIFORM_BUFFER_SIZE
:
2563 if (index
>= ctx
->Const
.MaxUniformBufferBindings
)
2565 if (!ctx
->Extensions
.ARB_uniform_buffer_object
)
2567 v
->value_int
= ctx
->UniformBufferBindings
[index
].Size
< 0 ? 0 :
2568 ctx
->UniformBufferBindings
[index
].Size
;
2571 /* ARB_shader_storage_buffer_object */
2572 case GL_SHADER_STORAGE_BUFFER_BINDING
:
2573 if (!ctx
->Extensions
.ARB_shader_storage_buffer_object
)
2575 if (index
>= ctx
->Const
.MaxShaderStorageBufferBindings
)
2577 buf
= ctx
->ShaderStorageBufferBindings
[index
].BufferObject
;
2578 v
->value_int
= buf
? buf
->Name
: 0;
2581 case GL_SHADER_STORAGE_BUFFER_START
:
2582 if (!ctx
->Extensions
.ARB_shader_storage_buffer_object
)
2584 if (index
>= ctx
->Const
.MaxShaderStorageBufferBindings
)
2586 v
->value_int
= ctx
->ShaderStorageBufferBindings
[index
].Offset
< 0 ? 0 :
2587 ctx
->ShaderStorageBufferBindings
[index
].Offset
;
2590 case GL_SHADER_STORAGE_BUFFER_SIZE
:
2591 if (!ctx
->Extensions
.ARB_shader_storage_buffer_object
)
2593 if (index
>= ctx
->Const
.MaxShaderStorageBufferBindings
)
2595 v
->value_int
= ctx
->ShaderStorageBufferBindings
[index
].Size
< 0 ? 0 :
2596 ctx
->ShaderStorageBufferBindings
[index
].Size
;
2599 /* ARB_texture_multisample / GL3.2 */
2600 case GL_SAMPLE_MASK_VALUE
:
2603 if (!ctx
->Extensions
.ARB_texture_multisample
)
2605 v
->value_int
= ctx
->Multisample
.SampleMaskValue
;
2608 case GL_ATOMIC_COUNTER_BUFFER_BINDING
:
2609 if (!ctx
->Extensions
.ARB_shader_atomic_counters
)
2611 if (index
>= ctx
->Const
.MaxAtomicBufferBindings
)
2613 buf
= ctx
->AtomicBufferBindings
[index
].BufferObject
;
2614 v
->value_int
= buf
? buf
->Name
: 0;
2617 case GL_ATOMIC_COUNTER_BUFFER_START
:
2618 if (!ctx
->Extensions
.ARB_shader_atomic_counters
)
2620 if (index
>= ctx
->Const
.MaxAtomicBufferBindings
)
2622 v
->value_int64
= ctx
->AtomicBufferBindings
[index
].Offset
< 0 ? 0 :
2623 ctx
->AtomicBufferBindings
[index
].Offset
;
2626 case GL_ATOMIC_COUNTER_BUFFER_SIZE
:
2627 if (!ctx
->Extensions
.ARB_shader_atomic_counters
)
2629 if (index
>= ctx
->Const
.MaxAtomicBufferBindings
)
2631 v
->value_int64
= ctx
->AtomicBufferBindings
[index
].Size
< 0 ? 0 :
2632 ctx
->AtomicBufferBindings
[index
].Size
;
2635 case GL_VERTEX_BINDING_DIVISOR
:
2636 if ((!_mesa_is_desktop_gl(ctx
) || !ctx
->Extensions
.ARB_instanced_arrays
) &&
2637 !_mesa_is_gles31(ctx
))
2639 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
)
2641 v
->value_int
= ctx
->Array
.VAO
->BufferBinding
[VERT_ATTRIB_GENERIC(index
)].InstanceDivisor
;
2644 case GL_VERTEX_BINDING_OFFSET
:
2645 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles31(ctx
))
2647 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
)
2649 v
->value_int
= ctx
->Array
.VAO
->BufferBinding
[VERT_ATTRIB_GENERIC(index
)].Offset
;
2652 case GL_VERTEX_BINDING_STRIDE
:
2653 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles31(ctx
))
2655 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
)
2657 v
->value_int
= ctx
->Array
.VAO
->BufferBinding
[VERT_ATTRIB_GENERIC(index
)].Stride
;
2660 case GL_VERTEX_BINDING_BUFFER
:
2661 if (ctx
->API
== API_OPENGLES2
&& ctx
->Version
< 31)
2663 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
)
2665 buf
= ctx
->Array
.VAO
->BufferBinding
[VERT_ATTRIB_GENERIC(index
)].BufferObj
;
2666 v
->value_int
= buf
? buf
->Name
: 0;
2669 /* ARB_shader_image_load_store */
2670 case GL_IMAGE_BINDING_NAME
: {
2671 struct gl_texture_object
*t
;
2673 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
2675 if (index
>= ctx
->Const
.MaxImageUnits
)
2678 t
= ctx
->ImageUnits
[index
].TexObj
;
2679 v
->value_int
= (t
? t
->Name
: 0);
2683 case GL_IMAGE_BINDING_LEVEL
:
2684 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
2686 if (index
>= ctx
->Const
.MaxImageUnits
)
2689 v
->value_int
= ctx
->ImageUnits
[index
].Level
;
2692 case GL_IMAGE_BINDING_LAYERED
:
2693 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
2695 if (index
>= ctx
->Const
.MaxImageUnits
)
2698 v
->value_int
= ctx
->ImageUnits
[index
].Layered
;
2701 case GL_IMAGE_BINDING_LAYER
:
2702 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
2704 if (index
>= ctx
->Const
.MaxImageUnits
)
2707 v
->value_int
= ctx
->ImageUnits
[index
].Layer
;
2710 case GL_IMAGE_BINDING_ACCESS
:
2711 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
2713 if (index
>= ctx
->Const
.MaxImageUnits
)
2716 v
->value_int
= ctx
->ImageUnits
[index
].Access
;
2719 case GL_IMAGE_BINDING_FORMAT
:
2720 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
2722 if (index
>= ctx
->Const
.MaxImageUnits
)
2725 v
->value_int
= ctx
->ImageUnits
[index
].Format
;
2728 /* ARB_direct_state_access */
2729 case GL_TEXTURE_BINDING_1D
:
2730 case GL_TEXTURE_BINDING_1D_ARRAY
:
2731 case GL_TEXTURE_BINDING_2D
:
2732 case GL_TEXTURE_BINDING_2D_ARRAY
:
2733 case GL_TEXTURE_BINDING_2D_MULTISAMPLE
:
2734 case GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY
:
2735 case GL_TEXTURE_BINDING_3D
:
2736 case GL_TEXTURE_BINDING_BUFFER
:
2737 case GL_TEXTURE_BINDING_CUBE_MAP
:
2738 case GL_TEXTURE_BINDING_CUBE_MAP_ARRAY
:
2739 case GL_TEXTURE_BINDING_RECTANGLE
: {
2742 target
= tex_binding_to_index(ctx
, pname
);
2745 if (index
>= _mesa_max_tex_unit(ctx
))
2748 v
->value_int
= ctx
->Texture
.Unit
[index
].CurrentTex
[target
]->Name
;
2752 case GL_SAMPLER_BINDING
: {
2753 struct gl_sampler_object
*samp
;
2755 if (!_mesa_is_desktop_gl(ctx
) || ctx
->Version
< 33)
2757 if (index
>= _mesa_max_tex_unit(ctx
))
2760 samp
= ctx
->Texture
.Unit
[index
].Sampler
;
2761 v
->value_int
= samp
? samp
->Name
: 0;
2765 case GL_MAX_COMPUTE_WORK_GROUP_COUNT
:
2766 if (!_mesa_has_compute_shaders(ctx
))
2770 v
->value_int
= ctx
->Const
.MaxComputeWorkGroupCount
[index
];
2773 case GL_MAX_COMPUTE_WORK_GROUP_SIZE
:
2774 if (!_mesa_has_compute_shaders(ctx
))
2778 v
->value_int
= ctx
->Const
.MaxComputeWorkGroupSize
[index
];
2781 /* ARB_compute_variable_group_size */
2782 case GL_MAX_COMPUTE_VARIABLE_GROUP_SIZE_ARB
:
2783 if (!ctx
->Extensions
.ARB_compute_variable_group_size
)
2787 v
->value_int
= ctx
->Const
.MaxComputeVariableGroupSize
[index
];
2790 /* GL_EXT_external_objects */
2791 case GL_NUM_DEVICE_UUIDS_EXT
:
2794 case GL_DRIVER_UUID_EXT
:
2797 _mesa_get_driver_uuid(ctx
, v
->value_int_4
);
2799 case GL_DEVICE_UUID_EXT
:
2802 _mesa_get_device_uuid(ctx
, v
->value_int_4
);
2804 /* GL_EXT_direct_state_access */
2808 case GL_TEXTURE_CUBE_MAP
:
2809 case GL_TEXTURE_GEN_S
:
2810 case GL_TEXTURE_GEN_T
:
2811 case GL_TEXTURE_GEN_R
:
2812 case GL_TEXTURE_GEN_Q
:
2813 case GL_TEXTURE_RECTANGLE_ARB
: {
2814 GLuint curTexUnitSave
;
2815 if (index
>= _mesa_max_tex_unit(ctx
))
2817 curTexUnitSave
= ctx
->Texture
.CurrentUnit
;
2818 _mesa_ActiveTexture_no_error(GL_TEXTURE0
+ index
);
2819 v
->value_int
= _mesa_IsEnabled(pname
);
2820 _mesa_ActiveTexture_no_error(GL_TEXTURE0
+ curTexUnitSave
);
2823 case GL_TEXTURE_COORD_ARRAY
: {
2824 GLuint curTexUnitSave
;
2825 if (index
>= ctx
->Const
.MaxTextureCoordUnits
)
2827 curTexUnitSave
= ctx
->Array
.ActiveTexture
;
2828 _mesa_ClientActiveTexture(GL_TEXTURE0
+ index
);
2829 v
->value_int
= _mesa_IsEnabled(pname
);
2830 _mesa_ClientActiveTexture(GL_TEXTURE0
+ curTexUnitSave
);
2833 case GL_TEXTURE_MATRIX
:
2834 if (index
>= ARRAY_SIZE(ctx
->TextureMatrixStack
))
2836 v
->value_matrix
= ctx
->TextureMatrixStack
[index
].Top
;
2838 case GL_TRANSPOSE_TEXTURE_MATRIX
:
2839 if (index
>= ARRAY_SIZE(ctx
->TextureMatrixStack
))
2841 v
->value_matrix
= ctx
->TextureMatrixStack
[index
].Top
;
2842 return TYPE_MATRIX_T
;
2843 /* GL_NV_viewport_swizzle */
2844 case GL_VIEWPORT_SWIZZLE_X_NV
:
2845 if (!ctx
->Extensions
.NV_viewport_swizzle
)
2847 if (index
>= ctx
->Const
.MaxViewports
)
2849 v
->value_int
= ctx
->ViewportArray
[index
].SwizzleX
;
2851 case GL_VIEWPORT_SWIZZLE_Y_NV
:
2852 if (!ctx
->Extensions
.NV_viewport_swizzle
)
2854 if (index
>= ctx
->Const
.MaxViewports
)
2856 v
->value_int
= ctx
->ViewportArray
[index
].SwizzleY
;
2858 case GL_VIEWPORT_SWIZZLE_Z_NV
:
2859 if (!ctx
->Extensions
.NV_viewport_swizzle
)
2861 if (index
>= ctx
->Const
.MaxViewports
)
2863 v
->value_int
= ctx
->ViewportArray
[index
].SwizzleZ
;
2865 case GL_VIEWPORT_SWIZZLE_W_NV
:
2866 if (!ctx
->Extensions
.NV_viewport_swizzle
)
2868 if (index
>= ctx
->Const
.MaxViewports
)
2870 v
->value_int
= ctx
->ViewportArray
[index
].SwizzleW
;
2875 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(pname=%s)", func
,
2876 _mesa_enum_to_string(pname
));
2877 return TYPE_INVALID
;
2879 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(pname=%s)", func
,
2880 _mesa_enum_to_string(pname
));
2881 return TYPE_INVALID
;
2885 _mesa_GetBooleani_v( GLenum pname
, GLuint index
, GLboolean
*params
)
2888 enum value_type type
=
2889 find_value_indexed("glGetBooleani_v", pname
, index
, &v
);
2894 params
[0] = INT_TO_BOOLEAN(v
.value_int
);
2898 params
[0] = INT_TO_BOOLEAN(v
.value_int_4
[0]);
2899 params
[1] = INT_TO_BOOLEAN(v
.value_int_4
[1]);
2900 params
[2] = INT_TO_BOOLEAN(v
.value_int_4
[2]);
2901 params
[3] = INT_TO_BOOLEAN(v
.value_int_4
[3]);
2904 params
[0] = INT64_TO_BOOLEAN(v
.value_int64
);
2907 ; /* nothing - GL error was recorded */
2912 _mesa_GetIntegeri_v( GLenum pname
, GLuint index
, GLint
*params
)
2915 enum value_type type
=
2916 find_value_indexed("glGetIntegeri_v", pname
, index
, &v
);
2921 params
[3] = IROUND(v
.value_float_4
[3]);
2924 params
[2] = IROUND(v
.value_float_4
[2]);
2927 params
[1] = IROUND(v
.value_float_4
[1]);
2930 params
[0] = IROUND(v
.value_float_4
[0]);
2933 case TYPE_DOUBLEN_2
:
2934 params
[1] = IROUND(v
.value_double_2
[1]);
2936 params
[0] = IROUND(v
.value_double_2
[0]);
2941 params
[0] = v
.value_int
;
2945 params
[0] = v
.value_int_4
[0];
2946 params
[1] = v
.value_int_4
[1];
2947 params
[2] = v
.value_int_4
[2];
2948 params
[3] = v
.value_int_4
[3];
2951 params
[0] = INT64_TO_INT(v
.value_int64
);
2954 ; /* nothing - GL error was recorded */
2959 _mesa_GetInteger64i_v( GLenum pname
, GLuint index
, GLint64
*params
)
2962 enum value_type type
=
2963 find_value_indexed("glGetInteger64i_v", pname
, index
, &v
);
2967 params
[0] = v
.value_int
;
2970 params
[0] = v
.value_int_4
[0];
2971 params
[1] = v
.value_int_4
[1];
2972 params
[2] = v
.value_int_4
[2];
2973 params
[3] = v
.value_int_4
[3];
2976 params
[0] = (GLuint
) v
.value_int
;
2979 params
[0] = (GLuint
) v
.value_int_4
[0];
2980 params
[1] = (GLuint
) v
.value_int_4
[1];
2981 params
[2] = (GLuint
) v
.value_int_4
[2];
2982 params
[3] = (GLuint
) v
.value_int_4
[3];
2985 params
[0] = v
.value_int64
;
2988 ; /* nothing - GL error was recorded */
2993 _mesa_GetFloati_v(GLenum pname
, GLuint index
, GLfloat
*params
)
2998 enum value_type type
=
2999 find_value_indexed("glGetFloati_v", pname
, index
, &v
);
3004 params
[3] = v
.value_float_4
[3];
3007 params
[2] = v
.value_float_4
[2];
3010 params
[1] = v
.value_float_4
[1];
3013 params
[0] = v
.value_float_4
[0];
3016 case TYPE_DOUBLEN_2
:
3017 params
[1] = (GLfloat
) v
.value_double_2
[1];
3019 params
[0] = (GLfloat
) v
.value_double_2
[0];
3023 params
[3] = (GLfloat
) v
.value_int_4
[3];
3025 params
[2] = (GLfloat
) v
.value_int_4
[2];
3028 params
[1] = (GLfloat
) v
.value_int_4
[1];
3032 params
[0] = (GLfloat
) v
.value_int_4
[0];
3036 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
3037 params
[i
] = (GLfloat
) v
.value_int_n
.ints
[i
];
3041 params
[3] = (GLfloat
) ((GLuint
) v
.value_int_4
[3]);
3043 params
[2] = (GLfloat
) ((GLuint
) v
.value_int_4
[2]);
3045 params
[1] = (GLfloat
) ((GLuint
) v
.value_int_4
[1]);
3047 params
[0] = (GLfloat
) ((GLuint
) v
.value_int_4
[0]);
3051 params
[0] = (GLfloat
) v
.value_int64
;
3055 params
[0] = BOOLEAN_TO_FLOAT(v
.value_bool
);
3059 params
[0] = (GLfloat
) v
.value_ubyte
;
3063 params
[0] = (GLfloat
) v
.value_short
;
3067 m
= *(GLmatrix
**) &v
;
3068 for (i
= 0; i
< 16; i
++)
3069 params
[i
] = m
->m
[i
];
3073 m
= *(GLmatrix
**) &v
;
3074 for (i
= 0; i
< 16; i
++)
3075 params
[i
] = m
->m
[transpose
[i
]];
3084 _mesa_GetDoublei_v(GLenum pname
, GLuint index
, GLdouble
*params
)
3089 enum value_type type
=
3090 find_value_indexed("glGetDoublei_v", pname
, index
, &v
);
3095 params
[3] = (GLdouble
) v
.value_float_4
[3];
3098 params
[2] = (GLdouble
) v
.value_float_4
[2];
3101 params
[1] = (GLdouble
) v
.value_float_4
[1];
3104 params
[0] = (GLdouble
) v
.value_float_4
[0];
3107 case TYPE_DOUBLEN_2
:
3108 params
[1] = v
.value_double_2
[1];
3110 params
[0] = v
.value_double_2
[0];
3114 params
[3] = (GLdouble
) v
.value_int_4
[3];
3116 params
[2] = (GLdouble
) v
.value_int_4
[2];
3119 params
[1] = (GLdouble
) v
.value_int_4
[1];
3123 params
[0] = (GLdouble
) v
.value_int_4
[0];
3127 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
3128 params
[i
] = (GLdouble
) v
.value_int_n
.ints
[i
];
3132 params
[3] = (GLdouble
) ((GLuint
) v
.value_int_4
[3]);
3134 params
[2] = (GLdouble
) ((GLuint
) v
.value_int_4
[2]);
3136 params
[1] = (GLdouble
) ((GLuint
) v
.value_int_4
[1]);
3138 params
[0] = (GLdouble
) ((GLuint
) v
.value_int_4
[0]);
3142 params
[0] = (GLdouble
) v
.value_int64
;
3146 params
[0] = (GLdouble
) BOOLEAN_TO_FLOAT(v
.value_bool
);
3150 params
[0] = (GLdouble
) v
.value_ubyte
;
3154 params
[0] = (GLdouble
) v
.value_short
;
3158 m
= *(GLmatrix
**) &v
;
3159 for (i
= 0; i
< 16; i
++)
3160 params
[i
] = (GLdouble
) m
->m
[i
];
3164 m
= *(GLmatrix
**) &v
;
3165 for (i
= 0; i
< 16; i
++)
3166 params
[i
] = (GLdouble
) m
->m
[transpose
[i
]];
3175 _mesa_GetUnsignedBytei_vEXT(GLenum target
, GLuint index
, GLubyte
*data
)
3179 enum value_type type
;
3180 const char *func
= "glGetUnsignedBytei_vEXT";
3182 GET_CURRENT_CONTEXT(ctx
);
3184 if (!ctx
->Extensions
.EXT_memory_object
) {
3185 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(unsupported)", func
);
3189 type
= find_value_indexed(func
, target
, index
, &v
);
3190 size
= get_value_size(type
, &v
);
3192 _mesa_problem(ctx
, "invalid value type in GetUnsignedBytei_vEXT()");
3221 case TYPE_DOUBLEN_2
:
3224 memcpy(data
, &v
.value_int
, size
);
3227 memcpy(data
, &v
.value_int_n
.ints
, size
);
3230 break; /* nothing - GL error was recorded */
3235 _mesa_GetFixedv(GLenum pname
, GLfixed
*params
)
3237 const struct value_desc
*d
;
3243 d
= find_value("glGetDoublev", pname
, &p
, &v
);
3248 params
[0] = INT_TO_FIXED(d
->offset
);
3253 params
[3] = FLOAT_TO_FIXED(((GLfloat
*) p
)[3]);
3256 params
[2] = FLOAT_TO_FIXED(((GLfloat
*) p
)[2]);
3259 params
[1] = FLOAT_TO_FIXED(((GLfloat
*) p
)[1]);
3262 params
[0] = FLOAT_TO_FIXED(((GLfloat
*) p
)[0]);
3265 case TYPE_DOUBLEN_2
:
3266 params
[1] = FLOAT_TO_FIXED(((GLdouble
*) p
)[1]);
3268 params
[0] = FLOAT_TO_FIXED(((GLdouble
*) p
)[0]);
3273 params
[3] = INT_TO_FIXED(((GLint
*) p
)[3]);
3276 params
[2] = INT_TO_FIXED(((GLint
*) p
)[2]);
3280 params
[1] = INT_TO_FIXED(((GLint
*) p
)[1]);
3284 params
[0] = INT_TO_FIXED(((GLint
*) p
)[0]);
3288 params
[0] = INT_TO_FIXED((GLint
)(((GLenum16
*) p
)[0]));
3292 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
3293 params
[i
] = INT_TO_FIXED(v
.value_int_n
.ints
[i
]);
3297 params
[0] = ((GLint64
*) p
)[0];
3301 params
[0] = BOOLEAN_TO_FIXED(((GLboolean
*) p
)[0]);
3305 params
[0] = INT_TO_FIXED(((GLubyte
*) p
)[0]);
3309 params
[0] = INT_TO_FIXED(((GLshort
*) p
)[0]);
3313 m
= *(GLmatrix
**) p
;
3314 for (i
= 0; i
< 16; i
++)
3315 params
[i
] = FLOAT_TO_FIXED(m
->m
[i
]);
3319 m
= *(GLmatrix
**) p
;
3320 for (i
= 0; i
< 16; i
++)
3321 params
[i
] = FLOAT_TO_FIXED(m
->m
[transpose
[i
]]);
3332 shift
= d
->type
- TYPE_BIT_0
;
3333 params
[0] = BOOLEAN_TO_FIXED((*(GLbitfield
*) p
>> shift
) & 1);