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)
132 enum value_location
{
154 EXTRA_NEW_FRAG_CLAMP
,
155 EXTRA_VALID_DRAW_BUFFER
,
156 EXTRA_VALID_TEXTURE_UNIT
,
157 EXTRA_VALID_CLIP_DISTANCE
,
161 EXTRA_EXT_ATOMICS_GS
,
162 EXTRA_EXT_SHADER_IMAGE_GS
,
163 EXTRA_EXT_ATOMICS_TESS
,
164 EXTRA_EXT_SHADER_IMAGE_TESS
,
166 EXTRA_EXT_FB_NO_ATTACH_GS
,
168 EXTRA_EXT_PROVOKING_VERTEX_32
,
171 #define NO_EXTRA NULL
176 GLubyte location
; /**< enum value_location */
177 GLubyte type
; /**< enum value_type */
184 GLfloat value_float_4
[4];
185 GLdouble value_double_2
[2];
186 GLmatrix
*value_matrix
;
188 GLint value_int_4
[4];
192 /* Sigh, see GL_COMPRESSED_TEXTURE_FORMATS_ARB handling */
196 GLboolean value_bool
;
199 #define BUFFER_FIELD(field, type) \
200 LOC_BUFFER, type, offsetof(struct gl_framebuffer, field)
201 #define CONTEXT_FIELD(field, type) \
202 LOC_CONTEXT, type, offsetof(struct gl_context, field)
203 #define ARRAY_FIELD(field, type) \
204 LOC_ARRAY, type, offsetof(struct gl_vertex_array_object, field)
205 #undef CONST /* already defined through windows.h */
206 #define CONST(value) \
207 LOC_CONTEXT, TYPE_CONST, value
209 #define BUFFER_INT(field) BUFFER_FIELD(field, TYPE_INT)
210 #define BUFFER_ENUM(field) BUFFER_FIELD(field, TYPE_ENUM)
211 #define BUFFER_ENUM16(field) BUFFER_FIELD(field, TYPE_ENUM16)
212 #define BUFFER_BOOL(field) BUFFER_FIELD(field, TYPE_BOOLEAN)
214 #define CONTEXT_INT(field) CONTEXT_FIELD(field, TYPE_INT)
215 #define CONTEXT_INT2(field) CONTEXT_FIELD(field, TYPE_INT_2)
216 #define CONTEXT_INT64(field) CONTEXT_FIELD(field, TYPE_INT64)
217 #define CONTEXT_UINT(field) CONTEXT_FIELD(field, TYPE_UINT)
218 #define CONTEXT_ENUM16(field) CONTEXT_FIELD(field, TYPE_ENUM16)
219 #define CONTEXT_ENUM(field) CONTEXT_FIELD(field, TYPE_ENUM)
220 #define CONTEXT_ENUM2(field) CONTEXT_FIELD(field, TYPE_ENUM_2)
221 #define CONTEXT_BOOL(field) CONTEXT_FIELD(field, TYPE_BOOLEAN)
222 #define CONTEXT_BIT0(field) CONTEXT_FIELD(field, TYPE_BIT_0)
223 #define CONTEXT_BIT1(field) CONTEXT_FIELD(field, TYPE_BIT_1)
224 #define CONTEXT_BIT2(field) CONTEXT_FIELD(field, TYPE_BIT_2)
225 #define CONTEXT_BIT3(field) CONTEXT_FIELD(field, TYPE_BIT_3)
226 #define CONTEXT_BIT4(field) CONTEXT_FIELD(field, TYPE_BIT_4)
227 #define CONTEXT_BIT5(field) CONTEXT_FIELD(field, TYPE_BIT_5)
228 #define CONTEXT_BIT6(field) CONTEXT_FIELD(field, TYPE_BIT_6)
229 #define CONTEXT_BIT7(field) CONTEXT_FIELD(field, TYPE_BIT_7)
230 #define CONTEXT_FLOAT(field) CONTEXT_FIELD(field, TYPE_FLOAT)
231 #define CONTEXT_FLOAT2(field) CONTEXT_FIELD(field, TYPE_FLOAT_2)
232 #define CONTEXT_FLOAT3(field) CONTEXT_FIELD(field, TYPE_FLOAT_3)
233 #define CONTEXT_FLOAT4(field) CONTEXT_FIELD(field, TYPE_FLOAT_4)
234 #define CONTEXT_FLOAT8(field) CONTEXT_FIELD(field, TYPE_FLOAT_8)
235 #define CONTEXT_MATRIX(field) CONTEXT_FIELD(field, TYPE_MATRIX)
236 #define CONTEXT_MATRIX_T(field) CONTEXT_FIELD(field, TYPE_MATRIX_T)
238 #define ARRAY_INT(field) ARRAY_FIELD(field, TYPE_INT)
239 #define ARRAY_ENUM(field) ARRAY_FIELD(field, TYPE_ENUM)
240 #define ARRAY_ENUM16(field) ARRAY_FIELD(field, TYPE_ENUM16)
241 #define ARRAY_BOOL(field) ARRAY_FIELD(field, TYPE_BOOLEAN)
244 offsetof(struct gl_extensions, f)
246 #define EXTRA_EXT(e) \
247 static const int extra_##e[] = { \
251 #define EXTRA_EXT2(e1, e2) \
252 static const int extra_##e1##_##e2[] = { \
253 EXT(e1), EXT(e2), EXTRA_END \
256 /* The 'extra' mechanism is a way to specify extra checks (such as
257 * extensions or specific gl versions) or actions (flush current, new
258 * buffers) that we need to do before looking up an enum. We need to
259 * declare them all up front so we can refer to them in the value_desc
262 * Each EXTRA_ will be executed. For EXTRA_* enums of extensions and API
263 * versions, listing multiple ones in an array means an error will be thrown
264 * only if none of them are available. If you need to check for "AND"
265 * behavior, you would need to make a custom EXTRA_ enum.
268 static const int extra_new_buffers
[] = {
273 static const int extra_new_frag_clamp
[] = {
274 EXTRA_NEW_FRAG_CLAMP
,
278 static const int extra_valid_draw_buffer
[] = {
279 EXTRA_VALID_DRAW_BUFFER
,
283 static const int extra_valid_texture_unit
[] = {
284 EXTRA_VALID_TEXTURE_UNIT
,
288 static const int extra_valid_clip_distance
[] = {
289 EXTRA_VALID_CLIP_DISTANCE
,
293 static const int extra_flush_current_valid_texture_unit
[] = {
295 EXTRA_VALID_TEXTURE_UNIT
,
299 static const int extra_flush_current
[] = {
304 static const int extra_EXT_texture_integer_and_new_buffers
[] = {
305 EXT(EXT_texture_integer
),
310 static const int extra_GLSL_130_es3
[] = {
316 static const int extra_texture_buffer_object
[] = {
317 EXT(ARB_texture_buffer_object
),
321 static const int extra_ARB_transform_feedback2_api_es3
[] = {
322 EXT(ARB_transform_feedback2
),
327 static const int extra_ARB_uniform_buffer_object_and_geometry_shader
[] = {
332 static const int extra_ARB_ES2_compatibility_api_es2
[] = {
333 EXT(ARB_ES2_compatibility
),
338 static const int extra_ARB_ES3_compatibility_api_es3
[] = {
339 EXT(ARB_ES3_compatibility
),
344 static const int extra_EXT_framebuffer_sRGB_and_new_buffers
[] = {
345 EXT(EXT_framebuffer_sRGB
),
350 static const int extra_EXT_packed_float
[] = {
351 EXT(EXT_packed_float
),
356 static const int extra_EXT_texture_array_es3
[] = {
357 EXT(EXT_texture_array
),
362 static const int extra_ARB_shader_atomic_counters_and_geometry_shader
[] = {
363 EXTRA_EXT_ATOMICS_GS
,
367 static const int extra_ARB_shader_image_load_store_and_geometry_shader
[] = {
368 EXTRA_EXT_SHADER_IMAGE_GS
,
372 static const int extra_ARB_shader_atomic_counters_and_tessellation
[] = {
373 EXTRA_EXT_ATOMICS_TESS
,
377 static const int extra_ARB_shader_image_load_store_and_tessellation
[] = {
378 EXTRA_EXT_SHADER_IMAGE_TESS
,
382 /* HACK: remove when ARB_compute_shader is actually supported */
383 static const int extra_ARB_compute_shader_es31
[] = {
384 EXT(ARB_compute_shader
),
389 static const int extra_ARB_shader_storage_buffer_object_es31
[] = {
390 EXT(ARB_shader_storage_buffer_object
),
395 static const int extra_ARB_shader_storage_buffer_object_and_geometry_shader
[] = {
400 static const int extra_ARB_shader_image_load_store_shader_storage_buffer_object_es31
[] = {
401 EXT(ARB_shader_image_load_store
),
402 EXT(ARB_shader_storage_buffer_object
),
407 static const int extra_ARB_framebuffer_no_attachments_and_geometry_shader
[] = {
408 EXTRA_EXT_FB_NO_ATTACH_GS
,
412 static const int extra_ARB_viewport_array_or_oes_geometry_shader
[] = {
413 EXT(ARB_viewport_array
),
418 static const int extra_ARB_viewport_array_or_oes_viewport_array
[] = {
419 EXT(ARB_viewport_array
),
420 EXT(OES_viewport_array
),
424 static const int extra_ARB_gpu_shader5_or_oes_geometry_shader
[] = {
425 EXT(ARB_gpu_shader5
),
430 static const int extra_ARB_gpu_shader5_or_OES_sample_variables
[] = {
431 EXT(ARB_gpu_shader5
),
432 EXT(OES_sample_variables
),
436 static const int extra_ES32
[] = {
437 EXT(ARB_ES3_2_compatibility
),
442 static const int extra_KHR_robustness_or_GL
[] = {
449 static const int extra_INTEL_conservative_rasterization
[] = {
450 EXT(INTEL_conservative_rasterization
),
454 EXTRA_EXT(ARB_texture_cube_map
);
455 EXTRA_EXT(EXT_texture_array
);
456 EXTRA_EXT(NV_fog_distance
);
457 EXTRA_EXT(EXT_texture_filter_anisotropic
);
458 EXTRA_EXT(NV_point_sprite
);
459 EXTRA_EXT(NV_texture_rectangle
);
460 EXTRA_EXT(EXT_stencil_two_side
);
461 EXTRA_EXT(EXT_depth_bounds_test
);
462 EXTRA_EXT(ARB_depth_clamp
);
463 EXTRA_EXT(ATI_fragment_shader
);
464 EXTRA_EXT(EXT_provoking_vertex
);
465 EXTRA_EXT(ARB_fragment_shader
);
466 EXTRA_EXT(ARB_fragment_program
);
467 EXTRA_EXT2(ARB_framebuffer_object
, EXT_framebuffer_multisample
);
468 EXTRA_EXT(ARB_seamless_cube_map
);
470 EXTRA_EXT(ARB_vertex_shader
);
471 EXTRA_EXT(EXT_transform_feedback
);
472 EXTRA_EXT(ARB_transform_feedback3
);
473 EXTRA_EXT(EXT_pixel_buffer_object
);
474 EXTRA_EXT(ARB_vertex_program
);
475 EXTRA_EXT2(NV_point_sprite
, ARB_point_sprite
);
476 EXTRA_EXT2(ARB_vertex_program
, ARB_fragment_program
);
477 EXTRA_EXT(ARB_color_buffer_float
);
478 EXTRA_EXT(EXT_framebuffer_sRGB
);
479 EXTRA_EXT(OES_EGL_image_external
);
480 EXTRA_EXT(ARB_blend_func_extended
);
481 EXTRA_EXT(ARB_uniform_buffer_object
);
482 EXTRA_EXT(ARB_timer_query
);
483 EXTRA_EXT2(ARB_texture_cube_map_array
, OES_texture_cube_map_array
);
484 EXTRA_EXT(ARB_texture_buffer_range
);
485 EXTRA_EXT(ARB_texture_multisample
);
486 EXTRA_EXT(ARB_texture_gather
);
487 EXTRA_EXT(ARB_shader_atomic_counters
);
488 EXTRA_EXT(ARB_draw_indirect
);
489 EXTRA_EXT(ARB_shader_image_load_store
);
490 EXTRA_EXT(ARB_query_buffer_object
);
491 EXTRA_EXT2(ARB_transform_feedback3
, ARB_gpu_shader5
);
492 EXTRA_EXT(INTEL_performance_query
);
493 EXTRA_EXT(ARB_explicit_uniform_location
);
494 EXTRA_EXT(ARB_clip_control
);
495 EXTRA_EXT(ARB_polygon_offset_clamp
);
496 EXTRA_EXT(ARB_framebuffer_no_attachments
);
497 EXTRA_EXT(ARB_tessellation_shader
);
498 EXTRA_EXT(ARB_shader_storage_buffer_object
);
499 EXTRA_EXT(ARB_indirect_parameters
);
500 EXTRA_EXT(ATI_meminfo
);
501 EXTRA_EXT(NVX_gpu_memory_info
);
502 EXTRA_EXT(ARB_cull_distance
);
503 EXTRA_EXT(EXT_window_rectangles
);
504 EXTRA_EXT(KHR_blend_equation_advanced_coherent
);
505 EXTRA_EXT(OES_primitive_bounding_box
);
506 EXTRA_EXT(ARB_compute_variable_group_size
);
507 EXTRA_EXT(KHR_robustness
);
508 EXTRA_EXT(ARB_sparse_buffer
);
509 EXTRA_EXT(NV_conservative_raster
);
510 EXTRA_EXT(NV_conservative_raster_dilate
);
511 EXTRA_EXT(NV_conservative_raster_pre_snap_triangles
);
514 extra_ARB_color_buffer_float_or_glcore
[] = {
515 EXT(ARB_color_buffer_float
),
521 extra_NV_primitive_restart
[] = {
522 EXT(NV_primitive_restart
),
526 static const int extra_version_30
[] = { EXTRA_VERSION_30
, EXTRA_END
};
527 static const int extra_version_31
[] = { EXTRA_VERSION_31
, EXTRA_END
};
528 static const int extra_version_32
[] = { EXTRA_VERSION_32
, EXTRA_END
};
529 static const int extra_version_43
[] = { EXTRA_VERSION_43
, EXTRA_END
};
531 static const int extra_gl30_es3
[] = {
537 static const int extra_gl32_es3
[] = {
543 static const int extra_version_32_OES_geometry_shader
[] = {
549 static const int extra_gl40_ARB_sample_shading
[] = {
551 EXT(ARB_sample_shading
),
556 extra_ARB_vertex_program_api_es2
[] = {
557 EXT(ARB_vertex_program
),
562 /* The ReadBuffer get token is valid under either full GL or under
563 * GLES2 if the NV_read_buffer extension is available. */
565 extra_NV_read_buffer_api_gl
[] = {
571 static const int extra_core_ARB_color_buffer_float_and_new_buffers
[] = {
573 EXT(ARB_color_buffer_float
),
578 static const int extra_EXT_shader_framebuffer_fetch
[] = {
581 EXT(EXT_shader_framebuffer_fetch
),
585 static const int extra_EXT_provoking_vertex_32
[] = {
586 EXTRA_EXT_PROVOKING_VERTEX_32
,
590 static const int extra_EXT_disjoint_timer_query
[] = {
593 EXT(EXT_disjoint_timer_query
),
598 /* This is the big table describing all the enums we accept in
599 * glGet*v(). The table is partitioned into six parts: enums
600 * understood by all GL APIs (OpenGL, GLES and GLES2), enums shared
601 * between OpenGL and GLES, enums exclusive to GLES, etc for the
602 * remaining combinations. To look up the enums valid in a given API
603 * we will use a hash table specific to that API. These tables are in
604 * turn generated at build time and included through get_hash.h.
607 #include "get_hash.h"
609 /* All we need now is a way to look up the value struct from the enum.
610 * The code generated by gcc for the old generated big switch
611 * statement is a big, balanced, open coded if/else tree, essentially
612 * an unrolled binary search. It would be natural to sort the new
613 * enum table and use bsearch(), but we will use a read-only hash
614 * table instead. bsearch() has a nice guaranteed worst case
615 * performance, but we're also guaranteed to hit that worst case
616 * (log2(n) iterations) for about half the enums. Instead, using an
617 * open addressing hash table, we can find the enum on the first try
618 * for 80% of the enums, 1 collision for 10% and never more than 5
619 * collisions for any enum (typical numbers). And the code is very
620 * simple, even though it feels a little magic. */
623 * Handle irregular enums
625 * Some values don't conform to the "well-known type at context
626 * pointer + offset" pattern, so we have this function to catch all
627 * the corner cases. Typically, it's a computed value or a one-off
628 * pointer to a custom struct or something.
630 * In this case we can't return a pointer to the value, so we'll have
631 * to use the temporary variable 'v' declared back in the calling
632 * glGet*v() function to store the result.
634 * \param ctx the current context
635 * \param d the struct value_desc that describes the enum
636 * \param v pointer to the tmp declared in the calling glGet*v() function
639 find_custom_value(struct gl_context
*ctx
, const struct value_desc
*d
, union value
*v
)
641 struct gl_buffer_object
**buffer_obj
;
642 struct gl_array_attributes
*array
;
646 case GL_MAJOR_VERSION
:
647 v
->value_int
= ctx
->Version
/ 10;
649 case GL_MINOR_VERSION
:
650 v
->value_int
= ctx
->Version
% 10;
656 case GL_TEXTURE_CUBE_MAP
:
657 case GL_TEXTURE_RECTANGLE_NV
:
658 case GL_TEXTURE_EXTERNAL_OES
:
659 v
->value_bool
= _mesa_IsEnabled(d
->pname
);
662 case GL_LINE_STIPPLE_PATTERN
:
663 /* This is the only GLushort, special case it here by promoting
664 * to an int rather than introducing a new type. */
665 v
->value_int
= ctx
->Line
.StipplePattern
;
668 case GL_CURRENT_RASTER_TEXTURE_COORDS
:
669 unit
= ctx
->Texture
.CurrentUnit
;
670 v
->value_float_4
[0] = ctx
->Current
.RasterTexCoords
[unit
][0];
671 v
->value_float_4
[1] = ctx
->Current
.RasterTexCoords
[unit
][1];
672 v
->value_float_4
[2] = ctx
->Current
.RasterTexCoords
[unit
][2];
673 v
->value_float_4
[3] = ctx
->Current
.RasterTexCoords
[unit
][3];
676 case GL_CURRENT_TEXTURE_COORDS
:
677 unit
= ctx
->Texture
.CurrentUnit
;
678 v
->value_float_4
[0] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
][0];
679 v
->value_float_4
[1] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
][1];
680 v
->value_float_4
[2] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
][2];
681 v
->value_float_4
[3] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
][3];
684 case GL_COLOR_WRITEMASK
:
685 v
->value_int_4
[0] = GET_COLORMASK_BIT(ctx
->Color
.ColorMask
, 0, 0);
686 v
->value_int_4
[1] = GET_COLORMASK_BIT(ctx
->Color
.ColorMask
, 0, 1);
687 v
->value_int_4
[2] = GET_COLORMASK_BIT(ctx
->Color
.ColorMask
, 0, 2);
688 v
->value_int_4
[3] = GET_COLORMASK_BIT(ctx
->Color
.ColorMask
, 0, 3);
692 v
->value_bool
= ctx
->Current
.Attrib
[VERT_ATTRIB_EDGEFLAG
][0] == 1.0F
;
696 v
->value_enum
= ctx
->ReadBuffer
->ColorReadBuffer
;
699 case GL_MAP2_GRID_DOMAIN
:
700 v
->value_float_4
[0] = ctx
->Eval
.MapGrid2u1
;
701 v
->value_float_4
[1] = ctx
->Eval
.MapGrid2u2
;
702 v
->value_float_4
[2] = ctx
->Eval
.MapGrid2v1
;
703 v
->value_float_4
[3] = ctx
->Eval
.MapGrid2v2
;
706 case GL_TEXTURE_STACK_DEPTH
:
707 unit
= ctx
->Texture
.CurrentUnit
;
708 v
->value_int
= ctx
->TextureMatrixStack
[unit
].Depth
+ 1;
710 case GL_TEXTURE_MATRIX
:
711 unit
= ctx
->Texture
.CurrentUnit
;
712 v
->value_matrix
= ctx
->TextureMatrixStack
[unit
].Top
;
715 case GL_TEXTURE_COORD_ARRAY
:
716 case GL_TEXTURE_COORD_ARRAY_SIZE
:
717 case GL_TEXTURE_COORD_ARRAY_TYPE
:
718 case GL_TEXTURE_COORD_ARRAY_STRIDE
:
719 array
= &ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_TEX(ctx
->Array
.ActiveTexture
)];
720 v
->value_int
= *(GLuint
*) ((char *) array
+ d
->offset
);
723 case GL_ACTIVE_TEXTURE_ARB
:
724 v
->value_int
= GL_TEXTURE0_ARB
+ ctx
->Texture
.CurrentUnit
;
726 case GL_CLIENT_ACTIVE_TEXTURE_ARB
:
727 v
->value_int
= GL_TEXTURE0_ARB
+ ctx
->Array
.ActiveTexture
;
730 case GL_MODELVIEW_STACK_DEPTH
:
731 case GL_PROJECTION_STACK_DEPTH
:
732 v
->value_int
= *(GLint
*) ((char *) ctx
+ d
->offset
) + 1;
735 case GL_MAX_TEXTURE_SIZE
:
736 case GL_MAX_3D_TEXTURE_SIZE
:
737 case GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB
:
738 p
= (GLuint
*) ((char *) ctx
+ d
->offset
);
739 v
->value_int
= 1 << (*p
- 1);
743 v
->value_int_4
[0] = ctx
->Scissor
.ScissorArray
[0].X
;
744 v
->value_int_4
[1] = ctx
->Scissor
.ScissorArray
[0].Y
;
745 v
->value_int_4
[2] = ctx
->Scissor
.ScissorArray
[0].Width
;
746 v
->value_int_4
[3] = ctx
->Scissor
.ScissorArray
[0].Height
;
749 case GL_SCISSOR_TEST
:
750 v
->value_bool
= ctx
->Scissor
.EnableFlags
& 1;
755 ctx
->ListState
.CurrentList
? ctx
->ListState
.CurrentList
->Name
: 0;
758 if (!ctx
->CompileFlag
)
760 else if (ctx
->ExecuteFlag
)
761 v
->value_enum
= GL_COMPILE_AND_EXECUTE
;
763 v
->value_enum
= GL_COMPILE
;
767 v
->value_float_4
[0] = ctx
->ViewportArray
[0].X
;
768 v
->value_float_4
[1] = ctx
->ViewportArray
[0].Y
;
769 v
->value_float_4
[2] = ctx
->ViewportArray
[0].Width
;
770 v
->value_float_4
[3] = ctx
->ViewportArray
[0].Height
;
774 v
->value_double_2
[0] = ctx
->ViewportArray
[0].Near
;
775 v
->value_double_2
[1] = ctx
->ViewportArray
[0].Far
;
778 case GL_ACTIVE_STENCIL_FACE_EXT
:
779 v
->value_enum
= ctx
->Stencil
.ActiveFace
? GL_BACK
: GL_FRONT
;
782 case GL_STENCIL_FAIL
:
783 v
->value_enum
= ctx
->Stencil
.FailFunc
[ctx
->Stencil
.ActiveFace
];
785 case GL_STENCIL_FUNC
:
786 v
->value_enum
= ctx
->Stencil
.Function
[ctx
->Stencil
.ActiveFace
];
788 case GL_STENCIL_PASS_DEPTH_FAIL
:
789 v
->value_enum
= ctx
->Stencil
.ZFailFunc
[ctx
->Stencil
.ActiveFace
];
791 case GL_STENCIL_PASS_DEPTH_PASS
:
792 v
->value_enum
= ctx
->Stencil
.ZPassFunc
[ctx
->Stencil
.ActiveFace
];
795 v
->value_int
= _mesa_get_stencil_ref(ctx
, ctx
->Stencil
.ActiveFace
);
797 case GL_STENCIL_BACK_REF
:
798 v
->value_int
= _mesa_get_stencil_ref(ctx
, 1);
800 case GL_STENCIL_VALUE_MASK
:
801 v
->value_int
= ctx
->Stencil
.ValueMask
[ctx
->Stencil
.ActiveFace
];
803 case GL_STENCIL_WRITEMASK
:
804 v
->value_int
= ctx
->Stencil
.WriteMask
[ctx
->Stencil
.ActiveFace
];
807 case GL_NUM_EXTENSIONS
:
808 v
->value_int
= _mesa_get_extension_count(ctx
);
811 case GL_IMPLEMENTATION_COLOR_READ_TYPE_OES
:
812 v
->value_int
= _mesa_get_color_read_type(ctx
, NULL
, "glGetIntegerv");
814 case GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES
:
815 v
->value_int
= _mesa_get_color_read_format(ctx
, NULL
, "glGetIntegerv");
818 case GL_CURRENT_MATRIX_STACK_DEPTH_ARB
:
819 v
->value_int
= ctx
->CurrentStack
->Depth
+ 1;
821 case GL_CURRENT_MATRIX_ARB
:
822 case GL_TRANSPOSE_CURRENT_MATRIX_ARB
:
823 v
->value_matrix
= ctx
->CurrentStack
->Top
;
826 case GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB
:
827 v
->value_int
= _mesa_get_compressed_formats(ctx
, NULL
);
829 case GL_COMPRESSED_TEXTURE_FORMATS_ARB
:
831 _mesa_get_compressed_formats(ctx
, v
->value_int_n
.ints
);
832 assert(v
->value_int_n
.n
<= (int) ARRAY_SIZE(v
->value_int_n
.ints
));
835 case GL_MAX_VARYING_FLOATS_ARB
:
836 v
->value_int
= ctx
->Const
.MaxVarying
* 4;
839 /* Various object names */
841 case GL_TEXTURE_BINDING_1D
:
842 case GL_TEXTURE_BINDING_2D
:
843 case GL_TEXTURE_BINDING_3D
:
844 case GL_TEXTURE_BINDING_1D_ARRAY_EXT
:
845 case GL_TEXTURE_BINDING_2D_ARRAY_EXT
:
846 case GL_TEXTURE_BINDING_CUBE_MAP_ARB
:
847 case GL_TEXTURE_BINDING_RECTANGLE_NV
:
848 case GL_TEXTURE_BINDING_EXTERNAL_OES
:
849 case GL_TEXTURE_BINDING_CUBE_MAP_ARRAY
:
850 case GL_TEXTURE_BINDING_2D_MULTISAMPLE
:
851 case GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY
:
852 unit
= ctx
->Texture
.CurrentUnit
;
854 ctx
->Texture
.Unit
[unit
].CurrentTex
[d
->offset
]->Name
;
857 /* GL_EXT_external_objects */
858 case GL_DRIVER_UUID_EXT
:
859 _mesa_get_driver_uuid(ctx
, v
->value_int_4
);
861 case GL_DEVICE_UUID_EXT
:
862 _mesa_get_device_uuid(ctx
, v
->value_int_4
);
865 /* GL_EXT_packed_float */
866 case GL_RGBA_SIGNED_COMPONENTS_EXT
:
868 /* Note: we only check the 0th color attachment. */
869 const struct gl_renderbuffer
*rb
=
870 ctx
->DrawBuffer
->_ColorDrawBuffers
[0];
871 if (rb
&& _mesa_is_format_signed(rb
->Format
)) {
872 /* Issue 17 of GL_EXT_packed_float: If a component (such as
873 * alpha) has zero bits, the component should not be considered
874 * signed and so the bit for the respective component should be
878 _mesa_get_format_bits(rb
->Format
, GL_RED_BITS
);
880 _mesa_get_format_bits(rb
->Format
, GL_GREEN_BITS
);
882 _mesa_get_format_bits(rb
->Format
, GL_BLUE_BITS
);
884 _mesa_get_format_bits(rb
->Format
, GL_ALPHA_BITS
);
886 _mesa_get_format_bits(rb
->Format
, GL_TEXTURE_LUMINANCE_SIZE
);
888 _mesa_get_format_bits(rb
->Format
, GL_TEXTURE_INTENSITY_SIZE
);
890 v
->value_int_4
[0] = r_bits
+ l_bits
+ i_bits
> 0;
891 v
->value_int_4
[1] = g_bits
+ l_bits
+ i_bits
> 0;
892 v
->value_int_4
[2] = b_bits
+ l_bits
+ i_bits
> 0;
893 v
->value_int_4
[3] = a_bits
+ i_bits
> 0;
899 v
->value_int_4
[3] = 0;
904 /* GL_ARB_vertex_buffer_object */
905 case GL_VERTEX_ARRAY_BUFFER_BINDING_ARB
:
906 case GL_NORMAL_ARRAY_BUFFER_BINDING_ARB
:
907 case GL_COLOR_ARRAY_BUFFER_BINDING_ARB
:
908 case GL_INDEX_ARRAY_BUFFER_BINDING_ARB
:
909 case GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB
:
910 case GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB
:
911 case GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB
:
912 buffer_obj
= (struct gl_buffer_object
**)
913 ((char *) ctx
->Array
.VAO
+ d
->offset
);
914 v
->value_int
= (*buffer_obj
)->Name
;
916 case GL_ARRAY_BUFFER_BINDING_ARB
:
917 v
->value_int
= ctx
->Array
.ArrayBufferObj
->Name
;
919 case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB
:
921 ctx
->Array
.VAO
->BufferBinding
[VERT_ATTRIB_TEX(ctx
->Array
.ActiveTexture
)].BufferObj
->Name
;
923 case GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB
:
924 v
->value_int
= ctx
->Array
.VAO
->IndexBufferObj
->Name
;
927 /* ARB_vertex_array_bgra */
928 case GL_COLOR_ARRAY_SIZE
:
929 array
= &ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_COLOR0
];
930 v
->value_int
= array
->Format
== GL_BGRA
? GL_BGRA
: array
->Size
;
932 case GL_SECONDARY_COLOR_ARRAY_SIZE
:
933 array
= &ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_COLOR1
];
934 v
->value_int
= array
->Format
== GL_BGRA
? GL_BGRA
: array
->Size
;
937 /* ARB_copy_buffer */
938 case GL_COPY_READ_BUFFER
:
939 v
->value_int
= ctx
->CopyReadBuffer
->Name
;
941 case GL_COPY_WRITE_BUFFER
:
942 v
->value_int
= ctx
->CopyWriteBuffer
->Name
;
945 case GL_PIXEL_PACK_BUFFER_BINDING_EXT
:
946 v
->value_int
= ctx
->Pack
.BufferObj
->Name
;
948 case GL_PIXEL_UNPACK_BUFFER_BINDING_EXT
:
949 v
->value_int
= ctx
->Unpack
.BufferObj
->Name
;
951 case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING
:
952 v
->value_int
= ctx
->TransformFeedback
.CurrentBuffer
->Name
;
954 case GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED
:
955 v
->value_int
= ctx
->TransformFeedback
.CurrentObject
->Paused
;
957 case GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE
:
958 v
->value_int
= ctx
->TransformFeedback
.CurrentObject
->Active
;
960 case GL_TRANSFORM_FEEDBACK_BINDING
:
961 v
->value_int
= ctx
->TransformFeedback
.CurrentObject
->Name
;
963 case GL_CURRENT_PROGRAM
:
964 /* The Changelog of the ARB_separate_shader_objects spec says:
966 * 24 25 Jul 2011 pbrown Remove the language erroneously deleting
967 * CURRENT_PROGRAM. In the EXT extension, this
968 * token was aliased to ACTIVE_PROGRAM_EXT, and
969 * was used to indicate the last program set by
970 * either ActiveProgramEXT or UseProgram. In
971 * the ARB extension, the SSO active programs
972 * are now program pipeline object state and
973 * CURRENT_PROGRAM should still be used to query
974 * the last program set by UseProgram (bug 7822).
977 ctx
->Shader
.ActiveProgram
? ctx
->Shader
.ActiveProgram
->Name
: 0;
979 case GL_READ_FRAMEBUFFER_BINDING_EXT
:
980 v
->value_int
= ctx
->ReadBuffer
->Name
;
982 case GL_RENDERBUFFER_BINDING_EXT
:
984 ctx
->CurrentRenderbuffer
? ctx
->CurrentRenderbuffer
->Name
: 0;
986 case GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES
:
987 v
->value_int
= ctx
->Array
.VAO
->BufferBinding
[VERT_ATTRIB_POINT_SIZE
].BufferObj
->Name
;
991 if (_mesa_get_clamp_fragment_color(ctx
, ctx
->DrawBuffer
))
992 COPY_4FV(v
->value_float_4
, ctx
->Fog
.Color
);
994 COPY_4FV(v
->value_float_4
, ctx
->Fog
.ColorUnclamped
);
996 case GL_COLOR_CLEAR_VALUE
:
997 if (_mesa_get_clamp_fragment_color(ctx
, ctx
->DrawBuffer
)) {
998 v
->value_float_4
[0] = CLAMP(ctx
->Color
.ClearColor
.f
[0], 0.0F
, 1.0F
);
999 v
->value_float_4
[1] = CLAMP(ctx
->Color
.ClearColor
.f
[1], 0.0F
, 1.0F
);
1000 v
->value_float_4
[2] = CLAMP(ctx
->Color
.ClearColor
.f
[2], 0.0F
, 1.0F
);
1001 v
->value_float_4
[3] = CLAMP(ctx
->Color
.ClearColor
.f
[3], 0.0F
, 1.0F
);
1003 COPY_4FV(v
->value_float_4
, ctx
->Color
.ClearColor
.f
);
1005 case GL_BLEND_COLOR_EXT
:
1006 if (_mesa_get_clamp_fragment_color(ctx
, ctx
->DrawBuffer
))
1007 COPY_4FV(v
->value_float_4
, ctx
->Color
.BlendColor
);
1009 COPY_4FV(v
->value_float_4
, ctx
->Color
.BlendColorUnclamped
);
1011 case GL_ALPHA_TEST_REF
:
1012 if (_mesa_get_clamp_fragment_color(ctx
, ctx
->DrawBuffer
))
1013 v
->value_float
= ctx
->Color
.AlphaRef
;
1015 v
->value_float
= ctx
->Color
.AlphaRefUnclamped
;
1017 case GL_MAX_VERTEX_UNIFORM_VECTORS
:
1018 v
->value_int
= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxUniformComponents
/ 4;
1021 case GL_MAX_FRAGMENT_UNIFORM_VECTORS
:
1022 v
->value_int
= ctx
->Const
.Program
[MESA_SHADER_FRAGMENT
].MaxUniformComponents
/ 4;
1025 /* GL_ARB_texture_buffer_object */
1026 case GL_TEXTURE_BUFFER_ARB
:
1027 v
->value_int
= ctx
->Texture
.BufferObject
->Name
;
1029 case GL_TEXTURE_BINDING_BUFFER_ARB
:
1030 unit
= ctx
->Texture
.CurrentUnit
;
1032 ctx
->Texture
.Unit
[unit
].CurrentTex
[TEXTURE_BUFFER_INDEX
]->Name
;
1034 case GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB
:
1036 struct gl_buffer_object
*buf
=
1037 ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
]
1038 .CurrentTex
[TEXTURE_BUFFER_INDEX
]->BufferObject
;
1039 v
->value_int
= buf
? buf
->Name
: 0;
1042 case GL_TEXTURE_BUFFER_FORMAT_ARB
:
1043 v
->value_int
= ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
]
1044 .CurrentTex
[TEXTURE_BUFFER_INDEX
]->BufferObjectFormat
;
1047 /* GL_ARB_sampler_objects */
1048 case GL_SAMPLER_BINDING
:
1050 struct gl_sampler_object
*samp
=
1051 ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
].Sampler
;
1052 v
->value_int
= samp
? samp
->Name
: 0;
1055 /* GL_ARB_uniform_buffer_object */
1056 case GL_UNIFORM_BUFFER_BINDING
:
1057 v
->value_int
= ctx
->UniformBuffer
->Name
;
1059 /* GL_ARB_shader_storage_buffer_object */
1060 case GL_SHADER_STORAGE_BUFFER_BINDING
:
1061 v
->value_int
= ctx
->ShaderStorageBuffer
->Name
;
1063 /* GL_ARB_query_buffer_object */
1064 case GL_QUERY_BUFFER_BINDING
:
1065 v
->value_int
= ctx
->QueryBuffer
->Name
;
1067 /* GL_ARB_timer_query */
1069 if (ctx
->Driver
.GetTimestamp
) {
1070 v
->value_int64
= ctx
->Driver
.GetTimestamp(ctx
);
1073 _mesa_problem(ctx
, "driver doesn't implement GetTimestamp");
1077 case GL_DEBUG_OUTPUT
:
1078 case GL_DEBUG_OUTPUT_SYNCHRONOUS
:
1079 case GL_DEBUG_LOGGED_MESSAGES
:
1080 case GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH
:
1081 case GL_DEBUG_GROUP_STACK_DEPTH
:
1082 v
->value_int
= _mesa_get_debug_state_int(ctx
, d
->pname
);
1084 /* GL_ARB_shader_atomic_counters */
1085 case GL_ATOMIC_COUNTER_BUFFER_BINDING
:
1086 if (ctx
->AtomicBuffer
) {
1087 v
->value_int
= ctx
->AtomicBuffer
->Name
;
1093 case GL_NUM_SHADING_LANGUAGE_VERSIONS
:
1094 v
->value_int
= _mesa_get_shading_language_version(ctx
, -1, NULL
);
1096 /* GL_ARB_draw_indirect */
1097 case GL_DRAW_INDIRECT_BUFFER_BINDING
:
1098 v
->value_int
= ctx
->DrawIndirectBuffer
->Name
;
1100 /* GL_ARB_indirect_parameters */
1101 case GL_PARAMETER_BUFFER_BINDING_ARB
:
1102 v
->value_int
= ctx
->ParameterBuffer
->Name
;
1104 /* GL_ARB_separate_shader_objects */
1105 case GL_PROGRAM_PIPELINE_BINDING
:
1106 if (ctx
->Pipeline
.Current
) {
1107 v
->value_int
= ctx
->Pipeline
.Current
->Name
;
1112 /* GL_ARB_compute_shader */
1113 case GL_DISPATCH_INDIRECT_BUFFER_BINDING
:
1114 v
->value_int
= ctx
->DispatchIndirectBuffer
->Name
;
1116 /* GL_ARB_multisample */
1118 v
->value_int
= _mesa_geometric_samples(ctx
->DrawBuffer
);
1120 case GL_SAMPLE_BUFFERS
:
1121 v
->value_int
= _mesa_geometric_samples(ctx
->DrawBuffer
) > 0;
1123 /* GL_EXT_textrue_integer */
1124 case GL_RGBA_INTEGER_MODE_EXT
:
1125 v
->value_int
= (ctx
->DrawBuffer
->_IntegerBuffers
!= 0);
1127 /* GL_ATI_meminfo & GL_NVX_gpu_memory_info */
1128 case GL_VBO_FREE_MEMORY_ATI
:
1129 case GL_TEXTURE_FREE_MEMORY_ATI
:
1130 case GL_RENDERBUFFER_FREE_MEMORY_ATI
:
1131 case GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX
:
1132 case GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX
:
1133 case GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX
:
1134 case GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX
:
1135 case GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX
:
1137 struct gl_memory_info info
;
1139 ctx
->Driver
.QueryMemoryInfo(ctx
, &info
);
1141 if (d
->pname
== GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX
)
1142 v
->value_int
= info
.total_device_memory
;
1143 else if (d
->pname
== GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX
)
1144 v
->value_int
= info
.total_device_memory
+
1145 info
.total_staging_memory
;
1146 else if (d
->pname
== GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX
)
1147 v
->value_int
= info
.avail_device_memory
;
1148 else if (d
->pname
== GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX
)
1149 v
->value_int
= info
.nr_device_memory_evictions
;
1150 else if (d
->pname
== GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX
)
1151 v
->value_int
= info
.device_memory_evicted
;
1153 /* ATI free memory enums.
1155 * Since the GPU memory is (usually) page-table based, every two
1156 * consecutive elements are equal. From the GL_ATI_meminfo
1159 * "param[0] - total memory free in the pool
1160 * param[1] - largest available free block in the pool
1161 * param[2] - total auxiliary memory free
1162 * param[3] - largest auxiliary free block"
1164 * All three (VBO, TEXTURE, RENDERBUFFER) queries return
1165 * the same numbers here.
1167 v
->value_int_4
[0] = info
.avail_device_memory
;
1168 v
->value_int_4
[1] = info
.avail_device_memory
;
1169 v
->value_int_4
[2] = info
.avail_staging_memory
;
1170 v
->value_int_4
[3] = info
.avail_staging_memory
;
1175 /* GL_ARB_get_program_binary */
1176 case GL_PROGRAM_BINARY_FORMATS
:
1177 assert(ctx
->Const
.NumProgramBinaryFormats
<= 1);
1178 v
->value_int_n
.n
= MIN2(ctx
->Const
.NumProgramBinaryFormats
, 1);
1179 if (ctx
->Const
.NumProgramBinaryFormats
> 0) {
1180 v
->value_int_n
.ints
[0] = GL_PROGRAM_BINARY_FORMAT_MESA
;
1183 /* GL_EXT_disjoint_timer_query */
1184 case GL_GPU_DISJOINT_EXT
:
1186 simple_mtx_lock(&ctx
->Shared
->Mutex
);
1187 v
->value_int
= ctx
->Shared
->DisjointOperation
;
1188 /* Reset state as expected by the spec. */
1189 ctx
->Shared
->DisjointOperation
= false;
1190 simple_mtx_unlock(&ctx
->Shared
->Mutex
);
1197 * Check extra constraints on a struct value_desc descriptor
1199 * If a struct value_desc has a non-NULL extra pointer, it means that
1200 * there are a number of extra constraints to check or actions to
1201 * perform. The extras is just an integer array where each integer
1202 * encode different constraints or actions.
1204 * \param ctx current context
1205 * \param func name of calling glGet*v() function for error reporting
1206 * \param d the struct value_desc that has the extra constraints
1208 * \return GL_FALSE if all of the constraints were not satisfied,
1209 * otherwise GL_TRUE.
1212 check_extra(struct gl_context
*ctx
, const char *func
, const struct value_desc
*d
)
1214 const GLuint version
= ctx
->Version
;
1215 GLboolean api_check
= GL_FALSE
;
1216 GLboolean api_found
= GL_FALSE
;
1219 for (e
= d
->extra
; *e
!= EXTRA_END
; e
++) {
1221 case EXTRA_VERSION_30
:
1222 api_check
= GL_TRUE
;
1224 api_found
= GL_TRUE
;
1226 case EXTRA_VERSION_31
:
1227 api_check
= GL_TRUE
;
1229 api_found
= GL_TRUE
;
1231 case EXTRA_VERSION_32
:
1232 api_check
= GL_TRUE
;
1234 api_found
= GL_TRUE
;
1236 case EXTRA_VERSION_40
:
1237 api_check
= GL_TRUE
;
1239 api_found
= GL_TRUE
;
1241 case EXTRA_VERSION_43
:
1243 if (_mesa_is_desktop_gl(ctx
) && version
>= 43)
1244 api_found
= GL_TRUE
;
1246 case EXTRA_NEW_FRAG_CLAMP
:
1247 if (ctx
->NewState
& (_NEW_BUFFERS
| _NEW_FRAG_CLAMP
))
1248 _mesa_update_state(ctx
);
1251 api_check
= GL_TRUE
;
1252 if (ctx
->API
== API_OPENGLES2
)
1253 api_found
= GL_TRUE
;
1256 api_check
= GL_TRUE
;
1257 if (_mesa_is_gles3(ctx
))
1258 api_found
= GL_TRUE
;
1260 case EXTRA_API_ES31
:
1261 api_check
= GL_TRUE
;
1262 if (_mesa_is_gles31(ctx
))
1263 api_found
= GL_TRUE
;
1265 case EXTRA_API_ES32
:
1266 api_check
= GL_TRUE
;
1267 if (_mesa_is_gles32(ctx
))
1268 api_found
= GL_TRUE
;
1271 api_check
= GL_TRUE
;
1272 if (_mesa_is_desktop_gl(ctx
))
1273 api_found
= GL_TRUE
;
1275 case EXTRA_API_GL_CORE
:
1276 api_check
= GL_TRUE
;
1277 if (ctx
->API
== API_OPENGL_CORE
)
1278 api_found
= GL_TRUE
;
1280 case EXTRA_NEW_BUFFERS
:
1281 if (ctx
->NewState
& _NEW_BUFFERS
)
1282 _mesa_update_state(ctx
);
1284 case EXTRA_FLUSH_CURRENT
:
1285 FLUSH_CURRENT(ctx
, 0);
1287 case EXTRA_VALID_DRAW_BUFFER
:
1288 if (d
->pname
- GL_DRAW_BUFFER0_ARB
>= ctx
->Const
.MaxDrawBuffers
) {
1289 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(draw buffer %u)",
1290 func
, d
->pname
- GL_DRAW_BUFFER0_ARB
);
1294 case EXTRA_VALID_TEXTURE_UNIT
:
1295 if (ctx
->Texture
.CurrentUnit
>= ctx
->Const
.MaxTextureCoordUnits
) {
1296 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(texture %u)",
1297 func
, ctx
->Texture
.CurrentUnit
);
1301 case EXTRA_VALID_CLIP_DISTANCE
:
1302 if (d
->pname
- GL_CLIP_DISTANCE0
>= ctx
->Const
.MaxClipPlanes
) {
1303 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(clip distance %u)",
1304 func
, d
->pname
- GL_CLIP_DISTANCE0
);
1308 case EXTRA_GLSL_130
:
1309 api_check
= GL_TRUE
;
1310 if (ctx
->Const
.GLSLVersion
>= 130)
1311 api_found
= GL_TRUE
;
1313 case EXTRA_EXT_UBO_GS
:
1314 api_check
= GL_TRUE
;
1315 if (ctx
->Extensions
.ARB_uniform_buffer_object
&&
1316 _mesa_has_geometry_shaders(ctx
))
1317 api_found
= GL_TRUE
;
1319 case EXTRA_EXT_ATOMICS_GS
:
1320 api_check
= GL_TRUE
;
1321 if (ctx
->Extensions
.ARB_shader_atomic_counters
&&
1322 _mesa_has_geometry_shaders(ctx
))
1323 api_found
= GL_TRUE
;
1325 case EXTRA_EXT_SHADER_IMAGE_GS
:
1326 api_check
= GL_TRUE
;
1327 if (ctx
->Extensions
.ARB_shader_image_load_store
&&
1328 _mesa_has_geometry_shaders(ctx
))
1329 api_found
= GL_TRUE
;
1331 case EXTRA_EXT_ATOMICS_TESS
:
1332 api_check
= GL_TRUE
;
1333 api_found
= ctx
->Extensions
.ARB_shader_atomic_counters
&&
1334 _mesa_has_tessellation(ctx
);
1336 case EXTRA_EXT_SHADER_IMAGE_TESS
:
1337 api_check
= GL_TRUE
;
1338 api_found
= ctx
->Extensions
.ARB_shader_image_load_store
&&
1339 _mesa_has_tessellation(ctx
);
1341 case EXTRA_EXT_SSBO_GS
:
1342 api_check
= GL_TRUE
;
1343 if (ctx
->Extensions
.ARB_shader_storage_buffer_object
&&
1344 _mesa_has_geometry_shaders(ctx
))
1345 api_found
= GL_TRUE
;
1347 case EXTRA_EXT_FB_NO_ATTACH_GS
:
1348 api_check
= GL_TRUE
;
1349 if (ctx
->Extensions
.ARB_framebuffer_no_attachments
&&
1350 (_mesa_is_desktop_gl(ctx
) ||
1351 _mesa_has_OES_geometry_shader(ctx
)))
1352 api_found
= GL_TRUE
;
1354 case EXTRA_EXT_ES_GS
:
1355 api_check
= GL_TRUE
;
1356 if (_mesa_has_OES_geometry_shader(ctx
))
1357 api_found
= GL_TRUE
;
1359 case EXTRA_EXT_PROVOKING_VERTEX_32
:
1361 if (ctx
->API
== API_OPENGL_COMPAT
|| version
== 32)
1362 api_found
= ctx
->Extensions
.EXT_provoking_vertex
;
1366 default: /* *e is a offset into the extension struct */
1367 api_check
= GL_TRUE
;
1368 if (*(GLboolean
*) ((char *) &ctx
->Extensions
+ *e
))
1369 api_found
= GL_TRUE
;
1374 if (api_check
&& !api_found
) {
1375 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(pname=%s)", func
,
1376 _mesa_enum_to_string(d
->pname
));
1383 static const struct value_desc error_value
=
1384 { 0, 0, TYPE_INVALID
, NO_OFFSET
, NO_EXTRA
};
1387 * Find the struct value_desc corresponding to the enum 'pname'.
1389 * We hash the enum value to get an index into the 'table' array,
1390 * which holds the index in the 'values' array of struct value_desc.
1391 * Once we've found the entry, we do the extra checks, if any, then
1392 * look up the value and return a pointer to it.
1394 * If the value has to be computed (for example, it's the result of a
1395 * function call or we need to add 1 to it), we use the tmp 'v' to
1398 * \param func name of glGet*v() func for error reporting
1399 * \param pname the enum value we're looking up
1400 * \param p is were we return the pointer to the value
1401 * \param v a tmp union value variable in the calling glGet*v() function
1403 * \return the struct value_desc corresponding to the enum or a struct
1404 * value_desc of TYPE_INVALID if not found. This lets the calling
1405 * glGet*v() function jump right into a switch statement and
1406 * handle errors there instead of having to check for NULL.
1408 static const struct value_desc
*
1409 find_value(const char *func
, GLenum pname
, void **p
, union value
*v
)
1411 GET_CURRENT_CONTEXT(ctx
);
1413 const struct value_desc
*d
;
1417 /* We index into the table_set[] list of per-API hash tables using the API's
1418 * value in the gl_api enum. Since GLES 3 doesn't have an API_OPENGL* enum
1419 * value since it's compatible with GLES2 its entry in table_set[] is at the
1422 STATIC_ASSERT(ARRAY_SIZE(table_set
) == API_OPENGL_LAST
+ 4);
1423 if (ctx
->API
== API_OPENGLES2
) {
1424 if (ctx
->Version
>= 32)
1425 api
= API_OPENGL_LAST
+ 3;
1426 else if (ctx
->Version
>= 31)
1427 api
= API_OPENGL_LAST
+ 2;
1428 else if (ctx
->Version
>= 30)
1429 api
= API_OPENGL_LAST
+ 1;
1431 mask
= ARRAY_SIZE(table(api
)) - 1;
1432 hash
= (pname
* prime_factor
);
1434 int idx
= table(api
)[hash
& mask
];
1436 /* If the enum isn't valid, the hash walk ends with index 0,
1437 * pointing to the first entry of values[] which doesn't hold
1438 * any valid enum. */
1439 if (unlikely(idx
== 0)) {
1440 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(pname=%s)", func
,
1441 _mesa_enum_to_string(pname
));
1442 return &error_value
;
1446 if (likely(d
->pname
== pname
))
1452 if (unlikely(d
->extra
&& !check_extra(ctx
, func
, d
)))
1453 return &error_value
;
1455 switch (d
->location
) {
1457 *p
= ((char *) ctx
->DrawBuffer
+ d
->offset
);
1460 *p
= ((char *) ctx
+ d
->offset
);
1463 *p
= ((char *) ctx
->Array
.VAO
+ d
->offset
);
1466 if (ctx
->Texture
.CurrentUnit
< ARRAY_SIZE(ctx
->Texture
.FixedFuncUnit
)) {
1467 unsigned index
= ctx
->Texture
.CurrentUnit
;
1468 *p
= ((char *)&ctx
->Texture
.FixedFuncUnit
[index
] + d
->offset
);
1472 find_custom_value(ctx
, d
, v
);
1480 /* silence warning */
1481 return &error_value
;
1484 static const int transpose
[] = {
1492 get_value_size(enum value_type type
, const union value
*v
)
1500 return sizeof(GLint
);
1503 return sizeof(GLint
) * 2;
1506 return sizeof(GLint
) * 3;
1509 return sizeof(GLint
) * 4;
1511 return sizeof(GLint
) * v
->value_int_n
.n
;
1513 return sizeof(GLint64
);
1516 return sizeof(GLenum16
);
1518 return sizeof(GLenum
);
1520 return sizeof(GLenum
) * 2;
1522 return sizeof(GLboolean
);
1534 return sizeof(GLfloat
);
1537 return sizeof(GLfloat
) * 2;
1540 return sizeof(GLfloat
) * 3;
1543 return sizeof(GLfloat
) * 4;
1545 return sizeof(GLfloat
) * 8;
1547 return sizeof(GLdouble
);
1548 case TYPE_DOUBLEN_2
:
1549 return sizeof(GLdouble
) * 2;
1551 return sizeof (GLfloat
) * 16;
1553 return sizeof (GLfloat
) * 16;
1560 _mesa_GetBooleanv(GLenum pname
, GLboolean
*params
)
1562 const struct value_desc
*d
;
1568 d
= find_value("glGetBooleanv", pname
, &p
, &v
);
1573 params
[0] = INT_TO_BOOLEAN(d
->offset
);
1577 params
[7] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[7]);
1578 params
[6] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[6]);
1579 params
[5] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[5]);
1580 params
[4] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[4]);
1583 params
[3] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[3]);
1586 params
[2] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[2]);
1589 params
[1] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[1]);
1592 params
[0] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[0]);
1595 case TYPE_DOUBLEN_2
:
1596 params
[1] = FLOAT_TO_BOOLEAN(((GLdouble
*) p
)[1]);
1598 params
[0] = FLOAT_TO_BOOLEAN(((GLdouble
*) p
)[0]);
1603 params
[3] = INT_TO_BOOLEAN(((GLint
*) p
)[3]);
1606 params
[2] = INT_TO_BOOLEAN(((GLint
*) p
)[2]);
1610 params
[1] = INT_TO_BOOLEAN(((GLint
*) p
)[1]);
1614 params
[0] = INT_TO_BOOLEAN(((GLint
*) p
)[0]);
1618 params
[0] = INT_TO_BOOLEAN(((GLenum16
*) p
)[0]);
1622 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
1623 params
[i
] = INT_TO_BOOLEAN(v
.value_int_n
.ints
[i
]);
1627 params
[0] = INT64_TO_BOOLEAN(((GLint64
*) p
)[0]);
1631 params
[0] = ((GLboolean
*) p
)[0];
1635 m
= *(GLmatrix
**) p
;
1636 for (i
= 0; i
< 16; i
++)
1637 params
[i
] = FLOAT_TO_BOOLEAN(m
->m
[i
]);
1641 m
= *(GLmatrix
**) p
;
1642 for (i
= 0; i
< 16; i
++)
1643 params
[i
] = FLOAT_TO_BOOLEAN(m
->m
[transpose
[i
]]);
1654 shift
= d
->type
- TYPE_BIT_0
;
1655 params
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
1661 _mesa_GetFloatv(GLenum pname
, GLfloat
*params
)
1663 const struct value_desc
*d
;
1669 d
= find_value("glGetFloatv", pname
, &p
, &v
);
1674 params
[0] = (GLfloat
) d
->offset
;
1678 params
[7] = ((GLfloat
*) p
)[7];
1679 params
[6] = ((GLfloat
*) p
)[6];
1680 params
[5] = ((GLfloat
*) p
)[5];
1681 params
[4] = ((GLfloat
*) p
)[4];
1684 params
[3] = ((GLfloat
*) p
)[3];
1687 params
[2] = ((GLfloat
*) p
)[2];
1690 params
[1] = ((GLfloat
*) p
)[1];
1693 params
[0] = ((GLfloat
*) p
)[0];
1696 case TYPE_DOUBLEN_2
:
1697 params
[1] = (GLfloat
) (((GLdouble
*) p
)[1]);
1699 params
[0] = (GLfloat
) (((GLdouble
*) p
)[0]);
1703 params
[3] = (GLfloat
) (((GLint
*) p
)[3]);
1705 params
[2] = (GLfloat
) (((GLint
*) p
)[2]);
1708 params
[1] = (GLfloat
) (((GLint
*) p
)[1]);
1711 params
[0] = (GLfloat
) (((GLint
*) p
)[0]);
1715 params
[0] = (GLfloat
) (((GLenum16
*) p
)[0]);
1719 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
1720 params
[i
] = (GLfloat
) v
.value_int_n
.ints
[i
];
1724 params
[3] = (GLfloat
) (((GLuint
*) p
)[3]);
1726 params
[2] = (GLfloat
) (((GLuint
*) p
)[2]);
1728 params
[1] = (GLfloat
) (((GLuint
*) p
)[1]);
1730 params
[0] = (GLfloat
) (((GLuint
*) p
)[0]);
1734 params
[0] = (GLfloat
) (((GLint64
*) p
)[0]);
1738 params
[0] = BOOLEAN_TO_FLOAT(*(GLboolean
*) p
);
1742 m
= *(GLmatrix
**) p
;
1743 for (i
= 0; i
< 16; i
++)
1744 params
[i
] = m
->m
[i
];
1748 m
= *(GLmatrix
**) p
;
1749 for (i
= 0; i
< 16; i
++)
1750 params
[i
] = m
->m
[transpose
[i
]];
1761 shift
= d
->type
- TYPE_BIT_0
;
1762 params
[0] = BOOLEAN_TO_FLOAT((*(GLbitfield
*) p
>> shift
) & 1);
1768 _mesa_GetIntegerv(GLenum pname
, GLint
*params
)
1770 const struct value_desc
*d
;
1776 d
= find_value("glGetIntegerv", pname
, &p
, &v
);
1781 params
[0] = d
->offset
;
1785 params
[7] = IROUND(((GLfloat
*) p
)[7]);
1786 params
[6] = IROUND(((GLfloat
*) p
)[6]);
1787 params
[5] = IROUND(((GLfloat
*) p
)[5]);
1788 params
[4] = IROUND(((GLfloat
*) p
)[4]);
1790 params
[3] = IROUND(((GLfloat
*) p
)[3]);
1792 params
[2] = IROUND(((GLfloat
*) p
)[2]);
1794 params
[1] = IROUND(((GLfloat
*) p
)[1]);
1796 params
[0] = IROUND(((GLfloat
*) p
)[0]);
1800 params
[3] = FLOAT_TO_INT(((GLfloat
*) p
)[3]);
1802 params
[2] = FLOAT_TO_INT(((GLfloat
*) p
)[2]);
1804 params
[1] = FLOAT_TO_INT(((GLfloat
*) p
)[1]);
1806 params
[0] = FLOAT_TO_INT(((GLfloat
*) p
)[0]);
1809 case TYPE_DOUBLEN_2
:
1810 params
[1] = FLOAT_TO_INT(((GLdouble
*) p
)[1]);
1812 params
[0] = FLOAT_TO_INT(((GLdouble
*) p
)[0]);
1817 params
[3] = ((GLint
*) p
)[3];
1820 params
[2] = ((GLint
*) p
)[2];
1824 params
[1] = ((GLint
*) p
)[1];
1828 params
[0] = ((GLint
*) p
)[0];
1832 params
[0] = ((GLenum16
*) p
)[0];
1836 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
1837 params
[i
] = v
.value_int_n
.ints
[i
];
1841 params
[0] = INT64_TO_INT(((GLint64
*) p
)[0]);
1845 params
[0] = BOOLEAN_TO_INT(*(GLboolean
*) p
);
1849 m
= *(GLmatrix
**) p
;
1850 for (i
= 0; i
< 16; i
++)
1851 params
[i
] = FLOAT_TO_INT(m
->m
[i
]);
1855 m
= *(GLmatrix
**) p
;
1856 for (i
= 0; i
< 16; i
++)
1857 params
[i
] = FLOAT_TO_INT(m
->m
[transpose
[i
]]);
1868 shift
= d
->type
- TYPE_BIT_0
;
1869 params
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
1875 _mesa_GetInteger64v(GLenum pname
, GLint64
*params
)
1877 const struct value_desc
*d
;
1883 d
= find_value("glGetInteger64v", pname
, &p
, &v
);
1888 params
[0] = d
->offset
;
1892 params
[7] = IROUND64(((GLfloat
*) p
)[7]);
1893 params
[6] = IROUND64(((GLfloat
*) p
)[6]);
1894 params
[5] = IROUND64(((GLfloat
*) p
)[5]);
1895 params
[4] = IROUND64(((GLfloat
*) p
)[4]);
1897 params
[3] = IROUND64(((GLfloat
*) p
)[3]);
1899 params
[2] = IROUND64(((GLfloat
*) p
)[2]);
1901 params
[1] = IROUND64(((GLfloat
*) p
)[1]);
1903 params
[0] = IROUND64(((GLfloat
*) p
)[0]);
1907 params
[3] = FLOAT_TO_INT(((GLfloat
*) p
)[3]);
1909 params
[2] = FLOAT_TO_INT(((GLfloat
*) p
)[2]);
1911 params
[1] = FLOAT_TO_INT(((GLfloat
*) p
)[1]);
1913 params
[0] = FLOAT_TO_INT(((GLfloat
*) p
)[0]);
1916 case TYPE_DOUBLEN_2
:
1917 params
[1] = FLOAT_TO_INT(((GLdouble
*) p
)[1]);
1919 params
[0] = FLOAT_TO_INT(((GLdouble
*) p
)[0]);
1923 params
[3] = ((GLint
*) p
)[3];
1925 params
[2] = ((GLint
*) p
)[2];
1928 params
[1] = ((GLint
*) p
)[1];
1931 params
[0] = ((GLint
*) p
)[0];
1935 params
[0] = ((GLenum16
*) p
)[0];
1939 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
1940 params
[i
] = INT_TO_BOOLEAN(v
.value_int_n
.ints
[i
]);
1944 params
[3] = ((GLuint
*) p
)[3];
1946 params
[2] = ((GLuint
*) p
)[2];
1948 params
[1] = ((GLuint
*) p
)[1];
1950 params
[0] = ((GLuint
*) p
)[0];
1954 params
[0] = ((GLint64
*) p
)[0];
1958 params
[0] = ((GLboolean
*) p
)[0];
1962 m
= *(GLmatrix
**) p
;
1963 for (i
= 0; i
< 16; i
++)
1964 params
[i
] = FLOAT_TO_INT64(m
->m
[i
]);
1968 m
= *(GLmatrix
**) p
;
1969 for (i
= 0; i
< 16; i
++)
1970 params
[i
] = FLOAT_TO_INT64(m
->m
[transpose
[i
]]);
1981 shift
= d
->type
- TYPE_BIT_0
;
1982 params
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
1988 _mesa_GetDoublev(GLenum pname
, GLdouble
*params
)
1990 const struct value_desc
*d
;
1996 d
= find_value("glGetDoublev", pname
, &p
, &v
);
2001 params
[0] = d
->offset
;
2005 params
[7] = ((GLfloat
*) p
)[7];
2006 params
[6] = ((GLfloat
*) p
)[6];
2007 params
[5] = ((GLfloat
*) p
)[5];
2008 params
[4] = ((GLfloat
*) p
)[4];
2011 params
[3] = ((GLfloat
*) p
)[3];
2014 params
[2] = ((GLfloat
*) p
)[2];
2017 params
[1] = ((GLfloat
*) p
)[1];
2020 params
[0] = ((GLfloat
*) p
)[0];
2023 case TYPE_DOUBLEN_2
:
2024 params
[1] = ((GLdouble
*) p
)[1];
2026 params
[0] = ((GLdouble
*) p
)[0];
2030 params
[3] = ((GLint
*) p
)[3];
2032 params
[2] = ((GLint
*) p
)[2];
2035 params
[1] = ((GLint
*) p
)[1];
2038 params
[0] = ((GLint
*) p
)[0];
2042 params
[0] = ((GLenum16
*) p
)[0];
2046 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
2047 params
[i
] = v
.value_int_n
.ints
[i
];
2051 params
[3] = ((GLuint
*) p
)[3];
2053 params
[2] = ((GLuint
*) p
)[2];
2055 params
[1] = ((GLuint
*) p
)[1];
2057 params
[0] = ((GLuint
*) p
)[0];
2061 params
[0] = (GLdouble
) (((GLint64
*) p
)[0]);
2065 params
[0] = *(GLboolean
*) p
;
2069 m
= *(GLmatrix
**) p
;
2070 for (i
= 0; i
< 16; i
++)
2071 params
[i
] = m
->m
[i
];
2075 m
= *(GLmatrix
**) p
;
2076 for (i
= 0; i
< 16; i
++)
2077 params
[i
] = m
->m
[transpose
[i
]];
2088 shift
= d
->type
- TYPE_BIT_0
;
2089 params
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
2095 _mesa_GetUnsignedBytevEXT(GLenum pname
, GLubyte
*data
)
2097 const struct value_desc
*d
;
2102 const char *func
= "glGetUnsignedBytevEXT";
2104 GET_CURRENT_CONTEXT(ctx
);
2106 if (!ctx
->Extensions
.EXT_memory_object
) {
2107 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(unsupported)", func
);
2111 d
= find_value(func
, pname
, &p
, &v
);
2112 size
= get_value_size(d
->type
, &v
);
2114 _mesa_problem(ctx
, "invalid value type in GetUnsignedBytevEXT()");
2126 shift
= d
->type
- TYPE_BIT_0
;
2127 data
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
2130 memcpy(data
, &d
->offset
, size
);
2133 memcpy(data
, &v
.value_int_n
.ints
, size
);
2157 case TYPE_DOUBLEN_2
:
2160 memcpy(data
, p
, size
);
2163 GLenum e
= *(GLenum16
*)p
;
2164 memcpy(data
, &e
, sizeof(e
));
2168 break; /* nothing - GL error was recorded */
2173 * Convert a GL texture binding enum such as GL_TEXTURE_BINDING_2D
2174 * into the corresponding Mesa texture target index.
2175 * \return TEXTURE_x_INDEX or -1 if binding is invalid
2178 tex_binding_to_index(const struct gl_context
*ctx
, GLenum binding
)
2181 case GL_TEXTURE_BINDING_1D
:
2182 return _mesa_is_desktop_gl(ctx
) ? TEXTURE_1D_INDEX
: -1;
2183 case GL_TEXTURE_BINDING_2D
:
2184 return TEXTURE_2D_INDEX
;
2185 case GL_TEXTURE_BINDING_3D
:
2186 return ctx
->API
!= API_OPENGLES
? TEXTURE_3D_INDEX
: -1;
2187 case GL_TEXTURE_BINDING_CUBE_MAP
:
2188 return ctx
->Extensions
.ARB_texture_cube_map
2189 ? TEXTURE_CUBE_INDEX
: -1;
2190 case GL_TEXTURE_BINDING_RECTANGLE
:
2191 return _mesa_is_desktop_gl(ctx
) && ctx
->Extensions
.NV_texture_rectangle
2192 ? TEXTURE_RECT_INDEX
: -1;
2193 case GL_TEXTURE_BINDING_1D_ARRAY
:
2194 return _mesa_is_desktop_gl(ctx
) && ctx
->Extensions
.EXT_texture_array
2195 ? TEXTURE_1D_ARRAY_INDEX
: -1;
2196 case GL_TEXTURE_BINDING_2D_ARRAY
:
2197 return (_mesa_is_desktop_gl(ctx
) && ctx
->Extensions
.EXT_texture_array
)
2198 || _mesa_is_gles3(ctx
)
2199 ? TEXTURE_2D_ARRAY_INDEX
: -1;
2200 case GL_TEXTURE_BINDING_BUFFER
:
2201 return (_mesa_has_ARB_texture_buffer_object(ctx
) ||
2202 _mesa_has_OES_texture_buffer(ctx
)) ?
2203 TEXTURE_BUFFER_INDEX
: -1;
2204 case GL_TEXTURE_BINDING_CUBE_MAP_ARRAY
:
2205 return _mesa_has_texture_cube_map_array(ctx
)
2206 ? TEXTURE_CUBE_ARRAY_INDEX
: -1;
2207 case GL_TEXTURE_BINDING_2D_MULTISAMPLE
:
2208 return _mesa_is_desktop_gl(ctx
) && ctx
->Extensions
.ARB_texture_multisample
2209 ? TEXTURE_2D_MULTISAMPLE_INDEX
: -1;
2210 case GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY
:
2211 return _mesa_is_desktop_gl(ctx
) && ctx
->Extensions
.ARB_texture_multisample
2212 ? TEXTURE_2D_MULTISAMPLE_ARRAY_INDEX
: -1;
2218 static enum value_type
2219 find_value_indexed(const char *func
, GLenum pname
, GLuint index
, union value
*v
)
2221 GET_CURRENT_CONTEXT(ctx
);
2226 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2228 if (!ctx
->Extensions
.EXT_draw_buffers2
)
2230 v
->value_int
= (ctx
->Color
.BlendEnabled
>> index
) & 1;
2235 case GL_BLEND_SRC_RGB
:
2236 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2238 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
2240 v
->value_int
= ctx
->Color
.Blend
[index
].SrcRGB
;
2242 case GL_BLEND_SRC_ALPHA
:
2243 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2245 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
2247 v
->value_int
= ctx
->Color
.Blend
[index
].SrcA
;
2251 case GL_BLEND_DST_RGB
:
2252 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2254 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
2256 v
->value_int
= ctx
->Color
.Blend
[index
].DstRGB
;
2258 case GL_BLEND_DST_ALPHA
:
2259 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2261 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
2263 v
->value_int
= ctx
->Color
.Blend
[index
].DstA
;
2265 case GL_BLEND_EQUATION_RGB
:
2266 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2268 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
2270 v
->value_int
= ctx
->Color
.Blend
[index
].EquationRGB
;
2272 case GL_BLEND_EQUATION_ALPHA
:
2273 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2275 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
2277 v
->value_int
= ctx
->Color
.Blend
[index
].EquationA
;
2280 case GL_COLOR_WRITEMASK
:
2281 if (index
>= ctx
->Const
.MaxDrawBuffers
)
2283 if (!ctx
->Extensions
.EXT_draw_buffers2
)
2285 v
->value_int_4
[0] = GET_COLORMASK_BIT(ctx
->Color
.ColorMask
, index
, 0);
2286 v
->value_int_4
[1] = GET_COLORMASK_BIT(ctx
->Color
.ColorMask
, index
, 1);
2287 v
->value_int_4
[2] = GET_COLORMASK_BIT(ctx
->Color
.ColorMask
, index
, 2);
2288 v
->value_int_4
[3] = GET_COLORMASK_BIT(ctx
->Color
.ColorMask
, index
, 3);
2291 case GL_SCISSOR_BOX
:
2292 if (index
>= ctx
->Const
.MaxViewports
)
2294 v
->value_int_4
[0] = ctx
->Scissor
.ScissorArray
[index
].X
;
2295 v
->value_int_4
[1] = ctx
->Scissor
.ScissorArray
[index
].Y
;
2296 v
->value_int_4
[2] = ctx
->Scissor
.ScissorArray
[index
].Width
;
2297 v
->value_int_4
[3] = ctx
->Scissor
.ScissorArray
[index
].Height
;
2300 case GL_WINDOW_RECTANGLE_EXT
:
2301 if (!ctx
->Extensions
.EXT_window_rectangles
)
2303 if (index
>= ctx
->Const
.MaxWindowRectangles
)
2305 v
->value_int_4
[0] = ctx
->Scissor
.WindowRects
[index
].X
;
2306 v
->value_int_4
[1] = ctx
->Scissor
.WindowRects
[index
].Y
;
2307 v
->value_int_4
[2] = ctx
->Scissor
.WindowRects
[index
].Width
;
2308 v
->value_int_4
[3] = ctx
->Scissor
.WindowRects
[index
].Height
;
2312 if (index
>= ctx
->Const
.MaxViewports
)
2314 v
->value_float_4
[0] = ctx
->ViewportArray
[index
].X
;
2315 v
->value_float_4
[1] = ctx
->ViewportArray
[index
].Y
;
2316 v
->value_float_4
[2] = ctx
->ViewportArray
[index
].Width
;
2317 v
->value_float_4
[3] = ctx
->ViewportArray
[index
].Height
;
2318 return TYPE_FLOAT_4
;
2320 case GL_DEPTH_RANGE
:
2321 if (index
>= ctx
->Const
.MaxViewports
)
2323 v
->value_double_2
[0] = ctx
->ViewportArray
[index
].Near
;
2324 v
->value_double_2
[1] = ctx
->ViewportArray
[index
].Far
;
2325 return TYPE_DOUBLEN_2
;
2327 case GL_TRANSFORM_FEEDBACK_BUFFER_START
:
2328 if (index
>= ctx
->Const
.MaxTransformFeedbackBuffers
)
2330 if (!ctx
->Extensions
.EXT_transform_feedback
)
2332 v
->value_int64
= ctx
->TransformFeedback
.CurrentObject
->Offset
[index
];
2335 case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE
:
2336 if (index
>= ctx
->Const
.MaxTransformFeedbackBuffers
)
2338 if (!ctx
->Extensions
.EXT_transform_feedback
)
2341 = ctx
->TransformFeedback
.CurrentObject
->RequestedSize
[index
];
2344 case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING
:
2345 if (index
>= ctx
->Const
.MaxTransformFeedbackBuffers
)
2347 if (!ctx
->Extensions
.EXT_transform_feedback
)
2349 v
->value_int
= ctx
->TransformFeedback
.CurrentObject
->BufferNames
[index
];
2352 case GL_UNIFORM_BUFFER_BINDING
:
2353 if (index
>= ctx
->Const
.MaxUniformBufferBindings
)
2355 if (!ctx
->Extensions
.ARB_uniform_buffer_object
)
2357 v
->value_int
= ctx
->UniformBufferBindings
[index
].BufferObject
->Name
;
2360 case GL_UNIFORM_BUFFER_START
:
2361 if (index
>= ctx
->Const
.MaxUniformBufferBindings
)
2363 if (!ctx
->Extensions
.ARB_uniform_buffer_object
)
2365 v
->value_int
= ctx
->UniformBufferBindings
[index
].Offset
< 0 ? 0 :
2366 ctx
->UniformBufferBindings
[index
].Offset
;
2369 case GL_UNIFORM_BUFFER_SIZE
:
2370 if (index
>= ctx
->Const
.MaxUniformBufferBindings
)
2372 if (!ctx
->Extensions
.ARB_uniform_buffer_object
)
2374 v
->value_int
= ctx
->UniformBufferBindings
[index
].Size
< 0 ? 0 :
2375 ctx
->UniformBufferBindings
[index
].Size
;
2378 /* ARB_shader_storage_buffer_object */
2379 case GL_SHADER_STORAGE_BUFFER_BINDING
:
2380 if (!ctx
->Extensions
.ARB_shader_storage_buffer_object
)
2382 if (index
>= ctx
->Const
.MaxShaderStorageBufferBindings
)
2384 v
->value_int
= ctx
->ShaderStorageBufferBindings
[index
].BufferObject
->Name
;
2387 case GL_SHADER_STORAGE_BUFFER_START
:
2388 if (!ctx
->Extensions
.ARB_shader_storage_buffer_object
)
2390 if (index
>= ctx
->Const
.MaxShaderStorageBufferBindings
)
2392 v
->value_int
= ctx
->ShaderStorageBufferBindings
[index
].Offset
< 0 ? 0 :
2393 ctx
->ShaderStorageBufferBindings
[index
].Offset
;
2396 case GL_SHADER_STORAGE_BUFFER_SIZE
:
2397 if (!ctx
->Extensions
.ARB_shader_storage_buffer_object
)
2399 if (index
>= ctx
->Const
.MaxShaderStorageBufferBindings
)
2401 v
->value_int
= ctx
->ShaderStorageBufferBindings
[index
].Size
< 0 ? 0 :
2402 ctx
->ShaderStorageBufferBindings
[index
].Size
;
2405 /* ARB_texture_multisample / GL3.2 */
2406 case GL_SAMPLE_MASK_VALUE
:
2409 if (!ctx
->Extensions
.ARB_texture_multisample
)
2411 v
->value_int
= ctx
->Multisample
.SampleMaskValue
;
2414 case GL_ATOMIC_COUNTER_BUFFER_BINDING
:
2415 if (!ctx
->Extensions
.ARB_shader_atomic_counters
)
2417 if (index
>= ctx
->Const
.MaxAtomicBufferBindings
)
2419 v
->value_int
= ctx
->AtomicBufferBindings
[index
].BufferObject
->Name
;
2422 case GL_ATOMIC_COUNTER_BUFFER_START
:
2423 if (!ctx
->Extensions
.ARB_shader_atomic_counters
)
2425 if (index
>= ctx
->Const
.MaxAtomicBufferBindings
)
2427 v
->value_int64
= ctx
->AtomicBufferBindings
[index
].Offset
< 0 ? 0 :
2428 ctx
->AtomicBufferBindings
[index
].Offset
;
2431 case GL_ATOMIC_COUNTER_BUFFER_SIZE
:
2432 if (!ctx
->Extensions
.ARB_shader_atomic_counters
)
2434 if (index
>= ctx
->Const
.MaxAtomicBufferBindings
)
2436 v
->value_int64
= ctx
->AtomicBufferBindings
[index
].Size
< 0 ? 0 :
2437 ctx
->AtomicBufferBindings
[index
].Size
;
2440 case GL_VERTEX_BINDING_DIVISOR
:
2441 if ((!_mesa_is_desktop_gl(ctx
) || !ctx
->Extensions
.ARB_instanced_arrays
) &&
2442 !_mesa_is_gles31(ctx
))
2444 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
)
2446 v
->value_int
= ctx
->Array
.VAO
->BufferBinding
[VERT_ATTRIB_GENERIC(index
)].InstanceDivisor
;
2449 case GL_VERTEX_BINDING_OFFSET
:
2450 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles31(ctx
))
2452 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
)
2454 v
->value_int
= ctx
->Array
.VAO
->BufferBinding
[VERT_ATTRIB_GENERIC(index
)].Offset
;
2457 case GL_VERTEX_BINDING_STRIDE
:
2458 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles31(ctx
))
2460 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
)
2462 v
->value_int
= ctx
->Array
.VAO
->BufferBinding
[VERT_ATTRIB_GENERIC(index
)].Stride
;
2465 case GL_VERTEX_BINDING_BUFFER
:
2466 if (ctx
->API
== API_OPENGLES2
&& ctx
->Version
< 31)
2468 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
)
2470 v
->value_int
= ctx
->Array
.VAO
->BufferBinding
[VERT_ATTRIB_GENERIC(index
)].BufferObj
->Name
;
2473 /* ARB_shader_image_load_store */
2474 case GL_IMAGE_BINDING_NAME
: {
2475 struct gl_texture_object
*t
;
2477 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
2479 if (index
>= ctx
->Const
.MaxImageUnits
)
2482 t
= ctx
->ImageUnits
[index
].TexObj
;
2483 v
->value_int
= (t
? t
->Name
: 0);
2487 case GL_IMAGE_BINDING_LEVEL
:
2488 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
2490 if (index
>= ctx
->Const
.MaxImageUnits
)
2493 v
->value_int
= ctx
->ImageUnits
[index
].Level
;
2496 case GL_IMAGE_BINDING_LAYERED
:
2497 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
2499 if (index
>= ctx
->Const
.MaxImageUnits
)
2502 v
->value_int
= ctx
->ImageUnits
[index
].Layered
;
2505 case GL_IMAGE_BINDING_LAYER
:
2506 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
2508 if (index
>= ctx
->Const
.MaxImageUnits
)
2511 v
->value_int
= ctx
->ImageUnits
[index
].Layer
;
2514 case GL_IMAGE_BINDING_ACCESS
:
2515 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
2517 if (index
>= ctx
->Const
.MaxImageUnits
)
2520 v
->value_int
= ctx
->ImageUnits
[index
].Access
;
2523 case GL_IMAGE_BINDING_FORMAT
:
2524 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
2526 if (index
>= ctx
->Const
.MaxImageUnits
)
2529 v
->value_int
= ctx
->ImageUnits
[index
].Format
;
2532 /* ARB_direct_state_access */
2533 case GL_TEXTURE_BINDING_1D
:
2534 case GL_TEXTURE_BINDING_1D_ARRAY
:
2535 case GL_TEXTURE_BINDING_2D
:
2536 case GL_TEXTURE_BINDING_2D_ARRAY
:
2537 case GL_TEXTURE_BINDING_2D_MULTISAMPLE
:
2538 case GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY
:
2539 case GL_TEXTURE_BINDING_3D
:
2540 case GL_TEXTURE_BINDING_BUFFER
:
2541 case GL_TEXTURE_BINDING_CUBE_MAP
:
2542 case GL_TEXTURE_BINDING_CUBE_MAP_ARRAY
:
2543 case GL_TEXTURE_BINDING_RECTANGLE
: {
2546 if (ctx
->API
!= API_OPENGL_CORE
)
2548 target
= tex_binding_to_index(ctx
, pname
);
2551 if (index
>= _mesa_max_tex_unit(ctx
))
2554 v
->value_int
= ctx
->Texture
.Unit
[index
].CurrentTex
[target
]->Name
;
2558 case GL_SAMPLER_BINDING
: {
2559 struct gl_sampler_object
*samp
;
2561 if (!_mesa_is_desktop_gl(ctx
) || ctx
->Version
< 33)
2563 if (index
>= _mesa_max_tex_unit(ctx
))
2566 samp
= ctx
->Texture
.Unit
[index
].Sampler
;
2567 v
->value_int
= samp
? samp
->Name
: 0;
2571 case GL_MAX_COMPUTE_WORK_GROUP_COUNT
:
2572 if (!_mesa_has_compute_shaders(ctx
))
2576 v
->value_int
= ctx
->Const
.MaxComputeWorkGroupCount
[index
];
2579 case GL_MAX_COMPUTE_WORK_GROUP_SIZE
:
2580 if (!_mesa_has_compute_shaders(ctx
))
2584 v
->value_int
= ctx
->Const
.MaxComputeWorkGroupSize
[index
];
2587 /* ARB_compute_variable_group_size */
2588 case GL_MAX_COMPUTE_VARIABLE_GROUP_SIZE_ARB
:
2589 if (!ctx
->Extensions
.ARB_compute_variable_group_size
)
2593 v
->value_int
= ctx
->Const
.MaxComputeVariableGroupSize
[index
];
2596 /* GL_EXT_external_objects */
2597 case GL_NUM_DEVICE_UUIDS_EXT
:
2600 case GL_DRIVER_UUID_EXT
:
2603 _mesa_get_driver_uuid(ctx
, v
->value_int_4
);
2605 case GL_DEVICE_UUID_EXT
:
2608 _mesa_get_device_uuid(ctx
, v
->value_int_4
);
2613 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(pname=%s)", func
,
2614 _mesa_enum_to_string(pname
));
2615 return TYPE_INVALID
;
2617 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(pname=%s)", func
,
2618 _mesa_enum_to_string(pname
));
2619 return TYPE_INVALID
;
2623 _mesa_GetBooleani_v( GLenum pname
, GLuint index
, GLboolean
*params
)
2626 enum value_type type
=
2627 find_value_indexed("glGetBooleani_v", pname
, index
, &v
);
2632 params
[0] = INT_TO_BOOLEAN(v
.value_int
);
2636 params
[0] = INT_TO_BOOLEAN(v
.value_int_4
[0]);
2637 params
[1] = INT_TO_BOOLEAN(v
.value_int_4
[1]);
2638 params
[2] = INT_TO_BOOLEAN(v
.value_int_4
[2]);
2639 params
[3] = INT_TO_BOOLEAN(v
.value_int_4
[3]);
2642 params
[0] = INT64_TO_BOOLEAN(v
.value_int64
);
2645 ; /* nothing - GL error was recorded */
2650 _mesa_GetIntegeri_v( GLenum pname
, GLuint index
, GLint
*params
)
2653 enum value_type type
=
2654 find_value_indexed("glGetIntegeri_v", pname
, index
, &v
);
2659 params
[3] = IROUND(v
.value_float_4
[3]);
2662 params
[2] = IROUND(v
.value_float_4
[2]);
2665 params
[1] = IROUND(v
.value_float_4
[1]);
2668 params
[0] = IROUND(v
.value_float_4
[0]);
2671 case TYPE_DOUBLEN_2
:
2672 params
[1] = IROUND(v
.value_double_2
[1]);
2674 params
[0] = IROUND(v
.value_double_2
[0]);
2679 params
[0] = v
.value_int
;
2683 params
[0] = v
.value_int_4
[0];
2684 params
[1] = v
.value_int_4
[1];
2685 params
[2] = v
.value_int_4
[2];
2686 params
[3] = v
.value_int_4
[3];
2689 params
[0] = INT64_TO_INT(v
.value_int64
);
2692 ; /* nothing - GL error was recorded */
2697 _mesa_GetInteger64i_v( GLenum pname
, GLuint index
, GLint64
*params
)
2700 enum value_type type
=
2701 find_value_indexed("glGetInteger64i_v", pname
, index
, &v
);
2705 params
[0] = v
.value_int
;
2708 params
[0] = v
.value_int_4
[0];
2709 params
[1] = v
.value_int_4
[1];
2710 params
[2] = v
.value_int_4
[2];
2711 params
[3] = v
.value_int_4
[3];
2714 params
[0] = (GLuint
) v
.value_int
;
2717 params
[0] = (GLuint
) v
.value_int_4
[0];
2718 params
[1] = (GLuint
) v
.value_int_4
[1];
2719 params
[2] = (GLuint
) v
.value_int_4
[2];
2720 params
[3] = (GLuint
) v
.value_int_4
[3];
2723 params
[0] = v
.value_int64
;
2726 ; /* nothing - GL error was recorded */
2731 _mesa_GetFloati_v(GLenum pname
, GLuint index
, GLfloat
*params
)
2736 enum value_type type
=
2737 find_value_indexed("glGetFloati_v", pname
, index
, &v
);
2742 params
[3] = v
.value_float_4
[3];
2745 params
[2] = v
.value_float_4
[2];
2748 params
[1] = v
.value_float_4
[1];
2751 params
[0] = v
.value_float_4
[0];
2754 case TYPE_DOUBLEN_2
:
2755 params
[1] = (GLfloat
) v
.value_double_2
[1];
2757 params
[0] = (GLfloat
) v
.value_double_2
[0];
2761 params
[3] = (GLfloat
) v
.value_int_4
[3];
2763 params
[2] = (GLfloat
) v
.value_int_4
[2];
2766 params
[1] = (GLfloat
) v
.value_int_4
[1];
2770 params
[0] = (GLfloat
) v
.value_int_4
[0];
2774 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
2775 params
[i
] = (GLfloat
) v
.value_int_n
.ints
[i
];
2779 params
[3] = (GLfloat
) ((GLuint
) v
.value_int_4
[3]);
2781 params
[2] = (GLfloat
) ((GLuint
) v
.value_int_4
[2]);
2783 params
[1] = (GLfloat
) ((GLuint
) v
.value_int_4
[1]);
2785 params
[0] = (GLfloat
) ((GLuint
) v
.value_int_4
[0]);
2789 params
[0] = (GLfloat
) v
.value_int64
;
2793 params
[0] = BOOLEAN_TO_FLOAT(v
.value_bool
);
2797 m
= *(GLmatrix
**) &v
;
2798 for (i
= 0; i
< 16; i
++)
2799 params
[i
] = m
->m
[i
];
2803 m
= *(GLmatrix
**) &v
;
2804 for (i
= 0; i
< 16; i
++)
2805 params
[i
] = m
->m
[transpose
[i
]];
2814 _mesa_GetDoublei_v(GLenum pname
, GLuint index
, GLdouble
*params
)
2819 enum value_type type
=
2820 find_value_indexed("glGetDoublei_v", pname
, index
, &v
);
2825 params
[3] = (GLdouble
) v
.value_float_4
[3];
2828 params
[2] = (GLdouble
) v
.value_float_4
[2];
2831 params
[1] = (GLdouble
) v
.value_float_4
[1];
2834 params
[0] = (GLdouble
) v
.value_float_4
[0];
2837 case TYPE_DOUBLEN_2
:
2838 params
[1] = v
.value_double_2
[1];
2840 params
[0] = v
.value_double_2
[0];
2844 params
[3] = (GLdouble
) v
.value_int_4
[3];
2846 params
[2] = (GLdouble
) v
.value_int_4
[2];
2849 params
[1] = (GLdouble
) v
.value_int_4
[1];
2853 params
[0] = (GLdouble
) v
.value_int_4
[0];
2857 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
2858 params
[i
] = (GLdouble
) v
.value_int_n
.ints
[i
];
2862 params
[3] = (GLdouble
) ((GLuint
) v
.value_int_4
[3]);
2864 params
[2] = (GLdouble
) ((GLuint
) v
.value_int_4
[2]);
2866 params
[1] = (GLdouble
) ((GLuint
) v
.value_int_4
[1]);
2868 params
[0] = (GLdouble
) ((GLuint
) v
.value_int_4
[0]);
2872 params
[0] = (GLdouble
) v
.value_int64
;
2876 params
[0] = (GLdouble
) BOOLEAN_TO_FLOAT(v
.value_bool
);
2880 m
= *(GLmatrix
**) &v
;
2881 for (i
= 0; i
< 16; i
++)
2882 params
[i
] = (GLdouble
) m
->m
[i
];
2886 m
= *(GLmatrix
**) &v
;
2887 for (i
= 0; i
< 16; i
++)
2888 params
[i
] = (GLdouble
) m
->m
[transpose
[i
]];
2897 _mesa_GetUnsignedBytei_vEXT(GLenum target
, GLuint index
, GLubyte
*data
)
2901 enum value_type type
;
2902 const char *func
= "glGetUnsignedBytei_vEXT";
2904 GET_CURRENT_CONTEXT(ctx
);
2906 if (!ctx
->Extensions
.EXT_memory_object
) {
2907 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(unsupported)", func
);
2911 type
= find_value_indexed(func
, target
, index
, &v
);
2912 size
= get_value_size(type
, &v
);
2914 _mesa_problem(ctx
, "invalid value type in GetUnsignedBytei_vEXT()");
2941 case TYPE_DOUBLEN_2
:
2944 memcpy(data
, &v
.value_int
, size
);
2947 memcpy(data
, &v
.value_int_n
.ints
, size
);
2950 break; /* nothing - GL error was recorded */
2955 _mesa_GetFixedv(GLenum pname
, GLfixed
*params
)
2957 const struct value_desc
*d
;
2963 d
= find_value("glGetDoublev", pname
, &p
, &v
);
2968 params
[0] = INT_TO_FIXED(d
->offset
);
2973 params
[3] = FLOAT_TO_FIXED(((GLfloat
*) p
)[3]);
2976 params
[2] = FLOAT_TO_FIXED(((GLfloat
*) p
)[2]);
2979 params
[1] = FLOAT_TO_FIXED(((GLfloat
*) p
)[1]);
2982 params
[0] = FLOAT_TO_FIXED(((GLfloat
*) p
)[0]);
2985 case TYPE_DOUBLEN_2
:
2986 params
[1] = FLOAT_TO_FIXED(((GLdouble
*) p
)[1]);
2988 params
[0] = FLOAT_TO_FIXED(((GLdouble
*) p
)[0]);
2993 params
[3] = INT_TO_FIXED(((GLint
*) p
)[3]);
2996 params
[2] = INT_TO_FIXED(((GLint
*) p
)[2]);
3000 params
[1] = INT_TO_FIXED(((GLint
*) p
)[1]);
3004 params
[0] = INT_TO_FIXED(((GLint
*) p
)[0]);
3008 params
[0] = INT_TO_FIXED(((GLenum16
*) p
)[0]);
3012 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
3013 params
[i
] = INT_TO_FIXED(v
.value_int_n
.ints
[i
]);
3017 params
[0] = ((GLint64
*) p
)[0];
3021 params
[0] = BOOLEAN_TO_FIXED(((GLboolean
*) p
)[0]);
3025 m
= *(GLmatrix
**) p
;
3026 for (i
= 0; i
< 16; i
++)
3027 params
[i
] = FLOAT_TO_FIXED(m
->m
[i
]);
3031 m
= *(GLmatrix
**) p
;
3032 for (i
= 0; i
< 16; i
++)
3033 params
[i
] = FLOAT_TO_FIXED(m
->m
[transpose
[i
]]);
3044 shift
= d
->type
- TYPE_BIT_0
;
3045 params
[0] = BOOLEAN_TO_FIXED((*(GLbitfield
*) p
>> shift
) & 1);