2
* Copyright (C) 2010 Brian Paul All Rights Reserved.
3
* Copyright (C) 2010 Intel Corporation
5
* Permission is hereby granted, free of charge, to any person obtaining a
6
* copy of this software and associated documentation files (the "Software"),
7
* to deal in the Software without restriction, including without limitation
8
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
9
* and/or sell copies of the Software, and to permit persons to whom the
10
* Software is furnished to do so, subject to the following conditions:
12
* The above copyright notice and this permission notice shall be included
13
* in all copies or substantial portions of the Software.
15
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
19
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
21
* OTHER DEALINGS IN THE SOFTWARE.
23
* Author: Kristian Høgsberg <krh@bitplanet.net>
29
#include "debug_output.h"
33
#include "extensions.h"
36
#include "multisample.h"
39
#include "spirv_extensions.h"
41
#include "texcompress.h"
43
#include "framebuffer.h"
44
#include "samplerobj.h"
48
#include "state_tracker/st_context.h"
49
#include "api_exec_decl.h"
51
/* This is a table driven implemetation of the glGet*v() functions.
52
* The basic idea is that most getters just look up an int somewhere
53
* in struct gl_context and then convert it to a bool or float according to
54
* which of glGetIntegerv() glGetBooleanv() etc is being called.
55
* Instead of generating code to do this, we can just record the enum
56
* value and the offset into struct gl_context in an array of structs. Then
57
* in glGet*(), we lookup the struct for the enum in question, and use
58
* the offset to get the int we need.
60
* Sometimes we need to look up a float, a boolean, a bit in a
61
* bitfield, a matrix or other types instead, so we need to track the
62
* type of the value in struct gl_context. And sometimes the value isn't in
63
* struct gl_context but in the drawbuffer, the array object, current texture
64
* unit, or maybe it's a computed value. So we need to also track
65
* where or how to find the value. Finally, we sometimes need to
66
* check that one of a number of extensions are enabled, the GL
67
* version or flush or call _mesa_update_state(). This is done by
68
* attaching optional extra information to the value description
69
* struct, it's sort of like an array of opcodes that describe extra
72
* Putting all this together we end up with struct value_desc below,
73
* and with a couple of macros to help, the table of struct value_desc
74
* is about as concise as the specification in the old python script.
77
static inline GLboolean
78
FLOAT_TO_BOOLEAN(GLfloat X)
80
return ( (X) ? GL_TRUE : GL_FALSE );
84
FLOAT_TO_FIXED(GLfloat F)
86
return ( ((F) * 65536.0f > INT_MAX) ? INT_MAX :
87
((F) * 65536.0f < INT_MIN) ? INT_MIN :
88
(GLint) ((F) * 65536.0f) );
91
static inline GLboolean
92
INT_TO_BOOLEAN(GLint I)
94
return ( (I) ? GL_TRUE : GL_FALSE );
100
return (((I) > SHRT_MAX) ? INT_MAX :
101
((I) < SHRT_MIN) ? INT_MIN :
102
(GLint) ((I) * 65536) );
106
static inline GLboolean
107
INT64_TO_BOOLEAN(GLint64 I)
109
return ( (I) ? GL_TRUE : GL_FALSE );
113
INT64_TO_INT(GLint64 I)
115
return ( (GLint)((I > INT_MAX) ? INT_MAX : ((I < INT_MIN) ? INT_MIN : (I))) );
119
BOOLEAN_TO_INT(GLboolean B)
121
return ( (GLint) (B) );
124
static inline GLfloat
125
BOOLEAN_TO_FLOAT(GLboolean B)
127
return ( (B) ? 1.0F : 0.0F );
130
static inline GLfixed
131
BOOLEAN_TO_FIXED(GLboolean B)
133
return ( (GLint) ((B) ? 1 : 0) << 16 );
178
enum value_location {
200
EXTRA_VALID_DRAW_BUFFER,
201
EXTRA_VALID_TEXTURE_UNIT,
202
EXTRA_VALID_CLIP_DISTANCE,
206
EXTRA_EXT_ATOMICS_GS,
207
EXTRA_EXT_SHADER_IMAGE_GS,
208
EXTRA_EXT_ATOMICS_TESS,
209
EXTRA_EXT_SHADER_IMAGE_TESS,
211
EXTRA_EXT_FB_NO_ATTACH_GS,
213
EXTRA_EXT_PROVOKING_VERTEX_32,
216
#define NO_EXTRA NULL
221
GLubyte location; /**< enum value_location */
222
GLubyte type; /**< enum value_type */
229
GLfloat value_float_4[4];
230
GLdouble value_double_2[2];
231
GLmatrix *value_matrix;
233
GLint value_int_4[4];
236
GLenum16 value_enum16;
241
/* Sigh, see GL_COMPRESSED_TEXTURE_FORMATS_ARB handling */
245
GLboolean value_bool;
248
#define BUFFER_FIELD(field, type) \
249
LOC_BUFFER, type, offsetof(struct gl_framebuffer, field)
250
#define CONTEXT_FIELD(field, type) \
251
LOC_CONTEXT, type, offsetof(struct gl_context, field)
252
#define ARRAY_FIELD(field, type) \
253
LOC_ARRAY, type, offsetof(struct gl_vertex_array_object, field)
254
#undef CONST /* already defined through windows.h */
255
#define CONST(value) \
256
LOC_CONTEXT, TYPE_CONST, value
258
#define BUFFER_INT(field) BUFFER_FIELD(field, TYPE_INT)
259
#define BUFFER_ENUM(field) BUFFER_FIELD(field, TYPE_ENUM)
260
#define BUFFER_ENUM16(field) BUFFER_FIELD(field, TYPE_ENUM16)
261
#define BUFFER_BOOL(field) BUFFER_FIELD(field, TYPE_BOOLEAN)
263
#define CONTEXT_INT(field) CONTEXT_FIELD(field, TYPE_INT)
264
#define CONTEXT_INT2(field) CONTEXT_FIELD(field, TYPE_INT_2)
265
#define CONTEXT_INT64(field) CONTEXT_FIELD(field, TYPE_INT64)
266
#define CONTEXT_UINT(field) CONTEXT_FIELD(field, TYPE_UINT)
267
#define CONTEXT_ENUM16(field) CONTEXT_FIELD(field, TYPE_ENUM16)
268
#define CONTEXT_ENUM(field) CONTEXT_FIELD(field, TYPE_ENUM)
269
#define CONTEXT_ENUM2(field) CONTEXT_FIELD(field, TYPE_ENUM_2)
270
#define CONTEXT_BOOL(field) CONTEXT_FIELD(field, TYPE_BOOLEAN)
271
#define CONTEXT_BIT0(field) CONTEXT_FIELD(field, TYPE_BIT_0)
272
#define CONTEXT_BIT1(field) CONTEXT_FIELD(field, TYPE_BIT_1)
273
#define CONTEXT_BIT2(field) CONTEXT_FIELD(field, TYPE_BIT_2)
274
#define CONTEXT_BIT3(field) CONTEXT_FIELD(field, TYPE_BIT_3)
275
#define CONTEXT_BIT4(field) CONTEXT_FIELD(field, TYPE_BIT_4)
276
#define CONTEXT_BIT5(field) CONTEXT_FIELD(field, TYPE_BIT_5)
277
#define CONTEXT_BIT6(field) CONTEXT_FIELD(field, TYPE_BIT_6)
278
#define CONTEXT_BIT7(field) CONTEXT_FIELD(field, TYPE_BIT_7)
279
#define CONTEXT_FLOAT(field) CONTEXT_FIELD(field, TYPE_FLOAT)
280
#define CONTEXT_FLOAT2(field) CONTEXT_FIELD(field, TYPE_FLOAT_2)
281
#define CONTEXT_FLOAT3(field) CONTEXT_FIELD(field, TYPE_FLOAT_3)
282
#define CONTEXT_FLOAT4(field) CONTEXT_FIELD(field, TYPE_FLOAT_4)
283
#define CONTEXT_FLOAT8(field) CONTEXT_FIELD(field, TYPE_FLOAT_8)
284
#define CONTEXT_MATRIX(field) CONTEXT_FIELD(field, TYPE_MATRIX)
285
#define CONTEXT_MATRIX_T(field) CONTEXT_FIELD(field, TYPE_MATRIX_T)
287
/* Vertex array fields */
288
#define ARRAY_INT(field) ARRAY_FIELD(field, TYPE_INT)
289
#define ARRAY_ENUM(field) ARRAY_FIELD(field, TYPE_ENUM)
290
#define ARRAY_ENUM16(field) ARRAY_FIELD(field, TYPE_ENUM16)
291
#define ARRAY_BOOL(field) ARRAY_FIELD(field, TYPE_BOOLEAN)
292
#define ARRAY_UBYTE(field) ARRAY_FIELD(field, TYPE_UBYTE)
293
#define ARRAY_SHORT(field) ARRAY_FIELD(field, TYPE_SHORT)
296
offsetof(struct gl_extensions, f)
298
#define EXTRA_EXT(e) \
299
static const int extra_##e[] = { \
303
#define EXTRA_EXT2(e1, e2) \
304
static const int extra_##e1##_##e2[] = { \
305
EXT(e1), EXT(e2), EXTRA_END \
308
/* The 'extra' mechanism is a way to specify extra checks (such as
309
* extensions or specific gl versions) or actions (flush current, new
310
* buffers) that we need to do before looking up an enum. We need to
311
* declare them all up front so we can refer to them in the value_desc
314
* Each EXTRA_ will be executed. For EXTRA_* enums of extensions and API
315
* versions, listing multiple ones in an array means an error will be thrown
316
* only if none of them are available. If you need to check for "AND"
317
* behavior, you would need to make a custom EXTRA_ enum.
320
static const int extra_new_buffers[] = {
325
static const int extra_valid_draw_buffer[] = {
326
EXTRA_VALID_DRAW_BUFFER,
330
static const int extra_valid_texture_unit[] = {
331
EXTRA_VALID_TEXTURE_UNIT,
335
static const int extra_valid_clip_distance[] = {
336
EXTRA_VALID_CLIP_DISTANCE,
340
static const int extra_flush_current_valid_texture_unit[] = {
342
EXTRA_VALID_TEXTURE_UNIT,
346
static const int extra_flush_current[] = {
351
static const int extra_EXT_texture_integer_and_new_buffers[] = {
352
EXT(EXT_texture_integer),
357
static const int extra_GLSL_130_es3_gpushader4[] = {
360
EXT(EXT_gpu_shader4),
364
static const int extra_texture_buffer_object[] = {
365
EXT(ARB_texture_buffer_object),
369
static const int extra_ARB_transform_feedback2_api_es3[] = {
370
EXT(ARB_transform_feedback2),
375
static const int extra_ARB_uniform_buffer_object_and_geometry_shader[] = {
380
static const int extra_ARB_ES2_compatibility_api_es2[] = {
381
EXT(ARB_ES2_compatibility),
386
static const int extra_ARB_ES3_compatibility_api_es3[] = {
387
EXT(ARB_ES3_compatibility),
392
static const int extra_EXT_framebuffer_sRGB_and_new_buffers[] = {
393
EXT(EXT_framebuffer_sRGB),
398
static const int extra_EXT_packed_float[] = {
399
EXT(EXT_packed_float),
404
static const int extra_EXT_texture_array_es3[] = {
405
EXT(EXT_texture_array),
410
static const int extra_ARB_shader_atomic_counters_and_geometry_shader[] = {
411
EXTRA_EXT_ATOMICS_GS,
415
static const int extra_ARB_shader_atomic_counters_es31[] = {
416
EXT(ARB_shader_atomic_counters),
421
static const int extra_ARB_shader_image_load_store_and_geometry_shader[] = {
422
EXTRA_EXT_SHADER_IMAGE_GS,
426
static const int extra_ARB_shader_atomic_counters_and_tessellation[] = {
427
EXTRA_EXT_ATOMICS_TESS,
431
static const int extra_ARB_shader_image_load_store_and_tessellation[] = {
432
EXTRA_EXT_SHADER_IMAGE_TESS,
436
static const int extra_ARB_shader_image_load_store_es31[] = {
437
EXT(ARB_shader_image_load_store),
442
/* HACK: remove when ARB_compute_shader is actually supported */
443
static const int extra_ARB_compute_shader_es31[] = {
444
EXT(ARB_compute_shader),
449
static const int extra_ARB_shader_storage_buffer_object_es31[] = {
450
EXT(ARB_shader_storage_buffer_object),
455
static const int extra_ARB_shader_storage_buffer_object_and_geometry_shader[] = {
460
static const int extra_ARB_shader_image_load_store_shader_storage_buffer_object_es31[] = {
461
EXT(ARB_shader_image_load_store),
462
EXT(ARB_shader_storage_buffer_object),
467
static const int extra_ARB_framebuffer_no_attachments_and_geometry_shader[] = {
468
EXTRA_EXT_FB_NO_ATTACH_GS,
472
static const int extra_ARB_viewport_array_or_oes_geometry_shader[] = {
473
EXT(ARB_viewport_array),
478
static const int extra_ARB_viewport_array_or_oes_viewport_array[] = {
479
EXT(ARB_viewport_array),
480
EXT(OES_viewport_array),
484
static const int extra_ARB_gpu_shader5_or_oes_geometry_shader[] = {
485
EXT(ARB_gpu_shader5),
490
static const int extra_ARB_gpu_shader5_or_OES_sample_variables[] = {
491
EXT(ARB_gpu_shader5),
492
EXT(OES_sample_variables),
496
static const int extra_ES32[] = {
497
EXT(ARB_ES3_2_compatibility),
502
static const int extra_KHR_robustness_or_GL[] = {
509
static const int extra_INTEL_conservative_rasterization[] = {
510
EXT(INTEL_conservative_rasterization),
514
static const int extra_ARB_timer_query_or_EXT_disjoint_timer_query[] = {
515
EXT(ARB_timer_query),
516
EXT(EXT_disjoint_timer_query),
520
static const int extra_ARB_framebuffer_object_or_EXT_framebuffer_multisample_or_EXT_multisampled_render_to_texture[] = {
521
EXT(ARB_framebuffer_object),
522
EXT(EXT_framebuffer_multisample),
523
EXT(EXT_multisampled_render_to_texture),
527
EXTRA_EXT(EXT_texture_array);
528
EXTRA_EXT(NV_fog_distance);
529
EXTRA_EXT(EXT_texture_filter_anisotropic);
530
EXTRA_EXT(NV_texture_rectangle);
531
EXTRA_EXT(EXT_stencil_two_side);
532
EXTRA_EXT(EXT_depth_bounds_test);
533
EXTRA_EXT(ARB_depth_clamp);
534
EXTRA_EXT(AMD_depth_clamp_separate);
535
EXTRA_EXT(ATI_fragment_shader);
536
EXTRA_EXT(EXT_provoking_vertex);
537
EXTRA_EXT(ARB_fragment_shader);
538
EXTRA_EXT(ARB_fragment_program);
539
EXTRA_EXT(ARB_seamless_cube_map);
541
EXTRA_EXT(ARB_vertex_shader);
542
EXTRA_EXT(EXT_transform_feedback);
543
EXTRA_EXT(ARB_transform_feedback3);
544
EXTRA_EXT(EXT_pixel_buffer_object);
545
EXTRA_EXT(ARB_vertex_program);
546
EXTRA_EXT(ARB_point_sprite);
547
EXTRA_EXT2(ARB_vertex_program, ARB_fragment_program);
548
EXTRA_EXT(ARB_color_buffer_float);
549
EXTRA_EXT(EXT_framebuffer_sRGB);
550
EXTRA_EXT(OES_EGL_image_external);
551
EXTRA_EXT(ARB_blend_func_extended);
552
EXTRA_EXT(ARB_uniform_buffer_object);
553
EXTRA_EXT2(ARB_texture_cube_map_array, OES_texture_cube_map_array);
554
EXTRA_EXT(ARB_texture_buffer_range);
555
EXTRA_EXT(ARB_texture_multisample);
556
EXTRA_EXT(ARB_texture_gather);
557
EXTRA_EXT(ARB_draw_indirect);
558
EXTRA_EXT(ARB_shader_image_load_store);
559
EXTRA_EXT(ARB_query_buffer_object);
560
EXTRA_EXT2(ARB_transform_feedback3, ARB_gpu_shader5);
561
EXTRA_EXT(INTEL_performance_query);
562
EXTRA_EXT(ARB_explicit_uniform_location);
563
EXTRA_EXT(ARB_clip_control);
564
EXTRA_EXT(ARB_polygon_offset_clamp);
565
EXTRA_EXT(ARB_framebuffer_no_attachments);
566
EXTRA_EXT(ARB_tessellation_shader);
567
EXTRA_EXT(ARB_shader_storage_buffer_object);
568
EXTRA_EXT(ARB_indirect_parameters);
569
EXTRA_EXT(ATI_meminfo);
570
EXTRA_EXT(NVX_gpu_memory_info);
571
EXTRA_EXT(ARB_cull_distance);
572
EXTRA_EXT(EXT_window_rectangles);
573
EXTRA_EXT(KHR_blend_equation_advanced_coherent);
574
EXTRA_EXT(OES_primitive_bounding_box);
575
EXTRA_EXT(ARB_compute_variable_group_size);
576
EXTRA_EXT(KHR_robustness);
577
EXTRA_EXT(ARB_sparse_buffer);
578
EXTRA_EXT(NV_conservative_raster);
579
EXTRA_EXT(NV_conservative_raster_dilate);
580
EXTRA_EXT(NV_conservative_raster_pre_snap_triangles);
581
EXTRA_EXT(ARB_sample_locations);
582
EXTRA_EXT(AMD_framebuffer_multisample_advanced);
583
EXTRA_EXT(ARB_spirv_extensions);
584
EXTRA_EXT(NV_viewport_swizzle);
585
EXTRA_EXT(ARB_sparse_texture);
588
extra_ARB_color_buffer_float_or_glcore[] = {
589
EXT(ARB_color_buffer_float),
595
extra_NV_primitive_restart[] = {
596
EXT(NV_primitive_restart),
600
static const int extra_version_30[] = { EXTRA_VERSION_30, EXTRA_END };
601
static const int extra_version_31[] = { EXTRA_VERSION_31, EXTRA_END };
602
static const int extra_version_32[] = { EXTRA_VERSION_32, EXTRA_END };
603
static const int extra_version_43[] = { EXTRA_VERSION_43, EXTRA_END };
605
static const int extra_gl30_es3[] = {
611
static const int extra_gl32_es3[] = {
617
static const int extra_version_32_OES_geometry_shader[] = {
623
static const int extra_gl40_ARB_sample_shading[] = {
625
EXT(ARB_sample_shading),
630
extra_ARB_vertex_program_api_es2[] = {
631
EXT(ARB_vertex_program),
636
/* The ReadBuffer get token is valid under either full GL or under
637
* GLES2 if the NV_read_buffer extension is available. */
639
extra_NV_read_buffer_api_gl[] = {
645
static const int extra_core_ARB_color_buffer_float_and_new_buffers[] = {
647
EXT(ARB_color_buffer_float),
652
static const int extra_EXT_shader_framebuffer_fetch[] = {
655
EXT(EXT_shader_framebuffer_fetch),
659
static const int extra_EXT_provoking_vertex_32[] = {
660
EXTRA_EXT_PROVOKING_VERTEX_32,
664
static const int extra_EXT_disjoint_timer_query[] = {
667
EXT(EXT_disjoint_timer_query),
672
/* This is the big table describing all the enums we accept in
673
* glGet*v(). The table is partitioned into six parts: enums
674
* understood by all GL APIs (OpenGL, GLES and GLES2), enums shared
675
* between OpenGL and GLES, enums exclusive to GLES, etc for the
676
* remaining combinations. To look up the enums valid in a given API
677
* we will use a hash table specific to that API. These tables are in
678
* turn generated at build time and included through get_hash.h.
681
#include "get_hash.h"
683
/* All we need now is a way to look up the value struct from the enum.
684
* The code generated by gcc for the old generated big switch
685
* statement is a big, balanced, open coded if/else tree, essentially
686
* an unrolled binary search. It would be natural to sort the new
687
* enum table and use bsearch(), but we will use a read-only hash
688
* table instead. bsearch() has a nice guaranteed worst case
689
* performance, but we're also guaranteed to hit that worst case
690
* (log2(n) iterations) for about half the enums. Instead, using an
691
* open addressing hash table, we can find the enum on the first try
692
* for 80% of the enums, 1 collision for 10% and never more than 5
693
* collisions for any enum (typical numbers). And the code is very
694
* simple, even though it feels a little magic. */
697
* Handle irregular enums
699
* Some values don't conform to the "well-known type at context
700
* pointer + offset" pattern, so we have this function to catch all
701
* the corner cases. Typically, it's a computed value or a one-off
702
* pointer to a custom struct or something.
704
* In this case we can't return a pointer to the value, so we'll have
705
* to use the temporary variable 'v' declared back in the calling
706
* glGet*v() function to store the result.
708
* \param ctx the current context
709
* \param d the struct value_desc that describes the enum
710
* \param v pointer to the tmp declared in the calling glGet*v() function
713
find_custom_value(struct gl_context *ctx, const struct value_desc *d, union value *v)
715
struct gl_buffer_object **buffer_obj, *buf;
716
struct gl_array_attributes *array;
720
case GL_MAJOR_VERSION:
721
v->value_int = ctx->Version / 10;
723
case GL_MINOR_VERSION:
724
v->value_int = ctx->Version % 10;
730
case GL_TEXTURE_CUBE_MAP:
731
case GL_TEXTURE_RECTANGLE_NV:
732
case GL_TEXTURE_EXTERNAL_OES:
733
v->value_bool = _mesa_IsEnabled(d->pname);
736
case GL_LINE_STIPPLE_PATTERN:
737
/* This is the only GLushort, special case it here by promoting
738
* to an int rather than introducing a new type. */
739
v->value_int = ctx->Line.StipplePattern;
742
case GL_CURRENT_RASTER_TEXTURE_COORDS:
743
unit = ctx->Texture.CurrentUnit;
744
v->value_float_4[0] = ctx->Current.RasterTexCoords[unit][0];
745
v->value_float_4[1] = ctx->Current.RasterTexCoords[unit][1];
746
v->value_float_4[2] = ctx->Current.RasterTexCoords[unit][2];
747
v->value_float_4[3] = ctx->Current.RasterTexCoords[unit][3];
750
case GL_CURRENT_TEXTURE_COORDS:
751
unit = ctx->Texture.CurrentUnit;
752
v->value_float_4[0] = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][0];
753
v->value_float_4[1] = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][1];
754
v->value_float_4[2] = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][2];
755
v->value_float_4[3] = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][3];
758
case GL_COLOR_WRITEMASK:
759
v->value_int_4[0] = GET_COLORMASK_BIT(ctx->Color.ColorMask, 0, 0);
760
v->value_int_4[1] = GET_COLORMASK_BIT(ctx->Color.ColorMask, 0, 1);
761
v->value_int_4[2] = GET_COLORMASK_BIT(ctx->Color.ColorMask, 0, 2);
762
v->value_int_4[3] = GET_COLORMASK_BIT(ctx->Color.ColorMask, 0, 3);
766
v->value_bool = ctx->Transform.DepthClampNear || ctx->Transform.DepthClampFar;
770
v->value_bool = ctx->Current.Attrib[VERT_ATTRIB_EDGEFLAG][0] == 1.0F;
774
v->value_enum16 = ctx->ReadBuffer->ColorReadBuffer;
777
case GL_MAP2_GRID_DOMAIN:
778
v->value_float_4[0] = ctx->Eval.MapGrid2u1;
779
v->value_float_4[1] = ctx->Eval.MapGrid2u2;
780
v->value_float_4[2] = ctx->Eval.MapGrid2v1;
781
v->value_float_4[3] = ctx->Eval.MapGrid2v2;
784
case GL_TEXTURE_STACK_DEPTH:
785
unit = ctx->Texture.CurrentUnit;
786
v->value_int = ctx->TextureMatrixStack[unit].Depth + 1;
788
case GL_TEXTURE_MATRIX:
789
unit = ctx->Texture.CurrentUnit;
790
v->value_matrix = ctx->TextureMatrixStack[unit].Top;
793
case GL_VERTEX_ARRAY:
794
v->value_bool = !!(ctx->Array.VAO->Enabled & VERT_BIT_POS);
796
case GL_NORMAL_ARRAY:
797
v->value_bool = !!(ctx->Array.VAO->Enabled & VERT_BIT_NORMAL);
800
v->value_bool = !!(ctx->Array.VAO->Enabled & VERT_BIT_COLOR0);
802
case GL_TEXTURE_COORD_ARRAY:
803
v->value_bool = !!(ctx->Array.VAO->Enabled & VERT_BIT_TEX(ctx->Array.ActiveTexture));
806
v->value_bool = !!(ctx->Array.VAO->Enabled & VERT_BIT_COLOR_INDEX);
808
case GL_EDGE_FLAG_ARRAY:
809
v->value_bool = !!(ctx->Array.VAO->Enabled & VERT_BIT_EDGEFLAG);
811
case GL_SECONDARY_COLOR_ARRAY:
812
v->value_bool = !!(ctx->Array.VAO->Enabled & VERT_BIT_COLOR1);
814
case GL_FOG_COORDINATE_ARRAY:
815
v->value_bool = !!(ctx->Array.VAO->Enabled & VERT_BIT_FOG);
817
case GL_POINT_SIZE_ARRAY_OES:
818
v->value_bool = !!(ctx->Array.VAO->Enabled & VERT_BIT_POINT_SIZE);
821
case GL_TEXTURE_COORD_ARRAY_TYPE:
822
case GL_TEXTURE_COORD_ARRAY_STRIDE:
823
array = &ctx->Array.VAO->VertexAttrib[VERT_ATTRIB_TEX(ctx->Array.ActiveTexture)];
824
v->value_int = *(GLuint *) ((char *) array + d->offset);
827
case GL_TEXTURE_COORD_ARRAY_SIZE:
828
array = &ctx->Array.VAO->VertexAttrib[VERT_ATTRIB_TEX(ctx->Array.ActiveTexture)];
829
v->value_int = array->Format.Size;
832
case GL_VERTEX_ARRAY_SIZE:
833
array = &ctx->Array.VAO->VertexAttrib[VERT_ATTRIB_POS];
834
v->value_int = array->Format.Size;
837
case GL_ACTIVE_TEXTURE_ARB:
838
v->value_int = GL_TEXTURE0_ARB + ctx->Texture.CurrentUnit;
840
case GL_CLIENT_ACTIVE_TEXTURE_ARB:
841
v->value_int = GL_TEXTURE0_ARB + ctx->Array.ActiveTexture;
844
case GL_MODELVIEW_STACK_DEPTH:
845
case GL_PROJECTION_STACK_DEPTH:
846
v->value_int = *(GLint *) ((char *) ctx + d->offset) + 1;
849
case GL_MAX_TEXTURE_SIZE:
850
case GL_MAX_3D_TEXTURE_SIZE:
851
case GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB:
852
p = (GLuint *) ((char *) ctx + d->offset);
853
v->value_int = 1 << (*p - 1);
857
v->value_int_4[0] = ctx->Scissor.ScissorArray[0].X;
858
v->value_int_4[1] = ctx->Scissor.ScissorArray[0].Y;
859
v->value_int_4[2] = ctx->Scissor.ScissorArray[0].Width;
860
v->value_int_4[3] = ctx->Scissor.ScissorArray[0].Height;
863
case GL_SCISSOR_TEST:
864
v->value_bool = ctx->Scissor.EnableFlags & 1;
869
ctx->ListState.CurrentList ? ctx->ListState.CurrentList->Name : 0;
872
if (!ctx->CompileFlag)
874
else if (ctx->ExecuteFlag)
875
v->value_enum16 = GL_COMPILE_AND_EXECUTE;
877
v->value_enum16 = GL_COMPILE;
881
v->value_float_4[0] = ctx->ViewportArray[0].X;
882
v->value_float_4[1] = ctx->ViewportArray[0].Y;
883
v->value_float_4[2] = ctx->ViewportArray[0].Width;
884
v->value_float_4[3] = ctx->ViewportArray[0].Height;
888
v->value_double_2[0] = ctx->ViewportArray[0].Near;
889
v->value_double_2[1] = ctx->ViewportArray[0].Far;
892
case GL_ACTIVE_STENCIL_FACE_EXT:
893
v->value_enum16 = ctx->Stencil.ActiveFace ? GL_BACK : GL_FRONT;
896
case GL_STENCIL_FAIL:
897
v->value_enum16 = ctx->Stencil.FailFunc[ctx->Stencil.ActiveFace];
899
case GL_STENCIL_FUNC:
900
v->value_enum16 = ctx->Stencil.Function[ctx->Stencil.ActiveFace];
902
case GL_STENCIL_PASS_DEPTH_FAIL:
903
v->value_enum16 = ctx->Stencil.ZFailFunc[ctx->Stencil.ActiveFace];
905
case GL_STENCIL_PASS_DEPTH_PASS:
906
v->value_enum16 = ctx->Stencil.ZPassFunc[ctx->Stencil.ActiveFace];
909
v->value_int = _mesa_get_stencil_ref(ctx, ctx->Stencil.ActiveFace);
911
case GL_STENCIL_BACK_REF:
912
v->value_int = _mesa_get_stencil_ref(ctx, 1);
914
case GL_STENCIL_VALUE_MASK:
915
v->value_int = ctx->Stencil.ValueMask[ctx->Stencil.ActiveFace];
917
case GL_STENCIL_WRITEMASK:
918
v->value_int = ctx->Stencil.WriteMask[ctx->Stencil.ActiveFace];
921
case GL_NUM_EXTENSIONS:
922
v->value_int = _mesa_get_extension_count(ctx);
925
case GL_IMPLEMENTATION_COLOR_READ_TYPE_OES:
926
v->value_int = _mesa_get_color_read_type(ctx, NULL, "glGetIntegerv");
928
case GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES:
929
v->value_int = _mesa_get_color_read_format(ctx, NULL, "glGetIntegerv");
932
case GL_CURRENT_MATRIX_STACK_DEPTH_ARB:
933
v->value_int = ctx->CurrentStack->Depth + 1;
935
case GL_CURRENT_MATRIX_ARB:
936
case GL_TRANSPOSE_CURRENT_MATRIX_ARB:
937
v->value_matrix = ctx->CurrentStack->Top;
940
case GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB:
941
v->value_int = _mesa_get_compressed_formats(ctx, NULL);
943
case GL_COMPRESSED_TEXTURE_FORMATS_ARB:
945
_mesa_get_compressed_formats(ctx, v->value_int_n.ints);
946
assert(v->value_int_n.n <= (int) ARRAY_SIZE(v->value_int_n.ints));
949
case GL_MAX_VARYING_FLOATS_ARB:
950
v->value_int = ctx->Const.MaxVarying * 4;
953
/* Various object names */
955
case GL_TEXTURE_BINDING_1D:
956
case GL_TEXTURE_BINDING_2D:
957
case GL_TEXTURE_BINDING_3D:
958
case GL_TEXTURE_BINDING_1D_ARRAY_EXT:
959
case GL_TEXTURE_BINDING_2D_ARRAY_EXT:
960
case GL_TEXTURE_BINDING_CUBE_MAP_ARB:
961
case GL_TEXTURE_BINDING_RECTANGLE_NV:
962
case GL_TEXTURE_BINDING_EXTERNAL_OES:
963
case GL_TEXTURE_BINDING_CUBE_MAP_ARRAY:
964
case GL_TEXTURE_BINDING_2D_MULTISAMPLE:
965
case GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY:
966
unit = ctx->Texture.CurrentUnit;
968
ctx->Texture.Unit[unit].CurrentTex[d->offset]->Name;
971
/* GL_EXT_external_objects */
972
case GL_NUM_DEVICE_UUIDS_EXT:
975
case GL_DRIVER_UUID_EXT:
976
_mesa_get_driver_uuid(ctx, v->value_int_4);
978
case GL_DEVICE_UUID_EXT:
979
_mesa_get_device_uuid(ctx, v->value_int_4);
982
/* GL_EXT_packed_float */
983
case GL_RGBA_SIGNED_COMPONENTS_EXT:
985
/* Note: we only check the 0th color attachment. */
986
const struct gl_renderbuffer *rb =
987
ctx->DrawBuffer->_ColorDrawBuffers[0];
988
if (rb && _mesa_is_format_signed(rb->Format)) {
989
/* Issue 17 of GL_EXT_packed_float: If a component (such as
990
* alpha) has zero bits, the component should not be considered
991
* signed and so the bit for the respective component should be
995
_mesa_get_format_bits(rb->Format, GL_RED_BITS);
997
_mesa_get_format_bits(rb->Format, GL_GREEN_BITS);
999
_mesa_get_format_bits(rb->Format, GL_BLUE_BITS);
1001
_mesa_get_format_bits(rb->Format, GL_ALPHA_BITS);
1003
_mesa_get_format_bits(rb->Format, GL_TEXTURE_LUMINANCE_SIZE);
1005
_mesa_get_format_bits(rb->Format, GL_TEXTURE_INTENSITY_SIZE);
1007
v->value_int_4[0] = r_bits + l_bits + i_bits > 0;
1008
v->value_int_4[1] = g_bits + l_bits + i_bits > 0;
1009
v->value_int_4[2] = b_bits + l_bits + i_bits > 0;
1010
v->value_int_4[3] = a_bits + i_bits > 0;
1016
v->value_int_4[3] = 0;
1021
/* GL_ARB_vertex_buffer_object */
1022
case GL_VERTEX_ARRAY_BUFFER_BINDING_ARB:
1023
case GL_NORMAL_ARRAY_BUFFER_BINDING_ARB:
1024
case GL_COLOR_ARRAY_BUFFER_BINDING_ARB:
1025
case GL_INDEX_ARRAY_BUFFER_BINDING_ARB:
1026
case GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB:
1027
case GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB:
1028
case GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB:
1029
buffer_obj = (struct gl_buffer_object **)
1030
((char *) ctx->Array.VAO + d->offset);
1031
v->value_int = (*buffer_obj) ? (*buffer_obj)->Name : 0;
1033
case GL_ARRAY_BUFFER_BINDING_ARB:
1034
buf = ctx->Array.ArrayBufferObj;
1035
v->value_int = buf ? buf->Name : 0;
1037
case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB:
1038
buf = ctx->Array.VAO->BufferBinding[VERT_ATTRIB_TEX(ctx->Array.ActiveTexture)].BufferObj;
1039
v->value_int = buf ? buf->Name : 0;
1041
case GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB:
1042
buf = ctx->Array.VAO->IndexBufferObj;
1043
v->value_int = buf ? buf->Name : 0;
1046
/* ARB_vertex_array_bgra */
1047
case GL_COLOR_ARRAY_SIZE:
1048
array = &ctx->Array.VAO->VertexAttrib[VERT_ATTRIB_COLOR0];
1049
v->value_int = array->Format.Format == GL_BGRA ? GL_BGRA : array->Format.Size;
1051
case GL_SECONDARY_COLOR_ARRAY_SIZE:
1052
array = &ctx->Array.VAO->VertexAttrib[VERT_ATTRIB_COLOR1];
1053
v->value_int = array->Format.Format == GL_BGRA ? GL_BGRA : array->Format.Size;
1056
/* ARB_copy_buffer */
1057
case GL_COPY_READ_BUFFER:
1058
v->value_int = ctx->CopyReadBuffer ? ctx->CopyReadBuffer->Name : 0;
1060
case GL_COPY_WRITE_BUFFER:
1061
v->value_int = ctx->CopyWriteBuffer ? ctx->CopyWriteBuffer->Name : 0;
1064
case GL_PIXEL_PACK_BUFFER_BINDING_EXT:
1065
v->value_int = ctx->Pack.BufferObj ? ctx->Pack.BufferObj->Name : 0;
1067
case GL_PIXEL_UNPACK_BUFFER_BINDING_EXT:
1068
v->value_int = ctx->Unpack.BufferObj ? ctx->Unpack.BufferObj->Name : 0;
1070
case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING:
1071
v->value_int = ctx->TransformFeedback.CurrentBuffer ?
1072
ctx->TransformFeedback.CurrentBuffer->Name : 0;
1074
case GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED:
1075
v->value_int = ctx->TransformFeedback.CurrentObject->Paused;
1077
case GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE:
1078
v->value_int = ctx->TransformFeedback.CurrentObject->Active;
1080
case GL_TRANSFORM_FEEDBACK_BINDING:
1081
v->value_int = ctx->TransformFeedback.CurrentObject->Name;
1083
case GL_CURRENT_PROGRAM:
1084
/* The Changelog of the ARB_separate_shader_objects spec says:
1086
* 24 25 Jul 2011 pbrown Remove the language erroneously deleting
1087
* CURRENT_PROGRAM. In the EXT extension, this
1088
* token was aliased to ACTIVE_PROGRAM_EXT, and
1089
* was used to indicate the last program set by
1090
* either ActiveProgramEXT or UseProgram. In
1091
* the ARB extension, the SSO active programs
1092
* are now program pipeline object state and
1093
* CURRENT_PROGRAM should still be used to query
1094
* the last program set by UseProgram (bug 7822).
1097
ctx->Shader.ActiveProgram ? ctx->Shader.ActiveProgram->Name : 0;
1099
case GL_READ_FRAMEBUFFER_BINDING_EXT:
1100
v->value_int = ctx->ReadBuffer->Name;
1102
case GL_RENDERBUFFER_BINDING_EXT:
1104
ctx->CurrentRenderbuffer ? ctx->CurrentRenderbuffer->Name : 0;
1106
case GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES:
1107
buf = ctx->Array.VAO->BufferBinding[VERT_ATTRIB_POINT_SIZE].BufferObj;
1108
v->value_int = buf ? buf->Name : 0;
1112
if (_mesa_get_clamp_fragment_color(ctx, ctx->DrawBuffer))
1113
COPY_4FV(v->value_float_4, ctx->Fog.Color);
1115
COPY_4FV(v->value_float_4, ctx->Fog.ColorUnclamped);
1117
case GL_COLOR_CLEAR_VALUE:
1118
if (_mesa_get_clamp_fragment_color(ctx, ctx->DrawBuffer)) {
1119
v->value_float_4[0] = CLAMP(ctx->Color.ClearColor.f[0], 0.0F, 1.0F);
1120
v->value_float_4[1] = CLAMP(ctx->Color.ClearColor.f[1], 0.0F, 1.0F);
1121
v->value_float_4[2] = CLAMP(ctx->Color.ClearColor.f[2], 0.0F, 1.0F);
1122
v->value_float_4[3] = CLAMP(ctx->Color.ClearColor.f[3], 0.0F, 1.0F);
1124
COPY_4FV(v->value_float_4, ctx->Color.ClearColor.f);
1126
case GL_BLEND_COLOR_EXT:
1127
if (_mesa_get_clamp_fragment_color(ctx, ctx->DrawBuffer))
1128
COPY_4FV(v->value_float_4, ctx->Color.BlendColor);
1130
COPY_4FV(v->value_float_4, ctx->Color.BlendColorUnclamped);
1132
case GL_ALPHA_TEST_REF:
1133
if (_mesa_get_clamp_fragment_color(ctx, ctx->DrawBuffer))
1134
v->value_float = ctx->Color.AlphaRef;
1136
v->value_float = ctx->Color.AlphaRefUnclamped;
1138
case GL_MAX_VERTEX_UNIFORM_VECTORS:
1139
v->value_int = ctx->Const.Program[MESA_SHADER_VERTEX].MaxUniformComponents / 4;
1142
case GL_MAX_FRAGMENT_UNIFORM_VECTORS:
1143
v->value_int = ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxUniformComponents / 4;
1146
/* GL_ARB_texture_buffer_object */
1147
case GL_TEXTURE_BUFFER_ARB:
1148
v->value_int = ctx->Texture.BufferObject ? ctx->Texture.BufferObject->Name : 0;
1150
case GL_TEXTURE_BINDING_BUFFER_ARB:
1151
unit = ctx->Texture.CurrentUnit;
1153
ctx->Texture.Unit[unit].CurrentTex[TEXTURE_BUFFER_INDEX]->Name;
1155
case GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB:
1157
struct gl_buffer_object *buf =
1158
ctx->Texture.Unit[ctx->Texture.CurrentUnit]
1159
.CurrentTex[TEXTURE_BUFFER_INDEX]->BufferObject;
1160
v->value_int = buf ? buf->Name : 0;
1163
case GL_TEXTURE_BUFFER_FORMAT_ARB:
1164
v->value_int = ctx->Texture.Unit[ctx->Texture.CurrentUnit]
1165
.CurrentTex[TEXTURE_BUFFER_INDEX]->BufferObjectFormat;
1168
/* GL_ARB_sampler_objects */
1169
case GL_SAMPLER_BINDING:
1171
struct gl_sampler_object *samp =
1172
ctx->Texture.Unit[ctx->Texture.CurrentUnit].Sampler;
1173
v->value_int = samp ? samp->Name : 0;
1176
/* GL_ARB_uniform_buffer_object */
1177
case GL_UNIFORM_BUFFER_BINDING:
1178
v->value_int = ctx->UniformBuffer ? ctx->UniformBuffer->Name : 0;
1180
/* GL_ARB_shader_storage_buffer_object */
1181
case GL_SHADER_STORAGE_BUFFER_BINDING:
1182
v->value_int = ctx->ShaderStorageBuffer ? ctx->ShaderStorageBuffer->Name : 0;
1184
/* GL_ARB_query_buffer_object */
1185
case GL_QUERY_BUFFER_BINDING:
1186
v->value_int = ctx->QueryBuffer ? ctx->QueryBuffer->Name : 0;
1188
/* GL_ARB_timer_query */
1190
v->value_int64 = _mesa_get_timestamp(ctx);
1193
case GL_DEBUG_OUTPUT:
1194
case GL_DEBUG_OUTPUT_SYNCHRONOUS:
1195
case GL_DEBUG_LOGGED_MESSAGES:
1196
case GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH:
1197
case GL_DEBUG_GROUP_STACK_DEPTH:
1198
v->value_int = _mesa_get_debug_state_int(ctx, d->pname);
1200
/* GL_ARB_shader_atomic_counters */
1201
case GL_ATOMIC_COUNTER_BUFFER_BINDING:
1202
v->value_int = ctx->AtomicBuffer ? ctx->AtomicBuffer->Name : 0;
1205
case GL_NUM_SHADING_LANGUAGE_VERSIONS:
1206
v->value_int = _mesa_get_shading_language_version(ctx, -1, NULL);
1208
/* GL_ARB_draw_indirect */
1209
case GL_DRAW_INDIRECT_BUFFER_BINDING:
1210
v->value_int = ctx->DrawIndirectBuffer ? ctx->DrawIndirectBuffer->Name: 0;
1212
/* GL_ARB_indirect_parameters */
1213
case GL_PARAMETER_BUFFER_BINDING_ARB:
1214
v->value_int = ctx->ParameterBuffer ? ctx->ParameterBuffer->Name : 0;
1216
/* GL_ARB_separate_shader_objects */
1217
case GL_PROGRAM_PIPELINE_BINDING:
1218
if (ctx->Pipeline.Current) {
1219
v->value_int = ctx->Pipeline.Current->Name;
1224
/* GL_ARB_compute_shader */
1225
case GL_DISPATCH_INDIRECT_BUFFER_BINDING:
1226
v->value_int = ctx->DispatchIndirectBuffer ?
1227
ctx->DispatchIndirectBuffer->Name : 0;
1229
/* GL_ARB_multisample */
1231
v->value_int = _mesa_geometric_samples(ctx->DrawBuffer);
1233
case GL_SAMPLE_BUFFERS:
1234
v->value_int = _mesa_geometric_samples(ctx->DrawBuffer) > 0;
1236
/* GL_EXT_textrue_integer */
1237
case GL_RGBA_INTEGER_MODE_EXT:
1238
v->value_int = (ctx->DrawBuffer->_IntegerBuffers != 0);
1240
/* GL_ATI_meminfo & GL_NVX_gpu_memory_info */
1241
case GL_VBO_FREE_MEMORY_ATI:
1242
case GL_TEXTURE_FREE_MEMORY_ATI:
1243
case GL_RENDERBUFFER_FREE_MEMORY_ATI:
1244
case GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX:
1245
case GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX:
1246
case GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX:
1247
case GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX:
1248
case GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX:
1250
struct pipe_memory_info info;
1251
struct pipe_screen *screen = ctx->pipe->screen;
1253
assert(screen->query_memory_info);
1254
screen->query_memory_info(screen, &info);
1256
if (d->pname == GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX)
1257
v->value_int = info.total_device_memory;
1258
else if (d->pname == GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX)
1259
v->value_int = info.total_device_memory +
1260
info.total_staging_memory;
1261
else if (d->pname == GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX)
1262
v->value_int = info.avail_device_memory;
1263
else if (d->pname == GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX)
1264
v->value_int = info.nr_device_memory_evictions;
1265
else if (d->pname == GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX)
1266
v->value_int = info.device_memory_evicted;
1268
/* ATI free memory enums.
1270
* Since the GPU memory is (usually) page-table based, every two
1271
* consecutive elements are equal. From the GL_ATI_meminfo
1274
* "param[0] - total memory free in the pool
1275
* param[1] - largest available free block in the pool
1276
* param[2] - total auxiliary memory free
1277
* param[3] - largest auxiliary free block"
1279
* All three (VBO, TEXTURE, RENDERBUFFER) queries return
1280
* the same numbers here.
1282
v->value_int_4[0] = info.avail_device_memory;
1283
v->value_int_4[1] = info.avail_device_memory;
1284
v->value_int_4[2] = info.avail_staging_memory;
1285
v->value_int_4[3] = info.avail_staging_memory;
1290
/* GL_ARB_get_program_binary */
1291
case GL_PROGRAM_BINARY_FORMATS:
1292
assert(ctx->Const.NumProgramBinaryFormats <= 1);
1293
v->value_int_n.n = MIN2(ctx->Const.NumProgramBinaryFormats, 1);
1294
if (ctx->Const.NumProgramBinaryFormats > 0) {
1295
v->value_int_n.ints[0] = GL_PROGRAM_BINARY_FORMAT_MESA;
1298
/* ARB_spirv_extensions */
1299
case GL_NUM_SPIR_V_EXTENSIONS:
1300
v->value_int = _mesa_get_spirv_extension_count(ctx);
1302
/* GL_EXT_disjoint_timer_query */
1303
case GL_GPU_DISJOINT_EXT:
1305
simple_mtx_lock(&ctx->Shared->Mutex);
1306
v->value_int = ctx->Shared->DisjointOperation;
1307
/* Reset state as expected by the spec. */
1308
ctx->Shared->DisjointOperation = false;
1309
simple_mtx_unlock(&ctx->Shared->Mutex);
1312
/* GL_ARB_sample_locations */
1313
case GL_SAMPLE_LOCATION_SUBPIXEL_BITS_ARB:
1314
case GL_SAMPLE_LOCATION_PIXEL_GRID_WIDTH_ARB:
1315
case GL_SAMPLE_LOCATION_PIXEL_GRID_HEIGHT_ARB:
1317
GLuint bits, width, height;
1319
if (ctx->NewState & _NEW_BUFFERS)
1320
_mesa_update_state(ctx);
1322
if (ctx->DrawBuffer->_Status != GL_FRAMEBUFFER_COMPLETE) {
1327
_mesa_GetProgrammableSampleCaps(ctx, ctx->DrawBuffer,
1328
&bits, &width, &height);
1330
if (d->pname == GL_SAMPLE_LOCATION_PIXEL_GRID_WIDTH_ARB)
1331
v->value_uint = width;
1332
else if (d->pname == GL_SAMPLE_LOCATION_PIXEL_GRID_HEIGHT_ARB)
1333
v->value_uint = height;
1335
v->value_uint = bits;
1338
case GL_PROGRAMMABLE_SAMPLE_LOCATION_TABLE_SIZE_ARB:
1339
v->value_uint = MAX_SAMPLE_LOCATION_TABLE_SIZE;
1342
/* GL_AMD_framebuffer_multisample_advanced */
1343
case GL_SUPPORTED_MULTISAMPLE_MODES_AMD:
1344
v->value_int_n.n = ctx->Const.NumSupportedMultisampleModes * 3;
1345
memcpy(v->value_int_n.ints, ctx->Const.SupportedMultisampleModes,
1346
v->value_int_n.n * sizeof(GLint));
1349
/* GL_NV_viewport_swizzle */
1350
case GL_VIEWPORT_SWIZZLE_X_NV:
1351
v->value_enum = ctx->ViewportArray[0].SwizzleX;
1353
case GL_VIEWPORT_SWIZZLE_Y_NV:
1354
v->value_enum = ctx->ViewportArray[0].SwizzleY;
1356
case GL_VIEWPORT_SWIZZLE_Z_NV:
1357
v->value_enum = ctx->ViewportArray[0].SwizzleZ;
1359
case GL_VIEWPORT_SWIZZLE_W_NV:
1360
v->value_enum = ctx->ViewportArray[0].SwizzleW;
1366
* Check extra constraints on a struct value_desc descriptor
1368
* If a struct value_desc has a non-NULL extra pointer, it means that
1369
* there are a number of extra constraints to check or actions to
1370
* perform. The extras is just an integer array where each integer
1371
* encode different constraints or actions.
1373
* \param ctx current context
1374
* \param func name of calling glGet*v() function for error reporting
1375
* \param d the struct value_desc that has the extra constraints
1377
* \return GL_FALSE if all of the constraints were not satisfied,
1378
* otherwise GL_TRUE.
1381
check_extra(struct gl_context *ctx, const char *func, const struct value_desc *d)
1383
const GLuint version = ctx->Version;
1384
GLboolean api_check = GL_FALSE;
1385
GLboolean api_found = GL_FALSE;
1388
for (e = d->extra; *e != EXTRA_END; e++) {
1390
case EXTRA_VERSION_30:
1391
api_check = GL_TRUE;
1393
api_found = GL_TRUE;
1395
case EXTRA_VERSION_31:
1396
api_check = GL_TRUE;
1398
api_found = GL_TRUE;
1400
case EXTRA_VERSION_32:
1401
api_check = GL_TRUE;
1403
api_found = GL_TRUE;
1405
case EXTRA_VERSION_40:
1406
api_check = GL_TRUE;
1408
api_found = GL_TRUE;
1410
case EXTRA_VERSION_43:
1411
api_check = GL_TRUE;
1412
if (_mesa_is_desktop_gl(ctx) && version >= 43)
1413
api_found = GL_TRUE;
1416
api_check = GL_TRUE;
1417
if (ctx->API == API_OPENGLES2)
1418
api_found = GL_TRUE;
1421
api_check = GL_TRUE;
1422
if (_mesa_is_gles3(ctx))
1423
api_found = GL_TRUE;
1425
case EXTRA_API_ES31:
1426
api_check = GL_TRUE;
1427
if (_mesa_is_gles31(ctx))
1428
api_found = GL_TRUE;
1430
case EXTRA_API_ES32:
1431
api_check = GL_TRUE;
1432
if (_mesa_is_gles32(ctx))
1433
api_found = GL_TRUE;
1436
api_check = GL_TRUE;
1437
if (_mesa_is_desktop_gl(ctx))
1438
api_found = GL_TRUE;
1440
case EXTRA_API_GL_CORE:
1441
api_check = GL_TRUE;
1442
if (ctx->API == API_OPENGL_CORE)
1443
api_found = GL_TRUE;
1445
case EXTRA_NEW_BUFFERS:
1446
if (ctx->NewState & _NEW_BUFFERS)
1447
_mesa_update_state(ctx);
1449
case EXTRA_FLUSH_CURRENT:
1450
FLUSH_CURRENT(ctx, 0);
1452
case EXTRA_VALID_DRAW_BUFFER:
1453
if (d->pname - GL_DRAW_BUFFER0_ARB >= ctx->Const.MaxDrawBuffers) {
1454
_mesa_error(ctx, GL_INVALID_OPERATION, "%s(draw buffer %u)",
1455
func, d->pname - GL_DRAW_BUFFER0_ARB);
1459
case EXTRA_VALID_TEXTURE_UNIT:
1460
if (ctx->Texture.CurrentUnit >= ctx->Const.MaxTextureCoordUnits) {
1461
_mesa_error(ctx, GL_INVALID_OPERATION, "%s(texture %u)",
1462
func, ctx->Texture.CurrentUnit);
1466
case EXTRA_VALID_CLIP_DISTANCE:
1467
if (d->pname - GL_CLIP_DISTANCE0 >= ctx->Const.MaxClipPlanes) {
1468
_mesa_error(ctx, GL_INVALID_ENUM, "%s(clip distance %u)",
1469
func, d->pname - GL_CLIP_DISTANCE0);
1473
case EXTRA_GLSL_130:
1474
api_check = GL_TRUE;
1475
if (ctx->Const.GLSLVersion >= 130)
1476
api_found = GL_TRUE;
1478
case EXTRA_EXT_UBO_GS:
1479
api_check = GL_TRUE;
1480
if (ctx->Extensions.ARB_uniform_buffer_object &&
1481
_mesa_has_geometry_shaders(ctx))
1482
api_found = GL_TRUE;
1484
case EXTRA_EXT_ATOMICS_GS:
1485
api_check = GL_TRUE;
1486
if (ctx->Extensions.ARB_shader_atomic_counters &&
1487
_mesa_has_geometry_shaders(ctx))
1488
api_found = GL_TRUE;
1490
case EXTRA_EXT_SHADER_IMAGE_GS:
1491
api_check = GL_TRUE;
1492
if ((ctx->Extensions.ARB_shader_image_load_store ||
1493
_mesa_is_gles31(ctx)) &&
1494
_mesa_has_geometry_shaders(ctx))
1495
api_found = GL_TRUE;
1497
case EXTRA_EXT_ATOMICS_TESS:
1498
api_check = GL_TRUE;
1499
api_found = ctx->Extensions.ARB_shader_atomic_counters &&
1500
_mesa_has_tessellation(ctx);
1502
case EXTRA_EXT_SHADER_IMAGE_TESS:
1503
api_check = GL_TRUE;
1504
api_found = ctx->Extensions.ARB_shader_image_load_store &&
1505
_mesa_has_tessellation(ctx);
1507
case EXTRA_EXT_SSBO_GS:
1508
api_check = GL_TRUE;
1509
if (ctx->Extensions.ARB_shader_storage_buffer_object &&
1510
_mesa_has_geometry_shaders(ctx))
1511
api_found = GL_TRUE;
1513
case EXTRA_EXT_FB_NO_ATTACH_GS:
1514
api_check = GL_TRUE;
1515
if (ctx->Extensions.ARB_framebuffer_no_attachments &&
1516
(_mesa_is_desktop_gl(ctx) ||
1517
_mesa_has_OES_geometry_shader(ctx)))
1518
api_found = GL_TRUE;
1520
case EXTRA_EXT_ES_GS:
1521
api_check = GL_TRUE;
1522
if (_mesa_has_OES_geometry_shader(ctx))
1523
api_found = GL_TRUE;
1525
case EXTRA_EXT_PROVOKING_VERTEX_32:
1526
api_check = GL_TRUE;
1527
if (ctx->API == API_OPENGL_COMPAT || version == 32)
1528
api_found = ctx->Extensions.EXT_provoking_vertex;
1532
default: /* *e is a offset into the extension struct */
1533
api_check = GL_TRUE;
1534
if (*(GLboolean *) ((char *) &ctx->Extensions + *e))
1535
api_found = GL_TRUE;
1540
if (api_check && !api_found) {
1541
_mesa_error(ctx, GL_INVALID_ENUM, "%s(pname=%s)", func,
1542
_mesa_enum_to_string(d->pname));
1549
static const struct value_desc error_value =
1550
{ 0, 0, TYPE_INVALID, NO_OFFSET, NO_EXTRA };
1553
* Find the struct value_desc corresponding to the enum 'pname'.
1555
* We hash the enum value to get an index into the 'table' array,
1556
* which holds the index in the 'values' array of struct value_desc.
1557
* Once we've found the entry, we do the extra checks, if any, then
1558
* look up the value and return a pointer to it.
1560
* If the value has to be computed (for example, it's the result of a
1561
* function call or we need to add 1 to it), we use the tmp 'v' to
1564
* \param func name of glGet*v() func for error reporting
1565
* \param pname the enum value we're looking up
1566
* \param p is were we return the pointer to the value
1567
* \param v a tmp union value variable in the calling glGet*v() function
1569
* \return the struct value_desc corresponding to the enum or a struct
1570
* value_desc of TYPE_INVALID if not found. This lets the calling
1571
* glGet*v() function jump right into a switch statement and
1572
* handle errors there instead of having to check for NULL.
1574
static const struct value_desc *
1575
find_value(const char *func, GLenum pname, void **p, union value *v)
1577
GET_CURRENT_CONTEXT(ctx);
1579
const struct value_desc *d;
1585
/* We index into the table_set[] list of per-API hash tables using the API's
1586
* value in the gl_api enum. Since GLES 3 doesn't have an API_OPENGL* enum
1587
* value since it's compatible with GLES2 its entry in table_set[] is at the
1590
STATIC_ASSERT(ARRAY_SIZE(table_set) == API_OPENGL_LAST + 4);
1591
if (ctx->API == API_OPENGLES2) {
1592
if (ctx->Version >= 32)
1593
api = API_OPENGL_LAST + 3;
1594
else if (ctx->Version >= 31)
1595
api = API_OPENGL_LAST + 2;
1596
else if (ctx->Version >= 30)
1597
api = API_OPENGL_LAST + 1;
1599
mask = ARRAY_SIZE(table(api)) - 1;
1600
hash = (pname * prime_factor);
1602
int idx = table(api)[hash & mask];
1604
/* If the enum isn't valid, the hash walk ends with index 0,
1605
* pointing to the first entry of values[] which doesn't hold
1606
* any valid enum. */
1607
if (unlikely(idx == 0)) {
1608
_mesa_error(ctx, GL_INVALID_ENUM, "%s(pname=%s)", func,
1609
_mesa_enum_to_string(pname));
1610
return &error_value;
1614
if (likely(d->pname == pname))
1620
if (unlikely(d->extra && !check_extra(ctx, func, d)))
1621
return &error_value;
1623
switch (d->location) {
1625
*p = ((char *) ctx->DrawBuffer + d->offset);
1628
*p = ((char *) ctx + d->offset);
1631
*p = ((char *) ctx->Array.VAO + d->offset);
1634
if (ctx->Texture.CurrentUnit < ARRAY_SIZE(ctx->Texture.FixedFuncUnit)) {
1635
unsigned index = ctx->Texture.CurrentUnit;
1636
*p = ((char *)&ctx->Texture.FixedFuncUnit[index] + d->offset);
1639
_mesa_error(ctx, GL_INVALID_VALUE, "%s(pname=%s,unit=%d)", func,
1640
_mesa_enum_to_string(pname),
1641
ctx->Texture.CurrentUnit);
1642
return &error_value;
1644
find_custom_value(ctx, d, v);
1652
/* silence warning */
1653
return &error_value;
1656
static const int transpose[] = {
1664
get_value_size(enum value_type type, const union value *v)
1672
return sizeof(GLint);
1675
return sizeof(GLint) * 2;
1678
return sizeof(GLint) * 3;
1681
return sizeof(GLint) * 4;
1683
return sizeof(GLint) * v->value_int_n.n;
1685
return sizeof(GLint64);
1688
return sizeof(GLenum16);
1690
return sizeof(GLenum);
1692
return sizeof(GLenum) * 2;
1694
return sizeof(GLboolean);
1696
return sizeof(GLubyte);
1698
return sizeof(GLshort);
1710
return sizeof(GLfloat);
1713
return sizeof(GLfloat) * 2;
1716
return sizeof(GLfloat) * 3;
1719
return sizeof(GLfloat) * 4;
1721
return sizeof(GLfloat) * 8;
1723
return sizeof(GLdouble);
1724
case TYPE_DOUBLEN_2:
1725
return sizeof(GLdouble) * 2;
1727
return sizeof (GLfloat) * 16;
1729
return sizeof (GLfloat) * 16;
1731
assert(!"invalid value_type given for get_value_size()");
1737
_mesa_GetBooleanv(GLenum pname, GLboolean *params)
1739
const struct value_desc *d;
1745
d = find_value("glGetBooleanv", pname, &p, &v);
1750
params[0] = INT_TO_BOOLEAN(d->offset);
1754
params[7] = FLOAT_TO_BOOLEAN(((GLfloat *) p)[7]);
1755
params[6] = FLOAT_TO_BOOLEAN(((GLfloat *) p)[6]);
1756
params[5] = FLOAT_TO_BOOLEAN(((GLfloat *) p)[5]);
1757
params[4] = FLOAT_TO_BOOLEAN(((GLfloat *) p)[4]);
1761
params[3] = FLOAT_TO_BOOLEAN(((GLfloat *) p)[3]);
1765
params[2] = FLOAT_TO_BOOLEAN(((GLfloat *) p)[2]);
1769
params[1] = FLOAT_TO_BOOLEAN(((GLfloat *) p)[1]);
1773
params[0] = FLOAT_TO_BOOLEAN(((GLfloat *) p)[0]);
1776
case TYPE_DOUBLEN_2:
1777
params[1] = FLOAT_TO_BOOLEAN(((GLdouble *) p)[1]);
1780
params[0] = FLOAT_TO_BOOLEAN(((GLdouble *) p)[0]);
1785
params[3] = INT_TO_BOOLEAN(((GLint *) p)[3]);
1789
params[2] = INT_TO_BOOLEAN(((GLint *) p)[2]);
1794
params[1] = INT_TO_BOOLEAN(((GLint *) p)[1]);
1799
params[0] = INT_TO_BOOLEAN(((GLint *) p)[0]);
1803
params[0] = INT_TO_BOOLEAN(((GLenum16 *) p)[0]);
1807
for (i = 0; i < v.value_int_n.n; i++)
1808
params[i] = INT_TO_BOOLEAN(v.value_int_n.ints[i]);
1812
params[0] = INT64_TO_BOOLEAN(((GLint64 *) p)[0]);
1816
params[0] = ((GLboolean*) p)[0];
1820
params[0] = INT_TO_BOOLEAN(((GLubyte *) p)[0]);
1824
params[0] = INT_TO_BOOLEAN(((GLshort *) p)[0]);
1828
m = *(GLmatrix **) p;
1829
for (i = 0; i < 16; i++)
1830
params[i] = FLOAT_TO_BOOLEAN(m->m[i]);
1834
m = *(GLmatrix **) p;
1835
for (i = 0; i < 16; i++)
1836
params[i] = FLOAT_TO_BOOLEAN(m->m[transpose[i]]);
1847
shift = d->type - TYPE_BIT_0;
1848
params[0] = (*(GLbitfield *) p >> shift) & 1;
1854
_mesa_GetFloatv(GLenum pname, GLfloat *params)
1856
const struct value_desc *d;
1862
d = find_value("glGetFloatv", pname, &p, &v);
1867
params[0] = (GLfloat) d->offset;
1871
params[7] = ((GLfloat *) p)[7];
1872
params[6] = ((GLfloat *) p)[6];
1873
params[5] = ((GLfloat *) p)[5];
1874
params[4] = ((GLfloat *) p)[4];
1878
params[3] = ((GLfloat *) p)[3];
1882
params[2] = ((GLfloat *) p)[2];
1886
params[1] = ((GLfloat *) p)[1];
1890
params[0] = ((GLfloat *) p)[0];
1893
case TYPE_DOUBLEN_2:
1894
params[1] = (GLfloat) (((GLdouble *) p)[1]);
1897
params[0] = (GLfloat) (((GLdouble *) p)[0]);
1901
params[3] = (GLfloat) (((GLint *) p)[3]);
1904
params[2] = (GLfloat) (((GLint *) p)[2]);
1908
params[1] = (GLfloat) (((GLint *) p)[1]);
1912
params[0] = (GLfloat) (((GLint *) p)[0]);
1916
params[0] = (GLfloat) (((GLenum16 *) p)[0]);
1920
for (i = 0; i < v.value_int_n.n; i++)
1921
params[i] = (GLfloat) v.value_int_n.ints[i];
1925
params[3] = (GLfloat) (((GLuint *) p)[3]);
1928
params[2] = (GLfloat) (((GLuint *) p)[2]);
1931
params[1] = (GLfloat) (((GLuint *) p)[1]);
1934
params[0] = (GLfloat) (((GLuint *) p)[0]);
1938
params[0] = (GLfloat) (((GLint64 *) p)[0]);
1942
params[0] = BOOLEAN_TO_FLOAT(*(GLboolean*) p);
1946
params[0] = (GLfloat) ((GLubyte *) p)[0];
1950
params[0] = (GLfloat) ((GLshort *) p)[0];
1954
m = *(GLmatrix **) p;
1955
for (i = 0; i < 16; i++)
1956
params[i] = m->m[i];
1960
m = *(GLmatrix **) p;
1961
for (i = 0; i < 16; i++)
1962
params[i] = m->m[transpose[i]];
1973
shift = d->type - TYPE_BIT_0;
1974
params[0] = BOOLEAN_TO_FLOAT((*(GLbitfield *) p >> shift) & 1);
1980
_mesa_GetIntegerv(GLenum pname, GLint *params)
1982
const struct value_desc *d;
1988
d = find_value("glGetIntegerv", pname, &p, &v);
1993
params[0] = d->offset;
1997
params[7] = lroundf(((GLfloat *) p)[7]);
1998
params[6] = lroundf(((GLfloat *) p)[6]);
1999
params[5] = lroundf(((GLfloat *) p)[5]);
2000
params[4] = lroundf(((GLfloat *) p)[4]);
2003
params[3] = lroundf(((GLfloat *) p)[3]);
2006
params[2] = lroundf(((GLfloat *) p)[2]);
2009
params[1] = lroundf(((GLfloat *) p)[1]);
2012
params[0] = lroundf(((GLfloat *) p)[0]);
2016
params[3] = FLOAT_TO_INT(((GLfloat *) p)[3]);
2019
params[2] = FLOAT_TO_INT(((GLfloat *) p)[2]);
2022
params[1] = FLOAT_TO_INT(((GLfloat *) p)[1]);
2025
params[0] = FLOAT_TO_INT(((GLfloat *) p)[0]);
2028
case TYPE_DOUBLEN_2:
2029
params[1] = FLOAT_TO_INT(((GLdouble *) p)[1]);
2032
params[0] = FLOAT_TO_INT(((GLdouble *) p)[0]);
2037
params[3] = ((GLint *) p)[3];
2041
params[2] = ((GLint *) p)[2];
2046
params[1] = ((GLint *) p)[1];
2051
params[0] = ((GLint *) p)[0];
2055
params[0] = ((GLenum16 *) p)[0];
2059
for (i = 0; i < v.value_int_n.n; i++)
2060
params[i] = v.value_int_n.ints[i];
2064
params[0] = INT64_TO_INT(((GLint64 *) p)[0]);
2068
params[0] = BOOLEAN_TO_INT(*(GLboolean*) p);
2072
params[0] = ((GLubyte *) p)[0];
2076
params[0] = ((GLshort *) p)[0];
2080
m = *(GLmatrix **) p;
2081
for (i = 0; i < 16; i++)
2082
params[i] = FLOAT_TO_INT(m->m[i]);
2086
m = *(GLmatrix **) p;
2087
for (i = 0; i < 16; i++)
2088
params[i] = FLOAT_TO_INT(m->m[transpose[i]]);
2099
shift = d->type - TYPE_BIT_0;
2100
params[0] = (*(GLbitfield *) p >> shift) & 1;
2106
_mesa_GetInteger64v(GLenum pname, GLint64 *params)
2108
const struct value_desc *d;
2114
d = find_value("glGetInteger64v", pname, &p, &v);
2119
params[0] = d->offset;
2123
params[7] = llround(((GLfloat *) p)[7]);
2124
params[6] = llround(((GLfloat *) p)[6]);
2125
params[5] = llround(((GLfloat *) p)[5]);
2126
params[4] = llround(((GLfloat *) p)[4]);
2129
params[3] = llround(((GLfloat *) p)[3]);
2132
params[2] = llround(((GLfloat *) p)[2]);
2135
params[1] = llround(((GLfloat *) p)[1]);
2138
params[0] = llround(((GLfloat *) p)[0]);
2142
params[3] = FLOAT_TO_INT(((GLfloat *) p)[3]);
2145
params[2] = FLOAT_TO_INT(((GLfloat *) p)[2]);
2148
params[1] = FLOAT_TO_INT(((GLfloat *) p)[1]);
2151
params[0] = FLOAT_TO_INT(((GLfloat *) p)[0]);
2154
case TYPE_DOUBLEN_2:
2155
params[1] = FLOAT_TO_INT(((GLdouble *) p)[1]);
2158
params[0] = FLOAT_TO_INT(((GLdouble *) p)[0]);
2162
params[3] = ((GLint *) p)[3];
2165
params[2] = ((GLint *) p)[2];
2169
params[1] = ((GLint *) p)[1];
2173
params[0] = ((GLint *) p)[0];
2177
params[0] = ((GLenum16 *) p)[0];
2181
for (i = 0; i < v.value_int_n.n; i++)
2182
params[i] = v.value_int_n.ints[i];
2186
params[3] = ((GLuint *) p)[3];
2189
params[2] = ((GLuint *) p)[2];
2192
params[1] = ((GLuint *) p)[1];
2195
params[0] = ((GLuint *) p)[0];
2199
params[0] = ((GLint64 *) p)[0];
2203
params[0] = ((GLboolean*) p)[0];
2207
m = *(GLmatrix **) p;
2208
for (i = 0; i < 16; i++)
2209
params[i] = FLOAT_TO_INT64(m->m[i]);
2213
m = *(GLmatrix **) p;
2214
for (i = 0; i < 16; i++)
2215
params[i] = FLOAT_TO_INT64(m->m[transpose[i]]);
2226
shift = d->type - TYPE_BIT_0;
2227
params[0] = (*(GLbitfield *) p >> shift) & 1;
2233
_mesa_GetDoublev(GLenum pname, GLdouble *params)
2235
const struct value_desc *d;
2241
d = find_value("glGetDoublev", pname, &p, &v);
2246
params[0] = d->offset;
2250
params[7] = ((GLfloat *) p)[7];
2251
params[6] = ((GLfloat *) p)[6];
2252
params[5] = ((GLfloat *) p)[5];
2253
params[4] = ((GLfloat *) p)[4];
2257
params[3] = ((GLfloat *) p)[3];
2261
params[2] = ((GLfloat *) p)[2];
2265
params[1] = ((GLfloat *) p)[1];
2269
params[0] = ((GLfloat *) p)[0];
2272
case TYPE_DOUBLEN_2:
2273
params[1] = ((GLdouble *) p)[1];
2276
params[0] = ((GLdouble *) p)[0];
2280
params[3] = ((GLint *) p)[3];
2283
params[2] = ((GLint *) p)[2];
2287
params[1] = ((GLint *) p)[1];
2291
params[0] = ((GLint *) p)[0];
2295
params[0] = ((GLenum16 *) p)[0];
2299
for (i = 0; i < v.value_int_n.n; i++)
2300
params[i] = v.value_int_n.ints[i];
2304
params[3] = ((GLuint *) p)[3];
2307
params[2] = ((GLuint *) p)[2];
2310
params[1] = ((GLuint *) p)[1];
2313
params[0] = ((GLuint *) p)[0];
2317
params[0] = (GLdouble) (((GLint64 *) p)[0]);
2321
params[0] = *(GLboolean*) p;
2325
params[0] = ((GLubyte *) p)[0];
2329
params[0] = ((GLshort *) p)[0];
2333
m = *(GLmatrix **) p;
2334
for (i = 0; i < 16; i++)
2335
params[i] = m->m[i];
2339
m = *(GLmatrix **) p;
2340
for (i = 0; i < 16; i++)
2341
params[i] = m->m[transpose[i]];
2352
shift = d->type - TYPE_BIT_0;
2353
params[0] = (*(GLbitfield *) p >> shift) & 1;
2359
_mesa_GetUnsignedBytevEXT(GLenum pname, GLubyte *data)
2361
const struct value_desc *d;
2366
const char *func = "glGetUnsignedBytevEXT";
2368
GET_CURRENT_CONTEXT(ctx);
2370
if (!ctx->Extensions.EXT_memory_object) {
2371
_mesa_error(ctx, GL_INVALID_OPERATION, "%s(unsupported)", func);
2375
d = find_value(func, pname, &p, &v);
2376
size = get_value_size(d->type, &v);
2387
shift = d->type - TYPE_BIT_0;
2388
data[0] = (*(GLbitfield *) p >> shift) & 1;
2391
memcpy(data, &d->offset, size);
2394
memcpy(data, &v.value_int_n.ints, size);
2420
case TYPE_DOUBLEN_2:
2423
memcpy(data, p, size);
2426
GLenum e = *(GLenum16 *)p;
2427
memcpy(data, &e, sizeof(e));
2431
break; /* nothing - GL error was recorded */
2436
* Convert a GL texture binding enum such as GL_TEXTURE_BINDING_2D
2437
* into the corresponding Mesa texture target index.
2438
* \return TEXTURE_x_INDEX or -1 if binding is invalid
2441
tex_binding_to_index(const struct gl_context *ctx, GLenum binding)
2444
case GL_TEXTURE_BINDING_1D:
2445
return _mesa_is_desktop_gl(ctx) ? TEXTURE_1D_INDEX : -1;
2446
case GL_TEXTURE_BINDING_2D:
2447
return TEXTURE_2D_INDEX;
2448
case GL_TEXTURE_BINDING_3D:
2449
return ctx->API != API_OPENGLES ? TEXTURE_3D_INDEX : -1;
2450
case GL_TEXTURE_BINDING_CUBE_MAP:
2451
return TEXTURE_CUBE_INDEX;
2452
case GL_TEXTURE_BINDING_RECTANGLE:
2453
return _mesa_is_desktop_gl(ctx) && ctx->Extensions.NV_texture_rectangle
2454
? TEXTURE_RECT_INDEX : -1;
2455
case GL_TEXTURE_BINDING_1D_ARRAY:
2456
return _mesa_is_desktop_gl(ctx) && ctx->Extensions.EXT_texture_array
2457
? TEXTURE_1D_ARRAY_INDEX : -1;
2458
case GL_TEXTURE_BINDING_2D_ARRAY:
2459
return (_mesa_is_desktop_gl(ctx) && ctx->Extensions.EXT_texture_array)
2460
|| _mesa_is_gles3(ctx)
2461
? TEXTURE_2D_ARRAY_INDEX : -1;
2462
case GL_TEXTURE_BINDING_BUFFER:
2463
return (_mesa_has_ARB_texture_buffer_object(ctx) ||
2464
_mesa_has_OES_texture_buffer(ctx)) ?
2465
TEXTURE_BUFFER_INDEX : -1;
2466
case GL_TEXTURE_BINDING_CUBE_MAP_ARRAY:
2467
return _mesa_has_texture_cube_map_array(ctx)
2468
? TEXTURE_CUBE_ARRAY_INDEX : -1;
2469
case GL_TEXTURE_BINDING_2D_MULTISAMPLE:
2470
return _mesa_is_desktop_gl(ctx) && ctx->Extensions.ARB_texture_multisample
2471
? TEXTURE_2D_MULTISAMPLE_INDEX : -1;
2472
case GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY:
2473
return _mesa_is_desktop_gl(ctx) && ctx->Extensions.ARB_texture_multisample
2474
? TEXTURE_2D_MULTISAMPLE_ARRAY_INDEX : -1;
2480
static enum value_type
2481
find_value_indexed(const char *func, GLenum pname, GLuint index, union value *v)
2483
GET_CURRENT_CONTEXT(ctx);
2484
struct gl_buffer_object *buf;
2489
if (index >= ctx->Const.MaxDrawBuffers)
2491
if (!ctx->Extensions.EXT_draw_buffers2)
2493
v->value_int = (ctx->Color.BlendEnabled >> index) & 1;
2498
case GL_BLEND_SRC_RGB:
2499
if (index >= ctx->Const.MaxDrawBuffers)
2501
if (!ctx->Extensions.ARB_draw_buffers_blend)
2503
v->value_int = ctx->Color.Blend[index].SrcRGB;
2505
case GL_BLEND_SRC_ALPHA:
2506
if (index >= ctx->Const.MaxDrawBuffers)
2508
if (!ctx->Extensions.ARB_draw_buffers_blend)
2510
v->value_int = ctx->Color.Blend[index].SrcA;
2514
case GL_BLEND_DST_RGB:
2515
if (index >= ctx->Const.MaxDrawBuffers)
2517
if (!ctx->Extensions.ARB_draw_buffers_blend)
2519
v->value_int = ctx->Color.Blend[index].DstRGB;
2521
case GL_BLEND_DST_ALPHA:
2522
if (index >= ctx->Const.MaxDrawBuffers)
2524
if (!ctx->Extensions.ARB_draw_buffers_blend)
2526
v->value_int = ctx->Color.Blend[index].DstA;
2528
case GL_BLEND_EQUATION_RGB:
2529
if (index >= ctx->Const.MaxDrawBuffers)
2531
if (!ctx->Extensions.ARB_draw_buffers_blend)
2533
v->value_int = ctx->Color.Blend[index].EquationRGB;
2535
case GL_BLEND_EQUATION_ALPHA:
2536
if (index >= ctx->Const.MaxDrawBuffers)
2538
if (!ctx->Extensions.ARB_draw_buffers_blend)
2540
v->value_int = ctx->Color.Blend[index].EquationA;
2543
case GL_COLOR_WRITEMASK:
2544
if (index >= ctx->Const.MaxDrawBuffers)
2546
if (!ctx->Extensions.EXT_draw_buffers2)
2548
v->value_int_4[0] = GET_COLORMASK_BIT(ctx->Color.ColorMask, index, 0);
2549
v->value_int_4[1] = GET_COLORMASK_BIT(ctx->Color.ColorMask, index, 1);
2550
v->value_int_4[2] = GET_COLORMASK_BIT(ctx->Color.ColorMask, index, 2);
2551
v->value_int_4[3] = GET_COLORMASK_BIT(ctx->Color.ColorMask, index, 3);
2554
case GL_SCISSOR_BOX:
2555
if (index >= ctx->Const.MaxViewports)
2557
v->value_int_4[0] = ctx->Scissor.ScissorArray[index].X;
2558
v->value_int_4[1] = ctx->Scissor.ScissorArray[index].Y;
2559
v->value_int_4[2] = ctx->Scissor.ScissorArray[index].Width;
2560
v->value_int_4[3] = ctx->Scissor.ScissorArray[index].Height;
2563
case GL_WINDOW_RECTANGLE_EXT:
2564
if (!ctx->Extensions.EXT_window_rectangles)
2566
if (index >= ctx->Const.MaxWindowRectangles)
2568
v->value_int_4[0] = ctx->Scissor.WindowRects[index].X;
2569
v->value_int_4[1] = ctx->Scissor.WindowRects[index].Y;
2570
v->value_int_4[2] = ctx->Scissor.WindowRects[index].Width;
2571
v->value_int_4[3] = ctx->Scissor.WindowRects[index].Height;
2575
if (index >= ctx->Const.MaxViewports)
2577
v->value_float_4[0] = ctx->ViewportArray[index].X;
2578
v->value_float_4[1] = ctx->ViewportArray[index].Y;
2579
v->value_float_4[2] = ctx->ViewportArray[index].Width;
2580
v->value_float_4[3] = ctx->ViewportArray[index].Height;
2581
return TYPE_FLOAT_4;
2583
case GL_DEPTH_RANGE:
2584
if (index >= ctx->Const.MaxViewports)
2586
v->value_double_2[0] = ctx->ViewportArray[index].Near;
2587
v->value_double_2[1] = ctx->ViewportArray[index].Far;
2588
return TYPE_DOUBLEN_2;
2590
case GL_TRANSFORM_FEEDBACK_BUFFER_START:
2591
if (index >= ctx->Const.MaxTransformFeedbackBuffers)
2593
if (!ctx->Extensions.EXT_transform_feedback)
2595
v->value_int64 = ctx->TransformFeedback.CurrentObject->Offset[index];
2598
case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE:
2599
if (index >= ctx->Const.MaxTransformFeedbackBuffers)
2601
if (!ctx->Extensions.EXT_transform_feedback)
2604
= ctx->TransformFeedback.CurrentObject->RequestedSize[index];
2607
case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING:
2608
if (index >= ctx->Const.MaxTransformFeedbackBuffers)
2610
if (!ctx->Extensions.EXT_transform_feedback)
2612
v->value_int = ctx->TransformFeedback.CurrentObject->BufferNames[index];
2615
case GL_UNIFORM_BUFFER_BINDING:
2616
if (index >= ctx->Const.MaxUniformBufferBindings)
2618
if (!ctx->Extensions.ARB_uniform_buffer_object)
2620
buf = ctx->UniformBufferBindings[index].BufferObject;
2621
v->value_int = buf ? buf->Name : 0;
2624
case GL_UNIFORM_BUFFER_START:
2625
if (index >= ctx->Const.MaxUniformBufferBindings)
2627
if (!ctx->Extensions.ARB_uniform_buffer_object)
2629
v->value_int = ctx->UniformBufferBindings[index].Offset < 0 ? 0 :
2630
ctx->UniformBufferBindings[index].Offset;
2633
case GL_UNIFORM_BUFFER_SIZE:
2634
if (index >= ctx->Const.MaxUniformBufferBindings)
2636
if (!ctx->Extensions.ARB_uniform_buffer_object)
2638
v->value_int = ctx->UniformBufferBindings[index].Size < 0 ? 0 :
2639
ctx->UniformBufferBindings[index].Size;
2642
/* ARB_shader_storage_buffer_object */
2643
case GL_SHADER_STORAGE_BUFFER_BINDING:
2644
if (!ctx->Extensions.ARB_shader_storage_buffer_object && !_mesa_is_gles31(ctx))
2646
if (index >= ctx->Const.MaxShaderStorageBufferBindings)
2648
buf = ctx->ShaderStorageBufferBindings[index].BufferObject;
2649
v->value_int = buf ? buf->Name : 0;
2652
case GL_SHADER_STORAGE_BUFFER_START:
2653
if (!ctx->Extensions.ARB_shader_storage_buffer_object && !_mesa_is_gles31(ctx))
2655
if (index >= ctx->Const.MaxShaderStorageBufferBindings)
2657
v->value_int = ctx->ShaderStorageBufferBindings[index].Offset < 0 ? 0 :
2658
ctx->ShaderStorageBufferBindings[index].Offset;
2661
case GL_SHADER_STORAGE_BUFFER_SIZE:
2662
if (!ctx->Extensions.ARB_shader_storage_buffer_object && !_mesa_is_gles31(ctx))
2664
if (index >= ctx->Const.MaxShaderStorageBufferBindings)
2666
v->value_int = ctx->ShaderStorageBufferBindings[index].Size < 0 ? 0 :
2667
ctx->ShaderStorageBufferBindings[index].Size;
2670
/* ARB_texture_multisample / GL3.2 */
2671
case GL_SAMPLE_MASK_VALUE:
2674
if (!ctx->Extensions.ARB_texture_multisample)
2676
v->value_int = ctx->Multisample.SampleMaskValue;
2679
case GL_ATOMIC_COUNTER_BUFFER_BINDING:
2680
if (!ctx->Extensions.ARB_shader_atomic_counters && !_mesa_is_gles31(ctx))
2682
if (index >= ctx->Const.MaxAtomicBufferBindings)
2684
buf = ctx->AtomicBufferBindings[index].BufferObject;
2685
v->value_int = buf ? buf->Name : 0;
2688
case GL_ATOMIC_COUNTER_BUFFER_START:
2689
if (!ctx->Extensions.ARB_shader_atomic_counters && !_mesa_is_gles31(ctx))
2691
if (index >= ctx->Const.MaxAtomicBufferBindings)
2693
v->value_int64 = ctx->AtomicBufferBindings[index].Offset < 0 ? 0 :
2694
ctx->AtomicBufferBindings[index].Offset;
2697
case GL_ATOMIC_COUNTER_BUFFER_SIZE:
2698
if (!ctx->Extensions.ARB_shader_atomic_counters && !_mesa_is_gles31(ctx))
2700
if (index >= ctx->Const.MaxAtomicBufferBindings)
2702
v->value_int64 = ctx->AtomicBufferBindings[index].Size < 0 ? 0 :
2703
ctx->AtomicBufferBindings[index].Size;
2706
case GL_VERTEX_BINDING_DIVISOR:
2707
if ((!_mesa_is_desktop_gl(ctx) || !ctx->Extensions.ARB_instanced_arrays) &&
2708
!_mesa_is_gles31(ctx))
2710
if (index >= ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs)
2712
v->value_int = ctx->Array.VAO->BufferBinding[VERT_ATTRIB_GENERIC(index)].InstanceDivisor;
2715
case GL_VERTEX_BINDING_OFFSET:
2716
if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles31(ctx))
2718
if (index >= ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs)
2720
v->value_int = ctx->Array.VAO->BufferBinding[VERT_ATTRIB_GENERIC(index)].Offset;
2723
case GL_VERTEX_BINDING_STRIDE:
2724
if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles31(ctx))
2726
if (index >= ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs)
2728
v->value_int = ctx->Array.VAO->BufferBinding[VERT_ATTRIB_GENERIC(index)].Stride;
2731
case GL_VERTEX_BINDING_BUFFER:
2732
if (ctx->API == API_OPENGLES2 && ctx->Version < 31)
2734
if (index >= ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs)
2736
buf = ctx->Array.VAO->BufferBinding[VERT_ATTRIB_GENERIC(index)].BufferObj;
2737
v->value_int = buf ? buf->Name : 0;
2740
/* ARB_shader_image_load_store */
2741
case GL_IMAGE_BINDING_NAME: {
2742
struct gl_texture_object *t;
2744
if (!ctx->Extensions.ARB_shader_image_load_store && !_mesa_is_gles31(ctx))
2746
if (index >= ctx->Const.MaxImageUnits)
2749
t = ctx->ImageUnits[index].TexObj;
2750
v->value_int = (t ? t->Name : 0);
2754
case GL_IMAGE_BINDING_LEVEL:
2755
if (!ctx->Extensions.ARB_shader_image_load_store && !_mesa_is_gles31(ctx))
2757
if (index >= ctx->Const.MaxImageUnits)
2760
v->value_int = ctx->ImageUnits[index].Level;
2763
case GL_IMAGE_BINDING_LAYERED:
2764
if (!ctx->Extensions.ARB_shader_image_load_store && !_mesa_is_gles31(ctx))
2766
if (index >= ctx->Const.MaxImageUnits)
2769
v->value_int = ctx->ImageUnits[index].Layered;
2772
case GL_IMAGE_BINDING_LAYER:
2773
if (!ctx->Extensions.ARB_shader_image_load_store && !_mesa_is_gles31(ctx))
2775
if (index >= ctx->Const.MaxImageUnits)
2778
v->value_int = ctx->ImageUnits[index].Layer;
2781
case GL_IMAGE_BINDING_ACCESS:
2782
if (!ctx->Extensions.ARB_shader_image_load_store && !_mesa_is_gles31(ctx))
2784
if (index >= ctx->Const.MaxImageUnits)
2787
v->value_int = ctx->ImageUnits[index].Access;
2790
case GL_IMAGE_BINDING_FORMAT:
2791
if (!ctx->Extensions.ARB_shader_image_load_store && !_mesa_is_gles31(ctx))
2793
if (index >= ctx->Const.MaxImageUnits)
2796
v->value_int = ctx->ImageUnits[index].Format;
2799
/* ARB_direct_state_access */
2800
case GL_TEXTURE_BINDING_1D:
2801
case GL_TEXTURE_BINDING_1D_ARRAY:
2802
case GL_TEXTURE_BINDING_2D:
2803
case GL_TEXTURE_BINDING_2D_ARRAY:
2804
case GL_TEXTURE_BINDING_2D_MULTISAMPLE:
2805
case GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY:
2806
case GL_TEXTURE_BINDING_3D:
2807
case GL_TEXTURE_BINDING_BUFFER:
2808
case GL_TEXTURE_BINDING_CUBE_MAP:
2809
case GL_TEXTURE_BINDING_CUBE_MAP_ARRAY:
2810
case GL_TEXTURE_BINDING_RECTANGLE: {
2813
target = tex_binding_to_index(ctx, pname);
2816
if (index >= _mesa_max_tex_unit(ctx))
2819
v->value_int = ctx->Texture.Unit[index].CurrentTex[target]->Name;
2823
case GL_SAMPLER_BINDING: {
2824
struct gl_sampler_object *samp;
2826
if (!_mesa_is_desktop_gl(ctx) || ctx->Version < 33)
2828
if (index >= _mesa_max_tex_unit(ctx))
2831
samp = ctx->Texture.Unit[index].Sampler;
2832
v->value_int = samp ? samp->Name : 0;
2836
case GL_MAX_COMPUTE_WORK_GROUP_COUNT:
2837
if (!_mesa_has_compute_shaders(ctx))
2841
v->value_int = ctx->Const.MaxComputeWorkGroupCount[index];
2844
case GL_MAX_COMPUTE_WORK_GROUP_SIZE:
2845
if (!_mesa_has_compute_shaders(ctx))
2849
v->value_int = ctx->Const.MaxComputeWorkGroupSize[index];
2852
/* ARB_compute_variable_group_size */
2853
case GL_MAX_COMPUTE_VARIABLE_GROUP_SIZE_ARB:
2854
if (!ctx->Extensions.ARB_compute_variable_group_size)
2858
v->value_int = ctx->Const.MaxComputeVariableGroupSize[index];
2861
/* GL_EXT_external_objects */
2862
case GL_NUM_DEVICE_UUIDS_EXT:
2865
case GL_DRIVER_UUID_EXT:
2868
_mesa_get_driver_uuid(ctx, v->value_int_4);
2870
case GL_DEVICE_UUID_EXT:
2873
_mesa_get_device_uuid(ctx, v->value_int_4);
2875
/* GL_EXT_direct_state_access */
2879
case GL_TEXTURE_CUBE_MAP:
2880
case GL_TEXTURE_GEN_S:
2881
case GL_TEXTURE_GEN_T:
2882
case GL_TEXTURE_GEN_R:
2883
case GL_TEXTURE_GEN_Q:
2884
case GL_TEXTURE_RECTANGLE_ARB: {
2885
GLuint curTexUnitSave;
2886
if (index >= _mesa_max_tex_unit(ctx))
2888
curTexUnitSave = ctx->Texture.CurrentUnit;
2889
_mesa_ActiveTexture_no_error(GL_TEXTURE0 + index);
2890
v->value_int = _mesa_IsEnabled(pname);
2891
_mesa_ActiveTexture_no_error(GL_TEXTURE0 + curTexUnitSave);
2894
case GL_TEXTURE_COORD_ARRAY: {
2895
GLuint curTexUnitSave;
2896
if (index >= ctx->Const.MaxTextureCoordUnits)
2898
curTexUnitSave = ctx->Array.ActiveTexture;
2899
_mesa_ClientActiveTexture(GL_TEXTURE0 + index);
2900
v->value_int = _mesa_IsEnabled(pname);
2901
_mesa_ClientActiveTexture(GL_TEXTURE0 + curTexUnitSave);
2904
case GL_TEXTURE_MATRIX:
2905
if (index >= ARRAY_SIZE(ctx->TextureMatrixStack))
2907
v->value_matrix = ctx->TextureMatrixStack[index].Top;
2909
case GL_TRANSPOSE_TEXTURE_MATRIX:
2910
if (index >= ARRAY_SIZE(ctx->TextureMatrixStack))
2912
v->value_matrix = ctx->TextureMatrixStack[index].Top;
2913
return TYPE_MATRIX_T;
2914
/* GL_NV_viewport_swizzle */
2915
case GL_VIEWPORT_SWIZZLE_X_NV:
2916
if (!ctx->Extensions.NV_viewport_swizzle)
2918
if (index >= ctx->Const.MaxViewports)
2920
v->value_int = ctx->ViewportArray[index].SwizzleX;
2922
case GL_VIEWPORT_SWIZZLE_Y_NV:
2923
if (!ctx->Extensions.NV_viewport_swizzle)
2925
if (index >= ctx->Const.MaxViewports)
2927
v->value_int = ctx->ViewportArray[index].SwizzleY;
2929
case GL_VIEWPORT_SWIZZLE_Z_NV:
2930
if (!ctx->Extensions.NV_viewport_swizzle)
2932
if (index >= ctx->Const.MaxViewports)
2934
v->value_int = ctx->ViewportArray[index].SwizzleZ;
2936
case GL_VIEWPORT_SWIZZLE_W_NV:
2937
if (!ctx->Extensions.NV_viewport_swizzle)
2939
if (index >= ctx->Const.MaxViewports)
2941
v->value_int = ctx->ViewportArray[index].SwizzleW;
2946
_mesa_error(ctx, GL_INVALID_ENUM, "%s(pname=%s)", func,
2947
_mesa_enum_to_string(pname));
2948
return TYPE_INVALID;
2950
_mesa_error(ctx, GL_INVALID_VALUE, "%s(pname=%s)", func,
2951
_mesa_enum_to_string(pname));
2952
return TYPE_INVALID;
2956
_mesa_GetBooleani_v( GLenum pname, GLuint index, GLboolean *params )
2959
enum value_type type =
2960
find_value_indexed("glGetBooleani_v", pname, index, &v);
2965
params[0] = INT_TO_BOOLEAN(v.value_int);
2969
params[0] = INT_TO_BOOLEAN(v.value_int_4[0]);
2970
params[1] = INT_TO_BOOLEAN(v.value_int_4[1]);
2971
params[2] = INT_TO_BOOLEAN(v.value_int_4[2]);
2972
params[3] = INT_TO_BOOLEAN(v.value_int_4[3]);
2975
params[0] = INT64_TO_BOOLEAN(v.value_int64);
2978
; /* nothing - GL error was recorded */
2983
_mesa_GetIntegeri_v( GLenum pname, GLuint index, GLint *params )
2986
enum value_type type =
2987
find_value_indexed("glGetIntegeri_v", pname, index, &v);
2992
params[3] = lroundf(v.value_float_4[3]);
2996
params[2] = lroundf(v.value_float_4[2]);
3000
params[1] = lroundf(v.value_float_4[1]);
3004
params[0] = lroundf(v.value_float_4[0]);
3007
case TYPE_DOUBLEN_2:
3008
params[1] = lroundf(v.value_double_2[1]);
3011
params[0] = lroundf(v.value_double_2[0]);
3016
params[0] = v.value_int;
3020
params[0] = v.value_int_4[0];
3021
params[1] = v.value_int_4[1];
3022
params[2] = v.value_int_4[2];
3023
params[3] = v.value_int_4[3];
3026
params[0] = INT64_TO_INT(v.value_int64);
3029
; /* nothing - GL error was recorded */
3034
_mesa_GetInteger64i_v( GLenum pname, GLuint index, GLint64 *params )
3037
enum value_type type =
3038
find_value_indexed("glGetInteger64i_v", pname, index, &v);
3042
params[0] = v.value_int;
3045
params[0] = v.value_int_4[0];
3046
params[1] = v.value_int_4[1];
3047
params[2] = v.value_int_4[2];
3048
params[3] = v.value_int_4[3];
3051
params[0] = (GLuint) v.value_int;
3054
params[0] = (GLuint) v.value_int_4[0];
3055
params[1] = (GLuint) v.value_int_4[1];
3056
params[2] = (GLuint) v.value_int_4[2];
3057
params[3] = (GLuint) v.value_int_4[3];
3060
params[0] = v.value_int64;
3063
; /* nothing - GL error was recorded */
3068
_mesa_GetFloati_v(GLenum pname, GLuint index, GLfloat *params)
3073
enum value_type type =
3074
find_value_indexed("glGetFloati_v", pname, index, &v);
3079
params[3] = v.value_float_4[3];
3083
params[2] = v.value_float_4[2];
3087
params[1] = v.value_float_4[1];
3091
params[0] = v.value_float_4[0];
3094
case TYPE_DOUBLEN_2:
3095
params[1] = (GLfloat) v.value_double_2[1];
3098
params[0] = (GLfloat) v.value_double_2[0];
3102
params[3] = (GLfloat) v.value_int_4[3];
3105
params[2] = (GLfloat) v.value_int_4[2];
3109
params[1] = (GLfloat) v.value_int_4[1];
3114
params[0] = (GLfloat) v.value_int_4[0];
3118
for (i = 0; i < v.value_int_n.n; i++)
3119
params[i] = (GLfloat) v.value_int_n.ints[i];
3123
params[3] = (GLfloat) ((GLuint) v.value_int_4[3]);
3126
params[2] = (GLfloat) ((GLuint) v.value_int_4[2]);
3129
params[1] = (GLfloat) ((GLuint) v.value_int_4[1]);
3132
params[0] = (GLfloat) ((GLuint) v.value_int_4[0]);
3136
params[0] = (GLfloat) v.value_int64;
3140
params[0] = BOOLEAN_TO_FLOAT(v.value_bool);
3144
params[0] = (GLfloat) v.value_ubyte;
3148
params[0] = (GLfloat) v.value_short;
3152
m = *(GLmatrix **) &v;
3153
for (i = 0; i < 16; i++)
3154
params[i] = m->m[i];
3158
m = *(GLmatrix **) &v;
3159
for (i = 0; i < 16; i++)
3160
params[i] = m->m[transpose[i]];
3169
_mesa_GetDoublei_v(GLenum pname, GLuint index, GLdouble *params)
3174
enum value_type type =
3175
find_value_indexed("glGetDoublei_v", pname, index, &v);
3180
params[3] = (GLdouble) v.value_float_4[3];
3184
params[2] = (GLdouble) v.value_float_4[2];
3188
params[1] = (GLdouble) v.value_float_4[1];
3192
params[0] = (GLdouble) v.value_float_4[0];
3195
case TYPE_DOUBLEN_2:
3196
params[1] = v.value_double_2[1];
3199
params[0] = v.value_double_2[0];
3203
params[3] = (GLdouble) v.value_int_4[3];
3206
params[2] = (GLdouble) v.value_int_4[2];
3210
params[1] = (GLdouble) v.value_int_4[1];
3215
params[0] = (GLdouble) v.value_int_4[0];
3219
for (i = 0; i < v.value_int_n.n; i++)
3220
params[i] = (GLdouble) v.value_int_n.ints[i];
3224
params[3] = (GLdouble) ((GLuint) v.value_int_4[3]);
3227
params[2] = (GLdouble) ((GLuint) v.value_int_4[2]);
3230
params[1] = (GLdouble) ((GLuint) v.value_int_4[1]);
3233
params[0] = (GLdouble) ((GLuint) v.value_int_4[0]);
3237
params[0] = (GLdouble) v.value_int64;
3241
params[0] = (GLdouble) BOOLEAN_TO_FLOAT(v.value_bool);
3245
params[0] = (GLdouble) v.value_ubyte;
3249
params[0] = (GLdouble) v.value_short;
3253
m = *(GLmatrix **) &v;
3254
for (i = 0; i < 16; i++)
3255
params[i] = (GLdouble) m->m[i];
3259
m = *(GLmatrix **) &v;
3260
for (i = 0; i < 16; i++)
3261
params[i] = (GLdouble) m->m[transpose[i]];
3270
_mesa_GetUnsignedBytei_vEXT(GLenum target, GLuint index, GLubyte *data)
3274
enum value_type type;
3275
const char *func = "glGetUnsignedBytei_vEXT";
3277
GET_CURRENT_CONTEXT(ctx);
3279
if (!ctx->Extensions.EXT_memory_object) {
3280
_mesa_error(ctx, GL_INVALID_OPERATION, "%s(unsupported)", func);
3284
type = find_value_indexed(func, target, index, &v);
3285
size = get_value_size(type, &v);
3313
case TYPE_DOUBLEN_2:
3316
memcpy(data, &v.value_int, size);
3319
memcpy(data, &v.value_int_n.ints, size);
3322
break; /* nothing - GL error was recorded */
3327
_mesa_GetFixedv(GLenum pname, GLfixed *params)
3329
const struct value_desc *d;
3335
d = find_value("glGetDoublev", pname, &p, &v);
3340
params[0] = INT_TO_FIXED(d->offset);
3345
params[3] = FLOAT_TO_FIXED(((GLfloat *) p)[3]);
3349
params[2] = FLOAT_TO_FIXED(((GLfloat *) p)[2]);
3353
params[1] = FLOAT_TO_FIXED(((GLfloat *) p)[1]);
3357
params[0] = FLOAT_TO_FIXED(((GLfloat *) p)[0]);
3360
case TYPE_DOUBLEN_2:
3361
params[1] = FLOAT_TO_FIXED(((GLdouble *) p)[1]);
3364
params[0] = FLOAT_TO_FIXED(((GLdouble *) p)[0]);
3369
params[3] = INT_TO_FIXED(((GLint *) p)[3]);
3373
params[2] = INT_TO_FIXED(((GLint *) p)[2]);
3378
params[1] = INT_TO_FIXED(((GLint *) p)[1]);
3383
params[0] = INT_TO_FIXED(((GLint *) p)[0]);
3387
params[0] = INT_TO_FIXED((GLint)(((GLenum16 *) p)[0]));
3391
for (i = 0; i < v.value_int_n.n; i++)
3392
params[i] = INT_TO_FIXED(v.value_int_n.ints[i]);
3396
params[0] = ((GLint64 *) p)[0];
3400
params[0] = BOOLEAN_TO_FIXED(((GLboolean*) p)[0]);
3404
params[0] = INT_TO_FIXED(((GLubyte *) p)[0]);
3408
params[0] = INT_TO_FIXED(((GLshort *) p)[0]);
3412
m = *(GLmatrix **) p;
3413
for (i = 0; i < 16; i++)
3414
params[i] = FLOAT_TO_FIXED(m->m[i]);
3418
m = *(GLmatrix **) p;
3419
for (i = 0; i < 16; i++)
3420
params[i] = FLOAT_TO_FIXED(m->m[transpose[i]]);
3431
shift = d->type - TYPE_BIT_0;
3432
params[0] = BOOLEAN_TO_FIXED((*(GLbitfield *) p >> shift) & 1);