1bf215546Sopenharmony_ci/*
2bf215546Sopenharmony_ci * Copyright (C) 2010  Brian Paul   All Rights Reserved.
3bf215546Sopenharmony_ci * Copyright (C) 2010  Intel Corporation
4bf215546Sopenharmony_ci *
5bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a
6bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"),
7bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation
8bf215546Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9bf215546Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the
10bf215546Sopenharmony_ci * Software is furnished to do so, subject to the following conditions:
11bf215546Sopenharmony_ci *
12bf215546Sopenharmony_ci * The above copyright notice and this permission notice shall be included
13bf215546Sopenharmony_ci * in all copies or substantial portions of the Software.
14bf215546Sopenharmony_ci *
15bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16bf215546Sopenharmony_ci * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18bf215546Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
19bf215546Sopenharmony_ci * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20bf215546Sopenharmony_ci * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
21bf215546Sopenharmony_ci * OTHER DEALINGS IN THE SOFTWARE.
22bf215546Sopenharmony_ci *
23bf215546Sopenharmony_ci * Author: Kristian Høgsberg <krh@bitplanet.net>
24bf215546Sopenharmony_ci */
25bf215546Sopenharmony_ci
26bf215546Sopenharmony_ci#include "glheader.h"
27bf215546Sopenharmony_ci#include "context.h"
28bf215546Sopenharmony_ci#include "blend.h"
29bf215546Sopenharmony_ci#include "debug_output.h"
30bf215546Sopenharmony_ci#include "enable.h"
31bf215546Sopenharmony_ci#include "enums.h"
32bf215546Sopenharmony_ci#include "errors.h"
33bf215546Sopenharmony_ci#include "extensions.h"
34bf215546Sopenharmony_ci#include "get.h"
35bf215546Sopenharmony_ci#include "macros.h"
36bf215546Sopenharmony_ci#include "multisample.h"
37bf215546Sopenharmony_ci#include "mtypes.h"
38bf215546Sopenharmony_ci#include "queryobj.h"
39bf215546Sopenharmony_ci#include "spirv_extensions.h"
40bf215546Sopenharmony_ci#include "state.h"
41bf215546Sopenharmony_ci#include "texcompress.h"
42bf215546Sopenharmony_ci#include "texstate.h"
43bf215546Sopenharmony_ci#include "framebuffer.h"
44bf215546Sopenharmony_ci#include "samplerobj.h"
45bf215546Sopenharmony_ci#include "stencil.h"
46bf215546Sopenharmony_ci#include "version.h"
47bf215546Sopenharmony_ci
48bf215546Sopenharmony_ci#include "state_tracker/st_context.h"
49bf215546Sopenharmony_ci#include "api_exec_decl.h"
50bf215546Sopenharmony_ci
51bf215546Sopenharmony_ci/* This is a table driven implemetation of the glGet*v() functions.
52bf215546Sopenharmony_ci * The basic idea is that most getters just look up an int somewhere
53bf215546Sopenharmony_ci * in struct gl_context and then convert it to a bool or float according to
54bf215546Sopenharmony_ci * which of glGetIntegerv() glGetBooleanv() etc is being called.
55bf215546Sopenharmony_ci * Instead of generating code to do this, we can just record the enum
56bf215546Sopenharmony_ci * value and the offset into struct gl_context in an array of structs.  Then
57bf215546Sopenharmony_ci * in glGet*(), we lookup the struct for the enum in question, and use
58bf215546Sopenharmony_ci * the offset to get the int we need.
59bf215546Sopenharmony_ci *
60bf215546Sopenharmony_ci * Sometimes we need to look up a float, a boolean, a bit in a
61bf215546Sopenharmony_ci * bitfield, a matrix or other types instead, so we need to track the
62bf215546Sopenharmony_ci * type of the value in struct gl_context.  And sometimes the value isn't in
63bf215546Sopenharmony_ci * struct gl_context but in the drawbuffer, the array object, current texture
64bf215546Sopenharmony_ci * unit, or maybe it's a computed value.  So we need to also track
65bf215546Sopenharmony_ci * where or how to find the value.  Finally, we sometimes need to
66bf215546Sopenharmony_ci * check that one of a number of extensions are enabled, the GL
67bf215546Sopenharmony_ci * version or flush or call _mesa_update_state().  This is done by
68bf215546Sopenharmony_ci * attaching optional extra information to the value description
69bf215546Sopenharmony_ci * struct, it's sort of like an array of opcodes that describe extra
70bf215546Sopenharmony_ci * checks or actions.
71bf215546Sopenharmony_ci *
72bf215546Sopenharmony_ci * Putting all this together we end up with struct value_desc below,
73bf215546Sopenharmony_ci * and with a couple of macros to help, the table of struct value_desc
74bf215546Sopenharmony_ci * is about as concise as the specification in the old python script.
75bf215546Sopenharmony_ci */
76bf215546Sopenharmony_ci
77bf215546Sopenharmony_cistatic inline GLboolean
78bf215546Sopenharmony_ciFLOAT_TO_BOOLEAN(GLfloat X)
79bf215546Sopenharmony_ci{
80bf215546Sopenharmony_ci   return ( (X) ? GL_TRUE : GL_FALSE );
81bf215546Sopenharmony_ci}
82bf215546Sopenharmony_ci
83bf215546Sopenharmony_cistatic inline GLint
84bf215546Sopenharmony_ciFLOAT_TO_FIXED(GLfloat F)
85bf215546Sopenharmony_ci{
86bf215546Sopenharmony_ci   return ( ((F) * 65536.0f > INT_MAX) ? INT_MAX :
87bf215546Sopenharmony_ci            ((F) * 65536.0f < INT_MIN) ? INT_MIN :
88bf215546Sopenharmony_ci            (GLint) ((F) * 65536.0f) );
89bf215546Sopenharmony_ci}
90bf215546Sopenharmony_ci
91bf215546Sopenharmony_cistatic inline GLboolean
92bf215546Sopenharmony_ciINT_TO_BOOLEAN(GLint I)
93bf215546Sopenharmony_ci{
94bf215546Sopenharmony_ci   return ( (I) ? GL_TRUE : GL_FALSE );
95bf215546Sopenharmony_ci}
96bf215546Sopenharmony_ci
97bf215546Sopenharmony_cistatic inline GLfixed
98bf215546Sopenharmony_ciINT_TO_FIXED(GLint I)
99bf215546Sopenharmony_ci{
100bf215546Sopenharmony_ci   return (((I) > SHRT_MAX) ? INT_MAX :
101bf215546Sopenharmony_ci           ((I) < SHRT_MIN) ? INT_MIN :
102bf215546Sopenharmony_ci           (GLint) ((I) * 65536) );
103bf215546Sopenharmony_ci}
104bf215546Sopenharmony_ci
105bf215546Sopenharmony_ci
106bf215546Sopenharmony_cistatic inline GLboolean
107bf215546Sopenharmony_ciINT64_TO_BOOLEAN(GLint64 I)
108bf215546Sopenharmony_ci{
109bf215546Sopenharmony_ci   return ( (I) ? GL_TRUE : GL_FALSE );
110bf215546Sopenharmony_ci}
111bf215546Sopenharmony_ci
112bf215546Sopenharmony_cistatic inline GLint
113bf215546Sopenharmony_ciINT64_TO_INT(GLint64 I)
114bf215546Sopenharmony_ci{
115bf215546Sopenharmony_ci   return ( (GLint)((I > INT_MAX) ? INT_MAX : ((I < INT_MIN) ? INT_MIN : (I))) );
116bf215546Sopenharmony_ci}
117bf215546Sopenharmony_ci
118bf215546Sopenharmony_cistatic inline GLint
119bf215546Sopenharmony_ciBOOLEAN_TO_INT(GLboolean B)
120bf215546Sopenharmony_ci{
121bf215546Sopenharmony_ci   return ( (GLint) (B) );
122bf215546Sopenharmony_ci}
123bf215546Sopenharmony_ci
124bf215546Sopenharmony_cistatic inline GLfloat
125bf215546Sopenharmony_ciBOOLEAN_TO_FLOAT(GLboolean B)
126bf215546Sopenharmony_ci{
127bf215546Sopenharmony_ci   return ( (B) ? 1.0F : 0.0F );
128bf215546Sopenharmony_ci}
129bf215546Sopenharmony_ci
130bf215546Sopenharmony_cistatic inline GLfixed
131bf215546Sopenharmony_ciBOOLEAN_TO_FIXED(GLboolean B)
132bf215546Sopenharmony_ci{
133bf215546Sopenharmony_ci   return ( (GLint) ((B) ? 1 : 0) << 16 );
134bf215546Sopenharmony_ci}
135bf215546Sopenharmony_ci
136bf215546Sopenharmony_cienum value_type {
137bf215546Sopenharmony_ci   TYPE_INVALID,
138bf215546Sopenharmony_ci   TYPE_INT,
139bf215546Sopenharmony_ci   TYPE_INT_2,
140bf215546Sopenharmony_ci   TYPE_INT_3,
141bf215546Sopenharmony_ci   TYPE_INT_4,
142bf215546Sopenharmony_ci   TYPE_INT_N,
143bf215546Sopenharmony_ci   TYPE_UINT,
144bf215546Sopenharmony_ci   TYPE_UINT_2,
145bf215546Sopenharmony_ci   TYPE_UINT_3,
146bf215546Sopenharmony_ci   TYPE_UINT_4,
147bf215546Sopenharmony_ci   TYPE_INT64,
148bf215546Sopenharmony_ci   TYPE_ENUM16,
149bf215546Sopenharmony_ci   TYPE_ENUM,
150bf215546Sopenharmony_ci   TYPE_ENUM_2,
151bf215546Sopenharmony_ci   TYPE_BOOLEAN,
152bf215546Sopenharmony_ci   TYPE_UBYTE,
153bf215546Sopenharmony_ci   TYPE_SHORT,
154bf215546Sopenharmony_ci   TYPE_BIT_0,
155bf215546Sopenharmony_ci   TYPE_BIT_1,
156bf215546Sopenharmony_ci   TYPE_BIT_2,
157bf215546Sopenharmony_ci   TYPE_BIT_3,
158bf215546Sopenharmony_ci   TYPE_BIT_4,
159bf215546Sopenharmony_ci   TYPE_BIT_5,
160bf215546Sopenharmony_ci   TYPE_BIT_6,
161bf215546Sopenharmony_ci   TYPE_BIT_7,
162bf215546Sopenharmony_ci   TYPE_FLOAT,
163bf215546Sopenharmony_ci   TYPE_FLOAT_2,
164bf215546Sopenharmony_ci   TYPE_FLOAT_3,
165bf215546Sopenharmony_ci   TYPE_FLOAT_4,
166bf215546Sopenharmony_ci   TYPE_FLOAT_8,
167bf215546Sopenharmony_ci   TYPE_FLOATN,
168bf215546Sopenharmony_ci   TYPE_FLOATN_2,
169bf215546Sopenharmony_ci   TYPE_FLOATN_3,
170bf215546Sopenharmony_ci   TYPE_FLOATN_4,
171bf215546Sopenharmony_ci   TYPE_DOUBLEN,
172bf215546Sopenharmony_ci   TYPE_DOUBLEN_2,
173bf215546Sopenharmony_ci   TYPE_MATRIX,
174bf215546Sopenharmony_ci   TYPE_MATRIX_T,
175bf215546Sopenharmony_ci   TYPE_CONST
176bf215546Sopenharmony_ci};
177bf215546Sopenharmony_ci
178bf215546Sopenharmony_cienum value_location {
179bf215546Sopenharmony_ci   LOC_BUFFER,
180bf215546Sopenharmony_ci   LOC_CONTEXT,
181bf215546Sopenharmony_ci   LOC_ARRAY,
182bf215546Sopenharmony_ci   LOC_TEXUNIT,
183bf215546Sopenharmony_ci   LOC_CUSTOM
184bf215546Sopenharmony_ci};
185bf215546Sopenharmony_ci
186bf215546Sopenharmony_cienum value_extra {
187bf215546Sopenharmony_ci   EXTRA_END = 0x8000,
188bf215546Sopenharmony_ci   EXTRA_VERSION_30,
189bf215546Sopenharmony_ci   EXTRA_VERSION_31,
190bf215546Sopenharmony_ci   EXTRA_VERSION_32,
191bf215546Sopenharmony_ci   EXTRA_VERSION_40,
192bf215546Sopenharmony_ci   EXTRA_VERSION_43,
193bf215546Sopenharmony_ci   EXTRA_API_GL,
194bf215546Sopenharmony_ci   EXTRA_API_GL_CORE,
195bf215546Sopenharmony_ci   EXTRA_API_ES2,
196bf215546Sopenharmony_ci   EXTRA_API_ES3,
197bf215546Sopenharmony_ci   EXTRA_API_ES31,
198bf215546Sopenharmony_ci   EXTRA_API_ES32,
199bf215546Sopenharmony_ci   EXTRA_NEW_BUFFERS,
200bf215546Sopenharmony_ci   EXTRA_VALID_DRAW_BUFFER,
201bf215546Sopenharmony_ci   EXTRA_VALID_TEXTURE_UNIT,
202bf215546Sopenharmony_ci   EXTRA_VALID_CLIP_DISTANCE,
203bf215546Sopenharmony_ci   EXTRA_FLUSH_CURRENT,
204bf215546Sopenharmony_ci   EXTRA_GLSL_130,
205bf215546Sopenharmony_ci   EXTRA_EXT_UBO_GS,
206bf215546Sopenharmony_ci   EXTRA_EXT_ATOMICS_GS,
207bf215546Sopenharmony_ci   EXTRA_EXT_SHADER_IMAGE_GS,
208bf215546Sopenharmony_ci   EXTRA_EXT_ATOMICS_TESS,
209bf215546Sopenharmony_ci   EXTRA_EXT_SHADER_IMAGE_TESS,
210bf215546Sopenharmony_ci   EXTRA_EXT_SSBO_GS,
211bf215546Sopenharmony_ci   EXTRA_EXT_FB_NO_ATTACH_GS,
212bf215546Sopenharmony_ci   EXTRA_EXT_ES_GS,
213bf215546Sopenharmony_ci   EXTRA_EXT_PROVOKING_VERTEX_32,
214bf215546Sopenharmony_ci};
215bf215546Sopenharmony_ci
216bf215546Sopenharmony_ci#define NO_EXTRA NULL
217bf215546Sopenharmony_ci#define NO_OFFSET 0
218bf215546Sopenharmony_ci
219bf215546Sopenharmony_cistruct value_desc {
220bf215546Sopenharmony_ci   GLenum pname;
221bf215546Sopenharmony_ci   GLubyte location;  /**< enum value_location */
222bf215546Sopenharmony_ci   GLubyte type;      /**< enum value_type */
223bf215546Sopenharmony_ci   int offset;
224bf215546Sopenharmony_ci   const int *extra;
225bf215546Sopenharmony_ci};
226bf215546Sopenharmony_ci
227bf215546Sopenharmony_ciunion value {
228bf215546Sopenharmony_ci   GLfloat value_float;
229bf215546Sopenharmony_ci   GLfloat value_float_4[4];
230bf215546Sopenharmony_ci   GLdouble value_double_2[2];
231bf215546Sopenharmony_ci   GLmatrix *value_matrix;
232bf215546Sopenharmony_ci   GLint value_int;
233bf215546Sopenharmony_ci   GLint value_int_2[2];
234bf215546Sopenharmony_ci   GLint value_int_4[4];
235bf215546Sopenharmony_ci   GLint64 value_int64;
236bf215546Sopenharmony_ci   GLenum value_enum;
237bf215546Sopenharmony_ci   GLenum16 value_enum16;
238bf215546Sopenharmony_ci   GLubyte value_ubyte;
239bf215546Sopenharmony_ci   GLshort value_short;
240bf215546Sopenharmony_ci   GLuint value_uint;
241bf215546Sopenharmony_ci
242bf215546Sopenharmony_ci   /* Sigh, see GL_COMPRESSED_TEXTURE_FORMATS_ARB handling */
243bf215546Sopenharmony_ci   struct {
244bf215546Sopenharmony_ci      GLint n, ints[100];
245bf215546Sopenharmony_ci   } value_int_n;
246bf215546Sopenharmony_ci   GLboolean value_bool;
247bf215546Sopenharmony_ci};
248bf215546Sopenharmony_ci
249bf215546Sopenharmony_ci#define BUFFER_FIELD(field, type) \
250bf215546Sopenharmony_ci   LOC_BUFFER, type, offsetof(struct gl_framebuffer, field)
251bf215546Sopenharmony_ci#define CONTEXT_FIELD(field, type) \
252bf215546Sopenharmony_ci   LOC_CONTEXT, type, offsetof(struct gl_context, field)
253bf215546Sopenharmony_ci#define ARRAY_FIELD(field, type) \
254bf215546Sopenharmony_ci   LOC_ARRAY, type, offsetof(struct gl_vertex_array_object, field)
255bf215546Sopenharmony_ci#undef CONST /* already defined through windows.h */
256bf215546Sopenharmony_ci#define CONST(value) \
257bf215546Sopenharmony_ci   LOC_CONTEXT, TYPE_CONST, value
258bf215546Sopenharmony_ci
259bf215546Sopenharmony_ci#define BUFFER_INT(field) BUFFER_FIELD(field, TYPE_INT)
260bf215546Sopenharmony_ci#define BUFFER_ENUM(field) BUFFER_FIELD(field, TYPE_ENUM)
261bf215546Sopenharmony_ci#define BUFFER_ENUM16(field) BUFFER_FIELD(field, TYPE_ENUM16)
262bf215546Sopenharmony_ci#define BUFFER_BOOL(field) BUFFER_FIELD(field, TYPE_BOOLEAN)
263bf215546Sopenharmony_ci
264bf215546Sopenharmony_ci#define CONTEXT_INT(field) CONTEXT_FIELD(field, TYPE_INT)
265bf215546Sopenharmony_ci#define CONTEXT_INT2(field) CONTEXT_FIELD(field, TYPE_INT_2)
266bf215546Sopenharmony_ci#define CONTEXT_INT64(field) CONTEXT_FIELD(field, TYPE_INT64)
267bf215546Sopenharmony_ci#define CONTEXT_UINT(field) CONTEXT_FIELD(field, TYPE_UINT)
268bf215546Sopenharmony_ci#define CONTEXT_ENUM16(field) CONTEXT_FIELD(field, TYPE_ENUM16)
269bf215546Sopenharmony_ci#define CONTEXT_ENUM(field) CONTEXT_FIELD(field, TYPE_ENUM)
270bf215546Sopenharmony_ci#define CONTEXT_ENUM2(field) CONTEXT_FIELD(field, TYPE_ENUM_2)
271bf215546Sopenharmony_ci#define CONTEXT_BOOL(field) CONTEXT_FIELD(field, TYPE_BOOLEAN)
272bf215546Sopenharmony_ci#define CONTEXT_BIT0(field) CONTEXT_FIELD(field, TYPE_BIT_0)
273bf215546Sopenharmony_ci#define CONTEXT_BIT1(field) CONTEXT_FIELD(field, TYPE_BIT_1)
274bf215546Sopenharmony_ci#define CONTEXT_BIT2(field) CONTEXT_FIELD(field, TYPE_BIT_2)
275bf215546Sopenharmony_ci#define CONTEXT_BIT3(field) CONTEXT_FIELD(field, TYPE_BIT_3)
276bf215546Sopenharmony_ci#define CONTEXT_BIT4(field) CONTEXT_FIELD(field, TYPE_BIT_4)
277bf215546Sopenharmony_ci#define CONTEXT_BIT5(field) CONTEXT_FIELD(field, TYPE_BIT_5)
278bf215546Sopenharmony_ci#define CONTEXT_BIT6(field) CONTEXT_FIELD(field, TYPE_BIT_6)
279bf215546Sopenharmony_ci#define CONTEXT_BIT7(field) CONTEXT_FIELD(field, TYPE_BIT_7)
280bf215546Sopenharmony_ci#define CONTEXT_FLOAT(field) CONTEXT_FIELD(field, TYPE_FLOAT)
281bf215546Sopenharmony_ci#define CONTEXT_FLOAT2(field) CONTEXT_FIELD(field, TYPE_FLOAT_2)
282bf215546Sopenharmony_ci#define CONTEXT_FLOAT3(field) CONTEXT_FIELD(field, TYPE_FLOAT_3)
283bf215546Sopenharmony_ci#define CONTEXT_FLOAT4(field) CONTEXT_FIELD(field, TYPE_FLOAT_4)
284bf215546Sopenharmony_ci#define CONTEXT_FLOAT8(field) CONTEXT_FIELD(field, TYPE_FLOAT_8)
285bf215546Sopenharmony_ci#define CONTEXT_MATRIX(field) CONTEXT_FIELD(field, TYPE_MATRIX)
286bf215546Sopenharmony_ci#define CONTEXT_MATRIX_T(field) CONTEXT_FIELD(field, TYPE_MATRIX_T)
287bf215546Sopenharmony_ci
288bf215546Sopenharmony_ci/* Vertex array fields */
289bf215546Sopenharmony_ci#define ARRAY_INT(field) ARRAY_FIELD(field, TYPE_INT)
290bf215546Sopenharmony_ci#define ARRAY_ENUM(field) ARRAY_FIELD(field, TYPE_ENUM)
291bf215546Sopenharmony_ci#define ARRAY_ENUM16(field) ARRAY_FIELD(field, TYPE_ENUM16)
292bf215546Sopenharmony_ci#define ARRAY_BOOL(field) ARRAY_FIELD(field, TYPE_BOOLEAN)
293bf215546Sopenharmony_ci#define ARRAY_UBYTE(field) ARRAY_FIELD(field, TYPE_UBYTE)
294bf215546Sopenharmony_ci#define ARRAY_SHORT(field) ARRAY_FIELD(field, TYPE_SHORT)
295bf215546Sopenharmony_ci
296bf215546Sopenharmony_ci#define EXT(f)					\
297bf215546Sopenharmony_ci   offsetof(struct gl_extensions, f)
298bf215546Sopenharmony_ci
299bf215546Sopenharmony_ci#define EXTRA_EXT(e)				\
300bf215546Sopenharmony_ci   static const int extra_##e[] = {		\
301bf215546Sopenharmony_ci      EXT(e), EXTRA_END				\
302bf215546Sopenharmony_ci   }
303bf215546Sopenharmony_ci
304bf215546Sopenharmony_ci#define EXTRA_EXT2(e1, e2)			\
305bf215546Sopenharmony_ci   static const int extra_##e1##_##e2[] = {	\
306bf215546Sopenharmony_ci      EXT(e1), EXT(e2), EXTRA_END		\
307bf215546Sopenharmony_ci   }
308bf215546Sopenharmony_ci
309bf215546Sopenharmony_ci/* The 'extra' mechanism is a way to specify extra checks (such as
310bf215546Sopenharmony_ci * extensions or specific gl versions) or actions (flush current, new
311bf215546Sopenharmony_ci * buffers) that we need to do before looking up an enum.  We need to
312bf215546Sopenharmony_ci * declare them all up front so we can refer to them in the value_desc
313bf215546Sopenharmony_ci * structs below.
314bf215546Sopenharmony_ci *
315bf215546Sopenharmony_ci * Each EXTRA_ will be executed.  For EXTRA_* enums of extensions and API
316bf215546Sopenharmony_ci * versions, listing multiple ones in an array means an error will be thrown
317bf215546Sopenharmony_ci * only if none of them are available.  If you need to check for "AND"
318bf215546Sopenharmony_ci * behavior, you would need to make a custom EXTRA_ enum.
319bf215546Sopenharmony_ci */
320bf215546Sopenharmony_ci
321bf215546Sopenharmony_cistatic const int extra_new_buffers[] = {
322bf215546Sopenharmony_ci   EXTRA_NEW_BUFFERS,
323bf215546Sopenharmony_ci   EXTRA_END
324bf215546Sopenharmony_ci};
325bf215546Sopenharmony_ci
326bf215546Sopenharmony_cistatic const int extra_valid_draw_buffer[] = {
327bf215546Sopenharmony_ci   EXTRA_VALID_DRAW_BUFFER,
328bf215546Sopenharmony_ci   EXTRA_END
329bf215546Sopenharmony_ci};
330bf215546Sopenharmony_ci
331bf215546Sopenharmony_cistatic const int extra_valid_texture_unit[] = {
332bf215546Sopenharmony_ci   EXTRA_VALID_TEXTURE_UNIT,
333bf215546Sopenharmony_ci   EXTRA_END
334bf215546Sopenharmony_ci};
335bf215546Sopenharmony_ci
336bf215546Sopenharmony_cistatic const int extra_valid_clip_distance[] = {
337bf215546Sopenharmony_ci   EXTRA_VALID_CLIP_DISTANCE,
338bf215546Sopenharmony_ci   EXTRA_END
339bf215546Sopenharmony_ci};
340bf215546Sopenharmony_ci
341bf215546Sopenharmony_cistatic const int extra_flush_current_valid_texture_unit[] = {
342bf215546Sopenharmony_ci   EXTRA_FLUSH_CURRENT,
343bf215546Sopenharmony_ci   EXTRA_VALID_TEXTURE_UNIT,
344bf215546Sopenharmony_ci   EXTRA_END
345bf215546Sopenharmony_ci};
346bf215546Sopenharmony_ci
347bf215546Sopenharmony_cistatic const int extra_flush_current[] = {
348bf215546Sopenharmony_ci   EXTRA_FLUSH_CURRENT,
349bf215546Sopenharmony_ci   EXTRA_END
350bf215546Sopenharmony_ci};
351bf215546Sopenharmony_ci
352bf215546Sopenharmony_cistatic const int extra_EXT_texture_integer_and_new_buffers[] = {
353bf215546Sopenharmony_ci   EXT(EXT_texture_integer),
354bf215546Sopenharmony_ci   EXTRA_NEW_BUFFERS,
355bf215546Sopenharmony_ci   EXTRA_END
356bf215546Sopenharmony_ci};
357bf215546Sopenharmony_ci
358bf215546Sopenharmony_cistatic const int extra_GLSL_130_es3_gpushader4[] = {
359bf215546Sopenharmony_ci   EXTRA_GLSL_130,
360bf215546Sopenharmony_ci   EXTRA_API_ES3,
361bf215546Sopenharmony_ci   EXT(EXT_gpu_shader4),
362bf215546Sopenharmony_ci   EXTRA_END
363bf215546Sopenharmony_ci};
364bf215546Sopenharmony_ci
365bf215546Sopenharmony_cistatic const int extra_texture_buffer_object[] = {
366bf215546Sopenharmony_ci   EXT(ARB_texture_buffer_object),
367bf215546Sopenharmony_ci   EXTRA_END
368bf215546Sopenharmony_ci};
369bf215546Sopenharmony_ci
370bf215546Sopenharmony_cistatic const int extra_ARB_transform_feedback2_api_es3[] = {
371bf215546Sopenharmony_ci   EXT(ARB_transform_feedback2),
372bf215546Sopenharmony_ci   EXTRA_API_ES3,
373bf215546Sopenharmony_ci   EXTRA_END
374bf215546Sopenharmony_ci};
375bf215546Sopenharmony_ci
376bf215546Sopenharmony_cistatic const int extra_ARB_uniform_buffer_object_and_geometry_shader[] = {
377bf215546Sopenharmony_ci   EXTRA_EXT_UBO_GS,
378bf215546Sopenharmony_ci   EXTRA_END
379bf215546Sopenharmony_ci};
380bf215546Sopenharmony_ci
381bf215546Sopenharmony_cistatic const int extra_ARB_ES2_compatibility_api_es2[] = {
382bf215546Sopenharmony_ci   EXT(ARB_ES2_compatibility),
383bf215546Sopenharmony_ci   EXTRA_API_ES2,
384bf215546Sopenharmony_ci   EXTRA_END
385bf215546Sopenharmony_ci};
386bf215546Sopenharmony_ci
387bf215546Sopenharmony_cistatic const int extra_ARB_ES3_compatibility_api_es3[] = {
388bf215546Sopenharmony_ci   EXT(ARB_ES3_compatibility),
389bf215546Sopenharmony_ci   EXTRA_API_ES3,
390bf215546Sopenharmony_ci   EXTRA_END
391bf215546Sopenharmony_ci};
392bf215546Sopenharmony_ci
393bf215546Sopenharmony_cistatic const int extra_EXT_framebuffer_sRGB_and_new_buffers[] = {
394bf215546Sopenharmony_ci   EXT(EXT_framebuffer_sRGB),
395bf215546Sopenharmony_ci   EXTRA_NEW_BUFFERS,
396bf215546Sopenharmony_ci   EXTRA_END
397bf215546Sopenharmony_ci};
398bf215546Sopenharmony_ci
399bf215546Sopenharmony_cistatic const int extra_EXT_packed_float[] = {
400bf215546Sopenharmony_ci   EXT(EXT_packed_float),
401bf215546Sopenharmony_ci   EXTRA_NEW_BUFFERS,
402bf215546Sopenharmony_ci   EXTRA_END
403bf215546Sopenharmony_ci};
404bf215546Sopenharmony_ci
405bf215546Sopenharmony_cistatic const int extra_EXT_texture_array_es3[] = {
406bf215546Sopenharmony_ci   EXT(EXT_texture_array),
407bf215546Sopenharmony_ci   EXTRA_API_ES3,
408bf215546Sopenharmony_ci   EXTRA_END
409bf215546Sopenharmony_ci};
410bf215546Sopenharmony_ci
411bf215546Sopenharmony_cistatic const int extra_ARB_shader_atomic_counters_and_geometry_shader[] = {
412bf215546Sopenharmony_ci   EXTRA_EXT_ATOMICS_GS,
413bf215546Sopenharmony_ci   EXTRA_END
414bf215546Sopenharmony_ci};
415bf215546Sopenharmony_ci
416bf215546Sopenharmony_cistatic const int extra_ARB_shader_atomic_counters_es31[] = {
417bf215546Sopenharmony_ci   EXT(ARB_shader_atomic_counters),
418bf215546Sopenharmony_ci   EXTRA_API_ES31,
419bf215546Sopenharmony_ci   EXTRA_END
420bf215546Sopenharmony_ci};
421bf215546Sopenharmony_ci
422bf215546Sopenharmony_cistatic const int extra_ARB_shader_image_load_store_and_geometry_shader[] = {
423bf215546Sopenharmony_ci   EXTRA_EXT_SHADER_IMAGE_GS,
424bf215546Sopenharmony_ci   EXTRA_END
425bf215546Sopenharmony_ci};
426bf215546Sopenharmony_ci
427bf215546Sopenharmony_cistatic const int extra_ARB_shader_atomic_counters_and_tessellation[] = {
428bf215546Sopenharmony_ci   EXTRA_EXT_ATOMICS_TESS,
429bf215546Sopenharmony_ci   EXTRA_END
430bf215546Sopenharmony_ci};
431bf215546Sopenharmony_ci
432bf215546Sopenharmony_cistatic const int extra_ARB_shader_image_load_store_and_tessellation[] = {
433bf215546Sopenharmony_ci   EXTRA_EXT_SHADER_IMAGE_TESS,
434bf215546Sopenharmony_ci   EXTRA_END
435bf215546Sopenharmony_ci};
436bf215546Sopenharmony_ci
437bf215546Sopenharmony_cistatic const int extra_ARB_shader_image_load_store_es31[] = {
438bf215546Sopenharmony_ci   EXT(ARB_shader_image_load_store),
439bf215546Sopenharmony_ci   EXTRA_API_ES31,
440bf215546Sopenharmony_ci   EXTRA_END
441bf215546Sopenharmony_ci};
442bf215546Sopenharmony_ci
443bf215546Sopenharmony_ci/* HACK: remove when ARB_compute_shader is actually supported */
444bf215546Sopenharmony_cistatic const int extra_ARB_compute_shader_es31[] = {
445bf215546Sopenharmony_ci   EXT(ARB_compute_shader),
446bf215546Sopenharmony_ci   EXTRA_API_ES31,
447bf215546Sopenharmony_ci   EXTRA_END
448bf215546Sopenharmony_ci};
449bf215546Sopenharmony_ci
450bf215546Sopenharmony_cistatic const int extra_ARB_shader_storage_buffer_object_es31[] = {
451bf215546Sopenharmony_ci   EXT(ARB_shader_storage_buffer_object),
452bf215546Sopenharmony_ci   EXTRA_API_ES31,
453bf215546Sopenharmony_ci   EXTRA_END
454bf215546Sopenharmony_ci};
455bf215546Sopenharmony_ci
456bf215546Sopenharmony_cistatic const int extra_ARB_shader_storage_buffer_object_and_geometry_shader[] = {
457bf215546Sopenharmony_ci   EXTRA_EXT_SSBO_GS,
458bf215546Sopenharmony_ci   EXTRA_END
459bf215546Sopenharmony_ci};
460bf215546Sopenharmony_ci
461bf215546Sopenharmony_cistatic const int extra_ARB_shader_image_load_store_shader_storage_buffer_object_es31[] = {
462bf215546Sopenharmony_ci   EXT(ARB_shader_image_load_store),
463bf215546Sopenharmony_ci   EXT(ARB_shader_storage_buffer_object),
464bf215546Sopenharmony_ci   EXTRA_API_ES31,
465bf215546Sopenharmony_ci   EXTRA_END
466bf215546Sopenharmony_ci};
467bf215546Sopenharmony_ci
468bf215546Sopenharmony_cistatic const int extra_ARB_framebuffer_no_attachments_and_geometry_shader[] = {
469bf215546Sopenharmony_ci   EXTRA_EXT_FB_NO_ATTACH_GS,
470bf215546Sopenharmony_ci   EXTRA_END
471bf215546Sopenharmony_ci};
472bf215546Sopenharmony_ci
473bf215546Sopenharmony_cistatic const int extra_ARB_viewport_array_or_oes_geometry_shader[] = {
474bf215546Sopenharmony_ci   EXT(ARB_viewport_array),
475bf215546Sopenharmony_ci   EXTRA_EXT_ES_GS,
476bf215546Sopenharmony_ci   EXTRA_END
477bf215546Sopenharmony_ci};
478bf215546Sopenharmony_ci
479bf215546Sopenharmony_cistatic const int extra_ARB_viewport_array_or_oes_viewport_array[] = {
480bf215546Sopenharmony_ci   EXT(ARB_viewport_array),
481bf215546Sopenharmony_ci   EXT(OES_viewport_array),
482bf215546Sopenharmony_ci   EXTRA_END
483bf215546Sopenharmony_ci};
484bf215546Sopenharmony_ci
485bf215546Sopenharmony_cistatic const int extra_ARB_gpu_shader5_or_oes_geometry_shader[] = {
486bf215546Sopenharmony_ci   EXT(ARB_gpu_shader5),
487bf215546Sopenharmony_ci   EXTRA_EXT_ES_GS,
488bf215546Sopenharmony_ci   EXTRA_END
489bf215546Sopenharmony_ci};
490bf215546Sopenharmony_ci
491bf215546Sopenharmony_cistatic const int extra_ARB_gpu_shader5_or_OES_sample_variables[] = {
492bf215546Sopenharmony_ci   EXT(ARB_gpu_shader5),
493bf215546Sopenharmony_ci   EXT(OES_sample_variables),
494bf215546Sopenharmony_ci   EXTRA_END
495bf215546Sopenharmony_ci};
496bf215546Sopenharmony_ci
497bf215546Sopenharmony_cistatic const int extra_ES32[] = {
498bf215546Sopenharmony_ci   EXT(ARB_ES3_2_compatibility),
499bf215546Sopenharmony_ci   EXTRA_API_ES32,
500bf215546Sopenharmony_ci   EXTRA_END
501bf215546Sopenharmony_ci};
502bf215546Sopenharmony_ci
503bf215546Sopenharmony_cistatic const int extra_KHR_robustness_or_GL[] = {
504bf215546Sopenharmony_ci   EXT(KHR_robustness),
505bf215546Sopenharmony_ci   EXTRA_API_GL,
506bf215546Sopenharmony_ci   EXTRA_API_GL_CORE,
507bf215546Sopenharmony_ci   EXTRA_END
508bf215546Sopenharmony_ci};
509bf215546Sopenharmony_ci
510bf215546Sopenharmony_cistatic const int extra_INTEL_conservative_rasterization[] = {
511bf215546Sopenharmony_ci   EXT(INTEL_conservative_rasterization),
512bf215546Sopenharmony_ci   EXTRA_END
513bf215546Sopenharmony_ci};
514bf215546Sopenharmony_ci
515bf215546Sopenharmony_cistatic const int extra_ARB_timer_query_or_EXT_disjoint_timer_query[] = {
516bf215546Sopenharmony_ci   EXT(ARB_timer_query),
517bf215546Sopenharmony_ci   EXT(EXT_disjoint_timer_query),
518bf215546Sopenharmony_ci   EXTRA_END
519bf215546Sopenharmony_ci};
520bf215546Sopenharmony_ci
521bf215546Sopenharmony_cistatic const int extra_ARB_framebuffer_object_or_EXT_framebuffer_multisample_or_EXT_multisampled_render_to_texture[] = {
522bf215546Sopenharmony_ci   EXT(ARB_framebuffer_object),
523bf215546Sopenharmony_ci   EXT(EXT_framebuffer_multisample),
524bf215546Sopenharmony_ci   EXT(EXT_multisampled_render_to_texture),
525bf215546Sopenharmony_ci   EXTRA_END
526bf215546Sopenharmony_ci};
527bf215546Sopenharmony_ci
528bf215546Sopenharmony_ciEXTRA_EXT(EXT_texture_array);
529bf215546Sopenharmony_ciEXTRA_EXT(NV_fog_distance);
530bf215546Sopenharmony_ciEXTRA_EXT(EXT_texture_filter_anisotropic);
531bf215546Sopenharmony_ciEXTRA_EXT(NV_texture_rectangle);
532bf215546Sopenharmony_ciEXTRA_EXT(EXT_stencil_two_side);
533bf215546Sopenharmony_ciEXTRA_EXT(EXT_depth_bounds_test);
534bf215546Sopenharmony_ciEXTRA_EXT(ARB_depth_clamp);
535bf215546Sopenharmony_ciEXTRA_EXT(AMD_depth_clamp_separate);
536bf215546Sopenharmony_ciEXTRA_EXT(ATI_fragment_shader);
537bf215546Sopenharmony_ciEXTRA_EXT(EXT_provoking_vertex);
538bf215546Sopenharmony_ciEXTRA_EXT(ARB_fragment_shader);
539bf215546Sopenharmony_ciEXTRA_EXT(ARB_fragment_program);
540bf215546Sopenharmony_ciEXTRA_EXT(ARB_seamless_cube_map);
541bf215546Sopenharmony_ciEXTRA_EXT(ARB_sync);
542bf215546Sopenharmony_ciEXTRA_EXT(ARB_vertex_shader);
543bf215546Sopenharmony_ciEXTRA_EXT(EXT_transform_feedback);
544bf215546Sopenharmony_ciEXTRA_EXT(ARB_transform_feedback3);
545bf215546Sopenharmony_ciEXTRA_EXT(EXT_pixel_buffer_object);
546bf215546Sopenharmony_ciEXTRA_EXT(ARB_vertex_program);
547bf215546Sopenharmony_ciEXTRA_EXT(ARB_point_sprite);
548bf215546Sopenharmony_ciEXTRA_EXT2(ARB_vertex_program, ARB_fragment_program);
549bf215546Sopenharmony_ciEXTRA_EXT(ARB_color_buffer_float);
550bf215546Sopenharmony_ciEXTRA_EXT(EXT_framebuffer_sRGB);
551bf215546Sopenharmony_ciEXTRA_EXT(OES_EGL_image_external);
552bf215546Sopenharmony_ciEXTRA_EXT(ARB_blend_func_extended);
553bf215546Sopenharmony_ciEXTRA_EXT(ARB_uniform_buffer_object);
554bf215546Sopenharmony_ciEXTRA_EXT2(ARB_texture_cube_map_array, OES_texture_cube_map_array);
555bf215546Sopenharmony_ciEXTRA_EXT(ARB_texture_buffer_range);
556bf215546Sopenharmony_ciEXTRA_EXT(ARB_texture_multisample);
557bf215546Sopenharmony_ciEXTRA_EXT(ARB_texture_gather);
558bf215546Sopenharmony_ciEXTRA_EXT(ARB_draw_indirect);
559bf215546Sopenharmony_ciEXTRA_EXT(ARB_shader_image_load_store);
560bf215546Sopenharmony_ciEXTRA_EXT(ARB_query_buffer_object);
561bf215546Sopenharmony_ciEXTRA_EXT2(ARB_transform_feedback3, ARB_gpu_shader5);
562bf215546Sopenharmony_ciEXTRA_EXT(INTEL_performance_query);
563bf215546Sopenharmony_ciEXTRA_EXT(ARB_explicit_uniform_location);
564bf215546Sopenharmony_ciEXTRA_EXT(ARB_clip_control);
565bf215546Sopenharmony_ciEXTRA_EXT(ARB_polygon_offset_clamp);
566bf215546Sopenharmony_ciEXTRA_EXT(ARB_framebuffer_no_attachments);
567bf215546Sopenharmony_ciEXTRA_EXT(ARB_tessellation_shader);
568bf215546Sopenharmony_ciEXTRA_EXT(ARB_shader_storage_buffer_object);
569bf215546Sopenharmony_ciEXTRA_EXT(ARB_indirect_parameters);
570bf215546Sopenharmony_ciEXTRA_EXT(ATI_meminfo);
571bf215546Sopenharmony_ciEXTRA_EXT(NVX_gpu_memory_info);
572bf215546Sopenharmony_ciEXTRA_EXT(ARB_cull_distance);
573bf215546Sopenharmony_ciEXTRA_EXT(EXT_window_rectangles);
574bf215546Sopenharmony_ciEXTRA_EXT(KHR_blend_equation_advanced_coherent);
575bf215546Sopenharmony_ciEXTRA_EXT(OES_primitive_bounding_box);
576bf215546Sopenharmony_ciEXTRA_EXT(ARB_compute_variable_group_size);
577bf215546Sopenharmony_ciEXTRA_EXT(KHR_robustness);
578bf215546Sopenharmony_ciEXTRA_EXT(ARB_sparse_buffer);
579bf215546Sopenharmony_ciEXTRA_EXT(NV_conservative_raster);
580bf215546Sopenharmony_ciEXTRA_EXT(NV_conservative_raster_dilate);
581bf215546Sopenharmony_ciEXTRA_EXT(NV_conservative_raster_pre_snap_triangles);
582bf215546Sopenharmony_ciEXTRA_EXT(ARB_sample_locations);
583bf215546Sopenharmony_ciEXTRA_EXT(AMD_framebuffer_multisample_advanced);
584bf215546Sopenharmony_ciEXTRA_EXT(ARB_spirv_extensions);
585bf215546Sopenharmony_ciEXTRA_EXT(NV_viewport_swizzle);
586bf215546Sopenharmony_ciEXTRA_EXT(ARB_sparse_texture);
587bf215546Sopenharmony_ci
588bf215546Sopenharmony_cistatic const int
589bf215546Sopenharmony_ciextra_ARB_color_buffer_float_or_glcore[] = {
590bf215546Sopenharmony_ci   EXT(ARB_color_buffer_float),
591bf215546Sopenharmony_ci   EXTRA_API_GL_CORE,
592bf215546Sopenharmony_ci   EXTRA_END
593bf215546Sopenharmony_ci};
594bf215546Sopenharmony_ci
595bf215546Sopenharmony_cistatic const int
596bf215546Sopenharmony_ciextra_NV_primitive_restart[] = {
597bf215546Sopenharmony_ci   EXT(NV_primitive_restart),
598bf215546Sopenharmony_ci   EXTRA_END
599bf215546Sopenharmony_ci};
600bf215546Sopenharmony_ci
601bf215546Sopenharmony_cistatic const int extra_version_30[] = { EXTRA_VERSION_30, EXTRA_END };
602bf215546Sopenharmony_cistatic const int extra_version_31[] = { EXTRA_VERSION_31, EXTRA_END };
603bf215546Sopenharmony_cistatic const int extra_version_32[] = { EXTRA_VERSION_32, EXTRA_END };
604bf215546Sopenharmony_cistatic const int extra_version_43[] = { EXTRA_VERSION_43, EXTRA_END };
605bf215546Sopenharmony_ci
606bf215546Sopenharmony_cistatic const int extra_gl30_es3[] = {
607bf215546Sopenharmony_ci    EXTRA_VERSION_30,
608bf215546Sopenharmony_ci    EXTRA_API_ES3,
609bf215546Sopenharmony_ci    EXTRA_END,
610bf215546Sopenharmony_ci};
611bf215546Sopenharmony_ci
612bf215546Sopenharmony_cistatic const int extra_gl32_es3[] = {
613bf215546Sopenharmony_ci    EXTRA_VERSION_32,
614bf215546Sopenharmony_ci    EXTRA_API_ES3,
615bf215546Sopenharmony_ci    EXTRA_END,
616bf215546Sopenharmony_ci};
617bf215546Sopenharmony_ci
618bf215546Sopenharmony_cistatic const int extra_version_32_OES_geometry_shader[] = {
619bf215546Sopenharmony_ci    EXTRA_VERSION_32,
620bf215546Sopenharmony_ci    EXTRA_EXT_ES_GS,
621bf215546Sopenharmony_ci    EXTRA_END
622bf215546Sopenharmony_ci};
623bf215546Sopenharmony_ci
624bf215546Sopenharmony_cistatic const int extra_gl40_ARB_sample_shading[] = {
625bf215546Sopenharmony_ci   EXTRA_VERSION_40,
626bf215546Sopenharmony_ci   EXT(ARB_sample_shading),
627bf215546Sopenharmony_ci   EXTRA_END
628bf215546Sopenharmony_ci};
629bf215546Sopenharmony_ci
630bf215546Sopenharmony_cistatic const int
631bf215546Sopenharmony_ciextra_ARB_vertex_program_api_es2[] = {
632bf215546Sopenharmony_ci   EXT(ARB_vertex_program),
633bf215546Sopenharmony_ci   EXTRA_API_ES2,
634bf215546Sopenharmony_ci   EXTRA_END
635bf215546Sopenharmony_ci};
636bf215546Sopenharmony_ci
637bf215546Sopenharmony_ci/* The ReadBuffer get token is valid under either full GL or under
638bf215546Sopenharmony_ci * GLES2 if the NV_read_buffer extension is available. */
639bf215546Sopenharmony_cistatic const int
640bf215546Sopenharmony_ciextra_NV_read_buffer_api_gl[] = {
641bf215546Sopenharmony_ci   EXTRA_API_ES2,
642bf215546Sopenharmony_ci   EXTRA_API_GL,
643bf215546Sopenharmony_ci   EXTRA_END
644bf215546Sopenharmony_ci};
645bf215546Sopenharmony_ci
646bf215546Sopenharmony_cistatic const int extra_core_ARB_color_buffer_float_and_new_buffers[] = {
647bf215546Sopenharmony_ci   EXTRA_API_GL_CORE,
648bf215546Sopenharmony_ci   EXT(ARB_color_buffer_float),
649bf215546Sopenharmony_ci   EXTRA_NEW_BUFFERS,
650bf215546Sopenharmony_ci   EXTRA_END
651bf215546Sopenharmony_ci};
652bf215546Sopenharmony_ci
653bf215546Sopenharmony_cistatic const int extra_EXT_shader_framebuffer_fetch[] = {
654bf215546Sopenharmony_ci   EXTRA_API_ES2,
655bf215546Sopenharmony_ci   EXTRA_API_ES3,
656bf215546Sopenharmony_ci   EXT(EXT_shader_framebuffer_fetch),
657bf215546Sopenharmony_ci   EXTRA_END
658bf215546Sopenharmony_ci};
659bf215546Sopenharmony_ci
660bf215546Sopenharmony_cistatic const int extra_EXT_provoking_vertex_32[] = {
661bf215546Sopenharmony_ci   EXTRA_EXT_PROVOKING_VERTEX_32,
662bf215546Sopenharmony_ci   EXTRA_END
663bf215546Sopenharmony_ci};
664bf215546Sopenharmony_ci
665bf215546Sopenharmony_cistatic const int extra_EXT_disjoint_timer_query[] = {
666bf215546Sopenharmony_ci   EXTRA_API_ES2,
667bf215546Sopenharmony_ci   EXTRA_API_ES3,
668bf215546Sopenharmony_ci   EXT(EXT_disjoint_timer_query),
669bf215546Sopenharmony_ci   EXTRA_END
670bf215546Sopenharmony_ci};
671bf215546Sopenharmony_ci
672bf215546Sopenharmony_ci
673bf215546Sopenharmony_ci/* This is the big table describing all the enums we accept in
674bf215546Sopenharmony_ci * glGet*v().  The table is partitioned into six parts: enums
675bf215546Sopenharmony_ci * understood by all GL APIs (OpenGL, GLES and GLES2), enums shared
676bf215546Sopenharmony_ci * between OpenGL and GLES, enums exclusive to GLES, etc for the
677bf215546Sopenharmony_ci * remaining combinations. To look up the enums valid in a given API
678bf215546Sopenharmony_ci * we will use a hash table specific to that API. These tables are in
679bf215546Sopenharmony_ci * turn generated at build time and included through get_hash.h.
680bf215546Sopenharmony_ci */
681bf215546Sopenharmony_ci
682bf215546Sopenharmony_ci#include "get_hash.h"
683bf215546Sopenharmony_ci
684bf215546Sopenharmony_ci/* All we need now is a way to look up the value struct from the enum.
685bf215546Sopenharmony_ci * The code generated by gcc for the old generated big switch
686bf215546Sopenharmony_ci * statement is a big, balanced, open coded if/else tree, essentially
687bf215546Sopenharmony_ci * an unrolled binary search.  It would be natural to sort the new
688bf215546Sopenharmony_ci * enum table and use bsearch(), but we will use a read-only hash
689bf215546Sopenharmony_ci * table instead.  bsearch() has a nice guaranteed worst case
690bf215546Sopenharmony_ci * performance, but we're also guaranteed to hit that worst case
691bf215546Sopenharmony_ci * (log2(n) iterations) for about half the enums.  Instead, using an
692bf215546Sopenharmony_ci * open addressing hash table, we can find the enum on the first try
693bf215546Sopenharmony_ci * for 80% of the enums, 1 collision for 10% and never more than 5
694bf215546Sopenharmony_ci * collisions for any enum (typical numbers).  And the code is very
695bf215546Sopenharmony_ci * simple, even though it feels a little magic. */
696bf215546Sopenharmony_ci
697bf215546Sopenharmony_ci/**
698bf215546Sopenharmony_ci * Handle irregular enums
699bf215546Sopenharmony_ci *
700bf215546Sopenharmony_ci * Some values don't conform to the "well-known type at context
701bf215546Sopenharmony_ci * pointer + offset" pattern, so we have this function to catch all
702bf215546Sopenharmony_ci * the corner cases.  Typically, it's a computed value or a one-off
703bf215546Sopenharmony_ci * pointer to a custom struct or something.
704bf215546Sopenharmony_ci *
705bf215546Sopenharmony_ci * In this case we can't return a pointer to the value, so we'll have
706bf215546Sopenharmony_ci * to use the temporary variable 'v' declared back in the calling
707bf215546Sopenharmony_ci * glGet*v() function to store the result.
708bf215546Sopenharmony_ci *
709bf215546Sopenharmony_ci * \param ctx the current context
710bf215546Sopenharmony_ci * \param d the struct value_desc that describes the enum
711bf215546Sopenharmony_ci * \param v pointer to the tmp declared in the calling glGet*v() function
712bf215546Sopenharmony_ci */
713bf215546Sopenharmony_cistatic void
714bf215546Sopenharmony_cifind_custom_value(struct gl_context *ctx, const struct value_desc *d, union value *v)
715bf215546Sopenharmony_ci{
716bf215546Sopenharmony_ci   struct gl_buffer_object **buffer_obj, *buf;
717bf215546Sopenharmony_ci   struct gl_array_attributes *array;
718bf215546Sopenharmony_ci   GLuint unit, *p;
719bf215546Sopenharmony_ci
720bf215546Sopenharmony_ci   switch (d->pname) {
721bf215546Sopenharmony_ci   case GL_MAJOR_VERSION:
722bf215546Sopenharmony_ci      v->value_int = ctx->Version / 10;
723bf215546Sopenharmony_ci      break;
724bf215546Sopenharmony_ci   case GL_MINOR_VERSION:
725bf215546Sopenharmony_ci      v->value_int = ctx->Version % 10;
726bf215546Sopenharmony_ci      break;
727bf215546Sopenharmony_ci
728bf215546Sopenharmony_ci   case GL_TEXTURE_1D:
729bf215546Sopenharmony_ci   case GL_TEXTURE_2D:
730bf215546Sopenharmony_ci   case GL_TEXTURE_3D:
731bf215546Sopenharmony_ci   case GL_TEXTURE_CUBE_MAP:
732bf215546Sopenharmony_ci   case GL_TEXTURE_RECTANGLE_NV:
733bf215546Sopenharmony_ci   case GL_TEXTURE_EXTERNAL_OES:
734bf215546Sopenharmony_ci      v->value_bool = _mesa_IsEnabled(d->pname);
735bf215546Sopenharmony_ci      break;
736bf215546Sopenharmony_ci
737bf215546Sopenharmony_ci   case GL_LINE_STIPPLE_PATTERN:
738bf215546Sopenharmony_ci      /* This is the only GLushort, special case it here by promoting
739bf215546Sopenharmony_ci       * to an int rather than introducing a new type. */
740bf215546Sopenharmony_ci      v->value_int = ctx->Line.StipplePattern;
741bf215546Sopenharmony_ci      break;
742bf215546Sopenharmony_ci
743bf215546Sopenharmony_ci   case GL_CURRENT_RASTER_TEXTURE_COORDS:
744bf215546Sopenharmony_ci      unit = ctx->Texture.CurrentUnit;
745bf215546Sopenharmony_ci      v->value_float_4[0] = ctx->Current.RasterTexCoords[unit][0];
746bf215546Sopenharmony_ci      v->value_float_4[1] = ctx->Current.RasterTexCoords[unit][1];
747bf215546Sopenharmony_ci      v->value_float_4[2] = ctx->Current.RasterTexCoords[unit][2];
748bf215546Sopenharmony_ci      v->value_float_4[3] = ctx->Current.RasterTexCoords[unit][3];
749bf215546Sopenharmony_ci      break;
750bf215546Sopenharmony_ci
751bf215546Sopenharmony_ci   case GL_CURRENT_TEXTURE_COORDS:
752bf215546Sopenharmony_ci      unit = ctx->Texture.CurrentUnit;
753bf215546Sopenharmony_ci      v->value_float_4[0] = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][0];
754bf215546Sopenharmony_ci      v->value_float_4[1] = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][1];
755bf215546Sopenharmony_ci      v->value_float_4[2] = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][2];
756bf215546Sopenharmony_ci      v->value_float_4[3] = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][3];
757bf215546Sopenharmony_ci      break;
758bf215546Sopenharmony_ci
759bf215546Sopenharmony_ci   case GL_COLOR_WRITEMASK:
760bf215546Sopenharmony_ci      v->value_int_4[0] = GET_COLORMASK_BIT(ctx->Color.ColorMask, 0, 0);
761bf215546Sopenharmony_ci      v->value_int_4[1] = GET_COLORMASK_BIT(ctx->Color.ColorMask, 0, 1);
762bf215546Sopenharmony_ci      v->value_int_4[2] = GET_COLORMASK_BIT(ctx->Color.ColorMask, 0, 2);
763bf215546Sopenharmony_ci      v->value_int_4[3] = GET_COLORMASK_BIT(ctx->Color.ColorMask, 0, 3);
764bf215546Sopenharmony_ci      break;
765bf215546Sopenharmony_ci
766bf215546Sopenharmony_ci   case GL_DEPTH_CLAMP:
767bf215546Sopenharmony_ci      v->value_bool = ctx->Transform.DepthClampNear || ctx->Transform.DepthClampFar;
768bf215546Sopenharmony_ci      break;
769bf215546Sopenharmony_ci
770bf215546Sopenharmony_ci   case GL_EDGE_FLAG:
771bf215546Sopenharmony_ci      v->value_bool = ctx->Current.Attrib[VERT_ATTRIB_EDGEFLAG][0] == 1.0F;
772bf215546Sopenharmony_ci      break;
773bf215546Sopenharmony_ci
774bf215546Sopenharmony_ci   case GL_READ_BUFFER:
775bf215546Sopenharmony_ci      v->value_enum16 = ctx->ReadBuffer->ColorReadBuffer;
776bf215546Sopenharmony_ci      break;
777bf215546Sopenharmony_ci
778bf215546Sopenharmony_ci   case GL_MAP2_GRID_DOMAIN:
779bf215546Sopenharmony_ci      v->value_float_4[0] = ctx->Eval.MapGrid2u1;
780bf215546Sopenharmony_ci      v->value_float_4[1] = ctx->Eval.MapGrid2u2;
781bf215546Sopenharmony_ci      v->value_float_4[2] = ctx->Eval.MapGrid2v1;
782bf215546Sopenharmony_ci      v->value_float_4[3] = ctx->Eval.MapGrid2v2;
783bf215546Sopenharmony_ci      break;
784bf215546Sopenharmony_ci
785bf215546Sopenharmony_ci   case GL_TEXTURE_STACK_DEPTH:
786bf215546Sopenharmony_ci      unit = ctx->Texture.CurrentUnit;
787bf215546Sopenharmony_ci      v->value_int = ctx->TextureMatrixStack[unit].Depth + 1;
788bf215546Sopenharmony_ci      break;
789bf215546Sopenharmony_ci   case GL_TEXTURE_MATRIX:
790bf215546Sopenharmony_ci      unit = ctx->Texture.CurrentUnit;
791bf215546Sopenharmony_ci      v->value_matrix = ctx->TextureMatrixStack[unit].Top;
792bf215546Sopenharmony_ci      break;
793bf215546Sopenharmony_ci
794bf215546Sopenharmony_ci   case GL_VERTEX_ARRAY:
795bf215546Sopenharmony_ci      v->value_bool = !!(ctx->Array.VAO->Enabled & VERT_BIT_POS);
796bf215546Sopenharmony_ci      break;
797bf215546Sopenharmony_ci   case GL_NORMAL_ARRAY:
798bf215546Sopenharmony_ci      v->value_bool = !!(ctx->Array.VAO->Enabled & VERT_BIT_NORMAL);
799bf215546Sopenharmony_ci      break;
800bf215546Sopenharmony_ci   case GL_COLOR_ARRAY:
801bf215546Sopenharmony_ci      v->value_bool = !!(ctx->Array.VAO->Enabled & VERT_BIT_COLOR0);
802bf215546Sopenharmony_ci      break;
803bf215546Sopenharmony_ci   case GL_TEXTURE_COORD_ARRAY:
804bf215546Sopenharmony_ci      v->value_bool = !!(ctx->Array.VAO->Enabled & VERT_BIT_TEX(ctx->Array.ActiveTexture));
805bf215546Sopenharmony_ci      break;
806bf215546Sopenharmony_ci   case GL_INDEX_ARRAY:
807bf215546Sopenharmony_ci      v->value_bool = !!(ctx->Array.VAO->Enabled & VERT_BIT_COLOR_INDEX);
808bf215546Sopenharmony_ci      break;
809bf215546Sopenharmony_ci   case GL_EDGE_FLAG_ARRAY:
810bf215546Sopenharmony_ci      v->value_bool = !!(ctx->Array.VAO->Enabled & VERT_BIT_EDGEFLAG);
811bf215546Sopenharmony_ci      break;
812bf215546Sopenharmony_ci   case GL_SECONDARY_COLOR_ARRAY:
813bf215546Sopenharmony_ci      v->value_bool = !!(ctx->Array.VAO->Enabled & VERT_BIT_COLOR1);
814bf215546Sopenharmony_ci      break;
815bf215546Sopenharmony_ci   case GL_FOG_COORDINATE_ARRAY:
816bf215546Sopenharmony_ci      v->value_bool = !!(ctx->Array.VAO->Enabled & VERT_BIT_FOG);
817bf215546Sopenharmony_ci      break;
818bf215546Sopenharmony_ci   case GL_POINT_SIZE_ARRAY_OES:
819bf215546Sopenharmony_ci      v->value_bool = !!(ctx->Array.VAO->Enabled & VERT_BIT_POINT_SIZE);
820bf215546Sopenharmony_ci      break;
821bf215546Sopenharmony_ci
822bf215546Sopenharmony_ci   case GL_TEXTURE_COORD_ARRAY_TYPE:
823bf215546Sopenharmony_ci   case GL_TEXTURE_COORD_ARRAY_STRIDE:
824bf215546Sopenharmony_ci      array = &ctx->Array.VAO->VertexAttrib[VERT_ATTRIB_TEX(ctx->Array.ActiveTexture)];
825bf215546Sopenharmony_ci      v->value_int = *(GLuint *) ((char *) array + d->offset);
826bf215546Sopenharmony_ci      break;
827bf215546Sopenharmony_ci
828bf215546Sopenharmony_ci   case GL_TEXTURE_COORD_ARRAY_SIZE:
829bf215546Sopenharmony_ci      array = &ctx->Array.VAO->VertexAttrib[VERT_ATTRIB_TEX(ctx->Array.ActiveTexture)];
830bf215546Sopenharmony_ci      v->value_int = array->Format.Size;
831bf215546Sopenharmony_ci      break;
832bf215546Sopenharmony_ci
833bf215546Sopenharmony_ci   case GL_VERTEX_ARRAY_SIZE:
834bf215546Sopenharmony_ci      array = &ctx->Array.VAO->VertexAttrib[VERT_ATTRIB_POS];
835bf215546Sopenharmony_ci      v->value_int = array->Format.Size;
836bf215546Sopenharmony_ci      break;
837bf215546Sopenharmony_ci
838bf215546Sopenharmony_ci   case GL_ACTIVE_TEXTURE_ARB:
839bf215546Sopenharmony_ci      v->value_int = GL_TEXTURE0_ARB + ctx->Texture.CurrentUnit;
840bf215546Sopenharmony_ci      break;
841bf215546Sopenharmony_ci   case GL_CLIENT_ACTIVE_TEXTURE_ARB:
842bf215546Sopenharmony_ci      v->value_int = GL_TEXTURE0_ARB + ctx->Array.ActiveTexture;
843bf215546Sopenharmony_ci      break;
844bf215546Sopenharmony_ci
845bf215546Sopenharmony_ci   case GL_MODELVIEW_STACK_DEPTH:
846bf215546Sopenharmony_ci   case GL_PROJECTION_STACK_DEPTH:
847bf215546Sopenharmony_ci      v->value_int = *(GLint *) ((char *) ctx + d->offset) + 1;
848bf215546Sopenharmony_ci      break;
849bf215546Sopenharmony_ci
850bf215546Sopenharmony_ci   case GL_MAX_TEXTURE_SIZE:
851bf215546Sopenharmony_ci   case GL_MAX_3D_TEXTURE_SIZE:
852bf215546Sopenharmony_ci   case GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB:
853bf215546Sopenharmony_ci      p = (GLuint *) ((char *) ctx + d->offset);
854bf215546Sopenharmony_ci      v->value_int = 1 << (*p - 1);
855bf215546Sopenharmony_ci      break;
856bf215546Sopenharmony_ci
857bf215546Sopenharmony_ci   case GL_SCISSOR_BOX:
858bf215546Sopenharmony_ci      v->value_int_4[0] = ctx->Scissor.ScissorArray[0].X;
859bf215546Sopenharmony_ci      v->value_int_4[1] = ctx->Scissor.ScissorArray[0].Y;
860bf215546Sopenharmony_ci      v->value_int_4[2] = ctx->Scissor.ScissorArray[0].Width;
861bf215546Sopenharmony_ci      v->value_int_4[3] = ctx->Scissor.ScissorArray[0].Height;
862bf215546Sopenharmony_ci      break;
863bf215546Sopenharmony_ci
864bf215546Sopenharmony_ci   case GL_SCISSOR_TEST:
865bf215546Sopenharmony_ci      v->value_bool = ctx->Scissor.EnableFlags & 1;
866bf215546Sopenharmony_ci      break;
867bf215546Sopenharmony_ci
868bf215546Sopenharmony_ci   case GL_LIST_INDEX:
869bf215546Sopenharmony_ci      v->value_int =
870bf215546Sopenharmony_ci         ctx->ListState.CurrentList ? ctx->ListState.CurrentList->Name : 0;
871bf215546Sopenharmony_ci      break;
872bf215546Sopenharmony_ci   case GL_LIST_MODE:
873bf215546Sopenharmony_ci      if (!ctx->CompileFlag)
874bf215546Sopenharmony_ci         v->value_enum16 = 0;
875bf215546Sopenharmony_ci      else if (ctx->ExecuteFlag)
876bf215546Sopenharmony_ci         v->value_enum16 = GL_COMPILE_AND_EXECUTE;
877bf215546Sopenharmony_ci      else
878bf215546Sopenharmony_ci         v->value_enum16 = GL_COMPILE;
879bf215546Sopenharmony_ci      break;
880bf215546Sopenharmony_ci
881bf215546Sopenharmony_ci   case GL_VIEWPORT:
882bf215546Sopenharmony_ci      v->value_float_4[0] = ctx->ViewportArray[0].X;
883bf215546Sopenharmony_ci      v->value_float_4[1] = ctx->ViewportArray[0].Y;
884bf215546Sopenharmony_ci      v->value_float_4[2] = ctx->ViewportArray[0].Width;
885bf215546Sopenharmony_ci      v->value_float_4[3] = ctx->ViewportArray[0].Height;
886bf215546Sopenharmony_ci      break;
887bf215546Sopenharmony_ci
888bf215546Sopenharmony_ci   case GL_DEPTH_RANGE:
889bf215546Sopenharmony_ci      v->value_double_2[0] = ctx->ViewportArray[0].Near;
890bf215546Sopenharmony_ci      v->value_double_2[1] = ctx->ViewportArray[0].Far;
891bf215546Sopenharmony_ci      break;
892bf215546Sopenharmony_ci
893bf215546Sopenharmony_ci   case GL_ACTIVE_STENCIL_FACE_EXT:
894bf215546Sopenharmony_ci      v->value_enum16 = ctx->Stencil.ActiveFace ? GL_BACK : GL_FRONT;
895bf215546Sopenharmony_ci      break;
896bf215546Sopenharmony_ci
897bf215546Sopenharmony_ci   case GL_STENCIL_FAIL:
898bf215546Sopenharmony_ci      v->value_enum16 = ctx->Stencil.FailFunc[ctx->Stencil.ActiveFace];
899bf215546Sopenharmony_ci      break;
900bf215546Sopenharmony_ci   case GL_STENCIL_FUNC:
901bf215546Sopenharmony_ci      v->value_enum16 = ctx->Stencil.Function[ctx->Stencil.ActiveFace];
902bf215546Sopenharmony_ci      break;
903bf215546Sopenharmony_ci   case GL_STENCIL_PASS_DEPTH_FAIL:
904bf215546Sopenharmony_ci      v->value_enum16 = ctx->Stencil.ZFailFunc[ctx->Stencil.ActiveFace];
905bf215546Sopenharmony_ci      break;
906bf215546Sopenharmony_ci   case GL_STENCIL_PASS_DEPTH_PASS:
907bf215546Sopenharmony_ci      v->value_enum16 = ctx->Stencil.ZPassFunc[ctx->Stencil.ActiveFace];
908bf215546Sopenharmony_ci      break;
909bf215546Sopenharmony_ci   case GL_STENCIL_REF:
910bf215546Sopenharmony_ci      v->value_int = _mesa_get_stencil_ref(ctx, ctx->Stencil.ActiveFace);
911bf215546Sopenharmony_ci      break;
912bf215546Sopenharmony_ci   case GL_STENCIL_BACK_REF:
913bf215546Sopenharmony_ci      v->value_int = _mesa_get_stencil_ref(ctx, 1);
914bf215546Sopenharmony_ci      break;
915bf215546Sopenharmony_ci   case GL_STENCIL_VALUE_MASK:
916bf215546Sopenharmony_ci      v->value_int = ctx->Stencil.ValueMask[ctx->Stencil.ActiveFace];
917bf215546Sopenharmony_ci      break;
918bf215546Sopenharmony_ci   case GL_STENCIL_WRITEMASK:
919bf215546Sopenharmony_ci      v->value_int = ctx->Stencil.WriteMask[ctx->Stencil.ActiveFace];
920bf215546Sopenharmony_ci      break;
921bf215546Sopenharmony_ci
922bf215546Sopenharmony_ci   case GL_NUM_EXTENSIONS:
923bf215546Sopenharmony_ci      v->value_int = _mesa_get_extension_count(ctx);
924bf215546Sopenharmony_ci      break;
925bf215546Sopenharmony_ci
926bf215546Sopenharmony_ci   case GL_IMPLEMENTATION_COLOR_READ_TYPE_OES:
927bf215546Sopenharmony_ci      v->value_int = _mesa_get_color_read_type(ctx, NULL, "glGetIntegerv");
928bf215546Sopenharmony_ci      break;
929bf215546Sopenharmony_ci   case GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES:
930bf215546Sopenharmony_ci      v->value_int = _mesa_get_color_read_format(ctx, NULL, "glGetIntegerv");
931bf215546Sopenharmony_ci      break;
932bf215546Sopenharmony_ci
933bf215546Sopenharmony_ci   case GL_CURRENT_MATRIX_STACK_DEPTH_ARB:
934bf215546Sopenharmony_ci      v->value_int = ctx->CurrentStack->Depth + 1;
935bf215546Sopenharmony_ci      break;
936bf215546Sopenharmony_ci   case GL_CURRENT_MATRIX_ARB:
937bf215546Sopenharmony_ci   case GL_TRANSPOSE_CURRENT_MATRIX_ARB:
938bf215546Sopenharmony_ci      v->value_matrix = ctx->CurrentStack->Top;
939bf215546Sopenharmony_ci      break;
940bf215546Sopenharmony_ci
941bf215546Sopenharmony_ci   case GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB:
942bf215546Sopenharmony_ci      v->value_int = _mesa_get_compressed_formats(ctx, NULL);
943bf215546Sopenharmony_ci      break;
944bf215546Sopenharmony_ci   case GL_COMPRESSED_TEXTURE_FORMATS_ARB:
945bf215546Sopenharmony_ci      v->value_int_n.n =
946bf215546Sopenharmony_ci         _mesa_get_compressed_formats(ctx, v->value_int_n.ints);
947bf215546Sopenharmony_ci      assert(v->value_int_n.n <= (int) ARRAY_SIZE(v->value_int_n.ints));
948bf215546Sopenharmony_ci      break;
949bf215546Sopenharmony_ci
950bf215546Sopenharmony_ci   case GL_MAX_VARYING_FLOATS_ARB:
951bf215546Sopenharmony_ci      v->value_int = ctx->Const.MaxVarying * 4;
952bf215546Sopenharmony_ci      break;
953bf215546Sopenharmony_ci
954bf215546Sopenharmony_ci   /* Various object names */
955bf215546Sopenharmony_ci
956bf215546Sopenharmony_ci   case GL_TEXTURE_BINDING_1D:
957bf215546Sopenharmony_ci   case GL_TEXTURE_BINDING_2D:
958bf215546Sopenharmony_ci   case GL_TEXTURE_BINDING_3D:
959bf215546Sopenharmony_ci   case GL_TEXTURE_BINDING_1D_ARRAY_EXT:
960bf215546Sopenharmony_ci   case GL_TEXTURE_BINDING_2D_ARRAY_EXT:
961bf215546Sopenharmony_ci   case GL_TEXTURE_BINDING_CUBE_MAP_ARB:
962bf215546Sopenharmony_ci   case GL_TEXTURE_BINDING_RECTANGLE_NV:
963bf215546Sopenharmony_ci   case GL_TEXTURE_BINDING_EXTERNAL_OES:
964bf215546Sopenharmony_ci   case GL_TEXTURE_BINDING_CUBE_MAP_ARRAY:
965bf215546Sopenharmony_ci   case GL_TEXTURE_BINDING_2D_MULTISAMPLE:
966bf215546Sopenharmony_ci   case GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY:
967bf215546Sopenharmony_ci      unit = ctx->Texture.CurrentUnit;
968bf215546Sopenharmony_ci      v->value_int =
969bf215546Sopenharmony_ci         ctx->Texture.Unit[unit].CurrentTex[d->offset]->Name;
970bf215546Sopenharmony_ci      break;
971bf215546Sopenharmony_ci
972bf215546Sopenharmony_ci   /* GL_EXT_external_objects */
973bf215546Sopenharmony_ci   case GL_NUM_DEVICE_UUIDS_EXT:
974bf215546Sopenharmony_ci      v->value_int = 1;
975bf215546Sopenharmony_ci      break;
976bf215546Sopenharmony_ci   case GL_DRIVER_UUID_EXT:
977bf215546Sopenharmony_ci      _mesa_get_driver_uuid(ctx, v->value_int_4);
978bf215546Sopenharmony_ci      break;
979bf215546Sopenharmony_ci   case GL_DEVICE_UUID_EXT:
980bf215546Sopenharmony_ci      _mesa_get_device_uuid(ctx, v->value_int_4);
981bf215546Sopenharmony_ci      break;
982bf215546Sopenharmony_ci
983bf215546Sopenharmony_ci   /* GL_EXT_memory_object_win32 */
984bf215546Sopenharmony_ci   case GL_DEVICE_LUID_EXT:
985bf215546Sopenharmony_ci      _mesa_get_device_luid(ctx, v->value_int_2);
986bf215546Sopenharmony_ci      break;
987bf215546Sopenharmony_ci   case GL_DEVICE_NODE_MASK_EXT:
988bf215546Sopenharmony_ci      v->value_int = ctx->pipe->screen->get_device_node_mask(ctx->pipe->screen);
989bf215546Sopenharmony_ci      break;
990bf215546Sopenharmony_ci
991bf215546Sopenharmony_ci   /* GL_EXT_packed_float */
992bf215546Sopenharmony_ci   case GL_RGBA_SIGNED_COMPONENTS_EXT:
993bf215546Sopenharmony_ci      {
994bf215546Sopenharmony_ci         /* Note: we only check the 0th color attachment. */
995bf215546Sopenharmony_ci         const struct gl_renderbuffer *rb =
996bf215546Sopenharmony_ci            ctx->DrawBuffer->_ColorDrawBuffers[0];
997bf215546Sopenharmony_ci         if (rb && _mesa_is_format_signed(rb->Format)) {
998bf215546Sopenharmony_ci            /* Issue 17 of GL_EXT_packed_float:  If a component (such as
999bf215546Sopenharmony_ci             * alpha) has zero bits, the component should not be considered
1000bf215546Sopenharmony_ci             * signed and so the bit for the respective component should be
1001bf215546Sopenharmony_ci             * zeroed.
1002bf215546Sopenharmony_ci             */
1003bf215546Sopenharmony_ci            GLint r_bits =
1004bf215546Sopenharmony_ci               _mesa_get_format_bits(rb->Format, GL_RED_BITS);
1005bf215546Sopenharmony_ci            GLint g_bits =
1006bf215546Sopenharmony_ci               _mesa_get_format_bits(rb->Format, GL_GREEN_BITS);
1007bf215546Sopenharmony_ci            GLint b_bits =
1008bf215546Sopenharmony_ci               _mesa_get_format_bits(rb->Format, GL_BLUE_BITS);
1009bf215546Sopenharmony_ci            GLint a_bits =
1010bf215546Sopenharmony_ci               _mesa_get_format_bits(rb->Format, GL_ALPHA_BITS);
1011bf215546Sopenharmony_ci            GLint l_bits =
1012bf215546Sopenharmony_ci               _mesa_get_format_bits(rb->Format, GL_TEXTURE_LUMINANCE_SIZE);
1013bf215546Sopenharmony_ci            GLint i_bits =
1014bf215546Sopenharmony_ci               _mesa_get_format_bits(rb->Format, GL_TEXTURE_INTENSITY_SIZE);
1015bf215546Sopenharmony_ci
1016bf215546Sopenharmony_ci            v->value_int_4[0] = r_bits + l_bits + i_bits > 0;
1017bf215546Sopenharmony_ci            v->value_int_4[1] = g_bits + l_bits + i_bits > 0;
1018bf215546Sopenharmony_ci            v->value_int_4[2] = b_bits + l_bits + i_bits > 0;
1019bf215546Sopenharmony_ci            v->value_int_4[3] = a_bits + i_bits > 0;
1020bf215546Sopenharmony_ci         }
1021bf215546Sopenharmony_ci         else {
1022bf215546Sopenharmony_ci            v->value_int_4[0] =
1023bf215546Sopenharmony_ci            v->value_int_4[1] =
1024bf215546Sopenharmony_ci            v->value_int_4[2] =
1025bf215546Sopenharmony_ci            v->value_int_4[3] = 0;
1026bf215546Sopenharmony_ci         }
1027bf215546Sopenharmony_ci      }
1028bf215546Sopenharmony_ci      break;
1029bf215546Sopenharmony_ci
1030bf215546Sopenharmony_ci   /* GL_ARB_vertex_buffer_object */
1031bf215546Sopenharmony_ci   case GL_VERTEX_ARRAY_BUFFER_BINDING_ARB:
1032bf215546Sopenharmony_ci   case GL_NORMAL_ARRAY_BUFFER_BINDING_ARB:
1033bf215546Sopenharmony_ci   case GL_COLOR_ARRAY_BUFFER_BINDING_ARB:
1034bf215546Sopenharmony_ci   case GL_INDEX_ARRAY_BUFFER_BINDING_ARB:
1035bf215546Sopenharmony_ci   case GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB:
1036bf215546Sopenharmony_ci   case GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB:
1037bf215546Sopenharmony_ci   case GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB:
1038bf215546Sopenharmony_ci      buffer_obj = (struct gl_buffer_object **)
1039bf215546Sopenharmony_ci         ((char *) ctx->Array.VAO + d->offset);
1040bf215546Sopenharmony_ci      v->value_int = (*buffer_obj) ? (*buffer_obj)->Name : 0;
1041bf215546Sopenharmony_ci      break;
1042bf215546Sopenharmony_ci   case GL_ARRAY_BUFFER_BINDING_ARB:
1043bf215546Sopenharmony_ci      buf = ctx->Array.ArrayBufferObj;
1044bf215546Sopenharmony_ci      v->value_int = buf ? buf->Name : 0;
1045bf215546Sopenharmony_ci      break;
1046bf215546Sopenharmony_ci   case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB:
1047bf215546Sopenharmony_ci      buf = ctx->Array.VAO->BufferBinding[VERT_ATTRIB_TEX(ctx->Array.ActiveTexture)].BufferObj;
1048bf215546Sopenharmony_ci      v->value_int = buf ? buf->Name : 0;
1049bf215546Sopenharmony_ci      break;
1050bf215546Sopenharmony_ci   case GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB:
1051bf215546Sopenharmony_ci      buf = ctx->Array.VAO->IndexBufferObj;
1052bf215546Sopenharmony_ci      v->value_int = buf ? buf->Name : 0;
1053bf215546Sopenharmony_ci      break;
1054bf215546Sopenharmony_ci
1055bf215546Sopenharmony_ci   /* ARB_vertex_array_bgra */
1056bf215546Sopenharmony_ci   case GL_COLOR_ARRAY_SIZE:
1057bf215546Sopenharmony_ci      array = &ctx->Array.VAO->VertexAttrib[VERT_ATTRIB_COLOR0];
1058bf215546Sopenharmony_ci      v->value_int = array->Format.Format == GL_BGRA ? GL_BGRA : array->Format.Size;
1059bf215546Sopenharmony_ci      break;
1060bf215546Sopenharmony_ci   case GL_SECONDARY_COLOR_ARRAY_SIZE:
1061bf215546Sopenharmony_ci      array = &ctx->Array.VAO->VertexAttrib[VERT_ATTRIB_COLOR1];
1062bf215546Sopenharmony_ci      v->value_int = array->Format.Format == GL_BGRA ? GL_BGRA : array->Format.Size;
1063bf215546Sopenharmony_ci      break;
1064bf215546Sopenharmony_ci
1065bf215546Sopenharmony_ci   /* ARB_copy_buffer */
1066bf215546Sopenharmony_ci   case GL_COPY_READ_BUFFER:
1067bf215546Sopenharmony_ci      v->value_int = ctx->CopyReadBuffer ? ctx->CopyReadBuffer->Name : 0;
1068bf215546Sopenharmony_ci      break;
1069bf215546Sopenharmony_ci   case GL_COPY_WRITE_BUFFER:
1070bf215546Sopenharmony_ci      v->value_int = ctx->CopyWriteBuffer ? ctx->CopyWriteBuffer->Name : 0;
1071bf215546Sopenharmony_ci      break;
1072bf215546Sopenharmony_ci
1073bf215546Sopenharmony_ci   case GL_PIXEL_PACK_BUFFER_BINDING_EXT:
1074bf215546Sopenharmony_ci      v->value_int = ctx->Pack.BufferObj ? ctx->Pack.BufferObj->Name : 0;
1075bf215546Sopenharmony_ci      break;
1076bf215546Sopenharmony_ci   case GL_PIXEL_UNPACK_BUFFER_BINDING_EXT:
1077bf215546Sopenharmony_ci      v->value_int = ctx->Unpack.BufferObj ? ctx->Unpack.BufferObj->Name : 0;
1078bf215546Sopenharmony_ci      break;
1079bf215546Sopenharmony_ci   case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING:
1080bf215546Sopenharmony_ci      v->value_int = ctx->TransformFeedback.CurrentBuffer ?
1081bf215546Sopenharmony_ci                        ctx->TransformFeedback.CurrentBuffer->Name : 0;
1082bf215546Sopenharmony_ci      break;
1083bf215546Sopenharmony_ci   case GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED:
1084bf215546Sopenharmony_ci      v->value_int = ctx->TransformFeedback.CurrentObject->Paused;
1085bf215546Sopenharmony_ci      break;
1086bf215546Sopenharmony_ci   case GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE:
1087bf215546Sopenharmony_ci      v->value_int = ctx->TransformFeedback.CurrentObject->Active;
1088bf215546Sopenharmony_ci      break;
1089bf215546Sopenharmony_ci   case GL_TRANSFORM_FEEDBACK_BINDING:
1090bf215546Sopenharmony_ci      v->value_int = ctx->TransformFeedback.CurrentObject->Name;
1091bf215546Sopenharmony_ci      break;
1092bf215546Sopenharmony_ci   case GL_CURRENT_PROGRAM:
1093bf215546Sopenharmony_ci      /* The Changelog of the ARB_separate_shader_objects spec says:
1094bf215546Sopenharmony_ci       *
1095bf215546Sopenharmony_ci       * 24 25 Jul 2011  pbrown  Remove the language erroneously deleting
1096bf215546Sopenharmony_ci       *                         CURRENT_PROGRAM.  In the EXT extension, this
1097bf215546Sopenharmony_ci       *                         token was aliased to ACTIVE_PROGRAM_EXT, and
1098bf215546Sopenharmony_ci       *                         was used to indicate the last program set by
1099bf215546Sopenharmony_ci       *                         either ActiveProgramEXT or UseProgram.  In
1100bf215546Sopenharmony_ci       *                         the ARB extension, the SSO active programs
1101bf215546Sopenharmony_ci       *                         are now program pipeline object state and
1102bf215546Sopenharmony_ci       *                         CURRENT_PROGRAM should still be used to query
1103bf215546Sopenharmony_ci       *                         the last program set by UseProgram (bug 7822).
1104bf215546Sopenharmony_ci       */
1105bf215546Sopenharmony_ci      v->value_int =
1106bf215546Sopenharmony_ci         ctx->Shader.ActiveProgram ? ctx->Shader.ActiveProgram->Name : 0;
1107bf215546Sopenharmony_ci      break;
1108bf215546Sopenharmony_ci   case GL_READ_FRAMEBUFFER_BINDING_EXT:
1109bf215546Sopenharmony_ci      v->value_int = ctx->ReadBuffer->Name;
1110bf215546Sopenharmony_ci      break;
1111bf215546Sopenharmony_ci   case GL_RENDERBUFFER_BINDING_EXT:
1112bf215546Sopenharmony_ci      v->value_int =
1113bf215546Sopenharmony_ci         ctx->CurrentRenderbuffer ? ctx->CurrentRenderbuffer->Name : 0;
1114bf215546Sopenharmony_ci      break;
1115bf215546Sopenharmony_ci   case GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES:
1116bf215546Sopenharmony_ci      buf = ctx->Array.VAO->BufferBinding[VERT_ATTRIB_POINT_SIZE].BufferObj;
1117bf215546Sopenharmony_ci      v->value_int = buf ? buf->Name : 0;
1118bf215546Sopenharmony_ci      break;
1119bf215546Sopenharmony_ci
1120bf215546Sopenharmony_ci   case GL_FOG_COLOR:
1121bf215546Sopenharmony_ci      if (_mesa_get_clamp_fragment_color(ctx, ctx->DrawBuffer))
1122bf215546Sopenharmony_ci         COPY_4FV(v->value_float_4, ctx->Fog.Color);
1123bf215546Sopenharmony_ci      else
1124bf215546Sopenharmony_ci         COPY_4FV(v->value_float_4, ctx->Fog.ColorUnclamped);
1125bf215546Sopenharmony_ci      break;
1126bf215546Sopenharmony_ci   case GL_COLOR_CLEAR_VALUE:
1127bf215546Sopenharmony_ci      if (_mesa_get_clamp_fragment_color(ctx, ctx->DrawBuffer)) {
1128bf215546Sopenharmony_ci         v->value_float_4[0] = CLAMP(ctx->Color.ClearColor.f[0], 0.0F, 1.0F);
1129bf215546Sopenharmony_ci         v->value_float_4[1] = CLAMP(ctx->Color.ClearColor.f[1], 0.0F, 1.0F);
1130bf215546Sopenharmony_ci         v->value_float_4[2] = CLAMP(ctx->Color.ClearColor.f[2], 0.0F, 1.0F);
1131bf215546Sopenharmony_ci         v->value_float_4[3] = CLAMP(ctx->Color.ClearColor.f[3], 0.0F, 1.0F);
1132bf215546Sopenharmony_ci      } else
1133bf215546Sopenharmony_ci         COPY_4FV(v->value_float_4, ctx->Color.ClearColor.f);
1134bf215546Sopenharmony_ci      break;
1135bf215546Sopenharmony_ci   case GL_BLEND_COLOR_EXT:
1136bf215546Sopenharmony_ci      if (_mesa_get_clamp_fragment_color(ctx, ctx->DrawBuffer))
1137bf215546Sopenharmony_ci         COPY_4FV(v->value_float_4, ctx->Color.BlendColor);
1138bf215546Sopenharmony_ci      else
1139bf215546Sopenharmony_ci         COPY_4FV(v->value_float_4, ctx->Color.BlendColorUnclamped);
1140bf215546Sopenharmony_ci      break;
1141bf215546Sopenharmony_ci   case GL_ALPHA_TEST_REF:
1142bf215546Sopenharmony_ci      if (_mesa_get_clamp_fragment_color(ctx, ctx->DrawBuffer))
1143bf215546Sopenharmony_ci         v->value_float = ctx->Color.AlphaRef;
1144bf215546Sopenharmony_ci      else
1145bf215546Sopenharmony_ci         v->value_float = ctx->Color.AlphaRefUnclamped;
1146bf215546Sopenharmony_ci      break;
1147bf215546Sopenharmony_ci   case GL_MAX_VERTEX_UNIFORM_VECTORS:
1148bf215546Sopenharmony_ci      v->value_int = ctx->Const.Program[MESA_SHADER_VERTEX].MaxUniformComponents / 4;
1149bf215546Sopenharmony_ci      break;
1150bf215546Sopenharmony_ci
1151bf215546Sopenharmony_ci   case GL_MAX_FRAGMENT_UNIFORM_VECTORS:
1152bf215546Sopenharmony_ci      v->value_int = ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxUniformComponents / 4;
1153bf215546Sopenharmony_ci      break;
1154bf215546Sopenharmony_ci
1155bf215546Sopenharmony_ci   /* GL_ARB_texture_buffer_object */
1156bf215546Sopenharmony_ci   case GL_TEXTURE_BUFFER_ARB:
1157bf215546Sopenharmony_ci      v->value_int = ctx->Texture.BufferObject ? ctx->Texture.BufferObject->Name : 0;
1158bf215546Sopenharmony_ci      break;
1159bf215546Sopenharmony_ci   case GL_TEXTURE_BINDING_BUFFER_ARB:
1160bf215546Sopenharmony_ci      unit = ctx->Texture.CurrentUnit;
1161bf215546Sopenharmony_ci      v->value_int =
1162bf215546Sopenharmony_ci         ctx->Texture.Unit[unit].CurrentTex[TEXTURE_BUFFER_INDEX]->Name;
1163bf215546Sopenharmony_ci      break;
1164bf215546Sopenharmony_ci   case GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB:
1165bf215546Sopenharmony_ci      {
1166bf215546Sopenharmony_ci         struct gl_buffer_object *buf =
1167bf215546Sopenharmony_ci            ctx->Texture.Unit[ctx->Texture.CurrentUnit]
1168bf215546Sopenharmony_ci            .CurrentTex[TEXTURE_BUFFER_INDEX]->BufferObject;
1169bf215546Sopenharmony_ci         v->value_int = buf ? buf->Name : 0;
1170bf215546Sopenharmony_ci      }
1171bf215546Sopenharmony_ci      break;
1172bf215546Sopenharmony_ci   case GL_TEXTURE_BUFFER_FORMAT_ARB:
1173bf215546Sopenharmony_ci      v->value_int = ctx->Texture.Unit[ctx->Texture.CurrentUnit]
1174bf215546Sopenharmony_ci         .CurrentTex[TEXTURE_BUFFER_INDEX]->BufferObjectFormat;
1175bf215546Sopenharmony_ci      break;
1176bf215546Sopenharmony_ci
1177bf215546Sopenharmony_ci   /* GL_ARB_sampler_objects */
1178bf215546Sopenharmony_ci   case GL_SAMPLER_BINDING:
1179bf215546Sopenharmony_ci      {
1180bf215546Sopenharmony_ci         struct gl_sampler_object *samp =
1181bf215546Sopenharmony_ci            ctx->Texture.Unit[ctx->Texture.CurrentUnit].Sampler;
1182bf215546Sopenharmony_ci         v->value_int = samp ? samp->Name : 0;
1183bf215546Sopenharmony_ci      }
1184bf215546Sopenharmony_ci      break;
1185bf215546Sopenharmony_ci   /* GL_ARB_uniform_buffer_object */
1186bf215546Sopenharmony_ci   case GL_UNIFORM_BUFFER_BINDING:
1187bf215546Sopenharmony_ci      v->value_int = ctx->UniformBuffer ? ctx->UniformBuffer->Name : 0;
1188bf215546Sopenharmony_ci      break;
1189bf215546Sopenharmony_ci   /* GL_ARB_shader_storage_buffer_object */
1190bf215546Sopenharmony_ci   case GL_SHADER_STORAGE_BUFFER_BINDING:
1191bf215546Sopenharmony_ci      v->value_int = ctx->ShaderStorageBuffer ? ctx->ShaderStorageBuffer->Name : 0;
1192bf215546Sopenharmony_ci      break;
1193bf215546Sopenharmony_ci   /* GL_ARB_query_buffer_object */
1194bf215546Sopenharmony_ci   case GL_QUERY_BUFFER_BINDING:
1195bf215546Sopenharmony_ci      v->value_int = ctx->QueryBuffer ? ctx->QueryBuffer->Name : 0;
1196bf215546Sopenharmony_ci      break;
1197bf215546Sopenharmony_ci   /* GL_ARB_timer_query */
1198bf215546Sopenharmony_ci   case GL_TIMESTAMP:
1199bf215546Sopenharmony_ci      v->value_int64 = _mesa_get_timestamp(ctx);
1200bf215546Sopenharmony_ci      break;
1201bf215546Sopenharmony_ci   /* GL_KHR_DEBUG */
1202bf215546Sopenharmony_ci   case GL_DEBUG_OUTPUT:
1203bf215546Sopenharmony_ci   case GL_DEBUG_OUTPUT_SYNCHRONOUS:
1204bf215546Sopenharmony_ci   case GL_DEBUG_LOGGED_MESSAGES:
1205bf215546Sopenharmony_ci   case GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH:
1206bf215546Sopenharmony_ci   case GL_DEBUG_GROUP_STACK_DEPTH:
1207bf215546Sopenharmony_ci      v->value_int = _mesa_get_debug_state_int(ctx, d->pname);
1208bf215546Sopenharmony_ci      break;
1209bf215546Sopenharmony_ci   /* GL_ARB_shader_atomic_counters */
1210bf215546Sopenharmony_ci   case GL_ATOMIC_COUNTER_BUFFER_BINDING:
1211bf215546Sopenharmony_ci      v->value_int = ctx->AtomicBuffer ? ctx->AtomicBuffer->Name : 0;
1212bf215546Sopenharmony_ci      break;
1213bf215546Sopenharmony_ci   /* GL 4.3 */
1214bf215546Sopenharmony_ci   case GL_NUM_SHADING_LANGUAGE_VERSIONS:
1215bf215546Sopenharmony_ci      v->value_int = _mesa_get_shading_language_version(ctx, -1, NULL);
1216bf215546Sopenharmony_ci      break;
1217bf215546Sopenharmony_ci   /* GL_ARB_draw_indirect */
1218bf215546Sopenharmony_ci   case GL_DRAW_INDIRECT_BUFFER_BINDING:
1219bf215546Sopenharmony_ci      v->value_int = ctx->DrawIndirectBuffer ? ctx->DrawIndirectBuffer->Name: 0;
1220bf215546Sopenharmony_ci      break;
1221bf215546Sopenharmony_ci   /* GL_ARB_indirect_parameters */
1222bf215546Sopenharmony_ci   case GL_PARAMETER_BUFFER_BINDING_ARB:
1223bf215546Sopenharmony_ci      v->value_int = ctx->ParameterBuffer ? ctx->ParameterBuffer->Name : 0;
1224bf215546Sopenharmony_ci      break;
1225bf215546Sopenharmony_ci   /* GL_ARB_separate_shader_objects */
1226bf215546Sopenharmony_ci   case GL_PROGRAM_PIPELINE_BINDING:
1227bf215546Sopenharmony_ci      if (ctx->Pipeline.Current) {
1228bf215546Sopenharmony_ci         v->value_int = ctx->Pipeline.Current->Name;
1229bf215546Sopenharmony_ci      } else {
1230bf215546Sopenharmony_ci         v->value_int = 0;
1231bf215546Sopenharmony_ci      }
1232bf215546Sopenharmony_ci      break;
1233bf215546Sopenharmony_ci   /* GL_ARB_compute_shader */
1234bf215546Sopenharmony_ci   case GL_DISPATCH_INDIRECT_BUFFER_BINDING:
1235bf215546Sopenharmony_ci      v->value_int = ctx->DispatchIndirectBuffer ?
1236bf215546Sopenharmony_ci                        ctx->DispatchIndirectBuffer->Name : 0;
1237bf215546Sopenharmony_ci      break;
1238bf215546Sopenharmony_ci   /* GL_ARB_multisample */
1239bf215546Sopenharmony_ci   case GL_SAMPLES:
1240bf215546Sopenharmony_ci      v->value_int = _mesa_geometric_samples(ctx->DrawBuffer);
1241bf215546Sopenharmony_ci      break;
1242bf215546Sopenharmony_ci   case GL_SAMPLE_BUFFERS:
1243bf215546Sopenharmony_ci      v->value_int = _mesa_geometric_samples(ctx->DrawBuffer) > 0;
1244bf215546Sopenharmony_ci      break;
1245bf215546Sopenharmony_ci   /* GL_EXT_textrue_integer */
1246bf215546Sopenharmony_ci   case GL_RGBA_INTEGER_MODE_EXT:
1247bf215546Sopenharmony_ci      v->value_int = (ctx->DrawBuffer->_IntegerBuffers != 0);
1248bf215546Sopenharmony_ci      break;
1249bf215546Sopenharmony_ci   /* GL_ATI_meminfo & GL_NVX_gpu_memory_info */
1250bf215546Sopenharmony_ci   case GL_VBO_FREE_MEMORY_ATI:
1251bf215546Sopenharmony_ci   case GL_TEXTURE_FREE_MEMORY_ATI:
1252bf215546Sopenharmony_ci   case GL_RENDERBUFFER_FREE_MEMORY_ATI:
1253bf215546Sopenharmony_ci   case GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX:
1254bf215546Sopenharmony_ci   case GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX:
1255bf215546Sopenharmony_ci   case GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX:
1256bf215546Sopenharmony_ci   case GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX:
1257bf215546Sopenharmony_ci   case GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX:
1258bf215546Sopenharmony_ci      {
1259bf215546Sopenharmony_ci         struct pipe_memory_info info;
1260bf215546Sopenharmony_ci         struct pipe_screen *screen = ctx->pipe->screen;
1261bf215546Sopenharmony_ci
1262bf215546Sopenharmony_ci         assert(screen->query_memory_info);
1263bf215546Sopenharmony_ci         screen->query_memory_info(screen, &info);
1264bf215546Sopenharmony_ci
1265bf215546Sopenharmony_ci         if (d->pname == GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX)
1266bf215546Sopenharmony_ci            v->value_int = info.total_device_memory;
1267bf215546Sopenharmony_ci         else if (d->pname == GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX)
1268bf215546Sopenharmony_ci            v->value_int = info.total_device_memory +
1269bf215546Sopenharmony_ci                           info.total_staging_memory;
1270bf215546Sopenharmony_ci         else if (d->pname == GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX)
1271bf215546Sopenharmony_ci            v->value_int = info.avail_device_memory;
1272bf215546Sopenharmony_ci         else if (d->pname == GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX)
1273bf215546Sopenharmony_ci            v->value_int = info.nr_device_memory_evictions;
1274bf215546Sopenharmony_ci         else if (d->pname == GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX)
1275bf215546Sopenharmony_ci            v->value_int = info.device_memory_evicted;
1276bf215546Sopenharmony_ci         else {
1277bf215546Sopenharmony_ci            /* ATI free memory enums.
1278bf215546Sopenharmony_ci             *
1279bf215546Sopenharmony_ci             * Since the GPU memory is (usually) page-table based, every two
1280bf215546Sopenharmony_ci             * consecutive elements are equal. From the GL_ATI_meminfo
1281bf215546Sopenharmony_ci             * specification:
1282bf215546Sopenharmony_ci             *
1283bf215546Sopenharmony_ci             *    "param[0] - total memory free in the pool
1284bf215546Sopenharmony_ci             *     param[1] - largest available free block in the pool
1285bf215546Sopenharmony_ci             *     param[2] - total auxiliary memory free
1286bf215546Sopenharmony_ci             *     param[3] - largest auxiliary free block"
1287bf215546Sopenharmony_ci             *
1288bf215546Sopenharmony_ci             * All three (VBO, TEXTURE, RENDERBUFFER) queries return
1289bf215546Sopenharmony_ci             * the same numbers here.
1290bf215546Sopenharmony_ci             */
1291bf215546Sopenharmony_ci            v->value_int_4[0] = info.avail_device_memory;
1292bf215546Sopenharmony_ci            v->value_int_4[1] = info.avail_device_memory;
1293bf215546Sopenharmony_ci            v->value_int_4[2] = info.avail_staging_memory;
1294bf215546Sopenharmony_ci            v->value_int_4[3] = info.avail_staging_memory;
1295bf215546Sopenharmony_ci         }
1296bf215546Sopenharmony_ci      }
1297bf215546Sopenharmony_ci      break;
1298bf215546Sopenharmony_ci
1299bf215546Sopenharmony_ci   /* GL_ARB_get_program_binary */
1300bf215546Sopenharmony_ci   case GL_PROGRAM_BINARY_FORMATS:
1301bf215546Sopenharmony_ci      assert(ctx->Const.NumProgramBinaryFormats <= 1);
1302bf215546Sopenharmony_ci      v->value_int_n.n = MIN2(ctx->Const.NumProgramBinaryFormats, 1);
1303bf215546Sopenharmony_ci      if (ctx->Const.NumProgramBinaryFormats > 0) {
1304bf215546Sopenharmony_ci         v->value_int_n.ints[0] = GL_PROGRAM_BINARY_FORMAT_MESA;
1305bf215546Sopenharmony_ci      }
1306bf215546Sopenharmony_ci      break;
1307bf215546Sopenharmony_ci   /* ARB_spirv_extensions */
1308bf215546Sopenharmony_ci   case GL_NUM_SPIR_V_EXTENSIONS:
1309bf215546Sopenharmony_ci      v->value_int = _mesa_get_spirv_extension_count(ctx);
1310bf215546Sopenharmony_ci      break;
1311bf215546Sopenharmony_ci   /* GL_EXT_disjoint_timer_query */
1312bf215546Sopenharmony_ci   case GL_GPU_DISJOINT_EXT:
1313bf215546Sopenharmony_ci      {
1314bf215546Sopenharmony_ci         simple_mtx_lock(&ctx->Shared->Mutex);
1315bf215546Sopenharmony_ci         v->value_int = ctx->Shared->DisjointOperation;
1316bf215546Sopenharmony_ci         /* Reset state as expected by the spec. */
1317bf215546Sopenharmony_ci         ctx->Shared->DisjointOperation = false;
1318bf215546Sopenharmony_ci         simple_mtx_unlock(&ctx->Shared->Mutex);
1319bf215546Sopenharmony_ci      }
1320bf215546Sopenharmony_ci      break;
1321bf215546Sopenharmony_ci   /* GL_ARB_sample_locations */
1322bf215546Sopenharmony_ci   case GL_SAMPLE_LOCATION_SUBPIXEL_BITS_ARB:
1323bf215546Sopenharmony_ci   case GL_SAMPLE_LOCATION_PIXEL_GRID_WIDTH_ARB:
1324bf215546Sopenharmony_ci   case GL_SAMPLE_LOCATION_PIXEL_GRID_HEIGHT_ARB:
1325bf215546Sopenharmony_ci      {
1326bf215546Sopenharmony_ci         GLuint bits, width, height;
1327bf215546Sopenharmony_ci
1328bf215546Sopenharmony_ci         if (ctx->NewState & _NEW_BUFFERS)
1329bf215546Sopenharmony_ci            _mesa_update_state(ctx);
1330bf215546Sopenharmony_ci
1331bf215546Sopenharmony_ci         if (ctx->DrawBuffer->_Status != GL_FRAMEBUFFER_COMPLETE) {
1332bf215546Sopenharmony_ci            v->value_uint = 0;
1333bf215546Sopenharmony_ci            break;
1334bf215546Sopenharmony_ci         }
1335bf215546Sopenharmony_ci
1336bf215546Sopenharmony_ci         _mesa_GetProgrammableSampleCaps(ctx, ctx->DrawBuffer,
1337bf215546Sopenharmony_ci                                         &bits, &width, &height);
1338bf215546Sopenharmony_ci
1339bf215546Sopenharmony_ci         if (d->pname == GL_SAMPLE_LOCATION_PIXEL_GRID_WIDTH_ARB)
1340bf215546Sopenharmony_ci            v->value_uint = width;
1341bf215546Sopenharmony_ci         else if (d->pname == GL_SAMPLE_LOCATION_PIXEL_GRID_HEIGHT_ARB)
1342bf215546Sopenharmony_ci            v->value_uint = height;
1343bf215546Sopenharmony_ci         else
1344bf215546Sopenharmony_ci            v->value_uint = bits;
1345bf215546Sopenharmony_ci      }
1346bf215546Sopenharmony_ci      break;
1347bf215546Sopenharmony_ci   case GL_PROGRAMMABLE_SAMPLE_LOCATION_TABLE_SIZE_ARB:
1348bf215546Sopenharmony_ci      v->value_uint = MAX_SAMPLE_LOCATION_TABLE_SIZE;
1349bf215546Sopenharmony_ci      break;
1350bf215546Sopenharmony_ci
1351bf215546Sopenharmony_ci   /* GL_AMD_framebuffer_multisample_advanced */
1352bf215546Sopenharmony_ci   case GL_SUPPORTED_MULTISAMPLE_MODES_AMD:
1353bf215546Sopenharmony_ci      v->value_int_n.n = ctx->Const.NumSupportedMultisampleModes * 3;
1354bf215546Sopenharmony_ci      memcpy(v->value_int_n.ints, ctx->Const.SupportedMultisampleModes,
1355bf215546Sopenharmony_ci             v->value_int_n.n * sizeof(GLint));
1356bf215546Sopenharmony_ci      break;
1357bf215546Sopenharmony_ci
1358bf215546Sopenharmony_ci   /* GL_NV_viewport_swizzle */
1359bf215546Sopenharmony_ci   case GL_VIEWPORT_SWIZZLE_X_NV:
1360bf215546Sopenharmony_ci      v->value_enum = ctx->ViewportArray[0].SwizzleX;
1361bf215546Sopenharmony_ci      break;
1362bf215546Sopenharmony_ci   case GL_VIEWPORT_SWIZZLE_Y_NV:
1363bf215546Sopenharmony_ci      v->value_enum = ctx->ViewportArray[0].SwizzleY;
1364bf215546Sopenharmony_ci      break;
1365bf215546Sopenharmony_ci   case GL_VIEWPORT_SWIZZLE_Z_NV:
1366bf215546Sopenharmony_ci      v->value_enum = ctx->ViewportArray[0].SwizzleZ;
1367bf215546Sopenharmony_ci      break;
1368bf215546Sopenharmony_ci   case GL_VIEWPORT_SWIZZLE_W_NV:
1369bf215546Sopenharmony_ci      v->value_enum = ctx->ViewportArray[0].SwizzleW;
1370bf215546Sopenharmony_ci      break;
1371bf215546Sopenharmony_ci   }
1372bf215546Sopenharmony_ci}
1373bf215546Sopenharmony_ci
1374bf215546Sopenharmony_ci/**
1375bf215546Sopenharmony_ci * Check extra constraints on a struct value_desc descriptor
1376bf215546Sopenharmony_ci *
1377bf215546Sopenharmony_ci * If a struct value_desc has a non-NULL extra pointer, it means that
1378bf215546Sopenharmony_ci * there are a number of extra constraints to check or actions to
1379bf215546Sopenharmony_ci * perform.  The extras is just an integer array where each integer
1380bf215546Sopenharmony_ci * encode different constraints or actions.
1381bf215546Sopenharmony_ci *
1382bf215546Sopenharmony_ci * \param ctx current context
1383bf215546Sopenharmony_ci * \param func name of calling glGet*v() function for error reporting
1384bf215546Sopenharmony_ci * \param d the struct value_desc that has the extra constraints
1385bf215546Sopenharmony_ci *
1386bf215546Sopenharmony_ci * \return GL_FALSE if all of the constraints were not satisfied,
1387bf215546Sopenharmony_ci *     otherwise GL_TRUE.
1388bf215546Sopenharmony_ci */
1389bf215546Sopenharmony_cistatic GLboolean
1390bf215546Sopenharmony_cicheck_extra(struct gl_context *ctx, const char *func, const struct value_desc *d)
1391bf215546Sopenharmony_ci{
1392bf215546Sopenharmony_ci   const GLuint version = ctx->Version;
1393bf215546Sopenharmony_ci   GLboolean api_check = GL_FALSE;
1394bf215546Sopenharmony_ci   GLboolean api_found = GL_FALSE;
1395bf215546Sopenharmony_ci   const int *e;
1396bf215546Sopenharmony_ci
1397bf215546Sopenharmony_ci   for (e = d->extra; *e != EXTRA_END; e++) {
1398bf215546Sopenharmony_ci      switch (*e) {
1399bf215546Sopenharmony_ci      case EXTRA_VERSION_30:
1400bf215546Sopenharmony_ci         api_check = GL_TRUE;
1401bf215546Sopenharmony_ci         if (version >= 30)
1402bf215546Sopenharmony_ci            api_found = GL_TRUE;
1403bf215546Sopenharmony_ci         break;
1404bf215546Sopenharmony_ci      case EXTRA_VERSION_31:
1405bf215546Sopenharmony_ci         api_check = GL_TRUE;
1406bf215546Sopenharmony_ci         if (version >= 31)
1407bf215546Sopenharmony_ci            api_found = GL_TRUE;
1408bf215546Sopenharmony_ci         break;
1409bf215546Sopenharmony_ci      case EXTRA_VERSION_32:
1410bf215546Sopenharmony_ci         api_check = GL_TRUE;
1411bf215546Sopenharmony_ci         if (version >= 32)
1412bf215546Sopenharmony_ci            api_found = GL_TRUE;
1413bf215546Sopenharmony_ci         break;
1414bf215546Sopenharmony_ci      case EXTRA_VERSION_40:
1415bf215546Sopenharmony_ci         api_check = GL_TRUE;
1416bf215546Sopenharmony_ci         if (version >= 40)
1417bf215546Sopenharmony_ci            api_found = GL_TRUE;
1418bf215546Sopenharmony_ci         break;
1419bf215546Sopenharmony_ci      case EXTRA_VERSION_43:
1420bf215546Sopenharmony_ci         api_check = GL_TRUE;
1421bf215546Sopenharmony_ci         if (_mesa_is_desktop_gl(ctx) && version >= 43)
1422bf215546Sopenharmony_ci            api_found = GL_TRUE;
1423bf215546Sopenharmony_ci         break;
1424bf215546Sopenharmony_ci      case EXTRA_API_ES2:
1425bf215546Sopenharmony_ci         api_check = GL_TRUE;
1426bf215546Sopenharmony_ci         if (ctx->API == API_OPENGLES2)
1427bf215546Sopenharmony_ci            api_found = GL_TRUE;
1428bf215546Sopenharmony_ci         break;
1429bf215546Sopenharmony_ci      case EXTRA_API_ES3:
1430bf215546Sopenharmony_ci         api_check = GL_TRUE;
1431bf215546Sopenharmony_ci         if (_mesa_is_gles3(ctx))
1432bf215546Sopenharmony_ci            api_found = GL_TRUE;
1433bf215546Sopenharmony_ci         break;
1434bf215546Sopenharmony_ci      case EXTRA_API_ES31:
1435bf215546Sopenharmony_ci         api_check = GL_TRUE;
1436bf215546Sopenharmony_ci         if (_mesa_is_gles31(ctx))
1437bf215546Sopenharmony_ci            api_found = GL_TRUE;
1438bf215546Sopenharmony_ci         break;
1439bf215546Sopenharmony_ci      case EXTRA_API_ES32:
1440bf215546Sopenharmony_ci         api_check = GL_TRUE;
1441bf215546Sopenharmony_ci         if (_mesa_is_gles32(ctx))
1442bf215546Sopenharmony_ci            api_found = GL_TRUE;
1443bf215546Sopenharmony_ci         break;
1444bf215546Sopenharmony_ci      case EXTRA_API_GL:
1445bf215546Sopenharmony_ci         api_check = GL_TRUE;
1446bf215546Sopenharmony_ci         if (_mesa_is_desktop_gl(ctx))
1447bf215546Sopenharmony_ci            api_found = GL_TRUE;
1448bf215546Sopenharmony_ci         break;
1449bf215546Sopenharmony_ci      case EXTRA_API_GL_CORE:
1450bf215546Sopenharmony_ci         api_check = GL_TRUE;
1451bf215546Sopenharmony_ci         if (ctx->API == API_OPENGL_CORE)
1452bf215546Sopenharmony_ci            api_found = GL_TRUE;
1453bf215546Sopenharmony_ci         break;
1454bf215546Sopenharmony_ci      case EXTRA_NEW_BUFFERS:
1455bf215546Sopenharmony_ci         if (ctx->NewState & _NEW_BUFFERS)
1456bf215546Sopenharmony_ci            _mesa_update_state(ctx);
1457bf215546Sopenharmony_ci         break;
1458bf215546Sopenharmony_ci      case EXTRA_FLUSH_CURRENT:
1459bf215546Sopenharmony_ci         FLUSH_CURRENT(ctx, 0);
1460bf215546Sopenharmony_ci         break;
1461bf215546Sopenharmony_ci      case EXTRA_VALID_DRAW_BUFFER:
1462bf215546Sopenharmony_ci         if (d->pname - GL_DRAW_BUFFER0_ARB >= ctx->Const.MaxDrawBuffers) {
1463bf215546Sopenharmony_ci            _mesa_error(ctx, GL_INVALID_OPERATION, "%s(draw buffer %u)",
1464bf215546Sopenharmony_ci                        func, d->pname - GL_DRAW_BUFFER0_ARB);
1465bf215546Sopenharmony_ci            return GL_FALSE;
1466bf215546Sopenharmony_ci         }
1467bf215546Sopenharmony_ci         break;
1468bf215546Sopenharmony_ci      case EXTRA_VALID_TEXTURE_UNIT:
1469bf215546Sopenharmony_ci         if (ctx->Texture.CurrentUnit >= ctx->Const.MaxTextureCoordUnits) {
1470bf215546Sopenharmony_ci            _mesa_error(ctx, GL_INVALID_OPERATION, "%s(texture %u)",
1471bf215546Sopenharmony_ci                        func, ctx->Texture.CurrentUnit);
1472bf215546Sopenharmony_ci            return GL_FALSE;
1473bf215546Sopenharmony_ci         }
1474bf215546Sopenharmony_ci         break;
1475bf215546Sopenharmony_ci      case EXTRA_VALID_CLIP_DISTANCE:
1476bf215546Sopenharmony_ci         if (d->pname - GL_CLIP_DISTANCE0 >= ctx->Const.MaxClipPlanes) {
1477bf215546Sopenharmony_ci            _mesa_error(ctx, GL_INVALID_ENUM, "%s(clip distance %u)",
1478bf215546Sopenharmony_ci                        func, d->pname - GL_CLIP_DISTANCE0);
1479bf215546Sopenharmony_ci            return GL_FALSE;
1480bf215546Sopenharmony_ci         }
1481bf215546Sopenharmony_ci         break;
1482bf215546Sopenharmony_ci      case EXTRA_GLSL_130:
1483bf215546Sopenharmony_ci         api_check = GL_TRUE;
1484bf215546Sopenharmony_ci         if (ctx->Const.GLSLVersion >= 130)
1485bf215546Sopenharmony_ci            api_found = GL_TRUE;
1486bf215546Sopenharmony_ci         break;
1487bf215546Sopenharmony_ci      case EXTRA_EXT_UBO_GS:
1488bf215546Sopenharmony_ci         api_check = GL_TRUE;
1489bf215546Sopenharmony_ci         if (ctx->Extensions.ARB_uniform_buffer_object &&
1490bf215546Sopenharmony_ci            _mesa_has_geometry_shaders(ctx))
1491bf215546Sopenharmony_ci            api_found = GL_TRUE;
1492bf215546Sopenharmony_ci         break;
1493bf215546Sopenharmony_ci      case EXTRA_EXT_ATOMICS_GS:
1494bf215546Sopenharmony_ci         api_check = GL_TRUE;
1495bf215546Sopenharmony_ci         if (ctx->Extensions.ARB_shader_atomic_counters &&
1496bf215546Sopenharmony_ci            _mesa_has_geometry_shaders(ctx))
1497bf215546Sopenharmony_ci            api_found = GL_TRUE;
1498bf215546Sopenharmony_ci         break;
1499bf215546Sopenharmony_ci      case EXTRA_EXT_SHADER_IMAGE_GS:
1500bf215546Sopenharmony_ci         api_check = GL_TRUE;
1501bf215546Sopenharmony_ci         if ((ctx->Extensions.ARB_shader_image_load_store ||
1502bf215546Sopenharmony_ci              _mesa_is_gles31(ctx)) &&
1503bf215546Sopenharmony_ci             _mesa_has_geometry_shaders(ctx))
1504bf215546Sopenharmony_ci            api_found = GL_TRUE;
1505bf215546Sopenharmony_ci         break;
1506bf215546Sopenharmony_ci      case EXTRA_EXT_ATOMICS_TESS:
1507bf215546Sopenharmony_ci         api_check = GL_TRUE;
1508bf215546Sopenharmony_ci         api_found = ctx->Extensions.ARB_shader_atomic_counters &&
1509bf215546Sopenharmony_ci                     _mesa_has_tessellation(ctx);
1510bf215546Sopenharmony_ci         break;
1511bf215546Sopenharmony_ci      case EXTRA_EXT_SHADER_IMAGE_TESS:
1512bf215546Sopenharmony_ci         api_check = GL_TRUE;
1513bf215546Sopenharmony_ci         api_found = ctx->Extensions.ARB_shader_image_load_store &&
1514bf215546Sopenharmony_ci                     _mesa_has_tessellation(ctx);
1515bf215546Sopenharmony_ci         break;
1516bf215546Sopenharmony_ci      case EXTRA_EXT_SSBO_GS:
1517bf215546Sopenharmony_ci         api_check = GL_TRUE;
1518bf215546Sopenharmony_ci         if (ctx->Extensions.ARB_shader_storage_buffer_object &&
1519bf215546Sopenharmony_ci            _mesa_has_geometry_shaders(ctx))
1520bf215546Sopenharmony_ci            api_found = GL_TRUE;
1521bf215546Sopenharmony_ci         break;
1522bf215546Sopenharmony_ci      case EXTRA_EXT_FB_NO_ATTACH_GS:
1523bf215546Sopenharmony_ci         api_check = GL_TRUE;
1524bf215546Sopenharmony_ci         if (ctx->Extensions.ARB_framebuffer_no_attachments &&
1525bf215546Sopenharmony_ci            (_mesa_is_desktop_gl(ctx) ||
1526bf215546Sopenharmony_ci            _mesa_has_OES_geometry_shader(ctx)))
1527bf215546Sopenharmony_ci            api_found = GL_TRUE;
1528bf215546Sopenharmony_ci         break;
1529bf215546Sopenharmony_ci      case EXTRA_EXT_ES_GS:
1530bf215546Sopenharmony_ci         api_check = GL_TRUE;
1531bf215546Sopenharmony_ci         if (_mesa_has_OES_geometry_shader(ctx))
1532bf215546Sopenharmony_ci            api_found = GL_TRUE;
1533bf215546Sopenharmony_ci         break;
1534bf215546Sopenharmony_ci      case EXTRA_EXT_PROVOKING_VERTEX_32:
1535bf215546Sopenharmony_ci         api_check = GL_TRUE;
1536bf215546Sopenharmony_ci         if (ctx->API == API_OPENGL_COMPAT || version == 32)
1537bf215546Sopenharmony_ci            api_found = ctx->Extensions.EXT_provoking_vertex;
1538bf215546Sopenharmony_ci         break;
1539bf215546Sopenharmony_ci      case EXTRA_END:
1540bf215546Sopenharmony_ci         break;
1541bf215546Sopenharmony_ci      default: /* *e is a offset into the extension struct */
1542bf215546Sopenharmony_ci         api_check = GL_TRUE;
1543bf215546Sopenharmony_ci         if (*(GLboolean *) ((char *) &ctx->Extensions + *e))
1544bf215546Sopenharmony_ci            api_found = GL_TRUE;
1545bf215546Sopenharmony_ci         break;
1546bf215546Sopenharmony_ci      }
1547bf215546Sopenharmony_ci   }
1548bf215546Sopenharmony_ci
1549bf215546Sopenharmony_ci   if (api_check && !api_found) {
1550bf215546Sopenharmony_ci      _mesa_error(ctx, GL_INVALID_ENUM, "%s(pname=%s)", func,
1551bf215546Sopenharmony_ci                  _mesa_enum_to_string(d->pname));
1552bf215546Sopenharmony_ci      return GL_FALSE;
1553bf215546Sopenharmony_ci   }
1554bf215546Sopenharmony_ci
1555bf215546Sopenharmony_ci   return GL_TRUE;
1556bf215546Sopenharmony_ci}
1557bf215546Sopenharmony_ci
1558bf215546Sopenharmony_cistatic const struct value_desc error_value =
1559bf215546Sopenharmony_ci   { 0, 0, TYPE_INVALID, NO_OFFSET, NO_EXTRA };
1560bf215546Sopenharmony_ci
1561bf215546Sopenharmony_ci/**
1562bf215546Sopenharmony_ci * Find the struct value_desc corresponding to the enum 'pname'.
1563bf215546Sopenharmony_ci *
1564bf215546Sopenharmony_ci * We hash the enum value to get an index into the 'table' array,
1565bf215546Sopenharmony_ci * which holds the index in the 'values' array of struct value_desc.
1566bf215546Sopenharmony_ci * Once we've found the entry, we do the extra checks, if any, then
1567bf215546Sopenharmony_ci * look up the value and return a pointer to it.
1568bf215546Sopenharmony_ci *
1569bf215546Sopenharmony_ci * If the value has to be computed (for example, it's the result of a
1570bf215546Sopenharmony_ci * function call or we need to add 1 to it), we use the tmp 'v' to
1571bf215546Sopenharmony_ci * store the result.
1572bf215546Sopenharmony_ci *
1573bf215546Sopenharmony_ci * \param func name of glGet*v() func for error reporting
1574bf215546Sopenharmony_ci * \param pname the enum value we're looking up
1575bf215546Sopenharmony_ci * \param p is were we return the pointer to the value
1576bf215546Sopenharmony_ci * \param v a tmp union value variable in the calling glGet*v() function
1577bf215546Sopenharmony_ci *
1578bf215546Sopenharmony_ci * \return the struct value_desc corresponding to the enum or a struct
1579bf215546Sopenharmony_ci *     value_desc of TYPE_INVALID if not found.  This lets the calling
1580bf215546Sopenharmony_ci *     glGet*v() function jump right into a switch statement and
1581bf215546Sopenharmony_ci *     handle errors there instead of having to check for NULL.
1582bf215546Sopenharmony_ci */
1583bf215546Sopenharmony_cistatic const struct value_desc *
1584bf215546Sopenharmony_cifind_value(const char *func, GLenum pname, void **p, union value *v)
1585bf215546Sopenharmony_ci{
1586bf215546Sopenharmony_ci   GET_CURRENT_CONTEXT(ctx);
1587bf215546Sopenharmony_ci   int mask, hash;
1588bf215546Sopenharmony_ci   const struct value_desc *d;
1589bf215546Sopenharmony_ci   int api;
1590bf215546Sopenharmony_ci
1591bf215546Sopenharmony_ci   *p = NULL;
1592bf215546Sopenharmony_ci
1593bf215546Sopenharmony_ci   api = ctx->API;
1594bf215546Sopenharmony_ci   /* We index into the table_set[] list of per-API hash tables using the API's
1595bf215546Sopenharmony_ci    * value in the gl_api enum. Since GLES 3 doesn't have an API_OPENGL* enum
1596bf215546Sopenharmony_ci    * value since it's compatible with GLES2 its entry in table_set[] is at the
1597bf215546Sopenharmony_ci    * end.
1598bf215546Sopenharmony_ci    */
1599bf215546Sopenharmony_ci   STATIC_ASSERT(ARRAY_SIZE(table_set) == API_OPENGL_LAST + 4);
1600bf215546Sopenharmony_ci   if (ctx->API == API_OPENGLES2) {
1601bf215546Sopenharmony_ci      if (ctx->Version >= 32)
1602bf215546Sopenharmony_ci         api = API_OPENGL_LAST + 3;
1603bf215546Sopenharmony_ci      else if (ctx->Version >= 31)
1604bf215546Sopenharmony_ci         api = API_OPENGL_LAST + 2;
1605bf215546Sopenharmony_ci      else if (ctx->Version >= 30)
1606bf215546Sopenharmony_ci         api = API_OPENGL_LAST + 1;
1607bf215546Sopenharmony_ci   }
1608bf215546Sopenharmony_ci   mask = ARRAY_SIZE(table(api)) - 1;
1609bf215546Sopenharmony_ci   hash = (pname * prime_factor);
1610bf215546Sopenharmony_ci   while (1) {
1611bf215546Sopenharmony_ci      int idx = table(api)[hash & mask];
1612bf215546Sopenharmony_ci
1613bf215546Sopenharmony_ci      /* If the enum isn't valid, the hash walk ends with index 0,
1614bf215546Sopenharmony_ci       * pointing to the first entry of values[] which doesn't hold
1615bf215546Sopenharmony_ci       * any valid enum. */
1616bf215546Sopenharmony_ci      if (unlikely(idx == 0)) {
1617bf215546Sopenharmony_ci         _mesa_error(ctx, GL_INVALID_ENUM, "%s(pname=%s)", func,
1618bf215546Sopenharmony_ci               _mesa_enum_to_string(pname));
1619bf215546Sopenharmony_ci         return &error_value;
1620bf215546Sopenharmony_ci      }
1621bf215546Sopenharmony_ci
1622bf215546Sopenharmony_ci      d = &values[idx];
1623bf215546Sopenharmony_ci      if (likely(d->pname == pname))
1624bf215546Sopenharmony_ci         break;
1625bf215546Sopenharmony_ci
1626bf215546Sopenharmony_ci      hash += prime_step;
1627bf215546Sopenharmony_ci   }
1628bf215546Sopenharmony_ci
1629bf215546Sopenharmony_ci   if (unlikely(d->extra && !check_extra(ctx, func, d)))
1630bf215546Sopenharmony_ci      return &error_value;
1631bf215546Sopenharmony_ci
1632bf215546Sopenharmony_ci   switch (d->location) {
1633bf215546Sopenharmony_ci   case LOC_BUFFER:
1634bf215546Sopenharmony_ci      *p = ((char *) ctx->DrawBuffer + d->offset);
1635bf215546Sopenharmony_ci      return d;
1636bf215546Sopenharmony_ci   case LOC_CONTEXT:
1637bf215546Sopenharmony_ci      *p = ((char *) ctx + d->offset);
1638bf215546Sopenharmony_ci      return d;
1639bf215546Sopenharmony_ci   case LOC_ARRAY:
1640bf215546Sopenharmony_ci      *p = ((char *) ctx->Array.VAO + d->offset);
1641bf215546Sopenharmony_ci      return d;
1642bf215546Sopenharmony_ci   case LOC_TEXUNIT:
1643bf215546Sopenharmony_ci      if (ctx->Texture.CurrentUnit < ARRAY_SIZE(ctx->Texture.FixedFuncUnit)) {
1644bf215546Sopenharmony_ci         unsigned index = ctx->Texture.CurrentUnit;
1645bf215546Sopenharmony_ci         *p = ((char *)&ctx->Texture.FixedFuncUnit[index] + d->offset);
1646bf215546Sopenharmony_ci         return d;
1647bf215546Sopenharmony_ci      }
1648bf215546Sopenharmony_ci      _mesa_error(ctx, GL_INVALID_VALUE, "%s(pname=%s,unit=%d)", func,
1649bf215546Sopenharmony_ci                  _mesa_enum_to_string(pname),
1650bf215546Sopenharmony_ci                  ctx->Texture.CurrentUnit);
1651bf215546Sopenharmony_ci      return &error_value;
1652bf215546Sopenharmony_ci   case LOC_CUSTOM:
1653bf215546Sopenharmony_ci      find_custom_value(ctx, d, v);
1654bf215546Sopenharmony_ci      *p = v;
1655bf215546Sopenharmony_ci      return d;
1656bf215546Sopenharmony_ci   default:
1657bf215546Sopenharmony_ci      assert(0);
1658bf215546Sopenharmony_ci      break;
1659bf215546Sopenharmony_ci   }
1660bf215546Sopenharmony_ci
1661bf215546Sopenharmony_ci   /* silence warning */
1662bf215546Sopenharmony_ci   return &error_value;
1663bf215546Sopenharmony_ci}
1664bf215546Sopenharmony_ci
1665bf215546Sopenharmony_cistatic const int transpose[] = {
1666bf215546Sopenharmony_ci   0, 4,  8, 12,
1667bf215546Sopenharmony_ci   1, 5,  9, 13,
1668bf215546Sopenharmony_ci   2, 6, 10, 14,
1669bf215546Sopenharmony_ci   3, 7, 11, 15
1670bf215546Sopenharmony_ci};
1671bf215546Sopenharmony_ci
1672bf215546Sopenharmony_cistatic GLsizei
1673bf215546Sopenharmony_ciget_value_size(enum value_type type, const union value *v)
1674bf215546Sopenharmony_ci{
1675bf215546Sopenharmony_ci   switch (type) {
1676bf215546Sopenharmony_ci   case TYPE_INVALID:
1677bf215546Sopenharmony_ci      return 0;
1678bf215546Sopenharmony_ci   case TYPE_CONST:
1679bf215546Sopenharmony_ci   case TYPE_UINT:
1680bf215546Sopenharmony_ci   case TYPE_INT:
1681bf215546Sopenharmony_ci      return sizeof(GLint);
1682bf215546Sopenharmony_ci   case TYPE_INT_2:
1683bf215546Sopenharmony_ci   case TYPE_UINT_2:
1684bf215546Sopenharmony_ci      return sizeof(GLint) * 2;
1685bf215546Sopenharmony_ci   case TYPE_INT_3:
1686bf215546Sopenharmony_ci   case TYPE_UINT_3:
1687bf215546Sopenharmony_ci      return sizeof(GLint) * 3;
1688bf215546Sopenharmony_ci   case TYPE_INT_4:
1689bf215546Sopenharmony_ci   case TYPE_UINT_4:
1690bf215546Sopenharmony_ci      return sizeof(GLint) * 4;
1691bf215546Sopenharmony_ci   case TYPE_INT_N:
1692bf215546Sopenharmony_ci      return sizeof(GLint) * v->value_int_n.n;
1693bf215546Sopenharmony_ci   case TYPE_INT64:
1694bf215546Sopenharmony_ci      return sizeof(GLint64);
1695bf215546Sopenharmony_ci      break;
1696bf215546Sopenharmony_ci   case TYPE_ENUM16:
1697bf215546Sopenharmony_ci      return sizeof(GLenum16);
1698bf215546Sopenharmony_ci   case TYPE_ENUM:
1699bf215546Sopenharmony_ci      return sizeof(GLenum);
1700bf215546Sopenharmony_ci   case TYPE_ENUM_2:
1701bf215546Sopenharmony_ci      return sizeof(GLenum) * 2;
1702bf215546Sopenharmony_ci   case TYPE_BOOLEAN:
1703bf215546Sopenharmony_ci      return sizeof(GLboolean);
1704bf215546Sopenharmony_ci   case TYPE_UBYTE:
1705bf215546Sopenharmony_ci      return sizeof(GLubyte);
1706bf215546Sopenharmony_ci   case TYPE_SHORT:
1707bf215546Sopenharmony_ci      return sizeof(GLshort);
1708bf215546Sopenharmony_ci   case TYPE_BIT_0:
1709bf215546Sopenharmony_ci   case TYPE_BIT_1:
1710bf215546Sopenharmony_ci   case TYPE_BIT_2:
1711bf215546Sopenharmony_ci   case TYPE_BIT_3:
1712bf215546Sopenharmony_ci   case TYPE_BIT_4:
1713bf215546Sopenharmony_ci   case TYPE_BIT_5:
1714bf215546Sopenharmony_ci   case TYPE_BIT_6:
1715bf215546Sopenharmony_ci   case TYPE_BIT_7:
1716bf215546Sopenharmony_ci      return 1;
1717bf215546Sopenharmony_ci   case TYPE_FLOAT:
1718bf215546Sopenharmony_ci   case TYPE_FLOATN:
1719bf215546Sopenharmony_ci      return sizeof(GLfloat);
1720bf215546Sopenharmony_ci   case TYPE_FLOAT_2:
1721bf215546Sopenharmony_ci   case TYPE_FLOATN_2:
1722bf215546Sopenharmony_ci      return sizeof(GLfloat) * 2;
1723bf215546Sopenharmony_ci   case TYPE_FLOAT_3:
1724bf215546Sopenharmony_ci   case TYPE_FLOATN_3:
1725bf215546Sopenharmony_ci      return sizeof(GLfloat) * 3;
1726bf215546Sopenharmony_ci   case TYPE_FLOAT_4:
1727bf215546Sopenharmony_ci   case TYPE_FLOATN_4:
1728bf215546Sopenharmony_ci      return sizeof(GLfloat) * 4;
1729bf215546Sopenharmony_ci   case TYPE_FLOAT_8:
1730bf215546Sopenharmony_ci      return sizeof(GLfloat) * 8;
1731bf215546Sopenharmony_ci   case TYPE_DOUBLEN:
1732bf215546Sopenharmony_ci      return sizeof(GLdouble);
1733bf215546Sopenharmony_ci   case TYPE_DOUBLEN_2:
1734bf215546Sopenharmony_ci      return sizeof(GLdouble) * 2;
1735bf215546Sopenharmony_ci   case TYPE_MATRIX:
1736bf215546Sopenharmony_ci      return sizeof (GLfloat) * 16;
1737bf215546Sopenharmony_ci   case TYPE_MATRIX_T:
1738bf215546Sopenharmony_ci      return sizeof (GLfloat) * 16;
1739bf215546Sopenharmony_ci   default:
1740bf215546Sopenharmony_ci      assert(!"invalid value_type given for get_value_size()");
1741bf215546Sopenharmony_ci      return -1;
1742bf215546Sopenharmony_ci   }
1743bf215546Sopenharmony_ci}
1744bf215546Sopenharmony_ci
1745bf215546Sopenharmony_civoid GLAPIENTRY
1746bf215546Sopenharmony_ci_mesa_GetBooleanv(GLenum pname, GLboolean *params)
1747bf215546Sopenharmony_ci{
1748bf215546Sopenharmony_ci   const struct value_desc *d;
1749bf215546Sopenharmony_ci   union value v;
1750bf215546Sopenharmony_ci   GLmatrix *m;
1751bf215546Sopenharmony_ci   int shift, i;
1752bf215546Sopenharmony_ci   void *p;
1753bf215546Sopenharmony_ci
1754bf215546Sopenharmony_ci   d = find_value("glGetBooleanv", pname, &p, &v);
1755bf215546Sopenharmony_ci   switch (d->type) {
1756bf215546Sopenharmony_ci   case TYPE_INVALID:
1757bf215546Sopenharmony_ci      break;
1758bf215546Sopenharmony_ci   case TYPE_CONST:
1759bf215546Sopenharmony_ci      params[0] = INT_TO_BOOLEAN(d->offset);
1760bf215546Sopenharmony_ci      break;
1761bf215546Sopenharmony_ci
1762bf215546Sopenharmony_ci   case TYPE_FLOAT_8:
1763bf215546Sopenharmony_ci      params[7] = FLOAT_TO_BOOLEAN(((GLfloat *) p)[7]);
1764bf215546Sopenharmony_ci      params[6] = FLOAT_TO_BOOLEAN(((GLfloat *) p)[6]);
1765bf215546Sopenharmony_ci      params[5] = FLOAT_TO_BOOLEAN(((GLfloat *) p)[5]);
1766bf215546Sopenharmony_ci      params[4] = FLOAT_TO_BOOLEAN(((GLfloat *) p)[4]);
1767bf215546Sopenharmony_ci      FALLTHROUGH;
1768bf215546Sopenharmony_ci   case TYPE_FLOAT_4:
1769bf215546Sopenharmony_ci   case TYPE_FLOATN_4:
1770bf215546Sopenharmony_ci      params[3] = FLOAT_TO_BOOLEAN(((GLfloat *) p)[3]);
1771bf215546Sopenharmony_ci      FALLTHROUGH;
1772bf215546Sopenharmony_ci   case TYPE_FLOAT_3:
1773bf215546Sopenharmony_ci   case TYPE_FLOATN_3:
1774bf215546Sopenharmony_ci      params[2] = FLOAT_TO_BOOLEAN(((GLfloat *) p)[2]);
1775bf215546Sopenharmony_ci      FALLTHROUGH;
1776bf215546Sopenharmony_ci   case TYPE_FLOAT_2:
1777bf215546Sopenharmony_ci   case TYPE_FLOATN_2:
1778bf215546Sopenharmony_ci      params[1] = FLOAT_TO_BOOLEAN(((GLfloat *) p)[1]);
1779bf215546Sopenharmony_ci      FALLTHROUGH;
1780bf215546Sopenharmony_ci   case TYPE_FLOAT:
1781bf215546Sopenharmony_ci   case TYPE_FLOATN:
1782bf215546Sopenharmony_ci      params[0] = FLOAT_TO_BOOLEAN(((GLfloat *) p)[0]);
1783bf215546Sopenharmony_ci      break;
1784bf215546Sopenharmony_ci
1785bf215546Sopenharmony_ci   case TYPE_DOUBLEN_2:
1786bf215546Sopenharmony_ci      params[1] = FLOAT_TO_BOOLEAN(((GLdouble *) p)[1]);
1787bf215546Sopenharmony_ci      FALLTHROUGH;
1788bf215546Sopenharmony_ci   case TYPE_DOUBLEN:
1789bf215546Sopenharmony_ci      params[0] = FLOAT_TO_BOOLEAN(((GLdouble *) p)[0]);
1790bf215546Sopenharmony_ci      break;
1791bf215546Sopenharmony_ci
1792bf215546Sopenharmony_ci   case TYPE_INT_4:
1793bf215546Sopenharmony_ci   case TYPE_UINT_4:
1794bf215546Sopenharmony_ci      params[3] = INT_TO_BOOLEAN(((GLint *) p)[3]);
1795bf215546Sopenharmony_ci      FALLTHROUGH;
1796bf215546Sopenharmony_ci   case TYPE_INT_3:
1797bf215546Sopenharmony_ci   case TYPE_UINT_3:
1798bf215546Sopenharmony_ci      params[2] = INT_TO_BOOLEAN(((GLint *) p)[2]);
1799bf215546Sopenharmony_ci      FALLTHROUGH;
1800bf215546Sopenharmony_ci   case TYPE_INT_2:
1801bf215546Sopenharmony_ci   case TYPE_UINT_2:
1802bf215546Sopenharmony_ci   case TYPE_ENUM_2:
1803bf215546Sopenharmony_ci      params[1] = INT_TO_BOOLEAN(((GLint *) p)[1]);
1804bf215546Sopenharmony_ci      FALLTHROUGH;
1805bf215546Sopenharmony_ci   case TYPE_INT:
1806bf215546Sopenharmony_ci   case TYPE_UINT:
1807bf215546Sopenharmony_ci   case TYPE_ENUM:
1808bf215546Sopenharmony_ci      params[0] = INT_TO_BOOLEAN(((GLint *) p)[0]);
1809bf215546Sopenharmony_ci      break;
1810bf215546Sopenharmony_ci
1811bf215546Sopenharmony_ci   case TYPE_ENUM16:
1812bf215546Sopenharmony_ci      params[0] = INT_TO_BOOLEAN(((GLenum16 *) p)[0]);
1813bf215546Sopenharmony_ci      break;
1814bf215546Sopenharmony_ci
1815bf215546Sopenharmony_ci   case TYPE_INT_N:
1816bf215546Sopenharmony_ci      for (i = 0; i < v.value_int_n.n; i++)
1817bf215546Sopenharmony_ci         params[i] = INT_TO_BOOLEAN(v.value_int_n.ints[i]);
1818bf215546Sopenharmony_ci      break;
1819bf215546Sopenharmony_ci
1820bf215546Sopenharmony_ci   case TYPE_INT64:
1821bf215546Sopenharmony_ci      params[0] = INT64_TO_BOOLEAN(((GLint64 *) p)[0]);
1822bf215546Sopenharmony_ci      break;
1823bf215546Sopenharmony_ci
1824bf215546Sopenharmony_ci   case TYPE_BOOLEAN:
1825bf215546Sopenharmony_ci      params[0] = ((GLboolean*) p)[0];
1826bf215546Sopenharmony_ci      break;
1827bf215546Sopenharmony_ci
1828bf215546Sopenharmony_ci   case TYPE_UBYTE:
1829bf215546Sopenharmony_ci      params[0] = INT_TO_BOOLEAN(((GLubyte *) p)[0]);
1830bf215546Sopenharmony_ci      break;
1831bf215546Sopenharmony_ci
1832bf215546Sopenharmony_ci   case TYPE_SHORT:
1833bf215546Sopenharmony_ci      params[0] = INT_TO_BOOLEAN(((GLshort *) p)[0]);
1834bf215546Sopenharmony_ci      break;
1835bf215546Sopenharmony_ci
1836bf215546Sopenharmony_ci   case TYPE_MATRIX:
1837bf215546Sopenharmony_ci      m = *(GLmatrix **) p;
1838bf215546Sopenharmony_ci      for (i = 0; i < 16; i++)
1839bf215546Sopenharmony_ci         params[i] = FLOAT_TO_BOOLEAN(m->m[i]);
1840bf215546Sopenharmony_ci      break;
1841bf215546Sopenharmony_ci
1842bf215546Sopenharmony_ci   case TYPE_MATRIX_T:
1843bf215546Sopenharmony_ci      m = *(GLmatrix **) p;
1844bf215546Sopenharmony_ci      for (i = 0; i < 16; i++)
1845bf215546Sopenharmony_ci         params[i] = FLOAT_TO_BOOLEAN(m->m[transpose[i]]);
1846bf215546Sopenharmony_ci      break;
1847bf215546Sopenharmony_ci
1848bf215546Sopenharmony_ci   case TYPE_BIT_0:
1849bf215546Sopenharmony_ci   case TYPE_BIT_1:
1850bf215546Sopenharmony_ci   case TYPE_BIT_2:
1851bf215546Sopenharmony_ci   case TYPE_BIT_3:
1852bf215546Sopenharmony_ci   case TYPE_BIT_4:
1853bf215546Sopenharmony_ci   case TYPE_BIT_5:
1854bf215546Sopenharmony_ci   case TYPE_BIT_6:
1855bf215546Sopenharmony_ci   case TYPE_BIT_7:
1856bf215546Sopenharmony_ci      shift = d->type - TYPE_BIT_0;
1857bf215546Sopenharmony_ci      params[0] = (*(GLbitfield *) p >> shift) & 1;
1858bf215546Sopenharmony_ci      break;
1859bf215546Sopenharmony_ci   }
1860bf215546Sopenharmony_ci}
1861bf215546Sopenharmony_ci
1862bf215546Sopenharmony_civoid GLAPIENTRY
1863bf215546Sopenharmony_ci_mesa_GetFloatv(GLenum pname, GLfloat *params)
1864bf215546Sopenharmony_ci{
1865bf215546Sopenharmony_ci   const struct value_desc *d;
1866bf215546Sopenharmony_ci   union value v;
1867bf215546Sopenharmony_ci   GLmatrix *m;
1868bf215546Sopenharmony_ci   int shift, i;
1869bf215546Sopenharmony_ci   void *p;
1870bf215546Sopenharmony_ci
1871bf215546Sopenharmony_ci   d = find_value("glGetFloatv", pname, &p, &v);
1872bf215546Sopenharmony_ci   switch (d->type) {
1873bf215546Sopenharmony_ci   case TYPE_INVALID:
1874bf215546Sopenharmony_ci      break;
1875bf215546Sopenharmony_ci   case TYPE_CONST:
1876bf215546Sopenharmony_ci      params[0] = (GLfloat) d->offset;
1877bf215546Sopenharmony_ci      break;
1878bf215546Sopenharmony_ci
1879bf215546Sopenharmony_ci   case TYPE_FLOAT_8:
1880bf215546Sopenharmony_ci      params[7] = ((GLfloat *) p)[7];
1881bf215546Sopenharmony_ci      params[6] = ((GLfloat *) p)[6];
1882bf215546Sopenharmony_ci      params[5] = ((GLfloat *) p)[5];
1883bf215546Sopenharmony_ci      params[4] = ((GLfloat *) p)[4];
1884bf215546Sopenharmony_ci      FALLTHROUGH;
1885bf215546Sopenharmony_ci   case TYPE_FLOAT_4:
1886bf215546Sopenharmony_ci   case TYPE_FLOATN_4:
1887bf215546Sopenharmony_ci      params[3] = ((GLfloat *) p)[3];
1888bf215546Sopenharmony_ci      FALLTHROUGH;
1889bf215546Sopenharmony_ci   case TYPE_FLOAT_3:
1890bf215546Sopenharmony_ci   case TYPE_FLOATN_3:
1891bf215546Sopenharmony_ci      params[2] = ((GLfloat *) p)[2];
1892bf215546Sopenharmony_ci      FALLTHROUGH;
1893bf215546Sopenharmony_ci   case TYPE_FLOAT_2:
1894bf215546Sopenharmony_ci   case TYPE_FLOATN_2:
1895bf215546Sopenharmony_ci      params[1] = ((GLfloat *) p)[1];
1896bf215546Sopenharmony_ci      FALLTHROUGH;
1897bf215546Sopenharmony_ci   case TYPE_FLOAT:
1898bf215546Sopenharmony_ci   case TYPE_FLOATN:
1899bf215546Sopenharmony_ci      params[0] = ((GLfloat *) p)[0];
1900bf215546Sopenharmony_ci      break;
1901bf215546Sopenharmony_ci
1902bf215546Sopenharmony_ci   case TYPE_DOUBLEN_2:
1903bf215546Sopenharmony_ci      params[1] = (GLfloat) (((GLdouble *) p)[1]);
1904bf215546Sopenharmony_ci      FALLTHROUGH;
1905bf215546Sopenharmony_ci   case TYPE_DOUBLEN:
1906bf215546Sopenharmony_ci      params[0] = (GLfloat) (((GLdouble *) p)[0]);
1907bf215546Sopenharmony_ci      break;
1908bf215546Sopenharmony_ci
1909bf215546Sopenharmony_ci   case TYPE_INT_4:
1910bf215546Sopenharmony_ci      params[3] = (GLfloat) (((GLint *) p)[3]);
1911bf215546Sopenharmony_ci      FALLTHROUGH;
1912bf215546Sopenharmony_ci   case TYPE_INT_3:
1913bf215546Sopenharmony_ci      params[2] = (GLfloat) (((GLint *) p)[2]);
1914bf215546Sopenharmony_ci      FALLTHROUGH;
1915bf215546Sopenharmony_ci   case TYPE_INT_2:
1916bf215546Sopenharmony_ci   case TYPE_ENUM_2:
1917bf215546Sopenharmony_ci      params[1] = (GLfloat) (((GLint *) p)[1]);
1918bf215546Sopenharmony_ci      FALLTHROUGH;
1919bf215546Sopenharmony_ci   case TYPE_INT:
1920bf215546Sopenharmony_ci   case TYPE_ENUM:
1921bf215546Sopenharmony_ci      params[0] = (GLfloat) (((GLint *) p)[0]);
1922bf215546Sopenharmony_ci      break;
1923bf215546Sopenharmony_ci
1924bf215546Sopenharmony_ci   case TYPE_ENUM16:
1925bf215546Sopenharmony_ci      params[0] = (GLfloat) (((GLenum16 *) p)[0]);
1926bf215546Sopenharmony_ci      break;
1927bf215546Sopenharmony_ci
1928bf215546Sopenharmony_ci   case TYPE_INT_N:
1929bf215546Sopenharmony_ci      for (i = 0; i < v.value_int_n.n; i++)
1930bf215546Sopenharmony_ci         params[i] = (GLfloat) v.value_int_n.ints[i];
1931bf215546Sopenharmony_ci      break;
1932bf215546Sopenharmony_ci
1933bf215546Sopenharmony_ci   case TYPE_UINT_4:
1934bf215546Sopenharmony_ci      params[3] = (GLfloat) (((GLuint *) p)[3]);
1935bf215546Sopenharmony_ci      FALLTHROUGH;
1936bf215546Sopenharmony_ci   case TYPE_UINT_3:
1937bf215546Sopenharmony_ci      params[2] = (GLfloat) (((GLuint *) p)[2]);
1938bf215546Sopenharmony_ci      FALLTHROUGH;
1939bf215546Sopenharmony_ci   case TYPE_UINT_2:
1940bf215546Sopenharmony_ci      params[1] = (GLfloat) (((GLuint *) p)[1]);
1941bf215546Sopenharmony_ci      FALLTHROUGH;
1942bf215546Sopenharmony_ci   case TYPE_UINT:
1943bf215546Sopenharmony_ci      params[0] = (GLfloat) (((GLuint *) p)[0]);
1944bf215546Sopenharmony_ci      break;
1945bf215546Sopenharmony_ci
1946bf215546Sopenharmony_ci   case TYPE_INT64:
1947bf215546Sopenharmony_ci      params[0] = (GLfloat) (((GLint64 *) p)[0]);
1948bf215546Sopenharmony_ci      break;
1949bf215546Sopenharmony_ci
1950bf215546Sopenharmony_ci   case TYPE_BOOLEAN:
1951bf215546Sopenharmony_ci      params[0] = BOOLEAN_TO_FLOAT(*(GLboolean*) p);
1952bf215546Sopenharmony_ci      break;
1953bf215546Sopenharmony_ci
1954bf215546Sopenharmony_ci   case TYPE_UBYTE:
1955bf215546Sopenharmony_ci      params[0] = (GLfloat) ((GLubyte *) p)[0];
1956bf215546Sopenharmony_ci      break;
1957bf215546Sopenharmony_ci
1958bf215546Sopenharmony_ci   case TYPE_SHORT:
1959bf215546Sopenharmony_ci      params[0] = (GLfloat) ((GLshort *) p)[0];
1960bf215546Sopenharmony_ci      break;
1961bf215546Sopenharmony_ci
1962bf215546Sopenharmony_ci   case TYPE_MATRIX:
1963bf215546Sopenharmony_ci      m = *(GLmatrix **) p;
1964bf215546Sopenharmony_ci      for (i = 0; i < 16; i++)
1965bf215546Sopenharmony_ci         params[i] = m->m[i];
1966bf215546Sopenharmony_ci      break;
1967bf215546Sopenharmony_ci
1968bf215546Sopenharmony_ci   case TYPE_MATRIX_T:
1969bf215546Sopenharmony_ci      m = *(GLmatrix **) p;
1970bf215546Sopenharmony_ci      for (i = 0; i < 16; i++)
1971bf215546Sopenharmony_ci         params[i] = m->m[transpose[i]];
1972bf215546Sopenharmony_ci      break;
1973bf215546Sopenharmony_ci
1974bf215546Sopenharmony_ci   case TYPE_BIT_0:
1975bf215546Sopenharmony_ci   case TYPE_BIT_1:
1976bf215546Sopenharmony_ci   case TYPE_BIT_2:
1977bf215546Sopenharmony_ci   case TYPE_BIT_3:
1978bf215546Sopenharmony_ci   case TYPE_BIT_4:
1979bf215546Sopenharmony_ci   case TYPE_BIT_5:
1980bf215546Sopenharmony_ci   case TYPE_BIT_6:
1981bf215546Sopenharmony_ci   case TYPE_BIT_7:
1982bf215546Sopenharmony_ci      shift = d->type - TYPE_BIT_0;
1983bf215546Sopenharmony_ci      params[0] = BOOLEAN_TO_FLOAT((*(GLbitfield *) p >> shift) & 1);
1984bf215546Sopenharmony_ci      break;
1985bf215546Sopenharmony_ci   }
1986bf215546Sopenharmony_ci}
1987bf215546Sopenharmony_ci
1988bf215546Sopenharmony_civoid GLAPIENTRY
1989bf215546Sopenharmony_ci_mesa_GetIntegerv(GLenum pname, GLint *params)
1990bf215546Sopenharmony_ci{
1991bf215546Sopenharmony_ci   const struct value_desc *d;
1992bf215546Sopenharmony_ci   union value v;
1993bf215546Sopenharmony_ci   GLmatrix *m;
1994bf215546Sopenharmony_ci   int shift, i;
1995bf215546Sopenharmony_ci   void *p;
1996bf215546Sopenharmony_ci
1997bf215546Sopenharmony_ci   d = find_value("glGetIntegerv", pname, &p, &v);
1998bf215546Sopenharmony_ci   switch (d->type) {
1999bf215546Sopenharmony_ci   case TYPE_INVALID:
2000bf215546Sopenharmony_ci      break;
2001bf215546Sopenharmony_ci   case TYPE_CONST:
2002bf215546Sopenharmony_ci      params[0] = d->offset;
2003bf215546Sopenharmony_ci      break;
2004bf215546Sopenharmony_ci
2005bf215546Sopenharmony_ci   case TYPE_FLOAT_8:
2006bf215546Sopenharmony_ci      params[7] = lroundf(((GLfloat *) p)[7]);
2007bf215546Sopenharmony_ci      params[6] = lroundf(((GLfloat *) p)[6]);
2008bf215546Sopenharmony_ci      params[5] = lroundf(((GLfloat *) p)[5]);
2009bf215546Sopenharmony_ci      params[4] = lroundf(((GLfloat *) p)[4]);
2010bf215546Sopenharmony_ci      FALLTHROUGH;
2011bf215546Sopenharmony_ci   case TYPE_FLOAT_4:
2012bf215546Sopenharmony_ci      params[3] = lroundf(((GLfloat *) p)[3]);
2013bf215546Sopenharmony_ci      FALLTHROUGH;
2014bf215546Sopenharmony_ci   case TYPE_FLOAT_3:
2015bf215546Sopenharmony_ci      params[2] = lroundf(((GLfloat *) p)[2]);
2016bf215546Sopenharmony_ci      FALLTHROUGH;
2017bf215546Sopenharmony_ci   case TYPE_FLOAT_2:
2018bf215546Sopenharmony_ci      params[1] = lroundf(((GLfloat *) p)[1]);
2019bf215546Sopenharmony_ci      FALLTHROUGH;
2020bf215546Sopenharmony_ci   case TYPE_FLOAT:
2021bf215546Sopenharmony_ci      params[0] = lroundf(((GLfloat *) p)[0]);
2022bf215546Sopenharmony_ci      break;
2023bf215546Sopenharmony_ci
2024bf215546Sopenharmony_ci   case TYPE_FLOATN_4:
2025bf215546Sopenharmony_ci      params[3] = FLOAT_TO_INT(((GLfloat *) p)[3]);
2026bf215546Sopenharmony_ci      FALLTHROUGH;
2027bf215546Sopenharmony_ci   case TYPE_FLOATN_3:
2028bf215546Sopenharmony_ci      params[2] = FLOAT_TO_INT(((GLfloat *) p)[2]);
2029bf215546Sopenharmony_ci      FALLTHROUGH;
2030bf215546Sopenharmony_ci   case TYPE_FLOATN_2:
2031bf215546Sopenharmony_ci      params[1] = FLOAT_TO_INT(((GLfloat *) p)[1]);
2032bf215546Sopenharmony_ci      FALLTHROUGH;
2033bf215546Sopenharmony_ci   case TYPE_FLOATN:
2034bf215546Sopenharmony_ci      params[0] = FLOAT_TO_INT(((GLfloat *) p)[0]);
2035bf215546Sopenharmony_ci      break;
2036bf215546Sopenharmony_ci
2037bf215546Sopenharmony_ci   case TYPE_DOUBLEN_2:
2038bf215546Sopenharmony_ci      params[1] = FLOAT_TO_INT(((GLdouble *) p)[1]);
2039bf215546Sopenharmony_ci      FALLTHROUGH;
2040bf215546Sopenharmony_ci   case TYPE_DOUBLEN:
2041bf215546Sopenharmony_ci      params[0] = FLOAT_TO_INT(((GLdouble *) p)[0]);
2042bf215546Sopenharmony_ci      break;
2043bf215546Sopenharmony_ci
2044bf215546Sopenharmony_ci   case TYPE_INT_4:
2045bf215546Sopenharmony_ci      params[3] = ((GLint *) p)[3];
2046bf215546Sopenharmony_ci      FALLTHROUGH;
2047bf215546Sopenharmony_ci   case TYPE_INT_3:
2048bf215546Sopenharmony_ci      params[2] = ((GLint *) p)[2];
2049bf215546Sopenharmony_ci      FALLTHROUGH;
2050bf215546Sopenharmony_ci   case TYPE_INT_2:
2051bf215546Sopenharmony_ci   case TYPE_ENUM_2:
2052bf215546Sopenharmony_ci      params[1] = ((GLint *) p)[1];
2053bf215546Sopenharmony_ci      FALLTHROUGH;
2054bf215546Sopenharmony_ci   case TYPE_INT:
2055bf215546Sopenharmony_ci   case TYPE_ENUM:
2056bf215546Sopenharmony_ci      params[0] = ((GLint *) p)[0];
2057bf215546Sopenharmony_ci      break;
2058bf215546Sopenharmony_ci
2059bf215546Sopenharmony_ci   case TYPE_UINT_4:
2060bf215546Sopenharmony_ci      params[3] = MIN2(((GLuint *) p)[3], INT_MAX);
2061bf215546Sopenharmony_ci      FALLTHROUGH;
2062bf215546Sopenharmony_ci   case TYPE_UINT_3:
2063bf215546Sopenharmony_ci      params[2] = MIN2(((GLuint *) p)[2], INT_MAX);
2064bf215546Sopenharmony_ci      FALLTHROUGH;
2065bf215546Sopenharmony_ci   case TYPE_UINT_2:
2066bf215546Sopenharmony_ci      params[1] = MIN2(((GLuint *) p)[1], INT_MAX);
2067bf215546Sopenharmony_ci      FALLTHROUGH;
2068bf215546Sopenharmony_ci   case TYPE_UINT:
2069bf215546Sopenharmony_ci      params[0] = MIN2(((GLuint *) p)[0], INT_MAX);
2070bf215546Sopenharmony_ci      break;
2071bf215546Sopenharmony_ci
2072bf215546Sopenharmony_ci   case TYPE_ENUM16:
2073bf215546Sopenharmony_ci      params[0] = ((GLenum16 *) p)[0];
2074bf215546Sopenharmony_ci      break;
2075bf215546Sopenharmony_ci
2076bf215546Sopenharmony_ci   case TYPE_INT_N:
2077bf215546Sopenharmony_ci      for (i = 0; i < v.value_int_n.n; i++)
2078bf215546Sopenharmony_ci         params[i] = v.value_int_n.ints[i];
2079bf215546Sopenharmony_ci      break;
2080bf215546Sopenharmony_ci
2081bf215546Sopenharmony_ci   case TYPE_INT64:
2082bf215546Sopenharmony_ci      params[0] = INT64_TO_INT(((GLint64 *) p)[0]);
2083bf215546Sopenharmony_ci      break;
2084bf215546Sopenharmony_ci
2085bf215546Sopenharmony_ci   case TYPE_BOOLEAN:
2086bf215546Sopenharmony_ci      params[0] = BOOLEAN_TO_INT(*(GLboolean*) p);
2087bf215546Sopenharmony_ci      break;
2088bf215546Sopenharmony_ci
2089bf215546Sopenharmony_ci   case TYPE_UBYTE:
2090bf215546Sopenharmony_ci      params[0] = ((GLubyte *) p)[0];
2091bf215546Sopenharmony_ci      break;
2092bf215546Sopenharmony_ci
2093bf215546Sopenharmony_ci   case TYPE_SHORT:
2094bf215546Sopenharmony_ci      params[0] = ((GLshort *) p)[0];
2095bf215546Sopenharmony_ci      break;
2096bf215546Sopenharmony_ci
2097bf215546Sopenharmony_ci   case TYPE_MATRIX:
2098bf215546Sopenharmony_ci      m = *(GLmatrix **) p;
2099bf215546Sopenharmony_ci      for (i = 0; i < 16; i++)
2100bf215546Sopenharmony_ci         params[i] = FLOAT_TO_INT(m->m[i]);
2101bf215546Sopenharmony_ci      break;
2102bf215546Sopenharmony_ci
2103bf215546Sopenharmony_ci   case TYPE_MATRIX_T:
2104bf215546Sopenharmony_ci      m = *(GLmatrix **) p;
2105bf215546Sopenharmony_ci      for (i = 0; i < 16; i++)
2106bf215546Sopenharmony_ci         params[i] = FLOAT_TO_INT(m->m[transpose[i]]);
2107bf215546Sopenharmony_ci      break;
2108bf215546Sopenharmony_ci
2109bf215546Sopenharmony_ci   case TYPE_BIT_0:
2110bf215546Sopenharmony_ci   case TYPE_BIT_1:
2111bf215546Sopenharmony_ci   case TYPE_BIT_2:
2112bf215546Sopenharmony_ci   case TYPE_BIT_3:
2113bf215546Sopenharmony_ci   case TYPE_BIT_4:
2114bf215546Sopenharmony_ci   case TYPE_BIT_5:
2115bf215546Sopenharmony_ci   case TYPE_BIT_6:
2116bf215546Sopenharmony_ci   case TYPE_BIT_7:
2117bf215546Sopenharmony_ci      shift = d->type - TYPE_BIT_0;
2118bf215546Sopenharmony_ci      params[0] = (*(GLbitfield *) p >> shift) & 1;
2119bf215546Sopenharmony_ci      break;
2120bf215546Sopenharmony_ci   }
2121bf215546Sopenharmony_ci}
2122bf215546Sopenharmony_ci
2123bf215546Sopenharmony_civoid GLAPIENTRY
2124bf215546Sopenharmony_ci_mesa_GetInteger64v(GLenum pname, GLint64 *params)
2125bf215546Sopenharmony_ci{
2126bf215546Sopenharmony_ci   const struct value_desc *d;
2127bf215546Sopenharmony_ci   union value v;
2128bf215546Sopenharmony_ci   GLmatrix *m;
2129bf215546Sopenharmony_ci   int shift, i;
2130bf215546Sopenharmony_ci   void *p;
2131bf215546Sopenharmony_ci
2132bf215546Sopenharmony_ci   d = find_value("glGetInteger64v", pname, &p, &v);
2133bf215546Sopenharmony_ci   switch (d->type) {
2134bf215546Sopenharmony_ci   case TYPE_INVALID:
2135bf215546Sopenharmony_ci      break;
2136bf215546Sopenharmony_ci   case TYPE_CONST:
2137bf215546Sopenharmony_ci      params[0] = d->offset;
2138bf215546Sopenharmony_ci      break;
2139bf215546Sopenharmony_ci
2140bf215546Sopenharmony_ci   case TYPE_FLOAT_8:
2141bf215546Sopenharmony_ci      params[7] = llround(((GLfloat *) p)[7]);
2142bf215546Sopenharmony_ci      params[6] = llround(((GLfloat *) p)[6]);
2143bf215546Sopenharmony_ci      params[5] = llround(((GLfloat *) p)[5]);
2144bf215546Sopenharmony_ci      params[4] = llround(((GLfloat *) p)[4]);
2145bf215546Sopenharmony_ci      FALLTHROUGH;
2146bf215546Sopenharmony_ci   case TYPE_FLOAT_4:
2147bf215546Sopenharmony_ci      params[3] = llround(((GLfloat *) p)[3]);
2148bf215546Sopenharmony_ci      FALLTHROUGH;
2149bf215546Sopenharmony_ci   case TYPE_FLOAT_3:
2150bf215546Sopenharmony_ci      params[2] = llround(((GLfloat *) p)[2]);
2151bf215546Sopenharmony_ci      FALLTHROUGH;
2152bf215546Sopenharmony_ci   case TYPE_FLOAT_2:
2153bf215546Sopenharmony_ci      params[1] = llround(((GLfloat *) p)[1]);
2154bf215546Sopenharmony_ci      FALLTHROUGH;
2155bf215546Sopenharmony_ci   case TYPE_FLOAT:
2156bf215546Sopenharmony_ci      params[0] = llround(((GLfloat *) p)[0]);
2157bf215546Sopenharmony_ci      break;
2158bf215546Sopenharmony_ci
2159bf215546Sopenharmony_ci   case TYPE_FLOATN_4:
2160bf215546Sopenharmony_ci      params[3] = FLOAT_TO_INT(((GLfloat *) p)[3]);
2161bf215546Sopenharmony_ci      FALLTHROUGH;
2162bf215546Sopenharmony_ci   case TYPE_FLOATN_3:
2163bf215546Sopenharmony_ci      params[2] = FLOAT_TO_INT(((GLfloat *) p)[2]);
2164bf215546Sopenharmony_ci      FALLTHROUGH;
2165bf215546Sopenharmony_ci   case TYPE_FLOATN_2:
2166bf215546Sopenharmony_ci      params[1] = FLOAT_TO_INT(((GLfloat *) p)[1]);
2167bf215546Sopenharmony_ci      FALLTHROUGH;
2168bf215546Sopenharmony_ci   case TYPE_FLOATN:
2169bf215546Sopenharmony_ci      params[0] = FLOAT_TO_INT(((GLfloat *) p)[0]);
2170bf215546Sopenharmony_ci      break;
2171bf215546Sopenharmony_ci
2172bf215546Sopenharmony_ci   case TYPE_DOUBLEN_2:
2173bf215546Sopenharmony_ci      params[1] = FLOAT_TO_INT(((GLdouble *) p)[1]);
2174bf215546Sopenharmony_ci      FALLTHROUGH;
2175bf215546Sopenharmony_ci   case TYPE_DOUBLEN:
2176bf215546Sopenharmony_ci      params[0] = FLOAT_TO_INT(((GLdouble *) p)[0]);
2177bf215546Sopenharmony_ci      break;
2178bf215546Sopenharmony_ci
2179bf215546Sopenharmony_ci   case TYPE_INT_4:
2180bf215546Sopenharmony_ci      params[3] = ((GLint *) p)[3];
2181bf215546Sopenharmony_ci      FALLTHROUGH;
2182bf215546Sopenharmony_ci   case TYPE_INT_3:
2183bf215546Sopenharmony_ci      params[2] = ((GLint *) p)[2];
2184bf215546Sopenharmony_ci      FALLTHROUGH;
2185bf215546Sopenharmony_ci   case TYPE_INT_2:
2186bf215546Sopenharmony_ci   case TYPE_ENUM_2:
2187bf215546Sopenharmony_ci      params[1] = ((GLint *) p)[1];
2188bf215546Sopenharmony_ci      FALLTHROUGH;
2189bf215546Sopenharmony_ci   case TYPE_INT:
2190bf215546Sopenharmony_ci   case TYPE_ENUM:
2191bf215546Sopenharmony_ci      params[0] = ((GLint *) p)[0];
2192bf215546Sopenharmony_ci      break;
2193bf215546Sopenharmony_ci
2194bf215546Sopenharmony_ci   case TYPE_ENUM16:
2195bf215546Sopenharmony_ci      params[0] = ((GLenum16 *) p)[0];
2196bf215546Sopenharmony_ci      break;
2197bf215546Sopenharmony_ci
2198bf215546Sopenharmony_ci   case TYPE_INT_N:
2199bf215546Sopenharmony_ci      for (i = 0; i < v.value_int_n.n; i++)
2200bf215546Sopenharmony_ci         params[i] = v.value_int_n.ints[i];
2201bf215546Sopenharmony_ci      break;
2202bf215546Sopenharmony_ci
2203bf215546Sopenharmony_ci   case TYPE_UINT_4:
2204bf215546Sopenharmony_ci      params[3] = ((GLuint *) p)[3];
2205bf215546Sopenharmony_ci      FALLTHROUGH;
2206bf215546Sopenharmony_ci   case TYPE_UINT_3:
2207bf215546Sopenharmony_ci      params[2] = ((GLuint *) p)[2];
2208bf215546Sopenharmony_ci      FALLTHROUGH;
2209bf215546Sopenharmony_ci   case TYPE_UINT_2:
2210bf215546Sopenharmony_ci      params[1] = ((GLuint *) p)[1];
2211bf215546Sopenharmony_ci      FALLTHROUGH;
2212bf215546Sopenharmony_ci   case TYPE_UINT:
2213bf215546Sopenharmony_ci      params[0] = ((GLuint *) p)[0];
2214bf215546Sopenharmony_ci      break;
2215bf215546Sopenharmony_ci
2216bf215546Sopenharmony_ci   case TYPE_INT64:
2217bf215546Sopenharmony_ci      params[0] = ((GLint64 *) p)[0];
2218bf215546Sopenharmony_ci      break;
2219bf215546Sopenharmony_ci
2220bf215546Sopenharmony_ci   case TYPE_BOOLEAN:
2221bf215546Sopenharmony_ci      params[0] = ((GLboolean*) p)[0];
2222bf215546Sopenharmony_ci      break;
2223bf215546Sopenharmony_ci
2224bf215546Sopenharmony_ci   case TYPE_MATRIX:
2225bf215546Sopenharmony_ci      m = *(GLmatrix **) p;
2226bf215546Sopenharmony_ci      for (i = 0; i < 16; i++)
2227bf215546Sopenharmony_ci         params[i] = FLOAT_TO_INT64(m->m[i]);
2228bf215546Sopenharmony_ci      break;
2229bf215546Sopenharmony_ci
2230bf215546Sopenharmony_ci   case TYPE_MATRIX_T:
2231bf215546Sopenharmony_ci      m = *(GLmatrix **) p;
2232bf215546Sopenharmony_ci      for (i = 0; i < 16; i++)
2233bf215546Sopenharmony_ci         params[i] = FLOAT_TO_INT64(m->m[transpose[i]]);
2234bf215546Sopenharmony_ci      break;
2235bf215546Sopenharmony_ci
2236bf215546Sopenharmony_ci   case TYPE_BIT_0:
2237bf215546Sopenharmony_ci   case TYPE_BIT_1:
2238bf215546Sopenharmony_ci   case TYPE_BIT_2:
2239bf215546Sopenharmony_ci   case TYPE_BIT_3:
2240bf215546Sopenharmony_ci   case TYPE_BIT_4:
2241bf215546Sopenharmony_ci   case TYPE_BIT_5:
2242bf215546Sopenharmony_ci   case TYPE_BIT_6:
2243bf215546Sopenharmony_ci   case TYPE_BIT_7:
2244bf215546Sopenharmony_ci      shift = d->type - TYPE_BIT_0;
2245bf215546Sopenharmony_ci      params[0] = (*(GLbitfield *) p >> shift) & 1;
2246bf215546Sopenharmony_ci      break;
2247bf215546Sopenharmony_ci   }
2248bf215546Sopenharmony_ci}
2249bf215546Sopenharmony_ci
2250bf215546Sopenharmony_civoid GLAPIENTRY
2251bf215546Sopenharmony_ci_mesa_GetDoublev(GLenum pname, GLdouble *params)
2252bf215546Sopenharmony_ci{
2253bf215546Sopenharmony_ci   const struct value_desc *d;
2254bf215546Sopenharmony_ci   union value v;
2255bf215546Sopenharmony_ci   GLmatrix *m;
2256bf215546Sopenharmony_ci   int shift, i;
2257bf215546Sopenharmony_ci   void *p;
2258bf215546Sopenharmony_ci
2259bf215546Sopenharmony_ci   d = find_value("glGetDoublev", pname, &p, &v);
2260bf215546Sopenharmony_ci   switch (d->type) {
2261bf215546Sopenharmony_ci   case TYPE_INVALID:
2262bf215546Sopenharmony_ci      break;
2263bf215546Sopenharmony_ci   case TYPE_CONST:
2264bf215546Sopenharmony_ci      params[0] = d->offset;
2265bf215546Sopenharmony_ci      break;
2266bf215546Sopenharmony_ci
2267bf215546Sopenharmony_ci   case TYPE_FLOAT_8:
2268bf215546Sopenharmony_ci      params[7] = ((GLfloat *) p)[7];
2269bf215546Sopenharmony_ci      params[6] = ((GLfloat *) p)[6];
2270bf215546Sopenharmony_ci      params[5] = ((GLfloat *) p)[5];
2271bf215546Sopenharmony_ci      params[4] = ((GLfloat *) p)[4];
2272bf215546Sopenharmony_ci      FALLTHROUGH;
2273bf215546Sopenharmony_ci   case TYPE_FLOAT_4:
2274bf215546Sopenharmony_ci   case TYPE_FLOATN_4:
2275bf215546Sopenharmony_ci      params[3] = ((GLfloat *) p)[3];
2276bf215546Sopenharmony_ci      FALLTHROUGH;
2277bf215546Sopenharmony_ci   case TYPE_FLOAT_3:
2278bf215546Sopenharmony_ci   case TYPE_FLOATN_3:
2279bf215546Sopenharmony_ci      params[2] = ((GLfloat *) p)[2];
2280bf215546Sopenharmony_ci      FALLTHROUGH;
2281bf215546Sopenharmony_ci   case TYPE_FLOAT_2:
2282bf215546Sopenharmony_ci   case TYPE_FLOATN_2:
2283bf215546Sopenharmony_ci      params[1] = ((GLfloat *) p)[1];
2284bf215546Sopenharmony_ci      FALLTHROUGH;
2285bf215546Sopenharmony_ci   case TYPE_FLOAT:
2286bf215546Sopenharmony_ci   case TYPE_FLOATN:
2287bf215546Sopenharmony_ci      params[0] = ((GLfloat *) p)[0];
2288bf215546Sopenharmony_ci      break;
2289bf215546Sopenharmony_ci
2290bf215546Sopenharmony_ci   case TYPE_DOUBLEN_2:
2291bf215546Sopenharmony_ci      params[1] = ((GLdouble *) p)[1];
2292bf215546Sopenharmony_ci      FALLTHROUGH;
2293bf215546Sopenharmony_ci   case TYPE_DOUBLEN:
2294bf215546Sopenharmony_ci      params[0] = ((GLdouble *) p)[0];
2295bf215546Sopenharmony_ci      break;
2296bf215546Sopenharmony_ci
2297bf215546Sopenharmony_ci   case TYPE_INT_4:
2298bf215546Sopenharmony_ci      params[3] = ((GLint *) p)[3];
2299bf215546Sopenharmony_ci      FALLTHROUGH;
2300bf215546Sopenharmony_ci   case TYPE_INT_3:
2301bf215546Sopenharmony_ci      params[2] = ((GLint *) p)[2];
2302bf215546Sopenharmony_ci      FALLTHROUGH;
2303bf215546Sopenharmony_ci   case TYPE_INT_2:
2304bf215546Sopenharmony_ci   case TYPE_ENUM_2:
2305bf215546Sopenharmony_ci      params[1] = ((GLint *) p)[1];
2306bf215546Sopenharmony_ci      FALLTHROUGH;
2307bf215546Sopenharmony_ci   case TYPE_INT:
2308bf215546Sopenharmony_ci   case TYPE_ENUM:
2309bf215546Sopenharmony_ci      params[0] = ((GLint *) p)[0];
2310bf215546Sopenharmony_ci      break;
2311bf215546Sopenharmony_ci
2312bf215546Sopenharmony_ci   case TYPE_ENUM16:
2313bf215546Sopenharmony_ci      params[0] = ((GLenum16 *) p)[0];
2314bf215546Sopenharmony_ci      break;
2315bf215546Sopenharmony_ci
2316bf215546Sopenharmony_ci   case TYPE_INT_N:
2317bf215546Sopenharmony_ci      for (i = 0; i < v.value_int_n.n; i++)
2318bf215546Sopenharmony_ci         params[i] = v.value_int_n.ints[i];
2319bf215546Sopenharmony_ci      break;
2320bf215546Sopenharmony_ci
2321bf215546Sopenharmony_ci   case TYPE_UINT_4:
2322bf215546Sopenharmony_ci      params[3] = ((GLuint *) p)[3];
2323bf215546Sopenharmony_ci      FALLTHROUGH;
2324bf215546Sopenharmony_ci   case TYPE_UINT_3:
2325bf215546Sopenharmony_ci      params[2] = ((GLuint *) p)[2];
2326bf215546Sopenharmony_ci      FALLTHROUGH;
2327bf215546Sopenharmony_ci   case TYPE_UINT_2:
2328bf215546Sopenharmony_ci      params[1] = ((GLuint *) p)[1];
2329bf215546Sopenharmony_ci      FALLTHROUGH;
2330bf215546Sopenharmony_ci   case TYPE_UINT:
2331bf215546Sopenharmony_ci      params[0] = ((GLuint *) p)[0];
2332bf215546Sopenharmony_ci      break;
2333bf215546Sopenharmony_ci
2334bf215546Sopenharmony_ci   case TYPE_INT64:
2335bf215546Sopenharmony_ci      params[0] = (GLdouble) (((GLint64 *) p)[0]);
2336bf215546Sopenharmony_ci      break;
2337bf215546Sopenharmony_ci
2338bf215546Sopenharmony_ci   case TYPE_BOOLEAN:
2339bf215546Sopenharmony_ci      params[0] = *(GLboolean*) p;
2340bf215546Sopenharmony_ci      break;
2341bf215546Sopenharmony_ci
2342bf215546Sopenharmony_ci   case TYPE_UBYTE:
2343bf215546Sopenharmony_ci      params[0] = ((GLubyte *) p)[0];
2344bf215546Sopenharmony_ci      break;
2345bf215546Sopenharmony_ci
2346bf215546Sopenharmony_ci   case TYPE_SHORT:
2347bf215546Sopenharmony_ci      params[0] = ((GLshort *) p)[0];
2348bf215546Sopenharmony_ci      break;
2349bf215546Sopenharmony_ci
2350bf215546Sopenharmony_ci   case TYPE_MATRIX:
2351bf215546Sopenharmony_ci      m = *(GLmatrix **) p;
2352bf215546Sopenharmony_ci      for (i = 0; i < 16; i++)
2353bf215546Sopenharmony_ci         params[i] = m->m[i];
2354bf215546Sopenharmony_ci      break;
2355bf215546Sopenharmony_ci
2356bf215546Sopenharmony_ci   case TYPE_MATRIX_T:
2357bf215546Sopenharmony_ci      m = *(GLmatrix **) p;
2358bf215546Sopenharmony_ci      for (i = 0; i < 16; i++)
2359bf215546Sopenharmony_ci         params[i] = m->m[transpose[i]];
2360bf215546Sopenharmony_ci      break;
2361bf215546Sopenharmony_ci
2362bf215546Sopenharmony_ci   case TYPE_BIT_0:
2363bf215546Sopenharmony_ci   case TYPE_BIT_1:
2364bf215546Sopenharmony_ci   case TYPE_BIT_2:
2365bf215546Sopenharmony_ci   case TYPE_BIT_3:
2366bf215546Sopenharmony_ci   case TYPE_BIT_4:
2367bf215546Sopenharmony_ci   case TYPE_BIT_5:
2368bf215546Sopenharmony_ci   case TYPE_BIT_6:
2369bf215546Sopenharmony_ci   case TYPE_BIT_7:
2370bf215546Sopenharmony_ci      shift = d->type - TYPE_BIT_0;
2371bf215546Sopenharmony_ci      params[0] = (*(GLbitfield *) p >> shift) & 1;
2372bf215546Sopenharmony_ci      break;
2373bf215546Sopenharmony_ci   }
2374bf215546Sopenharmony_ci}
2375bf215546Sopenharmony_ci
2376bf215546Sopenharmony_civoid GLAPIENTRY
2377bf215546Sopenharmony_ci_mesa_GetUnsignedBytevEXT(GLenum pname, GLubyte *data)
2378bf215546Sopenharmony_ci{
2379bf215546Sopenharmony_ci   const struct value_desc *d;
2380bf215546Sopenharmony_ci   union value v;
2381bf215546Sopenharmony_ci   int shift;
2382bf215546Sopenharmony_ci   void *p = NULL;
2383bf215546Sopenharmony_ci   GLsizei size;
2384bf215546Sopenharmony_ci   const char *func = "glGetUnsignedBytevEXT";
2385bf215546Sopenharmony_ci
2386bf215546Sopenharmony_ci   GET_CURRENT_CONTEXT(ctx);
2387bf215546Sopenharmony_ci
2388bf215546Sopenharmony_ci   if (!ctx->Extensions.EXT_memory_object) {
2389bf215546Sopenharmony_ci      _mesa_error(ctx, GL_INVALID_OPERATION, "%s(unsupported)", func);
2390bf215546Sopenharmony_ci      return;
2391bf215546Sopenharmony_ci   }
2392bf215546Sopenharmony_ci
2393bf215546Sopenharmony_ci   d = find_value(func, pname, &p, &v);
2394bf215546Sopenharmony_ci   size = get_value_size(d->type, &v);
2395bf215546Sopenharmony_ci
2396bf215546Sopenharmony_ci   switch (d->type) {
2397bf215546Sopenharmony_ci   case TYPE_BIT_0:
2398bf215546Sopenharmony_ci   case TYPE_BIT_1:
2399bf215546Sopenharmony_ci   case TYPE_BIT_2:
2400bf215546Sopenharmony_ci   case TYPE_BIT_3:
2401bf215546Sopenharmony_ci   case TYPE_BIT_4:
2402bf215546Sopenharmony_ci   case TYPE_BIT_5:
2403bf215546Sopenharmony_ci   case TYPE_BIT_6:
2404bf215546Sopenharmony_ci   case TYPE_BIT_7:
2405bf215546Sopenharmony_ci      shift = d->type - TYPE_BIT_0;
2406bf215546Sopenharmony_ci      data[0] = (*(GLbitfield *) p >> shift) & 1;
2407bf215546Sopenharmony_ci      break;
2408bf215546Sopenharmony_ci   case TYPE_CONST:
2409bf215546Sopenharmony_ci      memcpy(data, &d->offset, size);
2410bf215546Sopenharmony_ci      break;
2411bf215546Sopenharmony_ci   case TYPE_INT_N:
2412bf215546Sopenharmony_ci      memcpy(data, &v.value_int_n.ints, size);
2413bf215546Sopenharmony_ci      break;
2414bf215546Sopenharmony_ci   case TYPE_UINT:
2415bf215546Sopenharmony_ci   case TYPE_INT:
2416bf215546Sopenharmony_ci   case TYPE_INT_2:
2417bf215546Sopenharmony_ci   case TYPE_UINT_2:
2418bf215546Sopenharmony_ci   case TYPE_INT_3:
2419bf215546Sopenharmony_ci   case TYPE_UINT_3:
2420bf215546Sopenharmony_ci   case TYPE_INT_4:
2421bf215546Sopenharmony_ci   case TYPE_UINT_4:
2422bf215546Sopenharmony_ci   case TYPE_INT64:
2423bf215546Sopenharmony_ci   case TYPE_ENUM:
2424bf215546Sopenharmony_ci   case TYPE_ENUM_2:
2425bf215546Sopenharmony_ci   case TYPE_BOOLEAN:
2426bf215546Sopenharmony_ci   case TYPE_UBYTE:
2427bf215546Sopenharmony_ci   case TYPE_SHORT:
2428bf215546Sopenharmony_ci   case TYPE_FLOAT:
2429bf215546Sopenharmony_ci   case TYPE_FLOATN:
2430bf215546Sopenharmony_ci   case TYPE_FLOAT_2:
2431bf215546Sopenharmony_ci   case TYPE_FLOATN_2:
2432bf215546Sopenharmony_ci   case TYPE_FLOAT_3:
2433bf215546Sopenharmony_ci   case TYPE_FLOATN_3:
2434bf215546Sopenharmony_ci   case TYPE_FLOAT_4:
2435bf215546Sopenharmony_ci   case TYPE_FLOATN_4:
2436bf215546Sopenharmony_ci   case TYPE_FLOAT_8:
2437bf215546Sopenharmony_ci   case TYPE_DOUBLEN:
2438bf215546Sopenharmony_ci   case TYPE_DOUBLEN_2:
2439bf215546Sopenharmony_ci   case TYPE_MATRIX:
2440bf215546Sopenharmony_ci   case TYPE_MATRIX_T:
2441bf215546Sopenharmony_ci      memcpy(data, p, size);
2442bf215546Sopenharmony_ci      break;
2443bf215546Sopenharmony_ci   case TYPE_ENUM16: {
2444bf215546Sopenharmony_ci      GLenum e = *(GLenum16 *)p;
2445bf215546Sopenharmony_ci      memcpy(data, &e, sizeof(e));
2446bf215546Sopenharmony_ci      break;
2447bf215546Sopenharmony_ci   }
2448bf215546Sopenharmony_ci   default:
2449bf215546Sopenharmony_ci      break; /* nothing - GL error was recorded */
2450bf215546Sopenharmony_ci   }
2451bf215546Sopenharmony_ci}
2452bf215546Sopenharmony_ci
2453bf215546Sopenharmony_ci/**
2454bf215546Sopenharmony_ci * Convert a GL texture binding enum such as GL_TEXTURE_BINDING_2D
2455bf215546Sopenharmony_ci * into the corresponding Mesa texture target index.
2456bf215546Sopenharmony_ci * \return TEXTURE_x_INDEX or -1 if binding is invalid
2457bf215546Sopenharmony_ci */
2458bf215546Sopenharmony_cistatic int
2459bf215546Sopenharmony_citex_binding_to_index(const struct gl_context *ctx, GLenum binding)
2460bf215546Sopenharmony_ci{
2461bf215546Sopenharmony_ci   switch (binding) {
2462bf215546Sopenharmony_ci   case GL_TEXTURE_BINDING_1D:
2463bf215546Sopenharmony_ci      return _mesa_is_desktop_gl(ctx) ? TEXTURE_1D_INDEX : -1;
2464bf215546Sopenharmony_ci   case GL_TEXTURE_BINDING_2D:
2465bf215546Sopenharmony_ci      return TEXTURE_2D_INDEX;
2466bf215546Sopenharmony_ci   case GL_TEXTURE_BINDING_3D:
2467bf215546Sopenharmony_ci      return (ctx->API != API_OPENGLES &&
2468bf215546Sopenharmony_ci              !(ctx->API == API_OPENGLES2 && !ctx->Extensions.OES_texture_3D))
2469bf215546Sopenharmony_ci         ? TEXTURE_3D_INDEX : -1;
2470bf215546Sopenharmony_ci   case GL_TEXTURE_BINDING_CUBE_MAP:
2471bf215546Sopenharmony_ci      return TEXTURE_CUBE_INDEX;
2472bf215546Sopenharmony_ci   case GL_TEXTURE_BINDING_RECTANGLE:
2473bf215546Sopenharmony_ci      return _mesa_is_desktop_gl(ctx) && ctx->Extensions.NV_texture_rectangle
2474bf215546Sopenharmony_ci         ? TEXTURE_RECT_INDEX : -1;
2475bf215546Sopenharmony_ci   case GL_TEXTURE_BINDING_1D_ARRAY:
2476bf215546Sopenharmony_ci      return _mesa_is_desktop_gl(ctx) && ctx->Extensions.EXT_texture_array
2477bf215546Sopenharmony_ci         ? TEXTURE_1D_ARRAY_INDEX : -1;
2478bf215546Sopenharmony_ci   case GL_TEXTURE_BINDING_2D_ARRAY:
2479bf215546Sopenharmony_ci      return (_mesa_is_desktop_gl(ctx) && ctx->Extensions.EXT_texture_array)
2480bf215546Sopenharmony_ci         || _mesa_is_gles3(ctx)
2481bf215546Sopenharmony_ci         ? TEXTURE_2D_ARRAY_INDEX : -1;
2482bf215546Sopenharmony_ci   case GL_TEXTURE_BINDING_BUFFER:
2483bf215546Sopenharmony_ci      return (_mesa_has_ARB_texture_buffer_object(ctx) ||
2484bf215546Sopenharmony_ci              _mesa_has_OES_texture_buffer(ctx)) ?
2485bf215546Sopenharmony_ci             TEXTURE_BUFFER_INDEX : -1;
2486bf215546Sopenharmony_ci   case GL_TEXTURE_BINDING_CUBE_MAP_ARRAY:
2487bf215546Sopenharmony_ci      return _mesa_has_texture_cube_map_array(ctx)
2488bf215546Sopenharmony_ci         ? TEXTURE_CUBE_ARRAY_INDEX : -1;
2489bf215546Sopenharmony_ci   case GL_TEXTURE_BINDING_2D_MULTISAMPLE:
2490bf215546Sopenharmony_ci      return _mesa_is_desktop_gl(ctx) && ctx->Extensions.ARB_texture_multisample
2491bf215546Sopenharmony_ci         ? TEXTURE_2D_MULTISAMPLE_INDEX : -1;
2492bf215546Sopenharmony_ci   case GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY:
2493bf215546Sopenharmony_ci      return _mesa_is_desktop_gl(ctx) && ctx->Extensions.ARB_texture_multisample
2494bf215546Sopenharmony_ci         ? TEXTURE_2D_MULTISAMPLE_ARRAY_INDEX : -1;
2495bf215546Sopenharmony_ci   default:
2496bf215546Sopenharmony_ci      return -1;
2497bf215546Sopenharmony_ci   }
2498bf215546Sopenharmony_ci}
2499bf215546Sopenharmony_ci
2500bf215546Sopenharmony_cistatic enum value_type
2501bf215546Sopenharmony_cifind_value_indexed(const char *func, GLenum pname, GLuint index, union value *v)
2502bf215546Sopenharmony_ci{
2503bf215546Sopenharmony_ci   GET_CURRENT_CONTEXT(ctx);
2504bf215546Sopenharmony_ci   struct gl_buffer_object *buf;
2505bf215546Sopenharmony_ci
2506bf215546Sopenharmony_ci   switch (pname) {
2507bf215546Sopenharmony_ci
2508bf215546Sopenharmony_ci   case GL_BLEND:
2509bf215546Sopenharmony_ci      if (index >= ctx->Const.MaxDrawBuffers)
2510bf215546Sopenharmony_ci         goto invalid_value;
2511bf215546Sopenharmony_ci      if (!ctx->Extensions.EXT_draw_buffers2)
2512bf215546Sopenharmony_ci         goto invalid_enum;
2513bf215546Sopenharmony_ci      v->value_int = (ctx->Color.BlendEnabled >> index) & 1;
2514bf215546Sopenharmony_ci      return TYPE_INT;
2515bf215546Sopenharmony_ci
2516bf215546Sopenharmony_ci   case GL_BLEND_SRC:
2517bf215546Sopenharmony_ci      FALLTHROUGH;
2518bf215546Sopenharmony_ci   case GL_BLEND_SRC_RGB:
2519bf215546Sopenharmony_ci      if (index >= ctx->Const.MaxDrawBuffers)
2520bf215546Sopenharmony_ci         goto invalid_value;
2521bf215546Sopenharmony_ci      if (!ctx->Extensions.ARB_draw_buffers_blend)
2522bf215546Sopenharmony_ci         goto invalid_enum;
2523bf215546Sopenharmony_ci      v->value_int = ctx->Color.Blend[index].SrcRGB;
2524bf215546Sopenharmony_ci      return TYPE_INT;
2525bf215546Sopenharmony_ci   case GL_BLEND_SRC_ALPHA:
2526bf215546Sopenharmony_ci      if (index >= ctx->Const.MaxDrawBuffers)
2527bf215546Sopenharmony_ci         goto invalid_value;
2528bf215546Sopenharmony_ci      if (!ctx->Extensions.ARB_draw_buffers_blend)
2529bf215546Sopenharmony_ci         goto invalid_enum;
2530bf215546Sopenharmony_ci      v->value_int = ctx->Color.Blend[index].SrcA;
2531bf215546Sopenharmony_ci      return TYPE_INT;
2532bf215546Sopenharmony_ci   case GL_BLEND_DST:
2533bf215546Sopenharmony_ci      FALLTHROUGH;
2534bf215546Sopenharmony_ci   case GL_BLEND_DST_RGB:
2535bf215546Sopenharmony_ci      if (index >= ctx->Const.MaxDrawBuffers)
2536bf215546Sopenharmony_ci         goto invalid_value;
2537bf215546Sopenharmony_ci      if (!ctx->Extensions.ARB_draw_buffers_blend)
2538bf215546Sopenharmony_ci         goto invalid_enum;
2539bf215546Sopenharmony_ci      v->value_int = ctx->Color.Blend[index].DstRGB;
2540bf215546Sopenharmony_ci      return TYPE_INT;
2541bf215546Sopenharmony_ci   case GL_BLEND_DST_ALPHA:
2542bf215546Sopenharmony_ci      if (index >= ctx->Const.MaxDrawBuffers)
2543bf215546Sopenharmony_ci         goto invalid_value;
2544bf215546Sopenharmony_ci      if (!ctx->Extensions.ARB_draw_buffers_blend)
2545bf215546Sopenharmony_ci         goto invalid_enum;
2546bf215546Sopenharmony_ci      v->value_int = ctx->Color.Blend[index].DstA;
2547bf215546Sopenharmony_ci      return TYPE_INT;
2548bf215546Sopenharmony_ci   case GL_BLEND_EQUATION_RGB:
2549bf215546Sopenharmony_ci      if (index >= ctx->Const.MaxDrawBuffers)
2550bf215546Sopenharmony_ci         goto invalid_value;
2551bf215546Sopenharmony_ci      if (!ctx->Extensions.ARB_draw_buffers_blend)
2552bf215546Sopenharmony_ci         goto invalid_enum;
2553bf215546Sopenharmony_ci      v->value_int = ctx->Color.Blend[index].EquationRGB;
2554bf215546Sopenharmony_ci      return TYPE_INT;
2555bf215546Sopenharmony_ci   case GL_BLEND_EQUATION_ALPHA:
2556bf215546Sopenharmony_ci      if (index >= ctx->Const.MaxDrawBuffers)
2557bf215546Sopenharmony_ci         goto invalid_value;
2558bf215546Sopenharmony_ci      if (!ctx->Extensions.ARB_draw_buffers_blend)
2559bf215546Sopenharmony_ci         goto invalid_enum;
2560bf215546Sopenharmony_ci      v->value_int = ctx->Color.Blend[index].EquationA;
2561bf215546Sopenharmony_ci      return TYPE_INT;
2562bf215546Sopenharmony_ci
2563bf215546Sopenharmony_ci   case GL_COLOR_WRITEMASK:
2564bf215546Sopenharmony_ci      if (index >= ctx->Const.MaxDrawBuffers)
2565bf215546Sopenharmony_ci         goto invalid_value;
2566bf215546Sopenharmony_ci      if (!ctx->Extensions.EXT_draw_buffers2)
2567bf215546Sopenharmony_ci         goto invalid_enum;
2568bf215546Sopenharmony_ci      v->value_int_4[0] = GET_COLORMASK_BIT(ctx->Color.ColorMask, index, 0);
2569bf215546Sopenharmony_ci      v->value_int_4[1] = GET_COLORMASK_BIT(ctx->Color.ColorMask, index, 1);
2570bf215546Sopenharmony_ci      v->value_int_4[2] = GET_COLORMASK_BIT(ctx->Color.ColorMask, index, 2);
2571bf215546Sopenharmony_ci      v->value_int_4[3] = GET_COLORMASK_BIT(ctx->Color.ColorMask, index, 3);
2572bf215546Sopenharmony_ci      return TYPE_INT_4;
2573bf215546Sopenharmony_ci
2574bf215546Sopenharmony_ci   case GL_SCISSOR_BOX:
2575bf215546Sopenharmony_ci      if (index >= ctx->Const.MaxViewports)
2576bf215546Sopenharmony_ci         goto invalid_value;
2577bf215546Sopenharmony_ci      v->value_int_4[0] = ctx->Scissor.ScissorArray[index].X;
2578bf215546Sopenharmony_ci      v->value_int_4[1] = ctx->Scissor.ScissorArray[index].Y;
2579bf215546Sopenharmony_ci      v->value_int_4[2] = ctx->Scissor.ScissorArray[index].Width;
2580bf215546Sopenharmony_ci      v->value_int_4[3] = ctx->Scissor.ScissorArray[index].Height;
2581bf215546Sopenharmony_ci      return TYPE_INT_4;
2582bf215546Sopenharmony_ci
2583bf215546Sopenharmony_ci   case GL_WINDOW_RECTANGLE_EXT:
2584bf215546Sopenharmony_ci      if (!ctx->Extensions.EXT_window_rectangles)
2585bf215546Sopenharmony_ci         goto invalid_enum;
2586bf215546Sopenharmony_ci      if (index >= ctx->Const.MaxWindowRectangles)
2587bf215546Sopenharmony_ci         goto invalid_value;
2588bf215546Sopenharmony_ci      v->value_int_4[0] = ctx->Scissor.WindowRects[index].X;
2589bf215546Sopenharmony_ci      v->value_int_4[1] = ctx->Scissor.WindowRects[index].Y;
2590bf215546Sopenharmony_ci      v->value_int_4[2] = ctx->Scissor.WindowRects[index].Width;
2591bf215546Sopenharmony_ci      v->value_int_4[3] = ctx->Scissor.WindowRects[index].Height;
2592bf215546Sopenharmony_ci      return TYPE_INT_4;
2593bf215546Sopenharmony_ci
2594bf215546Sopenharmony_ci   case GL_VIEWPORT:
2595bf215546Sopenharmony_ci      if (index >= ctx->Const.MaxViewports)
2596bf215546Sopenharmony_ci         goto invalid_value;
2597bf215546Sopenharmony_ci      v->value_float_4[0] = ctx->ViewportArray[index].X;
2598bf215546Sopenharmony_ci      v->value_float_4[1] = ctx->ViewportArray[index].Y;
2599bf215546Sopenharmony_ci      v->value_float_4[2] = ctx->ViewportArray[index].Width;
2600bf215546Sopenharmony_ci      v->value_float_4[3] = ctx->ViewportArray[index].Height;
2601bf215546Sopenharmony_ci      return TYPE_FLOAT_4;
2602bf215546Sopenharmony_ci
2603bf215546Sopenharmony_ci   case GL_DEPTH_RANGE:
2604bf215546Sopenharmony_ci      if (index >= ctx->Const.MaxViewports)
2605bf215546Sopenharmony_ci         goto invalid_value;
2606bf215546Sopenharmony_ci      v->value_double_2[0] = ctx->ViewportArray[index].Near;
2607bf215546Sopenharmony_ci      v->value_double_2[1] = ctx->ViewportArray[index].Far;
2608bf215546Sopenharmony_ci      return TYPE_DOUBLEN_2;
2609bf215546Sopenharmony_ci
2610bf215546Sopenharmony_ci   case GL_TRANSFORM_FEEDBACK_BUFFER_START:
2611bf215546Sopenharmony_ci      if (index >= ctx->Const.MaxTransformFeedbackBuffers)
2612bf215546Sopenharmony_ci         goto invalid_value;
2613bf215546Sopenharmony_ci      if (!ctx->Extensions.EXT_transform_feedback)
2614bf215546Sopenharmony_ci         goto invalid_enum;
2615bf215546Sopenharmony_ci      v->value_int64 = ctx->TransformFeedback.CurrentObject->Offset[index];
2616bf215546Sopenharmony_ci      return TYPE_INT64;
2617bf215546Sopenharmony_ci
2618bf215546Sopenharmony_ci   case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE:
2619bf215546Sopenharmony_ci      if (index >= ctx->Const.MaxTransformFeedbackBuffers)
2620bf215546Sopenharmony_ci         goto invalid_value;
2621bf215546Sopenharmony_ci      if (!ctx->Extensions.EXT_transform_feedback)
2622bf215546Sopenharmony_ci         goto invalid_enum;
2623bf215546Sopenharmony_ci      v->value_int64
2624bf215546Sopenharmony_ci         = ctx->TransformFeedback.CurrentObject->RequestedSize[index];
2625bf215546Sopenharmony_ci      return TYPE_INT64;
2626bf215546Sopenharmony_ci
2627bf215546Sopenharmony_ci   case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING:
2628bf215546Sopenharmony_ci      if (index >= ctx->Const.MaxTransformFeedbackBuffers)
2629bf215546Sopenharmony_ci         goto invalid_value;
2630bf215546Sopenharmony_ci      if (!ctx->Extensions.EXT_transform_feedback)
2631bf215546Sopenharmony_ci         goto invalid_enum;
2632bf215546Sopenharmony_ci      v->value_int = ctx->TransformFeedback.CurrentObject->BufferNames[index];
2633bf215546Sopenharmony_ci      return TYPE_INT;
2634bf215546Sopenharmony_ci
2635bf215546Sopenharmony_ci   case GL_UNIFORM_BUFFER_BINDING:
2636bf215546Sopenharmony_ci      if (index >= ctx->Const.MaxUniformBufferBindings)
2637bf215546Sopenharmony_ci         goto invalid_value;
2638bf215546Sopenharmony_ci      if (!ctx->Extensions.ARB_uniform_buffer_object)
2639bf215546Sopenharmony_ci         goto invalid_enum;
2640bf215546Sopenharmony_ci      buf = ctx->UniformBufferBindings[index].BufferObject;
2641bf215546Sopenharmony_ci      v->value_int = buf ? buf->Name : 0;
2642bf215546Sopenharmony_ci      return TYPE_INT;
2643bf215546Sopenharmony_ci
2644bf215546Sopenharmony_ci   case GL_UNIFORM_BUFFER_START:
2645bf215546Sopenharmony_ci      if (index >= ctx->Const.MaxUniformBufferBindings)
2646bf215546Sopenharmony_ci         goto invalid_value;
2647bf215546Sopenharmony_ci      if (!ctx->Extensions.ARB_uniform_buffer_object)
2648bf215546Sopenharmony_ci         goto invalid_enum;
2649bf215546Sopenharmony_ci      v->value_int = ctx->UniformBufferBindings[index].Offset < 0 ? 0 :
2650bf215546Sopenharmony_ci                     ctx->UniformBufferBindings[index].Offset;
2651bf215546Sopenharmony_ci      return TYPE_INT;
2652bf215546Sopenharmony_ci
2653bf215546Sopenharmony_ci   case GL_UNIFORM_BUFFER_SIZE:
2654bf215546Sopenharmony_ci      if (index >= ctx->Const.MaxUniformBufferBindings)
2655bf215546Sopenharmony_ci         goto invalid_value;
2656bf215546Sopenharmony_ci      if (!ctx->Extensions.ARB_uniform_buffer_object)
2657bf215546Sopenharmony_ci         goto invalid_enum;
2658bf215546Sopenharmony_ci      v->value_int = ctx->UniformBufferBindings[index].Size < 0 ? 0 :
2659bf215546Sopenharmony_ci                     ctx->UniformBufferBindings[index].Size;
2660bf215546Sopenharmony_ci      return TYPE_INT;
2661bf215546Sopenharmony_ci
2662bf215546Sopenharmony_ci   /* ARB_shader_storage_buffer_object */
2663bf215546Sopenharmony_ci   case GL_SHADER_STORAGE_BUFFER_BINDING:
2664bf215546Sopenharmony_ci      if (!ctx->Extensions.ARB_shader_storage_buffer_object && !_mesa_is_gles31(ctx))
2665bf215546Sopenharmony_ci         goto invalid_enum;
2666bf215546Sopenharmony_ci      if (index >= ctx->Const.MaxShaderStorageBufferBindings)
2667bf215546Sopenharmony_ci         goto invalid_value;
2668bf215546Sopenharmony_ci      buf = ctx->ShaderStorageBufferBindings[index].BufferObject;
2669bf215546Sopenharmony_ci      v->value_int = buf ? buf->Name : 0;
2670bf215546Sopenharmony_ci      return TYPE_INT;
2671bf215546Sopenharmony_ci
2672bf215546Sopenharmony_ci   case GL_SHADER_STORAGE_BUFFER_START:
2673bf215546Sopenharmony_ci      if (!ctx->Extensions.ARB_shader_storage_buffer_object && !_mesa_is_gles31(ctx))
2674bf215546Sopenharmony_ci         goto invalid_enum;
2675bf215546Sopenharmony_ci      if (index >= ctx->Const.MaxShaderStorageBufferBindings)
2676bf215546Sopenharmony_ci         goto invalid_value;
2677bf215546Sopenharmony_ci      v->value_int = ctx->ShaderStorageBufferBindings[index].Offset < 0 ? 0 :
2678bf215546Sopenharmony_ci                     ctx->ShaderStorageBufferBindings[index].Offset;
2679bf215546Sopenharmony_ci      return TYPE_INT;
2680bf215546Sopenharmony_ci
2681bf215546Sopenharmony_ci   case GL_SHADER_STORAGE_BUFFER_SIZE:
2682bf215546Sopenharmony_ci      if (!ctx->Extensions.ARB_shader_storage_buffer_object && !_mesa_is_gles31(ctx))
2683bf215546Sopenharmony_ci         goto invalid_enum;
2684bf215546Sopenharmony_ci      if (index >= ctx->Const.MaxShaderStorageBufferBindings)
2685bf215546Sopenharmony_ci         goto invalid_value;
2686bf215546Sopenharmony_ci      v->value_int = ctx->ShaderStorageBufferBindings[index].Size < 0 ? 0 :
2687bf215546Sopenharmony_ci                     ctx->ShaderStorageBufferBindings[index].Size;
2688bf215546Sopenharmony_ci      return TYPE_INT;
2689bf215546Sopenharmony_ci
2690bf215546Sopenharmony_ci   /* ARB_texture_multisample / GL3.2 */
2691bf215546Sopenharmony_ci   case GL_SAMPLE_MASK_VALUE:
2692bf215546Sopenharmony_ci      if (index != 0)
2693bf215546Sopenharmony_ci         goto invalid_value;
2694bf215546Sopenharmony_ci      if (!ctx->Extensions.ARB_texture_multisample)
2695bf215546Sopenharmony_ci         goto invalid_enum;
2696bf215546Sopenharmony_ci      v->value_int = ctx->Multisample.SampleMaskValue;
2697bf215546Sopenharmony_ci      return TYPE_INT;
2698bf215546Sopenharmony_ci
2699bf215546Sopenharmony_ci   case GL_ATOMIC_COUNTER_BUFFER_BINDING:
2700bf215546Sopenharmony_ci      if (!ctx->Extensions.ARB_shader_atomic_counters && !_mesa_is_gles31(ctx))
2701bf215546Sopenharmony_ci         goto invalid_enum;
2702bf215546Sopenharmony_ci      if (index >= ctx->Const.MaxAtomicBufferBindings)
2703bf215546Sopenharmony_ci         goto invalid_value;
2704bf215546Sopenharmony_ci      buf = ctx->AtomicBufferBindings[index].BufferObject;
2705bf215546Sopenharmony_ci      v->value_int = buf ? buf->Name : 0;
2706bf215546Sopenharmony_ci      return TYPE_INT;
2707bf215546Sopenharmony_ci
2708bf215546Sopenharmony_ci   case GL_ATOMIC_COUNTER_BUFFER_START:
2709bf215546Sopenharmony_ci      if (!ctx->Extensions.ARB_shader_atomic_counters && !_mesa_is_gles31(ctx))
2710bf215546Sopenharmony_ci         goto invalid_enum;
2711bf215546Sopenharmony_ci      if (index >= ctx->Const.MaxAtomicBufferBindings)
2712bf215546Sopenharmony_ci         goto invalid_value;
2713bf215546Sopenharmony_ci      v->value_int64 = ctx->AtomicBufferBindings[index].Offset < 0 ? 0 :
2714bf215546Sopenharmony_ci                       ctx->AtomicBufferBindings[index].Offset;
2715bf215546Sopenharmony_ci      return TYPE_INT64;
2716bf215546Sopenharmony_ci
2717bf215546Sopenharmony_ci   case GL_ATOMIC_COUNTER_BUFFER_SIZE:
2718bf215546Sopenharmony_ci      if (!ctx->Extensions.ARB_shader_atomic_counters && !_mesa_is_gles31(ctx))
2719bf215546Sopenharmony_ci         goto invalid_enum;
2720bf215546Sopenharmony_ci      if (index >= ctx->Const.MaxAtomicBufferBindings)
2721bf215546Sopenharmony_ci         goto invalid_value;
2722bf215546Sopenharmony_ci      v->value_int64 = ctx->AtomicBufferBindings[index].Size < 0 ? 0 :
2723bf215546Sopenharmony_ci                       ctx->AtomicBufferBindings[index].Size;
2724bf215546Sopenharmony_ci      return TYPE_INT64;
2725bf215546Sopenharmony_ci
2726bf215546Sopenharmony_ci   case GL_VERTEX_BINDING_DIVISOR:
2727bf215546Sopenharmony_ci      if ((!_mesa_is_desktop_gl(ctx) || !ctx->Extensions.ARB_instanced_arrays) &&
2728bf215546Sopenharmony_ci          !_mesa_is_gles31(ctx))
2729bf215546Sopenharmony_ci          goto invalid_enum;
2730bf215546Sopenharmony_ci      if (index >= ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs)
2731bf215546Sopenharmony_ci          goto invalid_value;
2732bf215546Sopenharmony_ci      v->value_int = ctx->Array.VAO->BufferBinding[VERT_ATTRIB_GENERIC(index)].InstanceDivisor;
2733bf215546Sopenharmony_ci      return TYPE_INT;
2734bf215546Sopenharmony_ci
2735bf215546Sopenharmony_ci   case GL_VERTEX_BINDING_OFFSET:
2736bf215546Sopenharmony_ci      if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles31(ctx))
2737bf215546Sopenharmony_ci          goto invalid_enum;
2738bf215546Sopenharmony_ci      if (index >= ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs)
2739bf215546Sopenharmony_ci          goto invalid_value;
2740bf215546Sopenharmony_ci      v->value_int = ctx->Array.VAO->BufferBinding[VERT_ATTRIB_GENERIC(index)].Offset;
2741bf215546Sopenharmony_ci      return TYPE_INT;
2742bf215546Sopenharmony_ci
2743bf215546Sopenharmony_ci   case GL_VERTEX_BINDING_STRIDE:
2744bf215546Sopenharmony_ci      if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles31(ctx))
2745bf215546Sopenharmony_ci          goto invalid_enum;
2746bf215546Sopenharmony_ci      if (index >= ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs)
2747bf215546Sopenharmony_ci          goto invalid_value;
2748bf215546Sopenharmony_ci      v->value_int = ctx->Array.VAO->BufferBinding[VERT_ATTRIB_GENERIC(index)].Stride;
2749bf215546Sopenharmony_ci      return TYPE_INT;
2750bf215546Sopenharmony_ci
2751bf215546Sopenharmony_ci   case GL_VERTEX_BINDING_BUFFER:
2752bf215546Sopenharmony_ci      if (ctx->API == API_OPENGLES2 && ctx->Version < 31)
2753bf215546Sopenharmony_ci         goto invalid_enum;
2754bf215546Sopenharmony_ci      if (index >= ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs)
2755bf215546Sopenharmony_ci         goto invalid_value;
2756bf215546Sopenharmony_ci      buf = ctx->Array.VAO->BufferBinding[VERT_ATTRIB_GENERIC(index)].BufferObj;
2757bf215546Sopenharmony_ci      v->value_int = buf ? buf->Name : 0;
2758bf215546Sopenharmony_ci      return TYPE_INT;
2759bf215546Sopenharmony_ci
2760bf215546Sopenharmony_ci   /* ARB_shader_image_load_store */
2761bf215546Sopenharmony_ci   case GL_IMAGE_BINDING_NAME: {
2762bf215546Sopenharmony_ci      struct gl_texture_object *t;
2763bf215546Sopenharmony_ci
2764bf215546Sopenharmony_ci      if (!ctx->Extensions.ARB_shader_image_load_store && !_mesa_is_gles31(ctx))
2765bf215546Sopenharmony_ci         goto invalid_enum;
2766bf215546Sopenharmony_ci      if (index >= ctx->Const.MaxImageUnits)
2767bf215546Sopenharmony_ci         goto invalid_value;
2768bf215546Sopenharmony_ci
2769bf215546Sopenharmony_ci      t = ctx->ImageUnits[index].TexObj;
2770bf215546Sopenharmony_ci      v->value_int = (t ? t->Name : 0);
2771bf215546Sopenharmony_ci      return TYPE_INT;
2772bf215546Sopenharmony_ci   }
2773bf215546Sopenharmony_ci
2774bf215546Sopenharmony_ci   case GL_IMAGE_BINDING_LEVEL:
2775bf215546Sopenharmony_ci      if (!ctx->Extensions.ARB_shader_image_load_store && !_mesa_is_gles31(ctx))
2776bf215546Sopenharmony_ci         goto invalid_enum;
2777bf215546Sopenharmony_ci      if (index >= ctx->Const.MaxImageUnits)
2778bf215546Sopenharmony_ci         goto invalid_value;
2779bf215546Sopenharmony_ci
2780bf215546Sopenharmony_ci      v->value_int = ctx->ImageUnits[index].Level;
2781bf215546Sopenharmony_ci      return TYPE_INT;
2782bf215546Sopenharmony_ci
2783bf215546Sopenharmony_ci   case GL_IMAGE_BINDING_LAYERED:
2784bf215546Sopenharmony_ci      if (!ctx->Extensions.ARB_shader_image_load_store && !_mesa_is_gles31(ctx))
2785bf215546Sopenharmony_ci         goto invalid_enum;
2786bf215546Sopenharmony_ci      if (index >= ctx->Const.MaxImageUnits)
2787bf215546Sopenharmony_ci         goto invalid_value;
2788bf215546Sopenharmony_ci
2789bf215546Sopenharmony_ci      v->value_int = ctx->ImageUnits[index].Layered;
2790bf215546Sopenharmony_ci      return TYPE_INT;
2791bf215546Sopenharmony_ci
2792bf215546Sopenharmony_ci   case GL_IMAGE_BINDING_LAYER:
2793bf215546Sopenharmony_ci      if (!ctx->Extensions.ARB_shader_image_load_store && !_mesa_is_gles31(ctx))
2794bf215546Sopenharmony_ci         goto invalid_enum;
2795bf215546Sopenharmony_ci      if (index >= ctx->Const.MaxImageUnits)
2796bf215546Sopenharmony_ci         goto invalid_value;
2797bf215546Sopenharmony_ci
2798bf215546Sopenharmony_ci      v->value_int = ctx->ImageUnits[index].Layer;
2799bf215546Sopenharmony_ci      return TYPE_INT;
2800bf215546Sopenharmony_ci
2801bf215546Sopenharmony_ci   case GL_IMAGE_BINDING_ACCESS:
2802bf215546Sopenharmony_ci      if (!ctx->Extensions.ARB_shader_image_load_store && !_mesa_is_gles31(ctx))
2803bf215546Sopenharmony_ci         goto invalid_enum;
2804bf215546Sopenharmony_ci      if (index >= ctx->Const.MaxImageUnits)
2805bf215546Sopenharmony_ci         goto invalid_value;
2806bf215546Sopenharmony_ci
2807bf215546Sopenharmony_ci      v->value_int = ctx->ImageUnits[index].Access;
2808bf215546Sopenharmony_ci      return TYPE_INT;
2809bf215546Sopenharmony_ci
2810bf215546Sopenharmony_ci   case GL_IMAGE_BINDING_FORMAT:
2811bf215546Sopenharmony_ci      if (!ctx->Extensions.ARB_shader_image_load_store && !_mesa_is_gles31(ctx))
2812bf215546Sopenharmony_ci         goto invalid_enum;
2813bf215546Sopenharmony_ci      if (index >= ctx->Const.MaxImageUnits)
2814bf215546Sopenharmony_ci         goto invalid_value;
2815bf215546Sopenharmony_ci
2816bf215546Sopenharmony_ci      v->value_int = ctx->ImageUnits[index].Format;
2817bf215546Sopenharmony_ci      return TYPE_INT;
2818bf215546Sopenharmony_ci
2819bf215546Sopenharmony_ci   /* ARB_direct_state_access */
2820bf215546Sopenharmony_ci   case GL_TEXTURE_BINDING_1D:
2821bf215546Sopenharmony_ci   case GL_TEXTURE_BINDING_1D_ARRAY:
2822bf215546Sopenharmony_ci   case GL_TEXTURE_BINDING_2D:
2823bf215546Sopenharmony_ci   case GL_TEXTURE_BINDING_2D_ARRAY:
2824bf215546Sopenharmony_ci   case GL_TEXTURE_BINDING_2D_MULTISAMPLE:
2825bf215546Sopenharmony_ci   case GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY:
2826bf215546Sopenharmony_ci   case GL_TEXTURE_BINDING_3D:
2827bf215546Sopenharmony_ci   case GL_TEXTURE_BINDING_BUFFER:
2828bf215546Sopenharmony_ci   case GL_TEXTURE_BINDING_CUBE_MAP:
2829bf215546Sopenharmony_ci   case GL_TEXTURE_BINDING_CUBE_MAP_ARRAY:
2830bf215546Sopenharmony_ci   case GL_TEXTURE_BINDING_RECTANGLE: {
2831bf215546Sopenharmony_ci      int target;
2832bf215546Sopenharmony_ci
2833bf215546Sopenharmony_ci      target = tex_binding_to_index(ctx, pname);
2834bf215546Sopenharmony_ci      if (target < 0)
2835bf215546Sopenharmony_ci         goto invalid_enum;
2836bf215546Sopenharmony_ci      if (index >= _mesa_max_tex_unit(ctx))
2837bf215546Sopenharmony_ci         goto invalid_value;
2838bf215546Sopenharmony_ci
2839bf215546Sopenharmony_ci      v->value_int = ctx->Texture.Unit[index].CurrentTex[target]->Name;
2840bf215546Sopenharmony_ci      return TYPE_INT;
2841bf215546Sopenharmony_ci   }
2842bf215546Sopenharmony_ci
2843bf215546Sopenharmony_ci   case GL_SAMPLER_BINDING: {
2844bf215546Sopenharmony_ci      struct gl_sampler_object *samp;
2845bf215546Sopenharmony_ci
2846bf215546Sopenharmony_ci      if (!_mesa_is_desktop_gl(ctx) || ctx->Version < 33)
2847bf215546Sopenharmony_ci         goto invalid_enum;
2848bf215546Sopenharmony_ci      if (index >= _mesa_max_tex_unit(ctx))
2849bf215546Sopenharmony_ci         goto invalid_value;
2850bf215546Sopenharmony_ci
2851bf215546Sopenharmony_ci      samp = ctx->Texture.Unit[index].Sampler;
2852bf215546Sopenharmony_ci      v->value_int = samp ? samp->Name : 0;
2853bf215546Sopenharmony_ci      return TYPE_INT;
2854bf215546Sopenharmony_ci   }
2855bf215546Sopenharmony_ci
2856bf215546Sopenharmony_ci   case GL_MAX_COMPUTE_WORK_GROUP_COUNT:
2857bf215546Sopenharmony_ci      if (!_mesa_has_compute_shaders(ctx))
2858bf215546Sopenharmony_ci         goto invalid_enum;
2859bf215546Sopenharmony_ci      if (index >= 3)
2860bf215546Sopenharmony_ci         goto invalid_value;
2861bf215546Sopenharmony_ci      v->value_uint = ctx->Const.MaxComputeWorkGroupCount[index];
2862bf215546Sopenharmony_ci      return TYPE_UINT;
2863bf215546Sopenharmony_ci
2864bf215546Sopenharmony_ci   case GL_MAX_COMPUTE_WORK_GROUP_SIZE:
2865bf215546Sopenharmony_ci      if (!_mesa_has_compute_shaders(ctx))
2866bf215546Sopenharmony_ci         goto invalid_enum;
2867bf215546Sopenharmony_ci      if (index >= 3)
2868bf215546Sopenharmony_ci         goto invalid_value;
2869bf215546Sopenharmony_ci      v->value_int = ctx->Const.MaxComputeWorkGroupSize[index];
2870bf215546Sopenharmony_ci      return TYPE_INT;
2871bf215546Sopenharmony_ci
2872bf215546Sopenharmony_ci   /* ARB_compute_variable_group_size */
2873bf215546Sopenharmony_ci   case GL_MAX_COMPUTE_VARIABLE_GROUP_SIZE_ARB:
2874bf215546Sopenharmony_ci      if (!ctx->Extensions.ARB_compute_variable_group_size)
2875bf215546Sopenharmony_ci         goto invalid_enum;
2876bf215546Sopenharmony_ci      if (index >= 3)
2877bf215546Sopenharmony_ci         goto invalid_value;
2878bf215546Sopenharmony_ci      v->value_int = ctx->Const.MaxComputeVariableGroupSize[index];
2879bf215546Sopenharmony_ci      return TYPE_INT;
2880bf215546Sopenharmony_ci
2881bf215546Sopenharmony_ci   /* GL_EXT_external_objects */
2882bf215546Sopenharmony_ci   case GL_NUM_DEVICE_UUIDS_EXT:
2883bf215546Sopenharmony_ci      v->value_int = 1;
2884bf215546Sopenharmony_ci      return TYPE_INT;
2885bf215546Sopenharmony_ci   case GL_DRIVER_UUID_EXT:
2886bf215546Sopenharmony_ci      if (index >= 1)
2887bf215546Sopenharmony_ci         goto invalid_value;
2888bf215546Sopenharmony_ci      _mesa_get_driver_uuid(ctx, v->value_int_4);
2889bf215546Sopenharmony_ci      return TYPE_INT_4;
2890bf215546Sopenharmony_ci   case GL_DEVICE_UUID_EXT:
2891bf215546Sopenharmony_ci      if (index >= 1)
2892bf215546Sopenharmony_ci         goto invalid_value;
2893bf215546Sopenharmony_ci      _mesa_get_device_uuid(ctx, v->value_int_4);
2894bf215546Sopenharmony_ci      return TYPE_INT_4;
2895bf215546Sopenharmony_ci   /* GL_EXT_memory_object_win32 */
2896bf215546Sopenharmony_ci   case GL_DEVICE_LUID_EXT:
2897bf215546Sopenharmony_ci      if (index >= 1)
2898bf215546Sopenharmony_ci         goto invalid_value;
2899bf215546Sopenharmony_ci      _mesa_get_device_luid(ctx, v->value_int_2);
2900bf215546Sopenharmony_ci      return TYPE_INT_2;
2901bf215546Sopenharmony_ci   case GL_DEVICE_NODE_MASK_EXT:
2902bf215546Sopenharmony_ci      if (index >= 1)
2903bf215546Sopenharmony_ci         goto invalid_value;
2904bf215546Sopenharmony_ci      v->value_int = ctx->pipe->screen->get_device_node_mask(ctx->pipe->screen);
2905bf215546Sopenharmony_ci      return TYPE_INT;
2906bf215546Sopenharmony_ci   /* GL_EXT_direct_state_access */
2907bf215546Sopenharmony_ci   case GL_TEXTURE_1D:
2908bf215546Sopenharmony_ci   case GL_TEXTURE_2D:
2909bf215546Sopenharmony_ci   case GL_TEXTURE_3D:
2910bf215546Sopenharmony_ci   case GL_TEXTURE_CUBE_MAP:
2911bf215546Sopenharmony_ci   case GL_TEXTURE_GEN_S:
2912bf215546Sopenharmony_ci   case GL_TEXTURE_GEN_T:
2913bf215546Sopenharmony_ci   case GL_TEXTURE_GEN_R:
2914bf215546Sopenharmony_ci   case GL_TEXTURE_GEN_Q:
2915bf215546Sopenharmony_ci   case GL_TEXTURE_RECTANGLE_ARB: {
2916bf215546Sopenharmony_ci      GLuint curTexUnitSave;
2917bf215546Sopenharmony_ci      if (index >= _mesa_max_tex_unit(ctx))
2918bf215546Sopenharmony_ci         goto invalid_enum;
2919bf215546Sopenharmony_ci      curTexUnitSave = ctx->Texture.CurrentUnit;
2920bf215546Sopenharmony_ci      _mesa_ActiveTexture_no_error(GL_TEXTURE0 + index);
2921bf215546Sopenharmony_ci      v->value_int = _mesa_IsEnabled(pname);
2922bf215546Sopenharmony_ci      _mesa_ActiveTexture_no_error(GL_TEXTURE0 + curTexUnitSave);
2923bf215546Sopenharmony_ci      return TYPE_INT;
2924bf215546Sopenharmony_ci   }
2925bf215546Sopenharmony_ci   case GL_TEXTURE_COORD_ARRAY: {
2926bf215546Sopenharmony_ci      GLuint curTexUnitSave;
2927bf215546Sopenharmony_ci      if (index >= ctx->Const.MaxTextureCoordUnits)
2928bf215546Sopenharmony_ci         goto invalid_enum;
2929bf215546Sopenharmony_ci      curTexUnitSave = ctx->Array.ActiveTexture;
2930bf215546Sopenharmony_ci      _mesa_ClientActiveTexture(GL_TEXTURE0 + index);
2931bf215546Sopenharmony_ci      v->value_int = _mesa_IsEnabled(pname);
2932bf215546Sopenharmony_ci      _mesa_ClientActiveTexture(GL_TEXTURE0 + curTexUnitSave);
2933bf215546Sopenharmony_ci      return TYPE_INT;
2934bf215546Sopenharmony_ci   }
2935bf215546Sopenharmony_ci   case GL_TEXTURE_MATRIX:
2936bf215546Sopenharmony_ci      if (index >= ARRAY_SIZE(ctx->TextureMatrixStack))
2937bf215546Sopenharmony_ci         goto invalid_enum;
2938bf215546Sopenharmony_ci      v->value_matrix = ctx->TextureMatrixStack[index].Top;
2939bf215546Sopenharmony_ci      return TYPE_MATRIX;
2940bf215546Sopenharmony_ci   case GL_TRANSPOSE_TEXTURE_MATRIX:
2941bf215546Sopenharmony_ci      if (index >= ARRAY_SIZE(ctx->TextureMatrixStack))
2942bf215546Sopenharmony_ci         goto invalid_enum;
2943bf215546Sopenharmony_ci      v->value_matrix = ctx->TextureMatrixStack[index].Top;
2944bf215546Sopenharmony_ci      return TYPE_MATRIX_T;
2945bf215546Sopenharmony_ci   /* GL_NV_viewport_swizzle */
2946bf215546Sopenharmony_ci   case GL_VIEWPORT_SWIZZLE_X_NV:
2947bf215546Sopenharmony_ci      if (!ctx->Extensions.NV_viewport_swizzle)
2948bf215546Sopenharmony_ci         goto invalid_enum;
2949bf215546Sopenharmony_ci      if (index >= ctx->Const.MaxViewports)
2950bf215546Sopenharmony_ci         goto invalid_value;
2951bf215546Sopenharmony_ci      v->value_int = ctx->ViewportArray[index].SwizzleX;
2952bf215546Sopenharmony_ci      return TYPE_INT;
2953bf215546Sopenharmony_ci   case GL_VIEWPORT_SWIZZLE_Y_NV:
2954bf215546Sopenharmony_ci      if (!ctx->Extensions.NV_viewport_swizzle)
2955bf215546Sopenharmony_ci         goto invalid_enum;
2956bf215546Sopenharmony_ci      if (index >= ctx->Const.MaxViewports)
2957bf215546Sopenharmony_ci         goto invalid_value;
2958bf215546Sopenharmony_ci      v->value_int = ctx->ViewportArray[index].SwizzleY;
2959bf215546Sopenharmony_ci      return TYPE_INT;
2960bf215546Sopenharmony_ci   case GL_VIEWPORT_SWIZZLE_Z_NV:
2961bf215546Sopenharmony_ci      if (!ctx->Extensions.NV_viewport_swizzle)
2962bf215546Sopenharmony_ci         goto invalid_enum;
2963bf215546Sopenharmony_ci      if (index >= ctx->Const.MaxViewports)
2964bf215546Sopenharmony_ci         goto invalid_value;
2965bf215546Sopenharmony_ci      v->value_int = ctx->ViewportArray[index].SwizzleZ;
2966bf215546Sopenharmony_ci      return TYPE_INT;
2967bf215546Sopenharmony_ci   case GL_VIEWPORT_SWIZZLE_W_NV:
2968bf215546Sopenharmony_ci      if (!ctx->Extensions.NV_viewport_swizzle)
2969bf215546Sopenharmony_ci         goto invalid_enum;
2970bf215546Sopenharmony_ci      if (index >= ctx->Const.MaxViewports)
2971bf215546Sopenharmony_ci         goto invalid_value;
2972bf215546Sopenharmony_ci      v->value_int = ctx->ViewportArray[index].SwizzleW;
2973bf215546Sopenharmony_ci      return TYPE_INT;
2974bf215546Sopenharmony_ci   }
2975bf215546Sopenharmony_ci
2976bf215546Sopenharmony_ci invalid_enum:
2977bf215546Sopenharmony_ci   _mesa_error(ctx, GL_INVALID_ENUM, "%s(pname=%s)", func,
2978bf215546Sopenharmony_ci               _mesa_enum_to_string(pname));
2979bf215546Sopenharmony_ci   return TYPE_INVALID;
2980bf215546Sopenharmony_ci invalid_value:
2981bf215546Sopenharmony_ci   _mesa_error(ctx, GL_INVALID_VALUE, "%s(pname=%s)", func,
2982bf215546Sopenharmony_ci               _mesa_enum_to_string(pname));
2983bf215546Sopenharmony_ci   return TYPE_INVALID;
2984bf215546Sopenharmony_ci}
2985bf215546Sopenharmony_ci
2986bf215546Sopenharmony_civoid GLAPIENTRY
2987bf215546Sopenharmony_ci_mesa_GetBooleani_v( GLenum pname, GLuint index, GLboolean *params )
2988bf215546Sopenharmony_ci{
2989bf215546Sopenharmony_ci   union value v;
2990bf215546Sopenharmony_ci   enum value_type type =
2991bf215546Sopenharmony_ci      find_value_indexed("glGetBooleani_v", pname, index, &v);
2992bf215546Sopenharmony_ci
2993bf215546Sopenharmony_ci   switch (type) {
2994bf215546Sopenharmony_ci   case TYPE_INT:
2995bf215546Sopenharmony_ci   case TYPE_UINT:
2996bf215546Sopenharmony_ci      params[0] = INT_TO_BOOLEAN(v.value_int);
2997bf215546Sopenharmony_ci      break;
2998bf215546Sopenharmony_ci   case TYPE_INT_4:
2999bf215546Sopenharmony_ci   case TYPE_UINT_4:
3000bf215546Sopenharmony_ci      params[0] = INT_TO_BOOLEAN(v.value_int_4[0]);
3001bf215546Sopenharmony_ci      params[1] = INT_TO_BOOLEAN(v.value_int_4[1]);
3002bf215546Sopenharmony_ci      params[2] = INT_TO_BOOLEAN(v.value_int_4[2]);
3003bf215546Sopenharmony_ci      params[3] = INT_TO_BOOLEAN(v.value_int_4[3]);
3004bf215546Sopenharmony_ci      break;
3005bf215546Sopenharmony_ci   case TYPE_INT64:
3006bf215546Sopenharmony_ci      params[0] = INT64_TO_BOOLEAN(v.value_int64);
3007bf215546Sopenharmony_ci      break;
3008bf215546Sopenharmony_ci   default:
3009bf215546Sopenharmony_ci      ; /* nothing - GL error was recorded */
3010bf215546Sopenharmony_ci   }
3011bf215546Sopenharmony_ci}
3012bf215546Sopenharmony_ci
3013bf215546Sopenharmony_civoid GLAPIENTRY
3014bf215546Sopenharmony_ci_mesa_GetIntegeri_v( GLenum pname, GLuint index, GLint *params )
3015bf215546Sopenharmony_ci{
3016bf215546Sopenharmony_ci   union value v;
3017bf215546Sopenharmony_ci   enum value_type type =
3018bf215546Sopenharmony_ci      find_value_indexed("glGetIntegeri_v", pname, index, &v);
3019bf215546Sopenharmony_ci
3020bf215546Sopenharmony_ci   switch (type) {
3021bf215546Sopenharmony_ci   case TYPE_FLOAT_4:
3022bf215546Sopenharmony_ci   case TYPE_FLOATN_4:
3023bf215546Sopenharmony_ci      params[3] = lroundf(v.value_float_4[3]);
3024bf215546Sopenharmony_ci      FALLTHROUGH;
3025bf215546Sopenharmony_ci   case TYPE_FLOAT_3:
3026bf215546Sopenharmony_ci   case TYPE_FLOATN_3:
3027bf215546Sopenharmony_ci      params[2] = lroundf(v.value_float_4[2]);
3028bf215546Sopenharmony_ci      FALLTHROUGH;
3029bf215546Sopenharmony_ci   case TYPE_FLOAT_2:
3030bf215546Sopenharmony_ci   case TYPE_FLOATN_2:
3031bf215546Sopenharmony_ci      params[1] = lroundf(v.value_float_4[1]);
3032bf215546Sopenharmony_ci      FALLTHROUGH;
3033bf215546Sopenharmony_ci   case TYPE_FLOAT:
3034bf215546Sopenharmony_ci   case TYPE_FLOATN:
3035bf215546Sopenharmony_ci      params[0] = lroundf(v.value_float_4[0]);
3036bf215546Sopenharmony_ci      break;
3037bf215546Sopenharmony_ci
3038bf215546Sopenharmony_ci   case TYPE_DOUBLEN_2:
3039bf215546Sopenharmony_ci      params[1] = lroundf(v.value_double_2[1]);
3040bf215546Sopenharmony_ci      FALLTHROUGH;
3041bf215546Sopenharmony_ci   case TYPE_DOUBLEN:
3042bf215546Sopenharmony_ci      params[0] = lroundf(v.value_double_2[0]);
3043bf215546Sopenharmony_ci      break;
3044bf215546Sopenharmony_ci
3045bf215546Sopenharmony_ci   case TYPE_INT:
3046bf215546Sopenharmony_ci      params[0] = v.value_int;
3047bf215546Sopenharmony_ci      break;
3048bf215546Sopenharmony_ci   case TYPE_UINT:
3049bf215546Sopenharmony_ci      params[0] = MIN2(v.value_uint, INT_MAX);
3050bf215546Sopenharmony_ci      break;
3051bf215546Sopenharmony_ci   case TYPE_INT_4:
3052bf215546Sopenharmony_ci      params[0] = v.value_int_4[0];
3053bf215546Sopenharmony_ci      params[1] = v.value_int_4[1];
3054bf215546Sopenharmony_ci      params[2] = v.value_int_4[2];
3055bf215546Sopenharmony_ci      params[3] = v.value_int_4[3];
3056bf215546Sopenharmony_ci      break;
3057bf215546Sopenharmony_ci   case TYPE_UINT_4:
3058bf215546Sopenharmony_ci      params[0] = MIN2((GLuint)v.value_int_4[0], INT_MAX);
3059bf215546Sopenharmony_ci      params[1] = MIN2((GLuint)v.value_int_4[1], INT_MAX);
3060bf215546Sopenharmony_ci      params[2] = MIN2((GLuint)v.value_int_4[2], INT_MAX);
3061bf215546Sopenharmony_ci      params[3] = MIN2((GLuint)v.value_int_4[3], INT_MAX);
3062bf215546Sopenharmony_ci      break;
3063bf215546Sopenharmony_ci   case TYPE_INT64:
3064bf215546Sopenharmony_ci      params[0] = INT64_TO_INT(v.value_int64);
3065bf215546Sopenharmony_ci      break;
3066bf215546Sopenharmony_ci   default:
3067bf215546Sopenharmony_ci      ; /* nothing - GL error was recorded */
3068bf215546Sopenharmony_ci   }
3069bf215546Sopenharmony_ci}
3070bf215546Sopenharmony_ci
3071bf215546Sopenharmony_civoid GLAPIENTRY
3072bf215546Sopenharmony_ci_mesa_GetInteger64i_v( GLenum pname, GLuint index, GLint64 *params )
3073bf215546Sopenharmony_ci{
3074bf215546Sopenharmony_ci   union value v;
3075bf215546Sopenharmony_ci   enum value_type type =
3076bf215546Sopenharmony_ci      find_value_indexed("glGetInteger64i_v", pname, index, &v);
3077bf215546Sopenharmony_ci
3078bf215546Sopenharmony_ci   switch (type) {
3079bf215546Sopenharmony_ci   case TYPE_INT:
3080bf215546Sopenharmony_ci      params[0] = v.value_int;
3081bf215546Sopenharmony_ci      break;
3082bf215546Sopenharmony_ci   case TYPE_INT_4:
3083bf215546Sopenharmony_ci      params[0] = v.value_int_4[0];
3084bf215546Sopenharmony_ci      params[1] = v.value_int_4[1];
3085bf215546Sopenharmony_ci      params[2] = v.value_int_4[2];
3086bf215546Sopenharmony_ci      params[3] = v.value_int_4[3];
3087bf215546Sopenharmony_ci      break;
3088bf215546Sopenharmony_ci   case TYPE_UINT:
3089bf215546Sopenharmony_ci      params[0] = v.value_uint;
3090bf215546Sopenharmony_ci      break;
3091bf215546Sopenharmony_ci   case TYPE_UINT_4:
3092bf215546Sopenharmony_ci      params[0] = (GLuint) v.value_int_4[0];
3093bf215546Sopenharmony_ci      params[1] = (GLuint) v.value_int_4[1];
3094bf215546Sopenharmony_ci      params[2] = (GLuint) v.value_int_4[2];
3095bf215546Sopenharmony_ci      params[3] = (GLuint) v.value_int_4[3];
3096bf215546Sopenharmony_ci      break;
3097bf215546Sopenharmony_ci   case TYPE_INT64:
3098bf215546Sopenharmony_ci      params[0] = v.value_int64;
3099bf215546Sopenharmony_ci      break;
3100bf215546Sopenharmony_ci   default:
3101bf215546Sopenharmony_ci      ; /* nothing - GL error was recorded */
3102bf215546Sopenharmony_ci   }
3103bf215546Sopenharmony_ci}
3104bf215546Sopenharmony_ci
3105bf215546Sopenharmony_civoid GLAPIENTRY
3106bf215546Sopenharmony_ci_mesa_GetFloati_v(GLenum pname, GLuint index, GLfloat *params)
3107bf215546Sopenharmony_ci{
3108bf215546Sopenharmony_ci   int i;
3109bf215546Sopenharmony_ci   GLmatrix *m;
3110bf215546Sopenharmony_ci   union value v;
3111bf215546Sopenharmony_ci   enum value_type type =
3112bf215546Sopenharmony_ci      find_value_indexed("glGetFloati_v", pname, index, &v);
3113bf215546Sopenharmony_ci
3114bf215546Sopenharmony_ci   switch (type) {
3115bf215546Sopenharmony_ci   case TYPE_FLOAT_4:
3116bf215546Sopenharmony_ci   case TYPE_FLOATN_4:
3117bf215546Sopenharmony_ci      params[3] = v.value_float_4[3];
3118bf215546Sopenharmony_ci      FALLTHROUGH;
3119bf215546Sopenharmony_ci   case TYPE_FLOAT_3:
3120bf215546Sopenharmony_ci   case TYPE_FLOATN_3:
3121bf215546Sopenharmony_ci      params[2] = v.value_float_4[2];
3122bf215546Sopenharmony_ci      FALLTHROUGH;
3123bf215546Sopenharmony_ci   case TYPE_FLOAT_2:
3124bf215546Sopenharmony_ci   case TYPE_FLOATN_2:
3125bf215546Sopenharmony_ci      params[1] = v.value_float_4[1];
3126bf215546Sopenharmony_ci      FALLTHROUGH;
3127bf215546Sopenharmony_ci   case TYPE_FLOAT:
3128bf215546Sopenharmony_ci   case TYPE_FLOATN:
3129bf215546Sopenharmony_ci      params[0] = v.value_float_4[0];
3130bf215546Sopenharmony_ci      break;
3131bf215546Sopenharmony_ci
3132bf215546Sopenharmony_ci   case TYPE_DOUBLEN_2:
3133bf215546Sopenharmony_ci      params[1] = (GLfloat) v.value_double_2[1];
3134bf215546Sopenharmony_ci      FALLTHROUGH;
3135bf215546Sopenharmony_ci   case TYPE_DOUBLEN:
3136bf215546Sopenharmony_ci      params[0] = (GLfloat) v.value_double_2[0];
3137bf215546Sopenharmony_ci      break;
3138bf215546Sopenharmony_ci
3139bf215546Sopenharmony_ci   case TYPE_INT_4:
3140bf215546Sopenharmony_ci      params[3] = (GLfloat) v.value_int_4[3];
3141bf215546Sopenharmony_ci      FALLTHROUGH;
3142bf215546Sopenharmony_ci   case TYPE_INT_3:
3143bf215546Sopenharmony_ci      params[2] = (GLfloat) v.value_int_4[2];
3144bf215546Sopenharmony_ci      FALLTHROUGH;
3145bf215546Sopenharmony_ci   case TYPE_INT_2:
3146bf215546Sopenharmony_ci   case TYPE_ENUM_2:
3147bf215546Sopenharmony_ci      params[1] = (GLfloat) v.value_int_4[1];
3148bf215546Sopenharmony_ci      FALLTHROUGH;
3149bf215546Sopenharmony_ci   case TYPE_INT:
3150bf215546Sopenharmony_ci   case TYPE_ENUM:
3151bf215546Sopenharmony_ci   case TYPE_ENUM16:
3152bf215546Sopenharmony_ci      params[0] = (GLfloat) v.value_int_4[0];
3153bf215546Sopenharmony_ci      break;
3154bf215546Sopenharmony_ci
3155bf215546Sopenharmony_ci   case TYPE_INT_N:
3156bf215546Sopenharmony_ci      for (i = 0; i < v.value_int_n.n; i++)
3157bf215546Sopenharmony_ci         params[i] = (GLfloat) v.value_int_n.ints[i];
3158bf215546Sopenharmony_ci      break;
3159bf215546Sopenharmony_ci
3160bf215546Sopenharmony_ci   case TYPE_UINT_4:
3161bf215546Sopenharmony_ci      params[3] = (GLfloat) ((GLuint) v.value_int_4[3]);
3162bf215546Sopenharmony_ci      FALLTHROUGH;
3163bf215546Sopenharmony_ci   case TYPE_UINT_3:
3164bf215546Sopenharmony_ci      params[2] = (GLfloat) ((GLuint) v.value_int_4[2]);
3165bf215546Sopenharmony_ci      FALLTHROUGH;
3166bf215546Sopenharmony_ci   case TYPE_UINT_2:
3167bf215546Sopenharmony_ci      params[1] = (GLfloat) ((GLuint) v.value_int_4[1]);
3168bf215546Sopenharmony_ci      FALLTHROUGH;
3169bf215546Sopenharmony_ci   case TYPE_UINT:
3170bf215546Sopenharmony_ci      params[0] = (GLfloat) ((GLuint) v.value_int_4[0]);
3171bf215546Sopenharmony_ci      break;
3172bf215546Sopenharmony_ci
3173bf215546Sopenharmony_ci   case TYPE_INT64:
3174bf215546Sopenharmony_ci      params[0] = (GLfloat) v.value_int64;
3175bf215546Sopenharmony_ci      break;
3176bf215546Sopenharmony_ci
3177bf215546Sopenharmony_ci   case TYPE_BOOLEAN:
3178bf215546Sopenharmony_ci      params[0] = BOOLEAN_TO_FLOAT(v.value_bool);
3179bf215546Sopenharmony_ci      break;
3180bf215546Sopenharmony_ci
3181bf215546Sopenharmony_ci   case TYPE_UBYTE:
3182bf215546Sopenharmony_ci      params[0] = (GLfloat) v.value_ubyte;
3183bf215546Sopenharmony_ci      break;
3184bf215546Sopenharmony_ci
3185bf215546Sopenharmony_ci   case TYPE_SHORT:
3186bf215546Sopenharmony_ci      params[0] = (GLfloat) v.value_short;
3187bf215546Sopenharmony_ci      break;
3188bf215546Sopenharmony_ci
3189bf215546Sopenharmony_ci   case TYPE_MATRIX:
3190bf215546Sopenharmony_ci      m = *(GLmatrix **) &v;
3191bf215546Sopenharmony_ci      for (i = 0; i < 16; i++)
3192bf215546Sopenharmony_ci         params[i] = m->m[i];
3193bf215546Sopenharmony_ci      break;
3194bf215546Sopenharmony_ci
3195bf215546Sopenharmony_ci   case TYPE_MATRIX_T:
3196bf215546Sopenharmony_ci      m = *(GLmatrix **) &v;
3197bf215546Sopenharmony_ci      for (i = 0; i < 16; i++)
3198bf215546Sopenharmony_ci         params[i] = m->m[transpose[i]];
3199bf215546Sopenharmony_ci      break;
3200bf215546Sopenharmony_ci
3201bf215546Sopenharmony_ci   default:
3202bf215546Sopenharmony_ci      ;
3203bf215546Sopenharmony_ci   }
3204bf215546Sopenharmony_ci}
3205bf215546Sopenharmony_ci
3206bf215546Sopenharmony_civoid GLAPIENTRY
3207bf215546Sopenharmony_ci_mesa_GetDoublei_v(GLenum pname, GLuint index, GLdouble *params)
3208bf215546Sopenharmony_ci{
3209bf215546Sopenharmony_ci   int i;
3210bf215546Sopenharmony_ci   GLmatrix *m;
3211bf215546Sopenharmony_ci   union value v;
3212bf215546Sopenharmony_ci   enum value_type type =
3213bf215546Sopenharmony_ci      find_value_indexed("glGetDoublei_v", pname, index, &v);
3214bf215546Sopenharmony_ci
3215bf215546Sopenharmony_ci   switch (type) {
3216bf215546Sopenharmony_ci   case TYPE_FLOAT_4:
3217bf215546Sopenharmony_ci   case TYPE_FLOATN_4:
3218bf215546Sopenharmony_ci      params[3] = (GLdouble) v.value_float_4[3];
3219bf215546Sopenharmony_ci      FALLTHROUGH;
3220bf215546Sopenharmony_ci   case TYPE_FLOAT_3:
3221bf215546Sopenharmony_ci   case TYPE_FLOATN_3:
3222bf215546Sopenharmony_ci      params[2] = (GLdouble) v.value_float_4[2];
3223bf215546Sopenharmony_ci      FALLTHROUGH;
3224bf215546Sopenharmony_ci   case TYPE_FLOAT_2:
3225bf215546Sopenharmony_ci   case TYPE_FLOATN_2:
3226bf215546Sopenharmony_ci      params[1] = (GLdouble) v.value_float_4[1];
3227bf215546Sopenharmony_ci      FALLTHROUGH;
3228bf215546Sopenharmony_ci   case TYPE_FLOAT:
3229bf215546Sopenharmony_ci   case TYPE_FLOATN:
3230bf215546Sopenharmony_ci      params[0] = (GLdouble) v.value_float_4[0];
3231bf215546Sopenharmony_ci      break;
3232bf215546Sopenharmony_ci
3233bf215546Sopenharmony_ci   case TYPE_DOUBLEN_2:
3234bf215546Sopenharmony_ci      params[1] = v.value_double_2[1];
3235bf215546Sopenharmony_ci      FALLTHROUGH;
3236bf215546Sopenharmony_ci   case TYPE_DOUBLEN:
3237bf215546Sopenharmony_ci      params[0] = v.value_double_2[0];
3238bf215546Sopenharmony_ci      break;
3239bf215546Sopenharmony_ci
3240bf215546Sopenharmony_ci   case TYPE_INT_4:
3241bf215546Sopenharmony_ci      params[3] = (GLdouble) v.value_int_4[3];
3242bf215546Sopenharmony_ci      FALLTHROUGH;
3243bf215546Sopenharmony_ci   case TYPE_INT_3:
3244bf215546Sopenharmony_ci      params[2] = (GLdouble) v.value_int_4[2];
3245bf215546Sopenharmony_ci      FALLTHROUGH;
3246bf215546Sopenharmony_ci   case TYPE_INT_2:
3247bf215546Sopenharmony_ci   case TYPE_ENUM_2:
3248bf215546Sopenharmony_ci      params[1] = (GLdouble) v.value_int_4[1];
3249bf215546Sopenharmony_ci      FALLTHROUGH;
3250bf215546Sopenharmony_ci   case TYPE_INT:
3251bf215546Sopenharmony_ci   case TYPE_ENUM:
3252bf215546Sopenharmony_ci   case TYPE_ENUM16:
3253bf215546Sopenharmony_ci      params[0] = (GLdouble) v.value_int_4[0];
3254bf215546Sopenharmony_ci      break;
3255bf215546Sopenharmony_ci
3256bf215546Sopenharmony_ci   case TYPE_INT_N:
3257bf215546Sopenharmony_ci      for (i = 0; i < v.value_int_n.n; i++)
3258bf215546Sopenharmony_ci         params[i] = (GLdouble) v.value_int_n.ints[i];
3259bf215546Sopenharmony_ci      break;
3260bf215546Sopenharmony_ci
3261bf215546Sopenharmony_ci   case TYPE_UINT_4:
3262bf215546Sopenharmony_ci      params[3] = (GLdouble) ((GLuint) v.value_int_4[3]);
3263bf215546Sopenharmony_ci      FALLTHROUGH;
3264bf215546Sopenharmony_ci   case TYPE_UINT_3:
3265bf215546Sopenharmony_ci      params[2] = (GLdouble) ((GLuint) v.value_int_4[2]);
3266bf215546Sopenharmony_ci      FALLTHROUGH;
3267bf215546Sopenharmony_ci   case TYPE_UINT_2:
3268bf215546Sopenharmony_ci      params[1] = (GLdouble) ((GLuint) v.value_int_4[1]);
3269bf215546Sopenharmony_ci      FALLTHROUGH;
3270bf215546Sopenharmony_ci   case TYPE_UINT:
3271bf215546Sopenharmony_ci      params[0] = (GLdouble) ((GLuint) v.value_int_4[0]);
3272bf215546Sopenharmony_ci      break;
3273bf215546Sopenharmony_ci
3274bf215546Sopenharmony_ci   case TYPE_INT64:
3275bf215546Sopenharmony_ci      params[0] = (GLdouble) v.value_int64;
3276bf215546Sopenharmony_ci      break;
3277bf215546Sopenharmony_ci
3278bf215546Sopenharmony_ci   case TYPE_BOOLEAN:
3279bf215546Sopenharmony_ci      params[0] = (GLdouble) BOOLEAN_TO_FLOAT(v.value_bool);
3280bf215546Sopenharmony_ci      break;
3281bf215546Sopenharmony_ci
3282bf215546Sopenharmony_ci   case TYPE_UBYTE:
3283bf215546Sopenharmony_ci      params[0] = (GLdouble) v.value_ubyte;
3284bf215546Sopenharmony_ci      break;
3285bf215546Sopenharmony_ci
3286bf215546Sopenharmony_ci   case TYPE_SHORT:
3287bf215546Sopenharmony_ci      params[0] = (GLdouble) v.value_short;
3288bf215546Sopenharmony_ci      break;
3289bf215546Sopenharmony_ci
3290bf215546Sopenharmony_ci   case TYPE_MATRIX:
3291bf215546Sopenharmony_ci      m = *(GLmatrix **) &v;
3292bf215546Sopenharmony_ci      for (i = 0; i < 16; i++)
3293bf215546Sopenharmony_ci         params[i] = (GLdouble) m->m[i];
3294bf215546Sopenharmony_ci      break;
3295bf215546Sopenharmony_ci
3296bf215546Sopenharmony_ci   case TYPE_MATRIX_T:
3297bf215546Sopenharmony_ci      m = *(GLmatrix **) &v;
3298bf215546Sopenharmony_ci      for (i = 0; i < 16; i++)
3299bf215546Sopenharmony_ci         params[i] = (GLdouble) m->m[transpose[i]];
3300bf215546Sopenharmony_ci      break;
3301bf215546Sopenharmony_ci
3302bf215546Sopenharmony_ci   default:
3303bf215546Sopenharmony_ci      ;
3304bf215546Sopenharmony_ci   }
3305bf215546Sopenharmony_ci}
3306bf215546Sopenharmony_ci
3307bf215546Sopenharmony_civoid GLAPIENTRY
3308bf215546Sopenharmony_ci_mesa_GetUnsignedBytei_vEXT(GLenum target, GLuint index, GLubyte *data)
3309bf215546Sopenharmony_ci{
3310bf215546Sopenharmony_ci   GLsizei size;
3311bf215546Sopenharmony_ci   union value v;
3312bf215546Sopenharmony_ci   enum value_type type;
3313bf215546Sopenharmony_ci   const char *func = "glGetUnsignedBytei_vEXT";
3314bf215546Sopenharmony_ci
3315bf215546Sopenharmony_ci   GET_CURRENT_CONTEXT(ctx);
3316bf215546Sopenharmony_ci
3317bf215546Sopenharmony_ci   if (!ctx->Extensions.EXT_memory_object) {
3318bf215546Sopenharmony_ci      _mesa_error(ctx, GL_INVALID_OPERATION, "%s(unsupported)", func);
3319bf215546Sopenharmony_ci      return;
3320bf215546Sopenharmony_ci   }
3321bf215546Sopenharmony_ci
3322bf215546Sopenharmony_ci   type = find_value_indexed(func, target, index, &v);
3323bf215546Sopenharmony_ci   size = get_value_size(type, &v);
3324bf215546Sopenharmony_ci
3325bf215546Sopenharmony_ci   switch (type) {
3326bf215546Sopenharmony_ci   case TYPE_UINT:
3327bf215546Sopenharmony_ci   case TYPE_INT:
3328bf215546Sopenharmony_ci   case TYPE_INT_2:
3329bf215546Sopenharmony_ci   case TYPE_UINT_2:
3330bf215546Sopenharmony_ci   case TYPE_INT_3:
3331bf215546Sopenharmony_ci   case TYPE_UINT_3:
3332bf215546Sopenharmony_ci   case TYPE_INT_4:
3333bf215546Sopenharmony_ci   case TYPE_UINT_4:
3334bf215546Sopenharmony_ci   case TYPE_INT64:
3335bf215546Sopenharmony_ci   case TYPE_ENUM16:
3336bf215546Sopenharmony_ci   case TYPE_ENUM:
3337bf215546Sopenharmony_ci   case TYPE_ENUM_2:
3338bf215546Sopenharmony_ci   case TYPE_BOOLEAN:
3339bf215546Sopenharmony_ci   case TYPE_UBYTE:
3340bf215546Sopenharmony_ci   case TYPE_SHORT:
3341bf215546Sopenharmony_ci   case TYPE_FLOAT:
3342bf215546Sopenharmony_ci   case TYPE_FLOATN:
3343bf215546Sopenharmony_ci   case TYPE_FLOAT_2:
3344bf215546Sopenharmony_ci   case TYPE_FLOATN_2:
3345bf215546Sopenharmony_ci   case TYPE_FLOAT_3:
3346bf215546Sopenharmony_ci   case TYPE_FLOATN_3:
3347bf215546Sopenharmony_ci   case TYPE_FLOAT_4:
3348bf215546Sopenharmony_ci   case TYPE_FLOATN_4:
3349bf215546Sopenharmony_ci   case TYPE_FLOAT_8:
3350bf215546Sopenharmony_ci   case TYPE_DOUBLEN:
3351bf215546Sopenharmony_ci   case TYPE_DOUBLEN_2:
3352bf215546Sopenharmony_ci   case TYPE_MATRIX:
3353bf215546Sopenharmony_ci   case TYPE_MATRIX_T:
3354bf215546Sopenharmony_ci      memcpy(data, &v.value_int, size);
3355bf215546Sopenharmony_ci      break;
3356bf215546Sopenharmony_ci   case TYPE_INT_N:
3357bf215546Sopenharmony_ci      memcpy(data, &v.value_int_n.ints, size);
3358bf215546Sopenharmony_ci      break;
3359bf215546Sopenharmony_ci   default:
3360bf215546Sopenharmony_ci      break; /* nothing - GL error was recorded */
3361bf215546Sopenharmony_ci   }
3362bf215546Sopenharmony_ci}
3363bf215546Sopenharmony_ci
3364bf215546Sopenharmony_civoid GLAPIENTRY
3365bf215546Sopenharmony_ci_mesa_GetFixedv(GLenum pname, GLfixed *params)
3366bf215546Sopenharmony_ci{
3367bf215546Sopenharmony_ci   const struct value_desc *d;
3368bf215546Sopenharmony_ci   union value v;
3369bf215546Sopenharmony_ci   GLmatrix *m;
3370bf215546Sopenharmony_ci   int shift, i;
3371bf215546Sopenharmony_ci   void *p;
3372bf215546Sopenharmony_ci
3373bf215546Sopenharmony_ci   d = find_value("glGetDoublev", pname, &p, &v);
3374bf215546Sopenharmony_ci   switch (d->type) {
3375bf215546Sopenharmony_ci   case TYPE_INVALID:
3376bf215546Sopenharmony_ci      break;
3377bf215546Sopenharmony_ci   case TYPE_CONST:
3378bf215546Sopenharmony_ci      params[0] = INT_TO_FIXED(d->offset);
3379bf215546Sopenharmony_ci      break;
3380bf215546Sopenharmony_ci
3381bf215546Sopenharmony_ci   case TYPE_FLOAT_4:
3382bf215546Sopenharmony_ci   case TYPE_FLOATN_4:
3383bf215546Sopenharmony_ci      params[3] = FLOAT_TO_FIXED(((GLfloat *) p)[3]);
3384bf215546Sopenharmony_ci      FALLTHROUGH;
3385bf215546Sopenharmony_ci   case TYPE_FLOAT_3:
3386bf215546Sopenharmony_ci   case TYPE_FLOATN_3:
3387bf215546Sopenharmony_ci      params[2] = FLOAT_TO_FIXED(((GLfloat *) p)[2]);
3388bf215546Sopenharmony_ci      FALLTHROUGH;
3389bf215546Sopenharmony_ci   case TYPE_FLOAT_2:
3390bf215546Sopenharmony_ci   case TYPE_FLOATN_2:
3391bf215546Sopenharmony_ci      params[1] = FLOAT_TO_FIXED(((GLfloat *) p)[1]);
3392bf215546Sopenharmony_ci      FALLTHROUGH;
3393bf215546Sopenharmony_ci   case TYPE_FLOAT:
3394bf215546Sopenharmony_ci   case TYPE_FLOATN:
3395bf215546Sopenharmony_ci      params[0] = FLOAT_TO_FIXED(((GLfloat *) p)[0]);
3396bf215546Sopenharmony_ci      break;
3397bf215546Sopenharmony_ci
3398bf215546Sopenharmony_ci   case TYPE_DOUBLEN_2:
3399bf215546Sopenharmony_ci      params[1] = FLOAT_TO_FIXED(((GLdouble *) p)[1]);
3400bf215546Sopenharmony_ci      FALLTHROUGH;
3401bf215546Sopenharmony_ci   case TYPE_DOUBLEN:
3402bf215546Sopenharmony_ci      params[0] = FLOAT_TO_FIXED(((GLdouble *) p)[0]);
3403bf215546Sopenharmony_ci      break;
3404bf215546Sopenharmony_ci
3405bf215546Sopenharmony_ci   case TYPE_INT_4:
3406bf215546Sopenharmony_ci      params[3] = INT_TO_FIXED(((GLint *) p)[3]);
3407bf215546Sopenharmony_ci      FALLTHROUGH;
3408bf215546Sopenharmony_ci   case TYPE_INT_3:
3409bf215546Sopenharmony_ci      params[2] = INT_TO_FIXED(((GLint *) p)[2]);
3410bf215546Sopenharmony_ci      FALLTHROUGH;
3411bf215546Sopenharmony_ci   case TYPE_INT_2:
3412bf215546Sopenharmony_ci   case TYPE_ENUM_2:
3413bf215546Sopenharmony_ci      params[1] = INT_TO_FIXED(((GLint *) p)[1]);
3414bf215546Sopenharmony_ci      FALLTHROUGH;
3415bf215546Sopenharmony_ci   case TYPE_INT:
3416bf215546Sopenharmony_ci   case TYPE_ENUM:
3417bf215546Sopenharmony_ci      params[0] = INT_TO_FIXED(((GLint *) p)[0]);
3418bf215546Sopenharmony_ci      break;
3419bf215546Sopenharmony_ci
3420bf215546Sopenharmony_ci   case TYPE_UINT_4:
3421bf215546Sopenharmony_ci      params[3] = INT_TO_FIXED(((GLuint *) p)[3]);
3422bf215546Sopenharmony_ci      FALLTHROUGH;
3423bf215546Sopenharmony_ci   case TYPE_UINT_3:
3424bf215546Sopenharmony_ci      params[2] = INT_TO_FIXED(((GLuint *) p)[2]);
3425bf215546Sopenharmony_ci      FALLTHROUGH;
3426bf215546Sopenharmony_ci   case TYPE_UINT_2:
3427bf215546Sopenharmony_ci      params[1] = INT_TO_FIXED(((GLuint *) p)[1]);
3428bf215546Sopenharmony_ci      FALLTHROUGH;
3429bf215546Sopenharmony_ci   case TYPE_UINT:
3430bf215546Sopenharmony_ci      params[0] = INT_TO_FIXED(((GLuint *) p)[0]);
3431bf215546Sopenharmony_ci      break;
3432bf215546Sopenharmony_ci
3433bf215546Sopenharmony_ci   case TYPE_ENUM16:
3434bf215546Sopenharmony_ci      params[0] = INT_TO_FIXED((GLint)(((GLenum16 *) p)[0]));
3435bf215546Sopenharmony_ci      break;
3436bf215546Sopenharmony_ci
3437bf215546Sopenharmony_ci   case TYPE_INT_N:
3438bf215546Sopenharmony_ci      for (i = 0; i < v.value_int_n.n; i++)
3439bf215546Sopenharmony_ci         params[i] = INT_TO_FIXED(v.value_int_n.ints[i]);
3440bf215546Sopenharmony_ci      break;
3441bf215546Sopenharmony_ci
3442bf215546Sopenharmony_ci   case TYPE_INT64:
3443bf215546Sopenharmony_ci      params[0] = ((GLint64 *) p)[0];
3444bf215546Sopenharmony_ci      break;
3445bf215546Sopenharmony_ci
3446bf215546Sopenharmony_ci   case TYPE_BOOLEAN:
3447bf215546Sopenharmony_ci      params[0] = BOOLEAN_TO_FIXED(((GLboolean*) p)[0]);
3448bf215546Sopenharmony_ci      break;
3449bf215546Sopenharmony_ci
3450bf215546Sopenharmony_ci   case TYPE_UBYTE:
3451bf215546Sopenharmony_ci      params[0] = INT_TO_FIXED(((GLubyte *) p)[0]);
3452bf215546Sopenharmony_ci      break;
3453bf215546Sopenharmony_ci
3454bf215546Sopenharmony_ci   case TYPE_SHORT:
3455bf215546Sopenharmony_ci      params[0] = INT_TO_FIXED(((GLshort *) p)[0]);
3456bf215546Sopenharmony_ci      break;
3457bf215546Sopenharmony_ci
3458bf215546Sopenharmony_ci   case TYPE_MATRIX:
3459bf215546Sopenharmony_ci      m = *(GLmatrix **) p;
3460bf215546Sopenharmony_ci      for (i = 0; i < 16; i++)
3461bf215546Sopenharmony_ci         params[i] = FLOAT_TO_FIXED(m->m[i]);
3462bf215546Sopenharmony_ci      break;
3463bf215546Sopenharmony_ci
3464bf215546Sopenharmony_ci   case TYPE_MATRIX_T:
3465bf215546Sopenharmony_ci      m = *(GLmatrix **) p;
3466bf215546Sopenharmony_ci      for (i = 0; i < 16; i++)
3467bf215546Sopenharmony_ci         params[i] = FLOAT_TO_FIXED(m->m[transpose[i]]);
3468bf215546Sopenharmony_ci      break;
3469bf215546Sopenharmony_ci
3470bf215546Sopenharmony_ci   case TYPE_BIT_0:
3471bf215546Sopenharmony_ci   case TYPE_BIT_1:
3472bf215546Sopenharmony_ci   case TYPE_BIT_2:
3473bf215546Sopenharmony_ci   case TYPE_BIT_3:
3474bf215546Sopenharmony_ci   case TYPE_BIT_4:
3475bf215546Sopenharmony_ci   case TYPE_BIT_5:
3476bf215546Sopenharmony_ci   case TYPE_BIT_6:
3477bf215546Sopenharmony_ci   case TYPE_BIT_7:
3478bf215546Sopenharmony_ci      shift = d->type - TYPE_BIT_0;
3479bf215546Sopenharmony_ci      params[0] = BOOLEAN_TO_FIXED((*(GLbitfield *) p >> shift) & 1);
3480bf215546Sopenharmony_ci      break;
3481bf215546Sopenharmony_ci   }
3482bf215546Sopenharmony_ci}
3483