get.c revision b9abf16e
11.91Schristos/* 21.10Schristos * Copyright (C) 2010 Brian Paul All Rights Reserved. 31.1Scgd * Copyright (C) 2010 Intel Corporation 41.1Scgd * 51.82Sagc * Permission is hereby granted, free of charge, to any person obtaining a 61.82Sagc * copy of this software and associated documentation files (the "Software"), 71.82Sagc * to deal in the Software without restriction, including without limitation 81.82Sagc * the rights to use, copy, modify, merge, publish, distribute, sublicense, 91.82Sagc * and/or sell copies of the Software, and to permit persons to whom the 101.82Sagc * Software is furnished to do so, subject to the following conditions: 111.82Sagc * 121.82Sagc * The above copyright notice and this permission notice shall be included 131.82Sagc * in all copies or substantial portions of the Software. 141.82Sagc * 151.82Sagc * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 161.82Sagc * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 171.82Sagc * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 181.82Sagc * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 191.82Sagc * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 201.82Sagc * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 211.82Sagc * OTHER DEALINGS IN THE SOFTWARE. 221.82Sagc * 231.82Sagc * Author: Kristian Høgsberg <krh@bitplanet.net> 241.82Sagc */ 251.82Sagc 261.82Sagc#include "glheader.h" 271.82Sagc#include "context.h" 281.82Sagc#include "blend.h" 291.82Sagc#include "debug_output.h" 301.82Sagc#include "enable.h" 311.82Sagc#include "enums.h" 321.82Sagc#include "errors.h" 331.82Sagc#include "extensions.h" 341.82Sagc#include "get.h" 351.82Sagc#include "macros.h" 361.1Scgd#include "mtypes.h" 371.1Scgd#include "state.h" 381.1Scgd#include "texcompress.h" 391.1Scgd#include "texstate.h" 401.1Scgd#include "framebuffer.h" 411.1Scgd#include "samplerobj.h" 421.1Scgd#include "stencil.h" 431.1Scgd#include "version.h" 441.1Scgd 451.1Scgd/* This is a table driven implemetation of the glGet*v() functions. 461.1Scgd * The basic idea is that most getters just look up an int somewhere 471.1Scgd * in struct gl_context and then convert it to a bool or float according to 481.1Scgd * which of glGetIntegerv() glGetBooleanv() etc is being called. 491.1Scgd * Instead of generating code to do this, we can just record the enum 501.1Scgd * value and the offset into struct gl_context in an array of structs. Then 511.1Scgd * in glGet*(), we lookup the struct for the enum in question, and use 521.1Scgd * the offset to get the int we need. 531.1Scgd * 541.1Scgd * Sometimes we need to look up a float, a boolean, a bit in a 551.1Scgd * bitfield, a matrix or other types instead, so we need to track the 561.1Scgd * type of the value in struct gl_context. And sometimes the value isn't in 571.1Scgd * struct gl_context but in the drawbuffer, the array object, current texture 581.1Scgd * unit, or maybe it's a computed value. So we need to also track 591.1Scgd * where or how to find the value. Finally, we sometimes need to 601.1Scgd * check that one of a number of extensions are enabled, the GL 611.1Scgd * version or flush or call _mesa_update_state(). This is done by 621.1Scgd * attaching optional extra information to the value description 631.1Scgd * struct, it's sort of like an array of opcodes that describe extra 641.1Scgd * checks or actions. 651.1Scgd * 661.1Scgd * Putting all this together we end up with struct value_desc below, 671.1Scgd * and with a couple of macros to help, the table of struct value_desc 681.1Scgd * is about as concise as the specification in the old python script. 691.1Scgd */ 701.1Scgd 711.1Scgd#define FLOAT_TO_BOOLEAN(X) ( (X) ? GL_TRUE : GL_FALSE ) 721.84Sross#define FLOAT_TO_FIXED(F) ( ((F) * 65536.0f > INT_MAX) ? INT_MAX : \ 731.91Schristos ((F) * 65536.0f < INT_MIN) ? INT_MIN : \ 741.21Slukem (GLint) ((F) * 65536.0f) ) 751.19Schristos 761.1Scgd#define INT_TO_BOOLEAN(I) ( (I) ? GL_TRUE : GL_FALSE ) 771.10Schristos#define INT_TO_FIXED(I) ( ((I) > SHRT_MAX) ? INT_MAX : \ 781.16Schristos ((I) < SHRT_MIN) ? INT_MIN : \ 791.10Schristos (GLint) ((I) * 65536) ) 801.91Schristos 811.10Schristos#define INT64_TO_BOOLEAN(I) ( (I) ? GL_TRUE : GL_FALSE ) 821.1Scgd#define INT64_TO_INT(I) ( (GLint)((I > INT_MAX) ? INT_MAX : ((I < INT_MIN) ? INT_MIN : (I))) ) 831.21Slukem 841.1Scgd#define BOOLEAN_TO_INT(B) ( (GLint) (B) ) 851.1Scgd#define BOOLEAN_TO_INT64(B) ( (GLint64) (B) ) 861.1Scgd#define BOOLEAN_TO_FLOAT(B) ( (B) ? 1.0F : 0.0F ) 871.1Scgd#define BOOLEAN_TO_FIXED(B) ( (GLint) ((B) ? 1 : 0) << 16 ) 881.1Scgd 891.1Scgd#define ENUM_TO_INT64(E) ( (GLint64) (E) ) 901.1Scgd#define ENUM_TO_FIXED(E) (E) 911.1Scgd 921.1Scgdenum value_type { 931.1Scgd TYPE_INVALID, 941.1Scgd TYPE_INT, 951.1Scgd TYPE_INT_2, 961.1Scgd TYPE_INT_3, 971.1Scgd TYPE_INT_4, 981.1Scgd TYPE_INT_N, 991.1Scgd TYPE_UINT, 1001.1Scgd TYPE_UINT_2, 1011.1Scgd TYPE_UINT_3, 1021.1Scgd TYPE_UINT_4, 1031.1Scgd TYPE_INT64, 1041.1Scgd TYPE_ENUM16, 1051.1Scgd TYPE_ENUM, 1061.1Scgd TYPE_ENUM_2, 1071.1Scgd TYPE_BOOLEAN, 1081.1Scgd TYPE_UBYTE, 1091.1Scgd TYPE_SHORT, 1101.1Scgd TYPE_BIT_0, 1111.1Scgd TYPE_BIT_1, 1121.1Scgd TYPE_BIT_2, 1131.22Schristos TYPE_BIT_3, 1141.22Schristos TYPE_BIT_4, 1151.1Scgd TYPE_BIT_5, 1161.1Scgd TYPE_BIT_6, 1171.1Scgd TYPE_BIT_7, 1181.1Scgd TYPE_FLOAT, 1191.1Scgd TYPE_FLOAT_2, 1201.1Scgd TYPE_FLOAT_3, 1211.1Scgd TYPE_FLOAT_4, 1221.22Schristos TYPE_FLOAT_8, 1231.1Scgd TYPE_FLOATN, 1241.1Scgd TYPE_FLOATN_2, 1251.1Scgd TYPE_FLOATN_3, 1261.1Scgd TYPE_FLOATN_4, 1271.1Scgd TYPE_DOUBLEN, 1281.1Scgd TYPE_DOUBLEN_2, 1291.1Scgd TYPE_MATRIX, 1301.1Scgd TYPE_MATRIX_T, 1311.1Scgd TYPE_CONST 1321.1Scgd}; 1331.1Scgd 1341.1Scgdenum value_location { 1351.1Scgd LOC_BUFFER, 1361.1Scgd LOC_CONTEXT, 1371.1Scgd LOC_ARRAY, 1381.1Scgd LOC_TEXUNIT, 1391.1Scgd LOC_CUSTOM 1401.1Scgd}; 1411.5Scgd 1421.1Scgdenum value_extra { 1431.1Scgd EXTRA_END = 0x8000, 1441.1Scgd EXTRA_VERSION_30, 1451.1Scgd EXTRA_VERSION_31, 1461.72Swiz EXTRA_VERSION_32, 1471.72Swiz EXTRA_VERSION_40, 1481.1Scgd EXTRA_VERSION_43, 1491.35Schristos EXTRA_API_GL, 1501.35Schristos EXTRA_API_GL_CORE, 1511.35Schristos EXTRA_API_ES2, 1521.35Schristos EXTRA_API_ES3, 1531.35Schristos EXTRA_API_ES31, 1541.72Swiz EXTRA_API_ES32, 1551.72Swiz EXTRA_NEW_BUFFERS, 1561.72Swiz EXTRA_NEW_FRAG_CLAMP, 1571.72Swiz EXTRA_VALID_DRAW_BUFFER, 1581.72Swiz EXTRA_VALID_TEXTURE_UNIT, 1591.5Scgd EXTRA_VALID_CLIP_DISTANCE, 1601.5Scgd EXTRA_FLUSH_CURRENT, 1611.5Scgd EXTRA_GLSL_130, 1621.1Scgd EXTRA_EXT_UBO_GS, 1631.1Scgd EXTRA_EXT_ATOMICS_GS, 1641.40Ssommerfe EXTRA_EXT_SHADER_IMAGE_GS, 1651.12Schristos EXTRA_EXT_ATOMICS_TESS, 1661.12Schristos EXTRA_EXT_SHADER_IMAGE_TESS, 1671.16Schristos EXTRA_EXT_SSBO_GS, 1681.12Schristos EXTRA_EXT_FB_NO_ATTACH_GS, 1691.12Schristos EXTRA_EXT_ES_GS, 1701.12Schristos EXTRA_EXT_PROVOKING_VERTEX_32, 1711.1Scgd}; 1721.1Scgd 1731.16Schristos#define NO_EXTRA NULL 1741.1Scgd#define NO_OFFSET 0 1751.5Scgd 1761.5Scgdstruct value_desc { 1771.1Scgd GLenum pname; 1781.1Scgd GLubyte location; /**< enum value_location */ 1791.1Scgd GLubyte type; /**< enum value_type */ 1801.1Scgd int offset; 1811.16Schristos const int *extra; 1821.12Schristos}; 1831.12Schristos 1841.12Schristosunion value { 1851.12Schristos GLfloat value_float; 1861.1Scgd GLfloat value_float_4[4]; 1871.1Scgd GLdouble value_double_2[2]; 1881.1Scgd GLmatrix *value_matrix; 1891.1Scgd GLint value_int; 1901.1Scgd GLint value_int_4[4]; 1911.1Scgd GLint64 value_int64; 1921.71Schristos GLenum value_enum; 1931.71Schristos GLubyte value_ubyte; 1941.1Scgd GLshort value_short; 1951.1Scgd GLuint value_uint; 1961.1Scgd 1971.1Scgd /* Sigh, see GL_COMPRESSED_TEXTURE_FORMATS_ARB handling */ 1981.1Scgd struct { 1991.1Scgd GLint n, ints[100]; 2001.1Scgd } value_int_n; 2011.1Scgd GLboolean value_bool; 2021.1Scgd}; 2031.1Scgd 2041.1Scgd#define BUFFER_FIELD(field, type) \ 2051.1Scgd LOC_BUFFER, type, offsetof(struct gl_framebuffer, field) 2061.1Scgd#define CONTEXT_FIELD(field, type) \ 2071.1Scgd LOC_CONTEXT, type, offsetof(struct gl_context, field) 2081.1Scgd#define ARRAY_FIELD(field, type) \ 2091.1Scgd LOC_ARRAY, type, offsetof(struct gl_vertex_array_object, field) 2101.1Scgd#undef CONST /* already defined through windows.h */ 2111.1Scgd#define CONST(value) \ 2121.1Scgd LOC_CONTEXT, TYPE_CONST, value 2131.1Scgd 2141.1Scgd#define BUFFER_INT(field) BUFFER_FIELD(field, TYPE_INT) 2151.1Scgd#define BUFFER_ENUM(field) BUFFER_FIELD(field, TYPE_ENUM) 2161.1Scgd#define BUFFER_ENUM16(field) BUFFER_FIELD(field, TYPE_ENUM16) 2171.1Scgd#define BUFFER_BOOL(field) BUFFER_FIELD(field, TYPE_BOOLEAN) 2181.1Scgd 2191.1Scgd#define CONTEXT_INT(field) CONTEXT_FIELD(field, TYPE_INT) 2201.1Scgd#define CONTEXT_INT2(field) CONTEXT_FIELD(field, TYPE_INT_2) 2211.88Schristos#define CONTEXT_INT64(field) CONTEXT_FIELD(field, TYPE_INT64) 2221.1Scgd#define CONTEXT_UINT(field) CONTEXT_FIELD(field, TYPE_UINT) 2231.1Scgd#define CONTEXT_ENUM16(field) CONTEXT_FIELD(field, TYPE_ENUM16) 2241.1Scgd#define CONTEXT_ENUM(field) CONTEXT_FIELD(field, TYPE_ENUM) 2251.1Scgd#define CONTEXT_ENUM2(field) CONTEXT_FIELD(field, TYPE_ENUM_2) 2261.1Scgd#define CONTEXT_BOOL(field) CONTEXT_FIELD(field, TYPE_BOOLEAN) 2271.1Scgd#define CONTEXT_BIT0(field) CONTEXT_FIELD(field, TYPE_BIT_0) 2281.1Scgd#define CONTEXT_BIT1(field) CONTEXT_FIELD(field, TYPE_BIT_1) 2291.1Scgd#define CONTEXT_BIT2(field) CONTEXT_FIELD(field, TYPE_BIT_2) 2301.83Sjmc#define CONTEXT_BIT3(field) CONTEXT_FIELD(field, TYPE_BIT_3) 2311.83Sjmc#define CONTEXT_BIT4(field) CONTEXT_FIELD(field, TYPE_BIT_4) 2321.27Schristos#define CONTEXT_BIT5(field) CONTEXT_FIELD(field, TYPE_BIT_5) 2331.83Sjmc#define CONTEXT_BIT6(field) CONTEXT_FIELD(field, TYPE_BIT_6) 2341.27Schristos#define CONTEXT_BIT7(field) CONTEXT_FIELD(field, TYPE_BIT_7) 2351.83Sjmc#define CONTEXT_FLOAT(field) CONTEXT_FIELD(field, TYPE_FLOAT) 2361.27Schristos#define CONTEXT_FLOAT2(field) CONTEXT_FIELD(field, TYPE_FLOAT_2) 2371.83Sjmc#define CONTEXT_FLOAT3(field) CONTEXT_FIELD(field, TYPE_FLOAT_3) 2381.1Scgd#define CONTEXT_FLOAT4(field) CONTEXT_FIELD(field, TYPE_FLOAT_4) 2391.1Scgd#define CONTEXT_FLOAT8(field) CONTEXT_FIELD(field, TYPE_FLOAT_8) 2401.81Ssjg#define CONTEXT_MATRIX(field) CONTEXT_FIELD(field, TYPE_MATRIX) 2411.81Ssjg#define CONTEXT_MATRIX_T(field) CONTEXT_FIELD(field, TYPE_MATRIX_T) 2421.81Ssjg 2431.81Ssjg/* Vertex array fields */ 2441.81Ssjg#define ARRAY_INT(field) ARRAY_FIELD(field, TYPE_INT) 2451.83Sjmc#define ARRAY_ENUM(field) ARRAY_FIELD(field, TYPE_ENUM) 2461.81Ssjg#define ARRAY_ENUM16(field) ARRAY_FIELD(field, TYPE_ENUM16) 2471.83Sjmc#define ARRAY_BOOL(field) ARRAY_FIELD(field, TYPE_BOOLEAN) 2481.81Ssjg#define ARRAY_UBYTE(field) ARRAY_FIELD(field, TYPE_UBYTE) 2491.81Ssjg#define ARRAY_SHORT(field) ARRAY_FIELD(field, TYPE_SHORT) 2501.1Scgd 2511.1Scgd#define EXT(f) \ 2521.1Scgd offsetof(struct gl_extensions, f) 2531.12Schristos 2541.12Schristos#define EXTRA_EXT(e) \ 2551.83Sjmc static const int extra_##e[] = { \ 2561.12Schristos EXT(e), EXTRA_END \ 2571.1Scgd } 2581.1Scgd 2591.5Scgd#define EXTRA_EXT2(e1, e2) \ 2601.1Scgd static const int extra_##e1##_##e2[] = { \ 2611.1Scgd EXT(e1), EXT(e2), EXTRA_END \ 2621.1Scgd } 2631.1Scgd 2641.81Ssjg/* The 'extra' mechanism is a way to specify extra checks (such as 2651.1Scgd * extensions or specific gl versions) or actions (flush current, new 2661.81Ssjg * buffers) that we need to do before looking up an enum. We need to 2671.81Ssjg * declare them all up front so we can refer to them in the value_desc 2681.1Scgd * structs below. 2691.1Scgd * 2701.1Scgd * Each EXTRA_ will be executed. For EXTRA_* enums of extensions and API 2711.1Scgd * versions, listing multiple ones in an array means an error will be thrown 2721.12Schristos * only if none of them are available. If you need to check for "AND" 2731.12Schristos * behavior, you would need to make a custom EXTRA_ enum. 2741.12Schristos */ 2751.40Ssommerfe 2761.40Ssommerfestatic const int extra_new_buffers[] = { 2771.35Schristos EXTRA_NEW_BUFFERS, 2781.35Schristos EXTRA_END 2791.35Schristos}; 2801.35Schristos 2811.1Scgdstatic const int extra_new_frag_clamp[] = { 2821.35Schristos EXTRA_NEW_FRAG_CLAMP, 2831.36Schristos EXTRA_END 2841.35Schristos}; 2851.35Schristos 2861.72Swizstatic const int extra_valid_draw_buffer[] = { 2871.72Swiz EXTRA_VALID_DRAW_BUFFER, 2881.72Swiz EXTRA_END 2891.36Schristos}; 2901.39Smycroft 2911.35Schristosstatic const int extra_valid_texture_unit[] = { 2921.1Scgd EXTRA_VALID_TEXTURE_UNIT, 2931.12Schristos EXTRA_END 2941.1Scgd}; 2951.77Schristos 2961.1Scgdstatic const int extra_valid_clip_distance[] = { 2971.1Scgd EXTRA_VALID_CLIP_DISTANCE, 2981.40Ssommerfe EXTRA_END 2991.40Ssommerfe}; 3001.12Schristos 3011.73Sgsonstatic const int extra_flush_current_valid_texture_unit[] = { 3021.73Sgson EXTRA_FLUSH_CURRENT, 3031.73Sgson EXTRA_VALID_TEXTURE_UNIT, 3041.12Schristos EXTRA_END 3051.12Schristos}; 3061.12Schristos 3071.34Schristosstatic const int extra_flush_current[] = { 3081.12Schristos EXTRA_FLUSH_CURRENT, 3091.12Schristos EXTRA_END 3101.12Schristos}; 3111.34Schristos 3121.12Schristosstatic const int extra_EXT_texture_integer_and_new_buffers[] = { 3131.1Scgd EXT(EXT_texture_integer), 3141.1Scgd EXTRA_NEW_BUFFERS, 3151.1Scgd EXTRA_END 3161.1Scgd}; 3171.1Scgd 3181.16Schristosstatic const int extra_GLSL_130_es3_gpushader4[] = { 3191.1Scgd EXTRA_GLSL_130, 3201.12Schristos EXTRA_API_ES3, 3211.1Scgd EXT(EXT_gpu_shader4), 3221.1Scgd EXTRA_END 3231.1Scgd}; 3241.1Scgd 3251.69Spkstatic const int extra_texture_buffer_object[] = { 3261.5Scgd EXT(ARB_texture_buffer_object), 3271.26Schristos EXTRA_END 3281.5Scgd}; 3291.1Scgd 3301.12Schristosstatic const int extra_ARB_transform_feedback2_api_es3[] = { 3311.1Scgd EXT(ARB_transform_feedback2), 3321.12Schristos EXTRA_API_ES3, 3331.1Scgd EXTRA_END 3341.5Scgd}; 3351.1Scgd 3361.16Schristosstatic const int extra_ARB_uniform_buffer_object_and_geometry_shader[] = { 3371.13Schristos EXTRA_EXT_UBO_GS, 3381.13Schristos EXTRA_END 3391.13Schristos}; 3401.13Schristos 3411.13Schristosstatic const int extra_ARB_ES2_compatibility_api_es2[] = { 3421.28Schristos EXT(ARB_ES2_compatibility), 3431.28Schristos EXTRA_API_ES2, 3441.28Schristos EXTRA_END 3451.28Schristos}; 3461.28Schristos 3471.28Schristosstatic const int extra_ARB_ES3_compatibility_api_es3[] = { 3481.13Schristos EXT(ARB_ES3_compatibility), 3491.72Swiz EXTRA_API_ES3, 3501.72Swiz EXTRA_END 3511.73Sgson}; 3521.47Ssommerfe 3531.72Swizstatic const int extra_EXT_framebuffer_sRGB_and_new_buffers[] = { 3541.47Ssommerfe EXT(EXT_framebuffer_sRGB), 3551.72Swiz EXTRA_NEW_BUFFERS, 3561.72Swiz EXTRA_END 3571.72Swiz}; 3581.72Swiz 3591.12Schristosstatic const int extra_EXT_packed_float[] = { 3601.72Swiz EXT(EXT_packed_float), 3611.12Schristos EXTRA_NEW_BUFFERS, 3621.72Swiz EXTRA_END 3631.12Schristos}; 3641.12Schristos 3651.72Swizstatic const int extra_EXT_texture_array_es3[] = { 3661.72Swiz EXT(EXT_texture_array), 3671.12Schristos EXTRA_API_ES3, 3681.72Swiz EXTRA_END 3691.72Swiz}; 3701.72Swiz 3711.72Swizstatic const int extra_ARB_shader_atomic_counters_and_geometry_shader[] = { 3721.72Swiz EXTRA_EXT_ATOMICS_GS, 3731.77Schristos EXTRA_END 3741.72Swiz}; 3751.72Swiz 3761.72Swizstatic const int extra_ARB_shader_image_load_store_and_geometry_shader[] = { 3771.69Spk EXTRA_EXT_SHADER_IMAGE_GS, 3781.69Spk EXTRA_END 3791.69Spk}; 3801.69Spk 3811.69Spkstatic const int extra_ARB_shader_atomic_counters_and_tessellation[] = { 3821.69Spk EXTRA_EXT_ATOMICS_TESS, 3831.69Spk EXTRA_END 3841.69Spk}; 3851.69Spk 3861.69Spkstatic const int extra_ARB_shader_image_load_store_and_tessellation[] = { 3871.69Spk EXTRA_EXT_SHADER_IMAGE_TESS, 3881.69Spk EXTRA_END 3891.72Swiz}; 3901.69Spk 3911.69Spk/* HACK: remove when ARB_compute_shader is actually supported */ 3921.69Spkstatic const int extra_ARB_compute_shader_es31[] = { 3931.69Spk EXT(ARB_compute_shader), 3941.69Spk EXTRA_API_ES31, 3951.69Spk EXTRA_END 3961.69Spk}; 3971.72Swiz 3981.69Spkstatic const int extra_ARB_shader_storage_buffer_object_es31[] = { 3991.69Spk EXT(ARB_shader_storage_buffer_object), 4001.69Spk EXTRA_API_ES31, 4011.1Scgd EXTRA_END 4021.1Scgd}; 4031.1Scgd 4041.1Scgdstatic const int extra_ARB_shader_storage_buffer_object_and_geometry_shader[] = { 4051.1Scgd EXTRA_EXT_SSBO_GS, 4061.1Scgd EXTRA_END 4071.1Scgd}; 4081.72Swiz 4091.72Swizstatic const int extra_ARB_shader_image_load_store_shader_storage_buffer_object_es31[] = { 4101.72Swiz EXT(ARB_shader_image_load_store), 4111.72Swiz EXT(ARB_shader_storage_buffer_object), 4121.1Scgd EXTRA_API_ES31, 4131.1Scgd EXTRA_END 4141.1Scgd}; 4151.1Scgd 4161.1Scgdstatic const int extra_ARB_framebuffer_no_attachments_and_geometry_shader[] = { 4171.1Scgd EXTRA_EXT_FB_NO_ATTACH_GS, 4181.1Scgd EXTRA_END 4191.1Scgd}; 4201.1Scgd 4211.72Swizstatic const int extra_ARB_viewport_array_or_oes_geometry_shader[] = { 4221.1Scgd EXT(ARB_viewport_array), 4231.6Sjtc EXTRA_EXT_ES_GS, 4241.6Sjtc EXTRA_END 4251.1Scgd}; 4261.1Scgd 4271.12Schristosstatic const int extra_ARB_viewport_array_or_oes_viewport_array[] = { 4281.1Scgd EXT(ARB_viewport_array), 4291.1Scgd EXT(OES_viewport_array), 4301.1Scgd EXTRA_END 4311.1Scgd}; 4321.1Scgd 4331.1Scgdstatic const int extra_ARB_gpu_shader5_or_oes_geometry_shader[] = { 4341.1Scgd EXT(ARB_gpu_shader5), 4351.1Scgd EXTRA_EXT_ES_GS, 4361.12Schristos EXTRA_END 4371.16Schristos}; 4381.12Schristos 4391.12Schristosstatic const int extra_ARB_gpu_shader5_or_OES_sample_variables[] = { 4401.12Schristos EXT(ARB_gpu_shader5), 4411.12Schristos EXT(OES_sample_variables), 4421.1Scgd EXTRA_END 4431.1Scgd}; 4441.12Schristos 4451.1Scgdstatic const int extra_ES32[] = { 4461.1Scgd EXT(ARB_ES3_2_compatibility), 4471.1Scgd EXTRA_API_ES32, 4481.1Scgd EXTRA_END 4491.73Sgson}; 4501.73Sgson 4511.37Ssommerfestatic const int extra_KHR_robustness_or_GL[] = { 4521.72Swiz EXT(KHR_robustness), 4531.72Swiz EXTRA_API_GL, 4541.72Swiz EXTRA_API_GL_CORE, 4551.37Ssommerfe EXTRA_END 4561.37Ssommerfe}; 4571.37Ssommerfe 4581.37Ssommerfestatic const int extra_INTEL_conservative_rasterization[] = { 4591.73Sgson EXT(INTEL_conservative_rasterization), 4601.73Sgson EXTRA_END 4611.37Ssommerfe}; 4621.37Ssommerfe 4631.37SsommerfeEXTRA_EXT(ARB_texture_cube_map); 4641.37SsommerfeEXTRA_EXT(EXT_texture_array); 4651.87SjmcEXTRA_EXT(NV_fog_distance); 4661.37SsommerfeEXTRA_EXT(EXT_texture_filter_anisotropic); 4671.73SgsonEXTRA_EXT(NV_point_sprite); 4681.37SsommerfeEXTRA_EXT(NV_texture_rectangle); 4691.37SsommerfeEXTRA_EXT(EXT_stencil_two_side); 4701.37SsommerfeEXTRA_EXT(EXT_depth_bounds_test); 4711.47SsommerfeEXTRA_EXT(ARB_depth_clamp); 4721.47SsommerfeEXTRA_EXT(AMD_depth_clamp_separate); 4731.47SsommerfeEXTRA_EXT(ATI_fragment_shader); 4741.47SsommerfeEXTRA_EXT(EXT_provoking_vertex); 4751.47SsommerfeEXTRA_EXT(ARB_fragment_shader); 4761.47SsommerfeEXTRA_EXT(ARB_fragment_program); 4771.72SwizEXTRA_EXT2(ARB_framebuffer_object, EXT_framebuffer_multisample); 4781.72SwizEXTRA_EXT(ARB_seamless_cube_map); 4791.72SwizEXTRA_EXT(ARB_sync); 4801.47SsommerfeEXTRA_EXT(ARB_vertex_shader); 4811.47SsommerfeEXTRA_EXT(EXT_transform_feedback); 4821.47SsommerfeEXTRA_EXT(ARB_transform_feedback3); 4831.47SsommerfeEXTRA_EXT(EXT_pixel_buffer_object); 4841.47SsommerfeEXTRA_EXT(ARB_vertex_program); 4851.47SsommerfeEXTRA_EXT2(NV_point_sprite, ARB_point_sprite); 4861.47SsommerfeEXTRA_EXT2(ARB_vertex_program, ARB_fragment_program); 4871.47SsommerfeEXTRA_EXT(ARB_color_buffer_float); 4881.47SsommerfeEXTRA_EXT(EXT_framebuffer_sRGB); 4891.87SjmcEXTRA_EXT(OES_EGL_image_external); 4901.47SsommerfeEXTRA_EXT(ARB_blend_func_extended); 4911.47SsommerfeEXTRA_EXT(ARB_uniform_buffer_object); 4921.47SsommerfeEXTRA_EXT(ARB_timer_query); 4931.47SsommerfeEXTRA_EXT2(ARB_texture_cube_map_array, OES_texture_cube_map_array); 4941.37SsommerfeEXTRA_EXT(ARB_texture_buffer_range); 4951.37SsommerfeEXTRA_EXT(ARB_texture_multisample); 4961.37SsommerfeEXTRA_EXT(ARB_texture_gather); 4971.1ScgdEXTRA_EXT(ARB_shader_atomic_counters); 4981.1ScgdEXTRA_EXT(ARB_draw_indirect); 4991.1ScgdEXTRA_EXT(ARB_shader_image_load_store); 5001.1ScgdEXTRA_EXT(ARB_query_buffer_object); 5011.72SwizEXTRA_EXT2(ARB_transform_feedback3, ARB_gpu_shader5); 5021.72SwizEXTRA_EXT(INTEL_performance_query); 5031.72SwizEXTRA_EXT(ARB_explicit_uniform_location); 5041.1ScgdEXTRA_EXT(ARB_clip_control); 5051.1ScgdEXTRA_EXT(ARB_polygon_offset_clamp); 5061.1ScgdEXTRA_EXT(ARB_framebuffer_no_attachments); 5071.1ScgdEXTRA_EXT(ARB_tessellation_shader); 5081.1ScgdEXTRA_EXT(ARB_shader_storage_buffer_object); 5091.16SchristosEXTRA_EXT(ARB_indirect_parameters); 5101.1ScgdEXTRA_EXT(ATI_meminfo); 5111.1ScgdEXTRA_EXT(NVX_gpu_memory_info); 5121.1ScgdEXTRA_EXT(ARB_cull_distance); 5131.72SwizEXTRA_EXT(EXT_window_rectangles); 5141.1ScgdEXTRA_EXT(KHR_blend_equation_advanced_coherent); 5151.13SchristosEXTRA_EXT(OES_primitive_bounding_box); 5161.14SchristosEXTRA_EXT(ARB_compute_variable_group_size); 5171.28SchristosEXTRA_EXT(KHR_robustness); 5181.16SchristosEXTRA_EXT(ARB_sparse_buffer); 5191.12SchristosEXTRA_EXT(NV_conservative_raster); 5201.12SchristosEXTRA_EXT(NV_conservative_raster_dilate); 5211.12SchristosEXTRA_EXT(NV_conservative_raster_pre_snap_triangles); 5221.12SchristosEXTRA_EXT(ARB_sample_locations); 5231.12SchristosEXTRA_EXT(AMD_framebuffer_multisample_advanced); 5241.1Scgd 5251.1Scgdstatic const int 5261.1Scgdextra_ARB_color_buffer_float_or_glcore[] = { 5271.1Scgd EXT(ARB_color_buffer_float), 5281.1Scgd EXTRA_API_GL_CORE, 5291.1Scgd EXTRA_END 5301.1Scgd}; 5311.12Schristos 5321.1Scgdstatic const int 5331.12Schristosextra_NV_primitive_restart[] = { 5341.1Scgd EXT(NV_primitive_restart), 5351.16Schristos EXTRA_END 5361.1Scgd}; 5371.1Scgd 5381.1Scgdstatic const int extra_version_30[] = { EXTRA_VERSION_30, EXTRA_END }; 5391.1Scgdstatic const int extra_version_31[] = { EXTRA_VERSION_31, EXTRA_END }; 5401.5Scgdstatic const int extra_version_32[] = { EXTRA_VERSION_32, EXTRA_END }; 5411.1Scgdstatic const int extra_version_43[] = { EXTRA_VERSION_43, EXTRA_END }; 5421.16Schristos 5431.47Ssommerfestatic const int extra_gl30_es3[] = { 5441.47Ssommerfe EXTRA_VERSION_30, 5451.47Ssommerfe EXTRA_API_ES3, 5461.1Scgd EXTRA_END, 5471.1Scgd}; 5481.1Scgd 5491.1Scgdstatic const int extra_gl32_es3[] = { 5501.1Scgd EXTRA_VERSION_32, 5511.1Scgd EXTRA_API_ES3, 5521.28Schristos EXTRA_END, 5531.68Spk}; 5541.68Spk 5551.68Spkstatic const int extra_version_32_OES_geometry_shader[] = { 5561.14Schristos EXTRA_VERSION_32, 5571.14Schristos EXTRA_EXT_ES_GS, 5581.14Schristos EXTRA_END 5591.68Spk}; 5601.13Schristos 5611.12Schristosstatic const int extra_gl40_ARB_sample_shading[] = { 5621.12Schristos EXTRA_VERSION_40, 5631.47Ssommerfe EXT(ARB_sample_shading), 5641.12Schristos EXTRA_END 5651.12Schristos}; 5661.1Scgd 5671.28Schristosstatic const int 5681.28Schristosextra_ARB_vertex_program_api_es2[] = { 5691.28Schristos EXT(ARB_vertex_program), 5701.28Schristos EXTRA_API_ES2, 5711.28Schristos EXTRA_END 5721.1Scgd}; 5731.68Spk 5741.68Spk/* The ReadBuffer get token is valid under either full GL or under 5751.68Spk * GLES2 if the NV_read_buffer extension is available. */ 5761.13Schristosstatic const int 5771.1Scgdextra_NV_read_buffer_api_gl[] = { 5781.1Scgd EXTRA_API_ES2, 5791.1Scgd EXTRA_API_GL, 5801.1Scgd EXTRA_END 5811.1Scgd}; 5821.1Scgd 5831.1Scgdstatic const int extra_core_ARB_color_buffer_float_and_new_buffers[] = { 5841.1Scgd EXTRA_API_GL_CORE, 5851.1Scgd EXT(ARB_color_buffer_float), 5861.72Swiz EXTRA_NEW_BUFFERS, 5871.72Swiz EXTRA_END 5881.72Swiz}; 5891.72Swiz 5901.1Scgdstatic const int extra_EXT_shader_framebuffer_fetch[] = { 5911.1Scgd EXTRA_API_ES2, 5921.1Scgd EXTRA_API_ES3, 5931.1Scgd EXT(EXT_shader_framebuffer_fetch), 5941.1Scgd EXTRA_END 5951.1Scgd}; 5961.1Scgd 5971.1Scgdstatic const int extra_EXT_provoking_vertex_32[] = { 5981.72Swiz EXTRA_EXT_PROVOKING_VERTEX_32, 5991.1Scgd EXTRA_END 6001.16Schristos}; 6011.12Schristos 6021.12Schristosstatic const int extra_EXT_disjoint_timer_query[] = { 6031.12Schristos EXTRA_API_ES2, 6041.12Schristos EXTRA_API_ES3, 6051.12Schristos EXT(EXT_disjoint_timer_query), 6061.12Schristos EXTRA_END 6071.12Schristos}; 6081.16Schristos 6091.12Schristos 6101.72Swiz/* This is the big table describing all the enums we accept in 6111.72Swiz * glGet*v(). The table is partitioned into six parts: enums 6121.72Swiz * understood by all GL APIs (OpenGL, GLES and GLES2), enums shared 6131.72Swiz * between OpenGL and GLES, enums exclusive to GLES, etc for the 6141.12Schristos * remaining combinations. To look up the enums valid in a given API 6151.12Schristos * we will use a hash table specific to that API. These tables are in 6161.12Schristos * turn generated at build time and included through get_hash.h. 6171.12Schristos */ 6181.12Schristos 6191.12Schristos#include "get_hash.h" 6201.12Schristos 6211.12Schristos/* All we need now is a way to look up the value struct from the enum. 6221.72Swiz * The code generated by gcc for the old generated big switch 6231.12Schristos * statement is a big, balanced, open coded if/else tree, essentially 6241.70Spk * an unrolled binary search. It would be natural to sort the new 6251.1Scgd * enum table and use bsearch(), but we will use a read-only hash 6261.12Schristos * table instead. bsearch() has a nice guaranteed worst case 6271.1Scgd * performance, but we're also guaranteed to hit that worst case 6281.1Scgd * (log2(n) iterations) for about half the enums. Instead, using an 6291.1Scgd * open addressing hash table, we can find the enum on the first try 6301.1Scgd * for 80% of the enums, 1 collision for 10% and never more than 5 6311.1Scgd * collisions for any enum (typical numbers). And the code is very 6321.1Scgd * simple, even though it feels a little magic. */ 6331.1Scgd 6341.1Scgd/** 6351.1Scgd * Handle irregular enums 6361.1Scgd * 6371.1Scgd * Some values don't conform to the "well-known type at context 6381.1Scgd * pointer + offset" pattern, so we have this function to catch all 6391.1Scgd * the corner cases. Typically, it's a computed value or a one-off 6401.1Scgd * pointer to a custom struct or something. 6411.1Scgd * 6421.1Scgd * In this case we can't return a pointer to the value, so we'll have 6431.1Scgd * to use the temporary variable 'v' declared back in the calling 6441.72Swiz * glGet*v() function to store the result. 6451.72Swiz * 6461.72Swiz * \param ctx the current context 6471.72Swiz * \param d the struct value_desc that describes the enum 6481.1Scgd * \param v pointer to the tmp declared in the calling glGet*v() function 6491.1Scgd */ 6501.1Scgdstatic void 6511.1Scgdfind_custom_value(struct gl_context *ctx, const struct value_desc *d, union value *v) 6521.1Scgd{ 6531.1Scgd struct gl_buffer_object **buffer_obj; 6541.1Scgd struct gl_array_attributes *array; 6551.1Scgd GLuint unit, *p; 6561.1Scgd 6571.1Scgd switch (d->pname) { 6581.1Scgd case GL_MAJOR_VERSION: 6591.1Scgd v->value_int = ctx->Version / 10; 6601.72Swiz break; 6611.1Scgd case GL_MINOR_VERSION: 6621.1Scgd v->value_int = ctx->Version % 10; 6631.1Scgd break; 6641.1Scgd 6651.1Scgd case GL_TEXTURE_1D: 6661.1Scgd case GL_TEXTURE_2D: 6671.1Scgd case GL_TEXTURE_3D: 6681.1Scgd case GL_TEXTURE_CUBE_MAP: 6691.1Scgd case GL_TEXTURE_RECTANGLE_NV: 6701.77Schristos case GL_TEXTURE_EXTERNAL_OES: 6711.1Scgd v->value_bool = _mesa_IsEnabled(d->pname); 6721.1Scgd break; 6731.83Sjmc 6741.6Sjtc case GL_LINE_STIPPLE_PATTERN: 6751.16Schristos /* This is the only GLushort, special case it here by promoting 6761.88Schristos * to an int rather than introducing a new type. */ 6771.83Sjmc v->value_int = ctx->Line.StipplePattern; 6781.83Sjmc break; 6791.45Ssommerfe 6801.1Scgd case GL_CURRENT_RASTER_TEXTURE_COORDS: 6811.12Schristos unit = ctx->Texture.CurrentUnit; 6821.16Schristos v->value_float_4[0] = ctx->Current.RasterTexCoords[unit][0]; 6831.1Scgd v->value_float_4[1] = ctx->Current.RasterTexCoords[unit][1]; 6841.12Schristos v->value_float_4[2] = ctx->Current.RasterTexCoords[unit][2]; 6851.12Schristos v->value_float_4[3] = ctx->Current.RasterTexCoords[unit][3]; 6861.16Schristos break; 6871.12Schristos 6881.16Schristos case GL_CURRENT_TEXTURE_COORDS: 6891.1Scgd unit = ctx->Texture.CurrentUnit; 6901.1Scgd v->value_float_4[0] = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][0]; 6911.12Schristos v->value_float_4[1] = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][1]; 6921.12Schristos v->value_float_4[2] = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][2]; 6931.12Schristos v->value_float_4[3] = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][3]; 6941.12Schristos break; 6951.12Schristos 6961.12Schristos case GL_COLOR_WRITEMASK: 6971.1Scgd v->value_int_4[0] = GET_COLORMASK_BIT(ctx->Color.ColorMask, 0, 0); 6981.1Scgd v->value_int_4[1] = GET_COLORMASK_BIT(ctx->Color.ColorMask, 0, 1); 6991.1Scgd v->value_int_4[2] = GET_COLORMASK_BIT(ctx->Color.ColorMask, 0, 2); 7001.12Schristos v->value_int_4[3] = GET_COLORMASK_BIT(ctx->Color.ColorMask, 0, 3); 7011.1Scgd break; 7021.1Scgd 7031.1Scgd case GL_DEPTH_CLAMP: 7041.1Scgd v->value_bool = ctx->Transform.DepthClampNear || ctx->Transform.DepthClampFar; 7051.1Scgd break; 7061.1Scgd 7071.85Ssjg case GL_EDGE_FLAG: 7081.85Ssjg v->value_bool = ctx->Current.Attrib[VERT_ATTRIB_EDGEFLAG][0] == 1.0F; 7091.85Ssjg break; 7101.1Scgd 7111.85Ssjg case GL_READ_BUFFER: 7121.85Ssjg v->value_enum = ctx->ReadBuffer->ColorReadBuffer; 7131.1Scgd break; 7141.85Ssjg 7151.85Ssjg case GL_MAP2_GRID_DOMAIN: 7161.85Ssjg v->value_float_4[0] = ctx->Eval.MapGrid2u1; 7171.85Ssjg v->value_float_4[1] = ctx->Eval.MapGrid2u2; 7181.85Ssjg v->value_float_4[2] = ctx->Eval.MapGrid2v1; 7191.85Ssjg v->value_float_4[3] = ctx->Eval.MapGrid2v2; 7201.85Ssjg break; 7211.85Ssjg 7221.85Ssjg case GL_TEXTURE_STACK_DEPTH: 7231.85Ssjg unit = ctx->Texture.CurrentUnit; 7241.85Ssjg v->value_int = ctx->TextureMatrixStack[unit].Depth + 1; 7251.1Scgd break; 7261.1Scgd case GL_TEXTURE_MATRIX: 7271.1Scgd unit = ctx->Texture.CurrentUnit; 7281.1Scgd v->value_matrix = ctx->TextureMatrixStack[unit].Top; 7291.5Scgd break; 7301.5Scgd 7311.1Scgd case GL_VERTEX_ARRAY: 7321.83Sjmc v->value_bool = !!(ctx->Array.VAO->Enabled & VERT_BIT_POS); 7331.83Sjmc break; 7341.83Sjmc case GL_NORMAL_ARRAY: 7351.83Sjmc v->value_bool = !!(ctx->Array.VAO->Enabled & VERT_BIT_NORMAL); 7361.83Sjmc break; 7371.83Sjmc case GL_COLOR_ARRAY: 7381.83Sjmc v->value_bool = !!(ctx->Array.VAO->Enabled & VERT_BIT_COLOR0); 7391.83Sjmc break; 7401.89Schristos case GL_TEXTURE_COORD_ARRAY: 7411.83Sjmc v->value_bool = !!(ctx->Array.VAO->Enabled & VERT_BIT_TEX(ctx->Array.ActiveTexture)); 7421.83Sjmc break; 7431.83Sjmc case GL_INDEX_ARRAY: 7441.83Sjmc v->value_bool = !!(ctx->Array.VAO->Enabled & VERT_BIT_COLOR_INDEX); 7451.83Sjmc break; 7461.83Sjmc case GL_EDGE_FLAG_ARRAY: 7471.83Sjmc v->value_bool = !!(ctx->Array.VAO->Enabled & VERT_BIT_EDGEFLAG); 7481.83Sjmc break; 7491.83Sjmc case GL_SECONDARY_COLOR_ARRAY: 7501.1Scgd v->value_bool = !!(ctx->Array.VAO->Enabled & VERT_BIT_COLOR1); 7511.12Schristos break; 7521.1Scgd case GL_FOG_COORDINATE_ARRAY: 7531.12Schristos v->value_bool = !!(ctx->Array.VAO->Enabled & VERT_BIT_FOG); 7541.1Scgd break; 7551.83Sjmc case GL_POINT_SIZE_ARRAY_OES: 7561.83Sjmc v->value_bool = !!(ctx->Array.VAO->Enabled & VERT_BIT_POINT_SIZE); 7571.1Scgd break; 7581.1Scgd 7591.1Scgd case GL_TEXTURE_COORD_ARRAY_TYPE: 7601.1Scgd case GL_TEXTURE_COORD_ARRAY_STRIDE: 7611.12Schristos array = &ctx->Array.VAO->VertexAttrib[VERT_ATTRIB_TEX(ctx->Array.ActiveTexture)]; 7621.1Scgd v->value_int = *(GLuint *) ((char *) array + d->offset); 7631.1Scgd break; 7641.1Scgd 7651.1Scgd case GL_TEXTURE_COORD_ARRAY_SIZE: 7661.1Scgd array = &ctx->Array.VAO->VertexAttrib[VERT_ATTRIB_TEX(ctx->Array.ActiveTexture)]; 7671.1Scgd v->value_int = array->Format.Size; 7681.1Scgd break; 7691.1Scgd 7701.1Scgd case GL_VERTEX_ARRAY_SIZE: 7711.12Schristos array = &ctx->Array.VAO->VertexAttrib[VERT_ATTRIB_POS]; 7721.1Scgd v->value_int = array->Format.Size; 7731.12Schristos break; 7741.12Schristos 7751.12Schristos case GL_ACTIVE_TEXTURE_ARB: 7761.1Scgd v->value_int = GL_TEXTURE0_ARB + ctx->Texture.CurrentUnit; 7771.83Sjmc break; 7781.1Scgd case GL_CLIENT_ACTIVE_TEXTURE_ARB: 7791.1Scgd v->value_int = GL_TEXTURE0_ARB + ctx->Array.ActiveTexture; 7801.12Schristos break; 7811.1Scgd 7821.1Scgd case GL_MODELVIEW_STACK_DEPTH: 7831.1Scgd case GL_PROJECTION_STACK_DEPTH: 7841.1Scgd v->value_int = *(GLint *) ((char *) ctx + d->offset) + 1; 7851.1Scgd break; 7861.1Scgd 7871.1Scgd case GL_MAX_TEXTURE_SIZE: 7881.1Scgd case GL_MAX_3D_TEXTURE_SIZE: 7891.1Scgd case GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB: 7901.1Scgd p = (GLuint *) ((char *) ctx + d->offset); 7911.83Sjmc v->value_int = 1 << (*p - 1); 7921.83Sjmc break; 7931.83Sjmc 7941.83Sjmc case GL_SCISSOR_BOX: 7951.83Sjmc v->value_int_4[0] = ctx->Scissor.ScissorArray[0].X; 7961.1Scgd v->value_int_4[1] = ctx->Scissor.ScissorArray[0].Y; 7971.83Sjmc v->value_int_4[2] = ctx->Scissor.ScissorArray[0].Width; 7981.83Sjmc v->value_int_4[3] = ctx->Scissor.ScissorArray[0].Height; 7991.83Sjmc break; 8001.83Sjmc 8011.1Scgd case GL_SCISSOR_TEST: 8021.1Scgd v->value_bool = ctx->Scissor.EnableFlags & 1; 8031.1Scgd break; 8041.16Schristos 8051.1Scgd case GL_LIST_INDEX: 8061.1Scgd v->value_int = 8071.1Scgd ctx->ListState.CurrentList ? ctx->ListState.CurrentList->Name : 0; 8081.1Scgd break; 8091.1Scgd case GL_LIST_MODE: 8101.1Scgd if (!ctx->CompileFlag) 8111.1Scgd v->value_enum = 0; 8121.1Scgd else if (ctx->ExecuteFlag) 8131.1Scgd v->value_enum = GL_COMPILE_AND_EXECUTE; 8141.1Scgd else 8151.83Sjmc v->value_enum = GL_COMPILE; 8161.83Sjmc break; 8171.83Sjmc 8181.83Sjmc case GL_VIEWPORT: 8191.83Sjmc v->value_float_4[0] = ctx->ViewportArray[0].X; 8201.83Sjmc v->value_float_4[1] = ctx->ViewportArray[0].Y; 8211.83Sjmc v->value_float_4[2] = ctx->ViewportArray[0].Width; 8221.83Sjmc v->value_float_4[3] = ctx->ViewportArray[0].Height; 8231.83Sjmc break; 8241.83Sjmc 8251.83Sjmc case GL_DEPTH_RANGE: 8261.83Sjmc v->value_double_2[0] = ctx->ViewportArray[0].Near; 8271.83Sjmc v->value_double_2[1] = ctx->ViewportArray[0].Far; 8281.83Sjmc break; 8291.83Sjmc 8301.83Sjmc case GL_ACTIVE_STENCIL_FACE_EXT: 8311.83Sjmc v->value_enum = ctx->Stencil.ActiveFace ? GL_BACK : GL_FRONT; 8321.83Sjmc break; 8331.83Sjmc 8341.83Sjmc case GL_STENCIL_FAIL: 8351.83Sjmc v->value_enum = ctx->Stencil.FailFunc[ctx->Stencil.ActiveFace]; 8361.83Sjmc break; 8371.83Sjmc case GL_STENCIL_FUNC: 8381.83Sjmc v->value_enum = ctx->Stencil.Function[ctx->Stencil.ActiveFace]; 8391.1Scgd break; 8401.16Schristos case GL_STENCIL_PASS_DEPTH_FAIL: 8411.49Ssjg v->value_enum = ctx->Stencil.ZFailFunc[ctx->Stencil.ActiveFace]; 8421.49Ssjg break; 8431.49Ssjg case GL_STENCIL_PASS_DEPTH_PASS: 8441.49Ssjg v->value_enum = ctx->Stencil.ZPassFunc[ctx->Stencil.ActiveFace]; 8451.49Ssjg break; 8461.49Ssjg case GL_STENCIL_REF: 8471.33Ssjg v->value_int = _mesa_get_stencil_ref(ctx, ctx->Stencil.ActiveFace); 8481.55Ssjg break; 8491.88Schristos case GL_STENCIL_BACK_REF: 8501.88Schristos v->value_int = _mesa_get_stencil_ref(ctx, 1); 8511.88Schristos break; 8521.12Schristos case GL_STENCIL_VALUE_MASK: 8531.23Sitohy v->value_int = ctx->Stencil.ValueMask[ctx->Stencil.ActiveFace]; 8541.83Sjmc break; 8551.83Sjmc case GL_STENCIL_WRITEMASK: 8561.1Scgd v->value_int = ctx->Stencil.WriteMask[ctx->Stencil.ActiveFace]; 8571.1Scgd break; 8581.1Scgd 8591.1Scgd case GL_NUM_EXTENSIONS: 8601.1Scgd v->value_int = _mesa_get_extension_count(ctx); 8611.1Scgd break; 8621.1Scgd 8631.12Schristos case GL_IMPLEMENTATION_COLOR_READ_TYPE_OES: 8641.1Scgd v->value_int = _mesa_get_color_read_type(ctx, NULL, "glGetIntegerv"); 8651.1Scgd break; 8661.12Schristos case GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES: 8671.1Scgd v->value_int = _mesa_get_color_read_format(ctx, NULL, "glGetIntegerv"); 8681.83Sjmc break; 8691.12Schristos 8701.1Scgd case GL_CURRENT_MATRIX_STACK_DEPTH_ARB: 8711.88Schristos v->value_int = ctx->CurrentStack->Depth + 1; 8721.88Schristos break; 8731.88Schristos case GL_CURRENT_MATRIX_ARB: 8741.88Schristos case GL_TRANSPOSE_CURRENT_MATRIX_ARB: 8751.12Schristos v->value_matrix = ctx->CurrentStack->Top; 8761.1Scgd break; 8771.1Scgd 8781.1Scgd case GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB: 8791.1Scgd v->value_int = _mesa_get_compressed_formats(ctx, NULL); 8801.1Scgd break; 8811.1Scgd case GL_COMPRESSED_TEXTURE_FORMATS_ARB: 8821.1Scgd v->value_int_n.n = 8831.1Scgd _mesa_get_compressed_formats(ctx, v->value_int_n.ints); 8841.1Scgd assert(v->value_int_n.n <= (int) ARRAY_SIZE(v->value_int_n.ints)); 8851.1Scgd break; 8861.1Scgd 8871.1Scgd case GL_MAX_VARYING_FLOATS_ARB: 8881.1Scgd v->value_int = ctx->Const.MaxVarying * 4; 8891.1Scgd break; 8901.1Scgd 8911.1Scgd /* Various object names */ 8921.1Scgd 8931.72Swiz case GL_TEXTURE_BINDING_1D: 8941.1Scgd case GL_TEXTURE_BINDING_2D: 8951.12Schristos case GL_TEXTURE_BINDING_3D: 8961.12Schristos case GL_TEXTURE_BINDING_1D_ARRAY_EXT: 8971.12Schristos case GL_TEXTURE_BINDING_2D_ARRAY_EXT: 8981.12Schristos case GL_TEXTURE_BINDING_CUBE_MAP_ARB: 8991.12Schristos case GL_TEXTURE_BINDING_RECTANGLE_NV: 9001.12Schristos case GL_TEXTURE_BINDING_EXTERNAL_OES: 9011.12Schristos case GL_TEXTURE_BINDING_CUBE_MAP_ARRAY: 9021.12Schristos case GL_TEXTURE_BINDING_2D_MULTISAMPLE: 9031.12Schristos case GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY: 9041.12Schristos unit = ctx->Texture.CurrentUnit; 9051.12Schristos v->value_int = 9061.12Schristos ctx->Texture.Unit[unit].CurrentTex[d->offset]->Name; 9071.12Schristos break; 9081.12Schristos 9091.12Schristos /* GL_EXT_external_objects */ 9101.12Schristos case GL_NUM_DEVICE_UUIDS_EXT: 9111.12Schristos v->value_int = 1; 9121.12Schristos break; 9131.12Schristos case GL_DRIVER_UUID_EXT: 9141.12Schristos _mesa_get_driver_uuid(ctx, v->value_int_4); 9151.72Swiz break; 9161.12Schristos case GL_DEVICE_UUID_EXT: 9171.36Schristos _mesa_get_device_uuid(ctx, v->value_int_4); 9181.12Schristos break; 9191.12Schristos 9201.12Schristos /* GL_EXT_packed_float */ 9211.36Schristos case GL_RGBA_SIGNED_COMPONENTS_EXT: 9221.35Schristos { 9231.12Schristos /* Note: we only check the 0th color attachment. */ 9241.12Schristos const struct gl_renderbuffer *rb = 9251.12Schristos ctx->DrawBuffer->_ColorDrawBuffers[0]; 9261.12Schristos if (rb && _mesa_is_format_signed(rb->Format)) { 9271.12Schristos /* Issue 17 of GL_EXT_packed_float: If a component (such as 9281.12Schristos * alpha) has zero bits, the component should not be considered 9291.12Schristos * signed and so the bit for the respective component should be 9301.12Schristos * zeroed. 9311.12Schristos */ 9321.1Scgd GLint r_bits = 9331.1Scgd _mesa_get_format_bits(rb->Format, GL_RED_BITS); 9341.1Scgd GLint g_bits = 9351.1Scgd _mesa_get_format_bits(rb->Format, GL_GREEN_BITS); 9361.1Scgd GLint b_bits = 9371.1Scgd _mesa_get_format_bits(rb->Format, GL_BLUE_BITS); 9381.1Scgd GLint a_bits = 9391.1Scgd _mesa_get_format_bits(rb->Format, GL_ALPHA_BITS); 9401.1Scgd GLint l_bits = 9411.1Scgd _mesa_get_format_bits(rb->Format, GL_TEXTURE_LUMINANCE_SIZE); 9421.1Scgd GLint i_bits = 9431.1Scgd _mesa_get_format_bits(rb->Format, GL_TEXTURE_INTENSITY_SIZE); 9441.72Swiz 9451.72Swiz v->value_int_4[0] = r_bits + l_bits + i_bits > 0; 9461.72Swiz v->value_int_4[1] = g_bits + l_bits + i_bits > 0; 9471.72Swiz v->value_int_4[2] = b_bits + l_bits + i_bits > 0; 9481.1Scgd v->value_int_4[3] = a_bits + i_bits > 0; 9491.1Scgd } 9501.1Scgd else { 9511.1Scgd v->value_int_4[0] = 9521.1Scgd v->value_int_4[1] = 9531.1Scgd v->value_int_4[2] = 9541.16Schristos v->value_int_4[3] = 0; 9551.1Scgd } 9561.16Schristos } 9571.1Scgd break; 9581.1Scgd 9591.1Scgd /* GL_ARB_vertex_buffer_object */ 9601.1Scgd case GL_VERTEX_ARRAY_BUFFER_BINDING_ARB: 9611.5Scgd case GL_NORMAL_ARRAY_BUFFER_BINDING_ARB: 9621.72Swiz case GL_COLOR_ARRAY_BUFFER_BINDING_ARB: 9631.1Scgd case GL_INDEX_ARRAY_BUFFER_BINDING_ARB: 9641.13Schristos case GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB: 9651.1Scgd case GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB: 9661.12Schristos case GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB: 9671.12Schristos buffer_obj = (struct gl_buffer_object **) 9681.28Schristos ((char *) ctx->Array.VAO + d->offset); 9691.1Scgd v->value_int = (*buffer_obj)->Name; 9701.1Scgd break; 9711.1Scgd case GL_ARRAY_BUFFER_BINDING_ARB: 9721.1Scgd v->value_int = ctx->Array.ArrayBufferObj->Name; 9731.1Scgd break; 9741.1Scgd case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB: 9751.1Scgd v->value_int = 9761.1Scgd ctx->Array.VAO->BufferBinding[VERT_ATTRIB_TEX(ctx->Array.ActiveTexture)].BufferObj->Name; 9771.1Scgd break; 9781.12Schristos case GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB: 9791.12Schristos v->value_int = ctx->Array.VAO->IndexBufferObj->Name; 9801.12Schristos break; 9811.12Schristos 9821.1Scgd /* ARB_vertex_array_bgra */ 9831.12Schristos case GL_COLOR_ARRAY_SIZE: 9841.34Schristos array = &ctx->Array.VAO->VertexAttrib[VERT_ATTRIB_COLOR0]; 9851.1Scgd v->value_int = array->Format.Format == GL_BGRA ? GL_BGRA : array->Format.Size; 9861.1Scgd break; 9871.12Schristos case GL_SECONDARY_COLOR_ARRAY_SIZE: 9881.12Schristos array = &ctx->Array.VAO->VertexAttrib[VERT_ATTRIB_COLOR1]; 9891.12Schristos v->value_int = array->Format.Format == GL_BGRA ? GL_BGRA : array->Format.Size; 9901.12Schristos break; 9911.12Schristos 9921.1Scgd /* ARB_copy_buffer */ 9931.1Scgd case GL_COPY_READ_BUFFER: 9941.1Scgd v->value_int = ctx->CopyReadBuffer->Name; 9951.1Scgd break; 9961.12Schristos case GL_COPY_WRITE_BUFFER: 9971.12Schristos v->value_int = ctx->CopyWriteBuffer->Name; 9981.12Schristos break; 9991.16Schristos 10001.12Schristos case GL_PIXEL_PACK_BUFFER_BINDING_EXT: 10011.1Scgd v->value_int = ctx->Pack.BufferObj->Name; 10021.12Schristos break; 10031.12Schristos case GL_PIXEL_UNPACK_BUFFER_BINDING_EXT: 10041.12Schristos v->value_int = ctx->Unpack.BufferObj->Name; 10051.12Schristos break; 10061.12Schristos case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING: 10071.12Schristos v->value_int = ctx->TransformFeedback.CurrentBuffer->Name; 10081.12Schristos break; 10091.12Schristos case GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED: 10101.12Schristos v->value_int = ctx->TransformFeedback.CurrentObject->Paused; 10111.1Scgd break; 10121.1Scgd case GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE: 10131.1Scgd v->value_int = ctx->TransformFeedback.CurrentObject->Active; 10141.1Scgd break; 10151.1Scgd case GL_TRANSFORM_FEEDBACK_BINDING: 10161.1Scgd v->value_int = ctx->TransformFeedback.CurrentObject->Name; 10171.16Schristos break; 10181.1Scgd case GL_CURRENT_PROGRAM: 10191.12Schristos /* The Changelog of the ARB_separate_shader_objects spec says: 10201.28Schristos * 10211.1Scgd * 24 25 Jul 2011 pbrown Remove the language erroneously deleting 10221.1Scgd * CURRENT_PROGRAM. In the EXT extension, this 10231.16Schristos * token was aliased to ACTIVE_PROGRAM_EXT, and 10241.12Schristos * was used to indicate the last program set by 10251.1Scgd * either ActiveProgramEXT or UseProgram. In 10261.1Scgd * the ARB extension, the SSO active programs 10271.1Scgd * are now program pipeline object state and 10281.1Scgd * CURRENT_PROGRAM should still be used to query 10291.1Scgd * the last program set by UseProgram (bug 7822). 10301.12Schristos */ 10311.34Schristos v->value_int = 10321.34Schristos ctx->Shader.ActiveProgram ? ctx->Shader.ActiveProgram->Name : 0; 10331.1Scgd break; 10341.1Scgd case GL_READ_FRAMEBUFFER_BINDING_EXT: 10351.1Scgd v->value_int = ctx->ReadBuffer->Name; 10361.1Scgd break; 10371.12Schristos case GL_RENDERBUFFER_BINDING_EXT: 10381.12Schristos v->value_int = 10391.61Spk ctx->CurrentRenderbuffer ? ctx->CurrentRenderbuffer->Name : 0; 10401.61Spk break; 10411.12Schristos case GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES: 10421.12Schristos v->value_int = ctx->Array.VAO->BufferBinding[VERT_ATTRIB_POINT_SIZE].BufferObj->Name; 10431.12Schristos break; 10441.1Scgd 10451.12Schristos case GL_FOG_COLOR: 10461.1Scgd if (_mesa_get_clamp_fragment_color(ctx, ctx->DrawBuffer)) 10471.1Scgd COPY_4FV(v->value_float_4, ctx->Fog.Color); 10481.61Spk else 10491.61Spk COPY_4FV(v->value_float_4, ctx->Fog.ColorUnclamped); 10501.12Schristos break; 10511.12Schristos case GL_COLOR_CLEAR_VALUE: 10521.1Scgd if (_mesa_get_clamp_fragment_color(ctx, ctx->DrawBuffer)) { 10531.1Scgd v->value_float_4[0] = CLAMP(ctx->Color.ClearColor.f[0], 0.0F, 1.0F); 10541.13Schristos v->value_float_4[1] = CLAMP(ctx->Color.ClearColor.f[1], 0.0F, 1.0F); 10551.1Scgd v->value_float_4[2] = CLAMP(ctx->Color.ClearColor.f[2], 0.0F, 1.0F); 10561.1Scgd v->value_float_4[3] = CLAMP(ctx->Color.ClearColor.f[3], 0.0F, 1.0F); 10571.1Scgd } else 10581.12Schristos COPY_4FV(v->value_float_4, ctx->Color.ClearColor.f); 10591.1Scgd break; 10601.1Scgd case GL_BLEND_COLOR_EXT: 10611.61Spk if (_mesa_get_clamp_fragment_color(ctx, ctx->DrawBuffer)) 10621.61Spk COPY_4FV(v->value_float_4, ctx->Color.BlendColor); 10631.12Schristos else 10641.28Schristos COPY_4FV(v->value_float_4, ctx->Color.BlendColorUnclamped); 10651.12Schristos break; 10661.61Spk case GL_ALPHA_TEST_REF: 10671.61Spk if (_mesa_get_clamp_fragment_color(ctx, ctx->DrawBuffer)) 10681.12Schristos v->value_float = ctx->Color.AlphaRef; 10691.1Scgd else 10701.1Scgd v->value_float = ctx->Color.AlphaRefUnclamped; 10711.12Schristos break; 10721.1Scgd case GL_MAX_VERTEX_UNIFORM_VECTORS: 10731.1Scgd v->value_int = ctx->Const.Program[MESA_SHADER_VERTEX].MaxUniformComponents / 4; 10741.12Schristos break; 10751.28Schristos 10761.28Schristos case GL_MAX_FRAGMENT_UNIFORM_VECTORS: 10771.61Spk v->value_int = ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxUniformComponents / 4; 10781.61Spk break; 10791.28Schristos 10801.28Schristos /* GL_ARB_texture_buffer_object */ 10811.61Spk case GL_TEXTURE_BUFFER_ARB: 10821.61Spk v->value_int = ctx->Texture.BufferObject->Name; 10831.28Schristos break; 10841.28Schristos case GL_TEXTURE_BINDING_BUFFER_ARB: 10851.61Spk unit = ctx->Texture.CurrentUnit; 10861.61Spk v->value_int = 10871.28Schristos ctx->Texture.Unit[unit].CurrentTex[TEXTURE_BUFFER_INDEX]->Name; 10881.1Scgd break; 10891.1Scgd case GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB: 10901.1Scgd { 10911.12Schristos struct gl_buffer_object *buf = 10921.12Schristos ctx->Texture.Unit[ctx->Texture.CurrentUnit] 10931.12Schristos .CurrentTex[TEXTURE_BUFFER_INDEX]->BufferObject; 10941.12Schristos v->value_int = buf ? buf->Name : 0; 10951.12Schristos } 10961.1Scgd break; 10971.28Schristos case GL_TEXTURE_BUFFER_FORMAT_ARB: 10981.1Scgd v->value_int = ctx->Texture.Unit[ctx->Texture.CurrentUnit] 10991.1Scgd .CurrentTex[TEXTURE_BUFFER_INDEX]->BufferObjectFormat; 11001.16Schristos break; 11011.1Scgd 11021.1Scgd /* GL_ARB_sampler_objects */ 11031.1Scgd case GL_SAMPLER_BINDING: 11041.1Scgd { 11051.12Schristos struct gl_sampler_object *samp = 11061.1Scgd ctx->Texture.Unit[ctx->Texture.CurrentUnit].Sampler; 11071.1Scgd v->value_int = samp ? samp->Name : 0; 11081.61Spk } 11091.1Scgd break; 11101.12Schristos /* GL_ARB_uniform_buffer_object */ 11111.12Schristos case GL_UNIFORM_BUFFER_BINDING: 11121.12Schristos v->value_int = ctx->UniformBuffer->Name; 11131.61Spk break; 11141.61Spk /* GL_ARB_shader_storage_buffer_object */ 11151.12Schristos case GL_SHADER_STORAGE_BUFFER_BINDING: 11161.12Schristos v->value_int = ctx->ShaderStorageBuffer->Name; 11171.12Schristos break; 11181.12Schristos /* GL_ARB_query_buffer_object */ 11191.12Schristos case GL_QUERY_BUFFER_BINDING: 11201.12Schristos v->value_int = ctx->QueryBuffer->Name; 11211.12Schristos break; 11221.12Schristos /* GL_ARB_timer_query */ 11231.12Schristos case GL_TIMESTAMP: 11241.1Scgd if (ctx->Driver.GetTimestamp) { 11251.12Schristos v->value_int64 = ctx->Driver.GetTimestamp(ctx); 11261.12Schristos } 11271.12Schristos else { 11281.12Schristos _mesa_problem(ctx, "driver doesn't implement GetTimestamp"); 11291.12Schristos } 11301.12Schristos break; 11311.12Schristos /* GL_KHR_DEBUG */ 11321.12Schristos case GL_DEBUG_OUTPUT: 11331.12Schristos case GL_DEBUG_OUTPUT_SYNCHRONOUS: 11341.12Schristos case GL_DEBUG_LOGGED_MESSAGES: 11351.12Schristos case GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH: 11361.12Schristos case GL_DEBUG_GROUP_STACK_DEPTH: 11371.12Schristos v->value_int = _mesa_get_debug_state_int(ctx, d->pname); 11381.1Scgd break; 11391.12Schristos /* GL_ARB_shader_atomic_counters */ 11401.12Schristos case GL_ATOMIC_COUNTER_BUFFER_BINDING: 11411.1Scgd if (ctx->AtomicBuffer) { 11421.1Scgd v->value_int = ctx->AtomicBuffer->Name; 11431.12Schristos } else { 11441.1Scgd v->value_int = 0; 11451.1Scgd } 11461.61Spk break; 11471.61Spk /* GL 4.3 */ 11481.1Scgd case GL_NUM_SHADING_LANGUAGE_VERSIONS: 11491.1Scgd v->value_int = _mesa_get_shading_language_version(ctx, -1, NULL); 11501.12Schristos break; 11511.1Scgd /* GL_ARB_draw_indirect */ 11521.1Scgd case GL_DRAW_INDIRECT_BUFFER_BINDING: 11531.1Scgd v->value_int = ctx->DrawIndirectBuffer->Name; 11541.1Scgd break; 11551.1Scgd /* GL_ARB_indirect_parameters */ 11561.1Scgd case GL_PARAMETER_BUFFER_BINDING_ARB: 11571.1Scgd v->value_int = ctx->ParameterBuffer->Name; 11581.12Schristos break; 11591.12Schristos /* GL_ARB_separate_shader_objects */ 11601.12Schristos case GL_PROGRAM_PIPELINE_BINDING: 11611.12Schristos if (ctx->Pipeline.Current) { 11621.12Schristos v->value_int = ctx->Pipeline.Current->Name; 11631.12Schristos } else { 11641.12Schristos v->value_int = 0; 11651.12Schristos } 11661.28Schristos break; 11671.12Schristos /* GL_ARB_compute_shader */ 11681.12Schristos case GL_DISPATCH_INDIRECT_BUFFER_BINDING: 11691.12Schristos v->value_int = ctx->DispatchIndirectBuffer->Name; 11701.12Schristos break; 11711.12Schristos /* GL_ARB_multisample */ 11721.12Schristos case GL_SAMPLES: 11731.12Schristos v->value_int = _mesa_geometric_samples(ctx->DrawBuffer); 11741.12Schristos break; 11751.12Schristos case GL_SAMPLE_BUFFERS: 11761.12Schristos v->value_int = _mesa_geometric_samples(ctx->DrawBuffer) > 0; 11771.12Schristos break; 11781.1Scgd /* GL_EXT_textrue_integer */ 11791.1Scgd case GL_RGBA_INTEGER_MODE_EXT: 11801.1Scgd v->value_int = (ctx->DrawBuffer->_IntegerBuffers != 0); 11811.1Scgd break; 11821.16Schristos /* GL_ATI_meminfo & GL_NVX_gpu_memory_info */ 11831.42Ssommerfe case GL_VBO_FREE_MEMORY_ATI: 11841.42Ssommerfe case GL_TEXTURE_FREE_MEMORY_ATI: 11851.43Ssommerfe case GL_RENDERBUFFER_FREE_MEMORY_ATI: 11861.42Ssommerfe case GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX: 11871.42Ssommerfe case GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX: 11881.42Ssommerfe case GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX: 11891.42Ssommerfe case GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX: 11901.42Ssommerfe case GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX: 11911.42Ssommerfe { 11921.42Ssommerfe struct gl_memory_info info; 11931.1Scgd 11941.1Scgd ctx->Driver.QueryMemoryInfo(ctx, &info); 11951.1Scgd 11961.1Scgd if (d->pname == GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX) 11971.13Schristos v->value_int = info.total_device_memory; 11981.1Scgd else if (d->pname == GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX) 11991.1Scgd v->value_int = info.total_device_memory + 12001.1Scgd info.total_staging_memory; 12011.1Scgd else if (d->pname == GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX) 12021.1Scgd v->value_int = info.avail_device_memory; 12031.1Scgd else if (d->pname == GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX) 12041.1Scgd v->value_int = info.nr_device_memory_evictions; 12051.1Scgd else if (d->pname == GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX) 12061.12Schristos v->value_int = info.device_memory_evicted; 12071.1Scgd else { 12081.12Schristos /* ATI free memory enums. 12091.1Scgd * 12101.1Scgd * Since the GPU memory is (usually) page-table based, every two 12111.43Ssommerfe * consecutive elements are equal. From the GL_ATI_meminfo 12121.43Ssommerfe * specification: 12131.12Schristos * 12141.1Scgd * "param[0] - total memory free in the pool 12151.15Schristos * param[1] - largest available free block in the pool 12161.1Scgd * param[2] - total auxiliary memory free 12171.1Scgd * param[3] - largest auxiliary free block" 12181.1Scgd * 12191.12Schristos * All three (VBO, TEXTURE, RENDERBUFFER) queries return 12201.1Scgd * the same numbers here. 12211.1Scgd */ 12221.1Scgd v->value_int_4[0] = info.avail_device_memory; 12231.1Scgd v->value_int_4[1] = info.avail_device_memory; 12241.1Scgd v->value_int_4[2] = info.avail_staging_memory; 12251.1Scgd v->value_int_4[3] = info.avail_staging_memory; 12261.1Scgd } 12271.1Scgd } 12281.1Scgd break; 12291.1Scgd 12301.1Scgd /* GL_ARB_get_program_binary */ 12311.1Scgd case GL_PROGRAM_BINARY_FORMATS: 12321.16Schristos assert(ctx->Const.NumProgramBinaryFormats <= 1); 12331.1Scgd v->value_int_n.n = MIN2(ctx->Const.NumProgramBinaryFormats, 1); 12341.1Scgd if (ctx->Const.NumProgramBinaryFormats > 0) { 12351.1Scgd v->value_int_n.ints[0] = GL_PROGRAM_BINARY_FORMAT_MESA; 12361.1Scgd } 12371.12Schristos break; 12381.1Scgd /* GL_EXT_disjoint_timer_query */ 12391.1Scgd case GL_GPU_DISJOINT_EXT: 12401.1Scgd { 12411.1Scgd simple_mtx_lock(&ctx->Shared->Mutex); 12421.1Scgd v->value_int = ctx->Shared->DisjointOperation; 12431.1Scgd /* Reset state as expected by the spec. */ 12441.1Scgd ctx->Shared->DisjointOperation = false; 12451.1Scgd simple_mtx_unlock(&ctx->Shared->Mutex); 12461.1Scgd } 12471.72Swiz break; 12481.72Swiz /* GL_ARB_sample_locations */ 12491.72Swiz case GL_SAMPLE_LOCATION_SUBPIXEL_BITS_ARB: 12501.72Swiz case GL_SAMPLE_LOCATION_PIXEL_GRID_WIDTH_ARB: 12511.1Scgd case GL_SAMPLE_LOCATION_PIXEL_GRID_HEIGHT_ARB: 12521.1Scgd { 12531.1Scgd GLuint bits, width, height; 12541.1Scgd 12551.1Scgd if (ctx->NewState & _NEW_BUFFERS) 12561.1Scgd _mesa_update_state(ctx); 12571.1Scgd 12581.1Scgd if (ctx->DrawBuffer->_Status != GL_FRAMEBUFFER_COMPLETE) { 12591.1Scgd v->value_uint = 0; 12601.72Swiz break; 12611.1Scgd } 12621.1Scgd 12631.14Schristos ctx->Driver.GetProgrammableSampleCaps(ctx, ctx->DrawBuffer, 12641.1Scgd &bits, &width, &height); 12651.52Schristos 12661.1Scgd if (d->pname == GL_SAMPLE_LOCATION_PIXEL_GRID_WIDTH_ARB) 12671.1Scgd v->value_uint = width; 12681.1Scgd else if (d->pname == GL_SAMPLE_LOCATION_PIXEL_GRID_HEIGHT_ARB) 12691.1Scgd v->value_uint = height; 12701.1Scgd else 12711.1Scgd v->value_uint = bits; 12721.16Schristos } 12731.45Ssommerfe break; 12741.12Schristos case GL_PROGRAMMABLE_SAMPLE_LOCATION_TABLE_SIZE_ARB: 12751.12Schristos v->value_uint = MAX_SAMPLE_LOCATION_TABLE_SIZE; 12761.1Scgd break; 12771.1Scgd 12781.45Ssommerfe /* GL_AMD_framebuffer_multisample_advanced */ 12791.1Scgd case GL_SUPPORTED_MULTISAMPLE_MODES_AMD: 12801.1Scgd v->value_int_n.n = ctx->Const.NumSupportedMultisampleModes * 3; 12811.1Scgd memcpy(v->value_int_n.ints, ctx->Const.SupportedMultisampleModes, 12821.1Scgd v->value_int_n.n * sizeof(GLint)); 12831.12Schristos break; 12841.1Scgd } 12851.12Schristos} 12861.1Scgd 12871.1Scgd/** 12881.1Scgd * Check extra constraints on a struct value_desc descriptor 12891.14Schristos * 12901.14Schristos * If a struct value_desc has a non-NULL extra pointer, it means that 12911.12Schristos * there are a number of extra constraints to check or actions to 12921.1Scgd * perform. The extras is just an integer array where each integer 12931.1Scgd * encode different constraints or actions. 12941.1Scgd * 12951.1Scgd * \param ctx current context 12961.1Scgd * \param func name of calling glGet*v() function for error reporting 12971.1Scgd * \param d the struct value_desc that has the extra constraints 12981.1Scgd * 12991.1Scgd * \return GL_FALSE if all of the constraints were not satisfied, 13001.1Scgd * otherwise GL_TRUE. 13011.20Skleink */ 13021.12Schristosstatic GLboolean 13031.1Scgdcheck_extra(struct gl_context *ctx, const char *func, const struct value_desc *d) 13041.16Schristos{ 13051.12Schristos const GLuint version = ctx->Version; 13061.12Schristos GLboolean api_check = GL_FALSE; 13071.12Schristos GLboolean api_found = GL_FALSE; 13081.12Schristos const int *e; 13091.12Schristos 13101.12Schristos for (e = d->extra; *e != EXTRA_END; e++) { 13111.1Scgd switch (*e) { 13121.1Scgd case EXTRA_VERSION_30: 13131.1Scgd api_check = GL_TRUE; 13141.1Scgd if (version >= 30) 13151.1Scgd api_found = GL_TRUE; 13161.1Scgd break; 13171.1Scgd case EXTRA_VERSION_31: 13181.16Schristos api_check = GL_TRUE; 13191.1Scgd if (version >= 31) 13201.72Swiz api_found = GL_TRUE; 13211.72Swiz break; 13221.72Swiz case EXTRA_VERSION_32: 13231.72Swiz api_check = GL_TRUE; 13241.1Scgd if (version >= 32) 13251.1Scgd api_found = GL_TRUE; 13261.1Scgd break; 13271.1Scgd case EXTRA_VERSION_40: 13281.1Scgd api_check = GL_TRUE; 13291.1Scgd if (version >= 40) 13301.1Scgd api_found = GL_TRUE; 13311.1Scgd break; 13321.1Scgd case EXTRA_VERSION_43: 13331.77Schristos api_check = TRUE; 13341.1Scgd if (_mesa_is_desktop_gl(ctx) && version >= 43) 13351.12Schristos api_found = GL_TRUE; 13361.76Schristos break; 13371.1Scgd case EXTRA_NEW_FRAG_CLAMP: 13381.1Scgd if (ctx->NewState & (_NEW_BUFFERS | _NEW_FRAG_CLAMP)) 13391.16Schristos _mesa_update_state(ctx); 13401.1Scgd break; 13411.1Scgd case EXTRA_API_ES2: 13421.6Sjtc api_check = GL_TRUE; 13431.1Scgd if (ctx->API == API_OPENGLES2) 13441.1Scgd api_found = GL_TRUE; 13451.1Scgd break; 13461.1Scgd case EXTRA_API_ES3: 13471.1Scgd api_check = GL_TRUE; 13481.1Scgd if (_mesa_is_gles3(ctx)) 13491.1Scgd api_found = GL_TRUE; 13501.1Scgd break; 13511.1Scgd case EXTRA_API_ES31: 13521.1Scgd api_check = GL_TRUE; 13531.51Ssjg if (_mesa_is_gles31(ctx)) 13541.6Sjtc api_found = GL_TRUE; 13551.6Sjtc break; 13561.12Schristos case EXTRA_API_ES32: 13571.1Scgd api_check = GL_TRUE; 13581.1Scgd if (_mesa_is_gles32(ctx)) 13591.1Scgd api_found = GL_TRUE; 13601.1Scgd break; 13611.1Scgd case EXTRA_API_GL: 13621.16Schristos api_check = GL_TRUE; 13631.1Scgd if (_mesa_is_desktop_gl(ctx)) 13641.46Schristos api_found = GL_TRUE; 13651.12Schristos break; 13661.1Scgd case EXTRA_API_GL_CORE: 13671.46Schristos api_check = GL_TRUE; 13681.46Schristos if (ctx->API == API_OPENGL_CORE) 13691.12Schristos api_found = GL_TRUE; 13701.1Scgd break; 13711.46Schristos case EXTRA_NEW_BUFFERS: 13721.46Schristos if (ctx->NewState & _NEW_BUFFERS) 13731.12Schristos _mesa_update_state(ctx); 13741.12Schristos break; 13751.1Scgd case EXTRA_FLUSH_CURRENT: 13761.46Schristos FLUSH_CURRENT(ctx, 0); 13771.12Schristos break; 13781.1Scgd case EXTRA_VALID_DRAW_BUFFER: 13791.1Scgd if (d->pname - GL_DRAW_BUFFER0_ARB >= ctx->Const.MaxDrawBuffers) { 13801.1Scgd _mesa_error(ctx, GL_INVALID_OPERATION, "%s(draw buffer %u)", 13811.12Schristos func, d->pname - GL_DRAW_BUFFER0_ARB); 13821.1Scgd return GL_FALSE; 13831.1Scgd } 13841.1Scgd break; 13851.1Scgd case EXTRA_VALID_TEXTURE_UNIT: 13861.1Scgd if (ctx->Texture.CurrentUnit >= ctx->Const.MaxTextureCoordUnits) { 13871.1Scgd _mesa_error(ctx, GL_INVALID_OPERATION, "%s(texture %u)", 13881.1Scgd func, ctx->Texture.CurrentUnit); 13891.72Swiz return GL_FALSE; 13901.72Swiz } 13911.72Swiz break; 13921.72Swiz case EXTRA_VALID_CLIP_DISTANCE: 13931.1Scgd if (d->pname - GL_CLIP_DISTANCE0 >= ctx->Const.MaxClipPlanes) { 13941.1Scgd _mesa_error(ctx, GL_INVALID_ENUM, "%s(clip distance %u)", 13951.1Scgd func, d->pname - GL_CLIP_DISTANCE0); 13961.1Scgd return GL_FALSE; 13971.1Scgd } 13981.16Schristos break; 13991.1Scgd case EXTRA_GLSL_130: 14001.1Scgd api_check = GL_TRUE; 14011.1Scgd if (ctx->Const.GLSLVersion >= 130) 14021.1Scgd api_found = GL_TRUE; 14031.72Swiz break; 14041.1Scgd case EXTRA_EXT_UBO_GS: 14051.1Scgd api_check = GL_TRUE; 14061.1Scgd if (ctx->Extensions.ARB_uniform_buffer_object && 14071.1Scgd _mesa_has_geometry_shaders(ctx)) 14081.1Scgd api_found = GL_TRUE; 14091.1Scgd break; 14101.1Scgd case EXTRA_EXT_ATOMICS_GS: 14111.1Scgd api_check = GL_TRUE; 14121.1Scgd if (ctx->Extensions.ARB_shader_atomic_counters && 14131.1Scgd _mesa_has_geometry_shaders(ctx)) 14141.1Scgd api_found = GL_TRUE; 14151.72Swiz break; 14161.72Swiz case EXTRA_EXT_SHADER_IMAGE_GS: 14171.72Swiz api_check = GL_TRUE; 14181.1Scgd if (ctx->Extensions.ARB_shader_image_load_store && 14191.1Scgd _mesa_has_geometry_shaders(ctx)) 14201.1Scgd api_found = GL_TRUE; 14211.1Scgd break; 14221.1Scgd case EXTRA_EXT_ATOMICS_TESS: 14231.1Scgd api_check = GL_TRUE; 14241.1Scgd api_found = ctx->Extensions.ARB_shader_atomic_counters && 14251.1Scgd _mesa_has_tessellation(ctx); 14261.1Scgd break; 14271.1Scgd case EXTRA_EXT_SHADER_IMAGE_TESS: 14281.72Swiz api_check = GL_TRUE; 14291.1Scgd api_found = ctx->Extensions.ARB_shader_image_load_store && 14301.1Scgd _mesa_has_tessellation(ctx); 14311.69Spk break; 14321.16Schristos case EXTRA_EXT_SSBO_GS: 14331.49Ssjg api_check = GL_TRUE; 14341.49Ssjg if (ctx->Extensions.ARB_shader_storage_buffer_object && 14351.1Scgd _mesa_has_geometry_shaders(ctx)) 14361.1Scgd api_found = GL_TRUE; 14371.16Schristos break; 14381.12Schristos case EXTRA_EXT_FB_NO_ATTACH_GS: 14391.12Schristos api_check = GL_TRUE; 14401.12Schristos if (ctx->Extensions.ARB_framebuffer_no_attachments && 14411.12Schristos (_mesa_is_desktop_gl(ctx) || 14421.12Schristos _mesa_has_OES_geometry_shader(ctx))) 14431.1Scgd api_found = GL_TRUE; 14441.12Schristos break; 14451.12Schristos case EXTRA_EXT_ES_GS: 14461.1Scgd api_check = GL_TRUE; 14471.16Schristos if (_mesa_has_OES_geometry_shader(ctx)) 14481.1Scgd api_found = GL_TRUE; 14491.1Scgd break; 14501.16Schristos case EXTRA_EXT_PROVOKING_VERTEX_32: 14511.1Scgd api_check = TRUE; 14521.1Scgd if (ctx->API == API_OPENGL_COMPAT || version == 32) 14531.1Scgd api_found = ctx->Extensions.EXT_provoking_vertex; 14541.1Scgd break; 14551.12Schristos case EXTRA_END: 14561.12Schristos break; 14571.1Scgd default: /* *e is a offset into the extension struct */ 14581.1Scgd api_check = GL_TRUE; 14591.16Schristos if (*(GLboolean *) ((char *) &ctx->Extensions + *e)) 14601.1Scgd api_found = GL_TRUE; 14611.1Scgd break; 14621.1Scgd } 14631.1Scgd } 14641.1Scgd 14651.1Scgd if (api_check && !api_found) { 14661.69Spk _mesa_error(ctx, GL_INVALID_ENUM, "%s(pname=%s)", func, 14671.69Spk _mesa_enum_to_string(d->pname)); 14681.69Spk return GL_FALSE; 14691.12Schristos } 14701.53Smatt 14711.1Scgd return GL_TRUE; 14721.1Scgd} 14731.1Scgd 14741.69Spkstatic const struct value_desc error_value = 14751.69Spk { 0, 0, TYPE_INVALID, NO_OFFSET, NO_EXTRA }; 14761.69Spk 14771.69Spk/** 14781.69Spk * Find the struct value_desc corresponding to the enum 'pname'. 14791.69Spk * 14801.75Sgson * We hash the enum value to get an index into the 'table' array, 14811.69Spk * which holds the index in the 'values' array of struct value_desc. 14821.69Spk * Once we've found the entry, we do the extra checks, if any, then 14831.69Spk * look up the value and return a pointer to it. 14841.1Scgd * 14851.16Schristos * If the value has to be computed (for example, it's the result of a 14861.1Scgd * function call or we need to add 1 to it), we use the tmp 'v' to 14871.1Scgd * store the result. 14881.64Spk * 14891.64Spk * \param func name of glGet*v() func for error reporting 14901.64Spk * \param pname the enum value we're looking up 14911.64Spk * \param p is were we return the pointer to the value 14921.12Schristos * \param v a tmp union value variable in the calling glGet*v() function 14931.20Skleink * 14941.16Schristos * \return the struct value_desc corresponding to the enum or a struct 14951.40Ssommerfe * value_desc of TYPE_INVALID if not found. This lets the calling 14961.40Ssommerfe * glGet*v() function jump right into a switch statement and 14971.40Ssommerfe * handle errors there instead of having to check for NULL. 14981.40Ssommerfe */ 14991.40Ssommerfestatic const struct value_desc * 15001.40Ssommerfefind_value(const char *func, GLenum pname, void **p, union value *v) 15011.40Ssommerfe{ 15021.40Ssommerfe GET_CURRENT_CONTEXT(ctx); 15031.1Scgd int mask, hash; 15041.1Scgd const struct value_desc *d; 15051.1Scgd int api; 15061.1Scgd 15071.1Scgd api = ctx->API; 15081.64Spk /* We index into the table_set[] list of per-API hash tables using the API's 15091.64Spk * value in the gl_api enum. Since GLES 3 doesn't have an API_OPENGL* enum 15101.64Spk * value since it's compatible with GLES2 its entry in table_set[] is at the 15111.64Spk * end. 15121.1Scgd */ 15131.1Scgd STATIC_ASSERT(ARRAY_SIZE(table_set) == API_OPENGL_LAST + 4); 15141.1Scgd if (ctx->API == API_OPENGLES2) { 15151.1Scgd if (ctx->Version >= 32) 15161.1Scgd api = API_OPENGL_LAST + 3; 15171.1Scgd else if (ctx->Version >= 31) 15181.64Spk api = API_OPENGL_LAST + 2; 15191.64Spk else if (ctx->Version >= 30) 15201.64Spk api = API_OPENGL_LAST + 1; 15211.64Spk } 15221.1Scgd mask = ARRAY_SIZE(table(api)) - 1; 15231.1Scgd hash = (pname * prime_factor); 15241.1Scgd while (1) { 15251.16Schristos int idx = table(api)[hash & mask]; 15261.1Scgd 15271.1Scgd /* If the enum isn't valid, the hash walk ends with index 0, 15281.1Scgd * pointing to the first entry of values[] which doesn't hold 15291.12Schristos * any valid enum. */ 15301.64Spk if (unlikely(idx == 0)) { 15311.64Spk _mesa_error(ctx, GL_INVALID_ENUM, "%s(pname=%s)", func, 15321.64Spk _mesa_enum_to_string(pname)); 15331.64Spk return &error_value; 15341.1Scgd } 15351.1Scgd 15361.1Scgd d = &values[idx]; 15371.1Scgd if (likely(d->pname == pname)) 15381.1Scgd break; 15391.1Scgd 15401.1Scgd hash += prime_step; 15411.12Schristos } 15421.12Schristos 15431.12Schristos if (unlikely(d->extra && !check_extra(ctx, func, d))) 15441.12Schristos return &error_value; 15451.12Schristos 15461.12Schristos switch (d->location) { 15471.1Scgd case LOC_BUFFER: 15481.12Schristos *p = ((char *) ctx->DrawBuffer + d->offset); 15491.12Schristos return d; 15501.12Schristos case LOC_CONTEXT: 15511.16Schristos *p = ((char *) ctx + d->offset); 15521.12Schristos return d; 15531.48Schristos case LOC_ARRAY: 15541.12Schristos *p = ((char *) ctx->Array.VAO + d->offset); 15551.64Spk return d; 15561.48Schristos case LOC_TEXUNIT: 15571.12Schristos if (ctx->Texture.CurrentUnit < ARRAY_SIZE(ctx->Texture.FixedFuncUnit)) { 15581.1Scgd unsigned index = ctx->Texture.CurrentUnit; 15591.1Scgd *p = ((char *)&ctx->Texture.FixedFuncUnit[index] + d->offset); 15601.1Scgd } 15611.40Ssommerfe return d; 15621.40Ssommerfe case LOC_CUSTOM: 15631.36Schristos find_custom_value(ctx, d, v); 15641.1Scgd *p = v; 15651.1Scgd return d; 15661.1Scgd default: 15671.1Scgd assert(0); 15681.1Scgd break; 15691.1Scgd } 15701.16Schristos 15711.1Scgd /* silence warning */ 15721.1Scgd return &error_value; 15731.1Scgd} 15741.36Schristos 15751.1Scgdstatic const int transpose[] = { 15761.1Scgd 0, 4, 8, 12, 15771.1Scgd 1, 5, 9, 13, 15781.1Scgd 2, 6, 10, 14, 15791.12Schristos 3, 7, 11, 15 15801.5Scgd}; 15811.12Schristos 15821.12Schristosstatic GLsizei 15831.12Schristosget_value_size(enum value_type type, const union value *v) 15841.1Scgd{ 15851.1Scgd switch (type) { 15861.1Scgd case TYPE_INVALID: 15871.12Schristos return 0; 15881.1Scgd case TYPE_CONST: 15891.12Schristos case TYPE_UINT: 15901.12Schristos case TYPE_INT: 15911.1Scgd return sizeof(GLint); 15921.1Scgd case TYPE_INT_2: 15931.1Scgd case TYPE_UINT_2: 15941.1Scgd return sizeof(GLint) * 2; 15951.1Scgd case TYPE_INT_3: 15961.5Scgd case TYPE_UINT_3: 15971.16Schristos return sizeof(GLint) * 3; 15981.5Scgd case TYPE_INT_4: 15991.1Scgd case TYPE_UINT_4: 16001.1Scgd return sizeof(GLint) * 4; 16011.1Scgd case TYPE_INT_N: 16021.69Spk return sizeof(GLint) * v->value_int_n.n; 16031.69Spk case TYPE_INT64: 16041.69Spk return sizeof(GLint64); 16051.69Spk break; 16061.1Scgd case TYPE_ENUM16: 16071.12Schristos return sizeof(GLenum16); 16081.69Spk case TYPE_ENUM: 16091.1Scgd return sizeof(GLenum); 16101.1Scgd case TYPE_ENUM_2: 16111.1Scgd return sizeof(GLenum) * 2; 16121.1Scgd case TYPE_BOOLEAN: 16131.1Scgd return sizeof(GLboolean); 16141.1Scgd case TYPE_UBYTE: 16151.16Schristos return sizeof(GLubyte); 16161.1Scgd case TYPE_SHORT: 16171.1Scgd return sizeof(GLshort); 16181.1Scgd case TYPE_BIT_0: 16191.1Scgd case TYPE_BIT_1: 16201.1Scgd case TYPE_BIT_2: 16211.1Scgd case TYPE_BIT_3: 16221.1Scgd case TYPE_BIT_4: 16231.1Scgd case TYPE_BIT_5: 16241.72Swiz case TYPE_BIT_6: 16251.1Scgd case TYPE_BIT_7: 16261.1Scgd return 1; 16271.77Schristos case TYPE_FLOAT: 16281.16Schristos case TYPE_FLOATN: 16291.77Schristos return sizeof(GLfloat); 16301.1Scgd case TYPE_FLOAT_2: 16311.1Scgd case TYPE_FLOATN_2: 16321.1Scgd return sizeof(GLfloat) * 2; 16331.1Scgd case TYPE_FLOAT_3: 16341.1Scgd case TYPE_FLOATN_3: 16351.1Scgd return sizeof(GLfloat) * 3; 16361.1Scgd case TYPE_FLOAT_4: 16371.1Scgd case TYPE_FLOATN_4: 16381.1Scgd return sizeof(GLfloat) * 4; 16391.1Scgd case TYPE_FLOAT_8: 16401.1Scgd return sizeof(GLfloat) * 8; 16411.29Schristos case TYPE_DOUBLEN: 16421.1Scgd return sizeof(GLdouble); 16431.1Scgd case TYPE_DOUBLEN_2: 16441.1Scgd return sizeof(GLdouble) * 2; 16451.1Scgd case TYPE_MATRIX: 16461.1Scgd return sizeof (GLfloat) * 16; 16471.1Scgd case TYPE_MATRIX_T: 16481.1Scgd return sizeof (GLfloat) * 16; 16491.1Scgd default: 16501.1Scgd return -1; 16511.1Scgd } 16521.1Scgd} 16531.77Schristos 16541.1Scgdvoid GLAPIENTRY 16551.1Scgd_mesa_GetBooleanv(GLenum pname, GLboolean *params) 16561.1Scgd{ 16571.77Schristos const struct value_desc *d; 16581.1Scgd union value v; 16591.1Scgd GLmatrix *m; 16601.1Scgd int shift, i; 16611.12Schristos void *p; 16621.1Scgd 16631.1Scgd d = find_value("glGetBooleanv", pname, &p, &v); 16641.1Scgd switch (d->type) { 16651.1Scgd case TYPE_INVALID: 16661.1Scgd break; 16671.16Schristos case TYPE_CONST: 16681.1Scgd params[0] = INT_TO_BOOLEAN(d->offset); 16691.72Swiz break; 16701.72Swiz 16711.72Swiz case TYPE_FLOAT_8: 16721.1Scgd params[7] = FLOAT_TO_BOOLEAN(((GLfloat *) p)[7]); 16731.58Spk params[6] = FLOAT_TO_BOOLEAN(((GLfloat *) p)[6]); 16741.1Scgd params[5] = FLOAT_TO_BOOLEAN(((GLfloat *) p)[5]); 16751.1Scgd params[4] = FLOAT_TO_BOOLEAN(((GLfloat *) p)[4]); 16761.1Scgd case TYPE_FLOAT_4: 16771.58Spk case TYPE_FLOATN_4: 16781.72Swiz params[3] = FLOAT_TO_BOOLEAN(((GLfloat *) p)[3]); 16791.1Scgd case TYPE_FLOAT_3: 16801.12Schristos case TYPE_FLOATN_3: 16811.12Schristos params[2] = FLOAT_TO_BOOLEAN(((GLfloat *) p)[2]); 16821.12Schristos case TYPE_FLOAT_2: 16831.16Schristos case TYPE_FLOATN_2: 16841.1Scgd params[1] = FLOAT_TO_BOOLEAN(((GLfloat *) p)[1]); 16851.12Schristos case TYPE_FLOAT: 16861.12Schristos case TYPE_FLOATN: 16871.12Schristos params[0] = FLOAT_TO_BOOLEAN(((GLfloat *) p)[0]); 16881.12Schristos break; 16891.12Schristos 16901.12Schristos case TYPE_DOUBLEN_2: 16911.12Schristos params[1] = FLOAT_TO_BOOLEAN(((GLdouble *) p)[1]); 16921.12Schristos case TYPE_DOUBLEN: 16931.1Scgd params[0] = FLOAT_TO_BOOLEAN(((GLdouble *) p)[0]); 16941.12Schristos break; 16951.12Schristos 16961.12Schristos case TYPE_INT_4: 16971.12Schristos case TYPE_UINT_4: 16981.12Schristos params[3] = INT_TO_BOOLEAN(((GLint *) p)[3]); 16991.12Schristos case TYPE_INT_3: 17001.12Schristos case TYPE_UINT_3: 17011.12Schristos params[2] = INT_TO_BOOLEAN(((GLint *) p)[2]); 17021.12Schristos case TYPE_INT_2: 17031.1Scgd case TYPE_UINT_2: 17041.1Scgd case TYPE_ENUM_2: 17051.1Scgd params[1] = INT_TO_BOOLEAN(((GLint *) p)[1]); 17061.1Scgd case TYPE_INT: 17071.1Scgd case TYPE_UINT: 17081.12Schristos case TYPE_ENUM: 17091.12Schristos params[0] = INT_TO_BOOLEAN(((GLint *) p)[0]); 17101.12Schristos break; 17111.12Schristos 17121.12Schristos case TYPE_ENUM16: 17131.12Schristos params[0] = INT_TO_BOOLEAN(((GLenum16 *) p)[0]); 17141.12Schristos break; 17151.12Schristos 17161.1Scgd case TYPE_INT_N: 17171.1Scgd for (i = 0; i < v.value_int_n.n; i++) 17181.12Schristos params[i] = INT_TO_BOOLEAN(v.value_int_n.ints[i]); 17191.12Schristos break; 17201.12Schristos 17211.12Schristos case TYPE_INT64: 17221.1Scgd params[0] = INT64_TO_BOOLEAN(((GLint64 *) p)[0]); 17231.12Schristos break; 17241.70Spk 17251.1Scgd case TYPE_BOOLEAN: 17261.1Scgd params[0] = ((GLboolean*) p)[0]; 17271.1Scgd break; 17281.1Scgd 17291.12Schristos case TYPE_UBYTE: 17301.12Schristos params[0] = INT_TO_BOOLEAN(((GLubyte *) p)[0]); 17311.12Schristos break; 17321.12Schristos 17331.12Schristos case TYPE_SHORT: 17341.12Schristos params[0] = INT_TO_BOOLEAN(((GLshort *) p)[0]); 17351.12Schristos break; 17361.12Schristos 17371.1Scgd case TYPE_MATRIX: 17381.58Spk m = *(GLmatrix **) p; 17391.12Schristos for (i = 0; i < 16; i++) 17401.12Schristos params[i] = FLOAT_TO_BOOLEAN(m->m[i]); 17411.12Schristos break; 17421.12Schristos 17431.12Schristos case TYPE_MATRIX_T: 17441.12Schristos m = *(GLmatrix **) p; 17451.12Schristos for (i = 0; i < 16; i++) 17461.12Schristos params[i] = FLOAT_TO_BOOLEAN(m->m[transpose[i]]); 17471.12Schristos break; 17481.12Schristos 17491.12Schristos case TYPE_BIT_0: 17501.1Scgd case TYPE_BIT_1: 17511.12Schristos case TYPE_BIT_2: 17521.16Schristos case TYPE_BIT_3: 17531.1Scgd case TYPE_BIT_4: 17541.1Scgd case TYPE_BIT_5: 17551.1Scgd case TYPE_BIT_6: 17561.1Scgd case TYPE_BIT_7: 17571.1Scgd shift = d->type - TYPE_BIT_0; 17581.1Scgd params[0] = (*(GLbitfield *) p >> shift) & 1; 17591.1Scgd break; 17601.1Scgd } 17611.1Scgd} 17621.16Schristos 17631.1Scgdvoid GLAPIENTRY 17641.29Schristos_mesa_GetFloatv(GLenum pname, GLfloat *params) 17651.16Schristos{ 17661.1Scgd const struct value_desc *d; 17671.12Schristos union value v; 17681.1Scgd GLmatrix *m; 17691.12Schristos int shift, i; 17701.12Schristos void *p; 17711.1Scgd 17721.12Schristos d = find_value("glGetFloatv", pname, &p, &v); 17731.70Spk switch (d->type) { 17741.16Schristos case TYPE_INVALID: 17751.12Schristos break; 17761.12Schristos case TYPE_CONST: 17771.12Schristos params[0] = (GLfloat) d->offset; 17781.12Schristos break; 17791.12Schristos 17801.70Spk case TYPE_FLOAT_8: 17811.12Schristos params[7] = ((GLfloat *) p)[7]; 17821.12Schristos params[6] = ((GLfloat *) p)[6]; 17831.12Schristos params[5] = ((GLfloat *) p)[5]; 17841.1Scgd params[4] = ((GLfloat *) p)[4]; 17851.1Scgd case TYPE_FLOAT_4: 17861.1Scgd case TYPE_FLOATN_4: 17871.1Scgd params[3] = ((GLfloat *) p)[3]; 17881.1Scgd case TYPE_FLOAT_3: 17891.12Schristos case TYPE_FLOATN_3: 17901.12Schristos params[2] = ((GLfloat *) p)[2]; 17911.1Scgd case TYPE_FLOAT_2: 17921.1Scgd case TYPE_FLOATN_2: 17931.58Spk params[1] = ((GLfloat *) p)[1]; 17941.12Schristos case TYPE_FLOAT: 17951.1Scgd case TYPE_FLOATN: 17961.1Scgd params[0] = ((GLfloat *) p)[0]; 17971.1Scgd break; 17981.1Scgd 17991.12Schristos case TYPE_DOUBLEN_2: 18001.12Schristos params[1] = (GLfloat) (((GLdouble *) p)[1]); 18011.1Scgd case TYPE_DOUBLEN: 18021.1Scgd params[0] = (GLfloat) (((GLdouble *) p)[0]); 18031.12Schristos break; 18041.1Scgd 18051.12Schristos case TYPE_INT_4: 18061.12Schristos params[3] = (GLfloat) (((GLint *) p)[3]); 18071.12Schristos case TYPE_INT_3: 18081.12Schristos params[2] = (GLfloat) (((GLint *) p)[2]); 18091.12Schristos case TYPE_INT_2: 18101.12Schristos case TYPE_ENUM_2: 18111.12Schristos params[1] = (GLfloat) (((GLint *) p)[1]); 18121.12Schristos case TYPE_INT: 18131.12Schristos case TYPE_ENUM: 18141.12Schristos params[0] = (GLfloat) (((GLint *) p)[0]); 18151.12Schristos break; 18161.12Schristos 18171.1Scgd case TYPE_ENUM16: 18181.1Scgd params[0] = (GLfloat) (((GLenum16 *) p)[0]); 18191.1Scgd break; 18201.1Scgd 18211.1Scgd case TYPE_INT_N: 18221.1Scgd for (i = 0; i < v.value_int_n.n; i++) 18231.1Scgd params[i] = (GLfloat) v.value_int_n.ints[i]; 18241.12Schristos break; 18251.12Schristos 18261.1Scgd case TYPE_UINT_4: 18271.70Spk params[3] = (GLfloat) (((GLuint *) p)[3]); 18281.70Spk case TYPE_UINT_3: 18291.70Spk params[2] = (GLfloat) (((GLuint *) p)[2]); 18301.70Spk case TYPE_UINT_2: 18311.70Spk params[1] = (GLfloat) (((GLuint *) p)[1]); 18321.12Schristos case TYPE_UINT: 18331.70Spk params[0] = (GLfloat) (((GLuint *) p)[0]); 18341.12Schristos break; 18351.70Spk 18361.1Scgd case TYPE_INT64: 18371.1Scgd params[0] = (GLfloat) (((GLint64 *) p)[0]); 18381.1Scgd break; 18391.1Scgd 18401.16Schristos case TYPE_BOOLEAN: 18411.1Scgd params[0] = BOOLEAN_TO_FLOAT(*(GLboolean*) p); 18421.1Scgd break; 18431.1Scgd 18441.1Scgd case TYPE_UBYTE: 18451.13Schristos params[0] = (GLfloat) ((GLubyte *) p)[0]; 18461.16Schristos break; 18471.1Scgd 18481.1Scgd case TYPE_SHORT: 18491.1Scgd params[0] = (GLfloat) ((GLshort *) p)[0]; 18501.1Scgd break; 18511.1Scgd 18521.1Scgd case TYPE_MATRIX: 18531.1Scgd m = *(GLmatrix **) p; 18541.1Scgd for (i = 0; i < 16; i++) 18551.1Scgd params[i] = m->m[i]; 18561.1Scgd break; 18571.1Scgd 18581.1Scgd case TYPE_MATRIX_T: 18591.1Scgd m = *(GLmatrix **) p; 18601.28Schristos for (i = 0; i < 16; i++) 18611.12Schristos params[i] = m->m[transpose[i]]; 18621.16Schristos break; 18631.1Scgd 18641.1Scgd case TYPE_BIT_0: 18651.12Schristos case TYPE_BIT_1: 18661.12Schristos case TYPE_BIT_2: 18671.1Scgd case TYPE_BIT_3: 18681.1Scgd case TYPE_BIT_4: 18691.1Scgd case TYPE_BIT_5: 18701.1Scgd case TYPE_BIT_6: 18711.28Schristos case TYPE_BIT_7: 18721.12Schristos shift = d->type - TYPE_BIT_0; 18731.1Scgd params[0] = BOOLEAN_TO_FLOAT((*(GLbitfield *) p >> shift) & 1); 18741.1Scgd break; 18751.1Scgd } 18761.1Scgd} 18771.1Scgd 18781.1Scgdvoid GLAPIENTRY 18791.1Scgd_mesa_GetIntegerv(GLenum pname, GLint *params) 18801.12Schristos{ 18811.12Schristos const struct value_desc *d; 18821.1Scgd union value v; 18831.12Schristos GLmatrix *m; 18841.58Spk int shift, i; 18851.1Scgd void *p; 18861.1Scgd 18871.58Spk d = find_value("glGetIntegerv", pname, &p, &v); 18881.1Scgd switch (d->type) { 18891.1Scgd case TYPE_INVALID: 18901.1Scgd break; 18911.1Scgd case TYPE_CONST: 18921.1Scgd params[0] = d->offset; 18931.1Scgd break; 18941.16Schristos 18951.1Scgd case TYPE_FLOAT_8: 18961.72Swiz params[7] = IROUND(((GLfloat *) p)[7]); 18971.72Swiz params[6] = IROUND(((GLfloat *) p)[6]); 18981.72Swiz params[5] = IROUND(((GLfloat *) p)[5]); 18991.72Swiz params[4] = IROUND(((GLfloat *) p)[4]); 19001.72Swiz case TYPE_FLOAT_4: 19011.72Swiz params[3] = IROUND(((GLfloat *) p)[3]); 19021.1Scgd case TYPE_FLOAT_3: 19031.1Scgd params[2] = IROUND(((GLfloat *) p)[2]); 19041.1Scgd case TYPE_FLOAT_2: 19051.1Scgd params[1] = IROUND(((GLfloat *) p)[1]); 19061.1Scgd case TYPE_FLOAT: 19071.1Scgd params[0] = IROUND(((GLfloat *) p)[0]); 19081.1Scgd break; 19091.1Scgd 19101.1Scgd case TYPE_FLOATN_4: 19111.1Scgd params[3] = FLOAT_TO_INT(((GLfloat *) p)[3]); 19121.1Scgd case TYPE_FLOATN_3: 19131.72Swiz params[2] = FLOAT_TO_INT(((GLfloat *) p)[2]); 19141.1Scgd case TYPE_FLOATN_2: 19151.72Swiz params[1] = FLOAT_TO_INT(((GLfloat *) p)[1]); 19161.29Schristos case TYPE_FLOATN: 19171.1Scgd params[0] = FLOAT_TO_INT(((GLfloat *) p)[0]); 19181.1Scgd break; 19191.1Scgd 19201.31Schristos case TYPE_DOUBLEN_2: 19211.1Scgd params[1] = FLOAT_TO_INT(((GLdouble *) p)[1]); 19221.12Schristos case TYPE_DOUBLEN: 19231.12Schristos params[0] = FLOAT_TO_INT(((GLdouble *) p)[0]); 19241.1Scgd break; 19251.1Scgd 19261.89Schristos case TYPE_INT_4: 19271.12Schristos case TYPE_UINT_4: 19281.1Scgd params[3] = ((GLint *) p)[3]; 19291.1Scgd case TYPE_INT_3: 19301.1Scgd case TYPE_UINT_3: 19311.1Scgd params[2] = ((GLint *) p)[2]; 19321.91Schristos case TYPE_INT_2: 19331.91Schristos case TYPE_UINT_2: 19341.1Scgd case TYPE_ENUM_2: 19351.1Scgd params[1] = ((GLint *) p)[1]; 19361.1Scgd case TYPE_INT: 19371.1Scgd case TYPE_UINT: 19381.1Scgd case TYPE_ENUM: 19391.1Scgd params[0] = ((GLint *) p)[0]; 19401.1Scgd break; 19411.1Scgd 19421.1Scgd case TYPE_ENUM16: 19431.1Scgd params[0] = ((GLenum16 *) p)[0]; 19441.12Schristos break; 19451.1Scgd 19461.1Scgd case TYPE_INT_N: 19471.12Schristos for (i = 0; i < v.value_int_n.n; i++) 19481.1Scgd params[i] = v.value_int_n.ints[i]; 19491.1Scgd break; 19501.1Scgd 19511.1Scgd case TYPE_INT64: 19521.1Scgd params[0] = INT64_TO_INT(((GLint64 *) p)[0]); 19531.1Scgd break; 19541.1Scgd 19551.1Scgd case TYPE_BOOLEAN: 19561.12Schristos params[0] = BOOLEAN_TO_INT(*(GLboolean*) p); 19571.1Scgd break; 19581.1Scgd 19591.1Scgd case TYPE_UBYTE: 19601.1Scgd params[0] = ((GLubyte *) p)[0]; 19611.16Schristos break; 19621.36Schristos 19631.36Schristos case TYPE_SHORT: 19641.36Schristos params[0] = ((GLshort *) p)[0]; 19651.1Scgd break; 19661.16Schristos 19671.1Scgd case TYPE_MATRIX: 19681.1Scgd m = *(GLmatrix **) p; 19691.1Scgd for (i = 0; i < 16; i++) 19701.1Scgd params[i] = FLOAT_TO_INT(m->m[i]); 19711.45Ssommerfe break; 19721.45Ssommerfe 19731.1Scgd case TYPE_MATRIX_T: 19741.34Schristos m = *(GLmatrix **) p; 19751.34Schristos for (i = 0; i < 16; i++) 19761.34Schristos params[i] = FLOAT_TO_INT(m->m[transpose[i]]); 19771.34Schristos break; 19781.34Schristos 19791.34Schristos case TYPE_BIT_0: 19801.69Spk case TYPE_BIT_1: 19811.34Schristos case TYPE_BIT_2: 19821.1Scgd case TYPE_BIT_3: 19831.1Scgd case TYPE_BIT_4: 19841.1Scgd case TYPE_BIT_5: 19851.1Scgd case TYPE_BIT_6: 19861.1Scgd case TYPE_BIT_7: 19871.1Scgd shift = d->type - TYPE_BIT_0; 19881.16Schristos params[0] = (*(GLbitfield *) p >> shift) & 1; 19891.69Spk break; 19901.80Sitojun } 19911.31Schristos} 19921.31Schristos 19931.31Schristosvoid GLAPIENTRY 19941.69Spk_mesa_GetInteger64v(GLenum pname, GLint64 *params) 19951.31Schristos{ 19961.31Schristos const struct value_desc *d; 19971.12Schristos union value v; 19981.31Schristos GLmatrix *m; 19991.1Scgd int shift, i; 20001.12Schristos void *p; 20011.1Scgd 20021.1Scgd d = find_value("glGetInteger64v", pname, &p, &v); 20031.1Scgd switch (d->type) { 20041.1Scgd case TYPE_INVALID: 20051.1Scgd break; 20061.1Scgd case TYPE_CONST: 20071.1Scgd params[0] = d->offset; 20081.1Scgd break; 20091.1Scgd 20101.1Scgd case TYPE_FLOAT_8: 20111.5Scgd params[7] = IROUND64(((GLfloat *) p)[7]); 20121.1Scgd params[6] = IROUND64(((GLfloat *) p)[6]); 20131.1Scgd params[5] = IROUND64(((GLfloat *) p)[5]); 20141.1Scgd params[4] = IROUND64(((GLfloat *) p)[4]); 20151.1Scgd case TYPE_FLOAT_4: 20161.1Scgd params[3] = IROUND64(((GLfloat *) p)[3]); 20171.1Scgd case TYPE_FLOAT_3: 20181.1Scgd params[2] = IROUND64(((GLfloat *) p)[2]); 20191.1Scgd case TYPE_FLOAT_2: 20201.1Scgd params[1] = IROUND64(((GLfloat *) p)[1]); 20211.1Scgd case TYPE_FLOAT: 20221.1Scgd params[0] = IROUND64(((GLfloat *) p)[0]); 20231.12Schristos break; 20241.16Schristos 20251.1Scgd case TYPE_FLOATN_4: 20261.12Schristos params[3] = FLOAT_TO_INT(((GLfloat *) p)[3]); 20271.12Schristos case TYPE_FLOATN_3: 20281.1Scgd params[2] = FLOAT_TO_INT(((GLfloat *) p)[2]); 20291.1Scgd case TYPE_FLOATN_2: 20301.12Schristos params[1] = FLOAT_TO_INT(((GLfloat *) p)[1]); 20311.1Scgd case TYPE_FLOATN: 20321.1Scgd params[0] = FLOAT_TO_INT(((GLfloat *) p)[0]); 20331.1Scgd break; 20341.1Scgd 20351.1Scgd case TYPE_DOUBLEN_2: 20361.1Scgd params[1] = FLOAT_TO_INT(((GLdouble *) p)[1]); 20371.1Scgd case TYPE_DOUBLEN: 20381.1Scgd params[0] = FLOAT_TO_INT(((GLdouble *) p)[0]); 20391.1Scgd break; 20401.1Scgd 20411.1Scgd case TYPE_INT_4: 20421.1Scgd params[3] = ((GLint *) p)[3]; 20431.1Scgd case TYPE_INT_3: 20441.12Schristos params[2] = ((GLint *) p)[2]; 20451.1Scgd case TYPE_INT_2: 20461.1Scgd case TYPE_ENUM_2: 20471.1Scgd params[1] = ((GLint *) p)[1]; 20481.1Scgd case TYPE_INT: 20491.1Scgd case TYPE_ENUM: 20501.1Scgd params[0] = ((GLint *) p)[0]; 20511.1Scgd break; 20521.12Schristos 20531.16Schristos case TYPE_ENUM16: 20541.1Scgd params[0] = ((GLenum16 *) p)[0]; 20551.1Scgd break; 20561.1Scgd 20571.1Scgd case TYPE_INT_N: 20581.1Scgd for (i = 0; i < v.value_int_n.n; i++) 20591.1Scgd params[i] = v.value_int_n.ints[i]; 20601.1Scgd break; 20611.1Scgd 20621.45Ssommerfe case TYPE_UINT_4: 20631.1Scgd params[3] = ((GLuint *) p)[3]; 20641.1Scgd case TYPE_UINT_3: 20651.1Scgd params[2] = ((GLuint *) p)[2]; 20661.1Scgd case TYPE_UINT_2: 20671.1Scgd params[1] = ((GLuint *) p)[1]; 20681.12Schristos case TYPE_UINT: 20691.1Scgd params[0] = ((GLuint *) p)[0]; 20701.1Scgd break; 20711.1Scgd 20721.1Scgd case TYPE_INT64: 20731.1Scgd params[0] = ((GLint64 *) p)[0]; 20741.1Scgd break; 20751.1Scgd 20761.1Scgd case TYPE_BOOLEAN: 20771.1Scgd params[0] = ((GLboolean*) p)[0]; 20781.1Scgd break; 20791.1Scgd 20801.1Scgd case TYPE_MATRIX: 20811.1Scgd m = *(GLmatrix **) p; 20821.1Scgd for (i = 0; i < 16; i++) 20831.1Scgd params[i] = FLOAT_TO_INT64(m->m[i]); 20841.1Scgd break; 20851.1Scgd 20861.1Scgd case TYPE_MATRIX_T: 20871.1Scgd m = *(GLmatrix **) p; 20881.1Scgd for (i = 0; i < 16; i++) 20891.1Scgd params[i] = FLOAT_TO_INT64(m->m[transpose[i]]); 20901.1Scgd break; 20911.1Scgd 20921.12Schristos case TYPE_BIT_0: 20931.1Scgd case TYPE_BIT_1: 20941.1Scgd case TYPE_BIT_2: 20951.1Scgd case TYPE_BIT_3: 20961.1Scgd case TYPE_BIT_4: 20971.16Schristos case TYPE_BIT_5: 20981.1Scgd case TYPE_BIT_6: 20991.1Scgd case TYPE_BIT_7: 21001.1Scgd shift = d->type - TYPE_BIT_0; 21011.1Scgd params[0] = (*(GLbitfield *) p >> shift) & 1; 21021.1Scgd break; 21031.1Scgd } 21041.34Schristos} 21051.12Schristos 21061.34Schristosvoid GLAPIENTRY 21071.34Schristos_mesa_GetDoublev(GLenum pname, GLdouble *params) 21081.1Scgd{ 21091.12Schristos const struct value_desc *d; 21101.1Scgd union value v; 21111.1Scgd GLmatrix *m; 21121.1Scgd int shift, i; 21131.1Scgd void *p; 21141.1Scgd 21151.1Scgd d = find_value("glGetDoublev", pname, &p, &v); 21161.1Scgd switch (d->type) { 21171.1Scgd case TYPE_INVALID: 21181.1Scgd break; 21191.1Scgd case TYPE_CONST: 21201.1Scgd params[0] = d->offset; 21211.12Schristos break; 21221.1Scgd 21231.43Ssommerfe case TYPE_FLOAT_8: 21241.43Ssommerfe params[7] = ((GLfloat *) p)[7]; 21251.57Spk params[6] = ((GLfloat *) p)[6]; 21261.1Scgd params[5] = ((GLfloat *) p)[5]; 21271.1Scgd params[4] = ((GLfloat *) p)[4]; 21281.1Scgd case TYPE_FLOAT_4: 21291.1Scgd case TYPE_FLOATN_4: 21301.1Scgd params[3] = ((GLfloat *) p)[3]; 21311.1Scgd case TYPE_FLOAT_3: 21321.1Scgd case TYPE_FLOATN_3: 21331.1Scgd params[2] = ((GLfloat *) p)[2]; 21341.1Scgd case TYPE_FLOAT_2: 21351.12Schristos case TYPE_FLOATN_2: 21361.1Scgd params[1] = ((GLfloat *) p)[1]; 21371.1Scgd case TYPE_FLOAT: 21381.1Scgd case TYPE_FLOATN: 21391.1Scgd params[0] = ((GLfloat *) p)[0]; 21401.1Scgd break; 21411.1Scgd 21421.1Scgd case TYPE_DOUBLEN_2: 21431.1Scgd params[1] = ((GLdouble *) p)[1]; 21441.1Scgd case TYPE_DOUBLEN: 21451.1Scgd params[0] = ((GLdouble *) p)[0]; 21461.1Scgd break; 21471.31Schristos 21481.1Scgd case TYPE_INT_4: 21491.12Schristos params[3] = ((GLint *) p)[3]; 21501.1Scgd case TYPE_INT_3: 21511.1Scgd params[2] = ((GLint *) p)[2]; 21521.12Schristos case TYPE_INT_2: 21531.12Schristos case TYPE_ENUM_2: 21541.1Scgd params[1] = ((GLint *) p)[1]; 21551.1Scgd case TYPE_INT: 21561.12Schristos case TYPE_ENUM: 21571.12Schristos params[0] = ((GLint *) p)[0]; 21581.1Scgd break; 21591.12Schristos 21601.12Schristos case TYPE_ENUM16: 21611.80Sitojun params[0] = ((GLenum16 *) p)[0]; 21621.31Schristos break; 21631.12Schristos 21641.1Scgd case TYPE_INT_N: 21651.1Scgd for (i = 0; i < v.value_int_n.n; i++) 21661.1Scgd params[i] = v.value_int_n.ints[i]; 21671.12Schristos break; 21681.12Schristos 21691.12Schristos case TYPE_UINT_4: 21701.12Schristos params[3] = ((GLuint *) p)[3]; 21711.12Schristos case TYPE_UINT_3: 21721.12Schristos params[2] = ((GLuint *) p)[2]; 21731.12Schristos case TYPE_UINT_2: 21741.12Schristos params[1] = ((GLuint *) p)[1]; 21751.12Schristos case TYPE_UINT: 21761.12Schristos params[0] = ((GLuint *) p)[0]; 21771.12Schristos break; 21781.12Schristos 21791.12Schristos case TYPE_INT64: 21801.1Scgd params[0] = (GLdouble) (((GLint64 *) p)[0]); 21811.1Scgd break; 21821.12Schristos 21831.12Schristos case TYPE_BOOLEAN: 21841.12Schristos params[0] = *(GLboolean*) p; 21851.12Schristos break; 21861.12Schristos 21871.12Schristos case TYPE_UBYTE: 21881.12Schristos params[0] = ((GLubyte *) p)[0]; 21891.1Scgd break; 21901.1Scgd 21911.1Scgd case TYPE_SHORT: 21921.1Scgd params[0] = ((GLshort *) p)[0]; 21931.16Schristos break; 21941.1Scgd 21951.16Schristos case TYPE_MATRIX: 21961.12Schristos m = *(GLmatrix **) p; 21971.12Schristos for (i = 0; i < 16; i++) 21981.1Scgd params[i] = m->m[i]; 21991.1Scgd break; 22001.12Schristos 22011.1Scgd case TYPE_MATRIX_T: 22021.1Scgd m = *(GLmatrix **) p; 22031.1Scgd for (i = 0; i < 16; i++) 22041.1Scgd params[i] = m->m[transpose[i]]; 22051.1Scgd break; 22061.1Scgd 22071.16Schristos case TYPE_BIT_0: 22081.72Swiz case TYPE_BIT_1: 22091.12Schristos case TYPE_BIT_2: 22101.72Swiz case TYPE_BIT_3: 22111.12Schristos case TYPE_BIT_4: 22121.12Schristos case TYPE_BIT_5: 22131.12Schristos case TYPE_BIT_6: 22141.12Schristos case TYPE_BIT_7: 22151.12Schristos shift = d->type - TYPE_BIT_0; 22161.12Schristos params[0] = (*(GLbitfield *) p >> shift) & 1; 22171.12Schristos break; 22181.12Schristos } 22191.12Schristos} 22201.12Schristos 22211.12Schristosvoid GLAPIENTRY 22221.12Schristos_mesa_GetUnsignedBytevEXT(GLenum pname, GLubyte *data) 22231.12Schristos{ 22241.12Schristos const struct value_desc *d; 22251.12Schristos union value v; 22261.12Schristos int shift; 22271.12Schristos void *p = NULL; 22281.12Schristos GLsizei size; 22291.12Schristos const char *func = "glGetUnsignedBytevEXT"; 22301.12Schristos 22311.12Schristos GET_CURRENT_CONTEXT(ctx); 22321.12Schristos 22331.12Schristos if (!ctx->Extensions.EXT_memory_object) { 22341.12Schristos _mesa_error(ctx, GL_INVALID_OPERATION, "%s(unsupported)", func); 22351.12Schristos return; 22361.12Schristos } 22371.12Schristos 22381.12Schristos d = find_value(func, pname, &p, &v); 22391.12Schristos size = get_value_size(d->type, &v); 22401.12Schristos if (size <= 0) { 22411.12Schristos _mesa_problem(ctx, "invalid value type in GetUnsignedBytevEXT()"); 22421.12Schristos } 22431.12Schristos 22441.12Schristos switch (d->type) { 22451.12Schristos case TYPE_BIT_0: 22461.12Schristos case TYPE_BIT_1: 22471.12Schristos case TYPE_BIT_2: 22481.12Schristos case TYPE_BIT_3: 22491.12Schristos case TYPE_BIT_4: 22501.1Scgd case TYPE_BIT_5: 22511.1Scgd case TYPE_BIT_6: 22521.1Scgd case TYPE_BIT_7: 22531.1Scgd shift = d->type - TYPE_BIT_0; 22541.1Scgd data[0] = (*(GLbitfield *) p >> shift) & 1; 22551.1Scgd break; 22561.1Scgd case TYPE_CONST: 22571.1Scgd memcpy(data, &d->offset, size); 22581.1Scgd break; 22591.1Scgd case TYPE_INT_N: 22601.1Scgd memcpy(data, &v.value_int_n.ints, size); 22611.1Scgd break; 22621.1Scgd case TYPE_UINT: 22631.1Scgd case TYPE_INT: 22641.1Scgd case TYPE_INT_2: 22651.1Scgd case TYPE_UINT_2: 22661.1Scgd case TYPE_INT_3: 22671.16Schristos case TYPE_UINT_3: 22681.1Scgd case TYPE_INT_4: 22691.1Scgd case TYPE_UINT_4: 22701.72Swiz case TYPE_INT64: 22711.72Swiz case TYPE_ENUM: 22721.72Swiz case TYPE_ENUM_2: 22731.72Swiz case TYPE_BOOLEAN: 22741.72Swiz case TYPE_UBYTE: 22751.1Scgd case TYPE_SHORT: 22761.1Scgd case TYPE_FLOAT: 22771.1Scgd case TYPE_FLOATN: 22781.1Scgd case TYPE_FLOAT_2: 22791.1Scgd case TYPE_FLOATN_2: 22801.1Scgd case TYPE_FLOAT_3: 22811.1Scgd case TYPE_FLOATN_3: 22821.12Schristos case TYPE_FLOAT_4: 22831.72Swiz case TYPE_FLOATN_4: 22841.1Scgd case TYPE_FLOAT_8: 22851.1Scgd case TYPE_DOUBLEN: 22861.12Schristos case TYPE_DOUBLEN_2: 22871.72Swiz case TYPE_MATRIX: 22881.72Swiz case TYPE_MATRIX_T: 22891.72Swiz memcpy(data, p, size); 22901.16Schristos break; 22911.1Scgd case TYPE_ENUM16: { 22921.1Scgd GLenum e = *(GLenum16 *)p; 22931.1Scgd memcpy(data, &e, sizeof(e)); 22941.1Scgd break; 22951.16Schristos } 22961.1Scgd default: 22971.1Scgd break; /* nothing - GL error was recorded */ 22981.1Scgd } 22991.1Scgd} 23001.1Scgd 23011.12Schristos/** 23021.12Schristos * Convert a GL texture binding enum such as GL_TEXTURE_BINDING_2D 23031.16Schristos * into the corresponding Mesa texture target index. 23041.12Schristos * \return TEXTURE_x_INDEX or -1 if binding is invalid 23051.1Scgd */ 23061.1Scgdstatic int 23071.1Scgdtex_binding_to_index(const struct gl_context *ctx, GLenum binding) 23081.1Scgd{ 23091.1Scgd switch (binding) { 23101.1Scgd case GL_TEXTURE_BINDING_1D: 23111.1Scgd return _mesa_is_desktop_gl(ctx) ? TEXTURE_1D_INDEX : -1; 23121.1Scgd case GL_TEXTURE_BINDING_2D: 23131.1Scgd return TEXTURE_2D_INDEX; 23141.1Scgd case GL_TEXTURE_BINDING_3D: 23151.1Scgd return ctx->API != API_OPENGLES ? TEXTURE_3D_INDEX : -1; 23161.16Schristos case GL_TEXTURE_BINDING_CUBE_MAP: 23171.1Scgd return ctx->Extensions.ARB_texture_cube_map 23181.1Scgd ? TEXTURE_CUBE_INDEX : -1; 23191.1Scgd case GL_TEXTURE_BINDING_RECTANGLE: 23201.1Scgd return _mesa_is_desktop_gl(ctx) && ctx->Extensions.NV_texture_rectangle 23211.1Scgd ? TEXTURE_RECT_INDEX : -1; 23221.1Scgd case GL_TEXTURE_BINDING_1D_ARRAY: 23231.1Scgd return _mesa_is_desktop_gl(ctx) && ctx->Extensions.EXT_texture_array 23241.1Scgd ? TEXTURE_1D_ARRAY_INDEX : -1; 23251.1Scgd case GL_TEXTURE_BINDING_2D_ARRAY: 23261.1Scgd return (_mesa_is_desktop_gl(ctx) && ctx->Extensions.EXT_texture_array) 23271.1Scgd || _mesa_is_gles3(ctx) 23281.16Schristos ? TEXTURE_2D_ARRAY_INDEX : -1; 23291.1Scgd case GL_TEXTURE_BINDING_BUFFER: 23301.1Scgd return (_mesa_has_ARB_texture_buffer_object(ctx) || 23311.1Scgd _mesa_has_OES_texture_buffer(ctx)) ? 23321.16Schristos TEXTURE_BUFFER_INDEX : -1; 23331.1Scgd case GL_TEXTURE_BINDING_CUBE_MAP_ARRAY: 23341.1Scgd return _mesa_has_texture_cube_map_array(ctx) 23351.1Scgd ? TEXTURE_CUBE_ARRAY_INDEX : -1; 23361.1Scgd case GL_TEXTURE_BINDING_2D_MULTISAMPLE: 23371.1Scgd return _mesa_is_desktop_gl(ctx) && ctx->Extensions.ARB_texture_multisample 23381.1Scgd ? TEXTURE_2D_MULTISAMPLE_INDEX : -1; 23391.1Scgd case GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY: 23401.1Scgd return _mesa_is_desktop_gl(ctx) && ctx->Extensions.ARB_texture_multisample 23411.1Scgd ? TEXTURE_2D_MULTISAMPLE_ARRAY_INDEX : -1; 23421.1Scgd default: 23431.1Scgd return -1; 23441.1Scgd } 23451.1Scgd} 23461.16Schristos 23471.1Scgdstatic enum value_type 23481.1Scgdfind_value_indexed(const char *func, GLenum pname, GLuint index, union value *v) 23491.1Scgd{ 23501.1Scgd GET_CURRENT_CONTEXT(ctx); 23511.1Scgd 23521.16Schristos switch (pname) { 23531.1Scgd 23541.12Schristos case GL_BLEND: 23551.1Scgd if (index >= ctx->Const.MaxDrawBuffers) 23561.1Scgd goto invalid_value; 23571.1Scgd if (!ctx->Extensions.EXT_draw_buffers2) 23581.12Schristos goto invalid_enum; 23591.1Scgd v->value_int = (ctx->Color.BlendEnabled >> index) & 1; 23601.1Scgd return TYPE_INT; 23611.1Scgd 23621.16Schristos case GL_BLEND_SRC: 23631.54Swiz /* fall-through */ 23641.1Scgd case GL_BLEND_SRC_RGB: 23651.1Scgd if (index >= ctx->Const.MaxDrawBuffers) 23661.1Scgd goto invalid_value; 23671.16Schristos if (!ctx->Extensions.ARB_draw_buffers_blend) 23681.1Scgd goto invalid_enum; 23691.1Scgd v->value_int = ctx->Color.Blend[index].SrcRGB; 23701.1Scgd return TYPE_INT; 23711.12Schristos case GL_BLEND_SRC_ALPHA: 23721.16Schristos if (index >= ctx->Const.MaxDrawBuffers) 23731.16Schristos goto invalid_value; 23741.1Scgd if (!ctx->Extensions.ARB_draw_buffers_blend) 23751.1Scgd goto invalid_enum; 23761.1Scgd v->value_int = ctx->Color.Blend[index].SrcA; 23771.1Scgd return TYPE_INT; 23781.1Scgd case GL_BLEND_DST: 23791.1Scgd /* fall-through */ 23801.1Scgd case GL_BLEND_DST_RGB: 23811.1Scgd if (index >= ctx->Const.MaxDrawBuffers) 23821.12Schristos goto invalid_value; 23831.1Scgd if (!ctx->Extensions.ARB_draw_buffers_blend) 23841.1Scgd goto invalid_enum; 23851.12Schristos v->value_int = ctx->Color.Blend[index].DstRGB; 23861.12Schristos return TYPE_INT; 23871.1Scgd case GL_BLEND_DST_ALPHA: 23881.1Scgd if (index >= ctx->Const.MaxDrawBuffers) 23891.1Scgd goto invalid_value; 23901.5Scgd if (!ctx->Extensions.ARB_draw_buffers_blend) 23911.16Schristos goto invalid_enum; 23921.16Schristos v->value_int = ctx->Color.Blend[index].DstA; 23931.16Schristos return TYPE_INT; 23941.1Scgd case GL_BLEND_EQUATION_RGB: 23951.1Scgd if (index >= ctx->Const.MaxDrawBuffers) 23961.1Scgd goto invalid_value; 23971.1Scgd if (!ctx->Extensions.ARB_draw_buffers_blend) 23981.1Scgd goto invalid_enum; 23991.1Scgd v->value_int = ctx->Color.Blend[index].EquationRGB; 24001.1Scgd return TYPE_INT; 24011.1Scgd case GL_BLEND_EQUATION_ALPHA: 24021.1Scgd if (index >= ctx->Const.MaxDrawBuffers) 24031.1Scgd goto invalid_value; 24041.1Scgd if (!ctx->Extensions.ARB_draw_buffers_blend) 24051.16Schristos goto invalid_enum; 24061.16Schristos v->value_int = ctx->Color.Blend[index].EquationA; 24071.16Schristos return TYPE_INT; 24081.16Schristos 24091.16Schristos case GL_COLOR_WRITEMASK: 24101.1Scgd if (index >= ctx->Const.MaxDrawBuffers) 24111.1Scgd goto invalid_value; 24121.1Scgd if (!ctx->Extensions.EXT_draw_buffers2) 24131.1Scgd goto invalid_enum; 24141.1Scgd v->value_int_4[0] = GET_COLORMASK_BIT(ctx->Color.ColorMask, index, 0); 24151.1Scgd v->value_int_4[1] = GET_COLORMASK_BIT(ctx->Color.ColorMask, index, 1); 24161.1Scgd v->value_int_4[2] = GET_COLORMASK_BIT(ctx->Color.ColorMask, index, 2); 24171.1Scgd v->value_int_4[3] = GET_COLORMASK_BIT(ctx->Color.ColorMask, index, 3); 24181.1Scgd return TYPE_INT_4; 24191.1Scgd 24201.1Scgd case GL_SCISSOR_BOX: 24211.1Scgd if (index >= ctx->Const.MaxViewports) 24221.1Scgd goto invalid_value; 24231.1Scgd v->value_int_4[0] = ctx->Scissor.ScissorArray[index].X; 24241.12Schristos v->value_int_4[1] = ctx->Scissor.ScissorArray[index].Y; 24251.12Schristos v->value_int_4[2] = ctx->Scissor.ScissorArray[index].Width; 24261.12Schristos v->value_int_4[3] = ctx->Scissor.ScissorArray[index].Height; 24271.12Schristos return TYPE_INT_4; 24281.12Schristos 24291.72Swiz case GL_WINDOW_RECTANGLE_EXT: 24301.1Scgd if (!ctx->Extensions.EXT_window_rectangles) 24311.1Scgd goto invalid_enum; 24321.12Schristos if (index >= ctx->Const.MaxWindowRectangles) 24331.1Scgd goto invalid_value; 24341.1Scgd v->value_int_4[0] = ctx->Scissor.WindowRects[index].X; 24351.1Scgd v->value_int_4[1] = ctx->Scissor.WindowRects[index].Y; 24361.12Schristos v->value_int_4[2] = ctx->Scissor.WindowRects[index].Width; 24371.1Scgd v->value_int_4[3] = ctx->Scissor.WindowRects[index].Height; 24381.1Scgd return TYPE_INT_4; 24391.1Scgd 24401.1Scgd case GL_VIEWPORT: 24411.1Scgd if (index >= ctx->Const.MaxViewports) 24421.1Scgd goto invalid_value; 24431.12Schristos v->value_float_4[0] = ctx->ViewportArray[index].X; 24441.12Schristos v->value_float_4[1] = ctx->ViewportArray[index].Y; 24451.12Schristos v->value_float_4[2] = ctx->ViewportArray[index].Width; 24461.12Schristos v->value_float_4[3] = ctx->ViewportArray[index].Height; 24471.12Schristos return TYPE_FLOAT_4; 24481.1Scgd 24491.1Scgd case GL_DEPTH_RANGE: 24501.12Schristos if (index >= ctx->Const.MaxViewports) 24511.12Schristos goto invalid_value; 24521.34Schristos v->value_double_2[0] = ctx->ViewportArray[index].Near; 24531.34Schristos v->value_double_2[1] = ctx->ViewportArray[index].Far; 24541.1Scgd return TYPE_DOUBLEN_2; 24551.1Scgd 24561.1Scgd case GL_TRANSFORM_FEEDBACK_BUFFER_START: 24571.1Scgd if (index >= ctx->Const.MaxTransformFeedbackBuffers) 24581.91Schristos goto invalid_value; 24591.91Schristos if (!ctx->Extensions.EXT_transform_feedback) 24601.91Schristos goto invalid_enum; 24611.91Schristos v->value_int64 = ctx->TransformFeedback.CurrentObject->Offset[index]; 24621.91Schristos return TYPE_INT64; 24631.91Schristos 24641.91Schristos case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE: 24651.91Schristos if (index >= ctx->Const.MaxTransformFeedbackBuffers) 24661.91Schristos goto invalid_value; 24671.91Schristos if (!ctx->Extensions.EXT_transform_feedback) 24681.91Schristos goto invalid_enum; 24691.91Schristos v->value_int64 24701.91Schristos = ctx->TransformFeedback.CurrentObject->RequestedSize[index]; 24711.91Schristos return TYPE_INT64; 24721.91Schristos 24731.91Schristos case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING: 24741.91Schristos if (index >= ctx->Const.MaxTransformFeedbackBuffers) 24751.91Schristos goto invalid_value; 24761.91Schristos if (!ctx->Extensions.EXT_transform_feedback) 24771.91Schristos goto invalid_enum; 24781.91Schristos v->value_int = ctx->TransformFeedback.CurrentObject->BufferNames[index]; 24791.91Schristos return TYPE_INT; 24801.91Schristos 24811.91Schristos case GL_UNIFORM_BUFFER_BINDING: 24821.91Schristos if (index >= ctx->Const.MaxUniformBufferBindings) 24831.91Schristos goto invalid_value; 24841.91Schristos if (!ctx->Extensions.ARB_uniform_buffer_object) 24851.91Schristos goto invalid_enum; 24861.91Schristos v->value_int = ctx->UniformBufferBindings[index].BufferObject->Name; 24871.1Scgd return TYPE_INT; 24881.1Scgd 24891.1Scgd case GL_UNIFORM_BUFFER_START: 24901.1Scgd if (index >= ctx->Const.MaxUniformBufferBindings) 24911.1Scgd goto invalid_value; 24921.72Swiz if (!ctx->Extensions.ARB_uniform_buffer_object) 24931.72Swiz goto invalid_enum; 24941.72Swiz v->value_int = ctx->UniformBufferBindings[index].Offset < 0 ? 0 : 24951.1Scgd ctx->UniformBufferBindings[index].Offset; 24961.1Scgd return TYPE_INT; 24971.1Scgd 24981.1Scgd case GL_UNIFORM_BUFFER_SIZE: 24991.1Scgd if (index >= ctx->Const.MaxUniformBufferBindings) 25001.1Scgd goto invalid_value; 25011.1Scgd if (!ctx->Extensions.ARB_uniform_buffer_object) 25021.1Scgd goto invalid_enum; 25031.1Scgd v->value_int = ctx->UniformBufferBindings[index].Size < 0 ? 0 : 25041.1Scgd ctx->UniformBufferBindings[index].Size; 25051.1Scgd return TYPE_INT; 25061.1Scgd 25071.1Scgd /* ARB_shader_storage_buffer_object */ 25081.1Scgd case GL_SHADER_STORAGE_BUFFER_BINDING: 25091.1Scgd if (!ctx->Extensions.ARB_shader_storage_buffer_object) 25101.72Swiz goto invalid_enum; 25111.1Scgd if (index >= ctx->Const.MaxShaderStorageBufferBindings) 25121.1Scgd goto invalid_value; 25131.72Swiz v->value_int = ctx->ShaderStorageBufferBindings[index].BufferObject->Name; 25141.1Scgd return TYPE_INT; 25151.13Schristos 25161.1Scgd case GL_SHADER_STORAGE_BUFFER_START: 25171.1Scgd if (!ctx->Extensions.ARB_shader_storage_buffer_object) 25181.1Scgd goto invalid_enum; 25191.1Scgd if (index >= ctx->Const.MaxShaderStorageBufferBindings) 25201.1Scgd goto invalid_value; 25211.1Scgd v->value_int = ctx->ShaderStorageBufferBindings[index].Offset < 0 ? 0 : 25221.1Scgd ctx->ShaderStorageBufferBindings[index].Offset; 25231.16Schristos return TYPE_INT; 25241.13Schristos 25251.13Schristos case GL_SHADER_STORAGE_BUFFER_SIZE: 25261.1Scgd if (!ctx->Extensions.ARB_shader_storage_buffer_object) 25271.12Schristos goto invalid_enum; 25281.28Schristos if (index >= ctx->Const.MaxShaderStorageBufferBindings) 25291.28Schristos goto invalid_value; 25301.12Schristos v->value_int = ctx->ShaderStorageBufferBindings[index].Size < 0 ? 0 : 25311.12Schristos ctx->ShaderStorageBufferBindings[index].Size; 25321.16Schristos return TYPE_INT; 25331.12Schristos 25341.1Scgd /* ARB_texture_multisample / GL3.2 */ 25351.28Schristos case GL_SAMPLE_MASK_VALUE: 25361.6Sjtc if (index != 0) 25371.1Scgd goto invalid_value; 25381.16Schristos if (!ctx->Extensions.ARB_texture_multisample) 25391.1Scgd goto invalid_enum; 25401.1Scgd v->value_int = ctx->Multisample.SampleMaskValue; 25411.1Scgd return TYPE_INT; 25421.12Schristos 25431.1Scgd case GL_ATOMIC_COUNTER_BUFFER_BINDING: 25441.16Schristos if (!ctx->Extensions.ARB_shader_atomic_counters) 25451.1Scgd goto invalid_enum; 25461.1Scgd if (index >= ctx->Const.MaxAtomicBufferBindings) 25471.1Scgd goto invalid_value; 25481.12Schristos v->value_int = ctx->AtomicBufferBindings[index].BufferObject->Name; 25491.12Schristos return TYPE_INT; 25501.1Scgd 25511.12Schristos case GL_ATOMIC_COUNTER_BUFFER_START: 25521.12Schristos if (!ctx->Extensions.ARB_shader_atomic_counters) 25531.12Schristos goto invalid_enum; 25541.12Schristos if (index >= ctx->Const.MaxAtomicBufferBindings) 25551.69Spk goto invalid_value; 25561.12Schristos v->value_int64 = ctx->AtomicBufferBindings[index].Offset < 0 ? 0 : 25571.12Schristos ctx->AtomicBufferBindings[index].Offset; 25581.12Schristos return TYPE_INT64; 25591.12Schristos 25601.12Schristos case GL_ATOMIC_COUNTER_BUFFER_SIZE: 25611.1Scgd if (!ctx->Extensions.ARB_shader_atomic_counters) 25621.12Schristos goto invalid_enum; 25631.1Scgd if (index >= ctx->Const.MaxAtomicBufferBindings) 25641.1Scgd goto invalid_value; 25651.12Schristos v->value_int64 = ctx->AtomicBufferBindings[index].Size < 0 ? 0 : 25661.1Scgd ctx->AtomicBufferBindings[index].Size; 25671.1Scgd return TYPE_INT64; 25681.1Scgd 25691.1Scgd case GL_VERTEX_BINDING_DIVISOR: 25701.1Scgd if ((!_mesa_is_desktop_gl(ctx) || !ctx->Extensions.ARB_instanced_arrays) && 25711.1Scgd !_mesa_is_gles31(ctx)) 25721.1Scgd goto invalid_enum; 25731.1Scgd if (index >= ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs) 25741.16Schristos goto invalid_value; 25751.1Scgd v->value_int = ctx->Array.VAO->BufferBinding[VERT_ATTRIB_GENERIC(index)].InstanceDivisor; 25761.16Schristos return TYPE_INT; 25771.1Scgd 25781.1Scgd case GL_VERTEX_BINDING_OFFSET: 25791.16Schristos if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles31(ctx)) 25801.1Scgd goto invalid_enum; 25811.1Scgd if (index >= ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs) 25821.1Scgd goto invalid_value; 25831.1Scgd v->value_int = ctx->Array.VAO->BufferBinding[VERT_ATTRIB_GENERIC(index)].Offset; 25841.1Scgd return TYPE_INT; 25851.1Scgd 25861.72Swiz case GL_VERTEX_BINDING_STRIDE: 25871.1Scgd if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles31(ctx)) 25881.35Schristos goto invalid_enum; 25891.72Swiz if (index >= ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs) 25901.72Swiz goto invalid_value; 25911.5Scgd v->value_int = ctx->Array.VAO->BufferBinding[VERT_ATTRIB_GENERIC(index)].Stride; 25921.1Scgd return TYPE_INT; 25931.5Scgd 25941.1Scgd case GL_VERTEX_BINDING_BUFFER: 25951.12Schristos if (ctx->API == API_OPENGLES2 && ctx->Version < 31) 25961.42Ssommerfe goto invalid_enum; 25971.1Scgd if (index >= ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs) 25981.1Scgd goto invalid_value; 25991.1Scgd v->value_int = ctx->Array.VAO->BufferBinding[VERT_ATTRIB_GENERIC(index)].BufferObj->Name; 26001.1Scgd return TYPE_INT; 26011.1Scgd 26021.1Scgd /* ARB_shader_image_load_store */ 26031.1Scgd case GL_IMAGE_BINDING_NAME: { 26041.1Scgd struct gl_texture_object *t; 26051.1Scgd 26061.1Scgd if (!ctx->Extensions.ARB_shader_image_load_store) 26071.1Scgd goto invalid_enum; 26081.1Scgd if (index >= ctx->Const.MaxImageUnits) 26091.1Scgd goto invalid_value; 26101.1Scgd 26111.1Scgd t = ctx->ImageUnits[index].TexObj; 26121.1Scgd v->value_int = (t ? t->Name : 0); 26131.89Schristos return TYPE_INT; 26141.1Scgd } 26151.1Scgd 26161.1Scgd case GL_IMAGE_BINDING_LEVEL: 26171.1Scgd if (!ctx->Extensions.ARB_shader_image_load_store) 26181.1Scgd goto invalid_enum; 26191.1Scgd if (index >= ctx->Const.MaxImageUnits) 26201.1Scgd goto invalid_value; 26211.40Ssommerfe 26221.73Sgson v->value_int = ctx->ImageUnits[index].Level; 26231.35Schristos return TYPE_INT; 26241.73Sgson 26251.69Spk case GL_IMAGE_BINDING_LAYERED: 26261.69Spk if (!ctx->Extensions.ARB_shader_image_load_store) 26271.12Schristos goto invalid_enum; 26281.12Schristos if (index >= ctx->Const.MaxImageUnits) 26291.1Scgd goto invalid_value; 26301.73Sgson 26311.73Sgson v->value_int = ctx->ImageUnits[index].Layered; 26321.73Sgson return TYPE_INT; 26331.73Sgson 26341.73Sgson case GL_IMAGE_BINDING_LAYER: 26351.73Sgson if (!ctx->Extensions.ARB_shader_image_load_store) 26361.73Sgson goto invalid_enum; 26371.35Schristos if (index >= ctx->Const.MaxImageUnits) 26381.12Schristos goto invalid_value; 26391.73Sgson 26401.12Schristos v->value_int = ctx->ImageUnits[index].Layer; 26411.35Schristos return TYPE_INT; 26421.1Scgd 26431.1Scgd case GL_IMAGE_BINDING_ACCESS: 26441.12Schristos if (!ctx->Extensions.ARB_shader_image_load_store) 26451.69Spk goto invalid_enum; 26461.1Scgd if (index >= ctx->Const.MaxImageUnits) 26471.1Scgd goto invalid_value; 26481.1Scgd 26491.1Scgd v->value_int = ctx->ImageUnits[index].Access; 26501.1Scgd return TYPE_INT; 26511.1Scgd 26521.1Scgd case GL_IMAGE_BINDING_FORMAT: 26531.1Scgd if (!ctx->Extensions.ARB_shader_image_load_store) 26541.1Scgd goto invalid_enum; 26551.1Scgd if (index >= ctx->Const.MaxImageUnits) 26561.1Scgd goto invalid_value; 26571.1Scgd 26581.1Scgd v->value_int = ctx->ImageUnits[index].Format; 26591.1Scgd return TYPE_INT; 26601.1Scgd 26611.1Scgd /* ARB_direct_state_access */ 26621.1Scgd case GL_TEXTURE_BINDING_1D: 26631.1Scgd case GL_TEXTURE_BINDING_1D_ARRAY: 26641.1Scgd case GL_TEXTURE_BINDING_2D: 26651.1Scgd case GL_TEXTURE_BINDING_2D_ARRAY: 26661.72Swiz case GL_TEXTURE_BINDING_2D_MULTISAMPLE: 26671.1Scgd case GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY: 26681.12Schristos case GL_TEXTURE_BINDING_3D: 26691.1Scgd case GL_TEXTURE_BINDING_BUFFER: 26701.1Scgd case GL_TEXTURE_BINDING_CUBE_MAP: 26711.81Ssjg case GL_TEXTURE_BINDING_CUBE_MAP_ARRAY: 26721.81Ssjg case GL_TEXTURE_BINDING_RECTANGLE: { 26731.81Ssjg int target; 26741.81Ssjg 26751.81Ssjg if (ctx->API != API_OPENGL_CORE) 26761.81Ssjg goto invalid_enum; 26771.81Ssjg target = tex_binding_to_index(ctx, pname); 26781.81Ssjg if (target < 0) 26791.81Ssjg goto invalid_enum; 26801.81Ssjg if (index >= _mesa_max_tex_unit(ctx)) 26811.81Ssjg goto invalid_value; 26821.81Ssjg 26831.81Ssjg v->value_int = ctx->Texture.Unit[index].CurrentTex[target]->Name; 26841.81Ssjg return TYPE_INT; 26851.81Ssjg } 26861.81Ssjg 26871.81Ssjg case GL_SAMPLER_BINDING: { 26881.81Ssjg struct gl_sampler_object *samp; 26891.81Ssjg 26901.81Ssjg if (!_mesa_is_desktop_gl(ctx) || ctx->Version < 33) 26911.81Ssjg goto invalid_enum; 26921.81Ssjg if (index >= _mesa_max_tex_unit(ctx)) 26931.1Scgd goto invalid_value; 26941.1Scgd 26951.1Scgd samp = ctx->Texture.Unit[index].Sampler; 26961.1Scgd v->value_int = samp ? samp->Name : 0; 26971.1Scgd return TYPE_INT; 26981.72Swiz } 26991.72Swiz 27001.72Swiz case GL_MAX_COMPUTE_WORK_GROUP_COUNT: 27011.72Swiz if (!_mesa_has_compute_shaders(ctx)) 27021.72Swiz goto invalid_enum; 27031.72Swiz if (index >= 3) 27041.1Scgd goto invalid_value; 27051.1Scgd v->value_int = ctx->Const.MaxComputeWorkGroupCount[index]; 27061.1Scgd return TYPE_INT; 27071.1Scgd 27081.1Scgd case GL_MAX_COMPUTE_WORK_GROUP_SIZE: 27091.1Scgd if (!_mesa_has_compute_shaders(ctx)) 27101.1Scgd goto invalid_enum; 27111.1Scgd if (index >= 3) 27121.72Swiz goto invalid_value; 27131.1Scgd v->value_int = ctx->Const.MaxComputeWorkGroupSize[index]; 27141.1Scgd return TYPE_INT; 27151.1Scgd 27161.12Schristos /* ARB_compute_variable_group_size */ 27171.1Scgd case GL_MAX_COMPUTE_VARIABLE_GROUP_SIZE_ARB: 27181.1Scgd if (!ctx->Extensions.ARB_compute_variable_group_size) 27191.1Scgd goto invalid_enum; 27201.1Scgd if (index >= 3) 27211.1Scgd goto invalid_value; 27221.40Ssommerfe v->value_int = ctx->Const.MaxComputeVariableGroupSize[index]; 27231.1Scgd return TYPE_INT; 27241.1Scgd 27251.1Scgd /* GL_EXT_external_objects */ 27261.1Scgd case GL_NUM_DEVICE_UUIDS_EXT: 27271.1Scgd v->value_int = 1; 27281.1Scgd return TYPE_INT; 27291.12Schristos case GL_DRIVER_UUID_EXT: 27301.12Schristos if (index >= 1) 27311.12Schristos goto invalid_value; 27321.12Schristos _mesa_get_driver_uuid(ctx, v->value_int_4); 27331.12Schristos return TYPE_INT_4; 27341.1Scgd case GL_DEVICE_UUID_EXT: 27351.1Scgd if (index >= 1) 27361.40Ssommerfe goto invalid_value; 27371.1Scgd _mesa_get_device_uuid(ctx, v->value_int_4); 27381.1Scgd return TYPE_INT_4; 27391.1Scgd } 27401.1Scgd 27411.1Scgd invalid_enum: 27421.16Schristos _mesa_error(ctx, GL_INVALID_ENUM, "%s(pname=%s)", func, 27431.81Ssjg _mesa_enum_to_string(pname)); 27441.1Scgd return TYPE_INVALID; 27451.73Sgson invalid_value: 27461.73Sgson _mesa_error(ctx, GL_INVALID_VALUE, "%s(pname=%s)", func, 27471.74Senami _mesa_enum_to_string(pname)); 27481.74Senami return TYPE_INVALID; 27491.73Sgson} 27501.73Sgson 27511.73Sgsonvoid GLAPIENTRY 27521.69Spk_mesa_GetBooleani_v( GLenum pname, GLuint index, GLboolean *params ) 27531.1Scgd{ 27541.73Sgson union value v; 27551.1Scgd enum value_type type = 27561.73Sgson find_value_indexed("glGetBooleani_v", pname, index, &v); 27571.69Spk 27581.69Spk switch (type) { 27591.69Spk case TYPE_INT: 27601.69Spk case TYPE_UINT: 27611.69Spk params[0] = INT_TO_BOOLEAN(v.value_int); 27621.69Spk break; 27631.1Scgd case TYPE_INT_4: 27641.69Spk case TYPE_UINT_4: 27651.37Ssommerfe params[0] = INT_TO_BOOLEAN(v.value_int_4[0]); 27661.69Spk params[1] = INT_TO_BOOLEAN(v.value_int_4[1]); 27671.69Spk params[2] = INT_TO_BOOLEAN(v.value_int_4[2]); 27681.37Ssommerfe params[3] = INT_TO_BOOLEAN(v.value_int_4[3]); 27691.69Spk break; 27701.69Spk case TYPE_INT64: 27711.69Spk params[0] = INT64_TO_BOOLEAN(v.value_int64); 27721.69Spk break; 27731.69Spk default: 27741.1Scgd ; /* nothing - GL error was recorded */ 27751.1Scgd } 27761.1Scgd} 27771.16Schristos 27781.1Scgdvoid GLAPIENTRY 27791.1Scgd_mesa_GetIntegeri_v( GLenum pname, GLuint index, GLint *params ) 27801.1Scgd{ 27811.69Spk union value v; 27821.69Spk enum value_type type = 27831.69Spk find_value_indexed("glGetIntegeri_v", pname, index, &v); 27841.69Spk 27851.69Spk switch (type) { 27861.1Scgd case TYPE_FLOAT_4: 27871.69Spk case TYPE_FLOATN_4: 27881.16Schristos params[3] = IROUND(v.value_float_4[3]); 27891.12Schristos case TYPE_FLOAT_3: 27901.1Scgd case TYPE_FLOATN_3: 27911.1Scgd params[2] = IROUND(v.value_float_4[2]); 27921.91Schristos case TYPE_FLOAT_2: 27931.91Schristos case TYPE_FLOATN_2: 27941.91Schristos params[1] = IROUND(v.value_float_4[1]); 27951.91Schristos case TYPE_FLOAT: 27961.1Scgd case TYPE_FLOATN: 27971.1Scgd params[0] = IROUND(v.value_float_4[0]); 27981.12Schristos break; 27991.1Scgd 28001.1Scgd case TYPE_DOUBLEN_2: 28011.72Swiz params[1] = IROUND(v.value_double_2[1]); 28021.69Spk case TYPE_DOUBLEN: 28031.69Spk params[0] = IROUND(v.value_double_2[0]); 28041.69Spk break; 28051.69Spk 28061.69Spk case TYPE_INT: 28071.69Spk case TYPE_UINT: 28081.69Spk params[0] = v.value_int; 28091.69Spk break; 28101.69Spk case TYPE_INT_4: 28111.69Spk case TYPE_UINT_4: 28121.69Spk params[0] = v.value_int_4[0]; 28131.69Spk params[1] = v.value_int_4[1]; 28141.69Spk params[2] = v.value_int_4[2]; 28151.69Spk params[3] = v.value_int_4[3]; 28161.69Spk break; 28171.69Spk case TYPE_INT64: 28181.69Spk params[0] = INT64_TO_INT(v.value_int64); 28191.69Spk break; 28201.69Spk default: 28211.69Spk ; /* nothing - GL error was recorded */ 28221.69Spk } 28231.1Scgd} 28241.1Scgd 28251.1Scgdvoid GLAPIENTRY 28261.1Scgd_mesa_GetInteger64i_v( GLenum pname, GLuint index, GLint64 *params ) 28271.1Scgd{ 28281.1Scgd union value v; 28291.1Scgd enum value_type type = 28301.1Scgd find_value_indexed("glGetInteger64i_v", pname, index, &v); 28311.1Scgd 28321.1Scgd switch (type) { 28331.1Scgd case TYPE_INT: 28341.1Scgd params[0] = v.value_int; 28351.1Scgd break; 28361.1Scgd case TYPE_INT_4: 28371.1Scgd params[0] = v.value_int_4[0]; 28381.1Scgd params[1] = v.value_int_4[1]; 28391.1Scgd params[2] = v.value_int_4[2]; 28401.72Swiz params[3] = v.value_int_4[3]; 28411.1Scgd break; 28421.1Scgd case TYPE_UINT: 28431.1Scgd params[0] = (GLuint) v.value_int; 28441.1Scgd break; 28451.1Scgd case TYPE_UINT_4: 28461.1Scgd params[0] = (GLuint) v.value_int_4[0]; 28471.1Scgd params[1] = (GLuint) v.value_int_4[1]; 28481.12Schristos params[2] = (GLuint) v.value_int_4[2]; 28491.1Scgd params[3] = (GLuint) v.value_int_4[3]; 28501.1Scgd break; 28511.1Scgd case TYPE_INT64: 28521.1Scgd params[0] = v.value_int64; 28531.1Scgd break; 28541.1Scgd default: 28551.1Scgd ; /* nothing - GL error was recorded */ 28561.1Scgd } 28571.1Scgd} 28581.1Scgd 28591.1Scgdvoid GLAPIENTRY 28601.1Scgd_mesa_GetFloati_v(GLenum pname, GLuint index, GLfloat *params) 28611.66Spk{ 28621.1Scgd int i; 28631.1Scgd GLmatrix *m; 28641.1Scgd union value v; 28651.1Scgd enum value_type type = 28661.1Scgd find_value_indexed("glGetFloati_v", pname, index, &v); 28671.1Scgd 28681.1Scgd switch (type) { 28691.1Scgd case TYPE_FLOAT_4: 28701.1Scgd case TYPE_FLOATN_4: 28711.1Scgd params[3] = v.value_float_4[3]; 28721.77Schristos case TYPE_FLOAT_3: 28731.1Scgd case TYPE_FLOATN_3: 28741.66Spk params[2] = v.value_float_4[2]; 28751.1Scgd case TYPE_FLOAT_2: 28761.1Scgd case TYPE_FLOATN_2: 28771.66Spk params[1] = v.value_float_4[1]; 28781.66Spk case TYPE_FLOAT: 28791.1Scgd case TYPE_FLOATN: 28801.66Spk params[0] = v.value_float_4[0]; 28811.1Scgd break; 28821.1Scgd 28831.1Scgd case TYPE_DOUBLEN_2: 28841.1Scgd params[1] = (GLfloat) v.value_double_2[1]; 28851.1Scgd case TYPE_DOUBLEN: 28861.1Scgd params[0] = (GLfloat) v.value_double_2[0]; 28871.1Scgd break; 28881.1Scgd 28891.72Swiz case TYPE_INT_4: 28901.72Swiz params[3] = (GLfloat) v.value_int_4[3]; 28911.72Swiz case TYPE_INT_3: 28921.1Scgd params[2] = (GLfloat) v.value_int_4[2]; 28931.1Scgd case TYPE_INT_2: 28941.1Scgd case TYPE_ENUM_2: 28951.1Scgd params[1] = (GLfloat) v.value_int_4[1]; 28961.1Scgd case TYPE_INT: 28971.1Scgd case TYPE_ENUM: 28981.1Scgd case TYPE_ENUM16: 28991.1Scgd params[0] = (GLfloat) v.value_int_4[0]; 29001.1Scgd break; 29011.1Scgd 29021.1Scgd case TYPE_INT_N: 29031.1Scgd for (i = 0; i < v.value_int_n.n; i++) 29041.1Scgd params[i] = (GLfloat) v.value_int_n.ints[i]; 29051.1Scgd break; 29061.1Scgd 29071.1Scgd case TYPE_UINT_4: 29081.1Scgd params[3] = (GLfloat) ((GLuint) v.value_int_4[3]); 29091.1Scgd case TYPE_UINT_3: 29101.66Spk params[2] = (GLfloat) ((GLuint) v.value_int_4[2]); 29111.1Scgd case TYPE_UINT_2: 29121.1Scgd params[1] = (GLfloat) ((GLuint) v.value_int_4[1]); 29131.1Scgd case TYPE_UINT: 29141.1Scgd params[0] = (GLfloat) ((GLuint) v.value_int_4[0]); 29151.1Scgd break; 29161.1Scgd 29171.1Scgd case TYPE_INT64: 29181.1Scgd params[0] = (GLfloat) v.value_int64; 29191.1Scgd break; 29201.1Scgd 29211.1Scgd case TYPE_BOOLEAN: 29221.1Scgd params[0] = BOOLEAN_TO_FLOAT(v.value_bool); 29231.1Scgd break; 29241.1Scgd 29251.1Scgd case TYPE_UBYTE: 29261.1Scgd params[0] = (GLfloat) v.value_ubyte; 29271.1Scgd break; 29281.1Scgd 29291.1Scgd case TYPE_SHORT: 29301.72Swiz params[0] = (GLfloat) v.value_short; 29311.1Scgd break; 29321.65Spk 29331.65Spk case TYPE_MATRIX: 29341.65Spk m = *(GLmatrix **) &v; 29351.65Spk for (i = 0; i < 16; i++) 29361.65Spk params[i] = m->m[i]; 29371.65Spk break; 29381.66Spk 29391.1Scgd case TYPE_MATRIX_T: 29401.24Schristos m = *(GLmatrix **) &v; 29411.1Scgd for (i = 0; i < 16; i++) 29421.1Scgd params[i] = m->m[transpose[i]]; 29431.22Schristos break; 29441.22Schristos 29451.77Schristos default: 29461.22Schristos ; 29471.12Schristos } 29481.16Schristos} 29491.1Scgd 29501.1Scgdvoid GLAPIENTRY 29511.1Scgd_mesa_GetDoublei_v(GLenum pname, GLuint index, GLdouble *params) 29521.77Schristos{ 29531.77Schristos int i; 29541.65Spk GLmatrix *m; 29551.65Spk union value v; 29561.22Schristos enum value_type type = 29571.22Schristos find_value_indexed("glGetDoublei_v", pname, index, &v); 29581.22Schristos 29591.22Schristos switch (type) { 29601.22Schristos case TYPE_FLOAT_4: 29611.22Schristos case TYPE_FLOATN_4: 29621.22Schristos params[3] = (GLdouble) v.value_float_4[3]; 29631.22Schristos case TYPE_FLOAT_3: 29641.22Schristos case TYPE_FLOATN_3: 29651.22Schristos params[2] = (GLdouble) v.value_float_4[2]; 29661.22Schristos case TYPE_FLOAT_2: 29671.22Schristos case TYPE_FLOATN_2: 29681.22Schristos params[1] = (GLdouble) v.value_float_4[1]; 29691.22Schristos case TYPE_FLOAT: 29701.22Schristos case TYPE_FLOATN: 29711.22Schristos params[0] = (GLdouble) v.value_float_4[0]; 29721.22Schristos break; 29731.22Schristos 29741.22Schristos case TYPE_DOUBLEN_2: 29751.12Schristos params[1] = v.value_double_2[1]; 29761.22Schristos case TYPE_DOUBLEN: 29771.22Schristos params[0] = v.value_double_2[0]; 29781.22Schristos break; 29791.22Schristos 29801.83Sjmc case TYPE_INT_4: 29811.83Sjmc params[3] = (GLdouble) v.value_int_4[3]; 29821.83Sjmc case TYPE_INT_3: 29831.83Sjmc params[2] = (GLdouble) v.value_int_4[2]; 29841.22Schristos case TYPE_INT_2: 29851.22Schristos case TYPE_ENUM_2: 29861.22Schristos params[1] = (GLdouble) v.value_int_4[1]; 29871.22Schristos case TYPE_INT: 29881.22Schristos case TYPE_ENUM: 29891.22Schristos case TYPE_ENUM16: 29901.22Schristos params[0] = (GLdouble) v.value_int_4[0]; 29911.22Schristos break; 29921.1Scgd 29931.1Scgd case TYPE_INT_N: 29941.12Schristos for (i = 0; i < v.value_int_n.n; i++) 29951.1Scgd params[i] = (GLdouble) v.value_int_n.ints[i]; 29961.1Scgd break; 29971.1Scgd 29981.1Scgd case TYPE_UINT_4: 29991.1Scgd params[3] = (GLdouble) ((GLuint) v.value_int_4[3]); 30001.1Scgd case TYPE_UINT_3: 30011.12Schristos params[2] = (GLdouble) ((GLuint) v.value_int_4[2]); 30021.12Schristos case TYPE_UINT_2: 30031.66Spk params[1] = (GLdouble) ((GLuint) v.value_int_4[1]); 30041.12Schristos case TYPE_UINT: 30051.1Scgd params[0] = (GLdouble) ((GLuint) v.value_int_4[0]); 30061.66Spk break; 30071.66Spk 30081.66Spk case TYPE_INT64: 30091.66Spk params[0] = (GLdouble) v.value_int64; 30101.66Spk break; 30111.66Spk 30121.66Spk case TYPE_BOOLEAN: 30131.1Scgd params[0] = (GLdouble) BOOLEAN_TO_FLOAT(v.value_bool); 30141.1Scgd break; 30151.1Scgd 30161.1Scgd case TYPE_UBYTE: 30171.16Schristos params[0] = (GLdouble) v.value_ubyte; 30181.1Scgd break; 30191.1Scgd 30201.1Scgd case TYPE_SHORT: 30211.1Scgd params[0] = (GLdouble) v.value_short; 30221.1Scgd break; 30231.1Scgd 30241.12Schristos case TYPE_MATRIX: 30251.12Schristos m = *(GLmatrix **) &v; 30261.77Schristos for (i = 0; i < 16; i++) 30271.1Scgd params[i] = (GLdouble) m->m[i]; 30281.1Scgd break; 30291.1Scgd 30301.12Schristos case TYPE_MATRIX_T: 30311.1Scgd m = *(GLmatrix **) &v; 30321.1Scgd for (i = 0; i < 16; i++) 30331.1Scgd params[i] = (GLdouble) m->m[transpose[i]]; 30341.1Scgd break; 30351.1Scgd 30361.66Spk default: 30371.66Spk ; 30381.66Spk } 30391.66Spk} 30401.66Spk 30411.66Spkvoid GLAPIENTRY 30421.66Spk_mesa_GetUnsignedBytei_vEXT(GLenum target, GLuint index, GLubyte *data) 30431.1Scgd{ 30441.89Schristos GLsizei size; 30451.1Scgd union value v; 30461.1Scgd enum value_type type; 30471.1Scgd const char *func = "glGetUnsignedBytei_vEXT"; 30481.1Scgd 30491.1Scgd GET_CURRENT_CONTEXT(ctx); 30501.1Scgd 30511.1Scgd if (!ctx->Extensions.EXT_memory_object) { 30521.16Schristos _mesa_error(ctx, GL_INVALID_OPERATION, "%s(unsupported)", func); 30531.1Scgd return; 30541.12Schristos } 30551.1Scgd 30561.1Scgd type = find_value_indexed(func, target, index, &v); 30571.12Schristos size = get_value_size(type, &v); 30581.1Scgd if (size <= 0) { 30591.1Scgd _mesa_problem(ctx, "invalid value type in GetUnsignedBytei_vEXT()"); 30601.1Scgd } 30611.16Schristos 30621.1Scgd switch (type) { 30631.1Scgd case TYPE_UINT: 30641.22Schristos case TYPE_INT: 30651.1Scgd case TYPE_INT_2: 30661.12Schristos case TYPE_UINT_2: 30671.1Scgd case TYPE_INT_3: 30681.1Scgd case TYPE_UINT_3: 30691.1Scgd case TYPE_INT_4: 30701.1Scgd case TYPE_UINT_4: 30711.1Scgd case TYPE_INT64: 30721.1Scgd case TYPE_ENUM16: 30731.1Scgd case TYPE_ENUM: 30741.1Scgd case TYPE_ENUM_2: 30751.72Swiz case TYPE_BOOLEAN: 30761.72Swiz case TYPE_UBYTE: 30771.72Swiz case TYPE_SHORT: 30781.72Swiz case TYPE_FLOAT: 30791.72Swiz case TYPE_FLOATN: 30801.1Scgd case TYPE_FLOAT_2: 30811.1Scgd case TYPE_FLOATN_2: 30821.1Scgd case TYPE_FLOAT_3: 30831.1Scgd case TYPE_FLOATN_3: 30841.1Scgd case TYPE_FLOAT_4: 30851.1Scgd case TYPE_FLOATN_4: 30861.1Scgd case TYPE_FLOAT_8: 30871.1Scgd case TYPE_DOUBLEN: 30881.1Scgd case TYPE_DOUBLEN_2: 30891.72Swiz case TYPE_MATRIX: 30901.69Spk case TYPE_MATRIX_T: 30911.69Spk memcpy(data, &v.value_int, size); 30921.69Spk break; 30931.69Spk case TYPE_INT_N: 30941.69Spk memcpy(data, &v.value_int_n.ints, size); 30951.16Schristos break; 30961.1Scgd default: 30971.1Scgd break; /* nothing - GL error was recorded */ 30981.69Spk } 30991.69Spk} 31001.69Spk 31011.12Schristosvoid GLAPIENTRY 31021.67Spk_mesa_GetFixedv(GLenum pname, GLfixed *params) 31031.67Spk{ 31041.12Schristos const struct value_desc *d; 31051.67Spk union value v; 31061.1Scgd GLmatrix *m; 31071.67Spk int shift, i; 31081.67Spk void *p; 31091.12Schristos 31101.12Schristos d = find_value("glGetDoublev", pname, &p, &v); 31111.1Scgd switch (d->type) { 31121.1Scgd case TYPE_INVALID: 31131.1Scgd break; 31141.1Scgd case TYPE_CONST: 31151.1Scgd params[0] = INT_TO_FIXED(d->offset); 31161.1Scgd break; 31171.1Scgd 31181.12Schristos case TYPE_FLOAT_4: 31191.1Scgd case TYPE_FLOATN_4: 31201.1Scgd params[3] = FLOAT_TO_FIXED(((GLfloat *) p)[3]); 31211.1Scgd case TYPE_FLOAT_3: 31221.1Scgd case TYPE_FLOATN_3: 31231.13Schristos params[2] = FLOAT_TO_FIXED(((GLfloat *) p)[2]); 31241.1Scgd case TYPE_FLOAT_2: 31251.1Scgd case TYPE_FLOATN_2: 31261.1Scgd params[1] = FLOAT_TO_FIXED(((GLfloat *) p)[1]); 31271.12Schristos case TYPE_FLOAT: 31281.1Scgd case TYPE_FLOATN: 31291.1Scgd params[0] = FLOAT_TO_FIXED(((GLfloat *) p)[0]); 31301.12Schristos break; 31311.1Scgd 31321.1Scgd case TYPE_DOUBLEN_2: 31331.1Scgd params[1] = FLOAT_TO_FIXED(((GLdouble *) p)[1]); 31341.12Schristos case TYPE_DOUBLEN: 31351.12Schristos params[0] = FLOAT_TO_FIXED(((GLdouble *) p)[0]); 31361.69Spk break; 31371.69Spk 31381.12Schristos case TYPE_INT_4: 31391.12Schristos case TYPE_UINT_4: 31401.12Schristos params[3] = INT_TO_FIXED(((GLint *) p)[3]); 31411.12Schristos case TYPE_INT_3: 31421.12Schristos case TYPE_UINT_3: 31431.12Schristos params[2] = INT_TO_FIXED(((GLint *) p)[2]); 31441.62Spk case TYPE_INT_2: 31451.12Schristos case TYPE_UINT_2: 31461.12Schristos case TYPE_ENUM_2: 31471.12Schristos params[1] = INT_TO_FIXED(((GLint *) p)[1]); 31481.12Schristos case TYPE_INT: 31491.67Spk case TYPE_UINT: 31501.67Spk case TYPE_ENUM: 31511.12Schristos params[0] = INT_TO_FIXED(((GLint *) p)[0]); 31521.67Spk break; 31531.12Schristos 31541.12Schristos case TYPE_ENUM16: 31551.12Schristos params[0] = INT_TO_FIXED((GLint)(((GLenum16 *) p)[0])); 31561.12Schristos break; 31571.12Schristos 31581.12Schristos case TYPE_INT_N: 31591.12Schristos for (i = 0; i < v.value_int_n.n; i++) 31601.12Schristos params[i] = INT_TO_FIXED(v.value_int_n.ints[i]); 31611.12Schristos break; 31621.12Schristos 31631.67Spk case TYPE_INT64: 31641.67Spk params[0] = ((GLint64 *) p)[0]; 31651.12Schristos break; 31661.12Schristos 31671.12Schristos case TYPE_BOOLEAN: 31681.12Schristos params[0] = BOOLEAN_TO_FIXED(((GLboolean*) p)[0]); 31691.12Schristos break; 31701.12Schristos 31711.12Schristos case TYPE_UBYTE: 31721.12Schristos params[0] = INT_TO_FIXED(((GLubyte *) p)[0]); 31731.12Schristos break; 31741.16Schristos 31751.12Schristos case TYPE_SHORT: 31761.12Schristos params[0] = INT_TO_FIXED(((GLshort *) p)[0]); 31771.12Schristos break; 31781.12Schristos 31791.12Schristos case TYPE_MATRIX: 31801.12Schristos m = *(GLmatrix **) p; 31811.12Schristos for (i = 0; i < 16; i++) 31821.12Schristos params[i] = FLOAT_TO_FIXED(m->m[i]); 31831.12Schristos break; 31841.12Schristos 31851.12Schristos case TYPE_MATRIX_T: 31861.12Schristos m = *(GLmatrix **) p; 31871.12Schristos for (i = 0; i < 16; i++) 31881.12Schristos params[i] = FLOAT_TO_FIXED(m->m[transpose[i]]); 31891.13Schristos break; 31901.12Schristos 31911.12Schristos case TYPE_BIT_0: 31921.12Schristos case TYPE_BIT_1: 31931.12Schristos case TYPE_BIT_2: 31941.12Schristos case TYPE_BIT_3: 31951.12Schristos case TYPE_BIT_4: 31961.12Schristos case TYPE_BIT_5: 31971.12Schristos case TYPE_BIT_6: 31981.12Schristos case TYPE_BIT_7: 31991.12Schristos shift = d->type - TYPE_BIT_0; 32001.12Schristos params[0] = BOOLEAN_TO_FIXED((*(GLbitfield *) p >> shift) & 1); 32011.1Scgd break; 32021.1Scgd } 32031.1Scgd} 32041.1Scgd