get.c revision b9abf16e
13464ebd5Sriastradh/* 23464ebd5Sriastradh * Copyright (C) 2010 Brian Paul All Rights Reserved. 33464ebd5Sriastradh * Copyright (C) 2010 Intel Corporation 43464ebd5Sriastradh * 53464ebd5Sriastradh * Permission is hereby granted, free of charge, to any person obtaining a 63464ebd5Sriastradh * copy of this software and associated documentation files (the "Software"), 73464ebd5Sriastradh * to deal in the Software without restriction, including without limitation 83464ebd5Sriastradh * the rights to use, copy, modify, merge, publish, distribute, sublicense, 93464ebd5Sriastradh * and/or sell copies of the Software, and to permit persons to whom the 103464ebd5Sriastradh * Software is furnished to do so, subject to the following conditions: 113464ebd5Sriastradh * 123464ebd5Sriastradh * The above copyright notice and this permission notice shall be included 133464ebd5Sriastradh * in all copies or substantial portions of the Software. 143464ebd5Sriastradh * 153464ebd5Sriastradh * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 163464ebd5Sriastradh * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 173464ebd5Sriastradh * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18af69d88dSmrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 19af69d88dSmrg * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 20af69d88dSmrg * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 21af69d88dSmrg * OTHER DEALINGS IN THE SOFTWARE. 223464ebd5Sriastradh * 233464ebd5Sriastradh * Author: Kristian Høgsberg <krh@bitplanet.net> 243464ebd5Sriastradh */ 257117f1b4Smrg 267117f1b4Smrg#include "glheader.h" 277117f1b4Smrg#include "context.h" 28af69d88dSmrg#include "blend.h" 2901e04c3fSmrg#include "debug_output.h" 307117f1b4Smrg#include "enable.h" 313464ebd5Sriastradh#include "enums.h" 32af69d88dSmrg#include "errors.h" 337117f1b4Smrg#include "extensions.h" 347117f1b4Smrg#include "get.h" 357117f1b4Smrg#include "macros.h" 367117f1b4Smrg#include "mtypes.h" 377117f1b4Smrg#include "state.h" 387117f1b4Smrg#include "texcompress.h" 3901e04c3fSmrg#include "texstate.h" 404a49301eSmrg#include "framebuffer.h" 41af69d88dSmrg#include "samplerobj.h" 42af69d88dSmrg#include "stencil.h" 4301e04c3fSmrg#include "version.h" 447117f1b4Smrg 453464ebd5Sriastradh/* This is a table driven implemetation of the glGet*v() functions. 463464ebd5Sriastradh * The basic idea is that most getters just look up an int somewhere 473464ebd5Sriastradh * in struct gl_context and then convert it to a bool or float according to 483464ebd5Sriastradh * which of glGetIntegerv() glGetBooleanv() etc is being called. 493464ebd5Sriastradh * Instead of generating code to do this, we can just record the enum 503464ebd5Sriastradh * value and the offset into struct gl_context in an array of structs. Then 513464ebd5Sriastradh * in glGet*(), we lookup the struct for the enum in question, and use 523464ebd5Sriastradh * the offset to get the int we need. 533464ebd5Sriastradh * 543464ebd5Sriastradh * Sometimes we need to look up a float, a boolean, a bit in a 553464ebd5Sriastradh * bitfield, a matrix or other types instead, so we need to track the 563464ebd5Sriastradh * type of the value in struct gl_context. And sometimes the value isn't in 573464ebd5Sriastradh * struct gl_context but in the drawbuffer, the array object, current texture 583464ebd5Sriastradh * unit, or maybe it's a computed value. So we need to also track 593464ebd5Sriastradh * where or how to find the value. Finally, we sometimes need to 603464ebd5Sriastradh * check that one of a number of extensions are enabled, the GL 613464ebd5Sriastradh * version or flush or call _mesa_update_state(). This is done by 623464ebd5Sriastradh * attaching optional extra information to the value description 633464ebd5Sriastradh * struct, it's sort of like an array of opcodes that describe extra 643464ebd5Sriastradh * checks or actions. 653464ebd5Sriastradh * 663464ebd5Sriastradh * Putting all this together we end up with struct value_desc below, 673464ebd5Sriastradh * and with a couple of macros to help, the table of struct value_desc 683464ebd5Sriastradh * is about as concise as the specification in the old python script. 693464ebd5Sriastradh */ 703464ebd5Sriastradh 717117f1b4Smrg#define FLOAT_TO_BOOLEAN(X) ( (X) ? GL_TRUE : GL_FALSE ) 723464ebd5Sriastradh#define FLOAT_TO_FIXED(F) ( ((F) * 65536.0f > INT_MAX) ? INT_MAX : \ 733464ebd5Sriastradh ((F) * 65536.0f < INT_MIN) ? INT_MIN : \ 743464ebd5Sriastradh (GLint) ((F) * 65536.0f) ) 757117f1b4Smrg 767117f1b4Smrg#define INT_TO_BOOLEAN(I) ( (I) ? GL_TRUE : GL_FALSE ) 773464ebd5Sriastradh#define INT_TO_FIXED(I) ( ((I) > SHRT_MAX) ? INT_MAX : \ 783464ebd5Sriastradh ((I) < SHRT_MIN) ? INT_MIN : \ 793464ebd5Sriastradh (GLint) ((I) * 65536) ) 807117f1b4Smrg 814a49301eSmrg#define INT64_TO_BOOLEAN(I) ( (I) ? GL_TRUE : GL_FALSE ) 824a49301eSmrg#define INT64_TO_INT(I) ( (GLint)((I > INT_MAX) ? INT_MAX : ((I < INT_MIN) ? INT_MIN : (I))) ) 834a49301eSmrg 847117f1b4Smrg#define BOOLEAN_TO_INT(B) ( (GLint) (B) ) 854a49301eSmrg#define BOOLEAN_TO_INT64(B) ( (GLint64) (B) ) 867117f1b4Smrg#define BOOLEAN_TO_FLOAT(B) ( (B) ? 1.0F : 0.0F ) 873464ebd5Sriastradh#define BOOLEAN_TO_FIXED(B) ( (GLint) ((B) ? 1 : 0) << 16 ) 887117f1b4Smrg 894a49301eSmrg#define ENUM_TO_INT64(E) ( (GLint64) (E) ) 903464ebd5Sriastradh#define ENUM_TO_FIXED(E) (E) 914a49301eSmrg 923464ebd5Sriastradhenum value_type { 933464ebd5Sriastradh TYPE_INVALID, 943464ebd5Sriastradh TYPE_INT, 953464ebd5Sriastradh TYPE_INT_2, 963464ebd5Sriastradh TYPE_INT_3, 973464ebd5Sriastradh TYPE_INT_4, 983464ebd5Sriastradh TYPE_INT_N, 9901e04c3fSmrg TYPE_UINT, 10001e04c3fSmrg TYPE_UINT_2, 10101e04c3fSmrg TYPE_UINT_3, 10201e04c3fSmrg TYPE_UINT_4, 1033464ebd5Sriastradh TYPE_INT64, 10401e04c3fSmrg TYPE_ENUM16, 1053464ebd5Sriastradh TYPE_ENUM, 1063464ebd5Sriastradh TYPE_ENUM_2, 1073464ebd5Sriastradh TYPE_BOOLEAN, 10801e04c3fSmrg TYPE_UBYTE, 10901e04c3fSmrg TYPE_SHORT, 1103464ebd5Sriastradh TYPE_BIT_0, 1113464ebd5Sriastradh TYPE_BIT_1, 1123464ebd5Sriastradh TYPE_BIT_2, 1133464ebd5Sriastradh TYPE_BIT_3, 1143464ebd5Sriastradh TYPE_BIT_4, 1153464ebd5Sriastradh TYPE_BIT_5, 116af69d88dSmrg TYPE_BIT_6, 117af69d88dSmrg TYPE_BIT_7, 1183464ebd5Sriastradh TYPE_FLOAT, 1193464ebd5Sriastradh TYPE_FLOAT_2, 1203464ebd5Sriastradh TYPE_FLOAT_3, 1213464ebd5Sriastradh TYPE_FLOAT_4, 12201e04c3fSmrg TYPE_FLOAT_8, 1233464ebd5Sriastradh TYPE_FLOATN, 1243464ebd5Sriastradh TYPE_FLOATN_2, 1253464ebd5Sriastradh TYPE_FLOATN_3, 1263464ebd5Sriastradh TYPE_FLOATN_4, 1273464ebd5Sriastradh TYPE_DOUBLEN, 128af69d88dSmrg TYPE_DOUBLEN_2, 1293464ebd5Sriastradh TYPE_MATRIX, 1303464ebd5Sriastradh TYPE_MATRIX_T, 1313464ebd5Sriastradh TYPE_CONST 1323464ebd5Sriastradh}; 1337117f1b4Smrg 1343464ebd5Sriastradhenum value_location { 1353464ebd5Sriastradh LOC_BUFFER, 1363464ebd5Sriastradh LOC_CONTEXT, 1373464ebd5Sriastradh LOC_ARRAY, 1383464ebd5Sriastradh LOC_TEXUNIT, 1393464ebd5Sriastradh LOC_CUSTOM 1403464ebd5Sriastradh}; 1413464ebd5Sriastradh 1423464ebd5Sriastradhenum value_extra { 1433464ebd5Sriastradh EXTRA_END = 0x8000, 1443464ebd5Sriastradh EXTRA_VERSION_30, 1453464ebd5Sriastradh EXTRA_VERSION_31, 1463464ebd5Sriastradh EXTRA_VERSION_32, 147af69d88dSmrg EXTRA_VERSION_40, 14801e04c3fSmrg EXTRA_VERSION_43, 149af69d88dSmrg EXTRA_API_GL, 150af69d88dSmrg EXTRA_API_GL_CORE, 151af69d88dSmrg EXTRA_API_ES2, 152af69d88dSmrg EXTRA_API_ES3, 15301e04c3fSmrg EXTRA_API_ES31, 15401e04c3fSmrg EXTRA_API_ES32, 15501e04c3fSmrg EXTRA_NEW_BUFFERS, 1563464ebd5Sriastradh EXTRA_NEW_FRAG_CLAMP, 1573464ebd5Sriastradh EXTRA_VALID_DRAW_BUFFER, 1583464ebd5Sriastradh EXTRA_VALID_TEXTURE_UNIT, 159af69d88dSmrg EXTRA_VALID_CLIP_DISTANCE, 1603464ebd5Sriastradh EXTRA_FLUSH_CURRENT, 161af69d88dSmrg EXTRA_GLSL_130, 16201e04c3fSmrg EXTRA_EXT_UBO_GS, 16301e04c3fSmrg EXTRA_EXT_ATOMICS_GS, 16401e04c3fSmrg EXTRA_EXT_SHADER_IMAGE_GS, 16501e04c3fSmrg EXTRA_EXT_ATOMICS_TESS, 16601e04c3fSmrg EXTRA_EXT_SHADER_IMAGE_TESS, 16701e04c3fSmrg EXTRA_EXT_SSBO_GS, 16801e04c3fSmrg EXTRA_EXT_FB_NO_ATTACH_GS, 16901e04c3fSmrg EXTRA_EXT_ES_GS, 17001e04c3fSmrg EXTRA_EXT_PROVOKING_VERTEX_32, 1713464ebd5Sriastradh}; 1723464ebd5Sriastradh 1733464ebd5Sriastradh#define NO_EXTRA NULL 1743464ebd5Sriastradh#define NO_OFFSET 0 1753464ebd5Sriastradh 1763464ebd5Sriastradhstruct value_desc { 1773464ebd5Sriastradh GLenum pname; 1783464ebd5Sriastradh GLubyte location; /**< enum value_location */ 1793464ebd5Sriastradh GLubyte type; /**< enum value_type */ 1803464ebd5Sriastradh int offset; 1813464ebd5Sriastradh const int *extra; 1823464ebd5Sriastradh}; 1833464ebd5Sriastradh 1843464ebd5Sriastradhunion value { 1853464ebd5Sriastradh GLfloat value_float; 1863464ebd5Sriastradh GLfloat value_float_4[4]; 187af69d88dSmrg GLdouble value_double_2[2]; 1883464ebd5Sriastradh GLmatrix *value_matrix; 1893464ebd5Sriastradh GLint value_int; 1903464ebd5Sriastradh GLint value_int_4[4]; 1913464ebd5Sriastradh GLint64 value_int64; 1923464ebd5Sriastradh GLenum value_enum; 19301e04c3fSmrg GLubyte value_ubyte; 19401e04c3fSmrg GLshort value_short; 19501e04c3fSmrg GLuint value_uint; 1963464ebd5Sriastradh 1973464ebd5Sriastradh /* Sigh, see GL_COMPRESSED_TEXTURE_FORMATS_ARB handling */ 1983464ebd5Sriastradh struct { 1993464ebd5Sriastradh GLint n, ints[100]; 2003464ebd5Sriastradh } value_int_n; 2013464ebd5Sriastradh GLboolean value_bool; 2023464ebd5Sriastradh}; 2033464ebd5Sriastradh 2043464ebd5Sriastradh#define BUFFER_FIELD(field, type) \ 2053464ebd5Sriastradh LOC_BUFFER, type, offsetof(struct gl_framebuffer, field) 2063464ebd5Sriastradh#define CONTEXT_FIELD(field, type) \ 2073464ebd5Sriastradh LOC_CONTEXT, type, offsetof(struct gl_context, field) 2083464ebd5Sriastradh#define ARRAY_FIELD(field, type) \ 209af69d88dSmrg LOC_ARRAY, type, offsetof(struct gl_vertex_array_object, field) 210af69d88dSmrg#undef CONST /* already defined through windows.h */ 2113464ebd5Sriastradh#define CONST(value) \ 2123464ebd5Sriastradh LOC_CONTEXT, TYPE_CONST, value 2133464ebd5Sriastradh 2143464ebd5Sriastradh#define BUFFER_INT(field) BUFFER_FIELD(field, TYPE_INT) 2153464ebd5Sriastradh#define BUFFER_ENUM(field) BUFFER_FIELD(field, TYPE_ENUM) 21601e04c3fSmrg#define BUFFER_ENUM16(field) BUFFER_FIELD(field, TYPE_ENUM16) 2173464ebd5Sriastradh#define BUFFER_BOOL(field) BUFFER_FIELD(field, TYPE_BOOLEAN) 2183464ebd5Sriastradh 2193464ebd5Sriastradh#define CONTEXT_INT(field) CONTEXT_FIELD(field, TYPE_INT) 2203464ebd5Sriastradh#define CONTEXT_INT2(field) CONTEXT_FIELD(field, TYPE_INT_2) 2213464ebd5Sriastradh#define CONTEXT_INT64(field) CONTEXT_FIELD(field, TYPE_INT64) 22201e04c3fSmrg#define CONTEXT_UINT(field) CONTEXT_FIELD(field, TYPE_UINT) 22301e04c3fSmrg#define CONTEXT_ENUM16(field) CONTEXT_FIELD(field, TYPE_ENUM16) 2243464ebd5Sriastradh#define CONTEXT_ENUM(field) CONTEXT_FIELD(field, TYPE_ENUM) 2253464ebd5Sriastradh#define CONTEXT_ENUM2(field) CONTEXT_FIELD(field, TYPE_ENUM_2) 2263464ebd5Sriastradh#define CONTEXT_BOOL(field) CONTEXT_FIELD(field, TYPE_BOOLEAN) 2273464ebd5Sriastradh#define CONTEXT_BIT0(field) CONTEXT_FIELD(field, TYPE_BIT_0) 2283464ebd5Sriastradh#define CONTEXT_BIT1(field) CONTEXT_FIELD(field, TYPE_BIT_1) 2293464ebd5Sriastradh#define CONTEXT_BIT2(field) CONTEXT_FIELD(field, TYPE_BIT_2) 2303464ebd5Sriastradh#define CONTEXT_BIT3(field) CONTEXT_FIELD(field, TYPE_BIT_3) 2313464ebd5Sriastradh#define CONTEXT_BIT4(field) CONTEXT_FIELD(field, TYPE_BIT_4) 2323464ebd5Sriastradh#define CONTEXT_BIT5(field) CONTEXT_FIELD(field, TYPE_BIT_5) 233af69d88dSmrg#define CONTEXT_BIT6(field) CONTEXT_FIELD(field, TYPE_BIT_6) 234af69d88dSmrg#define CONTEXT_BIT7(field) CONTEXT_FIELD(field, TYPE_BIT_7) 2353464ebd5Sriastradh#define CONTEXT_FLOAT(field) CONTEXT_FIELD(field, TYPE_FLOAT) 2363464ebd5Sriastradh#define CONTEXT_FLOAT2(field) CONTEXT_FIELD(field, TYPE_FLOAT_2) 2373464ebd5Sriastradh#define CONTEXT_FLOAT3(field) CONTEXT_FIELD(field, TYPE_FLOAT_3) 2383464ebd5Sriastradh#define CONTEXT_FLOAT4(field) CONTEXT_FIELD(field, TYPE_FLOAT_4) 23901e04c3fSmrg#define CONTEXT_FLOAT8(field) CONTEXT_FIELD(field, TYPE_FLOAT_8) 2403464ebd5Sriastradh#define CONTEXT_MATRIX(field) CONTEXT_FIELD(field, TYPE_MATRIX) 2413464ebd5Sriastradh#define CONTEXT_MATRIX_T(field) CONTEXT_FIELD(field, TYPE_MATRIX_T) 2423464ebd5Sriastradh 24301e04c3fSmrg/* Vertex array fields */ 2443464ebd5Sriastradh#define ARRAY_INT(field) ARRAY_FIELD(field, TYPE_INT) 2453464ebd5Sriastradh#define ARRAY_ENUM(field) ARRAY_FIELD(field, TYPE_ENUM) 24601e04c3fSmrg#define ARRAY_ENUM16(field) ARRAY_FIELD(field, TYPE_ENUM16) 2473464ebd5Sriastradh#define ARRAY_BOOL(field) ARRAY_FIELD(field, TYPE_BOOLEAN) 24801e04c3fSmrg#define ARRAY_UBYTE(field) ARRAY_FIELD(field, TYPE_UBYTE) 24901e04c3fSmrg#define ARRAY_SHORT(field) ARRAY_FIELD(field, TYPE_SHORT) 2503464ebd5Sriastradh 2513464ebd5Sriastradh#define EXT(f) \ 2523464ebd5Sriastradh offsetof(struct gl_extensions, f) 2533464ebd5Sriastradh 2543464ebd5Sriastradh#define EXTRA_EXT(e) \ 2553464ebd5Sriastradh static const int extra_##e[] = { \ 2563464ebd5Sriastradh EXT(e), EXTRA_END \ 2577117f1b4Smrg } 2587117f1b4Smrg 2593464ebd5Sriastradh#define EXTRA_EXT2(e1, e2) \ 2603464ebd5Sriastradh static const int extra_##e1##_##e2[] = { \ 2613464ebd5Sriastradh EXT(e1), EXT(e2), EXTRA_END \ 2623464ebd5Sriastradh } 2633464ebd5Sriastradh 2643464ebd5Sriastradh/* The 'extra' mechanism is a way to specify extra checks (such as 2653464ebd5Sriastradh * extensions or specific gl versions) or actions (flush current, new 2663464ebd5Sriastradh * buffers) that we need to do before looking up an enum. We need to 2673464ebd5Sriastradh * declare them all up front so we can refer to them in the value_desc 268af69d88dSmrg * structs below. 269af69d88dSmrg * 270af69d88dSmrg * Each EXTRA_ will be executed. For EXTRA_* enums of extensions and API 271af69d88dSmrg * versions, listing multiple ones in an array means an error will be thrown 272af69d88dSmrg * only if none of them are available. If you need to check for "AND" 273af69d88dSmrg * behavior, you would need to make a custom EXTRA_ enum. 274af69d88dSmrg */ 2753464ebd5Sriastradh 2763464ebd5Sriastradhstatic const int extra_new_buffers[] = { 2773464ebd5Sriastradh EXTRA_NEW_BUFFERS, 2783464ebd5Sriastradh EXTRA_END 2793464ebd5Sriastradh}; 2803464ebd5Sriastradh 2813464ebd5Sriastradhstatic const int extra_new_frag_clamp[] = { 2823464ebd5Sriastradh EXTRA_NEW_FRAG_CLAMP, 2833464ebd5Sriastradh EXTRA_END 2843464ebd5Sriastradh}; 2853464ebd5Sriastradh 2863464ebd5Sriastradhstatic const int extra_valid_draw_buffer[] = { 2873464ebd5Sriastradh EXTRA_VALID_DRAW_BUFFER, 2883464ebd5Sriastradh EXTRA_END 2893464ebd5Sriastradh}; 2903464ebd5Sriastradh 2913464ebd5Sriastradhstatic const int extra_valid_texture_unit[] = { 2923464ebd5Sriastradh EXTRA_VALID_TEXTURE_UNIT, 2933464ebd5Sriastradh EXTRA_END 2943464ebd5Sriastradh}; 2953464ebd5Sriastradh 296af69d88dSmrgstatic const int extra_valid_clip_distance[] = { 297af69d88dSmrg EXTRA_VALID_CLIP_DISTANCE, 298af69d88dSmrg EXTRA_END 299af69d88dSmrg}; 300af69d88dSmrg 3013464ebd5Sriastradhstatic const int extra_flush_current_valid_texture_unit[] = { 3023464ebd5Sriastradh EXTRA_FLUSH_CURRENT, 3033464ebd5Sriastradh EXTRA_VALID_TEXTURE_UNIT, 3043464ebd5Sriastradh EXTRA_END 3053464ebd5Sriastradh}; 3063464ebd5Sriastradh 3073464ebd5Sriastradhstatic const int extra_flush_current[] = { 3083464ebd5Sriastradh EXTRA_FLUSH_CURRENT, 3093464ebd5Sriastradh EXTRA_END 3103464ebd5Sriastradh}; 3113464ebd5Sriastradh 312af69d88dSmrgstatic const int extra_EXT_texture_integer_and_new_buffers[] = { 313af69d88dSmrg EXT(EXT_texture_integer), 3143464ebd5Sriastradh EXTRA_NEW_BUFFERS, 3153464ebd5Sriastradh EXTRA_END 3163464ebd5Sriastradh}; 3173464ebd5Sriastradh 318b9abf16eSmayastatic const int extra_GLSL_130_es3_gpushader4[] = { 319af69d88dSmrg EXTRA_GLSL_130, 320af69d88dSmrg EXTRA_API_ES3, 321b9abf16eSmaya EXT(EXT_gpu_shader4), 3223464ebd5Sriastradh EXTRA_END 3233464ebd5Sriastradh}; 3243464ebd5Sriastradh 325af69d88dSmrgstatic const int extra_texture_buffer_object[] = { 326af69d88dSmrg EXT(ARB_texture_buffer_object), 3273464ebd5Sriastradh EXTRA_END 3283464ebd5Sriastradh}; 3293464ebd5Sriastradh 330af69d88dSmrgstatic const int extra_ARB_transform_feedback2_api_es3[] = { 331af69d88dSmrg EXT(ARB_transform_feedback2), 332af69d88dSmrg EXTRA_API_ES3, 3333464ebd5Sriastradh EXTRA_END 3343464ebd5Sriastradh}; 3353464ebd5Sriastradh 336af69d88dSmrgstatic const int extra_ARB_uniform_buffer_object_and_geometry_shader[] = { 33701e04c3fSmrg EXTRA_EXT_UBO_GS, 3383464ebd5Sriastradh EXTRA_END 3393464ebd5Sriastradh}; 3403464ebd5Sriastradh 341af69d88dSmrgstatic const int extra_ARB_ES2_compatibility_api_es2[] = { 342af69d88dSmrg EXT(ARB_ES2_compatibility), 343af69d88dSmrg EXTRA_API_ES2, 3443464ebd5Sriastradh EXTRA_END 3453464ebd5Sriastradh}; 3463464ebd5Sriastradh 347af69d88dSmrgstatic const int extra_ARB_ES3_compatibility_api_es3[] = { 348af69d88dSmrg EXT(ARB_ES3_compatibility), 349af69d88dSmrg EXTRA_API_ES3, 350af69d88dSmrg EXTRA_END 351af69d88dSmrg}; 352af69d88dSmrg 353af69d88dSmrgstatic const int extra_EXT_framebuffer_sRGB_and_new_buffers[] = { 354af69d88dSmrg EXT(EXT_framebuffer_sRGB), 355af69d88dSmrg EXTRA_NEW_BUFFERS, 356af69d88dSmrg EXTRA_END 357af69d88dSmrg}; 358af69d88dSmrg 359af69d88dSmrgstatic const int extra_EXT_packed_float[] = { 360af69d88dSmrg EXT(EXT_packed_float), 361af69d88dSmrg EXTRA_NEW_BUFFERS, 362af69d88dSmrg EXTRA_END 363af69d88dSmrg}; 364af69d88dSmrg 365af69d88dSmrgstatic const int extra_EXT_texture_array_es3[] = { 366af69d88dSmrg EXT(EXT_texture_array), 367af69d88dSmrg EXTRA_API_ES3, 368af69d88dSmrg EXTRA_END 369af69d88dSmrg}; 370af69d88dSmrg 371af69d88dSmrgstatic const int extra_ARB_shader_atomic_counters_and_geometry_shader[] = { 37201e04c3fSmrg EXTRA_EXT_ATOMICS_GS, 373af69d88dSmrg EXTRA_END 374af69d88dSmrg}; 375af69d88dSmrg 376af69d88dSmrgstatic const int extra_ARB_shader_image_load_store_and_geometry_shader[] = { 37701e04c3fSmrg EXTRA_EXT_SHADER_IMAGE_GS, 37801e04c3fSmrg EXTRA_END 37901e04c3fSmrg}; 38001e04c3fSmrg 38101e04c3fSmrgstatic const int extra_ARB_shader_atomic_counters_and_tessellation[] = { 38201e04c3fSmrg EXTRA_EXT_ATOMICS_TESS, 38301e04c3fSmrg EXTRA_END 38401e04c3fSmrg}; 38501e04c3fSmrg 38601e04c3fSmrgstatic const int extra_ARB_shader_image_load_store_and_tessellation[] = { 38701e04c3fSmrg EXTRA_EXT_SHADER_IMAGE_TESS, 38801e04c3fSmrg EXTRA_END 38901e04c3fSmrg}; 39001e04c3fSmrg 39101e04c3fSmrg/* HACK: remove when ARB_compute_shader is actually supported */ 39201e04c3fSmrgstatic const int extra_ARB_compute_shader_es31[] = { 39301e04c3fSmrg EXT(ARB_compute_shader), 39401e04c3fSmrg EXTRA_API_ES31, 39501e04c3fSmrg EXTRA_END 39601e04c3fSmrg}; 39701e04c3fSmrg 39801e04c3fSmrgstatic const int extra_ARB_shader_storage_buffer_object_es31[] = { 39901e04c3fSmrg EXT(ARB_shader_storage_buffer_object), 40001e04c3fSmrg EXTRA_API_ES31, 40101e04c3fSmrg EXTRA_END 40201e04c3fSmrg}; 40301e04c3fSmrg 40401e04c3fSmrgstatic const int extra_ARB_shader_storage_buffer_object_and_geometry_shader[] = { 40501e04c3fSmrg EXTRA_EXT_SSBO_GS, 40601e04c3fSmrg EXTRA_END 40701e04c3fSmrg}; 40801e04c3fSmrg 40901e04c3fSmrgstatic const int extra_ARB_shader_image_load_store_shader_storage_buffer_object_es31[] = { 41001e04c3fSmrg EXT(ARB_shader_image_load_store), 41101e04c3fSmrg EXT(ARB_shader_storage_buffer_object), 41201e04c3fSmrg EXTRA_API_ES31, 41301e04c3fSmrg EXTRA_END 41401e04c3fSmrg}; 41501e04c3fSmrg 41601e04c3fSmrgstatic const int extra_ARB_framebuffer_no_attachments_and_geometry_shader[] = { 41701e04c3fSmrg EXTRA_EXT_FB_NO_ATTACH_GS, 41801e04c3fSmrg EXTRA_END 41901e04c3fSmrg}; 42001e04c3fSmrg 42101e04c3fSmrgstatic const int extra_ARB_viewport_array_or_oes_geometry_shader[] = { 42201e04c3fSmrg EXT(ARB_viewport_array), 42301e04c3fSmrg EXTRA_EXT_ES_GS, 42401e04c3fSmrg EXTRA_END 42501e04c3fSmrg}; 42601e04c3fSmrg 42701e04c3fSmrgstatic const int extra_ARB_viewport_array_or_oes_viewport_array[] = { 42801e04c3fSmrg EXT(ARB_viewport_array), 42901e04c3fSmrg EXT(OES_viewport_array), 43001e04c3fSmrg EXTRA_END 43101e04c3fSmrg}; 43201e04c3fSmrg 43301e04c3fSmrgstatic const int extra_ARB_gpu_shader5_or_oes_geometry_shader[] = { 43401e04c3fSmrg EXT(ARB_gpu_shader5), 43501e04c3fSmrg EXTRA_EXT_ES_GS, 43601e04c3fSmrg EXTRA_END 43701e04c3fSmrg}; 43801e04c3fSmrg 43901e04c3fSmrgstatic const int extra_ARB_gpu_shader5_or_OES_sample_variables[] = { 44001e04c3fSmrg EXT(ARB_gpu_shader5), 44101e04c3fSmrg EXT(OES_sample_variables), 44201e04c3fSmrg EXTRA_END 44301e04c3fSmrg}; 44401e04c3fSmrg 44501e04c3fSmrgstatic const int extra_ES32[] = { 44601e04c3fSmrg EXT(ARB_ES3_2_compatibility), 44701e04c3fSmrg EXTRA_API_ES32, 44801e04c3fSmrg EXTRA_END 44901e04c3fSmrg}; 45001e04c3fSmrg 45101e04c3fSmrgstatic const int extra_KHR_robustness_or_GL[] = { 45201e04c3fSmrg EXT(KHR_robustness), 45301e04c3fSmrg EXTRA_API_GL, 45401e04c3fSmrg EXTRA_API_GL_CORE, 45501e04c3fSmrg EXTRA_END 45601e04c3fSmrg}; 45701e04c3fSmrg 45801e04c3fSmrgstatic const int extra_INTEL_conservative_rasterization[] = { 45901e04c3fSmrg EXT(INTEL_conservative_rasterization), 460af69d88dSmrg EXTRA_END 461af69d88dSmrg}; 4623464ebd5Sriastradh 4633464ebd5SriastradhEXTRA_EXT(ARB_texture_cube_map); 464af69d88dSmrgEXTRA_EXT(EXT_texture_array); 465af69d88dSmrgEXTRA_EXT(NV_fog_distance); 4663464ebd5SriastradhEXTRA_EXT(EXT_texture_filter_anisotropic); 4673464ebd5SriastradhEXTRA_EXT(NV_point_sprite); 4683464ebd5SriastradhEXTRA_EXT(NV_texture_rectangle); 4693464ebd5SriastradhEXTRA_EXT(EXT_stencil_two_side); 4703464ebd5SriastradhEXTRA_EXT(EXT_depth_bounds_test); 4713464ebd5SriastradhEXTRA_EXT(ARB_depth_clamp); 47201e04c3fSmrgEXTRA_EXT(AMD_depth_clamp_separate); 4733464ebd5SriastradhEXTRA_EXT(ATI_fragment_shader); 4743464ebd5SriastradhEXTRA_EXT(EXT_provoking_vertex); 4753464ebd5SriastradhEXTRA_EXT(ARB_fragment_shader); 4763464ebd5SriastradhEXTRA_EXT(ARB_fragment_program); 4773464ebd5SriastradhEXTRA_EXT2(ARB_framebuffer_object, EXT_framebuffer_multisample); 4783464ebd5SriastradhEXTRA_EXT(ARB_seamless_cube_map); 4793464ebd5SriastradhEXTRA_EXT(ARB_sync); 4803464ebd5SriastradhEXTRA_EXT(ARB_vertex_shader); 4813464ebd5SriastradhEXTRA_EXT(EXT_transform_feedback); 482af69d88dSmrgEXTRA_EXT(ARB_transform_feedback3); 4833464ebd5SriastradhEXTRA_EXT(EXT_pixel_buffer_object); 4843464ebd5SriastradhEXTRA_EXT(ARB_vertex_program); 4853464ebd5SriastradhEXTRA_EXT2(NV_point_sprite, ARB_point_sprite); 4863464ebd5SriastradhEXTRA_EXT2(ARB_vertex_program, ARB_fragment_program); 487af69d88dSmrgEXTRA_EXT(ARB_color_buffer_float); 4883464ebd5SriastradhEXTRA_EXT(EXT_framebuffer_sRGB); 489af69d88dSmrgEXTRA_EXT(OES_EGL_image_external); 490af69d88dSmrgEXTRA_EXT(ARB_blend_func_extended); 491af69d88dSmrgEXTRA_EXT(ARB_uniform_buffer_object); 492af69d88dSmrgEXTRA_EXT(ARB_timer_query); 49301e04c3fSmrgEXTRA_EXT2(ARB_texture_cube_map_array, OES_texture_cube_map_array); 494af69d88dSmrgEXTRA_EXT(ARB_texture_buffer_range); 495af69d88dSmrgEXTRA_EXT(ARB_texture_multisample); 496af69d88dSmrgEXTRA_EXT(ARB_texture_gather); 497af69d88dSmrgEXTRA_EXT(ARB_shader_atomic_counters); 498af69d88dSmrgEXTRA_EXT(ARB_draw_indirect); 499af69d88dSmrgEXTRA_EXT(ARB_shader_image_load_store); 50001e04c3fSmrgEXTRA_EXT(ARB_query_buffer_object); 501af69d88dSmrgEXTRA_EXT2(ARB_transform_feedback3, ARB_gpu_shader5); 502af69d88dSmrgEXTRA_EXT(INTEL_performance_query); 503af69d88dSmrgEXTRA_EXT(ARB_explicit_uniform_location); 50401e04c3fSmrgEXTRA_EXT(ARB_clip_control); 50501e04c3fSmrgEXTRA_EXT(ARB_polygon_offset_clamp); 50601e04c3fSmrgEXTRA_EXT(ARB_framebuffer_no_attachments); 50701e04c3fSmrgEXTRA_EXT(ARB_tessellation_shader); 50801e04c3fSmrgEXTRA_EXT(ARB_shader_storage_buffer_object); 50901e04c3fSmrgEXTRA_EXT(ARB_indirect_parameters); 51001e04c3fSmrgEXTRA_EXT(ATI_meminfo); 51101e04c3fSmrgEXTRA_EXT(NVX_gpu_memory_info); 51201e04c3fSmrgEXTRA_EXT(ARB_cull_distance); 51301e04c3fSmrgEXTRA_EXT(EXT_window_rectangles); 51401e04c3fSmrgEXTRA_EXT(KHR_blend_equation_advanced_coherent); 51501e04c3fSmrgEXTRA_EXT(OES_primitive_bounding_box); 51601e04c3fSmrgEXTRA_EXT(ARB_compute_variable_group_size); 51701e04c3fSmrgEXTRA_EXT(KHR_robustness); 51801e04c3fSmrgEXTRA_EXT(ARB_sparse_buffer); 51901e04c3fSmrgEXTRA_EXT(NV_conservative_raster); 52001e04c3fSmrgEXTRA_EXT(NV_conservative_raster_dilate); 52101e04c3fSmrgEXTRA_EXT(NV_conservative_raster_pre_snap_triangles); 52201e04c3fSmrgEXTRA_EXT(ARB_sample_locations); 52301e04c3fSmrgEXTRA_EXT(AMD_framebuffer_multisample_advanced); 5243464ebd5Sriastradh 5253464ebd5Sriastradhstatic const int 526af69d88dSmrgextra_ARB_color_buffer_float_or_glcore[] = { 527af69d88dSmrg EXT(ARB_color_buffer_float), 528af69d88dSmrg EXTRA_API_GL_CORE, 5293464ebd5Sriastradh EXTRA_END 5303464ebd5Sriastradh}; 5313464ebd5Sriastradh 5323464ebd5Sriastradhstatic const int 5333464ebd5Sriastradhextra_NV_primitive_restart[] = { 5343464ebd5Sriastradh EXT(NV_primitive_restart), 5353464ebd5Sriastradh EXTRA_END 5363464ebd5Sriastradh}; 5373464ebd5Sriastradh 5383464ebd5Sriastradhstatic const int extra_version_30[] = { EXTRA_VERSION_30, EXTRA_END }; 5393464ebd5Sriastradhstatic const int extra_version_31[] = { EXTRA_VERSION_31, EXTRA_END }; 5403464ebd5Sriastradhstatic const int extra_version_32[] = { EXTRA_VERSION_32, EXTRA_END }; 54101e04c3fSmrgstatic const int extra_version_43[] = { EXTRA_VERSION_43, EXTRA_END }; 542af69d88dSmrg 543af69d88dSmrgstatic const int extra_gl30_es3[] = { 544af69d88dSmrg EXTRA_VERSION_30, 545af69d88dSmrg EXTRA_API_ES3, 546af69d88dSmrg EXTRA_END, 547af69d88dSmrg}; 548af69d88dSmrg 549af69d88dSmrgstatic const int extra_gl32_es3[] = { 550af69d88dSmrg EXTRA_VERSION_32, 551af69d88dSmrg EXTRA_API_ES3, 552af69d88dSmrg EXTRA_END, 553af69d88dSmrg}; 554af69d88dSmrg 55501e04c3fSmrgstatic const int extra_version_32_OES_geometry_shader[] = { 556af69d88dSmrg EXTRA_VERSION_32, 55701e04c3fSmrg EXTRA_EXT_ES_GS, 558af69d88dSmrg EXTRA_END 559af69d88dSmrg}; 560af69d88dSmrg 561af69d88dSmrgstatic const int extra_gl40_ARB_sample_shading[] = { 562af69d88dSmrg EXTRA_VERSION_40, 563af69d88dSmrg EXT(ARB_sample_shading), 564af69d88dSmrg EXTRA_END 565af69d88dSmrg}; 5663464ebd5Sriastradh 5673464ebd5Sriastradhstatic const int 568af69d88dSmrgextra_ARB_vertex_program_api_es2[] = { 5693464ebd5Sriastradh EXT(ARB_vertex_program), 570af69d88dSmrg EXTRA_API_ES2, 571af69d88dSmrg EXTRA_END 572af69d88dSmrg}; 573af69d88dSmrg 574af69d88dSmrg/* The ReadBuffer get token is valid under either full GL or under 575af69d88dSmrg * GLES2 if the NV_read_buffer extension is available. */ 576af69d88dSmrgstatic const int 577af69d88dSmrgextra_NV_read_buffer_api_gl[] = { 578af69d88dSmrg EXTRA_API_ES2, 579af69d88dSmrg EXTRA_API_GL, 5803464ebd5Sriastradh EXTRA_END 5813464ebd5Sriastradh}; 5823464ebd5Sriastradh 583af69d88dSmrgstatic const int extra_core_ARB_color_buffer_float_and_new_buffers[] = { 584af69d88dSmrg EXTRA_API_GL_CORE, 585af69d88dSmrg EXT(ARB_color_buffer_float), 586af69d88dSmrg EXTRA_NEW_BUFFERS, 587af69d88dSmrg EXTRA_END 588af69d88dSmrg}; 5893464ebd5Sriastradh 59001e04c3fSmrgstatic const int extra_EXT_shader_framebuffer_fetch[] = { 59101e04c3fSmrg EXTRA_API_ES2, 59201e04c3fSmrg EXTRA_API_ES3, 59301e04c3fSmrg EXT(EXT_shader_framebuffer_fetch), 59401e04c3fSmrg EXTRA_END 59501e04c3fSmrg}; 59601e04c3fSmrg 59701e04c3fSmrgstatic const int extra_EXT_provoking_vertex_32[] = { 59801e04c3fSmrg EXTRA_EXT_PROVOKING_VERTEX_32, 59901e04c3fSmrg EXTRA_END 60001e04c3fSmrg}; 60101e04c3fSmrg 60201e04c3fSmrgstatic const int extra_EXT_disjoint_timer_query[] = { 60301e04c3fSmrg EXTRA_API_ES2, 60401e04c3fSmrg EXTRA_API_ES3, 60501e04c3fSmrg EXT(EXT_disjoint_timer_query), 60601e04c3fSmrg EXTRA_END 60701e04c3fSmrg}; 60801e04c3fSmrg 60901e04c3fSmrg 6103464ebd5Sriastradh/* This is the big table describing all the enums we accept in 6113464ebd5Sriastradh * glGet*v(). The table is partitioned into six parts: enums 6123464ebd5Sriastradh * understood by all GL APIs (OpenGL, GLES and GLES2), enums shared 6133464ebd5Sriastradh * between OpenGL and GLES, enums exclusive to GLES, etc for the 614af69d88dSmrg * remaining combinations. To look up the enums valid in a given API 615af69d88dSmrg * we will use a hash table specific to that API. These tables are in 616af69d88dSmrg * turn generated at build time and included through get_hash.h. 617af69d88dSmrg */ 6183464ebd5Sriastradh 619af69d88dSmrg#include "get_hash.h" 6203464ebd5Sriastradh 6213464ebd5Sriastradh/* All we need now is a way to look up the value struct from the enum. 6223464ebd5Sriastradh * The code generated by gcc for the old generated big switch 6233464ebd5Sriastradh * statement is a big, balanced, open coded if/else tree, essentially 6243464ebd5Sriastradh * an unrolled binary search. It would be natural to sort the new 6253464ebd5Sriastradh * enum table and use bsearch(), but we will use a read-only hash 6263464ebd5Sriastradh * table instead. bsearch() has a nice guaranteed worst case 6273464ebd5Sriastradh * performance, but we're also guaranteed to hit that worst case 6283464ebd5Sriastradh * (log2(n) iterations) for about half the enums. Instead, using an 6293464ebd5Sriastradh * open addressing hash table, we can find the enum on the first try 6303464ebd5Sriastradh * for 80% of the enums, 1 collision for 10% and never more than 5 6313464ebd5Sriastradh * collisions for any enum (typical numbers). And the code is very 6323464ebd5Sriastradh * simple, even though it feels a little magic. */ 6333464ebd5Sriastradh 6343464ebd5Sriastradh/** 6353464ebd5Sriastradh * Handle irregular enums 6363464ebd5Sriastradh * 6373464ebd5Sriastradh * Some values don't conform to the "well-known type at context 6383464ebd5Sriastradh * pointer + offset" pattern, so we have this function to catch all 6393464ebd5Sriastradh * the corner cases. Typically, it's a computed value or a one-off 6403464ebd5Sriastradh * pointer to a custom struct or something. 6413464ebd5Sriastradh * 6423464ebd5Sriastradh * In this case we can't return a pointer to the value, so we'll have 6433464ebd5Sriastradh * to use the temporary variable 'v' declared back in the calling 6443464ebd5Sriastradh * glGet*v() function to store the result. 6453464ebd5Sriastradh * 6463464ebd5Sriastradh * \param ctx the current context 6473464ebd5Sriastradh * \param d the struct value_desc that describes the enum 6483464ebd5Sriastradh * \param v pointer to the tmp declared in the calling glGet*v() function 6493464ebd5Sriastradh */ 6503464ebd5Sriastradhstatic void 6513464ebd5Sriastradhfind_custom_value(struct gl_context *ctx, const struct value_desc *d, union value *v) 6523464ebd5Sriastradh{ 6533464ebd5Sriastradh struct gl_buffer_object **buffer_obj; 65401e04c3fSmrg struct gl_array_attributes *array; 6553464ebd5Sriastradh GLuint unit, *p; 6563464ebd5Sriastradh 6573464ebd5Sriastradh switch (d->pname) { 658af69d88dSmrg case GL_MAJOR_VERSION: 659af69d88dSmrg v->value_int = ctx->Version / 10; 660af69d88dSmrg break; 661af69d88dSmrg case GL_MINOR_VERSION: 662af69d88dSmrg v->value_int = ctx->Version % 10; 663af69d88dSmrg break; 664af69d88dSmrg 6653464ebd5Sriastradh case GL_TEXTURE_1D: 6663464ebd5Sriastradh case GL_TEXTURE_2D: 6673464ebd5Sriastradh case GL_TEXTURE_3D: 66801e04c3fSmrg case GL_TEXTURE_CUBE_MAP: 6693464ebd5Sriastradh case GL_TEXTURE_RECTANGLE_NV: 670af69d88dSmrg case GL_TEXTURE_EXTERNAL_OES: 6713464ebd5Sriastradh v->value_bool = _mesa_IsEnabled(d->pname); 6723464ebd5Sriastradh break; 6733464ebd5Sriastradh 6743464ebd5Sriastradh case GL_LINE_STIPPLE_PATTERN: 6753464ebd5Sriastradh /* This is the only GLushort, special case it here by promoting 6763464ebd5Sriastradh * to an int rather than introducing a new type. */ 6773464ebd5Sriastradh v->value_int = ctx->Line.StipplePattern; 6783464ebd5Sriastradh break; 6793464ebd5Sriastradh 6803464ebd5Sriastradh case GL_CURRENT_RASTER_TEXTURE_COORDS: 6813464ebd5Sriastradh unit = ctx->Texture.CurrentUnit; 6823464ebd5Sriastradh v->value_float_4[0] = ctx->Current.RasterTexCoords[unit][0]; 6833464ebd5Sriastradh v->value_float_4[1] = ctx->Current.RasterTexCoords[unit][1]; 6843464ebd5Sriastradh v->value_float_4[2] = ctx->Current.RasterTexCoords[unit][2]; 6853464ebd5Sriastradh v->value_float_4[3] = ctx->Current.RasterTexCoords[unit][3]; 6863464ebd5Sriastradh break; 6873464ebd5Sriastradh 6883464ebd5Sriastradh case GL_CURRENT_TEXTURE_COORDS: 6893464ebd5Sriastradh unit = ctx->Texture.CurrentUnit; 6903464ebd5Sriastradh v->value_float_4[0] = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][0]; 6913464ebd5Sriastradh v->value_float_4[1] = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][1]; 6923464ebd5Sriastradh v->value_float_4[2] = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][2]; 6933464ebd5Sriastradh v->value_float_4[3] = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][3]; 6943464ebd5Sriastradh break; 6953464ebd5Sriastradh 6963464ebd5Sriastradh case GL_COLOR_WRITEMASK: 69701e04c3fSmrg v->value_int_4[0] = GET_COLORMASK_BIT(ctx->Color.ColorMask, 0, 0); 69801e04c3fSmrg v->value_int_4[1] = GET_COLORMASK_BIT(ctx->Color.ColorMask, 0, 1); 69901e04c3fSmrg v->value_int_4[2] = GET_COLORMASK_BIT(ctx->Color.ColorMask, 0, 2); 70001e04c3fSmrg v->value_int_4[3] = GET_COLORMASK_BIT(ctx->Color.ColorMask, 0, 3); 70101e04c3fSmrg break; 70201e04c3fSmrg 70301e04c3fSmrg case GL_DEPTH_CLAMP: 70401e04c3fSmrg v->value_bool = ctx->Transform.DepthClampNear || ctx->Transform.DepthClampFar; 7053464ebd5Sriastradh break; 7063464ebd5Sriastradh 7073464ebd5Sriastradh case GL_EDGE_FLAG: 70801e04c3fSmrg v->value_bool = ctx->Current.Attrib[VERT_ATTRIB_EDGEFLAG][0] == 1.0F; 7093464ebd5Sriastradh break; 7103464ebd5Sriastradh 7113464ebd5Sriastradh case GL_READ_BUFFER: 7123464ebd5Sriastradh v->value_enum = ctx->ReadBuffer->ColorReadBuffer; 7133464ebd5Sriastradh break; 7143464ebd5Sriastradh 7153464ebd5Sriastradh case GL_MAP2_GRID_DOMAIN: 7163464ebd5Sriastradh v->value_float_4[0] = ctx->Eval.MapGrid2u1; 7173464ebd5Sriastradh v->value_float_4[1] = ctx->Eval.MapGrid2u2; 7183464ebd5Sriastradh v->value_float_4[2] = ctx->Eval.MapGrid2v1; 7193464ebd5Sriastradh v->value_float_4[3] = ctx->Eval.MapGrid2v2; 7203464ebd5Sriastradh break; 7213464ebd5Sriastradh 7223464ebd5Sriastradh case GL_TEXTURE_STACK_DEPTH: 7233464ebd5Sriastradh unit = ctx->Texture.CurrentUnit; 7243464ebd5Sriastradh v->value_int = ctx->TextureMatrixStack[unit].Depth + 1; 7253464ebd5Sriastradh break; 7263464ebd5Sriastradh case GL_TEXTURE_MATRIX: 7273464ebd5Sriastradh unit = ctx->Texture.CurrentUnit; 7283464ebd5Sriastradh v->value_matrix = ctx->TextureMatrixStack[unit].Top; 7293464ebd5Sriastradh break; 7303464ebd5Sriastradh 731b9abf16eSmaya case GL_VERTEX_ARRAY: 732b9abf16eSmaya v->value_bool = !!(ctx->Array.VAO->Enabled & VERT_BIT_POS); 733b9abf16eSmaya break; 734b9abf16eSmaya case GL_NORMAL_ARRAY: 735b9abf16eSmaya v->value_bool = !!(ctx->Array.VAO->Enabled & VERT_BIT_NORMAL); 736b9abf16eSmaya break; 737b9abf16eSmaya case GL_COLOR_ARRAY: 738b9abf16eSmaya v->value_bool = !!(ctx->Array.VAO->Enabled & VERT_BIT_COLOR0); 739b9abf16eSmaya break; 7403464ebd5Sriastradh case GL_TEXTURE_COORD_ARRAY: 741b9abf16eSmaya v->value_bool = !!(ctx->Array.VAO->Enabled & VERT_BIT_TEX(ctx->Array.ActiveTexture)); 742b9abf16eSmaya break; 743b9abf16eSmaya case GL_INDEX_ARRAY: 744b9abf16eSmaya v->value_bool = !!(ctx->Array.VAO->Enabled & VERT_BIT_COLOR_INDEX); 745b9abf16eSmaya break; 746b9abf16eSmaya case GL_EDGE_FLAG_ARRAY: 747b9abf16eSmaya v->value_bool = !!(ctx->Array.VAO->Enabled & VERT_BIT_EDGEFLAG); 748b9abf16eSmaya break; 749b9abf16eSmaya case GL_SECONDARY_COLOR_ARRAY: 750b9abf16eSmaya v->value_bool = !!(ctx->Array.VAO->Enabled & VERT_BIT_COLOR1); 751b9abf16eSmaya break; 752b9abf16eSmaya case GL_FOG_COORDINATE_ARRAY: 753b9abf16eSmaya v->value_bool = !!(ctx->Array.VAO->Enabled & VERT_BIT_FOG); 754b9abf16eSmaya break; 755b9abf16eSmaya case GL_POINT_SIZE_ARRAY_OES: 756b9abf16eSmaya v->value_bool = !!(ctx->Array.VAO->Enabled & VERT_BIT_POINT_SIZE); 757b9abf16eSmaya break; 758b9abf16eSmaya 7593464ebd5Sriastradh case GL_TEXTURE_COORD_ARRAY_TYPE: 7603464ebd5Sriastradh case GL_TEXTURE_COORD_ARRAY_STRIDE: 761af69d88dSmrg array = &ctx->Array.VAO->VertexAttrib[VERT_ATTRIB_TEX(ctx->Array.ActiveTexture)]; 7623464ebd5Sriastradh v->value_int = *(GLuint *) ((char *) array + d->offset); 7633464ebd5Sriastradh break; 7643464ebd5Sriastradh 765b9abf16eSmaya case GL_TEXTURE_COORD_ARRAY_SIZE: 766b9abf16eSmaya array = &ctx->Array.VAO->VertexAttrib[VERT_ATTRIB_TEX(ctx->Array.ActiveTexture)]; 767b9abf16eSmaya v->value_int = array->Format.Size; 768b9abf16eSmaya break; 769b9abf16eSmaya 770b9abf16eSmaya case GL_VERTEX_ARRAY_SIZE: 771b9abf16eSmaya array = &ctx->Array.VAO->VertexAttrib[VERT_ATTRIB_POS]; 772b9abf16eSmaya v->value_int = array->Format.Size; 773b9abf16eSmaya break; 774b9abf16eSmaya 7753464ebd5Sriastradh case GL_ACTIVE_TEXTURE_ARB: 7763464ebd5Sriastradh v->value_int = GL_TEXTURE0_ARB + ctx->Texture.CurrentUnit; 7773464ebd5Sriastradh break; 7783464ebd5Sriastradh case GL_CLIENT_ACTIVE_TEXTURE_ARB: 7793464ebd5Sriastradh v->value_int = GL_TEXTURE0_ARB + ctx->Array.ActiveTexture; 7803464ebd5Sriastradh break; 7813464ebd5Sriastradh 7823464ebd5Sriastradh case GL_MODELVIEW_STACK_DEPTH: 7833464ebd5Sriastradh case GL_PROJECTION_STACK_DEPTH: 7843464ebd5Sriastradh v->value_int = *(GLint *) ((char *) ctx + d->offset) + 1; 7853464ebd5Sriastradh break; 7863464ebd5Sriastradh 7873464ebd5Sriastradh case GL_MAX_TEXTURE_SIZE: 7883464ebd5Sriastradh case GL_MAX_3D_TEXTURE_SIZE: 7893464ebd5Sriastradh case GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB: 7903464ebd5Sriastradh p = (GLuint *) ((char *) ctx + d->offset); 7913464ebd5Sriastradh v->value_int = 1 << (*p - 1); 7923464ebd5Sriastradh break; 7933464ebd5Sriastradh 7943464ebd5Sriastradh case GL_SCISSOR_BOX: 795af69d88dSmrg v->value_int_4[0] = ctx->Scissor.ScissorArray[0].X; 796af69d88dSmrg v->value_int_4[1] = ctx->Scissor.ScissorArray[0].Y; 797af69d88dSmrg v->value_int_4[2] = ctx->Scissor.ScissorArray[0].Width; 798af69d88dSmrg v->value_int_4[3] = ctx->Scissor.ScissorArray[0].Height; 799af69d88dSmrg break; 800af69d88dSmrg 801af69d88dSmrg case GL_SCISSOR_TEST: 802af69d88dSmrg v->value_bool = ctx->Scissor.EnableFlags & 1; 8033464ebd5Sriastradh break; 8043464ebd5Sriastradh 8053464ebd5Sriastradh case GL_LIST_INDEX: 8063464ebd5Sriastradh v->value_int = 80701e04c3fSmrg ctx->ListState.CurrentList ? ctx->ListState.CurrentList->Name : 0; 8083464ebd5Sriastradh break; 8093464ebd5Sriastradh case GL_LIST_MODE: 8103464ebd5Sriastradh if (!ctx->CompileFlag) 81101e04c3fSmrg v->value_enum = 0; 8123464ebd5Sriastradh else if (ctx->ExecuteFlag) 81301e04c3fSmrg v->value_enum = GL_COMPILE_AND_EXECUTE; 8143464ebd5Sriastradh else 81501e04c3fSmrg v->value_enum = GL_COMPILE; 8163464ebd5Sriastradh break; 8173464ebd5Sriastradh 8183464ebd5Sriastradh case GL_VIEWPORT: 819af69d88dSmrg v->value_float_4[0] = ctx->ViewportArray[0].X; 820af69d88dSmrg v->value_float_4[1] = ctx->ViewportArray[0].Y; 821af69d88dSmrg v->value_float_4[2] = ctx->ViewportArray[0].Width; 822af69d88dSmrg v->value_float_4[3] = ctx->ViewportArray[0].Height; 823af69d88dSmrg break; 824af69d88dSmrg 825af69d88dSmrg case GL_DEPTH_RANGE: 826af69d88dSmrg v->value_double_2[0] = ctx->ViewportArray[0].Near; 827af69d88dSmrg v->value_double_2[1] = ctx->ViewportArray[0].Far; 8283464ebd5Sriastradh break; 8293464ebd5Sriastradh 8303464ebd5Sriastradh case GL_ACTIVE_STENCIL_FACE_EXT: 8313464ebd5Sriastradh v->value_enum = ctx->Stencil.ActiveFace ? GL_BACK : GL_FRONT; 8323464ebd5Sriastradh break; 8333464ebd5Sriastradh 8343464ebd5Sriastradh case GL_STENCIL_FAIL: 8353464ebd5Sriastradh v->value_enum = ctx->Stencil.FailFunc[ctx->Stencil.ActiveFace]; 8363464ebd5Sriastradh break; 8373464ebd5Sriastradh case GL_STENCIL_FUNC: 8383464ebd5Sriastradh v->value_enum = ctx->Stencil.Function[ctx->Stencil.ActiveFace]; 8393464ebd5Sriastradh break; 8403464ebd5Sriastradh case GL_STENCIL_PASS_DEPTH_FAIL: 8413464ebd5Sriastradh v->value_enum = ctx->Stencil.ZFailFunc[ctx->Stencil.ActiveFace]; 8423464ebd5Sriastradh break; 8433464ebd5Sriastradh case GL_STENCIL_PASS_DEPTH_PASS: 8443464ebd5Sriastradh v->value_enum = ctx->Stencil.ZPassFunc[ctx->Stencil.ActiveFace]; 8453464ebd5Sriastradh break; 8463464ebd5Sriastradh case GL_STENCIL_REF: 847af69d88dSmrg v->value_int = _mesa_get_stencil_ref(ctx, ctx->Stencil.ActiveFace); 848af69d88dSmrg break; 849af69d88dSmrg case GL_STENCIL_BACK_REF: 850af69d88dSmrg v->value_int = _mesa_get_stencil_ref(ctx, 1); 8513464ebd5Sriastradh break; 8523464ebd5Sriastradh case GL_STENCIL_VALUE_MASK: 8533464ebd5Sriastradh v->value_int = ctx->Stencil.ValueMask[ctx->Stencil.ActiveFace]; 8543464ebd5Sriastradh break; 8553464ebd5Sriastradh case GL_STENCIL_WRITEMASK: 8563464ebd5Sriastradh v->value_int = ctx->Stencil.WriteMask[ctx->Stencil.ActiveFace]; 8573464ebd5Sriastradh break; 8583464ebd5Sriastradh 8593464ebd5Sriastradh case GL_NUM_EXTENSIONS: 8603464ebd5Sriastradh v->value_int = _mesa_get_extension_count(ctx); 8613464ebd5Sriastradh break; 8623464ebd5Sriastradh 8633464ebd5Sriastradh case GL_IMPLEMENTATION_COLOR_READ_TYPE_OES: 86401e04c3fSmrg v->value_int = _mesa_get_color_read_type(ctx, NULL, "glGetIntegerv"); 8653464ebd5Sriastradh break; 8663464ebd5Sriastradh case GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES: 86701e04c3fSmrg v->value_int = _mesa_get_color_read_format(ctx, NULL, "glGetIntegerv"); 8683464ebd5Sriastradh break; 8693464ebd5Sriastradh 8703464ebd5Sriastradh case GL_CURRENT_MATRIX_STACK_DEPTH_ARB: 8713464ebd5Sriastradh v->value_int = ctx->CurrentStack->Depth + 1; 8723464ebd5Sriastradh break; 8733464ebd5Sriastradh case GL_CURRENT_MATRIX_ARB: 8743464ebd5Sriastradh case GL_TRANSPOSE_CURRENT_MATRIX_ARB: 8753464ebd5Sriastradh v->value_matrix = ctx->CurrentStack->Top; 8763464ebd5Sriastradh break; 8773464ebd5Sriastradh 8783464ebd5Sriastradh case GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB: 8793464ebd5Sriastradh v->value_int = _mesa_get_compressed_formats(ctx, NULL); 8803464ebd5Sriastradh break; 8813464ebd5Sriastradh case GL_COMPRESSED_TEXTURE_FORMATS_ARB: 88201e04c3fSmrg v->value_int_n.n = 88301e04c3fSmrg _mesa_get_compressed_formats(ctx, v->value_int_n.ints); 88401e04c3fSmrg assert(v->value_int_n.n <= (int) ARRAY_SIZE(v->value_int_n.ints)); 8853464ebd5Sriastradh break; 8863464ebd5Sriastradh 8873464ebd5Sriastradh case GL_MAX_VARYING_FLOATS_ARB: 8883464ebd5Sriastradh v->value_int = ctx->Const.MaxVarying * 4; 8893464ebd5Sriastradh break; 8903464ebd5Sriastradh 8913464ebd5Sriastradh /* Various object names */ 8923464ebd5Sriastradh 8933464ebd5Sriastradh case GL_TEXTURE_BINDING_1D: 8943464ebd5Sriastradh case GL_TEXTURE_BINDING_2D: 8953464ebd5Sriastradh case GL_TEXTURE_BINDING_3D: 8963464ebd5Sriastradh case GL_TEXTURE_BINDING_1D_ARRAY_EXT: 8973464ebd5Sriastradh case GL_TEXTURE_BINDING_2D_ARRAY_EXT: 8983464ebd5Sriastradh case GL_TEXTURE_BINDING_CUBE_MAP_ARB: 8993464ebd5Sriastradh case GL_TEXTURE_BINDING_RECTANGLE_NV: 900af69d88dSmrg case GL_TEXTURE_BINDING_EXTERNAL_OES: 901af69d88dSmrg case GL_TEXTURE_BINDING_CUBE_MAP_ARRAY: 902af69d88dSmrg case GL_TEXTURE_BINDING_2D_MULTISAMPLE: 903af69d88dSmrg case GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY: 9043464ebd5Sriastradh unit = ctx->Texture.CurrentUnit; 9053464ebd5Sriastradh v->value_int = 90601e04c3fSmrg ctx->Texture.Unit[unit].CurrentTex[d->offset]->Name; 90701e04c3fSmrg break; 90801e04c3fSmrg 90901e04c3fSmrg /* GL_EXT_external_objects */ 910993e1d59Smrg case GL_NUM_DEVICE_UUIDS_EXT: 911993e1d59Smrg v->value_int = 1; 912993e1d59Smrg break; 91301e04c3fSmrg case GL_DRIVER_UUID_EXT: 91401e04c3fSmrg _mesa_get_driver_uuid(ctx, v->value_int_4); 91501e04c3fSmrg break; 91601e04c3fSmrg case GL_DEVICE_UUID_EXT: 91701e04c3fSmrg _mesa_get_device_uuid(ctx, v->value_int_4); 9183464ebd5Sriastradh break; 9193464ebd5Sriastradh 920af69d88dSmrg /* GL_EXT_packed_float */ 921af69d88dSmrg case GL_RGBA_SIGNED_COMPONENTS_EXT: 922af69d88dSmrg { 923af69d88dSmrg /* Note: we only check the 0th color attachment. */ 924af69d88dSmrg const struct gl_renderbuffer *rb = 925af69d88dSmrg ctx->DrawBuffer->_ColorDrawBuffers[0]; 926af69d88dSmrg if (rb && _mesa_is_format_signed(rb->Format)) { 927af69d88dSmrg /* Issue 17 of GL_EXT_packed_float: If a component (such as 928af69d88dSmrg * alpha) has zero bits, the component should not be considered 929af69d88dSmrg * signed and so the bit for the respective component should be 930af69d88dSmrg * zeroed. 931af69d88dSmrg */ 932af69d88dSmrg GLint r_bits = 933af69d88dSmrg _mesa_get_format_bits(rb->Format, GL_RED_BITS); 934af69d88dSmrg GLint g_bits = 935af69d88dSmrg _mesa_get_format_bits(rb->Format, GL_GREEN_BITS); 936af69d88dSmrg GLint b_bits = 937af69d88dSmrg _mesa_get_format_bits(rb->Format, GL_BLUE_BITS); 938af69d88dSmrg GLint a_bits = 939af69d88dSmrg _mesa_get_format_bits(rb->Format, GL_ALPHA_BITS); 940af69d88dSmrg GLint l_bits = 941af69d88dSmrg _mesa_get_format_bits(rb->Format, GL_TEXTURE_LUMINANCE_SIZE); 942af69d88dSmrg GLint i_bits = 943af69d88dSmrg _mesa_get_format_bits(rb->Format, GL_TEXTURE_INTENSITY_SIZE); 944af69d88dSmrg 945af69d88dSmrg v->value_int_4[0] = r_bits + l_bits + i_bits > 0; 946af69d88dSmrg v->value_int_4[1] = g_bits + l_bits + i_bits > 0; 947af69d88dSmrg v->value_int_4[2] = b_bits + l_bits + i_bits > 0; 948af69d88dSmrg v->value_int_4[3] = a_bits + i_bits > 0; 949af69d88dSmrg } 950af69d88dSmrg else { 951af69d88dSmrg v->value_int_4[0] = 952af69d88dSmrg v->value_int_4[1] = 953af69d88dSmrg v->value_int_4[2] = 954af69d88dSmrg v->value_int_4[3] = 0; 955af69d88dSmrg } 956af69d88dSmrg } 957af69d88dSmrg break; 958af69d88dSmrg 9593464ebd5Sriastradh /* GL_ARB_vertex_buffer_object */ 9603464ebd5Sriastradh case GL_VERTEX_ARRAY_BUFFER_BINDING_ARB: 9613464ebd5Sriastradh case GL_NORMAL_ARRAY_BUFFER_BINDING_ARB: 9623464ebd5Sriastradh case GL_COLOR_ARRAY_BUFFER_BINDING_ARB: 9633464ebd5Sriastradh case GL_INDEX_ARRAY_BUFFER_BINDING_ARB: 9643464ebd5Sriastradh case GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB: 9653464ebd5Sriastradh case GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB: 9663464ebd5Sriastradh case GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB: 9673464ebd5Sriastradh buffer_obj = (struct gl_buffer_object **) 96801e04c3fSmrg ((char *) ctx->Array.VAO + d->offset); 9693464ebd5Sriastradh v->value_int = (*buffer_obj)->Name; 9703464ebd5Sriastradh break; 9713464ebd5Sriastradh case GL_ARRAY_BUFFER_BINDING_ARB: 9723464ebd5Sriastradh v->value_int = ctx->Array.ArrayBufferObj->Name; 9733464ebd5Sriastradh break; 9743464ebd5Sriastradh case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB: 9753464ebd5Sriastradh v->value_int = 97601e04c3fSmrg ctx->Array.VAO->BufferBinding[VERT_ATTRIB_TEX(ctx->Array.ActiveTexture)].BufferObj->Name; 9773464ebd5Sriastradh break; 9783464ebd5Sriastradh case GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB: 979af69d88dSmrg v->value_int = ctx->Array.VAO->IndexBufferObj->Name; 980af69d88dSmrg break; 981af69d88dSmrg 982af69d88dSmrg /* ARB_vertex_array_bgra */ 983af69d88dSmrg case GL_COLOR_ARRAY_SIZE: 984af69d88dSmrg array = &ctx->Array.VAO->VertexAttrib[VERT_ATTRIB_COLOR0]; 985b9abf16eSmaya v->value_int = array->Format.Format == GL_BGRA ? GL_BGRA : array->Format.Size; 986af69d88dSmrg break; 987af69d88dSmrg case GL_SECONDARY_COLOR_ARRAY_SIZE: 988af69d88dSmrg array = &ctx->Array.VAO->VertexAttrib[VERT_ATTRIB_COLOR1]; 989b9abf16eSmaya v->value_int = array->Format.Format == GL_BGRA ? GL_BGRA : array->Format.Size; 9903464ebd5Sriastradh break; 9913464ebd5Sriastradh 9923464ebd5Sriastradh /* ARB_copy_buffer */ 9933464ebd5Sriastradh case GL_COPY_READ_BUFFER: 9943464ebd5Sriastradh v->value_int = ctx->CopyReadBuffer->Name; 9953464ebd5Sriastradh break; 9963464ebd5Sriastradh case GL_COPY_WRITE_BUFFER: 9973464ebd5Sriastradh v->value_int = ctx->CopyWriteBuffer->Name; 9983464ebd5Sriastradh break; 9993464ebd5Sriastradh 10003464ebd5Sriastradh case GL_PIXEL_PACK_BUFFER_BINDING_EXT: 10013464ebd5Sriastradh v->value_int = ctx->Pack.BufferObj->Name; 10023464ebd5Sriastradh break; 10033464ebd5Sriastradh case GL_PIXEL_UNPACK_BUFFER_BINDING_EXT: 10043464ebd5Sriastradh v->value_int = ctx->Unpack.BufferObj->Name; 10053464ebd5Sriastradh break; 10063464ebd5Sriastradh case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING: 10073464ebd5Sriastradh v->value_int = ctx->TransformFeedback.CurrentBuffer->Name; 10083464ebd5Sriastradh break; 10093464ebd5Sriastradh case GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED: 10103464ebd5Sriastradh v->value_int = ctx->TransformFeedback.CurrentObject->Paused; 10113464ebd5Sriastradh break; 10123464ebd5Sriastradh case GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE: 10133464ebd5Sriastradh v->value_int = ctx->TransformFeedback.CurrentObject->Active; 10143464ebd5Sriastradh break; 10153464ebd5Sriastradh case GL_TRANSFORM_FEEDBACK_BINDING: 10163464ebd5Sriastradh v->value_int = ctx->TransformFeedback.CurrentObject->Name; 10173464ebd5Sriastradh break; 10183464ebd5Sriastradh case GL_CURRENT_PROGRAM: 1019af69d88dSmrg /* The Changelog of the ARB_separate_shader_objects spec says: 1020af69d88dSmrg * 1021af69d88dSmrg * 24 25 Jul 2011 pbrown Remove the language erroneously deleting 1022af69d88dSmrg * CURRENT_PROGRAM. In the EXT extension, this 1023af69d88dSmrg * token was aliased to ACTIVE_PROGRAM_EXT, and 1024af69d88dSmrg * was used to indicate the last program set by 1025af69d88dSmrg * either ActiveProgramEXT or UseProgram. In 1026af69d88dSmrg * the ARB extension, the SSO active programs 1027af69d88dSmrg * are now program pipeline object state and 1028af69d88dSmrg * CURRENT_PROGRAM should still be used to query 1029af69d88dSmrg * the last program set by UseProgram (bug 7822). 1030af69d88dSmrg */ 10313464ebd5Sriastradh v->value_int = 103201e04c3fSmrg ctx->Shader.ActiveProgram ? ctx->Shader.ActiveProgram->Name : 0; 10333464ebd5Sriastradh break; 10343464ebd5Sriastradh case GL_READ_FRAMEBUFFER_BINDING_EXT: 10353464ebd5Sriastradh v->value_int = ctx->ReadBuffer->Name; 10363464ebd5Sriastradh break; 10373464ebd5Sriastradh case GL_RENDERBUFFER_BINDING_EXT: 10383464ebd5Sriastradh v->value_int = 103901e04c3fSmrg ctx->CurrentRenderbuffer ? ctx->CurrentRenderbuffer->Name : 0; 10403464ebd5Sriastradh break; 10413464ebd5Sriastradh case GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES: 104201e04c3fSmrg v->value_int = ctx->Array.VAO->BufferBinding[VERT_ATTRIB_POINT_SIZE].BufferObj->Name; 10433464ebd5Sriastradh break; 10443464ebd5Sriastradh 10453464ebd5Sriastradh case GL_FOG_COLOR: 104601e04c3fSmrg if (_mesa_get_clamp_fragment_color(ctx, ctx->DrawBuffer)) 10473464ebd5Sriastradh COPY_4FV(v->value_float_4, ctx->Fog.Color); 10483464ebd5Sriastradh else 10493464ebd5Sriastradh COPY_4FV(v->value_float_4, ctx->Fog.ColorUnclamped); 10503464ebd5Sriastradh break; 10513464ebd5Sriastradh case GL_COLOR_CLEAR_VALUE: 105201e04c3fSmrg if (_mesa_get_clamp_fragment_color(ctx, ctx->DrawBuffer)) { 1053af69d88dSmrg v->value_float_4[0] = CLAMP(ctx->Color.ClearColor.f[0], 0.0F, 1.0F); 1054af69d88dSmrg v->value_float_4[1] = CLAMP(ctx->Color.ClearColor.f[1], 0.0F, 1.0F); 1055af69d88dSmrg v->value_float_4[2] = CLAMP(ctx->Color.ClearColor.f[2], 0.0F, 1.0F); 1056af69d88dSmrg v->value_float_4[3] = CLAMP(ctx->Color.ClearColor.f[3], 0.0F, 1.0F); 1057af69d88dSmrg } else 1058af69d88dSmrg COPY_4FV(v->value_float_4, ctx->Color.ClearColor.f); 10593464ebd5Sriastradh break; 10603464ebd5Sriastradh case GL_BLEND_COLOR_EXT: 106101e04c3fSmrg if (_mesa_get_clamp_fragment_color(ctx, ctx->DrawBuffer)) 10623464ebd5Sriastradh COPY_4FV(v->value_float_4, ctx->Color.BlendColor); 10633464ebd5Sriastradh else 10643464ebd5Sriastradh COPY_4FV(v->value_float_4, ctx->Color.BlendColorUnclamped); 10653464ebd5Sriastradh break; 10663464ebd5Sriastradh case GL_ALPHA_TEST_REF: 106701e04c3fSmrg if (_mesa_get_clamp_fragment_color(ctx, ctx->DrawBuffer)) 10683464ebd5Sriastradh v->value_float = ctx->Color.AlphaRef; 10693464ebd5Sriastradh else 10703464ebd5Sriastradh v->value_float = ctx->Color.AlphaRefUnclamped; 10713464ebd5Sriastradh break; 10723464ebd5Sriastradh case GL_MAX_VERTEX_UNIFORM_VECTORS: 1073af69d88dSmrg v->value_int = ctx->Const.Program[MESA_SHADER_VERTEX].MaxUniformComponents / 4; 10743464ebd5Sriastradh break; 10753464ebd5Sriastradh 10763464ebd5Sriastradh case GL_MAX_FRAGMENT_UNIFORM_VECTORS: 1077af69d88dSmrg v->value_int = ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxUniformComponents / 4; 10783464ebd5Sriastradh break; 10793464ebd5Sriastradh 10803464ebd5Sriastradh /* GL_ARB_texture_buffer_object */ 10813464ebd5Sriastradh case GL_TEXTURE_BUFFER_ARB: 10823464ebd5Sriastradh v->value_int = ctx->Texture.BufferObject->Name; 10833464ebd5Sriastradh break; 10843464ebd5Sriastradh case GL_TEXTURE_BINDING_BUFFER_ARB: 10853464ebd5Sriastradh unit = ctx->Texture.CurrentUnit; 10863464ebd5Sriastradh v->value_int = 10873464ebd5Sriastradh ctx->Texture.Unit[unit].CurrentTex[TEXTURE_BUFFER_INDEX]->Name; 10883464ebd5Sriastradh break; 10893464ebd5Sriastradh case GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB: 10903464ebd5Sriastradh { 10913464ebd5Sriastradh struct gl_buffer_object *buf = 10923464ebd5Sriastradh ctx->Texture.Unit[ctx->Texture.CurrentUnit] 10933464ebd5Sriastradh .CurrentTex[TEXTURE_BUFFER_INDEX]->BufferObject; 10943464ebd5Sriastradh v->value_int = buf ? buf->Name : 0; 10953464ebd5Sriastradh } 10963464ebd5Sriastradh break; 10973464ebd5Sriastradh case GL_TEXTURE_BUFFER_FORMAT_ARB: 10983464ebd5Sriastradh v->value_int = ctx->Texture.Unit[ctx->Texture.CurrentUnit] 10993464ebd5Sriastradh .CurrentTex[TEXTURE_BUFFER_INDEX]->BufferObjectFormat; 11003464ebd5Sriastradh break; 11013464ebd5Sriastradh 11023464ebd5Sriastradh /* GL_ARB_sampler_objects */ 11033464ebd5Sriastradh case GL_SAMPLER_BINDING: 11043464ebd5Sriastradh { 11053464ebd5Sriastradh struct gl_sampler_object *samp = 11063464ebd5Sriastradh ctx->Texture.Unit[ctx->Texture.CurrentUnit].Sampler; 110701e04c3fSmrg v->value_int = samp ? samp->Name : 0; 1108af69d88dSmrg } 1109af69d88dSmrg break; 1110af69d88dSmrg /* GL_ARB_uniform_buffer_object */ 1111af69d88dSmrg case GL_UNIFORM_BUFFER_BINDING: 1112af69d88dSmrg v->value_int = ctx->UniformBuffer->Name; 1113af69d88dSmrg break; 111401e04c3fSmrg /* GL_ARB_shader_storage_buffer_object */ 111501e04c3fSmrg case GL_SHADER_STORAGE_BUFFER_BINDING: 111601e04c3fSmrg v->value_int = ctx->ShaderStorageBuffer->Name; 111701e04c3fSmrg break; 111801e04c3fSmrg /* GL_ARB_query_buffer_object */ 111901e04c3fSmrg case GL_QUERY_BUFFER_BINDING: 112001e04c3fSmrg v->value_int = ctx->QueryBuffer->Name; 112101e04c3fSmrg break; 1122af69d88dSmrg /* GL_ARB_timer_query */ 1123af69d88dSmrg case GL_TIMESTAMP: 1124af69d88dSmrg if (ctx->Driver.GetTimestamp) { 1125af69d88dSmrg v->value_int64 = ctx->Driver.GetTimestamp(ctx); 1126af69d88dSmrg } 1127af69d88dSmrg else { 1128af69d88dSmrg _mesa_problem(ctx, "driver doesn't implement GetTimestamp"); 11293464ebd5Sriastradh } 11303464ebd5Sriastradh break; 1131af69d88dSmrg /* GL_KHR_DEBUG */ 113201e04c3fSmrg case GL_DEBUG_OUTPUT: 113301e04c3fSmrg case GL_DEBUG_OUTPUT_SYNCHRONOUS: 1134af69d88dSmrg case GL_DEBUG_LOGGED_MESSAGES: 1135af69d88dSmrg case GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH: 1136af69d88dSmrg case GL_DEBUG_GROUP_STACK_DEPTH: 1137af69d88dSmrg v->value_int = _mesa_get_debug_state_int(ctx, d->pname); 1138af69d88dSmrg break; 1139af69d88dSmrg /* GL_ARB_shader_atomic_counters */ 1140af69d88dSmrg case GL_ATOMIC_COUNTER_BUFFER_BINDING: 1141af69d88dSmrg if (ctx->AtomicBuffer) { 1142af69d88dSmrg v->value_int = ctx->AtomicBuffer->Name; 1143af69d88dSmrg } else { 1144af69d88dSmrg v->value_int = 0; 1145af69d88dSmrg } 1146af69d88dSmrg break; 114701e04c3fSmrg /* GL 4.3 */ 114801e04c3fSmrg case GL_NUM_SHADING_LANGUAGE_VERSIONS: 114901e04c3fSmrg v->value_int = _mesa_get_shading_language_version(ctx, -1, NULL); 115001e04c3fSmrg break; 1151af69d88dSmrg /* GL_ARB_draw_indirect */ 1152af69d88dSmrg case GL_DRAW_INDIRECT_BUFFER_BINDING: 1153af69d88dSmrg v->value_int = ctx->DrawIndirectBuffer->Name; 1154af69d88dSmrg break; 115501e04c3fSmrg /* GL_ARB_indirect_parameters */ 115601e04c3fSmrg case GL_PARAMETER_BUFFER_BINDING_ARB: 115701e04c3fSmrg v->value_int = ctx->ParameterBuffer->Name; 115801e04c3fSmrg break; 1159af69d88dSmrg /* GL_ARB_separate_shader_objects */ 1160af69d88dSmrg case GL_PROGRAM_PIPELINE_BINDING: 1161af69d88dSmrg if (ctx->Pipeline.Current) { 1162af69d88dSmrg v->value_int = ctx->Pipeline.Current->Name; 1163af69d88dSmrg } else { 1164af69d88dSmrg v->value_int = 0; 1165af69d88dSmrg } 1166af69d88dSmrg break; 116701e04c3fSmrg /* GL_ARB_compute_shader */ 116801e04c3fSmrg case GL_DISPATCH_INDIRECT_BUFFER_BINDING: 116901e04c3fSmrg v->value_int = ctx->DispatchIndirectBuffer->Name; 117001e04c3fSmrg break; 117101e04c3fSmrg /* GL_ARB_multisample */ 117201e04c3fSmrg case GL_SAMPLES: 117301e04c3fSmrg v->value_int = _mesa_geometric_samples(ctx->DrawBuffer); 117401e04c3fSmrg break; 117501e04c3fSmrg case GL_SAMPLE_BUFFERS: 117601e04c3fSmrg v->value_int = _mesa_geometric_samples(ctx->DrawBuffer) > 0; 117701e04c3fSmrg break; 117801e04c3fSmrg /* GL_EXT_textrue_integer */ 117901e04c3fSmrg case GL_RGBA_INTEGER_MODE_EXT: 118001e04c3fSmrg v->value_int = (ctx->DrawBuffer->_IntegerBuffers != 0); 118101e04c3fSmrg break; 118201e04c3fSmrg /* GL_ATI_meminfo & GL_NVX_gpu_memory_info */ 118301e04c3fSmrg case GL_VBO_FREE_MEMORY_ATI: 118401e04c3fSmrg case GL_TEXTURE_FREE_MEMORY_ATI: 118501e04c3fSmrg case GL_RENDERBUFFER_FREE_MEMORY_ATI: 118601e04c3fSmrg case GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX: 118701e04c3fSmrg case GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX: 118801e04c3fSmrg case GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX: 118901e04c3fSmrg case GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX: 119001e04c3fSmrg case GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX: 119101e04c3fSmrg { 119201e04c3fSmrg struct gl_memory_info info; 119301e04c3fSmrg 119401e04c3fSmrg ctx->Driver.QueryMemoryInfo(ctx, &info); 119501e04c3fSmrg 119601e04c3fSmrg if (d->pname == GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX) 119701e04c3fSmrg v->value_int = info.total_device_memory; 119801e04c3fSmrg else if (d->pname == GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX) 119901e04c3fSmrg v->value_int = info.total_device_memory + 120001e04c3fSmrg info.total_staging_memory; 120101e04c3fSmrg else if (d->pname == GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX) 120201e04c3fSmrg v->value_int = info.avail_device_memory; 120301e04c3fSmrg else if (d->pname == GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX) 120401e04c3fSmrg v->value_int = info.nr_device_memory_evictions; 120501e04c3fSmrg else if (d->pname == GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX) 120601e04c3fSmrg v->value_int = info.device_memory_evicted; 120701e04c3fSmrg else { 120801e04c3fSmrg /* ATI free memory enums. 120901e04c3fSmrg * 121001e04c3fSmrg * Since the GPU memory is (usually) page-table based, every two 121101e04c3fSmrg * consecutive elements are equal. From the GL_ATI_meminfo 121201e04c3fSmrg * specification: 121301e04c3fSmrg * 121401e04c3fSmrg * "param[0] - total memory free in the pool 121501e04c3fSmrg * param[1] - largest available free block in the pool 121601e04c3fSmrg * param[2] - total auxiliary memory free 121701e04c3fSmrg * param[3] - largest auxiliary free block" 121801e04c3fSmrg * 121901e04c3fSmrg * All three (VBO, TEXTURE, RENDERBUFFER) queries return 122001e04c3fSmrg * the same numbers here. 122101e04c3fSmrg */ 122201e04c3fSmrg v->value_int_4[0] = info.avail_device_memory; 122301e04c3fSmrg v->value_int_4[1] = info.avail_device_memory; 122401e04c3fSmrg v->value_int_4[2] = info.avail_staging_memory; 122501e04c3fSmrg v->value_int_4[3] = info.avail_staging_memory; 122601e04c3fSmrg } 122701e04c3fSmrg } 122801e04c3fSmrg break; 122901e04c3fSmrg 123001e04c3fSmrg /* GL_ARB_get_program_binary */ 123101e04c3fSmrg case GL_PROGRAM_BINARY_FORMATS: 123201e04c3fSmrg assert(ctx->Const.NumProgramBinaryFormats <= 1); 123301e04c3fSmrg v->value_int_n.n = MIN2(ctx->Const.NumProgramBinaryFormats, 1); 123401e04c3fSmrg if (ctx->Const.NumProgramBinaryFormats > 0) { 123501e04c3fSmrg v->value_int_n.ints[0] = GL_PROGRAM_BINARY_FORMAT_MESA; 123601e04c3fSmrg } 123701e04c3fSmrg break; 123801e04c3fSmrg /* GL_EXT_disjoint_timer_query */ 123901e04c3fSmrg case GL_GPU_DISJOINT_EXT: 124001e04c3fSmrg { 124101e04c3fSmrg simple_mtx_lock(&ctx->Shared->Mutex); 124201e04c3fSmrg v->value_int = ctx->Shared->DisjointOperation; 124301e04c3fSmrg /* Reset state as expected by the spec. */ 124401e04c3fSmrg ctx->Shared->DisjointOperation = false; 124501e04c3fSmrg simple_mtx_unlock(&ctx->Shared->Mutex); 124601e04c3fSmrg } 124701e04c3fSmrg break; 124801e04c3fSmrg /* GL_ARB_sample_locations */ 124901e04c3fSmrg case GL_SAMPLE_LOCATION_SUBPIXEL_BITS_ARB: 125001e04c3fSmrg case GL_SAMPLE_LOCATION_PIXEL_GRID_WIDTH_ARB: 125101e04c3fSmrg case GL_SAMPLE_LOCATION_PIXEL_GRID_HEIGHT_ARB: 125201e04c3fSmrg { 125301e04c3fSmrg GLuint bits, width, height; 125401e04c3fSmrg 125501e04c3fSmrg if (ctx->NewState & _NEW_BUFFERS) 125601e04c3fSmrg _mesa_update_state(ctx); 125701e04c3fSmrg 125801e04c3fSmrg if (ctx->DrawBuffer->_Status != GL_FRAMEBUFFER_COMPLETE) { 125901e04c3fSmrg v->value_uint = 0; 126001e04c3fSmrg break; 126101e04c3fSmrg } 126201e04c3fSmrg 126301e04c3fSmrg ctx->Driver.GetProgrammableSampleCaps(ctx, ctx->DrawBuffer, 126401e04c3fSmrg &bits, &width, &height); 126501e04c3fSmrg 126601e04c3fSmrg if (d->pname == GL_SAMPLE_LOCATION_PIXEL_GRID_WIDTH_ARB) 126701e04c3fSmrg v->value_uint = width; 126801e04c3fSmrg else if (d->pname == GL_SAMPLE_LOCATION_PIXEL_GRID_HEIGHT_ARB) 126901e04c3fSmrg v->value_uint = height; 127001e04c3fSmrg else 127101e04c3fSmrg v->value_uint = bits; 127201e04c3fSmrg } 127301e04c3fSmrg break; 127401e04c3fSmrg case GL_PROGRAMMABLE_SAMPLE_LOCATION_TABLE_SIZE_ARB: 127501e04c3fSmrg v->value_uint = MAX_SAMPLE_LOCATION_TABLE_SIZE; 127601e04c3fSmrg break; 127701e04c3fSmrg 127801e04c3fSmrg /* GL_AMD_framebuffer_multisample_advanced */ 127901e04c3fSmrg case GL_SUPPORTED_MULTISAMPLE_MODES_AMD: 128001e04c3fSmrg v->value_int_n.n = ctx->Const.NumSupportedMultisampleModes * 3; 128101e04c3fSmrg memcpy(v->value_int_n.ints, ctx->Const.SupportedMultisampleModes, 128201e04c3fSmrg v->value_int_n.n * sizeof(GLint)); 128301e04c3fSmrg break; 1284af69d88dSmrg } 12853464ebd5Sriastradh} 12863464ebd5Sriastradh 12873464ebd5Sriastradh/** 12883464ebd5Sriastradh * Check extra constraints on a struct value_desc descriptor 12893464ebd5Sriastradh * 12903464ebd5Sriastradh * If a struct value_desc has a non-NULL extra pointer, it means that 12913464ebd5Sriastradh * there are a number of extra constraints to check or actions to 12923464ebd5Sriastradh * perform. The extras is just an integer array where each integer 12933464ebd5Sriastradh * encode different constraints or actions. 12943464ebd5Sriastradh * 12953464ebd5Sriastradh * \param ctx current context 12963464ebd5Sriastradh * \param func name of calling glGet*v() function for error reporting 12973464ebd5Sriastradh * \param d the struct value_desc that has the extra constraints 12983464ebd5Sriastradh * 1299af69d88dSmrg * \return GL_FALSE if all of the constraints were not satisfied, 13003464ebd5Sriastradh * otherwise GL_TRUE. 13017117f1b4Smrg */ 13023464ebd5Sriastradhstatic GLboolean 13033464ebd5Sriastradhcheck_extra(struct gl_context *ctx, const char *func, const struct value_desc *d) 13043464ebd5Sriastradh{ 1305af69d88dSmrg const GLuint version = ctx->Version; 1306af69d88dSmrg GLboolean api_check = GL_FALSE; 1307af69d88dSmrg GLboolean api_found = GL_FALSE; 13083464ebd5Sriastradh const int *e; 13093464ebd5Sriastradh 1310af69d88dSmrg for (e = d->extra; *e != EXTRA_END; e++) { 13113464ebd5Sriastradh switch (*e) { 13123464ebd5Sriastradh case EXTRA_VERSION_30: 1313af69d88dSmrg api_check = GL_TRUE; 1314af69d88dSmrg if (version >= 30) 1315af69d88dSmrg api_found = GL_TRUE; 131601e04c3fSmrg break; 13173464ebd5Sriastradh case EXTRA_VERSION_31: 1318af69d88dSmrg api_check = GL_TRUE; 1319af69d88dSmrg if (version >= 31) 1320af69d88dSmrg api_found = GL_TRUE; 132101e04c3fSmrg break; 13223464ebd5Sriastradh case EXTRA_VERSION_32: 1323af69d88dSmrg api_check = GL_TRUE; 1324af69d88dSmrg if (version >= 32) 1325af69d88dSmrg api_found = GL_TRUE; 132601e04c3fSmrg break; 132701e04c3fSmrg case EXTRA_VERSION_40: 132801e04c3fSmrg api_check = GL_TRUE; 132901e04c3fSmrg if (version >= 40) 133001e04c3fSmrg api_found = GL_TRUE; 133101e04c3fSmrg break; 133201e04c3fSmrg case EXTRA_VERSION_43: 133301e04c3fSmrg api_check = TRUE; 133401e04c3fSmrg if (_mesa_is_desktop_gl(ctx) && version >= 43) 133501e04c3fSmrg api_found = GL_TRUE; 133601e04c3fSmrg break; 13373464ebd5Sriastradh case EXTRA_NEW_FRAG_CLAMP: 13383464ebd5Sriastradh if (ctx->NewState & (_NEW_BUFFERS | _NEW_FRAG_CLAMP)) 13393464ebd5Sriastradh _mesa_update_state(ctx); 13403464ebd5Sriastradh break; 1341af69d88dSmrg case EXTRA_API_ES2: 1342af69d88dSmrg api_check = GL_TRUE; 1343af69d88dSmrg if (ctx->API == API_OPENGLES2) 1344af69d88dSmrg api_found = GL_TRUE; 134501e04c3fSmrg break; 1346af69d88dSmrg case EXTRA_API_ES3: 1347af69d88dSmrg api_check = GL_TRUE; 1348af69d88dSmrg if (_mesa_is_gles3(ctx)) 1349af69d88dSmrg api_found = GL_TRUE; 135001e04c3fSmrg break; 135101e04c3fSmrg case EXTRA_API_ES31: 135201e04c3fSmrg api_check = GL_TRUE; 135301e04c3fSmrg if (_mesa_is_gles31(ctx)) 135401e04c3fSmrg api_found = GL_TRUE; 135501e04c3fSmrg break; 135601e04c3fSmrg case EXTRA_API_ES32: 135701e04c3fSmrg api_check = GL_TRUE; 135801e04c3fSmrg if (_mesa_is_gles32(ctx)) 135901e04c3fSmrg api_found = GL_TRUE; 136001e04c3fSmrg break; 1361af69d88dSmrg case EXTRA_API_GL: 1362af69d88dSmrg api_check = GL_TRUE; 1363af69d88dSmrg if (_mesa_is_desktop_gl(ctx)) 1364af69d88dSmrg api_found = GL_TRUE; 136501e04c3fSmrg break; 1366af69d88dSmrg case EXTRA_API_GL_CORE: 1367af69d88dSmrg api_check = GL_TRUE; 1368af69d88dSmrg if (ctx->API == API_OPENGL_CORE) 1369af69d88dSmrg api_found = GL_TRUE; 137001e04c3fSmrg break; 13713464ebd5Sriastradh case EXTRA_NEW_BUFFERS: 137201e04c3fSmrg if (ctx->NewState & _NEW_BUFFERS) 137301e04c3fSmrg _mesa_update_state(ctx); 137401e04c3fSmrg break; 13753464ebd5Sriastradh case EXTRA_FLUSH_CURRENT: 137601e04c3fSmrg FLUSH_CURRENT(ctx, 0); 137701e04c3fSmrg break; 13783464ebd5Sriastradh case EXTRA_VALID_DRAW_BUFFER: 137901e04c3fSmrg if (d->pname - GL_DRAW_BUFFER0_ARB >= ctx->Const.MaxDrawBuffers) { 138001e04c3fSmrg _mesa_error(ctx, GL_INVALID_OPERATION, "%s(draw buffer %u)", 138101e04c3fSmrg func, d->pname - GL_DRAW_BUFFER0_ARB); 138201e04c3fSmrg return GL_FALSE; 138301e04c3fSmrg } 138401e04c3fSmrg break; 13853464ebd5Sriastradh case EXTRA_VALID_TEXTURE_UNIT: 138601e04c3fSmrg if (ctx->Texture.CurrentUnit >= ctx->Const.MaxTextureCoordUnits) { 138701e04c3fSmrg _mesa_error(ctx, GL_INVALID_OPERATION, "%s(texture %u)", 138801e04c3fSmrg func, ctx->Texture.CurrentUnit); 138901e04c3fSmrg return GL_FALSE; 139001e04c3fSmrg } 139101e04c3fSmrg break; 1392af69d88dSmrg case EXTRA_VALID_CLIP_DISTANCE: 139301e04c3fSmrg if (d->pname - GL_CLIP_DISTANCE0 >= ctx->Const.MaxClipPlanes) { 139401e04c3fSmrg _mesa_error(ctx, GL_INVALID_ENUM, "%s(clip distance %u)", 139501e04c3fSmrg func, d->pname - GL_CLIP_DISTANCE0); 139601e04c3fSmrg return GL_FALSE; 139701e04c3fSmrg } 139801e04c3fSmrg break; 1399af69d88dSmrg case EXTRA_GLSL_130: 1400af69d88dSmrg api_check = GL_TRUE; 1401af69d88dSmrg if (ctx->Const.GLSLVersion >= 130) 1402af69d88dSmrg api_found = GL_TRUE; 140301e04c3fSmrg break; 140401e04c3fSmrg case EXTRA_EXT_UBO_GS: 1405af69d88dSmrg api_check = GL_TRUE; 140601e04c3fSmrg if (ctx->Extensions.ARB_uniform_buffer_object && 140701e04c3fSmrg _mesa_has_geometry_shaders(ctx)) 140801e04c3fSmrg api_found = GL_TRUE; 140901e04c3fSmrg break; 141001e04c3fSmrg case EXTRA_EXT_ATOMICS_GS: 141101e04c3fSmrg api_check = GL_TRUE; 141201e04c3fSmrg if (ctx->Extensions.ARB_shader_atomic_counters && 141301e04c3fSmrg _mesa_has_geometry_shaders(ctx)) 141401e04c3fSmrg api_found = GL_TRUE; 141501e04c3fSmrg break; 141601e04c3fSmrg case EXTRA_EXT_SHADER_IMAGE_GS: 141701e04c3fSmrg api_check = GL_TRUE; 141801e04c3fSmrg if (ctx->Extensions.ARB_shader_image_load_store && 141901e04c3fSmrg _mesa_has_geometry_shaders(ctx)) 142001e04c3fSmrg api_found = GL_TRUE; 142101e04c3fSmrg break; 142201e04c3fSmrg case EXTRA_EXT_ATOMICS_TESS: 142301e04c3fSmrg api_check = GL_TRUE; 142401e04c3fSmrg api_found = ctx->Extensions.ARB_shader_atomic_counters && 142501e04c3fSmrg _mesa_has_tessellation(ctx); 142601e04c3fSmrg break; 142701e04c3fSmrg case EXTRA_EXT_SHADER_IMAGE_TESS: 142801e04c3fSmrg api_check = GL_TRUE; 142901e04c3fSmrg api_found = ctx->Extensions.ARB_shader_image_load_store && 143001e04c3fSmrg _mesa_has_tessellation(ctx); 143101e04c3fSmrg break; 143201e04c3fSmrg case EXTRA_EXT_SSBO_GS: 143301e04c3fSmrg api_check = GL_TRUE; 143401e04c3fSmrg if (ctx->Extensions.ARB_shader_storage_buffer_object && 143501e04c3fSmrg _mesa_has_geometry_shaders(ctx)) 143601e04c3fSmrg api_found = GL_TRUE; 1437af69d88dSmrg break; 143801e04c3fSmrg case EXTRA_EXT_FB_NO_ATTACH_GS: 1439af69d88dSmrg api_check = GL_TRUE; 144001e04c3fSmrg if (ctx->Extensions.ARB_framebuffer_no_attachments && 144101e04c3fSmrg (_mesa_is_desktop_gl(ctx) || 144201e04c3fSmrg _mesa_has_OES_geometry_shader(ctx))) 144301e04c3fSmrg api_found = GL_TRUE; 1444af69d88dSmrg break; 144501e04c3fSmrg case EXTRA_EXT_ES_GS: 1446af69d88dSmrg api_check = GL_TRUE; 144701e04c3fSmrg if (_mesa_has_OES_geometry_shader(ctx)) 144801e04c3fSmrg api_found = GL_TRUE; 144901e04c3fSmrg break; 145001e04c3fSmrg case EXTRA_EXT_PROVOKING_VERTEX_32: 145101e04c3fSmrg api_check = TRUE; 145201e04c3fSmrg if (ctx->API == API_OPENGL_COMPAT || version == 32) 145301e04c3fSmrg api_found = ctx->Extensions.EXT_provoking_vertex; 1454af69d88dSmrg break; 14553464ebd5Sriastradh case EXTRA_END: 145601e04c3fSmrg break; 14573464ebd5Sriastradh default: /* *e is a offset into the extension struct */ 145801e04c3fSmrg api_check = GL_TRUE; 145901e04c3fSmrg if (*(GLboolean *) ((char *) &ctx->Extensions + *e)) 146001e04c3fSmrg api_found = GL_TRUE; 146101e04c3fSmrg break; 14623464ebd5Sriastradh } 1463af69d88dSmrg } 14643464ebd5Sriastradh 1465af69d88dSmrg if (api_check && !api_found) { 14663464ebd5Sriastradh _mesa_error(ctx, GL_INVALID_ENUM, "%s(pname=%s)", func, 146701e04c3fSmrg _mesa_enum_to_string(d->pname)); 14683464ebd5Sriastradh return GL_FALSE; 14697117f1b4Smrg } 14707117f1b4Smrg 14713464ebd5Sriastradh return GL_TRUE; 14723464ebd5Sriastradh} 14733464ebd5Sriastradh 14743464ebd5Sriastradhstatic const struct value_desc error_value = 14753464ebd5Sriastradh { 0, 0, TYPE_INVALID, NO_OFFSET, NO_EXTRA }; 14763464ebd5Sriastradh 14773464ebd5Sriastradh/** 14783464ebd5Sriastradh * Find the struct value_desc corresponding to the enum 'pname'. 147901e04c3fSmrg * 14803464ebd5Sriastradh * We hash the enum value to get an index into the 'table' array, 14813464ebd5Sriastradh * which holds the index in the 'values' array of struct value_desc. 14823464ebd5Sriastradh * Once we've found the entry, we do the extra checks, if any, then 14833464ebd5Sriastradh * look up the value and return a pointer to it. 14843464ebd5Sriastradh * 14853464ebd5Sriastradh * If the value has to be computed (for example, it's the result of a 14863464ebd5Sriastradh * function call or we need to add 1 to it), we use the tmp 'v' to 14873464ebd5Sriastradh * store the result. 148801e04c3fSmrg * 14893464ebd5Sriastradh * \param func name of glGet*v() func for error reporting 14903464ebd5Sriastradh * \param pname the enum value we're looking up 14913464ebd5Sriastradh * \param p is were we return the pointer to the value 14923464ebd5Sriastradh * \param v a tmp union value variable in the calling glGet*v() function 14933464ebd5Sriastradh * 14943464ebd5Sriastradh * \return the struct value_desc corresponding to the enum or a struct 14953464ebd5Sriastradh * value_desc of TYPE_INVALID if not found. This lets the calling 14963464ebd5Sriastradh * glGet*v() function jump right into a switch statement and 14973464ebd5Sriastradh * handle errors there instead of having to check for NULL. 14987117f1b4Smrg */ 14993464ebd5Sriastradhstatic const struct value_desc * 15003464ebd5Sriastradhfind_value(const char *func, GLenum pname, void **p, union value *v) 15013464ebd5Sriastradh{ 15023464ebd5Sriastradh GET_CURRENT_CONTEXT(ctx); 15033464ebd5Sriastradh int mask, hash; 15043464ebd5Sriastradh const struct value_desc *d; 1505af69d88dSmrg int api; 15063464ebd5Sriastradh 1507af69d88dSmrg api = ctx->API; 1508af69d88dSmrg /* We index into the table_set[] list of per-API hash tables using the API's 1509af69d88dSmrg * value in the gl_api enum. Since GLES 3 doesn't have an API_OPENGL* enum 1510af69d88dSmrg * value since it's compatible with GLES2 its entry in table_set[] is at the 1511af69d88dSmrg * end. 1512af69d88dSmrg */ 151301e04c3fSmrg STATIC_ASSERT(ARRAY_SIZE(table_set) == API_OPENGL_LAST + 4); 151401e04c3fSmrg if (ctx->API == API_OPENGLES2) { 151501e04c3fSmrg if (ctx->Version >= 32) 151601e04c3fSmrg api = API_OPENGL_LAST + 3; 151701e04c3fSmrg else if (ctx->Version >= 31) 151801e04c3fSmrg api = API_OPENGL_LAST + 2; 151901e04c3fSmrg else if (ctx->Version >= 30) 152001e04c3fSmrg api = API_OPENGL_LAST + 1; 1521af69d88dSmrg } 152201e04c3fSmrg mask = ARRAY_SIZE(table(api)) - 1; 15233464ebd5Sriastradh hash = (pname * prime_factor); 15243464ebd5Sriastradh while (1) { 1525af69d88dSmrg int idx = table(api)[hash & mask]; 15263464ebd5Sriastradh 15273464ebd5Sriastradh /* If the enum isn't valid, the hash walk ends with index 0, 1528af69d88dSmrg * pointing to the first entry of values[] which doesn't hold 1529af69d88dSmrg * any valid enum. */ 1530af69d88dSmrg if (unlikely(idx == 0)) { 1531af69d88dSmrg _mesa_error(ctx, GL_INVALID_ENUM, "%s(pname=%s)", func, 153201e04c3fSmrg _mesa_enum_to_string(pname)); 1533af69d88dSmrg return &error_value; 15343464ebd5Sriastradh } 15353464ebd5Sriastradh 1536af69d88dSmrg d = &values[idx]; 15373464ebd5Sriastradh if (likely(d->pname == pname)) 1538af69d88dSmrg break; 15393464ebd5Sriastradh 15403464ebd5Sriastradh hash += prime_step; 15417117f1b4Smrg } 15427117f1b4Smrg 15433464ebd5Sriastradh if (unlikely(d->extra && !check_extra(ctx, func, d))) 15443464ebd5Sriastradh return &error_value; 15453464ebd5Sriastradh 15463464ebd5Sriastradh switch (d->location) { 15473464ebd5Sriastradh case LOC_BUFFER: 15483464ebd5Sriastradh *p = ((char *) ctx->DrawBuffer + d->offset); 15493464ebd5Sriastradh return d; 15503464ebd5Sriastradh case LOC_CONTEXT: 15513464ebd5Sriastradh *p = ((char *) ctx + d->offset); 15523464ebd5Sriastradh return d; 15533464ebd5Sriastradh case LOC_ARRAY: 1554af69d88dSmrg *p = ((char *) ctx->Array.VAO + d->offset); 15553464ebd5Sriastradh return d; 15563464ebd5Sriastradh case LOC_TEXUNIT: 155701e04c3fSmrg if (ctx->Texture.CurrentUnit < ARRAY_SIZE(ctx->Texture.FixedFuncUnit)) { 155801e04c3fSmrg unsigned index = ctx->Texture.CurrentUnit; 155901e04c3fSmrg *p = ((char *)&ctx->Texture.FixedFuncUnit[index] + d->offset); 156001e04c3fSmrg } 15613464ebd5Sriastradh return d; 15623464ebd5Sriastradh case LOC_CUSTOM: 15633464ebd5Sriastradh find_custom_value(ctx, d, v); 15643464ebd5Sriastradh *p = v; 15653464ebd5Sriastradh return d; 15663464ebd5Sriastradh default: 15673464ebd5Sriastradh assert(0); 15683464ebd5Sriastradh break; 15693464ebd5Sriastradh } 15703464ebd5Sriastradh 15713464ebd5Sriastradh /* silence warning */ 15723464ebd5Sriastradh return &error_value; 15733464ebd5Sriastradh} 15743464ebd5Sriastradh 15753464ebd5Sriastradhstatic const int transpose[] = { 15763464ebd5Sriastradh 0, 4, 8, 12, 15773464ebd5Sriastradh 1, 5, 9, 13, 15783464ebd5Sriastradh 2, 6, 10, 14, 15793464ebd5Sriastradh 3, 7, 11, 15 15803464ebd5Sriastradh}; 15817117f1b4Smrg 158201e04c3fSmrgstatic GLsizei 158301e04c3fSmrgget_value_size(enum value_type type, const union value *v) 158401e04c3fSmrg{ 158501e04c3fSmrg switch (type) { 158601e04c3fSmrg case TYPE_INVALID: 158701e04c3fSmrg return 0; 158801e04c3fSmrg case TYPE_CONST: 158901e04c3fSmrg case TYPE_UINT: 159001e04c3fSmrg case TYPE_INT: 159101e04c3fSmrg return sizeof(GLint); 159201e04c3fSmrg case TYPE_INT_2: 159301e04c3fSmrg case TYPE_UINT_2: 159401e04c3fSmrg return sizeof(GLint) * 2; 159501e04c3fSmrg case TYPE_INT_3: 159601e04c3fSmrg case TYPE_UINT_3: 159701e04c3fSmrg return sizeof(GLint) * 3; 159801e04c3fSmrg case TYPE_INT_4: 159901e04c3fSmrg case TYPE_UINT_4: 160001e04c3fSmrg return sizeof(GLint) * 4; 160101e04c3fSmrg case TYPE_INT_N: 160201e04c3fSmrg return sizeof(GLint) * v->value_int_n.n; 160301e04c3fSmrg case TYPE_INT64: 160401e04c3fSmrg return sizeof(GLint64); 160501e04c3fSmrg break; 160601e04c3fSmrg case TYPE_ENUM16: 160701e04c3fSmrg return sizeof(GLenum16); 160801e04c3fSmrg case TYPE_ENUM: 160901e04c3fSmrg return sizeof(GLenum); 161001e04c3fSmrg case TYPE_ENUM_2: 161101e04c3fSmrg return sizeof(GLenum) * 2; 161201e04c3fSmrg case TYPE_BOOLEAN: 161301e04c3fSmrg return sizeof(GLboolean); 161401e04c3fSmrg case TYPE_UBYTE: 161501e04c3fSmrg return sizeof(GLubyte); 161601e04c3fSmrg case TYPE_SHORT: 161701e04c3fSmrg return sizeof(GLshort); 161801e04c3fSmrg case TYPE_BIT_0: 161901e04c3fSmrg case TYPE_BIT_1: 162001e04c3fSmrg case TYPE_BIT_2: 162101e04c3fSmrg case TYPE_BIT_3: 162201e04c3fSmrg case TYPE_BIT_4: 162301e04c3fSmrg case TYPE_BIT_5: 162401e04c3fSmrg case TYPE_BIT_6: 162501e04c3fSmrg case TYPE_BIT_7: 162601e04c3fSmrg return 1; 162701e04c3fSmrg case TYPE_FLOAT: 162801e04c3fSmrg case TYPE_FLOATN: 162901e04c3fSmrg return sizeof(GLfloat); 163001e04c3fSmrg case TYPE_FLOAT_2: 163101e04c3fSmrg case TYPE_FLOATN_2: 163201e04c3fSmrg return sizeof(GLfloat) * 2; 163301e04c3fSmrg case TYPE_FLOAT_3: 163401e04c3fSmrg case TYPE_FLOATN_3: 163501e04c3fSmrg return sizeof(GLfloat) * 3; 163601e04c3fSmrg case TYPE_FLOAT_4: 163701e04c3fSmrg case TYPE_FLOATN_4: 163801e04c3fSmrg return sizeof(GLfloat) * 4; 163901e04c3fSmrg case TYPE_FLOAT_8: 164001e04c3fSmrg return sizeof(GLfloat) * 8; 164101e04c3fSmrg case TYPE_DOUBLEN: 164201e04c3fSmrg return sizeof(GLdouble); 164301e04c3fSmrg case TYPE_DOUBLEN_2: 164401e04c3fSmrg return sizeof(GLdouble) * 2; 164501e04c3fSmrg case TYPE_MATRIX: 164601e04c3fSmrg return sizeof (GLfloat) * 16; 164701e04c3fSmrg case TYPE_MATRIX_T: 164801e04c3fSmrg return sizeof (GLfloat) * 16; 164901e04c3fSmrg default: 165001e04c3fSmrg return -1; 165101e04c3fSmrg } 165201e04c3fSmrg} 165301e04c3fSmrg 16547117f1b4Smrgvoid GLAPIENTRY 16553464ebd5Sriastradh_mesa_GetBooleanv(GLenum pname, GLboolean *params) 16567117f1b4Smrg{ 16573464ebd5Sriastradh const struct value_desc *d; 16583464ebd5Sriastradh union value v; 16593464ebd5Sriastradh GLmatrix *m; 16603464ebd5Sriastradh int shift, i; 16613464ebd5Sriastradh void *p; 16627117f1b4Smrg 16633464ebd5Sriastradh d = find_value("glGetBooleanv", pname, &p, &v); 16643464ebd5Sriastradh switch (d->type) { 16653464ebd5Sriastradh case TYPE_INVALID: 16663464ebd5Sriastradh break; 16673464ebd5Sriastradh case TYPE_CONST: 16683464ebd5Sriastradh params[0] = INT_TO_BOOLEAN(d->offset); 16693464ebd5Sriastradh break; 16707117f1b4Smrg 167101e04c3fSmrg case TYPE_FLOAT_8: 167201e04c3fSmrg params[7] = FLOAT_TO_BOOLEAN(((GLfloat *) p)[7]); 167301e04c3fSmrg params[6] = FLOAT_TO_BOOLEAN(((GLfloat *) p)[6]); 167401e04c3fSmrg params[5] = FLOAT_TO_BOOLEAN(((GLfloat *) p)[5]); 167501e04c3fSmrg params[4] = FLOAT_TO_BOOLEAN(((GLfloat *) p)[4]); 16763464ebd5Sriastradh case TYPE_FLOAT_4: 16773464ebd5Sriastradh case TYPE_FLOATN_4: 16783464ebd5Sriastradh params[3] = FLOAT_TO_BOOLEAN(((GLfloat *) p)[3]); 16793464ebd5Sriastradh case TYPE_FLOAT_3: 16803464ebd5Sriastradh case TYPE_FLOATN_3: 16813464ebd5Sriastradh params[2] = FLOAT_TO_BOOLEAN(((GLfloat *) p)[2]); 16823464ebd5Sriastradh case TYPE_FLOAT_2: 16833464ebd5Sriastradh case TYPE_FLOATN_2: 16843464ebd5Sriastradh params[1] = FLOAT_TO_BOOLEAN(((GLfloat *) p)[1]); 16853464ebd5Sriastradh case TYPE_FLOAT: 16863464ebd5Sriastradh case TYPE_FLOATN: 16873464ebd5Sriastradh params[0] = FLOAT_TO_BOOLEAN(((GLfloat *) p)[0]); 16883464ebd5Sriastradh break; 16897117f1b4Smrg 1690af69d88dSmrg case TYPE_DOUBLEN_2: 1691af69d88dSmrg params[1] = FLOAT_TO_BOOLEAN(((GLdouble *) p)[1]); 16923464ebd5Sriastradh case TYPE_DOUBLEN: 16933464ebd5Sriastradh params[0] = FLOAT_TO_BOOLEAN(((GLdouble *) p)[0]); 16943464ebd5Sriastradh break; 16957117f1b4Smrg 16963464ebd5Sriastradh case TYPE_INT_4: 169701e04c3fSmrg case TYPE_UINT_4: 16983464ebd5Sriastradh params[3] = INT_TO_BOOLEAN(((GLint *) p)[3]); 16993464ebd5Sriastradh case TYPE_INT_3: 170001e04c3fSmrg case TYPE_UINT_3: 17013464ebd5Sriastradh params[2] = INT_TO_BOOLEAN(((GLint *) p)[2]); 17023464ebd5Sriastradh case TYPE_INT_2: 170301e04c3fSmrg case TYPE_UINT_2: 17043464ebd5Sriastradh case TYPE_ENUM_2: 17053464ebd5Sriastradh params[1] = INT_TO_BOOLEAN(((GLint *) p)[1]); 17063464ebd5Sriastradh case TYPE_INT: 170701e04c3fSmrg case TYPE_UINT: 17083464ebd5Sriastradh case TYPE_ENUM: 17093464ebd5Sriastradh params[0] = INT_TO_BOOLEAN(((GLint *) p)[0]); 17103464ebd5Sriastradh break; 17113464ebd5Sriastradh 171201e04c3fSmrg case TYPE_ENUM16: 171301e04c3fSmrg params[0] = INT_TO_BOOLEAN(((GLenum16 *) p)[0]); 171401e04c3fSmrg break; 171501e04c3fSmrg 17163464ebd5Sriastradh case TYPE_INT_N: 17173464ebd5Sriastradh for (i = 0; i < v.value_int_n.n; i++) 171801e04c3fSmrg params[i] = INT_TO_BOOLEAN(v.value_int_n.ints[i]); 17193464ebd5Sriastradh break; 17203464ebd5Sriastradh 17213464ebd5Sriastradh case TYPE_INT64: 17223464ebd5Sriastradh params[0] = INT64_TO_BOOLEAN(((GLint64 *) p)[0]); 17233464ebd5Sriastradh break; 17243464ebd5Sriastradh 17253464ebd5Sriastradh case TYPE_BOOLEAN: 17263464ebd5Sriastradh params[0] = ((GLboolean*) p)[0]; 172701e04c3fSmrg break; 172801e04c3fSmrg 172901e04c3fSmrg case TYPE_UBYTE: 173001e04c3fSmrg params[0] = INT_TO_BOOLEAN(((GLubyte *) p)[0]); 173101e04c3fSmrg break; 173201e04c3fSmrg 173301e04c3fSmrg case TYPE_SHORT: 173401e04c3fSmrg params[0] = INT_TO_BOOLEAN(((GLshort *) p)[0]); 173501e04c3fSmrg break; 17363464ebd5Sriastradh 17373464ebd5Sriastradh case TYPE_MATRIX: 17383464ebd5Sriastradh m = *(GLmatrix **) p; 17393464ebd5Sriastradh for (i = 0; i < 16; i++) 174001e04c3fSmrg params[i] = FLOAT_TO_BOOLEAN(m->m[i]); 17413464ebd5Sriastradh break; 17423464ebd5Sriastradh 17433464ebd5Sriastradh case TYPE_MATRIX_T: 17443464ebd5Sriastradh m = *(GLmatrix **) p; 17453464ebd5Sriastradh for (i = 0; i < 16; i++) 174601e04c3fSmrg params[i] = FLOAT_TO_BOOLEAN(m->m[transpose[i]]); 17473464ebd5Sriastradh break; 17483464ebd5Sriastradh 17493464ebd5Sriastradh case TYPE_BIT_0: 17503464ebd5Sriastradh case TYPE_BIT_1: 17513464ebd5Sriastradh case TYPE_BIT_2: 17523464ebd5Sriastradh case TYPE_BIT_3: 17533464ebd5Sriastradh case TYPE_BIT_4: 17543464ebd5Sriastradh case TYPE_BIT_5: 1755af69d88dSmrg case TYPE_BIT_6: 1756af69d88dSmrg case TYPE_BIT_7: 17573464ebd5Sriastradh shift = d->type - TYPE_BIT_0; 17583464ebd5Sriastradh params[0] = (*(GLbitfield *) p >> shift) & 1; 17593464ebd5Sriastradh break; 17604a49301eSmrg } 17614a49301eSmrg} 17627117f1b4Smrg 17637117f1b4Smrgvoid GLAPIENTRY 17643464ebd5Sriastradh_mesa_GetFloatv(GLenum pname, GLfloat *params) 17657117f1b4Smrg{ 17663464ebd5Sriastradh const struct value_desc *d; 17673464ebd5Sriastradh union value v; 17683464ebd5Sriastradh GLmatrix *m; 17693464ebd5Sriastradh int shift, i; 17703464ebd5Sriastradh void *p; 17717117f1b4Smrg 17723464ebd5Sriastradh d = find_value("glGetFloatv", pname, &p, &v); 17733464ebd5Sriastradh switch (d->type) { 17743464ebd5Sriastradh case TYPE_INVALID: 17753464ebd5Sriastradh break; 17763464ebd5Sriastradh case TYPE_CONST: 17773464ebd5Sriastradh params[0] = (GLfloat) d->offset; 17783464ebd5Sriastradh break; 17797117f1b4Smrg 178001e04c3fSmrg case TYPE_FLOAT_8: 178101e04c3fSmrg params[7] = ((GLfloat *) p)[7]; 178201e04c3fSmrg params[6] = ((GLfloat *) p)[6]; 178301e04c3fSmrg params[5] = ((GLfloat *) p)[5]; 178401e04c3fSmrg params[4] = ((GLfloat *) p)[4]; 17853464ebd5Sriastradh case TYPE_FLOAT_4: 17863464ebd5Sriastradh case TYPE_FLOATN_4: 17873464ebd5Sriastradh params[3] = ((GLfloat *) p)[3]; 17883464ebd5Sriastradh case TYPE_FLOAT_3: 17893464ebd5Sriastradh case TYPE_FLOATN_3: 17903464ebd5Sriastradh params[2] = ((GLfloat *) p)[2]; 17913464ebd5Sriastradh case TYPE_FLOAT_2: 17923464ebd5Sriastradh case TYPE_FLOATN_2: 17933464ebd5Sriastradh params[1] = ((GLfloat *) p)[1]; 17943464ebd5Sriastradh case TYPE_FLOAT: 17953464ebd5Sriastradh case TYPE_FLOATN: 17963464ebd5Sriastradh params[0] = ((GLfloat *) p)[0]; 17973464ebd5Sriastradh break; 17987117f1b4Smrg 1799af69d88dSmrg case TYPE_DOUBLEN_2: 1800af69d88dSmrg params[1] = (GLfloat) (((GLdouble *) p)[1]); 18013464ebd5Sriastradh case TYPE_DOUBLEN: 1802af69d88dSmrg params[0] = (GLfloat) (((GLdouble *) p)[0]); 18033464ebd5Sriastradh break; 18043464ebd5Sriastradh 18053464ebd5Sriastradh case TYPE_INT_4: 18063464ebd5Sriastradh params[3] = (GLfloat) (((GLint *) p)[3]); 18073464ebd5Sriastradh case TYPE_INT_3: 18083464ebd5Sriastradh params[2] = (GLfloat) (((GLint *) p)[2]); 18093464ebd5Sriastradh case TYPE_INT_2: 18103464ebd5Sriastradh case TYPE_ENUM_2: 18113464ebd5Sriastradh params[1] = (GLfloat) (((GLint *) p)[1]); 18123464ebd5Sriastradh case TYPE_INT: 18133464ebd5Sriastradh case TYPE_ENUM: 18143464ebd5Sriastradh params[0] = (GLfloat) (((GLint *) p)[0]); 18153464ebd5Sriastradh break; 18163464ebd5Sriastradh 181701e04c3fSmrg case TYPE_ENUM16: 181801e04c3fSmrg params[0] = (GLfloat) (((GLenum16 *) p)[0]); 181901e04c3fSmrg break; 182001e04c3fSmrg 18213464ebd5Sriastradh case TYPE_INT_N: 18223464ebd5Sriastradh for (i = 0; i < v.value_int_n.n; i++) 182301e04c3fSmrg params[i] = (GLfloat) v.value_int_n.ints[i]; 182401e04c3fSmrg break; 182501e04c3fSmrg 182601e04c3fSmrg case TYPE_UINT_4: 182701e04c3fSmrg params[3] = (GLfloat) (((GLuint *) p)[3]); 182801e04c3fSmrg case TYPE_UINT_3: 182901e04c3fSmrg params[2] = (GLfloat) (((GLuint *) p)[2]); 183001e04c3fSmrg case TYPE_UINT_2: 183101e04c3fSmrg params[1] = (GLfloat) (((GLuint *) p)[1]); 183201e04c3fSmrg case TYPE_UINT: 183301e04c3fSmrg params[0] = (GLfloat) (((GLuint *) p)[0]); 18343464ebd5Sriastradh break; 18353464ebd5Sriastradh 18363464ebd5Sriastradh case TYPE_INT64: 1837af69d88dSmrg params[0] = (GLfloat) (((GLint64 *) p)[0]); 18383464ebd5Sriastradh break; 18393464ebd5Sriastradh 18403464ebd5Sriastradh case TYPE_BOOLEAN: 18413464ebd5Sriastradh params[0] = BOOLEAN_TO_FLOAT(*(GLboolean*) p); 184201e04c3fSmrg break; 184301e04c3fSmrg 184401e04c3fSmrg case TYPE_UBYTE: 184501e04c3fSmrg params[0] = (GLfloat) ((GLubyte *) p)[0]; 184601e04c3fSmrg break; 184701e04c3fSmrg 184801e04c3fSmrg case TYPE_SHORT: 184901e04c3fSmrg params[0] = (GLfloat) ((GLshort *) p)[0]; 185001e04c3fSmrg break; 18513464ebd5Sriastradh 18523464ebd5Sriastradh case TYPE_MATRIX: 18533464ebd5Sriastradh m = *(GLmatrix **) p; 18543464ebd5Sriastradh for (i = 0; i < 16; i++) 185501e04c3fSmrg params[i] = m->m[i]; 18563464ebd5Sriastradh break; 18573464ebd5Sriastradh 18583464ebd5Sriastradh case TYPE_MATRIX_T: 18593464ebd5Sriastradh m = *(GLmatrix **) p; 18603464ebd5Sriastradh for (i = 0; i < 16; i++) 186101e04c3fSmrg params[i] = m->m[transpose[i]]; 18623464ebd5Sriastradh break; 18633464ebd5Sriastradh 18643464ebd5Sriastradh case TYPE_BIT_0: 18653464ebd5Sriastradh case TYPE_BIT_1: 18663464ebd5Sriastradh case TYPE_BIT_2: 18673464ebd5Sriastradh case TYPE_BIT_3: 18683464ebd5Sriastradh case TYPE_BIT_4: 18693464ebd5Sriastradh case TYPE_BIT_5: 1870af69d88dSmrg case TYPE_BIT_6: 1871af69d88dSmrg case TYPE_BIT_7: 18723464ebd5Sriastradh shift = d->type - TYPE_BIT_0; 18733464ebd5Sriastradh params[0] = BOOLEAN_TO_FLOAT((*(GLbitfield *) p >> shift) & 1); 18743464ebd5Sriastradh break; 18753464ebd5Sriastradh } 18767117f1b4Smrg} 18777117f1b4Smrg 1878cdc920a0Smrgvoid GLAPIENTRY 18793464ebd5Sriastradh_mesa_GetIntegerv(GLenum pname, GLint *params) 1880cdc920a0Smrg{ 18813464ebd5Sriastradh const struct value_desc *d; 18823464ebd5Sriastradh union value v; 18833464ebd5Sriastradh GLmatrix *m; 18843464ebd5Sriastradh int shift, i; 18853464ebd5Sriastradh void *p; 1886cdc920a0Smrg 18873464ebd5Sriastradh d = find_value("glGetIntegerv", pname, &p, &v); 18883464ebd5Sriastradh switch (d->type) { 18893464ebd5Sriastradh case TYPE_INVALID: 18903464ebd5Sriastradh break; 18913464ebd5Sriastradh case TYPE_CONST: 18923464ebd5Sriastradh params[0] = d->offset; 18933464ebd5Sriastradh break; 1894cdc920a0Smrg 189501e04c3fSmrg case TYPE_FLOAT_8: 189601e04c3fSmrg params[7] = IROUND(((GLfloat *) p)[7]); 189701e04c3fSmrg params[6] = IROUND(((GLfloat *) p)[6]); 189801e04c3fSmrg params[5] = IROUND(((GLfloat *) p)[5]); 189901e04c3fSmrg params[4] = IROUND(((GLfloat *) p)[4]); 19003464ebd5Sriastradh case TYPE_FLOAT_4: 19013464ebd5Sriastradh params[3] = IROUND(((GLfloat *) p)[3]); 19023464ebd5Sriastradh case TYPE_FLOAT_3: 19033464ebd5Sriastradh params[2] = IROUND(((GLfloat *) p)[2]); 19043464ebd5Sriastradh case TYPE_FLOAT_2: 19053464ebd5Sriastradh params[1] = IROUND(((GLfloat *) p)[1]); 19063464ebd5Sriastradh case TYPE_FLOAT: 19073464ebd5Sriastradh params[0] = IROUND(((GLfloat *) p)[0]); 19083464ebd5Sriastradh break; 1909cdc920a0Smrg 19103464ebd5Sriastradh case TYPE_FLOATN_4: 19113464ebd5Sriastradh params[3] = FLOAT_TO_INT(((GLfloat *) p)[3]); 19123464ebd5Sriastradh case TYPE_FLOATN_3: 19133464ebd5Sriastradh params[2] = FLOAT_TO_INT(((GLfloat *) p)[2]); 19143464ebd5Sriastradh case TYPE_FLOATN_2: 19153464ebd5Sriastradh params[1] = FLOAT_TO_INT(((GLfloat *) p)[1]); 19163464ebd5Sriastradh case TYPE_FLOATN: 19173464ebd5Sriastradh params[0] = FLOAT_TO_INT(((GLfloat *) p)[0]); 19183464ebd5Sriastradh break; 19193464ebd5Sriastradh 1920af69d88dSmrg case TYPE_DOUBLEN_2: 1921af69d88dSmrg params[1] = FLOAT_TO_INT(((GLdouble *) p)[1]); 19223464ebd5Sriastradh case TYPE_DOUBLEN: 19233464ebd5Sriastradh params[0] = FLOAT_TO_INT(((GLdouble *) p)[0]); 19243464ebd5Sriastradh break; 19253464ebd5Sriastradh 19263464ebd5Sriastradh case TYPE_INT_4: 192701e04c3fSmrg case TYPE_UINT_4: 19283464ebd5Sriastradh params[3] = ((GLint *) p)[3]; 19293464ebd5Sriastradh case TYPE_INT_3: 193001e04c3fSmrg case TYPE_UINT_3: 19313464ebd5Sriastradh params[2] = ((GLint *) p)[2]; 19323464ebd5Sriastradh case TYPE_INT_2: 193301e04c3fSmrg case TYPE_UINT_2: 19343464ebd5Sriastradh case TYPE_ENUM_2: 19353464ebd5Sriastradh params[1] = ((GLint *) p)[1]; 19363464ebd5Sriastradh case TYPE_INT: 193701e04c3fSmrg case TYPE_UINT: 19383464ebd5Sriastradh case TYPE_ENUM: 19393464ebd5Sriastradh params[0] = ((GLint *) p)[0]; 19403464ebd5Sriastradh break; 19413464ebd5Sriastradh 194201e04c3fSmrg case TYPE_ENUM16: 194301e04c3fSmrg params[0] = ((GLenum16 *) p)[0]; 194401e04c3fSmrg break; 194501e04c3fSmrg 19463464ebd5Sriastradh case TYPE_INT_N: 19473464ebd5Sriastradh for (i = 0; i < v.value_int_n.n; i++) 194801e04c3fSmrg params[i] = v.value_int_n.ints[i]; 19493464ebd5Sriastradh break; 19503464ebd5Sriastradh 19513464ebd5Sriastradh case TYPE_INT64: 19523464ebd5Sriastradh params[0] = INT64_TO_INT(((GLint64 *) p)[0]); 19533464ebd5Sriastradh break; 19543464ebd5Sriastradh 19553464ebd5Sriastradh case TYPE_BOOLEAN: 19563464ebd5Sriastradh params[0] = BOOLEAN_TO_INT(*(GLboolean*) p); 195701e04c3fSmrg break; 195801e04c3fSmrg 195901e04c3fSmrg case TYPE_UBYTE: 196001e04c3fSmrg params[0] = ((GLubyte *) p)[0]; 196101e04c3fSmrg break; 196201e04c3fSmrg 196301e04c3fSmrg case TYPE_SHORT: 196401e04c3fSmrg params[0] = ((GLshort *) p)[0]; 196501e04c3fSmrg break; 19663464ebd5Sriastradh 19673464ebd5Sriastradh case TYPE_MATRIX: 19683464ebd5Sriastradh m = *(GLmatrix **) p; 19693464ebd5Sriastradh for (i = 0; i < 16; i++) 197001e04c3fSmrg params[i] = FLOAT_TO_INT(m->m[i]); 19713464ebd5Sriastradh break; 19723464ebd5Sriastradh 19733464ebd5Sriastradh case TYPE_MATRIX_T: 19743464ebd5Sriastradh m = *(GLmatrix **) p; 19753464ebd5Sriastradh for (i = 0; i < 16; i++) 197601e04c3fSmrg params[i] = FLOAT_TO_INT(m->m[transpose[i]]); 19773464ebd5Sriastradh break; 19783464ebd5Sriastradh 19793464ebd5Sriastradh case TYPE_BIT_0: 19803464ebd5Sriastradh case TYPE_BIT_1: 19813464ebd5Sriastradh case TYPE_BIT_2: 19823464ebd5Sriastradh case TYPE_BIT_3: 19833464ebd5Sriastradh case TYPE_BIT_4: 19843464ebd5Sriastradh case TYPE_BIT_5: 1985af69d88dSmrg case TYPE_BIT_6: 1986af69d88dSmrg case TYPE_BIT_7: 19873464ebd5Sriastradh shift = d->type - TYPE_BIT_0; 19883464ebd5Sriastradh params[0] = (*(GLbitfield *) p >> shift) & 1; 19893464ebd5Sriastradh break; 1990cdc920a0Smrg } 1991cdc920a0Smrg} 1992cdc920a0Smrg 1993cdc920a0Smrgvoid GLAPIENTRY 19943464ebd5Sriastradh_mesa_GetInteger64v(GLenum pname, GLint64 *params) 1995cdc920a0Smrg{ 19963464ebd5Sriastradh const struct value_desc *d; 19973464ebd5Sriastradh union value v; 19983464ebd5Sriastradh GLmatrix *m; 19993464ebd5Sriastradh int shift, i; 20003464ebd5Sriastradh void *p; 2001cdc920a0Smrg 20023464ebd5Sriastradh d = find_value("glGetInteger64v", pname, &p, &v); 20033464ebd5Sriastradh switch (d->type) { 20043464ebd5Sriastradh case TYPE_INVALID: 20053464ebd5Sriastradh break; 20063464ebd5Sriastradh case TYPE_CONST: 20073464ebd5Sriastradh params[0] = d->offset; 20083464ebd5Sriastradh break; 2009cdc920a0Smrg 201001e04c3fSmrg case TYPE_FLOAT_8: 201101e04c3fSmrg params[7] = IROUND64(((GLfloat *) p)[7]); 201201e04c3fSmrg params[6] = IROUND64(((GLfloat *) p)[6]); 201301e04c3fSmrg params[5] = IROUND64(((GLfloat *) p)[5]); 201401e04c3fSmrg params[4] = IROUND64(((GLfloat *) p)[4]); 20153464ebd5Sriastradh case TYPE_FLOAT_4: 20163464ebd5Sriastradh params[3] = IROUND64(((GLfloat *) p)[3]); 20173464ebd5Sriastradh case TYPE_FLOAT_3: 20183464ebd5Sriastradh params[2] = IROUND64(((GLfloat *) p)[2]); 20193464ebd5Sriastradh case TYPE_FLOAT_2: 20203464ebd5Sriastradh params[1] = IROUND64(((GLfloat *) p)[1]); 20213464ebd5Sriastradh case TYPE_FLOAT: 20223464ebd5Sriastradh params[0] = IROUND64(((GLfloat *) p)[0]); 20233464ebd5Sriastradh break; 2024cdc920a0Smrg 20253464ebd5Sriastradh case TYPE_FLOATN_4: 202601e04c3fSmrg params[3] = FLOAT_TO_INT(((GLfloat *) p)[3]); 20273464ebd5Sriastradh case TYPE_FLOATN_3: 202801e04c3fSmrg params[2] = FLOAT_TO_INT(((GLfloat *) p)[2]); 20293464ebd5Sriastradh case TYPE_FLOATN_2: 203001e04c3fSmrg params[1] = FLOAT_TO_INT(((GLfloat *) p)[1]); 20313464ebd5Sriastradh case TYPE_FLOATN: 203201e04c3fSmrg params[0] = FLOAT_TO_INT(((GLfloat *) p)[0]); 20333464ebd5Sriastradh break; 20343464ebd5Sriastradh 2035af69d88dSmrg case TYPE_DOUBLEN_2: 203601e04c3fSmrg params[1] = FLOAT_TO_INT(((GLdouble *) p)[1]); 20373464ebd5Sriastradh case TYPE_DOUBLEN: 203801e04c3fSmrg params[0] = FLOAT_TO_INT(((GLdouble *) p)[0]); 20393464ebd5Sriastradh break; 20403464ebd5Sriastradh 20413464ebd5Sriastradh case TYPE_INT_4: 20423464ebd5Sriastradh params[3] = ((GLint *) p)[3]; 20433464ebd5Sriastradh case TYPE_INT_3: 20443464ebd5Sriastradh params[2] = ((GLint *) p)[2]; 20453464ebd5Sriastradh case TYPE_INT_2: 20463464ebd5Sriastradh case TYPE_ENUM_2: 20473464ebd5Sriastradh params[1] = ((GLint *) p)[1]; 20483464ebd5Sriastradh case TYPE_INT: 20493464ebd5Sriastradh case TYPE_ENUM: 20503464ebd5Sriastradh params[0] = ((GLint *) p)[0]; 20513464ebd5Sriastradh break; 20523464ebd5Sriastradh 205301e04c3fSmrg case TYPE_ENUM16: 205401e04c3fSmrg params[0] = ((GLenum16 *) p)[0]; 205501e04c3fSmrg break; 205601e04c3fSmrg 20573464ebd5Sriastradh case TYPE_INT_N: 20583464ebd5Sriastradh for (i = 0; i < v.value_int_n.n; i++) 205901e04c3fSmrg params[i] = v.value_int_n.ints[i]; 206001e04c3fSmrg break; 206101e04c3fSmrg 206201e04c3fSmrg case TYPE_UINT_4: 206301e04c3fSmrg params[3] = ((GLuint *) p)[3]; 206401e04c3fSmrg case TYPE_UINT_3: 206501e04c3fSmrg params[2] = ((GLuint *) p)[2]; 206601e04c3fSmrg case TYPE_UINT_2: 206701e04c3fSmrg params[1] = ((GLuint *) p)[1]; 206801e04c3fSmrg case TYPE_UINT: 206901e04c3fSmrg params[0] = ((GLuint *) p)[0]; 20703464ebd5Sriastradh break; 20713464ebd5Sriastradh 20723464ebd5Sriastradh case TYPE_INT64: 20733464ebd5Sriastradh params[0] = ((GLint64 *) p)[0]; 20743464ebd5Sriastradh break; 20753464ebd5Sriastradh 20763464ebd5Sriastradh case TYPE_BOOLEAN: 20773464ebd5Sriastradh params[0] = ((GLboolean*) p)[0]; 207801e04c3fSmrg break; 20793464ebd5Sriastradh 20803464ebd5Sriastradh case TYPE_MATRIX: 20813464ebd5Sriastradh m = *(GLmatrix **) p; 20823464ebd5Sriastradh for (i = 0; i < 16; i++) 208301e04c3fSmrg params[i] = FLOAT_TO_INT64(m->m[i]); 20843464ebd5Sriastradh break; 20853464ebd5Sriastradh 20863464ebd5Sriastradh case TYPE_MATRIX_T: 20873464ebd5Sriastradh m = *(GLmatrix **) p; 20883464ebd5Sriastradh for (i = 0; i < 16; i++) 208901e04c3fSmrg params[i] = FLOAT_TO_INT64(m->m[transpose[i]]); 20903464ebd5Sriastradh break; 20913464ebd5Sriastradh 20923464ebd5Sriastradh case TYPE_BIT_0: 20933464ebd5Sriastradh case TYPE_BIT_1: 20943464ebd5Sriastradh case TYPE_BIT_2: 20953464ebd5Sriastradh case TYPE_BIT_3: 20963464ebd5Sriastradh case TYPE_BIT_4: 20973464ebd5Sriastradh case TYPE_BIT_5: 2098af69d88dSmrg case TYPE_BIT_6: 2099af69d88dSmrg case TYPE_BIT_7: 21003464ebd5Sriastradh shift = d->type - TYPE_BIT_0; 21013464ebd5Sriastradh params[0] = (*(GLbitfield *) p >> shift) & 1; 21023464ebd5Sriastradh break; 2103cdc920a0Smrg } 2104cdc920a0Smrg} 2105cdc920a0Smrg 2106cdc920a0Smrgvoid GLAPIENTRY 21073464ebd5Sriastradh_mesa_GetDoublev(GLenum pname, GLdouble *params) 2108cdc920a0Smrg{ 21093464ebd5Sriastradh const struct value_desc *d; 21103464ebd5Sriastradh union value v; 21113464ebd5Sriastradh GLmatrix *m; 21123464ebd5Sriastradh int shift, i; 21133464ebd5Sriastradh void *p; 2114cdc920a0Smrg 21153464ebd5Sriastradh d = find_value("glGetDoublev", pname, &p, &v); 21163464ebd5Sriastradh switch (d->type) { 21173464ebd5Sriastradh case TYPE_INVALID: 21183464ebd5Sriastradh break; 21193464ebd5Sriastradh case TYPE_CONST: 21203464ebd5Sriastradh params[0] = d->offset; 21213464ebd5Sriastradh break; 21223464ebd5Sriastradh 212301e04c3fSmrg case TYPE_FLOAT_8: 212401e04c3fSmrg params[7] = ((GLfloat *) p)[7]; 212501e04c3fSmrg params[6] = ((GLfloat *) p)[6]; 212601e04c3fSmrg params[5] = ((GLfloat *) p)[5]; 212701e04c3fSmrg params[4] = ((GLfloat *) p)[4]; 21283464ebd5Sriastradh case TYPE_FLOAT_4: 21293464ebd5Sriastradh case TYPE_FLOATN_4: 21303464ebd5Sriastradh params[3] = ((GLfloat *) p)[3]; 21313464ebd5Sriastradh case TYPE_FLOAT_3: 21323464ebd5Sriastradh case TYPE_FLOATN_3: 21333464ebd5Sriastradh params[2] = ((GLfloat *) p)[2]; 21343464ebd5Sriastradh case TYPE_FLOAT_2: 21353464ebd5Sriastradh case TYPE_FLOATN_2: 21363464ebd5Sriastradh params[1] = ((GLfloat *) p)[1]; 21373464ebd5Sriastradh case TYPE_FLOAT: 21383464ebd5Sriastradh case TYPE_FLOATN: 21393464ebd5Sriastradh params[0] = ((GLfloat *) p)[0]; 21403464ebd5Sriastradh break; 21413464ebd5Sriastradh 2142af69d88dSmrg case TYPE_DOUBLEN_2: 2143af69d88dSmrg params[1] = ((GLdouble *) p)[1]; 21443464ebd5Sriastradh case TYPE_DOUBLEN: 21453464ebd5Sriastradh params[0] = ((GLdouble *) p)[0]; 21463464ebd5Sriastradh break; 21473464ebd5Sriastradh 21483464ebd5Sriastradh case TYPE_INT_4: 21493464ebd5Sriastradh params[3] = ((GLint *) p)[3]; 21503464ebd5Sriastradh case TYPE_INT_3: 21513464ebd5Sriastradh params[2] = ((GLint *) p)[2]; 21523464ebd5Sriastradh case TYPE_INT_2: 21533464ebd5Sriastradh case TYPE_ENUM_2: 21543464ebd5Sriastradh params[1] = ((GLint *) p)[1]; 21553464ebd5Sriastradh case TYPE_INT: 21563464ebd5Sriastradh case TYPE_ENUM: 21573464ebd5Sriastradh params[0] = ((GLint *) p)[0]; 21583464ebd5Sriastradh break; 21593464ebd5Sriastradh 216001e04c3fSmrg case TYPE_ENUM16: 216101e04c3fSmrg params[0] = ((GLenum16 *) p)[0]; 216201e04c3fSmrg break; 216301e04c3fSmrg 21643464ebd5Sriastradh case TYPE_INT_N: 21653464ebd5Sriastradh for (i = 0; i < v.value_int_n.n; i++) 216601e04c3fSmrg params[i] = v.value_int_n.ints[i]; 216701e04c3fSmrg break; 216801e04c3fSmrg 216901e04c3fSmrg case TYPE_UINT_4: 217001e04c3fSmrg params[3] = ((GLuint *) p)[3]; 217101e04c3fSmrg case TYPE_UINT_3: 217201e04c3fSmrg params[2] = ((GLuint *) p)[2]; 217301e04c3fSmrg case TYPE_UINT_2: 217401e04c3fSmrg params[1] = ((GLuint *) p)[1]; 217501e04c3fSmrg case TYPE_UINT: 217601e04c3fSmrg params[0] = ((GLuint *) p)[0]; 21773464ebd5Sriastradh break; 21783464ebd5Sriastradh 21793464ebd5Sriastradh case TYPE_INT64: 2180af69d88dSmrg params[0] = (GLdouble) (((GLint64 *) p)[0]); 21813464ebd5Sriastradh break; 21823464ebd5Sriastradh 21833464ebd5Sriastradh case TYPE_BOOLEAN: 21843464ebd5Sriastradh params[0] = *(GLboolean*) p; 218501e04c3fSmrg break; 218601e04c3fSmrg 218701e04c3fSmrg case TYPE_UBYTE: 218801e04c3fSmrg params[0] = ((GLubyte *) p)[0]; 218901e04c3fSmrg break; 219001e04c3fSmrg 219101e04c3fSmrg case TYPE_SHORT: 219201e04c3fSmrg params[0] = ((GLshort *) p)[0]; 219301e04c3fSmrg break; 21943464ebd5Sriastradh 21953464ebd5Sriastradh case TYPE_MATRIX: 21963464ebd5Sriastradh m = *(GLmatrix **) p; 21973464ebd5Sriastradh for (i = 0; i < 16; i++) 219801e04c3fSmrg params[i] = m->m[i]; 21993464ebd5Sriastradh break; 22003464ebd5Sriastradh 22013464ebd5Sriastradh case TYPE_MATRIX_T: 22023464ebd5Sriastradh m = *(GLmatrix **) p; 22033464ebd5Sriastradh for (i = 0; i < 16; i++) 220401e04c3fSmrg params[i] = m->m[transpose[i]]; 22053464ebd5Sriastradh break; 22063464ebd5Sriastradh 22073464ebd5Sriastradh case TYPE_BIT_0: 22083464ebd5Sriastradh case TYPE_BIT_1: 22093464ebd5Sriastradh case TYPE_BIT_2: 22103464ebd5Sriastradh case TYPE_BIT_3: 22113464ebd5Sriastradh case TYPE_BIT_4: 22123464ebd5Sriastradh case TYPE_BIT_5: 2213af69d88dSmrg case TYPE_BIT_6: 2214af69d88dSmrg case TYPE_BIT_7: 22153464ebd5Sriastradh shift = d->type - TYPE_BIT_0; 22163464ebd5Sriastradh params[0] = (*(GLbitfield *) p >> shift) & 1; 22173464ebd5Sriastradh break; 22183464ebd5Sriastradh } 22193464ebd5Sriastradh} 2220cdc920a0Smrg 222101e04c3fSmrgvoid GLAPIENTRY 222201e04c3fSmrg_mesa_GetUnsignedBytevEXT(GLenum pname, GLubyte *data) 222301e04c3fSmrg{ 222401e04c3fSmrg const struct value_desc *d; 222501e04c3fSmrg union value v; 222601e04c3fSmrg int shift; 222701e04c3fSmrg void *p = NULL; 222801e04c3fSmrg GLsizei size; 222901e04c3fSmrg const char *func = "glGetUnsignedBytevEXT"; 223001e04c3fSmrg 223101e04c3fSmrg GET_CURRENT_CONTEXT(ctx); 223201e04c3fSmrg 223301e04c3fSmrg if (!ctx->Extensions.EXT_memory_object) { 223401e04c3fSmrg _mesa_error(ctx, GL_INVALID_OPERATION, "%s(unsupported)", func); 223501e04c3fSmrg return; 223601e04c3fSmrg } 223701e04c3fSmrg 223801e04c3fSmrg d = find_value(func, pname, &p, &v); 223901e04c3fSmrg size = get_value_size(d->type, &v); 224001e04c3fSmrg if (size <= 0) { 224101e04c3fSmrg _mesa_problem(ctx, "invalid value type in GetUnsignedBytevEXT()"); 224201e04c3fSmrg } 224301e04c3fSmrg 224401e04c3fSmrg switch (d->type) { 224501e04c3fSmrg case TYPE_BIT_0: 224601e04c3fSmrg case TYPE_BIT_1: 224701e04c3fSmrg case TYPE_BIT_2: 224801e04c3fSmrg case TYPE_BIT_3: 224901e04c3fSmrg case TYPE_BIT_4: 225001e04c3fSmrg case TYPE_BIT_5: 225101e04c3fSmrg case TYPE_BIT_6: 225201e04c3fSmrg case TYPE_BIT_7: 225301e04c3fSmrg shift = d->type - TYPE_BIT_0; 225401e04c3fSmrg data[0] = (*(GLbitfield *) p >> shift) & 1; 225501e04c3fSmrg break; 225601e04c3fSmrg case TYPE_CONST: 225701e04c3fSmrg memcpy(data, &d->offset, size); 225801e04c3fSmrg break; 225901e04c3fSmrg case TYPE_INT_N: 226001e04c3fSmrg memcpy(data, &v.value_int_n.ints, size); 226101e04c3fSmrg break; 226201e04c3fSmrg case TYPE_UINT: 226301e04c3fSmrg case TYPE_INT: 226401e04c3fSmrg case TYPE_INT_2: 226501e04c3fSmrg case TYPE_UINT_2: 226601e04c3fSmrg case TYPE_INT_3: 226701e04c3fSmrg case TYPE_UINT_3: 226801e04c3fSmrg case TYPE_INT_4: 226901e04c3fSmrg case TYPE_UINT_4: 227001e04c3fSmrg case TYPE_INT64: 227101e04c3fSmrg case TYPE_ENUM: 227201e04c3fSmrg case TYPE_ENUM_2: 227301e04c3fSmrg case TYPE_BOOLEAN: 227401e04c3fSmrg case TYPE_UBYTE: 227501e04c3fSmrg case TYPE_SHORT: 227601e04c3fSmrg case TYPE_FLOAT: 227701e04c3fSmrg case TYPE_FLOATN: 227801e04c3fSmrg case TYPE_FLOAT_2: 227901e04c3fSmrg case TYPE_FLOATN_2: 228001e04c3fSmrg case TYPE_FLOAT_3: 228101e04c3fSmrg case TYPE_FLOATN_3: 228201e04c3fSmrg case TYPE_FLOAT_4: 228301e04c3fSmrg case TYPE_FLOATN_4: 228401e04c3fSmrg case TYPE_FLOAT_8: 228501e04c3fSmrg case TYPE_DOUBLEN: 228601e04c3fSmrg case TYPE_DOUBLEN_2: 228701e04c3fSmrg case TYPE_MATRIX: 228801e04c3fSmrg case TYPE_MATRIX_T: 228901e04c3fSmrg memcpy(data, p, size); 229001e04c3fSmrg break; 229101e04c3fSmrg case TYPE_ENUM16: { 229201e04c3fSmrg GLenum e = *(GLenum16 *)p; 229301e04c3fSmrg memcpy(data, &e, sizeof(e)); 229401e04c3fSmrg break; 229501e04c3fSmrg } 229601e04c3fSmrg default: 229701e04c3fSmrg break; /* nothing - GL error was recorded */ 229801e04c3fSmrg } 229901e04c3fSmrg} 230001e04c3fSmrg 230101e04c3fSmrg/** 230201e04c3fSmrg * Convert a GL texture binding enum such as GL_TEXTURE_BINDING_2D 230301e04c3fSmrg * into the corresponding Mesa texture target index. 230401e04c3fSmrg * \return TEXTURE_x_INDEX or -1 if binding is invalid 230501e04c3fSmrg */ 230601e04c3fSmrgstatic int 230701e04c3fSmrgtex_binding_to_index(const struct gl_context *ctx, GLenum binding) 230801e04c3fSmrg{ 230901e04c3fSmrg switch (binding) { 231001e04c3fSmrg case GL_TEXTURE_BINDING_1D: 231101e04c3fSmrg return _mesa_is_desktop_gl(ctx) ? TEXTURE_1D_INDEX : -1; 231201e04c3fSmrg case GL_TEXTURE_BINDING_2D: 231301e04c3fSmrg return TEXTURE_2D_INDEX; 231401e04c3fSmrg case GL_TEXTURE_BINDING_3D: 231501e04c3fSmrg return ctx->API != API_OPENGLES ? TEXTURE_3D_INDEX : -1; 231601e04c3fSmrg case GL_TEXTURE_BINDING_CUBE_MAP: 231701e04c3fSmrg return ctx->Extensions.ARB_texture_cube_map 231801e04c3fSmrg ? TEXTURE_CUBE_INDEX : -1; 231901e04c3fSmrg case GL_TEXTURE_BINDING_RECTANGLE: 232001e04c3fSmrg return _mesa_is_desktop_gl(ctx) && ctx->Extensions.NV_texture_rectangle 232101e04c3fSmrg ? TEXTURE_RECT_INDEX : -1; 232201e04c3fSmrg case GL_TEXTURE_BINDING_1D_ARRAY: 232301e04c3fSmrg return _mesa_is_desktop_gl(ctx) && ctx->Extensions.EXT_texture_array 232401e04c3fSmrg ? TEXTURE_1D_ARRAY_INDEX : -1; 232501e04c3fSmrg case GL_TEXTURE_BINDING_2D_ARRAY: 232601e04c3fSmrg return (_mesa_is_desktop_gl(ctx) && ctx->Extensions.EXT_texture_array) 232701e04c3fSmrg || _mesa_is_gles3(ctx) 232801e04c3fSmrg ? TEXTURE_2D_ARRAY_INDEX : -1; 232901e04c3fSmrg case GL_TEXTURE_BINDING_BUFFER: 233001e04c3fSmrg return (_mesa_has_ARB_texture_buffer_object(ctx) || 233101e04c3fSmrg _mesa_has_OES_texture_buffer(ctx)) ? 233201e04c3fSmrg TEXTURE_BUFFER_INDEX : -1; 233301e04c3fSmrg case GL_TEXTURE_BINDING_CUBE_MAP_ARRAY: 233401e04c3fSmrg return _mesa_has_texture_cube_map_array(ctx) 233501e04c3fSmrg ? TEXTURE_CUBE_ARRAY_INDEX : -1; 233601e04c3fSmrg case GL_TEXTURE_BINDING_2D_MULTISAMPLE: 233701e04c3fSmrg return _mesa_is_desktop_gl(ctx) && ctx->Extensions.ARB_texture_multisample 233801e04c3fSmrg ? TEXTURE_2D_MULTISAMPLE_INDEX : -1; 233901e04c3fSmrg case GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY: 234001e04c3fSmrg return _mesa_is_desktop_gl(ctx) && ctx->Extensions.ARB_texture_multisample 234101e04c3fSmrg ? TEXTURE_2D_MULTISAMPLE_ARRAY_INDEX : -1; 234201e04c3fSmrg default: 234301e04c3fSmrg return -1; 234401e04c3fSmrg } 234501e04c3fSmrg} 234601e04c3fSmrg 23473464ebd5Sriastradhstatic enum value_type 2348af69d88dSmrgfind_value_indexed(const char *func, GLenum pname, GLuint index, union value *v) 23493464ebd5Sriastradh{ 23503464ebd5Sriastradh GET_CURRENT_CONTEXT(ctx); 2351cdc920a0Smrg 2352cdc920a0Smrg switch (pname) { 23533464ebd5Sriastradh 23543464ebd5Sriastradh case GL_BLEND: 23553464ebd5Sriastradh if (index >= ctx->Const.MaxDrawBuffers) 235601e04c3fSmrg goto invalid_value; 23573464ebd5Sriastradh if (!ctx->Extensions.EXT_draw_buffers2) 235801e04c3fSmrg goto invalid_enum; 23593464ebd5Sriastradh v->value_int = (ctx->Color.BlendEnabled >> index) & 1; 23603464ebd5Sriastradh return TYPE_INT; 23613464ebd5Sriastradh 23623464ebd5Sriastradh case GL_BLEND_SRC: 23633464ebd5Sriastradh /* fall-through */ 23643464ebd5Sriastradh case GL_BLEND_SRC_RGB: 23653464ebd5Sriastradh if (index >= ctx->Const.MaxDrawBuffers) 236601e04c3fSmrg goto invalid_value; 23673464ebd5Sriastradh if (!ctx->Extensions.ARB_draw_buffers_blend) 236801e04c3fSmrg goto invalid_enum; 23693464ebd5Sriastradh v->value_int = ctx->Color.Blend[index].SrcRGB; 23703464ebd5Sriastradh return TYPE_INT; 23713464ebd5Sriastradh case GL_BLEND_SRC_ALPHA: 23723464ebd5Sriastradh if (index >= ctx->Const.MaxDrawBuffers) 237301e04c3fSmrg goto invalid_value; 23743464ebd5Sriastradh if (!ctx->Extensions.ARB_draw_buffers_blend) 237501e04c3fSmrg goto invalid_enum; 23763464ebd5Sriastradh v->value_int = ctx->Color.Blend[index].SrcA; 23773464ebd5Sriastradh return TYPE_INT; 23783464ebd5Sriastradh case GL_BLEND_DST: 23793464ebd5Sriastradh /* fall-through */ 23803464ebd5Sriastradh case GL_BLEND_DST_RGB: 23813464ebd5Sriastradh if (index >= ctx->Const.MaxDrawBuffers) 238201e04c3fSmrg goto invalid_value; 23833464ebd5Sriastradh if (!ctx->Extensions.ARB_draw_buffers_blend) 238401e04c3fSmrg goto invalid_enum; 23853464ebd5Sriastradh v->value_int = ctx->Color.Blend[index].DstRGB; 23863464ebd5Sriastradh return TYPE_INT; 23873464ebd5Sriastradh case GL_BLEND_DST_ALPHA: 23883464ebd5Sriastradh if (index >= ctx->Const.MaxDrawBuffers) 238901e04c3fSmrg goto invalid_value; 23903464ebd5Sriastradh if (!ctx->Extensions.ARB_draw_buffers_blend) 239101e04c3fSmrg goto invalid_enum; 23923464ebd5Sriastradh v->value_int = ctx->Color.Blend[index].DstA; 23933464ebd5Sriastradh return TYPE_INT; 23943464ebd5Sriastradh case GL_BLEND_EQUATION_RGB: 23953464ebd5Sriastradh if (index >= ctx->Const.MaxDrawBuffers) 239601e04c3fSmrg goto invalid_value; 23973464ebd5Sriastradh if (!ctx->Extensions.ARB_draw_buffers_blend) 239801e04c3fSmrg goto invalid_enum; 23993464ebd5Sriastradh v->value_int = ctx->Color.Blend[index].EquationRGB; 24003464ebd5Sriastradh return TYPE_INT; 24013464ebd5Sriastradh case GL_BLEND_EQUATION_ALPHA: 24023464ebd5Sriastradh if (index >= ctx->Const.MaxDrawBuffers) 240301e04c3fSmrg goto invalid_value; 24043464ebd5Sriastradh if (!ctx->Extensions.ARB_draw_buffers_blend) 240501e04c3fSmrg goto invalid_enum; 24063464ebd5Sriastradh v->value_int = ctx->Color.Blend[index].EquationA; 24073464ebd5Sriastradh return TYPE_INT; 24083464ebd5Sriastradh 24093464ebd5Sriastradh case GL_COLOR_WRITEMASK: 24103464ebd5Sriastradh if (index >= ctx->Const.MaxDrawBuffers) 241101e04c3fSmrg goto invalid_value; 24123464ebd5Sriastradh if (!ctx->Extensions.EXT_draw_buffers2) 241301e04c3fSmrg goto invalid_enum; 241401e04c3fSmrg v->value_int_4[0] = GET_COLORMASK_BIT(ctx->Color.ColorMask, index, 0); 241501e04c3fSmrg v->value_int_4[1] = GET_COLORMASK_BIT(ctx->Color.ColorMask, index, 1); 241601e04c3fSmrg v->value_int_4[2] = GET_COLORMASK_BIT(ctx->Color.ColorMask, index, 2); 241701e04c3fSmrg v->value_int_4[3] = GET_COLORMASK_BIT(ctx->Color.ColorMask, index, 3); 24183464ebd5Sriastradh return TYPE_INT_4; 24193464ebd5Sriastradh 2420af69d88dSmrg case GL_SCISSOR_BOX: 2421af69d88dSmrg if (index >= ctx->Const.MaxViewports) 2422af69d88dSmrg goto invalid_value; 2423af69d88dSmrg v->value_int_4[0] = ctx->Scissor.ScissorArray[index].X; 2424af69d88dSmrg v->value_int_4[1] = ctx->Scissor.ScissorArray[index].Y; 2425af69d88dSmrg v->value_int_4[2] = ctx->Scissor.ScissorArray[index].Width; 2426af69d88dSmrg v->value_int_4[3] = ctx->Scissor.ScissorArray[index].Height; 2427af69d88dSmrg return TYPE_INT_4; 2428af69d88dSmrg 242901e04c3fSmrg case GL_WINDOW_RECTANGLE_EXT: 243001e04c3fSmrg if (!ctx->Extensions.EXT_window_rectangles) 243101e04c3fSmrg goto invalid_enum; 243201e04c3fSmrg if (index >= ctx->Const.MaxWindowRectangles) 243301e04c3fSmrg goto invalid_value; 243401e04c3fSmrg v->value_int_4[0] = ctx->Scissor.WindowRects[index].X; 243501e04c3fSmrg v->value_int_4[1] = ctx->Scissor.WindowRects[index].Y; 243601e04c3fSmrg v->value_int_4[2] = ctx->Scissor.WindowRects[index].Width; 243701e04c3fSmrg v->value_int_4[3] = ctx->Scissor.WindowRects[index].Height; 243801e04c3fSmrg return TYPE_INT_4; 243901e04c3fSmrg 2440af69d88dSmrg case GL_VIEWPORT: 2441af69d88dSmrg if (index >= ctx->Const.MaxViewports) 2442af69d88dSmrg goto invalid_value; 2443af69d88dSmrg v->value_float_4[0] = ctx->ViewportArray[index].X; 2444af69d88dSmrg v->value_float_4[1] = ctx->ViewportArray[index].Y; 2445af69d88dSmrg v->value_float_4[2] = ctx->ViewportArray[index].Width; 2446af69d88dSmrg v->value_float_4[3] = ctx->ViewportArray[index].Height; 2447af69d88dSmrg return TYPE_FLOAT_4; 2448af69d88dSmrg 2449af69d88dSmrg case GL_DEPTH_RANGE: 2450af69d88dSmrg if (index >= ctx->Const.MaxViewports) 2451af69d88dSmrg goto invalid_value; 2452af69d88dSmrg v->value_double_2[0] = ctx->ViewportArray[index].Near; 2453af69d88dSmrg v->value_double_2[1] = ctx->ViewportArray[index].Far; 2454af69d88dSmrg return TYPE_DOUBLEN_2; 2455af69d88dSmrg 24563464ebd5Sriastradh case GL_TRANSFORM_FEEDBACK_BUFFER_START: 2457af69d88dSmrg if (index >= ctx->Const.MaxTransformFeedbackBuffers) 245801e04c3fSmrg goto invalid_value; 24593464ebd5Sriastradh if (!ctx->Extensions.EXT_transform_feedback) 246001e04c3fSmrg goto invalid_enum; 24613464ebd5Sriastradh v->value_int64 = ctx->TransformFeedback.CurrentObject->Offset[index]; 24623464ebd5Sriastradh return TYPE_INT64; 24633464ebd5Sriastradh 24643464ebd5Sriastradh case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE: 2465af69d88dSmrg if (index >= ctx->Const.MaxTransformFeedbackBuffers) 246601e04c3fSmrg goto invalid_value; 24673464ebd5Sriastradh if (!ctx->Extensions.EXT_transform_feedback) 246801e04c3fSmrg goto invalid_enum; 2469af69d88dSmrg v->value_int64 2470af69d88dSmrg = ctx->TransformFeedback.CurrentObject->RequestedSize[index]; 24713464ebd5Sriastradh return TYPE_INT64; 24723464ebd5Sriastradh 24733464ebd5Sriastradh case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING: 2474af69d88dSmrg if (index >= ctx->Const.MaxTransformFeedbackBuffers) 247501e04c3fSmrg goto invalid_value; 24763464ebd5Sriastradh if (!ctx->Extensions.EXT_transform_feedback) 247701e04c3fSmrg goto invalid_enum; 2478af69d88dSmrg v->value_int = ctx->TransformFeedback.CurrentObject->BufferNames[index]; 2479af69d88dSmrg return TYPE_INT; 2480af69d88dSmrg 2481af69d88dSmrg case GL_UNIFORM_BUFFER_BINDING: 2482af69d88dSmrg if (index >= ctx->Const.MaxUniformBufferBindings) 248301e04c3fSmrg goto invalid_value; 2484af69d88dSmrg if (!ctx->Extensions.ARB_uniform_buffer_object) 248501e04c3fSmrg goto invalid_enum; 2486af69d88dSmrg v->value_int = ctx->UniformBufferBindings[index].BufferObject->Name; 2487af69d88dSmrg return TYPE_INT; 2488af69d88dSmrg 2489af69d88dSmrg case GL_UNIFORM_BUFFER_START: 2490af69d88dSmrg if (index >= ctx->Const.MaxUniformBufferBindings) 249101e04c3fSmrg goto invalid_value; 2492af69d88dSmrg if (!ctx->Extensions.ARB_uniform_buffer_object) 249301e04c3fSmrg goto invalid_enum; 249401e04c3fSmrg v->value_int = ctx->UniformBufferBindings[index].Offset < 0 ? 0 : 249501e04c3fSmrg ctx->UniformBufferBindings[index].Offset; 2496af69d88dSmrg return TYPE_INT; 2497af69d88dSmrg 2498af69d88dSmrg case GL_UNIFORM_BUFFER_SIZE: 2499af69d88dSmrg if (index >= ctx->Const.MaxUniformBufferBindings) 250001e04c3fSmrg goto invalid_value; 2501af69d88dSmrg if (!ctx->Extensions.ARB_uniform_buffer_object) 250201e04c3fSmrg goto invalid_enum; 250301e04c3fSmrg v->value_int = ctx->UniformBufferBindings[index].Size < 0 ? 0 : 250401e04c3fSmrg ctx->UniformBufferBindings[index].Size; 250501e04c3fSmrg return TYPE_INT; 250601e04c3fSmrg 250701e04c3fSmrg /* ARB_shader_storage_buffer_object */ 250801e04c3fSmrg case GL_SHADER_STORAGE_BUFFER_BINDING: 250901e04c3fSmrg if (!ctx->Extensions.ARB_shader_storage_buffer_object) 251001e04c3fSmrg goto invalid_enum; 251101e04c3fSmrg if (index >= ctx->Const.MaxShaderStorageBufferBindings) 251201e04c3fSmrg goto invalid_value; 251301e04c3fSmrg v->value_int = ctx->ShaderStorageBufferBindings[index].BufferObject->Name; 251401e04c3fSmrg return TYPE_INT; 251501e04c3fSmrg 251601e04c3fSmrg case GL_SHADER_STORAGE_BUFFER_START: 251701e04c3fSmrg if (!ctx->Extensions.ARB_shader_storage_buffer_object) 251801e04c3fSmrg goto invalid_enum; 251901e04c3fSmrg if (index >= ctx->Const.MaxShaderStorageBufferBindings) 252001e04c3fSmrg goto invalid_value; 252101e04c3fSmrg v->value_int = ctx->ShaderStorageBufferBindings[index].Offset < 0 ? 0 : 252201e04c3fSmrg ctx->ShaderStorageBufferBindings[index].Offset; 252301e04c3fSmrg return TYPE_INT; 252401e04c3fSmrg 252501e04c3fSmrg case GL_SHADER_STORAGE_BUFFER_SIZE: 252601e04c3fSmrg if (!ctx->Extensions.ARB_shader_storage_buffer_object) 252701e04c3fSmrg goto invalid_enum; 252801e04c3fSmrg if (index >= ctx->Const.MaxShaderStorageBufferBindings) 252901e04c3fSmrg goto invalid_value; 253001e04c3fSmrg v->value_int = ctx->ShaderStorageBufferBindings[index].Size < 0 ? 0 : 253101e04c3fSmrg ctx->ShaderStorageBufferBindings[index].Size; 2532af69d88dSmrg return TYPE_INT; 2533af69d88dSmrg 2534af69d88dSmrg /* ARB_texture_multisample / GL3.2 */ 2535af69d88dSmrg case GL_SAMPLE_MASK_VALUE: 2536af69d88dSmrg if (index != 0) 2537af69d88dSmrg goto invalid_value; 2538af69d88dSmrg if (!ctx->Extensions.ARB_texture_multisample) 2539af69d88dSmrg goto invalid_enum; 2540af69d88dSmrg v->value_int = ctx->Multisample.SampleMaskValue; 2541af69d88dSmrg return TYPE_INT; 2542af69d88dSmrg 2543af69d88dSmrg case GL_ATOMIC_COUNTER_BUFFER_BINDING: 2544af69d88dSmrg if (!ctx->Extensions.ARB_shader_atomic_counters) 2545af69d88dSmrg goto invalid_enum; 2546af69d88dSmrg if (index >= ctx->Const.MaxAtomicBufferBindings) 2547af69d88dSmrg goto invalid_value; 2548af69d88dSmrg v->value_int = ctx->AtomicBufferBindings[index].BufferObject->Name; 2549af69d88dSmrg return TYPE_INT; 2550af69d88dSmrg 2551af69d88dSmrg case GL_ATOMIC_COUNTER_BUFFER_START: 2552af69d88dSmrg if (!ctx->Extensions.ARB_shader_atomic_counters) 2553af69d88dSmrg goto invalid_enum; 2554af69d88dSmrg if (index >= ctx->Const.MaxAtomicBufferBindings) 2555af69d88dSmrg goto invalid_value; 255601e04c3fSmrg v->value_int64 = ctx->AtomicBufferBindings[index].Offset < 0 ? 0 : 255701e04c3fSmrg ctx->AtomicBufferBindings[index].Offset; 2558af69d88dSmrg return TYPE_INT64; 2559af69d88dSmrg 2560af69d88dSmrg case GL_ATOMIC_COUNTER_BUFFER_SIZE: 2561af69d88dSmrg if (!ctx->Extensions.ARB_shader_atomic_counters) 2562af69d88dSmrg goto invalid_enum; 2563af69d88dSmrg if (index >= ctx->Const.MaxAtomicBufferBindings) 2564af69d88dSmrg goto invalid_value; 256501e04c3fSmrg v->value_int64 = ctx->AtomicBufferBindings[index].Size < 0 ? 0 : 256601e04c3fSmrg ctx->AtomicBufferBindings[index].Size; 2567af69d88dSmrg return TYPE_INT64; 2568af69d88dSmrg 2569af69d88dSmrg case GL_VERTEX_BINDING_DIVISOR: 257001e04c3fSmrg if ((!_mesa_is_desktop_gl(ctx) || !ctx->Extensions.ARB_instanced_arrays) && 257101e04c3fSmrg !_mesa_is_gles31(ctx)) 2572af69d88dSmrg goto invalid_enum; 2573af69d88dSmrg if (index >= ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs) 2574af69d88dSmrg goto invalid_value; 257501e04c3fSmrg v->value_int = ctx->Array.VAO->BufferBinding[VERT_ATTRIB_GENERIC(index)].InstanceDivisor; 2576af69d88dSmrg return TYPE_INT; 2577af69d88dSmrg 2578af69d88dSmrg case GL_VERTEX_BINDING_OFFSET: 257901e04c3fSmrg if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles31(ctx)) 2580af69d88dSmrg goto invalid_enum; 2581af69d88dSmrg if (index >= ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs) 2582af69d88dSmrg goto invalid_value; 258301e04c3fSmrg v->value_int = ctx->Array.VAO->BufferBinding[VERT_ATTRIB_GENERIC(index)].Offset; 2584af69d88dSmrg return TYPE_INT; 2585af69d88dSmrg 2586af69d88dSmrg case GL_VERTEX_BINDING_STRIDE: 258701e04c3fSmrg if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles31(ctx)) 2588af69d88dSmrg goto invalid_enum; 2589af69d88dSmrg if (index >= ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs) 2590af69d88dSmrg goto invalid_value; 259101e04c3fSmrg v->value_int = ctx->Array.VAO->BufferBinding[VERT_ATTRIB_GENERIC(index)].Stride; 259201e04c3fSmrg return TYPE_INT; 259301e04c3fSmrg 259401e04c3fSmrg case GL_VERTEX_BINDING_BUFFER: 259501e04c3fSmrg if (ctx->API == API_OPENGLES2 && ctx->Version < 31) 259601e04c3fSmrg goto invalid_enum; 259701e04c3fSmrg if (index >= ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs) 259801e04c3fSmrg goto invalid_value; 259901e04c3fSmrg v->value_int = ctx->Array.VAO->BufferBinding[VERT_ATTRIB_GENERIC(index)].BufferObj->Name; 260001e04c3fSmrg return TYPE_INT; 2601af69d88dSmrg 2602af69d88dSmrg /* ARB_shader_image_load_store */ 2603af69d88dSmrg case GL_IMAGE_BINDING_NAME: { 2604af69d88dSmrg struct gl_texture_object *t; 2605af69d88dSmrg 2606af69d88dSmrg if (!ctx->Extensions.ARB_shader_image_load_store) 2607af69d88dSmrg goto invalid_enum; 2608af69d88dSmrg if (index >= ctx->Const.MaxImageUnits) 2609af69d88dSmrg goto invalid_value; 2610af69d88dSmrg 2611af69d88dSmrg t = ctx->ImageUnits[index].TexObj; 2612af69d88dSmrg v->value_int = (t ? t->Name : 0); 2613af69d88dSmrg return TYPE_INT; 2614af69d88dSmrg } 2615af69d88dSmrg 2616af69d88dSmrg case GL_IMAGE_BINDING_LEVEL: 2617af69d88dSmrg if (!ctx->Extensions.ARB_shader_image_load_store) 2618af69d88dSmrg goto invalid_enum; 2619af69d88dSmrg if (index >= ctx->Const.MaxImageUnits) 2620af69d88dSmrg goto invalid_value; 2621af69d88dSmrg 2622af69d88dSmrg v->value_int = ctx->ImageUnits[index].Level; 2623af69d88dSmrg return TYPE_INT; 2624af69d88dSmrg 2625af69d88dSmrg case GL_IMAGE_BINDING_LAYERED: 2626af69d88dSmrg if (!ctx->Extensions.ARB_shader_image_load_store) 2627af69d88dSmrg goto invalid_enum; 2628af69d88dSmrg if (index >= ctx->Const.MaxImageUnits) 2629af69d88dSmrg goto invalid_value; 2630af69d88dSmrg 2631af69d88dSmrg v->value_int = ctx->ImageUnits[index].Layered; 2632af69d88dSmrg return TYPE_INT; 2633af69d88dSmrg 2634af69d88dSmrg case GL_IMAGE_BINDING_LAYER: 2635af69d88dSmrg if (!ctx->Extensions.ARB_shader_image_load_store) 2636af69d88dSmrg goto invalid_enum; 2637af69d88dSmrg if (index >= ctx->Const.MaxImageUnits) 2638af69d88dSmrg goto invalid_value; 2639af69d88dSmrg 2640af69d88dSmrg v->value_int = ctx->ImageUnits[index].Layer; 2641af69d88dSmrg return TYPE_INT; 2642af69d88dSmrg 2643af69d88dSmrg case GL_IMAGE_BINDING_ACCESS: 2644af69d88dSmrg if (!ctx->Extensions.ARB_shader_image_load_store) 2645af69d88dSmrg goto invalid_enum; 2646af69d88dSmrg if (index >= ctx->Const.MaxImageUnits) 2647af69d88dSmrg goto invalid_value; 2648af69d88dSmrg 2649af69d88dSmrg v->value_int = ctx->ImageUnits[index].Access; 2650af69d88dSmrg return TYPE_INT; 2651af69d88dSmrg 2652af69d88dSmrg case GL_IMAGE_BINDING_FORMAT: 2653af69d88dSmrg if (!ctx->Extensions.ARB_shader_image_load_store) 2654af69d88dSmrg goto invalid_enum; 2655af69d88dSmrg if (index >= ctx->Const.MaxImageUnits) 2656af69d88dSmrg goto invalid_value; 2657af69d88dSmrg 2658af69d88dSmrg v->value_int = ctx->ImageUnits[index].Format; 2659af69d88dSmrg return TYPE_INT; 2660af69d88dSmrg 266101e04c3fSmrg /* ARB_direct_state_access */ 266201e04c3fSmrg case GL_TEXTURE_BINDING_1D: 266301e04c3fSmrg case GL_TEXTURE_BINDING_1D_ARRAY: 266401e04c3fSmrg case GL_TEXTURE_BINDING_2D: 266501e04c3fSmrg case GL_TEXTURE_BINDING_2D_ARRAY: 266601e04c3fSmrg case GL_TEXTURE_BINDING_2D_MULTISAMPLE: 266701e04c3fSmrg case GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY: 266801e04c3fSmrg case GL_TEXTURE_BINDING_3D: 266901e04c3fSmrg case GL_TEXTURE_BINDING_BUFFER: 267001e04c3fSmrg case GL_TEXTURE_BINDING_CUBE_MAP: 267101e04c3fSmrg case GL_TEXTURE_BINDING_CUBE_MAP_ARRAY: 267201e04c3fSmrg case GL_TEXTURE_BINDING_RECTANGLE: { 267301e04c3fSmrg int target; 267401e04c3fSmrg 267501e04c3fSmrg if (ctx->API != API_OPENGL_CORE) 267601e04c3fSmrg goto invalid_enum; 267701e04c3fSmrg target = tex_binding_to_index(ctx, pname); 267801e04c3fSmrg if (target < 0) 267901e04c3fSmrg goto invalid_enum; 268001e04c3fSmrg if (index >= _mesa_max_tex_unit(ctx)) 268101e04c3fSmrg goto invalid_value; 268201e04c3fSmrg 268301e04c3fSmrg v->value_int = ctx->Texture.Unit[index].CurrentTex[target]->Name; 268401e04c3fSmrg return TYPE_INT; 268501e04c3fSmrg } 268601e04c3fSmrg 268701e04c3fSmrg case GL_SAMPLER_BINDING: { 268801e04c3fSmrg struct gl_sampler_object *samp; 268901e04c3fSmrg 269001e04c3fSmrg if (!_mesa_is_desktop_gl(ctx) || ctx->Version < 33) 269101e04c3fSmrg goto invalid_enum; 269201e04c3fSmrg if (index >= _mesa_max_tex_unit(ctx)) 269301e04c3fSmrg goto invalid_value; 269401e04c3fSmrg 269501e04c3fSmrg samp = ctx->Texture.Unit[index].Sampler; 269601e04c3fSmrg v->value_int = samp ? samp->Name : 0; 269701e04c3fSmrg return TYPE_INT; 269801e04c3fSmrg } 269901e04c3fSmrg 2700af69d88dSmrg case GL_MAX_COMPUTE_WORK_GROUP_COUNT: 270101e04c3fSmrg if (!_mesa_has_compute_shaders(ctx)) 2702af69d88dSmrg goto invalid_enum; 2703af69d88dSmrg if (index >= 3) 2704af69d88dSmrg goto invalid_value; 2705af69d88dSmrg v->value_int = ctx->Const.MaxComputeWorkGroupCount[index]; 2706af69d88dSmrg return TYPE_INT; 2707af69d88dSmrg 2708af69d88dSmrg case GL_MAX_COMPUTE_WORK_GROUP_SIZE: 270901e04c3fSmrg if (!_mesa_has_compute_shaders(ctx)) 2710af69d88dSmrg goto invalid_enum; 2711af69d88dSmrg if (index >= 3) 2712af69d88dSmrg goto invalid_value; 2713af69d88dSmrg v->value_int = ctx->Const.MaxComputeWorkGroupSize[index]; 27143464ebd5Sriastradh return TYPE_INT; 271501e04c3fSmrg 271601e04c3fSmrg /* ARB_compute_variable_group_size */ 271701e04c3fSmrg case GL_MAX_COMPUTE_VARIABLE_GROUP_SIZE_ARB: 271801e04c3fSmrg if (!ctx->Extensions.ARB_compute_variable_group_size) 271901e04c3fSmrg goto invalid_enum; 272001e04c3fSmrg if (index >= 3) 272101e04c3fSmrg goto invalid_value; 272201e04c3fSmrg v->value_int = ctx->Const.MaxComputeVariableGroupSize[index]; 272301e04c3fSmrg return TYPE_INT; 272401e04c3fSmrg 272501e04c3fSmrg /* GL_EXT_external_objects */ 272601e04c3fSmrg case GL_NUM_DEVICE_UUIDS_EXT: 272701e04c3fSmrg v->value_int = 1; 272801e04c3fSmrg return TYPE_INT; 272901e04c3fSmrg case GL_DRIVER_UUID_EXT: 273001e04c3fSmrg if (index >= 1) 273101e04c3fSmrg goto invalid_value; 273201e04c3fSmrg _mesa_get_driver_uuid(ctx, v->value_int_4); 273301e04c3fSmrg return TYPE_INT_4; 273401e04c3fSmrg case GL_DEVICE_UUID_EXT: 273501e04c3fSmrg if (index >= 1) 273601e04c3fSmrg goto invalid_value; 273701e04c3fSmrg _mesa_get_device_uuid(ctx, v->value_int_4); 273801e04c3fSmrg return TYPE_INT_4; 27393464ebd5Sriastradh } 27403464ebd5Sriastradh 27413464ebd5Sriastradh invalid_enum: 27423464ebd5Sriastradh _mesa_error(ctx, GL_INVALID_ENUM, "%s(pname=%s)", func, 274301e04c3fSmrg _mesa_enum_to_string(pname)); 27443464ebd5Sriastradh return TYPE_INVALID; 27453464ebd5Sriastradh invalid_value: 27463464ebd5Sriastradh _mesa_error(ctx, GL_INVALID_VALUE, "%s(pname=%s)", func, 274701e04c3fSmrg _mesa_enum_to_string(pname)); 27483464ebd5Sriastradh return TYPE_INVALID; 27493464ebd5Sriastradh} 27503464ebd5Sriastradh 27513464ebd5Sriastradhvoid GLAPIENTRY 2752af69d88dSmrg_mesa_GetBooleani_v( GLenum pname, GLuint index, GLboolean *params ) 27533464ebd5Sriastradh{ 27543464ebd5Sriastradh union value v; 27553464ebd5Sriastradh enum value_type type = 2756af69d88dSmrg find_value_indexed("glGetBooleani_v", pname, index, &v); 27573464ebd5Sriastradh 27583464ebd5Sriastradh switch (type) { 27593464ebd5Sriastradh case TYPE_INT: 276001e04c3fSmrg case TYPE_UINT: 27613464ebd5Sriastradh params[0] = INT_TO_BOOLEAN(v.value_int); 27623464ebd5Sriastradh break; 27633464ebd5Sriastradh case TYPE_INT_4: 276401e04c3fSmrg case TYPE_UINT_4: 27653464ebd5Sriastradh params[0] = INT_TO_BOOLEAN(v.value_int_4[0]); 27663464ebd5Sriastradh params[1] = INT_TO_BOOLEAN(v.value_int_4[1]); 27673464ebd5Sriastradh params[2] = INT_TO_BOOLEAN(v.value_int_4[2]); 27683464ebd5Sriastradh params[3] = INT_TO_BOOLEAN(v.value_int_4[3]); 27693464ebd5Sriastradh break; 27703464ebd5Sriastradh case TYPE_INT64: 2771af69d88dSmrg params[0] = INT64_TO_BOOLEAN(v.value_int64); 27723464ebd5Sriastradh break; 27733464ebd5Sriastradh default: 27743464ebd5Sriastradh ; /* nothing - GL error was recorded */ 27753464ebd5Sriastradh } 27763464ebd5Sriastradh} 27773464ebd5Sriastradh 27783464ebd5Sriastradhvoid GLAPIENTRY 2779af69d88dSmrg_mesa_GetIntegeri_v( GLenum pname, GLuint index, GLint *params ) 27803464ebd5Sriastradh{ 27813464ebd5Sriastradh union value v; 27823464ebd5Sriastradh enum value_type type = 2783af69d88dSmrg find_value_indexed("glGetIntegeri_v", pname, index, &v); 27843464ebd5Sriastradh 27853464ebd5Sriastradh switch (type) { 2786af69d88dSmrg case TYPE_FLOAT_4: 2787af69d88dSmrg case TYPE_FLOATN_4: 2788af69d88dSmrg params[3] = IROUND(v.value_float_4[3]); 2789af69d88dSmrg case TYPE_FLOAT_3: 2790af69d88dSmrg case TYPE_FLOATN_3: 2791af69d88dSmrg params[2] = IROUND(v.value_float_4[2]); 2792af69d88dSmrg case TYPE_FLOAT_2: 2793af69d88dSmrg case TYPE_FLOATN_2: 2794af69d88dSmrg params[1] = IROUND(v.value_float_4[1]); 2795af69d88dSmrg case TYPE_FLOAT: 2796af69d88dSmrg case TYPE_FLOATN: 2797af69d88dSmrg params[0] = IROUND(v.value_float_4[0]); 2798af69d88dSmrg break; 2799af69d88dSmrg 2800af69d88dSmrg case TYPE_DOUBLEN_2: 2801af69d88dSmrg params[1] = IROUND(v.value_double_2[1]); 2802af69d88dSmrg case TYPE_DOUBLEN: 2803af69d88dSmrg params[0] = IROUND(v.value_double_2[0]); 2804af69d88dSmrg break; 2805af69d88dSmrg 28063464ebd5Sriastradh case TYPE_INT: 280701e04c3fSmrg case TYPE_UINT: 28083464ebd5Sriastradh params[0] = v.value_int; 28093464ebd5Sriastradh break; 28103464ebd5Sriastradh case TYPE_INT_4: 281101e04c3fSmrg case TYPE_UINT_4: 28123464ebd5Sriastradh params[0] = v.value_int_4[0]; 28133464ebd5Sriastradh params[1] = v.value_int_4[1]; 28143464ebd5Sriastradh params[2] = v.value_int_4[2]; 28153464ebd5Sriastradh params[3] = v.value_int_4[3]; 28163464ebd5Sriastradh break; 28173464ebd5Sriastradh case TYPE_INT64: 2818af69d88dSmrg params[0] = INT64_TO_INT(v.value_int64); 28193464ebd5Sriastradh break; 28203464ebd5Sriastradh default: 28213464ebd5Sriastradh ; /* nothing - GL error was recorded */ 28223464ebd5Sriastradh } 28233464ebd5Sriastradh} 28243464ebd5Sriastradh 28253464ebd5Sriastradhvoid GLAPIENTRY 2826af69d88dSmrg_mesa_GetInteger64i_v( GLenum pname, GLuint index, GLint64 *params ) 28273464ebd5Sriastradh{ 28283464ebd5Sriastradh union value v; 28293464ebd5Sriastradh enum value_type type = 2830af69d88dSmrg find_value_indexed("glGetInteger64i_v", pname, index, &v); 28313464ebd5Sriastradh 28323464ebd5Sriastradh switch (type) { 28333464ebd5Sriastradh case TYPE_INT: 28343464ebd5Sriastradh params[0] = v.value_int; 28353464ebd5Sriastradh break; 28363464ebd5Sriastradh case TYPE_INT_4: 28373464ebd5Sriastradh params[0] = v.value_int_4[0]; 28383464ebd5Sriastradh params[1] = v.value_int_4[1]; 28393464ebd5Sriastradh params[2] = v.value_int_4[2]; 28403464ebd5Sriastradh params[3] = v.value_int_4[3]; 28413464ebd5Sriastradh break; 284201e04c3fSmrg case TYPE_UINT: 284301e04c3fSmrg params[0] = (GLuint) v.value_int; 284401e04c3fSmrg break; 284501e04c3fSmrg case TYPE_UINT_4: 284601e04c3fSmrg params[0] = (GLuint) v.value_int_4[0]; 284701e04c3fSmrg params[1] = (GLuint) v.value_int_4[1]; 284801e04c3fSmrg params[2] = (GLuint) v.value_int_4[2]; 284901e04c3fSmrg params[3] = (GLuint) v.value_int_4[3]; 285001e04c3fSmrg break; 28513464ebd5Sriastradh case TYPE_INT64: 2852af69d88dSmrg params[0] = v.value_int64; 28533464ebd5Sriastradh break; 28543464ebd5Sriastradh default: 28553464ebd5Sriastradh ; /* nothing - GL error was recorded */ 2856cdc920a0Smrg } 2857cdc920a0Smrg} 2858cdc920a0Smrg 2859af69d88dSmrgvoid GLAPIENTRY 2860af69d88dSmrg_mesa_GetFloati_v(GLenum pname, GLuint index, GLfloat *params) 2861af69d88dSmrg{ 2862af69d88dSmrg int i; 2863af69d88dSmrg GLmatrix *m; 2864af69d88dSmrg union value v; 2865af69d88dSmrg enum value_type type = 2866af69d88dSmrg find_value_indexed("glGetFloati_v", pname, index, &v); 2867af69d88dSmrg 2868af69d88dSmrg switch (type) { 2869af69d88dSmrg case TYPE_FLOAT_4: 2870af69d88dSmrg case TYPE_FLOATN_4: 2871af69d88dSmrg params[3] = v.value_float_4[3]; 2872af69d88dSmrg case TYPE_FLOAT_3: 2873af69d88dSmrg case TYPE_FLOATN_3: 2874af69d88dSmrg params[2] = v.value_float_4[2]; 2875af69d88dSmrg case TYPE_FLOAT_2: 2876af69d88dSmrg case TYPE_FLOATN_2: 2877af69d88dSmrg params[1] = v.value_float_4[1]; 2878af69d88dSmrg case TYPE_FLOAT: 2879af69d88dSmrg case TYPE_FLOATN: 2880af69d88dSmrg params[0] = v.value_float_4[0]; 2881af69d88dSmrg break; 2882af69d88dSmrg 2883af69d88dSmrg case TYPE_DOUBLEN_2: 2884af69d88dSmrg params[1] = (GLfloat) v.value_double_2[1]; 2885af69d88dSmrg case TYPE_DOUBLEN: 2886af69d88dSmrg params[0] = (GLfloat) v.value_double_2[0]; 2887af69d88dSmrg break; 2888af69d88dSmrg 2889af69d88dSmrg case TYPE_INT_4: 2890af69d88dSmrg params[3] = (GLfloat) v.value_int_4[3]; 2891af69d88dSmrg case TYPE_INT_3: 2892af69d88dSmrg params[2] = (GLfloat) v.value_int_4[2]; 2893af69d88dSmrg case TYPE_INT_2: 2894af69d88dSmrg case TYPE_ENUM_2: 2895af69d88dSmrg params[1] = (GLfloat) v.value_int_4[1]; 2896af69d88dSmrg case TYPE_INT: 2897af69d88dSmrg case TYPE_ENUM: 289801e04c3fSmrg case TYPE_ENUM16: 2899af69d88dSmrg params[0] = (GLfloat) v.value_int_4[0]; 2900af69d88dSmrg break; 2901af69d88dSmrg 2902af69d88dSmrg case TYPE_INT_N: 2903af69d88dSmrg for (i = 0; i < v.value_int_n.n; i++) 290401e04c3fSmrg params[i] = (GLfloat) v.value_int_n.ints[i]; 290501e04c3fSmrg break; 290601e04c3fSmrg 290701e04c3fSmrg case TYPE_UINT_4: 290801e04c3fSmrg params[3] = (GLfloat) ((GLuint) v.value_int_4[3]); 290901e04c3fSmrg case TYPE_UINT_3: 291001e04c3fSmrg params[2] = (GLfloat) ((GLuint) v.value_int_4[2]); 291101e04c3fSmrg case TYPE_UINT_2: 291201e04c3fSmrg params[1] = (GLfloat) ((GLuint) v.value_int_4[1]); 291301e04c3fSmrg case TYPE_UINT: 291401e04c3fSmrg params[0] = (GLfloat) ((GLuint) v.value_int_4[0]); 2915af69d88dSmrg break; 2916af69d88dSmrg 2917af69d88dSmrg case TYPE_INT64: 2918af69d88dSmrg params[0] = (GLfloat) v.value_int64; 2919af69d88dSmrg break; 2920af69d88dSmrg 2921af69d88dSmrg case TYPE_BOOLEAN: 2922af69d88dSmrg params[0] = BOOLEAN_TO_FLOAT(v.value_bool); 2923af69d88dSmrg break; 2924af69d88dSmrg 292501e04c3fSmrg case TYPE_UBYTE: 292601e04c3fSmrg params[0] = (GLfloat) v.value_ubyte; 292701e04c3fSmrg break; 292801e04c3fSmrg 292901e04c3fSmrg case TYPE_SHORT: 293001e04c3fSmrg params[0] = (GLfloat) v.value_short; 293101e04c3fSmrg break; 293201e04c3fSmrg 2933af69d88dSmrg case TYPE_MATRIX: 2934af69d88dSmrg m = *(GLmatrix **) &v; 2935af69d88dSmrg for (i = 0; i < 16; i++) 293601e04c3fSmrg params[i] = m->m[i]; 2937af69d88dSmrg break; 2938af69d88dSmrg 2939af69d88dSmrg case TYPE_MATRIX_T: 2940af69d88dSmrg m = *(GLmatrix **) &v; 2941af69d88dSmrg for (i = 0; i < 16; i++) 294201e04c3fSmrg params[i] = m->m[transpose[i]]; 2943af69d88dSmrg break; 2944af69d88dSmrg 2945af69d88dSmrg default: 2946af69d88dSmrg ; 2947af69d88dSmrg } 2948af69d88dSmrg} 2949af69d88dSmrg 2950af69d88dSmrgvoid GLAPIENTRY 2951af69d88dSmrg_mesa_GetDoublei_v(GLenum pname, GLuint index, GLdouble *params) 2952af69d88dSmrg{ 2953af69d88dSmrg int i; 2954af69d88dSmrg GLmatrix *m; 2955af69d88dSmrg union value v; 2956af69d88dSmrg enum value_type type = 2957af69d88dSmrg find_value_indexed("glGetDoublei_v", pname, index, &v); 2958af69d88dSmrg 2959af69d88dSmrg switch (type) { 2960af69d88dSmrg case TYPE_FLOAT_4: 2961af69d88dSmrg case TYPE_FLOATN_4: 2962af69d88dSmrg params[3] = (GLdouble) v.value_float_4[3]; 2963af69d88dSmrg case TYPE_FLOAT_3: 2964af69d88dSmrg case TYPE_FLOATN_3: 2965af69d88dSmrg params[2] = (GLdouble) v.value_float_4[2]; 2966af69d88dSmrg case TYPE_FLOAT_2: 2967af69d88dSmrg case TYPE_FLOATN_2: 2968af69d88dSmrg params[1] = (GLdouble) v.value_float_4[1]; 2969af69d88dSmrg case TYPE_FLOAT: 2970af69d88dSmrg case TYPE_FLOATN: 2971af69d88dSmrg params[0] = (GLdouble) v.value_float_4[0]; 2972af69d88dSmrg break; 2973af69d88dSmrg 2974af69d88dSmrg case TYPE_DOUBLEN_2: 2975af69d88dSmrg params[1] = v.value_double_2[1]; 2976af69d88dSmrg case TYPE_DOUBLEN: 2977af69d88dSmrg params[0] = v.value_double_2[0]; 2978af69d88dSmrg break; 2979af69d88dSmrg 2980af69d88dSmrg case TYPE_INT_4: 2981af69d88dSmrg params[3] = (GLdouble) v.value_int_4[3]; 2982af69d88dSmrg case TYPE_INT_3: 2983af69d88dSmrg params[2] = (GLdouble) v.value_int_4[2]; 2984af69d88dSmrg case TYPE_INT_2: 2985af69d88dSmrg case TYPE_ENUM_2: 2986af69d88dSmrg params[1] = (GLdouble) v.value_int_4[1]; 2987af69d88dSmrg case TYPE_INT: 2988af69d88dSmrg case TYPE_ENUM: 298901e04c3fSmrg case TYPE_ENUM16: 2990af69d88dSmrg params[0] = (GLdouble) v.value_int_4[0]; 2991af69d88dSmrg break; 2992af69d88dSmrg 2993af69d88dSmrg case TYPE_INT_N: 2994af69d88dSmrg for (i = 0; i < v.value_int_n.n; i++) 299501e04c3fSmrg params[i] = (GLdouble) v.value_int_n.ints[i]; 299601e04c3fSmrg break; 299701e04c3fSmrg 299801e04c3fSmrg case TYPE_UINT_4: 299901e04c3fSmrg params[3] = (GLdouble) ((GLuint) v.value_int_4[3]); 300001e04c3fSmrg case TYPE_UINT_3: 300101e04c3fSmrg params[2] = (GLdouble) ((GLuint) v.value_int_4[2]); 300201e04c3fSmrg case TYPE_UINT_2: 300301e04c3fSmrg params[1] = (GLdouble) ((GLuint) v.value_int_4[1]); 300401e04c3fSmrg case TYPE_UINT: 300501e04c3fSmrg params[0] = (GLdouble) ((GLuint) v.value_int_4[0]); 3006af69d88dSmrg break; 3007af69d88dSmrg 3008af69d88dSmrg case TYPE_INT64: 3009af69d88dSmrg params[0] = (GLdouble) v.value_int64; 3010af69d88dSmrg break; 3011af69d88dSmrg 3012af69d88dSmrg case TYPE_BOOLEAN: 3013af69d88dSmrg params[0] = (GLdouble) BOOLEAN_TO_FLOAT(v.value_bool); 3014af69d88dSmrg break; 3015af69d88dSmrg 301601e04c3fSmrg case TYPE_UBYTE: 301701e04c3fSmrg params[0] = (GLdouble) v.value_ubyte; 301801e04c3fSmrg break; 301901e04c3fSmrg 302001e04c3fSmrg case TYPE_SHORT: 302101e04c3fSmrg params[0] = (GLdouble) v.value_short; 302201e04c3fSmrg break; 302301e04c3fSmrg 3024af69d88dSmrg case TYPE_MATRIX: 3025af69d88dSmrg m = *(GLmatrix **) &v; 3026af69d88dSmrg for (i = 0; i < 16; i++) 302701e04c3fSmrg params[i] = (GLdouble) m->m[i]; 3028af69d88dSmrg break; 3029af69d88dSmrg 3030af69d88dSmrg case TYPE_MATRIX_T: 3031af69d88dSmrg m = *(GLmatrix **) &v; 3032af69d88dSmrg for (i = 0; i < 16; i++) 303301e04c3fSmrg params[i] = (GLdouble) m->m[transpose[i]]; 3034af69d88dSmrg break; 3035af69d88dSmrg 3036af69d88dSmrg default: 3037af69d88dSmrg ; 3038af69d88dSmrg } 3039af69d88dSmrg} 3040af69d88dSmrg 304101e04c3fSmrgvoid GLAPIENTRY 304201e04c3fSmrg_mesa_GetUnsignedBytei_vEXT(GLenum target, GLuint index, GLubyte *data) 304301e04c3fSmrg{ 304401e04c3fSmrg GLsizei size; 304501e04c3fSmrg union value v; 304601e04c3fSmrg enum value_type type; 304701e04c3fSmrg const char *func = "glGetUnsignedBytei_vEXT"; 304801e04c3fSmrg 304901e04c3fSmrg GET_CURRENT_CONTEXT(ctx); 305001e04c3fSmrg 305101e04c3fSmrg if (!ctx->Extensions.EXT_memory_object) { 305201e04c3fSmrg _mesa_error(ctx, GL_INVALID_OPERATION, "%s(unsupported)", func); 305301e04c3fSmrg return; 305401e04c3fSmrg } 305501e04c3fSmrg 305601e04c3fSmrg type = find_value_indexed(func, target, index, &v); 305701e04c3fSmrg size = get_value_size(type, &v); 305801e04c3fSmrg if (size <= 0) { 305901e04c3fSmrg _mesa_problem(ctx, "invalid value type in GetUnsignedBytei_vEXT()"); 306001e04c3fSmrg } 306101e04c3fSmrg 306201e04c3fSmrg switch (type) { 306301e04c3fSmrg case TYPE_UINT: 306401e04c3fSmrg case TYPE_INT: 306501e04c3fSmrg case TYPE_INT_2: 306601e04c3fSmrg case TYPE_UINT_2: 306701e04c3fSmrg case TYPE_INT_3: 306801e04c3fSmrg case TYPE_UINT_3: 306901e04c3fSmrg case TYPE_INT_4: 307001e04c3fSmrg case TYPE_UINT_4: 307101e04c3fSmrg case TYPE_INT64: 307201e04c3fSmrg case TYPE_ENUM16: 307301e04c3fSmrg case TYPE_ENUM: 307401e04c3fSmrg case TYPE_ENUM_2: 307501e04c3fSmrg case TYPE_BOOLEAN: 307601e04c3fSmrg case TYPE_UBYTE: 307701e04c3fSmrg case TYPE_SHORT: 307801e04c3fSmrg case TYPE_FLOAT: 307901e04c3fSmrg case TYPE_FLOATN: 308001e04c3fSmrg case TYPE_FLOAT_2: 308101e04c3fSmrg case TYPE_FLOATN_2: 308201e04c3fSmrg case TYPE_FLOAT_3: 308301e04c3fSmrg case TYPE_FLOATN_3: 308401e04c3fSmrg case TYPE_FLOAT_4: 308501e04c3fSmrg case TYPE_FLOATN_4: 308601e04c3fSmrg case TYPE_FLOAT_8: 308701e04c3fSmrg case TYPE_DOUBLEN: 308801e04c3fSmrg case TYPE_DOUBLEN_2: 308901e04c3fSmrg case TYPE_MATRIX: 309001e04c3fSmrg case TYPE_MATRIX_T: 309101e04c3fSmrg memcpy(data, &v.value_int, size); 309201e04c3fSmrg break; 309301e04c3fSmrg case TYPE_INT_N: 309401e04c3fSmrg memcpy(data, &v.value_int_n.ints, size); 309501e04c3fSmrg break; 309601e04c3fSmrg default: 309701e04c3fSmrg break; /* nothing - GL error was recorded */ 309801e04c3fSmrg } 309901e04c3fSmrg} 310001e04c3fSmrg 31013464ebd5Sriastradhvoid GLAPIENTRY 31023464ebd5Sriastradh_mesa_GetFixedv(GLenum pname, GLfixed *params) 31033464ebd5Sriastradh{ 31043464ebd5Sriastradh const struct value_desc *d; 31053464ebd5Sriastradh union value v; 31063464ebd5Sriastradh GLmatrix *m; 31073464ebd5Sriastradh int shift, i; 31083464ebd5Sriastradh void *p; 31093464ebd5Sriastradh 31103464ebd5Sriastradh d = find_value("glGetDoublev", pname, &p, &v); 31113464ebd5Sriastradh switch (d->type) { 31123464ebd5Sriastradh case TYPE_INVALID: 31133464ebd5Sriastradh break; 31143464ebd5Sriastradh case TYPE_CONST: 31153464ebd5Sriastradh params[0] = INT_TO_FIXED(d->offset); 31163464ebd5Sriastradh break; 31173464ebd5Sriastradh 31183464ebd5Sriastradh case TYPE_FLOAT_4: 31193464ebd5Sriastradh case TYPE_FLOATN_4: 31203464ebd5Sriastradh params[3] = FLOAT_TO_FIXED(((GLfloat *) p)[3]); 31213464ebd5Sriastradh case TYPE_FLOAT_3: 31223464ebd5Sriastradh case TYPE_FLOATN_3: 31233464ebd5Sriastradh params[2] = FLOAT_TO_FIXED(((GLfloat *) p)[2]); 31243464ebd5Sriastradh case TYPE_FLOAT_2: 31253464ebd5Sriastradh case TYPE_FLOATN_2: 31263464ebd5Sriastradh params[1] = FLOAT_TO_FIXED(((GLfloat *) p)[1]); 31273464ebd5Sriastradh case TYPE_FLOAT: 31283464ebd5Sriastradh case TYPE_FLOATN: 31293464ebd5Sriastradh params[0] = FLOAT_TO_FIXED(((GLfloat *) p)[0]); 31303464ebd5Sriastradh break; 31313464ebd5Sriastradh 3132af69d88dSmrg case TYPE_DOUBLEN_2: 3133af69d88dSmrg params[1] = FLOAT_TO_FIXED(((GLdouble *) p)[1]); 31343464ebd5Sriastradh case TYPE_DOUBLEN: 31353464ebd5Sriastradh params[0] = FLOAT_TO_FIXED(((GLdouble *) p)[0]); 31363464ebd5Sriastradh break; 31373464ebd5Sriastradh 31383464ebd5Sriastradh case TYPE_INT_4: 313901e04c3fSmrg case TYPE_UINT_4: 31403464ebd5Sriastradh params[3] = INT_TO_FIXED(((GLint *) p)[3]); 31413464ebd5Sriastradh case TYPE_INT_3: 314201e04c3fSmrg case TYPE_UINT_3: 31433464ebd5Sriastradh params[2] = INT_TO_FIXED(((GLint *) p)[2]); 31443464ebd5Sriastradh case TYPE_INT_2: 314501e04c3fSmrg case TYPE_UINT_2: 31463464ebd5Sriastradh case TYPE_ENUM_2: 31473464ebd5Sriastradh params[1] = INT_TO_FIXED(((GLint *) p)[1]); 31483464ebd5Sriastradh case TYPE_INT: 314901e04c3fSmrg case TYPE_UINT: 31503464ebd5Sriastradh case TYPE_ENUM: 31513464ebd5Sriastradh params[0] = INT_TO_FIXED(((GLint *) p)[0]); 31523464ebd5Sriastradh break; 31533464ebd5Sriastradh 315401e04c3fSmrg case TYPE_ENUM16: 315501e04c3fSmrg params[0] = INT_TO_FIXED((GLint)(((GLenum16 *) p)[0])); 315601e04c3fSmrg break; 315701e04c3fSmrg 31583464ebd5Sriastradh case TYPE_INT_N: 31593464ebd5Sriastradh for (i = 0; i < v.value_int_n.n; i++) 316001e04c3fSmrg params[i] = INT_TO_FIXED(v.value_int_n.ints[i]); 31613464ebd5Sriastradh break; 31623464ebd5Sriastradh 31633464ebd5Sriastradh case TYPE_INT64: 31643464ebd5Sriastradh params[0] = ((GLint64 *) p)[0]; 31653464ebd5Sriastradh break; 31663464ebd5Sriastradh 31673464ebd5Sriastradh case TYPE_BOOLEAN: 31683464ebd5Sriastradh params[0] = BOOLEAN_TO_FIXED(((GLboolean*) p)[0]); 316901e04c3fSmrg break; 317001e04c3fSmrg 317101e04c3fSmrg case TYPE_UBYTE: 317201e04c3fSmrg params[0] = INT_TO_FIXED(((GLubyte *) p)[0]); 317301e04c3fSmrg break; 317401e04c3fSmrg 317501e04c3fSmrg case TYPE_SHORT: 317601e04c3fSmrg params[0] = INT_TO_FIXED(((GLshort *) p)[0]); 317701e04c3fSmrg break; 31783464ebd5Sriastradh 31793464ebd5Sriastradh case TYPE_MATRIX: 31803464ebd5Sriastradh m = *(GLmatrix **) p; 31813464ebd5Sriastradh for (i = 0; i < 16; i++) 318201e04c3fSmrg params[i] = FLOAT_TO_FIXED(m->m[i]); 31833464ebd5Sriastradh break; 31843464ebd5Sriastradh 31853464ebd5Sriastradh case TYPE_MATRIX_T: 31863464ebd5Sriastradh m = *(GLmatrix **) p; 31873464ebd5Sriastradh for (i = 0; i < 16; i++) 318801e04c3fSmrg params[i] = FLOAT_TO_FIXED(m->m[transpose[i]]); 31893464ebd5Sriastradh break; 31903464ebd5Sriastradh 31913464ebd5Sriastradh case TYPE_BIT_0: 31923464ebd5Sriastradh case TYPE_BIT_1: 31933464ebd5Sriastradh case TYPE_BIT_2: 31943464ebd5Sriastradh case TYPE_BIT_3: 31953464ebd5Sriastradh case TYPE_BIT_4: 31963464ebd5Sriastradh case TYPE_BIT_5: 3197af69d88dSmrg case TYPE_BIT_6: 3198af69d88dSmrg case TYPE_BIT_7: 31993464ebd5Sriastradh shift = d->type - TYPE_BIT_0; 32003464ebd5Sriastradh params[0] = BOOLEAN_TO_FIXED((*(GLbitfield *) p >> shift) & 1); 32013464ebd5Sriastradh break; 32023464ebd5Sriastradh } 32033464ebd5Sriastradh} 3204