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
[] = {
282 EXT(EXT_texture_integer
),
286 static const int extra_EXT_texture_integer_and_new_buffers
[] = {
287 EXT(EXT_texture_integer
),
292 static const int extra_GLSL_130_es3
[] = {
298 static const int extra_texture_buffer_object
[] = {
301 EXT(ARB_texture_buffer_object
),
305 static const int extra_ARB_transform_feedback2_api_es3
[] = {
306 EXT(ARB_transform_feedback2
),
311 static const int extra_ARB_uniform_buffer_object_and_geometry_shader
[] = {
316 static const int extra_ARB_ES2_compatibility_api_es2
[] = {
317 EXT(ARB_ES2_compatibility
),
322 static const int extra_ARB_ES3_compatibility_api_es3
[] = {
323 EXT(ARB_ES3_compatibility
),
328 static const int extra_EXT_framebuffer_sRGB_and_new_buffers
[] = {
329 EXT(EXT_framebuffer_sRGB
),
334 static const int extra_EXT_packed_float
[] = {
335 EXT(EXT_packed_float
),
340 static const int extra_EXT_texture_array_es3
[] = {
341 EXT(EXT_texture_array
),
346 static const int extra_ARB_shader_atomic_counters_and_geometry_shader
[] = {
347 EXTRA_EXT_ATOMICS_GS4
,
351 static const int extra_ARB_shader_image_load_store_and_geometry_shader
[] = {
352 EXTRA_EXT_SHADER_IMAGE_GS4
,
356 EXTRA_EXT(ARB_texture_cube_map
);
357 EXTRA_EXT(EXT_texture_array
);
358 EXTRA_EXT(NV_fog_distance
);
359 EXTRA_EXT(EXT_texture_filter_anisotropic
);
360 EXTRA_EXT(NV_point_sprite
);
361 EXTRA_EXT(NV_texture_rectangle
);
362 EXTRA_EXT(EXT_stencil_two_side
);
363 EXTRA_EXT(EXT_depth_bounds_test
);
364 EXTRA_EXT(ARB_depth_clamp
);
365 EXTRA_EXT(ATI_fragment_shader
);
366 EXTRA_EXT(EXT_provoking_vertex
);
367 EXTRA_EXT(ARB_fragment_shader
);
368 EXTRA_EXT(ARB_fragment_program
);
369 EXTRA_EXT2(ARB_framebuffer_object
, EXT_framebuffer_multisample
);
370 EXTRA_EXT(ARB_seamless_cube_map
);
372 EXTRA_EXT(ARB_vertex_shader
);
373 EXTRA_EXT(EXT_transform_feedback
);
374 EXTRA_EXT(ARB_transform_feedback3
);
375 EXTRA_EXT(EXT_pixel_buffer_object
);
376 EXTRA_EXT(ARB_vertex_program
);
377 EXTRA_EXT2(NV_point_sprite
, ARB_point_sprite
);
378 EXTRA_EXT2(ARB_vertex_program
, ARB_fragment_program
);
379 EXTRA_EXT(ARB_geometry_shader4
);
380 EXTRA_EXT(ARB_color_buffer_float
);
381 EXTRA_EXT(EXT_framebuffer_sRGB
);
382 EXTRA_EXT(OES_EGL_image_external
);
383 EXTRA_EXT(ARB_blend_func_extended
);
384 EXTRA_EXT(ARB_uniform_buffer_object
);
385 EXTRA_EXT(ARB_timer_query
);
386 EXTRA_EXT(ARB_texture_cube_map_array
);
387 EXTRA_EXT(ARB_texture_buffer_range
);
388 EXTRA_EXT(ARB_texture_multisample
);
389 EXTRA_EXT(ARB_texture_gather
);
390 EXTRA_EXT(ARB_shader_atomic_counters
);
391 EXTRA_EXT(ARB_draw_indirect
);
392 EXTRA_EXT(ARB_shader_image_load_store
);
393 EXTRA_EXT(ARB_viewport_array
);
394 EXTRA_EXT(ARB_compute_shader
);
395 EXTRA_EXT(ARB_gpu_shader5
);
396 EXTRA_EXT2(ARB_transform_feedback3
, ARB_gpu_shader5
);
399 extra_ARB_color_buffer_float_or_glcore
[] = {
400 EXT(ARB_color_buffer_float
),
406 extra_NV_primitive_restart
[] = {
407 EXT(NV_primitive_restart
),
411 static const int extra_version_30
[] = { EXTRA_VERSION_30
, EXTRA_END
};
412 static const int extra_version_31
[] = { EXTRA_VERSION_31
, EXTRA_END
};
413 static const int extra_version_32
[] = { EXTRA_VERSION_32
, EXTRA_END
};
414 static const int extra_version_40
[] = { EXTRA_VERSION_40
, EXTRA_END
};
416 static const int extra_gl30_es3
[] = {
422 static const int extra_gl32_es3
[] = {
428 static const int extra_gl32_ARB_geometry_shader4
[] = {
430 EXT(ARB_geometry_shader4
),
434 static const int extra_gl40_ARB_sample_shading
[] = {
436 EXT(ARB_sample_shading
),
441 extra_ARB_vertex_program_api_es2
[] = {
442 EXT(ARB_vertex_program
),
447 /* The ReadBuffer get token is valid under either full GL or under
448 * GLES2 if the NV_read_buffer extension is available. */
450 extra_NV_read_buffer_api_gl
[] = {
456 static const int extra_core_ARB_color_buffer_float_and_new_buffers
[] = {
458 EXT(ARB_color_buffer_float
),
463 /* This is the big table describing all the enums we accept in
464 * glGet*v(). The table is partitioned into six parts: enums
465 * understood by all GL APIs (OpenGL, GLES and GLES2), enums shared
466 * between OpenGL and GLES, enums exclusive to GLES, etc for the
467 * remaining combinations. To look up the enums valid in a given API
468 * we will use a hash table specific to that API. These tables are in
469 * turn generated at build time and included through get_hash.h.
472 #include "get_hash.h"
474 /* All we need now is a way to look up the value struct from the enum.
475 * The code generated by gcc for the old generated big switch
476 * statement is a big, balanced, open coded if/else tree, essentially
477 * an unrolled binary search. It would be natural to sort the new
478 * enum table and use bsearch(), but we will use a read-only hash
479 * table instead. bsearch() has a nice guaranteed worst case
480 * performance, but we're also guaranteed to hit that worst case
481 * (log2(n) iterations) for about half the enums. Instead, using an
482 * open addressing hash table, we can find the enum on the first try
483 * for 80% of the enums, 1 collision for 10% and never more than 5
484 * collisions for any enum (typical numbers). And the code is very
485 * simple, even though it feels a little magic. */
489 print_table_stats(int api
)
491 int i
, j
, collisions
[11], count
, hash
, mask
;
492 const struct value_desc
*d
;
493 const char *api_names
[] = {
494 [API_OPENGL_COMPAT
] = "GL",
495 [API_OPENGL_CORE
] = "GL_CORE",
496 [API_OPENGLES
] = "GLES",
497 [API_OPENGLES2
] = "GLES2",
499 const char *api_name
;
501 api_name
= api
< Elements(api_names
) ? api_names
[api
] : "N/A";
503 mask
= Elements(table(api
)) - 1;
504 memset(collisions
, 0, sizeof collisions
);
506 for (i
= 0; i
< Elements(table(api
)); i
++) {
510 d
= &values
[table(api
)[i
]];
511 hash
= (d
->pname
* prime_factor
);
514 if (values
[table(api
)[hash
& mask
]].pname
== d
->pname
)
526 printf("number of enums for %s: %d (total %ld)\n",
527 api_name
, count
, Elements(values
));
528 for (i
= 0; i
< Elements(collisions
) - 1; i
++)
529 if (collisions
[i
] > 0)
530 printf(" %d enums with %d %scollisions\n",
531 collisions
[i
], i
, i
== 10 ? "or more " : "");
536 * Initialize the enum hash for a given API
538 * This is called from one_time_init() to insert the enum values that
539 * are valid for the API in question into the enum hash table.
541 * \param the current context, for determining the API in question
543 void _mesa_init_get_hash(struct gl_context
*ctx
)
546 print_table_stats(ctx
->API
);
553 * Handle irregular enums
555 * Some values don't conform to the "well-known type at context
556 * pointer + offset" pattern, so we have this function to catch all
557 * the corner cases. Typically, it's a computed value or a one-off
558 * pointer to a custom struct or something.
560 * In this case we can't return a pointer to the value, so we'll have
561 * to use the temporary variable 'v' declared back in the calling
562 * glGet*v() function to store the result.
564 * \param ctx the current context
565 * \param d the struct value_desc that describes the enum
566 * \param v pointer to the tmp declared in the calling glGet*v() function
569 find_custom_value(struct gl_context
*ctx
, const struct value_desc
*d
, union value
*v
)
571 struct gl_buffer_object
**buffer_obj
;
572 struct gl_vertex_attrib_array
*array
;
576 case GL_MAJOR_VERSION
:
577 v
->value_int
= ctx
->Version
/ 10;
579 case GL_MINOR_VERSION
:
580 v
->value_int
= ctx
->Version
% 10;
586 case GL_TEXTURE_CUBE_MAP_ARB
:
587 case GL_TEXTURE_RECTANGLE_NV
:
588 case GL_TEXTURE_EXTERNAL_OES
:
589 v
->value_bool
= _mesa_IsEnabled(d
->pname
);
592 case GL_LINE_STIPPLE_PATTERN
:
593 /* This is the only GLushort, special case it here by promoting
594 * to an int rather than introducing a new type. */
595 v
->value_int
= ctx
->Line
.StipplePattern
;
598 case GL_CURRENT_RASTER_TEXTURE_COORDS
:
599 unit
= ctx
->Texture
.CurrentUnit
;
600 v
->value_float_4
[0] = ctx
->Current
.RasterTexCoords
[unit
][0];
601 v
->value_float_4
[1] = ctx
->Current
.RasterTexCoords
[unit
][1];
602 v
->value_float_4
[2] = ctx
->Current
.RasterTexCoords
[unit
][2];
603 v
->value_float_4
[3] = ctx
->Current
.RasterTexCoords
[unit
][3];
606 case GL_CURRENT_TEXTURE_COORDS
:
607 unit
= ctx
->Texture
.CurrentUnit
;
608 v
->value_float_4
[0] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
][0];
609 v
->value_float_4
[1] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
][1];
610 v
->value_float_4
[2] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
][2];
611 v
->value_float_4
[3] = ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ unit
][3];
614 case GL_COLOR_WRITEMASK
:
615 v
->value_int_4
[0] = ctx
->Color
.ColorMask
[0][RCOMP
] ? 1 : 0;
616 v
->value_int_4
[1] = ctx
->Color
.ColorMask
[0][GCOMP
] ? 1 : 0;
617 v
->value_int_4
[2] = ctx
->Color
.ColorMask
[0][BCOMP
] ? 1 : 0;
618 v
->value_int_4
[3] = ctx
->Color
.ColorMask
[0][ACOMP
] ? 1 : 0;
622 v
->value_bool
= ctx
->Current
.Attrib
[VERT_ATTRIB_EDGEFLAG
][0] == 1.0;
626 v
->value_enum
= ctx
->ReadBuffer
->ColorReadBuffer
;
629 case GL_MAP2_GRID_DOMAIN
:
630 v
->value_float_4
[0] = ctx
->Eval
.MapGrid2u1
;
631 v
->value_float_4
[1] = ctx
->Eval
.MapGrid2u2
;
632 v
->value_float_4
[2] = ctx
->Eval
.MapGrid2v1
;
633 v
->value_float_4
[3] = ctx
->Eval
.MapGrid2v2
;
636 case GL_TEXTURE_STACK_DEPTH
:
637 unit
= ctx
->Texture
.CurrentUnit
;
638 v
->value_int
= ctx
->TextureMatrixStack
[unit
].Depth
+ 1;
640 case GL_TEXTURE_MATRIX
:
641 unit
= ctx
->Texture
.CurrentUnit
;
642 v
->value_matrix
= ctx
->TextureMatrixStack
[unit
].Top
;
645 case GL_TEXTURE_COORD_ARRAY
:
646 case GL_TEXTURE_COORD_ARRAY_SIZE
:
647 case GL_TEXTURE_COORD_ARRAY_TYPE
:
648 case GL_TEXTURE_COORD_ARRAY_STRIDE
:
649 array
= &ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_TEX(ctx
->Array
.ActiveTexture
)];
650 v
->value_int
= *(GLuint
*) ((char *) array
+ d
->offset
);
653 case GL_ACTIVE_TEXTURE_ARB
:
654 v
->value_int
= GL_TEXTURE0_ARB
+ ctx
->Texture
.CurrentUnit
;
656 case GL_CLIENT_ACTIVE_TEXTURE_ARB
:
657 v
->value_int
= GL_TEXTURE0_ARB
+ ctx
->Array
.ActiveTexture
;
660 case GL_MODELVIEW_STACK_DEPTH
:
661 case GL_PROJECTION_STACK_DEPTH
:
662 v
->value_int
= *(GLint
*) ((char *) ctx
+ d
->offset
) + 1;
665 case GL_MAX_TEXTURE_SIZE
:
666 case GL_MAX_3D_TEXTURE_SIZE
:
667 case GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB
:
668 p
= (GLuint
*) ((char *) ctx
+ d
->offset
);
669 v
->value_int
= 1 << (*p
- 1);
673 v
->value_int_4
[0] = ctx
->Scissor
.ScissorArray
[0].X
;
674 v
->value_int_4
[1] = ctx
->Scissor
.ScissorArray
[0].Y
;
675 v
->value_int_4
[2] = ctx
->Scissor
.ScissorArray
[0].Width
;
676 v
->value_int_4
[3] = ctx
->Scissor
.ScissorArray
[0].Height
;
679 case GL_SCISSOR_TEST
:
680 v
->value_bool
= ctx
->Scissor
.EnableFlags
& 1;
685 ctx
->ListState
.CurrentList
? ctx
->ListState
.CurrentList
->Name
: 0;
688 if (!ctx
->CompileFlag
)
690 else if (ctx
->ExecuteFlag
)
691 v
->value_enum
= GL_COMPILE_AND_EXECUTE
;
693 v
->value_enum
= GL_COMPILE
;
697 v
->value_float_4
[0] = ctx
->ViewportArray
[0].X
;
698 v
->value_float_4
[1] = ctx
->ViewportArray
[0].Y
;
699 v
->value_float_4
[2] = ctx
->ViewportArray
[0].Width
;
700 v
->value_float_4
[3] = ctx
->ViewportArray
[0].Height
;
704 v
->value_double_2
[0] = ctx
->ViewportArray
[0].Near
;
705 v
->value_double_2
[1] = ctx
->ViewportArray
[0].Far
;
708 case GL_ACTIVE_STENCIL_FACE_EXT
:
709 v
->value_enum
= ctx
->Stencil
.ActiveFace
? GL_BACK
: GL_FRONT
;
712 case GL_STENCIL_FAIL
:
713 v
->value_enum
= ctx
->Stencil
.FailFunc
[ctx
->Stencil
.ActiveFace
];
715 case GL_STENCIL_FUNC
:
716 v
->value_enum
= ctx
->Stencil
.Function
[ctx
->Stencil
.ActiveFace
];
718 case GL_STENCIL_PASS_DEPTH_FAIL
:
719 v
->value_enum
= ctx
->Stencil
.ZFailFunc
[ctx
->Stencil
.ActiveFace
];
721 case GL_STENCIL_PASS_DEPTH_PASS
:
722 v
->value_enum
= ctx
->Stencil
.ZPassFunc
[ctx
->Stencil
.ActiveFace
];
725 v
->value_int
= _mesa_get_stencil_ref(ctx
, ctx
->Stencil
.ActiveFace
);
727 case GL_STENCIL_BACK_REF
:
728 v
->value_int
= _mesa_get_stencil_ref(ctx
, 1);
730 case GL_STENCIL_VALUE_MASK
:
731 v
->value_int
= ctx
->Stencil
.ValueMask
[ctx
->Stencil
.ActiveFace
];
733 case GL_STENCIL_WRITEMASK
:
734 v
->value_int
= ctx
->Stencil
.WriteMask
[ctx
->Stencil
.ActiveFace
];
737 case GL_NUM_EXTENSIONS
:
738 v
->value_int
= _mesa_get_extension_count(ctx
);
741 case GL_IMPLEMENTATION_COLOR_READ_TYPE_OES
:
742 v
->value_int
= _mesa_get_color_read_type(ctx
);
744 case GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES
:
745 v
->value_int
= _mesa_get_color_read_format(ctx
);
748 case GL_CURRENT_MATRIX_STACK_DEPTH_ARB
:
749 v
->value_int
= ctx
->CurrentStack
->Depth
+ 1;
751 case GL_CURRENT_MATRIX_ARB
:
752 case GL_TRANSPOSE_CURRENT_MATRIX_ARB
:
753 v
->value_matrix
= ctx
->CurrentStack
->Top
;
756 case GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB
:
757 v
->value_int
= _mesa_get_compressed_formats(ctx
, NULL
);
759 case GL_COMPRESSED_TEXTURE_FORMATS_ARB
:
761 _mesa_get_compressed_formats(ctx
, v
->value_int_n
.ints
);
762 ASSERT(v
->value_int_n
.n
<= (int) ARRAY_SIZE(v
->value_int_n
.ints
));
765 case GL_MAX_VARYING_FLOATS_ARB
:
766 v
->value_int
= ctx
->Const
.MaxVarying
* 4;
769 /* Various object names */
771 case GL_TEXTURE_BINDING_1D
:
772 case GL_TEXTURE_BINDING_2D
:
773 case GL_TEXTURE_BINDING_3D
:
774 case GL_TEXTURE_BINDING_1D_ARRAY_EXT
:
775 case GL_TEXTURE_BINDING_2D_ARRAY_EXT
:
776 case GL_TEXTURE_BINDING_CUBE_MAP_ARB
:
777 case GL_TEXTURE_BINDING_RECTANGLE_NV
:
778 case GL_TEXTURE_BINDING_EXTERNAL_OES
:
779 case GL_TEXTURE_BINDING_CUBE_MAP_ARRAY
:
780 case GL_TEXTURE_BINDING_2D_MULTISAMPLE
:
781 case GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY
:
782 unit
= ctx
->Texture
.CurrentUnit
;
784 ctx
->Texture
.Unit
[unit
].CurrentTex
[d
->offset
]->Name
;
787 /* GL_EXT_packed_float */
788 case GL_RGBA_SIGNED_COMPONENTS_EXT
:
790 /* Note: we only check the 0th color attachment. */
791 const struct gl_renderbuffer
*rb
=
792 ctx
->DrawBuffer
->_ColorDrawBuffers
[0];
793 if (rb
&& _mesa_is_format_signed(rb
->Format
)) {
794 /* Issue 17 of GL_EXT_packed_float: If a component (such as
795 * alpha) has zero bits, the component should not be considered
796 * signed and so the bit for the respective component should be
800 _mesa_get_format_bits(rb
->Format
, GL_RED_BITS
);
802 _mesa_get_format_bits(rb
->Format
, GL_GREEN_BITS
);
804 _mesa_get_format_bits(rb
->Format
, GL_BLUE_BITS
);
806 _mesa_get_format_bits(rb
->Format
, GL_ALPHA_BITS
);
808 _mesa_get_format_bits(rb
->Format
, GL_TEXTURE_LUMINANCE_SIZE
);
810 _mesa_get_format_bits(rb
->Format
, GL_TEXTURE_INTENSITY_SIZE
);
812 v
->value_int_4
[0] = r_bits
+ l_bits
+ i_bits
> 0;
813 v
->value_int_4
[1] = g_bits
+ l_bits
+ i_bits
> 0;
814 v
->value_int_4
[2] = b_bits
+ l_bits
+ i_bits
> 0;
815 v
->value_int_4
[3] = a_bits
+ i_bits
> 0;
821 v
->value_int_4
[3] = 0;
826 /* GL_ARB_vertex_buffer_object */
827 case GL_VERTEX_ARRAY_BUFFER_BINDING_ARB
:
828 case GL_NORMAL_ARRAY_BUFFER_BINDING_ARB
:
829 case GL_COLOR_ARRAY_BUFFER_BINDING_ARB
:
830 case GL_INDEX_ARRAY_BUFFER_BINDING_ARB
:
831 case GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB
:
832 case GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB
:
833 case GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB
:
834 buffer_obj
= (struct gl_buffer_object
**)
835 ((char *) ctx
->Array
.VAO
+ d
->offset
);
836 v
->value_int
= (*buffer_obj
)->Name
;
838 case GL_ARRAY_BUFFER_BINDING_ARB
:
839 v
->value_int
= ctx
->Array
.ArrayBufferObj
->Name
;
841 case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB
:
843 ctx
->Array
.VAO
->VertexBinding
[VERT_ATTRIB_TEX(ctx
->Array
.ActiveTexture
)].BufferObj
->Name
;
845 case GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB
:
846 v
->value_int
= ctx
->Array
.VAO
->IndexBufferObj
->Name
;
849 /* ARB_copy_buffer */
850 case GL_COPY_READ_BUFFER
:
851 v
->value_int
= ctx
->CopyReadBuffer
->Name
;
853 case GL_COPY_WRITE_BUFFER
:
854 v
->value_int
= ctx
->CopyWriteBuffer
->Name
;
857 case GL_PIXEL_PACK_BUFFER_BINDING_EXT
:
858 v
->value_int
= ctx
->Pack
.BufferObj
->Name
;
860 case GL_PIXEL_UNPACK_BUFFER_BINDING_EXT
:
861 v
->value_int
= ctx
->Unpack
.BufferObj
->Name
;
863 case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING
:
864 v
->value_int
= ctx
->TransformFeedback
.CurrentBuffer
->Name
;
866 case GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED
:
867 v
->value_int
= ctx
->TransformFeedback
.CurrentObject
->Paused
;
869 case GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE
:
870 v
->value_int
= ctx
->TransformFeedback
.CurrentObject
->Active
;
872 case GL_TRANSFORM_FEEDBACK_BINDING
:
873 v
->value_int
= ctx
->TransformFeedback
.CurrentObject
->Name
;
875 case GL_CURRENT_PROGRAM
:
876 /* The Changelog of the ARB_separate_shader_objects spec says:
878 * 24 25 Jul 2011 pbrown Remove the language erroneously deleting
879 * CURRENT_PROGRAM. In the EXT extension, this
880 * token was aliased to ACTIVE_PROGRAM_EXT, and
881 * was used to indicate the last program set by
882 * either ActiveProgramEXT or UseProgram. In
883 * the ARB extension, the SSO active programs
884 * are now program pipeline object state and
885 * CURRENT_PROGRAM should still be used to query
886 * the last program set by UseProgram (bug 7822).
889 ctx
->Shader
.ActiveProgram
? ctx
->Shader
.ActiveProgram
->Name
: 0;
891 case GL_READ_FRAMEBUFFER_BINDING_EXT
:
892 v
->value_int
= ctx
->ReadBuffer
->Name
;
894 case GL_RENDERBUFFER_BINDING_EXT
:
896 ctx
->CurrentRenderbuffer
? ctx
->CurrentRenderbuffer
->Name
: 0;
898 case GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES
:
899 v
->value_int
= ctx
->Array
.VAO
->VertexBinding
[VERT_ATTRIB_POINT_SIZE
].BufferObj
->Name
;
903 if (_mesa_get_clamp_fragment_color(ctx
))
904 COPY_4FV(v
->value_float_4
, ctx
->Fog
.Color
);
906 COPY_4FV(v
->value_float_4
, ctx
->Fog
.ColorUnclamped
);
908 case GL_COLOR_CLEAR_VALUE
:
909 if (_mesa_get_clamp_fragment_color(ctx
)) {
910 v
->value_float_4
[0] = CLAMP(ctx
->Color
.ClearColor
.f
[0], 0.0F
, 1.0F
);
911 v
->value_float_4
[1] = CLAMP(ctx
->Color
.ClearColor
.f
[1], 0.0F
, 1.0F
);
912 v
->value_float_4
[2] = CLAMP(ctx
->Color
.ClearColor
.f
[2], 0.0F
, 1.0F
);
913 v
->value_float_4
[3] = CLAMP(ctx
->Color
.ClearColor
.f
[3], 0.0F
, 1.0F
);
915 COPY_4FV(v
->value_float_4
, ctx
->Color
.ClearColor
.f
);
917 case GL_BLEND_COLOR_EXT
:
918 if (_mesa_get_clamp_fragment_color(ctx
))
919 COPY_4FV(v
->value_float_4
, ctx
->Color
.BlendColor
);
921 COPY_4FV(v
->value_float_4
, ctx
->Color
.BlendColorUnclamped
);
923 case GL_ALPHA_TEST_REF
:
924 if (_mesa_get_clamp_fragment_color(ctx
))
925 v
->value_float
= ctx
->Color
.AlphaRef
;
927 v
->value_float
= ctx
->Color
.AlphaRefUnclamped
;
929 case GL_MAX_VERTEX_UNIFORM_VECTORS
:
930 v
->value_int
= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxUniformComponents
/ 4;
933 case GL_MAX_FRAGMENT_UNIFORM_VECTORS
:
934 v
->value_int
= ctx
->Const
.Program
[MESA_SHADER_FRAGMENT
].MaxUniformComponents
/ 4;
937 /* GL_ARB_texture_buffer_object */
938 case GL_TEXTURE_BUFFER_ARB
:
939 v
->value_int
= ctx
->Texture
.BufferObject
->Name
;
941 case GL_TEXTURE_BINDING_BUFFER_ARB
:
942 unit
= ctx
->Texture
.CurrentUnit
;
944 ctx
->Texture
.Unit
[unit
].CurrentTex
[TEXTURE_BUFFER_INDEX
]->Name
;
946 case GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB
:
948 struct gl_buffer_object
*buf
=
949 ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
]
950 .CurrentTex
[TEXTURE_BUFFER_INDEX
]->BufferObject
;
951 v
->value_int
= buf
? buf
->Name
: 0;
954 case GL_TEXTURE_BUFFER_FORMAT_ARB
:
955 v
->value_int
= ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
]
956 .CurrentTex
[TEXTURE_BUFFER_INDEX
]->BufferObjectFormat
;
959 /* GL_ARB_sampler_objects */
960 case GL_SAMPLER_BINDING
:
962 struct gl_sampler_object
*samp
=
963 ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
].Sampler
;
966 * The sampler object may have been deleted on another context,
967 * so we try to lookup the sampler object before returning its Name.
969 if (samp
&& _mesa_lookup_samplerobj(ctx
, samp
->Name
)) {
970 v
->value_int
= samp
->Name
;
976 /* GL_ARB_uniform_buffer_object */
977 case GL_UNIFORM_BUFFER_BINDING
:
978 v
->value_int
= ctx
->UniformBuffer
->Name
;
980 /* GL_ARB_timer_query */
982 if (ctx
->Driver
.GetTimestamp
) {
983 v
->value_int64
= ctx
->Driver
.GetTimestamp(ctx
);
986 _mesa_problem(ctx
, "driver doesn't implement GetTimestamp");
990 case GL_DEBUG_LOGGED_MESSAGES
:
991 case GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH
:
992 case GL_DEBUG_GROUP_STACK_DEPTH
:
993 v
->value_int
= _mesa_get_debug_state_int(ctx
, d
->pname
);
995 /* GL_ARB_shader_atomic_counters */
996 case GL_ATOMIC_COUNTER_BUFFER_BINDING
:
997 v
->value_int
= ctx
->AtomicBuffer
->Name
;
999 /* GL_ARB_draw_indirect */
1000 case GL_DRAW_INDIRECT_BUFFER_BINDING
:
1001 v
->value_int
= ctx
->DrawIndirectBuffer
->Name
;
1003 /* GL_ARB_separate_shader_objects */
1004 case GL_PROGRAM_PIPELINE_BINDING
:
1005 if (ctx
->Pipeline
.Current
) {
1006 v
->value_int
= ctx
->Pipeline
.Current
->Name
;
1015 * Check extra constraints on a struct value_desc descriptor
1017 * If a struct value_desc has a non-NULL extra pointer, it means that
1018 * there are a number of extra constraints to check or actions to
1019 * perform. The extras is just an integer array where each integer
1020 * encode different constraints or actions.
1022 * \param ctx current context
1023 * \param func name of calling glGet*v() function for error reporting
1024 * \param d the struct value_desc that has the extra constraints
1026 * \return GL_FALSE if all of the constraints were not satisfied,
1027 * otherwise GL_TRUE.
1030 check_extra(struct gl_context
*ctx
, const char *func
, const struct value_desc
*d
)
1032 const GLuint version
= ctx
->Version
;
1033 GLboolean api_check
= GL_FALSE
;
1034 GLboolean api_found
= GL_FALSE
;
1037 for (e
= d
->extra
; *e
!= EXTRA_END
; e
++) {
1039 case EXTRA_VERSION_30
:
1040 api_check
= GL_TRUE
;
1042 api_found
= GL_TRUE
;
1044 case EXTRA_VERSION_31
:
1045 api_check
= GL_TRUE
;
1047 api_found
= GL_TRUE
;
1049 case EXTRA_VERSION_32
:
1050 api_check
= GL_TRUE
;
1052 api_found
= GL_TRUE
;
1054 case EXTRA_NEW_FRAG_CLAMP
:
1055 if (ctx
->NewState
& (_NEW_BUFFERS
| _NEW_FRAG_CLAMP
))
1056 _mesa_update_state(ctx
);
1059 api_check
= GL_TRUE
;
1060 if (ctx
->API
== API_OPENGLES2
)
1061 api_found
= GL_TRUE
;
1064 api_check
= GL_TRUE
;
1065 if (_mesa_is_gles3(ctx
))
1066 api_found
= GL_TRUE
;
1069 api_check
= GL_TRUE
;
1070 if (_mesa_is_desktop_gl(ctx
))
1071 api_found
= GL_TRUE
;
1073 case EXTRA_API_GL_CORE
:
1074 api_check
= GL_TRUE
;
1075 if (ctx
->API
== API_OPENGL_CORE
)
1076 api_found
= GL_TRUE
;
1078 case EXTRA_NEW_BUFFERS
:
1079 if (ctx
->NewState
& _NEW_BUFFERS
)
1080 _mesa_update_state(ctx
);
1082 case EXTRA_FLUSH_CURRENT
:
1083 FLUSH_CURRENT(ctx
, 0);
1085 case EXTRA_VALID_DRAW_BUFFER
:
1086 if (d
->pname
- GL_DRAW_BUFFER0_ARB
>= ctx
->Const
.MaxDrawBuffers
) {
1087 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(draw buffer %u)",
1088 func
, d
->pname
- GL_DRAW_BUFFER0_ARB
);
1092 case EXTRA_VALID_TEXTURE_UNIT
:
1093 if (ctx
->Texture
.CurrentUnit
>= ctx
->Const
.MaxTextureCoordUnits
) {
1094 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(texture %u)",
1095 func
, ctx
->Texture
.CurrentUnit
);
1099 case EXTRA_VALID_CLIP_DISTANCE
:
1100 if (d
->pname
- GL_CLIP_DISTANCE0
>= ctx
->Const
.MaxClipPlanes
) {
1101 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(clip distance %u)",
1102 func
, d
->pname
- GL_CLIP_DISTANCE0
);
1106 case EXTRA_GLSL_130
:
1107 api_check
= GL_TRUE
;
1108 if (ctx
->Const
.GLSLVersion
>= 130)
1109 api_found
= GL_TRUE
;
1111 case EXTRA_EXT_UBO_GS4
:
1112 api_check
= GL_TRUE
;
1113 api_found
= (ctx
->Extensions
.ARB_uniform_buffer_object
&&
1114 _mesa_has_geometry_shaders(ctx
));
1116 case EXTRA_EXT_ATOMICS_GS4
:
1117 api_check
= GL_TRUE
;
1118 api_found
= (ctx
->Extensions
.ARB_shader_atomic_counters
&&
1119 _mesa_has_geometry_shaders(ctx
));
1121 case EXTRA_EXT_SHADER_IMAGE_GS4
:
1122 api_check
= GL_TRUE
;
1123 api_found
= (ctx
->Extensions
.ARB_shader_image_load_store
&&
1124 _mesa_has_geometry_shaders(ctx
));
1128 default: /* *e is a offset into the extension struct */
1129 api_check
= GL_TRUE
;
1130 if (*(GLboolean
*) ((char *) &ctx
->Extensions
+ *e
))
1131 api_found
= GL_TRUE
;
1136 if (api_check
&& !api_found
) {
1137 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(pname=%s)", func
,
1138 _mesa_lookup_enum_by_nr(d
->pname
));
1145 static const struct value_desc error_value
=
1146 { 0, 0, TYPE_INVALID
, NO_OFFSET
, NO_EXTRA
};
1149 * Find the struct value_desc corresponding to the enum 'pname'.
1151 * We hash the enum value to get an index into the 'table' array,
1152 * which holds the index in the 'values' array of struct value_desc.
1153 * Once we've found the entry, we do the extra checks, if any, then
1154 * look up the value and return a pointer to it.
1156 * If the value has to be computed (for example, it's the result of a
1157 * function call or we need to add 1 to it), we use the tmp 'v' to
1160 * \param func name of glGet*v() func for error reporting
1161 * \param pname the enum value we're looking up
1162 * \param p is were we return the pointer to the value
1163 * \param v a tmp union value variable in the calling glGet*v() function
1165 * \return the struct value_desc corresponding to the enum or a struct
1166 * value_desc of TYPE_INVALID if not found. This lets the calling
1167 * glGet*v() function jump right into a switch statement and
1168 * handle errors there instead of having to check for NULL.
1170 static const struct value_desc
*
1171 find_value(const char *func
, GLenum pname
, void **p
, union value
*v
)
1173 GET_CURRENT_CONTEXT(ctx
);
1174 struct gl_texture_unit
*unit
;
1176 const struct value_desc
*d
;
1180 /* We index into the table_set[] list of per-API hash tables using the API's
1181 * value in the gl_api enum. Since GLES 3 doesn't have an API_OPENGL* enum
1182 * value since it's compatible with GLES2 its entry in table_set[] is at the
1185 STATIC_ASSERT(Elements(table_set
) == API_OPENGL_LAST
+ 2);
1186 if (_mesa_is_gles3(ctx
)) {
1187 api
= API_OPENGL_LAST
+ 1;
1189 mask
= Elements(table(api
)) - 1;
1190 hash
= (pname
* prime_factor
);
1192 int idx
= table(api
)[hash
& mask
];
1194 /* If the enum isn't valid, the hash walk ends with index 0,
1195 * pointing to the first entry of values[] which doesn't hold
1196 * any valid enum. */
1197 if (unlikely(idx
== 0)) {
1198 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(pname=%s)", func
,
1199 _mesa_lookup_enum_by_nr(pname
));
1200 return &error_value
;
1204 if (likely(d
->pname
== pname
))
1210 if (unlikely(d
->extra
&& !check_extra(ctx
, func
, d
)))
1211 return &error_value
;
1213 switch (d
->location
) {
1215 *p
= ((char *) ctx
->DrawBuffer
+ d
->offset
);
1218 *p
= ((char *) ctx
+ d
->offset
);
1221 *p
= ((char *) ctx
->Array
.VAO
+ d
->offset
);
1224 unit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1225 *p
= ((char *) unit
+ d
->offset
);
1228 find_custom_value(ctx
, d
, v
);
1236 /* silence warning */
1237 return &error_value
;
1240 static const int transpose
[] = {
1248 _mesa_GetBooleanv(GLenum pname
, GLboolean
*params
)
1250 const struct value_desc
*d
;
1256 d
= find_value("glGetBooleanv", pname
, &p
, &v
);
1261 params
[0] = INT_TO_BOOLEAN(d
->offset
);
1266 params
[3] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[3]);
1269 params
[2] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[2]);
1272 params
[1] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[1]);
1275 params
[0] = FLOAT_TO_BOOLEAN(((GLfloat
*) p
)[0]);
1278 case TYPE_DOUBLEN_2
:
1279 params
[1] = FLOAT_TO_BOOLEAN(((GLdouble
*) p
)[1]);
1281 params
[0] = FLOAT_TO_BOOLEAN(((GLdouble
*) p
)[0]);
1285 params
[3] = INT_TO_BOOLEAN(((GLint
*) p
)[3]);
1287 params
[2] = INT_TO_BOOLEAN(((GLint
*) p
)[2]);
1290 params
[1] = INT_TO_BOOLEAN(((GLint
*) p
)[1]);
1293 params
[0] = INT_TO_BOOLEAN(((GLint
*) p
)[0]);
1297 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
1298 params
[i
] = INT_TO_BOOLEAN(v
.value_int_n
.ints
[i
]);
1302 params
[0] = INT64_TO_BOOLEAN(((GLint64
*) p
)[0]);
1306 params
[0] = ((GLboolean
*) p
)[0];
1310 m
= *(GLmatrix
**) p
;
1311 for (i
= 0; i
< 16; i
++)
1312 params
[i
] = FLOAT_TO_BOOLEAN(m
->m
[i
]);
1316 m
= *(GLmatrix
**) p
;
1317 for (i
= 0; i
< 16; i
++)
1318 params
[i
] = FLOAT_TO_BOOLEAN(m
->m
[transpose
[i
]]);
1329 shift
= d
->type
- TYPE_BIT_0
;
1330 params
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
1336 _mesa_GetFloatv(GLenum pname
, GLfloat
*params
)
1338 const struct value_desc
*d
;
1344 d
= find_value("glGetFloatv", pname
, &p
, &v
);
1349 params
[0] = (GLfloat
) d
->offset
;
1354 params
[3] = ((GLfloat
*) p
)[3];
1357 params
[2] = ((GLfloat
*) p
)[2];
1360 params
[1] = ((GLfloat
*) p
)[1];
1363 params
[0] = ((GLfloat
*) p
)[0];
1366 case TYPE_DOUBLEN_2
:
1367 params
[1] = (GLfloat
) (((GLdouble
*) p
)[1]);
1369 params
[0] = (GLfloat
) (((GLdouble
*) p
)[0]);
1373 params
[3] = (GLfloat
) (((GLint
*) p
)[3]);
1375 params
[2] = (GLfloat
) (((GLint
*) p
)[2]);
1378 params
[1] = (GLfloat
) (((GLint
*) p
)[1]);
1381 params
[0] = (GLfloat
) (((GLint
*) p
)[0]);
1385 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
1386 params
[i
] = INT_TO_FLOAT(v
.value_int_n
.ints
[i
]);
1390 params
[0] = (GLfloat
) (((GLint64
*) p
)[0]);
1394 params
[0] = BOOLEAN_TO_FLOAT(*(GLboolean
*) p
);
1398 m
= *(GLmatrix
**) p
;
1399 for (i
= 0; i
< 16; i
++)
1400 params
[i
] = m
->m
[i
];
1404 m
= *(GLmatrix
**) p
;
1405 for (i
= 0; i
< 16; i
++)
1406 params
[i
] = m
->m
[transpose
[i
]];
1417 shift
= d
->type
- TYPE_BIT_0
;
1418 params
[0] = BOOLEAN_TO_FLOAT((*(GLbitfield
*) p
>> shift
) & 1);
1424 _mesa_GetIntegerv(GLenum pname
, GLint
*params
)
1426 const struct value_desc
*d
;
1432 d
= find_value("glGetIntegerv", pname
, &p
, &v
);
1437 params
[0] = d
->offset
;
1441 params
[3] = IROUND(((GLfloat
*) p
)[3]);
1443 params
[2] = IROUND(((GLfloat
*) p
)[2]);
1445 params
[1] = IROUND(((GLfloat
*) p
)[1]);
1447 params
[0] = IROUND(((GLfloat
*) p
)[0]);
1451 params
[3] = FLOAT_TO_INT(((GLfloat
*) p
)[3]);
1453 params
[2] = FLOAT_TO_INT(((GLfloat
*) p
)[2]);
1455 params
[1] = FLOAT_TO_INT(((GLfloat
*) p
)[1]);
1457 params
[0] = FLOAT_TO_INT(((GLfloat
*) p
)[0]);
1460 case TYPE_DOUBLEN_2
:
1461 params
[1] = FLOAT_TO_INT(((GLdouble
*) p
)[1]);
1463 params
[0] = FLOAT_TO_INT(((GLdouble
*) p
)[0]);
1467 params
[3] = ((GLint
*) p
)[3];
1469 params
[2] = ((GLint
*) p
)[2];
1472 params
[1] = ((GLint
*) p
)[1];
1475 params
[0] = ((GLint
*) p
)[0];
1479 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
1480 params
[i
] = v
.value_int_n
.ints
[i
];
1484 params
[0] = INT64_TO_INT(((GLint64
*) p
)[0]);
1488 params
[0] = BOOLEAN_TO_INT(*(GLboolean
*) p
);
1492 m
= *(GLmatrix
**) p
;
1493 for (i
= 0; i
< 16; i
++)
1494 params
[i
] = FLOAT_TO_INT(m
->m
[i
]);
1498 m
= *(GLmatrix
**) p
;
1499 for (i
= 0; i
< 16; i
++)
1500 params
[i
] = FLOAT_TO_INT(m
->m
[transpose
[i
]]);
1511 shift
= d
->type
- TYPE_BIT_0
;
1512 params
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
1518 _mesa_GetInteger64v(GLenum pname
, GLint64
*params
)
1520 const struct value_desc
*d
;
1526 d
= find_value("glGetInteger64v", pname
, &p
, &v
);
1531 params
[0] = d
->offset
;
1535 params
[3] = IROUND64(((GLfloat
*) p
)[3]);
1537 params
[2] = IROUND64(((GLfloat
*) p
)[2]);
1539 params
[1] = IROUND64(((GLfloat
*) p
)[1]);
1541 params
[0] = IROUND64(((GLfloat
*) p
)[0]);
1545 params
[3] = FLOAT_TO_INT64(((GLfloat
*) p
)[3]);
1547 params
[2] = FLOAT_TO_INT64(((GLfloat
*) p
)[2]);
1549 params
[1] = FLOAT_TO_INT64(((GLfloat
*) p
)[1]);
1551 params
[0] = FLOAT_TO_INT64(((GLfloat
*) p
)[0]);
1554 case TYPE_DOUBLEN_2
:
1555 params
[1] = FLOAT_TO_INT64(((GLdouble
*) p
)[1]);
1557 params
[0] = FLOAT_TO_INT64(((GLdouble
*) p
)[0]);
1561 params
[3] = ((GLint
*) p
)[3];
1563 params
[2] = ((GLint
*) p
)[2];
1566 params
[1] = ((GLint
*) p
)[1];
1569 params
[0] = ((GLint
*) p
)[0];
1573 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
1574 params
[i
] = INT_TO_BOOLEAN(v
.value_int_n
.ints
[i
]);
1578 params
[0] = ((GLint64
*) p
)[0];
1582 params
[0] = ((GLboolean
*) p
)[0];
1586 m
= *(GLmatrix
**) p
;
1587 for (i
= 0; i
< 16; i
++)
1588 params
[i
] = FLOAT_TO_INT64(m
->m
[i
]);
1592 m
= *(GLmatrix
**) p
;
1593 for (i
= 0; i
< 16; i
++)
1594 params
[i
] = FLOAT_TO_INT64(m
->m
[transpose
[i
]]);
1605 shift
= d
->type
- TYPE_BIT_0
;
1606 params
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
1612 _mesa_GetDoublev(GLenum pname
, GLdouble
*params
)
1614 const struct value_desc
*d
;
1620 d
= find_value("glGetDoublev", pname
, &p
, &v
);
1625 params
[0] = d
->offset
;
1630 params
[3] = ((GLfloat
*) p
)[3];
1633 params
[2] = ((GLfloat
*) p
)[2];
1636 params
[1] = ((GLfloat
*) p
)[1];
1639 params
[0] = ((GLfloat
*) p
)[0];
1642 case TYPE_DOUBLEN_2
:
1643 params
[1] = ((GLdouble
*) p
)[1];
1645 params
[0] = ((GLdouble
*) p
)[0];
1649 params
[3] = ((GLint
*) p
)[3];
1651 params
[2] = ((GLint
*) p
)[2];
1654 params
[1] = ((GLint
*) p
)[1];
1657 params
[0] = ((GLint
*) p
)[0];
1661 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
1662 params
[i
] = v
.value_int_n
.ints
[i
];
1666 params
[0] = (GLdouble
) (((GLint64
*) p
)[0]);
1670 params
[0] = *(GLboolean
*) p
;
1674 m
= *(GLmatrix
**) p
;
1675 for (i
= 0; i
< 16; i
++)
1676 params
[i
] = m
->m
[i
];
1680 m
= *(GLmatrix
**) p
;
1681 for (i
= 0; i
< 16; i
++)
1682 params
[i
] = m
->m
[transpose
[i
]];
1693 shift
= d
->type
- TYPE_BIT_0
;
1694 params
[0] = (*(GLbitfield
*) p
>> shift
) & 1;
1699 static enum value_type
1700 find_value_indexed(const char *func
, GLenum pname
, GLuint index
, union value
*v
)
1702 GET_CURRENT_CONTEXT(ctx
);
1707 if (index
>= ctx
->Const
.MaxDrawBuffers
)
1709 if (!ctx
->Extensions
.EXT_draw_buffers2
)
1711 v
->value_int
= (ctx
->Color
.BlendEnabled
>> index
) & 1;
1716 case GL_BLEND_SRC_RGB
:
1717 if (index
>= ctx
->Const
.MaxDrawBuffers
)
1719 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
1721 v
->value_int
= ctx
->Color
.Blend
[index
].SrcRGB
;
1723 case GL_BLEND_SRC_ALPHA
:
1724 if (index
>= ctx
->Const
.MaxDrawBuffers
)
1726 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
1728 v
->value_int
= ctx
->Color
.Blend
[index
].SrcA
;
1732 case GL_BLEND_DST_RGB
:
1733 if (index
>= ctx
->Const
.MaxDrawBuffers
)
1735 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
1737 v
->value_int
= ctx
->Color
.Blend
[index
].DstRGB
;
1739 case GL_BLEND_DST_ALPHA
:
1740 if (index
>= ctx
->Const
.MaxDrawBuffers
)
1742 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
1744 v
->value_int
= ctx
->Color
.Blend
[index
].DstA
;
1746 case GL_BLEND_EQUATION_RGB
:
1747 if (index
>= ctx
->Const
.MaxDrawBuffers
)
1749 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
1751 v
->value_int
= ctx
->Color
.Blend
[index
].EquationRGB
;
1753 case GL_BLEND_EQUATION_ALPHA
:
1754 if (index
>= ctx
->Const
.MaxDrawBuffers
)
1756 if (!ctx
->Extensions
.ARB_draw_buffers_blend
)
1758 v
->value_int
= ctx
->Color
.Blend
[index
].EquationA
;
1761 case GL_COLOR_WRITEMASK
:
1762 if (index
>= ctx
->Const
.MaxDrawBuffers
)
1764 if (!ctx
->Extensions
.EXT_draw_buffers2
)
1766 v
->value_int_4
[0] = ctx
->Color
.ColorMask
[index
][RCOMP
] ? 1 : 0;
1767 v
->value_int_4
[1] = ctx
->Color
.ColorMask
[index
][GCOMP
] ? 1 : 0;
1768 v
->value_int_4
[2] = ctx
->Color
.ColorMask
[index
][BCOMP
] ? 1 : 0;
1769 v
->value_int_4
[3] = ctx
->Color
.ColorMask
[index
][ACOMP
] ? 1 : 0;
1772 case GL_SCISSOR_BOX
:
1773 if (index
>= ctx
->Const
.MaxViewports
)
1775 v
->value_int_4
[0] = ctx
->Scissor
.ScissorArray
[index
].X
;
1776 v
->value_int_4
[1] = ctx
->Scissor
.ScissorArray
[index
].Y
;
1777 v
->value_int_4
[2] = ctx
->Scissor
.ScissorArray
[index
].Width
;
1778 v
->value_int_4
[3] = ctx
->Scissor
.ScissorArray
[index
].Height
;
1782 if (index
>= ctx
->Const
.MaxViewports
)
1784 v
->value_float_4
[0] = ctx
->ViewportArray
[index
].X
;
1785 v
->value_float_4
[1] = ctx
->ViewportArray
[index
].Y
;
1786 v
->value_float_4
[2] = ctx
->ViewportArray
[index
].Width
;
1787 v
->value_float_4
[3] = ctx
->ViewportArray
[index
].Height
;
1788 return TYPE_FLOAT_4
;
1790 case GL_DEPTH_RANGE
:
1791 if (index
>= ctx
->Const
.MaxViewports
)
1793 v
->value_double_2
[0] = ctx
->ViewportArray
[index
].Near
;
1794 v
->value_double_2
[1] = ctx
->ViewportArray
[index
].Far
;
1795 return TYPE_DOUBLEN_2
;
1797 case GL_TRANSFORM_FEEDBACK_BUFFER_START
:
1798 if (index
>= ctx
->Const
.MaxTransformFeedbackBuffers
)
1800 if (!ctx
->Extensions
.EXT_transform_feedback
)
1802 v
->value_int64
= ctx
->TransformFeedback
.CurrentObject
->Offset
[index
];
1805 case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE
:
1806 if (index
>= ctx
->Const
.MaxTransformFeedbackBuffers
)
1808 if (!ctx
->Extensions
.EXT_transform_feedback
)
1811 = ctx
->TransformFeedback
.CurrentObject
->RequestedSize
[index
];
1814 case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING
:
1815 if (index
>= ctx
->Const
.MaxTransformFeedbackBuffers
)
1817 if (!ctx
->Extensions
.EXT_transform_feedback
)
1819 v
->value_int
= ctx
->TransformFeedback
.CurrentObject
->BufferNames
[index
];
1822 case GL_UNIFORM_BUFFER_BINDING
:
1823 if (index
>= ctx
->Const
.MaxUniformBufferBindings
)
1825 if (!ctx
->Extensions
.ARB_uniform_buffer_object
)
1827 v
->value_int
= ctx
->UniformBufferBindings
[index
].BufferObject
->Name
;
1830 case GL_UNIFORM_BUFFER_START
:
1831 if (index
>= ctx
->Const
.MaxUniformBufferBindings
)
1833 if (!ctx
->Extensions
.ARB_uniform_buffer_object
)
1835 v
->value_int
= ctx
->UniformBufferBindings
[index
].Offset
;
1838 case GL_UNIFORM_BUFFER_SIZE
:
1839 if (index
>= ctx
->Const
.MaxUniformBufferBindings
)
1841 if (!ctx
->Extensions
.ARB_uniform_buffer_object
)
1843 v
->value_int
= ctx
->UniformBufferBindings
[index
].Size
;
1846 /* ARB_texture_multisample / GL3.2 */
1847 case GL_SAMPLE_MASK_VALUE
:
1850 if (!ctx
->Extensions
.ARB_texture_multisample
)
1852 v
->value_int
= ctx
->Multisample
.SampleMaskValue
;
1855 case GL_ATOMIC_COUNTER_BUFFER_BINDING
:
1856 if (!ctx
->Extensions
.ARB_shader_atomic_counters
)
1858 if (index
>= ctx
->Const
.MaxAtomicBufferBindings
)
1860 v
->value_int
= ctx
->AtomicBufferBindings
[index
].BufferObject
->Name
;
1863 case GL_ATOMIC_COUNTER_BUFFER_START
:
1864 if (!ctx
->Extensions
.ARB_shader_atomic_counters
)
1866 if (index
>= ctx
->Const
.MaxAtomicBufferBindings
)
1868 v
->value_int64
= ctx
->AtomicBufferBindings
[index
].Offset
;
1871 case GL_ATOMIC_COUNTER_BUFFER_SIZE
:
1872 if (!ctx
->Extensions
.ARB_shader_atomic_counters
)
1874 if (index
>= ctx
->Const
.MaxAtomicBufferBindings
)
1876 v
->value_int64
= ctx
->AtomicBufferBindings
[index
].Size
;
1879 case GL_VERTEX_BINDING_DIVISOR
:
1880 if (!_mesa_is_desktop_gl(ctx
) || !ctx
->Extensions
.ARB_instanced_arrays
)
1882 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
)
1884 v
->value_int
= ctx
->Array
.VAO
->VertexBinding
[VERT_ATTRIB_GENERIC(index
)].InstanceDivisor
;
1887 case GL_VERTEX_BINDING_OFFSET
:
1888 if (!_mesa_is_desktop_gl(ctx
))
1890 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
)
1892 v
->value_int
= ctx
->Array
.VAO
->VertexBinding
[VERT_ATTRIB_GENERIC(index
)].Offset
;
1895 case GL_VERTEX_BINDING_STRIDE
:
1896 if (!_mesa_is_desktop_gl(ctx
))
1898 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
)
1900 v
->value_int
= ctx
->Array
.VAO
->VertexBinding
[VERT_ATTRIB_GENERIC(index
)].Stride
;
1902 /* ARB_shader_image_load_store */
1903 case GL_IMAGE_BINDING_NAME
: {
1904 struct gl_texture_object
*t
;
1906 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
1908 if (index
>= ctx
->Const
.MaxImageUnits
)
1911 t
= ctx
->ImageUnits
[index
].TexObj
;
1912 v
->value_int
= (t
? t
->Name
: 0);
1916 case GL_IMAGE_BINDING_LEVEL
:
1917 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
1919 if (index
>= ctx
->Const
.MaxImageUnits
)
1922 v
->value_int
= ctx
->ImageUnits
[index
].Level
;
1925 case GL_IMAGE_BINDING_LAYERED
:
1926 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
1928 if (index
>= ctx
->Const
.MaxImageUnits
)
1931 v
->value_int
= ctx
->ImageUnits
[index
].Layered
;
1934 case GL_IMAGE_BINDING_LAYER
:
1935 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
1937 if (index
>= ctx
->Const
.MaxImageUnits
)
1940 v
->value_int
= ctx
->ImageUnits
[index
].Layer
;
1943 case GL_IMAGE_BINDING_ACCESS
:
1944 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
1946 if (index
>= ctx
->Const
.MaxImageUnits
)
1949 v
->value_int
= ctx
->ImageUnits
[index
].Access
;
1952 case GL_IMAGE_BINDING_FORMAT
:
1953 if (!ctx
->Extensions
.ARB_shader_image_load_store
)
1955 if (index
>= ctx
->Const
.MaxImageUnits
)
1958 v
->value_int
= ctx
->ImageUnits
[index
].Format
;
1961 case GL_MAX_COMPUTE_WORK_GROUP_COUNT
:
1962 if (!_mesa_is_desktop_gl(ctx
) || !ctx
->Extensions
.ARB_compute_shader
)
1966 v
->value_int
= ctx
->Const
.MaxComputeWorkGroupCount
[index
];
1969 case GL_MAX_COMPUTE_WORK_GROUP_SIZE
:
1970 if (!_mesa_is_desktop_gl(ctx
) || !ctx
->Extensions
.ARB_compute_shader
)
1974 v
->value_int
= ctx
->Const
.MaxComputeWorkGroupSize
[index
];
1979 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(pname=%s)", func
,
1980 _mesa_lookup_enum_by_nr(pname
));
1981 return TYPE_INVALID
;
1983 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(pname=%s)", func
,
1984 _mesa_lookup_enum_by_nr(pname
));
1985 return TYPE_INVALID
;
1989 _mesa_GetBooleani_v( GLenum pname
, GLuint index
, GLboolean
*params
)
1992 enum value_type type
=
1993 find_value_indexed("glGetBooleani_v", pname
, index
, &v
);
1997 params
[0] = INT_TO_BOOLEAN(v
.value_int
);
2000 params
[0] = INT_TO_BOOLEAN(v
.value_int_4
[0]);
2001 params
[1] = INT_TO_BOOLEAN(v
.value_int_4
[1]);
2002 params
[2] = INT_TO_BOOLEAN(v
.value_int_4
[2]);
2003 params
[3] = INT_TO_BOOLEAN(v
.value_int_4
[3]);
2006 params
[0] = INT64_TO_BOOLEAN(v
.value_int64
);
2009 ; /* nothing - GL error was recorded */
2014 _mesa_GetIntegeri_v( GLenum pname
, GLuint index
, GLint
*params
)
2017 enum value_type type
=
2018 find_value_indexed("glGetIntegeri_v", pname
, index
, &v
);
2023 params
[3] = IROUND(v
.value_float_4
[3]);
2026 params
[2] = IROUND(v
.value_float_4
[2]);
2029 params
[1] = IROUND(v
.value_float_4
[1]);
2032 params
[0] = IROUND(v
.value_float_4
[0]);
2035 case TYPE_DOUBLEN_2
:
2036 params
[1] = IROUND(v
.value_double_2
[1]);
2038 params
[0] = IROUND(v
.value_double_2
[0]);
2042 params
[0] = v
.value_int
;
2045 params
[0] = v
.value_int_4
[0];
2046 params
[1] = v
.value_int_4
[1];
2047 params
[2] = v
.value_int_4
[2];
2048 params
[3] = v
.value_int_4
[3];
2051 params
[0] = INT64_TO_INT(v
.value_int64
);
2054 ; /* nothing - GL error was recorded */
2059 _mesa_GetInteger64i_v( GLenum pname
, GLuint index
, GLint64
*params
)
2062 enum value_type type
=
2063 find_value_indexed("glGetInteger64i_v", pname
, index
, &v
);
2067 params
[0] = v
.value_int
;
2070 params
[0] = v
.value_int_4
[0];
2071 params
[1] = v
.value_int_4
[1];
2072 params
[2] = v
.value_int_4
[2];
2073 params
[3] = v
.value_int_4
[3];
2076 params
[0] = v
.value_int64
;
2079 ; /* nothing - GL error was recorded */
2084 _mesa_GetFloati_v(GLenum pname
, GLuint index
, GLfloat
*params
)
2089 enum value_type type
=
2090 find_value_indexed("glGetFloati_v", pname
, index
, &v
);
2095 params
[3] = v
.value_float_4
[3];
2098 params
[2] = v
.value_float_4
[2];
2101 params
[1] = v
.value_float_4
[1];
2104 params
[0] = v
.value_float_4
[0];
2107 case TYPE_DOUBLEN_2
:
2108 params
[1] = (GLfloat
) v
.value_double_2
[1];
2110 params
[0] = (GLfloat
) v
.value_double_2
[0];
2114 params
[3] = (GLfloat
) v
.value_int_4
[3];
2116 params
[2] = (GLfloat
) v
.value_int_4
[2];
2119 params
[1] = (GLfloat
) v
.value_int_4
[1];
2122 params
[0] = (GLfloat
) v
.value_int_4
[0];
2126 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
2127 params
[i
] = INT_TO_FLOAT(v
.value_int_n
.ints
[i
]);
2131 params
[0] = (GLfloat
) v
.value_int64
;
2135 params
[0] = BOOLEAN_TO_FLOAT(v
.value_bool
);
2139 m
= *(GLmatrix
**) &v
;
2140 for (i
= 0; i
< 16; i
++)
2141 params
[i
] = m
->m
[i
];
2145 m
= *(GLmatrix
**) &v
;
2146 for (i
= 0; i
< 16; i
++)
2147 params
[i
] = m
->m
[transpose
[i
]];
2156 _mesa_GetDoublei_v(GLenum pname
, GLuint index
, GLdouble
*params
)
2161 enum value_type type
=
2162 find_value_indexed("glGetDoublei_v", pname
, index
, &v
);
2167 params
[3] = (GLdouble
) v
.value_float_4
[3];
2170 params
[2] = (GLdouble
) v
.value_float_4
[2];
2173 params
[1] = (GLdouble
) v
.value_float_4
[1];
2176 params
[0] = (GLdouble
) v
.value_float_4
[0];
2179 case TYPE_DOUBLEN_2
:
2180 params
[1] = v
.value_double_2
[1];
2182 params
[0] = v
.value_double_2
[0];
2186 params
[3] = (GLdouble
) v
.value_int_4
[3];
2188 params
[2] = (GLdouble
) v
.value_int_4
[2];
2191 params
[1] = (GLdouble
) v
.value_int_4
[1];
2194 params
[0] = (GLdouble
) v
.value_int_4
[0];
2198 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
2199 params
[i
] = (GLdouble
) INT_TO_FLOAT(v
.value_int_n
.ints
[i
]);
2203 params
[0] = (GLdouble
) v
.value_int64
;
2207 params
[0] = (GLdouble
) BOOLEAN_TO_FLOAT(v
.value_bool
);
2211 m
= *(GLmatrix
**) &v
;
2212 for (i
= 0; i
< 16; i
++)
2213 params
[i
] = (GLdouble
) m
->m
[i
];
2217 m
= *(GLmatrix
**) &v
;
2218 for (i
= 0; i
< 16; i
++)
2219 params
[i
] = (GLdouble
) m
->m
[transpose
[i
]];
2228 _mesa_GetFixedv(GLenum pname
, GLfixed
*params
)
2230 const struct value_desc
*d
;
2236 d
= find_value("glGetDoublev", pname
, &p
, &v
);
2241 params
[0] = INT_TO_FIXED(d
->offset
);
2246 params
[3] = FLOAT_TO_FIXED(((GLfloat
*) p
)[3]);
2249 params
[2] = FLOAT_TO_FIXED(((GLfloat
*) p
)[2]);
2252 params
[1] = FLOAT_TO_FIXED(((GLfloat
*) p
)[1]);
2255 params
[0] = FLOAT_TO_FIXED(((GLfloat
*) p
)[0]);
2258 case TYPE_DOUBLEN_2
:
2259 params
[1] = FLOAT_TO_FIXED(((GLdouble
*) p
)[1]);
2261 params
[0] = FLOAT_TO_FIXED(((GLdouble
*) p
)[0]);
2265 params
[3] = INT_TO_FIXED(((GLint
*) p
)[3]);
2267 params
[2] = INT_TO_FIXED(((GLint
*) p
)[2]);
2270 params
[1] = INT_TO_FIXED(((GLint
*) p
)[1]);
2273 params
[0] = INT_TO_FIXED(((GLint
*) p
)[0]);
2277 for (i
= 0; i
< v
.value_int_n
.n
; i
++)
2278 params
[i
] = INT_TO_FIXED(v
.value_int_n
.ints
[i
]);
2282 params
[0] = ((GLint64
*) p
)[0];
2286 params
[0] = BOOLEAN_TO_FIXED(((GLboolean
*) p
)[0]);
2290 m
= *(GLmatrix
**) p
;
2291 for (i
= 0; i
< 16; i
++)
2292 params
[i
] = FLOAT_TO_FIXED(m
->m
[i
]);
2296 m
= *(GLmatrix
**) p
;
2297 for (i
= 0; i
< 16; i
++)
2298 params
[i
] = FLOAT_TO_FIXED(m
->m
[transpose
[i
]]);
2309 shift
= d
->type
- TYPE_BIT_0
;
2310 params
[0] = BOOLEAN_TO_FIXED((*(GLbitfield
*) p
>> shift
) & 1);