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>
32 #include "extensions.h"
37 #include "texcompress.h"
38 #include "framebuffer.h"
39 #include "samplerobj.h"
42 /* This is a table driven implemetation of the glGet*v() functions.
43 * The basic idea is that most getters just look up an int somewhere
44 * in struct gl_context and then convert it to a bool or float according to
45 * which of glGetIntegerv() glGetBooleanv() etc is being called.
46 * Instead of generating code to do this, we can just record the enum
47 * value and the offset into struct gl_context in an array of structs. Then
48 * in glGet*(), we lookup the struct for the enum in question, and use
49 * the offset to get the int we need.
51 * Sometimes we need to look up a float, a boolean, a bit in a
52 * bitfield, a matrix or other types instead, so we need to track the
53 * type of the value in struct gl_context. And sometimes the value isn't in
54 * struct gl_context but in the drawbuffer, the array object, current texture
55 * unit, or maybe it's a computed value. So we need to also track
56 * where or how to find the value. Finally, we sometimes need to
57 * check that one of a number of extensions are enabled, the GL
58 * version or flush or call _mesa_update_state(). This is done by
59 * attaching optional extra information to the value description
60 * struct, it's sort of like an array of opcodes that describe extra
63 * Putting all this together we end up with struct value_desc below,
64 * and with a couple of macros to help, the table of struct value_desc
65 * is about as concise as the specification in the old python script.
68 #define FLOAT_TO_BOOLEAN(X) ( (X) ? GL_TRUE : GL_FALSE )
69 #define FLOAT_TO_FIXED(F) ( ((F) * 65536.0f > INT_MAX) ? INT_MAX : \
70 ((F) * 65536.0f < INT_MIN) ? INT_MIN : \
71 (GLint) ((F) * 65536.0f) )
73 #define INT_TO_BOOLEAN(I) ( (I) ? GL_TRUE : GL_FALSE )
74 #define INT_TO_FIXED(I) ( ((I) > SHRT_MAX) ? INT_MAX : \
75 ((I) < SHRT_MIN) ? INT_MIN : \
76 (GLint) ((I) * 65536) )
78 #define INT64_TO_BOOLEAN(I) ( (I) ? GL_TRUE : GL_FALSE )
79 #define INT64_TO_INT(I) ( (GLint)((I > INT_MAX) ? INT_MAX : ((I < INT_MIN) ? INT_MIN : (I))) )
81 #define BOOLEAN_TO_INT(B) ( (GLint) (B) )
82 #define BOOLEAN_TO_INT64(B) ( (GLint64) (B) )
83 #define BOOLEAN_TO_FLOAT(B) ( (B) ? 1.0F : 0.0F )
84 #define BOOLEAN_TO_FIXED(B) ( (GLint) ((B) ? 1 : 0) << 16 )
86 #define ENUM_TO_INT64(E) ( (GLint64) (E) )
87 #define ENUM_TO_FIXED(E) (E)
123 enum value_location
{
143 EXTRA_NEW_FRAG_CLAMP
,
144 EXTRA_VALID_DRAW_BUFFER
,
145 EXTRA_VALID_TEXTURE_UNIT
,
146 EXTRA_VALID_CLIP_DISTANCE
,
150 EXTRA_EXT_ATOMICS_GS4
,
151 EXTRA_EXT_SHADER_IMAGE_GS4
,
152 EXTRA_EXT_ATOMICS_TESS
,
153 EXTRA_EXT_SHADER_IMAGE_TESS
,
156 #define NO_EXTRA NULL
161 GLubyte location
; /**< enum value_location */
162 GLubyte type
; /**< enum value_type */
169 GLfloat value_float_4
[4];
170 GLdouble value_double_2
[2];
171 GLmatrix
*value_matrix
;
173 GLint value_int_4
[4];
177 /* Sigh, see GL_COMPRESSED_TEXTURE_FORMATS_ARB handling */
181 GLboolean value_bool
;
184 #define BUFFER_FIELD(field, type) \
185 LOC_BUFFER, type, offsetof(struct gl_framebuffer, field)
186 #define CONTEXT_FIELD(field, type) \
187 LOC_CONTEXT, type, offsetof(struct gl_context, field)
188 #define ARRAY_FIELD(field, type) \
189 LOC_ARRAY, type, offsetof(struct gl_vertex_array_object, field)
190 #undef CONST /* already defined through windows.h */
191 #define CONST(value) \
192 LOC_CONTEXT, TYPE_CONST, value
194 #define BUFFER_INT(field) BUFFER_FIELD(field, TYPE_INT)
195 #define BUFFER_ENUM(field) BUFFER_FIELD(field, TYPE_ENUM)
196 #define BUFFER_BOOL(field) BUFFER_FIELD(field, TYPE_BOOLEAN)
198 #define CONTEXT_INT(field) CONTEXT_FIELD(field, TYPE_INT)
199 #define CONTEXT_INT2(field) CONTEXT_FIELD(field, TYPE_INT_2)
200 #define CONTEXT_INT64(field) CONTEXT_FIELD(field, TYPE_INT64)
201 #define CONTEXT_ENUM(field) CONTEXT_FIELD(field, TYPE_ENUM)
202 #define CONTEXT_ENUM2(field) CONTEXT_FIELD(field, TYPE_ENUM_2)
203 #define CONTEXT_BOOL(field) CONTEXT_FIELD(field, TYPE_BOOLEAN)
204 #define CONTEXT_BIT0(field) CONTEXT_FIELD(field, TYPE_BIT_0)
205 #define CONTEXT_BIT1(field) CONTEXT_FIELD(field, TYPE_BIT_1)
206 #define CONTEXT_BIT2(field) CONTEXT_FIELD(field, TYPE_BIT_2)
207 #define CONTEXT_BIT3(field) CONTEXT_FIELD(field, TYPE_BIT_3)
208 #define CONTEXT_BIT4(field) CONTEXT_FIELD(field, TYPE_BIT_4)
209 #define CONTEXT_BIT5(field) CONTEXT_FIELD(field, TYPE_BIT_5)
210 #define CONTEXT_BIT6(field) CONTEXT_FIELD(field, TYPE_BIT_6)
211 #define CONTEXT_BIT7(field) CONTEXT_FIELD(field, TYPE_BIT_7)
212 #define CONTEXT_FLOAT(field) CONTEXT_FIELD(field, TYPE_FLOAT)
213 #define CONTEXT_FLOAT2(field) CONTEXT_FIELD(field, TYPE_FLOAT_2)
214 #define CONTEXT_FLOAT3(field) CONTEXT_FIELD(field, TYPE_FLOAT_3)
215 #define CONTEXT_FLOAT4(field) CONTEXT_FIELD(field, TYPE_FLOAT_4)
216 #define CONTEXT_MATRIX(field) CONTEXT_FIELD(field, TYPE_MATRIX)
217 #define CONTEXT_MATRIX_T(field) CONTEXT_FIELD(field, TYPE_MATRIX_T)
219 #define ARRAY_INT(field) ARRAY_FIELD(field, TYPE_INT)
220 #define ARRAY_ENUM(field) ARRAY_FIELD(field, TYPE_ENUM)
221 #define ARRAY_BOOL(field) ARRAY_FIELD(field, TYPE_BOOLEAN)
224 offsetof(struct gl_extensions, f)
226 #define EXTRA_EXT(e) \
227 static const int extra_##e[] = { \
231 #define EXTRA_EXT2(e1, e2) \
232 static const int extra_##e1##_##e2[] = { \
233 EXT(e1), EXT(e2), EXTRA_END \
236 /* The 'extra' mechanism is a way to specify extra checks (such as
237 * extensions or specific gl versions) or actions (flush current, new
238 * buffers) that we need to do before looking up an enum. We need to
239 * declare them all up front so we can refer to them in the value_desc
242 * Each EXTRA_ will be executed. For EXTRA_* enums of extensions and API
243 * versions, listing multiple ones in an array means an error will be thrown
244 * only if none of them are available. If you need to check for "AND"
245 * behavior, you would need to make a custom EXTRA_ enum.
248 static const int extra_new_buffers
[] = {
253 static const int extra_new_frag_clamp
[] = {
254 EXTRA_NEW_FRAG_CLAMP
,
258 static const int extra_valid_draw_buffer
[] = {
259 EXTRA_VALID_DRAW_BUFFER
,
263 static const int extra_valid_texture_unit
[] = {
264 EXTRA_VALID_TEXTURE_UNIT
,
268 static const int extra_valid_clip_distance
[] = {
269 EXTRA_VALID_CLIP_DISTANCE
,
273 static const int extra_flush_current_valid_texture_unit
[] = {
275 EXTRA_VALID_TEXTURE_UNIT
,
279 static const int extra_flush_current
[] = {
284 static const int extra_EXT_texture_integer_and_new_buffers
[] = {
285 EXT(EXT_texture_integer
),
290 static const int extra_GLSL_130_es3
[] = {
296 static const int extra_texture_buffer_object
[] = {
299 EXT(ARB_texture_buffer_object
),
303 static const int extra_ARB_transform_feedback2_api_es3
[] = {
304 EXT(ARB_transform_feedback2
),
309 static const int extra_ARB_uniform_buffer_object_and_geometry_shader
[] = {
314 static const int extra_ARB_ES2_compatibility_api_es2
[] = {
315 EXT(ARB_ES2_compatibility
),
320 static const int extra_ARB_ES3_compatibility_api_es3
[] = {
321 EXT(ARB_ES3_compatibility
),
326 static const int extra_EXT_framebuffer_sRGB_and_new_buffers
[] = {
327 EXT(EXT_framebuffer_sRGB
),
332 static const int extra_EXT_packed_float
[] = {
333 EXT(EXT_packed_float
),
338 static const int extra_EXT_texture_array_es3
[] = {
339 EXT(EXT_texture_array
),
344 static const int extra_ARB_shader_atomic_counters_and_geometry_shader
[] = {
345 EXTRA_EXT_ATOMICS_GS4
,
349 static const int extra_ARB_shader_image_load_store_and_geometry_shader
[] = {
350 EXTRA_EXT_SHADER_IMAGE_GS4
,
354 static const int extra_ARB_shader_atomic_counters_and_tessellation
[] = {
355 EXTRA_EXT_ATOMICS_TESS
,
359 static const int extra_ARB_shader_image_load_store_and_tessellation
[] = {
360 EXTRA_EXT_SHADER_IMAGE_TESS
,
364 static const int extra_ARB_draw_indirect_es31
[] = {
365 EXT(ARB_draw_indirect
),
370 static const int extra_ARB_shader_image_load_store_es31
[] = {
371 EXT(ARB_shader_image_load_store
),
376 static const int extra_ARB_shader_atomic_counters_es31
[] = {
377 EXT(ARB_shader_atomic_counters
),
382 static const int extra_ARB_texture_multisample_es31
[] = {
383 EXT(ARB_texture_multisample
),
388 static const int extra_ARB_texture_gather_es31
[] = {
389 EXT(ARB_texture_gather
),
394 EXTRA_EXT(ARB_texture_cube_map
);
395 EXTRA_EXT(EXT_texture_array
);
396 EXTRA_EXT(NV_fog_distance
);
397 EXTRA_EXT(EXT_texture_filter_anisotropic
);
398 EXTRA_EXT(NV_point_sprite
);
399 EXTRA_EXT(NV_texture_rectangle
);
400 EXTRA_EXT(EXT_stencil_two_side
);
401 EXTRA_EXT(EXT_depth_bounds_test
);
402 EXTRA_EXT(ARB_depth_clamp
);
403 EXTRA_EXT(ATI_fragment_shader
);
404 EXTRA_EXT(EXT_provoking_vertex
);
405 EXTRA_EXT(ARB_fragment_shader
);
406 EXTRA_EXT(ARB_fragment_program
);
407 EXTRA_EXT2(ARB_framebuffer_object
, EXT_framebuffer_multisample
);
408 EXTRA_EXT(ARB_seamless_cube_map
);
410 EXTRA_EXT(ARB_vertex_shader
);
411 EXTRA_EXT(EXT_transform_feedback
);
412 EXTRA_EXT(ARB_transform_feedback3
);
413 EXTRA_EXT(EXT_pixel_buffer_object
);
414 EXTRA_EXT(ARB_vertex_program
);
415 EXTRA_EXT2(NV_point_sprite
, ARB_point_sprite
);
416 EXTRA_EXT2(ARB_vertex_program
, ARB_fragment_program
);
417 EXTRA_EXT(ARB_geometry_shader4
);
418 EXTRA_EXT(ARB_color_buffer_float
);
419 EXTRA_EXT(EXT_framebuffer_sRGB
);
420 EXTRA_EXT(OES_EGL_image_external
);
421 EXTRA_EXT(ARB_blend_func_extended
);
422 EXTRA_EXT(ARB_uniform_buffer_object
);
423 EXTRA_EXT(ARB_timer_query
);
424 EXTRA_EXT(ARB_texture_cube_map_array
);
425 EXTRA_EXT(ARB_texture_buffer_range
);
426 EXTRA_EXT(ARB_texture_multisample
);
427 EXTRA_EXT(ARB_texture_gather
);
428 EXTRA_EXT(ARB_shader_atomic_counters
);
429 EXTRA_EXT(ARB_draw_indirect
);
430 EXTRA_EXT(ARB_shader_image_load_store
);
431 EXTRA_EXT(ARB_viewport_array
);
432 EXTRA_EXT(ARB_compute_shader
);
433 EXTRA_EXT(ARB_gpu_shader5
);
434 EXTRA_EXT2(ARB_transform_feedback3
, ARB_gpu_shader5
);
435 EXTRA_EXT(INTEL_performance_query
);
436 EXTRA_EXT(ARB_explicit_uniform_location
);
437 EXTRA_EXT(ARB_clip_control
);
438 EXTRA_EXT(EXT_polygon_offset_clamp
);
439 EXTRA_EXT(ARB_framebuffer_no_attachments
);
440 EXTRA_EXT(ARB_tessellation_shader
);
441 EXTRA_EXT(ARB_shader_subroutine
);
444 extra_ARB_color_buffer_float_or_glcore
[] = {
445 EXT(ARB_color_buffer_float
),
451 extra_NV_primitive_restart
[] = {
452 EXT(NV_primitive_restart
),
456 static const int extra_version_30
[] = { EXTRA_VERSION_30
, EXTRA_END
};
457 static const int extra_version_31
[] = { EXTRA_VERSION_31
, EXTRA_END
};
458 static const int extra_version_32
[] = { EXTRA_VERSION_32
, EXTRA_END
};
459 static const int extra_version_40
[] = { EXTRA_VERSION_40
, EXTRA_END
};
461 static const int extra_gl30_es3
[] = {
467 static const int extra_gl32_es3
[] = {
473 static const int extra_gl32_ARB_geometry_shader4
[] = {
475 EXT(ARB_geometry_shader4
),
479 static const int extra_gl40_ARB_sample_shading
[] = {
481 EXT(ARB_sample_shading
),
486 extra_ARB_vertex_program_api_es2
[] = {
487 EXT(ARB_vertex_program
),
492 /* The ReadBuffer get token is valid under either full GL or under
493 * GLES2 if the NV_read_buffer extension is available. */
495 extra_NV_read_buffer_api_gl
[] = {
501 static const int extra_core_ARB_color_buffer_float_and_new_buffers
[] = {
503 EXT(ARB_color_buffer_float
),
508 /* This is the big table describing all the enums we accept in
509 * glGet*v(). The table is partitioned into six parts: enums
510 * understood by all GL APIs (OpenGL, GLES and GLES2), enums shared
511 * between OpenGL and GLES, enums exclusive to GLES, etc for the
512 * remaining combinations. To look up the enums valid in a given API
513 * we will use a hash table specific to that API. These tables are in
514 * turn generated at build time and included through get_hash.h.
517 #include "get_hash.h"
519 /* All we need now is a way to look up the value struct from the enum.
520 * The code generated by gcc for the old generated big switch
521 * statement is a big, balanced, open coded if/else tree, essentially
522 * an unrolled binary search. It would be natural to sort the new
523 * enum table and use bsearch(), but we will use a read-only hash
524 * table instead. bsearch() has a nice guaranteed worst case
525 * performance, but we're also guaranteed to hit that worst case
526 * (log2(n) iterations) for about half the enums. Instead, using an
527 * open addressing hash table, we can find the enum on the first try
528 * for 80% of the enums, 1 collision for 10% and never more than 5
529 * collisions for any enum (typical numbers). And the code is very
530 * simple, even though it feels a little magic. */
534 print_table_stats(int api
)
536 int i
, j
, collisions
[11], count
, hash
, mask
;
537 const struct value_desc
*d
;
538 const char *api_names
[] = {
539 [API_OPENGL_COMPAT
] = "GL",
540 [API_OPENGL_CORE
] = "GL_CORE",
541 [API_OPENGLES
] = "GLES",
542 [API_OPENGLES2
] = "GLES2",
544 const char *api_name
;
546 api_name
= api
< ARRAY_SIZE(api_names
) ? api_names
[api
] : "N/A";
548 mask
= ARRAY_SIZE(table(api
)) - 1;
549 memset(collisions
, 0, sizeof collisions
);
551 for (i
= 0; i
< ARRAY_SIZE(table(api
)); i
++) {
555 d
= &values
[table(api
)[i
]];
556 hash
= (d
->pname
* prime_factor
);
559 if (values
[table(api
)[hash
& mask
]].pname
== d
->pname
)
571 printf("number of enums for %s: %d (total %ld)\n",
572 api_name
, count
, ARRAY_SIZE(values
));
573 for (i
= 0; i
< ARRAY_SIZE(collisions
) - 1; i
++)
574 if (collisions
[i
] > 0)
575 printf(" %d enums with %d %scollisions\n",
576 collisions
[i
], i
, i
== 10 ? "or more " : "");
581 * Initialize the enum hash for a given API
583 * This is called from one_time_init() to insert the enum values that
584 * are valid for the API in question into the enum hash table.
586 * \param the current context, for determining the API in question
588 void _mesa_init_get_hash(struct gl_context
*ctx
)
591 print_table_stats(ctx
->API
);
598 * Handle irregular enums
600 * Some values don't conform to the "well-known type at context
601 * pointer + offset" pattern, so we have this function to catch all
602 * the corner cases. Typically, it's a computed value or a one-off
603 * pointer to a custom struct or something.
605 * In this case we can't return a pointer to the value, so we'll have
606 * to use the temporary variable 'v' declared back in the calling
607 * glGet*v() function to store the result.
609 * \param ctx the current context
610 * \param d the struct value_desc that describes the enum
611 * \param v pointer to the tmp declared in the calling glGet*v() function
614 find_custom_value(struct gl_context
*ctx
, const struct value_desc
*d
, union value
*v
)
616 struct gl_buffer_object
**buffer_obj
;
617 struct gl_vertex_attrib_array
*array
;
621 case GL_MAJOR_VERSION
:
622 v
->value_int
= ctx
->Version
/ 10;
624 case GL_MINOR_VERSION
:
625 v
->value_int
= ctx
->Version
% 10;
631 case GL_TEXTURE_CUBE_MAP_ARB
:
632 case GL_TEXTURE_RECTANGLE_NV
:
633 case GL_TEXTURE_EXTERNAL_OES
:
634 v
->value_bool
= _mesa_IsEnabled(d
->pname
);
637 case GL_LINE_STIPPLE_PATTERN
:
638 /* This is the only GLushort, special case it here by promoting
639 * to an int rather than introducing a new type. */
640 v
->value_int
= ctx
->Line
.StipplePattern
;
643 case GL_CURRENT_RASTER_TEXTURE_COORDS
:
644 unit
= ctx
->Texture
.CurrentUnit
;
645 v
->value_float_4
[0] = ctx
->Current
.RasterTexCoords
[unit
][0];
646 v
->value_float_4
[1] = ctx
->Current
.RasterTexCoords
[unit
][1];
647 v
->value_float_4
[2] = ctx
->Current
.RasterTexCoords
[unit
][2];
648 v
->value_float_4
[3] = ctx
->Current
.RasterTexCoords
[unit
][3];
651 case GL_CURRENT_TEXTURE_COORDS
:
652 unit
= ctx
->Texture
.CurrentUnit
;
653 v
->value_float_4
[0] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
][0];
654 v
->value_float_4
[1] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
][1];
655 v
->value_float_4
[2] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
][2];
656 v
->value_float_4
[3] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
][3];
659 case GL_COLOR_WRITEMASK
:
660 v
->value_int_4
[0] = ctx
->Color
.ColorMask
[0][RCOMP
] ? 1 : 0;
661 v
->value_int_4
[1] = ctx
->Color
.ColorMask
[0][GCOMP
] ? 1 : 0;
662 v
->value_int_4
[2] = ctx
->Color
.ColorMask
[0][BCOMP
] ? 1 : 0;
663 v
->value_int_4
[3] = ctx
->Color
.ColorMask
[0][ACOMP
] ? 1 : 0;
667 v
->value_bool
= ctx
->Current
.Attrib
[VERT_ATTRIB_EDGEFLAG
][0] == 1.0;
671 v
->value_enum
= ctx
->ReadBuffer
->ColorReadBuffer
;
674 case GL_MAP2_GRID_DOMAIN
:
675 v
->value_float_4
[0] = ctx
->Eval
.MapGrid2u1
;
676 v
->value_float_4
[1] = ctx
->Eval
.MapGrid2u2
;
677 v
->value_float_4
[2] = ctx
->Eval
.MapGrid2v1
;
678 v
->value_float_4
[3] = ctx
->Eval
.MapGrid2v2
;
681 case GL_TEXTURE_STACK_DEPTH
:
682 unit
= ctx
->Texture
.CurrentUnit
;
683 v
->value_int
= ctx
->TextureMatrixStack
[unit
].Depth
+ 1;
685 case GL_TEXTURE_MATRIX
:
686 unit
= ctx
->Texture
.CurrentUnit
;
687 v
->value_matrix
= ctx
->TextureMatrixStack
[unit
].Top
;
690 case GL_TEXTURE_COORD_ARRAY
:
691 case GL_TEXTURE_COORD_ARRAY_SIZE
:
692 case GL_TEXTURE_COORD_ARRAY_TYPE
:
693 case GL_TEXTURE_COORD_ARRAY_STRIDE
:
694 array
= &ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_TEX(ctx
->Array
.ActiveTexture
)];
695 v
->value_int
= *(GLuint
*) ((char *) array
+ d
->offset
);
698 case GL_ACTIVE_TEXTURE_ARB
:
699 v
->value_int
= GL_TEXTURE0_ARB
+ ctx
->Texture
.CurrentUnit
;
701 case GL_CLIENT_ACTIVE_TEXTURE_ARB
:
702 v
->value_int
= GL_TEXTURE0_ARB
+ ctx
->Array
.ActiveTexture
;
705 case GL_MODELVIEW_STACK_DEPTH
:
706 case GL_PROJECTION_STACK_DEPTH
:
707 v
->value_int
= *(GLint
*) ((char *) ctx
+ d
->offset
) + 1;
710 case GL_MAX_TEXTURE_SIZE
:
711 case GL_MAX_3D_TEXTURE_SIZE
:
712 case GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB
:
713 p
= (GLuint
*) ((char *) ctx
+ d
->offset
);
714 v
->value_int
= 1 << (*p
- 1);
718 v
->value_int_4
[0] = ctx
->Scissor
.ScissorArray
[0].X
;
719 v
->value_int_4
[1] = ctx
->Scissor
.ScissorArray
[0].Y
;
720 v
->value_int_4
[2] = ctx
->Scissor
.ScissorArray
[0].Width
;
721 v
->value_int_4
[3] = ctx
->Scissor
.ScissorArray
[0].Height
;
724 case GL_SCISSOR_TEST
:
725 v
->value_bool
= ctx
->Scissor
.EnableFlags
& 1;
730 ctx
->ListState
.CurrentList
? ctx
->ListState
.CurrentList
->Name
: 0;
733 if (!ctx
->CompileFlag
)
735 else if (ctx
->ExecuteFlag
)
736 v
->value_enum
= GL_COMPILE_AND_EXECUTE
;
738 v
->value_enum
= GL_COMPILE
;
742 v
->value_float_4
[0] = ctx
->ViewportArray
[0].X
;
743 v
->value_float_4
[1] = ctx
->ViewportArray
[0].Y
;
744 v
->value_float_4
[2] = ctx
->ViewportArray
[0].Width
;
745 v
->value_float_4
[3] = ctx
->ViewportArray
[0].Height
;
749 v
->value_double_2
[0] = ctx
->ViewportArray
[0].Near
;
750 v
->value_double_2
[1] = ctx
->ViewportArray
[0].Far
;
753 case GL_ACTIVE_STENCIL_FACE_EXT
:
754 v
->value_enum
= ctx
->Stencil
.ActiveFace
? GL_BACK
: GL_FRONT
;
757 case GL_STENCIL_FAIL
:
758 v
->value_enum
= ctx
->Stencil
.FailFunc
[ctx
->Stencil
.ActiveFace
];
760 case GL_STENCIL_FUNC
:
761 v
->value_enum
= ctx
->Stencil
.Function
[ctx
->Stencil
.ActiveFace
];
763 case GL_STENCIL_PASS_DEPTH_FAIL
:
764 v
->value_enum
= ctx
->Stencil
.ZFailFunc
[ctx
->Stencil
.ActiveFace
];
766 case GL_STENCIL_PASS_DEPTH_PASS
:
767 v
->value_enum
= ctx
->Stencil
.ZPassFunc
[ctx
->Stencil
.ActiveFace
];
770 v
->value_int
= _mesa_get_stencil_ref(ctx
, ctx
->Stencil
.ActiveFace
);
772 case GL_STENCIL_BACK_REF
:
773 v
->value_int
= _mesa_get_stencil_ref(ctx
, 1);
775 case GL_STENCIL_VALUE_MASK
:
776 v
->value_int
= ctx
->Stencil
.ValueMask
[ctx
->Stencil
.ActiveFace
];
778 case GL_STENCIL_WRITEMASK
:
779 v
->value_int
= ctx
->Stencil
.WriteMask
[ctx
->Stencil
.ActiveFace
];
782 case GL_NUM_EXTENSIONS
:
783 v
->value_int
= _mesa_get_extension_count(ctx
);
786 case GL_IMPLEMENTATION_COLOR_READ_TYPE_OES
:
787 v
->value_int
= _mesa_get_color_read_type(ctx
);
789 case GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES
:
790 v
->value_int
= _mesa_get_color_read_format(ctx
);
793 case GL_CURRENT_MATRIX_STACK_DEPTH_ARB
:
794 v
->value_int
= ctx
->CurrentStack
->Depth
+ 1;
796 case GL_CURRENT_MATRIX_ARB
:
797 case GL_TRANSPOSE_CURRENT_MATRIX_ARB
:
798 v
->value_matrix
= ctx
->CurrentStack
->Top
;
801 case GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB
:
802 v
->value_int
= _mesa_get_compressed_formats(ctx
, NULL
);
804 case GL_COMPRESSED_TEXTURE_FORMATS_ARB
:
806 _mesa_get_compressed_formats(ctx
, v
->value_int_n
.ints
);
807 assert(v
->value_int_n
.n
<= (int) ARRAY_SIZE(v
->value_int_n
.ints
));
810 case GL_MAX_VARYING_FLOATS_ARB
:
811 v
->value_int
= ctx
->Const
.MaxVarying
* 4;
814 /* Various object names */
816 case GL_TEXTURE_BINDING_1D
:
817 case GL_TEXTURE_BINDING_2D
:
818 case GL_TEXTURE_BINDING_3D
:
819 case GL_TEXTURE_BINDING_1D_ARRAY_EXT
:
820 case GL_TEXTURE_BINDING_2D_ARRAY_EXT
:
821 case GL_TEXTURE_BINDING_CUBE_MAP_ARB
:
822 case GL_TEXTURE_BINDING_RECTANGLE_NV
:
823 case GL_TEXTURE_BINDING_EXTERNAL_OES
:
824 case GL_TEXTURE_BINDING_CUBE_MAP_ARRAY
:
825 case GL_TEXTURE_BINDING_2D_MULTISAMPLE
:
826 case GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY
:
827 unit
= ctx
->Texture
.CurrentUnit
;
829 ctx
->Texture
.Unit
[unit
].CurrentTex
[d
->offset
]->Name
;
832 /* GL_EXT_packed_float */
833 case GL_RGBA_SIGNED_COMPONENTS_EXT
:
835 /* Note: we only check the 0th color attachment. */
836 const struct gl_renderbuffer
*rb
=
837 ctx
->DrawBuffer
->_ColorDrawBuffers
[0];
838 if (rb
&& _mesa_is_format_signed(rb
->Format
)) {
839 /* Issue 17 of GL_EXT_packed_float: If a component (such as
840 * alpha) has zero bits, the component should not be considered
841 * signed and so the bit for the respective component should be
845 _mesa_get_format_bits(rb
->Format
, GL_RED_BITS
);
847 _mesa_get_format_bits(rb
->Format
, GL_GREEN_BITS
);
849 _mesa_get_format_bits(rb
->Format
, GL_BLUE_BITS
);
851 _mesa_get_format_bits(rb
->Format
, GL_ALPHA_BITS
);
853 _mesa_get_format_bits(rb
->Format
, GL_TEXTURE_LUMINANCE_SIZE
);
855 _mesa_get_format_bits(rb
->Format
, GL_TEXTURE_INTENSITY_SIZE
);
857 v
->value_int_4
[0] = r_bits
+ l_bits
+ i_bits
> 0;
858 v
->value_int_4
[1] = g_bits
+ l_bits
+ i_bits
> 0;
859 v
->value_int_4
[2] = b_bits
+ l_bits
+ i_bits
> 0;
860 v
->value_int_4
[3] = a_bits
+ i_bits
> 0;
866 v
->value_int_4
[3] = 0;
871 /* GL_ARB_vertex_buffer_object */
872 case GL_VERTEX_ARRAY_BUFFER_BINDING_ARB
:
873 case GL_NORMAL_ARRAY_BUFFER_BINDING_ARB
:
874 case GL_COLOR_ARRAY_BUFFER_BINDING_ARB
:
875 case GL_INDEX_ARRAY_BUFFER_BINDING_ARB
:
876 case GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB
:
877 case GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB
:
878 case GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB
:
879 buffer_obj
= (struct gl_buffer_object
**)
880 ((char *) ctx
->Array
.VAO
+ d
->offset
);
881 v
->value_int
= (*buffer_obj
)->Name
;
883 case GL_ARRAY_BUFFER_BINDING_ARB
:
884 v
->value_int
= ctx
->Array
.ArrayBufferObj
->Name
;
886 case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB
:
888 ctx
->Array
.VAO
->VertexBinding
[VERT_ATTRIB_TEX(ctx
->Array
.ActiveTexture
)].BufferObj
->Name
;
890 case GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB
:
891 v
->value_int
= ctx
->Array
.VAO
->IndexBufferObj
->Name
;
894 /* ARB_vertex_array_bgra */
895 case GL_COLOR_ARRAY_SIZE
:
896 array
= &ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_COLOR0
];
897 v
->value_int
= array
->Format
== GL_BGRA
? GL_BGRA
: array
->Size
;
899 case GL_SECONDARY_COLOR_ARRAY_SIZE
:
900 array
= &ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_COLOR1
];
901 v
->value_int
= array
->Format
== GL_BGRA
? GL_BGRA
: array
->Size
;
904 /* ARB_copy_buffer */
905 case GL_COPY_READ_BUFFER
:
906 v
->value_int
= ctx
->CopyReadBuffer
->Name
;
908 case GL_COPY_WRITE_BUFFER
:
909 v
->value_int
= ctx
->CopyWriteBuffer
->Name
;
912 case GL_PIXEL_PACK_BUFFER_BINDING_EXT
:
913 v
->value_int
= ctx
->Pack
.BufferObj
->Name
;
915 case GL_PIXEL_UNPACK_BUFFER_BINDING_EXT
:
916 v
->value_int
= ctx
->Unpack
.BufferObj
->Name
;
918 case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING
:
919 v
->value_int
= ctx
->TransformFeedback
.CurrentBuffer
->Name
;
921 case GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED
:
922 v
->value_int
= ctx
->TransformFeedback
.CurrentObject
->Paused
;
924 case GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE
:
925 v
->value_int
= ctx
->TransformFeedback
.CurrentObject
->Active
;
927 case GL_TRANSFORM_FEEDBACK_BINDING
:
928 v
->value_int
= ctx
->TransformFeedback
.CurrentObject
->Name
;
930 case GL_CURRENT_PROGRAM
:
931 /* The Changelog of the ARB_separate_shader_objects spec says:
933 * 24 25 Jul 2011 pbrown Remove the language erroneously deleting
934 * CURRENT_PROGRAM. In the EXT extension, this
935 * token was aliased to ACTIVE_PROGRAM_EXT, and
936 * was used to indicate the last program set by
937 * either ActiveProgramEXT or UseProgram. In
938 * the ARB extension, the SSO active programs
939 * are now program pipeline object state and
940 * CURRENT_PROGRAM should still be used to query
941 * the last program set by UseProgram (bug 7822).
944 ctx
->Shader
.ActiveProgram
? ctx
->Shader
.ActiveProgram
->Name
: 0;
946 case GL_READ_FRAMEBUFFER_BINDING_EXT
:
947 v
->value_int
= ctx
->ReadBuffer
->Name
;
949 case GL_RENDERBUFFER_BINDING_EXT
:
951 ctx
->CurrentRenderbuffer
? ctx
->CurrentRenderbuffer
->Name
: 0;
953 case GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES
:
954 v
->value_int
= ctx
->Array
.VAO
->VertexBinding
[VERT_ATTRIB_POINT_SIZE
].BufferObj
->Name
;
958 if (_mesa_get_clamp_fragment_color(ctx
, ctx
->DrawBuffer
))
959 COPY_4FV(v
->value_float_4
, ctx
->Fog
.Color
);
961 COPY_4FV(v
->value_float_4
, ctx
->Fog
.ColorUnclamped
);
963 case GL_COLOR_CLEAR_VALUE
:
964 if (_mesa_get_clamp_fragment_color(ctx
, ctx
->DrawBuffer
)) {
965 v
->value_float_4
[0] = CLAMP(ctx
->Color
.ClearColor
.f
[0], 0.0F
, 1.0F
);
966 v
->value_float_4
[1] = CLAMP(ctx
->Color
.ClearColor
.f
[1], 0.0F
, 1.0F
);
967 v
->value_float_4
[2] = CLAMP(ctx
->Color
.ClearColor
.f
[2], 0.0F
, 1.0F
);
968 v
->value_float_4
[3] = CLAMP(ctx
->Color
.ClearColor
.f
[3], 0.0F
, 1.0F
);
970 COPY_4FV(v
->value_float_4
, ctx
->Color
.ClearColor
.f
);
972 case GL_BLEND_COLOR_EXT
:
973 if (_mesa_get_clamp_fragment_color(ctx
, ctx
->DrawBuffer
))
974 COPY_4FV(v
->value_float_4
, ctx
->Color
.BlendColor
);
976 COPY_4FV(v
->value_float_4
, ctx
->Color
.BlendColorUnclamped
);
978 case GL_ALPHA_TEST_REF
:
979 if (_mesa_get_clamp_fragment_color(ctx
, ctx
->DrawBuffer
))
980 v
->value_float
= ctx
->Color
.AlphaRef
;
982 v
->value_float
= ctx
->Color
.AlphaRefUnclamped
;
984 case GL_MAX_VERTEX_UNIFORM_VECTORS
:
985 v
->value_int
= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxUniformComponents
/ 4;
988 case GL_MAX_FRAGMENT_UNIFORM_VECTORS
:
989 v
->value_int
= ctx
->Const
.Program
[MESA_SHADER_FRAGMENT
].MaxUniformComponents
/ 4;
992 /* GL_ARB_texture_buffer_object */
993 case GL_TEXTURE_BUFFER_ARB
:
994 v
->value_int
= ctx
->Texture
.BufferObject
->Name
;
996 case GL_TEXTURE_BINDING_BUFFER_ARB
:
997 unit
= ctx
->Texture
.CurrentUnit
;
999 ctx
->Texture
.Unit
[unit
].CurrentTex
[TEXTURE_BUFFER_INDEX
]->Name
;
1001 case GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB
:
1003 struct gl_buffer_object
*buf
=
1004 ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
]
1005 .CurrentTex
[TEXTURE_BUFFER_INDEX
]->BufferObject
;
1006 v
->value_int
= buf
? buf
->Name
: 0;
1009 case GL_TEXTURE_BUFFER_FORMAT_ARB
:
1010 v
->value_int
= ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
]
1011 .CurrentTex
[TEXTURE_BUFFER_INDEX
]->BufferObjectFormat
;
1014 /* GL_ARB_sampler_objects */
1015 case GL_SAMPLER_BINDING
:
1017 struct gl_sampler_object
*samp
=
1018 ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
].Sampler
;
1021 * The sampler object may have been deleted on another context,
1022 * so we try to lookup the sampler object before returning its Name.
1024 if (samp
&& _mesa_lookup_samplerobj(ctx
, samp
->Name
)) {
1025 v
->value_int
= samp
->Name
;
1031 /* GL_ARB_uniform_buffer_object */
1032 case GL_UNIFORM_BUFFER_BINDING
:
1033 v
->value_int
= ctx
->UniformBuffer
->Name
;
1035 /* GL_ARB_timer_query */
1037 if (ctx
->Driver
.GetTimestamp
) {
1038 v
->value_int64
= ctx
->Driver
.GetTimestamp(ctx
);
1041 _mesa_problem(ctx
, "driver doesn't implement GetTimestamp");
1045 case GL_DEBUG_LOGGED_MESSAGES
:
1046 case GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH
:
1047 case GL_DEBUG_GROUP_STACK_DEPTH
:
1048 v
->value_int
= _mesa_get_debug_state_int(ctx
, d
->pname
);
1050 /* GL_ARB_shader_atomic_counters */
1051 case GL_ATOMIC_COUNTER_BUFFER_BINDING
:
1052 if (ctx
->AtomicBuffer
) {
1053 v
->value_int
= ctx
->AtomicBuffer
->Name
;
1058 /* GL_ARB_draw_indirect */
1059 case GL_DRAW_INDIRECT_BUFFER_BINDING
:
1060 v
->value_int
= ctx
->DrawIndirectBuffer
->Name
;
1062 /* GL_ARB_separate_shader_objects */
1063 case GL_PROGRAM_PIPELINE_BINDING
:
1064 if (ctx
->Pipeline
.Current
) {
1065 v
->value_int
= ctx
->Pipeline
.Current
->Name
;
1074 * Check extra constraints on a struct value_desc descriptor
1076 * If a struct value_desc has a non-NULL extra pointer, it means that
1077 * there are a number of extra constraints to check or actions to
1078 * perform. The extras is just an integer array where each integer
1079 * encode different constraints or actions.
1081 * \param ctx current context
1082 * \param func name of calling glGet*v() function for error reporting
1083 * \param d the struct value_desc that has the extra constraints
1085 * \return GL_FALSE if all of the constraints were not satisfied,
1086 * otherwise GL_TRUE.
1089 check_extra(struct gl_context
*ctx
, const char *func
, const struct value_desc
*d
)
1091 const GLuint version
= ctx
->Version
;
1092 GLboolean api_check
= GL_FALSE
;
1093 GLboolean api_found
= GL_FALSE
;
1096 for (e
= d
->extra
; *e
!= EXTRA_END
; e
++) {
1098 case EXTRA_VERSION_30
:
1099 api_check
= GL_TRUE
;
1101 api_found
= GL_TRUE
;
1103 case EXTRA_VERSION_31
:
1104 api_check
= GL_TRUE
;
1106 api_found
= GL_TRUE
;
1108 case EXTRA_VERSION_32
:
1109 api_check
= GL_TRUE
;
1111 api_found
= GL_TRUE
;
1113 case EXTRA_NEW_FRAG_CLAMP
:
1114 if (ctx
->NewState
& (_NEW_BUFFERS
| _NEW_FRAG_CLAMP
))
1115 _mesa_update_state(ctx
);
1118 api_check
= GL_TRUE
;
1119 if (ctx
->API
== API_OPENGLES2
)
1120 api_found
= GL_TRUE
;
1123 api_check
= GL_TRUE
;
1124 if (_mesa_is_gles3(ctx
))
1125 api_found
= GL_TRUE
;
1127 case EXTRA_API_ES31
:
1128 api_check
= GL_TRUE
;
1129 if (_mesa_is_gles31(ctx
))
1130 api_found
= GL_TRUE
;
1133 api_check
= GL_TRUE
;
1134 if (_mesa_is_desktop_gl(ctx
))
1135 api_found
= GL_TRUE
;
1137 case EXTRA_API_GL_CORE
:
1138 api_check
= GL_TRUE
;
1139 if (ctx
->API
== API_OPENGL_CORE
)
1140 api_found
= GL_TRUE
;
1142 case EXTRA_NEW_BUFFERS
:
1143 if (ctx
->NewState
& _NEW_BUFFERS
)
1144 _mesa_update_state(ctx
);
1146 case EXTRA_FLUSH_CURRENT
:
1147 FLUSH_CURRENT(ctx
, 0);
1149 case EXTRA_VALID_DRAW_BUFFER
:
1150 if (d
->pname
- GL_DRAW_BUFFER0_ARB
>= ctx
->Const
.MaxDrawBuffers
) {
1151 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(draw buffer %u)",
1152 func
, d
->pname
- GL_DRAW_BUFFER0_ARB
);
1156 case EXTRA_VALID_TEXTURE_UNIT
:
1157 if (ctx
->Texture
.CurrentUnit
>= ctx
->Const
.MaxTextureCoordUnits
) {
1158 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(texture %u)",
1159 func
, ctx
->Texture
.CurrentUnit
);
1163 case EXTRA_VALID_CLIP_DISTANCE
:
1164 if (d
->pname
- GL_CLIP_DISTANCE0
>= ctx
->Const
.MaxClipPlanes
) {
1165 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(clip distance %u)",
1166 func
, d
->pname
- GL_CLIP_DISTANCE0
);
1170 case EXTRA_GLSL_130
:
1171 api_check
= GL_TRUE
;
1172 if (ctx
->Const
.GLSLVersion
>= 130)
1173 api_found
= GL_TRUE
;
1175 case EXTRA_EXT_UBO_GS4
:
1176 api_check
= GL_TRUE
;
1177 api_found
= (ctx
->Extensions
.ARB_uniform_buffer_object
&&
1178 _mesa_has_geometry_shaders(ctx
));
1180 case EXTRA_EXT_ATOMICS_GS4
:
1181 api_check
= GL_TRUE
;
1182 api_found
= (ctx
->Extensions
.ARB_shader_atomic_counters
&&
1183 _mesa_has_geometry_shaders(ctx
));
1185 case EXTRA_EXT_SHADER_IMAGE_GS4
:
1186 api_check
= GL_TRUE
;
1187 api_found
= (ctx
->Extensions
.ARB_shader_image_load_store
&&
1188 _mesa_has_geometry_shaders(ctx
));
1190 case EXTRA_EXT_ATOMICS_TESS
:
1191 api_check
= GL_TRUE
;
1192 api_found
= ctx
->Extensions
.ARB_shader_atomic_counters
&&
1193 _mesa_has_tessellation(ctx
);
1195 case EXTRA_EXT_SHADER_IMAGE_TESS
:
1196 api_check
= GL_TRUE
;
1197 api_found
= ctx
->Extensions
.ARB_shader_image_load_store
&&
1198 _mesa_has_tessellation(ctx
);
1202 default: /* *e is a offset into the extension struct */
1203 api_check
= GL_TRUE
;
1204 if (*(GLboolean
*) ((char *) &ctx
->Extensions
+ *e
))
1205 api_found
= GL_TRUE
;
1210 if (api_check
&& !api_found
) {
1211 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(pname=%s)", func
,
1212 _mesa_enum_to_string(d
->pname
));
1219 static const struct value_desc error_value
=
1220 { 0, 0, TYPE_INVALID
, NO_OFFSET
, NO_EXTRA
};
1223 * Find the struct value_desc corresponding to the enum 'pname'.
1225 * We hash the enum value to get an index into the 'table' array,
1226 * which holds the index in the 'values' array of struct value_desc.
1227 * Once we've found the entry, we do the extra checks, if any, then
1228 * look up the value and return a pointer to it.
1230 * If the value has to be computed (for example, it's the result of a
1231 * function call or we need to add 1 to it), we use the tmp 'v' to
1234 * \param func name of glGet*v() func for error reporting
1235 * \param pname the enum value we're looking up
1236 * \param p is were we return the pointer to the value
1237 * \param v a tmp union value variable in the calling glGet*v() function
1239 * \return the struct value_desc corresponding to the enum or a struct
1240 * value_desc of TYPE_INVALID if not found. This lets the calling
1241 * glGet*v() function jump right into a switch statement and
1242 * handle errors there instead of having to check for NULL.
1244 static const struct value_desc
*
1245 find_value(const char *func
, GLenum pname
, void **p
, union value
*v
)
1247 GET_CURRENT_CONTEXT(ctx
);
1248 struct gl_texture_unit
*unit
;
1250 const struct value_desc
*d
;
1254 /* We index into the table_set[] list of per-API hash tables using the API's
1255 * value in the gl_api enum. Since GLES 3 doesn't have an API_OPENGL* enum
1256 * value since it's compatible with GLES2 its entry in table_set[] is at the
1259 STATIC_ASSERT(ARRAY_SIZE(table_set
) == API_OPENGL_LAST
+ 3);
1260 if (_mesa_is_gles3(ctx
)) {
1261 api
= API_OPENGL_LAST
+ 1;
1263 if (_mesa_is_gles31(ctx
)) {
1264 api
= API_OPENGL_LAST
+ 2;
1266 mask
= ARRAY_SIZE(table(api
)) - 1;
1267 hash
= (pname
* prime_factor
);
1269 int idx
= table(api
)[hash
& mask
];
1271 /* If the enum isn't valid, the hash walk ends with index 0,
1272 * pointing to the first entry of values[] which doesn't hold
1273 * any valid enum. */
1274 if (unlikely(idx
== 0)) {
1275 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(pname=%s)", func
,
1276 _mesa_enum_to_string(pname
));
1277 return &error_value
;
1281 if (likely(d
->pname
== pname
))
1287 if (unlikely(d
->extra
&& !check_extra(ctx
, func
, d
)))
1288 return &error_value
;
1290 switch (d
->location
) {
1292 *p
= ((char *) ctx
->DrawBuffer
+ d
->offset
);
1295 *p
= ((char *) ctx
+ d
->offset
);
1298 *p
= ((char *) ctx
->Array
.VAO
+ d
->offset
);
1301 unit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1302 *p
= ((char *) unit
+ d
->offset
);
1305 find_custom_value(ctx
, d
, v
);
1313 /* silence warning */
1314 return &error_value
;
1317 static const int transpose
[] = {
1325 _mesa_GetBooleanv(GLenum pname
, GLboolean
*params
)
1327 const struct value_desc
*d
;
1333 d
= find_value("glGetBooleanv", pname
, &p
, &v
);
1338 params
[0] = INT_TO_BOOLEAN(d
->offset
);
1343 params
[3] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[3]);
1346 params
[2] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[2]);
1349 params
[1] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[1]);
1352 params
[0] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[0]);
1355 case TYPE_DOUBLEN_2
:
1356 params
[1] = FLOAT_TO_BOOLEAN(((GLdouble
*) p
)[1]);
1358 params
[0] = FLOAT_TO_BOOLEAN(((GLdouble
*) p
)[0]);
1362 params
[3] = INT_TO_BOOLEAN(((GLint
*) p
)[3]);
1364 params
[2] = INT_TO_BOOLEAN(((GLint
*) p
)[2]);
1367 params
[1] = INT_TO_BOOLEAN(((GLint
*) p
)[1]);
1370 params
[0] = INT_TO_BOOLEAN(((GLint
*) p
)[0]);
1374 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
1375 params
[i
] = INT_TO_BOOLEAN(v
.value_int_n
.ints
[i
]);
1379 params
[0] = INT64_TO_BOOLEAN(((GLint64
*) p
)[0]);
1383 params
[0] = ((GLboolean
*) p
)[0];
1387 m
= *(GLmatrix
**) p
;
1388 for (i
= 0; i
< 16; i
++)
1389 params
[i
] = FLOAT_TO_BOOLEAN(m
->m
[i
]);
1393 m
= *(GLmatrix
**) p
;
1394 for (i
= 0; i
< 16; i
++)
1395 params
[i
] = FLOAT_TO_BOOLEAN(m
->m
[transpose
[i
]]);
1406 shift
= d
->type
- TYPE_BIT_0
;
1407 params
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
1413 _mesa_GetFloatv(GLenum pname
, GLfloat
*params
)
1415 const struct value_desc
*d
;
1421 d
= find_value("glGetFloatv", pname
, &p
, &v
);
1426 params
[0] = (GLfloat
) d
->offset
;
1431 params
[3] = ((GLfloat
*) p
)[3];
1434 params
[2] = ((GLfloat
*) p
)[2];
1437 params
[1] = ((GLfloat
*) p
)[1];
1440 params
[0] = ((GLfloat
*) p
)[0];
1443 case TYPE_DOUBLEN_2
:
1444 params
[1] = (GLfloat
) (((GLdouble
*) p
)[1]);
1446 params
[0] = (GLfloat
) (((GLdouble
*) p
)[0]);
1450 params
[3] = (GLfloat
) (((GLint
*) p
)[3]);
1452 params
[2] = (GLfloat
) (((GLint
*) p
)[2]);
1455 params
[1] = (GLfloat
) (((GLint
*) p
)[1]);
1458 params
[0] = (GLfloat
) (((GLint
*) p
)[0]);
1462 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
1463 params
[i
] = INT_TO_FLOAT(v
.value_int_n
.ints
[i
]);
1467 params
[0] = (GLfloat
) (((GLint64
*) p
)[0]);
1471 params
[0] = BOOLEAN_TO_FLOAT(*(GLboolean
*) p
);
1475 m
= *(GLmatrix
**) p
;
1476 for (i
= 0; i
< 16; i
++)
1477 params
[i
] = m
->m
[i
];
1481 m
= *(GLmatrix
**) p
;
1482 for (i
= 0; i
< 16; i
++)
1483 params
[i
] = m
->m
[transpose
[i
]];
1494 shift
= d
->type
- TYPE_BIT_0
;
1495 params
[0] = BOOLEAN_TO_FLOAT((*(GLbitfield
*) p
>> shift
) & 1);
1501 _mesa_GetIntegerv(GLenum pname
, GLint
*params
)
1503 const struct value_desc
*d
;
1509 d
= find_value("glGetIntegerv", pname
, &p
, &v
);
1514 params
[0] = d
->offset
;
1518 params
[3] = IROUND(((GLfloat
*) p
)[3]);
1520 params
[2] = IROUND(((GLfloat
*) p
)[2]);
1522 params
[1] = IROUND(((GLfloat
*) p
)[1]);
1524 params
[0] = IROUND(((GLfloat
*) p
)[0]);
1528 params
[3] = FLOAT_TO_INT(((GLfloat
*) p
)[3]);
1530 params
[2] = FLOAT_TO_INT(((GLfloat
*) p
)[2]);
1532 params
[1] = FLOAT_TO_INT(((GLfloat
*) p
)[1]);
1534 params
[0] = FLOAT_TO_INT(((GLfloat
*) p
)[0]);
1537 case TYPE_DOUBLEN_2
:
1538 params
[1] = FLOAT_TO_INT(((GLdouble
*) p
)[1]);
1540 params
[0] = FLOAT_TO_INT(((GLdouble
*) p
)[0]);
1544 params
[3] = ((GLint
*) p
)[3];
1546 params
[2] = ((GLint
*) p
)[2];
1549 params
[1] = ((GLint
*) p
)[1];
1552 params
[0] = ((GLint
*) p
)[0];
1556 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
1557 params
[i
] = v
.value_int_n
.ints
[i
];
1561 params
[0] = INT64_TO_INT(((GLint64
*) p
)[0]);
1565 params
[0] = BOOLEAN_TO_INT(*(GLboolean
*) p
);
1569 m
= *(GLmatrix
**) p
;
1570 for (i
= 0; i
< 16; i
++)
1571 params
[i
] = FLOAT_TO_INT(m
->m
[i
]);
1575 m
= *(GLmatrix
**) p
;
1576 for (i
= 0; i
< 16; i
++)
1577 params
[i
] = FLOAT_TO_INT(m
->m
[transpose
[i
]]);
1588 shift
= d
->type
- TYPE_BIT_0
;
1589 params
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
1595 _mesa_GetInteger64v(GLenum pname
, GLint64
*params
)
1597 const struct value_desc
*d
;
1603 d
= find_value("glGetInteger64v", pname
, &p
, &v
);
1608 params
[0] = d
->offset
;
1612 params
[3] = IROUND64(((GLfloat
*) p
)[3]);
1614 params
[2] = IROUND64(((GLfloat
*) p
)[2]);
1616 params
[1] = IROUND64(((GLfloat
*) p
)[1]);
1618 params
[0] = IROUND64(((GLfloat
*) p
)[0]);
1622 params
[3] = FLOAT_TO_INT64(((GLfloat
*) p
)[3]);
1624 params
[2] = FLOAT_TO_INT64(((GLfloat
*) p
)[2]);
1626 params
[1] = FLOAT_TO_INT64(((GLfloat
*) p
)[1]);
1628 params
[0] = FLOAT_TO_INT64(((GLfloat
*) p
)[0]);
1631 case TYPE_DOUBLEN_2
:
1632 params
[1] = FLOAT_TO_INT64(((GLdouble
*) p
)[1]);
1634 params
[0] = FLOAT_TO_INT64(((GLdouble
*) p
)[0]);
1638 params
[3] = ((GLint
*) p
)[3];
1640 params
[2] = ((GLint
*) p
)[2];
1643 params
[1] = ((GLint
*) p
)[1];
1646 params
[0] = ((GLint
*) p
)[0];
1650 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
1651 params
[i
] = INT_TO_BOOLEAN(v
.value_int_n
.ints
[i
]);
1655 params
[0] = ((GLint64
*) p
)[0];
1659 params
[0] = ((GLboolean
*) p
)[0];
1663 m
= *(GLmatrix
**) p
;
1664 for (i
= 0; i
< 16; i
++)
1665 params
[i
] = FLOAT_TO_INT64(m
->m
[i
]);
1669 m
= *(GLmatrix
**) p
;
1670 for (i
= 0; i
< 16; i
++)
1671 params
[i
] = FLOAT_TO_INT64(m
->m
[transpose
[i
]]);
1682 shift
= d
->type
- TYPE_BIT_0
;
1683 params
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
1689 _mesa_GetDoublev(GLenum pname
, GLdouble
*params
)
1691 const struct value_desc
*d
;
1697 d
= find_value("glGetDoublev", pname
, &p
, &v
);
1702 params
[0] = d
->offset
;
1707 params
[3] = ((GLfloat
*) p
)[3];
1710 params
[2] = ((GLfloat
*) p
)[2];
1713 params
[1] = ((GLfloat
*) p
)[1];
1716 params
[0] = ((GLfloat
*) p
)[0];
1719 case TYPE_DOUBLEN_2
:
1720 params
[1] = ((GLdouble
*) p
)[1];
1722 params
[0] = ((GLdouble
*) p
)[0];
1726 params
[3] = ((GLint
*) p
)[3];
1728 params
[2] = ((GLint
*) p
)[2];
1731 params
[1] = ((GLint
*) p
)[1];
1734 params
[0] = ((GLint
*) p
)[0];
1738 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
1739 params
[i
] = v
.value_int_n
.ints
[i
];
1743 params
[0] = (GLdouble
) (((GLint64
*) p
)[0]);
1747 params
[0] = *(GLboolean
*) p
;
1751 m
= *(GLmatrix
**) p
;
1752 for (i
= 0; i
< 16; i
++)
1753 params
[i
] = m
->m
[i
];
1757 m
= *(GLmatrix
**) p
;
1758 for (i
= 0; i
< 16; i
++)
1759 params
[i
] = m
->m
[transpose
[i
]];
1770 shift
= d
->type
- TYPE_BIT_0
;
1771 params
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
1776 static enum value_type
1777 find_value_indexed(const char *func
, GLenum pname
, GLuint index
, union value
*v
)
1779 GET_CURRENT_CONTEXT(ctx
);
1784 if (index
>= ctx
->Const
.MaxDrawBuffers
)
1786 if (!ctx
->Extensions
.EXT_draw_buffers2
)
1788 v
->value_int
= (ctx
->Color
.BlendEnabled
>> index
) & 1;
1793 case GL_BLEND_SRC_RGB
:
1794 if (index
>= ctx
->Const
.MaxDrawBuffers
)
1796 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
1798 v
->value_int
= ctx
->Color
.Blend
[index
].SrcRGB
;
1800 case GL_BLEND_SRC_ALPHA
:
1801 if (index
>= ctx
->Const
.MaxDrawBuffers
)
1803 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
1805 v
->value_int
= ctx
->Color
.Blend
[index
].SrcA
;
1809 case GL_BLEND_DST_RGB
:
1810 if (index
>= ctx
->Const
.MaxDrawBuffers
)
1812 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
1814 v
->value_int
= ctx
->Color
.Blend
[index
].DstRGB
;
1816 case GL_BLEND_DST_ALPHA
:
1817 if (index
>= ctx
->Const
.MaxDrawBuffers
)
1819 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
1821 v
->value_int
= ctx
->Color
.Blend
[index
].DstA
;
1823 case GL_BLEND_EQUATION_RGB
:
1824 if (index
>= ctx
->Const
.MaxDrawBuffers
)
1826 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
1828 v
->value_int
= ctx
->Color
.Blend
[index
].EquationRGB
;
1830 case GL_BLEND_EQUATION_ALPHA
:
1831 if (index
>= ctx
->Const
.MaxDrawBuffers
)
1833 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
1835 v
->value_int
= ctx
->Color
.Blend
[index
].EquationA
;
1838 case GL_COLOR_WRITEMASK
:
1839 if (index
>= ctx
->Const
.MaxDrawBuffers
)
1841 if (!ctx
->Extensions
.EXT_draw_buffers2
)
1843 v
->value_int_4
[0] = ctx
->Color
.ColorMask
[index
][RCOMP
] ? 1 : 0;
1844 v
->value_int_4
[1] = ctx
->Color
.ColorMask
[index
][GCOMP
] ? 1 : 0;
1845 v
->value_int_4
[2] = ctx
->Color
.ColorMask
[index
][BCOMP
] ? 1 : 0;
1846 v
->value_int_4
[3] = ctx
->Color
.ColorMask
[index
][ACOMP
] ? 1 : 0;
1849 case GL_SCISSOR_BOX
:
1850 if (index
>= ctx
->Const
.MaxViewports
)
1852 v
->value_int_4
[0] = ctx
->Scissor
.ScissorArray
[index
].X
;
1853 v
->value_int_4
[1] = ctx
->Scissor
.ScissorArray
[index
].Y
;
1854 v
->value_int_4
[2] = ctx
->Scissor
.ScissorArray
[index
].Width
;
1855 v
->value_int_4
[3] = ctx
->Scissor
.ScissorArray
[index
].Height
;
1859 if (index
>= ctx
->Const
.MaxViewports
)
1861 v
->value_float_4
[0] = ctx
->ViewportArray
[index
].X
;
1862 v
->value_float_4
[1] = ctx
->ViewportArray
[index
].Y
;
1863 v
->value_float_4
[2] = ctx
->ViewportArray
[index
].Width
;
1864 v
->value_float_4
[3] = ctx
->ViewportArray
[index
].Height
;
1865 return TYPE_FLOAT_4
;
1867 case GL_DEPTH_RANGE
:
1868 if (index
>= ctx
->Const
.MaxViewports
)
1870 v
->value_double_2
[0] = ctx
->ViewportArray
[index
].Near
;
1871 v
->value_double_2
[1] = ctx
->ViewportArray
[index
].Far
;
1872 return TYPE_DOUBLEN_2
;
1874 case GL_TRANSFORM_FEEDBACK_BUFFER_START
:
1875 if (index
>= ctx
->Const
.MaxTransformFeedbackBuffers
)
1877 if (!ctx
->Extensions
.EXT_transform_feedback
)
1879 v
->value_int64
= ctx
->TransformFeedback
.CurrentObject
->Offset
[index
];
1882 case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE
:
1883 if (index
>= ctx
->Const
.MaxTransformFeedbackBuffers
)
1885 if (!ctx
->Extensions
.EXT_transform_feedback
)
1888 = ctx
->TransformFeedback
.CurrentObject
->RequestedSize
[index
];
1891 case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING
:
1892 if (index
>= ctx
->Const
.MaxTransformFeedbackBuffers
)
1894 if (!ctx
->Extensions
.EXT_transform_feedback
)
1896 v
->value_int
= ctx
->TransformFeedback
.CurrentObject
->BufferNames
[index
];
1899 case GL_UNIFORM_BUFFER_BINDING
:
1900 if (index
>= ctx
->Const
.MaxUniformBufferBindings
)
1902 if (!ctx
->Extensions
.ARB_uniform_buffer_object
)
1904 v
->value_int
= ctx
->UniformBufferBindings
[index
].BufferObject
->Name
;
1907 case GL_UNIFORM_BUFFER_START
:
1908 if (index
>= ctx
->Const
.MaxUniformBufferBindings
)
1910 if (!ctx
->Extensions
.ARB_uniform_buffer_object
)
1912 v
->value_int
= ctx
->UniformBufferBindings
[index
].Offset
;
1915 case GL_UNIFORM_BUFFER_SIZE
:
1916 if (index
>= ctx
->Const
.MaxUniformBufferBindings
)
1918 if (!ctx
->Extensions
.ARB_uniform_buffer_object
)
1920 v
->value_int
= ctx
->UniformBufferBindings
[index
].Size
;
1923 /* ARB_texture_multisample / GL3.2 */
1924 case GL_SAMPLE_MASK_VALUE
:
1927 if (!ctx
->Extensions
.ARB_texture_multisample
)
1929 v
->value_int
= ctx
->Multisample
.SampleMaskValue
;
1932 case GL_ATOMIC_COUNTER_BUFFER_BINDING
:
1933 if (!ctx
->Extensions
.ARB_shader_atomic_counters
)
1935 if (index
>= ctx
->Const
.MaxAtomicBufferBindings
)
1937 v
->value_int
= ctx
->AtomicBufferBindings
[index
].BufferObject
->Name
;
1940 case GL_ATOMIC_COUNTER_BUFFER_START
:
1941 if (!ctx
->Extensions
.ARB_shader_atomic_counters
)
1943 if (index
>= ctx
->Const
.MaxAtomicBufferBindings
)
1945 v
->value_int64
= ctx
->AtomicBufferBindings
[index
].Offset
;
1948 case GL_ATOMIC_COUNTER_BUFFER_SIZE
:
1949 if (!ctx
->Extensions
.ARB_shader_atomic_counters
)
1951 if (index
>= ctx
->Const
.MaxAtomicBufferBindings
)
1953 v
->value_int64
= ctx
->AtomicBufferBindings
[index
].Size
;
1956 case GL_VERTEX_BINDING_DIVISOR
:
1957 if (!_mesa_is_desktop_gl(ctx
) || !ctx
->Extensions
.ARB_instanced_arrays
)
1959 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
)
1961 v
->value_int
= ctx
->Array
.VAO
->VertexBinding
[VERT_ATTRIB_GENERIC(index
)].InstanceDivisor
;
1964 case GL_VERTEX_BINDING_OFFSET
:
1965 if (!_mesa_is_desktop_gl(ctx
))
1967 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
)
1969 v
->value_int
= ctx
->Array
.VAO
->VertexBinding
[VERT_ATTRIB_GENERIC(index
)].Offset
;
1972 case GL_VERTEX_BINDING_STRIDE
:
1973 if (!_mesa_is_desktop_gl(ctx
))
1975 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
)
1977 v
->value_int
= ctx
->Array
.VAO
->VertexBinding
[VERT_ATTRIB_GENERIC(index
)].Stride
;
1980 /* ARB_shader_image_load_store */
1981 case GL_IMAGE_BINDING_NAME
: {
1982 struct gl_texture_object
*t
;
1984 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
1986 if (index
>= ctx
->Const
.MaxImageUnits
)
1989 t
= ctx
->ImageUnits
[index
].TexObj
;
1990 v
->value_int
= (t
? t
->Name
: 0);
1994 case GL_IMAGE_BINDING_LEVEL
:
1995 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
1997 if (index
>= ctx
->Const
.MaxImageUnits
)
2000 v
->value_int
= ctx
->ImageUnits
[index
].Level
;
2003 case GL_IMAGE_BINDING_LAYERED
:
2004 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
2006 if (index
>= ctx
->Const
.MaxImageUnits
)
2009 v
->value_int
= ctx
->ImageUnits
[index
].Layered
;
2012 case GL_IMAGE_BINDING_LAYER
:
2013 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
2015 if (index
>= ctx
->Const
.MaxImageUnits
)
2018 v
->value_int
= ctx
->ImageUnits
[index
].Layer
;
2021 case GL_IMAGE_BINDING_ACCESS
:
2022 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
2024 if (index
>= ctx
->Const
.MaxImageUnits
)
2027 v
->value_int
= ctx
->ImageUnits
[index
].Access
;
2030 case GL_IMAGE_BINDING_FORMAT
:
2031 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
2033 if (index
>= ctx
->Const
.MaxImageUnits
)
2036 v
->value_int
= ctx
->ImageUnits
[index
].Format
;
2039 case GL_MAX_COMPUTE_WORK_GROUP_COUNT
:
2040 if (!_mesa_is_desktop_gl(ctx
) || !ctx
->Extensions
.ARB_compute_shader
)
2044 v
->value_int
= ctx
->Const
.MaxComputeWorkGroupCount
[index
];
2047 case GL_MAX_COMPUTE_WORK_GROUP_SIZE
:
2048 if (!_mesa_is_desktop_gl(ctx
) || !ctx
->Extensions
.ARB_compute_shader
)
2052 v
->value_int
= ctx
->Const
.MaxComputeWorkGroupSize
[index
];
2057 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(pname=%s)", func
,
2058 _mesa_enum_to_string(pname
));
2059 return TYPE_INVALID
;
2061 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(pname=%s)", func
,
2062 _mesa_enum_to_string(pname
));
2063 return TYPE_INVALID
;
2067 _mesa_GetBooleani_v( GLenum pname
, GLuint index
, GLboolean
*params
)
2070 enum value_type type
=
2071 find_value_indexed("glGetBooleani_v", pname
, index
, &v
);
2075 params
[0] = INT_TO_BOOLEAN(v
.value_int
);
2078 params
[0] = INT_TO_BOOLEAN(v
.value_int_4
[0]);
2079 params
[1] = INT_TO_BOOLEAN(v
.value_int_4
[1]);
2080 params
[2] = INT_TO_BOOLEAN(v
.value_int_4
[2]);
2081 params
[3] = INT_TO_BOOLEAN(v
.value_int_4
[3]);
2084 params
[0] = INT64_TO_BOOLEAN(v
.value_int64
);
2087 ; /* nothing - GL error was recorded */
2092 _mesa_GetIntegeri_v( GLenum pname
, GLuint index
, GLint
*params
)
2095 enum value_type type
=
2096 find_value_indexed("glGetIntegeri_v", pname
, index
, &v
);
2101 params
[3] = IROUND(v
.value_float_4
[3]);
2104 params
[2] = IROUND(v
.value_float_4
[2]);
2107 params
[1] = IROUND(v
.value_float_4
[1]);
2110 params
[0] = IROUND(v
.value_float_4
[0]);
2113 case TYPE_DOUBLEN_2
:
2114 params
[1] = IROUND(v
.value_double_2
[1]);
2116 params
[0] = IROUND(v
.value_double_2
[0]);
2120 params
[0] = v
.value_int
;
2123 params
[0] = v
.value_int_4
[0];
2124 params
[1] = v
.value_int_4
[1];
2125 params
[2] = v
.value_int_4
[2];
2126 params
[3] = v
.value_int_4
[3];
2129 params
[0] = INT64_TO_INT(v
.value_int64
);
2132 ; /* nothing - GL error was recorded */
2137 _mesa_GetInteger64i_v( GLenum pname
, GLuint index
, GLint64
*params
)
2140 enum value_type type
=
2141 find_value_indexed("glGetInteger64i_v", pname
, index
, &v
);
2145 params
[0] = v
.value_int
;
2148 params
[0] = v
.value_int_4
[0];
2149 params
[1] = v
.value_int_4
[1];
2150 params
[2] = v
.value_int_4
[2];
2151 params
[3] = v
.value_int_4
[3];
2154 params
[0] = v
.value_int64
;
2157 ; /* nothing - GL error was recorded */
2162 _mesa_GetFloati_v(GLenum pname
, GLuint index
, GLfloat
*params
)
2167 enum value_type type
=
2168 find_value_indexed("glGetFloati_v", pname
, index
, &v
);
2173 params
[3] = v
.value_float_4
[3];
2176 params
[2] = v
.value_float_4
[2];
2179 params
[1] = v
.value_float_4
[1];
2182 params
[0] = v
.value_float_4
[0];
2185 case TYPE_DOUBLEN_2
:
2186 params
[1] = (GLfloat
) v
.value_double_2
[1];
2188 params
[0] = (GLfloat
) v
.value_double_2
[0];
2192 params
[3] = (GLfloat
) v
.value_int_4
[3];
2194 params
[2] = (GLfloat
) v
.value_int_4
[2];
2197 params
[1] = (GLfloat
) v
.value_int_4
[1];
2200 params
[0] = (GLfloat
) v
.value_int_4
[0];
2204 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
2205 params
[i
] = INT_TO_FLOAT(v
.value_int_n
.ints
[i
]);
2209 params
[0] = (GLfloat
) v
.value_int64
;
2213 params
[0] = BOOLEAN_TO_FLOAT(v
.value_bool
);
2217 m
= *(GLmatrix
**) &v
;
2218 for (i
= 0; i
< 16; i
++)
2219 params
[i
] = m
->m
[i
];
2223 m
= *(GLmatrix
**) &v
;
2224 for (i
= 0; i
< 16; i
++)
2225 params
[i
] = m
->m
[transpose
[i
]];
2234 _mesa_GetDoublei_v(GLenum pname
, GLuint index
, GLdouble
*params
)
2239 enum value_type type
=
2240 find_value_indexed("glGetDoublei_v", pname
, index
, &v
);
2245 params
[3] = (GLdouble
) v
.value_float_4
[3];
2248 params
[2] = (GLdouble
) v
.value_float_4
[2];
2251 params
[1] = (GLdouble
) v
.value_float_4
[1];
2254 params
[0] = (GLdouble
) v
.value_float_4
[0];
2257 case TYPE_DOUBLEN_2
:
2258 params
[1] = v
.value_double_2
[1];
2260 params
[0] = v
.value_double_2
[0];
2264 params
[3] = (GLdouble
) v
.value_int_4
[3];
2266 params
[2] = (GLdouble
) v
.value_int_4
[2];
2269 params
[1] = (GLdouble
) v
.value_int_4
[1];
2272 params
[0] = (GLdouble
) v
.value_int_4
[0];
2276 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
2277 params
[i
] = (GLdouble
) INT_TO_FLOAT(v
.value_int_n
.ints
[i
]);
2281 params
[0] = (GLdouble
) v
.value_int64
;
2285 params
[0] = (GLdouble
) BOOLEAN_TO_FLOAT(v
.value_bool
);
2289 m
= *(GLmatrix
**) &v
;
2290 for (i
= 0; i
< 16; i
++)
2291 params
[i
] = (GLdouble
) m
->m
[i
];
2295 m
= *(GLmatrix
**) &v
;
2296 for (i
= 0; i
< 16; i
++)
2297 params
[i
] = (GLdouble
) m
->m
[transpose
[i
]];
2306 _mesa_GetFixedv(GLenum pname
, GLfixed
*params
)
2308 const struct value_desc
*d
;
2314 d
= find_value("glGetDoublev", pname
, &p
, &v
);
2319 params
[0] = INT_TO_FIXED(d
->offset
);
2324 params
[3] = FLOAT_TO_FIXED(((GLfloat
*) p
)[3]);
2327 params
[2] = FLOAT_TO_FIXED(((GLfloat
*) p
)[2]);
2330 params
[1] = FLOAT_TO_FIXED(((GLfloat
*) p
)[1]);
2333 params
[0] = FLOAT_TO_FIXED(((GLfloat
*) p
)[0]);
2336 case TYPE_DOUBLEN_2
:
2337 params
[1] = FLOAT_TO_FIXED(((GLdouble
*) p
)[1]);
2339 params
[0] = FLOAT_TO_FIXED(((GLdouble
*) p
)[0]);
2343 params
[3] = INT_TO_FIXED(((GLint
*) p
)[3]);
2345 params
[2] = INT_TO_FIXED(((GLint
*) p
)[2]);
2348 params
[1] = INT_TO_FIXED(((GLint
*) p
)[1]);
2351 params
[0] = INT_TO_FIXED(((GLint
*) p
)[0]);
2355 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
2356 params
[i
] = INT_TO_FIXED(v
.value_int_n
.ints
[i
]);
2360 params
[0] = ((GLint64
*) p
)[0];
2364 params
[0] = BOOLEAN_TO_FIXED(((GLboolean
*) p
)[0]);
2368 m
= *(GLmatrix
**) p
;
2369 for (i
= 0; i
< 16; i
++)
2370 params
[i
] = FLOAT_TO_FIXED(m
->m
[i
]);
2374 m
= *(GLmatrix
**) p
;
2375 for (i
= 0; i
< 16; i
++)
2376 params
[i
] = FLOAT_TO_FIXED(m
->m
[transpose
[i
]]);
2387 shift
= d
->type
- TYPE_BIT_0
;
2388 params
[0] = BOOLEAN_TO_FIXED((*(GLbitfield
*) p
>> shift
) & 1);