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
{
142 EXTRA_NEW_FRAG_CLAMP
,
143 EXTRA_VALID_DRAW_BUFFER
,
144 EXTRA_VALID_TEXTURE_UNIT
,
145 EXTRA_VALID_CLIP_DISTANCE
,
149 EXTRA_EXT_ATOMICS_GS4
,
150 EXTRA_EXT_SHADER_IMAGE_GS4
,
153 #define NO_EXTRA NULL
158 GLubyte location
; /**< enum value_location */
159 GLubyte type
; /**< enum value_type */
166 GLfloat value_float_4
[4];
167 GLdouble value_double_2
[2];
168 GLmatrix
*value_matrix
;
170 GLint value_int_4
[4];
174 /* Sigh, see GL_COMPRESSED_TEXTURE_FORMATS_ARB handling */
178 GLboolean value_bool
;
181 #define BUFFER_FIELD(field, type) \
182 LOC_BUFFER, type, offsetof(struct gl_framebuffer, field)
183 #define CONTEXT_FIELD(field, type) \
184 LOC_CONTEXT, type, offsetof(struct gl_context, field)
185 #define ARRAY_FIELD(field, type) \
186 LOC_ARRAY, type, offsetof(struct gl_vertex_array_object, field)
187 #undef CONST /* already defined through windows.h */
188 #define CONST(value) \
189 LOC_CONTEXT, TYPE_CONST, value
191 #define BUFFER_INT(field) BUFFER_FIELD(field, TYPE_INT)
192 #define BUFFER_ENUM(field) BUFFER_FIELD(field, TYPE_ENUM)
193 #define BUFFER_BOOL(field) BUFFER_FIELD(field, TYPE_BOOLEAN)
195 #define CONTEXT_INT(field) CONTEXT_FIELD(field, TYPE_INT)
196 #define CONTEXT_INT2(field) CONTEXT_FIELD(field, TYPE_INT_2)
197 #define CONTEXT_INT64(field) CONTEXT_FIELD(field, TYPE_INT64)
198 #define CONTEXT_ENUM(field) CONTEXT_FIELD(field, TYPE_ENUM)
199 #define CONTEXT_ENUM2(field) CONTEXT_FIELD(field, TYPE_ENUM_2)
200 #define CONTEXT_BOOL(field) CONTEXT_FIELD(field, TYPE_BOOLEAN)
201 #define CONTEXT_BIT0(field) CONTEXT_FIELD(field, TYPE_BIT_0)
202 #define CONTEXT_BIT1(field) CONTEXT_FIELD(field, TYPE_BIT_1)
203 #define CONTEXT_BIT2(field) CONTEXT_FIELD(field, TYPE_BIT_2)
204 #define CONTEXT_BIT3(field) CONTEXT_FIELD(field, TYPE_BIT_3)
205 #define CONTEXT_BIT4(field) CONTEXT_FIELD(field, TYPE_BIT_4)
206 #define CONTEXT_BIT5(field) CONTEXT_FIELD(field, TYPE_BIT_5)
207 #define CONTEXT_BIT6(field) CONTEXT_FIELD(field, TYPE_BIT_6)
208 #define CONTEXT_BIT7(field) CONTEXT_FIELD(field, TYPE_BIT_7)
209 #define CONTEXT_FLOAT(field) CONTEXT_FIELD(field, TYPE_FLOAT)
210 #define CONTEXT_FLOAT2(field) CONTEXT_FIELD(field, TYPE_FLOAT_2)
211 #define CONTEXT_FLOAT3(field) CONTEXT_FIELD(field, TYPE_FLOAT_3)
212 #define CONTEXT_FLOAT4(field) CONTEXT_FIELD(field, TYPE_FLOAT_4)
213 #define CONTEXT_MATRIX(field) CONTEXT_FIELD(field, TYPE_MATRIX)
214 #define CONTEXT_MATRIX_T(field) CONTEXT_FIELD(field, TYPE_MATRIX_T)
216 #define ARRAY_INT(field) ARRAY_FIELD(field, TYPE_INT)
217 #define ARRAY_ENUM(field) ARRAY_FIELD(field, TYPE_ENUM)
218 #define ARRAY_BOOL(field) ARRAY_FIELD(field, TYPE_BOOLEAN)
221 offsetof(struct gl_extensions, f)
223 #define EXTRA_EXT(e) \
224 static const int extra_##e[] = { \
228 #define EXTRA_EXT2(e1, e2) \
229 static const int extra_##e1##_##e2[] = { \
230 EXT(e1), EXT(e2), EXTRA_END \
233 /* The 'extra' mechanism is a way to specify extra checks (such as
234 * extensions or specific gl versions) or actions (flush current, new
235 * buffers) that we need to do before looking up an enum. We need to
236 * declare them all up front so we can refer to them in the value_desc
239 * Each EXTRA_ will be executed. For EXTRA_* enums of extensions and API
240 * versions, listing multiple ones in an array means an error will be thrown
241 * only if none of them are available. If you need to check for "AND"
242 * behavior, you would need to make a custom EXTRA_ enum.
245 static const int extra_new_buffers
[] = {
250 static const int extra_new_frag_clamp
[] = {
251 EXTRA_NEW_FRAG_CLAMP
,
255 static const int extra_valid_draw_buffer
[] = {
256 EXTRA_VALID_DRAW_BUFFER
,
260 static const int extra_valid_texture_unit
[] = {
261 EXTRA_VALID_TEXTURE_UNIT
,
265 static const int extra_valid_clip_distance
[] = {
266 EXTRA_VALID_CLIP_DISTANCE
,
270 static const int extra_flush_current_valid_texture_unit
[] = {
272 EXTRA_VALID_TEXTURE_UNIT
,
276 static const int extra_flush_current
[] = {
281 static const int extra_EXT_texture_integer_and_new_buffers
[] = {
282 EXT(EXT_texture_integer
),
287 static const int extra_GLSL_130_es3
[] = {
293 static const int extra_texture_buffer_object
[] = {
296 EXT(ARB_texture_buffer_object
),
300 static const int extra_ARB_transform_feedback2_api_es3
[] = {
301 EXT(ARB_transform_feedback2
),
306 static const int extra_ARB_uniform_buffer_object_and_geometry_shader
[] = {
311 static const int extra_ARB_ES2_compatibility_api_es2
[] = {
312 EXT(ARB_ES2_compatibility
),
317 static const int extra_ARB_ES3_compatibility_api_es3
[] = {
318 EXT(ARB_ES3_compatibility
),
323 static const int extra_EXT_framebuffer_sRGB_and_new_buffers
[] = {
324 EXT(EXT_framebuffer_sRGB
),
329 static const int extra_EXT_packed_float
[] = {
330 EXT(EXT_packed_float
),
335 static const int extra_EXT_texture_array_es3
[] = {
336 EXT(EXT_texture_array
),
341 static const int extra_ARB_shader_atomic_counters_and_geometry_shader
[] = {
342 EXTRA_EXT_ATOMICS_GS4
,
346 static const int extra_ARB_shader_image_load_store_and_geometry_shader
[] = {
347 EXTRA_EXT_SHADER_IMAGE_GS4
,
351 EXTRA_EXT(ARB_texture_cube_map
);
352 EXTRA_EXT(EXT_texture_array
);
353 EXTRA_EXT(NV_fog_distance
);
354 EXTRA_EXT(EXT_texture_filter_anisotropic
);
355 EXTRA_EXT(NV_point_sprite
);
356 EXTRA_EXT(NV_texture_rectangle
);
357 EXTRA_EXT(EXT_stencil_two_side
);
358 EXTRA_EXT(EXT_depth_bounds_test
);
359 EXTRA_EXT(ARB_depth_clamp
);
360 EXTRA_EXT(ATI_fragment_shader
);
361 EXTRA_EXT(EXT_provoking_vertex
);
362 EXTRA_EXT(ARB_fragment_shader
);
363 EXTRA_EXT(ARB_fragment_program
);
364 EXTRA_EXT2(ARB_framebuffer_object
, EXT_framebuffer_multisample
);
365 EXTRA_EXT(ARB_seamless_cube_map
);
367 EXTRA_EXT(ARB_vertex_shader
);
368 EXTRA_EXT(EXT_transform_feedback
);
369 EXTRA_EXT(ARB_transform_feedback3
);
370 EXTRA_EXT(EXT_pixel_buffer_object
);
371 EXTRA_EXT(ARB_vertex_program
);
372 EXTRA_EXT2(NV_point_sprite
, ARB_point_sprite
);
373 EXTRA_EXT2(ARB_vertex_program
, ARB_fragment_program
);
374 EXTRA_EXT(ARB_geometry_shader4
);
375 EXTRA_EXT(ARB_color_buffer_float
);
376 EXTRA_EXT(EXT_framebuffer_sRGB
);
377 EXTRA_EXT(OES_EGL_image_external
);
378 EXTRA_EXT(ARB_blend_func_extended
);
379 EXTRA_EXT(ARB_uniform_buffer_object
);
380 EXTRA_EXT(ARB_timer_query
);
381 EXTRA_EXT(ARB_texture_cube_map_array
);
382 EXTRA_EXT(ARB_texture_buffer_range
);
383 EXTRA_EXT(ARB_texture_multisample
);
384 EXTRA_EXT(ARB_texture_gather
);
385 EXTRA_EXT(ARB_shader_atomic_counters
);
386 EXTRA_EXT(ARB_draw_indirect
);
387 EXTRA_EXT(ARB_shader_image_load_store
);
388 EXTRA_EXT(ARB_viewport_array
);
389 EXTRA_EXT(ARB_compute_shader
);
390 EXTRA_EXT(ARB_gpu_shader5
);
391 EXTRA_EXT2(ARB_transform_feedback3
, ARB_gpu_shader5
);
392 EXTRA_EXT(INTEL_performance_query
);
393 EXTRA_EXT(ARB_explicit_uniform_location
);
394 EXTRA_EXT(ARB_clip_control
);
395 EXTRA_EXT(EXT_polygon_offset_clamp
);
398 extra_ARB_color_buffer_float_or_glcore
[] = {
399 EXT(ARB_color_buffer_float
),
405 extra_NV_primitive_restart
[] = {
406 EXT(NV_primitive_restart
),
410 static const int extra_version_30
[] = { EXTRA_VERSION_30
, EXTRA_END
};
411 static const int extra_version_31
[] = { EXTRA_VERSION_31
, EXTRA_END
};
412 static const int extra_version_32
[] = { EXTRA_VERSION_32
, EXTRA_END
};
413 static const int extra_version_40
[] = { EXTRA_VERSION_40
, EXTRA_END
};
415 static const int extra_gl30_es3
[] = {
421 static const int extra_gl32_es3
[] = {
427 static const int extra_gl32_ARB_geometry_shader4
[] = {
429 EXT(ARB_geometry_shader4
),
433 static const int extra_gl40_ARB_sample_shading
[] = {
435 EXT(ARB_sample_shading
),
440 extra_ARB_vertex_program_api_es2
[] = {
441 EXT(ARB_vertex_program
),
446 /* The ReadBuffer get token is valid under either full GL or under
447 * GLES2 if the NV_read_buffer extension is available. */
449 extra_NV_read_buffer_api_gl
[] = {
455 static const int extra_core_ARB_color_buffer_float_and_new_buffers
[] = {
457 EXT(ARB_color_buffer_float
),
462 /* This is the big table describing all the enums we accept in
463 * glGet*v(). The table is partitioned into six parts: enums
464 * understood by all GL APIs (OpenGL, GLES and GLES2), enums shared
465 * between OpenGL and GLES, enums exclusive to GLES, etc for the
466 * remaining combinations. To look up the enums valid in a given API
467 * we will use a hash table specific to that API. These tables are in
468 * turn generated at build time and included through get_hash.h.
471 #include "get_hash.h"
473 /* All we need now is a way to look up the value struct from the enum.
474 * The code generated by gcc for the old generated big switch
475 * statement is a big, balanced, open coded if/else tree, essentially
476 * an unrolled binary search. It would be natural to sort the new
477 * enum table and use bsearch(), but we will use a read-only hash
478 * table instead. bsearch() has a nice guaranteed worst case
479 * performance, but we're also guaranteed to hit that worst case
480 * (log2(n) iterations) for about half the enums. Instead, using an
481 * open addressing hash table, we can find the enum on the first try
482 * for 80% of the enums, 1 collision for 10% and never more than 5
483 * collisions for any enum (typical numbers). And the code is very
484 * simple, even though it feels a little magic. */
488 print_table_stats(int api
)
490 int i
, j
, collisions
[11], count
, hash
, mask
;
491 const struct value_desc
*d
;
492 const char *api_names
[] = {
493 [API_OPENGL_COMPAT
] = "GL",
494 [API_OPENGL_CORE
] = "GL_CORE",
495 [API_OPENGLES
] = "GLES",
496 [API_OPENGLES2
] = "GLES2",
498 const char *api_name
;
500 api_name
= api
< ARRAY_SIZE(api_names
) ? api_names
[api
] : "N/A";
502 mask
= ARRAY_SIZE(table(api
)) - 1;
503 memset(collisions
, 0, sizeof collisions
);
505 for (i
= 0; i
< ARRAY_SIZE(table(api
)); i
++) {
509 d
= &values
[table(api
)[i
]];
510 hash
= (d
->pname
* prime_factor
);
513 if (values
[table(api
)[hash
& mask
]].pname
== d
->pname
)
525 printf("number of enums for %s: %d (total %ld)\n",
526 api_name
, count
, ARRAY_SIZE(values
));
527 for (i
= 0; i
< ARRAY_SIZE(collisions
) - 1; i
++)
528 if (collisions
[i
] > 0)
529 printf(" %d enums with %d %scollisions\n",
530 collisions
[i
], i
, i
== 10 ? "or more " : "");
535 * Initialize the enum hash for a given API
537 * This is called from one_time_init() to insert the enum values that
538 * are valid for the API in question into the enum hash table.
540 * \param the current context, for determining the API in question
542 void _mesa_init_get_hash(struct gl_context
*ctx
)
545 print_table_stats(ctx
->API
);
552 * Handle irregular enums
554 * Some values don't conform to the "well-known type at context
555 * pointer + offset" pattern, so we have this function to catch all
556 * the corner cases. Typically, it's a computed value or a one-off
557 * pointer to a custom struct or something.
559 * In this case we can't return a pointer to the value, so we'll have
560 * to use the temporary variable 'v' declared back in the calling
561 * glGet*v() function to store the result.
563 * \param ctx the current context
564 * \param d the struct value_desc that describes the enum
565 * \param v pointer to the tmp declared in the calling glGet*v() function
568 find_custom_value(struct gl_context
*ctx
, const struct value_desc
*d
, union value
*v
)
570 struct gl_buffer_object
**buffer_obj
;
571 struct gl_vertex_attrib_array
*array
;
575 case GL_MAJOR_VERSION
:
576 v
->value_int
= ctx
->Version
/ 10;
578 case GL_MINOR_VERSION
:
579 v
->value_int
= ctx
->Version
% 10;
585 case GL_TEXTURE_CUBE_MAP_ARB
:
586 case GL_TEXTURE_RECTANGLE_NV
:
587 case GL_TEXTURE_EXTERNAL_OES
:
588 v
->value_bool
= _mesa_IsEnabled(d
->pname
);
591 case GL_LINE_STIPPLE_PATTERN
:
592 /* This is the only GLushort, special case it here by promoting
593 * to an int rather than introducing a new type. */
594 v
->value_int
= ctx
->Line
.StipplePattern
;
597 case GL_CURRENT_RASTER_TEXTURE_COORDS
:
598 unit
= ctx
->Texture
.CurrentUnit
;
599 v
->value_float_4
[0] = ctx
->Current
.RasterTexCoords
[unit
][0];
600 v
->value_float_4
[1] = ctx
->Current
.RasterTexCoords
[unit
][1];
601 v
->value_float_4
[2] = ctx
->Current
.RasterTexCoords
[unit
][2];
602 v
->value_float_4
[3] = ctx
->Current
.RasterTexCoords
[unit
][3];
605 case GL_CURRENT_TEXTURE_COORDS
:
606 unit
= ctx
->Texture
.CurrentUnit
;
607 v
->value_float_4
[0] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
][0];
608 v
->value_float_4
[1] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
][1];
609 v
->value_float_4
[2] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
][2];
610 v
->value_float_4
[3] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
][3];
613 case GL_COLOR_WRITEMASK
:
614 v
->value_int_4
[0] = ctx
->Color
.ColorMask
[0][RCOMP
] ? 1 : 0;
615 v
->value_int_4
[1] = ctx
->Color
.ColorMask
[0][GCOMP
] ? 1 : 0;
616 v
->value_int_4
[2] = ctx
->Color
.ColorMask
[0][BCOMP
] ? 1 : 0;
617 v
->value_int_4
[3] = ctx
->Color
.ColorMask
[0][ACOMP
] ? 1 : 0;
621 v
->value_bool
= ctx
->Current
.Attrib
[VERT_ATTRIB_EDGEFLAG
][0] == 1.0;
625 v
->value_enum
= ctx
->ReadBuffer
->ColorReadBuffer
;
628 case GL_MAP2_GRID_DOMAIN
:
629 v
->value_float_4
[0] = ctx
->Eval
.MapGrid2u1
;
630 v
->value_float_4
[1] = ctx
->Eval
.MapGrid2u2
;
631 v
->value_float_4
[2] = ctx
->Eval
.MapGrid2v1
;
632 v
->value_float_4
[3] = ctx
->Eval
.MapGrid2v2
;
635 case GL_TEXTURE_STACK_DEPTH
:
636 unit
= ctx
->Texture
.CurrentUnit
;
637 v
->value_int
= ctx
->TextureMatrixStack
[unit
].Depth
+ 1;
639 case GL_TEXTURE_MATRIX
:
640 unit
= ctx
->Texture
.CurrentUnit
;
641 v
->value_matrix
= ctx
->TextureMatrixStack
[unit
].Top
;
644 case GL_TEXTURE_COORD_ARRAY
:
645 case GL_TEXTURE_COORD_ARRAY_SIZE
:
646 case GL_TEXTURE_COORD_ARRAY_TYPE
:
647 case GL_TEXTURE_COORD_ARRAY_STRIDE
:
648 array
= &ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_TEX(ctx
->Array
.ActiveTexture
)];
649 v
->value_int
= *(GLuint
*) ((char *) array
+ d
->offset
);
652 case GL_ACTIVE_TEXTURE_ARB
:
653 v
->value_int
= GL_TEXTURE0_ARB
+ ctx
->Texture
.CurrentUnit
;
655 case GL_CLIENT_ACTIVE_TEXTURE_ARB
:
656 v
->value_int
= GL_TEXTURE0_ARB
+ ctx
->Array
.ActiveTexture
;
659 case GL_MODELVIEW_STACK_DEPTH
:
660 case GL_PROJECTION_STACK_DEPTH
:
661 v
->value_int
= *(GLint
*) ((char *) ctx
+ d
->offset
) + 1;
664 case GL_MAX_TEXTURE_SIZE
:
665 case GL_MAX_3D_TEXTURE_SIZE
:
666 case GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB
:
667 p
= (GLuint
*) ((char *) ctx
+ d
->offset
);
668 v
->value_int
= 1 << (*p
- 1);
672 v
->value_int_4
[0] = ctx
->Scissor
.ScissorArray
[0].X
;
673 v
->value_int_4
[1] = ctx
->Scissor
.ScissorArray
[0].Y
;
674 v
->value_int_4
[2] = ctx
->Scissor
.ScissorArray
[0].Width
;
675 v
->value_int_4
[3] = ctx
->Scissor
.ScissorArray
[0].Height
;
678 case GL_SCISSOR_TEST
:
679 v
->value_bool
= ctx
->Scissor
.EnableFlags
& 1;
684 ctx
->ListState
.CurrentList
? ctx
->ListState
.CurrentList
->Name
: 0;
687 if (!ctx
->CompileFlag
)
689 else if (ctx
->ExecuteFlag
)
690 v
->value_enum
= GL_COMPILE_AND_EXECUTE
;
692 v
->value_enum
= GL_COMPILE
;
696 v
->value_float_4
[0] = ctx
->ViewportArray
[0].X
;
697 v
->value_float_4
[1] = ctx
->ViewportArray
[0].Y
;
698 v
->value_float_4
[2] = ctx
->ViewportArray
[0].Width
;
699 v
->value_float_4
[3] = ctx
->ViewportArray
[0].Height
;
703 v
->value_double_2
[0] = ctx
->ViewportArray
[0].Near
;
704 v
->value_double_2
[1] = ctx
->ViewportArray
[0].Far
;
707 case GL_ACTIVE_STENCIL_FACE_EXT
:
708 v
->value_enum
= ctx
->Stencil
.ActiveFace
? GL_BACK
: GL_FRONT
;
711 case GL_STENCIL_FAIL
:
712 v
->value_enum
= ctx
->Stencil
.FailFunc
[ctx
->Stencil
.ActiveFace
];
714 case GL_STENCIL_FUNC
:
715 v
->value_enum
= ctx
->Stencil
.Function
[ctx
->Stencil
.ActiveFace
];
717 case GL_STENCIL_PASS_DEPTH_FAIL
:
718 v
->value_enum
= ctx
->Stencil
.ZFailFunc
[ctx
->Stencil
.ActiveFace
];
720 case GL_STENCIL_PASS_DEPTH_PASS
:
721 v
->value_enum
= ctx
->Stencil
.ZPassFunc
[ctx
->Stencil
.ActiveFace
];
724 v
->value_int
= _mesa_get_stencil_ref(ctx
, ctx
->Stencil
.ActiveFace
);
726 case GL_STENCIL_BACK_REF
:
727 v
->value_int
= _mesa_get_stencil_ref(ctx
, 1);
729 case GL_STENCIL_VALUE_MASK
:
730 v
->value_int
= ctx
->Stencil
.ValueMask
[ctx
->Stencil
.ActiveFace
];
732 case GL_STENCIL_WRITEMASK
:
733 v
->value_int
= ctx
->Stencil
.WriteMask
[ctx
->Stencil
.ActiveFace
];
736 case GL_NUM_EXTENSIONS
:
737 v
->value_int
= _mesa_get_extension_count(ctx
);
740 case GL_IMPLEMENTATION_COLOR_READ_TYPE_OES
:
741 v
->value_int
= _mesa_get_color_read_type(ctx
);
743 case GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES
:
744 v
->value_int
= _mesa_get_color_read_format(ctx
);
747 case GL_CURRENT_MATRIX_STACK_DEPTH_ARB
:
748 v
->value_int
= ctx
->CurrentStack
->Depth
+ 1;
750 case GL_CURRENT_MATRIX_ARB
:
751 case GL_TRANSPOSE_CURRENT_MATRIX_ARB
:
752 v
->value_matrix
= ctx
->CurrentStack
->Top
;
755 case GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB
:
756 v
->value_int
= _mesa_get_compressed_formats(ctx
, NULL
);
758 case GL_COMPRESSED_TEXTURE_FORMATS_ARB
:
760 _mesa_get_compressed_formats(ctx
, v
->value_int_n
.ints
);
761 assert(v
->value_int_n
.n
<= (int) ARRAY_SIZE(v
->value_int_n
.ints
));
764 case GL_MAX_VARYING_FLOATS_ARB
:
765 v
->value_int
= ctx
->Const
.MaxVarying
* 4;
768 /* Various object names */
770 case GL_TEXTURE_BINDING_1D
:
771 case GL_TEXTURE_BINDING_2D
:
772 case GL_TEXTURE_BINDING_3D
:
773 case GL_TEXTURE_BINDING_1D_ARRAY_EXT
:
774 case GL_TEXTURE_BINDING_2D_ARRAY_EXT
:
775 case GL_TEXTURE_BINDING_CUBE_MAP_ARB
:
776 case GL_TEXTURE_BINDING_RECTANGLE_NV
:
777 case GL_TEXTURE_BINDING_EXTERNAL_OES
:
778 case GL_TEXTURE_BINDING_CUBE_MAP_ARRAY
:
779 case GL_TEXTURE_BINDING_2D_MULTISAMPLE
:
780 case GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY
:
781 unit
= ctx
->Texture
.CurrentUnit
;
783 ctx
->Texture
.Unit
[unit
].CurrentTex
[d
->offset
]->Name
;
786 /* GL_EXT_packed_float */
787 case GL_RGBA_SIGNED_COMPONENTS_EXT
:
789 /* Note: we only check the 0th color attachment. */
790 const struct gl_renderbuffer
*rb
=
791 ctx
->DrawBuffer
->_ColorDrawBuffers
[0];
792 if (rb
&& _mesa_is_format_signed(rb
->Format
)) {
793 /* Issue 17 of GL_EXT_packed_float: If a component (such as
794 * alpha) has zero bits, the component should not be considered
795 * signed and so the bit for the respective component should be
799 _mesa_get_format_bits(rb
->Format
, GL_RED_BITS
);
801 _mesa_get_format_bits(rb
->Format
, GL_GREEN_BITS
);
803 _mesa_get_format_bits(rb
->Format
, GL_BLUE_BITS
);
805 _mesa_get_format_bits(rb
->Format
, GL_ALPHA_BITS
);
807 _mesa_get_format_bits(rb
->Format
, GL_TEXTURE_LUMINANCE_SIZE
);
809 _mesa_get_format_bits(rb
->Format
, GL_TEXTURE_INTENSITY_SIZE
);
811 v
->value_int_4
[0] = r_bits
+ l_bits
+ i_bits
> 0;
812 v
->value_int_4
[1] = g_bits
+ l_bits
+ i_bits
> 0;
813 v
->value_int_4
[2] = b_bits
+ l_bits
+ i_bits
> 0;
814 v
->value_int_4
[3] = a_bits
+ i_bits
> 0;
820 v
->value_int_4
[3] = 0;
825 /* GL_ARB_vertex_buffer_object */
826 case GL_VERTEX_ARRAY_BUFFER_BINDING_ARB
:
827 case GL_NORMAL_ARRAY_BUFFER_BINDING_ARB
:
828 case GL_COLOR_ARRAY_BUFFER_BINDING_ARB
:
829 case GL_INDEX_ARRAY_BUFFER_BINDING_ARB
:
830 case GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB
:
831 case GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB
:
832 case GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB
:
833 buffer_obj
= (struct gl_buffer_object
**)
834 ((char *) ctx
->Array
.VAO
+ d
->offset
);
835 v
->value_int
= (*buffer_obj
)->Name
;
837 case GL_ARRAY_BUFFER_BINDING_ARB
:
838 v
->value_int
= ctx
->Array
.ArrayBufferObj
->Name
;
840 case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB
:
842 ctx
->Array
.VAO
->VertexBinding
[VERT_ATTRIB_TEX(ctx
->Array
.ActiveTexture
)].BufferObj
->Name
;
844 case GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB
:
845 v
->value_int
= ctx
->Array
.VAO
->IndexBufferObj
->Name
;
848 /* ARB_vertex_array_bgra */
849 case GL_COLOR_ARRAY_SIZE
:
850 array
= &ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_COLOR0
];
851 v
->value_int
= array
->Format
== GL_BGRA
? GL_BGRA
: array
->Size
;
853 case GL_SECONDARY_COLOR_ARRAY_SIZE
:
854 array
= &ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_COLOR1
];
855 v
->value_int
= array
->Format
== GL_BGRA
? GL_BGRA
: array
->Size
;
858 /* ARB_copy_buffer */
859 case GL_COPY_READ_BUFFER
:
860 v
->value_int
= ctx
->CopyReadBuffer
->Name
;
862 case GL_COPY_WRITE_BUFFER
:
863 v
->value_int
= ctx
->CopyWriteBuffer
->Name
;
866 case GL_PIXEL_PACK_BUFFER_BINDING_EXT
:
867 v
->value_int
= ctx
->Pack
.BufferObj
->Name
;
869 case GL_PIXEL_UNPACK_BUFFER_BINDING_EXT
:
870 v
->value_int
= ctx
->Unpack
.BufferObj
->Name
;
872 case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING
:
873 v
->value_int
= ctx
->TransformFeedback
.CurrentBuffer
->Name
;
875 case GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED
:
876 v
->value_int
= ctx
->TransformFeedback
.CurrentObject
->Paused
;
878 case GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE
:
879 v
->value_int
= ctx
->TransformFeedback
.CurrentObject
->Active
;
881 case GL_TRANSFORM_FEEDBACK_BINDING
:
882 v
->value_int
= ctx
->TransformFeedback
.CurrentObject
->Name
;
884 case GL_CURRENT_PROGRAM
:
885 /* The Changelog of the ARB_separate_shader_objects spec says:
887 * 24 25 Jul 2011 pbrown Remove the language erroneously deleting
888 * CURRENT_PROGRAM. In the EXT extension, this
889 * token was aliased to ACTIVE_PROGRAM_EXT, and
890 * was used to indicate the last program set by
891 * either ActiveProgramEXT or UseProgram. In
892 * the ARB extension, the SSO active programs
893 * are now program pipeline object state and
894 * CURRENT_PROGRAM should still be used to query
895 * the last program set by UseProgram (bug 7822).
898 ctx
->Shader
.ActiveProgram
? ctx
->Shader
.ActiveProgram
->Name
: 0;
900 case GL_READ_FRAMEBUFFER_BINDING_EXT
:
901 v
->value_int
= ctx
->ReadBuffer
->Name
;
903 case GL_RENDERBUFFER_BINDING_EXT
:
905 ctx
->CurrentRenderbuffer
? ctx
->CurrentRenderbuffer
->Name
: 0;
907 case GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES
:
908 v
->value_int
= ctx
->Array
.VAO
->VertexBinding
[VERT_ATTRIB_POINT_SIZE
].BufferObj
->Name
;
912 if (_mesa_get_clamp_fragment_color(ctx
))
913 COPY_4FV(v
->value_float_4
, ctx
->Fog
.Color
);
915 COPY_4FV(v
->value_float_4
, ctx
->Fog
.ColorUnclamped
);
917 case GL_COLOR_CLEAR_VALUE
:
918 if (_mesa_get_clamp_fragment_color(ctx
)) {
919 v
->value_float_4
[0] = CLAMP(ctx
->Color
.ClearColor
.f
[0], 0.0F
, 1.0F
);
920 v
->value_float_4
[1] = CLAMP(ctx
->Color
.ClearColor
.f
[1], 0.0F
, 1.0F
);
921 v
->value_float_4
[2] = CLAMP(ctx
->Color
.ClearColor
.f
[2], 0.0F
, 1.0F
);
922 v
->value_float_4
[3] = CLAMP(ctx
->Color
.ClearColor
.f
[3], 0.0F
, 1.0F
);
924 COPY_4FV(v
->value_float_4
, ctx
->Color
.ClearColor
.f
);
926 case GL_BLEND_COLOR_EXT
:
927 if (_mesa_get_clamp_fragment_color(ctx
))
928 COPY_4FV(v
->value_float_4
, ctx
->Color
.BlendColor
);
930 COPY_4FV(v
->value_float_4
, ctx
->Color
.BlendColorUnclamped
);
932 case GL_ALPHA_TEST_REF
:
933 if (_mesa_get_clamp_fragment_color(ctx
))
934 v
->value_float
= ctx
->Color
.AlphaRef
;
936 v
->value_float
= ctx
->Color
.AlphaRefUnclamped
;
938 case GL_MAX_VERTEX_UNIFORM_VECTORS
:
939 v
->value_int
= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxUniformComponents
/ 4;
942 case GL_MAX_FRAGMENT_UNIFORM_VECTORS
:
943 v
->value_int
= ctx
->Const
.Program
[MESA_SHADER_FRAGMENT
].MaxUniformComponents
/ 4;
946 /* GL_ARB_texture_buffer_object */
947 case GL_TEXTURE_BUFFER_ARB
:
948 v
->value_int
= ctx
->Texture
.BufferObject
->Name
;
950 case GL_TEXTURE_BINDING_BUFFER_ARB
:
951 unit
= ctx
->Texture
.CurrentUnit
;
953 ctx
->Texture
.Unit
[unit
].CurrentTex
[TEXTURE_BUFFER_INDEX
]->Name
;
955 case GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB
:
957 struct gl_buffer_object
*buf
=
958 ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
]
959 .CurrentTex
[TEXTURE_BUFFER_INDEX
]->BufferObject
;
960 v
->value_int
= buf
? buf
->Name
: 0;
963 case GL_TEXTURE_BUFFER_FORMAT_ARB
:
964 v
->value_int
= ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
]
965 .CurrentTex
[TEXTURE_BUFFER_INDEX
]->BufferObjectFormat
;
968 /* GL_ARB_sampler_objects */
969 case GL_SAMPLER_BINDING
:
971 struct gl_sampler_object
*samp
=
972 ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
].Sampler
;
975 * The sampler object may have been deleted on another context,
976 * so we try to lookup the sampler object before returning its Name.
978 if (samp
&& _mesa_lookup_samplerobj(ctx
, samp
->Name
)) {
979 v
->value_int
= samp
->Name
;
985 /* GL_ARB_uniform_buffer_object */
986 case GL_UNIFORM_BUFFER_BINDING
:
987 v
->value_int
= ctx
->UniformBuffer
->Name
;
989 /* GL_ARB_timer_query */
991 if (ctx
->Driver
.GetTimestamp
) {
992 v
->value_int64
= ctx
->Driver
.GetTimestamp(ctx
);
995 _mesa_problem(ctx
, "driver doesn't implement GetTimestamp");
999 case GL_DEBUG_LOGGED_MESSAGES
:
1000 case GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH
:
1001 case GL_DEBUG_GROUP_STACK_DEPTH
:
1002 v
->value_int
= _mesa_get_debug_state_int(ctx
, d
->pname
);
1004 /* GL_ARB_shader_atomic_counters */
1005 case GL_ATOMIC_COUNTER_BUFFER_BINDING
:
1006 if (ctx
->AtomicBuffer
) {
1007 v
->value_int
= ctx
->AtomicBuffer
->Name
;
1012 /* GL_ARB_draw_indirect */
1013 case GL_DRAW_INDIRECT_BUFFER_BINDING
:
1014 v
->value_int
= ctx
->DrawIndirectBuffer
->Name
;
1016 /* GL_ARB_separate_shader_objects */
1017 case GL_PROGRAM_PIPELINE_BINDING
:
1018 if (ctx
->Pipeline
.Current
) {
1019 v
->value_int
= ctx
->Pipeline
.Current
->Name
;
1028 * Check extra constraints on a struct value_desc descriptor
1030 * If a struct value_desc has a non-NULL extra pointer, it means that
1031 * there are a number of extra constraints to check or actions to
1032 * perform. The extras is just an integer array where each integer
1033 * encode different constraints or actions.
1035 * \param ctx current context
1036 * \param func name of calling glGet*v() function for error reporting
1037 * \param d the struct value_desc that has the extra constraints
1039 * \return GL_FALSE if all of the constraints were not satisfied,
1040 * otherwise GL_TRUE.
1043 check_extra(struct gl_context
*ctx
, const char *func
, const struct value_desc
*d
)
1045 const GLuint version
= ctx
->Version
;
1046 GLboolean api_check
= GL_FALSE
;
1047 GLboolean api_found
= GL_FALSE
;
1050 for (e
= d
->extra
; *e
!= EXTRA_END
; e
++) {
1052 case EXTRA_VERSION_30
:
1053 api_check
= GL_TRUE
;
1055 api_found
= GL_TRUE
;
1057 case EXTRA_VERSION_31
:
1058 api_check
= GL_TRUE
;
1060 api_found
= GL_TRUE
;
1062 case EXTRA_VERSION_32
:
1063 api_check
= GL_TRUE
;
1065 api_found
= GL_TRUE
;
1067 case EXTRA_NEW_FRAG_CLAMP
:
1068 if (ctx
->NewState
& (_NEW_BUFFERS
| _NEW_FRAG_CLAMP
))
1069 _mesa_update_state(ctx
);
1072 api_check
= GL_TRUE
;
1073 if (ctx
->API
== API_OPENGLES2
)
1074 api_found
= GL_TRUE
;
1077 api_check
= GL_TRUE
;
1078 if (_mesa_is_gles3(ctx
))
1079 api_found
= GL_TRUE
;
1082 api_check
= GL_TRUE
;
1083 if (_mesa_is_desktop_gl(ctx
))
1084 api_found
= GL_TRUE
;
1086 case EXTRA_API_GL_CORE
:
1087 api_check
= GL_TRUE
;
1088 if (ctx
->API
== API_OPENGL_CORE
)
1089 api_found
= GL_TRUE
;
1091 case EXTRA_NEW_BUFFERS
:
1092 if (ctx
->NewState
& _NEW_BUFFERS
)
1093 _mesa_update_state(ctx
);
1095 case EXTRA_FLUSH_CURRENT
:
1096 FLUSH_CURRENT(ctx
, 0);
1098 case EXTRA_VALID_DRAW_BUFFER
:
1099 if (d
->pname
- GL_DRAW_BUFFER0_ARB
>= ctx
->Const
.MaxDrawBuffers
) {
1100 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(draw buffer %u)",
1101 func
, d
->pname
- GL_DRAW_BUFFER0_ARB
);
1105 case EXTRA_VALID_TEXTURE_UNIT
:
1106 if (ctx
->Texture
.CurrentUnit
>= ctx
->Const
.MaxTextureCoordUnits
) {
1107 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(texture %u)",
1108 func
, ctx
->Texture
.CurrentUnit
);
1112 case EXTRA_VALID_CLIP_DISTANCE
:
1113 if (d
->pname
- GL_CLIP_DISTANCE0
>= ctx
->Const
.MaxClipPlanes
) {
1114 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(clip distance %u)",
1115 func
, d
->pname
- GL_CLIP_DISTANCE0
);
1119 case EXTRA_GLSL_130
:
1120 api_check
= GL_TRUE
;
1121 if (ctx
->Const
.GLSLVersion
>= 130)
1122 api_found
= GL_TRUE
;
1124 case EXTRA_EXT_UBO_GS4
:
1125 api_check
= GL_TRUE
;
1126 api_found
= (ctx
->Extensions
.ARB_uniform_buffer_object
&&
1127 _mesa_has_geometry_shaders(ctx
));
1129 case EXTRA_EXT_ATOMICS_GS4
:
1130 api_check
= GL_TRUE
;
1131 api_found
= (ctx
->Extensions
.ARB_shader_atomic_counters
&&
1132 _mesa_has_geometry_shaders(ctx
));
1134 case EXTRA_EXT_SHADER_IMAGE_GS4
:
1135 api_check
= GL_TRUE
;
1136 api_found
= (ctx
->Extensions
.ARB_shader_image_load_store
&&
1137 _mesa_has_geometry_shaders(ctx
));
1141 default: /* *e is a offset into the extension struct */
1142 api_check
= GL_TRUE
;
1143 if (*(GLboolean
*) ((char *) &ctx
->Extensions
+ *e
))
1144 api_found
= GL_TRUE
;
1149 if (api_check
&& !api_found
) {
1150 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(pname=%s)", func
,
1151 _mesa_lookup_enum_by_nr(d
->pname
));
1158 static const struct value_desc error_value
=
1159 { 0, 0, TYPE_INVALID
, NO_OFFSET
, NO_EXTRA
};
1162 * Find the struct value_desc corresponding to the enum 'pname'.
1164 * We hash the enum value to get an index into the 'table' array,
1165 * which holds the index in the 'values' array of struct value_desc.
1166 * Once we've found the entry, we do the extra checks, if any, then
1167 * look up the value and return a pointer to it.
1169 * If the value has to be computed (for example, it's the result of a
1170 * function call or we need to add 1 to it), we use the tmp 'v' to
1173 * \param func name of glGet*v() func for error reporting
1174 * \param pname the enum value we're looking up
1175 * \param p is were we return the pointer to the value
1176 * \param v a tmp union value variable in the calling glGet*v() function
1178 * \return the struct value_desc corresponding to the enum or a struct
1179 * value_desc of TYPE_INVALID if not found. This lets the calling
1180 * glGet*v() function jump right into a switch statement and
1181 * handle errors there instead of having to check for NULL.
1183 static const struct value_desc
*
1184 find_value(const char *func
, GLenum pname
, void **p
, union value
*v
)
1186 GET_CURRENT_CONTEXT(ctx
);
1187 struct gl_texture_unit
*unit
;
1189 const struct value_desc
*d
;
1193 /* We index into the table_set[] list of per-API hash tables using the API's
1194 * value in the gl_api enum. Since GLES 3 doesn't have an API_OPENGL* enum
1195 * value since it's compatible with GLES2 its entry in table_set[] is at the
1198 STATIC_ASSERT(ARRAY_SIZE(table_set
) == API_OPENGL_LAST
+ 2);
1199 if (_mesa_is_gles3(ctx
)) {
1200 api
= API_OPENGL_LAST
+ 1;
1202 mask
= ARRAY_SIZE(table(api
)) - 1;
1203 hash
= (pname
* prime_factor
);
1205 int idx
= table(api
)[hash
& mask
];
1207 /* If the enum isn't valid, the hash walk ends with index 0,
1208 * pointing to the first entry of values[] which doesn't hold
1209 * any valid enum. */
1210 if (unlikely(idx
== 0)) {
1211 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(pname=%s)", func
,
1212 _mesa_lookup_enum_by_nr(pname
));
1213 return &error_value
;
1217 if (likely(d
->pname
== pname
))
1223 if (unlikely(d
->extra
&& !check_extra(ctx
, func
, d
)))
1224 return &error_value
;
1226 switch (d
->location
) {
1228 *p
= ((char *) ctx
->DrawBuffer
+ d
->offset
);
1231 *p
= ((char *) ctx
+ d
->offset
);
1234 *p
= ((char *) ctx
->Array
.VAO
+ d
->offset
);
1237 unit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1238 *p
= ((char *) unit
+ d
->offset
);
1241 find_custom_value(ctx
, d
, v
);
1249 /* silence warning */
1250 return &error_value
;
1253 static const int transpose
[] = {
1261 _mesa_GetBooleanv(GLenum pname
, GLboolean
*params
)
1263 const struct value_desc
*d
;
1269 d
= find_value("glGetBooleanv", pname
, &p
, &v
);
1274 params
[0] = INT_TO_BOOLEAN(d
->offset
);
1279 params
[3] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[3]);
1282 params
[2] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[2]);
1285 params
[1] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[1]);
1288 params
[0] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[0]);
1291 case TYPE_DOUBLEN_2
:
1292 params
[1] = FLOAT_TO_BOOLEAN(((GLdouble
*) p
)[1]);
1294 params
[0] = FLOAT_TO_BOOLEAN(((GLdouble
*) p
)[0]);
1298 params
[3] = INT_TO_BOOLEAN(((GLint
*) p
)[3]);
1300 params
[2] = INT_TO_BOOLEAN(((GLint
*) p
)[2]);
1303 params
[1] = INT_TO_BOOLEAN(((GLint
*) p
)[1]);
1306 params
[0] = INT_TO_BOOLEAN(((GLint
*) p
)[0]);
1310 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
1311 params
[i
] = INT_TO_BOOLEAN(v
.value_int_n
.ints
[i
]);
1315 params
[0] = INT64_TO_BOOLEAN(((GLint64
*) p
)[0]);
1319 params
[0] = ((GLboolean
*) p
)[0];
1323 m
= *(GLmatrix
**) p
;
1324 for (i
= 0; i
< 16; i
++)
1325 params
[i
] = FLOAT_TO_BOOLEAN(m
->m
[i
]);
1329 m
= *(GLmatrix
**) p
;
1330 for (i
= 0; i
< 16; i
++)
1331 params
[i
] = FLOAT_TO_BOOLEAN(m
->m
[transpose
[i
]]);
1342 shift
= d
->type
- TYPE_BIT_0
;
1343 params
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
1349 _mesa_GetFloatv(GLenum pname
, GLfloat
*params
)
1351 const struct value_desc
*d
;
1357 d
= find_value("glGetFloatv", pname
, &p
, &v
);
1362 params
[0] = (GLfloat
) d
->offset
;
1367 params
[3] = ((GLfloat
*) p
)[3];
1370 params
[2] = ((GLfloat
*) p
)[2];
1373 params
[1] = ((GLfloat
*) p
)[1];
1376 params
[0] = ((GLfloat
*) p
)[0];
1379 case TYPE_DOUBLEN_2
:
1380 params
[1] = (GLfloat
) (((GLdouble
*) p
)[1]);
1382 params
[0] = (GLfloat
) (((GLdouble
*) p
)[0]);
1386 params
[3] = (GLfloat
) (((GLint
*) p
)[3]);
1388 params
[2] = (GLfloat
) (((GLint
*) p
)[2]);
1391 params
[1] = (GLfloat
) (((GLint
*) p
)[1]);
1394 params
[0] = (GLfloat
) (((GLint
*) p
)[0]);
1398 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
1399 params
[i
] = INT_TO_FLOAT(v
.value_int_n
.ints
[i
]);
1403 params
[0] = (GLfloat
) (((GLint64
*) p
)[0]);
1407 params
[0] = BOOLEAN_TO_FLOAT(*(GLboolean
*) p
);
1411 m
= *(GLmatrix
**) p
;
1412 for (i
= 0; i
< 16; i
++)
1413 params
[i
] = m
->m
[i
];
1417 m
= *(GLmatrix
**) p
;
1418 for (i
= 0; i
< 16; i
++)
1419 params
[i
] = m
->m
[transpose
[i
]];
1430 shift
= d
->type
- TYPE_BIT_0
;
1431 params
[0] = BOOLEAN_TO_FLOAT((*(GLbitfield
*) p
>> shift
) & 1);
1437 _mesa_GetIntegerv(GLenum pname
, GLint
*params
)
1439 const struct value_desc
*d
;
1445 d
= find_value("glGetIntegerv", pname
, &p
, &v
);
1450 params
[0] = d
->offset
;
1454 params
[3] = IROUND(((GLfloat
*) p
)[3]);
1456 params
[2] = IROUND(((GLfloat
*) p
)[2]);
1458 params
[1] = IROUND(((GLfloat
*) p
)[1]);
1460 params
[0] = IROUND(((GLfloat
*) p
)[0]);
1464 params
[3] = FLOAT_TO_INT(((GLfloat
*) p
)[3]);
1466 params
[2] = FLOAT_TO_INT(((GLfloat
*) p
)[2]);
1468 params
[1] = FLOAT_TO_INT(((GLfloat
*) p
)[1]);
1470 params
[0] = FLOAT_TO_INT(((GLfloat
*) p
)[0]);
1473 case TYPE_DOUBLEN_2
:
1474 params
[1] = FLOAT_TO_INT(((GLdouble
*) p
)[1]);
1476 params
[0] = FLOAT_TO_INT(((GLdouble
*) p
)[0]);
1480 params
[3] = ((GLint
*) p
)[3];
1482 params
[2] = ((GLint
*) p
)[2];
1485 params
[1] = ((GLint
*) p
)[1];
1488 params
[0] = ((GLint
*) p
)[0];
1492 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
1493 params
[i
] = v
.value_int_n
.ints
[i
];
1497 params
[0] = INT64_TO_INT(((GLint64
*) p
)[0]);
1501 params
[0] = BOOLEAN_TO_INT(*(GLboolean
*) p
);
1505 m
= *(GLmatrix
**) p
;
1506 for (i
= 0; i
< 16; i
++)
1507 params
[i
] = FLOAT_TO_INT(m
->m
[i
]);
1511 m
= *(GLmatrix
**) p
;
1512 for (i
= 0; i
< 16; i
++)
1513 params
[i
] = FLOAT_TO_INT(m
->m
[transpose
[i
]]);
1524 shift
= d
->type
- TYPE_BIT_0
;
1525 params
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
1531 _mesa_GetInteger64v(GLenum pname
, GLint64
*params
)
1533 const struct value_desc
*d
;
1539 d
= find_value("glGetInteger64v", pname
, &p
, &v
);
1544 params
[0] = d
->offset
;
1548 params
[3] = IROUND64(((GLfloat
*) p
)[3]);
1550 params
[2] = IROUND64(((GLfloat
*) p
)[2]);
1552 params
[1] = IROUND64(((GLfloat
*) p
)[1]);
1554 params
[0] = IROUND64(((GLfloat
*) p
)[0]);
1558 params
[3] = FLOAT_TO_INT64(((GLfloat
*) p
)[3]);
1560 params
[2] = FLOAT_TO_INT64(((GLfloat
*) p
)[2]);
1562 params
[1] = FLOAT_TO_INT64(((GLfloat
*) p
)[1]);
1564 params
[0] = FLOAT_TO_INT64(((GLfloat
*) p
)[0]);
1567 case TYPE_DOUBLEN_2
:
1568 params
[1] = FLOAT_TO_INT64(((GLdouble
*) p
)[1]);
1570 params
[0] = FLOAT_TO_INT64(((GLdouble
*) p
)[0]);
1574 params
[3] = ((GLint
*) p
)[3];
1576 params
[2] = ((GLint
*) p
)[2];
1579 params
[1] = ((GLint
*) p
)[1];
1582 params
[0] = ((GLint
*) p
)[0];
1586 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
1587 params
[i
] = INT_TO_BOOLEAN(v
.value_int_n
.ints
[i
]);
1591 params
[0] = ((GLint64
*) p
)[0];
1595 params
[0] = ((GLboolean
*) p
)[0];
1599 m
= *(GLmatrix
**) p
;
1600 for (i
= 0; i
< 16; i
++)
1601 params
[i
] = FLOAT_TO_INT64(m
->m
[i
]);
1605 m
= *(GLmatrix
**) p
;
1606 for (i
= 0; i
< 16; i
++)
1607 params
[i
] = FLOAT_TO_INT64(m
->m
[transpose
[i
]]);
1618 shift
= d
->type
- TYPE_BIT_0
;
1619 params
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
1625 _mesa_GetDoublev(GLenum pname
, GLdouble
*params
)
1627 const struct value_desc
*d
;
1633 d
= find_value("glGetDoublev", pname
, &p
, &v
);
1638 params
[0] = d
->offset
;
1643 params
[3] = ((GLfloat
*) p
)[3];
1646 params
[2] = ((GLfloat
*) p
)[2];
1649 params
[1] = ((GLfloat
*) p
)[1];
1652 params
[0] = ((GLfloat
*) p
)[0];
1655 case TYPE_DOUBLEN_2
:
1656 params
[1] = ((GLdouble
*) p
)[1];
1658 params
[0] = ((GLdouble
*) p
)[0];
1662 params
[3] = ((GLint
*) p
)[3];
1664 params
[2] = ((GLint
*) p
)[2];
1667 params
[1] = ((GLint
*) p
)[1];
1670 params
[0] = ((GLint
*) p
)[0];
1674 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
1675 params
[i
] = v
.value_int_n
.ints
[i
];
1679 params
[0] = (GLdouble
) (((GLint64
*) p
)[0]);
1683 params
[0] = *(GLboolean
*) p
;
1687 m
= *(GLmatrix
**) p
;
1688 for (i
= 0; i
< 16; i
++)
1689 params
[i
] = m
->m
[i
];
1693 m
= *(GLmatrix
**) p
;
1694 for (i
= 0; i
< 16; i
++)
1695 params
[i
] = m
->m
[transpose
[i
]];
1706 shift
= d
->type
- TYPE_BIT_0
;
1707 params
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
1712 static enum value_type
1713 find_value_indexed(const char *func
, GLenum pname
, GLuint index
, union value
*v
)
1715 GET_CURRENT_CONTEXT(ctx
);
1720 if (index
>= ctx
->Const
.MaxDrawBuffers
)
1722 if (!ctx
->Extensions
.EXT_draw_buffers2
)
1724 v
->value_int
= (ctx
->Color
.BlendEnabled
>> index
) & 1;
1729 case GL_BLEND_SRC_RGB
:
1730 if (index
>= ctx
->Const
.MaxDrawBuffers
)
1732 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
1734 v
->value_int
= ctx
->Color
.Blend
[index
].SrcRGB
;
1736 case GL_BLEND_SRC_ALPHA
:
1737 if (index
>= ctx
->Const
.MaxDrawBuffers
)
1739 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
1741 v
->value_int
= ctx
->Color
.Blend
[index
].SrcA
;
1745 case GL_BLEND_DST_RGB
:
1746 if (index
>= ctx
->Const
.MaxDrawBuffers
)
1748 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
1750 v
->value_int
= ctx
->Color
.Blend
[index
].DstRGB
;
1752 case GL_BLEND_DST_ALPHA
:
1753 if (index
>= ctx
->Const
.MaxDrawBuffers
)
1755 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
1757 v
->value_int
= ctx
->Color
.Blend
[index
].DstA
;
1759 case GL_BLEND_EQUATION_RGB
:
1760 if (index
>= ctx
->Const
.MaxDrawBuffers
)
1762 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
1764 v
->value_int
= ctx
->Color
.Blend
[index
].EquationRGB
;
1766 case GL_BLEND_EQUATION_ALPHA
:
1767 if (index
>= ctx
->Const
.MaxDrawBuffers
)
1769 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
1771 v
->value_int
= ctx
->Color
.Blend
[index
].EquationA
;
1774 case GL_COLOR_WRITEMASK
:
1775 if (index
>= ctx
->Const
.MaxDrawBuffers
)
1777 if (!ctx
->Extensions
.EXT_draw_buffers2
)
1779 v
->value_int_4
[0] = ctx
->Color
.ColorMask
[index
][RCOMP
] ? 1 : 0;
1780 v
->value_int_4
[1] = ctx
->Color
.ColorMask
[index
][GCOMP
] ? 1 : 0;
1781 v
->value_int_4
[2] = ctx
->Color
.ColorMask
[index
][BCOMP
] ? 1 : 0;
1782 v
->value_int_4
[3] = ctx
->Color
.ColorMask
[index
][ACOMP
] ? 1 : 0;
1785 case GL_SCISSOR_BOX
:
1786 if (index
>= ctx
->Const
.MaxViewports
)
1788 v
->value_int_4
[0] = ctx
->Scissor
.ScissorArray
[index
].X
;
1789 v
->value_int_4
[1] = ctx
->Scissor
.ScissorArray
[index
].Y
;
1790 v
->value_int_4
[2] = ctx
->Scissor
.ScissorArray
[index
].Width
;
1791 v
->value_int_4
[3] = ctx
->Scissor
.ScissorArray
[index
].Height
;
1795 if (index
>= ctx
->Const
.MaxViewports
)
1797 v
->value_float_4
[0] = ctx
->ViewportArray
[index
].X
;
1798 v
->value_float_4
[1] = ctx
->ViewportArray
[index
].Y
;
1799 v
->value_float_4
[2] = ctx
->ViewportArray
[index
].Width
;
1800 v
->value_float_4
[3] = ctx
->ViewportArray
[index
].Height
;
1801 return TYPE_FLOAT_4
;
1803 case GL_DEPTH_RANGE
:
1804 if (index
>= ctx
->Const
.MaxViewports
)
1806 v
->value_double_2
[0] = ctx
->ViewportArray
[index
].Near
;
1807 v
->value_double_2
[1] = ctx
->ViewportArray
[index
].Far
;
1808 return TYPE_DOUBLEN_2
;
1810 case GL_TRANSFORM_FEEDBACK_BUFFER_START
:
1811 if (index
>= ctx
->Const
.MaxTransformFeedbackBuffers
)
1813 if (!ctx
->Extensions
.EXT_transform_feedback
)
1815 v
->value_int64
= ctx
->TransformFeedback
.CurrentObject
->Offset
[index
];
1818 case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE
:
1819 if (index
>= ctx
->Const
.MaxTransformFeedbackBuffers
)
1821 if (!ctx
->Extensions
.EXT_transform_feedback
)
1824 = ctx
->TransformFeedback
.CurrentObject
->RequestedSize
[index
];
1827 case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING
:
1828 if (index
>= ctx
->Const
.MaxTransformFeedbackBuffers
)
1830 if (!ctx
->Extensions
.EXT_transform_feedback
)
1832 v
->value_int
= ctx
->TransformFeedback
.CurrentObject
->BufferNames
[index
];
1835 case GL_UNIFORM_BUFFER_BINDING
:
1836 if (index
>= ctx
->Const
.MaxUniformBufferBindings
)
1838 if (!ctx
->Extensions
.ARB_uniform_buffer_object
)
1840 v
->value_int
= ctx
->UniformBufferBindings
[index
].BufferObject
->Name
;
1843 case GL_UNIFORM_BUFFER_START
:
1844 if (index
>= ctx
->Const
.MaxUniformBufferBindings
)
1846 if (!ctx
->Extensions
.ARB_uniform_buffer_object
)
1848 v
->value_int
= ctx
->UniformBufferBindings
[index
].Offset
;
1851 case GL_UNIFORM_BUFFER_SIZE
:
1852 if (index
>= ctx
->Const
.MaxUniformBufferBindings
)
1854 if (!ctx
->Extensions
.ARB_uniform_buffer_object
)
1856 v
->value_int
= ctx
->UniformBufferBindings
[index
].Size
;
1859 /* ARB_texture_multisample / GL3.2 */
1860 case GL_SAMPLE_MASK_VALUE
:
1863 if (!ctx
->Extensions
.ARB_texture_multisample
)
1865 v
->value_int
= ctx
->Multisample
.SampleMaskValue
;
1868 case GL_ATOMIC_COUNTER_BUFFER_BINDING
:
1869 if (!ctx
->Extensions
.ARB_shader_atomic_counters
)
1871 if (index
>= ctx
->Const
.MaxAtomicBufferBindings
)
1873 v
->value_int
= ctx
->AtomicBufferBindings
[index
].BufferObject
->Name
;
1876 case GL_ATOMIC_COUNTER_BUFFER_START
:
1877 if (!ctx
->Extensions
.ARB_shader_atomic_counters
)
1879 if (index
>= ctx
->Const
.MaxAtomicBufferBindings
)
1881 v
->value_int64
= ctx
->AtomicBufferBindings
[index
].Offset
;
1884 case GL_ATOMIC_COUNTER_BUFFER_SIZE
:
1885 if (!ctx
->Extensions
.ARB_shader_atomic_counters
)
1887 if (index
>= ctx
->Const
.MaxAtomicBufferBindings
)
1889 v
->value_int64
= ctx
->AtomicBufferBindings
[index
].Size
;
1892 case GL_VERTEX_BINDING_DIVISOR
:
1893 if (!_mesa_is_desktop_gl(ctx
) || !ctx
->Extensions
.ARB_instanced_arrays
)
1895 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
)
1897 v
->value_int
= ctx
->Array
.VAO
->VertexBinding
[VERT_ATTRIB_GENERIC(index
)].InstanceDivisor
;
1900 case GL_VERTEX_BINDING_OFFSET
:
1901 if (!_mesa_is_desktop_gl(ctx
))
1903 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
)
1905 v
->value_int
= ctx
->Array
.VAO
->VertexBinding
[VERT_ATTRIB_GENERIC(index
)].Offset
;
1908 case GL_VERTEX_BINDING_STRIDE
:
1909 if (!_mesa_is_desktop_gl(ctx
))
1911 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
)
1913 v
->value_int
= ctx
->Array
.VAO
->VertexBinding
[VERT_ATTRIB_GENERIC(index
)].Stride
;
1916 /* ARB_shader_image_load_store */
1917 case GL_IMAGE_BINDING_NAME
: {
1918 struct gl_texture_object
*t
;
1920 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
1922 if (index
>= ctx
->Const
.MaxImageUnits
)
1925 t
= ctx
->ImageUnits
[index
].TexObj
;
1926 v
->value_int
= (t
? t
->Name
: 0);
1930 case GL_IMAGE_BINDING_LEVEL
:
1931 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
1933 if (index
>= ctx
->Const
.MaxImageUnits
)
1936 v
->value_int
= ctx
->ImageUnits
[index
].Level
;
1939 case GL_IMAGE_BINDING_LAYERED
:
1940 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
1942 if (index
>= ctx
->Const
.MaxImageUnits
)
1945 v
->value_int
= ctx
->ImageUnits
[index
].Layered
;
1948 case GL_IMAGE_BINDING_LAYER
:
1949 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
1951 if (index
>= ctx
->Const
.MaxImageUnits
)
1954 v
->value_int
= ctx
->ImageUnits
[index
].Layer
;
1957 case GL_IMAGE_BINDING_ACCESS
:
1958 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
1960 if (index
>= ctx
->Const
.MaxImageUnits
)
1963 v
->value_int
= ctx
->ImageUnits
[index
].Access
;
1966 case GL_IMAGE_BINDING_FORMAT
:
1967 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
1969 if (index
>= ctx
->Const
.MaxImageUnits
)
1972 v
->value_int
= ctx
->ImageUnits
[index
].Format
;
1975 case GL_MAX_COMPUTE_WORK_GROUP_COUNT
:
1976 if (!_mesa_is_desktop_gl(ctx
) || !ctx
->Extensions
.ARB_compute_shader
)
1980 v
->value_int
= ctx
->Const
.MaxComputeWorkGroupCount
[index
];
1983 case GL_MAX_COMPUTE_WORK_GROUP_SIZE
:
1984 if (!_mesa_is_desktop_gl(ctx
) || !ctx
->Extensions
.ARB_compute_shader
)
1988 v
->value_int
= ctx
->Const
.MaxComputeWorkGroupSize
[index
];
1993 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(pname=%s)", func
,
1994 _mesa_lookup_enum_by_nr(pname
));
1995 return TYPE_INVALID
;
1997 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(pname=%s)", func
,
1998 _mesa_lookup_enum_by_nr(pname
));
1999 return TYPE_INVALID
;
2003 _mesa_GetBooleani_v( GLenum pname
, GLuint index
, GLboolean
*params
)
2006 enum value_type type
=
2007 find_value_indexed("glGetBooleani_v", pname
, index
, &v
);
2011 params
[0] = INT_TO_BOOLEAN(v
.value_int
);
2014 params
[0] = INT_TO_BOOLEAN(v
.value_int_4
[0]);
2015 params
[1] = INT_TO_BOOLEAN(v
.value_int_4
[1]);
2016 params
[2] = INT_TO_BOOLEAN(v
.value_int_4
[2]);
2017 params
[3] = INT_TO_BOOLEAN(v
.value_int_4
[3]);
2020 params
[0] = INT64_TO_BOOLEAN(v
.value_int64
);
2023 ; /* nothing - GL error was recorded */
2028 _mesa_GetIntegeri_v( GLenum pname
, GLuint index
, GLint
*params
)
2031 enum value_type type
=
2032 find_value_indexed("glGetIntegeri_v", pname
, index
, &v
);
2037 params
[3] = IROUND(v
.value_float_4
[3]);
2040 params
[2] = IROUND(v
.value_float_4
[2]);
2043 params
[1] = IROUND(v
.value_float_4
[1]);
2046 params
[0] = IROUND(v
.value_float_4
[0]);
2049 case TYPE_DOUBLEN_2
:
2050 params
[1] = IROUND(v
.value_double_2
[1]);
2052 params
[0] = IROUND(v
.value_double_2
[0]);
2056 params
[0] = v
.value_int
;
2059 params
[0] = v
.value_int_4
[0];
2060 params
[1] = v
.value_int_4
[1];
2061 params
[2] = v
.value_int_4
[2];
2062 params
[3] = v
.value_int_4
[3];
2065 params
[0] = INT64_TO_INT(v
.value_int64
);
2068 ; /* nothing - GL error was recorded */
2073 _mesa_GetInteger64i_v( GLenum pname
, GLuint index
, GLint64
*params
)
2076 enum value_type type
=
2077 find_value_indexed("glGetInteger64i_v", pname
, index
, &v
);
2081 params
[0] = v
.value_int
;
2084 params
[0] = v
.value_int_4
[0];
2085 params
[1] = v
.value_int_4
[1];
2086 params
[2] = v
.value_int_4
[2];
2087 params
[3] = v
.value_int_4
[3];
2090 params
[0] = v
.value_int64
;
2093 ; /* nothing - GL error was recorded */
2098 _mesa_GetFloati_v(GLenum pname
, GLuint index
, GLfloat
*params
)
2103 enum value_type type
=
2104 find_value_indexed("glGetFloati_v", pname
, index
, &v
);
2109 params
[3] = v
.value_float_4
[3];
2112 params
[2] = v
.value_float_4
[2];
2115 params
[1] = v
.value_float_4
[1];
2118 params
[0] = v
.value_float_4
[0];
2121 case TYPE_DOUBLEN_2
:
2122 params
[1] = (GLfloat
) v
.value_double_2
[1];
2124 params
[0] = (GLfloat
) v
.value_double_2
[0];
2128 params
[3] = (GLfloat
) v
.value_int_4
[3];
2130 params
[2] = (GLfloat
) v
.value_int_4
[2];
2133 params
[1] = (GLfloat
) v
.value_int_4
[1];
2136 params
[0] = (GLfloat
) v
.value_int_4
[0];
2140 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
2141 params
[i
] = INT_TO_FLOAT(v
.value_int_n
.ints
[i
]);
2145 params
[0] = (GLfloat
) v
.value_int64
;
2149 params
[0] = BOOLEAN_TO_FLOAT(v
.value_bool
);
2153 m
= *(GLmatrix
**) &v
;
2154 for (i
= 0; i
< 16; i
++)
2155 params
[i
] = m
->m
[i
];
2159 m
= *(GLmatrix
**) &v
;
2160 for (i
= 0; i
< 16; i
++)
2161 params
[i
] = m
->m
[transpose
[i
]];
2170 _mesa_GetDoublei_v(GLenum pname
, GLuint index
, GLdouble
*params
)
2175 enum value_type type
=
2176 find_value_indexed("glGetDoublei_v", pname
, index
, &v
);
2181 params
[3] = (GLdouble
) v
.value_float_4
[3];
2184 params
[2] = (GLdouble
) v
.value_float_4
[2];
2187 params
[1] = (GLdouble
) v
.value_float_4
[1];
2190 params
[0] = (GLdouble
) v
.value_float_4
[0];
2193 case TYPE_DOUBLEN_2
:
2194 params
[1] = v
.value_double_2
[1];
2196 params
[0] = v
.value_double_2
[0];
2200 params
[3] = (GLdouble
) v
.value_int_4
[3];
2202 params
[2] = (GLdouble
) v
.value_int_4
[2];
2205 params
[1] = (GLdouble
) v
.value_int_4
[1];
2208 params
[0] = (GLdouble
) v
.value_int_4
[0];
2212 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
2213 params
[i
] = (GLdouble
) INT_TO_FLOAT(v
.value_int_n
.ints
[i
]);
2217 params
[0] = (GLdouble
) v
.value_int64
;
2221 params
[0] = (GLdouble
) BOOLEAN_TO_FLOAT(v
.value_bool
);
2225 m
= *(GLmatrix
**) &v
;
2226 for (i
= 0; i
< 16; i
++)
2227 params
[i
] = (GLdouble
) m
->m
[i
];
2231 m
= *(GLmatrix
**) &v
;
2232 for (i
= 0; i
< 16; i
++)
2233 params
[i
] = (GLdouble
) m
->m
[transpose
[i
]];
2242 _mesa_GetFixedv(GLenum pname
, GLfixed
*params
)
2244 const struct value_desc
*d
;
2250 d
= find_value("glGetDoublev", pname
, &p
, &v
);
2255 params
[0] = INT_TO_FIXED(d
->offset
);
2260 params
[3] = FLOAT_TO_FIXED(((GLfloat
*) p
)[3]);
2263 params
[2] = FLOAT_TO_FIXED(((GLfloat
*) p
)[2]);
2266 params
[1] = FLOAT_TO_FIXED(((GLfloat
*) p
)[1]);
2269 params
[0] = FLOAT_TO_FIXED(((GLfloat
*) p
)[0]);
2272 case TYPE_DOUBLEN_2
:
2273 params
[1] = FLOAT_TO_FIXED(((GLdouble
*) p
)[1]);
2275 params
[0] = FLOAT_TO_FIXED(((GLdouble
*) p
)[0]);
2279 params
[3] = INT_TO_FIXED(((GLint
*) p
)[3]);
2281 params
[2] = INT_TO_FIXED(((GLint
*) p
)[2]);
2284 params
[1] = INT_TO_FIXED(((GLint
*) p
)[1]);
2287 params
[0] = INT_TO_FIXED(((GLint
*) p
)[0]);
2291 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
2292 params
[i
] = INT_TO_FIXED(v
.value_int_n
.ints
[i
]);
2296 params
[0] = ((GLint64
*) p
)[0];
2300 params
[0] = BOOLEAN_TO_FIXED(((GLboolean
*) p
)[0]);
2304 m
= *(GLmatrix
**) p
;
2305 for (i
= 0; i
< 16; i
++)
2306 params
[i
] = FLOAT_TO_FIXED(m
->m
[i
]);
2310 m
= *(GLmatrix
**) p
;
2311 for (i
= 0; i
< 16; i
++)
2312 params
[i
] = FLOAT_TO_FIXED(m
->m
[transpose
[i
]]);
2323 shift
= d
->type
- TYPE_BIT_0
;
2324 params
[0] = BOOLEAN_TO_FIXED((*(GLbitfield
*) p
>> shift
) & 1);