2 * Copyright (C) 2010 Brian Paul All Rights Reserved.
3 * Copyright (C) 2010 Intel Corporation
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included
13 * in all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
19 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
21 * OTHER DEALINGS IN THE SOFTWARE.
23 * Author: Kristian Høgsberg <krh@bitplanet.net>
29 #include "debug_output.h"
33 #include "extensions.h"
38 #include "texcompress.h"
40 #include "framebuffer.h"
41 #include "samplerobj.h"
45 /* This is a table driven implemetation of the glGet*v() functions.
46 * The basic idea is that most getters just look up an int somewhere
47 * in struct gl_context and then convert it to a bool or float according to
48 * which of glGetIntegerv() glGetBooleanv() etc is being called.
49 * Instead of generating code to do this, we can just record the enum
50 * value and the offset into struct gl_context in an array of structs. Then
51 * in glGet*(), we lookup the struct for the enum in question, and use
52 * the offset to get the int we need.
54 * Sometimes we need to look up a float, a boolean, a bit in a
55 * bitfield, a matrix or other types instead, so we need to track the
56 * type of the value in struct gl_context. And sometimes the value isn't in
57 * struct gl_context but in the drawbuffer, the array object, current texture
58 * unit, or maybe it's a computed value. So we need to also track
59 * where or how to find the value. Finally, we sometimes need to
60 * check that one of a number of extensions are enabled, the GL
61 * version or flush or call _mesa_update_state(). This is done by
62 * attaching optional extra information to the value description
63 * struct, it's sort of like an array of opcodes that describe extra
66 * Putting all this together we end up with struct value_desc below,
67 * and with a couple of macros to help, the table of struct value_desc
68 * is about as concise as the specification in the old python script.
71 #define FLOAT_TO_BOOLEAN(X) ( (X) ? GL_TRUE : GL_FALSE )
72 #define FLOAT_TO_FIXED(F) ( ((F) * 65536.0f > INT_MAX) ? INT_MAX : \
73 ((F) * 65536.0f < INT_MIN) ? INT_MIN : \
74 (GLint) ((F) * 65536.0f) )
76 #define INT_TO_BOOLEAN(I) ( (I) ? GL_TRUE : GL_FALSE )
77 #define INT_TO_FIXED(I) ( ((I) > SHRT_MAX) ? INT_MAX : \
78 ((I) < SHRT_MIN) ? INT_MIN : \
79 (GLint) ((I) * 65536) )
81 #define INT64_TO_BOOLEAN(I) ( (I) ? GL_TRUE : GL_FALSE )
82 #define INT64_TO_INT(I) ( (GLint)((I > INT_MAX) ? INT_MAX : ((I < INT_MIN) ? INT_MIN : (I))) )
84 #define BOOLEAN_TO_INT(B) ( (GLint) (B) )
85 #define BOOLEAN_TO_INT64(B) ( (GLint64) (B) )
86 #define BOOLEAN_TO_FLOAT(B) ( (B) ? 1.0F : 0.0F )
87 #define BOOLEAN_TO_FIXED(B) ( (GLint) ((B) ? 1 : 0) << 16 )
89 #define ENUM_TO_INT64(E) ( (GLint64) (E) )
90 #define ENUM_TO_FIXED(E) (E)
131 enum value_location
{
152 EXTRA_NEW_FRAG_CLAMP
,
153 EXTRA_VALID_DRAW_BUFFER
,
154 EXTRA_VALID_TEXTURE_UNIT
,
155 EXTRA_VALID_CLIP_DISTANCE
,
159 EXTRA_EXT_ATOMICS_GS
,
160 EXTRA_EXT_SHADER_IMAGE_GS
,
161 EXTRA_EXT_ATOMICS_TESS
,
162 EXTRA_EXT_SHADER_IMAGE_TESS
,
164 EXTRA_EXT_FB_NO_ATTACH_GS
,
166 EXTRA_EXT_PROVOKING_VERTEX_32
,
169 #define NO_EXTRA NULL
174 GLubyte location
; /**< enum value_location */
175 GLubyte type
; /**< enum value_type */
182 GLfloat value_float_4
[4];
183 GLdouble value_double_2
[2];
184 GLmatrix
*value_matrix
;
186 GLint value_int_4
[4];
190 /* Sigh, see GL_COMPRESSED_TEXTURE_FORMATS_ARB handling */
194 GLboolean value_bool
;
197 #define BUFFER_FIELD(field, type) \
198 LOC_BUFFER, type, offsetof(struct gl_framebuffer, field)
199 #define CONTEXT_FIELD(field, type) \
200 LOC_CONTEXT, type, offsetof(struct gl_context, field)
201 #define ARRAY_FIELD(field, type) \
202 LOC_ARRAY, type, offsetof(struct gl_vertex_array_object, field)
203 #undef CONST /* already defined through windows.h */
204 #define CONST(value) \
205 LOC_CONTEXT, TYPE_CONST, value
207 #define BUFFER_INT(field) BUFFER_FIELD(field, TYPE_INT)
208 #define BUFFER_ENUM(field) BUFFER_FIELD(field, TYPE_ENUM)
209 #define BUFFER_BOOL(field) BUFFER_FIELD(field, TYPE_BOOLEAN)
211 #define CONTEXT_INT(field) CONTEXT_FIELD(field, TYPE_INT)
212 #define CONTEXT_INT2(field) CONTEXT_FIELD(field, TYPE_INT_2)
213 #define CONTEXT_INT64(field) CONTEXT_FIELD(field, TYPE_INT64)
214 #define CONTEXT_UINT(field) CONTEXT_FIELD(field, TYPE_UINT)
215 #define CONTEXT_ENUM(field) CONTEXT_FIELD(field, TYPE_ENUM)
216 #define CONTEXT_ENUM2(field) CONTEXT_FIELD(field, TYPE_ENUM_2)
217 #define CONTEXT_BOOL(field) CONTEXT_FIELD(field, TYPE_BOOLEAN)
218 #define CONTEXT_BIT0(field) CONTEXT_FIELD(field, TYPE_BIT_0)
219 #define CONTEXT_BIT1(field) CONTEXT_FIELD(field, TYPE_BIT_1)
220 #define CONTEXT_BIT2(field) CONTEXT_FIELD(field, TYPE_BIT_2)
221 #define CONTEXT_BIT3(field) CONTEXT_FIELD(field, TYPE_BIT_3)
222 #define CONTEXT_BIT4(field) CONTEXT_FIELD(field, TYPE_BIT_4)
223 #define CONTEXT_BIT5(field) CONTEXT_FIELD(field, TYPE_BIT_5)
224 #define CONTEXT_BIT6(field) CONTEXT_FIELD(field, TYPE_BIT_6)
225 #define CONTEXT_BIT7(field) CONTEXT_FIELD(field, TYPE_BIT_7)
226 #define CONTEXT_FLOAT(field) CONTEXT_FIELD(field, TYPE_FLOAT)
227 #define CONTEXT_FLOAT2(field) CONTEXT_FIELD(field, TYPE_FLOAT_2)
228 #define CONTEXT_FLOAT3(field) CONTEXT_FIELD(field, TYPE_FLOAT_3)
229 #define CONTEXT_FLOAT4(field) CONTEXT_FIELD(field, TYPE_FLOAT_4)
230 #define CONTEXT_FLOAT8(field) CONTEXT_FIELD(field, TYPE_FLOAT_8)
231 #define CONTEXT_MATRIX(field) CONTEXT_FIELD(field, TYPE_MATRIX)
232 #define CONTEXT_MATRIX_T(field) CONTEXT_FIELD(field, TYPE_MATRIX_T)
234 #define ARRAY_INT(field) ARRAY_FIELD(field, TYPE_INT)
235 #define ARRAY_ENUM(field) ARRAY_FIELD(field, TYPE_ENUM)
236 #define ARRAY_BOOL(field) ARRAY_FIELD(field, TYPE_BOOLEAN)
239 offsetof(struct gl_extensions, f)
241 #define EXTRA_EXT(e) \
242 static const int extra_##e[] = { \
246 #define EXTRA_EXT2(e1, e2) \
247 static const int extra_##e1##_##e2[] = { \
248 EXT(e1), EXT(e2), EXTRA_END \
251 /* The 'extra' mechanism is a way to specify extra checks (such as
252 * extensions or specific gl versions) or actions (flush current, new
253 * buffers) that we need to do before looking up an enum. We need to
254 * declare them all up front so we can refer to them in the value_desc
257 * Each EXTRA_ will be executed. For EXTRA_* enums of extensions and API
258 * versions, listing multiple ones in an array means an error will be thrown
259 * only if none of them are available. If you need to check for "AND"
260 * behavior, you would need to make a custom EXTRA_ enum.
263 static const int extra_new_buffers
[] = {
268 static const int extra_new_frag_clamp
[] = {
269 EXTRA_NEW_FRAG_CLAMP
,
273 static const int extra_valid_draw_buffer
[] = {
274 EXTRA_VALID_DRAW_BUFFER
,
278 static const int extra_valid_texture_unit
[] = {
279 EXTRA_VALID_TEXTURE_UNIT
,
283 static const int extra_valid_clip_distance
[] = {
284 EXTRA_VALID_CLIP_DISTANCE
,
288 static const int extra_flush_current_valid_texture_unit
[] = {
290 EXTRA_VALID_TEXTURE_UNIT
,
294 static const int extra_flush_current
[] = {
299 static const int extra_EXT_texture_integer_and_new_buffers
[] = {
300 EXT(EXT_texture_integer
),
305 static const int extra_GLSL_130_es3
[] = {
311 static const int extra_texture_buffer_object
[] = {
312 EXT(ARB_texture_buffer_object
),
316 static const int extra_ARB_transform_feedback2_api_es3
[] = {
317 EXT(ARB_transform_feedback2
),
322 static const int extra_ARB_uniform_buffer_object_and_geometry_shader
[] = {
327 static const int extra_ARB_ES2_compatibility_api_es2
[] = {
328 EXT(ARB_ES2_compatibility
),
333 static const int extra_ARB_ES3_compatibility_api_es3
[] = {
334 EXT(ARB_ES3_compatibility
),
339 static const int extra_EXT_framebuffer_sRGB_and_new_buffers
[] = {
340 EXT(EXT_framebuffer_sRGB
),
345 static const int extra_EXT_packed_float
[] = {
346 EXT(EXT_packed_float
),
351 static const int extra_EXT_texture_array_es3
[] = {
352 EXT(EXT_texture_array
),
357 static const int extra_ARB_shader_atomic_counters_and_geometry_shader
[] = {
358 EXTRA_EXT_ATOMICS_GS
,
362 static const int extra_ARB_shader_image_load_store_and_geometry_shader
[] = {
363 EXTRA_EXT_SHADER_IMAGE_GS
,
367 static const int extra_ARB_shader_atomic_counters_and_tessellation
[] = {
368 EXTRA_EXT_ATOMICS_TESS
,
372 static const int extra_ARB_shader_image_load_store_and_tessellation
[] = {
373 EXTRA_EXT_SHADER_IMAGE_TESS
,
377 /* HACK: remove when ARB_compute_shader is actually supported */
378 static const int extra_ARB_compute_shader_es31
[] = {
379 EXT(ARB_compute_shader
),
384 static const int extra_ARB_shader_storage_buffer_object_es31
[] = {
385 EXT(ARB_shader_storage_buffer_object
),
390 static const int extra_ARB_shader_storage_buffer_object_and_geometry_shader
[] = {
395 static const int extra_ARB_shader_image_load_store_shader_storage_buffer_object_es31
[] = {
396 EXT(ARB_shader_image_load_store
),
397 EXT(ARB_shader_storage_buffer_object
),
402 static const int extra_ARB_framebuffer_no_attachments_and_geometry_shader
[] = {
403 EXTRA_EXT_FB_NO_ATTACH_GS
,
407 static const int extra_ARB_viewport_array_or_oes_geometry_shader
[] = {
408 EXT(ARB_viewport_array
),
413 static const int extra_ARB_viewport_array_or_oes_viewport_array
[] = {
414 EXT(ARB_viewport_array
),
415 EXT(OES_viewport_array
),
419 static const int extra_ARB_gpu_shader5_or_oes_geometry_shader
[] = {
420 EXT(ARB_gpu_shader5
),
425 static const int extra_ARB_gpu_shader5_or_OES_sample_variables
[] = {
426 EXT(ARB_gpu_shader5
),
427 EXT(OES_sample_variables
),
431 static const int extra_ES32
[] = {
432 EXT(ARB_ES3_2_compatibility
),
437 static const int extra_KHR_robustness_or_GL
[] = {
444 static const int extra_INTEL_conservative_rasterization
[] = {
445 EXT(INTEL_conservative_rasterization
),
449 EXTRA_EXT(ARB_texture_cube_map
);
450 EXTRA_EXT(EXT_texture_array
);
451 EXTRA_EXT(NV_fog_distance
);
452 EXTRA_EXT(EXT_texture_filter_anisotropic
);
453 EXTRA_EXT(NV_point_sprite
);
454 EXTRA_EXT(NV_texture_rectangle
);
455 EXTRA_EXT(EXT_stencil_two_side
);
456 EXTRA_EXT(EXT_depth_bounds_test
);
457 EXTRA_EXT(ARB_depth_clamp
);
458 EXTRA_EXT(ATI_fragment_shader
);
459 EXTRA_EXT(EXT_provoking_vertex
);
460 EXTRA_EXT(ARB_fragment_shader
);
461 EXTRA_EXT(ARB_fragment_program
);
462 EXTRA_EXT2(ARB_framebuffer_object
, EXT_framebuffer_multisample
);
463 EXTRA_EXT(ARB_seamless_cube_map
);
465 EXTRA_EXT(ARB_vertex_shader
);
466 EXTRA_EXT(EXT_transform_feedback
);
467 EXTRA_EXT(ARB_transform_feedback3
);
468 EXTRA_EXT(EXT_pixel_buffer_object
);
469 EXTRA_EXT(ARB_vertex_program
);
470 EXTRA_EXT2(NV_point_sprite
, ARB_point_sprite
);
471 EXTRA_EXT2(ARB_vertex_program
, ARB_fragment_program
);
472 EXTRA_EXT(ARB_color_buffer_float
);
473 EXTRA_EXT(EXT_framebuffer_sRGB
);
474 EXTRA_EXT(OES_EGL_image_external
);
475 EXTRA_EXT(ARB_blend_func_extended
);
476 EXTRA_EXT(ARB_uniform_buffer_object
);
477 EXTRA_EXT(ARB_timer_query
);
478 EXTRA_EXT2(ARB_texture_cube_map_array
, OES_texture_cube_map_array
);
479 EXTRA_EXT(ARB_texture_buffer_range
);
480 EXTRA_EXT(ARB_texture_multisample
);
481 EXTRA_EXT(ARB_texture_gather
);
482 EXTRA_EXT(ARB_shader_atomic_counters
);
483 EXTRA_EXT(ARB_draw_indirect
);
484 EXTRA_EXT(ARB_shader_image_load_store
);
485 EXTRA_EXT(ARB_query_buffer_object
);
486 EXTRA_EXT2(ARB_transform_feedback3
, ARB_gpu_shader5
);
487 EXTRA_EXT(INTEL_performance_query
);
488 EXTRA_EXT(ARB_explicit_uniform_location
);
489 EXTRA_EXT(ARB_clip_control
);
490 EXTRA_EXT(ARB_polygon_offset_clamp
);
491 EXTRA_EXT(ARB_framebuffer_no_attachments
);
492 EXTRA_EXT(ARB_tessellation_shader
);
493 EXTRA_EXT(ARB_shader_storage_buffer_object
);
494 EXTRA_EXT(ARB_indirect_parameters
);
495 EXTRA_EXT(ATI_meminfo
);
496 EXTRA_EXT(NVX_gpu_memory_info
);
497 EXTRA_EXT(ARB_cull_distance
);
498 EXTRA_EXT(EXT_window_rectangles
);
499 EXTRA_EXT(KHR_blend_equation_advanced_coherent
);
500 EXTRA_EXT(OES_primitive_bounding_box
);
501 EXTRA_EXT(ARB_compute_variable_group_size
);
502 EXTRA_EXT(KHR_robustness
);
503 EXTRA_EXT(ARB_sparse_buffer
);
506 extra_ARB_color_buffer_float_or_glcore
[] = {
507 EXT(ARB_color_buffer_float
),
513 extra_NV_primitive_restart
[] = {
514 EXT(NV_primitive_restart
),
518 static const int extra_version_30
[] = { EXTRA_VERSION_30
, EXTRA_END
};
519 static const int extra_version_31
[] = { EXTRA_VERSION_31
, EXTRA_END
};
520 static const int extra_version_32
[] = { EXTRA_VERSION_32
, EXTRA_END
};
522 static const int extra_gl30_es3
[] = {
528 static const int extra_gl32_es3
[] = {
534 static const int extra_version_32_OES_geometry_shader
[] = {
540 static const int extra_gl40_ARB_sample_shading
[] = {
542 EXT(ARB_sample_shading
),
547 extra_ARB_vertex_program_api_es2
[] = {
548 EXT(ARB_vertex_program
),
553 /* The ReadBuffer get token is valid under either full GL or under
554 * GLES2 if the NV_read_buffer extension is available. */
556 extra_NV_read_buffer_api_gl
[] = {
562 static const int extra_core_ARB_color_buffer_float_and_new_buffers
[] = {
564 EXT(ARB_color_buffer_float
),
569 static const int extra_EXT_shader_framebuffer_fetch
[] = {
572 EXT(MESA_shader_framebuffer_fetch
),
576 static const int extra_EXT_provoking_vertex_32
[] = {
577 EXTRA_EXT_PROVOKING_VERTEX_32
,
581 static const int extra_EXT_disjoint_timer_query
[] = {
584 EXT(EXT_disjoint_timer_query
),
589 /* This is the big table describing all the enums we accept in
590 * glGet*v(). The table is partitioned into six parts: enums
591 * understood by all GL APIs (OpenGL, GLES and GLES2), enums shared
592 * between OpenGL and GLES, enums exclusive to GLES, etc for the
593 * remaining combinations. To look up the enums valid in a given API
594 * we will use a hash table specific to that API. These tables are in
595 * turn generated at build time and included through get_hash.h.
598 #include "get_hash.h"
600 /* All we need now is a way to look up the value struct from the enum.
601 * The code generated by gcc for the old generated big switch
602 * statement is a big, balanced, open coded if/else tree, essentially
603 * an unrolled binary search. It would be natural to sort the new
604 * enum table and use bsearch(), but we will use a read-only hash
605 * table instead. bsearch() has a nice guaranteed worst case
606 * performance, but we're also guaranteed to hit that worst case
607 * (log2(n) iterations) for about half the enums. Instead, using an
608 * open addressing hash table, we can find the enum on the first try
609 * for 80% of the enums, 1 collision for 10% and never more than 5
610 * collisions for any enum (typical numbers). And the code is very
611 * simple, even though it feels a little magic. */
614 * Handle irregular enums
616 * Some values don't conform to the "well-known type at context
617 * pointer + offset" pattern, so we have this function to catch all
618 * the corner cases. Typically, it's a computed value or a one-off
619 * pointer to a custom struct or something.
621 * In this case we can't return a pointer to the value, so we'll have
622 * to use the temporary variable 'v' declared back in the calling
623 * glGet*v() function to store the result.
625 * \param ctx the current context
626 * \param d the struct value_desc that describes the enum
627 * \param v pointer to the tmp declared in the calling glGet*v() function
630 find_custom_value(struct gl_context
*ctx
, const struct value_desc
*d
, union value
*v
)
632 struct gl_buffer_object
**buffer_obj
;
633 struct gl_array_attributes
*array
;
637 case GL_MAJOR_VERSION
:
638 v
->value_int
= ctx
->Version
/ 10;
640 case GL_MINOR_VERSION
:
641 v
->value_int
= ctx
->Version
% 10;
647 case GL_TEXTURE_CUBE_MAP
:
648 case GL_TEXTURE_RECTANGLE_NV
:
649 case GL_TEXTURE_EXTERNAL_OES
:
650 v
->value_bool
= _mesa_IsEnabled(d
->pname
);
653 case GL_LINE_STIPPLE_PATTERN
:
654 /* This is the only GLushort, special case it here by promoting
655 * to an int rather than introducing a new type. */
656 v
->value_int
= ctx
->Line
.StipplePattern
;
659 case GL_CURRENT_RASTER_TEXTURE_COORDS
:
660 unit
= ctx
->Texture
.CurrentUnit
;
661 v
->value_float_4
[0] = ctx
->Current
.RasterTexCoords
[unit
][0];
662 v
->value_float_4
[1] = ctx
->Current
.RasterTexCoords
[unit
][1];
663 v
->value_float_4
[2] = ctx
->Current
.RasterTexCoords
[unit
][2];
664 v
->value_float_4
[3] = ctx
->Current
.RasterTexCoords
[unit
][3];
667 case GL_CURRENT_TEXTURE_COORDS
:
668 unit
= ctx
->Texture
.CurrentUnit
;
669 v
->value_float_4
[0] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
][0];
670 v
->value_float_4
[1] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
][1];
671 v
->value_float_4
[2] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
][2];
672 v
->value_float_4
[3] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
][3];
675 case GL_COLOR_WRITEMASK
:
676 v
->value_int_4
[0] = ctx
->Color
.ColorMask
[0][RCOMP
] ? 1 : 0;
677 v
->value_int_4
[1] = ctx
->Color
.ColorMask
[0][GCOMP
] ? 1 : 0;
678 v
->value_int_4
[2] = ctx
->Color
.ColorMask
[0][BCOMP
] ? 1 : 0;
679 v
->value_int_4
[3] = ctx
->Color
.ColorMask
[0][ACOMP
] ? 1 : 0;
683 v
->value_bool
= ctx
->Current
.Attrib
[VERT_ATTRIB_EDGEFLAG
][0] == 1.0F
;
687 v
->value_enum
= ctx
->ReadBuffer
->ColorReadBuffer
;
690 case GL_MAP2_GRID_DOMAIN
:
691 v
->value_float_4
[0] = ctx
->Eval
.MapGrid2u1
;
692 v
->value_float_4
[1] = ctx
->Eval
.MapGrid2u2
;
693 v
->value_float_4
[2] = ctx
->Eval
.MapGrid2v1
;
694 v
->value_float_4
[3] = ctx
->Eval
.MapGrid2v2
;
697 case GL_TEXTURE_STACK_DEPTH
:
698 unit
= ctx
->Texture
.CurrentUnit
;
699 v
->value_int
= ctx
->TextureMatrixStack
[unit
].Depth
+ 1;
701 case GL_TEXTURE_MATRIX
:
702 unit
= ctx
->Texture
.CurrentUnit
;
703 v
->value_matrix
= ctx
->TextureMatrixStack
[unit
].Top
;
706 case GL_TEXTURE_COORD_ARRAY
:
707 case GL_TEXTURE_COORD_ARRAY_SIZE
:
708 case GL_TEXTURE_COORD_ARRAY_TYPE
:
709 case GL_TEXTURE_COORD_ARRAY_STRIDE
:
710 array
= &ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_TEX(ctx
->Array
.ActiveTexture
)];
711 v
->value_int
= *(GLuint
*) ((char *) array
+ d
->offset
);
714 case GL_ACTIVE_TEXTURE_ARB
:
715 v
->value_int
= GL_TEXTURE0_ARB
+ ctx
->Texture
.CurrentUnit
;
717 case GL_CLIENT_ACTIVE_TEXTURE_ARB
:
718 v
->value_int
= GL_TEXTURE0_ARB
+ ctx
->Array
.ActiveTexture
;
721 case GL_MODELVIEW_STACK_DEPTH
:
722 case GL_PROJECTION_STACK_DEPTH
:
723 v
->value_int
= *(GLint
*) ((char *) ctx
+ d
->offset
) + 1;
726 case GL_MAX_TEXTURE_SIZE
:
727 case GL_MAX_3D_TEXTURE_SIZE
:
728 case GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB
:
729 p
= (GLuint
*) ((char *) ctx
+ d
->offset
);
730 v
->value_int
= 1 << (*p
- 1);
734 v
->value_int_4
[0] = ctx
->Scissor
.ScissorArray
[0].X
;
735 v
->value_int_4
[1] = ctx
->Scissor
.ScissorArray
[0].Y
;
736 v
->value_int_4
[2] = ctx
->Scissor
.ScissorArray
[0].Width
;
737 v
->value_int_4
[3] = ctx
->Scissor
.ScissorArray
[0].Height
;
740 case GL_SCISSOR_TEST
:
741 v
->value_bool
= ctx
->Scissor
.EnableFlags
& 1;
746 ctx
->ListState
.CurrentList
? ctx
->ListState
.CurrentList
->Name
: 0;
749 if (!ctx
->CompileFlag
)
751 else if (ctx
->ExecuteFlag
)
752 v
->value_enum
= GL_COMPILE_AND_EXECUTE
;
754 v
->value_enum
= GL_COMPILE
;
758 v
->value_float_4
[0] = ctx
->ViewportArray
[0].X
;
759 v
->value_float_4
[1] = ctx
->ViewportArray
[0].Y
;
760 v
->value_float_4
[2] = ctx
->ViewportArray
[0].Width
;
761 v
->value_float_4
[3] = ctx
->ViewportArray
[0].Height
;
765 v
->value_double_2
[0] = ctx
->ViewportArray
[0].Near
;
766 v
->value_double_2
[1] = ctx
->ViewportArray
[0].Far
;
769 case GL_ACTIVE_STENCIL_FACE_EXT
:
770 v
->value_enum
= ctx
->Stencil
.ActiveFace
? GL_BACK
: GL_FRONT
;
773 case GL_STENCIL_FAIL
:
774 v
->value_enum
= ctx
->Stencil
.FailFunc
[ctx
->Stencil
.ActiveFace
];
776 case GL_STENCIL_FUNC
:
777 v
->value_enum
= ctx
->Stencil
.Function
[ctx
->Stencil
.ActiveFace
];
779 case GL_STENCIL_PASS_DEPTH_FAIL
:
780 v
->value_enum
= ctx
->Stencil
.ZFailFunc
[ctx
->Stencil
.ActiveFace
];
782 case GL_STENCIL_PASS_DEPTH_PASS
:
783 v
->value_enum
= ctx
->Stencil
.ZPassFunc
[ctx
->Stencil
.ActiveFace
];
786 v
->value_int
= _mesa_get_stencil_ref(ctx
, ctx
->Stencil
.ActiveFace
);
788 case GL_STENCIL_BACK_REF
:
789 v
->value_int
= _mesa_get_stencil_ref(ctx
, 1);
791 case GL_STENCIL_VALUE_MASK
:
792 v
->value_int
= ctx
->Stencil
.ValueMask
[ctx
->Stencil
.ActiveFace
];
794 case GL_STENCIL_WRITEMASK
:
795 v
->value_int
= ctx
->Stencil
.WriteMask
[ctx
->Stencil
.ActiveFace
];
798 case GL_NUM_EXTENSIONS
:
799 v
->value_int
= _mesa_get_extension_count(ctx
);
802 case GL_IMPLEMENTATION_COLOR_READ_TYPE_OES
:
803 v
->value_int
= _mesa_get_color_read_type(ctx
, NULL
, "glGetIntegerv");
805 case GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES
:
806 v
->value_int
= _mesa_get_color_read_format(ctx
, NULL
, "glGetIntegerv");
809 case GL_CURRENT_MATRIX_STACK_DEPTH_ARB
:
810 v
->value_int
= ctx
->CurrentStack
->Depth
+ 1;
812 case GL_CURRENT_MATRIX_ARB
:
813 case GL_TRANSPOSE_CURRENT_MATRIX_ARB
:
814 v
->value_matrix
= ctx
->CurrentStack
->Top
;
817 case GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB
:
818 v
->value_int
= _mesa_get_compressed_formats(ctx
, NULL
);
820 case GL_COMPRESSED_TEXTURE_FORMATS_ARB
:
822 _mesa_get_compressed_formats(ctx
, v
->value_int_n
.ints
);
823 assert(v
->value_int_n
.n
<= (int) ARRAY_SIZE(v
->value_int_n
.ints
));
826 case GL_MAX_VARYING_FLOATS_ARB
:
827 v
->value_int
= ctx
->Const
.MaxVarying
* 4;
830 /* Various object names */
832 case GL_TEXTURE_BINDING_1D
:
833 case GL_TEXTURE_BINDING_2D
:
834 case GL_TEXTURE_BINDING_3D
:
835 case GL_TEXTURE_BINDING_1D_ARRAY_EXT
:
836 case GL_TEXTURE_BINDING_2D_ARRAY_EXT
:
837 case GL_TEXTURE_BINDING_CUBE_MAP_ARB
:
838 case GL_TEXTURE_BINDING_RECTANGLE_NV
:
839 case GL_TEXTURE_BINDING_EXTERNAL_OES
:
840 case GL_TEXTURE_BINDING_CUBE_MAP_ARRAY
:
841 case GL_TEXTURE_BINDING_2D_MULTISAMPLE
:
842 case GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY
:
843 unit
= ctx
->Texture
.CurrentUnit
;
845 ctx
->Texture
.Unit
[unit
].CurrentTex
[d
->offset
]->Name
;
848 /* GL_EXT_external_objects */
849 case GL_DRIVER_UUID_EXT
:
850 _mesa_get_driver_uuid(ctx
, v
->value_int_4
);
852 case GL_DEVICE_UUID_EXT
:
853 _mesa_get_device_uuid(ctx
, v
->value_int_4
);
856 /* GL_EXT_packed_float */
857 case GL_RGBA_SIGNED_COMPONENTS_EXT
:
859 /* Note: we only check the 0th color attachment. */
860 const struct gl_renderbuffer
*rb
=
861 ctx
->DrawBuffer
->_ColorDrawBuffers
[0];
862 if (rb
&& _mesa_is_format_signed(rb
->Format
)) {
863 /* Issue 17 of GL_EXT_packed_float: If a component (such as
864 * alpha) has zero bits, the component should not be considered
865 * signed and so the bit for the respective component should be
869 _mesa_get_format_bits(rb
->Format
, GL_RED_BITS
);
871 _mesa_get_format_bits(rb
->Format
, GL_GREEN_BITS
);
873 _mesa_get_format_bits(rb
->Format
, GL_BLUE_BITS
);
875 _mesa_get_format_bits(rb
->Format
, GL_ALPHA_BITS
);
877 _mesa_get_format_bits(rb
->Format
, GL_TEXTURE_LUMINANCE_SIZE
);
879 _mesa_get_format_bits(rb
->Format
, GL_TEXTURE_INTENSITY_SIZE
);
881 v
->value_int_4
[0] = r_bits
+ l_bits
+ i_bits
> 0;
882 v
->value_int_4
[1] = g_bits
+ l_bits
+ i_bits
> 0;
883 v
->value_int_4
[2] = b_bits
+ l_bits
+ i_bits
> 0;
884 v
->value_int_4
[3] = a_bits
+ i_bits
> 0;
890 v
->value_int_4
[3] = 0;
895 /* GL_ARB_vertex_buffer_object */
896 case GL_VERTEX_ARRAY_BUFFER_BINDING_ARB
:
897 case GL_NORMAL_ARRAY_BUFFER_BINDING_ARB
:
898 case GL_COLOR_ARRAY_BUFFER_BINDING_ARB
:
899 case GL_INDEX_ARRAY_BUFFER_BINDING_ARB
:
900 case GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB
:
901 case GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB
:
902 case GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB
:
903 buffer_obj
= (struct gl_buffer_object
**)
904 ((char *) ctx
->Array
.VAO
+ d
->offset
);
905 v
->value_int
= (*buffer_obj
)->Name
;
907 case GL_ARRAY_BUFFER_BINDING_ARB
:
908 v
->value_int
= ctx
->Array
.ArrayBufferObj
->Name
;
910 case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB
:
912 ctx
->Array
.VAO
->BufferBinding
[VERT_ATTRIB_TEX(ctx
->Array
.ActiveTexture
)].BufferObj
->Name
;
914 case GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB
:
915 v
->value_int
= ctx
->Array
.VAO
->IndexBufferObj
->Name
;
918 /* ARB_vertex_array_bgra */
919 case GL_COLOR_ARRAY_SIZE
:
920 array
= &ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_COLOR0
];
921 v
->value_int
= array
->Format
== GL_BGRA
? GL_BGRA
: array
->Size
;
923 case GL_SECONDARY_COLOR_ARRAY_SIZE
:
924 array
= &ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_COLOR1
];
925 v
->value_int
= array
->Format
== GL_BGRA
? GL_BGRA
: array
->Size
;
928 /* ARB_copy_buffer */
929 case GL_COPY_READ_BUFFER
:
930 v
->value_int
= ctx
->CopyReadBuffer
->Name
;
932 case GL_COPY_WRITE_BUFFER
:
933 v
->value_int
= ctx
->CopyWriteBuffer
->Name
;
936 case GL_PIXEL_PACK_BUFFER_BINDING_EXT
:
937 v
->value_int
= ctx
->Pack
.BufferObj
->Name
;
939 case GL_PIXEL_UNPACK_BUFFER_BINDING_EXT
:
940 v
->value_int
= ctx
->Unpack
.BufferObj
->Name
;
942 case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING
:
943 v
->value_int
= ctx
->TransformFeedback
.CurrentBuffer
->Name
;
945 case GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED
:
946 v
->value_int
= ctx
->TransformFeedback
.CurrentObject
->Paused
;
948 case GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE
:
949 v
->value_int
= ctx
->TransformFeedback
.CurrentObject
->Active
;
951 case GL_TRANSFORM_FEEDBACK_BINDING
:
952 v
->value_int
= ctx
->TransformFeedback
.CurrentObject
->Name
;
954 case GL_CURRENT_PROGRAM
:
955 /* The Changelog of the ARB_separate_shader_objects spec says:
957 * 24 25 Jul 2011 pbrown Remove the language erroneously deleting
958 * CURRENT_PROGRAM. In the EXT extension, this
959 * token was aliased to ACTIVE_PROGRAM_EXT, and
960 * was used to indicate the last program set by
961 * either ActiveProgramEXT or UseProgram. In
962 * the ARB extension, the SSO active programs
963 * are now program pipeline object state and
964 * CURRENT_PROGRAM should still be used to query
965 * the last program set by UseProgram (bug 7822).
968 ctx
->Shader
.ActiveProgram
? ctx
->Shader
.ActiveProgram
->Name
: 0;
970 case GL_READ_FRAMEBUFFER_BINDING_EXT
:
971 v
->value_int
= ctx
->ReadBuffer
->Name
;
973 case GL_RENDERBUFFER_BINDING_EXT
:
975 ctx
->CurrentRenderbuffer
? ctx
->CurrentRenderbuffer
->Name
: 0;
977 case GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES
:
978 v
->value_int
= ctx
->Array
.VAO
->BufferBinding
[VERT_ATTRIB_POINT_SIZE
].BufferObj
->Name
;
982 if (_mesa_get_clamp_fragment_color(ctx
, ctx
->DrawBuffer
))
983 COPY_4FV(v
->value_float_4
, ctx
->Fog
.Color
);
985 COPY_4FV(v
->value_float_4
, ctx
->Fog
.ColorUnclamped
);
987 case GL_COLOR_CLEAR_VALUE
:
988 if (_mesa_get_clamp_fragment_color(ctx
, ctx
->DrawBuffer
)) {
989 v
->value_float_4
[0] = CLAMP(ctx
->Color
.ClearColor
.f
[0], 0.0F
, 1.0F
);
990 v
->value_float_4
[1] = CLAMP(ctx
->Color
.ClearColor
.f
[1], 0.0F
, 1.0F
);
991 v
->value_float_4
[2] = CLAMP(ctx
->Color
.ClearColor
.f
[2], 0.0F
, 1.0F
);
992 v
->value_float_4
[3] = CLAMP(ctx
->Color
.ClearColor
.f
[3], 0.0F
, 1.0F
);
994 COPY_4FV(v
->value_float_4
, ctx
->Color
.ClearColor
.f
);
996 case GL_BLEND_COLOR_EXT
:
997 if (_mesa_get_clamp_fragment_color(ctx
, ctx
->DrawBuffer
))
998 COPY_4FV(v
->value_float_4
, ctx
->Color
.BlendColor
);
1000 COPY_4FV(v
->value_float_4
, ctx
->Color
.BlendColorUnclamped
);
1002 case GL_ALPHA_TEST_REF
:
1003 if (_mesa_get_clamp_fragment_color(ctx
, ctx
->DrawBuffer
))
1004 v
->value_float
= ctx
->Color
.AlphaRef
;
1006 v
->value_float
= ctx
->Color
.AlphaRefUnclamped
;
1008 case GL_MAX_VERTEX_UNIFORM_VECTORS
:
1009 v
->value_int
= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxUniformComponents
/ 4;
1012 case GL_MAX_FRAGMENT_UNIFORM_VECTORS
:
1013 v
->value_int
= ctx
->Const
.Program
[MESA_SHADER_FRAGMENT
].MaxUniformComponents
/ 4;
1016 /* GL_ARB_texture_buffer_object */
1017 case GL_TEXTURE_BUFFER_ARB
:
1018 v
->value_int
= ctx
->Texture
.BufferObject
->Name
;
1020 case GL_TEXTURE_BINDING_BUFFER_ARB
:
1021 unit
= ctx
->Texture
.CurrentUnit
;
1023 ctx
->Texture
.Unit
[unit
].CurrentTex
[TEXTURE_BUFFER_INDEX
]->Name
;
1025 case GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB
:
1027 struct gl_buffer_object
*buf
=
1028 ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
]
1029 .CurrentTex
[TEXTURE_BUFFER_INDEX
]->BufferObject
;
1030 v
->value_int
= buf
? buf
->Name
: 0;
1033 case GL_TEXTURE_BUFFER_FORMAT_ARB
:
1034 v
->value_int
= ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
]
1035 .CurrentTex
[TEXTURE_BUFFER_INDEX
]->BufferObjectFormat
;
1038 /* GL_ARB_sampler_objects */
1039 case GL_SAMPLER_BINDING
:
1041 struct gl_sampler_object
*samp
=
1042 ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
].Sampler
;
1043 v
->value_int
= samp
? samp
->Name
: 0;
1046 /* GL_ARB_uniform_buffer_object */
1047 case GL_UNIFORM_BUFFER_BINDING
:
1048 v
->value_int
= ctx
->UniformBuffer
->Name
;
1050 /* GL_ARB_shader_storage_buffer_object */
1051 case GL_SHADER_STORAGE_BUFFER_BINDING
:
1052 v
->value_int
= ctx
->ShaderStorageBuffer
->Name
;
1054 /* GL_ARB_query_buffer_object */
1055 case GL_QUERY_BUFFER_BINDING
:
1056 v
->value_int
= ctx
->QueryBuffer
->Name
;
1058 /* GL_ARB_timer_query */
1060 if (ctx
->Driver
.GetTimestamp
) {
1061 v
->value_int64
= ctx
->Driver
.GetTimestamp(ctx
);
1064 _mesa_problem(ctx
, "driver doesn't implement GetTimestamp");
1068 case GL_DEBUG_OUTPUT
:
1069 case GL_DEBUG_OUTPUT_SYNCHRONOUS
:
1070 case GL_DEBUG_LOGGED_MESSAGES
:
1071 case GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH
:
1072 case GL_DEBUG_GROUP_STACK_DEPTH
:
1073 v
->value_int
= _mesa_get_debug_state_int(ctx
, d
->pname
);
1075 /* GL_ARB_shader_atomic_counters */
1076 case GL_ATOMIC_COUNTER_BUFFER_BINDING
:
1077 if (ctx
->AtomicBuffer
) {
1078 v
->value_int
= ctx
->AtomicBuffer
->Name
;
1083 /* GL_ARB_draw_indirect */
1084 case GL_DRAW_INDIRECT_BUFFER_BINDING
:
1085 v
->value_int
= ctx
->DrawIndirectBuffer
->Name
;
1087 /* GL_ARB_indirect_parameters */
1088 case GL_PARAMETER_BUFFER_BINDING_ARB
:
1089 v
->value_int
= ctx
->ParameterBuffer
->Name
;
1091 /* GL_ARB_separate_shader_objects */
1092 case GL_PROGRAM_PIPELINE_BINDING
:
1093 if (ctx
->Pipeline
.Current
) {
1094 v
->value_int
= ctx
->Pipeline
.Current
->Name
;
1099 /* GL_ARB_compute_shader */
1100 case GL_DISPATCH_INDIRECT_BUFFER_BINDING
:
1101 v
->value_int
= ctx
->DispatchIndirectBuffer
->Name
;
1103 /* GL_ARB_multisample */
1105 v
->value_int
= _mesa_geometric_samples(ctx
->DrawBuffer
);
1107 case GL_SAMPLE_BUFFERS
:
1108 v
->value_int
= _mesa_geometric_samples(ctx
->DrawBuffer
) > 0;
1110 /* GL_EXT_textrue_integer */
1111 case GL_RGBA_INTEGER_MODE_EXT
:
1112 v
->value_int
= (ctx
->DrawBuffer
->_IntegerBuffers
!= 0);
1114 /* GL_ATI_meminfo & GL_NVX_gpu_memory_info */
1115 case GL_VBO_FREE_MEMORY_ATI
:
1116 case GL_TEXTURE_FREE_MEMORY_ATI
:
1117 case GL_RENDERBUFFER_FREE_MEMORY_ATI
:
1118 case GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX
:
1119 case GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX
:
1120 case GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX
:
1121 case GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX
:
1122 case GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX
:
1124 struct gl_memory_info info
;
1126 ctx
->Driver
.QueryMemoryInfo(ctx
, &info
);
1128 if (d
->pname
== GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX
)
1129 v
->value_int
= info
.total_device_memory
;
1130 else if (d
->pname
== GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX
)
1131 v
->value_int
= info
.total_device_memory
+
1132 info
.total_staging_memory
;
1133 else if (d
->pname
== GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX
)
1134 v
->value_int
= info
.avail_device_memory
;
1135 else if (d
->pname
== GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX
)
1136 v
->value_int
= info
.nr_device_memory_evictions
;
1137 else if (d
->pname
== GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX
)
1138 v
->value_int
= info
.device_memory_evicted
;
1140 /* ATI free memory enums.
1142 * Since the GPU memory is (usually) page-table based, every two
1143 * consecutive elements are equal. From the GL_ATI_meminfo
1146 * "param[0] - total memory free in the pool
1147 * param[1] - largest available free block in the pool
1148 * param[2] - total auxiliary memory free
1149 * param[3] - largest auxiliary free block"
1151 * All three (VBO, TEXTURE, RENDERBUFFER) queries return
1152 * the same numbers here.
1154 v
->value_int_4
[0] = info
.avail_device_memory
;
1155 v
->value_int_4
[1] = info
.avail_device_memory
;
1156 v
->value_int_4
[2] = info
.avail_staging_memory
;
1157 v
->value_int_4
[3] = info
.avail_staging_memory
;
1162 /* GL_ARB_get_program_binary */
1163 case GL_PROGRAM_BINARY_FORMATS
:
1164 assert(ctx
->Const
.NumProgramBinaryFormats
<= 1);
1165 v
->value_int_n
.n
= MIN2(ctx
->Const
.NumProgramBinaryFormats
, 1);
1166 if (ctx
->Const
.NumProgramBinaryFormats
> 0) {
1167 v
->value_int_n
.ints
[0] = GL_PROGRAM_BINARY_FORMAT_MESA
;
1170 /* GL_EXT_disjoint_timer_query */
1171 case GL_GPU_DISJOINT_EXT
:
1173 simple_mtx_lock(&ctx
->Shared
->Mutex
);
1174 v
->value_int
= ctx
->Shared
->DisjointOperation
;
1175 /* Reset state as expected by the spec. */
1176 ctx
->Shared
->DisjointOperation
= false;
1177 simple_mtx_unlock(&ctx
->Shared
->Mutex
);
1184 * Check extra constraints on a struct value_desc descriptor
1186 * If a struct value_desc has a non-NULL extra pointer, it means that
1187 * there are a number of extra constraints to check or actions to
1188 * perform. The extras is just an integer array where each integer
1189 * encode different constraints or actions.
1191 * \param ctx current context
1192 * \param func name of calling glGet*v() function for error reporting
1193 * \param d the struct value_desc that has the extra constraints
1195 * \return GL_FALSE if all of the constraints were not satisfied,
1196 * otherwise GL_TRUE.
1199 check_extra(struct gl_context
*ctx
, const char *func
, const struct value_desc
*d
)
1201 const GLuint version
= ctx
->Version
;
1202 GLboolean api_check
= GL_FALSE
;
1203 GLboolean api_found
= GL_FALSE
;
1206 for (e
= d
->extra
; *e
!= EXTRA_END
; e
++) {
1208 case EXTRA_VERSION_30
:
1209 api_check
= GL_TRUE
;
1211 api_found
= GL_TRUE
;
1213 case EXTRA_VERSION_31
:
1214 api_check
= GL_TRUE
;
1216 api_found
= GL_TRUE
;
1218 case EXTRA_VERSION_32
:
1219 api_check
= GL_TRUE
;
1221 api_found
= GL_TRUE
;
1223 case EXTRA_NEW_FRAG_CLAMP
:
1224 if (ctx
->NewState
& (_NEW_BUFFERS
| _NEW_FRAG_CLAMP
))
1225 _mesa_update_state(ctx
);
1228 api_check
= GL_TRUE
;
1229 if (ctx
->API
== API_OPENGLES2
)
1230 api_found
= GL_TRUE
;
1233 api_check
= GL_TRUE
;
1234 if (_mesa_is_gles3(ctx
))
1235 api_found
= GL_TRUE
;
1237 case EXTRA_API_ES31
:
1238 api_check
= GL_TRUE
;
1239 if (_mesa_is_gles31(ctx
))
1240 api_found
= GL_TRUE
;
1242 case EXTRA_API_ES32
:
1243 api_check
= GL_TRUE
;
1244 if (_mesa_is_gles32(ctx
))
1245 api_found
= GL_TRUE
;
1248 api_check
= GL_TRUE
;
1249 if (_mesa_is_desktop_gl(ctx
))
1250 api_found
= GL_TRUE
;
1252 case EXTRA_API_GL_CORE
:
1253 api_check
= GL_TRUE
;
1254 if (ctx
->API
== API_OPENGL_CORE
)
1255 api_found
= GL_TRUE
;
1257 case EXTRA_NEW_BUFFERS
:
1258 if (ctx
->NewState
& _NEW_BUFFERS
)
1259 _mesa_update_state(ctx
);
1261 case EXTRA_FLUSH_CURRENT
:
1262 FLUSH_CURRENT(ctx
, 0);
1264 case EXTRA_VALID_DRAW_BUFFER
:
1265 if (d
->pname
- GL_DRAW_BUFFER0_ARB
>= ctx
->Const
.MaxDrawBuffers
) {
1266 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(draw buffer %u)",
1267 func
, d
->pname
- GL_DRAW_BUFFER0_ARB
);
1271 case EXTRA_VALID_TEXTURE_UNIT
:
1272 if (ctx
->Texture
.CurrentUnit
>= ctx
->Const
.MaxTextureCoordUnits
) {
1273 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(texture %u)",
1274 func
, ctx
->Texture
.CurrentUnit
);
1278 case EXTRA_VALID_CLIP_DISTANCE
:
1279 if (d
->pname
- GL_CLIP_DISTANCE0
>= ctx
->Const
.MaxClipPlanes
) {
1280 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(clip distance %u)",
1281 func
, d
->pname
- GL_CLIP_DISTANCE0
);
1285 case EXTRA_GLSL_130
:
1286 api_check
= GL_TRUE
;
1287 if (ctx
->Const
.GLSLVersion
>= 130)
1288 api_found
= GL_TRUE
;
1290 case EXTRA_EXT_UBO_GS
:
1291 api_check
= GL_TRUE
;
1292 if (ctx
->Extensions
.ARB_uniform_buffer_object
&&
1293 _mesa_has_geometry_shaders(ctx
))
1294 api_found
= GL_TRUE
;
1296 case EXTRA_EXT_ATOMICS_GS
:
1297 api_check
= GL_TRUE
;
1298 if (ctx
->Extensions
.ARB_shader_atomic_counters
&&
1299 _mesa_has_geometry_shaders(ctx
))
1300 api_found
= GL_TRUE
;
1302 case EXTRA_EXT_SHADER_IMAGE_GS
:
1303 api_check
= GL_TRUE
;
1304 if (ctx
->Extensions
.ARB_shader_image_load_store
&&
1305 _mesa_has_geometry_shaders(ctx
))
1306 api_found
= GL_TRUE
;
1308 case EXTRA_EXT_ATOMICS_TESS
:
1309 api_check
= GL_TRUE
;
1310 api_found
= ctx
->Extensions
.ARB_shader_atomic_counters
&&
1311 _mesa_has_tessellation(ctx
);
1313 case EXTRA_EXT_SHADER_IMAGE_TESS
:
1314 api_check
= GL_TRUE
;
1315 api_found
= ctx
->Extensions
.ARB_shader_image_load_store
&&
1316 _mesa_has_tessellation(ctx
);
1318 case EXTRA_EXT_SSBO_GS
:
1319 api_check
= GL_TRUE
;
1320 if (ctx
->Extensions
.ARB_shader_storage_buffer_object
&&
1321 _mesa_has_geometry_shaders(ctx
))
1322 api_found
= GL_TRUE
;
1324 case EXTRA_EXT_FB_NO_ATTACH_GS
:
1325 api_check
= GL_TRUE
;
1326 if (ctx
->Extensions
.ARB_framebuffer_no_attachments
&&
1327 (_mesa_is_desktop_gl(ctx
) ||
1328 _mesa_has_OES_geometry_shader(ctx
)))
1329 api_found
= GL_TRUE
;
1331 case EXTRA_EXT_ES_GS
:
1332 api_check
= GL_TRUE
;
1333 if (_mesa_has_OES_geometry_shader(ctx
))
1334 api_found
= GL_TRUE
;
1336 case EXTRA_EXT_PROVOKING_VERTEX_32
:
1338 if (ctx
->API
== API_OPENGL_COMPAT
|| version
== 32)
1339 api_found
= ctx
->Extensions
.EXT_provoking_vertex
;
1343 default: /* *e is a offset into the extension struct */
1344 api_check
= GL_TRUE
;
1345 if (*(GLboolean
*) ((char *) &ctx
->Extensions
+ *e
))
1346 api_found
= GL_TRUE
;
1351 if (api_check
&& !api_found
) {
1352 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(pname=%s)", func
,
1353 _mesa_enum_to_string(d
->pname
));
1360 static const struct value_desc error_value
=
1361 { 0, 0, TYPE_INVALID
, NO_OFFSET
, NO_EXTRA
};
1364 * Find the struct value_desc corresponding to the enum 'pname'.
1366 * We hash the enum value to get an index into the 'table' array,
1367 * which holds the index in the 'values' array of struct value_desc.
1368 * Once we've found the entry, we do the extra checks, if any, then
1369 * look up the value and return a pointer to it.
1371 * If the value has to be computed (for example, it's the result of a
1372 * function call or we need to add 1 to it), we use the tmp 'v' to
1375 * \param func name of glGet*v() func for error reporting
1376 * \param pname the enum value we're looking up
1377 * \param p is were we return the pointer to the value
1378 * \param v a tmp union value variable in the calling glGet*v() function
1380 * \return the struct value_desc corresponding to the enum or a struct
1381 * value_desc of TYPE_INVALID if not found. This lets the calling
1382 * glGet*v() function jump right into a switch statement and
1383 * handle errors there instead of having to check for NULL.
1385 static const struct value_desc
*
1386 find_value(const char *func
, GLenum pname
, void **p
, union value
*v
)
1388 GET_CURRENT_CONTEXT(ctx
);
1389 struct gl_texture_unit
*unit
;
1391 const struct value_desc
*d
;
1395 /* We index into the table_set[] list of per-API hash tables using the API's
1396 * value in the gl_api enum. Since GLES 3 doesn't have an API_OPENGL* enum
1397 * value since it's compatible with GLES2 its entry in table_set[] is at the
1400 STATIC_ASSERT(ARRAY_SIZE(table_set
) == API_OPENGL_LAST
+ 4);
1401 if (ctx
->API
== API_OPENGLES2
) {
1402 if (ctx
->Version
>= 32)
1403 api
= API_OPENGL_LAST
+ 3;
1404 else if (ctx
->Version
>= 31)
1405 api
= API_OPENGL_LAST
+ 2;
1406 else if (ctx
->Version
>= 30)
1407 api
= API_OPENGL_LAST
+ 1;
1409 mask
= ARRAY_SIZE(table(api
)) - 1;
1410 hash
= (pname
* prime_factor
);
1412 int idx
= table(api
)[hash
& mask
];
1414 /* If the enum isn't valid, the hash walk ends with index 0,
1415 * pointing to the first entry of values[] which doesn't hold
1416 * any valid enum. */
1417 if (unlikely(idx
== 0)) {
1418 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(pname=%s)", func
,
1419 _mesa_enum_to_string(pname
));
1420 return &error_value
;
1424 if (likely(d
->pname
== pname
))
1430 if (unlikely(d
->extra
&& !check_extra(ctx
, func
, d
)))
1431 return &error_value
;
1433 switch (d
->location
) {
1435 *p
= ((char *) ctx
->DrawBuffer
+ d
->offset
);
1438 *p
= ((char *) ctx
+ d
->offset
);
1441 *p
= ((char *) ctx
->Array
.VAO
+ d
->offset
);
1444 unit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1445 *p
= ((char *) unit
+ d
->offset
);
1448 find_custom_value(ctx
, d
, v
);
1456 /* silence warning */
1457 return &error_value
;
1460 static const int transpose
[] = {
1468 get_value_size(enum value_type type
, const union value
*v
)
1476 return sizeof(GLint
);
1479 return sizeof(GLint
) * 2;
1482 return sizeof(GLint
) * 3;
1485 return sizeof(GLint
) * 4;
1487 return sizeof(GLint
) * v
->value_int_n
.n
;
1489 return sizeof(GLint64
);
1492 return sizeof(GLenum
);
1494 return sizeof(GLenum
) * 2;
1496 return sizeof(GLboolean
);
1508 return sizeof(GLfloat
);
1511 return sizeof(GLfloat
) * 2;
1514 return sizeof(GLfloat
) * 3;
1517 return sizeof(GLfloat
) * 4;
1519 return sizeof(GLfloat
) * 8;
1521 return sizeof(GLdouble
);
1522 case TYPE_DOUBLEN_2
:
1523 return sizeof(GLdouble
) * 2;
1525 return sizeof (GLfloat
) * 16;
1527 return sizeof (GLfloat
) * 16;
1534 _mesa_GetBooleanv(GLenum pname
, GLboolean
*params
)
1536 const struct value_desc
*d
;
1542 d
= find_value("glGetBooleanv", pname
, &p
, &v
);
1547 params
[0] = INT_TO_BOOLEAN(d
->offset
);
1551 params
[7] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[7]);
1552 params
[6] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[6]);
1553 params
[5] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[5]);
1554 params
[4] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[4]);
1557 params
[3] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[3]);
1560 params
[2] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[2]);
1563 params
[1] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[1]);
1566 params
[0] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[0]);
1569 case TYPE_DOUBLEN_2
:
1570 params
[1] = FLOAT_TO_BOOLEAN(((GLdouble
*) p
)[1]);
1572 params
[0] = FLOAT_TO_BOOLEAN(((GLdouble
*) p
)[0]);
1577 params
[3] = INT_TO_BOOLEAN(((GLint
*) p
)[3]);
1580 params
[2] = INT_TO_BOOLEAN(((GLint
*) p
)[2]);
1584 params
[1] = INT_TO_BOOLEAN(((GLint
*) p
)[1]);
1588 params
[0] = INT_TO_BOOLEAN(((GLint
*) p
)[0]);
1592 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
1593 params
[i
] = INT_TO_BOOLEAN(v
.value_int_n
.ints
[i
]);
1597 params
[0] = INT64_TO_BOOLEAN(((GLint64
*) p
)[0]);
1601 params
[0] = ((GLboolean
*) p
)[0];
1605 m
= *(GLmatrix
**) p
;
1606 for (i
= 0; i
< 16; i
++)
1607 params
[i
] = FLOAT_TO_BOOLEAN(m
->m
[i
]);
1611 m
= *(GLmatrix
**) p
;
1612 for (i
= 0; i
< 16; i
++)
1613 params
[i
] = FLOAT_TO_BOOLEAN(m
->m
[transpose
[i
]]);
1624 shift
= d
->type
- TYPE_BIT_0
;
1625 params
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
1631 _mesa_GetFloatv(GLenum pname
, GLfloat
*params
)
1633 const struct value_desc
*d
;
1639 d
= find_value("glGetFloatv", pname
, &p
, &v
);
1644 params
[0] = (GLfloat
) d
->offset
;
1648 params
[7] = ((GLfloat
*) p
)[7];
1649 params
[6] = ((GLfloat
*) p
)[6];
1650 params
[5] = ((GLfloat
*) p
)[5];
1651 params
[4] = ((GLfloat
*) p
)[4];
1654 params
[3] = ((GLfloat
*) p
)[3];
1657 params
[2] = ((GLfloat
*) p
)[2];
1660 params
[1] = ((GLfloat
*) p
)[1];
1663 params
[0] = ((GLfloat
*) p
)[0];
1666 case TYPE_DOUBLEN_2
:
1667 params
[1] = (GLfloat
) (((GLdouble
*) p
)[1]);
1669 params
[0] = (GLfloat
) (((GLdouble
*) p
)[0]);
1673 params
[3] = (GLfloat
) (((GLint
*) p
)[3]);
1675 params
[2] = (GLfloat
) (((GLint
*) p
)[2]);
1678 params
[1] = (GLfloat
) (((GLint
*) p
)[1]);
1681 params
[0] = (GLfloat
) (((GLint
*) p
)[0]);
1685 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
1686 params
[i
] = (GLfloat
) v
.value_int_n
.ints
[i
];
1690 params
[3] = (GLfloat
) (((GLuint
*) p
)[3]);
1692 params
[2] = (GLfloat
) (((GLuint
*) p
)[2]);
1694 params
[1] = (GLfloat
) (((GLuint
*) p
)[1]);
1696 params
[0] = (GLfloat
) (((GLuint
*) p
)[0]);
1700 params
[0] = (GLfloat
) (((GLint64
*) p
)[0]);
1704 params
[0] = BOOLEAN_TO_FLOAT(*(GLboolean
*) p
);
1708 m
= *(GLmatrix
**) p
;
1709 for (i
= 0; i
< 16; i
++)
1710 params
[i
] = m
->m
[i
];
1714 m
= *(GLmatrix
**) p
;
1715 for (i
= 0; i
< 16; i
++)
1716 params
[i
] = m
->m
[transpose
[i
]];
1727 shift
= d
->type
- TYPE_BIT_0
;
1728 params
[0] = BOOLEAN_TO_FLOAT((*(GLbitfield
*) p
>> shift
) & 1);
1734 _mesa_GetIntegerv(GLenum pname
, GLint
*params
)
1736 const struct value_desc
*d
;
1742 d
= find_value("glGetIntegerv", pname
, &p
, &v
);
1747 params
[0] = d
->offset
;
1751 params
[7] = IROUND(((GLfloat
*) p
)[7]);
1752 params
[6] = IROUND(((GLfloat
*) p
)[6]);
1753 params
[5] = IROUND(((GLfloat
*) p
)[5]);
1754 params
[4] = IROUND(((GLfloat
*) p
)[4]);
1756 params
[3] = IROUND(((GLfloat
*) p
)[3]);
1758 params
[2] = IROUND(((GLfloat
*) p
)[2]);
1760 params
[1] = IROUND(((GLfloat
*) p
)[1]);
1762 params
[0] = IROUND(((GLfloat
*) p
)[0]);
1766 params
[3] = FLOAT_TO_INT(((GLfloat
*) p
)[3]);
1768 params
[2] = FLOAT_TO_INT(((GLfloat
*) p
)[2]);
1770 params
[1] = FLOAT_TO_INT(((GLfloat
*) p
)[1]);
1772 params
[0] = FLOAT_TO_INT(((GLfloat
*) p
)[0]);
1775 case TYPE_DOUBLEN_2
:
1776 params
[1] = FLOAT_TO_INT(((GLdouble
*) p
)[1]);
1778 params
[0] = FLOAT_TO_INT(((GLdouble
*) p
)[0]);
1783 params
[3] = ((GLint
*) p
)[3];
1786 params
[2] = ((GLint
*) p
)[2];
1790 params
[1] = ((GLint
*) p
)[1];
1794 params
[0] = ((GLint
*) p
)[0];
1798 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
1799 params
[i
] = v
.value_int_n
.ints
[i
];
1803 params
[0] = INT64_TO_INT(((GLint64
*) p
)[0]);
1807 params
[0] = BOOLEAN_TO_INT(*(GLboolean
*) p
);
1811 m
= *(GLmatrix
**) p
;
1812 for (i
= 0; i
< 16; i
++)
1813 params
[i
] = FLOAT_TO_INT(m
->m
[i
]);
1817 m
= *(GLmatrix
**) p
;
1818 for (i
= 0; i
< 16; i
++)
1819 params
[i
] = FLOAT_TO_INT(m
->m
[transpose
[i
]]);
1830 shift
= d
->type
- TYPE_BIT_0
;
1831 params
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
1837 _mesa_GetInteger64v(GLenum pname
, GLint64
*params
)
1839 const struct value_desc
*d
;
1845 d
= find_value("glGetInteger64v", pname
, &p
, &v
);
1850 params
[0] = d
->offset
;
1854 params
[7] = IROUND64(((GLfloat
*) p
)[7]);
1855 params
[6] = IROUND64(((GLfloat
*) p
)[6]);
1856 params
[5] = IROUND64(((GLfloat
*) p
)[5]);
1857 params
[4] = IROUND64(((GLfloat
*) p
)[4]);
1859 params
[3] = IROUND64(((GLfloat
*) p
)[3]);
1861 params
[2] = IROUND64(((GLfloat
*) p
)[2]);
1863 params
[1] = IROUND64(((GLfloat
*) p
)[1]);
1865 params
[0] = IROUND64(((GLfloat
*) p
)[0]);
1869 params
[3] = FLOAT_TO_INT(((GLfloat
*) p
)[3]);
1871 params
[2] = FLOAT_TO_INT(((GLfloat
*) p
)[2]);
1873 params
[1] = FLOAT_TO_INT(((GLfloat
*) p
)[1]);
1875 params
[0] = FLOAT_TO_INT(((GLfloat
*) p
)[0]);
1878 case TYPE_DOUBLEN_2
:
1879 params
[1] = FLOAT_TO_INT(((GLdouble
*) p
)[1]);
1881 params
[0] = FLOAT_TO_INT(((GLdouble
*) p
)[0]);
1885 params
[3] = ((GLint
*) p
)[3];
1887 params
[2] = ((GLint
*) p
)[2];
1890 params
[1] = ((GLint
*) p
)[1];
1893 params
[0] = ((GLint
*) p
)[0];
1897 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
1898 params
[i
] = INT_TO_BOOLEAN(v
.value_int_n
.ints
[i
]);
1902 params
[3] = ((GLuint
*) p
)[3];
1904 params
[2] = ((GLuint
*) p
)[2];
1906 params
[1] = ((GLuint
*) p
)[1];
1908 params
[0] = ((GLuint
*) p
)[0];
1912 params
[0] = ((GLint64
*) p
)[0];
1916 params
[0] = ((GLboolean
*) p
)[0];
1920 m
= *(GLmatrix
**) p
;
1921 for (i
= 0; i
< 16; i
++)
1922 params
[i
] = FLOAT_TO_INT64(m
->m
[i
]);
1926 m
= *(GLmatrix
**) p
;
1927 for (i
= 0; i
< 16; i
++)
1928 params
[i
] = FLOAT_TO_INT64(m
->m
[transpose
[i
]]);
1939 shift
= d
->type
- TYPE_BIT_0
;
1940 params
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
1946 _mesa_GetDoublev(GLenum pname
, GLdouble
*params
)
1948 const struct value_desc
*d
;
1954 d
= find_value("glGetDoublev", pname
, &p
, &v
);
1959 params
[0] = d
->offset
;
1963 params
[7] = ((GLfloat
*) p
)[7];
1964 params
[6] = ((GLfloat
*) p
)[6];
1965 params
[5] = ((GLfloat
*) p
)[5];
1966 params
[4] = ((GLfloat
*) p
)[4];
1969 params
[3] = ((GLfloat
*) p
)[3];
1972 params
[2] = ((GLfloat
*) p
)[2];
1975 params
[1] = ((GLfloat
*) p
)[1];
1978 params
[0] = ((GLfloat
*) p
)[0];
1981 case TYPE_DOUBLEN_2
:
1982 params
[1] = ((GLdouble
*) p
)[1];
1984 params
[0] = ((GLdouble
*) p
)[0];
1988 params
[3] = ((GLint
*) p
)[3];
1990 params
[2] = ((GLint
*) p
)[2];
1993 params
[1] = ((GLint
*) p
)[1];
1996 params
[0] = ((GLint
*) p
)[0];
2000 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
2001 params
[i
] = v
.value_int_n
.ints
[i
];
2005 params
[3] = ((GLuint
*) p
)[3];
2007 params
[2] = ((GLuint
*) p
)[2];
2009 params
[1] = ((GLuint
*) p
)[1];
2011 params
[0] = ((GLuint
*) p
)[0];
2015 params
[0] = (GLdouble
) (((GLint64
*) p
)[0]);
2019 params
[0] = *(GLboolean
*) p
;
2023 m
= *(GLmatrix
**) p
;
2024 for (i
= 0; i
< 16; i
++)
2025 params
[i
] = m
->m
[i
];
2029 m
= *(GLmatrix
**) p
;
2030 for (i
= 0; i
< 16; i
++)
2031 params
[i
] = m
->m
[transpose
[i
]];
2042 shift
= d
->type
- TYPE_BIT_0
;
2043 params
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
2049 _mesa_GetUnsignedBytevEXT(GLenum pname
, GLubyte
*data
)
2051 const struct value_desc
*d
;
2056 const char *func
= "glGetUnsignedBytevEXT";
2058 GET_CURRENT_CONTEXT(ctx
);
2060 if (!ctx
->Extensions
.EXT_memory_object
) {
2061 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(unsupported)", func
);
2065 d
= find_value(func
, pname
, &p
, &v
);
2066 size
= get_value_size(d
->type
, &v
);
2068 _mesa_problem(ctx
, "invalid value type in GetUnsignedBytevEXT()");
2080 shift
= d
->type
- TYPE_BIT_0
;
2081 data
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
2084 memcpy(data
, &d
->offset
, size
);
2087 memcpy(data
, &v
.value_int_n
.ints
, size
);
2111 case TYPE_DOUBLEN_2
:
2114 memcpy(data
, p
, size
);
2117 break; /* nothing - GL error was recorded */
2122 * Convert a GL texture binding enum such as GL_TEXTURE_BINDING_2D
2123 * into the corresponding Mesa texture target index.
2124 * \return TEXTURE_x_INDEX or -1 if binding is invalid
2127 tex_binding_to_index(const struct gl_context
*ctx
, GLenum binding
)
2130 case GL_TEXTURE_BINDING_1D
:
2131 return _mesa_is_desktop_gl(ctx
) ? TEXTURE_1D_INDEX
: -1;
2132 case GL_TEXTURE_BINDING_2D
:
2133 return TEXTURE_2D_INDEX
;
2134 case GL_TEXTURE_BINDING_3D
:
2135 return ctx
->API
!= API_OPENGLES
? TEXTURE_3D_INDEX
: -1;
2136 case GL_TEXTURE_BINDING_CUBE_MAP
:
2137 return ctx
->Extensions
.ARB_texture_cube_map
2138 ? TEXTURE_CUBE_INDEX
: -1;
2139 case GL_TEXTURE_BINDING_RECTANGLE
:
2140 return _mesa_is_desktop_gl(ctx
) && ctx
->Extensions
.NV_texture_rectangle
2141 ? TEXTURE_RECT_INDEX
: -1;
2142 case GL_TEXTURE_BINDING_1D_ARRAY
:
2143 return _mesa_is_desktop_gl(ctx
) && ctx
->Extensions
.EXT_texture_array
2144 ? TEXTURE_1D_ARRAY_INDEX
: -1;
2145 case GL_TEXTURE_BINDING_2D_ARRAY
:
2146 return (_mesa_is_desktop_gl(ctx
) && ctx
->Extensions
.EXT_texture_array
)
2147 || _mesa_is_gles3(ctx
)
2148 ? TEXTURE_2D_ARRAY_INDEX
: -1;
2149 case GL_TEXTURE_BINDING_BUFFER
:
2150 return (_mesa_has_ARB_texture_buffer_object(ctx
) ||
2151 _mesa_has_OES_texture_buffer(ctx
)) ?
2152 TEXTURE_BUFFER_INDEX
: -1;
2153 case GL_TEXTURE_BINDING_CUBE_MAP_ARRAY
:
2154 return _mesa_has_texture_cube_map_array(ctx
)
2155 ? TEXTURE_CUBE_ARRAY_INDEX
: -1;
2156 case GL_TEXTURE_BINDING_2D_MULTISAMPLE
:
2157 return _mesa_is_desktop_gl(ctx
) && ctx
->Extensions
.ARB_texture_multisample
2158 ? TEXTURE_2D_MULTISAMPLE_INDEX
: -1;
2159 case GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY
:
2160 return _mesa_is_desktop_gl(ctx
) && ctx
->Extensions
.ARB_texture_multisample
2161 ? TEXTURE_2D_MULTISAMPLE_ARRAY_INDEX
: -1;
2167 static enum value_type
2168 find_value_indexed(const char *func
, GLenum pname
, GLuint index
, union value
*v
)
2170 GET_CURRENT_CONTEXT(ctx
);
2175 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2177 if (!ctx
->Extensions
.EXT_draw_buffers2
)
2179 v
->value_int
= (ctx
->Color
.BlendEnabled
>> index
) & 1;
2184 case GL_BLEND_SRC_RGB
:
2185 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2187 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
2189 v
->value_int
= ctx
->Color
.Blend
[index
].SrcRGB
;
2191 case GL_BLEND_SRC_ALPHA
:
2192 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2194 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
2196 v
->value_int
= ctx
->Color
.Blend
[index
].SrcA
;
2200 case GL_BLEND_DST_RGB
:
2201 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2203 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
2205 v
->value_int
= ctx
->Color
.Blend
[index
].DstRGB
;
2207 case GL_BLEND_DST_ALPHA
:
2208 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2210 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
2212 v
->value_int
= ctx
->Color
.Blend
[index
].DstA
;
2214 case GL_BLEND_EQUATION_RGB
:
2215 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2217 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
2219 v
->value_int
= ctx
->Color
.Blend
[index
].EquationRGB
;
2221 case GL_BLEND_EQUATION_ALPHA
:
2222 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2224 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
2226 v
->value_int
= ctx
->Color
.Blend
[index
].EquationA
;
2229 case GL_COLOR_WRITEMASK
:
2230 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2232 if (!ctx
->Extensions
.EXT_draw_buffers2
)
2234 v
->value_int_4
[0] = ctx
->Color
.ColorMask
[index
][RCOMP
] ? 1 : 0;
2235 v
->value_int_4
[1] = ctx
->Color
.ColorMask
[index
][GCOMP
] ? 1 : 0;
2236 v
->value_int_4
[2] = ctx
->Color
.ColorMask
[index
][BCOMP
] ? 1 : 0;
2237 v
->value_int_4
[3] = ctx
->Color
.ColorMask
[index
][ACOMP
] ? 1 : 0;
2240 case GL_SCISSOR_BOX
:
2241 if (index
>= ctx
->Const
.MaxViewports
)
2243 v
->value_int_4
[0] = ctx
->Scissor
.ScissorArray
[index
].X
;
2244 v
->value_int_4
[1] = ctx
->Scissor
.ScissorArray
[index
].Y
;
2245 v
->value_int_4
[2] = ctx
->Scissor
.ScissorArray
[index
].Width
;
2246 v
->value_int_4
[3] = ctx
->Scissor
.ScissorArray
[index
].Height
;
2249 case GL_WINDOW_RECTANGLE_EXT
:
2250 if (!ctx
->Extensions
.EXT_window_rectangles
)
2252 if (index
>= ctx
->Const
.MaxWindowRectangles
)
2254 v
->value_int_4
[0] = ctx
->Scissor
.WindowRects
[index
].X
;
2255 v
->value_int_4
[1] = ctx
->Scissor
.WindowRects
[index
].Y
;
2256 v
->value_int_4
[2] = ctx
->Scissor
.WindowRects
[index
].Width
;
2257 v
->value_int_4
[3] = ctx
->Scissor
.WindowRects
[index
].Height
;
2261 if (index
>= ctx
->Const
.MaxViewports
)
2263 v
->value_float_4
[0] = ctx
->ViewportArray
[index
].X
;
2264 v
->value_float_4
[1] = ctx
->ViewportArray
[index
].Y
;
2265 v
->value_float_4
[2] = ctx
->ViewportArray
[index
].Width
;
2266 v
->value_float_4
[3] = ctx
->ViewportArray
[index
].Height
;
2267 return TYPE_FLOAT_4
;
2269 case GL_DEPTH_RANGE
:
2270 if (index
>= ctx
->Const
.MaxViewports
)
2272 v
->value_double_2
[0] = ctx
->ViewportArray
[index
].Near
;
2273 v
->value_double_2
[1] = ctx
->ViewportArray
[index
].Far
;
2274 return TYPE_DOUBLEN_2
;
2276 case GL_TRANSFORM_FEEDBACK_BUFFER_START
:
2277 if (index
>= ctx
->Const
.MaxTransformFeedbackBuffers
)
2279 if (!ctx
->Extensions
.EXT_transform_feedback
)
2281 v
->value_int64
= ctx
->TransformFeedback
.CurrentObject
->Offset
[index
];
2284 case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE
:
2285 if (index
>= ctx
->Const
.MaxTransformFeedbackBuffers
)
2287 if (!ctx
->Extensions
.EXT_transform_feedback
)
2290 = ctx
->TransformFeedback
.CurrentObject
->RequestedSize
[index
];
2293 case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING
:
2294 if (index
>= ctx
->Const
.MaxTransformFeedbackBuffers
)
2296 if (!ctx
->Extensions
.EXT_transform_feedback
)
2298 v
->value_int
= ctx
->TransformFeedback
.CurrentObject
->BufferNames
[index
];
2301 case GL_UNIFORM_BUFFER_BINDING
:
2302 if (index
>= ctx
->Const
.MaxUniformBufferBindings
)
2304 if (!ctx
->Extensions
.ARB_uniform_buffer_object
)
2306 v
->value_int
= ctx
->UniformBufferBindings
[index
].BufferObject
->Name
;
2309 case GL_UNIFORM_BUFFER_START
:
2310 if (index
>= ctx
->Const
.MaxUniformBufferBindings
)
2312 if (!ctx
->Extensions
.ARB_uniform_buffer_object
)
2314 v
->value_int
= ctx
->UniformBufferBindings
[index
].Offset
< 0 ? 0 :
2315 ctx
->UniformBufferBindings
[index
].Offset
;
2318 case GL_UNIFORM_BUFFER_SIZE
:
2319 if (index
>= ctx
->Const
.MaxUniformBufferBindings
)
2321 if (!ctx
->Extensions
.ARB_uniform_buffer_object
)
2323 v
->value_int
= ctx
->UniformBufferBindings
[index
].Size
< 0 ? 0 :
2324 ctx
->UniformBufferBindings
[index
].Size
;
2327 /* ARB_shader_storage_buffer_object */
2328 case GL_SHADER_STORAGE_BUFFER_BINDING
:
2329 if (!ctx
->Extensions
.ARB_shader_storage_buffer_object
)
2331 if (index
>= ctx
->Const
.MaxShaderStorageBufferBindings
)
2333 v
->value_int
= ctx
->ShaderStorageBufferBindings
[index
].BufferObject
->Name
;
2336 case GL_SHADER_STORAGE_BUFFER_START
:
2337 if (!ctx
->Extensions
.ARB_shader_storage_buffer_object
)
2339 if (index
>= ctx
->Const
.MaxShaderStorageBufferBindings
)
2341 v
->value_int
= ctx
->ShaderStorageBufferBindings
[index
].Offset
< 0 ? 0 :
2342 ctx
->ShaderStorageBufferBindings
[index
].Offset
;
2345 case GL_SHADER_STORAGE_BUFFER_SIZE
:
2346 if (!ctx
->Extensions
.ARB_shader_storage_buffer_object
)
2348 if (index
>= ctx
->Const
.MaxShaderStorageBufferBindings
)
2350 v
->value_int
= ctx
->ShaderStorageBufferBindings
[index
].Size
< 0 ? 0 :
2351 ctx
->ShaderStorageBufferBindings
[index
].Size
;
2354 /* ARB_texture_multisample / GL3.2 */
2355 case GL_SAMPLE_MASK_VALUE
:
2358 if (!ctx
->Extensions
.ARB_texture_multisample
)
2360 v
->value_int
= ctx
->Multisample
.SampleMaskValue
;
2363 case GL_ATOMIC_COUNTER_BUFFER_BINDING
:
2364 if (!ctx
->Extensions
.ARB_shader_atomic_counters
)
2366 if (index
>= ctx
->Const
.MaxAtomicBufferBindings
)
2368 v
->value_int
= ctx
->AtomicBufferBindings
[index
].BufferObject
->Name
;
2371 case GL_ATOMIC_COUNTER_BUFFER_START
:
2372 if (!ctx
->Extensions
.ARB_shader_atomic_counters
)
2374 if (index
>= ctx
->Const
.MaxAtomicBufferBindings
)
2376 v
->value_int64
= ctx
->AtomicBufferBindings
[index
].Offset
< 0 ? 0 :
2377 ctx
->AtomicBufferBindings
[index
].Offset
;
2380 case GL_ATOMIC_COUNTER_BUFFER_SIZE
:
2381 if (!ctx
->Extensions
.ARB_shader_atomic_counters
)
2383 if (index
>= ctx
->Const
.MaxAtomicBufferBindings
)
2385 v
->value_int64
= ctx
->AtomicBufferBindings
[index
].Size
< 0 ? 0 :
2386 ctx
->AtomicBufferBindings
[index
].Size
;
2389 case GL_VERTEX_BINDING_DIVISOR
:
2390 if ((!_mesa_is_desktop_gl(ctx
) || !ctx
->Extensions
.ARB_instanced_arrays
) &&
2391 !_mesa_is_gles31(ctx
))
2393 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
)
2395 v
->value_int
= ctx
->Array
.VAO
->BufferBinding
[VERT_ATTRIB_GENERIC(index
)].InstanceDivisor
;
2398 case GL_VERTEX_BINDING_OFFSET
:
2399 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles31(ctx
))
2401 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
)
2403 v
->value_int
= ctx
->Array
.VAO
->BufferBinding
[VERT_ATTRIB_GENERIC(index
)].Offset
;
2406 case GL_VERTEX_BINDING_STRIDE
:
2407 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles31(ctx
))
2409 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
)
2411 v
->value_int
= ctx
->Array
.VAO
->BufferBinding
[VERT_ATTRIB_GENERIC(index
)].Stride
;
2414 case GL_VERTEX_BINDING_BUFFER
:
2415 if (ctx
->API
== API_OPENGLES2
&& ctx
->Version
< 31)
2417 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
)
2419 v
->value_int
= ctx
->Array
.VAO
->BufferBinding
[VERT_ATTRIB_GENERIC(index
)].BufferObj
->Name
;
2422 /* ARB_shader_image_load_store */
2423 case GL_IMAGE_BINDING_NAME
: {
2424 struct gl_texture_object
*t
;
2426 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
2428 if (index
>= ctx
->Const
.MaxImageUnits
)
2431 t
= ctx
->ImageUnits
[index
].TexObj
;
2432 v
->value_int
= (t
? t
->Name
: 0);
2436 case GL_IMAGE_BINDING_LEVEL
:
2437 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
2439 if (index
>= ctx
->Const
.MaxImageUnits
)
2442 v
->value_int
= ctx
->ImageUnits
[index
].Level
;
2445 case GL_IMAGE_BINDING_LAYERED
:
2446 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
2448 if (index
>= ctx
->Const
.MaxImageUnits
)
2451 v
->value_int
= ctx
->ImageUnits
[index
].Layered
;
2454 case GL_IMAGE_BINDING_LAYER
:
2455 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
2457 if (index
>= ctx
->Const
.MaxImageUnits
)
2460 v
->value_int
= ctx
->ImageUnits
[index
].Layer
;
2463 case GL_IMAGE_BINDING_ACCESS
:
2464 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
2466 if (index
>= ctx
->Const
.MaxImageUnits
)
2469 v
->value_int
= ctx
->ImageUnits
[index
].Access
;
2472 case GL_IMAGE_BINDING_FORMAT
:
2473 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
2475 if (index
>= ctx
->Const
.MaxImageUnits
)
2478 v
->value_int
= ctx
->ImageUnits
[index
].Format
;
2481 /* ARB_direct_state_access */
2482 case GL_TEXTURE_BINDING_1D
:
2483 case GL_TEXTURE_BINDING_1D_ARRAY
:
2484 case GL_TEXTURE_BINDING_2D
:
2485 case GL_TEXTURE_BINDING_2D_ARRAY
:
2486 case GL_TEXTURE_BINDING_2D_MULTISAMPLE
:
2487 case GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY
:
2488 case GL_TEXTURE_BINDING_3D
:
2489 case GL_TEXTURE_BINDING_BUFFER
:
2490 case GL_TEXTURE_BINDING_CUBE_MAP
:
2491 case GL_TEXTURE_BINDING_CUBE_MAP_ARRAY
:
2492 case GL_TEXTURE_BINDING_RECTANGLE
: {
2495 if (ctx
->API
!= API_OPENGL_CORE
)
2497 target
= tex_binding_to_index(ctx
, pname
);
2500 if (index
>= _mesa_max_tex_unit(ctx
))
2503 v
->value_int
= ctx
->Texture
.Unit
[index
].CurrentTex
[target
]->Name
;
2507 case GL_SAMPLER_BINDING
: {
2508 struct gl_sampler_object
*samp
;
2510 if (ctx
->API
!= API_OPENGL_CORE
)
2512 if (index
>= _mesa_max_tex_unit(ctx
))
2515 samp
= ctx
->Texture
.Unit
[index
].Sampler
;
2516 v
->value_int
= samp
? samp
->Name
: 0;
2520 case GL_MAX_COMPUTE_WORK_GROUP_COUNT
:
2521 if (!_mesa_has_compute_shaders(ctx
))
2525 v
->value_int
= ctx
->Const
.MaxComputeWorkGroupCount
[index
];
2528 case GL_MAX_COMPUTE_WORK_GROUP_SIZE
:
2529 if (!_mesa_has_compute_shaders(ctx
))
2533 v
->value_int
= ctx
->Const
.MaxComputeWorkGroupSize
[index
];
2536 /* ARB_compute_variable_group_size */
2537 case GL_MAX_COMPUTE_VARIABLE_GROUP_SIZE_ARB
:
2538 if (!ctx
->Extensions
.ARB_compute_variable_group_size
)
2542 v
->value_int
= ctx
->Const
.MaxComputeVariableGroupSize
[index
];
2545 /* GL_EXT_external_objects */
2546 case GL_DRIVER_UUID_EXT
:
2547 _mesa_get_driver_uuid(ctx
, v
->value_int_4
);
2549 case GL_DEVICE_UUID_EXT
:
2550 _mesa_get_device_uuid(ctx
, v
->value_int_4
);
2555 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(pname=%s)", func
,
2556 _mesa_enum_to_string(pname
));
2557 return TYPE_INVALID
;
2559 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(pname=%s)", func
,
2560 _mesa_enum_to_string(pname
));
2561 return TYPE_INVALID
;
2565 _mesa_GetBooleani_v( GLenum pname
, GLuint index
, GLboolean
*params
)
2568 enum value_type type
=
2569 find_value_indexed("glGetBooleani_v", pname
, index
, &v
);
2574 params
[0] = INT_TO_BOOLEAN(v
.value_int
);
2578 params
[0] = INT_TO_BOOLEAN(v
.value_int_4
[0]);
2579 params
[1] = INT_TO_BOOLEAN(v
.value_int_4
[1]);
2580 params
[2] = INT_TO_BOOLEAN(v
.value_int_4
[2]);
2581 params
[3] = INT_TO_BOOLEAN(v
.value_int_4
[3]);
2584 params
[0] = INT64_TO_BOOLEAN(v
.value_int64
);
2587 ; /* nothing - GL error was recorded */
2592 _mesa_GetIntegeri_v( GLenum pname
, GLuint index
, GLint
*params
)
2595 enum value_type type
=
2596 find_value_indexed("glGetIntegeri_v", pname
, index
, &v
);
2601 params
[3] = IROUND(v
.value_float_4
[3]);
2604 params
[2] = IROUND(v
.value_float_4
[2]);
2607 params
[1] = IROUND(v
.value_float_4
[1]);
2610 params
[0] = IROUND(v
.value_float_4
[0]);
2613 case TYPE_DOUBLEN_2
:
2614 params
[1] = IROUND(v
.value_double_2
[1]);
2616 params
[0] = IROUND(v
.value_double_2
[0]);
2621 params
[0] = v
.value_int
;
2625 params
[0] = v
.value_int_4
[0];
2626 params
[1] = v
.value_int_4
[1];
2627 params
[2] = v
.value_int_4
[2];
2628 params
[3] = v
.value_int_4
[3];
2631 params
[0] = INT64_TO_INT(v
.value_int64
);
2634 ; /* nothing - GL error was recorded */
2639 _mesa_GetInteger64i_v( GLenum pname
, GLuint index
, GLint64
*params
)
2642 enum value_type type
=
2643 find_value_indexed("glGetInteger64i_v", pname
, index
, &v
);
2647 params
[0] = v
.value_int
;
2650 params
[0] = v
.value_int_4
[0];
2651 params
[1] = v
.value_int_4
[1];
2652 params
[2] = v
.value_int_4
[2];
2653 params
[3] = v
.value_int_4
[3];
2656 params
[0] = (GLuint
) v
.value_int
;
2659 params
[0] = (GLuint
) v
.value_int_4
[0];
2660 params
[1] = (GLuint
) v
.value_int_4
[1];
2661 params
[2] = (GLuint
) v
.value_int_4
[2];
2662 params
[3] = (GLuint
) v
.value_int_4
[3];
2665 params
[0] = v
.value_int64
;
2668 ; /* nothing - GL error was recorded */
2673 _mesa_GetFloati_v(GLenum pname
, GLuint index
, GLfloat
*params
)
2678 enum value_type type
=
2679 find_value_indexed("glGetFloati_v", pname
, index
, &v
);
2684 params
[3] = v
.value_float_4
[3];
2687 params
[2] = v
.value_float_4
[2];
2690 params
[1] = v
.value_float_4
[1];
2693 params
[0] = v
.value_float_4
[0];
2696 case TYPE_DOUBLEN_2
:
2697 params
[1] = (GLfloat
) v
.value_double_2
[1];
2699 params
[0] = (GLfloat
) v
.value_double_2
[0];
2703 params
[3] = (GLfloat
) v
.value_int_4
[3];
2705 params
[2] = (GLfloat
) v
.value_int_4
[2];
2708 params
[1] = (GLfloat
) v
.value_int_4
[1];
2711 params
[0] = (GLfloat
) v
.value_int_4
[0];
2715 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
2716 params
[i
] = (GLfloat
) v
.value_int_n
.ints
[i
];
2720 params
[3] = (GLfloat
) ((GLuint
) v
.value_int_4
[3]);
2722 params
[2] = (GLfloat
) ((GLuint
) v
.value_int_4
[2]);
2724 params
[1] = (GLfloat
) ((GLuint
) v
.value_int_4
[1]);
2726 params
[0] = (GLfloat
) ((GLuint
) v
.value_int_4
[0]);
2730 params
[0] = (GLfloat
) v
.value_int64
;
2734 params
[0] = BOOLEAN_TO_FLOAT(v
.value_bool
);
2738 m
= *(GLmatrix
**) &v
;
2739 for (i
= 0; i
< 16; i
++)
2740 params
[i
] = m
->m
[i
];
2744 m
= *(GLmatrix
**) &v
;
2745 for (i
= 0; i
< 16; i
++)
2746 params
[i
] = m
->m
[transpose
[i
]];
2755 _mesa_GetDoublei_v(GLenum pname
, GLuint index
, GLdouble
*params
)
2760 enum value_type type
=
2761 find_value_indexed("glGetDoublei_v", pname
, index
, &v
);
2766 params
[3] = (GLdouble
) v
.value_float_4
[3];
2769 params
[2] = (GLdouble
) v
.value_float_4
[2];
2772 params
[1] = (GLdouble
) v
.value_float_4
[1];
2775 params
[0] = (GLdouble
) v
.value_float_4
[0];
2778 case TYPE_DOUBLEN_2
:
2779 params
[1] = v
.value_double_2
[1];
2781 params
[0] = v
.value_double_2
[0];
2785 params
[3] = (GLdouble
) v
.value_int_4
[3];
2787 params
[2] = (GLdouble
) v
.value_int_4
[2];
2790 params
[1] = (GLdouble
) v
.value_int_4
[1];
2793 params
[0] = (GLdouble
) v
.value_int_4
[0];
2797 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
2798 params
[i
] = (GLdouble
) v
.value_int_n
.ints
[i
];
2802 params
[3] = (GLdouble
) ((GLuint
) v
.value_int_4
[3]);
2804 params
[2] = (GLdouble
) ((GLuint
) v
.value_int_4
[2]);
2806 params
[1] = (GLdouble
) ((GLuint
) v
.value_int_4
[1]);
2808 params
[0] = (GLdouble
) ((GLuint
) v
.value_int_4
[0]);
2812 params
[0] = (GLdouble
) v
.value_int64
;
2816 params
[0] = (GLdouble
) BOOLEAN_TO_FLOAT(v
.value_bool
);
2820 m
= *(GLmatrix
**) &v
;
2821 for (i
= 0; i
< 16; i
++)
2822 params
[i
] = (GLdouble
) m
->m
[i
];
2826 m
= *(GLmatrix
**) &v
;
2827 for (i
= 0; i
< 16; i
++)
2828 params
[i
] = (GLdouble
) m
->m
[transpose
[i
]];
2837 _mesa_GetUnsignedBytei_vEXT(GLenum target
, GLuint index
, GLubyte
*data
)
2841 enum value_type type
;
2842 const char *func
= "glGetUnsignedBytei_vEXT";
2844 GET_CURRENT_CONTEXT(ctx
);
2846 if (!ctx
->Extensions
.EXT_memory_object
) {
2847 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(unsupported)", func
);
2851 type
= find_value_indexed(func
, target
, index
, &v
);
2852 size
= get_value_size(type
, &v
);
2854 _mesa_problem(ctx
, "invalid value type in GetUnsignedBytei_vEXT()");
2880 case TYPE_DOUBLEN_2
:
2883 memcpy(data
, &v
.value_int
, size
);
2886 memcpy(data
, &v
.value_int_n
.ints
, size
);
2889 break; /* nothing - GL error was recorded */
2894 _mesa_GetFixedv(GLenum pname
, GLfixed
*params
)
2896 const struct value_desc
*d
;
2902 d
= find_value("glGetDoublev", pname
, &p
, &v
);
2907 params
[0] = INT_TO_FIXED(d
->offset
);
2912 params
[3] = FLOAT_TO_FIXED(((GLfloat
*) p
)[3]);
2915 params
[2] = FLOAT_TO_FIXED(((GLfloat
*) p
)[2]);
2918 params
[1] = FLOAT_TO_FIXED(((GLfloat
*) p
)[1]);
2921 params
[0] = FLOAT_TO_FIXED(((GLfloat
*) p
)[0]);
2924 case TYPE_DOUBLEN_2
:
2925 params
[1] = FLOAT_TO_FIXED(((GLdouble
*) p
)[1]);
2927 params
[0] = FLOAT_TO_FIXED(((GLdouble
*) p
)[0]);
2932 params
[3] = INT_TO_FIXED(((GLint
*) p
)[3]);
2935 params
[2] = INT_TO_FIXED(((GLint
*) p
)[2]);
2939 params
[1] = INT_TO_FIXED(((GLint
*) p
)[1]);
2943 params
[0] = INT_TO_FIXED(((GLint
*) p
)[0]);
2947 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
2948 params
[i
] = INT_TO_FIXED(v
.value_int_n
.ints
[i
]);
2952 params
[0] = ((GLint64
*) p
)[0];
2956 params
[0] = BOOLEAN_TO_FIXED(((GLboolean
*) p
)[0]);
2960 m
= *(GLmatrix
**) p
;
2961 for (i
= 0; i
< 16; i
++)
2962 params
[i
] = FLOAT_TO_FIXED(m
->m
[i
]);
2966 m
= *(GLmatrix
**) p
;
2967 for (i
= 0; i
< 16; i
++)
2968 params
[i
] = FLOAT_TO_FIXED(m
->m
[transpose
[i
]]);
2979 shift
= d
->type
- TYPE_BIT_0
;
2980 params
[0] = BOOLEAN_TO_FIXED((*(GLbitfield
*) p
>> shift
) & 1);