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_VALID_DRAW_BUFFER
,
196 EXTRA_VALID_TEXTURE_UNIT
,
197 EXTRA_VALID_CLIP_DISTANCE
,
201 EXTRA_EXT_ATOMICS_GS
,
202 EXTRA_EXT_SHADER_IMAGE_GS
,
203 EXTRA_EXT_ATOMICS_TESS
,
204 EXTRA_EXT_SHADER_IMAGE_TESS
,
206 EXTRA_EXT_FB_NO_ATTACH_GS
,
208 EXTRA_EXT_PROVOKING_VERTEX_32
,
211 #define NO_EXTRA NULL
216 GLubyte location
; /**< enum value_location */
217 GLubyte type
; /**< enum value_type */
224 GLfloat value_float_4
[4];
225 GLdouble value_double_2
[2];
226 GLmatrix
*value_matrix
;
228 GLint value_int_4
[4];
235 /* Sigh, see GL_COMPRESSED_TEXTURE_FORMATS_ARB handling */
239 GLboolean value_bool
;
242 #define BUFFER_FIELD(field, type) \
243 LOC_BUFFER, type, offsetof(struct gl_framebuffer, field)
244 #define CONTEXT_FIELD(field, type) \
245 LOC_CONTEXT, type, offsetof(struct gl_context, field)
246 #define ARRAY_FIELD(field, type) \
247 LOC_ARRAY, type, offsetof(struct gl_vertex_array_object, field)
248 #undef CONST /* already defined through windows.h */
249 #define CONST(value) \
250 LOC_CONTEXT, TYPE_CONST, value
252 #define BUFFER_INT(field) BUFFER_FIELD(field, TYPE_INT)
253 #define BUFFER_ENUM(field) BUFFER_FIELD(field, TYPE_ENUM)
254 #define BUFFER_ENUM16(field) BUFFER_FIELD(field, TYPE_ENUM16)
255 #define BUFFER_BOOL(field) BUFFER_FIELD(field, TYPE_BOOLEAN)
257 #define CONTEXT_INT(field) CONTEXT_FIELD(field, TYPE_INT)
258 #define CONTEXT_INT2(field) CONTEXT_FIELD(field, TYPE_INT_2)
259 #define CONTEXT_INT64(field) CONTEXT_FIELD(field, TYPE_INT64)
260 #define CONTEXT_UINT(field) CONTEXT_FIELD(field, TYPE_UINT)
261 #define CONTEXT_ENUM16(field) CONTEXT_FIELD(field, TYPE_ENUM16)
262 #define CONTEXT_ENUM(field) CONTEXT_FIELD(field, TYPE_ENUM)
263 #define CONTEXT_ENUM2(field) CONTEXT_FIELD(field, TYPE_ENUM_2)
264 #define CONTEXT_BOOL(field) CONTEXT_FIELD(field, TYPE_BOOLEAN)
265 #define CONTEXT_BIT0(field) CONTEXT_FIELD(field, TYPE_BIT_0)
266 #define CONTEXT_BIT1(field) CONTEXT_FIELD(field, TYPE_BIT_1)
267 #define CONTEXT_BIT2(field) CONTEXT_FIELD(field, TYPE_BIT_2)
268 #define CONTEXT_BIT3(field) CONTEXT_FIELD(field, TYPE_BIT_3)
269 #define CONTEXT_BIT4(field) CONTEXT_FIELD(field, TYPE_BIT_4)
270 #define CONTEXT_BIT5(field) CONTEXT_FIELD(field, TYPE_BIT_5)
271 #define CONTEXT_BIT6(field) CONTEXT_FIELD(field, TYPE_BIT_6)
272 #define CONTEXT_BIT7(field) CONTEXT_FIELD(field, TYPE_BIT_7)
273 #define CONTEXT_FLOAT(field) CONTEXT_FIELD(field, TYPE_FLOAT)
274 #define CONTEXT_FLOAT2(field) CONTEXT_FIELD(field, TYPE_FLOAT_2)
275 #define CONTEXT_FLOAT3(field) CONTEXT_FIELD(field, TYPE_FLOAT_3)
276 #define CONTEXT_FLOAT4(field) CONTEXT_FIELD(field, TYPE_FLOAT_4)
277 #define CONTEXT_FLOAT8(field) CONTEXT_FIELD(field, TYPE_FLOAT_8)
278 #define CONTEXT_MATRIX(field) CONTEXT_FIELD(field, TYPE_MATRIX)
279 #define CONTEXT_MATRIX_T(field) CONTEXT_FIELD(field, TYPE_MATRIX_T)
281 /* Vertex array fields */
282 #define ARRAY_INT(field) ARRAY_FIELD(field, TYPE_INT)
283 #define ARRAY_ENUM(field) ARRAY_FIELD(field, TYPE_ENUM)
284 #define ARRAY_ENUM16(field) ARRAY_FIELD(field, TYPE_ENUM16)
285 #define ARRAY_BOOL(field) ARRAY_FIELD(field, TYPE_BOOLEAN)
286 #define ARRAY_UBYTE(field) ARRAY_FIELD(field, TYPE_UBYTE)
287 #define ARRAY_SHORT(field) ARRAY_FIELD(field, TYPE_SHORT)
290 offsetof(struct gl_extensions, f)
292 #define EXTRA_EXT(e) \
293 static const int extra_##e[] = { \
297 #define EXTRA_EXT2(e1, e2) \
298 static const int extra_##e1##_##e2[] = { \
299 EXT(e1), EXT(e2), EXTRA_END \
302 /* The 'extra' mechanism is a way to specify extra checks (such as
303 * extensions or specific gl versions) or actions (flush current, new
304 * buffers) that we need to do before looking up an enum. We need to
305 * declare them all up front so we can refer to them in the value_desc
308 * Each EXTRA_ will be executed. For EXTRA_* enums of extensions and API
309 * versions, listing multiple ones in an array means an error will be thrown
310 * only if none of them are available. If you need to check for "AND"
311 * behavior, you would need to make a custom EXTRA_ enum.
314 static const int extra_new_buffers
[] = {
319 static const int extra_valid_draw_buffer
[] = {
320 EXTRA_VALID_DRAW_BUFFER
,
324 static const int extra_valid_texture_unit
[] = {
325 EXTRA_VALID_TEXTURE_UNIT
,
329 static const int extra_valid_clip_distance
[] = {
330 EXTRA_VALID_CLIP_DISTANCE
,
334 static const int extra_flush_current_valid_texture_unit
[] = {
336 EXTRA_VALID_TEXTURE_UNIT
,
340 static const int extra_flush_current
[] = {
345 static const int extra_EXT_texture_integer_and_new_buffers
[] = {
346 EXT(EXT_texture_integer
),
351 static const int extra_GLSL_130_es3_gpushader4
[] = {
354 EXT(EXT_gpu_shader4
),
358 static const int extra_texture_buffer_object
[] = {
359 EXT(ARB_texture_buffer_object
),
363 static const int extra_ARB_transform_feedback2_api_es3
[] = {
364 EXT(ARB_transform_feedback2
),
369 static const int extra_ARB_uniform_buffer_object_and_geometry_shader
[] = {
374 static const int extra_ARB_ES2_compatibility_api_es2
[] = {
375 EXT(ARB_ES2_compatibility
),
380 static const int extra_ARB_ES3_compatibility_api_es3
[] = {
381 EXT(ARB_ES3_compatibility
),
386 static const int extra_EXT_framebuffer_sRGB_and_new_buffers
[] = {
387 EXT(EXT_framebuffer_sRGB
),
392 static const int extra_EXT_packed_float
[] = {
393 EXT(EXT_packed_float
),
398 static const int extra_EXT_texture_array_es3
[] = {
399 EXT(EXT_texture_array
),
404 static const int extra_ARB_shader_atomic_counters_and_geometry_shader
[] = {
405 EXTRA_EXT_ATOMICS_GS
,
409 static const int extra_ARB_shader_image_load_store_and_geometry_shader
[] = {
410 EXTRA_EXT_SHADER_IMAGE_GS
,
414 static const int extra_ARB_shader_atomic_counters_and_tessellation
[] = {
415 EXTRA_EXT_ATOMICS_TESS
,
419 static const int extra_ARB_shader_image_load_store_and_tessellation
[] = {
420 EXTRA_EXT_SHADER_IMAGE_TESS
,
424 /* HACK: remove when ARB_compute_shader is actually supported */
425 static const int extra_ARB_compute_shader_es31
[] = {
426 EXT(ARB_compute_shader
),
431 static const int extra_ARB_shader_storage_buffer_object_es31
[] = {
432 EXT(ARB_shader_storage_buffer_object
),
437 static const int extra_ARB_shader_storage_buffer_object_and_geometry_shader
[] = {
442 static const int extra_ARB_shader_image_load_store_shader_storage_buffer_object_es31
[] = {
443 EXT(ARB_shader_image_load_store
),
444 EXT(ARB_shader_storage_buffer_object
),
449 static const int extra_ARB_framebuffer_no_attachments_and_geometry_shader
[] = {
450 EXTRA_EXT_FB_NO_ATTACH_GS
,
454 static const int extra_ARB_viewport_array_or_oes_geometry_shader
[] = {
455 EXT(ARB_viewport_array
),
460 static const int extra_ARB_viewport_array_or_oes_viewport_array
[] = {
461 EXT(ARB_viewport_array
),
462 EXT(OES_viewport_array
),
466 static const int extra_ARB_gpu_shader5_or_oes_geometry_shader
[] = {
467 EXT(ARB_gpu_shader5
),
472 static const int extra_ARB_gpu_shader5_or_OES_sample_variables
[] = {
473 EXT(ARB_gpu_shader5
),
474 EXT(OES_sample_variables
),
478 static const int extra_ES32
[] = {
479 EXT(ARB_ES3_2_compatibility
),
484 static const int extra_KHR_robustness_or_GL
[] = {
491 static const int extra_INTEL_conservative_rasterization
[] = {
492 EXT(INTEL_conservative_rasterization
),
496 EXTRA_EXT(ARB_texture_cube_map
);
497 EXTRA_EXT(EXT_texture_array
);
498 EXTRA_EXT(NV_fog_distance
);
499 EXTRA_EXT(EXT_texture_filter_anisotropic
);
500 EXTRA_EXT(NV_point_sprite
);
501 EXTRA_EXT(NV_texture_rectangle
);
502 EXTRA_EXT(EXT_stencil_two_side
);
503 EXTRA_EXT(EXT_depth_bounds_test
);
504 EXTRA_EXT(ARB_depth_clamp
);
505 EXTRA_EXT(AMD_depth_clamp_separate
);
506 EXTRA_EXT(ATI_fragment_shader
);
507 EXTRA_EXT(EXT_provoking_vertex
);
508 EXTRA_EXT(ARB_fragment_shader
);
509 EXTRA_EXT(ARB_fragment_program
);
510 EXTRA_EXT2(ARB_framebuffer_object
, EXT_framebuffer_multisample
);
511 EXTRA_EXT(ARB_seamless_cube_map
);
513 EXTRA_EXT(ARB_vertex_shader
);
514 EXTRA_EXT(EXT_transform_feedback
);
515 EXTRA_EXT(ARB_transform_feedback3
);
516 EXTRA_EXT(EXT_pixel_buffer_object
);
517 EXTRA_EXT(ARB_vertex_program
);
518 EXTRA_EXT2(NV_point_sprite
, ARB_point_sprite
);
519 EXTRA_EXT2(ARB_vertex_program
, ARB_fragment_program
);
520 EXTRA_EXT(ARB_color_buffer_float
);
521 EXTRA_EXT(EXT_framebuffer_sRGB
);
522 EXTRA_EXT(OES_EGL_image_external
);
523 EXTRA_EXT(ARB_blend_func_extended
);
524 EXTRA_EXT(ARB_uniform_buffer_object
);
525 EXTRA_EXT(ARB_timer_query
);
526 EXTRA_EXT2(ARB_texture_cube_map_array
, OES_texture_cube_map_array
);
527 EXTRA_EXT(ARB_texture_buffer_range
);
528 EXTRA_EXT(ARB_texture_multisample
);
529 EXTRA_EXT(ARB_texture_gather
);
530 EXTRA_EXT(ARB_shader_atomic_counters
);
531 EXTRA_EXT(ARB_draw_indirect
);
532 EXTRA_EXT(ARB_shader_image_load_store
);
533 EXTRA_EXT(ARB_query_buffer_object
);
534 EXTRA_EXT2(ARB_transform_feedback3
, ARB_gpu_shader5
);
535 EXTRA_EXT(INTEL_performance_query
);
536 EXTRA_EXT(ARB_explicit_uniform_location
);
537 EXTRA_EXT(ARB_clip_control
);
538 EXTRA_EXT(ARB_polygon_offset_clamp
);
539 EXTRA_EXT(ARB_framebuffer_no_attachments
);
540 EXTRA_EXT(ARB_tessellation_shader
);
541 EXTRA_EXT(ARB_shader_storage_buffer_object
);
542 EXTRA_EXT(ARB_indirect_parameters
);
543 EXTRA_EXT(ATI_meminfo
);
544 EXTRA_EXT(NVX_gpu_memory_info
);
545 EXTRA_EXT(ARB_cull_distance
);
546 EXTRA_EXT(EXT_window_rectangles
);
547 EXTRA_EXT(KHR_blend_equation_advanced_coherent
);
548 EXTRA_EXT(OES_primitive_bounding_box
);
549 EXTRA_EXT(ARB_compute_variable_group_size
);
550 EXTRA_EXT(KHR_robustness
);
551 EXTRA_EXT(ARB_sparse_buffer
);
552 EXTRA_EXT(NV_conservative_raster
);
553 EXTRA_EXT(NV_conservative_raster_dilate
);
554 EXTRA_EXT(NV_conservative_raster_pre_snap_triangles
);
555 EXTRA_EXT(ARB_sample_locations
);
556 EXTRA_EXT(AMD_framebuffer_multisample_advanced
);
557 EXTRA_EXT(ARB_spirv_extensions
);
558 EXTRA_EXT(NV_viewport_swizzle
);
561 extra_ARB_color_buffer_float_or_glcore
[] = {
562 EXT(ARB_color_buffer_float
),
568 extra_NV_primitive_restart
[] = {
569 EXT(NV_primitive_restart
),
573 static const int extra_version_30
[] = { EXTRA_VERSION_30
, EXTRA_END
};
574 static const int extra_version_31
[] = { EXTRA_VERSION_31
, EXTRA_END
};
575 static const int extra_version_32
[] = { EXTRA_VERSION_32
, EXTRA_END
};
576 static const int extra_version_43
[] = { EXTRA_VERSION_43
, EXTRA_END
};
578 static const int extra_gl30_es3
[] = {
584 static const int extra_gl32_es3
[] = {
590 static const int extra_version_32_OES_geometry_shader
[] = {
596 static const int extra_gl40_ARB_sample_shading
[] = {
598 EXT(ARB_sample_shading
),
603 extra_ARB_vertex_program_api_es2
[] = {
604 EXT(ARB_vertex_program
),
609 /* The ReadBuffer get token is valid under either full GL or under
610 * GLES2 if the NV_read_buffer extension is available. */
612 extra_NV_read_buffer_api_gl
[] = {
618 static const int extra_core_ARB_color_buffer_float_and_new_buffers
[] = {
620 EXT(ARB_color_buffer_float
),
625 static const int extra_EXT_shader_framebuffer_fetch
[] = {
628 EXT(EXT_shader_framebuffer_fetch
),
632 static const int extra_EXT_provoking_vertex_32
[] = {
633 EXTRA_EXT_PROVOKING_VERTEX_32
,
637 static const int extra_EXT_disjoint_timer_query
[] = {
640 EXT(EXT_disjoint_timer_query
),
645 /* This is the big table describing all the enums we accept in
646 * glGet*v(). The table is partitioned into six parts: enums
647 * understood by all GL APIs (OpenGL, GLES and GLES2), enums shared
648 * between OpenGL and GLES, enums exclusive to GLES, etc for the
649 * remaining combinations. To look up the enums valid in a given API
650 * we will use a hash table specific to that API. These tables are in
651 * turn generated at build time and included through get_hash.h.
654 #include "get_hash.h"
656 /* All we need now is a way to look up the value struct from the enum.
657 * The code generated by gcc for the old generated big switch
658 * statement is a big, balanced, open coded if/else tree, essentially
659 * an unrolled binary search. It would be natural to sort the new
660 * enum table and use bsearch(), but we will use a read-only hash
661 * table instead. bsearch() has a nice guaranteed worst case
662 * performance, but we're also guaranteed to hit that worst case
663 * (log2(n) iterations) for about half the enums. Instead, using an
664 * open addressing hash table, we can find the enum on the first try
665 * for 80% of the enums, 1 collision for 10% and never more than 5
666 * collisions for any enum (typical numbers). And the code is very
667 * simple, even though it feels a little magic. */
670 * Handle irregular enums
672 * Some values don't conform to the "well-known type at context
673 * pointer + offset" pattern, so we have this function to catch all
674 * the corner cases. Typically, it's a computed value or a one-off
675 * pointer to a custom struct or something.
677 * In this case we can't return a pointer to the value, so we'll have
678 * to use the temporary variable 'v' declared back in the calling
679 * glGet*v() function to store the result.
681 * \param ctx the current context
682 * \param d the struct value_desc that describes the enum
683 * \param v pointer to the tmp declared in the calling glGet*v() function
686 find_custom_value(struct gl_context
*ctx
, const struct value_desc
*d
, union value
*v
)
688 struct gl_buffer_object
**buffer_obj
, *buf
;
689 struct gl_array_attributes
*array
;
693 case GL_MAJOR_VERSION
:
694 v
->value_int
= ctx
->Version
/ 10;
696 case GL_MINOR_VERSION
:
697 v
->value_int
= ctx
->Version
% 10;
703 case GL_TEXTURE_CUBE_MAP
:
704 case GL_TEXTURE_RECTANGLE_NV
:
705 case GL_TEXTURE_EXTERNAL_OES
:
706 v
->value_bool
= _mesa_IsEnabled(d
->pname
);
709 case GL_LINE_STIPPLE_PATTERN
:
710 /* This is the only GLushort, special case it here by promoting
711 * to an int rather than introducing a new type. */
712 v
->value_int
= ctx
->Line
.StipplePattern
;
715 case GL_CURRENT_RASTER_TEXTURE_COORDS
:
716 unit
= ctx
->Texture
.CurrentUnit
;
717 v
->value_float_4
[0] = ctx
->Current
.RasterTexCoords
[unit
][0];
718 v
->value_float_4
[1] = ctx
->Current
.RasterTexCoords
[unit
][1];
719 v
->value_float_4
[2] = ctx
->Current
.RasterTexCoords
[unit
][2];
720 v
->value_float_4
[3] = ctx
->Current
.RasterTexCoords
[unit
][3];
723 case GL_CURRENT_TEXTURE_COORDS
:
724 unit
= ctx
->Texture
.CurrentUnit
;
725 v
->value_float_4
[0] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
][0];
726 v
->value_float_4
[1] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
][1];
727 v
->value_float_4
[2] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
][2];
728 v
->value_float_4
[3] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
][3];
731 case GL_COLOR_WRITEMASK
:
732 v
->value_int_4
[0] = GET_COLORMASK_BIT(ctx
->Color
.ColorMask
, 0, 0);
733 v
->value_int_4
[1] = GET_COLORMASK_BIT(ctx
->Color
.ColorMask
, 0, 1);
734 v
->value_int_4
[2] = GET_COLORMASK_BIT(ctx
->Color
.ColorMask
, 0, 2);
735 v
->value_int_4
[3] = GET_COLORMASK_BIT(ctx
->Color
.ColorMask
, 0, 3);
739 v
->value_bool
= ctx
->Transform
.DepthClampNear
|| ctx
->Transform
.DepthClampFar
;
743 v
->value_bool
= ctx
->Current
.Attrib
[VERT_ATTRIB_EDGEFLAG
][0] == 1.0F
;
747 v
->value_enum
= ctx
->ReadBuffer
->ColorReadBuffer
;
750 case GL_MAP2_GRID_DOMAIN
:
751 v
->value_float_4
[0] = ctx
->Eval
.MapGrid2u1
;
752 v
->value_float_4
[1] = ctx
->Eval
.MapGrid2u2
;
753 v
->value_float_4
[2] = ctx
->Eval
.MapGrid2v1
;
754 v
->value_float_4
[3] = ctx
->Eval
.MapGrid2v2
;
757 case GL_TEXTURE_STACK_DEPTH
:
758 unit
= ctx
->Texture
.CurrentUnit
;
759 v
->value_int
= ctx
->TextureMatrixStack
[unit
].Depth
+ 1;
761 case GL_TEXTURE_MATRIX
:
762 unit
= ctx
->Texture
.CurrentUnit
;
763 v
->value_matrix
= ctx
->TextureMatrixStack
[unit
].Top
;
766 case GL_VERTEX_ARRAY
:
767 v
->value_bool
= !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_POS
);
769 case GL_NORMAL_ARRAY
:
770 v
->value_bool
= !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_NORMAL
);
773 v
->value_bool
= !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_COLOR0
);
775 case GL_TEXTURE_COORD_ARRAY
:
776 v
->value_bool
= !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_TEX(ctx
->Array
.ActiveTexture
));
779 v
->value_bool
= !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_COLOR_INDEX
);
781 case GL_EDGE_FLAG_ARRAY
:
782 v
->value_bool
= !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_EDGEFLAG
);
784 case GL_SECONDARY_COLOR_ARRAY
:
785 v
->value_bool
= !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_COLOR1
);
787 case GL_FOG_COORDINATE_ARRAY
:
788 v
->value_bool
= !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_FOG
);
790 case GL_POINT_SIZE_ARRAY_OES
:
791 v
->value_bool
= !!(ctx
->Array
.VAO
->Enabled
& VERT_BIT_POINT_SIZE
);
794 case GL_TEXTURE_COORD_ARRAY_TYPE
:
795 case GL_TEXTURE_COORD_ARRAY_STRIDE
:
796 array
= &ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_TEX(ctx
->Array
.ActiveTexture
)];
797 v
->value_int
= *(GLuint
*) ((char *) array
+ d
->offset
);
800 case GL_TEXTURE_COORD_ARRAY_SIZE
:
801 array
= &ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_TEX(ctx
->Array
.ActiveTexture
)];
802 v
->value_int
= array
->Format
.Size
;
805 case GL_VERTEX_ARRAY_SIZE
:
806 array
= &ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_POS
];
807 v
->value_int
= array
->Format
.Size
;
810 case GL_ACTIVE_TEXTURE_ARB
:
811 v
->value_int
= GL_TEXTURE0_ARB
+ ctx
->Texture
.CurrentUnit
;
813 case GL_CLIENT_ACTIVE_TEXTURE_ARB
:
814 v
->value_int
= GL_TEXTURE0_ARB
+ ctx
->Array
.ActiveTexture
;
817 case GL_MODELVIEW_STACK_DEPTH
:
818 case GL_PROJECTION_STACK_DEPTH
:
819 v
->value_int
= *(GLint
*) ((char *) ctx
+ d
->offset
) + 1;
822 case GL_MAX_TEXTURE_SIZE
:
823 case GL_MAX_3D_TEXTURE_SIZE
:
824 case GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB
:
825 p
= (GLuint
*) ((char *) ctx
+ d
->offset
);
826 v
->value_int
= 1 << (*p
- 1);
830 v
->value_int_4
[0] = ctx
->Scissor
.ScissorArray
[0].X
;
831 v
->value_int_4
[1] = ctx
->Scissor
.ScissorArray
[0].Y
;
832 v
->value_int_4
[2] = ctx
->Scissor
.ScissorArray
[0].Width
;
833 v
->value_int_4
[3] = ctx
->Scissor
.ScissorArray
[0].Height
;
836 case GL_SCISSOR_TEST
:
837 v
->value_bool
= ctx
->Scissor
.EnableFlags
& 1;
842 ctx
->ListState
.CurrentList
? ctx
->ListState
.CurrentList
->Name
: 0;
845 if (!ctx
->CompileFlag
)
847 else if (ctx
->ExecuteFlag
)
848 v
->value_enum
= GL_COMPILE_AND_EXECUTE
;
850 v
->value_enum
= GL_COMPILE
;
854 v
->value_float_4
[0] = ctx
->ViewportArray
[0].X
;
855 v
->value_float_4
[1] = ctx
->ViewportArray
[0].Y
;
856 v
->value_float_4
[2] = ctx
->ViewportArray
[0].Width
;
857 v
->value_float_4
[3] = ctx
->ViewportArray
[0].Height
;
861 v
->value_double_2
[0] = ctx
->ViewportArray
[0].Near
;
862 v
->value_double_2
[1] = ctx
->ViewportArray
[0].Far
;
865 case GL_ACTIVE_STENCIL_FACE_EXT
:
866 v
->value_enum
= ctx
->Stencil
.ActiveFace
? GL_BACK
: GL_FRONT
;
869 case GL_STENCIL_FAIL
:
870 v
->value_enum
= ctx
->Stencil
.FailFunc
[ctx
->Stencil
.ActiveFace
];
872 case GL_STENCIL_FUNC
:
873 v
->value_enum
= ctx
->Stencil
.Function
[ctx
->Stencil
.ActiveFace
];
875 case GL_STENCIL_PASS_DEPTH_FAIL
:
876 v
->value_enum
= ctx
->Stencil
.ZFailFunc
[ctx
->Stencil
.ActiveFace
];
878 case GL_STENCIL_PASS_DEPTH_PASS
:
879 v
->value_enum
= ctx
->Stencil
.ZPassFunc
[ctx
->Stencil
.ActiveFace
];
882 v
->value_int
= _mesa_get_stencil_ref(ctx
, ctx
->Stencil
.ActiveFace
);
884 case GL_STENCIL_BACK_REF
:
885 v
->value_int
= _mesa_get_stencil_ref(ctx
, 1);
887 case GL_STENCIL_VALUE_MASK
:
888 v
->value_int
= ctx
->Stencil
.ValueMask
[ctx
->Stencil
.ActiveFace
];
890 case GL_STENCIL_WRITEMASK
:
891 v
->value_int
= ctx
->Stencil
.WriteMask
[ctx
->Stencil
.ActiveFace
];
894 case GL_NUM_EXTENSIONS
:
895 v
->value_int
= _mesa_get_extension_count(ctx
);
898 case GL_IMPLEMENTATION_COLOR_READ_TYPE_OES
:
899 v
->value_int
= _mesa_get_color_read_type(ctx
, NULL
, "glGetIntegerv");
901 case GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES
:
902 v
->value_int
= _mesa_get_color_read_format(ctx
, NULL
, "glGetIntegerv");
905 case GL_CURRENT_MATRIX_STACK_DEPTH_ARB
:
906 v
->value_int
= ctx
->CurrentStack
->Depth
+ 1;
908 case GL_CURRENT_MATRIX_ARB
:
909 case GL_TRANSPOSE_CURRENT_MATRIX_ARB
:
910 v
->value_matrix
= ctx
->CurrentStack
->Top
;
913 case GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB
:
914 v
->value_int
= _mesa_get_compressed_formats(ctx
, NULL
);
916 case GL_COMPRESSED_TEXTURE_FORMATS_ARB
:
918 _mesa_get_compressed_formats(ctx
, v
->value_int_n
.ints
);
919 assert(v
->value_int_n
.n
<= (int) ARRAY_SIZE(v
->value_int_n
.ints
));
922 case GL_MAX_VARYING_FLOATS_ARB
:
923 v
->value_int
= ctx
->Const
.MaxVarying
* 4;
926 /* Various object names */
928 case GL_TEXTURE_BINDING_1D
:
929 case GL_TEXTURE_BINDING_2D
:
930 case GL_TEXTURE_BINDING_3D
:
931 case GL_TEXTURE_BINDING_1D_ARRAY_EXT
:
932 case GL_TEXTURE_BINDING_2D_ARRAY_EXT
:
933 case GL_TEXTURE_BINDING_CUBE_MAP_ARB
:
934 case GL_TEXTURE_BINDING_RECTANGLE_NV
:
935 case GL_TEXTURE_BINDING_EXTERNAL_OES
:
936 case GL_TEXTURE_BINDING_CUBE_MAP_ARRAY
:
937 case GL_TEXTURE_BINDING_2D_MULTISAMPLE
:
938 case GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY
:
939 unit
= ctx
->Texture
.CurrentUnit
;
941 ctx
->Texture
.Unit
[unit
].CurrentTex
[d
->offset
]->Name
;
944 /* GL_EXT_external_objects */
945 case GL_NUM_DEVICE_UUIDS_EXT
:
948 case GL_DRIVER_UUID_EXT
:
949 _mesa_get_driver_uuid(ctx
, v
->value_int_4
);
951 case GL_DEVICE_UUID_EXT
:
952 _mesa_get_device_uuid(ctx
, v
->value_int_4
);
955 /* GL_EXT_packed_float */
956 case GL_RGBA_SIGNED_COMPONENTS_EXT
:
958 /* Note: we only check the 0th color attachment. */
959 const struct gl_renderbuffer
*rb
=
960 ctx
->DrawBuffer
->_ColorDrawBuffers
[0];
961 if (rb
&& _mesa_is_format_signed(rb
->Format
)) {
962 /* Issue 17 of GL_EXT_packed_float: If a component (such as
963 * alpha) has zero bits, the component should not be considered
964 * signed and so the bit for the respective component should be
968 _mesa_get_format_bits(rb
->Format
, GL_RED_BITS
);
970 _mesa_get_format_bits(rb
->Format
, GL_GREEN_BITS
);
972 _mesa_get_format_bits(rb
->Format
, GL_BLUE_BITS
);
974 _mesa_get_format_bits(rb
->Format
, GL_ALPHA_BITS
);
976 _mesa_get_format_bits(rb
->Format
, GL_TEXTURE_LUMINANCE_SIZE
);
978 _mesa_get_format_bits(rb
->Format
, GL_TEXTURE_INTENSITY_SIZE
);
980 v
->value_int_4
[0] = r_bits
+ l_bits
+ i_bits
> 0;
981 v
->value_int_4
[1] = g_bits
+ l_bits
+ i_bits
> 0;
982 v
->value_int_4
[2] = b_bits
+ l_bits
+ i_bits
> 0;
983 v
->value_int_4
[3] = a_bits
+ i_bits
> 0;
989 v
->value_int_4
[3] = 0;
994 /* GL_ARB_vertex_buffer_object */
995 case GL_VERTEX_ARRAY_BUFFER_BINDING_ARB
:
996 case GL_NORMAL_ARRAY_BUFFER_BINDING_ARB
:
997 case GL_COLOR_ARRAY_BUFFER_BINDING_ARB
:
998 case GL_INDEX_ARRAY_BUFFER_BINDING_ARB
:
999 case GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB
:
1000 case GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB
:
1001 case GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB
:
1002 buffer_obj
= (struct gl_buffer_object
**)
1003 ((char *) ctx
->Array
.VAO
+ d
->offset
);
1004 v
->value_int
= (*buffer_obj
) ? (*buffer_obj
)->Name
: 0;
1006 case GL_ARRAY_BUFFER_BINDING_ARB
:
1007 buf
= ctx
->Array
.ArrayBufferObj
;
1008 v
->value_int
= buf
? buf
->Name
: 0;
1010 case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB
:
1011 buf
= ctx
->Array
.VAO
->BufferBinding
[VERT_ATTRIB_TEX(ctx
->Array
.ActiveTexture
)].BufferObj
;
1012 v
->value_int
= buf
? buf
->Name
: 0;
1014 case GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB
:
1015 buf
= ctx
->Array
.VAO
->IndexBufferObj
;
1016 v
->value_int
= buf
? buf
->Name
: 0;
1019 /* ARB_vertex_array_bgra */
1020 case GL_COLOR_ARRAY_SIZE
:
1021 array
= &ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_COLOR0
];
1022 v
->value_int
= array
->Format
.Format
== GL_BGRA
? GL_BGRA
: array
->Format
.Size
;
1024 case GL_SECONDARY_COLOR_ARRAY_SIZE
:
1025 array
= &ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_COLOR1
];
1026 v
->value_int
= array
->Format
.Format
== GL_BGRA
? GL_BGRA
: array
->Format
.Size
;
1029 /* ARB_copy_buffer */
1030 case GL_COPY_READ_BUFFER
:
1031 v
->value_int
= ctx
->CopyReadBuffer
? ctx
->CopyReadBuffer
->Name
: 0;
1033 case GL_COPY_WRITE_BUFFER
:
1034 v
->value_int
= ctx
->CopyWriteBuffer
? ctx
->CopyWriteBuffer
->Name
: 0;
1037 case GL_PIXEL_PACK_BUFFER_BINDING_EXT
:
1038 v
->value_int
= ctx
->Pack
.BufferObj
? ctx
->Pack
.BufferObj
->Name
: 0;
1040 case GL_PIXEL_UNPACK_BUFFER_BINDING_EXT
:
1041 v
->value_int
= ctx
->Unpack
.BufferObj
? ctx
->Unpack
.BufferObj
->Name
: 0;
1043 case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING
:
1044 v
->value_int
= ctx
->TransformFeedback
.CurrentBuffer
?
1045 ctx
->TransformFeedback
.CurrentBuffer
->Name
: 0;
1047 case GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED
:
1048 v
->value_int
= ctx
->TransformFeedback
.CurrentObject
->Paused
;
1050 case GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE
:
1051 v
->value_int
= ctx
->TransformFeedback
.CurrentObject
->Active
;
1053 case GL_TRANSFORM_FEEDBACK_BINDING
:
1054 v
->value_int
= ctx
->TransformFeedback
.CurrentObject
->Name
;
1056 case GL_CURRENT_PROGRAM
:
1057 /* The Changelog of the ARB_separate_shader_objects spec says:
1059 * 24 25 Jul 2011 pbrown Remove the language erroneously deleting
1060 * CURRENT_PROGRAM. In the EXT extension, this
1061 * token was aliased to ACTIVE_PROGRAM_EXT, and
1062 * was used to indicate the last program set by
1063 * either ActiveProgramEXT or UseProgram. In
1064 * the ARB extension, the SSO active programs
1065 * are now program pipeline object state and
1066 * CURRENT_PROGRAM should still be used to query
1067 * the last program set by UseProgram (bug 7822).
1070 ctx
->Shader
.ActiveProgram
? ctx
->Shader
.ActiveProgram
->Name
: 0;
1072 case GL_READ_FRAMEBUFFER_BINDING_EXT
:
1073 v
->value_int
= ctx
->ReadBuffer
->Name
;
1075 case GL_RENDERBUFFER_BINDING_EXT
:
1077 ctx
->CurrentRenderbuffer
? ctx
->CurrentRenderbuffer
->Name
: 0;
1079 case GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES
:
1080 buf
= ctx
->Array
.VAO
->BufferBinding
[VERT_ATTRIB_POINT_SIZE
].BufferObj
;
1081 v
->value_int
= buf
? buf
->Name
: 0;
1085 if (_mesa_get_clamp_fragment_color(ctx
, ctx
->DrawBuffer
))
1086 COPY_4FV(v
->value_float_4
, ctx
->Fog
.Color
);
1088 COPY_4FV(v
->value_float_4
, ctx
->Fog
.ColorUnclamped
);
1090 case GL_COLOR_CLEAR_VALUE
:
1091 if (_mesa_get_clamp_fragment_color(ctx
, ctx
->DrawBuffer
)) {
1092 v
->value_float_4
[0] = CLAMP(ctx
->Color
.ClearColor
.f
[0], 0.0F
, 1.0F
);
1093 v
->value_float_4
[1] = CLAMP(ctx
->Color
.ClearColor
.f
[1], 0.0F
, 1.0F
);
1094 v
->value_float_4
[2] = CLAMP(ctx
->Color
.ClearColor
.f
[2], 0.0F
, 1.0F
);
1095 v
->value_float_4
[3] = CLAMP(ctx
->Color
.ClearColor
.f
[3], 0.0F
, 1.0F
);
1097 COPY_4FV(v
->value_float_4
, ctx
->Color
.ClearColor
.f
);
1099 case GL_BLEND_COLOR_EXT
:
1100 if (_mesa_get_clamp_fragment_color(ctx
, ctx
->DrawBuffer
))
1101 COPY_4FV(v
->value_float_4
, ctx
->Color
.BlendColor
);
1103 COPY_4FV(v
->value_float_4
, ctx
->Color
.BlendColorUnclamped
);
1105 case GL_ALPHA_TEST_REF
:
1106 if (_mesa_get_clamp_fragment_color(ctx
, ctx
->DrawBuffer
))
1107 v
->value_float
= ctx
->Color
.AlphaRef
;
1109 v
->value_float
= ctx
->Color
.AlphaRefUnclamped
;
1111 case GL_MAX_VERTEX_UNIFORM_VECTORS
:
1112 v
->value_int
= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxUniformComponents
/ 4;
1115 case GL_MAX_FRAGMENT_UNIFORM_VECTORS
:
1116 v
->value_int
= ctx
->Const
.Program
[MESA_SHADER_FRAGMENT
].MaxUniformComponents
/ 4;
1119 /* GL_ARB_texture_buffer_object */
1120 case GL_TEXTURE_BUFFER_ARB
:
1121 v
->value_int
= ctx
->Texture
.BufferObject
? ctx
->Texture
.BufferObject
->Name
: 0;
1123 case GL_TEXTURE_BINDING_BUFFER_ARB
:
1124 unit
= ctx
->Texture
.CurrentUnit
;
1126 ctx
->Texture
.Unit
[unit
].CurrentTex
[TEXTURE_BUFFER_INDEX
]->Name
;
1128 case GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB
:
1130 struct gl_buffer_object
*buf
=
1131 ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
]
1132 .CurrentTex
[TEXTURE_BUFFER_INDEX
]->BufferObject
;
1133 v
->value_int
= buf
? buf
->Name
: 0;
1136 case GL_TEXTURE_BUFFER_FORMAT_ARB
:
1137 v
->value_int
= ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
]
1138 .CurrentTex
[TEXTURE_BUFFER_INDEX
]->BufferObjectFormat
;
1141 /* GL_ARB_sampler_objects */
1142 case GL_SAMPLER_BINDING
:
1144 struct gl_sampler_object
*samp
=
1145 ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
].Sampler
;
1146 v
->value_int
= samp
? samp
->Name
: 0;
1149 /* GL_ARB_uniform_buffer_object */
1150 case GL_UNIFORM_BUFFER_BINDING
:
1151 v
->value_int
= ctx
->UniformBuffer
? ctx
->UniformBuffer
->Name
: 0;
1153 /* GL_ARB_shader_storage_buffer_object */
1154 case GL_SHADER_STORAGE_BUFFER_BINDING
:
1155 v
->value_int
= ctx
->ShaderStorageBuffer
? ctx
->ShaderStorageBuffer
->Name
: 0;
1157 /* GL_ARB_query_buffer_object */
1158 case GL_QUERY_BUFFER_BINDING
:
1159 v
->value_int
= ctx
->QueryBuffer
? ctx
->QueryBuffer
->Name
: 0;
1161 /* GL_ARB_timer_query */
1163 if (ctx
->Driver
.GetTimestamp
) {
1164 v
->value_int64
= ctx
->Driver
.GetTimestamp(ctx
);
1167 _mesa_problem(ctx
, "driver doesn't implement GetTimestamp");
1171 case GL_DEBUG_OUTPUT
:
1172 case GL_DEBUG_OUTPUT_SYNCHRONOUS
:
1173 case GL_DEBUG_LOGGED_MESSAGES
:
1174 case GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH
:
1175 case GL_DEBUG_GROUP_STACK_DEPTH
:
1176 v
->value_int
= _mesa_get_debug_state_int(ctx
, d
->pname
);
1178 /* GL_ARB_shader_atomic_counters */
1179 case GL_ATOMIC_COUNTER_BUFFER_BINDING
:
1180 v
->value_int
= ctx
->AtomicBuffer
? ctx
->AtomicBuffer
->Name
: 0;
1183 case GL_NUM_SHADING_LANGUAGE_VERSIONS
:
1184 v
->value_int
= _mesa_get_shading_language_version(ctx
, -1, NULL
);
1186 /* GL_ARB_draw_indirect */
1187 case GL_DRAW_INDIRECT_BUFFER_BINDING
:
1188 v
->value_int
= ctx
->DrawIndirectBuffer
? ctx
->DrawIndirectBuffer
->Name
: 0;
1190 /* GL_ARB_indirect_parameters */
1191 case GL_PARAMETER_BUFFER_BINDING_ARB
:
1192 v
->value_int
= ctx
->ParameterBuffer
? ctx
->ParameterBuffer
->Name
: 0;
1194 /* GL_ARB_separate_shader_objects */
1195 case GL_PROGRAM_PIPELINE_BINDING
:
1196 if (ctx
->Pipeline
.Current
) {
1197 v
->value_int
= ctx
->Pipeline
.Current
->Name
;
1202 /* GL_ARB_compute_shader */
1203 case GL_DISPATCH_INDIRECT_BUFFER_BINDING
:
1204 v
->value_int
= ctx
->DispatchIndirectBuffer
?
1205 ctx
->DispatchIndirectBuffer
->Name
: 0;
1207 /* GL_ARB_multisample */
1209 v
->value_int
= _mesa_geometric_samples(ctx
->DrawBuffer
);
1211 case GL_SAMPLE_BUFFERS
:
1212 v
->value_int
= _mesa_geometric_samples(ctx
->DrawBuffer
) > 0;
1214 /* GL_EXT_textrue_integer */
1215 case GL_RGBA_INTEGER_MODE_EXT
:
1216 v
->value_int
= (ctx
->DrawBuffer
->_IntegerBuffers
!= 0);
1218 /* GL_ATI_meminfo & GL_NVX_gpu_memory_info */
1219 case GL_VBO_FREE_MEMORY_ATI
:
1220 case GL_TEXTURE_FREE_MEMORY_ATI
:
1221 case GL_RENDERBUFFER_FREE_MEMORY_ATI
:
1222 case GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX
:
1223 case GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX
:
1224 case GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX
:
1225 case GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX
:
1226 case GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX
:
1228 struct gl_memory_info info
;
1230 ctx
->Driver
.QueryMemoryInfo(ctx
, &info
);
1232 if (d
->pname
== GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX
)
1233 v
->value_int
= info
.total_device_memory
;
1234 else if (d
->pname
== GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX
)
1235 v
->value_int
= info
.total_device_memory
+
1236 info
.total_staging_memory
;
1237 else if (d
->pname
== GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX
)
1238 v
->value_int
= info
.avail_device_memory
;
1239 else if (d
->pname
== GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX
)
1240 v
->value_int
= info
.nr_device_memory_evictions
;
1241 else if (d
->pname
== GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX
)
1242 v
->value_int
= info
.device_memory_evicted
;
1244 /* ATI free memory enums.
1246 * Since the GPU memory is (usually) page-table based, every two
1247 * consecutive elements are equal. From the GL_ATI_meminfo
1250 * "param[0] - total memory free in the pool
1251 * param[1] - largest available free block in the pool
1252 * param[2] - total auxiliary memory free
1253 * param[3] - largest auxiliary free block"
1255 * All three (VBO, TEXTURE, RENDERBUFFER) queries return
1256 * the same numbers here.
1258 v
->value_int_4
[0] = info
.avail_device_memory
;
1259 v
->value_int_4
[1] = info
.avail_device_memory
;
1260 v
->value_int_4
[2] = info
.avail_staging_memory
;
1261 v
->value_int_4
[3] = info
.avail_staging_memory
;
1266 /* GL_ARB_get_program_binary */
1267 case GL_PROGRAM_BINARY_FORMATS
:
1268 assert(ctx
->Const
.NumProgramBinaryFormats
<= 1);
1269 v
->value_int_n
.n
= MIN2(ctx
->Const
.NumProgramBinaryFormats
, 1);
1270 if (ctx
->Const
.NumProgramBinaryFormats
> 0) {
1271 v
->value_int_n
.ints
[0] = GL_PROGRAM_BINARY_FORMAT_MESA
;
1274 /* ARB_spirv_extensions */
1275 case GL_NUM_SPIR_V_EXTENSIONS
:
1276 v
->value_int
= _mesa_get_spirv_extension_count(ctx
);
1278 /* GL_EXT_disjoint_timer_query */
1279 case GL_GPU_DISJOINT_EXT
:
1281 simple_mtx_lock(&ctx
->Shared
->Mutex
);
1282 v
->value_int
= ctx
->Shared
->DisjointOperation
;
1283 /* Reset state as expected by the spec. */
1284 ctx
->Shared
->DisjointOperation
= false;
1285 simple_mtx_unlock(&ctx
->Shared
->Mutex
);
1288 /* GL_ARB_sample_locations */
1289 case GL_SAMPLE_LOCATION_SUBPIXEL_BITS_ARB
:
1290 case GL_SAMPLE_LOCATION_PIXEL_GRID_WIDTH_ARB
:
1291 case GL_SAMPLE_LOCATION_PIXEL_GRID_HEIGHT_ARB
:
1293 GLuint bits
, width
, height
;
1295 if (ctx
->NewState
& _NEW_BUFFERS
)
1296 _mesa_update_state(ctx
);
1298 if (ctx
->DrawBuffer
->_Status
!= GL_FRAMEBUFFER_COMPLETE
) {
1303 ctx
->Driver
.GetProgrammableSampleCaps(ctx
, ctx
->DrawBuffer
,
1304 &bits
, &width
, &height
);
1306 if (d
->pname
== GL_SAMPLE_LOCATION_PIXEL_GRID_WIDTH_ARB
)
1307 v
->value_uint
= width
;
1308 else if (d
->pname
== GL_SAMPLE_LOCATION_PIXEL_GRID_HEIGHT_ARB
)
1309 v
->value_uint
= height
;
1311 v
->value_uint
= bits
;
1314 case GL_PROGRAMMABLE_SAMPLE_LOCATION_TABLE_SIZE_ARB
:
1315 v
->value_uint
= MAX_SAMPLE_LOCATION_TABLE_SIZE
;
1318 /* GL_AMD_framebuffer_multisample_advanced */
1319 case GL_SUPPORTED_MULTISAMPLE_MODES_AMD
:
1320 v
->value_int_n
.n
= ctx
->Const
.NumSupportedMultisampleModes
* 3;
1321 memcpy(v
->value_int_n
.ints
, ctx
->Const
.SupportedMultisampleModes
,
1322 v
->value_int_n
.n
* sizeof(GLint
));
1325 /* GL_NV_viewport_swizzle */
1326 case GL_VIEWPORT_SWIZZLE_X_NV
:
1327 v
->value_enum
= ctx
->ViewportArray
[0].SwizzleX
;
1329 case GL_VIEWPORT_SWIZZLE_Y_NV
:
1330 v
->value_enum
= ctx
->ViewportArray
[0].SwizzleY
;
1332 case GL_VIEWPORT_SWIZZLE_Z_NV
:
1333 v
->value_enum
= ctx
->ViewportArray
[0].SwizzleZ
;
1335 case GL_VIEWPORT_SWIZZLE_W_NV
:
1336 v
->value_enum
= ctx
->ViewportArray
[0].SwizzleW
;
1342 * Check extra constraints on a struct value_desc descriptor
1344 * If a struct value_desc has a non-NULL extra pointer, it means that
1345 * there are a number of extra constraints to check or actions to
1346 * perform. The extras is just an integer array where each integer
1347 * encode different constraints or actions.
1349 * \param ctx current context
1350 * \param func name of calling glGet*v() function for error reporting
1351 * \param d the struct value_desc that has the extra constraints
1353 * \return GL_FALSE if all of the constraints were not satisfied,
1354 * otherwise GL_TRUE.
1357 check_extra(struct gl_context
*ctx
, const char *func
, const struct value_desc
*d
)
1359 const GLuint version
= ctx
->Version
;
1360 GLboolean api_check
= GL_FALSE
;
1361 GLboolean api_found
= GL_FALSE
;
1364 for (e
= d
->extra
; *e
!= EXTRA_END
; e
++) {
1366 case EXTRA_VERSION_30
:
1367 api_check
= GL_TRUE
;
1369 api_found
= GL_TRUE
;
1371 case EXTRA_VERSION_31
:
1372 api_check
= GL_TRUE
;
1374 api_found
= GL_TRUE
;
1376 case EXTRA_VERSION_32
:
1377 api_check
= GL_TRUE
;
1379 api_found
= GL_TRUE
;
1381 case EXTRA_VERSION_40
:
1382 api_check
= GL_TRUE
;
1384 api_found
= GL_TRUE
;
1386 case EXTRA_VERSION_43
:
1387 api_check
= GL_TRUE
;
1388 if (_mesa_is_desktop_gl(ctx
) && version
>= 43)
1389 api_found
= GL_TRUE
;
1392 api_check
= GL_TRUE
;
1393 if (ctx
->API
== API_OPENGLES2
)
1394 api_found
= GL_TRUE
;
1397 api_check
= GL_TRUE
;
1398 if (_mesa_is_gles3(ctx
))
1399 api_found
= GL_TRUE
;
1401 case EXTRA_API_ES31
:
1402 api_check
= GL_TRUE
;
1403 if (_mesa_is_gles31(ctx
))
1404 api_found
= GL_TRUE
;
1406 case EXTRA_API_ES32
:
1407 api_check
= GL_TRUE
;
1408 if (_mesa_is_gles32(ctx
))
1409 api_found
= GL_TRUE
;
1412 api_check
= GL_TRUE
;
1413 if (_mesa_is_desktop_gl(ctx
))
1414 api_found
= GL_TRUE
;
1416 case EXTRA_API_GL_CORE
:
1417 api_check
= GL_TRUE
;
1418 if (ctx
->API
== API_OPENGL_CORE
)
1419 api_found
= GL_TRUE
;
1421 case EXTRA_NEW_BUFFERS
:
1422 if (ctx
->NewState
& _NEW_BUFFERS
)
1423 _mesa_update_state(ctx
);
1425 case EXTRA_FLUSH_CURRENT
:
1426 FLUSH_CURRENT(ctx
, 0);
1428 case EXTRA_VALID_DRAW_BUFFER
:
1429 if (d
->pname
- GL_DRAW_BUFFER0_ARB
>= ctx
->Const
.MaxDrawBuffers
) {
1430 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(draw buffer %u)",
1431 func
, d
->pname
- GL_DRAW_BUFFER0_ARB
);
1435 case EXTRA_VALID_TEXTURE_UNIT
:
1436 if (ctx
->Texture
.CurrentUnit
>= ctx
->Const
.MaxTextureCoordUnits
) {
1437 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(texture %u)",
1438 func
, ctx
->Texture
.CurrentUnit
);
1442 case EXTRA_VALID_CLIP_DISTANCE
:
1443 if (d
->pname
- GL_CLIP_DISTANCE0
>= ctx
->Const
.MaxClipPlanes
) {
1444 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(clip distance %u)",
1445 func
, d
->pname
- GL_CLIP_DISTANCE0
);
1449 case EXTRA_GLSL_130
:
1450 api_check
= GL_TRUE
;
1451 if (ctx
->Const
.GLSLVersion
>= 130)
1452 api_found
= GL_TRUE
;
1454 case EXTRA_EXT_UBO_GS
:
1455 api_check
= GL_TRUE
;
1456 if (ctx
->Extensions
.ARB_uniform_buffer_object
&&
1457 _mesa_has_geometry_shaders(ctx
))
1458 api_found
= GL_TRUE
;
1460 case EXTRA_EXT_ATOMICS_GS
:
1461 api_check
= GL_TRUE
;
1462 if (ctx
->Extensions
.ARB_shader_atomic_counters
&&
1463 _mesa_has_geometry_shaders(ctx
))
1464 api_found
= GL_TRUE
;
1466 case EXTRA_EXT_SHADER_IMAGE_GS
:
1467 api_check
= GL_TRUE
;
1468 if (ctx
->Extensions
.ARB_shader_image_load_store
&&
1469 _mesa_has_geometry_shaders(ctx
))
1470 api_found
= GL_TRUE
;
1472 case EXTRA_EXT_ATOMICS_TESS
:
1473 api_check
= GL_TRUE
;
1474 api_found
= ctx
->Extensions
.ARB_shader_atomic_counters
&&
1475 _mesa_has_tessellation(ctx
);
1477 case EXTRA_EXT_SHADER_IMAGE_TESS
:
1478 api_check
= GL_TRUE
;
1479 api_found
= ctx
->Extensions
.ARB_shader_image_load_store
&&
1480 _mesa_has_tessellation(ctx
);
1482 case EXTRA_EXT_SSBO_GS
:
1483 api_check
= GL_TRUE
;
1484 if (ctx
->Extensions
.ARB_shader_storage_buffer_object
&&
1485 _mesa_has_geometry_shaders(ctx
))
1486 api_found
= GL_TRUE
;
1488 case EXTRA_EXT_FB_NO_ATTACH_GS
:
1489 api_check
= GL_TRUE
;
1490 if (ctx
->Extensions
.ARB_framebuffer_no_attachments
&&
1491 (_mesa_is_desktop_gl(ctx
) ||
1492 _mesa_has_OES_geometry_shader(ctx
)))
1493 api_found
= GL_TRUE
;
1495 case EXTRA_EXT_ES_GS
:
1496 api_check
= GL_TRUE
;
1497 if (_mesa_has_OES_geometry_shader(ctx
))
1498 api_found
= GL_TRUE
;
1500 case EXTRA_EXT_PROVOKING_VERTEX_32
:
1501 api_check
= GL_TRUE
;
1502 if (ctx
->API
== API_OPENGL_COMPAT
|| version
== 32)
1503 api_found
= ctx
->Extensions
.EXT_provoking_vertex
;
1507 default: /* *e is a offset into the extension struct */
1508 api_check
= GL_TRUE
;
1509 if (*(GLboolean
*) ((char *) &ctx
->Extensions
+ *e
))
1510 api_found
= GL_TRUE
;
1515 if (api_check
&& !api_found
) {
1516 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(pname=%s)", func
,
1517 _mesa_enum_to_string(d
->pname
));
1524 static const struct value_desc error_value
=
1525 { 0, 0, TYPE_INVALID
, NO_OFFSET
, NO_EXTRA
};
1528 * Find the struct value_desc corresponding to the enum 'pname'.
1530 * We hash the enum value to get an index into the 'table' array,
1531 * which holds the index in the 'values' array of struct value_desc.
1532 * Once we've found the entry, we do the extra checks, if any, then
1533 * look up the value and return a pointer to it.
1535 * If the value has to be computed (for example, it's the result of a
1536 * function call or we need to add 1 to it), we use the tmp 'v' to
1539 * \param func name of glGet*v() func for error reporting
1540 * \param pname the enum value we're looking up
1541 * \param p is were we return the pointer to the value
1542 * \param v a tmp union value variable in the calling glGet*v() function
1544 * \return the struct value_desc corresponding to the enum or a struct
1545 * value_desc of TYPE_INVALID if not found. This lets the calling
1546 * glGet*v() function jump right into a switch statement and
1547 * handle errors there instead of having to check for NULL.
1549 static const struct value_desc
*
1550 find_value(const char *func
, GLenum pname
, void **p
, union value
*v
)
1552 GET_CURRENT_CONTEXT(ctx
);
1554 const struct value_desc
*d
;
1560 /* We index into the table_set[] list of per-API hash tables using the API's
1561 * value in the gl_api enum. Since GLES 3 doesn't have an API_OPENGL* enum
1562 * value since it's compatible with GLES2 its entry in table_set[] is at the
1565 STATIC_ASSERT(ARRAY_SIZE(table_set
) == API_OPENGL_LAST
+ 4);
1566 if (ctx
->API
== API_OPENGLES2
) {
1567 if (ctx
->Version
>= 32)
1568 api
= API_OPENGL_LAST
+ 3;
1569 else if (ctx
->Version
>= 31)
1570 api
= API_OPENGL_LAST
+ 2;
1571 else if (ctx
->Version
>= 30)
1572 api
= API_OPENGL_LAST
+ 1;
1574 mask
= ARRAY_SIZE(table(api
)) - 1;
1575 hash
= (pname
* prime_factor
);
1577 int idx
= table(api
)[hash
& mask
];
1579 /* If the enum isn't valid, the hash walk ends with index 0,
1580 * pointing to the first entry of values[] which doesn't hold
1581 * any valid enum. */
1582 if (unlikely(idx
== 0)) {
1583 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(pname=%s)", func
,
1584 _mesa_enum_to_string(pname
));
1585 return &error_value
;
1589 if (likely(d
->pname
== pname
))
1595 if (unlikely(d
->extra
&& !check_extra(ctx
, func
, d
)))
1596 return &error_value
;
1598 switch (d
->location
) {
1600 *p
= ((char *) ctx
->DrawBuffer
+ d
->offset
);
1603 *p
= ((char *) ctx
+ d
->offset
);
1606 *p
= ((char *) ctx
->Array
.VAO
+ d
->offset
);
1609 if (ctx
->Texture
.CurrentUnit
< ARRAY_SIZE(ctx
->Texture
.FixedFuncUnit
)) {
1610 unsigned index
= ctx
->Texture
.CurrentUnit
;
1611 *p
= ((char *)&ctx
->Texture
.FixedFuncUnit
[index
] + d
->offset
);
1614 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(pname=%s,unit=%d)", func
,
1615 _mesa_enum_to_string(pname
),
1616 ctx
->Texture
.CurrentUnit
);
1617 return &error_value
;
1619 find_custom_value(ctx
, d
, v
);
1627 /* silence warning */
1628 return &error_value
;
1631 static const int transpose
[] = {
1639 get_value_size(enum value_type type
, const union value
*v
)
1647 return sizeof(GLint
);
1650 return sizeof(GLint
) * 2;
1653 return sizeof(GLint
) * 3;
1656 return sizeof(GLint
) * 4;
1658 return sizeof(GLint
) * v
->value_int_n
.n
;
1660 return sizeof(GLint64
);
1663 return sizeof(GLenum16
);
1665 return sizeof(GLenum
);
1667 return sizeof(GLenum
) * 2;
1669 return sizeof(GLboolean
);
1671 return sizeof(GLubyte
);
1673 return sizeof(GLshort
);
1685 return sizeof(GLfloat
);
1688 return sizeof(GLfloat
) * 2;
1691 return sizeof(GLfloat
) * 3;
1694 return sizeof(GLfloat
) * 4;
1696 return sizeof(GLfloat
) * 8;
1698 return sizeof(GLdouble
);
1699 case TYPE_DOUBLEN_2
:
1700 return sizeof(GLdouble
) * 2;
1702 return sizeof (GLfloat
) * 16;
1704 return sizeof (GLfloat
) * 16;
1711 _mesa_GetBooleanv(GLenum pname
, GLboolean
*params
)
1713 const struct value_desc
*d
;
1719 d
= find_value("glGetBooleanv", pname
, &p
, &v
);
1724 params
[0] = INT_TO_BOOLEAN(d
->offset
);
1728 params
[7] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[7]);
1729 params
[6] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[6]);
1730 params
[5] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[5]);
1731 params
[4] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[4]);
1734 params
[3] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[3]);
1737 params
[2] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[2]);
1740 params
[1] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[1]);
1743 params
[0] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[0]);
1746 case TYPE_DOUBLEN_2
:
1747 params
[1] = FLOAT_TO_BOOLEAN(((GLdouble
*) p
)[1]);
1749 params
[0] = FLOAT_TO_BOOLEAN(((GLdouble
*) p
)[0]);
1754 params
[3] = INT_TO_BOOLEAN(((GLint
*) p
)[3]);
1757 params
[2] = INT_TO_BOOLEAN(((GLint
*) p
)[2]);
1761 params
[1] = INT_TO_BOOLEAN(((GLint
*) p
)[1]);
1765 params
[0] = INT_TO_BOOLEAN(((GLint
*) p
)[0]);
1769 params
[0] = INT_TO_BOOLEAN(((GLenum16
*) p
)[0]);
1773 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
1774 params
[i
] = INT_TO_BOOLEAN(v
.value_int_n
.ints
[i
]);
1778 params
[0] = INT64_TO_BOOLEAN(((GLint64
*) p
)[0]);
1782 params
[0] = ((GLboolean
*) p
)[0];
1786 params
[0] = INT_TO_BOOLEAN(((GLubyte
*) p
)[0]);
1790 params
[0] = INT_TO_BOOLEAN(((GLshort
*) p
)[0]);
1794 m
= *(GLmatrix
**) p
;
1795 for (i
= 0; i
< 16; i
++)
1796 params
[i
] = FLOAT_TO_BOOLEAN(m
->m
[i
]);
1800 m
= *(GLmatrix
**) p
;
1801 for (i
= 0; i
< 16; i
++)
1802 params
[i
] = FLOAT_TO_BOOLEAN(m
->m
[transpose
[i
]]);
1813 shift
= d
->type
- TYPE_BIT_0
;
1814 params
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
1820 _mesa_GetFloatv(GLenum pname
, GLfloat
*params
)
1822 const struct value_desc
*d
;
1828 d
= find_value("glGetFloatv", pname
, &p
, &v
);
1833 params
[0] = (GLfloat
) d
->offset
;
1837 params
[7] = ((GLfloat
*) p
)[7];
1838 params
[6] = ((GLfloat
*) p
)[6];
1839 params
[5] = ((GLfloat
*) p
)[5];
1840 params
[4] = ((GLfloat
*) p
)[4];
1843 params
[3] = ((GLfloat
*) p
)[3];
1846 params
[2] = ((GLfloat
*) p
)[2];
1849 params
[1] = ((GLfloat
*) p
)[1];
1852 params
[0] = ((GLfloat
*) p
)[0];
1855 case TYPE_DOUBLEN_2
:
1856 params
[1] = (GLfloat
) (((GLdouble
*) p
)[1]);
1858 params
[0] = (GLfloat
) (((GLdouble
*) p
)[0]);
1862 params
[3] = (GLfloat
) (((GLint
*) p
)[3]);
1864 params
[2] = (GLfloat
) (((GLint
*) p
)[2]);
1867 params
[1] = (GLfloat
) (((GLint
*) p
)[1]);
1870 params
[0] = (GLfloat
) (((GLint
*) p
)[0]);
1874 params
[0] = (GLfloat
) (((GLenum16
*) p
)[0]);
1878 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
1879 params
[i
] = (GLfloat
) v
.value_int_n
.ints
[i
];
1883 params
[3] = (GLfloat
) (((GLuint
*) p
)[3]);
1885 params
[2] = (GLfloat
) (((GLuint
*) p
)[2]);
1887 params
[1] = (GLfloat
) (((GLuint
*) p
)[1]);
1889 params
[0] = (GLfloat
) (((GLuint
*) p
)[0]);
1893 params
[0] = (GLfloat
) (((GLint64
*) p
)[0]);
1897 params
[0] = BOOLEAN_TO_FLOAT(*(GLboolean
*) p
);
1901 params
[0] = (GLfloat
) ((GLubyte
*) p
)[0];
1905 params
[0] = (GLfloat
) ((GLshort
*) p
)[0];
1909 m
= *(GLmatrix
**) p
;
1910 for (i
= 0; i
< 16; i
++)
1911 params
[i
] = m
->m
[i
];
1915 m
= *(GLmatrix
**) p
;
1916 for (i
= 0; i
< 16; i
++)
1917 params
[i
] = m
->m
[transpose
[i
]];
1928 shift
= d
->type
- TYPE_BIT_0
;
1929 params
[0] = BOOLEAN_TO_FLOAT((*(GLbitfield
*) p
>> shift
) & 1);
1935 _mesa_GetIntegerv(GLenum pname
, GLint
*params
)
1937 const struct value_desc
*d
;
1943 d
= find_value("glGetIntegerv", pname
, &p
, &v
);
1948 params
[0] = d
->offset
;
1952 params
[7] = lroundf(((GLfloat
*) p
)[7]);
1953 params
[6] = lroundf(((GLfloat
*) p
)[6]);
1954 params
[5] = lroundf(((GLfloat
*) p
)[5]);
1955 params
[4] = lroundf(((GLfloat
*) p
)[4]);
1957 params
[3] = lroundf(((GLfloat
*) p
)[3]);
1959 params
[2] = lroundf(((GLfloat
*) p
)[2]);
1961 params
[1] = lroundf(((GLfloat
*) p
)[1]);
1963 params
[0] = lroundf(((GLfloat
*) p
)[0]);
1967 params
[3] = FLOAT_TO_INT(((GLfloat
*) p
)[3]);
1969 params
[2] = FLOAT_TO_INT(((GLfloat
*) p
)[2]);
1971 params
[1] = FLOAT_TO_INT(((GLfloat
*) p
)[1]);
1973 params
[0] = FLOAT_TO_INT(((GLfloat
*) p
)[0]);
1976 case TYPE_DOUBLEN_2
:
1977 params
[1] = FLOAT_TO_INT(((GLdouble
*) p
)[1]);
1979 params
[0] = FLOAT_TO_INT(((GLdouble
*) p
)[0]);
1984 params
[3] = ((GLint
*) p
)[3];
1987 params
[2] = ((GLint
*) p
)[2];
1991 params
[1] = ((GLint
*) p
)[1];
1995 params
[0] = ((GLint
*) p
)[0];
1999 params
[0] = ((GLenum16
*) p
)[0];
2003 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
2004 params
[i
] = v
.value_int_n
.ints
[i
];
2008 params
[0] = INT64_TO_INT(((GLint64
*) p
)[0]);
2012 params
[0] = BOOLEAN_TO_INT(*(GLboolean
*) p
);
2016 params
[0] = ((GLubyte
*) p
)[0];
2020 params
[0] = ((GLshort
*) p
)[0];
2024 m
= *(GLmatrix
**) p
;
2025 for (i
= 0; i
< 16; i
++)
2026 params
[i
] = FLOAT_TO_INT(m
->m
[i
]);
2030 m
= *(GLmatrix
**) p
;
2031 for (i
= 0; i
< 16; i
++)
2032 params
[i
] = FLOAT_TO_INT(m
->m
[transpose
[i
]]);
2043 shift
= d
->type
- TYPE_BIT_0
;
2044 params
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
2050 _mesa_GetInteger64v(GLenum pname
, GLint64
*params
)
2052 const struct value_desc
*d
;
2058 d
= find_value("glGetInteger64v", pname
, &p
, &v
);
2063 params
[0] = d
->offset
;
2067 params
[7] = llround(((GLfloat
*) p
)[7]);
2068 params
[6] = llround(((GLfloat
*) p
)[6]);
2069 params
[5] = llround(((GLfloat
*) p
)[5]);
2070 params
[4] = llround(((GLfloat
*) p
)[4]);
2072 params
[3] = llround(((GLfloat
*) p
)[3]);
2074 params
[2] = llround(((GLfloat
*) p
)[2]);
2076 params
[1] = llround(((GLfloat
*) p
)[1]);
2078 params
[0] = llround(((GLfloat
*) p
)[0]);
2082 params
[3] = FLOAT_TO_INT(((GLfloat
*) p
)[3]);
2084 params
[2] = FLOAT_TO_INT(((GLfloat
*) p
)[2]);
2086 params
[1] = FLOAT_TO_INT(((GLfloat
*) p
)[1]);
2088 params
[0] = FLOAT_TO_INT(((GLfloat
*) p
)[0]);
2091 case TYPE_DOUBLEN_2
:
2092 params
[1] = FLOAT_TO_INT(((GLdouble
*) p
)[1]);
2094 params
[0] = FLOAT_TO_INT(((GLdouble
*) p
)[0]);
2098 params
[3] = ((GLint
*) p
)[3];
2100 params
[2] = ((GLint
*) p
)[2];
2103 params
[1] = ((GLint
*) p
)[1];
2106 params
[0] = ((GLint
*) p
)[0];
2110 params
[0] = ((GLenum16
*) p
)[0];
2114 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
2115 params
[i
] = v
.value_int_n
.ints
[i
];
2119 params
[3] = ((GLuint
*) p
)[3];
2121 params
[2] = ((GLuint
*) p
)[2];
2123 params
[1] = ((GLuint
*) p
)[1];
2125 params
[0] = ((GLuint
*) p
)[0];
2129 params
[0] = ((GLint64
*) p
)[0];
2133 params
[0] = ((GLboolean
*) p
)[0];
2137 m
= *(GLmatrix
**) p
;
2138 for (i
= 0; i
< 16; i
++)
2139 params
[i
] = FLOAT_TO_INT64(m
->m
[i
]);
2143 m
= *(GLmatrix
**) p
;
2144 for (i
= 0; i
< 16; i
++)
2145 params
[i
] = FLOAT_TO_INT64(m
->m
[transpose
[i
]]);
2156 shift
= d
->type
- TYPE_BIT_0
;
2157 params
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
2163 _mesa_GetDoublev(GLenum pname
, GLdouble
*params
)
2165 const struct value_desc
*d
;
2171 d
= find_value("glGetDoublev", pname
, &p
, &v
);
2176 params
[0] = d
->offset
;
2180 params
[7] = ((GLfloat
*) p
)[7];
2181 params
[6] = ((GLfloat
*) p
)[6];
2182 params
[5] = ((GLfloat
*) p
)[5];
2183 params
[4] = ((GLfloat
*) p
)[4];
2186 params
[3] = ((GLfloat
*) p
)[3];
2189 params
[2] = ((GLfloat
*) p
)[2];
2192 params
[1] = ((GLfloat
*) p
)[1];
2195 params
[0] = ((GLfloat
*) p
)[0];
2198 case TYPE_DOUBLEN_2
:
2199 params
[1] = ((GLdouble
*) p
)[1];
2201 params
[0] = ((GLdouble
*) p
)[0];
2205 params
[3] = ((GLint
*) p
)[3];
2207 params
[2] = ((GLint
*) p
)[2];
2210 params
[1] = ((GLint
*) p
)[1];
2213 params
[0] = ((GLint
*) p
)[0];
2217 params
[0] = ((GLenum16
*) p
)[0];
2221 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
2222 params
[i
] = v
.value_int_n
.ints
[i
];
2226 params
[3] = ((GLuint
*) p
)[3];
2228 params
[2] = ((GLuint
*) p
)[2];
2230 params
[1] = ((GLuint
*) p
)[1];
2232 params
[0] = ((GLuint
*) p
)[0];
2236 params
[0] = (GLdouble
) (((GLint64
*) p
)[0]);
2240 params
[0] = *(GLboolean
*) p
;
2244 params
[0] = ((GLubyte
*) p
)[0];
2248 params
[0] = ((GLshort
*) p
)[0];
2252 m
= *(GLmatrix
**) p
;
2253 for (i
= 0; i
< 16; i
++)
2254 params
[i
] = m
->m
[i
];
2258 m
= *(GLmatrix
**) p
;
2259 for (i
= 0; i
< 16; i
++)
2260 params
[i
] = m
->m
[transpose
[i
]];
2271 shift
= d
->type
- TYPE_BIT_0
;
2272 params
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
2278 _mesa_GetUnsignedBytevEXT(GLenum pname
, GLubyte
*data
)
2280 const struct value_desc
*d
;
2285 const char *func
= "glGetUnsignedBytevEXT";
2287 GET_CURRENT_CONTEXT(ctx
);
2289 if (!ctx
->Extensions
.EXT_memory_object
) {
2290 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(unsupported)", func
);
2294 d
= find_value(func
, pname
, &p
, &v
);
2295 size
= get_value_size(d
->type
, &v
);
2297 _mesa_problem(ctx
, "invalid value type in GetUnsignedBytevEXT()");
2309 shift
= d
->type
- TYPE_BIT_0
;
2310 data
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
2313 memcpy(data
, &d
->offset
, size
);
2316 memcpy(data
, &v
.value_int_n
.ints
, size
);
2342 case TYPE_DOUBLEN_2
:
2345 memcpy(data
, p
, size
);
2348 GLenum e
= *(GLenum16
*)p
;
2349 memcpy(data
, &e
, sizeof(e
));
2353 break; /* nothing - GL error was recorded */
2358 * Convert a GL texture binding enum such as GL_TEXTURE_BINDING_2D
2359 * into the corresponding Mesa texture target index.
2360 * \return TEXTURE_x_INDEX or -1 if binding is invalid
2363 tex_binding_to_index(const struct gl_context
*ctx
, GLenum binding
)
2366 case GL_TEXTURE_BINDING_1D
:
2367 return _mesa_is_desktop_gl(ctx
) ? TEXTURE_1D_INDEX
: -1;
2368 case GL_TEXTURE_BINDING_2D
:
2369 return TEXTURE_2D_INDEX
;
2370 case GL_TEXTURE_BINDING_3D
:
2371 return ctx
->API
!= API_OPENGLES
? TEXTURE_3D_INDEX
: -1;
2372 case GL_TEXTURE_BINDING_CUBE_MAP
:
2373 return ctx
->Extensions
.ARB_texture_cube_map
2374 ? TEXTURE_CUBE_INDEX
: -1;
2375 case GL_TEXTURE_BINDING_RECTANGLE
:
2376 return _mesa_is_desktop_gl(ctx
) && ctx
->Extensions
.NV_texture_rectangle
2377 ? TEXTURE_RECT_INDEX
: -1;
2378 case GL_TEXTURE_BINDING_1D_ARRAY
:
2379 return _mesa_is_desktop_gl(ctx
) && ctx
->Extensions
.EXT_texture_array
2380 ? TEXTURE_1D_ARRAY_INDEX
: -1;
2381 case GL_TEXTURE_BINDING_2D_ARRAY
:
2382 return (_mesa_is_desktop_gl(ctx
) && ctx
->Extensions
.EXT_texture_array
)
2383 || _mesa_is_gles3(ctx
)
2384 ? TEXTURE_2D_ARRAY_INDEX
: -1;
2385 case GL_TEXTURE_BINDING_BUFFER
:
2386 return (_mesa_has_ARB_texture_buffer_object(ctx
) ||
2387 _mesa_has_OES_texture_buffer(ctx
)) ?
2388 TEXTURE_BUFFER_INDEX
: -1;
2389 case GL_TEXTURE_BINDING_CUBE_MAP_ARRAY
:
2390 return _mesa_has_texture_cube_map_array(ctx
)
2391 ? TEXTURE_CUBE_ARRAY_INDEX
: -1;
2392 case GL_TEXTURE_BINDING_2D_MULTISAMPLE
:
2393 return _mesa_is_desktop_gl(ctx
) && ctx
->Extensions
.ARB_texture_multisample
2394 ? TEXTURE_2D_MULTISAMPLE_INDEX
: -1;
2395 case GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY
:
2396 return _mesa_is_desktop_gl(ctx
) && ctx
->Extensions
.ARB_texture_multisample
2397 ? TEXTURE_2D_MULTISAMPLE_ARRAY_INDEX
: -1;
2403 static enum value_type
2404 find_value_indexed(const char *func
, GLenum pname
, GLuint index
, union value
*v
)
2406 GET_CURRENT_CONTEXT(ctx
);
2407 struct gl_buffer_object
*buf
;
2412 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2414 if (!ctx
->Extensions
.EXT_draw_buffers2
)
2416 v
->value_int
= (ctx
->Color
.BlendEnabled
>> index
) & 1;
2421 case GL_BLEND_SRC_RGB
:
2422 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2424 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
2426 v
->value_int
= ctx
->Color
.Blend
[index
].SrcRGB
;
2428 case GL_BLEND_SRC_ALPHA
:
2429 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2431 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
2433 v
->value_int
= ctx
->Color
.Blend
[index
].SrcA
;
2437 case GL_BLEND_DST_RGB
:
2438 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2440 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
2442 v
->value_int
= ctx
->Color
.Blend
[index
].DstRGB
;
2444 case GL_BLEND_DST_ALPHA
:
2445 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2447 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
2449 v
->value_int
= ctx
->Color
.Blend
[index
].DstA
;
2451 case GL_BLEND_EQUATION_RGB
:
2452 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2454 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
2456 v
->value_int
= ctx
->Color
.Blend
[index
].EquationRGB
;
2458 case GL_BLEND_EQUATION_ALPHA
:
2459 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2461 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
2463 v
->value_int
= ctx
->Color
.Blend
[index
].EquationA
;
2466 case GL_COLOR_WRITEMASK
:
2467 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2469 if (!ctx
->Extensions
.EXT_draw_buffers2
)
2471 v
->value_int_4
[0] = GET_COLORMASK_BIT(ctx
->Color
.ColorMask
, index
, 0);
2472 v
->value_int_4
[1] = GET_COLORMASK_BIT(ctx
->Color
.ColorMask
, index
, 1);
2473 v
->value_int_4
[2] = GET_COLORMASK_BIT(ctx
->Color
.ColorMask
, index
, 2);
2474 v
->value_int_4
[3] = GET_COLORMASK_BIT(ctx
->Color
.ColorMask
, index
, 3);
2477 case GL_SCISSOR_BOX
:
2478 if (index
>= ctx
->Const
.MaxViewports
)
2480 v
->value_int_4
[0] = ctx
->Scissor
.ScissorArray
[index
].X
;
2481 v
->value_int_4
[1] = ctx
->Scissor
.ScissorArray
[index
].Y
;
2482 v
->value_int_4
[2] = ctx
->Scissor
.ScissorArray
[index
].Width
;
2483 v
->value_int_4
[3] = ctx
->Scissor
.ScissorArray
[index
].Height
;
2486 case GL_WINDOW_RECTANGLE_EXT
:
2487 if (!ctx
->Extensions
.EXT_window_rectangles
)
2489 if (index
>= ctx
->Const
.MaxWindowRectangles
)
2491 v
->value_int_4
[0] = ctx
->Scissor
.WindowRects
[index
].X
;
2492 v
->value_int_4
[1] = ctx
->Scissor
.WindowRects
[index
].Y
;
2493 v
->value_int_4
[2] = ctx
->Scissor
.WindowRects
[index
].Width
;
2494 v
->value_int_4
[3] = ctx
->Scissor
.WindowRects
[index
].Height
;
2498 if (index
>= ctx
->Const
.MaxViewports
)
2500 v
->value_float_4
[0] = ctx
->ViewportArray
[index
].X
;
2501 v
->value_float_4
[1] = ctx
->ViewportArray
[index
].Y
;
2502 v
->value_float_4
[2] = ctx
->ViewportArray
[index
].Width
;
2503 v
->value_float_4
[3] = ctx
->ViewportArray
[index
].Height
;
2504 return TYPE_FLOAT_4
;
2506 case GL_DEPTH_RANGE
:
2507 if (index
>= ctx
->Const
.MaxViewports
)
2509 v
->value_double_2
[0] = ctx
->ViewportArray
[index
].Near
;
2510 v
->value_double_2
[1] = ctx
->ViewportArray
[index
].Far
;
2511 return TYPE_DOUBLEN_2
;
2513 case GL_TRANSFORM_FEEDBACK_BUFFER_START
:
2514 if (index
>= ctx
->Const
.MaxTransformFeedbackBuffers
)
2516 if (!ctx
->Extensions
.EXT_transform_feedback
)
2518 v
->value_int64
= ctx
->TransformFeedback
.CurrentObject
->Offset
[index
];
2521 case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE
:
2522 if (index
>= ctx
->Const
.MaxTransformFeedbackBuffers
)
2524 if (!ctx
->Extensions
.EXT_transform_feedback
)
2527 = ctx
->TransformFeedback
.CurrentObject
->RequestedSize
[index
];
2530 case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING
:
2531 if (index
>= ctx
->Const
.MaxTransformFeedbackBuffers
)
2533 if (!ctx
->Extensions
.EXT_transform_feedback
)
2535 v
->value_int
= ctx
->TransformFeedback
.CurrentObject
->BufferNames
[index
];
2538 case GL_UNIFORM_BUFFER_BINDING
:
2539 if (index
>= ctx
->Const
.MaxUniformBufferBindings
)
2541 if (!ctx
->Extensions
.ARB_uniform_buffer_object
)
2543 buf
= ctx
->UniformBufferBindings
[index
].BufferObject
;
2544 v
->value_int
= buf
? buf
->Name
: 0;
2547 case GL_UNIFORM_BUFFER_START
:
2548 if (index
>= ctx
->Const
.MaxUniformBufferBindings
)
2550 if (!ctx
->Extensions
.ARB_uniform_buffer_object
)
2552 v
->value_int
= ctx
->UniformBufferBindings
[index
].Offset
< 0 ? 0 :
2553 ctx
->UniformBufferBindings
[index
].Offset
;
2556 case GL_UNIFORM_BUFFER_SIZE
:
2557 if (index
>= ctx
->Const
.MaxUniformBufferBindings
)
2559 if (!ctx
->Extensions
.ARB_uniform_buffer_object
)
2561 v
->value_int
= ctx
->UniformBufferBindings
[index
].Size
< 0 ? 0 :
2562 ctx
->UniformBufferBindings
[index
].Size
;
2565 /* ARB_shader_storage_buffer_object */
2566 case GL_SHADER_STORAGE_BUFFER_BINDING
:
2567 if (!ctx
->Extensions
.ARB_shader_storage_buffer_object
)
2569 if (index
>= ctx
->Const
.MaxShaderStorageBufferBindings
)
2571 buf
= ctx
->ShaderStorageBufferBindings
[index
].BufferObject
;
2572 v
->value_int
= buf
? buf
->Name
: 0;
2575 case GL_SHADER_STORAGE_BUFFER_START
:
2576 if (!ctx
->Extensions
.ARB_shader_storage_buffer_object
)
2578 if (index
>= ctx
->Const
.MaxShaderStorageBufferBindings
)
2580 v
->value_int
= ctx
->ShaderStorageBufferBindings
[index
].Offset
< 0 ? 0 :
2581 ctx
->ShaderStorageBufferBindings
[index
].Offset
;
2584 case GL_SHADER_STORAGE_BUFFER_SIZE
:
2585 if (!ctx
->Extensions
.ARB_shader_storage_buffer_object
)
2587 if (index
>= ctx
->Const
.MaxShaderStorageBufferBindings
)
2589 v
->value_int
= ctx
->ShaderStorageBufferBindings
[index
].Size
< 0 ? 0 :
2590 ctx
->ShaderStorageBufferBindings
[index
].Size
;
2593 /* ARB_texture_multisample / GL3.2 */
2594 case GL_SAMPLE_MASK_VALUE
:
2597 if (!ctx
->Extensions
.ARB_texture_multisample
)
2599 v
->value_int
= ctx
->Multisample
.SampleMaskValue
;
2602 case GL_ATOMIC_COUNTER_BUFFER_BINDING
:
2603 if (!ctx
->Extensions
.ARB_shader_atomic_counters
)
2605 if (index
>= ctx
->Const
.MaxAtomicBufferBindings
)
2607 buf
= ctx
->AtomicBufferBindings
[index
].BufferObject
;
2608 v
->value_int
= buf
? buf
->Name
: 0;
2611 case GL_ATOMIC_COUNTER_BUFFER_START
:
2612 if (!ctx
->Extensions
.ARB_shader_atomic_counters
)
2614 if (index
>= ctx
->Const
.MaxAtomicBufferBindings
)
2616 v
->value_int64
= ctx
->AtomicBufferBindings
[index
].Offset
< 0 ? 0 :
2617 ctx
->AtomicBufferBindings
[index
].Offset
;
2620 case GL_ATOMIC_COUNTER_BUFFER_SIZE
:
2621 if (!ctx
->Extensions
.ARB_shader_atomic_counters
)
2623 if (index
>= ctx
->Const
.MaxAtomicBufferBindings
)
2625 v
->value_int64
= ctx
->AtomicBufferBindings
[index
].Size
< 0 ? 0 :
2626 ctx
->AtomicBufferBindings
[index
].Size
;
2629 case GL_VERTEX_BINDING_DIVISOR
:
2630 if ((!_mesa_is_desktop_gl(ctx
) || !ctx
->Extensions
.ARB_instanced_arrays
) &&
2631 !_mesa_is_gles31(ctx
))
2633 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
)
2635 v
->value_int
= ctx
->Array
.VAO
->BufferBinding
[VERT_ATTRIB_GENERIC(index
)].InstanceDivisor
;
2638 case GL_VERTEX_BINDING_OFFSET
:
2639 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles31(ctx
))
2641 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
)
2643 v
->value_int
= ctx
->Array
.VAO
->BufferBinding
[VERT_ATTRIB_GENERIC(index
)].Offset
;
2646 case GL_VERTEX_BINDING_STRIDE
:
2647 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles31(ctx
))
2649 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
)
2651 v
->value_int
= ctx
->Array
.VAO
->BufferBinding
[VERT_ATTRIB_GENERIC(index
)].Stride
;
2654 case GL_VERTEX_BINDING_BUFFER
:
2655 if (ctx
->API
== API_OPENGLES2
&& ctx
->Version
< 31)
2657 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
)
2659 buf
= ctx
->Array
.VAO
->BufferBinding
[VERT_ATTRIB_GENERIC(index
)].BufferObj
;
2660 v
->value_int
= buf
? buf
->Name
: 0;
2663 /* ARB_shader_image_load_store */
2664 case GL_IMAGE_BINDING_NAME
: {
2665 struct gl_texture_object
*t
;
2667 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
2669 if (index
>= ctx
->Const
.MaxImageUnits
)
2672 t
= ctx
->ImageUnits
[index
].TexObj
;
2673 v
->value_int
= (t
? t
->Name
: 0);
2677 case GL_IMAGE_BINDING_LEVEL
:
2678 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
2680 if (index
>= ctx
->Const
.MaxImageUnits
)
2683 v
->value_int
= ctx
->ImageUnits
[index
].Level
;
2686 case GL_IMAGE_BINDING_LAYERED
:
2687 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
2689 if (index
>= ctx
->Const
.MaxImageUnits
)
2692 v
->value_int
= ctx
->ImageUnits
[index
].Layered
;
2695 case GL_IMAGE_BINDING_LAYER
:
2696 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
2698 if (index
>= ctx
->Const
.MaxImageUnits
)
2701 v
->value_int
= ctx
->ImageUnits
[index
].Layer
;
2704 case GL_IMAGE_BINDING_ACCESS
:
2705 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
2707 if (index
>= ctx
->Const
.MaxImageUnits
)
2710 v
->value_int
= ctx
->ImageUnits
[index
].Access
;
2713 case GL_IMAGE_BINDING_FORMAT
:
2714 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
2716 if (index
>= ctx
->Const
.MaxImageUnits
)
2719 v
->value_int
= ctx
->ImageUnits
[index
].Format
;
2722 /* ARB_direct_state_access */
2723 case GL_TEXTURE_BINDING_1D
:
2724 case GL_TEXTURE_BINDING_1D_ARRAY
:
2725 case GL_TEXTURE_BINDING_2D
:
2726 case GL_TEXTURE_BINDING_2D_ARRAY
:
2727 case GL_TEXTURE_BINDING_2D_MULTISAMPLE
:
2728 case GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY
:
2729 case GL_TEXTURE_BINDING_3D
:
2730 case GL_TEXTURE_BINDING_BUFFER
:
2731 case GL_TEXTURE_BINDING_CUBE_MAP
:
2732 case GL_TEXTURE_BINDING_CUBE_MAP_ARRAY
:
2733 case GL_TEXTURE_BINDING_RECTANGLE
: {
2736 target
= tex_binding_to_index(ctx
, pname
);
2739 if (index
>= _mesa_max_tex_unit(ctx
))
2742 v
->value_int
= ctx
->Texture
.Unit
[index
].CurrentTex
[target
]->Name
;
2746 case GL_SAMPLER_BINDING
: {
2747 struct gl_sampler_object
*samp
;
2749 if (!_mesa_is_desktop_gl(ctx
) || ctx
->Version
< 33)
2751 if (index
>= _mesa_max_tex_unit(ctx
))
2754 samp
= ctx
->Texture
.Unit
[index
].Sampler
;
2755 v
->value_int
= samp
? samp
->Name
: 0;
2759 case GL_MAX_COMPUTE_WORK_GROUP_COUNT
:
2760 if (!_mesa_has_compute_shaders(ctx
))
2764 v
->value_int
= ctx
->Const
.MaxComputeWorkGroupCount
[index
];
2767 case GL_MAX_COMPUTE_WORK_GROUP_SIZE
:
2768 if (!_mesa_has_compute_shaders(ctx
))
2772 v
->value_int
= ctx
->Const
.MaxComputeWorkGroupSize
[index
];
2775 /* ARB_compute_variable_group_size */
2776 case GL_MAX_COMPUTE_VARIABLE_GROUP_SIZE_ARB
:
2777 if (!ctx
->Extensions
.ARB_compute_variable_group_size
)
2781 v
->value_int
= ctx
->Const
.MaxComputeVariableGroupSize
[index
];
2784 /* GL_EXT_external_objects */
2785 case GL_NUM_DEVICE_UUIDS_EXT
:
2788 case GL_DRIVER_UUID_EXT
:
2791 _mesa_get_driver_uuid(ctx
, v
->value_int_4
);
2793 case GL_DEVICE_UUID_EXT
:
2796 _mesa_get_device_uuid(ctx
, v
->value_int_4
);
2798 /* GL_EXT_direct_state_access */
2802 case GL_TEXTURE_CUBE_MAP
:
2803 case GL_TEXTURE_GEN_S
:
2804 case GL_TEXTURE_GEN_T
:
2805 case GL_TEXTURE_GEN_R
:
2806 case GL_TEXTURE_GEN_Q
:
2807 case GL_TEXTURE_RECTANGLE_ARB
: {
2808 GLuint curTexUnitSave
;
2809 if (index
>= _mesa_max_tex_unit(ctx
))
2811 curTexUnitSave
= ctx
->Texture
.CurrentUnit
;
2812 _mesa_ActiveTexture_no_error(GL_TEXTURE0
+ index
);
2813 v
->value_int
= _mesa_IsEnabled(pname
);
2814 _mesa_ActiveTexture_no_error(GL_TEXTURE0
+ curTexUnitSave
);
2817 case GL_TEXTURE_COORD_ARRAY
: {
2818 GLuint curTexUnitSave
;
2819 if (index
>= ctx
->Const
.MaxTextureCoordUnits
)
2821 curTexUnitSave
= ctx
->Array
.ActiveTexture
;
2822 _mesa_ClientActiveTexture(GL_TEXTURE0
+ index
);
2823 v
->value_int
= _mesa_IsEnabled(pname
);
2824 _mesa_ClientActiveTexture(GL_TEXTURE0
+ curTexUnitSave
);
2827 case GL_TEXTURE_MATRIX
:
2828 if (index
>= ARRAY_SIZE(ctx
->TextureMatrixStack
))
2830 v
->value_matrix
= ctx
->TextureMatrixStack
[index
].Top
;
2832 case GL_TRANSPOSE_TEXTURE_MATRIX
:
2833 if (index
>= ARRAY_SIZE(ctx
->TextureMatrixStack
))
2835 v
->value_matrix
= ctx
->TextureMatrixStack
[index
].Top
;
2836 return TYPE_MATRIX_T
;
2837 /* GL_NV_viewport_swizzle */
2838 case GL_VIEWPORT_SWIZZLE_X_NV
:
2839 if (!ctx
->Extensions
.NV_viewport_swizzle
)
2841 if (index
>= ctx
->Const
.MaxViewports
)
2843 v
->value_int
= ctx
->ViewportArray
[index
].SwizzleX
;
2845 case GL_VIEWPORT_SWIZZLE_Y_NV
:
2846 if (!ctx
->Extensions
.NV_viewport_swizzle
)
2848 if (index
>= ctx
->Const
.MaxViewports
)
2850 v
->value_int
= ctx
->ViewportArray
[index
].SwizzleY
;
2852 case GL_VIEWPORT_SWIZZLE_Z_NV
:
2853 if (!ctx
->Extensions
.NV_viewport_swizzle
)
2855 if (index
>= ctx
->Const
.MaxViewports
)
2857 v
->value_int
= ctx
->ViewportArray
[index
].SwizzleZ
;
2859 case GL_VIEWPORT_SWIZZLE_W_NV
:
2860 if (!ctx
->Extensions
.NV_viewport_swizzle
)
2862 if (index
>= ctx
->Const
.MaxViewports
)
2864 v
->value_int
= ctx
->ViewportArray
[index
].SwizzleW
;
2869 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(pname=%s)", func
,
2870 _mesa_enum_to_string(pname
));
2871 return TYPE_INVALID
;
2873 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(pname=%s)", func
,
2874 _mesa_enum_to_string(pname
));
2875 return TYPE_INVALID
;
2879 _mesa_GetBooleani_v( GLenum pname
, GLuint index
, GLboolean
*params
)
2882 enum value_type type
=
2883 find_value_indexed("glGetBooleani_v", pname
, index
, &v
);
2888 params
[0] = INT_TO_BOOLEAN(v
.value_int
);
2892 params
[0] = INT_TO_BOOLEAN(v
.value_int_4
[0]);
2893 params
[1] = INT_TO_BOOLEAN(v
.value_int_4
[1]);
2894 params
[2] = INT_TO_BOOLEAN(v
.value_int_4
[2]);
2895 params
[3] = INT_TO_BOOLEAN(v
.value_int_4
[3]);
2898 params
[0] = INT64_TO_BOOLEAN(v
.value_int64
);
2901 ; /* nothing - GL error was recorded */
2906 _mesa_GetIntegeri_v( GLenum pname
, GLuint index
, GLint
*params
)
2909 enum value_type type
=
2910 find_value_indexed("glGetIntegeri_v", pname
, index
, &v
);
2915 params
[3] = lroundf(v
.value_float_4
[3]);
2918 params
[2] = lroundf(v
.value_float_4
[2]);
2921 params
[1] = lroundf(v
.value_float_4
[1]);
2924 params
[0] = lroundf(v
.value_float_4
[0]);
2927 case TYPE_DOUBLEN_2
:
2928 params
[1] = lroundf(v
.value_double_2
[1]);
2930 params
[0] = lroundf(v
.value_double_2
[0]);
2935 params
[0] = v
.value_int
;
2939 params
[0] = v
.value_int_4
[0];
2940 params
[1] = v
.value_int_4
[1];
2941 params
[2] = v
.value_int_4
[2];
2942 params
[3] = v
.value_int_4
[3];
2945 params
[0] = INT64_TO_INT(v
.value_int64
);
2948 ; /* nothing - GL error was recorded */
2953 _mesa_GetInteger64i_v( GLenum pname
, GLuint index
, GLint64
*params
)
2956 enum value_type type
=
2957 find_value_indexed("glGetInteger64i_v", pname
, index
, &v
);
2961 params
[0] = v
.value_int
;
2964 params
[0] = v
.value_int_4
[0];
2965 params
[1] = v
.value_int_4
[1];
2966 params
[2] = v
.value_int_4
[2];
2967 params
[3] = v
.value_int_4
[3];
2970 params
[0] = (GLuint
) v
.value_int
;
2973 params
[0] = (GLuint
) v
.value_int_4
[0];
2974 params
[1] = (GLuint
) v
.value_int_4
[1];
2975 params
[2] = (GLuint
) v
.value_int_4
[2];
2976 params
[3] = (GLuint
) v
.value_int_4
[3];
2979 params
[0] = v
.value_int64
;
2982 ; /* nothing - GL error was recorded */
2987 _mesa_GetFloati_v(GLenum pname
, GLuint index
, GLfloat
*params
)
2992 enum value_type type
=
2993 find_value_indexed("glGetFloati_v", pname
, index
, &v
);
2998 params
[3] = v
.value_float_4
[3];
3001 params
[2] = v
.value_float_4
[2];
3004 params
[1] = v
.value_float_4
[1];
3007 params
[0] = v
.value_float_4
[0];
3010 case TYPE_DOUBLEN_2
:
3011 params
[1] = (GLfloat
) v
.value_double_2
[1];
3013 params
[0] = (GLfloat
) v
.value_double_2
[0];
3017 params
[3] = (GLfloat
) v
.value_int_4
[3];
3019 params
[2] = (GLfloat
) v
.value_int_4
[2];
3022 params
[1] = (GLfloat
) v
.value_int_4
[1];
3026 params
[0] = (GLfloat
) v
.value_int_4
[0];
3030 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
3031 params
[i
] = (GLfloat
) v
.value_int_n
.ints
[i
];
3035 params
[3] = (GLfloat
) ((GLuint
) v
.value_int_4
[3]);
3037 params
[2] = (GLfloat
) ((GLuint
) v
.value_int_4
[2]);
3039 params
[1] = (GLfloat
) ((GLuint
) v
.value_int_4
[1]);
3041 params
[0] = (GLfloat
) ((GLuint
) v
.value_int_4
[0]);
3045 params
[0] = (GLfloat
) v
.value_int64
;
3049 params
[0] = BOOLEAN_TO_FLOAT(v
.value_bool
);
3053 params
[0] = (GLfloat
) v
.value_ubyte
;
3057 params
[0] = (GLfloat
) v
.value_short
;
3061 m
= *(GLmatrix
**) &v
;
3062 for (i
= 0; i
< 16; i
++)
3063 params
[i
] = m
->m
[i
];
3067 m
= *(GLmatrix
**) &v
;
3068 for (i
= 0; i
< 16; i
++)
3069 params
[i
] = m
->m
[transpose
[i
]];
3078 _mesa_GetDoublei_v(GLenum pname
, GLuint index
, GLdouble
*params
)
3083 enum value_type type
=
3084 find_value_indexed("glGetDoublei_v", pname
, index
, &v
);
3089 params
[3] = (GLdouble
) v
.value_float_4
[3];
3092 params
[2] = (GLdouble
) v
.value_float_4
[2];
3095 params
[1] = (GLdouble
) v
.value_float_4
[1];
3098 params
[0] = (GLdouble
) v
.value_float_4
[0];
3101 case TYPE_DOUBLEN_2
:
3102 params
[1] = v
.value_double_2
[1];
3104 params
[0] = v
.value_double_2
[0];
3108 params
[3] = (GLdouble
) v
.value_int_4
[3];
3110 params
[2] = (GLdouble
) v
.value_int_4
[2];
3113 params
[1] = (GLdouble
) v
.value_int_4
[1];
3117 params
[0] = (GLdouble
) v
.value_int_4
[0];
3121 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
3122 params
[i
] = (GLdouble
) v
.value_int_n
.ints
[i
];
3126 params
[3] = (GLdouble
) ((GLuint
) v
.value_int_4
[3]);
3128 params
[2] = (GLdouble
) ((GLuint
) v
.value_int_4
[2]);
3130 params
[1] = (GLdouble
) ((GLuint
) v
.value_int_4
[1]);
3132 params
[0] = (GLdouble
) ((GLuint
) v
.value_int_4
[0]);
3136 params
[0] = (GLdouble
) v
.value_int64
;
3140 params
[0] = (GLdouble
) BOOLEAN_TO_FLOAT(v
.value_bool
);
3144 params
[0] = (GLdouble
) v
.value_ubyte
;
3148 params
[0] = (GLdouble
) v
.value_short
;
3152 m
= *(GLmatrix
**) &v
;
3153 for (i
= 0; i
< 16; i
++)
3154 params
[i
] = (GLdouble
) m
->m
[i
];
3158 m
= *(GLmatrix
**) &v
;
3159 for (i
= 0; i
< 16; i
++)
3160 params
[i
] = (GLdouble
) m
->m
[transpose
[i
]];
3169 _mesa_GetUnsignedBytei_vEXT(GLenum target
, GLuint index
, GLubyte
*data
)
3173 enum value_type type
;
3174 const char *func
= "glGetUnsignedBytei_vEXT";
3176 GET_CURRENT_CONTEXT(ctx
);
3178 if (!ctx
->Extensions
.EXT_memory_object
) {
3179 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(unsupported)", func
);
3183 type
= find_value_indexed(func
, target
, index
, &v
);
3184 size
= get_value_size(type
, &v
);
3186 _mesa_problem(ctx
, "invalid value type in GetUnsignedBytei_vEXT()");
3215 case TYPE_DOUBLEN_2
:
3218 memcpy(data
, &v
.value_int
, size
);
3221 memcpy(data
, &v
.value_int_n
.ints
, size
);
3224 break; /* nothing - GL error was recorded */
3229 _mesa_GetFixedv(GLenum pname
, GLfixed
*params
)
3231 const struct value_desc
*d
;
3237 d
= find_value("glGetDoublev", pname
, &p
, &v
);
3242 params
[0] = INT_TO_FIXED(d
->offset
);
3247 params
[3] = FLOAT_TO_FIXED(((GLfloat
*) p
)[3]);
3250 params
[2] = FLOAT_TO_FIXED(((GLfloat
*) p
)[2]);
3253 params
[1] = FLOAT_TO_FIXED(((GLfloat
*) p
)[1]);
3256 params
[0] = FLOAT_TO_FIXED(((GLfloat
*) p
)[0]);
3259 case TYPE_DOUBLEN_2
:
3260 params
[1] = FLOAT_TO_FIXED(((GLdouble
*) p
)[1]);
3262 params
[0] = FLOAT_TO_FIXED(((GLdouble
*) p
)[0]);
3267 params
[3] = INT_TO_FIXED(((GLint
*) p
)[3]);
3270 params
[2] = INT_TO_FIXED(((GLint
*) p
)[2]);
3274 params
[1] = INT_TO_FIXED(((GLint
*) p
)[1]);
3278 params
[0] = INT_TO_FIXED(((GLint
*) p
)[0]);
3282 params
[0] = INT_TO_FIXED((GLint
)(((GLenum16
*) p
)[0]));
3286 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
3287 params
[i
] = INT_TO_FIXED(v
.value_int_n
.ints
[i
]);
3291 params
[0] = ((GLint64
*) p
)[0];
3295 params
[0] = BOOLEAN_TO_FIXED(((GLboolean
*) p
)[0]);
3299 params
[0] = INT_TO_FIXED(((GLubyte
*) p
)[0]);
3303 params
[0] = INT_TO_FIXED(((GLshort
*) p
)[0]);
3307 m
= *(GLmatrix
**) p
;
3308 for (i
= 0; i
< 16; i
++)
3309 params
[i
] = FLOAT_TO_FIXED(m
->m
[i
]);
3313 m
= *(GLmatrix
**) p
;
3314 for (i
= 0; i
< 16; i
++)
3315 params
[i
] = FLOAT_TO_FIXED(m
->m
[transpose
[i
]]);
3326 shift
= d
->type
- TYPE_BIT_0
;
3327 params
[0] = BOOLEAN_TO_FIXED((*(GLbitfield
*) p
>> shift
) & 1);