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 EXTRA_EXT(ARB_texture_cube_map
);
383 EXTRA_EXT(EXT_texture_array
);
384 EXTRA_EXT(NV_fog_distance
);
385 EXTRA_EXT(EXT_texture_filter_anisotropic
);
386 EXTRA_EXT(NV_point_sprite
);
387 EXTRA_EXT(NV_texture_rectangle
);
388 EXTRA_EXT(EXT_stencil_two_side
);
389 EXTRA_EXT(EXT_depth_bounds_test
);
390 EXTRA_EXT(ARB_depth_clamp
);
391 EXTRA_EXT(ATI_fragment_shader
);
392 EXTRA_EXT(EXT_provoking_vertex
);
393 EXTRA_EXT(ARB_fragment_shader
);
394 EXTRA_EXT(ARB_fragment_program
);
395 EXTRA_EXT2(ARB_framebuffer_object
, EXT_framebuffer_multisample
);
396 EXTRA_EXT(ARB_seamless_cube_map
);
398 EXTRA_EXT(ARB_vertex_shader
);
399 EXTRA_EXT(EXT_transform_feedback
);
400 EXTRA_EXT(ARB_transform_feedback3
);
401 EXTRA_EXT(EXT_pixel_buffer_object
);
402 EXTRA_EXT(ARB_vertex_program
);
403 EXTRA_EXT2(NV_point_sprite
, ARB_point_sprite
);
404 EXTRA_EXT2(ARB_vertex_program
, ARB_fragment_program
);
405 EXTRA_EXT(ARB_geometry_shader4
);
406 EXTRA_EXT(ARB_color_buffer_float
);
407 EXTRA_EXT(EXT_framebuffer_sRGB
);
408 EXTRA_EXT(OES_EGL_image_external
);
409 EXTRA_EXT(ARB_blend_func_extended
);
410 EXTRA_EXT(ARB_uniform_buffer_object
);
411 EXTRA_EXT(ARB_timer_query
);
412 EXTRA_EXT(ARB_texture_cube_map_array
);
413 EXTRA_EXT(ARB_texture_buffer_range
);
414 EXTRA_EXT(ARB_texture_multisample
);
415 EXTRA_EXT(ARB_texture_gather
);
416 EXTRA_EXT(ARB_shader_atomic_counters
);
417 EXTRA_EXT(ARB_draw_indirect
);
418 EXTRA_EXT(ARB_shader_image_load_store
);
419 EXTRA_EXT(ARB_viewport_array
);
420 EXTRA_EXT(ARB_compute_shader
);
421 EXTRA_EXT(ARB_gpu_shader5
);
422 EXTRA_EXT2(ARB_transform_feedback3
, ARB_gpu_shader5
);
423 EXTRA_EXT(INTEL_performance_query
);
424 EXTRA_EXT(ARB_explicit_uniform_location
);
425 EXTRA_EXT(ARB_clip_control
);
426 EXTRA_EXT(EXT_polygon_offset_clamp
);
427 EXTRA_EXT(ARB_framebuffer_no_attachments
);
428 EXTRA_EXT(ARB_tessellation_shader
);
429 EXTRA_EXT(ARB_shader_subroutine
);
432 extra_ARB_color_buffer_float_or_glcore
[] = {
433 EXT(ARB_color_buffer_float
),
439 extra_NV_primitive_restart
[] = {
440 EXT(NV_primitive_restart
),
444 static const int extra_version_30
[] = { EXTRA_VERSION_30
, EXTRA_END
};
445 static const int extra_version_31
[] = { EXTRA_VERSION_31
, EXTRA_END
};
446 static const int extra_version_32
[] = { EXTRA_VERSION_32
, EXTRA_END
};
447 static const int extra_version_40
[] = { EXTRA_VERSION_40
, EXTRA_END
};
449 static const int extra_gl30_es3
[] = {
455 static const int extra_gl32_es3
[] = {
461 static const int extra_gl32_ARB_geometry_shader4
[] = {
463 EXT(ARB_geometry_shader4
),
467 static const int extra_gl40_ARB_sample_shading
[] = {
469 EXT(ARB_sample_shading
),
474 extra_ARB_vertex_program_api_es2
[] = {
475 EXT(ARB_vertex_program
),
480 /* The ReadBuffer get token is valid under either full GL or under
481 * GLES2 if the NV_read_buffer extension is available. */
483 extra_NV_read_buffer_api_gl
[] = {
489 static const int extra_core_ARB_color_buffer_float_and_new_buffers
[] = {
491 EXT(ARB_color_buffer_float
),
496 /* This is the big table describing all the enums we accept in
497 * glGet*v(). The table is partitioned into six parts: enums
498 * understood by all GL APIs (OpenGL, GLES and GLES2), enums shared
499 * between OpenGL and GLES, enums exclusive to GLES, etc for the
500 * remaining combinations. To look up the enums valid in a given API
501 * we will use a hash table specific to that API. These tables are in
502 * turn generated at build time and included through get_hash.h.
505 #include "get_hash.h"
507 /* All we need now is a way to look up the value struct from the enum.
508 * The code generated by gcc for the old generated big switch
509 * statement is a big, balanced, open coded if/else tree, essentially
510 * an unrolled binary search. It would be natural to sort the new
511 * enum table and use bsearch(), but we will use a read-only hash
512 * table instead. bsearch() has a nice guaranteed worst case
513 * performance, but we're also guaranteed to hit that worst case
514 * (log2(n) iterations) for about half the enums. Instead, using an
515 * open addressing hash table, we can find the enum on the first try
516 * for 80% of the enums, 1 collision for 10% and never more than 5
517 * collisions for any enum (typical numbers). And the code is very
518 * simple, even though it feels a little magic. */
522 print_table_stats(int api
)
524 int i
, j
, collisions
[11], count
, hash
, mask
;
525 const struct value_desc
*d
;
526 const char *api_names
[] = {
527 [API_OPENGL_COMPAT
] = "GL",
528 [API_OPENGL_CORE
] = "GL_CORE",
529 [API_OPENGLES
] = "GLES",
530 [API_OPENGLES2
] = "GLES2",
532 const char *api_name
;
534 api_name
= api
< ARRAY_SIZE(api_names
) ? api_names
[api
] : "N/A";
536 mask
= ARRAY_SIZE(table(api
)) - 1;
537 memset(collisions
, 0, sizeof collisions
);
539 for (i
= 0; i
< ARRAY_SIZE(table(api
)); i
++) {
543 d
= &values
[table(api
)[i
]];
544 hash
= (d
->pname
* prime_factor
);
547 if (values
[table(api
)[hash
& mask
]].pname
== d
->pname
)
559 printf("number of enums for %s: %d (total %ld)\n",
560 api_name
, count
, ARRAY_SIZE(values
));
561 for (i
= 0; i
< ARRAY_SIZE(collisions
) - 1; i
++)
562 if (collisions
[i
] > 0)
563 printf(" %d enums with %d %scollisions\n",
564 collisions
[i
], i
, i
== 10 ? "or more " : "");
569 * Initialize the enum hash for a given API
571 * This is called from one_time_init() to insert the enum values that
572 * are valid for the API in question into the enum hash table.
574 * \param the current context, for determining the API in question
576 void _mesa_init_get_hash(struct gl_context
*ctx
)
579 print_table_stats(ctx
->API
);
586 * Handle irregular enums
588 * Some values don't conform to the "well-known type at context
589 * pointer + offset" pattern, so we have this function to catch all
590 * the corner cases. Typically, it's a computed value or a one-off
591 * pointer to a custom struct or something.
593 * In this case we can't return a pointer to the value, so we'll have
594 * to use the temporary variable 'v' declared back in the calling
595 * glGet*v() function to store the result.
597 * \param ctx the current context
598 * \param d the struct value_desc that describes the enum
599 * \param v pointer to the tmp declared in the calling glGet*v() function
602 find_custom_value(struct gl_context
*ctx
, const struct value_desc
*d
, union value
*v
)
604 struct gl_buffer_object
**buffer_obj
;
605 struct gl_vertex_attrib_array
*array
;
609 case GL_MAJOR_VERSION
:
610 v
->value_int
= ctx
->Version
/ 10;
612 case GL_MINOR_VERSION
:
613 v
->value_int
= ctx
->Version
% 10;
619 case GL_TEXTURE_CUBE_MAP_ARB
:
620 case GL_TEXTURE_RECTANGLE_NV
:
621 case GL_TEXTURE_EXTERNAL_OES
:
622 v
->value_bool
= _mesa_IsEnabled(d
->pname
);
625 case GL_LINE_STIPPLE_PATTERN
:
626 /* This is the only GLushort, special case it here by promoting
627 * to an int rather than introducing a new type. */
628 v
->value_int
= ctx
->Line
.StipplePattern
;
631 case GL_CURRENT_RASTER_TEXTURE_COORDS
:
632 unit
= ctx
->Texture
.CurrentUnit
;
633 v
->value_float_4
[0] = ctx
->Current
.RasterTexCoords
[unit
][0];
634 v
->value_float_4
[1] = ctx
->Current
.RasterTexCoords
[unit
][1];
635 v
->value_float_4
[2] = ctx
->Current
.RasterTexCoords
[unit
][2];
636 v
->value_float_4
[3] = ctx
->Current
.RasterTexCoords
[unit
][3];
639 case GL_CURRENT_TEXTURE_COORDS
:
640 unit
= ctx
->Texture
.CurrentUnit
;
641 v
->value_float_4
[0] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
][0];
642 v
->value_float_4
[1] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
][1];
643 v
->value_float_4
[2] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
][2];
644 v
->value_float_4
[3] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
][3];
647 case GL_COLOR_WRITEMASK
:
648 v
->value_int_4
[0] = ctx
->Color
.ColorMask
[0][RCOMP
] ? 1 : 0;
649 v
->value_int_4
[1] = ctx
->Color
.ColorMask
[0][GCOMP
] ? 1 : 0;
650 v
->value_int_4
[2] = ctx
->Color
.ColorMask
[0][BCOMP
] ? 1 : 0;
651 v
->value_int_4
[3] = ctx
->Color
.ColorMask
[0][ACOMP
] ? 1 : 0;
655 v
->value_bool
= ctx
->Current
.Attrib
[VERT_ATTRIB_EDGEFLAG
][0] == 1.0;
659 v
->value_enum
= ctx
->ReadBuffer
->ColorReadBuffer
;
662 case GL_MAP2_GRID_DOMAIN
:
663 v
->value_float_4
[0] = ctx
->Eval
.MapGrid2u1
;
664 v
->value_float_4
[1] = ctx
->Eval
.MapGrid2u2
;
665 v
->value_float_4
[2] = ctx
->Eval
.MapGrid2v1
;
666 v
->value_float_4
[3] = ctx
->Eval
.MapGrid2v2
;
669 case GL_TEXTURE_STACK_DEPTH
:
670 unit
= ctx
->Texture
.CurrentUnit
;
671 v
->value_int
= ctx
->TextureMatrixStack
[unit
].Depth
+ 1;
673 case GL_TEXTURE_MATRIX
:
674 unit
= ctx
->Texture
.CurrentUnit
;
675 v
->value_matrix
= ctx
->TextureMatrixStack
[unit
].Top
;
678 case GL_TEXTURE_COORD_ARRAY
:
679 case GL_TEXTURE_COORD_ARRAY_SIZE
:
680 case GL_TEXTURE_COORD_ARRAY_TYPE
:
681 case GL_TEXTURE_COORD_ARRAY_STRIDE
:
682 array
= &ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_TEX(ctx
->Array
.ActiveTexture
)];
683 v
->value_int
= *(GLuint
*) ((char *) array
+ d
->offset
);
686 case GL_ACTIVE_TEXTURE_ARB
:
687 v
->value_int
= GL_TEXTURE0_ARB
+ ctx
->Texture
.CurrentUnit
;
689 case GL_CLIENT_ACTIVE_TEXTURE_ARB
:
690 v
->value_int
= GL_TEXTURE0_ARB
+ ctx
->Array
.ActiveTexture
;
693 case GL_MODELVIEW_STACK_DEPTH
:
694 case GL_PROJECTION_STACK_DEPTH
:
695 v
->value_int
= *(GLint
*) ((char *) ctx
+ d
->offset
) + 1;
698 case GL_MAX_TEXTURE_SIZE
:
699 case GL_MAX_3D_TEXTURE_SIZE
:
700 case GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB
:
701 p
= (GLuint
*) ((char *) ctx
+ d
->offset
);
702 v
->value_int
= 1 << (*p
- 1);
706 v
->value_int_4
[0] = ctx
->Scissor
.ScissorArray
[0].X
;
707 v
->value_int_4
[1] = ctx
->Scissor
.ScissorArray
[0].Y
;
708 v
->value_int_4
[2] = ctx
->Scissor
.ScissorArray
[0].Width
;
709 v
->value_int_4
[3] = ctx
->Scissor
.ScissorArray
[0].Height
;
712 case GL_SCISSOR_TEST
:
713 v
->value_bool
= ctx
->Scissor
.EnableFlags
& 1;
718 ctx
->ListState
.CurrentList
? ctx
->ListState
.CurrentList
->Name
: 0;
721 if (!ctx
->CompileFlag
)
723 else if (ctx
->ExecuteFlag
)
724 v
->value_enum
= GL_COMPILE_AND_EXECUTE
;
726 v
->value_enum
= GL_COMPILE
;
730 v
->value_float_4
[0] = ctx
->ViewportArray
[0].X
;
731 v
->value_float_4
[1] = ctx
->ViewportArray
[0].Y
;
732 v
->value_float_4
[2] = ctx
->ViewportArray
[0].Width
;
733 v
->value_float_4
[3] = ctx
->ViewportArray
[0].Height
;
737 v
->value_double_2
[0] = ctx
->ViewportArray
[0].Near
;
738 v
->value_double_2
[1] = ctx
->ViewportArray
[0].Far
;
741 case GL_ACTIVE_STENCIL_FACE_EXT
:
742 v
->value_enum
= ctx
->Stencil
.ActiveFace
? GL_BACK
: GL_FRONT
;
745 case GL_STENCIL_FAIL
:
746 v
->value_enum
= ctx
->Stencil
.FailFunc
[ctx
->Stencil
.ActiveFace
];
748 case GL_STENCIL_FUNC
:
749 v
->value_enum
= ctx
->Stencil
.Function
[ctx
->Stencil
.ActiveFace
];
751 case GL_STENCIL_PASS_DEPTH_FAIL
:
752 v
->value_enum
= ctx
->Stencil
.ZFailFunc
[ctx
->Stencil
.ActiveFace
];
754 case GL_STENCIL_PASS_DEPTH_PASS
:
755 v
->value_enum
= ctx
->Stencil
.ZPassFunc
[ctx
->Stencil
.ActiveFace
];
758 v
->value_int
= _mesa_get_stencil_ref(ctx
, ctx
->Stencil
.ActiveFace
);
760 case GL_STENCIL_BACK_REF
:
761 v
->value_int
= _mesa_get_stencil_ref(ctx
, 1);
763 case GL_STENCIL_VALUE_MASK
:
764 v
->value_int
= ctx
->Stencil
.ValueMask
[ctx
->Stencil
.ActiveFace
];
766 case GL_STENCIL_WRITEMASK
:
767 v
->value_int
= ctx
->Stencil
.WriteMask
[ctx
->Stencil
.ActiveFace
];
770 case GL_NUM_EXTENSIONS
:
771 v
->value_int
= _mesa_get_extension_count(ctx
);
774 case GL_IMPLEMENTATION_COLOR_READ_TYPE_OES
:
775 v
->value_int
= _mesa_get_color_read_type(ctx
);
777 case GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES
:
778 v
->value_int
= _mesa_get_color_read_format(ctx
);
781 case GL_CURRENT_MATRIX_STACK_DEPTH_ARB
:
782 v
->value_int
= ctx
->CurrentStack
->Depth
+ 1;
784 case GL_CURRENT_MATRIX_ARB
:
785 case GL_TRANSPOSE_CURRENT_MATRIX_ARB
:
786 v
->value_matrix
= ctx
->CurrentStack
->Top
;
789 case GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB
:
790 v
->value_int
= _mesa_get_compressed_formats(ctx
, NULL
);
792 case GL_COMPRESSED_TEXTURE_FORMATS_ARB
:
794 _mesa_get_compressed_formats(ctx
, v
->value_int_n
.ints
);
795 assert(v
->value_int_n
.n
<= (int) ARRAY_SIZE(v
->value_int_n
.ints
));
798 case GL_MAX_VARYING_FLOATS_ARB
:
799 v
->value_int
= ctx
->Const
.MaxVarying
* 4;
802 /* Various object names */
804 case GL_TEXTURE_BINDING_1D
:
805 case GL_TEXTURE_BINDING_2D
:
806 case GL_TEXTURE_BINDING_3D
:
807 case GL_TEXTURE_BINDING_1D_ARRAY_EXT
:
808 case GL_TEXTURE_BINDING_2D_ARRAY_EXT
:
809 case GL_TEXTURE_BINDING_CUBE_MAP_ARB
:
810 case GL_TEXTURE_BINDING_RECTANGLE_NV
:
811 case GL_TEXTURE_BINDING_EXTERNAL_OES
:
812 case GL_TEXTURE_BINDING_CUBE_MAP_ARRAY
:
813 case GL_TEXTURE_BINDING_2D_MULTISAMPLE
:
814 case GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY
:
815 unit
= ctx
->Texture
.CurrentUnit
;
817 ctx
->Texture
.Unit
[unit
].CurrentTex
[d
->offset
]->Name
;
820 /* GL_EXT_packed_float */
821 case GL_RGBA_SIGNED_COMPONENTS_EXT
:
823 /* Note: we only check the 0th color attachment. */
824 const struct gl_renderbuffer
*rb
=
825 ctx
->DrawBuffer
->_ColorDrawBuffers
[0];
826 if (rb
&& _mesa_is_format_signed(rb
->Format
)) {
827 /* Issue 17 of GL_EXT_packed_float: If a component (such as
828 * alpha) has zero bits, the component should not be considered
829 * signed and so the bit for the respective component should be
833 _mesa_get_format_bits(rb
->Format
, GL_RED_BITS
);
835 _mesa_get_format_bits(rb
->Format
, GL_GREEN_BITS
);
837 _mesa_get_format_bits(rb
->Format
, GL_BLUE_BITS
);
839 _mesa_get_format_bits(rb
->Format
, GL_ALPHA_BITS
);
841 _mesa_get_format_bits(rb
->Format
, GL_TEXTURE_LUMINANCE_SIZE
);
843 _mesa_get_format_bits(rb
->Format
, GL_TEXTURE_INTENSITY_SIZE
);
845 v
->value_int_4
[0] = r_bits
+ l_bits
+ i_bits
> 0;
846 v
->value_int_4
[1] = g_bits
+ l_bits
+ i_bits
> 0;
847 v
->value_int_4
[2] = b_bits
+ l_bits
+ i_bits
> 0;
848 v
->value_int_4
[3] = a_bits
+ i_bits
> 0;
854 v
->value_int_4
[3] = 0;
859 /* GL_ARB_vertex_buffer_object */
860 case GL_VERTEX_ARRAY_BUFFER_BINDING_ARB
:
861 case GL_NORMAL_ARRAY_BUFFER_BINDING_ARB
:
862 case GL_COLOR_ARRAY_BUFFER_BINDING_ARB
:
863 case GL_INDEX_ARRAY_BUFFER_BINDING_ARB
:
864 case GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB
:
865 case GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB
:
866 case GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB
:
867 buffer_obj
= (struct gl_buffer_object
**)
868 ((char *) ctx
->Array
.VAO
+ d
->offset
);
869 v
->value_int
= (*buffer_obj
)->Name
;
871 case GL_ARRAY_BUFFER_BINDING_ARB
:
872 v
->value_int
= ctx
->Array
.ArrayBufferObj
->Name
;
874 case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB
:
876 ctx
->Array
.VAO
->VertexBinding
[VERT_ATTRIB_TEX(ctx
->Array
.ActiveTexture
)].BufferObj
->Name
;
878 case GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB
:
879 v
->value_int
= ctx
->Array
.VAO
->IndexBufferObj
->Name
;
882 /* ARB_vertex_array_bgra */
883 case GL_COLOR_ARRAY_SIZE
:
884 array
= &ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_COLOR0
];
885 v
->value_int
= array
->Format
== GL_BGRA
? GL_BGRA
: array
->Size
;
887 case GL_SECONDARY_COLOR_ARRAY_SIZE
:
888 array
= &ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_COLOR1
];
889 v
->value_int
= array
->Format
== GL_BGRA
? GL_BGRA
: array
->Size
;
892 /* ARB_copy_buffer */
893 case GL_COPY_READ_BUFFER
:
894 v
->value_int
= ctx
->CopyReadBuffer
->Name
;
896 case GL_COPY_WRITE_BUFFER
:
897 v
->value_int
= ctx
->CopyWriteBuffer
->Name
;
900 case GL_PIXEL_PACK_BUFFER_BINDING_EXT
:
901 v
->value_int
= ctx
->Pack
.BufferObj
->Name
;
903 case GL_PIXEL_UNPACK_BUFFER_BINDING_EXT
:
904 v
->value_int
= ctx
->Unpack
.BufferObj
->Name
;
906 case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING
:
907 v
->value_int
= ctx
->TransformFeedback
.CurrentBuffer
->Name
;
909 case GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED
:
910 v
->value_int
= ctx
->TransformFeedback
.CurrentObject
->Paused
;
912 case GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE
:
913 v
->value_int
= ctx
->TransformFeedback
.CurrentObject
->Active
;
915 case GL_TRANSFORM_FEEDBACK_BINDING
:
916 v
->value_int
= ctx
->TransformFeedback
.CurrentObject
->Name
;
918 case GL_CURRENT_PROGRAM
:
919 /* The Changelog of the ARB_separate_shader_objects spec says:
921 * 24 25 Jul 2011 pbrown Remove the language erroneously deleting
922 * CURRENT_PROGRAM. In the EXT extension, this
923 * token was aliased to ACTIVE_PROGRAM_EXT, and
924 * was used to indicate the last program set by
925 * either ActiveProgramEXT or UseProgram. In
926 * the ARB extension, the SSO active programs
927 * are now program pipeline object state and
928 * CURRENT_PROGRAM should still be used to query
929 * the last program set by UseProgram (bug 7822).
932 ctx
->Shader
.ActiveProgram
? ctx
->Shader
.ActiveProgram
->Name
: 0;
934 case GL_READ_FRAMEBUFFER_BINDING_EXT
:
935 v
->value_int
= ctx
->ReadBuffer
->Name
;
937 case GL_RENDERBUFFER_BINDING_EXT
:
939 ctx
->CurrentRenderbuffer
? ctx
->CurrentRenderbuffer
->Name
: 0;
941 case GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES
:
942 v
->value_int
= ctx
->Array
.VAO
->VertexBinding
[VERT_ATTRIB_POINT_SIZE
].BufferObj
->Name
;
946 if (_mesa_get_clamp_fragment_color(ctx
, ctx
->DrawBuffer
))
947 COPY_4FV(v
->value_float_4
, ctx
->Fog
.Color
);
949 COPY_4FV(v
->value_float_4
, ctx
->Fog
.ColorUnclamped
);
951 case GL_COLOR_CLEAR_VALUE
:
952 if (_mesa_get_clamp_fragment_color(ctx
, ctx
->DrawBuffer
)) {
953 v
->value_float_4
[0] = CLAMP(ctx
->Color
.ClearColor
.f
[0], 0.0F
, 1.0F
);
954 v
->value_float_4
[1] = CLAMP(ctx
->Color
.ClearColor
.f
[1], 0.0F
, 1.0F
);
955 v
->value_float_4
[2] = CLAMP(ctx
->Color
.ClearColor
.f
[2], 0.0F
, 1.0F
);
956 v
->value_float_4
[3] = CLAMP(ctx
->Color
.ClearColor
.f
[3], 0.0F
, 1.0F
);
958 COPY_4FV(v
->value_float_4
, ctx
->Color
.ClearColor
.f
);
960 case GL_BLEND_COLOR_EXT
:
961 if (_mesa_get_clamp_fragment_color(ctx
, ctx
->DrawBuffer
))
962 COPY_4FV(v
->value_float_4
, ctx
->Color
.BlendColor
);
964 COPY_4FV(v
->value_float_4
, ctx
->Color
.BlendColorUnclamped
);
966 case GL_ALPHA_TEST_REF
:
967 if (_mesa_get_clamp_fragment_color(ctx
, ctx
->DrawBuffer
))
968 v
->value_float
= ctx
->Color
.AlphaRef
;
970 v
->value_float
= ctx
->Color
.AlphaRefUnclamped
;
972 case GL_MAX_VERTEX_UNIFORM_VECTORS
:
973 v
->value_int
= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxUniformComponents
/ 4;
976 case GL_MAX_FRAGMENT_UNIFORM_VECTORS
:
977 v
->value_int
= ctx
->Const
.Program
[MESA_SHADER_FRAGMENT
].MaxUniformComponents
/ 4;
980 /* GL_ARB_texture_buffer_object */
981 case GL_TEXTURE_BUFFER_ARB
:
982 v
->value_int
= ctx
->Texture
.BufferObject
->Name
;
984 case GL_TEXTURE_BINDING_BUFFER_ARB
:
985 unit
= ctx
->Texture
.CurrentUnit
;
987 ctx
->Texture
.Unit
[unit
].CurrentTex
[TEXTURE_BUFFER_INDEX
]->Name
;
989 case GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB
:
991 struct gl_buffer_object
*buf
=
992 ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
]
993 .CurrentTex
[TEXTURE_BUFFER_INDEX
]->BufferObject
;
994 v
->value_int
= buf
? buf
->Name
: 0;
997 case GL_TEXTURE_BUFFER_FORMAT_ARB
:
998 v
->value_int
= ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
]
999 .CurrentTex
[TEXTURE_BUFFER_INDEX
]->BufferObjectFormat
;
1002 /* GL_ARB_sampler_objects */
1003 case GL_SAMPLER_BINDING
:
1005 struct gl_sampler_object
*samp
=
1006 ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
].Sampler
;
1009 * The sampler object may have been deleted on another context,
1010 * so we try to lookup the sampler object before returning its Name.
1012 if (samp
&& _mesa_lookup_samplerobj(ctx
, samp
->Name
)) {
1013 v
->value_int
= samp
->Name
;
1019 /* GL_ARB_uniform_buffer_object */
1020 case GL_UNIFORM_BUFFER_BINDING
:
1021 v
->value_int
= ctx
->UniformBuffer
->Name
;
1023 /* GL_ARB_timer_query */
1025 if (ctx
->Driver
.GetTimestamp
) {
1026 v
->value_int64
= ctx
->Driver
.GetTimestamp(ctx
);
1029 _mesa_problem(ctx
, "driver doesn't implement GetTimestamp");
1033 case GL_DEBUG_LOGGED_MESSAGES
:
1034 case GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH
:
1035 case GL_DEBUG_GROUP_STACK_DEPTH
:
1036 v
->value_int
= _mesa_get_debug_state_int(ctx
, d
->pname
);
1038 /* GL_ARB_shader_atomic_counters */
1039 case GL_ATOMIC_COUNTER_BUFFER_BINDING
:
1040 if (ctx
->AtomicBuffer
) {
1041 v
->value_int
= ctx
->AtomicBuffer
->Name
;
1046 /* GL_ARB_draw_indirect */
1047 case GL_DRAW_INDIRECT_BUFFER_BINDING
:
1048 v
->value_int
= ctx
->DrawIndirectBuffer
->Name
;
1050 /* GL_ARB_separate_shader_objects */
1051 case GL_PROGRAM_PIPELINE_BINDING
:
1052 if (ctx
->Pipeline
.Current
) {
1053 v
->value_int
= ctx
->Pipeline
.Current
->Name
;
1062 * Check extra constraints on a struct value_desc descriptor
1064 * If a struct value_desc has a non-NULL extra pointer, it means that
1065 * there are a number of extra constraints to check or actions to
1066 * perform. The extras is just an integer array where each integer
1067 * encode different constraints or actions.
1069 * \param ctx current context
1070 * \param func name of calling glGet*v() function for error reporting
1071 * \param d the struct value_desc that has the extra constraints
1073 * \return GL_FALSE if all of the constraints were not satisfied,
1074 * otherwise GL_TRUE.
1077 check_extra(struct gl_context
*ctx
, const char *func
, const struct value_desc
*d
)
1079 const GLuint version
= ctx
->Version
;
1080 GLboolean api_check
= GL_FALSE
;
1081 GLboolean api_found
= GL_FALSE
;
1084 for (e
= d
->extra
; *e
!= EXTRA_END
; e
++) {
1086 case EXTRA_VERSION_30
:
1087 api_check
= GL_TRUE
;
1089 api_found
= GL_TRUE
;
1091 case EXTRA_VERSION_31
:
1092 api_check
= GL_TRUE
;
1094 api_found
= GL_TRUE
;
1096 case EXTRA_VERSION_32
:
1097 api_check
= GL_TRUE
;
1099 api_found
= GL_TRUE
;
1101 case EXTRA_NEW_FRAG_CLAMP
:
1102 if (ctx
->NewState
& (_NEW_BUFFERS
| _NEW_FRAG_CLAMP
))
1103 _mesa_update_state(ctx
);
1106 api_check
= GL_TRUE
;
1107 if (ctx
->API
== API_OPENGLES2
)
1108 api_found
= GL_TRUE
;
1111 api_check
= GL_TRUE
;
1112 if (_mesa_is_gles3(ctx
))
1113 api_found
= GL_TRUE
;
1115 case EXTRA_API_ES31
:
1116 api_check
= GL_TRUE
;
1117 if (_mesa_is_gles31(ctx
))
1118 api_found
= GL_TRUE
;
1121 api_check
= GL_TRUE
;
1122 if (_mesa_is_desktop_gl(ctx
))
1123 api_found
= GL_TRUE
;
1125 case EXTRA_API_GL_CORE
:
1126 api_check
= GL_TRUE
;
1127 if (ctx
->API
== API_OPENGL_CORE
)
1128 api_found
= GL_TRUE
;
1130 case EXTRA_NEW_BUFFERS
:
1131 if (ctx
->NewState
& _NEW_BUFFERS
)
1132 _mesa_update_state(ctx
);
1134 case EXTRA_FLUSH_CURRENT
:
1135 FLUSH_CURRENT(ctx
, 0);
1137 case EXTRA_VALID_DRAW_BUFFER
:
1138 if (d
->pname
- GL_DRAW_BUFFER0_ARB
>= ctx
->Const
.MaxDrawBuffers
) {
1139 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(draw buffer %u)",
1140 func
, d
->pname
- GL_DRAW_BUFFER0_ARB
);
1144 case EXTRA_VALID_TEXTURE_UNIT
:
1145 if (ctx
->Texture
.CurrentUnit
>= ctx
->Const
.MaxTextureCoordUnits
) {
1146 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(texture %u)",
1147 func
, ctx
->Texture
.CurrentUnit
);
1151 case EXTRA_VALID_CLIP_DISTANCE
:
1152 if (d
->pname
- GL_CLIP_DISTANCE0
>= ctx
->Const
.MaxClipPlanes
) {
1153 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(clip distance %u)",
1154 func
, d
->pname
- GL_CLIP_DISTANCE0
);
1158 case EXTRA_GLSL_130
:
1159 api_check
= GL_TRUE
;
1160 if (ctx
->Const
.GLSLVersion
>= 130)
1161 api_found
= GL_TRUE
;
1163 case EXTRA_EXT_UBO_GS4
:
1164 api_check
= GL_TRUE
;
1165 api_found
= (ctx
->Extensions
.ARB_uniform_buffer_object
&&
1166 _mesa_has_geometry_shaders(ctx
));
1168 case EXTRA_EXT_ATOMICS_GS4
:
1169 api_check
= GL_TRUE
;
1170 api_found
= (ctx
->Extensions
.ARB_shader_atomic_counters
&&
1171 _mesa_has_geometry_shaders(ctx
));
1173 case EXTRA_EXT_SHADER_IMAGE_GS4
:
1174 api_check
= GL_TRUE
;
1175 api_found
= (ctx
->Extensions
.ARB_shader_image_load_store
&&
1176 _mesa_has_geometry_shaders(ctx
));
1178 case EXTRA_EXT_ATOMICS_TESS
:
1179 api_check
= GL_TRUE
;
1180 api_found
= ctx
->Extensions
.ARB_shader_atomic_counters
&&
1181 _mesa_has_tessellation(ctx
);
1183 case EXTRA_EXT_SHADER_IMAGE_TESS
:
1184 api_check
= GL_TRUE
;
1185 api_found
= ctx
->Extensions
.ARB_shader_image_load_store
&&
1186 _mesa_has_tessellation(ctx
);
1190 default: /* *e is a offset into the extension struct */
1191 api_check
= GL_TRUE
;
1192 if (*(GLboolean
*) ((char *) &ctx
->Extensions
+ *e
))
1193 api_found
= GL_TRUE
;
1198 if (api_check
&& !api_found
) {
1199 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(pname=%s)", func
,
1200 _mesa_enum_to_string(d
->pname
));
1207 static const struct value_desc error_value
=
1208 { 0, 0, TYPE_INVALID
, NO_OFFSET
, NO_EXTRA
};
1211 * Find the struct value_desc corresponding to the enum 'pname'.
1213 * We hash the enum value to get an index into the 'table' array,
1214 * which holds the index in the 'values' array of struct value_desc.
1215 * Once we've found the entry, we do the extra checks, if any, then
1216 * look up the value and return a pointer to it.
1218 * If the value has to be computed (for example, it's the result of a
1219 * function call or we need to add 1 to it), we use the tmp 'v' to
1222 * \param func name of glGet*v() func for error reporting
1223 * \param pname the enum value we're looking up
1224 * \param p is were we return the pointer to the value
1225 * \param v a tmp union value variable in the calling glGet*v() function
1227 * \return the struct value_desc corresponding to the enum or a struct
1228 * value_desc of TYPE_INVALID if not found. This lets the calling
1229 * glGet*v() function jump right into a switch statement and
1230 * handle errors there instead of having to check for NULL.
1232 static const struct value_desc
*
1233 find_value(const char *func
, GLenum pname
, void **p
, union value
*v
)
1235 GET_CURRENT_CONTEXT(ctx
);
1236 struct gl_texture_unit
*unit
;
1238 const struct value_desc
*d
;
1242 /* We index into the table_set[] list of per-API hash tables using the API's
1243 * value in the gl_api enum. Since GLES 3 doesn't have an API_OPENGL* enum
1244 * value since it's compatible with GLES2 its entry in table_set[] is at the
1247 STATIC_ASSERT(ARRAY_SIZE(table_set
) == API_OPENGL_LAST
+ 3);
1248 if (_mesa_is_gles3(ctx
)) {
1249 api
= API_OPENGL_LAST
+ 1;
1251 if (_mesa_is_gles31(ctx
)) {
1252 api
= API_OPENGL_LAST
+ 2;
1254 mask
= ARRAY_SIZE(table(api
)) - 1;
1255 hash
= (pname
* prime_factor
);
1257 int idx
= table(api
)[hash
& mask
];
1259 /* If the enum isn't valid, the hash walk ends with index 0,
1260 * pointing to the first entry of values[] which doesn't hold
1261 * any valid enum. */
1262 if (unlikely(idx
== 0)) {
1263 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(pname=%s)", func
,
1264 _mesa_enum_to_string(pname
));
1265 return &error_value
;
1269 if (likely(d
->pname
== pname
))
1275 if (unlikely(d
->extra
&& !check_extra(ctx
, func
, d
)))
1276 return &error_value
;
1278 switch (d
->location
) {
1280 *p
= ((char *) ctx
->DrawBuffer
+ d
->offset
);
1283 *p
= ((char *) ctx
+ d
->offset
);
1286 *p
= ((char *) ctx
->Array
.VAO
+ d
->offset
);
1289 unit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1290 *p
= ((char *) unit
+ d
->offset
);
1293 find_custom_value(ctx
, d
, v
);
1301 /* silence warning */
1302 return &error_value
;
1305 static const int transpose
[] = {
1313 _mesa_GetBooleanv(GLenum pname
, GLboolean
*params
)
1315 const struct value_desc
*d
;
1321 d
= find_value("glGetBooleanv", pname
, &p
, &v
);
1326 params
[0] = INT_TO_BOOLEAN(d
->offset
);
1331 params
[3] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[3]);
1334 params
[2] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[2]);
1337 params
[1] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[1]);
1340 params
[0] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[0]);
1343 case TYPE_DOUBLEN_2
:
1344 params
[1] = FLOAT_TO_BOOLEAN(((GLdouble
*) p
)[1]);
1346 params
[0] = FLOAT_TO_BOOLEAN(((GLdouble
*) p
)[0]);
1350 params
[3] = INT_TO_BOOLEAN(((GLint
*) p
)[3]);
1352 params
[2] = INT_TO_BOOLEAN(((GLint
*) p
)[2]);
1355 params
[1] = INT_TO_BOOLEAN(((GLint
*) p
)[1]);
1358 params
[0] = INT_TO_BOOLEAN(((GLint
*) p
)[0]);
1362 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
1363 params
[i
] = INT_TO_BOOLEAN(v
.value_int_n
.ints
[i
]);
1367 params
[0] = INT64_TO_BOOLEAN(((GLint64
*) p
)[0]);
1371 params
[0] = ((GLboolean
*) p
)[0];
1375 m
= *(GLmatrix
**) p
;
1376 for (i
= 0; i
< 16; i
++)
1377 params
[i
] = FLOAT_TO_BOOLEAN(m
->m
[i
]);
1381 m
= *(GLmatrix
**) p
;
1382 for (i
= 0; i
< 16; i
++)
1383 params
[i
] = FLOAT_TO_BOOLEAN(m
->m
[transpose
[i
]]);
1394 shift
= d
->type
- TYPE_BIT_0
;
1395 params
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
1401 _mesa_GetFloatv(GLenum pname
, GLfloat
*params
)
1403 const struct value_desc
*d
;
1409 d
= find_value("glGetFloatv", pname
, &p
, &v
);
1414 params
[0] = (GLfloat
) d
->offset
;
1419 params
[3] = ((GLfloat
*) p
)[3];
1422 params
[2] = ((GLfloat
*) p
)[2];
1425 params
[1] = ((GLfloat
*) p
)[1];
1428 params
[0] = ((GLfloat
*) p
)[0];
1431 case TYPE_DOUBLEN_2
:
1432 params
[1] = (GLfloat
) (((GLdouble
*) p
)[1]);
1434 params
[0] = (GLfloat
) (((GLdouble
*) p
)[0]);
1438 params
[3] = (GLfloat
) (((GLint
*) p
)[3]);
1440 params
[2] = (GLfloat
) (((GLint
*) p
)[2]);
1443 params
[1] = (GLfloat
) (((GLint
*) p
)[1]);
1446 params
[0] = (GLfloat
) (((GLint
*) p
)[0]);
1450 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
1451 params
[i
] = INT_TO_FLOAT(v
.value_int_n
.ints
[i
]);
1455 params
[0] = (GLfloat
) (((GLint64
*) p
)[0]);
1459 params
[0] = BOOLEAN_TO_FLOAT(*(GLboolean
*) p
);
1463 m
= *(GLmatrix
**) p
;
1464 for (i
= 0; i
< 16; i
++)
1465 params
[i
] = m
->m
[i
];
1469 m
= *(GLmatrix
**) p
;
1470 for (i
= 0; i
< 16; i
++)
1471 params
[i
] = m
->m
[transpose
[i
]];
1482 shift
= d
->type
- TYPE_BIT_0
;
1483 params
[0] = BOOLEAN_TO_FLOAT((*(GLbitfield
*) p
>> shift
) & 1);
1489 _mesa_GetIntegerv(GLenum pname
, GLint
*params
)
1491 const struct value_desc
*d
;
1497 d
= find_value("glGetIntegerv", pname
, &p
, &v
);
1502 params
[0] = d
->offset
;
1506 params
[3] = IROUND(((GLfloat
*) p
)[3]);
1508 params
[2] = IROUND(((GLfloat
*) p
)[2]);
1510 params
[1] = IROUND(((GLfloat
*) p
)[1]);
1512 params
[0] = IROUND(((GLfloat
*) p
)[0]);
1516 params
[3] = FLOAT_TO_INT(((GLfloat
*) p
)[3]);
1518 params
[2] = FLOAT_TO_INT(((GLfloat
*) p
)[2]);
1520 params
[1] = FLOAT_TO_INT(((GLfloat
*) p
)[1]);
1522 params
[0] = FLOAT_TO_INT(((GLfloat
*) p
)[0]);
1525 case TYPE_DOUBLEN_2
:
1526 params
[1] = FLOAT_TO_INT(((GLdouble
*) p
)[1]);
1528 params
[0] = FLOAT_TO_INT(((GLdouble
*) p
)[0]);
1532 params
[3] = ((GLint
*) p
)[3];
1534 params
[2] = ((GLint
*) p
)[2];
1537 params
[1] = ((GLint
*) p
)[1];
1540 params
[0] = ((GLint
*) p
)[0];
1544 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
1545 params
[i
] = v
.value_int_n
.ints
[i
];
1549 params
[0] = INT64_TO_INT(((GLint64
*) p
)[0]);
1553 params
[0] = BOOLEAN_TO_INT(*(GLboolean
*) p
);
1557 m
= *(GLmatrix
**) p
;
1558 for (i
= 0; i
< 16; i
++)
1559 params
[i
] = FLOAT_TO_INT(m
->m
[i
]);
1563 m
= *(GLmatrix
**) p
;
1564 for (i
= 0; i
< 16; i
++)
1565 params
[i
] = FLOAT_TO_INT(m
->m
[transpose
[i
]]);
1576 shift
= d
->type
- TYPE_BIT_0
;
1577 params
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
1583 _mesa_GetInteger64v(GLenum pname
, GLint64
*params
)
1585 const struct value_desc
*d
;
1591 d
= find_value("glGetInteger64v", pname
, &p
, &v
);
1596 params
[0] = d
->offset
;
1600 params
[3] = IROUND64(((GLfloat
*) p
)[3]);
1602 params
[2] = IROUND64(((GLfloat
*) p
)[2]);
1604 params
[1] = IROUND64(((GLfloat
*) p
)[1]);
1606 params
[0] = IROUND64(((GLfloat
*) p
)[0]);
1610 params
[3] = FLOAT_TO_INT64(((GLfloat
*) p
)[3]);
1612 params
[2] = FLOAT_TO_INT64(((GLfloat
*) p
)[2]);
1614 params
[1] = FLOAT_TO_INT64(((GLfloat
*) p
)[1]);
1616 params
[0] = FLOAT_TO_INT64(((GLfloat
*) p
)[0]);
1619 case TYPE_DOUBLEN_2
:
1620 params
[1] = FLOAT_TO_INT64(((GLdouble
*) p
)[1]);
1622 params
[0] = FLOAT_TO_INT64(((GLdouble
*) p
)[0]);
1626 params
[3] = ((GLint
*) p
)[3];
1628 params
[2] = ((GLint
*) p
)[2];
1631 params
[1] = ((GLint
*) p
)[1];
1634 params
[0] = ((GLint
*) p
)[0];
1638 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
1639 params
[i
] = INT_TO_BOOLEAN(v
.value_int_n
.ints
[i
]);
1643 params
[0] = ((GLint64
*) p
)[0];
1647 params
[0] = ((GLboolean
*) p
)[0];
1651 m
= *(GLmatrix
**) p
;
1652 for (i
= 0; i
< 16; i
++)
1653 params
[i
] = FLOAT_TO_INT64(m
->m
[i
]);
1657 m
= *(GLmatrix
**) p
;
1658 for (i
= 0; i
< 16; i
++)
1659 params
[i
] = FLOAT_TO_INT64(m
->m
[transpose
[i
]]);
1670 shift
= d
->type
- TYPE_BIT_0
;
1671 params
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
1677 _mesa_GetDoublev(GLenum pname
, GLdouble
*params
)
1679 const struct value_desc
*d
;
1685 d
= find_value("glGetDoublev", pname
, &p
, &v
);
1690 params
[0] = d
->offset
;
1695 params
[3] = ((GLfloat
*) p
)[3];
1698 params
[2] = ((GLfloat
*) p
)[2];
1701 params
[1] = ((GLfloat
*) p
)[1];
1704 params
[0] = ((GLfloat
*) p
)[0];
1707 case TYPE_DOUBLEN_2
:
1708 params
[1] = ((GLdouble
*) p
)[1];
1710 params
[0] = ((GLdouble
*) p
)[0];
1714 params
[3] = ((GLint
*) p
)[3];
1716 params
[2] = ((GLint
*) p
)[2];
1719 params
[1] = ((GLint
*) p
)[1];
1722 params
[0] = ((GLint
*) p
)[0];
1726 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
1727 params
[i
] = v
.value_int_n
.ints
[i
];
1731 params
[0] = (GLdouble
) (((GLint64
*) p
)[0]);
1735 params
[0] = *(GLboolean
*) p
;
1739 m
= *(GLmatrix
**) p
;
1740 for (i
= 0; i
< 16; i
++)
1741 params
[i
] = m
->m
[i
];
1745 m
= *(GLmatrix
**) p
;
1746 for (i
= 0; i
< 16; i
++)
1747 params
[i
] = m
->m
[transpose
[i
]];
1758 shift
= d
->type
- TYPE_BIT_0
;
1759 params
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
1764 static enum value_type
1765 find_value_indexed(const char *func
, GLenum pname
, GLuint index
, union value
*v
)
1767 GET_CURRENT_CONTEXT(ctx
);
1772 if (index
>= ctx
->Const
.MaxDrawBuffers
)
1774 if (!ctx
->Extensions
.EXT_draw_buffers2
)
1776 v
->value_int
= (ctx
->Color
.BlendEnabled
>> index
) & 1;
1781 case GL_BLEND_SRC_RGB
:
1782 if (index
>= ctx
->Const
.MaxDrawBuffers
)
1784 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
1786 v
->value_int
= ctx
->Color
.Blend
[index
].SrcRGB
;
1788 case GL_BLEND_SRC_ALPHA
:
1789 if (index
>= ctx
->Const
.MaxDrawBuffers
)
1791 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
1793 v
->value_int
= ctx
->Color
.Blend
[index
].SrcA
;
1797 case GL_BLEND_DST_RGB
:
1798 if (index
>= ctx
->Const
.MaxDrawBuffers
)
1800 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
1802 v
->value_int
= ctx
->Color
.Blend
[index
].DstRGB
;
1804 case GL_BLEND_DST_ALPHA
:
1805 if (index
>= ctx
->Const
.MaxDrawBuffers
)
1807 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
1809 v
->value_int
= ctx
->Color
.Blend
[index
].DstA
;
1811 case GL_BLEND_EQUATION_RGB
:
1812 if (index
>= ctx
->Const
.MaxDrawBuffers
)
1814 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
1816 v
->value_int
= ctx
->Color
.Blend
[index
].EquationRGB
;
1818 case GL_BLEND_EQUATION_ALPHA
:
1819 if (index
>= ctx
->Const
.MaxDrawBuffers
)
1821 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
1823 v
->value_int
= ctx
->Color
.Blend
[index
].EquationA
;
1826 case GL_COLOR_WRITEMASK
:
1827 if (index
>= ctx
->Const
.MaxDrawBuffers
)
1829 if (!ctx
->Extensions
.EXT_draw_buffers2
)
1831 v
->value_int_4
[0] = ctx
->Color
.ColorMask
[index
][RCOMP
] ? 1 : 0;
1832 v
->value_int_4
[1] = ctx
->Color
.ColorMask
[index
][GCOMP
] ? 1 : 0;
1833 v
->value_int_4
[2] = ctx
->Color
.ColorMask
[index
][BCOMP
] ? 1 : 0;
1834 v
->value_int_4
[3] = ctx
->Color
.ColorMask
[index
][ACOMP
] ? 1 : 0;
1837 case GL_SCISSOR_BOX
:
1838 if (index
>= ctx
->Const
.MaxViewports
)
1840 v
->value_int_4
[0] = ctx
->Scissor
.ScissorArray
[index
].X
;
1841 v
->value_int_4
[1] = ctx
->Scissor
.ScissorArray
[index
].Y
;
1842 v
->value_int_4
[2] = ctx
->Scissor
.ScissorArray
[index
].Width
;
1843 v
->value_int_4
[3] = ctx
->Scissor
.ScissorArray
[index
].Height
;
1847 if (index
>= ctx
->Const
.MaxViewports
)
1849 v
->value_float_4
[0] = ctx
->ViewportArray
[index
].X
;
1850 v
->value_float_4
[1] = ctx
->ViewportArray
[index
].Y
;
1851 v
->value_float_4
[2] = ctx
->ViewportArray
[index
].Width
;
1852 v
->value_float_4
[3] = ctx
->ViewportArray
[index
].Height
;
1853 return TYPE_FLOAT_4
;
1855 case GL_DEPTH_RANGE
:
1856 if (index
>= ctx
->Const
.MaxViewports
)
1858 v
->value_double_2
[0] = ctx
->ViewportArray
[index
].Near
;
1859 v
->value_double_2
[1] = ctx
->ViewportArray
[index
].Far
;
1860 return TYPE_DOUBLEN_2
;
1862 case GL_TRANSFORM_FEEDBACK_BUFFER_START
:
1863 if (index
>= ctx
->Const
.MaxTransformFeedbackBuffers
)
1865 if (!ctx
->Extensions
.EXT_transform_feedback
)
1867 v
->value_int64
= ctx
->TransformFeedback
.CurrentObject
->Offset
[index
];
1870 case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE
:
1871 if (index
>= ctx
->Const
.MaxTransformFeedbackBuffers
)
1873 if (!ctx
->Extensions
.EXT_transform_feedback
)
1876 = ctx
->TransformFeedback
.CurrentObject
->RequestedSize
[index
];
1879 case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING
:
1880 if (index
>= ctx
->Const
.MaxTransformFeedbackBuffers
)
1882 if (!ctx
->Extensions
.EXT_transform_feedback
)
1884 v
->value_int
= ctx
->TransformFeedback
.CurrentObject
->BufferNames
[index
];
1887 case GL_UNIFORM_BUFFER_BINDING
:
1888 if (index
>= ctx
->Const
.MaxUniformBufferBindings
)
1890 if (!ctx
->Extensions
.ARB_uniform_buffer_object
)
1892 v
->value_int
= ctx
->UniformBufferBindings
[index
].BufferObject
->Name
;
1895 case GL_UNIFORM_BUFFER_START
:
1896 if (index
>= ctx
->Const
.MaxUniformBufferBindings
)
1898 if (!ctx
->Extensions
.ARB_uniform_buffer_object
)
1900 v
->value_int
= ctx
->UniformBufferBindings
[index
].Offset
;
1903 case GL_UNIFORM_BUFFER_SIZE
:
1904 if (index
>= ctx
->Const
.MaxUniformBufferBindings
)
1906 if (!ctx
->Extensions
.ARB_uniform_buffer_object
)
1908 v
->value_int
= ctx
->UniformBufferBindings
[index
].Size
;
1911 /* ARB_texture_multisample / GL3.2 */
1912 case GL_SAMPLE_MASK_VALUE
:
1915 if (!ctx
->Extensions
.ARB_texture_multisample
)
1917 v
->value_int
= ctx
->Multisample
.SampleMaskValue
;
1920 case GL_ATOMIC_COUNTER_BUFFER_BINDING
:
1921 if (!ctx
->Extensions
.ARB_shader_atomic_counters
)
1923 if (index
>= ctx
->Const
.MaxAtomicBufferBindings
)
1925 v
->value_int
= ctx
->AtomicBufferBindings
[index
].BufferObject
->Name
;
1928 case GL_ATOMIC_COUNTER_BUFFER_START
:
1929 if (!ctx
->Extensions
.ARB_shader_atomic_counters
)
1931 if (index
>= ctx
->Const
.MaxAtomicBufferBindings
)
1933 v
->value_int64
= ctx
->AtomicBufferBindings
[index
].Offset
;
1936 case GL_ATOMIC_COUNTER_BUFFER_SIZE
:
1937 if (!ctx
->Extensions
.ARB_shader_atomic_counters
)
1939 if (index
>= ctx
->Const
.MaxAtomicBufferBindings
)
1941 v
->value_int64
= ctx
->AtomicBufferBindings
[index
].Size
;
1944 case GL_VERTEX_BINDING_DIVISOR
:
1945 if (!_mesa_is_desktop_gl(ctx
) || !ctx
->Extensions
.ARB_instanced_arrays
)
1947 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
)
1949 v
->value_int
= ctx
->Array
.VAO
->VertexBinding
[VERT_ATTRIB_GENERIC(index
)].InstanceDivisor
;
1952 case GL_VERTEX_BINDING_OFFSET
:
1953 if (!_mesa_is_desktop_gl(ctx
))
1955 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
)
1957 v
->value_int
= ctx
->Array
.VAO
->VertexBinding
[VERT_ATTRIB_GENERIC(index
)].Offset
;
1960 case GL_VERTEX_BINDING_STRIDE
:
1961 if (!_mesa_is_desktop_gl(ctx
))
1963 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
)
1965 v
->value_int
= ctx
->Array
.VAO
->VertexBinding
[VERT_ATTRIB_GENERIC(index
)].Stride
;
1968 /* ARB_shader_image_load_store */
1969 case GL_IMAGE_BINDING_NAME
: {
1970 struct gl_texture_object
*t
;
1972 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
1974 if (index
>= ctx
->Const
.MaxImageUnits
)
1977 t
= ctx
->ImageUnits
[index
].TexObj
;
1978 v
->value_int
= (t
? t
->Name
: 0);
1982 case GL_IMAGE_BINDING_LEVEL
:
1983 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
1985 if (index
>= ctx
->Const
.MaxImageUnits
)
1988 v
->value_int
= ctx
->ImageUnits
[index
].Level
;
1991 case GL_IMAGE_BINDING_LAYERED
:
1992 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
1994 if (index
>= ctx
->Const
.MaxImageUnits
)
1997 v
->value_int
= ctx
->ImageUnits
[index
].Layered
;
2000 case GL_IMAGE_BINDING_LAYER
:
2001 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
2003 if (index
>= ctx
->Const
.MaxImageUnits
)
2006 v
->value_int
= ctx
->ImageUnits
[index
].Layer
;
2009 case GL_IMAGE_BINDING_ACCESS
:
2010 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
2012 if (index
>= ctx
->Const
.MaxImageUnits
)
2015 v
->value_int
= ctx
->ImageUnits
[index
].Access
;
2018 case GL_IMAGE_BINDING_FORMAT
:
2019 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
2021 if (index
>= ctx
->Const
.MaxImageUnits
)
2024 v
->value_int
= ctx
->ImageUnits
[index
].Format
;
2027 case GL_MAX_COMPUTE_WORK_GROUP_COUNT
:
2028 if (!_mesa_is_desktop_gl(ctx
) || !ctx
->Extensions
.ARB_compute_shader
)
2032 v
->value_int
= ctx
->Const
.MaxComputeWorkGroupCount
[index
];
2035 case GL_MAX_COMPUTE_WORK_GROUP_SIZE
:
2036 if (!_mesa_is_desktop_gl(ctx
) || !ctx
->Extensions
.ARB_compute_shader
)
2040 v
->value_int
= ctx
->Const
.MaxComputeWorkGroupSize
[index
];
2045 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(pname=%s)", func
,
2046 _mesa_enum_to_string(pname
));
2047 return TYPE_INVALID
;
2049 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(pname=%s)", func
,
2050 _mesa_enum_to_string(pname
));
2051 return TYPE_INVALID
;
2055 _mesa_GetBooleani_v( GLenum pname
, GLuint index
, GLboolean
*params
)
2058 enum value_type type
=
2059 find_value_indexed("glGetBooleani_v", pname
, index
, &v
);
2063 params
[0] = INT_TO_BOOLEAN(v
.value_int
);
2066 params
[0] = INT_TO_BOOLEAN(v
.value_int_4
[0]);
2067 params
[1] = INT_TO_BOOLEAN(v
.value_int_4
[1]);
2068 params
[2] = INT_TO_BOOLEAN(v
.value_int_4
[2]);
2069 params
[3] = INT_TO_BOOLEAN(v
.value_int_4
[3]);
2072 params
[0] = INT64_TO_BOOLEAN(v
.value_int64
);
2075 ; /* nothing - GL error was recorded */
2080 _mesa_GetIntegeri_v( GLenum pname
, GLuint index
, GLint
*params
)
2083 enum value_type type
=
2084 find_value_indexed("glGetIntegeri_v", pname
, index
, &v
);
2089 params
[3] = IROUND(v
.value_float_4
[3]);
2092 params
[2] = IROUND(v
.value_float_4
[2]);
2095 params
[1] = IROUND(v
.value_float_4
[1]);
2098 params
[0] = IROUND(v
.value_float_4
[0]);
2101 case TYPE_DOUBLEN_2
:
2102 params
[1] = IROUND(v
.value_double_2
[1]);
2104 params
[0] = IROUND(v
.value_double_2
[0]);
2108 params
[0] = v
.value_int
;
2111 params
[0] = v
.value_int_4
[0];
2112 params
[1] = v
.value_int_4
[1];
2113 params
[2] = v
.value_int_4
[2];
2114 params
[3] = v
.value_int_4
[3];
2117 params
[0] = INT64_TO_INT(v
.value_int64
);
2120 ; /* nothing - GL error was recorded */
2125 _mesa_GetInteger64i_v( GLenum pname
, GLuint index
, GLint64
*params
)
2128 enum value_type type
=
2129 find_value_indexed("glGetInteger64i_v", pname
, index
, &v
);
2133 params
[0] = v
.value_int
;
2136 params
[0] = v
.value_int_4
[0];
2137 params
[1] = v
.value_int_4
[1];
2138 params
[2] = v
.value_int_4
[2];
2139 params
[3] = v
.value_int_4
[3];
2142 params
[0] = v
.value_int64
;
2145 ; /* nothing - GL error was recorded */
2150 _mesa_GetFloati_v(GLenum pname
, GLuint index
, GLfloat
*params
)
2155 enum value_type type
=
2156 find_value_indexed("glGetFloati_v", pname
, index
, &v
);
2161 params
[3] = v
.value_float_4
[3];
2164 params
[2] = v
.value_float_4
[2];
2167 params
[1] = v
.value_float_4
[1];
2170 params
[0] = v
.value_float_4
[0];
2173 case TYPE_DOUBLEN_2
:
2174 params
[1] = (GLfloat
) v
.value_double_2
[1];
2176 params
[0] = (GLfloat
) v
.value_double_2
[0];
2180 params
[3] = (GLfloat
) v
.value_int_4
[3];
2182 params
[2] = (GLfloat
) v
.value_int_4
[2];
2185 params
[1] = (GLfloat
) v
.value_int_4
[1];
2188 params
[0] = (GLfloat
) v
.value_int_4
[0];
2192 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
2193 params
[i
] = INT_TO_FLOAT(v
.value_int_n
.ints
[i
]);
2197 params
[0] = (GLfloat
) v
.value_int64
;
2201 params
[0] = BOOLEAN_TO_FLOAT(v
.value_bool
);
2205 m
= *(GLmatrix
**) &v
;
2206 for (i
= 0; i
< 16; i
++)
2207 params
[i
] = m
->m
[i
];
2211 m
= *(GLmatrix
**) &v
;
2212 for (i
= 0; i
< 16; i
++)
2213 params
[i
] = m
->m
[transpose
[i
]];
2222 _mesa_GetDoublei_v(GLenum pname
, GLuint index
, GLdouble
*params
)
2227 enum value_type type
=
2228 find_value_indexed("glGetDoublei_v", pname
, index
, &v
);
2233 params
[3] = (GLdouble
) v
.value_float_4
[3];
2236 params
[2] = (GLdouble
) v
.value_float_4
[2];
2239 params
[1] = (GLdouble
) v
.value_float_4
[1];
2242 params
[0] = (GLdouble
) v
.value_float_4
[0];
2245 case TYPE_DOUBLEN_2
:
2246 params
[1] = v
.value_double_2
[1];
2248 params
[0] = v
.value_double_2
[0];
2252 params
[3] = (GLdouble
) v
.value_int_4
[3];
2254 params
[2] = (GLdouble
) v
.value_int_4
[2];
2257 params
[1] = (GLdouble
) v
.value_int_4
[1];
2260 params
[0] = (GLdouble
) v
.value_int_4
[0];
2264 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
2265 params
[i
] = (GLdouble
) INT_TO_FLOAT(v
.value_int_n
.ints
[i
]);
2269 params
[0] = (GLdouble
) v
.value_int64
;
2273 params
[0] = (GLdouble
) BOOLEAN_TO_FLOAT(v
.value_bool
);
2277 m
= *(GLmatrix
**) &v
;
2278 for (i
= 0; i
< 16; i
++)
2279 params
[i
] = (GLdouble
) m
->m
[i
];
2283 m
= *(GLmatrix
**) &v
;
2284 for (i
= 0; i
< 16; i
++)
2285 params
[i
] = (GLdouble
) m
->m
[transpose
[i
]];
2294 _mesa_GetFixedv(GLenum pname
, GLfixed
*params
)
2296 const struct value_desc
*d
;
2302 d
= find_value("glGetDoublev", pname
, &p
, &v
);
2307 params
[0] = INT_TO_FIXED(d
->offset
);
2312 params
[3] = FLOAT_TO_FIXED(((GLfloat
*) p
)[3]);
2315 params
[2] = FLOAT_TO_FIXED(((GLfloat
*) p
)[2]);
2318 params
[1] = FLOAT_TO_FIXED(((GLfloat
*) p
)[1]);
2321 params
[0] = FLOAT_TO_FIXED(((GLfloat
*) p
)[0]);
2324 case TYPE_DOUBLEN_2
:
2325 params
[1] = FLOAT_TO_FIXED(((GLdouble
*) p
)[1]);
2327 params
[0] = FLOAT_TO_FIXED(((GLdouble
*) p
)[0]);
2331 params
[3] = INT_TO_FIXED(((GLint
*) p
)[3]);
2333 params
[2] = INT_TO_FIXED(((GLint
*) p
)[2]);
2336 params
[1] = INT_TO_FIXED(((GLint
*) p
)[1]);
2339 params
[0] = INT_TO_FIXED(((GLint
*) p
)[0]);
2343 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
2344 params
[i
] = INT_TO_FIXED(v
.value_int_n
.ints
[i
]);
2348 params
[0] = ((GLint64
*) p
)[0];
2352 params
[0] = BOOLEAN_TO_FIXED(((GLboolean
*) p
)[0]);
2356 m
= *(GLmatrix
**) p
;
2357 for (i
= 0; i
< 16; i
++)
2358 params
[i
] = FLOAT_TO_FIXED(m
->m
[i
]);
2362 m
= *(GLmatrix
**) p
;
2363 for (i
= 0; i
< 16; i
++)
2364 params
[i
] = FLOAT_TO_FIXED(m
->m
[transpose
[i
]]);
2375 shift
= d
->type
- TYPE_BIT_0
;
2376 params
[0] = BOOLEAN_TO_FIXED((*(GLbitfield
*) p
>> shift
) & 1);